@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.
- package/dist/index.js +306 -103
- package/dist/index.js.map +4 -4
- package/dist/zukhruf/index.d.ts +1 -0
- package/dist/zukhruf/index.d.ts.map +1 -1
- package/dist/zukhruf/index.js +306 -103
- package/dist/zukhruf/index.js.map +4 -4
- package/dist/zukhruf/mailbox/communication-schema.d.ts +26 -0
- package/dist/zukhruf/mailbox/communication-schema.d.ts.map +1 -0
- package/dist/zukhruf/mailbox/ddl.postgres.d.ts +2 -0
- package/dist/zukhruf/mailbox/ddl.postgres.d.ts.map +1 -0
- package/dist/zukhruf/mailbox/postgres.store.d.ts +23 -0
- package/dist/zukhruf/mailbox/postgres.store.d.ts.map +1 -0
- package/dist/zukhruf/mailbox/sqlite.store.d.ts.map +1 -1
- package/package.json +13 -4
package/dist/index.js
CHANGED
|
@@ -332,6 +332,7 @@ __export(zukhruf_exports, {
|
|
|
332
332
|
MessageDeliveryModes: () => MessageDeliveryModes,
|
|
333
333
|
PgBossConversationStatusChangeSource: () => PgBossConversationStatusChangeSource,
|
|
334
334
|
PgBossTurnQueue: () => PgBossTurnQueue,
|
|
335
|
+
PostgresMailboxStore: () => PostgresMailboxStore,
|
|
335
336
|
SqliteMailboxStore: () => SqliteMailboxStore,
|
|
336
337
|
TurnQueue: () => TurnQueue,
|
|
337
338
|
assertCommunication: () => assertCommunication,
|
|
@@ -547,48 +548,12 @@ function defineInstructions(...fragments) {
|
|
|
547
548
|
return fragments;
|
|
548
549
|
}
|
|
549
550
|
|
|
550
|
-
// packages/experimental/src/zukhruf/mailbox/
|
|
551
|
-
import {
|
|
552
|
-
import {
|
|
553
|
-
import { transaction } from "@zukhruf/sqlite-transaction";
|
|
554
|
-
import { z } from "zod";
|
|
555
|
-
|
|
556
|
-
// packages/experimental/src/zukhruf/mailbox/ddl.sqlite.ts
|
|
557
|
-
var SETUP = `
|
|
558
|
-
PRAGMA synchronous = NORMAL;
|
|
559
|
-
`;
|
|
560
|
-
var statements = [
|
|
561
|
-
`CREATE TABLE zukhruf_mailbox_items (
|
|
562
|
-
sequence INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
563
|
-
recipient_chat_id TEXT NOT NULL,
|
|
564
|
-
recipient_user_id TEXT NOT NULL,
|
|
565
|
-
communication TEXT NOT NULL
|
|
566
|
-
)`,
|
|
567
|
-
`CREATE TABLE zukhruf_mailbox_activity (
|
|
568
|
-
recipient_chat_id TEXT NOT NULL,
|
|
569
|
-
recipient_user_id TEXT NOT NULL,
|
|
570
|
-
turn_id TEXT NOT NULL,
|
|
571
|
-
PRIMARY KEY (recipient_chat_id, recipient_user_id)
|
|
572
|
-
)`,
|
|
573
|
-
`CREATE TABLE zukhruf_mailbox_consumed_terminal_ids (
|
|
574
|
-
communication_id TEXT PRIMARY KEY
|
|
575
|
-
)`,
|
|
576
|
-
`CREATE INDEX zukhruf_mailbox_recipient_sequence
|
|
577
|
-
ON zukhruf_mailbox_items (
|
|
578
|
-
recipient_chat_id,
|
|
579
|
-
recipient_user_id,
|
|
580
|
-
sequence
|
|
581
|
-
)`,
|
|
582
|
-
// enqueue relies on this index through INSERT OR IGNORE.
|
|
583
|
-
`CREATE UNIQUE INDEX zukhruf_mailbox_communication_id
|
|
584
|
-
ON zukhruf_mailbox_items (
|
|
585
|
-
json_extract(communication, '$.id')
|
|
586
|
-
)`
|
|
587
|
-
];
|
|
551
|
+
// packages/experimental/src/zukhruf/mailbox/postgres.store.ts
|
|
552
|
+
import { z as z2 } from "zod";
|
|
553
|
+
import { lockSchemaDDL, postgresTransaction } from "@deepagents/context";
|
|
588
554
|
|
|
589
|
-
// packages/experimental/src/zukhruf/mailbox/
|
|
590
|
-
|
|
591
|
-
};
|
|
555
|
+
// packages/experimental/src/zukhruf/mailbox/communication-schema.ts
|
|
556
|
+
import { z } from "zod";
|
|
592
557
|
|
|
593
558
|
// packages/experimental/src/zukhruf/mailbox/types.ts
|
|
594
559
|
import { randomUUID } from "node:crypto";
|
|
@@ -636,8 +601,7 @@ function assertConversationId(value, label) {
|
|
|
636
601
|
}
|
|
637
602
|
}
|
|
638
603
|
|
|
639
|
-
// packages/experimental/src/zukhruf/mailbox/
|
|
640
|
-
var tables = new Declaration(statements, { rows: "keep" });
|
|
604
|
+
// packages/experimental/src/zukhruf/mailbox/communication-schema.ts
|
|
641
605
|
var conversationIdSchema = z.object({
|
|
642
606
|
chatId: z.string(),
|
|
643
607
|
userId: z.string()
|
|
@@ -652,10 +616,249 @@ var communicationSchema = z.object({
|
|
|
652
616
|
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
653
617
|
triggerTurn: z.boolean()
|
|
654
618
|
});
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
619
|
+
|
|
620
|
+
// packages/experimental/src/zukhruf/mailbox/ddl.postgres.ts
|
|
621
|
+
function mailboxDDL(schema) {
|
|
622
|
+
return `
|
|
623
|
+
CREATE SCHEMA IF NOT EXISTS "${schema}";
|
|
624
|
+
|
|
625
|
+
CREATE TABLE IF NOT EXISTS "${schema}"."zukhruf_mailbox_items" (
|
|
626
|
+
sequence BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
|
627
|
+
communication_id TEXT NOT NULL UNIQUE,
|
|
628
|
+
recipient_chat_id TEXT NOT NULL,
|
|
629
|
+
recipient_user_id TEXT NOT NULL,
|
|
630
|
+
communication JSONB NOT NULL
|
|
631
|
+
);
|
|
632
|
+
|
|
633
|
+
CREATE INDEX IF NOT EXISTS "zukhruf_mailbox_recipient_sequence"
|
|
634
|
+
ON "${schema}"."zukhruf_mailbox_items" (recipient_chat_id, recipient_user_id, sequence);
|
|
635
|
+
|
|
636
|
+
CREATE TABLE IF NOT EXISTS "${schema}"."zukhruf_mailbox_activity" (
|
|
637
|
+
recipient_chat_id TEXT NOT NULL,
|
|
638
|
+
recipient_user_id TEXT NOT NULL,
|
|
639
|
+
turn_id TEXT NOT NULL,
|
|
640
|
+
PRIMARY KEY (recipient_chat_id, recipient_user_id)
|
|
641
|
+
);
|
|
642
|
+
|
|
643
|
+
CREATE TABLE IF NOT EXISTS "${schema}"."zukhruf_mailbox_consumed_terminal_ids" (
|
|
644
|
+
communication_id TEXT PRIMARY KEY
|
|
645
|
+
);
|
|
646
|
+
`;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
// packages/experimental/src/zukhruf/mailbox/store.ts
|
|
650
|
+
var MailboxStore = class {
|
|
651
|
+
};
|
|
652
|
+
|
|
653
|
+
// packages/experimental/src/zukhruf/mailbox/postgres.store.ts
|
|
654
|
+
var mailboxItemRowsSchema = z2.array(
|
|
655
|
+
z2.object({
|
|
656
|
+
sequence: z2.string(),
|
|
657
|
+
communication: communicationSchema
|
|
658
|
+
})
|
|
659
|
+
);
|
|
660
|
+
var existsRowsSchema = z2.tuple([z2.object({ exists: z2.boolean() })]);
|
|
661
|
+
var PostgresMailboxStore = class _PostgresMailboxStore extends MailboxStore {
|
|
662
|
+
#pool;
|
|
663
|
+
#schema;
|
|
664
|
+
constructor(pool, schema) {
|
|
665
|
+
super();
|
|
666
|
+
this.#pool = pool;
|
|
667
|
+
this.#schema = schema;
|
|
668
|
+
}
|
|
669
|
+
/** Opens the store: creates its schema objects before it returns. */
|
|
670
|
+
static async create(options) {
|
|
671
|
+
const schema = options.schema ?? "public";
|
|
672
|
+
await options.pool.query(lockSchemaDDL(mailboxDDL(schema), schema));
|
|
673
|
+
return new _PostgresMailboxStore(options.pool, schema);
|
|
674
|
+
}
|
|
675
|
+
#t(name) {
|
|
676
|
+
return `"${this.#schema}"."${name}"`;
|
|
677
|
+
}
|
|
678
|
+
/**
|
|
679
|
+
* Runs `fn` while holding the recipient's lock, so enqueue, drain and turn
|
|
680
|
+
* handoff on one mailbox take turns across every worker, as SQLite's
|
|
681
|
+
* immediate transactions do.
|
|
682
|
+
*/
|
|
683
|
+
#forRecipient(recipient, fn) {
|
|
684
|
+
return postgresTransaction(this.#pool, async (client) => {
|
|
685
|
+
await client.query(
|
|
686
|
+
"SELECT pg_advisory_xact_lock(hashtextextended($1, 0))",
|
|
687
|
+
[
|
|
688
|
+
`zukhruf:mailbox:${JSON.stringify([this.#schema, recipient.chatId, recipient.userId])}`
|
|
689
|
+
]
|
|
690
|
+
);
|
|
691
|
+
return fn(client);
|
|
692
|
+
});
|
|
693
|
+
}
|
|
694
|
+
async beginTurn(recipient, turnId) {
|
|
695
|
+
await this.#forRecipient(
|
|
696
|
+
recipient,
|
|
697
|
+
(client) => client.query(
|
|
698
|
+
`INSERT INTO ${this.#t("zukhruf_mailbox_activity")}
|
|
699
|
+
(recipient_chat_id, recipient_user_id, turn_id)
|
|
700
|
+
VALUES ($1, $2, $3)
|
|
701
|
+
ON CONFLICT (recipient_chat_id, recipient_user_id)
|
|
702
|
+
DO UPDATE SET turn_id = EXCLUDED.turn_id`,
|
|
703
|
+
[recipient.chatId, recipient.userId, turnId]
|
|
704
|
+
)
|
|
705
|
+
);
|
|
706
|
+
}
|
|
707
|
+
enqueue(communication) {
|
|
708
|
+
const { recipient } = communication;
|
|
709
|
+
return this.#forRecipient(recipient, async (client) => {
|
|
710
|
+
const consumedTerminal = communication.type === InterAgentCommunicationTypes.FinalAnswer && await this.#exists(
|
|
711
|
+
client,
|
|
712
|
+
`SELECT EXISTS (
|
|
713
|
+
SELECT 1 FROM ${this.#t("zukhruf_mailbox_consumed_terminal_ids")}
|
|
714
|
+
WHERE communication_id = $1)`,
|
|
715
|
+
[communication.id]
|
|
716
|
+
);
|
|
717
|
+
if (!consumedTerminal) {
|
|
718
|
+
await client.query(
|
|
719
|
+
`INSERT INTO ${this.#t("zukhruf_mailbox_items")}
|
|
720
|
+
(communication_id, recipient_chat_id, recipient_user_id, communication)
|
|
721
|
+
VALUES ($1, $2, $3, $4::jsonb)
|
|
722
|
+
ON CONFLICT (communication_id) DO NOTHING`,
|
|
723
|
+
[
|
|
724
|
+
communication.id,
|
|
725
|
+
recipient.chatId,
|
|
726
|
+
recipient.userId,
|
|
727
|
+
JSON.stringify(communication)
|
|
728
|
+
]
|
|
729
|
+
);
|
|
730
|
+
}
|
|
731
|
+
return { recipientActive: await this.#isTurnActive(client, recipient) };
|
|
732
|
+
});
|
|
733
|
+
}
|
|
734
|
+
endTurn(recipient, turnId) {
|
|
735
|
+
return this.#forRecipient(recipient, async (client) => {
|
|
736
|
+
const ended = await client.query(
|
|
737
|
+
`DELETE FROM ${this.#t("zukhruf_mailbox_activity")}
|
|
738
|
+
WHERE recipient_chat_id = $1
|
|
739
|
+
AND recipient_user_id = $2
|
|
740
|
+
AND turn_id = $3`,
|
|
741
|
+
[recipient.chatId, recipient.userId, turnId]
|
|
742
|
+
);
|
|
743
|
+
return {
|
|
744
|
+
hasPending: await this.#hasPending(client, recipient),
|
|
745
|
+
turnEnded: ended.rowCount === 1
|
|
746
|
+
};
|
|
747
|
+
});
|
|
748
|
+
}
|
|
749
|
+
hasPending(recipient) {
|
|
750
|
+
return this.#hasPending(this.#pool, recipient);
|
|
751
|
+
}
|
|
752
|
+
drain(recipient) {
|
|
753
|
+
return this.#drain(recipient, false);
|
|
754
|
+
}
|
|
755
|
+
drainLeadingQueueOnly(recipient) {
|
|
756
|
+
return this.#drain(recipient, true);
|
|
757
|
+
}
|
|
758
|
+
#drain(recipient, leadingQueueOnly) {
|
|
759
|
+
return this.#forRecipient(recipient, async (client) => {
|
|
760
|
+
const items = mailboxItemRowsSchema.parse(
|
|
761
|
+
(await client.query(
|
|
762
|
+
`SELECT sequence, communication
|
|
763
|
+
FROM ${this.#t("zukhruf_mailbox_items")}
|
|
764
|
+
WHERE recipient_chat_id = $1
|
|
765
|
+
AND recipient_user_id = $2
|
|
766
|
+
ORDER BY sequence`,
|
|
767
|
+
[recipient.chatId, recipient.userId]
|
|
768
|
+
)).rows
|
|
769
|
+
);
|
|
770
|
+
const firstTrigger = leadingQueueOnly ? items.findIndex(({ communication }) => communication.triggerTurn) : -1;
|
|
771
|
+
const consumed = firstTrigger === -1 ? items : items.slice(0, firstTrigger);
|
|
772
|
+
if (consumed.length === 0) return [];
|
|
773
|
+
await client.query(
|
|
774
|
+
`INSERT INTO ${this.#t("zukhruf_mailbox_consumed_terminal_ids")} (communication_id)
|
|
775
|
+
SELECT unnest($1::text[])
|
|
776
|
+
ON CONFLICT (communication_id) DO NOTHING`,
|
|
777
|
+
[
|
|
778
|
+
consumed.flatMap(
|
|
779
|
+
({ communication }) => communication.type === InterAgentCommunicationTypes.FinalAnswer ? [communication.id] : []
|
|
780
|
+
)
|
|
781
|
+
]
|
|
782
|
+
);
|
|
783
|
+
await client.query(
|
|
784
|
+
`DELETE FROM ${this.#t("zukhruf_mailbox_items")}
|
|
785
|
+
WHERE sequence = ANY($1::bigint[])`,
|
|
786
|
+
[consumed.map(({ sequence }) => sequence)]
|
|
787
|
+
);
|
|
788
|
+
return consumed.map(({ communication }) => communication);
|
|
789
|
+
});
|
|
790
|
+
}
|
|
791
|
+
#hasPending(queryable, recipient) {
|
|
792
|
+
return this.#exists(
|
|
793
|
+
queryable,
|
|
794
|
+
`SELECT EXISTS (
|
|
795
|
+
SELECT 1 FROM ${this.#t("zukhruf_mailbox_items")}
|
|
796
|
+
WHERE recipient_chat_id = $1 AND recipient_user_id = $2)`,
|
|
797
|
+
[recipient.chatId, recipient.userId]
|
|
798
|
+
);
|
|
799
|
+
}
|
|
800
|
+
#isTurnActive(client, recipient) {
|
|
801
|
+
return this.#exists(
|
|
802
|
+
client,
|
|
803
|
+
`SELECT EXISTS (
|
|
804
|
+
SELECT 1 FROM ${this.#t("zukhruf_mailbox_activity")}
|
|
805
|
+
WHERE recipient_chat_id = $1 AND recipient_user_id = $2)`,
|
|
806
|
+
[recipient.chatId, recipient.userId]
|
|
807
|
+
);
|
|
808
|
+
}
|
|
809
|
+
async #exists(queryable, sql, params) {
|
|
810
|
+
const [{ exists }] = existsRowsSchema.parse(
|
|
811
|
+
(await queryable.query(sql, params)).rows
|
|
812
|
+
);
|
|
813
|
+
return exists;
|
|
814
|
+
}
|
|
815
|
+
};
|
|
816
|
+
|
|
817
|
+
// packages/experimental/src/zukhruf/mailbox/sqlite.store.ts
|
|
818
|
+
import { Declaration } from "@zukhruf/sqlite-drift";
|
|
819
|
+
import { open } from "@zukhruf/sqlite-open";
|
|
820
|
+
import { transaction } from "@zukhruf/sqlite-transaction";
|
|
821
|
+
import { z as z3 } from "zod";
|
|
822
|
+
|
|
823
|
+
// packages/experimental/src/zukhruf/mailbox/ddl.sqlite.ts
|
|
824
|
+
var SETUP = `
|
|
825
|
+
PRAGMA synchronous = NORMAL;
|
|
826
|
+
`;
|
|
827
|
+
var statements = [
|
|
828
|
+
`CREATE TABLE zukhruf_mailbox_items (
|
|
829
|
+
sequence INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
830
|
+
recipient_chat_id TEXT NOT NULL,
|
|
831
|
+
recipient_user_id TEXT NOT NULL,
|
|
832
|
+
communication TEXT NOT NULL
|
|
833
|
+
)`,
|
|
834
|
+
`CREATE TABLE zukhruf_mailbox_activity (
|
|
835
|
+
recipient_chat_id TEXT NOT NULL,
|
|
836
|
+
recipient_user_id TEXT NOT NULL,
|
|
837
|
+
turn_id TEXT NOT NULL,
|
|
838
|
+
PRIMARY KEY (recipient_chat_id, recipient_user_id)
|
|
839
|
+
)`,
|
|
840
|
+
`CREATE TABLE zukhruf_mailbox_consumed_terminal_ids (
|
|
841
|
+
communication_id TEXT PRIMARY KEY
|
|
842
|
+
)`,
|
|
843
|
+
`CREATE INDEX zukhruf_mailbox_recipient_sequence
|
|
844
|
+
ON zukhruf_mailbox_items (
|
|
845
|
+
recipient_chat_id,
|
|
846
|
+
recipient_user_id,
|
|
847
|
+
sequence
|
|
848
|
+
)`,
|
|
849
|
+
// enqueue relies on this index through INSERT OR IGNORE.
|
|
850
|
+
`CREATE UNIQUE INDEX zukhruf_mailbox_communication_id
|
|
851
|
+
ON zukhruf_mailbox_items (
|
|
852
|
+
json_extract(communication, '$.id')
|
|
853
|
+
)`
|
|
854
|
+
];
|
|
855
|
+
|
|
856
|
+
// packages/experimental/src/zukhruf/mailbox/sqlite.store.ts
|
|
857
|
+
var tables = new Declaration(statements, { rows: "keep" });
|
|
858
|
+
var mailboxItemRowsSchema2 = z3.array(
|
|
859
|
+
z3.object({
|
|
860
|
+
sequence: z3.number(),
|
|
861
|
+
communication: z3.string().transform((text) => JSON.parse(text)).pipe(communicationSchema)
|
|
659
862
|
})
|
|
660
863
|
);
|
|
661
864
|
var SqliteMailboxStore = class extends MailboxStore {
|
|
@@ -768,7 +971,7 @@ var SqliteMailboxStore = class extends MailboxStore {
|
|
|
768
971
|
return transaction(
|
|
769
972
|
this.#database,
|
|
770
973
|
() => {
|
|
771
|
-
const items =
|
|
974
|
+
const items = mailboxItemRowsSchema2.parse(
|
|
772
975
|
this.#database.prepare(
|
|
773
976
|
`SELECT sequence, communication
|
|
774
977
|
FROM zukhruf_mailbox_items
|
|
@@ -814,7 +1017,7 @@ var SqliteMailboxStore = class extends MailboxStore {
|
|
|
814
1017
|
|
|
815
1018
|
// packages/experimental/src/zukhruf/queue/pg-boss.turn-queue.ts
|
|
816
1019
|
import { v7 as uuidv7 } from "uuid";
|
|
817
|
-
import { z as
|
|
1020
|
+
import { z as z4 } from "zod";
|
|
818
1021
|
import { isRecord } from "@deepagents/context";
|
|
819
1022
|
|
|
820
1023
|
// packages/experimental/src/zukhruf/queue/turn-queue.ts
|
|
@@ -823,7 +1026,7 @@ var TurnQueue = class {
|
|
|
823
1026
|
|
|
824
1027
|
// packages/experimental/src/zukhruf/queue/pg-boss.turn-queue.ts
|
|
825
1028
|
var MAX_TIMEOUT_MS = 2147483647;
|
|
826
|
-
var queueCatalogRowSchema =
|
|
1029
|
+
var queueCatalogRowSchema = z4.object({ table: z4.string() });
|
|
827
1030
|
function deadLetterQueueOf(queue) {
|
|
828
1031
|
return `${queue}-dead`;
|
|
829
1032
|
}
|
|
@@ -1704,17 +1907,17 @@ function arraysEqual(left, right) {
|
|
|
1704
1907
|
|
|
1705
1908
|
// packages/experimental/src/zukhruf/control-plane/agent-status-projector.ts
|
|
1706
1909
|
import { isTextUIPart } from "ai";
|
|
1707
|
-
import { z as
|
|
1910
|
+
import { z as z5 } from "zod";
|
|
1708
1911
|
import {
|
|
1709
1912
|
ContextEngine
|
|
1710
1913
|
} from "@deepagents/context";
|
|
1711
|
-
var listedAgentStatusSchema =
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1914
|
+
var listedAgentStatusSchema = z5.union([
|
|
1915
|
+
z5.enum(["pending_init", "running", "interrupted", "shutdown", "not_found"]),
|
|
1916
|
+
z5.object({ completed: z5.string().nullable() }).strict(),
|
|
1917
|
+
z5.object({ errored: z5.string() }).strict()
|
|
1715
1918
|
]);
|
|
1716
|
-
var listedAgentSchema =
|
|
1717
|
-
agent_name:
|
|
1919
|
+
var listedAgentSchema = z5.object({
|
|
1920
|
+
agent_name: z5.string(),
|
|
1718
1921
|
agent_status: listedAgentStatusSchema
|
|
1719
1922
|
}).strict();
|
|
1720
1923
|
var AgentStatusProjector = class _AgentStatusProjector {
|
|
@@ -2386,7 +2589,7 @@ import {
|
|
|
2386
2589
|
modelMessageSchema as modelMessageSchema2
|
|
2387
2590
|
} from "ai";
|
|
2388
2591
|
import { hash, randomUUID as randomUUID2 } from "node:crypto";
|
|
2389
|
-
import { z as
|
|
2592
|
+
import { z as z6 } from "zod";
|
|
2390
2593
|
|
|
2391
2594
|
// packages/compaction/dist/index.js
|
|
2392
2595
|
import {
|
|
@@ -2590,21 +2793,21 @@ ${options.instructions}` : SUMMARY_PROMPT,
|
|
|
2590
2793
|
}
|
|
2591
2794
|
|
|
2592
2795
|
// packages/experimental/src/zukhruf/runtime/compaction.ts
|
|
2593
|
-
var checkpointSchema =
|
|
2594
|
-
sourceCount:
|
|
2595
|
-
sourceHash:
|
|
2596
|
-
replacement:
|
|
2796
|
+
var checkpointSchema = z6.object({
|
|
2797
|
+
sourceCount: z6.number().int().positive(),
|
|
2798
|
+
sourceHash: z6.string(),
|
|
2799
|
+
replacement: z6.array(z6.unknown()).transform(
|
|
2597
2800
|
(messages) => messages.map((message) => modelMessageSchema2.parse(message))
|
|
2598
2801
|
)
|
|
2599
2802
|
});
|
|
2600
|
-
var cacheObservationSchema =
|
|
2601
|
-
scope:
|
|
2602
|
-
prefixLength:
|
|
2603
|
-
prefixHash:
|
|
2604
|
-
startedAt:
|
|
2605
|
-
retentionMs:
|
|
2803
|
+
var cacheObservationSchema = z6.object({
|
|
2804
|
+
scope: z6.string(),
|
|
2805
|
+
prefixLength: z6.number().int().nonnegative(),
|
|
2806
|
+
prefixHash: z6.string(),
|
|
2807
|
+
startedAt: z6.number().int().nonnegative(),
|
|
2808
|
+
retentionMs: z6.number().int().positive().optional()
|
|
2606
2809
|
});
|
|
2607
|
-
var inputUsageSchema = cacheObservationSchema.pick({ scope: true, prefixLength: true, prefixHash: true }).extend({ inputTokens:
|
|
2810
|
+
var inputUsageSchema = cacheObservationSchema.pick({ scope: true, prefixLength: true, prefixHash: true }).extend({ inputTokens: z6.number().int().nonnegative() });
|
|
2608
2811
|
function jsonDigest(value) {
|
|
2609
2812
|
return hash("sha256", JSON.stringify(value));
|
|
2610
2813
|
}
|
|
@@ -3683,21 +3886,21 @@ import {
|
|
|
3683
3886
|
} from "@deepagents/context";
|
|
3684
3887
|
|
|
3685
3888
|
// packages/experimental/src/zukhruf/runtime/conversation-status/child-progress.ts
|
|
3686
|
-
import { z as
|
|
3687
|
-
var childActivitySchema =
|
|
3688
|
-
id:
|
|
3689
|
-
type:
|
|
3690
|
-
at:
|
|
3691
|
-
actorPath:
|
|
3692
|
-
targetPath:
|
|
3693
|
-
streamId:
|
|
3694
|
-
outcome:
|
|
3889
|
+
import { z as z7 } from "zod";
|
|
3890
|
+
var childActivitySchema = z7.object({
|
|
3891
|
+
id: z7.string(),
|
|
3892
|
+
type: z7.enum(["spawn", "message", "followup", "interrupt", "completion"]),
|
|
3893
|
+
at: z7.number(),
|
|
3894
|
+
actorPath: z7.string(),
|
|
3895
|
+
targetPath: z7.string(),
|
|
3896
|
+
streamId: z7.string(),
|
|
3897
|
+
outcome: z7.enum(["completed", "failed", "cancelled"]).optional()
|
|
3695
3898
|
});
|
|
3696
|
-
var childActivitiesSchema =
|
|
3899
|
+
var childActivitiesSchema = z7.partialRecord(
|
|
3697
3900
|
childActivitySchema.shape.type,
|
|
3698
3901
|
childActivitySchema
|
|
3699
3902
|
);
|
|
3700
|
-
var childActivityMetadataSchema =
|
|
3903
|
+
var childActivityMetadataSchema = z7.looseObject({
|
|
3701
3904
|
childActivities: childActivitiesSchema.default({})
|
|
3702
3905
|
});
|
|
3703
3906
|
|
|
@@ -3991,13 +4194,13 @@ var StatusPublishingTurnQueue = class extends TurnQueue {
|
|
|
3991
4194
|
|
|
3992
4195
|
// packages/experimental/src/zukhruf/collaboration/interrupt-agent.ts
|
|
3993
4196
|
import { tool as tool2 } from "ai";
|
|
3994
|
-
import { z as
|
|
3995
|
-
var interruptAgentInputSchema =
|
|
3996
|
-
target:
|
|
4197
|
+
import { z as z8 } from "zod";
|
|
4198
|
+
var interruptAgentInputSchema = z8.object({
|
|
4199
|
+
target: z8.string().trim().min(1).describe(
|
|
3997
4200
|
"The canonical /root/... path, or a descendant-relative target name."
|
|
3998
4201
|
)
|
|
3999
4202
|
});
|
|
4000
|
-
var interruptAgentOutputSchema =
|
|
4203
|
+
var interruptAgentOutputSchema = z8.object({ previous_status: listedAgentStatusSchema }).strict();
|
|
4001
4204
|
var interruptAgentTool = tool2({
|
|
4002
4205
|
description: "Interrupt an agent's current turn, if any, and return its previous status. The agent remains available for messages and follow-up tasks.",
|
|
4003
4206
|
inputSchema: interruptAgentInputSchema,
|
|
@@ -4007,13 +4210,13 @@ var interruptAgentTool = tool2({
|
|
|
4007
4210
|
|
|
4008
4211
|
// packages/experimental/src/zukhruf/collaboration/list-agents.ts
|
|
4009
4212
|
import { tool as tool3 } from "ai";
|
|
4010
|
-
import { z as
|
|
4011
|
-
var listAgentsInputSchema =
|
|
4012
|
-
path_prefix:
|
|
4213
|
+
import { z as z9 } from "zod";
|
|
4214
|
+
var listAgentsInputSchema = z9.object({
|
|
4215
|
+
path_prefix: z9.string().trim().min(1).describe(
|
|
4013
4216
|
"Task-path prefix without a trailing slash. Omit to list the whole tree."
|
|
4014
4217
|
).optional()
|
|
4015
4218
|
});
|
|
4016
|
-
var listAgentsOutputSchema =
|
|
4219
|
+
var listAgentsOutputSchema = z9.object({ agents: z9.array(listedAgentSchema) }).strict();
|
|
4017
4220
|
var listAgentsTool = tool3({
|
|
4018
4221
|
description: "List live agents in the current root thread tree. Optionally filter by task-path prefix.",
|
|
4019
4222
|
inputSchema: listAgentsInputSchema,
|
|
@@ -4023,12 +4226,12 @@ var listAgentsTool = tool3({
|
|
|
4023
4226
|
|
|
4024
4227
|
// packages/experimental/src/zukhruf/collaboration/message-tools.ts
|
|
4025
4228
|
import { tool as tool4 } from "ai";
|
|
4026
|
-
import { z as
|
|
4027
|
-
var agentMessageInputSchema =
|
|
4028
|
-
target:
|
|
4229
|
+
import { z as z10 } from "zod";
|
|
4230
|
+
var agentMessageInputSchema = z10.object({
|
|
4231
|
+
target: z10.string().trim().min(1).describe(
|
|
4029
4232
|
"The canonical /root/... path, or a descendant-relative target name."
|
|
4030
4233
|
),
|
|
4031
|
-
message:
|
|
4234
|
+
message: z10.string().trim().min(1).describe("The message or follow-up task.")
|
|
4032
4235
|
});
|
|
4033
4236
|
var sendMessageTool = tool4({
|
|
4034
4237
|
description: "Queue a message for another agent. Address siblings with their canonical /root/... path.",
|
|
@@ -4049,7 +4252,7 @@ var followupTaskTool = tool4({
|
|
|
4049
4252
|
|
|
4050
4253
|
// packages/experimental/src/zukhruf/collaboration/spawn-agent.ts
|
|
4051
4254
|
import { tool as tool5 } from "ai";
|
|
4052
|
-
import { z as
|
|
4255
|
+
import { z as z11 } from "zod";
|
|
4053
4256
|
|
|
4054
4257
|
// packages/experimental/src/zukhruf/control-plane/fork-turns.ts
|
|
4055
4258
|
var forkTurnsError = "fork_turns must be `none`, `all`, or a positive integer string";
|
|
@@ -4062,18 +4265,18 @@ function parseForkTurns(value) {
|
|
|
4062
4265
|
}
|
|
4063
4266
|
|
|
4064
4267
|
// packages/experimental/src/zukhruf/collaboration/spawn-agent.ts
|
|
4065
|
-
var spawnAgentInputSchema =
|
|
4066
|
-
agent_type:
|
|
4067
|
-
task_name:
|
|
4268
|
+
var spawnAgentInputSchema = z11.object({
|
|
4269
|
+
agent_type: z11.string().trim().min(1).describe("The name of one available subagent declaration."),
|
|
4270
|
+
task_name: z11.string().trim().min(1).refine(
|
|
4068
4271
|
(value) => value !== "." && value !== ".." && !value.includes("/"),
|
|
4069
4272
|
"task_name must be one non-empty path segment"
|
|
4070
4273
|
).describe("One path segment naming this independent agent task."),
|
|
4071
|
-
message:
|
|
4072
|
-
fork_turns:
|
|
4274
|
+
message: z11.string().refine((value) => value.trim().length > 0, "message cannot be empty").describe("The initial task for the spawned agent."),
|
|
4275
|
+
fork_turns: z11.string().trim().refine((value) => parseForkTurns(value) !== void 0, forkTurnsError).describe(
|
|
4073
4276
|
"Required number of parent turns to fork. Use `none`, `all`, or a positive integer string such as `3`."
|
|
4074
4277
|
)
|
|
4075
4278
|
});
|
|
4076
|
-
var spawnAgentOutputSchema =
|
|
4279
|
+
var spawnAgentOutputSchema = z11.object({ task_name: z11.string() }).strict();
|
|
4077
4280
|
function createSpawnAgentTool(options) {
|
|
4078
4281
|
return tool5({
|
|
4079
4282
|
description: ({ context }) => {
|
|
@@ -4102,11 +4305,11 @@ function createSpawnAgentTool(options) {
|
|
|
4102
4305
|
|
|
4103
4306
|
// packages/experimental/src/zukhruf/collaboration/wait-agent.ts
|
|
4104
4307
|
import { tool as tool6 } from "ai";
|
|
4105
|
-
import { z as
|
|
4106
|
-
var waitAgentOutputSchema =
|
|
4308
|
+
import { z as z12 } from "zod";
|
|
4309
|
+
var waitAgentOutputSchema = z12.object({ message: z12.string(), timed_out: z12.boolean() }).strict();
|
|
4107
4310
|
function createWaitAgentTool(options) {
|
|
4108
|
-
const waitAgentInputSchema =
|
|
4109
|
-
timeout_ms:
|
|
4311
|
+
const waitAgentInputSchema = z12.object({
|
|
4312
|
+
timeout_ms: z12.number().int().max(options.maxTimeoutMs).optional().describe("Maximum time to wait in milliseconds.")
|
|
4110
4313
|
});
|
|
4111
4314
|
return tool6({
|
|
4112
4315
|
description: "Wait for pending mail addressed to this agent without consuming it.",
|