@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.
- package/dist/agent/agent-context.d.ts +1 -1
- package/dist/agent/agent-loop.d.ts +0 -8
- package/dist/agent/pause-client.d.ts +50 -0
- package/dist/index.d.ts +15 -6
- package/dist/index.js +537 -124
- package/dist/processors/ask-human.d.ts +30 -0
- package/dist/processors/ask-human.test.d.ts +1 -0
- package/dist/processors/gate-pause.d.ts +46 -0
- package/dist/processors/gate-pause.test.d.ts +1 -0
- package/dist/processors/index.d.ts +3 -0
- package/dist/runtimes/_cli-agent.d.ts +9 -0
- package/dist/runtimes/cursor.d.ts +9 -0
- package/dist/runtimes/droid.d.ts +9 -0
- package/dist/runtimes/openai-desktop.js +522 -122
- package/dist/runtimes/opencode.d.ts +25 -0
- package/dist/runtimes/vercel.js +11 -1
- package/dist/step-invocation/__tests__/background-invoker.test.d.ts +1 -0
- package/dist/step-invocation/index.d.ts +2 -1
- package/dist/step-invocation/invoker.d.ts +49 -0
- package/dist/step-invocation/protocol.d.ts +8 -0
- package/dist/types/runtime.d.ts +7 -0
- package/dist/types/sandbox.d.ts +54 -0
- package/dist/types/workflow.d.ts +12 -0
- package/dist/utils/errors.d.ts +9 -1
- package/package.json +1 -1
- package/src/agent/agent-context.ts +23 -16
- package/src/agent/agent-loop.ts +13 -33
- package/src/agent/pause-client.ts +108 -0
- package/src/agent/run-agent.ts +16 -7
- package/src/index.ts +27 -4
- package/src/processors/ask-human.ts +136 -0
- package/src/processors/gate-pause.ts +94 -0
- package/src/processors/index.ts +11 -0
- package/src/runtimes/_cli-agent.ts +13 -5
- package/src/runtimes/claude.ts +10 -6
- package/src/runtimes/cursor.ts +59 -0
- package/src/runtimes/droid.ts +63 -0
- package/src/runtimes/opencode.ts +61 -0
- package/src/sandbox.ts +78 -3
- package/src/step-invocation/index.ts +2 -1
- package/src/step-invocation/invoker.ts +359 -86
- package/src/step-invocation/protocol.ts +11 -0
- package/src/types/runtime.ts +7 -0
- package/src/types/sandbox.ts +53 -0
- package/src/types/workflow.ts +12 -0
- package/src/utils/errors.ts +19 -2
- package/dist/agent/local-pause-request.d.ts +0 -49
- package/src/agent/local-pause-request.ts +0 -90
- /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;
|