@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.
package/README.md CHANGED
@@ -50,6 +50,21 @@ The public experimental surface contains the pure declaration layer
50
50
  ports and adapters. The optional Hono transport plugin is a separate
51
51
  `@deepagents/experimental/zukhruf/http` entry point.
52
52
  Declarations have a types-only dependency on `@deepagents/context`.
53
+
54
+ `defineAgent()` accepts native AI SDK `reasoning`, `maxOutputTokens`,
55
+ `timeout`, `toolCallConcurrency`, `toolApproval`, and
56
+ `experimental_toolApprovalSecret` settings. The runtime forwards them to each
57
+ turn without adding defaults. If you configure a signing secret, reuse it
58
+ across workers and restarts that resume the same approval. A `toolApproval`
59
+ map overrides `needsApproval` for the listed tools; unlisted tools keep their
60
+ own rules. A callback controls every tool call, including tools added by the
61
+ runtime. The runtime stores approvals and resumes turns after a decision.
62
+
63
+ If the provider interrupts a response, the runtime retains partial output
64
+ and marks the turn `failed` without automatically retrying it. Compaction
65
+ keeps the input token and prompt cache measurements from the last successful
66
+ step.
67
+
53
68
  The `AgentHost` returned by `AgentRuntime.initialize()` exposes enqueue, host
54
69
  mailbox delivery, observation, approval, denial, worker lifecycle, and
55
70
  model-facing collaboration for declared subagents. Its control plane, executor,
package/dist/index.js CHANGED
@@ -532,10 +532,45 @@ function defineInstructions(...fragments) {
532
532
  }
533
533
 
534
534
  // packages/experimental/src/zukhruf/mailbox/sqlite.store.ts
535
+ import { Declaration } from "@zukhruf/sqlite-drift";
535
536
  import { transaction } from "@zukhruf/sqlite-transaction";
536
537
  import { DatabaseSync } from "node:sqlite";
537
538
  import { z } from "zod";
538
539
 
540
+ // packages/experimental/src/zukhruf/mailbox/ddl.sqlite.ts
541
+ var SETUP = `
542
+ PRAGMA journal_mode = WAL;
543
+ PRAGMA synchronous = NORMAL;
544
+ `;
545
+ var statements = [
546
+ `CREATE TABLE zukhruf_mailbox_items (
547
+ sequence INTEGER PRIMARY KEY AUTOINCREMENT,
548
+ recipient_chat_id TEXT NOT NULL,
549
+ recipient_user_id TEXT NOT NULL,
550
+ communication TEXT NOT NULL
551
+ )`,
552
+ `CREATE TABLE zukhruf_mailbox_activity (
553
+ recipient_chat_id TEXT NOT NULL,
554
+ recipient_user_id TEXT NOT NULL,
555
+ turn_id TEXT NOT NULL,
556
+ PRIMARY KEY (recipient_chat_id, recipient_user_id)
557
+ )`,
558
+ `CREATE TABLE zukhruf_mailbox_consumed_terminal_ids (
559
+ communication_id TEXT PRIMARY KEY
560
+ )`,
561
+ `CREATE INDEX zukhruf_mailbox_recipient_sequence
562
+ ON zukhruf_mailbox_items (
563
+ recipient_chat_id,
564
+ recipient_user_id,
565
+ sequence
566
+ )`,
567
+ // enqueue relies on this index through INSERT OR IGNORE.
568
+ `CREATE UNIQUE INDEX zukhruf_mailbox_communication_id
569
+ ON zukhruf_mailbox_items (
570
+ json_extract(communication, '$.id')
571
+ )`
572
+ ];
573
+
539
574
  // packages/experimental/src/zukhruf/mailbox/store.ts
540
575
  var MailboxStore = class {
541
576
  };
@@ -587,40 +622,7 @@ function assertConversationId(value, label) {
587
622
  }
588
623
 
589
624
  // packages/experimental/src/zukhruf/mailbox/sqlite.store.ts
590
- var DDL = `
591
- PRAGMA journal_mode = WAL;
592
- PRAGMA synchronous = NORMAL;
593
-
594
- CREATE TABLE IF NOT EXISTS zukhruf_mailbox_items (
595
- sequence INTEGER PRIMARY KEY AUTOINCREMENT,
596
- recipient_chat_id TEXT NOT NULL,
597
- recipient_user_id TEXT NOT NULL,
598
- communication TEXT NOT NULL
599
- );
600
-
601
- CREATE TABLE IF NOT EXISTS zukhruf_mailbox_activity (
602
- recipient_chat_id TEXT NOT NULL,
603
- recipient_user_id TEXT NOT NULL,
604
- turn_id TEXT NOT NULL,
605
- PRIMARY KEY (recipient_chat_id, recipient_user_id)
606
- );
607
-
608
- CREATE TABLE IF NOT EXISTS zukhruf_mailbox_consumed_terminal_ids (
609
- communication_id TEXT PRIMARY KEY
610
- );
611
-
612
- CREATE INDEX IF NOT EXISTS zukhruf_mailbox_recipient_sequence
613
- ON zukhruf_mailbox_items (
614
- recipient_chat_id,
615
- recipient_user_id,
616
- sequence
617
- );
618
-
619
- CREATE UNIQUE INDEX IF NOT EXISTS zukhruf_mailbox_communication_id
620
- ON zukhruf_mailbox_items (
621
- json_extract(communication, '$.id')
622
- );
623
- `;
625
+ var tables = new Declaration(statements, { rows: "keep" });
624
626
  var BUSY_TIMEOUT_MS = 5e3;
625
627
  var conversationIdSchema = z.object({
626
628
  chatId: z.string(),
@@ -647,7 +649,8 @@ var SqliteMailboxStore = class extends MailboxStore {
647
649
  constructor(path3) {
648
650
  super();
649
651
  this.#database = new DatabaseSync(path3, { timeout: BUSY_TIMEOUT_MS });
650
- this.#database.exec(DDL);
652
+ this.#database.exec(SETUP);
653
+ tables.apply(this.#database);
651
654
  }
652
655
  async beginTurn(recipient, turnId) {
653
656
  transaction(
@@ -2866,7 +2869,8 @@ function createCompaction(config, engine, store, signal, onEvent) {
2866
2869
  };
2867
2870
  };
2868
2871
  const onStepEnd = async (step) => {
2869
- if (signal.aborted || step.finishReason === "error") return;
2872
+ if (signal.aborted || step.finishReason === "error" || step.finishReason === "interrupted")
2873
+ return;
2870
2874
  const iterations = step.usage.raw?.iterations;
2871
2875
  const ambiguous = iterations != null && (!Array.isArray(iterations) || iterations.length !== 1 || !isRecord3(iterations[0]) || iterations[0].type !== "message") || step.content.some(
2872
2876
  (part) => part.type === "custom" && part.kind === "openai.compaction" || part.type === "text" && part.providerMetadata?.anthropic?.type === "compaction"
@@ -3151,6 +3155,11 @@ var AgentTurnExecutor = class {
3151
3155
  const agentOptions = {
3152
3156
  name: declaration.name,
3153
3157
  model: declaration.model,
3158
+ reasoning: declaration.reasoning,
3159
+ maxOutputTokens: declaration.maxOutputTokens,
3160
+ timeout: declaration.timeout,
3161
+ toolCallConcurrency: declaration.toolCallConcurrency,
3162
+ experimental_toolApprovalSecret: declaration.experimental_toolApprovalSecret,
3154
3163
  sandbox,
3155
3164
  context: engine,
3156
3165
  telemetry: this.#plugins.configureTelemetry(
@@ -3220,10 +3229,14 @@ var AgentTurnExecutor = class {
3220
3229
  data
3221
3230
  })
3222
3231
  ) : void 0;
3232
+ const { toolApproval } = declaration;
3223
3233
  const stream = await chat(
3224
3234
  agent({
3225
3235
  ...agentOptions,
3226
3236
  tools: modelTools,
3237
+ // The declaration's dynamic policy also sees injected runtime tools;
3238
+ // the call re-types it for this turn's tool set.
3239
+ toolApproval: typeof toolApproval === "function" ? (options) => toolApproval(options) : toolApproval,
3227
3240
  prepareStep: compaction?.prepareStep
3228
3241
  }),
3229
3242
  {
@@ -3616,7 +3629,8 @@ var ApprovalController = class _ApprovalController {
3616
3629
 
3617
3630
  // packages/experimental/src/zukhruf/runtime/conversation-status/projector.ts
3618
3631
  import { Latch } from "@zukhruf/async";
3619
- import { MemoryStore, Mutex } from "@zukhruf/mutex";
3632
+ import { Mutex } from "@zukhruf/mutex";
3633
+ import { MemoryStore } from "@zukhruf/mutex/memory";
3620
3634
  import { EventEmitter, on } from "node:events";
3621
3635
  import { isDeepStrictEqual as isDeepStrictEqual2 } from "node:util";
3622
3636
  import {