@deepagents/experimental 7.5.2 → 7.7.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/README.md +7 -6
- package/dist/index.js +49 -42
- package/dist/index.js.map +2 -2
- package/dist/providers/claude/accounts.d.ts +6 -0
- package/dist/providers/claude/accounts.d.ts.map +1 -1
- package/dist/providers/claude/index.js +14 -13
- package/dist/providers/claude/index.js.map +3 -3
- package/dist/providers/codex/generate-via-stream.d.ts.map +1 -1
- package/dist/providers/codex/index.js +5 -4
- package/dist/providers/codex/index.js.map +2 -2
- package/dist/zukhruf/agent.d.ts +6 -2
- package/dist/zukhruf/agent.d.ts.map +1 -1
- package/dist/zukhruf/index.js +49 -42
- package/dist/zukhruf/index.js.map +2 -2
- package/dist/zukhruf/plugins/conversation-scheduling/conversation-scheduler.d.ts +5 -0
- package/dist/zukhruf/plugins/conversation-scheduling/conversation-scheduler.d.ts.map +1 -1
- package/dist/zukhruf/plugins/conversation-scheduling/index.d.ts +6 -0
- package/dist/zukhruf/plugins/conversation-scheduling/index.d.ts.map +1 -1
- package/dist/zukhruf/plugins/conversation-scheduling/index.js +15 -7
- package/dist/zukhruf/plugins/conversation-scheduling/index.js.map +2 -2
- package/dist/zukhruf/plugins/http/index.d.ts.map +1 -1
- package/dist/zukhruf/plugins/http/index.js +12 -14
- package/dist/zukhruf/plugins/http/index.js.map +2 -2
- package/dist/zukhruf/plugins/schedules/http.js +2 -1
- package/dist/zukhruf/plugins/schedules/http.js.map +2 -2
- package/dist/zukhruf/plugins/schedules/index.js +2 -2
- package/dist/zukhruf/plugins/schedules/index.js.map +2 -2
- package/dist/zukhruf/plugins/uploads/http.js +1 -0
- package/dist/zukhruf/plugins/uploads/http.js.map +2 -2
- package/dist/zukhruf/plugins/uploads/index.js +7 -7
- package/dist/zukhruf/plugins/uploads/index.js.map +2 -2
- package/dist/zukhruf/runtime/agent-turn-executor.d.ts.map +1 -1
- package/dist/zukhruf/runtime/compaction.d.ts.map +1 -1
- package/dist/zukhruf/runtime/conversation-status/projector.d.ts.map +1 -1
- package/dist/zukhruf/sandbox/define.d.ts +3 -3
- package/dist/zukhruf/sandbox/define.d.ts.map +1 -1
- package/package.json +24 -21
package/README.md
CHANGED
|
@@ -116,12 +116,13 @@ adapters without registering them with `resources`; those adapters remain
|
|
|
116
116
|
caller-owned. Host and worker disposal always wait for active work. Only
|
|
117
117
|
registered adapters are released by host disposal.
|
|
118
118
|
|
|
119
|
-
The
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
119
|
+
The host lazily acquires one sandbox handle per agent declaration and
|
|
120
|
+
conversation from the agent's `sandbox` factory. Later turns and plugins borrow
|
|
121
|
+
the same handle; they must leave disposal to the host. A failed acquisition is
|
|
122
|
+
retried on the next request. Host disposal releases the held handles after its
|
|
123
|
+
workers stop. The backend's disposal policy determines whether the underlying
|
|
124
|
+
environment stops, is removed, or remains available; a named Microsandbox
|
|
125
|
+
microVM can outlive its host's client handle.
|
|
125
126
|
|
|
126
127
|
Zukhruf discovers immediate `skills/<name>/SKILL.md` children from each
|
|
127
128
|
configured sandbox once per conversation. It persists only the ordered catalog
|
package/dist/index.js
CHANGED
|
@@ -1132,7 +1132,7 @@ var PgBossTurnQueue = class _PgBossTurnQueue extends TurnQueue {
|
|
|
1132
1132
|
} catch (error) {
|
|
1133
1133
|
await options.onOrphaned(
|
|
1134
1134
|
turn,
|
|
1135
|
-
`turn follow-up reconciliation failed: ${error
|
|
1135
|
+
`turn follow-up reconciliation failed: ${Error.isError(error) ? error.message : String(error)}`
|
|
1136
1136
|
);
|
|
1137
1137
|
}
|
|
1138
1138
|
}
|
|
@@ -1965,8 +1965,8 @@ var AgentControlPlane = class _AgentControlPlane {
|
|
|
1965
1965
|
declarationName: childDeclaration.name
|
|
1966
1966
|
});
|
|
1967
1967
|
} catch (error) {
|
|
1968
|
-
if (error
|
|
1969
|
-
throw new Error(`spawn_agent: ${error.message}
|
|
1968
|
+
if (Error.isError(error) && error.message.startsWith("agent path ")) {
|
|
1969
|
+
throw new Error(`spawn_agent: ${error.message}`, { cause: error });
|
|
1970
1970
|
}
|
|
1971
1971
|
throw error;
|
|
1972
1972
|
}
|
|
@@ -2202,7 +2202,7 @@ var MailboxCoordinator = class {
|
|
|
2202
2202
|
});
|
|
2203
2203
|
} catch (error) {
|
|
2204
2204
|
await this.#streams.store.updateStreamStatus(wakeId, "failed", {
|
|
2205
|
-
error: error
|
|
2205
|
+
error: Error.isError(error) ? error.message : String(error)
|
|
2206
2206
|
});
|
|
2207
2207
|
throw error;
|
|
2208
2208
|
}
|
|
@@ -2375,7 +2375,7 @@ import {
|
|
|
2375
2375
|
asSchema,
|
|
2376
2376
|
modelMessageSchema as modelMessageSchema2
|
|
2377
2377
|
} from "ai";
|
|
2378
|
-
import {
|
|
2378
|
+
import { hash, randomUUID as randomUUID2 } from "node:crypto";
|
|
2379
2379
|
import { z as z4 } from "zod";
|
|
2380
2380
|
|
|
2381
2381
|
// packages/compaction/dist/index.js
|
|
@@ -2595,8 +2595,8 @@ var cacheObservationSchema = z4.object({
|
|
|
2595
2595
|
retentionMs: z4.number().int().positive().optional()
|
|
2596
2596
|
});
|
|
2597
2597
|
var inputUsageSchema = cacheObservationSchema.pick({ scope: true, prefixLength: true, prefixHash: true }).extend({ inputTokens: z4.number().int().nonnegative() });
|
|
2598
|
-
function
|
|
2599
|
-
return
|
|
2598
|
+
function jsonDigest(value) {
|
|
2599
|
+
return hash("sha256", JSON.stringify(value));
|
|
2600
2600
|
}
|
|
2601
2601
|
function isRecord3(value) {
|
|
2602
2602
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -2690,7 +2690,7 @@ function createCompaction(config, engine, store, signal, onEvent) {
|
|
|
2690
2690
|
])
|
|
2691
2691
|
);
|
|
2692
2692
|
const responseFormat = await settings.output?.responseFormat;
|
|
2693
|
-
settingsHash =
|
|
2693
|
+
settingsHash = jsonDigest([
|
|
2694
2694
|
tools,
|
|
2695
2695
|
settings.providerOptions,
|
|
2696
2696
|
settings.toolChoice,
|
|
@@ -2708,7 +2708,7 @@ function createCompaction(config, engine, store, signal, onEvent) {
|
|
|
2708
2708
|
});
|
|
2709
2709
|
return estimateTokens(messages);
|
|
2710
2710
|
};
|
|
2711
|
-
const scope = (model, instructions) =>
|
|
2711
|
+
const scope = (model, instructions) => jsonDigest([
|
|
2712
2712
|
engine.branch,
|
|
2713
2713
|
typeof model === "string" ? model : [model.provider, model.modelId],
|
|
2714
2714
|
instructions,
|
|
@@ -2735,7 +2735,7 @@ function createCompaction(config, engine, store, signal, onEvent) {
|
|
|
2735
2735
|
if (saved !== void 0) {
|
|
2736
2736
|
const checkpoint2 = checkpointSchema.parse(saved);
|
|
2737
2737
|
const prefix = messages.slice(0, checkpoint2.sourceCount);
|
|
2738
|
-
if (prefix.length === checkpoint2.sourceCount &&
|
|
2738
|
+
if (prefix.length === checkpoint2.sourceCount && jsonDigest(prefix) === checkpoint2.sourceHash) {
|
|
2739
2739
|
source = prefix;
|
|
2740
2740
|
replacement = checkpoint2.replacement;
|
|
2741
2741
|
messages = [
|
|
@@ -2752,7 +2752,7 @@ function createCompaction(config, engine, store, signal, onEvent) {
|
|
|
2752
2752
|
}
|
|
2753
2753
|
initialized = true;
|
|
2754
2754
|
}
|
|
2755
|
-
if (replacement.length > 0 &&
|
|
2755
|
+
if (replacement.length > 0 && jsonDigest(messages.slice(0, replacement.length)) !== jsonDigest(replacement)) {
|
|
2756
2756
|
source = [];
|
|
2757
2757
|
replacement = [];
|
|
2758
2758
|
}
|
|
@@ -2762,7 +2762,7 @@ function createCompaction(config, engine, store, signal, onEvent) {
|
|
|
2762
2762
|
const messageTokens = await (config.countTokens ?? estimateTokens)(
|
|
2763
2763
|
messages
|
|
2764
2764
|
);
|
|
2765
|
-
const tokens = config.countTokens === void 0 && baseline !== null && baseline.scope === scope(input.model, input.instructions) && baseline.prefixLength <= messages.length && baseline.prefixHash ===
|
|
2765
|
+
const tokens = config.countTokens === void 0 && baseline !== null && baseline.scope === scope(input.model, input.instructions) && baseline.prefixLength <= messages.length && baseline.prefixHash === jsonDigest(messages.slice(0, baseline.prefixLength)) ? baseline.inputTokens + estimateTokens(messages.slice(baseline.prefixLength)) : messageTokens + overhead;
|
|
2766
2766
|
if (!Number.isSafeInteger(messageTokens) || messageTokens < 0 || !Number.isSafeInteger(tokens)) {
|
|
2767
2767
|
throw new RangeError(
|
|
2768
2768
|
"compaction countTokens must return a non-negative safe integer."
|
|
@@ -2770,7 +2770,7 @@ function createCompaction(config, engine, store, signal, onEvent) {
|
|
|
2770
2770
|
}
|
|
2771
2771
|
signal.throwIfAborted();
|
|
2772
2772
|
const now = Date.now();
|
|
2773
|
-
const cacheAgeMs = cache !== null && cache.scope === scope(input.model, input.instructions) && cache.prefixLength <= messages.length && cache.prefixHash ===
|
|
2773
|
+
const cacheAgeMs = cache !== null && cache.scope === scope(input.model, input.instructions) && cache.prefixLength <= messages.length && cache.prefixHash === jsonDigest(messages.slice(0, cache.prefixLength)) && now >= cache.startedAt ? now - cache.startedAt : void 0;
|
|
2774
2774
|
const context = {
|
|
2775
2775
|
messages,
|
|
2776
2776
|
tokens,
|
|
@@ -2825,7 +2825,7 @@ function createCompaction(config, engine, store, signal, onEvent) {
|
|
|
2825
2825
|
);
|
|
2826
2826
|
const checkpoint = {
|
|
2827
2827
|
sourceCount,
|
|
2828
|
-
sourceHash:
|
|
2828
|
+
sourceHash: jsonDigest(nextSource),
|
|
2829
2829
|
replacement: nextReplacement
|
|
2830
2830
|
};
|
|
2831
2831
|
signal.throwIfAborted();
|
|
@@ -2862,7 +2862,7 @@ function createCompaction(config, engine, store, signal, onEvent) {
|
|
|
2862
2862
|
request = {
|
|
2863
2863
|
scope: scope(input, input.instructions),
|
|
2864
2864
|
prefixLength: input.messages.length,
|
|
2865
|
-
prefixHash:
|
|
2865
|
+
prefixHash: jsonDigest(input.messages),
|
|
2866
2866
|
startedAt: Date.now()
|
|
2867
2867
|
};
|
|
2868
2868
|
};
|
|
@@ -3005,10 +3005,10 @@ async function discoverAgentSkills(sandbox, signal) {
|
|
|
3005
3005
|
if (sandbox.workingDirectory === void 0) return EMPTY_SKILLS;
|
|
3006
3006
|
const skillsDirectory = path.posix.join(sandbox.workingDirectory, "skills");
|
|
3007
3007
|
const quotedSkillsDirectory = shellQuote(skillsDirectory);
|
|
3008
|
-
const result = await sandbox.sandbox.
|
|
3009
|
-
`if [ -d ${quotedSkillsDirectory} ]; then find ${quotedSkillsDirectory} -mindepth 1 -maxdepth 1 -type d -print; fi`,
|
|
3010
|
-
|
|
3011
|
-
);
|
|
3008
|
+
const result = await sandbox.sandbox.run({
|
|
3009
|
+
command: `if [ -d ${quotedSkillsDirectory} ]; then find ${quotedSkillsDirectory} -mindepth 1 -maxdepth 1 -type d -print; fi`,
|
|
3010
|
+
abortSignal: signal
|
|
3011
|
+
});
|
|
3012
3012
|
if (result.exitCode !== 0) {
|
|
3013
3013
|
throw new Error(
|
|
3014
3014
|
`AgentRuntime: failed to discover sandbox skills: ${result.stderr.trim() || `exit ${result.exitCode}`}`
|
|
@@ -3028,10 +3028,12 @@ function createAgentSkills(available) {
|
|
|
3028
3028
|
}
|
|
3029
3029
|
async function loadSkill(sandbox, directory) {
|
|
3030
3030
|
const directoryName = path.posix.basename(directory);
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3031
|
+
const skillPath = path.posix.join(directory, "SKILL.md");
|
|
3032
|
+
const skillMd = await sandbox.sandbox.readTextFile({ path: skillPath });
|
|
3033
|
+
if (skillMd === null) {
|
|
3034
|
+
throw new Error(`AgentRuntime: ${skillPath} does not exist`);
|
|
3035
|
+
}
|
|
3036
|
+
return availableSkill(skillMd, directoryName);
|
|
3035
3037
|
}
|
|
3036
3038
|
function availableSkill(skillMd, directoryName) {
|
|
3037
3039
|
const { frontmatter } = parseFrontmatter(skillMd);
|
|
@@ -3406,11 +3408,13 @@ var AgentTurnExecutor = class {
|
|
|
3406
3408
|
if (duplicate) {
|
|
3407
3409
|
throw new Error(`AgentRuntime: duplicate skill "${duplicate.name}"`);
|
|
3408
3410
|
}
|
|
3409
|
-
await
|
|
3410
|
-
pluginSkills.files.map(
|
|
3411
|
-
path:
|
|
3412
|
-
|
|
3413
|
-
|
|
3411
|
+
await Promise.all(
|
|
3412
|
+
pluginSkills.files.map(
|
|
3413
|
+
({ path: relativePath, content }) => sandbox.sandbox.writeBinaryFile({
|
|
3414
|
+
path: path2.posix.join(workingDirectory, relativePath),
|
|
3415
|
+
content
|
|
3416
|
+
})
|
|
3417
|
+
)
|
|
3414
3418
|
);
|
|
3415
3419
|
return createAgentSkills(
|
|
3416
3420
|
[...available, ...pluginSkills.available].toSorted(
|
|
@@ -3659,7 +3663,7 @@ var ConversationSandboxes = class {
|
|
|
3659
3663
|
};
|
|
3660
3664
|
|
|
3661
3665
|
// packages/experimental/src/zukhruf/runtime/conversation-status/projector.ts
|
|
3662
|
-
import { Latch } from "@zukhruf/async";
|
|
3666
|
+
import { Future, Latch } from "@zukhruf/async";
|
|
3663
3667
|
import { Mutex } from "@zukhruf/mutex";
|
|
3664
3668
|
import { MemoryStore } from "@zukhruf/mutex/memory";
|
|
3665
3669
|
import { EventEmitter, on } from "node:events";
|
|
@@ -3702,8 +3706,8 @@ var Detached = class {
|
|
|
3702
3706
|
var DETACHED = new Detached();
|
|
3703
3707
|
var RemoteAttachment = class {
|
|
3704
3708
|
abort = new AbortController();
|
|
3705
|
-
/**
|
|
3706
|
-
connected = new
|
|
3709
|
+
/** Resolves when the source subscribes; rejects with the error that stopped it. */
|
|
3710
|
+
connected = new Future();
|
|
3707
3711
|
/** Opens when the consume loop has stopped. */
|
|
3708
3712
|
ended = new Latch();
|
|
3709
3713
|
};
|
|
@@ -3887,10 +3891,11 @@ var ConversationStatusProjector = class _ConversationStatusProjector {
|
|
|
3887
3891
|
this.#remote = remote;
|
|
3888
3892
|
void this.#consumeRemote(source, remote);
|
|
3889
3893
|
}
|
|
3890
|
-
|
|
3891
|
-
|
|
3894
|
+
try {
|
|
3895
|
+
await remote.connected.wait();
|
|
3896
|
+
} catch (error) {
|
|
3892
3897
|
await this.#detachRemote();
|
|
3893
|
-
throw
|
|
3898
|
+
throw error;
|
|
3894
3899
|
}
|
|
3895
3900
|
}
|
|
3896
3901
|
async #detachRemote() {
|
|
@@ -3906,7 +3911,7 @@ var ConversationStatusProjector = class _ConversationStatusProjector {
|
|
|
3906
3911
|
try {
|
|
3907
3912
|
const events = await source.subscribe(remote.abort.signal);
|
|
3908
3913
|
connected = true;
|
|
3909
|
-
remote.connected.
|
|
3914
|
+
remote.connected.resolve();
|
|
3910
3915
|
for await (const event of events) {
|
|
3911
3916
|
if (event.type === "reset") {
|
|
3912
3917
|
this.#emit(event);
|
|
@@ -3921,8 +3926,8 @@ var ConversationStatusProjector = class _ConversationStatusProjector {
|
|
|
3921
3926
|
});
|
|
3922
3927
|
}
|
|
3923
3928
|
} catch (error) {
|
|
3924
|
-
if (!connected) remote.connected.
|
|
3925
|
-
if (connected && !(error
|
|
3929
|
+
if (!connected) remote.connected.reject(error);
|
|
3930
|
+
if (connected && !(Error.isError(error) && error.name === "AbortError")) {
|
|
3926
3931
|
this.#emit({ type: "error", error });
|
|
3927
3932
|
}
|
|
3928
3933
|
} finally {
|
|
@@ -4582,7 +4587,7 @@ var PluginManager = class {
|
|
|
4582
4587
|
if (errors.length > 0) {
|
|
4583
4588
|
throw new AggregateError(
|
|
4584
4589
|
errors,
|
|
4585
|
-
`AgentRuntime: conversation availability reconciliation failed for "${conversation.chatId}": ${errors.map((error) => error
|
|
4590
|
+
`AgentRuntime: conversation availability reconciliation failed for "${conversation.chatId}": ${errors.map((error) => Error.isError(error) ? error.message : String(error)).join("; ")}`
|
|
4586
4591
|
);
|
|
4587
4592
|
}
|
|
4588
4593
|
}
|
|
@@ -5090,7 +5095,7 @@ var PgBossConversationStatusChangeSource = class {
|
|
|
5090
5095
|
signal
|
|
5091
5096
|
);
|
|
5092
5097
|
} catch (error) {
|
|
5093
|
-
if (error
|
|
5098
|
+
if (Error.isError(error) && error.message === "pg-boss database does not support LISTEN") {
|
|
5094
5099
|
throw new Error(
|
|
5095
5100
|
"PgBossConversationStatusChangeSource requires a pg-boss database with LISTEN support",
|
|
5096
5101
|
{ cause: error }
|
|
@@ -5121,16 +5126,18 @@ function parseHint(payload) {
|
|
|
5121
5126
|
}
|
|
5122
5127
|
|
|
5123
5128
|
// packages/experimental/src/zukhruf/sandbox/define.ts
|
|
5124
|
-
import {
|
|
5129
|
+
import {
|
|
5130
|
+
createBashTool
|
|
5131
|
+
} from "@deepagents/context";
|
|
5125
5132
|
var DEFAULT_WORKING_DIRECTORY = "/workspace";
|
|
5126
5133
|
function defineSandbox(createBackend, options) {
|
|
5127
5134
|
return async (context) => {
|
|
5128
|
-
const workingDirectory = options?.
|
|
5135
|
+
const workingDirectory = options?.workingDirectory ?? DEFAULT_WORKING_DIRECTORY;
|
|
5129
5136
|
return Object.assign(
|
|
5130
5137
|
await createBashTool({
|
|
5131
5138
|
sandbox: await createBackend(context),
|
|
5132
5139
|
...options,
|
|
5133
|
-
|
|
5140
|
+
workingDirectory
|
|
5134
5141
|
}),
|
|
5135
5142
|
{ workingDirectory }
|
|
5136
5143
|
);
|