@agentclientprotocol/claude-agent-acp 0.67.0 → 0.68.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/acp-agent.d.ts +9 -21
- package/dist/acp-agent.d.ts.map +1 -1
- package/dist/acp-agent.js +161 -277
- package/dist/session-failure-extension.d.ts +104 -0
- package/dist/session-failure-extension.d.ts.map +1 -0
- package/dist/session-failure-extension.js +351 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,6 +17,7 @@ This tool implements an ACP agent by using the official [Claude Agent SDK](https
|
|
|
17
17
|
- Custom [Slash commands](https://docs.anthropic.com/en/docs/claude-code/slash-commands)
|
|
18
18
|
- Client MCP servers
|
|
19
19
|
- Session-scoped long-running goals through the provider-neutral [goal extension](docs/goal-extension.md)
|
|
20
|
+
- Structured errors, recovery, and warnings through the opt-in [session failure extension](docs/session-failure-extension.md)
|
|
20
21
|
|
|
21
22
|
Learn more about the [Agent Client Protocol](https://agentclientprotocol.com/).
|
|
22
23
|
|
package/dist/acp-agent.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { GoalRequest, GoalControlResponse, GoalSnapshot } from "./goal-extension
|
|
|
4
4
|
import { ContentBlockParam } from "@anthropic-ai/sdk/resources";
|
|
5
5
|
import { BetaContentBlock, BetaRawContentBlockDelta } from "@anthropic-ai/sdk/resources/beta.mjs";
|
|
6
6
|
import { SettingsManager } from "./settings.js";
|
|
7
|
+
import { type SessionFailureState } from "./session-failure-extension.js";
|
|
7
8
|
import { TaskState } from "./tools.js";
|
|
8
9
|
import { Pushable } from "./utils.js";
|
|
9
10
|
export declare const CLAUDE_CONFIG_DIR: string;
|
|
@@ -474,6 +475,10 @@ type Session = {
|
|
|
474
475
|
* NOT READ YET — recorded now so the mapping exists if/when we wire up
|
|
475
476
|
* fork/rewind. */
|
|
476
477
|
messageIdToUuid: Map<string, string>;
|
|
478
|
+
/** Durable-for-this-consumer failure state shared with session/load replay.
|
|
479
|
+
* Keeping it on the Session lets replay seed a failure that the persistent
|
|
480
|
+
* consumer can later clear with the same id and a higher revision. */
|
|
481
|
+
sessionFailureState: SessionFailureState;
|
|
477
482
|
};
|
|
478
483
|
export type SDKMessageFilter = {
|
|
479
484
|
type: string;
|
|
@@ -657,9 +662,7 @@ export declare class ClaudeAcpAgent {
|
|
|
657
662
|
clientCapabilities?: ClientCapabilities;
|
|
658
663
|
logger: Logger;
|
|
659
664
|
gatewayAuthRequest?: GatewayAuthRequest;
|
|
660
|
-
/**
|
|
661
|
-
* never persisted to disk (see the Configurable LLM Providers RFD). When
|
|
662
|
-
* set, it takes precedence over {@link gatewayAuthRequest}. */
|
|
665
|
+
/** Set while ACP overrides the agent's native provider configuration. */
|
|
663
666
|
providerConfig?: ProviderConfig;
|
|
664
667
|
/** Grace period before a `session/cancel` forces a wedged prompt loop to
|
|
665
668
|
* return "cancelled". See {@link DEFAULT_FORCE_CANCEL_GRACE_MS}. Mutable so
|
|
@@ -679,14 +682,6 @@ export declare class ClaudeAcpAgent {
|
|
|
679
682
|
* the title is best-effort and another turn will retry. */
|
|
680
683
|
private maybeUpdateSessionTitle;
|
|
681
684
|
authenticate(_params: AuthenticateRequest): Promise<void>;
|
|
682
|
-
/**
|
|
683
|
-
* `providers/list` — returns the single client-configurable custom gateway
|
|
684
|
-
* provider (`main`). `current` carries only non-secret routing (never headers,
|
|
685
|
-
* which may hold secrets); only `apiType`/`baseUrl` are surfaced for UI
|
|
686
|
-
* display, and is `null` when the provider is not configured/disabled. The
|
|
687
|
-
* provider is optional (`required: false`): while disabled/unconfigured the
|
|
688
|
-
* agent falls back to its own default routing (normal Claude login).
|
|
689
|
-
*/
|
|
690
685
|
unstable_listProviders(_params: ListProvidersRequest): Promise<ListProvidersResponse>;
|
|
691
686
|
/**
|
|
692
687
|
* `providers/set` — replace the full configuration for the `main` provider.
|
|
@@ -696,19 +691,12 @@ export declare class ClaudeAcpAgent {
|
|
|
696
691
|
*/
|
|
697
692
|
unstable_setProvider(params: SetProviderRequest): Promise<SetProviderResponse>;
|
|
698
693
|
/**
|
|
699
|
-
* `providers/disable`
|
|
700
|
-
*
|
|
701
|
-
* so the agent reverts to its own default routing and `providers/list` reports
|
|
702
|
-
* `current: null`. Disabling any other (unknown) ID is treated as a successful
|
|
703
|
-
* no-op per the RFD's idempotency rule.
|
|
694
|
+
* `providers/disable` ends ACP ownership of the single mutually exclusive
|
|
695
|
+
* backend slot and restores the agent's native routing state.
|
|
704
696
|
*/
|
|
705
697
|
unstable_disableProvider(params: DisableProviderRequest): Promise<DisableProviderResponse>;
|
|
706
|
-
/**
|
|
707
|
-
* Resolve the effective client-managed routing config. `providers/set` takes
|
|
708
|
-
* precedence; otherwise fall back to the legacy gateway auth request. Returns
|
|
709
|
-
* `null` when neither is configured.
|
|
710
|
-
*/
|
|
711
698
|
resolveProviderConfig(): ProviderConfig | null;
|
|
699
|
+
private defaultProviderConfig;
|
|
712
700
|
logout(_params: LogoutRequest): Promise<void>;
|
|
713
701
|
prompt(params: PromptRequest): Promise<PromptResponse>;
|
|
714
702
|
goal(params: GoalRequest): Promise<GoalControlResponse>;
|
package/dist/acp-agent.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"acp-agent.d.ts","sourceRoot":"","sources":["../src/acp-agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,mBAAmB,EAGnB,kBAAkB,EAClB,kBAAkB,EAClB,+BAA+B,EAC/B,wBAAwB,EACxB,yBAAyB,EACzB,sBAAsB,EACtB,uBAAuB,EACvB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACrB,WAAW,EACX,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,EACnB,aAAa,EAGb,iBAAiB,EACjB,kBAAkB,EAElB,aAAa,EACb,cAAc,EAEd,mBAAmB,EACnB,oBAAoB,EAEp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WAAW,GAClB,OAAO,CAAC,cAAc,CAAC,CAczB;AAED,wBAAgB,MAAM;;;EAgDrB"}
|
package/dist/acp-agent.js
CHANGED
|
@@ -11,11 +11,13 @@ import { promisify } from "node:util";
|
|
|
11
11
|
import packageJson from "../package.json" with { type: "json" };
|
|
12
12
|
import { applyAskElicitationResponse, askUserQuestionsToCreateRequest, createElicitationResponseToElicitResult, extractAskUserQuestions, extractRefusalFallbackPrompt, mcpElicitationToCreateRequest, REFUSAL_FALLBACK_DIALOG_KIND, refusalFallbackResultFromResponse, refusalFallbackToCreateRequest, } from "./elicitation.js";
|
|
13
13
|
import { SettingsManager } from "./settings.js";
|
|
14
|
+
import { activeUsageLimitMessage, airSessionFailureCapabilityMeta, assistantMessageText, createSessionFailureState, isSyntheticUsageLimitMessage, providerFailureCategory, SessionFailureController, sessionFailureMeta, supportsAirSessionFailures, } from "./session-failure-extension.js";
|
|
14
15
|
import { applyTaskCreate, applyTaskList, applyTaskUpdate, createPostToolUseHook, createTaskHook, parseTaskCreateOutput, parseTaskListOutput, parseTaskUpdateOutput, planEntries, registerHookCallback, taskStateToPlanEntries, toolInfoFromToolUse, toolUpdateFromDiffToolResponse, toolUpdateFromToolResult, } from "./tools.js";
|
|
15
16
|
import { nodeToWebReadable, nodeToWebWritable, Pushable, unreachable } from "./utils.js";
|
|
16
17
|
export const CLAUDE_CONFIG_DIR = process.env.CLAUDE_CONFIG_DIR ?? path.join(os.homedir(), ".claude");
|
|
17
18
|
const execFileAsync = promisify(execFile);
|
|
18
19
|
const MAX_TITLE_LENGTH = 256;
|
|
20
|
+
const MAX_INLINE_FAILURE_TITLE_LENGTH = 256;
|
|
19
21
|
function sanitizeTitle(text) {
|
|
20
22
|
// Replace newlines and collapse whitespace
|
|
21
23
|
const sanitized = text
|
|
@@ -146,130 +148,13 @@ function computeSessionFingerprint(params) {
|
|
|
146
148
|
const servers = [...(params.mcpServers ?? [])].sort((a, b) => a.name.localeCompare(b.name));
|
|
147
149
|
return JSON.stringify({ cwd: params.cwd, mcpServers: servers });
|
|
148
150
|
}
|
|
149
|
-
/**
|
|
150
|
-
* The single provider ID this agent exposes via `providers/*`. Claude Code has
|
|
151
|
-
* one LLM backend selected by protocol (anthropic / bedrock / vertex), so there
|
|
152
|
-
* is exactly one configurable provider.
|
|
153
|
-
*/
|
|
154
|
-
const PROVIDER_ID = "main";
|
|
155
|
-
/**
|
|
156
|
-
* Protocols the `main` provider can be configured with. These mirror the
|
|
157
|
-
* env-var mappings understood by {@link createEnvForProvider}.
|
|
158
|
-
*/
|
|
159
151
|
const SUPPORTED_PROTOCOLS = ["anthropic", "bedrock", "vertex"];
|
|
152
|
+
const PROVIDER_ID = "main";
|
|
153
|
+
const DEFAULT_ANTHROPIC_BASE_URL = "https://api.anthropic.com";
|
|
160
154
|
const SUBAGENT_TRANSCRIPT_CAPABILITY = "subagent-transcript";
|
|
161
|
-
// This is a protocol namespace, not user-facing branding: `jetbrains` owns the
|
|
162
|
-
// non-standard contract and `air` identifies the client defining its rendering
|
|
163
|
-
// semantics, without affecting unrelated JetBrains ACP clients.
|
|
164
|
-
const JETBRAINS_META_KEY = "jetbrains";
|
|
165
|
-
const AIR_META_KEY = "air";
|
|
166
|
-
const AIR_EXTENSION_VERSION_KEY = "version";
|
|
167
|
-
const AIR_EXTENSION_CAPABILITIES_KEY = "capabilities";
|
|
168
|
-
const AIR_SESSION_FAILURE_KEY = "sessionFailure";
|
|
169
|
-
const AIR_EXTENSION_VERSION = 1;
|
|
170
155
|
function supportsSubagentTranscript(capabilities) {
|
|
171
156
|
return capabilities?._meta?.[SUBAGENT_TRANSCRIPT_CAPABILITY] === true;
|
|
172
157
|
}
|
|
173
|
-
const AIR_FAILURE_PRESENTATION = {
|
|
174
|
-
// A non-fatal notice whose wording comes from the adapter or the SDK, so this message is only the
|
|
175
|
-
// fallback for an advisory published without one.
|
|
176
|
-
advisory: {
|
|
177
|
-
message: "Claude reported a notice.",
|
|
178
|
-
retryable: false,
|
|
179
|
-
actions: [],
|
|
180
|
-
},
|
|
181
|
-
auth_required: {
|
|
182
|
-
message: "Sign in to continue using Claude.",
|
|
183
|
-
retryable: false,
|
|
184
|
-
actions: ["login"],
|
|
185
|
-
},
|
|
186
|
-
bad_request: {
|
|
187
|
-
message: "Claude could not process this request.",
|
|
188
|
-
retryable: false,
|
|
189
|
-
actions: ["new_turn"],
|
|
190
|
-
},
|
|
191
|
-
budget_exhausted: {
|
|
192
|
-
message: "This Claude session reached its configured budget.",
|
|
193
|
-
retryable: false,
|
|
194
|
-
actions: ["new_session"],
|
|
195
|
-
},
|
|
196
|
-
context_exhausted: {
|
|
197
|
-
message: "This Claude turn reached its configured limit.",
|
|
198
|
-
retryable: false,
|
|
199
|
-
actions: ["new_turn"],
|
|
200
|
-
},
|
|
201
|
-
internal_error: {
|
|
202
|
-
message: "Claude Agent encountered an internal error.",
|
|
203
|
-
retryable: true,
|
|
204
|
-
actions: ["retry"],
|
|
205
|
-
},
|
|
206
|
-
overloaded: {
|
|
207
|
-
message: "Claude is temporarily overloaded.",
|
|
208
|
-
retryable: true,
|
|
209
|
-
actions: ["retry"],
|
|
210
|
-
},
|
|
211
|
-
provider_error: {
|
|
212
|
-
message: "The model provider reported an error.",
|
|
213
|
-
retryable: true,
|
|
214
|
-
actions: ["retry"],
|
|
215
|
-
},
|
|
216
|
-
quota_exhausted: {
|
|
217
|
-
message: "The Claude account has no available quota.",
|
|
218
|
-
retryable: false,
|
|
219
|
-
actions: ["new_session"],
|
|
220
|
-
},
|
|
221
|
-
rate_limited: {
|
|
222
|
-
message: "Claude is temporarily rate limited.",
|
|
223
|
-
retryable: true,
|
|
224
|
-
actions: ["retry"],
|
|
225
|
-
},
|
|
226
|
-
transport_lost: {
|
|
227
|
-
message: "The connection to Claude was lost.",
|
|
228
|
-
retryable: false,
|
|
229
|
-
actions: ["new_session"],
|
|
230
|
-
},
|
|
231
|
-
worker_shutdown: {
|
|
232
|
-
message: "The Claude worker is shutting down.",
|
|
233
|
-
retryable: false,
|
|
234
|
-
actions: ["new_session"],
|
|
235
|
-
},
|
|
236
|
-
};
|
|
237
|
-
function supportsAirSessionFailures(capabilities) {
|
|
238
|
-
const jetbrains = capabilities?._meta?.[JETBRAINS_META_KEY];
|
|
239
|
-
const air = jetbrains?.[AIR_META_KEY];
|
|
240
|
-
const version = air?.[AIR_EXTENSION_VERSION_KEY];
|
|
241
|
-
const advertised = air?.[AIR_EXTENSION_CAPABILITIES_KEY];
|
|
242
|
-
return (typeof version === "number" &&
|
|
243
|
-
Number.isFinite(version) &&
|
|
244
|
-
Number.isInteger(version) &&
|
|
245
|
-
version >= AIR_EXTENSION_VERSION &&
|
|
246
|
-
Array.isArray(advertised) &&
|
|
247
|
-
advertised.some((capability) => capability === AIR_SESSION_FAILURE_KEY));
|
|
248
|
-
}
|
|
249
|
-
function providerFailureCategory(errorKind) {
|
|
250
|
-
switch (errorKind) {
|
|
251
|
-
case "authentication_failed":
|
|
252
|
-
case "oauth_org_not_allowed":
|
|
253
|
-
return "auth_required";
|
|
254
|
-
case "billing_error":
|
|
255
|
-
return "quota_exhausted";
|
|
256
|
-
case "rate_limit":
|
|
257
|
-
return "rate_limited";
|
|
258
|
-
case "overloaded":
|
|
259
|
-
return "overloaded";
|
|
260
|
-
case "invalid_request":
|
|
261
|
-
case "model_not_found":
|
|
262
|
-
return "bad_request";
|
|
263
|
-
case "max_output_tokens":
|
|
264
|
-
return "context_exhausted";
|
|
265
|
-
case "server_error":
|
|
266
|
-
case "unknown":
|
|
267
|
-
case undefined:
|
|
268
|
-
return "provider_error";
|
|
269
|
-
default:
|
|
270
|
-
return "provider_error";
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
158
|
function parentToolUseIdOf(message) {
|
|
274
159
|
if (!("parent_tool_use_id" in message))
|
|
275
160
|
return null;
|
|
@@ -690,9 +575,7 @@ export class ClaudeAcpAgent {
|
|
|
690
575
|
clientCapabilities;
|
|
691
576
|
logger;
|
|
692
577
|
gatewayAuthRequest;
|
|
693
|
-
/**
|
|
694
|
-
* never persisted to disk (see the Configurable LLM Providers RFD). When
|
|
695
|
-
* set, it takes precedence over {@link gatewayAuthRequest}. */
|
|
578
|
+
/** Set while ACP overrides the agent's native provider configuration. */
|
|
696
579
|
providerConfig;
|
|
697
580
|
/** Grace period before a `session/cancel` forces a wedged prompt loop to
|
|
698
581
|
* return "cancelled". See {@link DEFAULT_FORCE_CANCEL_GRACE_MS}. Mutable so
|
|
@@ -846,12 +729,7 @@ export class ClaudeAcpAgent {
|
|
|
846
729
|
// steering extension contract: advertises the `_session/steering` request
|
|
847
730
|
// so clients know they may inject a follow-up into a running turn.
|
|
848
731
|
_meta: {
|
|
849
|
-
|
|
850
|
-
[AIR_META_KEY]: {
|
|
851
|
-
[AIR_EXTENSION_VERSION_KEY]: AIR_EXTENSION_VERSION,
|
|
852
|
-
[AIR_EXTENSION_CAPABILITIES_KEY]: [AIR_SESSION_FAILURE_KEY],
|
|
853
|
-
},
|
|
854
|
-
},
|
|
732
|
+
...airSessionFailureCapabilityMeta(),
|
|
855
733
|
steering: {
|
|
856
734
|
supported: true,
|
|
857
735
|
},
|
|
@@ -965,21 +843,13 @@ export class ClaudeAcpAgent {
|
|
|
965
843
|
}
|
|
966
844
|
throw new Error("Method not implemented.");
|
|
967
845
|
}
|
|
968
|
-
/**
|
|
969
|
-
* `providers/list` — returns the single client-configurable custom gateway
|
|
970
|
-
* provider (`main`). `current` carries only non-secret routing (never headers,
|
|
971
|
-
* which may hold secrets); only `apiType`/`baseUrl` are surfaced for UI
|
|
972
|
-
* display, and is `null` when the provider is not configured/disabled. The
|
|
973
|
-
* provider is optional (`required: false`): while disabled/unconfigured the
|
|
974
|
-
* agent falls back to its own default routing (normal Claude login).
|
|
975
|
-
*/
|
|
976
846
|
async unstable_listProviders(_params) {
|
|
977
|
-
const config = this.
|
|
847
|
+
const config = this.providerConfig ?? this.defaultProviderConfig();
|
|
978
848
|
const provider = {
|
|
979
849
|
providerId: PROVIDER_ID,
|
|
980
850
|
supported: SUPPORTED_PROTOCOLS,
|
|
981
851
|
required: false,
|
|
982
|
-
current:
|
|
852
|
+
current: { apiType: config.apiType, baseUrl: config.baseUrl },
|
|
983
853
|
};
|
|
984
854
|
return { providers: [provider] };
|
|
985
855
|
}
|
|
@@ -1021,30 +891,43 @@ export class ClaudeAcpAgent {
|
|
|
1021
891
|
return {};
|
|
1022
892
|
}
|
|
1023
893
|
/**
|
|
1024
|
-
* `providers/disable`
|
|
1025
|
-
*
|
|
1026
|
-
* so the agent reverts to its own default routing and `providers/list` reports
|
|
1027
|
-
* `current: null`. Disabling any other (unknown) ID is treated as a successful
|
|
1028
|
-
* no-op per the RFD's idempotency rule.
|
|
894
|
+
* `providers/disable` ends ACP ownership of the single mutually exclusive
|
|
895
|
+
* backend slot and restores the agent's native routing state.
|
|
1029
896
|
*/
|
|
1030
897
|
async unstable_disableProvider(params) {
|
|
1031
898
|
if (params.providerId === PROVIDER_ID) {
|
|
1032
899
|
this.providerConfig = undefined;
|
|
1033
|
-
this.gatewayAuthRequest = undefined;
|
|
1034
900
|
}
|
|
1035
901
|
// Unknown provider: idempotent success.
|
|
1036
902
|
return {};
|
|
1037
903
|
}
|
|
1038
|
-
/**
|
|
1039
|
-
* Resolve the effective client-managed routing config. `providers/set` takes
|
|
1040
|
-
* precedence; otherwise fall back to the legacy gateway auth request. Returns
|
|
1041
|
-
* `null` when neither is configured.
|
|
1042
|
-
*/
|
|
1043
904
|
resolveProviderConfig() {
|
|
1044
|
-
|
|
1045
|
-
|
|
905
|
+
return this.providerConfig ?? gatewayRequestToProviderConfig(this.gatewayAuthRequest);
|
|
906
|
+
}
|
|
907
|
+
defaultProviderConfig() {
|
|
908
|
+
const gatewayConfig = gatewayRequestToProviderConfig(this.gatewayAuthRequest);
|
|
909
|
+
if (gatewayConfig) {
|
|
910
|
+
return gatewayConfig;
|
|
911
|
+
}
|
|
912
|
+
if (process.env.CLAUDE_CODE_USE_BEDROCK) {
|
|
913
|
+
return {
|
|
914
|
+
apiType: "bedrock",
|
|
915
|
+
baseUrl: process.env.ANTHROPIC_BEDROCK_BASE_URL ?? "https://bedrock-runtime.amazonaws.com",
|
|
916
|
+
headers: {},
|
|
917
|
+
};
|
|
1046
918
|
}
|
|
1047
|
-
|
|
919
|
+
if (process.env.CLAUDE_CODE_USE_VERTEX) {
|
|
920
|
+
return {
|
|
921
|
+
apiType: "vertex",
|
|
922
|
+
baseUrl: process.env.ANTHROPIC_VERTEX_BASE_URL ?? "https://aiplatform.googleapis.com",
|
|
923
|
+
headers: {},
|
|
924
|
+
};
|
|
925
|
+
}
|
|
926
|
+
return {
|
|
927
|
+
apiType: "anthropic",
|
|
928
|
+
baseUrl: process.env.ANTHROPIC_BASE_URL ?? DEFAULT_ANTHROPIC_BASE_URL,
|
|
929
|
+
headers: {},
|
|
930
|
+
};
|
|
1048
931
|
}
|
|
1049
932
|
async logout(_params) {
|
|
1050
933
|
// Clear in-memory gateway credentials supplied via `authenticate` and any
|
|
@@ -1298,6 +1181,8 @@ export class ClaudeAcpAgent {
|
|
|
1298
1181
|
// it here so the subsequent `RequestError.internalError` can forward it to
|
|
1299
1182
|
// clients as structured `data`, sparing them from pattern-matching on text.
|
|
1300
1183
|
let lastAssistantError;
|
|
1184
|
+
let lastAssistantWasUsageLimit = false;
|
|
1185
|
+
let lastAssistantFailureTitle;
|
|
1301
1186
|
// When a streaming classifier refuses a turn, the assistant message carries
|
|
1302
1187
|
// stop_reason "refusal" and structured stop_details. We capture the
|
|
1303
1188
|
// human-readable explanation so the terminal `result` can surface it.
|
|
@@ -1351,113 +1236,41 @@ export class ClaudeAcpAgent {
|
|
|
1351
1236
|
}
|
|
1352
1237
|
await this.client.sessionUpdate(notification);
|
|
1353
1238
|
};
|
|
1354
|
-
const isAdvisory = (failure) => failure.severity === "warning";
|
|
1355
|
-
const failureRevisions = new Map();
|
|
1356
|
-
const sessionFailureEpoch = randomUUID();
|
|
1357
|
-
const activeSessionFailures = new Map();
|
|
1358
1239
|
let pendingWorkerShutdown = false;
|
|
1359
1240
|
const isCurrentConsumer = () => this.sessions[params.sessionId] === session;
|
|
1360
|
-
const
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
phase,
|
|
1370
|
-
category: failure.category,
|
|
1371
|
-
source: "claude",
|
|
1372
|
-
safeMessage: failure.safeMessage ?? presentation.message,
|
|
1373
|
-
retryable: presentation.retryable,
|
|
1374
|
-
actions: presentation.actions,
|
|
1375
|
-
...(failure.turnId ? { turnId: failure.turnId } : {}),
|
|
1376
|
-
...(failure.severity ? { severity: failure.severity } : {}),
|
|
1377
|
-
},
|
|
1378
|
-
},
|
|
1379
|
-
},
|
|
1380
|
-
};
|
|
1381
|
-
};
|
|
1382
|
-
const emitSessionFailure = async (failure, phase) => {
|
|
1383
|
-
if (!isCurrentConsumer()) {
|
|
1384
|
-
this.logger.error(`Session ${params.sessionId}: ignored AIR session failure from a stale query consumer`);
|
|
1385
|
-
return false;
|
|
1386
|
-
}
|
|
1387
|
-
try {
|
|
1388
|
-
await sendUpdate({
|
|
1389
|
-
sessionId: params.sessionId,
|
|
1390
|
-
update: {
|
|
1391
|
-
sessionUpdate: "session_info_update",
|
|
1392
|
-
_meta: sessionFailureMeta(failure, phase),
|
|
1393
|
-
},
|
|
1394
|
-
});
|
|
1395
|
-
return true;
|
|
1396
|
-
}
|
|
1397
|
-
catch (error) {
|
|
1398
|
-
this.logger.error(`Session ${params.sessionId}: failed to publish AIR session failure: ${error}`);
|
|
1399
|
-
return false;
|
|
1400
|
-
}
|
|
1401
|
-
};
|
|
1402
|
-
const clearSessionFailure = async (shouldClear = () => true) => {
|
|
1403
|
-
if (!supportsAirSessionFailures(this.clientCapabilities))
|
|
1404
|
-
return;
|
|
1405
|
-
for (const failure of [...activeSessionFailures.values()]) {
|
|
1406
|
-
if (!shouldClear(failure))
|
|
1407
|
-
continue;
|
|
1408
|
-
const cleared = {
|
|
1409
|
-
...failure,
|
|
1410
|
-
revision: failure.revision + 1,
|
|
1411
|
-
};
|
|
1412
|
-
if (await emitSessionFailure(cleared, "cleared")) {
|
|
1413
|
-
failureRevisions.set(cleared.id, cleared.revision);
|
|
1414
|
-
activeSessionFailures.delete(cleared.id);
|
|
1415
|
-
}
|
|
1416
|
-
}
|
|
1417
|
-
};
|
|
1418
|
-
const createSessionFailure = async (category, options = {}) => {
|
|
1419
|
-
if (!supportsAirSessionFailures(this.clientCapabilities) || !isCurrentConsumer()) {
|
|
1420
|
-
return undefined;
|
|
1421
|
-
}
|
|
1422
|
-
// An advisory is not a failure of the turn: it keeps its own id namespace and its own slot, so
|
|
1423
|
-
// it neither clears an actionable error nor is cleared by one. Only the newest advisory
|
|
1424
|
-
// matters, so they all share one id and bump its revision.
|
|
1425
|
-
if (category === "advisory") {
|
|
1426
|
-
const id = `${params.sessionId}:notice:${sessionFailureEpoch}`;
|
|
1427
|
-
return {
|
|
1428
|
-
id,
|
|
1429
|
-
revision: (failureRevisions.get(id) ?? 0) + 1,
|
|
1430
|
-
category,
|
|
1431
|
-
severity: "warning",
|
|
1432
|
-
...(options.safeMessage ? { safeMessage: options.safeMessage } : {}),
|
|
1433
|
-
};
|
|
1434
|
-
}
|
|
1241
|
+
const sessionFailures = new SessionFailureController({
|
|
1242
|
+
sessionId: params.sessionId,
|
|
1243
|
+
state: session.sessionFailureState,
|
|
1244
|
+
capabilities: this.clientCapabilities,
|
|
1245
|
+
isCurrent: isCurrentConsumer,
|
|
1246
|
+
sendUpdate,
|
|
1247
|
+
logger: this.logger,
|
|
1248
|
+
});
|
|
1249
|
+
const createSessionFailure = async (kind, options = {}) => {
|
|
1435
1250
|
const turnId = options.turnScoped === false ? undefined : session.activeTurn?.promptUuid;
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
:
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
category,
|
|
1444
|
-
...(turnId ? { turnId } : {}),
|
|
1445
|
-
};
|
|
1251
|
+
return sessionFailures.prepare(kind, {
|
|
1252
|
+
turnId,
|
|
1253
|
+
sessionScoped: options.turnScoped === false,
|
|
1254
|
+
title: options.title,
|
|
1255
|
+
details: options.details,
|
|
1256
|
+
severity: options.severity,
|
|
1257
|
+
});
|
|
1446
1258
|
};
|
|
1447
|
-
const publishSessionFailure = async (
|
|
1448
|
-
const
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1259
|
+
const publishSessionFailure = async (kind, options = {}) => {
|
|
1260
|
+
const turnId = options.turnScoped === false ? undefined : session.activeTurn?.promptUuid;
|
|
1261
|
+
await sessionFailures.publish(kind, {
|
|
1262
|
+
turnId,
|
|
1263
|
+
sessionScoped: options.turnScoped === false,
|
|
1264
|
+
title: options.title,
|
|
1265
|
+
details: options.details,
|
|
1266
|
+
severity: options.severity,
|
|
1267
|
+
});
|
|
1455
1268
|
};
|
|
1456
1269
|
const clearFailuresFromEarlierTurns = async () => {
|
|
1457
1270
|
const activeTurnId = session.activeTurn?.promptUuid;
|
|
1458
1271
|
// Advisories carry no turnId, so without the guard every turn boundary would sweep them away.
|
|
1459
1272
|
// They are session-scoped and stay until superseded or dismissed by the user.
|
|
1460
|
-
await
|
|
1273
|
+
await sessionFailures.clear((failure) => failure.recoveryPolicy === "next_attempt" && failure.turnId !== activeTurnId);
|
|
1461
1274
|
};
|
|
1462
1275
|
const internalErrorForClient = (data, rawDetail) => RequestError.internalError(data, supportsAirSessionFailures(this.clientCapabilities) ? undefined : rawDetail);
|
|
1463
1276
|
const resetTurnScratch = () => {
|
|
@@ -1465,6 +1278,8 @@ export class ClaudeAcpAgent {
|
|
|
1465
1278
|
lastAssistantUsage = null;
|
|
1466
1279
|
lastAssistantModel = null;
|
|
1467
1280
|
lastAssistantError = undefined;
|
|
1281
|
+
lastAssistantWasUsageLimit = false;
|
|
1282
|
+
lastAssistantFailureTitle = undefined;
|
|
1468
1283
|
lastRefusalExplanation = null;
|
|
1469
1284
|
compactionInProgress = false;
|
|
1470
1285
|
// Do NOT reset currentStreamMessageId or streamedBlocks here. Turn
|
|
@@ -1760,27 +1575,26 @@ export class ClaudeAcpAgent {
|
|
|
1760
1575
|
/** Complete a negotiated terminal failure on the prompt response itself,
|
|
1761
1576
|
* which is the canonical AIR carrier. Legacy clients keep the historical
|
|
1762
1577
|
* JSON-RPC rejection path. */
|
|
1763
|
-
const failActiveWithSessionFailure = async (
|
|
1578
|
+
const failActiveWithSessionFailure = async (kind, error, title) => {
|
|
1764
1579
|
if (!supportsAirSessionFailures(this.clientCapabilities)) {
|
|
1765
1580
|
failActive(error);
|
|
1766
1581
|
return;
|
|
1767
1582
|
}
|
|
1768
1583
|
if (!session.activeTurn || session.activeTurn.settled) {
|
|
1769
|
-
this.logger.error(`Session ${params.sessionId}: cannot attach ${
|
|
1770
|
-
await publishSessionFailure(
|
|
1584
|
+
this.logger.error(`Session ${params.sessionId}: cannot attach ${kind} to a prompt response because no active turn exists; publishing a session-scoped failure`);
|
|
1585
|
+
await publishSessionFailure(kind, { turnScoped: false, title });
|
|
1771
1586
|
return;
|
|
1772
1587
|
}
|
|
1773
|
-
const failure = await createSessionFailure(
|
|
1588
|
+
const failure = await createSessionFailure(kind, { title });
|
|
1774
1589
|
if (!failure) {
|
|
1775
1590
|
failActive(error);
|
|
1776
1591
|
return;
|
|
1777
1592
|
}
|
|
1778
|
-
|
|
1779
|
-
activeSessionFailures.set(failure.id, failure);
|
|
1593
|
+
sessionFailures.recordActive(failure);
|
|
1780
1594
|
settleActive({
|
|
1781
1595
|
stopReason: "end_turn",
|
|
1782
1596
|
usage: sessionUsage(session),
|
|
1783
|
-
_meta: sessionFailureMeta(failure
|
|
1597
|
+
_meta: sessionFailureMeta(failure),
|
|
1784
1598
|
});
|
|
1785
1599
|
};
|
|
1786
1600
|
/** Reject every in-flight turn — used when the stream dies. */
|
|
@@ -2278,7 +2092,7 @@ export class ClaudeAcpAgent {
|
|
|
2278
2092
|
// the next prompt; only a timer could tell those apart.
|
|
2279
2093
|
this.logger.error(`Session ${params.sessionId}: SDK went idle without emitting a result ` +
|
|
2280
2094
|
`for the active turn; failing the in-flight prompt (issue #825)`);
|
|
2281
|
-
await failActiveWithSessionFailure("internal_error", RequestError.internalError(errorKindData("no_result"), TURN_NO_RESULT_MESSAGE));
|
|
2095
|
+
await failActiveWithSessionFailure("internal_error", RequestError.internalError(errorKindData("no_result"), TURN_NO_RESULT_MESSAGE), TURN_NO_RESULT_MESSAGE);
|
|
2282
2096
|
}
|
|
2283
2097
|
// The SDK generates the session title in a background task and
|
|
2284
2098
|
// persists it to the session file; `idle` is the turn-over
|
|
@@ -2505,10 +2319,21 @@ export class ClaudeAcpAgent {
|
|
|
2505
2319
|
}
|
|
2506
2320
|
case "plugin_install":
|
|
2507
2321
|
case "notification":
|
|
2508
|
-
case "api_retry":
|
|
2509
2322
|
case "thinking_tokens":
|
|
2510
2323
|
// Todo: process via status api: https://docs.claude.com/en/docs/claude-code/hooks#hook-output
|
|
2511
2324
|
break;
|
|
2325
|
+
case "api_retry": {
|
|
2326
|
+
const title = message.error_status === null
|
|
2327
|
+
? `Reconnecting to Claude, attempt ${message.attempt} of ${message.max_retries}.`
|
|
2328
|
+
: `Retrying Claude, attempt ${message.attempt} of ${message.max_retries}.`;
|
|
2329
|
+
await publishSessionFailure(message.error_status === null
|
|
2330
|
+
? "transport_lost"
|
|
2331
|
+
: providerFailureCategory(message.error), {
|
|
2332
|
+
title,
|
|
2333
|
+
severity: "warning",
|
|
2334
|
+
});
|
|
2335
|
+
break;
|
|
2336
|
+
}
|
|
2512
2337
|
case "model_refusal_fallback": {
|
|
2513
2338
|
// The SDK retried a refused turn on the fallback model and made
|
|
2514
2339
|
// the swap persistent for the session. Without a notice the
|
|
@@ -2534,21 +2359,28 @@ export class ClaudeAcpAgent {
|
|
|
2534
2359
|
const category = message.api_refusal_category
|
|
2535
2360
|
? ` (${message.api_refusal_category})`
|
|
2536
2361
|
: "";
|
|
2537
|
-
const explanation = message.api_refusal_explanation
|
|
2538
|
-
? `\n\n${message.api_refusal_explanation}`
|
|
2539
|
-
: "";
|
|
2540
2362
|
const outcome = persistent
|
|
2541
2363
|
? `The session will continue on ${message.fallback_model}.`
|
|
2542
2364
|
: local
|
|
2543
2365
|
? `Only that response came from ${message.fallback_model}; the session stays on ${message.original_model}.`
|
|
2544
2366
|
: `The session stays on ${message.original_model}.`;
|
|
2545
|
-
const
|
|
2546
|
-
`retried with ${message.fallback_model}. ${outcome}
|
|
2367
|
+
const fallbackSummary = `${message.original_model} declined this request${category}; ` +
|
|
2368
|
+
`retried with ${message.fallback_model}. ${outcome}`;
|
|
2369
|
+
const explanation = message.api_refusal_explanation || undefined;
|
|
2370
|
+
const fallbackNotice = explanation
|
|
2371
|
+
? `${fallbackSummary}\n\n${explanation}`
|
|
2372
|
+
: fallbackSummary;
|
|
2547
2373
|
// A silent model swap is a session-level advisory, not something the model said.
|
|
2548
2374
|
// Clients that negotiated typed records get it as one; the rest keep the bold-label
|
|
2549
2375
|
// transcript line, which was the only way to flag it before.
|
|
2550
2376
|
if (supportsAirSessionFailures(this.clientCapabilities)) {
|
|
2551
|
-
|
|
2377
|
+
const useDetails = explanation !== undefined &&
|
|
2378
|
+
fallbackSummary.length + 2 + explanation.length >
|
|
2379
|
+
MAX_INLINE_FAILURE_TITLE_LENGTH;
|
|
2380
|
+
await publishSessionFailure("advisory", {
|
|
2381
|
+
title: useDetails ? fallbackSummary : fallbackNotice,
|
|
2382
|
+
...(useDetails ? { details: explanation } : {}),
|
|
2383
|
+
});
|
|
2552
2384
|
}
|
|
2553
2385
|
else {
|
|
2554
2386
|
await sendUpdate({
|
|
@@ -2872,13 +2704,15 @@ export class ClaudeAcpAgent {
|
|
|
2872
2704
|
settleOrDefer({ stopReason: "end_turn", usage: sessionUsage(session) });
|
|
2873
2705
|
break;
|
|
2874
2706
|
}
|
|
2875
|
-
if (!message.is_error) {
|
|
2876
|
-
|
|
2707
|
+
if (!message.is_error && lastAssistantModel !== null) {
|
|
2708
|
+
const activeTurnId = session.activeTurn?.promptUuid;
|
|
2709
|
+
await sessionFailures.clear((failure) => failure.recoveryPolicy === "real_model_success" ||
|
|
2710
|
+
(failure.severity === "warning" && failure.turnId === activeTurnId));
|
|
2877
2711
|
}
|
|
2878
2712
|
switch (message.subtype) {
|
|
2879
2713
|
case "success": {
|
|
2880
2714
|
if (message.result.includes("Please run /login")) {
|
|
2881
|
-
await failActiveWithSessionFailure("auth_required", RequestError.authRequired());
|
|
2715
|
+
await failActiveWithSessionFailure("auth_required", RequestError.authRequired(), message.result);
|
|
2882
2716
|
break;
|
|
2883
2717
|
}
|
|
2884
2718
|
if (message.stop_reason === "max_tokens") {
|
|
@@ -2886,7 +2720,7 @@ export class ClaudeAcpAgent {
|
|
|
2886
2720
|
break;
|
|
2887
2721
|
}
|
|
2888
2722
|
if (message.is_error) {
|
|
2889
|
-
await failActiveWithSessionFailure(providerFailureCategory(lastAssistantError), internalErrorForClient(errorKindData(lastAssistantError), message.result));
|
|
2723
|
+
await failActiveWithSessionFailure(providerFailureCategory(lastAssistantError, lastAssistantWasUsageLimit), internalErrorForClient(errorKindData(lastAssistantError), message.result), lastAssistantFailureTitle ?? message.result);
|
|
2890
2724
|
break;
|
|
2891
2725
|
}
|
|
2892
2726
|
// The result text is forwarded in two cases. Local-only
|
|
@@ -2922,7 +2756,7 @@ export class ClaudeAcpAgent {
|
|
|
2922
2756
|
break;
|
|
2923
2757
|
}
|
|
2924
2758
|
if (message.is_error) {
|
|
2925
|
-
await failActiveWithSessionFailure(providerFailureCategory(lastAssistantError), internalErrorForClient(errorKindData(lastAssistantError), message.errors.join(", ") || message.subtype));
|
|
2759
|
+
await failActiveWithSessionFailure(providerFailureCategory(lastAssistantError, lastAssistantWasUsageLimit), internalErrorForClient(errorKindData(lastAssistantError), message.errors.join(", ") || message.subtype), lastAssistantFailureTitle ?? (message.errors.join(", ") || message.subtype));
|
|
2926
2760
|
break;
|
|
2927
2761
|
}
|
|
2928
2762
|
stopReason = "end_turn";
|
|
@@ -2930,21 +2764,21 @@ export class ClaudeAcpAgent {
|
|
|
2930
2764
|
}
|
|
2931
2765
|
case "error_max_budget_usd":
|
|
2932
2766
|
if (message.is_error) {
|
|
2933
|
-
await failActiveWithSessionFailure("budget_exhausted", internalErrorForClient(errorKindData(lastAssistantError), message.errors.join(", ") || message.subtype));
|
|
2767
|
+
await failActiveWithSessionFailure("budget_exhausted", internalErrorForClient(errorKindData(lastAssistantError), message.errors.join(", ") || message.subtype), message.errors.join(", ") || message.subtype);
|
|
2934
2768
|
break;
|
|
2935
2769
|
}
|
|
2936
2770
|
stopReason = "max_turn_requests";
|
|
2937
2771
|
break;
|
|
2938
2772
|
case "error_max_turns":
|
|
2939
2773
|
if (message.is_error) {
|
|
2940
|
-
await failActiveWithSessionFailure("
|
|
2774
|
+
await failActiveWithSessionFailure("context_exhausted", internalErrorForClient(errorKindData(lastAssistantError), message.errors.join(", ") || message.subtype), message.errors.join(", ") || message.subtype);
|
|
2941
2775
|
break;
|
|
2942
2776
|
}
|
|
2943
2777
|
stopReason = "max_turn_requests";
|
|
2944
2778
|
break;
|
|
2945
2779
|
case "error_max_structured_output_retries":
|
|
2946
2780
|
if (message.is_error) {
|
|
2947
|
-
await failActiveWithSessionFailure("provider_error", internalErrorForClient(errorKindData(lastAssistantError), message.errors.join(", ") || message.subtype));
|
|
2781
|
+
await failActiveWithSessionFailure("provider_error", internalErrorForClient(errorKindData(lastAssistantError), message.errors.join(", ") || message.subtype), message.errors.join(", ") || message.subtype);
|
|
2948
2782
|
break;
|
|
2949
2783
|
}
|
|
2950
2784
|
stopReason = "max_turn_requests";
|
|
@@ -3218,6 +3052,10 @@ export class ClaudeAcpAgent {
|
|
|
3218
3052
|
if (message.type === "assistant" && message.parent_tool_use_id === null) {
|
|
3219
3053
|
lastAssistantUsage = snapshotFromUsage(message.message.usage);
|
|
3220
3054
|
lastAssistantTotalUsage = totalTokens(lastAssistantUsage);
|
|
3055
|
+
lastAssistantWasUsageLimit = isSyntheticUsageLimitMessage(message.message);
|
|
3056
|
+
if (message.error || lastAssistantWasUsageLimit) {
|
|
3057
|
+
lastAssistantFailureTitle = assistantMessageText(message.message);
|
|
3058
|
+
}
|
|
3221
3059
|
if (message.message.model && message.message.model !== "<synthetic>") {
|
|
3222
3060
|
lastAssistantModel = message.message.model;
|
|
3223
3061
|
}
|
|
@@ -3276,7 +3114,18 @@ export class ClaudeAcpAgent {
|
|
|
3276
3114
|
break;
|
|
3277
3115
|
}
|
|
3278
3116
|
if (message.type === "assistant" && isSyntheticLoginMessage(message.message)) {
|
|
3279
|
-
await failActiveWithSessionFailure("auth_required", RequestError.authRequired());
|
|
3117
|
+
await failActiveWithSessionFailure("auth_required", RequestError.authRequired(), assistantMessageText(message.message));
|
|
3118
|
+
break;
|
|
3119
|
+
}
|
|
3120
|
+
// AIR receives this provider condition on the terminal prompt
|
|
3121
|
+
// response as a typed failure whose title is the exact assistant
|
|
3122
|
+
// error text captured above. Do not duplicate that text as an
|
|
3123
|
+
// ordinary assistant message; legacy clients retain the historical
|
|
3124
|
+
// transcript behavior.
|
|
3125
|
+
if (message.type === "assistant" &&
|
|
3126
|
+
message.parent_tool_use_id === null &&
|
|
3127
|
+
(message.error || isSyntheticUsageLimitMessage(message.message)) &&
|
|
3128
|
+
supportsAirSessionFailures(this.clientCapabilities)) {
|
|
3280
3129
|
break;
|
|
3281
3130
|
}
|
|
3282
3131
|
let content;
|
|
@@ -3452,7 +3301,7 @@ export class ClaudeAcpAgent {
|
|
|
3452
3301
|
break;
|
|
3453
3302
|
case "auth_status":
|
|
3454
3303
|
if (!message.isAuthenticating && message.error === undefined) {
|
|
3455
|
-
await
|
|
3304
|
+
await sessionFailures.clear((failure) => failure.kind === "auth_required");
|
|
3456
3305
|
}
|
|
3457
3306
|
break;
|
|
3458
3307
|
default:
|
|
@@ -3951,9 +3800,28 @@ export class ClaudeAcpAgent {
|
|
|
3951
3800
|
async replaySessionHistory(sessionId) {
|
|
3952
3801
|
const toolUseCache = {};
|
|
3953
3802
|
const messages = await getSessionMessages(sessionId);
|
|
3954
|
-
const
|
|
3955
|
-
|
|
3803
|
+
const session = this.sessions[sessionId];
|
|
3804
|
+
const forwardSubagentText = session?.forwardSubagentText ?? supportsSubagentTranscript(this.clientCapabilities);
|
|
3805
|
+
const supportsTypedFailures = supportsAirSessionFailures(this.clientCapabilities);
|
|
3806
|
+
const activeUsageLimit = supportsTypedFailures ? activeUsageLimitMessage(messages) : undefined;
|
|
3807
|
+
const sessionFailures = session && supportsTypedFailures
|
|
3808
|
+
? new SessionFailureController({
|
|
3809
|
+
sessionId,
|
|
3810
|
+
state: session.sessionFailureState,
|
|
3811
|
+
capabilities: this.clientCapabilities,
|
|
3812
|
+
isCurrent: () => this.sessions[sessionId] === session,
|
|
3813
|
+
sendUpdate: (notification) => this.client.sessionUpdate(notification),
|
|
3814
|
+
logger: this.logger,
|
|
3815
|
+
})
|
|
3816
|
+
: undefined;
|
|
3817
|
+
let replayTurnId;
|
|
3956
3818
|
for (const message of messages) {
|
|
3819
|
+
if (message.type === "user" &&
|
|
3820
|
+
message.parent_tool_use_id === null &&
|
|
3821
|
+
typeof message.uuid === "string" &&
|
|
3822
|
+
message.uuid.length > 0) {
|
|
3823
|
+
replayTurnId = message.uuid;
|
|
3824
|
+
}
|
|
3957
3825
|
// Backfill the ACP messageId -> SDK uuid mapping for messages we didn't
|
|
3958
3826
|
// observe live (resumed/loaded sessions), so rewind/resume can translate
|
|
3959
3827
|
// a client-supplied id without an extra getSessionMessages read. Not read
|
|
@@ -3969,6 +3837,21 @@ export class ClaudeAcpAgent {
|
|
|
3969
3837
|
if (message.type === "assistant" && isSyntheticLoginMessage(message.message)) {
|
|
3970
3838
|
continue;
|
|
3971
3839
|
}
|
|
3840
|
+
// Capable clients saw every synthetic usage-limit message as a typed
|
|
3841
|
+
// failure live, so replay it at the same transcript position. The
|
|
3842
|
+
// preceding persisted user uuid is the live prompt uuid and therefore
|
|
3843
|
+
// recreates the same incident identity. Only the latest limit not
|
|
3844
|
+
// followed by a real model answer remains active internally.
|
|
3845
|
+
if (sessionFailures &&
|
|
3846
|
+
message.type === "assistant" &&
|
|
3847
|
+
message.parent_tool_use_id === null &&
|
|
3848
|
+
isSyntheticUsageLimitMessage(message.message)) {
|
|
3849
|
+
const title = assistantMessageText(message.message);
|
|
3850
|
+
if (title) {
|
|
3851
|
+
await sessionFailures.restore(replayTurnId ? `${replayTurnId}:error` : `${sessionId}:history-error:${message.uuid}`, "quota_exhausted", title, message.uuid === activeUsageLimit?.uuid);
|
|
3852
|
+
}
|
|
3853
|
+
continue;
|
|
3854
|
+
}
|
|
3972
3855
|
// @ts-expect-error - untyped in SDK but we handle all of these
|
|
3973
3856
|
let content = message.message.content;
|
|
3974
3857
|
const parentToolUseId = parentToolUseIdOf(message);
|
|
@@ -5113,6 +4996,7 @@ export class ClaudeAcpAgent {
|
|
|
5113
4996
|
emittedAssistantText: false,
|
|
5114
4997
|
owedTrailingIdles: 0,
|
|
5115
4998
|
messageIdToUuid: new Map(),
|
|
4999
|
+
sessionFailureState: createSessionFailureState(),
|
|
5116
5000
|
};
|
|
5117
5001
|
return {
|
|
5118
5002
|
sessionId,
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import type { ClientCapabilities, SessionNotification } from "@agentclientprotocol/sdk";
|
|
2
|
+
import { getSessionMessages, type SDKAssistantMessageError } from "@anthropic-ai/claude-agent-sdk";
|
|
3
|
+
export declare function airSessionFailureCapabilityMeta(): {
|
|
4
|
+
jetbrains: {
|
|
5
|
+
air: {
|
|
6
|
+
version: number;
|
|
7
|
+
capabilities: string[];
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export type ClaudeFailureKind = "advisory" | "auth_required" | "bad_request" | "budget_exhausted" | "context_exhausted" | "internal_error" | "overloaded" | "provider_error" | "quota_exhausted" | "rate_limited" | "transport_lost" | "worker_shutdown";
|
|
12
|
+
type AirSessionFailureCategory = "connection" | "access" | "limit" | "request" | "service" | "unknown";
|
|
13
|
+
type AirSessionFailureSeverity = "warning" | "error";
|
|
14
|
+
type AirSessionFailureAction = "retry" | "login" | "new_session";
|
|
15
|
+
type SessionFailureRecoveryPolicy = "never" | "next_attempt" | "real_model_success" | "auth_status" | "runtime_rebind";
|
|
16
|
+
export type PublishedSessionFailure = {
|
|
17
|
+
id: string;
|
|
18
|
+
revision: number;
|
|
19
|
+
kind: ClaudeFailureKind;
|
|
20
|
+
category: AirSessionFailureCategory;
|
|
21
|
+
turnId?: string;
|
|
22
|
+
severity: AirSessionFailureSeverity;
|
|
23
|
+
title: string;
|
|
24
|
+
details?: string;
|
|
25
|
+
actions: AirSessionFailureAction[];
|
|
26
|
+
recoveryPolicy: SessionFailureRecoveryPolicy;
|
|
27
|
+
};
|
|
28
|
+
type SessionFailureOptions = {
|
|
29
|
+
turnId?: string;
|
|
30
|
+
sessionScoped?: boolean;
|
|
31
|
+
title?: string;
|
|
32
|
+
details?: string;
|
|
33
|
+
severity?: AirSessionFailureSeverity;
|
|
34
|
+
};
|
|
35
|
+
export type SessionFailureState = {
|
|
36
|
+
epoch: string;
|
|
37
|
+
revisions: Map<string, number>;
|
|
38
|
+
active: Map<string, PublishedSessionFailure>;
|
|
39
|
+
nextIncident?: number;
|
|
40
|
+
lastNotice?: {
|
|
41
|
+
title: string;
|
|
42
|
+
id: string;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
type Logger = {
|
|
46
|
+
error: (...args: unknown[]) => void;
|
|
47
|
+
};
|
|
48
|
+
export declare function createSessionFailureState(): SessionFailureState;
|
|
49
|
+
export declare function sessionFailureMeta(failure: PublishedSessionFailure): {
|
|
50
|
+
jetbrains: {
|
|
51
|
+
air: {
|
|
52
|
+
version: number;
|
|
53
|
+
sessionFailure: {
|
|
54
|
+
actions: AirSessionFailureAction[];
|
|
55
|
+
details?: string | undefined;
|
|
56
|
+
id: string;
|
|
57
|
+
revision: number;
|
|
58
|
+
category: AirSessionFailureCategory;
|
|
59
|
+
severity: AirSessionFailureSeverity;
|
|
60
|
+
title: string;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
/** `getSessionMessages` deliberately exposes only the API message and strips
|
|
66
|
+
* transcript-level `error` / `isApiErrorMessage` fields. The SDK exports the
|
|
67
|
+
* exact stable prefixes used by its synthetic usage-limit errors, so replay
|
|
68
|
+
* can recover this one typed failure without matching arbitrary model prose. */
|
|
69
|
+
export declare function assistantMessageText(apiMessage: unknown): string | undefined;
|
|
70
|
+
export declare function isSyntheticUsageLimitMessage(apiMessage: unknown): boolean;
|
|
71
|
+
export declare function activeUsageLimitMessage(messages: Awaited<ReturnType<typeof getSessionMessages>>): {
|
|
72
|
+
uuid: string;
|
|
73
|
+
title: string;
|
|
74
|
+
} | undefined;
|
|
75
|
+
export declare function supportsAirSessionFailures(capabilities?: ClientCapabilities): boolean;
|
|
76
|
+
/** Owns the AIR failure lifecycle for both the live consumer and history replay.
|
|
77
|
+
* Published revisions become active only after delivery succeeds; recovery only
|
|
78
|
+
* removes internal active state because transcript records are historical. */
|
|
79
|
+
export declare class SessionFailureController {
|
|
80
|
+
private readonly sessionId;
|
|
81
|
+
private readonly state;
|
|
82
|
+
private readonly capabilities?;
|
|
83
|
+
private readonly isCurrent;
|
|
84
|
+
private readonly sendUpdate;
|
|
85
|
+
private readonly logger;
|
|
86
|
+
constructor(options: {
|
|
87
|
+
sessionId: string;
|
|
88
|
+
state: SessionFailureState;
|
|
89
|
+
capabilities?: ClientCapabilities;
|
|
90
|
+
isCurrent: () => boolean;
|
|
91
|
+
sendUpdate: (notification: SessionNotification) => Promise<void>;
|
|
92
|
+
logger: Logger;
|
|
93
|
+
});
|
|
94
|
+
private isSupported;
|
|
95
|
+
private emit;
|
|
96
|
+
recordActive(failure: PublishedSessionFailure): void;
|
|
97
|
+
clear(shouldClear?: (failure: PublishedSessionFailure) => boolean): Promise<boolean>;
|
|
98
|
+
prepare(kind: ClaudeFailureKind, failureOptions?: SessionFailureOptions): Promise<PublishedSessionFailure | undefined>;
|
|
99
|
+
publish(kind: ClaudeFailureKind, failureOptions?: SessionFailureOptions): Promise<void>;
|
|
100
|
+
restore(id: string, kind: ClaudeFailureKind, title: string, active?: boolean): Promise<boolean>;
|
|
101
|
+
}
|
|
102
|
+
export declare function providerFailureCategory(errorKind?: SDKAssistantMessageError, isUsageLimit?: boolean): ClaudeFailureKind;
|
|
103
|
+
export {};
|
|
104
|
+
//# sourceMappingURL=session-failure-extension.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-failure-extension.d.ts","sourceRoot":"","sources":["../src/session-failure-extension.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AACxF,OAAO,EACL,kBAAkB,EAClB,KAAK,wBAAwB,EAE9B,MAAM,gCAAgC,CAAC;AAUxC,wBAAgB,+BAA+B;;;;;;;EAS9C;AAED,MAAM,MAAM,iBAAiB,GACzB,UAAU,GACV,eAAe,GACf,aAAa,GACb,kBAAkB,GAClB,mBAAmB,GACnB,gBAAgB,GAChB,YAAY,GACZ,gBAAgB,GAChB,iBAAiB,GACjB,cAAc,GACd,gBAAgB,GAChB,iBAAiB,CAAC;AAEtB,KAAK,yBAAyB,GAC5B,YAAY,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;AAExE,KAAK,yBAAyB,GAAG,SAAS,GAAG,OAAO,CAAC;AACrD,KAAK,uBAAuB,GAAG,OAAO,GAAG,OAAO,GAAG,aAAa,CAAC;AAEjE,KAAK,4BAA4B,GAC/B,OAAO,GAAG,cAAc,GAAG,oBAAoB,GAAG,aAAa,GAAG,gBAAgB,CAAC;AAErF,MAAM,MAAM,uBAAuB,GAAG;IACpC,EA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B,cAAc,GAAE,qBAA0B,GACzC,OAAO,CAAC,IAAI,CAAC;IAMV,OAAO,CACX,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,iBAAiB,EACvB,KAAK,EAAE,MAAM,EACb,MAAM,UAAO,GACZ,OAAO,CAAC,OAAO,CAAC;CAsBpB;AAED,wBAAgB,uBAAuB,CACrC,SAAS,CAAC,EAAE,wBAAwB,EACpC,YAAY,UAAQ,GACnB,iBAAiB,CAwBnB"}
|
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
import { USAGE_LIMIT_ERROR_PREFIXES, } from "@anthropic-ai/claude-agent-sdk";
|
|
2
|
+
import { randomUUID } from "node:crypto";
|
|
3
|
+
const JETBRAINS_META_KEY = "jetbrains";
|
|
4
|
+
const AIR_META_KEY = "air";
|
|
5
|
+
const AIR_EXTENSION_VERSION_KEY = "version";
|
|
6
|
+
const AIR_EXTENSION_CAPABILITIES_KEY = "capabilities";
|
|
7
|
+
const AIR_SESSION_FAILURE_KEY = "sessionFailure";
|
|
8
|
+
const AIR_EXTENSION_VERSION = 1;
|
|
9
|
+
export function airSessionFailureCapabilityMeta() {
|
|
10
|
+
return {
|
|
11
|
+
[JETBRAINS_META_KEY]: {
|
|
12
|
+
[AIR_META_KEY]: {
|
|
13
|
+
[AIR_EXTENSION_VERSION_KEY]: AIR_EXTENSION_VERSION,
|
|
14
|
+
[AIR_EXTENSION_CAPABILITIES_KEY]: [AIR_SESSION_FAILURE_KEY],
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export function createSessionFailureState() {
|
|
20
|
+
return {
|
|
21
|
+
epoch: randomUUID(),
|
|
22
|
+
revisions: new Map(),
|
|
23
|
+
active: new Map(),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
const AIR_FAILURE_POLICY = {
|
|
27
|
+
advisory: {
|
|
28
|
+
category: "unknown",
|
|
29
|
+
actions: [],
|
|
30
|
+
fallbackTitle: "Claude reported a notice.",
|
|
31
|
+
},
|
|
32
|
+
auth_required: {
|
|
33
|
+
category: "access",
|
|
34
|
+
actions: ["login"],
|
|
35
|
+
fallbackTitle: "Sign in to continue using Claude.",
|
|
36
|
+
},
|
|
37
|
+
bad_request: {
|
|
38
|
+
category: "request",
|
|
39
|
+
actions: [],
|
|
40
|
+
fallbackTitle: "Claude could not process this request.",
|
|
41
|
+
},
|
|
42
|
+
budget_exhausted: {
|
|
43
|
+
category: "limit",
|
|
44
|
+
actions: ["new_session"],
|
|
45
|
+
fallbackTitle: "This Claude session reached its configured budget.",
|
|
46
|
+
},
|
|
47
|
+
context_exhausted: {
|
|
48
|
+
category: "limit",
|
|
49
|
+
actions: ["new_session"],
|
|
50
|
+
fallbackTitle: "This Claude turn reached its configured limit.",
|
|
51
|
+
},
|
|
52
|
+
internal_error: {
|
|
53
|
+
category: "service",
|
|
54
|
+
actions: ["retry", "new_session"],
|
|
55
|
+
fallbackTitle: "Claude Agent encountered an internal error.",
|
|
56
|
+
},
|
|
57
|
+
overloaded: {
|
|
58
|
+
category: "service",
|
|
59
|
+
actions: ["retry"],
|
|
60
|
+
fallbackTitle: "Claude is temporarily overloaded.",
|
|
61
|
+
},
|
|
62
|
+
provider_error: {
|
|
63
|
+
category: "service",
|
|
64
|
+
actions: ["retry"],
|
|
65
|
+
fallbackTitle: "The model provider reported an error.",
|
|
66
|
+
},
|
|
67
|
+
quota_exhausted: {
|
|
68
|
+
category: "limit",
|
|
69
|
+
actions: [],
|
|
70
|
+
fallbackTitle: "The Claude account has no available quota.",
|
|
71
|
+
},
|
|
72
|
+
rate_limited: {
|
|
73
|
+
category: "limit",
|
|
74
|
+
actions: ["retry"],
|
|
75
|
+
fallbackTitle: "Claude is temporarily rate limited.",
|
|
76
|
+
},
|
|
77
|
+
transport_lost: {
|
|
78
|
+
category: "connection",
|
|
79
|
+
actions: ["new_session"],
|
|
80
|
+
fallbackTitle: "The connection to Claude was lost.",
|
|
81
|
+
},
|
|
82
|
+
worker_shutdown: {
|
|
83
|
+
category: "connection",
|
|
84
|
+
actions: ["new_session"],
|
|
85
|
+
fallbackTitle: "The Claude worker is shutting down.",
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
export function sessionFailureMeta(failure) {
|
|
89
|
+
return {
|
|
90
|
+
[JETBRAINS_META_KEY]: {
|
|
91
|
+
[AIR_META_KEY]: {
|
|
92
|
+
[AIR_EXTENSION_VERSION_KEY]: AIR_EXTENSION_VERSION,
|
|
93
|
+
[AIR_SESSION_FAILURE_KEY]: {
|
|
94
|
+
id: failure.id,
|
|
95
|
+
revision: failure.revision,
|
|
96
|
+
category: failure.category,
|
|
97
|
+
severity: failure.severity,
|
|
98
|
+
title: failure.title,
|
|
99
|
+
...(failure.details ? { details: failure.details } : {}),
|
|
100
|
+
actions: failure.actions,
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/** `getSessionMessages` deliberately exposes only the API message and strips
|
|
107
|
+
* transcript-level `error` / `isApiErrorMessage` fields. The SDK exports the
|
|
108
|
+
* exact stable prefixes used by its synthetic usage-limit errors, so replay
|
|
109
|
+
* can recover this one typed failure without matching arbitrary model prose. */
|
|
110
|
+
export function assistantMessageText(apiMessage) {
|
|
111
|
+
if (!apiMessage || typeof apiMessage !== "object")
|
|
112
|
+
return undefined;
|
|
113
|
+
const { content } = apiMessage;
|
|
114
|
+
if (typeof content === "string")
|
|
115
|
+
return content || undefined;
|
|
116
|
+
if (!Array.isArray(content))
|
|
117
|
+
return undefined;
|
|
118
|
+
const text = content
|
|
119
|
+
.map((block) => block &&
|
|
120
|
+
typeof block === "object" &&
|
|
121
|
+
"type" in block &&
|
|
122
|
+
block.type === "text" &&
|
|
123
|
+
"text" in block &&
|
|
124
|
+
typeof block.text === "string"
|
|
125
|
+
? block.text
|
|
126
|
+
: "")
|
|
127
|
+
.join("");
|
|
128
|
+
return text || undefined;
|
|
129
|
+
}
|
|
130
|
+
export function isSyntheticUsageLimitMessage(apiMessage) {
|
|
131
|
+
if (!apiMessage || typeof apiMessage !== "object")
|
|
132
|
+
return false;
|
|
133
|
+
const { model } = apiMessage;
|
|
134
|
+
if (model !== "<synthetic>")
|
|
135
|
+
return false;
|
|
136
|
+
const text = assistantMessageText(apiMessage);
|
|
137
|
+
if (!text)
|
|
138
|
+
return false;
|
|
139
|
+
return USAGE_LIMIT_ERROR_PREFIXES.some((prefix) => text.startsWith(prefix));
|
|
140
|
+
}
|
|
141
|
+
export function activeUsageLimitMessage(messages) {
|
|
142
|
+
let active;
|
|
143
|
+
for (const message of messages) {
|
|
144
|
+
if (message.type !== "assistant" || message.parent_tool_use_id !== null)
|
|
145
|
+
continue;
|
|
146
|
+
if (isSyntheticUsageLimitMessage(message.message)) {
|
|
147
|
+
const title = assistantMessageText(message.message);
|
|
148
|
+
if (title)
|
|
149
|
+
active = { uuid: message.uuid, title };
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
const model = message.message && typeof message.message === "object" && "model" in message.message
|
|
153
|
+
? message.message.model
|
|
154
|
+
: undefined;
|
|
155
|
+
// A later real model answer proves the account recovered. Synthetic
|
|
156
|
+
// local-command/interruption messages do not: they can be appended while
|
|
157
|
+
// the provider remains unavailable.
|
|
158
|
+
if (model !== undefined && model !== "<synthetic>")
|
|
159
|
+
active = undefined;
|
|
160
|
+
}
|
|
161
|
+
return active;
|
|
162
|
+
}
|
|
163
|
+
export function supportsAirSessionFailures(capabilities) {
|
|
164
|
+
const jetbrains = capabilities?._meta?.[JETBRAINS_META_KEY];
|
|
165
|
+
const air = jetbrains?.[AIR_META_KEY];
|
|
166
|
+
const version = air?.[AIR_EXTENSION_VERSION_KEY];
|
|
167
|
+
const advertised = air?.[AIR_EXTENSION_CAPABILITIES_KEY];
|
|
168
|
+
return (typeof version === "number" &&
|
|
169
|
+
Number.isFinite(version) &&
|
|
170
|
+
Number.isInteger(version) &&
|
|
171
|
+
version >= AIR_EXTENSION_VERSION &&
|
|
172
|
+
Array.isArray(advertised) &&
|
|
173
|
+
advertised.some((capability) => capability === AIR_SESSION_FAILURE_KEY));
|
|
174
|
+
}
|
|
175
|
+
function sessionFailureRecoveryPolicy(kind, turnId) {
|
|
176
|
+
switch (kind) {
|
|
177
|
+
case "advisory":
|
|
178
|
+
return "never";
|
|
179
|
+
case "auth_required":
|
|
180
|
+
return "auth_status";
|
|
181
|
+
case "transport_lost":
|
|
182
|
+
case "worker_shutdown":
|
|
183
|
+
return "runtime_rebind";
|
|
184
|
+
case "quota_exhausted":
|
|
185
|
+
return "real_model_success";
|
|
186
|
+
default:
|
|
187
|
+
return turnId ? "next_attempt" : "real_model_success";
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
/** Owns the AIR failure lifecycle for both the live consumer and history replay.
|
|
191
|
+
* Published revisions become active only after delivery succeeds; recovery only
|
|
192
|
+
* removes internal active state because transcript records are historical. */
|
|
193
|
+
export class SessionFailureController {
|
|
194
|
+
sessionId;
|
|
195
|
+
state;
|
|
196
|
+
capabilities;
|
|
197
|
+
isCurrent;
|
|
198
|
+
sendUpdate;
|
|
199
|
+
logger;
|
|
200
|
+
constructor(options) {
|
|
201
|
+
this.sessionId = options.sessionId;
|
|
202
|
+
this.state = options.state;
|
|
203
|
+
this.capabilities = options.capabilities;
|
|
204
|
+
this.isCurrent = options.isCurrent;
|
|
205
|
+
this.sendUpdate = options.sendUpdate;
|
|
206
|
+
this.logger = options.logger;
|
|
207
|
+
}
|
|
208
|
+
isSupported() {
|
|
209
|
+
return supportsAirSessionFailures(this.capabilities);
|
|
210
|
+
}
|
|
211
|
+
async emit(failure) {
|
|
212
|
+
if (!this.isCurrent()) {
|
|
213
|
+
this.logger.error(`Session ${this.sessionId}: ignored AIR session failure from a stale consumer`);
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
216
|
+
try {
|
|
217
|
+
await this.sendUpdate({
|
|
218
|
+
sessionId: this.sessionId,
|
|
219
|
+
update: {
|
|
220
|
+
sessionUpdate: "session_info_update",
|
|
221
|
+
_meta: sessionFailureMeta(failure),
|
|
222
|
+
},
|
|
223
|
+
});
|
|
224
|
+
return true;
|
|
225
|
+
}
|
|
226
|
+
catch (error) {
|
|
227
|
+
this.logger.error(`Session ${this.sessionId}: failed to publish AIR session failure: ${error}`);
|
|
228
|
+
return false;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
recordActive(failure) {
|
|
232
|
+
this.state.revisions.set(failure.id, failure.revision);
|
|
233
|
+
this.state.active.set(failure.id, failure);
|
|
234
|
+
this.state.lastNotice =
|
|
235
|
+
failure.kind === "advisory" ? { title: failure.title, id: failure.id } : undefined;
|
|
236
|
+
}
|
|
237
|
+
async clear(shouldClear = () => true) {
|
|
238
|
+
if (!this.isSupported())
|
|
239
|
+
return true;
|
|
240
|
+
this.state.lastNotice = undefined;
|
|
241
|
+
for (const failure of [...this.state.active.values()]) {
|
|
242
|
+
if (!shouldClear(failure))
|
|
243
|
+
continue;
|
|
244
|
+
this.state.active.delete(failure.id);
|
|
245
|
+
}
|
|
246
|
+
return true;
|
|
247
|
+
}
|
|
248
|
+
async prepare(kind, failureOptions = {}) {
|
|
249
|
+
if (!this.isSupported() || !this.isCurrent())
|
|
250
|
+
return undefined;
|
|
251
|
+
const policy = AIR_FAILURE_POLICY[kind];
|
|
252
|
+
const title = failureOptions.title || policy.fallbackTitle;
|
|
253
|
+
if (kind === "advisory") {
|
|
254
|
+
const id = this.state.lastNotice?.title === title
|
|
255
|
+
? this.state.lastNotice.id
|
|
256
|
+
: `${this.sessionId}:notice:${this.state.epoch}:${this.state.nextIncident ?? 1}`;
|
|
257
|
+
if (this.state.lastNotice?.title !== title) {
|
|
258
|
+
this.state.nextIncident = (this.state.nextIncident ?? 1) + 1;
|
|
259
|
+
}
|
|
260
|
+
return {
|
|
261
|
+
id,
|
|
262
|
+
revision: (this.state.revisions.get(id) ?? 0) + 1,
|
|
263
|
+
kind,
|
|
264
|
+
category: policy.category,
|
|
265
|
+
severity: "warning",
|
|
266
|
+
title,
|
|
267
|
+
...(failureOptions.details ? { details: failureOptions.details } : {}),
|
|
268
|
+
actions: policy.actions,
|
|
269
|
+
recoveryPolicy: sessionFailureRecoveryPolicy(kind),
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
const id = failureOptions.turnId && !failureOptions.sessionScoped
|
|
273
|
+
? `${failureOptions.turnId}:error`
|
|
274
|
+
: `${this.sessionId}:session-error:${this.state.epoch}:${this.state.nextIncident ?? 1}`;
|
|
275
|
+
if (!failureOptions.turnId || failureOptions.sessionScoped) {
|
|
276
|
+
this.state.nextIncident = (this.state.nextIncident ?? 1) + 1;
|
|
277
|
+
}
|
|
278
|
+
return {
|
|
279
|
+
id,
|
|
280
|
+
revision: (this.state.revisions.get(id) ?? 0) + 1,
|
|
281
|
+
kind,
|
|
282
|
+
category: policy.category,
|
|
283
|
+
severity: failureOptions.severity ?? "error",
|
|
284
|
+
title,
|
|
285
|
+
...(failureOptions.details ? { details: failureOptions.details } : {}),
|
|
286
|
+
actions: failureOptions.severity === "warning" ? [] : policy.actions,
|
|
287
|
+
recoveryPolicy: sessionFailureRecoveryPolicy(kind, failureOptions.turnId && !failureOptions.sessionScoped ? failureOptions.turnId : undefined),
|
|
288
|
+
...(failureOptions.turnId && !failureOptions.sessionScoped
|
|
289
|
+
? { turnId: failureOptions.turnId }
|
|
290
|
+
: {}),
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
async publish(kind, failureOptions = {}) {
|
|
294
|
+
const failure = await this.prepare(kind, failureOptions);
|
|
295
|
+
if (!failure)
|
|
296
|
+
return;
|
|
297
|
+
if (await this.emit(failure))
|
|
298
|
+
this.recordActive(failure);
|
|
299
|
+
}
|
|
300
|
+
async restore(id, kind, title, active = true) {
|
|
301
|
+
if (!this.isSupported() || !this.isCurrent())
|
|
302
|
+
return false;
|
|
303
|
+
const policy = AIR_FAILURE_POLICY[kind];
|
|
304
|
+
const failure = {
|
|
305
|
+
id,
|
|
306
|
+
revision: (this.state.revisions.get(id) ?? 0) + 1,
|
|
307
|
+
kind,
|
|
308
|
+
category: policy.category,
|
|
309
|
+
severity: "error",
|
|
310
|
+
title,
|
|
311
|
+
actions: policy.actions,
|
|
312
|
+
recoveryPolicy: sessionFailureRecoveryPolicy(kind),
|
|
313
|
+
};
|
|
314
|
+
if (!(await this.emit(failure)))
|
|
315
|
+
return false;
|
|
316
|
+
this.state.revisions.set(failure.id, failure.revision);
|
|
317
|
+
if (active) {
|
|
318
|
+
this.state.active.set(failure.id, failure);
|
|
319
|
+
}
|
|
320
|
+
else {
|
|
321
|
+
this.state.active.delete(failure.id);
|
|
322
|
+
}
|
|
323
|
+
return true;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
export function providerFailureCategory(errorKind, isUsageLimit = false) {
|
|
327
|
+
if (isUsageLimit)
|
|
328
|
+
return "quota_exhausted";
|
|
329
|
+
switch (errorKind) {
|
|
330
|
+
case "authentication_failed":
|
|
331
|
+
case "oauth_org_not_allowed":
|
|
332
|
+
return "auth_required";
|
|
333
|
+
case "billing_error":
|
|
334
|
+
return "quota_exhausted";
|
|
335
|
+
case "rate_limit":
|
|
336
|
+
return "rate_limited";
|
|
337
|
+
case "overloaded":
|
|
338
|
+
return "overloaded";
|
|
339
|
+
case "invalid_request":
|
|
340
|
+
case "model_not_found":
|
|
341
|
+
return "bad_request";
|
|
342
|
+
case "max_output_tokens":
|
|
343
|
+
return "context_exhausted";
|
|
344
|
+
case "server_error":
|
|
345
|
+
case "unknown":
|
|
346
|
+
case undefined:
|
|
347
|
+
return "provider_error";
|
|
348
|
+
default:
|
|
349
|
+
return "provider_error";
|
|
350
|
+
}
|
|
351
|
+
}
|
package/package.json
CHANGED