@rayss-dev/openclaude 0.29.2-by-rayss → 0.30.1-by-rayss

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.
Files changed (4) hide show
  1. package/dist/acp.mjs +493 -138
  2. package/dist/cli.mjs +45 -45
  3. package/dist/sdk.mjs +413 -114
  4. package/package.json +225 -225
package/dist/sdk.mjs CHANGED
@@ -9434,7 +9434,7 @@ var init_version = __esm(() => {
9434
9434
  import_semver = __toESM(require_semver2(), 1);
9435
9435
  fallbackBuildVersion = (() => {
9436
9436
  try {
9437
- return "0.29.2-by-rayss";
9437
+ return "0.30.1-by-rayss";
9438
9438
  } catch {
9439
9439
  return "0.0.0";
9440
9440
  }
@@ -9443,6 +9443,28 @@ var init_version = __esm(() => {
9443
9443
  });
9444
9444
 
9445
9445
  // src/integrations/aimlapi/config.ts
9446
+ function isManagedAttributionHeaderName(name) {
9447
+ return AIMLAPI_MANAGED_ATTRIBUTION_HEADER_NAMES.has(name.trim().toLowerCase());
9448
+ }
9449
+ function omitManagedAttributionHeaders(headers) {
9450
+ const resolved = {};
9451
+ for (const [name, value] of Object.entries(headers)) {
9452
+ if (isManagedAttributionHeaderName(name))
9453
+ continue;
9454
+ resolved[name] = value;
9455
+ }
9456
+ return resolved;
9457
+ }
9458
+ function collectManagedAttributionValues(headers) {
9459
+ const collected = new Map;
9460
+ for (const [name, value] of Object.entries(headers)) {
9461
+ const key = name.trim().toLowerCase();
9462
+ if (AIMLAPI_MANAGED_ATTRIBUTION_HEADER_NAMES.has(key)) {
9463
+ collected.set(key, value);
9464
+ }
9465
+ }
9466
+ return collected;
9467
+ }
9446
9468
  function resolvePartnerId() {
9447
9469
  return DEFAULT_PARTNER_ID;
9448
9470
  }
@@ -9475,12 +9497,27 @@ function isCanonicalAimlapiInferenceBaseUrl(value) {
9475
9497
  return canonical !== null && candidate !== null && candidate.origin === canonical.origin && candidate.pathname === canonical.pathname;
9476
9498
  }
9477
9499
  function resolveAimlapiAttributionHeaders(headers, baseUrl) {
9500
+ const rest = omitManagedAttributionHeaders(headers);
9478
9501
  if (!baseUrl || isCanonicalAimlapiInferenceBaseUrl(baseUrl)) {
9479
- return { ...withResolvedPartnerHeader(headers), [SOURCE_HEADER_NAME]: AIMLAPI_SOURCE };
9502
+ const collected = collectManagedAttributionValues(headers);
9503
+ const managed = {
9504
+ [PARTNER_HEADER_NAME]: resolvePartnerId(),
9505
+ [SOURCE_HEADER_NAME]: AIMLAPI_SOURCE
9506
+ };
9507
+ for (const [key, canonical] of Object.entries(MANAGED_ATTRIBUTION_HEADER_CANONICAL_NAMES)) {
9508
+ if (key === PARTNER_HEADER_NAME.toLowerCase() || key === SOURCE_HEADER_NAME.toLowerCase()) {
9509
+ continue;
9510
+ }
9511
+ const value = collected.get(key);
9512
+ if (value !== undefined) {
9513
+ managed[canonical] = value;
9514
+ }
9515
+ }
9516
+ return { ...rest, ...managed };
9480
9517
  }
9481
- return Object.fromEntries(Object.entries(headers).filter(([name]) => !CATALOG_ATTRIBUTION_HEADER_NAMES.has(name.trim().toLowerCase())));
9518
+ return rest;
9482
9519
  }
9483
- var DEFAULT_ENDPOINTS, DEFAULT_PARTNER_ID = "part_62yQoGYDq4Yqnrj2R1iGrDNJ", PARTNER_HEADER_NAME = "X-AIMLAPI-Partner-ID", SOURCE_HEADER_NAME = "X-AIMLAPI-Source", AIMLAPI_SOURCE = "agent/openclaude", CATALOG_ATTRIBUTION_HEADER_NAMES;
9520
+ var DEFAULT_ENDPOINTS, DEFAULT_PARTNER_ID = "part_62yQoGYDq4Yqnrj2R1iGrDNJ", PARTNER_HEADER_NAME = "X-AIMLAPI-Partner-ID", SOURCE_HEADER_NAME = "X-AIMLAPI-Source", INTEGRATION_REPO_HEADER_NAME = "X-AIMLAPI-Integration-Repo", INTEGRATION_VERSION_HEADER_NAME = "X-AIMLAPI-Integration-Version", REFERER_HEADER_NAME = "HTTP-Referer", TITLE_HEADER_NAME = "X-Title", MANAGED_ATTRIBUTION_HEADER_CANONICAL_NAMES, AIMLAPI_MANAGED_ATTRIBUTION_HEADER_NAMES, AIMLAPI_SOURCE = "agent/openclaude";
9484
9521
  var init_config = __esm(() => {
9485
9522
  DEFAULT_ENDPOINTS = {
9486
9523
  authBaseUrl: "https://auth.aimlapi.com",
@@ -9489,14 +9526,15 @@ var init_config = __esm(() => {
9489
9526
  inferenceBaseUrl: "https://api.aimlapi.com/v1",
9490
9527
  verificationBaseUrl: "https://aimlapi.com/app"
9491
9528
  };
9492
- CATALOG_ATTRIBUTION_HEADER_NAMES = new Set([
9493
- PARTNER_HEADER_NAME.toLowerCase(),
9494
- SOURCE_HEADER_NAME.toLowerCase(),
9495
- "x-aimlapi-integration-repo",
9496
- "x-aimlapi-integration-version",
9497
- "http-referer",
9498
- "x-title"
9499
- ]);
9529
+ MANAGED_ATTRIBUTION_HEADER_CANONICAL_NAMES = {
9530
+ [PARTNER_HEADER_NAME.toLowerCase()]: PARTNER_HEADER_NAME,
9531
+ [SOURCE_HEADER_NAME.toLowerCase()]: SOURCE_HEADER_NAME,
9532
+ [INTEGRATION_REPO_HEADER_NAME.toLowerCase()]: INTEGRATION_REPO_HEADER_NAME,
9533
+ [INTEGRATION_VERSION_HEADER_NAME.toLowerCase()]: INTEGRATION_VERSION_HEADER_NAME,
9534
+ [REFERER_HEADER_NAME.toLowerCase()]: REFERER_HEADER_NAME,
9535
+ [TITLE_HEADER_NAME.toLowerCase()]: TITLE_HEADER_NAME
9536
+ };
9537
+ AIMLAPI_MANAGED_ATTRIBUTION_HEADER_NAMES = new Set(Object.keys(MANAGED_ATTRIBUTION_HEADER_CANONICAL_NAMES));
9500
9538
  });
9501
9539
 
9502
9540
  // src/integrations/gateways/aimlapi.ts
@@ -64716,7 +64754,7 @@ var init_schemas3 = __esm(() => {
64716
64754
  }),
64717
64755
  exports_external.object({
64718
64756
  source: exports_external.literal("hostPattern"),
64719
- hostPattern: exports_external.string().describe("Regex pattern to match the host/domain extracted from any marketplace source type. " + 'For github sources, matches against "github.com". For git sources (SSH or HTTPS), ' + "extracts the hostname from the URL. Use in strictKnownMarketplaces to allow all " + 'marketplaces from a specific host (e.g., "^github\\.mycompany\\.com$").')
64757
+ hostPattern: exports_external.string().describe("Regex pattern to match the host/domain extracted from any marketplace source type. " + 'For github sources, matches against "github.com". For git sources (SSH or HTTPS), ' + "extracts the hostname from the URL. Use in strictKnownMarketplaces to allow all " + 'marketplaces from a specific host (e.g., "^github\\.mycompany\\.com$"). ' + "The pattern must match the ENTIRE host: it is anchored before use, so " + '"github\\.mycompany\\.com" cannot be satisfied by a lookalike host such as ' + '"github.mycompany.com.evil.example". Use an explicit wildcard (e.g. ' + '".*\\.mycompany\\.com") to allow subdomains.')
64720
64758
  }),
64721
64759
  exports_external.object({
64722
64760
  source: exports_external.literal("pathPattern"),
@@ -65100,7 +65138,7 @@ function isBashPrefixTool(toolName) {
65100
65138
  return TOOL_VALIDATION_CONFIG.bashPrefixTools.includes(toolName);
65101
65139
  }
65102
65140
  function getCustomValidation(toolName) {
65103
- return TOOL_VALIDATION_CONFIG.customValidation[toolName];
65141
+ return Object.hasOwn(TOOL_VALIDATION_CONFIG.customValidation, toolName) ? TOOL_VALIDATION_CONFIG.customValidation[toolName] : undefined;
65104
65142
  }
65105
65143
  var TOOL_VALIDATION_CONFIG;
65106
65144
  var init_toolValidationConfig = __esm(() => {
@@ -67553,9 +67591,13 @@ function getRouteDiscoveryHeaders(routeId, options) {
67553
67591
  ...transportConfig?.headers ?? {},
67554
67592
  ...transportConfig?.openaiShim?.headers ?? {}
67555
67593
  };
67556
- const headers = {
67557
- ...routeId === "aimlapi" ? resolveAimlapiAttributionHeaders(descriptorHeaders, getRouteBaseUrl(routeId, options)) : descriptorHeaders,
67558
- ...options?.headers ?? {}
67594
+ const callerHeaders = options?.headers ?? {};
67595
+ const headers = routeId === "aimlapi" ? resolveAimlapiAttributionHeaders({
67596
+ ...callerHeaders,
67597
+ ...descriptorHeaders
67598
+ }, getRouteBaseUrl(routeId, options)) : {
67599
+ ...descriptorHeaders,
67600
+ ...callerHeaders
67559
67601
  };
67560
67602
  return Object.keys(headers).length > 0 ? headers : undefined;
67561
67603
  }
@@ -69098,17 +69140,17 @@ function isAttributionHeaderEnabled() {
69098
69140
  }
69099
69141
  return getFeatureValue_CACHED_MAY_BE_STALE("tengu_attribution_header", true);
69100
69142
  }
69101
- function getAttributionHeader(fingerprint) {
69102
- if (!isAttributionHeaderEnabled()) {
69143
+ function getAttributionHeader(fingerprint, policy) {
69144
+ if (!policy.generate) {
69103
69145
  return "";
69104
69146
  }
69105
- const version2 = `${"0.29.2-by-rayss"}.${fingerprint}`;
69147
+ const version2 = `${"0.30.1-by-rayss"}.${fingerprint}`;
69106
69148
  const entrypoint = process.env.CLAUDE_CODE_ENTRYPOINT ?? "unknown";
69107
69149
  const cch = "";
69108
69150
  const workload = getWorkload();
69109
69151
  const workloadPair = workload ? ` cc_workload=${workload};` : "";
69110
69152
  const header = `x-anthropic-billing-header: cc_version=${version2}; cc_entrypoint=${entrypoint};${cch}${workloadPair}`;
69111
- logForDebugging(`attribution header ${header}`);
69153
+ logForDebugging(`attribution header generated: ${policy.reason}`);
69112
69154
  return header;
69113
69155
  }
69114
69156
  var DEFAULT_PREFIX, AGENT_SDK_CLAUDE_CODE_PRESET_PREFIX, AGENT_SDK_PREFIX, CLI_SYSPROMPT_PREFIX_VALUES, CLI_SYSPROMPT_PREFIXES;
@@ -99912,6 +99954,7 @@ __export(exports_auth, {
99912
99954
  isOverageProvisioningAllowed: () => isOverageProvisioningAllowed,
99913
99955
  isOtelHeadersHelperFromProjectOrLocalSettings: () => isOtelHeadersHelperFromProjectOrLocalSettings,
99914
99956
  isMaxSubscriber: () => isMaxSubscriber,
99957
+ isManagedOAuthContext: () => isManagedOAuthContext,
99915
99958
  isGcpAuthRefreshFromProjectSettings: () => isGcpAuthRefreshFromProjectSettings,
99916
99959
  isEnterpriseSubscriber: () => isEnterpriseSubscriber,
99917
99960
  isCustomApiKeyApproved: () => isCustomApiKeyApproved,
@@ -99953,7 +99996,7 @@ import { exec } from "child_process";
99953
99996
  import { mkdir as mkdir3, stat as stat5 } from "fs/promises";
99954
99997
  import { join as join32 } from "path";
99955
99998
  function isManagedOAuthContext() {
99956
- return isEnvTruthy(process.env.CLAUDE_CODE_REMOTE) || process.env.CLAUDE_CODE_ENTRYPOINT === "claude-desktop";
99999
+ return isEnvTruthy(process.env.CLAUDE_CODE_REMOTE) || process.env.CLAUDE_CODE_ENTRYPOINT === "claude-desktop" || !!process.env.ANTHROPIC_UNIX_SOCKET && !!process.env.CLAUDE_CODE_OAUTH_TOKEN;
99957
100000
  }
99958
100001
  function isAnthropicAuthEnabled() {
99959
100002
  if (isBareMode())
@@ -102666,7 +102709,7 @@ var init_metadata = __esm(() => {
102666
102709
  COMPOUND_OPERATOR_REGEX = /\s*(?:&&|\|\||[;|])\s*/;
102667
102710
  WHITESPACE_REGEX = /\s+/;
102668
102711
  getVersionBase = memoize_default(() => {
102669
- const match = "0.29.2-by-rayss".match(/^\d+\.\d+\.\d+(?:-[a-z]+)?/);
102712
+ const match = "0.30.1-by-rayss".match(/^\d+\.\d+\.\d+(?:-[a-z]+)?/);
102670
102713
  return match ? match[0] : undefined;
102671
102714
  });
102672
102715
  buildEnvContext = memoize_default(async () => {
@@ -102706,9 +102749,9 @@ var init_metadata = __esm(() => {
102706
102749
  isGithubAction: isEnvTruthy(process.env.GITHUB_ACTIONS),
102707
102750
  isClaudeCodeAction: isEnvTruthy(process.env.CLAUDE_CODE_ACTION),
102708
102751
  isClaudeAiAuth: isClaudeAISubscriber(),
102709
- version: "0.29.2-by-rayss",
102752
+ version: "0.30.1-by-rayss",
102710
102753
  versionBase: getVersionBase(),
102711
- buildTime: "2026-08-28T02:14:46.317Z",
102754
+ buildTime: "2026-09-01T07:43:33.328Z",
102712
102755
  deploymentEnvironment: env2.detectDeploymentEnvironment(),
102713
102756
  ...isEnvTruthy(process.env.GITHUB_ACTIONS) && {
102714
102757
  githubEventName: process.env.GITHUB_EVENT_NAME,
@@ -111431,7 +111474,7 @@ var init_effort = __esm(() => {
111431
111474
 
111432
111475
  // src/utils/userAgent.ts
111433
111476
  function getClaudeCodeUserAgent() {
111434
- return `claude-code/${"0.29.2-by-rayss"}`;
111477
+ return `claude-code/${"0.30.1-by-rayss"}`;
111435
111478
  }
111436
111479
 
111437
111480
  // src/utils/http.ts
@@ -111440,7 +111483,7 @@ function getUserAgent() {
111440
111483
  const clientApp = process.env.CLAUDE_AGENT_SDK_CLIENT_APP ? `, client-app/${process.env.CLAUDE_AGENT_SDK_CLIENT_APP}` : "";
111441
111484
  const workload = getWorkload();
111442
111485
  const workloadSuffix = workload ? `, workload/${workload}` : "";
111443
- return `claude-cli/${"0.29.2-by-rayss"} (${process.env.USER_TYPE}, ${process.env.CLAUDE_CODE_ENTRYPOINT ?? "cli"}${agentSdkVersion}${clientApp}${workloadSuffix})`;
111486
+ return `claude-cli/${"0.30.1-by-rayss"} (${process.env.USER_TYPE}, ${process.env.CLAUDE_CODE_ENTRYPOINT ?? "cli"}${agentSdkVersion}${clientApp}${workloadSuffix})`;
111444
111487
  }
111445
111488
  function getMCPUserAgent() {
111446
111489
  const parts = [];
@@ -111454,7 +111497,7 @@ function getMCPUserAgent() {
111454
111497
  parts.push(`client-app/${process.env.CLAUDE_AGENT_SDK_CLIENT_APP}`);
111455
111498
  }
111456
111499
  const suffix = parts.length > 0 ? ` (${parts.join(", ")})` : "";
111457
- return `claude-code/${"0.29.2-by-rayss"}${suffix}`;
111500
+ return `claude-code/${"0.30.1-by-rayss"}${suffix}`;
111458
111501
  }
111459
111502
  function getWebFetchUserAgent() {
111460
111503
  const supportUrl = isFirstPartyAnthropicProvider() ? "https://support.anthropic.com/" : "https://github.com/rayss868/openclaude";
@@ -111467,7 +111510,188 @@ var init_http2 = __esm(() => {
111467
111510
  init_workloadContext();
111468
111511
  });
111469
111512
 
111513
+ // src/utils/anthropicAttribution.ts
111514
+ function resolveAnthropicAttributionAuth({
111515
+ apiKey,
111516
+ authToken,
111517
+ isSubscriber
111518
+ }) {
111519
+ if (apiKey === "external" || authToken === "api_key")
111520
+ return "api_key";
111521
+ if (authToken === "oauth" && isSubscriber)
111522
+ return "oauth_subscription";
111523
+ if (apiKey === "managed")
111524
+ return "api_key";
111525
+ return "unknown";
111526
+ }
111527
+ function resolveAnthropicAttributionPolicy({
111528
+ route,
111529
+ auth,
111530
+ attributionEnabled
111531
+ }) {
111532
+ if (route === "unknown") {
111533
+ return { generate: false, retain: false, reason: "unknown_route" };
111534
+ }
111535
+ if (route !== "official_anthropic") {
111536
+ return { generate: false, retain: false, reason: "non_official_route" };
111537
+ }
111538
+ if (auth === "oauth_subscription") {
111539
+ return {
111540
+ generate: true,
111541
+ retain: true,
111542
+ reason: "official_oauth_required"
111543
+ };
111544
+ }
111545
+ if (auth === "api_key") {
111546
+ return attributionEnabled ? {
111547
+ generate: true,
111548
+ retain: true,
111549
+ reason: "official_api_key_enabled"
111550
+ } : {
111551
+ generate: false,
111552
+ retain: false,
111553
+ reason: "official_api_key_disabled"
111554
+ };
111555
+ }
111556
+ return attributionEnabled ? {
111557
+ generate: true,
111558
+ retain: true,
111559
+ reason: "official_auth_unknown_enabled"
111560
+ } : {
111561
+ generate: false,
111562
+ retain: false,
111563
+ reason: "official_auth_unknown_disabled"
111564
+ };
111565
+ }
111566
+ function isAnthropicBillingAttributionBlock(text) {
111567
+ return text?.startsWith(ANTHROPIC_BILLING_ATTRIBUTION_PREFIX) ?? false;
111568
+ }
111569
+ function getAttributionBlockText(block) {
111570
+ if (typeof block === "string")
111571
+ return block;
111572
+ return block.type === undefined || block.type === "text" ? block.text : undefined;
111573
+ }
111574
+ function applyAnthropicAttributionPolicy(blocks, policy) {
111575
+ let retainedAttribution = false;
111576
+ return blocks.filter((block) => {
111577
+ if (!isAnthropicBillingAttributionBlock(getAttributionBlockText(block))) {
111578
+ return true;
111579
+ }
111580
+ if (!policy.retain || retainedAttribution)
111581
+ return false;
111582
+ retainedAttribution = true;
111583
+ return true;
111584
+ });
111585
+ }
111586
+ function getAnthropicAttributionDiagnostic(policy) {
111587
+ switch (policy.reason) {
111588
+ case "unknown_route":
111589
+ return "[anthropic-attribution] disabled for an unresolved request route";
111590
+ case "official_auth_unknown_enabled":
111591
+ case "official_auth_unknown_disabled":
111592
+ return "[anthropic-attribution] preserved the configured setting for ambiguous official auth";
111593
+ default:
111594
+ return null;
111595
+ }
111596
+ }
111597
+ var ANTHROPIC_BILLING_ATTRIBUTION_PREFIX = "x-anthropic-billing-header";
111598
+
111470
111599
  // src/services/api/authRouting.ts
111600
+ function resolveAnthropicAttributionAuthTokenSource(authTokenSource, managedOAuthContext) {
111601
+ if (managedOAuthContext && (authTokenSource === "ANTHROPIC_AUTH_TOKEN" || authTokenSource === "apiKeyHelper")) {
111602
+ return "none";
111603
+ }
111604
+ if (authTokenSource === "ANTHROPIC_AUTH_TOKEN" || authTokenSource === "apiKeyHelper") {
111605
+ return "api_key";
111606
+ }
111607
+ if (authTokenSource === "CLAUDE_CODE_OAUTH_TOKEN" || authTokenSource === "CLAUDE_CODE_OAUTH_TOKEN_FILE_DESCRIPTOR" || authTokenSource === "CCR_OAUTH_TOKEN_FILE" || authTokenSource === "claude.ai") {
111608
+ return "oauth";
111609
+ }
111610
+ return "none";
111611
+ }
111612
+ function isManagedOAuthEffective(authTokenSource, managedOAuthContext, bareMode) {
111613
+ return managedOAuthContext && !bareMode && resolveAnthropicAttributionAuthTokenSource(authTokenSource, false) === "oauth";
111614
+ }
111615
+ function resolveAnthropicAttributionAuthFromSources({
111616
+ apiKeySource,
111617
+ authTokenSource,
111618
+ bareMode,
111619
+ isSubscriber,
111620
+ managedOAuthContext
111621
+ }) {
111622
+ const managedOAuthIsEffective = isManagedOAuthEffective(authTokenSource, managedOAuthContext, bareMode);
111623
+ const apiKey = managedOAuthIsEffective ? "none" : apiKeySource === "ANTHROPIC_API_KEY" || apiKeySource === "apiKeyHelper" ? "external" : apiKeySource === "/login managed key" ? "managed" : "none";
111624
+ const authToken = resolveAnthropicAttributionAuthTokenSource(authTokenSource, managedOAuthIsEffective);
111625
+ return resolveAnthropicAttributionAuth({
111626
+ apiKey,
111627
+ authToken,
111628
+ isSubscriber
111629
+ });
111630
+ }
111631
+ function resolveCurrentAnthropicAttributionAuth() {
111632
+ let apiKeySource = "none";
111633
+ try {
111634
+ ({ source: apiKeySource } = getAnthropicApiKeyWithSource({
111635
+ skipRetrievingKeyFromApiKeyHelper: true
111636
+ }));
111637
+ } catch {}
111638
+ let authTokenSource = "none";
111639
+ try {
111640
+ ({ source: authTokenSource } = getAuthTokenSource());
111641
+ } catch {
111642
+ return "unknown";
111643
+ }
111644
+ const bareMode = isBareMode();
111645
+ const managedOAuthContext = isManagedOAuthContext();
111646
+ const managedOAuthIsEffective = isManagedOAuthEffective(authTokenSource, managedOAuthContext, bareMode);
111647
+ const hasOAuthToken = resolveAnthropicAttributionAuthTokenSource(authTokenSource, managedOAuthIsEffective) === "oauth";
111648
+ let isSubscriber = false;
111649
+ if (hasOAuthToken) {
111650
+ try {
111651
+ isSubscriber = managedOAuthIsEffective ? getSubscriptionType() !== "free" : isClaudeAISubscriber();
111652
+ } catch {
111653
+ return "unknown";
111654
+ }
111655
+ }
111656
+ return resolveAnthropicAttributionAuthFromSources({
111657
+ apiKeySource,
111658
+ authTokenSource,
111659
+ bareMode,
111660
+ isSubscriber,
111661
+ managedOAuthContext
111662
+ });
111663
+ }
111664
+ function resolveAnthropicAttributionRoute(providerOverride) {
111665
+ if (providerOverride)
111666
+ return "non_official";
111667
+ try {
111668
+ const routeId = resolveActiveRouteIdFromEnv(process.env);
111669
+ if (routeId === "anthropic" && getAPIProvider() === "firstParty" && isFirstPartyAnthropicBaseUrl()) {
111670
+ return "official_anthropic";
111671
+ }
111672
+ if (routeId && getTransportKindForRoute(routeId) !== null) {
111673
+ return "non_official";
111674
+ }
111675
+ return "unknown";
111676
+ } catch {
111677
+ return "unknown";
111678
+ }
111679
+ }
111680
+ function resolveCurrentAnthropicAttributionPolicy({
111681
+ attributionEnabled,
111682
+ providerOverride
111683
+ }) {
111684
+ const route = resolveAnthropicAttributionRoute(providerOverride);
111685
+ const policy = resolveAnthropicAttributionPolicy({
111686
+ route,
111687
+ auth: route === "official_anthropic" ? resolveCurrentAnthropicAttributionAuth() : "unknown",
111688
+ attributionEnabled
111689
+ });
111690
+ const diagnostic = getAnthropicAttributionDiagnostic(policy);
111691
+ if (diagnostic)
111692
+ logForDebugging(diagnostic);
111693
+ return policy;
111694
+ }
111471
111695
  function shouldUseFirstPartyAnthropicAuthForProvider({
111472
111696
  providerOverride,
111473
111697
  apiProvider,
@@ -111485,6 +111709,10 @@ function shouldUseCustomAnthropicBearerAuth({
111485
111709
  }
111486
111710
  var init_authRouting = __esm(() => {
111487
111711
  init_providers();
111712
+ init_auth();
111713
+ init_routeMetadata();
111714
+ init_debug();
111715
+ init_envUtils();
111488
111716
  });
111489
111717
 
111490
111718
  // src/services/api/vertexClient.ts
@@ -145655,7 +145883,7 @@ function doesSourceMatchHostPattern(source, pattern) {
145655
145883
  return false;
145656
145884
  }
145657
145885
  try {
145658
- const regex = new RegExp(pattern.hostPattern);
145886
+ const regex = new RegExp(`^(?:${pattern.hostPattern})$`);
145659
145887
  return regex.test(host);
145660
145888
  } catch {
145661
145889
  logError2(new Error(`Invalid hostPattern regex: ${pattern.hostPattern}`));
@@ -154930,7 +155158,7 @@ function computeFingerprint(messageText2, version2) {
154930
155158
  }
154931
155159
  function computeFingerprintFromMessages(messages) {
154932
155160
  const firstMessageText = extractFirstMessageText(messages);
154933
- return computeFingerprint(firstMessageText, "0.29.2-by-rayss");
155161
+ return computeFingerprint(firstMessageText, "0.30.1-by-rayss");
154934
155162
  }
154935
155163
  var FINGERPRINT_SALT = "59cf53e54c78";
154936
155164
  var init_fingerprint = () => {};
@@ -154972,9 +155200,12 @@ async function sideQuery(opts) {
154972
155200
  betas.push(STRUCTURED_OUTPUTS_BETA_HEADER);
154973
155201
  }
154974
155202
  const messageText2 = extractFirstUserMessageText(messages);
154975
- const fingerprint = computeFingerprint(messageText2, "0.29.2-by-rayss");
154976
- const attributionHeader = getAttributionHeader(fingerprint);
154977
- const systemBlocks = [
155203
+ const fingerprint = computeFingerprint(messageText2, publicBuildVersion);
155204
+ const attributionPolicy = resolveCurrentAnthropicAttributionPolicy({
155205
+ attributionEnabled: isAttributionHeaderEnabled()
155206
+ });
155207
+ const attributionHeader = getAttributionHeader(fingerprint, attributionPolicy);
155208
+ const systemBlocks = applyAnthropicAttributionPolicy([
154978
155209
  attributionHeader ? { type: "text", text: attributionHeader } : null,
154979
155210
  ...skipSystemPromptPrefix ? [] : [
154980
155211
  {
@@ -154986,7 +155217,7 @@ async function sideQuery(opts) {
154986
155217
  }
154987
155218
  ],
154988
155219
  ...Array.isArray(system) ? system : system ? [{ type: "text", text: system }] : []
154989
- ].filter((block) => block !== null);
155220
+ ].filter((block) => block !== null), attributionPolicy);
154990
155221
  let thinkingConfig;
154991
155222
  if (thinking === false) {
154992
155223
  thinkingConfig = { type: "disabled" };
@@ -155034,10 +155265,12 @@ var init_sideQuery = __esm(() => {
155034
155265
  init_betas();
155035
155266
  init_system();
155036
155267
  init_claude3();
155268
+ init_authRouting();
155037
155269
  init_client4();
155038
155270
  init_betas2();
155039
155271
  init_fingerprint();
155040
155272
  init_model();
155273
+ init_version();
155041
155274
  });
155042
155275
 
155043
155276
  // src/utils/claudeInChrome/mcpServer.ts
@@ -156292,7 +156525,7 @@ var init_client2 = __esm(() => {
156292
156525
  const client = new Client({
156293
156526
  name: "claude-code",
156294
156527
  title: "OpenClaude",
156295
- version: "0.29.2-by-rayss",
156528
+ version: "0.30.1-by-rayss",
156296
156529
  description: "OpenClaude — coding-agent CLI for any LLM provider",
156297
156530
  websiteUrl: PRODUCT_URL
156298
156531
  }, {
@@ -233258,7 +233491,7 @@ function getAnthropicEnvMetadata() {
233258
233491
  function getBuildAgeMinutes() {
233259
233492
  if (false)
233260
233493
  ;
233261
- const buildTime = new Date("2026-08-28T02:14:46.317Z").getTime();
233494
+ const buildTime = new Date("2026-09-01T07:43:33.328Z").getTime();
233262
233495
  if (isNaN(buildTime))
233263
233496
  return;
233264
233497
  return Math.floor((Date.now() - buildTime) / 60000);
@@ -242711,6 +242944,7 @@ var init_autoCompact = __esm(() => {
242711
242944
  var exports_compressToolHistory = {};
242712
242945
  __export(exports_compressToolHistory, {
242713
242946
  setToolHistoryCompressionEnabledOverrideForTest: () => setToolHistoryCompressionEnabledOverrideForTest,
242947
+ omitOldUserImages: () => omitOldUserImages,
242714
242948
  getTiers: () => getTiers,
242715
242949
  compressToolHistory: () => compressToolHistory
242716
242950
  });
@@ -242919,6 +243153,52 @@ function shouldCompressBlock(block2, toolUsesById) {
242919
243153
  return true;
242920
243154
  return isCompactableTool(toolUse.name);
242921
243155
  }
243156
+ function hasCompletedTurn(messages, fromIndex) {
243157
+ for (let i3 = fromIndex + 1;i3 < messages.length; i3++) {
243158
+ const content = getInner(messages[i3]).content;
243159
+ if (!Array.isArray(content))
243160
+ continue;
243161
+ const types = content.map((b) => b?.type);
243162
+ if (types.includes("tool_use"))
243163
+ continue;
243164
+ if ((getInner(messages[i3]).role ?? messages[i3].role) === "assistant") {
243165
+ return true;
243166
+ }
243167
+ }
243168
+ return false;
243169
+ }
243170
+ function omitOldUserImages(messages) {
243171
+ let changed = false;
243172
+ const out = messages.map((msg, i3) => {
243173
+ const inner = getInner(msg);
243174
+ if ((inner.role ?? msg.role) !== "user")
243175
+ return msg;
243176
+ const content = inner.content;
243177
+ if (!Array.isArray(content))
243178
+ return msg;
243179
+ if (!content.some((block2) => isInlineImagePayload(block2)))
243180
+ return msg;
243181
+ if (!hasCompletedTurn(messages, i3))
243182
+ return msg;
243183
+ let omitted = false;
243184
+ const newContent = content.map((block2) => {
243185
+ if (isInlineImagePayload(block2)) {
243186
+ omitted = true;
243187
+ return { type: "text", text: OMITTED_USER_IMAGE_MARKER };
243188
+ }
243189
+ return block2;
243190
+ });
243191
+ if (!omitted)
243192
+ return msg;
243193
+ changed = true;
243194
+ const newMessage = rewriteMessage(msg, newContent);
243195
+ if (msg.imagePermissionToolUseIds) {
243196
+ return { ...newMessage, imagePermissionToolUseIds: [] };
243197
+ }
243198
+ return newMessage;
243199
+ });
243200
+ return changed ? out : messages;
243201
+ }
242922
243202
  function compressToolHistory(messages, model, options2 = {}) {
242923
243203
  const compressionEnabled = toolHistoryCompressionEnabledOverrideForTest ?? getGlobalConfig().toolHistoryCompressionEnabled;
242924
243204
  if (!compressionEnabled)
@@ -242927,10 +243207,11 @@ function compressToolHistory(messages, model, options2 = {}) {
242927
243207
  const textBlockSeparator = options2.textBlockSeparator ?? `
242928
243208
 
242929
243209
  `;
242930
- const toolResults = indexToolResults(messages);
243210
+ const working = options2.omitOldUserImages ? omitOldUserImages(messages) : messages;
243211
+ const toolResults = indexToolResults(working);
242931
243212
  const total = toolResults.length;
242932
243213
  if (total <= tiers.recent)
242933
- return messages;
243214
+ return working;
242934
243215
  const positionsByMessage = new Map;
242935
243216
  for (let pos = 0;pos < toolResults.length; pos++) {
242936
243217
  const { messageIndex, blockIndex } = toolResults[pos];
@@ -242941,8 +243222,8 @@ function compressToolHistory(messages, model, options2 = {}) {
242941
243222
  }
242942
243223
  positions.set(blockIndex, pos);
242943
243224
  }
242944
- const toolUsesById = indexToolUses(messages);
242945
- return messages.map((msg, i3) => {
243225
+ const toolUsesById = indexToolUses(working);
243226
+ return working.map((msg, i3) => {
242946
243227
  const positions = positionsByMessage.get(i3);
242947
243228
  if (!positions)
242948
243229
  return msg;
@@ -242988,7 +243269,7 @@ function compressToolHistory(messages, model, options2 = {}) {
242988
243269
  return rewriteMessage(msg, newContent);
242989
243270
  });
242990
243271
  }
242991
- var MID_MAX_CHARS = 2000, STUB_ARGS_MAX_CHARS = 200, OMITTED_INLINE_IMAGE_MARKER = "[Inline image omitted from tool history]", toolHistoryCompressionEnabledOverrideForTest, STUB_MARKER_RE, TRUNCATION_MARKER_RE;
243272
+ var MID_MAX_CHARS = 2000, STUB_ARGS_MAX_CHARS = 200, OMITTED_INLINE_IMAGE_MARKER = "[Inline image omitted from tool history]", OMITTED_USER_IMAGE_MARKER = "[Image omitted from history]", toolHistoryCompressionEnabledOverrideForTest, STUB_MARKER_RE, TRUNCATION_MARKER_RE;
242992
243273
  var init_compressToolHistory = __esm(() => {
242993
243274
  init_autoCompact();
242994
243275
  init_microCompact();
@@ -243279,7 +243560,8 @@ function prepareOpenAIRequest({
243279
243560
 
243280
243561
  ` : `
243281
243562
  `,
243282
- runtimeLimits
243563
+ runtimeLimits,
243564
+ omitOldUserImages: true
243283
243565
  }) : rawMessages;
243284
243566
  const useNativeOllamaChat = effectiveTransport === "chat_completions" && !shimConfig.endpointPath && isDirectLocalOllamaEndpoint(request.baseUrl) && isLikelyOllamaEndpoint(request.baseUrl);
243285
243567
  const openaiMessages = effectiveTransport === "chat_completions" ? convertMessages(compressedMessages, params.system, {
@@ -243395,7 +243677,8 @@ function prepareOpenAIRequest({
243395
243677
  const getResponsesInput = () => {
243396
243678
  responsesMessages ??= effectiveTransport === "chat_completions" ? fastPath.skipToolHistoryCompression || skipCompressionForPrefixCache ? rawMessages : compressToolHistory(rawMessages, request.resolvedModel, {
243397
243679
  textBlockSeparator: `
243398
- `
243680
+ `,
243681
+ omitOldUserImages: true
243399
243682
  }) : compressedMessages;
243400
243683
  responsesInput ??= convertAnthropicMessagesToResponsesInput(responsesMessages, effectiveTransport === "responses_compat");
243401
243684
  return responsesInput;
@@ -246171,61 +246454,50 @@ function convertSystemPrompt2(system) {
246171
246454
  }
246172
246455
  return String(system);
246173
246456
  }
246174
- function ensureTextPartForImageContent(parts) {
246175
- if (!parts.some((part) => part.type === "image_url"))
246176
- return parts;
246177
- if (parts.some((part) => part.type === "text" && part.text.trim().length > 0))
246178
- return parts;
246179
- return [{ type: "text", text: "Image attached." }, ...parts];
246180
- }
246181
246457
  function joinTextContentParts(parts) {
246182
246458
  return parts.map((part) => part.type === "text" ? part.text : "").join("");
246183
246459
  }
246184
- function convertToolResultContent(content, isError, options2) {
246185
- if (typeof content === "string")
246186
- return isError ? `Error: ${content}` : content;
246460
+ function extractToolResultWithImagePlaceholder(content, isError, options2) {
246461
+ if (typeof content === "string") {
246462
+ return { text: isError ? `Error: ${content}` : content, images: [] };
246463
+ }
246187
246464
  if (!Array.isArray(content)) {
246188
- const text = JSON.stringify(content ?? "");
246189
- return isError ? `Error: ${text}` : text;
246465
+ const text2 = JSON.stringify(content ?? "");
246466
+ return { text: isError ? `Error: ${text2}` : text2, images: [] };
246190
246467
  }
246191
- const parts = [];
246468
+ const textChunks = [];
246469
+ const images = [];
246192
246470
  for (const block2 of content) {
246193
246471
  if (block2?.type === "text" && typeof block2.text === "string") {
246194
- parts.push({ type: "text", text: block2.text });
246472
+ textChunks.push(block2.text);
246195
246473
  } else if (block2?.type === "tool_reference" && typeof block2.tool_name === "string") {
246196
- parts.push({ type: "text", text: `Tool "${block2.tool_name}" is now loaded and available to call.` });
246474
+ textChunks.push(`Tool "${block2.tool_name}" is now loaded and available to call.`);
246197
246475
  } else if (block2?.type === "image") {
246198
246476
  if (options2?.supportsImageInputs === false) {
246199
246477
  throw new Error("The active provider accepts text-only messages and does not support image inputs.");
246200
246478
  }
246479
+ textChunks.push("(see following user message for image)");
246201
246480
  const source = block2.source;
246202
- if (source?.type === "url" && source.url)
246203
- parts.push({ type: "image_url", image_url: { url: source.url } });
246204
- else if (source?.type === "base64" && source.media_type && source.data) {
246205
- parts.push({
246481
+ if (source?.type === "url" && source.url) {
246482
+ images.push({ type: "image_url", image_url: { url: source.url } });
246483
+ } else if (source?.type === "base64" && source.media_type && source.data) {
246484
+ images.push({
246206
246485
  type: "image_url",
246207
246486
  image_url: { url: `data:${source.media_type};base64,${source.data}` }
246208
246487
  });
246209
246488
  }
246210
246489
  } else if (typeof block2?.text === "string") {
246211
- parts.push({ type: "text", text: block2.text });
246490
+ textChunks.push(block2.text);
246212
246491
  }
246213
246492
  }
246214
- if (parts.length === 0)
246215
- return "";
246216
- if (parts.length === 1 && parts[0].type === "text")
246217
- return isError ? `Error: ${parts[0].text}` : parts[0].text;
246218
- if (parts.every((part) => part.type === "text")) {
246219
- const text = parts.map((part) => part.text).join(`
246493
+ let text = textChunks.join(`
246220
246494
 
246221
246495
  `);
246222
- return isError ? `Error: ${text}` : text;
246223
- }
246224
- if (isError && parts[0]?.type === "text")
246225
- parts[0] = { ...parts[0], text: `Error: ${parts[0].text}` };
246226
- else if (isError)
246227
- parts.unshift({ type: "text", text: "Error:" });
246228
- return ensureTextPartForImageContent(parts);
246496
+ if (isError)
246497
+ text = text ? `Error: ${text}` : "Error:";
246498
+ if (!text && images.length === 0)
246499
+ text = "";
246500
+ return { text, images };
246229
246501
  }
246230
246502
  function convertContentBlocks(content, options2) {
246231
246503
  if (typeof content === "string")
@@ -246274,7 +246546,7 @@ function convertContentBlocks(content, options2) {
246274
246546
  return parts.map((part) => part.text).join(`
246275
246547
 
246276
246548
  `);
246277
- return ensureTextPartForImageContent(parts);
246549
+ return parts;
246278
246550
  }
246279
246551
  function convertMessages(messages, system, options2 = {}) {
246280
246552
  const result = [];
@@ -246304,6 +246576,7 @@ function convertMessages(messages, system, options2 = {}) {
246304
246576
  continue;
246305
246577
  }
246306
246578
  let otherContent;
246579
+ const toolResultImages = [];
246307
246580
  for (const block2 of content) {
246308
246581
  if (block2?.type !== "tool_result") {
246309
246582
  otherContent ??= [];
@@ -246312,15 +246585,20 @@ function convertMessages(messages, system, options2 = {}) {
246312
246585
  }
246313
246586
  const id = block2.tool_use_id ?? "unknown";
246314
246587
  if (knownToolCallIds.has(id)) {
246588
+ const extracted = extractToolResultWithImagePlaceholder(block2.content, block2.is_error, options2);
246315
246589
  result.push({
246316
246590
  role: "tool",
246317
246591
  tool_call_id: id,
246318
- content: convertToolResultContent(block2.content, block2.is_error, options2)
246592
+ content: extracted.text
246319
246593
  });
246594
+ toolResultImages.push(...extracted.images);
246320
246595
  } else {
246321
246596
  options2.log?.(`Dropping orphan tool_result for ID: ${id} to prevent API error`);
246322
246597
  }
246323
246598
  }
246599
+ if (toolResultImages.length > 0) {
246600
+ result.push({ role: "user", content: toolResultImages });
246601
+ }
246324
246602
  if (otherContent?.length)
246325
246603
  result.push({ role: "user", content: convertContentBlocks(otherContent, options2) });
246326
246604
  continue;
@@ -255365,6 +255643,9 @@ function getContentText(content) {
255365
255643
  }
255366
255644
  return null;
255367
255645
  }
255646
+ function getUserMessagePreviewText(content) {
255647
+ return getContentText(content)?.trim() || "(no prompt)";
255648
+ }
255368
255649
  var STRIPPED_TAGS_RE;
255369
255650
  var init_content = __esm(() => {
255370
255651
  init_xml();
@@ -255941,6 +256222,7 @@ __export(exports_messages, {
255941
256222
  hasSuccessfulToolCall: () => hasSuccessfulToolCall,
255942
256223
  handleMessageFromStream: () => handleMessageFromStream,
255943
256224
  getUserMessageText: () => getUserMessageText,
256225
+ getUserMessagePreviewText: () => getUserMessagePreviewText,
255944
256226
  getToolUseIDs: () => getToolUseIDs,
255945
256227
  getToolUseID: () => getToolUseID,
255946
256228
  getToolResultIDs: () => getToolResultIDs,
@@ -262109,7 +262391,7 @@ async function readLiteMetadata(filePath, fileSize, buf, sessionId) {
262109
262391
  const projectPath = extractJsonStringField(head, "cwd");
262110
262392
  const teamName = extractJsonStringField(head, "teamName");
262111
262393
  const agentSetting = extractJsonStringField(head, "agentSetting");
262112
- const firstPrompt = extractLastJsonStringField(tail, "lastPrompt") || extractFirstPromptFromChunk(head) || extractJsonStringFieldPrefix(head, "content", 200) || extractJsonStringFieldPrefix(head, "text", 200) || "";
262394
+ const firstPrompt = extractFirstPromptFromChunk(head) || extractLastJsonStringField(tail, "lastPrompt") || extractJsonStringFieldPrefix(head, "content", 200) || extractJsonStringFieldPrefix(head, "text", 200) || "";
262113
262395
  const customTitle = extractLastJsonStringField(tail, "customTitle") ?? extractLastJsonStringField(head, "customTitle") ?? extractLastJsonStringField(tail, "aiTitle") ?? extractLastJsonStringField(head, "aiTitle");
262114
262396
  const summary = extractLastJsonStringField(tail, "summary");
262115
262397
  const tagLine = tail.split(`
@@ -262376,7 +262658,7 @@ var init_sessionStorage = __esm(() => {
262376
262658
  init_slowOperations();
262377
262659
  init_transcriptFileLock();
262378
262660
  init_uuid();
262379
- VERSION3 = typeof MACRO !== "undefined" ? "0.29.2-by-rayss" : "unknown";
262661
+ VERSION3 = typeof MACRO !== "undefined" ? "0.30.1-by-rayss" : "unknown";
262380
262662
  MAX_TOMBSTONE_REWRITE_BYTES = 50 * 1024 * 1024;
262381
262663
  TRANSCRIPT_COPY_CHUNK_BYTES = 64 * 1024;
262382
262664
  transcriptRewriteHooksForTesting = {};
@@ -263843,7 +264125,7 @@ var init_filesystem = __esm(() => {
263843
264125
  });
263844
264126
  getBundledSkillsRoot = memoize_default(function getBundledSkillsRoot2() {
263845
264127
  const nonce = randomBytes10(16).toString("hex");
263846
- return join88(getClaudeTempDir(), "bundled-skills", "0.29.2-by-rayss", nonce);
264128
+ return join88(getClaudeTempDir(), "bundled-skills", "0.30.1-by-rayss", nonce);
263847
264129
  });
263848
264130
  getResolvedWorkingDirPaths = memoize_default(getPathsForPermissionCheck);
263849
264131
  });
@@ -270350,8 +270632,11 @@ function logStripOnce(stripped) {
270350
270632
  loggedStrip = true;
270351
270633
  logForDebugging(`[betas] Stripped from tool schemas: [${stripped.join(", ")}] (CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1)`);
270352
270634
  }
270635
+ function getSystemPromptTelemetryBlock(systemPrompt) {
270636
+ return splitSysPromptPrefix(systemPrompt).find((block2) => !isAnthropicBillingAttributionBlock(block2.text));
270637
+ }
270353
270638
  function logAPIPrefix(systemPrompt) {
270354
- const [firstSyspromptBlock] = splitSysPromptPrefix(systemPrompt);
270639
+ const firstSyspromptBlock = getSystemPromptTelemetryBlock(systemPrompt);
270355
270640
  const firstSystemPrompt = firstSyspromptBlock?.text;
270356
270641
  logEvent("tengu_sysprompt_block", {
270357
270642
  snippet: firstSystemPrompt?.slice(0, 20),
@@ -270373,7 +270658,7 @@ function splitSysPromptPrefix(systemPrompt, options2) {
270373
270658
  continue;
270374
270659
  if (prompt === SYSTEM_PROMPT_DYNAMIC_BOUNDARY)
270375
270660
  continue;
270376
- if (prompt.startsWith("x-anthropic-billing-header")) {
270661
+ if (isAnthropicBillingAttributionBlock(prompt)) {
270377
270662
  attributionHeader2 = prompt;
270378
270663
  } else if (CLI_SYSPROMPT_PREFIXES.has(prompt)) {
270379
270664
  systemPromptPrefix2 = prompt;
@@ -270407,7 +270692,7 @@ function splitSysPromptPrefix(systemPrompt, options2) {
270407
270692
  const block2 = systemPrompt[i3];
270408
270693
  if (!block2 || block2 === SYSTEM_PROMPT_DYNAMIC_BOUNDARY)
270409
270694
  continue;
270410
- if (block2.startsWith("x-anthropic-billing-header")) {
270695
+ if (isAnthropicBillingAttributionBlock(block2)) {
270411
270696
  attributionHeader2 = block2;
270412
270697
  } else if (CLI_SYSPROMPT_PREFIXES.has(block2)) {
270413
270698
  systemPromptPrefix2 = block2;
@@ -270450,7 +270735,7 @@ function splitSysPromptPrefix(systemPrompt, options2) {
270450
270735
  for (const block2 of systemPrompt) {
270451
270736
  if (!block2)
270452
270737
  continue;
270453
- if (block2.startsWith("x-anthropic-billing-header")) {
270738
+ if (isAnthropicBillingAttributionBlock(block2)) {
270454
270739
  attributionHeader = block2;
270455
270740
  } else if (CLI_SYSPROMPT_PREFIXES.has(block2)) {
270456
270741
  systemPromptPrefix = block2;
@@ -271321,8 +271606,8 @@ ${deferredToolList}
271321
271606
  }
271322
271607
  const hasChromeTools = filteredTools.some((t) => isToolFromMcpServer(t.name, CLAUDE_IN_CHROME_MCP_SERVER_NAME));
271323
271608
  const injectChromeHere = useToolSearch && hasChromeTools && !isMcpInstructionsDeltaEnabled();
271609
+ const attributionEnabled = isAttributionHeaderEnabled();
271324
271610
  systemPrompt = asSystemPrompt([
271325
- getAttributionHeader(fingerprint),
271326
271611
  getCLISyspromptPrefix({
271327
271612
  isNonInteractive: options2.isNonInteractiveSession,
271328
271613
  hasAppendSystemPrompt: options2.hasAppendSystemPrompt
@@ -271331,12 +271616,6 @@ ${deferredToolList}
271331
271616
  ...advisorModel ? [ADVISOR_TOOL_INSTRUCTIONS] : [],
271332
271617
  ...injectChromeHere ? [CHROME_TOOL_SEARCH_INSTRUCTIONS] : []
271333
271618
  ].filter(Boolean));
271334
- logAPIPrefix(systemPrompt);
271335
- const enablePromptCaching = options2.enablePromptCaching ?? getPromptCachingEnabled(options2.model);
271336
- const system = buildSystemPromptBlocks(systemPrompt, enablePromptCaching, {
271337
- skipGlobalCacheForSystemPrompt: needsToolBasedCacheMarker,
271338
- querySource: options2.querySource
271339
- });
271340
271619
  const useBetas = betas.length > 0;
271341
271620
  const extraToolSchemas = [...options2.extraToolSchemas ?? []];
271342
271621
  if (advisorModel) {
@@ -271377,24 +271656,6 @@ ${deferredToolList}
271377
271656
  }
271378
271657
  const sonnet1mExpLatched = getSonnet1mExpTreatmentEnabled(options2.model);
271379
271658
  const effort = resolveAppliedEffort(options2.model, options2.effortValue);
271380
- if (true) {
271381
- const toolsForCacheDetection = allTools.filter((t) => !(("defer_loading" in t) && t.defer_loading));
271382
- recordPromptState({
271383
- system,
271384
- toolSchemas: toolsForCacheDetection,
271385
- querySource: options2.querySource,
271386
- model: options2.model,
271387
- agentId: options2.agentId,
271388
- fastMode: fastModeHeaderLatched,
271389
- globalCacheStrategy,
271390
- betas,
271391
- autoModeActive: afkHeaderLatched,
271392
- isUsingOverage: currentLimits.isUsingOverage ?? false,
271393
- cachedMCEnabled: cacheEditingHeaderLatched,
271394
- effortValue: effort,
271395
- extraBodyParams: getExtraBodyParams()
271396
- });
271397
- }
271398
271659
  const startIncludingRetries = Date.now();
271399
271660
  let start = Date.now();
271400
271661
  let attemptNumber = 0;
@@ -271428,6 +271689,8 @@ ${deferredToolList}
271428
271689
  const consumedCacheEdits = cachedMCEnabled ? consumePendingCacheEdits() : null;
271429
271690
  const consumedPinnedEdits = cachedMCEnabled ? getPinnedCacheEdits() : [];
271430
271691
  let lastRequestBetas;
271692
+ let apiPrefixLogged = false;
271693
+ let promptStateRecorded = false;
271431
271694
  const paramsFromContext = (retryContext) => {
271432
271695
  const betasParams = [...betas];
271433
271696
  if (!betasParams.includes(CONTEXT_1M_BETA_HEADER) && sonnet1mExpLatched) {
@@ -271474,7 +271737,42 @@ ${deferredToolList}
271474
271737
  isRedactThinkingActive: betasParams.includes(REDACT_THINKING_BETA_HEADER),
271475
271738
  clearAllThinking: thinkingClearLatched
271476
271739
  });
271477
- const enablePromptCaching2 = options2.enablePromptCaching ?? getPromptCachingEnabled(retryContext.model);
271740
+ const enablePromptCaching = options2.enablePromptCaching ?? getPromptCachingEnabled(retryContext.model);
271741
+ const attributionPolicy = resolveCurrentAnthropicAttributionPolicy({
271742
+ attributionEnabled,
271743
+ providerOverride: options2.providerOverride
271744
+ });
271745
+ const requestSystemPrompt = asSystemPrompt(applyAnthropicAttributionPolicy([
271746
+ getAttributionHeader(fingerprint, attributionPolicy),
271747
+ ...systemPrompt
271748
+ ].filter(Boolean), attributionPolicy));
271749
+ const system = buildSystemPromptBlocks(requestSystemPrompt, enablePromptCaching, {
271750
+ skipGlobalCacheForSystemPrompt: needsToolBasedCacheMarker,
271751
+ querySource: options2.querySource
271752
+ });
271753
+ if (!apiPrefixLogged) {
271754
+ apiPrefixLogged = true;
271755
+ logAPIPrefix(requestSystemPrompt);
271756
+ }
271757
+ if (!promptStateRecorded) {
271758
+ promptStateRecorded = true;
271759
+ const toolsForCacheDetection = allTools.filter((t) => !(("defer_loading" in t) && t.defer_loading));
271760
+ recordPromptState({
271761
+ system,
271762
+ toolSchemas: toolsForCacheDetection,
271763
+ querySource: options2.querySource,
271764
+ model: options2.model,
271765
+ agentId: options2.agentId,
271766
+ fastMode: fastModeHeaderLatched,
271767
+ globalCacheStrategy,
271768
+ betas,
271769
+ autoModeActive: afkHeaderLatched,
271770
+ isUsingOverage: currentLimits.isUsingOverage ?? false,
271771
+ cachedMCEnabled: cacheEditingHeaderLatched,
271772
+ effortValue: effort,
271773
+ extraBodyParams: getExtraBodyParams()
271774
+ });
271775
+ }
271478
271776
  let speed;
271479
271777
  const isFastModeForRetry = isFastModeEnabled() && isFastModeAvailable() && !isFastModeCooldown() && isFastModeSupportedByModel(options2.model) && !!retryContext.fastMode;
271480
271778
  if (isFastModeForRetry) {
@@ -271498,7 +271796,7 @@ ${deferredToolList}
271498
271796
  return {
271499
271797
  model: normalizeModelStringForAPI(providerRequestModel),
271500
271798
  system,
271501
- messages: addCacheBreakpoints(messagesForAPI, enablePromptCaching2, options2.querySource, useCachedMC, consumedCacheEdits, consumedPinnedEdits, options2.skipCacheWrite),
271799
+ messages: addCacheBreakpoints(messagesForAPI, enablePromptCaching, options2.querySource, useCachedMC, consumedCacheEdits, consumedPinnedEdits, options2.skipCacheWrite),
271502
271800
  tools: allTools,
271503
271801
  tool_choice: options2.toolChoice,
271504
271802
  ...useBetas && { betas: betasParams },
@@ -272728,6 +273026,7 @@ var init_claude3 = __esm(() => {
272728
273026
  init_manager();
272729
273027
  init_utils4();
272730
273028
  init_vcr();
273029
+ init_authRouting();
272731
273030
  init_client4();
272732
273031
  init_errors4();
272733
273032
  init_logging();
@@ -278365,7 +278664,7 @@ function buildSystemInitMessage(inputs) {
278365
278664
  slash_commands: inputs.commands.filter((c7) => c7.userInvocable !== false).map((c7) => c7.name),
278366
278665
  apiKeySource: getAnthropicApiKeyWithSource().source,
278367
278666
  betas: getSdkBetas(),
278368
- claude_code_version: "0.29.2-by-rayss",
278667
+ claude_code_version: "0.30.1-by-rayss",
278369
278668
  output_style: outputStyle,
278370
278669
  agents: inputs.agents.map((agent) => agent.agentType),
278371
278670
  skills: inputs.skills.filter((s) => s.userInvocable !== false).map((skill) => skill.name),
@@ -282960,4 +283259,4 @@ export {
282960
283259
  AbortError
282961
283260
  };
282962
283261
 
282963
- //# debugId=8256BAC37AFFD8C864756E2164756E21
283262
+ //# debugId=1129A77F5598618764756E2164756E21