There is no separate method per operation, deliberately: the set of actions differs by provider, and a single entry point lets the same code hold whichever storage it was given.
await storage.run({ action: "collections" });
await storage.run({ action: "find", collection: "users", filter: { active: true },
options: { limit: 20, skip: 0 } });
await storage.run({ action: "execute", sql: "SELECT id, name FROM users LIMIT 20" });
await storage.run({ action: "list", prefix: "invoices/" });storage.run(action="collections")
storage.run(action="find", collection="users", filter={"active": True},
options={"limit": 20, "skip": 0})
storage.run(action="execute", sql="SELECT id, name FROM users LIMIT 20")
storage.run(action="list", prefix="invoices/")Reading
| action | On | Gives back |
|---|---|---|
| overview | any | What is in there, in one call — the cheapest way to orient yourself. |
| collections | a document database | Every collection, with its count. |
| schema | a document database | The fields seen in recent documents, with their types. |
| find | a document database | Documents matching a filter. |
| count | a document database | How many match. |
| aggregate | a document database | The result of a pipeline. |
| tables | a relational database | Every table, with its columns. |
| execute | a relational database | The rows a statement returns. |
| list | object storage | Keys, optionally under a prefix. |
| object | object storage | One object's bytes. |
| usage | any | How much space is taken. |
| search | any | Documents found by meaning — the one action that costs. |
Writing
| action | On | Does |
|---|---|---|
| insert | a document database | Adds documents. |
| update | a document database | Changes those that match. |
| delete | a document database, object storage | Removes documents, or an object. |
| save | a document database | Inserts or replaces, by identity. |
| createCollection | a document database | Makes a collection. |
| dropCollection | a document database | Removes one, and everything in it. |
| upload | object storage | Puts bytes under a key. |
| execute | a relational database | Runs a statement that changes data. |
The same action reads and writes on a relational database — the statement decides. A guard that trusts the action name rather than the statement is not a guard.
Object-shaped arguments travel as JSON text
A filter, a pipeline, an update, a list of documents — send them as a JSON string, not as an object. This is not a style preference: a model asked to produce a nested object strips keys beginning with $, and every aggregate then fails for a reason nothing explains.
await storage.run({
action: "aggregate",
collection: "orders",
pipeline: JSON.stringify([
{ $match: { status: "paid" } },
{ $group: { _id: "$country", total: { $sum: "$amount" } } },
{ $sort: { total: -1 } },
]),
});import json
storage.run(
action="aggregate",
collection="orders",
pipeline=json.dumps([
{"$match": {"status": "paid"}},
{"$group": {"_id": "$country", "total": {"$sum": "$amount"}}},
{"$sort": {"total": -1}},
]),
)What is refused, and why
| Refused | Reason |
|---|---|
| An update or delete with an empty filter | It matches everything. Pass all: true to mean it. |
| A statement with no WHERE | Same reasoning, on the relational side. |
| Several statements in one execute | One statement, so one thing can be judged. |
| $where · $function · $accumulator | They run code inside the database. |
| $out · $merge | A pipeline that writes somewhere else is not a read. |
These run before anything is asked of the storage, and before an agent's permission prompt — so a refusal costs nothing and asks nobody.
// Refused: matches every document
await storage.run({ action: "delete", collection: "logs", filter: JSON.stringify({}) });
// Accepted: you said so
await storage.run({ action: "delete", collection: "logs", filter: JSON.stringify({}), all: true });import json
# Refused: matches every document
storage.run(action="delete", collection="logs", filter=json.dumps({}))
# Accepted: you said so
storage.run(action="delete", collection="logs", filter=json.dumps({}), all=True)What it costs
Every action is free except search, which costs one credit. That credit is taken before the call and refunded on any refusal — including an unknown storage id, which vectorised nothing.
const found = await storage.run({ action: "search", query: "refund policy", limit: 5 });
// { results: [{ text, score, source: { id, name, index } }], scanned, model, creditsUsed: 1 }found = storage.run(action="search", query="refund policy", limit=5)
# {"results": [{"text", "score", "source": {"id", "name", "index"}}], "scanned", "model", "creditsUsed": 1}Documents uploaded to a storage are indexed on our side when they arrive, so the same action works for a document database, a relational one and a bucket alike. Without an embedding service it refuses with embedding_unavailable rather than answering on a fallback that is not semantic.
Errors
| Code | Status | When |
|---|---|---|
| storage_id_required | 400 | No storage was named. |
| storage_not_found | 404 | No active storage of this account with that id. |
| unsupported_provider_for_run | 400 | That provider has no data to run against. |
| quota_exceeded | 403 | A write past the plan's space. Reads and deletes still work. |
| embedding_unavailable | 503 | search only, and it refuses rather than guessing. |
A refusal from the storage itself keeps its own message, so a rejected statement reads as the database explained it rather than as a bare status.
A connected storage is not tested until you run something
connect() registers without opening the connection. Run a cheap read right after connecting — collections, or tables — so a wrong URI fails where you are looking.