@deepagents/experimental 7.8.0 → 7.8.1

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 (47) hide show
  1. package/README.md +16 -5
  2. package/dist/index.js +140 -120
  3. package/dist/index.js.map +4 -4
  4. package/dist/zukhruf/control-plane/agent-control-plane.d.ts.map +1 -1
  5. package/dist/zukhruf/control-plane/agent-thread-limit-error.d.ts +6 -0
  6. package/dist/zukhruf/control-plane/agent-thread-limit-error.d.ts.map +1 -0
  7. package/dist/zukhruf/control-plane/agent-turn-id.d.ts +3 -0
  8. package/dist/zukhruf/control-plane/agent-turn-id.d.ts.map +1 -1
  9. package/dist/zukhruf/control-plane/stale-turn-error.d.ts +7 -0
  10. package/dist/zukhruf/control-plane/stale-turn-error.d.ts.map +1 -0
  11. package/dist/zukhruf/control-plane/turn-not-found-error.d.ts +7 -0
  12. package/dist/zukhruf/control-plane/turn-not-found-error.d.ts.map +1 -0
  13. package/dist/zukhruf/index.d.ts +3 -0
  14. package/dist/zukhruf/index.d.ts.map +1 -1
  15. package/dist/zukhruf/index.js +140 -120
  16. package/dist/zukhruf/index.js.map +4 -4
  17. package/dist/zukhruf/is-named-error.d.ts +7 -0
  18. package/dist/zukhruf/is-named-error.d.ts.map +1 -0
  19. package/dist/zukhruf/plugins/conversation-scheduling/conversation-scheduler.d.ts +1 -1
  20. package/dist/zukhruf/plugins/conversation-scheduling/conversation-scheduler.d.ts.map +1 -1
  21. package/dist/zukhruf/plugins/conversation-scheduling/index.d.ts.map +1 -1
  22. package/dist/zukhruf/plugins/conversation-scheduling/index.js +142 -136
  23. package/dist/zukhruf/plugins/conversation-scheduling/index.js.map +3 -3
  24. package/dist/zukhruf/plugins/http/index.d.ts +2 -2
  25. package/dist/zukhruf/plugins/http/index.d.ts.map +1 -1
  26. package/dist/zukhruf/plugins/http/index.js +72 -17
  27. package/dist/zukhruf/plugins/http/index.js.map +4 -4
  28. package/dist/zukhruf/plugins/schedules/http.d.ts.map +1 -1
  29. package/dist/zukhruf/plugins/schedules/http.js +44 -32
  30. package/dist/zukhruf/plugins/schedules/http.js.map +4 -4
  31. package/dist/zukhruf/plugins/schedules/index.d.ts +2 -2
  32. package/dist/zukhruf/plugins/schedules/index.d.ts.map +1 -1
  33. package/dist/zukhruf/plugins/schedules/index.js +138 -143
  34. package/dist/zukhruf/plugins/schedules/index.js.map +3 -3
  35. package/dist/zukhruf/plugins/uploads/http.js +30 -19
  36. package/dist/zukhruf/plugins/uploads/http.js.map +4 -4
  37. package/dist/zukhruf/plugins/uploads/index.d.ts +2 -2
  38. package/dist/zukhruf/plugins/uploads/index.d.ts.map +1 -1
  39. package/dist/zukhruf/plugins/uploads/index.js +48 -55
  40. package/dist/zukhruf/plugins/uploads/index.js.map +2 -2
  41. package/dist/zukhruf/queue/pg-boss.turn-queue.d.ts +4 -1
  42. package/dist/zukhruf/queue/pg-boss.turn-queue.d.ts.map +1 -1
  43. package/dist/zukhruf/runtime/agent-runtime.d.ts +19 -11
  44. package/dist/zukhruf/runtime/agent-runtime.d.ts.map +1 -1
  45. package/dist/zukhruf/runtime/plugin/plugin-manager.d.ts +4 -4
  46. package/dist/zukhruf/runtime/plugin/plugin-manager.d.ts.map +1 -1
  47. package/package.json +11 -11
@@ -1 +1 @@
1
- {"version":3,"file":"agent-control-plane.d.ts","sourceRoot":"","sources":["../../../src/zukhruf/control-plane/agent-control-plane.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,KAAK,EACV,cAAc,EAGf,MAAM,qBAAqB,CAAC;AAM7B,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC9E,OAAO,KAAK,EA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AG,SAAS,CAAC;IAQ7B,KAAK,CACT,KAAK,EAAE,UAAU,EACjB,KAAK,EAAE,eAAe,GACrB,OAAO,CAAC,gBAAgB,CAAC;IAiEtB,WAAW,CACf,KAAK,EAAE,UAAU,EACjB,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GACzC,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAQxB,YAAY,CAChB,KAAK,EAAE,UAAU,EACjB,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GACzC,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAQxB,UAAU,CACd,KAAK,EAAE,UAAU,EACjB,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC;QAAE,MAAM,EAAE,WAAW,EAAE,CAAA;KAAE,CAAC;IAiB/B,cAAc,CAClB,KAAK,EAAE,UAAU,EACjB,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,GACxB,OAAO,CAAC;QAAE,eAAe,EAAE,WAAW,CAAC,cAAc,CAAC,CAAA;KAAE,CAAC;IA4C5D,cAAc,CACZ,KAAK,EAAE,UAAU,EACjB,OAAO,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,GACnD,OAAO,CAAC,OAAO,CAAC;IAIb,eAAe,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;CAkFzE"}
@@ -0,0 +1,6 @@
1
+ /** A sub-agent turn refused because its tree already runs maxConcurrentThreadsPerSession - 1 sub-agents. */
2
+ export declare class AgentThreadLimitError extends Error {
3
+ readonly name = "AgentThreadLimitError";
4
+ constructor();
5
+ }
6
+ //# sourceMappingURL=agent-thread-limit-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-thread-limit-error.d.ts","sourceRoot":"","sources":["../../../src/zukhruf/control-plane/agent-thread-limit-error.ts"],"names":[],"mappings":"AAAA,4GAA4G;AAC5G,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,SAAkB,IAAI,2BAA2B;;CAKlD"}
@@ -1,4 +1,7 @@
1
+ import { z } from 'zod';
1
2
  import type { ConversationId } from '../mailbox/types.ts';
3
+ /** The shape of every AgentTurnId string; AgentTurnId.assertOwner checks whose it is. */
4
+ export declare const agentTurnIdSchema: z.ZodString;
2
5
  /** Conversation-scoped durable identity for one caller-supplied turn key. */
3
6
  export declare class AgentTurnId {
4
7
  #private;
@@ -1 +1 @@
1
- {"version":3,"file":"agent-turn-id.d.ts","sourceRoot":"","sources":["../../../src/zukhruf/control-plane/agent-turn-id.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,6EAA6E;AAC7E,qBAAa,WAAW;;IAItB,OAAO;IAIP,MAAM,CAAC,WAAW,CAChB,YAAY,EAAE,cAAc,EAC5B,SAAS,EAAE,MAAM,GAChB,WAAW;IAUd,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE,cAAc,GAAG,WAAW;IAIxD,MAAM,CAAC,WAAW,CAAC,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;IASxE,QAAQ,IAAI,MAAM;CAGnB;AAED,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,cAAc,GAAG,MAAM,CAQ1E"}
1
+ {"version":3,"file":"agent-turn-id.d.ts","sourceRoot":"","sources":["../../../src/zukhruf/control-plane/agent-turn-id.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAK1D,yFAAyF;AACzF,eAAO,MAAM,iBAAiB,aAQ5B,CAAC;AAEH,6EAA6E;AAC7E,qBAAa,WAAW;;IAGtB,OAAO;IAIP,MAAM,CAAC,WAAW,CAChB,YAAY,EAAE,cAAc,EAC5B,SAAS,EAAE,MAAM,GAChB,WAAW;IAQd,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE,cAAc,GAAG,WAAW;IAIxD,MAAM,CAAC,WAAW,CAAC,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;IAOxE,QAAQ,IAAI,MAAM;CAGnB;AAED,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,cAAc,GAAG,MAAM,CAQ1E"}
@@ -0,0 +1,7 @@
1
+ /** An assistant continuation (an approval answer) for a turn the conversation has moved past. */
2
+ export declare class StaleTurnError extends Error {
3
+ readonly name = "StaleTurnError";
4
+ readonly turnId: string;
5
+ constructor(turnId: string);
6
+ }
7
+ //# sourceMappingURL=stale-turn-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stale-turn-error.d.ts","sourceRoot":"","sources":["../../../src/zukhruf/control-plane/stale-turn-error.ts"],"names":[],"mappings":"AAAA,iGAAiG;AACjG,qBAAa,cAAe,SAAQ,KAAK;IACvC,SAAkB,IAAI,oBAAoB;IAC1C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBAEZ,MAAM,EAAE,MAAM;CAI3B"}
@@ -0,0 +1,7 @@
1
+ /** A turn id the conversation never issued reads as absent, so another conversation's turn is never confirmed. */
2
+ export declare class TurnNotFoundError extends Error {
3
+ readonly name = "TurnNotFoundError";
4
+ readonly turnId: string;
5
+ constructor(turnId: string);
6
+ }
7
+ //# sourceMappingURL=turn-not-found-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"turn-not-found-error.d.ts","sourceRoot":"","sources":["../../../src/zukhruf/control-plane/turn-not-found-error.ts"],"names":[],"mappings":"AAAA,kHAAkH;AAClH,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,SAAkB,IAAI,uBAAuB;IAC7C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBAEZ,MAAM,EAAE,MAAM;CAI3B"}
@@ -1,7 +1,10 @@
1
1
  export * from './agent.ts';
2
2
  export * from './control-plane/agent-path.ts';
3
3
  export * from './control-plane/agent-thread.ts';
4
+ export { AgentThreadLimitError } from './control-plane/agent-thread-limit-error.ts';
4
5
  export { ConversationNotFoundError } from './control-plane/conversation-not-found-error.ts';
6
+ export { StaleTurnError } from './control-plane/stale-turn-error.ts';
7
+ export { TurnNotFoundError } from './control-plane/turn-not-found-error.ts';
5
8
  export * from './instructions.ts';
6
9
  export * from './mailbox/postgres.store.ts';
7
10
  export * from './mailbox/sqlite.store.ts';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/zukhruf/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,+BAA+B,CAAC;AAC9C,cAAc,iCAAiC,CAAC;AAChD,OAAO,EAAE,yBAAyB,EAAE,MAAM,iDAAiD,CAAC;AAC5F,cAAc,mBAAmB,CAAC;AAClC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,YAAY,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AACpE,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,YAAY,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,mBAAmB,gDAAgD,CAAC;AACpE,mBAAmB,iDAAiD,CAAC;AACrE,cAAc,wDAAwD,CAAC;AACvE,mBAAmB,4CAA4C,CAAC;AAChE,cAAc,qBAAqB,CAAC;AACpC,cAAc,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/zukhruf/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,+BAA+B,CAAC;AAC9C,cAAc,iCAAiC,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,6CAA6C,CAAC;AACpF,OAAO,EAAE,yBAAyB,EAAE,MAAM,iDAAiD,CAAC;AAC5F,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yCAAyC,CAAC;AAC5E,cAAc,mBAAmB,CAAC;AAClC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,YAAY,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AACpE,cAAc,+BAA+B,CAAC;AAC9C,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,YAAY,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,mBAAmB,gDAAgD,CAAC;AACpE,mBAAmB,iDAAiD,CAAC;AACrE,cAAc,wDAAwD,CAAC;AACvE,mBAAmB,4CAA4C,CAAC;AAChE,cAAc,qBAAqB,CAAC;AACpC,cAAc,WAAW,CAAC"}
@@ -182,6 +182,14 @@ var AgentThread = class _AgentThread {
182
182
  }
183
183
  };
184
184
 
185
+ // packages/experimental/src/zukhruf/control-plane/agent-thread-limit-error.ts
186
+ var AgentThreadLimitError = class extends Error {
187
+ name = "AgentThreadLimitError";
188
+ constructor() {
189
+ super("agent thread limit reached");
190
+ }
191
+ };
192
+
185
193
  // packages/experimental/src/zukhruf/control-plane/conversation-not-found-error.ts
186
194
  var ConversationNotFoundError = class extends Error {
187
195
  name = "ConversationNotFoundError";
@@ -197,6 +205,26 @@ function assertConversationOwner(conversation, storedUserId) {
197
205
  }
198
206
  }
199
207
 
208
+ // packages/experimental/src/zukhruf/control-plane/stale-turn-error.ts
209
+ var StaleTurnError = class extends Error {
210
+ name = "StaleTurnError";
211
+ turnId;
212
+ constructor(turnId) {
213
+ super(`turn "${turnId}" is not the latest turn`);
214
+ this.turnId = turnId;
215
+ }
216
+ };
217
+
218
+ // packages/experimental/src/zukhruf/control-plane/turn-not-found-error.ts
219
+ var TurnNotFoundError = class extends Error {
220
+ name = "TurnNotFoundError";
221
+ turnId;
222
+ constructor(turnId) {
223
+ super(`turn "${turnId}" does not exist`);
224
+ this.turnId = turnId;
225
+ }
226
+ };
227
+
200
228
  // packages/experimental/src/zukhruf/instructions.ts
201
229
  function defineInstructions(...fragments) {
202
230
  return fragments;
@@ -679,7 +707,6 @@ var TurnQueue = class {
679
707
  };
680
708
 
681
709
  // packages/experimental/src/zukhruf/queue/pg-boss.turn-queue.ts
682
- var MAX_TIMEOUT_MS = 2147483647;
683
710
  var queueCatalogRowSchema = z4.object({ table: z4.string() });
684
711
  function deadLetterQueueOf(queue) {
685
712
  return `${queue}-dead`;
@@ -694,13 +721,13 @@ var PgBossTurnQueue = class _PgBossTurnQueue extends TurnQueue {
694
721
  #active = /* @__PURE__ */ new Map();
695
722
  /** Cancels that arrived before a local worker runs the turn; each expires on its own timer. */
696
723
  #cancelIntents = /* @__PURE__ */ new Map();
697
- constructor(boss, settings, table) {
724
+ constructor(boss, settings, opened) {
698
725
  super();
699
726
  this.#boss = boss;
700
727
  this.#queue = settings.queue;
701
728
  this.#schema = settings.schema;
702
- this.#table = table;
703
- this.#cancelIntentTtlMs = settings.expireInSeconds * 1e3;
729
+ this.#table = opened.table;
730
+ this.#cancelIntentTtlMs = opened.expireInSeconds * 1e3;
704
731
  this.#pollingIntervalSeconds = settings.pollingIntervalSeconds;
705
732
  }
706
733
  /**
@@ -709,20 +736,13 @@ var PgBossTurnQueue = class _PgBossTurnQueue extends TurnQueue {
709
736
  */
710
737
  static async create(boss, options = {}) {
711
738
  const settings = _PgBossTurnQueue.#settings(boss, options);
712
- const table = await _PgBossTurnQueue.#openQueue(boss, settings);
713
- return new _PgBossTurnQueue(boss, settings, table);
739
+ const opened = await _PgBossTurnQueue.#openQueue(boss, settings);
740
+ return new _PgBossTurnQueue(boss, settings, opened);
714
741
  }
715
742
  static #settings(boss, options) {
716
743
  const db = boss.getDb();
717
744
  const configuredSchema = "config" in db && isRecord(db.config) ? db.config.schema : void 0;
718
745
  const bossSchema = typeof configuredSchema === "string" ? configuredSchema : void 0;
719
- const expireInSeconds = options.expireInSeconds ?? 3600;
720
- const cancelIntentTtlMs = expireInSeconds * 1e3;
721
- if (!Number.isFinite(expireInSeconds) || expireInSeconds <= 0 || !Number.isSafeInteger(cancelIntentTtlMs) || cancelIntentTtlMs > Number.MAX_SAFE_INTEGER - Date.now()) {
722
- throw new Error(
723
- "PgBossTurnQueue expireInSeconds must be a finite positive duration"
724
- );
725
- }
726
746
  if (options.schema === void 0 && bossSchema === void 0) {
727
747
  throw new Error(
728
748
  "PgBossTurnQueue cannot read the schema from a custom PgBoss database adapter; pass the PgBoss schema in options.schema"
@@ -736,12 +756,12 @@ var PgBossTurnQueue = class _PgBossTurnQueue extends TurnQueue {
736
756
  return {
737
757
  queue: options.queue ?? "zukhruf-turns",
738
758
  schema: options.schema ?? bossSchema ?? "pgboss",
739
- expireInSeconds,
759
+ expireInSeconds: options.expireInSeconds ?? 3600,
740
760
  heartbeatSeconds: options.heartbeatSeconds ?? 30,
741
761
  pollingIntervalSeconds: options.pollingIntervalSeconds ?? 1
742
762
  };
743
763
  }
744
- /** Creates the queues when they are missing; returns the turn queue's job table. */
764
+ /** Creates the queues when they are missing; returns the turn queue as stored. */
745
765
  static async #openQueue(boss, settings) {
746
766
  const deadLetterQueue = deadLetterQueueOf(settings.queue);
747
767
  if (!await boss.getQueue(deadLetterQueue)) {
@@ -759,10 +779,10 @@ var PgBossTurnQueue = class _PgBossTurnQueue extends TurnQueue {
759
779
  });
760
780
  queue = await boss.getQueue(settings.queue);
761
781
  }
762
- if (!queue) {
782
+ if (!queue?.expireInSeconds) {
763
783
  throw new Error(`Queue "${settings.queue}" was not initialized`);
764
784
  }
765
- const { table } = queue;
785
+ const { table, expireInSeconds } = queue;
766
786
  try {
767
787
  const catalog = await boss.getDb().executeSql(
768
788
  `SELECT table_name AS "table"
@@ -783,7 +803,7 @@ var PgBossTurnQueue = class _PgBossTurnQueue extends TurnQueue {
783
803
  { cause }
784
804
  );
785
805
  }
786
- return table;
806
+ return { table, expireInSeconds };
787
807
  }
788
808
  get queue() {
789
809
  return this.#queue;
@@ -824,10 +844,10 @@ var PgBossTurnQueue = class _PgBossTurnQueue extends TurnQueue {
824
844
  async cancel(streamId) {
825
845
  this.#rememberCancelIntent(streamId);
826
846
  this.#abortLocal(streamId);
827
- const jobs = await this.#boss.findJobs(this.#queue, {
828
- data: { streamId }
829
- });
830
- const queued = jobs.filter((job) => job.state === "created" || job.state === "retry").map((job) => job.id);
847
+ const queued = (await this.#boss.findJobs(this.#queue, {
848
+ data: { streamId },
849
+ queued: true
850
+ })).map((job) => job.id);
831
851
  if (queued.length > 0) await this.#deleteIfStillQueued(queued);
832
852
  this.#abortLocal(streamId);
833
853
  const remaining = await this.#boss.findJobs(this.#queue, {
@@ -943,18 +963,15 @@ var PgBossTurnQueue = class _PgBossTurnQueue extends TurnQueue {
943
963
  }
944
964
  #rememberCancelIntent(streamId) {
945
965
  this.#forgetCancelIntent(streamId);
946
- this.#armCancelIntent(streamId, Date.now() + this.#cancelIntentTtlMs);
947
- }
948
- #armCancelIntent(streamId, expiresAt) {
949
966
  const timer = globalThis.setTimeout(
950
- () => {
951
- if (Date.now() < expiresAt) this.#armCancelIntent(streamId, expiresAt);
952
- else this.#cancelIntents.delete(streamId);
953
- },
954
- Math.min(MAX_TIMEOUT_MS, Math.max(1, expiresAt - Date.now()))
967
+ () => this.#cancelIntents.delete(streamId),
968
+ this.#cancelIntentTtlMs
955
969
  );
956
970
  timer.unref();
957
- this.#cancelIntents.set(streamId, { expiresAt, timer });
971
+ this.#cancelIntents.set(streamId, {
972
+ expiresAt: Date.now() + this.#cancelIntentTtlMs,
973
+ timer
974
+ });
958
975
  }
959
976
  #hasCancelIntent(streamId) {
960
977
  const intent = this.#cancelIntents.get(streamId);
@@ -1687,9 +1704,14 @@ var AgentStatusProjector = class _AgentStatusProjector {
1687
1704
  };
1688
1705
 
1689
1706
  // packages/experimental/src/zukhruf/control-plane/agent-turn-id.ts
1690
- import { v5 as uuidv53 } from "uuid";
1707
+ import { v5 as uuidv53, validate as validateUuid } from "uuid";
1708
+ import { z as z6 } from "zod";
1709
+ var prefix = "zukhruf-turn";
1710
+ var agentTurnIdSchema = z6.string().refine((value) => {
1711
+ const [head, scope, turn, ...rest] = value.split(":");
1712
+ return head === prefix && rest.length === 0 && validateUuid(scope) && validateUuid(turn);
1713
+ });
1691
1714
  var AgentTurnId = class _AgentTurnId {
1692
- static #prefix = "zukhruf-turn";
1693
1715
  #value;
1694
1716
  constructor(value) {
1695
1717
  this.#value = value;
@@ -1699,19 +1721,15 @@ var AgentTurnId = class _AgentTurnId {
1699
1721
  throw new Error("turn id cannot be empty");
1700
1722
  }
1701
1723
  const scope = conversationNamespace(conversation);
1702
- return new _AgentTurnId(
1703
- `${_AgentTurnId.#prefix}:${scope}:${uuidv53(requestId, scope)}`
1704
- );
1724
+ return new _AgentTurnId(`${prefix}:${scope}:${uuidv53(requestId, scope)}`);
1705
1725
  }
1706
1726
  static random(conversation) {
1707
1727
  return _AgentTurnId.fromRequest(conversation, crypto.randomUUID());
1708
1728
  }
1709
1729
  static assertOwner(conversation, streamId) {
1710
- const expectedPrefix = `${_AgentTurnId.#prefix}:${conversationNamespace(conversation)}:`;
1730
+ const expectedPrefix = `${prefix}:${conversationNamespace(conversation)}:`;
1711
1731
  if (!streamId.startsWith(expectedPrefix)) {
1712
- throw new Error(
1713
- `stream "${streamId}" does not belong to conversation "${conversation.chatId}"`
1714
- );
1732
+ throw new TurnNotFoundError(streamId);
1715
1733
  }
1716
1734
  }
1717
1735
  toString() {
@@ -1771,13 +1789,12 @@ var AgentControlPlane = class _AgentControlPlane {
1771
1789
  await this.#directory.assertOwnerIfExists(conversation);
1772
1790
  const thread = await this.#directory.load(conversation);
1773
1791
  if (thread && !thread.path.isRoot && await this.#queue.getTurnActivity(conversation) !== "running" && !await this.#hasExecutionCapacity(thread)) {
1774
- throw new Error("agent thread limit reached");
1792
+ throw new AgentThreadLimitError();
1775
1793
  }
1776
1794
  const streamId = message.role === "assistant" ? await this.#continuationStreamId(conversation, message) : AgentTurnId.fromRequest(conversation, message.id).toString();
1777
1795
  if (message.role === "assistant" || turn.trigger === "regenerate-message") {
1778
1796
  const status = await this.#streams.store.getStreamStatus(streamId);
1779
- if (status === void 0)
1780
- throw new Error("enqueue: continuation stream does not exist");
1797
+ if (status === void 0) throw new TurnNotFoundError(streamId);
1781
1798
  if (status === "queued" || status === "running") return streamId;
1782
1799
  await this.#streams.reopen(streamId);
1783
1800
  } else {
@@ -1794,12 +1811,7 @@ var AgentControlPlane = class _AgentControlPlane {
1794
1811
  }
1795
1812
  async #continuationStreamId(conversation, message) {
1796
1813
  const streamId = (await this.#directory.load(conversation))?.lastTurnId;
1797
- if (!streamId)
1798
- throw new Error("enqueue: assistant continuation has no previous turn");
1799
- if (message.id !== streamId)
1800
- throw new Error(
1801
- "enqueue: assistant continuation must update the current assistant message"
1802
- );
1814
+ if (message.id !== streamId) throw new StaleTurnError(message.id);
1803
1815
  return streamId;
1804
1816
  }
1805
1817
  recordLatestTurn(conversation, streamId) {
@@ -1885,11 +1897,11 @@ var AgentControlPlane = class _AgentControlPlane {
1885
1897
  });
1886
1898
  }
1887
1899
  async listAgents(actor, pathPrefix) {
1888
- const prefix = pathPrefix ? actor.thread.path.resolve(pathPrefix) : void 0;
1900
+ const prefix2 = pathPrefix ? actor.thread.path.resolve(pathPrefix) : void 0;
1889
1901
  const threads = await this.#directory.listTree(actor.thread);
1890
1902
  const agents = await Promise.all(
1891
1903
  threads.flatMap((thread) => {
1892
- if (prefix && !prefix.contains(thread.path)) return [];
1904
+ if (prefix2 && !prefix2.contains(thread.path)) return [];
1893
1905
  return [this.#statusProjector.projectListedAgent(actor.turn, thread)];
1894
1906
  })
1895
1907
  );
@@ -2243,7 +2255,7 @@ import {
2243
2255
  modelMessageSchema as modelMessageSchema2
2244
2256
  } from "ai";
2245
2257
  import { hash, randomUUID as randomUUID2 } from "node:crypto";
2246
- import { z as z6 } from "zod";
2258
+ import { z as z7 } from "zod";
2247
2259
 
2248
2260
  // packages/compaction/dist/index.js
2249
2261
  import {
@@ -2447,21 +2459,21 @@ ${options.instructions}` : SUMMARY_PROMPT,
2447
2459
  }
2448
2460
 
2449
2461
  // packages/experimental/src/zukhruf/runtime/compaction.ts
2450
- var checkpointSchema = z6.object({
2451
- sourceCount: z6.number().int().positive(),
2452
- sourceHash: z6.string(),
2453
- replacement: z6.array(z6.unknown()).transform(
2462
+ var checkpointSchema = z7.object({
2463
+ sourceCount: z7.number().int().positive(),
2464
+ sourceHash: z7.string(),
2465
+ replacement: z7.array(z7.unknown()).transform(
2454
2466
  (messages) => messages.map((message) => modelMessageSchema2.parse(message))
2455
2467
  )
2456
2468
  });
2457
- var cacheObservationSchema = z6.object({
2458
- scope: z6.string(),
2459
- prefixLength: z6.number().int().nonnegative(),
2460
- prefixHash: z6.string(),
2461
- startedAt: z6.number().int().nonnegative(),
2462
- retentionMs: z6.number().int().positive().optional()
2469
+ var cacheObservationSchema = z7.object({
2470
+ scope: z7.string(),
2471
+ prefixLength: z7.number().int().nonnegative(),
2472
+ prefixHash: z7.string(),
2473
+ startedAt: z7.number().int().nonnegative(),
2474
+ retentionMs: z7.number().int().positive().optional()
2463
2475
  });
2464
- var inputUsageSchema = cacheObservationSchema.pick({ scope: true, prefixLength: true, prefixHash: true }).extend({ inputTokens: z6.number().int().nonnegative() });
2476
+ var inputUsageSchema = cacheObservationSchema.pick({ scope: true, prefixLength: true, prefixHash: true }).extend({ inputTokens: z7.number().int().nonnegative() });
2465
2477
  function jsonDigest(value) {
2466
2478
  return hash("sha256", JSON.stringify(value));
2467
2479
  }
@@ -2601,9 +2613,9 @@ function createCompaction(config, engine, store, signal, onEvent) {
2601
2613
  }
2602
2614
  if (saved !== void 0) {
2603
2615
  const checkpoint2 = checkpointSchema.parse(saved);
2604
- const prefix = messages.slice(0, checkpoint2.sourceCount);
2605
- if (prefix.length === checkpoint2.sourceCount && jsonDigest(prefix) === checkpoint2.sourceHash) {
2606
- source = prefix;
2616
+ const prefix2 = messages.slice(0, checkpoint2.sourceCount);
2617
+ if (prefix2.length === checkpoint2.sourceCount && jsonDigest(prefix2) === checkpoint2.sourceHash) {
2618
+ source = prefix2;
2607
2619
  replacement = checkpoint2.replacement;
2608
2620
  messages = [
2609
2621
  ...replacement,
@@ -3540,21 +3552,21 @@ import {
3540
3552
  } from "@deepagents/context";
3541
3553
 
3542
3554
  // packages/experimental/src/zukhruf/runtime/conversation-status/child-progress.ts
3543
- import { z as z7 } from "zod";
3544
- var childActivitySchema = z7.object({
3545
- id: z7.string(),
3546
- type: z7.enum(["spawn", "message", "followup", "interrupt", "completion"]),
3547
- at: z7.number(),
3548
- actorPath: z7.string(),
3549
- targetPath: z7.string(),
3550
- streamId: z7.string(),
3551
- outcome: z7.enum(["completed", "failed", "cancelled"]).optional()
3555
+ import { z as z8 } from "zod";
3556
+ var childActivitySchema = z8.object({
3557
+ id: z8.string(),
3558
+ type: z8.enum(["spawn", "message", "followup", "interrupt", "completion"]),
3559
+ at: z8.number(),
3560
+ actorPath: z8.string(),
3561
+ targetPath: z8.string(),
3562
+ streamId: z8.string(),
3563
+ outcome: z8.enum(["completed", "failed", "cancelled"]).optional()
3552
3564
  });
3553
- var childActivitiesSchema = z7.partialRecord(
3565
+ var childActivitiesSchema = z8.partialRecord(
3554
3566
  childActivitySchema.shape.type,
3555
3567
  childActivitySchema
3556
3568
  );
3557
- var childActivityMetadataSchema = z7.looseObject({
3569
+ var childActivityMetadataSchema = z8.looseObject({
3558
3570
  childActivities: childActivitiesSchema.default({})
3559
3571
  });
3560
3572
 
@@ -3848,13 +3860,13 @@ var StatusPublishingTurnQueue = class extends TurnQueue {
3848
3860
 
3849
3861
  // packages/experimental/src/zukhruf/collaboration/interrupt-agent.ts
3850
3862
  import { tool as tool2 } from "ai";
3851
- import { z as z8 } from "zod";
3852
- var interruptAgentInputSchema = z8.object({
3853
- target: z8.string().trim().min(1).describe(
3863
+ import { z as z9 } from "zod";
3864
+ var interruptAgentInputSchema = z9.object({
3865
+ target: z9.string().trim().min(1).describe(
3854
3866
  "The canonical /root/... path, or a descendant-relative target name."
3855
3867
  )
3856
3868
  });
3857
- var interruptAgentOutputSchema = z8.object({ previous_status: listedAgentStatusSchema }).strict();
3869
+ var interruptAgentOutputSchema = z9.object({ previous_status: listedAgentStatusSchema }).strict();
3858
3870
  var interruptAgentTool = tool2({
3859
3871
  description: "Interrupt an agent's current turn, if any, and return its previous status. The agent remains available for messages and follow-up tasks.",
3860
3872
  inputSchema: interruptAgentInputSchema,
@@ -3864,13 +3876,13 @@ var interruptAgentTool = tool2({
3864
3876
 
3865
3877
  // packages/experimental/src/zukhruf/collaboration/list-agents.ts
3866
3878
  import { tool as tool3 } from "ai";
3867
- import { z as z9 } from "zod";
3868
- var listAgentsInputSchema = z9.object({
3869
- path_prefix: z9.string().trim().min(1).describe(
3879
+ import { z as z10 } from "zod";
3880
+ var listAgentsInputSchema = z10.object({
3881
+ path_prefix: z10.string().trim().min(1).describe(
3870
3882
  "Task-path prefix without a trailing slash. Omit to list the whole tree."
3871
3883
  ).optional()
3872
3884
  });
3873
- var listAgentsOutputSchema = z9.object({ agents: z9.array(listedAgentSchema) }).strict();
3885
+ var listAgentsOutputSchema = z10.object({ agents: z10.array(listedAgentSchema) }).strict();
3874
3886
  var listAgentsTool = tool3({
3875
3887
  description: "List live agents in the current root thread tree. Optionally filter by task-path prefix.",
3876
3888
  inputSchema: listAgentsInputSchema,
@@ -3880,12 +3892,12 @@ var listAgentsTool = tool3({
3880
3892
 
3881
3893
  // packages/experimental/src/zukhruf/collaboration/message-tools.ts
3882
3894
  import { tool as tool4 } from "ai";
3883
- import { z as z10 } from "zod";
3884
- var agentMessageInputSchema = z10.object({
3885
- target: z10.string().trim().min(1).describe(
3895
+ import { z as z11 } from "zod";
3896
+ var agentMessageInputSchema = z11.object({
3897
+ target: z11.string().trim().min(1).describe(
3886
3898
  "The canonical /root/... path, or a descendant-relative target name."
3887
3899
  ),
3888
- message: z10.string().trim().min(1).describe("The message or follow-up task.")
3900
+ message: z11.string().trim().min(1).describe("The message or follow-up task.")
3889
3901
  });
3890
3902
  var sendMessageTool = tool4({
3891
3903
  description: "Queue a message for another agent. Address siblings with their canonical /root/... path.",
@@ -3906,7 +3918,7 @@ var followupTaskTool = tool4({
3906
3918
 
3907
3919
  // packages/experimental/src/zukhruf/collaboration/spawn-agent.ts
3908
3920
  import { tool as tool5 } from "ai";
3909
- import { z as z11 } from "zod";
3921
+ import { z as z12 } from "zod";
3910
3922
 
3911
3923
  // packages/experimental/src/zukhruf/control-plane/fork-turns.ts
3912
3924
  var forkTurnsError = "fork_turns must be `none`, `all`, or a positive integer string";
@@ -3919,18 +3931,18 @@ function parseForkTurns(value) {
3919
3931
  }
3920
3932
 
3921
3933
  // packages/experimental/src/zukhruf/collaboration/spawn-agent.ts
3922
- var spawnAgentInputSchema = z11.object({
3923
- agent_type: z11.string().trim().min(1).describe("The name of one available subagent declaration."),
3924
- task_name: z11.string().trim().min(1).refine(
3934
+ var spawnAgentInputSchema = z12.object({
3935
+ agent_type: z12.string().trim().min(1).describe("The name of one available subagent declaration."),
3936
+ task_name: z12.string().trim().min(1).refine(
3925
3937
  (value) => value !== "." && value !== ".." && !value.includes("/"),
3926
3938
  "task_name must be one non-empty path segment"
3927
3939
  ).describe("One path segment naming this independent agent task."),
3928
- message: z11.string().refine((value) => value.trim().length > 0, "message cannot be empty").describe("The initial task for the spawned agent."),
3929
- fork_turns: z11.string().trim().refine((value) => parseForkTurns(value) !== void 0, forkTurnsError).describe(
3940
+ message: z12.string().refine((value) => value.trim().length > 0, "message cannot be empty").describe("The initial task for the spawned agent."),
3941
+ fork_turns: z12.string().trim().refine((value) => parseForkTurns(value) !== void 0, forkTurnsError).describe(
3930
3942
  "Required number of parent turns to fork. Use `none`, `all`, or a positive integer string such as `3`."
3931
3943
  )
3932
3944
  });
3933
- var spawnAgentOutputSchema = z11.object({ task_name: z11.string() }).strict();
3945
+ var spawnAgentOutputSchema = z12.object({ task_name: z12.string() }).strict();
3934
3946
  function createSpawnAgentTool(options) {
3935
3947
  return tool5({
3936
3948
  description: ({ context }) => {
@@ -3959,11 +3971,11 @@ function createSpawnAgentTool(options) {
3959
3971
 
3960
3972
  // packages/experimental/src/zukhruf/collaboration/wait-agent.ts
3961
3973
  import { tool as tool6 } from "ai";
3962
- import { z as z12 } from "zod";
3963
- var waitAgentOutputSchema = z12.object({ message: z12.string(), timed_out: z12.boolean() }).strict();
3974
+ import { z as z13 } from "zod";
3975
+ var waitAgentOutputSchema = z13.object({ message: z13.string(), timed_out: z13.boolean() }).strict();
3964
3976
  function createWaitAgentTool(options) {
3965
- const waitAgentInputSchema = z12.object({
3966
- timeout_ms: z12.number().int().max(options.maxTimeoutMs).optional().describe("Maximum time to wait in milliseconds.")
3977
+ const waitAgentInputSchema = z13.object({
3978
+ timeout_ms: z13.number().int().max(options.maxTimeoutMs).optional().describe("Maximum time to wait in milliseconds.")
3967
3979
  });
3968
3980
  return tool6({
3969
3981
  description: "Wait for pending mail addressed to this agent without consuming it.",
@@ -4336,7 +4348,7 @@ var PluginToolComposition = class {
4336
4348
  };
4337
4349
 
4338
4350
  // packages/experimental/src/zukhruf/runtime/plugin/plugin-manager.ts
4339
- function createdFrom(plugin, definition) {
4351
+ function initializedFrom(plugin, definition) {
4340
4352
  return plugin.definition === definition;
4341
4353
  }
4342
4354
  var PluginManager = class {
@@ -4349,6 +4361,7 @@ var PluginManager = class {
4349
4361
  #plugins;
4350
4362
  #toolComposition;
4351
4363
  #resources = new AsyncDisposableStack();
4364
+ #running = [];
4352
4365
  constructor(root, bindings, multiAgent) {
4353
4366
  let configuredRoot = root;
4354
4367
  const pluginBindings = new PluginBindings(root.plugins, bindings);
@@ -4401,15 +4414,20 @@ var PluginManager = class {
4401
4414
  return this.#resources.disposeAsync();
4402
4415
  }
4403
4416
  get(definition) {
4404
- const plugin = this.#plugins.find(
4405
- (candidate) => createdFrom(candidate, definition)
4417
+ if (!this.#plugins.some((plugin2) => plugin2.definition === definition)) {
4418
+ throw new Error(
4419
+ `AgentRuntime: plugin "${definition.name}" does not belong to this runtime`
4420
+ );
4421
+ }
4422
+ const plugin = this.#running.find(
4423
+ (candidate) => initializedFrom(candidate, definition)
4406
4424
  );
4407
4425
  if (!plugin) {
4408
4426
  throw new Error(
4409
- `AgentRuntime: plugin "${definition.name}" does not belong to this runtime`
4427
+ `AgentRuntime: plugin "${definition.name}" has no running phase, since its initialize() returned nothing`
4410
4428
  );
4411
4429
  }
4412
- return plugin.instance;
4430
+ return plugin.running;
4413
4431
  }
4414
4432
  configureTelemetry(context, telemetry) {
4415
4433
  const integrations = [];
@@ -4419,20 +4437,21 @@ var PluginManager = class {
4419
4437
  return integrations.length === 0 ? telemetry : { ...telemetry, integrations };
4420
4438
  }
4421
4439
  get reconcilesAvailability() {
4422
- return this.#plugins.some(
4423
- ({ instance }) => Boolean(instance.conversationAvailable)
4440
+ return this.#running.some(
4441
+ ({ running }) => Boolean(running.conversationAvailable)
4424
4442
  );
4425
4443
  }
4426
- async startWorkers(host, workers, waitForActive) {
4427
- for (const { instance } of this.#plugins) {
4428
- if (instance.work) workers.use(await instance.work(host, waitForActive));
4444
+ async startWorkers(workers, waitForActive) {
4445
+ for (const { running } of this.#running) {
4446
+ if (running.work) workers.use(await running.work(waitForActive));
4429
4447
  }
4430
4448
  }
4431
4449
  async initialize(host) {
4432
4450
  for (const { definition, instance } of this.#plugins) {
4433
4451
  const initialized = await instance.initialize?.(host);
4434
4452
  if (!initialized) continue;
4435
- this.#resources.use(initialized);
4453
+ this.#running.push({ definition, running: initialized });
4454
+ this.#resources.defer(() => initialized[Symbol.asyncDispose]?.());
4436
4455
  if (initialized.tools) {
4437
4456
  this.#toolComposition.add(definition.name, initialized.tools);
4438
4457
  }
@@ -4442,11 +4461,11 @@ var PluginManager = class {
4442
4461
  this.#toolComposition.compose(this.declarations.values())
4443
4462
  );
4444
4463
  }
4445
- async conversationAvailable(host, conversation) {
4464
+ async conversationAvailable(conversation) {
4446
4465
  const errors = [];
4447
- for (const { instance } of this.#plugins) {
4466
+ for (const { running } of this.#running) {
4448
4467
  try {
4449
- await instance.conversationAvailable?.(host, conversation);
4468
+ await running.conversationAvailable?.(conversation);
4450
4469
  } catch (error) {
4451
4470
  errors.push(error);
4452
4471
  }
@@ -4704,6 +4723,7 @@ var RuntimeHost = class {
4704
4723
  [Symbol.asyncDispose]() {
4705
4724
  return this.#resources.disposeAsync();
4706
4725
  }
4726
+ /** The running phase `initialize(host)` returned for `definition`. */
4707
4727
  plugin(definition) {
4708
4728
  return this.#plugins.get(definition);
4709
4729
  }
@@ -4734,7 +4754,7 @@ var RuntimeHost = class {
4734
4754
  read: () => this.#conversationStatus.read(conversation),
4735
4755
  publish: () => this.#conversationStatus.publish(conversation)
4736
4756
  },
4737
- () => this.#plugins.conversationAvailable(this.#pluginHost, conversation)
4757
+ () => this.#plugins.conversationAvailable(conversation)
4738
4758
  );
4739
4759
  }
4740
4760
  /**
@@ -4802,7 +4822,7 @@ var RuntimeHost = class {
4802
4822
  }
4803
4823
  async #startWorkers(options) {
4804
4824
  await using workers = new AsyncDisposableStack();
4805
- await this.#plugins.startWorkers(this.#pluginHost, workers, true);
4825
+ await this.#plugins.startWorkers(workers, true);
4806
4826
  const reconcilesAvailability = this.#plugins.reconcilesAvailability;
4807
4827
  workers.use(
4808
4828
  await this.#queue.consume(this.#executor.execute.bind(this.#executor), {
@@ -4812,10 +4832,7 @@ var RuntimeHost = class {
4812
4832
  onSettled: async ({ chatId, userId }) => {
4813
4833
  await this.#conversationStatus.publish({ chatId, userId });
4814
4834
  if (reconcilesAvailability) {
4815
- await this.#plugins.conversationAvailable(this.#pluginHost, {
4816
- chatId,
4817
- userId
4818
- });
4835
+ await this.#plugins.conversationAvailable({ chatId, userId });
4819
4836
  }
4820
4837
  }
4821
4838
  })
@@ -5016,6 +5033,7 @@ export {
5016
5033
  AgentPluginCapability,
5017
5034
  AgentRuntime,
5018
5035
  AgentThread,
5036
+ AgentThreadLimitError,
5019
5037
  ConversationNotFoundError,
5020
5038
  DEFAULT_CONVERSATION_STATUS_CHANNEL,
5021
5039
  InterAgentCommunicationTypes,
@@ -5025,6 +5043,8 @@ export {
5025
5043
  PgBossTurnQueue,
5026
5044
  PostgresMailboxStore,
5027
5045
  SqliteMailboxStore,
5046
+ StaleTurnError,
5047
+ TurnNotFoundError,
5028
5048
  TurnQueue,
5029
5049
  assertCommunication,
5030
5050
  createInterAgentCommunication,