@agentclientprotocol/claude-agent-acp 0.102.1-preview.1 → 0.102.1-preview.3
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 +5 -1
- package/dist/acp-agent.d.ts +93 -622
- package/dist/acp-agent.d.ts.map +1 -1
- package/dist/acp-agent.js +369 -3474
- package/dist/acp-client.d.ts +28 -0
- package/dist/acp-client.d.ts.map +1 -0
- package/dist/acp-client.js +1 -0
- package/dist/acp-subagents.d.ts +1 -2
- package/dist/acp-subagents.d.ts.map +1 -1
- package/dist/auth-methods.d.ts +21 -0
- package/dist/auth-methods.d.ts.map +1 -0
- package/dist/auth-methods.js +68 -0
- package/dist/auth-status-reporter.d.ts +112 -0
- package/dist/auth-status-reporter.d.ts.map +1 -0
- package/dist/auth-status-reporter.js +253 -0
- package/dist/background-work.d.ts +12 -265
- package/dist/background-work.d.ts.map +1 -1
- package/dist/background-work.js +8 -558
- package/dist/client-system-prompt.d.ts +7 -0
- package/dist/client-system-prompt.d.ts.map +1 -1
- package/dist/client-system-prompt.js +24 -0
- package/dist/context-compaction.d.ts +20 -0
- package/dist/context-compaction.d.ts.map +1 -1
- package/dist/context-compaction.js +26 -0
- package/dist/context-window.d.ts +70 -0
- package/dist/context-window.d.ts.map +1 -0
- package/dist/context-window.js +132 -0
- package/dist/diff.d.ts +1 -1
- package/dist/diff.js +1 -1
- package/dist/elicitation.d.ts +66 -1
- package/dist/elicitation.d.ts.map +1 -1
- package/dist/elicitation.js +109 -0
- package/dist/file-change-audit.d.ts +4 -3
- package/dist/file-change-audit.d.ts.map +1 -1
- package/dist/file-change-audit.js +3 -2
- package/dist/lib.d.ts +5 -1
- package/dist/lib.d.ts.map +1 -1
- package/dist/lib.js +3 -1
- package/dist/logger.d.ts +10 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +1 -0
- package/dist/mcp-oauth.d.ts +44 -0
- package/dist/mcp-oauth.d.ts.map +1 -0
- package/dist/mcp-oauth.js +142 -0
- package/dist/mcp-servers.d.ts +10 -0
- package/dist/mcp-servers.d.ts.map +1 -0
- package/dist/mcp-servers.js +29 -0
- package/dist/message-filters.d.ts +43 -0
- package/dist/message-filters.d.ts.map +1 -0
- package/dist/message-filters.js +197 -0
- package/dist/native-subagents.d.ts +18 -8
- package/dist/native-subagents.d.ts.map +1 -1
- package/dist/native-subagents.js +7 -35
- package/dist/new-session-meta.d.ts +40 -0
- package/dist/new-session-meta.d.ts.map +1 -0
- package/dist/new-session-meta.js +1 -0
- package/dist/permissions/presentation.d.ts +29 -0
- package/dist/permissions/presentation.d.ts.map +1 -1
- package/dist/permissions/presentation.js +38 -11
- package/dist/prompt-suggestions.d.ts +29 -0
- package/dist/prompt-suggestions.d.ts.map +1 -1
- package/dist/prompt-suggestions.js +45 -0
- package/dist/prompt-to-claude.d.ts +10 -0
- package/dist/prompt-to-claude.d.ts.map +1 -0
- package/dist/prompt-to-claude.js +120 -0
- package/dist/providers.d.ts +139 -0
- package/dist/providers.d.ts.map +1 -0
- package/dist/providers.js +286 -0
- package/dist/remote-control.d.ts +62 -0
- package/dist/remote-control.d.ts.map +1 -0
- package/dist/remote-control.js +78 -0
- package/dist/result-end.d.ts +68 -0
- package/dist/result-end.d.ts.map +1 -0
- package/dist/result-end.js +84 -0
- package/dist/sdk-to-acp.d.ts +93 -0
- package/dist/sdk-to-acp.d.ts.map +1 -0
- package/dist/sdk-to-acp.js +635 -0
- package/dist/serve.d.ts +9 -3
- package/dist/serve.d.ts.map +1 -1
- package/dist/serve.js +10 -5
- package/dist/session-config-ids.d.ts +1 -0
- package/dist/session-config-ids.d.ts.map +1 -1
- package/dist/session-config-ids.js +1 -0
- package/dist/session-config-options.d.ts +64 -0
- package/dist/session-config-options.d.ts.map +1 -0
- package/dist/session-config-options.js +162 -0
- package/dist/session-effort.d.ts +67 -0
- package/dist/session-effort.d.ts.map +1 -1
- package/dist/session-effort.js +98 -0
- package/dist/session-env.d.ts +22 -0
- package/dist/session-env.d.ts.map +1 -0
- package/dist/session-env.js +66 -0
- package/dist/session-fast-mode.d.ts +83 -0
- package/dist/session-fast-mode.d.ts.map +1 -0
- package/dist/session-fast-mode.js +142 -0
- package/dist/session-index/connection.d.ts +5 -6
- package/dist/session-index/connection.d.ts.map +1 -1
- package/dist/session-index/connection.js +3 -5
- package/dist/session-mode.d.ts +1 -0
- package/dist/session-mode.d.ts.map +1 -1
- package/dist/session-mode.js +1 -1
- package/dist/session-model.d.ts +41 -0
- package/dist/session-model.d.ts.map +1 -1
- package/dist/session-model.js +110 -45
- package/dist/session-notices.d.ts +44 -0
- package/dist/session-notices.d.ts.map +1 -1
- package/dist/session-notices.js +68 -0
- package/dist/session-titles.d.ts +34 -12
- package/dist/session-titles.d.ts.map +1 -1
- package/dist/session-titles.js +7 -6
- package/dist/session-usage.d.ts +125 -0
- package/dist/session-usage.d.ts.map +1 -0
- package/dist/session-usage.js +196 -0
- package/dist/slash-commands.d.ts +10 -0
- package/dist/slash-commands.d.ts.map +1 -0
- package/dist/slash-commands.js +99 -0
- package/dist/streamed-text.d.ts +33 -0
- package/dist/streamed-text.d.ts.map +1 -0
- package/dist/streamed-text.js +71 -0
- package/dist/subagent-configuration.d.ts +32 -0
- package/dist/subagent-configuration.d.ts.map +1 -0
- package/dist/subagent-configuration.js +70 -0
- package/dist/subagent-replay.d.ts +18 -0
- package/dist/subagent-replay.d.ts.map +1 -1
- package/dist/subagent-replay.js +25 -15
- package/dist/tool-calls/client-capabilities.d.ts +8 -8
- package/dist/tool-calls/client-capabilities.js +4 -4
- package/dist/tool-calls/renderer.d.ts +4 -5
- package/dist/tool-calls/renderer.d.ts.map +1 -1
- package/dist/tool-calls/renderer.js +4 -5
- package/dist/turn-events.d.ts +6 -46
- package/dist/turn-events.d.ts.map +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/v2/agent.d.ts +7 -11
- package/dist/v2/agent.d.ts.map +1 -1
- package/dist/v2/agent.js +751 -331
- package/dist/v2/air.d.ts +33 -0
- package/dist/v2/air.d.ts.map +1 -0
- package/dist/v2/air.js +29 -0
- package/dist/v2/auth.d.ts +97 -0
- package/dist/v2/auth.d.ts.map +1 -0
- package/dist/v2/auth.js +216 -0
- package/dist/v2/background.d.ts +27 -16
- package/dist/v2/background.d.ts.map +1 -1
- package/dist/v2/background.js +4 -32
- package/dist/v2/child-config.d.ts +55 -0
- package/dist/v2/child-config.d.ts.map +1 -0
- package/dist/v2/child-config.js +92 -0
- package/dist/v2/clear-context.d.ts +94 -0
- package/dist/v2/clear-context.d.ts.map +1 -0
- package/dist/v2/clear-context.js +176 -0
- package/dist/v2/commands.d.ts +46 -0
- package/dist/v2/commands.d.ts.map +1 -0
- package/dist/v2/commands.js +54 -0
- package/dist/v2/config.d.ts +187 -0
- package/dist/v2/config.d.ts.map +1 -0
- package/dist/v2/config.js +494 -0
- package/dist/v2/elicitation.d.ts +93 -0
- package/dist/v2/elicitation.d.ts.map +1 -0
- package/dist/v2/elicitation.js +160 -0
- package/dist/v2/file-changes.d.ts +61 -0
- package/dist/v2/file-changes.d.ts.map +1 -0
- package/dist/v2/file-changes.js +108 -0
- package/dist/v2/file-preview.d.ts +18 -0
- package/dist/v2/file-preview.d.ts.map +1 -0
- package/dist/v2/file-preview.js +29 -0
- package/dist/v2/initialize.d.ts +10 -24
- package/dist/v2/initialize.d.ts.map +1 -1
- package/dist/v2/initialize.js +4 -111
- package/dist/v2/outcome.d.ts +81 -0
- package/dist/v2/outcome.d.ts.map +1 -0
- package/dist/v2/outcome.js +166 -0
- package/dist/v2/permissions.d.ts +92 -0
- package/dist/v2/permissions.d.ts.map +1 -0
- package/dist/v2/permissions.js +162 -0
- package/dist/v2/prompt.d.ts +2 -42
- package/dist/v2/prompt.d.ts.map +1 -1
- package/dist/v2/prompt.js +2 -119
- package/dist/v2/remote-control.d.ts +41 -0
- package/dist/v2/remote-control.d.ts.map +1 -0
- package/dist/v2/remote-control.js +63 -0
- package/dist/v2/reports.d.ts +198 -0
- package/dist/v2/reports.d.ts.map +1 -0
- package/dist/v2/reports.js +487 -0
- package/dist/v2/restarts.d.ts +128 -0
- package/dist/v2/restarts.d.ts.map +1 -0
- package/dist/v2/restarts.js +348 -0
- package/dist/v2/session-requests.d.ts +20 -0
- package/dist/v2/session-requests.d.ts.map +1 -0
- package/dist/v2/session-requests.js +108 -0
- package/dist/v2/session-update.d.ts +2 -13
- package/dist/v2/session-update.d.ts.map +1 -1
- package/dist/v2/session-update.js +2 -22
- package/dist/v2/session.d.ts +340 -41
- package/dist/v2/session.d.ts.map +1 -1
- package/dist/v2/session.js +1224 -141
- package/dist/v2/setup.d.ts +49 -0
- package/dist/v2/setup.d.ts.map +1 -0
- package/dist/v2/setup.js +62 -0
- package/dist/v2/stopped-work.d.ts +123 -0
- package/dist/v2/stopped-work.d.ts.map +1 -0
- package/dist/v2/stopped-work.js +210 -0
- package/dist/v2/stream.d.ts +229 -0
- package/dist/v2/stream.d.ts.map +1 -0
- package/dist/v2/stream.js +507 -0
- package/dist/v2/subagent-replay.d.ts +115 -0
- package/dist/v2/subagent-replay.d.ts.map +1 -0
- package/dist/v2/subagent-replay.js +479 -0
- package/dist/v2/subscription-guard.d.ts +60 -0
- package/dist/v2/subscription-guard.d.ts.map +1 -0
- package/dist/v2/subscription-guard.js +84 -0
- package/dist/v2/tasks.d.ts +492 -0
- package/dist/v2/tasks.d.ts.map +1 -0
- package/dist/v2/tasks.js +1728 -0
- package/dist/v2/terminal.d.ts.map +1 -1
- package/dist/v2/terminal.js +6 -1
- package/dist/v2/tool-call.d.ts +3 -2
- package/dist/v2/tool-call.d.ts.map +1 -1
- package/dist/v2/update-translator.d.ts +36 -0
- package/dist/v2/update-translator.d.ts.map +1 -0
- package/dist/v2/update-translator.js +80 -0
- package/dist/workflow-progress.d.ts +23 -0
- package/dist/workflow-progress.d.ts.map +1 -1
- package/dist/workflow-progress.js +31 -8
- package/package.json +1 -1
- package/dist/v2/permission.d.ts +0 -28
- package/dist/v2/permission.d.ts.map +0 -1
- package/dist/v2/permission.js +0 -41
package/dist/acp-agent.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { AgentApp, AuthenticateRequest, AvailableCommand, CancelNotification, ClientCapabilities,
|
|
2
|
-
import type {
|
|
3
|
-
import { AgentInfo, CanUseTool, FastModeDisabledReason,
|
|
1
|
+
import { AgentApp, AuthenticateRequest, AvailableCommand, CancelNotification, ClientCapabilities, DisableProviderRequest, DisableProviderResponse, ForkSessionRequest, ForkSessionResponse, InitializeRequest, InitializeResponse, ListProvidersRequest, ListProvidersResponse, ListSessionsRequest, ListSessionsResponse, LoadSessionRequest, LoadSessionResponse, LogoutRequest, NewSessionRequest, NewSessionResponse, PromptRequest, PromptResponse, ReadTextFileRequest, ReadTextFileResponse, SetProviderRequest, SetProviderResponse, ResumeSessionRequest, ResumeSessionResponse, SessionConfigOption, SessionModeState, SetSessionConfigOptionRequest, SetSessionConfigOptionResponse, SetSessionModeRequest, SetSessionModeResponse, CloseSessionRequest, CloseSessionResponse, DeleteSessionRequest, DeleteSessionResponse, WriteTextFileRequest, WriteTextFileResponse } from "@agentclientprotocol/sdk/unstable";
|
|
2
|
+
import type { TurnEvents, TurnOutcome } from "./turn-events.js";
|
|
3
|
+
import { AgentInfo, CanUseTool, FastModeDisabledReason, ModelInfo, PermissionMode, Query, SDKUserMessage, Settings } from "@anthropic-ai/claude-agent-sdk";
|
|
4
4
|
import { GoalRequest, GoalControlResponse, GoalSnapshot } from "./goal-extension.js";
|
|
5
5
|
import { type SubagentChecklists } from "./plans.js";
|
|
6
|
+
import { PromptSuggestions } from "./prompt-suggestions.js";
|
|
6
7
|
import { SessionTitles } from "./session-titles.js";
|
|
7
8
|
import { AcpSessionNotification } from "./acp-subagents.js";
|
|
8
9
|
import { NativeSubagent, NativeSubagentRuntime } from "./native-subagents.js";
|
|
@@ -10,11 +11,8 @@ import * as sessionIndex from "./session-index/connection.js";
|
|
|
10
11
|
import type { BatchGetSessionsRequest, RenameSessionRequest, SessionIdRequest } from "./session-index/service.js";
|
|
11
12
|
import type { ListSubscribeRequest, ListUnsubscribeRequest } from "./session-index/list-subscriptions.js";
|
|
12
13
|
import { AsyncTaskRuntime } from "./async-tasks.js";
|
|
13
|
-
import {
|
|
14
|
+
import { SessionBackgroundWork } from "./background-work.js";
|
|
14
15
|
import { type AuthStatus, type AuthStatusKind } from "./auth-status.js";
|
|
15
|
-
import { ContentBlockParam } from "@anthropic-ai/sdk/resources";
|
|
16
|
-
import { BetaContentBlock, BetaRawContentBlockDelta } from "@anthropic-ai/sdk/resources/beta.mjs";
|
|
17
|
-
import { type AcpPermissionRequest } from "./permissions/presentation.js";
|
|
18
16
|
import { SettingsManager } from "./settings.js";
|
|
19
17
|
import { type SessionFailureState } from "./session-failure-extension.js";
|
|
20
18
|
import { type ClaudeSubscriptionGuardState } from "./hide-claude-auth.js";
|
|
@@ -22,33 +20,28 @@ import { type FileChangeReportTurnState, type NativeFileChangeReporter } from ".
|
|
|
22
20
|
import { ContextCompactionLifecycle } from "./context-compaction.js";
|
|
23
21
|
import { IdleCompaction } from "./idle-compaction.js";
|
|
24
22
|
import { TaskState } from "./tools.js";
|
|
23
|
+
import { type AccumulatedUsage, type ModelTokenTally } from "./session-usage.js";
|
|
25
24
|
import { ToolCallFieldTracker } from "./tool-calls/field-tracker.js";
|
|
26
|
-
import { ClientCapabilities as ToolCallClientCapabilities } from "./tool-calls/client-capabilities.js";
|
|
27
25
|
import { Pushable } from "./utils.js";
|
|
28
26
|
export { DEFAULT_AGENT_ID } from "./session-config-ids.js";
|
|
29
|
-
import { MODE_CONFIG_ID } from "./session-mode.js";
|
|
30
27
|
import { type SessionModelState } from "./session-model.js";
|
|
31
|
-
import { type
|
|
28
|
+
import { type GatewayAuthRequest, type ProviderConfig } from "./providers.js";
|
|
29
|
+
export { AGENT_CONFIG_ID, BUILTIN_AGENT_NAMES, buildConfigOptions, clientSupportsBooleanConfigOptions, clientSupportsRecommendedConfigValue, type ConfigOptionPresentation, discoverCustomAgents, MODE_CONFIG_ID, } from "./session-config-options.js";
|
|
30
|
+
export { createFastModeConfigOption, FAST_MODE_CONFIG_ID, FAST_MODE_OFF, FAST_MODE_ON, fastModeStateEnabled, type FastModeOptionState, normalizeFastModeDisabledReason, resolveFastModeEnabled, } from "./session-fast-mode.js";
|
|
32
31
|
export { EFFORT_CONFIG_ID, settingsEffortForModel } from "./session-effort.js";
|
|
33
32
|
export { applyAvailableModelsAllowlist, matchResumedModel, MODEL_CONFIG_ID, resolveModelPreference, } from "./session-model.js";
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
cachedReadTokens: number;
|
|
47
|
-
cachedWriteTokens: number;
|
|
48
|
-
};
|
|
49
|
-
/** Per-model token tallies keyed by the model id the SDK reported them under
|
|
50
|
-
* (its resolved spelling, e.g. "claude-opus-5[1m]"). */
|
|
51
|
-
type ModelTokenTally = Record<string, AccumulatedUsage>;
|
|
33
|
+
import type { AcpClient } from "./acp-client.js";
|
|
34
|
+
import type { Logger } from "./logger.js";
|
|
35
|
+
import type { SDKMessageFilter } from "./new-session-meta.js";
|
|
36
|
+
import { type ToolUseCache } from "./sdk-to-acp.js";
|
|
37
|
+
export { AUTONOMOUS_RESULT_ORIGINS, isAbortedResult, isLoginRequiredText } from "./result-end.js";
|
|
38
|
+
export type { AcpClient } from "./acp-client.js";
|
|
39
|
+
export type { Logger } from "./logger.js";
|
|
40
|
+
export { isLocalCommandMetadata, isReplayHiddenMetaMessage, isSyntheticLoginMessage, stripLocalCommandMetadata, } from "./message-filters.js";
|
|
41
|
+
export type { NewSessionMeta, SDKMessageFilter } from "./new-session-meta.js";
|
|
42
|
+
export { promptToClaude } from "./prompt-to-claude.js";
|
|
43
|
+
export { messageIdForGrouping, streamEventToAcpNotifications, toAcpNotifications, type StreamedToolInputCache, type ToolUseCache, } from "./sdk-to-acp.js";
|
|
44
|
+
export { getAvailableSlashCommands } from "./slash-commands.js";
|
|
52
45
|
/** The structured replacement for the text of a local command that Claude
|
|
53
46
|
* Code runs itself, such as `/usage` or `/mcp`. */
|
|
54
47
|
type LocalCommandMarkdown = {
|
|
@@ -318,9 +311,6 @@ type OpenUserInput = {
|
|
|
318
311
|
/** The subagent that asked: absent for the main conversation and for a
|
|
319
312
|
* request that names no agent. */
|
|
320
313
|
agentID?: string;
|
|
321
|
-
/** Set by a cancel that comes while the request is open (see
|
|
322
|
-
* `withPendingUserInput`). */
|
|
323
|
-
cancelled?: boolean;
|
|
324
314
|
};
|
|
325
315
|
export type Session = {
|
|
326
316
|
query: Query;
|
|
@@ -363,15 +353,8 @@ export type Session = {
|
|
|
363
353
|
/** Last goal snapshot sent to the ACP client, used to roll back an
|
|
364
354
|
* optimistic `/goal` update when the command itself fails. */
|
|
365
355
|
lastPublishedGoal?: GoalSnapshot | null;
|
|
366
|
-
/**
|
|
367
|
-
|
|
368
|
-
lastPublishedPromptSuggestion?: string | null;
|
|
369
|
-
/** Whether an arriving `prompt_suggestion` still answers the turn the user is
|
|
370
|
-
* waiting on: set at a turn's result, cleared when the next prompt arrives.
|
|
371
|
-
* A prediction the user outran — the next prompt was sent before the
|
|
372
|
-
* prediction was read off the stream — follows a turn that is already
|
|
373
|
-
* answered, so it is dropped instead of published mid-turn. */
|
|
374
|
-
promptSuggestionExpected?: boolean;
|
|
356
|
+
/** The follow-up prompt the client holds, for an AIR client only. */
|
|
357
|
+
promptSuggestions?: PromptSuggestions;
|
|
375
358
|
/** Count of result messages the consumer should treat as orphans and skip
|
|
376
359
|
* (not promote/attribute to the current head). When cancel() settles+removes
|
|
377
360
|
* a queued turn, that turn's user message was already pushed to the SDK, so
|
|
@@ -585,8 +568,7 @@ export type Session = {
|
|
|
585
568
|
forwardSubagentText: boolean;
|
|
586
569
|
/** The ACP permission and elicitation requests that await user input.
|
|
587
570
|
* Parallel subagents can ask concurrently. Steering stays non-interrupting
|
|
588
|
-
* while any request is open
|
|
589
|
-
* that blocks it is open (see {@link blocksForeground}). */
|
|
571
|
+
* while any request is open, and the idle compaction waits until none is. */
|
|
590
572
|
openUserInputs?: Set<OpenUserInput>;
|
|
591
573
|
/** Context window size of the session's current model, carried across
|
|
592
574
|
* prompts so mid-stream usage_update notifications report a correct `size`
|
|
@@ -650,8 +632,8 @@ export type Session = {
|
|
|
650
632
|
/** The tool uses that the consumer reached in the stream, each with whether
|
|
651
633
|
* it dropped it as output of the work a cancel stopped (`true`, see
|
|
652
634
|
* `dropsStoppedWorkOutput`). The first sight of a tool use decides: its
|
|
653
|
-
* streamed start, or its complete message. `canUseTool`
|
|
654
|
-
*
|
|
635
|
+
* streamed start, or its complete message. `canUseTool` reads it (see
|
|
636
|
+
* `isStoppedWorkToolUse`). The oldest entries are
|
|
655
637
|
* dropped. */
|
|
656
638
|
reachedToolUses?: Map<string, boolean>;
|
|
657
639
|
/** What waits for the consumer to reach each tool use (see
|
|
@@ -757,17 +739,14 @@ export type Session = {
|
|
|
757
739
|
* `perTaskStopAffordance`: then it spares both, and the client is expected
|
|
758
740
|
* to stop each one itself. A client that can cancel one subagent gets the
|
|
759
741
|
* declaration, but it has no control for a workflow unless it is AIR with
|
|
760
|
-
* `asyncTasks` (`_session/async_task/stop`)
|
|
761
|
-
* background work (`background.reported`, with `tool_call/cancel`), which
|
|
762
|
-
* `session/cancel` must leave running. So for any other such client the
|
|
742
|
+
* `asyncTasks` (`_session/async_task/stop`). So for any other such client the
|
|
763
743
|
* adapter stops the workflows after the interrupt, as the interrupt did
|
|
764
744
|
* before. */
|
|
765
745
|
stopsWorkflowsOnCancel?: boolean;
|
|
766
|
-
/** The
|
|
767
|
-
*
|
|
768
|
-
*
|
|
769
|
-
*
|
|
770
|
-
* the `background` lists. Per CLI process, as is a session. */
|
|
746
|
+
/** The terminals of the commands that Claude Code runs in the background
|
|
747
|
+
* for the session, kept for a client that renders terminals and is not
|
|
748
|
+
* AIR (AIR shows a command through its async tasks). Per CLI process, as
|
|
749
|
+
* is a session. */
|
|
771
750
|
background: SessionBackgroundWork;
|
|
772
751
|
/** The parent tool call of each subagent that a settle bookend removed from
|
|
773
752
|
* `liveBackgroundTasks`. The SDK can resume such a subagent under the same
|
|
@@ -915,191 +894,7 @@ export declare function computeSessionFingerprint(params: {
|
|
|
915
894
|
systemPrompt?: NewSessionRequest["systemPrompt"];
|
|
916
895
|
_meta?: NewSessionRequest["_meta"];
|
|
917
896
|
}): string;
|
|
918
|
-
export type SDKMessageFilter = {
|
|
919
|
-
type: string;
|
|
920
|
-
subtype?: string;
|
|
921
|
-
origin?: SDKMessageOrigin["kind"];
|
|
922
|
-
};
|
|
923
|
-
/**
|
|
924
|
-
* Extra metadata that can be given when creating a new session.
|
|
925
|
-
*/
|
|
926
|
-
export type NewSessionMeta = {
|
|
927
|
-
claudeCode?: {
|
|
928
|
-
/**
|
|
929
|
-
* Options forwarded to Claude Code when starting a new session.
|
|
930
|
-
* Those parameters will be ignored and managed by ACP:
|
|
931
|
-
* - cwd
|
|
932
|
-
* - includePartialMessages
|
|
933
|
-
* - permissionMode
|
|
934
|
-
* - canUseTool
|
|
935
|
-
* - executable
|
|
936
|
-
* Those parameters will be used and updated to work with ACP:
|
|
937
|
-
* - hooks (merged with ACP's hooks)
|
|
938
|
-
* - mcpServers (merged with ACP's mcpServers)
|
|
939
|
-
* - disallowedTools (merged with ACP's disallowedTools)
|
|
940
|
-
* - tools (passed through; defaults to claude_code preset if not provided)
|
|
941
|
-
* - allowDangerouslySkipPermissions (set to `false` to remove bypassPermissions
|
|
942
|
-
* from this session; repeat it on session/load. `true` cannot override root)
|
|
943
|
-
*/
|
|
944
|
-
options?: Options;
|
|
945
|
-
/**
|
|
946
|
-
* When set, raw SDK messages are emitted as extNotification("_claude/sdkMessage", message)
|
|
947
|
-
* in addition to normal processing.
|
|
948
|
-
* - true: emit all messages
|
|
949
|
-
* - false/undefined: emit nothing (default)
|
|
950
|
-
* - SDKMessageFilter[]: emit only messages matching at least one filter
|
|
951
|
-
*/
|
|
952
|
-
emitRawSDKMessages?: boolean | SDKMessageFilter[];
|
|
953
|
-
};
|
|
954
|
-
additionalRoots?: string[];
|
|
955
|
-
};
|
|
956
|
-
/**
|
|
957
|
-
* Extra metadata for 'gateway' authentication requests.
|
|
958
|
-
*/
|
|
959
|
-
type GatewayAuthMeta = {
|
|
960
|
-
/**
|
|
961
|
-
* These parameters are mapped to environment variables to:
|
|
962
|
-
* - Redirect API calls via baseUrl
|
|
963
|
-
* - Inject custom headers
|
|
964
|
-
* - Bypass the default Claude login requirement
|
|
965
|
-
*
|
|
966
|
-
* Both members are optional in the type because the payload arrives
|
|
967
|
-
* unvalidated from the client. `authenticate` rejects a request that lacks a
|
|
968
|
-
* usable `baseUrl`.
|
|
969
|
-
*/
|
|
970
|
-
gateway?: {
|
|
971
|
-
baseUrl?: string;
|
|
972
|
-
headers?: Record<string, string>;
|
|
973
|
-
};
|
|
974
|
-
};
|
|
975
|
-
type GatewayAuthRequest = AuthenticateRequest & {
|
|
976
|
-
_meta?: GatewayAuthMeta;
|
|
977
|
-
};
|
|
978
|
-
/**
|
|
979
|
-
* Resolved, non-secret + secret routing config for the `main` provider. This is
|
|
980
|
-
* the shared shape produced by both `providers/set` and the legacy gateway auth
|
|
981
|
-
* path, and consumed by {@link createEnvForProvider}. `null` means the provider
|
|
982
|
-
* is unconfigured (no client-managed routing in effect).
|
|
983
|
-
*/
|
|
984
|
-
type ProviderConfig = {
|
|
985
|
-
apiType: LlmProtocol;
|
|
986
|
-
baseUrl: string;
|
|
987
|
-
headers: Record<string, string>;
|
|
988
|
-
/** Present only for `apiType === "vertex"`. */
|
|
989
|
-
vertex?: {
|
|
990
|
-
projectId: string;
|
|
991
|
-
region: string;
|
|
992
|
-
};
|
|
993
|
-
/**
|
|
994
|
-
* Model ids an `anthropic` or `bedrock` gateway listed when it was set via
|
|
995
|
-
* `providers/set`; the model picker offers only these. Absent when the
|
|
996
|
-
* listing failed or the config came from elsewhere (gateway `authenticate`),
|
|
997
|
-
* so nothing is narrowed.
|
|
998
|
-
*/
|
|
999
|
-
listedModels?: string[];
|
|
1000
|
-
/**
|
|
1001
|
-
* The cross-region prefix of the model ids a `bedrock` gateway
|
|
1002
|
-
* listed (`eu` for `eu.anthropic.claude-sonnet-5`), passed to the CLI as
|
|
1003
|
-
* `ANTHROPIC_BEDROCK_REGION_PREFIX` so it calls the models under that prefix.
|
|
1004
|
-
*/
|
|
1005
|
-
bedrockRegionPrefix?: string;
|
|
1006
|
-
};
|
|
1007
897
|
export type { ToolUpdateMeta } from "./tool-calls/renderer.js";
|
|
1008
|
-
export type ToolUseCache = {
|
|
1009
|
-
[key: string]: {
|
|
1010
|
-
type: "tool_use" | "server_tool_use" | "mcp_tool_use";
|
|
1011
|
-
id: string;
|
|
1012
|
-
name: string;
|
|
1013
|
-
input: unknown;
|
|
1014
|
-
};
|
|
1015
|
-
};
|
|
1016
|
-
type StreamedToolInput = {
|
|
1017
|
-
id: string;
|
|
1018
|
-
name: string;
|
|
1019
|
-
partialJson: string;
|
|
1020
|
-
inString: boolean;
|
|
1021
|
-
escaped: boolean;
|
|
1022
|
-
objectDepth: number;
|
|
1023
|
-
arrayDepth: number;
|
|
1024
|
-
/** Offset of the most recent comma at the top level of the input object
|
|
1025
|
-
* (-1 before the first). Everything before it is a complete field. */
|
|
1026
|
-
lastTopLevelComma: number;
|
|
1027
|
-
/** The comma offset the last emitted refinement was sliced at (-1 before the
|
|
1028
|
-
* first), so a field boundary only triggers one recovery attempt. */
|
|
1029
|
-
emittedThroughComma: number;
|
|
1030
|
-
};
|
|
1031
|
-
export type StreamedToolInputCache = Map<string, Map<number, StreamedToolInput>>;
|
|
1032
|
-
/**
|
|
1033
|
-
* Return user-message content with local-command and injected-context marker
|
|
1034
|
-
* tags removed, or `null` if nothing meaningful remains (caller should skip
|
|
1035
|
-
* the message). Preserves real prose that's mixed in alongside the markers —
|
|
1036
|
-
* e.g. a message like `<command-name>…</command-name>hi` becomes `hi`, and
|
|
1037
|
-
* `hi<system-reminder>…</system-reminder>` becomes `hi`.
|
|
1038
|
-
*/
|
|
1039
|
-
export declare function stripLocalCommandMetadata(content: unknown): unknown | null;
|
|
1040
|
-
export declare function isLocalCommandMetadata(content: unknown): boolean;
|
|
1041
|
-
/**
|
|
1042
|
-
* True when CLI error text tells the user to sign in with `/login`. The CLI
|
|
1043
|
-
* words this several ways — "Not logged in · Please run /login", "Not logged
|
|
1044
|
-
* in · Run /login", "Login expired · Run /login to sign in again, or
|
|
1045
|
-
* re-authenticate your Anthropic profile" — so match the "run /login"
|
|
1046
|
-
* instruction rather than one sentence.
|
|
1047
|
-
*/
|
|
1048
|
-
export declare function isLoginRequiredText(text: string): boolean;
|
|
1049
|
-
/**
|
|
1050
|
-
* True for the synthetic assistant message the CLI injects into the transcript
|
|
1051
|
-
* when a turn fails authentication (e.g. "Not logged in · Please run /login",
|
|
1052
|
-
* "Session expired. Please run /login to sign in again."). The `/login`
|
|
1053
|
-
* instruction is Claude Code TUI-specific and meaningless to ACP clients
|
|
1054
|
-
* (issue #863). The live prompt loop suppresses the text and fails the turn
|
|
1055
|
-
* with `authRequired` so the client can run its own auth flow; replay must
|
|
1056
|
-
* skip it too — both for parity with what the client saw live and because the
|
|
1057
|
-
* message stays in the transcript forever, so it would resurface on every
|
|
1058
|
-
* session/load even after the user has logged back in.
|
|
1059
|
-
*
|
|
1060
|
-
* Takes the API message (`message.message`), which replay only knows as
|
|
1061
|
-
* `unknown`. The persisted record's structured `error` marker is stripped by
|
|
1062
|
-
* `getSessionMessages`, and the CLI does not always set it to
|
|
1063
|
-
* `authentication_failed` anyway: an expired login with no refresh token
|
|
1064
|
-
* ("Login expired · Run /login to sign in again, …") arrives as
|
|
1065
|
-
* `invalid_request`. So the synthetic model + text is what both paths match on.
|
|
1066
|
-
* Usage-limit banners are excluded because some of them also mention `/login`
|
|
1067
|
-
* (to switch accounts) and have their own handling.
|
|
1068
|
-
*/
|
|
1069
|
-
export declare function isSyntheticLoginMessage(apiMessage: unknown): boolean;
|
|
1070
|
-
/**
|
|
1071
|
-
* True for a transcript message delivered to the model from another agent,
|
|
1072
|
-
* session or channel. Since SDK 0.3.284 `getSessionMessages` returns these as
|
|
1073
|
-
* `is_meta` user messages whose content is the full harness framing (envelope
|
|
1074
|
-
* XML plus the "not typed by your user" preamble). The live prompt loop never
|
|
1075
|
-
* renders them, so replay skips them too rather than presenting them as text
|
|
1076
|
-
* the user typed. Other `is_meta` messages (compact summaries) are kept.
|
|
1077
|
-
*
|
|
1078
|
-
* `is_meta` and `origin` are runtime fields not declared on `SessionMessage`.
|
|
1079
|
-
*/
|
|
1080
|
-
export declare function isReplayHiddenMetaMessage(message: unknown): boolean;
|
|
1081
|
-
/**
|
|
1082
|
-
* Client-facing surface the agent calls back into. This is the subset of ACP
|
|
1083
|
-
* client methods the agent actually uses, expressed as a narrow interface so
|
|
1084
|
-
* tests can supply lightweight mocks. In production it is backed by
|
|
1085
|
-
* {@link ClientConnection} over the SDK's typed `AgentContext`.
|
|
1086
|
-
*/
|
|
1087
|
-
export interface AcpClient {
|
|
1088
|
-
sessionUpdate(params: AcpSessionNotification): Promise<void>;
|
|
1089
|
-
/** `signal`, when aborted, sends `$/cancel_request` for the in-flight
|
|
1090
|
-
* permission request so the client can dismiss its prompt, and rejects the
|
|
1091
|
-
* call at once: a client that ignores the cancel never answers. */
|
|
1092
|
-
requestPermission(params: AcpPermissionRequest, signal?: AbortSignal): Promise<RequestPermissionResponse>;
|
|
1093
|
-
readTextFile(params: ReadTextFileRequest): Promise<ReadTextFileResponse>;
|
|
1094
|
-
writeTextFile(params: WriteTextFileRequest): Promise<WriteTextFileResponse>;
|
|
1095
|
-
/** `signal`, when aborted, sends `$/cancel_request` for the in-flight
|
|
1096
|
-
* elicitation so the client can dismiss its prompt, and rejects the call
|
|
1097
|
-
* at once, as {@link requestPermission} does. */
|
|
1098
|
-
createElicitation(params: CreateElicitationRequest, signal?: AbortSignal): Promise<CreateElicitationResponse>;
|
|
1099
|
-
completeElicitation(params: CompleteElicitationNotification): Promise<void>;
|
|
1100
|
-
/** Send a custom (extension) notification, e.g. `_claude/sdkMessage`. */
|
|
1101
|
-
extNotification(method: string, params: Record<string, unknown>): Promise<void>;
|
|
1102
|
-
}
|
|
1103
898
|
export declare class ClaudeAcpAgent {
|
|
1104
899
|
sessions: {
|
|
1105
900
|
[key: string]: Session;
|
|
@@ -1118,27 +913,11 @@ export declare class ClaudeAcpAgent {
|
|
|
1118
913
|
/** Per session: queue that runs mode/config changes and query restarts one at a time. */
|
|
1119
914
|
private readonly configurationChanges;
|
|
1120
915
|
private readonly exitPlan;
|
|
1121
|
-
/**
|
|
1122
|
-
* `authenticate`/`logout`.
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
/** In-flight `claude auth status --json` probe, shared by every caller so
|
|
1127
|
-
* a concurrent `initialize` and start-of-prompt read never spawn two CLI
|
|
1128
|
-
* processes. */
|
|
1129
|
-
private cliAuthProbe;
|
|
1130
|
-
/** Counts auth-affecting events (`authenticate`, `logout`) on this
|
|
1131
|
-
* connection. A probe records it at start and publishes only if it has not
|
|
1132
|
-
* moved, so a slow read can never overwrite a newer login or logout. */
|
|
1133
|
-
private authEpoch;
|
|
1134
|
-
/** Keeps the "session account told us nothing" note to one line per process
|
|
1135
|
-
* instead of one per session. */
|
|
1136
|
-
private loggedUninformativeAccount;
|
|
1137
|
-
/** Same, for the "client provider override active" note. */
|
|
1138
|
-
private loggedOverriddenAccount;
|
|
1139
|
-
/** Same, for the "the CLI probe timed out" warning: a wedged CLI stays wedged
|
|
1140
|
-
* and would otherwise warn once per probe, i.e. once per user prompt. */
|
|
1141
|
-
private loggedProbeTimeout;
|
|
916
|
+
/** The connection's `authStatus` state and pushes, connection-scoped like
|
|
917
|
+
* `authenticate`/`logout`. */
|
|
918
|
+
private readonly authStatus;
|
|
919
|
+
/** Last auth identity reported to the client. Undefined means "not determined yet". */
|
|
920
|
+
get currentAuthStatus(): AuthStatus | undefined;
|
|
1142
921
|
/** Grace period before a `session/cancel` forces a wedged prompt loop to
|
|
1143
922
|
* return "cancelled". See {@link DEFAULT_FORCE_CANCEL_GRACE_MS}. Mutable so
|
|
1144
923
|
* tests can shrink it. */
|
|
@@ -1146,12 +925,6 @@ export declare class ClaudeAcpAgent {
|
|
|
1146
925
|
/** How long `canUseTool` or a hook waits for the consumer to reach a tool
|
|
1147
926
|
* use (see `isStoppedWorkToolUse`). Mutable so tests can shrink it. */
|
|
1148
927
|
toolUseWaitMs: number;
|
|
1149
|
-
/**
|
|
1150
|
-
* The connection serves ACP v2 (`src/v2/`). The agent still speaks v1
|
|
1151
|
-
* types, except for the tool call content that v2 needs and v1 cannot
|
|
1152
|
-
* express: see {@link ToolCallClientCapabilities.v2}.
|
|
1153
|
-
*/
|
|
1154
|
-
private readonly v2;
|
|
1155
928
|
/**
|
|
1156
929
|
* The subagent replay of each session's last load, until
|
|
1157
930
|
* {@link publishCurrentSubagentStates} sends its children's current states.
|
|
@@ -1163,10 +936,6 @@ export declare class ClaudeAcpAgent {
|
|
|
1163
936
|
* {@link publishReplayedChildModels}.
|
|
1164
937
|
*/
|
|
1165
938
|
private readonly replayedChildModels;
|
|
1166
|
-
/** See the `foreground` constructor option. */
|
|
1167
|
-
private readonly foregroundEvents?;
|
|
1168
|
-
/** See the `background` constructor option. */
|
|
1169
|
-
private readonly backgroundWork;
|
|
1170
939
|
/** Counts the prompts `startTurn()` has received, across sessions. */
|
|
1171
940
|
private promptsReceived;
|
|
1172
941
|
/** Per session, the `promptsReceived` count when its last cancel started.
|
|
@@ -1174,39 +943,23 @@ export declare class ClaudeAcpAgent {
|
|
|
1174
943
|
* yet ends as cancelled instead of being queued. */
|
|
1175
944
|
private readonly cancelledThrough;
|
|
1176
945
|
/**
|
|
1177
|
-
* The foreground work of each session while it runs
|
|
1178
|
-
*
|
|
1179
|
-
*
|
|
1180
|
-
*
|
|
1181
|
-
*
|
|
946
|
+
* The owner of the foreground work of each session while it runs (see
|
|
947
|
+
* {@link ForegroundOwner}), by the session id that the client knows. A
|
|
948
|
+
* clear-context restart replaces the Claude Code session behind that id and
|
|
949
|
+
* moves the running turn to it, so the work belongs to the id, not to a
|
|
950
|
+
* {@link Session}.
|
|
1182
951
|
*/
|
|
1183
952
|
private readonly foregroundWork;
|
|
1184
953
|
/** The session index (docs/air-extensions.md, "Session index"). */
|
|
1185
954
|
private readonly sessionIndex;
|
|
1186
955
|
/**
|
|
1187
956
|
* Whether a turn ends at its result while background subagents that it
|
|
1188
|
-
* spawned or resumed still run. Only an
|
|
957
|
+
* spawned or resumed still run. Only an AIR client that declares
|
|
1189
958
|
* `backgroundSubagents` gets this. Every other client keeps the hold of
|
|
1190
959
|
* `Turn.deferredSettle`.
|
|
1191
960
|
*/
|
|
1192
961
|
private endsTurnsWithLiveSubagents;
|
|
1193
|
-
constructor(client: AcpClient, logger?: Logger
|
|
1194
|
-
v2?: boolean;
|
|
1195
|
-
/**
|
|
1196
|
-
* Where the agent reports a session's foreground work (see
|
|
1197
|
-
* {@link ForegroundEvents}), called each time work starts in the session
|
|
1198
|
-
* `sessionId`. Without it, nothing reports the work, which the agent
|
|
1199
|
-
* still tracks: a v1 client has no session state, and learns that a turn
|
|
1200
|
-
* ended from its prompt response.
|
|
1201
|
-
*/
|
|
1202
|
-
foreground?: (sessionId: string) => ForegroundEvents;
|
|
1203
|
-
/**
|
|
1204
|
-
* Where the agent reports the background work of each session (see
|
|
1205
|
-
* `background-work.ts`): once when the session starts, and each time
|
|
1206
|
-
* the work changes. Without it, nothing reports the work.
|
|
1207
|
-
*/
|
|
1208
|
-
background?: BackgroundSink;
|
|
1209
|
-
});
|
|
962
|
+
constructor(client: AcpClient, logger?: Logger);
|
|
1210
963
|
initialize(request: InitializeRequest): Promise<InitializeResponse>;
|
|
1211
964
|
newSession(params: NewSessionRequest): Promise<NewSessionResponse>;
|
|
1212
965
|
/**
|
|
@@ -1257,66 +1010,12 @@ export declare class ClaudeAcpAgent {
|
|
|
1257
1010
|
}>;
|
|
1258
1011
|
/**
|
|
1259
1012
|
* `authenticate` — the legacy gateway methods store a provider override that
|
|
1260
|
-
* every later session reads
|
|
1261
|
-
*
|
|
1262
|
-
* `TypeError` deep in session creation, or installs an empty base URL that
|
|
1263
|
-
* silently turns the `--hide-claude-auth` subscription guard off.
|
|
1264
|
-
*
|
|
1265
|
-
* A call that carries no gateway payload at all keeps its historical
|
|
1266
|
-
* meaning: it installs no override and succeeds. That has always been a
|
|
1267
|
-
* no-op here, and a client that probes the method this way must keep
|
|
1268
|
-
* working. Only a payload that IS present has to be usable.
|
|
1013
|
+
* every later session reads, once {@link validatedGatewayAuthRequest} accepts
|
|
1014
|
+
* its payload.
|
|
1269
1015
|
*/
|
|
1270
1016
|
authenticate(_params: AuthenticateRequest): Promise<void>;
|
|
1271
|
-
/**
|
|
1272
|
-
* Stores `next` and pushes it to the client.
|
|
1273
|
-
*
|
|
1274
|
-
* A push goes out only when the payload changed. The identity is read on many
|
|
1275
|
-
* occasions — each session create, each guarded turn, the start of each user
|
|
1276
|
-
* prompt — and almost all of them see the same login. Clients replace their
|
|
1277
|
-
* whole state on each update and tolerate duplicates, so a repeat is
|
|
1278
|
-
* harmless, but it is also pure noise; {@link sameAuthStatus} drops it.
|
|
1279
|
-
*
|
|
1280
|
-
* What the agent owes is truth — a stale or uninformative source must not
|
|
1281
|
-
* reach here at all (see the epoch check in the probe and the guards at
|
|
1282
|
-
* session create).
|
|
1283
|
-
*/
|
|
1017
|
+
/** Stores `next` and pushes it to the client when it changed (see {@link AuthStatusReporter.set}). */
|
|
1284
1018
|
setAuthStatus(next: AuthStatus | undefined): void;
|
|
1285
|
-
/**
|
|
1286
|
-
* Report the identity behind a session's `AccountInfo`.
|
|
1287
|
-
*
|
|
1288
|
-
* `AccountInfo` is richer than the CLI probe (it is what the live query
|
|
1289
|
-
* actually authenticates with). Called before the `--hide-claude-auth` guard
|
|
1290
|
-
* may refuse the session or the turn: that flag blocks the *use* of a
|
|
1291
|
-
* subscription, it does not make the state secret, and a refusal is when the
|
|
1292
|
-
* client most needs to know the account it was refused for.
|
|
1293
|
-
*
|
|
1294
|
-
* Two cases skip it:
|
|
1295
|
-
*
|
|
1296
|
-
* - ACP gateway *authentication* (`gatewayAuthRequest`): the gateway, not
|
|
1297
|
-
* this account, is the agent-owned identity — already reported as
|
|
1298
|
-
* `kind: "gateway"` by `authenticate`.
|
|
1299
|
-
* - A client-driven provider override (`providers/set`): the session then
|
|
1300
|
-
* routes through the client's endpoint and `AccountInfo` describes that
|
|
1301
|
-
* route (e.g. `apiProvider: "gateway"`), which is NOT agent-owned state.
|
|
1302
|
-
* `authStatus` reports the agent's own login only, so the CLI probe —
|
|
1303
|
-
* which reads the credential store the override never touches — stays
|
|
1304
|
-
* authoritative.
|
|
1305
|
-
*
|
|
1306
|
-
* An account with no identity signal (e.g. `{apiProvider: "firstParty"}`
|
|
1307
|
-
* under an apiKeyHelper) means "nothing to add", not "logged out" — keep
|
|
1308
|
-
* what the CLI probe already established instead of overwriting it.
|
|
1309
|
-
*/
|
|
1310
|
-
private useAuthStatusSettings;
|
|
1311
|
-
private publishSessionAccountIdentity;
|
|
1312
|
-
/** Shares one in-flight `claude auth status --json` run between callers. The
|
|
1313
|
-
* promise is released once settled so a later call re-probes instead of
|
|
1314
|
-
* replaying a stale verdict. `fresh` forces a new run even when one is in
|
|
1315
|
-
* flight — `logout` needs a read that started after the credentials were
|
|
1316
|
-
* cleared. */
|
|
1317
|
-
private probeCliAuthStatus;
|
|
1318
|
-
/** Never rejects: an unavailable CLI means "not reported", not an error. */
|
|
1319
|
-
private runCliAuthProbe;
|
|
1320
1019
|
/**
|
|
1321
1020
|
* Feed the completed probe to the `--hide-claude-auth` guard.
|
|
1322
1021
|
*
|
|
@@ -1337,10 +1036,9 @@ export declare class ClaudeAcpAgent {
|
|
|
1337
1036
|
private markSessionsWhoseAccountKindChanged;
|
|
1338
1037
|
unstable_listProviders(_params: ListProvidersRequest): Promise<ListProvidersResponse>;
|
|
1339
1038
|
/**
|
|
1340
|
-
* `providers/set` — replace the full configuration for the `main` provider
|
|
1341
|
-
*
|
|
1342
|
-
*
|
|
1343
|
-
* loaded after this call.
|
|
1039
|
+
* `providers/set` — replace the full configuration for the `main` provider
|
|
1040
|
+
* (validated by {@link providerConfigFromSetRequest}). Config is
|
|
1041
|
+
* process-scoped and applies to sessions created or loaded after this call.
|
|
1344
1042
|
*/
|
|
1345
1043
|
unstable_setProvider(params: SetProviderRequest): Promise<SetProviderResponse>;
|
|
1346
1044
|
/**
|
|
@@ -1348,16 +1046,7 @@ export declare class ClaudeAcpAgent {
|
|
|
1348
1046
|
* backend slot and restores the agent's native routing state.
|
|
1349
1047
|
*/
|
|
1350
1048
|
unstable_disableProvider(params: DisableProviderRequest): Promise<DisableProviderResponse>;
|
|
1351
|
-
/**
|
|
1352
|
-
* The model ids the gateway in `config` lists, read before `providers/set`
|
|
1353
|
-
* returns so the sessions it recreates already offer only those, and for
|
|
1354
|
-
* `bedrock` the region prefix picked from them. Setting the same gateway
|
|
1355
|
-
* again reuses the previous listing. `vertex` gateways are not listed.
|
|
1356
|
-
* Throws a {@link GatewayListingError} when the listing fails.
|
|
1357
|
-
*/
|
|
1358
|
-
private listProviderModels;
|
|
1359
1049
|
resolveProviderConfig(): ProviderConfig | null;
|
|
1360
|
-
private defaultProviderConfig;
|
|
1361
1050
|
logout(_params: LogoutRequest): Promise<void>;
|
|
1362
1051
|
/** The structured replacement for a prompt that is exactly `/usage` or a
|
|
1363
1052
|
* `/mcp` command. Claude Code runs the command, and the replacement takes
|
|
@@ -1371,8 +1060,7 @@ export declare class ClaudeAcpAgent {
|
|
|
1371
1060
|
*
|
|
1372
1061
|
* A content block that the agent does not advertise, such as `audio`, fails
|
|
1373
1062
|
* the request with invalid params (-32602) before anything is queued:
|
|
1374
|
-
* `promptToClaude` would drop it.
|
|
1375
|
-
* `v1PromptRequest`, which rejects these blocks itself.
|
|
1063
|
+
* `promptToClaude` would drop it.
|
|
1376
1064
|
*/
|
|
1377
1065
|
prompt(params: PromptRequest, origin?: TurnOrigin): Promise<PromptResponse>;
|
|
1378
1066
|
/**
|
|
@@ -1382,7 +1070,7 @@ export declare class ClaudeAcpAgent {
|
|
|
1382
1070
|
* before this resolves.
|
|
1383
1071
|
*/
|
|
1384
1072
|
startTurn(params: PromptRequest, events: TurnEvents, origin?: TurnOrigin): Promise<void>;
|
|
1385
|
-
/**
|
|
1073
|
+
/** Runs the command, and sends its reply (see `runRemoteControlCommand`). */
|
|
1386
1074
|
private runRemoteControlCommand;
|
|
1387
1075
|
/** `--hide-claude-auth` applies only to the CLI's own login. A provider
|
|
1388
1076
|
* override (`providers/set` or gateway `authenticate`) routes traffic away
|
|
@@ -1472,9 +1160,10 @@ export declare class ClaudeAcpAgent {
|
|
|
1472
1160
|
goal(params: GoalRequest): Promise<GoalControlResponse>;
|
|
1473
1161
|
private publishGoal;
|
|
1474
1162
|
/**
|
|
1475
|
-
*
|
|
1476
|
-
*
|
|
1477
|
-
*
|
|
1163
|
+
* Sends the `_meta` of a session's {@link PromptSuggestions}: the follow-up
|
|
1164
|
+
* prompt the CLI predicted for the next turn, or the clear of the one the
|
|
1165
|
+
* client holds. Only AIR renders it, so only an AIR session has the state;
|
|
1166
|
+
* see `docs/air-extensions.md`.
|
|
1478
1167
|
*/
|
|
1479
1168
|
private publishPromptSuggestion;
|
|
1480
1169
|
private publishTaskPlan;
|
|
@@ -1599,40 +1288,14 @@ export declare class ClaudeAcpAgent {
|
|
|
1599
1288
|
private closeQueryStream;
|
|
1600
1289
|
/** Cleanly tear down a session: cancel in-flight work, release stream
|
|
1601
1290
|
* resources, and remove it from the session map. Returns once the turns it
|
|
1602
|
-
* cancels have ended, so their
|
|
1603
|
-
*
|
|
1604
|
-
* `session/close` cancels "as if `session/cancel` had been called", then
|
|
1605
|
-
* frees the session. A wedged consumer holds it at most
|
|
1291
|
+
* cancels have ended, so their `session/prompt` responses go out before
|
|
1292
|
+
* the caller answers. A wedged consumer holds it at most
|
|
1606
1293
|
* {@link TEARDOWN_TURN_END_TIMEOUT_MS}. */
|
|
1607
1294
|
private teardownSession;
|
|
1608
1295
|
/** Tear down all active sessions. Called when the ACP connection closes. */
|
|
1609
1296
|
dispose(): Promise<void>;
|
|
1610
1297
|
/** Idempotent: a session that is not loaded here is already closed. */
|
|
1611
1298
|
closeSession(params: CloseSessionRequest): Promise<CloseSessionResponse>;
|
|
1612
|
-
/** Stops a command running in the background (v2 `terminal/cancel`, see
|
|
1613
|
-
* {@link cancelBackgroundWork}). */
|
|
1614
|
-
cancelBackgroundTerminal(params: {
|
|
1615
|
-
sessionId: string;
|
|
1616
|
-
terminalId: string;
|
|
1617
|
-
}): Promise<void>;
|
|
1618
|
-
/** Stops the task of a tool call running in the background (v2
|
|
1619
|
-
* `tool_call/cancel`, see {@link cancelBackgroundWork}). */
|
|
1620
|
-
cancelBackgroundToolCall(params: {
|
|
1621
|
-
sessionId: string;
|
|
1622
|
-
toolCallId: string;
|
|
1623
|
-
}): Promise<void>;
|
|
1624
|
-
/** Sends the current state of each tool call in `toolCallIds` that the root
|
|
1625
|
-
* session `sessionId` runs in the background: the call as its tool use
|
|
1626
|
-
* shows it, with its status now. v2 requires it for each tool call that a
|
|
1627
|
-
* `session/resume` snapshot lists. A failure is logged, as for
|
|
1628
|
-
* {@link publishLiveSubagents}. */
|
|
1629
|
-
publishBackgroundToolCalls(sessionId: string, toolCallIds: string[]): Promise<void>;
|
|
1630
|
-
/** Sends the current `subagent_update` of each live subagent session in
|
|
1631
|
-
* `children`, of the session `sessionId` (see
|
|
1632
|
-
* {@link NativeSubagentRuntime.currentUpdate}). v2 requires it for each
|
|
1633
|
-
* child that a `session/resume` snapshot lists. A failure is logged, as
|
|
1634
|
-
* for {@link publishCurrentSubagentStates}. */
|
|
1635
|
-
publishLiveSubagents(sessionId: string, children: string[]): Promise<void>;
|
|
1636
1299
|
/** Per client: see {@link sessionIndex.SessionIndexConnection.deleteSession}. */
|
|
1637
1300
|
deleteSession(params: DeleteSessionRequest): Promise<DeleteSessionResponse>;
|
|
1638
1301
|
setSessionMode(params: SetSessionModeRequest): Promise<SetSessionModeResponse>;
|
|
@@ -1651,65 +1314,32 @@ export declare class ClaudeAcpAgent {
|
|
|
1651
1314
|
* conversation) as awaiting user input for exactly the lifetime of its
|
|
1652
1315
|
* promise (see `Session.openUserInputs`). Steering consults the open
|
|
1653
1316
|
* requests synchronously, so a message arriving while any permission or
|
|
1654
|
-
* elicitation card is open uses non-interrupting SDK delivery.
|
|
1655
|
-
*
|
|
1656
|
-
* `signal` aborts when Claude Code withdraws the request, which is not an
|
|
1657
|
-
* answer. Example: the user cancels while a permission request is open.
|
|
1658
|
-
* Claude Code's interrupt withdraws it as it stops the work, and the work
|
|
1659
|
-
* ends `idle cancelled` right after. The end of the request then reports
|
|
1660
|
-
* no `running`: the client would see `requires_action`, `running`, `idle
|
|
1661
|
-
* cancelled`. A withdrawal without a cancel means that something else
|
|
1662
|
-
* answered the request in the user's place, such as a `PermissionRequest`
|
|
1663
|
-
* hook, and the work goes on, so the end reports `running`. */
|
|
1317
|
+
* elicitation card is open uses non-interrupting SDK delivery. */
|
|
1664
1318
|
private withPendingUserInput;
|
|
1665
|
-
/** Report whether the session's foreground work awaits the user: exactly
|
|
1666
|
-
* while a permission request or question that blocks it is open (see
|
|
1667
|
-
* {@link blocksForeground}). A request does not say which prompt it is for,
|
|
1668
|
-
* and Claude Code can ask for a queued prompt before the consumer activates
|
|
1669
|
-
* it, so a request is not tied to the work that was running when it
|
|
1670
|
-
* opened. Called when a request opens or closes, when a turn activates, and
|
|
1671
|
-
* when a task registers or moves to the background.
|
|
1672
|
-
*
|
|
1673
|
-
* When the last request ends, the work reports `running` again, unless a
|
|
1674
|
-
* cancel withdrew that request (`withdrawnByCancel`, see
|
|
1675
|
-
* {@link withPendingUserInput}): the work is being stopped, and reports its
|
|
1676
|
-
* end next. */
|
|
1677
|
-
private syncAwaitingUser;
|
|
1678
1319
|
/** Whether Claude is working in the session `sessionId`: an unsettled turn in
|
|
1679
1320
|
* its queue, or foreground work that no turn owns, such as a cycle that
|
|
1680
1321
|
* Claude Code started on its own. */
|
|
1681
1322
|
private claudeIsWorking;
|
|
1682
|
-
/** Sends the current title and `updatedAt` of the session `sessionId` as a
|
|
1683
|
-
* `session_info_update` (see {@link SessionTitles.publishCurrent}). A
|
|
1684
|
-
* failure is logged: the info is optional, so it does not fail a resume. */
|
|
1685
|
-
publishCurrentSessionInfo(sessionId: string): Promise<void>;
|
|
1686
|
-
/** The foreground state of the session `sessionId` now, as v2's
|
|
1687
|
-
* `state_update` names it: `idle` while no work runs, `requires_action`
|
|
1688
|
-
* while the work awaits the user (see {@link syncAwaitingUser}), and
|
|
1689
|
-
* `running` otherwise. */
|
|
1690
|
-
foregroundState(sessionId: string): "idle" | "running" | "requires_action";
|
|
1691
1323
|
/** Make `owner` the foreground work of the session `sessionId` (see
|
|
1692
|
-
* {@link
|
|
1693
|
-
*
|
|
1694
|
-
*
|
|
1695
|
-
* its own, and only the owner's end ends the work. */
|
|
1324
|
+
* {@link ForegroundOwner}). If work already runs, it goes on under
|
|
1325
|
+
* `owner`: a turn takes over a cycle that Claude Code started on its own,
|
|
1326
|
+
* and only the owner's end ends the work. */
|
|
1696
1327
|
private startForeground;
|
|
1697
|
-
/** End the foreground work of the session `sessionId
|
|
1698
|
-
*
|
|
1328
|
+
/** End the foreground work of the session `sessionId`, if `owner` is that
|
|
1329
|
+
* work. */
|
|
1699
1330
|
private endForeground;
|
|
1700
1331
|
/** Start a model cycle that Claude Code started on its own as the foreground
|
|
1701
|
-
* work (see {@link
|
|
1332
|
+
* work (see {@link ForegroundOwner}) when `message` is its first output:
|
|
1702
1333
|
* model output of the main conversation (not a subagent's) while no work
|
|
1703
1334
|
* runs. That includes a turn that v1 holds for its background subagents,
|
|
1704
1335
|
* whose work ended at its result, so its follow-up is a cycle. Output of
|
|
1705
1336
|
* the work a cancel stopped starts nothing (see Session.cancelled). */
|
|
1706
1337
|
private startAutonomousCycle;
|
|
1707
|
-
/** Whether the client has been told that the session's work ended:
|
|
1708
|
-
*
|
|
1709
|
-
*
|
|
1710
|
-
*
|
|
1711
|
-
*
|
|
1712
|
-
* tool calls still reach the client after a cancel. */
|
|
1338
|
+
/** Whether the client has been told that the session's work ended: by the
|
|
1339
|
+
* response to the turn's prompt, so no turn is active. The client is told
|
|
1340
|
+
* nothing of a cycle, so its end is its result or idle: until then, Claude
|
|
1341
|
+
* Code's results for the cycle's tool calls still reach the client after a
|
|
1342
|
+
* cancel. */
|
|
1713
1343
|
private workEndReported;
|
|
1714
1344
|
/** Whether the consumer drops what it reaches now as output of the work a
|
|
1715
1345
|
* cancel stopped: the client has been told that the work ended, and the
|
|
@@ -1769,9 +1399,9 @@ export declare class ClaudeAcpAgent {
|
|
|
1769
1399
|
/** `signal`, also aborted when `teardownSession` aborts the
|
|
1770
1400
|
* `abortController` of session `sessionId`. Claude Code aborts a callback's
|
|
1771
1401
|
* own signal when its query closes, but not necessarily before
|
|
1772
|
-
* `session/close` responds, and
|
|
1773
|
-
*
|
|
1774
|
-
*
|
|
1402
|
+
* `session/close` responds, and every pending permission request and
|
|
1403
|
+
* elicitation of the session is cancelled with `$/cancel_request` before
|
|
1404
|
+
* that response. */
|
|
1775
1405
|
private untilSessionClosed;
|
|
1776
1406
|
/** Settle the tool call `ensureToolCallEmitted` emitted for a
|
|
1777
1407
|
* SandboxNetworkAccess request once the request is answered. The callback
|
|
@@ -1810,41 +1440,24 @@ export declare class ClaudeAcpAgent {
|
|
|
1810
1440
|
*/
|
|
1811
1441
|
private subagentModels;
|
|
1812
1442
|
private subagentConfigurationHook;
|
|
1813
|
-
/**
|
|
1814
|
-
* Captures pre-execution patches for v2 Edit and Write tool calls.
|
|
1815
|
-
*
|
|
1816
|
-
* A v2 diff cannot hold the input's snippet, so the patch needs the file as
|
|
1817
|
-
* it was before the tool runs. Claude Code waits for the hook before running
|
|
1818
|
-
* the tool. If its streamed tool use has not arrived, the patch waits for
|
|
1819
|
-
* the tool call's first publication. The hook makes no permission decision,
|
|
1820
|
-
* and a failure only leaves the preview out.
|
|
1821
|
-
*/
|
|
1822
|
-
private fileChangePreviewHook;
|
|
1823
|
-
private previewFileChange;
|
|
1824
1443
|
canUseTool(sessionId: string): CanUseTool;
|
|
1825
1444
|
/**
|
|
1826
1445
|
* Handle elicitation requests that originate from MCP servers by forwarding
|
|
1827
|
-
* them to the client over ACP
|
|
1828
|
-
* server as `decline`. A request the user never saw, because the client did
|
|
1829
|
-
* not advertise its mode, we can't represent it, or the client answered with
|
|
1830
|
-
* an error, is a `cancel`.
|
|
1446
|
+
* them to the client over ACP (see {@link answerMcpElicitation}).
|
|
1831
1447
|
*/
|
|
1832
1448
|
private handleMcpElicitation;
|
|
1833
1449
|
/**
|
|
1834
1450
|
* Present the built-in AskUserQuestion tool's questions as an ACP form
|
|
1835
|
-
* elicitation and return the answers as the tool's `updatedInput
|
|
1836
|
-
* `canUseTool` since that is
|
|
1837
|
-
*
|
|
1838
|
-
* a
|
|
1451
|
+
* elicitation and return the answers as the tool's `updatedInput` (see
|
|
1452
|
+
* {@link answerAskUserQuestion}). Called from `canUseTool` since that is
|
|
1453
|
+
* where the SDK routes the tool's permission check. The elicitation goes to
|
|
1454
|
+
* `requestSessionId`, a subagent's child session for a question it asks,
|
|
1455
|
+
* and blocks the turn of `sessionId`.
|
|
1839
1456
|
*/
|
|
1840
1457
|
private handleAskUserQuestion;
|
|
1841
1458
|
/**
|
|
1842
1459
|
* Handle `request_user_dialog` control requests — blocking dialogs the CLI
|
|
1843
|
-
* asks the host to render
|
|
1844
|
-
* are ever emitted; everything unexpected is answered `cancelled` (the
|
|
1845
|
-
* required answer for unrecognized kinds), which applies the dialog's
|
|
1846
|
-
* default behavior CLI-side. Today the only declared kind is the
|
|
1847
|
-
* refusal-fallback consent prompt, rendered as an ACP form elicitation.
|
|
1460
|
+
* asks the host to render (see {@link answerUserDialog}).
|
|
1848
1461
|
*/
|
|
1849
1462
|
private handleUserDialog;
|
|
1850
1463
|
/**
|
|
@@ -1869,17 +1482,9 @@ export declare class ClaudeAcpAgent {
|
|
|
1869
1482
|
/**
|
|
1870
1483
|
* The work that follows a session setup response: the session's commands,
|
|
1871
1484
|
* the current states of the subagents a load replayed, and MCP server
|
|
1872
|
-
* authentication.
|
|
1873
|
-
* work once they have sent their response, so it does nothing here.
|
|
1485
|
+
* authentication.
|
|
1874
1486
|
*/
|
|
1875
1487
|
private afterSetupResponse;
|
|
1876
|
-
/**
|
|
1877
|
-
* Starts OAuth in the background for the servers of `mcpServers` that
|
|
1878
|
-
* Claude Code reports as needing it, which sends the client a URL
|
|
1879
|
-
* elicitation. The v2 surface calls it after the setup response, since v2
|
|
1880
|
-
* asks for no elicitation before the `session/new` response.
|
|
1881
|
-
*/
|
|
1882
|
-
authenticateMcpServers(sessionId: string, mcpServers: McpServer[]): void;
|
|
1883
1488
|
/**
|
|
1884
1489
|
* Sends the current state of each subagent that the last load of
|
|
1885
1490
|
* `sessionId` replayed (see {@link RfdSubagentReplay.currentStates}). Run it
|
|
@@ -1898,21 +1503,12 @@ export declare class ClaudeAcpAgent {
|
|
|
1898
1503
|
private publishReplayedChildModels;
|
|
1899
1504
|
private updateConfigOption;
|
|
1900
1505
|
/**
|
|
1901
|
-
* Refine a heuristic context window with `getContextUsage().rawMaxTokens
|
|
1902
|
-
* without blocking the caller. The text heuristic
|
|
1903
|
-
* whose picker rows carry no "1m" token (e.g.
|
|
1904
|
-
* 2.1.283 `opus`/`default`), so those would
|
|
1905
|
-
* first result's modelUsage arrives.
|
|
1906
|
-
*
|
|
1907
|
-
* Never awaited: SDK control requests are serialized, so awaiting here
|
|
1908
|
-
* would delay session/new or a model switch (~15s on older CLIs, issues
|
|
1909
|
-
* #886/#880; ~0.5s on 2.1.283). Requests the `summary` detail instead of
|
|
1910
|
-
* the default `full` breakdown, which issues one `messages/count_tokens`
|
|
1911
|
-
* call per category (~18 for a bare session) and hit rate limits on every
|
|
1912
|
-
* model switch; `summary` answers locally with the same `rawMaxTokens`.
|
|
1913
|
-
*
|
|
1914
|
-
* Does not write `contextWindowCache` (that stays keyed to the
|
|
1915
|
-
* `result.modelUsage` spellings) — a later result still overwrites this.
|
|
1506
|
+
* Refine a heuristic context window with `getContextUsage().rawMaxTokens`
|
|
1507
|
+
* (`readContextWindow`), without blocking the caller. The text heuristic
|
|
1508
|
+
* misses natively-1M models whose picker rows carry no "1m" token (e.g.
|
|
1509
|
+
* `sonnet`, and since CLI 2.1.283 `opus`/`default`), so those would
|
|
1510
|
+
* otherwise show 200k until the first result's modelUsage arrives. A later
|
|
1511
|
+
* result still overwrites this.
|
|
1916
1512
|
*/
|
|
1917
1513
|
private refreshContextWindowInBackground;
|
|
1918
1514
|
private applyConfigOptionValue;
|
|
@@ -1944,25 +1540,14 @@ export declare class ClaudeAcpAgent {
|
|
|
1944
1540
|
* `fast_mode_state` (delivered on `system`/init and on user-turn `result`s).
|
|
1945
1541
|
* The SDK can flip fast mode independently of the user — e.g. back to `on`
|
|
1946
1542
|
* once a rate-limit `cooldown` clears — so we mirror definitive on/off
|
|
1947
|
-
* changes into the config option and notify the client
|
|
1543
|
+
* changes into the config option and notify the client (see
|
|
1544
|
+
* {@link fastModeStateChange}).
|
|
1948
1545
|
*
|
|
1949
|
-
*
|
|
1950
|
-
*
|
|
1951
|
-
*
|
|
1952
|
-
*
|
|
1953
|
-
*
|
|
1954
|
-
* reselected (the source of the earlier intent-clobber bug was mutating it
|
|
1955
|
-
* here).
|
|
1956
|
-
* - `cooldown`: a transient suspension of an already-enabled fast mode.
|
|
1957
|
-
* Leave the toggle as-is rather than flapping it — and never let a stray
|
|
1958
|
-
* cooldown spuriously enable a toggle the user has off.
|
|
1959
|
-
*
|
|
1960
|
-
* `reason` is the SDK's `fast_mode_disabled_reason`, reported alongside the
|
|
1961
|
-
* state. Only explainable reasons are retained (see
|
|
1962
|
-
* {@link normalizeFastModeDisabledReason}), so the comparison below tracks
|
|
1963
|
-
* exactly what the user can see: a routine `sdk_opt_in_required` report on
|
|
1964
|
-
* every turn's result can't churn the option, while a real blocker updates
|
|
1965
|
-
* the description even when the toggle's own value is unchanged. */
|
|
1546
|
+
* Without a Fast mode option the current model doesn't support fast mode,
|
|
1547
|
+
* so the reported state reflects capability, not the user's intent. The
|
|
1548
|
+
* retained setting stays untouched so it's correct when a supporting model
|
|
1549
|
+
* is reselected (the source of the earlier intent-clobber bug was mutating
|
|
1550
|
+
* it here). */
|
|
1966
1551
|
private syncFastModeState;
|
|
1967
1552
|
private getOrCreateSession;
|
|
1968
1553
|
/**
|
|
@@ -1994,120 +1579,6 @@ export declare class ClaudeAcpAgent {
|
|
|
1994
1579
|
/** Tell a capable client when a non-auth error ends a session during a provider switch. */
|
|
1995
1580
|
private reportSessionLostOnProviderUpdate;
|
|
1996
1581
|
}
|
|
1997
|
-
export declare const BUILTIN_AGENT_NAMES: Set<string>;
|
|
1998
|
-
/** Discover user/plugin/project-configured main-thread agents, excluding the
|
|
1999
|
-
* built-in subagents and the reserved "default" sentinel. Returns an empty
|
|
2000
|
-
* list if discovery fails so a flaky control request never blocks session
|
|
2001
|
-
* creation. */
|
|
2002
|
-
export declare function discoverCustomAgents(q: Query): Promise<AgentInfo[]>;
|
|
2003
|
-
/** Stable ids for the session config options surfaced via `configOptions`.
|
|
2004
|
-
* Centralized so the option declarations in `buildConfigOptions` and the
|
|
2005
|
-
* handlers in `setSessionConfigOption`/`applyConfigOptionValue` reference the
|
|
2006
|
-
* same identifiers and can't drift apart. */
|
|
2007
|
-
export { MODE_CONFIG_ID };
|
|
2008
|
-
export declare const AGENT_CONFIG_ID = "agent";
|
|
2009
|
-
export declare const FAST_MODE_CONFIG_ID = "fast";
|
|
2010
|
-
/** Select-fallback values used when the client has not opted into boolean
|
|
2011
|
-
* config options (see {@link createFastModeConfigOption}). */
|
|
2012
|
-
export declare const FAST_MODE_ON = "on";
|
|
2013
|
-
export declare const FAST_MODE_OFF = "off";
|
|
2014
|
-
/** Map the SDK's tri-state `fast_mode_state` onto the boolean config toggle.
|
|
2015
|
-
* `cooldown` (fast mode temporarily suspended after a rate limit, per the SDK
|
|
2016
|
-
* docs) keeps the toggle on so it reflects the user's intent — only an
|
|
2017
|
-
* explicit `off` clears it. */
|
|
2018
|
-
export declare function fastModeStateEnabled(state: FastModeState): boolean;
|
|
2019
|
-
/** Normalize an SDK-reported `fast_mode_disabled_reason` to the one we retain:
|
|
2020
|
-
* a reason we have an explanation for, else `undefined`. Keeping only
|
|
2021
|
-
* explainable reasons means state comparisons (see `syncFastModeState`) track
|
|
2022
|
-
* exactly what the user can see, so routine reports like
|
|
2023
|
-
* `sdk_opt_in_required` never churn the config option. */
|
|
2024
|
-
export declare function normalizeFastModeDisabledReason(reason: FastModeDisabledReason | undefined): FastModeDisabledReason | undefined;
|
|
2025
|
-
/** Whether the Client advertised support for boolean session config options
|
|
2026
|
-
* (`session.configOptions.boolean`). Agents MUST only send `type: "boolean"`
|
|
2027
|
-
* config options to Clients that opt in; otherwise we fall back to a `select`.
|
|
2028
|
-
* See https://agentclientprotocol.com/rfds/boolean-config-option. */
|
|
2029
|
-
export declare function clientSupportsBooleanConfigOptions(clientCapabilities?: ClientCapabilities | null): boolean;
|
|
2030
|
-
/** Whether the Client advertised the AIR `recommendedValue` capability for
|
|
2031
|
-
* select-style model and effort options. Missing or malformed AIR metadata
|
|
2032
|
-
* retains the legacy `default` entries. */
|
|
2033
|
-
export declare function clientSupportsRecommendedConfigValue(clientCapabilities?: ClientCapabilities | null): boolean;
|
|
2034
|
-
/** Build the Fast mode config option. When the Client supports boolean config
|
|
2035
|
-
* options we expose a native `type: "boolean"` toggle; otherwise we degrade to
|
|
2036
|
-
* a two-value `select` ("on"/"off") so older Clients still get a usable
|
|
2037
|
-
* control.
|
|
2038
|
-
*
|
|
2039
|
-
* `disabledReason` (the SDK's `fast_mode_disabled_reason`) is folded into the
|
|
2040
|
-
* description while the toggle reads off, so a user whose account or provider
|
|
2041
|
-
* can't serve Fast mode sees why instead of a switch that silently refuses to
|
|
2042
|
-
* stay on. Ignored while enabled: a reason reported alongside an `on`/`cooldown`
|
|
2043
|
-
* state isn't blocking anything right now. */
|
|
2044
|
-
export declare function createFastModeConfigOption(enabled: boolean, useBooleanOption: boolean, disabledReason?: FastModeDisabledReason): SessionConfigOption;
|
|
2045
|
-
/** Resolve the requested Fast mode value from a `session/set_config_option`
|
|
2046
|
-
* request. Accepts a native boolean (boolean-capable Clients) or the
|
|
2047
|
-
* "on"/"off" select-fallback strings. */
|
|
2048
|
-
export declare function resolveFastModeEnabled(params: SetSessionConfigOptionRequest): boolean;
|
|
2049
|
-
/** Per-model Fast mode state threaded into {@link buildConfigOptions}. The
|
|
2050
|
-
* option is only surfaced when the current model `supported`s fast mode. */
|
|
2051
|
-
export type FastModeOptionState = {
|
|
2052
|
-
supported: boolean;
|
|
2053
|
-
enabled: boolean;
|
|
2054
|
-
/** Whether the Client opted into boolean config options. */
|
|
2055
|
-
useBooleanOption: boolean;
|
|
2056
|
-
/** Latest explainable `fast_mode_disabled_reason`, folded into the option's
|
|
2057
|
-
* description while the toggle reads off. */
|
|
2058
|
-
disabledReason?: FastModeDisabledReason;
|
|
2059
|
-
};
|
|
2060
|
-
export type ConfigOptionPresentation = {
|
|
2061
|
-
/** Replace ambiguous `default` rows with concrete values and advertise the
|
|
2062
|
-
* SDK/adapter recommendation as `_meta.jetbrains.air.recommendedValue`. */
|
|
2063
|
-
useRecommendedValue: boolean;
|
|
2064
|
-
};
|
|
2065
|
-
export declare function buildConfigOptions(modes: SessionModeState, models: SessionModelState, modelInfos: ModelInfo[], currentEffortLevel?: string, agents?: AgentInfo[], currentAgent?: string, fastMode?: FastModeOptionState, presentation?: ConfigOptionPresentation, ultracode?: UltracodeOptionState): SessionConfigOption[];
|
|
2066
|
-
export declare function promptToClaude(prompt: PromptRequest): SDKUserMessage;
|
|
2067
|
-
/**
|
|
2068
|
-
* Resolves the ACP `messageId` for a Claude SDK message (live) or a persisted
|
|
2069
|
-
* transcript message (replay) so chunk grouping is identical in both views.
|
|
2070
|
-
*
|
|
2071
|
-
* Assistant turns are keyed by the Anthropic API message id (`message.id`),
|
|
2072
|
-
* which is identical at `message_start`, on the consolidated assistant message,
|
|
2073
|
-
* and in the persisted transcript — unlike the per-`stream_event` uuid, which is
|
|
2074
|
-
* unique per event and never persisted. User messages have no API id, but they
|
|
2075
|
-
* are never streamed, so their (stable) SDK uuid is used instead. ACP message
|
|
2076
|
-
* ids are opaque strings, so no particular format is required.
|
|
2077
|
-
*/
|
|
2078
|
-
export declare function messageIdForGrouping(message: {
|
|
2079
|
-
type?: string;
|
|
2080
|
-
uuid?: string | null;
|
|
2081
|
-
message?: unknown;
|
|
2082
|
-
}): string | undefined;
|
|
2083
|
-
export declare function toAcpNotifications(content: string | ContentBlockParam[] | BetaContentBlock[] | BetaRawContentBlockDelta[], role: "assistant" | "user", sessionId: string, toolUseCache: ToolUseCache, client: AcpClient, logger: Logger, options?: {
|
|
2084
|
-
registerHooks?: boolean;
|
|
2085
|
-
clientCapabilities?: ClientCapabilities;
|
|
2086
|
-
toolCallCapabilities?: ToolCallClientCapabilities;
|
|
2087
|
-
parentToolUseId?: string | null;
|
|
2088
|
-
cwd?: string;
|
|
2089
|
-
taskState?: TaskState;
|
|
2090
|
-
subagentChecklists?: SubagentChecklists;
|
|
2091
|
-
emittedToolCalls?: Set<string>;
|
|
2092
|
-
inputComplete?: boolean;
|
|
2093
|
-
toolCallFields?: ToolCallFieldTracker;
|
|
2094
|
-
messageId?: string;
|
|
2095
|
-
toolUseResult?: unknown;
|
|
2096
|
-
toolResultMeta?: unknown;
|
|
2097
|
-
cancelled?: boolean;
|
|
2098
|
-
replay?: boolean;
|
|
2099
|
-
}): SessionNotification[];
|
|
2100
|
-
export declare function streamEventToAcpNotifications(message: SDKPartialAssistantMessage, sessionId: string, toolUseCache: ToolUseCache, client: AcpClient, logger: Logger, options?: {
|
|
2101
|
-
clientCapabilities?: ClientCapabilities;
|
|
2102
|
-
toolCallCapabilities?: ToolCallClientCapabilities;
|
|
2103
|
-
cwd?: string;
|
|
2104
|
-
taskState?: TaskState;
|
|
2105
|
-
subagentChecklists?: SubagentChecklists;
|
|
2106
|
-
emittedToolCalls?: Set<string>;
|
|
2107
|
-
toolCallFields?: ToolCallFieldTracker;
|
|
2108
|
-
messageId?: string;
|
|
2109
|
-
streamedToolInputs?: StreamedToolInputCache;
|
|
2110
|
-
}): SessionNotification[];
|
|
2111
1582
|
/** Run a `session/prompt` while honoring `$/cancel_request` for it. ACP clients
|
|
2112
1583
|
* normally stop a turn with the `session/cancel` notification, but `signal`
|
|
2113
1584
|
* (the prompt request's abort signal) also fires when the client sends the
|