@deepagents/experimental 7.7.2 → 7.8.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.
@@ -3,6 +3,7 @@ export * from './control-plane/agent-path.ts';
3
3
  export * from './control-plane/agent-thread.ts';
4
4
  export { ConversationNotFoundError } from './control-plane/conversation-not-found-error.ts';
5
5
  export * from './instructions.ts';
6
+ export * from './mailbox/postgres.store.ts';
6
7
  export * from './mailbox/sqlite.store.ts';
7
8
  export * from './mailbox/store.ts';
8
9
  export * from './mailbox/types.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,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,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"}
@@ -202,48 +202,12 @@ function defineInstructions(...fragments) {
202
202
  return fragments;
203
203
  }
204
204
 
205
- // packages/experimental/src/zukhruf/mailbox/sqlite.store.ts
206
- import { Declaration } from "@zukhruf/sqlite-drift";
207
- import { open } from "@zukhruf/sqlite-open";
208
- import { transaction } from "@zukhruf/sqlite-transaction";
209
- import { z } from "zod";
210
-
211
- // packages/experimental/src/zukhruf/mailbox/ddl.sqlite.ts
212
- var SETUP = `
213
- PRAGMA synchronous = NORMAL;
214
- `;
215
- var statements = [
216
- `CREATE TABLE zukhruf_mailbox_items (
217
- sequence INTEGER PRIMARY KEY AUTOINCREMENT,
218
- recipient_chat_id TEXT NOT NULL,
219
- recipient_user_id TEXT NOT NULL,
220
- communication TEXT NOT NULL
221
- )`,
222
- `CREATE TABLE zukhruf_mailbox_activity (
223
- recipient_chat_id TEXT NOT NULL,
224
- recipient_user_id TEXT NOT NULL,
225
- turn_id TEXT NOT NULL,
226
- PRIMARY KEY (recipient_chat_id, recipient_user_id)
227
- )`,
228
- `CREATE TABLE zukhruf_mailbox_consumed_terminal_ids (
229
- communication_id TEXT PRIMARY KEY
230
- )`,
231
- `CREATE INDEX zukhruf_mailbox_recipient_sequence
232
- ON zukhruf_mailbox_items (
233
- recipient_chat_id,
234
- recipient_user_id,
235
- sequence
236
- )`,
237
- // enqueue relies on this index through INSERT OR IGNORE.
238
- `CREATE UNIQUE INDEX zukhruf_mailbox_communication_id
239
- ON zukhruf_mailbox_items (
240
- json_extract(communication, '$.id')
241
- )`
242
- ];
205
+ // packages/experimental/src/zukhruf/mailbox/postgres.store.ts
206
+ import { z as z2 } from "zod";
207
+ import { lockSchemaDDL, postgresTransaction } from "@deepagents/context";
243
208
 
244
- // packages/experimental/src/zukhruf/mailbox/store.ts
245
- var MailboxStore = class {
246
- };
209
+ // packages/experimental/src/zukhruf/mailbox/communication-schema.ts
210
+ import { z } from "zod";
247
211
 
248
212
  // packages/experimental/src/zukhruf/mailbox/types.ts
249
213
  import { randomUUID } from "node:crypto";
@@ -291,8 +255,7 @@ function assertConversationId(value, label) {
291
255
  }
292
256
  }
293
257
 
294
- // packages/experimental/src/zukhruf/mailbox/sqlite.store.ts
295
- var tables = new Declaration(statements, { rows: "keep" });
258
+ // packages/experimental/src/zukhruf/mailbox/communication-schema.ts
296
259
  var conversationIdSchema = z.object({
297
260
  chatId: z.string(),
298
261
  userId: z.string()
@@ -307,10 +270,249 @@ var communicationSchema = z.object({
307
270
  metadata: z.record(z.string(), z.unknown()).optional(),
308
271
  triggerTurn: z.boolean()
309
272
  });
310
- var mailboxItemRowsSchema = z.array(
311
- z.object({
312
- sequence: z.number(),
313
- communication: z.string().transform((text) => JSON.parse(text)).pipe(communicationSchema)
273
+
274
+ // packages/experimental/src/zukhruf/mailbox/ddl.postgres.ts
275
+ function mailboxDDL(schema) {
276
+ return `
277
+ CREATE SCHEMA IF NOT EXISTS "${schema}";
278
+
279
+ CREATE TABLE IF NOT EXISTS "${schema}"."zukhruf_mailbox_items" (
280
+ sequence BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
281
+ communication_id TEXT NOT NULL UNIQUE,
282
+ recipient_chat_id TEXT NOT NULL,
283
+ recipient_user_id TEXT NOT NULL,
284
+ communication JSONB NOT NULL
285
+ );
286
+
287
+ CREATE INDEX IF NOT EXISTS "zukhruf_mailbox_recipient_sequence"
288
+ ON "${schema}"."zukhruf_mailbox_items" (recipient_chat_id, recipient_user_id, sequence);
289
+
290
+ CREATE TABLE IF NOT EXISTS "${schema}"."zukhruf_mailbox_activity" (
291
+ recipient_chat_id TEXT NOT NULL,
292
+ recipient_user_id TEXT NOT NULL,
293
+ turn_id TEXT NOT NULL,
294
+ PRIMARY KEY (recipient_chat_id, recipient_user_id)
295
+ );
296
+
297
+ CREATE TABLE IF NOT EXISTS "${schema}"."zukhruf_mailbox_consumed_terminal_ids" (
298
+ communication_id TEXT PRIMARY KEY
299
+ );
300
+ `;
301
+ }
302
+
303
+ // packages/experimental/src/zukhruf/mailbox/store.ts
304
+ var MailboxStore = class {
305
+ };
306
+
307
+ // packages/experimental/src/zukhruf/mailbox/postgres.store.ts
308
+ var mailboxItemRowsSchema = z2.array(
309
+ z2.object({
310
+ sequence: z2.string(),
311
+ communication: communicationSchema
312
+ })
313
+ );
314
+ var existsRowsSchema = z2.tuple([z2.object({ exists: z2.boolean() })]);
315
+ var PostgresMailboxStore = class _PostgresMailboxStore extends MailboxStore {
316
+ #pool;
317
+ #schema;
318
+ constructor(pool, schema) {
319
+ super();
320
+ this.#pool = pool;
321
+ this.#schema = schema;
322
+ }
323
+ /** Opens the store: creates its schema objects before it returns. */
324
+ static async create(options) {
325
+ const schema = options.schema ?? "public";
326
+ await options.pool.query(lockSchemaDDL(mailboxDDL(schema), schema));
327
+ return new _PostgresMailboxStore(options.pool, schema);
328
+ }
329
+ #t(name) {
330
+ return `"${this.#schema}"."${name}"`;
331
+ }
332
+ /**
333
+ * Runs `fn` while holding the recipient's lock, so enqueue, drain and turn
334
+ * handoff on one mailbox take turns across every worker, as SQLite's
335
+ * immediate transactions do.
336
+ */
337
+ #forRecipient(recipient, fn) {
338
+ return postgresTransaction(this.#pool, async (client) => {
339
+ await client.query(
340
+ "SELECT pg_advisory_xact_lock(hashtextextended($1, 0))",
341
+ [
342
+ `zukhruf:mailbox:${JSON.stringify([this.#schema, recipient.chatId, recipient.userId])}`
343
+ ]
344
+ );
345
+ return fn(client);
346
+ });
347
+ }
348
+ async beginTurn(recipient, turnId) {
349
+ await this.#forRecipient(
350
+ recipient,
351
+ (client) => client.query(
352
+ `INSERT INTO ${this.#t("zukhruf_mailbox_activity")}
353
+ (recipient_chat_id, recipient_user_id, turn_id)
354
+ VALUES ($1, $2, $3)
355
+ ON CONFLICT (recipient_chat_id, recipient_user_id)
356
+ DO UPDATE SET turn_id = EXCLUDED.turn_id`,
357
+ [recipient.chatId, recipient.userId, turnId]
358
+ )
359
+ );
360
+ }
361
+ enqueue(communication) {
362
+ const { recipient } = communication;
363
+ return this.#forRecipient(recipient, async (client) => {
364
+ const consumedTerminal = communication.type === InterAgentCommunicationTypes.FinalAnswer && await this.#exists(
365
+ client,
366
+ `SELECT EXISTS (
367
+ SELECT 1 FROM ${this.#t("zukhruf_mailbox_consumed_terminal_ids")}
368
+ WHERE communication_id = $1)`,
369
+ [communication.id]
370
+ );
371
+ if (!consumedTerminal) {
372
+ await client.query(
373
+ `INSERT INTO ${this.#t("zukhruf_mailbox_items")}
374
+ (communication_id, recipient_chat_id, recipient_user_id, communication)
375
+ VALUES ($1, $2, $3, $4::jsonb)
376
+ ON CONFLICT (communication_id) DO NOTHING`,
377
+ [
378
+ communication.id,
379
+ recipient.chatId,
380
+ recipient.userId,
381
+ JSON.stringify(communication)
382
+ ]
383
+ );
384
+ }
385
+ return { recipientActive: await this.#isTurnActive(client, recipient) };
386
+ });
387
+ }
388
+ endTurn(recipient, turnId) {
389
+ return this.#forRecipient(recipient, async (client) => {
390
+ const ended = await client.query(
391
+ `DELETE FROM ${this.#t("zukhruf_mailbox_activity")}
392
+ WHERE recipient_chat_id = $1
393
+ AND recipient_user_id = $2
394
+ AND turn_id = $3`,
395
+ [recipient.chatId, recipient.userId, turnId]
396
+ );
397
+ return {
398
+ hasPending: await this.#hasPending(client, recipient),
399
+ turnEnded: ended.rowCount === 1
400
+ };
401
+ });
402
+ }
403
+ hasPending(recipient) {
404
+ return this.#hasPending(this.#pool, recipient);
405
+ }
406
+ drain(recipient) {
407
+ return this.#drain(recipient, false);
408
+ }
409
+ drainLeadingQueueOnly(recipient) {
410
+ return this.#drain(recipient, true);
411
+ }
412
+ #drain(recipient, leadingQueueOnly) {
413
+ return this.#forRecipient(recipient, async (client) => {
414
+ const items = mailboxItemRowsSchema.parse(
415
+ (await client.query(
416
+ `SELECT sequence, communication
417
+ FROM ${this.#t("zukhruf_mailbox_items")}
418
+ WHERE recipient_chat_id = $1
419
+ AND recipient_user_id = $2
420
+ ORDER BY sequence`,
421
+ [recipient.chatId, recipient.userId]
422
+ )).rows
423
+ );
424
+ const firstTrigger = leadingQueueOnly ? items.findIndex(({ communication }) => communication.triggerTurn) : -1;
425
+ const consumed = firstTrigger === -1 ? items : items.slice(0, firstTrigger);
426
+ if (consumed.length === 0) return [];
427
+ await client.query(
428
+ `INSERT INTO ${this.#t("zukhruf_mailbox_consumed_terminal_ids")} (communication_id)
429
+ SELECT unnest($1::text[])
430
+ ON CONFLICT (communication_id) DO NOTHING`,
431
+ [
432
+ consumed.flatMap(
433
+ ({ communication }) => communication.type === InterAgentCommunicationTypes.FinalAnswer ? [communication.id] : []
434
+ )
435
+ ]
436
+ );
437
+ await client.query(
438
+ `DELETE FROM ${this.#t("zukhruf_mailbox_items")}
439
+ WHERE sequence = ANY($1::bigint[])`,
440
+ [consumed.map(({ sequence }) => sequence)]
441
+ );
442
+ return consumed.map(({ communication }) => communication);
443
+ });
444
+ }
445
+ #hasPending(queryable, recipient) {
446
+ return this.#exists(
447
+ queryable,
448
+ `SELECT EXISTS (
449
+ SELECT 1 FROM ${this.#t("zukhruf_mailbox_items")}
450
+ WHERE recipient_chat_id = $1 AND recipient_user_id = $2)`,
451
+ [recipient.chatId, recipient.userId]
452
+ );
453
+ }
454
+ #isTurnActive(client, recipient) {
455
+ return this.#exists(
456
+ client,
457
+ `SELECT EXISTS (
458
+ SELECT 1 FROM ${this.#t("zukhruf_mailbox_activity")}
459
+ WHERE recipient_chat_id = $1 AND recipient_user_id = $2)`,
460
+ [recipient.chatId, recipient.userId]
461
+ );
462
+ }
463
+ async #exists(queryable, sql, params) {
464
+ const [{ exists }] = existsRowsSchema.parse(
465
+ (await queryable.query(sql, params)).rows
466
+ );
467
+ return exists;
468
+ }
469
+ };
470
+
471
+ // packages/experimental/src/zukhruf/mailbox/sqlite.store.ts
472
+ import { Declaration } from "@zukhruf/sqlite-drift";
473
+ import { open } from "@zukhruf/sqlite-open";
474
+ import { transaction } from "@zukhruf/sqlite-transaction";
475
+ import { z as z3 } from "zod";
476
+
477
+ // packages/experimental/src/zukhruf/mailbox/ddl.sqlite.ts
478
+ var SETUP = `
479
+ PRAGMA synchronous = NORMAL;
480
+ `;
481
+ var statements = [
482
+ `CREATE TABLE zukhruf_mailbox_items (
483
+ sequence INTEGER PRIMARY KEY AUTOINCREMENT,
484
+ recipient_chat_id TEXT NOT NULL,
485
+ recipient_user_id TEXT NOT NULL,
486
+ communication TEXT NOT NULL
487
+ )`,
488
+ `CREATE TABLE zukhruf_mailbox_activity (
489
+ recipient_chat_id TEXT NOT NULL,
490
+ recipient_user_id TEXT NOT NULL,
491
+ turn_id TEXT NOT NULL,
492
+ PRIMARY KEY (recipient_chat_id, recipient_user_id)
493
+ )`,
494
+ `CREATE TABLE zukhruf_mailbox_consumed_terminal_ids (
495
+ communication_id TEXT PRIMARY KEY
496
+ )`,
497
+ `CREATE INDEX zukhruf_mailbox_recipient_sequence
498
+ ON zukhruf_mailbox_items (
499
+ recipient_chat_id,
500
+ recipient_user_id,
501
+ sequence
502
+ )`,
503
+ // enqueue relies on this index through INSERT OR IGNORE.
504
+ `CREATE UNIQUE INDEX zukhruf_mailbox_communication_id
505
+ ON zukhruf_mailbox_items (
506
+ json_extract(communication, '$.id')
507
+ )`
508
+ ];
509
+
510
+ // packages/experimental/src/zukhruf/mailbox/sqlite.store.ts
511
+ var tables = new Declaration(statements, { rows: "keep" });
512
+ var mailboxItemRowsSchema2 = z3.array(
513
+ z3.object({
514
+ sequence: z3.number(),
515
+ communication: z3.string().transform((text) => JSON.parse(text)).pipe(communicationSchema)
314
516
  })
315
517
  );
316
518
  var SqliteMailboxStore = class extends MailboxStore {
@@ -423,7 +625,7 @@ var SqliteMailboxStore = class extends MailboxStore {
423
625
  return transaction(
424
626
  this.#database,
425
627
  () => {
426
- const items = mailboxItemRowsSchema.parse(
628
+ const items = mailboxItemRowsSchema2.parse(
427
629
  this.#database.prepare(
428
630
  `SELECT sequence, communication
429
631
  FROM zukhruf_mailbox_items
@@ -469,7 +671,7 @@ var SqliteMailboxStore = class extends MailboxStore {
469
671
 
470
672
  // packages/experimental/src/zukhruf/queue/pg-boss.turn-queue.ts
471
673
  import { v7 as uuidv7 } from "uuid";
472
- import { z as z2 } from "zod";
674
+ import { z as z4 } from "zod";
473
675
  import { isRecord } from "@deepagents/context";
474
676
 
475
677
  // packages/experimental/src/zukhruf/queue/turn-queue.ts
@@ -478,7 +680,7 @@ var TurnQueue = class {
478
680
 
479
681
  // packages/experimental/src/zukhruf/queue/pg-boss.turn-queue.ts
480
682
  var MAX_TIMEOUT_MS = 2147483647;
481
- var queueCatalogRowSchema = z2.object({ table: z2.string() });
683
+ var queueCatalogRowSchema = z4.object({ table: z4.string() });
482
684
  function deadLetterQueueOf(queue) {
483
685
  return `${queue}-dead`;
484
686
  }
@@ -1359,17 +1561,17 @@ function arraysEqual(left, right) {
1359
1561
 
1360
1562
  // packages/experimental/src/zukhruf/control-plane/agent-status-projector.ts
1361
1563
  import { isTextUIPart } from "ai";
1362
- import { z as z3 } from "zod";
1564
+ import { z as z5 } from "zod";
1363
1565
  import {
1364
1566
  ContextEngine
1365
1567
  } from "@deepagents/context";
1366
- var listedAgentStatusSchema = z3.union([
1367
- z3.enum(["pending_init", "running", "interrupted", "shutdown", "not_found"]),
1368
- z3.object({ completed: z3.string().nullable() }).strict(),
1369
- z3.object({ errored: z3.string() }).strict()
1568
+ var listedAgentStatusSchema = z5.union([
1569
+ z5.enum(["pending_init", "running", "interrupted", "shutdown", "not_found"]),
1570
+ z5.object({ completed: z5.string().nullable() }).strict(),
1571
+ z5.object({ errored: z5.string() }).strict()
1370
1572
  ]);
1371
- var listedAgentSchema = z3.object({
1372
- agent_name: z3.string(),
1573
+ var listedAgentSchema = z5.object({
1574
+ agent_name: z5.string(),
1373
1575
  agent_status: listedAgentStatusSchema
1374
1576
  }).strict();
1375
1577
  var AgentStatusProjector = class _AgentStatusProjector {
@@ -2041,7 +2243,7 @@ import {
2041
2243
  modelMessageSchema as modelMessageSchema2
2042
2244
  } from "ai";
2043
2245
  import { hash, randomUUID as randomUUID2 } from "node:crypto";
2044
- import { z as z4 } from "zod";
2246
+ import { z as z6 } from "zod";
2045
2247
 
2046
2248
  // packages/compaction/dist/index.js
2047
2249
  import {
@@ -2245,21 +2447,21 @@ ${options.instructions}` : SUMMARY_PROMPT,
2245
2447
  }
2246
2448
 
2247
2449
  // packages/experimental/src/zukhruf/runtime/compaction.ts
2248
- var checkpointSchema = z4.object({
2249
- sourceCount: z4.number().int().positive(),
2250
- sourceHash: z4.string(),
2251
- replacement: z4.array(z4.unknown()).transform(
2450
+ var checkpointSchema = z6.object({
2451
+ sourceCount: z6.number().int().positive(),
2452
+ sourceHash: z6.string(),
2453
+ replacement: z6.array(z6.unknown()).transform(
2252
2454
  (messages) => messages.map((message) => modelMessageSchema2.parse(message))
2253
2455
  )
2254
2456
  });
2255
- var cacheObservationSchema = z4.object({
2256
- scope: z4.string(),
2257
- prefixLength: z4.number().int().nonnegative(),
2258
- prefixHash: z4.string(),
2259
- startedAt: z4.number().int().nonnegative(),
2260
- retentionMs: z4.number().int().positive().optional()
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()
2261
2463
  });
2262
- var inputUsageSchema = cacheObservationSchema.pick({ scope: true, prefixLength: true, prefixHash: true }).extend({ inputTokens: z4.number().int().nonnegative() });
2464
+ var inputUsageSchema = cacheObservationSchema.pick({ scope: true, prefixLength: true, prefixHash: true }).extend({ inputTokens: z6.number().int().nonnegative() });
2263
2465
  function jsonDigest(value) {
2264
2466
  return hash("sha256", JSON.stringify(value));
2265
2467
  }
@@ -3338,21 +3540,21 @@ import {
3338
3540
  } from "@deepagents/context";
3339
3541
 
3340
3542
  // packages/experimental/src/zukhruf/runtime/conversation-status/child-progress.ts
3341
- import { z as z5 } from "zod";
3342
- var childActivitySchema = z5.object({
3343
- id: z5.string(),
3344
- type: z5.enum(["spawn", "message", "followup", "interrupt", "completion"]),
3345
- at: z5.number(),
3346
- actorPath: z5.string(),
3347
- targetPath: z5.string(),
3348
- streamId: z5.string(),
3349
- outcome: z5.enum(["completed", "failed", "cancelled"]).optional()
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()
3350
3552
  });
3351
- var childActivitiesSchema = z5.partialRecord(
3553
+ var childActivitiesSchema = z7.partialRecord(
3352
3554
  childActivitySchema.shape.type,
3353
3555
  childActivitySchema
3354
3556
  );
3355
- var childActivityMetadataSchema = z5.looseObject({
3557
+ var childActivityMetadataSchema = z7.looseObject({
3356
3558
  childActivities: childActivitiesSchema.default({})
3357
3559
  });
3358
3560
 
@@ -3646,13 +3848,13 @@ var StatusPublishingTurnQueue = class extends TurnQueue {
3646
3848
 
3647
3849
  // packages/experimental/src/zukhruf/collaboration/interrupt-agent.ts
3648
3850
  import { tool as tool2 } from "ai";
3649
- import { z as z6 } from "zod";
3650
- var interruptAgentInputSchema = z6.object({
3651
- target: z6.string().trim().min(1).describe(
3851
+ import { z as z8 } from "zod";
3852
+ var interruptAgentInputSchema = z8.object({
3853
+ target: z8.string().trim().min(1).describe(
3652
3854
  "The canonical /root/... path, or a descendant-relative target name."
3653
3855
  )
3654
3856
  });
3655
- var interruptAgentOutputSchema = z6.object({ previous_status: listedAgentStatusSchema }).strict();
3857
+ var interruptAgentOutputSchema = z8.object({ previous_status: listedAgentStatusSchema }).strict();
3656
3858
  var interruptAgentTool = tool2({
3657
3859
  description: "Interrupt an agent's current turn, if any, and return its previous status. The agent remains available for messages and follow-up tasks.",
3658
3860
  inputSchema: interruptAgentInputSchema,
@@ -3662,13 +3864,13 @@ var interruptAgentTool = tool2({
3662
3864
 
3663
3865
  // packages/experimental/src/zukhruf/collaboration/list-agents.ts
3664
3866
  import { tool as tool3 } from "ai";
3665
- import { z as z7 } from "zod";
3666
- var listAgentsInputSchema = z7.object({
3667
- path_prefix: z7.string().trim().min(1).describe(
3867
+ import { z as z9 } from "zod";
3868
+ var listAgentsInputSchema = z9.object({
3869
+ path_prefix: z9.string().trim().min(1).describe(
3668
3870
  "Task-path prefix without a trailing slash. Omit to list the whole tree."
3669
3871
  ).optional()
3670
3872
  });
3671
- var listAgentsOutputSchema = z7.object({ agents: z7.array(listedAgentSchema) }).strict();
3873
+ var listAgentsOutputSchema = z9.object({ agents: z9.array(listedAgentSchema) }).strict();
3672
3874
  var listAgentsTool = tool3({
3673
3875
  description: "List live agents in the current root thread tree. Optionally filter by task-path prefix.",
3674
3876
  inputSchema: listAgentsInputSchema,
@@ -3678,12 +3880,12 @@ var listAgentsTool = tool3({
3678
3880
 
3679
3881
  // packages/experimental/src/zukhruf/collaboration/message-tools.ts
3680
3882
  import { tool as tool4 } from "ai";
3681
- import { z as z8 } from "zod";
3682
- var agentMessageInputSchema = z8.object({
3683
- target: z8.string().trim().min(1).describe(
3883
+ import { z as z10 } from "zod";
3884
+ var agentMessageInputSchema = z10.object({
3885
+ target: z10.string().trim().min(1).describe(
3684
3886
  "The canonical /root/... path, or a descendant-relative target name."
3685
3887
  ),
3686
- message: z8.string().trim().min(1).describe("The message or follow-up task.")
3888
+ message: z10.string().trim().min(1).describe("The message or follow-up task.")
3687
3889
  });
3688
3890
  var sendMessageTool = tool4({
3689
3891
  description: "Queue a message for another agent. Address siblings with their canonical /root/... path.",
@@ -3704,7 +3906,7 @@ var followupTaskTool = tool4({
3704
3906
 
3705
3907
  // packages/experimental/src/zukhruf/collaboration/spawn-agent.ts
3706
3908
  import { tool as tool5 } from "ai";
3707
- import { z as z9 } from "zod";
3909
+ import { z as z11 } from "zod";
3708
3910
 
3709
3911
  // packages/experimental/src/zukhruf/control-plane/fork-turns.ts
3710
3912
  var forkTurnsError = "fork_turns must be `none`, `all`, or a positive integer string";
@@ -3717,18 +3919,18 @@ function parseForkTurns(value) {
3717
3919
  }
3718
3920
 
3719
3921
  // packages/experimental/src/zukhruf/collaboration/spawn-agent.ts
3720
- var spawnAgentInputSchema = z9.object({
3721
- agent_type: z9.string().trim().min(1).describe("The name of one available subagent declaration."),
3722
- task_name: z9.string().trim().min(1).refine(
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(
3723
3925
  (value) => value !== "." && value !== ".." && !value.includes("/"),
3724
3926
  "task_name must be one non-empty path segment"
3725
3927
  ).describe("One path segment naming this independent agent task."),
3726
- message: z9.string().refine((value) => value.trim().length > 0, "message cannot be empty").describe("The initial task for the spawned agent."),
3727
- fork_turns: z9.string().trim().refine((value) => parseForkTurns(value) !== void 0, forkTurnsError).describe(
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(
3728
3930
  "Required number of parent turns to fork. Use `none`, `all`, or a positive integer string such as `3`."
3729
3931
  )
3730
3932
  });
3731
- var spawnAgentOutputSchema = z9.object({ task_name: z9.string() }).strict();
3933
+ var spawnAgentOutputSchema = z11.object({ task_name: z11.string() }).strict();
3732
3934
  function createSpawnAgentTool(options) {
3733
3935
  return tool5({
3734
3936
  description: ({ context }) => {
@@ -3757,11 +3959,11 @@ function createSpawnAgentTool(options) {
3757
3959
 
3758
3960
  // packages/experimental/src/zukhruf/collaboration/wait-agent.ts
3759
3961
  import { tool as tool6 } from "ai";
3760
- import { z as z10 } from "zod";
3761
- var waitAgentOutputSchema = z10.object({ message: z10.string(), timed_out: z10.boolean() }).strict();
3962
+ import { z as z12 } from "zod";
3963
+ var waitAgentOutputSchema = z12.object({ message: z12.string(), timed_out: z12.boolean() }).strict();
3762
3964
  function createWaitAgentTool(options) {
3763
- const waitAgentInputSchema = z10.object({
3764
- timeout_ms: z10.number().int().max(options.maxTimeoutMs).optional().describe("Maximum time to wait in milliseconds.")
3965
+ const waitAgentInputSchema = z12.object({
3966
+ timeout_ms: z12.number().int().max(options.maxTimeoutMs).optional().describe("Maximum time to wait in milliseconds.")
3765
3967
  });
3766
3968
  return tool6({
3767
3969
  description: "Wait for pending mail addressed to this agent without consuming it.",
@@ -4821,6 +5023,7 @@ export {
4821
5023
  MessageDeliveryModes,
4822
5024
  PgBossConversationStatusChangeSource,
4823
5025
  PgBossTurnQueue,
5026
+ PostgresMailboxStore,
4824
5027
  SqliteMailboxStore,
4825
5028
  TurnQueue,
4826
5029
  assertCommunication,