@aui.io/apollo 0.1.81 → 0.1.82

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -87,6 +87,60 @@ export interface MockDbIdentitiesUpsertResponse {
87
87
  personas?: number;
88
88
  [key: string]: unknown;
89
89
  }
90
+ /** How `POST …/rows` treats rows whose primary key already exists. */
91
+ export declare const MOCKDB_SEED_MODES: readonly ["append", "upsert", "replace"];
92
+ export type MockDbSeedMode = (typeof MOCKDB_SEED_MODES)[number];
93
+ export interface MockDbSeedOptions {
94
+ /** append (default): duplicate key → 409; upsert: patch existing keys; replace: truncate first. */
95
+ mode?: MockDbSeedMode;
96
+ /** false → the reply carries counts only, not the stored rows (for large imports). */
97
+ echo?: boolean;
98
+ /** replace only: also empty collections that reference this one (child-first). */
99
+ cascade?: boolean;
100
+ }
101
+ export interface MockDbSeedResponse {
102
+ collection?: string;
103
+ mode?: MockDbSeedMode;
104
+ inserted?: number;
105
+ updated?: number;
106
+ deleted?: number;
107
+ /** replace: the collections emptied first, child-first. */
108
+ replaced?: string[];
109
+ rows?: unknown[];
110
+ [key: string]: unknown;
111
+ }
112
+ export interface MockDbTruncateResponse {
113
+ collection?: string;
114
+ truncated?: string[];
115
+ rowsDeleted?: Record<string, number>;
116
+ overlayCleared?: number;
117
+ [key: string]: unknown;
118
+ }
119
+ /** What `POST …/reset` may clear. `data` keeps schemas + endpoints + personas; `all` keeps only the agent + keys. */
120
+ export declare const MOCKDB_RESET_SCOPES: readonly ["data", "all"];
121
+ export type MockDbResetScope = (typeof MOCKDB_RESET_SCOPES)[number];
122
+ export interface MockDbResetResponse {
123
+ agentId?: string;
124
+ scope?: MockDbResetScope;
125
+ collections?: string[];
126
+ rowsDeleted?: number;
127
+ overlayCleared?: number;
128
+ sessionsCleared?: number;
129
+ endpointsDeleted?: number;
130
+ personasCleared?: number;
131
+ /** The service's own word for it: the agent record was never touched. */
132
+ keys?: "unchanged";
133
+ runtimeKeyPrefix?: string | null;
134
+ mgmtKeyPrefix?: string | null;
135
+ [key: string]: unknown;
136
+ }
137
+ export interface MockDbRowsPage {
138
+ collection?: string;
139
+ rows?: unknown[];
140
+ count?: number;
141
+ total?: number;
142
+ [key: string]: unknown;
143
+ }
90
144
  export interface MockDbClientOptions {
91
145
  baseUrl: string;
92
146
  timeoutMs?: number;
@@ -123,7 +177,34 @@ export declare class MockDbClient {
123
177
  updateCollection(agentId: string, auth: MockDbAuth, name: string, body: {
124
178
  addColumns: unknown[];
125
179
  }): Promise<unknown>;
126
- seedRows(agentId: string, auth: MockDbAuth, collection: string, rows: unknown[]): Promise<unknown>;
180
+ /** Drop a collection and its table. The service cascades FKs at the table level. */
181
+ deleteCollection(agentId: string, auth: MockDbAuth, name: string): Promise<unknown>;
182
+ seedRows(agentId: string, auth: MockDbAuth, collection: string, rows: unknown[], options?: MockDbSeedOptions): Promise<MockDbSeedResponse>;
183
+ /** Page through a collection's BASE rows (the seed, not any session's view). */
184
+ listRows(agentId: string, auth: MockDbAuth, collection: string, page?: {
185
+ limit?: number;
186
+ offset?: number;
187
+ resolve?: boolean;
188
+ }): Promise<MockDbRowsPage>;
189
+ /**
190
+ * Truncate: every base row of the collection plus its overlay records in
191
+ * every session. A parent whose dependents hold rows is a 409 unless
192
+ * `cascade`, which empties the dependents too, child-first.
193
+ */
194
+ truncateCollection(agentId: string, auth: MockDbAuth, collection: string, options?: {
195
+ cascade?: boolean;
196
+ }): Promise<MockDbTruncateResponse>;
197
+ /** Patch one BASE row by its primary-key value (or full `__lid`). Body = partial column values. */
198
+ patchRow(agentId: string, auth: MockDbAuth, collection: string, id: string, patch: Record<string, unknown>): Promise<unknown>;
199
+ /** Remove one BASE row by its primary-key value (or full `__lid`). */
200
+ deleteRow(agentId: string, auth: MockDbAuth, collection: string, id: string): Promise<unknown>;
201
+ /**
202
+ * Key-stable reset. Unlike `deleteAgent`, the agent record — and so both
203
+ * keys, and everything wired to the runtime key — is never touched.
204
+ */
205
+ resetAgent(agentId: string, auth: MockDbAuth, options?: {
206
+ scope?: MockDbResetScope;
207
+ }): Promise<MockDbResetResponse>;
127
208
  createEndpoint(agentId: string, auth: MockDbAuth, body: Record<string, unknown>): Promise<unknown>;
128
209
  listEndpoints(agentId: string, auth: MockDbAuth): Promise<unknown>;
129
210
  getEndpoint(agentId: string, auth: MockDbAuth, slug: string): Promise<unknown>;
@@ -9,7 +9,13 @@
9
9
  * POST /api/agents/{agentId}/collections → create collection
10
10
  * GET /api/agents/{agentId}/collections → list collections
11
11
  * PATCH /api/agents/{agentId}/collections/{name} → add columns
12
- * POST /api/agents/{agentId}/collections/{name}/rows → seed base rows
12
+ * DELETE /api/agents/{agentId}/collections/{name} → drop a collection
13
+ * POST /api/agents/{agentId}/collections/{name}/rows → seed base rows (mode: append|upsert|replace)
14
+ * GET /api/agents/{agentId}/collections/{name}/rows → list base rows (paged, with total)
15
+ * DELETE /api/agents/{agentId}/collections/{name}/rows → truncate a collection (?cascade=true)
16
+ * PATCH /api/agents/{agentId}/collections/{name}/rows/{id} → edit one base row
17
+ * DELETE /api/agents/{agentId}/collections/{name}/rows/{id} → remove one base row
18
+ * POST /api/agents/{agentId}/reset → key-stable reset (scope: data|all)
13
19
  * POST /api/agents/{agentId}/endpoints → create endpoint
14
20
  * GET /api/agents/{agentId}/endpoints → list endpoints
15
21
  * GET /api/agents/{agentId}/endpoints/{slug} → get one endpoint
@@ -51,6 +57,10 @@ import { randomUUID } from "node:crypto";
51
57
  import { ApiError, CliError } from "../errors/index.js";
52
58
  import { captureLog } from "./capture.js";
53
59
  import { redact, redactHeaderRecord } from "./transport.js";
60
+ /** How `POST …/rows` treats rows whose primary key already exists. */
61
+ export const MOCKDB_SEED_MODES = ["append", "upsert", "replace"];
62
+ /** What `POST …/reset` may clear. `data` keeps schemas + endpoints + personas; `all` keeps only the agent + keys. */
63
+ export const MOCKDB_RESET_SCOPES = ["data", "all"];
54
64
  export const MOCKDB_SERVICE_NAME = "mock-db";
55
65
  function authHeaders(auth) {
56
66
  if (auth.mode === "token") {
@@ -135,8 +145,61 @@ export class MockDbClient {
135
145
  updateCollection(agentId, auth, name, body) {
136
146
  return this.request(`/api/agents/${encodeURIComponent(agentId)}/collections/${encodeURIComponent(name)}`, { method: "PATCH", auth, body });
137
147
  }
138
- seedRows(agentId, auth, collection, rows) {
139
- return this.request(`/api/agents/${encodeURIComponent(agentId)}/collections/${encodeURIComponent(collection)}/rows`, { method: "POST", auth, body: { rows } });
148
+ /** Drop a collection and its table. The service cascades FKs at the table level. */
149
+ deleteCollection(agentId, auth, name) {
150
+ return this.request(`/api/agents/${encodeURIComponent(agentId)}/collections/${encodeURIComponent(name)}`, { method: "DELETE", auth });
151
+ }
152
+ seedRows(agentId, auth, collection, rows, options = {}) {
153
+ return this.request(`/api/agents/${encodeURIComponent(agentId)}/collections/${encodeURIComponent(collection)}/rows`, {
154
+ method: "POST",
155
+ auth,
156
+ body: {
157
+ rows,
158
+ ...(options.mode === undefined ? {} : { mode: options.mode }),
159
+ ...(options.echo === undefined ? {} : { echo: options.echo }),
160
+ ...(options.cascade === undefined ? {} : { cascade: options.cascade }),
161
+ },
162
+ });
163
+ }
164
+ /** Page through a collection's BASE rows (the seed, not any session's view). */
165
+ listRows(agentId, auth, collection, page = {}) {
166
+ const query = new URLSearchParams();
167
+ if (page.limit !== undefined)
168
+ query.set("limit", String(page.limit));
169
+ if (page.offset !== undefined)
170
+ query.set("offset", String(page.offset));
171
+ if (page.resolve)
172
+ query.set("resolve", "true");
173
+ const suffix = query.size > 0 ? `?${query.toString()}` : "";
174
+ return this.request(`/api/agents/${encodeURIComponent(agentId)}/collections/${encodeURIComponent(collection)}/rows${suffix}`, { method: "GET", auth });
175
+ }
176
+ /**
177
+ * Truncate: every base row of the collection plus its overlay records in
178
+ * every session. A parent whose dependents hold rows is a 409 unless
179
+ * `cascade`, which empties the dependents too, child-first.
180
+ */
181
+ truncateCollection(agentId, auth, collection, options = {}) {
182
+ const suffix = options.cascade ? "?cascade=true" : "";
183
+ return this.request(`/api/agents/${encodeURIComponent(agentId)}/collections/${encodeURIComponent(collection)}/rows${suffix}`, { method: "DELETE", auth });
184
+ }
185
+ /** Patch one BASE row by its primary-key value (or full `__lid`). Body = partial column values. */
186
+ patchRow(agentId, auth, collection, id, patch) {
187
+ return this.request(`/api/agents/${encodeURIComponent(agentId)}/collections/${encodeURIComponent(collection)}/rows/${encodeURIComponent(id)}`, { method: "PATCH", auth, body: patch });
188
+ }
189
+ /** Remove one BASE row by its primary-key value (or full `__lid`). */
190
+ deleteRow(agentId, auth, collection, id) {
191
+ return this.request(`/api/agents/${encodeURIComponent(agentId)}/collections/${encodeURIComponent(collection)}/rows/${encodeURIComponent(id)}`, { method: "DELETE", auth });
192
+ }
193
+ /**
194
+ * Key-stable reset. Unlike `deleteAgent`, the agent record — and so both
195
+ * keys, and everything wired to the runtime key — is never touched.
196
+ */
197
+ resetAgent(agentId, auth, options = {}) {
198
+ return this.request(`/api/agents/${encodeURIComponent(agentId)}/reset`, {
199
+ method: "POST",
200
+ auth,
201
+ body: options.scope === undefined ? {} : { scope: options.scope },
202
+ });
140
203
  }
141
204
  createEndpoint(agentId, auth, body) {
142
205
  return this.request(`/api/agents/${encodeURIComponent(agentId)}/endpoints`, {
@@ -1 +1 @@
1
- {"version":3,"file":"mock-db.js","sourceRoot":"","sources":["../../../src/api/mock-db.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAoB,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAuB,MAAM,gBAAgB,CAAC;AA4GjF,MAAM,CAAC,MAAM,mBAAmB,GAAG,SAAS,CAAC;AAE7C,SAAS,WAAW,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I,IAAI,CAAC,WAAW,KAAK,KAAK,EAAE,CAAC;gBAC/B,qDAAqD;gBACrD,MAAM,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;YAC7D,CAAC;QACH,CAAC;IACH,CAAC;CACF;AAED,iFAAiF;AACjF,SAAS,cAAc,CAAC,MAAe;IACrC,MAAM,OAAO,GAAI,MAAmD,EAAE,KAAK,EAAE,OAAO,CAAC;IACrF,OAAO,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AACtE,CAAC;AAED,2FAA2F;AAC3F,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,IAAI,CAAC,CAAC,KAAK,YAAY,QAAQ,CAAC;QAAE,OAAO,SAAS,CAAC;IACnD,MAAM,IAAI,GAAI,KAAK,CAAC,MAAgD,EAAE,KAAK,EAAE,IAAI,CAAC;IAClF,OAAO,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;AACrD,CAAC;AAED,iGAAiG;AACjG,MAAM,UAAU,sBAAsB,CAAC,KAAc;IACnD,OAAO,KAAK,YAAY,QAAQ,IAAI,KAAK,CAAC,IAAI,KAAK,eAAe,CAAC;AACrE,CAAC"}
@@ -1,4 +1,4 @@
1
- import { MockDbClient, type MockDbCloneResponse, type MockDbIdentitiesResponse, type MockDbIdentitiesUpsertResponse, type MockDbProvisionResponse, type MockDbSampleData, type MockDbStatusResponse, type MockDbTokenAuth } from "../api/mock-db.js";
1
+ import { MockDbClient, type MockDbCloneResponse, type MockDbIdentitiesResponse, type MockDbIdentitiesUpsertResponse, type MockDbProvisionResponse, type MockDbResetResponse, type MockDbResetScope, type MockDbRowsPage, type MockDbSampleData, type MockDbSeedMode, type MockDbSeedResponse, type MockDbStatusResponse, type MockDbTokenAuth, type MockDbTruncateResponse } from "../api/mock-db.js";
2
2
  import type { Context } from "../config/index.js";
3
3
  import { keyPrefixes } from "../config/mockdb-keys.js";
4
4
  /** Env var the wired `connections.yaml` reads the runtime key from by default. */
@@ -48,7 +48,88 @@ export declare function statusMockDb(context: Context, options?: MockDbServiceOp
48
48
  export declare function createCollection(context: Context, name: string, schema: unknown, options?: MockDbServiceOptions): Promise<unknown>;
49
49
  export declare function listCollections(context: Context, options?: MockDbServiceOptions): Promise<unknown>;
50
50
  export declare function updateCollection(context: Context, name: string, addColumns: unknown[], options?: MockDbServiceOptions): Promise<unknown>;
51
- export declare function seedRows(context: Context, collection: string, rows: unknown[], options?: MockDbServiceOptions): Promise<unknown>;
51
+ export interface SeedRowsOptions extends MockDbServiceOptions {
52
+ /** append (default) / upsert / replace — see `MockDbSeedOptions`. */
53
+ mode?: MockDbSeedMode;
54
+ /** false → counts only in the reply (the CLI's choice for a file import). */
55
+ echo?: boolean;
56
+ /** replace only: also empty collections that reference this one. */
57
+ cascade?: boolean;
58
+ }
59
+ /** One request. Rows of any count ride it (the service batches its INSERTs); a file import batches on top (`seedRowsFromFile`). */
60
+ export declare function seedRows(context: Context, collection: string, rows: unknown[], options?: SeedRowsOptions): Promise<MockDbSeedResponse>;
61
+ /** Rows per request when a file is imported; well under any body-size limit for ordinary rows. */
62
+ export declare const DEFAULT_SEED_BATCH_SIZE = 500;
63
+ export interface SeedFileOptions extends SeedRowsOptions {
64
+ /** Rows per request (default `DEFAULT_SEED_BATCH_SIZE`). */
65
+ batchSize?: number;
66
+ /** Called after every batch lands. */
67
+ onProgress?: (progress: {
68
+ batch: number;
69
+ batches: number;
70
+ sent: number;
71
+ total: number;
72
+ }) => void;
73
+ }
74
+ export interface SeedFileResult {
75
+ file: string;
76
+ collection: string;
77
+ mode: MockDbSeedMode;
78
+ rowsRead: number;
79
+ batchSize: number;
80
+ batches: number;
81
+ inserted: number;
82
+ updated: number;
83
+ deleted: number;
84
+ /** replace: the collections the first batch emptied, child-first. */
85
+ replaced: string[];
86
+ }
87
+ /**
88
+ * Parse a seed file: a JSON array, the `{ "rows": [...] }` wrapper the service
89
+ * body uses, or NDJSON / JSON Lines (one object per line, blank lines ignored).
90
+ * The shape is detected from the content, not the extension, so `.json`,
91
+ * `.ndjson` and `.jsonl` all work.
92
+ */
93
+ export declare function parseRowsFile(text: string, where: string): unknown[];
94
+ /** Read + parse a seed file from disk. */
95
+ export declare function readRowsFile(file: string): Promise<{
96
+ path: string;
97
+ rows: unknown[];
98
+ }>;
99
+ /**
100
+ * Seed a whole file in batches, sequentially, stopping at the first failure.
101
+ *
102
+ * `replace` is honoured by the FIRST batch only — it truncates and inserts in
103
+ * one service transaction — and the rest append, so the collection ends up
104
+ * holding exactly the file. `upsert` rides every batch (and is safe to
105
+ * re-run); `append` rides every batch. Nothing is auto-retried: a failed batch
106
+ * is reported with exactly which rows landed, so the caller re-sends only
107
+ * what is missing (or re-runs the whole file with `upsert`).
108
+ */
109
+ export declare function seedRowsFromFile(context: Context, collection: string, file: string, options?: SeedFileOptions): Promise<SeedFileResult>;
110
+ export declare function listRows(context: Context, collection: string, page?: {
111
+ limit?: number;
112
+ offset?: number;
113
+ resolve?: boolean;
114
+ }, options?: MockDbServiceOptions): Promise<MockDbRowsPage>;
115
+ export declare function patchRow(context: Context, collection: string, id: string, patch: Record<string, unknown>, options?: MockDbServiceOptions): Promise<unknown>;
116
+ export declare function deleteRow(context: Context, collection: string, id: string, options?: MockDbServiceOptions): Promise<unknown>;
117
+ export declare function truncateCollection(context: Context, name: string, options?: MockDbServiceOptions & {
118
+ cascade?: boolean;
119
+ }): Promise<MockDbTruncateResponse>;
120
+ export declare function deleteCollection(context: Context, name: string, options?: MockDbServiceOptions): Promise<unknown>;
121
+ /**
122
+ * The key-stable reset. The local key cache is deliberately NOT cleared —
123
+ * the service never touched the agent record, so the stored keys are still
124
+ * the live ones; `delete` is the command that forgets them.
125
+ */
126
+ export declare function resetMockDb(context: Context, options?: MockDbServiceOptions & {
127
+ scope?: MockDbResetScope;
128
+ }): Promise<MockDbResetResponse>;
129
+ /** Parse `--mode`; undefined means append. */
130
+ export declare function parseSeedMode(raw: string | undefined): MockDbSeedMode | undefined;
131
+ /** Parse `--scope`; undefined means data. */
132
+ export declare function parseResetScope(raw: string | undefined): MockDbResetScope | undefined;
52
133
  export declare function createEndpoint(context: Context, body: Record<string, unknown>, options?: MockDbServiceOptions): Promise<unknown>;
53
134
  export declare function listEndpoints(context: Context, options?: MockDbServiceOptions): Promise<unknown>;
54
135
  export declare function getEndpoint(context: Context, slug: string, options?: MockDbServiceOptions): Promise<unknown>;
@@ -153,7 +234,7 @@ export declare function normalizeSchema(raw: unknown): {
153
234
  */
154
235
  export declare function normalizeAddColumns(raw: unknown): unknown[];
155
236
  /** The text emitted by `apollo mockdb guide` — the how-to for driving the mock DB. */
156
- export declare const MOCKDB_GUIDE = "# Mock DB \u2014 Apollo CLI Guide\n\nA per-agent **mock database** for building and testing agents that have no\nreal backend (or no test environment) yet. You define collections (tables),\nseed realistic data, and declare named read/write endpoints; the agent's\nprogram sources then call those endpoints at runtime through a\n`connections.yaml` connection. It supports relative date/time fields\n(`now-30d`) that stay fresh, and per-conversation copy-on-write keyed by the\nsession id, so test runs are isolated and resettable.\n\nAll `apollo mockdb` commands are **non-interactive**. Pass the global\n`--json` for the machine envelope (`{ \"success\": true, \"data\": ... }`).\n\n## How auth works (and why it's safe)\n\n- The agent comes from the checkout you are standing in (`.apollorc`) or\n `--agent <id>`; the account from the active project (`--account <id>` or\n `APOLLO_ACCOUNT_ID` to override).\n- Your Apollo token is sent **first-party from the CLI** only where the\n service demands it: `provision`, `status`, `delete`, and minting a\n management key. The service verifies it against Apollo (you must be a\n member of the agent's account).\n- Provision returns two per-agent keys, stored under `~/.apollo/mockdb/`:\n - **managementKey** \u2014 used for ALL other management calls (`X-Mgmt-Key`;\n no Apollo token transmitted). Minted on demand if missing/rejected.\n - **runtimeKey** \u2014 what the agent's connection uses at runtime; also what\n `apollo mockdb execute` uses to test endpoints.\n\n## Typical workflow\n\n```bash\n# 1. Provision (stores the keys) and wire bundle/src/connections.yaml\napollo mockdb provision --wire\n\n# 2. Create collections (parents before children \u2014 FKs need the parent first)\napollo mockdb collections create --name users \\\n --schema '{\"columns\":[{\"name\":\"id\",\"type\":\"text\",\"primaryKey\":true},{\"name\":\"name\",\"type\":\"text\"}]}'\napollo mockdb collections create --name accounts \\\n --schema '{\"columns\":[{\"name\":\"id\",\"type\":\"text\",\"primaryKey\":true},{\"name\":\"user_id\",\"type\":\"text\",\"references\":\"users.id\"},{\"name\":\"balance\",\"type\":\"number\"},{\"name\":\"opened_at\",\"type\":\"reldate\"}]}'\n\n# 3. Seed data (relative date tokens allowed)\napollo mockdb seed --collection users --rows '[{\"id\":\"U1\",\"name\":\"Ada Lovelace\"}]'\napollo mockdb seed --collection accounts --rows '[{\"id\":\"A1\",\"user_id\":\"U1\",\"balance\":4200.5,\"opened_at\":\"now-400d\"}]'\n\n# 4. Declare the endpoints the agent will call\napollo mockdb endpoint create --slug get-accounts \\\n --param-schema '{\"user_id\":{\"type\":\"string\",\"required\":true}}' \\\n --spec '{\"kind\":\"read\",\"collection\":\"accounts\",\"where\":[{\"column\":\"user_id\",\"op\":\"eq\",\"param\":\"user_id\"}]}'\n\n# 4b. A read keyed by a SET of ids: op \"in\" + a param declared { \"type\": \"array\" }\napollo mockdb endpoint create --slug accounts-by-ids \\\n --param-schema '{\"ids\":{\"type\":\"array\",\"required\":true}}' \\\n --spec '{\"kind\":\"read\",\"collection\":\"accounts\",\"where\":[{\"column\":\"id\",\"op\":\"in\",\"param\":\"ids\"}]}'\n\n# 5. Test an endpoint under a session (runtime key + session = a conversation)\napollo mockdb execute --slug get-accounts --session test-1 --body '{\"user_id\":\"U1\"}'\napollo mockdb execute --slug accounts-by-ids --body '{\"ids\":[\"A1\",\"A3\"]}'\n\n# 6. Inspect / reset that session's overlay\napollo mockdb session get --key test-1\napollo mockdb session reset --key test-1\n```\n\nThen map each program source that names `connection: mock-db` to an endpoint\nunder `operations` in `bundle/src/connections.yaml` (`method: POST`,\n`path: /<slug>/execute`, `rows: $.data.rows` -- the stub `wire` writes carries\nthe template), export the runtime key as `MOCKDB_TOKEN` (or the connection's\n`token_env`), and `apollo validate && apollo push`.\n\n## Endpoint params \u2014 `--param-schema` types\n\nEvery param a spec references (`where` clauses, insert/update values) must be\ndeclared: `{ \"<name>\": { \"type\": <type>, \"required\"?: bool } }`. An unknown type\nis a 400 at `endpoint create` / `update`.\n\n| type | accepts |\n|---|---|\n| `string` | any value, stringified |\n| `integer` / `number` | a number (numeric strings accepted) |\n| `boolean` | `true` / `false` (the strings too) |\n| `json` | any JSON value, passed through untouched |\n| `array` | a JSON array -- **what `op: \"in\"` needs**. On a GET query string, `?ids=A1,A2` or `?ids=[\"A1\",\"A2\"]` |\n\nDo not declare a set as `string`: the array is stringified to `\"A1,A2\"` and the\n`in` clause rejects it (`where id op \"in\" needs an array value (param \"ids\"\nresolved to string -- declare it as { \"type\": \"array\" } in paramSchema)`).\n\nOn the runtime side nothing is typed: a list-valued key bound on the source rides a\nPOST body as a JSON array as-is (no `type:` on the connection variable -- the\nloader refuses one), and a query-string variable renders it comma-joined\n(`style: csv`, the default) or repeated (`style: repeat`); mock-db's `array`\nparam accepts either.\n\n## Personas for the playground simulator (`identities`)\n\nOnce the mock DB has data, the playground can offer a **persona picker** before\nthe first message so a tester speaks as a real seeded user. The payload is\nauthored here \u2014 the schema and seed values are already in hand:\n\n```bash\n# Read what's stored (no personas \u21D2 { \"personas\": [] } \u2014 the picker is off).\napollo mockdb identities get\n\n# Upsert the payload (large payloads are easier from a file).\napollo mockdb identities set --file personas.json\napollo mockdb identities set --sample-data '{\n \"instructions\": \"Pick a persona to simulate as.\",\n \"personas\": [\n {\n \"label\": \"Jane Doe (verified)\",\n \"state\": \"verified\",\n \"default\": true,\n \"fields\": [\n { \"key\": \"user_id\", \"label\": \"User ID\", \"value\": \"U1001\", \"group\": \"who_you_are\" },\n { \"key\": \"pin\", \"label\": \"PIN\", \"value\": \"4321\", \"group\": \"verify\", \"role\": \"secret\" }\n ]\n }\n ]\n}'\n```\n\nRules the service enforces (a 400 names the exact `personas[i].fields[j]`):\n\n- Each persona needs a non-empty `label` and `state`; each field needs\n `key`, `label`, `value`, and a `group` of `who_you_are` | `verify` |\n `good_to_know` | `records`.\n- Exactly **one** persona carries `default: true` (when there is at least one).\n- Optional per-field extras: `role` (`key` | `secret`), `audience`\n (`user` | `simulator` | `both`), `required_to_start`, `match`, `maps_to`.\n- Optional per-persona `intents` (`{ title, message }`) seed suggested openers.\n\n`set` is a full **REPLACE**, not a merge \u2014 `{\"personas\":[]}` turns the picker\noff. Seed the values first: every persona value must exist in the mock DB.\nPersonas travel with the DB \u2014 `clone` and `export` carry them.\n\n## Cloning another agent's mock DB\n\n```bash\n# Copy a template agent's collections + rows + endpoints + personas into THIS\n# agent (the target must be empty; your account must own both agents):\napollo mockdb clone --from <templateAgentId>\n```\n\n## Commands\n\n| Command | What it does |\n|---|---|\n| `mockdb provision [--wire]` | Create the agent's mock DB; store runtime + management keys |\n| `mockdb status` | Ownership + local key prefixes + verdict (ok / empty / new / unknown) |\n| `mockdb describe` | Schema, relationships, relative-field flags, endpoints, row counts |\n| `mockdb collections create --name <n> --schema <json>` | Create a collection (table) |\n| `mockdb collections update --name <n> --add-columns <json>` | Add nullable columns (no rename/type-change/drop) |\n| `mockdb collections list` | List collections |\n| `mockdb seed --collection <n> --rows <json-array>` | Seed base rows |\n| `mockdb endpoint create --slug <s> --spec <json> [--param-schema <json>] [--description <t>]` | Declare a read/insert/update/delete endpoint |\n| `mockdb endpoint list` / `get <slug>` | List / inspect endpoints |\n| `mockdb endpoint update <slug> [--spec] [--param-schema] [--description]` | PATCH-merge an endpoint |\n| `mockdb endpoint delete <slug>` | Delete an endpoint (re-map operations + push after) |\n| `mockdb execute --slug <s> [--session <key>] [--body <json>]` | Run an endpoint with the runtime key |\n| `mockdb identities get` / `set --sample-data <json> | --file <path>` | Read / replace the persona payload |\n| `mockdb session get --key <key>` / `reset --key <key>` | Inspect / reset a session overlay |\n| `mockdb rotate mgmt` / `rotate runtime` | Mint fresh keys (re-wire after a runtime rotation) |\n| `mockdb clone --from <id>` | Clone another agent's mock DB into this one (target must be empty) |\n| `mockdb export` | Export schema + base data + endpoints + personas |\n| `mockdb keys` | Show locally stored key prefixes (no secrets) |\n| `mockdb wire [--connection-id] [--token-env]` | Write bundle/src/connections.yaml for the runtime key |\n| `mockdb delete --force` | Permanently delete the mock DB (Apollo token only) |\n| `mockdb guide [--output <file>]` | Write this guide to a file (default GUIDE.md) |\n\nCommon flags: `--agent <id>`, `--account <id>`, and the global `--json`.\n\n## Notes\n\n- Create collections **parent-first** (a `references` FK needs the parent).\n- **Writes need `--session`**; reads may omit it to peek at pristine base.\n- Endpoint `where`/value params must be declared in `--param-schema`, with a\n type the service knows (`string|integer|number|boolean|json|array`); a set fed to\n `op: \"in\"` is `array`.\n- `execute` resolves the runtime key from `$MOCKDB_TOKEN` \u2192 the local cache \u2192\n a fresh mint (then reports `runtimeKeyResync` so you re-wire).\n- A blank 2xx from the service is a transient transport blip: reads retry it,\n writes stop and tell you to verify before retrying (never duplicate rows).\n- Override the service URL with `APOLLO_MOCKDB_URL`.\n";
237
+ export declare const MOCKDB_GUIDE = "# Mock DB \u2014 Apollo CLI Guide\n\nA per-agent **mock database** for building and testing agents that have no\nreal backend (or no test environment) yet. You define collections (tables),\nseed realistic data, and declare named read/write endpoints; the agent's\nprogram sources then call those endpoints at runtime through a\n`connections.yaml` connection. It supports relative date/time fields\n(`now-30d`) that stay fresh, and per-conversation copy-on-write keyed by the\nsession id, so test runs are isolated and resettable.\n\nAll `apollo mockdb` commands are **non-interactive**. Pass the global\n`--json` for the machine envelope (`{ \"success\": true, \"data\": ... }`).\n\n## How auth works (and why it's safe)\n\n- The agent comes from the checkout you are standing in (`.apollorc`) or\n `--agent <id>`; the account from the active project (`--account <id>` or\n `APOLLO_ACCOUNT_ID` to override).\n- Your Apollo token is sent **first-party from the CLI** only where the\n service demands it: `provision`, `status`, `delete`, and minting a\n management key. The service verifies it against Apollo (you must be a\n member of the agent's account).\n- Provision returns two per-agent keys, stored under `~/.apollo/mockdb/`:\n - **managementKey** \u2014 used for ALL other management calls (`X-Mgmt-Key`;\n no Apollo token transmitted). Minted on demand if missing/rejected.\n - **runtimeKey** \u2014 what the agent's connection uses at runtime; also what\n `apollo mockdb execute` uses to test endpoints.\n\n## Typical workflow\n\n```bash\n# 1. Provision (stores the keys) and wire bundle/src/connections.yaml\napollo mockdb provision --wire\n\n# 2. Create collections (parents before children \u2014 FKs need the parent first)\napollo mockdb collections create --name users \\\n --schema '{\"columns\":[{\"name\":\"id\",\"type\":\"text\",\"primaryKey\":true},{\"name\":\"name\",\"type\":\"text\"}]}'\napollo mockdb collections create --name accounts \\\n --schema '{\"columns\":[{\"name\":\"id\",\"type\":\"text\",\"primaryKey\":true},{\"name\":\"user_id\",\"type\":\"text\",\"references\":\"users.id\"},{\"name\":\"balance\",\"type\":\"number\"},{\"name\":\"opened_at\",\"type\":\"reldate\"}]}'\n\n# 3. Seed data (relative date tokens allowed). Inline for a handful of rows,\n# --file (a JSON array or NDJSON) for a real dataset -- any size, batched.\napollo mockdb seed --collection users --rows '[{\"id\":\"U1\",\"name\":\"Ada Lovelace\"}]'\napollo mockdb seed --collection accounts --file accounts.json\n\n# 4. Declare the endpoints the agent will call\napollo mockdb endpoint create --slug get-accounts \\\n --param-schema '{\"user_id\":{\"type\":\"string\",\"required\":true}}' \\\n --spec '{\"kind\":\"read\",\"collection\":\"accounts\",\"where\":[{\"column\":\"user_id\",\"op\":\"eq\",\"param\":\"user_id\"}]}'\n\n# 4b. A read keyed by a SET of ids: op \"in\" + a param declared { \"type\": \"array\" }\napollo mockdb endpoint create --slug accounts-by-ids \\\n --param-schema '{\"ids\":{\"type\":\"array\",\"required\":true}}' \\\n --spec '{\"kind\":\"read\",\"collection\":\"accounts\",\"where\":[{\"column\":\"id\",\"op\":\"in\",\"param\":\"ids\"}]}'\n\n# 5. Test an endpoint under a session (runtime key + session = a conversation)\napollo mockdb execute --slug get-accounts --session test-1 --body '{\"user_id\":\"U1\"}'\napollo mockdb execute --slug accounts-by-ids --body '{\"ids\":[\"A1\",\"A3\"]}'\n\n# 6. Inspect / reset that session's overlay\napollo mockdb session get --key test-1\napollo mockdb session reset --key test-1\n```\n\nThen map each program source that names `connection: mock-db` to an endpoint\nunder `operations` in `bundle/src/connections.yaml` (`method: POST`,\n`path: /<slug>/execute`, `rows: $.data.rows` -- the stub `wire` writes carries\nthe template), export the runtime key as `MOCKDB_TOKEN` (or the connection's\n`token_env`), and `apollo validate && apollo push`.\n\n## Endpoint params \u2014 `--param-schema` types\n\nEvery param a spec references (`where` clauses, insert/update values) must be\ndeclared: `{ \"<name>\": { \"type\": <type>, \"required\"?: bool } }`. An unknown type\nis a 400 at `endpoint create` / `update`.\n\n| type | accepts |\n|---|---|\n| `string` | any value, stringified |\n| `integer` / `number` | a number (numeric strings accepted) |\n| `boolean` | `true` / `false` (the strings too) |\n| `json` | any JSON value, passed through untouched |\n| `array` | a JSON array -- **what `op: \"in\"` needs**. On a GET query string, `?ids=A1,A2` or `?ids=[\"A1\",\"A2\"]` |\n\nDo not declare a set as `string`: the array is stringified to `\"A1,A2\"` and the\n`in` clause rejects it (`where id op \"in\" needs an array value (param \"ids\"\nresolved to string -- declare it as { \"type\": \"array\" } in paramSchema)`).\n\nOn the runtime side nothing is typed: a list-valued key bound on the source rides a\nPOST body as a JSON array as-is (no `type:` on the connection variable -- the\nloader refuses one), and a query-string variable renders it comma-joined\n(`style: csv`, the default) or repeated (`style: repeat`); mock-db's `array`\nparam accepts either.\n\n## Changing data without a drop (keys stay valid)\n\n`mockdb delete --force` forgets the agent, so the next `provision` mints NEW\nkeys and everything wired to the old runtime key -- the vault's `MOCKDB_TOKEN`,\na deployed connection -- breaks until re-wired. None of these touch the keys:\n\n```bash\n# Re-seed everything: empty every collection + session overlay, keep schema,\n# endpoints, personas and keys. Then seed again.\napollo mockdb reset --force\n# Start over from an empty DB with the SAME keys (drops collections + endpoints + personas).\napollo mockdb reset --scope all --force\n\n# One collection: empty it (a parent with populated FK children is refused\n# unless --cascade, which empties the children too), drop it, or edit one row.\napollo mockdb collections truncate --name orders\napollo mockdb collections truncate --name users --cascade\napollo mockdb collections delete --name scratch --force\napollo mockdb rows list --collection users --limit 20\napollo mockdb rows patch --collection users --id U1 --set '{\"tier\":\"gold\"}'\napollo mockdb rows delete --collection users --id U9\n\n# Seed modes: upsert patches rows whose key exists (safe to re-run a file);\n# replace empties the collection first, in one transaction.\napollo mockdb seed --collection users --file users.json --mode upsert\napollo mockdb seed --collection orders --file orders.ndjson --mode replace\n```\n\nA read is never silently capped: `execute` replies `data.total` (the full\nmatch) and `data.hasMore` beside `rows`/`count`. Anything that sums or\ncounts rows must page (`offset` += `count`) until `hasMore` is false -- the\n`pagination:` stanza `wire` writes makes the engine do that on its own.\n\n## Personas for the playground simulator (`identities`)\n\nOnce the mock DB has data, the playground can offer a **persona picker** before\nthe first message so a tester speaks as a real seeded user. The payload is\nauthored here \u2014 the schema and seed values are already in hand:\n\n```bash\n# Read what's stored (no personas \u21D2 { \"personas\": [] } \u2014 the picker is off).\napollo mockdb identities get\n\n# Upsert the payload (large payloads are easier from a file).\napollo mockdb identities set --file personas.json\napollo mockdb identities set --sample-data '{\n \"instructions\": \"Pick a persona to simulate as.\",\n \"personas\": [\n {\n \"label\": \"Jane Doe (verified)\",\n \"state\": \"verified\",\n \"default\": true,\n \"fields\": [\n { \"key\": \"user_id\", \"label\": \"User ID\", \"value\": \"U1001\", \"group\": \"who_you_are\" },\n { \"key\": \"pin\", \"label\": \"PIN\", \"value\": \"4321\", \"group\": \"verify\", \"role\": \"secret\" }\n ]\n }\n ]\n}'\n```\n\nRules the service enforces (a 400 names the exact `personas[i].fields[j]`):\n\n- Each persona needs a non-empty `label` and `state`; each field needs\n `key`, `label`, `value`, and a `group` of `who_you_are` | `verify` |\n `good_to_know` | `records`.\n- Exactly **one** persona carries `default: true` (when there is at least one).\n- Optional per-field extras: `role` (`key` | `secret`), `audience`\n (`user` | `simulator` | `both`), `required_to_start`, `match`, `maps_to`.\n- Optional per-persona `intents` (`{ title, message }`) seed suggested openers.\n\n`set` is a full **REPLACE**, not a merge \u2014 `{\"personas\":[]}` turns the picker\noff. Seed the values first: every persona value must exist in the mock DB.\nPersonas travel with the DB \u2014 `clone` and `export` carry them.\n\n## Cloning another agent's mock DB\n\n```bash\n# Copy a template agent's collections + rows + endpoints + personas into THIS\n# agent (the target must be empty; your account must own both agents):\napollo mockdb clone --from <templateAgentId>\n```\n\n## Commands\n\n| Command | What it does |\n|---|---|\n| `mockdb provision [--wire]` | Create the agent's mock DB; store runtime + management keys |\n| `mockdb status` | Ownership + local key prefixes + verdict (ok / empty / new / unknown) |\n| `mockdb describe` | Schema, relationships, relative-field flags, endpoints, row counts |\n| `mockdb collections create --name <n> --schema <json>` | Create a collection (table) |\n| `mockdb collections update --name <n> --add-columns <json>` | Add nullable columns (no rename/type-change/drop) |\n| `mockdb collections list` | List collections |\n| `mockdb collections truncate --name <n> [--cascade]` | Empty a collection (base rows + its session overlay records); keys stay |\n| `mockdb collections delete --name <n> --force` | Drop a collection and its table |\n| `mockdb seed --collection <n> (--rows <json-array> \\| --file <path>) [--mode append\\|upsert\\|replace] [--batch <n>] [--cascade]` | Seed base rows; a file (JSON array or NDJSON) is sent in batches |\n| `mockdb rows list --collection <n> [--limit] [--offset] [--resolve]` | Page through base rows (with the total) |\n| `mockdb rows patch --collection <n> --id <id> --set <json>` | Edit one base row by primary key |\n| `mockdb rows delete --collection <n> --id <id>` | Remove one base row by primary key |\n| `mockdb reset [--scope data\\|all] --force` | Key-stable reset: `data` empties every collection + sessions; `all` also drops collections, endpoints, personas |\n| `mockdb endpoint create --slug <s> --spec <json> [--param-schema <json>] [--description <t>]` | Declare a read/insert/update/delete endpoint |\n| `mockdb endpoint list` / `get <slug>` | List / inspect endpoints |\n| `mockdb endpoint update <slug> [--spec] [--param-schema] [--description]` | PATCH-merge an endpoint |\n| `mockdb endpoint delete <slug>` | Delete an endpoint (re-map operations + push after) |\n| `mockdb execute --slug <s> [--session <key>] [--body <json>]` | Run an endpoint with the runtime key |\n| `mockdb identities get` / `set --sample-data <json> | --file <path>` | Read / replace the persona payload |\n| `mockdb session get --key <key>` / `reset --key <key>` | Inspect / reset a session overlay |\n| `mockdb rotate mgmt` / `rotate runtime` | Mint fresh keys (re-wire after a runtime rotation) |\n| `mockdb clone --from <id>` | Clone another agent's mock DB into this one (target must be empty) |\n| `mockdb export` | Export schema + base data + endpoints + personas |\n| `mockdb keys` | Show locally stored key prefixes (no secrets) |\n| `mockdb wire [--connection-id] [--token-env]` | Write bundle/src/connections.yaml for the runtime key |\n| `mockdb delete --force` | Permanently delete the mock DB (Apollo token only) -- the next provision mints NEW keys; prefer `reset` |\n| `mockdb guide [--output <file>]` | Write this guide to a file (default GUIDE.md) |\n\nCommon flags: `--agent <id>`, `--account <id>`, and the global `--json`.\n\n## Notes\n\n- Create collections **parent-first** (a `references` FK needs the parent).\n- **Writes need `--session`**; reads may omit it to peek at pristine base.\n- Endpoint `where`/value params must be declared in `--param-schema`, with a\n type the service knows (`string|integer|number|boolean|json|array`); a set fed to\n `op: \"in\"` is `array`.\n- `execute` resolves the runtime key from `$MOCKDB_TOKEN` \u2192 the local cache \u2192\n a fresh mint (then reports `runtimeKeyResync` so you re-wire).\n- A read replies at most `limit` rows (default 100, cap 1000) and says so:\n `data.total` / `data.hasMore`. Page with `offset` until `hasMore` is false.\n- A blank 2xx from the service is a transient transport blip: reads retry it,\n writes stop and tell you to verify before retrying (never duplicate rows).\n- Override the service URL with `APOLLO_MOCKDB_URL`.\n";
157
238
  /** Write the guide to `outputPath` (default `GUIDE.md` in the cwd). */
158
239
  export declare function writeMockDbGuide(outputPath?: string): Promise<{
159
240
  written: true;