@agent-compose/sdk 0.5.9 → 0.7.0

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 (49) hide show
  1. package/dist/agent/agent-context.d.ts +1 -1
  2. package/dist/agent/agent-loop.d.ts +0 -8
  3. package/dist/agent/pause-client.d.ts +50 -0
  4. package/dist/index.d.ts +15 -6
  5. package/dist/index.js +537 -124
  6. package/dist/processors/ask-human.d.ts +30 -0
  7. package/dist/processors/ask-human.test.d.ts +1 -0
  8. package/dist/processors/gate-pause.d.ts +46 -0
  9. package/dist/processors/gate-pause.test.d.ts +1 -0
  10. package/dist/processors/index.d.ts +3 -0
  11. package/dist/runtimes/_cli-agent.d.ts +9 -0
  12. package/dist/runtimes/cursor.d.ts +9 -0
  13. package/dist/runtimes/droid.d.ts +9 -0
  14. package/dist/runtimes/openai-desktop.js +522 -122
  15. package/dist/runtimes/opencode.d.ts +25 -0
  16. package/dist/runtimes/vercel.js +11 -1
  17. package/dist/step-invocation/__tests__/background-invoker.test.d.ts +1 -0
  18. package/dist/step-invocation/index.d.ts +2 -1
  19. package/dist/step-invocation/invoker.d.ts +49 -0
  20. package/dist/step-invocation/protocol.d.ts +8 -0
  21. package/dist/types/runtime.d.ts +7 -0
  22. package/dist/types/sandbox.d.ts +54 -0
  23. package/dist/types/workflow.d.ts +12 -0
  24. package/dist/utils/errors.d.ts +9 -1
  25. package/package.json +1 -1
  26. package/src/agent/agent-context.ts +23 -16
  27. package/src/agent/agent-loop.ts +13 -33
  28. package/src/agent/pause-client.ts +108 -0
  29. package/src/agent/run-agent.ts +16 -7
  30. package/src/index.ts +27 -4
  31. package/src/processors/ask-human.ts +136 -0
  32. package/src/processors/gate-pause.ts +94 -0
  33. package/src/processors/index.ts +11 -0
  34. package/src/runtimes/_cli-agent.ts +13 -5
  35. package/src/runtimes/claude.ts +10 -6
  36. package/src/runtimes/cursor.ts +59 -0
  37. package/src/runtimes/droid.ts +63 -0
  38. package/src/runtimes/opencode.ts +61 -0
  39. package/src/sandbox.ts +78 -3
  40. package/src/step-invocation/index.ts +2 -1
  41. package/src/step-invocation/invoker.ts +359 -86
  42. package/src/step-invocation/protocol.ts +11 -0
  43. package/src/types/runtime.ts +7 -0
  44. package/src/types/sandbox.ts +53 -0
  45. package/src/types/workflow.ts +12 -0
  46. package/src/utils/errors.ts +19 -2
  47. package/dist/agent/local-pause-request.d.ts +0 -49
  48. package/src/agent/local-pause-request.ts +0 -90
  49. /package/dist/agent/{local-pause-request.test.d.ts → pause-client.test.d.ts} +0 -0
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Ask-human processor (ADR-0028).
3
+ *
4
+ * Makes "ask a human" a FIRST-CLASS agent affordance: when the agent calls the
5
+ * built-in `AskUserQuestion` tool, this short-circuits it into a SERVER pause
6
+ * (`requestPauseAndAwait`) — the run freezes (compute stops), the question +
7
+ * options land on the human's pause feed, and the human's answer comes back as
8
+ * the tool result. No `agentc pause` CLI for the model to remember, and no
9
+ * dependency on prompt discipline: the moment the agent asks, the run pauses.
10
+ *
11
+ * Loud by construction — the danger this fixes is a pause that SILENTLY doesn't
12
+ * happen (a stale in-sandbox CLI, a non-E2B substrate, an auth error) letting
13
+ * the agent proceed as if it had an answer:
14
+ * - pause cannot be created (server reject) → `Verdict.abort` ENDS the agent
15
+ * loop with a WorkflowError. The run fails loud; it never guesses an answer.
16
+ * - pause expires / is cancelled → the tool result says NO answer came and to
17
+ * not assume one.
18
+ *
19
+ * Lives in the shared `gateToolCall` chain, so one implementation covers every
20
+ * runtime (the Claude Agent SDK `PreToolUse` hook and the ACP permission path).
21
+ * No run credential in the env (local / non-sandbox) → no-op: `AskUserQuestion`
22
+ * passes through untouched so a dev invocation isn't hard-failed.
23
+ */
24
+ import type { Processor } from "./processor.js";
25
+ import type { GatePauseConnection } from "./gate-pause.js";
26
+ /** The Claude built-in tool an agent uses to ask the user a question. */
27
+ export declare const ASK_USER_QUESTION_TOOL = "AskUserQuestion";
28
+ export declare function createAskHumanProcessor(opts?: {
29
+ connection?: GatePauseConnection;
30
+ }): Processor;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Gate-pause processor (ADR-0028).
3
+ *
4
+ * A pre-tool gate that, when its `policy` flags a tool call as needing human
5
+ * approval, pauses the run as a SERVER operation (`requestPauseAndAwait`) and
6
+ * blocks until a human answers — then allows or denies the tool.
7
+ *
8
+ * It pauses through the server pause API (`requestPauseAndAwait`), so the pause
9
+ * is a server operation no `try/catch` can swallow. It does NOT use today's
10
+ * `ctx.pause`, which still throws `PauseSignal` — exactly the swallowable path
11
+ * ADR-0028 supersedes for agents. (Routing `ctx.pause` itself through this same
12
+ * server pause is the natural unification — ADR-0028 open question — at which
13
+ * point "the pause API" and "ctx.pause" become one thing.) Because it lives in
14
+ * the shared `gateToolCall` chain, one implementation covers every runtime — the
15
+ * Claude Agent SDK `PreToolUse` hook and the ACP `session/request_permission`
16
+ * path both route through it.
17
+ *
18
+ * Opt-in: the workflow/agent supplies the `policy` (which may be a heuristic or
19
+ * an async classifier agent). The connection defaults to the run credential in
20
+ * the sandbox env; absent it (local / non-sandbox), the gate is a no-op and
21
+ * tool calls pass through untouched.
22
+ */
23
+ import type { Processor, ProcessorContext, ToolCall } from "./processor.js";
24
+ export interface GatePauseApproval {
25
+ /** Human-readable question shown on the approval UI. */
26
+ reason: string;
27
+ /** Decision options the human picks from. Defaults to Approve / Deny. */
28
+ options?: Array<{
29
+ id: string;
30
+ label: string;
31
+ }>;
32
+ }
33
+ /** Decide whether a tool call needs human approval. Return `false` to let it
34
+ * through untouched, or an approval request to pause the run until a human
35
+ * answers. May be async (e.g. a small classifier agent). */
36
+ export type GatePausePolicy = (call: ToolCall, ctx: ProcessorContext) => (false | GatePauseApproval) | Promise<false | GatePauseApproval>;
37
+ export interface GatePauseConnection {
38
+ baseUrl: string;
39
+ token: string;
40
+ runId: string;
41
+ }
42
+ export declare function createGatePauseProcessor(opts: {
43
+ policy: GatePausePolicy;
44
+ /** Override the server connection (defaults to the sandbox run-credential env). */
45
+ connection?: GatePauseConnection;
46
+ }): Processor;
@@ -0,0 +1 @@
1
+ export {};
@@ -2,3 +2,6 @@ export type { Processor, ProcessorContext, ProcessorVerdict, ToolCall, } from ".
2
2
  export { Verdict } from "./processor.js";
3
3
  export { runProcessorChain } from "./runner.js";
4
4
  export { denyTools, humanApproval, requireScope, redactPattern, } from "./builtins.js";
5
+ export { createGatePauseProcessor } from "./gate-pause.js";
6
+ export type { GatePausePolicy, GatePauseApproval, GatePauseConnection } from "./gate-pause.js";
7
+ export { createAskHumanProcessor, ASK_USER_QUESTION_TOOL } from "./ask-human.js";
@@ -34,6 +34,15 @@ export declare function shellQuote(value: string): string;
34
34
  * route to JSONL exactly like a handshake error. Overridable via the env for
35
35
  * ops tuning; defaults sane. */
36
36
  export declare const ACP_HANDSHAKE_TIMEOUT_MS: number;
37
+ /** Idle deadline for a PROMPT TURN (distinct from the handshake gate above). A
38
+ * turn is killed only if it goes fully SILENT for this long — the deadline is
39
+ * re-armed on every streamed message, so a long, *streaming* turn never trips
40
+ * it. This must be generous: a reasoning model (GLM, gpt-5-codex) can think for
41
+ * tens of seconds between tool calls with no wire activity, which is NOT a hang.
42
+ * The 10s handshake timeout was far too tight here and killed live GLM turns
43
+ * mid-report. Only a genuinely wedged CLI (the Gemini-style hang) should trip
44
+ * this. Overridable via the env for ops tuning. */
45
+ export declare const ACP_TURN_IDLE_TIMEOUT_MS: number;
37
46
  /** Readiness gate for the LIVE ACP attempt. The duplex-stdin transport in
38
47
  * `spawnAcpProcess` is now real (`commands.spawnDuplex` on the local provider),
39
48
  * so the agent's `initialize` request bytes are delivered and the handshake can
@@ -0,0 +1,9 @@
1
+ import { type CliAgentSpec } from "./_cli-agent.js";
2
+ export declare const cursorSpec: CliAgentSpec;
3
+ export interface CursorRuntimeConfig {
4
+ /** Cursor model id; ACP mode ignores it (account default) — applies to the `-p` fallback. */
5
+ model?: string;
6
+ }
7
+ export declare function createCursorRuntime(config?: CursorRuntimeConfig): import("../index.js").AgentRuntime<import("../index.js").SandboxProvider>;
8
+ declare const _default: import("../index.js").AgentRuntime<import("../index.js").SandboxProvider>;
9
+ export default _default;
@@ -0,0 +1,9 @@
1
+ import { type CliAgentSpec } from "./_cli-agent.js";
2
+ export declare const droidSpec: CliAgentSpec;
3
+ export interface DroidRuntimeConfig {
4
+ /** `custom:<displayName>-<index>` matching the provisioned settings.json. */
5
+ model?: string;
6
+ }
7
+ export declare function createDroidRuntime(config?: DroidRuntimeConfig): import("../index.js").AgentRuntime<import("../index.js").SandboxProvider>;
8
+ declare const _default: import("../index.js").AgentRuntime<import("../index.js").SandboxProvider>;
9
+ export default _default;