@deepagents/experimental 7.5.2 → 7.6.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.
Files changed (33) hide show
  1. package/README.md +7 -6
  2. package/dist/index.js +40 -34
  3. package/dist/index.js.map +2 -2
  4. package/dist/providers/claude/accounts.d.ts +6 -0
  5. package/dist/providers/claude/accounts.d.ts.map +1 -1
  6. package/dist/providers/claude/index.js +14 -13
  7. package/dist/providers/claude/index.js.map +3 -3
  8. package/dist/providers/codex/generate-via-stream.d.ts.map +1 -1
  9. package/dist/providers/codex/index.js +5 -4
  10. package/dist/providers/codex/index.js.map +2 -2
  11. package/dist/zukhruf/index.js +40 -34
  12. package/dist/zukhruf/index.js.map +2 -2
  13. package/dist/zukhruf/plugins/conversation-scheduling/conversation-scheduler.d.ts +5 -0
  14. package/dist/zukhruf/plugins/conversation-scheduling/conversation-scheduler.d.ts.map +1 -1
  15. package/dist/zukhruf/plugins/conversation-scheduling/index.d.ts +6 -0
  16. package/dist/zukhruf/plugins/conversation-scheduling/index.d.ts.map +1 -1
  17. package/dist/zukhruf/plugins/conversation-scheduling/index.js +14 -6
  18. package/dist/zukhruf/plugins/conversation-scheduling/index.js.map +2 -2
  19. package/dist/zukhruf/plugins/http/index.js +1 -1
  20. package/dist/zukhruf/plugins/http/index.js.map +2 -2
  21. package/dist/zukhruf/plugins/schedules/http.js +1 -1
  22. package/dist/zukhruf/plugins/schedules/http.js.map +2 -2
  23. package/dist/zukhruf/plugins/schedules/index.js +1 -1
  24. package/dist/zukhruf/plugins/schedules/index.js.map +2 -2
  25. package/dist/zukhruf/plugins/uploads/http.js.map +1 -1
  26. package/dist/zukhruf/plugins/uploads/index.js +7 -7
  27. package/dist/zukhruf/plugins/uploads/index.js.map +2 -2
  28. package/dist/zukhruf/runtime/agent-turn-executor.d.ts.map +1 -1
  29. package/dist/zukhruf/runtime/compaction.d.ts.map +1 -1
  30. package/dist/zukhruf/runtime/conversation-status/projector.d.ts.map +1 -1
  31. package/dist/zukhruf/sandbox/define.d.ts +3 -3
  32. package/dist/zukhruf/sandbox/define.d.ts.map +1 -1
  33. 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 runtime also owns each sandbox handle returned by the agent's `sandbox`
120
- factory. It acquires a handle for a turn and disposes it when execution ends,
121
- including on failure. Return a handle that can be disposed independently on
122
- each call. A backend's disposal policy determines whether the underlying
123
- sandbox is retained; a named Microsandbox microVM can outlive its turn's
124
- client handle.
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 instanceof Error ? error.message : String(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 instanceof Error && error.message.startsWith("agent path ")) {
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 instanceof Error ? error.message : String(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 { createHash, randomUUID as randomUUID2 } from "node:crypto";
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 hash(value) {
2599
- return createHash("sha256").update(JSON.stringify(value)).digest("hex");
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 = hash([
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) => hash([
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 && hash(prefix) === checkpoint2.sourceHash) {
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 && hash(messages.slice(0, replacement.length)) !== hash(replacement)) {
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 === hash(messages.slice(0, baseline.prefixLength)) ? baseline.inputTokens + estimateTokens(messages.slice(baseline.prefixLength)) : messageTokens + overhead;
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 === hash(messages.slice(0, cache.prefixLength)) && now >= cache.startedAt ? now - cache.startedAt : void 0;
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: hash(nextSource),
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: hash(input.messages),
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.executeCommand(
3009
- `if [ -d ${quotedSkillsDirectory} ]; then find ${quotedSkillsDirectory} -mindepth 1 -maxdepth 1 -type d -print; fi`,
3010
- { signal }
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
- return availableSkill(
3032
- await sandbox.sandbox.readFile(path.posix.join(directory, "SKILL.md")),
3033
- directoryName
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 sandbox.sandbox.writeFiles(
3410
- pluginSkills.files.map(({ path: relativePath, content }) => ({
3411
- path: path2.posix.join(workingDirectory, relativePath),
3412
- content
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(
@@ -3922,7 +3926,7 @@ var ConversationStatusProjector = class _ConversationStatusProjector {
3922
3926
  }
3923
3927
  } catch (error) {
3924
3928
  if (!connected) remote.connected.open({ error });
3925
- if (connected && !(error instanceof Error && error.name === "AbortError")) {
3929
+ if (connected && !(Error.isError(error) && error.name === "AbortError")) {
3926
3930
  this.#emit({ type: "error", error });
3927
3931
  }
3928
3932
  } finally {
@@ -4582,7 +4586,7 @@ var PluginManager = class {
4582
4586
  if (errors.length > 0) {
4583
4587
  throw new AggregateError(
4584
4588
  errors,
4585
- `AgentRuntime: conversation availability reconciliation failed for "${conversation.chatId}": ${errors.map((error) => error instanceof Error ? error.message : String(error)).join("; ")}`
4589
+ `AgentRuntime: conversation availability reconciliation failed for "${conversation.chatId}": ${errors.map((error) => Error.isError(error) ? error.message : String(error)).join("; ")}`
4586
4590
  );
4587
4591
  }
4588
4592
  }
@@ -5090,7 +5094,7 @@ var PgBossConversationStatusChangeSource = class {
5090
5094
  signal
5091
5095
  );
5092
5096
  } catch (error) {
5093
- if (error instanceof Error && error.message === "pg-boss database does not support LISTEN") {
5097
+ if (Error.isError(error) && error.message === "pg-boss database does not support LISTEN") {
5094
5098
  throw new Error(
5095
5099
  "PgBossConversationStatusChangeSource requires a pg-boss database with LISTEN support",
5096
5100
  { cause: error }
@@ -5121,16 +5125,18 @@ function parseHint(payload) {
5121
5125
  }
5122
5126
 
5123
5127
  // packages/experimental/src/zukhruf/sandbox/define.ts
5124
- import { createBashTool } from "@deepagents/context";
5128
+ import {
5129
+ createBashTool
5130
+ } from "@deepagents/context";
5125
5131
  var DEFAULT_WORKING_DIRECTORY = "/workspace";
5126
5132
  function defineSandbox(createBackend, options) {
5127
5133
  return async (context) => {
5128
- const workingDirectory = options?.destination ?? DEFAULT_WORKING_DIRECTORY;
5134
+ const workingDirectory = options?.workingDirectory ?? DEFAULT_WORKING_DIRECTORY;
5129
5135
  return Object.assign(
5130
5136
  await createBashTool({
5131
5137
  sandbox: await createBackend(context),
5132
5138
  ...options,
5133
- destination: workingDirectory
5139
+ workingDirectory
5134
5140
  }),
5135
5141
  { workingDirectory }
5136
5142
  );