agentbox-sdk 0.1.308 → 0.1.310

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.
@@ -258,6 +258,14 @@ declare class Sandbox<P extends SandboxProviderName = SandboxProviderName> {
258
258
  * cached internally).
259
259
  */
260
260
  findOrProvision(): Promise<this>;
261
+ /**
262
+ * Attach to an existing sandbox by id, skipping the
263
+ * `findMatchingSandbox` lookup. Useful when the caller just created the
264
+ * sandbox (e.g. via a provider-native fork API) and knows its id.
265
+ * Repeated calls are cheap. Currently only the Daytona adapter
266
+ * implements this; other providers throw.
267
+ */
268
+ attachById(id: string): Promise<this>;
261
269
  openPort(port: number): Promise<this>;
262
270
  setSecret(name: string, value: string): this;
263
271
  setSecrets(values: Record<string, string>): this;
@@ -1,6 +1,6 @@
1
- import { o as AgentProviderName, h as AgentOptions, t as AgentRunConfig, s as AgentRun, r as AgentResult, a2 as RawAgentEvent, b as AgentAttachRequest, y as AttachedRun } from '../types-CZdyLzA4.js';
2
- export { a as AgentApprovalMode, c as AgentCommandConfig, d as AgentCostData, e as AgentExecutionRequest, f as AgentLocalMcpConfig, g as AgentMcpConfig, i as AgentOptionsBase, j as AgentOptionsMap, k as AgentPermissionDecision, l as AgentPermissionKind, m as AgentPermissionResponse, n as AgentProviderAdapter, p as AgentReasoningEffort, q as AgentRemoteMcpConfig, u as AgentRunSink, v as AgentSetupRequest, w as AgentSkillConfig, x as AgentSubAgentConfig, C as ClaudeCodeAgentOptions, z as ClaudeCodeHookConfig, B as ClaudeCodeHookEvent, D as ClaudeCodeHookHandler, E as ClaudeCodeHookMatcherGroup, F as ClaudeCodeHooksConfig, G as ClaudeCodeProviderOptions, H as CodexAgentOptions, I as CodexCommandHook, J as CodexHookEvent, K as CodexHookMatcherGroup, L as CodexHooksConfig, M as CodexProviderOptions, N as DataContent, O as EmbeddedSkillConfig, P as FilePart, Q as ImagePart, X as OpenCodeAgentOptions, Y as OpenCodePluginConfig, Z as OpenCodePluginEvent, _ as OpenCodePluginHookConfig, $ as OpenCodeProviderOptions, a4 as RepoSkillConfig, aa as TextPart, ae as UserContent, af as UserContentPart } from '../types-CZdyLzA4.js';
3
- import { S as Sandbox } from '../Sandbox-K6VNqKeo.js';
1
+ import { o as AgentProviderName, h as AgentOptions, t as AgentRunConfig, s as AgentRun, r as AgentResult, a2 as RawAgentEvent, b as AgentAttachRequest, y as AttachedRun, a9 as SetupLayout } from '../types-du-Kkn53.js';
2
+ export { a as AgentApprovalMode, c as AgentCommandConfig, d as AgentCostData, e as AgentExecutionRequest, f as AgentLocalMcpConfig, g as AgentMcpConfig, i as AgentOptionsBase, j as AgentOptionsMap, k as AgentPermissionDecision, l as AgentPermissionKind, m as AgentPermissionResponse, n as AgentProviderAdapter, p as AgentReasoningEffort, q as AgentRemoteMcpConfig, u as AgentRunSink, v as AgentSetupRequest, w as AgentSkillConfig, x as AgentSubAgentConfig, C as ClaudeCodeAgentOptions, z as ClaudeCodeHookConfig, B as ClaudeCodeHookEvent, D as ClaudeCodeHookHandler, E as ClaudeCodeHookMatcherGroup, F as ClaudeCodeHooksConfig, G as ClaudeCodeProviderOptions, H as CodexAgentOptions, I as CodexCommandHook, J as CodexHookEvent, K as CodexHookMatcherGroup, L as CodexHooksConfig, M as CodexProviderOptions, N as DataContent, O as EmbeddedSkillConfig, P as FilePart, Q as ImagePart, X as OpenCodeAgentOptions, Y as OpenCodePluginConfig, Z as OpenCodePluginEvent, _ as OpenCodePluginHookConfig, $ as OpenCodeProviderOptions, a4 as RepoSkillConfig, ab as TextPart, af as UserContent, ag as UserContentPart } from '../types-du-Kkn53.js';
3
+ import { S as Sandbox } from '../Sandbox-DcKAU-E3.js';
4
4
  export { AgentProvider } from '../enums.js';
5
5
  import 'e2b';
6
6
  import '@vercel/sandbox';
@@ -67,6 +67,28 @@ declare class Agent<P extends AgentProviderName = AgentProviderName> {
67
67
  static attach<P extends AgentProviderName>(request: AgentAttachRequest<P>): Promise<AttachedRun>;
68
68
  }
69
69
 
70
+ /**
71
+ * The on-disk root for every artifact agentbox writes for a given
72
+ * provider. Deterministic — same inputs, same path — so `setup()` and
73
+ * `execute()` agree on file locations without any data channel between
74
+ * them.
75
+ *
76
+ * - **Sandbox**: `/tmp/agentbox/<provider>` inside the sandbox.
77
+ * - **Local host**: `<os.tmpdir()>/agentbox-<provider>` on the host.
78
+ */
79
+ declare function agentboxRoot(provider: AgentProviderName, hasSandbox?: boolean): string;
80
+ /**
81
+ * Resolve the on-disk layout (config dirs per provider) for the given
82
+ * agentbox root. Public so external consumers (e.g. agentbox-driven
83
+ * orchestrators) can locate where each CLI writes its files without
84
+ * having to hardcode the layout shape.
85
+ *
86
+ * Pair with {@link agentboxRoot} to get the root for `(provider,
87
+ * hasSandbox)` first, then call this to expand it into the per-provider
88
+ * dirs (`claudeDir`, `codexDir`, `opencodeDir`, …).
89
+ */
90
+ declare function getAgentLayout(rootDir: string): SetupLayout;
91
+
70
92
  /**
71
93
  * Ports each agent harness needs exposed on its sandbox in order to reach
72
94
  * its app-server (or equivalent local server). These are used to:
@@ -85,4 +107,4 @@ declare class Agent<P extends AgentProviderName = AgentProviderName> {
85
107
  declare const AGENT_RESERVED_PORTS: Record<AgentProviderName, readonly number[]>;
86
108
  declare function collectAllAgentReservedPorts(): number[];
87
109
 
88
- export { AGENT_RESERVED_PORTS, Agent, AgentAttachRequest, AgentOptions, AgentProviderName, AgentResult, AgentRun, AgentRunConfig, AttachedRun, collectAllAgentReservedPorts };
110
+ export { AGENT_RESERVED_PORTS, Agent, AgentAttachRequest, AgentOptions, AgentProviderName, AgentResult, AgentRun, AgentRunConfig, AttachedRun, SetupLayout, agentboxRoot, collectAllAgentReservedPorts, getAgentLayout };
@@ -1,7 +1,9 @@
1
1
  import {
2
- Agent
3
- } from "../chunk-T3RBNOSE.js";
4
- import "../chunk-ZDSHOGJ4.js";
2
+ Agent,
3
+ agentboxRoot,
4
+ getAgentLayout
5
+ } from "../chunk-6MDOW3GK.js";
6
+ import "../chunk-PNONJAGY.js";
5
7
  import {
6
8
  AGENT_RESERVED_PORTS,
7
9
  collectAllAgentReservedPorts
@@ -14,5 +16,7 @@ export {
14
16
  AGENT_RESERVED_PORTS,
15
17
  Agent,
16
18
  AgentProvider,
17
- collectAllAgentReservedPorts
19
+ agentboxRoot,
20
+ collectAllAgentReservedPorts,
21
+ getAgentLayout
18
22
  };
@@ -2,7 +2,7 @@ import {
2
2
  createNormalizedEvent,
3
3
  normalizeRawAgentEvent,
4
4
  toAISDKStream
5
- } from "./chunk-ZDSHOGJ4.js";
5
+ } from "./chunk-PNONJAGY.js";
6
6
  import {
7
7
  AgentBoxError,
8
8
  AsyncQueue,
@@ -893,10 +893,10 @@ function shortLabel(command) {
893
893
  const oneLine = command.replace(/\s+/g, " ").trim();
894
894
  return oneLine.length > 60 ? `${oneLine.slice(0, 60)}\u2026` : oneLine;
895
895
  }
896
- function agentboxRoot(provider, hasSandbox) {
896
+ function agentboxRoot(provider, hasSandbox = true) {
897
897
  return hasSandbox ? `/tmp/agentbox/${provider}` : path4.join(os.tmpdir(), `agentbox-${provider}`);
898
898
  }
899
- function buildLayout(rootDir) {
899
+ function getAgentLayout(rootDir) {
900
900
  const xdgConfigHome = path4.join(rootDir, ".config");
901
901
  return {
902
902
  rootDir,
@@ -1108,7 +1108,7 @@ ${output}` : "";
1108
1108
  async function createSetupTarget(provider, setupId, options) {
1109
1109
  return time(debugRuntime, `createSetupTarget ${provider}`, async () => {
1110
1110
  void setupId;
1111
- const layout = buildLayout(
1111
+ const layout = getAgentLayout(
1112
1112
  agentboxRoot(provider, Boolean(options.sandbox))
1113
1113
  );
1114
1114
  if (options.sandbox) {
@@ -1662,6 +1662,7 @@ function buildClaudeQueryOptions(params) {
1662
1662
  if (run.systemPrompt) {
1663
1663
  extraArgs["append-system-prompt"] = run.systemPrompt;
1664
1664
  }
1665
+ const includeHookEvents = provider?.includeHookEvents ?? false;
1665
1666
  return {
1666
1667
  cwd: params.cwd ?? params.request.options.cwd,
1667
1668
  env: params.env,
@@ -1669,7 +1670,9 @@ function buildClaudeQueryOptions(params) {
1669
1670
  settings: params.settingsPath,
1670
1671
  extraArgs,
1671
1672
  includePartialMessages: true,
1673
+ includeHookEvents,
1672
1674
  thinking: { type: "adaptive", display: "summarized" },
1675
+ ...provider?.additionalDirectories?.length ? { additionalDirectories: provider.additionalDirectories } : {},
1673
1676
  ...run.model ? { model: run.model } : {},
1674
1677
  ...run.reasoning ? { effort: run.reasoning } : {},
1675
1678
  ...provider?.permissionMode ? { permissionMode: provider.permissionMode } : {},
@@ -2355,12 +2358,33 @@ var ClaudeCodeAgentAdapter = class {
2355
2358
  rawPayloads.push(message);
2356
2359
  sink.emitRaw(toRawEvent(request.runId, message, message.type));
2357
2360
  if (message.type === "system") {
2358
- const sys = message;
2359
- if (sys.subtype === "init" && sys.session_id) {
2361
+ const sub = message.subtype;
2362
+ if (sub === "init") {
2363
+ const sys = message;
2364
+ if (sys.session_id) {
2365
+ debugClaude(
2366
+ "\u2605 session.init session_id=%s (%dms)",
2367
+ sys.session_id.slice(0, 8),
2368
+ Date.now() - executeStartedAt
2369
+ );
2370
+ }
2371
+ } else if (sub === "hook_started") {
2372
+ const h = message;
2360
2373
  debugClaude(
2361
- "\u2605 session.init session_id=%s (%dms)",
2362
- sys.session_id.slice(0, 8),
2363
- Date.now() - executeStartedAt
2374
+ "hook.started name=%s event=%s hook_id=%s",
2375
+ h.hook_name,
2376
+ h.hook_event,
2377
+ h.hook_id
2378
+ );
2379
+ } else if (sub === "hook_response") {
2380
+ const h = message;
2381
+ const stderr = h.stderr && h.stderr.length > 0 ? h.stderr.replace(/\s+$/, "") : void 0;
2382
+ debugClaude(
2383
+ "hook.response name=%s exit=%s outcome=%s%s",
2384
+ h.hook_name,
2385
+ h.exit_code,
2386
+ h.outcome,
2387
+ stderr ? ` stderr=${JSON.stringify(stderr).slice(0, 200)}` : ""
2364
2388
  );
2365
2389
  }
2366
2390
  continue;
@@ -3864,12 +3888,17 @@ function buildOpenCodeConfig(options, interactiveApproval) {
3864
3888
  ])
3865
3889
  );
3866
3890
  const googleBaseUrl = options.env?.GOOGLE_BASE_URL;
3891
+ const openRouterBaseUrl = options.env?.OPENROUTER_BASE_URL;
3867
3892
  return {
3868
3893
  $schema: "https://opencode.ai/config.json",
3869
3894
  ...mcpConfig ? { mcp: mcpConfig } : {},
3870
3895
  ...commandsConfig ? { command: commandsConfig } : {},
3871
3896
  provider: {
3872
- openrouter: { options: { baseURL: "https://openrouter.ai/api/v1" } },
3897
+ openrouter: {
3898
+ options: {
3899
+ baseURL: openRouterBaseUrl || "https://openrouter.ai/api/v1"
3900
+ }
3901
+ },
3873
3902
  ...googleBaseUrl ? { google: { options: { baseURL: googleBaseUrl } } } : {}
3874
3903
  },
3875
3904
  agent: {
@@ -5156,5 +5185,7 @@ var Agent = class {
5156
5185
  };
5157
5186
 
5158
5187
  export {
5188
+ agentboxRoot,
5189
+ getAgentLayout,
5159
5190
  Agent
5160
5191
  };
@@ -144,6 +144,44 @@ var SandboxAdapter = class {
144
144
  }
145
145
  await this.provisioning;
146
146
  }
147
+ /**
148
+ * Attach to an already-existing sandbox by id. Skips the
149
+ * `findMatchingSandbox` lookup that `findOrProvision` does — useful when
150
+ * the caller just created the sandbox (e.g. via a fork API) and knows
151
+ * its id directly. Idempotent: a second call is a no-op once attached.
152
+ *
153
+ * Default implementation throws — providers opt in by overriding
154
+ * `attachExisting`. Currently implemented by the Daytona adapter.
155
+ */
156
+ async attachById(id) {
157
+ if (this.provisioned) {
158
+ return;
159
+ }
160
+ if (!this.provisioning) {
161
+ this.provisioning = time(
162
+ debugSandbox,
163
+ `attachById [${this.provider}] ${id}`,
164
+ async () => {
165
+ await this.attachExisting(id);
166
+ this.provisioned = true;
167
+ }
168
+ ).finally(() => {
169
+ this.provisioning = void 0;
170
+ });
171
+ }
172
+ await this.provisioning;
173
+ }
174
+ /**
175
+ * Provider hook for `attachById`. Adopt the sandbox with the given id
176
+ * (e.g. fetch via the provider client, mark `isWarmFlag`, start if
177
+ * paused). Throw if the provider doesn't support direct attach.
178
+ */
179
+ async attachExisting(id) {
180
+ void id;
181
+ throw new Error(
182
+ `attachById is not supported by the ${this.provider} provider.`
183
+ );
184
+ }
147
185
  /**
148
186
  * Throw a consistent error when a method that needs a provisioned
149
187
  * sandbox is called before `findOrProvision()`. Provider adapters call
@@ -238,6 +276,19 @@ var DaytonaSandboxAdapter = class extends SandboxAdapter {
238
276
  get id() {
239
277
  return this.sandbox?.id;
240
278
  }
279
+ async attachExisting(id) {
280
+ const existing = await this.client.get(id);
281
+ if (!existing) {
282
+ throw new Error(`Daytona sandbox ${id} not found`);
283
+ }
284
+ this.sandbox = existing;
285
+ const state = existing.state ?? "unknown";
286
+ const isWarm = state === "started";
287
+ if (!isWarm) {
288
+ await existing.start();
289
+ }
290
+ this.isWarmFlag = isWarm;
291
+ }
241
292
  async provision() {
242
293
  const existing = await this.findMatchingSandbox();
243
294
  if (existing) {
@@ -284,9 +335,9 @@ var DaytonaSandboxAdapter = class extends SandboxAdapter {
284
335
  this.requireProvisioned();
285
336
  const sandbox = this.requireSandbox();
286
337
  const result = await sandbox.process.executeCommand(
287
- toShellCommand(command),
338
+ this.buildSessionCommand(command, options),
288
339
  options?.cwd ?? this.workingDir,
289
- this.getMergedEnv(options?.env),
340
+ void 0,
290
341
  options?.timeoutMs ? Math.ceil(options.timeoutMs / 1e3) : void 0
291
342
  );
292
343
  const output = result.result ?? "";
@@ -2120,6 +2171,17 @@ var Sandbox = class {
2120
2171
  );
2121
2172
  return this;
2122
2173
  }
2174
+ /**
2175
+ * Attach to an existing sandbox by id, skipping the
2176
+ * `findMatchingSandbox` lookup. Useful when the caller just created the
2177
+ * sandbox (e.g. via a provider-native fork API) and knows its id.
2178
+ * Repeated calls are cheap. Currently only the Daytona adapter
2179
+ * implements this; other providers throw.
2180
+ */
2181
+ async attachById(id) {
2182
+ await this.adapter.attachById(id);
2183
+ return this;
2184
+ }
2123
2185
  async openPort(port) {
2124
2186
  await time(
2125
2187
  debugSandbox,
@@ -291,6 +291,9 @@ var CodexLogAssembler = class {
291
291
  this.byItemId.set(itemId, next);
292
292
  return clone(next);
293
293
  }
294
+ getSnapshots() {
295
+ return Array.from(this.byItemId.values()).map(clone);
296
+ }
294
297
  };
295
298
  var OpenCodeLogAssembler = class {
296
299
  userMessageIds = /* @__PURE__ */ new Set();
@@ -376,12 +379,22 @@ var OpenCodeLogAssembler = class {
376
379
  this.byPartId.set(partId, next);
377
380
  return clone(next);
378
381
  }
382
+ getSnapshots() {
383
+ return Array.from(this.byPartId.values()).map(clone);
384
+ }
379
385
  };
380
386
  var ClaudeCodeLogAssembler = class {
381
387
  currentMessageId = null;
382
388
  textByMessageId = /* @__PURE__ */ new Map();
383
389
  thinkingByMessageId = /* @__PURE__ */ new Map();
384
390
  byMessageId = /* @__PURE__ */ new Map();
391
+ // Per-message tool_use / image / other non-text-non-thinking content blocks.
392
+ // Tracked persistently so any `upsertMessage` call (including those from a
393
+ // post-assistant `message_start` re-anchor) still renders them — otherwise
394
+ // a later stream_event for the same messageId would emit a snapshot without
395
+ // tool_use blocks, and the UI's dedup-by-messageId would wipe the running
396
+ // command from the trace.
397
+ extraBlocksByMessageId = /* @__PURE__ */ new Map();
385
398
  process(event) {
386
399
  if (!isRecord(event)) return [];
387
400
  const type = typeof event.type === "string" ? event.type : "";
@@ -429,7 +442,8 @@ var ClaudeCodeLogAssembler = class {
429
442
  if (final.thinking) {
430
443
  this.thinkingByMessageId.set(id, final.thinking);
431
444
  }
432
- const snapshot = this.upsertMessage(id, final.extraBlocks);
445
+ this.mergeExtraBlocks(id, final.extraBlocks);
446
+ const snapshot = this.upsertMessage(id);
433
447
  this.currentMessageId = null;
434
448
  return [snapshot];
435
449
  }
@@ -440,6 +454,7 @@ var ClaudeCodeLogAssembler = class {
440
454
  this.textByMessageId.clear();
441
455
  this.thinkingByMessageId.clear();
442
456
  this.byMessageId.clear();
457
+ this.extraBlocksByMessageId.clear();
443
458
  for (const snapshot of snapshots) {
444
459
  if (!isRecord(snapshot)) continue;
445
460
  if (snapshot.type !== "message.updated") continue;
@@ -450,25 +465,46 @@ var ClaudeCodeLogAssembler = class {
450
465
  const content = message && Array.isArray(message.content) ? message.content : [];
451
466
  let text = "";
452
467
  let thinking = "";
468
+ const extraBlocks = [];
453
469
  for (const block of content) {
454
470
  if (!isRecord(block)) continue;
455
471
  if (block.type === "text" && typeof block.text === "string") {
456
472
  text += block.text;
457
473
  } else if (block.type === "thinking" && typeof block.thinking === "string") {
458
474
  thinking += block.thinking;
475
+ } else {
476
+ extraBlocks.push(block);
459
477
  }
460
478
  }
461
479
  this.textByMessageId.set(messageId, text);
462
480
  this.thinkingByMessageId.set(messageId, thinking);
481
+ if (extraBlocks.length > 0) {
482
+ this.mergeExtraBlocks(messageId, extraBlocks);
483
+ }
484
+ }
485
+ }
486
+ mergeExtraBlocks(messageId, blocks) {
487
+ if (blocks.length === 0) return;
488
+ let map = this.extraBlocksByMessageId.get(messageId);
489
+ if (!map) {
490
+ map = /* @__PURE__ */ new Map();
491
+ this.extraBlocksByMessageId.set(messageId, map);
492
+ }
493
+ for (const block of blocks) {
494
+ const key = typeof block.id === "string" && block.id ? `id:${block.id}` : `idx:${map.size}`;
495
+ map.set(key, clone(block));
463
496
  }
464
497
  }
465
- upsertMessage(messageId, extraBlocks = []) {
498
+ upsertMessage(messageId) {
466
499
  const text = this.textByMessageId.get(messageId) ?? "";
467
500
  const thinking = this.thinkingByMessageId.get(messageId) ?? "";
468
501
  const content = [];
469
502
  if (thinking) content.push({ type: "thinking", thinking });
470
503
  if (text) content.push({ type: "text", text });
471
- for (const block of extraBlocks) content.push(clone(block));
504
+ const extras = this.extraBlocksByMessageId.get(messageId);
505
+ if (extras) {
506
+ for (const block of extras.values()) content.push(clone(block));
507
+ }
472
508
  const next = {
473
509
  type: "message.updated",
474
510
  messageId,
@@ -481,6 +517,9 @@ var ClaudeCodeLogAssembler = class {
481
517
  this.byMessageId.set(messageId, next);
482
518
  return clone(next);
483
519
  }
520
+ getSnapshots() {
521
+ return Array.from(this.byMessageId.values()).map(clone);
522
+ }
484
523
  };
485
524
  function extractClaudeAssistantContent(message) {
486
525
  const content = Array.isArray(message.content) ? message.content : [];
@@ -523,6 +562,29 @@ var ProviderLogAssembler = class {
523
562
  }
524
563
  return [];
525
564
  }
565
+ /**
566
+ * Return the current deduped snapshot set held by the active per-provider
567
+ * assembler. Equivalent to running `dedupeSnapshots` over the full sequence
568
+ * of snapshots emitted by `process()` since construction (or last seed), but
569
+ * read directly from in-memory state — no transport or persistence layer
570
+ * involved. Used end-of-run to persist the full trace without paying a
571
+ * Redis LRANGE + parse roundtrip.
572
+ *
573
+ * Snapshots are returned in first-seen order (Map insertion order). Entries
574
+ * are cloned, so the caller can serialize them freely.
575
+ */
576
+ getSnapshots(provider) {
577
+ if (provider === AgentProvider.Codex || provider === "codex") {
578
+ return this.codex.getSnapshots();
579
+ }
580
+ if (provider === AgentProvider.OpenCode || provider === "opencode") {
581
+ return this.openCode.getSnapshots();
582
+ }
583
+ if (provider === AgentProvider.ClaudeCode || provider === "claude-code") {
584
+ return this.claudeCode.getSnapshots();
585
+ }
586
+ return [];
587
+ }
526
588
  /**
527
589
  * Re-seed the assembler from a sequence of previously-assembled snapshots
528
590
  * so that subsequent `process()` calls produce snapshots consistent with
@@ -1,6 +1,6 @@
1
- export { A as AISDKEvent, R as MessageCompletedEvent, S as MessageInjectedEvent, T as MessageStartedEvent, U as NormalizedAgentEvent, V as NormalizedAgentEventBase, W as NormalizedAgentEventType, a0 as PermissionRequestedEvent, a1 as PermissionResolvedEvent, a2 as RawAgentEvent, a3 as ReasoningDeltaEvent, a5 as RunCancelledEvent, a6 as RunCompletedEvent, a7 as RunErrorEvent, a8 as RunStartedEvent, a9 as TextDeltaEvent, ab as ToolCallCompletedEvent, ac as ToolCallDeltaEvent, ad as ToolCallStartedEvent, ag as createNormalizedEvent, ah as normalizeRawAgentEvent, ai as toAISDKEvent, aj as toAISDKStream } from '../types-CZdyLzA4.js';
1
+ export { A as AISDKEvent, R as MessageCompletedEvent, S as MessageInjectedEvent, T as MessageStartedEvent, U as NormalizedAgentEvent, V as NormalizedAgentEventBase, W as NormalizedAgentEventType, a0 as PermissionRequestedEvent, a1 as PermissionResolvedEvent, a2 as RawAgentEvent, a3 as ReasoningDeltaEvent, a5 as RunCancelledEvent, a6 as RunCompletedEvent, a7 as RunErrorEvent, a8 as RunStartedEvent, aa as TextDeltaEvent, ac as ToolCallCompletedEvent, ad as ToolCallDeltaEvent, ae as ToolCallStartedEvent, ah as createNormalizedEvent, ai as normalizeRawAgentEvent, aj as toAISDKEvent, ak as toAISDKStream } from '../types-du-Kkn53.js';
2
2
  import { AgentProvider } from '../enums.js';
3
- import '../Sandbox-K6VNqKeo.js';
3
+ import '../Sandbox-DcKAU-E3.js';
4
4
  import 'e2b';
5
5
  import '@vercel/sandbox';
6
6
  import '@daytonaio/sdk';
@@ -69,6 +69,18 @@ declare class ProviderLogAssembler {
69
69
  * a delta with no payload) or already represented by a previous snapshot.
70
70
  */
71
71
  process(provider: AgentProvider | string | null | undefined, event: unknown): JsonRecord[];
72
+ /**
73
+ * Return the current deduped snapshot set held by the active per-provider
74
+ * assembler. Equivalent to running `dedupeSnapshots` over the full sequence
75
+ * of snapshots emitted by `process()` since construction (or last seed), but
76
+ * read directly from in-memory state — no transport or persistence layer
77
+ * involved. Used end-of-run to persist the full trace without paying a
78
+ * Redis LRANGE + parse roundtrip.
79
+ *
80
+ * Snapshots are returned in first-seen order (Map insertion order). Entries
81
+ * are cloned, so the caller can serialize them freely.
82
+ */
83
+ getSnapshots(provider: AgentProvider | string | null | undefined): JsonRecord[];
72
84
  /**
73
85
  * Re-seed the assembler from a sequence of previously-assembled snapshots
74
86
  * so that subsequent `process()` calls produce snapshots consistent with
@@ -4,7 +4,7 @@ import {
4
4
  normalizeRawAgentEvent,
5
5
  toAISDKEvent,
6
6
  toAISDKStream
7
- } from "../chunk-ZDSHOGJ4.js";
7
+ } from "../chunk-PNONJAGY.js";
8
8
  import "../chunk-GOFJNFAD.js";
9
9
  export {
10
10
  ProviderLogAssembler,
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- export { A as AISDKEvent, a as AgentApprovalMode, b as AgentAttachRequest, c as AgentCommandConfig, d as AgentCostData, e as AgentExecutionRequest, f as AgentLocalMcpConfig, g as AgentMcpConfig, h as AgentOptions, i as AgentOptionsBase, j as AgentOptionsMap, k as AgentPermissionDecision, l as AgentPermissionKind, m as AgentPermissionResponse, n as AgentProviderAdapter, o as AgentProviderName, p as AgentReasoningEffort, q as AgentRemoteMcpConfig, r as AgentResult, s as AgentRun, t as AgentRunConfig, u as AgentRunSink, v as AgentSetupRequest, w as AgentSkillConfig, x as AgentSubAgentConfig, y as AttachedRun, C as ClaudeCodeAgentOptions, z as ClaudeCodeHookConfig, B as ClaudeCodeHookEvent, D as ClaudeCodeHookHandler, E as ClaudeCodeHookMatcherGroup, F as ClaudeCodeHooksConfig, G as ClaudeCodeProviderOptions, H as CodexAgentOptions, I as CodexCommandHook, J as CodexHookEvent, K as CodexHookMatcherGroup, L as CodexHooksConfig, M as CodexProviderOptions, N as DataContent, O as EmbeddedSkillConfig, P as FilePart, Q as ImagePart, R as MessageCompletedEvent, S as MessageInjectedEvent, T as MessageStartedEvent, U as NormalizedAgentEvent, V as NormalizedAgentEventBase, W as NormalizedAgentEventType, X as OpenCodeAgentOptions, Y as OpenCodePluginConfig, Z as OpenCodePluginEvent, _ as OpenCodePluginHookConfig, $ as OpenCodeProviderOptions, a0 as PermissionRequestedEvent, a1 as PermissionResolvedEvent, a2 as RawAgentEvent, a3 as ReasoningDeltaEvent, a4 as RepoSkillConfig, a5 as RunCancelledEvent, a6 as RunCompletedEvent, a7 as RunErrorEvent, a8 as RunStartedEvent, a9 as TextDeltaEvent, aa as TextPart, ab as ToolCallCompletedEvent, ac as ToolCallDeltaEvent, ad as ToolCallStartedEvent, ae as UserContent, af as UserContentPart, ag as createNormalizedEvent, ah as normalizeRawAgentEvent, ai as toAISDKEvent, aj as toAISDKStream } from './types-CZdyLzA4.js';
2
- export { AGENT_RESERVED_PORTS, Agent, collectAllAgentReservedPorts } from './agents/index.js';
3
- export { A as AsyncCommandHandle, C as CommandEvent, a as CommandOptions, b as CommandResult, D as DaytonaProviderOptions, c as DaytonaSandboxOptions, E as E2bProviderOptions, d as E2bSandboxOptions, G as GitCloneOptions, L as LocalDockerProviderOptions, e as LocalDockerSandboxOptions, M as ModalProviderOptions, f as ModalSandboxOptions, S as Sandbox, g as SandboxDescriptor, h as SandboxListOptions, i as SandboxOptions, j as SandboxOptionsBase, k as SandboxOptionsMap, l as SandboxProviderName, m as SandboxRaw, n as SandboxRawMap, o as SandboxResourceSpec, T as TarballEntry, V as VercelGitSource, p as VercelProviderOptions, q as VercelSandboxOptions } from './Sandbox-K6VNqKeo.js';
1
+ export { A as AISDKEvent, a as AgentApprovalMode, b as AgentAttachRequest, c as AgentCommandConfig, d as AgentCostData, e as AgentExecutionRequest, f as AgentLocalMcpConfig, g as AgentMcpConfig, h as AgentOptions, i as AgentOptionsBase, j as AgentOptionsMap, k as AgentPermissionDecision, l as AgentPermissionKind, m as AgentPermissionResponse, n as AgentProviderAdapter, o as AgentProviderName, p as AgentReasoningEffort, q as AgentRemoteMcpConfig, r as AgentResult, s as AgentRun, t as AgentRunConfig, u as AgentRunSink, v as AgentSetupRequest, w as AgentSkillConfig, x as AgentSubAgentConfig, y as AttachedRun, C as ClaudeCodeAgentOptions, z as ClaudeCodeHookConfig, B as ClaudeCodeHookEvent, D as ClaudeCodeHookHandler, E as ClaudeCodeHookMatcherGroup, F as ClaudeCodeHooksConfig, G as ClaudeCodeProviderOptions, H as CodexAgentOptions, I as CodexCommandHook, J as CodexHookEvent, K as CodexHookMatcherGroup, L as CodexHooksConfig, M as CodexProviderOptions, N as DataContent, O as EmbeddedSkillConfig, P as FilePart, Q as ImagePart, R as MessageCompletedEvent, S as MessageInjectedEvent, T as MessageStartedEvent, U as NormalizedAgentEvent, V as NormalizedAgentEventBase, W as NormalizedAgentEventType, X as OpenCodeAgentOptions, Y as OpenCodePluginConfig, Z as OpenCodePluginEvent, _ as OpenCodePluginHookConfig, $ as OpenCodeProviderOptions, a0 as PermissionRequestedEvent, a1 as PermissionResolvedEvent, a2 as RawAgentEvent, a3 as ReasoningDeltaEvent, a4 as RepoSkillConfig, a5 as RunCancelledEvent, a6 as RunCompletedEvent, a7 as RunErrorEvent, a8 as RunStartedEvent, a9 as SetupLayout, aa as TextDeltaEvent, ab as TextPart, ac as ToolCallCompletedEvent, ad as ToolCallDeltaEvent, ae as ToolCallStartedEvent, af as UserContent, ag as UserContentPart, ah as createNormalizedEvent, ai as normalizeRawAgentEvent, aj as toAISDKEvent, ak as toAISDKStream } from './types-du-Kkn53.js';
2
+ export { AGENT_RESERVED_PORTS, Agent, agentboxRoot, collectAllAgentReservedPorts, getAgentLayout } from './agents/index.js';
3
+ export { A as AsyncCommandHandle, C as CommandEvent, a as CommandOptions, b as CommandResult, D as DaytonaProviderOptions, c as DaytonaSandboxOptions, E as E2bProviderOptions, d as E2bSandboxOptions, G as GitCloneOptions, L as LocalDockerProviderOptions, e as LocalDockerSandboxOptions, M as ModalProviderOptions, f as ModalSandboxOptions, S as Sandbox, g as SandboxDescriptor, h as SandboxListOptions, i as SandboxOptions, j as SandboxOptionsBase, k as SandboxOptionsMap, l as SandboxProviderName, m as SandboxRaw, n as SandboxRawMap, o as SandboxResourceSpec, T as TarballEntry, V as VercelGitSource, p as VercelProviderOptions, q as VercelSandboxOptions } from './Sandbox-DcKAU-E3.js';
4
4
  export { SandboxAdapter, buildGitCloneCommand } from './sandboxes/index.js';
5
5
  export { ProviderLogAssembler } from './events/index.js';
6
6
  export { AgentProvider, SandboxProvider } from './enums.js';
package/dist/index.js CHANGED
@@ -1,18 +1,20 @@
1
1
  import {
2
- Agent
3
- } from "./chunk-T3RBNOSE.js";
2
+ Agent,
3
+ agentboxRoot,
4
+ getAgentLayout
5
+ } from "./chunk-6MDOW3GK.js";
4
6
  import {
5
7
  ProviderLogAssembler,
6
8
  createNormalizedEvent,
7
9
  normalizeRawAgentEvent,
8
10
  toAISDKEvent,
9
11
  toAISDKStream
10
- } from "./chunk-ZDSHOGJ4.js";
12
+ } from "./chunk-PNONJAGY.js";
11
13
  import {
12
14
  Sandbox,
13
15
  SandboxAdapter,
14
16
  buildGitCloneCommand
15
- } from "./chunk-QNNAAVJV.js";
17
+ } from "./chunk-HYHLKO3L.js";
16
18
  import {
17
19
  AGENT_RESERVED_PORTS,
18
20
  collectAllAgentReservedPorts
@@ -30,9 +32,11 @@ export {
30
32
  Sandbox,
31
33
  SandboxAdapter,
32
34
  SandboxProvider,
35
+ agentboxRoot,
33
36
  buildGitCloneCommand,
34
37
  collectAllAgentReservedPorts,
35
38
  createNormalizedEvent,
39
+ getAgentLayout,
36
40
  normalizeRawAgentEvent,
37
41
  toAISDKEvent,
38
42
  toAISDKStream
@@ -1,5 +1,5 @@
1
- import { l as SandboxProviderName, i as SandboxOptions, a as CommandOptions, b as CommandResult, A as AsyncCommandHandle, h as SandboxListOptions, g as SandboxDescriptor, T as TarballEntry, G as GitCloneOptions } from '../Sandbox-K6VNqKeo.js';
2
- export { C as CommandEvent, D as DaytonaProviderOptions, c as DaytonaSandboxOptions, E as E2bProviderOptions, d as E2bSandboxOptions, L as LocalDockerProviderOptions, e as LocalDockerSandboxOptions, M as ModalProviderOptions, f as ModalSandboxOptions, S as Sandbox, j as SandboxOptionsBase, k as SandboxOptionsMap, m as SandboxRaw, n as SandboxRawMap, o as SandboxResourceSpec, V as VercelGitSource, p as VercelProviderOptions, q as VercelSandboxOptions } from '../Sandbox-K6VNqKeo.js';
1
+ import { l as SandboxProviderName, i as SandboxOptions, a as CommandOptions, b as CommandResult, A as AsyncCommandHandle, h as SandboxListOptions, g as SandboxDescriptor, T as TarballEntry, G as GitCloneOptions } from '../Sandbox-DcKAU-E3.js';
2
+ export { C as CommandEvent, D as DaytonaProviderOptions, c as DaytonaSandboxOptions, E as E2bProviderOptions, d as E2bSandboxOptions, L as LocalDockerProviderOptions, e as LocalDockerSandboxOptions, M as ModalProviderOptions, f as ModalSandboxOptions, S as Sandbox, j as SandboxOptionsBase, k as SandboxOptionsMap, m as SandboxRaw, n as SandboxRawMap, o as SandboxResourceSpec, V as VercelGitSource, p as VercelProviderOptions, q as VercelSandboxOptions } from '../Sandbox-DcKAU-E3.js';
3
3
  export { SandboxProvider } from '../enums.js';
4
4
  import 'e2b';
5
5
  import '@vercel/sandbox';
@@ -60,6 +60,22 @@ declare abstract class SandboxAdapter<TProvider extends SandboxProviderName = Sa
60
60
  * (potentially slow) sandbox attach / create happens.
61
61
  */
62
62
  findOrProvision(): Promise<void>;
63
+ /**
64
+ * Attach to an already-existing sandbox by id. Skips the
65
+ * `findMatchingSandbox` lookup that `findOrProvision` does — useful when
66
+ * the caller just created the sandbox (e.g. via a fork API) and knows
67
+ * its id directly. Idempotent: a second call is a no-op once attached.
68
+ *
69
+ * Default implementation throws — providers opt in by overriding
70
+ * `attachExisting`. Currently implemented by the Daytona adapter.
71
+ */
72
+ attachById(id: string): Promise<void>;
73
+ /**
74
+ * Provider hook for `attachById`. Adopt the sandbox with the given id
75
+ * (e.g. fetch via the provider client, mark `isWarmFlag`, start if
76
+ * paused). Throw if the provider doesn't support direct attach.
77
+ */
78
+ protected attachExisting(id: string): Promise<void>;
63
79
  /**
64
80
  * Throw a consistent error when a method that needs a provisioned
65
81
  * sandbox is called before `findOrProvision()`. Provider adapters call
@@ -2,7 +2,7 @@ import {
2
2
  Sandbox,
3
3
  SandboxAdapter,
4
4
  buildGitCloneCommand
5
- } from "../chunk-QNNAAVJV.js";
5
+ } from "../chunk-HYHLKO3L.js";
6
6
  import "../chunk-AVXJMCBC.js";
7
7
  import "../chunk-NSJM57Z4.js";
8
8
  import {
@@ -1,5 +1,5 @@
1
1
  import { AgentProvider } from './enums.js';
2
- import { S as Sandbox } from './Sandbox-K6VNqKeo.js';
2
+ import { S as Sandbox } from './Sandbox-DcKAU-E3.js';
3
3
 
4
4
  interface RawAgentEvent<TPayload = unknown> {
5
5
  provider: string;
@@ -284,6 +284,15 @@ interface AgentCommandConfig {
284
284
  model?: string;
285
285
  subtask?: boolean;
286
286
  }
287
+ interface SetupLayout {
288
+ rootDir: string;
289
+ homeDir: string;
290
+ xdgConfigHome: string;
291
+ agentsDir: string;
292
+ claudeDir: string;
293
+ opencodeDir: string;
294
+ codexDir: string;
295
+ }
287
296
 
288
297
  type AgentProviderName = AgentProvider;
289
298
  type DataContent = string | URL | Uint8Array | ArrayBuffer | Buffer;
@@ -392,6 +401,23 @@ interface ClaudeCodeProviderOptions {
392
401
  allowedTools?: string[];
393
402
  autoApproveTools?: boolean;
394
403
  verbose?: boolean;
404
+ /**
405
+ * Extra directories Claude Code is allowed to read/write outside `cwd`.
406
+ * Passed through to `--add-dir` (one flag per entry). Use absolute paths.
407
+ *
408
+ * Common case: cwd points at a parent directory and tasks need access
409
+ * to sibling repos cloned under it. Listing each repo here surfaces it
410
+ * to the agent without changing the working directory.
411
+ */
412
+ additionalDirectories?: string[];
413
+ /**
414
+ * When `true` (the default), the in-sandbox CLI emits `hook_started` and
415
+ * `hook_response` system messages so the host can observe every hook
416
+ * fire — useful to confirm a project-defined hook actually ran and to
417
+ * surface its stdout/stderr/exit_code on failures. Set `false` to
418
+ * silence them when hook noise drowns out the rest of the event stream.
419
+ */
420
+ includeHookEvents?: boolean;
395
421
  }
396
422
  interface CodexAgentOptions extends AgentOptionsBase {
397
423
  provider?: CodexProviderOptions;
@@ -581,4 +607,4 @@ interface AgentProviderAdapter<P extends AgentProviderName = AgentProviderName>
581
607
  attachSendMessage(request: AgentAttachRequest<P>, content: UserContent): Promise<void>;
582
608
  }
583
609
 
584
- export { type OpenCodeProviderOptions as $, type AISDKEvent as A, type ClaudeCodeHookEvent as B, type ClaudeCodeAgentOptions as C, type ClaudeCodeHookHandler as D, type ClaudeCodeHookMatcherGroup as E, type ClaudeCodeHooksConfig as F, type ClaudeCodeProviderOptions as G, type CodexAgentOptions as H, type CodexCommandHook as I, type CodexHookEvent as J, type CodexHookMatcherGroup as K, type CodexHooksConfig as L, type CodexProviderOptions as M, type DataContent as N, type EmbeddedSkillConfig as O, type FilePart as P, type ImagePart as Q, type MessageCompletedEvent as R, type MessageInjectedEvent as S, type MessageStartedEvent as T, type NormalizedAgentEvent as U, type NormalizedAgentEventBase as V, type NormalizedAgentEventType as W, type OpenCodeAgentOptions as X, type OpenCodePluginConfig as Y, type OpenCodePluginEvent as Z, type OpenCodePluginHookConfig as _, type AgentApprovalMode as a, type PermissionRequestedEvent as a0, type PermissionResolvedEvent as a1, type RawAgentEvent as a2, type ReasoningDeltaEvent as a3, type RepoSkillConfig as a4, type RunCancelledEvent as a5, type RunCompletedEvent as a6, type RunErrorEvent as a7, type RunStartedEvent as a8, type TextDeltaEvent as a9, type TextPart as aa, type ToolCallCompletedEvent as ab, type ToolCallDeltaEvent as ac, type ToolCallStartedEvent as ad, type UserContent as ae, type UserContentPart as af, createNormalizedEvent as ag, normalizeRawAgentEvent as ah, toAISDKEvent as ai, toAISDKStream as aj, type AgentAttachRequest as b, type AgentCommandConfig as c, type AgentCostData as d, type AgentExecutionRequest as e, type AgentLocalMcpConfig as f, type AgentMcpConfig as g, type AgentOptions as h, type AgentOptionsBase as i, type AgentOptionsMap as j, type AgentPermissionDecision as k, type AgentPermissionKind as l, type AgentPermissionResponse as m, type AgentProviderAdapter as n, type AgentProviderName as o, type AgentReasoningEffort as p, type AgentRemoteMcpConfig as q, type AgentResult as r, type AgentRun as s, type AgentRunConfig as t, type AgentRunSink as u, type AgentSetupRequest as v, type AgentSkillConfig as w, type AgentSubAgentConfig as x, type AttachedRun as y, type ClaudeCodeHookConfig as z };
610
+ export { type OpenCodeProviderOptions as $, type AISDKEvent as A, type ClaudeCodeHookEvent as B, type ClaudeCodeAgentOptions as C, type ClaudeCodeHookHandler as D, type ClaudeCodeHookMatcherGroup as E, type ClaudeCodeHooksConfig as F, type ClaudeCodeProviderOptions as G, type CodexAgentOptions as H, type CodexCommandHook as I, type CodexHookEvent as J, type CodexHookMatcherGroup as K, type CodexHooksConfig as L, type CodexProviderOptions as M, type DataContent as N, type EmbeddedSkillConfig as O, type FilePart as P, type ImagePart as Q, type MessageCompletedEvent as R, type MessageInjectedEvent as S, type MessageStartedEvent as T, type NormalizedAgentEvent as U, type NormalizedAgentEventBase as V, type NormalizedAgentEventType as W, type OpenCodeAgentOptions as X, type OpenCodePluginConfig as Y, type OpenCodePluginEvent as Z, type OpenCodePluginHookConfig as _, type AgentApprovalMode as a, type PermissionRequestedEvent as a0, type PermissionResolvedEvent as a1, type RawAgentEvent as a2, type ReasoningDeltaEvent as a3, type RepoSkillConfig as a4, type RunCancelledEvent as a5, type RunCompletedEvent as a6, type RunErrorEvent as a7, type RunStartedEvent as a8, type SetupLayout as a9, type TextDeltaEvent as aa, type TextPart as ab, type ToolCallCompletedEvent as ac, type ToolCallDeltaEvent as ad, type ToolCallStartedEvent as ae, type UserContent as af, type UserContentPart as ag, createNormalizedEvent as ah, normalizeRawAgentEvent as ai, toAISDKEvent as aj, toAISDKStream as ak, type AgentAttachRequest as b, type AgentCommandConfig as c, type AgentCostData as d, type AgentExecutionRequest as e, type AgentLocalMcpConfig as f, type AgentMcpConfig as g, type AgentOptions as h, type AgentOptionsBase as i, type AgentOptionsMap as j, type AgentPermissionDecision as k, type AgentPermissionKind as l, type AgentPermissionResponse as m, type AgentProviderAdapter as n, type AgentProviderName as o, type AgentReasoningEffort as p, type AgentRemoteMcpConfig as q, type AgentResult as r, type AgentRun as s, type AgentRunConfig as t, type AgentRunSink as u, type AgentSetupRequest as v, type AgentSkillConfig as w, type AgentSubAgentConfig as x, type AttachedRun as y, type ClaudeCodeHookConfig as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentbox-sdk",
3
- "version": "0.1.308",
3
+ "version": "0.1.310",
4
4
  "description": "Swappable coding agents and sandbox providers for Bun and TypeScript.",
5
5
  "license": "MIT",
6
6
  "repository": {