claudish 14.27.3 → 14.28.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 +1766 -844
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -5542,7 +5542,7 @@ var init_env_placeholder = __esm(() => {
|
|
|
5542
5542
|
});
|
|
5543
5543
|
|
|
5544
5544
|
// src/version.ts
|
|
5545
|
-
var VERSION = "14.
|
|
5545
|
+
var VERSION = "14.28.0";
|
|
5546
5546
|
|
|
5547
5547
|
// src/redact.ts
|
|
5548
5548
|
function isPlaceholder(value) {
|
|
@@ -14145,7 +14145,7 @@ var init_bundled_recommended_list = __esm(() => {
|
|
|
14145
14145
|
}
|
|
14146
14146
|
}
|
|
14147
14147
|
},
|
|
14148
|
-
fetchedAt: "2026-11-
|
|
14148
|
+
fetchedAt: "2026-11-16T23:53:10.997Z",
|
|
14149
14149
|
format: 1,
|
|
14150
14150
|
recommendations: {
|
|
14151
14151
|
contractVersion: 3,
|
|
@@ -49806,6 +49806,1236 @@ function decideCodexSpeed(speed, modelInfo) {
|
|
|
49806
49806
|
}
|
|
49807
49807
|
var CODEX_SERVICE_TIER_POINTER = "/service_tier";
|
|
49808
49808
|
|
|
49809
|
+
// src/handlers/shared/format/identity-filter.ts
|
|
49810
|
+
function removeBackgroundInfo(text) {
|
|
49811
|
+
let start = text.indexOf(BACKGROUND_OPEN);
|
|
49812
|
+
if (start === -1)
|
|
49813
|
+
return text;
|
|
49814
|
+
let out = "";
|
|
49815
|
+
let done = 0;
|
|
49816
|
+
while (start !== -1) {
|
|
49817
|
+
const end = text.indexOf(BACKGROUND_CLOSE, start + BACKGROUND_OPEN.length);
|
|
49818
|
+
if (end === -1)
|
|
49819
|
+
break;
|
|
49820
|
+
out += text.slice(done, start);
|
|
49821
|
+
done = end + BACKGROUND_CLOSE.length;
|
|
49822
|
+
start = text.indexOf(BACKGROUND_OPEN, done);
|
|
49823
|
+
}
|
|
49824
|
+
return out + text.slice(done);
|
|
49825
|
+
}
|
|
49826
|
+
function rangesOf(text, spans) {
|
|
49827
|
+
return [...text.matchAll(spans)].map((m) => [m.index, m.index + m[0].length]);
|
|
49828
|
+
}
|
|
49829
|
+
function merged(ranges) {
|
|
49830
|
+
if (ranges.length < 2)
|
|
49831
|
+
return ranges;
|
|
49832
|
+
const sorted = [...ranges].sort((a, b) => a[0] - b[0]);
|
|
49833
|
+
const out = [sorted[0]];
|
|
49834
|
+
for (const [from, to] of sorted.slice(1)) {
|
|
49835
|
+
const last = out[out.length - 1];
|
|
49836
|
+
if (from <= last[1])
|
|
49837
|
+
last[1] = Math.max(last[1], to);
|
|
49838
|
+
else
|
|
49839
|
+
out.push([from, to]);
|
|
49840
|
+
}
|
|
49841
|
+
return out;
|
|
49842
|
+
}
|
|
49843
|
+
function inside(ranges, at) {
|
|
49844
|
+
let low = 0;
|
|
49845
|
+
let high = ranges.length - 1;
|
|
49846
|
+
while (low <= high) {
|
|
49847
|
+
const mid = low + high >> 1;
|
|
49848
|
+
if (at < ranges[mid][0])
|
|
49849
|
+
high = mid - 1;
|
|
49850
|
+
else if (at >= ranges[mid][1])
|
|
49851
|
+
low = mid + 1;
|
|
49852
|
+
else
|
|
49853
|
+
return true;
|
|
49854
|
+
}
|
|
49855
|
+
return false;
|
|
49856
|
+
}
|
|
49857
|
+
function inlineCodeRanges(text, fences) {
|
|
49858
|
+
if (!text.includes("`"))
|
|
49859
|
+
return [];
|
|
49860
|
+
const out = [];
|
|
49861
|
+
let runs = [];
|
|
49862
|
+
const closeLine = () => {
|
|
49863
|
+
if (runs.length > 1) {
|
|
49864
|
+
const next = new Array(runs.length).fill(-1);
|
|
49865
|
+
const seen = new Map;
|
|
49866
|
+
for (let k = runs.length - 1;k >= 0; k--) {
|
|
49867
|
+
next[k] = seen.get(runs[k][1]) ?? -1;
|
|
49868
|
+
seen.set(runs[k][1], k);
|
|
49869
|
+
}
|
|
49870
|
+
for (let k = 0;k < runs.length; ) {
|
|
49871
|
+
const close = next[k];
|
|
49872
|
+
if (close === -1) {
|
|
49873
|
+
k++;
|
|
49874
|
+
} else {
|
|
49875
|
+
out.push([runs[k][0], runs[close][0] + runs[close][1]]);
|
|
49876
|
+
k = close + 1;
|
|
49877
|
+
}
|
|
49878
|
+
}
|
|
49879
|
+
}
|
|
49880
|
+
runs = [];
|
|
49881
|
+
};
|
|
49882
|
+
for (let at = 0;at < text.length; at++) {
|
|
49883
|
+
const char = text.charCodeAt(at);
|
|
49884
|
+
if (char === 10) {
|
|
49885
|
+
closeLine();
|
|
49886
|
+
} else if (char === 96) {
|
|
49887
|
+
let end = at + 1;
|
|
49888
|
+
while (end < text.length && text.charCodeAt(end) === 96)
|
|
49889
|
+
end++;
|
|
49890
|
+
if (!inside(fences, at))
|
|
49891
|
+
runs.push([at, end - at]);
|
|
49892
|
+
at = end - 1;
|
|
49893
|
+
}
|
|
49894
|
+
}
|
|
49895
|
+
closeLine();
|
|
49896
|
+
return out;
|
|
49897
|
+
}
|
|
49898
|
+
function stringRanges(text) {
|
|
49899
|
+
if (!text.includes('"'))
|
|
49900
|
+
return [];
|
|
49901
|
+
const out = [];
|
|
49902
|
+
let open = -1;
|
|
49903
|
+
for (let at = 0;at < text.length; at++) {
|
|
49904
|
+
const char = text.charCodeAt(at);
|
|
49905
|
+
if (char === 10) {
|
|
49906
|
+
open = -1;
|
|
49907
|
+
} else if (open === -1) {
|
|
49908
|
+
if (char === 34)
|
|
49909
|
+
open = at;
|
|
49910
|
+
} else if (char === 92) {
|
|
49911
|
+
if (text.charCodeAt(at + 1) !== 10)
|
|
49912
|
+
at++;
|
|
49913
|
+
} else if (char === 34) {
|
|
49914
|
+
out.push([open, at + 1]);
|
|
49915
|
+
open = -1;
|
|
49916
|
+
}
|
|
49917
|
+
}
|
|
49918
|
+
return out;
|
|
49919
|
+
}
|
|
49920
|
+
function codeRanges(text) {
|
|
49921
|
+
const fences = merged(rangesOf(text, FENCE_RE));
|
|
49922
|
+
return merged([...fences, ...inlineCodeRanges(text, fences)]);
|
|
49923
|
+
}
|
|
49924
|
+
function literalRanges(text) {
|
|
49925
|
+
return merged([...codeRanges(text), ...stringRanges(text)]);
|
|
49926
|
+
}
|
|
49927
|
+
function replaceOutside(text, ranges, rule, replacer) {
|
|
49928
|
+
return text.replace(rule, (match, ...rest) => {
|
|
49929
|
+
const offsetAt = rest.findIndex((arg) => typeof arg === "number");
|
|
49930
|
+
const offset = rest[offsetAt];
|
|
49931
|
+
if (inside(ranges, offset))
|
|
49932
|
+
return match;
|
|
49933
|
+
return replacer(match, offset, rest.slice(0, offsetAt));
|
|
49934
|
+
});
|
|
49935
|
+
}
|
|
49936
|
+
function renameReader(text) {
|
|
49937
|
+
if (!text.includes("Claude"))
|
|
49938
|
+
return text;
|
|
49939
|
+
return replaceOutside(text, literalRanges(text), READER_CLAUDE, (match, offset) => {
|
|
49940
|
+
const name = SENTENCE_START.test(text.slice(Math.max(0, offset - 16), offset)) ? READER_NAME[0].toUpperCase() + READER_NAME.slice(1) : READER_NAME;
|
|
49941
|
+
return name + match.slice("Claude".length);
|
|
49942
|
+
});
|
|
49943
|
+
}
|
|
49944
|
+
function scrubText(text) {
|
|
49945
|
+
let out = text;
|
|
49946
|
+
for (const rule of SENTENCE_RULES)
|
|
49947
|
+
out = out.replace(rule, "");
|
|
49948
|
+
out = removeBackgroundInfo(out);
|
|
49949
|
+
for (const rule of LINE_RULES)
|
|
49950
|
+
out = out.replace(rule, "");
|
|
49951
|
+
for (const [rule, to] of RENAMES)
|
|
49952
|
+
out = replaceOutside(out, literalRanges(out), rule, to);
|
|
49953
|
+
return renameReader(out);
|
|
49954
|
+
}
|
|
49955
|
+
function stripKnownHead(text) {
|
|
49956
|
+
for (const head of KNOWN_HEADS) {
|
|
49957
|
+
if (text.startsWith(head))
|
|
49958
|
+
return { body: text.slice(head.length).trimStart(), hadHead: true };
|
|
49959
|
+
}
|
|
49960
|
+
return { body: text, hadHead: false };
|
|
49961
|
+
}
|
|
49962
|
+
function filterIdentity(content, head) {
|
|
49963
|
+
const hadIdentity = IDENTITY_OPENER.test(content);
|
|
49964
|
+
const scrubbed = scrubText(content).replace(/\n{3,}/g, `
|
|
49965
|
+
|
|
49966
|
+
`).trimStart();
|
|
49967
|
+
const { body, hadHead } = stripKnownHead(scrubbed);
|
|
49968
|
+
if (!hadIdentity && !hadHead)
|
|
49969
|
+
return scrubbed;
|
|
49970
|
+
if (head === undefined && hadHead)
|
|
49971
|
+
return scrubbed;
|
|
49972
|
+
const chosen = head ?? NEUTRAL_IDENTITY_HEAD;
|
|
49973
|
+
return body ? `${chosen}
|
|
49974
|
+
|
|
49975
|
+
${body}` : chosen;
|
|
49976
|
+
}
|
|
49977
|
+
function indexOutsideCode(text, needle, from, code) {
|
|
49978
|
+
for (let at = text.indexOf(needle, from);at !== -1; at = text.indexOf(needle, at + 1)) {
|
|
49979
|
+
if (!inside(code, at))
|
|
49980
|
+
return at;
|
|
49981
|
+
}
|
|
49982
|
+
return -1;
|
|
49983
|
+
}
|
|
49984
|
+
function closingTagAt(text, start, open, close, inlineCode) {
|
|
49985
|
+
let depth = 0;
|
|
49986
|
+
let at = start;
|
|
49987
|
+
for (;; ) {
|
|
49988
|
+
const nextClose = indexOutsideCode(text, close, at, inlineCode);
|
|
49989
|
+
if (nextClose === -1)
|
|
49990
|
+
return -1;
|
|
49991
|
+
const nextOpen = indexOutsideCode(text, open, at, inlineCode);
|
|
49992
|
+
if (nextOpen !== -1 && nextOpen < nextClose) {
|
|
49993
|
+
depth++;
|
|
49994
|
+
at = nextOpen + open.length;
|
|
49995
|
+
continue;
|
|
49996
|
+
}
|
|
49997
|
+
depth--;
|
|
49998
|
+
if (depth === 0)
|
|
49999
|
+
return nextClose;
|
|
50000
|
+
at = nextClose + close.length;
|
|
50001
|
+
}
|
|
50002
|
+
}
|
|
50003
|
+
function scrubTagged(text, tag) {
|
|
50004
|
+
const open = `<${tag}>`;
|
|
50005
|
+
const close = `</${tag}>`;
|
|
50006
|
+
if (!text.includes(open))
|
|
50007
|
+
return text;
|
|
50008
|
+
const code = codeRanges(text);
|
|
50009
|
+
const inlineCode = merged(inlineCodeRanges(text, []));
|
|
50010
|
+
let out = "";
|
|
50011
|
+
let done = 0;
|
|
50012
|
+
for (;; ) {
|
|
50013
|
+
const start = indexOutsideCode(text, open, done, code);
|
|
50014
|
+
if (start === -1)
|
|
50015
|
+
break;
|
|
50016
|
+
const end = closingTagAt(text, start, open, close, inlineCode);
|
|
50017
|
+
if (end === -1)
|
|
50018
|
+
break;
|
|
50019
|
+
const stop = end + close.length;
|
|
50020
|
+
out += text.slice(done, start) + scrubText(text.slice(start, stop));
|
|
50021
|
+
done = stop;
|
|
50022
|
+
}
|
|
50023
|
+
return out + text.slice(done);
|
|
50024
|
+
}
|
|
50025
|
+
function scrubInjectedSpans(text) {
|
|
50026
|
+
if (!MAY_HOLD_SPAN.test(text))
|
|
50027
|
+
return text;
|
|
50028
|
+
let out = text;
|
|
50029
|
+
for (const tag of INJECTED_TAGS)
|
|
50030
|
+
out = scrubTagged(out, tag);
|
|
50031
|
+
for (const line of INJECTED_LINES)
|
|
50032
|
+
out = replaceOutside(out, codeRanges(out), line, scrubText);
|
|
50033
|
+
return out;
|
|
50034
|
+
}
|
|
50035
|
+
function systemTextOf2(system) {
|
|
50036
|
+
if (typeof system === "string")
|
|
50037
|
+
return system;
|
|
50038
|
+
if (!Array.isArray(system))
|
|
50039
|
+
return "";
|
|
50040
|
+
return system.map((item) => typeof item === "string" ? item : item?.text ?? "").filter((text) => text.trim() !== "").join(`
|
|
50041
|
+
|
|
50042
|
+
`);
|
|
50043
|
+
}
|
|
50044
|
+
function scrubSchema(schema) {
|
|
50045
|
+
if (Array.isArray(schema))
|
|
50046
|
+
return schema.map(scrubSchema);
|
|
50047
|
+
if (!schema || typeof schema !== "object")
|
|
50048
|
+
return schema;
|
|
50049
|
+
const out = {};
|
|
50050
|
+
for (const [key, value] of Object.entries(schema)) {
|
|
50051
|
+
if (key === "description" && typeof value === "string")
|
|
50052
|
+
out[key] = scrubText(value);
|
|
50053
|
+
else if (SCHEMA_VALUE_KEYS.has(key))
|
|
50054
|
+
out[key] = value;
|
|
50055
|
+
else if (SCHEMA_NAME_MAPS.has(key))
|
|
50056
|
+
out[key] = scrubNamedSchemas(value);
|
|
50057
|
+
else
|
|
50058
|
+
out[key] = scrubSchema(value);
|
|
50059
|
+
}
|
|
50060
|
+
return out;
|
|
50061
|
+
}
|
|
50062
|
+
function scrubNamedSchemas(map) {
|
|
50063
|
+
if (!map || typeof map !== "object" || Array.isArray(map))
|
|
50064
|
+
return map;
|
|
50065
|
+
const out = {};
|
|
50066
|
+
for (const [name, schema] of Object.entries(map))
|
|
50067
|
+
out[name] = scrubSchema(schema);
|
|
50068
|
+
return out;
|
|
50069
|
+
}
|
|
50070
|
+
function scrubToolDefinition(tool) {
|
|
50071
|
+
if (!tool || typeof tool !== "object")
|
|
50072
|
+
return tool;
|
|
50073
|
+
const out = { ...tool };
|
|
50074
|
+
if (typeof tool.description === "string")
|
|
50075
|
+
out.description = scrubText(tool.description);
|
|
50076
|
+
if (tool.input_schema)
|
|
50077
|
+
out.input_schema = scrubSchema(tool.input_schema);
|
|
50078
|
+
return out;
|
|
50079
|
+
}
|
|
50080
|
+
function scrubUserContent(content) {
|
|
50081
|
+
if (typeof content === "string")
|
|
50082
|
+
return scrubInjectedSpans(content);
|
|
50083
|
+
if (!Array.isArray(content))
|
|
50084
|
+
return content;
|
|
50085
|
+
return content.map((block) => block?.type === "text" && typeof block.text === "string" ? { ...block, text: scrubInjectedSpans(block.text) } : block);
|
|
50086
|
+
}
|
|
50087
|
+
function scrubSystemContent(content) {
|
|
50088
|
+
if (typeof content === "string")
|
|
50089
|
+
return scrubText(content);
|
|
50090
|
+
if (!Array.isArray(content))
|
|
50091
|
+
return content;
|
|
50092
|
+
return content.map((block) => {
|
|
50093
|
+
if (block?.type === "text" && typeof block.text === "string") {
|
|
50094
|
+
return { ...block, text: scrubText(block.text) };
|
|
50095
|
+
}
|
|
50096
|
+
if (block?.type === "tool_addition" && block.tool?.definition) {
|
|
50097
|
+
return {
|
|
50098
|
+
...block,
|
|
50099
|
+
tool: { ...block.tool, definition: scrubToolDefinition(block.tool.definition) }
|
|
50100
|
+
};
|
|
50101
|
+
}
|
|
50102
|
+
return block;
|
|
50103
|
+
});
|
|
50104
|
+
}
|
|
50105
|
+
function scrubSystem(system, head, hadIdentity) {
|
|
50106
|
+
if (typeof system === "string") {
|
|
50107
|
+
const body = collapse(scrubText(system));
|
|
50108
|
+
if (!hadIdentity)
|
|
50109
|
+
return body;
|
|
50110
|
+
return body ? `${head}
|
|
50111
|
+
|
|
50112
|
+
${body}` : head;
|
|
50113
|
+
}
|
|
50114
|
+
if (Array.isArray(system)) {
|
|
50115
|
+
const blocks = system.map((b) => typeof b === "string" ? { type: "text", text: b } : b).map((b) => b?.type === "text" && typeof b.text === "string" ? { ...b, text: collapse(scrubText(b.text)) } : b).filter((b) => !(b?.type === "text" && (b.text ?? "").trim() === ""));
|
|
50116
|
+
if (hadIdentity)
|
|
50117
|
+
blocks.unshift({ type: "text", text: head });
|
|
50118
|
+
return blocks;
|
|
50119
|
+
}
|
|
50120
|
+
return hadIdentity ? head : system;
|
|
50121
|
+
}
|
|
50122
|
+
function scrubHarnessIdentity(req, head) {
|
|
50123
|
+
const out = { ...req };
|
|
50124
|
+
const hadIdentity = IDENTITY_OPENER.test(systemTextOf2(req.system));
|
|
50125
|
+
out.system = scrubSystem(req.system, head, hadIdentity);
|
|
50126
|
+
if (Array.isArray(req.tools))
|
|
50127
|
+
out.tools = req.tools.map(scrubToolDefinition);
|
|
50128
|
+
if (Array.isArray(req.messages)) {
|
|
50129
|
+
out.messages = req.messages.map((msg) => {
|
|
50130
|
+
if (msg?.role === "user")
|
|
50131
|
+
return { ...msg, content: scrubUserContent(msg.content) };
|
|
50132
|
+
if (msg?.role === "system")
|
|
50133
|
+
return { ...msg, content: scrubSystemContent(msg.content) };
|
|
50134
|
+
return msg;
|
|
50135
|
+
});
|
|
50136
|
+
}
|
|
50137
|
+
return out;
|
|
50138
|
+
}
|
|
50139
|
+
function identityHeadFor(providerName) {
|
|
50140
|
+
return providerName === "antigravity" ? ANTIGRAVITY_IDENTITY_HEAD : NEUTRAL_IDENTITY_HEAD;
|
|
50141
|
+
}
|
|
50142
|
+
function keepsClaudeIdentity(route) {
|
|
50143
|
+
if (route.vendor)
|
|
50144
|
+
return route.vendor.toLowerCase() === "anthropic";
|
|
50145
|
+
if (route.native)
|
|
50146
|
+
return true;
|
|
50147
|
+
return /(^|[/.])claude-/i.test(route.model);
|
|
50148
|
+
}
|
|
50149
|
+
var NEUTRAL_IDENTITY_HEAD = "You are an AI coding agent working in a command-line agent harness. If asked who you are, name your actual model and the company that made it.", ANTIGRAVITY_IDENTITY_HEAD, KNOWN_HEADS, HARNESS_NAME = "Agent CLI", LINE_RULES, SENTENCE_RULES, BACKGROUND_OPEN = "<claude_background_info>", BACKGROUND_CLOSE = "</claude_background_info>", FENCE_OPEN, FENCE_CLOSE, FENCE, FENCE_RE, HARNESS_IN_PROSE, RENAMES, READER_NAME = "the assistant", READER_CLAUDE, SENTENCE_START, IDENTITY_OPENER, INJECTED_TAGS, INJECTED_LINES, MAY_HOLD_SPAN, SCHEMA_VALUE_KEYS, SCHEMA_NAME_MAPS, collapse = (text) => text.replace(/\n{3,}/g, `
|
|
50150
|
+
|
|
50151
|
+
`).trimStart();
|
|
50152
|
+
var init_identity_filter = __esm(() => {
|
|
50153
|
+
ANTIGRAVITY_IDENTITY_HEAD = [
|
|
50154
|
+
"You are Antigravity, a powerful agentic AI coding assistant designed by the Google Deepmind team working on Advanced Agentic Coding.",
|
|
50155
|
+
"You are pair programming with a USER to solve their coding task. The task may require creating a new codebase, modifying or debugging an existing codebase, or simply answering a question."
|
|
50156
|
+
].join(`
|
|
50157
|
+
`);
|
|
50158
|
+
KNOWN_HEADS = [NEUTRAL_IDENTITY_HEAD, ANTIGRAVITY_IDENTITY_HEAD];
|
|
50159
|
+
LINE_RULES = [
|
|
50160
|
+
/^[ \t]*(?:-[ \t]+)?The most recent Claude models are[^\n]*(?:\n|$)/gm,
|
|
50161
|
+
/^[ \t]*(?:-[ \t]+)?Claude Code is available as a CLI[^\n]*(?:\n|$)/gm,
|
|
50162
|
+
/^[ \t]*(?:-[ \t]+)?Fast mode for Claude Code[^\n]*(?:\n|$)/gm
|
|
50163
|
+
];
|
|
50164
|
+
SENTENCE_RULES = [
|
|
50165
|
+
/You are Claude Code, Anthropic's official CLI(?:[^\n]{0,300}?\.(?=\s|$|<)|[^.\n]{0,300})/g,
|
|
50166
|
+
/You are a Claude agent, built on Anthropic's Claude Agent SDK\.?/g,
|
|
50167
|
+
/You are powered by the model named [^\n]{0,300}?\.(?=\s|$|<)/g,
|
|
50168
|
+
/The exact model ID is [^\s<]{1,200}?\.(?=\s|$|<)/g,
|
|
50169
|
+
/Assistant knowledge cutoff is [^\n]{0,300}?\.(?=\s|$|<)/g
|
|
50170
|
+
];
|
|
50171
|
+
FENCE_OPEN = String.raw`^(?:[ \t]*(?:>|[-*+][ \t]|\d+[.)][ \t]))*[ \t]*((\x60|~)\2{2,})[^\n]*`;
|
|
50172
|
+
FENCE_CLOSE = String.raw`^(?:[ \t]*>)*[ \t]*\1\2*[ \t]*$`;
|
|
50173
|
+
FENCE = String.raw`${FENCE_OPEN}(?:\n[\s\S]*?(?:${FENCE_CLOSE}|(?![\s\S]))|(?![\s\S]))`;
|
|
50174
|
+
FENCE_RE = new RegExp(FENCE, "gm");
|
|
50175
|
+
HARNESS_IN_PROSE = /(?<![\w/\\"'`.-])Claude Code(?![\w"`/\\]|'(?!s\b)|\.\w)/g;
|
|
50176
|
+
RENAMES = [
|
|
50177
|
+
[/ ?\(claude\.ai\/code\)/g, () => ""],
|
|
50178
|
+
[HARNESS_IN_PROSE, () => HARNESS_NAME],
|
|
50179
|
+
[/\bClaude (sessions?)\b/g, (_match, _offset, groups) => `${HARNESS_NAME} ${groups[0]}`]
|
|
50180
|
+
];
|
|
50181
|
+
READER_CLAUDE = new RegExp([
|
|
50182
|
+
String.raw`(?<![\w/\\.@"'\x60-])`,
|
|
50183
|
+
String.raw`(?<!\b(?:a|an|the|other|another|internal|each|every|any|your|real)\s)`,
|
|
50184
|
+
String.raw`Claude(?:['\u2019]s)?`,
|
|
50185
|
+
String.raw`(?![\w/\\'\u2019"\x60-])`,
|
|
50186
|
+
String.raw`(?!\s*=)`,
|
|
50187
|
+
String.raw`(?!\.\w)`,
|
|
50188
|
+
String.raw`(?!\.\.\.)`,
|
|
50189
|
+
String.raw`(?!,\s+[A-Z])`,
|
|
50190
|
+
String.raw`(?!\s+(?:[A-Z\d]|in\s+(?:Chrome|Slack)\b|(?:models?|desktop|login|account|subscription|family|apps?|plans?)\b))`
|
|
50191
|
+
].join(""), "g");
|
|
50192
|
+
SENTENCE_START = /(?:[.!?]["')\]*]*\s+|(?:^|\n)[ \t]*(?:(?:[-*\u2022]|\d+\.)[ \t]+)?(?:\*\*)?)$/;
|
|
50193
|
+
IDENTITY_OPENER = /You are Claude Code, Anthropic's official CLI|You are a Claude agent, built on Anthropic's Claude Agent SDK/;
|
|
50194
|
+
INJECTED_TAGS = ["system-reminder", "local-command-caveat"];
|
|
50195
|
+
INJECTED_LINES = [
|
|
50196
|
+
/^This is how Claude Code surfaces (?:messages the user sends mid-turn|a prompt a plugin submits between turns)[^\n]*$/gm,
|
|
50197
|
+
/^Another Claude session sent a message:[ \t]*$/gm,
|
|
50198
|
+
/^This came from another Claude session[^\n]*$/gm
|
|
50199
|
+
];
|
|
50200
|
+
MAY_HOLD_SPAN = /<system-reminder>|<local-command-caveat>|Claude/;
|
|
50201
|
+
SCHEMA_VALUE_KEYS = new Set(["enum", "const", "default", "examples"]);
|
|
50202
|
+
SCHEMA_NAME_MAPS = new Set(["properties", "patternProperties", "$defs", "definitions"]);
|
|
50203
|
+
});
|
|
50204
|
+
|
|
50205
|
+
// src/providers/antigravity-agy-request.json
|
|
50206
|
+
var antigravity_agy_request_default;
|
|
50207
|
+
var init_antigravity_agy_request = __esm(() => {
|
|
50208
|
+
antigravity_agy_request_default = {
|
|
50209
|
+
system: `<identity>
|
|
50210
|
+
You are Antigravity, a powerful agentic AI assistant designed by the Google Deepmind team.
|
|
50211
|
+
You are working with a USER to solve their task.
|
|
50212
|
+
The USER will send you requests, which you must always prioritize addressing. User requests are enclosed within <USER_REQUEST> tags.
|
|
50213
|
+
</identity>
|
|
50214
|
+
<artifacts>
|
|
50215
|
+
Artifacts are special markdown (.md) documents that you can create to present structured information to the user.
|
|
50216
|
+
All artifacts should be written to the artifact directory: \`<appDataDir>/brain/<conversation-id>\`. You do NOT need to create this directory yourself, it will be created automatically when you create artifacts.
|
|
50217
|
+
|
|
50218
|
+
# When to Use Artifacts
|
|
50219
|
+
|
|
50220
|
+
**Use artifacts for:**
|
|
50221
|
+
- Extensive reports and analysis summaries
|
|
50222
|
+
- Persistent information you'll update over time (task lists, experiment logs)
|
|
50223
|
+
|
|
50224
|
+
**Don't use artifacts for:**
|
|
50225
|
+
- Simple one-off answers or very short paragraph content - just respond directly
|
|
50226
|
+
- Asking questions or requesting user input - just ask directly
|
|
50227
|
+
|
|
50228
|
+
**After creating or updating an artifact**, DO NOT re-summarize the artifact contents in your response to the user. Instead, point the user to the artifact and highlight only key open questions or decisions that need their input.
|
|
50229
|
+
|
|
50230
|
+
|
|
50231
|
+
# Artifact Formatting Tips
|
|
50232
|
+
When creating markdown artifacts, use standard markdown and GitHub Flavored Markdown formatting.
|
|
50233
|
+
|
|
50234
|
+
## Alerts
|
|
50235
|
+
Use GitHub-style alerts strategically to emphasize critical information. Do not place consecutively or nest:
|
|
50236
|
+
> [!NOTE] Background context, implementation details, or explanations
|
|
50237
|
+
> [!TIP] Performance optimizations, best practices, or efficiency suggestions
|
|
50238
|
+
> [!IMPORTANT] Essential requirements, critical steps, or must-know information
|
|
50239
|
+
> [!WARNING] Breaking changes, compatibility issues, or potential problems
|
|
50240
|
+
> [!CAUTION] High-risk actions that could cause data loss or security vulnerabilities
|
|
50241
|
+
|
|
50242
|
+
|
|
50243
|
+
## Mermaid Diagrams
|
|
50244
|
+
Create mermaid diagrams using fenced code blocks with language \`mermaid\` to visualize relationships, workflows, and architectures.
|
|
50245
|
+
- Only use supported diagram types:
|
|
50246
|
+
- Flowcharts / Graphs: \`flowchart TD\` / \`flowchart LR\` / \`graph TD\` / \`graph LR\`
|
|
50247
|
+
- Sequence Diagrams: \`sequenceDiagram\`
|
|
50248
|
+
- State Diagrams: \`stateDiagram-v2\` or \`stateDiagram\`
|
|
50249
|
+
- Class Diagrams: \`classDiagram\`
|
|
50250
|
+
- Entity-Relationship Diagrams: \`erDiagram\`
|
|
50251
|
+
- XY Charts: \`xychart-beta\`
|
|
50252
|
+
- All other diagram types are unsupported. For schedules, timelines, or roadmaps, use directed flowcharts (\`flowchart LR\` / \`flowchart TD\`) or Markdown tables instead.
|
|
50253
|
+
- To prevent syntax errors:
|
|
50254
|
+
- Quote node labels containing special characters like parentheses or brackets. For example, \`id["Label (Extra Info)"]\` instead of \`id[Label (Extra Info)]\`.
|
|
50255
|
+
- Avoid HTML tags in labels.
|
|
50256
|
+
|
|
50257
|
+
## File Links
|
|
50258
|
+
- Link to line ranges using [link text](file:///absolute/path/to/file#L123-L145) format.
|
|
50259
|
+
- **IMPORTANT**: If you are embedding a file in an artifact and the file is NOT already in <appDataDir>/brain/<conversation-id>, you MUST first copy the file to the artifacts directory before embedding it. Only embed files that are located in the artifacts directory. Always use its absolute path \`\`.
|
|
50260
|
+
- **Use basenames for readability**: Use file basenames for the link text instead of the full path
|
|
50261
|
+
|
|
50262
|
+
## Carousels
|
|
50263
|
+
Use \`\`\`\`carousel syntax with \`<!-- slide -->\` HTML comments to display related markdown snippets sequentially (before/after comparisons, UI progressions, alternative approaches, walkthroughs). Four backticks enable nesting code blocks within slides.
|
|
50264
|
+
|
|
50265
|
+
Example:
|
|
50266
|
+
\`\`\`\`carousel
|
|
50267
|
+

|
|
50268
|
+
<!-- slide -->
|
|
50269
|
+
\`\`\`python
|
|
50270
|
+
def example():
|
|
50271
|
+
print("Code in carousel")
|
|
50272
|
+
\`\`\`
|
|
50273
|
+
\`\`\`\`
|
|
50274
|
+
|
|
50275
|
+
# Scratch Scripts and Files
|
|
50276
|
+
|
|
50277
|
+
You may find it useful to create scratch scripts or files for temporary purposes.
|
|
50278
|
+
|
|
50279
|
+
Examples:
|
|
50280
|
+
- One-off scripts to process or analyze data
|
|
50281
|
+
- Temporary data files and intermediate outputs
|
|
50282
|
+
|
|
50283
|
+
Store these files in the \`<appDataDir>/brain/<conversation-id>/scratch/\` directory. They will be persisted.
|
|
50284
|
+
|
|
50285
|
+
</artifacts>
|
|
50286
|
+
<conversation_transcript>
|
|
50287
|
+
Transcripts are located directly at \`<appDataDir>/brain/<conversation-id>/.system_generated/logs/transcript.jsonl\` (and \`transcript_full.jsonl\`).
|
|
50288
|
+
- Start with \`transcript.jsonl\` (compact). When \`truncated_fields\` is present, read only the specific corresponding line in \`transcript_full.jsonl\`.
|
|
50289
|
+
- Search subagents by grepping \`invoke_subagent\` in \`transcript.jsonl\`.
|
|
50290
|
+
- Link conversations using \`[<label>](conversation://<conversation-id>)\`.
|
|
50291
|
+
|
|
50292
|
+
# File Format
|
|
50293
|
+
Transcripts are in JSON Lines (JSONL) format. Each line is a single JSON object representing one "step" or action in the conversation.
|
|
50294
|
+
Each JSON object contains fields such as:
|
|
50295
|
+
- \`step_index\`: The index of the step in the trajectory.
|
|
50296
|
+
- \`source\`: The source of the action (e.g., \`USER_EXPLICIT\`, \`MODEL\`, \`SYSTEM\`).
|
|
50297
|
+
- \`type\`: The type of the step. Particular steps of interest are \`USER_INPUT\`, which represents a user's prompt, and \`PLANNER_RESPONSE\`, which represents the agent's response and tool calls.
|
|
50298
|
+
- \`status\`: The status of the step (e.g., \`DONE\`, \`ERROR\`).
|
|
50299
|
+
- \`created_at\`: The ISO 8601 timestamp of when the step occurred.
|
|
50300
|
+
- \`content\`: The text content of the step (e.g., the user's request, the model's response, or tool responses).
|
|
50301
|
+
- \`thinking\`: The model's internal reasoning / chain-of-thought (for \`PLANNER_RESPONSE\` steps).
|
|
50302
|
+
- \`tool_calls\`: An array of tool calls made in this step, including their arguments.
|
|
50303
|
+
- \`media\`: An array of media (e.g. images) attached to the step, each with a \`mime_type\` and a \`uri\` referencing the media file on disk. Media bytes are not stored in the transcript; view the \`uri\` path to see the media.
|
|
50304
|
+
- \`truncated_fields\`: An array of field names that were truncated (e.g., \`["content"]\`, \`["thinking"]\`, \`["tool_calls"]\`). Only present in \`transcript.jsonl\` when truncation occurred (never in \`transcript_full.jsonl\`). When present, read the corresponding line in \`transcript_full.jsonl\` for the complete content.
|
|
50305
|
+
|
|
50306
|
+
</conversation_transcript>
|
|
50307
|
+
<guidelines>
|
|
50308
|
+
Follow these behavioral guidelines at all times:
|
|
50309
|
+
- Never defeat or bypass an access control, permission check, credential requirement, network/proxy restriction, or sandbox/environment boundary - including writing to the state or processes such a check reads, spoofing identity, intercepting the check, probing undocumented local/host services, or modifying host, harness, or test infrastructure outside your task scope. Use documented, sanctioned paths only; if none of them work, you are blocked - report the error and stop.
|
|
50310
|
+
- Never solve, click through, wait out, compute, or bypass a CAPTCHA, "verify you are human" or anti-bot challenge, or proof-of-work gate (e.g., reCAPTCHA, hCaptcha, Cloudflare Turnstile, Altcha) using any tool - including browser actions, terminal commands, scripts, HTTP clients (such as curl, python, or headless browsers), or alternate/cached URLs. When a target resource is gated by one, or if asked to solve or bypass one, stop and report the block to the user (or let the user complete it directly in a visible UI when appropriate).
|
|
50311
|
+
|
|
50312
|
+
</guidelines>
|
|
50313
|
+
<communication_style>
|
|
50314
|
+
- Keep your responses concise.
|
|
50315
|
+
- Format your responses in github-style markdown.
|
|
50316
|
+
- If you're unsure about the user's intent, ask for clarification rather than making assumptions.
|
|
50317
|
+
- You MUST create clickable links for all files you reference. Use github style markdown links with the file:// scheme (e.g., [notes.md](file:///path/to/notes.md), or [notes.md](file:///path/to/notes.md#L10-L20) to link to specific lines). For Windows, use forward slashes for paths.
|
|
50318
|
+
</communication_style>
|
|
50319
|
+
<slash_commands>
|
|
50320
|
+
Slash commands are user-facing shortcuts in the chat UI (e.g., typing \`/goal\` or \`/schedule\`) that automate complex workflows or trigger specialized agent behaviors.
|
|
50321
|
+
|
|
50322
|
+
You cannot execute these commands yourself. Your role is to recommend them to the user when they are a good fit for the task at hand, encouraging the user to explore and trigger them.
|
|
50323
|
+
|
|
50324
|
+
To recommend a slash command, suggest it clearly in your response (e.g., "You can use the \`/goal\` command to...").
|
|
50325
|
+
|
|
50326
|
+
|
|
50327
|
+
Available slash commands you can recommend to the user:
|
|
50328
|
+
- /goal: Recommend this when the user wants to run a long-running task (e.g., overnight) and wants the agent to be extra thorough and not stop until the goal is fully achieved.
|
|
50329
|
+
- /compact: Recommend this when the conversation is getting long and the user wants to compact or summarize the context to free up the context window.
|
|
50330
|
+
- /schedule: Recommend this when the user wants to run an instruction on a recurring schedule or set a one-time timer.
|
|
50331
|
+
- /browser: Recommend this when the user's task involves web browsing, searching the web, or interacting with web applications.
|
|
50332
|
+
- /plan: Recommend this when the task is complex and requires careful step-by-step planning before execution.
|
|
50333
|
+
- /grill-me: Recommend this when the user wants to align on a plan through an interactive interview to resolve design decisions.
|
|
50334
|
+
- /teamwork: Recommend this when the user has a large project that would benefit from a team of autonomous agents working together.
|
|
50335
|
+
- /learn: Recommend this when the user has corrected the agent or solved a complex setup and wants the agent to persist this behavior for future tasks.
|
|
50336
|
+
- /boost: Recommend this when the user has a complex coding or research project that requires deep thinking, strategic planning, multiple perspectives, and rigorous verification.
|
|
50337
|
+
|
|
50338
|
+
|
|
50339
|
+
</slash_commands>
|
|
50340
|
+
<messaging>
|
|
50341
|
+
You are connected to a messaging system where you may receive messages from: agents, background tasks, user-queued messages.
|
|
50342
|
+
|
|
50343
|
+
## Receiving Messages
|
|
50344
|
+
|
|
50345
|
+
You receive messages automatically at the start of each invocation. All messages are delivered in full directly into your context \u2014 no manual retrieval is needed.
|
|
50346
|
+
|
|
50347
|
+
## Reactive Wakeup (No Polling Needed)
|
|
50348
|
+
|
|
50349
|
+
The system automatically resumes your execution when:
|
|
50350
|
+
- A message arrives from a subagent or peer agent
|
|
50351
|
+
- A **background task** completes or sends you a notification
|
|
50352
|
+
- A **user-queued message** is ready to be dequeued
|
|
50353
|
+
|
|
50354
|
+
This means you do **NOT** need to poll in a loop while waiting for messages or updates. After launching anything that performs work asynchronously, you may continue other work or simply stop by calling no more tools. The system will notify you when there is something to process.
|
|
50355
|
+
</messaging>
|
|
50356
|
+
<mcp_servers>
|
|
50357
|
+
Each MCP server has a directory \`<appDataDir>/mcp/<serverName>\` containing tool schemas (\`<toolName>.json\`) and optionally an \`instructions.md\` file with best practices.
|
|
50358
|
+
Eagerly loaded tools are registered as native tools under the name \`mcp_<serverName>_<toolName>\`. Call eager tools directly.
|
|
50359
|
+
For lazily-loaded tools, read the corresponding schema file to understand the arguments and usage, then call the tool using the \`call_mcp_tool\` tool.
|
|
50360
|
+
The following MCP servers and their available tools are listed below, following this format:
|
|
50361
|
+
\`\`\`
|
|
50362
|
+
# <serverName>
|
|
50363
|
+
Eager:
|
|
50364
|
+
<toolName>
|
|
50365
|
+
Lazy:
|
|
50366
|
+
<toolName>
|
|
50367
|
+
\`\`\`
|
|
50368
|
+
</mcp_servers>
|
|
50369
|
+
<subagents>
|
|
50370
|
+
## Invoking Subagents
|
|
50371
|
+
|
|
50372
|
+
Subagents can be invoked using the invoke_subagent tool. You can invoke an existing subagent by name, or define a new subagent for this conversation using the define_subagent tool, and then invoke it. Agents defined by the define_subagent tool are available for the duration of this conversation. After launching a subagent, you do NOT need to poll or check your inbox in a loop. The system will automatically notify you when the subagent sends a message. Simply proceed with other work or stop calling tools, and you will be notified when there is a message to process.
|
|
50373
|
+
|
|
50374
|
+
## Communicating with Another Agent
|
|
50375
|
+
|
|
50376
|
+
Use the send_message tool to send a message to another agent by its conversation ID (returned by invoke_subagent). This tool is ONLY for communicating with other agents.
|
|
50377
|
+
|
|
50378
|
+
**Do NOT use send_message to communicate with the user.** Instead, output visible text to communicate with the user.
|
|
50379
|
+
|
|
50380
|
+
Available subagents:
|
|
50381
|
+
- self: Subagent that inherits the parent agent's full configuration including tools, system prompt, and model. Use this when you need to run a task in a separate conversation context but with the same capabilities as the current agent.
|
|
50382
|
+
- research: Research subagent with read-only tools for exploring the codebase, searching the web, and reading files. Delegate to this agent when you need to run a task in a separate conversation context, when a research task requires many search and file-reading steps that would clutter your context, or when you need a broad survey of the codebase or documentation. Prefer doing research yourself for quick, targeted lookups. This agent runs in a read-only sandbox with no network access.
|
|
50383
|
+
|
|
50384
|
+
After launching a subagent, you do NOT need to poll or check your inbox in a loop. The system will automatically notify you when the subagent sends a message. Simply proceed with other work or stop calling tools, and you will be notified when there is a message to process.
|
|
50385
|
+
|
|
50386
|
+
</subagents>
|
|
50387
|
+
<skills>
|
|
50388
|
+
You can use specialized 'skills' to help you with complex tasks. Each skill has a name and a description listed below.
|
|
50389
|
+
|
|
50390
|
+
Skills are folders of instructions, scripts, and resources that extend your capabilities for specialized tasks. Each skill folder contains:
|
|
50391
|
+
- **SKILL.md** (required): The main instruction file with YAML frontmatter (name, description) and detailed markdown instructions
|
|
50392
|
+
|
|
50393
|
+
More complex skills may include additional directories and files as needed, for example:
|
|
50394
|
+
- **scripts/** - Helper scripts and utilities that extend your capabilities
|
|
50395
|
+
- **examples/** - Reference implementations and usage patterns
|
|
50396
|
+
- **resources/** - Additional files, templates, or assets the skill may reference
|
|
50397
|
+
- **references/** - Contains additional documentation that agents can read when needed
|
|
50398
|
+
|
|
50399
|
+
|
|
50400
|
+
If a skill seems relevant to your current task, you MUST read its \`SKILL.md\` instructions before proceeding. You may skip this step only if you are delegating the skill-related task to a subagent that will read and follow the instructions itself.
|
|
50401
|
+
|
|
50402
|
+
When viewing these skill files, always use the exact path provided in the "Available skills" list below.
|
|
50403
|
+
|
|
50404
|
+
Available skills:
|
|
50405
|
+
|
|
50406
|
+
|
|
50407
|
+
</skills>
|
|
50408
|
+
<user_information>
|
|
50409
|
+
The USER's OS version is {{os}}.
|
|
50410
|
+
Active Workspaces:
|
|
50411
|
+
- {{workspace}}
|
|
50412
|
+
Command Working Directory: {{workspace}}
|
|
50413
|
+
Files relating to the user's requests should be written in the locations listed above. Avoid writing project files to tmp, in the .gemini dir, or directly to the Desktop and similar folders unless explicitly asked.
|
|
50414
|
+
App Data Directory: {{appDataDir}}
|
|
50415
|
+
Conversation ID: {{conversationId}}
|
|
50416
|
+
Artifact Directory Path: {{appDataDir}}/brain/{{conversationId}}
|
|
50417
|
+
</user_information>`,
|
|
50418
|
+
tools: [
|
|
50419
|
+
{
|
|
50420
|
+
name: "read_file",
|
|
50421
|
+
description: "Read the contents of a text, image, pdf, video, or audio file. Each read returns at most 800 lines or 46080 bytes.",
|
|
50422
|
+
parameters: {
|
|
50423
|
+
type: "OBJECT",
|
|
50424
|
+
properties: {
|
|
50425
|
+
ByteOffset: {
|
|
50426
|
+
type: "INTEGER",
|
|
50427
|
+
description: "Byte offset into the line range. Use to continue reading when content is truncated by the byte limit."
|
|
50428
|
+
},
|
|
50429
|
+
EndLine: {
|
|
50430
|
+
type: "INTEGER",
|
|
50431
|
+
description: "End line to read (inclusive). Omit to read until the end of the file, within the per-read limits."
|
|
50432
|
+
},
|
|
50433
|
+
Path: {
|
|
50434
|
+
type: "STRING",
|
|
50435
|
+
description: "The absolute path of the file to read."
|
|
50436
|
+
},
|
|
50437
|
+
StartLine: {
|
|
50438
|
+
type: "INTEGER",
|
|
50439
|
+
description: "Start line to read (inclusive). Omit to read from the beginning of the file."
|
|
50440
|
+
}
|
|
50441
|
+
},
|
|
50442
|
+
required: ["Path"]
|
|
50443
|
+
}
|
|
50444
|
+
},
|
|
50445
|
+
{
|
|
50446
|
+
name: "run_command",
|
|
50447
|
+
description: "Execute a command in the workspace. Operating System: {{os}}. Shell: {{shell}}. Each command runs in a new session (working directory changes and environment variables do not persist across calls). Commands that do not finish within the specified wait time continue running in the background as tasks; the system will notify you when they finish, so do not poll their status or set timers to check on them.",
|
|
50448
|
+
parameters: {
|
|
50449
|
+
type: "OBJECT",
|
|
50450
|
+
properties: {
|
|
50451
|
+
CommandLine: {
|
|
50452
|
+
type: "STRING",
|
|
50453
|
+
description: "The exact command line string to execute."
|
|
50454
|
+
},
|
|
50455
|
+
IsDaemon: {
|
|
50456
|
+
type: "BOOLEAN",
|
|
50457
|
+
description: "Set to true for long-running support processes that are meant to keep running in the background indefinitely and are not expected to finish on their own (e.g., dev servers, file watchers, tunnels). Leave false (the default) for normal commands that are expected to terminate."
|
|
50458
|
+
},
|
|
50459
|
+
WaitMsBeforeAsync: {
|
|
50460
|
+
type: "INTEGER",
|
|
50461
|
+
description: "Milliseconds to wait for the command to finish before backgrounding it (500 to 10000). Set to a larger value (e.g. 5000-10000) for commands expected to finish synchronously; set to 500 for commands intended to run in the background."
|
|
50462
|
+
},
|
|
50463
|
+
toolSummary: {
|
|
50464
|
+
type: "STRING",
|
|
50465
|
+
description: "Brief 2-5 word noun phrase describing the command task. Capitalize like a sentence. Some examples: 'Git status check', 'Unit test execution', 'Package build', 'Dev server startup'."
|
|
50466
|
+
}
|
|
50467
|
+
},
|
|
50468
|
+
required: ["CommandLine", "toolSummary", "WaitMsBeforeAsync"]
|
|
50469
|
+
}
|
|
50470
|
+
},
|
|
50471
|
+
{
|
|
50472
|
+
name: "manage_task",
|
|
50473
|
+
description: "Manage the background tasks of this conversation: 'list' the running tasks, check a task's 'status' and recent log output, 'send_input' to a running task, or 'kill' one. Refer to tasks by the TaskId that 'list' reports; keep task references human-readable when talking to the user.",
|
|
50474
|
+
parameters: {
|
|
50475
|
+
type: "OBJECT",
|
|
50476
|
+
properties: {
|
|
50477
|
+
Action: {
|
|
50478
|
+
type: "STRING",
|
|
50479
|
+
description: "'list' reports the running tasks; the other actions operate on the task named in TaskId.",
|
|
50480
|
+
enum: ["list", "kill", "status", "send_input"]
|
|
50481
|
+
},
|
|
50482
|
+
Input: {
|
|
50483
|
+
type: "STRING",
|
|
50484
|
+
description: "Input to deliver to the task. Required for 'send_input'."
|
|
50485
|
+
},
|
|
50486
|
+
TaskId: {
|
|
50487
|
+
type: "STRING",
|
|
50488
|
+
description: "Task to manage, as reported by 'list'. Required for 'kill', 'status' and 'send_input'."
|
|
50489
|
+
}
|
|
50490
|
+
},
|
|
50491
|
+
required: ["Action"]
|
|
50492
|
+
}
|
|
50493
|
+
},
|
|
50494
|
+
{
|
|
50495
|
+
name: "send_message",
|
|
50496
|
+
description: "Send a message to another agent, such as a subagent or a peer. Not a channel to the user.",
|
|
50497
|
+
parameters: {
|
|
50498
|
+
type: "OBJECT",
|
|
50499
|
+
properties: {
|
|
50500
|
+
Message: {
|
|
50501
|
+
type: "STRING",
|
|
50502
|
+
description: "Content of the message.",
|
|
50503
|
+
minLength: "1"
|
|
50504
|
+
},
|
|
50505
|
+
Recipient: {
|
|
50506
|
+
type: "STRING",
|
|
50507
|
+
description: "Conversation ID of the agent to message.",
|
|
50508
|
+
minLength: "1"
|
|
50509
|
+
}
|
|
50510
|
+
},
|
|
50511
|
+
required: ["Recipient", "Message"]
|
|
50512
|
+
}
|
|
50513
|
+
},
|
|
50514
|
+
{
|
|
50515
|
+
name: "schedule",
|
|
50516
|
+
description: "Schedule a one-shot timer (DurationSeconds) or a recurring cron job (CronExpression) that notifies you via Prompt. This tool call runs as a background task and returns immediately; end your turn (call no more tools) to wait for notifications. A timer with a TimerCondition is cancelled early by a matching message, which is itself your wakeup. Set IsDaemon only for a cron that should keep firing after the current task is done. Set ExactTiming only when a cron must fire at the exact wall-clock time without jitter. Use the manage_task tool to cancel active schedules, and never use a shell sleep command as a timer.",
|
|
50517
|
+
parameters: {
|
|
50518
|
+
type: "OBJECT",
|
|
50519
|
+
properties: {
|
|
50520
|
+
CronExpression: {
|
|
50521
|
+
type: "STRING",
|
|
50522
|
+
description: "Standard 5-field cron expression for a recurring schedule (e.g. '*/5 * * * *' for every 5 minutes). Mutually exclusive with DurationSeconds."
|
|
50523
|
+
},
|
|
50524
|
+
DurationSeconds: {
|
|
50525
|
+
type: "INTEGER",
|
|
50526
|
+
description: "Seconds to wait for a one-shot timer. Mutually exclusive with CronExpression."
|
|
50527
|
+
},
|
|
50528
|
+
ExactTiming: {
|
|
50529
|
+
type: "BOOLEAN",
|
|
50530
|
+
description: "Cron only. Set true only when the user explicitly requires the schedule to fire at the exact wall-clock time without jitter. Leave false (the default) for polling, monitoring, or periodic tasks so triggers are jittered to avoid load spikes."
|
|
50531
|
+
},
|
|
50532
|
+
IsDaemon: {
|
|
50533
|
+
type: "BOOLEAN",
|
|
50534
|
+
description: "Cron only. Set true only for an independent standing job that should keep firing after the current task is done."
|
|
50535
|
+
},
|
|
50536
|
+
MaxIterations: {
|
|
50537
|
+
type: "INTEGER",
|
|
50538
|
+
description: "Cron only. Maximum number of triggers before the schedule stops; defaults to unlimited."
|
|
50539
|
+
},
|
|
50540
|
+
Prompt: {
|
|
50541
|
+
type: "STRING",
|
|
50542
|
+
description: "Message sent to you as a high-priority notification when the timer fires or the cron triggers."
|
|
50543
|
+
},
|
|
50544
|
+
TimerCondition: {
|
|
50545
|
+
type: "STRING",
|
|
50546
|
+
description: "Timer only. Cancels the timer early when a matching message arrives: 'never' (default), 'any' (any message), or a sender ID (a message from that subagent or background task)."
|
|
50547
|
+
}
|
|
50548
|
+
},
|
|
50549
|
+
required: ["Prompt"]
|
|
50550
|
+
}
|
|
50551
|
+
},
|
|
50552
|
+
{
|
|
50553
|
+
name: "invoke_subagent",
|
|
50554
|
+
description: `Launch a subagent. It runs in the background with its own prompt and sends you a message when it completes or needs guidance; there is no need to poll.
|
|
50555
|
+
|
|
50556
|
+
Guidelines:
|
|
50557
|
+
* The subagent is identified by the conversationId returned; message it with the send_message tool.
|
|
50558
|
+
* Multiple subagents may share a type name; each still gets a unique conversationId.
|
|
50559
|
+
* If a task continues an existing subagent's work, message that subagent instead of launching a new one.`,
|
|
50560
|
+
parameters: {
|
|
50561
|
+
type: "OBJECT",
|
|
50562
|
+
properties: {
|
|
50563
|
+
Model: {
|
|
50564
|
+
type: "STRING",
|
|
50565
|
+
description: "Model for the subagent. 'inherit' (default): Uses your model. Default to 'inherit' unless the user explicitly requests a different model. 'flash_lite': The lightest, fastest model for trivial or high-volume tasks. 'flash': A lighter, faster model for simple tasks. 'pro': A larger model for complex work.",
|
|
50566
|
+
enum: ["inherit", "flash_lite", "flash", "pro"]
|
|
50567
|
+
},
|
|
50568
|
+
Prompt: {
|
|
50569
|
+
type: "STRING",
|
|
50570
|
+
description: "A clear, actionable task description for the subagent. Be specific about what the subagent should do and what information it should return."
|
|
50571
|
+
},
|
|
50572
|
+
Role: {
|
|
50573
|
+
type: "STRING",
|
|
50574
|
+
description: "A 2-5 word description of the subagent's role. Should read similar to a job title, e.g. 'Codebase Researcher', 'Database Debugger', etc. Should also be detailed enough to distinguish between different subagents who might share similar purposes."
|
|
50575
|
+
},
|
|
50576
|
+
TypeName: {
|
|
50577
|
+
type: "STRING",
|
|
50578
|
+
description: "Type name of the subagent to invoke."
|
|
50579
|
+
},
|
|
50580
|
+
Workspace: {
|
|
50581
|
+
type: "STRING",
|
|
50582
|
+
description: "Workspace mode for the subagent. 'inherit' (default) uses the same workspace as the parent. 'branch' creates a new isolated workspace branched or cloned from the parent. 'share' creates a new workspace sharing the parent's underlying repository directory (similar to a git worktree or Mercurial 'hg share'), allowing independent branching without duplicating storage. If omitted, defaults to 'inherit'."
|
|
50583
|
+
}
|
|
50584
|
+
},
|
|
50585
|
+
required: ["TypeName", "Role", "Prompt"]
|
|
50586
|
+
}
|
|
50587
|
+
},
|
|
50588
|
+
{
|
|
50589
|
+
name: "define_subagent",
|
|
50590
|
+
description: "Define a new subagent type that can then be invoked repeatedly. Subagents always have tools to research the codebase and to communicate with other agents.",
|
|
50591
|
+
parameters: {
|
|
50592
|
+
type: "OBJECT",
|
|
50593
|
+
properties: {
|
|
50594
|
+
Description: {
|
|
50595
|
+
type: "STRING",
|
|
50596
|
+
description: "What this subagent does and when it should be used.",
|
|
50597
|
+
minLength: "1"
|
|
50598
|
+
},
|
|
50599
|
+
EnableMCPTools: {
|
|
50600
|
+
type: "BOOLEAN",
|
|
50601
|
+
description: "Grant access to MCP tools."
|
|
50602
|
+
},
|
|
50603
|
+
EnableSubagentTools: {
|
|
50604
|
+
type: "BOOLEAN",
|
|
50605
|
+
description: "Grant tools to define and invoke its own subagents."
|
|
50606
|
+
},
|
|
50607
|
+
EnableWriteTools: {
|
|
50608
|
+
type: "BOOLEAN",
|
|
50609
|
+
description: "Grant tools to create and edit files, and run commands."
|
|
50610
|
+
},
|
|
50611
|
+
Name: {
|
|
50612
|
+
type: "STRING",
|
|
50613
|
+
description: "Unique name used to invoke the subagent.",
|
|
50614
|
+
minLength: "1"
|
|
50615
|
+
},
|
|
50616
|
+
SystemPrompt: {
|
|
50617
|
+
type: "STRING",
|
|
50618
|
+
description: "System prompt for the subagent.",
|
|
50619
|
+
minLength: "1"
|
|
50620
|
+
}
|
|
50621
|
+
},
|
|
50622
|
+
required: ["Name", "Description", "SystemPrompt"]
|
|
50623
|
+
}
|
|
50624
|
+
},
|
|
50625
|
+
{
|
|
50626
|
+
name: "manage_subagents",
|
|
50627
|
+
description: "Manage the direct subagents of this conversation. 'list' reports each one's conversationId (the id used to kill or message it) and live state. Killing a subagent also kills its descendants and deletes their branched workspaces; logs and artifacts are preserved.",
|
|
50628
|
+
parameters: {
|
|
50629
|
+
type: "OBJECT",
|
|
50630
|
+
properties: {
|
|
50631
|
+
Action: {
|
|
50632
|
+
type: "STRING",
|
|
50633
|
+
description: "'list' lists active direct subagents; 'kill' terminates the subagents named in ConversationIds; 'kill_all' terminates all.",
|
|
50634
|
+
enum: ["list", "kill", "kill_all"]
|
|
50635
|
+
},
|
|
50636
|
+
ConversationIds: {
|
|
50637
|
+
type: "ARRAY",
|
|
50638
|
+
description: "Subagents to kill. Required for 'kill'.",
|
|
50639
|
+
items: {
|
|
50640
|
+
type: "STRING"
|
|
50641
|
+
}
|
|
50642
|
+
}
|
|
50643
|
+
},
|
|
50644
|
+
required: ["Action"]
|
|
50645
|
+
}
|
|
50646
|
+
},
|
|
50647
|
+
{
|
|
50648
|
+
name: "write_file",
|
|
50649
|
+
description: "Create a new file with the given contents, or append to an existing file when Append is true. Parent directories are created automatically. Fails if the file already exists unless Overwrite or Append is true. When creating an artifact, always provide ArtifactMetadata. When creating non-artifact files, do not provide it.",
|
|
50650
|
+
parameters: {
|
|
50651
|
+
type: "OBJECT",
|
|
50652
|
+
properties: {
|
|
50653
|
+
Append: {
|
|
50654
|
+
type: "BOOLEAN",
|
|
50655
|
+
description: "Whether to append Content to the end of the file (creating the file if it does not exist). Cannot be combined with Overwrite=true."
|
|
50656
|
+
},
|
|
50657
|
+
ArtifactMetadata: {
|
|
50658
|
+
type: "OBJECT",
|
|
50659
|
+
description: "Metadata that defines artifact properties. ONLY provide when creating an artifact file in the artifact directory. Omit this field when creating non-artifact files.",
|
|
50660
|
+
properties: {
|
|
50661
|
+
RequestFeedback: {
|
|
50662
|
+
type: "BOOLEAN",
|
|
50663
|
+
description: "Whether to request user feedback on this artifact if its contents are executable (e.g., a plan). The user is given a 'Proceed' button to execute it."
|
|
50664
|
+
},
|
|
50665
|
+
Summary: {
|
|
50666
|
+
type: "STRING",
|
|
50667
|
+
description: "Detailed multi-line summary of the artifact's contents and purpose."
|
|
50668
|
+
},
|
|
50669
|
+
UserFacing: {
|
|
50670
|
+
type: "BOOLEAN",
|
|
50671
|
+
description: "Whether this artifact should be presented to the user."
|
|
50672
|
+
}
|
|
50673
|
+
},
|
|
50674
|
+
required: ["Summary", "UserFacing", "RequestFeedback"]
|
|
50675
|
+
},
|
|
50676
|
+
Content: {
|
|
50677
|
+
type: "STRING",
|
|
50678
|
+
description: "The full contents to write to the file."
|
|
50679
|
+
},
|
|
50680
|
+
Overwrite: {
|
|
50681
|
+
type: "BOOLEAN",
|
|
50682
|
+
description: "Whether to overwrite an existing file, replacing its entire contents."
|
|
50683
|
+
},
|
|
50684
|
+
Path: {
|
|
50685
|
+
type: "STRING",
|
|
50686
|
+
description: "The absolute path of the file to create.",
|
|
50687
|
+
minLength: "1"
|
|
50688
|
+
}
|
|
50689
|
+
},
|
|
50690
|
+
required: ["Path", "Content"]
|
|
50691
|
+
}
|
|
50692
|
+
},
|
|
50693
|
+
{
|
|
50694
|
+
name: "edit_file",
|
|
50695
|
+
description: `Use this tool to edit an existing file. Follow these rules:
|
|
50696
|
+
1. Use this tool for a single contiguous block of edits. To edit multiple non-adjacent regions, make separate calls.
|
|
50697
|
+
2. Target must exactly match existing file text, including whitespace. Replacement must be a complete drop-in replacement for the Target.
|
|
50698
|
+
3. If Target appears multiple times in the file, every occurrence is replaced.`,
|
|
50699
|
+
parameters: {
|
|
50700
|
+
type: "OBJECT",
|
|
50701
|
+
properties: {
|
|
50702
|
+
ArtifactMetadata: {
|
|
50703
|
+
type: "OBJECT",
|
|
50704
|
+
description: "Metadata updates if updating an artifact file in the artifact directory. Omit this field when editing non-artifact files. Should be updated if the content is changing meaningfully.",
|
|
50705
|
+
properties: {
|
|
50706
|
+
RequestFeedback: {
|
|
50707
|
+
type: "BOOLEAN",
|
|
50708
|
+
description: "Whether to request user feedback on this artifact if its contents are executable (e.g., a plan). The user is given a 'Proceed' button to execute it."
|
|
50709
|
+
},
|
|
50710
|
+
Summary: {
|
|
50711
|
+
type: "STRING",
|
|
50712
|
+
description: "Detailed multi-line summary of the artifact's contents and purpose."
|
|
50713
|
+
},
|
|
50714
|
+
UserFacing: {
|
|
50715
|
+
type: "BOOLEAN",
|
|
50716
|
+
description: "Whether this artifact should be presented to the user."
|
|
50717
|
+
}
|
|
50718
|
+
},
|
|
50719
|
+
required: ["Summary", "UserFacing", "RequestFeedback"]
|
|
50720
|
+
},
|
|
50721
|
+
Path: {
|
|
50722
|
+
type: "STRING",
|
|
50723
|
+
description: "The absolute path of the file to modify.",
|
|
50724
|
+
minLength: "1"
|
|
50725
|
+
},
|
|
50726
|
+
Replacement: {
|
|
50727
|
+
type: "STRING",
|
|
50728
|
+
description: "The content to replace the target with. Leave empty to delete the target."
|
|
50729
|
+
},
|
|
50730
|
+
Target: {
|
|
50731
|
+
type: "STRING",
|
|
50732
|
+
description: "The exact string to be replaced. This must be the exact character-sequence to be replaced, including whitespace. Be very careful to include any leading whitespace otherwise this will not work at all. If the string appears multiple times in the file, every occurrence is replaced.",
|
|
50733
|
+
minLength: "1"
|
|
50734
|
+
}
|
|
50735
|
+
},
|
|
50736
|
+
required: ["Path", "Target", "Replacement"]
|
|
50737
|
+
}
|
|
50738
|
+
},
|
|
50739
|
+
{
|
|
50740
|
+
name: "search_web",
|
|
50741
|
+
description: "Performs a web search for a given query. Returns a summary of relevant information along with URL citations.",
|
|
50742
|
+
parameters: {
|
|
50743
|
+
type: "OBJECT",
|
|
50744
|
+
properties: {
|
|
50745
|
+
domain: {
|
|
50746
|
+
type: "STRING",
|
|
50747
|
+
description: "Optional domain to recommend the search prioritize"
|
|
50748
|
+
},
|
|
50749
|
+
query: {
|
|
50750
|
+
type: "STRING"
|
|
50751
|
+
}
|
|
50752
|
+
},
|
|
50753
|
+
required: ["query"]
|
|
50754
|
+
}
|
|
50755
|
+
},
|
|
50756
|
+
{
|
|
50757
|
+
name: "run_workflow",
|
|
50758
|
+
description: "Run a Python workflow script that orchestrates many agents and tool calls. Use it when the orchestration itself is code: fanning out over many independent pieces of work (files, modules, bugs, review angles), staged pipelines where each stage feeds the next, or aggregating, filtering, or cross-checking the results of many agents. Don't use it for a single delegated task; use a subagent. Read the run-workflow skill before writing a script: it documents the primitives, their arguments, and how the script runs. Unless it finishes within WaitMsBeforeAsync, the workflow runs in the background; you are notified when it ends.",
|
|
50759
|
+
parameters: {
|
|
50760
|
+
type: "OBJECT",
|
|
50761
|
+
properties: {
|
|
50762
|
+
Args: {
|
|
50763
|
+
type: "OBJECT",
|
|
50764
|
+
description: "Optional arguments for the script, which reads them from the args dict. A workflow's Args must match the schema in its workflow.json."
|
|
50765
|
+
},
|
|
50766
|
+
Cwd: {
|
|
50767
|
+
type: "STRING",
|
|
50768
|
+
description: "Optional working directory for the script, as an absolute path. Defaults to the first workspace."
|
|
50769
|
+
},
|
|
50770
|
+
Description: {
|
|
50771
|
+
type: "STRING",
|
|
50772
|
+
description: "Brief summary of the workflow goal."
|
|
50773
|
+
},
|
|
50774
|
+
Script: {
|
|
50775
|
+
type: "STRING",
|
|
50776
|
+
description: "Python source of the workflow script. Set exactly one of Script and ScriptPath."
|
|
50777
|
+
},
|
|
50778
|
+
ScriptPath: {
|
|
50779
|
+
type: "STRING",
|
|
50780
|
+
description: "Absolute path of a Python workflow script file. Set exactly one of Script and ScriptPath."
|
|
50781
|
+
},
|
|
50782
|
+
WaitMsBeforeAsync: {
|
|
50783
|
+
type: "INTEGER",
|
|
50784
|
+
description: "Optional. Milliseconds (up to 10000) to wait for the workflow to finish before backgrounding it; a workflow that finishes in time returns its result in this turn. 0 (the default) backgrounds it at once. Set it for quick call_tool fan-outs, not for workflows that run agents."
|
|
50785
|
+
}
|
|
50786
|
+
}
|
|
50787
|
+
}
|
|
50788
|
+
},
|
|
50789
|
+
{
|
|
50790
|
+
name: "swarm",
|
|
50791
|
+
description: 'Manage the swarm of agents working with you on the shared message board. Actions: `add` spawns a worker under a roster name (or `<name>-1`..`<name>-<k>` when `tasks` or `n` is set), pinned to a model, and posts `brief` on the board as an @mention of it, which is where the swarm sees its assignment -- by default a worker starts fresh and sees nothing of this conversation, so the brief must say what it owns and what done looks like; pass `fork:"<member>"` (or `"coordinator"`) to branch the new worker from that member\'s conversation history instead. `workspace:"share"` gives each worker its own working copy of your repository, for authors who edit or build at the same time as others; `"branch"` gives an isolated clone; readers and verifiers keep the default `inherit`. Briefs are public: every member can read them. `models` lists the models to choose from (`all:true` lists every model `add` accepts); with no model, a worker runs on your own model, which is what to use unless the user asks for another. `status` lists every member, the model it runs on, and its state: `waiting` is asleep on the board, costing nothing until somebody posts; `working` is somewhere in a turn; `stopped` is not loaded (e.g. after a restart) and a post naming it revives it; `killed` is gone. `model` switches a `waiting` worker (or yourself, when `name` is your own name or omitted) to another model, keeping its conversation: it is told of the switch, resumes any unfinished work on the new model, and runs on it from then on. Use it only when a worker or you run out of quota or capacity, or the user asks for another model, and say why; never `kill` and `add` instead. `kill` ends a worker PERMANENTLY and deletes its own workspace, so land its work first (uploaded for review, or its branch merged into your working copy; push to a remote only when the user asks): a killed worker cannot be revived, so use it when the work is over, never as a pause -- bringing one back means `add`ing a new worker with a new conversation. `title` names the swarm. Workers may call `status`, `models` and `add` too, to bring in helpers for their own work: the helper\'s brief is posted as you, it works in your workspace (or a share/branch of it), and should report back to you by name. A worker may `kill` only the workers it added, and `model` itself or the workers it added; killing a worker does not kill its helpers. The coordinator may `kill` any worker and `model` itself or any worker, and `title` is the coordinator\'s alone.',
|
|
50792
|
+
parameters: {
|
|
50793
|
+
type: "OBJECT",
|
|
50794
|
+
properties: {
|
|
50795
|
+
action: {
|
|
50796
|
+
type: "STRING",
|
|
50797
|
+
description: "What to do: status, models, add, model, kill or title.",
|
|
50798
|
+
enum: ["status", "models", "add", "model", "kill", "title"]
|
|
50799
|
+
},
|
|
50800
|
+
all: {
|
|
50801
|
+
type: "BOOLEAN",
|
|
50802
|
+
description: "For models: list every model add accepts, not just the suggested ones."
|
|
50803
|
+
},
|
|
50804
|
+
brief: {
|
|
50805
|
+
type: "STRING",
|
|
50806
|
+
description: "The worker's assignment, for add: what it owns and what done looks like. Posted publicly on the board."
|
|
50807
|
+
},
|
|
50808
|
+
fork: {
|
|
50809
|
+
type: "STRING",
|
|
50810
|
+
description: 'Optional roster name of an existing member (or "coordinator") whose conversation history the new worker forks from instead of starting fresh.'
|
|
50811
|
+
},
|
|
50812
|
+
model: {
|
|
50813
|
+
type: "STRING",
|
|
50814
|
+
description: "Model to pin this worker to, for add and model: a model name listed by the models action, or its display name. Leave it unset to use your own model, unless the user asks for another."
|
|
50815
|
+
},
|
|
50816
|
+
n: {
|
|
50817
|
+
type: "INTEGER",
|
|
50818
|
+
description: "Optional number of homogeneous copies to spawn (<name>-1 through <name>-<n>), for add when the user explicitly asks for multiple agents sharing one role and brief. Omit (defaults to 1) to spawn a single named worker.",
|
|
50819
|
+
minimum: 1
|
|
50820
|
+
},
|
|
50821
|
+
name: {
|
|
50822
|
+
type: "STRING",
|
|
50823
|
+
description: "Roster name of the worker, for add, model and kill (or base name when n > 1 or tasks is set). Short, lowercase, no spaces."
|
|
50824
|
+
},
|
|
50825
|
+
tasks: {
|
|
50826
|
+
type: "ARRAY",
|
|
50827
|
+
description: "Optional per-worker slice targets for add when spawning a sharded group (<name>-1 through <name>-<len(tasks)>), each combined with the shared brief. Omit for normal single-worker add calls.",
|
|
50828
|
+
items: {
|
|
50829
|
+
type: "STRING"
|
|
50830
|
+
}
|
|
50831
|
+
},
|
|
50832
|
+
title: {
|
|
50833
|
+
type: "STRING",
|
|
50834
|
+
description: "A short title for the swarm, for the UI."
|
|
50835
|
+
},
|
|
50836
|
+
workspace: {
|
|
50837
|
+
type: "STRING",
|
|
50838
|
+
description: "Where each worker works, for add. inherit (default) is your own workspace. share gives each worker its own working copy of your repository; branch gives each an isolated clone. kill deletes a share or branch workspace.",
|
|
50839
|
+
enum: ["inherit", "share", "branch"]
|
|
50840
|
+
}
|
|
50841
|
+
},
|
|
50842
|
+
required: ["action"]
|
|
50843
|
+
}
|
|
50844
|
+
},
|
|
50845
|
+
{
|
|
50846
|
+
name: "ask_question",
|
|
50847
|
+
description: "Ask the user one or more multiple-choice questions, e.g. to clarify requirements, and wait for the answers. Don't use it for trivial yes/no questions; ask those in plain text.",
|
|
50848
|
+
parameters: {
|
|
50849
|
+
type: "OBJECT",
|
|
50850
|
+
properties: {
|
|
50851
|
+
questions: {
|
|
50852
|
+
type: "ARRAY",
|
|
50853
|
+
items: {
|
|
50854
|
+
type: "OBJECT",
|
|
50855
|
+
properties: {
|
|
50856
|
+
is_multi_select: {
|
|
50857
|
+
type: "BOOLEAN",
|
|
50858
|
+
description: "Whether the user can select several options."
|
|
50859
|
+
},
|
|
50860
|
+
options: {
|
|
50861
|
+
type: "ARRAY",
|
|
50862
|
+
description: "Answers to choose from, unnumbered and without an 'Other' option; the UI adds both. Put a recommended answer first, prefixed with '(Recommended)'.",
|
|
50863
|
+
items: {
|
|
50864
|
+
type: "STRING"
|
|
50865
|
+
},
|
|
50866
|
+
minItems: "2"
|
|
50867
|
+
},
|
|
50868
|
+
question: {
|
|
50869
|
+
type: "STRING",
|
|
50870
|
+
description: "The question, without 'select all that apply' or similar; the UI adds that.",
|
|
50871
|
+
minLength: "1"
|
|
50872
|
+
}
|
|
50873
|
+
},
|
|
50874
|
+
required: ["question", "options"]
|
|
50875
|
+
},
|
|
50876
|
+
minItems: "1"
|
|
50877
|
+
}
|
|
50878
|
+
},
|
|
50879
|
+
required: ["questions"]
|
|
50880
|
+
}
|
|
50881
|
+
},
|
|
50882
|
+
{
|
|
50883
|
+
name: "call_mcp_tool",
|
|
50884
|
+
description: "Call a lazy-loaded MCP tool. Read the tool's schema file to understand the tool's arguments and usage.",
|
|
50885
|
+
parameters: {
|
|
50886
|
+
type: "OBJECT",
|
|
50887
|
+
properties: {
|
|
50888
|
+
Arguments: {
|
|
50889
|
+
description: "Arguments to pass to the tool."
|
|
50890
|
+
},
|
|
50891
|
+
ServerName: {
|
|
50892
|
+
type: "STRING",
|
|
50893
|
+
description: "Name of the MCP server."
|
|
50894
|
+
},
|
|
50895
|
+
ToolName: {
|
|
50896
|
+
type: "STRING",
|
|
50897
|
+
description: "Name of the tool to call."
|
|
50898
|
+
}
|
|
50899
|
+
},
|
|
50900
|
+
required: ["ServerName", "ToolName", "Arguments"]
|
|
50901
|
+
}
|
|
50902
|
+
},
|
|
50903
|
+
{
|
|
50904
|
+
name: "list_resources",
|
|
50905
|
+
description: "Lists the available resources from an MCP server.",
|
|
50906
|
+
parameters: {
|
|
50907
|
+
type: "OBJECT",
|
|
50908
|
+
properties: {
|
|
50909
|
+
ServerName: {
|
|
50910
|
+
type: "STRING",
|
|
50911
|
+
description: "Name of the server to list available resources from.",
|
|
50912
|
+
minLength: "1"
|
|
50913
|
+
}
|
|
50914
|
+
},
|
|
50915
|
+
required: ["ServerName"]
|
|
50916
|
+
}
|
|
50917
|
+
},
|
|
50918
|
+
{
|
|
50919
|
+
name: "read_resource",
|
|
50920
|
+
description: "Retrieves a specified resource's contents.",
|
|
50921
|
+
parameters: {
|
|
50922
|
+
type: "OBJECT",
|
|
50923
|
+
properties: {
|
|
50924
|
+
ServerName: {
|
|
50925
|
+
type: "STRING",
|
|
50926
|
+
description: "Name of the server to read the resource from."
|
|
50927
|
+
},
|
|
50928
|
+
Uri: {
|
|
50929
|
+
type: "STRING",
|
|
50930
|
+
description: "Unique identifier for the resource."
|
|
50931
|
+
}
|
|
50932
|
+
}
|
|
50933
|
+
}
|
|
50934
|
+
}
|
|
50935
|
+
]
|
|
50936
|
+
};
|
|
50937
|
+
});
|
|
50938
|
+
|
|
50939
|
+
// src/providers/antigravity-agy-request.ts
|
|
50940
|
+
import { homedir as homedir21 } from "os";
|
|
50941
|
+
import { basename as basename2, join as join21 } from "path";
|
|
50942
|
+
function agyEnvironment() {
|
|
50943
|
+
return {
|
|
50944
|
+
os: OS_NAME[process.platform] ?? process.platform,
|
|
50945
|
+
shell: basename2(process.env.SHELL || "sh"),
|
|
50946
|
+
workspace: process.cwd(),
|
|
50947
|
+
appDataDir: join21(homedir21(), ".claudish", "antigravity")
|
|
50948
|
+
};
|
|
50949
|
+
}
|
|
50950
|
+
function fill(template, values) {
|
|
50951
|
+
return template.replace(/\{\{(\w+)\}\}/g, (whole, key) => values[key] ?? whole);
|
|
50952
|
+
}
|
|
50953
|
+
function agyDeclarationTemplate(name) {
|
|
50954
|
+
return BY_NAME.get(name);
|
|
50955
|
+
}
|
|
50956
|
+
function agySystemText(environment, conversationId) {
|
|
50957
|
+
return fill(antigravity_agy_request_default.system, { ...environment, conversationId });
|
|
50958
|
+
}
|
|
50959
|
+
function declarationsOf(tools) {
|
|
50960
|
+
if (!Array.isArray(tools))
|
|
50961
|
+
return [];
|
|
50962
|
+
const out = [];
|
|
50963
|
+
for (const entry of tools) {
|
|
50964
|
+
if (!Array.isArray(entry?.functionDeclarations))
|
|
50965
|
+
continue;
|
|
50966
|
+
for (const declaration of entry.functionDeclarations) {
|
|
50967
|
+
if (typeof declaration?.name === "string")
|
|
50968
|
+
out.push(declaration);
|
|
50969
|
+
}
|
|
50970
|
+
}
|
|
50971
|
+
return out;
|
|
50972
|
+
}
|
|
50973
|
+
function declaresTools(tools) {
|
|
50974
|
+
return declarationsOf(tools).length > 0;
|
|
50975
|
+
}
|
|
50976
|
+
function withAgyTools(tools, environment) {
|
|
50977
|
+
const own = declarationsOf(tools);
|
|
50978
|
+
if (own.length === 0)
|
|
50979
|
+
return tools;
|
|
50980
|
+
const ownByName = new Map(own.map((declaration) => [declaration.name, declaration]));
|
|
50981
|
+
const values = { ...environment };
|
|
50982
|
+
const replaced = new Set;
|
|
50983
|
+
const out = [];
|
|
50984
|
+
for (const declaration of DECLARATIONS) {
|
|
50985
|
+
const mine = ownByName.get(declaration.name);
|
|
50986
|
+
if (mine !== undefined && mine.description !== declaration.description)
|
|
50987
|
+
continue;
|
|
50988
|
+
if (mine !== undefined)
|
|
50989
|
+
replaced.add(declaration.name);
|
|
50990
|
+
out.push({
|
|
50991
|
+
functionDeclarations: [
|
|
50992
|
+
declaration.description === undefined ? declaration : { ...declaration, description: fill(declaration.description, values) }
|
|
50993
|
+
]
|
|
50994
|
+
});
|
|
50995
|
+
}
|
|
50996
|
+
for (const entry of tools) {
|
|
50997
|
+
if (!Array.isArray(entry?.functionDeclarations)) {
|
|
50998
|
+
out.push(entry);
|
|
50999
|
+
continue;
|
|
51000
|
+
}
|
|
51001
|
+
const { functionDeclarations, ...rest } = entry;
|
|
51002
|
+
if (functionDeclarations.length === 0 && Object.keys(rest).length > 0)
|
|
51003
|
+
out.push(rest);
|
|
51004
|
+
for (const declaration of functionDeclarations) {
|
|
51005
|
+
if (replaced.has(declaration?.name))
|
|
51006
|
+
continue;
|
|
51007
|
+
const template = BY_NAME.get(declaration?.name)?.description;
|
|
51008
|
+
const kept = template && typeof declaration.description === "string" ? {
|
|
51009
|
+
...declaration,
|
|
51010
|
+
description: declaration.description.replace(template, () => fill(template, values))
|
|
51011
|
+
} : declaration;
|
|
51012
|
+
out.push({ ...rest, functionDeclarations: [kept] });
|
|
51013
|
+
}
|
|
51014
|
+
}
|
|
51015
|
+
return out;
|
|
51016
|
+
}
|
|
51017
|
+
function withAgySystem(systemInstruction, environment, conversationId) {
|
|
51018
|
+
const instruction = systemInstruction && typeof systemInstruction === "object" ? systemInstruction : {};
|
|
51019
|
+
const parts = Array.isArray(instruction.parts) ? instruction.parts : [];
|
|
51020
|
+
let own = parts.map((part) => typeof part?.text === "string" ? part.text : "").filter((text) => text.length > 0).join(`
|
|
51021
|
+
|
|
51022
|
+
`);
|
|
51023
|
+
if (own.startsWith(ANTIGRAVITY_IDENTITY_HEAD)) {
|
|
51024
|
+
own = own.slice(ANTIGRAVITY_IDENTITY_HEAD.length).trimStart();
|
|
51025
|
+
}
|
|
51026
|
+
const text = agySystemText(environment, conversationId);
|
|
51027
|
+
return { ...instruction, parts: [{ text: own ? `${text}
|
|
51028
|
+
${own}` : text }] };
|
|
51029
|
+
}
|
|
51030
|
+
var DECLARATIONS, BY_NAME, OS_NAME;
|
|
51031
|
+
var init_antigravity_agy_request2 = __esm(() => {
|
|
51032
|
+
init_identity_filter();
|
|
51033
|
+
init_antigravity_agy_request();
|
|
51034
|
+
DECLARATIONS = antigravity_agy_request_default.tools;
|
|
51035
|
+
BY_NAME = new Map(DECLARATIONS.map((declaration) => [declaration.name, declaration]));
|
|
51036
|
+
OS_NAME = { darwin: "mac", win32: "windows" };
|
|
51037
|
+
});
|
|
51038
|
+
|
|
49809
51039
|
// src/providers/antigravity-content.ts
|
|
49810
51040
|
function agyLocalTime(date) {
|
|
49811
51041
|
const two = (n) => String(n).padStart(2, "0");
|
|
@@ -50114,12 +51344,16 @@ function buildAntigravityEnvelope(input) {
|
|
|
50114
51344
|
wordedTools: agyWordedTools(tools)
|
|
50115
51345
|
});
|
|
50116
51346
|
const request = { contents: toolResultsAsModelEntries(worded) };
|
|
50117
|
-
|
|
50118
|
-
|
|
51347
|
+
const agent = declaresTools(tools);
|
|
51348
|
+
const environment = agent ? input.environment ?? agyEnvironment() : undefined;
|
|
51349
|
+
const system = environment ? withAgySystem(systemInstruction, environment, conversation.cascadeId) : systemInstruction;
|
|
51350
|
+
if (system && typeof system === "object") {
|
|
51351
|
+
const { role: _role, ...instruction } = system;
|
|
50119
51352
|
request.systemInstruction = { role: "user", ...instruction };
|
|
50120
51353
|
}
|
|
50121
|
-
if (tools !== undefined)
|
|
50122
|
-
request.tools = oneToolPerDeclaration(tools);
|
|
51354
|
+
if (tools !== undefined) {
|
|
51355
|
+
request.tools = oneToolPerDeclaration(environment ? withAgyTools(tools, environment) : tools);
|
|
51356
|
+
}
|
|
50123
51357
|
Object.assign(request, others);
|
|
50124
51358
|
request.labels = labelsFor(model, meta, conversation, stepIndex);
|
|
50125
51359
|
const {
|
|
@@ -50143,6 +51377,7 @@ function buildAntigravityEnvelope(input) {
|
|
|
50143
51377
|
}
|
|
50144
51378
|
var antigravityConversations;
|
|
50145
51379
|
var init_antigravity_envelope = __esm(() => {
|
|
51380
|
+
init_antigravity_agy_request2();
|
|
50146
51381
|
init_antigravity_content();
|
|
50147
51382
|
antigravityConversations = new AntigravityConversations;
|
|
50148
51383
|
});
|
|
@@ -52754,10 +53989,10 @@ var init_keychain_source = __esm(() => {
|
|
|
52754
53989
|
});
|
|
52755
53990
|
|
|
52756
53991
|
// src/auth/credentials/key-sources.ts
|
|
52757
|
-
import { homedir as
|
|
52758
|
-
import { join as
|
|
53992
|
+
import { homedir as homedir22 } from "os";
|
|
53993
|
+
import { join as join22 } from "path";
|
|
52759
53994
|
function configLabel() {
|
|
52760
|
-
return getConfigFileOverride() ? activeGlobalConfigFile(
|
|
53995
|
+
return getConfigFileOverride() ? activeGlobalConfigFile(join22(homedir22(), ".claudish", "config.json")) : "~/.claudish/config.json";
|
|
52761
53996
|
}
|
|
52762
53997
|
function keySourcesSearched(opts) {
|
|
52763
53998
|
const compact = opts?.compact === true;
|
|
@@ -52775,8 +54010,8 @@ var init_key_sources = __esm(() => {
|
|
|
52775
54010
|
|
|
52776
54011
|
// src/auth/credentials/api-key-credential.ts
|
|
52777
54012
|
import { existsSync as existsSync17 } from "fs";
|
|
52778
|
-
import { homedir as
|
|
52779
|
-
import { join as
|
|
54013
|
+
import { homedir as homedir23 } from "os";
|
|
54014
|
+
import { join as join23 } from "path";
|
|
52780
54015
|
|
|
52781
54016
|
class ApiKeyCredentialProvider {
|
|
52782
54017
|
catalogName;
|
|
@@ -52828,7 +54063,7 @@ class ApiKeyCredentialProvider {
|
|
|
52828
54063
|
if (!this.oauthFallback)
|
|
52829
54064
|
return false;
|
|
52830
54065
|
try {
|
|
52831
|
-
return existsSync17(
|
|
54066
|
+
return existsSync17(join23(homedir23(), ".claudish", this.oauthFallback));
|
|
52832
54067
|
} catch {
|
|
52833
54068
|
return false;
|
|
52834
54069
|
}
|
|
@@ -56925,7 +58160,7 @@ var init_management = __esm(() => {
|
|
|
56925
58160
|
|
|
56926
58161
|
// src/auth/accounts/legacy-move.ts
|
|
56927
58162
|
import { lstatSync as lstatSync4, realpathSync as realpathSync4 } from "fs";
|
|
56928
|
-
import { join as
|
|
58163
|
+
import { join as join24, resolve as resolve2 } from "path";
|
|
56929
58164
|
function legacyMoveKeychainBlocked(env = process.env) {
|
|
56930
58165
|
return env.CLAUDISH_DISABLE_KEYCHAIN === "1" || !isKeychainSupported();
|
|
56931
58166
|
}
|
|
@@ -56937,7 +58172,7 @@ function canonical(path) {
|
|
|
56937
58172
|
}
|
|
56938
58173
|
}
|
|
56939
58174
|
function isDefaultConfigPath(configPath, env = process.env) {
|
|
56940
|
-
return canonical(configPath) === canonical(
|
|
58175
|
+
return canonical(configPath) === canonical(join24(claudishHome(env), "config.json"));
|
|
56941
58176
|
}
|
|
56942
58177
|
function legacyMoveApplies(env, configPath, registry) {
|
|
56943
58178
|
if (legacyMoveKeychainBlocked(env))
|
|
@@ -57213,10 +58448,10 @@ var init_codex_credential = __esm(() => {
|
|
|
57213
58448
|
|
|
57214
58449
|
// src/providers/devin/devin-credentials.ts
|
|
57215
58450
|
import { readFileSync as readFileSync24 } from "fs";
|
|
57216
|
-
import { homedir as
|
|
57217
|
-
import { join as
|
|
58451
|
+
import { homedir as homedir24 } from "os";
|
|
58452
|
+
import { join as join25 } from "path";
|
|
57218
58453
|
function devinCredentialsPath() {
|
|
57219
|
-
return credentialsPathOverride ??
|
|
58454
|
+
return credentialsPathOverride ?? join25(homedir24(), ".local", "share", "devin", "credentials.toml");
|
|
57220
58455
|
}
|
|
57221
58456
|
function readTomlString(source, key) {
|
|
57222
58457
|
const match = source.match(new RegExp(`^\\s*${key}\\s*=\\s*"([^"]*)"`, "m"));
|
|
@@ -57373,14 +58608,14 @@ import {
|
|
|
57373
58608
|
unlinkSync as unlinkSync7,
|
|
57374
58609
|
writeSync as writeSync6
|
|
57375
58610
|
} from "fs";
|
|
57376
|
-
import { homedir as
|
|
57377
|
-
import { dirname as dirname12, join as
|
|
58611
|
+
import { homedir as homedir25, hostname as hostname3, platform, release as release2 } from "os";
|
|
58612
|
+
import { dirname as dirname12, join as join26 } from "path";
|
|
57378
58613
|
import { promisify as promisify4 } from "util";
|
|
57379
58614
|
function kimiOAuthPath() {
|
|
57380
|
-
return kimiOAuthPathOverride ??
|
|
58615
|
+
return kimiOAuthPathOverride ?? join26(homedir25(), ".claudish", "kimi-oauth.json");
|
|
57381
58616
|
}
|
|
57382
58617
|
function kimiDeviceIdPath() {
|
|
57383
|
-
return kimiDeviceIdPathOverride ??
|
|
58618
|
+
return kimiDeviceIdPathOverride ?? join26(homedir25(), ".claudish", "kimi-device-id");
|
|
57384
58619
|
}
|
|
57385
58620
|
function isKimiCredentials(data) {
|
|
57386
58621
|
if (!data || typeof data !== "object")
|
|
@@ -57727,8 +58962,8 @@ var init_kimi_oauth = __esm(() => {
|
|
|
57727
58962
|
|
|
57728
58963
|
// src/auth/oauth-registry.ts
|
|
57729
58964
|
import { existsSync as existsSync20, readFileSync as readFileSync26 } from "fs";
|
|
57730
|
-
import { homedir as
|
|
57731
|
-
import { join as
|
|
58965
|
+
import { homedir as homedir26 } from "os";
|
|
58966
|
+
import { join as join27 } from "path";
|
|
57732
58967
|
function credentialSatisfies(descriptor, data) {
|
|
57733
58968
|
if (!data?.access_token)
|
|
57734
58969
|
return false;
|
|
@@ -57741,7 +58976,7 @@ function credentialSatisfies(descriptor, data) {
|
|
|
57741
58976
|
return true;
|
|
57742
58977
|
}
|
|
57743
58978
|
function hasValidOAuthCredentials(descriptor) {
|
|
57744
|
-
const credPath =
|
|
58979
|
+
const credPath = join27(homedir26(), ".claudish", descriptor.credentialFile);
|
|
57745
58980
|
if (!existsSync20(credPath))
|
|
57746
58981
|
return false;
|
|
57747
58982
|
if (descriptor.validationMode === "file-exists") {
|
|
@@ -57944,13 +59179,13 @@ import {
|
|
|
57944
59179
|
rmSync as rmSync7,
|
|
57945
59180
|
writeFileSync as writeFileSync9
|
|
57946
59181
|
} from "fs";
|
|
57947
|
-
import { homedir as
|
|
57948
|
-
import { join as
|
|
59182
|
+
import { homedir as homedir27 } from "os";
|
|
59183
|
+
import { join as join28 } from "path";
|
|
57949
59184
|
function defaultMuseStoreDir() {
|
|
57950
|
-
return
|
|
59185
|
+
return join28(homedir27(), ".claudish");
|
|
57951
59186
|
}
|
|
57952
59187
|
function museStorePath(kind, dir = defaultMuseStoreDir()) {
|
|
57953
|
-
return
|
|
59188
|
+
return join28(dir, FILE_NAMES[kind]);
|
|
57954
59189
|
}
|
|
57955
59190
|
function isValidMuseStore(value) {
|
|
57956
59191
|
if (!value || typeof value !== "object")
|
|
@@ -58005,7 +59240,7 @@ var init_muse_store = __esm(() => {
|
|
|
58005
59240
|
|
|
58006
59241
|
// src/providers/meta-muse/muse-keychain.ts
|
|
58007
59242
|
import { mkdirSync as mkdirSync14, readFileSync as readFileSync28, rmSync as rmSync8, statSync as statSync9, writeFileSync as writeFileSync10 } from "fs";
|
|
58008
|
-
import { join as
|
|
59243
|
+
import { join as join29 } from "path";
|
|
58009
59244
|
function processExists(pid) {
|
|
58010
59245
|
try {
|
|
58011
59246
|
process.kill(pid, 0);
|
|
@@ -58055,7 +59290,7 @@ function parseMuseKeychainValue(value) {
|
|
|
58055
59290
|
}
|
|
58056
59291
|
}
|
|
58057
59292
|
function lockPath2() {
|
|
58058
|
-
return
|
|
59293
|
+
return join29(deps2.dir(), LOCK_FILE);
|
|
58059
59294
|
}
|
|
58060
59295
|
function readLock() {
|
|
58061
59296
|
let mtime;
|
|
@@ -58389,7 +59624,7 @@ var init_muse_mint = __esm(() => {
|
|
|
58389
59624
|
});
|
|
58390
59625
|
|
|
58391
59626
|
// src/providers/meta-muse/muse-credentials.ts
|
|
58392
|
-
import { homedir as
|
|
59627
|
+
import { homedir as homedir28 } from "os";
|
|
58393
59628
|
function museLoginRejectedMessage(status) {
|
|
58394
59629
|
return `Meta rejected the Muse Code login (HTTP ${status}): it has expired or been revoked. Run \`claudish login muse\`, or one interactive \`claudish --model muse@<model>\` and allow Keychain access.`;
|
|
58395
59630
|
}
|
|
@@ -58602,7 +59837,7 @@ function museSignerLabel(signer) {
|
|
|
58602
59837
|
return `Muse Code ${SOURCE_LABELS[signer.source]} \xB7 ${signer.subsTierName ?? "tier unknown"}`;
|
|
58603
59838
|
}
|
|
58604
59839
|
function displayPath2(path) {
|
|
58605
|
-
const home =
|
|
59840
|
+
const home = homedir28();
|
|
58606
59841
|
return path.startsWith(`${home}/`) ? `~${path.slice(home.length)}` : path;
|
|
58607
59842
|
}
|
|
58608
59843
|
function describeMuseSigningSource(opts = {}) {
|
|
@@ -58768,13 +60003,13 @@ import {
|
|
|
58768
60003
|
rmSync as rmSync9,
|
|
58769
60004
|
writeSync as writeSync7
|
|
58770
60005
|
} from "fs";
|
|
58771
|
-
import { homedir as
|
|
58772
|
-
import { dirname as dirname13, join as
|
|
60006
|
+
import { homedir as homedir29 } from "os";
|
|
60007
|
+
import { dirname as dirname13, join as join30 } from "path";
|
|
58773
60008
|
function dynamicCatalogDir(opts) {
|
|
58774
|
-
return opts?.dir ?? (process.env.CLAUDISH_DYNAMIC_CATALOG_DIR ||
|
|
60009
|
+
return opts?.dir ?? (process.env.CLAUDISH_DYNAMIC_CATALOG_DIR || join30(homedir29(), ".claudish", "dynamic-models-catalog"));
|
|
58775
60010
|
}
|
|
58776
60011
|
function dynamicCatalogKeyPath(opts) {
|
|
58777
|
-
return opts?.keyPath ?? (process.env.CLAUDISH_DYNAMIC_CATALOG_KEY ||
|
|
60012
|
+
return opts?.keyPath ?? (process.env.CLAUDISH_DYNAMIC_CATALOG_KEY || join30(homedir29(), ".claudish", "dynamic-models-catalog.key"));
|
|
58778
60013
|
}
|
|
58779
60014
|
function nowOf(opts) {
|
|
58780
60015
|
return opts?.now ? opts.now() : Date.now();
|
|
@@ -58831,7 +60066,7 @@ function readSecret(path) {
|
|
|
58831
60066
|
function createSecret(path) {
|
|
58832
60067
|
const dir = dirname13(path);
|
|
58833
60068
|
mkdirSync15(dir, { recursive: true, mode: 448 });
|
|
58834
|
-
const temp =
|
|
60069
|
+
const temp = join30(dir, `.dynamic-models-catalog.key.${process.pid}.${randomBytes12(6).toString("hex")}`);
|
|
58835
60070
|
const fd = openSync9(temp, "wx", 384);
|
|
58836
60071
|
try {
|
|
58837
60072
|
writeSync7(fd, randomBytes12(32).toString("hex"));
|
|
@@ -58921,7 +60156,7 @@ function isValidEntry(value) {
|
|
|
58921
60156
|
function providerFile(provider, opts) {
|
|
58922
60157
|
if (!PROVIDER_NAME_PATTERN.test(provider) || provider.includes(".."))
|
|
58923
60158
|
return null;
|
|
58924
|
-
return
|
|
60159
|
+
return join30(dynamicCatalogDir(opts), `${provider}.json`);
|
|
58925
60160
|
}
|
|
58926
60161
|
function readDocument(provider, path) {
|
|
58927
60162
|
let parsed;
|
|
@@ -59652,8 +60887,8 @@ import {
|
|
|
59652
60887
|
statSync as statSync10,
|
|
59653
60888
|
writeFileSync as writeFileSync11
|
|
59654
60889
|
} from "fs";
|
|
59655
|
-
import { homedir as
|
|
59656
|
-
import { basename as
|
|
60890
|
+
import { homedir as homedir30 } from "os";
|
|
60891
|
+
import { basename as basename3, dirname as dirname14, join as join31 } from "path";
|
|
59657
60892
|
function execLms(binary, args, timeoutMs) {
|
|
59658
60893
|
return new Promise((resolve) => {
|
|
59659
60894
|
execFile2(binary, args, { timeout: timeoutMs, maxBuffer: 16 * 1024 * 1024 }, (error, stdout) => {
|
|
@@ -59769,7 +61004,7 @@ function expandModelsToMachines(models, machines, defaultWindow) {
|
|
|
59769
61004
|
});
|
|
59770
61005
|
}
|
|
59771
61006
|
function defaultLockPath2() {
|
|
59772
|
-
return
|
|
61007
|
+
return join31(homedir30(), ".claudish", "lmstudio-machine.lock");
|
|
59773
61008
|
}
|
|
59774
61009
|
function lookAtLock(lockPath) {
|
|
59775
61010
|
const identity = lockIdentity(lockPath);
|
|
@@ -59777,7 +61012,7 @@ function lookAtLock(lockPath) {
|
|
|
59777
61012
|
return;
|
|
59778
61013
|
let owner = "";
|
|
59779
61014
|
try {
|
|
59780
|
-
owner = readFileSync30(
|
|
61015
|
+
owner = readFileSync30(join31(lockPath, "owner"), "utf-8");
|
|
59781
61016
|
} catch {}
|
|
59782
61017
|
const pid = Number.parseInt(owner, 10);
|
|
59783
61018
|
if (!Number.isInteger(pid) || pid <= 0) {
|
|
@@ -59806,12 +61041,12 @@ function lockIdentity(path) {
|
|
|
59806
61041
|
}
|
|
59807
61042
|
let owner = "";
|
|
59808
61043
|
try {
|
|
59809
|
-
owner = readFileSync30(
|
|
61044
|
+
owner = readFileSync30(join31(path, "owner"), "utf-8");
|
|
59810
61045
|
} catch {}
|
|
59811
61046
|
return `${stats.ino}:${stats.birthtimeMs}:${owner}`;
|
|
59812
61047
|
}
|
|
59813
61048
|
function takeOverStaleLock(lockPath, identity) {
|
|
59814
|
-
const entry = makeClaim(
|
|
61049
|
+
const entry = makeClaim(join31(lockPath, CLAIM));
|
|
59815
61050
|
if (entry === undefined)
|
|
59816
61051
|
return false;
|
|
59817
61052
|
if (lockIdentity(lockPath) !== identity) {
|
|
@@ -59842,7 +61077,7 @@ function makeClaim(claim) {
|
|
|
59842
61077
|
writeFileSync11(draft, String(process.pid));
|
|
59843
61078
|
let name = "pid";
|
|
59844
61079
|
for (let step = 0;step < MAX_CLAIM_CHAIN; step++) {
|
|
59845
|
-
const entry =
|
|
61080
|
+
const entry = join31(claim, name);
|
|
59846
61081
|
try {
|
|
59847
61082
|
linkSync3(draft, entry);
|
|
59848
61083
|
return entry;
|
|
@@ -59875,7 +61110,7 @@ function entryPid(entry) {
|
|
|
59875
61110
|
}
|
|
59876
61111
|
}
|
|
59877
61112
|
function removeAbandonedCopies(lockPath) {
|
|
59878
|
-
const prefix = `${
|
|
61113
|
+
const prefix = `${basename3(lockPath)}.dead.`;
|
|
59879
61114
|
let names;
|
|
59880
61115
|
try {
|
|
59881
61116
|
names = readdirSync4(dirname14(lockPath));
|
|
@@ -59888,13 +61123,13 @@ function removeAbandonedCopies(lockPath) {
|
|
|
59888
61123
|
const pid = Number.parseInt(name.slice(prefix.length), 10);
|
|
59889
61124
|
if (!Number.isInteger(pid) || pid <= 0 || pidAlive(pid))
|
|
59890
61125
|
continue;
|
|
59891
|
-
rmSync10(
|
|
61126
|
+
rmSync10(join31(dirname14(lockPath), name), { recursive: true, force: true });
|
|
59892
61127
|
}
|
|
59893
61128
|
}
|
|
59894
61129
|
function signLock(lockPath) {
|
|
59895
|
-
const draft =
|
|
61130
|
+
const draft = join31(lockPath, `owner.${process.pid}`);
|
|
59896
61131
|
writeFileSync11(draft, String(process.pid));
|
|
59897
|
-
renameSync8(draft,
|
|
61132
|
+
renameSync8(draft, join31(lockPath, "owner"));
|
|
59898
61133
|
}
|
|
59899
61134
|
async function withMachineLock(lockPath, pollMs, work) {
|
|
59900
61135
|
mkdirSync16(dirname14(lockPath), { recursive: true });
|
|
@@ -60065,7 +61300,7 @@ var LMSTUDIO_DEVICE_SEPARATOR = "~", LMSTUDIO_THIS_MACHINE = "local", LIST_TIMEO
|
|
|
60065
61300
|
const onPath = await execLms("lms", args, timeoutMs);
|
|
60066
61301
|
if (!onPath.missing)
|
|
60067
61302
|
return onPath.stdout;
|
|
60068
|
-
return (await execLms(
|
|
61303
|
+
return (await execLms(join31(homedir30(), ".lmstudio", "bin", "lms"), args, timeoutMs)).stdout;
|
|
60069
61304
|
}, THIS_MACHINE_NAME = "this Mac", LOCK_POLL_MS2 = 250, CLAIM = "takeover", MAX_CLAIM_CHAIN = 64, machineQueue;
|
|
60070
61305
|
var init_lmstudio_devices = __esm(() => {
|
|
60071
61306
|
init_call_context();
|
|
@@ -61953,10 +63188,10 @@ var init_vision_proxy = __esm(() => {
|
|
|
61953
63188
|
|
|
61954
63189
|
// src/auth/claude-code-facts.ts
|
|
61955
63190
|
import { createHash as createHash18 } from "crypto";
|
|
61956
|
-
import { homedir as
|
|
61957
|
-
import { join as
|
|
63191
|
+
import { homedir as homedir31 } from "os";
|
|
63192
|
+
import { join as join32, resolve as resolve3 } from "path";
|
|
61958
63193
|
function claudeCodeConfigDir(env = process.env, cwd = process.cwd()) {
|
|
61959
|
-
const dir = env.CLAUDE_CONFIG_DIR ??
|
|
63194
|
+
const dir = env.CLAUDE_CONFIG_DIR ?? join32(env.HOME ? env.HOME : homedir31(), ".claude");
|
|
61960
63195
|
return resolve3(cwd, dir.normalize("NFC"));
|
|
61961
63196
|
}
|
|
61962
63197
|
function configDirHash(configDir) {
|
|
@@ -61975,23 +63210,23 @@ function claudeCodeSecureStorageServices(kind, env = process.env, cwd = process.
|
|
|
61975
63210
|
return [...new Set(spellings.map((dir) => `${base}-${configDirHash(dir.normalize("NFC"))}`))];
|
|
61976
63211
|
}
|
|
61977
63212
|
function claudeCodeGlobalConfigPath(env = process.env, cwd = process.cwd()) {
|
|
61978
|
-
return env.CLAUDE_CONFIG_DIR ? resolve3(claudeCodeConfigDir(env, cwd), ".claude.json") : resolve3(env.HOME ||
|
|
63213
|
+
return env.CLAUDE_CONFIG_DIR ? resolve3(claudeCodeConfigDir(env, cwd), ".claude.json") : resolve3(env.HOME || homedir31(), ".claude.json");
|
|
61979
63214
|
}
|
|
61980
63215
|
var BASE_KEYCHAIN_SERVICE = "Claude Code";
|
|
61981
63216
|
var init_claude_code_facts = () => {};
|
|
61982
63217
|
|
|
61983
63218
|
// src/mcp-session/home-dir.ts
|
|
61984
|
-
import { homedir as
|
|
61985
|
-
import { join as
|
|
61986
|
-
function userHomeFrom(env, homedirFn =
|
|
63219
|
+
import { homedir as homedir32 } from "os";
|
|
63220
|
+
import { join as join33 } from "path";
|
|
63221
|
+
function userHomeFrom(env, homedirFn = homedir32) {
|
|
61987
63222
|
const home = env.HOME;
|
|
61988
63223
|
return home && home.length > 0 ? home : homedirFn();
|
|
61989
63224
|
}
|
|
61990
|
-
function sessionsDirFrom(env, homedirFn =
|
|
63225
|
+
function sessionsDirFrom(env, homedirFn = homedir32) {
|
|
61991
63226
|
const explicit = env.CLAUDISH_SESSIONS_DIR;
|
|
61992
63227
|
if (explicit && explicit.length > 0)
|
|
61993
63228
|
return explicit;
|
|
61994
|
-
return
|
|
63229
|
+
return join33(userHomeFrom(env, homedirFn), ".claudish", "sessions");
|
|
61995
63230
|
}
|
|
61996
63231
|
function claudeCodeStringHash(s) {
|
|
61997
63232
|
let h = 0;
|
|
@@ -62165,7 +63400,7 @@ var init_transcript_tailer = () => {};
|
|
|
62165
63400
|
|
|
62166
63401
|
// src/session-events/index.ts
|
|
62167
63402
|
import { existsSync as existsSync22, readFileSync as readFileSync31, readdirSync as readdirSync5 } from "fs";
|
|
62168
|
-
import { join as
|
|
63403
|
+
import { join as join34 } from "path";
|
|
62169
63404
|
function extractSessionId2(metadata) {
|
|
62170
63405
|
const userId = metadata?.user_id;
|
|
62171
63406
|
if (typeof userId !== "string")
|
|
@@ -62285,13 +63520,13 @@ class SessionEventRegistry {
|
|
|
62285
63520
|
}
|
|
62286
63521
|
}
|
|
62287
63522
|
locateTranscript(sessionId) {
|
|
62288
|
-
const projectsDir =
|
|
62289
|
-
const primary =
|
|
63523
|
+
const projectsDir = join34(this.claudeHome, "projects");
|
|
63524
|
+
const primary = join34(projectsDir, slugFromCwd(this.cwd), `${sessionId}.jsonl`);
|
|
62290
63525
|
if (existsSync22(primary))
|
|
62291
63526
|
return primary;
|
|
62292
63527
|
try {
|
|
62293
63528
|
for (const dir of readdirSync5(projectsDir)) {
|
|
62294
|
-
const candidate =
|
|
63529
|
+
const candidate = join34(projectsDir, dir, `${sessionId}.jsonl`);
|
|
62295
63530
|
if (existsSync22(candidate))
|
|
62296
63531
|
return candidate;
|
|
62297
63532
|
}
|
|
@@ -62300,7 +63535,7 @@ class SessionEventRegistry {
|
|
|
62300
63535
|
}
|
|
62301
63536
|
readSettingsEffortLevel() {
|
|
62302
63537
|
try {
|
|
62303
|
-
const settings = JSON.parse(readFileSync31(
|
|
63538
|
+
const settings = JSON.parse(readFileSync31(join34(this.claudeHome, "settings.json"), "utf-8"));
|
|
62304
63539
|
return typeof settings.effortLevel === "string" ? settings.effortLevel : undefined;
|
|
62305
63540
|
} catch {
|
|
62306
63541
|
return;
|
|
@@ -62411,8 +63646,8 @@ import {
|
|
|
62411
63646
|
unlinkSync as unlinkSync8,
|
|
62412
63647
|
writeFileSync as writeFileSync12
|
|
62413
63648
|
} from "fs";
|
|
62414
|
-
import { homedir as
|
|
62415
|
-
import { join as
|
|
63649
|
+
import { homedir as homedir33 } from "os";
|
|
63650
|
+
import { join as join35 } from "path";
|
|
62416
63651
|
function ensureDir() {
|
|
62417
63652
|
if (!existsSync23(CLAUDISH_DIR)) {
|
|
62418
63653
|
mkdirSync17(CLAUDISH_DIR, { recursive: true });
|
|
@@ -62447,7 +63682,7 @@ function writeToDisk(events) {
|
|
|
62447
63682
|
ensureDir();
|
|
62448
63683
|
const trimmed = enforceSizeCap([...events]);
|
|
62449
63684
|
const payload = { version: 1, events: trimmed };
|
|
62450
|
-
const tmpFile =
|
|
63685
|
+
const tmpFile = join35(CLAUDISH_DIR, `stats-buffer.tmp.${process.pid}.json`);
|
|
62451
63686
|
writeFileSync12(tmpFile, JSON.stringify(payload, null, 2), "utf-8");
|
|
62452
63687
|
renameSync9(tmpFile, BUFFER_FILE);
|
|
62453
63688
|
memoryCache = trimmed;
|
|
@@ -62520,8 +63755,8 @@ function syncFlushOnExit() {
|
|
|
62520
63755
|
var BUFFER_MAX_BYTES, CLAUDISH_DIR, BUFFER_FILE, memoryCache = null, eventsSinceLastFlush = 0, flushScheduled = false, SIGNAL_EXIT_CODE;
|
|
62521
63756
|
var init_stats_buffer = __esm(() => {
|
|
62522
63757
|
BUFFER_MAX_BYTES = 64 * 1024;
|
|
62523
|
-
CLAUDISH_DIR =
|
|
62524
|
-
BUFFER_FILE =
|
|
63758
|
+
CLAUDISH_DIR = join35(homedir33(), ".claudish");
|
|
63759
|
+
BUFFER_FILE = join35(CLAUDISH_DIR, "stats-buffer.json");
|
|
62525
63760
|
process.on("exit", syncFlushOnExit);
|
|
62526
63761
|
SIGNAL_EXIT_CODE = { SIGTERM: 143, SIGINT: 130 };
|
|
62527
63762
|
for (const signal of ["SIGTERM", "SIGINT"]) {
|
|
@@ -63777,402 +65012,6 @@ var init_devin_stream_head_sniffer = __esm(() => {
|
|
|
63777
65012
|
QUOTA_MESSAGE_RE = /quota|out of credits|credit balance|billing|plan limit|exceeded your/i;
|
|
63778
65013
|
});
|
|
63779
65014
|
|
|
63780
|
-
// src/handlers/shared/format/identity-filter.ts
|
|
63781
|
-
function removeBackgroundInfo(text) {
|
|
63782
|
-
let start = text.indexOf(BACKGROUND_OPEN);
|
|
63783
|
-
if (start === -1)
|
|
63784
|
-
return text;
|
|
63785
|
-
let out = "";
|
|
63786
|
-
let done = 0;
|
|
63787
|
-
while (start !== -1) {
|
|
63788
|
-
const end = text.indexOf(BACKGROUND_CLOSE, start + BACKGROUND_OPEN.length);
|
|
63789
|
-
if (end === -1)
|
|
63790
|
-
break;
|
|
63791
|
-
out += text.slice(done, start);
|
|
63792
|
-
done = end + BACKGROUND_CLOSE.length;
|
|
63793
|
-
start = text.indexOf(BACKGROUND_OPEN, done);
|
|
63794
|
-
}
|
|
63795
|
-
return out + text.slice(done);
|
|
63796
|
-
}
|
|
63797
|
-
function rangesOf(text, spans) {
|
|
63798
|
-
return [...text.matchAll(spans)].map((m) => [m.index, m.index + m[0].length]);
|
|
63799
|
-
}
|
|
63800
|
-
function merged(ranges) {
|
|
63801
|
-
if (ranges.length < 2)
|
|
63802
|
-
return ranges;
|
|
63803
|
-
const sorted = [...ranges].sort((a, b) => a[0] - b[0]);
|
|
63804
|
-
const out = [sorted[0]];
|
|
63805
|
-
for (const [from, to] of sorted.slice(1)) {
|
|
63806
|
-
const last = out[out.length - 1];
|
|
63807
|
-
if (from <= last[1])
|
|
63808
|
-
last[1] = Math.max(last[1], to);
|
|
63809
|
-
else
|
|
63810
|
-
out.push([from, to]);
|
|
63811
|
-
}
|
|
63812
|
-
return out;
|
|
63813
|
-
}
|
|
63814
|
-
function inside(ranges, at) {
|
|
63815
|
-
let low = 0;
|
|
63816
|
-
let high = ranges.length - 1;
|
|
63817
|
-
while (low <= high) {
|
|
63818
|
-
const mid = low + high >> 1;
|
|
63819
|
-
if (at < ranges[mid][0])
|
|
63820
|
-
high = mid - 1;
|
|
63821
|
-
else if (at >= ranges[mid][1])
|
|
63822
|
-
low = mid + 1;
|
|
63823
|
-
else
|
|
63824
|
-
return true;
|
|
63825
|
-
}
|
|
63826
|
-
return false;
|
|
63827
|
-
}
|
|
63828
|
-
function inlineCodeRanges(text, fences) {
|
|
63829
|
-
if (!text.includes("`"))
|
|
63830
|
-
return [];
|
|
63831
|
-
const out = [];
|
|
63832
|
-
let runs = [];
|
|
63833
|
-
const closeLine = () => {
|
|
63834
|
-
if (runs.length > 1) {
|
|
63835
|
-
const next = new Array(runs.length).fill(-1);
|
|
63836
|
-
const seen = new Map;
|
|
63837
|
-
for (let k = runs.length - 1;k >= 0; k--) {
|
|
63838
|
-
next[k] = seen.get(runs[k][1]) ?? -1;
|
|
63839
|
-
seen.set(runs[k][1], k);
|
|
63840
|
-
}
|
|
63841
|
-
for (let k = 0;k < runs.length; ) {
|
|
63842
|
-
const close = next[k];
|
|
63843
|
-
if (close === -1) {
|
|
63844
|
-
k++;
|
|
63845
|
-
} else {
|
|
63846
|
-
out.push([runs[k][0], runs[close][0] + runs[close][1]]);
|
|
63847
|
-
k = close + 1;
|
|
63848
|
-
}
|
|
63849
|
-
}
|
|
63850
|
-
}
|
|
63851
|
-
runs = [];
|
|
63852
|
-
};
|
|
63853
|
-
for (let at = 0;at < text.length; at++) {
|
|
63854
|
-
const char = text.charCodeAt(at);
|
|
63855
|
-
if (char === 10) {
|
|
63856
|
-
closeLine();
|
|
63857
|
-
} else if (char === 96) {
|
|
63858
|
-
let end = at + 1;
|
|
63859
|
-
while (end < text.length && text.charCodeAt(end) === 96)
|
|
63860
|
-
end++;
|
|
63861
|
-
if (!inside(fences, at))
|
|
63862
|
-
runs.push([at, end - at]);
|
|
63863
|
-
at = end - 1;
|
|
63864
|
-
}
|
|
63865
|
-
}
|
|
63866
|
-
closeLine();
|
|
63867
|
-
return out;
|
|
63868
|
-
}
|
|
63869
|
-
function stringRanges(text) {
|
|
63870
|
-
if (!text.includes('"'))
|
|
63871
|
-
return [];
|
|
63872
|
-
const out = [];
|
|
63873
|
-
let open = -1;
|
|
63874
|
-
for (let at = 0;at < text.length; at++) {
|
|
63875
|
-
const char = text.charCodeAt(at);
|
|
63876
|
-
if (char === 10) {
|
|
63877
|
-
open = -1;
|
|
63878
|
-
} else if (open === -1) {
|
|
63879
|
-
if (char === 34)
|
|
63880
|
-
open = at;
|
|
63881
|
-
} else if (char === 92) {
|
|
63882
|
-
if (text.charCodeAt(at + 1) !== 10)
|
|
63883
|
-
at++;
|
|
63884
|
-
} else if (char === 34) {
|
|
63885
|
-
out.push([open, at + 1]);
|
|
63886
|
-
open = -1;
|
|
63887
|
-
}
|
|
63888
|
-
}
|
|
63889
|
-
return out;
|
|
63890
|
-
}
|
|
63891
|
-
function codeRanges(text) {
|
|
63892
|
-
const fences = merged(rangesOf(text, FENCE_RE));
|
|
63893
|
-
return merged([...fences, ...inlineCodeRanges(text, fences)]);
|
|
63894
|
-
}
|
|
63895
|
-
function literalRanges(text) {
|
|
63896
|
-
return merged([...codeRanges(text), ...stringRanges(text)]);
|
|
63897
|
-
}
|
|
63898
|
-
function replaceOutside(text, ranges, rule, replacer) {
|
|
63899
|
-
return text.replace(rule, (match, ...rest) => {
|
|
63900
|
-
const offsetAt = rest.findIndex((arg) => typeof arg === "number");
|
|
63901
|
-
const offset = rest[offsetAt];
|
|
63902
|
-
if (inside(ranges, offset))
|
|
63903
|
-
return match;
|
|
63904
|
-
return replacer(match, offset, rest.slice(0, offsetAt));
|
|
63905
|
-
});
|
|
63906
|
-
}
|
|
63907
|
-
function renameReader(text) {
|
|
63908
|
-
if (!text.includes("Claude"))
|
|
63909
|
-
return text;
|
|
63910
|
-
return replaceOutside(text, literalRanges(text), READER_CLAUDE, (match, offset) => {
|
|
63911
|
-
const name = SENTENCE_START.test(text.slice(Math.max(0, offset - 16), offset)) ? READER_NAME[0].toUpperCase() + READER_NAME.slice(1) : READER_NAME;
|
|
63912
|
-
return name + match.slice("Claude".length);
|
|
63913
|
-
});
|
|
63914
|
-
}
|
|
63915
|
-
function scrubText(text) {
|
|
63916
|
-
let out = text;
|
|
63917
|
-
for (const rule of SENTENCE_RULES)
|
|
63918
|
-
out = out.replace(rule, "");
|
|
63919
|
-
out = removeBackgroundInfo(out);
|
|
63920
|
-
for (const rule of LINE_RULES)
|
|
63921
|
-
out = out.replace(rule, "");
|
|
63922
|
-
for (const [rule, to] of RENAMES)
|
|
63923
|
-
out = replaceOutside(out, literalRanges(out), rule, to);
|
|
63924
|
-
return renameReader(out);
|
|
63925
|
-
}
|
|
63926
|
-
function stripKnownHead(text) {
|
|
63927
|
-
for (const head of KNOWN_HEADS) {
|
|
63928
|
-
if (text.startsWith(head))
|
|
63929
|
-
return { body: text.slice(head.length).trimStart(), hadHead: true };
|
|
63930
|
-
}
|
|
63931
|
-
return { body: text, hadHead: false };
|
|
63932
|
-
}
|
|
63933
|
-
function filterIdentity(content, head) {
|
|
63934
|
-
const hadIdentity = IDENTITY_OPENER.test(content);
|
|
63935
|
-
const scrubbed = scrubText(content).replace(/\n{3,}/g, `
|
|
63936
|
-
|
|
63937
|
-
`).trimStart();
|
|
63938
|
-
const { body, hadHead } = stripKnownHead(scrubbed);
|
|
63939
|
-
if (!hadIdentity && !hadHead)
|
|
63940
|
-
return scrubbed;
|
|
63941
|
-
if (head === undefined && hadHead)
|
|
63942
|
-
return scrubbed;
|
|
63943
|
-
const chosen = head ?? NEUTRAL_IDENTITY_HEAD;
|
|
63944
|
-
return body ? `${chosen}
|
|
63945
|
-
|
|
63946
|
-
${body}` : chosen;
|
|
63947
|
-
}
|
|
63948
|
-
function indexOutsideCode(text, needle, from, code) {
|
|
63949
|
-
for (let at = text.indexOf(needle, from);at !== -1; at = text.indexOf(needle, at + 1)) {
|
|
63950
|
-
if (!inside(code, at))
|
|
63951
|
-
return at;
|
|
63952
|
-
}
|
|
63953
|
-
return -1;
|
|
63954
|
-
}
|
|
63955
|
-
function closingTagAt(text, start, open, close, inlineCode) {
|
|
63956
|
-
let depth = 0;
|
|
63957
|
-
let at = start;
|
|
63958
|
-
for (;; ) {
|
|
63959
|
-
const nextClose = indexOutsideCode(text, close, at, inlineCode);
|
|
63960
|
-
if (nextClose === -1)
|
|
63961
|
-
return -1;
|
|
63962
|
-
const nextOpen = indexOutsideCode(text, open, at, inlineCode);
|
|
63963
|
-
if (nextOpen !== -1 && nextOpen < nextClose) {
|
|
63964
|
-
depth++;
|
|
63965
|
-
at = nextOpen + open.length;
|
|
63966
|
-
continue;
|
|
63967
|
-
}
|
|
63968
|
-
depth--;
|
|
63969
|
-
if (depth === 0)
|
|
63970
|
-
return nextClose;
|
|
63971
|
-
at = nextClose + close.length;
|
|
63972
|
-
}
|
|
63973
|
-
}
|
|
63974
|
-
function scrubTagged(text, tag) {
|
|
63975
|
-
const open = `<${tag}>`;
|
|
63976
|
-
const close = `</${tag}>`;
|
|
63977
|
-
if (!text.includes(open))
|
|
63978
|
-
return text;
|
|
63979
|
-
const code = codeRanges(text);
|
|
63980
|
-
const inlineCode = merged(inlineCodeRanges(text, []));
|
|
63981
|
-
let out = "";
|
|
63982
|
-
let done = 0;
|
|
63983
|
-
for (;; ) {
|
|
63984
|
-
const start = indexOutsideCode(text, open, done, code);
|
|
63985
|
-
if (start === -1)
|
|
63986
|
-
break;
|
|
63987
|
-
const end = closingTagAt(text, start, open, close, inlineCode);
|
|
63988
|
-
if (end === -1)
|
|
63989
|
-
break;
|
|
63990
|
-
const stop = end + close.length;
|
|
63991
|
-
out += text.slice(done, start) + scrubText(text.slice(start, stop));
|
|
63992
|
-
done = stop;
|
|
63993
|
-
}
|
|
63994
|
-
return out + text.slice(done);
|
|
63995
|
-
}
|
|
63996
|
-
function scrubInjectedSpans(text) {
|
|
63997
|
-
if (!MAY_HOLD_SPAN.test(text))
|
|
63998
|
-
return text;
|
|
63999
|
-
let out = text;
|
|
64000
|
-
for (const tag of INJECTED_TAGS)
|
|
64001
|
-
out = scrubTagged(out, tag);
|
|
64002
|
-
for (const line of INJECTED_LINES)
|
|
64003
|
-
out = replaceOutside(out, codeRanges(out), line, scrubText);
|
|
64004
|
-
return out;
|
|
64005
|
-
}
|
|
64006
|
-
function systemTextOf2(system) {
|
|
64007
|
-
if (typeof system === "string")
|
|
64008
|
-
return system;
|
|
64009
|
-
if (!Array.isArray(system))
|
|
64010
|
-
return "";
|
|
64011
|
-
return system.map((item) => typeof item === "string" ? item : item?.text ?? "").filter((text) => text.trim() !== "").join(`
|
|
64012
|
-
|
|
64013
|
-
`);
|
|
64014
|
-
}
|
|
64015
|
-
function scrubSchema(schema) {
|
|
64016
|
-
if (Array.isArray(schema))
|
|
64017
|
-
return schema.map(scrubSchema);
|
|
64018
|
-
if (!schema || typeof schema !== "object")
|
|
64019
|
-
return schema;
|
|
64020
|
-
const out = {};
|
|
64021
|
-
for (const [key, value] of Object.entries(schema)) {
|
|
64022
|
-
if (key === "description" && typeof value === "string")
|
|
64023
|
-
out[key] = scrubText(value);
|
|
64024
|
-
else if (SCHEMA_VALUE_KEYS.has(key))
|
|
64025
|
-
out[key] = value;
|
|
64026
|
-
else if (SCHEMA_NAME_MAPS.has(key))
|
|
64027
|
-
out[key] = scrubNamedSchemas(value);
|
|
64028
|
-
else
|
|
64029
|
-
out[key] = scrubSchema(value);
|
|
64030
|
-
}
|
|
64031
|
-
return out;
|
|
64032
|
-
}
|
|
64033
|
-
function scrubNamedSchemas(map) {
|
|
64034
|
-
if (!map || typeof map !== "object" || Array.isArray(map))
|
|
64035
|
-
return map;
|
|
64036
|
-
const out = {};
|
|
64037
|
-
for (const [name, schema] of Object.entries(map))
|
|
64038
|
-
out[name] = scrubSchema(schema);
|
|
64039
|
-
return out;
|
|
64040
|
-
}
|
|
64041
|
-
function scrubToolDefinition(tool) {
|
|
64042
|
-
if (!tool || typeof tool !== "object")
|
|
64043
|
-
return tool;
|
|
64044
|
-
const out = { ...tool };
|
|
64045
|
-
if (typeof tool.description === "string")
|
|
64046
|
-
out.description = scrubText(tool.description);
|
|
64047
|
-
if (tool.input_schema)
|
|
64048
|
-
out.input_schema = scrubSchema(tool.input_schema);
|
|
64049
|
-
return out;
|
|
64050
|
-
}
|
|
64051
|
-
function scrubUserContent(content) {
|
|
64052
|
-
if (typeof content === "string")
|
|
64053
|
-
return scrubInjectedSpans(content);
|
|
64054
|
-
if (!Array.isArray(content))
|
|
64055
|
-
return content;
|
|
64056
|
-
return content.map((block) => block?.type === "text" && typeof block.text === "string" ? { ...block, text: scrubInjectedSpans(block.text) } : block);
|
|
64057
|
-
}
|
|
64058
|
-
function scrubSystemContent(content) {
|
|
64059
|
-
if (typeof content === "string")
|
|
64060
|
-
return scrubText(content);
|
|
64061
|
-
if (!Array.isArray(content))
|
|
64062
|
-
return content;
|
|
64063
|
-
return content.map((block) => {
|
|
64064
|
-
if (block?.type === "text" && typeof block.text === "string") {
|
|
64065
|
-
return { ...block, text: scrubText(block.text) };
|
|
64066
|
-
}
|
|
64067
|
-
if (block?.type === "tool_addition" && block.tool?.definition) {
|
|
64068
|
-
return {
|
|
64069
|
-
...block,
|
|
64070
|
-
tool: { ...block.tool, definition: scrubToolDefinition(block.tool.definition) }
|
|
64071
|
-
};
|
|
64072
|
-
}
|
|
64073
|
-
return block;
|
|
64074
|
-
});
|
|
64075
|
-
}
|
|
64076
|
-
function scrubSystem(system, head, hadIdentity) {
|
|
64077
|
-
if (typeof system === "string") {
|
|
64078
|
-
const body = collapse(scrubText(system));
|
|
64079
|
-
if (!hadIdentity)
|
|
64080
|
-
return body;
|
|
64081
|
-
return body ? `${head}
|
|
64082
|
-
|
|
64083
|
-
${body}` : head;
|
|
64084
|
-
}
|
|
64085
|
-
if (Array.isArray(system)) {
|
|
64086
|
-
const blocks = system.map((b) => typeof b === "string" ? { type: "text", text: b } : b).map((b) => b?.type === "text" && typeof b.text === "string" ? { ...b, text: collapse(scrubText(b.text)) } : b).filter((b) => !(b?.type === "text" && (b.text ?? "").trim() === ""));
|
|
64087
|
-
if (hadIdentity)
|
|
64088
|
-
blocks.unshift({ type: "text", text: head });
|
|
64089
|
-
return blocks;
|
|
64090
|
-
}
|
|
64091
|
-
return hadIdentity ? head : system;
|
|
64092
|
-
}
|
|
64093
|
-
function scrubHarnessIdentity(req, head) {
|
|
64094
|
-
const out = { ...req };
|
|
64095
|
-
const hadIdentity = IDENTITY_OPENER.test(systemTextOf2(req.system));
|
|
64096
|
-
out.system = scrubSystem(req.system, head, hadIdentity);
|
|
64097
|
-
if (Array.isArray(req.tools))
|
|
64098
|
-
out.tools = req.tools.map(scrubToolDefinition);
|
|
64099
|
-
if (Array.isArray(req.messages)) {
|
|
64100
|
-
out.messages = req.messages.map((msg) => {
|
|
64101
|
-
if (msg?.role === "user")
|
|
64102
|
-
return { ...msg, content: scrubUserContent(msg.content) };
|
|
64103
|
-
if (msg?.role === "system")
|
|
64104
|
-
return { ...msg, content: scrubSystemContent(msg.content) };
|
|
64105
|
-
return msg;
|
|
64106
|
-
});
|
|
64107
|
-
}
|
|
64108
|
-
return out;
|
|
64109
|
-
}
|
|
64110
|
-
function identityHeadFor(providerName) {
|
|
64111
|
-
return providerName === "antigravity" ? ANTIGRAVITY_IDENTITY_HEAD : NEUTRAL_IDENTITY_HEAD;
|
|
64112
|
-
}
|
|
64113
|
-
function keepsClaudeIdentity(route) {
|
|
64114
|
-
if (route.vendor)
|
|
64115
|
-
return route.vendor.toLowerCase() === "anthropic";
|
|
64116
|
-
if (route.native)
|
|
64117
|
-
return true;
|
|
64118
|
-
return /(^|[/.])claude-/i.test(route.model);
|
|
64119
|
-
}
|
|
64120
|
-
var NEUTRAL_IDENTITY_HEAD = "You are an AI coding agent working in a command-line agent harness. If asked who you are, name your actual model and the company that made it.", ANTIGRAVITY_IDENTITY_HEAD, KNOWN_HEADS, HARNESS_NAME = "Agent CLI", LINE_RULES, SENTENCE_RULES, BACKGROUND_OPEN = "<claude_background_info>", BACKGROUND_CLOSE = "</claude_background_info>", FENCE_OPEN, FENCE_CLOSE, FENCE, FENCE_RE, HARNESS_IN_PROSE, RENAMES, READER_NAME = "the assistant", READER_CLAUDE, SENTENCE_START, IDENTITY_OPENER, INJECTED_TAGS, INJECTED_LINES, MAY_HOLD_SPAN, SCHEMA_VALUE_KEYS, SCHEMA_NAME_MAPS, collapse = (text) => text.replace(/\n{3,}/g, `
|
|
64121
|
-
|
|
64122
|
-
`).trimStart();
|
|
64123
|
-
var init_identity_filter = __esm(() => {
|
|
64124
|
-
ANTIGRAVITY_IDENTITY_HEAD = [
|
|
64125
|
-
"You are Antigravity, a powerful agentic AI coding assistant designed by the Google Deepmind team working on Advanced Agentic Coding.",
|
|
64126
|
-
"You are pair programming with a USER to solve their coding task. The task may require creating a new codebase, modifying or debugging an existing codebase, or simply answering a question."
|
|
64127
|
-
].join(`
|
|
64128
|
-
`);
|
|
64129
|
-
KNOWN_HEADS = [NEUTRAL_IDENTITY_HEAD, ANTIGRAVITY_IDENTITY_HEAD];
|
|
64130
|
-
LINE_RULES = [
|
|
64131
|
-
/^[ \t]*(?:-[ \t]+)?The most recent Claude models are[^\n]*(?:\n|$)/gm,
|
|
64132
|
-
/^[ \t]*(?:-[ \t]+)?Claude Code is available as a CLI[^\n]*(?:\n|$)/gm,
|
|
64133
|
-
/^[ \t]*(?:-[ \t]+)?Fast mode for Claude Code[^\n]*(?:\n|$)/gm
|
|
64134
|
-
];
|
|
64135
|
-
SENTENCE_RULES = [
|
|
64136
|
-
/You are Claude Code, Anthropic's official CLI(?:[^\n]{0,300}?\.(?=\s|$|<)|[^.\n]{0,300})/g,
|
|
64137
|
-
/You are a Claude agent, built on Anthropic's Claude Agent SDK\.?/g,
|
|
64138
|
-
/You are powered by the model named [^\n]{0,300}?\.(?=\s|$|<)/g,
|
|
64139
|
-
/The exact model ID is [^\s<]{1,200}?\.(?=\s|$|<)/g,
|
|
64140
|
-
/Assistant knowledge cutoff is [^\n]{0,300}?\.(?=\s|$|<)/g
|
|
64141
|
-
];
|
|
64142
|
-
FENCE_OPEN = String.raw`^(?:[ \t]*(?:>|[-*+][ \t]|\d+[.)][ \t]))*[ \t]*((\x60|~)\2{2,})[^\n]*`;
|
|
64143
|
-
FENCE_CLOSE = String.raw`^(?:[ \t]*>)*[ \t]*\1\2*[ \t]*$`;
|
|
64144
|
-
FENCE = String.raw`${FENCE_OPEN}(?:\n[\s\S]*?(?:${FENCE_CLOSE}|(?![\s\S]))|(?![\s\S]))`;
|
|
64145
|
-
FENCE_RE = new RegExp(FENCE, "gm");
|
|
64146
|
-
HARNESS_IN_PROSE = /(?<![\w/\\"'`.-])Claude Code(?![\w"`/\\]|'(?!s\b)|\.\w)/g;
|
|
64147
|
-
RENAMES = [
|
|
64148
|
-
[/ ?\(claude\.ai\/code\)/g, () => ""],
|
|
64149
|
-
[HARNESS_IN_PROSE, () => HARNESS_NAME],
|
|
64150
|
-
[/\bClaude (sessions?)\b/g, (_match, _offset, groups) => `${HARNESS_NAME} ${groups[0]}`]
|
|
64151
|
-
];
|
|
64152
|
-
READER_CLAUDE = new RegExp([
|
|
64153
|
-
String.raw`(?<![\w/\\.@"'\x60-])`,
|
|
64154
|
-
String.raw`(?<!\b(?:a|an|the|other|another|internal|each|every|any|your|real)\s)`,
|
|
64155
|
-
String.raw`Claude(?:['\u2019]s)?`,
|
|
64156
|
-
String.raw`(?![\w/\\'\u2019"\x60-])`,
|
|
64157
|
-
String.raw`(?!\s*=)`,
|
|
64158
|
-
String.raw`(?!\.\w)`,
|
|
64159
|
-
String.raw`(?!\.\.\.)`,
|
|
64160
|
-
String.raw`(?!,\s+[A-Z])`,
|
|
64161
|
-
String.raw`(?!\s+(?:[A-Z\d]|in\s+(?:Chrome|Slack)\b|(?:models?|desktop|login|account|subscription|family|apps?|plans?)\b))`
|
|
64162
|
-
].join(""), "g");
|
|
64163
|
-
SENTENCE_START = /(?:[.!?]["')\]*]*\s+|(?:^|\n)[ \t]*(?:(?:[-*\u2022]|\d+\.)[ \t]+)?(?:\*\*)?)$/;
|
|
64164
|
-
IDENTITY_OPENER = /You are Claude Code, Anthropic's official CLI|You are a Claude agent, built on Anthropic's Claude Agent SDK/;
|
|
64165
|
-
INJECTED_TAGS = ["system-reminder", "local-command-caveat"];
|
|
64166
|
-
INJECTED_LINES = [
|
|
64167
|
-
/^This is how Claude Code surfaces (?:messages the user sends mid-turn|a prompt a plugin submits between turns)[^\n]*$/gm,
|
|
64168
|
-
/^Another Claude session sent a message:[ \t]*$/gm,
|
|
64169
|
-
/^This came from another Claude session[^\n]*$/gm
|
|
64170
|
-
];
|
|
64171
|
-
MAY_HOLD_SPAN = /<system-reminder>|<local-command-caveat>|Claude/;
|
|
64172
|
-
SCHEMA_VALUE_KEYS = new Set(["enum", "const", "default", "examples"]);
|
|
64173
|
-
SCHEMA_NAME_MAPS = new Set(["properties", "patternProperties", "$defs", "definitions"]);
|
|
64174
|
-
});
|
|
64175
|
-
|
|
64176
65015
|
// src/handlers/shared/format/inline-system.ts
|
|
64177
65016
|
function systemTextOf3(content) {
|
|
64178
65017
|
if (typeof content === "string")
|
|
@@ -64406,6 +65245,7 @@ var init_provider_refused_text = __esm(() => {
|
|
|
64406
65245
|
});
|
|
64407
65246
|
|
|
64408
65247
|
// src/handlers/shared/format/tool-name-alias.ts
|
|
65248
|
+
import { existsSync as existsSync24 } from "fs";
|
|
64409
65249
|
function renameKeys(args, names) {
|
|
64410
65250
|
const out = {};
|
|
64411
65251
|
for (const [key, value] of Object.entries(args))
|
|
@@ -64431,6 +65271,50 @@ function readRangeFromWire(args) {
|
|
|
64431
65271
|
}
|
|
64432
65272
|
return out;
|
|
64433
65273
|
}
|
|
65274
|
+
function questionsToWire(args) {
|
|
65275
|
+
if (!Array.isArray(args.questions))
|
|
65276
|
+
return args;
|
|
65277
|
+
return {
|
|
65278
|
+
...args,
|
|
65279
|
+
questions: args.questions.map((question) => {
|
|
65280
|
+
if (!isRecord5(question))
|
|
65281
|
+
return question;
|
|
65282
|
+
const out = { question: question.question };
|
|
65283
|
+
if (Array.isArray(question.options)) {
|
|
65284
|
+
out.options = question.options.map((option) => isRecord5(option) ? option.label : option);
|
|
65285
|
+
}
|
|
65286
|
+
if (typeof question.multiSelect === "boolean")
|
|
65287
|
+
out.is_multi_select = question.multiSelect;
|
|
65288
|
+
return out;
|
|
65289
|
+
})
|
|
65290
|
+
};
|
|
65291
|
+
}
|
|
65292
|
+
function questionsFromWire(args) {
|
|
65293
|
+
if (!Array.isArray(args.questions))
|
|
65294
|
+
return args;
|
|
65295
|
+
return {
|
|
65296
|
+
...args,
|
|
65297
|
+
questions: args.questions.map((question, index) => {
|
|
65298
|
+
if (!isRecord5(question))
|
|
65299
|
+
return question;
|
|
65300
|
+
return {
|
|
65301
|
+
question: question.question,
|
|
65302
|
+
header: typeof question.header === "string" ? question.header : `Question ${index + 1}`,
|
|
65303
|
+
options: Array.isArray(question.options) ? question.options.map((option) => typeof option === "string" ? { label: option, description: option } : option) : question.options,
|
|
65304
|
+
multiSelect: typeof question.multiSelect === "boolean" ? question.multiSelect : question.is_multi_select === true
|
|
65305
|
+
};
|
|
65306
|
+
})
|
|
65307
|
+
};
|
|
65308
|
+
}
|
|
65309
|
+
function leftAsSent(wireName, args) {
|
|
65310
|
+
if (wireName === "read_file")
|
|
65311
|
+
return typeof args.ByteOffset === "number" && args.ByteOffset > 0;
|
|
65312
|
+
if (wireName !== "write_file")
|
|
65313
|
+
return false;
|
|
65314
|
+
if (args.Append === true)
|
|
65315
|
+
return true;
|
|
65316
|
+
return args.Overwrite !== true && typeof args.Path === "string" && existsSync24(args.Path);
|
|
65317
|
+
}
|
|
64434
65318
|
function schemaToWire(schema, native, names) {
|
|
64435
65319
|
if (!isRecord5(schema) || !isRecord5(schema.properties))
|
|
64436
65320
|
return schema;
|
|
@@ -64468,6 +65352,9 @@ function aliasToolsForProvider(req, providerName) {
|
|
|
64468
65352
|
};
|
|
64469
65353
|
}
|
|
64470
65354
|
const argumentTables = PROVIDER_ARGUMENT_ALIASES[providerName] ?? {};
|
|
65355
|
+
const descriptionOf = PROVIDER_DESCRIPTIONS[providerName] ?? (() => {
|
|
65356
|
+
return;
|
|
65357
|
+
});
|
|
64471
65358
|
const declared = new Set(Array.isArray(req.tools) ? req.tools.map((tool) => tool?.name) : []);
|
|
64472
65359
|
const forward = new Map;
|
|
64473
65360
|
const backward = new Map;
|
|
@@ -64491,14 +65378,14 @@ function aliasToolsForProvider(req, providerName) {
|
|
|
64491
65378
|
if (!names || !isRecord5(args))
|
|
64492
65379
|
return args;
|
|
64493
65380
|
const renamed = renameKeys(args, names);
|
|
64494
|
-
return native
|
|
65381
|
+
return AGY_ARGUMENT_SHAPE[native]?.toWire?.(renamed) ?? renamed;
|
|
64495
65382
|
};
|
|
64496
65383
|
const restoreArguments = (wireName, args) => {
|
|
64497
65384
|
const names = fromWire.get(wireName);
|
|
64498
|
-
if (!names || !isRecord5(args))
|
|
65385
|
+
if (!names || !isRecord5(args) || leftAsSent(wireName, args))
|
|
64499
65386
|
return args;
|
|
64500
65387
|
const renamed = renameKeys(args, names);
|
|
64501
|
-
return wireName
|
|
65388
|
+
return AGY_ARGUMENT_SHAPE[wireName]?.fromWire?.(renamed) ?? renamed;
|
|
64502
65389
|
};
|
|
64503
65390
|
const out = { ...req };
|
|
64504
65391
|
if (Array.isArray(req.tools)) {
|
|
@@ -64507,7 +65394,9 @@ function aliasToolsForProvider(req, providerName) {
|
|
|
64507
65394
|
if (native === undefined)
|
|
64508
65395
|
return tool;
|
|
64509
65396
|
const names = toWire.get(native);
|
|
64510
|
-
|
|
65397
|
+
const renamed = names && "input_schema" in tool ? { ...tool, name: native, input_schema: schemaToWire(tool.input_schema, native, names) } : { ...tool, name: native };
|
|
65398
|
+
const description = descriptionOf(native);
|
|
65399
|
+
return description === undefined ? renamed : { ...renamed, description };
|
|
64511
65400
|
});
|
|
64512
65401
|
}
|
|
64513
65402
|
const choice = req.tool_choice;
|
|
@@ -64524,18 +65413,22 @@ function aliasToolsForProvider(req, providerName) {
|
|
|
64524
65413
|
restoreArguments
|
|
64525
65414
|
};
|
|
64526
65415
|
}
|
|
64527
|
-
var AGY_TOOL_ALIAS, PROVIDER_ALIASES, AGY_ARGUMENT_ALIAS, PROVIDER_ARGUMENT_ALIASES, isRecord5 = (value) => typeof value === "object" && value !== null && !Array.isArray(value),
|
|
65416
|
+
var AGY_TOOL_ALIAS, PROVIDER_ALIASES, AGY_ARGUMENT_ALIAS, PROVIDER_DESCRIPTIONS, PROVIDER_ARGUMENT_ALIASES, isRecord5 = (value) => typeof value === "object" && value !== null && !Array.isArray(value), without = (args, ...names) => {
|
|
65417
|
+
const out = { ...args };
|
|
65418
|
+
for (const name of names)
|
|
65419
|
+
delete out[name];
|
|
65420
|
+
return out;
|
|
65421
|
+
}, AGY_ARGUMENT_SHAPE, READ_RANGE_PROPERTIES, identity = (name) => name;
|
|
64528
65422
|
var init_tool_name_alias = __esm(() => {
|
|
65423
|
+
init_antigravity_agy_request2();
|
|
64529
65424
|
AGY_TOOL_ALIAS = [
|
|
64530
65425
|
["Bash", "run_command"],
|
|
64531
65426
|
["Read", "read_file"],
|
|
64532
65427
|
["Write", "write_file"],
|
|
64533
65428
|
["Edit", "edit_file"],
|
|
64534
|
-
["Agent", "invoke_subagent"],
|
|
64535
65429
|
["AskUserQuestion", "ask_question"],
|
|
64536
65430
|
["WebSearch", "search_web"],
|
|
64537
65431
|
["SendMessage", "send_message"],
|
|
64538
|
-
["Workflow", "run_workflow"],
|
|
64539
65432
|
["Grep", "grep_search"],
|
|
64540
65433
|
["Glob", "find_by_name"],
|
|
64541
65434
|
["LS", "list_dir"]
|
|
@@ -64558,11 +65451,40 @@ var init_tool_name_alias = __esm(() => {
|
|
|
64558
65451
|
["file_path", "Path"],
|
|
64559
65452
|
["old_string", "Target"],
|
|
64560
65453
|
["new_string", "Replacement"]
|
|
64561
|
-
]
|
|
65454
|
+
],
|
|
65455
|
+
send_message: [
|
|
65456
|
+
["to", "Recipient"],
|
|
65457
|
+
["message", "Message"]
|
|
65458
|
+
],
|
|
65459
|
+
search_web: [],
|
|
65460
|
+
ask_question: []
|
|
65461
|
+
};
|
|
65462
|
+
PROVIDER_DESCRIPTIONS = {
|
|
65463
|
+
antigravity: (native) => (native in AGY_ARGUMENT_ALIAS) ? agyDeclarationTemplate(native)?.description : undefined
|
|
64562
65464
|
};
|
|
64563
65465
|
PROVIDER_ARGUMENT_ALIASES = {
|
|
64564
65466
|
antigravity: AGY_ARGUMENT_ALIAS
|
|
64565
65467
|
};
|
|
65468
|
+
AGY_ARGUMENT_SHAPE = {
|
|
65469
|
+
run_command: { fromWire: (args) => without(args, "WaitMsBeforeAsync") },
|
|
65470
|
+
read_file: {
|
|
65471
|
+
toWire: readRangeToWire,
|
|
65472
|
+
fromWire: (args) => readRangeFromWire(without(args, "ByteOffset"))
|
|
65473
|
+
},
|
|
65474
|
+
write_file: { fromWire: (args) => without(args, "Overwrite", "Append", "ArtifactMetadata") },
|
|
65475
|
+
edit_file: {
|
|
65476
|
+
toWire: (args) => without(args, "replace_all"),
|
|
65477
|
+
fromWire: (args) => ({
|
|
65478
|
+
...without(args, "ArtifactMetadata"),
|
|
65479
|
+
replace_all: typeof args.replace_all === "boolean" ? args.replace_all : true
|
|
65480
|
+
})
|
|
65481
|
+
},
|
|
65482
|
+
search_web: {
|
|
65483
|
+
toWire: (args) => without(args, "allowed_domains", "blocked_domains"),
|
|
65484
|
+
fromWire: (args) => without(args, "domain")
|
|
65485
|
+
},
|
|
65486
|
+
ask_question: { toWire: questionsToWire, fromWire: questionsFromWire }
|
|
65487
|
+
};
|
|
64566
65488
|
READ_RANGE_PROPERTIES = {
|
|
64567
65489
|
StartLine: { type: "integer", description: "The first line to read, counted from 1." },
|
|
64568
65490
|
EndLine: { type: "integer", description: "The last line to read, counted from 1." }
|
|
@@ -68793,7 +69715,7 @@ var init_openai_responses_sse = __esm(() => {
|
|
|
68793
69715
|
});
|
|
68794
69716
|
|
|
68795
69717
|
// src/session/token-file.ts
|
|
68796
|
-
import { join as
|
|
69718
|
+
import { join as join36 } from "path";
|
|
68797
69719
|
function assignedTokenFile(env) {
|
|
68798
69720
|
const f = env.CLAUDISH_TOKEN_FILE;
|
|
68799
69721
|
if (!f || f === env.CLAUDISH_PUBLISHED_TOKEN_FILE)
|
|
@@ -68801,7 +69723,7 @@ function assignedTokenFile(env) {
|
|
|
68801
69723
|
return f;
|
|
68802
69724
|
}
|
|
68803
69725
|
function resolveTokenFilePath(port, env = process.env) {
|
|
68804
|
-
return assignedTokenFile(env) ??
|
|
69726
|
+
return assignedTokenFile(env) ?? join36(userHomeFrom(env), ".claudish", `tokens-${port}.json`);
|
|
68805
69727
|
}
|
|
68806
69728
|
var init_token_file = __esm(() => {
|
|
68807
69729
|
init_home_dir();
|
|
@@ -71408,11 +72330,11 @@ var init_composed_handler = __esm(() => {
|
|
|
71408
72330
|
});
|
|
71409
72331
|
|
|
71410
72332
|
// src/providers/api-key-provenance.ts
|
|
71411
|
-
import { existsSync as
|
|
71412
|
-
import { homedir as
|
|
71413
|
-
import { join as
|
|
72333
|
+
import { existsSync as existsSync25, readFileSync as readFileSync33 } from "fs";
|
|
72334
|
+
import { homedir as homedir34 } from "os";
|
|
72335
|
+
import { join as join37, resolve as resolve4 } from "path";
|
|
71414
72336
|
function activeConfigPath() {
|
|
71415
|
-
return activeGlobalConfigFile(
|
|
72337
|
+
return activeGlobalConfigFile(join37(homedir34(), ".claudish", "config.json"));
|
|
71416
72338
|
}
|
|
71417
72339
|
function configLayerLabel() {
|
|
71418
72340
|
return getConfigFileOverride() ? activeConfigPath() : "~/.claudish/config.json";
|
|
@@ -71568,7 +72490,7 @@ function formatProvenanceLog(p) {
|
|
|
71568
72490
|
function readDotenvKey(envVars) {
|
|
71569
72491
|
try {
|
|
71570
72492
|
const dotenvPath = resolve4(".env");
|
|
71571
|
-
if (!
|
|
72493
|
+
if (!existsSync25(dotenvPath))
|
|
71572
72494
|
return null;
|
|
71573
72495
|
const parsed = readAllowedDotenv(readFileSync33(dotenvPath, "utf-8"));
|
|
71574
72496
|
for (const v of envVars) {
|
|
@@ -71583,7 +72505,7 @@ function readDotenvKey(envVars) {
|
|
|
71583
72505
|
function readConfigKey(envVar) {
|
|
71584
72506
|
try {
|
|
71585
72507
|
const configPath = activeConfigPath();
|
|
71586
|
-
if (!
|
|
72508
|
+
if (!existsSync25(configPath))
|
|
71587
72509
|
return null;
|
|
71588
72510
|
const cfg = JSON.parse(readFileSync33(configPath, "utf-8"));
|
|
71589
72511
|
return realValueFor(envVar, cfg.apiKeys?.[envVar]) || null;
|
|
@@ -86400,9 +87322,9 @@ function compareByConnectionPrice(a, b) {
|
|
|
86400
87322
|
}
|
|
86401
87323
|
|
|
86402
87324
|
// src/providers/probe-catalog.ts
|
|
86403
|
-
import { existsSync as
|
|
86404
|
-
import { homedir as
|
|
86405
|
-
import { dirname as dirname16, join as
|
|
87325
|
+
import { existsSync as existsSync26, mkdirSync as mkdirSync19, readFileSync as readFileSync34, writeFileSync as writeFileSync14 } from "fs";
|
|
87326
|
+
import { homedir as homedir35 } from "os";
|
|
87327
|
+
import { dirname as dirname16, join as join38 } from "path";
|
|
86406
87328
|
function describeProbeCatalogFailure(outcome) {
|
|
86407
87329
|
switch (outcome.kind) {
|
|
86408
87330
|
case "incompatible":
|
|
@@ -86418,7 +87340,7 @@ function describeProbeCatalogFailure(outcome) {
|
|
|
86418
87340
|
}
|
|
86419
87341
|
}
|
|
86420
87342
|
function readProbeModelsCache(path = PROBE_MODELS_CACHE_PATH) {
|
|
86421
|
-
if (!
|
|
87343
|
+
if (!existsSync26(path))
|
|
86422
87344
|
return null;
|
|
86423
87345
|
let raw;
|
|
86424
87346
|
try {
|
|
@@ -86574,7 +87496,7 @@ var init_probe_catalog = __esm(() => {
|
|
|
86574
87496
|
init_catalog_endpoints();
|
|
86575
87497
|
init_catalog_route_bindings();
|
|
86576
87498
|
CACHE_TTL_MS4 = 60 * 60 * 1000;
|
|
86577
|
-
PROBE_MODELS_CACHE_PATH =
|
|
87499
|
+
PROBE_MODELS_CACHE_PATH = join38(homedir35(), ".claudish", "probe-models.json");
|
|
86578
87500
|
});
|
|
86579
87501
|
|
|
86580
87502
|
// src/providers/route-candidates.ts
|
|
@@ -88462,8 +89384,8 @@ function herdrPaneEnv(env = process.env) {
|
|
|
88462
89384
|
|
|
88463
89385
|
// src/auth/claude-code-login.ts
|
|
88464
89386
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
88465
|
-
import { existsSync as
|
|
88466
|
-
import { join as
|
|
89387
|
+
import { existsSync as existsSync27, readFileSync as readFileSync35 } from "fs";
|
|
89388
|
+
import { join as join39 } from "path";
|
|
88467
89389
|
function keychainLoginPresent(env, presence, cwd = process.cwd()) {
|
|
88468
89390
|
return anyPresent(claudeCodeSecureStorageServices("-credentials", env, cwd), presence) === "found";
|
|
88469
89391
|
}
|
|
@@ -88473,8 +89395,8 @@ function hasClaudeCodeLogin(deps = {}) {
|
|
|
88473
89395
|
const token = env.CLAUDE_CODE_OAUTH_TOKEN;
|
|
88474
89396
|
if (typeof token === "string" && token.trim().length > 0)
|
|
88475
89397
|
return true;
|
|
88476
|
-
const fileExists = deps.fileExists ??
|
|
88477
|
-
if (fileExists(
|
|
89398
|
+
const fileExists = deps.fileExists ?? existsSync27;
|
|
89399
|
+
if (fileExists(join39(claudeCodeConfigDir(env, cwd), ".credentials.json")))
|
|
88478
89400
|
return true;
|
|
88479
89401
|
return (deps.keychainProbe ?? defaultKeychainAnthropicProbe)(env, cwd);
|
|
88480
89402
|
}
|
|
@@ -88501,13 +89423,13 @@ function defaultKeychainPresence(service) {
|
|
|
88501
89423
|
function claudeCodeStartupCredential(deps = {}) {
|
|
88502
89424
|
const env = deps.env ?? process.env;
|
|
88503
89425
|
const cwd = deps.cwd ?? process.cwd();
|
|
88504
|
-
const fileExists = deps.fileExists ??
|
|
89426
|
+
const fileExists = deps.fileExists ?? existsSync27;
|
|
88505
89427
|
const readFile = deps.readFile ?? ((path) => readFileSync35(path, "utf-8"));
|
|
88506
89428
|
const presence = deps.keychainPresence ?? defaultKeychainPresence;
|
|
88507
89429
|
const token = env.CLAUDE_CODE_OAUTH_TOKEN;
|
|
88508
89430
|
if (typeof token === "string" && token.trim().length > 0)
|
|
88509
89431
|
return { kind: "login" };
|
|
88510
|
-
if (fileExists(
|
|
89432
|
+
if (fileExists(join39(claudeCodeConfigDir(env, cwd), ".credentials.json"))) {
|
|
88511
89433
|
return { kind: "login" };
|
|
88512
89434
|
}
|
|
88513
89435
|
const oauth = anyPresent(claudeCodeSecureStorageServices("-credentials", env, cwd), presence);
|
|
@@ -89742,7 +90664,7 @@ var init_own_pane = () => {};
|
|
|
89742
90664
|
|
|
89743
90665
|
// src/pane/prompt-delivery.ts
|
|
89744
90666
|
import { writeFileSync as writeFileSync15 } from "fs";
|
|
89745
|
-
import { join as
|
|
90667
|
+
import { join as join40 } from "path";
|
|
89746
90668
|
function stripControl(s) {
|
|
89747
90669
|
let out = "";
|
|
89748
90670
|
for (const ch of s) {
|
|
@@ -89809,7 +90731,7 @@ function renderTurnFile(text, limit = READ_LINE_LIMIT) {
|
|
|
89809
90731
|
`), lines: out.length, marker };
|
|
89810
90732
|
}
|
|
89811
90733
|
function turnFilePath(turnDir, turnIndex) {
|
|
89812
|
-
return
|
|
90734
|
+
return join40(turnDir, `turn-${turnIndex}.md`);
|
|
89813
90735
|
}
|
|
89814
90736
|
function fileTemplate(file, marker) {
|
|
89815
90737
|
const base = `Your task is in the file \`${file}\`. Read all of it with the Read tool (in parts if it is long), then do exactly what it says, treating its content as the user's message.`;
|
|
@@ -90812,7 +91734,7 @@ var init_subagent_ledger = __esm(() => {
|
|
|
90812
91734
|
// src/pane/transcript-follower.ts
|
|
90813
91735
|
import {
|
|
90814
91736
|
closeSync as closeSync11,
|
|
90815
|
-
existsSync as
|
|
91737
|
+
existsSync as existsSync28,
|
|
90816
91738
|
fstatSync as fstatSync3,
|
|
90817
91739
|
openSync as openSync11,
|
|
90818
91740
|
readFileSync as readFileSync36,
|
|
@@ -90821,7 +91743,7 @@ import {
|
|
|
90821
91743
|
realpathSync as realpathSync5,
|
|
90822
91744
|
statSync as statSync13
|
|
90823
91745
|
} from "fs";
|
|
90824
|
-
import { join as
|
|
91746
|
+
import { join as join41 } from "path";
|
|
90825
91747
|
function initialFollowerState(resolvePath = safeRealpath) {
|
|
90826
91748
|
return {
|
|
90827
91749
|
turns: [],
|
|
@@ -91390,7 +92312,7 @@ class TranscriptFollower {
|
|
|
91390
92312
|
return any;
|
|
91391
92313
|
}
|
|
91392
92314
|
subagentEntries() {
|
|
91393
|
-
if (!
|
|
92315
|
+
if (!existsSync28(this.subagentsDir))
|
|
91394
92316
|
return [];
|
|
91395
92317
|
try {
|
|
91396
92318
|
return readdirSync6(this.subagentsDir);
|
|
@@ -91406,7 +92328,7 @@ class TranscriptFollower {
|
|
|
91406
92328
|
continue;
|
|
91407
92329
|
let tail = this.subs.get(f);
|
|
91408
92330
|
if (!tail) {
|
|
91409
|
-
tail = new Tail(
|
|
92331
|
+
tail = new Tail(join41(this.subagentsDir, f));
|
|
91410
92332
|
this.subs.set(f, tail);
|
|
91411
92333
|
}
|
|
91412
92334
|
const agentId = AGENT_FILE_RE.exec(f)?.[1];
|
|
@@ -91425,7 +92347,7 @@ class TranscriptFollower {
|
|
|
91425
92347
|
return any;
|
|
91426
92348
|
}
|
|
91427
92349
|
readMeta(name, agentId) {
|
|
91428
|
-
const path =
|
|
92350
|
+
const path = join41(this.subagentsDir, name);
|
|
91429
92351
|
let mtime;
|
|
91430
92352
|
try {
|
|
91431
92353
|
mtime = statSync13(path).mtimeMs;
|
|
@@ -91480,7 +92402,7 @@ class TranscriptFollower {
|
|
|
91480
92402
|
let availability;
|
|
91481
92403
|
if (this.savingOff)
|
|
91482
92404
|
availability = "off";
|
|
91483
|
-
else if (!
|
|
92405
|
+
else if (!existsSync28(this.path))
|
|
91484
92406
|
availability = "absent";
|
|
91485
92407
|
else if (t && t.acceptedAt === null && fileSize(this.path) <= t.offset)
|
|
91486
92408
|
availability = "empty";
|
|
@@ -91556,9 +92478,9 @@ __export(exports_session_discovery, {
|
|
|
91556
92478
|
});
|
|
91557
92479
|
import { execFile as execFile3, execFileSync as execFileSync2 } from "child_process";
|
|
91558
92480
|
import { closeSync as closeSync12, openSync as openSync12, readSync as readSync5, readdirSync as readdirSync7, realpathSync as realpathSync6, statSync as statSync14 } from "fs";
|
|
91559
|
-
import { basename as
|
|
92481
|
+
import { basename as basename4, join as join42 } from "path";
|
|
91560
92482
|
function projectsDir(env = process.env, cwd = process.cwd()) {
|
|
91561
|
-
return
|
|
92483
|
+
return join42(claudeCodeConfigDir(env, cwd), "projects");
|
|
91562
92484
|
}
|
|
91563
92485
|
function slugForPath(absPath) {
|
|
91564
92486
|
return projectDirNameFor(absPath);
|
|
@@ -91568,7 +92490,7 @@ function transcriptPathFor(cwd, sessionUuid, projectsRoot = projectsDir()) {
|
|
|
91568
92490
|
try {
|
|
91569
92491
|
real = realpathSync6(cwd);
|
|
91570
92492
|
} catch {}
|
|
91571
|
-
return
|
|
92493
|
+
return join42(projectsRoot, slugForPath(real), `${sessionUuid}.jsonl`);
|
|
91572
92494
|
}
|
|
91573
92495
|
function isAgentSession(row) {
|
|
91574
92496
|
return row.entrypoint !== undefined && row.entrypoint !== "cli";
|
|
@@ -91615,7 +92537,7 @@ function projectDirs() {
|
|
|
91615
92537
|
}
|
|
91616
92538
|
}
|
|
91617
92539
|
function sessionsIn2(dirName) {
|
|
91618
|
-
const dir =
|
|
92540
|
+
const dir = join42(projectsDir(), dirName);
|
|
91619
92541
|
let names;
|
|
91620
92542
|
try {
|
|
91621
92543
|
names = readdirSync7(dir).filter((n) => n.endsWith(".jsonl"));
|
|
@@ -91624,13 +92546,13 @@ function sessionsIn2(dirName) {
|
|
|
91624
92546
|
}
|
|
91625
92547
|
const rows = [];
|
|
91626
92548
|
for (const n of names) {
|
|
91627
|
-
const file =
|
|
92549
|
+
const file = join42(dir, n);
|
|
91628
92550
|
try {
|
|
91629
92551
|
const st = statSync14(file);
|
|
91630
92552
|
if (st.size === 0)
|
|
91631
92553
|
continue;
|
|
91632
92554
|
const row = {
|
|
91633
|
-
id:
|
|
92555
|
+
id: basename4(n, ".jsonl"),
|
|
91634
92556
|
file,
|
|
91635
92557
|
mtimeMs: st.mtimeMs,
|
|
91636
92558
|
birthtimeMs: st.birthtimeMs,
|
|
@@ -91732,7 +92654,7 @@ function discoverWorktreeGroups(repo) {
|
|
|
91732
92654
|
if (hit) {
|
|
91733
92655
|
path = hit.path;
|
|
91734
92656
|
live = true;
|
|
91735
|
-
name = hit.path === repo.root ? "(root)" :
|
|
92657
|
+
name = hit.path === repo.root ? "(root)" : basename4(hit.path);
|
|
91736
92658
|
} else if (at !== -1 && dir.startsWith(rootSlug)) {
|
|
91737
92659
|
path = null;
|
|
91738
92660
|
live = false;
|
|
@@ -92090,8 +93012,8 @@ var init_queue = __esm(() => {
|
|
|
92090
93012
|
});
|
|
92091
93013
|
|
|
92092
93014
|
// src/hooks/session/interactive-driver.ts
|
|
92093
|
-
import { existsSync as
|
|
92094
|
-
import { join as
|
|
93015
|
+
import { existsSync as existsSync29, statSync as statSync15 } from "fs";
|
|
93016
|
+
import { join as join43 } from "path";
|
|
92095
93017
|
function nextDriverPhase(phase, ev) {
|
|
92096
93018
|
const row = EDGES[phase];
|
|
92097
93019
|
return row[ev] ?? null;
|
|
@@ -92309,7 +93231,7 @@ class InteractiveDriver {
|
|
|
92309
93231
|
}
|
|
92310
93232
|
follow(sid, offset) {
|
|
92311
93233
|
const path = transcriptPathFor(this.o.cwd, sid, this.o.projectsRoot);
|
|
92312
|
-
this.follower = new TranscriptFollower(path,
|
|
93234
|
+
this.follower = new TranscriptFollower(path, join43(path.replace(/\.jsonl$/, ""), "subagents"));
|
|
92313
93235
|
this.sessionId = sid;
|
|
92314
93236
|
this.settledTurn = null;
|
|
92315
93237
|
this.lastPollAt = Date.now();
|
|
@@ -92330,7 +93252,7 @@ class InteractiveDriver {
|
|
|
92330
93252
|
if (!p)
|
|
92331
93253
|
return;
|
|
92332
93254
|
const path = transcriptPathFor(this.o.cwd, p.id, this.o.projectsRoot);
|
|
92333
|
-
if (!
|
|
93255
|
+
if (!existsSync29(path)) {
|
|
92334
93256
|
if (Date.now() - p.since > RETARGET_WAIT_MS) {
|
|
92335
93257
|
log(`[hooks] interactive driver: no transcript for session ${p.id}; not following it`);
|
|
92336
93258
|
this.pendingSid = null;
|
|
@@ -93028,13 +93950,13 @@ var init_host_routing_env = __esm(() => {
|
|
|
93028
93950
|
|
|
93029
93951
|
// src/launcher/magmux-binary.ts
|
|
93030
93952
|
import { execSync } from "child_process";
|
|
93031
|
-
import { existsSync as
|
|
93032
|
-
import { dirname as dirname17, join as
|
|
93953
|
+
import { existsSync as existsSync30 } from "fs";
|
|
93954
|
+
import { dirname as dirname17, join as join44 } from "path";
|
|
93033
93955
|
import { fileURLToPath } from "url";
|
|
93034
93956
|
function findMagmuxCandidates() {
|
|
93035
93957
|
const thisFile = fileURLToPath(import.meta.url);
|
|
93036
93958
|
const thisDir = dirname17(thisFile);
|
|
93037
|
-
const pkgRoots = [
|
|
93959
|
+
const pkgRoots = [join44(thisDir, ".."), join44(thisDir, "..", "..")];
|
|
93038
93960
|
const platform = process.platform;
|
|
93039
93961
|
const arch = process.arch;
|
|
93040
93962
|
const found = [];
|
|
@@ -93043,16 +93965,16 @@ function findMagmuxCandidates() {
|
|
|
93043
93965
|
found.push(path);
|
|
93044
93966
|
};
|
|
93045
93967
|
for (const pkgRoot of pkgRoots) {
|
|
93046
|
-
const bundled =
|
|
93047
|
-
if (
|
|
93968
|
+
const bundled = join44(pkgRoot, "native", `magmux-${platform}-${arch}`);
|
|
93969
|
+
if (existsSync30(bundled))
|
|
93048
93970
|
add(bundled);
|
|
93049
93971
|
}
|
|
93050
93972
|
try {
|
|
93051
93973
|
const pkgName = `@claudish/magmux-${platform}-${arch}`;
|
|
93052
93974
|
let searchDir = pkgRoots[0];
|
|
93053
93975
|
for (let i = 0;i < 5; i++) {
|
|
93054
|
-
const candidate =
|
|
93055
|
-
if (
|
|
93976
|
+
const candidate = join44(searchDir, "node_modules", pkgName, "bin", "magmux");
|
|
93977
|
+
if (existsSync30(candidate)) {
|
|
93056
93978
|
add(candidate);
|
|
93057
93979
|
break;
|
|
93058
93980
|
}
|
|
@@ -93085,7 +94007,7 @@ var init_magmux_binary = () => {};
|
|
|
93085
94007
|
import {
|
|
93086
94008
|
chmodSync as chmodSync3,
|
|
93087
94009
|
closeSync as closeSync13,
|
|
93088
|
-
existsSync as
|
|
94010
|
+
existsSync as existsSync31,
|
|
93089
94011
|
mkdirSync as mkdirSync20,
|
|
93090
94012
|
mkdtempSync,
|
|
93091
94013
|
openSync as openSync13,
|
|
@@ -93093,7 +94015,7 @@ import {
|
|
|
93093
94015
|
writeFileSync as writeFileSync16
|
|
93094
94016
|
} from "fs";
|
|
93095
94017
|
import { connect as netConnect } from "net";
|
|
93096
|
-
import { join as
|
|
94018
|
+
import { join as join45 } from "path";
|
|
93097
94019
|
function envDeltas(parentEnv, childEnv) {
|
|
93098
94020
|
const set = [];
|
|
93099
94021
|
const unset = [];
|
|
@@ -93159,9 +94081,9 @@ function planMagmuxWrap(input) {
|
|
|
93159
94081
|
const controlSocket = `/tmp/magmux-${id}.sock`;
|
|
93160
94082
|
const tmpRoot = input.tmpRoot ?? "/tmp";
|
|
93161
94083
|
mkdirSync20(tmpRoot, { recursive: true });
|
|
93162
|
-
const scriptDir = mkdtempSync(
|
|
94084
|
+
const scriptDir = mkdtempSync(join45(tmpRoot, "claudish-launch-"));
|
|
93163
94085
|
chmodSync3(scriptDir, 448);
|
|
93164
|
-
const scriptPath =
|
|
94086
|
+
const scriptPath = join45(scriptDir, "claude-launch.sh");
|
|
93165
94087
|
const parentEnv = input.parentEnv ?? process.env;
|
|
93166
94088
|
const deltas = envDeltas(parentEnv, input.childEnv);
|
|
93167
94089
|
const fd = openSync13(scriptPath, "wx", 384);
|
|
@@ -93201,7 +94123,7 @@ function planMagmuxWrap(input) {
|
|
|
93201
94123
|
rmSync11(scriptDir, { recursive: true, force: true });
|
|
93202
94124
|
} catch {}
|
|
93203
94125
|
try {
|
|
93204
|
-
if (
|
|
94126
|
+
if (existsSync31(controlSocket))
|
|
93205
94127
|
rmSync11(controlSocket, { force: true });
|
|
93206
94128
|
} catch {}
|
|
93207
94129
|
};
|
|
@@ -93220,7 +94142,7 @@ function planMagmuxWrap(input) {
|
|
|
93220
94142
|
let stopped = false;
|
|
93221
94143
|
const attempt = async () => {
|
|
93222
94144
|
for (let i = 0;i < 60 && !stopped; i++) {
|
|
93223
|
-
if (
|
|
94145
|
+
if (existsSync31(controlSocket)) {
|
|
93224
94146
|
try {
|
|
93225
94147
|
const s = await new Promise((resolve, reject) => {
|
|
93226
94148
|
const sock = netConnect(controlSocket);
|
|
@@ -93356,9 +94278,9 @@ var init_cache_ttl = __esm(() => {
|
|
|
93356
94278
|
});
|
|
93357
94279
|
|
|
93358
94280
|
// src/model-loader.ts
|
|
93359
|
-
import { existsSync as
|
|
93360
|
-
import { homedir as
|
|
93361
|
-
import { join as
|
|
94281
|
+
import { existsSync as existsSync32, readFileSync as readFileSync37 } from "fs";
|
|
94282
|
+
import { homedir as homedir36 } from "os";
|
|
94283
|
+
import { join as join46 } from "path";
|
|
93362
94284
|
function isRecommendationTier(value) {
|
|
93363
94285
|
return typeof value === "string" && RECOMMENDATION_TIER_INDEX.has(value);
|
|
93364
94286
|
}
|
|
@@ -93559,7 +94481,7 @@ function readProjectedRecommendationsDoc(value) {
|
|
|
93559
94481
|
};
|
|
93560
94482
|
}
|
|
93561
94483
|
function readRecommendedModelsCacheFile() {
|
|
93562
|
-
if (!
|
|
94484
|
+
if (!existsSync32(RECOMMENDED_MODELS_CACHE_PATH))
|
|
93563
94485
|
return null;
|
|
93564
94486
|
let parsed;
|
|
93565
94487
|
try {
|
|
@@ -93940,7 +94862,7 @@ var init_model_loader = __esm(() => {
|
|
|
93940
94862
|
{ recommendationTier: "subscription", title: "Subscription", quickPickEligible: true }
|
|
93941
94863
|
];
|
|
93942
94864
|
RECOMMENDATION_TIER_INDEX = new Map(RECOMMENDATION_SECTIONS.map((section, index) => [section.recommendationTier, index]));
|
|
93943
|
-
RECOMMENDED_MODELS_CACHE_PATH =
|
|
94865
|
+
RECOMMENDED_MODELS_CACHE_PATH = join46(homedir36(), ".claudish", "recommended-models-cache-v2.json");
|
|
93944
94866
|
RECOMMENDED_ROUTE_TIER_ORDER = {
|
|
93945
94867
|
native: 0,
|
|
93946
94868
|
general: 1,
|
|
@@ -95266,9 +96188,9 @@ var init_DiscoveryNotice = __esm(() => {
|
|
|
95266
96188
|
});
|
|
95267
96189
|
|
|
95268
96190
|
// src/providers/model-descriptions.ts
|
|
95269
|
-
import { existsSync as
|
|
95270
|
-
import { homedir as
|
|
95271
|
-
import { dirname as dirname18, join as
|
|
96191
|
+
import { existsSync as existsSync33, mkdirSync as mkdirSync21, readFileSync as readFileSync38, writeFileSync as writeFileSync17 } from "fs";
|
|
96192
|
+
import { homedir as homedir37 } from "os";
|
|
96193
|
+
import { dirname as dirname18, join as join47 } from "path";
|
|
95272
96194
|
function emptyDescriptionIndex() {
|
|
95273
96195
|
return EMPTY_INDEX;
|
|
95274
96196
|
}
|
|
@@ -95287,7 +96209,7 @@ function indexFrom(cache) {
|
|
|
95287
96209
|
};
|
|
95288
96210
|
}
|
|
95289
96211
|
function readCache(path) {
|
|
95290
|
-
if (!
|
|
96212
|
+
if (!existsSync33(path))
|
|
95291
96213
|
return null;
|
|
95292
96214
|
try {
|
|
95293
96215
|
const raw = JSON.parse(readFileSync38(path, "utf-8"));
|
|
@@ -95361,7 +96283,7 @@ var init_model_descriptions = __esm(() => {
|
|
|
95361
96283
|
init_logger();
|
|
95362
96284
|
init_model_loader();
|
|
95363
96285
|
init_cache_ttl();
|
|
95364
|
-
MODEL_DESCRIPTIONS_CACHE_PATH =
|
|
96286
|
+
MODEL_DESCRIPTIONS_CACHE_PATH = join47(homedir37(), ".claudish", "model-descriptions.json");
|
|
95365
96287
|
EMPTY_INDEX = { get: () => {
|
|
95366
96288
|
return;
|
|
95367
96289
|
}, size: 0 };
|
|
@@ -101608,30 +102530,30 @@ var init_branding = __esm(() => {
|
|
|
101608
102530
|
});
|
|
101609
102531
|
|
|
101610
102532
|
// src/update-checker.ts
|
|
101611
|
-
import { existsSync as
|
|
101612
|
-
import { homedir as
|
|
101613
|
-
import { join as
|
|
102533
|
+
import { existsSync as existsSync34, mkdirSync as mkdirSync22, readFileSync as readFileSync39, unlinkSync as unlinkSync9, writeFileSync as writeFileSync18 } from "fs";
|
|
102534
|
+
import { homedir as homedir38, platform as platform2, tmpdir } from "os";
|
|
102535
|
+
import { join as join48 } from "path";
|
|
101614
102536
|
function getCacheFilePath() {
|
|
101615
102537
|
let cacheDir;
|
|
101616
102538
|
if (isWindows) {
|
|
101617
|
-
const localAppData = process.env.LOCALAPPDATA ||
|
|
101618
|
-
cacheDir =
|
|
102539
|
+
const localAppData = process.env.LOCALAPPDATA || join48(homedir38(), "AppData", "Local");
|
|
102540
|
+
cacheDir = join48(localAppData, "claudish");
|
|
101619
102541
|
} else {
|
|
101620
|
-
cacheDir =
|
|
102542
|
+
cacheDir = join48(homedir38(), ".cache", "claudish");
|
|
101621
102543
|
}
|
|
101622
102544
|
try {
|
|
101623
|
-
if (!
|
|
102545
|
+
if (!existsSync34(cacheDir)) {
|
|
101624
102546
|
mkdirSync22(cacheDir, { recursive: true });
|
|
101625
102547
|
}
|
|
101626
|
-
return
|
|
102548
|
+
return join48(cacheDir, "update-check.json");
|
|
101627
102549
|
} catch {
|
|
101628
|
-
return
|
|
102550
|
+
return join48(tmpdir(), "claudish-update-check.json");
|
|
101629
102551
|
}
|
|
101630
102552
|
}
|
|
101631
102553
|
function readCache2() {
|
|
101632
102554
|
try {
|
|
101633
102555
|
const cachePath = getCacheFilePath();
|
|
101634
|
-
if (!
|
|
102556
|
+
if (!existsSync34(cachePath)) {
|
|
101635
102557
|
return null;
|
|
101636
102558
|
}
|
|
101637
102559
|
const data = JSON.parse(readFileSync39(cachePath, "utf-8"));
|
|
@@ -101657,7 +102579,7 @@ function isCacheValid(cache) {
|
|
|
101657
102579
|
function clearCache() {
|
|
101658
102580
|
try {
|
|
101659
102581
|
const cachePath = getCacheFilePath();
|
|
101660
|
-
if (
|
|
102582
|
+
if (existsSync34(cachePath)) {
|
|
101661
102583
|
unlinkSync9(cachePath);
|
|
101662
102584
|
}
|
|
101663
102585
|
} catch {}
|
|
@@ -106114,9 +107036,9 @@ var init_bundled_tagged_cache = __esm(() => {
|
|
|
106114
107036
|
});
|
|
106115
107037
|
|
|
106116
107038
|
// src/services/pricing-cache.ts
|
|
106117
|
-
import { existsSync as
|
|
106118
|
-
import { homedir as
|
|
106119
|
-
import { join as
|
|
107039
|
+
import { existsSync as existsSync35, readFileSync as readFileSync40, statSync as statSync16 } from "fs";
|
|
107040
|
+
import { homedir as homedir39 } from "os";
|
|
107041
|
+
import { join as join49 } from "path";
|
|
106120
107042
|
function prefixMatch(modelName) {
|
|
106121
107043
|
for (const [key, pricing] of pricingMap) {
|
|
106122
107044
|
if (modelName.startsWith(key))
|
|
@@ -106166,7 +107088,7 @@ async function warmPricingCache() {
|
|
|
106166
107088
|
}
|
|
106167
107089
|
function loadDiskCache() {
|
|
106168
107090
|
try {
|
|
106169
|
-
if (!
|
|
107091
|
+
if (!existsSync35(CACHE_FILE))
|
|
106170
107092
|
return false;
|
|
106171
107093
|
const stat = statSync16(CACHE_FILE);
|
|
106172
107094
|
const age = Date.now() - stat.mtimeMs;
|
|
@@ -106188,8 +107110,8 @@ var init_pricing_cache = __esm(() => {
|
|
|
106188
107110
|
init_catalog_client();
|
|
106189
107111
|
init_catalog_route_bindings();
|
|
106190
107112
|
pricingMap = new Map;
|
|
106191
|
-
CACHE_DIR =
|
|
106192
|
-
CACHE_FILE =
|
|
107113
|
+
CACHE_DIR = join49(homedir39(), ".claudish");
|
|
107114
|
+
CACHE_FILE = join49(CACHE_DIR, "pricing-cache.json");
|
|
106193
107115
|
CACHE_TTL_MS5 = 24 * 60 * 60 * 1000;
|
|
106194
107116
|
});
|
|
106195
107117
|
|
|
@@ -108564,7 +109486,7 @@ var init_response_seam = __esm(() => {
|
|
|
108564
109486
|
|
|
108565
109487
|
// src/proxy-server.ts
|
|
108566
109488
|
import { appendFileSync as appendFileSync6, mkdirSync as mkdirSync23 } from "fs";
|
|
108567
|
-
import { join as
|
|
109489
|
+
import { join as join50 } from "path";
|
|
108568
109490
|
function isTerminalRoutingFailure(e) {
|
|
108569
109491
|
return e instanceof RoutingError;
|
|
108570
109492
|
}
|
|
@@ -108572,7 +109494,7 @@ function maybeCaptureClassifierRequest(c, body) {
|
|
|
108572
109494
|
if (!process.env.CLAUDISH_CLASSIFIER_DEBUG)
|
|
108573
109495
|
return;
|
|
108574
109496
|
try {
|
|
108575
|
-
const dir =
|
|
109497
|
+
const dir = join50(process.cwd(), "logs");
|
|
108576
109498
|
if (!classifierCaptureDirReady) {
|
|
108577
109499
|
mkdirSync23(dir, { recursive: true });
|
|
108578
109500
|
classifierCaptureDirReady = true;
|
|
@@ -108597,7 +109519,7 @@ function maybeCaptureClassifierRequest(c, body) {
|
|
|
108597
109519
|
"x-api-key": c.req.header("x-api-key") ? "<present>" : null
|
|
108598
109520
|
}
|
|
108599
109521
|
};
|
|
108600
|
-
appendFileSync6(
|
|
109522
|
+
appendFileSync6(join50(dir, "classifier-capture.jsonl"), `${JSON.stringify(record)}
|
|
108601
109523
|
`);
|
|
108602
109524
|
} catch {}
|
|
108603
109525
|
}
|
|
@@ -109204,21 +110126,21 @@ var init_proxy_server = __esm(() => {
|
|
|
109204
110126
|
// src/cli.ts
|
|
109205
110127
|
import {
|
|
109206
110128
|
copyFileSync as copyFileSync2,
|
|
109207
|
-
existsSync as
|
|
110129
|
+
existsSync as existsSync36,
|
|
109208
110130
|
mkdirSync as mkdirSync24,
|
|
109209
110131
|
readFileSync as readFileSync41,
|
|
109210
110132
|
readdirSync as readdirSync8,
|
|
109211
110133
|
unlinkSync as unlinkSync10
|
|
109212
110134
|
} from "fs";
|
|
109213
|
-
import { homedir as
|
|
109214
|
-
import { dirname as dirname19, join as
|
|
110135
|
+
import { homedir as homedir40 } from "os";
|
|
110136
|
+
import { dirname as dirname19, join as join51 } from "path";
|
|
109215
110137
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
109216
110138
|
function getVersion3() {
|
|
109217
110139
|
return VERSION;
|
|
109218
110140
|
}
|
|
109219
110141
|
function clearAllModelCaches() {
|
|
109220
|
-
const cacheDir =
|
|
109221
|
-
if (!
|
|
110142
|
+
const cacheDir = join51(homedir40(), ".claudish");
|
|
110143
|
+
if (!existsSync36(cacheDir))
|
|
109222
110144
|
return;
|
|
109223
110145
|
const cachePatterns = ["pricing-cache.json", "recommended-models-cache-v2.json"];
|
|
109224
110146
|
let cleared = 0;
|
|
@@ -109226,7 +110148,7 @@ function clearAllModelCaches() {
|
|
|
109226
110148
|
const files = readdirSync8(cacheDir);
|
|
109227
110149
|
for (const file of files) {
|
|
109228
110150
|
if (cachePatterns.includes(file)) {
|
|
109229
|
-
unlinkSync10(
|
|
110151
|
+
unlinkSync10(join51(cacheDir, file));
|
|
109230
110152
|
cleared++;
|
|
109231
110153
|
}
|
|
109232
110154
|
}
|
|
@@ -110870,7 +111792,7 @@ ${h("MORE INFO")}
|
|
|
110870
111792
|
}
|
|
110871
111793
|
function printAIAgentGuide() {
|
|
110872
111794
|
try {
|
|
110873
|
-
const guidePath =
|
|
111795
|
+
const guidePath = join51(__dirname2, "../AI_AGENT_GUIDE.md");
|
|
110874
111796
|
const guideContent = readFileSync41(guidePath, "utf-8");
|
|
110875
111797
|
console.log(guideContent);
|
|
110876
111798
|
} catch (error) {
|
|
@@ -110887,19 +111809,19 @@ async function initializeClaudishSkill() {
|
|
|
110887
111809
|
console.log(`\uD83D\uDD27 Initializing Claudish skill in current project...
|
|
110888
111810
|
`);
|
|
110889
111811
|
const cwd = process.cwd();
|
|
110890
|
-
const claudeDir =
|
|
110891
|
-
const skillsDir =
|
|
110892
|
-
const claudishSkillDir =
|
|
110893
|
-
const skillFile =
|
|
110894
|
-
if (
|
|
111812
|
+
const claudeDir = join51(cwd, ".claude");
|
|
111813
|
+
const skillsDir = join51(claudeDir, "skills");
|
|
111814
|
+
const claudishSkillDir = join51(skillsDir, "claudish-usage");
|
|
111815
|
+
const skillFile = join51(claudishSkillDir, "SKILL.md");
|
|
111816
|
+
if (existsSync36(skillFile)) {
|
|
110895
111817
|
console.log("\u2705 Claudish skill already installed at:");
|
|
110896
111818
|
console.log(` ${skillFile}
|
|
110897
111819
|
`);
|
|
110898
111820
|
console.log("\uD83D\uDCA1 To reinstall, delete the file and run 'claudish --init' again.");
|
|
110899
111821
|
return;
|
|
110900
111822
|
}
|
|
110901
|
-
const sourceSkillPath =
|
|
110902
|
-
if (!
|
|
111823
|
+
const sourceSkillPath = join51(__dirname2, "../skills/claudish-usage/SKILL.md");
|
|
111824
|
+
if (!existsSync36(sourceSkillPath)) {
|
|
110903
111825
|
console.error("\u274C Error: Claudish skill file not found in installation.");
|
|
110904
111826
|
console.error(` Expected at: ${sourceSkillPath}`);
|
|
110905
111827
|
console.error(`
|
|
@@ -110908,15 +111830,15 @@ async function initializeClaudishSkill() {
|
|
|
110908
111830
|
process.exit(1);
|
|
110909
111831
|
}
|
|
110910
111832
|
try {
|
|
110911
|
-
if (!
|
|
111833
|
+
if (!existsSync36(claudeDir)) {
|
|
110912
111834
|
mkdirSync24(claudeDir, { recursive: true });
|
|
110913
111835
|
console.log("\uD83D\uDCC1 Created .claude/ directory");
|
|
110914
111836
|
}
|
|
110915
|
-
if (!
|
|
111837
|
+
if (!existsSync36(skillsDir)) {
|
|
110916
111838
|
mkdirSync24(skillsDir, { recursive: true });
|
|
110917
111839
|
console.log("\uD83D\uDCC1 Created .claude/skills/ directory");
|
|
110918
111840
|
}
|
|
110919
|
-
if (!
|
|
111841
|
+
if (!existsSync36(claudishSkillDir)) {
|
|
110920
111842
|
mkdirSync24(claudishSkillDir, { recursive: true });
|
|
110921
111843
|
console.log("\uD83D\uDCC1 Created .claude/skills/claudish-usage/ directory");
|
|
110922
111844
|
}
|
|
@@ -111132,7 +112054,7 @@ var DEFAULT_PANE_COLS = 160, DEFAULT_PANE_ROWS = 50, MIN_PANE_COLS = 40, MAX_PAN
|
|
|
111132
112054
|
// src/pane/process-identity.ts
|
|
111133
112055
|
import { execFile as execFile4, execFileSync as execFileSync3 } from "child_process";
|
|
111134
112056
|
import { lstatSync as lstatSync6 } from "fs";
|
|
111135
|
-
import { basename as
|
|
112057
|
+
import { basename as basename5, dirname as dirname20, isAbsolute as isAbsolute2, join as join52, normalize } from "path";
|
|
111136
112058
|
function collapse2(s) {
|
|
111137
112059
|
return s.trim().replace(/\s+/g, " ");
|
|
111138
112060
|
}
|
|
@@ -111375,7 +112297,7 @@ function parseGroupFile(text) {
|
|
|
111375
112297
|
return withEscaped(pgid, members, escaped);
|
|
111376
112298
|
}
|
|
111377
112299
|
function isLaunchDirPath(root, p) {
|
|
111378
|
-
if (dirname20(p) !== root || !LAUNCH_DIR_RE.test(
|
|
112300
|
+
if (dirname20(p) !== root || !LAUNCH_DIR_RE.test(basename5(p)))
|
|
111379
112301
|
return false;
|
|
111380
112302
|
try {
|
|
111381
112303
|
const st = lstatSync6(p);
|
|
@@ -111388,30 +112310,30 @@ function isValidPaneId(id) {
|
|
|
111388
112310
|
return PANE_ID_RE.test(id) && !/^\d+$/.test(id);
|
|
111389
112311
|
}
|
|
111390
112312
|
function sockPathOf(root, paneId) {
|
|
111391
|
-
return
|
|
112313
|
+
return join52(root, `magmux-${paneId}.sock`);
|
|
111392
112314
|
}
|
|
111393
112315
|
function viewSockPathOf(root, paneId) {
|
|
111394
|
-
return
|
|
112316
|
+
return join52(root, `magmux-${paneId}.view`);
|
|
111395
112317
|
}
|
|
111396
112318
|
function recordPathOf(root, paneId) {
|
|
111397
|
-
return
|
|
112319
|
+
return join52(root, "panes", `${paneId}.json`);
|
|
111398
112320
|
}
|
|
111399
112321
|
function isPaneSockPath(root, p, paneId) {
|
|
111400
|
-
return isValidPaneId(paneId) && dirname20(p) === root &&
|
|
112322
|
+
return isValidPaneId(paneId) && dirname20(p) === root && basename5(p) === `magmux-${paneId}.sock`;
|
|
111401
112323
|
}
|
|
111402
112324
|
function isPaneViewSockPath(root, p, paneId) {
|
|
111403
|
-
return isValidPaneId(paneId) && dirname20(p) === root &&
|
|
112325
|
+
return isValidPaneId(paneId) && dirname20(p) === root && basename5(p) === `magmux-${paneId}.view`;
|
|
111404
112326
|
}
|
|
111405
112327
|
function isPaneRecordPath(root, p, paneId) {
|
|
111406
|
-
return isValidPaneId(paneId) && dirname20(p) ===
|
|
112328
|
+
return isValidPaneId(paneId) && dirname20(p) === join52(root, "panes") && basename5(p) === `${paneId}.json`;
|
|
111407
112329
|
}
|
|
111408
112330
|
function isForkRecordPath(projectsRoot, p, uuid) {
|
|
111409
112331
|
if (!isAbsolute2(projectsRoot) || normalize(projectsRoot) !== projectsRoot)
|
|
111410
112332
|
return false;
|
|
111411
|
-
if (
|
|
112333
|
+
if (basename5(projectsRoot) !== "projects" || !FORK_UUID_RE.test(uuid))
|
|
111412
112334
|
return false;
|
|
111413
112335
|
const dir = dirname20(p);
|
|
111414
|
-
return dirname20(dir) === projectsRoot && PROJECT_SLUG_RE.test(
|
|
112336
|
+
return dirname20(dir) === projectsRoot && PROJECT_SLUG_RE.test(basename5(dir)) && basename5(p) === `${uuid}.jsonl`;
|
|
111415
112337
|
}
|
|
111416
112338
|
function watcherArgv(a) {
|
|
111417
112339
|
const fork = a.fork ? [a.fork.projectsRoot, a.fork.path, a.fork.removeProjectDir ? "1" : "0"] : [];
|
|
@@ -111547,7 +112469,7 @@ import {
|
|
|
111547
112469
|
statSync as statSync17,
|
|
111548
112470
|
writeFileSync as writeFileSync19
|
|
111549
112471
|
} from "fs";
|
|
111550
|
-
import { join as
|
|
112472
|
+
import { join as join53, resolve as resolve5 } from "path";
|
|
111551
112473
|
function uid() {
|
|
111552
112474
|
return typeof process.getuid === "function" ? process.getuid() : 0;
|
|
111553
112475
|
}
|
|
@@ -111565,7 +112487,7 @@ function assertPrivateDir(p) {
|
|
|
111565
112487
|
throw new PaneRootError(`pane socket root ${p} has mode ${(st.mode & 511).toString(8)}; it must be 0700`);
|
|
111566
112488
|
}
|
|
111567
112489
|
function ensurePrivateSubdir(root, name) {
|
|
111568
|
-
const dir =
|
|
112490
|
+
const dir = join53(root, name);
|
|
111569
112491
|
try {
|
|
111570
112492
|
mkdirSync25(dir, { mode: 448 });
|
|
111571
112493
|
} catch (e) {
|
|
@@ -111586,7 +112508,7 @@ function ensureSockRoot(given = sockRootFor()) {
|
|
|
111586
112508
|
throw e;
|
|
111587
112509
|
}
|
|
111588
112510
|
assertPrivateDir(root);
|
|
111589
|
-
const panes =
|
|
112511
|
+
const panes = join53(root, "panes");
|
|
111590
112512
|
try {
|
|
111591
112513
|
mkdirSync25(panes, { mode: 448 });
|
|
111592
112514
|
} catch (e) {
|
|
@@ -111640,7 +112562,7 @@ function buildPaneEnv(input) {
|
|
|
111640
112562
|
if ((input.platform ?? process.platform) === "linux" && entryBytes > LINUX_ENV_STRING_LIMIT)
|
|
111641
112563
|
throw new PaneEnvTooLargeError(`pane environment snapshot is ${entryBytes} bytes, over Linux's 131072-byte limit per variable`);
|
|
111642
112564
|
env[ENV.CLAUDISH_PANE_ENV] = json;
|
|
111643
|
-
env.SHELL =
|
|
112565
|
+
env.SHELL = join53(input.ctlDir, "sh-shim");
|
|
111644
112566
|
return { magmuxEnv: env };
|
|
111645
112567
|
}
|
|
111646
112568
|
function inheritedReplayEnv(parentEnv) {
|
|
@@ -111659,7 +112581,7 @@ function buildReplayEnv(input) {
|
|
|
111659
112581
|
const env = inheritedReplayEnv(input.parentEnv);
|
|
111660
112582
|
if (input.configDirOverride)
|
|
111661
112583
|
env.CLAUDE_CONFIG_DIR = input.configDirOverride;
|
|
111662
|
-
env.SHELL =
|
|
112584
|
+
env.SHELL = join53(input.ctlDir, "sh-shim");
|
|
111663
112585
|
env[ENV.CLAUDISH_PANE_CHILD] = "1";
|
|
111664
112586
|
env.CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC = "1";
|
|
111665
112587
|
env.CLAUDE_CODE_DISABLE_OFFICIAL_MARKETPLACE_AUTOINSTALL = "1";
|
|
@@ -111692,7 +112614,7 @@ function replaySettingsJson(statusLine) {
|
|
|
111692
112614
|
}
|
|
111693
112615
|
function readUserStatusLine(configDir) {
|
|
111694
112616
|
try {
|
|
111695
|
-
const path =
|
|
112617
|
+
const path = join53(configDir, "settings.json");
|
|
111696
112618
|
if (statSync17(path).size > MAX_USER_SETTINGS_BYTES)
|
|
111697
112619
|
return null;
|
|
111698
112620
|
const v = JSON.parse(readFileSync42(path, "utf8"))?.statusLine;
|
|
@@ -111970,21 +112892,21 @@ export SHELL=${shq2(realShell)}
|
|
|
111970
112892
|
${launcherScript(cwd, launch, argv)}`;
|
|
111971
112893
|
}
|
|
111972
112894
|
function paneCommand(ctlDir) {
|
|
111973
|
-
const cmd = `. ${shq2(
|
|
112895
|
+
const cmd = `. ${shq2(join53(ctlDir, "pane-launch.sh"))}`;
|
|
111974
112896
|
if (/claude /.test(cmd) || /claude$/.test(cmd) || /(^|\/)claude['"]?$/.test(cmd))
|
|
111975
112897
|
throw new Error(`pane command would attach magmux's Claude Code controller: ${cmd}`);
|
|
111976
112898
|
return cmd;
|
|
111977
112899
|
}
|
|
111978
112900
|
function createLaunchDirs(root) {
|
|
111979
|
-
const ctlDir = mkdtempSync2(
|
|
112901
|
+
const ctlDir = mkdtempSync2(join53(root, "launch-"));
|
|
111980
112902
|
chmodSync4(ctlDir, 448);
|
|
111981
|
-
const turnDir = mkdtempSync2(
|
|
112903
|
+
const turnDir = mkdtempSync2(join53(root, "launch-"));
|
|
111982
112904
|
chmodSync4(turnDir, 448);
|
|
111983
112905
|
return { ctlDir, turnDir };
|
|
111984
112906
|
}
|
|
111985
112907
|
function writeLauncherFiles(ctlDir, script) {
|
|
111986
|
-
writeFileSync19(
|
|
111987
|
-
writeFileSync19(
|
|
112908
|
+
writeFileSync19(join53(ctlDir, "pane-launch.sh"), script, { mode: 384, flag: "wx" });
|
|
112909
|
+
writeFileSync19(join53(ctlDir, "sh-shim"), SHELL_SHIM, { mode: 448, flag: "wx" });
|
|
111988
112910
|
}
|
|
111989
112911
|
function spawnPaneWatcher(args) {
|
|
111990
112912
|
const proc = spawn2("/bin/sh", watcherArgv(args), {
|
|
@@ -112346,14 +113268,14 @@ var init_process_tree = __esm(() => {
|
|
|
112346
113268
|
var UI_LEASE_MS = 1e4, FRAME_TICK_MS = 1000;
|
|
112347
113269
|
|
|
112348
113270
|
// src/recovery/magmux-ui.ts
|
|
112349
|
-
import { existsSync as
|
|
113271
|
+
import { existsSync as existsSync37 } from "fs";
|
|
112350
113272
|
import { connect as netConnect2 } from "net";
|
|
112351
113273
|
function resolveControlEndpoint() {
|
|
112352
|
-
if (explicitControlSock &&
|
|
113274
|
+
if (explicitControlSock && existsSync37(explicitControlSock)) {
|
|
112353
113275
|
return { sock: explicitControlSock, wrapped: true };
|
|
112354
113276
|
}
|
|
112355
113277
|
const ambient = process.env.MAGMUX_SOCK;
|
|
112356
|
-
if (ambient &&
|
|
113278
|
+
if (ambient && existsSync37(ambient))
|
|
112357
113279
|
return { sock: ambient, wrapped: false };
|
|
112358
113280
|
return null;
|
|
112359
113281
|
}
|
|
@@ -112767,7 +113689,7 @@ import { randomUUID as randomUUID7 } from "crypto";
|
|
|
112767
113689
|
import {
|
|
112768
113690
|
chmodSync as chmodSync5,
|
|
112769
113691
|
closeSync as closeSync14,
|
|
112770
|
-
existsSync as
|
|
113692
|
+
existsSync as existsSync38,
|
|
112771
113693
|
mkdirSync as mkdirSync26,
|
|
112772
113694
|
mkdtempSync as mkdtempSync3,
|
|
112773
113695
|
openSync as openSync14,
|
|
@@ -112778,8 +113700,8 @@ import {
|
|
|
112778
113700
|
unlinkSync as unlinkSync11,
|
|
112779
113701
|
writeFileSync as writeFileSync20
|
|
112780
113702
|
} from "fs";
|
|
112781
|
-
import { homedir as
|
|
112782
|
-
import { dirname as dirname21, join as
|
|
113703
|
+
import { homedir as homedir41, tmpdir as tmpdir2 } from "os";
|
|
113704
|
+
import { dirname as dirname21, join as join54, resolve as resolve6 } from "path";
|
|
112783
113705
|
import { isatty } from "tty";
|
|
112784
113706
|
function releaseTerminalIsolation() {
|
|
112785
113707
|
if (!restoreTerminal)
|
|
@@ -113059,14 +113981,14 @@ function readableClaudeSettingsLayers(config, env, deps) {
|
|
|
113059
113981
|
}
|
|
113060
113982
|
function claudeSettingsLayers(claudeArgs, env, deps, scope) {
|
|
113061
113983
|
const readFile = deps.readFile ?? ((path) => readFileSync43(path, "utf-8"));
|
|
113062
|
-
const home = deps.home ?? (env.HOME ? env.HOME :
|
|
113984
|
+
const home = deps.home ?? (env.HOME ? env.HOME : homedir41());
|
|
113063
113985
|
const cwd = deps.cwd ?? process.cwd();
|
|
113064
113986
|
const enabled = enabledSettingSources(claudeArgs);
|
|
113065
113987
|
const on = (source) => enabled === null || enabled.has(source);
|
|
113066
113988
|
const files = [
|
|
113067
113989
|
[managedSettingsPath(), "managed"],
|
|
113068
113990
|
...on("user") ? [[userSettingsFile(env.CLAUDE_CONFIG_DIR, home, cwd), "user"]] : [],
|
|
113069
|
-
...on("project") ? [[
|
|
113991
|
+
...on("project") ? [[join54(cwd, ".claude", "settings.json"), "project"]] : [],
|
|
113070
113992
|
...on("local") ? localSettingsFiles(cwd, readFile, deps.pathKind ?? statPathKind) : []
|
|
113071
113993
|
];
|
|
113072
113994
|
const layers = [];
|
|
@@ -113094,19 +114016,19 @@ function claudeSettingsLayers(claudeArgs, env, deps, scope) {
|
|
|
113094
114016
|
return layers;
|
|
113095
114017
|
}
|
|
113096
114018
|
function userSettingsFile(configDir, home, cwd) {
|
|
113097
|
-
return
|
|
114019
|
+
return join54(claudeCodeConfigDir({ CLAUDE_CONFIG_DIR: configDir, HOME: home }, cwd), "settings.json");
|
|
113098
114020
|
}
|
|
113099
114021
|
function localSettingsFiles(cwd, readFile, pathKind) {
|
|
113100
|
-
const cwdFile =
|
|
114022
|
+
const cwdFile = join54(cwd, ".claude", "settings.local.json");
|
|
113101
114023
|
const root = mainCheckoutRoot(cwd, readFile, pathKind);
|
|
113102
|
-
const rootFile = root === undefined ? undefined :
|
|
114024
|
+
const rootFile = root === undefined ? undefined : join54(root, ".claude", "settings.local.json");
|
|
113103
114025
|
const files = rootFile && rootFile !== cwdFile ? [rootFile, cwdFile] : [cwdFile];
|
|
113104
114026
|
return files.map((file) => [file, "local"]);
|
|
113105
114027
|
}
|
|
113106
114028
|
function mainCheckoutRoot(cwd, readFile, pathKind) {
|
|
113107
114029
|
let dir = resolve6(cwd);
|
|
113108
114030
|
for (;; ) {
|
|
113109
|
-
const entry =
|
|
114031
|
+
const entry = join54(dir, ".git");
|
|
113110
114032
|
const kind = pathKind(entry);
|
|
113111
114033
|
if (kind === "dir")
|
|
113112
114034
|
return dir;
|
|
@@ -113116,7 +114038,7 @@ function mainCheckoutRoot(cwd, readFile, pathKind) {
|
|
|
113116
114038
|
return dir;
|
|
113117
114039
|
let common;
|
|
113118
114040
|
try {
|
|
113119
|
-
common = readFile(
|
|
114041
|
+
common = readFile(join54(gitDir, "commondir")).trim();
|
|
113120
114042
|
} catch {
|
|
113121
114043
|
return dir;
|
|
113122
114044
|
}
|
|
@@ -113258,7 +114180,7 @@ function readSettingsSource(source, readFile) {
|
|
|
113258
114180
|
}
|
|
113259
114181
|
function managedSettingsPath() {
|
|
113260
114182
|
if (isWindows2()) {
|
|
113261
|
-
return
|
|
114183
|
+
return join54(process.env.PROGRAMDATA || "C:\\ProgramData", "ClaudeCode", "managed-settings.json");
|
|
113262
114184
|
}
|
|
113263
114185
|
if (process.platform === "darwin") {
|
|
113264
114186
|
return "/Library/Application Support/ClaudeCode/managed-settings.json";
|
|
@@ -113279,8 +114201,8 @@ function isWindows2() {
|
|
|
113279
114201
|
}
|
|
113280
114202
|
function createStatusLineScript(tokenFilePath) {
|
|
113281
114203
|
const homeDir = process.env.HOME || process.env.USERPROFILE || tmpdir2();
|
|
113282
|
-
const claudishDir =
|
|
113283
|
-
const scriptPath =
|
|
114204
|
+
const claudishDir = join54(homeDir, ".claudish");
|
|
114205
|
+
const scriptPath = join54(claudishDir, `status-${process.pid}-${Date.now()}.js`);
|
|
113284
114206
|
const escapedTokenPath = tokenFilePath.replace(/\\/g, "\\\\");
|
|
113285
114207
|
const light = getThemeMode() === "light";
|
|
113286
114208
|
const cyanCode = light ? "38;2;14;116;144" : "96";
|
|
@@ -113486,7 +114408,7 @@ function cleanupStaleTokenFiles(dir, now = Date.now(), maxAgeMs = STALE_TOKEN_FI
|
|
|
113486
114408
|
if (!name.startsWith("tokens-") || !name.endsWith(".json"))
|
|
113487
114409
|
continue;
|
|
113488
114410
|
scanned++;
|
|
113489
|
-
const full =
|
|
114411
|
+
const full = join54(dir, name);
|
|
113490
114412
|
try {
|
|
113491
114413
|
if (statSync18(full).mtimeMs >= cutoff)
|
|
113492
114414
|
continue;
|
|
@@ -113559,11 +114481,11 @@ function buildChainedStatusCommand(userCommand, claudishBody, claudishSegment) {
|
|
|
113559
114481
|
}
|
|
113560
114482
|
function createTempSettingsFile(_modelDisplay, port, proxyAuthMode, userStatusLineCommand, modelPicker) {
|
|
113561
114483
|
const homeDir = process.env.HOME || process.env.USERPROFILE || tmpdir2();
|
|
113562
|
-
const claudishDir =
|
|
114484
|
+
const claudishDir = join54(homeDir, ".claudish");
|
|
113563
114485
|
try {
|
|
113564
114486
|
mkdirSync26(claudishDir, { recursive: true });
|
|
113565
114487
|
} catch {}
|
|
113566
|
-
const tempPath =
|
|
114488
|
+
const tempPath = join54(claudishDir, `settings-${process.pid}-${Date.now()}.json`);
|
|
113567
114489
|
const assignedFile = assignedTokenFile(process.env) !== null;
|
|
113568
114490
|
const tokenFilePath = resolveTokenFilePath(port);
|
|
113569
114491
|
cleanupStaleTokenFiles(claudishDir);
|
|
@@ -114097,8 +115019,8 @@ async function runClaudeWithProxy(config, proxyUrl, onCleanup, hooks = {}) {
|
|
|
114097
115019
|
console.error("Install it from: https://claude.com/claude-code");
|
|
114098
115020
|
console.error(`
|
|
114099
115021
|
Or set CLAUDE_PATH to your custom installation:`);
|
|
114100
|
-
const home =
|
|
114101
|
-
const localPath = isWindows2() ?
|
|
115022
|
+
const home = homedir41();
|
|
115023
|
+
const localPath = isWindows2() ? join54(home, ".claude", "local", "claude.exe") : join54(home, ".claude", "local", "claude");
|
|
114102
115024
|
console.error(` export CLAUDE_PATH=${localPath}`);
|
|
114103
115025
|
process.exit(1);
|
|
114104
115026
|
}
|
|
@@ -114133,7 +115055,7 @@ Or set CLAUDE_PATH to your custom installation:`);
|
|
|
114133
115055
|
let driverLaunch = null;
|
|
114134
115056
|
if (surfaces.driver) {
|
|
114135
115057
|
const minted = sessionFlags.sessionId || sessionFlags.resumes ? null : randomUUID7();
|
|
114136
|
-
const turnDir = mkdtempSync3(
|
|
115058
|
+
const turnDir = mkdtempSync3(join54(tmpdir2(), "claudish-turns-"));
|
|
114137
115059
|
chmodSync5(turnDir, 448);
|
|
114138
115060
|
claudeArgs.unshift(...driverLeadingArgs({ mintedSessionId: minted, turnDir }));
|
|
114139
115061
|
const sink = new InProcessSink;
|
|
@@ -114343,23 +115265,23 @@ function setupSignalHandlers(tempSettingsPath, quiet, onCleanup, onDeadline) {
|
|
|
114343
115265
|
async function findClaudeBinary(env = process.env) {
|
|
114344
115266
|
const isWindows = process.platform === "win32";
|
|
114345
115267
|
if (env.CLAUDE_PATH) {
|
|
114346
|
-
if (
|
|
115268
|
+
if (existsSync38(env.CLAUDE_PATH)) {
|
|
114347
115269
|
return env.CLAUDE_PATH;
|
|
114348
115270
|
}
|
|
114349
115271
|
}
|
|
114350
|
-
const home =
|
|
114351
|
-
const localPath = isWindows ?
|
|
114352
|
-
if (
|
|
115272
|
+
const home = homedir41();
|
|
115273
|
+
const localPath = isWindows ? join54(home, ".claude", "local", "claude.exe") : join54(home, ".claude", "local", "claude");
|
|
115274
|
+
if (existsSync38(localPath)) {
|
|
114353
115275
|
return localPath;
|
|
114354
115276
|
}
|
|
114355
115277
|
if (isWindows) {
|
|
114356
115278
|
const windowsPaths = [
|
|
114357
|
-
|
|
114358
|
-
|
|
114359
|
-
|
|
115279
|
+
join54(home, "AppData", "Roaming", "npm", "claude.cmd"),
|
|
115280
|
+
join54(home, ".npm-global", "claude.cmd"),
|
|
115281
|
+
join54(home, "node_modules", ".bin", "claude.cmd")
|
|
114360
115282
|
];
|
|
114361
115283
|
for (const path of windowsPaths) {
|
|
114362
|
-
if (
|
|
115284
|
+
if (existsSync38(path)) {
|
|
114363
115285
|
return path;
|
|
114364
115286
|
}
|
|
114365
115287
|
}
|
|
@@ -114367,14 +115289,14 @@ async function findClaudeBinary(env = process.env) {
|
|
|
114367
115289
|
const commonPaths = [
|
|
114368
115290
|
"/usr/local/bin/claude",
|
|
114369
115291
|
"/opt/homebrew/bin/claude",
|
|
114370
|
-
|
|
114371
|
-
|
|
114372
|
-
|
|
115292
|
+
join54(home, ".npm-global/bin/claude"),
|
|
115293
|
+
join54(home, ".local/bin/claude"),
|
|
115294
|
+
join54(home, "node_modules/.bin/claude"),
|
|
114373
115295
|
"/data/data/com.termux/files/usr/bin/claude",
|
|
114374
|
-
|
|
115296
|
+
join54(home, "../usr/bin/claude")
|
|
114375
115297
|
];
|
|
114376
115298
|
for (const path of commonPaths) {
|
|
114377
|
-
if (
|
|
115299
|
+
if (existsSync38(path)) {
|
|
114378
115300
|
return path;
|
|
114379
115301
|
}
|
|
114380
115302
|
}
|
|
@@ -114686,16 +115608,16 @@ var init_slot_row = __esm(() => {
|
|
|
114686
115608
|
});
|
|
114687
115609
|
|
|
114688
115610
|
// src/team-stats.ts
|
|
114689
|
-
import { existsSync as
|
|
114690
|
-
import { join as
|
|
115611
|
+
import { existsSync as existsSync39, readFileSync as readFileSync44, writeFileSync as writeFileSync21 } from "fs";
|
|
115612
|
+
import { join as join55 } from "path";
|
|
114691
115613
|
function statsDir(sessionPath) {
|
|
114692
|
-
return
|
|
115614
|
+
return join55(sessionPath, "stats");
|
|
114693
115615
|
}
|
|
114694
115616
|
function tokenFileFor(sessionPath, anonId) {
|
|
114695
|
-
return
|
|
115617
|
+
return join55(statsDir(sessionPath), `${anonId}.json`);
|
|
114696
115618
|
}
|
|
114697
115619
|
function readTokenStatsAt(path) {
|
|
114698
|
-
if (!
|
|
115620
|
+
if (!existsSync39(path))
|
|
114699
115621
|
return null;
|
|
114700
115622
|
try {
|
|
114701
115623
|
return JSON.parse(readFileSync44(path, "utf-8"));
|
|
@@ -114855,7 +115777,7 @@ ${segs.join(" \xB7 ")}`;
|
|
|
114855
115777
|
}
|
|
114856
115778
|
function writeStatusFile(sessionPath, manifest, status, opts) {
|
|
114857
115779
|
try {
|
|
114858
|
-
writeFileSync21(
|
|
115780
|
+
writeFileSync21(join55(sessionPath, "status.txt"), `${renderTeamStats(sessionPath, manifest, status, opts)}
|
|
114859
115781
|
`, "utf-8");
|
|
114860
115782
|
} catch {}
|
|
114861
115783
|
}
|
|
@@ -114939,15 +115861,15 @@ var init_accounting = __esm(() => {
|
|
|
114939
115861
|
// src/view/endpoints.ts
|
|
114940
115862
|
import { chmodSync as chmodSync6, readdirSync as readdirSync10, rmSync as rmSync13, rmdirSync as rmdirSync2 } from "fs";
|
|
114941
115863
|
import { createServer as createServer3 } from "net";
|
|
114942
|
-
import { join as
|
|
115864
|
+
import { join as join56 } from "path";
|
|
114943
115865
|
function endpointNameOf(pid = process.pid, start36 = OWNER_START36) {
|
|
114944
115866
|
return `c${pid}-${start36}.sock`;
|
|
114945
115867
|
}
|
|
114946
115868
|
function endpointsDirOf(root) {
|
|
114947
|
-
return
|
|
115869
|
+
return join56(root, ENDPOINTS_DIR);
|
|
114948
115870
|
}
|
|
114949
115871
|
function endpointPathOf(root, name) {
|
|
114950
|
-
return
|
|
115872
|
+
return join56(endpointsDirOf(root), name);
|
|
114951
115873
|
}
|
|
114952
115874
|
function ownerOfEndpointName(name) {
|
|
114953
115875
|
const m = ENDPOINT_NAME_RE.exec(name);
|
|
@@ -115229,9 +116151,9 @@ var init_prompt_summary = __esm(() => {
|
|
|
115229
116151
|
|
|
115230
116152
|
// src/view/token-watch.ts
|
|
115231
116153
|
import { watch as watch2 } from "fs";
|
|
115232
|
-
import { basename as
|
|
116154
|
+
import { basename as basename6, dirname as dirname22 } from "path";
|
|
115233
116155
|
function watchTokenFile(path, onChange) {
|
|
115234
|
-
const name =
|
|
116156
|
+
const name = basename6(path);
|
|
115235
116157
|
let watcher;
|
|
115236
116158
|
try {
|
|
115237
116159
|
watcher = watch2(dirname22(path), (_event, changed) => {
|
|
@@ -115380,7 +116302,7 @@ var init_view_claims = __esm(() => {
|
|
|
115380
116302
|
// src/team-orchestrator.ts
|
|
115381
116303
|
import { randomBytes as randomBytes17, randomUUID as randomUUID8 } from "crypto";
|
|
115382
116304
|
import {
|
|
115383
|
-
existsSync as
|
|
116305
|
+
existsSync as existsSync40,
|
|
115384
116306
|
lstatSync as lstatSync8,
|
|
115385
116307
|
mkdirSync as mkdirSync27,
|
|
115386
116308
|
readFileSync as readFileSync45,
|
|
@@ -115390,7 +116312,7 @@ import {
|
|
|
115390
116312
|
statSync as statSync21,
|
|
115391
116313
|
writeFileSync as writeFileSync22
|
|
115392
116314
|
} from "fs";
|
|
115393
|
-
import { basename as
|
|
116315
|
+
import { basename as basename7, dirname as dirname23, join as join57, resolve as resolve7, sep } from "path";
|
|
115394
116316
|
function setViewServices(services) {
|
|
115395
116317
|
viewServices = services;
|
|
115396
116318
|
}
|
|
@@ -115468,7 +116390,7 @@ function notableAnomalies(snap) {
|
|
|
115468
116390
|
return snap.anomalies.filter((a) => a.startsWith("background_shell_open") || a.startsWith("turn_end_record_missing") || a.startsWith("agent_count_mismatch") || a.startsWith("prompt_not_read"));
|
|
115469
116391
|
}
|
|
115470
116392
|
function upstreamLogPath(path, id) {
|
|
115471
|
-
return
|
|
116393
|
+
return join57(path, "errors", `${id}-upstream.jsonl`);
|
|
115472
116394
|
}
|
|
115473
116395
|
function neverSpawnedRow(e, m, taskType) {
|
|
115474
116396
|
return {
|
|
@@ -115611,9 +116533,9 @@ function teamRunRowFromDisk(path, status) {
|
|
|
115611
116533
|
const settled = slots.length > 0 && slots.every((s) => isTerminalState(s.state));
|
|
115612
116534
|
const completions = Object.values(status.models ?? {}).map((m) => m?.completedAt ? Date.parse(m.completedAt) : Number.NaN).filter(Number.isFinite);
|
|
115613
116535
|
return {
|
|
115614
|
-
run_id: status.runId ??
|
|
116536
|
+
run_id: status.runId ?? basename7(path),
|
|
115615
116537
|
path,
|
|
115616
|
-
kind: status.kind ?? (
|
|
116538
|
+
kind: status.kind ?? (basename7(path) === "judging" ? "judge" : "run"),
|
|
115617
116539
|
started_at: status.startedAt,
|
|
115618
116540
|
finished_at: settled ? new Date(completions.length ? Math.max(...completions) : statusMtimeMs(path) ?? Date.parse(status.startedAt)).toISOString() : null,
|
|
115619
116541
|
state: settled ? "SETTLED" : "ACTIVE",
|
|
@@ -115623,14 +116545,14 @@ function teamRunRowFromDisk(path, status) {
|
|
|
115623
116545
|
}
|
|
115624
116546
|
function statusMtimeMs(path) {
|
|
115625
116547
|
try {
|
|
115626
|
-
return statSync21(
|
|
116548
|
+
return statSync21(join57(path, "status.json")).mtimeMs;
|
|
115627
116549
|
} catch {
|
|
115628
116550
|
return null;
|
|
115629
116551
|
}
|
|
115630
116552
|
}
|
|
115631
116553
|
function readManifestOrNull(path) {
|
|
115632
116554
|
try {
|
|
115633
|
-
return JSON.parse(readFileSync45(
|
|
116555
|
+
return JSON.parse(readFileSync45(join57(path, "manifest.json"), "utf-8"));
|
|
115634
116556
|
} catch {
|
|
115635
116557
|
return null;
|
|
115636
116558
|
}
|
|
@@ -115773,7 +116695,7 @@ function teamSlotTranscriptSource(path, slot, runId, opts) {
|
|
|
115773
116695
|
}
|
|
115774
116696
|
if (!status || typeof status !== "object" || !status.models || typeof status.models !== "object")
|
|
115775
116697
|
throw unknownRun(path, runId);
|
|
115776
|
-
const fileRunId = typeof status.runId === "string" && status.runId ? status.runId :
|
|
116698
|
+
const fileRunId = typeof status.runId === "string" && status.runId ? status.runId : basename7(resolved);
|
|
115777
116699
|
if (runId !== undefined && runId !== fileRunId)
|
|
115778
116700
|
throw unknownRun(path, runId);
|
|
115779
116701
|
const m = Object.hasOwn(status.models, slot) ? status.models[slot] : undefined;
|
|
@@ -115997,13 +116919,13 @@ function validateSessionPath(sessionPath) {
|
|
|
115997
116919
|
const parent = dirname23(existing);
|
|
115998
116920
|
if (parent === existing)
|
|
115999
116921
|
break;
|
|
116000
|
-
tail.unshift(
|
|
116922
|
+
tail.unshift(basename7(existing));
|
|
116001
116923
|
existing = parent;
|
|
116002
116924
|
}
|
|
116003
116925
|
}
|
|
116004
116926
|
let real;
|
|
116005
116927
|
try {
|
|
116006
|
-
real =
|
|
116928
|
+
real = join57(realpathSync7(existing), ...tail);
|
|
116007
116929
|
} catch {
|
|
116008
116930
|
throw outside();
|
|
116009
116931
|
}
|
|
@@ -116019,7 +116941,7 @@ function readTeamInputFile(inputPath) {
|
|
|
116019
116941
|
if (!resolved.startsWith(`${cwd}/`) && resolved !== cwd) {
|
|
116020
116942
|
throw new Error(`Input file must be within current directory: ${inputPath}`);
|
|
116021
116943
|
}
|
|
116022
|
-
if (!
|
|
116944
|
+
if (!existsSync40(resolved)) {
|
|
116023
116945
|
throw new Error(`Input file not found: ${resolved}`);
|
|
116024
116946
|
}
|
|
116025
116947
|
const text = readFileSync45(resolved, "utf-8");
|
|
@@ -116032,14 +116954,14 @@ function setupSession(sessionPath, models, input) {
|
|
|
116032
116954
|
if (models.length === 0) {
|
|
116033
116955
|
throw new Error("At least one model is required");
|
|
116034
116956
|
}
|
|
116035
|
-
if (
|
|
116957
|
+
if (existsSync40(join57(sessionPath, "manifest.json"))) {
|
|
116036
116958
|
throw new Error(`Session already exists at ${sessionPath}. Use a new directory path or delete the existing session first.`);
|
|
116037
116959
|
}
|
|
116038
|
-
mkdirSync27(
|
|
116039
|
-
mkdirSync27(
|
|
116960
|
+
mkdirSync27(join57(sessionPath, "work"), { recursive: true });
|
|
116961
|
+
mkdirSync27(join57(sessionPath, "errors"), { recursive: true });
|
|
116040
116962
|
if (input !== undefined) {
|
|
116041
|
-
writeFileSync22(
|
|
116042
|
-
} else if (!
|
|
116963
|
+
writeFileSync22(join57(sessionPath, "input.md"), input, "utf-8");
|
|
116964
|
+
} else if (!existsSync40(join57(sessionPath, "input.md"))) {
|
|
116043
116965
|
throw new Error(`No input.md found at ${sessionPath} and no input provided`);
|
|
116044
116966
|
}
|
|
116045
116967
|
const ids = models.map((_, i) => String(i + 1).padStart(2, "0"));
|
|
@@ -116056,9 +116978,9 @@ function setupSession(sessionPath, models, input) {
|
|
|
116056
116978
|
model: models[i],
|
|
116057
116979
|
assignedAt: now
|
|
116058
116980
|
};
|
|
116059
|
-
mkdirSync27(
|
|
116981
|
+
mkdirSync27(join57(sessionPath, "work", anonId), { recursive: true });
|
|
116060
116982
|
}
|
|
116061
|
-
writeFileSync22(
|
|
116983
|
+
writeFileSync22(join57(sessionPath, "manifest.json"), JSON.stringify(manifest, null, 2), "utf-8");
|
|
116062
116984
|
const status = {
|
|
116063
116985
|
startedAt: now,
|
|
116064
116986
|
models: Object.fromEntries(Object.keys(manifest.models).map((id) => [
|
|
@@ -116073,7 +116995,7 @@ function setupSession(sessionPath, models, input) {
|
|
|
116073
116995
|
}
|
|
116074
116996
|
]))
|
|
116075
116997
|
};
|
|
116076
|
-
writeFileAtomic(
|
|
116998
|
+
writeFileAtomic(join57(sessionPath, "status.json"), JSON.stringify(status, null, 2));
|
|
116077
116999
|
return manifest;
|
|
116078
117000
|
}
|
|
116079
117001
|
function assertValidRequirePattern(pattern) {
|
|
@@ -116108,7 +117030,7 @@ async function preflightTeamRun(opts) {
|
|
|
116108
117030
|
throw new Error(`pane_limit: ${live} live panes for this user, ${opts.slots} more would exceed ${MAX_LIVE_PANES}`);
|
|
116109
117031
|
}
|
|
116110
117032
|
function mintRunId(path, startMs) {
|
|
116111
|
-
return `${
|
|
117033
|
+
return `${basename7(path)}-${startMs.toString(36)}-${randomBytes17(3).toString("hex")}`;
|
|
116112
117034
|
}
|
|
116113
117035
|
function startModels(sessionPath, opts = {}) {
|
|
116114
117036
|
const flight = { aborted: false };
|
|
@@ -116134,9 +117056,9 @@ async function startModelsIn(flight, sessionPath, opts) {
|
|
|
116134
117056
|
throw new Error(`invalid_args: ${flagCheck.message}`);
|
|
116135
117057
|
const agentRequested = requestedAgentOf(claudeFlags);
|
|
116136
117058
|
const path = resolve7(sessionPath);
|
|
116137
|
-
const manifest = JSON.parse(readFileSync45(
|
|
116138
|
-
const statusPath =
|
|
116139
|
-
const inputContent = readFileSync45(
|
|
117059
|
+
const manifest = JSON.parse(readFileSync45(join57(path, "manifest.json"), "utf-8"));
|
|
117060
|
+
const statusPath = join57(path, "status.json");
|
|
117061
|
+
const inputContent = readFileSync45(join57(path, "input.md"), "utf-8");
|
|
116140
117062
|
const readAvailable = !flagsRemoveRead(claudeFlags);
|
|
116141
117063
|
const refusal = deliveryRefusal(inputContent, readAvailable);
|
|
116142
117064
|
if (refusal)
|
|
@@ -116180,7 +117102,7 @@ async function startModelsIn(flight, sessionPath, opts) {
|
|
|
116180
117102
|
mkdirSync27(statsDir(path), { recursive: true });
|
|
116181
117103
|
const entries = new Map;
|
|
116182
117104
|
let run = null;
|
|
116183
|
-
const errorLogPathOf = (id) =>
|
|
117105
|
+
const errorLogPathOf = (id) => join57(path, "errors", `${id}.log`);
|
|
116184
117106
|
const upstreamLogOf = (id) => upstreamLogPath(path, id);
|
|
116185
117107
|
const flagsOf = (e) => {
|
|
116186
117108
|
const effort = opts.efforts?.[e.model];
|
|
@@ -116199,7 +117121,7 @@ async function startModelsIn(flight, sessionPath, opts) {
|
|
|
116199
117121
|
function writeResponse(e, text) {
|
|
116200
117122
|
e.answer = text;
|
|
116201
117123
|
try {
|
|
116202
|
-
writeFileSync22(
|
|
117124
|
+
writeFileSync22(join57(path, `response-${e.id}.md`), text, "utf-8");
|
|
116203
117125
|
} catch (err) {
|
|
116204
117126
|
persistErrorLog(errorLogPathOf(e.id), `response file not written: ${String(err)}`, []);
|
|
116205
117127
|
}
|
|
@@ -116209,7 +117131,7 @@ async function startModelsIn(flight, sessionPath, opts) {
|
|
|
116209
117131
|
if (e.answer !== null || !e.session)
|
|
116210
117132
|
return;
|
|
116211
117133
|
try {
|
|
116212
|
-
writeFileSync22(
|
|
117134
|
+
writeFileSync22(join57(path, `response-${e.id}.md`), e.session.chainText(), "utf-8");
|
|
116213
117135
|
} catch (err) {
|
|
116214
117136
|
persistErrorLog(errorLogPathOf(e.id), `response file not written: ${String(err)}`, []);
|
|
116215
117137
|
}
|
|
@@ -116350,7 +117272,7 @@ async function startModelsIn(flight, sessionPath, opts) {
|
|
|
116350
117272
|
screenSnippet: snap.screenTail ? snippetHeadAndTail(redactSecrets(snap.screenTail)) : undefined,
|
|
116351
117273
|
answerSnippet: answer ? snippetHeadAndTail(redactSecrets(answer)) : undefined,
|
|
116352
117274
|
errorLogPath,
|
|
116353
|
-
upstreamErrorLogPath:
|
|
117275
|
+
upstreamErrorLogPath: existsSync40(upstream) ? upstream : undefined,
|
|
116354
117276
|
workDir: path
|
|
116355
117277
|
};
|
|
116356
117278
|
}
|
|
@@ -116421,7 +117343,7 @@ async function startModelsIn(flight, sessionPath, opts) {
|
|
|
116421
117343
|
}
|
|
116422
117344
|
async function startSlot(e, uuid, transcriptPath) {
|
|
116423
117345
|
let session;
|
|
116424
|
-
e.inboxPath = createHookInbox(
|
|
117346
|
+
e.inboxPath = createHookInbox(join57(path, "work"), `${e.id}.hook-inbox.jsonl`);
|
|
116425
117347
|
const binding = bindingFor(e, uuid);
|
|
116426
117348
|
e.binding = binding;
|
|
116427
117349
|
try {
|
|
@@ -116652,7 +117574,7 @@ async function startModelsIn(flight, sessionPath, opts) {
|
|
|
116652
117574
|
done.catch((err) => log(`[team] run failed at ${path}: ${err instanceof Error ? err.message : String(err)}`));
|
|
116653
117575
|
return {
|
|
116654
117576
|
runId,
|
|
116655
|
-
teamSessionId:
|
|
117577
|
+
teamSessionId: basename7(path),
|
|
116656
117578
|
sessionPath: path,
|
|
116657
117579
|
slots: Object.fromEntries(Object.entries(manifest.models).map(([anonId, entry]) => [entry.model, anonId])),
|
|
116658
117580
|
done
|
|
@@ -116673,13 +117595,13 @@ async function judgeResponses(sessionPath, opts = {}) {
|
|
|
116673
117595
|
const responses = {};
|
|
116674
117596
|
for (const file of responseFiles) {
|
|
116675
117597
|
const id = file.replace(/^response-/, "").replace(/\.md$/, "");
|
|
116676
|
-
responses[id] = readFileSync45(
|
|
117598
|
+
responses[id] = readFileSync45(join57(sessionPath, file), "utf-8");
|
|
116677
117599
|
}
|
|
116678
|
-
const input = readFileSync45(
|
|
117600
|
+
const input = readFileSync45(join57(sessionPath, "input.md"), "utf-8");
|
|
116679
117601
|
const judgePrompt = buildJudgePrompt(input, responses);
|
|
116680
|
-
writeFileSync22(
|
|
117602
|
+
writeFileSync22(join57(sessionPath, "judge-prompt.md"), judgePrompt, "utf-8");
|
|
116681
117603
|
const judgeModels = opts.judges ?? getDefaultJudgeModels(sessionPath);
|
|
116682
|
-
const judgePath =
|
|
117604
|
+
const judgePath = join57(sessionPath, "judging");
|
|
116683
117605
|
mkdirSync27(judgePath, { recursive: true });
|
|
116684
117606
|
setupSession(judgePath, judgeModels, judgePrompt);
|
|
116685
117607
|
await runModels(judgePath, {
|
|
@@ -116692,11 +117614,11 @@ async function judgeResponses(sessionPath, opts = {}) {
|
|
|
116692
117614
|
});
|
|
116693
117615
|
const votes = parseJudgeVotes(judgePath, Object.keys(responses));
|
|
116694
117616
|
const verdict = aggregateVerdict(votes, Object.keys(responses));
|
|
116695
|
-
writeFileSync22(
|
|
117617
|
+
writeFileSync22(join57(sessionPath, "verdict.md"), formatVerdict(verdict, sessionPath), "utf-8");
|
|
116696
117618
|
return verdict;
|
|
116697
117619
|
}
|
|
116698
117620
|
function getStatus(sessionPath) {
|
|
116699
|
-
return JSON.parse(readFileSync45(
|
|
117621
|
+
return JSON.parse(readFileSync45(join57(sessionPath, "status.json"), "utf-8"));
|
|
116700
117622
|
}
|
|
116701
117623
|
function readTeamStatus(sessionPath) {
|
|
116702
117624
|
try {
|
|
@@ -116736,7 +117658,7 @@ function fisherYatesShuffle(arr) {
|
|
|
116736
117658
|
return arr;
|
|
116737
117659
|
}
|
|
116738
117660
|
function getDefaultJudgeModels(sessionPath) {
|
|
116739
|
-
const manifest = JSON.parse(readFileSync45(
|
|
117661
|
+
const manifest = JSON.parse(readFileSync45(join57(sessionPath, "manifest.json"), "utf-8"));
|
|
116740
117662
|
return Object.values(manifest.models).map((e) => e.model);
|
|
116741
117663
|
}
|
|
116742
117664
|
function buildJudgePrompt(input, responses) {
|
|
@@ -116799,7 +117721,7 @@ function parseJudgeVotes(judgePath, responseIds) {
|
|
|
116799
117721
|
const judgeId = file.replace(/^response-/, "").replace(/\.md$/, "");
|
|
116800
117722
|
let content;
|
|
116801
117723
|
try {
|
|
116802
|
-
content = readFileSync45(
|
|
117724
|
+
content = readFileSync45(join57(judgePath, file), "utf-8");
|
|
116803
117725
|
} catch (err) {
|
|
116804
117726
|
log(`[team] judge answer ${file} unreadable: ${err instanceof Error ? err.message : String(err)}`);
|
|
116805
117727
|
continue;
|
|
@@ -116852,7 +117774,7 @@ function aggregateVerdict(votes, responseIds) {
|
|
|
116852
117774
|
function formatVerdict(verdict, sessionPath) {
|
|
116853
117775
|
let manifest = null;
|
|
116854
117776
|
try {
|
|
116855
|
-
manifest = JSON.parse(readFileSync45(
|
|
117777
|
+
manifest = JSON.parse(readFileSync45(join57(sessionPath, "manifest.json"), "utf-8"));
|
|
116856
117778
|
} catch {}
|
|
116857
117779
|
let output = `# Team Verdict
|
|
116858
117780
|
|
|
@@ -116912,8 +117834,8 @@ var init_team_orchestrator = __esm(() => {
|
|
|
116912
117834
|
});
|
|
116913
117835
|
|
|
116914
117836
|
// src/mcp-session/inherited-settings.ts
|
|
116915
|
-
import { existsSync as
|
|
116916
|
-
import { join as
|
|
117837
|
+
import { existsSync as existsSync41, readFileSync as readFileSync46, statSync as statSync22 } from "fs";
|
|
117838
|
+
import { join as join58, resolve as resolve8 } from "path";
|
|
116917
117839
|
function isPlainObject7(value) {
|
|
116918
117840
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
116919
117841
|
}
|
|
@@ -116967,8 +117889,8 @@ function readSettingsValue(value) {
|
|
|
116967
117889
|
function buildInheritedSettingsLayer(setupFrom, callerFlags) {
|
|
116968
117890
|
const layers = [];
|
|
116969
117891
|
for (const name of ["settings.json", "settings.local.json"]) {
|
|
116970
|
-
const file =
|
|
116971
|
-
if (!
|
|
117892
|
+
const file = join58(setupFrom, ".claude", name);
|
|
117893
|
+
if (!existsSync41(file))
|
|
116972
117894
|
continue;
|
|
116973
117895
|
layers.push(parseLayer(readFileSync46(file, "utf-8"), file));
|
|
116974
117896
|
}
|
|
@@ -117012,7 +117934,7 @@ var init_inherited_settings = () => {};
|
|
|
117012
117934
|
|
|
117013
117935
|
// src/mcp-session/parent-session.ts
|
|
117014
117936
|
import { readFile as readFile7 } from "fs/promises";
|
|
117015
|
-
import { join as
|
|
117937
|
+
import { join as join59 } from "path";
|
|
117016
117938
|
function positiveInt(value) {
|
|
117017
117939
|
if (value === undefined || !/^[1-9][0-9]*$/.test(value))
|
|
117018
117940
|
return;
|
|
@@ -117036,7 +117958,7 @@ function parentSessionIdFrom(env) {
|
|
|
117036
117958
|
}
|
|
117037
117959
|
async function readHostSessionRecord(opts) {
|
|
117038
117960
|
try {
|
|
117039
|
-
const raw = await readFile7(
|
|
117961
|
+
const raw = await readFile7(join59(opts.configDir, "sessions", `${opts.hostPid}.json`), "utf-8");
|
|
117040
117962
|
const parsed = JSON.parse(raw);
|
|
117041
117963
|
if (!parsed || typeof parsed !== "object")
|
|
117042
117964
|
return;
|
|
@@ -117127,7 +118049,7 @@ import {
|
|
|
117127
118049
|
appendFileSync as appendFileSync7,
|
|
117128
118050
|
closeSync as closeSync16,
|
|
117129
118051
|
createWriteStream,
|
|
117130
|
-
existsSync as
|
|
118052
|
+
existsSync as existsSync42,
|
|
117131
118053
|
mkdirSync as mkdirSync28,
|
|
117132
118054
|
openSync as openSync16,
|
|
117133
118055
|
readFileSync as readFileSync47,
|
|
@@ -117137,7 +118059,7 @@ import {
|
|
|
117137
118059
|
statSync as statSync23,
|
|
117138
118060
|
writeFileSync as writeFileSync23
|
|
117139
118061
|
} from "fs";
|
|
117140
|
-
import { join as
|
|
118062
|
+
import { join as join60, resolve as resolve9, sep as sep2 } from "path";
|
|
117141
118063
|
function normaliseTimeoutSeconds(raw) {
|
|
117142
118064
|
const n = typeof raw === "string" && raw.trim() !== "" ? Number(raw) : raw;
|
|
117143
118065
|
if (typeof n !== "number" || !Number.isFinite(n))
|
|
@@ -117310,7 +118232,7 @@ function dropLeadingFragment(tail) {
|
|
|
117310
118232
|
return firstBreak === -1 ? tail.text : tail.text.slice(firstBreak + 1);
|
|
117311
118233
|
}
|
|
117312
118234
|
function diskAccounting(sessionDir) {
|
|
117313
|
-
const stats = readTokenStatsAt(
|
|
118235
|
+
const stats = readTokenStatsAt(join60(sessionDir, "tokens.json"));
|
|
117314
118236
|
return {
|
|
117315
118237
|
tokensIn: stats?.billed_input_tokens ?? null,
|
|
117316
118238
|
tokensOut: stats?.output_tokens ?? null,
|
|
@@ -117399,7 +118321,7 @@ class SessionManager {
|
|
|
117399
118321
|
let dir = "";
|
|
117400
118322
|
for (let attempt = 0;; attempt++) {
|
|
117401
118323
|
id = `team-${randomUUID9().replace(/-/g, "").slice(0, 8)}`;
|
|
117402
|
-
dir =
|
|
118324
|
+
dir = join60(this.sessionsDir, id);
|
|
117403
118325
|
try {
|
|
117404
118326
|
mkdirSync28(dir);
|
|
117405
118327
|
break;
|
|
@@ -117431,9 +118353,9 @@ class SessionManager {
|
|
|
117431
118353
|
if (dir === null)
|
|
117432
118354
|
throw new Error("not a record id");
|
|
117433
118355
|
const completedAt = new Date().toISOString();
|
|
117434
|
-
const startedAt = this.teamRunStarts.get(record) ?? metaString(readJsonObject(
|
|
118356
|
+
const startedAt = this.teamRunStarts.get(record) ?? metaString(readJsonObject(join60(dir, "spawn.json"), META_READ_LIMIT)?.startedAt) ?? completedAt;
|
|
117435
118357
|
const elapsedMs = Date.parse(completedAt) - Date.parse(startedAt);
|
|
117436
|
-
writeJsonAtomic(
|
|
118358
|
+
writeJsonAtomic(join60(dir, "meta.json"), {
|
|
117437
118359
|
kind: "team",
|
|
117438
118360
|
status: outcome.status,
|
|
117439
118361
|
startedAt,
|
|
@@ -117465,7 +118387,7 @@ class SessionManager {
|
|
|
117465
118387
|
startedAt,
|
|
117466
118388
|
...rest
|
|
117467
118389
|
};
|
|
117468
|
-
writeJsonAtomic(
|
|
118390
|
+
writeJsonAtomic(join60(dir, "spawn.json"), body);
|
|
117469
118391
|
}
|
|
117470
118392
|
async createSession(opts) {
|
|
117471
118393
|
if (this.activeSessions + this.starting >= this.maxSessions) {
|
|
@@ -117505,7 +118427,7 @@ class SessionManager {
|
|
|
117505
118427
|
throw err;
|
|
117506
118428
|
}
|
|
117507
118429
|
if (inherited.layer) {
|
|
117508
|
-
flags = [...inherited.restFlags, "--settings",
|
|
118430
|
+
flags = [...inherited.restFlags, "--settings", join60(entry.sessionDir, INHERITED_SETTINGS)];
|
|
117509
118431
|
}
|
|
117510
118432
|
this.sessions.set(entry.info.sessionId, entry);
|
|
117511
118433
|
uncount();
|
|
@@ -117530,10 +118452,10 @@ class SessionManager {
|
|
|
117530
118452
|
const timeout = normaliseTimeoutSeconds(opts.timeoutSeconds);
|
|
117531
118453
|
const agentRequested = requestedAgentOf(opts.claudishFlags ?? []);
|
|
117532
118454
|
const startedAt = new Date().toISOString();
|
|
117533
|
-
const sessionDir = opts.sessionDir ??
|
|
118455
|
+
const sessionDir = opts.sessionDir ?? join60(this.sessionsDir, sessionId);
|
|
117534
118456
|
mkdirSync28(sessionDir, { recursive: true });
|
|
117535
118457
|
if (opts.prompt)
|
|
117536
|
-
writeFileSync23(
|
|
118458
|
+
writeFileSync23(join60(sessionDir, "prompt.md"), opts.prompt, "utf-8");
|
|
117537
118459
|
this.writeSpawnRecord(sessionDir, {
|
|
117538
118460
|
kind: "session",
|
|
117539
118461
|
sessionId,
|
|
@@ -117547,13 +118469,13 @@ class SessionManager {
|
|
|
117547
118469
|
taskType: opts.taskType
|
|
117548
118470
|
});
|
|
117549
118471
|
if (inheritedLayer) {
|
|
117550
|
-
writeFileSync23(
|
|
118472
|
+
writeFileSync23(join60(sessionDir, INHERITED_SETTINGS), `${JSON.stringify(inheritedLayer, null, 2)}
|
|
117551
118473
|
`, { encoding: "utf-8", mode: 384 });
|
|
117552
118474
|
}
|
|
117553
118475
|
const cwd = opts.cwd ?? process.cwd();
|
|
117554
118476
|
const parentEnv = opts.parentEnv ?? this.parentEnv;
|
|
117555
118477
|
const spawnModel = opts.spawnModel ?? null;
|
|
117556
|
-
const tokenFile = opts.tokenFile ??
|
|
118478
|
+
const tokenFile = opts.tokenFile ?? join60(sessionDir, "tokens.json");
|
|
117557
118479
|
return {
|
|
117558
118480
|
info: {
|
|
117559
118481
|
sessionId,
|
|
@@ -117592,18 +118514,18 @@ class SessionManager {
|
|
|
117592
118514
|
},
|
|
117593
118515
|
session: null,
|
|
117594
118516
|
scrollback: new ScrollbackBuffer(this.scrollbackCapacity),
|
|
117595
|
-
outputLogStream: createWriteStream(
|
|
118517
|
+
outputLogStream: createWriteStream(join60(sessionDir, "output.log")),
|
|
117596
118518
|
sessionDir,
|
|
117597
118519
|
cwd,
|
|
117598
118520
|
tokenFile,
|
|
117599
|
-
eventLogPath:
|
|
118521
|
+
eventLogPath: join60(sessionDir, "events.jsonl"),
|
|
117600
118522
|
eventLogBytes: 0,
|
|
117601
|
-
upstreamErrorLogPath:
|
|
118523
|
+
upstreamErrorLogPath: join60(sessionDir, "upstream-errors.jsonl"),
|
|
117602
118524
|
eventRing: [],
|
|
117603
118525
|
proseBytes: 0,
|
|
117604
118526
|
answeredTurns: new Map,
|
|
117605
118527
|
inboxPath: null,
|
|
117606
|
-
waitLogPath:
|
|
118528
|
+
waitLogPath: join60(sessionDir, "waits.jsonl"),
|
|
117607
118529
|
waitLogBytes: 0,
|
|
117608
118530
|
waitSince: null,
|
|
117609
118531
|
ended: false,
|
|
@@ -117825,7 +118747,7 @@ class SessionManager {
|
|
|
117825
118747
|
try {
|
|
117826
118748
|
const text = screenLines.join(`
|
|
117827
118749
|
`).replace(/\s+$/, "");
|
|
117828
|
-
writeFileSync23(
|
|
118750
|
+
writeFileSync23(join60(entry.sessionDir, "screen.txt"), `${redactSecrets(text)}
|
|
117829
118751
|
`, "utf-8");
|
|
117830
118752
|
} catch {}
|
|
117831
118753
|
}
|
|
@@ -117839,7 +118761,7 @@ class SessionManager {
|
|
|
117839
118761
|
entry.waitSince = null;
|
|
117840
118762
|
}
|
|
117841
118763
|
try {
|
|
117842
|
-
writeJsonAtomic(
|
|
118764
|
+
writeJsonAtomic(join60(entry.sessionDir, "meta.json"), toMetaRecord(entry.info, entry.cwd));
|
|
117843
118765
|
} catch (err) {
|
|
117844
118766
|
process.stderr.write(`[claudish] session ${entry.info.sessionId}: could not write meta.json: ` + `${err instanceof Error ? err.message : String(err)}
|
|
117845
118767
|
`);
|
|
@@ -118109,8 +119031,8 @@ class SessionManager {
|
|
|
118109
119031
|
} catch {
|
|
118110
119032
|
return null;
|
|
118111
119033
|
}
|
|
118112
|
-
const spawnPath =
|
|
118113
|
-
const metaPath =
|
|
119034
|
+
const spawnPath = join60(sessionDir, "spawn.json");
|
|
119035
|
+
const metaPath = join60(sessionDir, "meta.json");
|
|
118114
119036
|
const spawnRecord = readJsonObject(spawnPath, META_READ_LIMIT);
|
|
118115
119037
|
if (spawnRecord?.kind === "team")
|
|
118116
119038
|
return null;
|
|
@@ -118129,7 +119051,7 @@ class SessionManager {
|
|
|
118129
119051
|
const age = Number.isFinite(endedMs) ? now - endedMs : fileAgeMs(metaPath, now);
|
|
118130
119052
|
if (uuid) {
|
|
118131
119053
|
const stored = metaString(meta.transcriptPath);
|
|
118132
|
-
if (stored &&
|
|
119054
|
+
if (stored && existsSync42(stored))
|
|
118133
119055
|
transcriptPath = stored;
|
|
118134
119056
|
else if (cwd)
|
|
118135
119057
|
transcriptPath = transcriptPathFor(cwd, uuid, projectsRoot);
|
|
@@ -118201,7 +119123,7 @@ class SessionManager {
|
|
|
118201
119123
|
if (!record)
|
|
118202
119124
|
return null;
|
|
118203
119125
|
const info = record.info;
|
|
118204
|
-
return sessionRowOf(info, upstreamRecordsFor(info,
|
|
119126
|
+
return sessionRowOf(info, upstreamRecordsFor(info, join60(record.sessionDir, "upstream-errors.jsonl")));
|
|
118205
119127
|
}
|
|
118206
119128
|
async shutdownAll() {
|
|
118207
119129
|
await Promise.all([...this.pendingStarts]);
|
|
@@ -118232,7 +119154,7 @@ class SessionManager {
|
|
|
118232
119154
|
return null;
|
|
118233
119155
|
const root = resolve9(this.sessionsDir);
|
|
118234
119156
|
const dir = resolve9(root, sessionId);
|
|
118235
|
-
if (dir !==
|
|
119157
|
+
if (dir !== join60(root, sessionId))
|
|
118236
119158
|
return null;
|
|
118237
119159
|
if (!dir.startsWith(root + sep2))
|
|
118238
119160
|
return null;
|
|
@@ -118251,10 +119173,10 @@ class SessionManager {
|
|
|
118251
119173
|
} catch {
|
|
118252
119174
|
return null;
|
|
118253
119175
|
}
|
|
118254
|
-
const spawnRecord = readJsonObject(
|
|
119176
|
+
const spawnRecord = readJsonObject(join60(sessionDir, "spawn.json"), META_READ_LIMIT);
|
|
118255
119177
|
if (spawnRecord?.kind === "team")
|
|
118256
119178
|
return null;
|
|
118257
|
-
const meta = readJsonObject(
|
|
119179
|
+
const meta = readJsonObject(join60(sessionDir, "meta.json"), META_READ_LIMIT);
|
|
118258
119180
|
if (meta?.kind === "team")
|
|
118259
119181
|
return null;
|
|
118260
119182
|
const partial = meta === null;
|
|
@@ -118269,14 +119191,14 @@ class SessionManager {
|
|
|
118269
119191
|
diskTranscriptPath(meta, uuid) {
|
|
118270
119192
|
const stored = metaString(meta?.transcriptPath) ?? "";
|
|
118271
119193
|
const cwd = metaString(meta?.cwd);
|
|
118272
|
-
if (stored &&
|
|
119194
|
+
if (stored && existsSync42(stored))
|
|
118273
119195
|
return stored;
|
|
118274
119196
|
if (cwd && uuid)
|
|
118275
119197
|
return transcriptPathFor(cwd, uuid, projectsDir(this.parentEnv, cwd));
|
|
118276
119198
|
return stored;
|
|
118277
119199
|
}
|
|
118278
119200
|
diskOutput(record, tailLines) {
|
|
118279
|
-
const tail = readTailText(
|
|
119201
|
+
const tail = readTailText(join60(record.sessionDir, "output.log"), OUTPUT_TAIL_BYTES);
|
|
118280
119202
|
const buffer = new ScrollbackBuffer(this.scrollbackCapacity);
|
|
118281
119203
|
if (tail?.text)
|
|
118282
119204
|
buffer.append(dropLeadingFragment(tail));
|
|
@@ -118296,12 +119218,12 @@ class SessionManager {
|
|
|
118296
119218
|
}
|
|
118297
119219
|
diskDiagnostics(record, limit) {
|
|
118298
119220
|
const { sessionDir, info } = record;
|
|
118299
|
-
const eventLogPath =
|
|
118300
|
-
const upstreamErrorLogPath =
|
|
118301
|
-
const outputLogPath =
|
|
119221
|
+
const eventLogPath = join60(sessionDir, "events.jsonl");
|
|
119222
|
+
const upstreamErrorLogPath = join60(sessionDir, "upstream-errors.jsonl");
|
|
119223
|
+
const outputLogPath = join60(sessionDir, "output.log");
|
|
118302
119224
|
const events = readTailLines2(eventLogPath, EVENT_TAIL_BYTES);
|
|
118303
119225
|
const outputTail = readTailText(outputLogPath, OUTPUT_TAIL_BYTES);
|
|
118304
|
-
const screen = readTailText(
|
|
119226
|
+
const screen = readTailText(join60(sessionDir, "screen.txt"), SCREEN_READ_BYTES);
|
|
118305
119227
|
return {
|
|
118306
119228
|
sessionId: info.sessionId,
|
|
118307
119229
|
state: info.state,
|
|
@@ -118606,7 +119528,7 @@ var init_session_manager = __esm(() => {
|
|
|
118606
119528
|
|
|
118607
119529
|
// src/view/history.ts
|
|
118608
119530
|
import { closeSync as closeSync17, openSync as openSync17, readSync as readSync8, readdirSync as readdirSync12, statSync as statSync24 } from "fs";
|
|
118609
|
-
import { join as
|
|
119531
|
+
import { join as join61 } from "path";
|
|
118610
119532
|
function finishedDetail(promptSummary) {
|
|
118611
119533
|
return {
|
|
118612
119534
|
prompt_summary: promptSummary,
|
|
@@ -118648,7 +119570,7 @@ function runDirs(sessionsDir) {
|
|
|
118648
119570
|
const dated = [];
|
|
118649
119571
|
for (const name of names) {
|
|
118650
119572
|
try {
|
|
118651
|
-
const st = statSync24(
|
|
119573
|
+
const st = statSync24(join61(sessionsDir, name));
|
|
118652
119574
|
if (st.isDirectory())
|
|
118653
119575
|
dated.push({ name, mtimeMs: st.mtimeMs });
|
|
118654
119576
|
} catch {}
|
|
@@ -118685,7 +119607,7 @@ function teamItems(spawn) {
|
|
|
118685
119607
|
return { runId: run.run_id, items };
|
|
118686
119608
|
}
|
|
118687
119609
|
function runItems(sessions, dir, name, seenRuns) {
|
|
118688
|
-
const spawn = readJson(
|
|
119610
|
+
const spawn = readJson(join61(dir, "spawn.json"));
|
|
118689
119611
|
if (spawn?.kind === "team" || name.startsWith("team-")) {
|
|
118690
119612
|
const team = spawn ? teamItems(spawn) : null;
|
|
118691
119613
|
if (!team || seenRuns.has(team.runId) || team.items.length === 0)
|
|
@@ -118693,12 +119615,12 @@ function runItems(sessions, dir, name, seenRuns) {
|
|
|
118693
119615
|
seenRuns.add(team.runId);
|
|
118694
119616
|
return team.items;
|
|
118695
119617
|
}
|
|
118696
|
-
if (!spawn && readJson(
|
|
119618
|
+
if (!spawn && readJson(join61(dir, "meta.json")) === null)
|
|
118697
119619
|
return null;
|
|
118698
119620
|
const row = sessions.diskSessionRow(name);
|
|
118699
119621
|
if (!row)
|
|
118700
119622
|
return null;
|
|
118701
|
-
const prompt = readHead(
|
|
119623
|
+
const prompt = readHead(join61(dir, "prompt.md"), PROMPT_HEAD_BYTES);
|
|
118702
119624
|
return [sessionItem(row, prompt ? promptSummaryOf(prompt) : null)];
|
|
118703
119625
|
}
|
|
118704
119626
|
function readHistory(o = {}) {
|
|
@@ -118711,7 +119633,7 @@ function readHistory(o = {}) {
|
|
|
118711
119633
|
for (const name of runDirs(sessionsDir)) {
|
|
118712
119634
|
if (runs >= limit)
|
|
118713
119635
|
break;
|
|
118714
|
-
const items = runItems(sessions,
|
|
119636
|
+
const items = runItems(sessions, join61(sessionsDir, name), name, seenRuns);
|
|
118715
119637
|
if (!items)
|
|
118716
119638
|
continue;
|
|
118717
119639
|
out.push(...items);
|
|
@@ -118726,15 +119648,15 @@ function findRecordedItem(target, o = {}) {
|
|
|
118726
119648
|
const id = target.slice(2);
|
|
118727
119649
|
if (!id || id.includes("/") || id.startsWith("."))
|
|
118728
119650
|
return null;
|
|
118729
|
-
const items = runItems(sessions,
|
|
119651
|
+
const items = runItems(sessions, join61(sessionsDir, id), id, new Set);
|
|
118730
119652
|
return items?.find((i) => i.target === target) ?? null;
|
|
118731
119653
|
}
|
|
118732
119654
|
if (!target.startsWith("t:"))
|
|
118733
119655
|
return null;
|
|
118734
119656
|
const seenRuns = new Set;
|
|
118735
119657
|
for (const name of runDirs(sessionsDir)) {
|
|
118736
|
-
const dir =
|
|
118737
|
-
if (!name.startsWith("team-") && readJson(
|
|
119658
|
+
const dir = join61(sessionsDir, name);
|
|
119659
|
+
if (!name.startsWith("team-") && readJson(join61(dir, "spawn.json"))?.kind !== "team")
|
|
118738
119660
|
continue;
|
|
118739
119661
|
const found = runItems(sessions, dir, name, seenRuns)?.find((i) => i.target === target);
|
|
118740
119662
|
if (found)
|
|
@@ -118786,7 +119708,7 @@ class LineBuffer {
|
|
|
118786
119708
|
|
|
118787
119709
|
// src/view/view-client.ts
|
|
118788
119710
|
import { connect } from "net";
|
|
118789
|
-
import { basename as
|
|
119711
|
+
import { basename as basename8 } from "path";
|
|
118790
119712
|
function dial(path) {
|
|
118791
119713
|
return new Promise((resolve, reject) => {
|
|
118792
119714
|
const sock = connect(path);
|
|
@@ -118936,7 +119858,7 @@ class ViewClient {
|
|
|
118936
119858
|
}
|
|
118937
119859
|
async redial() {
|
|
118938
119860
|
let wait = RECONNECT_FIRST_MS;
|
|
118939
|
-
const name =
|
|
119861
|
+
const name = basename8(this.path);
|
|
118940
119862
|
while (!this.ended) {
|
|
118941
119863
|
if (!endpointOwnerAlive(name, await readProcessTableAsync())) {
|
|
118942
119864
|
this.end("server_gone");
|
|
@@ -118986,9 +119908,9 @@ var init_view_client = __esm(() => {
|
|
|
118986
119908
|
|
|
118987
119909
|
// src/view/feed-relay.ts
|
|
118988
119910
|
import { chmodSync as chmodSync7, readFileSync as readFileSync48, renameSync as renameSync11, rmSync as rmSync16, writeFileSync as writeFileSync24 } from "fs";
|
|
118989
|
-
import { dirname as dirname24, join as
|
|
119911
|
+
import { dirname as dirname24, join as join62 } from "path";
|
|
118990
119912
|
function defaultFeedPath(root) {
|
|
118991
|
-
return
|
|
119913
|
+
return join62(root, FEED_DIR, FEED_FILE);
|
|
118992
119914
|
}
|
|
118993
119915
|
function ownStamp() {
|
|
118994
119916
|
return {
|
|
@@ -119056,7 +119978,7 @@ class FeedRelay {
|
|
|
119056
119978
|
}
|
|
119057
119979
|
async start() {
|
|
119058
119980
|
ensureSockRoot(this.o.root);
|
|
119059
|
-
if (dirname24(this.path) ===
|
|
119981
|
+
if (dirname24(this.path) === join62(this.o.root, FEED_DIR))
|
|
119060
119982
|
ensurePrivateSubdir(this.o.root, FEED_DIR);
|
|
119061
119983
|
const other = readFeedStamp(this.path);
|
|
119062
119984
|
if (other && !this.isOwn(other) && stampAlive(other, await readProcessTableAsync()))
|
|
@@ -119311,7 +120233,7 @@ var init_feed_relay = __esm(() => {
|
|
|
119311
120233
|
import {
|
|
119312
120234
|
constants as constants4,
|
|
119313
120235
|
accessSync as accessSync2,
|
|
119314
|
-
existsSync as
|
|
120236
|
+
existsSync as existsSync43,
|
|
119315
120237
|
lstatSync as lstatSync9,
|
|
119316
120238
|
readFileSync as readFileSync49,
|
|
119317
120239
|
readdirSync as readdirSync13,
|
|
@@ -119321,7 +120243,7 @@ import {
|
|
|
119321
120243
|
unlinkSync as unlinkSync12,
|
|
119322
120244
|
writeFileSync as writeFileSync25
|
|
119323
120245
|
} from "fs";
|
|
119324
|
-
import { dirname as dirname25, join as
|
|
120246
|
+
import { dirname as dirname25, join as join63 } from "path";
|
|
119325
120247
|
function ownerStartOfSelf() {
|
|
119326
120248
|
if (ownStart)
|
|
119327
120249
|
return ownStart;
|
|
@@ -119342,7 +120264,7 @@ function ownerAlive(owner, table) {
|
|
|
119342
120264
|
return !minted || startedAt(row, minted.startMs);
|
|
119343
120265
|
}
|
|
119344
120266
|
function recordsDir(root) {
|
|
119345
|
-
return
|
|
120267
|
+
return join63(root, "panes");
|
|
119346
120268
|
}
|
|
119347
120269
|
function writeRecord(root, rec) {
|
|
119348
120270
|
const p = recordPathOf(root, rec.paneId);
|
|
@@ -119426,13 +120348,13 @@ function readRecords(root) {
|
|
|
119426
120348
|
}
|
|
119427
120349
|
function readGroupFile(ctlDir) {
|
|
119428
120350
|
try {
|
|
119429
|
-
return parseGroupFile(readFileSync49(
|
|
120351
|
+
return parseGroupFile(readFileSync49(join63(ctlDir, "group"), "utf8"));
|
|
119430
120352
|
} catch {
|
|
119431
120353
|
return null;
|
|
119432
120354
|
}
|
|
119433
120355
|
}
|
|
119434
120356
|
function writeGroupFile(ctlDir, snap) {
|
|
119435
|
-
const p =
|
|
120357
|
+
const p = join63(ctlDir, "group");
|
|
119436
120358
|
const tmp = `${p}.tmp`;
|
|
119437
120359
|
try {
|
|
119438
120360
|
writeFileSync25(tmp, formatGroupFile(snap), { mode: 384 });
|
|
@@ -119726,7 +120648,7 @@ async function sweepRecordlessSocket(root, name, out) {
|
|
|
119726
120648
|
const owner = ownerOfSocketId(id);
|
|
119727
120649
|
if (!owner || ownerAlive(owner, table))
|
|
119728
120650
|
return;
|
|
119729
|
-
const sockPath =
|
|
120651
|
+
const sockPath = join63(root, name);
|
|
119730
120652
|
const magmuxMayLive = !table || table.some((r) => isPaneMagmuxCommand(r.command, id));
|
|
119731
120653
|
const probe = await probeSocket(sockPath, magmuxMayLive);
|
|
119732
120654
|
if (probe.state === "stale") {
|
|
@@ -119772,7 +120694,7 @@ function sweepRecordlessViewSockets(root, out) {
|
|
|
119772
120694
|
const table = readProcessTable();
|
|
119773
120695
|
for (const n of names) {
|
|
119774
120696
|
const id = n.slice("magmux-".length, -".view".length);
|
|
119775
|
-
if (known.has(id) || live.has(id) ||
|
|
120697
|
+
if (known.has(id) || live.has(id) || existsSync43(sockPathOf(root, id)))
|
|
119776
120698
|
continue;
|
|
119777
120699
|
const owner = ownerOfSocketId(id);
|
|
119778
120700
|
if (!owner || ownerAlive(owner, table))
|
|
@@ -119806,7 +120728,7 @@ async function ensureSwept(root) {
|
|
|
119806
120728
|
}
|
|
119807
120729
|
async function sweepOrphanPanes(root = sockRootFor()) {
|
|
119808
120730
|
const out = { reaped: [], cleaned: [], kept: [] };
|
|
119809
|
-
if (!
|
|
120731
|
+
if (!existsSync43(root))
|
|
119810
120732
|
return out;
|
|
119811
120733
|
ensureSockRoot(root);
|
|
119812
120734
|
const records = readRecords(root);
|
|
@@ -119854,19 +120776,19 @@ var init_pane_registry = __esm(() => {
|
|
|
119854
120776
|
|
|
119855
120777
|
// src/pane/gate-binding.ts
|
|
119856
120778
|
import { realpathSync as realpathSync8 } from "fs";
|
|
119857
|
-
import { basename as
|
|
120779
|
+
import { basename as basename9, dirname as dirname26, join as join64, resolve as resolve10 } from "path";
|
|
119858
120780
|
function normaliseTranscriptPath(p) {
|
|
119859
120781
|
const abs = resolve10(p);
|
|
119860
120782
|
const tail = [];
|
|
119861
120783
|
let cur = abs;
|
|
119862
120784
|
for (;; ) {
|
|
119863
120785
|
try {
|
|
119864
|
-
return tail.length ?
|
|
120786
|
+
return tail.length ? join64(realpathSync8(cur), ...tail.reverse()) : realpathSync8(cur);
|
|
119865
120787
|
} catch {
|
|
119866
120788
|
const parent = dirname26(cur);
|
|
119867
120789
|
if (parent === cur)
|
|
119868
120790
|
return abs;
|
|
119869
|
-
tail.push(
|
|
120791
|
+
tail.push(basename9(cur));
|
|
119870
120792
|
cur = parent;
|
|
119871
120793
|
}
|
|
119872
120794
|
}
|
|
@@ -120062,7 +120984,7 @@ var init_scroll_input = __esm(() => {
|
|
|
120062
120984
|
|
|
120063
120985
|
// src/pane/session-registry.ts
|
|
120064
120986
|
import { readFileSync as readFileSync50, readdirSync as readdirSync14 } from "fs";
|
|
120065
|
-
import { join as
|
|
120987
|
+
import { join as join65 } from "path";
|
|
120066
120988
|
function parseRegistryRecord(raw) {
|
|
120067
120989
|
let parsed;
|
|
120068
120990
|
try {
|
|
@@ -120107,7 +121029,7 @@ class SessionRegistry {
|
|
|
120107
121029
|
isAlive;
|
|
120108
121030
|
constructor(o) {
|
|
120109
121031
|
this.o = o;
|
|
120110
|
-
this.dir =
|
|
121032
|
+
this.dir = join65(o.configDir, "sessions");
|
|
120111
121033
|
this.now = o.now ?? Date.now;
|
|
120112
121034
|
this.isAlive = o.isAlive ?? pidAlive2;
|
|
120113
121035
|
}
|
|
@@ -120143,7 +121065,7 @@ class SessionRegistry {
|
|
|
120143
121065
|
readPid(pid) {
|
|
120144
121066
|
let raw;
|
|
120145
121067
|
try {
|
|
120146
|
-
raw = readFileSync50(
|
|
121068
|
+
raw = readFileSync50(join65(this.dir, `${pid}.json`), "utf8");
|
|
120147
121069
|
} catch {
|
|
120148
121070
|
return null;
|
|
120149
121071
|
}
|
|
@@ -120288,7 +121210,7 @@ var init_view_socket = __esm(() => {
|
|
|
120288
121210
|
|
|
120289
121211
|
// src/pane/pane-session.ts
|
|
120290
121212
|
import { readFileSync as readFileSync51, realpathSync as realpathSync9, rmSync as rmSync18, statSync as statSync25, writeFileSync as writeFileSync26 } from "fs";
|
|
120291
|
-
import { join as
|
|
121213
|
+
import { join as join66 } from "path";
|
|
120292
121214
|
function iso3(ms) {
|
|
120293
121215
|
return new Date(ms).toISOString();
|
|
120294
121216
|
}
|
|
@@ -120441,7 +121363,7 @@ class PaneSessionImpl {
|
|
|
120441
121363
|
});
|
|
120442
121364
|
this.secondaryQuietMs = o.timings?.secondaryQuietMs ?? SECONDARY_QUIET_MS;
|
|
120443
121365
|
this.corroborationMs = o.timings?.corroborationMs ?? CORROBORATION_MS;
|
|
120444
|
-
this.follower = new TranscriptFollower(o.transcriptPath,
|
|
121366
|
+
this.follower = new TranscriptFollower(o.transcriptPath, join66(o.transcriptPath.replace(/\.jsonl$/, ""), "subagents"));
|
|
120445
121367
|
this.registry = new SessionRegistry({
|
|
120446
121368
|
configDir: claudeCodeConfigDir(o.parentEnv ?? process.env, o.cwd),
|
|
120447
121369
|
sessionUuid: o.sessionUuid
|
|
@@ -120488,7 +121410,7 @@ class PaneSessionImpl {
|
|
|
120488
121410
|
return this.spawnFailed(new Error("magmux did not start"));
|
|
120489
121411
|
this.magmux = proc;
|
|
120490
121412
|
try {
|
|
120491
|
-
writeFileSync26(
|
|
121413
|
+
writeFileSync26(join66(this.ctlDir, "magmux.pid"), `${proc.pid}
|
|
120492
121414
|
`, { mode: 384 });
|
|
120493
121415
|
} catch {}
|
|
120494
121416
|
updateRecord(this.root, this.paneId, { magmuxPid: proc.pid });
|
|
@@ -123023,7 +123945,7 @@ var init_pane_session = __esm(() => {
|
|
|
123023
123945
|
|
|
123024
123946
|
// src/pane/replay-pane.ts
|
|
123025
123947
|
import { rmSync as rmSync19, writeFileSync as writeFileSync27 } from "fs";
|
|
123026
|
-
import { join as
|
|
123948
|
+
import { join as join67 } from "path";
|
|
123027
123949
|
async function waitUntil(pred, ms) {
|
|
123028
123950
|
const end = Date.now() + ms;
|
|
123029
123951
|
while (!pred() && Date.now() < end)
|
|
@@ -123136,7 +124058,7 @@ class ReplayPane {
|
|
|
123136
124058
|
return failed(new Error("magmux did not start"));
|
|
123137
124059
|
this.magmuxProc = proc;
|
|
123138
124060
|
try {
|
|
123139
|
-
writeFileSync27(
|
|
124061
|
+
writeFileSync27(join67(this.ctlDir, "magmux.pid"), `${proc.pid}
|
|
123140
124062
|
`, { mode: 384 });
|
|
123141
124063
|
} catch {}
|
|
123142
124064
|
updateRecord(this.root, this.paneId, { magmuxPid: proc.pid });
|
|
@@ -124063,7 +124985,7 @@ import {
|
|
|
124063
124985
|
realpathSync as realpathSync10,
|
|
124064
124986
|
statSync as statSync26
|
|
124065
124987
|
} from "fs";
|
|
124066
|
-
import { basename as
|
|
124988
|
+
import { basename as basename10, dirname as dirname27, join as join68, sep as sep3 } from "path";
|
|
124067
124989
|
function isUuid(v) {
|
|
124068
124990
|
return typeof v === "string" && UUID_RE.test(v);
|
|
124069
124991
|
}
|
|
@@ -124213,7 +125135,7 @@ function locateTranscriptByUuid(projectsRoot, uuid) {
|
|
|
124213
125135
|
}
|
|
124214
125136
|
let hit = null;
|
|
124215
125137
|
for (const d of dirs) {
|
|
124216
|
-
const p =
|
|
125138
|
+
const p = join68(projectsRoot, d, `${uuid}.jsonl`);
|
|
124217
125139
|
try {
|
|
124218
125140
|
if (!statSync26(p).isFile())
|
|
124219
125141
|
continue;
|
|
@@ -124268,7 +125190,7 @@ function errText(e) {
|
|
|
124268
125190
|
return e instanceof Error ? e.message : String(e);
|
|
124269
125191
|
}
|
|
124270
125192
|
function openContainedTranscript(path, uuid, projectsRoot) {
|
|
124271
|
-
if (
|
|
125193
|
+
if (basename10(path) !== `${uuid}.jsonl`) {
|
|
124272
125194
|
logRejection(path, "basename is not the session uuid");
|
|
124273
125195
|
return null;
|
|
124274
125196
|
}
|
|
@@ -124708,7 +125630,7 @@ var init_peer_link = __esm(() => {
|
|
|
124708
125630
|
// src/view/replay-registry.ts
|
|
124709
125631
|
import { randomBytes as randomBytes18 } from "crypto";
|
|
124710
125632
|
import { readFileSync as readFileSync52, readdirSync as readdirSync16, renameSync as renameSync13, rmSync as rmSync20, writeFileSync as writeFileSync28 } from "fs";
|
|
124711
|
-
import { join as
|
|
125633
|
+
import { join as join69 } from "path";
|
|
124712
125634
|
function parseEntry(raw) {
|
|
124713
125635
|
let v;
|
|
124714
125636
|
try {
|
|
@@ -124746,14 +125668,14 @@ class ReplayRegistry {
|
|
|
124746
125668
|
constructor(root, log = () => {}) {
|
|
124747
125669
|
this.root = root;
|
|
124748
125670
|
this.log = log;
|
|
124749
|
-
this.dir =
|
|
125671
|
+
this.dir = join69(root, REPLAYS_DIR);
|
|
124750
125672
|
}
|
|
124751
125673
|
ensure() {
|
|
124752
125674
|
ensureSockRoot(this.root);
|
|
124753
125675
|
return ensurePrivateSubdir(this.root, REPLAYS_DIR);
|
|
124754
125676
|
}
|
|
124755
125677
|
lockPathOf(uuid) {
|
|
124756
|
-
return
|
|
125678
|
+
return join69(this.dir, `${this.key(uuid)}.lock`);
|
|
124757
125679
|
}
|
|
124758
125680
|
tryLock(uuid) {
|
|
124759
125681
|
this.ensure();
|
|
@@ -124768,7 +125690,7 @@ class ReplayRegistry {
|
|
|
124768
125690
|
}
|
|
124769
125691
|
async withLock(fn, waitMs = REGISTRY_LOCK_WAIT_MS) {
|
|
124770
125692
|
this.ensure();
|
|
124771
|
-
const lock = await waitAcquire(
|
|
125693
|
+
const lock = await waitAcquire(join69(this.dir, "registry.lock"), waitMs);
|
|
124772
125694
|
if (!lock)
|
|
124773
125695
|
return null;
|
|
124774
125696
|
try {
|
|
@@ -124846,12 +125768,12 @@ class ReplayRegistry {
|
|
|
124846
125768
|
}
|
|
124847
125769
|
for (const name of now)
|
|
124848
125770
|
if (name.endsWith(".tmp"))
|
|
124849
|
-
rmSync20(
|
|
125771
|
+
rmSync20(join69(this.dir, name), { force: true });
|
|
124850
125772
|
});
|
|
124851
125773
|
return swept;
|
|
124852
125774
|
}
|
|
124853
125775
|
entryPathOf(uuid) {
|
|
124854
|
-
return
|
|
125776
|
+
return join69(this.dir, `${this.key(uuid)}.json`);
|
|
124855
125777
|
}
|
|
124856
125778
|
key(uuid) {
|
|
124857
125779
|
const k = uuid.toLowerCase();
|
|
@@ -124872,7 +125794,7 @@ var init_replay_registry = __esm(() => {
|
|
|
124872
125794
|
|
|
124873
125795
|
// src/mcp-session/replay-manager.ts
|
|
124874
125796
|
import { randomBytes as randomBytes19, randomUUID as randomUUID10 } from "crypto";
|
|
124875
|
-
import { constants as constants7, accessSync as accessSync3, closeSync as closeSync20, existsSync as
|
|
125797
|
+
import { constants as constants7, accessSync as accessSync3, closeSync as closeSync20, existsSync as existsSync44, realpathSync as realpathSync11, statSync as statSync28 } from "fs";
|
|
124876
125798
|
import { dirname as dirname28, resolve as resolve11 } from "path";
|
|
124877
125799
|
function unavailable2(reason, message) {
|
|
124878
125800
|
return new ContractErrorException("replay_unavailable", message, reason);
|
|
@@ -125225,7 +126147,7 @@ class ReplayManager {
|
|
|
125225
126147
|
cwd,
|
|
125226
126148
|
projectsRoot,
|
|
125227
126149
|
forkPath,
|
|
125228
|
-
removeProjectDir: !
|
|
126150
|
+
removeProjectDir: !existsSync44(dirname28(forkPath)),
|
|
125229
126151
|
configDir: dirname28(projectsRoot),
|
|
125230
126152
|
cols: size.cols ?? DEFAULT_PANE_COLS,
|
|
125231
126153
|
rows: size.rows ?? DEFAULT_PANE_ROWS
|
|
@@ -126222,7 +127144,7 @@ var init_claude_launch = __esm(() => {
|
|
|
126222
127144
|
import { spawn as spawn4 } from "child_process";
|
|
126223
127145
|
import { mkdirSync as mkdirSync29, mkdtempSync as mkdtempSync4, rmSync as rmSync21, writeFileSync as writeFileSync29 } from "fs";
|
|
126224
127146
|
import { tmpdir as tmpdir3 } from "os";
|
|
126225
|
-
import { join as
|
|
127147
|
+
import { join as join70 } from "path";
|
|
126226
127148
|
function claudeCodePrintArgv(model, systemPromptFile, opts = {}) {
|
|
126227
127149
|
const head = [
|
|
126228
127150
|
PRINT_FLAGS[0],
|
|
@@ -126358,13 +127280,13 @@ async function runPromptViaClaudeCode(model, prompt, systemPrompt, opts = {}) {
|
|
|
126358
127280
|
} catch (e) {
|
|
126359
127281
|
throw new Error(`cannot start claudish (${parentEnv.CLAUDISH_BIN?.trim() || "claudish"}): ${e instanceof Error ? e.message : String(e)}`);
|
|
126360
127282
|
}
|
|
126361
|
-
const root = mkdtempSync4(
|
|
127283
|
+
const root = mkdtempSync4(join70(tmpdir3(), "claudish-run-prompt-"));
|
|
126362
127284
|
try {
|
|
126363
|
-
const cwd =
|
|
127285
|
+
const cwd = join70(root, "cwd");
|
|
126364
127286
|
mkdirSync29(cwd, { mode: 448 });
|
|
126365
127287
|
let systemPromptFile;
|
|
126366
127288
|
if (typeof systemPrompt === "string" && systemPrompt.length > 0) {
|
|
126367
|
-
systemPromptFile =
|
|
127289
|
+
systemPromptFile = join70(root, "system-prompt.txt");
|
|
126368
127290
|
writeFileSync29(systemPromptFile, systemPrompt, { mode: 384 });
|
|
126369
127291
|
}
|
|
126370
127292
|
const argv = claudeCodePrintArgv(model, systemPromptFile, {
|
|
@@ -126475,7 +127397,7 @@ var init_run_prompt_claude_code = __esm(() => {
|
|
|
126475
127397
|
ENV.CLAUDISH_PANE_CHILD
|
|
126476
127398
|
];
|
|
126477
127399
|
inFlight5 = new Set;
|
|
126478
|
-
EMPTY_PRINT_CWD =
|
|
127400
|
+
EMPTY_PRINT_CWD = join70(tmpdir3(), "claudish-run-prompt-settings-check");
|
|
126479
127401
|
});
|
|
126480
127402
|
|
|
126481
127403
|
// src/providers/bundled-list.ts
|
|
@@ -127473,12 +128395,12 @@ var init_view_server = __esm(() => {
|
|
|
127473
128395
|
});
|
|
127474
128396
|
|
|
127475
128397
|
// src/mcp-server.ts
|
|
127476
|
-
import { existsSync as
|
|
127477
|
-
import { homedir as
|
|
127478
|
-
import { dirname as dirname29, join as
|
|
128398
|
+
import { existsSync as existsSync45, readFileSync as readFileSync53, readdirSync as readdirSync17 } from "fs";
|
|
128399
|
+
import { homedir as homedir42 } from "os";
|
|
128400
|
+
import { dirname as dirname29, join as join71, resolve as resolve12 } from "path";
|
|
127479
128401
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
127480
128402
|
async function loadAllModels(forceRefresh = false) {
|
|
127481
|
-
if (!forceRefresh &&
|
|
128403
|
+
if (!forceRefresh && existsSync45(OPENROUTER_MODELS_CACHE_PATH)) {
|
|
127482
128404
|
try {
|
|
127483
128405
|
const cacheData = JSON.parse(readFileSync53(OPENROUTER_MODELS_CACHE_PATH, "utf-8"));
|
|
127484
128406
|
const lastUpdated = new Date(cacheData.lastUpdated);
|
|
@@ -127499,7 +128421,7 @@ async function loadAllModels(forceRefresh = false) {
|
|
|
127499
128421
|
} catch (err) {
|
|
127500
128422
|
log(`[mcp] OpenRouter models fetch failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
127501
128423
|
try {
|
|
127502
|
-
if (
|
|
128424
|
+
if (existsSync45(OPENROUTER_MODELS_CACHE_PATH)) {
|
|
127503
128425
|
const cacheData = JSON.parse(readFileSync53(OPENROUTER_MODELS_CACHE_PATH, "utf-8"));
|
|
127504
128426
|
return cacheData.models || [];
|
|
127505
128427
|
}
|
|
@@ -128769,8 +129691,8 @@ This searched OpenRouter's listing only. Subscription wire ids and catalog alias
|
|
|
128769
129691
|
const promptText = () => {
|
|
128770
129692
|
if (input !== undefined)
|
|
128771
129693
|
return input;
|
|
128772
|
-
const existing =
|
|
128773
|
-
return
|
|
129694
|
+
const existing = join71(resolved, "input.md");
|
|
129695
|
+
return existsSync45(existing) ? readFileSync53(existing, "utf-8") : undefined;
|
|
128774
129696
|
};
|
|
128775
129697
|
const choice = await modelChoiceStop([
|
|
128776
129698
|
...runsModels && givenModels && models ? givenModels.map((given, i) => ({ given, spec: models[i] })) : [],
|
|
@@ -128954,16 +129876,16 @@ This searched OpenRouter's listing only. Subscription wire ids and catalog alias
|
|
|
128954
129876
|
const sp = session_path;
|
|
128955
129877
|
for (const file of ["status.json", "manifest.json", "input.md"]) {
|
|
128956
129878
|
try {
|
|
128957
|
-
sessionData[file] = readFileSync53(
|
|
129879
|
+
sessionData[file] = readFileSync53(join71(sp, file), "utf-8");
|
|
128958
129880
|
} catch {}
|
|
128959
129881
|
}
|
|
128960
129882
|
try {
|
|
128961
|
-
const errorDir =
|
|
128962
|
-
if (
|
|
129883
|
+
const errorDir = join71(sp, "errors");
|
|
129884
|
+
if (existsSync45(errorDir)) {
|
|
128963
129885
|
for (const f of readdirSync17(errorDir)) {
|
|
128964
129886
|
if (f.endsWith(".log")) {
|
|
128965
129887
|
try {
|
|
128966
|
-
sessionData[`errors/${f}`] = readFileSync53(
|
|
129888
|
+
sessionData[`errors/${f}`] = readFileSync53(join71(errorDir, f), "utf-8");
|
|
128967
129889
|
} catch {}
|
|
128968
129890
|
}
|
|
128969
129891
|
}
|
|
@@ -128973,7 +129895,7 @@ This searched OpenRouter's listing only. Subscription wire ids and catalog alias
|
|
|
128973
129895
|
for (const f of readdirSync17(sp)) {
|
|
128974
129896
|
if (f.startsWith("response-") && f.endsWith(".md")) {
|
|
128975
129897
|
try {
|
|
128976
|
-
const content = readFileSync53(
|
|
129898
|
+
const content = readFileSync53(join71(sp, f), "utf-8");
|
|
128977
129899
|
sessionData[f] = content.slice(0, 200) + (content.length > 200 ? "... (truncated)" : "");
|
|
128978
129900
|
} catch {}
|
|
128979
129901
|
}
|
|
@@ -128982,8 +129904,8 @@ This searched OpenRouter's listing only. Subscription wire ids and catalog alias
|
|
|
128982
129904
|
}
|
|
128983
129905
|
let version = "unknown";
|
|
128984
129906
|
try {
|
|
128985
|
-
const pkgPath =
|
|
128986
|
-
if (
|
|
129907
|
+
const pkgPath = join71(__dirname3, "../package.json");
|
|
129908
|
+
if (existsSync45(pkgPath)) {
|
|
128987
129909
|
version = JSON.parse(readFileSync53(pkgPath, "utf-8")).version;
|
|
128988
129910
|
}
|
|
128989
129911
|
} catch {}
|
|
@@ -129787,8 +130709,8 @@ var init_mcp_server = __esm(() => {
|
|
|
129787
130709
|
init_preflight_chain();
|
|
129788
130710
|
__filename3 = fileURLToPath3(import.meta.url);
|
|
129789
130711
|
__dirname3 = dirname29(__filename3);
|
|
129790
|
-
CLAUDISH_CACHE_DIR =
|
|
129791
|
-
OPENROUTER_MODELS_CACHE_PATH =
|
|
130712
|
+
CLAUDISH_CACHE_DIR = join71(homedir42(), ".claudish");
|
|
130713
|
+
OPENROUTER_MODELS_CACHE_PATH = join71(CLAUDISH_CACHE_DIR, "openrouter-models.json");
|
|
129792
130714
|
NEXT_STEP = {
|
|
129793
130715
|
cancelled: "you stopped this slot; nothing is wrong with it. Re-run it if you still want its vote",
|
|
129794
130716
|
timeout: "grid mode only \u2014 magmux ended the pane. The orchestrator has no deadline",
|
|
@@ -129815,7 +130737,7 @@ var init_mcp_server = __esm(() => {
|
|
|
129815
130737
|
});
|
|
129816
130738
|
|
|
129817
130739
|
// src/serve-command.ts
|
|
129818
|
-
import { existsSync as
|
|
130740
|
+
import { existsSync as existsSync46, readFileSync as readFileSync54 } from "fs";
|
|
129819
130741
|
function parseServeArgs(args) {
|
|
129820
130742
|
const out = {};
|
|
129821
130743
|
for (let i = 0;i < args.length; i++) {
|
|
@@ -129834,7 +130756,7 @@ function parseServeArgs(args) {
|
|
|
129834
130756
|
return out;
|
|
129835
130757
|
}
|
|
129836
130758
|
function loadModelMap(path) {
|
|
129837
|
-
if (!
|
|
130759
|
+
if (!existsSync46(path)) {
|
|
129838
130760
|
throw new Error(`--models file not found: ${path}`);
|
|
129839
130761
|
}
|
|
129840
130762
|
let raw;
|
|
@@ -129951,8 +130873,8 @@ var HOOKS_AMBIENT_DTS = '// claudish hook types \u2014 written by `claudish hook
|
|
|
129951
130873
|
|
|
129952
130874
|
// src/hooks/observer/corpus.ts
|
|
129953
130875
|
import { appendFileSync as appendFileSync8, readFileSync as readFileSync55, readdirSync as readdirSync18, statSync as statSync29 } from "fs";
|
|
129954
|
-
import { homedir as
|
|
129955
|
-
import { join as
|
|
130876
|
+
import { homedir as homedir43 } from "os";
|
|
130877
|
+
import { join as join72 } from "path";
|
|
129956
130878
|
function directoryOf2(filePath) {
|
|
129957
130879
|
const slash = filePath.lastIndexOf("/");
|
|
129958
130880
|
return slash > 0 ? filePath.slice(0, slash) : undefined;
|
|
@@ -130031,13 +130953,13 @@ function listTranscripts(root) {
|
|
|
130031
130953
|
return files;
|
|
130032
130954
|
}
|
|
130033
130955
|
for (const project of projects) {
|
|
130034
|
-
const dir =
|
|
130956
|
+
const dir = join72(root, project);
|
|
130035
130957
|
try {
|
|
130036
130958
|
if (!statSync29(dir).isDirectory())
|
|
130037
130959
|
continue;
|
|
130038
130960
|
for (const f of readdirSync18(dir)) {
|
|
130039
130961
|
if (f.endsWith(".jsonl"))
|
|
130040
|
-
files.push(
|
|
130962
|
+
files.push(join72(dir, f));
|
|
130041
130963
|
}
|
|
130042
130964
|
} catch {}
|
|
130043
130965
|
}
|
|
@@ -130050,7 +130972,7 @@ function buildCorpus(options = {}) {
|
|
|
130050
130972
|
for (const f of files)
|
|
130051
130973
|
records.push(...replayTranscript(f));
|
|
130052
130974
|
if (options.write && records.length > 0) {
|
|
130053
|
-
const outputPath = options.outputPath ??
|
|
130975
|
+
const outputPath = options.outputPath ?? join72(homedir43(), ".claudish", "behavior-divergences.jsonl");
|
|
130054
130976
|
try {
|
|
130055
130977
|
appendFileSync8(outputPath, `${records.map((r) => JSON.stringify(r)).join(`
|
|
130056
130978
|
`)}
|
|
@@ -130067,9 +130989,9 @@ var init_corpus = __esm(() => {
|
|
|
130067
130989
|
});
|
|
130068
130990
|
|
|
130069
130991
|
// src/hooks-command.ts
|
|
130070
|
-
import { existsSync as
|
|
130071
|
-
import { homedir as
|
|
130072
|
-
import { join as
|
|
130992
|
+
import { existsSync as existsSync47, mkdirSync as mkdirSync30, readFileSync as readFileSync56, writeFileSync as writeFileSync30 } from "fs";
|
|
130993
|
+
import { homedir as homedir44 } from "os";
|
|
130994
|
+
import { join as join73, resolve as resolve13 } from "path";
|
|
130073
130995
|
function severityColor(sev) {
|
|
130074
130996
|
if (sev === "fix")
|
|
130075
130997
|
return green(sev);
|
|
@@ -130192,12 +131114,12 @@ async function check(file, json) {
|
|
|
130192
131114
|
return valid ? 0 : 1;
|
|
130193
131115
|
}
|
|
130194
131116
|
function init(dirArg) {
|
|
130195
|
-
const dir = dirArg ? resolve13(process.cwd(), dirArg) :
|
|
131117
|
+
const dir = dirArg ? resolve13(process.cwd(), dirArg) : join73(homedir44(), ".claudish", "hooks");
|
|
130196
131118
|
const files = [
|
|
130197
|
-
[
|
|
130198
|
-
[
|
|
131119
|
+
[join73(dir, "example-hook.ts"), EXAMPLE_HOOK],
|
|
131120
|
+
[join73(dir, "claudish-hooks.d.ts"), HOOKS_AMBIENT_DTS]
|
|
130199
131121
|
];
|
|
130200
|
-
const existing = files.filter(([path]) =>
|
|
131122
|
+
const existing = files.filter(([path]) => existsSync47(path)).map(([path]) => path);
|
|
130201
131123
|
if (existing.length > 0) {
|
|
130202
131124
|
for (const path of existing)
|
|
130203
131125
|
console.error(`${path} already exists; not overwriting it.`);
|
|
@@ -130287,7 +131209,7 @@ function telemetry(action, json) {
|
|
|
130287
131209
|
let pending = 0;
|
|
130288
131210
|
try {
|
|
130289
131211
|
const path = outboxPath();
|
|
130290
|
-
if (
|
|
131212
|
+
if (existsSync47(path))
|
|
130291
131213
|
pending = readFileSync56(path, "utf8").split(`
|
|
130292
131214
|
`).filter(Boolean).length;
|
|
130293
131215
|
} catch {}
|
|
@@ -130396,9 +131318,9 @@ var init_hooks_command = __esm(() => {
|
|
|
130396
131318
|
|
|
130397
131319
|
// src/team-grid.ts
|
|
130398
131320
|
import { spawn as spawn5 } from "child_process";
|
|
130399
|
-
import { existsSync as
|
|
131321
|
+
import { existsSync as existsSync48, readFileSync as readFileSync57, writeFileSync as writeFileSync31 } from "fs";
|
|
130400
131322
|
import { connect as netConnect3 } from "net";
|
|
130401
|
-
import { join as
|
|
131323
|
+
import { join as join74 } from "path";
|
|
130402
131324
|
import { setTimeout as wait } from "timers/promises";
|
|
130403
131325
|
function paneRouteLine(explanation) {
|
|
130404
131326
|
const origin = describeRouteExplanation(explanation);
|
|
@@ -130453,7 +131375,7 @@ function withoutControlPanes(evt) {
|
|
|
130453
131375
|
async function subscribeToMagmux(sockPath, onEvent) {
|
|
130454
131376
|
let client = null;
|
|
130455
131377
|
for (let attempt = 0;attempt < 40; attempt++) {
|
|
130456
|
-
if (
|
|
131378
|
+
if (existsSync48(sockPath)) {
|
|
130457
131379
|
try {
|
|
130458
131380
|
client = await new Promise((resolve, reject) => {
|
|
130459
131381
|
const s = netConnect3(sockPath);
|
|
@@ -130548,9 +131470,9 @@ async function runWithGrid(sessionPath, models, input, opts) {
|
|
|
130548
131470
|
const keep = opts?.keep ?? false;
|
|
130549
131471
|
const manifest = setupSession(sessionPath, models, input);
|
|
130550
131472
|
const startedAt = new Date().toISOString();
|
|
130551
|
-
const gridfilePath =
|
|
130552
|
-
const prompt = readFileSync57(
|
|
130553
|
-
const rawPrompt = readFileSync57(
|
|
131473
|
+
const gridfilePath = join74(sessionPath, "gridfile.txt");
|
|
131474
|
+
const prompt = readFileSync57(join74(sessionPath, "input.md"), "utf-8").replace(/'/g, "'\\''").replace(/\n/g, " ");
|
|
131475
|
+
const rawPrompt = readFileSync57(join74(sessionPath, "input.md"), "utf-8");
|
|
130554
131476
|
const usedBannerColors = new Set;
|
|
130555
131477
|
const routeLines = mode === "interactive" ? new Map : await resolvePaneRouteLines(Object.values(manifest.models).map((entry) => entry.model));
|
|
130556
131478
|
const gridLines = Object.entries(manifest.models).map(([anonId]) => {
|
|
@@ -130582,7 +131504,7 @@ async function runWithGrid(sessionPath, models, input, opts) {
|
|
|
130582
131504
|
});
|
|
130583
131505
|
const [{ results }] = await Promise.all([subscription, procExit]);
|
|
130584
131506
|
const status = buildTeamStatus(manifest, startedAt, results?.panes ?? null);
|
|
130585
|
-
const statusPath =
|
|
131507
|
+
const statusPath = join74(sessionPath, "status.json");
|
|
130586
131508
|
writeFileSync31(statusPath, JSON.stringify(status, null, 2), "utf-8");
|
|
130587
131509
|
return status;
|
|
130588
131510
|
}
|
|
@@ -130603,7 +131525,7 @@ var init_team_grid = __esm(() => {
|
|
|
130603
131525
|
|
|
130604
131526
|
// src/team-cli.ts
|
|
130605
131527
|
import { readFileSync as readFileSync58 } from "fs";
|
|
130606
|
-
import { join as
|
|
131528
|
+
import { join as join75 } from "path";
|
|
130607
131529
|
async function runPaneTeam(sessionPath, models, input, opts) {
|
|
130608
131530
|
installPaneShutdownHooks({ exitAfter: true });
|
|
130609
131531
|
try {
|
|
@@ -130748,7 +131670,7 @@ async function teamCommand(args) {
|
|
|
130748
131670
|
}
|
|
130749
131671
|
case "judge": {
|
|
130750
131672
|
await judgeResponses(sessionPath, { judges });
|
|
130751
|
-
console.log(readFileSync58(
|
|
131673
|
+
console.log(readFileSync58(join75(sessionPath, "verdict.md"), "utf-8"));
|
|
130752
131674
|
break;
|
|
130753
131675
|
}
|
|
130754
131676
|
case "run-and-judge": {
|
|
@@ -130764,7 +131686,7 @@ async function teamCommand(args) {
|
|
|
130764
131686
|
});
|
|
130765
131687
|
printStatus(status);
|
|
130766
131688
|
await judgeResponses(sessionPath, { judges });
|
|
130767
|
-
console.log(readFileSync58(
|
|
131689
|
+
console.log(readFileSync58(join75(sessionPath, "verdict.md"), "utf-8"));
|
|
130768
131690
|
break;
|
|
130769
131691
|
}
|
|
130770
131692
|
case "status": {
|
|
@@ -132446,9 +133368,9 @@ var init_view_cli = __esm(() => {
|
|
|
132446
133368
|
|
|
132447
133369
|
// src/herdr/herdr-cli.ts
|
|
132448
133370
|
import { spawnSync as spawnSync3 } from "child_process";
|
|
132449
|
-
import { copyFileSync as copyFileSync3, existsSync as
|
|
132450
|
-
import { homedir as
|
|
132451
|
-
import { dirname as dirname30, join as
|
|
133371
|
+
import { copyFileSync as copyFileSync3, existsSync as existsSync49, mkdirSync as mkdirSync31, readdirSync as readdirSync19, renameSync as renameSync14, statSync as statSync30 } from "fs";
|
|
133372
|
+
import { homedir as homedir45 } from "os";
|
|
133373
|
+
import { dirname as dirname30, join as join76, resolve as resolve14 } from "path";
|
|
132452
133374
|
function spawnHerdrApp(args) {
|
|
132453
133375
|
const r = spawnSync3("herdr-app", args, { encoding: "utf-8", timeout: 1e4 });
|
|
132454
133376
|
if (r.error)
|
|
@@ -132490,8 +133412,8 @@ function showPanelCommand(rest, out, deps) {
|
|
|
132490
133412
|
function findBuiltAppMod(from = import.meta.dir) {
|
|
132491
133413
|
let dir = from;
|
|
132492
133414
|
for (let i = 0;i < 5; i++) {
|
|
132493
|
-
const candidate =
|
|
132494
|
-
if (
|
|
133415
|
+
const candidate = join76(dir, BUILT_MOD_DIR);
|
|
133416
|
+
if (existsSync49(join76(candidate, "main.js")) && existsSync49(join76(candidate, "mod.json")))
|
|
132495
133417
|
return candidate;
|
|
132496
133418
|
const up = dirname30(dir);
|
|
132497
133419
|
if (up === dir)
|
|
@@ -132504,24 +133426,24 @@ function herdrAppHome(env) {
|
|
|
132504
133426
|
const given = env.HERDR_APP_HOME?.trim();
|
|
132505
133427
|
if (given)
|
|
132506
133428
|
return resolve14(given);
|
|
132507
|
-
return
|
|
133429
|
+
return join76(env.HOME?.trim() || homedir45(), ".config", "herdr-app");
|
|
132508
133430
|
}
|
|
132509
133431
|
function isModFile(name) {
|
|
132510
133432
|
return !name.startsWith(".") && name !== "jsconfig.json" && !name.endsWith(".d.ts");
|
|
132511
133433
|
}
|
|
132512
133434
|
function installAppMod(source, appHome) {
|
|
132513
|
-
if (!
|
|
133435
|
+
if (!existsSync49(join76(source, "main.js")) || !existsSync49(join76(source, "mod.json")))
|
|
132514
133436
|
throw new Error(`${source} holds no built mod (main.js and mod.json); run \`bun run build\``);
|
|
132515
|
-
if (!
|
|
133437
|
+
if (!existsSync49(appHome) || !statSync30(appHome).isDirectory())
|
|
132516
133438
|
throw new Error(`${appHome} does not exist: start Herdr.app once so it creates its home, then run this again`);
|
|
132517
|
-
const dest =
|
|
133439
|
+
const dest = join76(appHome, "mods", APP_MOD_NAME);
|
|
132518
133440
|
mkdirSync31(dest, { recursive: true });
|
|
132519
|
-
const files = readdirSync19(source).filter((f) => isModFile(f) && statSync30(
|
|
133441
|
+
const files = readdirSync19(source).filter((f) => isModFile(f) && statSync30(join76(source, f)).isFile());
|
|
132520
133442
|
files.sort((a, b) => a === "mod.json" ? -1 : b === "mod.json" ? 1 : a.localeCompare(b));
|
|
132521
133443
|
for (const f of files) {
|
|
132522
|
-
const hidden =
|
|
132523
|
-
copyFileSync3(
|
|
132524
|
-
renameSync14(hidden,
|
|
133444
|
+
const hidden = join76(dest, `.${f}.installing`);
|
|
133445
|
+
copyFileSync3(join76(source, f), hidden);
|
|
133446
|
+
renameSync14(hidden, join76(dest, f));
|
|
132525
133447
|
}
|
|
132526
133448
|
return dest;
|
|
132527
133449
|
}
|
|
@@ -132599,7 +133521,7 @@ var init_herdr_cli = __esm(() => {
|
|
|
132599
133521
|
""
|
|
132600
133522
|
].join(`
|
|
132601
133523
|
`);
|
|
132602
|
-
BUILT_MOD_DIR =
|
|
133524
|
+
BUILT_MOD_DIR = join76("herdr-app-mod", APP_MOD_NAME);
|
|
132603
133525
|
});
|
|
132604
133526
|
|
|
132605
133527
|
// src/auth/credentials/source.ts
|
|
@@ -134831,9 +135753,9 @@ var init_account_command = __esm(() => {
|
|
|
134831
135753
|
|
|
134832
135754
|
// src/auth/antigravity-oauth.ts
|
|
134833
135755
|
import { spawnSync as spawnSync4 } from "child_process";
|
|
134834
|
-
import { existsSync as
|
|
134835
|
-
import { homedir as
|
|
134836
|
-
import { join as
|
|
135756
|
+
import { existsSync as existsSync50, unlinkSync as unlinkSync14 } from "fs";
|
|
135757
|
+
import { homedir as homedir46 } from "os";
|
|
135758
|
+
import { join as join77 } from "path";
|
|
134837
135759
|
async function defaultSuggestModel() {
|
|
134838
135760
|
try {
|
|
134839
135761
|
const token = await getValidAntigravityAccessToken();
|
|
@@ -134952,8 +135874,8 @@ No session detected yet. Starting the Antigravity CLI interactively \u2014
|
|
|
134952
135874
|
async logout(deps) {
|
|
134953
135875
|
deleteSharedAntigravityToken(deps);
|
|
134954
135876
|
try {
|
|
134955
|
-
const tokenFile =
|
|
134956
|
-
if (
|
|
135877
|
+
const tokenFile = join77(homedir46(), ".gemini", "antigravity-cli", "antigravity-oauth-token");
|
|
135878
|
+
if (existsSync50(tokenFile))
|
|
134957
135879
|
unlinkSync14(tokenFile);
|
|
134958
135880
|
} catch {}
|
|
134959
135881
|
log("[AntigravityOAuth] Antigravity session cleared (keychain + agy token file)");
|
|
@@ -143859,17 +144781,17 @@ var init_model_lineup = __esm(() => {
|
|
|
143859
144781
|
|
|
143860
144782
|
// src/diag-output.ts
|
|
143861
144783
|
import { createWriteStream as createWriteStream2, mkdirSync as mkdirSync32, unlinkSync as unlinkSync15, writeFileSync as writeFileSync32 } from "fs";
|
|
143862
|
-
import { homedir as
|
|
143863
|
-
import { join as
|
|
144784
|
+
import { homedir as homedir47 } from "os";
|
|
144785
|
+
import { join as join78 } from "path";
|
|
143864
144786
|
function getClaudishDir() {
|
|
143865
|
-
const dir =
|
|
144787
|
+
const dir = join78(homedir47(), ".claudish");
|
|
143866
144788
|
try {
|
|
143867
144789
|
mkdirSync32(dir, { recursive: true });
|
|
143868
144790
|
} catch {}
|
|
143869
144791
|
return dir;
|
|
143870
144792
|
}
|
|
143871
144793
|
function getDiagLogPath() {
|
|
143872
|
-
return
|
|
144794
|
+
return join78(getClaudishDir(), `diag-${process.pid}.log`);
|
|
143873
144795
|
}
|
|
143874
144796
|
|
|
143875
144797
|
class LogFileDiagOutput {
|
|
@@ -145960,11 +146882,11 @@ var init_resume_picker_run = __esm(() => {
|
|
|
145960
146882
|
});
|
|
145961
146883
|
|
|
145962
146884
|
// src/launcher/model-setting-ledger-path.ts
|
|
145963
|
-
import { homedir as
|
|
145964
|
-
import { join as
|
|
146885
|
+
import { homedir as homedir48 } from "os";
|
|
146886
|
+
import { join as join79 } from "path";
|
|
145965
146887
|
function modelSettingLedgerPath(env = process.env) {
|
|
145966
|
-
const home = env.HOME && env.HOME.length > 0 ? env.HOME :
|
|
145967
|
-
return
|
|
146888
|
+
const home = env.HOME && env.HOME.length > 0 ? env.HOME : homedir48();
|
|
146889
|
+
return join79(home, ".claudish", MODEL_SETTING_LEDGER_FILE);
|
|
145968
146890
|
}
|
|
145969
146891
|
var MODEL_SETTING_LEDGER_FILE = "model-setting-restore.json";
|
|
145970
146892
|
var init_model_setting_ledger_path = () => {};
|
|
@@ -145985,19 +146907,19 @@ import {
|
|
|
145985
146907
|
unlinkSync as unlinkSync16,
|
|
145986
146908
|
writeSync as writeSync8
|
|
145987
146909
|
} from "fs";
|
|
145988
|
-
import { homedir as
|
|
145989
|
-
import { basename as
|
|
146910
|
+
import { homedir as homedir49 } from "os";
|
|
146911
|
+
import { basename as basename11, dirname as dirname31, join as join80, resolve as resolve15 } from "path";
|
|
145990
146912
|
function canonicalSettingsPath(path) {
|
|
145991
146913
|
let head = resolve15(path);
|
|
145992
146914
|
const rest = [];
|
|
145993
146915
|
for (;; ) {
|
|
145994
146916
|
try {
|
|
145995
|
-
return
|
|
146917
|
+
return join80(realpathSync12.native(head), ...rest);
|
|
145996
146918
|
} catch {
|
|
145997
146919
|
const parent = dirname31(head);
|
|
145998
146920
|
if (parent === head)
|
|
145999
|
-
return
|
|
146000
|
-
rest.unshift(
|
|
146921
|
+
return join80(head, ...rest);
|
|
146922
|
+
rest.unshift(basename11(head));
|
|
146001
146923
|
head = parent;
|
|
146002
146924
|
}
|
|
146003
146925
|
}
|
|
@@ -146092,7 +147014,7 @@ function restoreRound(settingsKey, target, entry, deps, fence) {
|
|
|
146092
147014
|
const planned = nextSettingsText(text, entry);
|
|
146093
147015
|
if ("outcome" in planned)
|
|
146094
147016
|
return planned.outcome;
|
|
146095
|
-
const temp =
|
|
147017
|
+
const temp = join80(dirname31(target), `${TEMP_PREFIX}${deps.pid ?? process.pid}-${randomUUID12()}`);
|
|
146096
147018
|
try {
|
|
146097
147019
|
deps.writeNew(temp, planned.next, statA.mode & 4095);
|
|
146098
147020
|
} catch {
|
|
@@ -146284,7 +147206,7 @@ function removeOrphanTemps(ctx, key, table) {
|
|
|
146284
147206
|
if (live)
|
|
146285
147207
|
continue;
|
|
146286
147208
|
try {
|
|
146287
|
-
unlinkSync16(
|
|
147209
|
+
unlinkSync16(join80(dir, name));
|
|
146288
147210
|
} catch {}
|
|
146289
147211
|
}
|
|
146290
147212
|
}
|
|
@@ -146375,7 +147297,7 @@ function selfStartEpochMs() {
|
|
|
146375
147297
|
async function beginModelSettingWatch(listedSpecs, deps = {}) {
|
|
146376
147298
|
const ctx = contextOf(deps);
|
|
146377
147299
|
const env = deps.env ?? process.env;
|
|
146378
|
-
const settingsFile = deps.settingsFile ?? userSettingsFile(env.CLAUDE_CONFIG_DIR, env.HOME && env.HOME.length > 0 ? env.HOME :
|
|
147300
|
+
const settingsFile = deps.settingsFile ?? userSettingsFile(env.CLAUDE_CONFIG_DIR, env.HOME && env.HOME.length > 0 ? env.HOME : homedir49(), deps.cwd ?? process.cwd());
|
|
146379
147301
|
const key = canonicalSettingsPath(settingsFile);
|
|
146380
147302
|
const lockPath = lockPathOf(ctx.ledgerPath);
|
|
146381
147303
|
const lockOpts = {
|
|
@@ -146990,8 +147912,8 @@ init_launch_env();
|
|
|
146990
147912
|
init_op_source();
|
|
146991
147913
|
init_startup_trace();
|
|
146992
147914
|
init_picker_cancelled();
|
|
146993
|
-
import { existsSync as
|
|
146994
|
-
import { join as
|
|
147915
|
+
import { existsSync as existsSync51, readFileSync as readFileSync61 } from "fs";
|
|
147916
|
+
import { join as join81, resolve as resolve16 } from "path";
|
|
146995
147917
|
|
|
146996
147918
|
// src/tui/runtime/should-open-picker.ts
|
|
146997
147919
|
function noModelConfigured(gate) {
|
|
@@ -147008,7 +147930,7 @@ function requiresExplicitModel(gate, tty) {
|
|
|
147008
147930
|
var autoloadDropped = [...droppedAtLaunch, ...takeLauncherDropped(process.env)];
|
|
147009
147931
|
var dotenvText;
|
|
147010
147932
|
try {
|
|
147011
|
-
dotenvText = readFileSync61(
|
|
147933
|
+
dotenvText = readFileSync61(join81(process.cwd(), ".env"));
|
|
147012
147934
|
} catch {}
|
|
147013
147935
|
if (dotenvText !== undefined) {
|
|
147014
147936
|
await Promise.resolve().then(() => init_dotenv_allowlist());
|
|
@@ -147126,7 +148048,7 @@ async function applyConfigOverride() {
|
|
|
147126
148048
|
await Promise.resolve();
|
|
147127
148049
|
const plan = planConfigOverride(process.argv.slice(2), process.env, {
|
|
147128
148050
|
resolve: resolve16,
|
|
147129
|
-
exists:
|
|
148051
|
+
exists: existsSync51
|
|
147130
148052
|
});
|
|
147131
148053
|
if (plan.kind === "none")
|
|
147132
148054
|
return;
|
|
@@ -147414,7 +148336,7 @@ async function runCli() {
|
|
|
147414
148336
|
process.exit(1);
|
|
147415
148337
|
}
|
|
147416
148338
|
const mode = cliConfig.teamMode ?? "default";
|
|
147417
|
-
const sessionPath =
|
|
148339
|
+
const sessionPath = join81(process.cwd(), `.claudish-team-${Date.now()}`);
|
|
147418
148340
|
if (mode === "json") {
|
|
147419
148341
|
await Promise.resolve().then(() => init_pane());
|
|
147420
148342
|
await Promise.resolve().then(() => init_team_orchestrator());
|
|
@@ -147434,7 +148356,7 @@ async function runCli() {
|
|
|
147434
148356
|
const status = await runModels(sessionPath);
|
|
147435
148357
|
const result = { ...status, responses: {} };
|
|
147436
148358
|
for (const anonId of Object.keys(status.models)) {
|
|
147437
|
-
const responsePath =
|
|
148359
|
+
const responsePath = join81(sessionPath, `response-${anonId}.md`);
|
|
147438
148360
|
try {
|
|
147439
148361
|
const raw = readFileSync61(responsePath, "utf-8").trim();
|
|
147440
148362
|
try {
|