@deepagents/experimental 7.1.3 → 7.2.0

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.
@@ -188,10 +188,45 @@ function defineInstructions(...fragments) {
188
188
  }
189
189
 
190
190
  // packages/experimental/src/zukhruf/mailbox/sqlite.store.ts
191
+ import { Declaration } from "@zukhruf/sqlite-drift";
191
192
  import { transaction } from "@zukhruf/sqlite-transaction";
192
193
  import { DatabaseSync } from "node:sqlite";
193
194
  import { z } from "zod";
194
195
 
196
+ // packages/experimental/src/zukhruf/mailbox/ddl.sqlite.ts
197
+ var SETUP = `
198
+ PRAGMA journal_mode = WAL;
199
+ PRAGMA synchronous = NORMAL;
200
+ `;
201
+ var statements = [
202
+ `CREATE TABLE zukhruf_mailbox_items (
203
+ sequence INTEGER PRIMARY KEY AUTOINCREMENT,
204
+ recipient_chat_id TEXT NOT NULL,
205
+ recipient_user_id TEXT NOT NULL,
206
+ communication TEXT NOT NULL
207
+ )`,
208
+ `CREATE TABLE zukhruf_mailbox_activity (
209
+ recipient_chat_id TEXT NOT NULL,
210
+ recipient_user_id TEXT NOT NULL,
211
+ turn_id TEXT NOT NULL,
212
+ PRIMARY KEY (recipient_chat_id, recipient_user_id)
213
+ )`,
214
+ `CREATE TABLE zukhruf_mailbox_consumed_terminal_ids (
215
+ communication_id TEXT PRIMARY KEY
216
+ )`,
217
+ `CREATE INDEX zukhruf_mailbox_recipient_sequence
218
+ ON zukhruf_mailbox_items (
219
+ recipient_chat_id,
220
+ recipient_user_id,
221
+ sequence
222
+ )`,
223
+ // enqueue relies on this index through INSERT OR IGNORE.
224
+ `CREATE UNIQUE INDEX zukhruf_mailbox_communication_id
225
+ ON zukhruf_mailbox_items (
226
+ json_extract(communication, '$.id')
227
+ )`
228
+ ];
229
+
195
230
  // packages/experimental/src/zukhruf/mailbox/store.ts
196
231
  var MailboxStore = class {
197
232
  };
@@ -243,40 +278,7 @@ function assertConversationId(value, label) {
243
278
  }
244
279
 
245
280
  // packages/experimental/src/zukhruf/mailbox/sqlite.store.ts
246
- var DDL = `
247
- PRAGMA journal_mode = WAL;
248
- PRAGMA synchronous = NORMAL;
249
-
250
- CREATE TABLE IF NOT EXISTS zukhruf_mailbox_items (
251
- sequence INTEGER PRIMARY KEY AUTOINCREMENT,
252
- recipient_chat_id TEXT NOT NULL,
253
- recipient_user_id TEXT NOT NULL,
254
- communication TEXT NOT NULL
255
- );
256
-
257
- CREATE TABLE IF NOT EXISTS zukhruf_mailbox_activity (
258
- recipient_chat_id TEXT NOT NULL,
259
- recipient_user_id TEXT NOT NULL,
260
- turn_id TEXT NOT NULL,
261
- PRIMARY KEY (recipient_chat_id, recipient_user_id)
262
- );
263
-
264
- CREATE TABLE IF NOT EXISTS zukhruf_mailbox_consumed_terminal_ids (
265
- communication_id TEXT PRIMARY KEY
266
- );
267
-
268
- CREATE INDEX IF NOT EXISTS zukhruf_mailbox_recipient_sequence
269
- ON zukhruf_mailbox_items (
270
- recipient_chat_id,
271
- recipient_user_id,
272
- sequence
273
- );
274
-
275
- CREATE UNIQUE INDEX IF NOT EXISTS zukhruf_mailbox_communication_id
276
- ON zukhruf_mailbox_items (
277
- json_extract(communication, '$.id')
278
- );
279
- `;
281
+ var tables = new Declaration(statements, { rows: "keep" });
280
282
  var BUSY_TIMEOUT_MS = 5e3;
281
283
  var conversationIdSchema = z.object({
282
284
  chatId: z.string(),
@@ -303,7 +305,8 @@ var SqliteMailboxStore = class extends MailboxStore {
303
305
  constructor(path3) {
304
306
  super();
305
307
  this.#database = new DatabaseSync(path3, { timeout: BUSY_TIMEOUT_MS });
306
- this.#database.exec(DDL);
308
+ this.#database.exec(SETUP);
309
+ tables.apply(this.#database);
307
310
  }
308
311
  async beginTurn(recipient, turnId) {
309
312
  transaction(
@@ -2522,7 +2525,8 @@ function createCompaction(config, engine, store, signal, onEvent) {
2522
2525
  };
2523
2526
  };
2524
2527
  const onStepEnd = async (step) => {
2525
- if (signal.aborted || step.finishReason === "error") return;
2528
+ if (signal.aborted || step.finishReason === "error" || step.finishReason === "interrupted")
2529
+ return;
2526
2530
  const iterations = step.usage.raw?.iterations;
2527
2531
  const ambiguous = iterations != null && (!Array.isArray(iterations) || iterations.length !== 1 || !isRecord3(iterations[0]) || iterations[0].type !== "message") || step.content.some(
2528
2532
  (part) => part.type === "custom" && part.kind === "openai.compaction" || part.type === "text" && part.providerMetadata?.anthropic?.type === "compaction"
@@ -2807,6 +2811,11 @@ var AgentTurnExecutor = class {
2807
2811
  const agentOptions = {
2808
2812
  name: declaration.name,
2809
2813
  model: declaration.model,
2814
+ reasoning: declaration.reasoning,
2815
+ maxOutputTokens: declaration.maxOutputTokens,
2816
+ timeout: declaration.timeout,
2817
+ toolCallConcurrency: declaration.toolCallConcurrency,
2818
+ experimental_toolApprovalSecret: declaration.experimental_toolApprovalSecret,
2810
2819
  sandbox,
2811
2820
  context: engine,
2812
2821
  telemetry: this.#plugins.configureTelemetry(
@@ -2876,10 +2885,14 @@ var AgentTurnExecutor = class {
2876
2885
  data
2877
2886
  })
2878
2887
  ) : void 0;
2888
+ const { toolApproval } = declaration;
2879
2889
  const stream = await chat(
2880
2890
  agent({
2881
2891
  ...agentOptions,
2882
2892
  tools: modelTools,
2893
+ // The declaration's dynamic policy also sees injected runtime tools;
2894
+ // the call re-types it for this turn's tool set.
2895
+ toolApproval: typeof toolApproval === "function" ? (options) => toolApproval(options) : toolApproval,
2883
2896
  prepareStep: compaction?.prepareStep
2884
2897
  }),
2885
2898
  {
@@ -3272,7 +3285,8 @@ var ApprovalController = class _ApprovalController {
3272
3285
 
3273
3286
  // packages/experimental/src/zukhruf/runtime/conversation-status/projector.ts
3274
3287
  import { Latch } from "@zukhruf/async";
3275
- import { MemoryStore, Mutex } from "@zukhruf/mutex";
3288
+ import { Mutex } from "@zukhruf/mutex";
3289
+ import { MemoryStore } from "@zukhruf/mutex/memory";
3276
3290
  import { EventEmitter, on } from "node:events";
3277
3291
  import { isDeepStrictEqual as isDeepStrictEqual2 } from "node:util";
3278
3292
  import {