@agentclientprotocol/claude-agent-acp 0.59.0 → 0.60.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/acp-agent.d.ts +76 -5
- package/dist/acp-agent.d.ts.map +1 -1
- package/dist/acp-agent.js +445 -95
- package/dist/tools.d.ts +1 -2
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +34 -9
- package/package.json +5 -5
package/dist/acp-agent.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AuthenticateRequest, CancelNotification, ClientCapabilities, CompleteElicitationNotification, CreateElicitationRequest, CreateElicitationResponse, ForkSessionRequest, ForkSessionResponse, InitializeRequest, InitializeResponse, ListSessionsRequest, ListSessionsResponse, LoadSessionRequest, LoadSessionResponse, LogoutRequest, NewSessionRequest, NewSessionResponse, PromptRequest, PromptResponse, ReadTextFileRequest, ReadTextFileResponse, RequestPermissionRequest, RequestPermissionResponse, ResumeSessionRequest, ResumeSessionResponse, SessionConfigOption, SessionModeState, SessionNotification, SetSessionConfigOptionRequest, SetSessionConfigOptionResponse, SetSessionModeRequest, SetSessionModeResponse, CloseSessionRequest, CloseSessionResponse, DeleteSessionRequest, DeleteSessionResponse, WriteTextFileRequest, WriteTextFileResponse } from "@agentclientprotocol/sdk";
|
|
1
|
+
import { AuthenticateRequest, CancelNotification, ClientCapabilities, CompleteElicitationNotification, CreateElicitationRequest, CreateElicitationResponse, DisableProviderRequest, DisableProviderResponse, ForkSessionRequest, ForkSessionResponse, InitializeRequest, InitializeResponse, ListProvidersRequest, ListProvidersResponse, LlmProtocol, ListSessionsRequest, ListSessionsResponse, LoadSessionRequest, LoadSessionResponse, LogoutRequest, NewSessionRequest, NewSessionResponse, PromptRequest, PromptResponse, ReadTextFileRequest, ReadTextFileResponse, SetProviderRequest, SetProviderResponse, RequestPermissionRequest, RequestPermissionResponse, ResumeSessionRequest, ResumeSessionResponse, SessionConfigOption, SessionModeState, SessionNotification, SetSessionConfigOptionRequest, SetSessionConfigOptionResponse, SetSessionModeRequest, SetSessionModeResponse, CloseSessionRequest, CloseSessionResponse, DeleteSessionRequest, DeleteSessionResponse, WriteTextFileRequest, WriteTextFileResponse } from "@agentclientprotocol/sdk";
|
|
2
2
|
import { AgentInfo, CanUseTool, FastModeState, ModelInfo, Options, PermissionMode, PermissionUpdate, Query, SDKMessageOrigin, SDKPartialAssistantMessage, SDKUserMessage } from "@anthropic-ai/claude-agent-sdk";
|
|
3
3
|
import { ContentBlockParam } from "@anthropic-ai/sdk/resources";
|
|
4
4
|
import { BetaContentBlock, BetaRawContentBlockDelta } from "@anthropic-ai/sdk/resources/beta.mjs";
|
|
@@ -222,11 +222,32 @@ type Session = {
|
|
|
222
222
|
emitRawSDKMessages: boolean | SDKMessageFilter[];
|
|
223
223
|
/** Context window size of the session's current model, carried across
|
|
224
224
|
* prompts so mid-stream usage_update notifications report a correct `size`
|
|
225
|
-
* before the turn's first result message arrives. Seeded
|
|
226
|
-
*
|
|
227
|
-
*
|
|
228
|
-
*
|
|
225
|
+
* before the turn's first result message arrives. Seeded synchronously at
|
|
226
|
+
* session creation and on model switches from the per-model cache or the
|
|
227
|
+
* text heuristic (DEFAULT_CONTEXT_WINDOW when both miss; on session/load the
|
|
228
|
+
* resumed session's own `getContextUsage` report wins, see
|
|
229
|
+
* `readResumedLiveModel`), then confirmed — and the cache populated — by each
|
|
230
|
+
* result's modelUsage. No extra `getContextUsage` IPC is on these paths: on a
|
|
231
|
+
* fresh session it stalls until the first turn runs (see the seeding call
|
|
232
|
+
* sites and `contextWindowCache`). */
|
|
229
233
|
contextWindowSize: number;
|
|
234
|
+
/** Whether `contextWindowSize` came from an authoritative source (the
|
|
235
|
+
* cross-session cache, a resumed session's `getContextUsage` report, or a
|
|
236
|
+
* `result.modelUsage`) rather than the text heuristic / default. Guards the
|
|
237
|
+
* mid-stream `message_start` heuristic upgrade: an authoritative window that
|
|
238
|
+
* happens to equal DEFAULT_CONTEXT_WINDOW must not be mistaken for "unseeded"
|
|
239
|
+
* and clobbered by a "1m" text match. */
|
|
240
|
+
contextWindowAuthoritative: boolean;
|
|
241
|
+
/** Stable identifier of the LLM backend this session's query was created
|
|
242
|
+
* against, derived from the routing-relevant vars of the exact `env` handed
|
|
243
|
+
* to the SDK at query creation (see {@link providerCacheKeyFor}). The context
|
|
244
|
+
* window is a property of (model id, backend) — the same resolved model id
|
|
245
|
+
* can name different windows behind different base URLs, routing headers, or
|
|
246
|
+
* credentials — so this scopes the module-global `contextWindowCache` per
|
|
247
|
+
* backend. Captured from the query's own env (not re-resolved later) because
|
|
248
|
+
* the process-wide provider config can change while a session is being
|
|
249
|
+
* created, while the query stays baked to the env it was created with. */
|
|
250
|
+
providerCacheKey: string;
|
|
230
251
|
/** Accumulated task list for the session, keyed by task ID. Task IDs are
|
|
231
252
|
* per-session, so this state must not be shared across sessions. */
|
|
232
253
|
taskState: TaskState;
|
|
@@ -431,6 +452,22 @@ type GatewayAuthMeta = {
|
|
|
431
452
|
type GatewayAuthRequest = AuthenticateRequest & {
|
|
432
453
|
_meta?: GatewayAuthMeta;
|
|
433
454
|
};
|
|
455
|
+
/**
|
|
456
|
+
* Resolved, non-secret + secret routing config for the `main` provider. This is
|
|
457
|
+
* the shared shape produced by both `providers/set` and the legacy gateway auth
|
|
458
|
+
* path, and consumed by {@link createEnvForProvider}. `null` means the provider
|
|
459
|
+
* is unconfigured (no client-managed routing in effect).
|
|
460
|
+
*/
|
|
461
|
+
type ProviderConfig = {
|
|
462
|
+
apiType: LlmProtocol;
|
|
463
|
+
baseUrl: string;
|
|
464
|
+
headers: Record<string, string>;
|
|
465
|
+
/** Present only for `apiType === "vertex"`. */
|
|
466
|
+
vertex?: {
|
|
467
|
+
projectId: string;
|
|
468
|
+
region: string;
|
|
469
|
+
};
|
|
470
|
+
};
|
|
434
471
|
/**
|
|
435
472
|
* Extra metadata that the agent provides for each tool_call / tool_update update.
|
|
436
473
|
*/
|
|
@@ -543,6 +580,10 @@ export declare class ClaudeAcpAgent {
|
|
|
543
580
|
clientCapabilities?: ClientCapabilities;
|
|
544
581
|
logger: Logger;
|
|
545
582
|
gatewayAuthRequest?: GatewayAuthRequest;
|
|
583
|
+
/** Client-managed LLM routing set via `providers/set`. Process-scoped and
|
|
584
|
+
* never persisted to disk (see the Configurable LLM Providers RFD). When
|
|
585
|
+
* set, it takes precedence over {@link gatewayAuthRequest}. */
|
|
586
|
+
providerConfig?: ProviderConfig;
|
|
546
587
|
/** Grace period before a `session/cancel` forces a wedged prompt loop to
|
|
547
588
|
* return "cancelled". See {@link DEFAULT_FORCE_CANCEL_GRACE_MS}. Mutable so
|
|
548
589
|
* tests can shrink it. */
|
|
@@ -561,6 +602,36 @@ export declare class ClaudeAcpAgent {
|
|
|
561
602
|
* the title is best-effort and another turn will retry. */
|
|
562
603
|
private maybeUpdateSessionTitle;
|
|
563
604
|
authenticate(_params: AuthenticateRequest): Promise<void>;
|
|
605
|
+
/**
|
|
606
|
+
* `providers/list` — returns the single client-configurable custom gateway
|
|
607
|
+
* provider (`main`). `current` carries only non-secret routing (never headers,
|
|
608
|
+
* which may hold secrets); only `apiType`/`baseUrl` are surfaced for UI
|
|
609
|
+
* display, and is `null` when the provider is not configured/disabled. The
|
|
610
|
+
* provider is optional (`required: false`): while disabled/unconfigured the
|
|
611
|
+
* agent falls back to its own default routing (normal Claude login).
|
|
612
|
+
*/
|
|
613
|
+
unstable_listProviders(_params: ListProvidersRequest): Promise<ListProvidersResponse>;
|
|
614
|
+
/**
|
|
615
|
+
* `providers/set` — replace the full configuration for the `main` provider.
|
|
616
|
+
* Rejects unknown IDs, unsupported protocols, and empty/invalid base URLs with
|
|
617
|
+
* `invalid_params`. Config is process-scoped and applies to sessions created or
|
|
618
|
+
* loaded after this call.
|
|
619
|
+
*/
|
|
620
|
+
unstable_setProvider(params: SetProviderRequest): Promise<SetProviderResponse>;
|
|
621
|
+
/**
|
|
622
|
+
* `providers/disable` — disabling the `main` provider clears any client-managed
|
|
623
|
+
* routing (both a `providers/set` config and the legacy gateway auth request),
|
|
624
|
+
* so the agent reverts to its own default routing and `providers/list` reports
|
|
625
|
+
* `current: null`. Disabling any other (unknown) ID is treated as a successful
|
|
626
|
+
* no-op per the RFD's idempotency rule.
|
|
627
|
+
*/
|
|
628
|
+
unstable_disableProvider(params: DisableProviderRequest): Promise<DisableProviderResponse>;
|
|
629
|
+
/**
|
|
630
|
+
* Resolve the effective client-managed routing config. `providers/set` takes
|
|
631
|
+
* precedence; otherwise fall back to the legacy gateway auth request. Returns
|
|
632
|
+
* `null` when neither is configured.
|
|
633
|
+
*/
|
|
634
|
+
resolveProviderConfig(): ProviderConfig | null;
|
|
564
635
|
logout(_params: LogoutRequest): Promise<void>;
|
|
565
636
|
prompt(params: PromptRequest): Promise<PromptResponse>;
|
|
566
637
|
/** Lazily start the per-session consumer that drains the SDK query stream for
|
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,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,EACnB,aAAa,EAGb,iBAAiB,EACjB,kBAAkB,EAElB,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,oBAAoB,EAEpB,wBAAwB,EACxB,yBAAyB,EACzB,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,EACnB,6BAA6B,EAC7B,8BAA8B,EAC9B,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,EACpB,q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E,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC,EAC3D,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,cAAc,CAAC,CAczB;AAED,wBAAgB,MAAM;;;EAwCrB"}
|
package/dist/acp-agent.js
CHANGED
|
@@ -97,6 +97,17 @@ function computeSessionFingerprint(params) {
|
|
|
97
97
|
const servers = [...(params.mcpServers ?? [])].sort((a, b) => a.name.localeCompare(b.name));
|
|
98
98
|
return JSON.stringify({ cwd: params.cwd, mcpServers: servers });
|
|
99
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* The single provider ID this agent exposes via `providers/*`. Claude Code has
|
|
102
|
+
* one LLM backend selected by protocol (anthropic / bedrock / vertex), so there
|
|
103
|
+
* is exactly one configurable provider.
|
|
104
|
+
*/
|
|
105
|
+
const PROVIDER_ID = "main";
|
|
106
|
+
/**
|
|
107
|
+
* Protocols the `main` provider can be configured with. These mirror the
|
|
108
|
+
* env-var mappings understood by {@link createEnvForProvider}.
|
|
109
|
+
*/
|
|
110
|
+
const SUPPORTED_PROTOCOLS = ["anthropic", "bedrock", "vertex"];
|
|
100
111
|
/**
|
|
101
112
|
* Advance the lexer state across the fragment appended since the last delta:
|
|
102
113
|
* just enough JSON awareness (string/escape, nesting depth) to spot commas
|
|
@@ -433,6 +444,10 @@ export class ClaudeAcpAgent {
|
|
|
433
444
|
clientCapabilities;
|
|
434
445
|
logger;
|
|
435
446
|
gatewayAuthRequest;
|
|
447
|
+
/** Client-managed LLM routing set via `providers/set`. Process-scoped and
|
|
448
|
+
* never persisted to disk (see the Configurable LLM Providers RFD). When
|
|
449
|
+
* set, it takes precedence over {@link gatewayAuthRequest}. */
|
|
450
|
+
providerConfig;
|
|
436
451
|
/** Grace period before a `session/cancel` forces a wedged prompt loop to
|
|
437
452
|
* return "cancelled". See {@link DEFAULT_FORCE_CANCEL_GRACE_MS}. Mutable so
|
|
438
453
|
* tests can shrink it. */
|
|
@@ -558,6 +573,10 @@ export class ClaudeAcpAgent {
|
|
|
558
573
|
auth: {
|
|
559
574
|
logout: {},
|
|
560
575
|
},
|
|
576
|
+
// Client-managed LLM routing via `providers/list`, `providers/set`, and
|
|
577
|
+
// `providers/disable`. Advertised unconditionally; there is no client
|
|
578
|
+
// capability prerequisite for the provider methods.
|
|
579
|
+
providers: {},
|
|
561
580
|
loadSession: true,
|
|
562
581
|
sessionCapabilities: {
|
|
563
582
|
additionalDirectories: {},
|
|
@@ -681,11 +700,100 @@ export class ClaudeAcpAgent {
|
|
|
681
700
|
}
|
|
682
701
|
throw new Error("Method not implemented.");
|
|
683
702
|
}
|
|
703
|
+
/**
|
|
704
|
+
* `providers/list` — returns the single client-configurable custom gateway
|
|
705
|
+
* provider (`main`). `current` carries only non-secret routing (never headers,
|
|
706
|
+
* which may hold secrets); only `apiType`/`baseUrl` are surfaced for UI
|
|
707
|
+
* display, and is `null` when the provider is not configured/disabled. The
|
|
708
|
+
* provider is optional (`required: false`): while disabled/unconfigured the
|
|
709
|
+
* agent falls back to its own default routing (normal Claude login).
|
|
710
|
+
*/
|
|
711
|
+
async unstable_listProviders(_params) {
|
|
712
|
+
const config = this.resolveProviderConfig();
|
|
713
|
+
const provider = {
|
|
714
|
+
providerId: PROVIDER_ID,
|
|
715
|
+
supported: SUPPORTED_PROTOCOLS,
|
|
716
|
+
required: false,
|
|
717
|
+
current: config ? { apiType: config.apiType, baseUrl: config.baseUrl } : null,
|
|
718
|
+
};
|
|
719
|
+
return { providers: [provider] };
|
|
720
|
+
}
|
|
721
|
+
/**
|
|
722
|
+
* `providers/set` — replace the full configuration for the `main` provider.
|
|
723
|
+
* Rejects unknown IDs, unsupported protocols, and empty/invalid base URLs with
|
|
724
|
+
* `invalid_params`. Config is process-scoped and applies to sessions created or
|
|
725
|
+
* loaded after this call.
|
|
726
|
+
*/
|
|
727
|
+
async unstable_setProvider(params) {
|
|
728
|
+
if (params.providerId !== PROVIDER_ID) {
|
|
729
|
+
throw RequestError.invalidParams({ providerId: params.providerId }, `Unknown provider ID "${params.providerId}"; expected "${PROVIDER_ID}".`);
|
|
730
|
+
}
|
|
731
|
+
if (!SUPPORTED_PROTOCOLS.includes(params.apiType)) {
|
|
732
|
+
throw RequestError.invalidParams({ apiType: params.apiType, supported: SUPPORTED_PROTOCOLS }, `Unsupported apiType "${params.apiType}" for provider "${PROVIDER_ID}".`);
|
|
733
|
+
}
|
|
734
|
+
if (!isValidBaseUrl(params.baseUrl)) {
|
|
735
|
+
throw RequestError.invalidParams({ baseUrl: params.baseUrl }, "baseUrl must be a non-empty absolute http(s) URL.");
|
|
736
|
+
}
|
|
737
|
+
const config = {
|
|
738
|
+
apiType: params.apiType,
|
|
739
|
+
baseUrl: params.baseUrl,
|
|
740
|
+
headers: params.headers ?? {},
|
|
741
|
+
};
|
|
742
|
+
// Vertex requires project + region, which the standard payload cannot
|
|
743
|
+
// carry, so they arrive via `_meta.claudeCode.vertex`.
|
|
744
|
+
if (params.apiType === "vertex") {
|
|
745
|
+
const vertex = params._meta?.claudeCode?.vertex;
|
|
746
|
+
if (!vertex ||
|
|
747
|
+
typeof vertex.projectId !== "string" ||
|
|
748
|
+
vertex.projectId.trim() === "" ||
|
|
749
|
+
typeof vertex.region !== "string" ||
|
|
750
|
+
vertex.region.trim() === "") {
|
|
751
|
+
throw RequestError.invalidParams(undefined, "vertex apiType requires non-empty `_meta.claudeCode.vertex.projectId` and `_meta.claudeCode.vertex.region`.");
|
|
752
|
+
}
|
|
753
|
+
config.vertex = { projectId: vertex.projectId, region: vertex.region };
|
|
754
|
+
}
|
|
755
|
+
this.providerConfig = config;
|
|
756
|
+
return {};
|
|
757
|
+
}
|
|
758
|
+
/**
|
|
759
|
+
* `providers/disable` — disabling the `main` provider clears any client-managed
|
|
760
|
+
* routing (both a `providers/set` config and the legacy gateway auth request),
|
|
761
|
+
* so the agent reverts to its own default routing and `providers/list` reports
|
|
762
|
+
* `current: null`. Disabling any other (unknown) ID is treated as a successful
|
|
763
|
+
* no-op per the RFD's idempotency rule.
|
|
764
|
+
*/
|
|
765
|
+
async unstable_disableProvider(params) {
|
|
766
|
+
if (params.providerId === PROVIDER_ID) {
|
|
767
|
+
this.providerConfig = undefined;
|
|
768
|
+
this.gatewayAuthRequest = undefined;
|
|
769
|
+
}
|
|
770
|
+
// Unknown provider: idempotent success.
|
|
771
|
+
return {};
|
|
772
|
+
}
|
|
773
|
+
/**
|
|
774
|
+
* Resolve the effective client-managed routing config. `providers/set` takes
|
|
775
|
+
* precedence; otherwise fall back to the legacy gateway auth request. Returns
|
|
776
|
+
* `null` when neither is configured.
|
|
777
|
+
*/
|
|
778
|
+
resolveProviderConfig() {
|
|
779
|
+
if (this.providerConfig) {
|
|
780
|
+
return this.providerConfig;
|
|
781
|
+
}
|
|
782
|
+
return gatewayRequestToProviderConfig(this.gatewayAuthRequest);
|
|
783
|
+
}
|
|
684
784
|
async logout(_params) {
|
|
685
|
-
// Clear in-memory gateway credentials supplied via `authenticate
|
|
686
|
-
//
|
|
687
|
-
//
|
|
785
|
+
// Clear in-memory gateway credentials supplied via `authenticate` and any
|
|
786
|
+
// provider routing set via `providers/set`. Neither touches the on-disk
|
|
787
|
+
// credential store, so dropping these references is the whole logout for
|
|
788
|
+
// those paths.
|
|
688
789
|
this.gatewayAuthRequest = undefined;
|
|
790
|
+
this.providerConfig = undefined;
|
|
791
|
+
// Learned context windows are per-account state too: 1M-context
|
|
792
|
+
// entitlement is gated per org/tier, and an OAuth re-login is invisible to
|
|
793
|
+
// the env-derived provider cache key, so windows learned under the old
|
|
794
|
+
// login must not seed sessions under the next. Worst case of clearing is
|
|
795
|
+
// re-learning on each model's next turn.
|
|
796
|
+
contextWindowCache.clear();
|
|
689
797
|
// For the Claude/Console login methods the credentials live in the native
|
|
690
798
|
// CLI's store (keychain or config dir), which only the binary can clear.
|
|
691
799
|
// `claude auth logout` is non-interactive and idempotent.
|
|
@@ -1943,12 +2051,35 @@ export class ClaudeAcpAgent {
|
|
|
1943
2051
|
const matchingModelUsage = lastAssistantModel
|
|
1944
2052
|
? getMatchingModelUsage(message.modelUsage, lastAssistantModel)
|
|
1945
2053
|
: null;
|
|
1946
|
-
// Only overwrite when we have an authoritative value
|
|
1947
|
-
// (e.g. a turn with no top-level assistant message)
|
|
1948
|
-
//
|
|
1949
|
-
//
|
|
1950
|
-
|
|
1951
|
-
|
|
2054
|
+
// Only overwrite when we have an authoritative, sane value. A miss
|
|
2055
|
+
// (e.g. a turn with no top-level assistant message), or a
|
|
2056
|
+
// nonsensical non-positive/NaN window (observed from third-party
|
|
2057
|
+
// backends), would otherwise discard the window learned on a prior
|
|
2058
|
+
// turn and leave the next prompt's mid-stream updates reporting a
|
|
2059
|
+
// wrong size. `cacheContextWindow` applies the same `> 0` guard, so
|
|
2060
|
+
// a bad value never reaches the cross-session cache either.
|
|
2061
|
+
if (matchingModelUsage &&
|
|
2062
|
+
typeof matchingModelUsage.usage.contextWindow === "number" &&
|
|
2063
|
+
matchingModelUsage.usage.contextWindow > 0) {
|
|
2064
|
+
session.contextWindowSize = matchingModelUsage.usage.contextWindow;
|
|
2065
|
+
session.contextWindowAuthoritative = true;
|
|
2066
|
+
// Authoritative: fold it into the cross-session cache keyed on
|
|
2067
|
+
// (this session's provider, the resolved model id —
|
|
2068
|
+
// matchingModelUsage.key, e.g. "claude-sonnet-5[1m]") so a later
|
|
2069
|
+
// session/new or switch on the same provider that resolves to
|
|
2070
|
+
// this model seeds the correct window synchronously, with no
|
|
2071
|
+
// getContextUsage IPC.
|
|
2072
|
+
cacheContextWindow(contextWindowCacheKey(session.providerCacheKey, matchingModelUsage.key), matchingModelUsage.usage.contextWindow);
|
|
2073
|
+
// Also cache under the assistant message's own (bare) spelling.
|
|
2074
|
+
// Seed-time reads fall back to a picker value / verbatim live id
|
|
2075
|
+
// when a row carries no resolvedModel (the synthesized
|
|
2076
|
+
// out-of-allowlist resume row sets it undefined on purpose), and
|
|
2077
|
+
// those spellings match `.model` from the assistant message, not
|
|
2078
|
+
// the decorated modelUsage key — without this entry such rows
|
|
2079
|
+
// could never hit the cache.
|
|
2080
|
+
if (lastAssistantModel && lastAssistantModel !== matchingModelUsage.key) {
|
|
2081
|
+
cacheContextWindow(contextWindowCacheKey(session.providerCacheKey, lastAssistantModel), matchingModelUsage.usage.contextWindow);
|
|
2082
|
+
}
|
|
1952
2083
|
}
|
|
1953
2084
|
// Send usage_update notification
|
|
1954
2085
|
if (lastAssistantTotalUsage !== null) {
|
|
@@ -2191,11 +2322,16 @@ export class ClaudeAcpAgent {
|
|
|
2191
2322
|
const model = message.event.message.model;
|
|
2192
2323
|
if (model && model !== "<synthetic>") {
|
|
2193
2324
|
lastAssistantModel = model;
|
|
2194
|
-
// Only upgrade from the default — once
|
|
2195
|
-
//
|
|
2196
|
-
//
|
|
2197
|
-
// confirmed by each `result`), trust it over
|
|
2198
|
-
|
|
2325
|
+
// Only upgrade from the heuristic default — once we have an
|
|
2326
|
+
// authoritative window (cache-seeded at session creation or
|
|
2327
|
+
// on a model switch, read from the resumed session on
|
|
2328
|
+
// session/load, confirmed by each `result`), trust it over
|
|
2329
|
+
// the heuristic. The flag, not the value, is the sentinel: an
|
|
2330
|
+
// authoritative window can legitimately equal
|
|
2331
|
+
// DEFAULT_CONTEXT_WINDOW (e.g. a backend serving a 200k lane
|
|
2332
|
+
// under a "[1m]"-spelled id) and must not be clobbered.
|
|
2333
|
+
if (!session.contextWindowAuthoritative &&
|
|
2334
|
+
session.contextWindowSize === DEFAULT_CONTEXT_WINDOW) {
|
|
2199
2335
|
const inferred = inferContextWindowFromModel(model);
|
|
2200
2336
|
if (inferred !== null) {
|
|
2201
2337
|
session.contextWindowSize = inferred;
|
|
@@ -2490,7 +2626,20 @@ export class ClaudeAcpAgent {
|
|
|
2490
2626
|
_meta: {
|
|
2491
2627
|
claudeCode: {
|
|
2492
2628
|
toolName: message.tool_name,
|
|
2493
|
-
toolResponse: {
|
|
2629
|
+
toolResponse: {
|
|
2630
|
+
elapsedTimeSeconds: message.elapsed_time_seconds,
|
|
2631
|
+
// For Agent/Task calls: the subagent's type, and — when
|
|
2632
|
+
// the subagent is waiting out an API rate-limit retry —
|
|
2633
|
+
// the SDK's retry counters (attempt, max_retries,
|
|
2634
|
+
// retry_delay_ms, …), forwarded verbatim so clients can
|
|
2635
|
+
// show why a spawn looks stalled.
|
|
2636
|
+
...(message.subagent_type !== undefined && {
|
|
2637
|
+
subagentType: message.subagent_type,
|
|
2638
|
+
}),
|
|
2639
|
+
...(message.subagent_retry !== undefined && {
|
|
2640
|
+
subagentRetry: message.subagent_retry,
|
|
2641
|
+
}),
|
|
2642
|
+
},
|
|
2494
2643
|
},
|
|
2495
2644
|
},
|
|
2496
2645
|
},
|
|
@@ -3090,7 +3239,7 @@ export class ClaudeAcpAgent {
|
|
|
3090
3239
|
await this.client.sessionUpdate({ sessionId, update });
|
|
3091
3240
|
}
|
|
3092
3241
|
canUseTool(sessionId) {
|
|
3093
|
-
return async (toolName, toolInput, { signal, suggestions, toolUseID, agentID }) => {
|
|
3242
|
+
return async (toolName, toolInput, { signal, suggestions, toolUseID, agentID, matchedAskRule }) => {
|
|
3094
3243
|
const alwaysAllowLabel = describeAlwaysAllow(suggestions, toolName);
|
|
3095
3244
|
const supportsTerminalOutput = this.clientCapabilities?._meta?.["terminal_output"] === true;
|
|
3096
3245
|
const session = this.sessions[sessionId];
|
|
@@ -3198,7 +3347,14 @@ export class ClaudeAcpAgent {
|
|
|
3198
3347
|
};
|
|
3199
3348
|
}
|
|
3200
3349
|
}
|
|
3201
|
-
|
|
3350
|
+
// In bypass mode the CLI skips permission checks itself; the asks that
|
|
3351
|
+
// still reach canUseTool are the ones it insists on prompting for even
|
|
3352
|
+
// under --dangerously-skip-permissions. Keep auto-allowing those —
|
|
3353
|
+
// bypass means bypass — EXCEPT rule-forced asks (`matchedAskRule`): the
|
|
3354
|
+
// user explicitly configured a permissions.ask rule for this tool, and
|
|
3355
|
+
// the SDK's guidance is that hosts running auto-approval must treat such
|
|
3356
|
+
// asks as a human prompt. Fall through to the normal request below.
|
|
3357
|
+
if (session.modes.currentModeId === "bypassPermissions" && !matchedAskRule) {
|
|
3202
3358
|
return {
|
|
3203
3359
|
behavior: "allow",
|
|
3204
3360
|
updatedInput: toolInput,
|
|
@@ -3404,17 +3560,21 @@ export class ClaudeAcpAgent {
|
|
|
3404
3560
|
// carries no "1m" token.
|
|
3405
3561
|
const newModelInfo = session.modelInfos.find((m) => m.value === value);
|
|
3406
3562
|
if (session.models.currentModelId !== value) {
|
|
3407
|
-
//
|
|
3408
|
-
//
|
|
3409
|
-
// `
|
|
3410
|
-
//
|
|
3411
|
-
//
|
|
3412
|
-
//
|
|
3413
|
-
//
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3563
|
+
// Seed the new model's context window WITHOUT any IPC on the switch
|
|
3564
|
+
// path: cached authoritative value if we've already learned it (from a
|
|
3565
|
+
// prior turn's `result.modelUsage`), else the text heuristic, else the
|
|
3566
|
+
// default. We deliberately do NOT call `getContextUsage` here — before
|
|
3567
|
+
// a fresh session's first prompt turn that control request is not
|
|
3568
|
+
// serviced (~15s stall, issues #886/#880), and (because SDK control
|
|
3569
|
+
// requests are serialized over one channel) it would drag the awaited
|
|
3570
|
+
// `setModel` down with it. The authoritative window arrives on the
|
|
3571
|
+
// first `result.modelUsage` for the model and is cached from there;
|
|
3572
|
+
// until then a switched-to alias that has never run a turn shows the
|
|
3573
|
+
// heuristic/default window, which self-corrects on its first response
|
|
3574
|
+
// (matches pre-0.59.0 behavior).
|
|
3575
|
+
const seeded = immediateContextWindow(session.providerCacheKey, value, newModelInfo);
|
|
3576
|
+
session.contextWindowSize = seeded.size;
|
|
3577
|
+
session.contextWindowAuthoritative = seeded.authoritative;
|
|
3418
3578
|
}
|
|
3419
3579
|
session.models = { ...session.models, currentModelId: value };
|
|
3420
3580
|
// Recompute availableModes for the new model and clamp the current
|
|
@@ -3746,6 +3906,28 @@ export class ClaudeAcpAgent {
|
|
|
3746
3906
|
// below) so the TaskCreated/TaskCompleted hook callbacks can close over
|
|
3747
3907
|
// the same Map that the streaming message handler will read from.
|
|
3748
3908
|
const taskState = new Map();
|
|
3909
|
+
// The exact env the query will be created with. Built (and the provider
|
|
3910
|
+
// cache key derived from it, below) in one place so the key always
|
|
3911
|
+
// describes the backend this query actually talks to: `providers/set`,
|
|
3912
|
+
// `providers/disable`, and `logout` mutate the process-wide provider
|
|
3913
|
+
// config concurrently, so re-resolving it after any of the awaits between
|
|
3914
|
+
// here and the session registration could disagree with the env baked
|
|
3915
|
+
// into the query.
|
|
3916
|
+
const env = {
|
|
3917
|
+
...process.env,
|
|
3918
|
+
...userProvidedOptions?.env,
|
|
3919
|
+
// Client-managed LLM routing: `providers/set` config wins, else the
|
|
3920
|
+
// legacy gateway auth request. Baked into the query at creation, so it
|
|
3921
|
+
// only affects sessions started after the change (matching the RFD).
|
|
3922
|
+
...createEnvForProvider(this.resolveProviderConfig()),
|
|
3923
|
+
// Opt-in to session state events like when the agent is idle
|
|
3924
|
+
CLAUDE_CODE_EMIT_SESSION_STATE_EVENTS: "1",
|
|
3925
|
+
};
|
|
3926
|
+
// Scopes the context-window cache to this query's backend (see
|
|
3927
|
+
// `contextWindowCache`). Derived from the same `env` object handed to the
|
|
3928
|
+
// SDK, so per-session `_meta` env routing and ambient process-env routing
|
|
3929
|
+
// are distinguished exactly as the CLI will see them.
|
|
3930
|
+
const providerCacheKey = providerCacheKeyFor(env);
|
|
3749
3931
|
const options = {
|
|
3750
3932
|
systemPrompt,
|
|
3751
3933
|
settingSources: ["user", "project", "local"],
|
|
@@ -3762,13 +3944,7 @@ export class ClaudeAcpAgent {
|
|
|
3762
3944
|
...(modelConfig.availableModels && { availableModels: modelConfig.availableModels }),
|
|
3763
3945
|
},
|
|
3764
3946
|
}),
|
|
3765
|
-
env
|
|
3766
|
-
...process.env,
|
|
3767
|
-
...userProvidedOptions?.env,
|
|
3768
|
-
...createEnvForGateway(this.gatewayAuthRequest),
|
|
3769
|
-
// Opt-in to session state events like when the agent is idle
|
|
3770
|
-
CLAUDE_CODE_EMIT_SESSION_STATE_EVENTS: "1",
|
|
3771
|
-
},
|
|
3947
|
+
env,
|
|
3772
3948
|
// Override certain fields that must be controlled by ACP
|
|
3773
3949
|
cwd: params.cwd,
|
|
3774
3950
|
includePartialMessages: true,
|
|
@@ -3810,7 +3986,7 @@ export class ClaudeAcpAgent {
|
|
|
3810
3986
|
...(userProvidedOptions?.hooks?.PostToolUse || []),
|
|
3811
3987
|
{
|
|
3812
3988
|
hooks: [
|
|
3813
|
-
createPostToolUseHook(
|
|
3989
|
+
createPostToolUseHook({
|
|
3814
3990
|
onEnterPlanMode: async () => {
|
|
3815
3991
|
await this.client.sessionUpdate({
|
|
3816
3992
|
sessionId,
|
|
@@ -3916,7 +4092,7 @@ export class ClaudeAcpAgent {
|
|
|
3916
4092
|
const allowedModels = Array.isArray(settingsAvailableModels)
|
|
3917
4093
|
? applyAvailableModelsAllowlist(initializationResult.models, settingsAvailableModels, settingsModelOverrides)
|
|
3918
4094
|
: initializationResult.models;
|
|
3919
|
-
const models = await getAvailableModels(q, allowedModels, initializationResult.models, settingsManager, this.logger, creationOpts.resume !== undefined);
|
|
4095
|
+
const { modelState: models, resumedContextWindow } = await getAvailableModels(q, allowedModels, initializationResult.models, settingsManager, this.logger, creationOpts.resume !== undefined);
|
|
3920
4096
|
// Gate `auto` (and future model-specific modes) on the resolved model's
|
|
3921
4097
|
// `ModelInfo`. See `buildAvailableModes` for the canonical SDK signal.
|
|
3922
4098
|
// A resumed session can be running a model outside the `availableModels`
|
|
@@ -4012,25 +4188,39 @@ export class ClaudeAcpAgent {
|
|
|
4012
4188
|
typeof initialEffort.currentValue === "string" &&
|
|
4013
4189
|
initialEffort.currentValue !== "default") {
|
|
4014
4190
|
await q.applyFlagSettings({
|
|
4015
|
-
effortLevel: initialEffort.currentValue,
|
|
4191
|
+
effortLevel: toSdkEffortLevel(initialEffort.currentValue),
|
|
4016
4192
|
});
|
|
4017
4193
|
}
|
|
4018
|
-
// Seed the context window
|
|
4019
|
-
//
|
|
4020
|
-
//
|
|
4021
|
-
//
|
|
4022
|
-
//
|
|
4023
|
-
//
|
|
4024
|
-
//
|
|
4194
|
+
// Seed the context window WITHOUT any extra IPC on the session/new path.
|
|
4195
|
+
// On session/load, the resumed session's own `getContextUsage` report — a
|
|
4196
|
+
// response `getAvailableModels` already awaited to learn the live model
|
|
4197
|
+
// (resumed sessions ARE serviced pre-turn, unlike fresh ones) — is
|
|
4198
|
+
// authoritative and wins. Otherwise: the cached authoritative window if a
|
|
4199
|
+
// prior turn has learned it for this model (`result.modelUsage`,
|
|
4200
|
+
// cross-session), else the text heuristic, else the default. We
|
|
4201
|
+
// deliberately do NOT issue a getContextUsage call here: on a fresh
|
|
4202
|
+
// session that control request is not serviced until the first prompt
|
|
4203
|
+
// turn runs, so awaiting it — as 0.59.0 did — made session/new take ~15s
|
|
4204
|
+
// (issues #886/#880). The authoritative window arrives on the first
|
|
4205
|
+
// `result.modelUsage` and is cached from there.
|
|
4206
|
+
//
|
|
4207
|
+
// Text inference alone misses aliases that resolve to extended-context
|
|
4208
|
+
// models with no "1m" token anywhere in their id or description (e.g.
|
|
4209
|
+
// `sonnet` → claude-sonnet-5, natively ~1M): those stream
|
|
4210
|
+
// `usage_update.size: 200000` until the first result's modelUsage corrects
|
|
4211
|
+
// it — but the cache means only the FIRST session to ever run a turn on such
|
|
4212
|
+
// a model eats that window, not every fresh session after a process
|
|
4213
|
+
// restart (issue #596; a post-restart session/load is covered by the
|
|
4214
|
+
// resumed report above).
|
|
4025
4215
|
//
|
|
4026
4216
|
// The inference fallback is deliberately keyed to the allowlisted entry: a
|
|
4027
4217
|
// fallback-resolved sibling's resolvedModel/displayName/description can
|
|
4028
4218
|
// describe a different context lane than the verbatim live id (e.g. an
|
|
4029
4219
|
// "opus[1m]" row matched for a bare 200k id), so on the fallback path only
|
|
4030
4220
|
// the id itself is a trustworthy window signal.
|
|
4031
|
-
const
|
|
4032
|
-
|
|
4033
|
-
|
|
4221
|
+
const seededWindow = resumedContextWindow !== null
|
|
4222
|
+
? { size: resumedContextWindow, authoritative: true }
|
|
4223
|
+
: immediateContextWindow(providerCacheKey, models.currentModelId, allowlistedModelInfo);
|
|
4034
4224
|
this.sessions[sessionId] = {
|
|
4035
4225
|
query: q,
|
|
4036
4226
|
input: input,
|
|
@@ -4053,7 +4243,9 @@ export class ClaudeAcpAgent {
|
|
|
4053
4243
|
fastModeEnabled,
|
|
4054
4244
|
abortController,
|
|
4055
4245
|
emitRawSDKMessages: sessionMeta?.claudeCode?.emitRawSDKMessages ?? false,
|
|
4056
|
-
contextWindowSize,
|
|
4246
|
+
contextWindowSize: seededWindow.size,
|
|
4247
|
+
contextWindowAuthoritative: seededWindow.authoritative,
|
|
4248
|
+
providerCacheKey,
|
|
4057
4249
|
taskState,
|
|
4058
4250
|
toolUseCache: {},
|
|
4059
4251
|
emittedToolCalls: new Set(),
|
|
@@ -4129,27 +4321,76 @@ function snapshotFromUsage(usage) {
|
|
|
4129
4321
|
cache_creation_input_tokens: usage.cache_creation_input_tokens ?? 0,
|
|
4130
4322
|
};
|
|
4131
4323
|
}
|
|
4132
|
-
|
|
4324
|
+
/**
|
|
4325
|
+
* Adapt a legacy gateway `authenticate` request into the shared
|
|
4326
|
+
* {@link ProviderConfig} shape. Returns `null` when no gateway request is
|
|
4327
|
+
* present. `methodId` selects the protocol: `gateway-bedrock` → bedrock,
|
|
4328
|
+
* otherwise anthropic.
|
|
4329
|
+
*/
|
|
4330
|
+
function gatewayRequestToProviderConfig(request) {
|
|
4133
4331
|
if (!request?._meta) {
|
|
4332
|
+
return null;
|
|
4333
|
+
}
|
|
4334
|
+
return {
|
|
4335
|
+
apiType: request.methodId === "gateway-bedrock" ? "bedrock" : "anthropic",
|
|
4336
|
+
baseUrl: request._meta.gateway.baseUrl,
|
|
4337
|
+
headers: request._meta.gateway.headers,
|
|
4338
|
+
};
|
|
4339
|
+
}
|
|
4340
|
+
/**
|
|
4341
|
+
* Map a resolved provider config into the Claude Code env vars that redirect API
|
|
4342
|
+
* traffic and inject headers. Returns an empty object when routing is
|
|
4343
|
+
* unconfigured. The token/bypass placeholders (`" "`) are required so the CLI
|
|
4344
|
+
* skips its normal login/credential checks when a gateway is in use.
|
|
4345
|
+
*/
|
|
4346
|
+
function createEnvForProvider(config) {
|
|
4347
|
+
if (!config) {
|
|
4134
4348
|
return {};
|
|
4135
4349
|
}
|
|
4136
|
-
const customHeaders = Object.entries(
|
|
4350
|
+
const customHeaders = Object.entries(config.headers)
|
|
4137
4351
|
.map(([key, value]) => `${key}: ${value}`)
|
|
4138
4352
|
.join("\n");
|
|
4139
|
-
if (
|
|
4353
|
+
if (config.apiType === "bedrock") {
|
|
4140
4354
|
return {
|
|
4141
4355
|
CLAUDE_CODE_USE_BEDROCK: "1",
|
|
4142
4356
|
AWS_BEARER_TOKEN_BEDROCK: " ", // Must be non-empty to bypass pass configuration check
|
|
4143
|
-
ANTHROPIC_BEDROCK_BASE_URL:
|
|
4357
|
+
ANTHROPIC_BEDROCK_BASE_URL: config.baseUrl,
|
|
4358
|
+
ANTHROPIC_CUSTOM_HEADERS: customHeaders,
|
|
4359
|
+
};
|
|
4360
|
+
}
|
|
4361
|
+
if (config.apiType === "vertex") {
|
|
4362
|
+
// `config.vertex` is guaranteed present for vertex by `unstable_setProvider`
|
|
4363
|
+
// validation; fall back to empty strings defensively.
|
|
4364
|
+
return {
|
|
4365
|
+
CLAUDE_CODE_USE_VERTEX: "1",
|
|
4366
|
+
ANTHROPIC_VERTEX_BASE_URL: config.baseUrl,
|
|
4367
|
+
ANTHROPIC_VERTEX_PROJECT_ID: config.vertex?.projectId ?? "",
|
|
4368
|
+
CLOUD_ML_REGION: config.vertex?.region ?? "",
|
|
4144
4369
|
ANTHROPIC_CUSTOM_HEADERS: customHeaders,
|
|
4145
4370
|
};
|
|
4146
4371
|
}
|
|
4147
4372
|
return {
|
|
4148
|
-
ANTHROPIC_BASE_URL:
|
|
4373
|
+
ANTHROPIC_BASE_URL: config.baseUrl,
|
|
4149
4374
|
ANTHROPIC_CUSTOM_HEADERS: customHeaders,
|
|
4150
4375
|
ANTHROPIC_AUTH_TOKEN: " ", // Must be specified to bypass claude login requirement
|
|
4151
4376
|
};
|
|
4152
4377
|
}
|
|
4378
|
+
/**
|
|
4379
|
+
* Validate a provider base URL: must be a non-empty absolute http(s) URL.
|
|
4380
|
+
*/
|
|
4381
|
+
function isValidBaseUrl(baseUrl) {
|
|
4382
|
+
if (typeof baseUrl !== "string" || baseUrl.trim() === "") {
|
|
4383
|
+
return false;
|
|
4384
|
+
}
|
|
4385
|
+
let parsed;
|
|
4386
|
+
try {
|
|
4387
|
+
parsed = new URL(baseUrl);
|
|
4388
|
+
}
|
|
4389
|
+
catch {
|
|
4390
|
+
return false;
|
|
4391
|
+
}
|
|
4392
|
+
return parsed.protocol === "http:" || parsed.protocol === "https:";
|
|
4393
|
+
}
|
|
4153
4394
|
/**
|
|
4154
4395
|
* Build the list of permission modes the agent will advertise for the given
|
|
4155
4396
|
* model. `auto` is gated by `ModelInfo.supportsAutoMode === true`, which is
|
|
@@ -4199,7 +4440,10 @@ function buildAvailableModes(modelInfo) {
|
|
|
4199
4440
|
// and only clears a key when an explicit `null` is sent — see
|
|
4200
4441
|
// `applyFlagSettings` in @anthropic-ai/claude-agent-sdk. Mapping both the
|
|
4201
4442
|
// `"default"` sentinel and `undefined` (effort option absent for the model) to
|
|
4202
|
-
// `null` ensures any previously-applied flag is actually cleared.
|
|
4443
|
+
// `null` ensures any previously-applied flag is actually cleared. Typed as
|
|
4444
|
+
// `EffortLevel` (not `Settings["effortLevel"]`): the picker offers whatever
|
|
4445
|
+
// `supportedEffortLevels` reports, which includes the session-scoped `"max"`
|
|
4446
|
+
// that the persisted Settings shape deliberately excludes.
|
|
4203
4447
|
function toSdkEffortLevel(value) {
|
|
4204
4448
|
return value === undefined || value === "default" ? null : value;
|
|
4205
4449
|
}
|
|
@@ -4651,23 +4895,37 @@ export function applyAvailableModelsAllowlist(sdkModels, allowlist, settingsMode
|
|
|
4651
4895
|
}
|
|
4652
4896
|
/** Read the model a resumed session is actually running (via the
|
|
4653
4897
|
* `getContextUsage` control request — the same source `/context` prints) and
|
|
4654
|
-
* map it onto the picker
|
|
4655
|
-
*
|
|
4656
|
-
*
|
|
4898
|
+
* map it onto the picker, along with the report's authoritative context
|
|
4899
|
+
* window (`rawMaxTokens`). Resumed sessions get this request serviced before
|
|
4900
|
+
* any turn runs in the new process — unlike fresh sessions, where it stalls
|
|
4901
|
+
* until the first prompt turn (issues #886/#880) — so the same response that
|
|
4902
|
+
* restores the live model (issue #845) also seeds the window for free,
|
|
4903
|
+
* covering post-restart reloads of models the text heuristic misses (issue
|
|
4904
|
+
* #596). Best-effort: a control-request failure is logged and returns nulls
|
|
4905
|
+
* so callers keep their current choice; failing the whole session/load over
|
|
4906
|
+
* an unreadable report would be worse. */
|
|
4657
4907
|
async function readResumedLiveModel(query, models, logger) {
|
|
4658
4908
|
try {
|
|
4659
|
-
const
|
|
4660
|
-
return
|
|
4909
|
+
const usage = await query.getContextUsage();
|
|
4910
|
+
return {
|
|
4911
|
+
model: usage.model ? matchResumedModel(models, usage.model) : null,
|
|
4912
|
+
contextWindow: usage.rawMaxTokens > 0 ? usage.rawMaxTokens : null,
|
|
4913
|
+
};
|
|
4661
4914
|
}
|
|
4662
4915
|
catch (error) {
|
|
4663
4916
|
logger.error("Failed to read the resumed session's live model:", error);
|
|
4664
|
-
return null;
|
|
4917
|
+
return { model: null, contextWindow: null };
|
|
4665
4918
|
}
|
|
4666
4919
|
}
|
|
4667
4920
|
async function getAvailableModels(query, models, sdkModels, settingsManager, logger, isResumedSession) {
|
|
4668
4921
|
const settings = settingsManager.getSettings();
|
|
4669
4922
|
let currentModel = models[0];
|
|
4670
4923
|
let resolvedFromInput;
|
|
4924
|
+
// The context window reported alongside a resumed session's live model.
|
|
4925
|
+
// Only ever non-null on the paths where `currentModel` IS the live model
|
|
4926
|
+
// (no override, or a failed override re-assert), so the window always
|
|
4927
|
+
// describes the model the session actually runs.
|
|
4928
|
+
let resumedContextWindow = null;
|
|
4671
4929
|
// Model priority (highest to lowest):
|
|
4672
4930
|
// 1. ANTHROPIC_MODEL environment variable
|
|
4673
4931
|
// 2. settings.model (user configuration)
|
|
@@ -4695,7 +4953,9 @@ async function getAvailableModels(query, models, sdkModels, settingsManager, log
|
|
|
4695
4953
|
// the SDK is already running this model, and pushing a picker alias back
|
|
4696
4954
|
// (e.g. "opus[1m]") could change the live model rather than describe it.
|
|
4697
4955
|
if (resolvedFromInput === undefined && isResumedSession) {
|
|
4698
|
-
|
|
4956
|
+
const live = await readResumedLiveModel(query, models, logger);
|
|
4957
|
+
currentModel = live.model ?? currentModel;
|
|
4958
|
+
resumedContextWindow = live.contextWindow;
|
|
4699
4959
|
}
|
|
4700
4960
|
// Skip the setModel round-trip when we can prove the SDK has already landed
|
|
4701
4961
|
// on the same model. Two cases qualify:
|
|
@@ -4728,16 +4988,21 @@ async function getAvailableModels(query, models, sdkModels, settingsManager, log
|
|
|
4728
4988
|
if (!isResumedSession)
|
|
4729
4989
|
throw error;
|
|
4730
4990
|
logger.error(`Failed to re-assert model "${currentModel.value}" on resume:`, error);
|
|
4731
|
-
|
|
4991
|
+
const live = await readResumedLiveModel(query, models, logger);
|
|
4992
|
+
currentModel = live.model ?? currentModel;
|
|
4993
|
+
resumedContextWindow = live.contextWindow;
|
|
4732
4994
|
}
|
|
4733
4995
|
}
|
|
4734
4996
|
return {
|
|
4735
|
-
|
|
4736
|
-
|
|
4737
|
-
|
|
4738
|
-
|
|
4739
|
-
|
|
4740
|
-
|
|
4997
|
+
modelState: {
|
|
4998
|
+
availableModels: models.map((model) => ({
|
|
4999
|
+
modelId: model.value,
|
|
5000
|
+
name: model.displayName,
|
|
5001
|
+
description: model.description,
|
|
5002
|
+
})),
|
|
5003
|
+
currentModelId: currentModel.value,
|
|
5004
|
+
},
|
|
5005
|
+
resumedContextWindow,
|
|
4741
5006
|
};
|
|
4742
5007
|
}
|
|
4743
5008
|
function getAvailableSlashCommands(commands) {
|
|
@@ -4864,6 +5129,12 @@ export function promptToClaude(prompt) {
|
|
|
4864
5129
|
},
|
|
4865
5130
|
session_id: prompt.sessionId,
|
|
4866
5131
|
parent_tool_use_id: null,
|
|
5132
|
+
// ACP prompts are the user's own input relayed by the client. Stamp the
|
|
5133
|
+
// provenance explicitly: per the SDK, a host wrapping keyboard input must
|
|
5134
|
+
// send `{kind: "human"}` — an absent `origin` is treated as unattributed
|
|
5135
|
+
// and fails closed at the CLI's strict isHuman() trust gates (e.g. the
|
|
5136
|
+
// ultracode keyword opt-in honors only human-originated turns).
|
|
5137
|
+
origin: { kind: "human" },
|
|
4867
5138
|
};
|
|
4868
5139
|
}
|
|
4869
5140
|
/**
|
|
@@ -5463,6 +5734,9 @@ export function runAcp() {
|
|
|
5463
5734
|
.onRequest(methods.agent.session.setMode, (ctx) => agent.setSessionMode(ctx.params))
|
|
5464
5735
|
.onRequest(methods.agent.session.setConfigOption, (ctx) => agent.setSessionConfigOption(ctx.params))
|
|
5465
5736
|
.onRequest(methods.agent.authenticate, (ctx) => agent.authenticate(ctx.params))
|
|
5737
|
+
.onRequest(methods.agent.providers.list, (ctx) => agent.unstable_listProviders(ctx.params))
|
|
5738
|
+
.onRequest(methods.agent.providers.set, (ctx) => agent.unstable_setProvider(ctx.params))
|
|
5739
|
+
.onRequest(methods.agent.providers.disable, (ctx) => agent.unstable_disableProvider(ctx.params))
|
|
5466
5740
|
.onRequest(methods.agent.logout, (ctx) => agent.logout(ctx.params))
|
|
5467
5741
|
.onRequest(methods.agent.session.prompt, (ctx) => runPromptWithCancellation(agent, ctx.params, ctx.signal))
|
|
5468
5742
|
.onNotification(methods.agent.session.cancel, (ctx) => agent.cancel(ctx.params))
|
|
@@ -5477,9 +5751,9 @@ function commonPrefixLength(a, b) {
|
|
|
5477
5751
|
}
|
|
5478
5752
|
return i;
|
|
5479
5753
|
}
|
|
5480
|
-
/** Best-effort first guess of a model's context window, used
|
|
5481
|
-
*
|
|
5482
|
-
*
|
|
5754
|
+
/** Best-effort first guess of a model's context window, used to seed the
|
|
5755
|
+
* window synchronously (via `immediateContextWindow`) until a `result` message
|
|
5756
|
+
* arrives with the authoritative `modelUsage` value.
|
|
5483
5757
|
*
|
|
5484
5758
|
* Anthropic 1M-context variants encode "1m" as a distinct token in the SDK
|
|
5485
5759
|
* model ID (e.g., "claude-opus-4-6-1m"), which `\b1m\b` catches without also
|
|
@@ -5489,9 +5763,12 @@ function commonPrefixLength(a, b) {
|
|
|
5489
5763
|
* "claude-opus-4-8[1m]", "Opus 4.7 (1M context)"), so callers pass those too.
|
|
5490
5764
|
* This text scan can't catch every model — some resolve to extended-context
|
|
5491
5765
|
* models with no "1m" anywhere (e.g. `sonnet` → claude-sonnet-5, natively
|
|
5492
|
-
* ~1M)
|
|
5493
|
-
*
|
|
5494
|
-
*
|
|
5766
|
+
* ~1M). Such a miss falls back to the default window and is corrected by
|
|
5767
|
+
* `result.modelUsage` (and cached) within one turn. We do NOT consult the
|
|
5768
|
+
* SDK's `getContextUsage` to close that gap: on a fresh session it is not
|
|
5769
|
+
* serviced before the first prompt turn (issues #886/#880, see
|
|
5770
|
+
* `contextWindowCache`; resumed sessions do get it, via
|
|
5771
|
+
* `readResumedLiveModel`). */
|
|
5495
5772
|
function inferContextWindowFromModel(...texts) {
|
|
5496
5773
|
if (texts.some((text) => text != null && /\b1m\b/i.test(text)))
|
|
5497
5774
|
return 1_000_000;
|
|
@@ -5512,28 +5789,95 @@ async function fetchContextUsedTokens(query, logger) {
|
|
|
5512
5789
|
return null;
|
|
5513
5790
|
}
|
|
5514
5791
|
}
|
|
5515
|
-
/**
|
|
5516
|
-
* `
|
|
5517
|
-
*
|
|
5518
|
-
*
|
|
5519
|
-
*
|
|
5520
|
-
*
|
|
5521
|
-
*
|
|
5792
|
+
/** Cross-session cache of authoritative context windows, keyed by
|
|
5793
|
+
* `${providerCacheKey}\0${modelId}` (see {@link contextWindowCacheKey}).
|
|
5794
|
+
* The window is a property of (model id, backend): the same resolved model id
|
|
5795
|
+
* (e.g. "claude-sonnet-5[1m]", the spelling of the `result.modelUsage` keys)
|
|
5796
|
+
* can name different context lanes behind different base URLs, routing
|
|
5797
|
+
* headers, or credentials, so the key carries both. Caching it module-level
|
|
5798
|
+
* lets a later session/new or switch that resolves to the same (backend,
|
|
5799
|
+
* model) — in this session or any other, within the adapter's lifetime — seed
|
|
5800
|
+
* the correct window synchronously with no IPC. Keying on the resolved id
|
|
5801
|
+
* (rather than the picker value) means aliases that resolve to the same
|
|
5802
|
+
* concrete model share one entry; the result handler additionally writes the
|
|
5803
|
+
* bare assistant-message spelling so seed-time reads that fall back to a
|
|
5804
|
+
* verbatim live id (rows without `resolvedModel`) can hit too.
|
|
5522
5805
|
*
|
|
5523
|
-
*
|
|
5524
|
-
*
|
|
5525
|
-
*
|
|
5526
|
-
*
|
|
5527
|
-
|
|
5528
|
-
|
|
5529
|
-
|
|
5530
|
-
|
|
5531
|
-
|
|
5532
|
-
|
|
5533
|
-
|
|
5534
|
-
|
|
5806
|
+
* Populated authoritatively by each `result.modelUsage` a turn confirms (see
|
|
5807
|
+
* the consumer's result handler). We deliberately never populate it from a
|
|
5808
|
+
* fresh session's `getContextUsage`: before that session's first prompt turn
|
|
5809
|
+
* has run the control request is not serviced (it stalls ~15s, and serializes
|
|
5810
|
+
* ahead of an awaited `setModel` — issues #886/#880, regressed in 0.59.0), so
|
|
5811
|
+
* it can neither beat the first `result` nor be issued cheaply before one.
|
|
5812
|
+
* Resumed sessions are the exception — their report IS serviced pre-turn, and
|
|
5813
|
+
* the session/load path seeds (but does not cache) the window from the same
|
|
5814
|
+
* response that restores the live model, see `readResumedLiveModel`.
|
|
5815
|
+
* Cleared on `logout`: 1M-context entitlement can differ per account/tier, so
|
|
5816
|
+
* windows learned under one login must not seed sessions under the next. */
|
|
5817
|
+
const contextWindowCache = new Map();
|
|
5818
|
+
/** The env vars that determine which LLM backend — and which context lane on
|
|
5819
|
+
* it — a query's API traffic reaches: endpoint selection (base URLs and the
|
|
5820
|
+
* Bedrock/Vertex switches with their project/region), routing/beta headers
|
|
5821
|
+
* (an `anthropic-beta: context-1m-…` header flips the same model id at the
|
|
5822
|
+
* same endpoint between context lanes), and credential identity (extended
|
|
5823
|
+
* context is entitlement-gated per account). Used to derive the
|
|
5824
|
+
* provider-cache key from the exact env a query is created with, so
|
|
5825
|
+
* `providers/set` config, per-session `_meta` env overrides, and ambient
|
|
5826
|
+
* process env are all distinguished exactly as the CLI will see them. */
|
|
5827
|
+
const PROVIDER_ROUTING_ENV_VARS = [
|
|
5828
|
+
"ANTHROPIC_BASE_URL",
|
|
5829
|
+
"ANTHROPIC_BEDROCK_BASE_URL",
|
|
5830
|
+
"ANTHROPIC_VERTEX_BASE_URL",
|
|
5831
|
+
"CLAUDE_CODE_USE_BEDROCK",
|
|
5832
|
+
"CLAUDE_CODE_USE_VERTEX",
|
|
5833
|
+
"ANTHROPIC_VERTEX_PROJECT_ID",
|
|
5834
|
+
"CLOUD_ML_REGION",
|
|
5835
|
+
"AWS_REGION",
|
|
5836
|
+
"ANTHROPIC_CUSTOM_HEADERS",
|
|
5837
|
+
"ANTHROPIC_API_KEY",
|
|
5838
|
+
"ANTHROPIC_AUTH_TOKEN",
|
|
5839
|
+
];
|
|
5840
|
+
/** Stable identifier for the LLM backend a session's query is created against,
|
|
5841
|
+
* used to scope {@link contextWindowCache} per backend. Positional `\0`-join
|
|
5842
|
+
* of {@link PROVIDER_ROUTING_ENV_VARS} values, so no segment can masquerade
|
|
5843
|
+
* as another and unset vars everywhere yield one stable "default" bucket.
|
|
5844
|
+
* Header/credential values can be secrets; the key only ever lives as an
|
|
5845
|
+
* in-memory Map key and is never logged or surfaced. Over-keying is the safe
|
|
5846
|
+
* side: a var change that didn't really change the backend costs one cache
|
|
5847
|
+
* miss (heuristic seed until the next result), while under-keying would serve
|
|
5848
|
+
* one backend's window for another's. */
|
|
5849
|
+
function providerCacheKeyFor(env) {
|
|
5850
|
+
return PROVIDER_ROUTING_ENV_VARS.map((name) => env[name] ?? "").join("\0");
|
|
5851
|
+
}
|
|
5852
|
+
/** Compose the `contextWindowCache` key from a session's provider key and a
|
|
5853
|
+
* model id. `\0`-joined so the model segment can't collide with a provider
|
|
5854
|
+
* segment. */
|
|
5855
|
+
function contextWindowCacheKey(providerCacheKey, modelId) {
|
|
5856
|
+
return `${providerCacheKey}\0${modelId}`;
|
|
5857
|
+
}
|
|
5858
|
+
function cacheContextWindow(modelKey, window) {
|
|
5859
|
+
if (window > 0) {
|
|
5860
|
+
contextWindowCache.set(modelKey, window);
|
|
5535
5861
|
}
|
|
5536
5862
|
}
|
|
5863
|
+
/** The context window to report *right now* for a model, with NO IPC on the
|
|
5864
|
+
* critical path: the cached authoritative value if we've learned it (from a
|
|
5865
|
+
* prior turn's `result.modelUsage`, this or any session on the same backend),
|
|
5866
|
+
* else the text heuristic over the model row's identity strings, else the
|
|
5867
|
+
* default. Derives the cache key itself — `modelInfo?.resolvedModel ?? modelId`,
|
|
5868
|
+
* the same rule at every seed site — so read keys can't drift from the write
|
|
5869
|
+
* site's spelling. `authoritative` reports whether the value came from the
|
|
5870
|
+
* cache: an authoritative window can legitimately equal
|
|
5871
|
+
* DEFAULT_CONTEXT_WINDOW, so the value alone can't tell the caller. */
|
|
5872
|
+
function immediateContextWindow(providerCacheKey, modelId, modelInfo) {
|
|
5873
|
+
const cached = contextWindowCache.get(contextWindowCacheKey(providerCacheKey, modelInfo?.resolvedModel ?? modelId));
|
|
5874
|
+
if (cached !== undefined)
|
|
5875
|
+
return { size: cached, authoritative: true };
|
|
5876
|
+
return {
|
|
5877
|
+
size: inferContextWindowFromModel(modelId, modelInfo?.resolvedModel, modelInfo?.displayName, modelInfo?.description) ?? DEFAULT_CONTEXT_WINDOW,
|
|
5878
|
+
authoritative: false,
|
|
5879
|
+
};
|
|
5880
|
+
}
|
|
5537
5881
|
/** Translate the legacy `MAX_THINKING_TOKENS` env var into the SDK's `thinking`
|
|
5538
5882
|
* option. The `maxThinkingTokens` option it used to feed is deprecated and
|
|
5539
5883
|
* reduced to on/off on current models, so map the value to explicit thinking
|
|
@@ -5575,6 +5919,12 @@ function getMatchingModelUsage(modelUsage, currentModel) {
|
|
|
5575
5919
|
}
|
|
5576
5920
|
}
|
|
5577
5921
|
if (bestKey) {
|
|
5578
|
-
|
|
5922
|
+
// `bestKey` is the SDK's resolved model id (e.g. "claude-sonnet-5[1m]"),
|
|
5923
|
+
// the same spelling as ModelInfo.resolvedModel — the primary key the
|
|
5924
|
+
// window is cached under. `currentModel` (the assistant message's
|
|
5925
|
+
// `.model`) can be the bare form (e.g. "claude-sonnet-5"); the result
|
|
5926
|
+
// handler caches under that spelling too, for seed-time reads that fall
|
|
5927
|
+
// back to a bare id (rows without `resolvedModel`).
|
|
5928
|
+
return { key: bestKey, usage: modelUsage[bestKey] };
|
|
5579
5929
|
}
|
|
5580
5930
|
}
|
package/dist/tools.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { HookCallback } from "@anthropic-ai/claude-agent-sdk";
|
|
|
3
3
|
import { TaskCreateInput, TaskCreateOutput, TaskUpdateInput } from "@anthropic-ai/claude-agent-sdk/sdk-tools.js";
|
|
4
4
|
import { ToolResultBlockParam, WebSearchToolResultBlockParam } from "@anthropic-ai/sdk/resources";
|
|
5
5
|
import { BetaBashCodeExecutionToolResultBlockParam, BetaCodeExecutionToolResultBlockParam, BetaRequestMCPToolResultBlockParam, BetaTextEditorCodeExecutionToolResultBlockParam, BetaToolResultBlockParam, BetaToolSearchToolResultBlockParam, BetaWebFetchToolResultBlockParam, BetaWebSearchToolResultBlockParam } from "@anthropic-ai/sdk/resources/beta.mjs";
|
|
6
|
-
import { Logger } from "./acp-agent.js";
|
|
7
6
|
interface ToolInfo {
|
|
8
7
|
title: string;
|
|
9
8
|
kind: ToolKind;
|
|
@@ -82,7 +81,7 @@ export declare function toolUpdateFromDiffToolResponse(toolResponse: unknown): {
|
|
|
82
81
|
export declare const registerHookCallback: (toolUseID: string, { onPostToolUseHook, }: {
|
|
83
82
|
onPostToolUseHook?: (toolUseID: string, toolInput: unknown, toolResponse: unknown) => Promise<void>;
|
|
84
83
|
}) => void;
|
|
85
|
-
export declare const createPostToolUseHook: (
|
|
84
|
+
export declare const createPostToolUseHook: (options?: {
|
|
86
85
|
onEnterPlanMode?: () => Promise<void>;
|
|
87
86
|
}) => HookCallback;
|
|
88
87
|
/**
|
package/dist/tools.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,QAAQ,EACT,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAaL,eAAe,EACf,gBAAgB,EAChB,eAAe,EAKhB,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAGL,oBAAoB,EAEpB,6BAA6B,EAE9B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAEL,yCAAyC,EAGzC,qCAAqC,EAGrC,kCAAkC,EAGlC,+CAA+C,EAI/C,wBAAwB,EACxB,kCAAkC,EAIlC,gCAAgC,EAEhC,iCAAiC,EAClC,MAAM,sCAAsC,CAAC;
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,QAAQ,EACT,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAaL,eAAe,EACf,gBAAgB,EAChB,eAAe,EAKhB,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAGL,oBAAoB,EAEpB,6BAA6B,EAE9B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EA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S,CAAC,EAAE,gBAAgB,EAAE,CAAC;CAChC,CAoCA;AAcD,eAAO,MAAM,oBAAoB,GAC/B,WAAW,MAAM,EACjB,wBAEG;IACD,iBAAiB,CAAC,EAAE,CAClB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,OAAO,EAClB,YAAY,EAAE,OAAO,KAClB,OAAO,CAAC,IAAI,CAAC,CAAC;CACpB,SAKF,CAAC;AAGF,eAAO,MAAM,qBAAqB,GAC/B,UAAU;IAAE,eAAe,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,KAAG,YAiBtD,CAAC;AAEJ;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,GACxB,SAAS;IAAE,SAAS,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,KAAG,YAsBpE,CAAC"}
|
package/dist/tools.js
CHANGED
|
@@ -362,9 +362,38 @@ function structuredResult(toolUseResult) {
|
|
|
362
362
|
* matching rather than mangle the report.
|
|
363
363
|
*/
|
|
364
364
|
function stripAgentTrailer(text) {
|
|
365
|
-
return text
|
|
366
|
-
|
|
367
|
-
|
|
365
|
+
return stripAgentIdLine(stripUsageBlock(text));
|
|
366
|
+
}
|
|
367
|
+
const USAGE_OPEN = "<usage>";
|
|
368
|
+
const USAGE_CLOSE = "</usage>";
|
|
369
|
+
/** Remove a trailing `<usage>…</usage>` block, plus trailing whitespace and
|
|
370
|
+
* one preceding newline. Matches from the *last* `<usage>` so a report that
|
|
371
|
+
* merely mentions the marker earlier isn't truncated at the mention. */
|
|
372
|
+
function stripUsageBlock(text) {
|
|
373
|
+
const body = text.trimEnd();
|
|
374
|
+
if (!body.endsWith(USAGE_CLOSE)) {
|
|
375
|
+
return text;
|
|
376
|
+
}
|
|
377
|
+
const open = body.lastIndexOf(USAGE_OPEN, body.length - USAGE_CLOSE.length - USAGE_OPEN.length);
|
|
378
|
+
if (open === -1) {
|
|
379
|
+
return text;
|
|
380
|
+
}
|
|
381
|
+
return body.slice(0, open > 0 && body[open - 1] === "\n" ? open - 1 : open);
|
|
382
|
+
}
|
|
383
|
+
/** The continuation line, anchored to a whole line so the regex has a single
|
|
384
|
+
* start position and no ambiguous repetition (`[\w-]+` can't consume the
|
|
385
|
+
* following space, `[^)]*` can't consume the closing paren) — it runs in
|
|
386
|
+
* linear time on any input. */
|
|
387
|
+
const AGENT_ID_LINE = /^agentId: [\w-]+ \([^)]*\)$/;
|
|
388
|
+
/** Remove a final `agentId: <id> (…)` line, plus trailing whitespace and the
|
|
389
|
+
* newline that preceded the line. */
|
|
390
|
+
function stripAgentIdLine(text) {
|
|
391
|
+
const body = text.trimEnd();
|
|
392
|
+
const lineStart = body.lastIndexOf("\n") + 1;
|
|
393
|
+
if (!AGENT_ID_LINE.test(body.slice(lineStart))) {
|
|
394
|
+
return text;
|
|
395
|
+
}
|
|
396
|
+
return body.slice(0, Math.max(lineStart - 1, 0));
|
|
368
397
|
}
|
|
369
398
|
/** Apply {@link stripAgentTrailer} across a raw tool_result `content` (plain
|
|
370
399
|
* string or block array), leaving non-text blocks untouched. */
|
|
@@ -898,7 +927,7 @@ export const registerHookCallback = (toolUseID, { onPostToolUseHook, }) => {
|
|
|
898
927
|
};
|
|
899
928
|
};
|
|
900
929
|
/* A callback for Claude Code that is called when receiving a PostToolUse hook */
|
|
901
|
-
export const createPostToolUseHook = (
|
|
930
|
+
export const createPostToolUseHook = (options) => async (input, toolUseID) => {
|
|
902
931
|
if (input.hook_event_name === "PostToolUse") {
|
|
903
932
|
// Handle EnterPlanMode tool - notify client of mode change after successful execution
|
|
904
933
|
if (input.tool_name === "EnterPlanMode" && options?.onEnterPlanMode) {
|
|
@@ -908,12 +937,8 @@ export const createPostToolUseHook = (logger = console, options) => async (input
|
|
|
908
937
|
const onPostToolUseHook = toolUseCallbacks[toolUseID]?.onPostToolUseHook;
|
|
909
938
|
if (onPostToolUseHook) {
|
|
910
939
|
await onPostToolUseHook(toolUseID, input.tool_input, input.tool_response);
|
|
911
|
-
delete toolUseCallbacks[toolUseID]; // Cleanup after execution
|
|
912
|
-
}
|
|
913
|
-
else {
|
|
914
|
-
logger.error(`No onPostToolUseHook found for tool use ID: ${toolUseID}`);
|
|
915
|
-
delete toolUseCallbacks[toolUseID];
|
|
916
940
|
}
|
|
941
|
+
delete toolUseCallbacks[toolUseID]; // Cleanup after execution
|
|
917
942
|
}
|
|
918
943
|
}
|
|
919
944
|
return { continue: true };
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.60.0",
|
|
7
7
|
"description": "An ACP-compatible coding agent powered by the Claude Agent SDK (TypeScript)",
|
|
8
8
|
"main": "dist/lib.js",
|
|
9
9
|
"types": "dist/lib.d.ts",
|
|
@@ -64,16 +64,16 @@
|
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
66
|
"@agentclientprotocol/sdk": "1.2.1",
|
|
67
|
-
"@anthropic-ai/claude-agent-sdk": "0.3.
|
|
67
|
+
"@anthropic-ai/claude-agent-sdk": "0.3.215",
|
|
68
68
|
"zod": "^3.25.0 || ^4.0.0"
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
|
-
"@anthropic-ai/sdk": "0.
|
|
71
|
+
"@anthropic-ai/sdk": "0.112.3",
|
|
72
72
|
"@eslint/js": "10.0.1",
|
|
73
73
|
"@tsconfig/node22": "22.0.5",
|
|
74
74
|
"@types/node": "26.1.1",
|
|
75
|
-
"@typescript-eslint/eslint-plugin": "8.
|
|
76
|
-
"@typescript-eslint/parser": "8.
|
|
75
|
+
"@typescript-eslint/eslint-plugin": "8.64.0",
|
|
76
|
+
"@typescript-eslint/parser": "8.64.0",
|
|
77
77
|
"eslint": "10.7.0",
|
|
78
78
|
"eslint-config-prettier": "10.1.8",
|
|
79
79
|
"globals": "17.7.0",
|