@cnwenf/occ 2.1.330 → 2.1.332
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.js +350 -81
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
-
globalThis.MACRO={"VERSION":"2.1.
|
|
2
|
+
globalThis.MACRO={"VERSION":"2.1.332","BINARY_NAME":"occ","BUILD_TIME":"2026-09-12T20:24:55.070Z","FEEDBACK_CHANNEL":"","ISSUES_EXPLAINER":"","NATIVE_PACKAGE_URL":"","PACKAGE_URL":"@cnwenf/occ","VERSION_CHANGELOG":""};
|
|
3
3
|
// @bun
|
|
4
4
|
var __create = Object.create;
|
|
5
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
@@ -260734,7 +260734,8 @@ var init_FileReadTool = __esm(() => {
|
|
|
260734
260734
|
return {
|
|
260735
260735
|
result: false,
|
|
260736
260736
|
message: "File is in a directory that is denied by your permission settings.",
|
|
260737
|
-
errorCode: 1
|
|
260737
|
+
errorCode: 1,
|
|
260738
|
+
deniedByPermissionRule: true
|
|
260738
260739
|
};
|
|
260739
260740
|
}
|
|
260740
260741
|
const isUncPath = fullFilePath.startsWith("\\\\") || fullFilePath.startsWith("//");
|
|
@@ -374648,14 +374649,16 @@ var init_FileWriteTool = __esm(() => {
|
|
|
374648
374649
|
return {
|
|
374649
374650
|
result: false,
|
|
374650
374651
|
message: "File is in a directory that is denied by your permission settings.",
|
|
374651
|
-
errorCode: 1
|
|
374652
|
+
errorCode: 1,
|
|
374653
|
+
deniedByPermissionRule: true
|
|
374652
374654
|
};
|
|
374653
374655
|
}
|
|
374654
374656
|
if (isCoveredByReadDenyRule(fullFilePath, toolPermissionContext)) {
|
|
374655
374657
|
return {
|
|
374656
374658
|
result: false,
|
|
374657
374659
|
message: READ_DENY_WRITE_MESSAGE,
|
|
374658
|
-
errorCode: 13
|
|
374660
|
+
errorCode: 13,
|
|
374661
|
+
deniedByPermissionRule: true
|
|
374659
374662
|
};
|
|
374660
374663
|
}
|
|
374661
374664
|
if (fullFilePath.startsWith("\\\\") || fullFilePath.startsWith("//")) {
|
|
@@ -380709,6 +380712,19 @@ var init_sedValidation = __esm(() => {
|
|
|
380709
380712
|
// src/tools/BashTool/pathValidation.ts
|
|
380710
380713
|
import { homedir as homedir22 } from "os";
|
|
380711
380714
|
import { isAbsolute as isAbsolute21, resolve as resolve30 } from "path";
|
|
380715
|
+
function filterTeeDevicePaths(paths2) {
|
|
380716
|
+
return paths2.filter((p4) => !TEE_DEVICE_PATHS.has(p4));
|
|
380717
|
+
}
|
|
380718
|
+
function canonicalizePathCommandName(cmd) {
|
|
380719
|
+
if (!cmd) {
|
|
380720
|
+
return cmd;
|
|
380721
|
+
}
|
|
380722
|
+
const base2 = cmd.replace(/^.*[\\/]/, "");
|
|
380723
|
+
if (CANONICAL_PATH_COMMAND_BASENAMES.has(base2)) {
|
|
380724
|
+
return base2;
|
|
380725
|
+
}
|
|
380726
|
+
return base2.toLowerCase().replace(/\.exe$/, "") === "tee" ? "tee" : cmd;
|
|
380727
|
+
}
|
|
380712
380728
|
function checkDangerousRemovalPaths(command4, args, cwd2) {
|
|
380713
380729
|
const extractor = PATH_EXTRACTORS[command4];
|
|
380714
380730
|
const paths2 = extractor(args);
|
|
@@ -380900,7 +380916,8 @@ function validateSinglePathCommand(cmd, cwd2, toolPermissionContext, compoundCom
|
|
|
380900
380916
|
message: "Empty command - no paths to validate"
|
|
380901
380917
|
};
|
|
380902
380918
|
}
|
|
380903
|
-
const [
|
|
380919
|
+
const [rawBaseCmd, ...args] = extractedArgs;
|
|
380920
|
+
const baseCmd = canonicalizePathCommandName(rawBaseCmd);
|
|
380904
380921
|
if (!baseCmd || !SUPPORTED_PATH_COMMANDS.includes(baseCmd)) {
|
|
380905
380922
|
return {
|
|
380906
380923
|
behavior: "passthrough",
|
|
@@ -380919,7 +380936,8 @@ function validateSinglePathCommandArgv(cmd, cwd2, toolPermissionContext, compoun
|
|
|
380919
380936
|
message: "Empty command - no paths to validate"
|
|
380920
380937
|
};
|
|
380921
380938
|
}
|
|
380922
|
-
const [
|
|
380939
|
+
const [rawBaseCmd, ...args] = argv;
|
|
380940
|
+
const baseCmd = canonicalizePathCommandName(rawBaseCmd);
|
|
380923
380941
|
if (!baseCmd || !SUPPORTED_PATH_COMMANDS.includes(baseCmd)) {
|
|
380924
380942
|
return {
|
|
380925
380943
|
behavior: "passthrough",
|
|
@@ -381146,7 +381164,7 @@ function stripWrappersFromArgv(argv) {
|
|
|
381146
381164
|
}
|
|
381147
381165
|
}
|
|
381148
381166
|
}
|
|
381149
|
-
var PATH_EXTRACTORS, SUPPORTED_PATH_COMMANDS, ACTION_VERBS, COMMAND_OPERATION_TYPE, COMMAND_VALIDATOR, TIMEOUT_FLAG_VALUE_RE;
|
|
381167
|
+
var TEE_DEVICE_PATHS, CANONICAL_PATH_COMMAND_BASENAMES, PATH_EXTRACTORS, SUPPORTED_PATH_COMMANDS, ACTION_VERBS, COMMAND_OPERATION_TYPE, COMMAND_VALIDATOR, TIMEOUT_FLAG_VALUE_RE;
|
|
381150
381168
|
var init_pathValidation2 = __esm(() => {
|
|
381151
381169
|
init_commands4();
|
|
381152
381170
|
init_shellQuote();
|
|
@@ -381156,6 +381174,13 @@ var init_pathValidation2 = __esm(() => {
|
|
|
381156
381174
|
init_pathValidation();
|
|
381157
381175
|
init_bashPermissions();
|
|
381158
381176
|
init_sedValidation();
|
|
381177
|
+
TEE_DEVICE_PATHS = new Set([
|
|
381178
|
+
"/dev/null",
|
|
381179
|
+
"/dev/stdout",
|
|
381180
|
+
"/dev/stderr",
|
|
381181
|
+
"/dev/tty"
|
|
381182
|
+
]);
|
|
381183
|
+
CANONICAL_PATH_COMMAND_BASENAMES = new Set(["rm", "rmdir", "tee"]);
|
|
381159
381184
|
PATH_EXTRACTORS = {
|
|
381160
381185
|
cd: (args) => args.length === 0 ? [homedir22()] : [args.join(" ")],
|
|
381161
381186
|
ls: (args) => {
|
|
@@ -381238,6 +381263,7 @@ var init_pathValidation2 = __esm(() => {
|
|
|
381238
381263
|
sha256sum: filterOutFlags,
|
|
381239
381264
|
sha1sum: filterOutFlags,
|
|
381240
381265
|
md5sum: filterOutFlags,
|
|
381266
|
+
tee: (args) => filterTeeDevicePaths(filterOutFlags(args)),
|
|
381241
381267
|
tr: (args) => {
|
|
381242
381268
|
const hasDelete = args.some((a5) => a5 === "-d" || a5 === "--delete" || a5.startsWith("-") && a5.includes("d"));
|
|
381243
381269
|
const nonFlags = filterOutFlags(args);
|
|
@@ -381428,7 +381454,8 @@ var init_pathValidation2 = __esm(() => {
|
|
|
381428
381454
|
jq: "process JSON from files in",
|
|
381429
381455
|
sha256sum: "compute SHA-256 checksums for files in",
|
|
381430
381456
|
sha1sum: "compute SHA-1 checksums for files in",
|
|
381431
|
-
md5sum: "compute MD5 checksums for files in"
|
|
381457
|
+
md5sum: "compute MD5 checksums for files in",
|
|
381458
|
+
tee: "write to files in"
|
|
381432
381459
|
};
|
|
381433
381460
|
COMMAND_OPERATION_TYPE = {
|
|
381434
381461
|
cd: "read",
|
|
@@ -381466,7 +381493,8 @@ var init_pathValidation2 = __esm(() => {
|
|
|
381466
381493
|
jq: "read",
|
|
381467
381494
|
sha256sum: "read",
|
|
381468
381495
|
sha1sum: "read",
|
|
381469
|
-
md5sum: "read"
|
|
381496
|
+
md5sum: "read",
|
|
381497
|
+
tee: "write"
|
|
381470
381498
|
};
|
|
381471
381499
|
COMMAND_VALIDATOR = {
|
|
381472
381500
|
mv: (args) => !args.some((arg) => arg?.startsWith("-")),
|
|
@@ -381666,7 +381694,7 @@ function extractWritePathsFromSubcommand(subcommand) {
|
|
|
381666
381694
|
const tokens = parseResult.tokens.filter((t4) => typeof t4 === "string");
|
|
381667
381695
|
if (tokens.length === 0)
|
|
381668
381696
|
return [];
|
|
381669
|
-
const baseCmd = tokens[0];
|
|
381697
|
+
const baseCmd = canonicalizePathCommandName(tokens[0]?.replace(/[\\'"]/g, ""));
|
|
381670
381698
|
if (!baseCmd)
|
|
381671
381699
|
return [];
|
|
381672
381700
|
if (!(baseCmd in COMMAND_OPERATION_TYPE)) {
|
|
@@ -395528,14 +395556,19 @@ async function gracefulShutdown(exitCode = 0, reason = "other", options) {
|
|
|
395528
395556
|
return;
|
|
395529
395557
|
}
|
|
395530
395558
|
shutdownInProgress = true;
|
|
395531
|
-
const {
|
|
395559
|
+
const {
|
|
395560
|
+
executeSessionEndHooks,
|
|
395561
|
+
getSessionEndHookTimeoutMs,
|
|
395562
|
+
getSessionEndHooksBudgetMs
|
|
395563
|
+
} = await Promise.resolve().then(() => (init_hooks5(), exports_hooks2));
|
|
395532
395564
|
const sessionEndTimeoutMs = getSessionEndHookTimeoutMs();
|
|
395565
|
+
const sessionEndBudgetMs = getSessionEndHooksBudgetMs();
|
|
395533
395566
|
failsafeTimer = setTimeout(async (code) => {
|
|
395534
395567
|
cleanupTerminalModes();
|
|
395535
395568
|
printResumeHint();
|
|
395536
395569
|
await drainStdoutBeforeExit(500);
|
|
395537
395570
|
forceExit(code);
|
|
395538
|
-
}, Math.max(5000,
|
|
395571
|
+
}, Math.max(5000, sessionEndBudgetMs + 3500), exitCode);
|
|
395539
395572
|
failsafeTimer.unref();
|
|
395540
395573
|
process.exitCode = exitCode;
|
|
395541
395574
|
cleanupTerminalModes();
|
|
@@ -395560,7 +395593,7 @@ async function gracefulShutdown(exitCode = 0, reason = "other", options) {
|
|
|
395560
395593
|
try {
|
|
395561
395594
|
await executeSessionEndHooks(reason, {
|
|
395562
395595
|
...options,
|
|
395563
|
-
signal: AbortSignal.timeout(
|
|
395596
|
+
signal: AbortSignal.timeout(sessionEndBudgetMs),
|
|
395564
395597
|
timeoutMs: sessionEndTimeoutMs
|
|
395565
395598
|
});
|
|
395566
395599
|
} catch {}
|
|
@@ -451315,7 +451348,8 @@ var init_FileEditTool = __esm(() => {
|
|
|
451315
451348
|
result: false,
|
|
451316
451349
|
behavior: "ask",
|
|
451317
451350
|
message: "File is in a directory that is denied by your permission settings.",
|
|
451318
|
-
errorCode: 2
|
|
451351
|
+
errorCode: 2,
|
|
451352
|
+
deniedByPermissionRule: true
|
|
451319
451353
|
};
|
|
451320
451354
|
}
|
|
451321
451355
|
if (isCoveredByReadDenyRule(fullFilePath, appState.toolPermissionContext)) {
|
|
@@ -451323,7 +451357,8 @@ var init_FileEditTool = __esm(() => {
|
|
|
451323
451357
|
result: false,
|
|
451324
451358
|
behavior: "ask",
|
|
451325
451359
|
message: READ_DENY_EDIT_MESSAGE,
|
|
451326
|
-
errorCode: 13
|
|
451360
|
+
errorCode: 13,
|
|
451361
|
+
deniedByPermissionRule: true
|
|
451327
451362
|
};
|
|
451328
451363
|
}
|
|
451329
451364
|
if (fullFilePath.startsWith("\\\\") || fullFilePath.startsWith("//")) {
|
|
@@ -476316,7 +476351,8 @@ function deserializeMessagesWithInterruptDetection(serializedMessages) {
|
|
|
476316
476351
|
const filteredToolUses = filterUnresolvedToolUses(migratedMessages);
|
|
476317
476352
|
const filteredThinking = filterOrphanedThinkingOnlyMessages(filteredToolUses);
|
|
476318
476353
|
const filteredMessages = filterWhitespaceOnlyAssistantMessages(filteredThinking);
|
|
476319
|
-
const
|
|
476354
|
+
const droppedUnresolvedToolUses = filteredToolUses.length !== migratedMessages.length;
|
|
476355
|
+
const internalState = applyResumeStalenessGates(detectTurnInterruption(filteredMessages), droppedUnresolvedToolUses ? migratedMessages : filteredMessages);
|
|
476320
476356
|
let turnInterruptionState;
|
|
476321
476357
|
if (internalState.kind === "interrupted_turn") {
|
|
476322
476358
|
const [continuationMessage] = normalizeMessages([
|
|
@@ -476377,6 +476413,87 @@ function detectTurnInterruption(messages) {
|
|
|
476377
476413
|
}
|
|
476378
476414
|
return { kind: "none" };
|
|
476379
476415
|
}
|
|
476416
|
+
function getResumeMaxAgeEnvMs() {
|
|
476417
|
+
const raw = process.env[RESUME_MAX_AGE_ENV];
|
|
476418
|
+
if (!raw)
|
|
476419
|
+
return;
|
|
476420
|
+
const n5 = Number(raw);
|
|
476421
|
+
if (n5 === 0)
|
|
476422
|
+
return 0;
|
|
476423
|
+
return Number.isFinite(n5) && n5 > 0 ? n5 : RESUME_INVALID_ENV_MAX_AGE_MS;
|
|
476424
|
+
}
|
|
476425
|
+
function getResumeMaxAge() {
|
|
476426
|
+
const fromEnv5 = getResumeMaxAgeEnvMs();
|
|
476427
|
+
if (fromEnv5)
|
|
476428
|
+
return { maxAgeMs: fromEnv5, source: "env" };
|
|
476429
|
+
return { maxAgeMs: RESUME_DEFAULT_MAX_AGE_MS, source: "default" };
|
|
476430
|
+
}
|
|
476431
|
+
function messageTimestampMs(m5) {
|
|
476432
|
+
return Date.parse(typeof m5.timestamp === "string" ? m5.timestamp : "");
|
|
476433
|
+
}
|
|
476434
|
+
function isResumeTailStaleByEnv(messages) {
|
|
476435
|
+
const maxAge = getResumeMaxAgeEnvMs();
|
|
476436
|
+
if (!maxAge)
|
|
476437
|
+
return false;
|
|
476438
|
+
for (let i6 = messages.length - 1;i6 >= 0; i6--) {
|
|
476439
|
+
const m5 = messages[i6];
|
|
476440
|
+
if (m5.type === "system" || m5.type === "progress")
|
|
476441
|
+
continue;
|
|
476442
|
+
const t4 = messageTimestampMs(m5);
|
|
476443
|
+
if (Number.isFinite(t4))
|
|
476444
|
+
return Date.now() - t4 >= maxAge;
|
|
476445
|
+
}
|
|
476446
|
+
return true;
|
|
476447
|
+
}
|
|
476448
|
+
function isResumeRowStale(m5, maxAgeMs) {
|
|
476449
|
+
const t4 = messageTimestampMs(m5);
|
|
476450
|
+
return !Number.isFinite(t4) || Math.abs(Date.now() - t4) >= maxAgeMs;
|
|
476451
|
+
}
|
|
476452
|
+
function newerResumeRow(a5, b5) {
|
|
476453
|
+
if (a5 === undefined || b5 === undefined)
|
|
476454
|
+
return a5 ?? b5;
|
|
476455
|
+
const ra = messageTimestampMs(a5);
|
|
476456
|
+
const rb = messageTimestampMs(b5);
|
|
476457
|
+
if (!Number.isFinite(ra))
|
|
476458
|
+
return a5;
|
|
476459
|
+
if (!Number.isFinite(rb))
|
|
476460
|
+
return b5;
|
|
476461
|
+
return rb > ra ? b5 : a5;
|
|
476462
|
+
}
|
|
476463
|
+
function findSkippedTailApiErrorRow(messages) {
|
|
476464
|
+
const lastRelevantIdx = messages.findLastIndex((m5) => m5.type !== "system" && m5.type !== "progress" && !(m5.type === "assistant" && m5.isApiErrorMessage));
|
|
476465
|
+
let newest;
|
|
476466
|
+
for (let i6 = lastRelevantIdx + 1;i6 < messages.length; i6++) {
|
|
476467
|
+
const m5 = messages[i6];
|
|
476468
|
+
if (m5.type === "assistant" && m5.isApiErrorMessage) {
|
|
476469
|
+
newest = newerResumeRow(newest, m5);
|
|
476470
|
+
}
|
|
476471
|
+
}
|
|
476472
|
+
return newest;
|
|
476473
|
+
}
|
|
476474
|
+
function applyResumeStalenessGates(state3, walkMessages) {
|
|
476475
|
+
if (state3.kind === "none")
|
|
476476
|
+
return state3;
|
|
476477
|
+
if (isResumeTailStaleByEnv(walkMessages)) {
|
|
476478
|
+
if (process.env.CLAUDE_CODE_RESUME_INTERRUPTED_TURN) {
|
|
476479
|
+
logForDebugging(`[conversationRecovery] tengu_resume_stale_turn_suppressed (kind: ${state3.kind})`);
|
|
476480
|
+
}
|
|
476481
|
+
return { kind: "none" };
|
|
476482
|
+
}
|
|
476483
|
+
const apiErrorRow = findSkippedTailApiErrorRow(walkMessages);
|
|
476484
|
+
if (apiErrorRow !== undefined) {
|
|
476485
|
+
const bound = getResumeMaxAge();
|
|
476486
|
+
if (isResumeRowStale(apiErrorRow, bound.maxAgeMs)) {
|
|
476487
|
+
if (process.env.CLAUDE_CODE_RESUME_INTERRUPTED_TURN) {
|
|
476488
|
+
const t4 = messageTimestampMs(apiErrorRow);
|
|
476489
|
+
const ageMin = Number.isFinite(t4) ? Math.floor((Date.now() - t4) / 60000) : undefined;
|
|
476490
|
+
logForDebugging(`[conversationRecovery] tengu_resume_stale_turn_suppressed (kind: ${state3.kind}, tail: api_error` + (ageMin !== undefined ? `, age_min: ${ageMin}` : "") + `, bound_source: ${bound.source}, bound_min: ${Math.floor(bound.maxAgeMs / 60000)})`);
|
|
476491
|
+
}
|
|
476492
|
+
return { kind: "none" };
|
|
476493
|
+
}
|
|
476494
|
+
}
|
|
476495
|
+
return state3;
|
|
476496
|
+
}
|
|
476380
476497
|
function isTerminalToolResult(result, messages, resultIdx) {
|
|
476381
476498
|
const content = result.message.content;
|
|
476382
476499
|
if (!Array.isArray(content))
|
|
@@ -476554,7 +476671,7 @@ async function loadConversationForResume(source, sourceJsonlFile) {
|
|
|
476554
476671
|
throw error52;
|
|
476555
476672
|
}
|
|
476556
476673
|
}
|
|
476557
|
-
var BRIEF_TOOL_NAME4, LEGACY_BRIEF_TOOL_NAME2, SEND_USER_FILE_TOOL_NAME3, LOCAL_COMMAND_TAG_KINDS;
|
|
476674
|
+
var BRIEF_TOOL_NAME4, LEGACY_BRIEF_TOOL_NAME2, SEND_USER_FILE_TOOL_NAME3, RESUME_MAX_AGE_ENV = "CLAUDE_CODE_RESUME_INTERRUPTED_TURN_MAX_AGE_MS", RESUME_DEFAULT_MAX_AGE_MS = 21600000, RESUME_INVALID_ENV_MAX_AGE_MS = 3600000, LOCAL_COMMAND_TAG_KINDS;
|
|
476558
476675
|
var init_conversationRecovery = __esm(() => {
|
|
476559
476676
|
init_featureFlags();
|
|
476560
476677
|
init_cwd2();
|
|
@@ -476565,6 +476682,7 @@ var init_conversationRecovery = __esm(() => {
|
|
|
476565
476682
|
init_attachments2();
|
|
476566
476683
|
init_fileHistory();
|
|
476567
476684
|
init_log3();
|
|
476685
|
+
init_debug();
|
|
476568
476686
|
init_messages3();
|
|
476569
476687
|
init_plans();
|
|
476570
476688
|
init_sessionStart();
|
|
@@ -481765,6 +481883,38 @@ var init_UI10 = __esm(() => {
|
|
|
481765
481883
|
jsx_runtime137 = __toESM(require_jsx_runtime(), 1);
|
|
481766
481884
|
});
|
|
481767
481885
|
|
|
481886
|
+
// src/utils/combinedAbortSignal.ts
|
|
481887
|
+
function createCombinedAbortSignal(signal, opts) {
|
|
481888
|
+
const { signalB, timeoutMs } = opts ?? {};
|
|
481889
|
+
const combined = createAbortController();
|
|
481890
|
+
if (signal?.aborted || signalB?.aborted) {
|
|
481891
|
+
combined.abort();
|
|
481892
|
+
return { signal: combined.signal, cleanup: () => {} };
|
|
481893
|
+
}
|
|
481894
|
+
let timer;
|
|
481895
|
+
const abortCombined = () => {
|
|
481896
|
+
if (timer !== undefined)
|
|
481897
|
+
clearTimeout(timer);
|
|
481898
|
+
combined.abort();
|
|
481899
|
+
};
|
|
481900
|
+
if (timeoutMs !== undefined) {
|
|
481901
|
+
timer = setTimeout(abortCombined, timeoutMs);
|
|
481902
|
+
timer.unref?.();
|
|
481903
|
+
}
|
|
481904
|
+
signal?.addEventListener("abort", abortCombined);
|
|
481905
|
+
signalB?.addEventListener("abort", abortCombined);
|
|
481906
|
+
const cleanup = () => {
|
|
481907
|
+
if (timer !== undefined)
|
|
481908
|
+
clearTimeout(timer);
|
|
481909
|
+
signal?.removeEventListener("abort", abortCombined);
|
|
481910
|
+
signalB?.removeEventListener("abort", abortCombined);
|
|
481911
|
+
};
|
|
481912
|
+
return { signal: combined.signal, cleanup };
|
|
481913
|
+
}
|
|
481914
|
+
var init_combinedAbortSignal = __esm(() => {
|
|
481915
|
+
init_abortController();
|
|
481916
|
+
});
|
|
481917
|
+
|
|
481768
481918
|
// src/utils/mcpOutputStorage.ts
|
|
481769
481919
|
import { writeFile as writeFile27 } from "fs/promises";
|
|
481770
481920
|
import { join as join100 } from "path";
|
|
@@ -498499,11 +498649,13 @@ __export(exports_utils2, {
|
|
|
498499
498649
|
isPermittedRedirect: () => isPermittedRedirect,
|
|
498500
498650
|
invalidUrlErrorMessage: () => invalidUrlErrorMessage,
|
|
498501
498651
|
getWithPermittedRedirects: () => getWithPermittedRedirects,
|
|
498652
|
+
getWebFetchDeadlineMs: () => getWebFetchDeadlineMs,
|
|
498502
498653
|
getURLMarkdownContent: () => getURLMarkdownContent,
|
|
498503
498654
|
getTurndownService: () => getTurndownService,
|
|
498504
498655
|
clearWebFetchCache: () => clearWebFetchCache,
|
|
498505
498656
|
checkDomainBlocklist: () => checkDomainBlocklist,
|
|
498506
498657
|
applyPromptToMarkdown: () => applyPromptToMarkdown,
|
|
498658
|
+
WebFetchTransportError: () => WebFetchTransportError,
|
|
498507
498659
|
MAX_MARKDOWN_LENGTH: () => MAX_MARKDOWN_LENGTH
|
|
498508
498660
|
});
|
|
498509
498661
|
function clearWebFetchCache() {
|
|
@@ -498523,6 +498675,13 @@ function getTurndownService() {
|
|
|
498523
498675
|
return service;
|
|
498524
498676
|
});
|
|
498525
498677
|
}
|
|
498678
|
+
function getWebFetchDeadlineMs() {
|
|
498679
|
+
const fromEnv5 = parseEnvInt(process.env.CLAUDE_CODE_WEBFETCH_DEADLINE_MS);
|
|
498680
|
+
if (fromEnv5 !== undefined) {
|
|
498681
|
+
return Math.min(fromEnv5, MAX_DEADLINE_MS);
|
|
498682
|
+
}
|
|
498683
|
+
return WEBFETCH_DEADLINE_MS_DEFAULT;
|
|
498684
|
+
}
|
|
498526
498685
|
function isPreapprovedUrl(url3) {
|
|
498527
498686
|
try {
|
|
498528
498687
|
const parsedUrl = new URL(url3);
|
|
@@ -498606,13 +498765,30 @@ function isPermittedRedirect(originalUrl, redirectUrl) {
|
|
|
498606
498765
|
return false;
|
|
498607
498766
|
}
|
|
498608
498767
|
}
|
|
498609
|
-
async function getWithPermittedRedirects(url3, signal, redirectChecker, depth = 0) {
|
|
498768
|
+
async function getWithPermittedRedirects(url3, signal, redirectChecker, depth = 0, deadlineSignal) {
|
|
498769
|
+
if (deadlineSignal !== undefined) {
|
|
498770
|
+
return fetchWithRedirectChain(url3, signal, redirectChecker, depth, deadlineSignal);
|
|
498771
|
+
}
|
|
498772
|
+
const deadlineMs = getWebFetchDeadlineMs();
|
|
498773
|
+
if (deadlineMs === 0) {
|
|
498774
|
+
return fetchWithRedirectChain(url3, signal, redirectChecker, depth, new AbortController().signal);
|
|
498775
|
+
}
|
|
498776
|
+
const deadline = createCombinedAbortSignal(undefined, {
|
|
498777
|
+
timeoutMs: deadlineMs
|
|
498778
|
+
});
|
|
498779
|
+
try {
|
|
498780
|
+
return await fetchWithRedirectChain(url3, signal, redirectChecker, depth, deadline.signal);
|
|
498781
|
+
} finally {
|
|
498782
|
+
deadline.cleanup();
|
|
498783
|
+
}
|
|
498784
|
+
}
|
|
498785
|
+
async function fetchWithRedirectChain(url3, signal, redirectChecker, depth, deadlineSignal) {
|
|
498610
498786
|
if (depth > MAX_REDIRECTS) {
|
|
498611
498787
|
throw new Error(`Too many redirects (exceeded ${MAX_REDIRECTS})`);
|
|
498612
498788
|
}
|
|
498613
498789
|
try {
|
|
498614
498790
|
return await axios_default.get(url3, {
|
|
498615
|
-
signal,
|
|
498791
|
+
signal: AbortSignal.any([signal, deadlineSignal]),
|
|
498616
498792
|
timeout: FETCH_TIMEOUT_MS3,
|
|
498617
498793
|
maxRedirects: 0,
|
|
498618
498794
|
responseType: "arraybuffer",
|
|
@@ -498623,14 +498799,17 @@ async function getWithPermittedRedirects(url3, signal, redirectChecker, depth =
|
|
|
498623
498799
|
}
|
|
498624
498800
|
});
|
|
498625
498801
|
} catch (error52) {
|
|
498626
|
-
if (axios_default.
|
|
498802
|
+
if (axios_default.isCancel(error52) && deadlineSignal.aborted && !signal.aborted) {
|
|
498803
|
+
throw new WebFetchTransportError(`Fetch did not complete within the ${getWebFetchDeadlineMs() / 1000}s deadline`, "EDEADLINE");
|
|
498804
|
+
}
|
|
498805
|
+
if (axios_default.isAxiosError(error52) && error52.response && REDIRECT_STATUS_CODES.has(error52.response.status)) {
|
|
498627
498806
|
const redirectLocation = error52.response.headers.location;
|
|
498628
498807
|
if (!redirectLocation) {
|
|
498629
498808
|
throw new Error("Redirect missing Location header");
|
|
498630
498809
|
}
|
|
498631
498810
|
const redirectUrl = new URL(redirectLocation, url3).toString();
|
|
498632
498811
|
if (redirectChecker(url3, redirectUrl)) {
|
|
498633
|
-
return
|
|
498812
|
+
return fetchWithRedirectChain(redirectUrl, signal, redirectChecker, depth + 1, deadlineSignal);
|
|
498634
498813
|
} else {
|
|
498635
498814
|
return {
|
|
498636
498815
|
type: "redirect",
|
|
@@ -498684,7 +498863,7 @@ async function getURLMarkdownContent(url3, abortController) {
|
|
|
498684
498863
|
case "blocked":
|
|
498685
498864
|
throw new DomainBlockedError(hostname4);
|
|
498686
498865
|
case "check_failed":
|
|
498687
|
-
throw new DomainCheckFailedError(hostname4);
|
|
498866
|
+
throw new DomainCheckFailedError(hostname4, axios_default.isCancel(checkResult.error) ? "EDEADLINE_PREFLIGHT" : undefined);
|
|
498688
498867
|
}
|
|
498689
498868
|
}
|
|
498690
498869
|
if (process.env.USER_TYPE === "ant") {
|
|
@@ -498768,12 +498947,14 @@ async function applyPromptToMarkdown(prompt, markdownContent, signal, isNonInter
|
|
|
498768
498947
|
}
|
|
498769
498948
|
return "No response from model";
|
|
498770
498949
|
}
|
|
498771
|
-
var DomainBlockedError, DomainCheckFailedError, EgressBlockedError, MAX_CACHE_SIZE_BYTES, URL_CACHE, DOMAIN_CHECK_CACHE, turndownServicePromise, MAX_URL_LENGTH = 2000, MAX_HTTP_CONTENT_LENGTH = 10485760, FETCH_TIMEOUT_MS3 = 60000, DOMAIN_CHECK_TIMEOUT_MS = 1e4, MAX_REDIRECTS = 10, MAX_MARKDOWN_LENGTH = 1e5;
|
|
498950
|
+
var DomainBlockedError, DomainCheckFailedError, WebFetchTransportError, EgressBlockedError, MAX_CACHE_SIZE_BYTES, URL_CACHE, DOMAIN_CHECK_CACHE, turndownServicePromise, MAX_URL_LENGTH = 2000, MAX_HTTP_CONTENT_LENGTH = 10485760, FETCH_TIMEOUT_MS3 = 60000, DOMAIN_CHECK_TIMEOUT_MS = 1e4, MAX_REDIRECTS = 10, REDIRECT_STATUS_CODES, WEBFETCH_DEADLINE_MS_DEFAULT = 300000, MAX_DEADLINE_MS = 2147483647, MAX_MARKDOWN_LENGTH = 1e5;
|
|
498772
498951
|
var init_utils12 = __esm(() => {
|
|
498773
498952
|
init_axios2();
|
|
498774
498953
|
init_index_min();
|
|
498775
498954
|
init_analytics();
|
|
498776
498955
|
init_claude();
|
|
498956
|
+
init_combinedAbortSignal();
|
|
498957
|
+
init_envValidation();
|
|
498777
498958
|
init_errors();
|
|
498778
498959
|
init_http4();
|
|
498779
498960
|
init_log3();
|
|
@@ -498789,9 +498970,19 @@ var init_utils12 = __esm(() => {
|
|
|
498789
498970
|
}
|
|
498790
498971
|
};
|
|
498791
498972
|
DomainCheckFailedError = class DomainCheckFailedError extends Error {
|
|
498792
|
-
|
|
498973
|
+
code;
|
|
498974
|
+
constructor(domain2, code) {
|
|
498793
498975
|
super(`Unable to verify if domain ${domain2} is safe to fetch. This may be due to network restrictions or enterprise security policies blocking claude.ai.`);
|
|
498794
498976
|
this.name = "DomainCheckFailedError";
|
|
498977
|
+
this.code = code;
|
|
498978
|
+
}
|
|
498979
|
+
};
|
|
498980
|
+
WebFetchTransportError = class WebFetchTransportError extends Error {
|
|
498981
|
+
code;
|
|
498982
|
+
constructor(message, code) {
|
|
498983
|
+
super(message);
|
|
498984
|
+
this.name = "WebFetchTransportError";
|
|
498985
|
+
this.code = code;
|
|
498795
498986
|
}
|
|
498796
498987
|
};
|
|
498797
498988
|
EgressBlockedError = class EgressBlockedError extends Error {
|
|
@@ -498815,6 +499006,13 @@ var init_utils12 = __esm(() => {
|
|
|
498815
499006
|
max: 128,
|
|
498816
499007
|
ttl: 5 * 60 * 1000
|
|
498817
499008
|
});
|
|
499009
|
+
REDIRECT_STATUS_CODES = new Set([
|
|
499010
|
+
301,
|
|
499011
|
+
302,
|
|
499012
|
+
303,
|
|
499013
|
+
307,
|
|
499014
|
+
308
|
|
499015
|
+
]);
|
|
498818
499016
|
});
|
|
498819
499017
|
|
|
498820
499018
|
// src/tools/WebFetchTool/WebFetchTool.ts
|
|
@@ -561594,18 +561792,18 @@ function parseFolderPath(folderPath) {
|
|
|
561594
561792
|
}
|
|
561595
561793
|
return { platform: platform5, buildId };
|
|
561596
561794
|
}
|
|
561597
|
-
var
|
|
561795
|
+
var import_debug179, debugCache;
|
|
561598
561796
|
var init_Cache = __esm(() => {
|
|
561599
561797
|
init_browser_data();
|
|
561600
561798
|
init_detectPlatform();
|
|
561601
|
-
|
|
561602
|
-
debugCache =
|
|
561799
|
+
import_debug179 = __toESM(require_src(), 1);
|
|
561800
|
+
debugCache = import_debug179.default("puppeteer:browsers:cache");
|
|
561603
561801
|
});
|
|
561604
561802
|
|
|
561605
561803
|
// node_modules/.bun/@puppeteer+browsers@2.13.2/node_modules/@puppeteer/browsers/lib/esm/debug.js
|
|
561606
|
-
var
|
|
561804
|
+
var import_debug180;
|
|
561607
561805
|
var init_debug3 = __esm(() => {
|
|
561608
|
-
|
|
561806
|
+
import_debug180 = __toESM(require_src(), 1);
|
|
561609
561807
|
});
|
|
561610
561808
|
|
|
561611
561809
|
// node_modules/.bun/@puppeteer+browsers@2.13.2/node_modules/@puppeteer/browsers/lib/esm/launch.js
|
|
@@ -561924,7 +562122,7 @@ var init_launch = __esm(() => {
|
|
|
561924
562122
|
init_Cache();
|
|
561925
562123
|
init_debug3();
|
|
561926
562124
|
init_detectPlatform();
|
|
561927
|
-
debugLaunch =
|
|
562125
|
+
debugLaunch = import_debug180.default("puppeteer:browsers:launcher");
|
|
561928
562126
|
CDP_WEBSOCKET_ENDPOINT_REGEX = /^DevTools listening on (ws:\/\/.*)$/;
|
|
561929
562127
|
WEBDRIVER_BIDI_WEBSOCKET_ENDPOINT_REGEX = /^WebDriver BiDi listening on (ws:\/\/.*)$/;
|
|
561930
562128
|
processListeners = new Map;
|
|
@@ -567008,10 +567206,10 @@ async function installDMG(dmgPath, folderPath) {
|
|
|
567008
567206
|
spawnSync4("hdiutil", ["detach", mountPath, "-quiet"]);
|
|
567009
567207
|
}
|
|
567010
567208
|
}
|
|
567011
|
-
var
|
|
567209
|
+
var import_debug182, debugFileUtil, internalConstantsForTesting;
|
|
567012
567210
|
var init_fileUtil = __esm(() => {
|
|
567013
|
-
|
|
567014
|
-
debugFileUtil =
|
|
567211
|
+
import_debug182 = __toESM(require_src(), 1);
|
|
567212
|
+
debugFileUtil = import_debug182.default("puppeteer:browsers:fileUtil");
|
|
567015
567213
|
internalConstantsForTesting = {
|
|
567016
567214
|
xz: "xz",
|
|
567017
567215
|
bzip2: "bzip2"
|
|
@@ -567304,7 +567502,7 @@ var init_install = __esm(() => {
|
|
|
567304
567502
|
init_fileUtil();
|
|
567305
567503
|
init_httpUtil();
|
|
567306
567504
|
import_progress = __toESM(require_node_progress(), 1);
|
|
567307
|
-
debugInstall =
|
|
567505
|
+
debugInstall = import_debug180.default("puppeteer:browsers:install");
|
|
567308
567506
|
times = new Map;
|
|
567309
567507
|
});
|
|
567310
567508
|
|
|
@@ -573579,7 +573777,7 @@ import fs23 from "fs";
|
|
|
573579
573777
|
import os16 from "os";
|
|
573580
573778
|
import { dirname as dirname45 } from "path";
|
|
573581
573779
|
import { PassThrough as PassThrough4 } from "stream";
|
|
573582
|
-
var
|
|
573780
|
+
var import_debug184, __runInitializers23 = function(thisArg, initializers, value) {
|
|
573583
573781
|
var useValue = arguments.length > 2;
|
|
573584
573782
|
for (var i6 = 0;i6 < initializers.length; i6++) {
|
|
573585
573783
|
value = useValue ? initializers[i6].call(thisArg, value) : initializers[i6].call(thisArg);
|
|
@@ -573639,8 +573837,8 @@ var init_ScreenRecorder = __esm(() => {
|
|
|
573639
573837
|
init_util6();
|
|
573640
573838
|
init_decorators();
|
|
573641
573839
|
init_disposable();
|
|
573642
|
-
|
|
573643
|
-
debugFfmpeg =
|
|
573840
|
+
import_debug184 = __toESM(require_src(), 1);
|
|
573841
|
+
debugFfmpeg = import_debug184.default("puppeteer:ffmpeg");
|
|
573644
573842
|
ScreenRecorder = (() => {
|
|
573645
573843
|
let _classSuper = PassThrough4;
|
|
573646
573844
|
let _instanceExtraInitializers = [];
|
|
@@ -581311,12 +581509,13 @@ async function fetchAndCacheGatewayModels() {
|
|
|
581311
581509
|
}
|
|
581312
581510
|
const baseUrl = process.env.ANTHROPIC_BASE_URL.replace(/\/+$/, "");
|
|
581313
581511
|
const url3 = `${baseUrl}/v1/models?limit=1000`;
|
|
581512
|
+
const timeoutMs = Number(process.env[DISCOVERY_TIMEOUT_ENV] ?? DEFAULT_DISCOVERY_TIMEOUT_MS);
|
|
581314
581513
|
try {
|
|
581315
581514
|
const response3 = await fetch(url3, {
|
|
581316
581515
|
method: "GET",
|
|
581317
581516
|
headers: buildHeaders5(),
|
|
581318
581517
|
redirect: "error",
|
|
581319
|
-
signal: AbortSignal.timeout(
|
|
581518
|
+
signal: AbortSignal.timeout(timeoutMs)
|
|
581320
581519
|
});
|
|
581321
581520
|
if (!response3.ok) {
|
|
581322
581521
|
logForDebugging(`[Bootstrap] Gateway /v1/models fetch failed: HTTP ${response3.status}`);
|
|
@@ -581340,7 +581539,7 @@ async function fetchAndCacheGatewayModels() {
|
|
|
581340
581539
|
logForDebugging(`[Bootstrap] Gateway /v1/models fetch failed: ${error52 instanceof Error ? error52.message : "unknown"}`);
|
|
581341
581540
|
}
|
|
581342
581541
|
}
|
|
581343
|
-
var GatewayModelSchema, GatewayModelsResponseSchema, GatewayCacheSchema;
|
|
581542
|
+
var GatewayModelSchema, GatewayModelsResponseSchema, GatewayCacheSchema, DEFAULT_DISCOVERY_TIMEOUT_MS = 3000, DISCOVERY_TIMEOUT_ENV = "CLAUDE_CODE_GATEWAY_MODEL_DISCOVERY_TIMEOUT_MS";
|
|
581344
581543
|
var init_gatewayModelDiscovery = __esm(() => {
|
|
581345
581544
|
init_v4();
|
|
581346
581545
|
init_auth6();
|
|
@@ -586492,6 +586691,37 @@ var init_prefixStagger = __esm(() => {
|
|
|
586492
586691
|
});
|
|
586493
586692
|
|
|
586494
586693
|
// src/tools/WorkflowTool/primitives.ts
|
|
586694
|
+
import { availableParallelism } from "os";
|
|
586695
|
+
function parseConcurrencyEnv(raw) {
|
|
586696
|
+
if (raw === undefined) {
|
|
586697
|
+
return;
|
|
586698
|
+
}
|
|
586699
|
+
if (!/^[+-]?\d+$/.test(raw.trim())) {
|
|
586700
|
+
return;
|
|
586701
|
+
}
|
|
586702
|
+
const n5 = Number(raw.trim());
|
|
586703
|
+
if (!Number.isFinite(n5)) {
|
|
586704
|
+
return;
|
|
586705
|
+
}
|
|
586706
|
+
if (n5 < 1) {
|
|
586707
|
+
return;
|
|
586708
|
+
}
|
|
586709
|
+
if (n5 > 256) {
|
|
586710
|
+
return;
|
|
586711
|
+
}
|
|
586712
|
+
return n5;
|
|
586713
|
+
}
|
|
586714
|
+
function getDefaultWorkflowConcurrency() {
|
|
586715
|
+
return Math.min(16, Math.max(2, availableParallelism() - 2));
|
|
586716
|
+
}
|
|
586717
|
+
function resolveWorkflowConcurrency() {
|
|
586718
|
+
const fromEnv5 = parseConcurrencyEnv(process.env[WORKFLOW_CONCURRENCY_ENV]);
|
|
586719
|
+
const gate = fromEnv5 ?? getDefaultWorkflowConcurrency();
|
|
586720
|
+
if (fromEnv5 !== undefined) {
|
|
586721
|
+
logForDebugging(`workflow: concurrent agent gate = ${gate} (CLAUDE_CODE_WORKFLOW_MAX_CONCURRENT_AGENTS)`);
|
|
586722
|
+
}
|
|
586723
|
+
return gate;
|
|
586724
|
+
}
|
|
586495
586725
|
function workflowAgentTelemetryAttributes(runId, workflowName) {
|
|
586496
586726
|
return {
|
|
586497
586727
|
"workflow.run_id": runId,
|
|
@@ -586623,7 +586853,7 @@ function extractToolUseStats(messages) {
|
|
|
586623
586853
|
return { toolUseCount, recentActivities: capped, lastActivity };
|
|
586624
586854
|
}
|
|
586625
586855
|
function createPrimitives(ctx) {
|
|
586626
|
-
const concurrency =
|
|
586856
|
+
const concurrency = resolveWorkflowConcurrency();
|
|
586627
586857
|
const agent = async (prompt, opts = {}) => {
|
|
586628
586858
|
if (!prompt || typeof prompt !== "string") {
|
|
586629
586859
|
throw new Error("agent() requires a non-empty string prompt");
|
|
@@ -587027,7 +587257,7 @@ function buildPrimitivesObject(ctx) {
|
|
|
587027
587257
|
resolveWorkflow: p4.resolveWorkflow
|
|
587028
587258
|
};
|
|
587029
587259
|
}
|
|
587030
|
-
var WORKFLOW_AGENT_LIFETIME_CAP = 1000, WORKFLOW_PARALLEL_MAX_ITEMS = 4096,
|
|
587260
|
+
var WORKFLOW_AGENT_LIFETIME_CAP = 1000, WORKFLOW_PARALLEL_MAX_ITEMS = 4096, WORKFLOW_CONCURRENCY_ENV = "CLAUDE_CODE_WORKFLOW_MAX_CONCURRENT_AGENTS";
|
|
587031
587261
|
var init_primitives = __esm(() => {
|
|
587032
587262
|
init_runAgent();
|
|
587033
587263
|
init_generalPurposeAgent();
|
|
@@ -595690,6 +595920,11 @@ async function checkPermissionsAndCallTool(tool, toolUseID, input2, toolUseConte
|
|
|
595690
595920
|
},
|
|
595691
595921
|
...mcpToolDetailsForAnalytics(tool.name, mcpServerType, mcpServerBaseUrl)
|
|
595692
595922
|
});
|
|
595923
|
+
if (isValidCall.deniedByPermissionRule) {
|
|
595924
|
+
const observableInput = { ...parsedInput.data };
|
|
595925
|
+
tool.backfillObservableInput?.(observableInput);
|
|
595926
|
+
toolUseContext.onPermissionDenial?.(tool, toolUseID, observableInput);
|
|
595927
|
+
}
|
|
595693
595928
|
return [
|
|
595694
595929
|
{
|
|
595695
595930
|
message: createUserMessage({
|
|
@@ -606897,6 +607132,8 @@ function runPostCompactCleanup(querySource) {
|
|
|
606897
607132
|
if (isMainThreadCompact) {
|
|
606898
607133
|
getUserContext.cache.clear?.();
|
|
606899
607134
|
resetGetMemoryFilesCache("compact");
|
|
607135
|
+
getSystemContext.cache.clear?.();
|
|
607136
|
+
getGitStatus.cache.clear?.();
|
|
606900
607137
|
}
|
|
606901
607138
|
clearSystemPromptSections();
|
|
606902
607139
|
clearClassifierApprovals();
|
|
@@ -625728,9 +625965,28 @@ async function findAvailablePort() {
|
|
|
625728
625965
|
});
|
|
625729
625966
|
return REDIRECT_PORT_FALLBACK;
|
|
625730
625967
|
} catch {
|
|
625968
|
+
const ephemeralPort = await tryAssignEphemeralPort();
|
|
625969
|
+
if (ephemeralPort !== undefined) {
|
|
625970
|
+
return ephemeralPort;
|
|
625971
|
+
}
|
|
625731
625972
|
throw new Error(`No available ports for OAuth redirect`);
|
|
625732
625973
|
}
|
|
625733
625974
|
}
|
|
625975
|
+
async function tryAssignEphemeralPort() {
|
|
625976
|
+
try {
|
|
625977
|
+
return await new Promise((resolve53) => {
|
|
625978
|
+
const testServer = createServer4();
|
|
625979
|
+
testServer.once("error", () => resolve53(undefined));
|
|
625980
|
+
testServer.listen(0, "127.0.0.1", () => {
|
|
625981
|
+
const address = testServer.address();
|
|
625982
|
+
const port2 = typeof address === "object" && address !== null ? address.port : undefined;
|
|
625983
|
+
testServer.close(() => resolve53(port2));
|
|
625984
|
+
});
|
|
625985
|
+
});
|
|
625986
|
+
} catch {
|
|
625987
|
+
return;
|
|
625988
|
+
}
|
|
625989
|
+
}
|
|
625734
625990
|
var REDIRECT_PORT_RANGE, REDIRECT_PORT_FALLBACK = 3118;
|
|
625735
625991
|
var init_oauthPort = __esm(() => {
|
|
625736
625992
|
init_platform2();
|
|
@@ -644967,6 +645223,9 @@ var init_ScrollBox = __esm(() => {
|
|
|
644967
645223
|
});
|
|
644968
645224
|
|
|
644969
645225
|
// src/utils/sideQuestion.ts
|
|
645226
|
+
function containsFakeToolCalls(text2) {
|
|
645227
|
+
return BTW_FAKE_TOOLCALL_DETECTOR.test(text2);
|
|
645228
|
+
}
|
|
644970
645229
|
function findBtwTriggerPositions(text2) {
|
|
644971
645230
|
const positions = [];
|
|
644972
645231
|
const matches = text2.matchAll(BTW_PATTERN);
|
|
@@ -644995,6 +645254,7 @@ IMPORTANT CONTEXT:
|
|
|
644995
645254
|
|
|
644996
645255
|
CRITICAL CONSTRAINTS:
|
|
644997
645256
|
- You have NO tools available - you cannot read files, run commands, search, or take any actions
|
|
645257
|
+
- Do NOT write tool calls or tool output as text (for example invoke or function_calls XML blocks) - nothing you write here is executed; if answering would need reading files, running commands, or searching, say that can't be checked from a side question and suggest asking in the main conversation
|
|
644998
645258
|
- This is a one-off response - there will be no follow-up turns
|
|
644999
645259
|
- You can ONLY provide information based on what you already know from the conversation context
|
|
645000
645260
|
- NEVER say things like "Let me try...", "I'll now...", "Let me check...", or promise to take any action
|
|
@@ -645027,8 +645287,11 @@ function extractSideQuestionResponse(messages) {
|
|
|
645027
645287
|
const text2 = extractTextContent(assistantBlocks, `
|
|
645028
645288
|
|
|
645029
645289
|
`).trim();
|
|
645030
|
-
if (text2)
|
|
645031
|
-
return text2
|
|
645290
|
+
if (text2) {
|
|
645291
|
+
return containsFakeToolCalls(text2) ? `${text2}
|
|
645292
|
+
|
|
645293
|
+
${BTW_TOOLCALL_DISCLAIMER}` : text2;
|
|
645294
|
+
}
|
|
645032
645295
|
const toolUse = assistantBlocks.find((b6) => b6.type === "tool_use");
|
|
645033
645296
|
if (toolUse) {
|
|
645034
645297
|
const toolName = "name" in toolUse ? toolUse.name : "a tool";
|
|
@@ -645041,12 +645304,13 @@ function extractSideQuestionResponse(messages) {
|
|
|
645041
645304
|
}
|
|
645042
645305
|
return null;
|
|
645043
645306
|
}
|
|
645044
|
-
var BTW_PATTERN;
|
|
645307
|
+
var BTW_PATTERN, BTW_TOOL_CALL_PREFIX = "antml:", BTW_FAKE_TOOLCALL_DETECTOR, BTW_TOOLCALL_DISCLAIMER = "_/btw can't run tools: any tool calls or tool output shown above were not executed and may not reflect your actual files or data. Ask in the main conversation to check._";
|
|
645045
645308
|
var init_sideQuestion = __esm(() => {
|
|
645046
645309
|
init_errorUtils();
|
|
645047
645310
|
init_forkedAgent();
|
|
645048
645311
|
init_messages3();
|
|
645049
645312
|
BTW_PATTERN = /^\/btw\b/gi;
|
|
645313
|
+
BTW_FAKE_TOOLCALL_DETECTOR = new RegExp(`<(?:${BTW_TOOL_CALL_PREFIX})?(?:function_calls>|invoke name=)|</(?:${BTW_TOOL_CALL_PREFIX})?(?:function_calls|invoke)>`);
|
|
645050
645314
|
});
|
|
645051
645315
|
|
|
645052
645316
|
// src/commands/btw/btw.tsx
|
|
@@ -647111,10 +647375,11 @@ async function clearConversation({
|
|
|
647111
647375
|
setConversationId
|
|
647112
647376
|
}) {
|
|
647113
647377
|
const sessionEndTimeoutMs = getSessionEndHookTimeoutMs();
|
|
647378
|
+
const sessionEndBudgetMs = getSessionEndHooksBudgetMs();
|
|
647114
647379
|
await executeSessionEndHooks("clear", {
|
|
647115
647380
|
getAppState,
|
|
647116
647381
|
setAppState,
|
|
647117
|
-
signal: AbortSignal.timeout(
|
|
647382
|
+
signal: AbortSignal.timeout(sessionEndBudgetMs),
|
|
647118
647383
|
timeoutMs: sessionEndTimeoutMs
|
|
647119
647384
|
});
|
|
647120
647385
|
const lastRequestId = getLastMainRequestId();
|
|
@@ -704074,6 +704339,7 @@ var init_cd2 = __esm(() => {
|
|
|
704074
704339
|
var exports_focus = {};
|
|
704075
704340
|
__export(exports_focus, {
|
|
704076
704341
|
setFocusViewEnabled: () => setFocusViewEnabled,
|
|
704342
|
+
isFullscreenActive: () => isFullscreenActive2,
|
|
704077
704343
|
isFocusViewEnabled: () => isFocusViewEnabled,
|
|
704078
704344
|
call: () => call46
|
|
704079
704345
|
});
|
|
@@ -729176,38 +729442,6 @@ var init_hooks4 = __esm(() => {
|
|
|
729176
729442
|
});
|
|
729177
729443
|
});
|
|
729178
729444
|
|
|
729179
|
-
// src/utils/combinedAbortSignal.ts
|
|
729180
|
-
function createCombinedAbortSignal(signal, opts) {
|
|
729181
|
-
const { signalB, timeoutMs } = opts ?? {};
|
|
729182
|
-
const combined = createAbortController();
|
|
729183
|
-
if (signal?.aborted || signalB?.aborted) {
|
|
729184
|
-
combined.abort();
|
|
729185
|
-
return { signal: combined.signal, cleanup: () => {} };
|
|
729186
|
-
}
|
|
729187
|
-
let timer2;
|
|
729188
|
-
const abortCombined = () => {
|
|
729189
|
-
if (timer2 !== undefined)
|
|
729190
|
-
clearTimeout(timer2);
|
|
729191
|
-
combined.abort();
|
|
729192
|
-
};
|
|
729193
|
-
if (timeoutMs !== undefined) {
|
|
729194
|
-
timer2 = setTimeout(abortCombined, timeoutMs);
|
|
729195
|
-
timer2.unref?.();
|
|
729196
|
-
}
|
|
729197
|
-
signal?.addEventListener("abort", abortCombined);
|
|
729198
|
-
signalB?.addEventListener("abort", abortCombined);
|
|
729199
|
-
const cleanup2 = () => {
|
|
729200
|
-
if (timer2 !== undefined)
|
|
729201
|
-
clearTimeout(timer2);
|
|
729202
|
-
signal?.removeEventListener("abort", abortCombined);
|
|
729203
|
-
signalB?.removeEventListener("abort", abortCombined);
|
|
729204
|
-
};
|
|
729205
|
-
return { signal: combined.signal, cleanup: cleanup2 };
|
|
729206
|
-
}
|
|
729207
|
-
var init_combinedAbortSignal = __esm(() => {
|
|
729208
|
-
init_abortController();
|
|
729209
|
-
});
|
|
729210
|
-
|
|
729211
729445
|
// src/utils/hooks/hookHelpers.ts
|
|
729212
729446
|
function addArgumentsToPrompt(prompt, jsonInput) {
|
|
729213
729447
|
return substituteArguments(prompt, jsonInput);
|
|
@@ -730043,6 +730277,7 @@ __export(exports_hooks2, {
|
|
|
730043
730277
|
getTaskCreatedHookMessage: () => getTaskCreatedHookMessage,
|
|
730044
730278
|
getTaskCompletedHookMessage: () => getTaskCompletedHookMessage,
|
|
730045
730279
|
getStopHookMessage: () => getStopHookMessage,
|
|
730280
|
+
getSessionEndHooksBudgetMs: () => getSessionEndHooksBudgetMs,
|
|
730046
730281
|
getSessionEndHookTimeoutMs: () => getSessionEndHookTimeoutMs,
|
|
730047
730282
|
getPreToolHookBlockingMessage: () => getPreToolHookBlockingMessage,
|
|
730048
730283
|
getMatchingHooks: () => getMatchingHooks,
|
|
@@ -730093,9 +730328,28 @@ function hookCallbackTimeoutMessage(hookName, timeoutMs) {
|
|
|
730093
730328
|
return `${hookName} hook callback timed out after ${timeoutMs}ms`;
|
|
730094
730329
|
}
|
|
730095
730330
|
function getSessionEndHookTimeoutMs() {
|
|
730096
|
-
const
|
|
730097
|
-
|
|
730098
|
-
|
|
730331
|
+
const parsed = parseEnvInt(process.env.CLAUDE_CODE_SESSIONEND_HOOKS_TIMEOUT_MS);
|
|
730332
|
+
return parsed ?? SESSION_END_HOOK_TIMEOUT_MS_DEFAULT;
|
|
730333
|
+
}
|
|
730334
|
+
function getSessionEndHooksBudgetMs() {
|
|
730335
|
+
const fromEnv5 = parseEnvInt(process.env.CLAUDE_CODE_SESSIONEND_HOOKS_TIMEOUT_MS);
|
|
730336
|
+
if (fromEnv5 !== undefined) {
|
|
730337
|
+
return fromEnv5;
|
|
730338
|
+
}
|
|
730339
|
+
let maxHookTimeoutMs = 0;
|
|
730340
|
+
try {
|
|
730341
|
+
for (const matcher of getHooksConfigFromSnapshot()?.SessionEnd ?? []) {
|
|
730342
|
+
for (const hook of matcher.hooks ?? []) {
|
|
730343
|
+
const timeoutSec = hook.timeout;
|
|
730344
|
+
if (timeoutSec && timeoutSec * 1000 > maxHookTimeoutMs) {
|
|
730345
|
+
maxHookTimeoutMs = timeoutSec * 1000;
|
|
730346
|
+
}
|
|
730347
|
+
}
|
|
730348
|
+
}
|
|
730349
|
+
} catch (e4) {
|
|
730350
|
+
logError2(e4);
|
|
730351
|
+
}
|
|
730352
|
+
return Math.max(SESSION_END_HOOK_TIMEOUT_MS_DEFAULT, Math.min(maxHookTimeoutMs, SESSION_END_HOOKS_BUDGET_MS_MAX));
|
|
730099
730353
|
}
|
|
730100
730354
|
function executeInBackground({
|
|
730101
730355
|
processId,
|
|
@@ -733427,7 +733681,7 @@ async function* executeMessageDisplayHooks(display, getAppState, agentId, signal
|
|
|
733427
733681
|
timeoutMs
|
|
733428
733682
|
});
|
|
733429
733683
|
}
|
|
733430
|
-
var TOOL_HOOK_EXECUTION_TIMEOUT_MS, PRE_TOOL_USE_HOOK_TIMEOUT_MESSAGE = "PreToolUse hook did not respond before its timeout (host client may be unreachable). The tool call was not executed; other configured hooks may not have completed.", SESSION_END_HOOK_TIMEOUT_MS_DEFAULT = 1500, BACKGROUND_TASK_TYPE_LABELS, HOOK_STRING_CAP = 1000, HOOK_JSON_VALIDATION_ERROR_PREFIX = "Hook JSON output validation failed \u2014 ", HOOK_JSON_DISCRIMINATOR_KEYS, MISSING_SCRIPT_HOOK_EVENTS, MATCHER_COMMA_HYPHEN_EVENTS;
|
|
733684
|
+
var TOOL_HOOK_EXECUTION_TIMEOUT_MS, PRE_TOOL_USE_HOOK_TIMEOUT_MESSAGE = "PreToolUse hook did not respond before its timeout (host client may be unreachable). The tool call was not executed; other configured hooks may not have completed.", SESSION_END_HOOK_TIMEOUT_MS_DEFAULT = 1500, SESSION_END_HOOKS_BUDGET_MS_MAX = 60000, BACKGROUND_TASK_TYPE_LABELS, HOOK_STRING_CAP = 1000, HOOK_JSON_VALIDATION_ERROR_PREFIX = "Hook JSON output validation failed \u2014 ", HOOK_JSON_DISCRIMINATOR_KEYS, MISSING_SCRIPT_HOOK_EVENTS, MATCHER_COMMA_HYPHEN_EVENTS;
|
|
733431
733685
|
var init_hooks5 = __esm(() => {
|
|
733432
733686
|
init_file();
|
|
733433
733687
|
init_envValidation();
|
|
@@ -796852,6 +797106,7 @@ var init_tipRegistry = __esm(() => {
|
|
|
796852
797106
|
init_fileHistory();
|
|
796853
797107
|
init_settings2();
|
|
796854
797108
|
init_terminalSetup();
|
|
797109
|
+
init_focus2();
|
|
796855
797110
|
init_DesktopUpsellStartup();
|
|
796856
797111
|
init_color();
|
|
796857
797112
|
init_OverageCreditUpsell();
|
|
@@ -797328,6 +797583,12 @@ ${blue2(`/plugin install vercel@${OFFICIAL_MARKETPLACE_NAME}`)}`;
|
|
|
797328
797583
|
const config8 = getGlobalConfig();
|
|
797329
797584
|
return config8.numStartups > 5;
|
|
797330
797585
|
}
|
|
797586
|
+
},
|
|
797587
|
+
{
|
|
797588
|
+
id: "focus-view",
|
|
797589
|
+
content: async () => "Use /focus to see just your prompt, a one-line summary of the work, and the response",
|
|
797590
|
+
cooldownSessions: 15,
|
|
797591
|
+
isRelevant: async () => isFullscreenActive2() && getSettings_DEPRECATED().viewMode === undefined && !isFocusViewEnabled()
|
|
797331
797592
|
}
|
|
797332
797593
|
];
|
|
797333
797594
|
internalOnlyTips = process.env.USER_TYPE === "ant" ? [
|
|
@@ -819385,6 +819646,14 @@ class QueryEngine {
|
|
|
819385
819646
|
updateFileHistoryState: processUserInputContext.updateFileHistoryState,
|
|
819386
819647
|
updateAttributionState: processUserInputContext.updateAttributionState,
|
|
819387
819648
|
setSDKStatus,
|
|
819649
|
+
onPermissionDenial: (tool, toolUseId, input2) => {
|
|
819650
|
+
this.permissionDenials.push({
|
|
819651
|
+
type: "permission_denial",
|
|
819652
|
+
tool_name: sdkCompatToolName(tool.name),
|
|
819653
|
+
tool_use_id: toolUseId,
|
|
819654
|
+
tool_input: input2
|
|
819655
|
+
});
|
|
819656
|
+
},
|
|
819388
819657
|
taskRegistry: getHeadlessTaskRegistry()
|
|
819389
819658
|
};
|
|
819390
819659
|
headlessProfilerCheckpoint("before_skills_plugins");
|