@opencow-ai/opencow-agent-sdk 0.4.26 → 0.4.28
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/capabilities/mcp/types.d.ts +3 -0
- package/dist/capabilities/plugins/pluginOptionsStorage.d.ts +6 -0
- package/dist/capabilities/plugins/schemas.d.ts +6 -0
- package/dist/capabilities/plugins/sdkPluginRuntime.d.ts +2 -0
- package/dist/cli.mjs +228 -241
- package/dist/client.js +288 -257
- package/dist/constants/oauth.d.ts +0 -8
- package/dist/controller/compact/compact.d.ts +8 -2
- package/dist/controller/dispatch/toolHooks.d.ts +4 -3
- package/dist/controller/loop.d.ts +2 -1
- package/dist/entrypoints/sdk/controlSchemas.d.ts +25 -0
- package/dist/entrypoints/sdk/coreSchemas.d.ts +16 -0
- package/dist/entrypoints/sdk/runtimeTypes.d.ts +21 -0
- package/dist/providers/shared/retry.d.ts +13 -1
- package/dist/sdk.js +288 -257
- package/dist/session/branding.d.ts +4 -0
- package/dist/session/brandingConfig.d.ts +16 -0
- package/dist/session/contextSnapshot.d.ts +14 -0
- package/dist/session/state/index.d.ts +1 -1
- package/dist/session/state/registries.d.ts +8 -1
- package/dist/session/state/types.d.ts +2 -0
- package/dist/types/contextSnapshot.d.ts +17 -0
- package/package.json +1 -1
- package/dist/capabilities/tools/AgentTool/built-in/claudeCodeGuideAgent.d.ts +0 -3
package/dist/client.js
CHANGED
|
@@ -19278,21 +19278,49 @@ var init_envVars = __esm(() => {
|
|
|
19278
19278
|
});
|
|
19279
19279
|
|
|
19280
19280
|
// src/session/brandingConfig.ts
|
|
19281
|
+
function toProductSlug(value) {
|
|
19282
|
+
const slug = value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
|
|
19283
|
+
return slug || PRODUCT_SLUG_FALLBACK;
|
|
19284
|
+
}
|
|
19281
19285
|
function normalizeBrandName(value, fallback) {
|
|
19282
19286
|
const normalized = value?.replace(/[\u0000-\u001f\u007f]+/g, " ").replace(/\s+/g, " ").trim();
|
|
19283
19287
|
return normalized ? normalized.slice(0, 80) : fallback;
|
|
19284
19288
|
}
|
|
19289
|
+
function optionalUrl(key, value) {
|
|
19290
|
+
const trimmed = value?.trim();
|
|
19291
|
+
return trimmed ? { [key]: trimmed } : {};
|
|
19292
|
+
}
|
|
19293
|
+
function validatedProductUrl(value) {
|
|
19294
|
+
const trimmed = value?.trim();
|
|
19295
|
+
if (!trimmed)
|
|
19296
|
+
return {};
|
|
19297
|
+
let protocol;
|
|
19298
|
+
try {
|
|
19299
|
+
protocol = new URL(trimmed).protocol;
|
|
19300
|
+
} catch {
|
|
19301
|
+
throw new TypeError(`branding.productUrl is not a valid URL: ${trimmed}`);
|
|
19302
|
+
}
|
|
19303
|
+
if (protocol !== "https:" && protocol !== "http:" || /[^\x21-\x7e]/.test(trimmed)) {
|
|
19304
|
+
throw new TypeError(`branding.productUrl must be an ASCII http(s) URL: ${trimmed}`);
|
|
19305
|
+
}
|
|
19306
|
+
return { productUrl: trimmed };
|
|
19307
|
+
}
|
|
19285
19308
|
function resolveBranding(options) {
|
|
19286
19309
|
const productName = normalizeBrandName(options?.productName, DEFAULT_BRANDING.productName);
|
|
19310
|
+
const explicitSlug = options?.productSlug?.trim();
|
|
19287
19311
|
return Object.freeze({
|
|
19288
19312
|
productName,
|
|
19289
|
-
|
|
19313
|
+
productSlug: toProductSlug(explicitSlug || productName),
|
|
19314
|
+
assistantName: normalizeBrandName(options?.assistantName, productName),
|
|
19315
|
+
...optionalUrl("mcpOAuthClientMetadataUrl", options?.mcpOAuthClientMetadataUrl),
|
|
19316
|
+
...validatedProductUrl(options?.productUrl)
|
|
19290
19317
|
});
|
|
19291
19318
|
}
|
|
19292
|
-
var DEFAULT_BRANDING;
|
|
19319
|
+
var DEFAULT_BRANDING, PRODUCT_SLUG_FALLBACK = "app";
|
|
19293
19320
|
var init_brandingConfig = __esm(() => {
|
|
19294
19321
|
DEFAULT_BRANDING = Object.freeze({
|
|
19295
19322
|
productName: "Agentic",
|
|
19323
|
+
productSlug: "agentic",
|
|
19296
19324
|
assistantName: "Agentic"
|
|
19297
19325
|
});
|
|
19298
19326
|
});
|
|
@@ -19309,12 +19337,17 @@ function getAssistantIdentityPrompt() {
|
|
|
19309
19337
|
return `You are ${getBranding().assistantName}, an agentic coding assistant.`;
|
|
19310
19338
|
}
|
|
19311
19339
|
function getMcpClientInfo() {
|
|
19312
|
-
const { productName } = getBranding();
|
|
19340
|
+
const { productName, productSlug, productUrl } = getBranding();
|
|
19313
19341
|
return {
|
|
19342
|
+
name: productSlug,
|
|
19314
19343
|
title: `${productName} Coding Client`,
|
|
19315
|
-
description: `${productName} agentic coding client
|
|
19344
|
+
description: `${productName} agentic coding client`,
|
|
19345
|
+
...productUrl ? { websiteUrl: productUrl } : {}
|
|
19316
19346
|
};
|
|
19317
19347
|
}
|
|
19348
|
+
function getProductUserAgentToken() {
|
|
19349
|
+
return getBranding().productSlug;
|
|
19350
|
+
}
|
|
19318
19351
|
var brandingStorage;
|
|
19319
19352
|
var init_branding = __esm(() => {
|
|
19320
19353
|
init_brandingConfig();
|
|
@@ -35403,7 +35436,7 @@ function getOauthConfig() {
|
|
|
35403
35436
|
}
|
|
35404
35437
|
return config;
|
|
35405
35438
|
}
|
|
35406
|
-
var CLAUDE_AI_INFERENCE_SCOPE = "user:inference", CLAUDE_AI_PROFILE_SCOPE = "user:profile", CONSOLE_SCOPE = "org:create_api_key", OAUTH_BETA_HEADER = "oauth-2025-04-20", CONSOLE_OAUTH_SCOPES, CLAUDE_AI_OAUTH_SCOPES, ALL_OAUTH_SCOPES, PROD_OAUTH_CONFIG,
|
|
35439
|
+
var CLAUDE_AI_INFERENCE_SCOPE = "user:inference", CLAUDE_AI_PROFILE_SCOPE = "user:profile", CONSOLE_SCOPE = "org:create_api_key", OAUTH_BETA_HEADER = "oauth-2025-04-20", CONSOLE_OAUTH_SCOPES, CLAUDE_AI_OAUTH_SCOPES, ALL_OAUTH_SCOPES, PROD_OAUTH_CONFIG, STAGING_OAUTH_CONFIG, ALLOWED_OAUTH_BASE_URLS;
|
|
35407
35440
|
var init_oauth = __esm(() => {
|
|
35408
35441
|
init_envUtils();
|
|
35409
35442
|
init_envVars();
|
|
@@ -38538,6 +38571,7 @@ var init_git = __esm(() => {
|
|
|
38538
38571
|
init_log2();
|
|
38539
38572
|
init_memoize2();
|
|
38540
38573
|
init_which();
|
|
38574
|
+
init_branding();
|
|
38541
38575
|
GIT_ROOT_NOT_FOUND = Symbol("git-root-not-found");
|
|
38542
38576
|
findGitRootImpl = memoizeWithLRU((startPath) => {
|
|
38543
38577
|
const startTime = Date.now();
|
|
@@ -39828,7 +39862,8 @@ var init_types4 = __esm(() => {
|
|
|
39828
39862
|
type: literal("stdio").optional(),
|
|
39829
39863
|
command: string2().min(1, "Command cannot be empty"),
|
|
39830
39864
|
args: array(string2()).default([]),
|
|
39831
|
-
env: record(string2(), string2()).optional()
|
|
39865
|
+
env: record(string2(), string2()).optional(),
|
|
39866
|
+
cwd: string2().optional()
|
|
39832
39867
|
}));
|
|
39833
39868
|
McpXaaConfigSchema = lazySchema(() => boolean2());
|
|
39834
39869
|
McpOAuthConfigSchema = lazySchema(() => object2({
|
|
@@ -40765,7 +40800,7 @@ var init_types5 = __esm(() => {
|
|
|
40765
40800
|
allow: array(PermissionRuleSchema()).optional().describe("List of permission rules for allowed operations"),
|
|
40766
40801
|
deny: array(PermissionRuleSchema()).optional().describe("List of permission rules for denied operations"),
|
|
40767
40802
|
ask: array(PermissionRuleSchema()).optional().describe("List of permission rules that should always prompt for confirmation"),
|
|
40768
|
-
defaultMode: _enum(EXTERNAL_PERMISSION_MODES).optional().describe("Default permission mode when
|
|
40803
|
+
defaultMode: _enum(EXTERNAL_PERMISSION_MODES).optional().describe("Default permission mode when the agent needs access"),
|
|
40769
40804
|
disableBypassPermissionsMode: _enum(["disable"]).optional().describe("Disable the ability to bypass permission prompts"),
|
|
40770
40805
|
...{},
|
|
40771
40806
|
additionalDirectories: array(string2()).optional().describe("Additional directories to include in the permission scope")
|
|
@@ -40810,7 +40845,7 @@ var init_types5 = __esm(() => {
|
|
|
40810
40845
|
"mcp"
|
|
40811
40846
|
];
|
|
40812
40847
|
SettingsSchema = lazySchema(() => object2({
|
|
40813
|
-
$schema: literal(CLAUDE_CODE_SETTINGS_SCHEMA_URL).optional().describe("JSON Schema reference for
|
|
40848
|
+
$schema: literal(CLAUDE_CODE_SETTINGS_SCHEMA_URL).optional().describe("JSON Schema reference for settings"),
|
|
40814
40849
|
apiKeyHelper: string2().optional().describe("Path to a script that outputs authentication values"),
|
|
40815
40850
|
awsCredentialExport: string2().optional().describe("Path to a script that exports AWS credentials"),
|
|
40816
40851
|
awsAuthRefresh: string2().optional().describe("Path to a script that refreshes AWS authentication"),
|
|
@@ -40818,7 +40853,7 @@ var init_types5 = __esm(() => {
|
|
|
40818
40853
|
...isEnvTruthy(resolveEnvVar("ENABLE_XAA")) ? {
|
|
40819
40854
|
xaaIdp: object2({
|
|
40820
40855
|
issuer: string2().url().describe("IdP issuer URL for OIDC discovery"),
|
|
40821
|
-
clientId: string2().describe("
|
|
40856
|
+
clientId: string2().describe("The client_id registered at the IdP"),
|
|
40822
40857
|
callbackPort: number2().int().positive().optional().describe("Fixed loopback callback port for the IdP OIDC login. " + "Only needed if the IdP does not honor RFC 8252 port-any matching.")
|
|
40823
40858
|
}).optional().describe("XAA (SEP-990) IdP connection. Configure once; all XAA-enabled MCP servers reuse this.")
|
|
40824
40859
|
} : {},
|
|
@@ -40828,10 +40863,10 @@ var init_types5 = __esm(() => {
|
|
|
40828
40863
|
}).optional().describe("Custom file suggestion configuration for @ mentions"),
|
|
40829
40864
|
respectGitignore: boolean2().optional().describe("Whether file picker should respect .gitignore files (default: true). " + "Note: .ignore files are always respected."),
|
|
40830
40865
|
cleanupPeriodDays: number2().nonnegative().int().optional().describe("Number of days to retain chat transcripts (default: 30). Setting to 0 disables session persistence entirely: no transcripts are written and existing transcripts are deleted at startup."),
|
|
40831
|
-
env: EnvironmentVariablesSchema().optional().describe("Environment variables to set for
|
|
40866
|
+
env: EnvironmentVariablesSchema().optional().describe("Environment variables to set for agent sessions"),
|
|
40832
40867
|
includeGitInstructions: boolean2().optional().describe("Include built-in commit and PR workflow instructions in Claude's system prompt (default: true)"),
|
|
40833
40868
|
permissions: PermissionsSchema().optional().describe("Tool usage permissions configuration"),
|
|
40834
|
-
model: string2().optional().describe("Override the default model used by
|
|
40869
|
+
model: string2().optional().describe("Override the default model used by the agent"),
|
|
40835
40870
|
availableModels: array(string2()).optional().describe("Allowlist of models that users can select. " + 'Accepts family aliases ("opus" allows any opus version), ' + 'version prefixes ("opus-4-5" allows only that version), ' + "and full model IDs. " + "If undefined, all models are available. If empty array, only the default model is available. " + "Typically set in managed settings by enterprise administrators."),
|
|
40836
40871
|
modelOverrides: record(string2(), string2()).optional().describe('Override mapping from Anthropic model ID (e.g. "claude-opus-4-6") to provider-specific ' + "model ID (e.g. a Bedrock inference profile ARN). Typically set in managed settings by " + "enterprise administrators."),
|
|
40837
40872
|
enableAllProjectMcpServers: boolean2().optional().describe("Whether to automatically approve all MCP servers in the project"),
|
|
@@ -63656,11 +63691,6 @@ function parseAnthropicStreamChunk(chunk) {
|
|
|
63656
63691
|
return [chunk];
|
|
63657
63692
|
}
|
|
63658
63693
|
|
|
63659
|
-
// src/providers/shared/userAgent.ts
|
|
63660
|
-
function getClaudeCodeUserAgent() {
|
|
63661
|
-
return `claude-code/${"99.0.0"}`;
|
|
63662
|
-
}
|
|
63663
|
-
|
|
63664
63694
|
// src/session/workloadContext.ts
|
|
63665
63695
|
import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
|
|
63666
63696
|
function getWorkload() {
|
|
@@ -63692,17 +63722,19 @@ function getMCPUserAgent() {
|
|
|
63692
63722
|
parts.push(`client-app/${process.env.CLAUDE_AGENT_SDK_CLIENT_APP}`);
|
|
63693
63723
|
}
|
|
63694
63724
|
const suffix = parts.length > 0 ? ` (${parts.join(", ")})` : "";
|
|
63695
|
-
return
|
|
63725
|
+
return `${getProductUserAgentToken()}/${"99.0.0"}${suffix}`;
|
|
63696
63726
|
}
|
|
63697
63727
|
function getWebFetchUserAgent() {
|
|
63698
|
-
const
|
|
63699
|
-
|
|
63728
|
+
const { productSlug, productUrl } = getBranding();
|
|
63729
|
+
const contact = productUrl ? `; +${productUrl}` : "";
|
|
63730
|
+
return `${productSlug}-User (${productSlug}/${"99.0.0"}${contact})`;
|
|
63700
63731
|
}
|
|
63701
63732
|
var init_http2 = __esm(() => {
|
|
63702
63733
|
init_oauth();
|
|
63703
63734
|
init_auth();
|
|
63704
63735
|
init_state2();
|
|
63705
63736
|
init_workloadContext();
|
|
63737
|
+
init_branding();
|
|
63706
63738
|
});
|
|
63707
63739
|
|
|
63708
63740
|
// src/providers/shared/model/providers.ts
|
|
@@ -90260,6 +90292,7 @@ function createBootQueryContext() {
|
|
|
90260
90292
|
loaded: createSignal()
|
|
90261
90293
|
},
|
|
90262
90294
|
pluginDataPaths: new Map,
|
|
90295
|
+
pluginContentVariables: {},
|
|
90263
90296
|
lspManager: null
|
|
90264
90297
|
},
|
|
90265
90298
|
diagnostics: createFreshDiagnostics(),
|
|
@@ -90351,6 +90384,7 @@ function deriveSubagentRegistries(parent) {
|
|
|
90351
90384
|
skillListingSuppressNext: false,
|
|
90352
90385
|
dynamicSkills: parent.dynamicSkills,
|
|
90353
90386
|
pluginDataPaths: parent.pluginDataPaths,
|
|
90387
|
+
pluginContentVariables: parent.pluginContentVariables,
|
|
90354
90388
|
lspManager: parent.lspManager
|
|
90355
90389
|
};
|
|
90356
90390
|
}
|
|
@@ -90606,6 +90640,7 @@ function buildQueryContextFromSdk(options) {
|
|
|
90606
90640
|
loaded: createSignal()
|
|
90607
90641
|
},
|
|
90608
90642
|
pluginDataPaths: new Map,
|
|
90643
|
+
pluginContentVariables: {},
|
|
90609
90644
|
lspManager: null
|
|
90610
90645
|
},
|
|
90611
90646
|
diagnostics: createFreshDiagnostics(),
|
|
@@ -91120,11 +91155,22 @@ function resetSdkInitState() {
|
|
|
91120
91155
|
r.initJsonSchema = null;
|
|
91121
91156
|
r.registeredHooks = null;
|
|
91122
91157
|
}
|
|
91123
|
-
function setExplicitPluginRuntimeContext(dataPaths, lspManager) {
|
|
91158
|
+
function setExplicitPluginRuntimeContext(dataPaths, lspManager, contentVariables) {
|
|
91124
91159
|
const registries = getQueryContext().registries;
|
|
91125
91160
|
registries.pluginDataPaths = new Map(dataPaths);
|
|
91161
|
+
registries.pluginContentVariables = { ...contentVariables };
|
|
91126
91162
|
registries.lspManager = lspManager;
|
|
91127
91163
|
}
|
|
91164
|
+
function setExplicitPluginRuntimeBundle(bundle) {
|
|
91165
|
+
setExplicitPluginRuntimeContext(bundle.dataPaths, bundle.lspManager, bundle.contentVariables ?? {});
|
|
91166
|
+
}
|
|
91167
|
+
function tryGetPluginContentVariables() {
|
|
91168
|
+
try {
|
|
91169
|
+
return getQueryContext().registries.pluginContentVariables;
|
|
91170
|
+
} catch {
|
|
91171
|
+
return {};
|
|
91172
|
+
}
|
|
91173
|
+
}
|
|
91128
91174
|
function tryGetExplicitPluginDataPath(pluginId) {
|
|
91129
91175
|
try {
|
|
91130
91176
|
return getQueryContext().registries.pluginDataPaths.get(pluginId);
|
|
@@ -91590,6 +91636,7 @@ __export(exports_state, {
|
|
|
91590
91636
|
setCwdState: () => setCwdState2,
|
|
91591
91637
|
setDirectConnectServerUrl: () => setDirectConnectServerUrl,
|
|
91592
91638
|
setEnvVar: () => setEnvVar,
|
|
91639
|
+
setExplicitPluginRuntimeBundle: () => setExplicitPluginRuntimeBundle,
|
|
91593
91640
|
setExplicitPluginRuntimeContext: () => setExplicitPluginRuntimeContext,
|
|
91594
91641
|
setFastModeHeaderLatched: () => setFastModeHeaderLatched2,
|
|
91595
91642
|
setFlagSettingsInline: () => setFlagSettingsInline,
|
|
@@ -91626,6 +91673,7 @@ __export(exports_state, {
|
|
|
91626
91673
|
snapshotOutputTokensForTurn: () => snapshotOutputTokensForTurn,
|
|
91627
91674
|
switchSession: () => switchSession,
|
|
91628
91675
|
tryGetExplicitPluginDataPath: () => tryGetExplicitPluginDataPath,
|
|
91676
|
+
tryGetPluginContentVariables: () => tryGetPluginContentVariables,
|
|
91629
91677
|
tryGetQueryContext: () => tryGetQueryContext,
|
|
91630
91678
|
tryGetSessionLspManager: () => tryGetSessionLspManager,
|
|
91631
91679
|
unregisterCreatedTeam: () => unregisterCreatedTeam
|
|
@@ -107266,6 +107314,7 @@ var init_TaskOutput = __esm(() => {
|
|
|
107266
107314
|
init_stringUtils();
|
|
107267
107315
|
init_diskOutput();
|
|
107268
107316
|
init_fsOperations();
|
|
107317
|
+
init_branding();
|
|
107269
107318
|
DEFAULT_MAX_MEMORY = 8 * 1024 * 1024;
|
|
107270
107319
|
TaskOutput = class TaskOutput {
|
|
107271
107320
|
taskId;
|
|
@@ -107453,7 +107502,7 @@ Output truncated (${sizeKB}KB total). Full output saved to: ${this.path}`;
|
|
|
107453
107502
|
} catch (err) {
|
|
107454
107503
|
const code = err instanceof Error && "code" in err ? String(err.code) : "unknown";
|
|
107455
107504
|
logForDebugging(`TaskOutput.#readStdoutFromFile: failed to read ${this.path} (${code}): ${err}`);
|
|
107456
|
-
return `<bash output unavailable: output file ${this.path} could not be read (${code}). This usually means another
|
|
107505
|
+
return `<bash output unavailable: output file ${this.path} could not be read (${code}). This usually means another ${getBranding().productName} process in the same project deleted it during startup cleanup.>`;
|
|
107457
107506
|
}
|
|
107458
107507
|
}
|
|
107459
107508
|
getStderr() {
|
|
@@ -113094,6 +113143,11 @@ function substitutePluginVariables(value, plugin) {
|
|
|
113094
113143
|
}
|
|
113095
113144
|
return out;
|
|
113096
113145
|
}
|
|
113146
|
+
function substitutePluginContentVariables(value, variables = tryGetPluginContentVariables()) {
|
|
113147
|
+
if (Object.keys(variables).length === 0)
|
|
113148
|
+
return value;
|
|
113149
|
+
return value.replace(/\$\{([A-Z][A-Z0-9_]*)\}/g, (match, name) => Object.hasOwn(variables, name) ? variables[name] : match);
|
|
113150
|
+
}
|
|
113097
113151
|
function substituteUserConfigVariables(value, userConfig) {
|
|
113098
113152
|
return value.replace(/\$\{user_config\.([^}]+)\}/g, (_match, key) => {
|
|
113099
113153
|
const configValue = userConfig[key];
|
|
@@ -119720,6 +119774,10 @@ function tokenCountWithEstimation(messages) {
|
|
|
119720
119774
|
}
|
|
119721
119775
|
return getTokenCountFromUsage(usage) + roughTokenCountEstimationForMessages(messages.slice(i + 1));
|
|
119722
119776
|
}
|
|
119777
|
+
const baselineTokens = message?.contextBaselineTokens;
|
|
119778
|
+
if (typeof baselineTokens === "number" && Number.isFinite(baselineTokens) && baselineTokens >= 0) {
|
|
119779
|
+
return baselineTokens + roughTokenCountEstimationForMessages(messages.slice(i + 1));
|
|
119780
|
+
}
|
|
119723
119781
|
i--;
|
|
119724
119782
|
}
|
|
119725
119783
|
return roughTokenCountEstimationForMessages(messages);
|
|
@@ -120387,6 +120445,75 @@ var init_contextAnalysis = __esm(() => {
|
|
|
120387
120445
|
init_slowOperations();
|
|
120388
120446
|
});
|
|
120389
120447
|
|
|
120448
|
+
// src/session/contextSnapshot.ts
|
|
120449
|
+
function cloneSnapshotMessage(message) {
|
|
120450
|
+
if (message.type !== "system" || message.subtype !== "compact_boundary") {
|
|
120451
|
+
return message;
|
|
120452
|
+
}
|
|
120453
|
+
const { contextSnapshot: _ignored, ...compactMetadata } = message.compactMetadata;
|
|
120454
|
+
return {
|
|
120455
|
+
...message,
|
|
120456
|
+
compactMetadata
|
|
120457
|
+
};
|
|
120458
|
+
}
|
|
120459
|
+
function isSnapshotMessage(message) {
|
|
120460
|
+
return CONTEXT_SNAPSHOT_MESSAGE_TYPES.has(message.type);
|
|
120461
|
+
}
|
|
120462
|
+
function buildContextSnapshot(messages) {
|
|
120463
|
+
const snapshotMessages = messages.filter(isSnapshotMessage).map(cloneSnapshotMessage);
|
|
120464
|
+
if (snapshotMessages.length === 0)
|
|
120465
|
+
return;
|
|
120466
|
+
return {
|
|
120467
|
+
schemaVersion: 1,
|
|
120468
|
+
messages: snapshotMessages,
|
|
120469
|
+
baselineTokens: tokenCountWithEstimation(snapshotMessages)
|
|
120470
|
+
};
|
|
120471
|
+
}
|
|
120472
|
+
function isRecord2(value) {
|
|
120473
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
120474
|
+
}
|
|
120475
|
+
function isValidSnapshotMessage(value) {
|
|
120476
|
+
if (!isRecord2(value) || typeof value.type !== "string")
|
|
120477
|
+
return false;
|
|
120478
|
+
return CONTEXT_SNAPSHOT_MESSAGE_TYPES.has(value.type);
|
|
120479
|
+
}
|
|
120480
|
+
function normalizeContextSnapshot(raw) {
|
|
120481
|
+
if (!isRecord2(raw)) {
|
|
120482
|
+
throw new Error("Invalid context snapshot: expected an object");
|
|
120483
|
+
}
|
|
120484
|
+
if (raw.schemaVersion !== 1) {
|
|
120485
|
+
throw new Error(`Invalid context snapshot: unsupported schemaVersion ${String(raw.schemaVersion)}`);
|
|
120486
|
+
}
|
|
120487
|
+
if (!Array.isArray(raw.messages) || raw.messages.length === 0) {
|
|
120488
|
+
throw new Error("Invalid context snapshot: messages must be a non-empty array");
|
|
120489
|
+
}
|
|
120490
|
+
if (typeof raw.baselineTokens !== "number" || !Number.isFinite(raw.baselineTokens) || raw.baselineTokens < 0) {
|
|
120491
|
+
throw new Error("Invalid context snapshot: baselineTokens must be a non-negative number");
|
|
120492
|
+
}
|
|
120493
|
+
const messages = raw.messages.map((message, index) => {
|
|
120494
|
+
if (!isValidSnapshotMessage(message)) {
|
|
120495
|
+
throw new Error(`Invalid context snapshot: unsupported message at index ${index}`);
|
|
120496
|
+
}
|
|
120497
|
+
return message;
|
|
120498
|
+
});
|
|
120499
|
+
const baselineTokens = raw.baselineTokens;
|
|
120500
|
+
if (baselineTokens > 0) {
|
|
120501
|
+
const last = messages.at(-1);
|
|
120502
|
+
last.contextBaselineTokens = baselineTokens;
|
|
120503
|
+
}
|
|
120504
|
+
return { messages, baselineTokens };
|
|
120505
|
+
}
|
|
120506
|
+
var CONTEXT_SNAPSHOT_MESSAGE_TYPES;
|
|
120507
|
+
var init_contextSnapshot = __esm(() => {
|
|
120508
|
+
init_tokens();
|
|
120509
|
+
CONTEXT_SNAPSHOT_MESSAGE_TYPES = new Set([
|
|
120510
|
+
"assistant",
|
|
120511
|
+
"user",
|
|
120512
|
+
"attachment",
|
|
120513
|
+
"system"
|
|
120514
|
+
]);
|
|
120515
|
+
});
|
|
120516
|
+
|
|
120390
120517
|
// src/providers/anthropic/rateLimits/mocking.ts
|
|
120391
120518
|
function processRateLimitHeaders(headers) {
|
|
120392
120519
|
if (shouldProcessMockLimits()) {
|
|
@@ -122431,7 +122558,7 @@ function getErrorMessageIfRefusal(stopReason, model) {
|
|
|
122431
122558
|
}
|
|
122432
122559
|
logEvent("tengu_refusal_api_response", {});
|
|
122433
122560
|
const usagePolicyUrl = isFamily(getProvider(), "firstParty") ? "https://www.anthropic.com/legal/aup" : "your provider's acceptable use policy";
|
|
122434
|
-
const baseMessage = getIsNonInteractiveSession() ? `${API_ERROR_MESSAGE_PREFIX}:
|
|
122561
|
+
const baseMessage = getIsNonInteractiveSession() ? `${API_ERROR_MESSAGE_PREFIX}: ${getBranding().productName} is unable to respond to this request, which appears to violate our Usage Policy (${usagePolicyUrl}). Try rephrasing the request or attempting a different approach.` : `${API_ERROR_MESSAGE_PREFIX}: ${getBranding().productName} is unable to respond to this request, which appears to violate our Usage Policy (${usagePolicyUrl}). Please double press esc to edit your last message or start a new session for ${getBranding().productName} to assist with a different task.`;
|
|
122435
122562
|
const modelSuggestion = model !== "claude-sonnet-4-20250514" ? " If you are seeing this refusal repeatedly, try running /model claude-sonnet-4-20250514 to switch models." : "";
|
|
122436
122563
|
return createAssistantAPIErrorMessage({
|
|
122437
122564
|
content: baseMessage + modelSuggestion,
|
|
@@ -122478,6 +122605,7 @@ var init_errors7 = __esm(() => {
|
|
|
122478
122605
|
init_claudeAiLimits();
|
|
122479
122606
|
init_mocking();
|
|
122480
122607
|
init_errorUtils();
|
|
122608
|
+
init_branding();
|
|
122481
122609
|
});
|
|
122482
122610
|
|
|
122483
122611
|
// src/providers/shared/retry.ts
|
|
@@ -122499,6 +122627,9 @@ function wrapBodyTransportError(error) {
|
|
|
122499
122627
|
return new APIConnectionError({ message: error.message, cause: error });
|
|
122500
122628
|
}
|
|
122501
122629
|
function toReplayableStreamError(error) {
|
|
122630
|
+
if (error instanceof EmptyStreamError) {
|
|
122631
|
+
return new APIConnectionError({ message: error.message, cause: error });
|
|
122632
|
+
}
|
|
122502
122633
|
const wrapped = error instanceof Error && error.message.startsWith(STREAM_WATCHDOG_ABORT_PREFIX) ? new APIConnectionError({ message: error.message, cause: error }) : wrapBodyTransportError(error);
|
|
122503
122634
|
if (!(wrapped instanceof APIConnectionError) || wrapped instanceof APIConnectionTimeoutError || extractConnectionErrorDetails(wrapped)?.isSSLError) {
|
|
122504
122635
|
return null;
|
|
@@ -122957,7 +123088,7 @@ function getRateLimitResetDelayMs(error) {
|
|
|
122957
123088
|
}
|
|
122958
123089
|
return null;
|
|
122959
123090
|
}
|
|
122960
|
-
var abortError = () => new APIUserAbortError, DEFAULT_MAX_RETRIES = 10, FLOOR_OUTPUT_TOKENS = 3000, MAX_529_RETRIES = 3, BASE_DELAY_MS = 500, FOREGROUND_529_RETRY_SOURCES, CONNECTION_WAIT_INITIAL_DELAY_MS = 5000, CONNECTION_WAIT_MAX_DELAY_MS = 60000, BODY_TRANSPORT_FAILURE_RE, STREAM_WATCHDOG_ABORT_PREFIX = "Stream idle timeout", PERSISTENT_MAX_BACKOFF_MS, PERSISTENT_RESET_CAP_MS, HEARTBEAT_INTERVAL_MS = 30000, DEFAULT_CONNECTION_WAIT_BACKOFF, CannotRetryError, FallbackTriggeredError, DEFAULT_FAST_MODE_FALLBACK_HOLD_MS, SHORT_RETRY_THRESHOLD_MS, MIN_COOLDOWN_MS;
|
|
123091
|
+
var abortError = () => new APIUserAbortError, DEFAULT_MAX_RETRIES = 10, FLOOR_OUTPUT_TOKENS = 3000, MAX_529_RETRIES = 3, BASE_DELAY_MS = 500, FOREGROUND_529_RETRY_SOURCES, CONNECTION_WAIT_INITIAL_DELAY_MS = 5000, CONNECTION_WAIT_MAX_DELAY_MS = 60000, BODY_TRANSPORT_FAILURE_RE, STREAM_WATCHDOG_ABORT_PREFIX = "Stream idle timeout", EmptyStreamError, PERSISTENT_MAX_BACKOFF_MS, PERSISTENT_RESET_CAP_MS, HEARTBEAT_INTERVAL_MS = 30000, DEFAULT_CONNECTION_WAIT_BACKOFF, CannotRetryError, FallbackTriggeredError, DEFAULT_FAST_MODE_FALLBACK_HOLD_MS, SHORT_RETRY_THRESHOLD_MS, MIN_COOLDOWN_MS;
|
|
122961
123092
|
var init_retry = __esm(() => {
|
|
122962
123093
|
init_sdk();
|
|
122963
123094
|
init_aws();
|
|
@@ -122994,6 +123125,12 @@ var init_retry = __esm(() => {
|
|
|
122994
123125
|
...[]
|
|
122995
123126
|
]);
|
|
122996
123127
|
BODY_TRANSPORT_FAILURE_RE = /socket connection was closed|^terminated$|other side closed|fetch failed/i;
|
|
123128
|
+
EmptyStreamError = class EmptyStreamError extends Error {
|
|
123129
|
+
constructor(message = "Stream ended before completing the response") {
|
|
123130
|
+
super(message);
|
|
123131
|
+
this.name = "EmptyStreamError";
|
|
123132
|
+
}
|
|
123133
|
+
};
|
|
122997
123134
|
PERSISTENT_MAX_BACKOFF_MS = 5 * 60 * 1000;
|
|
122998
123135
|
PERSISTENT_RESET_CAP_MS = 6 * 60 * 60 * 1000;
|
|
122999
123136
|
DEFAULT_CONNECTION_WAIT_BACKOFF = {
|
|
@@ -166883,40 +167020,6 @@ var init_p_map = __esm(() => {
|
|
|
166883
167020
|
pMapSkip = Symbol("skip");
|
|
166884
167021
|
});
|
|
166885
167022
|
|
|
166886
|
-
// src/session/bridge/sessionIdCompat.ts
|
|
166887
|
-
function toCompatSessionId(id) {
|
|
166888
|
-
if (!id.startsWith("cse_"))
|
|
166889
|
-
return id;
|
|
166890
|
-
if (_isCseShimEnabled && !_isCseShimEnabled())
|
|
166891
|
-
return id;
|
|
166892
|
-
return "session_" + id.slice("cse_".length);
|
|
166893
|
-
}
|
|
166894
|
-
var _isCseShimEnabled;
|
|
166895
|
-
|
|
166896
|
-
// src/constants/product.ts
|
|
166897
|
-
function isRemoteSessionStaging(sessionId, ingressUrl) {
|
|
166898
|
-
return sessionId?.includes("_staging_") === true || ingressUrl?.includes("staging") === true;
|
|
166899
|
-
}
|
|
166900
|
-
function isRemoteSessionLocal(sessionId, ingressUrl) {
|
|
166901
|
-
return sessionId?.includes("_local_") === true || ingressUrl?.includes("localhost") === true;
|
|
166902
|
-
}
|
|
166903
|
-
function getClaudeAiBaseUrl(sessionId, ingressUrl) {
|
|
166904
|
-
if (isRemoteSessionLocal(sessionId, ingressUrl)) {
|
|
166905
|
-
return CLAUDE_AI_LOCAL_BASE_URL;
|
|
166906
|
-
}
|
|
166907
|
-
if (isRemoteSessionStaging(sessionId, ingressUrl)) {
|
|
166908
|
-
return CLAUDE_AI_STAGING_BASE_URL;
|
|
166909
|
-
}
|
|
166910
|
-
return CLAUDE_AI_BASE_URL;
|
|
166911
|
-
}
|
|
166912
|
-
function getRemoteSessionUrl(sessionId, ingressUrl) {
|
|
166913
|
-
;
|
|
166914
|
-
const compatId = toCompatSessionId(sessionId);
|
|
166915
|
-
const baseUrl = getClaudeAiBaseUrl(compatId, ingressUrl);
|
|
166916
|
-
return `${baseUrl}/code/${compatId}`;
|
|
166917
|
-
}
|
|
166918
|
-
var PRODUCT_URL = "https://claude.com/claude-code", TELEMETRY_SERVICE_NAME = "claude-code", CLAUDE_AI_BASE_URL = "https://claude.ai", CLAUDE_AI_STAGING_BASE_URL = "https://claude-ai.staging.ant.dev", CLAUDE_AI_LOCAL_BASE_URL = "http://localhost:4000";
|
|
166919
|
-
|
|
166920
167023
|
// node_modules/.bun/semver@7.7.4/node_modules/semver/internal/constants.js
|
|
166921
167024
|
var require_constants7 = __commonJS(function(exports, module) {
|
|
166922
167025
|
var SEMVER_SPEC_VERSION = "2.0.0";
|
|
@@ -171661,7 +171764,7 @@ function normalizeCodexMcpFields(input) {
|
|
|
171661
171764
|
}
|
|
171662
171765
|
|
|
171663
171766
|
// src/capabilities/plugins/mcpPluginIntegration.ts
|
|
171664
|
-
import { join as join40 } from "path";
|
|
171767
|
+
import { join as join40, resolve as resolvePath } from "path";
|
|
171665
171768
|
async function loadMcpServersFromMcpb(plugin, mcpbPath, errors) {
|
|
171666
171769
|
try {
|
|
171667
171770
|
logForDebugging(`Loading MCP servers from MCPB: ${mcpbPath}`);
|
|
@@ -171871,6 +171974,9 @@ function resolvePluginMcpEnvironment(config, plugin, userConfig, errors, pluginN
|
|
|
171871
171974
|
if (stdioConfig.args) {
|
|
171872
171975
|
stdioConfig.args = stdioConfig.args.map((arg) => resolveValue(arg));
|
|
171873
171976
|
}
|
|
171977
|
+
if (stdioConfig.cwd) {
|
|
171978
|
+
stdioConfig.cwd = resolvePath(plugin.path, resolveValue(stdioConfig.cwd));
|
|
171979
|
+
}
|
|
171874
171980
|
const resolvedEnv = {
|
|
171875
171981
|
CLAUDE_PLUGIN_ROOT: plugin.path,
|
|
171876
171982
|
CLAUDE_PLUGIN_DATA: plugin.dataPath ?? getPluginDataDir(plugin.source),
|
|
@@ -172435,160 +172541,6 @@ var init_agentMemorySnapshot = __esm(() => {
|
|
|
172435
172541
|
}));
|
|
172436
172542
|
});
|
|
172437
172543
|
|
|
172438
|
-
// src/capabilities/tools/AgentTool/built-in/claudeCodeGuideAgent.ts
|
|
172439
|
-
function getClaudeCodeGuideBasePrompt() {
|
|
172440
|
-
const localSearchHint = hasEmbeddedSearchTools() ? `${FILE_READ_TOOL_NAME}, \`find\`, and \`grep\`` : `${FILE_READ_TOOL_NAME}, ${GLOB_TOOL_NAME}, and ${GREP_TOOL_NAME}`;
|
|
172441
|
-
return `You are the Claude guide agent. Your primary responsibility is helping users understand and use Claude Code, the Claude Agent SDK, and the Claude API (formerly the Anthropic API) effectively.
|
|
172442
|
-
|
|
172443
|
-
**Your expertise spans three domains:**
|
|
172444
|
-
|
|
172445
|
-
1. **Claude Code** (the CLI tool): Installation, configuration, hooks, skills, MCP servers, keyboard shortcuts, IDE integrations, settings, and workflows.
|
|
172446
|
-
|
|
172447
|
-
2. **Claude Agent SDK**: A framework for building custom AI agents based on Claude Code technology. Available for Node.js/TypeScript and Python.
|
|
172448
|
-
|
|
172449
|
-
3. **Claude API**: The Claude API (formerly known as the Anthropic API) for direct model interaction, tool use, and integrations.
|
|
172450
|
-
|
|
172451
|
-
**Documentation sources:**
|
|
172452
|
-
|
|
172453
|
-
- **Claude Code docs** (${CLAUDE_CODE_DOCS_MAP_URL}): Fetch this for questions about the Claude Code CLI tool, including:
|
|
172454
|
-
- Installation, setup, and getting started
|
|
172455
|
-
- Hooks (pre/post command execution)
|
|
172456
|
-
- Custom skills
|
|
172457
|
-
- MCP server configuration
|
|
172458
|
-
- IDE integrations (VS Code, JetBrains)
|
|
172459
|
-
- Settings files and configuration
|
|
172460
|
-
- Keyboard shortcuts and hotkeys
|
|
172461
|
-
- Subagents and plugins
|
|
172462
|
-
- Sandboxing and security
|
|
172463
|
-
|
|
172464
|
-
- **Claude Agent SDK docs** (${CDP_DOCS_MAP_URL}): Fetch this for questions about building agents with the SDK, including:
|
|
172465
|
-
- SDK overview and getting started (Python and TypeScript)
|
|
172466
|
-
- Agent configuration + custom tools
|
|
172467
|
-
- Session management and permissions
|
|
172468
|
-
- MCP integration in agents
|
|
172469
|
-
- Hosting and deployment
|
|
172470
|
-
- Cost tracking and context management
|
|
172471
|
-
Note: Agent SDK docs are part of the Claude API documentation at the same URL.
|
|
172472
|
-
|
|
172473
|
-
- **Claude API docs** (${CDP_DOCS_MAP_URL}): Fetch this for questions about the Claude API (formerly the Anthropic API), including:
|
|
172474
|
-
- Messages API and streaming
|
|
172475
|
-
- Tool use (function calling) and Anthropic-defined tools (computer use, code execution, web search, text editor, bash, programmatic tool calling, tool search tool, context editing, Files API, structured outputs)
|
|
172476
|
-
- Vision, PDF support, and citations
|
|
172477
|
-
- Extended thinking and structured outputs
|
|
172478
|
-
- MCP connector for remote MCP servers
|
|
172479
|
-
- Cloud provider integrations (Bedrock, Vertex AI, Foundry)
|
|
172480
|
-
|
|
172481
|
-
**Approach:**
|
|
172482
|
-
1. Determine which domain the user's question falls into
|
|
172483
|
-
2. Use ${WEB_FETCH_TOOL_NAME} to fetch the appropriate docs map
|
|
172484
|
-
3. Identify the most relevant documentation URLs from the map
|
|
172485
|
-
4. Fetch the specific documentation pages
|
|
172486
|
-
5. Provide clear, actionable guidance based on official documentation
|
|
172487
|
-
6. Use ${WEB_SEARCH_TOOL_NAME} if docs don't cover the topic
|
|
172488
|
-
7. Reference local project files (CLAUDE.md, .claude/ directory) when relevant using ${localSearchHint}
|
|
172489
|
-
|
|
172490
|
-
**Guidelines:**
|
|
172491
|
-
- Always prioritize official documentation over assumptions
|
|
172492
|
-
- Keep responses concise and actionable
|
|
172493
|
-
- Include specific examples or code snippets when helpful
|
|
172494
|
-
- Reference exact documentation URLs in your responses
|
|
172495
|
-
- Help users discover features by proactively suggesting related commands, shortcuts, or capabilities
|
|
172496
|
-
|
|
172497
|
-
Complete the user's request by providing accurate, documentation-based guidance.`;
|
|
172498
|
-
}
|
|
172499
|
-
function getFeedbackGuideline() {
|
|
172500
|
-
if (isUsing3PServices()) {
|
|
172501
|
-
return `- When you cannot find an answer or the feature doesn't exist, direct the user to ${"report the issue at https://github.com/anthropics/claude-code/issues"}`;
|
|
172502
|
-
}
|
|
172503
|
-
return "- When you cannot find an answer or the feature doesn't exist, direct the user to use /feedback to report a feature request or bug";
|
|
172504
|
-
}
|
|
172505
|
-
var CLAUDE_CODE_DOCS_MAP_URL = "https://code.claude.com/docs/en/claude_code_docs_map.md", CDP_DOCS_MAP_URL = "https://platform.claude.com/llms.txt", CLAUDE_CODE_GUIDE_AGENT_TYPE = "claude-code-guide", CLAUDE_CODE_GUIDE_AGENT;
|
|
172506
|
-
var init_claudeCodeGuideAgent = __esm(() => {
|
|
172507
|
-
init_auth();
|
|
172508
|
-
init_embeddedTools();
|
|
172509
|
-
init_settings2();
|
|
172510
|
-
init_slowOperations();
|
|
172511
|
-
CLAUDE_CODE_GUIDE_AGENT = {
|
|
172512
|
-
agentType: CLAUDE_CODE_GUIDE_AGENT_TYPE,
|
|
172513
|
-
whenToUse: `Use this agent when the user asks questions ("Can Claude...", "Does Claude...", "How do I...") about: (1) Claude Code (the CLI tool) - features, hooks, slash commands, MCP servers, settings, IDE integrations, keyboard shortcuts; (2) Claude Agent SDK - building custom agents; (3) Claude API (formerly Anthropic API) - API usage, tool use, Anthropic SDK usage. **IMPORTANT:** Before spawning a new agent, check if there is already a running or recently completed claude-code-guide agent that you can continue via ${SEND_MESSAGE_TOOL_NAME}.`,
|
|
172514
|
-
tools: hasEmbeddedSearchTools() ? [
|
|
172515
|
-
BASH_TOOL_NAME,
|
|
172516
|
-
FILE_READ_TOOL_NAME,
|
|
172517
|
-
WEB_FETCH_TOOL_NAME,
|
|
172518
|
-
WEB_SEARCH_TOOL_NAME
|
|
172519
|
-
] : [
|
|
172520
|
-
GLOB_TOOL_NAME,
|
|
172521
|
-
GREP_TOOL_NAME,
|
|
172522
|
-
FILE_READ_TOOL_NAME,
|
|
172523
|
-
WEB_FETCH_TOOL_NAME,
|
|
172524
|
-
WEB_SEARCH_TOOL_NAME
|
|
172525
|
-
],
|
|
172526
|
-
source: "built-in",
|
|
172527
|
-
baseDir: "built-in",
|
|
172528
|
-
model: "haiku",
|
|
172529
|
-
permissionMode: "dontAsk",
|
|
172530
|
-
getSystemPrompt({ toolUseContext }) {
|
|
172531
|
-
const commands = toolUseContext.options.commands;
|
|
172532
|
-
const contextSections = [];
|
|
172533
|
-
const customCommands = commands.filter((cmd) => cmd.type === "prompt");
|
|
172534
|
-
if (customCommands.length > 0) {
|
|
172535
|
-
const commandList = customCommands.map((cmd) => `- /${cmd.name}: ${cmd.description}`).join(`
|
|
172536
|
-
`);
|
|
172537
|
-
contextSections.push(`**Available custom skills in this project:**
|
|
172538
|
-
${commandList}`);
|
|
172539
|
-
}
|
|
172540
|
-
const customAgents = toolUseContext.options.agentDefinitions.activeAgents.filter((a) => a.source !== "built-in");
|
|
172541
|
-
if (customAgents.length > 0) {
|
|
172542
|
-
const agentList = customAgents.map((a) => `- ${a.agentType}: ${a.whenToUse}`).join(`
|
|
172543
|
-
`);
|
|
172544
|
-
contextSections.push(`**Available custom agents configured:**
|
|
172545
|
-
${agentList}`);
|
|
172546
|
-
}
|
|
172547
|
-
const mcpClients = toolUseContext.options.mcpClients;
|
|
172548
|
-
if (mcpClients && mcpClients.length > 0) {
|
|
172549
|
-
const mcpList = mcpClients.map((client) => `- ${client.name}`).join(`
|
|
172550
|
-
`);
|
|
172551
|
-
contextSections.push(`**Configured MCP servers:**
|
|
172552
|
-
${mcpList}`);
|
|
172553
|
-
}
|
|
172554
|
-
const pluginCommands = commands.filter((cmd) => cmd.type === "prompt" && cmd.source === "plugin");
|
|
172555
|
-
if (pluginCommands.length > 0) {
|
|
172556
|
-
const pluginList = pluginCommands.map((cmd) => `- /${cmd.name}: ${cmd.description}`).join(`
|
|
172557
|
-
`);
|
|
172558
|
-
contextSections.push(`**Available plugin skills:**
|
|
172559
|
-
${pluginList}`);
|
|
172560
|
-
}
|
|
172561
|
-
const settings = getSettings_DEPRECATED();
|
|
172562
|
-
if (Object.keys(settings).length > 0) {
|
|
172563
|
-
const settingsJson = jsonStringify(settings, null, 2);
|
|
172564
|
-
contextSections.push(`**User's settings.json:**
|
|
172565
|
-
\`\`\`json
|
|
172566
|
-
${settingsJson}
|
|
172567
|
-
\`\`\``);
|
|
172568
|
-
}
|
|
172569
|
-
const feedbackGuideline = getFeedbackGuideline();
|
|
172570
|
-
const basePromptWithFeedback = `${getClaudeCodeGuideBasePrompt()}
|
|
172571
|
-
${feedbackGuideline}`;
|
|
172572
|
-
if (contextSections.length > 0) {
|
|
172573
|
-
return `${basePromptWithFeedback}
|
|
172574
|
-
|
|
172575
|
-
---
|
|
172576
|
-
|
|
172577
|
-
# User's Current Configuration
|
|
172578
|
-
|
|
172579
|
-
The user has the following custom setup in their environment:
|
|
172580
|
-
|
|
172581
|
-
${contextSections.join(`
|
|
172582
|
-
|
|
172583
|
-
`)}
|
|
172584
|
-
|
|
172585
|
-
When answering questions, consider these configured features and proactively suggest them when relevant.`;
|
|
172586
|
-
}
|
|
172587
|
-
return basePromptWithFeedback;
|
|
172588
|
-
}
|
|
172589
|
-
};
|
|
172590
|
-
});
|
|
172591
|
-
|
|
172592
172544
|
// src/capabilities/tools/AgentTool/built-in/exploreAgent.ts
|
|
172593
172545
|
function getExploreSystemPrompt() {
|
|
172594
172546
|
const embedded = hasEmbeddedSearchTools();
|
|
@@ -173063,10 +173015,6 @@ function getBuiltInAgents() {
|
|
|
173063
173015
|
if (areExplorePlanAgentsEnabled()) {
|
|
173064
173016
|
agents.push(EXPLORE_AGENT, PLAN_AGENT);
|
|
173065
173017
|
}
|
|
173066
|
-
const isNonSdkEntrypoint = resolveEnvVar("ENTRYPOINT") !== "sdk-ts" && resolveEnvVar("ENTRYPOINT") !== "sdk-py" && resolveEnvVar("ENTRYPOINT") !== "sdk-cli";
|
|
173067
|
-
if (isNonSdkEntrypoint) {
|
|
173068
|
-
agents.push(CLAUDE_CODE_GUIDE_AGENT);
|
|
173069
|
-
}
|
|
173070
173018
|
if (false) {}
|
|
173071
173019
|
return agents;
|
|
173072
173020
|
}
|
|
@@ -173076,7 +173024,6 @@ function resolveSdkAgents(hostAgents) {
|
|
|
173076
173024
|
var init_builtInAgents = __esm(() => {
|
|
173077
173025
|
init_state();
|
|
173078
173026
|
init_envUtils();
|
|
173079
|
-
init_claudeCodeGuideAgent();
|
|
173080
173027
|
init_exploreAgent();
|
|
173081
173028
|
init_generalPurposeAgent();
|
|
173082
173029
|
init_planAgent();
|
|
@@ -176884,6 +176831,40 @@ var init_agentSummary = __esm(() => {
|
|
|
176884
176831
|
init_sessionStorage();
|
|
176885
176832
|
});
|
|
176886
176833
|
|
|
176834
|
+
// src/session/bridge/sessionIdCompat.ts
|
|
176835
|
+
function toCompatSessionId(id) {
|
|
176836
|
+
if (!id.startsWith("cse_"))
|
|
176837
|
+
return id;
|
|
176838
|
+
if (_isCseShimEnabled && !_isCseShimEnabled())
|
|
176839
|
+
return id;
|
|
176840
|
+
return "session_" + id.slice("cse_".length);
|
|
176841
|
+
}
|
|
176842
|
+
var _isCseShimEnabled;
|
|
176843
|
+
|
|
176844
|
+
// src/constants/product.ts
|
|
176845
|
+
function isRemoteSessionStaging(sessionId, ingressUrl) {
|
|
176846
|
+
return sessionId?.includes("_staging_") === true || ingressUrl?.includes("staging") === true;
|
|
176847
|
+
}
|
|
176848
|
+
function isRemoteSessionLocal(sessionId, ingressUrl) {
|
|
176849
|
+
return sessionId?.includes("_local_") === true || ingressUrl?.includes("localhost") === true;
|
|
176850
|
+
}
|
|
176851
|
+
function getClaudeAiBaseUrl(sessionId, ingressUrl) {
|
|
176852
|
+
if (isRemoteSessionLocal(sessionId, ingressUrl)) {
|
|
176853
|
+
return CLAUDE_AI_LOCAL_BASE_URL;
|
|
176854
|
+
}
|
|
176855
|
+
if (isRemoteSessionStaging(sessionId, ingressUrl)) {
|
|
176856
|
+
return CLAUDE_AI_STAGING_BASE_URL;
|
|
176857
|
+
}
|
|
176858
|
+
return CLAUDE_AI_BASE_URL;
|
|
176859
|
+
}
|
|
176860
|
+
function getRemoteSessionUrl(sessionId, ingressUrl) {
|
|
176861
|
+
;
|
|
176862
|
+
const compatId = toCompatSessionId(sessionId);
|
|
176863
|
+
const baseUrl = getClaudeAiBaseUrl(compatId, ingressUrl);
|
|
176864
|
+
return `${baseUrl}/code/${compatId}`;
|
|
176865
|
+
}
|
|
176866
|
+
var TELEMETRY_SERVICE_NAME = "claude-code", CLAUDE_AI_BASE_URL = "https://claude.ai", CLAUDE_AI_STAGING_BASE_URL = "https://claude-ai.staging.ant.dev", CLAUDE_AI_LOCAL_BASE_URL = "http://localhost:4000";
|
|
176867
|
+
|
|
176887
176868
|
// src/session/tasks.ts
|
|
176888
176869
|
import { join as join44 } from "path";
|
|
176889
176870
|
function notifyTasksUpdated() {
|
|
@@ -177551,7 +177532,6 @@ NOTE: You just closed out 3+ tasks and none of them was a verification step. Bef
|
|
|
177551
177532
|
}
|
|
177552
177533
|
});
|
|
177553
177534
|
});
|
|
177554
|
-
|
|
177555
177535
|
// src/providers/anthropic/policyLimits/types.ts
|
|
177556
177536
|
var PolicyLimitsResponseSchema;
|
|
177557
177537
|
var init_types8 = __esm(() => {
|
|
@@ -179298,7 +179278,8 @@ var init_coreSchemas = __esm(() => {
|
|
|
179298
179278
|
type: literal("stdio").optional(),
|
|
179299
179279
|
command: string2(),
|
|
179300
179280
|
args: array(string2()).optional(),
|
|
179301
|
-
env: record(string2(), string2()).optional()
|
|
179281
|
+
env: record(string2(), string2()).optional(),
|
|
179282
|
+
cwd: string2().optional()
|
|
179302
179283
|
}));
|
|
179303
179284
|
McpSSEServerConfigSchema2 = lazySchema(() => object2({
|
|
179304
179285
|
type: literal("sse"),
|
|
@@ -180047,6 +180028,11 @@ var init_coreSchemas = __esm(() => {
|
|
|
180047
180028
|
trigger: _enum(["manual", "auto"]),
|
|
180048
180029
|
pre_tokens: number2(),
|
|
180049
180030
|
post_tokens: number2().optional().describe("Estimated resulting context size after compaction."),
|
|
180031
|
+
context_snapshot: object2({
|
|
180032
|
+
schemaVersion: literal(1),
|
|
180033
|
+
messages: array(unknown()),
|
|
180034
|
+
baselineTokens: number2()
|
|
180035
|
+
}).optional().describe("Opaque canonical post-compact context. Hosts persist and return it unchanged via Options.initialContextSnapshot."),
|
|
180050
180036
|
preserved_segment: object2({
|
|
180051
180037
|
head_uuid: UUIDPlaceholder(),
|
|
180052
180038
|
anchor_uuid: UUIDPlaceholder(),
|
|
@@ -185339,7 +185325,7 @@ function validateCommandPaths(command, args, cwd, toolPermissionContext, compoun
|
|
|
185339
185325
|
if (validator && !validator(args)) {
|
|
185340
185326
|
return {
|
|
185341
185327
|
behavior: "ask",
|
|
185342
|
-
message: `${command} with flags requires manual approval to ensure path safety. For security,
|
|
185328
|
+
message: `${command} with flags requires manual approval to ensure path safety. For security, ${getBranding().productName} cannot automatically validate ${command} commands that use flags, as some flags like --target-directory=PATH can bypass path validation.`,
|
|
185343
185329
|
decisionReason: {
|
|
185344
185330
|
type: "other",
|
|
185345
185331
|
reason: `${command} command with flags requires manual approval`
|
|
@@ -185349,7 +185335,7 @@ function validateCommandPaths(command, args, cwd, toolPermissionContext, compoun
|
|
|
185349
185335
|
if (compoundCommandHasCd && operationType !== "read") {
|
|
185350
185336
|
return {
|
|
185351
185337
|
behavior: "ask",
|
|
185352
|
-
message: `Commands that change directories and perform write operations require explicit approval to ensure paths are evaluated correctly. For security,
|
|
185338
|
+
message: `Commands that change directories and perform write operations require explicit approval to ensure paths are evaluated correctly. For security, ${getBranding().productName} cannot automatically determine the final working directory when 'cd' is used in compound commands.`,
|
|
185353
185339
|
decisionReason: {
|
|
185354
185340
|
type: "other",
|
|
185355
185341
|
reason: "Compound command contains cd with write operation - manual approval required to prevent path resolution bypass"
|
|
@@ -185361,7 +185347,7 @@ function validateCommandPaths(command, args, cwd, toolPermissionContext, compoun
|
|
|
185361
185347
|
if (!allowed) {
|
|
185362
185348
|
const workingDirs = Array.from(allWorkingDirectories(toolPermissionContext));
|
|
185363
185349
|
const dirListStr = formatDirectoryList(workingDirs);
|
|
185364
|
-
const message = decisionReason?.type === "other" || decisionReason?.type === "safetyCheck" ? decisionReason.reason : `${command} in '${resolvedPath}' was blocked. For security,
|
|
185350
|
+
const message = decisionReason?.type === "other" || decisionReason?.type === "safetyCheck" ? decisionReason.reason : `${command} in '${resolvedPath}' was blocked. For security, ${getBranding().productName} may only ${ACTION_VERBS[command]} the allowed working directories for this session: ${dirListStr}.`;
|
|
185365
185351
|
if (decisionReason?.type === "rule") {
|
|
185366
185352
|
return {
|
|
185367
185353
|
behavior: "deny",
|
|
@@ -185486,7 +185472,7 @@ function validateOutputRedirections(redirections, cwd, toolPermissionContext, co
|
|
|
185486
185472
|
if (compoundCommandHasCd && redirections.length > 0) {
|
|
185487
185473
|
return {
|
|
185488
185474
|
behavior: "ask",
|
|
185489
|
-
message: `Commands that change directories and write via output redirection require explicit approval to ensure paths are evaluated correctly. For security,
|
|
185475
|
+
message: `Commands that change directories and write via output redirection require explicit approval to ensure paths are evaluated correctly. For security, ${getBranding().productName} cannot automatically determine the final working directory when 'cd' is used in compound commands.`,
|
|
185490
185476
|
decisionReason: {
|
|
185491
185477
|
type: "other",
|
|
185492
185478
|
reason: "Compound command contains cd with output redirection - manual approval required to prevent path resolution bypass"
|
|
@@ -185501,7 +185487,7 @@ function validateOutputRedirections(redirections, cwd, toolPermissionContext, co
|
|
|
185501
185487
|
if (!allowed) {
|
|
185502
185488
|
const workingDirs = Array.from(allWorkingDirectories(toolPermissionContext));
|
|
185503
185489
|
const dirListStr = formatDirectoryList(workingDirs);
|
|
185504
|
-
const message = decisionReason?.type === "other" || decisionReason?.type === "safetyCheck" ? decisionReason.reason : decisionReason?.type === "rule" ? `Output redirection to '${resolvedPath}' was blocked by a deny rule.` : `Output redirection to '${resolvedPath}' was blocked. For security,
|
|
185490
|
+
const message = decisionReason?.type === "other" || decisionReason?.type === "safetyCheck" ? decisionReason.reason : decisionReason?.type === "rule" ? `Output redirection to '${resolvedPath}' was blocked by a deny rule.` : `Output redirection to '${resolvedPath}' was blocked. For security, ${getBranding().productName} may only write to files in the allowed working directories for this session: ${dirListStr}.`;
|
|
185505
185491
|
if (decisionReason?.type === "rule") {
|
|
185506
185492
|
return {
|
|
185507
185493
|
behavior: "deny",
|
|
@@ -185708,6 +185694,7 @@ var init_pathValidation2 = __esm(() => {
|
|
|
185708
185694
|
init_pathValidation();
|
|
185709
185695
|
init_bashPermissions();
|
|
185710
185696
|
init_sedValidation();
|
|
185697
|
+
init_branding();
|
|
185711
185698
|
PATH_EXTRACTORS = {
|
|
185712
185699
|
cd: (args) => args.length === 0 ? [homedir16()] : [args.join(" ")],
|
|
185713
185700
|
ls: (args) => {
|
|
@@ -198207,7 +198194,7 @@ function validateInputForSettingsFileEdit(filePath, originalContent, getUpdatedC
|
|
|
198207
198194
|
if (!afterValidation.isValid) {
|
|
198208
198195
|
return {
|
|
198209
198196
|
result: false,
|
|
198210
|
-
message: `
|
|
198197
|
+
message: `settings.json validation failed after edit:
|
|
198211
198198
|
${afterValidation.error}
|
|
198212
198199
|
|
|
198213
198200
|
Full schema:
|
|
@@ -200491,7 +200478,7 @@ var LITERAL_BACKSLASH = "\\", SNAPSHOT_CREATION_TIMEOUT = 1e4, VCS_DIRECTORIES_T
|
|
|
200491
200478
|
logForDebugging(`Looking for shell config file: ${configFile}`);
|
|
200492
200479
|
const configFileExists = await pathExists(configFile);
|
|
200493
200480
|
if (!configFileExists) {
|
|
200494
|
-
logForDebugging(`Shell config file not found: ${configFile}, creating snapshot with
|
|
200481
|
+
logForDebugging(`Shell config file not found: ${configFile}, creating snapshot with ${getBranding().productName} defaults only`);
|
|
200495
200482
|
}
|
|
200496
200483
|
const timestamp = Date.now();
|
|
200497
200484
|
const randomId = Math.random().toString(36).substring(2, 8);
|
|
@@ -200604,6 +200591,7 @@ var init_ShellSnapshot = __esm(() => {
|
|
|
200604
200591
|
init_subprocessEnv();
|
|
200605
200592
|
init_shellQuote();
|
|
200606
200593
|
init_state2();
|
|
200594
|
+
init_branding();
|
|
200607
200595
|
VCS_DIRECTORIES_TO_EXCLUDE2 = [
|
|
200608
200596
|
".git",
|
|
200609
200597
|
".svn",
|
|
@@ -211414,6 +211402,7 @@ ${content}`;
|
|
|
211414
211402
|
source: sourceName,
|
|
211415
211403
|
dataPath: pluginDataPath
|
|
211416
211404
|
});
|
|
211405
|
+
finalContent = substitutePluginContentVariables(finalContent);
|
|
211417
211406
|
if (pluginManifest.userConfig) {
|
|
211418
211407
|
finalContent = substituteUserConfigInContent(finalContent, loadPluginOptions(sourceName), pluginManifest.userConfig);
|
|
211419
211408
|
}
|
|
@@ -214514,7 +214503,7 @@ async function loadPluginSettings(pluginPath, manifest) {
|
|
|
214514
214503
|
try {
|
|
214515
214504
|
const content = await getFsImplementation().readFile(settingsJsonPath, { encoding: "utf-8" });
|
|
214516
214505
|
const parsed = jsonParse(content);
|
|
214517
|
-
if (
|
|
214506
|
+
if (isRecord3(parsed)) {
|
|
214518
214507
|
const filtered = parsePluginSettings(parsed);
|
|
214519
214508
|
if (filtered) {
|
|
214520
214509
|
logForDebugging(`Loaded settings from settings.json for plugin ${manifest.name}`);
|
|
@@ -215193,7 +215182,7 @@ function cachePluginSettings(plugins) {
|
|
|
215193
215182
|
logForDebugging(`Cached plugin settings with keys: ${Object.keys(settings).join(", ")}`);
|
|
215194
215183
|
}
|
|
215195
215184
|
}
|
|
215196
|
-
function
|
|
215185
|
+
function isRecord3(value) {
|
|
215197
215186
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
215198
215187
|
}
|
|
215199
215188
|
var PluginSettingsSchema, loadAllPlugins, loadAllPluginsCacheOnly;
|
|
@@ -217002,7 +216991,7 @@ async function performMCPOAuthFlow(serverName, serverConfig, onAuthorizationUrl,
|
|
|
217002
216991
|
}
|
|
217003
216992
|
if (code) {
|
|
217004
216993
|
res.writeHead(200, { "Content-Type": "text/html" });
|
|
217005
|
-
res.end(`<h1>Authentication Successful</h1><p>You can close this window. Return to
|
|
216994
|
+
res.end(`<h1>Authentication Successful</h1><p>You can close this window. Return to ${import_xss2.default(getBranding().productName)}.</p>`);
|
|
217006
216995
|
cleanup();
|
|
217007
216996
|
resolveOnce(code);
|
|
217008
216997
|
}
|
|
@@ -217168,7 +217157,7 @@ class ClaudeAuthProvider {
|
|
|
217168
217157
|
}
|
|
217169
217158
|
get clientMetadata() {
|
|
217170
217159
|
const metadata = {
|
|
217171
|
-
client_name:
|
|
217160
|
+
client_name: `${getBranding().productName} (${this.serverName})`,
|
|
217172
217161
|
redirect_uris: [this.redirectUri],
|
|
217173
217162
|
grant_types: ["authorization_code", "refresh_token"],
|
|
217174
217163
|
response_types: ["code"],
|
|
@@ -217187,7 +217176,7 @@ class ClaudeAuthProvider {
|
|
|
217187
217176
|
logMCPDebug(this.serverName, `Using CIMD URL from env: ${override}`);
|
|
217188
217177
|
return override;
|
|
217189
217178
|
}
|
|
217190
|
-
return
|
|
217179
|
+
return getBranding().mcpOAuthClientMetadataUrl;
|
|
217191
217180
|
}
|
|
217192
217181
|
setMetadata(metadata) {
|
|
217193
217182
|
this._metadata = metadata;
|
|
@@ -217755,7 +217744,7 @@ var init_auth6 = __esm(() => {
|
|
|
217755
217744
|
init_auth5();
|
|
217756
217745
|
init_errors8();
|
|
217757
217746
|
init_auth4();
|
|
217758
|
-
|
|
217747
|
+
init_branding();
|
|
217759
217748
|
init_browser();
|
|
217760
217749
|
init_envUtils();
|
|
217761
217750
|
init_errors5();
|
|
@@ -222655,7 +222644,7 @@ function isIncludedMcpTool(tool) {
|
|
|
222655
222644
|
return !tool.name.startsWith("mcp__ide__") || ALLOWED_IDE_TOOLS.includes(tool.name);
|
|
222656
222645
|
}
|
|
222657
222646
|
function getServerCacheKey(name, serverRef) {
|
|
222658
|
-
return `${name}-${jsonStringify(serverRef)}`;
|
|
222647
|
+
return `${name}-${jsonStringify(serverRef)}-${jsonStringify(getBranding())}`;
|
|
222659
222648
|
}
|
|
222660
222649
|
async function clearServerCache(name, serverRef) {
|
|
222661
222650
|
const key = getServerCacheKey(name, serverRef);
|
|
@@ -223270,6 +223259,7 @@ var init_client5 = __esm(() => {
|
|
|
223270
223259
|
ALLOWED_IDE_TOOLS = ["mcp__ide__executeCode", "mcp__ide__getDiagnostics"];
|
|
223271
223260
|
connectToServer = memoize_default(async (name, serverRef, serverStats) => {
|
|
223272
223261
|
const connectStartTime = Date.now();
|
|
223262
|
+
const cacheKey = getServerCacheKey(name, serverRef);
|
|
223273
223263
|
let inProcessServer;
|
|
223274
223264
|
try {
|
|
223275
223265
|
let transport;
|
|
@@ -223468,6 +223458,7 @@ var init_client5 = __esm(() => {
|
|
|
223468
223458
|
...subprocessEnv(),
|
|
223469
223459
|
...serverRef.env
|
|
223470
223460
|
},
|
|
223461
|
+
...serverRef.cwd ? { cwd: serverRef.cwd } : {},
|
|
223471
223462
|
stderr: "pipe"
|
|
223472
223463
|
});
|
|
223473
223464
|
} else {
|
|
@@ -223489,10 +223480,8 @@ var init_client5 = __esm(() => {
|
|
|
223489
223480
|
}
|
|
223490
223481
|
}
|
|
223491
223482
|
const client = new Client({
|
|
223492
|
-
name: TELEMETRY_SERVICE_NAME,
|
|
223493
223483
|
...getMcpClientInfo(),
|
|
223494
|
-
version: "99.0.0"
|
|
223495
|
-
websiteUrl: PRODUCT_URL
|
|
223484
|
+
version: "99.0.0"
|
|
223496
223485
|
}, {
|
|
223497
223486
|
capabilities: {
|
|
223498
223487
|
roots: {},
|
|
@@ -223702,12 +223691,11 @@ var init_client5 = __esm(() => {
|
|
|
223702
223691
|
const uptime = Date.now() - connectionStartTime;
|
|
223703
223692
|
const transportType = serverRef.type ?? "unknown";
|
|
223704
223693
|
logMCPDebug(name, `${transportType.toUpperCase()} connection closed after ${Math.floor(uptime / 1000)}s (${hasErrorOccurred ? "with errors" : "cleanly"})`);
|
|
223705
|
-
const key = getServerCacheKey(name, serverRef);
|
|
223706
223694
|
fetchToolsForClient.cache.delete(name);
|
|
223707
223695
|
fetchResourcesForClient.cache.delete(name);
|
|
223708
223696
|
fetchCommandsForClient.cache.delete(name);
|
|
223709
223697
|
if (false) {}
|
|
223710
|
-
connectToServer.cache.delete(
|
|
223698
|
+
connectToServer.cache.delete(cacheKey);
|
|
223711
223699
|
logMCPDebug(name, `Cleared connection cache for reconnection`);
|
|
223712
223700
|
if (originalOnclose) {
|
|
223713
223701
|
originalOnclose();
|
|
@@ -224315,12 +224303,11 @@ async function* runPostToolUseFailureHooks(toolUseContext, tool, toolUseID, mess
|
|
|
224315
224303
|
}
|
|
224316
224304
|
async function resolveHookPermissionDecision(hookPermissionResult, tool, input, toolUseContext, canUseTool, assistantMessage, toolUseID) {
|
|
224317
224305
|
const requiresInteraction = tool.requiresUserInteraction?.();
|
|
224318
|
-
const requireCanUseTool = toolUseContext.requireCanUseTool;
|
|
224319
224306
|
if (hookPermissionResult?.behavior === "allow") {
|
|
224320
224307
|
const hookInput = hookPermissionResult.updatedInput ?? input;
|
|
224321
224308
|
const interactionSatisfied = requiresInteraction && hookPermissionResult.updatedInput !== undefined;
|
|
224322
|
-
if (
|
|
224323
|
-
logForDebugging(`Hook approved tool use for ${tool.name},
|
|
224309
|
+
if (!interactionSatisfied) {
|
|
224310
|
+
logForDebugging(`Hook approved tool use for ${tool.name}, deferring final decision to canUseTool`);
|
|
224324
224311
|
return {
|
|
224325
224312
|
decision: await consumePermissionPreDecision(toolUseContext, toolUseID, hookInput, () => canUseTool(tool, hookInput, toolUseContext, assistantMessage, toolUseID)),
|
|
224326
224313
|
input: hookInput
|
|
@@ -224328,7 +224315,7 @@ async function resolveHookPermissionDecision(hookPermissionResult, tool, input,
|
|
|
224328
224315
|
}
|
|
224329
224316
|
const ruleCheck = await checkRuleBasedPermissions(tool, hookInput, toolUseContext);
|
|
224330
224317
|
if (ruleCheck === null) {
|
|
224331
|
-
logForDebugging(
|
|
224318
|
+
logForDebugging(`Hook satisfied user interaction for ${tool.name} via updatedInput`);
|
|
224332
224319
|
return { decision: hookPermissionResult, input: hookInput };
|
|
224333
224320
|
}
|
|
224334
224321
|
if (ruleCheck.behavior === "deny") {
|
|
@@ -227396,7 +227383,7 @@ function getAnthropicEnvMetadata() {
|
|
|
227396
227383
|
function getBuildAgeMinutes() {
|
|
227397
227384
|
if (false)
|
|
227398
227385
|
;
|
|
227399
|
-
const buildTime = new Date("2026-10-
|
|
227386
|
+
const buildTime = new Date("2026-10-24T12:55:52.344Z").getTime();
|
|
227400
227387
|
if (isNaN(buildTime))
|
|
227401
227388
|
return;
|
|
227402
227389
|
return Math.floor((Date.now() - buildTime) / 60000);
|
|
@@ -228594,6 +228581,15 @@ function buildPostCompactMessages(result) {
|
|
|
228594
228581
|
...result.hookResults
|
|
228595
228582
|
];
|
|
228596
228583
|
}
|
|
228584
|
+
function attachContextSnapshot(result) {
|
|
228585
|
+
if (!result.boundaryMarker?.compactMetadata)
|
|
228586
|
+
return result;
|
|
228587
|
+
const snapshot = buildContextSnapshot(buildPostCompactMessages(result));
|
|
228588
|
+
if (snapshot) {
|
|
228589
|
+
result.boundaryMarker.compactMetadata.contextSnapshot = snapshot;
|
|
228590
|
+
}
|
|
228591
|
+
return result;
|
|
228592
|
+
}
|
|
228597
228593
|
function annotateBoundaryWithPreservedSegment(boundary, anchorUuid, messagesToKeep) {
|
|
228598
228594
|
const keep = messagesToKeep ?? [];
|
|
228599
228595
|
if (keep.length === 0)
|
|
@@ -229164,6 +229160,7 @@ var init_compact = __esm(() => {
|
|
|
229164
229160
|
init_debug();
|
|
229165
229161
|
init_errors5();
|
|
229166
229162
|
init_fileStateCache();
|
|
229163
|
+
init_contextSnapshot();
|
|
229167
229164
|
init_forkedAgent();
|
|
229168
229165
|
init_hooks2();
|
|
229169
229166
|
init_log2();
|
|
@@ -229786,7 +229783,7 @@ async function autoCompactIfNeeded(messages, toolUseContext, cacheSafeParams, qu
|
|
|
229786
229783
|
markPostCompaction();
|
|
229787
229784
|
return {
|
|
229788
229785
|
wasCompacted: true,
|
|
229789
|
-
compactionResult: sessionMemoryResult
|
|
229786
|
+
compactionResult: attachContextSnapshot(sessionMemoryResult)
|
|
229790
229787
|
};
|
|
229791
229788
|
}
|
|
229792
229789
|
try {
|
|
@@ -229795,7 +229792,7 @@ async function autoCompactIfNeeded(messages, toolUseContext, cacheSafeParams, qu
|
|
|
229795
229792
|
runPostCompactCleanup(querySource);
|
|
229796
229793
|
return {
|
|
229797
229794
|
wasCompacted: true,
|
|
229798
|
-
compactionResult,
|
|
229795
|
+
compactionResult: attachContextSnapshot(compactionResult),
|
|
229799
229796
|
consecutiveFailures: 0
|
|
229800
229797
|
};
|
|
229801
229798
|
} catch (error) {
|
|
@@ -229820,13 +229817,19 @@ async function manualCompact(messages, toolUseContext, cacheSafeParams, instruct
|
|
|
229820
229817
|
setLastSummarizedMessageId(undefined);
|
|
229821
229818
|
runPostCompactCleanup();
|
|
229822
229819
|
markPostCompaction();
|
|
229823
|
-
return {
|
|
229820
|
+
return {
|
|
229821
|
+
wasCompacted: true,
|
|
229822
|
+
compactionResult: attachContextSnapshot(sessionMemoryResult)
|
|
229823
|
+
};
|
|
229824
229824
|
}
|
|
229825
229825
|
}
|
|
229826
229826
|
const compactionResult = await deps.compactConversation(messages, toolUseContext, cacheSafeParams, false, instructions, false);
|
|
229827
229827
|
setLastSummarizedMessageId(undefined);
|
|
229828
229828
|
runPostCompactCleanup();
|
|
229829
|
-
return {
|
|
229829
|
+
return {
|
|
229830
|
+
wasCompacted: true,
|
|
229831
|
+
compactionResult: attachContextSnapshot(compactionResult)
|
|
229832
|
+
};
|
|
229830
229833
|
}
|
|
229831
229834
|
var MAX_OUTPUT_TOKENS_FOR_SUMMARY = 20000, AUTOCOMPACT_BUFFER_TOKENS = 13000, WARNING_THRESHOLD_BUFFER_TOKENS = 20000, ERROR_THRESHOLD_BUFFER_TOKENS = 20000, MANUAL_COMPACT_BUFFER_TOKENS = 3000, MAX_CONSECUTIVE_AUTOCOMPACT_FAILURES = 3;
|
|
229832
229835
|
var init_autoCompact = __esm(() => {
|
|
@@ -238878,12 +238881,15 @@ ${deferredToolList}
|
|
|
238878
238881
|
throw new Error("Stream idle timeout - no chunks received");
|
|
238879
238882
|
}
|
|
238880
238883
|
if (!partialMessage || newMessages.length === 0 && !stopReason) {
|
|
238881
|
-
logForDebugging(!partialMessage ? "Stream completed without receiving message_start event - triggering non-streaming fallback" : "Stream completed with message_start but no content blocks completed -
|
|
238884
|
+
logForDebugging(!partialMessage ? "Stream completed without receiving message_start event - triggering non-streaming fallback" : "Stream completed with message_start but no content blocks completed - incomplete stream", { level: "error" });
|
|
238882
238885
|
logEvent("tengu_stream_no_events", {
|
|
238883
238886
|
model: options.model,
|
|
238884
238887
|
request_id: streamRequestId ?? "unknown"
|
|
238885
238888
|
});
|
|
238886
|
-
|
|
238889
|
+
if (!partialMessage) {
|
|
238890
|
+
throw new Error("Stream ended without receiving any events");
|
|
238891
|
+
}
|
|
238892
|
+
throw new EmptyStreamError;
|
|
238887
238893
|
}
|
|
238888
238894
|
if (stallCount > 0) {
|
|
238889
238895
|
logForDebugging(`Streaming completed with ${stallCount} stall(s), total stall time: ${(totalStallTime / 1000).toFixed(1)}s`, { level: "warn" });
|
|
@@ -238928,6 +238934,9 @@ ${deferredToolList}
|
|
|
238928
238934
|
throw new APIConnectionTimeoutError({ message: "Request timed out" });
|
|
238929
238935
|
}
|
|
238930
238936
|
}
|
|
238937
|
+
if (options.streamReplayEscape && newMessages.length === 0 && !signal.aborted && toReplayableStreamError(streamingError)) {
|
|
238938
|
+
throw streamingError;
|
|
238939
|
+
}
|
|
238931
238940
|
const disableFallback = isEnvTruthy(resolveEnvVar("DISABLE_NONSTREAMING_FALLBACK")) || getFeatureValue_CACHED_MAY_BE_STALE("tengu_disable_streaming_to_non_streaming_fallback", false);
|
|
238932
238941
|
if (disableFallback) {
|
|
238933
238942
|
logForDebugging(`Error streaming (non-streaming fallback disabled): ${errorMessage(streamingError)}`, { level: "error" });
|
|
@@ -241214,7 +241223,7 @@ function AUTO_REJECT_MESSAGE(toolName) {
|
|
|
241214
241223
|
return `Permission to use ${toolName} has been denied. ${DENIAL_WORKAROUND_GUIDANCE}`;
|
|
241215
241224
|
}
|
|
241216
241225
|
function DONT_ASK_REJECT_MESSAGE(toolName) {
|
|
241217
|
-
return `Permission to use ${toolName} has been denied because
|
|
241226
|
+
return `Permission to use ${toolName} has been denied because ${getBranding().productName} is running in don't ask mode. ${DENIAL_WORKAROUND_GUIDANCE}`;
|
|
241218
241227
|
}
|
|
241219
241228
|
function isSyntheticMessage(message) {
|
|
241220
241229
|
return message.type !== "progress" && message.type !== "attachment" && message.type !== "system" && Array.isArray(message.message.content) && message.message.content[0]?.type === "text" && SYNTHETIC_MESSAGES.has(message.message.content[0].text);
|
|
@@ -243971,6 +243980,7 @@ var init_messages4 = __esm(() => {
|
|
|
243971
243980
|
init_tasks();
|
|
243972
243981
|
init_toolSearch();
|
|
243973
243982
|
init_state2();
|
|
243983
|
+
init_branding();
|
|
243974
243984
|
DENIAL_WORKAROUND_GUIDANCE = `IMPORTANT: You *may* attempt to accomplish this action using other tools that might naturally be used to accomplish this goal, ` + `e.g. using head instead of cat. But you *should not* attempt to work around this denial in malicious ways, ` + `e.g. do not use your ability to run tests to execute non-test actions. ` + `You should only try to work around this restriction in reasonable ways that do not attempt to bypass the intent behind this denial. ` + `If you believe this capability is essential to complete the user's request, STOP and explain to the user ` + `what you were trying to do and why you need this permission. Let the user decide how to proceed.`;
|
|
243975
243985
|
SYNTHETIC_MESSAGES = new Set([
|
|
243976
243986
|
INTERRUPT_MESSAGE,
|
|
@@ -270789,6 +270799,9 @@ function toSDKCompactMetadata(meta) {
|
|
|
270789
270799
|
trigger: meta.trigger,
|
|
270790
270800
|
pre_tokens: meta.preTokens,
|
|
270791
270801
|
...meta.postTokens !== undefined && { post_tokens: meta.postTokens },
|
|
270802
|
+
...meta.contextSnapshot !== undefined && {
|
|
270803
|
+
context_snapshot: meta.contextSnapshot
|
|
270804
|
+
},
|
|
270792
270805
|
...seg && {
|
|
270793
270806
|
preserved_segment: {
|
|
270794
270807
|
head_uuid: seg.headUuid,
|
|
@@ -273041,6 +273054,7 @@ function registerSdkInlineSkillHandler() {
|
|
|
273041
273054
|
init_backgroundAbortRegistry();
|
|
273042
273055
|
init_backgroundTaskScope();
|
|
273043
273056
|
init_sessionStorage();
|
|
273057
|
+
init_contextSnapshot();
|
|
273044
273058
|
init_branding();
|
|
273045
273059
|
init_hooks2();
|
|
273046
273060
|
init_debug();
|
|
@@ -273327,10 +273341,11 @@ init_http2();
|
|
|
273327
273341
|
init_log2();
|
|
273328
273342
|
init_state2();
|
|
273329
273343
|
init_mcpOutputStorage();
|
|
273344
|
+
init_branding();
|
|
273330
273345
|
init_settings2();
|
|
273331
273346
|
class DomainBlockedError extends Error {
|
|
273332
273347
|
constructor(domain) {
|
|
273333
|
-
super(
|
|
273348
|
+
super(`${getBranding().productName} is unable to fetch from ${domain}`);
|
|
273334
273349
|
this.name = "DomainBlockedError";
|
|
273335
273350
|
}
|
|
273336
273351
|
}
|
|
@@ -278673,6 +278688,7 @@ async function stageManagedPluginSnapshot(snapshot, appliedState) {
|
|
|
278673
278688
|
try {
|
|
278674
278689
|
for (const plugin of snapshot.plugins)
|
|
278675
278690
|
validateManagedPlugin(plugin);
|
|
278691
|
+
const contentVariables = validateContentVariables(snapshot.contentVariables);
|
|
278676
278692
|
const bundle = await stageResolvedPlugins(snapshot.revision, snapshot.plugins.map((plugin) => ({
|
|
278677
278693
|
id: plugin.id,
|
|
278678
278694
|
path: plugin.source.path,
|
|
@@ -278682,7 +278698,7 @@ async function stageManagedPluginSnapshot(snapshot, appliedState) {
|
|
|
278682
278698
|
})));
|
|
278683
278699
|
return {
|
|
278684
278700
|
status: "staged",
|
|
278685
|
-
bundle,
|
|
278701
|
+
bundle: { ...bundle, contentVariables },
|
|
278686
278702
|
result: {
|
|
278687
278703
|
status: "applied",
|
|
278688
278704
|
requestedRevision: snapshot.revision,
|
|
@@ -278712,6 +278728,20 @@ async function inspectPluginSnapshot(snapshot) {
|
|
|
278712
278728
|
return rejectResult(snapshot.revision, appliedState, error);
|
|
278713
278729
|
}
|
|
278714
278730
|
}
|
|
278731
|
+
var CONTENT_VARIABLE_NAME = /^[A-Z][A-Z0-9_]*$/;
|
|
278732
|
+
function validateContentVariables(variables) {
|
|
278733
|
+
if (!variables)
|
|
278734
|
+
return {};
|
|
278735
|
+
for (const [name, value] of Object.entries(variables)) {
|
|
278736
|
+
if (!CONTENT_VARIABLE_NAME.test(name)) {
|
|
278737
|
+
throw new Error(`Invalid plugin content variable name: ${name}`);
|
|
278738
|
+
}
|
|
278739
|
+
if (typeof value !== "string") {
|
|
278740
|
+
throw new Error(`Plugin content variable ${name} must be a string`);
|
|
278741
|
+
}
|
|
278742
|
+
}
|
|
278743
|
+
return Object.freeze({ ...variables });
|
|
278744
|
+
}
|
|
278715
278745
|
function validateManagedPlugin(plugin) {
|
|
278716
278746
|
if (plugin.source.type !== "local")
|
|
278717
278747
|
throw new Error(`Unsupported plugin source for ${plugin.id}`);
|
|
@@ -279060,7 +279090,9 @@ function runSdkQueryRuntime(params) {
|
|
|
279060
279090
|
const appStateStore = buildAppStateStore(applyFileCheckpointingInitialState(applyDisallowedTools(applyPermissionMode(getDefaultAppState(), options.permissionMode), options.disallowedTools), options.fileCheckpointing?.initialState), fileCheckpointingOnChange);
|
|
279061
279091
|
const releaseBackgroundTaskScope = bindBackgroundTaskScope(appStateStore.setAppState, ownership.backgroundTaskScope);
|
|
279062
279092
|
const initialMessagesForReplay = options.resume ? loadAndRestampHistoricalMessages(options.resume, queryContext.identity.sessionId, options.initialMessages) : options.initialMessages;
|
|
279063
|
-
|
|
279093
|
+
const contextSnapshot = options.initialContextSnapshot === undefined ? undefined : normalizeContextSnapshot(options.initialContextSnapshot);
|
|
279094
|
+
const initialMessages = normalizeInitialMessages(initialMessagesForReplay);
|
|
279095
|
+
let mutableMessages = contextSnapshot ? [...contextSnapshot.messages, ...initialMessages] : initialMessages;
|
|
279064
279096
|
let readFileCache = createFileStateCacheWithSizeLimit(DEFAULT_READ_FILE_CACHE_SIZE);
|
|
279065
279097
|
const dynamicClients = [];
|
|
279066
279098
|
const sdkClients = [];
|
|
@@ -279124,7 +279156,6 @@ function runSdkQueryRuntime(params) {
|
|
|
279124
279156
|
const [clientTransport, serverTransport] = createLinkedTransportPair();
|
|
279125
279157
|
await inProcessServer.connect(serverTransport);
|
|
279126
279158
|
const client = new Client({
|
|
279127
|
-
name: "claude-code",
|
|
279128
279159
|
...getMcpClientInfo(),
|
|
279129
279160
|
version: "99.0.0"
|
|
279130
279161
|
}, {
|
|
@@ -279165,7 +279196,7 @@ function runSdkQueryRuntime(params) {
|
|
|
279165
279196
|
activePluginBundle = await stageStaticLocalPlugins(options.plugins, cwd);
|
|
279166
279197
|
}
|
|
279167
279198
|
if (activePluginBundle) {
|
|
279168
|
-
|
|
279199
|
+
setExplicitPluginRuntimeBundle(activePluginBundle);
|
|
279169
279200
|
registerHookCallbacks2(activePluginBundle.hooks);
|
|
279170
279201
|
}
|
|
279171
279202
|
const shellCapabilities = await initializeShellCapabilities();
|
|
@@ -279565,7 +279596,7 @@ class SessionRuntime {
|
|
|
279565
279596
|
this.projectContextIds.add(ctx.identity.sessionId);
|
|
279566
279597
|
await runWithQueryContext(ctx, async () => {
|
|
279567
279598
|
if (this.pluginBundle) {
|
|
279568
|
-
|
|
279599
|
+
setExplicitPluginRuntimeBundle(this.pluginBundle);
|
|
279569
279600
|
registerHookCallbacks2(this.pluginBundle.hooks);
|
|
279570
279601
|
}
|
|
279571
279602
|
if (this.baseOptions.hooks) {
|
|
@@ -280584,4 +280615,4 @@ export {
|
|
|
280584
280615
|
watchScheduledTasks
|
|
280585
280616
|
};
|
|
280586
280617
|
|
|
280587
|
-
//# debugId=
|
|
280618
|
+
//# debugId=E18A4788D5E5D36064756E2164756E21
|