@deepagents/experimental 7.3.0 → 7.5.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.
Files changed (31) hide show
  1. package/README.md +3 -0
  2. package/dist/index.js +9 -9
  3. package/dist/index.js.map +3 -3
  4. package/dist/providers/claude/index.js +5 -3
  5. package/dist/providers/claude/index.js.map +2 -2
  6. package/dist/providers/claude/local-credentials.d.ts.map +1 -1
  7. package/dist/providers/codex/index.js +3 -1
  8. package/dist/providers/codex/index.js.map +2 -2
  9. package/dist/providers/codex/local-credentials.d.ts.map +1 -1
  10. package/dist/zukhruf/agent.d.ts +3 -1
  11. package/dist/zukhruf/agent.d.ts.map +1 -1
  12. package/dist/zukhruf/index.js +9 -9
  13. package/dist/zukhruf/index.js.map +3 -3
  14. package/dist/zukhruf/mailbox/ddl.sqlite.d.ts +1 -1
  15. package/dist/zukhruf/mailbox/ddl.sqlite.d.ts.map +1 -1
  16. package/dist/zukhruf/mailbox/sqlite.store.d.ts.map +1 -1
  17. package/dist/zukhruf/plugins/conversation-scheduling/index.d.ts.map +1 -1
  18. package/dist/zukhruf/plugins/conversation-scheduling/index.js +8 -11
  19. package/dist/zukhruf/plugins/conversation-scheduling/index.js.map +2 -2
  20. package/dist/zukhruf/plugins/http/index.d.ts.map +1 -1
  21. package/dist/zukhruf/plugins/http/index.js +40 -20
  22. package/dist/zukhruf/plugins/http/index.js.map +2 -2
  23. package/dist/zukhruf/plugins/schedules/http.js.map +1 -1
  24. package/dist/zukhruf/plugins/schedules/index.d.ts.map +1 -1
  25. package/dist/zukhruf/plugins/schedules/index.js +15 -16
  26. package/dist/zukhruf/plugins/schedules/index.js.map +3 -3
  27. package/dist/zukhruf/plugins/uploads/http.js.map +1 -1
  28. package/dist/zukhruf/plugins/uploads/index.js +7 -8
  29. package/dist/zukhruf/plugins/uploads/index.js.map +2 -2
  30. package/dist/zukhruf/runtime/agent-turn-executor.d.ts.map +1 -1
  31. package/package.json +9 -8
package/README.md CHANGED
@@ -59,6 +59,9 @@ across workers and restarts that resume the same approval. A `toolApproval`
59
59
  map overrides `needsApproval` for the listed tools; unlisted tools keep their
60
60
  own rules. A callback controls every tool call, including tools added by the
61
61
  runtime. The runtime stores approvals and resumes turns after a decision.
62
+ `defineAgent()` also accepts the AI SDK `stopWhen`, which ends the agent loop of
63
+ a turn, for example `[hasToolCall('notify'), isStepCount(6)]`. Without it, a
64
+ turn uses the default of `agent()` in `@deepagents/context`.
62
65
 
63
66
  If the provider interrupts a response, the runtime retains partial output
64
67
  and marks the turn `failed` without automatically retrying it. Compaction
package/dist/index.js CHANGED
@@ -533,13 +533,12 @@ function defineInstructions(...fragments) {
533
533
 
534
534
  // packages/experimental/src/zukhruf/mailbox/sqlite.store.ts
535
535
  import { Declaration } from "@zukhruf/sqlite-drift";
536
+ import { open } from "@zukhruf/sqlite-open";
536
537
  import { transaction } from "@zukhruf/sqlite-transaction";
537
- import { DatabaseSync } from "node:sqlite";
538
538
  import { z } from "zod";
539
539
 
540
540
  // packages/experimental/src/zukhruf/mailbox/ddl.sqlite.ts
541
541
  var SETUP = `
542
- PRAGMA journal_mode = WAL;
543
542
  PRAGMA synchronous = NORMAL;
544
543
  `;
545
544
  var statements = [
@@ -623,7 +622,6 @@ function assertConversationId(value, label) {
623
622
 
624
623
  // packages/experimental/src/zukhruf/mailbox/sqlite.store.ts
625
624
  var tables = new Declaration(statements, { rows: "keep" });
626
- var BUSY_TIMEOUT_MS = 5e3;
627
625
  var conversationIdSchema = z.object({
628
626
  chatId: z.string(),
629
627
  userId: z.string()
@@ -648,7 +646,7 @@ var SqliteMailboxStore = class extends MailboxStore {
648
646
  #database;
649
647
  constructor(path3) {
650
648
  super();
651
- this.#database = new DatabaseSync(path3, { timeout: BUSY_TIMEOUT_MS });
649
+ this.#database = open(path3);
652
650
  this.#database.exec(SETUP);
653
651
  tables.apply(this.#database);
654
652
  }
@@ -2415,12 +2413,12 @@ function replacementRange(messages, keepLastMessages) {
2415
2413
  while (messages[start]?.role === "system") start++;
2416
2414
  let limit = messages.length - keepLastMessages;
2417
2415
  const links = /* @__PURE__ */ new Map();
2418
- const link = (key, index, open) => {
2416
+ const link = (key, index, open2) => {
2419
2417
  const previous = links.get(key);
2420
2418
  links.set(key, {
2421
2419
  first: previous?.first ?? index,
2422
2420
  last: index,
2423
- open: open ?? previous?.open ?? false
2421
+ open: open2 ?? previous?.open ?? false
2424
2422
  });
2425
2423
  };
2426
2424
  for (const [index, message] of messages.entries()) {
@@ -2449,8 +2447,8 @@ function replacementRange(messages, keepLastMessages) {
2449
2447
  }
2450
2448
  }
2451
2449
  const crossings = new Int32Array(messages.length + 1);
2452
- for (const { first, last, open } of links.values()) {
2453
- if (open) limit = Math.min(limit, first);
2450
+ for (const { first, last, open: open2 } of links.values()) {
2451
+ if (open2) limit = Math.min(limit, first);
2454
2452
  crossings[first + 1]++;
2455
2453
  crossings[last + 1]--;
2456
2454
  }
@@ -2541,7 +2539,7 @@ ${options.instructions}` : SUMMARY_PROMPT,
2541
2539
  abortSignal
2542
2540
  });
2543
2541
  abortSignal?.throwIfAborted();
2544
- const usage = generated.totalUsage;
2542
+ const { usage } = generated;
2545
2543
  if (generated.finishReason !== "stop" || generated.content.some(
2546
2544
  (part) => part.type !== "text" && part.type !== "reasoning"
2547
2545
  )) {
@@ -3123,6 +3121,7 @@ var AgentTurnExecutor = class {
3123
3121
  chatId: turn.chatId,
3124
3122
  userId: turn.userId
3125
3123
  });
3124
+ await using _turnSandbox = sandbox.sandbox;
3126
3125
  const agentSkills = await this.#skillsFor(
3127
3126
  turn,
3128
3127
  declaration.name,
@@ -3158,6 +3157,7 @@ var AgentTurnExecutor = class {
3158
3157
  reasoning: declaration.reasoning,
3159
3158
  maxOutputTokens: declaration.maxOutputTokens,
3160
3159
  timeout: declaration.timeout,
3160
+ stopWhen: declaration.stopWhen,
3161
3161
  toolCallConcurrency: declaration.toolCallConcurrency,
3162
3162
  experimental_toolApprovalSecret: declaration.experimental_toolApprovalSecret,
3163
3163
  sandbox,