@agent-compose/sdk 0.8.4 → 0.8.6
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 +213 -189
- package/dist/agent/agent-context.d.ts +9 -1
- package/dist/agent/agent-loop.d.ts +14 -6
- package/dist/agent/perf-sampler.d.ts +27 -2
- package/dist/agent/run-agent.d.ts +1 -1
- package/dist/client.d.ts +250 -59
- package/dist/directives.d.ts +14 -0
- package/dist/display.d.ts +7 -0
- package/dist/errors.d.ts +1 -1
- package/dist/generated/agentc-commands.d.ts +34 -0
- package/dist/index.d.ts +13 -11
- package/dist/index.js +1692 -194
- package/dist/request-context/request-context.d.ts +1 -1
- package/dist/runtimes/_cli-agent.d.ts +278 -58
- package/dist/runtimes/claude-code.d.ts +90 -1
- package/dist/runtimes/claude.d.ts +1 -1
- package/dist/runtimes/codex.d.ts +94 -6
- package/dist/runtimes/codex.mid-turn-hook.test.d.ts +10 -0
- package/dist/runtimes/openai-desktop.d.ts +50 -0
- package/dist/runtimes/openai-desktop.js +1689 -211
- package/dist/runtimes/openai-desktop.test.d.ts +20 -0
- package/dist/runtimes/opencode.d.ts +48 -11
- package/dist/runtimes/opencode.test.d.ts +14 -0
- package/dist/runtimes/tool-pulse.test.d.ts +17 -0
- package/dist/sandbox/baked-clis.d.ts +75 -0
- package/dist/sandbox/devbox.d.ts +5 -5
- package/dist/sandbox/exec-stream.d.ts +1 -2
- package/dist/sandbox/network-policy.d.ts +23 -5
- package/dist/sandbox/registry.d.ts +12 -0
- package/dist/sandbox/sizes.d.ts +11 -5
- package/dist/sandbox.d.ts +5 -3
- package/dist/step-invocation/protocol.d.ts +3 -4
- package/dist/step-invocation/server.d.ts +2 -2
- package/dist/step-invocation/types.d.ts +2 -2
- package/dist/types/api-conversations.d.ts +513 -27
- package/dist/types/api-factory.d.ts +183 -3
- package/dist/types/api-projects.d.ts +480 -0
- package/dist/types/api-runs.d.ts +8 -0
- package/dist/types/api-scopes.d.ts +32 -3
- package/dist/types/conversation-stream.d.ts +27 -1
- package/dist/types/execution-context.d.ts +1 -1
- package/dist/types/protocol.d.ts +182 -2
- package/dist/types/runtime.d.ts +80 -2
- package/dist/types/workflow-metadata.d.ts +2 -4
- package/dist/types/workflow-plan.d.ts +1 -3
- package/dist/utils/bundler.d.ts +23 -0
- package/dist/workflow-steps/observability.d.ts +2 -3
- package/dist/workflow-steps/runner.d.ts +5 -8
- package/dist/workflow-steps/types.d.ts +8 -10
- package/dist/workflow-steps/workflow.d.ts +2 -1
- package/dist/workflows/engine.d.ts +3 -5
- package/dist/workflows/invoke-child.d.ts +2 -2
- package/package.json +2 -2
- package/src/agent/agent-context.ts +193 -116
- package/src/agent/agent-loop.ts +16 -9
- package/src/agent/desktop-open.ts +13 -1
- package/src/agent/perf-sampler.ts +54 -3
- package/src/agent/run-agent.ts +1 -1
- package/src/client.ts +418 -80
- package/src/directives.ts +21 -1
- package/src/display.ts +12 -0
- package/src/errors.ts +1 -0
- package/src/generated/agentc-commands.ts +571 -0
- package/src/index.ts +65 -18
- package/src/pause/pause-core.ts +2 -1
- package/src/request-context/request-context.ts +1 -1
- package/src/runtimes/_cli-agent.ts +607 -132
- package/src/runtimes/claude-code.ts +427 -20
- package/src/runtimes/claude.ts +1 -1
- package/src/runtimes/codex.ts +188 -19
- package/src/runtimes/openai-desktop.ts +82 -19
- package/src/runtimes/opencode.ts +195 -26
- package/src/sandbox/baked-clis.ts +86 -0
- package/src/sandbox/devbox.ts +5 -5
- package/src/sandbox/exec-stream.ts +1 -2
- package/src/sandbox/network-policy.ts +51 -7
- package/src/sandbox/providers/e2b.ts +63 -19
- package/src/sandbox/providers/vercel.ts +6 -6
- package/src/sandbox/registry.ts +19 -1
- package/src/sandbox/sizes.ts +11 -5
- package/src/sandbox.ts +9 -2
- package/src/step-invocation/invoker.ts +2 -6
- package/src/step-invocation/protocol.ts +3 -4
- package/src/step-invocation/server.ts +2 -2
- package/src/types/api-conversations.ts +424 -29
- package/src/types/api-factory.ts +189 -3
- package/src/types/api-projects.ts +443 -0
- package/src/types/api-runs.ts +5 -0
- package/src/types/api-scopes.ts +32 -3
- package/src/types/conversation-stream.ts +29 -1
- package/src/types/execution-context.ts +1 -1
- package/src/types/protocol.ts +180 -2
- package/src/types/runtime.ts +71 -2
- package/src/types/sandbox-environment.ts +1 -2
- package/src/types/workflow-metadata.ts +2 -4
- package/src/types/workflow-plan.ts +1 -3
- package/src/utils/bundler.ts +88 -19
- package/src/workflow-steps/observability.ts +2 -3
- package/src/workflow-steps/runner.ts +5 -8
- package/src/workflow-steps/types.ts +8 -10
- package/src/workflow-steps/workflow.ts +2 -1
- package/src/workflows/engine.ts +3 -5
- package/src/workflows/invoke-child.ts +2 -2
- package/dist/pause/__tests__/errors.test.d.ts +0 -1
- package/dist/pause/__tests__/wrappers.test.d.ts +0 -1
- package/dist/step-invocation/__tests__/protocol.test.d.ts +0 -1
package/src/sandbox/registry.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* at creation time.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { SandboxNotFoundError, RateLimitError } from "e2b";
|
|
9
|
+
import { SandboxNotFoundError, RateLimitError, NotFoundError } from "e2b";
|
|
10
10
|
import pRetry from "p-retry";
|
|
11
11
|
import type { FailedAttemptError } from "p-retry";
|
|
12
12
|
import type { SandboxProvider } from "../types/sandbox.js";
|
|
@@ -45,6 +45,24 @@ function isTransientSandboxError(error: unknown): boolean {
|
|
|
45
45
|
.test(message);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
/** Did a CREATE fail because its create SOURCE (template alias / snapshot id)
|
|
49
|
+
* does not resolve on the provider — vs any other create fault? The server's
|
|
50
|
+
* recovery-boot fall-through keys on this: a ring snapshot licensed on an
|
|
51
|
+
* INDETERMINATE existence probe that turns out to be gone must fall through
|
|
52
|
+
* the ring toward the base image, while every other create fault (quota,
|
|
53
|
+
* auth, 5xx, network) must propagate — falling through on those would trade
|
|
54
|
+
* a still-recoverable machine state for a base boot. E2B maps the create-
|
|
55
|
+
* time 404 ("template not found") to its typed `NotFoundError`; the message
|
|
56
|
+
* match is the fallback for untyped transports (Vercel). Lives in the SDK
|
|
57
|
+
* because the server holds its OWN `e2b` module instance — an `instanceof`
|
|
58
|
+
* against the class from the wrong copy is always false. */
|
|
59
|
+
export function isSandboxSourceNotFoundError(error: unknown): boolean {
|
|
60
|
+
if (error instanceof NotFoundError) return true;
|
|
61
|
+
const message = error instanceof Error ? error.message : String(error ?? "");
|
|
62
|
+
return /(?:template|snapshot)[^\n]{0,80}not[\s_-]?found|not[\s_-]?found[^\n]{0,80}(?:template|snapshot)/i
|
|
63
|
+
.test(message);
|
|
64
|
+
}
|
|
65
|
+
|
|
48
66
|
/** The ONE place the sandbox retry policy lives. Provisioning, reconnecting, and
|
|
49
67
|
* snapshotting all race with the sandbox being paused/reclaimed; this runs the call
|
|
50
68
|
* through p-retry's generic backoff, retrying ONLY the transient race (and failing
|
package/src/sandbox/sizes.ts
CHANGED
|
@@ -148,15 +148,21 @@ export function sandboxSizeLabel(size: SandboxSize): string {
|
|
|
148
148
|
/** Stable E2B template ALIAS for the platform base at a given size
|
|
149
149
|
* (`agent-compose-base-<size>`). Aliases — not snapshot ids — so the refs are
|
|
150
150
|
* multi-account-clean: the same string resolves in any E2B account that built
|
|
151
|
-
* the templates. Built by `infra/e2b-template/build.ts
|
|
152
|
-
*
|
|
151
|
+
* the templates. Built by `infra/e2b-template/build.ts`. An EXPLICIT
|
|
152
|
+
* `bootFrom`/template target only — nothing boots it by default: template-less
|
|
153
|
+
* E2B creates resolve `e2bAgentEnvTemplate` (the session-identical image)
|
|
154
|
+
* instead, so the run and session lanes can never diverge on baked tooling. */
|
|
153
155
|
export function e2bBaseTemplate(size: SandboxSize): string {
|
|
154
156
|
return `agent-compose-base-${size}`;
|
|
155
157
|
}
|
|
156
158
|
|
|
157
|
-
/** Stable E2B template ALIAS for the agent runtime (base + claude binary
|
|
158
|
-
* given size (`agent-env-<size>`).
|
|
159
|
-
*
|
|
159
|
+
/** Stable E2B template ALIAS for the agent runtime (base + claude binary +
|
|
160
|
+
* dev toolbelt + session desktop) at a given size (`agent-env-<size>`).
|
|
161
|
+
* THE default E2B boot image, both lanes: every cloud SESSION boots it
|
|
162
|
+
* (server/src/sandbox/persistent.ts), and every template-less E2B workflow
|
|
163
|
+
* RUN boots it too (the e2b provider's size-matched default). The agent
|
|
164
|
+
* default templates boot from this via
|
|
165
|
+
* `bootFrom: { snapshotId: e2bAgentEnvTemplate(size) }`. Multi-account-clean
|
|
160
166
|
* for the same reason as `e2bBaseTemplate`. */
|
|
161
167
|
export function e2bAgentEnvTemplate(size: SandboxSize): string {
|
|
162
168
|
return `agent-env-${size}`;
|
package/src/sandbox.ts
CHANGED
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
* - `sandbox/network-policy.ts` — egress policy shape + per-provider translators
|
|
6
6
|
* - `sandbox/sizes.ts` — machine sizes + E2B template aliases
|
|
7
7
|
* - `sandbox/devbox.ts` — the ADR-0038 per-member desktop machine alias
|
|
8
|
+
* - `sandbox/baked-clis.ts` — harness CLI versions the session image bakes
|
|
8
9
|
* - `sandbox/provider-def.ts` — provider contract, create opts, fleet tag
|
|
9
|
-
* - `sandbox/exec-stream.ts` — SSE exec-stream parser
|
|
10
|
+
* - `sandbox/exec-stream.ts` — SSE exec-stream parser
|
|
10
11
|
* - `sandbox/providers/*` — vercel / e2b / e2b-desktop / local providers
|
|
11
12
|
* - `sandbox/registry.ts` — provider registry + fleet management
|
|
12
13
|
*/
|
|
@@ -19,7 +20,7 @@ export type {
|
|
|
19
20
|
SandboxNetworkSubnetPolicy,
|
|
20
21
|
SandboxNetworkPolicy,
|
|
21
22
|
} from "./sandbox/network-policy.js";
|
|
22
|
-
export { DOT_SEGMENT_PATH_RE2, toVercelNetworkPolicy, toE2bNetwork } from "./sandbox/network-policy.js";
|
|
23
|
+
export { DOT_SEGMENT_PATH_RE2, openEgressExcept, toVercelNetworkPolicy, toE2bNetwork } from "./sandbox/network-policy.js";
|
|
23
24
|
|
|
24
25
|
export type { SandboxSize } from "./sandbox/sizes.js";
|
|
25
26
|
export {
|
|
@@ -48,6 +49,11 @@ export {
|
|
|
48
49
|
e2bDevboxTemplateRef,
|
|
49
50
|
} from "./sandbox/devbox.js";
|
|
50
51
|
|
|
52
|
+
export {
|
|
53
|
+
CLAUDE_CODE_VERSION, CODEX_CLI_VERSION, OPENCODE_CLI_VERSION, RTK_VERSION,
|
|
54
|
+
CLAUDE_CODE_NO_SELF_UPDATE_ENV, CODEX_NO_SELF_UPDATE_CONFIG_LINE, OPENCODE_NO_SELF_UPDATE_CONFIG,
|
|
55
|
+
} from "./sandbox/baked-clis.js";
|
|
56
|
+
|
|
51
57
|
export { AGENT_COMPOSE_TAG } from "./sandbox/provider-def.js";
|
|
52
58
|
export type { SandboxCreateOpts, OwnedSandbox } from "./sandbox/provider-def.js";
|
|
53
59
|
|
|
@@ -65,6 +71,7 @@ export {
|
|
|
65
71
|
reconnectSandbox,
|
|
66
72
|
deleteSandboxSnapshot,
|
|
67
73
|
snapshotResolves,
|
|
74
|
+
isSandboxSourceNotFoundError,
|
|
68
75
|
getSandboxQuotas,
|
|
69
76
|
listOwnedSandboxes,
|
|
70
77
|
killSandboxById,
|
|
@@ -526,12 +526,8 @@ export async function invokeStep<TOutput = unknown>(
|
|
|
526
526
|
|
|
527
527
|
let result: { stdout: string; stderr: string; exitCode: number };
|
|
528
528
|
try {
|
|
529
|
-
// Run the agent as ROOT (ADR-0019 follow-up).
|
|
530
|
-
//
|
|
531
|
-
// so a non-root agent EACCESes on every shared file — the reason for the
|
|
532
|
-
// expensive boot-time `chmod -R` walk. As root the agent writes them
|
|
533
|
-
// directly: the walk disappears entirely. Egress is edge-enforced with NO
|
|
534
|
-
// root exemption (see sandbox.ts), so root is confined exactly like the
|
|
529
|
+
// Run the agent as ROOT (ADR-0019 follow-up). Egress is edge-enforced with
|
|
530
|
+
// NO root exemption (see sandbox.ts), so root is confined exactly like the
|
|
535
531
|
// non-root user. `HOME=/root` so the spawned `claude` finds root's skills.
|
|
536
532
|
//
|
|
537
533
|
// Same pipeline pattern as `launchStep`: tee the runner's stdout to the
|
|
@@ -38,12 +38,11 @@ export function stepPauseLinePrefix(token: string): string {
|
|
|
38
38
|
return `${STEP_PAUSE_PREFIX}${token}:`;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
/** Sandbox-side path where
|
|
42
|
-
*
|
|
43
|
-
* the runner from this path; single source of truth. */
|
|
41
|
+
/** Sandbox-side path where the sandbox bootstrap writes the compiled runner
|
|
42
|
+
* bundle; `invokeStep` spawns the runner from this path. */
|
|
44
43
|
export const RUNNER_BUNDLE_PATH = "/tmp/runner.bundle.js";
|
|
45
44
|
|
|
46
|
-
/** Command the invoker
|
|
45
|
+
/** Command the invoker spawns inside the sandbox. */
|
|
47
46
|
export const RUNNER_COMMAND = `node ${RUNNER_BUNDLE_PATH}`;
|
|
48
47
|
|
|
49
48
|
/** Names of the env vars the invoker stamps onto the runner subprocess.
|
|
@@ -153,8 +153,8 @@ function scrubProtocolEnvs(): void {
|
|
|
153
153
|
* from process.env so user code (including any workflow module imported
|
|
154
154
|
* inside the handler) cannot read AC_STEP_RESULT_TOKEN — that keeps the
|
|
155
155
|
* result channel uncorruptible by stdout output from anywhere in the
|
|
156
|
-
* workflow's dep tree. RUN_ID remains available
|
|
157
|
-
*
|
|
156
|
+
* workflow's dep tree. RUN_ID remains available: SDK code inside the step
|
|
157
|
+
* (`agent()`, the client's parent-run link) reads it.
|
|
158
158
|
*/
|
|
159
159
|
export async function serveStep<TInput, TOutput>(
|
|
160
160
|
handler: StepHandler<TInput, TOutput>,
|