@agent-compose/sdk 0.5.5 → 0.5.7

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.
Files changed (40) hide show
  1. package/README.md +4 -4
  2. package/dist/agent/agent-loop-contract.test.d.ts +1 -0
  3. package/dist/agent/agent-loop.d.ts +1 -1
  4. package/dist/client.d.ts +65 -23
  5. package/dist/index.d.ts +4 -2
  6. package/dist/index.js +389 -109
  7. package/dist/runtimes/_cli-agent.d.ts +25 -8
  8. package/dist/runtimes/amp.d.ts +7 -6
  9. package/dist/runtimes/claude.d.ts +9 -1
  10. package/dist/runtimes/cli-agent.test.d.ts +9 -0
  11. package/dist/runtimes/codex.d.ts +6 -5
  12. package/dist/runtimes/openai-desktop.js +387 -109
  13. package/dist/sandbox-errors.d.ts +49 -0
  14. package/dist/sandbox.d.ts +68 -13
  15. package/dist/step-invocation/protocol.d.ts +6 -0
  16. package/dist/types/sandbox-environment.d.ts +1 -10
  17. package/dist/types/sandbox.d.ts +27 -3
  18. package/dist/types/workflow-metadata.d.ts +88 -23
  19. package/dist/types/workflow.d.ts +38 -10
  20. package/dist/utils/bundler.d.ts +38 -9
  21. package/dist/workflow-steps/workflow.d.ts +1 -3
  22. package/package.json +2 -2
  23. package/src/agent/agent-loop.ts +56 -7
  24. package/src/client.ts +144 -25
  25. package/src/index.ts +4 -2
  26. package/src/runtimes/_cli-agent.ts +75 -42
  27. package/src/runtimes/amp.ts +11 -6
  28. package/src/runtimes/claude.ts +66 -8
  29. package/src/runtimes/codex.ts +10 -5
  30. package/src/sandbox-errors.ts +53 -0
  31. package/src/sandbox.ts +378 -56
  32. package/src/step-invocation/invoker.ts +66 -8
  33. package/src/step-invocation/protocol.ts +9 -0
  34. package/src/step-invocation/server.ts +27 -4
  35. package/src/types/sandbox-environment.ts +1 -11
  36. package/src/types/sandbox.ts +28 -3
  37. package/src/types/workflow-metadata.ts +97 -26
  38. package/src/types/workflow.ts +38 -11
  39. package/src/utils/bundler.ts +43 -13
  40. package/src/workflow-steps/workflow.ts +1 -3
@@ -12,14 +12,16 @@
12
12
  * AsyncQueue bridge → init/usage/done/error lifecycle), parameterised per-CLI
13
13
  * by a `CliAgentSpec`.
14
14
  *
15
- * Requirements (per spec): the provider CLI is installed in the sandbox image,
16
- * and the provider's API key is present in the sandbox environment (see each
17
- * spec's `authEnv`). `commands.run` inherits the sandbox env, so secrets set via
18
- * `agentc secrets set` are visible to the CLI.
19
- *
20
- * NOTE: the per-CLI command construction + resume flags + exact event shapes in
21
- * the shipped specs are mapped from each tool's docs and have NOT been verified
22
- * against a live CLI run — verify before relying on them in production.
15
+ * Provisioning (per spec): the runtime installs the provider CLI on demand —
16
+ * `command -v <bin>` before the first turn, falling back to the spec's
17
+ * `install` command when it's absent — so it works on a bare sandbox with no
18
+ * manual setup or hardcoded snapshot id. Pair it with
19
+ * `snapshots: { bootFrom: "reuse" }` on the workflow and the install happens
20
+ * exactly once: the first run installs the CLI and captures a snapshot, and
21
+ * every run after boots from that snapshot with the CLI already present (the
22
+ * probe short-circuits). The provider's API key must be in the sandbox env
23
+ * (see each spec's `authEnv`); `commands.run` inherits the sandbox env, so
24
+ * values set via `agentc secrets set` are visible to the CLI.
23
25
  */
24
26
  import type { AgentMessage, ModelExecutionContract, RuntimeOptions, SandboxProvider } from "../index.js";
25
27
  /** Single-quote a value for safe interpolation into a `sh -c` command line. */
@@ -34,6 +36,15 @@ export interface CliAgentSpec {
34
36
  authEnv: string;
35
37
  /** Default model id when none is configured; omit to let the CLI choose. */
36
38
  defaultModel?: string;
39
+ /** Binary the runtime spawns (`codex`, `amp`). Probed with `command -v`
40
+ * before the first turn; if absent, `install` provisions it. */
41
+ bin: string;
42
+ /** Shell command that installs `bin` when it's missing from the sandbox.
43
+ * Runs at most once per runner, and only when the probe fails — so booting
44
+ * from a snapshot that already has the CLI (the steady state under
45
+ * `snapshots: { bootFrom: "reuse" }`) skips it. Must leave `bin` resolvable
46
+ * on a non-login shell's PATH (the runtime spawns via `sh -c`). */
47
+ install: string;
37
48
  /** Serialise the user prompt into the bytes written to the prompt file —
38
49
  * plain text for a CLI that reads the prompt from stdin (codex `-`), or a
39
50
  * JSONL user message for a `--stream-json-input` CLI (amp). */
@@ -62,6 +73,12 @@ export declare class CliAgentRunner implements ModelExecutionContract {
62
73
  readonly kind: string;
63
74
  constructor(sandbox: SandboxProvider, options: RuntimeOptions, spec: CliAgentSpec, configModel?: string | undefined);
64
75
  get model(): string | undefined;
76
+ private installed;
77
+ /** Provision the CLI on demand. A no-op once `bin` is on PATH — the steady
78
+ * state under `snapshots: { bootFrom: "reuse" }`, where the first run's
79
+ * install is baked into the snapshot every later run boots from. So the
80
+ * install command runs exactly once: on the first run of a content hash. */
81
+ private ensureInstalled;
65
82
  sendMessage(opts: {
66
83
  prompt: string;
67
84
  sessionId?: string;
@@ -5,13 +5,14 @@
5
5
  * own loop + tools, so we only stream-parse what it prints.
6
6
  *
7
7
  * Auth: set `AMP_API_KEY` (`sgamp_…`) in the sandbox env via a workflow secret.
8
- * Requires the `amp` CLI (`@ampcode/cli`) installed in the sandbox image. The
9
- * model is chosen by the AMP_API_KEY account (e.g. a GPT-only token runs GPT);
10
- * the runtime doesn't pin a model.
8
+ * The runtime installs the `amp` CLI (`@ampcode/cli`) on demand — no image
9
+ * baking needed; pair with `snapshots: { bootFrom: "reuse" }` to install once
10
+ * and boot from the captured snapshot on every run after. The model is chosen
11
+ * by the AMP_API_KEY account (e.g. a GPT-only token runs GPT); the runtime
12
+ * doesn't pin a model.
11
13
  *
12
- * ⚠️ NOT verified against a live `amp` run — the thread-continue syntax and the
13
- * exact assistant/result shapes are mapped from the docs (ampcode.com). Verify
14
- * before production use.
14
+ * Verified against a live `amp -x --stream-json` run: the user-message stdin
15
+ * shape, assistant content blocks, and result usage below all round-trip.
15
16
  */
16
17
  export interface AmpRuntimeConfig {
17
18
  /** Amp uses its configured model; reserved for forward-compatibility. */
@@ -7,7 +7,11 @@ export interface ClaudeRuntimeConfig {
7
7
  claudeMdContent?: string;
8
8
  /** Env overrides for Agent SDK provider routing. */
9
9
  env?: Record<string, string>;
10
- /** Model to use. Defaults to DEFAULT_CLAUDE_MODEL. */
10
+ /** Model to use. Accepts a caliber shorthand — "fable" (most capable),
11
+ * "opus", "sonnet", "haiku" (fastest/cheapest) — or an exact model id.
12
+ * Defaults to DEFAULT_CLAUDE_MODEL (Fable). Orchestrators pick a caliber
13
+ * per agent: fable/opus for planning + implementation, sonnet for focused
14
+ * single-responsibility work, haiku for mechanical tasks. */
11
15
  model?: string;
12
16
  /** MCP servers to configure for the Agent SDK. */
13
17
  mcpServers?: Record<string, {
@@ -21,6 +25,10 @@ export interface ClaudeRuntimeConfig {
21
25
  thinking?: ThinkingConfig;
22
26
  /** Reasoning effort hint for models that support adaptive thinking. */
23
27
  effort?: "low" | "medium" | "high" | "xhigh" | "max";
28
+ /** Skills to enable for the agent (the Agent SDK's `skills` option — also
29
+ * auto-adds the `Skill` tool). The agent-env bakes the `/ac:*` skills via
30
+ * `agentc init`; default `"all"` makes them usable. Pass `[]` to disable. */
31
+ skills?: string[] | "all";
24
32
  }
25
33
  export declare class ClaudeRunner implements ModelExecutionContract {
26
34
  private readonly options;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * CliAgentRunner self-provisioning — the runtime installs its CLI on demand
3
+ * (`command -v <bin>` → install if missing), runs the install at most once per
4
+ * runner, and surfaces an install failure as an `error` message rather than
5
+ * blowing up. This is what lets `createCodexRuntime()` work on a bare sandbox
6
+ * with no image baking, and lets `snapshots: { bootFrom: "reuse" }` collapse
7
+ * the install to a one-time cost.
8
+ */
9
+ export {};
@@ -4,12 +4,13 @@
4
4
  * Built on the shared CLI-agent base; Codex brings its own loop + tools, so we
5
5
  * only stream-parse what it prints.
6
6
  *
7
- * Auth: set `CODEX_API_KEY` (or `OPENAI_API_KEY`) in the sandbox env via a
8
- * workflow secret. Requires the `codex` CLI installed in the sandbox image.
7
+ * Auth: set `OPENAI_API_KEY` (or `CODEX_API_KEY`) in the sandbox env via a
8
+ * workflow secret. The runtime installs the `codex` CLI (`@openai/codex`) on
9
+ * demand — no image baking needed; pair with `snapshots: { bootFrom: "reuse" }`
10
+ * to install once and boot from the captured snapshot on every run after.
9
11
  *
10
- * ⚠️ NOT verified against a live `codex` run — the resume flag and the exact
11
- * item shapes (command_execution / reasoning fields) are mapped from the docs
12
- * (developers.openai.com/codex/noninteractive). Verify before production use.
12
+ * Verified against codex-cli 0.124.0: `codex exec --json` + resume-by-thread,
13
+ * with the command_execution / reasoning / agent_message item shapes below.
13
14
  */
14
15
  export interface CodexRuntimeConfig {
15
16
  /** Codex model id (`-m`). Omit to use the codex CLI's configured default. */