agentbox-sdk 0.1.508 → 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
@@ -115,6 +115,70 @@ for await (const event of run) {
115
115
  const result = await run.finished;
116
116
  ```
117
117
 
118
+ Claude Code can leave work running after its turn ends (`run_in_background`
119
+ shells, `Monitor`, background subagents, scheduled wakeups) and re-prompts
120
+ itself when that work finishes. AgentBox reports it through `background.tasks`
121
+ events — `tasks` is the full live set after each change and `waiting` is `true`
122
+ while the harness has ended its turn and the run stays open only for those
123
+ tasks (or, with an empty set, for the wake-up the CLI queues for a task that
124
+ finished mid-turn) — and settles the run on the follow-up turn's result
125
+ instead of the first one. Once background work has been seen, a turn end
126
+ settles the run only after a 15s grace with no new turn, and a final
127
+ `background.tasks` with `tasks: []` and `waiting: false` precedes the settle.
128
+ `backgroundTaskTimeoutMs` bounds the total time spent waiting across the run:
129
+ default 30 minutes, `0` settles at the first turn end as before, `Infinity`
130
+ waits forever. On expiry the tasks are stopped best-effort and the run
131
+ completes with the last turn's text.
132
+
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.
158
+
159
+ OpenCode has no background shells, monitors, or wake-ups; its only work that
160
+ outlives a turn is `task {background: true}`, which the server accepts only when
161
+ it runs with `OPENCODE_EXPERIMENTAL_BACKGROUND_SUBAGENTS=true` (or the
162
+ `OPENCODE_EXPERIMENTAL` umbrella) in its environment. With that flag the parent
163
+ session goes idle while the child session runs and OpenCode itself re-prompts
164
+ the parent with the child's result. AgentBox recognises a background child from
165
+ the parent's `task` tool call (`metadata.background`), so nothing depends on the
166
+ caller's env: while such a child is live at the parent's idle the run stays
167
+ open, the children are reported through `background.tasks` (`type:
168
+ "subagent"`, `description` is the task description / child session title),
169
+ `waiting` flips to `false` when the parent resumes, and the run settles on the
170
+ next parent idle with nothing live — its text is the parent's last assistant
171
+ message, never the injected result. Child liveness comes from SSE frames
172
+ reconciled against `GET /session/status` at each parent idle and while waiting,
173
+ and the injected `<task id=… state=…>` result also counts as the child's
174
+ completion, so a lost frame cannot hold the run open. A child that ends without
175
+ waking the parent settles the run after the 15s grace. `backgroundTaskTimeoutMs`
176
+ bounds the total wait as for Claude Code; on expiry, or when the run fails with
177
+ a child still live, the leftover subagents are stopped best-effort via
178
+ `POST /session/:id/abort`. Aborting the run while waiting cancels the children
179
+ through the same endpoint. Without the flag nothing changes: a parent idle is
180
+ the end of the run.
181
+
118
182
  ## Agents
119
183
 
120
184
  Three agent providers are supported. Each wraps a CLI that runs inside the sandbox:
@@ -138,13 +202,15 @@ Pass an optional `reasoning` level alongside `model` on any run. It maps to each
138
202
  ```ts
139
203
  await agent.run({
140
204
  model: "sonnet",
141
- reasoning: "high", // "low" | "medium" | "high" | "xhigh"
205
+ reasoning: "high", // "low" | "medium" | "high" | "xhigh" | "max" | "ultra"
142
206
  input: "Refactor this module and explain your reasoning.",
143
207
  });
144
208
  ```
145
209
 
146
210
  `xhigh` requires a model that supports it (e.g. Claude Opus 4.7+, Codex `gpt-5.4`).
147
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
+
148
214
  ### Open-source & custom models (OpenRouter, OSS)
149
215
 
150
216
  Codex isn't limited to OpenAI models — it can route through any
@@ -547,7 +613,11 @@ Host Claude runs the Anthropic SDK with the SDK-matched CLI by default.
547
613
  `provider.binary` explicitly selects another compatible CLI. Sign-in and session
548
614
  storage remain CLI-owned. Managed configuration loads generated skills, commands,
549
615
  and subagents as a private local plugin. Native configuration loads user, project,
550
- and local settings instead. Neither mode copies the CLI's credentials.
616
+ and local settings instead. Neither mode copies the CLI's credentials. When
617
+ `backgroundTaskTimeoutMs` expires, host Claude stops the leftover background
618
+ tasks through the SDK; in a sandbox the daemon lets the CLI wind down on
619
+ disconnect, bounded by `CLAUDE_CODE_PRINT_BG_WAIT_CEILING_MS=30000`, which
620
+ AgentBox sets in the CLI environment unless `env` already defines it.
551
621
 
552
622
  Each host OpenCode Agent owns an authenticated loopback server on an ephemeral
553
623
  port. Managed configuration uses an isolated configuration directory; native
@@ -578,3 +648,5 @@ CLIs and SDK mocks; live tests remain opt-in.
578
648
  ## License
579
649
 
580
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, a7 as RawAgentEvent, b as AgentAttachRequest, B as AttachedRun, ae as SetupLayout, ak as UserContent } from '../types-BQ-_AUfY.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, C as ClaudeCodeAgentOptions, D as ClaudeCodeHookConfig, E as ClaudeCodeHookEvent, F as ClaudeCodeHookHandler, G as ClaudeCodeHookMatcherGroup, H as ClaudeCodeHooksConfig, I as ClaudeCodeProviderOptions, J as CodexAgentOptions, K as CodexCommandHook, L as CodexHookEvent, M as CodexHookMatcherGroup, N as CodexHooksConfig, O as CodexModelProviderConfig, P as CodexProviderOptions, Q as DataContent, R as EmbeddedSkillConfig, S as FilePart, T as ImagePart, $ as OpenCodeAgentOptions, a0 as OpenCodePluginConfig, a1 as OpenCodePluginEvent, a2 as OpenCodePluginHookConfig, a3 as OpenCodeProviderOptions, a4 as OpenRouterPlugin, a9 as RepoSkillConfig, ag as TextPart, al as UserContentPart } from '../types-BQ-_AUfY.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-BO4J4KSM.js";
7
+ } from "../chunk-4DADE7TF.js";
8
8
  import "../chunk-775FIGGL.js";
9
9
  import {
10
10
  AGENT_RESERVED_PORTS,