@deepagents/experimental 6.0.0 → 6.1.2
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/README.md +8 -0
- package/dist/index.js +577 -43
- package/dist/index.js.map +4 -4
- package/dist/zukhruf/agent.d.ts +5 -1
- package/dist/zukhruf/agent.d.ts.map +1 -1
- package/dist/zukhruf/control-plane/agent-declaration-registry.d.ts +1 -0
- package/dist/zukhruf/control-plane/agent-declaration-registry.d.ts.map +1 -1
- package/dist/zukhruf/index.d.ts +1 -0
- package/dist/zukhruf/index.d.ts.map +1 -1
- package/dist/zukhruf/index.js +577 -43
- package/dist/zukhruf/index.js.map +4 -4
- package/dist/zukhruf/protocol/parse.d.ts +3 -0
- package/dist/zukhruf/protocol/parse.d.ts.map +1 -0
- package/dist/zukhruf/protocol/session.d.ts +23 -0
- package/dist/zukhruf/protocol/session.d.ts.map +1 -0
- package/dist/zukhruf/protocol/validator.d.ts +64 -0
- package/dist/zukhruf/protocol/validator.d.ts.map +1 -0
- package/dist/zukhruf/runtime/agent-runtime.d.ts +16 -1
- package/dist/zukhruf/runtime/agent-runtime.d.ts.map +1 -1
- package/dist/zukhruf/runtime/agent-skills.d.ts +9 -0
- package/dist/zukhruf/runtime/agent-skills.d.ts.map +1 -0
- package/dist/zukhruf/runtime/agent-turn-executor.d.ts.map +1 -1
- package/dist/zukhruf/sandbox/define.d.ts +4 -3
- package/dist/zukhruf/sandbox/define.d.ts.map +1 -1
- package/package.json +6 -4
package/dist/zukhruf/index.js
CHANGED
|
@@ -21,17 +21,17 @@ var AgentPath = class _AgentPath {
|
|
|
21
21
|
return new _AgentPath("/root");
|
|
22
22
|
}
|
|
23
23
|
static parse(value) {
|
|
24
|
-
const
|
|
25
|
-
if (
|
|
24
|
+
const path2 = value.trim();
|
|
25
|
+
if (path2 !== "/root" && !path2.startsWith("/root/")) {
|
|
26
26
|
throw new Error(`agent path "${value}" must start at /root`);
|
|
27
27
|
}
|
|
28
|
-
const segments =
|
|
28
|
+
const segments = path2.slice(1).split("/");
|
|
29
29
|
if (segments.some(
|
|
30
30
|
(segment) => segment.length === 0 || segment !== segment.trim() || segment === "." || segment === ".."
|
|
31
31
|
)) {
|
|
32
32
|
throw new Error(`agent path "${value}" contains an invalid segment`);
|
|
33
33
|
}
|
|
34
|
-
return new _AgentPath(
|
|
34
|
+
return new _AgentPath(path2);
|
|
35
35
|
}
|
|
36
36
|
/** Relative targets name descendants; absolute targets keep their canonical path. */
|
|
37
37
|
resolve(target) {
|
|
@@ -95,21 +95,21 @@ var AgentThread = class _AgentThread {
|
|
|
95
95
|
}
|
|
96
96
|
static fromMetadata(conversation, metadata) {
|
|
97
97
|
const treeId = metadata?.zukhrufTreeId;
|
|
98
|
-
const
|
|
99
|
-
if (typeof treeId !== "string" || !_AgentThread.#isRecord(
|
|
98
|
+
const zukhruf2 = metadata?.zukhruf;
|
|
99
|
+
if (typeof treeId !== "string" || !_AgentThread.#isRecord(zukhruf2)) {
|
|
100
100
|
return void 0;
|
|
101
101
|
}
|
|
102
|
-
const { path, parentChatId, declarationName, lastTurnId } =
|
|
103
|
-
if (typeof
|
|
102
|
+
const { path: path2, parentChatId, declarationName, lastTurnId } = zukhruf2;
|
|
103
|
+
if (typeof path2 !== "string" || parentChatId !== null && typeof parentChatId !== "string" || typeof declarationName !== "string" || lastTurnId !== void 0 && typeof lastTurnId !== "string") {
|
|
104
104
|
return void 0;
|
|
105
105
|
}
|
|
106
106
|
let parsedPath;
|
|
107
107
|
try {
|
|
108
|
-
parsedPath = AgentPath.parse(
|
|
108
|
+
parsedPath = AgentPath.parse(path2);
|
|
109
109
|
} catch {
|
|
110
110
|
return void 0;
|
|
111
111
|
}
|
|
112
|
-
if (parsedPath.toString() !==
|
|
112
|
+
if (parsedPath.toString() !== path2) return void 0;
|
|
113
113
|
try {
|
|
114
114
|
return new _AgentThread({
|
|
115
115
|
conversation,
|
|
@@ -234,6 +234,9 @@ var AgentDeclarationRegistry = class {
|
|
|
234
234
|
get(name) {
|
|
235
235
|
return this.#declarations.get(name);
|
|
236
236
|
}
|
|
237
|
+
values() {
|
|
238
|
+
return this.#declarations.values();
|
|
239
|
+
}
|
|
237
240
|
#register(declaration, visited) {
|
|
238
241
|
if (visited.has(declaration)) return;
|
|
239
242
|
visited.add(declaration);
|
|
@@ -330,20 +333,20 @@ var AgentDirectory = class _AgentDirectory {
|
|
|
330
333
|
);
|
|
331
334
|
}
|
|
332
335
|
async resolve(thread, target) {
|
|
333
|
-
const
|
|
336
|
+
const path2 = thread.path.resolve(target);
|
|
334
337
|
const match = await this.find(thread, target);
|
|
335
338
|
if (match) return match;
|
|
336
|
-
throw new Error(`agent path "${
|
|
339
|
+
throw new Error(`agent path "${path2}" does not exist in this tree`);
|
|
337
340
|
}
|
|
338
341
|
async find(thread, target) {
|
|
339
|
-
const
|
|
342
|
+
const path2 = thread.path.resolve(target);
|
|
340
343
|
return (await this.listTree(thread)).find(
|
|
341
|
-
(candidate) => candidate.path.equals(
|
|
344
|
+
(candidate) => candidate.path.equals(path2)
|
|
342
345
|
);
|
|
343
346
|
}
|
|
344
347
|
async createChild(options) {
|
|
345
|
-
const
|
|
346
|
-
const pathString =
|
|
348
|
+
const path2 = options.parent.path.resolve(options.taskName);
|
|
349
|
+
const pathString = path2.toString();
|
|
347
350
|
const conversation = {
|
|
348
351
|
chatId: _AgentDirectory.#childChatId(
|
|
349
352
|
options.parent.conversation.userId,
|
|
@@ -353,7 +356,7 @@ var AgentDirectory = class _AgentDirectory {
|
|
|
353
356
|
userId: options.parent.conversation.userId
|
|
354
357
|
};
|
|
355
358
|
const occupied = (await this.listTree(options.parent)).find(
|
|
356
|
-
(thread) => thread.path.equals(
|
|
359
|
+
(thread) => thread.path.equals(path2)
|
|
357
360
|
);
|
|
358
361
|
if (occupied && occupied.conversation.chatId !== conversation.chatId) {
|
|
359
362
|
throw new Error(`agent path "${pathString}" already exists`);
|
|
@@ -361,7 +364,7 @@ var AgentDirectory = class _AgentDirectory {
|
|
|
361
364
|
const child = new AgentThread({
|
|
362
365
|
conversation,
|
|
363
366
|
treeId: options.parent.treeId,
|
|
364
|
-
path,
|
|
367
|
+
path: path2,
|
|
365
368
|
parentChatId: options.parent.conversation.chatId,
|
|
366
369
|
declarationName: options.declarationName
|
|
367
370
|
});
|
|
@@ -379,9 +382,9 @@ var AgentDirectory = class _AgentDirectory {
|
|
|
379
382
|
}
|
|
380
383
|
return stored;
|
|
381
384
|
}
|
|
382
|
-
static #childChatId(userId, treeId,
|
|
385
|
+
static #childChatId(userId, treeId, path2) {
|
|
383
386
|
return uuidv5(
|
|
384
|
-
`urn:deepagents:zukhruf:agent:${JSON.stringify([userId, treeId,
|
|
387
|
+
`urn:deepagents:zukhruf:agent:${JSON.stringify([userId, treeId, path2])}`,
|
|
385
388
|
uuidv5.URL
|
|
386
389
|
);
|
|
387
390
|
}
|
|
@@ -518,14 +521,14 @@ var AgentHistoryForker = class {
|
|
|
518
521
|
let claimed;
|
|
519
522
|
await this.#store.updateChat(child.conversation.chatId, (chat2) => {
|
|
520
523
|
const metadata = chat2.metadata;
|
|
521
|
-
const
|
|
522
|
-
if (!isRecord(
|
|
524
|
+
const zukhruf2 = metadata?.zukhruf;
|
|
525
|
+
if (!isRecord(zukhruf2)) {
|
|
523
526
|
throw new Error(
|
|
524
527
|
`spawn_agent: child chat "${child.conversation.chatId}" is missing Zukhruf metadata`
|
|
525
528
|
);
|
|
526
529
|
}
|
|
527
|
-
if (
|
|
528
|
-
claimed = parseHistoryForkRecord(
|
|
530
|
+
if (zukhruf2.historyFork !== void 0) {
|
|
531
|
+
claimed = parseHistoryForkRecord(zukhruf2.historyFork);
|
|
529
532
|
if (claimed.parentChatId !== proposed.parentChatId || claimed.forkTurns !== proposed.forkTurns) {
|
|
530
533
|
throw new Error(
|
|
531
534
|
`spawn_agent: agent path "${child.path}" already exists with a different fork_turns setting`
|
|
@@ -537,7 +540,7 @@ var AgentHistoryForker = class {
|
|
|
537
540
|
return {
|
|
538
541
|
metadata: {
|
|
539
542
|
...metadata,
|
|
540
|
-
zukhruf: { ...
|
|
543
|
+
zukhruf: { ...zukhruf2, historyFork: proposed }
|
|
541
544
|
}
|
|
542
545
|
};
|
|
543
546
|
});
|
|
@@ -624,13 +627,13 @@ var AgentHistoryForker = class {
|
|
|
624
627
|
let sourceMessageIds;
|
|
625
628
|
await this.#store.updateChat(child.conversation.chatId, (chat2) => {
|
|
626
629
|
const metadata = chat2.metadata;
|
|
627
|
-
const
|
|
628
|
-
if (!isRecord(
|
|
630
|
+
const zukhruf2 = metadata?.zukhruf;
|
|
631
|
+
if (!isRecord(zukhruf2)) {
|
|
629
632
|
throw new Error(
|
|
630
633
|
`spawn_agent: child chat "${child.conversation.chatId}" is missing Zukhruf metadata`
|
|
631
634
|
);
|
|
632
635
|
}
|
|
633
|
-
const record = parseHistoryForkRecord(
|
|
636
|
+
const record = parseHistoryForkRecord(zukhruf2.historyFork);
|
|
634
637
|
if (record.sourceMessageIds !== void 0) {
|
|
635
638
|
sourceMessageIds = record.sourceMessageIds;
|
|
636
639
|
return void 0;
|
|
@@ -640,7 +643,7 @@ var AgentHistoryForker = class {
|
|
|
640
643
|
metadata: {
|
|
641
644
|
...metadata,
|
|
642
645
|
zukhruf: {
|
|
643
|
-
...
|
|
646
|
+
...zukhruf2,
|
|
644
647
|
historyFork: { ...record, sourceMessageIds: proposedIds }
|
|
645
648
|
}
|
|
646
649
|
}
|
|
@@ -1522,6 +1525,59 @@ function configureTool(collaborationTool, config) {
|
|
|
1522
1525
|
};
|
|
1523
1526
|
}
|
|
1524
1527
|
|
|
1528
|
+
// packages/experimental/src/zukhruf/runtime/agent-skills.ts
|
|
1529
|
+
import path from "node:path";
|
|
1530
|
+
import {
|
|
1531
|
+
parseFrontmatter,
|
|
1532
|
+
skills
|
|
1533
|
+
} from "@deepagents/context";
|
|
1534
|
+
var EMPTY_SKILLS = { available: [], fragments: [] };
|
|
1535
|
+
async function discoverAgentSkills(sandbox, signal) {
|
|
1536
|
+
if (sandbox.workingDirectory === void 0) return EMPTY_SKILLS;
|
|
1537
|
+
const skillsDirectory = path.posix.join(sandbox.workingDirectory, "skills");
|
|
1538
|
+
const quotedSkillsDirectory = shellQuote(skillsDirectory);
|
|
1539
|
+
const result = await sandbox.sandbox.executeCommand(
|
|
1540
|
+
`if [ -d ${quotedSkillsDirectory} ]; then find ${quotedSkillsDirectory} -mindepth 1 -maxdepth 1 -type d -print; fi`,
|
|
1541
|
+
{ signal }
|
|
1542
|
+
);
|
|
1543
|
+
if (result.exitCode !== 0) {
|
|
1544
|
+
throw new Error(
|
|
1545
|
+
`AgentRuntime: failed to discover sandbox skills: ${result.stderr.trim() || `exit ${result.exitCode}`}`
|
|
1546
|
+
);
|
|
1547
|
+
}
|
|
1548
|
+
const skillDirectories = result.stdout.split("\n").filter(Boolean).filter((directory) => !path.posix.basename(directory).startsWith(".")).toSorted();
|
|
1549
|
+
if (skillDirectories.length === 0) return EMPTY_SKILLS;
|
|
1550
|
+
const discovered = await Promise.all(
|
|
1551
|
+
skillDirectories.map((directory) => loadSkill(sandbox, directory))
|
|
1552
|
+
);
|
|
1553
|
+
return createAgentSkills(discovered);
|
|
1554
|
+
}
|
|
1555
|
+
function createAgentSkills(available) {
|
|
1556
|
+
if (available.length === 0) return EMPTY_SKILLS;
|
|
1557
|
+
const snapshot = [...available];
|
|
1558
|
+
return { available: snapshot, fragments: [skills(snapshot)] };
|
|
1559
|
+
}
|
|
1560
|
+
async function loadSkill(sandbox, directory) {
|
|
1561
|
+
const directoryName = path.posix.basename(directory);
|
|
1562
|
+
const skillMd = await sandbox.sandbox.readFile(
|
|
1563
|
+
path.posix.join(directory, "SKILL.md")
|
|
1564
|
+
);
|
|
1565
|
+
const { frontmatter } = parseFrontmatter(skillMd);
|
|
1566
|
+
if (frontmatter.name !== directoryName) {
|
|
1567
|
+
throw new Error(
|
|
1568
|
+
`AgentRuntime: skill "${frontmatter.name}" must use matching directory "${directoryName}"`
|
|
1569
|
+
);
|
|
1570
|
+
}
|
|
1571
|
+
return {
|
|
1572
|
+
name: frontmatter.name,
|
|
1573
|
+
description: frontmatter.description,
|
|
1574
|
+
path: path.posix.join("skills", directoryName, "SKILL.md")
|
|
1575
|
+
};
|
|
1576
|
+
}
|
|
1577
|
+
function shellQuote(value) {
|
|
1578
|
+
return `'${value.replaceAll("'", "'\\''")}'`;
|
|
1579
|
+
}
|
|
1580
|
+
|
|
1525
1581
|
// packages/experimental/src/zukhruf/runtime/agent-turn-executor.ts
|
|
1526
1582
|
var AgentTurnExecutor = class {
|
|
1527
1583
|
#store;
|
|
@@ -1576,10 +1632,7 @@ var AgentTurnExecutor = class {
|
|
|
1576
1632
|
if (await this.#projectSkippedTerminalTurn(turn)) return;
|
|
1577
1633
|
const { declaration, thread } = await this.#controlPlane.resolve(turn);
|
|
1578
1634
|
const usageHint = thread.path.isRoot ? this.#multiAgentV2.rootAgentUsageHintText : this.#multiAgentV2.subagentUsageHintText;
|
|
1579
|
-
const engine = this.#engineFor(turn)
|
|
1580
|
-
...declaration.instructions,
|
|
1581
|
-
...usageHint === void 0 ? [] : [role(usageHint)]
|
|
1582
|
-
);
|
|
1635
|
+
const engine = this.#engineFor(turn);
|
|
1583
1636
|
if (turn.kind === "ask" || turn.kind === "mailbox") {
|
|
1584
1637
|
const head = (await engine.getMessages()).at(-1);
|
|
1585
1638
|
if (this.#approvals.isPaused(head)) {
|
|
@@ -1603,6 +1656,12 @@ var AgentTurnExecutor = class {
|
|
|
1603
1656
|
chatId: turn.chatId,
|
|
1604
1657
|
userId: turn.userId
|
|
1605
1658
|
});
|
|
1659
|
+
const agentSkills = await this.#skillsFor(turn, sandbox, signal);
|
|
1660
|
+
engine.set(
|
|
1661
|
+
...declaration.instructions,
|
|
1662
|
+
...agentSkills.fragments,
|
|
1663
|
+
...usageHint === void 0 ? [] : [role(usageHint)]
|
|
1664
|
+
);
|
|
1606
1665
|
if (await this.#projectSkippedTerminalTurn(turn)) return;
|
|
1607
1666
|
if (!await this.#streams.claim(turn.streamId)) {
|
|
1608
1667
|
await this.#projectSkippedTerminalTurn(turn);
|
|
@@ -1715,6 +1774,29 @@ var AgentTurnExecutor = class {
|
|
|
1715
1774
|
(communication) => this.#mailboxInputMessage(communication)
|
|
1716
1775
|
);
|
|
1717
1776
|
}
|
|
1777
|
+
async #skillsFor(turn, sandbox, signal) {
|
|
1778
|
+
const chat2 = await this.#store.getChat(turn.chatId);
|
|
1779
|
+
const existing = readSkills(chat2?.metadata);
|
|
1780
|
+
if (existing !== void 0) return createAgentSkills(existing);
|
|
1781
|
+
if (sandbox.workingDirectory === void 0) return createAgentSkills([]);
|
|
1782
|
+
const discovered = await discoverAgentSkills(sandbox, signal);
|
|
1783
|
+
let available = discovered.available;
|
|
1784
|
+
await this.#store.updateChat(turn.chatId, ({ metadata }) => {
|
|
1785
|
+
const persisted = readSkills(metadata);
|
|
1786
|
+
if (persisted !== void 0) {
|
|
1787
|
+
available = persisted;
|
|
1788
|
+
return void 0;
|
|
1789
|
+
}
|
|
1790
|
+
const zukhruf2 = isRecord2(metadata?.zukhruf) ? metadata.zukhruf : {};
|
|
1791
|
+
return {
|
|
1792
|
+
metadata: {
|
|
1793
|
+
...metadata,
|
|
1794
|
+
zukhruf: { ...zukhruf2, skills: available }
|
|
1795
|
+
}
|
|
1796
|
+
};
|
|
1797
|
+
});
|
|
1798
|
+
return available === discovered.available ? discovered : createAgentSkills(available);
|
|
1799
|
+
}
|
|
1718
1800
|
#engineFor({ chatId, userId }) {
|
|
1719
1801
|
return new ContextEngine2({ store: this.#store, chatId, userId });
|
|
1720
1802
|
}
|
|
@@ -1743,6 +1825,22 @@ Payload:
|
|
|
1743
1825
|
${communication.content}`;
|
|
1744
1826
|
}
|
|
1745
1827
|
};
|
|
1828
|
+
function readSkills(metadata) {
|
|
1829
|
+
const zukhruf2 = metadata?.zukhruf;
|
|
1830
|
+
if (!isRecord2(zukhruf2) || !Object.hasOwn(zukhruf2, "skills")) {
|
|
1831
|
+
return void 0;
|
|
1832
|
+
}
|
|
1833
|
+
if (!Array.isArray(zukhruf2.skills) || !zukhruf2.skills.every(isSkill)) {
|
|
1834
|
+
throw new Error("AgentRuntime: stored skill catalog is invalid");
|
|
1835
|
+
}
|
|
1836
|
+
return zukhruf2.skills;
|
|
1837
|
+
}
|
|
1838
|
+
function isSkill(value) {
|
|
1839
|
+
return isRecord2(value) && typeof value.name === "string" && typeof value.description === "string" && typeof value.path === "string";
|
|
1840
|
+
}
|
|
1841
|
+
function isRecord2(value) {
|
|
1842
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1843
|
+
}
|
|
1746
1844
|
|
|
1747
1845
|
// packages/experimental/src/zukhruf/runtime/approval-controller.ts
|
|
1748
1846
|
import {
|
|
@@ -1988,7 +2086,8 @@ var AgentObservation = class {
|
|
|
1988
2086
|
#conversation;
|
|
1989
2087
|
#store;
|
|
1990
2088
|
#streams;
|
|
1991
|
-
|
|
2089
|
+
#queue;
|
|
2090
|
+
constructor(conversation, store, streams, queue) {
|
|
1992
2091
|
this.engine = new ContextEngine4({
|
|
1993
2092
|
store,
|
|
1994
2093
|
chatId: conversation.chatId,
|
|
@@ -1997,6 +2096,7 @@ var AgentObservation = class {
|
|
|
1997
2096
|
this.#conversation = conversation;
|
|
1998
2097
|
this.#store = store;
|
|
1999
2098
|
this.#streams = streams;
|
|
2099
|
+
this.#queue = queue;
|
|
2000
2100
|
}
|
|
2001
2101
|
async resume() {
|
|
2002
2102
|
const id = await this.#headStreamId();
|
|
@@ -2016,16 +2116,27 @@ var AgentObservation = class {
|
|
|
2016
2116
|
if (!id) return;
|
|
2017
2117
|
AgentTurnId.assertOwner(this.#conversation, id);
|
|
2018
2118
|
const status = await this.#streams.store.getStreamStatus(id);
|
|
2019
|
-
if (status === "queued" || status === "running") {
|
|
2119
|
+
if (status === "queued" || status === "running" || status === "cancelled") {
|
|
2020
2120
|
await this.#streams.cancel(id);
|
|
2121
|
+
await this.#queue.cancel(id);
|
|
2021
2122
|
}
|
|
2022
2123
|
}
|
|
2023
2124
|
async #headStreamId() {
|
|
2125
|
+
const scheduled = await this.#queue.getCurrentTurn(this.#conversation);
|
|
2126
|
+
if (scheduled) return scheduled.streamId;
|
|
2127
|
+
const chat2 = await this.#store.getChat(this.#conversation.chatId);
|
|
2128
|
+
if (!chat2) return void 0;
|
|
2129
|
+
if (chat2.userId !== this.#conversation.userId) {
|
|
2130
|
+
throw new Error(
|
|
2131
|
+
`chat "${this.#conversation.chatId}" belongs to user "${chat2.userId}", not "${this.#conversation.userId}"`
|
|
2132
|
+
);
|
|
2133
|
+
}
|
|
2024
2134
|
const head = await this.engine.headMessage();
|
|
2025
2135
|
return head?.name === "assistant" ? head.id : void 0;
|
|
2026
2136
|
}
|
|
2027
2137
|
};
|
|
2028
2138
|
var AgentRuntime = class {
|
|
2139
|
+
info;
|
|
2029
2140
|
#store;
|
|
2030
2141
|
#queue;
|
|
2031
2142
|
#streams;
|
|
@@ -2074,6 +2185,18 @@ var AgentRuntime = class {
|
|
|
2074
2185
|
this.#directory = directory;
|
|
2075
2186
|
this.#controlPlane = controlPlane;
|
|
2076
2187
|
this.#approvals = approvals;
|
|
2188
|
+
this.info = {
|
|
2189
|
+
root: declarations.root.name,
|
|
2190
|
+
agents: Array.from(declarations.values(), (declaration) => ({
|
|
2191
|
+
name: declaration.name,
|
|
2192
|
+
model: {
|
|
2193
|
+
provider: declaration.model.provider,
|
|
2194
|
+
modelId: declaration.model.modelId
|
|
2195
|
+
},
|
|
2196
|
+
tools: Object.keys(declaration.tools ?? {}).sort(),
|
|
2197
|
+
subagents: (declaration.subagents ?? []).map(({ name }) => name)
|
|
2198
|
+
}))
|
|
2199
|
+
};
|
|
2077
2200
|
this.#executor = new AgentTurnExecutor({
|
|
2078
2201
|
store: options.store,
|
|
2079
2202
|
streams,
|
|
@@ -2083,6 +2206,14 @@ var AgentRuntime = class {
|
|
|
2083
2206
|
multiAgentV2
|
|
2084
2207
|
});
|
|
2085
2208
|
}
|
|
2209
|
+
async createSession(conversation) {
|
|
2210
|
+
await this.#controlPlane.resolve(conversation);
|
|
2211
|
+
}
|
|
2212
|
+
async sessionExists(conversation) {
|
|
2213
|
+
const chat2 = await this.#store.getChat(conversation.chatId);
|
|
2214
|
+
if (!chat2 || chat2.userId !== conversation.userId) return false;
|
|
2215
|
+
return (await this.#directory.load(conversation))?.path.isRoot ?? false;
|
|
2216
|
+
}
|
|
2086
2217
|
async enqueue(conversation, turn) {
|
|
2087
2218
|
const streamId = await this.#controlPlane.enqueue(conversation, turn);
|
|
2088
2219
|
return { id: streamId, stream: this.#streams.watch(streamId) };
|
|
@@ -2098,7 +2229,12 @@ var AgentRuntime = class {
|
|
|
2098
2229
|
return this.#approvals.deny(conversation, input);
|
|
2099
2230
|
}
|
|
2100
2231
|
observe(conversation) {
|
|
2101
|
-
return new AgentObservation(
|
|
2232
|
+
return new AgentObservation(
|
|
2233
|
+
conversation,
|
|
2234
|
+
this.#store,
|
|
2235
|
+
this.#streams,
|
|
2236
|
+
this.#queue
|
|
2237
|
+
);
|
|
2102
2238
|
}
|
|
2103
2239
|
work(options) {
|
|
2104
2240
|
return this.#queue.consume(this.#executor.execute.bind(this.#executor), {
|
|
@@ -2217,9 +2353,9 @@ var BUSY_TIMEOUT_MS = 5e3;
|
|
|
2217
2353
|
var SqliteMailboxStore = class extends MailboxStore {
|
|
2218
2354
|
#database;
|
|
2219
2355
|
#closed = false;
|
|
2220
|
-
constructor(
|
|
2356
|
+
constructor(path2) {
|
|
2221
2357
|
super();
|
|
2222
|
-
this.#database = new DatabaseSync(
|
|
2358
|
+
this.#database = new DatabaseSync(path2, { timeout: BUSY_TIMEOUT_MS });
|
|
2223
2359
|
this.#database.exec(DDL);
|
|
2224
2360
|
}
|
|
2225
2361
|
async beginTurn(recipient, turnId) {
|
|
@@ -2369,6 +2505,386 @@ var SqliteMailboxStore = class extends MailboxStore {
|
|
|
2369
2505
|
}
|
|
2370
2506
|
};
|
|
2371
2507
|
|
|
2508
|
+
// packages/experimental/src/zukhruf/protocol/session.ts
|
|
2509
|
+
import { createUIMessageStreamResponse } from "ai";
|
|
2510
|
+
import { Hono } from "hono";
|
|
2511
|
+
import { bodyLimit } from "hono/body-limit";
|
|
2512
|
+
import { HTTPException as HTTPException3 } from "hono/http-exception";
|
|
2513
|
+
import { v5 as uuidv56, validate as validateUuid } from "uuid";
|
|
2514
|
+
import z9 from "zod";
|
|
2515
|
+
|
|
2516
|
+
// packages/experimental/src/zukhruf/protocol/validator.ts
|
|
2517
|
+
import { parse as parseContentType } from "fast-content-type-parse";
|
|
2518
|
+
import { createMiddleware } from "hono/factory";
|
|
2519
|
+
import { HTTPException as HTTPException2 } from "hono/http-exception";
|
|
2520
|
+
import z8 from "zod";
|
|
2521
|
+
|
|
2522
|
+
// packages/experimental/src/zukhruf/protocol/parse.ts
|
|
2523
|
+
import { HTTPException } from "hono/http-exception";
|
|
2524
|
+
import "zod";
|
|
2525
|
+
async function parse(schema, input) {
|
|
2526
|
+
const result = await schema.safeParseAsync(input);
|
|
2527
|
+
if (!result.success) {
|
|
2528
|
+
const errors = result.error.flatten((issue) => ({
|
|
2529
|
+
message: issue.message,
|
|
2530
|
+
code: issue.code,
|
|
2531
|
+
path: issue.path.join(".")
|
|
2532
|
+
})).fieldErrors;
|
|
2533
|
+
throw new HTTPException(400, {
|
|
2534
|
+
message: "Validation failed",
|
|
2535
|
+
cause: {
|
|
2536
|
+
code: "api/validation-failed",
|
|
2537
|
+
detail: "The input data is invalid",
|
|
2538
|
+
errors
|
|
2539
|
+
}
|
|
2540
|
+
});
|
|
2541
|
+
}
|
|
2542
|
+
return result.data;
|
|
2543
|
+
}
|
|
2544
|
+
|
|
2545
|
+
// packages/experimental/src/zukhruf/protocol/validator.ts
|
|
2546
|
+
function validate(expectedContentTypeOrSelector, selector) {
|
|
2547
|
+
const expectedContentType = typeof expectedContentTypeOrSelector === "string" ? expectedContentTypeOrSelector : void 0;
|
|
2548
|
+
const _selector = typeof expectedContentTypeOrSelector === "function" ? expectedContentTypeOrSelector : selector;
|
|
2549
|
+
if (!_selector) {
|
|
2550
|
+
throw new Error("Selector function is required");
|
|
2551
|
+
}
|
|
2552
|
+
return createMiddleware(async (c, next) => {
|
|
2553
|
+
const ct = c.req.header("content-type");
|
|
2554
|
+
if (c.req.method === "GET" && ct) {
|
|
2555
|
+
throw new HTTPException2(415, {
|
|
2556
|
+
message: "Unsupported Media Type",
|
|
2557
|
+
cause: {
|
|
2558
|
+
code: "api/unsupported-media-type",
|
|
2559
|
+
detail: `GET requests cannot have a content type header`
|
|
2560
|
+
}
|
|
2561
|
+
});
|
|
2562
|
+
}
|
|
2563
|
+
if (expectedContentType) {
|
|
2564
|
+
void verifyContentType(ct, expectedContentType);
|
|
2565
|
+
}
|
|
2566
|
+
const contentType = ct ? parseContentType(ct) : null;
|
|
2567
|
+
let body = null;
|
|
2568
|
+
switch (contentType?.type) {
|
|
2569
|
+
case "application/json":
|
|
2570
|
+
body = await parseJson(c);
|
|
2571
|
+
break;
|
|
2572
|
+
case "application/x-www-form-urlencoded":
|
|
2573
|
+
case "multipart/form-data":
|
|
2574
|
+
body = await c.req.parseBody();
|
|
2575
|
+
break;
|
|
2576
|
+
default:
|
|
2577
|
+
body = {};
|
|
2578
|
+
}
|
|
2579
|
+
const payload = {
|
|
2580
|
+
body,
|
|
2581
|
+
query: parseQueryParams(c.req.query()),
|
|
2582
|
+
queries: parseQueriesParams(c.req.queries()),
|
|
2583
|
+
params: c.req.param(),
|
|
2584
|
+
headers: Object.fromEntries(
|
|
2585
|
+
Object.entries(c.req.header()).map(([k, v]) => [k, v ?? ""])
|
|
2586
|
+
)
|
|
2587
|
+
};
|
|
2588
|
+
const config = _selector(payload);
|
|
2589
|
+
const schema = z8.object(
|
|
2590
|
+
Object.entries(config).reduce(
|
|
2591
|
+
(acc, [key, value]) => {
|
|
2592
|
+
acc[key] = value.against;
|
|
2593
|
+
return acc;
|
|
2594
|
+
},
|
|
2595
|
+
{}
|
|
2596
|
+
)
|
|
2597
|
+
);
|
|
2598
|
+
const input = Object.entries(config).reduce(
|
|
2599
|
+
(acc, [key, value]) => {
|
|
2600
|
+
acc[key] = value.select;
|
|
2601
|
+
return acc;
|
|
2602
|
+
},
|
|
2603
|
+
{}
|
|
2604
|
+
);
|
|
2605
|
+
const parsed = await parse(schema, input);
|
|
2606
|
+
c.set("input", parsed);
|
|
2607
|
+
await next();
|
|
2608
|
+
});
|
|
2609
|
+
}
|
|
2610
|
+
function verifyContentType(actual, expected) {
|
|
2611
|
+
if (!actual) {
|
|
2612
|
+
throw new HTTPException2(415, {
|
|
2613
|
+
message: "Unsupported Media Type",
|
|
2614
|
+
cause: {
|
|
2615
|
+
code: "api/unsupported-media-type",
|
|
2616
|
+
detail: "Missing content type header"
|
|
2617
|
+
}
|
|
2618
|
+
});
|
|
2619
|
+
}
|
|
2620
|
+
const { type: incomingContentType } = parseContentType(actual);
|
|
2621
|
+
if (incomingContentType !== expected) {
|
|
2622
|
+
throw new HTTPException2(415, {
|
|
2623
|
+
message: "Unsupported Media Type",
|
|
2624
|
+
cause: {
|
|
2625
|
+
code: "api/unsupported-media-type",
|
|
2626
|
+
detail: `Expected content type: ${expected}, but got: ${incomingContentType}`
|
|
2627
|
+
}
|
|
2628
|
+
});
|
|
2629
|
+
}
|
|
2630
|
+
}
|
|
2631
|
+
async function parseJson(context) {
|
|
2632
|
+
try {
|
|
2633
|
+
return await context.req.json();
|
|
2634
|
+
} catch (error) {
|
|
2635
|
+
throw new HTTPException2(400, {
|
|
2636
|
+
message: "The request body is not valid JSON",
|
|
2637
|
+
cause: {
|
|
2638
|
+
code: "api/invalid-json",
|
|
2639
|
+
detail: error instanceof Error ? error.message : String(error)
|
|
2640
|
+
}
|
|
2641
|
+
});
|
|
2642
|
+
}
|
|
2643
|
+
}
|
|
2644
|
+
function parseQueryParams(queryParams) {
|
|
2645
|
+
return Object.fromEntries(
|
|
2646
|
+
Object.entries(queryParams).map(([key, value]) => [
|
|
2647
|
+
key,
|
|
2648
|
+
value === "null" ? null : value
|
|
2649
|
+
])
|
|
2650
|
+
);
|
|
2651
|
+
}
|
|
2652
|
+
function parseQueriesParams(queriesParams) {
|
|
2653
|
+
return Object.fromEntries(
|
|
2654
|
+
Object.entries(queriesParams).map(([key, values]) => [
|
|
2655
|
+
key,
|
|
2656
|
+
values.map((value) => value === "null" ? null : value)
|
|
2657
|
+
])
|
|
2658
|
+
);
|
|
2659
|
+
}
|
|
2660
|
+
|
|
2661
|
+
// packages/experimental/src/zukhruf/protocol/session.ts
|
|
2662
|
+
var ZUKHRUF_ROUTE_PREFIX = "/zukhruf/v1";
|
|
2663
|
+
var CREATE_SESSION_ROUTE_PATH = "/session";
|
|
2664
|
+
var SESSION_ROUTE_PATH = "/session/:sessionId";
|
|
2665
|
+
var SESSION_CANCEL_ROUTE_PATH = "/session/:sessionId/cancel";
|
|
2666
|
+
var SESSION_STREAM_ROUTE_PATH = "/session/:sessionId/stream";
|
|
2667
|
+
var INFO_ROUTE_PATH = "/info";
|
|
2668
|
+
var HEALTH_ROUTE_PATH = "/health";
|
|
2669
|
+
var ZUKHRUF_CREATE_SESSION_ROUTE_PATH = `${ZUKHRUF_ROUTE_PREFIX}${CREATE_SESSION_ROUTE_PATH}`;
|
|
2670
|
+
var ZUKHRUF_SESSION_ROUTE_PATH = `${ZUKHRUF_ROUTE_PREFIX}${SESSION_ROUTE_PATH}`;
|
|
2671
|
+
var ZUKHRUF_SESSION_CANCEL_ROUTE_PATH = `${ZUKHRUF_ROUTE_PREFIX}${SESSION_CANCEL_ROUTE_PATH}`;
|
|
2672
|
+
var ZUKHRUF_SESSION_STREAM_ROUTE_PATH = `${ZUKHRUF_ROUTE_PREFIX}${SESSION_STREAM_ROUTE_PATH}`;
|
|
2673
|
+
var ZUKHRUF_INFO_ROUTE_PATH = `${ZUKHRUF_ROUTE_PREFIX}${INFO_ROUTE_PATH}`;
|
|
2674
|
+
var ZUKHRUF_HEALTH_ROUTE_PATH = `${ZUKHRUF_ROUTE_PREFIX}${HEALTH_ROUTE_PATH}`;
|
|
2675
|
+
var ZUKHRUF_SESSION_ID_HEADER = "x-zukhruf-session-id";
|
|
2676
|
+
var MAX_BODY_BYTES = 10 * 1024;
|
|
2677
|
+
var MAX_IDEMPOTENCY_KEY_LENGTH = 200;
|
|
2678
|
+
var MAX_INPUT_LENGTH = 8e3;
|
|
2679
|
+
var SESSION_NAMESPACE = uuidv56("urn:deepagents:zukhruf:sessions", uuidv56.URL);
|
|
2680
|
+
var NO_STORE = { "cache-control": "no-store" };
|
|
2681
|
+
var sessionIdSchema = z9.string().refine(validateUuid);
|
|
2682
|
+
var turnBodySchema = z9.strictObject({
|
|
2683
|
+
input: z9.string().trim().min(1).max(MAX_INPUT_LENGTH)
|
|
2684
|
+
});
|
|
2685
|
+
var idempotencyKeySchema = z9.string().trim().min(1).max(MAX_IDEMPOTENCY_KEY_LENGTH);
|
|
2686
|
+
var limitTurnBody = bodyLimit({
|
|
2687
|
+
maxSize: MAX_BODY_BYTES,
|
|
2688
|
+
onError: () => {
|
|
2689
|
+
throw new HTTPException3(413, {
|
|
2690
|
+
message: "Request body is too large",
|
|
2691
|
+
cause: {
|
|
2692
|
+
code: "api/payload-too-large",
|
|
2693
|
+
detail: `Request body exceeds ${MAX_BODY_BYTES} bytes`
|
|
2694
|
+
}
|
|
2695
|
+
});
|
|
2696
|
+
}
|
|
2697
|
+
});
|
|
2698
|
+
function zukhruf(runtime) {
|
|
2699
|
+
const app = new Hono();
|
|
2700
|
+
app.onError((error, context) => {
|
|
2701
|
+
if (error instanceof HTTPException3) {
|
|
2702
|
+
return context.json(
|
|
2703
|
+
{ cause: error.cause, error: error.message },
|
|
2704
|
+
error.status,
|
|
2705
|
+
NO_STORE
|
|
2706
|
+
);
|
|
2707
|
+
}
|
|
2708
|
+
throw error;
|
|
2709
|
+
});
|
|
2710
|
+
app.on(
|
|
2711
|
+
["GET", "HEAD"],
|
|
2712
|
+
HEALTH_ROUTE_PATH,
|
|
2713
|
+
(context) => context.req.method === "HEAD" ? context.body(null, 200, NO_STORE) : context.json({ ok: true }, 200, NO_STORE)
|
|
2714
|
+
);
|
|
2715
|
+
app.all(
|
|
2716
|
+
HEALTH_ROUTE_PATH,
|
|
2717
|
+
(context) => methodNotAllowed(context, "GET, HEAD")
|
|
2718
|
+
);
|
|
2719
|
+
app.use("*", async (context, next) => {
|
|
2720
|
+
if (!context.get("userId")?.trim()) {
|
|
2721
|
+
throw new HTTPException3(401, {
|
|
2722
|
+
message: "Authentication required",
|
|
2723
|
+
cause: {
|
|
2724
|
+
code: "api/unauthenticated",
|
|
2725
|
+
detail: "Authentication required to access Zukhruf"
|
|
2726
|
+
}
|
|
2727
|
+
});
|
|
2728
|
+
}
|
|
2729
|
+
await next();
|
|
2730
|
+
});
|
|
2731
|
+
app.get(
|
|
2732
|
+
INFO_ROUTE_PATH,
|
|
2733
|
+
(context) => context.json(runtime.info, 200, NO_STORE)
|
|
2734
|
+
);
|
|
2735
|
+
app.all(INFO_ROUTE_PATH, (context) => methodNotAllowed(context, "GET"));
|
|
2736
|
+
app.post(
|
|
2737
|
+
CREATE_SESSION_ROUTE_PATH,
|
|
2738
|
+
limitTurnBody,
|
|
2739
|
+
validate("application/json", (payload) => ({
|
|
2740
|
+
body: {
|
|
2741
|
+
select: payload.body,
|
|
2742
|
+
against: turnBodySchema
|
|
2743
|
+
},
|
|
2744
|
+
idempotencyKey: {
|
|
2745
|
+
select: payload.headers["idempotency-key"],
|
|
2746
|
+
against: idempotencyKeySchema
|
|
2747
|
+
}
|
|
2748
|
+
})),
|
|
2749
|
+
async (context) => {
|
|
2750
|
+
const { body, idempotencyKey } = context.var.input;
|
|
2751
|
+
const userId = context.get("userId");
|
|
2752
|
+
const sessionId = uuidv56(
|
|
2753
|
+
JSON.stringify([userId, idempotencyKey]),
|
|
2754
|
+
SESSION_NAMESPACE
|
|
2755
|
+
);
|
|
2756
|
+
const conversation = { chatId: sessionId, userId };
|
|
2757
|
+
await runtime.createSession(conversation);
|
|
2758
|
+
await runtime.enqueue(conversation, {
|
|
2759
|
+
id: idempotencyKey,
|
|
2760
|
+
input: body.input.trim()
|
|
2761
|
+
});
|
|
2762
|
+
return accepted(context, sessionId);
|
|
2763
|
+
}
|
|
2764
|
+
);
|
|
2765
|
+
app.all(
|
|
2766
|
+
CREATE_SESSION_ROUTE_PATH,
|
|
2767
|
+
(context) => methodNotAllowed(context, "POST")
|
|
2768
|
+
);
|
|
2769
|
+
app.post(
|
|
2770
|
+
SESSION_ROUTE_PATH,
|
|
2771
|
+
limitTurnBody,
|
|
2772
|
+
validate("application/json", (payload) => ({
|
|
2773
|
+
body: {
|
|
2774
|
+
select: payload.body,
|
|
2775
|
+
against: turnBodySchema
|
|
2776
|
+
},
|
|
2777
|
+
idempotencyKey: {
|
|
2778
|
+
select: payload.headers["idempotency-key"],
|
|
2779
|
+
against: idempotencyKeySchema
|
|
2780
|
+
},
|
|
2781
|
+
sessionId: {
|
|
2782
|
+
select: payload.params.sessionId,
|
|
2783
|
+
against: sessionIdSchema
|
|
2784
|
+
}
|
|
2785
|
+
})),
|
|
2786
|
+
async (context) => {
|
|
2787
|
+
const { body, idempotencyKey, sessionId } = context.var.input;
|
|
2788
|
+
const conversation = {
|
|
2789
|
+
chatId: sessionId,
|
|
2790
|
+
userId: context.get("userId")
|
|
2791
|
+
};
|
|
2792
|
+
await requireSession(runtime, conversation);
|
|
2793
|
+
await runtime.enqueue(conversation, {
|
|
2794
|
+
id: idempotencyKey,
|
|
2795
|
+
input: body.input.trim()
|
|
2796
|
+
});
|
|
2797
|
+
return accepted(context, sessionId);
|
|
2798
|
+
}
|
|
2799
|
+
);
|
|
2800
|
+
app.all(SESSION_ROUTE_PATH, (context) => methodNotAllowed(context, "POST"));
|
|
2801
|
+
app.post(
|
|
2802
|
+
SESSION_CANCEL_ROUTE_PATH,
|
|
2803
|
+
validate((payload) => ({
|
|
2804
|
+
sessionId: {
|
|
2805
|
+
select: payload.params.sessionId,
|
|
2806
|
+
against: sessionIdSchema
|
|
2807
|
+
}
|
|
2808
|
+
})),
|
|
2809
|
+
async (context) => {
|
|
2810
|
+
const { sessionId } = context.var.input;
|
|
2811
|
+
const conversation = {
|
|
2812
|
+
chatId: sessionId,
|
|
2813
|
+
userId: context.get("userId")
|
|
2814
|
+
};
|
|
2815
|
+
await requireSession(runtime, conversation);
|
|
2816
|
+
await runtime.observe(conversation).cancel();
|
|
2817
|
+
return context.body(null, 204, NO_STORE);
|
|
2818
|
+
}
|
|
2819
|
+
);
|
|
2820
|
+
app.all(
|
|
2821
|
+
SESSION_CANCEL_ROUTE_PATH,
|
|
2822
|
+
(context) => methodNotAllowed(context, "POST")
|
|
2823
|
+
);
|
|
2824
|
+
app.get(
|
|
2825
|
+
SESSION_STREAM_ROUTE_PATH,
|
|
2826
|
+
validate((payload) => ({
|
|
2827
|
+
sessionId: {
|
|
2828
|
+
select: payload.params.sessionId,
|
|
2829
|
+
against: sessionIdSchema
|
|
2830
|
+
}
|
|
2831
|
+
})),
|
|
2832
|
+
async (context) => {
|
|
2833
|
+
const { sessionId } = context.var.input;
|
|
2834
|
+
const conversation = {
|
|
2835
|
+
chatId: sessionId,
|
|
2836
|
+
userId: context.get("userId")
|
|
2837
|
+
};
|
|
2838
|
+
await requireSession(runtime, conversation);
|
|
2839
|
+
const stream = await runtime.observe(conversation).resume();
|
|
2840
|
+
if (!stream) {
|
|
2841
|
+
throw new HTTPException3(404, {
|
|
2842
|
+
message: "Session stream not found",
|
|
2843
|
+
cause: {
|
|
2844
|
+
code: "zukhruf/session-stream-not-found",
|
|
2845
|
+
detail: `No durable stream exists for session ${sessionId}`
|
|
2846
|
+
}
|
|
2847
|
+
});
|
|
2848
|
+
}
|
|
2849
|
+
return createUIMessageStreamResponse({
|
|
2850
|
+
headers: NO_STORE,
|
|
2851
|
+
stream
|
|
2852
|
+
});
|
|
2853
|
+
}
|
|
2854
|
+
);
|
|
2855
|
+
app.all(
|
|
2856
|
+
SESSION_STREAM_ROUTE_PATH,
|
|
2857
|
+
(context) => methodNotAllowed(context, "GET")
|
|
2858
|
+
);
|
|
2859
|
+
return app;
|
|
2860
|
+
}
|
|
2861
|
+
function accepted(context, sessionId) {
|
|
2862
|
+
return context.json({ ok: true, sessionId }, 202, {
|
|
2863
|
+
...NO_STORE,
|
|
2864
|
+
[ZUKHRUF_SESSION_ID_HEADER]: sessionId
|
|
2865
|
+
});
|
|
2866
|
+
}
|
|
2867
|
+
async function requireSession(runtime, conversation) {
|
|
2868
|
+
if (await runtime.sessionExists(conversation)) return;
|
|
2869
|
+
throw new HTTPException3(404, {
|
|
2870
|
+
message: "Session not found",
|
|
2871
|
+
cause: {
|
|
2872
|
+
code: "zukhruf/session-not-found",
|
|
2873
|
+
detail: `Session ${conversation.chatId} does not exist`
|
|
2874
|
+
}
|
|
2875
|
+
});
|
|
2876
|
+
}
|
|
2877
|
+
function methodNotAllowed(context, allow) {
|
|
2878
|
+
context.header("Allow", allow);
|
|
2879
|
+
throw new HTTPException3(405, {
|
|
2880
|
+
message: "Method not allowed",
|
|
2881
|
+
cause: {
|
|
2882
|
+
code: "api/method-not-allowed",
|
|
2883
|
+
detail: `This endpoint only accepts ${allow} requests`
|
|
2884
|
+
}
|
|
2885
|
+
});
|
|
2886
|
+
}
|
|
2887
|
+
|
|
2372
2888
|
// packages/experimental/src/zukhruf/queue/pg-boss.turn-queue.ts
|
|
2373
2889
|
import { v7 as uuidv7 } from "uuid";
|
|
2374
2890
|
|
|
@@ -2736,11 +3252,20 @@ async function renderTurn(stream) {
|
|
|
2736
3252
|
}
|
|
2737
3253
|
|
|
2738
3254
|
// packages/experimental/src/zukhruf/sandbox/define.ts
|
|
2739
|
-
import {
|
|
2740
|
-
|
|
2741
|
-
} from "@deepagents/context";
|
|
3255
|
+
import { createBashTool } from "@deepagents/context";
|
|
3256
|
+
var DEFAULT_WORKING_DIRECTORY = "/workspace";
|
|
2742
3257
|
function defineSandbox(createBackend, options) {
|
|
2743
|
-
return async (context) =>
|
|
3258
|
+
return async (context) => {
|
|
3259
|
+
const workingDirectory = options?.destination ?? DEFAULT_WORKING_DIRECTORY;
|
|
3260
|
+
return Object.assign(
|
|
3261
|
+
await createBashTool({
|
|
3262
|
+
sandbox: await createBackend(context),
|
|
3263
|
+
...options,
|
|
3264
|
+
destination: workingDirectory
|
|
3265
|
+
}),
|
|
3266
|
+
{ workingDirectory }
|
|
3267
|
+
);
|
|
3268
|
+
};
|
|
2744
3269
|
}
|
|
2745
3270
|
|
|
2746
3271
|
// packages/experimental/src/zukhruf/tool.ts
|
|
@@ -2759,12 +3284,21 @@ export {
|
|
|
2759
3284
|
PgBossTurnQueue,
|
|
2760
3285
|
SqliteMailboxStore,
|
|
2761
3286
|
TurnQueue,
|
|
3287
|
+
ZUKHRUF_CREATE_SESSION_ROUTE_PATH,
|
|
3288
|
+
ZUKHRUF_HEALTH_ROUTE_PATH,
|
|
3289
|
+
ZUKHRUF_INFO_ROUTE_PATH,
|
|
3290
|
+
ZUKHRUF_ROUTE_PREFIX,
|
|
3291
|
+
ZUKHRUF_SESSION_CANCEL_ROUTE_PATH,
|
|
3292
|
+
ZUKHRUF_SESSION_ID_HEADER,
|
|
3293
|
+
ZUKHRUF_SESSION_ROUTE_PATH,
|
|
3294
|
+
ZUKHRUF_SESSION_STREAM_ROUTE_PATH,
|
|
2762
3295
|
assertCommunication,
|
|
2763
3296
|
createInterAgentCommunication,
|
|
2764
3297
|
defineAgent,
|
|
2765
3298
|
defineInstructions,
|
|
2766
3299
|
defineSandbox,
|
|
2767
3300
|
defineTool,
|
|
2768
|
-
renderTurn
|
|
3301
|
+
renderTurn,
|
|
3302
|
+
zukhruf
|
|
2769
3303
|
};
|
|
2770
3304
|
//# sourceMappingURL=index.js.map
|