agentbox-sdk 0.1.511 → 0.1.512

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
@@ -130,33 +130,31 @@ default 30 minutes, `0` settles at the first turn end as before, `Infinity`
130
130
  waits forever. On expiry the tasks are stopped best-effort and the run
131
131
  completes with the last turn's text.
132
132
 
133
- Codex has no background mode of its own: its unified exec tool hands control
134
- back to the model early (`yield_time_ms`) and leaves the process running inside
135
- the app-server, where nothing wakes the model when it finishes. When a Codex
136
- turn ends with such a command still running, AgentBox keeps the app-server up
137
- and reports the command through `background.tasks` (`type: "command"`,
138
- `description` is the command line). Once every leftover command has finished
139
- while the model was idle, AgentBox starts a follow-up turn on the same thread
140
- carrying each command's exit code, duration and the last 4000 characters of
141
- output, asking the model to verify the outcome and finish without restarting
142
- the command; that turn is surfaced as a `message.injected` event and the run
143
- settles on its result (which may in turn leave more commands running). A
144
- message sent while waiting runs as a normal turn and is checked the same way; a
145
- command that finishes during a turn is left to the model's own polling and is
146
- only visible through `tool.call.completed`. A failed follow-up turn fails the
147
- run like any other turn. When `backgroundTaskTimeoutMs` expires, AgentBox asks
148
- the app-server to terminate the leftover processes
149
- (`thread/backgroundTerminals/list` + `terminate`, best effort) and completes
150
- with the last turn's text; `0` keeps the legacy settle-at-first-turn behaviour.
151
- Any unified-exec process still running at turn end counts a dev server or
152
- watcher the model leaves running on purpose holds the run open until the
153
- ceiling so hosts that expect such processes should pass a shorter
154
- `backgroundTaskTimeoutMs` for Codex. Spawned Codex sub-agents are not tracked:
155
- the parent must `wait_agent` for them within its turn. A waiting run can still
156
- be cancelled statelessly: `Agent.attach(...).abort()` interrupts the active turn
157
- when there is one and otherwise starts a turn only to interrupt it, which the
158
- originating run observes as an interrupted turn and reports as `run.cancelled`;
159
- the leftover processes are then terminated.
133
+ Codex owns command polling (`write_stdin`), yielded code-mode waits (`wait`),
134
+ and subagent waits (`wait_agent`). AgentBox finishes an ordinary Codex run on
135
+ its root `turn/completed`, regardless of shell processes still running. It does
136
+ not classify commands, wait for their exit, or inject synthetic follow-up turns.
137
+ Raw tool events remain available. A command ending after the final turn does
138
+ not restart the model. Remote cleanup disconnects from the shared app-server;
139
+ local cleanup shuts down the app-server it owns.
140
+
141
+ Native Codex goals are a separate lifecycle: an active root-thread goal keeps
142
+ the run open between turns so Codex can continue on its own. AgentBox reports
143
+ these gaps with `background.tasks { tasks: [], waiting: true }` and clears the
144
+ wait when the next native turn starts. A root goal becoming `complete` or
145
+ `blocked` ends the run after its final turn; a goal cleared or made inactive
146
+ while idle settles immediately. Child-thread and stale-turn goal updates do
147
+ not end the root run. `blocked` preserves the final answer without implying
148
+ that the objective was achieved.
149
+
150
+ Only these native goal waits use `backgroundTaskTimeoutMs` for Codex. The
151
+ 15-second idle grace and total wait ceiling bound the gap between native turns;
152
+ `0` settles at the first turn. Expiry settles with the last answer without
153
+ terminating remote shell processes. A user message can resume an idle goal
154
+ wait. Stateless cancellation (`Agent.attach(...).abort()`) interrupts an active
155
+ turn, or starts a turn only to interrupt it if the thread is idle, then stops
156
+ the idle thread's leftover terminals. Claude Code and OpenCode retain their own
157
+ background-work handling described above and below.
160
158
 
161
159
  OpenCode has no background shells, monitors, or wake-ups; its only work that
162
160
  outlives a turn is `task {background: true}`, which the server accepts only when
@@ -204,13 +202,15 @@ Pass an optional `reasoning` level alongside `model` on any run. It maps to each
204
202
  ```ts
205
203
  await agent.run({
206
204
  model: "sonnet",
207
- reasoning: "high", // "low" | "medium" | "high" | "xhigh"
205
+ reasoning: "high", // "low" | "medium" | "high" | "xhigh" | "max" | "ultra"
208
206
  input: "Refactor this module and explain your reasoning.",
209
207
  });
210
208
  ```
211
209
 
212
210
  `xhigh` requires a model that supports it (e.g. Claude Opus 4.7+, Codex `gpt-5.4`).
213
211
 
212
+ Codex also supports `max` (maximum reasoning) and `ultra` (maximum reasoning with automatic task delegation). Astra, GPT-5.6 Sol, and GPT-5.6 Terra support both; GPT-5.6 Luna supports `max`. Check the runtime's `model/list` → `supportedReasoningEfforts` for model availability. Both values are forwarded unchanged to `turn/start.effort`, including resumed and plan-mode turns; other AgentBox providers reject them.
213
+
214
214
  ### Open-source & custom models (OpenRouter, OSS)
215
215
 
216
216
  Codex isn't limited to OpenAI models — it can route through any
@@ -648,3 +648,5 @@ CLIs and SDK mocks; live tests remain opt-in.
648
648
  ## License
649
649
 
650
650
  MIT
651
+
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.
@@ -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-B4yy80AJ.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-B4yy80AJ.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-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';
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-G3VEVR6Y.js";
7
+ } from "../chunk-4DADE7TF.js";
8
8
  import "../chunk-775FIGGL.js";
9
9
  import {
10
10
  AGENT_RESERVED_PORTS,
@@ -2051,12 +2051,16 @@ function buildClaudeQueryOptions(params) {
2051
2051
  extraArgs["append-system-prompt"] = run.systemPrompt;
2052
2052
  }
2053
2053
  const includeHookEvents = provider?.includeHookEvents ?? false;
2054
+ if (run.reasoning === "max" || run.reasoning === "ultra") {
2055
+ throw new Error(`Reasoning effort "${run.reasoning}" is only supported by Codex.`);
2056
+ }
2054
2057
  const effort = provider?.ultracode ? "xhigh" : run.reasoning;
2055
2058
  return {
2056
2059
  cwd: params.cwd ?? params.request.options.cwd,
2057
2060
  env: params.env,
2058
2061
  pathToClaudeCodeExecutable: provider?.binary ?? "claude",
2059
2062
  ...params.settingsPath ? { settings: params.settingsPath } : {},
2063
+ ...params.request.options.configuration === "native" && provider?.fastMode !== void 0 ? { settings: { fastMode: provider.fastMode } } : {},
2060
2064
  ...params.request.options.configuration === "native" ? {
2061
2065
  settingSources: ["user", "project", "local"],
2062
2066
  systemPrompt: { type: "preset", preset: "claude_code" }
@@ -2704,7 +2708,11 @@ var ClaudeCodeAgentAdapter = class {
2704
2708
  const workflowSettings = buildClaudeWorkflowSettings(
2705
2709
  options.provider?.ultracode
2706
2710
  );
2707
- const claudeSettings = { ...hookSettings, ...workflowSettings };
2711
+ const claudeSettings = {
2712
+ ...hookSettings,
2713
+ ...workflowSettings,
2714
+ ...options.provider?.fastMode !== void 0 ? { fastMode: options.provider.fastMode } : {}
2715
+ };
2708
2716
  const mcpConfigJson = buildClaudeMcpConfig(options.mcps) ?? JSON.stringify({ mcpServers: {} }, null, 2);
2709
2717
  const artifacts = [
2710
2718
  ...!sandbox ? [{ path: path8.join(target.layout.claudeDir, ".claude-plugin", "plugin.json"), content: JSON.stringify({ name: "agentbox", version: "1.0.0" }) }] : [],
@@ -3642,6 +3650,7 @@ function buildThreadParams(cwd, options, request) {
3642
3650
  return {
3643
3651
  cwd,
3644
3652
  model: request.run.model ?? null,
3653
+ ...request.options.provider?.serviceTier !== void 0 ? { serviceTier: request.options.provider.serviceTier } : {},
3645
3654
  ...options.provider?.approvalPolicy ? { approvalPolicy: options.provider.approvalPolicy } : options.configuration === "native" && !options.fullAccess ? {} : { approvalPolicy: !options.fullAccess && isInteractiveApproval(options) ? "untrusted" : "never" },
3646
3655
  sandbox: buildCodexSandboxMode(options),
3647
3656
  serviceName: "agentbox",
@@ -3657,6 +3666,7 @@ function buildResumeParams(cwd, options, request) {
3657
3666
  threadId: request.run.resumeSessionId,
3658
3667
  cwd,
3659
3668
  model: request.run.model ?? null,
3669
+ ...request.options.provider?.serviceTier !== void 0 ? { serviceTier: request.options.provider.serviceTier } : {},
3660
3670
  ...options.provider?.approvalPolicy ? { approvalPolicy: options.provider.approvalPolicy } : options.configuration === "native" && !options.fullAccess ? {} : { approvalPolicy: !options.fullAccess && isInteractiveApproval(options) ? "untrusted" : "never" },
3661
3671
  sandbox: buildCodexSandboxMode(options),
3662
3672
  ...request.run.systemPrompt ? { developerInstructions: request.run.systemPrompt } : options.configuration === "native" ? {} : { developerInstructions: null },
@@ -3673,6 +3683,7 @@ function buildForkParams(cwd, options, request) {
3673
3683
  lastTurnId: request.run.forkAtMessageId ?? null,
3674
3684
  cwd,
3675
3685
  model: request.run.model ?? null,
3686
+ ...request.options.provider?.serviceTier !== void 0 ? { serviceTier: request.options.provider.serviceTier } : {},
3676
3687
  ...options.provider?.approvalPolicy ? { approvalPolicy: options.provider.approvalPolicy } : options.configuration === "native" && !options.fullAccess ? {} : { approvalPolicy: !options.fullAccess && isInteractiveApproval(options) ? "untrusted" : "never" },
3677
3688
  sandbox: buildCodexSandboxMode(options),
3678
3689
  ...request.run.systemPrompt ? { developerInstructions: request.run.systemPrompt } : options.configuration === "native" ? {} : { developerInstructions: null },
@@ -3712,6 +3723,7 @@ function buildCodexTurnStartParams(params) {
3712
3723
  },
3713
3724
  ...sandboxPolicy ? { sandboxPolicy } : {},
3714
3725
  model: request.run.model ?? null,
3726
+ ...request.options.provider?.serviceTier !== void 0 ? { serviceTier: request.options.provider.serviceTier } : {},
3715
3727
  effort: request.run.reasoning ?? null,
3716
3728
  ...request.run.mode ? { collaborationMode: {
3717
3729
  mode: request.run.mode,
@@ -3720,23 +3732,6 @@ function buildCodexTurnStartParams(params) {
3720
3732
  outputSchema: null
3721
3733
  };
3722
3734
  }
3723
- var BACKGROUND_OUTPUT_TAIL_CHARS = 4e3;
3724
- function buildCodexBackgroundFollowUp(items) {
3725
- const reports = items.map((item) => {
3726
- const tail = (item.aggregatedOutput ?? "").slice(-BACKGROUND_OUTPUT_TAIL_CHARS).trimEnd();
3727
- const duration = item.durationMs === void 0 ? "an unknown time" : `${Math.round(item.durationMs / 1e3)}s`;
3728
- return `\`${item.command}\` exited with code ${item.exitCode ?? "unknown"} after ${duration}.
3729
- Output (last ${BACKGROUND_OUTPUT_TAIL_CHARS} chars):
3730
- \`\`\`
3731
- ${tail || "(no output)"}
3732
- \`\`\`
3733
- `;
3734
- });
3735
- return `Background command finished while you were idle.
3736
-
3737
- ${reports.join("")}
3738
- Continue from here: verify the outcome and finish the task. Do not restart the command.`;
3739
- }
3740
3735
  var CODEX_CANCEL_TURN_TEXT = "Run cancelled by the host.";
3741
3736
  async function terminateBackgroundTerminals(client, threadId) {
3742
3737
  await withTimeout((async () => {
@@ -4511,7 +4506,6 @@ var CodexAgentAdapter = class {
4511
4506
  const interactiveApproval = isInteractiveApproval(request.options);
4512
4507
  let rootThreadId;
4513
4508
  let turnId;
4514
- let pendingTurns = 1;
4515
4509
  let abortInvoked = false;
4516
4510
  sink.setAbort(async () => {
4517
4511
  abortInvoked = true;
@@ -4565,61 +4559,33 @@ var CodexAgentAdapter = class {
4565
4559
  let streamedText = "";
4566
4560
  const timeoutMs = resolveBackgroundTaskTimeoutMs(request.options.backgroundTaskTimeoutMs);
4567
4561
  const isRootThread = (params) => !params?.threadId || params.threadId === rootThreadId;
4568
- const inFlight = /* @__PURE__ */ new Map();
4569
- const finished = [];
4562
+ let goalStatus = request.run.goal ? "active" : void 0;
4570
4563
  let pendingWait;
4571
4564
  let waitedMs = 0;
4572
- let followUpSent = false;
4573
4565
  let turnMessageText = "";
4574
4566
  let lastTurn;
4575
- let lastTasksKey = JSON.stringify({ tasks: [], waiting: false });
4576
- const liveTasks = () => [...inFlight.values()].filter((item) => item.outlived).map((item) => ({ id: item.id, type: "command", description: item.command }));
4577
- const emitTasks = (tasks, waiting) => {
4578
- const key = JSON.stringify({ tasks, waiting });
4579
- if (key === lastTasksKey) return;
4580
- lastTasksKey = key;
4581
- sink.emitEvent(createNormalizedEvent("background.tasks", { provider: request.provider, runId: request.runId }, { tasks, waiting }));
4567
+ let goalWaiting = false;
4568
+ const emitGoalWaiting = (waiting) => {
4569
+ if (waiting === goalWaiting) return;
4570
+ goalWaiting = waiting;
4571
+ sink.emitEvent(createNormalizedEvent("background.tasks", { provider: request.provider, runId: request.runId }, { tasks: [], waiting }));
4582
4572
  };
4583
4573
  const endWait = () => {
4584
4574
  if (!pendingWait) return;
4585
4575
  waitedMs += pendingWait.elapsedMs();
4586
4576
  pendingWait.clear();
4587
4577
  pendingWait = void 0;
4588
- followUpSent = false;
4589
- };
4590
- const sendBackgroundFollowUp = async () => {
4591
- if (!rootThreadId || !pendingWait || followUpSent || finished.length === 0 || abortInvoked) return;
4592
- if (timeoutMs - waitedMs - pendingWait.elapsedMs() <= 0) return;
4593
- followUpSent = true;
4594
- const text2 = buildCodexBackgroundFollowUp(finished.splice(0));
4595
- try {
4596
- const response = await client.request(
4597
- "turn/start",
4598
- buildCodexTurnStartParams({
4599
- threadId: rootThreadId,
4600
- inputItems: [{ type: "text", text: text2, text_elements: [] }],
4601
- request
4602
- })
4603
- );
4604
- endWait();
4605
- sink.emitEvent(createNormalizedEvent("message.injected", { provider: request.provider, runId: request.runId }, {
4606
- content: text2,
4607
- ...typeof response?.turn?.id === "string" ? { messageId: response.turn.id } : {}
4608
- }));
4609
- } catch (error) {
4610
- debugCodex("background follow-up turn/start failed: %o", error);
4611
- }
4578
+ emitGoalWaiting(false);
4612
4579
  };
4613
4580
  const completion = new Promise((resolve, reject) => {
4614
4581
  const settle = () => {
4615
4582
  endWait();
4616
- emitTasks([], false);
4617
4583
  sink.emitEvent(createNormalizedEvent("run.completed", { provider: request.provider, runId: request.runId }, { text: lastTurn?.messageText || void 0 }));
4618
4584
  resolve({ text: lastTurn?.text ?? streamedText, turnId, threadId: rootThreadId, interrupted: false });
4619
4585
  };
4620
4586
  const settleOnFailure = (error) => {
4621
4587
  if (!pendingWait || !lastTurn || abortInvoked) return false;
4622
- debugCodex("\u2605 transport failed during background wait; settling on the last turn: %o", error);
4588
+ debugCodex("\u2605 transport failed during goal wait; settling on the last turn: %o", error);
4623
4589
  settle();
4624
4590
  return true;
4625
4591
  };
@@ -4639,8 +4605,7 @@ var CodexAgentAdapter = class {
4639
4605
  }
4640
4606
  if ("reason" in step) {
4641
4607
  if (!abortInvoked) {
4642
- debugCodex("\u2605 background wait over (%s) with %d command(s) in flight", step.reason, inFlight.size);
4643
- if (step.reason === "ceiling" && rootThreadId) await terminateBackgroundTerminals(client, rootThreadId);
4608
+ debugCodex("\u2605 native goal wait over (%s)", step.reason);
4644
4609
  settle();
4645
4610
  return;
4646
4611
  }
@@ -4724,11 +4689,29 @@ var CodexAgentAdapter = class {
4724
4689
  sink.emitEvent(createNormalizedEvent("plan.completed", { provider: request.provider, runId: request.runId }, { text: item2.text }));
4725
4690
  }
4726
4691
  }
4692
+ if (rootThreadId && message.params && message.params.threadId === rootThreadId) {
4693
+ if (message.method === "thread/goal/updated") {
4694
+ const goal = message.params.goal;
4695
+ if (!message.params.turnId || message.params.turnId === turnId) {
4696
+ goalStatus = typeof goal?.status === "string" ? goal.status : void 0;
4697
+ if (goalStatus !== "active" && pendingWait && !abortInvoked) {
4698
+ settle();
4699
+ return;
4700
+ }
4701
+ }
4702
+ } else if (message.method === "thread/goal/cleared") {
4703
+ goalStatus = void 0;
4704
+ if (pendingWait && !abortInvoked) {
4705
+ settle();
4706
+ return;
4707
+ }
4708
+ }
4709
+ }
4727
4710
  const turn = message.params?.turn;
4728
4711
  const rootTurnCompleted = message.method === "turn/completed" && isRootThread(message.params);
4729
- const waitAfterTurn = rootTurnCompleted && pendingTurns <= 1 && timeoutMs !== 0 && !abortInvoked && turn?.status === "completed" && (inFlight.size > 0 || finished.length > 0);
4712
+ const waitAfterTurn = rootTurnCompleted && timeoutMs !== 0 && !abortInvoked && turn?.status === "completed" && goalStatus === "active";
4730
4713
  for (const event of toNormalizedCodexEvents(request.runId, message)) {
4731
- if (event.type === "run.completed" && (waitAfterTurn || turn?.status === "interrupted")) continue;
4714
+ if (event.type === "run.completed" && (!rootTurnCompleted || waitAfterTurn || turn?.status === "interrupted")) continue;
4732
4715
  sink.emitEvent(event);
4733
4716
  if (event.type === "text.delta") {
4734
4717
  streamedText += event.delta;
@@ -4740,61 +4723,31 @@ var CodexAgentAdapter = class {
4740
4723
  rootThreadId = message.params?.thread?.id ?? rootThreadId;
4741
4724
  }
4742
4725
  if (message.method === "turn/started") {
4743
- turnId = turn?.id ?? turnId;
4744
4726
  if (isRootThread(message.params)) {
4727
+ turnId = turn?.id ?? turnId;
4745
4728
  streamedText = "";
4746
4729
  turnMessageText = "";
4747
- if (pendingWait) debugCodex("\u2605 follow-up turn started; background wait over");
4730
+ if (pendingWait) debugCodex("\u2605 follow-up turn started; native goal wait over");
4748
4731
  endWait();
4749
- emitTasks(liveTasks(), false);
4750
- }
4751
- }
4752
- if (item?.type === "commandExecution" && typeof item.id === "string" && isRootThread(message.params)) {
4753
- if (message.method === "item/started") {
4754
- inFlight.set(item.id, {
4755
- id: item.id,
4756
- command: String(item.command ?? ""),
4757
- processId: typeof item.processId === "string" ? item.processId : void 0,
4758
- outlived: false
4759
- });
4760
- } else if (message.method === "item/completed") {
4761
- const tracked = inFlight.get(item.id);
4762
- inFlight.delete(item.id);
4763
- if (tracked?.outlived && pendingWait) {
4764
- finished.push({
4765
- ...tracked,
4766
- aggregatedOutput: typeof item.aggregatedOutput === "string" ? item.aggregatedOutput : void 0,
4767
- exitCode: typeof item.exitCode === "number" ? item.exitCode : void 0,
4768
- durationMs: typeof item.durationMs === "number" ? item.durationMs : void 0
4769
- });
4770
- }
4771
- emitTasks(liveTasks(), pendingWait !== void 0);
4772
- pendingWait?.setIdle(inFlight.size === 0);
4773
- if (pendingWait && inFlight.size === 0) await sendBackgroundFollowUp();
4774
4732
  }
4775
4733
  }
4776
4734
  if (rootTurnCompleted) {
4777
- pendingTurns--;
4778
- if (pendingTurns <= 0) {
4779
- const previousText = lastTurn?.text;
4780
- lastTurn = { text: streamedText, messageText: turnMessageText };
4781
- if (!waitAfterTurn) {
4782
- resolve({
4783
- text: streamedText || previousText,
4784
- turnId,
4785
- threadId: rootThreadId,
4786
- interrupted: turn?.status === "interrupted"
4787
- });
4788
- return;
4789
- }
4790
- for (const tracked of inFlight.values()) tracked.outlived = true;
4791
- debugCodex("\u2605 turn ended with %d command(s) in flight; waiting", inFlight.size);
4792
- endWait();
4793
- pendingWait = new BackgroundWait(BACKGROUND_TASK_GRACE_MS, Math.max(0, timeoutMs - waitedMs));
4794
- pendingWait.setIdle(inFlight.size === 0);
4795
- emitTasks(liveTasks(), true);
4796
- if (inFlight.size === 0) await sendBackgroundFollowUp();
4735
+ const previousText = lastTurn?.text;
4736
+ lastTurn = { text: streamedText, messageText: turnMessageText };
4737
+ if (!waitAfterTurn) {
4738
+ resolve({
4739
+ text: streamedText || previousText,
4740
+ turnId,
4741
+ threadId: rootThreadId,
4742
+ interrupted: turn?.status === "interrupted"
4743
+ });
4744
+ return;
4797
4745
  }
4746
+ debugCodex("\u2605 turn ended with an active goal; waiting for native continuation");
4747
+ endWait();
4748
+ pendingWait = new BackgroundWait(BACKGROUND_TASK_GRACE_MS, Math.max(0, timeoutMs - waitedMs));
4749
+ pendingWait.setIdle(true);
4750
+ emitGoalWaiting(true);
4798
4751
  }
4799
4752
  if (message.method === "error" && !shouldIgnoreCodexError(message)) {
4800
4753
  reject(message);
@@ -4873,7 +4826,6 @@ var CodexAgentAdapter = class {
4873
4826
  completionError = err;
4874
4827
  }
4875
4828
  endWait();
4876
- emitTasks([], false);
4877
4829
  if (completionError !== void 0) {
4878
4830
  if (abortInvoked) {
4879
4831
  debugCodex(
@@ -4919,8 +4871,8 @@ var CodexAgentAdapter = class {
4919
4871
  * driven by the normalized `message.started` event whose
4920
4872
  * `messageId` IS the codex turnId).
4921
4873
  *
4922
- * When that interrupt is rejected — the thread is idle in a background
4923
- * wait, or the turn id is stale or missing — a turn is started only to be
4874
+ * When that interrupt is rejected — the thread is between native goal
4875
+ * turns, or the turn id is stale or missing — a turn is started only to be
4924
4876
  * interrupted, so the originating run still observes an interrupted turn
4925
4877
  * and cancels; the model's leftover processes are then terminated.
4926
4878
  * Without `sessionId` the call is a no-op.
@@ -6830,6 +6782,9 @@ var Agent = class {
6830
6782
  this.setupPromise = void 0;
6831
6783
  }
6832
6784
  stream(runConfig) {
6785
+ if (this.provider !== AgentProvider.Codex && (runConfig.reasoning === "max" || runConfig.reasoning === "ultra")) {
6786
+ throw new Error(`Reasoning effort "${runConfig.reasoning}" is only supported by Codex.`);
6787
+ }
6833
6788
  if (runConfig.resumeSessionId && runConfig.forkSessionId) {
6834
6789
  throw new Error(
6835
6790
  "AgentRunConfig.resumeSessionId and forkSessionId are mutually exclusive."
@@ -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-B4yy80AJ.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-VT1LMbLW.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-B4yy80AJ.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-VT1LMbLW.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-G3VEVR6Y.js";
7
+ } from "./chunk-4DADE7TF.js";
8
8
  import {
9
9
  ProviderLogAssembler,
10
10
  createNormalizedEvent,
@@ -377,7 +377,8 @@ interface FilePart {
377
377
  }
378
378
  type UserContentPart = TextPart | ImagePart | FilePart;
379
379
  type UserContent = string | UserContentPart[];
380
- type AgentReasoningEffort = "low" | "medium" | "high" | "xhigh";
380
+ /** `max` and `ultra` are Codex-only and require a supporting model/runtime. */
381
+ type AgentReasoningEffort = "low" | "medium" | "high" | "xhigh" | "max" | "ultra";
381
382
  interface AgentRunConfig {
382
383
  input: UserContent;
383
384
  runId?: string;
@@ -492,6 +493,12 @@ interface AgentOptionsBase {
492
493
  * work); `Infinity` waits forever. On expiry the tasks are stopped
493
494
  * best-effort and the run completes with the last turn's text. Progress
494
495
  * is reported through `background.tasks` events.
496
+ * For Codex, only gaps between active native goal turns use this budget
497
+ * (also bounded by the idle grace). Ordinary turns finish on turn/completed,
498
+ * regardless of live shell processes. No synthetic command-result turn is
499
+ * injected, and goal-wait expiry does not terminate remote shell processes.
500
+ * Inactive goals settle after their final turn; clearing a goal while idle
501
+ * settles immediately.
495
502
  */
496
503
  backgroundTaskTimeoutMs?: number;
497
504
  approvalMode?: AgentApprovalMode;
@@ -505,6 +512,8 @@ interface AgentOptionsBase {
505
512
  commands?: AgentCommandConfig[];
506
513
  }
507
514
  interface CodexProviderOptions {
515
+ /** Native service tier; "default" explicitly selects standard speed. */
516
+ serviceTier?: string;
508
517
  /** Explicit policy for new, resumed, and forked native sessions. */
509
518
  approvalPolicy?: "untrusted" | "on-request" | "never";
510
519
  /** Managed host execution defaults to read-only; native configuration uses the CLI's settings. */
@@ -564,6 +573,8 @@ interface OpenCodeProviderOptions {
564
573
  plugins?: OpenCodePluginConfig[];
565
574
  }
566
575
  interface ClaudeCodeProviderOptions {
576
+ /** Request fast mode explicitly; false overrides inherited fast settings. */
577
+ fastMode?: boolean;
567
578
  binary?: string;
568
579
  args?: string[];
569
580
  hooks?: ClaudeCodeHooksConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentbox-sdk",
3
- "version": "0.1.511",
3
+ "version": "0.1.512",
4
4
  "description": "Swappable coding agents and sandbox providers for Bun and TypeScript.",
5
5
  "license": "MIT",
6
6
  "repository": {