@agentclientprotocol/claude-agent-acp 0.113.0 → 0.113.1-preview.10
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 -3
- package/dist/async-tasks.d.ts +27 -0
- package/dist/async-tasks.d.ts.map +1 -1
- package/dist/async-tasks.js +36 -0
- package/dist/claude-cli.d.ts +22 -16
- package/dist/claude-cli.d.ts.map +1 -1
- package/dist/claude-cli.js +40 -18
- package/dist/mcp-oauth.d.ts +3 -2
- package/dist/mcp-oauth.d.ts.map +1 -1
- package/dist/mcp-oauth.js +65 -27
- package/dist/resumed-session.d.ts +9 -2
- package/dist/resumed-session.d.ts.map +1 -1
- package/dist/resumed-session.js +51 -7
- package/dist/sdk-to-acp.js +4 -2
- package/dist/session-cursors.d.ts +1 -1
- package/dist/session-cursors.d.ts.map +1 -1
- package/dist/session-cursors.js +8 -2
- package/dist/session-index/service.d.ts.map +1 -1
- package/dist/session-index/service.js +9 -17
- package/dist/session-index/session-index.d.ts +1 -13
- package/dist/session-index/session-index.d.ts.map +1 -1
- package/dist/session-index/session-index.js +3 -29
- package/dist/session-index/transcript-scan.d.ts +17 -4
- package/dist/session-index/transcript-scan.d.ts.map +1 -1
- package/dist/session-index/transcript-scan.js +44 -3
- package/dist/session-mode.d.ts +38 -1
- package/dist/session-mode.d.ts.map +1 -1
- package/dist/session-mode.js +73 -15
- package/dist/session-read.d.ts +45 -0
- package/dist/session-read.d.ts.map +1 -0
- package/dist/session-read.js +300 -0
- package/dist/session-rewind.d.ts +6 -2
- package/dist/session-rewind.d.ts.map +1 -1
- package/dist/session-rewind.js +13 -4
- package/dist/session-ultracode.d.ts +14 -5
- package/dist/session-ultracode.d.ts.map +1 -1
- package/dist/session-ultracode.js +23 -11
- package/dist/startup-failure.d.ts +11 -1
- package/dist/startup-failure.d.ts.map +1 -1
- package/dist/startup-failure.js +33 -1
- package/dist/subagent-history.d.ts +9 -1
- package/dist/subagent-history.d.ts.map +1 -1
- package/dist/subagent-history.js +55 -13
- package/dist/v1/acp-agent.d.ts +8 -1
- package/dist/v1/acp-agent.d.ts.map +1 -1
- package/dist/v1/acp-agent.js +167 -87
- package/dist/v1/async-task-stop.d.ts +31 -0
- package/dist/v1/async-task-stop.d.ts.map +1 -1
- package/dist/v1/async-task-stop.js +41 -0
- package/dist/v1/session-read.d.ts +31 -0
- package/dist/v1/session-read.d.ts.map +1 -0
- package/dist/v1/session-read.js +62 -0
- package/dist/v2/agent.d.ts.map +1 -1
- package/dist/v2/agent.js +60 -25
- package/dist/v2/commands.d.ts +8 -3
- package/dist/v2/commands.d.ts.map +1 -1
- package/dist/v2/commands.js +4 -3
- package/dist/v2/config.d.ts +3 -3
- package/dist/v2/config.d.ts.map +1 -1
- package/dist/v2/config.js +11 -9
- package/dist/v2/session-read.d.ts +11 -0
- package/dist/v2/session-read.d.ts.map +1 -0
- package/dist/v2/session-read.js +28 -0
- package/dist/v2/session.d.ts.map +1 -1
- package/dist/v2/session.js +19 -2
- package/dist/v2/stream.d.ts +9 -13
- package/dist/v2/stream.d.ts.map +1 -1
- package/dist/v2/stream.js +10 -9
- package/dist/v2/subagent-replay.d.ts +16 -4
- package/dist/v2/subagent-replay.d.ts.map +1 -1
- package/dist/v2/subagent-replay.js +22 -10
- package/dist/v2/tasks.d.ts.map +1 -1
- package/dist/v2/tasks.js +5 -3
- package/package.json +8 -8
package/dist/v1/acp-agent.js
CHANGED
|
@@ -12,7 +12,7 @@ import { AIR_ASYNC_TASKS_CAPABILITY, AIR_BACKGROUND_SUBAGENTS_CAPABILITY, AIR_CU
|
|
|
12
12
|
import * as sessionIndex from "./session-index.js";
|
|
13
13
|
import { AsyncTaskRuntime, backgroundBashTaskFromToolResult, backgroundedBashToolCallIds, clientSupportsAsyncTasks, } from "../async-tasks.js";
|
|
14
14
|
import { SessionBackgroundWork } from "./background-work.js";
|
|
15
|
-
import { ASYNC_TASK_STOP_METHOD, parseAsyncTaskStopRequest, } from "./async-task-stop.js";
|
|
15
|
+
import { ASYNC_TASK_STOP_METHOD, parseAsyncTaskStopRequest, interruptAutonomousTurn, interruptKeepsWaitingPrompts, waitingPrompts, } from "./async-task-stop.js";
|
|
16
16
|
import { STEER_METHOD, parseSteerRequest, } from "./steering.js";
|
|
17
17
|
import { AUTH_STATUS_UPDATE_METHOD, authStatusCapability, fromAccountInfo, gatewayAuthStatus, notLoggedInAuthStatus, } from "../auth-status.js";
|
|
18
18
|
import { AuthStatusReporter, cliLogout } from "../auth-status-reporter.js";
|
|
@@ -28,9 +28,10 @@ import { answerAskUserQuestion, answerMcpElicitation, answerUserDialog, elicitUn
|
|
|
28
28
|
import { startMcpServerAuthentication as startSharedMcpServerAuthentication, supportsMcpOAuth, } from "../mcp-oauth.js";
|
|
29
29
|
import { forkSession } from "../fork-session.js";
|
|
30
30
|
import { anchoredForkCursorUpdate, forkCursorUpdate, hasForkCursor, LastReportedEntity, promptGetsCursor, withRewindCapability, } from "../session-cursors.js";
|
|
31
|
+
import { SESSION_READ_CAPABILITY, SESSION_READ_METHOD } from "../session-read.js";
|
|
31
32
|
import { cutAtRewindPoint, loadRewindableHistory, parseSessionRewindRequest, prepareRewoundResume, rewindSession, SESSION_REWIND_METHOD, } from "../session-rewind.js";
|
|
32
33
|
import { clientSystemPrompt, sessionSystemPrompt, SYSTEM_PROMPT_CAPABILITY, } from "../client-system-prompt.js";
|
|
33
|
-
import { readSubagentMessages, subagentHistory, subagentLaunchIds, subagentLaunchedBy, subagentLineage, } from "../subagent-history.js";
|
|
34
|
+
import { readSubagentMessages, readSubagentMessagesOrFail, subagentHistory, subagentLaunchIds, subagentLaunchedBy, subagentLineage, } from "../subagent-history.js";
|
|
34
35
|
import { RfdSubagentReplay, ReplayTranscript, replaySubagentTerminalState, } from "../subagent-replay.js";
|
|
35
36
|
import { readHistoryAcrossCompactions, readResumedSession, readResumedTail, } from "../resumed-session.js";
|
|
36
37
|
import { SessionTiming } from "../session-timing.js";
|
|
@@ -55,6 +56,7 @@ import { addModelUsage, getMatchingModelUsage, modelUsageIncrement, normalizeMod
|
|
|
55
56
|
import { previewPatchContent } from "../diff.js";
|
|
56
57
|
import { backgroundedBashToolCall, withRunningTerminal, withStreamedTerminal, } from "../tool-calls/background.js";
|
|
57
58
|
import { ChangedMetaClient, ClientConnection } from "./client-connection.js";
|
|
59
|
+
import { V1SessionReads } from "./session-read.js";
|
|
58
60
|
import { ToolCallFieldTracker } from "../tool-calls/field-tracker.js";
|
|
59
61
|
import { RetractedToolCalls } from "../tool-calls/retracted.js";
|
|
60
62
|
import { ClientCapabilities as ToolCallClientCapabilities } from "../tool-calls/client-capabilities.js";
|
|
@@ -71,18 +73,18 @@ import { MODE_CONFIG_ID, resolveInitialPermissionMode, SessionModeManager, } fro
|
|
|
71
73
|
import { aliasResumedModelRow, applyAvailableModelsAllowlist, getAvailableModels, MODEL_CONFIG_ID, modelDisplayName, modelEntryFor, narrowToGatewayModels, resolveModelPreference, withCurrentModelInfo, } from "../session-model.js";
|
|
72
74
|
import { applyProviderRoute, createEnvForProvider, defaultProviderConfig, gatewayRequestToProviderConfig, isGatewayAuthMethod, listProvidersResponse, loggableBaseUrl, PROVIDER_ID, providerConfigFromSetRequest, providerRouteSettings, validatedGatewayAuthRequest, withListedModels, } from "../providers.js";
|
|
73
75
|
import { EFFORT_CONFIG_ID, effortFlagSettings, effortForModelSwitch, mergeEffortSettings, settleEffortAfterModelSwitch, settingsEffortForModel, withoutEffort, } from "../session-effort.js";
|
|
74
|
-
import { createUltracodeConfigOption,
|
|
76
|
+
import { createUltracodeConfigOption, readSettingsReport, ULTRACODE_CONFIG_ID, ultracodeSupported, ultracodeWorkflowsEnabled, } from "../session-ultracode.js";
|
|
75
77
|
import { buildConfigOptions, clientSupportsBooleanConfigOptions, clientSupportsRecommendedConfigValue, configOptionValue, setSelectedModel, discoverCustomAgents, } from "../session-config-options.js";
|
|
76
78
|
import { applyFastModeFlag, createFastModeConfigOption, FAST_MODE_CONFIG_ID, fastModeResultIsNews, fastModeStateChange, fastModeStateEnabled, normalizeFastModeDisabledReason, } from "../session-fast-mode.js";
|
|
77
79
|
import { cacheResultContextWindow, clearContextWindowCache, immediateContextWindow, providerCacheKeyFor, readContextWindow, } from "../context-window.js";
|
|
78
80
|
import { isLoginRequiredText, resultEnd, turnErrorData } from "../result-end.js";
|
|
79
|
-
import { STARTUP_FAILURE_RESULTS_ENV, startupFailureError } from "../startup-failure.js";
|
|
81
|
+
import { STARTUP_FAILURE_RESULTS_ENV, rejectSkippedSettings, startupFailureError, } from "../startup-failure.js";
|
|
80
82
|
import { recordStreamedDelta, unstreamedRemainder } from "../streamed-text.js";
|
|
81
83
|
import { subagentHookOptions } from "../subagent-configuration.js";
|
|
82
84
|
import { isReplayHiddenMetaMessage, isSyntheticLoginMessage, LOCAL_ONLY_COMMANDS, stripLocalCommandMetadata, } from "../message-filters.js";
|
|
83
85
|
import { computeSessionFingerprint } from "./session-fingerprint.js";
|
|
84
86
|
import { promptToClaude, SUPPORTED_PROMPT_CONTENT_TYPES } from "../prompt-to-claude.js";
|
|
85
|
-
import {
|
|
87
|
+
import { isAbortedResult } from "../result-end.js";
|
|
86
88
|
import { messageIdForGrouping, stampParentToolUseId, streamEventToAcpNotifications, toAcpNotifications, } from "../sdk-to-acp.js";
|
|
87
89
|
import { getAvailableSlashCommands } from "../slash-commands.js";
|
|
88
90
|
/** Claude CLI emits this synthetic result when an interrupted cycle ends on
|
|
@@ -409,6 +411,7 @@ export class ClaudeAcpAgent {
|
|
|
409
411
|
announcedChildren = new AnnouncedChildren();
|
|
410
412
|
/** What anchors a live cursor: the last entity that the client holds per session. */
|
|
411
413
|
lastEntities = new LastReportedEntity();
|
|
414
|
+
sessionReads;
|
|
412
415
|
/**
|
|
413
416
|
* AIR's draft: the model that the last load of each session replayed to each
|
|
414
417
|
* child session, as the model id and the entry that went out. See
|
|
@@ -457,6 +460,7 @@ export class ClaudeAcpAgent {
|
|
|
457
460
|
mcp = new McpOverAcp()) {
|
|
458
461
|
this.mcp = mcp;
|
|
459
462
|
this.sessions = {};
|
|
463
|
+
this.sessionReads = new V1SessionReads(client);
|
|
460
464
|
this.client = new ChangedMetaClient(client, () => this.toolCallCapabilities.air.client, (update) => {
|
|
461
465
|
// Before the client can name the child that a `subagent_update` announces.
|
|
462
466
|
this.announcedChildren.sending(update);
|
|
@@ -635,6 +639,7 @@ export class ClaudeAcpAgent {
|
|
|
635
639
|
// Only AIR gets the AIR capabilities and the goal capability, under
|
|
636
640
|
// `jetbrains.air`.
|
|
637
641
|
_meta: {
|
|
642
|
+
sessionRead: SESSION_READ_CAPABILITY,
|
|
638
643
|
...(this.toolCallCapabilities.air.client
|
|
639
644
|
? withAirMeta(airSessionFailureCapabilityMeta(AGENT_FILE_CHANGE_REPORT_CAPABILITY, AIR_NATIVE_SUBAGENT_SESSIONS_CAPABILITY, AIR_ASYNC_TASKS_CAPABILITY, AIR_CUSTOM_INSTRUCTIONS_CAPABILITY, AIR_RECOMMENDED_CONFIG_VALUE_CAPABILITY, AIR_DIFF_PATCH_CAPABILITY, AIR_PLAN_FILE_CAPABILITY, AIR_BACKGROUND_SUBAGENTS_CAPABILITY, ...this.sessionIndex.capabilities(), ...(clientSupportsAirCapability(request.clientCapabilities, AIR_SESSION_REWIND_CAPABILITY)
|
|
640
645
|
? [AIR_SESSION_REWIND_CAPABILITY]
|
|
@@ -654,15 +659,15 @@ export class ClaudeAcpAgent {
|
|
|
654
659
|
// Without `configOptions`: a restart of the query restores the session's choices itself.
|
|
655
660
|
const { configOptions, ...request } = params;
|
|
656
661
|
const initial = initialConfigOptions(configOptions);
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
+
const resume = params._meta?.claudeCode?.options?.resume;
|
|
663
|
+
return this.sessionReads.transition(resume, "open", async () => {
|
|
664
|
+
while (this.providerUpdate)
|
|
665
|
+
await this.providerUpdate;
|
|
666
|
+
const created = await this.createSession(request, { resume });
|
|
667
|
+
const response = await this.withInitialConfigOptions(created, initial);
|
|
668
|
+
this.afterSetupResponse(response.sessionId, params.mcpServers);
|
|
669
|
+
return response;
|
|
662
670
|
});
|
|
663
|
-
const response = await this.withInitialConfigOptions(created, initial);
|
|
664
|
-
this.afterSetupResponse(response.sessionId, params.mcpServers);
|
|
665
|
-
return response;
|
|
666
671
|
}
|
|
667
672
|
/**
|
|
668
673
|
* `session/options`: the modes and config options that `session/new` with
|
|
@@ -677,7 +682,8 @@ export class ClaudeAcpAgent {
|
|
|
677
682
|
* hooks in it, as in every query.
|
|
678
683
|
*
|
|
679
684
|
* It sends no update, and it creates, loads and changes no session. A
|
|
680
|
-
* `sessionId` that is neither held nor stored fails with `-32002`.
|
|
685
|
+
* `sessionId` that is neither held nor stored fails with `-32002`. It fails
|
|
686
|
+
* as the start would when Claude Code skipped an invalid settings file.
|
|
681
687
|
*/
|
|
682
688
|
async sessionOptions(params) {
|
|
683
689
|
while (this.providerUpdate)
|
|
@@ -718,17 +724,7 @@ export class ClaudeAcpAgent {
|
|
|
718
724
|
async createSessionWhileReplaying(params, timing) {
|
|
719
725
|
await this.validateCwd(params.cwd, params.additionalDirectories);
|
|
720
726
|
clientSystemPrompt(params.systemPrompt);
|
|
721
|
-
const pending =
|
|
722
|
-
state: {
|
|
723
|
-
cwd: params.cwd,
|
|
724
|
-
taskState: new Map(),
|
|
725
|
-
subagentChecklists: new Set(),
|
|
726
|
-
forwardSubagentText: this.forwardsSubagentText(params._meta),
|
|
727
|
-
messageIdToUuid: new Map(),
|
|
728
|
-
sessionFailureState: createSessionFailureState(),
|
|
729
|
-
},
|
|
730
|
-
stopped: false,
|
|
731
|
-
};
|
|
727
|
+
const pending = this.pendingReplay(params.cwd, params._meta);
|
|
732
728
|
const transcript = readResumedSession(params.sessionId, this.logger);
|
|
733
729
|
const replay = transcript
|
|
734
730
|
.then(({ messages }) => this.replaySessionHistory(params.sessionId, messages, pending))
|
|
@@ -789,16 +785,18 @@ export class ClaudeAcpAgent {
|
|
|
789
785
|
// The fork row can lack `forkedFrom`: the scan reads it from the first
|
|
790
786
|
// 64 KB of the transcript only. So the fork is held back by its id too.
|
|
791
787
|
this.sessionIndex.onForkCreated(params.sessionId, sessionId);
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
788
|
+
return this.sessionReads.transition(sessionId, "open", async () => {
|
|
789
|
+
const { modes, configOptions } = await this.withInitialConfigOptions(await this.getOrCreateSession({
|
|
790
|
+
sessionId,
|
|
791
|
+
cwd: params.cwd,
|
|
792
|
+
mcpServers: params.mcpServers,
|
|
793
|
+
additionalDirectories: params.additionalDirectories,
|
|
794
|
+
systemPrompt: params.systemPrompt,
|
|
795
|
+
_meta: params._meta,
|
|
796
|
+
}), initial);
|
|
797
|
+
this.afterSetupResponse(sessionId, params.mcpServers ?? []);
|
|
798
|
+
return { sessionId, modes, configOptions };
|
|
799
|
+
});
|
|
802
800
|
}
|
|
803
801
|
/** Runs `fork`, the handler of a `session/fork` request of `sourceId`,
|
|
804
802
|
* with its forks held back from the session list (see
|
|
@@ -884,14 +882,19 @@ export class ClaudeAcpAgent {
|
|
|
884
882
|
});
|
|
885
883
|
}
|
|
886
884
|
async resumeSession(params) {
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
885
|
+
return this.sessionReads.transition(params.sessionId, "open", async () => {
|
|
886
|
+
const initial = initialConfigOptions(params.configOptions);
|
|
887
|
+
while (this.providerUpdate)
|
|
888
|
+
await this.providerUpdate;
|
|
889
|
+
const result = await this.withInitialConfigOptions(await this.getOrCreateSession(params), initial);
|
|
890
|
+
this.afterSetupResponse(params.sessionId, params.mcpServers ?? []);
|
|
891
|
+
return result;
|
|
892
|
+
});
|
|
893
|
+
}
|
|
894
|
+
loadSession(params) {
|
|
895
|
+
return this.sessionReads.transition(params.sessionId, "open", () => this.loadAndReplay(params));
|
|
893
896
|
}
|
|
894
|
-
async
|
|
897
|
+
async loadAndReplay(params) {
|
|
895
898
|
const timing = new SessionTiming(this.logger, "load", params.sessionId);
|
|
896
899
|
const initial = initialConfigOptions(params.configOptions);
|
|
897
900
|
while (this.providerUpdate)
|
|
@@ -912,6 +915,17 @@ export class ClaudeAcpAgent {
|
|
|
912
915
|
this.afterSetupResponse(params.sessionId, params.mcpServers ?? []);
|
|
913
916
|
return result;
|
|
914
917
|
}
|
|
918
|
+
readSession(params, signal) {
|
|
919
|
+
return this.sessionReads.read(params, {
|
|
920
|
+
capabilities: this.clientCapabilities,
|
|
921
|
+
airClient: this.toolCallCapabilities.air.client,
|
|
922
|
+
signal,
|
|
923
|
+
isOpen: (sessionId) => Object.hasOwn(this.sessions, sessionId),
|
|
924
|
+
assertRoot: (sessionId) => this.assertNoChildSession(sessionId, "read"),
|
|
925
|
+
clientTitle: (title) => this.sessionIndex.clientTitle(title),
|
|
926
|
+
render: (sessionId, cwd, replay) => this.replaySessionHistory(sessionId, undefined, this.pendingReplay(cwd), replay),
|
|
927
|
+
});
|
|
928
|
+
}
|
|
915
929
|
/**
|
|
916
930
|
* One page of the sessions, newest first. The cursor is the offset of the
|
|
917
931
|
* page. The SDK then orders the transcripts by their modification time and
|
|
@@ -1136,16 +1150,17 @@ export class ClaudeAcpAgent {
|
|
|
1136
1150
|
reconnected = outcome.reconnected;
|
|
1137
1151
|
return outcome.markdown;
|
|
1138
1152
|
},
|
|
1139
|
-
// A reconnect starts OAuth for
|
|
1140
|
-
//
|
|
1153
|
+
// A reconnect starts OAuth for each server that it tried and that needs
|
|
1154
|
+
// it, also for one from Claude Code's settings or the project's
|
|
1155
|
+
// `.mcp.json`: the client has no terminal to sign in from. A plain
|
|
1156
|
+
// `/mcp` and a cancelled turn start none.
|
|
1141
1157
|
afterDelivery: () => {
|
|
1142
1158
|
const session = this.sessions[params.sessionId];
|
|
1143
1159
|
if (!session || session.cancelled)
|
|
1144
1160
|
return;
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
startMcpServerAuthentication(this, params.sessionId, servers);
|
|
1161
|
+
if (reconnected.length > 0) {
|
|
1162
|
+
startMcpServerAuthentication(this, params.sessionId, new Set(reconnected));
|
|
1163
|
+
}
|
|
1149
1164
|
},
|
|
1150
1165
|
};
|
|
1151
1166
|
}
|
|
@@ -1909,13 +1924,16 @@ export class ClaudeAcpAgent {
|
|
|
1909
1924
|
try {
|
|
1910
1925
|
if (asyncTasks.isAutonomousTurn(params.asyncTaskId)) {
|
|
1911
1926
|
// The task stands for a turn that Claude Code started on its own, so
|
|
1912
|
-
// stopping it interrupts that turn. A prompt that
|
|
1913
|
-
//
|
|
1914
|
-
|
|
1927
|
+
// stopping it interrupts that turn. A waiting prompt that is still in
|
|
1928
|
+
// Claude Code's queue survives the interrupt and runs next. One that
|
|
1929
|
+
// Claude Code already dispatched into a turn, or any prompt on a CLI
|
|
1930
|
+
// that sends no lifecycle frames, may be part of the interrupted turn.
|
|
1931
|
+
const waiting = waitingPrompts(session.turnQueue);
|
|
1932
|
+
if (!interruptKeepsWaitingPrompts(session, waiting)) {
|
|
1915
1933
|
asyncTasks.releaseStop(params.asyncTaskId);
|
|
1916
1934
|
return { stopped: false };
|
|
1917
1935
|
}
|
|
1918
|
-
await session.query.
|
|
1936
|
+
await interruptAutonomousTurn(session.query, asyncTasks, waiting, this.logger);
|
|
1919
1937
|
}
|
|
1920
1938
|
else {
|
|
1921
1939
|
await session.query.stopTask(params.asyncTaskId);
|
|
@@ -3390,6 +3408,10 @@ export class ClaudeAcpAgent {
|
|
|
3390
3408
|
case "system":
|
|
3391
3409
|
switch (message.subtype) {
|
|
3392
3410
|
case "init":
|
|
3411
|
+
// The mode at the start of the turn (see `modeReported`).
|
|
3412
|
+
if (message.permissionMode) {
|
|
3413
|
+
await this.sessionModes.modeReported(params.sessionId, session, message.permissionMode);
|
|
3414
|
+
}
|
|
3393
3415
|
// Latch the lifecycle capability so cancel() routes orphan
|
|
3394
3416
|
// accounting through `orphanCommands` (per-uuid, exact)
|
|
3395
3417
|
// instead of the coalescing-blind count. Never unlatch: init
|
|
@@ -3449,6 +3471,10 @@ export class ClaudeAcpAgent {
|
|
|
3449
3471
|
await this.reportMcpServerStartupFailures(session, message.mcp_servers, supportsNotices, sendUpdate, params.sessionId);
|
|
3450
3472
|
break;
|
|
3451
3473
|
case "status": {
|
|
3474
|
+
// The mode after a change (see `modeReported`).
|
|
3475
|
+
if (message.permissionMode) {
|
|
3476
|
+
await this.sessionModes.modeReported(params.sessionId, session, message.permissionMode);
|
|
3477
|
+
}
|
|
3452
3478
|
// A model request that serves none of the prompts a cancel
|
|
3453
3479
|
// stopped is new work, such as Claude Code's follow-up after a
|
|
3454
3480
|
// background command finished. It comes after the stopped
|
|
@@ -4191,8 +4217,11 @@ export class ClaudeAcpAgent {
|
|
|
4191
4217
|
// slash-command output forwarding), though their cost is real.
|
|
4192
4218
|
// The exception: the user's prompt was added to that turn while it
|
|
4193
4219
|
// ran, so its result answers the prompt (see answersPendingPrompt).
|
|
4194
|
-
|
|
4195
|
-
|
|
4220
|
+
// A stop that interrupted an autonomous turn owes that turn's
|
|
4221
|
+
// aborted result, which has no origin after a scheduler fire.
|
|
4222
|
+
const answersPrompt = answersPendingPrompt(message);
|
|
4223
|
+
const startedByClaudeCode = asyncTasks.startedByClaudeCode(message, answersPrompt);
|
|
4224
|
+
const isAutonomousResult = startedByClaudeCode && !answersPrompt;
|
|
4196
4225
|
// A result with no turn to claim it also ends the cycle that
|
|
4197
4226
|
// Claude Code started on its own, whatever its origin says. A
|
|
4198
4227
|
// scheduler fire (a ScheduleWakeup or cron prompt) is one: its
|
|
@@ -5290,8 +5319,9 @@ export class ClaudeAcpAgent {
|
|
|
5290
5319
|
else if (message.parent_tool_use_id !== null &&
|
|
5291
5320
|
Array.isArray(message.message.content)) {
|
|
5292
5321
|
// A foreground fork inherits a placeholder result for its own
|
|
5293
|
-
// launch
|
|
5294
|
-
//
|
|
5322
|
+
// launch, and Claude Code before 2.1.332 streams it ("Fork
|
|
5323
|
+
// started — that fork is you."). Only the launching side can
|
|
5324
|
+
// complete that Agent call with the fork's actual report.
|
|
5295
5325
|
const launchId = message.parent_tool_use_id;
|
|
5296
5326
|
content = message.message.content.filter((block) => block.type !== "tool_result" || block.tool_use_id !== launchId);
|
|
5297
5327
|
// The message-level sidecar cannot describe a remaining result
|
|
@@ -6127,6 +6157,7 @@ export class ClaudeAcpAgent {
|
|
|
6127
6157
|
}
|
|
6128
6158
|
/** Tear down all active sessions. Called when the ACP connection closes. */
|
|
6129
6159
|
async dispose() {
|
|
6160
|
+
this.sessionReads.dispose();
|
|
6130
6161
|
this.sessionIndex.dispose();
|
|
6131
6162
|
await Promise.all(Object.keys(this.sessions).map((id) => this.teardownSession(id)));
|
|
6132
6163
|
}
|
|
@@ -6145,8 +6176,10 @@ export class ClaudeAcpAgent {
|
|
|
6145
6176
|
}
|
|
6146
6177
|
/** Idempotent: a session that is not loaded here is already closed. */
|
|
6147
6178
|
async closeSession(params) {
|
|
6148
|
-
|
|
6149
|
-
|
|
6179
|
+
return this.sessionReads.transition(params.sessionId, "close", async () => {
|
|
6180
|
+
await this.endSession(params.sessionId);
|
|
6181
|
+
return {};
|
|
6182
|
+
});
|
|
6150
6183
|
}
|
|
6151
6184
|
/**
|
|
6152
6185
|
* `session/status`: `open` for a session that this connection holds. A held
|
|
@@ -6168,7 +6201,7 @@ export class ClaudeAcpAgent {
|
|
|
6168
6201
|
}
|
|
6169
6202
|
/** Per client: see {@link sessionIndex.SessionIndexConnection.deleteSession}. */
|
|
6170
6203
|
async deleteSession(params) {
|
|
6171
|
-
return this.sessionIndex.deleteSession(params);
|
|
6204
|
+
return this.sessionReads.transition(params.sessionId, "close", () => this.sessionIndex.deleteSession(params));
|
|
6172
6205
|
}
|
|
6173
6206
|
setSessionMode(params) {
|
|
6174
6207
|
return this.serializeConfigurationChange(params.sessionId, () => this.sessionModes.setSessionMode(params));
|
|
@@ -6225,15 +6258,34 @@ export class ClaudeAcpAgent {
|
|
|
6225
6258
|
await this.applyConfigOptionValue(params.sessionId, session, params.configId, effectiveValue, duringSetup);
|
|
6226
6259
|
return { configOptions: session.configOptions };
|
|
6227
6260
|
}
|
|
6228
|
-
|
|
6261
|
+
pendingReplay(cwd, meta) {
|
|
6262
|
+
return {
|
|
6263
|
+
state: {
|
|
6264
|
+
cwd,
|
|
6265
|
+
taskState: new Map(),
|
|
6266
|
+
subagentChecklists: new Set(),
|
|
6267
|
+
forwardSubagentText: this.forwardsSubagentText(meta),
|
|
6268
|
+
messageIdToUuid: new Map(),
|
|
6269
|
+
sessionFailureState: createSessionFailureState(),
|
|
6270
|
+
},
|
|
6271
|
+
stopped: false,
|
|
6272
|
+
};
|
|
6273
|
+
}
|
|
6274
|
+
async replaySessionHistory(sessionId, resumedMessages, pending, detached) {
|
|
6229
6275
|
const replayStartedAt = performance.now();
|
|
6230
6276
|
const toolUseCache = {};
|
|
6277
|
+
const publish = detached?.publish ??
|
|
6278
|
+
((notification) => this.client.sessionUpdate(notification));
|
|
6231
6279
|
// A replay rebuilds the client's entities, and its cursors anchor to those.
|
|
6232
|
-
|
|
6280
|
+
if (!detached)
|
|
6281
|
+
this.lastEntities.forget(sessionId);
|
|
6233
6282
|
// A load replays the messages before each compaction too, unless reading them fails.
|
|
6234
6283
|
// The rewind cut comes first: the dropped turns get no replay and no cursor.
|
|
6235
|
-
const current =
|
|
6236
|
-
|
|
6284
|
+
const current = detached?.messages ??
|
|
6285
|
+
(await cutAtRewindPoint(sessionId, resumedMessages ?? (await getSessionMessages(sessionId)), this.logger));
|
|
6286
|
+
const messages = detached
|
|
6287
|
+
? current
|
|
6288
|
+
: await readHistoryAcrossCompactions(sessionId, current, this.logger);
|
|
6237
6289
|
// A cursor whose resume point a compaction left out cannot be rewound to.
|
|
6238
6290
|
const currentUuids = new Set(current.map((message) => message.uuid));
|
|
6239
6291
|
const historyLoadedAt = performance.now();
|
|
@@ -6259,12 +6311,14 @@ export class ClaudeAcpAgent {
|
|
|
6259
6311
|
state: session.sessionFailureState,
|
|
6260
6312
|
capabilities: this.clientCapabilities,
|
|
6261
6313
|
isCurrent: () => {
|
|
6314
|
+
if (detached)
|
|
6315
|
+
return !detached.signal.aborted;
|
|
6262
6316
|
const live = this.sessions[sessionId];
|
|
6263
6317
|
if (!live)
|
|
6264
6318
|
return pending !== undefined && !pending.stopped;
|
|
6265
6319
|
return live.sessionFailureState === session.sessionFailureState;
|
|
6266
6320
|
},
|
|
6267
|
-
sendUpdate:
|
|
6321
|
+
sendUpdate: publish,
|
|
6268
6322
|
logger: this.logger,
|
|
6269
6323
|
})
|
|
6270
6324
|
: undefined;
|
|
@@ -6282,6 +6336,12 @@ export class ClaudeAcpAgent {
|
|
|
6282
6336
|
// no model to the list, and each child's model is its id until the load
|
|
6283
6337
|
// response refines it (see `publishCurrentSubagentStates`).
|
|
6284
6338
|
const replayModels = pending ? undefined : this.subagentModels(sessionId);
|
|
6339
|
+
const readSubagentHistory = () => detached
|
|
6340
|
+
? subagentHistory(sessionId, { strict: true, transcript: detached.transcript })
|
|
6341
|
+
: subagentHistory(sessionId);
|
|
6342
|
+
const readChildMessages = (agentId, history, launchId) => detached
|
|
6343
|
+
? readSubagentMessagesOrFail(sessionId, agentId, history, launchId)
|
|
6344
|
+
: readSubagentMessages(sessionId, agentId, history, this.logger);
|
|
6285
6345
|
// Registers the Agent and Task launches of `list`, and the terminal state
|
|
6286
6346
|
// of each launch from its tool_result.
|
|
6287
6347
|
const registerLaunches = (list) => {
|
|
@@ -6364,7 +6424,7 @@ export class ClaudeAcpAgent {
|
|
|
6364
6424
|
const parentSessionId = child.parentToolUseId
|
|
6365
6425
|
? (replayChildren.get(child.parentToolUseId)?.sessionId ?? sessionId)
|
|
6366
6426
|
: sessionId;
|
|
6367
|
-
await
|
|
6427
|
+
await publish(asSdkSessionNotification({
|
|
6368
6428
|
sessionId: parentSessionId,
|
|
6369
6429
|
update: {
|
|
6370
6430
|
sessionUpdate: "subagent_spawned",
|
|
@@ -6380,7 +6440,7 @@ export class ClaudeAcpAgent {
|
|
|
6380
6440
|
};
|
|
6381
6441
|
// Only a history with an Agent or Task launch has subagent transcripts to read.
|
|
6382
6442
|
const subagents = nativeReplayEnabled && replayChildren.size > 0
|
|
6383
|
-
? await
|
|
6443
|
+
? await readSubagentHistory()
|
|
6384
6444
|
: { agents: new Map() };
|
|
6385
6445
|
const airReplay = nativeReplayEnabled ? new ReplayTranscript(subagents) : undefined;
|
|
6386
6446
|
airReplay?.scan(messages, sessionId);
|
|
@@ -6388,10 +6448,10 @@ export class ClaudeAcpAgent {
|
|
|
6388
6448
|
const rfdHistory = form === "rfd" &&
|
|
6389
6449
|
messages.some((message) => subagentLaunchIds(message.message?.content)
|
|
6390
6450
|
.length > 0)
|
|
6391
|
-
? await
|
|
6451
|
+
? await readSubagentHistory()
|
|
6392
6452
|
: { agents: new Map() };
|
|
6393
6453
|
const rfdReplay = form === "rfd"
|
|
6394
|
-
? new RfdSubagentReplay(rfdHistory,
|
|
6454
|
+
? new RfdSubagentReplay(rfdHistory, publish, detached ? undefined : this.subagentModels(sessionId), session?.cwd)
|
|
6395
6455
|
: undefined;
|
|
6396
6456
|
rfdReplay?.scan(messages, sessionId);
|
|
6397
6457
|
// History persists no task_started frame, so a background task gets its
|
|
@@ -6401,7 +6461,7 @@ export class ClaudeAcpAgent {
|
|
|
6401
6461
|
// The tool cache forgets a tool use at its result, but a notification
|
|
6402
6462
|
// comes later and needs the tool use that started the task.
|
|
6403
6463
|
const replayToolUses = new Map();
|
|
6404
|
-
const replayAsyncTasks = new AsyncTaskRuntime(clientSupportsAsyncTasks(this.clientCapabilities), sessionId,
|
|
6464
|
+
const replayAsyncTasks = new AsyncTaskRuntime(clientSupportsAsyncTasks(this.clientCapabilities), sessionId, publish, {
|
|
6405
6465
|
routeOf: (toolCallId) => {
|
|
6406
6466
|
const target = replayToolUses.get(toolCallId)?.sessionId;
|
|
6407
6467
|
return target && target !== sessionId
|
|
@@ -6447,6 +6507,7 @@ export class ClaudeAcpAgent {
|
|
|
6447
6507
|
const pause = messageLoopYielder.maybeYield();
|
|
6448
6508
|
if (pause)
|
|
6449
6509
|
await pause;
|
|
6510
|
+
detached?.signal.throwIfAborted();
|
|
6450
6511
|
if (pending?.stopped || isReplayHiddenMetaMessage(message)) {
|
|
6451
6512
|
return;
|
|
6452
6513
|
}
|
|
@@ -6512,7 +6573,7 @@ export class ClaudeAcpAgent {
|
|
|
6512
6573
|
if (replayChild?.announced && entry && !sameModelEntry(replayChild.model, entry)) {
|
|
6513
6574
|
replayChild.responseModel = model;
|
|
6514
6575
|
replayChild.model = entry;
|
|
6515
|
-
await
|
|
6576
|
+
await publish({
|
|
6516
6577
|
sessionId: replayChild.sessionId,
|
|
6517
6578
|
update: {
|
|
6518
6579
|
sessionUpdate: "config_option_update",
|
|
@@ -6563,7 +6624,10 @@ export class ClaudeAcpAgent {
|
|
|
6563
6624
|
// A subagent's own compaction summary is not the root session's.
|
|
6564
6625
|
if (replayCompactionUpdates &&
|
|
6565
6626
|
parentToolUseId === null &&
|
|
6566
|
-
(await replayCompactSummary(message,
|
|
6627
|
+
(await replayCompactSummary(message, publish, {
|
|
6628
|
+
sessionId,
|
|
6629
|
+
airClient: this.toolCallCapabilities.air.client,
|
|
6630
|
+
}))) {
|
|
6567
6631
|
return;
|
|
6568
6632
|
}
|
|
6569
6633
|
for (const notification of toAcpNotifications(
|
|
@@ -6595,7 +6659,7 @@ export class ClaudeAcpAgent {
|
|
|
6595
6659
|
: undefined;
|
|
6596
6660
|
if (handback !== undefined) {
|
|
6597
6661
|
if (handback !== null) {
|
|
6598
|
-
await
|
|
6662
|
+
await publish({
|
|
6599
6663
|
sessionId: replayTargetSessionId,
|
|
6600
6664
|
update: {
|
|
6601
6665
|
sessionUpdate: "agent_message_chunk",
|
|
@@ -6607,7 +6671,7 @@ export class ClaudeAcpAgent {
|
|
|
6607
6671
|
continue;
|
|
6608
6672
|
}
|
|
6609
6673
|
const replayed = { ...notification, sessionId: replayTargetSessionId };
|
|
6610
|
-
await
|
|
6674
|
+
await publish(rfdReplay
|
|
6611
6675
|
? asSdkSessionNotification(rfdReplay.withTarget(replayed, replayTargetSessionId))
|
|
6612
6676
|
: replayed);
|
|
6613
6677
|
}
|
|
@@ -6621,7 +6685,7 @@ export class ClaudeAcpAgent {
|
|
|
6621
6685
|
if (!agentId || replayedSubagents.has(agentId))
|
|
6622
6686
|
continue;
|
|
6623
6687
|
replayedSubagents.add(agentId);
|
|
6624
|
-
const childMessages = await
|
|
6688
|
+
const childMessages = await readChildMessages(agentId, subagents, toolUseId);
|
|
6625
6689
|
registerLaunches(childMessages);
|
|
6626
6690
|
airReplay?.scan(childMessages, agentId);
|
|
6627
6691
|
for (const childMessage of childMessages)
|
|
@@ -6635,7 +6699,7 @@ export class ClaudeAcpAgent {
|
|
|
6635
6699
|
const launched = rfdReplay.childOfLaunch(toolUseId);
|
|
6636
6700
|
if (!launched || launched.announced)
|
|
6637
6701
|
continue;
|
|
6638
|
-
const childMessages = await
|
|
6702
|
+
const childMessages = await readChildMessages(launched.sessionId, rfdHistory, toolUseId);
|
|
6639
6703
|
await rfdReplay.announce(launched);
|
|
6640
6704
|
rfdReplay.scan(childMessages, launched.sessionId);
|
|
6641
6705
|
for (const childMessage of childMessages)
|
|
@@ -6646,20 +6710,30 @@ export class ClaudeAcpAgent {
|
|
|
6646
6710
|
};
|
|
6647
6711
|
for (const [index, message] of messages.entries()) {
|
|
6648
6712
|
// Before the message's own chunk: the cursor lies before the message.
|
|
6649
|
-
const before = this.lastEntities.last(sessionId);
|
|
6713
|
+
const before = detached ? undefined : this.lastEntities.last(sessionId);
|
|
6650
6714
|
await replayMessage(message);
|
|
6651
6715
|
// A task notification record is no user message to the client (see `replayMessage`).
|
|
6652
6716
|
if (!pending?.stopped &&
|
|
6653
6717
|
hasForkCursor(messages, index) &&
|
|
6654
6718
|
!isTaskNotificationRecord(message)) {
|
|
6655
|
-
|
|
6656
|
-
|
|
6657
|
-
|
|
6719
|
+
const update = forkCursorUpdate(message.uuid);
|
|
6720
|
+
if (detached) {
|
|
6721
|
+
if (this.clientCapabilities?.session?.cursors != null) {
|
|
6722
|
+
await publish({ sessionId, update });
|
|
6723
|
+
}
|
|
6724
|
+
}
|
|
6725
|
+
else {
|
|
6726
|
+
this.announceCursor(sessionId, update, before, {
|
|
6727
|
+
rewindable: currentUuids.has(messages[index - 1].uuid),
|
|
6728
|
+
});
|
|
6729
|
+
}
|
|
6658
6730
|
}
|
|
6659
6731
|
}
|
|
6732
|
+
detached?.endHistory();
|
|
6660
6733
|
if (rfdReplay && !pending?.stopped) {
|
|
6661
6734
|
await rfdReplay.finish(clientSupportsNotices(this.clientCapabilities), sessionId);
|
|
6662
|
-
|
|
6735
|
+
if (!detached)
|
|
6736
|
+
this.replayedSubagents.set(sessionId, rfdReplay);
|
|
6663
6737
|
}
|
|
6664
6738
|
if (nativeReplayEnabled && !pending?.stopped) {
|
|
6665
6739
|
const childModels = new Map();
|
|
@@ -6668,7 +6742,7 @@ export class ClaudeAcpAgent {
|
|
|
6668
6742
|
childModels.set(child.sessionId, { model: child.responseModel, sent: child.model });
|
|
6669
6743
|
}
|
|
6670
6744
|
}
|
|
6671
|
-
if (childModels.size > 0)
|
|
6745
|
+
if (!detached && childModels.size > 0)
|
|
6672
6746
|
this.replayedChildModels.set(sessionId, childModels);
|
|
6673
6747
|
// Claude history persists sidechain messages and Agent/Task tool uses,
|
|
6674
6748
|
// but not task_started/task_updated lifecycle frames. Recover terminal
|
|
@@ -6680,7 +6754,7 @@ export class ClaudeAcpAgent {
|
|
|
6680
6754
|
const parentSessionId = child.parentToolUseId
|
|
6681
6755
|
? (replayChildren.get(child.parentToolUseId)?.sessionId ?? sessionId)
|
|
6682
6756
|
: sessionId;
|
|
6683
|
-
await
|
|
6757
|
+
await publish(asSdkSessionNotification({
|
|
6684
6758
|
sessionId: parentSessionId,
|
|
6685
6759
|
update: {
|
|
6686
6760
|
sessionUpdate: "subagent_state_update",
|
|
@@ -6697,9 +6771,10 @@ export class ClaudeAcpAgent {
|
|
|
6697
6771
|
// A client with `loadReplayEnd` gets one more update after the whole
|
|
6698
6772
|
// replay, the subagent history included. A stopped replay (the CLI start
|
|
6699
6773
|
// failed) does not get it, and a failed replay throws before this line.
|
|
6700
|
-
if (!
|
|
6774
|
+
if (!detached &&
|
|
6775
|
+
!pending?.stopped &&
|
|
6701
6776
|
clientSupportsAirCapability(this.clientCapabilities, AIR_LOAD_REPLAY_END_CAPABILITY)) {
|
|
6702
|
-
await
|
|
6777
|
+
await publish({
|
|
6703
6778
|
sessionId,
|
|
6704
6779
|
// No `title` and no `updatedAt`: `null` would clear them.
|
|
6705
6780
|
update: {
|
|
@@ -8187,9 +8262,12 @@ export class ClaudeAcpAgent {
|
|
|
8187
8262
|
hooks: [
|
|
8188
8263
|
...(subagentConfigHook ? [subagentConfigHook] : []),
|
|
8189
8264
|
createPostToolUseHook({
|
|
8265
|
+
// Claude Code reports the mode in a `status` frame too: the
|
|
8266
|
+
// first of the two is recorded.
|
|
8190
8267
|
onEnterPlanMode: async () => {
|
|
8191
|
-
|
|
8192
|
-
|
|
8268
|
+
const entered = this.sessions[sessionId];
|
|
8269
|
+
if (entered)
|
|
8270
|
+
await this.sessionModes.modeReported(sessionId, entered, "plan");
|
|
8193
8271
|
},
|
|
8194
8272
|
}),
|
|
8195
8273
|
],
|
|
@@ -8451,7 +8529,7 @@ export class ClaudeAcpAgent {
|
|
|
8451
8529
|
// The CLI reports whether ultracode can run (workflows enabled and a
|
|
8452
8530
|
// supporting model) and whether the session already requests it (an
|
|
8453
8531
|
// `ultracode: true` setting). Without a report, fall back to settings.
|
|
8454
|
-
const ultracodeReport = await
|
|
8532
|
+
const { ultracode: ultracodeReport, settingsErrors } = await readSettingsReport(q);
|
|
8455
8533
|
timing.phase("ultracode");
|
|
8456
8534
|
const ultracodeEnabled = ultracodeReport?.requested ?? effortSettings.ultracode === true;
|
|
8457
8535
|
const workflowsEnabled = ultracodeWorkflowsEnabled(ultracodeReport, currentModelInfo);
|
|
@@ -8464,6 +8542,7 @@ export class ClaudeAcpAgent {
|
|
|
8464
8542
|
useRecommendedValue,
|
|
8465
8543
|
airClient: this.toolCallCapabilities.air.client,
|
|
8466
8544
|
}, ultracode);
|
|
8545
|
+
rejectSkippedSettings(settingsErrors);
|
|
8467
8546
|
if (creationOpts.optionsOnly) {
|
|
8468
8547
|
this.discardUnregisteredQuery(q, input, settingsManager);
|
|
8469
8548
|
return { sessionId, modes, configOptions };
|
|
@@ -9105,6 +9184,7 @@ export function v1AgentApp(logger, onAgent) {
|
|
|
9105
9184
|
.onRequest(methods.agent.initialize, (ctx) => agent.initialize(ctx.params))
|
|
9106
9185
|
.onRequest(methods.agent.session.new, (ctx) => agent.newSession(ctx.params))
|
|
9107
9186
|
.onRequest(methods.agent.session.load, ofRootSession("load", (ctx) => agent.loadSession(ctx.params)))
|
|
9187
|
+
.onRequest(SESSION_READ_METHOD, { parse: (params) => params }, (ctx) => agent.readSession(ctx.params, ctx.signal))
|
|
9108
9188
|
.onRequest(methods.agent.session.fork, ofRootSession("fork", (ctx) => agent.forking(ctx.params.sessionId, () => agent.unstable_forkSession(ctx.params))))
|
|
9109
9189
|
.onRequest(methods.agent.session.list, (ctx) => agent.listSessions(ctx.params))
|
|
9110
9190
|
.onRequest(methods.agent.session.delete, ofRootSession("delete", (ctx) => agent.deleteSession(ctx.params)))
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { AsyncTaskRuntime } from "../async-tasks.js";
|
|
1
2
|
/** Stops one Claude background task without cancelling the parent prompt turn. */
|
|
2
3
|
export declare const ASYNC_TASK_STOP_METHOD = "_session/async_task/stop";
|
|
3
4
|
export type AsyncTaskStopRequest = {
|
|
@@ -8,4 +9,34 @@ export type AsyncTaskStopResponse = {
|
|
|
8
9
|
stopped: boolean;
|
|
9
10
|
};
|
|
10
11
|
export declare function parseAsyncTaskStopRequest(value: unknown): AsyncTaskStopRequest;
|
|
12
|
+
/** The part of a queued prompt turn that the stop of an autonomous turn reads. */
|
|
13
|
+
export type WaitingPrompt = {
|
|
14
|
+
promptUuid: string;
|
|
15
|
+
settled?: boolean;
|
|
16
|
+
commandStarted?: boolean;
|
|
17
|
+
};
|
|
18
|
+
/** The prompts in `turnQueue` that still await their turn. */
|
|
19
|
+
export declare function waitingPrompts<T extends WaitingPrompt>(turnQueue: readonly T[] | undefined): T[];
|
|
20
|
+
/**
|
|
21
|
+
* Whether an interrupt of the running autonomous turn leaves `waiting` to run
|
|
22
|
+
* next. A prompt still in Claude Code's queue survives it and is listed in the
|
|
23
|
+
* receipt's `still_queued`. A prompt that a `started` lifecycle frame says the
|
|
24
|
+
* CLI already dispatched into a turn may be part of the interrupted turn, and
|
|
25
|
+
* without lifecycle frames the adapter cannot tell which case a prompt is in.
|
|
26
|
+
*/
|
|
27
|
+
export declare function interruptKeepsWaitingPrompts(session: {
|
|
28
|
+
msgLifecycleV1?: boolean;
|
|
29
|
+
}, waiting: readonly WaitingPrompt[]): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Interrupts the running autonomous turn for a stop. The turn's aborted result
|
|
32
|
+
* is owed to the stop from before the interrupt, so a failed interrupt rolls
|
|
33
|
+
* the debt back.
|
|
34
|
+
*/
|
|
35
|
+
export declare function interruptAutonomousTurn(query: {
|
|
36
|
+
interrupt(): Promise<{
|
|
37
|
+
still_queued?: readonly string[];
|
|
38
|
+
} | undefined>;
|
|
39
|
+
}, asyncTasks: Pick<AsyncTaskRuntime, "autonomousTurnInterrupting" | "autonomousTurnInterruptFailed">, waiting: readonly WaitingPrompt[], logger: {
|
|
40
|
+
log(message: string): void;
|
|
41
|
+
}): Promise<void>;
|
|
11
42
|
//# sourceMappingURL=async-task-stop.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"async-task-stop.d.ts","sourceRoot":"","sources":["../../src/v1/async-task-stop.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"async-task-stop.d.ts","sourceRoot":"","sources":["../../src/v1/async-task-stop.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,kFAAkF;AAClF,eAAO,MAAM,sBAAsB,6BAA6B,CAAC;AAEjE,MAAM,MAAM,oBAAoB,GAAG;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,OAAO,GAAG,oBAAoB,CAoB9E;AAED,kFAAkF;AAClF,MAAM,MAAM,aAAa,GAAG;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,cAAc,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAEhG,8DAA8D;AAC9D,wBAAgB,cAAc,CAAC,CAAC,SAAS,aAAa,EAAE,SAAS,EAAE,SAAS,CAAC,EAAE,GAAG,SAAS,GAAG,CAAC,EAAE,CAEhG;AAED;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE;IAAE,cAAc,CAAC,EAAE,OAAO,CAAA;CAAE,EACrC,OAAO,EAAE,SAAS,aAAa,EAAE,GAChC,OAAO,CAKT;AAED;;;;GAIG;AACH,wBAAsB,uBAAuB,CAC3C,KAAK,EAAE;IAAE,SAAS,IAAI,OAAO,CAAC;QAAE,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;KAAE,GAAG,SAAS,CAAC,CAAA;CAAE,EACjF,UAAU,EAAE,IAAI,CACd,gBAAgB,EAChB,4BAA4B,GAAG,+BAA+B,CAC/D,EACD,OAAO,EAAE,SAAS,aAAa,EAAE,EACjC,MAAM,EAAE;IAAE,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GACrC,OAAO,CAAC,IAAI,CAAC,CAoBf"}
|