@tangle-network/agent-app 0.63.41 → 0.63.43

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/agent-app",
3
- "version": "0.63.41",
3
+ "version": "0.63.43",
4
4
  "packageManager": "pnpm@11.24.0",
5
5
  "description": "Build agent applications with typed chat, tools, sandboxes, integrations, billing, and evaluation.",
6
6
  "keywords": [
@@ -1,40 +0,0 @@
1
- // src/sandbox/computer-receipts.ts
2
- var DEFAULT_COMPUTER_STEP_RECEIPT_TABLE = "computer_step_receipts";
3
- var COMPUTER_STEP_RECEIPT_TABLE_DDL = `CREATE TABLE IF NOT EXISTS ${DEFAULT_COMPUTER_STEP_RECEIPT_TABLE} (
4
- step_id TEXT PRIMARY KEY,
5
- state TEXT NOT NULL,
6
- receipt TEXT NOT NULL,
7
- updated_at INTEGER NOT NULL
8
- );
9
- CREATE INDEX IF NOT EXISTS ${DEFAULT_COMPUTER_STEP_RECEIPT_TABLE}_by_age ON ${DEFAULT_COMPUTER_STEP_RECEIPT_TABLE} (updated_at);`;
10
- var SAFE_IDENTIFIER = /^[A-Za-z_][A-Za-z0-9_]*$/;
11
- var PRUNE_EVERY_WRITES = 64;
12
- var DEFAULT_RETENTION_MS = 30 * 24 * 36e5;
13
- function createD1ComputerStepReceipts(db, options = {}) {
14
- const table = options.table ?? DEFAULT_COMPUTER_STEP_RECEIPT_TABLE;
15
- if (!SAFE_IDENTIFIER.test(table)) throw new Error(`Invalid computer step receipt table name: ${JSON.stringify(table)}`);
16
- const now = options.now ?? (() => Date.now());
17
- const readSql = `SELECT receipt FROM ${table} WHERE step_id = ?`;
18
- const writeSql = `INSERT INTO ${table} (step_id, state, receipt, updated_at) VALUES (?, ?, ?, ?)
19
- ON CONFLICT(step_id) DO UPDATE SET state = excluded.state, receipt = excluded.receipt, updated_at = excluded.updated_at
20
- WHERE ${table}.state <> 'settled'`;
21
- const pruneSql = `DELETE FROM ${table} WHERE updated_at < ?`;
22
- let writes = 0;
23
- return {
24
- async read(stepId) {
25
- const row = await db.prepare(readSql).bind(stepId).first();
26
- return row ? JSON.parse(row.receipt) : null;
27
- },
28
- async write(receipt) {
29
- await db.prepare(writeSql).bind(receipt.stepId, receipt.state, JSON.stringify(receipt), receipt.updatedAt).run();
30
- if (++writes % PRUNE_EVERY_WRITES === 0) await db.prepare(pruneSql).bind(now() - (options.retentionMs ?? DEFAULT_RETENTION_MS)).run();
31
- }
32
- };
33
- }
34
-
35
- export {
36
- DEFAULT_COMPUTER_STEP_RECEIPT_TABLE,
37
- COMPUTER_STEP_RECEIPT_TABLE_DDL,
38
- createD1ComputerStepReceipts
39
- };
40
- //# sourceMappingURL=chunk-GY4IPYG4.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/sandbox/computer-receipts.ts"],"sourcesContent":["/**\n * Computer-step receipts: the durable record of one `sandbox_run` call, keyed\n * by its step id (the turn's execution, the session and the tool call).\n *\n * `prepared` is written before the task is sent and holds the Vault listing\n * taken then, so a repeated call after a lost request still copies the files\n * the first send wrote. `settled` holds the answer the model read, the model\n * that ran and the file receipt; a repeated call returns it and sends nothing.\n * A receipt holds no credential.\n */\nimport type { ComputerFileListing, ComputerFileReceipt } from './computer-files'\n\nexport interface ComputerStepReceipt {\n stepId: string\n state: 'prepared' | 'settled'\n sessionId: string\n model?: string\n /** The Vault listing before the first send, while `prepared`. */\n before?: ComputerFileListing\n /** The answer the model read, file receipt line included, once `settled`. */\n answer?: string\n files?: ComputerFileReceipt\n updatedAt: number\n}\n\nexport interface ComputerStepReceipts {\n read(stepId: string): Promise<ComputerStepReceipt | null>\n /** A `settled` receipt is final: a later `prepared` write for the same step never replaces it. */\n write(receipt: ComputerStepReceipt): Promise<void>\n}\n\n/** The D1 surface the store uses. A real `D1Database` satisfies it. */\nexport interface ComputerStepReceiptD1Like {\n prepare(query: string): {\n bind(...values: unknown[]): {\n first<T = Record<string, unknown>>(): Promise<T | null>\n run(): Promise<unknown>\n }\n }\n}\n\nexport const DEFAULT_COMPUTER_STEP_RECEIPT_TABLE = 'computer_step_receipts'\n\n/** Paste into a product migration; the store never runs DDL. Times are epoch ms. */\nexport const COMPUTER_STEP_RECEIPT_TABLE_DDL = `CREATE TABLE IF NOT EXISTS ${DEFAULT_COMPUTER_STEP_RECEIPT_TABLE} (\n step_id TEXT PRIMARY KEY,\n state TEXT NOT NULL,\n receipt TEXT NOT NULL,\n updated_at INTEGER NOT NULL\n);\nCREATE INDEX IF NOT EXISTS ${DEFAULT_COMPUTER_STEP_RECEIPT_TABLE}_by_age ON ${DEFAULT_COMPUTER_STEP_RECEIPT_TABLE} (updated_at);`\n\nconst SAFE_IDENTIFIER = /^[A-Za-z_][A-Za-z0-9_]*$/\nconst PRUNE_EVERY_WRITES = 64\nconst DEFAULT_RETENTION_MS = 30 * 24 * 3600_000\n\n/** Receipts in one D1 table, shared by every isolate. Rows older than `retentionMs` (default 30 days) are pruned. */\nexport function createD1ComputerStepReceipts(db: ComputerStepReceiptD1Like, options: {\n table?: string; retentionMs?: number; now?: () => number\n} = {}): ComputerStepReceipts {\n const table = options.table ?? DEFAULT_COMPUTER_STEP_RECEIPT_TABLE\n if (!SAFE_IDENTIFIER.test(table)) throw new Error(`Invalid computer step receipt table name: ${JSON.stringify(table)}`)\n const now = options.now ?? (() => Date.now())\n const readSql = `SELECT receipt FROM ${table} WHERE step_id = ?`\n const writeSql = `INSERT INTO ${table} (step_id, state, receipt, updated_at) VALUES (?, ?, ?, ?)\nON CONFLICT(step_id) DO UPDATE SET state = excluded.state, receipt = excluded.receipt, updated_at = excluded.updated_at\nWHERE ${table}.state <> 'settled'`\n const pruneSql = `DELETE FROM ${table} WHERE updated_at < ?`\n let writes = 0\n return {\n async read(stepId) {\n const row = await db.prepare(readSql).bind(stepId).first<{ receipt: string }>()\n return row ? JSON.parse(row.receipt) as ComputerStepReceipt : null\n },\n async write(receipt) {\n await db.prepare(writeSql).bind(receipt.stepId, receipt.state, JSON.stringify(receipt), receipt.updatedAt).run()\n if (++writes % PRUNE_EVERY_WRITES === 0) await db.prepare(pruneSql).bind(now() - (options.retentionMs ?? DEFAULT_RETENTION_MS)).run()\n },\n }\n}\n"],"mappings":";AAyCO,IAAM,sCAAsC;AAG5C,IAAM,kCAAkC,8BAA8B,mCAAmC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,6BAMnF,mCAAmC,cAAc,mCAAmC;AAEjH,IAAM,kBAAkB;AACxB,IAAM,qBAAqB;AAC3B,IAAM,uBAAuB,KAAK,KAAK;AAGhC,SAAS,6BAA6B,IAA+B,UAExE,CAAC,GAAyB;AAC5B,QAAM,QAAQ,QAAQ,SAAS;AAC/B,MAAI,CAAC,gBAAgB,KAAK,KAAK,EAAG,OAAM,IAAI,MAAM,6CAA6C,KAAK,UAAU,KAAK,CAAC,EAAE;AACtH,QAAM,MAAM,QAAQ,QAAQ,MAAM,KAAK,IAAI;AAC3C,QAAM,UAAU,uBAAuB,KAAK;AAC5C,QAAM,WAAW,eAAe,KAAK;AAAA;AAAA,QAE/B,KAAK;AACX,QAAM,WAAW,eAAe,KAAK;AACrC,MAAI,SAAS;AACb,SAAO;AAAA,IACL,MAAM,KAAK,QAAQ;AACjB,YAAM,MAAM,MAAM,GAAG,QAAQ,OAAO,EAAE,KAAK,MAAM,EAAE,MAA2B;AAC9E,aAAO,MAAM,KAAK,MAAM,IAAI,OAAO,IAA2B;AAAA,IAChE;AAAA,IACA,MAAM,MAAM,SAAS;AACnB,YAAM,GAAG,QAAQ,QAAQ,EAAE,KAAK,QAAQ,QAAQ,QAAQ,OAAO,KAAK,UAAU,OAAO,GAAG,QAAQ,SAAS,EAAE,IAAI;AAC/G,UAAI,EAAE,SAAS,uBAAuB,EAAG,OAAM,GAAG,QAAQ,QAAQ,EAAE,KAAK,IAAI,KAAK,QAAQ,eAAe,qBAAqB,EAAE,IAAI;AAAA,IACtI;AAAA,EACF;AACF;","names":[]}