@gaburieuru/claudio 0.25.0 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +343 -346
- package/dist/cli.mjs +96 -79
- package/dist/sdk.mjs +284 -61
- package/package.json +211 -211
package/dist/sdk.mjs
CHANGED
|
@@ -16982,7 +16982,7 @@ var init_version = __esm(() => {
|
|
|
16982
16982
|
import_semver = __toESM(require_semver2(), 1);
|
|
16983
16983
|
fallbackBuildVersion = (() => {
|
|
16984
16984
|
try {
|
|
16985
|
-
return "0.
|
|
16985
|
+
return "0.26.0";
|
|
16986
16986
|
} catch {
|
|
16987
16987
|
return "0.0.0";
|
|
16988
16988
|
}
|
|
@@ -65989,7 +65989,7 @@ function getRemoteSessionUrl(sessionId, ingressUrl) {
|
|
|
65989
65989
|
const baseUrl = getClaudeAiBaseUrl(compatId, ingressUrl);
|
|
65990
65990
|
return `${baseUrl}/code/${compatId}`;
|
|
65991
65991
|
}
|
|
65992
|
-
var PRODUCT_DISPLAY_NAME = "
|
|
65992
|
+
var PRODUCT_DISPLAY_NAME = "Claude", PRODUCT_URL = "https://claude.com/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", STAGING_INGRESS_HOSTNAME = "api-staging.anthropic.com", STAGING_INGRESS_HOST_SUFFIX = ".staging.ant.dev";
|
|
65993
65993
|
|
|
65994
65994
|
// src/constants/system.ts
|
|
65995
65995
|
function getCLISyspromptPrefix(options) {
|
|
@@ -66015,7 +66015,7 @@ function getAttributionHeader(fingerprint) {
|
|
|
66015
66015
|
if (!isAttributionHeaderEnabled()) {
|
|
66016
66016
|
return "";
|
|
66017
66017
|
}
|
|
66018
|
-
const version2 = `${"0.
|
|
66018
|
+
const version2 = `${"0.26.0"}.${fingerprint}`;
|
|
66019
66019
|
const entrypoint = process.env.CLAUDE_CODE_ENTRYPOINT ?? "unknown";
|
|
66020
66020
|
const cch = "";
|
|
66021
66021
|
const workload = getWorkload();
|
|
@@ -99108,7 +99108,7 @@ var init_metadata = __esm(() => {
|
|
|
99108
99108
|
COMPOUND_OPERATOR_REGEX = /\s*(?:&&|\|\||[;|])\s*/;
|
|
99109
99109
|
WHITESPACE_REGEX = /\s+/;
|
|
99110
99110
|
getVersionBase = memoize_default(() => {
|
|
99111
|
-
const match = "0.
|
|
99111
|
+
const match = "0.26.0".match(/^\d+\.\d+\.\d+(?:-[a-z]+)?/);
|
|
99112
99112
|
return match ? match[0] : undefined;
|
|
99113
99113
|
});
|
|
99114
99114
|
buildEnvContext = memoize_default(async () => {
|
|
@@ -99148,9 +99148,9 @@ var init_metadata = __esm(() => {
|
|
|
99148
99148
|
isGithubAction: isEnvTruthy(process.env.GITHUB_ACTIONS),
|
|
99149
99149
|
isClaudeCodeAction: isEnvTruthy(process.env.CLAUDE_CODE_ACTION),
|
|
99150
99150
|
isClaudeAiAuth: isClaudeAISubscriber(),
|
|
99151
|
-
version: "0.
|
|
99151
|
+
version: "0.26.0",
|
|
99152
99152
|
versionBase: getVersionBase(),
|
|
99153
|
-
buildTime: "2026-07-
|
|
99153
|
+
buildTime: "2026-07-19T22:54:23.872Z",
|
|
99154
99154
|
deploymentEnvironment: env2.detectDeploymentEnvironment(),
|
|
99155
99155
|
...isEnvTruthy(process.env.GITHUB_ACTIONS) && {
|
|
99156
99156
|
githubEventName: process.env.GITHUB_EVENT_NAME,
|
|
@@ -107594,7 +107594,7 @@ var init_effort = __esm(() => {
|
|
|
107594
107594
|
|
|
107595
107595
|
// src/utils/userAgent.ts
|
|
107596
107596
|
function getClaudeCodeUserAgent() {
|
|
107597
|
-
return `claude-code/${"0.
|
|
107597
|
+
return `claude-code/${"0.26.0"}`;
|
|
107598
107598
|
}
|
|
107599
107599
|
|
|
107600
107600
|
// src/utils/http.ts
|
|
@@ -107603,7 +107603,7 @@ function getUserAgent() {
|
|
|
107603
107603
|
const clientApp = process.env.CLAUDE_AGENT_SDK_CLIENT_APP ? `, client-app/${process.env.CLAUDE_AGENT_SDK_CLIENT_APP}` : "";
|
|
107604
107604
|
const workload = getWorkload();
|
|
107605
107605
|
const workloadSuffix = workload ? `, workload/${workload}` : "";
|
|
107606
|
-
return `claude-cli/${"0.
|
|
107606
|
+
return `claude-cli/${"0.26.0"} (${process.env.USER_TYPE}, ${process.env.CLAUDE_CODE_ENTRYPOINT ?? "cli"}${agentSdkVersion}${clientApp}${workloadSuffix})`;
|
|
107607
107607
|
}
|
|
107608
107608
|
function getMCPUserAgent() {
|
|
107609
107609
|
const parts = [];
|
|
@@ -107617,7 +107617,7 @@ function getMCPUserAgent() {
|
|
|
107617
107617
|
parts.push(`client-app/${process.env.CLAUDE_AGENT_SDK_CLIENT_APP}`);
|
|
107618
107618
|
}
|
|
107619
107619
|
const suffix = parts.length > 0 ? ` (${parts.join(", ")})` : "";
|
|
107620
|
-
return `claude-code/${"0.
|
|
107620
|
+
return `claude-code/${"0.26.0"}${suffix}`;
|
|
107621
107621
|
}
|
|
107622
107622
|
function getWebFetchUserAgent() {
|
|
107623
107623
|
const supportUrl = isFirstPartyAnthropicProvider() ? "https://support.anthropic.com/" : "https://github.com/Gitlawb/openclaude";
|
|
@@ -147496,7 +147496,7 @@ function computeFingerprint(messageText, version2) {
|
|
|
147496
147496
|
}
|
|
147497
147497
|
function computeFingerprintFromMessages(messages) {
|
|
147498
147498
|
const firstMessageText = extractFirstMessageText(messages);
|
|
147499
|
-
return computeFingerprint(firstMessageText, "0.
|
|
147499
|
+
return computeFingerprint(firstMessageText, "0.26.0");
|
|
147500
147500
|
}
|
|
147501
147501
|
var FINGERPRINT_SALT = "59cf53e54c78";
|
|
147502
147502
|
var init_fingerprint = () => {};
|
|
@@ -147538,7 +147538,7 @@ async function sideQuery(opts) {
|
|
|
147538
147538
|
betas.push(STRUCTURED_OUTPUTS_BETA_HEADER);
|
|
147539
147539
|
}
|
|
147540
147540
|
const messageText = extractFirstUserMessageText(messages);
|
|
147541
|
-
const fingerprint = computeFingerprint(messageText, "0.
|
|
147541
|
+
const fingerprint = computeFingerprint(messageText, "0.26.0");
|
|
147542
147542
|
const attributionHeader = getAttributionHeader(fingerprint);
|
|
147543
147543
|
const systemBlocks = [
|
|
147544
147544
|
attributionHeader ? { type: "text", text: attributionHeader } : null,
|
|
@@ -148831,7 +148831,7 @@ var init_client2 = __esm(() => {
|
|
|
148831
148831
|
const client = new Client({
|
|
148832
148832
|
name: "claude-code",
|
|
148833
148833
|
title: "Claudio",
|
|
148834
|
-
version: "0.
|
|
148834
|
+
version: "0.26.0",
|
|
148835
148835
|
description: "Claudio — coding-agent CLI for any LLM provider",
|
|
148836
148836
|
websiteUrl: PRODUCT_URL
|
|
148837
148837
|
}, {
|
|
@@ -159129,7 +159129,7 @@ async function processSlashCommand(inputString, precedingInputBlocks, imageConte
|
|
|
159129
159129
|
precedingInputBlocks
|
|
159130
159130
|
})
|
|
159131
159131
|
}),
|
|
159132
|
-
...parsedArgs ? [
|
|
159132
|
+
...parsedArgs ? [createSystemMessage2(`Args from unknown skill: ${parsedArgs}`, "warning")] : []
|
|
159133
159133
|
],
|
|
159134
159134
|
shouldQuery: false,
|
|
159135
159135
|
resultText: unknownMessage
|
|
@@ -222831,7 +222831,7 @@ async function* evaluateGoalAfterTurn({
|
|
|
222831
222831
|
const paused = pauseGoalAtMaxTurns(goal, terminalUuid, nowIso());
|
|
222832
222832
|
toolUseContext.setAppState((prev) => ({ ...prev, goal: paused }));
|
|
222833
222833
|
await persistGoal(saveGoalState2, paused, logGoalPersistenceFailure);
|
|
222834
|
-
yield
|
|
222834
|
+
yield createSystemMessage2(paused.lastReason ?? "Goal paused: automatic continuation has been paused.", "warning");
|
|
222835
222835
|
return [];
|
|
222836
222836
|
}
|
|
222837
222837
|
if (!shouldEvaluateGoal(goal, terminalUuid))
|
|
@@ -222855,7 +222855,7 @@ async function* evaluateGoalAfterTurn({
|
|
|
222855
222855
|
});
|
|
222856
222856
|
toolUseContext.setAppState((prev) => ({ ...prev, goal: achieved }));
|
|
222857
222857
|
await persistGoal(saveGoalState2, achieved, logGoalPersistenceFailure);
|
|
222858
|
-
yield
|
|
222858
|
+
yield createSystemMessage2(`Goal achieved: ${decision.reason}`, "info");
|
|
222859
222859
|
return [];
|
|
222860
222860
|
}
|
|
222861
222861
|
if (decision.decision === "malformed" || decision.decision === "error") {
|
|
@@ -222869,7 +222869,7 @@ async function* evaluateGoalAfterTurn({
|
|
|
222869
222869
|
}), now);
|
|
222870
222870
|
toolUseContext.setAppState((prev) => ({ ...prev, goal: paused }));
|
|
222871
222871
|
await persistGoal(saveGoalState2, paused, logGoalPersistenceFailure);
|
|
222872
|
-
yield
|
|
222872
|
+
yield createSystemMessage2(`Goal paused: ${decision.reason}`, "warning");
|
|
222873
222873
|
return [];
|
|
222874
222874
|
}
|
|
222875
222875
|
const updatedGoal = markGoalEvaluated(goal, {
|
|
@@ -222882,12 +222882,12 @@ async function* evaluateGoalAfterTurn({
|
|
|
222882
222882
|
const paused = pauseGoalAtMaxTurns(updatedGoal, terminalUuid, nowIso(), decision.reason);
|
|
222883
222883
|
toolUseContext.setAppState((prev) => ({ ...prev, goal: paused }));
|
|
222884
222884
|
await persistGoal(saveGoalState2, paused, logGoalPersistenceFailure);
|
|
222885
|
-
yield
|
|
222885
|
+
yield createSystemMessage2(`Goal not complete: ${decision.reason} Goal paused after reaching the maximum of ${updatedGoal.maxTurns} turns.`, "warning");
|
|
222886
222886
|
return [];
|
|
222887
222887
|
}
|
|
222888
222888
|
toolUseContext.setAppState((prev) => ({ ...prev, goal: updatedGoal }));
|
|
222889
222889
|
await persistGoal(saveGoalState2, updatedGoal, logGoalPersistenceFailure);
|
|
222890
|
-
yield
|
|
222890
|
+
yield createSystemMessage2(`Goal not complete: ${decision.reason}`, "info");
|
|
222891
222891
|
return [
|
|
222892
222892
|
createUserMessage({
|
|
222893
222893
|
content: buildGoalContinuationInstruction(updatedGoal, decision),
|
|
@@ -223025,7 +223025,7 @@ async function* handleStopHooks(messagesForQuery, assistantMessages, systemPromp
|
|
|
223025
223025
|
});
|
|
223026
223026
|
const abortSystemMessage = getQueryAbortSystemMessage(abortReason2);
|
|
223027
223027
|
if (abortSystemMessage) {
|
|
223028
|
-
yield
|
|
223028
|
+
yield createSystemMessage2(abortSystemMessage, "warning");
|
|
223029
223029
|
}
|
|
223030
223030
|
if (shouldCreateUserInterruptionMessage(abortReason2)) {
|
|
223031
223031
|
yield createUserInterruptionMessage({
|
|
@@ -223196,7 +223196,7 @@ async function* handleStopHooks(messagesForQuery, assistantMessages, systemPromp
|
|
|
223196
223196
|
queryChainId: toolUseContext.queryTracking?.chainId,
|
|
223197
223197
|
queryDepth: toolUseContext.queryTracking?.depth
|
|
223198
223198
|
});
|
|
223199
|
-
yield
|
|
223199
|
+
yield createSystemMessage2(`Stop hook failed: ${errorMessage(error40)}`, "warning");
|
|
223200
223200
|
return {
|
|
223201
223201
|
blockingErrors: [],
|
|
223202
223202
|
preventContinuation: false,
|
|
@@ -223753,10 +223753,10 @@ function createAutoCompactDiagnosticMessage(args) {
|
|
|
223753
223753
|
if (circuitBreakerActive || circuitBreakerTripped) {
|
|
223754
223754
|
const retryDelayMs = nextRetryAtMs !== undefined ? nextRetryAtMs - Date.now() : undefined;
|
|
223755
223755
|
const retryText = retryDelayMs !== undefined && retryDelayMs > 0 ? ` It will retry after ${formatAutoCompactRetryDelay(retryDelayMs)}.` : "";
|
|
223756
|
-
return
|
|
223756
|
+
return createSystemMessage2(`Automatic compaction is paused after repeated failures.${retryText} Claudio will stop before sending oversized requests while the guard is active.`, "warning");
|
|
223757
223757
|
}
|
|
223758
223758
|
if (consecutiveFailures !== undefined && consecutiveFailures > 0) {
|
|
223759
|
-
return
|
|
223759
|
+
return createSystemMessage2(`Automatic compaction failed (${consecutiveFailures}/${MAX_CONSECUTIVE_AUTOCOMPACT_FAILURES}); Claudio will retry compaction on the next eligible turn.`, "warning");
|
|
223760
223760
|
}
|
|
223761
223761
|
return;
|
|
223762
223762
|
}
|
|
@@ -224053,7 +224053,7 @@ async function* queryLoop(params, consumedCommandUuids) {
|
|
|
224053
224053
|
sessionId: getSessionId()
|
|
224054
224054
|
});
|
|
224055
224055
|
if (pinnedTurnRoute.routed === false && pinnedTurnRoute.justDisabledForSession) {
|
|
224056
|
-
yield
|
|
224056
|
+
yield createSystemMessage2("Smart routing disabled for this session: both configured models are outside the org allowlist. Using the default model.", "warning");
|
|
224057
224057
|
}
|
|
224058
224058
|
if (pinnedTurnRoute.routed) {
|
|
224059
224059
|
recordRoutingDecision(pinnedTurnRoute.complexity);
|
|
@@ -224321,7 +224321,7 @@ async function* queryLoop(params, consumedCommandUuids) {
|
|
|
224321
224321
|
queryChainId: queryChainIdForAnalytics,
|
|
224322
224322
|
queryDepth: queryTracking.depth
|
|
224323
224323
|
});
|
|
224324
|
-
yield
|
|
224324
|
+
yield createSystemMessage2(`Switched to ${renderModelName(innerError.fallbackModel)} due to high demand for ${renderModelName(innerError.originalModel)}`, "warning");
|
|
224325
224325
|
continue;
|
|
224326
224326
|
}
|
|
224327
224327
|
if (pinnedTurnRoute?.routed && pinnedTurnRoute.complexity === "simple" && !routedFallbackUsed && !(innerError instanceof FallbackTriggeredError) && !toolUseContext.abortController.signal.aborted && isRetryableRoutedModelError(innerError)) {
|
|
@@ -224348,7 +224348,7 @@ async function* queryLoop(params, consumedCommandUuids) {
|
|
|
224348
224348
|
currentModel = strongModel;
|
|
224349
224349
|
toolUseContext.options.mainLoopModel = strongModel;
|
|
224350
224350
|
messagesForQuery = stripThinkingBlocksIfProviderAllows(messagesForQuery);
|
|
224351
|
-
yield
|
|
224351
|
+
yield createSystemMessage2(`Smart routing: retrying on ${renderModelName(strongModel)} after the simple model failed`, "warning");
|
|
224352
224352
|
continue;
|
|
224353
224353
|
}
|
|
224354
224354
|
throw innerError;
|
|
@@ -224393,7 +224393,7 @@ async function* queryLoop(params, consumedCommandUuids) {
|
|
|
224393
224393
|
if (false) {}
|
|
224394
224394
|
const abortSystemMessage = getQueryAbortSystemMessage(abortReason2);
|
|
224395
224395
|
if (abortSystemMessage) {
|
|
224396
|
-
yield
|
|
224396
|
+
yield createSystemMessage2(abortSystemMessage, "warning");
|
|
224397
224397
|
}
|
|
224398
224398
|
if (shouldCreateUserInterruptionMessage(abortReason2)) {
|
|
224399
224399
|
yield createUserInterruptionMessage({
|
|
@@ -224500,7 +224500,7 @@ async function* queryLoop(params, consumedCommandUuids) {
|
|
|
224500
224500
|
return { reason: "prompt_too_long" };
|
|
224501
224501
|
}
|
|
224502
224502
|
if (shouldRecoverContextOverflow(lastMessage, hasAttemptedContextOverflowRecovery, querySource)) {
|
|
224503
|
-
yield
|
|
224503
|
+
yield createSystemMessage2("Provider context limit reached; compacting conversation and retrying turn.", "warning");
|
|
224504
224504
|
const nextTracking = {
|
|
224505
224505
|
...tracking ?? { compacted: false, turnId: "", turnCounter: 0 },
|
|
224506
224506
|
forceReason: "context-overflow"
|
|
@@ -224536,7 +224536,7 @@ async function* queryLoop(params, consumedCommandUuids) {
|
|
|
224536
224536
|
previousMaxOutputTokensOverride: effectiveMaxOutputTokensOverride
|
|
224537
224537
|
}
|
|
224538
224538
|
});
|
|
224539
|
-
yield
|
|
224539
|
+
yield createSystemMessage2(`Provider maximum output tokens limit is ${providerMaxTokensCap.toLocaleString("en-US")}; retrying with that cap.`, "warning");
|
|
224540
224540
|
const next2 = {
|
|
224541
224541
|
messages: messagesForQuery,
|
|
224542
224542
|
toolUseContext,
|
|
@@ -224638,7 +224638,7 @@ async function* queryLoop(params, consumedCommandUuids) {
|
|
|
224638
224638
|
}));
|
|
224639
224639
|
toolUseContext.options.mainLoopModel = activatedModel;
|
|
224640
224640
|
}
|
|
224641
|
-
yield
|
|
224641
|
+
yield createSystemMessage2(`Provider ${fromLabel} rate-limited — switched to ${activated.name}. Retrying turn.`, "warning");
|
|
224642
224642
|
const next2 = {
|
|
224643
224643
|
messages: messagesForQuery,
|
|
224644
224644
|
toolUseContext,
|
|
@@ -224861,7 +224861,7 @@ async function* queryLoop(params, consumedCommandUuids) {
|
|
|
224861
224861
|
if (false) {}
|
|
224862
224862
|
const abortSystemMessage = getQueryAbortSystemMessage(abortReason2);
|
|
224863
224863
|
if (abortSystemMessage) {
|
|
224864
|
-
yield
|
|
224864
|
+
yield createSystemMessage2(abortSystemMessage, "warning");
|
|
224865
224865
|
}
|
|
224866
224866
|
if (shouldCreateUserInterruptionMessage(abortReason2)) {
|
|
224867
224867
|
yield createUserInterruptionMessage({
|
|
@@ -225212,7 +225212,7 @@ function getAnthropicEnvMetadata() {
|
|
|
225212
225212
|
function getBuildAgeMinutes() {
|
|
225213
225213
|
if (false)
|
|
225214
225214
|
;
|
|
225215
|
-
const buildTime = new Date("2026-07-
|
|
225215
|
+
const buildTime = new Date("2026-07-19T22:54:23.872Z").getTime();
|
|
225216
225216
|
if (isNaN(buildTime))
|
|
225217
225217
|
return;
|
|
225218
225218
|
return Math.floor((Date.now() - buildTime) / 60000);
|
|
@@ -236882,6 +236882,14 @@ function convertChunkUsage(usage) {
|
|
|
236882
236882
|
return;
|
|
236883
236883
|
return buildAnthropicUsageFromRawUsage(usage);
|
|
236884
236884
|
}
|
|
236885
|
+
function ensureMessageDeltaUsage(usage) {
|
|
236886
|
+
return {
|
|
236887
|
+
input_tokens: usage?.input_tokens ?? 0,
|
|
236888
|
+
output_tokens: usage?.output_tokens ?? 0,
|
|
236889
|
+
cache_creation_input_tokens: usage?.cache_creation_input_tokens ?? 0,
|
|
236890
|
+
cache_read_input_tokens: usage?.cache_read_input_tokens ?? 0
|
|
236891
|
+
};
|
|
236892
|
+
}
|
|
236885
236893
|
function couldBeRawToolCallsRequestedPrefix(text) {
|
|
236886
236894
|
const trimmedStart = text.trimStart();
|
|
236887
236895
|
return RAW_TOOL_CALLS_REQUESTED_PREFIX.startsWith(trimmedStart) || trimmedStart.startsWith(RAW_TOOL_CALLS_REQUESTED_PREFIX);
|
|
@@ -237327,7 +237335,7 @@ async function* geminiSseToAnthropic(response, model, signal) {
|
|
|
237327
237335
|
yield {
|
|
237328
237336
|
type: "message_delta",
|
|
237329
237337
|
delta: { stop_reason: mapFinishReason(finishReason, hasEmittedCurrentTool) },
|
|
237330
|
-
usage: usage
|
|
237338
|
+
usage: ensureMessageDeltaUsage(usage)
|
|
237331
237339
|
};
|
|
237332
237340
|
throwIfStreamAborted2(signal);
|
|
237333
237341
|
yield { type: "message_stop" };
|
|
@@ -237441,7 +237449,7 @@ async function* geminiSseToAnthropic(response, model, signal) {
|
|
|
237441
237449
|
yield {
|
|
237442
237450
|
type: "message_delta",
|
|
237443
237451
|
delta: { stop_reason: mapFinishReason(finishReason, hasEmittedCurrentTool) },
|
|
237444
|
-
usage: usage
|
|
237452
|
+
usage: ensureMessageDeltaUsage(usage)
|
|
237445
237453
|
};
|
|
237446
237454
|
throwIfStreamAborted2(signal);
|
|
237447
237455
|
yield { type: "message_stop" };
|
|
@@ -237659,7 +237667,7 @@ async function* openaiStreamToAnthropic(response, model, signal, isOllama = fals
|
|
|
237659
237667
|
stop_reason: message.stop_reason,
|
|
237660
237668
|
stop_sequence: null
|
|
237661
237669
|
},
|
|
237662
|
-
usage: message.usage
|
|
237670
|
+
usage: ensureMessageDeltaUsage(message.usage)
|
|
237663
237671
|
};
|
|
237664
237672
|
yield { type: "message_stop" };
|
|
237665
237673
|
return;
|
|
@@ -238225,11 +238233,9 @@ async function* openaiStreamToAnthropic(response, model, signal, isOllama = fals
|
|
|
238225
238233
|
yield {
|
|
238226
238234
|
type: "message_delta",
|
|
238227
238235
|
delta: { stop_reason: stopReason, stop_sequence: null },
|
|
238228
|
-
|
|
238236
|
+
usage: ensureMessageDeltaUsage(chunkUsage)
|
|
238229
238237
|
};
|
|
238230
|
-
|
|
238231
|
-
hasEmittedFinalUsage = true;
|
|
238232
|
-
}
|
|
238238
|
+
hasEmittedFinalUsage = true;
|
|
238233
238239
|
}
|
|
238234
238240
|
}
|
|
238235
238241
|
if (!hasEmittedFinalUsage && chunkUsage && (chunk.choices?.length ?? 0) === 0 && lastStopReason !== null) {
|
|
@@ -238237,7 +238243,7 @@ async function* openaiStreamToAnthropic(response, model, signal, isOllama = fals
|
|
|
238237
238243
|
yield {
|
|
238238
238244
|
type: "message_delta",
|
|
238239
238245
|
delta: { stop_reason: lastStopReason, stop_sequence: null },
|
|
238240
|
-
usage: chunkUsage
|
|
238246
|
+
usage: ensureMessageDeltaUsage(chunkUsage)
|
|
238241
238247
|
};
|
|
238242
238248
|
hasEmittedFinalUsage = true;
|
|
238243
238249
|
}
|
|
@@ -247971,7 +247977,7 @@ function projectSnippedView(messages) {
|
|
|
247971
247977
|
|
|
247972
247978
|
// src/utils/messages/systemFactories.ts
|
|
247973
247979
|
import { randomUUID as randomUUID20 } from "crypto";
|
|
247974
|
-
function
|
|
247980
|
+
function createSystemMessage2(content, level, toolUseID, preventContinuation) {
|
|
247975
247981
|
return {
|
|
247976
247982
|
type: "system",
|
|
247977
247983
|
subtype: "informational",
|
|
@@ -248262,7 +248268,7 @@ __export(exports_messages, {
|
|
|
248262
248268
|
createTurnDurationMessage: () => createTurnDurationMessage,
|
|
248263
248269
|
createToolUseSummaryMessage: () => createToolUseSummaryMessage,
|
|
248264
248270
|
createToolResultStopMessage: () => createToolResultStopMessage,
|
|
248265
|
-
createSystemMessage: () =>
|
|
248271
|
+
createSystemMessage: () => createSystemMessage2,
|
|
248266
248272
|
createSystemAPIErrorMessage: () => createSystemAPIErrorMessage,
|
|
248267
248273
|
createSyntheticUserCaveatMessage: () => createSyntheticUserCaveatMessage,
|
|
248268
248274
|
createStopHookSummaryMessage: () => createStopHookSummaryMessage,
|
|
@@ -254112,7 +254118,7 @@ var init_sessionStorage = __esm(() => {
|
|
|
254112
254118
|
init_sessionPersistencePolicy();
|
|
254113
254119
|
init_slowOperations();
|
|
254114
254120
|
init_uuid();
|
|
254115
|
-
VERSION3 = typeof MACRO !== "undefined" ? "0.
|
|
254121
|
+
VERSION3 = typeof MACRO !== "undefined" ? "0.26.0" : "unknown";
|
|
254116
254122
|
MAX_TOMBSTONE_REWRITE_BYTES = 50 * 1024 * 1024;
|
|
254117
254123
|
SKIP_FIRST_PROMPT_PATTERN2 = /^(?:\s*<[a-z][\w-]*[\s>]|\[Request interrupted by user[^\]]*\])/;
|
|
254118
254124
|
EPHEMERAL_PROGRESS_TYPES = new Set([
|
|
@@ -255557,7 +255563,7 @@ var init_filesystem = __esm(() => {
|
|
|
255557
255563
|
});
|
|
255558
255564
|
getBundledSkillsRoot = memoize_default(function getBundledSkillsRoot2() {
|
|
255559
255565
|
const nonce = randomBytes8(16).toString("hex");
|
|
255560
|
-
return join84(getClaudeTempDir(), "bundled-skills", "0.
|
|
255566
|
+
return join84(getClaudeTempDir(), "bundled-skills", "0.26.0", nonce);
|
|
255561
255567
|
});
|
|
255562
255568
|
getResolvedWorkingDirPaths = memoize_default(getPathsForPermissionCheck);
|
|
255563
255569
|
});
|
|
@@ -261564,7 +261570,7 @@ function getSimpleDoingTasksSection() {
|
|
|
261564
261570
|
] : []
|
|
261565
261571
|
];
|
|
261566
261572
|
const userHelpSubitems = [
|
|
261567
|
-
`/help: Get help with using
|
|
261573
|
+
`/help: Get help with using Claude`,
|
|
261568
261574
|
`To give feedback, users should ${"report the issue at https://github.com/Gitlawb/openclaude/issues"}`
|
|
261569
261575
|
];
|
|
261570
261576
|
const items = [
|
|
@@ -261584,7 +261590,7 @@ function getSimpleDoingTasksSection() {
|
|
|
261584
261590
|
`Report outcomes faithfully: if tests fail, say so with the relevant output; if you did not run a verification step, say that rather than implying it succeeded. Never claim "all tests pass" when output shows failures, never suppress or simplify failing checks (tests, lints, type errors) to manufacture a green result, and never characterize incomplete or broken work as done. Equally, when a check did pass or a task is complete, state it plainly — do not hedge confirmed results with unnecessary disclaimers, downgrade finished work to "partial," or re-verify things you already checked. The goal is an accurate report, not a defensive one.`
|
|
261585
261591
|
] : [],
|
|
261586
261592
|
...process.env.USER_TYPE === "ant" ? [
|
|
261587
|
-
`If the user reports a bug, slowness, or unexpected behavior with
|
|
261593
|
+
`If the user reports a bug, slowness, or unexpected behavior with Claude itself (as opposed to asking you to fix their own code), recommend the appropriate slash command: /issue for model-related problems (odd outputs, wrong tool choices, hallucinations, refusals), or /share to upload the full session transcript for product bugs, crashes, slowness, or general issues. Only recommend these when the user is describing a problem with Claude.`
|
|
261588
261594
|
] : [],
|
|
261589
261595
|
`If the user asks for help or wants to give feedback inform them of the following:`,
|
|
261590
261596
|
userHelpSubitems
|
|
@@ -261707,7 +261713,7 @@ function getSimpleToneAndStyleSection() {
|
|
|
261707
261713
|
async function getSystemPrompt(tools, model, additionalWorkingDirectories, mcpClients) {
|
|
261708
261714
|
if (isEnvTruthy(process.env.CLAUDE_CODE_SIMPLE)) {
|
|
261709
261715
|
return [
|
|
261710
|
-
`You are
|
|
261716
|
+
`You are Claude, Anthropic's coding agent and CLI.
|
|
261711
261717
|
|
|
261712
261718
|
CWD: ${getCwd()}
|
|
261713
261719
|
Date: ${getSessionStartDate()}`
|
|
@@ -261817,8 +261823,8 @@ async function computeSimpleEnvInfo(modelId, additionalWorkingDirectories) {
|
|
|
261817
261823
|
`OS Version: ${unameSR}`,
|
|
261818
261824
|
modelDescription,
|
|
261819
261825
|
knowledgeCutoffMessage,
|
|
261820
|
-
process.env.USER_TYPE === "ant" && isUndercover() ? null : `
|
|
261821
|
-
process.env.USER_TYPE === "ant" && isUndercover() ? null : `Fast mode for
|
|
261826
|
+
process.env.USER_TYPE === "ant" && isUndercover() ? null : `Claude is available as a CLI in the terminal and can be used across local development environments and IDE workflows.`,
|
|
261827
|
+
process.env.USER_TYPE === "ant" && isUndercover() ? null : `Fast mode for Claude uses the same ${FRONTIER_MODEL_NAME} model with faster output. It does NOT switch to a different model. It can be toggled with /fast.`
|
|
261822
261828
|
].filter((item) => item !== null);
|
|
261823
261829
|
return [
|
|
261824
261830
|
`# Environment`,
|
|
@@ -261910,7 +261916,7 @@ function getFunctionResultClearingSection(model) {
|
|
|
261910
261916
|
|
|
261911
261917
|
Old tool results will be automatically cleared from context to free up space. The ${config2.keepRecent} most recent results are always kept.`;
|
|
261912
261918
|
}
|
|
261913
|
-
var getCachedMCConfigForFRC, DISCOVER_SKILLS_TOOL_NAME = null, SYSTEM_PROMPT_DYNAMIC_BOUNDARY = "__SYSTEM_PROMPT_DYNAMIC_BOUNDARY__", FRONTIER_MODEL_NAME = "Claude Opus 4.8", DEFAULT_AGENT_PROMPT = `You are an agent for
|
|
261919
|
+
var getCachedMCConfigForFRC, DISCOVER_SKILLS_TOOL_NAME = null, SYSTEM_PROMPT_DYNAMIC_BOUNDARY = "__SYSTEM_PROMPT_DYNAMIC_BOUNDARY__", FRONTIER_MODEL_NAME = "Claude Opus 4.8", DEFAULT_AGENT_PROMPT = `You are an agent for Claude, Anthropic's coding agent and CLI. Given the user's message, you should use the tools available to complete the task. Complete the task fully—don't gold-plate, but don't leave it half-done. When you complete the task, respond with a concise report covering what was done and any key findings — the caller will relay this to the user, so it only needs the essentials.`, SUMMARIZE_TOOL_RESULTS_SECTION = `When working with tool results, write down any important information you might need later in your response, as the original tool result may be cleared later.`;
|
|
261914
261920
|
var init_prompts3 = __esm(() => {
|
|
261915
261921
|
init_env();
|
|
261916
261922
|
init_git();
|
|
@@ -263639,9 +263645,18 @@ ${deferredToolList}
|
|
|
263639
263645
|
case "message_stop":
|
|
263640
263646
|
break;
|
|
263641
263647
|
}
|
|
263648
|
+
const streamEventPart = part.type === "message_delta" ? {
|
|
263649
|
+
...part,
|
|
263650
|
+
usage: {
|
|
263651
|
+
input_tokens: part.usage?.input_tokens ?? usage.input_tokens ?? 0,
|
|
263652
|
+
output_tokens: part.usage?.output_tokens ?? usage.output_tokens ?? 0,
|
|
263653
|
+
cache_creation_input_tokens: part.usage?.cache_creation_input_tokens ?? usage.cache_creation_input_tokens ?? 0,
|
|
263654
|
+
cache_read_input_tokens: part.usage?.cache_read_input_tokens ?? usage.cache_read_input_tokens ?? 0
|
|
263655
|
+
}
|
|
263656
|
+
} : part;
|
|
263642
263657
|
yield {
|
|
263643
263658
|
type: "stream_event",
|
|
263644
|
-
event:
|
|
263659
|
+
event: streamEventPart,
|
|
263645
263660
|
...part.type === "message_start" ? { ttftMs } : undefined
|
|
263646
263661
|
};
|
|
263647
263662
|
}
|
|
@@ -264445,6 +264460,160 @@ var init_imageStore = __esm(() => {
|
|
|
264445
264460
|
// src/utils/ultraplan/keyword.ts
|
|
264446
264461
|
var init_keyword = () => {};
|
|
264447
264462
|
|
|
264463
|
+
// src/utils/visionDescribe.ts
|
|
264464
|
+
import { mkdirSync as mkdirSync6, readFileSync as readFileSync12, statSync as statSync7, writeFileSync as writeFileSync5 } from "fs";
|
|
264465
|
+
import { basename as basename26, extname as extname8, join as join89 } from "path";
|
|
264466
|
+
import { tmpdir as tmpdir6 } from "os";
|
|
264467
|
+
function visionDescribeAvailable() {
|
|
264468
|
+
return !!(process.env.CLAUDE_CODE_VISION_API_KEY || process.env.MANIAC_VISION_API_KEY || process.env.GROQ_API_KEY);
|
|
264469
|
+
}
|
|
264470
|
+
function resolveVisionKey() {
|
|
264471
|
+
const key = process.env.CLAUDE_CODE_VISION_API_KEY || process.env.MANIAC_VISION_API_KEY || process.env.GROQ_API_KEY || "";
|
|
264472
|
+
if (!key) {
|
|
264473
|
+
throw new Error("Vision routing requires GROQ_API_KEY (or CLAUDE_CODE_VISION_API_KEY / MANIAC_VISION_API_KEY)");
|
|
264474
|
+
}
|
|
264475
|
+
return key;
|
|
264476
|
+
}
|
|
264477
|
+
function shouldRouteImagesThroughVisionDescribe(model) {
|
|
264478
|
+
if (!visionDescribeAvailable())
|
|
264479
|
+
return false;
|
|
264480
|
+
if (isEnvTruthy(process.env.CLAUDE_CODE_DISABLE_VISION_ROUTE))
|
|
264481
|
+
return false;
|
|
264482
|
+
if (isEnvDefinedFalsy(process.env.CLAUDE_CODE_VISION_ROUTE))
|
|
264483
|
+
return false;
|
|
264484
|
+
if (isEnvTruthy(process.env.CLAUDE_CODE_VISION_ROUTE))
|
|
264485
|
+
return true;
|
|
264486
|
+
const target = model ?? getMainLoopModel();
|
|
264487
|
+
const routeId = resolveRouteIdFromBaseUrl(process.env.OPENAI_BASE_URL) ?? undefined;
|
|
264488
|
+
const descriptor = findModelDescriptorForApiNameWithRoute(target, routeId);
|
|
264489
|
+
if (descriptor?.capabilities?.supportsVision === true)
|
|
264490
|
+
return false;
|
|
264491
|
+
if (descriptor?.capabilities?.supportsVision === false)
|
|
264492
|
+
return true;
|
|
264493
|
+
return isEnvTruthy(process.env.CLAUDE_CODE_USE_OPENAI) || isEnvTruthy(process.env.CLAUDE_CODE_USE_GEMINI) || isEnvTruthy(process.env.CLAUDE_CODE_USE_MISTRAL) || isEnvTruthy(process.env.CLAUDE_CODE_USE_GITHUB) || !isVisionSupported(target, { routeId, baseUrl: process.env.OPENAI_BASE_URL });
|
|
264494
|
+
}
|
|
264495
|
+
async function describeImage(imagePath, userText) {
|
|
264496
|
+
const apiKey = resolveVisionKey();
|
|
264497
|
+
const stat31 = statSync7(imagePath);
|
|
264498
|
+
if (stat31.size > MAX_IMAGE_BYTES) {
|
|
264499
|
+
throw new Error(`Image too large (${(stat31.size / 1024 / 1024).toFixed(1)}MB > 4MB): ${imagePath}`);
|
|
264500
|
+
}
|
|
264501
|
+
const ext = extname8(imagePath).toLowerCase();
|
|
264502
|
+
const mime = IMAGE_MIME[ext];
|
|
264503
|
+
if (!mime)
|
|
264504
|
+
throw new Error(`Unsupported image type "${ext}": ${imagePath}`);
|
|
264505
|
+
const b64 = readFileSync12(imagePath).toString("base64");
|
|
264506
|
+
const userContext = userText?.trim() ? `Contexto da pergunta do usuario (para voce saber o que priorizar na descricao): "${userText.trim()}"` : "Descreva a imagem.";
|
|
264507
|
+
const res = await fetch(`${VISION_BASE_URL.replace(/\/$/, "")}/chat/completions`, {
|
|
264508
|
+
method: "POST",
|
|
264509
|
+
headers: {
|
|
264510
|
+
"Content-Type": "application/json",
|
|
264511
|
+
Authorization: `Bearer ${apiKey}`
|
|
264512
|
+
},
|
|
264513
|
+
body: JSON.stringify({
|
|
264514
|
+
model: VISION_MODEL,
|
|
264515
|
+
temperature: 0.2,
|
|
264516
|
+
max_tokens: 4096,
|
|
264517
|
+
reasoning_format: "hidden",
|
|
264518
|
+
messages: [
|
|
264519
|
+
{ role: "system", content: DESCRIBE_PROMPT },
|
|
264520
|
+
{
|
|
264521
|
+
role: "user",
|
|
264522
|
+
content: [
|
|
264523
|
+
{ type: "text", text: userContext },
|
|
264524
|
+
{
|
|
264525
|
+
type: "image_url",
|
|
264526
|
+
image_url: { url: `data:${mime};base64,${b64}` }
|
|
264527
|
+
}
|
|
264528
|
+
]
|
|
264529
|
+
}
|
|
264530
|
+
]
|
|
264531
|
+
}),
|
|
264532
|
+
signal: AbortSignal.timeout(90000)
|
|
264533
|
+
});
|
|
264534
|
+
if (!res.ok) {
|
|
264535
|
+
throw new Error(`Vision model HTTP ${res.status}`);
|
|
264536
|
+
}
|
|
264537
|
+
const data = await res.json();
|
|
264538
|
+
const raw = data.choices?.[0]?.message?.content || "";
|
|
264539
|
+
let description = raw.replace(/<think>[\s\S]*?<\/think>/gi, "").trim();
|
|
264540
|
+
if (description.startsWith("<think>"))
|
|
264541
|
+
description = "";
|
|
264542
|
+
if (!description)
|
|
264543
|
+
throw new Error("Vision model returned an empty description");
|
|
264544
|
+
return description;
|
|
264545
|
+
}
|
|
264546
|
+
async function describeImages(imagePaths, userText) {
|
|
264547
|
+
const results = [];
|
|
264548
|
+
for (const p of imagePaths) {
|
|
264549
|
+
try {
|
|
264550
|
+
results.push({ path: p, description: await describeImage(p, userText) });
|
|
264551
|
+
} catch (e) {
|
|
264552
|
+
const msg = e instanceof Error ? e.message : "unknown error";
|
|
264553
|
+
const safe = msg.startsWith("Vision model HTTP") || msg.startsWith("Image too large") || msg.startsWith("Unsupported image") || msg.includes("Vision routing requires") || msg.includes("empty description") ? msg : "vision request failed";
|
|
264554
|
+
results.push({ path: p, description: `[falha ao ler imagem: ${safe}]` });
|
|
264555
|
+
}
|
|
264556
|
+
}
|
|
264557
|
+
return results;
|
|
264558
|
+
}
|
|
264559
|
+
function buildVisionAugmentedMessage(message, descriptions) {
|
|
264560
|
+
if (descriptions.length === 0)
|
|
264561
|
+
return message;
|
|
264562
|
+
const blocks = descriptions.map((d, i3) => `[image${i3 + 1}] (${basename26(d.path)}):
|
|
264563
|
+
${d.description}`).join(`
|
|
264564
|
+
|
|
264565
|
+
`);
|
|
264566
|
+
return `${message}
|
|
264567
|
+
|
|
264568
|
+
=== IMAGENS ANEXADAS (descritas pelo modelo de visao ${VISION_MODEL}) ===
|
|
264569
|
+
Voce nao ve as imagens diretamente; use as descricoes abaixo como se fossem as imagens.
|
|
264570
|
+
|
|
264571
|
+
${blocks}
|
|
264572
|
+
=== FIM DAS IMAGENS ===`;
|
|
264573
|
+
}
|
|
264574
|
+
function getVisionModelLabel() {
|
|
264575
|
+
return VISION_MODEL;
|
|
264576
|
+
}
|
|
264577
|
+
function writeTempImageFromBase64(data, mediaType = "image/png") {
|
|
264578
|
+
if (data.length > Math.ceil(MAX_IMAGE_BYTES * 4 / 3) + 64) {
|
|
264579
|
+
throw new Error(`Image too large (base64 exceeds ~${MAX_IMAGE_BYTES / 1024 / 1024}MB limit)`);
|
|
264580
|
+
}
|
|
264581
|
+
const buf = Buffer.from(data, "base64");
|
|
264582
|
+
if (buf.byteLength > MAX_IMAGE_BYTES) {
|
|
264583
|
+
throw new Error(`Image too large (${(buf.byteLength / 1024 / 1024).toFixed(1)}MB > 4MB)`);
|
|
264584
|
+
}
|
|
264585
|
+
const ext = mediaType === "image/jpeg" || mediaType === "image/jpg" ? ".jpg" : mediaType === "image/webp" ? ".webp" : mediaType === "image/gif" ? ".gif" : ".png";
|
|
264586
|
+
const dir = join89(tmpdir6(), "claudio-vision");
|
|
264587
|
+
mkdirSync6(dir, { recursive: true });
|
|
264588
|
+
const file2 = join89(dir, `img-${Date.now()}-${Math.random().toString(36).slice(2, 8)}${ext}`);
|
|
264589
|
+
writeFileSync5(file2, buf);
|
|
264590
|
+
return file2;
|
|
264591
|
+
}
|
|
264592
|
+
var VISION_BASE_URL, VISION_MODEL, MAX_IMAGE_BYTES, IMAGE_MIME, DESCRIBE_PROMPT = `Voce eh um descritor de imagens para outro modelo de IA que NAO consegue ver imagens.
|
|
264593
|
+
Descreva a imagem em detalhes exaustivos e objetivos, em portugues brasileiro:
|
|
264594
|
+
- Se houver texto, codigo, logs ou mensagens de erro: TRANSCREVA tudo literalmente, preservando formatacao.
|
|
264595
|
+
- Se for uma interface/screenshot: descreva layout, componentes, cores, estados e qualquer valor visivel.
|
|
264596
|
+
- Se for um diagrama: descreva nos, conexoes e fluxo.
|
|
264597
|
+
- Se for uma foto: descreva cena, objetos e contexto relevante.
|
|
264598
|
+
Nao interprete nem responda a pergunta do usuario — apenas descreva o que a imagem contem.`;
|
|
264599
|
+
var init_visionDescribe = __esm(() => {
|
|
264600
|
+
init_envUtils();
|
|
264601
|
+
init_visionUtils();
|
|
264602
|
+
init_model();
|
|
264603
|
+
init_integrations();
|
|
264604
|
+
VISION_BASE_URL = process.env.CLAUDE_CODE_VISION_BASE_URL || process.env.MANIAC_VISION_BASE_URL || "https://api.groq.com/openai/v1";
|
|
264605
|
+
VISION_MODEL = process.env.CLAUDE_CODE_VISION_MODEL || process.env.MANIAC_VISION_MODEL || "qwen/qwen3.6-27b";
|
|
264606
|
+
MAX_IMAGE_BYTES = 4 * 1024 * 1024;
|
|
264607
|
+
IMAGE_MIME = {
|
|
264608
|
+
".png": "image/png",
|
|
264609
|
+
".jpg": "image/jpeg",
|
|
264610
|
+
".jpeg": "image/jpeg",
|
|
264611
|
+
".gif": "image/gif",
|
|
264612
|
+
".webp": "image/webp",
|
|
264613
|
+
".bmp": "image/bmp"
|
|
264614
|
+
};
|
|
264615
|
+
});
|
|
264616
|
+
|
|
264448
264617
|
// src/utils/userPromptKeywords.ts
|
|
264449
264618
|
function matchesNegativeKeyword(input) {
|
|
264450
264619
|
const lowerInput = input.toLowerCase();
|
|
@@ -264587,8 +264756,8 @@ function extractBaseCommand2(segment) {
|
|
|
264587
264756
|
const stripped = segment.trim().replace(/^[&.]\s+/, "");
|
|
264588
264757
|
const firstToken = stripped.split(/\s+/)[0] || "";
|
|
264589
264758
|
const unquoted = firstToken.replace(/^["']|["']$/g, "");
|
|
264590
|
-
const
|
|
264591
|
-
return
|
|
264759
|
+
const basename27 = unquoted.split(/[\\/]/).pop() || unquoted;
|
|
264760
|
+
return basename27.toLowerCase().replace(/\.(exe|cmd|bat|ps1)$/, "");
|
|
264592
264761
|
}
|
|
264593
264762
|
function splitStatements(command) {
|
|
264594
264763
|
const statements = [];
|
|
@@ -265106,11 +265275,11 @@ var init_commandSemantics2 = __esm(() => {
|
|
|
265106
265275
|
});
|
|
265107
265276
|
|
|
265108
265277
|
// src/tools/PowerShellTool/gitSafety.ts
|
|
265109
|
-
import { basename as
|
|
265278
|
+
import { basename as basename27, posix as posix6, resolve as resolve29, sep as sep23 } from "path";
|
|
265110
265279
|
function resolveCwdReentry(normalized) {
|
|
265111
265280
|
if (!normalized.startsWith("../"))
|
|
265112
265281
|
return normalized;
|
|
265113
|
-
const cwdBase =
|
|
265282
|
+
const cwdBase = basename27(getCwd()).toLowerCase();
|
|
265114
265283
|
if (!cwdBase)
|
|
265115
265284
|
return normalized;
|
|
265116
265285
|
const prefix = "../" + cwdBase + "/";
|
|
@@ -269730,6 +269899,59 @@ async function processUserInputBase(input, mode, setToolJSX, context2, pastedCon
|
|
|
269730
269899
|
imageContentBlocks.push(resized.block);
|
|
269731
269900
|
}
|
|
269732
269901
|
queryCheckpoint("query_pasted_image_processing_end");
|
|
269902
|
+
const imagesInPreceding = precedingInputBlocks.filter((b) => b.type === "image");
|
|
269903
|
+
const needsVisionRoute = (imageContentBlocks.length > 0 || imagesInPreceding.length > 0) && shouldRouteImagesThroughVisionDescribe();
|
|
269904
|
+
if (needsVisionRoute) {
|
|
269905
|
+
const paths2 = [];
|
|
269906
|
+
for (const pastedImage of imageContents) {
|
|
269907
|
+
const stored = storedImagePaths2.get(pastedImage.id);
|
|
269908
|
+
if (stored) {
|
|
269909
|
+
paths2.push(stored);
|
|
269910
|
+
continue;
|
|
269911
|
+
}
|
|
269912
|
+
if (pastedImage.sourcePath) {
|
|
269913
|
+
paths2.push(pastedImage.sourcePath);
|
|
269914
|
+
continue;
|
|
269915
|
+
}
|
|
269916
|
+
paths2.push(writeTempImageFromBase64(pastedImage.content, pastedImage.mediaType || "image/png"));
|
|
269917
|
+
}
|
|
269918
|
+
for (const block2 of imagesInPreceding) {
|
|
269919
|
+
if (block2.source.type === "base64") {
|
|
269920
|
+
paths2.push(writeTempImageFromBase64(block2.source.data, block2.source.media_type || "image/png"));
|
|
269921
|
+
}
|
|
269922
|
+
}
|
|
269923
|
+
if (paths2.length > 0) {
|
|
269924
|
+
logEvent("tengu_vision_route_start", {
|
|
269925
|
+
image_count: paths2.length,
|
|
269926
|
+
vision_model: getVisionModelLabel()
|
|
269927
|
+
});
|
|
269928
|
+
try {
|
|
269929
|
+
const descriptions = await describeImages(paths2, inputString ?? undefined);
|
|
269930
|
+
const baseText = inputString ?? "";
|
|
269931
|
+
inputString = buildVisionAugmentedMessage(baseText, descriptions);
|
|
269932
|
+
normalizedInput = inputString;
|
|
269933
|
+
imageContentBlocks.length = 0;
|
|
269934
|
+
precedingInputBlocks = precedingInputBlocks.filter((b) => b.type !== "image");
|
|
269935
|
+
imageMetadataTexts.push(`[Vision] Described ${descriptions.length} image(s) via ${getVisionModelLabel()} (Looking → Looked). Main model receives text only.`);
|
|
269936
|
+
logEvent("tengu_vision_route_ok", {
|
|
269937
|
+
image_count: descriptions.length
|
|
269938
|
+
});
|
|
269939
|
+
} catch (e) {
|
|
269940
|
+
const msg = e instanceof Error ? e.message : "unknown error";
|
|
269941
|
+
const safe = msg.startsWith("Vision model HTTP") || msg.startsWith("Image too large") || msg.startsWith("Unsupported image") || msg.includes("Vision routing requires") || msg.includes("empty description") || msg.includes("base64 exceeds") ? msg : "vision request failed";
|
|
269942
|
+
imageContentBlocks.length = 0;
|
|
269943
|
+
precedingInputBlocks = precedingInputBlocks.filter((b) => b.type !== "image");
|
|
269944
|
+
inputString = `${inputString ?? ""}
|
|
269945
|
+
|
|
269946
|
+
[NOTA: ${paths2.length} imagem(ns) anexada(s), mas o modelo de visao falhou: ${safe}]`;
|
|
269947
|
+
normalizedInput = inputString;
|
|
269948
|
+
imageMetadataTexts.push(`[Vision] Failed: ${safe}`);
|
|
269949
|
+
logEvent("tengu_vision_route_error", {});
|
|
269950
|
+
}
|
|
269951
|
+
}
|
|
269952
|
+
} else if ((imageContentBlocks.length > 0 || imagesInPreceding.length > 0) && !visionDescribeAvailable() && (process.env.CLAUDE_CODE_USE_OPENAI === "1" || process.env.CLAUDE_CODE_USE_OPENAI === "true")) {
|
|
269953
|
+
imageMetadataTexts.push("[Vision] Images attached but GROQ_API_KEY (or CLAUDE_CODE_VISION_API_KEY) is not set — vision routing is off. Main model may reject images.");
|
|
269954
|
+
}
|
|
269733
269955
|
let effectiveSkipSlash = skipSlashCommands;
|
|
269734
269956
|
if (bridgeOrigin && inputString !== null && inputString.startsWith("/")) {
|
|
269735
269957
|
const parsed = parseSlashCommand(inputString);
|
|
@@ -269800,6 +270022,7 @@ var init_processUserInput = __esm(() => {
|
|
|
269800
270022
|
init_messages();
|
|
269801
270023
|
init_queryProfiler();
|
|
269802
270024
|
init_keyword();
|
|
270025
|
+
init_visionDescribe();
|
|
269803
270026
|
init_processTextPrompt();
|
|
269804
270027
|
});
|
|
269805
270028
|
|
|
@@ -269910,7 +270133,7 @@ function buildSystemInitMessage(inputs) {
|
|
|
269910
270133
|
slash_commands: inputs.commands.filter((c6) => c6.userInvocable !== false).map((c6) => c6.name),
|
|
269911
270134
|
apiKeySource: getAnthropicApiKeyWithSource().source,
|
|
269912
270135
|
betas: getSdkBetas(),
|
|
269913
|
-
claude_code_version: "0.
|
|
270136
|
+
claude_code_version: "0.26.0",
|
|
269914
270137
|
output_style: outputStyle,
|
|
269915
270138
|
agents: inputs.agents.map((agent) => agent.agentType),
|
|
269916
270139
|
skills: inputs.skills.filter((s) => s.userInvocable !== false).map((skill) => skill.name),
|
|
@@ -271949,7 +272172,7 @@ __export(exports_upstreamproxy, {
|
|
|
271949
272172
|
});
|
|
271950
272173
|
import { mkdir as mkdir28, readFile as readFile28, unlink as unlink12, writeFile as writeFile22 } from "fs/promises";
|
|
271951
272174
|
import { homedir as homedir24 } from "os";
|
|
271952
|
-
import { join as
|
|
272175
|
+
import { join as join90 } from "path";
|
|
271953
272176
|
async function initUpstreamProxy(opts) {
|
|
271954
272177
|
if (!isEnvTruthy(process.env.CLAUDE_CODE_REMOTE)) {
|
|
271955
272178
|
return state2;
|
|
@@ -271970,7 +272193,7 @@ async function initUpstreamProxy(opts) {
|
|
|
271970
272193
|
}
|
|
271971
272194
|
setNonDumpable();
|
|
271972
272195
|
const baseUrl = opts?.ccrBaseUrl ?? process.env.ANTHROPIC_BASE_URL ?? "https://api.anthropic.com";
|
|
271973
|
-
const caBundlePath = opts?.caBundlePath ??
|
|
272196
|
+
const caBundlePath = opts?.caBundlePath ?? join90(homedir24(), ".ccr", "ca-bundle.crt");
|
|
271974
272197
|
const caOk = await downloadCaBundle(baseUrl, opts?.systemCaPath ?? SYSTEM_CA_BUNDLE, caBundlePath);
|
|
271975
272198
|
if (!caOk)
|
|
271976
272199
|
return state2;
|
|
@@ -272088,7 +272311,7 @@ async function downloadCaBundle(baseUrl, systemCaPath, outPath) {
|
|
|
272088
272311
|
return false;
|
|
272089
272312
|
}
|
|
272090
272313
|
const systemCa = await readFile28(systemCaPath, "utf8").catch(() => "");
|
|
272091
|
-
await mkdir28(
|
|
272314
|
+
await mkdir28(join90(outPath, ".."), { recursive: true });
|
|
272092
272315
|
await writeFile22(outPath, systemCa + `
|
|
272093
272316
|
` + ccrCa, "utf8");
|
|
272094
272317
|
return true;
|
|
@@ -272371,7 +272594,7 @@ var init_shared2 = __esm(() => {
|
|
|
272371
272594
|
// src/entrypoints/sdk/sessions.ts
|
|
272372
272595
|
import { randomUUID as randomUUID31 } from "crypto";
|
|
272373
272596
|
import { appendFile as appendFile4, mkdir as mkdir29, unlink as unlink13, writeFile as writeFile23 } from "fs/promises";
|
|
272374
|
-
import { dirname as dirname44, join as
|
|
272597
|
+
import { dirname as dirname44, join as join91 } from "path";
|
|
272375
272598
|
function toSDKSessionInfo(info) {
|
|
272376
272599
|
return {
|
|
272377
272600
|
sessionId: info.sessionId,
|
|
@@ -272538,7 +272761,7 @@ async function forkSession(sessionId, options2) {
|
|
|
272538
272761
|
}
|
|
272539
272762
|
const forkSessionId = randomUUID31();
|
|
272540
272763
|
const targetDir = dirname44(resolved.filePath);
|
|
272541
|
-
const forkPath =
|
|
272764
|
+
const forkPath = join91(targetDir, `${forkSessionId}.jsonl`);
|
|
272542
272765
|
const uuidMap = new Map;
|
|
272543
272766
|
const mainEntries = [];
|
|
272544
272767
|
const metadataEntries = [];
|
|
@@ -274273,4 +274496,4 @@ export {
|
|
|
274273
274496
|
AbortError
|
|
274274
274497
|
};
|
|
274275
274498
|
|
|
274276
|
-
//# debugId=
|
|
274499
|
+
//# debugId=99E16CBF78A7CF1164756E2164756E21
|