claudish 7.66.1 → 7.67.1
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/index.js +891 -322
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -731,7 +731,7 @@ var init_onepassword_config = __esm(() => {
|
|
|
731
731
|
});
|
|
732
732
|
|
|
733
733
|
// src/version.ts
|
|
734
|
-
var VERSION = "7.
|
|
734
|
+
var VERSION = "7.67.1";
|
|
735
735
|
|
|
736
736
|
// src/logger.ts
|
|
737
737
|
var exports_logger = {};
|
|
@@ -27562,6 +27562,7 @@ __export(exports_profile_config, {
|
|
|
27562
27562
|
loadConfig: () => loadConfig,
|
|
27563
27563
|
loadLocalConfig: () => loadLocalConfig,
|
|
27564
27564
|
localConfigExists: () => localConfigExists,
|
|
27565
|
+
readProOnUltracode: () => readProOnUltracode,
|
|
27565
27566
|
removeApiKey: () => removeApiKey,
|
|
27566
27567
|
removeEndpoint: () => removeEndpoint,
|
|
27567
27568
|
saveConfig: () => saveConfig,
|
|
@@ -27650,6 +27651,9 @@ function loadConfig() {
|
|
|
27650
27651
|
if (config2.behavior !== undefined) {
|
|
27651
27652
|
merged.behavior = config2.behavior;
|
|
27652
27653
|
}
|
|
27654
|
+
if (config2.proOnUltracode !== undefined) {
|
|
27655
|
+
merged.proOnUltracode = config2.proOnUltracode;
|
|
27656
|
+
}
|
|
27653
27657
|
return merged;
|
|
27654
27658
|
} catch (error46) {
|
|
27655
27659
|
console.error(`Warning: Failed to load config, using defaults: ${error46}`);
|
|
@@ -27685,6 +27689,19 @@ function getLocalConfigPath() {
|
|
|
27685
27689
|
function localConfigExists() {
|
|
27686
27690
|
return existsSync5(getLocalConfigPath());
|
|
27687
27691
|
}
|
|
27692
|
+
function readProOnUltracode(paths = defaultScopedConfigPaths) {
|
|
27693
|
+
for (const pathFn of [paths.project, paths.global]) {
|
|
27694
|
+
try {
|
|
27695
|
+
const path = pathFn();
|
|
27696
|
+
if (!existsSync5(path))
|
|
27697
|
+
continue;
|
|
27698
|
+
const parsed = JSON.parse(readFileSync5(path, "utf-8"));
|
|
27699
|
+
if (typeof parsed?.proOnUltracode === "boolean")
|
|
27700
|
+
return parsed.proOnUltracode;
|
|
27701
|
+
} catch {}
|
|
27702
|
+
}
|
|
27703
|
+
return;
|
|
27704
|
+
}
|
|
27688
27705
|
function isProjectDirectory() {
|
|
27689
27706
|
const cwd = process.cwd();
|
|
27690
27707
|
return [".git", "package.json", "Cargo.toml", "go.mod", "pyproject.toml", ".claudish.json"].some((f) => existsSync5(join7(cwd, f)));
|
|
@@ -27968,7 +27985,7 @@ function disableLocalProvider(providerName) {
|
|
|
27968
27985
|
}
|
|
27969
27986
|
saveConfig(config2);
|
|
27970
27987
|
}
|
|
27971
|
-
var CONFIG_DIR, CONFIG_FILE, LOCAL_CONFIG_FILENAME = ".claudish.json", DEFAULT_CONFIG;
|
|
27988
|
+
var CONFIG_DIR, CONFIG_FILE, LOCAL_CONFIG_FILENAME = ".claudish.json", DEFAULT_CONFIG, defaultScopedConfigPaths;
|
|
27972
27989
|
var init_profile_config = __esm(() => {
|
|
27973
27990
|
CONFIG_DIR = join7(homedir7(), ".claudish");
|
|
27974
27991
|
CONFIG_FILE = join7(CONFIG_DIR, "config.json");
|
|
@@ -27985,6 +28002,10 @@ var init_profile_config = __esm(() => {
|
|
|
27985
28002
|
}
|
|
27986
28003
|
}
|
|
27987
28004
|
};
|
|
28005
|
+
defaultScopedConfigPaths = {
|
|
28006
|
+
global: () => activeConfigFile(),
|
|
28007
|
+
project: () => getLocalConfigPath()
|
|
28008
|
+
};
|
|
27988
28009
|
});
|
|
27989
28010
|
|
|
27990
28011
|
// src/providers/runtime-providers.ts
|
|
@@ -28149,6 +28170,24 @@ function lookupFamilyDefaultVariant(familyId, provider, cachePath) {
|
|
|
28149
28170
|
}
|
|
28150
28171
|
return;
|
|
28151
28172
|
}
|
|
28173
|
+
function lookupVariantPresets(baseModelId, provider, cachePath) {
|
|
28174
|
+
const cache2 = readAllModelsCache(cachePath);
|
|
28175
|
+
if (!cache2)
|
|
28176
|
+
return [];
|
|
28177
|
+
const wanted = stripVendorPrefix(baseModelId.toLowerCase());
|
|
28178
|
+
const found = [];
|
|
28179
|
+
for (const entry of cache2.entries) {
|
|
28180
|
+
const rv = entry.routeVariant;
|
|
28181
|
+
if (!rv?.preset || !rv.baseModelId)
|
|
28182
|
+
continue;
|
|
28183
|
+
if (stripVendorPrefix(rv.baseModelId.toLowerCase()) !== wanted)
|
|
28184
|
+
continue;
|
|
28185
|
+
if (provider !== undefined && rv.provider !== provider)
|
|
28186
|
+
continue;
|
|
28187
|
+
found.push({ modelId: entry.modelId, preset: rv.preset, provider: rv.provider });
|
|
28188
|
+
}
|
|
28189
|
+
return found;
|
|
28190
|
+
}
|
|
28152
28191
|
function lookupModelCapabilities(modelId, cachePath) {
|
|
28153
28192
|
const entry = findCacheEntry(modelId, cachePath);
|
|
28154
28193
|
if (!entry)
|
|
@@ -28177,6 +28216,9 @@ function isSubscriptionPlan(provider, cachePath) {
|
|
|
28177
28216
|
return false;
|
|
28178
28217
|
return cache2.entries.some((e) => e.subscriptionPlans?.includes(provider));
|
|
28179
28218
|
}
|
|
28219
|
+
function stripVendorPrefix(lowerId) {
|
|
28220
|
+
return lowerId.includes("/") ? lowerId.substring(lowerId.lastIndexOf("/") + 1) : lowerId;
|
|
28221
|
+
}
|
|
28180
28222
|
function findCacheEntry(modelId, cachePath) {
|
|
28181
28223
|
if (modelId.includes("@")) {
|
|
28182
28224
|
throw new Error(`model-catalog lookup received provider-routed ID "${modelId}" \u2014 callers must strip the "@" prefix before calling`);
|
|
@@ -28185,7 +28227,7 @@ function findCacheEntry(modelId, cachePath) {
|
|
|
28185
28227
|
if (!cache2 || cache2.entries.length === 0)
|
|
28186
28228
|
return;
|
|
28187
28229
|
const lower = modelId.toLowerCase();
|
|
28188
|
-
const unprefixed =
|
|
28230
|
+
const unprefixed = stripVendorPrefix(lower);
|
|
28189
28231
|
for (const entry of cache2.entries) {
|
|
28190
28232
|
const entryId = entry.modelId.toLowerCase();
|
|
28191
28233
|
const exactMatch = entryId === unprefixed || entryId === lower;
|
|
@@ -28226,8 +28268,10 @@ function truncateToolName(name, maxLength) {
|
|
|
28226
28268
|
log(`[ToolName] Truncated: "${name}" -> "${truncated}" (${name.length} -> ${truncated.length} chars)`);
|
|
28227
28269
|
return truncated;
|
|
28228
28270
|
}
|
|
28271
|
+
var TOOL_NAME_SOURCE = "[A-Za-z_][A-Za-z0-9_.-]{0,63}", TOOL_NAME_SHAPE;
|
|
28229
28272
|
var init_tool_name_utils = __esm(() => {
|
|
28230
28273
|
init_logger();
|
|
28274
|
+
TOOL_NAME_SHAPE = new RegExp(`^${TOOL_NAME_SOURCE}$`);
|
|
28231
28275
|
});
|
|
28232
28276
|
|
|
28233
28277
|
// src/handlers/shared/format/openai-messages.ts
|
|
@@ -28658,6 +28702,8 @@ class BaseAPIFormat {
|
|
|
28658
28702
|
return request;
|
|
28659
28703
|
}
|
|
28660
28704
|
clampToAdvertisedEffort(requested, reasoning) {
|
|
28705
|
+
if (this.pinnedEffort)
|
|
28706
|
+
return this.pinnedEffort;
|
|
28661
28707
|
const advertised = (reasoning.efforts ?? []).filter(isEffortLevel);
|
|
28662
28708
|
if (advertised.length === 0) {
|
|
28663
28709
|
return isEffortLevel(reasoning.defaultEffort) ? reasoning.defaultEffort : undefined;
|
|
@@ -28699,7 +28745,13 @@ class BaseAPIFormat {
|
|
|
28699
28745
|
return 8192;
|
|
28700
28746
|
}
|
|
28701
28747
|
}
|
|
28748
|
+
pinnedEffort;
|
|
28749
|
+
setEffortOverride(level) {
|
|
28750
|
+
this.pinnedEffort = level;
|
|
28751
|
+
}
|
|
28702
28752
|
resolveEffortLevel(originalRequest) {
|
|
28753
|
+
if (this.pinnedEffort)
|
|
28754
|
+
return this.pinnedEffort;
|
|
28703
28755
|
const lvl = originalRequest?.output_config?.effort;
|
|
28704
28756
|
if (typeof lvl === "string") {
|
|
28705
28757
|
const lower = lvl.toLowerCase();
|
|
@@ -29539,9 +29591,32 @@ function filterIdentity(content) {
|
|
|
29539
29591
|
}
|
|
29540
29592
|
|
|
29541
29593
|
// src/handlers/shared/tool-call-recovery.ts
|
|
29542
|
-
function
|
|
29594
|
+
function hasExtractableFunctionTag(text) {
|
|
29595
|
+
return FUNCTION_TAG_PRESENT.test(text);
|
|
29596
|
+
}
|
|
29597
|
+
function keepOnlyRealTools(extracted, knownToolNames) {
|
|
29598
|
+
const kept = [];
|
|
29599
|
+
for (const call of extracted) {
|
|
29600
|
+
if (!TOOL_NAME_SHAPE.test(call.name)) {
|
|
29601
|
+
log(`[ToolRecovery] Dropped extracted call: name is not an identifier: ${JSON.stringify(call.name.slice(0, 120))}`);
|
|
29602
|
+
continue;
|
|
29603
|
+
}
|
|
29604
|
+
if (!knownToolNames || knownToolNames.length === 0) {
|
|
29605
|
+
kept.push(call);
|
|
29606
|
+
continue;
|
|
29607
|
+
}
|
|
29608
|
+
const canonical = knownToolNames.find((t) => t.toLowerCase() === call.name.toLowerCase());
|
|
29609
|
+
if (!canonical) {
|
|
29610
|
+
log(`[ToolRecovery] Dropped extracted call for unadvertised tool: ${call.name}`);
|
|
29611
|
+
continue;
|
|
29612
|
+
}
|
|
29613
|
+
kept.push(canonical === call.name ? call : { ...call, name: canonical });
|
|
29614
|
+
}
|
|
29615
|
+
return kept;
|
|
29616
|
+
}
|
|
29617
|
+
function extractToolCallsFromText(text, knownToolNames) {
|
|
29543
29618
|
const extracted = [];
|
|
29544
|
-
const qwenPattern =
|
|
29619
|
+
const qwenPattern = new RegExp(FUNCTION_TAG_SOURCE, "gi");
|
|
29545
29620
|
let match;
|
|
29546
29621
|
while ((match = qwenPattern.exec(text)) !== null) {
|
|
29547
29622
|
const funcName = match[1];
|
|
@@ -29635,7 +29710,7 @@ function extractToolCallsFromText(text) {
|
|
|
29635
29710
|
}
|
|
29636
29711
|
} catch (e) {}
|
|
29637
29712
|
}
|
|
29638
|
-
const knownTools = [
|
|
29713
|
+
const knownTools = knownToolNames && knownToolNames.length > 0 ? knownToolNames : [
|
|
29639
29714
|
"Task",
|
|
29640
29715
|
"Read",
|
|
29641
29716
|
"Write",
|
|
@@ -29743,7 +29818,7 @@ function extractToolCallsFromText(text) {
|
|
|
29743
29818
|
}
|
|
29744
29819
|
}
|
|
29745
29820
|
}
|
|
29746
|
-
return extracted;
|
|
29821
|
+
return keepOnlyRealTools(extracted, knownToolNames);
|
|
29747
29822
|
}
|
|
29748
29823
|
function inferMissingParameters(toolName2, args, missingParams, context) {
|
|
29749
29824
|
const inferred = { ...args };
|
|
@@ -29908,8 +29983,12 @@ function validateAndRepairToolCall(toolName2, argsStr, toolSchemas, textContent)
|
|
|
29908
29983
|
}
|
|
29909
29984
|
return { valid: false, args: repairedArgs, repaired: false, missingParams: stillMissing };
|
|
29910
29985
|
}
|
|
29986
|
+
var FUNCTION_TAG_SOURCE, FUNCTION_TAG_PRESENT;
|
|
29911
29987
|
var init_tool_call_recovery = __esm(() => {
|
|
29988
|
+
init_tool_name_utils();
|
|
29912
29989
|
init_logger();
|
|
29990
|
+
FUNCTION_TAG_SOURCE = `<function=(${TOOL_NAME_SOURCE})>([\\s\\S]*?)(?=<function=|$)`;
|
|
29991
|
+
FUNCTION_TAG_PRESENT = new RegExp(`<function=${TOOL_NAME_SOURCE}>`);
|
|
29913
29992
|
});
|
|
29914
29993
|
|
|
29915
29994
|
// src/handlers/shared/web-search-detector.ts
|
|
@@ -30052,7 +30131,10 @@ data: ${JSON.stringify(d)}
|
|
|
30052
30131
|
const preview = state.accumulatedText.slice(0, 500).replace(/\n/g, "\\n");
|
|
30053
30132
|
log(`[Streaming] Accumulated text (${state.accumulatedText.length} chars): ${preview}...`);
|
|
30054
30133
|
}
|
|
30055
|
-
const textToolCalls = extractToolCallsFromText(state.accumulatedText);
|
|
30134
|
+
const textToolCalls = state.tools.size > 0 ? [] : extractToolCallsFromText(state.accumulatedText, toolSchemas?.map((t) => t?.name).filter((n) => !!n));
|
|
30135
|
+
if (state.tools.size > 0 && state.accumulatedText.length > 0) {
|
|
30136
|
+
log(`[Streaming] Skipping text-based tool extraction: ${state.tools.size} structured tool call(s) already present`);
|
|
30137
|
+
}
|
|
30056
30138
|
log(`[Streaming] Text-based tool calls found: ${textToolCalls.length}`);
|
|
30057
30139
|
if (textToolCalls.length > 0) {
|
|
30058
30140
|
log(`[Streaming] Found ${textToolCalls.length} text-based tool call(s), converting to structured format`);
|
|
@@ -30259,7 +30341,7 @@ data: ${JSON.stringify(d)}
|
|
|
30259
30341
|
}
|
|
30260
30342
|
if (res.cleanedText) {
|
|
30261
30343
|
state.accumulatedText += res.cleanedText;
|
|
30262
|
-
const hasStructuredToolPattern =
|
|
30344
|
+
const hasStructuredToolPattern = hasExtractableFunctionTag(state.accumulatedText) || /\{\s*"(?:name|tool)"\s*:\s*"(?:Task|Read|Write|Edit|Bash|Grep|Glob)"/i.test(state.accumulatedText) || /<tool_call>/.test(state.accumulatedText);
|
|
30263
30345
|
const shouldHoldBack = hasStructuredToolPattern && state.accumulatedText.length < 1000;
|
|
30264
30346
|
if (shouldHoldBack) {
|
|
30265
30347
|
log(`[Streaming] Text held back (structured tool pattern): ${state.accumulatedText.length} chars accumulated`);
|
|
@@ -35177,6 +35259,57 @@ var init_middleware = __esm(() => {
|
|
|
35177
35259
|
init_gemini_thought_signature();
|
|
35178
35260
|
});
|
|
35179
35261
|
|
|
35262
|
+
// src/model-params.ts
|
|
35263
|
+
function isPlainObject3(value) {
|
|
35264
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
35265
|
+
}
|
|
35266
|
+
function deepMergeParams(target, source) {
|
|
35267
|
+
for (const [key, value] of Object.entries(source)) {
|
|
35268
|
+
if (isPlainObject3(value) && isPlainObject3(target[key])) {
|
|
35269
|
+
deepMergeParams(target[key], value);
|
|
35270
|
+
} else if (isPlainObject3(value)) {
|
|
35271
|
+
target[key] = deepMergeParams({}, value);
|
|
35272
|
+
} else {
|
|
35273
|
+
target[key] = value;
|
|
35274
|
+
}
|
|
35275
|
+
}
|
|
35276
|
+
return target;
|
|
35277
|
+
}
|
|
35278
|
+
function coerceValue(raw) {
|
|
35279
|
+
try {
|
|
35280
|
+
return JSON.parse(raw);
|
|
35281
|
+
} catch {
|
|
35282
|
+
return raw;
|
|
35283
|
+
}
|
|
35284
|
+
}
|
|
35285
|
+
function parseModelParams(spec, into = {}) {
|
|
35286
|
+
for (const item of spec.split(",")) {
|
|
35287
|
+
const trimmed2 = item.trim();
|
|
35288
|
+
if (!trimmed2)
|
|
35289
|
+
continue;
|
|
35290
|
+
const eq = trimmed2.indexOf("=");
|
|
35291
|
+
if (eq <= 0) {
|
|
35292
|
+
throw new Error(`--model-params item "${trimmed2}" must be key=value`);
|
|
35293
|
+
}
|
|
35294
|
+
const key = trimmed2.slice(0, eq).trim();
|
|
35295
|
+
const raw = trimmed2.slice(eq + 1);
|
|
35296
|
+
const path = key.split(".");
|
|
35297
|
+
if (path.some((seg) => seg.length === 0)) {
|
|
35298
|
+
throw new Error(`--model-params key "${key}" has an empty dot segment`);
|
|
35299
|
+
}
|
|
35300
|
+
const nested = {};
|
|
35301
|
+
let cursor = nested;
|
|
35302
|
+
for (const seg of path.slice(0, -1)) {
|
|
35303
|
+
const child = {};
|
|
35304
|
+
cursor[seg] = child;
|
|
35305
|
+
cursor = child;
|
|
35306
|
+
}
|
|
35307
|
+
cursor[path[path.length - 1]] = coerceValue(raw);
|
|
35308
|
+
deepMergeParams(into, nested);
|
|
35309
|
+
}
|
|
35310
|
+
return into;
|
|
35311
|
+
}
|
|
35312
|
+
|
|
35180
35313
|
// src/handlers/shared/quota-exhaustion.ts
|
|
35181
35314
|
function hasQuotaExhaustionWording(errorBody) {
|
|
35182
35315
|
const lower = (errorBody || "").toLowerCase();
|
|
@@ -39198,6 +39331,362 @@ var init_vision_proxy = __esm(() => {
|
|
|
39198
39331
|
init_catalog_query();
|
|
39199
39332
|
});
|
|
39200
39333
|
|
|
39334
|
+
// src/session-events/event-translator.ts
|
|
39335
|
+
function translateLine(line) {
|
|
39336
|
+
let record4;
|
|
39337
|
+
try {
|
|
39338
|
+
record4 = JSON.parse(line);
|
|
39339
|
+
} catch {
|
|
39340
|
+
return null;
|
|
39341
|
+
}
|
|
39342
|
+
if (record4 === null || typeof record4 !== "object")
|
|
39343
|
+
return null;
|
|
39344
|
+
const at = typeof record4.timestamp === "string" ? record4.timestamp : undefined;
|
|
39345
|
+
if (record4.type === "attachment") {
|
|
39346
|
+
const attachmentType = record4.attachment?.type;
|
|
39347
|
+
if (attachmentType === "ultra_effort_enter")
|
|
39348
|
+
return { kind: "ultra_effort_enter", at };
|
|
39349
|
+
if (attachmentType === "ultra_effort_exit")
|
|
39350
|
+
return { kind: "ultra_effort_exit", at };
|
|
39351
|
+
return {
|
|
39352
|
+
kind: "unknown",
|
|
39353
|
+
attachmentType: typeof attachmentType === "string" ? attachmentType : undefined,
|
|
39354
|
+
at
|
|
39355
|
+
};
|
|
39356
|
+
}
|
|
39357
|
+
if (record4.type === "user") {
|
|
39358
|
+
const content = record4.message?.content;
|
|
39359
|
+
if (typeof content === "string" && content.includes("<local-command-stdout>")) {
|
|
39360
|
+
const match = content.match(EFFORT_STDOUT_RE);
|
|
39361
|
+
if (match) {
|
|
39362
|
+
const scope = match[2] === "this session only" ? "session" : "default";
|
|
39363
|
+
return { kind: "effort_changed", level: match[1], scope, at };
|
|
39364
|
+
}
|
|
39365
|
+
}
|
|
39366
|
+
}
|
|
39367
|
+
return null;
|
|
39368
|
+
}
|
|
39369
|
+
var EFFORT_STDOUT_RE;
|
|
39370
|
+
var init_event_translator = __esm(() => {
|
|
39371
|
+
EFFORT_STDOUT_RE = /Set effort level to (\S+) \((this session only|saved as your default)/;
|
|
39372
|
+
});
|
|
39373
|
+
|
|
39374
|
+
// src/session-events/session-state.ts
|
|
39375
|
+
function initialState(seed) {
|
|
39376
|
+
if (seed?.defaultEffort) {
|
|
39377
|
+
return {
|
|
39378
|
+
ultracodeActive: false,
|
|
39379
|
+
effort: seed.defaultEffort,
|
|
39380
|
+
defaultEffort: seed.defaultEffort,
|
|
39381
|
+
seededFrom: "settings"
|
|
39382
|
+
};
|
|
39383
|
+
}
|
|
39384
|
+
return { ultracodeActive: false, seededFrom: "none" };
|
|
39385
|
+
}
|
|
39386
|
+
function reduceEvent(state, event) {
|
|
39387
|
+
const next = { ...state, lastEventAt: event.at ?? state.lastEventAt };
|
|
39388
|
+
switch (event.kind) {
|
|
39389
|
+
case "ultra_effort_enter":
|
|
39390
|
+
next.ultracodeActive = true;
|
|
39391
|
+
return next;
|
|
39392
|
+
case "ultra_effort_exit":
|
|
39393
|
+
next.ultracodeActive = false;
|
|
39394
|
+
return next;
|
|
39395
|
+
case "effort_changed":
|
|
39396
|
+
next.effort = event.level;
|
|
39397
|
+
next.effortScope = event.scope;
|
|
39398
|
+
next.ultracodeActive = event.level === "ultracode";
|
|
39399
|
+
if (event.scope === "default")
|
|
39400
|
+
next.defaultEffort = event.level;
|
|
39401
|
+
return next;
|
|
39402
|
+
default:
|
|
39403
|
+
return next;
|
|
39404
|
+
}
|
|
39405
|
+
}
|
|
39406
|
+
|
|
39407
|
+
// src/session-events/transcript-tailer.ts
|
|
39408
|
+
import { closeSync as closeSync5, openSync as openSync5, readSync, statSync as statSync4 } from "fs";
|
|
39409
|
+
|
|
39410
|
+
class TranscriptTailer {
|
|
39411
|
+
filePath;
|
|
39412
|
+
onLine;
|
|
39413
|
+
opts;
|
|
39414
|
+
offset = 0;
|
|
39415
|
+
buffer = "";
|
|
39416
|
+
decoder = new TextDecoder;
|
|
39417
|
+
timer = null;
|
|
39418
|
+
disposed = false;
|
|
39419
|
+
constructor(filePath, onLine, opts = {}) {
|
|
39420
|
+
this.filePath = filePath;
|
|
39421
|
+
this.onLine = onLine;
|
|
39422
|
+
this.opts = opts;
|
|
39423
|
+
}
|
|
39424
|
+
start() {
|
|
39425
|
+
if (this.disposed)
|
|
39426
|
+
return;
|
|
39427
|
+
this.tick();
|
|
39428
|
+
this.schedule();
|
|
39429
|
+
}
|
|
39430
|
+
syncNow() {
|
|
39431
|
+
this.tick();
|
|
39432
|
+
}
|
|
39433
|
+
dispose() {
|
|
39434
|
+
this.disposed = true;
|
|
39435
|
+
if (this.timer) {
|
|
39436
|
+
clearTimeout(this.timer);
|
|
39437
|
+
this.timer = null;
|
|
39438
|
+
}
|
|
39439
|
+
}
|
|
39440
|
+
schedule() {
|
|
39441
|
+
if (this.disposed)
|
|
39442
|
+
return;
|
|
39443
|
+
this.timer = setTimeout(() => {
|
|
39444
|
+
this.tick();
|
|
39445
|
+
this.schedule();
|
|
39446
|
+
}, this.opts.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS);
|
|
39447
|
+
this.timer.unref?.();
|
|
39448
|
+
}
|
|
39449
|
+
tick() {
|
|
39450
|
+
if (this.disposed)
|
|
39451
|
+
return;
|
|
39452
|
+
try {
|
|
39453
|
+
const size = statSync4(this.filePath).size;
|
|
39454
|
+
if (size < this.offset) {
|
|
39455
|
+
this.offset = 0;
|
|
39456
|
+
this.buffer = "";
|
|
39457
|
+
this.decoder = new TextDecoder;
|
|
39458
|
+
}
|
|
39459
|
+
if (size === this.offset)
|
|
39460
|
+
return;
|
|
39461
|
+
const fd = openSync5(this.filePath, "r");
|
|
39462
|
+
let chunk;
|
|
39463
|
+
try {
|
|
39464
|
+
chunk = Buffer.alloc(size - this.offset);
|
|
39465
|
+
const bytesRead = readSync(fd, chunk, 0, chunk.length, this.offset);
|
|
39466
|
+
this.offset += bytesRead;
|
|
39467
|
+
if (bytesRead < chunk.length)
|
|
39468
|
+
chunk = chunk.subarray(0, bytesRead);
|
|
39469
|
+
} finally {
|
|
39470
|
+
closeSync5(fd);
|
|
39471
|
+
}
|
|
39472
|
+
this.buffer += this.decoder.decode(chunk, { stream: true });
|
|
39473
|
+
const lines = this.buffer.split(`
|
|
39474
|
+
`);
|
|
39475
|
+
this.buffer = lines.pop() ?? "";
|
|
39476
|
+
for (const line of lines) {
|
|
39477
|
+
if (line.trim())
|
|
39478
|
+
this.onLine(line);
|
|
39479
|
+
}
|
|
39480
|
+
} catch (err) {
|
|
39481
|
+
this.dispose();
|
|
39482
|
+
this.opts.onError?.(err);
|
|
39483
|
+
}
|
|
39484
|
+
}
|
|
39485
|
+
}
|
|
39486
|
+
var DEFAULT_POLL_INTERVAL_MS = 250;
|
|
39487
|
+
var init_transcript_tailer = () => {};
|
|
39488
|
+
|
|
39489
|
+
// src/session-events/index.ts
|
|
39490
|
+
import { existsSync as existsSync16, readFileSync as readFileSync15, readdirSync as readdirSync3 } from "fs";
|
|
39491
|
+
import { homedir as homedir23 } from "os";
|
|
39492
|
+
import { join as join23 } from "path";
|
|
39493
|
+
function extractSessionId2(metadata) {
|
|
39494
|
+
const userId = metadata?.user_id;
|
|
39495
|
+
if (typeof userId !== "string")
|
|
39496
|
+
return;
|
|
39497
|
+
try {
|
|
39498
|
+
const parsed = JSON.parse(userId);
|
|
39499
|
+
if (typeof parsed?.session_id === "string" && parsed.session_id) {
|
|
39500
|
+
return parsed.session_id;
|
|
39501
|
+
}
|
|
39502
|
+
} catch {}
|
|
39503
|
+
const match = userId.match(/session_([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})/i);
|
|
39504
|
+
return match?.[1];
|
|
39505
|
+
}
|
|
39506
|
+
function slugFromCwd(cwd) {
|
|
39507
|
+
return cwd.replace(/[^a-zA-Z0-9]/g, "-");
|
|
39508
|
+
}
|
|
39509
|
+
|
|
39510
|
+
class SessionEventRegistry {
|
|
39511
|
+
sessions = new Map;
|
|
39512
|
+
misses = new Map;
|
|
39513
|
+
subscribers = [];
|
|
39514
|
+
claudeHome;
|
|
39515
|
+
pollIntervalMs;
|
|
39516
|
+
constructor(opts = {}) {
|
|
39517
|
+
this.claudeHome = opts.claudeHome ?? join23(homedir23(), ".claude");
|
|
39518
|
+
this.pollIntervalMs = opts.pollIntervalMs;
|
|
39519
|
+
}
|
|
39520
|
+
ensureSession(sessionId) {
|
|
39521
|
+
try {
|
|
39522
|
+
this.sweepIdle();
|
|
39523
|
+
const existing = this.sessions.get(sessionId);
|
|
39524
|
+
if (existing) {
|
|
39525
|
+
existing.lastActivity = Date.now();
|
|
39526
|
+
return;
|
|
39527
|
+
}
|
|
39528
|
+
const miss = this.misses.get(sessionId);
|
|
39529
|
+
if (miss) {
|
|
39530
|
+
if (miss.count >= MAX_MISSES)
|
|
39531
|
+
return;
|
|
39532
|
+
if (Date.now() - miss.lastTry < MISS_TTL_MS)
|
|
39533
|
+
return;
|
|
39534
|
+
}
|
|
39535
|
+
const filePath = this.locateTranscript(sessionId);
|
|
39536
|
+
if (!filePath) {
|
|
39537
|
+
const count = (miss?.count ?? 0) + 1;
|
|
39538
|
+
this.misses.set(sessionId, { lastTry: Date.now(), count });
|
|
39539
|
+
if (count === MAX_MISSES) {
|
|
39540
|
+
log(`[SessionEvents] transcript for session ${sessionId} not found after ${MAX_MISSES} attempts \u2014 giving up`);
|
|
39541
|
+
}
|
|
39542
|
+
return;
|
|
39543
|
+
}
|
|
39544
|
+
this.misses.delete(sessionId);
|
|
39545
|
+
const entry = {
|
|
39546
|
+
state: initialState({ defaultEffort: this.readSettingsEffortLevel() }),
|
|
39547
|
+
tailer: new TranscriptTailer(filePath, (line) => this.onLine(sessionId, line), {
|
|
39548
|
+
pollIntervalMs: this.pollIntervalMs,
|
|
39549
|
+
onError: (err) => log(`[SessionEvents] tailer for ${sessionId} stopped: ${err}`)
|
|
39550
|
+
}),
|
|
39551
|
+
lastActivity: Date.now()
|
|
39552
|
+
};
|
|
39553
|
+
this.sessions.set(sessionId, entry);
|
|
39554
|
+
entry.tailer.start();
|
|
39555
|
+
log(`[SessionEvents] tailing ${filePath}`);
|
|
39556
|
+
} catch (err) {
|
|
39557
|
+
log(`[SessionEvents] ensureSession(${sessionId}) failed: ${err}`);
|
|
39558
|
+
}
|
|
39559
|
+
}
|
|
39560
|
+
sync(sessionId) {
|
|
39561
|
+
try {
|
|
39562
|
+
const entry = this.sessions.get(sessionId);
|
|
39563
|
+
if (entry) {
|
|
39564
|
+
entry.lastActivity = Date.now();
|
|
39565
|
+
entry.tailer.syncNow();
|
|
39566
|
+
}
|
|
39567
|
+
} catch (err) {
|
|
39568
|
+
log(`[SessionEvents] sync(${sessionId}) failed: ${err}`);
|
|
39569
|
+
}
|
|
39570
|
+
}
|
|
39571
|
+
getState(sessionId) {
|
|
39572
|
+
return this.sessions.get(sessionId)?.state;
|
|
39573
|
+
}
|
|
39574
|
+
subscribe(fn) {
|
|
39575
|
+
this.subscribers.push(fn);
|
|
39576
|
+
return () => {
|
|
39577
|
+
this.subscribers = this.subscribers.filter((s) => s !== fn);
|
|
39578
|
+
};
|
|
39579
|
+
}
|
|
39580
|
+
disposeAll() {
|
|
39581
|
+
for (const entry of this.sessions.values()) {
|
|
39582
|
+
entry.tailer.dispose();
|
|
39583
|
+
}
|
|
39584
|
+
this.sessions.clear();
|
|
39585
|
+
this.misses.clear();
|
|
39586
|
+
}
|
|
39587
|
+
onLine(sessionId, line) {
|
|
39588
|
+
const event = translateLine(line);
|
|
39589
|
+
if (!event)
|
|
39590
|
+
return;
|
|
39591
|
+
const entry = this.sessions.get(sessionId);
|
|
39592
|
+
if (!entry)
|
|
39593
|
+
return;
|
|
39594
|
+
entry.state = reduceEvent(entry.state, event);
|
|
39595
|
+
log(`[SessionEvents] ${sessionId}: ${event.kind}${event.kind === "effort_changed" ? ` level=${event.level} scope=${event.scope}` : ""} \u2192 ultracodeActive=${entry.state.ultracodeActive}`);
|
|
39596
|
+
for (const fn of this.subscribers) {
|
|
39597
|
+
try {
|
|
39598
|
+
fn(sessionId, event);
|
|
39599
|
+
} catch {}
|
|
39600
|
+
}
|
|
39601
|
+
}
|
|
39602
|
+
locateTranscript(sessionId) {
|
|
39603
|
+
const projectsDir = join23(this.claudeHome, "projects");
|
|
39604
|
+
const primary = join23(projectsDir, slugFromCwd(process.cwd()), `${sessionId}.jsonl`);
|
|
39605
|
+
if (existsSync16(primary))
|
|
39606
|
+
return primary;
|
|
39607
|
+
try {
|
|
39608
|
+
for (const dir of readdirSync3(projectsDir)) {
|
|
39609
|
+
const candidate = join23(projectsDir, dir, `${sessionId}.jsonl`);
|
|
39610
|
+
if (existsSync16(candidate))
|
|
39611
|
+
return candidate;
|
|
39612
|
+
}
|
|
39613
|
+
} catch {}
|
|
39614
|
+
return;
|
|
39615
|
+
}
|
|
39616
|
+
readSettingsEffortLevel() {
|
|
39617
|
+
try {
|
|
39618
|
+
const settings = JSON.parse(readFileSync15(join23(this.claudeHome, "settings.json"), "utf-8"));
|
|
39619
|
+
return typeof settings.effortLevel === "string" ? settings.effortLevel : undefined;
|
|
39620
|
+
} catch {
|
|
39621
|
+
return;
|
|
39622
|
+
}
|
|
39623
|
+
}
|
|
39624
|
+
sweepIdle() {
|
|
39625
|
+
const now2 = Date.now();
|
|
39626
|
+
for (const [sid, entry] of this.sessions) {
|
|
39627
|
+
if (now2 - entry.lastActivity > IDLE_SWEEP_MS) {
|
|
39628
|
+
entry.tailer.dispose();
|
|
39629
|
+
this.sessions.delete(sid);
|
|
39630
|
+
}
|
|
39631
|
+
}
|
|
39632
|
+
}
|
|
39633
|
+
}
|
|
39634
|
+
var MISS_TTL_MS = 5000, MAX_MISSES = 5, IDLE_SWEEP_MS, sessionEvents;
|
|
39635
|
+
var init_session_events = __esm(() => {
|
|
39636
|
+
init_logger();
|
|
39637
|
+
init_event_translator();
|
|
39638
|
+
init_transcript_tailer();
|
|
39639
|
+
IDLE_SWEEP_MS = 30 * 60 * 1000;
|
|
39640
|
+
sessionEvents = new SessionEventRegistry;
|
|
39641
|
+
});
|
|
39642
|
+
|
|
39643
|
+
// src/session-events/pro-injection.ts
|
|
39644
|
+
function resolveVariantPreset(bareModelName, provider, cachePath) {
|
|
39645
|
+
for (const variant of lookupVariantPresets(bareModelName, provider, cachePath)) {
|
|
39646
|
+
try {
|
|
39647
|
+
const params = parseModelParams(variant.preset);
|
|
39648
|
+
if (Object.keys(params).length === 0)
|
|
39649
|
+
continue;
|
|
39650
|
+
return {
|
|
39651
|
+
params,
|
|
39652
|
+
variantModelId: variant.modelId,
|
|
39653
|
+
provider: variant.provider,
|
|
39654
|
+
preset: variant.preset
|
|
39655
|
+
};
|
|
39656
|
+
} catch {}
|
|
39657
|
+
}
|
|
39658
|
+
return;
|
|
39659
|
+
}
|
|
39660
|
+
function applyProInjection(requestPayload, opts) {
|
|
39661
|
+
try {
|
|
39662
|
+
if (!opts.enabled || !opts.sessionId)
|
|
39663
|
+
return false;
|
|
39664
|
+
if (opts.outputConfig?.effort !== "xhigh")
|
|
39665
|
+
return false;
|
|
39666
|
+
if (opts.outputConfig?.format)
|
|
39667
|
+
return false;
|
|
39668
|
+
const registry2 = opts.registry ?? sessionEvents;
|
|
39669
|
+
registry2.ensureSession(opts.sessionId);
|
|
39670
|
+
registry2.sync(opts.sessionId);
|
|
39671
|
+
const state = registry2.getState(opts.sessionId);
|
|
39672
|
+
if (!state?.ultracodeActive)
|
|
39673
|
+
return false;
|
|
39674
|
+
const resolved = resolveVariantPreset(opts.bareModelName, opts.provider, opts.cachePath);
|
|
39675
|
+
if (!resolved)
|
|
39676
|
+
return false;
|
|
39677
|
+
deepMergeParams(requestPayload, resolved.params);
|
|
39678
|
+
log(`[SessionEvents] ultracode active \u2192 preset ${resolved.preset} for ${opts.targetModel} ` + `(catalog variant ${resolved.variantModelId} @ ${resolved.provider}, session ${opts.sessionId})`);
|
|
39679
|
+
return true;
|
|
39680
|
+
} catch {
|
|
39681
|
+
return false;
|
|
39682
|
+
}
|
|
39683
|
+
}
|
|
39684
|
+
var init_pro_injection = __esm(() => {
|
|
39685
|
+
init_model_catalog();
|
|
39686
|
+
init_logger();
|
|
39687
|
+
init_session_events();
|
|
39688
|
+
});
|
|
39689
|
+
|
|
39201
39690
|
// src/providers/model-parser.ts
|
|
39202
39691
|
function parseModelChain(modelSpec) {
|
|
39203
39692
|
const parts = modelSpec.split(MODEL_CHAIN_SEPARATOR).map((s) => s.trim()).filter(Boolean);
|
|
@@ -39313,25 +39802,25 @@ var init_model_parser = __esm(() => {
|
|
|
39313
39802
|
|
|
39314
39803
|
// src/stats-buffer.ts
|
|
39315
39804
|
import {
|
|
39316
|
-
existsSync as
|
|
39805
|
+
existsSync as existsSync17,
|
|
39317
39806
|
mkdirSync as mkdirSync9,
|
|
39318
|
-
readFileSync as
|
|
39807
|
+
readFileSync as readFileSync16,
|
|
39319
39808
|
renameSync as renameSync2,
|
|
39320
39809
|
unlinkSync as unlinkSync5,
|
|
39321
39810
|
writeFileSync as writeFileSync8
|
|
39322
39811
|
} from "fs";
|
|
39323
|
-
import { homedir as
|
|
39324
|
-
import { join as
|
|
39812
|
+
import { homedir as homedir24 } from "os";
|
|
39813
|
+
import { join as join24 } from "path";
|
|
39325
39814
|
function ensureDir() {
|
|
39326
|
-
if (!
|
|
39815
|
+
if (!existsSync17(CLAUDISH_DIR)) {
|
|
39327
39816
|
mkdirSync9(CLAUDISH_DIR, { recursive: true });
|
|
39328
39817
|
}
|
|
39329
39818
|
}
|
|
39330
39819
|
function readFromDisk() {
|
|
39331
39820
|
try {
|
|
39332
|
-
if (!
|
|
39821
|
+
if (!existsSync17(BUFFER_FILE))
|
|
39333
39822
|
return [];
|
|
39334
|
-
const raw =
|
|
39823
|
+
const raw = readFileSync16(BUFFER_FILE, "utf-8");
|
|
39335
39824
|
const parsed = JSON.parse(raw);
|
|
39336
39825
|
if (!Array.isArray(parsed.events))
|
|
39337
39826
|
return [];
|
|
@@ -39356,7 +39845,7 @@ function writeToDisk(events) {
|
|
|
39356
39845
|
ensureDir();
|
|
39357
39846
|
const trimmed2 = enforceSizeCap([...events]);
|
|
39358
39847
|
const payload = { version: 1, events: trimmed2 };
|
|
39359
|
-
const tmpFile =
|
|
39848
|
+
const tmpFile = join24(CLAUDISH_DIR, `stats-buffer.tmp.${process.pid}.json`);
|
|
39360
39849
|
writeFileSync8(tmpFile, JSON.stringify(payload, null, 2), "utf-8");
|
|
39361
39850
|
renameSync2(tmpFile, BUFFER_FILE);
|
|
39362
39851
|
memoryCache = trimmed2;
|
|
@@ -39400,7 +39889,7 @@ function clearBuffer() {
|
|
|
39400
39889
|
try {
|
|
39401
39890
|
memoryCache = [];
|
|
39402
39891
|
eventsSinceLastFlush = 0;
|
|
39403
|
-
if (
|
|
39892
|
+
if (existsSync17(BUFFER_FILE)) {
|
|
39404
39893
|
unlinkSync5(BUFFER_FILE);
|
|
39405
39894
|
}
|
|
39406
39895
|
} catch {}
|
|
@@ -39429,8 +39918,8 @@ function syncFlushOnExit() {
|
|
|
39429
39918
|
var BUFFER_MAX_BYTES, CLAUDISH_DIR, BUFFER_FILE, memoryCache = null, eventsSinceLastFlush = 0, flushScheduled = false, SIGNAL_EXIT_CODE;
|
|
39430
39919
|
var init_stats_buffer = __esm(() => {
|
|
39431
39920
|
BUFFER_MAX_BYTES = 64 * 1024;
|
|
39432
|
-
CLAUDISH_DIR =
|
|
39433
|
-
BUFFER_FILE =
|
|
39921
|
+
CLAUDISH_DIR = join24(homedir24(), ".claudish");
|
|
39922
|
+
BUFFER_FILE = join24(CLAUDISH_DIR, "stats-buffer.json");
|
|
39434
39923
|
process.on("exit", syncFlushOnExit);
|
|
39435
39924
|
SIGNAL_EXIT_CODE = { SIGTERM: 143, SIGINT: 130 };
|
|
39436
39925
|
for (const signal of ["SIGTERM", "SIGINT"]) {
|
|
@@ -42548,8 +43037,8 @@ var init_openai_responses_sse = __esm(() => {
|
|
|
42548
43037
|
|
|
42549
43038
|
// src/handlers/shared/token-tracker.ts
|
|
42550
43039
|
import { mkdirSync as mkdirSync10, writeFileSync as writeFileSync9 } from "fs";
|
|
42551
|
-
import { homedir as
|
|
42552
|
-
import { dirname as dirname8, join as
|
|
43040
|
+
import { homedir as homedir25 } from "os";
|
|
43041
|
+
import { dirname as dirname8, join as join25 } from "path";
|
|
42553
43042
|
function stripProviderPrefix(name) {
|
|
42554
43043
|
const at = name.indexOf("@");
|
|
42555
43044
|
return at === -1 ? name : name.slice(at + 1);
|
|
@@ -42573,7 +43062,8 @@ class TokenTracker {
|
|
|
42573
43062
|
this.config = config2;
|
|
42574
43063
|
}
|
|
42575
43064
|
recordToolUse(name) {
|
|
42576
|
-
const
|
|
43065
|
+
const trimmed2 = name.trim();
|
|
43066
|
+
const key = !trimmed2 ? "unknown" : TOOL_NAME_SHAPE.test(trimmed2) ? trimmed2 : "malformed";
|
|
42577
43067
|
this.toolCallsByName.set(key, (this.toolCallsByName.get(key) ?? 0) + 1);
|
|
42578
43068
|
}
|
|
42579
43069
|
getToolCallCount() {
|
|
@@ -42737,7 +43227,7 @@ class TokenTracker {
|
|
|
42737
43227
|
};
|
|
42738
43228
|
}
|
|
42739
43229
|
const override = process.env.CLAUDISH_TOKEN_FILE;
|
|
42740
|
-
const outPath = override ||
|
|
43230
|
+
const outPath = override || join25(homedir25(), ".claudish", `tokens-${this.port}.json`);
|
|
42741
43231
|
mkdirSync10(dirname8(outPath), { recursive: true });
|
|
42742
43232
|
writeFileSync9(outPath, JSON.stringify(data), "utf-8");
|
|
42743
43233
|
} catch (e) {
|
|
@@ -42746,6 +43236,7 @@ class TokenTracker {
|
|
|
42746
43236
|
}
|
|
42747
43237
|
}
|
|
42748
43238
|
var init_token_tracker = __esm(() => {
|
|
43239
|
+
init_tool_name_utils();
|
|
42749
43240
|
init_types2();
|
|
42750
43241
|
init_logger();
|
|
42751
43242
|
init_remote_provider_types();
|
|
@@ -42862,6 +43353,12 @@ class ComposedHandler {
|
|
|
42862
43353
|
}
|
|
42863
43354
|
this.middlewareManager.initialize().catch((err) => log(`[ComposedHandler:${this.bareModelName}] Middleware init error: ${err}`));
|
|
42864
43355
|
this.behaviorEngine = getBehaviorEngine();
|
|
43356
|
+
if (options.effortOverride) {
|
|
43357
|
+
for (const dialect of new Set([this.explicitAdapter, this.resolvedDialect, this.modelAdapter].filter(Boolean))) {
|
|
43358
|
+
dialect.setEffortOverride(options.effortOverride);
|
|
43359
|
+
}
|
|
43360
|
+
log(`[ComposedHandler] --effort ${options.effortOverride} pinned for ${this.targetModel} (catalog clamp skipped)`);
|
|
43361
|
+
}
|
|
42865
43362
|
this.tokenTracker = new TokenTracker(port, {
|
|
42866
43363
|
contextWindow: this.getModelContextWindow(),
|
|
42867
43364
|
providerName: provider.name,
|
|
@@ -43000,6 +43497,22 @@ class ComposedHandler {
|
|
|
43000
43497
|
this.modelAdapter.prepareRequest(requestPayload, claudeRequest);
|
|
43001
43498
|
}
|
|
43002
43499
|
const toolNameMap = adapter.getToolNameMap();
|
|
43500
|
+
if (this.options.proOnUltracode) {
|
|
43501
|
+
applyProInjection(requestPayload, {
|
|
43502
|
+
enabled: true,
|
|
43503
|
+
sessionId: extractSessionId2(claudeRequest?.metadata),
|
|
43504
|
+
bareModelName: this.bareModelName,
|
|
43505
|
+
provider: this.provider.name,
|
|
43506
|
+
targetModel: this.targetModel,
|
|
43507
|
+
outputConfig: claudeRequest?.output_config,
|
|
43508
|
+
registry: this.options.sessionEventRegistry,
|
|
43509
|
+
cachePath: this.options.catalogCachePath
|
|
43510
|
+
});
|
|
43511
|
+
}
|
|
43512
|
+
if (this.options.modelParams) {
|
|
43513
|
+
deepMergeParams(requestPayload, this.options.modelParams);
|
|
43514
|
+
log(`[ComposedHandler] Merged --model-params (${Object.keys(this.options.modelParams).join(", ")}) for ${this.targetModel}`);
|
|
43515
|
+
}
|
|
43003
43516
|
if (this.provider.refreshAuth) {
|
|
43004
43517
|
try {
|
|
43005
43518
|
await this.provider.refreshAuth();
|
|
@@ -43716,6 +44229,8 @@ var init_composed_handler = __esm(() => {
|
|
|
43716
44229
|
init_middleware();
|
|
43717
44230
|
init_openai();
|
|
43718
44231
|
init_vision_proxy();
|
|
44232
|
+
init_session_events();
|
|
44233
|
+
init_pro_injection();
|
|
43719
44234
|
init_stats();
|
|
43720
44235
|
init_telemetry();
|
|
43721
44236
|
init_transform();
|
|
@@ -43739,11 +44254,11 @@ var init_composed_handler = __esm(() => {
|
|
|
43739
44254
|
});
|
|
43740
44255
|
|
|
43741
44256
|
// src/providers/api-key-provenance.ts
|
|
43742
|
-
import { existsSync as
|
|
43743
|
-
import { homedir as
|
|
43744
|
-
import { join as
|
|
44257
|
+
import { existsSync as existsSync18, readFileSync as readFileSync17 } from "fs";
|
|
44258
|
+
import { homedir as homedir26 } from "os";
|
|
44259
|
+
import { join as join26, resolve as resolve2 } from "path";
|
|
43745
44260
|
function activeConfigPath() {
|
|
43746
|
-
return activeGlobalConfigFile(
|
|
44261
|
+
return activeGlobalConfigFile(join26(homedir26(), ".claudish", "config.json"));
|
|
43747
44262
|
}
|
|
43748
44263
|
function configLayerLabel() {
|
|
43749
44264
|
return getConfigFileOverride() ? activeConfigPath() : "~/.claudish/config.json";
|
|
@@ -43823,9 +44338,9 @@ function formatProvenanceLog(p) {
|
|
|
43823
44338
|
function readDotenvKey(envVars) {
|
|
43824
44339
|
try {
|
|
43825
44340
|
const dotenvPath = resolve2(".env");
|
|
43826
|
-
if (!
|
|
44341
|
+
if (!existsSync18(dotenvPath))
|
|
43827
44342
|
return null;
|
|
43828
|
-
const parsed = import_dotenv.parse(
|
|
44343
|
+
const parsed = import_dotenv.parse(readFileSync17(dotenvPath, "utf-8"));
|
|
43829
44344
|
for (const v of envVars) {
|
|
43830
44345
|
if (parsed[v])
|
|
43831
44346
|
return parsed[v];
|
|
@@ -43838,9 +44353,9 @@ function readDotenvKey(envVars) {
|
|
|
43838
44353
|
function readConfigKey(envVar) {
|
|
43839
44354
|
try {
|
|
43840
44355
|
const configPath = activeConfigPath();
|
|
43841
|
-
if (!
|
|
44356
|
+
if (!existsSync18(configPath))
|
|
43842
44357
|
return null;
|
|
43843
|
-
const cfg = JSON.parse(
|
|
44358
|
+
const cfg = JSON.parse(readFileSync17(configPath, "utf-8"));
|
|
43844
44359
|
return cfg.apiKeys?.[envVar] || null;
|
|
43845
44360
|
} catch {
|
|
43846
44361
|
return null;
|
|
@@ -48354,9 +48869,9 @@ __export(exports_session_discovery, {
|
|
|
48354
48869
|
transcriptPathFor: () => transcriptPathFor
|
|
48355
48870
|
});
|
|
48356
48871
|
import { execFile, execFileSync as execFileSync2 } from "child_process";
|
|
48357
|
-
import { closeSync as
|
|
48358
|
-
import { homedir as
|
|
48359
|
-
import { basename, join as
|
|
48872
|
+
import { closeSync as closeSync6, openSync as openSync6, readSync as readSync2, readdirSync as readdirSync4, realpathSync, statSync as statSync5 } from "fs";
|
|
48873
|
+
import { homedir as homedir27 } from "os";
|
|
48874
|
+
import { basename, join as join27 } from "path";
|
|
48360
48875
|
function slugForPath(absPath) {
|
|
48361
48876
|
return absPath.replace(/[/.]/g, "-");
|
|
48362
48877
|
}
|
|
@@ -48365,7 +48880,7 @@ function transcriptPathFor(cwd, sessionUuid) {
|
|
|
48365
48880
|
try {
|
|
48366
48881
|
real = realpathSync(cwd);
|
|
48367
48882
|
} catch {}
|
|
48368
|
-
return
|
|
48883
|
+
return join27(PROJECTS_DIR, slugForPath(real), `${sessionUuid}.jsonl`);
|
|
48369
48884
|
}
|
|
48370
48885
|
function isAgentSession(row) {
|
|
48371
48886
|
return row.entrypoint !== undefined && row.entrypoint !== "cli";
|
|
@@ -48406,24 +48921,24 @@ function getRepoContext(cwd = process.cwd()) {
|
|
|
48406
48921
|
}
|
|
48407
48922
|
function projectDirs() {
|
|
48408
48923
|
try {
|
|
48409
|
-
return
|
|
48924
|
+
return readdirSync4(PROJECTS_DIR, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name);
|
|
48410
48925
|
} catch {
|
|
48411
48926
|
return [];
|
|
48412
48927
|
}
|
|
48413
48928
|
}
|
|
48414
48929
|
function sessionsIn(dirName) {
|
|
48415
|
-
const dir =
|
|
48930
|
+
const dir = join27(PROJECTS_DIR, dirName);
|
|
48416
48931
|
let names;
|
|
48417
48932
|
try {
|
|
48418
|
-
names =
|
|
48933
|
+
names = readdirSync4(dir).filter((n) => n.endsWith(".jsonl"));
|
|
48419
48934
|
} catch {
|
|
48420
48935
|
return [];
|
|
48421
48936
|
}
|
|
48422
48937
|
const rows = [];
|
|
48423
48938
|
for (const n of names) {
|
|
48424
|
-
const file2 =
|
|
48939
|
+
const file2 = join27(dir, n);
|
|
48425
48940
|
try {
|
|
48426
|
-
const st =
|
|
48941
|
+
const st = statSync5(file2);
|
|
48427
48942
|
if (st.size === 0)
|
|
48428
48943
|
continue;
|
|
48429
48944
|
const row = {
|
|
@@ -48583,7 +49098,7 @@ function discoverWorktreeGroups(repo) {
|
|
|
48583
49098
|
g.activeNow = g.sessions.some((s) => isActive(s));
|
|
48584
49099
|
if (g.path) {
|
|
48585
49100
|
try {
|
|
48586
|
-
g.createdMs =
|
|
49101
|
+
g.createdMs = statSync5(g.path).birthtimeMs;
|
|
48587
49102
|
} catch {}
|
|
48588
49103
|
}
|
|
48589
49104
|
if (!g.createdMs && g.sessions.length > 0) {
|
|
@@ -48601,16 +49116,16 @@ function readChunk(file2, pos, len) {
|
|
|
48601
49116
|
return "";
|
|
48602
49117
|
let fd = null;
|
|
48603
49118
|
try {
|
|
48604
|
-
fd =
|
|
49119
|
+
fd = openSync6(file2, "r");
|
|
48605
49120
|
const buf = Buffer.allocUnsafe(len);
|
|
48606
|
-
const n =
|
|
49121
|
+
const n = readSync2(fd, buf, 0, len, pos);
|
|
48607
49122
|
return buf.subarray(0, n).toString("utf-8");
|
|
48608
49123
|
} catch {
|
|
48609
49124
|
return "";
|
|
48610
49125
|
} finally {
|
|
48611
49126
|
if (fd !== null) {
|
|
48612
49127
|
try {
|
|
48613
|
-
|
|
49128
|
+
closeSync6(fd);
|
|
48614
49129
|
} catch {}
|
|
48615
49130
|
}
|
|
48616
49131
|
}
|
|
@@ -48671,7 +49186,7 @@ function hydrateSession(row) {
|
|
|
48671
49186
|
row.hydrated = true;
|
|
48672
49187
|
if (isActive(row)) {
|
|
48673
49188
|
try {
|
|
48674
|
-
row.sizeBytes =
|
|
49189
|
+
row.sizeBytes = statSync5(row.file).size;
|
|
48675
49190
|
} catch {}
|
|
48676
49191
|
}
|
|
48677
49192
|
const head = parseRecords(readChunk(row.file, 0, Math.min(HEAD_BYTES, row.sizeBytes)), false);
|
|
@@ -48780,7 +49295,7 @@ function findLatestSessionId(cwd = process.cwd(), sinceMs = 0) {
|
|
|
48780
49295
|
}
|
|
48781
49296
|
var ENTRYPOINT_BYTES = 8192, PROJECTS_DIR, ACTIVE_WINDOW_MS = 120000, HEAD_BYTES, TAIL_BYTES, HARNESS_ENVELOPES, DEEP_TAIL_BYTES, RECENT_AI_TURNS = 5, RECENT_USER_TURNS = 1;
|
|
48782
49297
|
var init_session_discovery = __esm(() => {
|
|
48783
|
-
PROJECTS_DIR =
|
|
49298
|
+
PROJECTS_DIR = join27(homedir27(), ".claude", "projects");
|
|
48784
49299
|
HEAD_BYTES = 64 * 1024;
|
|
48785
49300
|
TAIL_BYTES = 128 * 1024;
|
|
48786
49301
|
HARNESS_ENVELOPES = [
|
|
@@ -48805,19 +49320,19 @@ function resolveClaudishSpawn(env = process.env) {
|
|
|
48805
49320
|
var CLAUDISH_BIN_ENV = "CLAUDISH_BIN";
|
|
48806
49321
|
|
|
48807
49322
|
// src/team-stats.ts
|
|
48808
|
-
import { existsSync as
|
|
48809
|
-
import { join as
|
|
49323
|
+
import { existsSync as existsSync19, readFileSync as readFileSync18, writeFileSync as writeFileSync10 } from "fs";
|
|
49324
|
+
import { join as join28 } from "path";
|
|
48810
49325
|
function statsDir(sessionPath) {
|
|
48811
|
-
return
|
|
49326
|
+
return join28(sessionPath, "stats");
|
|
48812
49327
|
}
|
|
48813
49328
|
function tokenFileFor(sessionPath, anonId) {
|
|
48814
|
-
return
|
|
49329
|
+
return join28(statsDir(sessionPath), `${anonId}.json`);
|
|
48815
49330
|
}
|
|
48816
49331
|
function readTokenStatsAt(path) {
|
|
48817
|
-
if (!
|
|
49332
|
+
if (!existsSync19(path))
|
|
48818
49333
|
return null;
|
|
48819
49334
|
try {
|
|
48820
|
-
return JSON.parse(
|
|
49335
|
+
return JSON.parse(readFileSync18(path, "utf-8"));
|
|
48821
49336
|
} catch {
|
|
48822
49337
|
return null;
|
|
48823
49338
|
}
|
|
@@ -48968,7 +49483,7 @@ ${segs.join(" \xB7 ")}`;
|
|
|
48968
49483
|
}
|
|
48969
49484
|
function writeStatusFile(sessionPath, manifest, status, opts) {
|
|
48970
49485
|
try {
|
|
48971
|
-
writeFileSync10(
|
|
49486
|
+
writeFileSync10(join28(sessionPath, "status.txt"), `${renderTeamStats(sessionPath, manifest, status, opts)}
|
|
48972
49487
|
`, "utf-8");
|
|
48973
49488
|
} catch {}
|
|
48974
49489
|
}
|
|
@@ -49000,13 +49515,13 @@ __export(exports_team_orchestrator, {
|
|
|
49000
49515
|
import { spawn as spawn2 } from "child_process";
|
|
49001
49516
|
import {
|
|
49002
49517
|
createWriteStream,
|
|
49003
|
-
existsSync as
|
|
49518
|
+
existsSync as existsSync20,
|
|
49004
49519
|
mkdirSync as mkdirSync11,
|
|
49005
|
-
readFileSync as
|
|
49006
|
-
readdirSync as
|
|
49520
|
+
readFileSync as readFileSync19,
|
|
49521
|
+
readdirSync as readdirSync5,
|
|
49007
49522
|
writeFileSync as writeFileSync11
|
|
49008
49523
|
} from "fs";
|
|
49009
|
-
import { join as
|
|
49524
|
+
import { join as join29, resolve as resolve3 } from "path";
|
|
49010
49525
|
function resolveCaptureMode(explicit, env = process.env) {
|
|
49011
49526
|
if (explicit)
|
|
49012
49527
|
return explicit;
|
|
@@ -49095,14 +49610,14 @@ function setupSession(sessionPath, models, input) {
|
|
|
49095
49610
|
if (models.length === 0) {
|
|
49096
49611
|
throw new Error("At least one model is required");
|
|
49097
49612
|
}
|
|
49098
|
-
if (
|
|
49613
|
+
if (existsSync20(join29(sessionPath, "manifest.json"))) {
|
|
49099
49614
|
throw new Error(`Session already exists at ${sessionPath}. Use a new directory path or delete the existing session first.`);
|
|
49100
49615
|
}
|
|
49101
|
-
mkdirSync11(
|
|
49102
|
-
mkdirSync11(
|
|
49616
|
+
mkdirSync11(join29(sessionPath, "work"), { recursive: true });
|
|
49617
|
+
mkdirSync11(join29(sessionPath, "errors"), { recursive: true });
|
|
49103
49618
|
if (input !== undefined) {
|
|
49104
|
-
writeFileSync11(
|
|
49105
|
-
} else if (!
|
|
49619
|
+
writeFileSync11(join29(sessionPath, "input.md"), input, "utf-8");
|
|
49620
|
+
} else if (!existsSync20(join29(sessionPath, "input.md"))) {
|
|
49106
49621
|
throw new Error(`No input.md found at ${sessionPath} and no input provided`);
|
|
49107
49622
|
}
|
|
49108
49623
|
const ids = models.map((_, i) => String(i + 1).padStart(2, "0"));
|
|
@@ -49119,9 +49634,9 @@ function setupSession(sessionPath, models, input) {
|
|
|
49119
49634
|
model: models[i],
|
|
49120
49635
|
assignedAt: now2
|
|
49121
49636
|
};
|
|
49122
|
-
mkdirSync11(
|
|
49637
|
+
mkdirSync11(join29(sessionPath, "work", anonId), { recursive: true });
|
|
49123
49638
|
}
|
|
49124
|
-
writeFileSync11(
|
|
49639
|
+
writeFileSync11(join29(sessionPath, "manifest.json"), JSON.stringify(manifest, null, 2), "utf-8");
|
|
49125
49640
|
const status = {
|
|
49126
49641
|
startedAt: now2,
|
|
49127
49642
|
models: Object.fromEntries(Object.keys(manifest.models).map((id) => [
|
|
@@ -49135,7 +49650,7 @@ function setupSession(sessionPath, models, input) {
|
|
|
49135
49650
|
}
|
|
49136
49651
|
]))
|
|
49137
49652
|
};
|
|
49138
|
-
writeFileSync11(
|
|
49653
|
+
writeFileSync11(join29(sessionPath, "status.json"), JSON.stringify(status, null, 2), "utf-8");
|
|
49139
49654
|
return manifest;
|
|
49140
49655
|
}
|
|
49141
49656
|
function assertValidRequirePattern(pattern) {
|
|
@@ -49152,7 +49667,7 @@ function readFullOutputIfNeeded(opts) {
|
|
|
49152
49667
|
if (crashed || !requirePattern || outputSize <= STDOUT_TAIL_LIMIT)
|
|
49153
49668
|
return;
|
|
49154
49669
|
try {
|
|
49155
|
-
return
|
|
49670
|
+
return readFileSync19(outputPath, "utf-8");
|
|
49156
49671
|
} catch {
|
|
49157
49672
|
return;
|
|
49158
49673
|
}
|
|
@@ -49160,12 +49675,12 @@ function readFullOutputIfNeeded(opts) {
|
|
|
49160
49675
|
async function runModels(sessionPath, opts = {}) {
|
|
49161
49676
|
const timeoutMs = (opts.timeout ?? 300) * 1000;
|
|
49162
49677
|
assertValidRequirePattern(opts.requirePattern);
|
|
49163
|
-
const manifest = JSON.parse(
|
|
49164
|
-
const statusPath =
|
|
49165
|
-
const inputPath =
|
|
49166
|
-
const inputContent =
|
|
49678
|
+
const manifest = JSON.parse(readFileSync19(join29(sessionPath, "manifest.json"), "utf-8"));
|
|
49679
|
+
const statusPath = join29(sessionPath, "status.json");
|
|
49680
|
+
const inputPath = join29(sessionPath, "input.md");
|
|
49681
|
+
const inputContent = readFileSync19(inputPath, "utf-8");
|
|
49167
49682
|
const spawnPlan = await (opts.spawnPlanner ?? prehydrateCredentialsForSpawn)(Object.values(manifest.models).map((m) => m.model));
|
|
49168
|
-
const statusCache = JSON.parse(
|
|
49683
|
+
const statusCache = JSON.parse(readFileSync19(statusPath, "utf-8"));
|
|
49169
49684
|
function updateModelStatus(id, update) {
|
|
49170
49685
|
statusCache.models[id] = { ...statusCache.models[id], ...update };
|
|
49171
49686
|
writeFileSync11(statusPath, JSON.stringify(statusCache, null, 2), "utf-8");
|
|
@@ -49213,8 +49728,8 @@ async function runModels(sessionPath, opts = {}) {
|
|
|
49213
49728
|
process.on("SIGINT", sigintHandler);
|
|
49214
49729
|
const completionPromises = [];
|
|
49215
49730
|
for (const [anonId, entry] of Object.entries(manifest.models)) {
|
|
49216
|
-
const outputPath =
|
|
49217
|
-
const errorLogPath =
|
|
49731
|
+
const outputPath = join29(sessionPath, `response-${anonId}.md`);
|
|
49732
|
+
const errorLogPath = join29(sessionPath, "errors", `${anonId}.log`);
|
|
49218
49733
|
const spawnModel = spawnPlan.pinned.get(entry.model) ?? entry.model;
|
|
49219
49734
|
const args = [
|
|
49220
49735
|
"--model",
|
|
@@ -49440,7 +49955,7 @@ async function runModels(sessionPath, opts = {}) {
|
|
|
49440
49955
|
opts.onStatusChange?.(id, statusCache.models[id]);
|
|
49441
49956
|
const stopped = await terminateChildTree(proc);
|
|
49442
49957
|
if (!stopped) {
|
|
49443
|
-
persistErrorLog(rt?.errorLogPath ??
|
|
49958
|
+
persistErrorLog(rt?.errorLogPath ?? join29(sessionPath, "errors", `${id}.log`), "TIMEOUT: child survived SIGKILL \u2014 it may still be running and billing", stderr, stdoutTail);
|
|
49444
49959
|
}
|
|
49445
49960
|
};
|
|
49446
49961
|
const allDone = Promise.all(completionPromises);
|
|
@@ -49492,30 +50007,30 @@ async function runModels(sessionPath, opts = {}) {
|
|
|
49492
50007
|
return statusCache;
|
|
49493
50008
|
}
|
|
49494
50009
|
async function judgeResponses(sessionPath, opts = {}) {
|
|
49495
|
-
const responseFiles =
|
|
50010
|
+
const responseFiles = readdirSync5(sessionPath).filter((f) => f.startsWith("response-") && f.endsWith(".md")).sort();
|
|
49496
50011
|
if (responseFiles.length < 2) {
|
|
49497
50012
|
throw new Error(`Need at least 2 responses to judge, found ${responseFiles.length}`);
|
|
49498
50013
|
}
|
|
49499
50014
|
const responses = {};
|
|
49500
50015
|
for (const file2 of responseFiles) {
|
|
49501
50016
|
const id = file2.replace(/^response-/, "").replace(/\.md$/, "");
|
|
49502
|
-
responses[id] =
|
|
50017
|
+
responses[id] = readFileSync19(join29(sessionPath, file2), "utf-8");
|
|
49503
50018
|
}
|
|
49504
|
-
const input =
|
|
50019
|
+
const input = readFileSync19(join29(sessionPath, "input.md"), "utf-8");
|
|
49505
50020
|
const judgePrompt = buildJudgePrompt(input, responses);
|
|
49506
|
-
writeFileSync11(
|
|
50021
|
+
writeFileSync11(join29(sessionPath, "judge-prompt.md"), judgePrompt, "utf-8");
|
|
49507
50022
|
const judgeModels = opts.judges ?? getDefaultJudgeModels(sessionPath);
|
|
49508
|
-
const judgePath =
|
|
50023
|
+
const judgePath = join29(sessionPath, "judging");
|
|
49509
50024
|
mkdirSync11(judgePath, { recursive: true });
|
|
49510
50025
|
setupSession(judgePath, judgeModels, judgePrompt);
|
|
49511
50026
|
await runModels(judgePath, { claudeFlags: opts.claudeFlags });
|
|
49512
50027
|
const votes = parseJudgeVotes(judgePath, Object.keys(responses));
|
|
49513
50028
|
const verdict = aggregateVerdict(votes, Object.keys(responses));
|
|
49514
|
-
writeFileSync11(
|
|
50029
|
+
writeFileSync11(join29(sessionPath, "verdict.md"), formatVerdict(verdict, sessionPath), "utf-8");
|
|
49515
50030
|
return verdict;
|
|
49516
50031
|
}
|
|
49517
50032
|
function getStatus(sessionPath) {
|
|
49518
|
-
return JSON.parse(
|
|
50033
|
+
return JSON.parse(readFileSync19(join29(sessionPath, "status.json"), "utf-8"));
|
|
49519
50034
|
}
|
|
49520
50035
|
function fisherYatesShuffle(arr) {
|
|
49521
50036
|
for (let i = arr.length - 1;i > 0; i--) {
|
|
@@ -49525,7 +50040,7 @@ function fisherYatesShuffle(arr) {
|
|
|
49525
50040
|
return arr;
|
|
49526
50041
|
}
|
|
49527
50042
|
function getDefaultJudgeModels(sessionPath) {
|
|
49528
|
-
const manifest = JSON.parse(
|
|
50043
|
+
const manifest = JSON.parse(readFileSync19(join29(sessionPath, "manifest.json"), "utf-8"));
|
|
49529
50044
|
return Object.values(manifest.models).map((e) => e.model);
|
|
49530
50045
|
}
|
|
49531
50046
|
function buildJudgePrompt(input, responses) {
|
|
@@ -49583,12 +50098,12 @@ function buildJudgePrompt(input, responses) {
|
|
|
49583
50098
|
}
|
|
49584
50099
|
function parseJudgeVotes(judgePath, responseIds) {
|
|
49585
50100
|
const votes = [];
|
|
49586
|
-
const responseFiles =
|
|
50101
|
+
const responseFiles = readdirSync5(judgePath).filter((f) => f.startsWith("response-") && f.endsWith(".md")).sort();
|
|
49587
50102
|
for (const file2 of responseFiles) {
|
|
49588
50103
|
const judgeId = file2.replace(/^response-/, "").replace(/\.md$/, "");
|
|
49589
50104
|
let content;
|
|
49590
50105
|
try {
|
|
49591
|
-
content =
|
|
50106
|
+
content = readFileSync19(join29(judgePath, file2), "utf-8");
|
|
49592
50107
|
} catch {
|
|
49593
50108
|
continue;
|
|
49594
50109
|
}
|
|
@@ -49640,7 +50155,7 @@ function aggregateVerdict(votes, responseIds) {
|
|
|
49640
50155
|
function formatVerdict(verdict, sessionPath) {
|
|
49641
50156
|
let manifest = null;
|
|
49642
50157
|
try {
|
|
49643
|
-
manifest = JSON.parse(
|
|
50158
|
+
manifest = JSON.parse(readFileSync19(join29(sessionPath, "manifest.json"), "utf-8"));
|
|
49644
50159
|
} catch {}
|
|
49645
50160
|
let output = `# Team Verdict
|
|
49646
50161
|
|
|
@@ -49691,17 +50206,17 @@ import { spawn as spawn3 } from "child_process";
|
|
|
49691
50206
|
import { randomUUID as randomUUID4 } from "crypto";
|
|
49692
50207
|
import {
|
|
49693
50208
|
appendFileSync as appendFileSync6,
|
|
49694
|
-
closeSync as
|
|
50209
|
+
closeSync as closeSync7,
|
|
49695
50210
|
createWriteStream as createWriteStream2,
|
|
49696
50211
|
mkdirSync as mkdirSync12,
|
|
49697
|
-
openSync as
|
|
49698
|
-
readFileSync as
|
|
49699
|
-
readSync as
|
|
49700
|
-
statSync as
|
|
50212
|
+
openSync as openSync7,
|
|
50213
|
+
readFileSync as readFileSync20,
|
|
50214
|
+
readSync as readSync3,
|
|
50215
|
+
statSync as statSync6,
|
|
49701
50216
|
writeFileSync as writeFileSync12
|
|
49702
50217
|
} from "fs";
|
|
49703
|
-
import { homedir as
|
|
49704
|
-
import { join as
|
|
50218
|
+
import { homedir as homedir28 } from "os";
|
|
50219
|
+
import { join as join30, resolve as resolve4, sep } from "path";
|
|
49705
50220
|
import { StringDecoder } from "string_decoder";
|
|
49706
50221
|
function buildChannelSpawnArgs(opts) {
|
|
49707
50222
|
return [
|
|
@@ -49739,21 +50254,21 @@ function decodeChunk(decoder, chunk) {
|
|
|
49739
50254
|
function readTailText(path, maxBytes) {
|
|
49740
50255
|
let fd = null;
|
|
49741
50256
|
try {
|
|
49742
|
-
const size =
|
|
50257
|
+
const size = statSync6(path).size;
|
|
49743
50258
|
if (size === 0)
|
|
49744
50259
|
return { text: "", truncated: false };
|
|
49745
50260
|
const start = Math.max(0, size - maxBytes);
|
|
49746
50261
|
const length = size - start;
|
|
49747
50262
|
const buf = Buffer.alloc(length);
|
|
49748
|
-
fd =
|
|
49749
|
-
|
|
50263
|
+
fd = openSync7(path, "r");
|
|
50264
|
+
readSync3(fd, buf, 0, length, start);
|
|
49750
50265
|
return { text: buf.toString("utf-8"), truncated: start > 0 };
|
|
49751
50266
|
} catch {
|
|
49752
50267
|
return null;
|
|
49753
50268
|
} finally {
|
|
49754
50269
|
if (fd !== null) {
|
|
49755
50270
|
try {
|
|
49756
|
-
|
|
50271
|
+
closeSync7(fd);
|
|
49757
50272
|
} catch {}
|
|
49758
50273
|
}
|
|
49759
50274
|
}
|
|
@@ -49770,7 +50285,7 @@ function readTailLines(path, maxBytes) {
|
|
|
49770
50285
|
}
|
|
49771
50286
|
function fileSize(path) {
|
|
49772
50287
|
try {
|
|
49773
|
-
return
|
|
50288
|
+
return statSync6(path).size;
|
|
49774
50289
|
} catch {
|
|
49775
50290
|
return 0;
|
|
49776
50291
|
}
|
|
@@ -49779,7 +50294,7 @@ function readJsonObject(path, maxBytes) {
|
|
|
49779
50294
|
try {
|
|
49780
50295
|
if (fileSize(path) > maxBytes)
|
|
49781
50296
|
return null;
|
|
49782
|
-
const parsed = JSON.parse(
|
|
50297
|
+
const parsed = JSON.parse(readFileSync20(path, "utf-8"));
|
|
49783
50298
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
|
|
49784
50299
|
return null;
|
|
49785
50300
|
return parsed;
|
|
@@ -49795,7 +50310,7 @@ function dropLeadingFragment(tail) {
|
|
|
49795
50310
|
return firstBreak === -1 ? tail.text : tail.text.slice(firstBreak + 1);
|
|
49796
50311
|
}
|
|
49797
50312
|
function diskAccounting(sessionDir) {
|
|
49798
|
-
const stats = readTokenStatsAt(
|
|
50313
|
+
const stats = readTokenStatsAt(join30(sessionDir, "tokens.json"));
|
|
49799
50314
|
return {
|
|
49800
50315
|
tokensUsed: (stats?.total_tokens ?? 0) || (stats?.input_tokens ?? 0) + (stats?.output_tokens ?? 0),
|
|
49801
50316
|
costUsd: stats?.total_cost ?? 0,
|
|
@@ -49835,7 +50350,7 @@ class SessionManager {
|
|
|
49835
50350
|
this.maxSessions = options?.maxSessions ?? DEFAULT_MAX_SESSIONS;
|
|
49836
50351
|
this.scrollbackCapacity = options?.scrollbackCapacity ?? DEFAULT_SCROLLBACK;
|
|
49837
50352
|
this.terminalRetentionMs = options?.terminalRetentionMs ?? TERMINAL_RETENTION_MS;
|
|
49838
|
-
this.sessionsDir = options?.sessionsDir ?? process.env.CLAUDISH_SESSIONS_DIR ??
|
|
50353
|
+
this.sessionsDir = options?.sessionsDir ?? process.env.CLAUDISH_SESSIONS_DIR ?? join30(homedir28(), ".claudish", "sessions");
|
|
49839
50354
|
this.stallSeconds = options?.stallSeconds;
|
|
49840
50355
|
this.onStateChange = options?.onStateChange;
|
|
49841
50356
|
}
|
|
@@ -49848,19 +50363,19 @@ class SessionManager {
|
|
|
49848
50363
|
const claudeSessionId = randomUUID4();
|
|
49849
50364
|
const timeout = Math.min(opts.timeoutSeconds ?? DEFAULT_TIMEOUT, MAX_TIMEOUT);
|
|
49850
50365
|
const startedAt = new Date().toISOString();
|
|
49851
|
-
const sessionDir =
|
|
50366
|
+
const sessionDir = join30(this.sessionsDir, sessionId2);
|
|
49852
50367
|
mkdirSync12(sessionDir, { recursive: true });
|
|
49853
50368
|
if (opts.prompt) {
|
|
49854
|
-
writeFileSync12(
|
|
50369
|
+
writeFileSync12(join30(sessionDir, "prompt.md"), opts.prompt, "utf-8");
|
|
49855
50370
|
}
|
|
49856
50371
|
const args = buildChannelSpawnArgs({
|
|
49857
50372
|
model: opts.spawnModel ?? opts.model,
|
|
49858
50373
|
claudeSessionId,
|
|
49859
50374
|
claudishFlags: opts.claudishFlags
|
|
49860
50375
|
});
|
|
49861
|
-
const tokenFile =
|
|
49862
|
-
const eventLogPath =
|
|
49863
|
-
const upstreamErrorLogPath =
|
|
50376
|
+
const tokenFile = join30(sessionDir, "tokens.json");
|
|
50377
|
+
const eventLogPath = join30(sessionDir, "events.jsonl");
|
|
50378
|
+
const upstreamErrorLogPath = join30(sessionDir, "upstream-errors.jsonl");
|
|
49864
50379
|
const cwd = opts.cwd ?? process.cwd();
|
|
49865
50380
|
const spawnTarget = resolveClaudishSpawn();
|
|
49866
50381
|
const proc = spawn3(spawnTarget.command, [...spawnTarget.prefixArgs, ...args], {
|
|
@@ -49875,7 +50390,7 @@ class SessionManager {
|
|
|
49875
50390
|
}
|
|
49876
50391
|
});
|
|
49877
50392
|
const scrollback = new ScrollbackBuffer(this.scrollbackCapacity);
|
|
49878
|
-
const outputLogStream = createWriteStream2(
|
|
50393
|
+
const outputLogStream = createWriteStream2(join30(sessionDir, "output.log"));
|
|
49879
50394
|
const entry = {
|
|
49880
50395
|
info: {
|
|
49881
50396
|
sessionId: sessionId2,
|
|
@@ -50159,7 +50674,7 @@ class SessionManager {
|
|
|
50159
50674
|
return null;
|
|
50160
50675
|
const root = resolve4(this.sessionsDir);
|
|
50161
50676
|
const dir = resolve4(root, sessionId2);
|
|
50162
|
-
if (dir !==
|
|
50677
|
+
if (dir !== join30(root, sessionId2))
|
|
50163
50678
|
return null;
|
|
50164
50679
|
if (!dir.startsWith(root + sep))
|
|
50165
50680
|
return null;
|
|
@@ -50171,14 +50686,14 @@ class SessionManager {
|
|
|
50171
50686
|
return null;
|
|
50172
50687
|
let dirMtimeMs;
|
|
50173
50688
|
try {
|
|
50174
|
-
const stat2 =
|
|
50689
|
+
const stat2 = statSync6(sessionDir);
|
|
50175
50690
|
if (!stat2.isDirectory())
|
|
50176
50691
|
return null;
|
|
50177
50692
|
dirMtimeMs = stat2.mtimeMs;
|
|
50178
50693
|
} catch {
|
|
50179
50694
|
return null;
|
|
50180
50695
|
}
|
|
50181
|
-
const meta3 = readJsonObject(
|
|
50696
|
+
const meta3 = readJsonObject(join30(sessionDir, "meta.json"), META_READ_LIMIT);
|
|
50182
50697
|
const partial2 = meta3 === null;
|
|
50183
50698
|
const measured = diskAccounting(sessionDir);
|
|
50184
50699
|
const startedAt = metaString(meta3?.startedAt) ?? new Date(dirMtimeMs).toISOString();
|
|
@@ -50207,7 +50722,7 @@ class SessionManager {
|
|
|
50207
50722
|
};
|
|
50208
50723
|
}
|
|
50209
50724
|
diskOutput(record4, tailLines) {
|
|
50210
|
-
const tail = readTailText(
|
|
50725
|
+
const tail = readTailText(join30(record4.sessionDir, "output.log"), OUTPUT_TAIL_BYTES);
|
|
50211
50726
|
const buffer = new ScrollbackBuffer(this.scrollbackCapacity);
|
|
50212
50727
|
if (tail?.text)
|
|
50213
50728
|
buffer.append(dropLeadingFragment(tail));
|
|
@@ -50225,9 +50740,9 @@ class SessionManager {
|
|
|
50225
50740
|
}
|
|
50226
50741
|
diskDiagnostics(record4, limit) {
|
|
50227
50742
|
const { sessionDir, info } = record4;
|
|
50228
|
-
const eventLogPath =
|
|
50229
|
-
const upstreamErrorLogPath =
|
|
50230
|
-
const outputLogPath =
|
|
50743
|
+
const eventLogPath = join30(sessionDir, "events.jsonl");
|
|
50744
|
+
const upstreamErrorLogPath = join30(sessionDir, "upstream-errors.jsonl");
|
|
50745
|
+
const outputLogPath = join30(sessionDir, "output.log");
|
|
50231
50746
|
const events = readTailLines(eventLogPath, EVENT_TAIL_BYTES);
|
|
50232
50747
|
const outputTail = readTailText(outputLogPath, OUTPUT_TAIL_BYTES);
|
|
50233
50748
|
return {
|
|
@@ -50268,7 +50783,7 @@ class SessionManager {
|
|
|
50268
50783
|
};
|
|
50269
50784
|
}
|
|
50270
50785
|
diskStderrForDiagnostics(record4) {
|
|
50271
|
-
const tail = readTailText(
|
|
50786
|
+
const tail = readTailText(join30(record4.sessionDir, "stderr.log"), STDERR_READ_BYTES);
|
|
50272
50787
|
const raw = tail?.text ?? "";
|
|
50273
50788
|
const filtered = record4.info.status === "completed";
|
|
50274
50789
|
const source = filtered ? meaningfulStderr(raw) : raw;
|
|
@@ -50443,11 +50958,11 @@ ${STDERR_TRUNCATION_MARKER} ${STDERR_SIDE_LIMIT} bytes per end \u2026
|
|
|
50443
50958
|
entry.outputLogStream?.end();
|
|
50444
50959
|
entry.outputLogStream = null;
|
|
50445
50960
|
if (entry.stderr) {
|
|
50446
|
-
writeFileSync12(
|
|
50961
|
+
writeFileSync12(join30(entry.sessionDir, "stderr.log"), redactSecrets(entry.stderr), "utf-8");
|
|
50447
50962
|
}
|
|
50448
50963
|
this.refreshAccounting(entry);
|
|
50449
50964
|
entry.info.claudeSessionId = entry.reducer.claudeSessionId ?? entry.info.claudeSessionId;
|
|
50450
|
-
writeFileSync12(
|
|
50965
|
+
writeFileSync12(join30(entry.sessionDir, "meta.json"), JSON.stringify(entry.info, null, 2), "utf-8");
|
|
50451
50966
|
}
|
|
50452
50967
|
scheduleEviction(entry) {
|
|
50453
50968
|
if (entry.evictHandle)
|
|
@@ -50507,7 +51022,7 @@ ${STDERR_TRUNCATION_MARKER} ${STDERR_SIDE_LIMIT} bytes per end \u2026
|
|
|
50507
51022
|
return { state: "completed", content: "" };
|
|
50508
51023
|
}
|
|
50509
51024
|
refreshAccounting(entry) {
|
|
50510
|
-
const stats = readTokenStatsAt(
|
|
51025
|
+
const stats = readTokenStatsAt(join30(entry.sessionDir, "tokens.json"));
|
|
50511
51026
|
const fileTokens = (stats?.total_tokens ?? 0) || (stats?.input_tokens ?? 0) + (stats?.output_tokens ?? 0);
|
|
50512
51027
|
entry.info.tokensUsed = fileTokens || entry.reducer.tokens;
|
|
50513
51028
|
entry.info.costUsd = stats?.total_cost ?? 0;
|
|
@@ -50766,9 +51281,9 @@ function compareByReleaseDateDesc(a, b) {
|
|
|
50766
51281
|
}
|
|
50767
51282
|
|
|
50768
51283
|
// src/model-loader.ts
|
|
50769
|
-
import { existsSync as
|
|
50770
|
-
import { homedir as
|
|
50771
|
-
import { join as
|
|
51284
|
+
import { existsSync as existsSync21, mkdirSync as mkdirSync13, readFileSync as readFileSync21, writeFileSync as writeFileSync13 } from "fs";
|
|
51285
|
+
import { homedir as homedir29 } from "os";
|
|
51286
|
+
import { join as join31 } from "path";
|
|
50772
51287
|
function groupRecommendedModels(entries) {
|
|
50773
51288
|
const byId = new Map;
|
|
50774
51289
|
const categoryOrder = new Map;
|
|
@@ -50887,9 +51402,9 @@ async function getRecommendedModels(opts = {}) {
|
|
|
50887
51402
|
if (!forceRefresh && _cachedRecommendedModels) {
|
|
50888
51403
|
return _cachedRecommendedModels;
|
|
50889
51404
|
}
|
|
50890
|
-
if (!forceRefresh &&
|
|
51405
|
+
if (!forceRefresh && existsSync21(RECOMMENDED_MODELS_CACHE_PATH)) {
|
|
50891
51406
|
try {
|
|
50892
|
-
const cacheData = JSON.parse(
|
|
51407
|
+
const cacheData = JSON.parse(readFileSync21(RECOMMENDED_MODELS_CACHE_PATH, "utf-8"));
|
|
50893
51408
|
if (cacheData.models && cacheData.models.length > 0 && isFreshEnough(cacheData)) {
|
|
50894
51409
|
_cachedRecommendedModels = cacheData;
|
|
50895
51410
|
return cacheData;
|
|
@@ -50905,7 +51420,7 @@ async function getRecommendedModels(opts = {}) {
|
|
|
50905
51420
|
if (data.models && data.models.length > 0) {
|
|
50906
51421
|
_cachedRecommendedModels = data;
|
|
50907
51422
|
try {
|
|
50908
|
-
const cacheDir =
|
|
51423
|
+
const cacheDir = join31(homedir29(), ".claudish");
|
|
50909
51424
|
mkdirSync13(cacheDir, { recursive: true });
|
|
50910
51425
|
writeFileSync13(RECOMMENDED_MODELS_CACHE_PATH, JSON.stringify(data), "utf-8");
|
|
50911
51426
|
} catch {}
|
|
@@ -50918,9 +51433,9 @@ async function getRecommendedModels(opts = {}) {
|
|
|
50918
51433
|
function getRecommendedModelsSync() {
|
|
50919
51434
|
if (_cachedRecommendedModels)
|
|
50920
51435
|
return _cachedRecommendedModels;
|
|
50921
|
-
if (
|
|
51436
|
+
if (existsSync21(RECOMMENDED_MODELS_CACHE_PATH)) {
|
|
50922
51437
|
try {
|
|
50923
|
-
const cacheData = JSON.parse(
|
|
51438
|
+
const cacheData = JSON.parse(readFileSync21(RECOMMENDED_MODELS_CACHE_PATH, "utf-8"));
|
|
50924
51439
|
if (cacheData.models && cacheData.models.length > 0 && isFreshEnough(cacheData)) {
|
|
50925
51440
|
_cachedRecommendedModels = cacheData;
|
|
50926
51441
|
return cacheData;
|
|
@@ -51044,7 +51559,7 @@ var _cachedModelInfo = null, _cachedModelIds = null, _cachedRecommendedModels =
|
|
|
51044
51559
|
var init_model_loader = __esm(() => {
|
|
51045
51560
|
init_cache_ttl();
|
|
51046
51561
|
FIREBASE_RECOMMENDED_URL = `${FIREBASE_BASE_URL}?catalog=recommended`;
|
|
51047
|
-
RECOMMENDED_MODELS_CACHE_PATH =
|
|
51562
|
+
RECOMMENDED_MODELS_CACHE_PATH = join31(homedir29(), ".claudish", "recommended-models-cache.json");
|
|
51048
51563
|
FIREBASE_SLUG_TO_PROVIDER_NAME = {
|
|
51049
51564
|
openai: "openai",
|
|
51050
51565
|
google: "google",
|
|
@@ -54945,9 +55460,9 @@ var init_poe = __esm(() => {
|
|
|
54945
55460
|
});
|
|
54946
55461
|
|
|
54947
55462
|
// src/services/pricing-cache.ts
|
|
54948
|
-
import { existsSync as
|
|
54949
|
-
import { homedir as
|
|
54950
|
-
import { join as
|
|
55463
|
+
import { existsSync as existsSync22, readFileSync as readFileSync22, statSync as statSync7 } from "fs";
|
|
55464
|
+
import { homedir as homedir30 } from "os";
|
|
55465
|
+
import { join as join32 } from "path";
|
|
54951
55466
|
function prefixMatch(modelName) {
|
|
54952
55467
|
for (const [key, pricing] of pricingMap) {
|
|
54953
55468
|
if (modelName.startsWith(key))
|
|
@@ -54985,12 +55500,12 @@ async function warmPricingCache() {
|
|
|
54985
55500
|
}
|
|
54986
55501
|
function loadDiskCache() {
|
|
54987
55502
|
try {
|
|
54988
|
-
if (!
|
|
55503
|
+
if (!existsSync22(CACHE_FILE))
|
|
54989
55504
|
return false;
|
|
54990
|
-
const stat2 =
|
|
55505
|
+
const stat2 = statSync7(CACHE_FILE);
|
|
54991
55506
|
const age = Date.now() - stat2.mtimeMs;
|
|
54992
55507
|
const isFresh = age < CACHE_TTL_MS3;
|
|
54993
|
-
const raw2 =
|
|
55508
|
+
const raw2 = readFileSync22(CACHE_FILE, "utf-8");
|
|
54994
55509
|
const data = JSON.parse(raw2);
|
|
54995
55510
|
for (const [key, pricing] of Object.entries(data)) {
|
|
54996
55511
|
pricingMap.set(key, pricing);
|
|
@@ -55006,8 +55521,8 @@ var init_pricing_cache = __esm(() => {
|
|
|
55006
55521
|
init_logger();
|
|
55007
55522
|
init_catalog_query();
|
|
55008
55523
|
pricingMap = new Map;
|
|
55009
|
-
CACHE_DIR =
|
|
55010
|
-
CACHE_FILE =
|
|
55524
|
+
CACHE_DIR = join32(homedir30(), ".claudish");
|
|
55525
|
+
CACHE_FILE = join32(CACHE_DIR, "pricing-cache.json");
|
|
55011
55526
|
CACHE_TTL_MS3 = 24 * 60 * 60 * 1000;
|
|
55012
55527
|
});
|
|
55013
55528
|
|
|
@@ -55017,12 +55532,12 @@ __export(exports_proxy_server, {
|
|
|
55017
55532
|
createProxyServer: () => createProxyServer
|
|
55018
55533
|
});
|
|
55019
55534
|
import { appendFileSync as appendFileSync8, mkdirSync as mkdirSync14 } from "fs";
|
|
55020
|
-
import { join as
|
|
55535
|
+
import { join as join33 } from "path";
|
|
55021
55536
|
function maybeCaptureClassifierRequest(c, body) {
|
|
55022
55537
|
if (!process.env.CLAUDISH_CLASSIFIER_DEBUG)
|
|
55023
55538
|
return;
|
|
55024
55539
|
try {
|
|
55025
|
-
const dir =
|
|
55540
|
+
const dir = join33(process.cwd(), "logs");
|
|
55026
55541
|
if (!classifierCaptureDirReady) {
|
|
55027
55542
|
mkdirSync14(dir, { recursive: true });
|
|
55028
55543
|
classifierCaptureDirReady = true;
|
|
@@ -55047,7 +55562,7 @@ function maybeCaptureClassifierRequest(c, body) {
|
|
|
55047
55562
|
"x-api-key": c.req.header("x-api-key") ? "<present>" : null
|
|
55048
55563
|
}
|
|
55049
55564
|
};
|
|
55050
|
-
appendFileSync8(
|
|
55565
|
+
appendFileSync8(join33(dir, "classifier-capture.jsonl"), `${JSON.stringify(record4)}
|
|
55051
55566
|
`);
|
|
55052
55567
|
} catch {}
|
|
55053
55568
|
}
|
|
@@ -55070,6 +55585,11 @@ async function createProxyServer(port, _openrouterApiKey, model, monitorMode = f
|
|
|
55070
55585
|
log(`[Proxy] behavior hooks load skipped: ${err instanceof Error ? err.message : String(err)}`);
|
|
55071
55586
|
}
|
|
55072
55587
|
const nativeHandler = new NativeHandler(anthropicApiKey, options.advisorModels, options.advisorCollector);
|
|
55588
|
+
const requestShapingOpts = {
|
|
55589
|
+
effortOverride: isEffortLevel(options.effortOverride) ? options.effortOverride : undefined,
|
|
55590
|
+
modelParams: options.modelParams,
|
|
55591
|
+
proOnUltracode: options.proOnUltracode
|
|
55592
|
+
};
|
|
55073
55593
|
const openRouterHandlers = new Map;
|
|
55074
55594
|
const localProviderHandlers = new Map;
|
|
55075
55595
|
const remoteProviderHandlers = new Map;
|
|
@@ -55083,7 +55603,8 @@ async function createProxyServer(port, _openrouterApiKey, model, monitorMode = f
|
|
|
55083
55603
|
openRouterHandlers.set(modelId, new ComposedHandler(orProvider, modelId, modelId, port, {
|
|
55084
55604
|
adapter: orAdapter,
|
|
55085
55605
|
isInteractive: options.isInteractive,
|
|
55086
|
-
invocationMode
|
|
55606
|
+
invocationMode,
|
|
55607
|
+
...requestShapingOpts
|
|
55087
55608
|
}));
|
|
55088
55609
|
}
|
|
55089
55610
|
return openRouterHandlers.get(modelId);
|
|
@@ -55098,7 +55619,8 @@ async function createProxyServer(port, _openrouterApiKey, model, monitorMode = f
|
|
|
55098
55619
|
const poeTransport = new PoeProvider;
|
|
55099
55620
|
poeHandlers.set(modelId, new ComposedHandler(poeTransport, modelId, modelId, port, {
|
|
55100
55621
|
isInteractive: options.isInteractive,
|
|
55101
|
-
invocationMode
|
|
55622
|
+
invocationMode,
|
|
55623
|
+
...requestShapingOpts
|
|
55102
55624
|
}));
|
|
55103
55625
|
}
|
|
55104
55626
|
return poeHandlers.get(modelId);
|
|
@@ -55121,7 +55643,8 @@ async function createProxyServer(port, _openrouterApiKey, model, monitorMode = f
|
|
|
55121
55643
|
tokenStrategy: "local",
|
|
55122
55644
|
summarizeTools: options.summarizeTools,
|
|
55123
55645
|
isInteractive: options.isInteractive,
|
|
55124
|
-
invocationMode
|
|
55646
|
+
invocationMode,
|
|
55647
|
+
...requestShapingOpts
|
|
55125
55648
|
});
|
|
55126
55649
|
localProviderHandlers.set(targetModel, handler);
|
|
55127
55650
|
log(`[Proxy] Created local provider handler: ${resolved.provider.name}/${resolved.modelName}${resolved.concurrency !== undefined ? ` (concurrency: ${resolved.concurrency})` : ""}`);
|
|
@@ -55137,7 +55660,8 @@ async function createProxyServer(port, _openrouterApiKey, model, monitorMode = f
|
|
|
55137
55660
|
tokenStrategy: "local",
|
|
55138
55661
|
summarizeTools: options.summarizeTools,
|
|
55139
55662
|
isInteractive: options.isInteractive,
|
|
55140
|
-
invocationMode
|
|
55663
|
+
invocationMode,
|
|
55664
|
+
...requestShapingOpts
|
|
55141
55665
|
});
|
|
55142
55666
|
localProviderHandlers.set(targetModel, handler);
|
|
55143
55667
|
log(`[Proxy] Created URL-based local provider handler: ${urlParsed.baseUrl}/${urlParsed.modelName}`);
|
|
@@ -55192,7 +55716,7 @@ async function createProxyServer(port, _openrouterApiKey, model, monitorMode = f
|
|
|
55192
55716
|
apiKey,
|
|
55193
55717
|
targetModel,
|
|
55194
55718
|
port,
|
|
55195
|
-
sharedOpts: { isInteractive: options.isInteractive, invocationMode }
|
|
55719
|
+
sharedOpts: { isInteractive: options.isInteractive, invocationMode, ...requestShapingOpts }
|
|
55196
55720
|
});
|
|
55197
55721
|
if (!handler) {
|
|
55198
55722
|
return null;
|
|
@@ -55515,6 +56039,7 @@ var RoutingError, classifierCaptureDirReady = false;
|
|
|
55515
56039
|
var init_proxy_server = __esm(() => {
|
|
55516
56040
|
init_dist();
|
|
55517
56041
|
init_cors();
|
|
56042
|
+
init_base_api_format();
|
|
55518
56043
|
init_local_adapter();
|
|
55519
56044
|
init_openrouter_api_format();
|
|
55520
56045
|
init_authority();
|
|
@@ -55560,14 +56085,14 @@ __export(exports_mcp_server, {
|
|
|
55560
56085
|
runPromptViaProxy: () => runPromptViaProxy,
|
|
55561
56086
|
startMcpServer: () => startMcpServer
|
|
55562
56087
|
});
|
|
55563
|
-
import { existsSync as
|
|
55564
|
-
import { homedir as
|
|
55565
|
-
import { dirname as dirname9, join as
|
|
56088
|
+
import { existsSync as existsSync23, mkdirSync as mkdirSync15, readFileSync as readFileSync23, readdirSync as readdirSync6, writeFileSync as writeFileSync14 } from "fs";
|
|
56089
|
+
import { homedir as homedir31 } from "os";
|
|
56090
|
+
import { dirname as dirname9, join as join34, resolve as resolve5 } from "path";
|
|
55566
56091
|
import { fileURLToPath } from "url";
|
|
55567
56092
|
async function loadAllModels(forceRefresh = false) {
|
|
55568
|
-
if (!forceRefresh &&
|
|
56093
|
+
if (!forceRefresh && existsSync23(ALL_MODELS_CACHE_PATH2)) {
|
|
55569
56094
|
try {
|
|
55570
|
-
const cacheData = JSON.parse(
|
|
56095
|
+
const cacheData = JSON.parse(readFileSync23(ALL_MODELS_CACHE_PATH2, "utf-8"));
|
|
55571
56096
|
const lastUpdated = new Date(cacheData.lastUpdated);
|
|
55572
56097
|
const ageInDays = (Date.now() - lastUpdated.getTime()) / (1000 * 60 * 60 * 24);
|
|
55573
56098
|
if (ageInDays <= CACHE_MAX_AGE_DAYS) {
|
|
@@ -55585,8 +56110,8 @@ async function loadAllModels(forceRefresh = false) {
|
|
|
55585
56110
|
writeFileSync14(ALL_MODELS_CACHE_PATH2, JSON.stringify({ lastUpdated: new Date().toISOString(), models }), "utf-8");
|
|
55586
56111
|
return models;
|
|
55587
56112
|
} catch {
|
|
55588
|
-
if (
|
|
55589
|
-
const cacheData = JSON.parse(
|
|
56113
|
+
if (existsSync23(ALL_MODELS_CACHE_PATH2)) {
|
|
56114
|
+
const cacheData = JSON.parse(readFileSync23(ALL_MODELS_CACHE_PATH2, "utf-8"));
|
|
55590
56115
|
return cacheData.models || [];
|
|
55591
56116
|
}
|
|
55592
56117
|
return [];
|
|
@@ -56324,7 +56849,7 @@ Use with: run_prompt(model="${results[0].model.id}", prompt="your prompt")`;
|
|
|
56324
56849
|
let stderrFull = stderr_snippet || "";
|
|
56325
56850
|
if (error_log_path) {
|
|
56326
56851
|
try {
|
|
56327
|
-
stderrFull =
|
|
56852
|
+
stderrFull = readFileSync23(error_log_path, "utf-8");
|
|
56328
56853
|
} catch {}
|
|
56329
56854
|
}
|
|
56330
56855
|
const sessionData = {};
|
|
@@ -56332,26 +56857,26 @@ Use with: run_prompt(model="${results[0].model.id}", prompt="your prompt")`;
|
|
|
56332
56857
|
const sp = session_path;
|
|
56333
56858
|
for (const file2 of ["status.json", "manifest.json", "input.md"]) {
|
|
56334
56859
|
try {
|
|
56335
|
-
sessionData[file2] =
|
|
56860
|
+
sessionData[file2] = readFileSync23(join34(sp, file2), "utf-8");
|
|
56336
56861
|
} catch {}
|
|
56337
56862
|
}
|
|
56338
56863
|
try {
|
|
56339
|
-
const errorDir =
|
|
56340
|
-
if (
|
|
56341
|
-
for (const f of
|
|
56864
|
+
const errorDir = join34(sp, "errors");
|
|
56865
|
+
if (existsSync23(errorDir)) {
|
|
56866
|
+
for (const f of readdirSync6(errorDir)) {
|
|
56342
56867
|
if (f.endsWith(".log")) {
|
|
56343
56868
|
try {
|
|
56344
|
-
sessionData[`errors/${f}`] =
|
|
56869
|
+
sessionData[`errors/${f}`] = readFileSync23(join34(errorDir, f), "utf-8");
|
|
56345
56870
|
} catch {}
|
|
56346
56871
|
}
|
|
56347
56872
|
}
|
|
56348
56873
|
}
|
|
56349
56874
|
} catch {}
|
|
56350
56875
|
try {
|
|
56351
|
-
for (const f of
|
|
56876
|
+
for (const f of readdirSync6(sp)) {
|
|
56352
56877
|
if (f.startsWith("response-") && f.endsWith(".md")) {
|
|
56353
56878
|
try {
|
|
56354
|
-
const content =
|
|
56879
|
+
const content = readFileSync23(join34(sp, f), "utf-8");
|
|
56355
56880
|
sessionData[f] = content.slice(0, 200) + (content.length > 200 ? "... (truncated)" : "");
|
|
56356
56881
|
} catch {}
|
|
56357
56882
|
}
|
|
@@ -56360,9 +56885,9 @@ Use with: run_prompt(model="${results[0].model.id}", prompt="your prompt")`;
|
|
|
56360
56885
|
}
|
|
56361
56886
|
let version2 = "unknown";
|
|
56362
56887
|
try {
|
|
56363
|
-
const pkgPath =
|
|
56364
|
-
if (
|
|
56365
|
-
version2 = JSON.parse(
|
|
56888
|
+
const pkgPath = join34(__dirname2, "../package.json");
|
|
56889
|
+
if (existsSync23(pkgPath)) {
|
|
56890
|
+
version2 = JSON.parse(readFileSync23(pkgPath, "utf-8")).version;
|
|
56366
56891
|
}
|
|
56367
56892
|
} catch {}
|
|
56368
56893
|
const report = {
|
|
@@ -56827,8 +57352,8 @@ var init_mcp_server = __esm(() => {
|
|
|
56827
57352
|
import_dotenv2.config({ quiet: true });
|
|
56828
57353
|
__filename2 = fileURLToPath(import.meta.url);
|
|
56829
57354
|
__dirname2 = dirname9(__filename2);
|
|
56830
|
-
CLAUDISH_CACHE_DIR =
|
|
56831
|
-
ALL_MODELS_CACHE_PATH2 =
|
|
57355
|
+
CLAUDISH_CACHE_DIR = join34(homedir31(), ".claudish");
|
|
57356
|
+
ALL_MODELS_CACHE_PATH2 = join34(CLAUDISH_CACHE_DIR, "all-models.json");
|
|
56832
57357
|
NEXT_STEP = {
|
|
56833
57358
|
nonzero_exit: "read the evidence log, then retry or drop the model",
|
|
56834
57359
|
timeout: "raise `timeout`, or pick a faster model",
|
|
@@ -56855,7 +57380,7 @@ var exports_serve_command = {};
|
|
|
56855
57380
|
__export(exports_serve_command, {
|
|
56856
57381
|
serveCommand: () => serveCommand
|
|
56857
57382
|
});
|
|
56858
|
-
import { existsSync as
|
|
57383
|
+
import { existsSync as existsSync24, readFileSync as readFileSync24 } from "fs";
|
|
56859
57384
|
function parseServeArgs(args) {
|
|
56860
57385
|
const out = {};
|
|
56861
57386
|
for (let i = 0;i < args.length; i++) {
|
|
@@ -56874,12 +57399,12 @@ function parseServeArgs(args) {
|
|
|
56874
57399
|
return out;
|
|
56875
57400
|
}
|
|
56876
57401
|
function loadModelMap(path) {
|
|
56877
|
-
if (!
|
|
57402
|
+
if (!existsSync24(path)) {
|
|
56878
57403
|
throw new Error(`--models file not found: ${path}`);
|
|
56879
57404
|
}
|
|
56880
57405
|
let raw2;
|
|
56881
57406
|
try {
|
|
56882
|
-
raw2 =
|
|
57407
|
+
raw2 = readFileSync24(path, "utf-8");
|
|
56883
57408
|
} catch (e) {
|
|
56884
57409
|
throw new Error(`failed to read --models file ${path}: ${e instanceof Error ? e.message : String(e)}`);
|
|
56885
57410
|
}
|
|
@@ -57194,7 +57719,7 @@ var exports_behavior_command = {};
|
|
|
57194
57719
|
__export(exports_behavior_command, {
|
|
57195
57720
|
behaviorCommand: () => behaviorCommand
|
|
57196
57721
|
});
|
|
57197
|
-
import { existsSync as
|
|
57722
|
+
import { existsSync as existsSync25, readFileSync as readFileSync25, writeFileSync as writeFileSync15 } from "fs";
|
|
57198
57723
|
function severityColor(sev) {
|
|
57199
57724
|
if (sev === "fix")
|
|
57200
57725
|
return green(sev);
|
|
@@ -57292,8 +57817,8 @@ function setTelemetryEnabled(value) {
|
|
|
57292
57817
|
const path = getConfigPath();
|
|
57293
57818
|
let cfg = {};
|
|
57294
57819
|
try {
|
|
57295
|
-
if (
|
|
57296
|
-
const parsed = JSON.parse(
|
|
57820
|
+
if (existsSync25(path)) {
|
|
57821
|
+
const parsed = JSON.parse(readFileSync25(path, "utf-8"));
|
|
57297
57822
|
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
57298
57823
|
cfg = parsed;
|
|
57299
57824
|
}
|
|
@@ -57314,8 +57839,8 @@ function showTelemetry(action, json2) {
|
|
|
57314
57839
|
let pending = 0;
|
|
57315
57840
|
try {
|
|
57316
57841
|
const path = outboxPath();
|
|
57317
|
-
if (
|
|
57318
|
-
pending =
|
|
57842
|
+
if (existsSync25(path)) {
|
|
57843
|
+
pending = readFileSync25(path, "utf8").split(`
|
|
57319
57844
|
`).filter(Boolean).length;
|
|
57320
57845
|
}
|
|
57321
57846
|
} catch {}
|
|
@@ -57400,9 +57925,9 @@ __export(exports_team_grid, {
|
|
|
57400
57925
|
});
|
|
57401
57926
|
import { spawn as spawn4 } from "child_process";
|
|
57402
57927
|
import { execSync } from "child_process";
|
|
57403
|
-
import { existsSync as
|
|
57928
|
+
import { existsSync as existsSync26, readFileSync as readFileSync26, writeFileSync as writeFileSync16 } from "fs";
|
|
57404
57929
|
import { connect as netConnect } from "net";
|
|
57405
|
-
import { dirname as dirname10, join as
|
|
57930
|
+
import { dirname as dirname10, join as join35 } from "path";
|
|
57406
57931
|
import { setTimeout as wait } from "timers/promises";
|
|
57407
57932
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
57408
57933
|
function resolveRouteInfo(modelId) {
|
|
@@ -57496,18 +58021,18 @@ function buildPaneHeader(model, prompt, bg) {
|
|
|
57496
58021
|
function findMagmuxBinary() {
|
|
57497
58022
|
const thisFile = fileURLToPath2(import.meta.url);
|
|
57498
58023
|
const thisDir = dirname10(thisFile);
|
|
57499
|
-
const pkgRoot =
|
|
58024
|
+
const pkgRoot = join35(thisDir, "..");
|
|
57500
58025
|
const platform2 = process.platform;
|
|
57501
58026
|
const arch = process.arch;
|
|
57502
|
-
const bundledMagmux =
|
|
57503
|
-
if (
|
|
58027
|
+
const bundledMagmux = join35(pkgRoot, "native", `magmux-${platform2}-${arch}`);
|
|
58028
|
+
if (existsSync26(bundledMagmux))
|
|
57504
58029
|
return bundledMagmux;
|
|
57505
58030
|
try {
|
|
57506
58031
|
const pkgName = `@claudish/magmux-${platform2}-${arch}`;
|
|
57507
58032
|
let searchDir = pkgRoot;
|
|
57508
58033
|
for (let i = 0;i < 5; i++) {
|
|
57509
|
-
const candidate =
|
|
57510
|
-
if (
|
|
58034
|
+
const candidate = join35(searchDir, "node_modules", pkgName, "bin", "magmux");
|
|
58035
|
+
if (existsSync26(candidate))
|
|
57511
58036
|
return candidate;
|
|
57512
58037
|
const parent = dirname10(searchDir);
|
|
57513
58038
|
if (parent === searchDir)
|
|
@@ -57531,7 +58056,7 @@ function withoutControlPanes(evt) {
|
|
|
57531
58056
|
async function subscribeToMagmux(sockPath, onEvent) {
|
|
57532
58057
|
let client = null;
|
|
57533
58058
|
for (let attempt = 0;attempt < 40; attempt++) {
|
|
57534
|
-
if (
|
|
58059
|
+
if (existsSync26(sockPath)) {
|
|
57535
58060
|
try {
|
|
57536
58061
|
client = await new Promise((resolve6, reject) => {
|
|
57537
58062
|
const s = netConnect(sockPath);
|
|
@@ -57618,9 +58143,9 @@ async function runWithGrid(sessionPath, models, input, opts) {
|
|
|
57618
58143
|
const keep = opts?.keep ?? false;
|
|
57619
58144
|
const manifest = setupSession(sessionPath, models, input);
|
|
57620
58145
|
const startedAt = new Date().toISOString();
|
|
57621
|
-
const gridfilePath =
|
|
57622
|
-
const prompt =
|
|
57623
|
-
const rawPrompt =
|
|
58146
|
+
const gridfilePath = join35(sessionPath, "gridfile.txt");
|
|
58147
|
+
const prompt = readFileSync26(join35(sessionPath, "input.md"), "utf-8").replace(/'/g, "'\\''").replace(/\n/g, " ");
|
|
58148
|
+
const rawPrompt = readFileSync26(join35(sessionPath, "input.md"), "utf-8");
|
|
57624
58149
|
const usedBannerColors = new Set;
|
|
57625
58150
|
const gridLines = Object.entries(manifest.models).map(([anonId]) => {
|
|
57626
58151
|
const model = manifest.models[anonId].model;
|
|
@@ -57651,7 +58176,7 @@ async function runWithGrid(sessionPath, models, input, opts) {
|
|
|
57651
58176
|
});
|
|
57652
58177
|
const [{ results }] = await Promise.all([subscription, procExit]);
|
|
57653
58178
|
const status = buildTeamStatus(manifest, startedAt, results?.panes ?? null);
|
|
57654
|
-
const statusPath =
|
|
58179
|
+
const statusPath = join35(sessionPath, "status.json");
|
|
57655
58180
|
writeFileSync16(statusPath, JSON.stringify(status, null, 2), "utf-8");
|
|
57656
58181
|
return status;
|
|
57657
58182
|
}
|
|
@@ -57676,8 +58201,8 @@ var exports_team_cli = {};
|
|
|
57676
58201
|
__export(exports_team_cli, {
|
|
57677
58202
|
teamCommand: () => teamCommand
|
|
57678
58203
|
});
|
|
57679
|
-
import { readFileSync as
|
|
57680
|
-
import { join as
|
|
58204
|
+
import { readFileSync as readFileSync27 } from "fs";
|
|
58205
|
+
import { join as join36 } from "path";
|
|
57681
58206
|
function getFlag(args, flag) {
|
|
57682
58207
|
const idx = args.indexOf(flag);
|
|
57683
58208
|
if (idx === -1 || idx + 1 >= args.length)
|
|
@@ -57800,7 +58325,7 @@ async function teamCommand(args) {
|
|
|
57800
58325
|
}
|
|
57801
58326
|
case "judge": {
|
|
57802
58327
|
await judgeResponses(sessionPath, { judges });
|
|
57803
|
-
console.log(
|
|
58328
|
+
console.log(readFileSync27(join36(sessionPath, "verdict.md"), "utf-8"));
|
|
57804
58329
|
break;
|
|
57805
58330
|
}
|
|
57806
58331
|
case "run-and-judge": {
|
|
@@ -57818,7 +58343,7 @@ async function teamCommand(args) {
|
|
|
57818
58343
|
});
|
|
57819
58344
|
printStatus(status);
|
|
57820
58345
|
await judgeResponses(sessionPath, { judges });
|
|
57821
|
-
console.log(
|
|
58346
|
+
console.log(readFileSync27(join36(sessionPath, "verdict.md"), "utf-8"));
|
|
57822
58347
|
break;
|
|
57823
58348
|
}
|
|
57824
58349
|
case "status": {
|
|
@@ -58468,7 +58993,7 @@ var init_theme = __esm(() => {
|
|
|
58468
58993
|
});
|
|
58469
58994
|
|
|
58470
58995
|
// ../../node_modules/.bun/@inquirer+core@11.0.1+04f2146be16c61ef/node_modules/@inquirer/core/dist/lib/make-theme.js
|
|
58471
|
-
function
|
|
58996
|
+
function isPlainObject4(value) {
|
|
58472
58997
|
if (typeof value !== "object" || value === null)
|
|
58473
58998
|
return false;
|
|
58474
58999
|
let proto = value;
|
|
@@ -58482,7 +59007,7 @@ function deepMerge(...objects) {
|
|
|
58482
59007
|
for (const obj of objects) {
|
|
58483
59008
|
for (const [key, value] of Object.entries(obj)) {
|
|
58484
59009
|
const prevValue = output[key];
|
|
58485
|
-
output[key] =
|
|
59010
|
+
output[key] = isPlainObject4(prevValue) && isPlainObject4(value) ? deepMerge(prevValue, value) : value;
|
|
58486
59011
|
}
|
|
58487
59012
|
}
|
|
58488
59013
|
return output;
|
|
@@ -69245,7 +69770,7 @@ var init_RemoveFileError = __esm(() => {
|
|
|
69245
69770
|
|
|
69246
69771
|
// ../../node_modules/.bun/@inquirer+external-editor@2.0.1+04f2146be16c61ef/node_modules/@inquirer/external-editor/dist/index.js
|
|
69247
69772
|
import { spawn as spawn5, spawnSync as spawnSync2 } from "child_process";
|
|
69248
|
-
import { readFileSync as
|
|
69773
|
+
import { readFileSync as readFileSync28, unlinkSync as unlinkSync6, writeFileSync as writeFileSync17 } from "fs";
|
|
69249
69774
|
import path from "path";
|
|
69250
69775
|
import os from "os";
|
|
69251
69776
|
import { randomUUID as randomUUID5 } from "crypto";
|
|
@@ -69361,7 +69886,7 @@ class ExternalEditor {
|
|
|
69361
69886
|
}
|
|
69362
69887
|
readTemporaryFile() {
|
|
69363
69888
|
try {
|
|
69364
|
-
const tempFileBuffer =
|
|
69889
|
+
const tempFileBuffer = readFileSync28(this.tempFile);
|
|
69365
69890
|
if (tempFileBuffer.length === 0) {
|
|
69366
69891
|
this.text = "";
|
|
69367
69892
|
} else {
|
|
@@ -70756,9 +71281,9 @@ var init_keychain_command = __esm(() => {
|
|
|
70756
71281
|
|
|
70757
71282
|
// src/auth/antigravity-oauth.ts
|
|
70758
71283
|
import { spawnSync as spawnSync3 } from "child_process";
|
|
70759
|
-
import { existsSync as
|
|
70760
|
-
import { homedir as
|
|
70761
|
-
import { join as
|
|
71284
|
+
import { existsSync as existsSync27, unlinkSync as unlinkSync7 } from "fs";
|
|
71285
|
+
import { homedir as homedir32 } from "os";
|
|
71286
|
+
import { join as join37 } from "path";
|
|
70762
71287
|
async function defaultSuggestModel() {
|
|
70763
71288
|
try {
|
|
70764
71289
|
const tok = readSharedAntigravityToken();
|
|
@@ -70879,8 +71404,8 @@ No session detected yet. Starting the Antigravity CLI interactively \u2014
|
|
|
70879
71404
|
async logout(deps2) {
|
|
70880
71405
|
deleteSharedAntigravityToken(deps2);
|
|
70881
71406
|
try {
|
|
70882
|
-
const tokenFile =
|
|
70883
|
-
if (
|
|
71407
|
+
const tokenFile = join37(homedir32(), ".gemini", "antigravity-cli", "antigravity-oauth-token");
|
|
71408
|
+
if (existsSync27(tokenFile))
|
|
70884
71409
|
unlinkSync7(tokenFile);
|
|
70885
71410
|
} catch {}
|
|
70886
71411
|
log("[AntigravityOAuth] Antigravity session cleared (keychain + agy token file)");
|
|
@@ -72282,6 +72807,23 @@ var init_model_selector = __esm(() => {
|
|
|
72282
72807
|
};
|
|
72283
72808
|
});
|
|
72284
72809
|
|
|
72810
|
+
// src/providers/probe-runner.ts
|
|
72811
|
+
function pinProbeModelSpec(link) {
|
|
72812
|
+
if (link.provider === "native-anthropic")
|
|
72813
|
+
return link.modelSpec;
|
|
72814
|
+
return link.modelSpec.includes("@") ? link.modelSpec : `${link.provider}@${link.modelSpec}`;
|
|
72815
|
+
}
|
|
72816
|
+
function probeProviderRoute(proxyUrl, link, timeoutMs) {
|
|
72817
|
+
return probeLink(proxyUrl, {
|
|
72818
|
+
...link,
|
|
72819
|
+
modelSpec: pinProbeModelSpec(link)
|
|
72820
|
+
}, timeoutMs);
|
|
72821
|
+
}
|
|
72822
|
+
var INTERACTIVE_PROBE_TIMEOUT_MS = 60000;
|
|
72823
|
+
var init_probe_runner = __esm(() => {
|
|
72824
|
+
init_probe_live();
|
|
72825
|
+
});
|
|
72826
|
+
|
|
72285
72827
|
// src/tui/theme.ts
|
|
72286
72828
|
import { createTextAttributes } from "@opentui/core";
|
|
72287
72829
|
function latencyBucket(ms) {
|
|
@@ -72905,7 +73447,7 @@ function buildDirectRowData(result) {
|
|
|
72905
73447
|
{
|
|
72906
73448
|
num: "1",
|
|
72907
73449
|
provider: result.nativeProvider,
|
|
72908
|
-
spec:
|
|
73450
|
+
spec: pinProbeModelSpec({ provider: result.nativeProvider, modelSpec: result.model }),
|
|
72909
73451
|
status,
|
|
72910
73452
|
errorDetail,
|
|
72911
73453
|
barsTiming
|
|
@@ -73238,6 +73780,7 @@ function printProbeResults(results, isLiveProbe) {
|
|
|
73238
73780
|
var pc, ANSI_RE2, PRINTER_BAR_WIDTH = 24, PRINTER_TOK_WIDTH = 14, PRINTER_TRACK = "\xB7", PRINTER_BAR_FILL = "\u2588", STAGE_NUM_W = 6, PRINTER_TOK_VALUE_W = 9, PRINTER_BARS_FULL_WIDTH, PRINTER_BARS_NOTOK_WIDTH, PRINTER_BARS_MIN_WIDTH, MIN_CARD_WIDTH = 60, CARD_PADDING_LEFT = 2, CARD_PADDING_RIGHT = 2;
|
|
73239
73781
|
var init_probe_results_printer = __esm(() => {
|
|
73240
73782
|
init_probe_live();
|
|
73783
|
+
init_probe_runner();
|
|
73241
73784
|
init_ansi();
|
|
73242
73785
|
init_theme_mode();
|
|
73243
73786
|
init_theme2();
|
|
@@ -74711,23 +75254,6 @@ var init_claude_code_aliases = __esm(() => {
|
|
|
74711
75254
|
};
|
|
74712
75255
|
});
|
|
74713
75256
|
|
|
74714
|
-
// src/providers/probe-runner.ts
|
|
74715
|
-
function pinProbeModelSpec(link) {
|
|
74716
|
-
if (link.provider === "native-anthropic")
|
|
74717
|
-
return link.modelSpec;
|
|
74718
|
-
return link.modelSpec.includes("@") ? link.modelSpec : `${link.provider}@${link.modelSpec}`;
|
|
74719
|
-
}
|
|
74720
|
-
function probeProviderRoute(proxyUrl, link, timeoutMs) {
|
|
74721
|
-
return probeLink(proxyUrl, {
|
|
74722
|
-
...link,
|
|
74723
|
-
modelSpec: pinProbeModelSpec(link)
|
|
74724
|
-
}, timeoutMs);
|
|
74725
|
-
}
|
|
74726
|
-
var INTERACTIVE_PROBE_TIMEOUT_MS = 60000;
|
|
74727
|
-
var init_probe_runner = __esm(() => {
|
|
74728
|
-
init_probe_live();
|
|
74729
|
-
});
|
|
74730
|
-
|
|
74731
75257
|
// src/cli.ts
|
|
74732
75258
|
var exports_cli = {};
|
|
74733
75259
|
__export(exports_cli, {
|
|
@@ -74744,30 +75270,30 @@ __export(exports_cli, {
|
|
|
74744
75270
|
});
|
|
74745
75271
|
import {
|
|
74746
75272
|
copyFileSync as copyFileSync2,
|
|
74747
|
-
existsSync as
|
|
75273
|
+
existsSync as existsSync28,
|
|
74748
75274
|
mkdirSync as mkdirSync16,
|
|
74749
|
-
readFileSync as
|
|
74750
|
-
readdirSync as
|
|
75275
|
+
readFileSync as readFileSync29,
|
|
75276
|
+
readdirSync as readdirSync7,
|
|
74751
75277
|
unlinkSync as unlinkSync8,
|
|
74752
75278
|
writeFileSync as writeFileSync18
|
|
74753
75279
|
} from "fs";
|
|
74754
|
-
import { homedir as
|
|
74755
|
-
import { dirname as dirname11, join as
|
|
75280
|
+
import { homedir as homedir33 } from "os";
|
|
75281
|
+
import { dirname as dirname11, join as join38 } from "path";
|
|
74756
75282
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
74757
75283
|
function getVersion3() {
|
|
74758
75284
|
return VERSION;
|
|
74759
75285
|
}
|
|
74760
75286
|
function clearAllModelCaches() {
|
|
74761
|
-
const cacheDir =
|
|
74762
|
-
if (!
|
|
75287
|
+
const cacheDir = join38(homedir33(), ".claudish");
|
|
75288
|
+
if (!existsSync28(cacheDir))
|
|
74763
75289
|
return;
|
|
74764
75290
|
const cachePatterns = ["pricing-cache.json", "recommended-models-cache.json"];
|
|
74765
75291
|
let cleared = 0;
|
|
74766
75292
|
try {
|
|
74767
|
-
const files =
|
|
75293
|
+
const files = readdirSync7(cacheDir);
|
|
74768
75294
|
for (const file2 of files) {
|
|
74769
75295
|
if (cachePatterns.includes(file2)) {
|
|
74770
|
-
unlinkSync8(
|
|
75296
|
+
unlinkSync8(join38(cacheDir, file2));
|
|
74771
75297
|
cleared++;
|
|
74772
75298
|
}
|
|
74773
75299
|
}
|
|
@@ -74987,6 +75513,33 @@ async function parseArgs(args) {
|
|
|
74987
75513
|
process.exit(1);
|
|
74988
75514
|
}
|
|
74989
75515
|
config3.classifierProvider = cpArg;
|
|
75516
|
+
} else if (arg === "--model-params") {
|
|
75517
|
+
const mpArg = args[++i];
|
|
75518
|
+
if (!mpArg) {
|
|
75519
|
+
console.error("--model-params requires k=v[,k=v...] (e.g. reasoning.mode=pro)");
|
|
75520
|
+
process.exit(1);
|
|
75521
|
+
}
|
|
75522
|
+
try {
|
|
75523
|
+
config3.modelParams = parseModelParams(mpArg, config3.modelParams ?? {});
|
|
75524
|
+
} catch (err) {
|
|
75525
|
+
console.error(err instanceof Error ? err.message : String(err));
|
|
75526
|
+
process.exit(1);
|
|
75527
|
+
}
|
|
75528
|
+
} else if (arg === "--effort-override") {
|
|
75529
|
+
const effArg = args[++i];
|
|
75530
|
+
if (!effArg) {
|
|
75531
|
+
console.error(`--effort-override requires a level (${EFFORT_LEVELS.join(", ")})`);
|
|
75532
|
+
process.exit(1);
|
|
75533
|
+
}
|
|
75534
|
+
if (!isEffortLevel(effArg)) {
|
|
75535
|
+
console.error(`--effort-override "${effArg}" is not a canonical level (${EFFORT_LEVELS.join(", ")}). ` + "For a provider-specific value, use --model-params (e.g. --model-params reasoning_effort=<value>).");
|
|
75536
|
+
process.exit(1);
|
|
75537
|
+
}
|
|
75538
|
+
config3.effortOverride = effArg;
|
|
75539
|
+
} else if (arg === "--pro-on-ultracode") {
|
|
75540
|
+
config3.proOnUltracode = true;
|
|
75541
|
+
} else if (arg === "--no-pro-on-ultracode") {
|
|
75542
|
+
config3.proOnUltracode = false;
|
|
74990
75543
|
} else if (arg === "--op-env" || arg.startsWith("--op-env=")) {
|
|
74991
75544
|
const v = arg.startsWith("--op-env=") ? arg.slice("--op-env=".length) : args[++i];
|
|
74992
75545
|
if (!v) {
|
|
@@ -75197,8 +75750,8 @@ Usage: claudish --models --provider <slug>`);
|
|
|
75197
75750
|
});
|
|
75198
75751
|
config3.resolvedDefaultProvider = resolved;
|
|
75199
75752
|
if (resolved.legacyAutoPromoted && !config3.quiet) {
|
|
75200
|
-
const markerFile =
|
|
75201
|
-
if (!
|
|
75753
|
+
const markerFile = join38(homedir33(), ".claudish", ".legacy-litellm-hint-shown");
|
|
75754
|
+
if (!existsSync28(markerFile)) {
|
|
75202
75755
|
const hint = buildLegacyHint(resolved);
|
|
75203
75756
|
if (hint) {
|
|
75204
75757
|
console.error(hint);
|
|
@@ -75210,6 +75763,14 @@ Usage: claudish --models --provider <slug>`);
|
|
|
75210
75763
|
}
|
|
75211
75764
|
}
|
|
75212
75765
|
} catch {}
|
|
75766
|
+
if (config3.proOnUltracode === undefined) {
|
|
75767
|
+
const envVal = process.env.CLAUDISH_PRO_ON_ULTRACODE;
|
|
75768
|
+
if (envVal !== undefined) {
|
|
75769
|
+
config3.proOnUltracode = envVal === "1" || envVal.toLowerCase() === "true";
|
|
75770
|
+
} else {
|
|
75771
|
+
config3.proOnUltracode = readProOnUltracode() === true;
|
|
75772
|
+
}
|
|
75773
|
+
}
|
|
75213
75774
|
return config3;
|
|
75214
75775
|
}
|
|
75215
75776
|
function formatModelDocPricing(pricing) {
|
|
@@ -75805,14 +76366,14 @@ async function probeModelRouting(models, jsonOutput, options = { live: true, tim
|
|
|
75805
76366
|
}
|
|
75806
76367
|
return;
|
|
75807
76368
|
}
|
|
75808
|
-
const
|
|
76369
|
+
const initialState2 = {
|
|
75809
76370
|
steps: [],
|
|
75810
76371
|
links: [],
|
|
75811
76372
|
phase: "live",
|
|
75812
76373
|
results: [],
|
|
75813
76374
|
activeTab: "summary"
|
|
75814
76375
|
};
|
|
75815
|
-
const tui = await startProbeTui(
|
|
76376
|
+
const tui = await startProbeTui(initialState2);
|
|
75816
76377
|
const addStep = (name, status) => {
|
|
75817
76378
|
tui.store.setState((prev) => ({
|
|
75818
76379
|
...prev,
|
|
@@ -76106,6 +76667,10 @@ ${h("OPTIONS")}
|
|
|
76106
76667
|
${green2("--free")} Show only FREE models in the interactive selector
|
|
76107
76668
|
${green2("--monitor")} Monitor mode - proxy to REAL Anthropic API and log traffic
|
|
76108
76669
|
${green2("--advisor")} ${yellow2('"m1,m2[:collector]"')} Multi-model advisor replacement (implies --monitor)
|
|
76670
|
+
${green2("--model-params")} ${yellow2('"k=v,..."')} Extra request params merged into the payload (e.g. reasoning.mode=pro)
|
|
76671
|
+
${green2("--effort-override")} ${yellow2("<level>")} Pin reasoning effort verbatim, skipping the per-model clamp
|
|
76672
|
+
${green2("--pro-on-ultracode")} Apply the model's catalog preset while in ultracode (opt-in)
|
|
76673
|
+
${green2("--no-pro-on-ultracode")} Force that off for this run (when enabled in config/env)
|
|
76109
76674
|
${green2("-y, --auto-approve")} Skip permission prompts (--dangerously-skip-permissions)
|
|
76110
76675
|
${green2("--no-auto-approve")} Explicitly enable permission prompts (default)
|
|
76111
76676
|
${green2("--dangerous")} Pass --dangerouslyDisableSandbox to Claude Code
|
|
@@ -76317,8 +76882,8 @@ ${h("MORE INFO")}
|
|
|
76317
76882
|
}
|
|
76318
76883
|
function printAIAgentGuide() {
|
|
76319
76884
|
try {
|
|
76320
|
-
const guidePath =
|
|
76321
|
-
const guideContent =
|
|
76885
|
+
const guidePath = join38(__dirname3, "../AI_AGENT_GUIDE.md");
|
|
76886
|
+
const guideContent = readFileSync29(guidePath, "utf-8");
|
|
76322
76887
|
console.log(guideContent);
|
|
76323
76888
|
} catch (error46) {
|
|
76324
76889
|
console.error("Error reading AI Agent Guide:");
|
|
@@ -76334,19 +76899,19 @@ async function initializeClaudishSkill() {
|
|
|
76334
76899
|
console.log(`\uD83D\uDD27 Initializing Claudish skill in current project...
|
|
76335
76900
|
`);
|
|
76336
76901
|
const cwd = process.cwd();
|
|
76337
|
-
const claudeDir =
|
|
76338
|
-
const skillsDir =
|
|
76339
|
-
const claudishSkillDir =
|
|
76340
|
-
const skillFile =
|
|
76341
|
-
if (
|
|
76902
|
+
const claudeDir = join38(cwd, ".claude");
|
|
76903
|
+
const skillsDir = join38(claudeDir, "skills");
|
|
76904
|
+
const claudishSkillDir = join38(skillsDir, "claudish-usage");
|
|
76905
|
+
const skillFile = join38(claudishSkillDir, "SKILL.md");
|
|
76906
|
+
if (existsSync28(skillFile)) {
|
|
76342
76907
|
console.log("\u2705 Claudish skill already installed at:");
|
|
76343
76908
|
console.log(` ${skillFile}
|
|
76344
76909
|
`);
|
|
76345
76910
|
console.log("\uD83D\uDCA1 To reinstall, delete the file and run 'claudish --init' again.");
|
|
76346
76911
|
return;
|
|
76347
76912
|
}
|
|
76348
|
-
const sourceSkillPath =
|
|
76349
|
-
if (!
|
|
76913
|
+
const sourceSkillPath = join38(__dirname3, "../skills/claudish-usage/SKILL.md");
|
|
76914
|
+
if (!existsSync28(sourceSkillPath)) {
|
|
76350
76915
|
console.error("\u274C Error: Claudish skill file not found in installation.");
|
|
76351
76916
|
console.error(` Expected at: ${sourceSkillPath}`);
|
|
76352
76917
|
console.error(`
|
|
@@ -76355,15 +76920,15 @@ async function initializeClaudishSkill() {
|
|
|
76355
76920
|
process.exit(1);
|
|
76356
76921
|
}
|
|
76357
76922
|
try {
|
|
76358
|
-
if (!
|
|
76923
|
+
if (!existsSync28(claudeDir)) {
|
|
76359
76924
|
mkdirSync16(claudeDir, { recursive: true });
|
|
76360
76925
|
console.log("\uD83D\uDCC1 Created .claude/ directory");
|
|
76361
76926
|
}
|
|
76362
|
-
if (!
|
|
76927
|
+
if (!existsSync28(skillsDir)) {
|
|
76363
76928
|
mkdirSync16(skillsDir, { recursive: true });
|
|
76364
76929
|
console.log("\uD83D\uDCC1 Created .claude/skills/ directory");
|
|
76365
76930
|
}
|
|
76366
|
-
if (!
|
|
76931
|
+
if (!existsSync28(claudishSkillDir)) {
|
|
76367
76932
|
mkdirSync16(claudishSkillDir, { recursive: true });
|
|
76368
76933
|
console.log("\uD83D\uDCC1 Created .claude/skills/claudish-usage/ directory");
|
|
76369
76934
|
}
|
|
@@ -76421,6 +76986,7 @@ function printAvailableModels() {
|
|
|
76421
76986
|
}
|
|
76422
76987
|
var __filename3, __dirname3;
|
|
76423
76988
|
var init_cli = __esm(() => {
|
|
76989
|
+
init_base_api_format();
|
|
76424
76990
|
init_config2();
|
|
76425
76991
|
init_model_loader();
|
|
76426
76992
|
init_model_selector();
|
|
@@ -76452,33 +77018,33 @@ __export(exports_update_checker, {
|
|
|
76452
77018
|
fetchLatestVersion: () => fetchLatestVersion,
|
|
76453
77019
|
fetchLatestVersionOrThrow: () => fetchLatestVersionOrThrow
|
|
76454
77020
|
});
|
|
76455
|
-
import { existsSync as
|
|
76456
|
-
import { homedir as
|
|
76457
|
-
import { join as
|
|
77021
|
+
import { existsSync as existsSync29, mkdirSync as mkdirSync17, readFileSync as readFileSync30, unlinkSync as unlinkSync9, writeFileSync as writeFileSync19 } from "fs";
|
|
77022
|
+
import { homedir as homedir34, platform as platform2, tmpdir } from "os";
|
|
77023
|
+
import { join as join39 } from "path";
|
|
76458
77024
|
function getCacheFilePath() {
|
|
76459
77025
|
let cacheDir;
|
|
76460
77026
|
if (isWindows) {
|
|
76461
|
-
const localAppData = process.env.LOCALAPPDATA ||
|
|
76462
|
-
cacheDir =
|
|
77027
|
+
const localAppData = process.env.LOCALAPPDATA || join39(homedir34(), "AppData", "Local");
|
|
77028
|
+
cacheDir = join39(localAppData, "claudish");
|
|
76463
77029
|
} else {
|
|
76464
|
-
cacheDir =
|
|
77030
|
+
cacheDir = join39(homedir34(), ".cache", "claudish");
|
|
76465
77031
|
}
|
|
76466
77032
|
try {
|
|
76467
|
-
if (!
|
|
77033
|
+
if (!existsSync29(cacheDir)) {
|
|
76468
77034
|
mkdirSync17(cacheDir, { recursive: true });
|
|
76469
77035
|
}
|
|
76470
|
-
return
|
|
77036
|
+
return join39(cacheDir, "update-check.json");
|
|
76471
77037
|
} catch {
|
|
76472
|
-
return
|
|
77038
|
+
return join39(tmpdir(), "claudish-update-check.json");
|
|
76473
77039
|
}
|
|
76474
77040
|
}
|
|
76475
77041
|
function readCache() {
|
|
76476
77042
|
try {
|
|
76477
77043
|
const cachePath = getCacheFilePath();
|
|
76478
|
-
if (!
|
|
77044
|
+
if (!existsSync29(cachePath)) {
|
|
76479
77045
|
return null;
|
|
76480
77046
|
}
|
|
76481
|
-
const data = JSON.parse(
|
|
77047
|
+
const data = JSON.parse(readFileSync30(cachePath, "utf-8"));
|
|
76482
77048
|
return data;
|
|
76483
77049
|
} catch {
|
|
76484
77050
|
return null;
|
|
@@ -76501,7 +77067,7 @@ function isCacheValid(cache3) {
|
|
|
76501
77067
|
function clearCache() {
|
|
76502
77068
|
try {
|
|
76503
77069
|
const cachePath = getCacheFilePath();
|
|
76504
|
-
if (
|
|
77070
|
+
if (existsSync29(cachePath)) {
|
|
76505
77071
|
unlinkSync9(cachePath);
|
|
76506
77072
|
}
|
|
76507
77073
|
} catch {}
|
|
@@ -77405,15 +77971,15 @@ var init_local_liveness = __esm(() => {
|
|
|
77405
77971
|
});
|
|
77406
77972
|
|
|
77407
77973
|
// src/providers/probe-catalog.ts
|
|
77408
|
-
import { existsSync as
|
|
77409
|
-
import { homedir as
|
|
77410
|
-
import { dirname as dirname12, join as
|
|
77974
|
+
import { existsSync as existsSync30, mkdirSync as mkdirSync18, readFileSync as readFileSync31, writeFileSync as writeFileSync20 } from "fs";
|
|
77975
|
+
import { homedir as homedir35 } from "os";
|
|
77976
|
+
import { dirname as dirname12, join as join40 } from "path";
|
|
77411
77977
|
function readProbeModelsCache(path2 = PROBE_MODELS_CACHE_PATH) {
|
|
77412
|
-
if (!
|
|
77978
|
+
if (!existsSync30(path2))
|
|
77413
77979
|
return null;
|
|
77414
77980
|
let raw2;
|
|
77415
77981
|
try {
|
|
77416
|
-
raw2 = JSON.parse(
|
|
77982
|
+
raw2 = JSON.parse(readFileSync31(path2, "utf-8"));
|
|
77417
77983
|
} catch {
|
|
77418
77984
|
return null;
|
|
77419
77985
|
}
|
|
@@ -77542,7 +78108,7 @@ function isValidResponse(raw2) {
|
|
|
77542
78108
|
var PROBE_MODELS_URL = "https://us-central1-claudish-6da10.cloudfunctions.net/probeModels", CACHE_TTL_MS4, FETCH_TIMEOUT_MS3 = 15000, PROBE_MODELS_CACHE_PATH, _inFlight = null;
|
|
77543
78109
|
var init_probe_catalog = __esm(() => {
|
|
77544
78110
|
CACHE_TTL_MS4 = 60 * 60 * 1000;
|
|
77545
|
-
PROBE_MODELS_CACHE_PATH =
|
|
78111
|
+
PROBE_MODELS_CACHE_PATH = join40(homedir35(), ".claudish", "probe-models.json");
|
|
77546
78112
|
});
|
|
77547
78113
|
|
|
77548
78114
|
// src/tui/constants.ts
|
|
@@ -84145,18 +84711,18 @@ __export(exports_claude_runner, {
|
|
|
84145
84711
|
});
|
|
84146
84712
|
import { spawn as spawn6, spawnSync as spawnSync5 } from "child_process";
|
|
84147
84713
|
import {
|
|
84148
|
-
closeSync as
|
|
84149
|
-
existsSync as
|
|
84714
|
+
closeSync as closeSync8,
|
|
84715
|
+
existsSync as existsSync31,
|
|
84150
84716
|
mkdirSync as mkdirSync19,
|
|
84151
|
-
openSync as
|
|
84152
|
-
readFileSync as
|
|
84153
|
-
readdirSync as
|
|
84154
|
-
statSync as
|
|
84717
|
+
openSync as openSync8,
|
|
84718
|
+
readFileSync as readFileSync32,
|
|
84719
|
+
readdirSync as readdirSync8,
|
|
84720
|
+
statSync as statSync8,
|
|
84155
84721
|
unlinkSync as unlinkSync10,
|
|
84156
84722
|
writeFileSync as writeFileSync21
|
|
84157
84723
|
} from "fs";
|
|
84158
|
-
import { homedir as
|
|
84159
|
-
import { dirname as dirname13, join as
|
|
84724
|
+
import { homedir as homedir36, tmpdir as tmpdir2 } from "os";
|
|
84725
|
+
import { dirname as dirname13, join as join41 } from "path";
|
|
84160
84726
|
import { isatty } from "tty";
|
|
84161
84727
|
function releaseTerminalIsolation() {
|
|
84162
84728
|
if (!restoreTerminal)
|
|
@@ -84195,11 +84761,11 @@ function shouldHideIncidentalAnthropicKey(config3, env = process.env) {
|
|
|
84195
84761
|
}
|
|
84196
84762
|
function hasResolvableAnthropicAuth(deps2 = {}) {
|
|
84197
84763
|
const env = deps2.env ?? process.env;
|
|
84198
|
-
const fileExists = deps2.fileExists ??
|
|
84764
|
+
const fileExists = deps2.fileExists ?? existsSync31;
|
|
84199
84765
|
const keychainProbe = deps2.keychainProbe ?? defaultKeychainAnthropicProbe;
|
|
84200
84766
|
if (env.ANTHROPIC_API_KEY || env.ANTHROPIC_AUTH_TOKEN)
|
|
84201
84767
|
return true;
|
|
84202
|
-
if (fileExists(
|
|
84768
|
+
if (fileExists(join41(homedir36(), ".claude", ".credentials.json")))
|
|
84203
84769
|
return true;
|
|
84204
84770
|
return keychainProbe();
|
|
84205
84771
|
}
|
|
@@ -84211,14 +84777,14 @@ function isProxyAuthMode(config3) {
|
|
|
84211
84777
|
}
|
|
84212
84778
|
function managedSettingsPath() {
|
|
84213
84779
|
if (isWindows2()) {
|
|
84214
|
-
return
|
|
84780
|
+
return join41(process.env.PROGRAMDATA || "C:\\ProgramData", "ClaudeCode", "managed-settings.json");
|
|
84215
84781
|
}
|
|
84216
84782
|
if (process.platform === "darwin") {
|
|
84217
84783
|
return "/Library/Application Support/ClaudeCode/managed-settings.json";
|
|
84218
84784
|
}
|
|
84219
84785
|
return "/etc/claude-code/managed-settings.json";
|
|
84220
84786
|
}
|
|
84221
|
-
function managedSettingsForcesClaudeAi(readFile3 =
|
|
84787
|
+
function managedSettingsForcesClaudeAi(readFile3 = readFileSync32) {
|
|
84222
84788
|
try {
|
|
84223
84789
|
const raw2 = readFile3(managedSettingsPath(), "utf-8");
|
|
84224
84790
|
const parsed = JSON.parse(raw2);
|
|
@@ -84232,9 +84798,9 @@ function isWindows2() {
|
|
|
84232
84798
|
}
|
|
84233
84799
|
function createStatusLineScript(tokenFilePath) {
|
|
84234
84800
|
const homeDir = process.env.HOME || process.env.USERPROFILE || tmpdir2();
|
|
84235
|
-
const claudishDir =
|
|
84801
|
+
const claudishDir = join41(homeDir, ".claudish");
|
|
84236
84802
|
const timestamp = Date.now();
|
|
84237
|
-
const scriptPath =
|
|
84803
|
+
const scriptPath = join41(claudishDir, `status-${timestamp}.js`);
|
|
84238
84804
|
const escapedTokenPath = tokenFilePath.replace(/\\/g, "\\\\");
|
|
84239
84805
|
const light = getThemeMode() === "light";
|
|
84240
84806
|
const cyanCode = light ? "38;2;14;116;144" : "96";
|
|
@@ -84392,7 +84958,7 @@ function cleanupStaleTokenFiles(dir, now2 = Date.now(), maxAgeMs = STALE_TOKEN_F
|
|
|
84392
84958
|
let removed = 0;
|
|
84393
84959
|
let entries;
|
|
84394
84960
|
try {
|
|
84395
|
-
entries =
|
|
84961
|
+
entries = readdirSync8(dir);
|
|
84396
84962
|
} catch {
|
|
84397
84963
|
return 0;
|
|
84398
84964
|
}
|
|
@@ -84404,9 +84970,9 @@ function cleanupStaleTokenFiles(dir, now2 = Date.now(), maxAgeMs = STALE_TOKEN_F
|
|
|
84404
84970
|
if (!name.startsWith("tokens-") || !name.endsWith(".json"))
|
|
84405
84971
|
continue;
|
|
84406
84972
|
scanned++;
|
|
84407
|
-
const full =
|
|
84973
|
+
const full = join41(dir, name);
|
|
84408
84974
|
try {
|
|
84409
|
-
if (
|
|
84975
|
+
if (statSync8(full).mtimeMs >= cutoff)
|
|
84410
84976
|
continue;
|
|
84411
84977
|
unlinkSync10(full);
|
|
84412
84978
|
removed++;
|
|
@@ -84421,7 +84987,7 @@ function parseSettingsArg(value) {
|
|
|
84421
84987
|
if (value.trimStart().startsWith("{")) {
|
|
84422
84988
|
return JSON.parse(value);
|
|
84423
84989
|
}
|
|
84424
|
-
return JSON.parse(
|
|
84990
|
+
return JSON.parse(readFileSync32(value, "utf-8"));
|
|
84425
84991
|
}
|
|
84426
84992
|
function parseSettingsArgSafe(value) {
|
|
84427
84993
|
try {
|
|
@@ -84433,13 +84999,13 @@ function parseSettingsArgSafe(value) {
|
|
|
84433
84999
|
}
|
|
84434
85000
|
function userSettingsFileCandidates(cwd) {
|
|
84435
85001
|
return [
|
|
84436
|
-
|
|
84437
|
-
|
|
84438
|
-
|
|
85002
|
+
join41(homedir36(), ".claude", "settings.json"),
|
|
85003
|
+
join41(cwd, ".claude", "settings.json"),
|
|
85004
|
+
join41(cwd, ".claude", "settings.local.json")
|
|
84439
85005
|
];
|
|
84440
85006
|
}
|
|
84441
85007
|
function discoverUserStatusLineCommand(claudeArgs = [], cwd = process.cwd()) {
|
|
84442
|
-
const sources = userSettingsFileCandidates(cwd).filter((file2) =>
|
|
85008
|
+
const sources = userSettingsFileCandidates(cwd).filter((file2) => existsSync31(file2));
|
|
84443
85009
|
const idx = claudeArgs.indexOf("--settings");
|
|
84444
85010
|
const settingsArg = idx === -1 ? undefined : claudeArgs[idx + 1];
|
|
84445
85011
|
if (settingsArg)
|
|
@@ -84476,13 +85042,13 @@ function buildChainedStatusCommand(userCommand, claudishBody, claudishSegment) {
|
|
|
84476
85042
|
}
|
|
84477
85043
|
function createTempSettingsFile(_modelDisplay, port, proxyAuthMode, userStatusLineCommand) {
|
|
84478
85044
|
const homeDir = process.env.HOME || process.env.USERPROFILE || tmpdir2();
|
|
84479
|
-
const claudishDir =
|
|
85045
|
+
const claudishDir = join41(homeDir, ".claudish");
|
|
84480
85046
|
try {
|
|
84481
85047
|
mkdirSync19(claudishDir, { recursive: true });
|
|
84482
85048
|
} catch {}
|
|
84483
85049
|
const timestamp = Date.now();
|
|
84484
|
-
const tempPath =
|
|
84485
|
-
const tokenFilePath =
|
|
85050
|
+
const tempPath = join41(claudishDir, `settings-${timestamp}.json`);
|
|
85051
|
+
const tokenFilePath = join41(claudishDir, `tokens-${port}.json`);
|
|
84486
85052
|
cleanupStaleTokenFiles(claudishDir);
|
|
84487
85053
|
initializeTokenFile(tokenFilePath);
|
|
84488
85054
|
let statusCommand;
|
|
@@ -84736,8 +85302,8 @@ async function runClaudeWithProxy(config3, proxyUrl, onCleanup) {
|
|
|
84736
85302
|
console.error("Install it from: https://claude.com/claude-code");
|
|
84737
85303
|
console.error(`
|
|
84738
85304
|
Or set CLAUDE_PATH to your custom installation:`);
|
|
84739
|
-
const home =
|
|
84740
|
-
const localPath = isWindows2() ?
|
|
85305
|
+
const home = homedir36();
|
|
85306
|
+
const localPath = isWindows2() ? join41(home, ".claude", "local", "claude.exe") : join41(home, ".claude", "local", "claude");
|
|
84741
85307
|
console.error(` export CLAUDE_PATH=${localPath}`);
|
|
84742
85308
|
process.exit(1);
|
|
84743
85309
|
}
|
|
@@ -84748,11 +85314,11 @@ Or set CLAUDE_PATH to your custom installation:`);
|
|
|
84748
85314
|
const childWantsTty = config3.interactive && !process.stdout.isTTY && Boolean(process.stdin.isTTY);
|
|
84749
85315
|
if (childWantsTty) {
|
|
84750
85316
|
try {
|
|
84751
|
-
const fd =
|
|
85317
|
+
const fd = openSync8("/dev/fd/0", "r+");
|
|
84752
85318
|
if (isatty(fd)) {
|
|
84753
85319
|
ttyFd = fd;
|
|
84754
85320
|
} else {
|
|
84755
|
-
|
|
85321
|
+
closeSync8(fd);
|
|
84756
85322
|
}
|
|
84757
85323
|
} catch {
|
|
84758
85324
|
ttyFd = undefined;
|
|
@@ -84775,7 +85341,7 @@ Or set CLAUDE_PATH to your custom installation:`);
|
|
|
84775
85341
|
const fdToClose = ttyFd;
|
|
84776
85342
|
proc.on("spawn", () => {
|
|
84777
85343
|
try {
|
|
84778
|
-
|
|
85344
|
+
closeSync8(fdToClose);
|
|
84779
85345
|
} catch {}
|
|
84780
85346
|
});
|
|
84781
85347
|
}
|
|
@@ -84817,23 +85383,23 @@ function setupSignalHandlers(proc, tempSettingsPath, quiet, onCleanup) {
|
|
|
84817
85383
|
async function findClaudeBinary() {
|
|
84818
85384
|
const isWindows3 = process.platform === "win32";
|
|
84819
85385
|
if (process.env.CLAUDE_PATH) {
|
|
84820
|
-
if (
|
|
85386
|
+
if (existsSync31(process.env.CLAUDE_PATH)) {
|
|
84821
85387
|
return process.env.CLAUDE_PATH;
|
|
84822
85388
|
}
|
|
84823
85389
|
}
|
|
84824
|
-
const home =
|
|
84825
|
-
const localPath = isWindows3 ?
|
|
84826
|
-
if (
|
|
85390
|
+
const home = homedir36();
|
|
85391
|
+
const localPath = isWindows3 ? join41(home, ".claude", "local", "claude.exe") : join41(home, ".claude", "local", "claude");
|
|
85392
|
+
if (existsSync31(localPath)) {
|
|
84827
85393
|
return localPath;
|
|
84828
85394
|
}
|
|
84829
85395
|
if (isWindows3) {
|
|
84830
85396
|
const windowsPaths = [
|
|
84831
|
-
|
|
84832
|
-
|
|
84833
|
-
|
|
85397
|
+
join41(home, "AppData", "Roaming", "npm", "claude.cmd"),
|
|
85398
|
+
join41(home, ".npm-global", "claude.cmd"),
|
|
85399
|
+
join41(home, "node_modules", ".bin", "claude.cmd")
|
|
84834
85400
|
];
|
|
84835
85401
|
for (const path2 of windowsPaths) {
|
|
84836
|
-
if (
|
|
85402
|
+
if (existsSync31(path2)) {
|
|
84837
85403
|
return path2;
|
|
84838
85404
|
}
|
|
84839
85405
|
}
|
|
@@ -84841,14 +85407,14 @@ async function findClaudeBinary() {
|
|
|
84841
85407
|
const commonPaths = [
|
|
84842
85408
|
"/usr/local/bin/claude",
|
|
84843
85409
|
"/opt/homebrew/bin/claude",
|
|
84844
|
-
|
|
84845
|
-
|
|
84846
|
-
|
|
85410
|
+
join41(home, ".npm-global/bin/claude"),
|
|
85411
|
+
join41(home, ".local/bin/claude"),
|
|
85412
|
+
join41(home, "node_modules/.bin/claude"),
|
|
84847
85413
|
"/data/data/com.termux/files/usr/bin/claude",
|
|
84848
|
-
|
|
85414
|
+
join41(home, "../usr/bin/claude")
|
|
84849
85415
|
];
|
|
84850
85416
|
for (const path2 of commonPaths) {
|
|
84851
|
-
if (
|
|
85417
|
+
if (existsSync31(path2)) {
|
|
84852
85418
|
return path2;
|
|
84853
85419
|
}
|
|
84854
85420
|
}
|
|
@@ -84929,17 +85495,17 @@ __export(exports_diag_output, {
|
|
|
84929
85495
|
createDiagOutput: () => createDiagOutput
|
|
84930
85496
|
});
|
|
84931
85497
|
import { createWriteStream as createWriteStream3, mkdirSync as mkdirSync20, unlinkSync as unlinkSync11, writeFileSync as writeFileSync22 } from "fs";
|
|
84932
|
-
import { homedir as
|
|
84933
|
-
import { join as
|
|
85498
|
+
import { homedir as homedir37 } from "os";
|
|
85499
|
+
import { join as join42 } from "path";
|
|
84934
85500
|
function getClaudishDir() {
|
|
84935
|
-
const dir =
|
|
85501
|
+
const dir = join42(homedir37(), ".claudish");
|
|
84936
85502
|
try {
|
|
84937
85503
|
mkdirSync20(dir, { recursive: true });
|
|
84938
85504
|
} catch {}
|
|
84939
85505
|
return dir;
|
|
84940
85506
|
}
|
|
84941
85507
|
function getDiagLogPath() {
|
|
84942
|
-
return
|
|
85508
|
+
return join42(getClaudishDir(), `diag-${process.pid}.log`);
|
|
84943
85509
|
}
|
|
84944
85510
|
|
|
84945
85511
|
class LogFileDiagOutput {
|
|
@@ -85544,7 +86110,7 @@ var init_widgets = __esm(() => {
|
|
|
85544
86110
|
});
|
|
85545
86111
|
|
|
85546
86112
|
// src/session/conversation.ts
|
|
85547
|
-
import { closeSync as
|
|
86113
|
+
import { closeSync as closeSync9, openSync as openSync9, readSync as readSync4, statSync as statSync9 } from "fs";
|
|
85548
86114
|
import { StringDecoder as StringDecoder2 } from "string_decoder";
|
|
85549
86115
|
function looksLikeTurn(line) {
|
|
85550
86116
|
const assistant = line.includes('"type":"assistant"');
|
|
@@ -85599,8 +86165,8 @@ function readConversation(file2, opts = {}) {
|
|
|
85599
86165
|
};
|
|
85600
86166
|
let fd = null;
|
|
85601
86167
|
try {
|
|
85602
|
-
const size =
|
|
85603
|
-
fd =
|
|
86168
|
+
const size = statSync9(file2).size;
|
|
86169
|
+
fd = openSync9(file2, "r");
|
|
85604
86170
|
const buf = Buffer.allocUnsafe(chunkBytes);
|
|
85605
86171
|
const decoder = new StringDecoder2("utf-8");
|
|
85606
86172
|
let pending = "";
|
|
@@ -85632,7 +86198,7 @@ function readConversation(file2, opts = {}) {
|
|
|
85632
86198
|
take({ role: raw2.role, text, elided });
|
|
85633
86199
|
};
|
|
85634
86200
|
while (pos < size) {
|
|
85635
|
-
const n =
|
|
86201
|
+
const n = readSync4(fd, buf, 0, Math.min(chunkBytes, size - pos), pos);
|
|
85636
86202
|
if (n <= 0)
|
|
85637
86203
|
break;
|
|
85638
86204
|
pos += n;
|
|
@@ -85656,7 +86222,7 @@ function readConversation(file2, opts = {}) {
|
|
|
85656
86222
|
} catch {} finally {
|
|
85657
86223
|
if (fd !== null) {
|
|
85658
86224
|
try {
|
|
85659
|
-
|
|
86225
|
+
closeSync9(fd);
|
|
85660
86226
|
} catch {}
|
|
85661
86227
|
}
|
|
85662
86228
|
}
|
|
@@ -87263,16 +87829,16 @@ __export(exports_session_stats, {
|
|
|
87263
87829
|
readSessionStats: () => readSessionStats,
|
|
87264
87830
|
tokenFilePath: () => tokenFilePath
|
|
87265
87831
|
});
|
|
87266
|
-
import { readFileSync as
|
|
87267
|
-
import { homedir as
|
|
87268
|
-
import { join as
|
|
87832
|
+
import { readFileSync as readFileSync33 } from "fs";
|
|
87833
|
+
import { homedir as homedir38 } from "os";
|
|
87834
|
+
import { join as join43 } from "path";
|
|
87269
87835
|
function tokenFilePath(port) {
|
|
87270
|
-
return process.env.CLAUDISH_TOKEN_FILE ||
|
|
87836
|
+
return process.env.CLAUDISH_TOKEN_FILE || join43(homedir38(), ".claudish", `tokens-${port}.json`);
|
|
87271
87837
|
}
|
|
87272
87838
|
function readSessionStats(port, opts) {
|
|
87273
87839
|
let raw2;
|
|
87274
87840
|
try {
|
|
87275
|
-
raw2 = JSON.parse(
|
|
87841
|
+
raw2 = JSON.parse(readFileSync33(tokenFilePath(port), "utf-8"));
|
|
87276
87842
|
} catch {
|
|
87277
87843
|
return null;
|
|
87278
87844
|
}
|
|
@@ -87611,8 +88177,8 @@ var init_session_summary = __esm(() => {
|
|
|
87611
88177
|
init_op_source();
|
|
87612
88178
|
init_startup_trace();
|
|
87613
88179
|
var import_dotenv3 = __toESM(require_main(), 1);
|
|
87614
|
-
import { existsSync as
|
|
87615
|
-
import { join as
|
|
88180
|
+
import { existsSync as existsSync32, readFileSync as readFileSync34 } from "fs";
|
|
88181
|
+
import { join as join44, resolve as resolve6 } from "path";
|
|
87616
88182
|
import_dotenv3.config({ quiet: true });
|
|
87617
88183
|
function classifyStartupKind() {
|
|
87618
88184
|
const argv = process.argv.slice(2);
|
|
@@ -87712,7 +88278,7 @@ async function applyConfigOverride() {
|
|
|
87712
88278
|
const { planConfigOverride: planConfigOverride2, setConfigFileOverride: setConfigFileOverride2 } = await Promise.resolve().then(() => exports_config_override);
|
|
87713
88279
|
const plan = planConfigOverride2(process.argv.slice(2), process.env, {
|
|
87714
88280
|
resolve: resolve6,
|
|
87715
|
-
exists:
|
|
88281
|
+
exists: existsSync32
|
|
87716
88282
|
});
|
|
87717
88283
|
if (plan.kind === "none")
|
|
87718
88284
|
return;
|
|
@@ -87885,14 +88451,14 @@ async function runCli() {
|
|
|
87885
88451
|
if (cliConfig.team && cliConfig.team.length > 0) {
|
|
87886
88452
|
let prompt = cliConfig.claudeArgs.join(" ");
|
|
87887
88453
|
if (cliConfig.inputFile) {
|
|
87888
|
-
prompt =
|
|
88454
|
+
prompt = readFileSync34(cliConfig.inputFile, "utf-8");
|
|
87889
88455
|
}
|
|
87890
88456
|
if (!prompt.trim()) {
|
|
87891
88457
|
console.error("Error: --team requires a prompt (positional args or -f <file>)");
|
|
87892
88458
|
process.exit(1);
|
|
87893
88459
|
}
|
|
87894
88460
|
const mode = cliConfig.teamMode ?? "default";
|
|
87895
|
-
const sessionPath =
|
|
88461
|
+
const sessionPath = join44(process.cwd(), `.claudish-team-${Date.now()}`);
|
|
87896
88462
|
if (mode === "json") {
|
|
87897
88463
|
const { setupSession: setupSession2, runModels: runModels2 } = await Promise.resolve().then(() => (init_team_orchestrator(), exports_team_orchestrator));
|
|
87898
88464
|
setupSession2(sessionPath, cliConfig.team, prompt);
|
|
@@ -87902,9 +88468,9 @@ async function runCli() {
|
|
|
87902
88468
|
});
|
|
87903
88469
|
const result = { ...status2, responses: {} };
|
|
87904
88470
|
for (const anonId of Object.keys(status2.models)) {
|
|
87905
|
-
const responsePath =
|
|
88471
|
+
const responsePath = join44(sessionPath, `response-${anonId}.md`);
|
|
87906
88472
|
try {
|
|
87907
|
-
const raw2 =
|
|
88473
|
+
const raw2 = readFileSync34(responsePath, "utf-8").trim();
|
|
87908
88474
|
try {
|
|
87909
88475
|
result.responses[anonId] = JSON.parse(raw2);
|
|
87910
88476
|
} catch {
|
|
@@ -88110,7 +88676,10 @@ Team Status`);
|
|
|
88110
88676
|
advisorModels: cliConfig.advisorModels,
|
|
88111
88677
|
advisorCollector: cliConfig.advisorCollector,
|
|
88112
88678
|
modelChain: cliConfig.monitor ? undefined : cliConfig.modelChain,
|
|
88113
|
-
classifier: resolveClassifierConfig(cliConfig, process.env)
|
|
88679
|
+
classifier: resolveClassifierConfig(cliConfig, process.env),
|
|
88680
|
+
effortOverride: cliConfig.effortOverride,
|
|
88681
|
+
modelParams: cliConfig.modelParams,
|
|
88682
|
+
proOnUltracode: cliConfig.proOnUltracode
|
|
88114
88683
|
}));
|
|
88115
88684
|
const diag = createDiagOutput2({
|
|
88116
88685
|
interactive: cliConfig.interactive,
|