agentbox-sdk 0.1.512 → 0.1.513

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 CHANGED
@@ -650,3 +650,13 @@ CLIs and SDK mocks; live tests remain opt-in.
650
650
  MIT
651
651
 
652
652
  For native speed selection, use `provider: { serviceTier: "fast" }` with Codex (or `"default"` for standard speed), and `provider: { fastMode: true }` with Claude Code. Omit these options to inherit harness settings. Availability and usage charges are enforced by the harness.
653
+
654
+ ### Preparing local Codex before a prompt
655
+
656
+ For an interactive host, `provider: { prewarm: true }` makes `await agent.setup()`
657
+ start and initialize the next Codex app-server. It does not create a thread, send
658
+ a prompt, or run tools. The next `stream()`/`run()` consumes that prepared process
659
+ and stops it normally when the run ends; abort still stops the owned process.
660
+ A prepared process that exited while idle is replaced before execution. Call
661
+ `await agent.killServer()` to dispose an unused prepared process. Prewarming is
662
+ host-only and opt-in. Use a new Agent for a changed cwd, environment, or policy.
@@ -1,5 +1,5 @@
1
- import { o as AgentProviderName, h as AgentOptions, t as AgentRunConfig, s as AgentRun, r as AgentResult, a9 as RawAgentEvent, b as AgentAttachRequest, B as AttachedRun, ag as SetupLayout, am as UserContent } from '../types-VT1LMbLW.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, y as AgentUserAnswer, z as AgentUserQuestion, E as ClaudeCodeAgentOptions, F as ClaudeCodeHookConfig, G as ClaudeCodeHookEvent, H as ClaudeCodeHookHandler, I as ClaudeCodeHookMatcherGroup, J as ClaudeCodeHooksConfig, K as ClaudeCodeProviderOptions, L as CodexAgentOptions, M as CodexCommandHook, N as CodexHookEvent, O as CodexHookMatcherGroup, P as CodexHooksConfig, Q as CodexModelProviderConfig, R as CodexProviderOptions, S as DataContent, T as EmbeddedSkillConfig, U as FilePart, V as ImagePart, a1 as OpenCodeAgentOptions, a2 as OpenCodePluginConfig, a3 as OpenCodePluginEvent, a4 as OpenCodePluginHookConfig, a5 as OpenCodeProviderOptions, a6 as OpenRouterPlugin, ab as RepoSkillConfig, ai as TextPart, an as UserContentPart } from '../types-VT1LMbLW.js';
1
+ import { o as AgentProviderName, h as AgentOptions, t as AgentRunConfig, s as AgentRun, r as AgentResult, a9 as RawAgentEvent, b as AgentAttachRequest, B as AttachedRun, ag as SetupLayout, am as UserContent } from '../types-NhKw_6mW.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, y as AgentUserAnswer, z as AgentUserQuestion, E as ClaudeCodeAgentOptions, F as ClaudeCodeHookConfig, G as ClaudeCodeHookEvent, H as ClaudeCodeHookHandler, I as ClaudeCodeHookMatcherGroup, J as ClaudeCodeHooksConfig, K as ClaudeCodeProviderOptions, L as CodexAgentOptions, M as CodexCommandHook, N as CodexHookEvent, O as CodexHookMatcherGroup, P as CodexHooksConfig, Q as CodexModelProviderConfig, R as CodexProviderOptions, S as DataContent, T as EmbeddedSkillConfig, U as FilePart, V as ImagePart, a1 as OpenCodeAgentOptions, a2 as OpenCodePluginConfig, a3 as OpenCodePluginEvent, a4 as OpenCodePluginHookConfig, a5 as OpenCodeProviderOptions, a6 as OpenRouterPlugin, ab as RepoSkillConfig, ai as TextPart, an as UserContentPart } from '../types-NhKw_6mW.js';
3
3
  import { S as Sandbox } from '../Sandbox-DcKAU-E3.js';
4
4
  export { AgentProvider } from '../enums.js';
5
5
  import 'e2b';
@@ -4,7 +4,7 @@ import {
4
4
  getAgentLayout,
5
5
  harnessCapabilities,
6
6
  resolveHarnessCommand
7
- } from "../chunk-4DADE7TF.js";
7
+ } from "../chunk-XJWZR2NR.js";
8
8
  import "../chunk-775FIGGL.js";
9
9
  import {
10
10
  AGENT_RESERVED_PORTS,
@@ -4425,6 +4425,7 @@ async function createRuntime(request, inputParts) {
4425
4425
  cleanup: async () => {
4426
4426
  await processHandle.kill();
4427
4427
  },
4428
+ isAlive: () => processHandle.child.exitCode === null && processHandle.child.signalCode === null && !processHandle.child.killed,
4428
4429
  raw: { processHandle, codexDir },
4429
4430
  inputItems
4430
4431
  };
@@ -4472,11 +4473,47 @@ async function killCodexAppServer(request) {
4472
4473
  { cwd: options.cwd, timeoutMs: 1e4 }
4473
4474
  ).catch(() => void 0);
4474
4475
  }
4476
+ async function initializeCodexClient(client) {
4477
+ await client.request("initialize", {
4478
+ clientInfo: { title: "AgentBox", name: "AgentBox", version: "0.1.0" },
4479
+ capabilities: { experimentalApi: true }
4480
+ });
4481
+ await client.notify("initialized", {});
4482
+ }
4475
4483
  var CodexAgentAdapter = class {
4484
+ prepared;
4485
+ preparationGeneration = 0;
4476
4486
  async setup(request) {
4487
+ const generation = this.preparationGeneration;
4488
+ if (request.options.provider?.prewarm && request.options.sandbox) {
4489
+ throw new Error("Codex prewarm is only supported for host execution.");
4490
+ }
4477
4491
  await setupCodex(request);
4492
+ if (!request.options.provider?.prewarm || this.prepared?.isAlive?.()) return;
4493
+ await this.prepared?.cleanup();
4494
+ if (generation !== this.preparationGeneration) throw new Error("Codex preparation was cancelled.");
4495
+ const runtime = await createRuntime(request, []);
4496
+ if (generation !== this.preparationGeneration) {
4497
+ await runtime.cleanup();
4498
+ throw new Error("Codex preparation was cancelled.");
4499
+ }
4500
+ const client = new JsonRpcLineClient(runtime.source, runtime.writeLine);
4501
+ const prepared = { ...runtime, client };
4502
+ this.prepared = prepared;
4503
+ try {
4504
+ await withTimeout(initializeCodexClient(client), 1e4);
4505
+ if (this.prepared !== prepared) throw new Error("Codex preparation was cancelled.");
4506
+ } catch (error) {
4507
+ if (this.prepared === prepared) this.prepared = void 0;
4508
+ await runtime.cleanup();
4509
+ throw error;
4510
+ }
4478
4511
  }
4479
4512
  async killServer(request) {
4513
+ this.preparationGeneration++;
4514
+ const prepared = this.prepared;
4515
+ this.prepared = void 0;
4516
+ await prepared?.cleanup();
4480
4517
  await killCodexAppServer(request);
4481
4518
  }
4482
4519
  async execute(request, sink) {
@@ -4487,11 +4524,20 @@ var CodexAgentAdapter = class {
4487
4524
  "validateProviderUserInput",
4488
4525
  () => validateProviderUserInput(request.provider, request.run.input)
4489
4526
  );
4490
- const runtime = await time(
4491
- debugCodex,
4492
- "createRuntime",
4493
- () => createRuntime(request, inputParts)
4494
- );
4527
+ const prepared = this.prepared;
4528
+ this.prepared = void 0;
4529
+ let runtime;
4530
+ if (prepared?.isAlive?.()) {
4531
+ try {
4532
+ runtime = { ...prepared, inputItems: await buildCodexInputItems(request.options, inputParts) };
4533
+ } catch (error) {
4534
+ await prepared.cleanup();
4535
+ throw error;
4536
+ }
4537
+ } else {
4538
+ await prepared?.cleanup();
4539
+ runtime = await time(debugCodex, "createRuntime", () => createRuntime(request, inputParts));
4540
+ }
4495
4541
  sink.setRaw(runtime.raw);
4496
4542
  sink.emitEvent(
4497
4543
  createNormalizedEvent("run.started", {
@@ -4760,17 +4806,7 @@ var CodexAgentAdapter = class {
4760
4806
  });
4761
4807
  try {
4762
4808
  if (!runtime.client) {
4763
- await client.request("initialize", {
4764
- clientInfo: {
4765
- title: "AgentBox",
4766
- name: "AgentBox",
4767
- version: "0.1.0"
4768
- },
4769
- capabilities: {
4770
- experimentalApi: true
4771
- }
4772
- });
4773
- await client.notify("initialized", {});
4809
+ await initializeCodexClient(client);
4774
4810
  }
4775
4811
  const cwd = request.options.cwd ?? process.cwd();
4776
4812
  let threadResponse;
@@ -1,4 +1,4 @@
1
- export { A as AISDKEvent, C as BackgroundTask, D as BackgroundTasksEvent, W as MessageCompletedEvent, X as MessageInjectedEvent, Y as MessageStartedEvent, Z as NativePlanEvent, _ as NormalizedAgentEvent, $ as NormalizedAgentEventBase, a0 as NormalizedAgentEventType, a7 as PermissionRequestedEvent, a8 as PermissionResolvedEvent, a9 as RawAgentEvent, aa as ReasoningDeltaEvent, ac as RunCancelledEvent, ad as RunCompletedEvent, ae as RunErrorEvent, af as RunStartedEvent, ah as TextDeltaEvent, aj as ToolCallCompletedEvent, ak as ToolCallDeltaEvent, al as ToolCallStartedEvent, ao as createNormalizedEvent, ap as normalizeRawAgentEvent, aq as toAISDKEvent, ar as toAISDKStream } from '../types-VT1LMbLW.js';
1
+ export { A as AISDKEvent, C as BackgroundTask, D as BackgroundTasksEvent, W as MessageCompletedEvent, X as MessageInjectedEvent, Y as MessageStartedEvent, Z as NativePlanEvent, _ as NormalizedAgentEvent, $ as NormalizedAgentEventBase, a0 as NormalizedAgentEventType, a7 as PermissionRequestedEvent, a8 as PermissionResolvedEvent, a9 as RawAgentEvent, aa as ReasoningDeltaEvent, ac as RunCancelledEvent, ad as RunCompletedEvent, ae as RunErrorEvent, af as RunStartedEvent, ah as TextDeltaEvent, aj as ToolCallCompletedEvent, ak as ToolCallDeltaEvent, al as ToolCallStartedEvent, ao as createNormalizedEvent, ap as normalizeRawAgentEvent, aq as toAISDKEvent, ar as toAISDKStream } from '../types-NhKw_6mW.js';
2
2
  import { AgentProvider } from '../enums.js';
3
3
  import '../Sandbox-DcKAU-E3.js';
4
4
  import 'e2b';
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
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 AgentUserAnswer, z as AgentUserQuestion, B as AttachedRun, C as BackgroundTask, D as BackgroundTasksEvent, E as ClaudeCodeAgentOptions, F as ClaudeCodeHookConfig, G as ClaudeCodeHookEvent, H as ClaudeCodeHookHandler, I as ClaudeCodeHookMatcherGroup, J as ClaudeCodeHooksConfig, K as ClaudeCodeProviderOptions, L as CodexAgentOptions, M as CodexCommandHook, N as CodexHookEvent, O as CodexHookMatcherGroup, P as CodexHooksConfig, Q as CodexModelProviderConfig, R as CodexProviderOptions, S as DataContent, T as EmbeddedSkillConfig, U as FilePart, V as ImagePart, W as MessageCompletedEvent, X as MessageInjectedEvent, Y as MessageStartedEvent, Z as NativePlanEvent, _ as NormalizedAgentEvent, $ as NormalizedAgentEventBase, a0 as NormalizedAgentEventType, a1 as OpenCodeAgentOptions, a2 as OpenCodePluginConfig, a3 as OpenCodePluginEvent, a4 as OpenCodePluginHookConfig, a5 as OpenCodeProviderOptions, a6 as OpenRouterPlugin, a7 as PermissionRequestedEvent, a8 as PermissionResolvedEvent, a9 as RawAgentEvent, aa as ReasoningDeltaEvent, ab as RepoSkillConfig, ac as RunCancelledEvent, ad as RunCompletedEvent, ae as RunErrorEvent, af as RunStartedEvent, ag as SetupLayout, ah as TextDeltaEvent, ai as TextPart, aj as ToolCallCompletedEvent, ak as ToolCallDeltaEvent, al as ToolCallStartedEvent, am as UserContent, an as UserContentPart, ao as createNormalizedEvent, ap as normalizeRawAgentEvent, aq as toAISDKEvent, ar as toAISDKStream } from './types-VT1LMbLW.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 AgentUserAnswer, z as AgentUserQuestion, B as AttachedRun, C as BackgroundTask, D as BackgroundTasksEvent, E as ClaudeCodeAgentOptions, F as ClaudeCodeHookConfig, G as ClaudeCodeHookEvent, H as ClaudeCodeHookHandler, I as ClaudeCodeHookMatcherGroup, J as ClaudeCodeHooksConfig, K as ClaudeCodeProviderOptions, L as CodexAgentOptions, M as CodexCommandHook, N as CodexHookEvent, O as CodexHookMatcherGroup, P as CodexHooksConfig, Q as CodexModelProviderConfig, R as CodexProviderOptions, S as DataContent, T as EmbeddedSkillConfig, U as FilePart, V as ImagePart, W as MessageCompletedEvent, X as MessageInjectedEvent, Y as MessageStartedEvent, Z as NativePlanEvent, _ as NormalizedAgentEvent, $ as NormalizedAgentEventBase, a0 as NormalizedAgentEventType, a1 as OpenCodeAgentOptions, a2 as OpenCodePluginConfig, a3 as OpenCodePluginEvent, a4 as OpenCodePluginHookConfig, a5 as OpenCodeProviderOptions, a6 as OpenRouterPlugin, a7 as PermissionRequestedEvent, a8 as PermissionResolvedEvent, a9 as RawAgentEvent, aa as ReasoningDeltaEvent, ab as RepoSkillConfig, ac as RunCancelledEvent, ad as RunCompletedEvent, ae as RunErrorEvent, af as RunStartedEvent, ag as SetupLayout, ah as TextDeltaEvent, ai as TextPart, aj as ToolCallCompletedEvent, ak as ToolCallDeltaEvent, al as ToolCallStartedEvent, am as UserContent, an as UserContentPart, ao as createNormalizedEvent, ap as normalizeRawAgentEvent, aq as toAISDKEvent, ar as toAISDKStream } from './types-NhKw_6mW.js';
2
2
  export { AGENT_RESERVED_PORTS, Agent, HarnessCapabilities, HarnessCommand, agentboxRoot, collectAllAgentReservedPorts, getAgentLayout, harnessCapabilities, resolveHarnessCommand } from './agents/index.js';
3
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';
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  getAgentLayout,
5
5
  harnessCapabilities,
6
6
  resolveHarnessCommand
7
- } from "./chunk-4DADE7TF.js";
7
+ } from "./chunk-XJWZR2NR.js";
8
8
  import {
9
9
  ProviderLogAssembler,
10
10
  createNormalizedEvent,
@@ -512,6 +512,10 @@ interface AgentOptionsBase {
512
512
  commands?: AgentCommandConfig[];
513
513
  }
514
514
  interface CodexProviderOptions {
515
+ /** Prepare the next host app-server during setup(), before a prompt arrives.
516
+ * No thread or turn is started. Each execution still owns and stops its
517
+ * process; killServer() also disposes an unused prepared process. */
518
+ prewarm?: boolean;
515
519
  /** Native service tier; "default" explicitly selects standard speed. */
516
520
  serviceTier?: string;
517
521
  /** Explicit policy for new, resumed, and forked native sessions. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentbox-sdk",
3
- "version": "0.1.512",
3
+ "version": "0.1.513",
4
4
  "description": "Swappable coding agents and sandbox providers for Bun and TypeScript.",
5
5
  "license": "MIT",
6
6
  "repository": {