stitchkit 0.129.0 → 0.130.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/CHANGELOG.md +26 -0
- package/dist/agent-executor/acp/v1-connect.d.ts +87 -19
- package/dist/agent-executor/acp/v1-connect.d.ts.map +1 -1
- package/dist/agent-executor/acp/v1-driver.d.ts +4 -2
- package/dist/agent-executor/acp/v1-driver.d.ts.map +1 -1
- package/dist/agent-executor/acp/v1-handlers.d.ts +56 -0
- package/dist/agent-executor/acp/v1-handlers.d.ts.map +1 -0
- package/dist/agent-executor/acp/v1-map.d.ts +13 -2
- package/dist/agent-executor/acp/v1-map.d.ts.map +1 -1
- package/dist/agent-executor/acp/v1-permission.d.ts +44 -0
- package/dist/agent-executor/acp/v1-permission.d.ts.map +1 -0
- package/dist/agent-executor/acp/v1-protocol.d.ts +63 -10
- package/dist/agent-executor/acp/v1-protocol.d.ts.map +1 -1
- package/dist/agent-executor/acp/v1-session.d.ts +34 -7
- package/dist/agent-executor/acp/v1-session.d.ts.map +1 -1
- package/dist/agent-executor/acp/v1-turn.d.ts +51 -13
- package/dist/agent-executor/acp/v1-turn.d.ts.map +1 -1
- package/dist/agent-executor/claude/classify.d.ts +10 -0
- package/dist/agent-executor/claude/classify.d.ts.map +1 -1
- package/dist/agent-executor/claude/cli-driver.d.ts +4 -1
- package/dist/agent-executor/claude/cli-driver.d.ts.map +1 -1
- package/dist/agent-executor/claude/events.d.ts +146 -0
- package/dist/agent-executor/claude/events.d.ts.map +1 -0
- package/dist/agent-executor/claude/limits.d.ts +7 -1
- package/dist/agent-executor/claude/limits.d.ts.map +1 -1
- package/dist/agent-executor/claude/protocol.d.ts +49 -9
- package/dist/agent-executor/claude/protocol.d.ts.map +1 -1
- package/dist/agent-executor/claude/session.d.ts +2 -0
- package/dist/agent-executor/claude/session.d.ts.map +1 -1
- package/dist/agent-executor/claude-sdk/controls.d.ts +10 -1
- package/dist/agent-executor/claude-sdk/controls.d.ts.map +1 -1
- package/dist/agent-executor/claude-sdk/driver.d.ts +97 -3
- package/dist/agent-executor/claude-sdk/driver.d.ts.map +1 -1
- package/dist/agent-executor/claude-sdk/probe.d.ts +29 -0
- package/dist/agent-executor/claude-sdk/probe.d.ts.map +1 -0
- package/dist/agent-executor/claude-sdk/query-loop.d.ts +53 -5
- package/dist/agent-executor/claude-sdk/query-loop.d.ts.map +1 -1
- package/dist/agent-executor/claude-sdk/query-options.d.ts +2 -0
- package/dist/agent-executor/claude-sdk/query-options.d.ts.map +1 -1
- package/dist/agent-executor/claude-sdk/session.d.ts +2 -3
- package/dist/agent-executor/claude-sdk/session.d.ts.map +1 -1
- package/dist/agent-executor/claude-sdk/turn-usage.d.ts +81 -0
- package/dist/agent-executor/claude-sdk/turn-usage.d.ts.map +1 -0
- package/dist/agent-executor/codex/classify.d.ts +4 -0
- package/dist/agent-executor/codex/classify.d.ts.map +1 -1
- package/dist/agent-executor/codex/connect.d.ts +2 -1
- package/dist/agent-executor/codex/connect.d.ts.map +1 -1
- package/dist/agent-executor/codex/control-client.d.ts +168 -0
- package/dist/agent-executor/codex/control-client.d.ts.map +1 -0
- package/dist/agent-executor/codex/driver.d.ts +22 -2
- package/dist/agent-executor/codex/driver.d.ts.map +1 -1
- package/dist/agent-executor/codex/handlers.d.ts +47 -0
- package/dist/agent-executor/codex/handlers.d.ts.map +1 -0
- package/dist/agent-executor/codex/limits.d.ts.map +1 -1
- package/dist/agent-executor/codex/protocol.d.ts +124 -0
- package/dist/agent-executor/codex/protocol.d.ts.map +1 -1
- package/dist/agent-executor/codex/request-answers.d.ts +101 -0
- package/dist/agent-executor/codex/request-answers.d.ts.map +1 -0
- package/dist/agent-executor/codex/session-controls.d.ts +91 -51
- package/dist/agent-executor/codex/session-controls.d.ts.map +1 -1
- package/dist/agent-executor/codex/session.d.ts +34 -12
- package/dist/agent-executor/codex/session.d.ts.map +1 -1
- package/dist/agent-executor/codex/shared-server.d.ts +29 -0
- package/dist/agent-executor/codex/shared-server.d.ts.map +1 -0
- package/dist/agent-executor/codex/shared-thread.d.ts +46 -0
- package/dist/agent-executor/codex/shared-thread.d.ts.map +1 -0
- package/dist/agent-executor/codex/thread-controls.d.ts +128 -0
- package/dist/agent-executor/codex/thread-controls.d.ts.map +1 -0
- package/dist/agent-executor/codex/turn-input.d.ts +30 -0
- package/dist/agent-executor/codex/turn-input.d.ts.map +1 -0
- package/dist/agent-executor/contract.d.ts +77 -0
- package/dist/agent-executor/contract.d.ts.map +1 -1
- package/dist/agent-executor/engine.d.ts +6 -2
- package/dist/agent-executor/engine.d.ts.map +1 -1
- package/dist/agent-executor/executor-contract.d.ts +54 -0
- package/dist/agent-executor/executor-contract.d.ts.map +1 -1
- package/dist/agent-executor/handoff-schemas.d.ts +407 -0
- package/dist/agent-executor/handoff-schemas.d.ts.map +1 -0
- package/dist/agent-executor/handoff.d.ts +12 -0
- package/dist/agent-executor/handoff.d.ts.map +1 -0
- package/dist/agent-executor/hello.d.ts +72 -0
- package/dist/agent-executor/hello.d.ts.map +1 -1
- package/dist/agent-executor/image-input.d.ts +22 -0
- package/dist/agent-executor/image-input.d.ts.map +1 -1
- package/dist/agent-executor/projection.d.ts +2 -2
- package/dist/agent-executor/projection.d.ts.map +1 -1
- package/dist/agent-executor/session-primitives.d.ts +10 -1
- package/dist/agent-executor/session-primitives.d.ts.map +1 -1
- package/dist/agent-executor/testing/conformance.d.ts.map +1 -1
- package/dist/agent-executor/testing/replay-driver.d.ts +41 -0
- package/dist/agent-executor/testing/replay-driver.d.ts.map +1 -0
- package/dist/agent-executor/testing/replay-gate.d.ts +11 -0
- package/dist/agent-executor/testing/replay-gate.d.ts.map +1 -0
- package/dist/agent-executor/testing/replay-runner.d.ts +27 -0
- package/dist/agent-executor/testing/replay-runner.d.ts.map +1 -0
- package/dist/agent-executor/testing/replay-scenarios.d.ts +21 -0
- package/dist/agent-executor/testing/replay-scenarios.d.ts.map +1 -0
- package/dist/agent-executor/testing/replay-transcript.d.ts +296 -0
- package/dist/agent-executor/testing/replay-transcript.d.ts.map +1 -0
- package/dist/agent-executor/vocabulary.d.ts +135 -0
- package/dist/agent-executor/vocabulary.d.ts.map +1 -1
- package/dist/agent-runtime/branch-provider.d.ts +2 -2
- package/dist/agent-runtime/deferred-tool-selection.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor/acp.d.ts +4 -1
- package/dist/entrypoints/agent-executor/acp.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor/acp.js +847 -214
- package/dist/entrypoints/agent-executor/claude-sdk.d.ts +5 -1
- package/dist/entrypoints/agent-executor/claude-sdk.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor/claude-sdk.js +713 -205
- package/dist/entrypoints/agent-executor/claude.js +44 -19
- package/dist/entrypoints/agent-executor/codex.d.ts +9 -2
- package/dist/entrypoints/agent-executor/codex.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor/codex.js +1775 -359
- package/dist/entrypoints/agent-executor/testing.d.ts +4 -0
- package/dist/entrypoints/agent-executor/testing.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor/testing.js +1002 -2
- package/dist/entrypoints/agent-executor.d.ts +4 -2
- package/dist/entrypoints/agent-executor.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor.js +411 -23
- package/dist/entrypoints/agent-runtime.js +4 -23
- package/dist/entrypoints/tools/mcp.d.ts +1 -0
- package/dist/entrypoints/tools/mcp.d.ts.map +1 -1
- package/dist/entrypoints/tools/mcp.js +1 -1
- package/dist/entrypoints/tools/toolkit.js +1 -1
- package/dist/{index-wv2amqm4.js → index-2s8sy57y.js} +36 -103
- package/dist/{index-afb6z77w.js → index-dbp6xemn.js} +75 -7
- package/dist/{index-bjmj2q1z.js → index-jrn3prgm.js} +1 -1
- package/dist/index-kne9g2c5.js +30 -0
- package/dist/index-p1qmpq0p.js +1300 -0
- package/dist/{index-7jqn3b3g.js → index-v759mzed.js} +152 -2
- package/dist/{index-cbhxhma2.js → index-x5ayy5bn.js} +1 -0
- package/dist/index-y0a4gt1s.js +142 -0
- package/dist/tools/internal/rank-tools.d.ts +10 -0
- package/dist/tools/internal/rank-tools.d.ts.map +1 -0
- package/dist/tools/mcp/handler.d.ts +7 -3
- package/dist/tools/mcp/handler.d.ts.map +1 -1
- package/dist/tools/mcp/lazy-discovery.d.ts +47 -0
- package/dist/tools/mcp/lazy-discovery.d.ts.map +1 -0
- package/dist/tools/mcp/mount.d.ts +7 -0
- package/dist/tools/mcp/mount.d.ts.map +1 -1
- package/dist/tools/mcp/register.d.ts +2 -2
- package/dist/tools/mcp/register.d.ts.map +1 -1
- package/llms/agent-executor-acp.txt +7 -8
- package/llms/agent-executor-claude-sdk.txt +4 -2
- package/llms/agent-executor-codex.txt +8 -4
- package/llms/agent-executor-testing.txt +5 -1
- package/llms/agent-executor.txt +7 -6
- package/llms/stitchkit.txt +74 -74
- package/llms/tools-mcp.txt +3 -2
- package/llms/tools.txt +24 -0
- package/llms/{upgrading-0.128.0-0.129.0.txt → upgrading-0.128.0-0.130.0.txt} +30 -3
- package/llms/upgrading.txt +1 -1
- package/llms-full.txt +159 -97
- package/llms.txt +8 -8
- package/package.json +1 -1
- package/dist/index-y71zn1gw.js +0 -586
package/CHANGELOG.md
CHANGED
|
@@ -15,6 +15,32 @@ additive**; the first breaking change landed in 0.10.0. Grep the file for
|
|
|
15
15
|
|
|
16
16
|
## [Unreleased]
|
|
17
17
|
|
|
18
|
+
## [0.130.0] - 2026-11-26
|
|
19
|
+
|
|
20
|
+
### ⚠️ Breaking changes
|
|
21
|
+
|
|
22
|
+
**Who must act:** every caller of `stitchkit/agent-executor` that switches exhaustively on `ExecutorDelta['type']` or forwards `status` deltas to a `0.129.0` server ([migration](docs/guide/upgrading.md#executor-status-delta)).
|
|
23
|
+
|
|
24
|
+
- `stitchkit/agent-executor` — widened `ExecutorDeltaSchema` / `ExecutorDelta` with `ExecutorStatusDeltaSchema` (`{ type: 'status', phase: 'spawning' | 'initializing' | 'verifying', ... }`) so executor startup lifecycle progress can be observed in-band alongside `onStartupPhase` callbacks. Exhaustive `switch (delta.type)` consumers must handle `case 'status':` (ignored by `projectExecutorDeltas`).
|
|
25
|
+
`switch (delta.type) { … case 'window': break; }` → `switch (delta.type) { … case 'status': case 'window': break; }`.
|
|
26
|
+
**Affects:** `stitchkit/agent-executor` ExecutorDeltaSchema, ExecutorDelta, ExecutorStatusDeltaSchema, projectExecutorDeltas
|
|
27
|
+
|
|
28
|
+
### Added
|
|
29
|
+
|
|
30
|
+
- `stitchkit/agent-executor` — extended `InteractionReplySchema` with optional `scope: 'once' | 'session'` and `updatedInput` on `approve` and optional `interrupt: boolean` on `deny`, extended `ExecutorUsageDeltaSchema` with optional `cacheCreationInputTokens`, `thinkingTokens`, `totalTokens`, cumulative `total` (`ExecutorTokenUsageSchema`), and per-model `modelUsage` (`ExecutorModelUsageSchema`, bounded to 64 models), added declarative `ExecutorDriverCapabilitiesSchema` (`capabilities` on drivers and `ExecutorEngineInfoSchema`, validated by `runAgentEngineConformance`), `ExecutorThreadDispositionSchema` (`threadDisposition: 'reusable' | 'broken'` on `turn-end` and `TurnReportSchema.failure`), `ExecutorStartupPhaseSchema` (`onStartupPhase` on driver `open` / `connectControl` / `openSharedServer`), and the pure portable context-handoff builder (`buildContextHandoff`, `withInlineHandoffContext`, and `ContextHandoff*` schemas).
|
|
31
|
+
- `stitchkit/agent-executor/acp` — added ACP v1 protocol compatibility (`protocolVersion >= 1` accepted while ACP v2 `"info"` responses are refused), `clientInfo`, `sessionMeta`, `stdoutLineFilter`, `probeMode` (`'ephemeral-session' | 'initialize-only' | 'passive'`) / `passiveVersion`, `session/delete` fallback on ephemeral probe cleanup, `transformUpdate`, post-settle `onUpdate` / `onPermissionRequest` / `session.respond()`, `onDisconnect`, `watchPromptOutcome` (`AcpPromptOutcomeOverride` with `threadDisposition`), `usageInputIncludesCachedRead` + `cachedWriteTokens` / `thoughtTokens` / `totalTokens` mapping, `steerMode: 'prompt'` + `session.steerTurn()`, `allow_always` (`scope: 'session'`) and `{ kind: 'input', value: { optionId } }` permission replies (with fail-closed `updatedInput` refusal), and per-open `model` / `thoughtLevel` / `mode` overrides with `session/set_model` fallback.
|
|
32
|
+
- `stitchkit/agent-executor/claude`, `stitchkit/agent-executor/claude-sdk` — added active plan-limit pulling via `ClaudeSdkSession.readUsage(opts?)` (`ClaudeSdkUsageRead`), session-scoped `addRules` (`destination: 'session'`) and turn-cancelling `deny` (`interrupt: true`) on `canUseTool` and Claude CLI `control_request` approvals (with fail-closed checks on raw tool names and `suppressAlwaysAllowRule`), `approve.updatedInput` for `AskUserQuestion` and structured `onPermissionRequest` (`ClaudeSdkPermissionRequestMeta` for `ExitPlanMode` / safety metadata), `onElicitation`, `setMcpServers` / `stopTask` / `backgroundTasks`, `onEvent` (`ClaudeRuntimeEventSchema`) + `compact_boundary` → `window { reset: 'context' }`, additive per-turn `onTurnUsage` (`ClaudeSdkTurnUsageSchema`), isolated `driver.probeCapabilities()` (`ClaudeSdkCapabilitiesProbe`), `resumeSessionAt` / `resumeDropsTurn` on `ClaudeSdkOpenInput`, per-model `modelUsage` / `cache_creation_input_tokens` / `thinking_tokens` preservation on `result` records, and `ClaudeSdkDriverConfig.onQueryExit` (`ClaudeSdkQueryExitContext`).
|
|
33
|
+
- `stitchkit/agent-executor/codex` — added external turn and request observation (`onNotification`, `onServerRequest`, `onDisconnect` on `CodexDriverConfig`, bounded external request tracking without `-32601` for the 5 handled v2 server requests — `item/commandExecution/requestApproval`, `item/fileChange/requestApproval`, `item/permissions/requestApproval`, `item/tool/requestUserInput`, and `mcpServer/elicitation/request` — and unified `respond()` on `CodexSession` / `CodexControlConnection` with fail-closed `updatedInput` refusal and fail-closed `deny.interrupt` refusal on `item/permissions/requestApproval`), threadless `driver.connectControl(input)` connections, opt-in headless `stdio` multi-thread server `driver.openSharedServer()` (`CodexSharedServer`, ADR 0329), live `readThread`, `listThreads`, `listLoadedThreads`, `listCollaborationModes`, `listTurns`, `listItems`, `archiveThread`, `unarchiveThread`, `unsubscribeThread`, `setThreadName`, `updateThreadMetadata`, `revertThread` (`thread/revert`), and `injectItems` (`thread/inject_items`) RPCs, ordered `CodexSkillInput` (`{ type: 'skill', name, path }`) turn and steer inputs, `open({ forkFrom })` and `deferGoalContinuation` on `thread/fork`, full `item/tool/requestUserInput` metadata (`header`, `options`, `isOther`, `isSecret`), approval metadata and `availableDecisions`-checked `acceptForSession` / `cancel` responses, cumulative `tokenUsage.total` mapping, and `app/list/updated` notification opt-out.
|
|
34
|
+
- `stitchkit/agent-executor/testing` — added the in-process, zero-subprocess deterministic replay driver (`createReplayExecutorDriver`, `createReplayGate`, `REPLAY_SCENARIOS`, `unpackReplayScenario`, `replayDialectScenarios`, `parseReplayTranscript`, `formatReplayTranscript`, and `ExecutorReplayTranscriptSchema` / `ExecutorReplayStepSchema`).
|
|
35
|
+
- `stitchkit/tools/mcp` — added opt-in lazy tool discovery (`discovery: McpLazyDiscoveryConfig` on stateful `mountMcp`, `buildMcpServer`, and `createStdioMcpServer`; refused on stateless `createMcpHandler`), keeping non-initial contract tools disabled at startup, exposing `tool_search`, revealing matched tools per session with a single `notifications/tools/list_changed`, and enforcing identical `access` policies and catalog stamps.
|
|
36
|
+
|
|
37
|
+
### Fixed
|
|
38
|
+
|
|
39
|
+
- `stitchkit/agent-executor/claude-sdk` `createClaudeSdkDriver` now distinguishes unexpected idle EOF from mid-turn EOF when reporting query termination, and notifies `onQueryExit` after clearing live session state without firing on caller `close()`, caller abort, or failed `open()`.
|
|
40
|
+
**Affects:** `stitchkit/agent-executor/claude-sdk` createClaudeSdkDriver(open)
|
|
41
|
+
- `stitchkit/agent-executor/codex` `createCodexDriver` now guards `stdio` transport startup readiness and rechecks early process exit after `pidReady` on both `stdio` and Unix-socket transports, preventing dropped fatal exit errors during handshake.
|
|
42
|
+
**Affects:** `stitchkit/agent-executor/codex` createCodexDriver(open, connectControl)
|
|
43
|
+
|
|
18
44
|
## [0.129.0] - 2026-11-25
|
|
19
45
|
|
|
20
46
|
### ⚠️ Breaking changes
|
|
@@ -1,12 +1,53 @@
|
|
|
1
|
-
import { createJsonRpcPeer } from '../json-rpc-peer.js';
|
|
1
|
+
import { createJsonRpcPeer, type JsonRpcValue } from '../json-rpc-peer.js';
|
|
2
2
|
import { type ExecutorProfileConfig } from '../profile.js';
|
|
3
|
-
import type {
|
|
3
|
+
import type { ExecutorErrorKind, ExecutorStartupPhase, ExecutorThreadDisposition } from '../vocabulary.js';
|
|
4
|
+
import type { AcpPermissionRequestEvent, AcpTransformUpdate, AcpUpdateEvent } from './v1-handlers.js';
|
|
5
|
+
import { type AcpClientInfo, type AcpInitializeResult, type AcpMcpServer, type AcpPromptResult } from './v1-protocol.js';
|
|
6
|
+
/** How `info()` and `status()` probe the ACP agent. */
|
|
7
|
+
export type AcpProbeMode = 'ephemeral-session' | 'initialize-only' | 'passive';
|
|
8
|
+
/** How {@link AcpSession.steerTurn} steers a running turn. */
|
|
9
|
+
export type AcpSteerMode = 'none' | 'prompt';
|
|
10
|
+
/** Optional `_meta` object passed on `session/new`, `session/resume`, and `session/load`. */
|
|
11
|
+
export type AcpSessionMetaInput = Readonly<Record<string, JsonRpcValue>> | ((initialized: AcpInitializeResult) => Readonly<Record<string, JsonRpcValue>> | undefined);
|
|
12
|
+
/** Structured failure override returned by {@link AcpWatchPromptOutcome} to reclassify a prompt response. */
|
|
13
|
+
export interface AcpPromptOutcomeOverride {
|
|
14
|
+
readonly outcome?: 'failed';
|
|
15
|
+
readonly errorKind: ExecutorErrorKind;
|
|
16
|
+
readonly message: string;
|
|
17
|
+
readonly threadDisposition?: ExecutorThreadDisposition;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Optional hook run before each `session/prompt` request; returns a checker invoked once the
|
|
21
|
+
* prompt settles so host-side inspection can detect failures masked behind `stopReason: "end_turn"`.
|
|
22
|
+
*/
|
|
23
|
+
export type AcpWatchPromptOutcome = (context: {
|
|
24
|
+
readonly sessionId: string;
|
|
25
|
+
readonly turnId: string;
|
|
26
|
+
readonly generation: number;
|
|
27
|
+
}) => Promise<(result: AcpPromptResult) => Promise<AcpPromptOutcomeOverride | undefined> | AcpPromptOutcomeOverride | undefined> | ((result: AcpPromptResult) => Promise<AcpPromptOutcomeOverride | undefined> | AcpPromptOutcomeOverride | undefined);
|
|
4
28
|
/** Configuration for {@link createAcpDriver}. */
|
|
5
29
|
export interface AcpDriverConfig {
|
|
6
30
|
/** The agent to run: `agy`, `gemini`. */
|
|
7
31
|
executable: string;
|
|
8
32
|
/** Its arguments: `['acp']`, `['acp', '--sandbox']`, `['--experimental-acp']`. */
|
|
9
33
|
args?: readonly string[];
|
|
34
|
+
/** Optional `clientInfo` sent on `initialize`. */
|
|
35
|
+
clientInfo?: AcpClientInfo;
|
|
36
|
+
/** Optional `_meta` object (or factory over the `initialize` response) sent on session open/resume/load. */
|
|
37
|
+
sessionMeta?: AcpSessionMetaInput;
|
|
38
|
+
/**
|
|
39
|
+
* Optional filter invoked on every stdout line before JSON-RPC parsing; returning `false`
|
|
40
|
+
* skips non-protocol lines (such as OAuth prompts) instead of failing the connection.
|
|
41
|
+
*/
|
|
42
|
+
stdoutLineFilter?: (line: string) => boolean;
|
|
43
|
+
/**
|
|
44
|
+
* How `info()` and `status()` probe the agent: `'ephemeral-session'` (default, runs `initialize`
|
|
45
|
+
* and an ephemeral `session/new`), `'initialize-only'` (skips `session/new`), or `'passive'`
|
|
46
|
+
* (spawns zero processes and reports honest `unknown`/`not-asked`).
|
|
47
|
+
*/
|
|
48
|
+
probeMode?: AcpProbeMode;
|
|
49
|
+
/** Version reported by `info()` when `probeMode` is `'passive'` (defaults to `'unknown'`). */
|
|
50
|
+
passiveVersion?: string;
|
|
10
51
|
/** Set at open through the option of category `model`; refused if the agent offers none or not this value. */
|
|
11
52
|
model?: string;
|
|
12
53
|
/** Set at open through the option of category `thought_level`, after the model, which may narrow it. */
|
|
@@ -15,14 +56,34 @@ export interface AcpDriverConfig {
|
|
|
15
56
|
* Set at open through the option of category `mode`. Negotiates the agent's advertised mode
|
|
16
57
|
* value only; it does not enforce host-side pre-execution tool approval (`approvalEnforcement`
|
|
17
58
|
* is `'agent-initiated'`). Whether an agent sends `session/request_permission` before a tool
|
|
18
|
-
* runs depends on the agent's own permission policy
|
|
19
|
-
* `--cli_dir_name <subdir>` with `{"toolPermission":"strict","agentMode":""}` in
|
|
20
|
-
* `~/.gemini/antigravity-cli/<subdir>/settings.json`, which prompts before every tool action
|
|
21
|
-
* including reads).
|
|
59
|
+
* runs depends on the agent's own permission policy.
|
|
22
60
|
*/
|
|
23
61
|
mode?: string;
|
|
24
62
|
/** MCP servers the agent connects to, passed on `session/new`, `session/load` and `session/resume`. */
|
|
25
63
|
mcpServers?: readonly AcpMcpServer[];
|
|
64
|
+
/** Optional transformer normalizing, expanding, or dropping incoming `session/update` records before mapping. */
|
|
65
|
+
transformUpdate?: AcpTransformUpdate;
|
|
66
|
+
/** Optional observer invoked for `session/update` notifications on an open session (including post-settle). */
|
|
67
|
+
onUpdate?: (event: AcpUpdateEvent) => void;
|
|
68
|
+
/**
|
|
69
|
+
* Optional handler for `session/request_permission` arriving outside an active `startTurn()`.
|
|
70
|
+
* When omitted, requests outside an active turn are refused with `-32601`.
|
|
71
|
+
*/
|
|
72
|
+
onPermissionRequest?: (event: AcpPermissionRequestEvent) => Promise<void> | void;
|
|
73
|
+
/** Optional callback invoked when an opened session drops unexpectedly before `close()` or caller abort. */
|
|
74
|
+
onDisconnect?: (error: Error) => void;
|
|
75
|
+
/**
|
|
76
|
+
* Optional hook started before `session/prompt` and consulted after it settles so hidden API
|
|
77
|
+
* errors masked as `end_turn` can fail the turn with an error kind and `threadDisposition`.
|
|
78
|
+
*/
|
|
79
|
+
watchPromptOutcome?: AcpWatchPromptOutcome;
|
|
80
|
+
/**
|
|
81
|
+
* Whether the agent's `usage.inputTokens` already includes `cachedReadTokens`. Default `true`.
|
|
82
|
+
* Set `false` for agents that report uncached input separately so `cachedReadTokens` is added.
|
|
83
|
+
*/
|
|
84
|
+
usageInputIncludesCachedRead?: boolean;
|
|
85
|
+
/** Whether `session.steerTurn()` is disabled (`'none'`, default) or steers via a new `session/prompt` (`'prompt'`). */
|
|
86
|
+
steerMode?: AcpSteerMode;
|
|
26
87
|
/** The bytes behind a `file` part's `reference`; without it a file part is refused. */
|
|
27
88
|
resolveFile?: (reference: string) => Promise<Uint8Array>;
|
|
28
89
|
/** The largest image sent. Default 5 MiB. */
|
|
@@ -33,23 +94,26 @@ export interface AcpDriverConfig {
|
|
|
33
94
|
/** How long one request (`initialize`, `session/new`) may take. Default 60 s. */
|
|
34
95
|
requestTimeoutMs?: number;
|
|
35
96
|
}
|
|
36
|
-
/** Bounded timeout for `session/close`: capped at 5 s and never longer than `requestTimeoutMs`. */
|
|
97
|
+
/** Bounded timeout for `session/close` and `session/delete`: capped at 5 s and never longer than `requestTimeoutMs`. */
|
|
37
98
|
export declare function closeRequestTimeoutMs(config: Pick<AcpDriverConfig, 'requestTimeoutMs'>): number;
|
|
38
|
-
/**
|
|
99
|
+
/** Resolve and validate optional `_meta` for `session/new`, `session/resume`, or `session/load`. */
|
|
100
|
+
export declare function resolveAcpSessionMeta(sessionMeta: AcpSessionMetaInput | undefined, initialized: AcpInitializeResult): Record<string, JsonRpcValue> | undefined;
|
|
101
|
+
/** Refuse invalid options before any agent is spawned. */
|
|
39
102
|
export declare function assertAcpDriverOptions(config: AcpDriverConfig): void;
|
|
40
103
|
export type AcpHandlers = {
|
|
41
104
|
onRequest?: Parameters<typeof createJsonRpcPeer>[0]['onRequest'];
|
|
42
105
|
onNotification?: Parameters<typeof createJsonRpcPeer>[0]['onNotification'];
|
|
43
106
|
onEnd?: (error: Error) => void;
|
|
107
|
+
onStartupPhase?: (phase: ExecutorStartupPhase) => void;
|
|
44
108
|
};
|
|
45
|
-
/** Spawn the agent and
|
|
109
|
+
/** Spawn the agent and perform the ACP v1 handshake; ACP v2 (`"info" in raw`) or version < 1 is refused. */
|
|
46
110
|
export declare function connectAcp(config: AcpDriverConfig, profile: ExecutorProfileConfig, cwd: string, signal: AbortSignal, handlers?: AcpHandlers): Promise<{
|
|
47
111
|
engine: import("../engine-process.js").EngineProcess;
|
|
48
112
|
peer: {
|
|
49
|
-
request(method: string, params?:
|
|
113
|
+
request(method: string, params?: JsonRpcValue, options?: {
|
|
50
114
|
readonly timeoutMs?: number | null;
|
|
51
|
-
}): Promise<
|
|
52
|
-
notify(method: string, params?:
|
|
115
|
+
}): Promise<JsonRpcValue>;
|
|
116
|
+
notify(method: string, params?: JsonRpcValue): void;
|
|
53
117
|
receive(line: string): void;
|
|
54
118
|
close(reason?: unknown): void;
|
|
55
119
|
};
|
|
@@ -68,23 +132,27 @@ export declare function connectAcp(config: AcpDriverConfig, profile: ExecutorPro
|
|
|
68
132
|
[x: string]: unknown;
|
|
69
133
|
resume?: boolean | {
|
|
70
134
|
[x: string]: unknown;
|
|
71
|
-
} | undefined;
|
|
135
|
+
} | null | undefined;
|
|
72
136
|
load?: boolean | {
|
|
73
137
|
[x: string]: unknown;
|
|
74
|
-
} | undefined;
|
|
138
|
+
} | null | undefined;
|
|
75
139
|
list?: boolean | {
|
|
76
140
|
[x: string]: unknown;
|
|
77
|
-
} | undefined;
|
|
141
|
+
} | null | undefined;
|
|
78
142
|
close?: boolean | {
|
|
79
143
|
[x: string]: unknown;
|
|
80
|
-
} | undefined;
|
|
144
|
+
} | null | undefined;
|
|
145
|
+
delete?: boolean | {
|
|
146
|
+
[x: string]: unknown;
|
|
147
|
+
} | null | undefined;
|
|
81
148
|
} | undefined;
|
|
82
149
|
} | undefined;
|
|
83
150
|
agentInfo?: {
|
|
84
151
|
[x: string]: unknown;
|
|
85
152
|
name?: string | undefined;
|
|
153
|
+
title?: string | null | undefined;
|
|
86
154
|
version?: string | undefined;
|
|
87
|
-
} | undefined;
|
|
155
|
+
} | null | undefined;
|
|
88
156
|
authMethods?: {
|
|
89
157
|
[x: string]: unknown;
|
|
90
158
|
id: string;
|
|
@@ -92,6 +160,6 @@ export declare function connectAcp(config: AcpDriverConfig, profile: ExecutorPro
|
|
|
92
160
|
};
|
|
93
161
|
}>;
|
|
94
162
|
export type AcpConnection = Awaited<ReturnType<typeof connectAcp>>;
|
|
95
|
-
/** Whether the agent declared a session capability (`resume`, `list`): `{}` or `true`. */
|
|
96
|
-
export declare function acpCan(connection: AcpConnection, capability: 'resume' | 'load' | 'list' | 'close'): boolean;
|
|
163
|
+
/** Whether the agent declared a session capability (`resume`, `load`, `list`, `close`, `delete`): `{}` or `true`. */
|
|
164
|
+
export declare function acpCan(connection: AcpConnection, capability: 'resume' | 'load' | 'list' | 'close' | 'delete'): boolean;
|
|
97
165
|
//# sourceMappingURL=v1-connect.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"v1-connect.d.ts","sourceRoot":"","sources":["../../../src/agent-executor/acp/v1-connect.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"v1-connect.d.ts","sourceRoot":"","sources":["../../../src/agent-executor/acp/v1-connect.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,iBAAiB,EAAoB,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC1F,OAAO,EAAE,KAAK,qBAAqB,EAAqB,MAAM,YAAY,CAAC;AAE3E,OAAO,KAAK,EACV,iBAAiB,EACjB,oBAAoB,EACpB,yBAAyB,EAC1B,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EACV,yBAAyB,EACzB,kBAAkB,EAClB,cAAc,EACf,MAAM,eAAe,CAAC;AACvB,OAAO,EAEL,KAAK,aAAa,EAElB,KAAK,mBAAmB,EAExB,KAAK,YAAY,EACjB,KAAK,eAAe,EACrB,MAAM,eAAe,CAAC;AAOvB,uDAAuD;AACvD,MAAM,MAAM,YAAY,GAAG,mBAAmB,GAAG,iBAAiB,GAAG,SAAS,CAAC;AAE/E,8DAA8D;AAC9D,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,QAAQ,CAAC;AAE7C,6FAA6F;AAC7F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'../hello.js';
|
|
2
3
|
import { type ExecutorProfileConfig } from '../profile.js';
|
|
3
4
|
import { type AcpDriverConfig } from './v1-connect.js';
|
|
4
|
-
import { type AcpApprovalEnforcement, type AcpSession } from './v1-session.js';
|
|
5
|
+
import { type AcpApprovalEnforcement, type AcpOpenInput, type AcpSession } from './v1-session.js';
|
|
5
6
|
export type { AcpDriverConfig } from './v1-connect.js';
|
|
6
7
|
export type { AcpApprovalEnforcement, AcpSession } from './v1-session.js';
|
|
7
8
|
/** A session the agent keeps, as `session/list` answers. */
|
|
@@ -13,13 +14,14 @@ export interface AcpSessionSummary {
|
|
|
13
14
|
}
|
|
14
15
|
/** An {@link AgentEngineDriver} speaking ACP v1, adding session listing and session config options. */
|
|
15
16
|
export interface AcpDriver extends AgentEngineDriver {
|
|
17
|
+
readonly capabilities: ExecutorDriverCapabilities;
|
|
16
18
|
/**
|
|
17
19
|
* How tool approvals are enforced over ACP: always `'agent-initiated'`. The host answers
|
|
18
20
|
* `session/request_permission` requests only when the agent chooses to send them and never
|
|
19
21
|
* synthesizes approvals for unprompted tool calls.
|
|
20
22
|
*/
|
|
21
23
|
readonly approvalEnforcement: AcpApprovalEnforcement;
|
|
22
|
-
open(input:
|
|
24
|
+
open(input: AcpOpenInput): Promise<AcpSession>;
|
|
23
25
|
/** The sessions the agent keeps for a working directory; refused if it does not declare `list`. */
|
|
24
26
|
sessions(input: {
|
|
25
27
|
profile: ExecutorProfileConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"v1-driver.d.ts","sourceRoot":"","sources":["../../../src/agent-executor/acp/v1-driver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"v1-driver.d.ts","sourceRoot":"","sources":["../../../src/agent-executor/acp/v1-driver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,KAAK,EAAE,0BAA0B,EAAsB,MAAM,UAAU,CAAC;AAC/E,OAAO,EAAE,KAAK,qBAAqB,EAAiB,MAAM,YAAY,CAAC;AAEvE,OAAO,EAEL,KAAK,eAAe,EAKrB,MAAM,cAAc,CAAC;AAOtB,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,YAAY,EACjB,KAAK,UAAU,EAEhB,MAAM,cAAc,CAAC;AAEtB,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,YAAY,EAAE,sBAAsB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAEvE,4DAA4D;AAC5D,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,uGAAuG;AACvG,MAAM,WAAW,SAAU,SAAQ,iBAAiB;IAClD,QAAQ,CAAC,YAAY,EAAE,0BAA0B,CAAC;IAClD;;;;OAIG;IACH,QAAQ,CAAC,mBAAmB,EAAE,sBAAsB,CAAC;IACrD,IAAI,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAC/C,mGAAmG;IACnG,QAAQ,CAAC,KAAK,EAAE;QACd,OAAO,EAAE,qBAAqB,CAAC;QAC/B,GAAG,EAAE,MAAM,CAAC;KACb,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAAC;CAClC;AAqDD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,eAAe,GAAG,SAAS,CAyHlE"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { InteractionReply } from '../executor-contract.js';
|
|
2
|
+
import { type JsonRpcValue } from '../json-rpc-peer.js';
|
|
3
|
+
import type { ExecutorDelta } from '../vocabulary.js';
|
|
4
|
+
import { type PendingExternalAcpRequest } from './v1-permission.js';
|
|
5
|
+
import { type AcpConfigOption, type AcpPermissionRequest, type AcpSessionUpdate } from './v1-protocol.js';
|
|
6
|
+
import type { AcpTurnSlot } from './v1-turn.js';
|
|
7
|
+
/** Optional hook normalizing, expanding, or dropping one incoming `session/update` before mapping. */
|
|
8
|
+
export type AcpTransformUpdate = (update: AcpSessionUpdate) => AcpSessionUpdate | readonly AcpSessionUpdate[] | null | undefined;
|
|
9
|
+
/** `session/update` notification observed on an open ACP session (during or after `startTurn()`). */
|
|
10
|
+
export interface AcpUpdateEvent {
|
|
11
|
+
/** Session identifier carried on the notification. */
|
|
12
|
+
readonly sessionId: string;
|
|
13
|
+
/** The normalized ACP `session/update` payload (after `transformUpdate`, if configured). */
|
|
14
|
+
readonly update: AcpSessionUpdate;
|
|
15
|
+
/** `true` when a driver-initiated `startTurn()` owned the session as this update arrived. */
|
|
16
|
+
readonly duringActiveTurn: boolean;
|
|
17
|
+
/** Normalized executor deltas produced for this update. */
|
|
18
|
+
readonly deltas: readonly ExecutorDelta[];
|
|
19
|
+
}
|
|
20
|
+
/** `session/request_permission` received outside an active `startTurn()` (post-settle background work). */
|
|
21
|
+
export interface AcpPermissionRequestEvent {
|
|
22
|
+
/** JSON-RPC request identifier as a string, also carried on `delta.interactionId`. */
|
|
23
|
+
readonly interactionId: string;
|
|
24
|
+
/** Session identifier carried on the permission request. */
|
|
25
|
+
readonly sessionId: string;
|
|
26
|
+
/** Parsed ACP permission request payload including `toolCall` and full `options`. */
|
|
27
|
+
readonly request: AcpPermissionRequest;
|
|
28
|
+
/** Normalized executor `request` delta preserving tool input and option metadata. */
|
|
29
|
+
readonly delta: Extract<ExecutorDelta, {
|
|
30
|
+
type: 'request';
|
|
31
|
+
}>;
|
|
32
|
+
/** Answer this post-settle permission request once; throws `TypeError` if invalid or already resolved. */
|
|
33
|
+
respond(reply: InteractionReply['reply']): Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
interface AcpHandlersState {
|
|
36
|
+
externalPending: Map<string, PendingExternalAcpRequest>;
|
|
37
|
+
isOpened: () => boolean;
|
|
38
|
+
getTurn: () => AcpTurnSlot | undefined;
|
|
39
|
+
onSessionMeta: (meta: {
|
|
40
|
+
configOptions?: readonly AcpConfigOption[];
|
|
41
|
+
title?: string;
|
|
42
|
+
commands?: readonly string[];
|
|
43
|
+
}) => void;
|
|
44
|
+
transformUpdate?: AcpTransformUpdate;
|
|
45
|
+
onUpdate?: (event: AcpUpdateEvent) => void;
|
|
46
|
+
onPermissionRequest?: (event: AcpPermissionRequestEvent) => Promise<void> | void;
|
|
47
|
+
onEnd: (error: Error) => void;
|
|
48
|
+
}
|
|
49
|
+
/** Create JSON-RPC notification, permission-request, and disconnect handlers for an ACP session. */
|
|
50
|
+
export declare function createAcpHandlers(state: AcpHandlersState): {
|
|
51
|
+
onNotification: (method: string, params: JsonRpcValue | undefined) => void;
|
|
52
|
+
onRequest: (method: string, params: JsonRpcValue | undefined, id: string | number) => Promise<import("zod").JSONType>;
|
|
53
|
+
onEnd: (error: Error) => void;
|
|
54
|
+
};
|
|
55
|
+
export {};
|
|
56
|
+
//# sourceMappingURL=v1-handlers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"v1-handlers.d.ts","sourceRoot":"","sources":["../../../src/agent-executor/acp/v1-handlers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC7D,OAAO,EAA2C,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAE9F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,EAIL,KAAK,yBAAyB,EAC/B,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,oBAAoB,EAEzB,KAAK,gBAAgB,EAGtB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAK7C,sGAAsG;AACtG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IAAI,CAAC;IACX,eAAe,CAAC,EAAE,kBAAkB,CAAC;IACrC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;IAC3C,mBAAmB,CAAC,EAAE,CAAC,KAAK,EAAE,yBAAyB,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACjF,KAAK,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAC/B;AAuND,oGAAoG;AACpG,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,gBAAgB;IAMrD,cAAc,WAAW,MAAM,UAAU,YAAY,GAAG,SAAS;IAEjE,SAAS,WAAW,MAAM,UAAU,YAAY,GAAG,SAAS,MAAM,MAAM,GAAG,MAAM;IAEjF,KAAK,UAnOQ,KAAK,KAAK,IAAI;EAqO9B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AgentMessagePart } from '../../agent-parts/parts.js';
|
|
2
|
-
import type { ExecutorDelta, ExecutorErrorKind } from '../vocabulary.js';
|
|
3
|
-
import type { AcpSessionUpdate } from './v1-protocol.js';
|
|
2
|
+
import type { ExecutorDelta, ExecutorErrorKind, ExecutorTokenUsage } from '../vocabulary.js';
|
|
3
|
+
import type { AcpPromptUsage, AcpSessionUpdate } from './v1-protocol.js';
|
|
4
4
|
/**
|
|
5
5
|
* Classify a JSON-RPC refusal from an ACP agent into a structured executor
|
|
6
6
|
* error kind (`rateLimited` or `authRequired`), or `undefined` when it is a
|
|
@@ -22,6 +22,17 @@ export interface AcpUpdateTrack {
|
|
|
22
22
|
export declare function mapAcpUpdate(update: AcpSessionUpdate, turnId: string, chunk: number, track?: AcpUpdateTrack): ExecutorDelta[];
|
|
23
23
|
/** How a prompt's stop reason ends the turn; asked to stop, a turn ends interrupted whatever the agent says. */
|
|
24
24
|
export declare function acpOutcome(stopReason: string, interruptRequested: boolean): 'completed' | 'interrupted' | 'failed';
|
|
25
|
+
/**
|
|
26
|
+
* Normalize one ACP prompt `usage` object into executor token counters, preserving
|
|
27
|
+
* `cachedWriteTokens`, `thoughtTokens`, and `totalTokens`. When `usageInputIncludesCachedRead`
|
|
28
|
+
* is `false`, adds `cachedReadTokens` onto `inputTokens` so total input reflects both uncached
|
|
29
|
+
* and cache-read tokens.
|
|
30
|
+
*/
|
|
31
|
+
export declare function normalizeAcpUsage(usage: AcpPromptUsage, options?: {
|
|
32
|
+
readonly usageInputIncludesCachedRead?: boolean;
|
|
33
|
+
}): ExecutorTokenUsage;
|
|
34
|
+
/** Accumulate normalized token counters across multiple prompt generations of one steered turn. */
|
|
35
|
+
export declare function addAcpTokenUsage(total: ExecutorTokenUsage | undefined, next: ExecutorTokenUsage): ExecutorTokenUsage;
|
|
25
36
|
export interface AcpPromptLimits {
|
|
26
37
|
/** The agent declared `promptCapabilities.image`. */
|
|
27
38
|
images: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"v1-map.d.ts","sourceRoot":"","sources":["../../../src/agent-executor/acp/v1-map.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAIhE,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"v1-map.d.ts","sourceRoot":"","sources":["../../../src/agent-executor/acp/v1-map.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAIhE,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAC1F,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAQtE;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,OAAO,GACb,OAAO,CAAC,iBAAiB,EAAE,aAAa,GAAG,cAAc,CAAC,GAAG,SAAS,CAOxE;AAuBD,oG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equestTurn } from '../engine-requests.js';
|
|
3
|
+
import { type InteractionReply } from '../executor-contract.js';
|
|
4
|
+
import type { JsonRpcValue } from '../json-rpc-peer.js';
|
|
5
|
+
import type { AcpPermissionOption, AcpPermissionRequest } from './v1-protocol.js';
|
|
6
|
+
/** The answer to a permission request nobody will choose an option for. */
|
|
7
|
+
export declare const ACP_CANCELLED: JsonRpcValue;
|
|
8
|
+
/** Metadata kept with one held ACP permission request. */
|
|
9
|
+
export interface AcpPermissionDetail {
|
|
10
|
+
readonly options: readonly AcpPermissionOption[];
|
|
11
|
+
}
|
|
12
|
+
/** A permission request arriving outside an active `startTurn()` (post-settle background work). */
|
|
13
|
+
export interface PendingExternalAcpRequest {
|
|
14
|
+
readonly detail: AcpPermissionDetail;
|
|
15
|
+
resolve(answer: JsonRpcValue): void;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Build the `request` delta fields for one ACP `session/request_permission` payload.
|
|
19
|
+
* Preserves existing top-level `rawInput`/`args` keys while exposing `options`
|
|
20
|
+
* (`optionId`, `kind`, `name`, `_meta`) in `delta.input`.
|
|
21
|
+
*/
|
|
22
|
+
export declare function buildAcpPermissionDeltaFields(asked: AcpPermissionRequest): {
|
|
23
|
+
callId?: string | undefined;
|
|
24
|
+
toolName: string;
|
|
25
|
+
input: z.JSONType;
|
|
26
|
+
prompt?: string | undefined;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Validate and build the ACP JSON-RPC response payload for one held permission request.
|
|
30
|
+
* All fail-closed checks run before any pending map entry is consumed so a refused reply
|
|
31
|
+
* leaves the request open for a valid follow-up answer.
|
|
32
|
+
*/
|
|
33
|
+
export declare function buildAcpPermissionAnswer(detail: AcpPermissionDetail, rawReply: InteractionReply['reply']): JsonRpcValue;
|
|
34
|
+
/** Answer one held permission request owned by the active turn (`turn.respond`). */
|
|
35
|
+
export declare function answerActiveAcpTurnRequest(turn: EngineRequestTurn<JsonRpcValue, AcpPermissionDetail>, interactionId: string, rawReply: InteractionReply['reply']): void;
|
|
36
|
+
/** Answer one pending permission request on the active turn or post-settle external map. */
|
|
37
|
+
export declare function answerAcpSessionRequest(input: {
|
|
38
|
+
turn: EngineRequestTurn<JsonRpcValue, AcpPermissionDetail> | undefined;
|
|
39
|
+
externalPending: Map<string, PendingExternalAcpRequest>;
|
|
40
|
+
expectedEntry?: PendingExternalAcpRequest;
|
|
41
|
+
interactionId: string;
|
|
42
|
+
reply: InteractionReply['reply'];
|
|
43
|
+
}): void;
|
|
44
|
+
//# sourceMappingURL=v1-permission.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"v1-permission.d.ts","sourceRoot":"","sources":["../../../src/agent-executor/acp/v1-permission.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAuB,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACjF,OAAO,EAAE,KAAK,gBAAgB,EAA0B,MAAM,sBAAsB,CAAC;AACrF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,KAAK,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAE/E,2EAA2E;AAC3E,eAAO,MAAM,aAAa,EAAE,YAAoD,CAAC;AAMjF,0DAA0D;AAC1D,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,OAAO,EAAE,SAAS,mBAAmB,EAAE,CAAC;CAClD;AAED,mGAAmG;AACnG,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,MAAM,EAAE,mBAAmB,CAAC;IACrC,OAAO,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;CACrC;AAQD;;;;GAIG;AACH,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,oBAAoB;;;;;EA4BxE;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,mBAAmB,EAC3B,QAAQ,EAAE,gBAAgB,CAAC,OAAO,CAAC,GAClC,YAAY,CAkDd;AAED,oFAAoF;AACpF,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,iBAAiB,CAAC,YAAY,EAAE,mBAAmB,CAAC,EAC1D,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,gBAAgB,CAAC,OAAO,CAAC,GAClC,IAAI,CAON;AAED,4FAA4F;AAC5F,wBAAgB,uBAAuB,CAAC,KAAK,EAAE;IAC7C,IAAI,EAAE,iBAAiB,CAAC,YAAY,EAAE,mBAAmB,CAAC,GAAG,SAAS,CAAC;IACvE,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,yBAAyB,CAAC,CAAC;IACxD,aAAa,CAAC,EAAE,yBAAyB,CAAC;IAC1C,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;CAClC,GAAG,IAAI,CAeP"}
|
|
@@ -2,12 +2,32 @@ import { z } from 'zod';
|
|
|
2
2
|
/**
|
|
3
3
|
* The slice of the Agent Client Protocol, version 1 (JSON-RPC 2.0 over
|
|
4
4
|
* stdio), the driver reads. Agents add vendor fields beside the standard
|
|
5
|
-
* ones — `
|
|
6
|
-
* `
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* ones — e.g. `load_session` / `session_capabilities` beside `loadSession` /
|
|
6
|
+
* `sessionCapabilities`, and `name`/`args` beside `title`/`rawInput` — so
|
|
7
|
+
* every inbound schema lets unknown keys through while keeping the keys the
|
|
8
|
+
* driver reads strictly typed.
|
|
9
9
|
*/
|
|
10
10
|
export declare const ACP_PROTOCOL_VERSION = 1;
|
|
11
|
+
/** ACP v1 agent-side JSON-RPC methods this driver calls or recognizes. */
|
|
12
|
+
export declare const ACP_V1_AGENT_METHODS: ("initialize" | "session/cancel" | "session/close" | "session/delete" | "session/list" | "session/load" | "session/new" | "session/prompt" | "session/resume" | "session/set_config_option" | "session/set_model")[];
|
|
13
|
+
/** ACP v1 client-side JSON-RPC methods this driver handles. */
|
|
14
|
+
export declare const ACP_V1_CLIENT_METHODS: ("session/request_permission" | "session/update")[];
|
|
15
|
+
/** ACP v1 `session/update` discriminators recognized by this driver. */
|
|
16
|
+
export declare const ACP_V1_UPDATE_KINDS: ("agent_message_chunk" | "agent_thought_chunk" | "available_commands_update" | "compaction_summary_chunk" | "compaction_update" | "config_option_update" | "current_mode_update" | "plan" | "plan_removed" | "plan_update" | "session_info_update" | "tool_call" | "tool_call_update" | "usage_update" | "user_message_chunk")[];
|
|
17
|
+
/** ACP v1 permission option kinds defined by the protocol. */
|
|
18
|
+
export declare const ACP_V1_PERMISSION_OPTION_KINDS: ("allow_always" | "allow_once" | "reject_always" | "reject_once")[];
|
|
19
|
+
/** ACP v1 prompt stop reasons defined by the protocol. */
|
|
20
|
+
export declare const ACP_V1_STOP_REASONS: ("cancelled" | "end_turn" | "max_tokens" | "max_turn_requests" | "refusal")[];
|
|
21
|
+
/** ACP v1 prompt `usage` token counter field names preserved by this driver. */
|
|
22
|
+
export declare const ACP_V1_USAGE_FIELDS: ("cachedReadTokens" | "cachedWriteTokens" | "inputTokens" | "outputTokens" | "thoughtTokens" | "totalTokens")[];
|
|
23
|
+
/** Client identity optionally sent on ACP `initialize`. */
|
|
24
|
+
export declare const AcpClientInfoSchema: z.ZodObject<{
|
|
25
|
+
name: z.ZodString;
|
|
26
|
+
version: z.ZodString;
|
|
27
|
+
title: z.ZodOptional<z.ZodString>;
|
|
28
|
+
}, z.core.$strict>;
|
|
29
|
+
/** ACP client implementation metadata inferred from `AcpClientInfoSchema`. */
|
|
30
|
+
export type AcpClientInfo = z.infer<typeof AcpClientInfoSchema>;
|
|
11
31
|
export declare const AcpInitializeResultSchema: z.ZodObject<{
|
|
12
32
|
protocolVersion: z.ZodInt;
|
|
13
33
|
agentCapabilities: z.ZodOptional<z.ZodObject<{
|
|
@@ -16,20 +36,24 @@ export declare const AcpInitializeResultSchema: z.ZodObject<{
|
|
|
16
36
|
image: z.ZodOptional<z.ZodBoolean>;
|
|
17
37
|
}, z.core.$loose>>;
|
|
18
38
|
sessionCapabilities: z.ZodOptional<z.ZodObject<{
|
|
19
|
-
resume: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{}, z.core.$loose>]
|
|
20
|
-
load: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{}, z.core.$loose>]
|
|
21
|
-
list: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{}, z.core.$loose>]
|
|
22
|
-
close: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{}, z.core.$loose>]
|
|
39
|
+
resume: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{}, z.core.$loose>]>>>;
|
|
40
|
+
load: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{}, z.core.$loose>]>>>;
|
|
41
|
+
list: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{}, z.core.$loose>]>>>;
|
|
42
|
+
close: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{}, z.core.$loose>]>>>;
|
|
43
|
+
delete: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{}, z.core.$loose>]>>>;
|
|
23
44
|
}, z.core.$loose>>;
|
|
24
45
|
}, z.core.$loose>>;
|
|
25
|
-
agentInfo: z.ZodOptional<z.ZodObject<{
|
|
46
|
+
agentInfo: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
26
47
|
name: z.ZodOptional<z.ZodString>;
|
|
48
|
+
title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
27
49
|
version: z.ZodOptional<z.ZodString>;
|
|
28
|
-
}, z.core.$loose
|
|
50
|
+
}, z.core.$loose>>>;
|
|
29
51
|
authMethods: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
30
52
|
id: z.ZodString;
|
|
31
53
|
}, z.core.$loose>>>;
|
|
32
54
|
}, z.core.$loose>;
|
|
55
|
+
/** ACP v1 `initialize` response inferred from `AcpInitializeResultSchema`. */
|
|
56
|
+
export type AcpInitializeResult = z.infer<typeof AcpInitializeResultSchema>;
|
|
33
57
|
/** A setting the agent offers on a session: a select of values, flat or grouped. */
|
|
34
58
|
export declare const AcpConfigOptionSchema: z.ZodObject<{
|
|
35
59
|
id: z.ZodString;
|
|
@@ -204,6 +228,7 @@ export declare const AcpSessionUpdateSchema: z.ZodObject<{
|
|
|
204
228
|
name: z.ZodString;
|
|
205
229
|
}, z.core.$loose>>>;
|
|
206
230
|
}, z.core.$loose>;
|
|
231
|
+
/** One `session/update` payload emitted by an ACP v1 agent. */
|
|
207
232
|
export type AcpSessionUpdate = z.infer<typeof AcpSessionUpdateSchema>;
|
|
208
233
|
export declare const AcpUpdateNotificationSchema: z.ZodObject<{
|
|
209
234
|
sessionId: z.ZodString;
|
|
@@ -245,26 +270,54 @@ export declare const AcpUpdateNotificationSchema: z.ZodObject<{
|
|
|
245
270
|
}, z.core.$loose>>>;
|
|
246
271
|
}, z.core.$loose>;
|
|
247
272
|
}, z.core.$loose>;
|
|
273
|
+
export declare const AcpPromptUsageSchema: z.ZodObject<{
|
|
274
|
+
inputTokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
|
|
275
|
+
outputTokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
|
|
276
|
+
cachedReadTokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
|
|
277
|
+
cachedWriteTokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
|
|
278
|
+
thoughtTokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
|
|
279
|
+
totalTokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
|
|
280
|
+
}, z.core.$loose>;
|
|
281
|
+
/** ACP v1 prompt token counters inferred from `AcpPromptUsageSchema`. */
|
|
282
|
+
export type AcpPromptUsage = z.infer<typeof AcpPromptUsageSchema>;
|
|
248
283
|
export declare const AcpPromptResultSchema: z.ZodObject<{
|
|
249
284
|
stopReason: z.ZodString;
|
|
250
285
|
usage: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
251
286
|
inputTokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
|
|
252
287
|
outputTokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
|
|
253
288
|
cachedReadTokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
|
|
289
|
+
cachedWriteTokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
|
|
290
|
+
thoughtTokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
|
|
291
|
+
totalTokens: z.ZodOptional<z.ZodNullable<z.ZodInt>>;
|
|
254
292
|
}, z.core.$loose>>>;
|
|
255
293
|
}, z.core.$loose>;
|
|
294
|
+
/** ACP v1 `session/prompt` response inferred from `AcpPromptResultSchema`. */
|
|
295
|
+
export type AcpPromptResult = z.infer<typeof AcpPromptResultSchema>;
|
|
296
|
+
export declare const AcpPermissionOptionSchema: z.ZodObject<{
|
|
297
|
+
optionId: z.ZodString;
|
|
298
|
+
kind: z.ZodString;
|
|
299
|
+
name: z.ZodOptional<z.ZodString>;
|
|
300
|
+
_meta: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>>;
|
|
301
|
+
}, z.core.$loose>;
|
|
302
|
+
/** One selectable option on `session/request_permission`, inferred from `AcpPermissionOptionSchema`. */
|
|
303
|
+
export type AcpPermissionOption = z.infer<typeof AcpPermissionOptionSchema>;
|
|
256
304
|
export declare const AcpPermissionRequestSchema: z.ZodObject<{
|
|
257
305
|
sessionId: z.ZodString;
|
|
258
306
|
toolCall: z.ZodObject<{
|
|
259
307
|
toolCallId: z.ZodString;
|
|
260
308
|
title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
261
309
|
name: z.ZodOptional<z.ZodString>;
|
|
310
|
+
kind: z.ZodOptional<z.ZodString>;
|
|
262
311
|
rawInput: z.ZodOptional<z.ZodJSONSchema>;
|
|
263
312
|
args: z.ZodOptional<z.ZodJSONSchema>;
|
|
264
313
|
}, z.core.$loose>;
|
|
265
314
|
options: z.ZodArray<z.ZodObject<{
|
|
266
315
|
optionId: z.ZodString;
|
|
267
316
|
kind: z.ZodString;
|
|
317
|
+
name: z.ZodOptional<z.ZodString>;
|
|
318
|
+
_meta: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>>;
|
|
268
319
|
}, z.core.$loose>>;
|
|
269
320
|
}, z.core.$loose>;
|
|
321
|
+
/** ACP v1 `session/request_permission` payload inferred from `AcpPermissionRequestSchema`. */
|
|
322
|
+
export type AcpPermissionRequest = z.infer<typeof AcpPermissionRequestSchema>;
|
|
270
323
|
//# sourceMappingURL=v1-protocol.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"v1-protocol.d.ts","sourceRoot":"","sources":["../../../src/agent-executor/acp/v1-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"v1-protocol.d.ts","sourceRoot":"","sources":["../../../src/agent-executor/acp/v1-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,IAAI,CAAC;AAEtC,0EAA0E;AAC1E,eAAO,MAAM,oBAAoB,sNAYvB,CAAC;AAEX,+DAA+D;AAC/D,eAAO,MAAM,qBAAqB,qDAGxB,CAAC;AAEX,wEAAwE;AACxE,eAAO,MAAM,mBAAmB,kUAgBtB,CAAC;AAEX,8DAA8D;AAC9D,eAAO,MAAM,8BAA8B,qE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C;AACH,+DAA+D;AAC/D,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEtE,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAGtC,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;;iBAO/B,CAAC;AACH,yEAAyE;AACzE,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE,eAAO,MAAM,qBAAqB;;;;;;;;;;iBAGhC,CAAC;AACH,8EAA8E;AAC9E,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE,eAAO,MAAM,yBAAyB;;;;;iBAKpC,CAAC;AACH,wGAAwG;AACxG,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE5E,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;iBAWrC,CAAC;AACH,8FAA8F;AAC9F,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import type { AgentMessagePart } from '../../agent-parts/parts.js';
|
|
1
2
|
import type { AgentEngineSession } from '../engine.js';
|
|
3
|
+
import type { InteractionReply } from '../executor-contract.js';
|
|
2
4
|
import type { ExecutorProfileConfig } from '../profile.js';
|
|
5
|
+
import type { ExecutorStartupPhase } from '../vocabulary.js';
|
|
3
6
|
import { type AcpDriverConfig } from './v1-connect.js';
|
|
4
7
|
import { type AcpConfigOption } from './v1-protocol.js';
|
|
5
8
|
/**
|
|
@@ -8,7 +11,27 @@ import { type AcpConfigOption } from './v1-protocol.js';
|
|
|
8
11
|
* to ask before running tools and never synthesizes fake requests after `tool_call` updates.
|
|
9
12
|
*/
|
|
10
13
|
export type AcpApprovalEnforcement = 'agent-initiated';
|
|
11
|
-
/**
|
|
14
|
+
/** Input to {@link AcpDriver.open}, extending {@link AgentEngineDriver.open} with per-session overrides. */
|
|
15
|
+
export interface AcpOpenInput {
|
|
16
|
+
readonly profile: ExecutorProfileConfig;
|
|
17
|
+
readonly cwd: string;
|
|
18
|
+
/** Resume or load this native session; a fresh one is started without it. */
|
|
19
|
+
readonly nativeThreadId?: string;
|
|
20
|
+
/** Per-session model override (overrides {@link AcpDriverConfig.model}). */
|
|
21
|
+
readonly model?: string;
|
|
22
|
+
/** Per-session thought level override (overrides {@link AcpDriverConfig.thoughtLevel}). */
|
|
23
|
+
readonly thoughtLevel?: string;
|
|
24
|
+
/** Per-session mode override (overrides {@link AcpDriverConfig.mode}). */
|
|
25
|
+
readonly mode?: string;
|
|
26
|
+
/** Optional observer invoked with startup phases (`spawning`, `initializing`) during open. */
|
|
27
|
+
readonly onStartupPhase?: (phase: ExecutorStartupPhase) => void;
|
|
28
|
+
readonly signal?: AbortSignal;
|
|
29
|
+
}
|
|
30
|
+
/** Input to {@link AcpSession.steerTurn} when `steerMode` is `'prompt'`. */
|
|
31
|
+
export interface AcpSteerTurnInput {
|
|
32
|
+
readonly input: readonly AgentMessagePart[];
|
|
33
|
+
}
|
|
34
|
+
/** A session with what ACP says about it besides turns: its settings, title, commands, steering, and post-settle replies. */
|
|
12
35
|
export interface AcpSession extends AgentEngineSession {
|
|
13
36
|
/** Always `'agent-initiated'`: whether a tool pauses for host approval is decided by the agent. */
|
|
14
37
|
readonly approvalEnforcement: AcpApprovalEnforcement;
|
|
@@ -20,11 +43,15 @@ export interface AcpSession extends AgentEngineSession {
|
|
|
20
43
|
readonly commands: readonly string[];
|
|
21
44
|
/** Change one setting; the agent answers with every option, which may have narrowed. */
|
|
22
45
|
setConfigOption(configId: string, value: string): Promise<readonly AcpConfigOption[]>;
|
|
46
|
+
/** Answer a pending permission request from either the active turn or a post-settle `onPermissionRequest` event. */
|
|
47
|
+
respond(interactionId: string, reply: InteractionReply['reply']): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Steer the currently running turn with an additional `session/prompt` generation when
|
|
50
|
+
* `steerMode` is `'prompt'`. Throws `TypeError` when `steerMode` is `'none'` (default).
|
|
51
|
+
*/
|
|
52
|
+
steerTurn(input: AcpSteerTurnInput): Promise<{
|
|
53
|
+
readonly turnId: string;
|
|
54
|
+
}>;
|
|
23
55
|
}
|
|
24
|
-
export declare function openAcpSession(config: AcpDriverConfig, input:
|
|
25
|
-
profile: ExecutorProfileConfig;
|
|
26
|
-
cwd: string;
|
|
27
|
-
nativeThreadId?: string;
|
|
28
|
-
signal?: AbortSignal;
|
|
29
|
-
}): Promise<AcpSession>;
|
|
56
|
+
export declare function openAcpSession(config: AcpDriverConfig, input: AcpOpenInput): Promise<AcpSession>;
|
|
30
57
|
//# sourceMappingURL=v1-session.d.ts.map
|