@opencow-ai/opencow-agent-sdk 0.4.29 → 0.4.30
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/cli.mjs +31 -19
- package/dist/client.js +23 -10
- package/dist/entrypoints/sdk/runtimeTypes.d.ts +7 -0
- package/dist/sdk.js +23 -10
- package/dist/types/toolRuntime.d.ts +2 -0
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -86737,7 +86737,7 @@ function printStartupScreen() {
|
|
|
86737
86737
|
const sLen = ` ● ${sL} Ready — type /help to begin`.length;
|
|
86738
86738
|
out.push(boxRow(sRow, W, sLen));
|
|
86739
86739
|
out.push(`${rgb(...BORDER)}╚${"═".repeat(W - 2)}╝${RESET}`);
|
|
86740
|
-
out.push(` ${DIM}${rgb(...DIMCOL)}opencow ${RESET}${rgb(...ACCENT)}v${"0.4.
|
|
86740
|
+
out.push(` ${DIM}${rgb(...DIMCOL)}opencow ${RESET}${rgb(...ACCENT)}v${"0.4.30"}${RESET}`);
|
|
86741
86741
|
out.push("");
|
|
86742
86742
|
process.stdout.write(out.join(`
|
|
86743
86743
|
`) + `
|
|
@@ -138409,16 +138409,17 @@ function getAssistantMessageFromError(error, model, options) {
|
|
|
138409
138409
|
error: "rate_limit"
|
|
138410
138410
|
});
|
|
138411
138411
|
}
|
|
138412
|
-
if (error instanceof APIError && error.status === 429
|
|
138413
|
-
const
|
|
138414
|
-
const
|
|
138412
|
+
if (error instanceof APIError && error.status === 429) {
|
|
138413
|
+
const quotaHeaders = shouldProcessRateLimits(isClaudeAISubscriber()) ? error.headers : undefined;
|
|
138414
|
+
const rateLimitType = quotaHeaders?.get?.("anthropic-ratelimit-unified-representative-claim");
|
|
138415
|
+
const overageStatus = quotaHeaders?.get?.("anthropic-ratelimit-unified-overage-status");
|
|
138415
138416
|
if (rateLimitType || overageStatus) {
|
|
138416
138417
|
const limits = {
|
|
138417
138418
|
status: "rejected",
|
|
138418
138419
|
unifiedRateLimitFallbackAvailable: false,
|
|
138419
138420
|
isUsingOverage: false
|
|
138420
138421
|
};
|
|
138421
|
-
const resetHeader =
|
|
138422
|
+
const resetHeader = quotaHeaders?.get?.("anthropic-ratelimit-unified-reset");
|
|
138422
138423
|
if (resetHeader) {
|
|
138423
138424
|
limits.resetsAt = Number(resetHeader);
|
|
138424
138425
|
}
|
|
@@ -138428,11 +138429,11 @@ function getAssistantMessageFromError(error, model, options) {
|
|
|
138428
138429
|
if (overageStatus) {
|
|
138429
138430
|
limits.overageStatus = overageStatus;
|
|
138430
138431
|
}
|
|
138431
|
-
const overageResetHeader =
|
|
138432
|
+
const overageResetHeader = quotaHeaders?.get?.("anthropic-ratelimit-unified-overage-reset");
|
|
138432
138433
|
if (overageResetHeader) {
|
|
138433
138434
|
limits.overageResetsAt = Number(overageResetHeader);
|
|
138434
138435
|
}
|
|
138435
|
-
const overageDisabledReason =
|
|
138436
|
+
const overageDisabledReason = quotaHeaders?.get?.("anthropic-ratelimit-unified-overage-disabled-reason");
|
|
138436
138437
|
if (overageDisabledReason) {
|
|
138437
138438
|
limits.overageDisabledReason = overageDisabledReason;
|
|
138438
138439
|
}
|
|
@@ -138573,6 +138574,13 @@ Run /share and post the JSON file to ${MACRO.FEEDBACK_CHANNEL}.`;
|
|
|
138573
138574
|
error: "billing_error"
|
|
138574
138575
|
});
|
|
138575
138576
|
}
|
|
138577
|
+
if (error instanceof APIError && (error.status === 402 || error.message.includes('"type":"billing_error"'))) {
|
|
138578
|
+
const detail = error.message.match(/"message"\s*:\s*"([^"]*)"/)?.[1];
|
|
138579
|
+
return createAssistantAPIErrorMessage({
|
|
138580
|
+
content: `${API_ERROR_MESSAGE_PREFIX}: ${detail || error.message}`,
|
|
138581
|
+
error: "billing_error"
|
|
138582
|
+
});
|
|
138583
|
+
}
|
|
138576
138584
|
if (error instanceof APIError && error.status === 400 && error.message.toLowerCase().includes("organization has been disabled")) {
|
|
138577
138585
|
const { source } = getAnthropicApiKeyWithSource();
|
|
138578
138586
|
if (source === "ANTHROPIC_API_KEY" && process.env.ANTHROPIC_API_KEY && !isClaudeAISubscriber()) {
|
|
@@ -234417,7 +234425,6 @@ async function* queryLoop(params, consumedCommandUuids) {
|
|
|
234417
234425
|
exceeds200kTokens: permissionMode === "plan" && doesMostRecentAssistantMessageExceed200k(messagesForQuery)
|
|
234418
234426
|
});
|
|
234419
234427
|
queryCheckpoint("query_setup_end");
|
|
234420
|
-
const dumpPromptsFetch = undefined;
|
|
234421
234428
|
let collapseOwnsIt = false;
|
|
234422
234429
|
if (false) {}
|
|
234423
234430
|
const mediaRecoveryEnabled = reactiveCompact?.isReactiveCompactEnabled() ?? false;
|
|
@@ -234470,7 +234477,7 @@ async function* queryLoop(params, consumedCommandUuids) {
|
|
|
234470
234477
|
hasAppendSystemPrompt: !!toolUseContext.options.appendSystemPrompt,
|
|
234471
234478
|
maxOutputTokensOverride,
|
|
234472
234479
|
maxOutputTokensLimitOverride: params.maxOutputTokensLimitOverride,
|
|
234473
|
-
fetchOverride:
|
|
234480
|
+
fetchOverride: toolUseContext.options.fetchOverride,
|
|
234474
234481
|
mcpTools: appState.mcp.tools,
|
|
234475
234482
|
hasPendingMcpServers: appState.mcp.clients.some((c) => c.type === "pending"),
|
|
234476
234483
|
queryTracking,
|
|
@@ -235183,7 +235190,7 @@ function getAnthropicEnvMetadata() {
|
|
|
235183
235190
|
function getBuildAgeMinutes() {
|
|
235184
235191
|
if (false)
|
|
235185
235192
|
;
|
|
235186
|
-
const buildTime = new Date("2026-11-
|
|
235193
|
+
const buildTime = new Date("2026-11-04T12:30:46.458Z").getTime();
|
|
235187
235194
|
if (isNaN(buildTime))
|
|
235188
235195
|
return;
|
|
235189
235196
|
return Math.floor((Date.now() - buildTime) / 60000);
|
|
@@ -239056,6 +239063,7 @@ async function* runAgent({
|
|
|
239056
239063
|
mcpResources: toolUseContext.options.mcpResources,
|
|
239057
239064
|
agentDefinitions: toolUseContext.options.agentDefinitions,
|
|
239058
239065
|
subagentDisallowedTools: toolUseContext.options.subagentDisallowedTools,
|
|
239066
|
+
fetchOverride: toolUseContext.options.fetchOverride,
|
|
239059
239067
|
...useExactTools && { querySource }
|
|
239060
239068
|
};
|
|
239061
239069
|
agentToolRuntimeContext = createSubagentContext(toolUseContext, {
|
|
@@ -480216,7 +480224,7 @@ function buildPrimarySection() {
|
|
|
480216
480224
|
}, undefined, false, undefined, this);
|
|
480217
480225
|
return [{
|
|
480218
480226
|
label: "Version",
|
|
480219
|
-
value: "0.4.
|
|
480227
|
+
value: "0.4.30"
|
|
480220
480228
|
}, {
|
|
480221
480229
|
label: "Session name",
|
|
480222
480230
|
value: nameValue
|
|
@@ -528296,7 +528304,7 @@ var init_bridge_kick = __esm(() => {
|
|
|
528296
528304
|
var call58 = async () => {
|
|
528297
528305
|
return {
|
|
528298
528306
|
type: "text",
|
|
528299
|
-
value: `${"99.0.0"} (built ${"2026-11-
|
|
528307
|
+
value: `${"99.0.0"} (built ${"2026-11-04T12:30:46.458Z"})`
|
|
528300
528308
|
};
|
|
528301
528309
|
}, version2, version_default;
|
|
528302
528310
|
var init_version = __esm(() => {
|
|
@@ -545975,7 +545983,7 @@ function WelcomeV2() {
|
|
|
545975
545983
|
dimColor: true,
|
|
545976
545984
|
children: [
|
|
545977
545985
|
"v",
|
|
545978
|
-
"0.4.
|
|
545986
|
+
"0.4.30",
|
|
545979
545987
|
" "
|
|
545980
545988
|
]
|
|
545981
545989
|
}, undefined, true, undefined, this)
|
|
@@ -546175,7 +546183,7 @@ function WelcomeV2() {
|
|
|
546175
546183
|
dimColor: true,
|
|
546176
546184
|
children: [
|
|
546177
546185
|
"v",
|
|
546178
|
-
"0.4.
|
|
546186
|
+
"0.4.30",
|
|
546179
546187
|
" "
|
|
546180
546188
|
]
|
|
546181
546189
|
}, undefined, true, undefined, this)
|
|
@@ -546401,7 +546409,7 @@ function AppleTerminalWelcomeV2(t0) {
|
|
|
546401
546409
|
dimColor: true,
|
|
546402
546410
|
children: [
|
|
546403
546411
|
"v",
|
|
546404
|
-
"0.4.
|
|
546412
|
+
"0.4.30",
|
|
546405
546413
|
" "
|
|
546406
546414
|
]
|
|
546407
546415
|
}, undefined, true, undefined, this);
|
|
@@ -546655,7 +546663,7 @@ function AppleTerminalWelcomeV2(t0) {
|
|
|
546655
546663
|
dimColor: true,
|
|
546656
546664
|
children: [
|
|
546657
546665
|
"v",
|
|
546658
|
-
"0.4.
|
|
546666
|
+
"0.4.30",
|
|
546659
546667
|
" "
|
|
546660
546668
|
]
|
|
546661
546669
|
}, undefined, true, undefined, this);
|
|
@@ -557387,6 +557395,7 @@ class QueryEngine {
|
|
|
557387
557395
|
maxOutputTokensLimit,
|
|
557388
557396
|
contextWindow,
|
|
557389
557397
|
modelProviders: this.config.modelProviders,
|
|
557398
|
+
fetchOverride: this.config.fetchOverride,
|
|
557390
557399
|
subagentDisallowedTools: this.config.subagentDisallowedTools,
|
|
557391
557400
|
preDecidePermissions
|
|
557392
557401
|
},
|
|
@@ -557486,6 +557495,7 @@ class QueryEngine {
|
|
|
557486
557495
|
maxOutputTokensLimit,
|
|
557487
557496
|
contextWindow,
|
|
557488
557497
|
modelProviders: this.config.modelProviders,
|
|
557498
|
+
fetchOverride: this.config.fetchOverride,
|
|
557489
557499
|
subagentDisallowedTools: this.config.subagentDisallowedTools,
|
|
557490
557500
|
preDecidePermissions
|
|
557491
557501
|
},
|
|
@@ -557995,6 +558005,7 @@ async function* ask({
|
|
|
557995
558005
|
userSpecifiedModel,
|
|
557996
558006
|
fallbackModel,
|
|
557997
558007
|
modelProviders,
|
|
558008
|
+
fetchOverride,
|
|
557998
558009
|
jsonSchema,
|
|
557999
558010
|
getAppState,
|
|
558000
558011
|
setAppState,
|
|
@@ -558025,6 +558036,7 @@ async function* ask({
|
|
|
558025
558036
|
userSpecifiedModel,
|
|
558026
558037
|
fallbackModel,
|
|
558027
558038
|
modelProviders,
|
|
558039
|
+
fetchOverride,
|
|
558028
558040
|
thinkingConfig,
|
|
558029
558041
|
maxTurns,
|
|
558030
558042
|
maxBudgetUsd,
|
|
@@ -567412,7 +567424,7 @@ Usage: claude --remote "your task description"`, () => gracefulShutdown(1));
|
|
|
567412
567424
|
pendingHookMessages
|
|
567413
567425
|
}, renderAndRun);
|
|
567414
567426
|
}
|
|
567415
|
-
}).version("0.4.
|
|
567427
|
+
}).version("0.4.30 (OpenCow)", "-v, --version", "Output the version number");
|
|
567416
567428
|
program.option("-w, --worktree [name]", "Create a new git worktree for this session (optionally specify a name)");
|
|
567417
567429
|
program.option("--tmux", "Create a tmux session for the worktree (requires --worktree). Uses iTerm2 native panes when available; use --tmux=classic for traditional tmux.");
|
|
567418
567430
|
if (canUserConfigureAdvisor()) {
|
|
@@ -568007,7 +568019,7 @@ if (false) {}
|
|
|
568007
568019
|
async function main2() {
|
|
568008
568020
|
const args = process.argv.slice(2);
|
|
568009
568021
|
if (args.length === 1 && (args[0] === "--version" || args[0] === "-v" || args[0] === "-V")) {
|
|
568010
|
-
console.log(`${"0.4.
|
|
568022
|
+
console.log(`${"0.4.30"} (OpenCow)`);
|
|
568011
568023
|
return;
|
|
568012
568024
|
}
|
|
568013
568025
|
if (args.includes("--provider")) {
|
|
@@ -568107,4 +568119,4 @@ async function main2() {
|
|
|
568107
568119
|
}
|
|
568108
568120
|
main2();
|
|
568109
568121
|
|
|
568110
|
-
//# debugId=
|
|
568122
|
+
//# debugId=350424289A5BE31764756E2164756E21
|
package/dist/client.js
CHANGED
|
@@ -122191,16 +122191,17 @@ function getAssistantMessageFromError(error, model, options) {
|
|
|
122191
122191
|
error: "rate_limit"
|
|
122192
122192
|
});
|
|
122193
122193
|
}
|
|
122194
|
-
if (error instanceof APIError && error.status === 429
|
|
122195
|
-
const
|
|
122196
|
-
const
|
|
122194
|
+
if (error instanceof APIError && error.status === 429) {
|
|
122195
|
+
const quotaHeaders = shouldProcessRateLimits(isClaudeAISubscriber()) ? error.headers : undefined;
|
|
122196
|
+
const rateLimitType = quotaHeaders?.get?.("anthropic-ratelimit-unified-representative-claim");
|
|
122197
|
+
const overageStatus = quotaHeaders?.get?.("anthropic-ratelimit-unified-overage-status");
|
|
122197
122198
|
if (rateLimitType || overageStatus) {
|
|
122198
122199
|
const limits = {
|
|
122199
122200
|
status: "rejected",
|
|
122200
122201
|
unifiedRateLimitFallbackAvailable: false,
|
|
122201
122202
|
isUsingOverage: false
|
|
122202
122203
|
};
|
|
122203
|
-
const resetHeader =
|
|
122204
|
+
const resetHeader = quotaHeaders?.get?.("anthropic-ratelimit-unified-reset");
|
|
122204
122205
|
if (resetHeader) {
|
|
122205
122206
|
limits.resetsAt = Number(resetHeader);
|
|
122206
122207
|
}
|
|
@@ -122210,11 +122211,11 @@ function getAssistantMessageFromError(error, model, options) {
|
|
|
122210
122211
|
if (overageStatus) {
|
|
122211
122212
|
limits.overageStatus = overageStatus;
|
|
122212
122213
|
}
|
|
122213
|
-
const overageResetHeader =
|
|
122214
|
+
const overageResetHeader = quotaHeaders?.get?.("anthropic-ratelimit-unified-overage-reset");
|
|
122214
122215
|
if (overageResetHeader) {
|
|
122215
122216
|
limits.overageResetsAt = Number(overageResetHeader);
|
|
122216
122217
|
}
|
|
122217
|
-
const overageDisabledReason =
|
|
122218
|
+
const overageDisabledReason = quotaHeaders?.get?.("anthropic-ratelimit-unified-overage-disabled-reason");
|
|
122218
122219
|
if (overageDisabledReason) {
|
|
122219
122220
|
limits.overageDisabledReason = overageDisabledReason;
|
|
122220
122221
|
}
|
|
@@ -122355,6 +122356,13 @@ Run /share and post the JSON file to ${MACRO.FEEDBACK_CHANNEL}.`;
|
|
|
122355
122356
|
error: "billing_error"
|
|
122356
122357
|
});
|
|
122357
122358
|
}
|
|
122359
|
+
if (error instanceof APIError && (error.status === 402 || error.message.includes('"type":"billing_error"'))) {
|
|
122360
|
+
const detail = error.message.match(/"message"\s*:\s*"([^"]*)"/)?.[1];
|
|
122361
|
+
return createAssistantAPIErrorMessage({
|
|
122362
|
+
content: `${API_ERROR_MESSAGE_PREFIX}: ${detail || error.message}`,
|
|
122363
|
+
error: "billing_error"
|
|
122364
|
+
});
|
|
122365
|
+
}
|
|
122358
122366
|
if (error instanceof APIError && error.status === 400 && error.message.toLowerCase().includes("organization has been disabled")) {
|
|
122359
122367
|
const { source } = getAnthropicApiKeyWithSource();
|
|
122360
122368
|
if (source === "ANTHROPIC_API_KEY" && process.env.ANTHROPIC_API_KEY && !isClaudeAISubscriber()) {
|
|
@@ -176405,6 +176413,7 @@ async function* runAgent({
|
|
|
176405
176413
|
mcpResources: toolUseContext.options.mcpResources,
|
|
176406
176414
|
agentDefinitions: toolUseContext.options.agentDefinitions,
|
|
176407
176415
|
subagentDisallowedTools: toolUseContext.options.subagentDisallowedTools,
|
|
176416
|
+
fetchOverride: toolUseContext.options.fetchOverride,
|
|
176408
176417
|
...useExactTools && { querySource }
|
|
176409
176418
|
};
|
|
176410
176419
|
agentToolRuntimeContext = createSubagentContext(toolUseContext, {
|
|
@@ -226651,7 +226660,6 @@ async function* queryLoop(params, consumedCommandUuids) {
|
|
|
226651
226660
|
exceeds200kTokens: permissionMode === "plan" && doesMostRecentAssistantMessageExceed200k(messagesForQuery)
|
|
226652
226661
|
});
|
|
226653
226662
|
queryCheckpoint("query_setup_end");
|
|
226654
|
-
const dumpPromptsFetch = undefined;
|
|
226655
226663
|
let collapseOwnsIt = false;
|
|
226656
226664
|
if (false) {}
|
|
226657
226665
|
const mediaRecoveryEnabled = reactiveCompact?.isReactiveCompactEnabled() ?? false;
|
|
@@ -226704,7 +226712,7 @@ async function* queryLoop(params, consumedCommandUuids) {
|
|
|
226704
226712
|
hasAppendSystemPrompt: !!toolUseContext.options.appendSystemPrompt,
|
|
226705
226713
|
maxOutputTokensOverride,
|
|
226706
226714
|
maxOutputTokensLimitOverride: params.maxOutputTokensLimitOverride,
|
|
226707
|
-
fetchOverride:
|
|
226715
|
+
fetchOverride: toolUseContext.options.fetchOverride,
|
|
226708
226716
|
mcpTools: appState.mcp.tools,
|
|
226709
226717
|
hasPendingMcpServers: appState.mcp.clients.some((c) => c.type === "pending"),
|
|
226710
226718
|
queryTracking,
|
|
@@ -227383,7 +227391,7 @@ function getAnthropicEnvMetadata() {
|
|
|
227383
227391
|
function getBuildAgeMinutes() {
|
|
227384
227392
|
if (false)
|
|
227385
227393
|
;
|
|
227386
|
-
const buildTime = new Date("2026-11-
|
|
227394
|
+
const buildTime = new Date("2026-11-04T12:30:46.458Z").getTime();
|
|
227387
227395
|
if (isNaN(buildTime))
|
|
227388
227396
|
return;
|
|
227389
227397
|
return Math.floor((Date.now() - buildTime) / 60000);
|
|
@@ -271008,6 +271016,7 @@ class QueryEngine {
|
|
|
271008
271016
|
maxOutputTokensLimit,
|
|
271009
271017
|
contextWindow,
|
|
271010
271018
|
modelProviders: this.config.modelProviders,
|
|
271019
|
+
fetchOverride: this.config.fetchOverride,
|
|
271011
271020
|
subagentDisallowedTools: this.config.subagentDisallowedTools,
|
|
271012
271021
|
preDecidePermissions
|
|
271013
271022
|
},
|
|
@@ -271107,6 +271116,7 @@ class QueryEngine {
|
|
|
271107
271116
|
maxOutputTokensLimit,
|
|
271108
271117
|
contextWindow,
|
|
271109
271118
|
modelProviders: this.config.modelProviders,
|
|
271119
|
+
fetchOverride: this.config.fetchOverride,
|
|
271110
271120
|
subagentDisallowedTools: this.config.subagentDisallowedTools,
|
|
271111
271121
|
preDecidePermissions
|
|
271112
271122
|
},
|
|
@@ -271616,6 +271626,7 @@ async function* ask({
|
|
|
271616
271626
|
userSpecifiedModel,
|
|
271617
271627
|
fallbackModel,
|
|
271618
271628
|
modelProviders,
|
|
271629
|
+
fetchOverride,
|
|
271619
271630
|
jsonSchema,
|
|
271620
271631
|
getAppState,
|
|
271621
271632
|
setAppState,
|
|
@@ -271646,6 +271657,7 @@ async function* ask({
|
|
|
271646
271657
|
userSpecifiedModel,
|
|
271647
271658
|
fallbackModel,
|
|
271648
271659
|
modelProviders,
|
|
271660
|
+
fetchOverride,
|
|
271649
271661
|
thinkingConfig,
|
|
271650
271662
|
maxTurns,
|
|
271651
271663
|
maxBudgetUsd,
|
|
@@ -279288,6 +279300,7 @@ function runSdkQueryRuntime(params) {
|
|
|
279288
279300
|
fallbackModel: typeof options.fallbackModel === "string" && options.fallbackModel.length > 0 ? options.fallbackModel : undefined,
|
|
279289
279301
|
jsonSchema: options.jsonSchema && typeof options.jsonSchema === "object" ? options.jsonSchema : undefined,
|
|
279290
279302
|
modelProviders: options.modelProviders && typeof options.modelProviders === "object" ? options.modelProviders : undefined,
|
|
279303
|
+
fetchOverride: typeof options.fetchOverride === "function" ? options.fetchOverride : undefined,
|
|
279291
279304
|
getAppState: appStateStore.getAppState,
|
|
279292
279305
|
setAppState: appStateStore.setAppState,
|
|
279293
279306
|
abortController: runtimeState.abortController,
|
|
@@ -280615,4 +280628,4 @@ export {
|
|
|
280615
280628
|
watchScheduledTasks
|
|
280616
280629
|
};
|
|
280617
280630
|
|
|
280618
|
-
//# debugId=
|
|
280631
|
+
//# debugId=B13AF4A366BF432D64756E2164756E21
|
|
@@ -483,6 +483,13 @@ export type Options = {
|
|
|
483
483
|
* the catalog use the session provider config as before.
|
|
484
484
|
*/
|
|
485
485
|
modelProviders?: ModelProviders;
|
|
486
|
+
/**
|
|
487
|
+
* Host fetch for this session's model requests (main loop and subagents).
|
|
488
|
+
* Lets the host attach per-request headers or observe responses (e.g. surface
|
|
489
|
+
* a billing rejection in its own UI). Return the response unchanged unless the
|
|
490
|
+
* host deliberately alters retry semantics. Absent → global fetch.
|
|
491
|
+
*/
|
|
492
|
+
fetchOverride?: typeof globalThis.fetch;
|
|
486
493
|
/**
|
|
487
494
|
* Per-protocol passthrough channel for fields the wire supports but the
|
|
488
495
|
* SDK does not surface as first-class options. The shim merges these
|
package/dist/sdk.js
CHANGED
|
@@ -122191,16 +122191,17 @@ function getAssistantMessageFromError(error, model, options) {
|
|
|
122191
122191
|
error: "rate_limit"
|
|
122192
122192
|
});
|
|
122193
122193
|
}
|
|
122194
|
-
if (error instanceof APIError && error.status === 429
|
|
122195
|
-
const
|
|
122196
|
-
const
|
|
122194
|
+
if (error instanceof APIError && error.status === 429) {
|
|
122195
|
+
const quotaHeaders = shouldProcessRateLimits(isClaudeAISubscriber()) ? error.headers : undefined;
|
|
122196
|
+
const rateLimitType = quotaHeaders?.get?.("anthropic-ratelimit-unified-representative-claim");
|
|
122197
|
+
const overageStatus = quotaHeaders?.get?.("anthropic-ratelimit-unified-overage-status");
|
|
122197
122198
|
if (rateLimitType || overageStatus) {
|
|
122198
122199
|
const limits = {
|
|
122199
122200
|
status: "rejected",
|
|
122200
122201
|
unifiedRateLimitFallbackAvailable: false,
|
|
122201
122202
|
isUsingOverage: false
|
|
122202
122203
|
};
|
|
122203
|
-
const resetHeader =
|
|
122204
|
+
const resetHeader = quotaHeaders?.get?.("anthropic-ratelimit-unified-reset");
|
|
122204
122205
|
if (resetHeader) {
|
|
122205
122206
|
limits.resetsAt = Number(resetHeader);
|
|
122206
122207
|
}
|
|
@@ -122210,11 +122211,11 @@ function getAssistantMessageFromError(error, model, options) {
|
|
|
122210
122211
|
if (overageStatus) {
|
|
122211
122212
|
limits.overageStatus = overageStatus;
|
|
122212
122213
|
}
|
|
122213
|
-
const overageResetHeader =
|
|
122214
|
+
const overageResetHeader = quotaHeaders?.get?.("anthropic-ratelimit-unified-overage-reset");
|
|
122214
122215
|
if (overageResetHeader) {
|
|
122215
122216
|
limits.overageResetsAt = Number(overageResetHeader);
|
|
122216
122217
|
}
|
|
122217
|
-
const overageDisabledReason =
|
|
122218
|
+
const overageDisabledReason = quotaHeaders?.get?.("anthropic-ratelimit-unified-overage-disabled-reason");
|
|
122218
122219
|
if (overageDisabledReason) {
|
|
122219
122220
|
limits.overageDisabledReason = overageDisabledReason;
|
|
122220
122221
|
}
|
|
@@ -122355,6 +122356,13 @@ Run /share and post the JSON file to ${MACRO.FEEDBACK_CHANNEL}.`;
|
|
|
122355
122356
|
error: "billing_error"
|
|
122356
122357
|
});
|
|
122357
122358
|
}
|
|
122359
|
+
if (error instanceof APIError && (error.status === 402 || error.message.includes('"type":"billing_error"'))) {
|
|
122360
|
+
const detail = error.message.match(/"message"\s*:\s*"([^"]*)"/)?.[1];
|
|
122361
|
+
return createAssistantAPIErrorMessage({
|
|
122362
|
+
content: `${API_ERROR_MESSAGE_PREFIX}: ${detail || error.message}`,
|
|
122363
|
+
error: "billing_error"
|
|
122364
|
+
});
|
|
122365
|
+
}
|
|
122358
122366
|
if (error instanceof APIError && error.status === 400 && error.message.toLowerCase().includes("organization has been disabled")) {
|
|
122359
122367
|
const { source } = getAnthropicApiKeyWithSource();
|
|
122360
122368
|
if (source === "ANTHROPIC_API_KEY" && process.env.ANTHROPIC_API_KEY && !isClaudeAISubscriber()) {
|
|
@@ -176405,6 +176413,7 @@ async function* runAgent({
|
|
|
176405
176413
|
mcpResources: toolUseContext.options.mcpResources,
|
|
176406
176414
|
agentDefinitions: toolUseContext.options.agentDefinitions,
|
|
176407
176415
|
subagentDisallowedTools: toolUseContext.options.subagentDisallowedTools,
|
|
176416
|
+
fetchOverride: toolUseContext.options.fetchOverride,
|
|
176408
176417
|
...useExactTools && { querySource }
|
|
176409
176418
|
};
|
|
176410
176419
|
agentToolRuntimeContext = createSubagentContext(toolUseContext, {
|
|
@@ -226651,7 +226660,6 @@ async function* queryLoop(params, consumedCommandUuids) {
|
|
|
226651
226660
|
exceeds200kTokens: permissionMode === "plan" && doesMostRecentAssistantMessageExceed200k(messagesForQuery)
|
|
226652
226661
|
});
|
|
226653
226662
|
queryCheckpoint("query_setup_end");
|
|
226654
|
-
const dumpPromptsFetch = undefined;
|
|
226655
226663
|
let collapseOwnsIt = false;
|
|
226656
226664
|
if (false) {}
|
|
226657
226665
|
const mediaRecoveryEnabled = reactiveCompact?.isReactiveCompactEnabled() ?? false;
|
|
@@ -226704,7 +226712,7 @@ async function* queryLoop(params, consumedCommandUuids) {
|
|
|
226704
226712
|
hasAppendSystemPrompt: !!toolUseContext.options.appendSystemPrompt,
|
|
226705
226713
|
maxOutputTokensOverride,
|
|
226706
226714
|
maxOutputTokensLimitOverride: params.maxOutputTokensLimitOverride,
|
|
226707
|
-
fetchOverride:
|
|
226715
|
+
fetchOverride: toolUseContext.options.fetchOverride,
|
|
226708
226716
|
mcpTools: appState.mcp.tools,
|
|
226709
226717
|
hasPendingMcpServers: appState.mcp.clients.some((c) => c.type === "pending"),
|
|
226710
226718
|
queryTracking,
|
|
@@ -227383,7 +227391,7 @@ function getAnthropicEnvMetadata() {
|
|
|
227383
227391
|
function getBuildAgeMinutes() {
|
|
227384
227392
|
if (false)
|
|
227385
227393
|
;
|
|
227386
|
-
const buildTime = new Date("2026-11-
|
|
227394
|
+
const buildTime = new Date("2026-11-04T12:30:46.458Z").getTime();
|
|
227387
227395
|
if (isNaN(buildTime))
|
|
227388
227396
|
return;
|
|
227389
227397
|
return Math.floor((Date.now() - buildTime) / 60000);
|
|
@@ -271008,6 +271016,7 @@ class QueryEngine {
|
|
|
271008
271016
|
maxOutputTokensLimit,
|
|
271009
271017
|
contextWindow,
|
|
271010
271018
|
modelProviders: this.config.modelProviders,
|
|
271019
|
+
fetchOverride: this.config.fetchOverride,
|
|
271011
271020
|
subagentDisallowedTools: this.config.subagentDisallowedTools,
|
|
271012
271021
|
preDecidePermissions
|
|
271013
271022
|
},
|
|
@@ -271107,6 +271116,7 @@ class QueryEngine {
|
|
|
271107
271116
|
maxOutputTokensLimit,
|
|
271108
271117
|
contextWindow,
|
|
271109
271118
|
modelProviders: this.config.modelProviders,
|
|
271119
|
+
fetchOverride: this.config.fetchOverride,
|
|
271110
271120
|
subagentDisallowedTools: this.config.subagentDisallowedTools,
|
|
271111
271121
|
preDecidePermissions
|
|
271112
271122
|
},
|
|
@@ -271616,6 +271626,7 @@ async function* ask({
|
|
|
271616
271626
|
userSpecifiedModel,
|
|
271617
271627
|
fallbackModel,
|
|
271618
271628
|
modelProviders,
|
|
271629
|
+
fetchOverride,
|
|
271619
271630
|
jsonSchema,
|
|
271620
271631
|
getAppState,
|
|
271621
271632
|
setAppState,
|
|
@@ -271646,6 +271657,7 @@ async function* ask({
|
|
|
271646
271657
|
userSpecifiedModel,
|
|
271647
271658
|
fallbackModel,
|
|
271648
271659
|
modelProviders,
|
|
271660
|
+
fetchOverride,
|
|
271649
271661
|
thinkingConfig,
|
|
271650
271662
|
maxTurns,
|
|
271651
271663
|
maxBudgetUsd,
|
|
@@ -279288,6 +279300,7 @@ function runSdkQueryRuntime(params) {
|
|
|
279288
279300
|
fallbackModel: typeof options.fallbackModel === "string" && options.fallbackModel.length > 0 ? options.fallbackModel : undefined,
|
|
279289
279301
|
jsonSchema: options.jsonSchema && typeof options.jsonSchema === "object" ? options.jsonSchema : undefined,
|
|
279290
279302
|
modelProviders: options.modelProviders && typeof options.modelProviders === "object" ? options.modelProviders : undefined,
|
|
279303
|
+
fetchOverride: typeof options.fetchOverride === "function" ? options.fetchOverride : undefined,
|
|
279291
279304
|
getAppState: appStateStore.getAppState,
|
|
279292
279305
|
setAppState: appStateStore.setAppState,
|
|
279293
279306
|
abortController: runtimeState.abortController,
|
|
@@ -280615,4 +280628,4 @@ export {
|
|
|
280615
280628
|
watchScheduledTasks
|
|
280616
280629
|
};
|
|
280617
280630
|
|
|
280618
|
-
//# debugId=
|
|
280631
|
+
//# debugId=12B4F50CE40DB29164756E2164756E21
|
|
@@ -124,6 +124,8 @@ export type ToolRuntimeContext = {
|
|
|
124
124
|
* wire/endpoint than the main session gets its own provider override.
|
|
125
125
|
*/
|
|
126
126
|
modelProviders?: ModelProviders;
|
|
127
|
+
/** Host fetch for model requests (see Options.fetchOverride); propagated to subagents. */
|
|
128
|
+
fetchOverride?: typeof globalThis.fetch;
|
|
127
129
|
/**
|
|
128
130
|
* Tool names excluded from sub-agents only (see Options.subagentDisallowedTools).
|
|
129
131
|
* Applied by runAgent via filterSubagentDisallowedTools and propagated to
|
package/package.json
CHANGED