@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
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Each subpath entry (./zukhruf/http, ./zukhruf/schedules/http) bundles its own
3
+ * copy of a main-entry error class, so `instanceof` fails across entries; the
4
+ * class's literal `name` is what survives. Import the class with `import type`.
5
+ */
6
+ export declare function isNamedError<NamedError extends Error>(error: unknown, name: NamedError['name']): error is NamedError;
7
+ //# sourceMappingURL=is-named-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-named-error.d.ts","sourceRoot":"","sources":["../../src/zukhruf/is-named-error.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,UAAU,SAAS,KAAK,EACnD,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,UAAU,CAAC,MAAM,CAAC,GACvB,KAAK,IAAI,UAAU,CAErB"}
@@ -43,7 +43,7 @@ export interface SchedulingWake {
43
43
  }
44
44
  interface ConversationSchedulerOptions {
45
45
  scheduler: WakeScheduler<SchedulingWake>;
46
- host: () => AgentPluginHost;
46
+ host: AgentPluginHost;
47
47
  timezone: string;
48
48
  clock: {
49
49
  Date: {
@@ -1 +1 @@
1
- {"version":3,"file":"conversation-scheduler.d.ts","sourceRoot":"","sources":["../../../../src/zukhruf/plugins/conversation-scheduling/conversation-scheduler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,KAAK,EAAQ,aAAa,EAAE,MAAM,qBAAqB,CAAC;AA0C/D,QAAA,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA0BvB,CAAC;AAEL,KAAK,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAC7D,KAAK,cAAc,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC;AAGtD,MAAM,WAAW,cAAc;IAC7B,YAAY,EAAE,cAAc,CAAC;IAC7B,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;CACtB;AAsBD,UAAU,4BAA4B;IACpC,SAAS,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;IACzC,IAAI,EAAE,MAAM,eAAe,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE;QAAE,IAAI,EAAE;YAAE,GAAG,IAAI,MAAM,CAAA;SAAE,CAAA;KAAE,CAAC;CACpC;AAED,UAAU,eAAe;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,sEAAsE;AACtE,qBAAa,qBAAqB;;IAIhC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;gBAEd,OAAO,EAAE,4BAA4B;IAO3C,UAAU,CACd,YAAY,EAAE,cAAc,EAC5B,KAAK,EAAE,eAAe,EACtB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,cAAc,CAAC;IA4DpB,QAAQ,CAAC,YAAY,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAOjE,UAAU,CAAC,YAAY,EAAE,cAAc,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBnE,eAAe,CACnB,YAAY,EAAE,cAAc,EAC5B,KAAK,EAAE;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAC9D,OAAO,CAAC;QACT,YAAY,EAAE,MAAM,CAAC;QACrB,mBAAmB,EAAE,MAAM,CAAC;QAC5B,UAAU,EAAE,OAAO,CAAC;KACrB,CAAC;IAmCI,WAAW,CAAC,YAAY,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC;IAkB1D,IAAI,CAAC,aAAa,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,eAAe,CAAC;IAIvD,wBAAwB,CAAC,YAAY,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CAsW5E"}
1
+ {"version":3,"file":"conversation-scheduler.d.ts","sourceRoot":"","sources":["../../../../src/zukhruf/plugins/conversation-scheduling/conversation-scheduler.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,KAAK,EAAQ,aAAa,EAAE,MAAM,qBAAqB,CAAC;AA0C/D,QAAA,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA0BvB,CAAC;AAEL,KAAK,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAC7D,KAAK,cAAc,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC;AAGtD,MAAM,WAAW,cAAc;IAC7B,YAAY,EAAE,cAAc,CAAC;IAC7B,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;CACtB;AAsBD,UAAU,4BAA4B;IACpC,SAAS,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;IACzC,IAAI,EAAE,eAAe,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE;QAAE,IAAI,EAAE;YAAE,GAAG,IAAI,MAAM,CAAA;SAAE,CAAA;KAAE,CAAC;CACpC;AAED,UAAU,eAAe;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,sEAAsE;AACtE,qBAAa,qBAAqB;;IAIhC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;gBAEd,OAAO,EAAE,4BAA4B;IAO3C,UAAU,CACd,YAAY,EAAE,cAAc,EAC5B,KAAK,EAAE,eAAe,EACtB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,cAAc,CAAC;IA4DpB,QAAQ,CAAC,YAAY,EAAE,cAAc,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAOjE,UAAU,CAAC,YAAY,EAAE,cAAc,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBnE,eAAe,CACnB,YAAY,EAAE,cAAc,EAC5B,KAAK,EAAE;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAC9D,OAAO,CAAC;QACT,YAAY,EAAE,MAAM,CAAC;QACrB,mBAAmB,EAAE,MAAM,CAAC;QAC5B,UAAU,EAAE,OAAO,CAAC;KACrB,CAAC;IAmCI,WAAW,CAAC,YAAY,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC;IAkB1D,IAAI,CAAC,aAAa,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,eAAe,CAAC;IAIvD,wBAAwB,CAAC,YAAY,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CAmW5E"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/zukhruf/plugins/conversation-scheduling/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,KAAK,qBAAqB,EAE3B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAEL,KAAK,cAAc,EACpB,MAAM,6BAA6B,CAAC;AAErC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,YAAY,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAElE,eAAO,MAAM,kCAAkC;;;IAO7C,iEAAiE;;cACxB;YAAE,GAAG,IAAI,MAAM,CAAA;SAAE;;CAGlD,CAAC;AAEX,+EAA+E;AAC/E,wBAAgB,sBAAsB,IAAI,qBAAqB,CAgC9D"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/zukhruf/plugins/conversation-scheduling/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,KAAK,qBAAqB,EAC3B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAEL,KAAK,cAAc,EACpB,MAAM,6BAA6B,CAAC;AAErC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,YAAY,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAElE,eAAO,MAAM,kCAAkC;;;IAO7C,iEAAiE;;cACxB;YAAE,GAAG,IAAI,MAAM,CAAA;SAAE;;CAGlD,CAAC;AAEX,+EAA+E;AAC/E,wBAAgB,sBAAsB,IAAI,qBAAqB,CAkC9D"}
@@ -33,7 +33,13 @@ var listedAgentSchema = z.object({
33
33
  }).strict();
34
34
 
35
35
  // packages/experimental/src/zukhruf/control-plane/agent-turn-id.ts
36
- import { v5 as uuidv53 } from "uuid";
36
+ import { v5 as uuidv53, validate as validateUuid } from "uuid";
37
+ import { z as z2 } from "zod";
38
+ var prefix = "zukhruf-turn";
39
+ var agentTurnIdSchema = z2.string().refine((value) => {
40
+ const [head, scope, turn, ...rest] = value.split(":");
41
+ return head === prefix && rest.length === 0 && validateUuid(scope) && validateUuid(turn);
42
+ });
37
43
  function conversationNamespace(conversation) {
38
44
  if (!conversation.chatId.trim() || !conversation.userId.trim()) {
39
45
  throw new Error("conversation requires non-empty chatId and userId");
@@ -72,7 +78,7 @@ import {
72
78
  asSchema,
73
79
  modelMessageSchema as modelMessageSchema2
74
80
  } from "ai";
75
- import { z as z2 } from "zod";
81
+ import { z as z3 } from "zod";
76
82
 
77
83
  // packages/compaction/dist/index.js
78
84
  import {
@@ -81,21 +87,21 @@ import {
81
87
  } from "ai";
82
88
 
83
89
  // packages/experimental/src/zukhruf/runtime/compaction.ts
84
- var checkpointSchema = z2.object({
85
- sourceCount: z2.number().int().positive(),
86
- sourceHash: z2.string(),
87
- replacement: z2.array(z2.unknown()).transform(
90
+ var checkpointSchema = z3.object({
91
+ sourceCount: z3.number().int().positive(),
92
+ sourceHash: z3.string(),
93
+ replacement: z3.array(z3.unknown()).transform(
88
94
  (messages) => messages.map((message) => modelMessageSchema2.parse(message))
89
95
  )
90
96
  });
91
- var cacheObservationSchema = z2.object({
92
- scope: z2.string(),
93
- prefixLength: z2.number().int().nonnegative(),
94
- prefixHash: z2.string(),
95
- startedAt: z2.number().int().nonnegative(),
96
- retentionMs: z2.number().int().positive().optional()
97
+ var cacheObservationSchema = z3.object({
98
+ scope: z3.string(),
99
+ prefixLength: z3.number().int().nonnegative(),
100
+ prefixHash: z3.string(),
101
+ startedAt: z3.number().int().nonnegative(),
102
+ retentionMs: z3.number().int().positive().optional()
97
103
  });
98
- var inputUsageSchema = cacheObservationSchema.pick({ scope: true, prefixLength: true, prefixHash: true }).extend({ inputTokens: z2.number().int().nonnegative() });
104
+ var inputUsageSchema = cacheObservationSchema.pick({ scope: true, prefixLength: true, prefixHash: true }).extend({ inputTokens: z3.number().int().nonnegative() });
99
105
 
100
106
  // packages/experimental/src/zukhruf/runtime/plugin/agent-skills.ts
101
107
  import {
@@ -122,21 +128,21 @@ import {
122
128
  } from "@deepagents/context";
123
129
 
124
130
  // packages/experimental/src/zukhruf/runtime/conversation-status/child-progress.ts
125
- import { z as z3 } from "zod";
126
- var childActivitySchema = z3.object({
127
- id: z3.string(),
128
- type: z3.enum(["spawn", "message", "followup", "interrupt", "completion"]),
129
- at: z3.number(),
130
- actorPath: z3.string(),
131
- targetPath: z3.string(),
132
- streamId: z3.string(),
133
- outcome: z3.enum(["completed", "failed", "cancelled"]).optional()
131
+ import { z as z4 } from "zod";
132
+ var childActivitySchema = z4.object({
133
+ id: z4.string(),
134
+ type: z4.enum(["spawn", "message", "followup", "interrupt", "completion"]),
135
+ at: z4.number(),
136
+ actorPath: z4.string(),
137
+ targetPath: z4.string(),
138
+ streamId: z4.string(),
139
+ outcome: z4.enum(["completed", "failed", "cancelled"]).optional()
134
140
  });
135
- var childActivitiesSchema = z3.partialRecord(
141
+ var childActivitiesSchema = z4.partialRecord(
136
142
  childActivitySchema.shape.type,
137
143
  childActivitySchema
138
144
  );
139
- var childActivityMetadataSchema = z3.looseObject({
145
+ var childActivityMetadataSchema = z4.looseObject({
140
146
  childActivities: childActivitiesSchema.default({})
141
147
  });
142
148
 
@@ -150,13 +156,13 @@ var DETACHED = new Detached();
150
156
 
151
157
  // packages/experimental/src/zukhruf/collaboration/interrupt-agent.ts
152
158
  import { tool as tool2 } from "ai";
153
- import { z as z4 } from "zod";
154
- var interruptAgentInputSchema = z4.object({
155
- target: z4.string().trim().min(1).describe(
159
+ import { z as z5 } from "zod";
160
+ var interruptAgentInputSchema = z5.object({
161
+ target: z5.string().trim().min(1).describe(
156
162
  "The canonical /root/... path, or a descendant-relative target name."
157
163
  )
158
164
  });
159
- var interruptAgentOutputSchema = z4.object({ previous_status: listedAgentStatusSchema }).strict();
165
+ var interruptAgentOutputSchema = z5.object({ previous_status: listedAgentStatusSchema }).strict();
160
166
  var interruptAgentTool = tool2({
161
167
  description: "Interrupt an agent's current turn, if any, and return its previous status. The agent remains available for messages and follow-up tasks.",
162
168
  inputSchema: interruptAgentInputSchema,
@@ -166,13 +172,13 @@ var interruptAgentTool = tool2({
166
172
 
167
173
  // packages/experimental/src/zukhruf/collaboration/list-agents.ts
168
174
  import { tool as tool3 } from "ai";
169
- import { z as z5 } from "zod";
170
- var listAgentsInputSchema = z5.object({
171
- path_prefix: z5.string().trim().min(1).describe(
175
+ import { z as z6 } from "zod";
176
+ var listAgentsInputSchema = z6.object({
177
+ path_prefix: z6.string().trim().min(1).describe(
172
178
  "Task-path prefix without a trailing slash. Omit to list the whole tree."
173
179
  ).optional()
174
180
  });
175
- var listAgentsOutputSchema = z5.object({ agents: z5.array(listedAgentSchema) }).strict();
181
+ var listAgentsOutputSchema = z6.object({ agents: z6.array(listedAgentSchema) }).strict();
176
182
  var listAgentsTool = tool3({
177
183
  description: "List live agents in the current root thread tree. Optionally filter by task-path prefix.",
178
184
  inputSchema: listAgentsInputSchema,
@@ -182,12 +188,12 @@ var listAgentsTool = tool3({
182
188
 
183
189
  // packages/experimental/src/zukhruf/collaboration/message-tools.ts
184
190
  import { tool as tool4 } from "ai";
185
- import { z as z6 } from "zod";
186
- var agentMessageInputSchema = z6.object({
187
- target: z6.string().trim().min(1).describe(
191
+ import { z as z7 } from "zod";
192
+ var agentMessageInputSchema = z7.object({
193
+ target: z7.string().trim().min(1).describe(
188
194
  "The canonical /root/... path, or a descendant-relative target name."
189
195
  ),
190
- message: z6.string().trim().min(1).describe("The message or follow-up task.")
196
+ message: z7.string().trim().min(1).describe("The message or follow-up task.")
191
197
  });
192
198
  var sendMessageTool = tool4({
193
199
  description: "Queue a message for another agent. Address siblings with their canonical /root/... path.",
@@ -208,7 +214,7 @@ var followupTaskTool = tool4({
208
214
 
209
215
  // packages/experimental/src/zukhruf/collaboration/spawn-agent.ts
210
216
  import { tool as tool5 } from "ai";
211
- import { z as z7 } from "zod";
217
+ import { z as z8 } from "zod";
212
218
 
213
219
  // packages/experimental/src/zukhruf/control-plane/fork-turns.ts
214
220
  var forkTurnsError = "fork_turns must be `none`, `all`, or a positive integer string";
@@ -221,23 +227,23 @@ function parseForkTurns(value) {
221
227
  }
222
228
 
223
229
  // packages/experimental/src/zukhruf/collaboration/spawn-agent.ts
224
- var spawnAgentInputSchema = z7.object({
225
- agent_type: z7.string().trim().min(1).describe("The name of one available subagent declaration."),
226
- task_name: z7.string().trim().min(1).refine(
230
+ var spawnAgentInputSchema = z8.object({
231
+ agent_type: z8.string().trim().min(1).describe("The name of one available subagent declaration."),
232
+ task_name: z8.string().trim().min(1).refine(
227
233
  (value) => value !== "." && value !== ".." && !value.includes("/"),
228
234
  "task_name must be one non-empty path segment"
229
235
  ).describe("One path segment naming this independent agent task."),
230
- message: z7.string().refine((value) => value.trim().length > 0, "message cannot be empty").describe("The initial task for the spawned agent."),
231
- fork_turns: z7.string().trim().refine((value) => parseForkTurns(value) !== void 0, forkTurnsError).describe(
236
+ message: z8.string().refine((value) => value.trim().length > 0, "message cannot be empty").describe("The initial task for the spawned agent."),
237
+ fork_turns: z8.string().trim().refine((value) => parseForkTurns(value) !== void 0, forkTurnsError).describe(
232
238
  "Required number of parent turns to fork. Use `none`, `all`, or a positive integer string such as `3`."
233
239
  )
234
240
  });
235
- var spawnAgentOutputSchema = z7.object({ task_name: z7.string() }).strict();
241
+ var spawnAgentOutputSchema = z8.object({ task_name: z8.string() }).strict();
236
242
 
237
243
  // packages/experimental/src/zukhruf/collaboration/wait-agent.ts
238
244
  import { tool as tool6 } from "ai";
239
- import { z as z8 } from "zod";
240
- var waitAgentOutputSchema = z8.object({ message: z8.string(), timed_out: z8.boolean() }).strict();
245
+ import { z as z9 } from "zod";
246
+ var waitAgentOutputSchema = z9.object({ message: z9.string(), timed_out: z9.boolean() }).strict();
241
247
 
242
248
  // packages/experimental/src/zukhruf/runtime/plugin/plugin-agents.ts
243
249
  import { parseFrontmatter as parseFrontmatter2, role as role2 } from "@deepagents/context";
@@ -270,28 +276,28 @@ var AgentPluginCapability = class {
270
276
  // packages/experimental/src/zukhruf/plugins/conversation-scheduling/conversation-scheduler.ts
271
277
  import { CronExpressionParser } from "cron-parser";
272
278
  import { v5 as uuidv55 } from "uuid";
273
- import { z as z9 } from "zod";
279
+ import { z as z10 } from "zod";
274
280
  import { isRecord } from "@deepagents/context";
275
281
  var DAY_MS = 24 * 60 * 60 * 1e3;
276
282
  var CRON_LIFETIME_MS = 7 * DAY_MS;
277
283
  var MAX_CRON_JOBS = 50;
278
- var cronDefinitionSchema = z9.object({
279
- id: z9.uuid(),
280
- expression: z9.string().min(1),
281
- prompt: z9.string(),
282
- recurring: z9.boolean(),
283
- timezone: z9.string().min(1),
284
- createdAt: z9.number().int().nonnegative(),
285
- expiresAt: z9.number().int().nonnegative(),
286
- nextRunAt: z9.number().int().nonnegative(),
287
- generation: z9.number().int().positive()
284
+ var cronDefinitionSchema = z10.object({
285
+ id: z10.uuid(),
286
+ expression: z10.string().min(1),
287
+ prompt: z10.string(),
288
+ recurring: z10.boolean(),
289
+ timezone: z10.string().min(1),
290
+ createdAt: z10.number().int().nonnegative(),
291
+ expiresAt: z10.number().int().nonnegative(),
292
+ nextRunAt: z10.number().int().nonnegative(),
293
+ generation: z10.number().int().positive()
288
294
  }).strict();
289
- var dispatchingOccurrenceSchema = z9.object({
290
- kind: z9.enum(["cron", "dynamic"]),
291
- definitionId: z9.uuid().optional(),
292
- generation: z9.number().int().positive(),
293
- scheduledFor: z9.number().int().nonnegative(),
294
- prompt: z9.string()
295
+ var dispatchingOccurrenceSchema = z10.object({
296
+ kind: z10.enum(["cron", "dynamic"]),
297
+ definitionId: z10.uuid().optional(),
298
+ generation: z10.number().int().positive(),
299
+ scheduledFor: z10.number().int().nonnegative(),
300
+ prompt: z10.string()
295
301
  }).strict().superRefine((occurrence, context) => {
296
302
  if (occurrence.kind === "cron" !== (occurrence.definitionId !== void 0)) {
297
303
  context.addIssue({
@@ -300,14 +306,14 @@ var dispatchingOccurrenceSchema = z9.object({
300
306
  });
301
307
  }
302
308
  });
303
- var schedulingStateSchema = z9.object({
304
- cron: z9.record(z9.string(), cronDefinitionSchema),
305
- dynamic: z9.object({
306
- prompt: z9.string(),
307
- reason: z9.string(),
308
- createdAt: z9.number().int().nonnegative(),
309
- nextRunAt: z9.number().int().nonnegative(),
310
- generation: z9.number().int().positive()
309
+ var schedulingStateSchema = z10.object({
310
+ cron: z10.record(z10.string(), cronDefinitionSchema),
311
+ dynamic: z10.object({
312
+ prompt: z10.string(),
313
+ reason: z10.string(),
314
+ createdAt: z10.number().int().nonnegative(),
315
+ nextRunAt: z10.number().int().nonnegative(),
316
+ generation: z10.number().int().positive()
311
317
  }).strict().optional(),
312
318
  dispatching: dispatchingOccurrenceSchema.optional()
313
319
  }).strict().superRefine(({ cron }, context) => {
@@ -321,12 +327,12 @@ var schedulingStateSchema = z9.object({
321
327
  }
322
328
  }
323
329
  });
324
- var schedulingWakeSchema = z9.object({
325
- conversation: z9.object({ chatId: z9.string().min(1), userId: z9.string().min(1) }).strict(),
326
- kind: z9.enum(["cron", "dynamic"]),
327
- definitionId: z9.uuid().optional(),
328
- generation: z9.number().int().positive(),
329
- scheduledFor: z9.number().int().nonnegative()
330
+ var schedulingWakeSchema = z10.object({
331
+ conversation: z10.object({ chatId: z10.string().min(1), userId: z10.string().min(1) }).strict(),
332
+ kind: z10.enum(["cron", "dynamic"]),
333
+ definitionId: z10.uuid().optional(),
334
+ generation: z10.number().int().positive(),
335
+ scheduledFor: z10.number().int().nonnegative()
330
336
  }).strict().superRefine((wake, context) => {
331
337
  if (wake.kind === "cron" !== (wake.definitionId !== void 0)) {
332
338
  context.addIssue({
@@ -473,7 +479,7 @@ var ConversationScheduler = class _ConversationScheduler {
473
479
  return this.#scheduler.consume((wake) => this.#handle(wake), waitForActive);
474
480
  }
475
481
  async materializeDueIfEligible(conversation) {
476
- if (!await this.#host().isConversationAvailable(conversation)) return;
482
+ if (!await this.#host.isConversationAvailable(conversation)) return;
477
483
  const state = await this.#read(conversation);
478
484
  const now = this.#clock.Date.now();
479
485
  const wake = state.dispatching ? this.#dispatchingWake(conversation, state.dispatching) : [
@@ -502,8 +508,7 @@ var ConversationScheduler = class _ConversationScheduler {
502
508
  `Scheduling wake id "${rawWake.id}" does not match its payload`
503
509
  );
504
510
  }
505
- if (!await this.#host().isConversationAvailable(wake.conversation))
506
- return;
511
+ if (!await this.#host.isConversationAvailable(wake.conversation)) return;
507
512
  const state = await this.#read(wake.conversation);
508
513
  const dispatching = this.#matchingDispatching(state, wake);
509
514
  if (dispatching) {
@@ -584,7 +589,7 @@ var ConversationScheduler = class _ConversationScheduler {
584
589
  scheduledFor: wake.scheduledFor,
585
590
  occurrenceId
586
591
  };
587
- await this.#host().enqueue(wake.conversation, {
592
+ await this.#host.enqueue(wake.conversation, {
588
593
  message: {
589
594
  id: occurrenceId,
590
595
  role: "user",
@@ -693,12 +698,10 @@ var ConversationScheduler = class _ConversationScheduler {
693
698
  }
694
699
  }
695
700
  async #read(conversation) {
696
- return this.#parse(
697
- await this.#host().readConversationMetadata(conversation)
698
- );
701
+ return this.#parse(await this.#host.readConversationMetadata(conversation));
699
702
  }
700
703
  async #update(conversation, update) {
701
- await this.#host().updateConversationMetadata(conversation, (stored) => {
704
+ await this.#host.updateConversationMetadata(conversation, (stored) => {
702
705
  const state = update(this.#parse(stored));
703
706
  const metadata = stored ?? {};
704
707
  const zukhruf = _ConversationScheduler.#record(metadata.zukhruf);
@@ -744,52 +747,52 @@ var ConversationScheduler = class _ConversationScheduler {
744
747
  // packages/experimental/src/zukhruf/plugins/conversation-scheduling/tools.ts
745
748
  import { tool as tool7 } from "ai";
746
749
  import cronstrue from "cronstrue";
747
- import { z as z10 } from "zod";
748
- var nonBlank = z10.string().refine((value) => value.trim().length > 0, {
750
+ import { z as z11 } from "zod";
751
+ var nonBlank = z11.string().refine((value) => value.trim().length > 0, {
749
752
  message: "must not be blank"
750
753
  });
751
- var cronCreateInput = z10.object({
752
- cron: z10.string().trim().min(1),
754
+ var cronCreateInput = z11.object({
755
+ cron: z11.string().trim().min(1),
753
756
  prompt: nonBlank,
754
- recurring: z10.boolean().optional()
757
+ recurring: z11.boolean().optional()
755
758
  }).strict();
756
- var cronOutput = z10.object({
757
- id: z10.uuid(),
758
- humanSchedule: z10.string(),
759
- nextRunAt: z10.number(),
760
- timezone: z10.string(),
761
- recurring: z10.boolean(),
762
- warning: z10.string().optional()
759
+ var cronOutput = z11.object({
760
+ id: z11.uuid(),
761
+ humanSchedule: z11.string(),
762
+ nextRunAt: z11.number(),
763
+ timezone: z11.string(),
764
+ recurring: z11.boolean(),
765
+ warning: z11.string().optional()
763
766
  }).strict();
764
- var cronListOutput = z10.object({
765
- jobs: z10.array(
766
- z10.object({
767
- id: z10.uuid(),
768
- cron: z10.string(),
769
- humanSchedule: z10.string(),
770
- nextRunAt: z10.number(),
771
- timezone: z10.string(),
772
- prompt: z10.string(),
773
- recurring: z10.boolean().optional()
767
+ var cronListOutput = z11.object({
768
+ jobs: z11.array(
769
+ z11.object({
770
+ id: z11.uuid(),
771
+ cron: z11.string(),
772
+ humanSchedule: z11.string(),
773
+ nextRunAt: z11.number(),
774
+ timezone: z11.string(),
775
+ prompt: z11.string(),
776
+ recurring: z11.boolean().optional()
774
777
  }).strict()
775
778
  )
776
779
  }).strict();
777
- var cronDeleteInput = z10.object({ id: z10.uuid() }).strict();
778
- var cronDeleteOutput = z10.object({ id: z10.uuid() }).strict();
779
- var scheduleWakeupInput = z10.union([
780
- z10.object({ stop: z10.literal(true) }).strict(),
781
- z10.object({
782
- delaySeconds: z10.number().min(60).max(3600),
780
+ var cronDeleteInput = z11.object({ id: z11.uuid() }).strict();
781
+ var cronDeleteOutput = z11.object({ id: z11.uuid() }).strict();
782
+ var scheduleWakeupInput = z11.union([
783
+ z11.object({ stop: z11.literal(true) }).strict(),
784
+ z11.object({
785
+ delaySeconds: z11.number().min(60).max(3600),
783
786
  reason: nonBlank,
784
787
  prompt: nonBlank
785
788
  }).strict()
786
789
  ]);
787
- var scheduleWakeupOutput = z10.object({
788
- scheduledFor: z10.number(),
789
- clampedDelaySeconds: z10.number(),
790
- wasClamped: z10.boolean(),
791
- stopped: z10.boolean().optional(),
792
- cancelledWakeups: z10.number().int().nonnegative().optional()
790
+ var scheduleWakeupOutput = z11.object({
791
+ scheduledFor: z11.number(),
792
+ clampedDelaySeconds: z11.number(),
793
+ wasClamped: z11.boolean(),
794
+ stopped: z11.boolean().optional(),
795
+ cancelledWakeups: z11.number().int().nonnegative().optional()
793
796
  }).strict();
794
797
  var schedulingToolMetadata = {
795
798
  zukhruf: {
@@ -838,7 +841,7 @@ function createSchedulingTools(conversationScheduler) {
838
841
  }),
839
842
  CronList: tool7({
840
843
  description: "List durable cron schedules in this conversation.",
841
- inputSchema: z10.object({}).strict(),
844
+ inputSchema: z11.object({}).strict(),
842
845
  outputSchema: cronListOutput,
843
846
  metadata: schedulingToolMetadata,
844
847
  execute: async (_input, { context }) => {
@@ -1002,24 +1005,27 @@ function conversationScheduling() {
1002
1005
  conversationSchedulingCapabilities.clock
1003
1006
  ],
1004
1007
  create(bindings) {
1005
- let host = () => {
1006
- throw new Error(
1007
- "conversation-scheduling plugin must be initialized before use"
1008
- );
1009
- };
1010
- const scheduler = new ConversationScheduler({
1011
- scheduler: bindings.get(conversationSchedulingCapabilities.scheduler),
1012
- host: () => host(),
1013
- timezone: bindings.get(conversationSchedulingCapabilities.timezone),
1014
- clock: bindings.get(conversationSchedulingCapabilities.clock)
1015
- });
1008
+ const scheduler = bindings.get(
1009
+ conversationSchedulingCapabilities.scheduler
1010
+ );
1011
+ const timezone = bindings.get(
1012
+ conversationSchedulingCapabilities.timezone
1013
+ );
1014
+ const clock = bindings.get(conversationSchedulingCapabilities.clock);
1016
1015
  return {
1017
- tools: createSchedulingTools(scheduler),
1018
- async initialize(runtimeHost) {
1019
- host = () => runtimeHost;
1020
- },
1021
- work: (_host, waitForActive) => scheduler.work(waitForActive),
1022
- conversationAvailable: (_host, conversation) => scheduler.materializeDueIfEligible(conversation)
1016
+ async initialize(host) {
1017
+ const conversationScheduler = new ConversationScheduler({
1018
+ scheduler,
1019
+ host,
1020
+ timezone,
1021
+ clock
1022
+ });
1023
+ return {
1024
+ tools: createSchedulingTools(conversationScheduler),
1025
+ work: (waitForActive) => conversationScheduler.work(waitForActive),
1026
+ conversationAvailable: (conversation) => conversationScheduler.materializeDueIfEligible(conversation)
1027
+ };
1028
+ }
1023
1029
  };
1024
1030
  }
1025
1031
  };