claudish 7.66.0 → 7.67.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +933 -354
- 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.0";
|
|
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;
|
|
@@ -28658,6 +28700,8 @@ class BaseAPIFormat {
|
|
|
28658
28700
|
return request;
|
|
28659
28701
|
}
|
|
28660
28702
|
clampToAdvertisedEffort(requested, reasoning) {
|
|
28703
|
+
if (this.pinnedEffort)
|
|
28704
|
+
return this.pinnedEffort;
|
|
28661
28705
|
const advertised = (reasoning.efforts ?? []).filter(isEffortLevel);
|
|
28662
28706
|
if (advertised.length === 0) {
|
|
28663
28707
|
return isEffortLevel(reasoning.defaultEffort) ? reasoning.defaultEffort : undefined;
|
|
@@ -28699,7 +28743,13 @@ class BaseAPIFormat {
|
|
|
28699
28743
|
return 8192;
|
|
28700
28744
|
}
|
|
28701
28745
|
}
|
|
28746
|
+
pinnedEffort;
|
|
28747
|
+
setEffortOverride(level) {
|
|
28748
|
+
this.pinnedEffort = level;
|
|
28749
|
+
}
|
|
28702
28750
|
resolveEffortLevel(originalRequest) {
|
|
28751
|
+
if (this.pinnedEffort)
|
|
28752
|
+
return this.pinnedEffort;
|
|
28703
28753
|
const lvl = originalRequest?.output_config?.effort;
|
|
28704
28754
|
if (typeof lvl === "string") {
|
|
28705
28755
|
const lower = lvl.toLowerCase();
|
|
@@ -35177,31 +35227,91 @@ var init_middleware = __esm(() => {
|
|
|
35177
35227
|
init_gemini_thought_signature();
|
|
35178
35228
|
});
|
|
35179
35229
|
|
|
35230
|
+
// src/model-params.ts
|
|
35231
|
+
function isPlainObject3(value) {
|
|
35232
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
35233
|
+
}
|
|
35234
|
+
function deepMergeParams(target, source) {
|
|
35235
|
+
for (const [key, value] of Object.entries(source)) {
|
|
35236
|
+
if (isPlainObject3(value) && isPlainObject3(target[key])) {
|
|
35237
|
+
deepMergeParams(target[key], value);
|
|
35238
|
+
} else if (isPlainObject3(value)) {
|
|
35239
|
+
target[key] = deepMergeParams({}, value);
|
|
35240
|
+
} else {
|
|
35241
|
+
target[key] = value;
|
|
35242
|
+
}
|
|
35243
|
+
}
|
|
35244
|
+
return target;
|
|
35245
|
+
}
|
|
35246
|
+
function coerceValue(raw) {
|
|
35247
|
+
try {
|
|
35248
|
+
return JSON.parse(raw);
|
|
35249
|
+
} catch {
|
|
35250
|
+
return raw;
|
|
35251
|
+
}
|
|
35252
|
+
}
|
|
35253
|
+
function parseModelParams(spec, into = {}) {
|
|
35254
|
+
for (const item of spec.split(",")) {
|
|
35255
|
+
const trimmed2 = item.trim();
|
|
35256
|
+
if (!trimmed2)
|
|
35257
|
+
continue;
|
|
35258
|
+
const eq = trimmed2.indexOf("=");
|
|
35259
|
+
if (eq <= 0) {
|
|
35260
|
+
throw new Error(`--model-params item "${trimmed2}" must be key=value`);
|
|
35261
|
+
}
|
|
35262
|
+
const key = trimmed2.slice(0, eq).trim();
|
|
35263
|
+
const raw = trimmed2.slice(eq + 1);
|
|
35264
|
+
const path = key.split(".");
|
|
35265
|
+
if (path.some((seg) => seg.length === 0)) {
|
|
35266
|
+
throw new Error(`--model-params key "${key}" has an empty dot segment`);
|
|
35267
|
+
}
|
|
35268
|
+
const nested = {};
|
|
35269
|
+
let cursor = nested;
|
|
35270
|
+
for (const seg of path.slice(0, -1)) {
|
|
35271
|
+
const child = {};
|
|
35272
|
+
cursor[seg] = child;
|
|
35273
|
+
cursor = child;
|
|
35274
|
+
}
|
|
35275
|
+
cursor[path[path.length - 1]] = coerceValue(raw);
|
|
35276
|
+
deepMergeParams(into, nested);
|
|
35277
|
+
}
|
|
35278
|
+
return into;
|
|
35279
|
+
}
|
|
35280
|
+
|
|
35180
35281
|
// src/handlers/shared/quota-exhaustion.ts
|
|
35181
35282
|
function hasQuotaExhaustionWording(errorBody) {
|
|
35182
35283
|
const lower = (errorBody || "").toLowerCase();
|
|
35183
35284
|
return EXHAUSTION_PHRASES.some((phrase) => lower.includes(phrase));
|
|
35184
35285
|
}
|
|
35286
|
+
function hasPlanLimitWording(errorBody) {
|
|
35287
|
+
const lower = (errorBody || "").toLowerCase();
|
|
35288
|
+
if (BALANCE_PHRASES.some((phrase) => lower.includes(phrase)))
|
|
35289
|
+
return false;
|
|
35290
|
+
return PLAN_LIMIT_PHRASES.some((phrase) => lower.includes(phrase));
|
|
35291
|
+
}
|
|
35185
35292
|
function isQuotaExhaustionError(status, errorBody) {
|
|
35186
35293
|
if (status !== 401 && status !== 403 && status !== 429)
|
|
35187
35294
|
return false;
|
|
35188
35295
|
return hasQuotaExhaustionWording(errorBody);
|
|
35189
35296
|
}
|
|
35190
|
-
var EXHAUSTION_PHRASES;
|
|
35297
|
+
var BALANCE_PHRASES, PLAN_LIMIT_PHRASES, EXHAUSTION_PHRASES;
|
|
35191
35298
|
var init_quota_exhaustion = __esm(() => {
|
|
35192
|
-
|
|
35299
|
+
BALANCE_PHRASES = [
|
|
35300
|
+
"insufficient balance",
|
|
35301
|
+
"insufficient_quota",
|
|
35302
|
+
"out of credits",
|
|
35303
|
+
"credit balance"
|
|
35304
|
+
];
|
|
35305
|
+
PLAN_LIMIT_PHRASES = [
|
|
35193
35306
|
"usage limit",
|
|
35194
35307
|
"billing cycle",
|
|
35195
35308
|
"quota",
|
|
35196
|
-
"insufficient balance",
|
|
35197
|
-
"insufficient_quota",
|
|
35198
35309
|
"upgrade your plan",
|
|
35199
35310
|
"exceeded your current",
|
|
35200
|
-
"out of credits",
|
|
35201
|
-
"credit balance",
|
|
35202
35311
|
"daily limit",
|
|
35203
35312
|
"plan limit"
|
|
35204
35313
|
];
|
|
35314
|
+
EXHAUSTION_PHRASES = [...BALANCE_PHRASES, ...PLAN_LIMIT_PHRASES];
|
|
35205
35315
|
});
|
|
35206
35316
|
|
|
35207
35317
|
// src/handlers/shared/gemini-queue.ts
|
|
@@ -39189,6 +39299,362 @@ var init_vision_proxy = __esm(() => {
|
|
|
39189
39299
|
init_catalog_query();
|
|
39190
39300
|
});
|
|
39191
39301
|
|
|
39302
|
+
// src/session-events/event-translator.ts
|
|
39303
|
+
function translateLine(line) {
|
|
39304
|
+
let record4;
|
|
39305
|
+
try {
|
|
39306
|
+
record4 = JSON.parse(line);
|
|
39307
|
+
} catch {
|
|
39308
|
+
return null;
|
|
39309
|
+
}
|
|
39310
|
+
if (record4 === null || typeof record4 !== "object")
|
|
39311
|
+
return null;
|
|
39312
|
+
const at = typeof record4.timestamp === "string" ? record4.timestamp : undefined;
|
|
39313
|
+
if (record4.type === "attachment") {
|
|
39314
|
+
const attachmentType = record4.attachment?.type;
|
|
39315
|
+
if (attachmentType === "ultra_effort_enter")
|
|
39316
|
+
return { kind: "ultra_effort_enter", at };
|
|
39317
|
+
if (attachmentType === "ultra_effort_exit")
|
|
39318
|
+
return { kind: "ultra_effort_exit", at };
|
|
39319
|
+
return {
|
|
39320
|
+
kind: "unknown",
|
|
39321
|
+
attachmentType: typeof attachmentType === "string" ? attachmentType : undefined,
|
|
39322
|
+
at
|
|
39323
|
+
};
|
|
39324
|
+
}
|
|
39325
|
+
if (record4.type === "user") {
|
|
39326
|
+
const content = record4.message?.content;
|
|
39327
|
+
if (typeof content === "string" && content.includes("<local-command-stdout>")) {
|
|
39328
|
+
const match = content.match(EFFORT_STDOUT_RE);
|
|
39329
|
+
if (match) {
|
|
39330
|
+
const scope = match[2] === "this session only" ? "session" : "default";
|
|
39331
|
+
return { kind: "effort_changed", level: match[1], scope, at };
|
|
39332
|
+
}
|
|
39333
|
+
}
|
|
39334
|
+
}
|
|
39335
|
+
return null;
|
|
39336
|
+
}
|
|
39337
|
+
var EFFORT_STDOUT_RE;
|
|
39338
|
+
var init_event_translator = __esm(() => {
|
|
39339
|
+
EFFORT_STDOUT_RE = /Set effort level to (\S+) \((this session only|saved as your default)/;
|
|
39340
|
+
});
|
|
39341
|
+
|
|
39342
|
+
// src/session-events/session-state.ts
|
|
39343
|
+
function initialState(seed) {
|
|
39344
|
+
if (seed?.defaultEffort) {
|
|
39345
|
+
return {
|
|
39346
|
+
ultracodeActive: false,
|
|
39347
|
+
effort: seed.defaultEffort,
|
|
39348
|
+
defaultEffort: seed.defaultEffort,
|
|
39349
|
+
seededFrom: "settings"
|
|
39350
|
+
};
|
|
39351
|
+
}
|
|
39352
|
+
return { ultracodeActive: false, seededFrom: "none" };
|
|
39353
|
+
}
|
|
39354
|
+
function reduceEvent(state, event) {
|
|
39355
|
+
const next = { ...state, lastEventAt: event.at ?? state.lastEventAt };
|
|
39356
|
+
switch (event.kind) {
|
|
39357
|
+
case "ultra_effort_enter":
|
|
39358
|
+
next.ultracodeActive = true;
|
|
39359
|
+
return next;
|
|
39360
|
+
case "ultra_effort_exit":
|
|
39361
|
+
next.ultracodeActive = false;
|
|
39362
|
+
return next;
|
|
39363
|
+
case "effort_changed":
|
|
39364
|
+
next.effort = event.level;
|
|
39365
|
+
next.effortScope = event.scope;
|
|
39366
|
+
next.ultracodeActive = event.level === "ultracode";
|
|
39367
|
+
if (event.scope === "default")
|
|
39368
|
+
next.defaultEffort = event.level;
|
|
39369
|
+
return next;
|
|
39370
|
+
default:
|
|
39371
|
+
return next;
|
|
39372
|
+
}
|
|
39373
|
+
}
|
|
39374
|
+
|
|
39375
|
+
// src/session-events/transcript-tailer.ts
|
|
39376
|
+
import { closeSync as closeSync5, openSync as openSync5, readSync, statSync as statSync4 } from "fs";
|
|
39377
|
+
|
|
39378
|
+
class TranscriptTailer {
|
|
39379
|
+
filePath;
|
|
39380
|
+
onLine;
|
|
39381
|
+
opts;
|
|
39382
|
+
offset = 0;
|
|
39383
|
+
buffer = "";
|
|
39384
|
+
decoder = new TextDecoder;
|
|
39385
|
+
timer = null;
|
|
39386
|
+
disposed = false;
|
|
39387
|
+
constructor(filePath, onLine, opts = {}) {
|
|
39388
|
+
this.filePath = filePath;
|
|
39389
|
+
this.onLine = onLine;
|
|
39390
|
+
this.opts = opts;
|
|
39391
|
+
}
|
|
39392
|
+
start() {
|
|
39393
|
+
if (this.disposed)
|
|
39394
|
+
return;
|
|
39395
|
+
this.tick();
|
|
39396
|
+
this.schedule();
|
|
39397
|
+
}
|
|
39398
|
+
syncNow() {
|
|
39399
|
+
this.tick();
|
|
39400
|
+
}
|
|
39401
|
+
dispose() {
|
|
39402
|
+
this.disposed = true;
|
|
39403
|
+
if (this.timer) {
|
|
39404
|
+
clearTimeout(this.timer);
|
|
39405
|
+
this.timer = null;
|
|
39406
|
+
}
|
|
39407
|
+
}
|
|
39408
|
+
schedule() {
|
|
39409
|
+
if (this.disposed)
|
|
39410
|
+
return;
|
|
39411
|
+
this.timer = setTimeout(() => {
|
|
39412
|
+
this.tick();
|
|
39413
|
+
this.schedule();
|
|
39414
|
+
}, this.opts.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS);
|
|
39415
|
+
this.timer.unref?.();
|
|
39416
|
+
}
|
|
39417
|
+
tick() {
|
|
39418
|
+
if (this.disposed)
|
|
39419
|
+
return;
|
|
39420
|
+
try {
|
|
39421
|
+
const size = statSync4(this.filePath).size;
|
|
39422
|
+
if (size < this.offset) {
|
|
39423
|
+
this.offset = 0;
|
|
39424
|
+
this.buffer = "";
|
|
39425
|
+
this.decoder = new TextDecoder;
|
|
39426
|
+
}
|
|
39427
|
+
if (size === this.offset)
|
|
39428
|
+
return;
|
|
39429
|
+
const fd = openSync5(this.filePath, "r");
|
|
39430
|
+
let chunk;
|
|
39431
|
+
try {
|
|
39432
|
+
chunk = Buffer.alloc(size - this.offset);
|
|
39433
|
+
const bytesRead = readSync(fd, chunk, 0, chunk.length, this.offset);
|
|
39434
|
+
this.offset += bytesRead;
|
|
39435
|
+
if (bytesRead < chunk.length)
|
|
39436
|
+
chunk = chunk.subarray(0, bytesRead);
|
|
39437
|
+
} finally {
|
|
39438
|
+
closeSync5(fd);
|
|
39439
|
+
}
|
|
39440
|
+
this.buffer += this.decoder.decode(chunk, { stream: true });
|
|
39441
|
+
const lines = this.buffer.split(`
|
|
39442
|
+
`);
|
|
39443
|
+
this.buffer = lines.pop() ?? "";
|
|
39444
|
+
for (const line of lines) {
|
|
39445
|
+
if (line.trim())
|
|
39446
|
+
this.onLine(line);
|
|
39447
|
+
}
|
|
39448
|
+
} catch (err) {
|
|
39449
|
+
this.dispose();
|
|
39450
|
+
this.opts.onError?.(err);
|
|
39451
|
+
}
|
|
39452
|
+
}
|
|
39453
|
+
}
|
|
39454
|
+
var DEFAULT_POLL_INTERVAL_MS = 250;
|
|
39455
|
+
var init_transcript_tailer = () => {};
|
|
39456
|
+
|
|
39457
|
+
// src/session-events/index.ts
|
|
39458
|
+
import { existsSync as existsSync16, readFileSync as readFileSync15, readdirSync as readdirSync3 } from "fs";
|
|
39459
|
+
import { homedir as homedir23 } from "os";
|
|
39460
|
+
import { join as join23 } from "path";
|
|
39461
|
+
function extractSessionId2(metadata) {
|
|
39462
|
+
const userId = metadata?.user_id;
|
|
39463
|
+
if (typeof userId !== "string")
|
|
39464
|
+
return;
|
|
39465
|
+
try {
|
|
39466
|
+
const parsed = JSON.parse(userId);
|
|
39467
|
+
if (typeof parsed?.session_id === "string" && parsed.session_id) {
|
|
39468
|
+
return parsed.session_id;
|
|
39469
|
+
}
|
|
39470
|
+
} catch {}
|
|
39471
|
+
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);
|
|
39472
|
+
return match?.[1];
|
|
39473
|
+
}
|
|
39474
|
+
function slugFromCwd(cwd) {
|
|
39475
|
+
return cwd.replace(/[^a-zA-Z0-9]/g, "-");
|
|
39476
|
+
}
|
|
39477
|
+
|
|
39478
|
+
class SessionEventRegistry {
|
|
39479
|
+
sessions = new Map;
|
|
39480
|
+
misses = new Map;
|
|
39481
|
+
subscribers = [];
|
|
39482
|
+
claudeHome;
|
|
39483
|
+
pollIntervalMs;
|
|
39484
|
+
constructor(opts = {}) {
|
|
39485
|
+
this.claudeHome = opts.claudeHome ?? join23(homedir23(), ".claude");
|
|
39486
|
+
this.pollIntervalMs = opts.pollIntervalMs;
|
|
39487
|
+
}
|
|
39488
|
+
ensureSession(sessionId) {
|
|
39489
|
+
try {
|
|
39490
|
+
this.sweepIdle();
|
|
39491
|
+
const existing = this.sessions.get(sessionId);
|
|
39492
|
+
if (existing) {
|
|
39493
|
+
existing.lastActivity = Date.now();
|
|
39494
|
+
return;
|
|
39495
|
+
}
|
|
39496
|
+
const miss = this.misses.get(sessionId);
|
|
39497
|
+
if (miss) {
|
|
39498
|
+
if (miss.count >= MAX_MISSES)
|
|
39499
|
+
return;
|
|
39500
|
+
if (Date.now() - miss.lastTry < MISS_TTL_MS)
|
|
39501
|
+
return;
|
|
39502
|
+
}
|
|
39503
|
+
const filePath = this.locateTranscript(sessionId);
|
|
39504
|
+
if (!filePath) {
|
|
39505
|
+
const count = (miss?.count ?? 0) + 1;
|
|
39506
|
+
this.misses.set(sessionId, { lastTry: Date.now(), count });
|
|
39507
|
+
if (count === MAX_MISSES) {
|
|
39508
|
+
log(`[SessionEvents] transcript for session ${sessionId} not found after ${MAX_MISSES} attempts \u2014 giving up`);
|
|
39509
|
+
}
|
|
39510
|
+
return;
|
|
39511
|
+
}
|
|
39512
|
+
this.misses.delete(sessionId);
|
|
39513
|
+
const entry = {
|
|
39514
|
+
state: initialState({ defaultEffort: this.readSettingsEffortLevel() }),
|
|
39515
|
+
tailer: new TranscriptTailer(filePath, (line) => this.onLine(sessionId, line), {
|
|
39516
|
+
pollIntervalMs: this.pollIntervalMs,
|
|
39517
|
+
onError: (err) => log(`[SessionEvents] tailer for ${sessionId} stopped: ${err}`)
|
|
39518
|
+
}),
|
|
39519
|
+
lastActivity: Date.now()
|
|
39520
|
+
};
|
|
39521
|
+
this.sessions.set(sessionId, entry);
|
|
39522
|
+
entry.tailer.start();
|
|
39523
|
+
log(`[SessionEvents] tailing ${filePath}`);
|
|
39524
|
+
} catch (err) {
|
|
39525
|
+
log(`[SessionEvents] ensureSession(${sessionId}) failed: ${err}`);
|
|
39526
|
+
}
|
|
39527
|
+
}
|
|
39528
|
+
sync(sessionId) {
|
|
39529
|
+
try {
|
|
39530
|
+
const entry = this.sessions.get(sessionId);
|
|
39531
|
+
if (entry) {
|
|
39532
|
+
entry.lastActivity = Date.now();
|
|
39533
|
+
entry.tailer.syncNow();
|
|
39534
|
+
}
|
|
39535
|
+
} catch (err) {
|
|
39536
|
+
log(`[SessionEvents] sync(${sessionId}) failed: ${err}`);
|
|
39537
|
+
}
|
|
39538
|
+
}
|
|
39539
|
+
getState(sessionId) {
|
|
39540
|
+
return this.sessions.get(sessionId)?.state;
|
|
39541
|
+
}
|
|
39542
|
+
subscribe(fn) {
|
|
39543
|
+
this.subscribers.push(fn);
|
|
39544
|
+
return () => {
|
|
39545
|
+
this.subscribers = this.subscribers.filter((s) => s !== fn);
|
|
39546
|
+
};
|
|
39547
|
+
}
|
|
39548
|
+
disposeAll() {
|
|
39549
|
+
for (const entry of this.sessions.values()) {
|
|
39550
|
+
entry.tailer.dispose();
|
|
39551
|
+
}
|
|
39552
|
+
this.sessions.clear();
|
|
39553
|
+
this.misses.clear();
|
|
39554
|
+
}
|
|
39555
|
+
onLine(sessionId, line) {
|
|
39556
|
+
const event = translateLine(line);
|
|
39557
|
+
if (!event)
|
|
39558
|
+
return;
|
|
39559
|
+
const entry = this.sessions.get(sessionId);
|
|
39560
|
+
if (!entry)
|
|
39561
|
+
return;
|
|
39562
|
+
entry.state = reduceEvent(entry.state, event);
|
|
39563
|
+
log(`[SessionEvents] ${sessionId}: ${event.kind}${event.kind === "effort_changed" ? ` level=${event.level} scope=${event.scope}` : ""} \u2192 ultracodeActive=${entry.state.ultracodeActive}`);
|
|
39564
|
+
for (const fn of this.subscribers) {
|
|
39565
|
+
try {
|
|
39566
|
+
fn(sessionId, event);
|
|
39567
|
+
} catch {}
|
|
39568
|
+
}
|
|
39569
|
+
}
|
|
39570
|
+
locateTranscript(sessionId) {
|
|
39571
|
+
const projectsDir = join23(this.claudeHome, "projects");
|
|
39572
|
+
const primary = join23(projectsDir, slugFromCwd(process.cwd()), `${sessionId}.jsonl`);
|
|
39573
|
+
if (existsSync16(primary))
|
|
39574
|
+
return primary;
|
|
39575
|
+
try {
|
|
39576
|
+
for (const dir of readdirSync3(projectsDir)) {
|
|
39577
|
+
const candidate = join23(projectsDir, dir, `${sessionId}.jsonl`);
|
|
39578
|
+
if (existsSync16(candidate))
|
|
39579
|
+
return candidate;
|
|
39580
|
+
}
|
|
39581
|
+
} catch {}
|
|
39582
|
+
return;
|
|
39583
|
+
}
|
|
39584
|
+
readSettingsEffortLevel() {
|
|
39585
|
+
try {
|
|
39586
|
+
const settings = JSON.parse(readFileSync15(join23(this.claudeHome, "settings.json"), "utf-8"));
|
|
39587
|
+
return typeof settings.effortLevel === "string" ? settings.effortLevel : undefined;
|
|
39588
|
+
} catch {
|
|
39589
|
+
return;
|
|
39590
|
+
}
|
|
39591
|
+
}
|
|
39592
|
+
sweepIdle() {
|
|
39593
|
+
const now2 = Date.now();
|
|
39594
|
+
for (const [sid, entry] of this.sessions) {
|
|
39595
|
+
if (now2 - entry.lastActivity > IDLE_SWEEP_MS) {
|
|
39596
|
+
entry.tailer.dispose();
|
|
39597
|
+
this.sessions.delete(sid);
|
|
39598
|
+
}
|
|
39599
|
+
}
|
|
39600
|
+
}
|
|
39601
|
+
}
|
|
39602
|
+
var MISS_TTL_MS = 5000, MAX_MISSES = 5, IDLE_SWEEP_MS, sessionEvents;
|
|
39603
|
+
var init_session_events = __esm(() => {
|
|
39604
|
+
init_logger();
|
|
39605
|
+
init_event_translator();
|
|
39606
|
+
init_transcript_tailer();
|
|
39607
|
+
IDLE_SWEEP_MS = 30 * 60 * 1000;
|
|
39608
|
+
sessionEvents = new SessionEventRegistry;
|
|
39609
|
+
});
|
|
39610
|
+
|
|
39611
|
+
// src/session-events/pro-injection.ts
|
|
39612
|
+
function resolveVariantPreset(bareModelName, provider, cachePath) {
|
|
39613
|
+
for (const variant of lookupVariantPresets(bareModelName, provider, cachePath)) {
|
|
39614
|
+
try {
|
|
39615
|
+
const params = parseModelParams(variant.preset);
|
|
39616
|
+
if (Object.keys(params).length === 0)
|
|
39617
|
+
continue;
|
|
39618
|
+
return {
|
|
39619
|
+
params,
|
|
39620
|
+
variantModelId: variant.modelId,
|
|
39621
|
+
provider: variant.provider,
|
|
39622
|
+
preset: variant.preset
|
|
39623
|
+
};
|
|
39624
|
+
} catch {}
|
|
39625
|
+
}
|
|
39626
|
+
return;
|
|
39627
|
+
}
|
|
39628
|
+
function applyProInjection(requestPayload, opts) {
|
|
39629
|
+
try {
|
|
39630
|
+
if (!opts.enabled || !opts.sessionId)
|
|
39631
|
+
return false;
|
|
39632
|
+
if (opts.outputConfig?.effort !== "xhigh")
|
|
39633
|
+
return false;
|
|
39634
|
+
if (opts.outputConfig?.format)
|
|
39635
|
+
return false;
|
|
39636
|
+
const registry2 = opts.registry ?? sessionEvents;
|
|
39637
|
+
registry2.ensureSession(opts.sessionId);
|
|
39638
|
+
registry2.sync(opts.sessionId);
|
|
39639
|
+
const state = registry2.getState(opts.sessionId);
|
|
39640
|
+
if (!state?.ultracodeActive)
|
|
39641
|
+
return false;
|
|
39642
|
+
const resolved = resolveVariantPreset(opts.bareModelName, opts.provider, opts.cachePath);
|
|
39643
|
+
if (!resolved)
|
|
39644
|
+
return false;
|
|
39645
|
+
deepMergeParams(requestPayload, resolved.params);
|
|
39646
|
+
log(`[SessionEvents] ultracode active \u2192 preset ${resolved.preset} for ${opts.targetModel} ` + `(catalog variant ${resolved.variantModelId} @ ${resolved.provider}, session ${opts.sessionId})`);
|
|
39647
|
+
return true;
|
|
39648
|
+
} catch {
|
|
39649
|
+
return false;
|
|
39650
|
+
}
|
|
39651
|
+
}
|
|
39652
|
+
var init_pro_injection = __esm(() => {
|
|
39653
|
+
init_model_catalog();
|
|
39654
|
+
init_logger();
|
|
39655
|
+
init_session_events();
|
|
39656
|
+
});
|
|
39657
|
+
|
|
39192
39658
|
// src/providers/model-parser.ts
|
|
39193
39659
|
function parseModelChain(modelSpec) {
|
|
39194
39660
|
const parts = modelSpec.split(MODEL_CHAIN_SEPARATOR).map((s) => s.trim()).filter(Boolean);
|
|
@@ -39304,25 +39770,25 @@ var init_model_parser = __esm(() => {
|
|
|
39304
39770
|
|
|
39305
39771
|
// src/stats-buffer.ts
|
|
39306
39772
|
import {
|
|
39307
|
-
existsSync as
|
|
39773
|
+
existsSync as existsSync17,
|
|
39308
39774
|
mkdirSync as mkdirSync9,
|
|
39309
|
-
readFileSync as
|
|
39775
|
+
readFileSync as readFileSync16,
|
|
39310
39776
|
renameSync as renameSync2,
|
|
39311
39777
|
unlinkSync as unlinkSync5,
|
|
39312
39778
|
writeFileSync as writeFileSync8
|
|
39313
39779
|
} from "fs";
|
|
39314
|
-
import { homedir as
|
|
39315
|
-
import { join as
|
|
39780
|
+
import { homedir as homedir24 } from "os";
|
|
39781
|
+
import { join as join24 } from "path";
|
|
39316
39782
|
function ensureDir() {
|
|
39317
|
-
if (!
|
|
39783
|
+
if (!existsSync17(CLAUDISH_DIR)) {
|
|
39318
39784
|
mkdirSync9(CLAUDISH_DIR, { recursive: true });
|
|
39319
39785
|
}
|
|
39320
39786
|
}
|
|
39321
39787
|
function readFromDisk() {
|
|
39322
39788
|
try {
|
|
39323
|
-
if (!
|
|
39789
|
+
if (!existsSync17(BUFFER_FILE))
|
|
39324
39790
|
return [];
|
|
39325
|
-
const raw =
|
|
39791
|
+
const raw = readFileSync16(BUFFER_FILE, "utf-8");
|
|
39326
39792
|
const parsed = JSON.parse(raw);
|
|
39327
39793
|
if (!Array.isArray(parsed.events))
|
|
39328
39794
|
return [];
|
|
@@ -39347,7 +39813,7 @@ function writeToDisk(events) {
|
|
|
39347
39813
|
ensureDir();
|
|
39348
39814
|
const trimmed2 = enforceSizeCap([...events]);
|
|
39349
39815
|
const payload = { version: 1, events: trimmed2 };
|
|
39350
|
-
const tmpFile =
|
|
39816
|
+
const tmpFile = join24(CLAUDISH_DIR, `stats-buffer.tmp.${process.pid}.json`);
|
|
39351
39817
|
writeFileSync8(tmpFile, JSON.stringify(payload, null, 2), "utf-8");
|
|
39352
39818
|
renameSync2(tmpFile, BUFFER_FILE);
|
|
39353
39819
|
memoryCache = trimmed2;
|
|
@@ -39391,7 +39857,7 @@ function clearBuffer() {
|
|
|
39391
39857
|
try {
|
|
39392
39858
|
memoryCache = [];
|
|
39393
39859
|
eventsSinceLastFlush = 0;
|
|
39394
|
-
if (
|
|
39860
|
+
if (existsSync17(BUFFER_FILE)) {
|
|
39395
39861
|
unlinkSync5(BUFFER_FILE);
|
|
39396
39862
|
}
|
|
39397
39863
|
} catch {}
|
|
@@ -39420,8 +39886,8 @@ function syncFlushOnExit() {
|
|
|
39420
39886
|
var BUFFER_MAX_BYTES, CLAUDISH_DIR, BUFFER_FILE, memoryCache = null, eventsSinceLastFlush = 0, flushScheduled = false, SIGNAL_EXIT_CODE;
|
|
39421
39887
|
var init_stats_buffer = __esm(() => {
|
|
39422
39888
|
BUFFER_MAX_BYTES = 64 * 1024;
|
|
39423
|
-
CLAUDISH_DIR =
|
|
39424
|
-
BUFFER_FILE =
|
|
39889
|
+
CLAUDISH_DIR = join24(homedir24(), ".claudish");
|
|
39890
|
+
BUFFER_FILE = join24(CLAUDISH_DIR, "stats-buffer.json");
|
|
39425
39891
|
process.on("exit", syncFlushOnExit);
|
|
39426
39892
|
SIGNAL_EXIT_CODE = { SIGTERM: 143, SIGINT: 130 };
|
|
39427
39893
|
for (const signal of ["SIGTERM", "SIGINT"]) {
|
|
@@ -42539,8 +43005,8 @@ var init_openai_responses_sse = __esm(() => {
|
|
|
42539
43005
|
|
|
42540
43006
|
// src/handlers/shared/token-tracker.ts
|
|
42541
43007
|
import { mkdirSync as mkdirSync10, writeFileSync as writeFileSync9 } from "fs";
|
|
42542
|
-
import { homedir as
|
|
42543
|
-
import { dirname as dirname8, join as
|
|
43008
|
+
import { homedir as homedir25 } from "os";
|
|
43009
|
+
import { dirname as dirname8, join as join25 } from "path";
|
|
42544
43010
|
function stripProviderPrefix(name) {
|
|
42545
43011
|
const at = name.indexOf("@");
|
|
42546
43012
|
return at === -1 ? name : name.slice(at + 1);
|
|
@@ -42728,7 +43194,7 @@ class TokenTracker {
|
|
|
42728
43194
|
};
|
|
42729
43195
|
}
|
|
42730
43196
|
const override = process.env.CLAUDISH_TOKEN_FILE;
|
|
42731
|
-
const outPath = override ||
|
|
43197
|
+
const outPath = override || join25(homedir25(), ".claudish", `tokens-${this.port}.json`);
|
|
42732
43198
|
mkdirSync10(dirname8(outPath), { recursive: true });
|
|
42733
43199
|
writeFileSync9(outPath, JSON.stringify(data), "utf-8");
|
|
42734
43200
|
} catch (e) {
|
|
@@ -42853,6 +43319,12 @@ class ComposedHandler {
|
|
|
42853
43319
|
}
|
|
42854
43320
|
this.middlewareManager.initialize().catch((err) => log(`[ComposedHandler:${this.bareModelName}] Middleware init error: ${err}`));
|
|
42855
43321
|
this.behaviorEngine = getBehaviorEngine();
|
|
43322
|
+
if (options.effortOverride) {
|
|
43323
|
+
for (const dialect of new Set([this.explicitAdapter, this.resolvedDialect, this.modelAdapter].filter(Boolean))) {
|
|
43324
|
+
dialect.setEffortOverride(options.effortOverride);
|
|
43325
|
+
}
|
|
43326
|
+
log(`[ComposedHandler] --effort ${options.effortOverride} pinned for ${this.targetModel} (catalog clamp skipped)`);
|
|
43327
|
+
}
|
|
42856
43328
|
this.tokenTracker = new TokenTracker(port, {
|
|
42857
43329
|
contextWindow: this.getModelContextWindow(),
|
|
42858
43330
|
providerName: provider.name,
|
|
@@ -42991,6 +43463,22 @@ class ComposedHandler {
|
|
|
42991
43463
|
this.modelAdapter.prepareRequest(requestPayload, claudeRequest);
|
|
42992
43464
|
}
|
|
42993
43465
|
const toolNameMap = adapter.getToolNameMap();
|
|
43466
|
+
if (this.options.proOnUltracode) {
|
|
43467
|
+
applyProInjection(requestPayload, {
|
|
43468
|
+
enabled: true,
|
|
43469
|
+
sessionId: extractSessionId2(claudeRequest?.metadata),
|
|
43470
|
+
bareModelName: this.bareModelName,
|
|
43471
|
+
provider: this.provider.name,
|
|
43472
|
+
targetModel: this.targetModel,
|
|
43473
|
+
outputConfig: claudeRequest?.output_config,
|
|
43474
|
+
registry: this.options.sessionEventRegistry,
|
|
43475
|
+
cachePath: this.options.catalogCachePath
|
|
43476
|
+
});
|
|
43477
|
+
}
|
|
43478
|
+
if (this.options.modelParams) {
|
|
43479
|
+
deepMergeParams(requestPayload, this.options.modelParams);
|
|
43480
|
+
log(`[ComposedHandler] Merged --model-params (${Object.keys(this.options.modelParams).join(", ")}) for ${this.targetModel}`);
|
|
43481
|
+
}
|
|
42994
43482
|
if (this.provider.refreshAuth) {
|
|
42995
43483
|
try {
|
|
42996
43484
|
await this.provider.refreshAuth();
|
|
@@ -43650,6 +44138,9 @@ function getRecoveryHint(status, errorText, providerName, transportTerminal429)
|
|
|
43650
44138
|
return "Provider overloaded. Retry or use a different model.";
|
|
43651
44139
|
}
|
|
43652
44140
|
if (status === 429 && (transportTerminal429 ?? isTerminal429(errorText))) {
|
|
44141
|
+
if (hasPlanLimitWording(errorText)) {
|
|
44142
|
+
return "Plan limit reached \u2014 your allowance is spent for this cycle and refills on the provider's own schedule (see the message below). Wait, upgrade the plan, or switch provider.";
|
|
44143
|
+
}
|
|
43653
44144
|
return "Out of quota \u2014 check your plan & billing details. This won't recover on retry.";
|
|
43654
44145
|
}
|
|
43655
44146
|
if (status === 429 && transportTerminal429 === false) {
|
|
@@ -43666,6 +44157,9 @@ function getRecoveryHint(status, errorText, providerName, transportTerminal429)
|
|
|
43666
44157
|
return "Model not supported by this provider. Verify model name.";
|
|
43667
44158
|
}
|
|
43668
44159
|
if (isQuotaExhaustionError(status, errorText)) {
|
|
44160
|
+
if (hasPlanLimitWording(errorText)) {
|
|
44161
|
+
return "Plan limit reached \u2014 your allowance is spent for this cycle and refills on the provider's own schedule (see the message below). Wait, upgrade the plan, or switch provider.";
|
|
44162
|
+
}
|
|
43669
44163
|
return "Out of quota \u2014 check your plan & billing details. This won't recover on retry.";
|
|
43670
44164
|
}
|
|
43671
44165
|
if (hasActionableLink(errorText)) {
|
|
@@ -43701,6 +44195,8 @@ var init_composed_handler = __esm(() => {
|
|
|
43701
44195
|
init_middleware();
|
|
43702
44196
|
init_openai();
|
|
43703
44197
|
init_vision_proxy();
|
|
44198
|
+
init_session_events();
|
|
44199
|
+
init_pro_injection();
|
|
43704
44200
|
init_stats();
|
|
43705
44201
|
init_telemetry();
|
|
43706
44202
|
init_transform();
|
|
@@ -43724,11 +44220,11 @@ var init_composed_handler = __esm(() => {
|
|
|
43724
44220
|
});
|
|
43725
44221
|
|
|
43726
44222
|
// src/providers/api-key-provenance.ts
|
|
43727
|
-
import { existsSync as
|
|
43728
|
-
import { homedir as
|
|
43729
|
-
import { join as
|
|
44223
|
+
import { existsSync as existsSync18, readFileSync as readFileSync17 } from "fs";
|
|
44224
|
+
import { homedir as homedir26 } from "os";
|
|
44225
|
+
import { join as join26, resolve as resolve2 } from "path";
|
|
43730
44226
|
function activeConfigPath() {
|
|
43731
|
-
return activeGlobalConfigFile(
|
|
44227
|
+
return activeGlobalConfigFile(join26(homedir26(), ".claudish", "config.json"));
|
|
43732
44228
|
}
|
|
43733
44229
|
function configLayerLabel() {
|
|
43734
44230
|
return getConfigFileOverride() ? activeConfigPath() : "~/.claudish/config.json";
|
|
@@ -43808,9 +44304,9 @@ function formatProvenanceLog(p) {
|
|
|
43808
44304
|
function readDotenvKey(envVars) {
|
|
43809
44305
|
try {
|
|
43810
44306
|
const dotenvPath = resolve2(".env");
|
|
43811
|
-
if (!
|
|
44307
|
+
if (!existsSync18(dotenvPath))
|
|
43812
44308
|
return null;
|
|
43813
|
-
const parsed = import_dotenv.parse(
|
|
44309
|
+
const parsed = import_dotenv.parse(readFileSync17(dotenvPath, "utf-8"));
|
|
43814
44310
|
for (const v of envVars) {
|
|
43815
44311
|
if (parsed[v])
|
|
43816
44312
|
return parsed[v];
|
|
@@ -43823,9 +44319,9 @@ function readDotenvKey(envVars) {
|
|
|
43823
44319
|
function readConfigKey(envVar) {
|
|
43824
44320
|
try {
|
|
43825
44321
|
const configPath = activeConfigPath();
|
|
43826
|
-
if (!
|
|
44322
|
+
if (!existsSync18(configPath))
|
|
43827
44323
|
return null;
|
|
43828
|
-
const cfg = JSON.parse(
|
|
44324
|
+
const cfg = JSON.parse(readFileSync17(configPath, "utf-8"));
|
|
43829
44325
|
return cfg.apiKeys?.[envVar] || null;
|
|
43830
44326
|
} catch {
|
|
43831
44327
|
return null;
|
|
@@ -48339,9 +48835,9 @@ __export(exports_session_discovery, {
|
|
|
48339
48835
|
transcriptPathFor: () => transcriptPathFor
|
|
48340
48836
|
});
|
|
48341
48837
|
import { execFile, execFileSync as execFileSync2 } from "child_process";
|
|
48342
|
-
import { closeSync as
|
|
48343
|
-
import { homedir as
|
|
48344
|
-
import { basename, join as
|
|
48838
|
+
import { closeSync as closeSync6, openSync as openSync6, readSync as readSync2, readdirSync as readdirSync4, realpathSync, statSync as statSync5 } from "fs";
|
|
48839
|
+
import { homedir as homedir27 } from "os";
|
|
48840
|
+
import { basename, join as join27 } from "path";
|
|
48345
48841
|
function slugForPath(absPath) {
|
|
48346
48842
|
return absPath.replace(/[/.]/g, "-");
|
|
48347
48843
|
}
|
|
@@ -48350,7 +48846,7 @@ function transcriptPathFor(cwd, sessionUuid) {
|
|
|
48350
48846
|
try {
|
|
48351
48847
|
real = realpathSync(cwd);
|
|
48352
48848
|
} catch {}
|
|
48353
|
-
return
|
|
48849
|
+
return join27(PROJECTS_DIR, slugForPath(real), `${sessionUuid}.jsonl`);
|
|
48354
48850
|
}
|
|
48355
48851
|
function isAgentSession(row) {
|
|
48356
48852
|
return row.entrypoint !== undefined && row.entrypoint !== "cli";
|
|
@@ -48391,24 +48887,24 @@ function getRepoContext(cwd = process.cwd()) {
|
|
|
48391
48887
|
}
|
|
48392
48888
|
function projectDirs() {
|
|
48393
48889
|
try {
|
|
48394
|
-
return
|
|
48890
|
+
return readdirSync4(PROJECTS_DIR, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name);
|
|
48395
48891
|
} catch {
|
|
48396
48892
|
return [];
|
|
48397
48893
|
}
|
|
48398
48894
|
}
|
|
48399
48895
|
function sessionsIn(dirName) {
|
|
48400
|
-
const dir =
|
|
48896
|
+
const dir = join27(PROJECTS_DIR, dirName);
|
|
48401
48897
|
let names;
|
|
48402
48898
|
try {
|
|
48403
|
-
names =
|
|
48899
|
+
names = readdirSync4(dir).filter((n) => n.endsWith(".jsonl"));
|
|
48404
48900
|
} catch {
|
|
48405
48901
|
return [];
|
|
48406
48902
|
}
|
|
48407
48903
|
const rows = [];
|
|
48408
48904
|
for (const n of names) {
|
|
48409
|
-
const file2 =
|
|
48905
|
+
const file2 = join27(dir, n);
|
|
48410
48906
|
try {
|
|
48411
|
-
const st =
|
|
48907
|
+
const st = statSync5(file2);
|
|
48412
48908
|
if (st.size === 0)
|
|
48413
48909
|
continue;
|
|
48414
48910
|
const row = {
|
|
@@ -48568,7 +49064,7 @@ function discoverWorktreeGroups(repo) {
|
|
|
48568
49064
|
g.activeNow = g.sessions.some((s) => isActive(s));
|
|
48569
49065
|
if (g.path) {
|
|
48570
49066
|
try {
|
|
48571
|
-
g.createdMs =
|
|
49067
|
+
g.createdMs = statSync5(g.path).birthtimeMs;
|
|
48572
49068
|
} catch {}
|
|
48573
49069
|
}
|
|
48574
49070
|
if (!g.createdMs && g.sessions.length > 0) {
|
|
@@ -48586,16 +49082,16 @@ function readChunk(file2, pos, len) {
|
|
|
48586
49082
|
return "";
|
|
48587
49083
|
let fd = null;
|
|
48588
49084
|
try {
|
|
48589
|
-
fd =
|
|
49085
|
+
fd = openSync6(file2, "r");
|
|
48590
49086
|
const buf = Buffer.allocUnsafe(len);
|
|
48591
|
-
const n =
|
|
49087
|
+
const n = readSync2(fd, buf, 0, len, pos);
|
|
48592
49088
|
return buf.subarray(0, n).toString("utf-8");
|
|
48593
49089
|
} catch {
|
|
48594
49090
|
return "";
|
|
48595
49091
|
} finally {
|
|
48596
49092
|
if (fd !== null) {
|
|
48597
49093
|
try {
|
|
48598
|
-
|
|
49094
|
+
closeSync6(fd);
|
|
48599
49095
|
} catch {}
|
|
48600
49096
|
}
|
|
48601
49097
|
}
|
|
@@ -48656,7 +49152,7 @@ function hydrateSession(row) {
|
|
|
48656
49152
|
row.hydrated = true;
|
|
48657
49153
|
if (isActive(row)) {
|
|
48658
49154
|
try {
|
|
48659
|
-
row.sizeBytes =
|
|
49155
|
+
row.sizeBytes = statSync5(row.file).size;
|
|
48660
49156
|
} catch {}
|
|
48661
49157
|
}
|
|
48662
49158
|
const head = parseRecords(readChunk(row.file, 0, Math.min(HEAD_BYTES, row.sizeBytes)), false);
|
|
@@ -48765,7 +49261,7 @@ function findLatestSessionId(cwd = process.cwd(), sinceMs = 0) {
|
|
|
48765
49261
|
}
|
|
48766
49262
|
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;
|
|
48767
49263
|
var init_session_discovery = __esm(() => {
|
|
48768
|
-
PROJECTS_DIR =
|
|
49264
|
+
PROJECTS_DIR = join27(homedir27(), ".claude", "projects");
|
|
48769
49265
|
HEAD_BYTES = 64 * 1024;
|
|
48770
49266
|
TAIL_BYTES = 128 * 1024;
|
|
48771
49267
|
HARNESS_ENVELOPES = [
|
|
@@ -48790,19 +49286,19 @@ function resolveClaudishSpawn(env = process.env) {
|
|
|
48790
49286
|
var CLAUDISH_BIN_ENV = "CLAUDISH_BIN";
|
|
48791
49287
|
|
|
48792
49288
|
// src/team-stats.ts
|
|
48793
|
-
import { existsSync as
|
|
48794
|
-
import { join as
|
|
49289
|
+
import { existsSync as existsSync19, readFileSync as readFileSync18, writeFileSync as writeFileSync10 } from "fs";
|
|
49290
|
+
import { join as join28 } from "path";
|
|
48795
49291
|
function statsDir(sessionPath) {
|
|
48796
|
-
return
|
|
49292
|
+
return join28(sessionPath, "stats");
|
|
48797
49293
|
}
|
|
48798
49294
|
function tokenFileFor(sessionPath, anonId) {
|
|
48799
|
-
return
|
|
49295
|
+
return join28(statsDir(sessionPath), `${anonId}.json`);
|
|
48800
49296
|
}
|
|
48801
49297
|
function readTokenStatsAt(path) {
|
|
48802
|
-
if (!
|
|
49298
|
+
if (!existsSync19(path))
|
|
48803
49299
|
return null;
|
|
48804
49300
|
try {
|
|
48805
|
-
return JSON.parse(
|
|
49301
|
+
return JSON.parse(readFileSync18(path, "utf-8"));
|
|
48806
49302
|
} catch {
|
|
48807
49303
|
return null;
|
|
48808
49304
|
}
|
|
@@ -48953,7 +49449,7 @@ ${segs.join(" \xB7 ")}`;
|
|
|
48953
49449
|
}
|
|
48954
49450
|
function writeStatusFile(sessionPath, manifest, status, opts) {
|
|
48955
49451
|
try {
|
|
48956
|
-
writeFileSync10(
|
|
49452
|
+
writeFileSync10(join28(sessionPath, "status.txt"), `${renderTeamStats(sessionPath, manifest, status, opts)}
|
|
48957
49453
|
`, "utf-8");
|
|
48958
49454
|
} catch {}
|
|
48959
49455
|
}
|
|
@@ -48985,13 +49481,13 @@ __export(exports_team_orchestrator, {
|
|
|
48985
49481
|
import { spawn as spawn2 } from "child_process";
|
|
48986
49482
|
import {
|
|
48987
49483
|
createWriteStream,
|
|
48988
|
-
existsSync as
|
|
49484
|
+
existsSync as existsSync20,
|
|
48989
49485
|
mkdirSync as mkdirSync11,
|
|
48990
|
-
readFileSync as
|
|
48991
|
-
readdirSync as
|
|
49486
|
+
readFileSync as readFileSync19,
|
|
49487
|
+
readdirSync as readdirSync5,
|
|
48992
49488
|
writeFileSync as writeFileSync11
|
|
48993
49489
|
} from "fs";
|
|
48994
|
-
import { join as
|
|
49490
|
+
import { join as join29, resolve as resolve3 } from "path";
|
|
48995
49491
|
function resolveCaptureMode(explicit, env = process.env) {
|
|
48996
49492
|
if (explicit)
|
|
48997
49493
|
return explicit;
|
|
@@ -49080,14 +49576,14 @@ function setupSession(sessionPath, models, input) {
|
|
|
49080
49576
|
if (models.length === 0) {
|
|
49081
49577
|
throw new Error("At least one model is required");
|
|
49082
49578
|
}
|
|
49083
|
-
if (
|
|
49579
|
+
if (existsSync20(join29(sessionPath, "manifest.json"))) {
|
|
49084
49580
|
throw new Error(`Session already exists at ${sessionPath}. Use a new directory path or delete the existing session first.`);
|
|
49085
49581
|
}
|
|
49086
|
-
mkdirSync11(
|
|
49087
|
-
mkdirSync11(
|
|
49582
|
+
mkdirSync11(join29(sessionPath, "work"), { recursive: true });
|
|
49583
|
+
mkdirSync11(join29(sessionPath, "errors"), { recursive: true });
|
|
49088
49584
|
if (input !== undefined) {
|
|
49089
|
-
writeFileSync11(
|
|
49090
|
-
} else if (!
|
|
49585
|
+
writeFileSync11(join29(sessionPath, "input.md"), input, "utf-8");
|
|
49586
|
+
} else if (!existsSync20(join29(sessionPath, "input.md"))) {
|
|
49091
49587
|
throw new Error(`No input.md found at ${sessionPath} and no input provided`);
|
|
49092
49588
|
}
|
|
49093
49589
|
const ids = models.map((_, i) => String(i + 1).padStart(2, "0"));
|
|
@@ -49104,9 +49600,9 @@ function setupSession(sessionPath, models, input) {
|
|
|
49104
49600
|
model: models[i],
|
|
49105
49601
|
assignedAt: now2
|
|
49106
49602
|
};
|
|
49107
|
-
mkdirSync11(
|
|
49603
|
+
mkdirSync11(join29(sessionPath, "work", anonId), { recursive: true });
|
|
49108
49604
|
}
|
|
49109
|
-
writeFileSync11(
|
|
49605
|
+
writeFileSync11(join29(sessionPath, "manifest.json"), JSON.stringify(manifest, null, 2), "utf-8");
|
|
49110
49606
|
const status = {
|
|
49111
49607
|
startedAt: now2,
|
|
49112
49608
|
models: Object.fromEntries(Object.keys(manifest.models).map((id) => [
|
|
@@ -49120,7 +49616,7 @@ function setupSession(sessionPath, models, input) {
|
|
|
49120
49616
|
}
|
|
49121
49617
|
]))
|
|
49122
49618
|
};
|
|
49123
|
-
writeFileSync11(
|
|
49619
|
+
writeFileSync11(join29(sessionPath, "status.json"), JSON.stringify(status, null, 2), "utf-8");
|
|
49124
49620
|
return manifest;
|
|
49125
49621
|
}
|
|
49126
49622
|
function assertValidRequirePattern(pattern) {
|
|
@@ -49137,7 +49633,7 @@ function readFullOutputIfNeeded(opts) {
|
|
|
49137
49633
|
if (crashed || !requirePattern || outputSize <= STDOUT_TAIL_LIMIT)
|
|
49138
49634
|
return;
|
|
49139
49635
|
try {
|
|
49140
|
-
return
|
|
49636
|
+
return readFileSync19(outputPath, "utf-8");
|
|
49141
49637
|
} catch {
|
|
49142
49638
|
return;
|
|
49143
49639
|
}
|
|
@@ -49145,12 +49641,12 @@ function readFullOutputIfNeeded(opts) {
|
|
|
49145
49641
|
async function runModels(sessionPath, opts = {}) {
|
|
49146
49642
|
const timeoutMs = (opts.timeout ?? 300) * 1000;
|
|
49147
49643
|
assertValidRequirePattern(opts.requirePattern);
|
|
49148
|
-
const manifest = JSON.parse(
|
|
49149
|
-
const statusPath =
|
|
49150
|
-
const inputPath =
|
|
49151
|
-
const inputContent =
|
|
49644
|
+
const manifest = JSON.parse(readFileSync19(join29(sessionPath, "manifest.json"), "utf-8"));
|
|
49645
|
+
const statusPath = join29(sessionPath, "status.json");
|
|
49646
|
+
const inputPath = join29(sessionPath, "input.md");
|
|
49647
|
+
const inputContent = readFileSync19(inputPath, "utf-8");
|
|
49152
49648
|
const spawnPlan = await (opts.spawnPlanner ?? prehydrateCredentialsForSpawn)(Object.values(manifest.models).map((m) => m.model));
|
|
49153
|
-
const statusCache = JSON.parse(
|
|
49649
|
+
const statusCache = JSON.parse(readFileSync19(statusPath, "utf-8"));
|
|
49154
49650
|
function updateModelStatus(id, update) {
|
|
49155
49651
|
statusCache.models[id] = { ...statusCache.models[id], ...update };
|
|
49156
49652
|
writeFileSync11(statusPath, JSON.stringify(statusCache, null, 2), "utf-8");
|
|
@@ -49198,8 +49694,8 @@ async function runModels(sessionPath, opts = {}) {
|
|
|
49198
49694
|
process.on("SIGINT", sigintHandler);
|
|
49199
49695
|
const completionPromises = [];
|
|
49200
49696
|
for (const [anonId, entry] of Object.entries(manifest.models)) {
|
|
49201
|
-
const outputPath =
|
|
49202
|
-
const errorLogPath =
|
|
49697
|
+
const outputPath = join29(sessionPath, `response-${anonId}.md`);
|
|
49698
|
+
const errorLogPath = join29(sessionPath, "errors", `${anonId}.log`);
|
|
49203
49699
|
const spawnModel = spawnPlan.pinned.get(entry.model) ?? entry.model;
|
|
49204
49700
|
const args = [
|
|
49205
49701
|
"--model",
|
|
@@ -49425,7 +49921,7 @@ async function runModels(sessionPath, opts = {}) {
|
|
|
49425
49921
|
opts.onStatusChange?.(id, statusCache.models[id]);
|
|
49426
49922
|
const stopped = await terminateChildTree(proc);
|
|
49427
49923
|
if (!stopped) {
|
|
49428
|
-
persistErrorLog(rt?.errorLogPath ??
|
|
49924
|
+
persistErrorLog(rt?.errorLogPath ?? join29(sessionPath, "errors", `${id}.log`), "TIMEOUT: child survived SIGKILL \u2014 it may still be running and billing", stderr, stdoutTail);
|
|
49429
49925
|
}
|
|
49430
49926
|
};
|
|
49431
49927
|
const allDone = Promise.all(completionPromises);
|
|
@@ -49477,30 +49973,30 @@ async function runModels(sessionPath, opts = {}) {
|
|
|
49477
49973
|
return statusCache;
|
|
49478
49974
|
}
|
|
49479
49975
|
async function judgeResponses(sessionPath, opts = {}) {
|
|
49480
|
-
const responseFiles =
|
|
49976
|
+
const responseFiles = readdirSync5(sessionPath).filter((f) => f.startsWith("response-") && f.endsWith(".md")).sort();
|
|
49481
49977
|
if (responseFiles.length < 2) {
|
|
49482
49978
|
throw new Error(`Need at least 2 responses to judge, found ${responseFiles.length}`);
|
|
49483
49979
|
}
|
|
49484
49980
|
const responses = {};
|
|
49485
49981
|
for (const file2 of responseFiles) {
|
|
49486
49982
|
const id = file2.replace(/^response-/, "").replace(/\.md$/, "");
|
|
49487
|
-
responses[id] =
|
|
49983
|
+
responses[id] = readFileSync19(join29(sessionPath, file2), "utf-8");
|
|
49488
49984
|
}
|
|
49489
|
-
const input =
|
|
49985
|
+
const input = readFileSync19(join29(sessionPath, "input.md"), "utf-8");
|
|
49490
49986
|
const judgePrompt = buildJudgePrompt(input, responses);
|
|
49491
|
-
writeFileSync11(
|
|
49987
|
+
writeFileSync11(join29(sessionPath, "judge-prompt.md"), judgePrompt, "utf-8");
|
|
49492
49988
|
const judgeModels = opts.judges ?? getDefaultJudgeModels(sessionPath);
|
|
49493
|
-
const judgePath =
|
|
49989
|
+
const judgePath = join29(sessionPath, "judging");
|
|
49494
49990
|
mkdirSync11(judgePath, { recursive: true });
|
|
49495
49991
|
setupSession(judgePath, judgeModels, judgePrompt);
|
|
49496
49992
|
await runModels(judgePath, { claudeFlags: opts.claudeFlags });
|
|
49497
49993
|
const votes = parseJudgeVotes(judgePath, Object.keys(responses));
|
|
49498
49994
|
const verdict = aggregateVerdict(votes, Object.keys(responses));
|
|
49499
|
-
writeFileSync11(
|
|
49995
|
+
writeFileSync11(join29(sessionPath, "verdict.md"), formatVerdict(verdict, sessionPath), "utf-8");
|
|
49500
49996
|
return verdict;
|
|
49501
49997
|
}
|
|
49502
49998
|
function getStatus(sessionPath) {
|
|
49503
|
-
return JSON.parse(
|
|
49999
|
+
return JSON.parse(readFileSync19(join29(sessionPath, "status.json"), "utf-8"));
|
|
49504
50000
|
}
|
|
49505
50001
|
function fisherYatesShuffle(arr) {
|
|
49506
50002
|
for (let i = arr.length - 1;i > 0; i--) {
|
|
@@ -49510,7 +50006,7 @@ function fisherYatesShuffle(arr) {
|
|
|
49510
50006
|
return arr;
|
|
49511
50007
|
}
|
|
49512
50008
|
function getDefaultJudgeModels(sessionPath) {
|
|
49513
|
-
const manifest = JSON.parse(
|
|
50009
|
+
const manifest = JSON.parse(readFileSync19(join29(sessionPath, "manifest.json"), "utf-8"));
|
|
49514
50010
|
return Object.values(manifest.models).map((e) => e.model);
|
|
49515
50011
|
}
|
|
49516
50012
|
function buildJudgePrompt(input, responses) {
|
|
@@ -49568,12 +50064,12 @@ function buildJudgePrompt(input, responses) {
|
|
|
49568
50064
|
}
|
|
49569
50065
|
function parseJudgeVotes(judgePath, responseIds) {
|
|
49570
50066
|
const votes = [];
|
|
49571
|
-
const responseFiles =
|
|
50067
|
+
const responseFiles = readdirSync5(judgePath).filter((f) => f.startsWith("response-") && f.endsWith(".md")).sort();
|
|
49572
50068
|
for (const file2 of responseFiles) {
|
|
49573
50069
|
const judgeId = file2.replace(/^response-/, "").replace(/\.md$/, "");
|
|
49574
50070
|
let content;
|
|
49575
50071
|
try {
|
|
49576
|
-
content =
|
|
50072
|
+
content = readFileSync19(join29(judgePath, file2), "utf-8");
|
|
49577
50073
|
} catch {
|
|
49578
50074
|
continue;
|
|
49579
50075
|
}
|
|
@@ -49625,7 +50121,7 @@ function aggregateVerdict(votes, responseIds) {
|
|
|
49625
50121
|
function formatVerdict(verdict, sessionPath) {
|
|
49626
50122
|
let manifest = null;
|
|
49627
50123
|
try {
|
|
49628
|
-
manifest = JSON.parse(
|
|
50124
|
+
manifest = JSON.parse(readFileSync19(join29(sessionPath, "manifest.json"), "utf-8"));
|
|
49629
50125
|
} catch {}
|
|
49630
50126
|
let output = `# Team Verdict
|
|
49631
50127
|
|
|
@@ -49676,17 +50172,17 @@ import { spawn as spawn3 } from "child_process";
|
|
|
49676
50172
|
import { randomUUID as randomUUID4 } from "crypto";
|
|
49677
50173
|
import {
|
|
49678
50174
|
appendFileSync as appendFileSync6,
|
|
49679
|
-
closeSync as
|
|
50175
|
+
closeSync as closeSync7,
|
|
49680
50176
|
createWriteStream as createWriteStream2,
|
|
49681
50177
|
mkdirSync as mkdirSync12,
|
|
49682
|
-
openSync as
|
|
49683
|
-
readFileSync as
|
|
49684
|
-
readSync as
|
|
49685
|
-
statSync as
|
|
50178
|
+
openSync as openSync7,
|
|
50179
|
+
readFileSync as readFileSync20,
|
|
50180
|
+
readSync as readSync3,
|
|
50181
|
+
statSync as statSync6,
|
|
49686
50182
|
writeFileSync as writeFileSync12
|
|
49687
50183
|
} from "fs";
|
|
49688
|
-
import { homedir as
|
|
49689
|
-
import { join as
|
|
50184
|
+
import { homedir as homedir28 } from "os";
|
|
50185
|
+
import { join as join30, resolve as resolve4, sep } from "path";
|
|
49690
50186
|
import { StringDecoder } from "string_decoder";
|
|
49691
50187
|
function buildChannelSpawnArgs(opts) {
|
|
49692
50188
|
return [
|
|
@@ -49724,21 +50220,21 @@ function decodeChunk(decoder, chunk) {
|
|
|
49724
50220
|
function readTailText(path, maxBytes) {
|
|
49725
50221
|
let fd = null;
|
|
49726
50222
|
try {
|
|
49727
|
-
const size =
|
|
50223
|
+
const size = statSync6(path).size;
|
|
49728
50224
|
if (size === 0)
|
|
49729
50225
|
return { text: "", truncated: false };
|
|
49730
50226
|
const start = Math.max(0, size - maxBytes);
|
|
49731
50227
|
const length = size - start;
|
|
49732
50228
|
const buf = Buffer.alloc(length);
|
|
49733
|
-
fd =
|
|
49734
|
-
|
|
50229
|
+
fd = openSync7(path, "r");
|
|
50230
|
+
readSync3(fd, buf, 0, length, start);
|
|
49735
50231
|
return { text: buf.toString("utf-8"), truncated: start > 0 };
|
|
49736
50232
|
} catch {
|
|
49737
50233
|
return null;
|
|
49738
50234
|
} finally {
|
|
49739
50235
|
if (fd !== null) {
|
|
49740
50236
|
try {
|
|
49741
|
-
|
|
50237
|
+
closeSync7(fd);
|
|
49742
50238
|
} catch {}
|
|
49743
50239
|
}
|
|
49744
50240
|
}
|
|
@@ -49755,7 +50251,7 @@ function readTailLines(path, maxBytes) {
|
|
|
49755
50251
|
}
|
|
49756
50252
|
function fileSize(path) {
|
|
49757
50253
|
try {
|
|
49758
|
-
return
|
|
50254
|
+
return statSync6(path).size;
|
|
49759
50255
|
} catch {
|
|
49760
50256
|
return 0;
|
|
49761
50257
|
}
|
|
@@ -49764,7 +50260,7 @@ function readJsonObject(path, maxBytes) {
|
|
|
49764
50260
|
try {
|
|
49765
50261
|
if (fileSize(path) > maxBytes)
|
|
49766
50262
|
return null;
|
|
49767
|
-
const parsed = JSON.parse(
|
|
50263
|
+
const parsed = JSON.parse(readFileSync20(path, "utf-8"));
|
|
49768
50264
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
|
|
49769
50265
|
return null;
|
|
49770
50266
|
return parsed;
|
|
@@ -49780,7 +50276,7 @@ function dropLeadingFragment(tail) {
|
|
|
49780
50276
|
return firstBreak === -1 ? tail.text : tail.text.slice(firstBreak + 1);
|
|
49781
50277
|
}
|
|
49782
50278
|
function diskAccounting(sessionDir) {
|
|
49783
|
-
const stats = readTokenStatsAt(
|
|
50279
|
+
const stats = readTokenStatsAt(join30(sessionDir, "tokens.json"));
|
|
49784
50280
|
return {
|
|
49785
50281
|
tokensUsed: (stats?.total_tokens ?? 0) || (stats?.input_tokens ?? 0) + (stats?.output_tokens ?? 0),
|
|
49786
50282
|
costUsd: stats?.total_cost ?? 0,
|
|
@@ -49820,7 +50316,7 @@ class SessionManager {
|
|
|
49820
50316
|
this.maxSessions = options?.maxSessions ?? DEFAULT_MAX_SESSIONS;
|
|
49821
50317
|
this.scrollbackCapacity = options?.scrollbackCapacity ?? DEFAULT_SCROLLBACK;
|
|
49822
50318
|
this.terminalRetentionMs = options?.terminalRetentionMs ?? TERMINAL_RETENTION_MS;
|
|
49823
|
-
this.sessionsDir = options?.sessionsDir ?? process.env.CLAUDISH_SESSIONS_DIR ??
|
|
50319
|
+
this.sessionsDir = options?.sessionsDir ?? process.env.CLAUDISH_SESSIONS_DIR ?? join30(homedir28(), ".claudish", "sessions");
|
|
49824
50320
|
this.stallSeconds = options?.stallSeconds;
|
|
49825
50321
|
this.onStateChange = options?.onStateChange;
|
|
49826
50322
|
}
|
|
@@ -49833,19 +50329,19 @@ class SessionManager {
|
|
|
49833
50329
|
const claudeSessionId = randomUUID4();
|
|
49834
50330
|
const timeout = Math.min(opts.timeoutSeconds ?? DEFAULT_TIMEOUT, MAX_TIMEOUT);
|
|
49835
50331
|
const startedAt = new Date().toISOString();
|
|
49836
|
-
const sessionDir =
|
|
50332
|
+
const sessionDir = join30(this.sessionsDir, sessionId2);
|
|
49837
50333
|
mkdirSync12(sessionDir, { recursive: true });
|
|
49838
50334
|
if (opts.prompt) {
|
|
49839
|
-
writeFileSync12(
|
|
50335
|
+
writeFileSync12(join30(sessionDir, "prompt.md"), opts.prompt, "utf-8");
|
|
49840
50336
|
}
|
|
49841
50337
|
const args = buildChannelSpawnArgs({
|
|
49842
50338
|
model: opts.spawnModel ?? opts.model,
|
|
49843
50339
|
claudeSessionId,
|
|
49844
50340
|
claudishFlags: opts.claudishFlags
|
|
49845
50341
|
});
|
|
49846
|
-
const tokenFile =
|
|
49847
|
-
const eventLogPath =
|
|
49848
|
-
const upstreamErrorLogPath =
|
|
50342
|
+
const tokenFile = join30(sessionDir, "tokens.json");
|
|
50343
|
+
const eventLogPath = join30(sessionDir, "events.jsonl");
|
|
50344
|
+
const upstreamErrorLogPath = join30(sessionDir, "upstream-errors.jsonl");
|
|
49849
50345
|
const cwd = opts.cwd ?? process.cwd();
|
|
49850
50346
|
const spawnTarget = resolveClaudishSpawn();
|
|
49851
50347
|
const proc = spawn3(spawnTarget.command, [...spawnTarget.prefixArgs, ...args], {
|
|
@@ -49860,7 +50356,7 @@ class SessionManager {
|
|
|
49860
50356
|
}
|
|
49861
50357
|
});
|
|
49862
50358
|
const scrollback = new ScrollbackBuffer(this.scrollbackCapacity);
|
|
49863
|
-
const outputLogStream = createWriteStream2(
|
|
50359
|
+
const outputLogStream = createWriteStream2(join30(sessionDir, "output.log"));
|
|
49864
50360
|
const entry = {
|
|
49865
50361
|
info: {
|
|
49866
50362
|
sessionId: sessionId2,
|
|
@@ -50144,7 +50640,7 @@ class SessionManager {
|
|
|
50144
50640
|
return null;
|
|
50145
50641
|
const root = resolve4(this.sessionsDir);
|
|
50146
50642
|
const dir = resolve4(root, sessionId2);
|
|
50147
|
-
if (dir !==
|
|
50643
|
+
if (dir !== join30(root, sessionId2))
|
|
50148
50644
|
return null;
|
|
50149
50645
|
if (!dir.startsWith(root + sep))
|
|
50150
50646
|
return null;
|
|
@@ -50156,14 +50652,14 @@ class SessionManager {
|
|
|
50156
50652
|
return null;
|
|
50157
50653
|
let dirMtimeMs;
|
|
50158
50654
|
try {
|
|
50159
|
-
const stat2 =
|
|
50655
|
+
const stat2 = statSync6(sessionDir);
|
|
50160
50656
|
if (!stat2.isDirectory())
|
|
50161
50657
|
return null;
|
|
50162
50658
|
dirMtimeMs = stat2.mtimeMs;
|
|
50163
50659
|
} catch {
|
|
50164
50660
|
return null;
|
|
50165
50661
|
}
|
|
50166
|
-
const meta3 = readJsonObject(
|
|
50662
|
+
const meta3 = readJsonObject(join30(sessionDir, "meta.json"), META_READ_LIMIT);
|
|
50167
50663
|
const partial2 = meta3 === null;
|
|
50168
50664
|
const measured = diskAccounting(sessionDir);
|
|
50169
50665
|
const startedAt = metaString(meta3?.startedAt) ?? new Date(dirMtimeMs).toISOString();
|
|
@@ -50192,7 +50688,7 @@ class SessionManager {
|
|
|
50192
50688
|
};
|
|
50193
50689
|
}
|
|
50194
50690
|
diskOutput(record4, tailLines) {
|
|
50195
|
-
const tail = readTailText(
|
|
50691
|
+
const tail = readTailText(join30(record4.sessionDir, "output.log"), OUTPUT_TAIL_BYTES);
|
|
50196
50692
|
const buffer = new ScrollbackBuffer(this.scrollbackCapacity);
|
|
50197
50693
|
if (tail?.text)
|
|
50198
50694
|
buffer.append(dropLeadingFragment(tail));
|
|
@@ -50210,9 +50706,9 @@ class SessionManager {
|
|
|
50210
50706
|
}
|
|
50211
50707
|
diskDiagnostics(record4, limit) {
|
|
50212
50708
|
const { sessionDir, info } = record4;
|
|
50213
|
-
const eventLogPath =
|
|
50214
|
-
const upstreamErrorLogPath =
|
|
50215
|
-
const outputLogPath =
|
|
50709
|
+
const eventLogPath = join30(sessionDir, "events.jsonl");
|
|
50710
|
+
const upstreamErrorLogPath = join30(sessionDir, "upstream-errors.jsonl");
|
|
50711
|
+
const outputLogPath = join30(sessionDir, "output.log");
|
|
50216
50712
|
const events = readTailLines(eventLogPath, EVENT_TAIL_BYTES);
|
|
50217
50713
|
const outputTail = readTailText(outputLogPath, OUTPUT_TAIL_BYTES);
|
|
50218
50714
|
return {
|
|
@@ -50253,7 +50749,7 @@ class SessionManager {
|
|
|
50253
50749
|
};
|
|
50254
50750
|
}
|
|
50255
50751
|
diskStderrForDiagnostics(record4) {
|
|
50256
|
-
const tail = readTailText(
|
|
50752
|
+
const tail = readTailText(join30(record4.sessionDir, "stderr.log"), STDERR_READ_BYTES);
|
|
50257
50753
|
const raw = tail?.text ?? "";
|
|
50258
50754
|
const filtered = record4.info.status === "completed";
|
|
50259
50755
|
const source = filtered ? meaningfulStderr(raw) : raw;
|
|
@@ -50428,11 +50924,11 @@ ${STDERR_TRUNCATION_MARKER} ${STDERR_SIDE_LIMIT} bytes per end \u2026
|
|
|
50428
50924
|
entry.outputLogStream?.end();
|
|
50429
50925
|
entry.outputLogStream = null;
|
|
50430
50926
|
if (entry.stderr) {
|
|
50431
|
-
writeFileSync12(
|
|
50927
|
+
writeFileSync12(join30(entry.sessionDir, "stderr.log"), redactSecrets(entry.stderr), "utf-8");
|
|
50432
50928
|
}
|
|
50433
50929
|
this.refreshAccounting(entry);
|
|
50434
50930
|
entry.info.claudeSessionId = entry.reducer.claudeSessionId ?? entry.info.claudeSessionId;
|
|
50435
|
-
writeFileSync12(
|
|
50931
|
+
writeFileSync12(join30(entry.sessionDir, "meta.json"), JSON.stringify(entry.info, null, 2), "utf-8");
|
|
50436
50932
|
}
|
|
50437
50933
|
scheduleEviction(entry) {
|
|
50438
50934
|
if (entry.evictHandle)
|
|
@@ -50492,7 +50988,7 @@ ${STDERR_TRUNCATION_MARKER} ${STDERR_SIDE_LIMIT} bytes per end \u2026
|
|
|
50492
50988
|
return { state: "completed", content: "" };
|
|
50493
50989
|
}
|
|
50494
50990
|
refreshAccounting(entry) {
|
|
50495
|
-
const stats = readTokenStatsAt(
|
|
50991
|
+
const stats = readTokenStatsAt(join30(entry.sessionDir, "tokens.json"));
|
|
50496
50992
|
const fileTokens = (stats?.total_tokens ?? 0) || (stats?.input_tokens ?? 0) + (stats?.output_tokens ?? 0);
|
|
50497
50993
|
entry.info.tokensUsed = fileTokens || entry.reducer.tokens;
|
|
50498
50994
|
entry.info.costUsd = stats?.total_cost ?? 0;
|
|
@@ -50751,9 +51247,9 @@ function compareByReleaseDateDesc(a, b) {
|
|
|
50751
51247
|
}
|
|
50752
51248
|
|
|
50753
51249
|
// src/model-loader.ts
|
|
50754
|
-
import { existsSync as
|
|
50755
|
-
import { homedir as
|
|
50756
|
-
import { join as
|
|
51250
|
+
import { existsSync as existsSync21, mkdirSync as mkdirSync13, readFileSync as readFileSync21, writeFileSync as writeFileSync13 } from "fs";
|
|
51251
|
+
import { homedir as homedir29 } from "os";
|
|
51252
|
+
import { join as join31 } from "path";
|
|
50757
51253
|
function groupRecommendedModels(entries) {
|
|
50758
51254
|
const byId = new Map;
|
|
50759
51255
|
const categoryOrder = new Map;
|
|
@@ -50872,9 +51368,9 @@ async function getRecommendedModels(opts = {}) {
|
|
|
50872
51368
|
if (!forceRefresh && _cachedRecommendedModels) {
|
|
50873
51369
|
return _cachedRecommendedModels;
|
|
50874
51370
|
}
|
|
50875
|
-
if (!forceRefresh &&
|
|
51371
|
+
if (!forceRefresh && existsSync21(RECOMMENDED_MODELS_CACHE_PATH)) {
|
|
50876
51372
|
try {
|
|
50877
|
-
const cacheData = JSON.parse(
|
|
51373
|
+
const cacheData = JSON.parse(readFileSync21(RECOMMENDED_MODELS_CACHE_PATH, "utf-8"));
|
|
50878
51374
|
if (cacheData.models && cacheData.models.length > 0 && isFreshEnough(cacheData)) {
|
|
50879
51375
|
_cachedRecommendedModels = cacheData;
|
|
50880
51376
|
return cacheData;
|
|
@@ -50890,7 +51386,7 @@ async function getRecommendedModels(opts = {}) {
|
|
|
50890
51386
|
if (data.models && data.models.length > 0) {
|
|
50891
51387
|
_cachedRecommendedModels = data;
|
|
50892
51388
|
try {
|
|
50893
|
-
const cacheDir =
|
|
51389
|
+
const cacheDir = join31(homedir29(), ".claudish");
|
|
50894
51390
|
mkdirSync13(cacheDir, { recursive: true });
|
|
50895
51391
|
writeFileSync13(RECOMMENDED_MODELS_CACHE_PATH, JSON.stringify(data), "utf-8");
|
|
50896
51392
|
} catch {}
|
|
@@ -50903,9 +51399,9 @@ async function getRecommendedModels(opts = {}) {
|
|
|
50903
51399
|
function getRecommendedModelsSync() {
|
|
50904
51400
|
if (_cachedRecommendedModels)
|
|
50905
51401
|
return _cachedRecommendedModels;
|
|
50906
|
-
if (
|
|
51402
|
+
if (existsSync21(RECOMMENDED_MODELS_CACHE_PATH)) {
|
|
50907
51403
|
try {
|
|
50908
|
-
const cacheData = JSON.parse(
|
|
51404
|
+
const cacheData = JSON.parse(readFileSync21(RECOMMENDED_MODELS_CACHE_PATH, "utf-8"));
|
|
50909
51405
|
if (cacheData.models && cacheData.models.length > 0 && isFreshEnough(cacheData)) {
|
|
50910
51406
|
_cachedRecommendedModels = cacheData;
|
|
50911
51407
|
return cacheData;
|
|
@@ -51029,7 +51525,7 @@ var _cachedModelInfo = null, _cachedModelIds = null, _cachedRecommendedModels =
|
|
|
51029
51525
|
var init_model_loader = __esm(() => {
|
|
51030
51526
|
init_cache_ttl();
|
|
51031
51527
|
FIREBASE_RECOMMENDED_URL = `${FIREBASE_BASE_URL}?catalog=recommended`;
|
|
51032
|
-
RECOMMENDED_MODELS_CACHE_PATH =
|
|
51528
|
+
RECOMMENDED_MODELS_CACHE_PATH = join31(homedir29(), ".claudish", "recommended-models-cache.json");
|
|
51033
51529
|
FIREBASE_SLUG_TO_PROVIDER_NAME = {
|
|
51034
51530
|
openai: "openai",
|
|
51035
51531
|
google: "google",
|
|
@@ -51223,6 +51719,14 @@ function classifyHttpError(status, body, latencyMs) {
|
|
|
51223
51719
|
};
|
|
51224
51720
|
}
|
|
51225
51721
|
if (status === 429) {
|
|
51722
|
+
if (hasPlanLimitWording(body)) {
|
|
51723
|
+
return {
|
|
51724
|
+
state: "plan-limit",
|
|
51725
|
+
latencyMs,
|
|
51726
|
+
httpStatus: status,
|
|
51727
|
+
errorMessage: extractErrorMessage(body) || "Plan allowance spent for this cycle"
|
|
51728
|
+
};
|
|
51729
|
+
}
|
|
51226
51730
|
return {
|
|
51227
51731
|
state: "rate-limited",
|
|
51228
51732
|
latencyMs,
|
|
@@ -51231,6 +51735,14 @@ function classifyHttpError(status, body, latencyMs) {
|
|
|
51231
51735
|
};
|
|
51232
51736
|
}
|
|
51233
51737
|
if (upstream === 429 || status === 402) {
|
|
51738
|
+
if (status !== 402 && hasPlanLimitWording(body)) {
|
|
51739
|
+
return {
|
|
51740
|
+
state: "plan-limit",
|
|
51741
|
+
latencyMs,
|
|
51742
|
+
httpStatus: upstream ?? status,
|
|
51743
|
+
errorMessage: extractErrorMessage(body) || "Plan allowance spent for this cycle"
|
|
51744
|
+
};
|
|
51745
|
+
}
|
|
51234
51746
|
return {
|
|
51235
51747
|
state: "out-of-credit",
|
|
51236
51748
|
latencyMs,
|
|
@@ -51253,7 +51765,7 @@ function classifyHttpError(status, body, latencyMs) {
|
|
|
51253
51765
|
errorMessage: extractErrorMessage(body) || `HTTP ${status}`
|
|
51254
51766
|
};
|
|
51255
51767
|
}
|
|
51256
|
-
function truncateKeepingLink(text, max =
|
|
51768
|
+
function truncateKeepingLink(text, max = 400) {
|
|
51257
51769
|
if (text.length <= max)
|
|
51258
51770
|
return text;
|
|
51259
51771
|
const url2 = text.match(/https?:\/\/\S+/i)?.[0];
|
|
@@ -51470,6 +51982,8 @@ function describeProbeState(result) {
|
|
|
51470
51982
|
return withDetail(`rate limited \xB7 ${result.latencyMs}ms`, result.errorMessage);
|
|
51471
51983
|
case "out-of-credit":
|
|
51472
51984
|
return withDetail(`out of credit \xB7 ${status}${latency}`.trim(), result.errorMessage);
|
|
51985
|
+
case "plan-limit":
|
|
51986
|
+
return withDetail(`plan limit reached \xB7 ${status}${latency}`.trim(), result.errorMessage);
|
|
51473
51987
|
case "server-error":
|
|
51474
51988
|
return withDetail(`server error \xB7 ${status} \xB7 ${result.latencyMs}ms`, result.errorMessage);
|
|
51475
51989
|
case "timeout":
|
|
@@ -51486,12 +52000,13 @@ function isReadyState(state) {
|
|
|
51486
52000
|
return state === "live";
|
|
51487
52001
|
}
|
|
51488
52002
|
function isFailureState(state) {
|
|
51489
|
-
return state === "auth-failed" || state === "model-not-found" || state === "rate-limited" || state === "out-of-credit" || state === "server-error" || state === "timeout" || state === "network-error" || state === "error";
|
|
52003
|
+
return state === "auth-failed" || state === "model-not-found" || state === "rate-limited" || state === "out-of-credit" || state === "plan-limit" || state === "server-error" || state === "timeout" || state === "network-error" || state === "error";
|
|
51490
52004
|
}
|
|
51491
52005
|
var STREAM_MS_FLOOR = 50, OAUTH_PROVIDERS2, PROBE_PROMPT = "Count from one to twenty in words, one per line.", PROBE_MAX_TOKENS = 512, MINIMAL_EFFORT_UNSUPPORTED;
|
|
51492
52006
|
var init_probe_live = __esm(() => {
|
|
51493
52007
|
init_anthropic_error();
|
|
51494
52008
|
init_model_unsupported();
|
|
52009
|
+
init_quota_exhaustion();
|
|
51495
52010
|
OAUTH_PROVIDERS2 = new Set(["vertex", "antigravity", "devin"]);
|
|
51496
52011
|
MINIMAL_EFFORT_UNSUPPORTED = new Set(["native-anthropic", "anthropic"]);
|
|
51497
52012
|
});
|
|
@@ -54911,9 +55426,9 @@ var init_poe = __esm(() => {
|
|
|
54911
55426
|
});
|
|
54912
55427
|
|
|
54913
55428
|
// src/services/pricing-cache.ts
|
|
54914
|
-
import { existsSync as
|
|
54915
|
-
import { homedir as
|
|
54916
|
-
import { join as
|
|
55429
|
+
import { existsSync as existsSync22, readFileSync as readFileSync22, statSync as statSync7 } from "fs";
|
|
55430
|
+
import { homedir as homedir30 } from "os";
|
|
55431
|
+
import { join as join32 } from "path";
|
|
54917
55432
|
function prefixMatch(modelName) {
|
|
54918
55433
|
for (const [key, pricing] of pricingMap) {
|
|
54919
55434
|
if (modelName.startsWith(key))
|
|
@@ -54951,12 +55466,12 @@ async function warmPricingCache() {
|
|
|
54951
55466
|
}
|
|
54952
55467
|
function loadDiskCache() {
|
|
54953
55468
|
try {
|
|
54954
|
-
if (!
|
|
55469
|
+
if (!existsSync22(CACHE_FILE))
|
|
54955
55470
|
return false;
|
|
54956
|
-
const stat2 =
|
|
55471
|
+
const stat2 = statSync7(CACHE_FILE);
|
|
54957
55472
|
const age = Date.now() - stat2.mtimeMs;
|
|
54958
55473
|
const isFresh = age < CACHE_TTL_MS3;
|
|
54959
|
-
const raw2 =
|
|
55474
|
+
const raw2 = readFileSync22(CACHE_FILE, "utf-8");
|
|
54960
55475
|
const data = JSON.parse(raw2);
|
|
54961
55476
|
for (const [key, pricing] of Object.entries(data)) {
|
|
54962
55477
|
pricingMap.set(key, pricing);
|
|
@@ -54972,8 +55487,8 @@ var init_pricing_cache = __esm(() => {
|
|
|
54972
55487
|
init_logger();
|
|
54973
55488
|
init_catalog_query();
|
|
54974
55489
|
pricingMap = new Map;
|
|
54975
|
-
CACHE_DIR =
|
|
54976
|
-
CACHE_FILE =
|
|
55490
|
+
CACHE_DIR = join32(homedir30(), ".claudish");
|
|
55491
|
+
CACHE_FILE = join32(CACHE_DIR, "pricing-cache.json");
|
|
54977
55492
|
CACHE_TTL_MS3 = 24 * 60 * 60 * 1000;
|
|
54978
55493
|
});
|
|
54979
55494
|
|
|
@@ -54983,12 +55498,12 @@ __export(exports_proxy_server, {
|
|
|
54983
55498
|
createProxyServer: () => createProxyServer
|
|
54984
55499
|
});
|
|
54985
55500
|
import { appendFileSync as appendFileSync8, mkdirSync as mkdirSync14 } from "fs";
|
|
54986
|
-
import { join as
|
|
55501
|
+
import { join as join33 } from "path";
|
|
54987
55502
|
function maybeCaptureClassifierRequest(c, body) {
|
|
54988
55503
|
if (!process.env.CLAUDISH_CLASSIFIER_DEBUG)
|
|
54989
55504
|
return;
|
|
54990
55505
|
try {
|
|
54991
|
-
const dir =
|
|
55506
|
+
const dir = join33(process.cwd(), "logs");
|
|
54992
55507
|
if (!classifierCaptureDirReady) {
|
|
54993
55508
|
mkdirSync14(dir, { recursive: true });
|
|
54994
55509
|
classifierCaptureDirReady = true;
|
|
@@ -55013,7 +55528,7 @@ function maybeCaptureClassifierRequest(c, body) {
|
|
|
55013
55528
|
"x-api-key": c.req.header("x-api-key") ? "<present>" : null
|
|
55014
55529
|
}
|
|
55015
55530
|
};
|
|
55016
|
-
appendFileSync8(
|
|
55531
|
+
appendFileSync8(join33(dir, "classifier-capture.jsonl"), `${JSON.stringify(record4)}
|
|
55017
55532
|
`);
|
|
55018
55533
|
} catch {}
|
|
55019
55534
|
}
|
|
@@ -55036,6 +55551,11 @@ async function createProxyServer(port, _openrouterApiKey, model, monitorMode = f
|
|
|
55036
55551
|
log(`[Proxy] behavior hooks load skipped: ${err instanceof Error ? err.message : String(err)}`);
|
|
55037
55552
|
}
|
|
55038
55553
|
const nativeHandler = new NativeHandler(anthropicApiKey, options.advisorModels, options.advisorCollector);
|
|
55554
|
+
const requestShapingOpts = {
|
|
55555
|
+
effortOverride: isEffortLevel(options.effortOverride) ? options.effortOverride : undefined,
|
|
55556
|
+
modelParams: options.modelParams,
|
|
55557
|
+
proOnUltracode: options.proOnUltracode
|
|
55558
|
+
};
|
|
55039
55559
|
const openRouterHandlers = new Map;
|
|
55040
55560
|
const localProviderHandlers = new Map;
|
|
55041
55561
|
const remoteProviderHandlers = new Map;
|
|
@@ -55049,7 +55569,8 @@ async function createProxyServer(port, _openrouterApiKey, model, monitorMode = f
|
|
|
55049
55569
|
openRouterHandlers.set(modelId, new ComposedHandler(orProvider, modelId, modelId, port, {
|
|
55050
55570
|
adapter: orAdapter,
|
|
55051
55571
|
isInteractive: options.isInteractive,
|
|
55052
|
-
invocationMode
|
|
55572
|
+
invocationMode,
|
|
55573
|
+
...requestShapingOpts
|
|
55053
55574
|
}));
|
|
55054
55575
|
}
|
|
55055
55576
|
return openRouterHandlers.get(modelId);
|
|
@@ -55064,7 +55585,8 @@ async function createProxyServer(port, _openrouterApiKey, model, monitorMode = f
|
|
|
55064
55585
|
const poeTransport = new PoeProvider;
|
|
55065
55586
|
poeHandlers.set(modelId, new ComposedHandler(poeTransport, modelId, modelId, port, {
|
|
55066
55587
|
isInteractive: options.isInteractive,
|
|
55067
|
-
invocationMode
|
|
55588
|
+
invocationMode,
|
|
55589
|
+
...requestShapingOpts
|
|
55068
55590
|
}));
|
|
55069
55591
|
}
|
|
55070
55592
|
return poeHandlers.get(modelId);
|
|
@@ -55087,7 +55609,8 @@ async function createProxyServer(port, _openrouterApiKey, model, monitorMode = f
|
|
|
55087
55609
|
tokenStrategy: "local",
|
|
55088
55610
|
summarizeTools: options.summarizeTools,
|
|
55089
55611
|
isInteractive: options.isInteractive,
|
|
55090
|
-
invocationMode
|
|
55612
|
+
invocationMode,
|
|
55613
|
+
...requestShapingOpts
|
|
55091
55614
|
});
|
|
55092
55615
|
localProviderHandlers.set(targetModel, handler);
|
|
55093
55616
|
log(`[Proxy] Created local provider handler: ${resolved.provider.name}/${resolved.modelName}${resolved.concurrency !== undefined ? ` (concurrency: ${resolved.concurrency})` : ""}`);
|
|
@@ -55103,7 +55626,8 @@ async function createProxyServer(port, _openrouterApiKey, model, monitorMode = f
|
|
|
55103
55626
|
tokenStrategy: "local",
|
|
55104
55627
|
summarizeTools: options.summarizeTools,
|
|
55105
55628
|
isInteractive: options.isInteractive,
|
|
55106
|
-
invocationMode
|
|
55629
|
+
invocationMode,
|
|
55630
|
+
...requestShapingOpts
|
|
55107
55631
|
});
|
|
55108
55632
|
localProviderHandlers.set(targetModel, handler);
|
|
55109
55633
|
log(`[Proxy] Created URL-based local provider handler: ${urlParsed.baseUrl}/${urlParsed.modelName}`);
|
|
@@ -55158,7 +55682,7 @@ async function createProxyServer(port, _openrouterApiKey, model, monitorMode = f
|
|
|
55158
55682
|
apiKey,
|
|
55159
55683
|
targetModel,
|
|
55160
55684
|
port,
|
|
55161
|
-
sharedOpts: { isInteractive: options.isInteractive, invocationMode }
|
|
55685
|
+
sharedOpts: { isInteractive: options.isInteractive, invocationMode, ...requestShapingOpts }
|
|
55162
55686
|
});
|
|
55163
55687
|
if (!handler) {
|
|
55164
55688
|
return null;
|
|
@@ -55481,6 +56005,7 @@ var RoutingError, classifierCaptureDirReady = false;
|
|
|
55481
56005
|
var init_proxy_server = __esm(() => {
|
|
55482
56006
|
init_dist();
|
|
55483
56007
|
init_cors();
|
|
56008
|
+
init_base_api_format();
|
|
55484
56009
|
init_local_adapter();
|
|
55485
56010
|
init_openrouter_api_format();
|
|
55486
56011
|
init_authority();
|
|
@@ -55526,14 +56051,14 @@ __export(exports_mcp_server, {
|
|
|
55526
56051
|
runPromptViaProxy: () => runPromptViaProxy,
|
|
55527
56052
|
startMcpServer: () => startMcpServer
|
|
55528
56053
|
});
|
|
55529
|
-
import { existsSync as
|
|
55530
|
-
import { homedir as
|
|
55531
|
-
import { dirname as dirname9, join as
|
|
56054
|
+
import { existsSync as existsSync23, mkdirSync as mkdirSync15, readFileSync as readFileSync23, readdirSync as readdirSync6, writeFileSync as writeFileSync14 } from "fs";
|
|
56055
|
+
import { homedir as homedir31 } from "os";
|
|
56056
|
+
import { dirname as dirname9, join as join34, resolve as resolve5 } from "path";
|
|
55532
56057
|
import { fileURLToPath } from "url";
|
|
55533
56058
|
async function loadAllModels(forceRefresh = false) {
|
|
55534
|
-
if (!forceRefresh &&
|
|
56059
|
+
if (!forceRefresh && existsSync23(ALL_MODELS_CACHE_PATH2)) {
|
|
55535
56060
|
try {
|
|
55536
|
-
const cacheData = JSON.parse(
|
|
56061
|
+
const cacheData = JSON.parse(readFileSync23(ALL_MODELS_CACHE_PATH2, "utf-8"));
|
|
55537
56062
|
const lastUpdated = new Date(cacheData.lastUpdated);
|
|
55538
56063
|
const ageInDays = (Date.now() - lastUpdated.getTime()) / (1000 * 60 * 60 * 24);
|
|
55539
56064
|
if (ageInDays <= CACHE_MAX_AGE_DAYS) {
|
|
@@ -55551,8 +56076,8 @@ async function loadAllModels(forceRefresh = false) {
|
|
|
55551
56076
|
writeFileSync14(ALL_MODELS_CACHE_PATH2, JSON.stringify({ lastUpdated: new Date().toISOString(), models }), "utf-8");
|
|
55552
56077
|
return models;
|
|
55553
56078
|
} catch {
|
|
55554
|
-
if (
|
|
55555
|
-
const cacheData = JSON.parse(
|
|
56079
|
+
if (existsSync23(ALL_MODELS_CACHE_PATH2)) {
|
|
56080
|
+
const cacheData = JSON.parse(readFileSync23(ALL_MODELS_CACHE_PATH2, "utf-8"));
|
|
55556
56081
|
return cacheData.models || [];
|
|
55557
56082
|
}
|
|
55558
56083
|
return [];
|
|
@@ -56290,7 +56815,7 @@ Use with: run_prompt(model="${results[0].model.id}", prompt="your prompt")`;
|
|
|
56290
56815
|
let stderrFull = stderr_snippet || "";
|
|
56291
56816
|
if (error_log_path) {
|
|
56292
56817
|
try {
|
|
56293
|
-
stderrFull =
|
|
56818
|
+
stderrFull = readFileSync23(error_log_path, "utf-8");
|
|
56294
56819
|
} catch {}
|
|
56295
56820
|
}
|
|
56296
56821
|
const sessionData = {};
|
|
@@ -56298,26 +56823,26 @@ Use with: run_prompt(model="${results[0].model.id}", prompt="your prompt")`;
|
|
|
56298
56823
|
const sp = session_path;
|
|
56299
56824
|
for (const file2 of ["status.json", "manifest.json", "input.md"]) {
|
|
56300
56825
|
try {
|
|
56301
|
-
sessionData[file2] =
|
|
56826
|
+
sessionData[file2] = readFileSync23(join34(sp, file2), "utf-8");
|
|
56302
56827
|
} catch {}
|
|
56303
56828
|
}
|
|
56304
56829
|
try {
|
|
56305
|
-
const errorDir =
|
|
56306
|
-
if (
|
|
56307
|
-
for (const f of
|
|
56830
|
+
const errorDir = join34(sp, "errors");
|
|
56831
|
+
if (existsSync23(errorDir)) {
|
|
56832
|
+
for (const f of readdirSync6(errorDir)) {
|
|
56308
56833
|
if (f.endsWith(".log")) {
|
|
56309
56834
|
try {
|
|
56310
|
-
sessionData[`errors/${f}`] =
|
|
56835
|
+
sessionData[`errors/${f}`] = readFileSync23(join34(errorDir, f), "utf-8");
|
|
56311
56836
|
} catch {}
|
|
56312
56837
|
}
|
|
56313
56838
|
}
|
|
56314
56839
|
}
|
|
56315
56840
|
} catch {}
|
|
56316
56841
|
try {
|
|
56317
|
-
for (const f of
|
|
56842
|
+
for (const f of readdirSync6(sp)) {
|
|
56318
56843
|
if (f.startsWith("response-") && f.endsWith(".md")) {
|
|
56319
56844
|
try {
|
|
56320
|
-
const content =
|
|
56845
|
+
const content = readFileSync23(join34(sp, f), "utf-8");
|
|
56321
56846
|
sessionData[f] = content.slice(0, 200) + (content.length > 200 ? "... (truncated)" : "");
|
|
56322
56847
|
} catch {}
|
|
56323
56848
|
}
|
|
@@ -56326,9 +56851,9 @@ Use with: run_prompt(model="${results[0].model.id}", prompt="your prompt")`;
|
|
|
56326
56851
|
}
|
|
56327
56852
|
let version2 = "unknown";
|
|
56328
56853
|
try {
|
|
56329
|
-
const pkgPath =
|
|
56330
|
-
if (
|
|
56331
|
-
version2 = JSON.parse(
|
|
56854
|
+
const pkgPath = join34(__dirname2, "../package.json");
|
|
56855
|
+
if (existsSync23(pkgPath)) {
|
|
56856
|
+
version2 = JSON.parse(readFileSync23(pkgPath, "utf-8")).version;
|
|
56332
56857
|
}
|
|
56333
56858
|
} catch {}
|
|
56334
56859
|
const report = {
|
|
@@ -56793,8 +57318,8 @@ var init_mcp_server = __esm(() => {
|
|
|
56793
57318
|
import_dotenv2.config({ quiet: true });
|
|
56794
57319
|
__filename2 = fileURLToPath(import.meta.url);
|
|
56795
57320
|
__dirname2 = dirname9(__filename2);
|
|
56796
|
-
CLAUDISH_CACHE_DIR =
|
|
56797
|
-
ALL_MODELS_CACHE_PATH2 =
|
|
57321
|
+
CLAUDISH_CACHE_DIR = join34(homedir31(), ".claudish");
|
|
57322
|
+
ALL_MODELS_CACHE_PATH2 = join34(CLAUDISH_CACHE_DIR, "all-models.json");
|
|
56798
57323
|
NEXT_STEP = {
|
|
56799
57324
|
nonzero_exit: "read the evidence log, then retry or drop the model",
|
|
56800
57325
|
timeout: "raise `timeout`, or pick a faster model",
|
|
@@ -56821,7 +57346,7 @@ var exports_serve_command = {};
|
|
|
56821
57346
|
__export(exports_serve_command, {
|
|
56822
57347
|
serveCommand: () => serveCommand
|
|
56823
57348
|
});
|
|
56824
|
-
import { existsSync as
|
|
57349
|
+
import { existsSync as existsSync24, readFileSync as readFileSync24 } from "fs";
|
|
56825
57350
|
function parseServeArgs(args) {
|
|
56826
57351
|
const out = {};
|
|
56827
57352
|
for (let i = 0;i < args.length; i++) {
|
|
@@ -56840,12 +57365,12 @@ function parseServeArgs(args) {
|
|
|
56840
57365
|
return out;
|
|
56841
57366
|
}
|
|
56842
57367
|
function loadModelMap(path) {
|
|
56843
|
-
if (!
|
|
57368
|
+
if (!existsSync24(path)) {
|
|
56844
57369
|
throw new Error(`--models file not found: ${path}`);
|
|
56845
57370
|
}
|
|
56846
57371
|
let raw2;
|
|
56847
57372
|
try {
|
|
56848
|
-
raw2 =
|
|
57373
|
+
raw2 = readFileSync24(path, "utf-8");
|
|
56849
57374
|
} catch (e) {
|
|
56850
57375
|
throw new Error(`failed to read --models file ${path}: ${e instanceof Error ? e.message : String(e)}`);
|
|
56851
57376
|
}
|
|
@@ -57160,7 +57685,7 @@ var exports_behavior_command = {};
|
|
|
57160
57685
|
__export(exports_behavior_command, {
|
|
57161
57686
|
behaviorCommand: () => behaviorCommand
|
|
57162
57687
|
});
|
|
57163
|
-
import { existsSync as
|
|
57688
|
+
import { existsSync as existsSync25, readFileSync as readFileSync25, writeFileSync as writeFileSync15 } from "fs";
|
|
57164
57689
|
function severityColor(sev) {
|
|
57165
57690
|
if (sev === "fix")
|
|
57166
57691
|
return green(sev);
|
|
@@ -57258,8 +57783,8 @@ function setTelemetryEnabled(value) {
|
|
|
57258
57783
|
const path = getConfigPath();
|
|
57259
57784
|
let cfg = {};
|
|
57260
57785
|
try {
|
|
57261
|
-
if (
|
|
57262
|
-
const parsed = JSON.parse(
|
|
57786
|
+
if (existsSync25(path)) {
|
|
57787
|
+
const parsed = JSON.parse(readFileSync25(path, "utf-8"));
|
|
57263
57788
|
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
57264
57789
|
cfg = parsed;
|
|
57265
57790
|
}
|
|
@@ -57280,8 +57805,8 @@ function showTelemetry(action, json2) {
|
|
|
57280
57805
|
let pending = 0;
|
|
57281
57806
|
try {
|
|
57282
57807
|
const path = outboxPath();
|
|
57283
|
-
if (
|
|
57284
|
-
pending =
|
|
57808
|
+
if (existsSync25(path)) {
|
|
57809
|
+
pending = readFileSync25(path, "utf8").split(`
|
|
57285
57810
|
`).filter(Boolean).length;
|
|
57286
57811
|
}
|
|
57287
57812
|
} catch {}
|
|
@@ -57366,9 +57891,9 @@ __export(exports_team_grid, {
|
|
|
57366
57891
|
});
|
|
57367
57892
|
import { spawn as spawn4 } from "child_process";
|
|
57368
57893
|
import { execSync } from "child_process";
|
|
57369
|
-
import { existsSync as
|
|
57894
|
+
import { existsSync as existsSync26, readFileSync as readFileSync26, writeFileSync as writeFileSync16 } from "fs";
|
|
57370
57895
|
import { connect as netConnect } from "net";
|
|
57371
|
-
import { dirname as dirname10, join as
|
|
57896
|
+
import { dirname as dirname10, join as join35 } from "path";
|
|
57372
57897
|
import { setTimeout as wait } from "timers/promises";
|
|
57373
57898
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
57374
57899
|
function resolveRouteInfo(modelId) {
|
|
@@ -57462,18 +57987,18 @@ function buildPaneHeader(model, prompt, bg) {
|
|
|
57462
57987
|
function findMagmuxBinary() {
|
|
57463
57988
|
const thisFile = fileURLToPath2(import.meta.url);
|
|
57464
57989
|
const thisDir = dirname10(thisFile);
|
|
57465
|
-
const pkgRoot =
|
|
57990
|
+
const pkgRoot = join35(thisDir, "..");
|
|
57466
57991
|
const platform2 = process.platform;
|
|
57467
57992
|
const arch = process.arch;
|
|
57468
|
-
const bundledMagmux =
|
|
57469
|
-
if (
|
|
57993
|
+
const bundledMagmux = join35(pkgRoot, "native", `magmux-${platform2}-${arch}`);
|
|
57994
|
+
if (existsSync26(bundledMagmux))
|
|
57470
57995
|
return bundledMagmux;
|
|
57471
57996
|
try {
|
|
57472
57997
|
const pkgName = `@claudish/magmux-${platform2}-${arch}`;
|
|
57473
57998
|
let searchDir = pkgRoot;
|
|
57474
57999
|
for (let i = 0;i < 5; i++) {
|
|
57475
|
-
const candidate =
|
|
57476
|
-
if (
|
|
58000
|
+
const candidate = join35(searchDir, "node_modules", pkgName, "bin", "magmux");
|
|
58001
|
+
if (existsSync26(candidate))
|
|
57477
58002
|
return candidate;
|
|
57478
58003
|
const parent = dirname10(searchDir);
|
|
57479
58004
|
if (parent === searchDir)
|
|
@@ -57497,7 +58022,7 @@ function withoutControlPanes(evt) {
|
|
|
57497
58022
|
async function subscribeToMagmux(sockPath, onEvent) {
|
|
57498
58023
|
let client = null;
|
|
57499
58024
|
for (let attempt = 0;attempt < 40; attempt++) {
|
|
57500
|
-
if (
|
|
58025
|
+
if (existsSync26(sockPath)) {
|
|
57501
58026
|
try {
|
|
57502
58027
|
client = await new Promise((resolve6, reject) => {
|
|
57503
58028
|
const s = netConnect(sockPath);
|
|
@@ -57584,9 +58109,9 @@ async function runWithGrid(sessionPath, models, input, opts) {
|
|
|
57584
58109
|
const keep = opts?.keep ?? false;
|
|
57585
58110
|
const manifest = setupSession(sessionPath, models, input);
|
|
57586
58111
|
const startedAt = new Date().toISOString();
|
|
57587
|
-
const gridfilePath =
|
|
57588
|
-
const prompt =
|
|
57589
|
-
const rawPrompt =
|
|
58112
|
+
const gridfilePath = join35(sessionPath, "gridfile.txt");
|
|
58113
|
+
const prompt = readFileSync26(join35(sessionPath, "input.md"), "utf-8").replace(/'/g, "'\\''").replace(/\n/g, " ");
|
|
58114
|
+
const rawPrompt = readFileSync26(join35(sessionPath, "input.md"), "utf-8");
|
|
57590
58115
|
const usedBannerColors = new Set;
|
|
57591
58116
|
const gridLines = Object.entries(manifest.models).map(([anonId]) => {
|
|
57592
58117
|
const model = manifest.models[anonId].model;
|
|
@@ -57617,7 +58142,7 @@ async function runWithGrid(sessionPath, models, input, opts) {
|
|
|
57617
58142
|
});
|
|
57618
58143
|
const [{ results }] = await Promise.all([subscription, procExit]);
|
|
57619
58144
|
const status = buildTeamStatus(manifest, startedAt, results?.panes ?? null);
|
|
57620
|
-
const statusPath =
|
|
58145
|
+
const statusPath = join35(sessionPath, "status.json");
|
|
57621
58146
|
writeFileSync16(statusPath, JSON.stringify(status, null, 2), "utf-8");
|
|
57622
58147
|
return status;
|
|
57623
58148
|
}
|
|
@@ -57642,8 +58167,8 @@ var exports_team_cli = {};
|
|
|
57642
58167
|
__export(exports_team_cli, {
|
|
57643
58168
|
teamCommand: () => teamCommand
|
|
57644
58169
|
});
|
|
57645
|
-
import { readFileSync as
|
|
57646
|
-
import { join as
|
|
58170
|
+
import { readFileSync as readFileSync27 } from "fs";
|
|
58171
|
+
import { join as join36 } from "path";
|
|
57647
58172
|
function getFlag(args, flag) {
|
|
57648
58173
|
const idx = args.indexOf(flag);
|
|
57649
58174
|
if (idx === -1 || idx + 1 >= args.length)
|
|
@@ -57766,7 +58291,7 @@ async function teamCommand(args) {
|
|
|
57766
58291
|
}
|
|
57767
58292
|
case "judge": {
|
|
57768
58293
|
await judgeResponses(sessionPath, { judges });
|
|
57769
|
-
console.log(
|
|
58294
|
+
console.log(readFileSync27(join36(sessionPath, "verdict.md"), "utf-8"));
|
|
57770
58295
|
break;
|
|
57771
58296
|
}
|
|
57772
58297
|
case "run-and-judge": {
|
|
@@ -57784,7 +58309,7 @@ async function teamCommand(args) {
|
|
|
57784
58309
|
});
|
|
57785
58310
|
printStatus(status);
|
|
57786
58311
|
await judgeResponses(sessionPath, { judges });
|
|
57787
|
-
console.log(
|
|
58312
|
+
console.log(readFileSync27(join36(sessionPath, "verdict.md"), "utf-8"));
|
|
57788
58313
|
break;
|
|
57789
58314
|
}
|
|
57790
58315
|
case "status": {
|
|
@@ -58434,7 +58959,7 @@ var init_theme = __esm(() => {
|
|
|
58434
58959
|
});
|
|
58435
58960
|
|
|
58436
58961
|
// ../../node_modules/.bun/@inquirer+core@11.0.1+04f2146be16c61ef/node_modules/@inquirer/core/dist/lib/make-theme.js
|
|
58437
|
-
function
|
|
58962
|
+
function isPlainObject4(value) {
|
|
58438
58963
|
if (typeof value !== "object" || value === null)
|
|
58439
58964
|
return false;
|
|
58440
58965
|
let proto = value;
|
|
@@ -58448,7 +58973,7 @@ function deepMerge(...objects) {
|
|
|
58448
58973
|
for (const obj of objects) {
|
|
58449
58974
|
for (const [key, value] of Object.entries(obj)) {
|
|
58450
58975
|
const prevValue = output[key];
|
|
58451
|
-
output[key] =
|
|
58976
|
+
output[key] = isPlainObject4(prevValue) && isPlainObject4(value) ? deepMerge(prevValue, value) : value;
|
|
58452
58977
|
}
|
|
58453
58978
|
}
|
|
58454
58979
|
return output;
|
|
@@ -69211,7 +69736,7 @@ var init_RemoveFileError = __esm(() => {
|
|
|
69211
69736
|
|
|
69212
69737
|
// ../../node_modules/.bun/@inquirer+external-editor@2.0.1+04f2146be16c61ef/node_modules/@inquirer/external-editor/dist/index.js
|
|
69213
69738
|
import { spawn as spawn5, spawnSync as spawnSync2 } from "child_process";
|
|
69214
|
-
import { readFileSync as
|
|
69739
|
+
import { readFileSync as readFileSync28, unlinkSync as unlinkSync6, writeFileSync as writeFileSync17 } from "fs";
|
|
69215
69740
|
import path from "path";
|
|
69216
69741
|
import os from "os";
|
|
69217
69742
|
import { randomUUID as randomUUID5 } from "crypto";
|
|
@@ -69327,7 +69852,7 @@ class ExternalEditor {
|
|
|
69327
69852
|
}
|
|
69328
69853
|
readTemporaryFile() {
|
|
69329
69854
|
try {
|
|
69330
|
-
const tempFileBuffer =
|
|
69855
|
+
const tempFileBuffer = readFileSync28(this.tempFile);
|
|
69331
69856
|
if (tempFileBuffer.length === 0) {
|
|
69332
69857
|
this.text = "";
|
|
69333
69858
|
} else {
|
|
@@ -70722,9 +71247,9 @@ var init_keychain_command = __esm(() => {
|
|
|
70722
71247
|
|
|
70723
71248
|
// src/auth/antigravity-oauth.ts
|
|
70724
71249
|
import { spawnSync as spawnSync3 } from "child_process";
|
|
70725
|
-
import { existsSync as
|
|
70726
|
-
import { homedir as
|
|
70727
|
-
import { join as
|
|
71250
|
+
import { existsSync as existsSync27, unlinkSync as unlinkSync7 } from "fs";
|
|
71251
|
+
import { homedir as homedir32 } from "os";
|
|
71252
|
+
import { join as join37 } from "path";
|
|
70728
71253
|
async function defaultSuggestModel() {
|
|
70729
71254
|
try {
|
|
70730
71255
|
const tok = readSharedAntigravityToken();
|
|
@@ -70845,8 +71370,8 @@ No session detected yet. Starting the Antigravity CLI interactively \u2014
|
|
|
70845
71370
|
async logout(deps2) {
|
|
70846
71371
|
deleteSharedAntigravityToken(deps2);
|
|
70847
71372
|
try {
|
|
70848
|
-
const tokenFile =
|
|
70849
|
-
if (
|
|
71373
|
+
const tokenFile = join37(homedir32(), ".gemini", "antigravity-cli", "antigravity-oauth-token");
|
|
71374
|
+
if (existsSync27(tokenFile))
|
|
70850
71375
|
unlinkSync7(tokenFile);
|
|
70851
71376
|
} catch {}
|
|
70852
71377
|
log("[AntigravityOAuth] Antigravity session cleared (keychain + agy token file)");
|
|
@@ -72248,6 +72773,23 @@ var init_model_selector = __esm(() => {
|
|
|
72248
72773
|
};
|
|
72249
72774
|
});
|
|
72250
72775
|
|
|
72776
|
+
// src/providers/probe-runner.ts
|
|
72777
|
+
function pinProbeModelSpec(link) {
|
|
72778
|
+
if (link.provider === "native-anthropic")
|
|
72779
|
+
return link.modelSpec;
|
|
72780
|
+
return link.modelSpec.includes("@") ? link.modelSpec : `${link.provider}@${link.modelSpec}`;
|
|
72781
|
+
}
|
|
72782
|
+
function probeProviderRoute(proxyUrl, link, timeoutMs) {
|
|
72783
|
+
return probeLink(proxyUrl, {
|
|
72784
|
+
...link,
|
|
72785
|
+
modelSpec: pinProbeModelSpec(link)
|
|
72786
|
+
}, timeoutMs);
|
|
72787
|
+
}
|
|
72788
|
+
var INTERACTIVE_PROBE_TIMEOUT_MS = 60000;
|
|
72789
|
+
var init_probe_runner = __esm(() => {
|
|
72790
|
+
init_probe_live();
|
|
72791
|
+
});
|
|
72792
|
+
|
|
72251
72793
|
// src/tui/theme.ts
|
|
72252
72794
|
import { createTextAttributes } from "@opentui/core";
|
|
72253
72795
|
function latencyBucket(ms) {
|
|
@@ -72716,6 +73258,8 @@ function shortStatusLabel(probe2, hasCreds, _hint) {
|
|
|
72716
73258
|
return `${pc.red}\u2297 rate-limited${pc.reset}`;
|
|
72717
73259
|
case "out-of-credit":
|
|
72718
73260
|
return `${pc.red}\u2297 no credit${pc.reset}`;
|
|
73261
|
+
case "plan-limit":
|
|
73262
|
+
return `${pc.red}\u2297 plan limit${pc.reset}`;
|
|
72719
73263
|
case "server-error":
|
|
72720
73264
|
return `${pc.red}\u2297 server ${probe2.httpStatus ?? ""}${pc.reset}`;
|
|
72721
73265
|
case "timeout":
|
|
@@ -72869,7 +73413,7 @@ function buildDirectRowData(result) {
|
|
|
72869
73413
|
{
|
|
72870
73414
|
num: "1",
|
|
72871
73415
|
provider: result.nativeProvider,
|
|
72872
|
-
spec:
|
|
73416
|
+
spec: pinProbeModelSpec({ provider: result.nativeProvider, modelSpec: result.model }),
|
|
72873
73417
|
status,
|
|
72874
73418
|
errorDetail,
|
|
72875
73419
|
barsTiming
|
|
@@ -73202,6 +73746,7 @@ function printProbeResults(results, isLiveProbe) {
|
|
|
73202
73746
|
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;
|
|
73203
73747
|
var init_probe_results_printer = __esm(() => {
|
|
73204
73748
|
init_probe_live();
|
|
73749
|
+
init_probe_runner();
|
|
73205
73750
|
init_ansi();
|
|
73206
73751
|
init_theme_mode();
|
|
73207
73752
|
init_theme2();
|
|
@@ -74675,23 +75220,6 @@ var init_claude_code_aliases = __esm(() => {
|
|
|
74675
75220
|
};
|
|
74676
75221
|
});
|
|
74677
75222
|
|
|
74678
|
-
// src/providers/probe-runner.ts
|
|
74679
|
-
function pinProbeModelSpec(link) {
|
|
74680
|
-
if (link.provider === "native-anthropic")
|
|
74681
|
-
return link.modelSpec;
|
|
74682
|
-
return link.modelSpec.includes("@") ? link.modelSpec : `${link.provider}@${link.modelSpec}`;
|
|
74683
|
-
}
|
|
74684
|
-
function probeProviderRoute(proxyUrl, link, timeoutMs) {
|
|
74685
|
-
return probeLink(proxyUrl, {
|
|
74686
|
-
...link,
|
|
74687
|
-
modelSpec: pinProbeModelSpec(link)
|
|
74688
|
-
}, timeoutMs);
|
|
74689
|
-
}
|
|
74690
|
-
var INTERACTIVE_PROBE_TIMEOUT_MS = 60000;
|
|
74691
|
-
var init_probe_runner = __esm(() => {
|
|
74692
|
-
init_probe_live();
|
|
74693
|
-
});
|
|
74694
|
-
|
|
74695
75223
|
// src/cli.ts
|
|
74696
75224
|
var exports_cli = {};
|
|
74697
75225
|
__export(exports_cli, {
|
|
@@ -74708,30 +75236,30 @@ __export(exports_cli, {
|
|
|
74708
75236
|
});
|
|
74709
75237
|
import {
|
|
74710
75238
|
copyFileSync as copyFileSync2,
|
|
74711
|
-
existsSync as
|
|
75239
|
+
existsSync as existsSync28,
|
|
74712
75240
|
mkdirSync as mkdirSync16,
|
|
74713
|
-
readFileSync as
|
|
74714
|
-
readdirSync as
|
|
75241
|
+
readFileSync as readFileSync29,
|
|
75242
|
+
readdirSync as readdirSync7,
|
|
74715
75243
|
unlinkSync as unlinkSync8,
|
|
74716
75244
|
writeFileSync as writeFileSync18
|
|
74717
75245
|
} from "fs";
|
|
74718
|
-
import { homedir as
|
|
74719
|
-
import { dirname as dirname11, join as
|
|
75246
|
+
import { homedir as homedir33 } from "os";
|
|
75247
|
+
import { dirname as dirname11, join as join38 } from "path";
|
|
74720
75248
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
74721
75249
|
function getVersion3() {
|
|
74722
75250
|
return VERSION;
|
|
74723
75251
|
}
|
|
74724
75252
|
function clearAllModelCaches() {
|
|
74725
|
-
const cacheDir =
|
|
74726
|
-
if (!
|
|
75253
|
+
const cacheDir = join38(homedir33(), ".claudish");
|
|
75254
|
+
if (!existsSync28(cacheDir))
|
|
74727
75255
|
return;
|
|
74728
75256
|
const cachePatterns = ["pricing-cache.json", "recommended-models-cache.json"];
|
|
74729
75257
|
let cleared = 0;
|
|
74730
75258
|
try {
|
|
74731
|
-
const files =
|
|
75259
|
+
const files = readdirSync7(cacheDir);
|
|
74732
75260
|
for (const file2 of files) {
|
|
74733
75261
|
if (cachePatterns.includes(file2)) {
|
|
74734
|
-
unlinkSync8(
|
|
75262
|
+
unlinkSync8(join38(cacheDir, file2));
|
|
74735
75263
|
cleared++;
|
|
74736
75264
|
}
|
|
74737
75265
|
}
|
|
@@ -74951,6 +75479,33 @@ async function parseArgs(args) {
|
|
|
74951
75479
|
process.exit(1);
|
|
74952
75480
|
}
|
|
74953
75481
|
config3.classifierProvider = cpArg;
|
|
75482
|
+
} else if (arg === "--model-params") {
|
|
75483
|
+
const mpArg = args[++i];
|
|
75484
|
+
if (!mpArg) {
|
|
75485
|
+
console.error("--model-params requires k=v[,k=v...] (e.g. reasoning.mode=pro)");
|
|
75486
|
+
process.exit(1);
|
|
75487
|
+
}
|
|
75488
|
+
try {
|
|
75489
|
+
config3.modelParams = parseModelParams(mpArg, config3.modelParams ?? {});
|
|
75490
|
+
} catch (err) {
|
|
75491
|
+
console.error(err instanceof Error ? err.message : String(err));
|
|
75492
|
+
process.exit(1);
|
|
75493
|
+
}
|
|
75494
|
+
} else if (arg === "--effort-override") {
|
|
75495
|
+
const effArg = args[++i];
|
|
75496
|
+
if (!effArg) {
|
|
75497
|
+
console.error(`--effort-override requires a level (${EFFORT_LEVELS.join(", ")})`);
|
|
75498
|
+
process.exit(1);
|
|
75499
|
+
}
|
|
75500
|
+
if (!isEffortLevel(effArg)) {
|
|
75501
|
+
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>).");
|
|
75502
|
+
process.exit(1);
|
|
75503
|
+
}
|
|
75504
|
+
config3.effortOverride = effArg;
|
|
75505
|
+
} else if (arg === "--pro-on-ultracode") {
|
|
75506
|
+
config3.proOnUltracode = true;
|
|
75507
|
+
} else if (arg === "--no-pro-on-ultracode") {
|
|
75508
|
+
config3.proOnUltracode = false;
|
|
74954
75509
|
} else if (arg === "--op-env" || arg.startsWith("--op-env=")) {
|
|
74955
75510
|
const v = arg.startsWith("--op-env=") ? arg.slice("--op-env=".length) : args[++i];
|
|
74956
75511
|
if (!v) {
|
|
@@ -75161,8 +75716,8 @@ Usage: claudish --models --provider <slug>`);
|
|
|
75161
75716
|
});
|
|
75162
75717
|
config3.resolvedDefaultProvider = resolved;
|
|
75163
75718
|
if (resolved.legacyAutoPromoted && !config3.quiet) {
|
|
75164
|
-
const markerFile =
|
|
75165
|
-
if (!
|
|
75719
|
+
const markerFile = join38(homedir33(), ".claudish", ".legacy-litellm-hint-shown");
|
|
75720
|
+
if (!existsSync28(markerFile)) {
|
|
75166
75721
|
const hint = buildLegacyHint(resolved);
|
|
75167
75722
|
if (hint) {
|
|
75168
75723
|
console.error(hint);
|
|
@@ -75174,6 +75729,14 @@ Usage: claudish --models --provider <slug>`);
|
|
|
75174
75729
|
}
|
|
75175
75730
|
}
|
|
75176
75731
|
} catch {}
|
|
75732
|
+
if (config3.proOnUltracode === undefined) {
|
|
75733
|
+
const envVal = process.env.CLAUDISH_PRO_ON_ULTRACODE;
|
|
75734
|
+
if (envVal !== undefined) {
|
|
75735
|
+
config3.proOnUltracode = envVal === "1" || envVal.toLowerCase() === "true";
|
|
75736
|
+
} else {
|
|
75737
|
+
config3.proOnUltracode = readProOnUltracode() === true;
|
|
75738
|
+
}
|
|
75739
|
+
}
|
|
75177
75740
|
return config3;
|
|
75178
75741
|
}
|
|
75179
75742
|
function formatModelDocPricing(pricing) {
|
|
@@ -75769,14 +76332,14 @@ async function probeModelRouting(models, jsonOutput, options = { live: true, tim
|
|
|
75769
76332
|
}
|
|
75770
76333
|
return;
|
|
75771
76334
|
}
|
|
75772
|
-
const
|
|
76335
|
+
const initialState2 = {
|
|
75773
76336
|
steps: [],
|
|
75774
76337
|
links: [],
|
|
75775
76338
|
phase: "live",
|
|
75776
76339
|
results: [],
|
|
75777
76340
|
activeTab: "summary"
|
|
75778
76341
|
};
|
|
75779
|
-
const tui = await startProbeTui(
|
|
76342
|
+
const tui = await startProbeTui(initialState2);
|
|
75780
76343
|
const addStep = (name, status) => {
|
|
75781
76344
|
tui.store.setState((prev) => ({
|
|
75782
76345
|
...prev,
|
|
@@ -76070,6 +76633,10 @@ ${h("OPTIONS")}
|
|
|
76070
76633
|
${green2("--free")} Show only FREE models in the interactive selector
|
|
76071
76634
|
${green2("--monitor")} Monitor mode - proxy to REAL Anthropic API and log traffic
|
|
76072
76635
|
${green2("--advisor")} ${yellow2('"m1,m2[:collector]"')} Multi-model advisor replacement (implies --monitor)
|
|
76636
|
+
${green2("--model-params")} ${yellow2('"k=v,..."')} Extra request params merged into the payload (e.g. reasoning.mode=pro)
|
|
76637
|
+
${green2("--effort-override")} ${yellow2("<level>")} Pin reasoning effort verbatim, skipping the per-model clamp
|
|
76638
|
+
${green2("--pro-on-ultracode")} Apply the model's catalog preset while in ultracode (opt-in)
|
|
76639
|
+
${green2("--no-pro-on-ultracode")} Force that off for this run (when enabled in config/env)
|
|
76073
76640
|
${green2("-y, --auto-approve")} Skip permission prompts (--dangerously-skip-permissions)
|
|
76074
76641
|
${green2("--no-auto-approve")} Explicitly enable permission prompts (default)
|
|
76075
76642
|
${green2("--dangerous")} Pass --dangerouslyDisableSandbox to Claude Code
|
|
@@ -76281,8 +76848,8 @@ ${h("MORE INFO")}
|
|
|
76281
76848
|
}
|
|
76282
76849
|
function printAIAgentGuide() {
|
|
76283
76850
|
try {
|
|
76284
|
-
const guidePath =
|
|
76285
|
-
const guideContent =
|
|
76851
|
+
const guidePath = join38(__dirname3, "../AI_AGENT_GUIDE.md");
|
|
76852
|
+
const guideContent = readFileSync29(guidePath, "utf-8");
|
|
76286
76853
|
console.log(guideContent);
|
|
76287
76854
|
} catch (error46) {
|
|
76288
76855
|
console.error("Error reading AI Agent Guide:");
|
|
@@ -76298,19 +76865,19 @@ async function initializeClaudishSkill() {
|
|
|
76298
76865
|
console.log(`\uD83D\uDD27 Initializing Claudish skill in current project...
|
|
76299
76866
|
`);
|
|
76300
76867
|
const cwd = process.cwd();
|
|
76301
|
-
const claudeDir =
|
|
76302
|
-
const skillsDir =
|
|
76303
|
-
const claudishSkillDir =
|
|
76304
|
-
const skillFile =
|
|
76305
|
-
if (
|
|
76868
|
+
const claudeDir = join38(cwd, ".claude");
|
|
76869
|
+
const skillsDir = join38(claudeDir, "skills");
|
|
76870
|
+
const claudishSkillDir = join38(skillsDir, "claudish-usage");
|
|
76871
|
+
const skillFile = join38(claudishSkillDir, "SKILL.md");
|
|
76872
|
+
if (existsSync28(skillFile)) {
|
|
76306
76873
|
console.log("\u2705 Claudish skill already installed at:");
|
|
76307
76874
|
console.log(` ${skillFile}
|
|
76308
76875
|
`);
|
|
76309
76876
|
console.log("\uD83D\uDCA1 To reinstall, delete the file and run 'claudish --init' again.");
|
|
76310
76877
|
return;
|
|
76311
76878
|
}
|
|
76312
|
-
const sourceSkillPath =
|
|
76313
|
-
if (!
|
|
76879
|
+
const sourceSkillPath = join38(__dirname3, "../skills/claudish-usage/SKILL.md");
|
|
76880
|
+
if (!existsSync28(sourceSkillPath)) {
|
|
76314
76881
|
console.error("\u274C Error: Claudish skill file not found in installation.");
|
|
76315
76882
|
console.error(` Expected at: ${sourceSkillPath}`);
|
|
76316
76883
|
console.error(`
|
|
@@ -76319,15 +76886,15 @@ async function initializeClaudishSkill() {
|
|
|
76319
76886
|
process.exit(1);
|
|
76320
76887
|
}
|
|
76321
76888
|
try {
|
|
76322
|
-
if (!
|
|
76889
|
+
if (!existsSync28(claudeDir)) {
|
|
76323
76890
|
mkdirSync16(claudeDir, { recursive: true });
|
|
76324
76891
|
console.log("\uD83D\uDCC1 Created .claude/ directory");
|
|
76325
76892
|
}
|
|
76326
|
-
if (!
|
|
76893
|
+
if (!existsSync28(skillsDir)) {
|
|
76327
76894
|
mkdirSync16(skillsDir, { recursive: true });
|
|
76328
76895
|
console.log("\uD83D\uDCC1 Created .claude/skills/ directory");
|
|
76329
76896
|
}
|
|
76330
|
-
if (!
|
|
76897
|
+
if (!existsSync28(claudishSkillDir)) {
|
|
76331
76898
|
mkdirSync16(claudishSkillDir, { recursive: true });
|
|
76332
76899
|
console.log("\uD83D\uDCC1 Created .claude/skills/claudish-usage/ directory");
|
|
76333
76900
|
}
|
|
@@ -76385,6 +76952,7 @@ function printAvailableModels() {
|
|
|
76385
76952
|
}
|
|
76386
76953
|
var __filename3, __dirname3;
|
|
76387
76954
|
var init_cli = __esm(() => {
|
|
76955
|
+
init_base_api_format();
|
|
76388
76956
|
init_config2();
|
|
76389
76957
|
init_model_loader();
|
|
76390
76958
|
init_model_selector();
|
|
@@ -76416,33 +76984,33 @@ __export(exports_update_checker, {
|
|
|
76416
76984
|
fetchLatestVersion: () => fetchLatestVersion,
|
|
76417
76985
|
fetchLatestVersionOrThrow: () => fetchLatestVersionOrThrow
|
|
76418
76986
|
});
|
|
76419
|
-
import { existsSync as
|
|
76420
|
-
import { homedir as
|
|
76421
|
-
import { join as
|
|
76987
|
+
import { existsSync as existsSync29, mkdirSync as mkdirSync17, readFileSync as readFileSync30, unlinkSync as unlinkSync9, writeFileSync as writeFileSync19 } from "fs";
|
|
76988
|
+
import { homedir as homedir34, platform as platform2, tmpdir } from "os";
|
|
76989
|
+
import { join as join39 } from "path";
|
|
76422
76990
|
function getCacheFilePath() {
|
|
76423
76991
|
let cacheDir;
|
|
76424
76992
|
if (isWindows) {
|
|
76425
|
-
const localAppData = process.env.LOCALAPPDATA ||
|
|
76426
|
-
cacheDir =
|
|
76993
|
+
const localAppData = process.env.LOCALAPPDATA || join39(homedir34(), "AppData", "Local");
|
|
76994
|
+
cacheDir = join39(localAppData, "claudish");
|
|
76427
76995
|
} else {
|
|
76428
|
-
cacheDir =
|
|
76996
|
+
cacheDir = join39(homedir34(), ".cache", "claudish");
|
|
76429
76997
|
}
|
|
76430
76998
|
try {
|
|
76431
|
-
if (!
|
|
76999
|
+
if (!existsSync29(cacheDir)) {
|
|
76432
77000
|
mkdirSync17(cacheDir, { recursive: true });
|
|
76433
77001
|
}
|
|
76434
|
-
return
|
|
77002
|
+
return join39(cacheDir, "update-check.json");
|
|
76435
77003
|
} catch {
|
|
76436
|
-
return
|
|
77004
|
+
return join39(tmpdir(), "claudish-update-check.json");
|
|
76437
77005
|
}
|
|
76438
77006
|
}
|
|
76439
77007
|
function readCache() {
|
|
76440
77008
|
try {
|
|
76441
77009
|
const cachePath = getCacheFilePath();
|
|
76442
|
-
if (!
|
|
77010
|
+
if (!existsSync29(cachePath)) {
|
|
76443
77011
|
return null;
|
|
76444
77012
|
}
|
|
76445
|
-
const data = JSON.parse(
|
|
77013
|
+
const data = JSON.parse(readFileSync30(cachePath, "utf-8"));
|
|
76446
77014
|
return data;
|
|
76447
77015
|
} catch {
|
|
76448
77016
|
return null;
|
|
@@ -76465,7 +77033,7 @@ function isCacheValid(cache3) {
|
|
|
76465
77033
|
function clearCache() {
|
|
76466
77034
|
try {
|
|
76467
77035
|
const cachePath = getCacheFilePath();
|
|
76468
|
-
if (
|
|
77036
|
+
if (existsSync29(cachePath)) {
|
|
76469
77037
|
unlinkSync9(cachePath);
|
|
76470
77038
|
}
|
|
76471
77039
|
} catch {}
|
|
@@ -77369,15 +77937,15 @@ var init_local_liveness = __esm(() => {
|
|
|
77369
77937
|
});
|
|
77370
77938
|
|
|
77371
77939
|
// src/providers/probe-catalog.ts
|
|
77372
|
-
import { existsSync as
|
|
77373
|
-
import { homedir as
|
|
77374
|
-
import { dirname as dirname12, join as
|
|
77940
|
+
import { existsSync as existsSync30, mkdirSync as mkdirSync18, readFileSync as readFileSync31, writeFileSync as writeFileSync20 } from "fs";
|
|
77941
|
+
import { homedir as homedir35 } from "os";
|
|
77942
|
+
import { dirname as dirname12, join as join40 } from "path";
|
|
77375
77943
|
function readProbeModelsCache(path2 = PROBE_MODELS_CACHE_PATH) {
|
|
77376
|
-
if (!
|
|
77944
|
+
if (!existsSync30(path2))
|
|
77377
77945
|
return null;
|
|
77378
77946
|
let raw2;
|
|
77379
77947
|
try {
|
|
77380
|
-
raw2 = JSON.parse(
|
|
77948
|
+
raw2 = JSON.parse(readFileSync31(path2, "utf-8"));
|
|
77381
77949
|
} catch {
|
|
77382
77950
|
return null;
|
|
77383
77951
|
}
|
|
@@ -77506,7 +78074,7 @@ function isValidResponse(raw2) {
|
|
|
77506
78074
|
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;
|
|
77507
78075
|
var init_probe_catalog = __esm(() => {
|
|
77508
78076
|
CACHE_TTL_MS4 = 60 * 60 * 1000;
|
|
77509
|
-
PROBE_MODELS_CACHE_PATH =
|
|
78077
|
+
PROBE_MODELS_CACHE_PATH = join40(homedir35(), ".claudish", "probe-models.json");
|
|
77510
78078
|
});
|
|
77511
78079
|
|
|
77512
78080
|
// src/tui/constants.ts
|
|
@@ -79796,12 +80364,29 @@ var init_ProfilesContent = __esm(() => {
|
|
|
79796
80364
|
|
|
79797
80365
|
// src/tui/components/ProviderDetail.tsx
|
|
79798
80366
|
import { jsx as jsx11, jsxs as jsxs10, Fragment as Fragment7 } from "@opentui/react/jsx-runtime";
|
|
79799
|
-
function
|
|
80367
|
+
function wrapToLines(text, maxWidth, maxLines) {
|
|
79800
80368
|
const collapsed = text.replace(/\s+/g, " ").trim();
|
|
79801
80369
|
const limit = Math.max(20, maxWidth);
|
|
79802
80370
|
if (collapsed.length <= limit)
|
|
79803
|
-
return collapsed;
|
|
79804
|
-
|
|
80371
|
+
return [collapsed];
|
|
80372
|
+
const lines = [];
|
|
80373
|
+
let rest = collapsed;
|
|
80374
|
+
while (rest.length > 0 && lines.length < maxLines) {
|
|
80375
|
+
if (rest.length <= limit) {
|
|
80376
|
+
lines.push(rest);
|
|
80377
|
+
break;
|
|
80378
|
+
}
|
|
80379
|
+
const slice = rest.slice(0, limit);
|
|
80380
|
+
const cut = slice.lastIndexOf(" ");
|
|
80381
|
+
const at = cut > limit * 0.5 ? cut : limit;
|
|
80382
|
+
lines.push(rest.slice(0, at));
|
|
80383
|
+
rest = rest.slice(at).trimStart();
|
|
80384
|
+
}
|
|
80385
|
+
if (rest.length > 0 && lines.length === maxLines) {
|
|
80386
|
+
const last = lines[maxLines - 1] ?? "";
|
|
80387
|
+
lines[maxLines - 1] = `${last.slice(0, Math.max(1, limit - 1))}\u2026`;
|
|
80388
|
+
}
|
|
80389
|
+
return lines;
|
|
79805
80390
|
}
|
|
79806
80391
|
function resolveProviderDetailKeyDisplay(input) {
|
|
79807
80392
|
if (input.isLocal)
|
|
@@ -79911,6 +80496,7 @@ function ProviderDetail({
|
|
|
79911
80496
|
});
|
|
79912
80497
|
}
|
|
79913
80498
|
const tr = testResults[selectedProvider.name];
|
|
80499
|
+
const failureText = tr && (tr.status === "failed" || tr.status === "unavailable") ? tr.providerMessage ?? tr.error : undefined;
|
|
79914
80500
|
return /* @__PURE__ */ jsxs10("box", {
|
|
79915
80501
|
height: DETAIL_H,
|
|
79916
80502
|
border: true,
|
|
@@ -80089,7 +80675,7 @@ function ProviderDetail({
|
|
|
80089
80675
|
})
|
|
80090
80676
|
]
|
|
80091
80677
|
}),
|
|
80092
|
-
/* @__PURE__ */ jsxs10("text", {
|
|
80678
|
+
!failureText && /* @__PURE__ */ jsxs10("text", {
|
|
80093
80679
|
children: [
|
|
80094
80680
|
/* @__PURE__ */ jsxs10("span", {
|
|
80095
80681
|
fg: C.blue,
|
|
@@ -80105,7 +80691,7 @@ function ProviderDetail({
|
|
|
80105
80691
|
})
|
|
80106
80692
|
]
|
|
80107
80693
|
}),
|
|
80108
|
-
selectedProvider.keyUrl && /* @__PURE__ */ jsxs10("text", {
|
|
80694
|
+
selectedProvider.keyUrl && !failureText && /* @__PURE__ */ jsxs10("text", {
|
|
80109
80695
|
children: [
|
|
80110
80696
|
/* @__PURE__ */ jsxs10("span", {
|
|
80111
80697
|
fg: C.blue,
|
|
@@ -80150,34 +80736,24 @@ function ProviderDetail({
|
|
|
80150
80736
|
})
|
|
80151
80737
|
]
|
|
80152
80738
|
}),
|
|
80153
|
-
tr.status === "failed" && /* @__PURE__ */
|
|
80154
|
-
|
|
80155
|
-
|
|
80156
|
-
|
|
80157
|
-
attributes: A.bold,
|
|
80158
|
-
children: "\u2717 failed"
|
|
80159
|
-
}),
|
|
80160
|
-
tr.error && /* @__PURE__ */ jsx11("span", {
|
|
80161
|
-
fg: C.red,
|
|
80162
|
-
children: ` ${truncateOneLine(tr.error, width - 16)}`
|
|
80163
|
-
})
|
|
80164
|
-
]
|
|
80739
|
+
tr.status === "failed" && /* @__PURE__ */ jsx11("span", {
|
|
80740
|
+
fg: C.red,
|
|
80741
|
+
attributes: A.bold,
|
|
80742
|
+
children: "\u2717 failed"
|
|
80165
80743
|
}),
|
|
80166
|
-
tr.status === "unavailable" && /* @__PURE__ */
|
|
80167
|
-
|
|
80168
|
-
|
|
80169
|
-
|
|
80170
|
-
attributes: A.bold,
|
|
80171
|
-
children: "\u25CB unavailable"
|
|
80172
|
-
}),
|
|
80173
|
-
tr.error && /* @__PURE__ */ jsx11("span", {
|
|
80174
|
-
fg: C.yellow,
|
|
80175
|
-
children: ` ${truncateOneLine(tr.error, width - 16)}`
|
|
80176
|
-
})
|
|
80177
|
-
]
|
|
80744
|
+
tr.status === "unavailable" && /* @__PURE__ */ jsx11("span", {
|
|
80745
|
+
fg: C.yellow,
|
|
80746
|
+
attributes: A.bold,
|
|
80747
|
+
children: "\u25CB unavailable"
|
|
80178
80748
|
})
|
|
80179
80749
|
]
|
|
80180
|
-
})
|
|
80750
|
+
}),
|
|
80751
|
+
failureText && wrapToLines(failureText, width - 4, 2).map((line, i) => /* @__PURE__ */ jsx11("text", {
|
|
80752
|
+
children: /* @__PURE__ */ jsx11("span", {
|
|
80753
|
+
fg: tr?.status === "unavailable" ? C.yellow : C.red,
|
|
80754
|
+
children: line
|
|
80755
|
+
})
|
|
80756
|
+
}, i))
|
|
80181
80757
|
]
|
|
80182
80758
|
});
|
|
80183
80759
|
}
|
|
@@ -82763,7 +83339,7 @@ function App({ requestLogin } = {}) {
|
|
|
82763
83339
|
const error46 = tried.size > 1 ? `${baseError} (tried ${tried.size} models)` : baseError;
|
|
82764
83340
|
setTestResults((prev) => ({
|
|
82765
83341
|
...prev,
|
|
82766
|
-
[provName]: { status: "failed", error: error46, ms }
|
|
83342
|
+
[provName]: { status: "failed", error: error46, providerMessage: result.errorMessage, ms }
|
|
82767
83343
|
}));
|
|
82768
83344
|
}
|
|
82769
83345
|
} catch (err) {
|
|
@@ -84101,18 +84677,18 @@ __export(exports_claude_runner, {
|
|
|
84101
84677
|
});
|
|
84102
84678
|
import { spawn as spawn6, spawnSync as spawnSync5 } from "child_process";
|
|
84103
84679
|
import {
|
|
84104
|
-
closeSync as
|
|
84105
|
-
existsSync as
|
|
84680
|
+
closeSync as closeSync8,
|
|
84681
|
+
existsSync as existsSync31,
|
|
84106
84682
|
mkdirSync as mkdirSync19,
|
|
84107
|
-
openSync as
|
|
84108
|
-
readFileSync as
|
|
84109
|
-
readdirSync as
|
|
84110
|
-
statSync as
|
|
84683
|
+
openSync as openSync8,
|
|
84684
|
+
readFileSync as readFileSync32,
|
|
84685
|
+
readdirSync as readdirSync8,
|
|
84686
|
+
statSync as statSync8,
|
|
84111
84687
|
unlinkSync as unlinkSync10,
|
|
84112
84688
|
writeFileSync as writeFileSync21
|
|
84113
84689
|
} from "fs";
|
|
84114
|
-
import { homedir as
|
|
84115
|
-
import { dirname as dirname13, join as
|
|
84690
|
+
import { homedir as homedir36, tmpdir as tmpdir2 } from "os";
|
|
84691
|
+
import { dirname as dirname13, join as join41 } from "path";
|
|
84116
84692
|
import { isatty } from "tty";
|
|
84117
84693
|
function releaseTerminalIsolation() {
|
|
84118
84694
|
if (!restoreTerminal)
|
|
@@ -84151,11 +84727,11 @@ function shouldHideIncidentalAnthropicKey(config3, env = process.env) {
|
|
|
84151
84727
|
}
|
|
84152
84728
|
function hasResolvableAnthropicAuth(deps2 = {}) {
|
|
84153
84729
|
const env = deps2.env ?? process.env;
|
|
84154
|
-
const fileExists = deps2.fileExists ??
|
|
84730
|
+
const fileExists = deps2.fileExists ?? existsSync31;
|
|
84155
84731
|
const keychainProbe = deps2.keychainProbe ?? defaultKeychainAnthropicProbe;
|
|
84156
84732
|
if (env.ANTHROPIC_API_KEY || env.ANTHROPIC_AUTH_TOKEN)
|
|
84157
84733
|
return true;
|
|
84158
|
-
if (fileExists(
|
|
84734
|
+
if (fileExists(join41(homedir36(), ".claude", ".credentials.json")))
|
|
84159
84735
|
return true;
|
|
84160
84736
|
return keychainProbe();
|
|
84161
84737
|
}
|
|
@@ -84167,14 +84743,14 @@ function isProxyAuthMode(config3) {
|
|
|
84167
84743
|
}
|
|
84168
84744
|
function managedSettingsPath() {
|
|
84169
84745
|
if (isWindows2()) {
|
|
84170
|
-
return
|
|
84746
|
+
return join41(process.env.PROGRAMDATA || "C:\\ProgramData", "ClaudeCode", "managed-settings.json");
|
|
84171
84747
|
}
|
|
84172
84748
|
if (process.platform === "darwin") {
|
|
84173
84749
|
return "/Library/Application Support/ClaudeCode/managed-settings.json";
|
|
84174
84750
|
}
|
|
84175
84751
|
return "/etc/claude-code/managed-settings.json";
|
|
84176
84752
|
}
|
|
84177
|
-
function managedSettingsForcesClaudeAi(readFile3 =
|
|
84753
|
+
function managedSettingsForcesClaudeAi(readFile3 = readFileSync32) {
|
|
84178
84754
|
try {
|
|
84179
84755
|
const raw2 = readFile3(managedSettingsPath(), "utf-8");
|
|
84180
84756
|
const parsed = JSON.parse(raw2);
|
|
@@ -84188,9 +84764,9 @@ function isWindows2() {
|
|
|
84188
84764
|
}
|
|
84189
84765
|
function createStatusLineScript(tokenFilePath) {
|
|
84190
84766
|
const homeDir = process.env.HOME || process.env.USERPROFILE || tmpdir2();
|
|
84191
|
-
const claudishDir =
|
|
84767
|
+
const claudishDir = join41(homeDir, ".claudish");
|
|
84192
84768
|
const timestamp = Date.now();
|
|
84193
|
-
const scriptPath =
|
|
84769
|
+
const scriptPath = join41(claudishDir, `status-${timestamp}.js`);
|
|
84194
84770
|
const escapedTokenPath = tokenFilePath.replace(/\\/g, "\\\\");
|
|
84195
84771
|
const light = getThemeMode() === "light";
|
|
84196
84772
|
const cyanCode = light ? "38;2;14;116;144" : "96";
|
|
@@ -84348,7 +84924,7 @@ function cleanupStaleTokenFiles(dir, now2 = Date.now(), maxAgeMs = STALE_TOKEN_F
|
|
|
84348
84924
|
let removed = 0;
|
|
84349
84925
|
let entries;
|
|
84350
84926
|
try {
|
|
84351
|
-
entries =
|
|
84927
|
+
entries = readdirSync8(dir);
|
|
84352
84928
|
} catch {
|
|
84353
84929
|
return 0;
|
|
84354
84930
|
}
|
|
@@ -84360,9 +84936,9 @@ function cleanupStaleTokenFiles(dir, now2 = Date.now(), maxAgeMs = STALE_TOKEN_F
|
|
|
84360
84936
|
if (!name.startsWith("tokens-") || !name.endsWith(".json"))
|
|
84361
84937
|
continue;
|
|
84362
84938
|
scanned++;
|
|
84363
|
-
const full =
|
|
84939
|
+
const full = join41(dir, name);
|
|
84364
84940
|
try {
|
|
84365
|
-
if (
|
|
84941
|
+
if (statSync8(full).mtimeMs >= cutoff)
|
|
84366
84942
|
continue;
|
|
84367
84943
|
unlinkSync10(full);
|
|
84368
84944
|
removed++;
|
|
@@ -84377,7 +84953,7 @@ function parseSettingsArg(value) {
|
|
|
84377
84953
|
if (value.trimStart().startsWith("{")) {
|
|
84378
84954
|
return JSON.parse(value);
|
|
84379
84955
|
}
|
|
84380
|
-
return JSON.parse(
|
|
84956
|
+
return JSON.parse(readFileSync32(value, "utf-8"));
|
|
84381
84957
|
}
|
|
84382
84958
|
function parseSettingsArgSafe(value) {
|
|
84383
84959
|
try {
|
|
@@ -84389,13 +84965,13 @@ function parseSettingsArgSafe(value) {
|
|
|
84389
84965
|
}
|
|
84390
84966
|
function userSettingsFileCandidates(cwd) {
|
|
84391
84967
|
return [
|
|
84392
|
-
|
|
84393
|
-
|
|
84394
|
-
|
|
84968
|
+
join41(homedir36(), ".claude", "settings.json"),
|
|
84969
|
+
join41(cwd, ".claude", "settings.json"),
|
|
84970
|
+
join41(cwd, ".claude", "settings.local.json")
|
|
84395
84971
|
];
|
|
84396
84972
|
}
|
|
84397
84973
|
function discoverUserStatusLineCommand(claudeArgs = [], cwd = process.cwd()) {
|
|
84398
|
-
const sources = userSettingsFileCandidates(cwd).filter((file2) =>
|
|
84974
|
+
const sources = userSettingsFileCandidates(cwd).filter((file2) => existsSync31(file2));
|
|
84399
84975
|
const idx = claudeArgs.indexOf("--settings");
|
|
84400
84976
|
const settingsArg = idx === -1 ? undefined : claudeArgs[idx + 1];
|
|
84401
84977
|
if (settingsArg)
|
|
@@ -84432,13 +85008,13 @@ function buildChainedStatusCommand(userCommand, claudishBody, claudishSegment) {
|
|
|
84432
85008
|
}
|
|
84433
85009
|
function createTempSettingsFile(_modelDisplay, port, proxyAuthMode, userStatusLineCommand) {
|
|
84434
85010
|
const homeDir = process.env.HOME || process.env.USERPROFILE || tmpdir2();
|
|
84435
|
-
const claudishDir =
|
|
85011
|
+
const claudishDir = join41(homeDir, ".claudish");
|
|
84436
85012
|
try {
|
|
84437
85013
|
mkdirSync19(claudishDir, { recursive: true });
|
|
84438
85014
|
} catch {}
|
|
84439
85015
|
const timestamp = Date.now();
|
|
84440
|
-
const tempPath =
|
|
84441
|
-
const tokenFilePath =
|
|
85016
|
+
const tempPath = join41(claudishDir, `settings-${timestamp}.json`);
|
|
85017
|
+
const tokenFilePath = join41(claudishDir, `tokens-${port}.json`);
|
|
84442
85018
|
cleanupStaleTokenFiles(claudishDir);
|
|
84443
85019
|
initializeTokenFile(tokenFilePath);
|
|
84444
85020
|
let statusCommand;
|
|
@@ -84692,8 +85268,8 @@ async function runClaudeWithProxy(config3, proxyUrl, onCleanup) {
|
|
|
84692
85268
|
console.error("Install it from: https://claude.com/claude-code");
|
|
84693
85269
|
console.error(`
|
|
84694
85270
|
Or set CLAUDE_PATH to your custom installation:`);
|
|
84695
|
-
const home =
|
|
84696
|
-
const localPath = isWindows2() ?
|
|
85271
|
+
const home = homedir36();
|
|
85272
|
+
const localPath = isWindows2() ? join41(home, ".claude", "local", "claude.exe") : join41(home, ".claude", "local", "claude");
|
|
84697
85273
|
console.error(` export CLAUDE_PATH=${localPath}`);
|
|
84698
85274
|
process.exit(1);
|
|
84699
85275
|
}
|
|
@@ -84704,11 +85280,11 @@ Or set CLAUDE_PATH to your custom installation:`);
|
|
|
84704
85280
|
const childWantsTty = config3.interactive && !process.stdout.isTTY && Boolean(process.stdin.isTTY);
|
|
84705
85281
|
if (childWantsTty) {
|
|
84706
85282
|
try {
|
|
84707
|
-
const fd =
|
|
85283
|
+
const fd = openSync8("/dev/fd/0", "r+");
|
|
84708
85284
|
if (isatty(fd)) {
|
|
84709
85285
|
ttyFd = fd;
|
|
84710
85286
|
} else {
|
|
84711
|
-
|
|
85287
|
+
closeSync8(fd);
|
|
84712
85288
|
}
|
|
84713
85289
|
} catch {
|
|
84714
85290
|
ttyFd = undefined;
|
|
@@ -84731,7 +85307,7 @@ Or set CLAUDE_PATH to your custom installation:`);
|
|
|
84731
85307
|
const fdToClose = ttyFd;
|
|
84732
85308
|
proc.on("spawn", () => {
|
|
84733
85309
|
try {
|
|
84734
|
-
|
|
85310
|
+
closeSync8(fdToClose);
|
|
84735
85311
|
} catch {}
|
|
84736
85312
|
});
|
|
84737
85313
|
}
|
|
@@ -84773,23 +85349,23 @@ function setupSignalHandlers(proc, tempSettingsPath, quiet, onCleanup) {
|
|
|
84773
85349
|
async function findClaudeBinary() {
|
|
84774
85350
|
const isWindows3 = process.platform === "win32";
|
|
84775
85351
|
if (process.env.CLAUDE_PATH) {
|
|
84776
|
-
if (
|
|
85352
|
+
if (existsSync31(process.env.CLAUDE_PATH)) {
|
|
84777
85353
|
return process.env.CLAUDE_PATH;
|
|
84778
85354
|
}
|
|
84779
85355
|
}
|
|
84780
|
-
const home =
|
|
84781
|
-
const localPath = isWindows3 ?
|
|
84782
|
-
if (
|
|
85356
|
+
const home = homedir36();
|
|
85357
|
+
const localPath = isWindows3 ? join41(home, ".claude", "local", "claude.exe") : join41(home, ".claude", "local", "claude");
|
|
85358
|
+
if (existsSync31(localPath)) {
|
|
84783
85359
|
return localPath;
|
|
84784
85360
|
}
|
|
84785
85361
|
if (isWindows3) {
|
|
84786
85362
|
const windowsPaths = [
|
|
84787
|
-
|
|
84788
|
-
|
|
84789
|
-
|
|
85363
|
+
join41(home, "AppData", "Roaming", "npm", "claude.cmd"),
|
|
85364
|
+
join41(home, ".npm-global", "claude.cmd"),
|
|
85365
|
+
join41(home, "node_modules", ".bin", "claude.cmd")
|
|
84790
85366
|
];
|
|
84791
85367
|
for (const path2 of windowsPaths) {
|
|
84792
|
-
if (
|
|
85368
|
+
if (existsSync31(path2)) {
|
|
84793
85369
|
return path2;
|
|
84794
85370
|
}
|
|
84795
85371
|
}
|
|
@@ -84797,14 +85373,14 @@ async function findClaudeBinary() {
|
|
|
84797
85373
|
const commonPaths = [
|
|
84798
85374
|
"/usr/local/bin/claude",
|
|
84799
85375
|
"/opt/homebrew/bin/claude",
|
|
84800
|
-
|
|
84801
|
-
|
|
84802
|
-
|
|
85376
|
+
join41(home, ".npm-global/bin/claude"),
|
|
85377
|
+
join41(home, ".local/bin/claude"),
|
|
85378
|
+
join41(home, "node_modules/.bin/claude"),
|
|
84803
85379
|
"/data/data/com.termux/files/usr/bin/claude",
|
|
84804
|
-
|
|
85380
|
+
join41(home, "../usr/bin/claude")
|
|
84805
85381
|
];
|
|
84806
85382
|
for (const path2 of commonPaths) {
|
|
84807
|
-
if (
|
|
85383
|
+
if (existsSync31(path2)) {
|
|
84808
85384
|
return path2;
|
|
84809
85385
|
}
|
|
84810
85386
|
}
|
|
@@ -84885,17 +85461,17 @@ __export(exports_diag_output, {
|
|
|
84885
85461
|
createDiagOutput: () => createDiagOutput
|
|
84886
85462
|
});
|
|
84887
85463
|
import { createWriteStream as createWriteStream3, mkdirSync as mkdirSync20, unlinkSync as unlinkSync11, writeFileSync as writeFileSync22 } from "fs";
|
|
84888
|
-
import { homedir as
|
|
84889
|
-
import { join as
|
|
85464
|
+
import { homedir as homedir37 } from "os";
|
|
85465
|
+
import { join as join42 } from "path";
|
|
84890
85466
|
function getClaudishDir() {
|
|
84891
|
-
const dir =
|
|
85467
|
+
const dir = join42(homedir37(), ".claudish");
|
|
84892
85468
|
try {
|
|
84893
85469
|
mkdirSync20(dir, { recursive: true });
|
|
84894
85470
|
} catch {}
|
|
84895
85471
|
return dir;
|
|
84896
85472
|
}
|
|
84897
85473
|
function getDiagLogPath() {
|
|
84898
|
-
return
|
|
85474
|
+
return join42(getClaudishDir(), `diag-${process.pid}.log`);
|
|
84899
85475
|
}
|
|
84900
85476
|
|
|
84901
85477
|
class LogFileDiagOutput {
|
|
@@ -85500,7 +86076,7 @@ var init_widgets = __esm(() => {
|
|
|
85500
86076
|
});
|
|
85501
86077
|
|
|
85502
86078
|
// src/session/conversation.ts
|
|
85503
|
-
import { closeSync as
|
|
86079
|
+
import { closeSync as closeSync9, openSync as openSync9, readSync as readSync4, statSync as statSync9 } from "fs";
|
|
85504
86080
|
import { StringDecoder as StringDecoder2 } from "string_decoder";
|
|
85505
86081
|
function looksLikeTurn(line) {
|
|
85506
86082
|
const assistant = line.includes('"type":"assistant"');
|
|
@@ -85555,8 +86131,8 @@ function readConversation(file2, opts = {}) {
|
|
|
85555
86131
|
};
|
|
85556
86132
|
let fd = null;
|
|
85557
86133
|
try {
|
|
85558
|
-
const size =
|
|
85559
|
-
fd =
|
|
86134
|
+
const size = statSync9(file2).size;
|
|
86135
|
+
fd = openSync9(file2, "r");
|
|
85560
86136
|
const buf = Buffer.allocUnsafe(chunkBytes);
|
|
85561
86137
|
const decoder = new StringDecoder2("utf-8");
|
|
85562
86138
|
let pending = "";
|
|
@@ -85588,7 +86164,7 @@ function readConversation(file2, opts = {}) {
|
|
|
85588
86164
|
take({ role: raw2.role, text, elided });
|
|
85589
86165
|
};
|
|
85590
86166
|
while (pos < size) {
|
|
85591
|
-
const n =
|
|
86167
|
+
const n = readSync4(fd, buf, 0, Math.min(chunkBytes, size - pos), pos);
|
|
85592
86168
|
if (n <= 0)
|
|
85593
86169
|
break;
|
|
85594
86170
|
pos += n;
|
|
@@ -85612,7 +86188,7 @@ function readConversation(file2, opts = {}) {
|
|
|
85612
86188
|
} catch {} finally {
|
|
85613
86189
|
if (fd !== null) {
|
|
85614
86190
|
try {
|
|
85615
|
-
|
|
86191
|
+
closeSync9(fd);
|
|
85616
86192
|
} catch {}
|
|
85617
86193
|
}
|
|
85618
86194
|
}
|
|
@@ -87219,16 +87795,16 @@ __export(exports_session_stats, {
|
|
|
87219
87795
|
readSessionStats: () => readSessionStats,
|
|
87220
87796
|
tokenFilePath: () => tokenFilePath
|
|
87221
87797
|
});
|
|
87222
|
-
import { readFileSync as
|
|
87223
|
-
import { homedir as
|
|
87224
|
-
import { join as
|
|
87798
|
+
import { readFileSync as readFileSync33 } from "fs";
|
|
87799
|
+
import { homedir as homedir38 } from "os";
|
|
87800
|
+
import { join as join43 } from "path";
|
|
87225
87801
|
function tokenFilePath(port) {
|
|
87226
|
-
return process.env.CLAUDISH_TOKEN_FILE ||
|
|
87802
|
+
return process.env.CLAUDISH_TOKEN_FILE || join43(homedir38(), ".claudish", `tokens-${port}.json`);
|
|
87227
87803
|
}
|
|
87228
87804
|
function readSessionStats(port, opts) {
|
|
87229
87805
|
let raw2;
|
|
87230
87806
|
try {
|
|
87231
|
-
raw2 = JSON.parse(
|
|
87807
|
+
raw2 = JSON.parse(readFileSync33(tokenFilePath(port), "utf-8"));
|
|
87232
87808
|
} catch {
|
|
87233
87809
|
return null;
|
|
87234
87810
|
}
|
|
@@ -87567,8 +88143,8 @@ var init_session_summary = __esm(() => {
|
|
|
87567
88143
|
init_op_source();
|
|
87568
88144
|
init_startup_trace();
|
|
87569
88145
|
var import_dotenv3 = __toESM(require_main(), 1);
|
|
87570
|
-
import { existsSync as
|
|
87571
|
-
import { join as
|
|
88146
|
+
import { existsSync as existsSync32, readFileSync as readFileSync34 } from "fs";
|
|
88147
|
+
import { join as join44, resolve as resolve6 } from "path";
|
|
87572
88148
|
import_dotenv3.config({ quiet: true });
|
|
87573
88149
|
function classifyStartupKind() {
|
|
87574
88150
|
const argv = process.argv.slice(2);
|
|
@@ -87668,7 +88244,7 @@ async function applyConfigOverride() {
|
|
|
87668
88244
|
const { planConfigOverride: planConfigOverride2, setConfigFileOverride: setConfigFileOverride2 } = await Promise.resolve().then(() => exports_config_override);
|
|
87669
88245
|
const plan = planConfigOverride2(process.argv.slice(2), process.env, {
|
|
87670
88246
|
resolve: resolve6,
|
|
87671
|
-
exists:
|
|
88247
|
+
exists: existsSync32
|
|
87672
88248
|
});
|
|
87673
88249
|
if (plan.kind === "none")
|
|
87674
88250
|
return;
|
|
@@ -87841,14 +88417,14 @@ async function runCli() {
|
|
|
87841
88417
|
if (cliConfig.team && cliConfig.team.length > 0) {
|
|
87842
88418
|
let prompt = cliConfig.claudeArgs.join(" ");
|
|
87843
88419
|
if (cliConfig.inputFile) {
|
|
87844
|
-
prompt =
|
|
88420
|
+
prompt = readFileSync34(cliConfig.inputFile, "utf-8");
|
|
87845
88421
|
}
|
|
87846
88422
|
if (!prompt.trim()) {
|
|
87847
88423
|
console.error("Error: --team requires a prompt (positional args or -f <file>)");
|
|
87848
88424
|
process.exit(1);
|
|
87849
88425
|
}
|
|
87850
88426
|
const mode = cliConfig.teamMode ?? "default";
|
|
87851
|
-
const sessionPath =
|
|
88427
|
+
const sessionPath = join44(process.cwd(), `.claudish-team-${Date.now()}`);
|
|
87852
88428
|
if (mode === "json") {
|
|
87853
88429
|
const { setupSession: setupSession2, runModels: runModels2 } = await Promise.resolve().then(() => (init_team_orchestrator(), exports_team_orchestrator));
|
|
87854
88430
|
setupSession2(sessionPath, cliConfig.team, prompt);
|
|
@@ -87858,9 +88434,9 @@ async function runCli() {
|
|
|
87858
88434
|
});
|
|
87859
88435
|
const result = { ...status2, responses: {} };
|
|
87860
88436
|
for (const anonId of Object.keys(status2.models)) {
|
|
87861
|
-
const responsePath =
|
|
88437
|
+
const responsePath = join44(sessionPath, `response-${anonId}.md`);
|
|
87862
88438
|
try {
|
|
87863
|
-
const raw2 =
|
|
88439
|
+
const raw2 = readFileSync34(responsePath, "utf-8").trim();
|
|
87864
88440
|
try {
|
|
87865
88441
|
result.responses[anonId] = JSON.parse(raw2);
|
|
87866
88442
|
} catch {
|
|
@@ -88066,7 +88642,10 @@ Team Status`);
|
|
|
88066
88642
|
advisorModels: cliConfig.advisorModels,
|
|
88067
88643
|
advisorCollector: cliConfig.advisorCollector,
|
|
88068
88644
|
modelChain: cliConfig.monitor ? undefined : cliConfig.modelChain,
|
|
88069
|
-
classifier: resolveClassifierConfig(cliConfig, process.env)
|
|
88645
|
+
classifier: resolveClassifierConfig(cliConfig, process.env),
|
|
88646
|
+
effortOverride: cliConfig.effortOverride,
|
|
88647
|
+
modelParams: cliConfig.modelParams,
|
|
88648
|
+
proOnUltracode: cliConfig.proOnUltracode
|
|
88070
88649
|
}));
|
|
88071
88650
|
const diag = createDiagOutput2({
|
|
88072
88651
|
interactive: cliConfig.interactive,
|