@agent-compose/sdk 0.8.0 → 0.8.1

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 CHANGED
@@ -959,6 +959,8 @@ function extractMetadata(source) {
959
959
  out.invokePolicy = freezeMetadataValue(source.invokePolicy);
960
960
  if (source.environmentBuild !== undefined)
961
961
  out.environmentBuild = source.environmentBuild;
962
+ if (source.factoryDrive !== undefined)
963
+ out.factoryDrive = source.factoryDrive;
962
964
  return Object.freeze(out);
963
965
  }
964
966
  function freezeMetadataValue(value) {
@@ -1446,14 +1448,47 @@ class AgentComposeClient {
1446
1448
  ...opts?.placeholders !== undefined ? { placeholders: opts.placeholders } : {},
1447
1449
  ...opts?.size !== undefined ? { size: opts.size } : {},
1448
1450
  ...parentRunId ? { parentRunId } : {},
1449
- ...opts?.agentId ? { agentId: opts.agentId } : {}
1451
+ ...opts?.agentId ? { agentId: opts.agentId } : {},
1452
+ ...opts?.funding !== undefined ? { funding: opts.funding } : {},
1453
+ ...opts?.fundingSecret !== undefined ? { fundingSecret: opts.fundingSecret } : {}
1454
+ }
1455
+ });
1456
+ }
1457
+ invokeInline(workflow, input, opts) {
1458
+ const parentRunId = opts?.parentRunId === undefined ? detectAmbientParentRunId() : opts.parentRunId;
1459
+ const factorySlug = opts?.factorySlug ?? DEFAULT_FACTORY;
1460
+ const headers = {};
1461
+ if (opts?.idempotencyKey)
1462
+ headers["Idempotency-Key"] = opts.idempotencyKey;
1463
+ return this.fetch(`/api/v1/factories/${encodeURIComponent(factorySlug)}/invoke`, {
1464
+ method: "POST",
1465
+ ...opts?.idempotencyKey ? { headers } : {},
1466
+ body: {
1467
+ workflow,
1468
+ input,
1469
+ ...opts?.title !== undefined ? { title: opts.title } : {},
1470
+ ...opts?.snapshots !== undefined ? { snapshots: opts.snapshots } : {},
1471
+ ...opts?.networkPolicy !== undefined ? { networkPolicy: opts.networkPolicy } : {},
1472
+ ...opts?.placeholders !== undefined ? { placeholders: opts.placeholders } : {},
1473
+ ...opts?.size !== undefined ? { size: opts.size } : {},
1474
+ ...parentRunId ? { parentRunId } : {},
1475
+ ...opts?.agentId ? { agentId: opts.agentId } : {},
1476
+ ...opts?.funding !== undefined ? { funding: opts.funding } : {},
1477
+ ...opts?.fundingSecret !== undefined ? { fundingSecret: opts.fundingSecret } : {}
1450
1478
  }
1451
1479
  });
1452
1480
  }
1453
1481
  async invokeAndWait(name, input, opts) {
1482
+ const { id: runId } = await this.invoke(name, input, opts);
1483
+ return this.waitForRun(runId, opts);
1484
+ }
1485
+ async invokeInlineAndWait(workflow, input, opts) {
1486
+ const { id: runId } = await this.invokeInline(workflow, input, opts);
1487
+ return this.waitForRun(runId, opts);
1488
+ }
1489
+ async waitForRun(runId, opts) {
1454
1490
  const timeoutMs = opts?.timeoutMs ?? 30 * 60 * 1000;
1455
1491
  const pollMs = opts?.pollIntervalMs ?? 1000;
1456
- const { id: runId } = await this.invoke(name, input, opts);
1457
1492
  const deadline = Date.now() + timeoutMs;
1458
1493
  while (Date.now() < deadline) {
1459
1494
  const status = await this.getStatus(runId);
@@ -1462,7 +1497,7 @@ class AgentComposeClient {
1462
1497
  }
1463
1498
  await new Promise((r) => setTimeout(r, pollMs));
1464
1499
  }
1465
- throw new AgentComposeError(504, `invokeAndWait: run ${runId} did not settle within ${timeoutMs}ms`);
1500
+ throw new AgentComposeError(504, `waitForRun: run ${runId} did not settle within ${timeoutMs}ms`);
1466
1501
  }
1467
1502
  async listSnapshots(opts) {
1468
1503
  const body = await this.listSnapshotsPage(opts);
@@ -1598,6 +1633,11 @@ class AgentComposeClient {
1598
1633
  preview: a.preview
1599
1634
  }));
1600
1635
  }
1636
+ async getRunArtifactBytes(runId, path) {
1637
+ const q2 = new URLSearchParams({ path });
1638
+ const buf = await this.fetch(`/api/v1/workflows/${encodeURIComponent(runId)}/artifacts/content?${q2}`, { responseType: "arrayBuffer" });
1639
+ return new Uint8Array(buf);
1640
+ }
1601
1641
  async putFactoryFile(path, content, opts) {
1602
1642
  const factorySlug = opts?.factorySlug ?? (typeof process !== "undefined" ? process.env?.AGENT_COMPOSE_FACTORY : undefined) ?? DEFAULT_FACTORY;
1603
1643
  const runToken = typeof process !== "undefined" ? process.env?.AGENT_COMPOSE_RUN_TOKEN : undefined;
@@ -1621,12 +1661,28 @@ class AgentComposeClient {
1621
1661
  const q2 = new URLSearchParams({ path });
1622
1662
  if (opts?.revision !== undefined)
1623
1663
  q2.set("revision", String(opts.revision));
1664
+ if (opts?.branch !== undefined)
1665
+ q2.set("branch", opts.branch);
1624
1666
  const buf = await this.fetch(`/api/v1/factories/${encodeURIComponent(factorySlug)}/files/content?${q2}`, { responseType: "arrayBuffer" });
1625
1667
  return new Uint8Array(buf);
1626
1668
  }
1627
1669
  async getFactoryFile(path, opts) {
1628
1670
  return new TextDecoder().decode(await this.getFactoryFileBytes(path, opts));
1629
1671
  }
1672
+ async createDriveMountSession(opts) {
1673
+ const factorySlug = opts?.factorySlug ?? (typeof process !== "undefined" ? process.env?.AGENT_COMPOSE_FACTORY : undefined) ?? DEFAULT_FACTORY;
1674
+ return this.fetch(`/api/v1/factories/${encodeURIComponent(factorySlug)}/files/mount-sessions`, {
1675
+ method: "POST",
1676
+ body: {
1677
+ ...opts?.conversationId ? { conversationId: opts.conversationId } : {},
1678
+ ...opts?.host ? { host: opts.host } : {}
1679
+ }
1680
+ });
1681
+ }
1682
+ async releaseDriveMountSession(conversationId, opts) {
1683
+ const factorySlug = opts?.factorySlug ?? (typeof process !== "undefined" ? process.env?.AGENT_COMPOSE_FACTORY : undefined) ?? DEFAULT_FACTORY;
1684
+ return this.fetch(`/api/v1/factories/${encodeURIComponent(factorySlug)}/files/mount-sessions/${encodeURIComponent(conversationId)}/release`, { method: "POST", body: {} });
1685
+ }
1630
1686
  listConversations(opts) {
1631
1687
  const q2 = new URLSearchParams;
1632
1688
  if (opts?.cursor)
@@ -1639,8 +1695,9 @@ class AgentComposeClient {
1639
1695
  q2.set("cursor", opts.cursor);
1640
1696
  return this.fetch(`/api/v1/sessions?${q2}`);
1641
1697
  }
1642
- getConversation(id) {
1643
- return this.fetch(`/api/v1/conversations/${encodeURIComponent(id)}`);
1698
+ getConversation(id, opts) {
1699
+ const q2 = opts?.limit !== undefined ? `?limit=${opts.limit}` : "";
1700
+ return this.fetch(`/api/v1/conversations/${encodeURIComponent(id)}${q2}`);
1644
1701
  }
1645
1702
  createCloudSession(input) {
1646
1703
  return this.fetch(`/api/v1/sessions/cloud`, {
@@ -1658,7 +1715,10 @@ class AgentComposeClient {
1658
1715
  ...input.templateId ? { templateId: input.templateId } : {},
1659
1716
  ...input.sandboxSize ? { sandboxSize: input.sandboxSize } : {},
1660
1717
  ...input.networkPolicy !== undefined ? { networkPolicy: input.networkPolicy } : {},
1661
- ...input.connectorProfileId !== undefined ? { connectorProfileId: input.connectorProfileId } : {}
1718
+ ...input.connectorProfileId !== undefined ? { connectorProfileId: input.connectorProfileId } : {},
1719
+ ...input.setupCommand !== undefined ? { setupCommand: input.setupCommand } : {},
1720
+ ...input.handoffOrigin !== undefined ? { handoffOrigin: input.handoffOrigin } : {},
1721
+ ...input.seedFiles !== undefined ? { seedFiles: input.seedFiles } : {}
1662
1722
  }
1663
1723
  });
1664
1724
  }
@@ -2466,6 +2526,7 @@ class AcpClientPeer {
2466
2526
  }
2467
2527
  // src/utils/bundler.ts
2468
2528
  import { createHash as createHash2 } from "node:crypto";
2529
+ import { dirname as dirname2 } from "node:path";
2469
2530
  import { parse as babelParse } from "@babel/parser";
2470
2531
 
2471
2532
  // src/utils/source-loader.ts
@@ -2495,15 +2556,119 @@ class WorkflowSourceValidationError extends Error {
2495
2556
  this.name = "WorkflowSourceValidationError";
2496
2557
  }
2497
2558
  }
2559
+ var SDK_PACKAGE = "@agent-compose/sdk";
2560
+ var SDK_SPECIFIER_ALIASES = [
2561
+ "agentc/sdk",
2562
+ "@agentc/sdk",
2563
+ "agentc-sdk",
2564
+ "agent-compose/sdk",
2565
+ "agentcompose/sdk",
2566
+ "@agentcompose/sdk",
2567
+ "agent-compose-sdk"
2568
+ ];
2569
+ var SDK_ALIAS_SET = new Set(SDK_SPECIFIER_ALIASES);
2570
+ function resolveSdkAlias(specifier) {
2571
+ return SDK_ALIAS_SET.has(specifier) ? SDK_PACKAGE : null;
2572
+ }
2573
+ function aliasFilter() {
2574
+ const alternation = SDK_SPECIFIER_ALIASES.map((s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
2575
+ return new RegExp(`^(?:${alternation})$`);
2576
+ }
2577
+ function sdkAliasPlugin(bun) {
2578
+ return {
2579
+ name: "agent-compose-sdk-alias",
2580
+ setup(build) {
2581
+ build.onResolve({ filter: aliasFilter() }, (args) => {
2582
+ const target = resolveSdkAlias(args.path);
2583
+ if (!target)
2584
+ return;
2585
+ const from = args.importer ? dirname2(args.importer) : args.resolveDir;
2586
+ try {
2587
+ return { path: bun.resolveSync(target, from && from.length > 0 ? from : process.cwd()) };
2588
+ } catch {
2589
+ return;
2590
+ }
2591
+ });
2592
+ }
2593
+ };
2594
+ }
2595
+ function readUnresolvedSpecifier(diag) {
2596
+ if (!diag || typeof diag !== "object")
2597
+ return null;
2598
+ const d = diag;
2599
+ if (typeof d.specifier === "string" && d.specifier.length > 0)
2600
+ return d.specifier;
2601
+ const message = typeof d.message === "string" ? d.message : "";
2602
+ const m = /Could not resolve:?\s*"([^"]+)"/.exec(message);
2603
+ return m ? m[1] : null;
2604
+ }
2605
+ function flattenDiagnostics(failure) {
2606
+ const out = [];
2607
+ const seen = new Set;
2608
+ const walk = (node, depth) => {
2609
+ if (!node || depth > 4 || seen.has(node))
2610
+ return;
2611
+ seen.add(node);
2612
+ if (Array.isArray(node)) {
2613
+ for (const sub of node)
2614
+ walk(sub, depth + 1);
2615
+ return;
2616
+ }
2617
+ out.push(node);
2618
+ if (typeof node === "object") {
2619
+ const n = node;
2620
+ if (Array.isArray(n.errors))
2621
+ for (const sub of n.errors)
2622
+ walk(sub, depth + 1);
2623
+ if (n.cause)
2624
+ walk(n.cause, depth + 1);
2625
+ }
2626
+ };
2627
+ walk(failure, 0);
2628
+ return out;
2629
+ }
2630
+ function diagnosticText(diag) {
2631
+ if (diag instanceof Error)
2632
+ return diag.message || String(diag);
2633
+ if (diag && typeof diag === "object" && typeof diag.message === "string") {
2634
+ return diag.message;
2635
+ }
2636
+ return String(diag);
2637
+ }
2638
+ function explainBundleFailure(err, label) {
2639
+ const diagnostics = flattenDiagnostics(err);
2640
+ const unresolved = [];
2641
+ for (const diag of diagnostics) {
2642
+ const specifier = readUnresolvedSpecifier(diag);
2643
+ if (specifier && !unresolved.includes(specifier))
2644
+ unresolved.push(specifier);
2645
+ }
2646
+ if (unresolved.length > 0) {
2647
+ const quoted = unresolved.map((s) => `"${s}"`).join(", ");
2648
+ return `Could not resolve ${quoted} — workflow source imports the platform SDK as "${SDK_PACKAGE}". ` + `Fix the import specifier in ${label}; anything that is genuinely a third-party ` + `package must be installed where the source is bundled.`;
2649
+ }
2650
+ const detail = diagnostics.map(diagnosticText).filter((t) => t.length > 0 && t !== "Bundle failed").join(`
2651
+ `);
2652
+ return `Failed to bundle ${label}:
2653
+ ${detail || "the bundler reported no diagnostics"}`;
2654
+ }
2498
2655
  async function bundle(path, label) {
2499
2656
  const bun = globalThis;
2500
2657
  if (!bun.Bun?.build)
2501
2658
  throw new Error("bundleWorkflow requires the Bun runtime (Bun.build)");
2502
- const result = await bun.Bun.build({ entrypoints: [path], format: "esm", target: "node" });
2659
+ let result;
2660
+ try {
2661
+ result = await bun.Bun.build({
2662
+ entrypoints: [path],
2663
+ format: "esm",
2664
+ target: "node",
2665
+ plugins: [sdkAliasPlugin(bun.Bun)]
2666
+ });
2667
+ } catch (err) {
2668
+ throw new WorkflowSourceValidationError(explainBundleFailure(err, label));
2669
+ }
2503
2670
  if (!result.success) {
2504
- throw new Error(`Failed to bundle ${label}:
2505
- ${result.logs.map((l) => l.message).join(`
2506
- `)}`);
2671
+ throw new WorkflowSourceValidationError(explainBundleFailure(result.logs, label));
2507
2672
  }
2508
2673
  return result.outputs[0].text();
2509
2674
  }
@@ -2621,7 +2786,8 @@ async function bundleWorkflow(workflowPath, overrides) {
2621
2786
  ...metadata.connectors !== undefined ? { connectors: metadata.connectors } : {},
2622
2787
  ...metadata.connectorOperation !== undefined ? { connectorOperation: metadata.connectorOperation } : {},
2623
2788
  ...metadata.invokePolicy !== undefined ? { invokePolicy: metadata.invokePolicy } : {},
2624
- ...metadata.environmentBuild !== undefined ? { environmentBuild: metadata.environmentBuild } : {}
2789
+ ...metadata.environmentBuild !== undefined ? { environmentBuild: metadata.environmentBuild } : {},
2790
+ ...metadata.factoryDrive !== undefined ? { factoryDrive: metadata.factoryDrive } : {}
2625
2791
  };
2626
2792
  }
2627
2793
  function extractIOSchema(zodSchema) {
@@ -3019,7 +3185,8 @@ async function agentLoop(opts) {
3019
3185
  label,
3020
3186
  allowedTools: opts.allowedTools ?? DEFAULT_ALLOWED_TOOLS,
3021
3187
  ...client.model != null ? { model: client.model } : {},
3022
- ...client.kind != null ? { runtimeKind: client.kind } : {}
3188
+ ...client.kind != null ? { runtimeKind: client.kind } : {},
3189
+ ...opts.phase != null ? { phase: opts.phase } : {}
3023
3190
  });
3024
3191
  }
3025
3192
  const flushState = async (currentIteration) => {
@@ -3986,7 +4153,7 @@ var codexSpec = {
3986
4153
  "--skip-git-repo-check",
3987
4154
  "--dangerously-bypass-approvals-and-sandbox",
3988
4155
  ...model ? ["-m", shellQuote(model)] : [],
3989
- ...effort ? ["-c", `model_reasoning_effort=${effort}`] : [],
4156
+ ...effort ? ["-c", `model_reasoning_effort=${effort === "max" ? "xhigh" : effort}`] : [],
3990
4157
  ...cwd ? ["-C", shellQuote(cwd)] : []
3991
4158
  ].join(" ");
3992
4159
  const exec = sessionId ? `codex exec resume ${shellQuote(sessionId)} ${flags}` : `codex exec ${flags}`;
@@ -4208,7 +4375,7 @@ function toolResultText(content) {
4208
4375
  }
4209
4376
  return content == null ? "" : JSON.stringify(content) ?? "";
4210
4377
  }
4211
- var CLAUDE_CODE_THINKING_TOKENS = { low: 2048, medium: 8192, high: 16384 };
4378
+ var CLAUDE_CODE_EFFORT_LEVELS = ["low", "medium", "high", "xhigh", "max"];
4212
4379
  var claudeCodeSpec = {
4213
4380
  kind: "claude-code",
4214
4381
  authEnv: "ANTHROPIC_API_KEY",
@@ -4224,14 +4391,15 @@ var claudeCodeSpec = {
4224
4391
  "--include-partial-messages",
4225
4392
  "--dangerously-skip-permissions",
4226
4393
  ...model ? [`--model ${shellQuote(model)}`] : [],
4394
+ ...effort ? [`--effort ${effort}`] : [],
4227
4395
  ...sessionId ? [`--resume ${shellQuote(sessionId)}`] : []
4228
4396
  ].join(" ");
4229
- const thinking = effort ? `MAX_THINKING_TOKENS=${CLAUDE_CODE_THINKING_TOKENS[effort]} ` : "";
4230
- return `${cwd ? `cd ${shellQuote(cwd)} && ` : ""}${thinking}IS_SANDBOX=1 claude ${flags} < ${shellQuote(promptPath)}`;
4397
+ return `${cwd ? `cd ${shellQuote(cwd)} && ` : ""}IS_SANDBOX=1 claude ${flags} < ${shellQuote(promptPath)}`;
4231
4398
  },
4232
4399
  extractSessionId: (p) => typeof p.session_id === "string" ? p.session_id : undefined,
4233
4400
  mapEvent: (p) => {
4234
4401
  const ts = now10();
4402
+ const parent = typeof p.parent_tool_use_id === "string" && p.parent_tool_use_id.length > 0 ? { parentToolUseId: p.parent_tool_use_id } : {};
4235
4403
  switch (p.type) {
4236
4404
  case "assistant": {
4237
4405
  const message = p.message;
@@ -4249,6 +4417,7 @@ var claudeCodeSpec = {
4249
4417
  toolName: String(b.name ?? "tool"),
4250
4418
  toolInput: b.input ?? {},
4251
4419
  toolUseId: String(b.id ?? ""),
4420
+ ...parent,
4252
4421
  timestamp: ts
4253
4422
  }];
4254
4423
  }
@@ -4263,6 +4432,7 @@ var claudeCodeSpec = {
4263
4432
  toolUseId: String(b.tool_use_id ?? ""),
4264
4433
  output: toolResultText(b.content),
4265
4434
  isError: b.is_error === true,
4435
+ ...parent,
4266
4436
  timestamp: ts
4267
4437
  }] : []);
4268
4438
  }
@@ -4892,7 +5062,7 @@ var vercelProviderDef = {
4892
5062
 
4893
5063
  // src/sandbox/providers/local.ts
4894
5064
  import { promises as fs2 } from "node:fs";
4895
- import { dirname as dirname2 } from "node:path";
5065
+ import { dirname as dirname3 } from "node:path";
4896
5066
  import { spawn } from "node:child_process";
4897
5067
  import { Readable, Writable } from "node:stream";
4898
5068
  function makeLocalSandboxProvider() {
@@ -4958,7 +5128,7 @@ function makeLocalSandboxProvider() {
4958
5128
  },
4959
5129
  files: {
4960
5130
  async write(path, content) {
4961
- await fs2.mkdir(dirname2(path), { recursive: true });
5131
+ await fs2.mkdir(dirname3(path), { recursive: true });
4962
5132
  await fs2.writeFile(path, content);
4963
5133
  },
4964
5134
  async read(path) {
@@ -5509,6 +5679,15 @@ async function runWorkflow(wf, ctx, opts) {
5509
5679
  }
5510
5680
  }
5511
5681
  // src/workflows/invoke-child.ts
5682
+ function deriveInvokeChildIdempotencyKey(parentRunId, childName) {
5683
+ const step = getActiveStep();
5684
+ if (!step)
5685
+ return null;
5686
+ const ordinal = nextPauseOrdinalInActiveStep(`invoke-child:${childName}`);
5687
+ if (ordinal === null)
5688
+ return null;
5689
+ return `invoke-child:${parentRunId}:step${step.stepIndex}:${childName}:${ordinal}`;
5690
+ }
5512
5691
  function buildInvokeChild(runId, opts = {}) {
5513
5692
  let childClient = null;
5514
5693
  const getChildClient = () => {
@@ -5522,11 +5701,15 @@ function buildInvokeChild(runId, opts = {}) {
5522
5701
  childClient = new AgentComposeClient({ apiKey, baseUrl });
5523
5702
  return childClient;
5524
5703
  };
5525
- return (name, input, childOpts) => getChildClient().invokeAndWait(name, input, {
5526
- ...childOpts,
5527
- parentRunId: runId,
5528
- factorySlug: childOpts?.factorySlug ?? opts.defaultFactorySlug ?? process.env.AGENT_COMPOSE_FACTORY ?? process.env.AGENT_COMPOSE_FACTORY_SLUG ?? "default"
5529
- });
5704
+ return (name, input, childOpts) => {
5705
+ const idempotencyKey = childOpts?.idempotencyKey ?? deriveInvokeChildIdempotencyKey(runId, name) ?? undefined;
5706
+ return getChildClient().invokeAndWait(name, input, {
5707
+ ...childOpts,
5708
+ ...idempotencyKey !== undefined ? { idempotencyKey } : {},
5709
+ parentRunId: runId,
5710
+ factorySlug: childOpts?.factorySlug ?? opts.defaultFactorySlug ?? process.env.AGENT_COMPOSE_FACTORY ?? process.env.AGENT_COMPOSE_FACTORY_SLUG ?? "default"
5711
+ });
5712
+ };
5530
5713
  }
5531
5714
  // src/workflow-steps/step.ts
5532
5715
  var CONTROL_CHARS = /[\u0000-\u001f\u007f]/;
@@ -6599,6 +6782,7 @@ async function agent(opts) {
6599
6782
  runtime: (runtimeOpts) => opts.runtime.create(opts.sandbox, { ...runtimeOpts, agentManual: buildAgentContextDoc(process.env) }),
6600
6783
  agentId,
6601
6784
  ...opts.label !== undefined ? { label: opts.label } : {},
6785
+ ...opts.phase !== undefined ? { phase: opts.phase } : {},
6602
6786
  ...opts.budget?.turnsPerIteration !== undefined ? { turnsPerIteration: opts.budget.turnsPerIteration } : {},
6603
6787
  ...opts.budget?.maxIterations !== undefined ? { maxIterations: opts.budget.maxIterations } : {},
6604
6788
  ...opts.tools !== undefined ? { allowedTools: opts.tools } : {},
@@ -6669,7 +6853,21 @@ function clampPlanEntries(raw) {
6669
6853
  var TABLE_MAX_COLUMNS = 12;
6670
6854
  var TABLE_MAX_ROWS = 100;
6671
6855
  var TABLE_CELL_MAX_CHARS = 200;
6672
- var IMAGE_PATH_MAX_CHARS = 512;
6856
+ var DRIVE_PATH_MAX_CHARS = 512;
6857
+ function isPlausibleDrivePath(raw) {
6858
+ if (raw.trim().length === 0 || raw.length > DRIVE_PATH_MAX_CHARS)
6859
+ return false;
6860
+ if (raw.startsWith("-"))
6861
+ return false;
6862
+ if (/[\u0000-\u001f\u007f\\]/.test(raw))
6863
+ return false;
6864
+ if (/[|<>;`]|\$\(/.test(raw))
6865
+ return false;
6866
+ const trimmed = raw.replace(/^\/+|\/+$/g, "");
6867
+ if (trimmed.length === 0)
6868
+ return false;
6869
+ return trimmed.split("/").every((seg) => seg !== "" && seg !== "." && seg !== "..");
6870
+ }
6673
6871
  function clampCellString(s) {
6674
6872
  return s.length > TABLE_CELL_MAX_CHARS ? `${s.slice(0, TABLE_CELL_MAX_CHARS - 1)}…` : s;
6675
6873
  }
@@ -6860,7 +7058,7 @@ function parseDisplayMarker(line) {
6860
7058
  }
6861
7059
  case "document": {
6862
7060
  const path = str("path");
6863
- if (!path)
7061
+ if (!path || !isPlausibleDrivePath(path))
6864
7062
  return null;
6865
7063
  return {
6866
7064
  kind: "document",
@@ -6875,7 +7073,7 @@ function parseDisplayMarker(line) {
6875
7073
  }
6876
7074
  case "image": {
6877
7075
  const path = str("path");
6878
- if (!path || path.length > IMAGE_PATH_MAX_CHARS)
7076
+ if (!path || !isPlausibleDrivePath(path))
6879
7077
  return null;
6880
7078
  return {
6881
7079
  kind: "image",
@@ -7014,6 +7212,8 @@ function detectAgentcInvocation(command) {
7014
7212
  const w = words[i];
7015
7213
  if (SHELL_STOPPERS.has(w))
7016
7214
  break;
7215
+ if (/^\d*>&\d+$/.test(w))
7216
+ continue;
7017
7217
  if (w.startsWith("--")) {
7018
7218
  if (VALUE_FLAGS.has(w) && i + 1 < words.length && !SHELL_STOPPERS.has(words[i + 1])) {
7019
7219
  flags.set(w, words[i + 1]);
@@ -7026,6 +7226,7 @@ function detectAgentcInvocation(command) {
7026
7226
  const factorySlug = flags.get("--factory");
7027
7227
  const withSlug = factorySlug ? { factorySlug } : {};
7028
7228
  const uuid = (v) => v && UUID_RE.test(v) ? v : null;
7229
+ const drivePath = (v) => v && isPlausibleDrivePath(v) ? v : null;
7029
7230
  if (args[0] === "display") {
7030
7231
  switch (args[1]) {
7031
7232
  case "run": {
@@ -7036,19 +7237,27 @@ function detectAgentcInvocation(command) {
7036
7237
  const runId = uuid(args[2]);
7037
7238
  return runId ? { verb: "display-changes", runId, ...withSlug } : null;
7038
7239
  }
7039
- case "document":
7040
- return args[2] ? { verb: "display-document", path: args[2], ...withSlug } : null;
7240
+ case "document": {
7241
+ const path = drivePath(args[2]);
7242
+ return path ? { verb: "display-document", path, ...withSlug } : null;
7243
+ }
7041
7244
  case "plan":
7042
7245
  return { verb: "display-plan" };
7043
- case "image":
7044
- return args[2] ? { verb: "display-image", path: args[2], ...withSlug } : null;
7045
- case "preview":
7046
- return args[2] ? { verb: "display-preview", path: args[2] } : null;
7246
+ case "image": {
7247
+ const path = drivePath(args[2]);
7248
+ return path ? { verb: "display-image", path, ...withSlug } : null;
7249
+ }
7250
+ case "preview": {
7251
+ const path = drivePath(args[2]);
7252
+ return path ? { verb: "display-preview", path } : null;
7253
+ }
7047
7254
  case "table": {
7048
7255
  const file = flags.get("--file");
7049
7256
  const hasData = flags.has("--data");
7050
- if (file && !hasData)
7051
- return { verb: "display-table", source: "file", path: file };
7257
+ if (file && !hasData) {
7258
+ const path = drivePath(file);
7259
+ return path ? { verb: "display-table", source: "file", path } : null;
7260
+ }
7052
7261
  if (hasData && !file)
7053
7262
  return { verb: "display-table", source: "inline" };
7054
7263
  return null;
@@ -7060,11 +7269,12 @@ function detectAgentcInvocation(command) {
7060
7269
  case "diff": {
7061
7270
  const from = flags.get("--from");
7062
7271
  const to = flags.get("--to");
7063
- if (!args[2] || !from || !to)
7272
+ const path = drivePath(args[2]);
7273
+ if (!path || !from || !to)
7064
7274
  return null;
7065
7275
  if (!REVISION_SELECTOR_RE.test(from) || !REVISION_SELECTOR_RE.test(to))
7066
7276
  return null;
7067
- return { verb: "display-diff", path: args[2], from, to };
7277
+ return { verb: "display-diff", path, from, to };
7068
7278
  }
7069
7279
  case "ask": {
7070
7280
  const prompt = flags.get("--prompt");
@@ -7095,8 +7305,9 @@ function detectAgentcInvocation(command) {
7095
7305
  const runId = uuid(args[2]);
7096
7306
  return runId ? { verb: "run-get", runId } : null;
7097
7307
  }
7098
- if (args[0] === "files" && args[1] === "read" && args[2]) {
7099
- return { verb: "files-read", path: args[2], ...withSlug };
7308
+ if (args[0] === "files" && args[1] === "read") {
7309
+ const path = drivePath(args[2]);
7310
+ return path ? { verb: "files-read", path, ...withSlug } : null;
7100
7311
  }
7101
7312
  return null;
7102
7313
  }
@@ -7339,6 +7550,7 @@ export {
7339
7550
  runWorkflowSingleStep,
7340
7551
  runWorkflow,
7341
7552
  runProcessorChain,
7553
+ resolveSdkAlias,
7342
7554
  requireScope,
7343
7555
  requestPauseAndAwait,
7344
7556
  requestContextPath,
@@ -7367,6 +7579,7 @@ export {
7367
7579
  killSandboxById,
7368
7580
  killAllSandboxes,
7369
7581
  isWorkflow,
7582
+ isPlausibleDrivePath,
7370
7583
  isPlatformE2bTemplateAlias,
7371
7584
  isE2bSupportedSize,
7372
7585
  invokeStep,
@@ -7375,6 +7588,7 @@ export {
7375
7588
  getSandboxQuotas,
7376
7589
  formatError,
7377
7590
  findDisplayMarker,
7591
+ explainBundleFailure,
7378
7592
  editTool,
7379
7593
  e2bMachineSpec,
7380
7594
  e2bDevboxTemplateRef,
@@ -7441,6 +7655,8 @@ export {
7441
7655
  STEP_RESULT_PREFIX,
7442
7656
  STEP_PAUSE_PREFIX,
7443
7657
  STEP_ENV,
7658
+ SDK_SPECIFIER_ALIASES,
7659
+ SDK_PACKAGE,
7444
7660
  SANDBOX_VCPUS,
7445
7661
  SANDBOX_UNAVAILABLE_PREFIX,
7446
7662
  ReservedKeyError,
@@ -7462,6 +7678,7 @@ export {
7462
7678
  E2B_DEVBOX_TEMPLATE,
7463
7679
  E2B_DEVBOX_SPEC,
7464
7680
  E2B_DEVBOX_RECIPE_VERSION,
7681
+ DRIVE_PATH_MAX_CHARS,
7465
7682
  DISPLAY_MARKER_VERSION,
7466
7683
  DISPLAY_MARKER_KEY,
7467
7684
  DIRECTIVE_MARKER_SUFFIX,
@@ -7469,7 +7686,7 @@ export {
7469
7686
  DEFAULT_SANDBOX_SIZE,
7470
7687
  DEFAULT_CLAUDE_MODEL,
7471
7688
  ClaudeRunner,
7472
- CLAUDE_CODE_THINKING_TOKENS,
7689
+ CLAUDE_CODE_EFFORT_LEVELS,
7473
7690
  CLAUDE_CODE_ACP_ADAPTER,
7474
7691
  CHART_MAX_SERIES,
7475
7692
  CHART_MAX_POINTS_PER_SERIES,
@@ -69,13 +69,15 @@ export declare const ACP_TURN_IDLE_TIMEOUT_MS: number;
69
69
  * implements duplex) falls back to JSONL cleanly via the capability check in
70
70
  * `sendMessage`. */
71
71
  export declare const ACP_TRANSPORT_READY = true;
72
- /** Reasoning-effort level a CLI turn may carry (T2 session effort). The
73
- * per-CLI mapping lives in each spec's `buildCommand` — Claude Code takes a
74
- * thinking-token budget via `MAX_THINKING_TOKENS`, codex takes
75
- * `-c model_reasoning_effort=<level>`. Specs without a real knob
76
- * (opencode/droid/cursor) never receive one: the server hides + rejects
77
- * effort for those runtimes. */
78
- export type CliReasoningEffort = "low" | "medium" | "high";
72
+ /** Reasoning-effort level a CLI turn may carry (T2 session effort) — the
73
+ * UNION of what the effort-capable CLIs accept. The per-CLI mapping lives in
74
+ * each spec's `buildCommand` — Claude Code takes its own `--effort` flag
75
+ * (all five levels), codex takes `-c model_reasoning_effort=<level>`
76
+ * (low|medium|high|xhigh — no "max"; the spec clamps it). Specs without a
77
+ * real knob (opencode/droid/cursor) never receive one: the server hides +
78
+ * rejects effort for those runtimes, and rejects levels a runtime lacks
79
+ * (sessionEffortLockError). */
80
+ export type CliReasoningEffort = "low" | "medium" | "high" | "xhigh" | "max";
79
81
  /** Per-CLI behaviour. The base owns the lifecycle (init/done/error) and the
80
82
  * transport (spawn + JSONL parse); a spec owns the CLI-specific bits. */
81
83
  export interface CliAgentSpec {
@@ -40,18 +40,20 @@ import { type CliAgentSpec, type CliReasoningEffort } from "./_cli-agent.js";
40
40
  * bridge daemon (cli/src/bridge/acp.ts) imports this same pin so both
41
41
  * executors launch the identical adapter. Verified against 0.16.2. */
42
42
  export declare const CLAUDE_CODE_ACP_ADAPTER = "@zed-industries/claude-code-acp@0.16.2";
43
- /** Extended-thinking token budget per effort level — Claude Code's real knob
44
- * is the `MAX_THINKING_TOKENS` env var (its documented settings env), set
45
- * per invocation below. Values mirror the platform turn loop's
46
- * `EFFORT_BUDGET_TOKENS` (server model-client) so "high" means the same
47
- * thing in a channel and in a claude-code session. */
48
- export declare const CLAUDE_CODE_THINKING_TOKENS: Record<CliReasoningEffort, number>;
43
+ /** Claude Code's real reasoning knob is its own `--effort <level>` flag
44
+ * (low|medium|high|xhigh|max — verified against `claude -p --help`). The
45
+ * CliReasoningEffort union IS the CLI's vocabulary, so the level rides the
46
+ * flag verbatim; the CLI itself downgrades a level the selected model lacks
47
+ * (its documented behaviour, e.g. xhigh → high off Opus). The old
48
+ * `MAX_THINKING_TOKENS` env mapping is gone: the CLI deprecated it (treated
49
+ * as on/off on current models) and it could never express xhigh/max. */
50
+ export declare const CLAUDE_CODE_EFFORT_LEVELS: readonly CliReasoningEffort[];
49
51
  export declare const claudeCodeSpec: CliAgentSpec;
50
52
  export interface ClaudeCodeRuntimeConfig {
51
53
  /** Claude model id (`--model`). Omit to use the CLI's configured default. */
52
54
  model?: string;
53
- /** Extended-thinking effort (`MAX_THINKING_TOKENS`). Omit for the CLI's
54
- * default behaviour (no forced budget). */
55
+ /** Reasoning effort (`--effort <level>`; the CLI accepts all five levels).
56
+ * Omit for the CLI's default behaviour. */
55
57
  effort?: CliReasoningEffort;
56
58
  }
57
59
  export declare function createClaudeCodeRuntime(config?: ClaudeCodeRuntimeConfig): import("../index.js").AgentRuntime<import("../sandbox.js").SandboxProvider>;
@@ -20,12 +20,15 @@ export declare function isCodexAdvisoryNoise(text: string): boolean;
20
20
  * `mapEvent` is the golden the ACP normaliser is asserted equal to. Not part
21
21
  * of the public runtime surface — `createCodexRuntime` stays the entry point. */
22
22
  export declare const codexSpec: CliAgentSpec;
23
+ /** The effort levels codex actually has (`model_reasoning_effort`):
24
+ * low|medium|high|xhigh — no "max" (that level is Claude Code's alone). */
25
+ export type CodexReasoningEffort = Exclude<CliReasoningEffort, "max">;
23
26
  export interface CodexRuntimeConfig {
24
27
  /** Codex model id (`-m`). Omit to use the codex CLI's configured default. */
25
28
  model?: string;
26
29
  /** Reasoning effort (`-c model_reasoning_effort=<level>`). Omit to use the
27
30
  * codex CLI's configured default. */
28
- effort?: CliReasoningEffort;
31
+ effort?: CodexReasoningEffort;
29
32
  }
30
33
  export declare function createCodexRuntime(config?: CodexRuntimeConfig): import("../index.js").AgentRuntime<import("../sandbox.js").SandboxProvider>;
31
34
  declare const _default: import("../index.js").AgentRuntime<import("../sandbox.js").SandboxProvider>;