@chibitek/chibi 0.1.206 → 0.1.208
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/assets/{TerminalPanel-BBJ8EeT7.js → TerminalPanel-B5bwdaJ5.js} +1 -1
- package/dist/assets/{abnfDiagram-O67JEVCF-a06YszXx.js → abnfDiagram-O67JEVCF-BLKuHvdS.js} +1 -1
- package/dist/assets/{arc-Fe3WbFfc.js → arc-BeOf3Y3d.js} +1 -1
- package/dist/assets/{architectureDiagram-NJMV4G6O-DYcb0ZrL.js → architectureDiagram-NJMV4G6O-DnXr729a.js} +1 -1
- package/dist/assets/{blockDiagram-BEXU5L5S-xC5y8We2.js → blockDiagram-BEXU5L5S-CEiwrTaI.js} +1 -1
- package/dist/assets/{c4Diagram-YGBWAQC7-Dm81dUJa.js → c4Diagram-YGBWAQC7-C0-29khR.js} +1 -1
- package/dist/assets/channel-_JFliC5C.js +1 -0
- package/dist/assets/{chunk-2Q5K7J3B-CDVJUGUd.js → chunk-2Q5K7J3B-D8dKbbui.js} +1 -1
- package/dist/assets/{chunk-3FUC2YCW-BvPx7oJb.js → chunk-3FUC2YCW-fAEY1oOe.js} +2 -2
- package/dist/assets/{chunk-5VM5RSS4-kUQxxDSH.js → chunk-5VM5RSS4-Djza4B4b.js} +1 -1
- package/dist/assets/{chunk-GTNCS2PH-hmSLPBzT.js → chunk-GTNCS2PH-BWFGSXNt.js} +1 -1
- package/dist/assets/{chunk-GWA4HPMP-ivlnCC25.js → chunk-GWA4HPMP-BGo5oevY.js} +1 -1
- package/dist/assets/{chunk-JWPE2WC7-hjxL5olg.js → chunk-JWPE2WC7-DIdxOMOn.js} +1 -1
- package/dist/assets/{chunk-NETBCI7D-ClgHcSe7.js → chunk-NETBCI7D-Dc4tJ9uD.js} +1 -1
- package/dist/assets/{chunk-WEXAMYUT-1i-fNDpg.js → chunk-WEXAMYUT-DvZ9F5yw.js} +1 -1
- package/dist/assets/{chunk-XXDRQBXY-BhPdm5u4.js → chunk-XXDRQBXY-BYUVYcxq.js} +1 -1
- package/dist/assets/{classDiagram-v2-NBCMYWYE-BsL-gKkF.js → classDiagram-v2-NBCMYWYE-BtnsJQvT.js} +1 -1
- package/dist/assets/{cose-bilkent-JH36ORCC-piSPlA0p.js → cose-bilkent-JH36ORCC-DLDe1VHc.js} +1 -1
- package/dist/assets/{cynefin-OW5HDTMX-D2T5q7wD.js → cynefin-OW5HDTMX-a1GJE5iI.js} +1 -1
- package/dist/assets/{cynefinDiagram-VND7K2PF-CWHt2804.js → cynefinDiagram-VND7K2PF-DXxGLDlQ.js} +1 -1
- package/dist/assets/{dagre-6A5THRUB-BNioVBDz.js → dagre-6A5THRUB-DAW_YZe9.js} +1 -1
- package/dist/assets/{diagram-22UHCM2B-DULW9a3n.js → diagram-22UHCM2B-oq3saywD.js} +1 -1
- package/dist/assets/{diagram-3UASUU5V-EYvilvye.js → diagram-3UASUU5V-BhCP3hS9.js} +1 -1
- package/dist/assets/{diagram-ATOU4E4O-BRkFLoxi.js → diagram-ATOU4E4O-ByFRn1dW.js} +1 -1
- package/dist/assets/{diagram-CDSNMT55-B0IbbTpB.js → diagram-CDSNMT55-DWoCvkNH.js} +1 -1
- package/dist/assets/{diagram-MLGK6HIB-u7n_3e2v.js → diagram-MLGK6HIB-CSH5kSlk.js} +1 -1
- package/dist/assets/{diagram-MPIPVDR6-NegomnHr.js → diagram-MPIPVDR6-Cnpx1s-T.js} +1 -1
- package/dist/assets/{ebnfDiagram-ZINNZB2B-BPZmiseK.js → ebnfDiagram-ZINNZB2B-DPmX63Vg.js} +1 -1
- package/dist/assets/{elk-276RUBZZ-BcBEThvp.js → elk-276RUBZZ-DUtmO9kb.js} +1 -1
- package/dist/assets/{erDiagram-OPXOYQCR-BVAGByE5.js → erDiagram-OPXOYQCR-SxwJeJu-.js} +1 -1
- package/dist/assets/{flowDiagram-KWPJA3E3-ByZ1IyAE.js → flowDiagram-KWPJA3E3--QZAAUjB.js} +1 -1
- package/dist/assets/{ganttDiagram-FUAMR5RP-CEa3O2pJ.js → ganttDiagram-FUAMR5RP-CRz6i2Pe.js} +1 -1
- package/dist/assets/{gitGraphDiagram-X574FWY7-dul-ZoaX.js → gitGraphDiagram-X574FWY7-Dx9Cisl2.js} +1 -1
- package/dist/assets/{index-CFUbzTrj.js → index-BGkOob08.js} +1 -1
- package/dist/assets/{index-Tw4-5a-J.js → index-vIsgWbJW.js} +153 -153
- package/dist/assets/{infoDiagram-VRGFBTTK-Bt9KS597.js → infoDiagram-VRGFBTTK-CDLogk8N.js} +1 -1
- package/dist/assets/{ishikawaDiagram-OU5B5YK6-BjJTuEjh.js → ishikawaDiagram-OU5B5YK6-DsrF1wno.js} +1 -1
- package/dist/assets/{journeyDiagram-ZHPQQLJL-j07hDjg4.js → journeyDiagram-ZHPQQLJL-DUi8LEA6.js} +1 -1
- package/dist/assets/{kanban-definition-PNTS6WVX-DU8baSEs.js → kanban-definition-PNTS6WVX-BAdWXobw.js} +1 -1
- package/dist/assets/{linear-Dj1tr9Bh.js → linear-Dha948ns.js} +1 -1
- package/dist/assets/{mermaid.core-BeSGZMCl.js → mermaid.core-BqT1aUP9.js} +5 -5
- package/dist/assets/{mindmap-definition-NLK3R4M7-LiRl-Bq2.js → mindmap-definition-NLK3R4M7-XS1wDQ80.js} +1 -1
- package/dist/assets/{pegDiagram-GJSIUBJH-COL7EWof.js → pegDiagram-GJSIUBJH-BphuafcF.js} +1 -1
- package/dist/assets/{pieDiagram-5QR66LMP-BnMXaara.js → pieDiagram-5QR66LMP-JN9mbdiU.js} +1 -1
- package/dist/assets/{quadrantDiagram-O4NWA36T-BjLcZ6bG.js → quadrantDiagram-O4NWA36T-CkBF7Woa.js} +1 -1
- package/dist/assets/{railroadDiagram-XR7U4H2S-wKCzKLAA.js → railroadDiagram-XR7U4H2S-Ie1GVpj5.js} +1 -1
- package/dist/assets/{requirementDiagram-PLB6GJNP-BjoTwmZ-.js → requirementDiagram-PLB6GJNP-B8xGM6w4.js} +1 -1
- package/dist/assets/{sankeyDiagram-IPEJSGJF-CuGyR0Tn.js → sankeyDiagram-IPEJSGJF-BgTSlqMg.js} +1 -1
- package/dist/assets/{sequenceDiagram-PO4LG4MO-DxOzUuSx.js → sequenceDiagram-PO4LG4MO-B1J4EIne.js} +1 -1
- package/dist/assets/{sizeCapture-INFHLROL-B-bTrmx9.js → sizeCapture-INFHLROL-Cpcjc5oE.js} +1 -1
- package/dist/assets/{stateDiagram-v2-GCMORJYK-D6ZflrZQ.js → stateDiagram-v2-GCMORJYK-CtQKYLT4.js} +1 -1
- package/dist/assets/{swimlanes-2SLR337P-DKgdDJlH.js → swimlanes-2SLR337P-DpIk02zs.js} +1 -1
- package/dist/assets/swimlanesDiagram-TC7HE7FX-DPTl4zVS.js +8 -0
- package/dist/assets/{timeline-definition-EJHVYXUP-Dli4hqxc.js → timeline-definition-EJHVYXUP-DsA7dQhy.js} +1 -1
- package/dist/assets/{usecaseDiagram-POWQR4AR-CQ8Cc1rN.js → usecaseDiagram-POWQR4AR-BM42_rDz.js} +1 -1
- package/dist/assets/{vennDiagram-UO4OBE2U-JEu7ZkzA.js → vennDiagram-UO4OBE2U-DgLtqgJF.js} +1 -1
- package/dist/assets/{wardleyDiagram-VNRHLVJA-DkFigbd0.js → wardleyDiagram-VNRHLVJA-BKUUTKBJ.js} +1 -1
- package/dist/assets/{xychartDiagram-PMCCYNJV-DwOctln8.js → xychartDiagram-PMCCYNJV-B9RWvizV.js} +1 -1
- package/dist/index.html +1 -1
- package/dist-server/accounts-proxy.js +12 -2
- package/dist-server/browser-proxy.js +15 -2
- package/dist-server/drivers/phone-proxy.js +13 -4
- package/dist-server/index.js +3168 -2730
- package/dist-server/openmausbot.js +821 -638
- package/dist-server/pair-cli.js +821 -638
- package/dist-server/server/accounts-proxy.js +17 -2
- package/dist-server/server/agents-token-file.js +10 -7
- package/dist-server/server/browser-proxy.js +18 -2
- package/dist-server/server/connection-cap-failover.js +8 -4
- package/dist-server/server/drivers/acp/core.js +20 -47
- package/dist-server/server/drivers/acp/custom.js +5 -0
- package/dist-server/server/drivers/acp/hermes.js +1 -0
- package/dist-server/server/drivers/acp/kimi-turn-failure.js +68 -0
- package/dist-server/server/drivers/acp/kimi.js +7 -0
- package/dist-server/server/drivers/acp/mcp-limit.js +47 -0
- package/dist-server/server/drivers/acp/rpc-error.js +35 -0
- package/dist-server/server/drivers/acp/setup-failure.js +9 -0
- package/dist-server/server/drivers/acp/vibe.js +11 -5
- package/dist-server/server/drivers/chat-text-only.js +47 -0
- package/dist-server/server/drivers/openai-chat-protocol.js +15 -0
- package/dist-server/server/drivers/openai-chat.js +8 -18
- package/dist-server/server/drivers/phone-proxy.js +18 -4
- package/dist-server/server/drivers/turn-mcp.js +3 -0
- package/dist-server/server/drivers/vibe-login.js +17 -8
- package/dist-server/server/engine-failover.js +16 -24
- package/dist-server/server/engine-failure.js +3 -3
- package/dist-server/server/engine-rest.js +5 -3
- package/dist-server/server/engine-tiers.js +12 -9
- package/dist-server/server/harness/bus.js +7 -2
- package/dist-server/server/index.js +19 -18
- package/dist-server/server/injected-model-rest.js +17 -0
- package/dist-server/server/model-levels/aliases.js +243 -38
- package/dist-server/server/model-levels/chibitek-rankings.js +8 -8
- package/dist-server/server/model-levels/classes.js +106 -38
- package/dist-server/server/model-levels/index.js +26 -14
- package/dist-server/server/model-levels/model-ids.js +91 -0
- package/dist-server/server/model-levels/overrides.js +7 -4
- package/dist-server/server/model-levels/sources.js +4 -1
- package/dist-server/server/pay-per-use.js +13 -1
- package/package.json +1 -1
- package/dist/assets/channel-D3ihDYTR.js +0 -1
- package/dist/assets/swimlanesDiagram-TC7HE7FX-DSlLxTUH.js +0 -8
package/dist-server/pair-cli.js
CHANGED
|
@@ -138,11 +138,11 @@ function isNodeScript(file2, host) {
|
|
|
138
138
|
return /\.[cm]?js$/i.test(file2) || !extname(file2) && hasNodeShebang(file2, host);
|
|
139
139
|
}
|
|
140
140
|
function parseCmdShim(shim, host) {
|
|
141
|
-
const
|
|
142
|
-
if (
|
|
141
|
+
const text7 = host.readText(shim);
|
|
142
|
+
if (text7 === null) return null;
|
|
143
143
|
const dir = dirname(shim);
|
|
144
|
-
const npmEntry = /^SET "NP[MX]_CLI_JS=%~dp0\\([^"]+)"/im.exec(
|
|
145
|
-
const targets = [...npmEntry ? [npmEntry] : [], ...
|
|
144
|
+
const npmEntry = /^SET "NP[MX]_CLI_JS=%~dp0\\([^"]+)"/im.exec(text7);
|
|
145
|
+
const targets = [...npmEntry ? [npmEntry] : [], ...text7.matchAll(/"%~?dp0%?\\?([^"]+)"/g)].map((m3) => join(dir, m3[1])).filter((p3) => host.isFile(p3) && basename(p3).toLowerCase() !== "node.exe");
|
|
146
146
|
const script = targets.find((p3) => isNodeScript(p3, host));
|
|
147
147
|
if (script) return nodeLaunch(script, dir, host);
|
|
148
148
|
const exe = targets.find((p3) => [".exe", ".com"].includes(extname(p3).toLowerCase()));
|
|
@@ -573,9 +573,9 @@ function runBounded(resolved, opts, cb) {
|
|
|
573
573
|
const receive = (which) => (chunk) => {
|
|
574
574
|
if (done) return;
|
|
575
575
|
bytes += chunk.length;
|
|
576
|
-
const
|
|
577
|
-
if (which === "out") stdout2 +=
|
|
578
|
-
else stderr +=
|
|
576
|
+
const text7 = chunk.toString("utf8");
|
|
577
|
+
if (which === "out") stdout2 += text7;
|
|
578
|
+
else stderr += text7;
|
|
579
579
|
if (bytes > maxBuffer) {
|
|
580
580
|
stop(Object.assign(new Error(`${which === "out" ? "stdout" : "stderr"} maxBuffer length exceeded`), {
|
|
581
581
|
code: "ERR_CHILD_PROCESS_STDIO_MAXBUFFER",
|
|
@@ -625,8 +625,8 @@ function probeCli(cli, args, options) {
|
|
|
625
625
|
});
|
|
626
626
|
});
|
|
627
627
|
}
|
|
628
|
-
function outputTail(
|
|
629
|
-
return stripVTControlCharacters(
|
|
628
|
+
function outputTail(text7, lines = 8, chars = 800) {
|
|
629
|
+
return stripVTControlCharacters(text7).split(/\r?\n/).map((line) => line.trimEnd()).filter((line) => line.trim()).slice(-lines).join("\n").slice(-chars);
|
|
630
630
|
}
|
|
631
631
|
function describeProbeFailure(cli, args, probe) {
|
|
632
632
|
const command = `\`${[cli, ...args].join(" ")}\``;
|
|
@@ -635,10 +635,10 @@ function describeProbeFailure(cli, args, probe) {
|
|
|
635
635
|
else if (probe.launchError) head = `${command} could not start (${probe.launchError})`;
|
|
636
636
|
else if (probe.timedOut) head = `${command} did not answer within ${Math.round(probe.ms / 1e3)} seconds and was stopped. An antivirus scan of a newly installed program can do this; try again in a minute`;
|
|
637
637
|
else head = `${command} failed (exit code ${probe.exitCode ?? "unknown"})`;
|
|
638
|
-
const
|
|
638
|
+
const tail3 = outputTail(`${probe.stderr}
|
|
639
639
|
${probe.stdout}`);
|
|
640
|
-
return
|
|
641
|
-
${
|
|
640
|
+
return tail3 ? `${head}:
|
|
641
|
+
${tail3}` : head;
|
|
642
642
|
}
|
|
643
643
|
function spawnCommand(command, args, opts = {}) {
|
|
644
644
|
const resolved = resolveCommand(command, args, opts.env);
|
|
@@ -8205,8 +8205,8 @@ var capitalizeFirstCharacter, error28;
|
|
|
8205
8205
|
var init_lt = __esm({
|
|
8206
8206
|
"../atomic-harness-skills/node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/locales/lt.js"() {
|
|
8207
8207
|
init_util();
|
|
8208
|
-
capitalizeFirstCharacter = (
|
|
8209
|
-
return
|
|
8208
|
+
capitalizeFirstCharacter = (text7) => {
|
|
8209
|
+
return text7.charAt(0).toUpperCase() + text7.slice(1);
|
|
8210
8210
|
};
|
|
8211
8211
|
error28 = () => {
|
|
8212
8212
|
const Sizable = {
|
|
@@ -17491,16 +17491,16 @@ function isSecretName(name) {
|
|
|
17491
17491
|
}
|
|
17492
17492
|
function looksLikeSecretValue(value) {
|
|
17493
17493
|
if (typeof value !== "string") return false;
|
|
17494
|
-
const
|
|
17495
|
-
if (
|
|
17496
|
-
return AUTH_SCHEME.test(
|
|
17494
|
+
const text7 = value.trim();
|
|
17495
|
+
if (text7.length < 8 || text7.includes("${")) return false;
|
|
17496
|
+
return AUTH_SCHEME.test(text7) || TOKEN_PREFIX.test(text7) || JWT.test(text7) || URL_PASSWORD.test(text7);
|
|
17497
17497
|
}
|
|
17498
17498
|
function isSecretEntry(name, value) {
|
|
17499
17499
|
if (typeof value !== "string") return false;
|
|
17500
|
-
const
|
|
17501
|
-
if (!
|
|
17502
|
-
if (looksLikeSecretValue(
|
|
17503
|
-
return isSecretName(name) && !PATH_OR_URL.test(
|
|
17500
|
+
const text7 = value.trim();
|
|
17501
|
+
if (!text7 || text7 === MCP_SECRET_PLACEHOLDER || text7.includes("${")) return false;
|
|
17502
|
+
if (looksLikeSecretValue(text7)) return true;
|
|
17503
|
+
return isSecretName(name) && !PATH_OR_URL.test(text7) && !PLAIN_SETTING.test(text7);
|
|
17504
17504
|
}
|
|
17505
17505
|
function sanitizeMcpSecrets(value) {
|
|
17506
17506
|
const out = {};
|
|
@@ -17688,8 +17688,8 @@ var init_mcp_secrets2 = __esm({
|
|
|
17688
17688
|
});
|
|
17689
17689
|
|
|
17690
17690
|
// server/schema.ts
|
|
17691
|
-
function parseJson(
|
|
17692
|
-
return JSON.parse(
|
|
17691
|
+
function parseJson(text7) {
|
|
17692
|
+
return JSON.parse(text7);
|
|
17693
17693
|
}
|
|
17694
17694
|
function schemaIssue(error51, fallback) {
|
|
17695
17695
|
const issue2 = error51.issues[0];
|
|
@@ -20879,9 +20879,9 @@ var require_main = __commonJS({
|
|
|
20879
20879
|
});
|
|
20880
20880
|
|
|
20881
20881
|
// shared/redact.ts
|
|
20882
|
-
function redactSecretsInText(
|
|
20883
|
-
if (!
|
|
20884
|
-
let out =
|
|
20882
|
+
function redactSecretsInText(text7) {
|
|
20883
|
+
if (!text7 || text7.length < 8) return text7;
|
|
20884
|
+
let out = text7;
|
|
20885
20885
|
out = out.replace(PEM_BLOCK, (_m, open2, body, close) => `${open2}
|
|
20886
20886
|
${mask(body.trim())}
|
|
20887
20887
|
${close}`);
|
|
@@ -26540,9 +26540,9 @@ var init_local_inject = __esm({
|
|
|
26540
26540
|
|
|
26541
26541
|
// server/drivers/prompt-shape.ts
|
|
26542
26542
|
function permissionKindOfLabel(label) {
|
|
26543
|
-
const
|
|
26544
|
-
if (REJECT_LABEL.test(
|
|
26545
|
-
if (ALLOW_LABEL.test(
|
|
26543
|
+
const text7 = label.trim();
|
|
26544
|
+
if (REJECT_LABEL.test(text7)) return ALWAYS_LABEL.test(text7) ? "reject_always" : "reject_once";
|
|
26545
|
+
if (ALLOW_LABEL.test(text7)) return ALWAYS_LABEL.test(text7) ? "allow_always" : "allow_once";
|
|
26546
26546
|
return null;
|
|
26547
26547
|
}
|
|
26548
26548
|
function isChoicePrompt(prompt) {
|
|
@@ -26722,10 +26722,10 @@ function toolDetailPreview(value) {
|
|
|
26722
26722
|
return result;
|
|
26723
26723
|
};
|
|
26724
26724
|
const safe = redactSecrets(bounded(value));
|
|
26725
|
-
const
|
|
26726
|
-
if (!
|
|
26727
|
-
return
|
|
26728
|
-
[\u2026 preview shortened]` :
|
|
26725
|
+
const text7 = typeof safe === "string" ? safe : JSON.stringify(safe, null, 2);
|
|
26726
|
+
if (!text7?.trim() || text7 === "{}" || text7 === "[]") return void 0;
|
|
26727
|
+
return text7.length > 6e3 ? `${text7.slice(0, 6e3)}
|
|
26728
|
+
[\u2026 preview shortened]` : text7;
|
|
26729
26729
|
}
|
|
26730
26730
|
function fieldsOf(input) {
|
|
26731
26731
|
if (input === null || typeof input !== "object" || Array.isArray(input)) return void 0;
|
|
@@ -26742,8 +26742,8 @@ function askInputSummary(input) {
|
|
|
26742
26742
|
if (typeof fields.question === "string") return cut(fields.question, QUESTION_LIMIT);
|
|
26743
26743
|
if (typeof fields.command === "string") return cut(fields.command, LIMIT);
|
|
26744
26744
|
if (typeof fields.url === "string") return cut(fields.url, LIMIT);
|
|
26745
|
-
const
|
|
26746
|
-
return
|
|
26745
|
+
const text7 = JSON.stringify(fields);
|
|
26746
|
+
return text7 === "{}" ? void 0 : cut(text7, LIMIT);
|
|
26747
26747
|
}
|
|
26748
26748
|
var QUESTION_LIMIT, LIMIT, cut;
|
|
26749
26749
|
var init_tool_summary = __esm({
|
|
@@ -26752,7 +26752,7 @@ var init_tool_summary = __esm({
|
|
|
26752
26752
|
init_redact2();
|
|
26753
26753
|
QUESTION_LIMIT = 300;
|
|
26754
26754
|
LIMIT = 200;
|
|
26755
|
-
cut = (
|
|
26755
|
+
cut = (text7, limit) => redactSecretsInText(text7).trim().slice(0, limit);
|
|
26756
26756
|
}
|
|
26757
26757
|
});
|
|
26758
26758
|
|
|
@@ -26778,17 +26778,17 @@ var init_mcp_tool_images = __esm({
|
|
|
26778
26778
|
|
|
26779
26779
|
// shared/mcp-tool-ref.ts
|
|
26780
26780
|
function mcpToolRefFromLabel(label, servers) {
|
|
26781
|
-
const
|
|
26782
|
-
if (!
|
|
26781
|
+
const text7 = label.trim();
|
|
26782
|
+
if (!text7) return null;
|
|
26783
26783
|
const ordered = [...servers].sort((a2, b3) => b3.length - a2.length);
|
|
26784
26784
|
const accept = (server, tool2) => MCP_TOOL_NAME.test(tool2) ? { server, tool: tool2 } : null;
|
|
26785
26785
|
for (const server of ordered) {
|
|
26786
26786
|
const claude = `mcp__${server}__`;
|
|
26787
|
-
if (
|
|
26788
|
-
const hit = accept(server,
|
|
26787
|
+
if (text7.startsWith(claude)) {
|
|
26788
|
+
const hit = accept(server, text7.slice(claude.length));
|
|
26789
26789
|
if (hit) return hit;
|
|
26790
26790
|
}
|
|
26791
|
-
const display = new RegExp(`^(\\S+) \\(${server.replace(/[.*+?^${}()|[\]\\-]/g, "\\$&")} MCP Server\\)$`).exec(
|
|
26791
|
+
const display = new RegExp(`^(\\S+) \\(${server.replace(/[.*+?^${}()|[\]\\-]/g, "\\$&")} MCP Server\\)$`).exec(text7);
|
|
26792
26792
|
if (display) {
|
|
26793
26793
|
const hit = accept(server, display[1]);
|
|
26794
26794
|
if (hit) return hit;
|
|
@@ -26796,8 +26796,8 @@ function mcpToolRefFromLabel(label, servers) {
|
|
|
26796
26796
|
}
|
|
26797
26797
|
for (const separator of ["__", ":", ".", "/", "_"]) {
|
|
26798
26798
|
for (const server of ordered) {
|
|
26799
|
-
if (!
|
|
26800
|
-
const hit = accept(server,
|
|
26799
|
+
if (!text7.startsWith(`${server}${separator}`)) continue;
|
|
26800
|
+
const hit = accept(server, text7.slice(server.length + separator.length));
|
|
26801
26801
|
if (hit) return hit;
|
|
26802
26802
|
}
|
|
26803
26803
|
}
|
|
@@ -26815,8 +26815,8 @@ var init_mcp_tool_ref = __esm({
|
|
|
26815
26815
|
function isBrokenAntigravityCheckpoint(driverKind, message3) {
|
|
26816
26816
|
return driverKind === "antigravityAgent" && message3.includes("could not find doneCh for checkpoint");
|
|
26817
26817
|
}
|
|
26818
|
-
function isAntigravityCheckpointReply(driverKind,
|
|
26819
|
-
return driverKind === "antigravityAgent" && /^Agent execution error: could not find doneCh for checkpoint\s*$/.test(
|
|
26818
|
+
function isAntigravityCheckpointReply(driverKind, text7) {
|
|
26819
|
+
return driverKind === "antigravityAgent" && /^Agent execution error: could not find doneCh for checkpoint\s*$/.test(text7.trim());
|
|
26820
26820
|
}
|
|
26821
26821
|
var init_checkpoint_recovery = __esm({
|
|
26822
26822
|
"server/checkpoint-recovery.ts"() {
|
|
@@ -26856,9 +26856,9 @@ var init_provider_safety = __esm({
|
|
|
26856
26856
|
});
|
|
26857
26857
|
|
|
26858
26858
|
// server/model-access-refusal.ts
|
|
26859
|
-
function isModelAccessRefused(
|
|
26860
|
-
if (!
|
|
26861
|
-
return MODEL_ACCESS_REFUSED.some((pattern) => pattern.test(
|
|
26859
|
+
function isModelAccessRefused(text7) {
|
|
26860
|
+
if (!text7 || SIGN_IN_WORDS.test(text7)) return false;
|
|
26861
|
+
return MODEL_ACCESS_REFUSED.some((pattern) => pattern.test(text7));
|
|
26862
26862
|
}
|
|
26863
26863
|
var AUTH_STATUS, MODEL_NAME, MODEL_ACCESS_REFUSED, SIGN_IN_WORDS;
|
|
26864
26864
|
var init_model_access_refusal = __esm({
|
|
@@ -26894,14 +26894,14 @@ var init_model_access_refusal = __esm({
|
|
|
26894
26894
|
});
|
|
26895
26895
|
|
|
26896
26896
|
// server/engine-failure.ts
|
|
26897
|
-
function statedReset(
|
|
26898
|
-
const reset = parseReset(
|
|
26897
|
+
function statedReset(text7, now = Date.now()) {
|
|
26898
|
+
const reset = parseReset(text7, now);
|
|
26899
26899
|
if (reset) return { resetAt: reset.at, resetText: reset.text };
|
|
26900
|
-
const windowMs = rollingWindowMs(
|
|
26901
|
-
return windowMs ? { windowMs, resetText: rollingWindowPhrase(
|
|
26900
|
+
const windowMs = rollingWindowMs(text7);
|
|
26901
|
+
return windowMs ? { windowMs, resetText: rollingWindowPhrase(text7) } : {};
|
|
26902
26902
|
}
|
|
26903
|
-
function rollingWindowMs(
|
|
26904
|
-
const m3 = ROLLING_WINDOW.exec(
|
|
26903
|
+
function rollingWindowMs(text7) {
|
|
26904
|
+
const m3 = ROLLING_WINDOW.exec(text7);
|
|
26905
26905
|
if (!m3) return void 0;
|
|
26906
26906
|
const amount = Number(m3[1] ?? m3[3]);
|
|
26907
26907
|
const unit = (m3[2] ?? m3[4]).toLowerCase();
|
|
@@ -26909,37 +26909,37 @@ function rollingWindowMs(text6) {
|
|
|
26909
26909
|
const ms2 = amount * scale;
|
|
26910
26910
|
return Number.isFinite(ms2) && ms2 > 0 ? Math.min(ms2, MAX_WINDOW_MS) : void 0;
|
|
26911
26911
|
}
|
|
26912
|
-
function rollingWindowPhrase(
|
|
26913
|
-
const m3 = ROLLING_WINDOW.exec(
|
|
26912
|
+
function rollingWindowPhrase(text7) {
|
|
26913
|
+
const m3 = ROLLING_WINDOW.exec(text7);
|
|
26914
26914
|
if (!m3) return void 0;
|
|
26915
|
-
const lead = /\b(?:usage\s+)?resets?\s+(?:over\s+)?(?:a\s+)?$/i.exec(
|
|
26915
|
+
const lead = /\b(?:usage\s+)?resets?\s+(?:over\s+)?(?:a\s+)?$/i.exec(text7.slice(Math.max(0, m3.index - 30), m3.index));
|
|
26916
26916
|
return resetPhrase(`${lead ? lead[0] : ""}${m3[0]}`);
|
|
26917
26917
|
}
|
|
26918
|
-
function isCredentialDead(
|
|
26919
|
-
return Boolean(
|
|
26918
|
+
function isCredentialDead(text7) {
|
|
26919
|
+
return Boolean(text7) && CREDENTIAL_DEAD.some((pattern) => pattern.test(text7));
|
|
26920
26920
|
}
|
|
26921
26921
|
function isOpaqueRequestRejection(message3) {
|
|
26922
26922
|
return OPAQUE_REQUEST_REJECTION.test(message3);
|
|
26923
26923
|
}
|
|
26924
|
-
function classifyEngineFailure(
|
|
26925
|
-
if (!
|
|
26926
|
-
const tooFast = TOO_FAST.some((pattern) => pattern.test(
|
|
26927
|
-
if (USAGE_LIMITED.some((pattern) => pattern.test(
|
|
26928
|
-
return { kind: "usage_limited", ...statedReset(
|
|
26929
|
-
}
|
|
26930
|
-
if (isCredentialDead(
|
|
26931
|
-
if (isModelAccessRefused(
|
|
26932
|
-
if (AUTH_FAILED.some((pattern) => pattern.test(
|
|
26933
|
-
if (STALLED.some((pattern) => pattern.test(
|
|
26934
|
-
if (tooFast || RATE_LIMITED.some((pattern) => pattern.test(
|
|
26935
|
-
const reset = parseReset(
|
|
26924
|
+
function classifyEngineFailure(text7, now = Date.now()) {
|
|
26925
|
+
if (!text7) return null;
|
|
26926
|
+
const tooFast = TOO_FAST.some((pattern) => pattern.test(text7));
|
|
26927
|
+
if (USAGE_LIMITED.some((pattern) => pattern.test(text7)) || !tooFast && EXHAUSTED.some((pattern) => pattern.test(text7))) {
|
|
26928
|
+
return { kind: "usage_limited", ...statedReset(text7, now) };
|
|
26929
|
+
}
|
|
26930
|
+
if (isCredentialDead(text7)) return { kind: "auth_failed", permanent: true };
|
|
26931
|
+
if (isModelAccessRefused(text7)) return { kind: "request_rejected" };
|
|
26932
|
+
if (AUTH_FAILED.some((pattern) => pattern.test(text7))) return { kind: "auth_failed" };
|
|
26933
|
+
if (STALLED.some((pattern) => pattern.test(text7))) return { kind: "stalled" };
|
|
26934
|
+
if (tooFast || RATE_LIMITED.some((pattern) => pattern.test(text7))) {
|
|
26935
|
+
const reset = parseReset(text7, now);
|
|
26936
26936
|
return { kind: "rate_limited", ...reset ? { resetAt: reset.at, resetText: reset.text } : {} };
|
|
26937
26937
|
}
|
|
26938
26938
|
return null;
|
|
26939
26939
|
}
|
|
26940
|
-
function logAuthFailure(
|
|
26941
|
-
if (!
|
|
26942
|
-
for (const line of
|
|
26940
|
+
function logAuthFailure(text7) {
|
|
26941
|
+
if (!text7) return void 0;
|
|
26942
|
+
for (const line of text7.split(/\r?\n/)) {
|
|
26943
26943
|
if (LOG_AUTH_FAILED.some((pattern) => pattern.test(line))) return line.trim().slice(0, 300);
|
|
26944
26944
|
}
|
|
26945
26945
|
return void 0;
|
|
@@ -26955,13 +26955,13 @@ function engineFailureFromCodexInfo(info) {
|
|
|
26955
26955
|
if (name === "unauthorized") return "auth_failed";
|
|
26956
26956
|
return void 0;
|
|
26957
26957
|
}
|
|
26958
|
-
function parseResetAt(
|
|
26959
|
-
return parseReset(
|
|
26958
|
+
function parseResetAt(text7, now = Date.now()) {
|
|
26959
|
+
return parseReset(text7, now)?.at;
|
|
26960
26960
|
}
|
|
26961
|
-
function parseReset(
|
|
26962
|
-
if (!
|
|
26961
|
+
function parseReset(text7, now = Date.now()) {
|
|
26962
|
+
if (!text7) return void 0;
|
|
26963
26963
|
for (const read of RESET_READERS) {
|
|
26964
|
-
for (const found of read(
|
|
26964
|
+
for (const found of read(text7, now)) {
|
|
26965
26965
|
if (Number.isFinite(found.at) && found.at > now && found.at - now <= MAX_RESET_AHEAD_MS) {
|
|
26966
26966
|
return { at: Math.round(found.at), text: resetPhrase(found.phrase) };
|
|
26967
26967
|
}
|
|
@@ -26988,27 +26988,27 @@ function resetHintFromData(data) {
|
|
|
26988
26988
|
};
|
|
26989
26989
|
return walk(data, 0);
|
|
26990
26990
|
}
|
|
26991
|
-
function durationMs(
|
|
26991
|
+
function durationMs(text7) {
|
|
26992
26992
|
let total = 0;
|
|
26993
|
-
for (const part of
|
|
26993
|
+
for (const part of text7.matchAll(new RegExp(String.raw`(\d+(?:\.\d+)?)\s*(${UNIT})`, "gi"))) {
|
|
26994
26994
|
const unit = part[2].toLowerCase();
|
|
26995
26995
|
const scale = unit === "ms" || unit.startsWith("milli") ? 1 : unit[0] === "d" ? DAY_MS4 : unit[0] === "h" ? HOUR_MS : unit[0] === "m" ? MINUTE_MS : 1e3;
|
|
26996
26996
|
total += Number(part[1]) * scale;
|
|
26997
26997
|
}
|
|
26998
26998
|
return total;
|
|
26999
26999
|
}
|
|
27000
|
-
function leadIn(
|
|
27001
|
-
const before =
|
|
27000
|
+
function leadIn(text7, index) {
|
|
27001
|
+
const before = text7.slice(Math.max(0, index - 30), index);
|
|
27002
27002
|
const lead = new RegExp(String.raw`${RESET_WORD}(?:\s+(?:at|on|in))?[\s:=∙·-]*$`, "i").exec(before);
|
|
27003
27003
|
return lead ? index - (before.length - lead.index) : index;
|
|
27004
27004
|
}
|
|
27005
|
-
function readClock(
|
|
27005
|
+
function readClock(text7, now) {
|
|
27006
27006
|
const reading = {};
|
|
27007
27007
|
let i2 = 0;
|
|
27008
|
-
const skipFiller = () => i2 += CLOCK_FILLER.exec(
|
|
27008
|
+
const skipFiller = () => i2 += CLOCK_FILLER.exec(text7.slice(i2))[0].length;
|
|
27009
27009
|
skipFiller();
|
|
27010
27010
|
for (let parts = 0; parts < 4; parts++) {
|
|
27011
|
-
const rest =
|
|
27011
|
+
const rest = text7.slice(i2);
|
|
27012
27012
|
let m3;
|
|
27013
27013
|
if (!reading.dayWord && reading.weekday === void 0 && !reading.date && (m3 = CLOCK_PARTS.dayWord.exec(rest))) {
|
|
27014
27014
|
reading.dayWord = m3[1].toLowerCase();
|
|
@@ -27033,11 +27033,11 @@ function readClock(text6, now) {
|
|
|
27033
27033
|
i2 += m3[0].length;
|
|
27034
27034
|
const before = i2;
|
|
27035
27035
|
skipFiller();
|
|
27036
|
-
if (!Object.values(CLOCK_PARTS).some((part) => part.test(
|
|
27036
|
+
if (!Object.values(CLOCK_PARTS).some((part) => part.test(text7.slice(i2)))) i2 = before;
|
|
27037
27037
|
}
|
|
27038
27038
|
if (reading.hour === void 0 || reading.hour > 23 || reading.minute > 59) return void 0;
|
|
27039
27039
|
if (reading.date && (reading.date.month < 1 || reading.date.day < 1 || reading.date.day > 31)) return void 0;
|
|
27040
|
-
const after = zoneAfter(
|
|
27040
|
+
const after = zoneAfter(text7.slice(i2));
|
|
27041
27041
|
const zone = after?.zone ?? localZone();
|
|
27042
27042
|
const length = i2 + (after?.length ?? 0);
|
|
27043
27043
|
const today = zonedToday(now, zone);
|
|
@@ -27059,21 +27059,21 @@ function readClock(text6, now) {
|
|
|
27059
27059
|
return { at: found, length };
|
|
27060
27060
|
}
|
|
27061
27061
|
function parseZone(token) {
|
|
27062
|
-
const
|
|
27063
|
-
const offset = /^(?:UTC|GMT)?\s*([+-])\s*(\d{1,2})(?::?(\d{2}))?$/i.exec(
|
|
27062
|
+
const text7 = token.trim();
|
|
27063
|
+
const offset = /^(?:UTC|GMT)?\s*([+-])\s*(\d{1,2})(?::?(\d{2}))?$/i.exec(text7);
|
|
27064
27064
|
if (offset) {
|
|
27065
27065
|
const minutes = Number(offset[2]) * 60 + Number(offset[3] ?? 0);
|
|
27066
27066
|
return minutes <= 14 * 60 ? { offsetMinutes: offset[1] === "-" ? -minutes : minutes } : void 0;
|
|
27067
27067
|
}
|
|
27068
|
-
const upper =
|
|
27068
|
+
const upper = text7.toUpperCase();
|
|
27069
27069
|
if (upper in ZONE_ABBREVIATIONS) return { offsetMinutes: ZONE_ABBREVIATIONS[upper] };
|
|
27070
|
-
return
|
|
27070
|
+
return text7.includes("/") && validTimeZone(text7) ? { name: text7 } : void 0;
|
|
27071
27071
|
}
|
|
27072
|
-
function zoneAfter(
|
|
27073
|
-
const bare = new RegExp(String.raw`^\s*,?\s*(${ZONE_TOKEN})(?![A-Za-z0-9/])`).exec(
|
|
27072
|
+
function zoneAfter(text7) {
|
|
27073
|
+
const bare = new RegExp(String.raw`^\s*,?\s*(${ZONE_TOKEN})(?![A-Za-z0-9/])`).exec(text7);
|
|
27074
27074
|
const bareZone = bare ? parseZone(bare[1]) : void 0;
|
|
27075
27075
|
if (bare && bareZone) return { zone: bareZone, length: bare[0].length };
|
|
27076
|
-
const paren = /^[^()\n]{0,20}\(([^()\n]{1,60})\)/.exec(
|
|
27076
|
+
const paren = /^[^()\n]{0,20}\(([^()\n]{1,60})\)/.exec(text7);
|
|
27077
27077
|
if (paren) {
|
|
27078
27078
|
for (const token of paren[1].split(/[\s,;]+/).reverse()) {
|
|
27079
27079
|
const zone = parseZone(token);
|
|
@@ -27124,8 +27124,8 @@ function wallToInstant(year, month, day, hour, minute, zone, extraMs = 0) {
|
|
|
27124
27124
|
at2 = wall - offsetAt(at2);
|
|
27125
27125
|
return at2;
|
|
27126
27126
|
}
|
|
27127
|
-
function resetPhrase(
|
|
27128
|
-
const phrase =
|
|
27127
|
+
function resetPhrase(text7) {
|
|
27128
|
+
const phrase = text7.replace(/\s+/g, " ").trim().replace(/^[\s|,;:∙·-]+|[\s,;:.∙·-]+$/g, "");
|
|
27129
27129
|
return phrase.length > RESET_TEXT_MAX ? `${phrase.slice(0, RESET_TEXT_MAX - 1)}\u2026` : phrase;
|
|
27130
27130
|
}
|
|
27131
27131
|
var MAX_WINDOW_MS, ROLLING_WINDOW, USAGE_LIMITED, EXHAUSTED, TOO_FAST, RATE_LIMITED, CREDENTIAL_DEAD, LOGIN_EXPIRED_REPLY, AUTH_FAILED, STALLED, OPAQUE_REQUEST_REJECTION, LOG_AUTH_FAILED, MINUTE_MS, HOUR_MS, DAY_MS4, MAX_RESET_AHEAD_MS, RESET_TEXT_MAX, RESET_DATA_KEYS, UNIT, DURATION, RESET_WORD, RESET_READERS, MONTH, WEEKDAYS, CLOCK_FILLER, CLOCK_PARTS, monthIndex, ZONE_ABBREVIATIONS, ZONE_TOKEN, localZone;
|
|
@@ -27146,7 +27146,8 @@ var init_engine_failure = __esm({
|
|
|
27146
27146
|
// Codex: "You've hit your usage limit. Upgrade to Pro ... or try again in 2 days 4 hours";
|
|
27147
27147
|
// Cursor: "You've hit your usage limit for this month".
|
|
27148
27148
|
/\busage limit\b/i,
|
|
27149
|
-
/\bhit your (
|
|
27149
|
+
/\bhit your (?:[\w-]+ )?limit\b/i,
|
|
27150
|
+
// \"hit your 5-hour limit · resets 3:50am\" (Claude Code, 2026-11-22)
|
|
27150
27151
|
/\b(?:5-hour|five-hour|hourly|weekly|daily|monthly|session|opus|sonnet) (?:usage )?limit (?:reached|exceeded|hit)\b/i,
|
|
27151
27152
|
/\blimit reached\b[^.]*\breset/i,
|
|
27152
27153
|
// OpenAI API: "You exceeded your current quota, please check your plan and billing details." (insufficient_quota);
|
|
@@ -27157,7 +27158,7 @@ var init_engine_failure = __esm({
|
|
|
27157
27158
|
/\bplan limit\b|\blimit (?:of|for) your (?:plan|subscription)\b/i,
|
|
27158
27159
|
// Anthropic API: "Your credit balance is too low to access the Anthropic API."
|
|
27159
27160
|
// xAI: "Your team ... has either used all available credits or reached its monthly spending limit."
|
|
27160
|
-
/\bcredit balance (?:is )?too low\b|\binsufficient (?:\w+ )?(?:credits?|balance|funds)\b|\b(?:out|run out) of credits\b/i,
|
|
27161
|
+
/\bcredit balance (?:is )?too low\b|\binsufficient (?:\w+ )?(?:credits?|balance|funds)\b|\b(?:out|run out) of (?:usage )?credits\b/i,
|
|
27161
27162
|
/\bused all (?:available |of your )?credits\b|\bno credits? (?:left|remaining)\b|\bspending limit\b/i,
|
|
27162
27163
|
/\bexhausted your (?:\w+ )?quota\b/i,
|
|
27163
27164
|
/\bquota\b[^.]{0,60}\b(?:exceeded|exhausted|reached|used up)\b|\b(?:exceeded|exhausted|reached)\b[^.]{0,40}\bquota\b/i,
|
|
@@ -27200,7 +27201,8 @@ var init_engine_failure = __esm({
|
|
|
27200
27201
|
/\b(?:token|session|credentials?) (?:has |have )?expired\b|\bexpired (?:token|session|credentials?)\b/i
|
|
27201
27202
|
];
|
|
27202
27203
|
STALLED = [
|
|
27203
|
-
/\bwent fully silent\b[^.]{0,80}\bturn was stopped\b/i
|
|
27204
|
+
/\bwent fully silent\b[^.]{0,80}\bturn was stopped\b|\bGateway inaccessible\b/i
|
|
27205
|
+
// the second: Hermes `acp` could not reach or start its gateway service, so it is not responding (2026-11-22)
|
|
27204
27206
|
];
|
|
27205
27207
|
OPAQUE_REQUEST_REJECTION = /^Internal error: Bad Request \(session\/prompt\b/;
|
|
27206
27208
|
LOG_AUTH_FAILED = [
|
|
@@ -27233,49 +27235,49 @@ var init_engine_failure = __esm({
|
|
|
27233
27235
|
RESET_WORD = String.raw`\b(?:resets?|try again|retry|available again|renews?|refresh(?:es)?)\b`;
|
|
27234
27236
|
RESET_READERS = [
|
|
27235
27237
|
// Claude Code's "usage limit reached|1759348800".
|
|
27236
|
-
function* epochPipe(
|
|
27237
|
-
for (const m3 of
|
|
27238
|
+
function* epochPipe(text7) {
|
|
27239
|
+
for (const m3 of text7.matchAll(/(?:usage limit reached\s*)?\|\s*(\d{10})(\d{3})?(?!\d)/gi)) {
|
|
27238
27240
|
yield { at: Number(m3[1]) * 1e3, phrase: m3[0] };
|
|
27239
27241
|
}
|
|
27240
27242
|
},
|
|
27241
27243
|
// A structured reset instant: Codex's "resets_at": 1759348800, a
|
|
27242
27244
|
// "resetsAt", the unified rate-limit header.
|
|
27243
|
-
function* epochField(
|
|
27244
|
-
for (const m3 of
|
|
27245
|
+
function* epochField(text7) {
|
|
27246
|
+
for (const m3 of text7.matchAll(/["']?\b(?:resets_at|resetsAt|reset_at|resetAt|ratelimit-unified-reset)["']?\s*[:=]\s*["']?(\d{10}|\d{13})(?!\d)/gi)) {
|
|
27245
27247
|
yield { at: m3[1].length === 13 ? Number(m3[1]) : Number(m3[1]) * 1e3, phrase: m3[0] };
|
|
27246
27248
|
}
|
|
27247
27249
|
},
|
|
27248
27250
|
// "2026-09-25T18:00:00Z", "2026-10-03 09:00:00+02:00", "2026-08-08 00:00 UTC".
|
|
27249
|
-
function* isoTimestamp(
|
|
27250
|
-
for (const m3 of
|
|
27251
|
+
function* isoTimestamp(text7) {
|
|
27252
|
+
for (const m3 of text7.matchAll(/\b(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?(?:\s*(Z|UTC|GMT|[+-]\d{2}:?\d{2})\b)?/g)) {
|
|
27251
27253
|
const [, y, mo2, d, h2, mi2, sec, frac, zoneText] = m3;
|
|
27252
|
-
const start = leadIn(
|
|
27254
|
+
const start = leadIn(text7, m3.index);
|
|
27253
27255
|
if (!zoneText && start === m3.index) continue;
|
|
27254
|
-
const after = zoneText ? void 0 : zoneAfter(
|
|
27256
|
+
const after = zoneText ? void 0 : zoneAfter(text7.slice(m3.index + m3[0].length));
|
|
27255
27257
|
const zone = zoneText ? parseZone(zoneText) : after?.zone ?? localZone();
|
|
27256
27258
|
if (!zone) continue;
|
|
27257
27259
|
const ms2 = frac ? Math.round(Number(`0.${frac}`) * 1e3) : 0;
|
|
27258
27260
|
const at2 = wallToInstant(Number(y), Number(mo2), Number(d), Number(h2), Number(mi2), zone, Number(sec ?? 0) * 1e3 + ms2);
|
|
27259
|
-
yield { at: at2, phrase:
|
|
27261
|
+
yield { at: at2, phrase: text7.slice(start, m3.index + m3[0].length + (after?.length ?? 0)) };
|
|
27260
27262
|
}
|
|
27261
27263
|
},
|
|
27262
27264
|
// "Retry-After: 120", "retry after 3600 seconds".
|
|
27263
|
-
function* retryAfter(
|
|
27264
|
-
for (const m3 of
|
|
27265
|
+
function* retryAfter(text7, now) {
|
|
27266
|
+
for (const m3 of text7.matchAll(new RegExp(String.raw`\bretry[- ]after:?\s*(\d+(?:\.\d+)?)\s*(${UNIT})?`, "gi"))) {
|
|
27265
27267
|
yield { at: now + (m3[2] ? durationMs(`${m3[1]}${m3[2]}`) : Number(m3[1]) * 1e3), phrase: m3[0] };
|
|
27266
27268
|
}
|
|
27267
27269
|
},
|
|
27268
27270
|
// Structured durations: Gemini's "retryDelay": "41s", Codex's
|
|
27269
27271
|
// "resets_in_seconds": 3600, a "retry_after": 30.
|
|
27270
|
-
function* durationField(
|
|
27271
|
-
for (const m3 of
|
|
27272
|
+
function* durationField(text7, now) {
|
|
27273
|
+
for (const m3 of text7.matchAll(/["']?\b(retryDelay|retry_delay|retryAfter|retry_after(?:_seconds)?|resets_in_seconds|resetsInSeconds)["']?\s*[:=]\s*["']?(\d+(?:\.\d+)?)\s*(ms|s)?(?![a-z\d])/gi)) {
|
|
27272
27274
|
yield { at: now + Number(m3[2]) * (m3[3]?.toLowerCase() === "ms" ? 1 : 1e3), phrase: m3[0] };
|
|
27273
27275
|
}
|
|
27274
27276
|
},
|
|
27275
27277
|
// "try again in 2 days 4 hours 12 minutes", "resets in 37m", "Please
|
|
27276
27278
|
// retry in 41.5s", "resets in 2d 4h 30m", Hermes's "resets in ~127h".
|
|
27277
|
-
function* relative(
|
|
27278
|
-
for (const m3 of
|
|
27279
|
+
function* relative(text7, now) {
|
|
27280
|
+
for (const m3 of text7.matchAll(new RegExp(String.raw`${RESET_WORD}\s+in\s+~?\s*(${DURATION})`, "gi"))) {
|
|
27279
27281
|
const total = durationMs(m3[1]);
|
|
27280
27282
|
if (total > 0) yield { at: now + total, phrase: m3[0] };
|
|
27281
27283
|
}
|
|
@@ -27283,11 +27285,11 @@ var init_engine_failure = __esm({
|
|
|
27283
27285
|
// A time of day, maybe with a date: "resets 3pm (America/New_York)",
|
|
27284
27286
|
// "resets Oct 3, 9am", "try again tomorrow at 9:00", "resets Thursday
|
|
27285
27287
|
// 9am", "Access resets at 3:45 PM EDT", "15:05 on 26 Sep 2026".
|
|
27286
|
-
function* clock2(
|
|
27287
|
-
for (const m3 of
|
|
27288
|
+
function* clock2(text7, now) {
|
|
27289
|
+
for (const m3 of text7.matchAll(new RegExp(RESET_WORD, "gi"))) {
|
|
27288
27290
|
const start = m3.index + m3[0].length;
|
|
27289
|
-
const found = readClock(
|
|
27290
|
-
if (found) yield { at: found.at, phrase:
|
|
27291
|
+
const found = readClock(text7.slice(start, start + 120), now);
|
|
27292
|
+
if (found) yield { at: found.at, phrase: text7.slice(m3.index, start + found.length) };
|
|
27291
27293
|
}
|
|
27292
27294
|
}
|
|
27293
27295
|
];
|
|
@@ -27349,13 +27351,13 @@ function isModelRejection(error51, requested) {
|
|
|
27349
27351
|
return MODEL_REJECTION.test(message3) || requested.length > 0 && message3.includes(requested) && /\bmodel\b/i.test(message3);
|
|
27350
27352
|
}
|
|
27351
27353
|
function classifyError(err) {
|
|
27352
|
-
const
|
|
27353
|
-
if (isProviderSafetyBlock(
|
|
27354
|
-
if (CREDENTIAL_REFRESH_CONFLICT.test(
|
|
27354
|
+
const text7 = messageOf(err);
|
|
27355
|
+
if (isProviderSafetyBlock(text7)) return { transient: false, reason: "provider_safety" };
|
|
27356
|
+
if (CREDENTIAL_REFRESH_CONFLICT.test(text7)) {
|
|
27355
27357
|
if (err && "exitCode" in err && err.exitCode !== null && err.exitCode < 0) return { transient: false, reason: "interrupted" };
|
|
27356
27358
|
return { transient: true, reason: "credential_refresh" };
|
|
27357
27359
|
}
|
|
27358
|
-
const failure = classifyEngineFailure(
|
|
27360
|
+
const failure = classifyEngineFailure(text7);
|
|
27359
27361
|
if (failure?.kind === "rate_limited") {
|
|
27360
27362
|
if (err && "exitCode" in err && err.exitCode !== null && err.exitCode < 0) return { transient: false, reason: "interrupted" };
|
|
27361
27363
|
return { transient: true, reason: "rate_limited" };
|
|
@@ -27365,18 +27367,18 @@ function classifyError(err) {
|
|
|
27365
27367
|
const { exitCode: code } = err;
|
|
27366
27368
|
if (code !== null && code < 0) return { transient: false, reason: "interrupted" };
|
|
27367
27369
|
for (const { pattern, reason } of TRANSIENT_PATTERNS) {
|
|
27368
|
-
if (pattern.test(
|
|
27370
|
+
if (pattern.test(text7)) return { transient: true, reason };
|
|
27369
27371
|
}
|
|
27370
27372
|
for (const { pattern, reason } of TERMINAL_PATTERNS) {
|
|
27371
|
-
if (pattern.test(
|
|
27373
|
+
if (pattern.test(text7)) return { transient: false, reason };
|
|
27372
27374
|
}
|
|
27373
27375
|
return { transient: false, reason: "terminal_exit" };
|
|
27374
27376
|
}
|
|
27375
27377
|
for (const { pattern, reason } of TERMINAL_PATTERNS) {
|
|
27376
|
-
if (pattern.test(
|
|
27378
|
+
if (pattern.test(text7)) return { transient: false, reason };
|
|
27377
27379
|
}
|
|
27378
27380
|
for (const { pattern, reason } of TRANSIENT_PATTERNS) {
|
|
27379
|
-
if (pattern.test(
|
|
27381
|
+
if (pattern.test(text7)) return { transient: true, reason };
|
|
27380
27382
|
}
|
|
27381
27383
|
return { transient: false, reason: "unknown" };
|
|
27382
27384
|
}
|
|
@@ -27514,18 +27516,20 @@ function turnMcpServers(turn) {
|
|
|
27514
27516
|
}
|
|
27515
27517
|
return servers;
|
|
27516
27518
|
}
|
|
27519
|
+
var ATOMIC_MCP_SERVERS;
|
|
27517
27520
|
var init_turn_mcp = __esm({
|
|
27518
27521
|
"server/drivers/turn-mcp.ts"() {
|
|
27519
27522
|
"use strict";
|
|
27520
27523
|
init_mcp_gate_config();
|
|
27524
|
+
ATOMIC_MCP_SERVERS = /* @__PURE__ */ new Set(["agents", "atomic_accounts", "browser", "computer"]);
|
|
27521
27525
|
}
|
|
27522
27526
|
});
|
|
27523
27527
|
|
|
27524
27528
|
// server/drivers/volatile-notes.ts
|
|
27525
27529
|
function volatileSectionsOf(turn) {
|
|
27526
27530
|
if (turn.systemVolatileSections) return turn.systemVolatileSections.filter((section) => section.text.trim());
|
|
27527
|
-
const
|
|
27528
|
-
return
|
|
27531
|
+
const text7 = turn.systemVolatile ?? "";
|
|
27532
|
+
return text7.trim() ? [{ id: "volatile", label: "Notes", text: text7 }] : [];
|
|
27529
27533
|
}
|
|
27530
27534
|
function volatileNote(sections, delivered, first) {
|
|
27531
27535
|
const parts = [];
|
|
@@ -27550,11 +27554,11 @@ ${lead}
|
|
|
27550
27554
|
${parts.join("\n\n")}
|
|
27551
27555
|
</system-reminder>`;
|
|
27552
27556
|
}
|
|
27553
|
-
function withNote(
|
|
27554
|
-
if (!note) return
|
|
27555
|
-
return
|
|
27557
|
+
function withNote(text7, note) {
|
|
27558
|
+
if (!note) return text7;
|
|
27559
|
+
return text7 ? `${note}
|
|
27556
27560
|
|
|
27557
|
-
${
|
|
27561
|
+
${text7}` : note;
|
|
27558
27562
|
}
|
|
27559
27563
|
var init_volatile_notes = __esm({
|
|
27560
27564
|
"server/drivers/volatile-notes.ts"() {
|
|
@@ -27568,11 +27572,11 @@ function sanitizeToolLogValue(value, budget, depth = 0) {
|
|
|
27568
27572
|
if (typeof value === "string") {
|
|
27569
27573
|
if (/^data:image\//iu.test(value) || budget.text <= 0) return void 0;
|
|
27570
27574
|
const limit = Math.min(TOOL_LOG_TEXT_LIMIT, budget.text);
|
|
27571
|
-
const
|
|
27575
|
+
const text7 = value.length <= limit ? value : `[Earlier output truncated]
|
|
27572
27576
|
|
|
27573
27577
|
${value.slice(-limit)}`;
|
|
27574
|
-
budget.text -=
|
|
27575
|
-
return
|
|
27578
|
+
budget.text -= text7.length;
|
|
27579
|
+
return text7;
|
|
27576
27580
|
}
|
|
27577
27581
|
if (Array.isArray(value)) {
|
|
27578
27582
|
return value.flatMap((entry) => {
|
|
@@ -27603,10 +27607,94 @@ var init_tool_log = __esm({
|
|
|
27603
27607
|
}
|
|
27604
27608
|
});
|
|
27605
27609
|
|
|
27610
|
+
// server/drivers/acp/rpc-error.ts
|
|
27611
|
+
function acpRpcError(value, method) {
|
|
27612
|
+
const raw = value && typeof value === "object" ? value : {};
|
|
27613
|
+
const message3 = typeof raw.message === "string" ? raw.message : "ACP request failed";
|
|
27614
|
+
const data = raw.data;
|
|
27615
|
+
const fields = data && typeof data === "object" ? data : {};
|
|
27616
|
+
const nested = fields.error && typeof fields.error === "object" ? fields.error : {};
|
|
27617
|
+
const detail = typeof data === "string" ? data : typeof fields.details === "string" ? fields.details : typeof fields.message === "string" ? fields.message : text4(nested.message);
|
|
27618
|
+
const context = [
|
|
27619
|
+
method,
|
|
27620
|
+
typeof fields.service === "string" ? `service: ${fields.service}` : "",
|
|
27621
|
+
text4(fields.errorName)
|
|
27622
|
+
].filter(Boolean).join(", ");
|
|
27623
|
+
const said = detail && detail !== message3 ? `${message3}: ${detail}` : message3;
|
|
27624
|
+
const reset = parseResetAt(said) === void 0 ? resetHintFromData(data) : void 0;
|
|
27625
|
+
const diagnostic = `${said}${reset ? ` (${reset})` : ""} (${context})`;
|
|
27626
|
+
const error51 = new Error(redactSecretsInText(diagnostic).slice(0, 1500));
|
|
27627
|
+
return Object.assign(error51, {
|
|
27628
|
+
code: raw.code,
|
|
27629
|
+
data,
|
|
27630
|
+
// -32603 is JSON-RPC's internal error. Invalid params, unsupported
|
|
27631
|
+
// methods and auth refusals are user/configuration issues, not evidence
|
|
27632
|
+
// of a broken process. Preserve their session instead of retrying them.
|
|
27633
|
+
acpSessionFailure: raw.code === -32603
|
|
27634
|
+
});
|
|
27635
|
+
}
|
|
27636
|
+
var text4;
|
|
27637
|
+
var init_rpc_error = __esm({
|
|
27638
|
+
"server/drivers/acp/rpc-error.ts"() {
|
|
27639
|
+
"use strict";
|
|
27640
|
+
init_engine_failure();
|
|
27641
|
+
init_redact2();
|
|
27642
|
+
text4 = (value) => typeof value === "string" ? value : "";
|
|
27643
|
+
}
|
|
27644
|
+
});
|
|
27645
|
+
|
|
27646
|
+
// server/drivers/acp/mcp-limit.ts
|
|
27647
|
+
function mcpListBytes(servers) {
|
|
27648
|
+
return JSON.stringify(servers).replace(/[\u0080-\uffff]/g, "\\u0000").length;
|
|
27649
|
+
}
|
|
27650
|
+
function limitMcpServers(servers, limit) {
|
|
27651
|
+
if (!limit) return { kept: [...servers], left: [] };
|
|
27652
|
+
const kept = new Set(servers.filter((server) => ATOMIC_MCP_SERVERS.has(server.name)));
|
|
27653
|
+
const left = [];
|
|
27654
|
+
for (const server of servers) {
|
|
27655
|
+
if (kept.has(server)) continue;
|
|
27656
|
+
const fits = kept.size < limit.count && (limit.bytes === void 0 || mcpListBytes([...kept, server]) <= limit.bytes);
|
|
27657
|
+
if (fits) kept.add(server);
|
|
27658
|
+
else left.push(server.name);
|
|
27659
|
+
}
|
|
27660
|
+
return { kept: servers.filter((server) => kept.has(server)), left };
|
|
27661
|
+
}
|
|
27662
|
+
function sessionMcpServers(support12, servers, log = console.error) {
|
|
27663
|
+
const { kept, left } = limitMcpServers(servers, support12.mcpServerLimit);
|
|
27664
|
+
const key = `${support12.driverKind}
|
|
27665
|
+
${left.join("\n")}`;
|
|
27666
|
+
if (left.length && !reported.has(key)) {
|
|
27667
|
+
reported.add(key);
|
|
27668
|
+
const cap = support12.mcpServerLimit;
|
|
27669
|
+
log(`[${support12.driverKind}] ${support12.displayName} takes at most ${cap.count} MCP servers per session${cap.bytes === void 0 ? "" : ` (${cap.bytes} bytes)`}: left out ${left.join(", ")}`);
|
|
27670
|
+
}
|
|
27671
|
+
return kept;
|
|
27672
|
+
}
|
|
27673
|
+
var reported;
|
|
27674
|
+
var init_mcp_limit = __esm({
|
|
27675
|
+
"server/drivers/acp/mcp-limit.ts"() {
|
|
27676
|
+
"use strict";
|
|
27677
|
+
init_turn_mcp();
|
|
27678
|
+
reported = /* @__PURE__ */ new Set();
|
|
27679
|
+
}
|
|
27680
|
+
});
|
|
27681
|
+
|
|
27682
|
+
// server/drivers/acp/setup-failure.ts
|
|
27683
|
+
function failureFields(setup, failure, message3) {
|
|
27684
|
+
const named = failure ?? (setup && !classifyEngineFailure(message3) ? "provider_error" : void 0);
|
|
27685
|
+
return { ...setup ? { setup: true } : {}, ...named ? { failure: named } : {} };
|
|
27686
|
+
}
|
|
27687
|
+
var init_setup_failure = __esm({
|
|
27688
|
+
"server/drivers/acp/setup-failure.ts"() {
|
|
27689
|
+
"use strict";
|
|
27690
|
+
init_engine_failure();
|
|
27691
|
+
}
|
|
27692
|
+
});
|
|
27693
|
+
|
|
27606
27694
|
// shared/approval-readback.ts
|
|
27607
|
-
function compareEffectiveMode(ladder, requested,
|
|
27608
|
-
const want =
|
|
27609
|
-
const got =
|
|
27695
|
+
function compareEffectiveMode(ladder, requested, reported2) {
|
|
27696
|
+
const want = text5(requested);
|
|
27697
|
+
const got = text5(reported2);
|
|
27610
27698
|
const ranks = MODE_LADDERS[ladder];
|
|
27611
27699
|
if (want === null || got === null) return { status: "unverified", requested: want, reported: got };
|
|
27612
27700
|
const wantRank = ranks?.[want];
|
|
@@ -27619,14 +27707,14 @@ function compareEffectiveMode(ladder, requested, reported) {
|
|
|
27619
27707
|
function looserModeMessage(engine, readback) {
|
|
27620
27708
|
return `${engine} ran with looser permissions than requested (asked for "${readback.requested}", it reported "${readback.reported}"), so Atomic stopped the turn before it could act. Update ${engine}, check its own settings for a pinned mode, then try again.`;
|
|
27621
27709
|
}
|
|
27622
|
-
function assertEffectiveModeNotLooser(engine, ladder, requested,
|
|
27623
|
-
const readback = compareEffectiveMode(ladder, requested,
|
|
27710
|
+
function assertEffectiveModeNotLooser(engine, ladder, requested, reported2) {
|
|
27711
|
+
const readback = compareEffectiveMode(ladder, requested, reported2);
|
|
27624
27712
|
if (readback.status === "looser") {
|
|
27625
27713
|
throw Object.assign(new Error(looserModeMessage(engine, readback)), { code: "APPROVAL_MODE_LOOSER", readback });
|
|
27626
27714
|
}
|
|
27627
27715
|
return readback;
|
|
27628
27716
|
}
|
|
27629
|
-
var MODE_LADDERS,
|
|
27717
|
+
var MODE_LADDERS, text5;
|
|
27630
27718
|
var init_approval_readback = __esm({
|
|
27631
27719
|
"shared/approval-readback.ts"() {
|
|
27632
27720
|
"use strict";
|
|
@@ -27637,7 +27725,7 @@ var init_approval_readback = __esm({
|
|
|
27637
27725
|
qwenAgent: { plan: 4, default: 3, "auto-edit": 2, autoEdit: 2, auto: 1, yolo: 0 },
|
|
27638
27726
|
geminiAgent: { plan: 4, default: 3, autoEdit: 2, auto_edit: 2, "auto-edit": 2, yolo: 0 }
|
|
27639
27727
|
};
|
|
27640
|
-
|
|
27728
|
+
text5 = (value) => typeof value === "string" && value.trim() ? value.trim() : null;
|
|
27641
27729
|
}
|
|
27642
27730
|
});
|
|
27643
27731
|
|
|
@@ -27659,10 +27747,10 @@ function noteModeUpdate(session, raw) {
|
|
|
27659
27747
|
function forgetStaleModeReport(session, support12) {
|
|
27660
27748
|
if (support12.approvalModeReadback?.setsModeOverWire) stateOf(session).reported = null;
|
|
27661
27749
|
}
|
|
27662
|
-
function approvalReadbackFor(support12, config2, turn,
|
|
27750
|
+
function approvalReadbackFor(support12, config2, turn, reported2) {
|
|
27663
27751
|
const rules = support12.approvalModeReadback;
|
|
27664
|
-
if (!rules) return { status: "unverified", requested: null, reported };
|
|
27665
|
-
return compareEffectiveMode(rules.ladder, rules.expected(config2, turn),
|
|
27752
|
+
if (!rules) return { status: "unverified", requested: null, reported: reported2 };
|
|
27753
|
+
return compareEffectiveMode(rules.ladder, rules.expected(config2, turn), reported2);
|
|
27666
27754
|
}
|
|
27667
27755
|
function armModeReadback(input) {
|
|
27668
27756
|
const { support: support12, session, config: config2, turn } = input;
|
|
@@ -27699,28 +27787,6 @@ import { createHash as createHash5 } from "node:crypto";
|
|
|
27699
27787
|
function skipSubscriptionAuthForLocalInject(model) {
|
|
27700
27788
|
return Boolean(decodeInjectId(model));
|
|
27701
27789
|
}
|
|
27702
|
-
function acpRpcError(value, method) {
|
|
27703
|
-
const message3 = typeof value?.message === "string" ? value.message : "ACP request failed";
|
|
27704
|
-
const data = value?.data;
|
|
27705
|
-
const detail = typeof data === "string" ? data : typeof data?.details === "string" ? data.details : typeof data?.message === "string" ? data.message : typeof data?.error?.message === "string" ? data.error.message : "";
|
|
27706
|
-
const context = [
|
|
27707
|
-
method,
|
|
27708
|
-
typeof data?.service === "string" ? `service: ${data.service}` : "",
|
|
27709
|
-
typeof data?.errorName === "string" ? data.errorName : ""
|
|
27710
|
-
].filter(Boolean).join(", ");
|
|
27711
|
-
const said = detail && detail !== message3 ? `${message3}: ${detail}` : message3;
|
|
27712
|
-
const reset = parseResetAt(said) === void 0 ? resetHintFromData(data) : void 0;
|
|
27713
|
-
const diagnostic = `${said}${reset ? ` (${reset})` : ""} (${context})`;
|
|
27714
|
-
const error51 = new Error(redactSecretsInText(diagnostic).slice(0, 1500));
|
|
27715
|
-
return Object.assign(error51, {
|
|
27716
|
-
code: value?.code,
|
|
27717
|
-
data,
|
|
27718
|
-
// -32603 is JSON-RPC's internal error. Invalid params, unsupported
|
|
27719
|
-
// methods and auth refusals are user/configuration issues, not evidence
|
|
27720
|
-
// of a broken process. Preserve their session instead of retrying them.
|
|
27721
|
-
acpSessionFailure: value?.code === -32603
|
|
27722
|
-
});
|
|
27723
|
-
}
|
|
27724
27790
|
function classifyAcpError(support12, error51) {
|
|
27725
27791
|
const code = support12.classifyError?.(error51);
|
|
27726
27792
|
if (code) return code;
|
|
@@ -27953,7 +28019,7 @@ function createAcpDriver(support12) {
|
|
|
27953
28019
|
emit({
|
|
27954
28020
|
...base3(threadId, current.turnId),
|
|
27955
28021
|
type: "runtime.error",
|
|
27956
|
-
message: `${DRIVER_KIND8} ended the turn with no reply, image, or tool result`
|
|
28022
|
+
message: current.emptyReason ?? `${DRIVER_KIND8} ended the turn with no reply, image, or tool result`
|
|
27957
28023
|
});
|
|
27958
28024
|
}
|
|
27959
28025
|
emit({ ...base3(threadId, current.turnId), type: "turn.completed", ok: finalOk, stopReason: finalStopReason, cost: null });
|
|
@@ -28374,11 +28440,8 @@ function createAcpDriver(support12) {
|
|
|
28374
28440
|
session.dead = true;
|
|
28375
28441
|
const current = session.current;
|
|
28376
28442
|
if (current) {
|
|
28377
|
-
|
|
28378
|
-
|
|
28379
|
-
type: "runtime.error",
|
|
28380
|
-
message: `${DRIVER_KIND8} exited ${code} before the prompt result${session.stderr ? `: ${session.stderr.trim().slice(-300)}` : ""}`
|
|
28381
|
-
});
|
|
28443
|
+
const message3 = `${DRIVER_KIND8} exited ${code} before the prompt result${session.stderr ? `: ${session.stderr.trim().slice(-300)}` : ""}`;
|
|
28444
|
+
emit({ ...base3(threadId, current.turnId), type: "runtime.error", message: message3, ...failureFields(!current.state.promptSent && !session.closing, void 0, message3) });
|
|
28382
28445
|
settle(threadId, session, false, "exit_before_result");
|
|
28383
28446
|
} else if (sessions.get(threadId) === session) {
|
|
28384
28447
|
sessions.delete(threadId);
|
|
@@ -28479,11 +28542,11 @@ function createAcpDriver(support12) {
|
|
|
28479
28542
|
return option;
|
|
28480
28543
|
};
|
|
28481
28544
|
const flushAssistantText = () => {
|
|
28482
|
-
const
|
|
28545
|
+
const text7 = state2.text;
|
|
28483
28546
|
state2.text = "";
|
|
28484
|
-
if (!
|
|
28547
|
+
if (!text7.trim()) return;
|
|
28485
28548
|
state2.producedItem = true;
|
|
28486
|
-
emit({ ...base3(threadId, turnId), type: "item.completed", itemType: "assistant_text", text:
|
|
28549
|
+
emit({ ...base3(threadId, turnId), type: "item.completed", itemType: "assistant_text", text: text7 });
|
|
28487
28550
|
};
|
|
28488
28551
|
const current = {
|
|
28489
28552
|
turnId,
|
|
@@ -28568,9 +28631,10 @@ function createAcpDriver(support12) {
|
|
|
28568
28631
|
if (liveSessionId !== null && session.sessionKey === sessionKey && (cursor3 === null || cursor3 === liveSessionId)) {
|
|
28569
28632
|
break;
|
|
28570
28633
|
}
|
|
28571
|
-
const sessionServers = mcpServers.filter((server) => !("type" in server) || init?.agentCapabilities?.mcpCapabilities?.[server.type] === true);
|
|
28634
|
+
const sessionServers = sessionMcpServers(support12, mcpServers.filter((server) => !("type" in server) || init?.agentCapabilities?.mcpCapabilities?.[server.type] === true));
|
|
28572
28635
|
let loaded = false;
|
|
28573
|
-
|
|
28636
|
+
const fresh = support12.freshSessionForLocalModel === true && liveSessionId !== cursor3 && decodeInjectId(turn.model) !== null;
|
|
28637
|
+
if (cursor3 && !fresh) {
|
|
28574
28638
|
try {
|
|
28575
28639
|
await request(
|
|
28576
28640
|
support12.resumeMethod === "resume" ? "session/resume" : "session/load",
|
|
@@ -28714,7 +28778,7 @@ function createAcpDriver(support12) {
|
|
|
28714
28778
|
}
|
|
28715
28779
|
emitSessionStarted();
|
|
28716
28780
|
const instructed = promptWithInstructions(threadId, sessionId, createdNativeSession, promptTurn);
|
|
28717
|
-
const
|
|
28781
|
+
const text7 = support12.buildPromptText ? support12.buildPromptText(instructed) : instructed.system ? `${instructed.system}
|
|
28718
28782
|
|
|
28719
28783
|
${instructed.text}` : instructed.text;
|
|
28720
28784
|
const imageBlocks = support12.images === true && runtimeAcceptsImages ? await readAcpImageBlocks(turn.images ?? []) : [];
|
|
@@ -28737,10 +28801,11 @@ ${instructed.text}` : instructed.text;
|
|
|
28737
28801
|
}
|
|
28738
28802
|
});
|
|
28739
28803
|
state2.promptSent = true;
|
|
28804
|
+
const promptedAt = Date.now();
|
|
28740
28805
|
const promptIdleMs = promptIdleTimeoutMs(support12, cliTurn.model);
|
|
28741
28806
|
const result = await request(
|
|
28742
28807
|
"session/prompt",
|
|
28743
|
-
{ sessionId, prompt: [{ type: "text", text:
|
|
28808
|
+
{ sessionId, prompt: [{ type: "text", text: text7 }, ...imageBlocks] },
|
|
28744
28809
|
void 0,
|
|
28745
28810
|
void 0,
|
|
28746
28811
|
promptIdleMs,
|
|
@@ -28759,8 +28824,10 @@ ${instructed.text}` : instructed.text;
|
|
|
28759
28824
|
});
|
|
28760
28825
|
}
|
|
28761
28826
|
const reason = result?.stopReason;
|
|
28762
|
-
if (reason === "end_turn")
|
|
28763
|
-
|
|
28827
|
+
if (reason === "end_turn") {
|
|
28828
|
+
if (!state2.producedItem && !state2.text.trim()) current.emptyReason = await support12.explainEmptyTurn?.({ sessionId, since: promptedAt, env });
|
|
28829
|
+
settle(threadId, session, true, null);
|
|
28830
|
+
} else if (reason === "cancelled") settle(threadId, session, true, "cancelled");
|
|
28764
28831
|
else {
|
|
28765
28832
|
const errorMessage = typeof result?.error === "string" && result.error ? result.error : typeof result?.message === "string" && result.message ? result.message : `Model turn failed: ${reason ?? "unknown error"}`;
|
|
28766
28833
|
emit({
|
|
@@ -28779,13 +28846,8 @@ ${instructed.text}` : instructed.text;
|
|
|
28779
28846
|
const stalled = e?.acpPromptStall === true;
|
|
28780
28847
|
const needsAuth = code === "invalid_credentials" || code === "inactive_subscription" || message3 === support12.loginNote || logAuth;
|
|
28781
28848
|
const failure = needsAuth ? "auth_failed" : stalled ? "stalled" : engineFailureFromCode(code) ?? (isOpaqueRequestRejection(message3) ? "request_rejected" : void 0);
|
|
28782
|
-
|
|
28783
|
-
|
|
28784
|
-
type: "runtime.error",
|
|
28785
|
-
message: message3,
|
|
28786
|
-
...needsAuth ? { setup: true } : {},
|
|
28787
|
-
...failure ? { failure } : {}
|
|
28788
|
-
});
|
|
28849
|
+
const setup = needsAuth || !state2.promptSent && !session.closing;
|
|
28850
|
+
emit({ ...base3(threadId, turnId), type: "runtime.error", message: message3, ...failureFields(setup, failure, message3) });
|
|
28789
28851
|
if ((logAuth || !needsAuth && (stalled || isBrokenAntigravityCheckpoint(DRIVER_KIND8, message3) || e?.acpSessionFailure === true || code === "upstream_outage")) && session.child.exitCode === null && !session.closing) {
|
|
28790
28852
|
closeSession(threadId, logAuth ? "provider-auth" : stalled ? "prompt-stall" : "rpc-failure");
|
|
28791
28853
|
}
|
|
@@ -28877,7 +28939,6 @@ var init_core3 = __esm({
|
|
|
28877
28939
|
init_tool_summary();
|
|
28878
28940
|
init_mcp_tool_images();
|
|
28879
28941
|
init_mcp_tool_ref();
|
|
28880
|
-
init_redact2();
|
|
28881
28942
|
init_checkpoint_recovery();
|
|
28882
28943
|
init_resume_recovery();
|
|
28883
28944
|
init_retry();
|
|
@@ -28885,6 +28946,9 @@ var init_core3 = __esm({
|
|
|
28885
28946
|
init_turn_mcp();
|
|
28886
28947
|
init_volatile_notes();
|
|
28887
28948
|
init_tool_log();
|
|
28949
|
+
init_rpc_error();
|
|
28950
|
+
init_mcp_limit();
|
|
28951
|
+
init_setup_failure();
|
|
28888
28952
|
init_mode_readback();
|
|
28889
28953
|
envOr = (key, fallback) => Number(process.env[key] ?? fallback);
|
|
28890
28954
|
INIT_TIMEOUT = envOr("OPENMAUS_ACP_INIT_TIMEOUT_MS", 3e5);
|
|
@@ -29636,25 +29700,25 @@ async function pinnedZipEntries(path4) {
|
|
|
29636
29700
|
try {
|
|
29637
29701
|
const info = await handle.stat();
|
|
29638
29702
|
const tailBytes = Math.min(info.size, MAX_EOCD_BYTES);
|
|
29639
|
-
const
|
|
29703
|
+
const tail3 = Buffer.alloc(tailBytes);
|
|
29640
29704
|
const tailOffset = info.size - tailBytes;
|
|
29641
|
-
if ((await handle.read(
|
|
29705
|
+
if ((await handle.read(tail3, 0, tailBytes, tailOffset)).bytesRead !== tailBytes) {
|
|
29642
29706
|
throw new Error("The verified archive was truncated.");
|
|
29643
29707
|
}
|
|
29644
29708
|
let eocd = -1;
|
|
29645
|
-
for (let cursor4 =
|
|
29646
|
-
if (
|
|
29709
|
+
for (let cursor4 = tail3.length - 22; cursor4 >= 0; cursor4 -= 1) {
|
|
29710
|
+
if (tail3.readUInt32LE(cursor4) === EOCD_SIGNATURE && cursor4 + 22 + tail3.readUInt16LE(cursor4 + 20) === tail3.length) {
|
|
29647
29711
|
eocd = cursor4;
|
|
29648
29712
|
break;
|
|
29649
29713
|
}
|
|
29650
29714
|
}
|
|
29651
29715
|
if (eocd < 0) throw new Error("The verified archive has no valid ZIP directory.");
|
|
29652
|
-
const disk =
|
|
29653
|
-
const directoryDisk =
|
|
29654
|
-
const diskEntries =
|
|
29655
|
-
const entryCount =
|
|
29656
|
-
const directoryBytes =
|
|
29657
|
-
const directoryOffset =
|
|
29716
|
+
const disk = tail3.readUInt16LE(eocd + 4);
|
|
29717
|
+
const directoryDisk = tail3.readUInt16LE(eocd + 6);
|
|
29718
|
+
const diskEntries = tail3.readUInt16LE(eocd + 8);
|
|
29719
|
+
const entryCount = tail3.readUInt16LE(eocd + 10);
|
|
29720
|
+
const directoryBytes = tail3.readUInt32LE(eocd + 12);
|
|
29721
|
+
const directoryOffset = tail3.readUInt32LE(eocd + 16);
|
|
29658
29722
|
const eocdOffset = tailOffset + eocd;
|
|
29659
29723
|
if (disk !== 0 || directoryDisk !== 0 || diskEntries !== entryCount || entryCount !== 2 || directoryBytes === 4294967295 || directoryOffset === 4294967295 || directoryOffset + directoryBytes > eocdOffset) throw new Error("The verified archive uses an unsupported ZIP layout.");
|
|
29660
29724
|
const directory = Buffer.alloc(directoryBytes);
|
|
@@ -29791,7 +29855,7 @@ async function installOnce2(options) {
|
|
|
29791
29855
|
const handle = await open(archivePath, "wx", 384);
|
|
29792
29856
|
const hash2 = createHash7("sha256");
|
|
29793
29857
|
let downloaded = 0;
|
|
29794
|
-
let
|
|
29858
|
+
let reported2 = 0;
|
|
29795
29859
|
options.onProgress?.({ phase: "downloading", received: 0, total: asset.archiveBytes, detail: `Downloading ${asset.url}` });
|
|
29796
29860
|
try {
|
|
29797
29861
|
for await (const raw of response.body) {
|
|
@@ -29807,8 +29871,8 @@ async function installOnce2(options) {
|
|
|
29807
29871
|
}
|
|
29808
29872
|
hash2.update(chunk);
|
|
29809
29873
|
downloaded += chunk.length;
|
|
29810
|
-
if (downloaded -
|
|
29811
|
-
|
|
29874
|
+
if (downloaded - reported2 >= 4 * 1024 * 1024 || downloaded === asset.archiveBytes) {
|
|
29875
|
+
reported2 = downloaded;
|
|
29812
29876
|
options.onProgress?.({ phase: "downloading", received: downloaded, total: asset.archiveBytes });
|
|
29813
29877
|
}
|
|
29814
29878
|
}
|
|
@@ -30185,14 +30249,14 @@ var init_boxagent = __esm({
|
|
|
30185
30249
|
let pendingText = "";
|
|
30186
30250
|
let problem = null;
|
|
30187
30251
|
const flushAssistantText = () => {
|
|
30188
|
-
const
|
|
30252
|
+
const text7 = pendingText;
|
|
30189
30253
|
pendingText = "";
|
|
30190
|
-
if (!
|
|
30191
|
-
emit({ ...base3(threadId, turnId), type: "item.completed", itemType: "assistant_text", text:
|
|
30254
|
+
if (!text7.trim()) return;
|
|
30255
|
+
emit({ ...base3(threadId, turnId), type: "item.completed", itemType: "assistant_text", text: text7 });
|
|
30192
30256
|
};
|
|
30193
|
-
const ingest = (
|
|
30194
|
-
const delta =
|
|
30195
|
-
lastText =
|
|
30257
|
+
const ingest = (text7) => {
|
|
30258
|
+
const delta = text7.startsWith(lastText) ? text7.slice(lastText.length) : text7;
|
|
30259
|
+
lastText = text7;
|
|
30196
30260
|
if (!delta) return;
|
|
30197
30261
|
pendingText += delta;
|
|
30198
30262
|
emit({ ...base3(threadId, turnId), type: "content.delta", streamKind: "assistant_text", delta });
|
|
@@ -30210,9 +30274,9 @@ var init_boxagent = __esm({
|
|
|
30210
30274
|
seen.add(id);
|
|
30211
30275
|
appendNative(threadId, { dir: "in", source: "box.events", msg: ev });
|
|
30212
30276
|
const kind = String(ev.type ?? ev.kind ?? "");
|
|
30213
|
-
const
|
|
30214
|
-
if (/assistant|message|output|response/i.test(kind) && typeof
|
|
30215
|
-
ingest(
|
|
30277
|
+
const text7 = ev.text ?? ev.message ?? ev.data?.text ?? ev.data?.content ?? null;
|
|
30278
|
+
if (/assistant|message|output|response/i.test(kind) && typeof text7 === "string" && text7.trim()) {
|
|
30279
|
+
ingest(text7);
|
|
30216
30280
|
} else if (/usage_limit|error|fail/i.test(kind)) {
|
|
30217
30281
|
const why = ev.data?.summary ?? ev.data?.message ?? ev.data?.error ?? ev.message;
|
|
30218
30282
|
if (typeof why === "string" && why.trim()) problem = why.trim();
|
|
@@ -30329,8 +30393,8 @@ function toolName(tool2) {
|
|
|
30329
30393
|
function bareTool(tool2) {
|
|
30330
30394
|
return toolName(tool2).toLowerCase();
|
|
30331
30395
|
}
|
|
30332
|
-
function collapse(
|
|
30333
|
-
return
|
|
30396
|
+
function collapse(text7) {
|
|
30397
|
+
return text7.trim().replace(/\s+/g, " ");
|
|
30334
30398
|
}
|
|
30335
30399
|
function isShellTool(tool2) {
|
|
30336
30400
|
return SHELL_TOOL.test(bareTool(tool2));
|
|
@@ -30889,8 +30953,8 @@ var init_rtk_rewrite = __esm({
|
|
|
30889
30953
|
|
|
30890
30954
|
// server/drivers/claude-stdin.ts
|
|
30891
30955
|
import { readFileSync as readFileSync10 } from "node:fs";
|
|
30892
|
-
function claudeUserMessage(
|
|
30893
|
-
if (!images?.length) return { type: "user", message: { role: "user", content:
|
|
30956
|
+
function claudeUserMessage(text7, images) {
|
|
30957
|
+
if (!images?.length) return { type: "user", message: { role: "user", content: text7 } };
|
|
30894
30958
|
const content = images.map((image) => ({
|
|
30895
30959
|
type: "image",
|
|
30896
30960
|
source: {
|
|
@@ -30899,7 +30963,7 @@ function claudeUserMessage(text6, images) {
|
|
|
30899
30963
|
data: readFileSync10(image.path).toString("base64")
|
|
30900
30964
|
}
|
|
30901
30965
|
}));
|
|
30902
|
-
if (
|
|
30966
|
+
if (text7) content.push({ type: "text", text: text7 });
|
|
30903
30967
|
return { type: "user", message: { role: "user", content } };
|
|
30904
30968
|
}
|
|
30905
30969
|
function diagnosticClaudeUserMessage(message3) {
|
|
@@ -30939,9 +31003,9 @@ function isControl(char) {
|
|
|
30939
31003
|
}
|
|
30940
31004
|
function oneLine(value) {
|
|
30941
31005
|
if (typeof value !== "string") return null;
|
|
30942
|
-
const
|
|
30943
|
-
if (!
|
|
30944
|
-
return
|
|
31006
|
+
const text7 = Array.from(value, (char) => isControl(char) ? " " : char).join("").replace(/\s+/g, " ").trim();
|
|
31007
|
+
if (!text7) return null;
|
|
31008
|
+
return text7.length > MAX_MESSAGE ? `${text7.slice(0, MAX_MESSAGE - 1)}\u2026` : text7;
|
|
30945
31009
|
}
|
|
30946
31010
|
function yesValue(field) {
|
|
30947
31011
|
if (field.type === "boolean") return true;
|
|
@@ -31059,7 +31123,7 @@ var init_claude_elicitation = __esm({
|
|
|
31059
31123
|
});
|
|
31060
31124
|
|
|
31061
31125
|
// shared/ask-question.ts
|
|
31062
|
-
function
|
|
31126
|
+
function text6(value, limit) {
|
|
31063
31127
|
if (typeof value !== "string") return void 0;
|
|
31064
31128
|
const trimmed = value.trim();
|
|
31065
31129
|
return trimmed ? trimmed.slice(0, limit) : void 0;
|
|
@@ -31069,18 +31133,18 @@ function isRecord3(value) {
|
|
|
31069
31133
|
}
|
|
31070
31134
|
function parseOption(value) {
|
|
31071
31135
|
if (typeof value === "string") {
|
|
31072
|
-
const label2 =
|
|
31136
|
+
const label2 = text6(value, MAX_LABEL);
|
|
31073
31137
|
return label2 ? { label: label2 } : null;
|
|
31074
31138
|
}
|
|
31075
31139
|
if (!isRecord3(value)) return null;
|
|
31076
|
-
const label =
|
|
31140
|
+
const label = text6(value.label, MAX_LABEL);
|
|
31077
31141
|
if (!label) return null;
|
|
31078
|
-
const description =
|
|
31142
|
+
const description = text6(value.description, MAX_DESCRIPTION);
|
|
31079
31143
|
return description ? { label, description } : { label };
|
|
31080
31144
|
}
|
|
31081
31145
|
function parseQuestion(value) {
|
|
31082
31146
|
if (!isRecord3(value)) return null;
|
|
31083
|
-
const question =
|
|
31147
|
+
const question = text6(value.question, MAX_QUESTION_TEXT);
|
|
31084
31148
|
if (!question) return null;
|
|
31085
31149
|
const options = [];
|
|
31086
31150
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -31091,7 +31155,7 @@ function parseQuestion(value) {
|
|
|
31091
31155
|
options.push(option);
|
|
31092
31156
|
if (options.length === MAX_OPTIONS) break;
|
|
31093
31157
|
}
|
|
31094
|
-
const header =
|
|
31158
|
+
const header = text6(value.header, MAX_LABEL);
|
|
31095
31159
|
return {
|
|
31096
31160
|
question,
|
|
31097
31161
|
...header ? { header } : {},
|
|
@@ -31120,7 +31184,7 @@ function parseChoices(input, limit = MAX_CHOICES) {
|
|
|
31120
31184
|
const choices = [];
|
|
31121
31185
|
const seen = /* @__PURE__ */ new Set();
|
|
31122
31186
|
for (const raw of input) {
|
|
31123
|
-
const label = typeof raw === "string" ?
|
|
31187
|
+
const label = typeof raw === "string" ? text6(raw, MAX_LABEL) : isRecord3(raw) ? text6(raw.label, MAX_LABEL) : void 0;
|
|
31124
31188
|
if (!label || seen.has(label)) continue;
|
|
31125
31189
|
seen.add(label);
|
|
31126
31190
|
choices.push(label);
|
|
@@ -31177,19 +31241,19 @@ function resolveClaudeConfigDir(configDir2, env = process.env) {
|
|
|
31177
31241
|
}
|
|
31178
31242
|
return normalize(expanded);
|
|
31179
31243
|
}
|
|
31180
|
-
function claudeAuthFailure(frame,
|
|
31244
|
+
function claudeAuthFailure(frame, text7) {
|
|
31181
31245
|
if (frame.is_api_error_message !== true && typeof frame.error !== "string") return false;
|
|
31182
|
-
return !isModelAccessRefused(
|
|
31246
|
+
return !isModelAccessRefused(text7) && (frame.error === "authentication_failed" || classifyError({ text: text7 }).reason === "auth_failed");
|
|
31183
31247
|
}
|
|
31184
|
-
function claudeCredentialRefreshConflict(frame,
|
|
31248
|
+
function claudeCredentialRefreshConflict(frame, text7) {
|
|
31185
31249
|
if (frame.is_api_error_message !== true && typeof frame.error !== "string") return false;
|
|
31186
|
-
return CREDENTIAL_REFRESH_CONFLICT.test(
|
|
31250
|
+
return CREDENTIAL_REFRESH_CONFLICT.test(text7);
|
|
31187
31251
|
}
|
|
31188
31252
|
function claudeResultStopReason(o) {
|
|
31189
|
-
const
|
|
31190
|
-
if (o.is_error !== true) return
|
|
31191
|
-
const subtype =
|
|
31192
|
-
return
|
|
31253
|
+
const text7 = (value) => typeof value === "string" && value.trim() ? value.trim() : null;
|
|
31254
|
+
if (o.is_error !== true) return text7(o.stop_reason) ?? text7(o.terminal_reason);
|
|
31255
|
+
const subtype = text7(o.subtype);
|
|
31256
|
+
return text7(o.terminal_reason) ?? (subtype && subtype !== "success" ? subtype : null) ?? "error";
|
|
31193
31257
|
}
|
|
31194
31258
|
function claudeEnvironment(model, source2 = process.env, configDir2, instanceEnvironment = {}) {
|
|
31195
31259
|
const env = { ...source2, PATH: augmentedPath(), NPM_CONFIG_LOGLEVEL: "error" };
|
|
@@ -32364,24 +32428,24 @@ var init_claude = __esm({
|
|
|
32364
32428
|
level: typeof msg.model === "string" ? "response-reported" : "unknown"
|
|
32365
32429
|
});
|
|
32366
32430
|
}
|
|
32367
|
-
const
|
|
32368
|
-
if (claudeAuthFailure(o,
|
|
32431
|
+
const text7 = firstText(msg.content);
|
|
32432
|
+
if (claudeAuthFailure(o, text7)) {
|
|
32369
32433
|
if (session.turn) session.turn.authFailed = true;
|
|
32370
|
-
emit({ ...base3(threadId, currentTurnId()), type: "runtime.error", message:
|
|
32434
|
+
emit({ ...base3(threadId, currentTurnId()), type: "runtime.error", message: text7, setup: true, failure: "auth_failed" });
|
|
32371
32435
|
break;
|
|
32372
32436
|
}
|
|
32373
|
-
if (claudeCredentialRefreshConflict(o,
|
|
32374
|
-
if (session.turn) session.turn.refreshConflict =
|
|
32437
|
+
if (claudeCredentialRefreshConflict(o, text7)) {
|
|
32438
|
+
if (session.turn) session.turn.refreshConflict = text7.trim();
|
|
32375
32439
|
break;
|
|
32376
32440
|
}
|
|
32377
|
-
if (
|
|
32378
|
-
if (
|
|
32441
|
+
if (text7.trim() && o.is_api_error_message !== true && typeof o.error !== "string" && session.turn) session.turn.produced = true;
|
|
32442
|
+
if (text7.trim()) {
|
|
32379
32443
|
const synthetic = o.is_api_error_message === true || typeof o.error === "string" ? { synthetic: true } : {};
|
|
32380
32444
|
if (!session.turn?.sawStreamDelta) {
|
|
32381
|
-
emit({ ...base3(threadId, currentTurnId()), ...synthetic, type: "content.delta", streamKind: "assistant_text", delta:
|
|
32445
|
+
emit({ ...base3(threadId, currentTurnId()), ...synthetic, type: "content.delta", streamKind: "assistant_text", delta: text7 });
|
|
32382
32446
|
}
|
|
32383
32447
|
if (session.turn) session.turn.sawStreamDelta = false;
|
|
32384
|
-
emit({ ...base3(threadId, currentTurnId()), ...synthetic, type: "item.completed", itemType: "assistant_text", text:
|
|
32448
|
+
emit({ ...base3(threadId, currentTurnId()), ...synthetic, type: "item.completed", itemType: "assistant_text", text: text7 });
|
|
32385
32449
|
}
|
|
32386
32450
|
for (const b3 of Array.isArray(msg.content) ? msg.content : []) {
|
|
32387
32451
|
if (b3.type === "tool_use") {
|
|
@@ -32632,12 +32696,12 @@ var init_claude = __esm({
|
|
|
32632
32696
|
}
|
|
32633
32697
|
return { turnId };
|
|
32634
32698
|
};
|
|
32635
|
-
const steer = async (threadId,
|
|
32699
|
+
const steer = async (threadId, text7) => {
|
|
32636
32700
|
const s4 = sessions.get(threadId);
|
|
32637
32701
|
if (!s4 || !s4.turn || s4.turn.settled || s4.closing || s4.child.exitCode !== null) return "refused";
|
|
32638
32702
|
const turn = s4.turn;
|
|
32639
32703
|
turn.pendingSteers = (turn.pendingSteers ?? 0) + 1;
|
|
32640
|
-
if (await writeUser(s4, threadId, claudeUserMessage(
|
|
32704
|
+
if (await writeUser(s4, threadId, claudeUserMessage(text7, void 0))) return "steered";
|
|
32641
32705
|
turn.pendingSteers = Math.max(0, turn.pendingSteers - 1);
|
|
32642
32706
|
return "refused";
|
|
32643
32707
|
};
|
|
@@ -32872,42 +32936,42 @@ var init_codex_tool_surface = __esm({
|
|
|
32872
32936
|
});
|
|
32873
32937
|
|
|
32874
32938
|
// server/toml-lite.ts
|
|
32875
|
-
function parseTomlLite(
|
|
32939
|
+
function parseTomlLite(text7) {
|
|
32876
32940
|
const root = {};
|
|
32877
32941
|
let current = root;
|
|
32878
32942
|
let pos = 0;
|
|
32879
|
-
const peek = () =>
|
|
32943
|
+
const peek = () => text7[pos];
|
|
32880
32944
|
const skipSpaces = () => {
|
|
32881
|
-
while (pos <
|
|
32945
|
+
while (pos < text7.length && (text7[pos] === " " || text7[pos] === " ")) pos += 1;
|
|
32882
32946
|
};
|
|
32883
32947
|
const skipComment = () => {
|
|
32884
|
-
if (
|
|
32948
|
+
if (text7[pos] === "#") while (pos < text7.length && text7[pos] !== "\n") pos += 1;
|
|
32885
32949
|
};
|
|
32886
32950
|
const skipBlank = () => {
|
|
32887
32951
|
for (; ; ) {
|
|
32888
32952
|
const before = pos;
|
|
32889
|
-
while (pos <
|
|
32953
|
+
while (pos < text7.length && /[ \t\r\n]/.test(text7[pos])) pos += 1;
|
|
32890
32954
|
skipComment();
|
|
32891
32955
|
if (pos === before) return;
|
|
32892
32956
|
}
|
|
32893
32957
|
};
|
|
32894
32958
|
const skipLine = () => {
|
|
32895
|
-
while (pos <
|
|
32959
|
+
while (pos < text7.length && text7[pos] !== "\n") pos += 1;
|
|
32896
32960
|
};
|
|
32897
32961
|
const basicString = () => {
|
|
32898
|
-
const multi =
|
|
32962
|
+
const multi = text7.startsWith('"""', pos);
|
|
32899
32963
|
pos += multi ? 3 : 1;
|
|
32900
|
-
if (multi &&
|
|
32964
|
+
if (multi && text7[pos] === "\n") pos += 1;
|
|
32901
32965
|
let out = "";
|
|
32902
|
-
while (pos <
|
|
32903
|
-
if (multi ?
|
|
32966
|
+
while (pos < text7.length) {
|
|
32967
|
+
if (multi ? text7.startsWith('"""', pos) : text7[pos] === '"') {
|
|
32904
32968
|
pos += multi ? 3 : 1;
|
|
32905
32969
|
return out;
|
|
32906
32970
|
}
|
|
32907
|
-
const ch =
|
|
32971
|
+
const ch = text7[pos];
|
|
32908
32972
|
if (!multi && ch === "\n") throw new TomlError("unterminated string");
|
|
32909
32973
|
if (ch === "\\") {
|
|
32910
|
-
const next =
|
|
32974
|
+
const next = text7[pos + 1];
|
|
32911
32975
|
pos += 2;
|
|
32912
32976
|
if (next === "n") out += "\n";
|
|
32913
32977
|
else if (next === "t") out += " ";
|
|
@@ -32915,10 +32979,10 @@ function parseTomlLite(text6) {
|
|
|
32915
32979
|
else if (next === '"' || next === "\\") out += next;
|
|
32916
32980
|
else if (next === "u" || next === "U") {
|
|
32917
32981
|
const length = next === "u" ? 4 : 8;
|
|
32918
|
-
out += String.fromCodePoint(parseInt(
|
|
32982
|
+
out += String.fromCodePoint(parseInt(text7.slice(pos, pos + length), 16));
|
|
32919
32983
|
pos += length;
|
|
32920
32984
|
} else if (multi && next === "\n") {
|
|
32921
|
-
while (pos <
|
|
32985
|
+
while (pos < text7.length && /[ \t\r\n]/.test(text7[pos])) pos += 1;
|
|
32922
32986
|
} else out += next ?? "";
|
|
32923
32987
|
continue;
|
|
32924
32988
|
}
|
|
@@ -32928,12 +32992,12 @@ function parseTomlLite(text6) {
|
|
|
32928
32992
|
throw new TomlError("unterminated string");
|
|
32929
32993
|
};
|
|
32930
32994
|
const literalString = () => {
|
|
32931
|
-
const multi =
|
|
32995
|
+
const multi = text7.startsWith("'''", pos);
|
|
32932
32996
|
pos += multi ? 3 : 1;
|
|
32933
|
-
if (multi &&
|
|
32934
|
-
const end =
|
|
32997
|
+
if (multi && text7[pos] === "\n") pos += 1;
|
|
32998
|
+
const end = text7.indexOf(multi ? "'''" : "'", pos);
|
|
32935
32999
|
if (end < 0) throw new TomlError("unterminated string");
|
|
32936
|
-
const value2 =
|
|
33000
|
+
const value2 = text7.slice(pos, end);
|
|
32937
33001
|
if (!multi && value2.includes("\n")) throw new TomlError("unterminated string");
|
|
32938
33002
|
pos = end + (multi ? 3 : 1);
|
|
32939
33003
|
return value2;
|
|
@@ -32943,9 +33007,9 @@ function parseTomlLite(text6) {
|
|
|
32943
33007
|
if (peek() === '"') return basicString();
|
|
32944
33008
|
if (peek() === "'") return literalString();
|
|
32945
33009
|
const start = pos;
|
|
32946
|
-
while (pos <
|
|
33010
|
+
while (pos < text7.length && /[A-Za-z0-9_-]/.test(text7[pos])) pos += 1;
|
|
32947
33011
|
if (pos === start) throw new TomlError("expected a key");
|
|
32948
|
-
return
|
|
33012
|
+
return text7.slice(start, pos);
|
|
32949
33013
|
};
|
|
32950
33014
|
const keyPath = () => {
|
|
32951
33015
|
const parts = [key()];
|
|
@@ -32997,8 +33061,8 @@ function parseTomlLite(text6) {
|
|
|
32997
33061
|
}
|
|
32998
33062
|
}
|
|
32999
33063
|
const start = pos;
|
|
33000
|
-
while (pos <
|
|
33001
|
-
const raw =
|
|
33064
|
+
while (pos < text7.length && !/[,\]}\r\n#]/.test(text7[pos])) pos += 1;
|
|
33065
|
+
const raw = text7.slice(start, pos).trim();
|
|
33002
33066
|
if (raw === "true") return true;
|
|
33003
33067
|
if (raw === "false") return false;
|
|
33004
33068
|
const number5 = Number(raw.replace(/_/g, ""));
|
|
@@ -33023,12 +33087,12 @@ function parseTomlLite(text6) {
|
|
|
33023
33087
|
const parent = tableAt(base3, path4.slice(0, -1));
|
|
33024
33088
|
parent[path4[path4.length - 1]] = item;
|
|
33025
33089
|
}
|
|
33026
|
-
while (pos <
|
|
33090
|
+
while (pos < text7.length) {
|
|
33027
33091
|
skipBlank();
|
|
33028
|
-
if (pos >=
|
|
33092
|
+
if (pos >= text7.length) break;
|
|
33029
33093
|
const lineStart = pos;
|
|
33030
33094
|
try {
|
|
33031
|
-
if (
|
|
33095
|
+
if (text7.startsWith("[[", pos)) {
|
|
33032
33096
|
pos += 2;
|
|
33033
33097
|
keyPath();
|
|
33034
33098
|
current = {};
|
|
@@ -33634,7 +33698,7 @@ function unquote(raw) {
|
|
|
33634
33698
|
}
|
|
33635
33699
|
return value;
|
|
33636
33700
|
}
|
|
33637
|
-
function parseCodexToml(
|
|
33701
|
+
function parseCodexToml(text7) {
|
|
33638
33702
|
const result = { providers: [] };
|
|
33639
33703
|
const byId = /* @__PURE__ */ new Map();
|
|
33640
33704
|
let section = "root";
|
|
@@ -33647,7 +33711,7 @@ function parseCodexToml(text6) {
|
|
|
33647
33711
|
}
|
|
33648
33712
|
return provider;
|
|
33649
33713
|
};
|
|
33650
|
-
for (const line of
|
|
33714
|
+
for (const line of text7.split(/\r?\n/)) {
|
|
33651
33715
|
const stripped = line.trim();
|
|
33652
33716
|
if (!stripped || stripped.startsWith("#")) continue;
|
|
33653
33717
|
if (stripped.startsWith("[") && stripped.endsWith("]")) {
|
|
@@ -34325,8 +34389,8 @@ function codexRetryHttpStatus(info) {
|
|
|
34325
34389
|
function withCodexReset(message3, info) {
|
|
34326
34390
|
const hint = parseResetAt(message3) === void 0 ? resetHintFromData(info) : void 0;
|
|
34327
34391
|
if (!hint) return message3.slice(0, 400);
|
|
34328
|
-
const
|
|
34329
|
-
return `${message3.slice(0, 400 -
|
|
34392
|
+
const tail3 = ` (${hint})`;
|
|
34393
|
+
return `${message3.slice(0, 400 - tail3.length)}${tail3}`;
|
|
34330
34394
|
}
|
|
34331
34395
|
function missingNativeCodexThread(error51, cursor3) {
|
|
34332
34396
|
return error51 instanceof CodexRpcError && error51.code === -32600 && error51.message === `no rollout found for thread id ${cursor3}`;
|
|
@@ -34908,14 +34972,14 @@ var init_codex = __esm({
|
|
|
34908
34972
|
emit({ ...base3(threadId, turnId), type: "runtime.error", message: "codex did not shut down after termination was requested" });
|
|
34909
34973
|
}
|
|
34910
34974
|
};
|
|
34911
|
-
const steerActiveTurn = async (
|
|
34975
|
+
const steerActiveTurn = async (text7) => {
|
|
34912
34976
|
if (state2.settled || abandoned || stopRequested || !codexThreadId || !codexTurnId) return "refused";
|
|
34913
34977
|
if (child.exitCode !== null || child.signalCode !== null) return "refused";
|
|
34914
34978
|
try {
|
|
34915
34979
|
const steerTimeoutMs = Math.max(1, Number(process.env.FAKE_CODEX_STEER_TIMEOUT_MS ?? 1e4) || 1e4);
|
|
34916
34980
|
await request("turn/steer", {
|
|
34917
34981
|
threadId: codexThreadId,
|
|
34918
|
-
input: [{ type: "text", text:
|
|
34982
|
+
input: [{ type: "text", text: text7 }],
|
|
34919
34983
|
expectedTurnId: codexTurnId
|
|
34920
34984
|
}, steerTimeoutMs);
|
|
34921
34985
|
return "steered";
|
|
@@ -35522,9 +35586,9 @@ ${status.stderr}`)) {
|
|
|
35522
35586
|
interruptTurn: async (threadId) => {
|
|
35523
35587
|
await active.get(threadId)?.stop();
|
|
35524
35588
|
},
|
|
35525
|
-
steer: async (threadId,
|
|
35589
|
+
steer: async (threadId, text7) => {
|
|
35526
35590
|
const turn = active.get(threadId);
|
|
35527
|
-
return turn?.steer ? await turn.steer(
|
|
35591
|
+
return turn?.steer ? await turn.steer(text7) : "refused";
|
|
35528
35592
|
},
|
|
35529
35593
|
respondToRequest: async (threadId, requestId, decision) => {
|
|
35530
35594
|
const turn = active.get(threadId);
|
|
@@ -38711,8 +38775,8 @@ var require_utils = __commonJS({
|
|
|
38711
38775
|
}
|
|
38712
38776
|
if (bestLength < 2) return hextets.join(":");
|
|
38713
38777
|
const head = hextets.slice(0, bestStart).join(":");
|
|
38714
|
-
const
|
|
38715
|
-
return head + "::" +
|
|
38778
|
+
const tail3 = hextets.slice(bestStart + bestLength).join(":");
|
|
38779
|
+
return head + "::" + tail3;
|
|
38716
38780
|
}
|
|
38717
38781
|
function normalizeIPv6Address(input) {
|
|
38718
38782
|
const compression = input.indexOf("::");
|
|
@@ -40145,7 +40209,7 @@ var require_core = __commonJS({
|
|
|
40145
40209
|
errorsText(errors = this.errors, { separator = ", ", dataVar = "data" } = {}) {
|
|
40146
40210
|
if (!errors || errors.length === 0)
|
|
40147
40211
|
return "No errors";
|
|
40148
|
-
return errors.map((e) => `${dataVar}${e.instancePath} ${e.message}`).reduce((
|
|
40212
|
+
return errors.map((e) => `${dataVar}${e.instancePath} ${e.message}`).reduce((text7, msg) => text7 + separator + msg);
|
|
40149
40213
|
}
|
|
40150
40214
|
$dataMetaSchema(metaSchema, keywordsJsonPointers) {
|
|
40151
40215
|
const rules = this.RULES.all;
|
|
@@ -44669,7 +44733,7 @@ function boundedText(value) {
|
|
|
44669
44733
|
[MCP result truncated at 50KB; request less output.]`;
|
|
44670
44734
|
}
|
|
44671
44735
|
function namesBlockedPath(args, roots, home = homedir17()) {
|
|
44672
|
-
const slash = (
|
|
44736
|
+
const slash = (text7) => text7.replaceAll("\\", "/").toLowerCase();
|
|
44673
44737
|
const needles = roots.flatMap((root) => {
|
|
44674
44738
|
const full = slash(root).replace(/\/+$/, "");
|
|
44675
44739
|
const base3 = slash(home).replace(/\/+$/, "");
|
|
@@ -45101,6 +45165,17 @@ var init_chat_tool_approval = __esm({
|
|
|
45101
45165
|
function object3(value) {
|
|
45102
45166
|
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
45103
45167
|
}
|
|
45168
|
+
function providerError(json2) {
|
|
45169
|
+
if (typeof json2.error === "string") return json2.error;
|
|
45170
|
+
const error51 = object3(json2.error);
|
|
45171
|
+
if (error51) return typeof error51.message === "string" ? error51.message : "unknown error";
|
|
45172
|
+
const code = json2.base_resp?.status_code;
|
|
45173
|
+
if (typeof code === "number" && code !== 0) {
|
|
45174
|
+
const msg = typeof json2.base_resp?.status_msg === "string" ? json2.base_resp.status_msg : "";
|
|
45175
|
+
return `upstream error ${code}${msg ? `: ${msg}` : ""}`;
|
|
45176
|
+
}
|
|
45177
|
+
return null;
|
|
45178
|
+
}
|
|
45104
45179
|
var MAX_CHAT_TOOL_CALLS, MAX_ARGUMENT_CHARS, ChatProtocolError, ChatReasoningDetails, ChatToolCalls;
|
|
45105
45180
|
var init_openai_chat_protocol = __esm({
|
|
45106
45181
|
"server/drivers/openai-chat-protocol.ts"() {
|
|
@@ -45180,18 +45255,49 @@ var init_openai_chat_protocol = __esm({
|
|
|
45180
45255
|
}
|
|
45181
45256
|
});
|
|
45182
45257
|
|
|
45183
|
-
// server/drivers/
|
|
45184
|
-
function
|
|
45185
|
-
|
|
45186
|
-
|
|
45187
|
-
|
|
45188
|
-
|
|
45189
|
-
|
|
45190
|
-
|
|
45191
|
-
|
|
45192
|
-
|
|
45193
|
-
|
|
45258
|
+
// server/drivers/chat-text-only.ts
|
|
45259
|
+
function hasImageParts(messages) {
|
|
45260
|
+
return messages.some((message3) => Array.isArray(message3.content) && message3.content.some((part) => part.type === "image_url"));
|
|
45261
|
+
}
|
|
45262
|
+
function isImagePartRefusal(status, body) {
|
|
45263
|
+
return (status === 400 || status === 415 || status === 422) && REFUSALS.some((pattern) => pattern.test(body.slice(0, 4e3)));
|
|
45264
|
+
}
|
|
45265
|
+
function withoutImages(messages) {
|
|
45266
|
+
return messages.map((message3) => {
|
|
45267
|
+
if (!Array.isArray(message3.content) || !message3.content.some((part) => part.type === "image_url")) return message3;
|
|
45268
|
+
const text7 = message3.content.map((part) => part.type === "text" ? part.text : IMAGE_OMITTED_NOTE).join("\n");
|
|
45269
|
+
return { ...message3, content: text7 };
|
|
45270
|
+
});
|
|
45194
45271
|
}
|
|
45272
|
+
function sendableMessages(apiUrl, model, messages) {
|
|
45273
|
+
return textOnly.has(keyOf(apiUrl, model)) && hasImageParts(messages) ? withoutImages(messages) : messages;
|
|
45274
|
+
}
|
|
45275
|
+
function learnTextOnly(apiUrl, model, status, body, sent) {
|
|
45276
|
+
if (!hasImageParts(sent) || !isImagePartRefusal(status, body)) return false;
|
|
45277
|
+
textOnly.add(keyOf(apiUrl, model));
|
|
45278
|
+
return true;
|
|
45279
|
+
}
|
|
45280
|
+
var IMAGE_OMITTED_NOTE, REFUSALS, textOnly, keyOf;
|
|
45281
|
+
var init_chat_text_only = __esm({
|
|
45282
|
+
"server/drivers/chat-text-only.ts"() {
|
|
45283
|
+
"use strict";
|
|
45284
|
+
IMAGE_OMITTED_NOTE = "[Image omitted: this model reads text only, so it cannot see the image.]";
|
|
45285
|
+
REFUSALS = [
|
|
45286
|
+
// Z.ai (GLM-5.3, 2026-11)
|
|
45287
|
+
/content\.type\b[^\n]{0,80}\ballowed values?\s*:\s*\[\s*['"]text['"]\s*\]/i,
|
|
45288
|
+
// OpenAI: "Invalid content type. image_url is only supported by certain models."
|
|
45289
|
+
/\bimage_url\b[^\n]{0,80}\b(?:only supported|not supported|unsupported)\b/i,
|
|
45290
|
+
// llama.cpp, vLLM, Mistral and others, in their several wordings
|
|
45291
|
+
/\b(?:does not|doesn't|do not|cannot|can't) (?:support|accept|process|handle) (?:image inputs?|images|vision|multimodal)\b/i,
|
|
45292
|
+
/\b(?:image|vision|multimodal) (?:input|inputs|content) (?:is|are) not supported\b/i
|
|
45293
|
+
];
|
|
45294
|
+
textOnly = /* @__PURE__ */ new Set();
|
|
45295
|
+
keyOf = (apiUrl, model) => `${apiUrl}
|
|
45296
|
+
${model}`;
|
|
45297
|
+
}
|
|
45298
|
+
});
|
|
45299
|
+
|
|
45300
|
+
// server/drivers/openai-chat.ts
|
|
45195
45301
|
function createOpenAIChatRuntime(options) {
|
|
45196
45302
|
const { input } = options;
|
|
45197
45303
|
const listeners = /* @__PURE__ */ new Set();
|
|
@@ -45218,18 +45324,20 @@ function createOpenAIChatRuntime(options) {
|
|
|
45218
45324
|
resetIdleTimer();
|
|
45219
45325
|
try {
|
|
45220
45326
|
const activeSignal = signal ? AbortSignal.any([signal, timeoutController.signal]) : timeoutController.signal;
|
|
45327
|
+
const sendable = sendableMessages(options.apiUrl, model, messages);
|
|
45221
45328
|
const response = await fetch(`${options.apiUrl}/chat/completions`, {
|
|
45222
45329
|
method: "POST",
|
|
45223
|
-
...
|
|
45330
|
+
...hasImageParts(sendable) ? { redirect: "error" } : {},
|
|
45224
45331
|
headers: { ...options.extraHeaders, authorization: `Bearer ${options.apiKey}`, "content-type": "application/json" },
|
|
45225
45332
|
body: JSON.stringify({
|
|
45226
|
-
...options.requestBody(model,
|
|
45333
|
+
...options.requestBody(model, sendable, stream),
|
|
45227
45334
|
...tools.length ? { tools } : {}
|
|
45228
45335
|
}),
|
|
45229
45336
|
signal: activeSignal
|
|
45230
45337
|
});
|
|
45231
45338
|
if (!response.ok) {
|
|
45232
45339
|
const body = await response.text().catch(() => "");
|
|
45340
|
+
if (learnTextOnly(options.apiUrl, model, response.status, body, sendable)) return await complete(messages, model, stream, signal, onDelta, tools, onIdentity);
|
|
45233
45341
|
throw new Error(`${options.httpErrorLabel} HTTP ${response.status}${body ? `: ${body.slice(0, 200)}` : ""}`);
|
|
45234
45342
|
}
|
|
45235
45343
|
if (!stream || response.headers.get("content-type")?.includes("application/json")) {
|
|
@@ -45262,7 +45370,7 @@ function createOpenAIChatRuntime(options) {
|
|
|
45262
45370
|
if (!response.body) {
|
|
45263
45371
|
throw new Error(options.noBodyError ?? `${options.httpErrorLabel} returned no response body`);
|
|
45264
45372
|
}
|
|
45265
|
-
let
|
|
45373
|
+
let text7 = "";
|
|
45266
45374
|
let reasoning = "";
|
|
45267
45375
|
let protocolReasoning = "";
|
|
45268
45376
|
let usage = null;
|
|
@@ -45304,7 +45412,7 @@ function createOpenAIChatRuntime(options) {
|
|
|
45304
45412
|
onDelta?.(reasoningDelta, "reasoning_text");
|
|
45305
45413
|
}
|
|
45306
45414
|
if (contentDelta) {
|
|
45307
|
-
|
|
45415
|
+
text7 += contentDelta;
|
|
45308
45416
|
onDelta?.(contentDelta, "assistant_text");
|
|
45309
45417
|
}
|
|
45310
45418
|
if (chunk.usage) usage = usageFrom(chunk.usage);
|
|
@@ -45346,7 +45454,7 @@ function createOpenAIChatRuntime(options) {
|
|
|
45346
45454
|
}
|
|
45347
45455
|
activeSignal.throwIfAborted();
|
|
45348
45456
|
if (!sawChoice) throw new ChatProtocolError("provider returned no streaming completion choice");
|
|
45349
|
-
return { text:
|
|
45457
|
+
return { text: text7, reasoning, usage, toolCalls: calls.finish(finishReason, malformedFrame), finishReason, protocolReasoning, protocolReasoningDetails: details.blocks };
|
|
45350
45458
|
} finally {
|
|
45351
45459
|
if (idleTimer) clearTimeout(idleTimer);
|
|
45352
45460
|
}
|
|
@@ -45379,8 +45487,8 @@ function createOpenAIChatRuntime(options) {
|
|
|
45379
45487
|
}
|
|
45380
45488
|
}
|
|
45381
45489
|
}
|
|
45382
|
-
const safeText = (
|
|
45383
|
-
let safe =
|
|
45490
|
+
const safeText = (text7) => {
|
|
45491
|
+
let safe = text7;
|
|
45384
45492
|
for (const secret of secrets) if (secret) safe = safe.split(secret).join("[redacted]");
|
|
45385
45493
|
return redactSecretsInText(safe);
|
|
45386
45494
|
};
|
|
@@ -45437,8 +45545,8 @@ function createOpenAIChatRuntime(options) {
|
|
|
45437
45545
|
for (; ; ) {
|
|
45438
45546
|
let streamed = false;
|
|
45439
45547
|
const pending = { assistant_text: "", reasoning_text: "" };
|
|
45440
|
-
const delta = (
|
|
45441
|
-
let combined = pending[streamKind] +
|
|
45548
|
+
const delta = (text7, streamKind, flush = false) => {
|
|
45549
|
+
let combined = pending[streamKind] + text7;
|
|
45442
45550
|
for (const secret of secrets) if (secret) combined = combined.split(secret).join("[redacted]");
|
|
45443
45551
|
let hold = 0;
|
|
45444
45552
|
if (!flush) for (const secret of secrets) {
|
|
@@ -45457,9 +45565,9 @@ function createOpenAIChatRuntime(options) {
|
|
|
45457
45565
|
const callId = newId();
|
|
45458
45566
|
emit({ ...base3(turn.threadId, turnId), type: "model.call", callId });
|
|
45459
45567
|
let previousIdentity = "";
|
|
45460
|
-
completion = await complete(messages, model, true, abort.signal, (
|
|
45568
|
+
completion = await complete(messages, model, true, abort.signal, (text7, streamKind) => {
|
|
45461
45569
|
streamed = true;
|
|
45462
|
-
delta(
|
|
45570
|
+
delta(text7, streamKind);
|
|
45463
45571
|
}, tools.definitions, (reportedModel, responseId) => {
|
|
45464
45572
|
const identity2 = JSON.stringify([reportedModel, responseId]);
|
|
45465
45573
|
if (identity2 === previousIdentity) return;
|
|
@@ -45560,11 +45668,11 @@ function createOpenAIChatRuntime(options) {
|
|
|
45560
45668
|
result = { ok: false, text: abort.signal.aborted ? "Tool interrupted; an operation already dispatched may have taken effect. Verify its state before retrying." : safeText(asError(error51).message).slice(0, 2e3) };
|
|
45561
45669
|
}
|
|
45562
45670
|
if (!started) emit({ ...base3(turn.threadId, turnId), type: "item.started", itemType: "tool", itemId: call.id, title: call.function.name });
|
|
45563
|
-
const
|
|
45564
|
-
const output = preview({ ok: result.ok, result:
|
|
45671
|
+
const text7 = safeText(result.text);
|
|
45672
|
+
const output = preview({ ok: result.ok, result: text7 });
|
|
45565
45673
|
emit({ ...base3(turn.threadId, turnId), type: "item.completed", itemType: "tool", itemId: call.id, ok: result.ok, output });
|
|
45566
45674
|
if (!result.ok) toolFailed = true;
|
|
45567
|
-
messages.push({ role: "tool", tool_call_id: call.id, content: JSON.stringify({ ok: result.ok, result:
|
|
45675
|
+
messages.push({ role: "tool", tool_call_id: call.id, content: JSON.stringify({ ok: result.ok, result: text7 }) });
|
|
45568
45676
|
screenshotParts.push(...chatToolImages(call.id, result.images));
|
|
45569
45677
|
abort.signal.throwIfAborted();
|
|
45570
45678
|
if (fatal) throw fatal;
|
|
@@ -45656,9 +45764,9 @@ function createOpenAIChatRuntime(options) {
|
|
|
45656
45764
|
},
|
|
45657
45765
|
generateText: async (prompt, { signal } = {}) => {
|
|
45658
45766
|
const model = options.generateModel?.() ?? options.models().default;
|
|
45659
|
-
const { text:
|
|
45767
|
+
const { text: text7, reasoning, toolCalls } = await complete([{ role: "user", content: prompt }], model, false, signal);
|
|
45660
45768
|
if (toolCalls.length) throw new ChatProtocolError("provider returned tool calls to a text-only helper");
|
|
45661
|
-
return
|
|
45769
|
+
return text7.trim() ? text7 : reasoning;
|
|
45662
45770
|
},
|
|
45663
45771
|
dispose: async () => {
|
|
45664
45772
|
const turns = [...active.values()];
|
|
@@ -45680,6 +45788,7 @@ var init_openai_chat = __esm({
|
|
|
45680
45788
|
init_chat_images();
|
|
45681
45789
|
init_chat_tool_approval();
|
|
45682
45790
|
init_openai_chat_protocol();
|
|
45791
|
+
init_chat_text_only();
|
|
45683
45792
|
init_native();
|
|
45684
45793
|
init_retry();
|
|
45685
45794
|
usageFrom = (usage) => usage ? { input: usage.prompt_tokens ?? 0, output: usage.completion_tokens ?? 0 } : null;
|
|
@@ -45739,7 +45848,7 @@ var init_grok = __esm({
|
|
|
45739
45848
|
nativeLog: {
|
|
45740
45849
|
source: "xai.chat.completions",
|
|
45741
45850
|
outgoing: (_turn, messages, model) => ({ model, messages }),
|
|
45742
|
-
incoming: ({ text:
|
|
45851
|
+
incoming: ({ text: text7, usage }) => ({ text: text7, usage })
|
|
45743
45852
|
}
|
|
45744
45853
|
});
|
|
45745
45854
|
}
|
|
@@ -45751,12 +45860,12 @@ var init_grok = __esm({
|
|
|
45751
45860
|
import { existsSync as existsSync17, readFileSync as readFileSync20, writeFileSync as writeFileSync13 } from "node:fs";
|
|
45752
45861
|
import { homedir as homedir18 } from "node:os";
|
|
45753
45862
|
import { join as join39 } from "node:path";
|
|
45754
|
-
function decodeGrokModelText(
|
|
45755
|
-
if (/\bnot authenticated\b/i.test(
|
|
45863
|
+
function decodeGrokModelText(text7) {
|
|
45864
|
+
if (/\bnot authenticated\b/i.test(text7)) return null;
|
|
45756
45865
|
const options = [];
|
|
45757
45866
|
let listed = null;
|
|
45758
45867
|
let stated = null;
|
|
45759
|
-
for (const raw of
|
|
45868
|
+
for (const raw of text7.split(/\r?\n/)) {
|
|
45760
45869
|
const line = raw.trim();
|
|
45761
45870
|
const header = /^default model:\s*(\S+)/i.exec(line);
|
|
45762
45871
|
if (header) {
|
|
@@ -45795,9 +45904,9 @@ function unquote2(raw) {
|
|
|
45795
45904
|
}
|
|
45796
45905
|
function readGrokModelCatalog(env = process.env, base3 = STATIC_GROK_MODELS) {
|
|
45797
45906
|
const path4 = join39(grokHome(env), "config.toml");
|
|
45798
|
-
let
|
|
45907
|
+
let text7 = "";
|
|
45799
45908
|
try {
|
|
45800
|
-
|
|
45909
|
+
text7 = readFileSync20(path4, "utf8");
|
|
45801
45910
|
} catch {
|
|
45802
45911
|
return base3;
|
|
45803
45912
|
}
|
|
@@ -45815,7 +45924,7 @@ function readGrokModelCatalog(env = process.env, base3 = STATIC_GROK_MODELS) {
|
|
|
45815
45924
|
options.push({ id: current.slug, label: current.name || current.slug, custom: true });
|
|
45816
45925
|
current = null;
|
|
45817
45926
|
};
|
|
45818
|
-
for (const line of
|
|
45927
|
+
for (const line of text7.split(/\r?\n/)) {
|
|
45819
45928
|
const stripped = line.trim();
|
|
45820
45929
|
if (stripped === "[models]") {
|
|
45821
45930
|
flush();
|
|
@@ -45851,8 +45960,8 @@ function readGrokModelCatalog(env = process.env, base3 = STATIC_GROK_MODELS) {
|
|
|
45851
45960
|
function classifyGrokError(error51) {
|
|
45852
45961
|
const message3 = error51 instanceof Error ? error51.message : String(error51 ?? "");
|
|
45853
45962
|
const data = error51 && typeof error51 === "object" ? error51.data : void 0;
|
|
45854
|
-
const
|
|
45855
|
-
return classifyEngineFailure(
|
|
45963
|
+
const text7 = `${message3} ${typeof data === "string" ? data : data ? JSON.stringify(data) : ""}`;
|
|
45964
|
+
return classifyEngineFailure(text7)?.kind === "usage_limited" ? "quota_or_region_restriction" : void 0;
|
|
45856
45965
|
}
|
|
45857
45966
|
function suggestGrokSlug(host, model, taken) {
|
|
45858
45967
|
let base3 = `${host}-${model}`.toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
@@ -45874,11 +45983,11 @@ function ensureGrokInjectSlug(modelId, env = process.env) {
|
|
|
45874
45983
|
const host = localHost(inject.host);
|
|
45875
45984
|
if (!host) return modelId;
|
|
45876
45985
|
const path4 = join39(grokHome(env), "config.toml");
|
|
45877
|
-
let
|
|
45986
|
+
let text7 = "";
|
|
45878
45987
|
try {
|
|
45879
|
-
|
|
45988
|
+
text7 = readFileSync20(path4, "utf8");
|
|
45880
45989
|
} catch {
|
|
45881
|
-
|
|
45990
|
+
text7 = "";
|
|
45882
45991
|
}
|
|
45883
45992
|
const taken = new Set(STATIC_GROK_MODELS.options.map((option) => option.id));
|
|
45884
45993
|
let current = null;
|
|
@@ -45891,7 +46000,7 @@ function ensureGrokInjectSlug(modelId, env = process.env) {
|
|
|
45891
46000
|
current = null;
|
|
45892
46001
|
};
|
|
45893
46002
|
let found = null;
|
|
45894
|
-
for (const line of
|
|
46003
|
+
for (const line of text7.split(/\r?\n/)) {
|
|
45895
46004
|
const stripped = line.trim();
|
|
45896
46005
|
if (stripped.startsWith("[model.") && stripped.endsWith("]")) {
|
|
45897
46006
|
flush();
|
|
@@ -45924,9 +46033,9 @@ function ensureGrokInjectSlug(modelId, env = process.env) {
|
|
|
45924
46033
|
`api_key = ${quoteToml(hostApiKey(host, env))}`,
|
|
45925
46034
|
""
|
|
45926
46035
|
].join("\n");
|
|
45927
|
-
const next =
|
|
46036
|
+
const next = text7 && !text7.endsWith("\n") ? `${text7}
|
|
45928
46037
|
|
|
45929
|
-
${block2}` : `${
|
|
46038
|
+
${block2}` : `${text7}${text7 ? "\n" : ""}${block2}`;
|
|
45930
46039
|
writeFileSync13(path4, next);
|
|
45931
46040
|
return slug;
|
|
45932
46041
|
}
|
|
@@ -46113,18 +46222,69 @@ ${turn.text}` : turn.text
|
|
|
46113
46222
|
}
|
|
46114
46223
|
});
|
|
46115
46224
|
|
|
46225
|
+
// server/drivers/acp/kimi-turn-failure.ts
|
|
46226
|
+
import { closeSync as closeSync6, existsSync as existsSync19, fstatSync as fstatSync2, openSync as openSync6, readdirSync as readdirSync7, readSync as readSync3 } from "node:fs";
|
|
46227
|
+
import { join as join41 } from "node:path";
|
|
46228
|
+
function tail2(path4) {
|
|
46229
|
+
const file2 = openSync6(path4, "r");
|
|
46230
|
+
try {
|
|
46231
|
+
const size = fstatSync2(file2).size;
|
|
46232
|
+
const buffer = Buffer.alloc(Math.min(size, TAIL_BYTES));
|
|
46233
|
+
readSync3(file2, buffer, 0, buffer.length, size - buffer.length);
|
|
46234
|
+
return buffer.toString("utf8");
|
|
46235
|
+
} finally {
|
|
46236
|
+
closeSync6(file2);
|
|
46237
|
+
}
|
|
46238
|
+
}
|
|
46239
|
+
function kimiTurnFailure(dataRoot, sessionId, since) {
|
|
46240
|
+
try {
|
|
46241
|
+
if (!/^[\w-]+$/.test(sessionId)) return void 0;
|
|
46242
|
+
const sessions = join41(dataRoot, "sessions");
|
|
46243
|
+
const log = readdirSync7(sessions).map((workdir) => join41(sessions, workdir, sessionId, "logs", "kimi-code.log")).find((path4) => existsSync19(path4));
|
|
46244
|
+
if (!log) return void 0;
|
|
46245
|
+
const lines = tail2(log).split(/\r?\n/);
|
|
46246
|
+
for (let index = lines.length - 1; index >= 0; index--) {
|
|
46247
|
+
const record6 = FAILED_TURN.exec(lines[index]);
|
|
46248
|
+
if (!record6) continue;
|
|
46249
|
+
if (!(Date.parse(record6[1]) >= since)) return void 0;
|
|
46250
|
+
const error51 = JSON.parse(JSON.parse(record6[2]));
|
|
46251
|
+
const message3 = typeof error51.message === "string" ? error51.message.trim() : "";
|
|
46252
|
+
return message3 ? redactSecretsInText(message3).slice(0, 600) : void 0;
|
|
46253
|
+
}
|
|
46254
|
+
} catch {
|
|
46255
|
+
}
|
|
46256
|
+
return void 0;
|
|
46257
|
+
}
|
|
46258
|
+
async function awaitKimiTurnFailure(dataRoot, sessionId, since, waitMs = 1500) {
|
|
46259
|
+
const deadline = Date.now() + waitMs;
|
|
46260
|
+
for (; ; ) {
|
|
46261
|
+
const message3 = kimiTurnFailure(dataRoot, sessionId, since);
|
|
46262
|
+
if (message3 || Date.now() >= deadline) return message3;
|
|
46263
|
+
await new Promise((resolve14) => setTimeout(resolve14, 100));
|
|
46264
|
+
}
|
|
46265
|
+
}
|
|
46266
|
+
var FAILED_TURN, TAIL_BYTES;
|
|
46267
|
+
var init_kimi_turn_failure = __esm({
|
|
46268
|
+
"server/drivers/acp/kimi-turn-failure.ts"() {
|
|
46269
|
+
"use strict";
|
|
46270
|
+
init_redact2();
|
|
46271
|
+
FAILED_TURN = /^(\S+)\s+\w+\s+acp: turn ended with failed reason\s+error=("(?:[^"\\]|\\.)*")/;
|
|
46272
|
+
TAIL_BYTES = 256 * 1024;
|
|
46273
|
+
}
|
|
46274
|
+
});
|
|
46275
|
+
|
|
46116
46276
|
// server/drivers/acp/kimi.ts
|
|
46117
|
-
import { existsSync as
|
|
46277
|
+
import { existsSync as existsSync20, mkdirSync as mkdirSync18, readFileSync as readFileSync22, writeFileSync as writeFileSync14 } from "node:fs";
|
|
46118
46278
|
import { homedir as homedir20 } from "node:os";
|
|
46119
|
-
import { join as
|
|
46279
|
+
import { join as join42 } from "node:path";
|
|
46120
46280
|
function isLocalInjectAlias(slug) {
|
|
46121
46281
|
return LOCAL_PROVIDER_PREFIXES.some((prefix) => slug.startsWith(prefix));
|
|
46122
46282
|
}
|
|
46123
46283
|
function kimiDataRoot(env) {
|
|
46124
|
-
return env.KIMI_CODE_HOME ||
|
|
46284
|
+
return env.KIMI_CODE_HOME || join42(env.HOME || env.USERPROFILE || homedir20(), ".kimi-code");
|
|
46125
46285
|
}
|
|
46126
46286
|
function credentialsPath(env) {
|
|
46127
|
-
return
|
|
46287
|
+
return join42(kimiDataRoot(env), "credentials", "kimi-code.json");
|
|
46128
46288
|
}
|
|
46129
46289
|
function quoteToml2(value) {
|
|
46130
46290
|
return `"${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
@@ -46150,18 +46310,18 @@ function stripTomlLineComment(line) {
|
|
|
46150
46310
|
}
|
|
46151
46311
|
return line;
|
|
46152
46312
|
}
|
|
46153
|
-
function takeTomlBasicEscape(
|
|
46154
|
-
const code =
|
|
46313
|
+
function takeTomlBasicEscape(text7, i2) {
|
|
46314
|
+
const code = text7[i2 + 1];
|
|
46155
46315
|
if (code === void 0) return { ok: false };
|
|
46156
46316
|
if (code === "u") {
|
|
46157
|
-
const hex3 =
|
|
46317
|
+
const hex3 = text7.slice(i2 + 2, i2 + 6);
|
|
46158
46318
|
if (!/^[0-9a-fA-F]{4}$/.test(hex3)) return { ok: false };
|
|
46159
46319
|
const point = parseInt(hex3, 16);
|
|
46160
46320
|
if (point >= 55296 && point <= 57343) return { ok: false };
|
|
46161
46321
|
return { ok: true, value: String.fromCharCode(point), next: i2 + 6 };
|
|
46162
46322
|
}
|
|
46163
46323
|
if (code === "U") {
|
|
46164
|
-
const hex3 =
|
|
46324
|
+
const hex3 = text7.slice(i2 + 2, i2 + 10);
|
|
46165
46325
|
if (!/^[0-9a-fA-F]{8}$/.test(hex3)) return { ok: false };
|
|
46166
46326
|
const point = parseInt(hex3, 16);
|
|
46167
46327
|
if (point > 1114111 || point >= 55296 && point <= 57343) return { ok: false };
|
|
@@ -46233,14 +46393,14 @@ function tomlRowKey(row) {
|
|
|
46233
46393
|
const eq = row.indexOf("=");
|
|
46234
46394
|
return unquoteTomlKey(eq < 0 ? row : row.slice(0, eq));
|
|
46235
46395
|
}
|
|
46236
|
-
function tomlTables(
|
|
46396
|
+
function tomlTables(text7) {
|
|
46237
46397
|
const headings = [];
|
|
46238
46398
|
let mode = "out";
|
|
46239
46399
|
let i2 = 0;
|
|
46240
|
-
const atLineStart = (idx) => idx === 0 ||
|
|
46241
|
-
while (i2 <
|
|
46400
|
+
const atLineStart = (idx) => idx === 0 || text7[idx - 1] === "\n";
|
|
46401
|
+
while (i2 < text7.length) {
|
|
46242
46402
|
if (mode === "mlbasic") {
|
|
46243
|
-
if (
|
|
46403
|
+
if (text7.startsWith('"""', i2)) {
|
|
46244
46404
|
mode = "out";
|
|
46245
46405
|
i2 += 3;
|
|
46246
46406
|
continue;
|
|
@@ -46249,7 +46409,7 @@ function tomlTables(text6) {
|
|
|
46249
46409
|
continue;
|
|
46250
46410
|
}
|
|
46251
46411
|
if (mode === "mllit") {
|
|
46252
|
-
if (
|
|
46412
|
+
if (text7.startsWith("'''", i2)) {
|
|
46253
46413
|
mode = "out";
|
|
46254
46414
|
i2 += 3;
|
|
46255
46415
|
continue;
|
|
@@ -46258,61 +46418,61 @@ function tomlTables(text6) {
|
|
|
46258
46418
|
continue;
|
|
46259
46419
|
}
|
|
46260
46420
|
if (mode === "basic") {
|
|
46261
|
-
if (
|
|
46421
|
+
if (text7[i2] === "\n") {
|
|
46262
46422
|
mode = "out";
|
|
46263
46423
|
i2 += 1;
|
|
46264
46424
|
continue;
|
|
46265
46425
|
}
|
|
46266
|
-
if (
|
|
46426
|
+
if (text7[i2] === "\\") {
|
|
46267
46427
|
i2 += 2;
|
|
46268
46428
|
continue;
|
|
46269
46429
|
}
|
|
46270
|
-
if (
|
|
46430
|
+
if (text7[i2] === '"') mode = "out";
|
|
46271
46431
|
i2 += 1;
|
|
46272
46432
|
continue;
|
|
46273
46433
|
}
|
|
46274
46434
|
if (mode === "literal") {
|
|
46275
|
-
if (
|
|
46435
|
+
if (text7[i2] === "\n") {
|
|
46276
46436
|
mode = "out";
|
|
46277
46437
|
i2 += 1;
|
|
46278
46438
|
continue;
|
|
46279
46439
|
}
|
|
46280
|
-
if (
|
|
46440
|
+
if (text7[i2] === "'") mode = "out";
|
|
46281
46441
|
i2 += 1;
|
|
46282
46442
|
continue;
|
|
46283
46443
|
}
|
|
46284
|
-
if (
|
|
46444
|
+
if (text7.startsWith('"""', i2)) {
|
|
46285
46445
|
mode = "mlbasic";
|
|
46286
46446
|
i2 += 3;
|
|
46287
46447
|
continue;
|
|
46288
46448
|
}
|
|
46289
|
-
if (
|
|
46449
|
+
if (text7.startsWith("'''", i2)) {
|
|
46290
46450
|
mode = "mllit";
|
|
46291
46451
|
i2 += 3;
|
|
46292
46452
|
continue;
|
|
46293
46453
|
}
|
|
46294
|
-
if (
|
|
46454
|
+
if (text7[i2] === '"') {
|
|
46295
46455
|
mode = "basic";
|
|
46296
46456
|
i2 += 1;
|
|
46297
46457
|
continue;
|
|
46298
46458
|
}
|
|
46299
|
-
if (
|
|
46459
|
+
if (text7[i2] === "'") {
|
|
46300
46460
|
mode = "literal";
|
|
46301
46461
|
i2 += 1;
|
|
46302
46462
|
continue;
|
|
46303
46463
|
}
|
|
46304
|
-
if (
|
|
46305
|
-
const nl =
|
|
46306
|
-
i2 = nl < 0 ?
|
|
46464
|
+
if (text7[i2] === "#") {
|
|
46465
|
+
const nl = text7.indexOf("\n", i2);
|
|
46466
|
+
i2 = nl < 0 ? text7.length : nl + 1;
|
|
46307
46467
|
continue;
|
|
46308
46468
|
}
|
|
46309
46469
|
if (atLineStart(i2)) {
|
|
46310
46470
|
let j2 = i2;
|
|
46311
|
-
while (j2 <
|
|
46312
|
-
if (
|
|
46313
|
-
const nl =
|
|
46314
|
-
const lineEnd = nl < 0 ?
|
|
46315
|
-
const raw =
|
|
46471
|
+
while (j2 < text7.length && (text7[j2] === " " || text7[j2] === " ")) j2 += 1;
|
|
46472
|
+
if (text7[j2] === "[") {
|
|
46473
|
+
const nl = text7.indexOf("\n", j2);
|
|
46474
|
+
const lineEnd = nl < 0 ? text7.length : nl;
|
|
46475
|
+
const raw = text7.slice(j2, lineEnd).replace(/\r$/, "");
|
|
46316
46476
|
const stripped = stripTomlLineComment(raw).trim();
|
|
46317
46477
|
const array2 = stripped.startsWith("[[");
|
|
46318
46478
|
const name = array2 ? canonicalizeTomlHeading(`[${stripped.replace(/^\s*\[\[/, "").replace(/\]\]\s*$/, "")}]`) : canonicalizeTomlHeading(raw);
|
|
@@ -46325,11 +46485,11 @@ function tomlTables(text6) {
|
|
|
46325
46485
|
}
|
|
46326
46486
|
return headings.map((heading, index) => ({
|
|
46327
46487
|
heading,
|
|
46328
|
-
end: index + 1 < headings.length ? headings[index + 1].lineStart :
|
|
46488
|
+
end: index + 1 < headings.length ? headings[index + 1].lineStart : text7.length
|
|
46329
46489
|
})).filter((entry) => entry.heading.patchable && entry.heading.name).map((entry) => ({
|
|
46330
46490
|
name: entry.heading.name,
|
|
46331
46491
|
headingStart: entry.heading.lineStart,
|
|
46332
|
-
bodyStart: entry.heading.lineEnd + (
|
|
46492
|
+
bodyStart: entry.heading.lineEnd + (text7[entry.heading.lineEnd] === "\n" ? 1 : 0),
|
|
46333
46493
|
end: entry.end
|
|
46334
46494
|
}));
|
|
46335
46495
|
}
|
|
@@ -46385,22 +46545,22 @@ function tomlKeys(block2) {
|
|
|
46385
46545
|
take(block2.length);
|
|
46386
46546
|
return keys;
|
|
46387
46547
|
}
|
|
46388
|
-
function hasTomlTable(
|
|
46548
|
+
function hasTomlTable(text7, heading) {
|
|
46389
46549
|
const name = canonicalizeTomlHeading(heading);
|
|
46390
|
-
return name !== null && tomlTables(
|
|
46550
|
+
return name !== null && tomlTables(text7).some((table) => table.name === name);
|
|
46391
46551
|
}
|
|
46392
|
-
function patchTomlTable(
|
|
46552
|
+
function patchTomlTable(text7, heading, rows) {
|
|
46393
46553
|
const name = canonicalizeTomlHeading(heading);
|
|
46394
|
-
if (!name) return
|
|
46395
|
-
const table = tomlTables(
|
|
46396
|
-
if (!table) return
|
|
46397
|
-
const keys = tomlKeys(
|
|
46554
|
+
if (!name) return text7;
|
|
46555
|
+
const table = tomlTables(text7).find((entry) => entry.name === name);
|
|
46556
|
+
if (!table) return text7;
|
|
46557
|
+
const keys = tomlKeys(text7.slice(table.bodyStart, table.end));
|
|
46398
46558
|
const missing = rows.filter((row) => !keys.has(tomlRowKey(row)));
|
|
46399
|
-
if (!missing.length) return
|
|
46559
|
+
if (!missing.length) return text7;
|
|
46400
46560
|
let insertAt = table.end;
|
|
46401
|
-
while (insertAt > table.bodyStart && (
|
|
46402
|
-
const before =
|
|
46403
|
-
const after =
|
|
46561
|
+
while (insertAt > table.bodyStart && (text7[insertAt - 1] === "\n" || text7[insertAt - 1] === "\r")) insertAt -= 1;
|
|
46562
|
+
const before = text7.slice(0, insertAt);
|
|
46563
|
+
const after = text7.slice(insertAt);
|
|
46404
46564
|
const pad = before.endsWith("\n") || before.length === 0 ? "" : "\n";
|
|
46405
46565
|
return `${before}${pad}${missing.join("\n")}${after.startsWith("\n") ? "" : "\n"}${after}`;
|
|
46406
46566
|
}
|
|
@@ -46412,18 +46572,18 @@ function ensureKimiInjectAlias(modelId, env = process.env) {
|
|
|
46412
46572
|
const alias = `${inject.host}/${inject.model.replace(/\//g, "-")}`;
|
|
46413
46573
|
const dataRoot = kimiDataRoot(env);
|
|
46414
46574
|
mkdirSync18(dataRoot, { recursive: true });
|
|
46415
|
-
const path4 =
|
|
46416
|
-
let
|
|
46575
|
+
const path4 = join42(dataRoot, "config.toml");
|
|
46576
|
+
let text7 = "";
|
|
46417
46577
|
try {
|
|
46418
|
-
|
|
46578
|
+
text7 = readFileSync22(path4, "utf8");
|
|
46419
46579
|
} catch {
|
|
46420
|
-
|
|
46580
|
+
text7 = "";
|
|
46421
46581
|
}
|
|
46422
|
-
const original =
|
|
46582
|
+
const original = text7;
|
|
46423
46583
|
const providerHeading = `[providers.${inject.host}]`;
|
|
46424
46584
|
const modelHeading = `[models.${quoteTomlKey(alias)}]`;
|
|
46425
46585
|
const blocks = [];
|
|
46426
|
-
if (!hasTomlTable(
|
|
46586
|
+
if (!hasTomlTable(text7, providerHeading)) {
|
|
46427
46587
|
blocks.push(
|
|
46428
46588
|
[
|
|
46429
46589
|
providerHeading,
|
|
@@ -46434,8 +46594,8 @@ function ensureKimiInjectAlias(modelId, env = process.env) {
|
|
|
46434
46594
|
].join("\n")
|
|
46435
46595
|
);
|
|
46436
46596
|
}
|
|
46437
|
-
if (hasTomlTable(
|
|
46438
|
-
|
|
46597
|
+
if (hasTomlTable(text7, modelHeading)) {
|
|
46598
|
+
text7 = patchTomlTable(text7, modelHeading, [`protocol = "openai"`, `max_context_size = 262144`]);
|
|
46439
46599
|
} else {
|
|
46440
46600
|
blocks.push(
|
|
46441
46601
|
[
|
|
@@ -46449,13 +46609,13 @@ function ensureKimiInjectAlias(modelId, env = process.env) {
|
|
|
46449
46609
|
);
|
|
46450
46610
|
}
|
|
46451
46611
|
if (blocks.length) {
|
|
46452
|
-
const prefix =
|
|
46612
|
+
const prefix = text7 && !text7.endsWith("\n") ? `${text7}
|
|
46453
46613
|
|
|
46454
|
-
` :
|
|
46614
|
+
` : text7 ? `${text7}
|
|
46455
46615
|
` : "";
|
|
46456
46616
|
writeFileSync14(path4, `${prefix}${blocks.join("\n")}`);
|
|
46457
|
-
} else if (
|
|
46458
|
-
writeFileSync14(path4,
|
|
46617
|
+
} else if (text7 !== original) {
|
|
46618
|
+
writeFileSync14(path4, text7);
|
|
46459
46619
|
}
|
|
46460
46620
|
return alias;
|
|
46461
46621
|
}
|
|
@@ -46475,9 +46635,9 @@ function stripKimiModelEnv(env) {
|
|
|
46475
46635
|
}
|
|
46476
46636
|
function readKimiModelCatalog(env) {
|
|
46477
46637
|
const dataRoot = kimiDataRoot(env);
|
|
46478
|
-
let
|
|
46638
|
+
let text7 = "";
|
|
46479
46639
|
try {
|
|
46480
|
-
|
|
46640
|
+
text7 = readFileSync22(join42(dataRoot, "config.toml"), "utf8");
|
|
46481
46641
|
} catch {
|
|
46482
46642
|
return STATIC_KIMI_MODELS;
|
|
46483
46643
|
}
|
|
@@ -46493,7 +46653,7 @@ function readKimiModelCatalog(env) {
|
|
|
46493
46653
|
options.push({ id: current.slug, label: current.name || current.slug, custom: true });
|
|
46494
46654
|
current = null;
|
|
46495
46655
|
};
|
|
46496
|
-
for (const line of
|
|
46656
|
+
for (const line of text7.split(/\r?\n/)) {
|
|
46497
46657
|
const stripped = line.trim();
|
|
46498
46658
|
if ((stripped.startsWith("[model.") || stripped.startsWith("[models.")) && stripped.endsWith("]")) {
|
|
46499
46659
|
flush();
|
|
@@ -46525,6 +46685,7 @@ var init_kimi = __esm({
|
|
|
46525
46685
|
"use strict";
|
|
46526
46686
|
init_local_inject();
|
|
46527
46687
|
init_core3();
|
|
46688
|
+
init_kimi_turn_failure();
|
|
46528
46689
|
STATIC_KIMI_MODELS = {
|
|
46529
46690
|
default: "kimi-code/k3",
|
|
46530
46691
|
options: [
|
|
@@ -46595,7 +46756,7 @@ var init_kimi = __esm({
|
|
|
46595
46756
|
authFailure: "continue",
|
|
46596
46757
|
// Match the child CLI's own data-root precedence. A custom instance HOME or
|
|
46597
46758
|
// KIMI_CODE_HOME must not be checked against the server user's home instead.
|
|
46598
|
-
isAuthenticated: (env) =>
|
|
46759
|
+
isAuthenticated: (env) => existsSync20(credentialsPath(env)),
|
|
46599
46760
|
// Full rides Kimi's ACP session mode, not argv. `kimi acp` builds its
|
|
46600
46761
|
// harness without the global -y/--yolo and --auto flags and starts every
|
|
46601
46762
|
// ACP session in mode "default" (verified against kimi-code 0.28.1), so
|
|
@@ -46618,19 +46779,25 @@ var init_kimi = __esm({
|
|
|
46618
46779
|
},
|
|
46619
46780
|
buildPromptText: (turn) => turn.system ? `${turn.system}
|
|
46620
46781
|
|
|
46621
|
-
${turn.text}` : turn.text
|
|
46782
|
+
${turn.text}` : turn.text,
|
|
46783
|
+
// Kimi answers end_turn with nothing when its provider refused the turn
|
|
46784
|
+
// (a 403 for a plan without Kimi Code access): the reason is in its log.
|
|
46785
|
+
explainEmptyTurn: async ({ sessionId, since, env }) => {
|
|
46786
|
+
const message3 = await awaitKimiTurnFailure(kimiDataRoot(env), sessionId, since);
|
|
46787
|
+
return message3 ? `Kimi: ${message3}` : void 0;
|
|
46788
|
+
}
|
|
46622
46789
|
};
|
|
46623
46790
|
KimiAgentDriver = createAcpDriver(support4);
|
|
46624
46791
|
}
|
|
46625
46792
|
});
|
|
46626
46793
|
|
|
46627
46794
|
// server/drivers/acp/droid.ts
|
|
46628
|
-
import { existsSync as
|
|
46795
|
+
import { existsSync as existsSync21, mkdirSync as mkdirSync19, readFileSync as readFileSync23, writeFileSync as writeFileSync15 } from "node:fs";
|
|
46629
46796
|
import { homedir as homedir21 } from "node:os";
|
|
46630
|
-
import { join as
|
|
46797
|
+
import { join as join43 } from "node:path";
|
|
46631
46798
|
function authFilePaths(env) {
|
|
46632
46799
|
const home = env.FACTORY_HOME_OVERRIDE || env.HOME || homedir21();
|
|
46633
|
-
return AUTH_FILES.map((name) =>
|
|
46800
|
+
return AUTH_FILES.map((name) => join43(home, ".factory", name));
|
|
46634
46801
|
}
|
|
46635
46802
|
function droidInjectId(host, model) {
|
|
46636
46803
|
const safe = `${host}-${model}`.replace(/[^a-zA-Z0-9._+-]+/g, "-").replace(/-+/g, "-");
|
|
@@ -46645,14 +46812,14 @@ function ensureDroidInjectModel(modelId, env = process.env) {
|
|
|
46645
46812
|
const host = localHost(inject.host);
|
|
46646
46813
|
if (!host) return modelId;
|
|
46647
46814
|
const id = droidInjectId(inject.host, inject.model);
|
|
46648
|
-
const dir =
|
|
46815
|
+
const dir = join43(factoryHome(env), ".factory");
|
|
46649
46816
|
mkdirSync19(dir, { recursive: true });
|
|
46650
|
-
const path4 =
|
|
46817
|
+
const path4 = join43(dir, "settings.json");
|
|
46651
46818
|
let settings2 = {};
|
|
46652
46819
|
try {
|
|
46653
46820
|
settings2 = JSON.parse(readFileSync23(path4, "utf8"));
|
|
46654
46821
|
} catch (error51) {
|
|
46655
|
-
if (
|
|
46822
|
+
if (existsSync21(path4)) throw error51;
|
|
46656
46823
|
}
|
|
46657
46824
|
const custom2 = Array.isArray(settings2.customModels) ? [...settings2.customModels] : [];
|
|
46658
46825
|
const match = custom2.find(
|
|
@@ -46683,11 +46850,11 @@ function ensureDroidInjectModel(modelId, env = process.env) {
|
|
|
46683
46850
|
function applyDroidLocalAuthEnv(env, modelId) {
|
|
46684
46851
|
if (!decodeInjectId(modelId)) return;
|
|
46685
46852
|
if (env.FACTORY_API_KEY?.trim()) return;
|
|
46686
|
-
if (authFilePaths(env).some(
|
|
46853
|
+
if (authFilePaths(env).some(existsSync21)) return;
|
|
46687
46854
|
env.FACTORY_API_KEY = "openmausbot-local";
|
|
46688
46855
|
}
|
|
46689
46856
|
function readSettings(env) {
|
|
46690
|
-
return JSON.parse(readFileSync23(
|
|
46857
|
+
return JSON.parse(readFileSync23(join43(factoryHome(env), ".factory", "settings.json"), "utf8"));
|
|
46691
46858
|
}
|
|
46692
46859
|
async function resolveModels(env) {
|
|
46693
46860
|
let catalog2 = MODELS3;
|
|
@@ -46775,7 +46942,7 @@ var init_droid = __esm({
|
|
|
46775
46942
|
// The signed-in CLI is the primary source; FACTORY_API_KEY is the fallback
|
|
46776
46943
|
// droid itself advertises, and it is checked last so an ambient key can
|
|
46777
46944
|
// never be what makes an otherwise logged-out instance look ready.
|
|
46778
|
-
isAuthenticated: (env) => authFilePaths(env).some(
|
|
46945
|
+
isAuthenticated: (env) => authFilePaths(env).some(existsSync21) || Boolean(env.FACTORY_API_KEY),
|
|
46779
46946
|
resolveModels,
|
|
46780
46947
|
resolveTurnModel: (model, env) => model ? ensureDroidInjectModel(model, env) : model,
|
|
46781
46948
|
applyTurnEnv: (env, { requestedModel }) => {
|
|
@@ -46816,8 +46983,8 @@ function resolveCursorAcpModelId(available, wanted) {
|
|
|
46816
46983
|
}
|
|
46817
46984
|
return null;
|
|
46818
46985
|
}
|
|
46819
|
-
function firstJsonValue(
|
|
46820
|
-
const trimmed =
|
|
46986
|
+
function firstJsonValue(text7) {
|
|
46987
|
+
const trimmed = text7.trim();
|
|
46821
46988
|
if (!trimmed) return null;
|
|
46822
46989
|
try {
|
|
46823
46990
|
return JSON.parse(trimmed);
|
|
@@ -46891,12 +47058,12 @@ function stripModelMarkers(label) {
|
|
|
46891
47058
|
}
|
|
46892
47059
|
return { label: cleaned, isDefault, isCurrent };
|
|
46893
47060
|
}
|
|
46894
|
-
function decodeCursorModelText(
|
|
47061
|
+
function decodeCursorModelText(text7) {
|
|
46895
47062
|
const options = [];
|
|
46896
47063
|
const seen = /* @__PURE__ */ new Set();
|
|
46897
47064
|
let markedDefault;
|
|
46898
47065
|
let markedCurrent;
|
|
46899
|
-
for (const raw of
|
|
47066
|
+
for (const raw of text7.split(/\r?\n/)) {
|
|
46900
47067
|
const line = raw.trim();
|
|
46901
47068
|
if (!line || line.startsWith("#") || /^available\s+models?\b/i.test(line) || /^models?\b/i.test(line)) continue;
|
|
46902
47069
|
const stripped = line.replace(/^[\s*•-]+\s*/, "");
|
|
@@ -46949,8 +47116,8 @@ function decodeCursorAuthStatus(payload) {
|
|
|
46949
47116
|
}
|
|
46950
47117
|
return null;
|
|
46951
47118
|
}
|
|
46952
|
-
function decodeCursorAuthText(
|
|
46953
|
-
const normalized =
|
|
47119
|
+
function decodeCursorAuthText(text7) {
|
|
47120
|
+
const normalized = text7.trim().toLowerCase();
|
|
46954
47121
|
if (!normalized) return null;
|
|
46955
47122
|
if (/not (?:logged|signed) in|not authenticated|unauthenticated|logged out/.test(normalized)) return false;
|
|
46956
47123
|
if (/login successful|logged in|signed in|authenticated/.test(normalized)) return true;
|
|
@@ -47159,18 +47326,18 @@ import { createHash as createHash13 } from "node:crypto";
|
|
|
47159
47326
|
function requestKey(id) {
|
|
47160
47327
|
return `${typeof id === "number" ? "number" : "string"}:${String(id)}`;
|
|
47161
47328
|
}
|
|
47162
|
-
function utf8ByteLength(
|
|
47329
|
+
function utf8ByteLength(text7) {
|
|
47163
47330
|
let bytes = 0;
|
|
47164
|
-
for (const scalar of
|
|
47331
|
+
for (const scalar of text7) {
|
|
47165
47332
|
const point = scalar.codePointAt(0);
|
|
47166
47333
|
bytes += point <= 127 ? 1 : point <= 2047 ? 2 : point <= 65535 ? 3 : 4;
|
|
47167
47334
|
}
|
|
47168
47335
|
return bytes;
|
|
47169
47336
|
}
|
|
47170
|
-
function truncateToUtf8Bytes(
|
|
47337
|
+
function truncateToUtf8Bytes(text7, limitBytes) {
|
|
47171
47338
|
let bytes = 0;
|
|
47172
47339
|
let end = 0;
|
|
47173
|
-
for (const scalar of
|
|
47340
|
+
for (const scalar of text7) {
|
|
47174
47341
|
const point = scalar.codePointAt(0);
|
|
47175
47342
|
const width = point <= 127 ? 1 : point <= 2047 ? 2 : point <= 65535 ? 3 : 4;
|
|
47176
47343
|
if (bytes + width > limitBytes)
|
|
@@ -47178,7 +47345,7 @@ function truncateToUtf8Bytes(text6, limitBytes) {
|
|
|
47178
47345
|
bytes += width;
|
|
47179
47346
|
end += scalar.length;
|
|
47180
47347
|
}
|
|
47181
|
-
return
|
|
47348
|
+
return text7.slice(0, end);
|
|
47182
47349
|
}
|
|
47183
47350
|
function canonical(value) {
|
|
47184
47351
|
if (Array.isArray(value))
|
|
@@ -47419,10 +47586,10 @@ var init_connection = __esm({
|
|
|
47419
47586
|
throw new ProtocolError("unreachable command retry state");
|
|
47420
47587
|
}
|
|
47421
47588
|
async close() {
|
|
47422
|
-
const
|
|
47589
|
+
const tail3 = this.#writeTail;
|
|
47423
47590
|
if (this.#transport.close !== void 0) {
|
|
47424
47591
|
await this.#transport.close(this.#submitTail);
|
|
47425
|
-
await
|
|
47592
|
+
await tail3;
|
|
47426
47593
|
} else {
|
|
47427
47594
|
this.#finish(new ProtocolError("connection closed"));
|
|
47428
47595
|
}
|
|
@@ -48574,14 +48741,14 @@ var init_muse_code_login = __esm({
|
|
|
48574
48741
|
});
|
|
48575
48742
|
|
|
48576
48743
|
// server/drivers/muse-code.ts
|
|
48577
|
-
import { existsSync as
|
|
48744
|
+
import { existsSync as existsSync22, mkdtempSync as mkdtempSync4, readFileSync as readFileSync24, rmSync as rmSync9, statSync as statSync6 } from "node:fs";
|
|
48578
48745
|
import { readFile as readFile4 } from "node:fs/promises";
|
|
48579
48746
|
import { homedir as homedir22, tmpdir as tmpdir6 } from "node:os";
|
|
48580
|
-
import { join as
|
|
48747
|
+
import { join as join44 } from "node:path";
|
|
48581
48748
|
function museCredentialPath(env, platform = process.platform) {
|
|
48582
48749
|
if (env.MUSE_AUTH_PATH?.trim()) return env.MUSE_AUTH_PATH.trim();
|
|
48583
48750
|
const home = (platform === "win32" ? env.USERPROFILE || env.HOME : env.HOME) || homedir22();
|
|
48584
|
-
return
|
|
48751
|
+
return join44(env.XDG_CONFIG_HOME?.trim() || join44(home, ".config"), "muse", "auth.json");
|
|
48585
48752
|
}
|
|
48586
48753
|
function museCredential(path4) {
|
|
48587
48754
|
let raw;
|
|
@@ -48675,8 +48842,8 @@ function museToolStart(item) {
|
|
|
48675
48842
|
}
|
|
48676
48843
|
function museToolOutput(item) {
|
|
48677
48844
|
const ok = item.status === "completed" && (item.exitCode === void 0 || item.exitCode === 0);
|
|
48678
|
-
const
|
|
48679
|
-
const output = [item.status !== "completed" ? item.failureReason || `Muse reported ${item.status}.` : "",
|
|
48845
|
+
const text7 = item.visibleOutput ?? item.result?.summary ?? item.text ?? item.summary?.join("\n") ?? item.fallbackText ?? "";
|
|
48846
|
+
const output = [item.status !== "completed" ? item.failureReason || `Muse reported ${item.status}.` : "", text7].filter(Boolean).join("\n");
|
|
48680
48847
|
return { ok, ...output ? { output: redactSecretsInText(output.slice(0, MAX_TOOL_OUTPUT)) } : {} };
|
|
48681
48848
|
}
|
|
48682
48849
|
function museQuestions(raw) {
|
|
@@ -48843,7 +49010,7 @@ var init_muse_code = __esm({
|
|
|
48843
49010
|
lastRefresh = Date.now();
|
|
48844
49011
|
});
|
|
48845
49012
|
const listModels = async () => {
|
|
48846
|
-
const cwd = mkdtempSync4(
|
|
49013
|
+
const cwd = mkdtempSync4(join44(tmpdir6(), "atomic-muse-models-"));
|
|
48847
49014
|
let host;
|
|
48848
49015
|
try {
|
|
48849
49016
|
host = await startHost(["serve", "--disable-shell", "--disable-write", "--no-session-log", "--contributor-mode", "off"], cwd, "models", false);
|
|
@@ -48944,12 +49111,12 @@ var init_muse_code = __esm({
|
|
|
48944
49111
|
active.items.set(item.itemId, item);
|
|
48945
49112
|
if (item.kind === "agentMessage") {
|
|
48946
49113
|
if (item.status !== "completed" || item.retracted) return;
|
|
48947
|
-
const
|
|
49114
|
+
const text7 = item.text ?? "";
|
|
48948
49115
|
const streamed = active.streamed.get(item.itemId) ?? "";
|
|
48949
|
-
if (
|
|
48950
|
-
emit({ type: "content.delta", threadId, turnId: active.turnId, itemId: item.itemId, streamKind: "assistant_text", delta:
|
|
49116
|
+
if (text7.startsWith(streamed) && text7.length > streamed.length) {
|
|
49117
|
+
emit({ type: "content.delta", threadId, turnId: active.turnId, itemId: item.itemId, streamKind: "assistant_text", delta: text7.slice(streamed.length) });
|
|
48951
49118
|
}
|
|
48952
|
-
if (
|
|
49119
|
+
if (text7) emit({ type: "item.completed", threadId, turnId: active.turnId, itemId: item.itemId, itemType: "assistant_text", text: text7 });
|
|
48953
49120
|
} else if (item.kind === "reasoning") {
|
|
48954
49121
|
if (!seen) emit({ type: "item.started", threadId, turnId: active.turnId, itemId: item.itemId, itemType: "reasoning" });
|
|
48955
49122
|
} else if (TOOL_KINDS.has(item.kind)) {
|
|
@@ -49146,16 +49313,16 @@ var init_muse_code = __esm({
|
|
|
49146
49313
|
const rebuilt = Boolean(resumeId && turn.recoveryText);
|
|
49147
49314
|
return { text: rebuilt ? turn.recoveryText : turn.text, rebuilt, started: true };
|
|
49148
49315
|
};
|
|
49149
|
-
const withInstructions = (state2, turn,
|
|
49316
|
+
const withInstructions = (state2, turn, text7, started) => {
|
|
49150
49317
|
const sessionId = state2.sessionId;
|
|
49151
49318
|
if (turn.systemStable === void 0) return turn.system && started ? `${turn.system}
|
|
49152
49319
|
|
|
49153
|
-
${
|
|
49320
|
+
${text7}` : text7;
|
|
49154
49321
|
let entry = state2.instructions;
|
|
49155
49322
|
const resend = started || !entry || entry.sessionId !== sessionId || entry.stable !== turn.systemStable || entry.turns >= INSTRUCTIONS_REFRESH_TURNS;
|
|
49156
49323
|
if (resend) entry = state2.instructions = { sessionId, stable: turn.systemStable, turns: 0, seen: /* @__PURE__ */ new Map() };
|
|
49157
49324
|
entry.turns++;
|
|
49158
|
-
const body = withNote(
|
|
49325
|
+
const body = withNote(text7, volatileNote(volatileSectionsOf(turn), entry.seen, entry.seen.size === 0));
|
|
49159
49326
|
return resend && turn.systemStable ? `${turn.systemStable}
|
|
49160
49327
|
|
|
49161
49328
|
${body}` : body;
|
|
@@ -49173,7 +49340,7 @@ ${body}` : body;
|
|
|
49173
49340
|
await host.connection.command("session/setModel", { sessionId, model: { modelId: turn.model, providerId: config2.provider } });
|
|
49174
49341
|
state2.model = turn.model;
|
|
49175
49342
|
}
|
|
49176
|
-
const
|
|
49343
|
+
const text7 = withInstructions(state2, turn, session.text, session.started);
|
|
49177
49344
|
const images = turn.images?.length ? await Promise.all(turn.images.map(async (image) => ({
|
|
49178
49345
|
type: "image",
|
|
49179
49346
|
mediaType: image.mime,
|
|
@@ -49185,7 +49352,7 @@ ${body}` : body;
|
|
|
49185
49352
|
active.nativeTurnId = host.connection.mintCommandId();
|
|
49186
49353
|
await host.connection.command("turn/start", {
|
|
49187
49354
|
sessionId,
|
|
49188
|
-
input: [{ type: "text", text:
|
|
49355
|
+
input: [{ type: "text", text: text7 }, ...images],
|
|
49189
49356
|
...effort ? { reasoningEffort: effort } : {}
|
|
49190
49357
|
}, { commandId: active.nativeTurnId });
|
|
49191
49358
|
} catch (error51) {
|
|
@@ -49265,7 +49432,7 @@ ${body}` : body;
|
|
|
49265
49432
|
return "unavailable";
|
|
49266
49433
|
}
|
|
49267
49434
|
},
|
|
49268
|
-
async steer(threadId,
|
|
49435
|
+
async steer(threadId, text7) {
|
|
49269
49436
|
const state2 = threads.get(threadId);
|
|
49270
49437
|
const active = state2?.active;
|
|
49271
49438
|
if (!state2?.host || !state2.sessionId || !active?.nativeTurnId || active.finished) return "refused";
|
|
@@ -49273,7 +49440,7 @@ ${body}` : body;
|
|
|
49273
49440
|
await state2.host.connection.command("turn/steer", {
|
|
49274
49441
|
sessionId: state2.sessionId,
|
|
49275
49442
|
expectedTurnId: active.nativeTurnId,
|
|
49276
|
-
input: [{ type: "text", text:
|
|
49443
|
+
input: [{ type: "text", text: text7 }]
|
|
49277
49444
|
});
|
|
49278
49445
|
return "steered";
|
|
49279
49446
|
} catch (error51) {
|
|
@@ -49292,7 +49459,7 @@ ${body}` : body;
|
|
|
49292
49459
|
return () => listeners.delete(listener);
|
|
49293
49460
|
}
|
|
49294
49461
|
};
|
|
49295
|
-
if (
|
|
49462
|
+
if (existsSync22(credentialPath()) || existsSync22(config2.cli) || findCliCandidates(config2.cli).length) void refreshModels();
|
|
49296
49463
|
return {
|
|
49297
49464
|
instanceId,
|
|
49298
49465
|
driverKind: MUSE_CODE_DRIVER,
|
|
@@ -49339,9 +49506,9 @@ ${body}` : body;
|
|
|
49339
49506
|
});
|
|
49340
49507
|
|
|
49341
49508
|
// server/drivers/acp/opencode-go.ts
|
|
49342
|
-
import { existsSync as
|
|
49509
|
+
import { existsSync as existsSync23, mkdirSync as mkdirSync20, readFileSync as readFileSync25, writeFileSync as writeFileSync16 } from "node:fs";
|
|
49343
49510
|
import { homedir as homedir23 } from "node:os";
|
|
49344
|
-
import { join as
|
|
49511
|
+
import { join as join45 } from "node:path";
|
|
49345
49512
|
function labelForModel(id) {
|
|
49346
49513
|
return id.split(/[-_.]+/g).filter(Boolean).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
|
|
49347
49514
|
}
|
|
@@ -49444,7 +49611,7 @@ async function discoverOpenCodeModels(environment, cli = "opencode") {
|
|
|
49444
49611
|
}
|
|
49445
49612
|
function opencodeConfigDir(env) {
|
|
49446
49613
|
const home = env.HOME || env.USERPROFILE || homedir23();
|
|
49447
|
-
return
|
|
49614
|
+
return join45(env.XDG_CONFIG_HOME || join45(home, ".config"), "opencode");
|
|
49448
49615
|
}
|
|
49449
49616
|
function ensureOpenCodeInjectModel(modelId, env = process.env) {
|
|
49450
49617
|
const inject = decodeInjectId(modelId);
|
|
@@ -49454,9 +49621,9 @@ function ensureOpenCodeInjectModel(modelId, env = process.env) {
|
|
|
49454
49621
|
const native = `${inject.host}/${inject.model}`;
|
|
49455
49622
|
const dir = opencodeConfigDir(env);
|
|
49456
49623
|
mkdirSync20(dir, { recursive: true });
|
|
49457
|
-
const path4 =
|
|
49624
|
+
const path4 = join45(dir, "opencode.json");
|
|
49458
49625
|
let config2 = { $schema: "https://opencode.ai/config.json" };
|
|
49459
|
-
if (
|
|
49626
|
+
if (existsSync23(path4)) {
|
|
49460
49627
|
try {
|
|
49461
49628
|
config2 = JSON.parse(readFileSync25(path4, "utf8"));
|
|
49462
49629
|
} catch {
|
|
@@ -49492,10 +49659,10 @@ function ensureOpenCodeInjectModel(modelId, env = process.env) {
|
|
|
49492
49659
|
function storedAuthPaths(env) {
|
|
49493
49660
|
const home = env.HOME || env.USERPROFILE || homedir23();
|
|
49494
49661
|
const roots = [
|
|
49495
|
-
env.XDG_DATA_HOME ||
|
|
49496
|
-
process.platform === "darwin" ?
|
|
49662
|
+
env.XDG_DATA_HOME || join45(home, ".local", "share"),
|
|
49663
|
+
process.platform === "darwin" ? join45(home, "Library", "Application Support") : process.platform === "win32" ? env.LOCALAPPDATA || join45(home, "AppData", "Local") : ""
|
|
49497
49664
|
].filter(Boolean);
|
|
49498
|
-
return [...new Set(roots)].map((root) =>
|
|
49665
|
+
return [...new Set(roots)].map((root) => join45(root, "opencode", "auth.json"));
|
|
49499
49666
|
}
|
|
49500
49667
|
function usableAuthEntry(parsed) {
|
|
49501
49668
|
return Object.values(parsed).some((auth) => {
|
|
@@ -49651,13 +49818,13 @@ ${turn.text}` : turn.text
|
|
|
49651
49818
|
});
|
|
49652
49819
|
|
|
49653
49820
|
// server/drivers/acp/qwen.ts
|
|
49654
|
-
import { chmodSync as chmodSync6, existsSync as
|
|
49821
|
+
import { chmodSync as chmodSync6, existsSync as existsSync24, mkdirSync as mkdirSync21, readFileSync as readFileSync26, writeFileSync as writeFileSync17 } from "node:fs";
|
|
49655
49822
|
import { createHash as createHash14 } from "node:crypto";
|
|
49656
49823
|
import { homedir as homedir24 } from "node:os";
|
|
49657
|
-
import { join as
|
|
49824
|
+
import { join as join46 } from "node:path";
|
|
49658
49825
|
function qwenHome(env) {
|
|
49659
49826
|
const home = process.platform === "win32" ? env.USERPROFILE || env.HOME || homedir24() : env.HOME || env.USERPROFILE || homedir24();
|
|
49660
|
-
return
|
|
49827
|
+
return join46(home, ".qwen");
|
|
49661
49828
|
}
|
|
49662
49829
|
function isRecord5(value) {
|
|
49663
49830
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
@@ -49669,7 +49836,7 @@ function qwenModelLabel(id, name) {
|
|
|
49669
49836
|
function readQwenRoutes(env) {
|
|
49670
49837
|
let settings2;
|
|
49671
49838
|
try {
|
|
49672
|
-
settings2 = JSON.parse(readFileSync26(
|
|
49839
|
+
settings2 = JSON.parse(readFileSync26(join46(qwenHome(env), "settings.json"), "utf8"));
|
|
49673
49840
|
} catch {
|
|
49674
49841
|
return [];
|
|
49675
49842
|
}
|
|
@@ -49753,9 +49920,9 @@ function ensureQwenInjectModel(modelId, env = process.env) {
|
|
|
49753
49920
|
if (!host) return modelId;
|
|
49754
49921
|
const dir = qwenHome(env);
|
|
49755
49922
|
mkdirSync21(dir, { recursive: true });
|
|
49756
|
-
const path4 =
|
|
49923
|
+
const path4 = join46(dir, "settings.json");
|
|
49757
49924
|
let settings2 = {};
|
|
49758
|
-
if (
|
|
49925
|
+
if (existsSync24(path4)) {
|
|
49759
49926
|
try {
|
|
49760
49927
|
settings2 = JSON.parse(readFileSync26(path4, "utf8"));
|
|
49761
49928
|
} catch {
|
|
@@ -49898,29 +50065,32 @@ function mistralSignInLink(value) {
|
|
|
49898
50065
|
return host === "mistral.ai" || host.endsWith(".mistral.ai") ? url2.href : null;
|
|
49899
50066
|
}
|
|
49900
50067
|
function vibeSignInFailure(error51) {
|
|
49901
|
-
const
|
|
49902
|
-
if (/denied/i.test(
|
|
49903
|
-
if (/expired|timed out/i.test(
|
|
50068
|
+
const text7 = error51 instanceof VibeRequestError ? error51.message : "";
|
|
50069
|
+
if (/denied/i.test(text7)) return "The Mistral sign-in was declined. Start sign-in again to try another account.";
|
|
50070
|
+
if (/expired|timed out/i.test(text7)) return "The Mistral sign-in expired. Start sign-in again.";
|
|
49904
50071
|
if (error51 instanceof Error && !(error51 instanceof VibeRequestError)) return error51.message;
|
|
49905
50072
|
return "Mistral Vibe sign-in did not finish. Check this computer's connection and that Vibe is up to date, then try again.";
|
|
49906
50073
|
}
|
|
49907
|
-
async function
|
|
50074
|
+
async function vibeSignInState(cli, env, timeoutMs = 2e4) {
|
|
49908
50075
|
let client;
|
|
49909
50076
|
try {
|
|
49910
50077
|
client = new VibeAcpClient(cli, env);
|
|
49911
50078
|
} catch {
|
|
49912
|
-
return
|
|
50079
|
+
return "signed-out";
|
|
49913
50080
|
}
|
|
49914
50081
|
try {
|
|
49915
50082
|
await client.initialize(timeoutMs);
|
|
49916
50083
|
const status = await client.request("_auth/status", {}, timeoutMs);
|
|
49917
|
-
return status?.authenticated === true;
|
|
50084
|
+
return status?.authenticated === true ? "signed-in" : "signed-out";
|
|
49918
50085
|
} catch {
|
|
49919
|
-
return
|
|
50086
|
+
return client.missing ? "missing" : "signed-out";
|
|
49920
50087
|
} finally {
|
|
49921
50088
|
client.close();
|
|
49922
50089
|
}
|
|
49923
50090
|
}
|
|
50091
|
+
async function vibeSignedIn(cli, env, timeoutMs = 2e4) {
|
|
50092
|
+
return await vibeSignInState(cli, env, timeoutMs) === "signed-in";
|
|
50093
|
+
}
|
|
49924
50094
|
var MAX_LINE, DELEGATED, VibeAcpClient, VibeRequestError, VibeLoginController;
|
|
49925
50095
|
var init_vibe_login = __esm({
|
|
49926
50096
|
"server/drivers/vibe-login.ts"() {
|
|
@@ -49934,12 +50104,17 @@ var init_vibe_login = __esm({
|
|
|
49934
50104
|
nextId = 1;
|
|
49935
50105
|
buffer = "";
|
|
49936
50106
|
closed = false;
|
|
50107
|
+
/** The command was not found: nothing is installed to sign in to. */
|
|
50108
|
+
missing = false;
|
|
49937
50109
|
constructor(cli, env) {
|
|
49938
50110
|
this.child = spawnCli(cli, [], { env, stdio: ["pipe", "pipe", "pipe"] });
|
|
49939
50111
|
this.child.stderr?.resume();
|
|
49940
50112
|
this.child.stdout?.on("data", (chunk) => this.receive(chunk.toString("utf8")));
|
|
49941
50113
|
const fail = (message3) => this.close(new Error(message3));
|
|
49942
|
-
this.child.once("error", (error51) =>
|
|
50114
|
+
this.child.once("error", (error51) => {
|
|
50115
|
+
this.missing = error51.code === "ENOENT";
|
|
50116
|
+
fail(this.missing ? "Mistral Vibe is not installed on this computer. Install it, then try again." : "Mistral Vibe could not start on this computer. Check its install, then try again.");
|
|
50117
|
+
});
|
|
49943
50118
|
this.child.once("close", () => fail("Mistral Vibe stopped before it answered. Update Vibe and try again."));
|
|
49944
50119
|
}
|
|
49945
50120
|
/** initialize, opting in to the delegated browser sign-in. */
|
|
@@ -49975,8 +50150,8 @@ var init_vibe_login = __esm({
|
|
|
49975
50150
|
}
|
|
49976
50151
|
if (this.child.exitCode === null && this.child.signalCode === null) void killCliTree(this.child).catch(() => false);
|
|
49977
50152
|
}
|
|
49978
|
-
receive(
|
|
49979
|
-
this.buffer +=
|
|
50153
|
+
receive(text7) {
|
|
50154
|
+
this.buffer += text7;
|
|
49980
50155
|
if (this.buffer.length > MAX_LINE) {
|
|
49981
50156
|
this.close(new Error("Mistral Vibe returned an unexpected answer. Update Vibe and try again."));
|
|
49982
50157
|
return;
|
|
@@ -50149,7 +50324,7 @@ var init_vibe = __esm({
|
|
|
50149
50324
|
models: MODELS4,
|
|
50150
50325
|
defaultCli: "vibe-acp",
|
|
50151
50326
|
nativeSource: "vibe.acp",
|
|
50152
|
-
loginNote: "Mistral Vibe is not
|
|
50327
|
+
loginNote: "Mistral Vibe is not signed in: choose Sign in with Mistral on its engine card",
|
|
50153
50328
|
// Mistral's own installer (it installs uv, then mistral-vibe). Not a
|
|
50154
50329
|
// vendorScript: mistral.ai redirects it to raw.githubusercontent.com, a host
|
|
50155
50330
|
// vendor-install.ts cannot pin to Mistral. Mistral targets macOS and Linux;
|
|
@@ -50164,11 +50339,17 @@ var init_vibe = __esm({
|
|
|
50164
50339
|
spawnArgs: () => [],
|
|
50165
50340
|
selectModel: { configId: "model" },
|
|
50166
50341
|
// Sign-in is the delegated browser flow on the engine card, never a
|
|
50167
|
-
// prompt in the middle of a turn.
|
|
50342
|
+
// prompt in the middle of a turn: no authenticate call is made. The
|
|
50343
|
+
// sign-in gate is requireAuthenticationBeforeSpawn (Vibe's own
|
|
50344
|
+
// `_auth/status`), so the handshake continues without one; "fail" here
|
|
50345
|
+
// stopped every turn of a signed-in Vibe with loginNote.
|
|
50168
50346
|
pickAuthMethod: () => null,
|
|
50169
|
-
authFailure: "
|
|
50347
|
+
authFailure: "continue",
|
|
50170
50348
|
requireAuthenticationBeforeSpawn: true,
|
|
50171
|
-
|
|
50349
|
+
// A missing `vibe-acp` passes this gate on purpose: the spawn then says it
|
|
50350
|
+
// is not installed, where loginNote would have blamed the sign-in. The
|
|
50351
|
+
// engine list never asks here without a CLI (snapshot probes it first).
|
|
50352
|
+
isAuthenticated: (env, config2, instanceId) => cachedSignedIn(`${instanceId}:${env.VIBE_HOME ?? ""}`, async () => await vibeSignInState(config2.cli || "vibe-acp", env) !== "signed-out"),
|
|
50172
50353
|
async configureSession({ request, sessionId, config: config2, turn }) {
|
|
50173
50354
|
const value = vibeSessionMode(config2.fullAuto, turn.approvalMode);
|
|
50174
50355
|
let reply;
|
|
@@ -50397,12 +50578,12 @@ var init_atomic_engine_local = __esm({
|
|
|
50397
50578
|
// server/atomic-engine-accounts.ts
|
|
50398
50579
|
import { mkdirSync as mkdirSync22, readFileSync as readFileSync27, writeFileSync as writeFileSync18 } from "node:fs";
|
|
50399
50580
|
import { homedir as homedir25 } from "node:os";
|
|
50400
|
-
import { join as
|
|
50581
|
+
import { join as join47 } from "node:path";
|
|
50401
50582
|
function rawConfig2(entry) {
|
|
50402
50583
|
return entry.config && typeof entry.config === "object" && !Array.isArray(entry.config) ? entry.config : {};
|
|
50403
50584
|
}
|
|
50404
50585
|
function expandHome(path4) {
|
|
50405
|
-
return path4 === "~" ? homedir25() : path4.startsWith("~/") ?
|
|
50586
|
+
return path4 === "~" ? homedir25() : path4.startsWith("~/") ? join47(homedir25(), path4.slice(2)) : path4;
|
|
50406
50587
|
}
|
|
50407
50588
|
function asAccount(id, entry) {
|
|
50408
50589
|
if (entry.enabled === false) return null;
|
|
@@ -50434,7 +50615,7 @@ function asAccount(id, entry) {
|
|
|
50434
50615
|
kind: "codex-cli",
|
|
50435
50616
|
label,
|
|
50436
50617
|
billing: "subscription",
|
|
50437
|
-
home: home ? expandHome(home) :
|
|
50618
|
+
home: home ? expandHome(home) : join47(homedir25(), ".codex"),
|
|
50438
50619
|
model: FAILOVER_MODEL["openai-codex"]
|
|
50439
50620
|
} };
|
|
50440
50621
|
}
|
|
@@ -50513,16 +50694,16 @@ function atomicEngineAccounts(input) {
|
|
|
50513
50694
|
}
|
|
50514
50695
|
function writeAtomicEngineAccountsFile(engineHome, accounts) {
|
|
50515
50696
|
const shareable = accounts.map(({ restingUntil: _resting, ...account }) => account);
|
|
50516
|
-
const
|
|
50697
|
+
const text7 = `${JSON.stringify({ version: 1, accounts: shareable }, null, 2)}
|
|
50517
50698
|
`;
|
|
50518
|
-
const path4 =
|
|
50699
|
+
const path4 = join47(engineHome, ACCOUNTS_FILE);
|
|
50519
50700
|
try {
|
|
50520
|
-
if (readFileSync27(path4, "utf8") ===
|
|
50701
|
+
if (readFileSync27(path4, "utf8") === text7) return;
|
|
50521
50702
|
} catch {
|
|
50522
50703
|
}
|
|
50523
50704
|
try {
|
|
50524
50705
|
mkdirSync22(engineHome, { recursive: true, mode: 448 });
|
|
50525
|
-
writeFileSync18(path4,
|
|
50706
|
+
writeFileSync18(path4, text7, { mode: 384 });
|
|
50526
50707
|
} catch (error51) {
|
|
50527
50708
|
console.warn(`[atomic-engine] could not write ${path4}: ${error51.message}`);
|
|
50528
50709
|
}
|
|
@@ -50607,31 +50788,31 @@ var init_atomic_engine_release = __esm({
|
|
|
50607
50788
|
|
|
50608
50789
|
// server/atomic-engine-runtime.ts
|
|
50609
50790
|
import { createHash as createHash15, randomUUID as randomUUID16 } from "node:crypto";
|
|
50610
|
-
import { createWriteStream as createWriteStream2, existsSync as
|
|
50611
|
-
import { join as
|
|
50791
|
+
import { createWriteStream as createWriteStream2, existsSync as existsSync25, mkdirSync as mkdirSync23, readdirSync as readdirSync8, readFileSync as readFileSync28, rmSync as rmSync10, writeFileSync as writeFileSync19 } from "node:fs";
|
|
50792
|
+
import { join as join48 } from "node:path";
|
|
50612
50793
|
import { Readable, Transform as Transform2 } from "node:stream";
|
|
50613
50794
|
import { pipeline as pipeline2 } from "node:stream/promises";
|
|
50614
50795
|
function atomicEngineHome(baseDir = DATA_DIR) {
|
|
50615
|
-
return
|
|
50796
|
+
return join48(baseDir, "tools", "atomic-engine");
|
|
50616
50797
|
}
|
|
50617
50798
|
function atomicEnginePython(root, platform = process.platform) {
|
|
50618
|
-
return platform === "win32" ?
|
|
50799
|
+
return platform === "win32" ? join48(root, "atomic-engine", "python", "python.exe") : join48(root, "atomic-engine", "python", "bin", "python3");
|
|
50619
50800
|
}
|
|
50620
50801
|
function managedAtomicEngine(baseDir = DATA_DIR, asset = atomicEngineAsset(), platform = process.platform) {
|
|
50621
50802
|
if (!asset) return null;
|
|
50622
|
-
const root =
|
|
50803
|
+
const root = join48(atomicEngineHome(baseDir), asset.version);
|
|
50623
50804
|
try {
|
|
50624
|
-
if (readFileSync28(
|
|
50805
|
+
if (readFileSync28(join48(root, MARKER2), "utf8").trim() !== asset.sha512) return null;
|
|
50625
50806
|
} catch {
|
|
50626
50807
|
return null;
|
|
50627
50808
|
}
|
|
50628
50809
|
const python = atomicEnginePython(root, platform);
|
|
50629
|
-
return
|
|
50810
|
+
return existsSync25(python) ? { version: asset.version, root, python } : null;
|
|
50630
50811
|
}
|
|
50631
50812
|
function systemTar(platform = process.platform) {
|
|
50632
50813
|
if (platform !== "win32") return "/usr/bin/tar";
|
|
50633
50814
|
const systemRoot = process.env.SystemRoot ?? process.env.SYSTEMROOT ?? "C:\\Windows";
|
|
50634
|
-
return
|
|
50815
|
+
return join48(systemRoot, "System32", "tar.exe");
|
|
50635
50816
|
}
|
|
50636
50817
|
async function download(asset, file2, options) {
|
|
50637
50818
|
let response;
|
|
@@ -50676,8 +50857,8 @@ async function installOnce3(options) {
|
|
|
50676
50857
|
const home = atomicEngineHome(baseDir);
|
|
50677
50858
|
mkdirSync23(home, { recursive: true });
|
|
50678
50859
|
const id = randomUUID16();
|
|
50679
|
-
const archive =
|
|
50680
|
-
const staging =
|
|
50860
|
+
const archive = join48(home, `.download-${id}.tar.gz`);
|
|
50861
|
+
const staging = join48(home, `.staging-${id}`);
|
|
50681
50862
|
try {
|
|
50682
50863
|
await download(asset, archive, options);
|
|
50683
50864
|
options.onProgress?.({ phase: "installing" });
|
|
@@ -50687,8 +50868,8 @@ async function installOnce3(options) {
|
|
|
50687
50868
|
} catch (error51) {
|
|
50688
50869
|
throw new AtomicEngineInstallError("install", `Could not unpack Atomic Engine: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
50689
50870
|
}
|
|
50690
|
-
if (!
|
|
50691
|
-
const root =
|
|
50871
|
+
if (!existsSync25(atomicEnginePython(staging))) throw new AtomicEngineInstallError("install", "The Atomic Engine package has no Python runtime for this computer");
|
|
50872
|
+
const root = join48(home, asset.version);
|
|
50692
50873
|
rmSync10(root, { recursive: true, force: true });
|
|
50693
50874
|
await promoteDirectory(staging, root);
|
|
50694
50875
|
const python = atomicEnginePython(root);
|
|
@@ -50699,10 +50880,10 @@ async function installOnce3(options) {
|
|
|
50699
50880
|
await removeDirectoryQuietly(root, "Atomic Engine has no install marker there, so it is not used");
|
|
50700
50881
|
throw new AtomicEngineInstallError("install", `Atomic Engine did not start after installing: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
50701
50882
|
}
|
|
50702
|
-
writeFileSync19(
|
|
50883
|
+
writeFileSync19(join48(root, MARKER2), `${asset.sha512}
|
|
50703
50884
|
`);
|
|
50704
|
-
for (const name of
|
|
50705
|
-
if (name !== asset.version && !name.startsWith(".")) rmSync10(
|
|
50885
|
+
for (const name of readdirSync8(home)) {
|
|
50886
|
+
if (name !== asset.version && !name.startsWith(".")) rmSync10(join48(home, name), { recursive: true, force: true });
|
|
50706
50887
|
}
|
|
50707
50888
|
const installed = managedAtomicEngine(baseDir, asset);
|
|
50708
50889
|
if (!installed) throw new AtomicEngineInstallError("install", "Atomic Engine did not install completely");
|
|
@@ -51661,14 +51842,14 @@ var init_stringifyComment = __esm({
|
|
|
51661
51842
|
});
|
|
51662
51843
|
|
|
51663
51844
|
// ../atomic-harness-skills/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/stringify/foldFlowLines.js
|
|
51664
|
-
function foldFlowLines(
|
|
51845
|
+
function foldFlowLines(text7, indent, mode = "flow", { indentAtStart, lineWidth = 80, minContentWidth = 20, onFold, onOverflow } = {}) {
|
|
51665
51846
|
if (!lineWidth || lineWidth < 0)
|
|
51666
|
-
return
|
|
51847
|
+
return text7;
|
|
51667
51848
|
if (lineWidth < minContentWidth)
|
|
51668
51849
|
minContentWidth = 0;
|
|
51669
51850
|
const endStep = Math.max(1 + minContentWidth, 1 + lineWidth - indent.length);
|
|
51670
|
-
if (
|
|
51671
|
-
return
|
|
51851
|
+
if (text7.length <= endStep)
|
|
51852
|
+
return text7;
|
|
51672
51853
|
const folds = [];
|
|
51673
51854
|
const escapedFolds = {};
|
|
51674
51855
|
let end = lineWidth - indent.length;
|
|
@@ -51685,14 +51866,14 @@ function foldFlowLines(text6, indent, mode = "flow", { indentAtStart, lineWidth
|
|
|
51685
51866
|
let escStart = -1;
|
|
51686
51867
|
let escEnd = -1;
|
|
51687
51868
|
if (mode === FOLD_BLOCK) {
|
|
51688
|
-
i2 = consumeMoreIndentedLines(
|
|
51869
|
+
i2 = consumeMoreIndentedLines(text7, i2, indent.length);
|
|
51689
51870
|
if (i2 !== -1)
|
|
51690
51871
|
end = i2 + endStep;
|
|
51691
51872
|
}
|
|
51692
|
-
for (let ch; ch =
|
|
51873
|
+
for (let ch; ch = text7[i2 += 1]; ) {
|
|
51693
51874
|
if (mode === FOLD_QUOTED && ch === "\\") {
|
|
51694
51875
|
escStart = i2;
|
|
51695
|
-
switch (
|
|
51876
|
+
switch (text7[i2 + 1]) {
|
|
51696
51877
|
case "x":
|
|
51697
51878
|
i2 += 3;
|
|
51698
51879
|
break;
|
|
@@ -51709,12 +51890,12 @@ function foldFlowLines(text6, indent, mode = "flow", { indentAtStart, lineWidth
|
|
|
51709
51890
|
}
|
|
51710
51891
|
if (ch === "\n") {
|
|
51711
51892
|
if (mode === FOLD_BLOCK)
|
|
51712
|
-
i2 = consumeMoreIndentedLines(
|
|
51893
|
+
i2 = consumeMoreIndentedLines(text7, i2, indent.length);
|
|
51713
51894
|
end = i2 + indent.length + endStep;
|
|
51714
51895
|
split = void 0;
|
|
51715
51896
|
} else {
|
|
51716
51897
|
if (ch === " " && prev && prev !== " " && prev !== "\n" && prev !== " ") {
|
|
51717
|
-
const next =
|
|
51898
|
+
const next = text7[i2 + 1];
|
|
51718
51899
|
if (next && next !== " " && next !== "\n" && next !== " ")
|
|
51719
51900
|
split = i2;
|
|
51720
51901
|
}
|
|
@@ -51726,12 +51907,12 @@ function foldFlowLines(text6, indent, mode = "flow", { indentAtStart, lineWidth
|
|
|
51726
51907
|
} else if (mode === FOLD_QUOTED) {
|
|
51727
51908
|
while (prev === " " || prev === " ") {
|
|
51728
51909
|
prev = ch;
|
|
51729
|
-
ch =
|
|
51910
|
+
ch = text7[i2 += 1];
|
|
51730
51911
|
overflow = true;
|
|
51731
51912
|
}
|
|
51732
51913
|
const j2 = i2 > escEnd + 1 ? i2 - 2 : escStart - 1;
|
|
51733
51914
|
if (escapedFolds[j2])
|
|
51734
|
-
return
|
|
51915
|
+
return text7;
|
|
51735
51916
|
folds.push(j2);
|
|
51736
51917
|
escapedFolds[j2] = true;
|
|
51737
51918
|
end = j2 + endStep;
|
|
@@ -51746,39 +51927,39 @@ function foldFlowLines(text6, indent, mode = "flow", { indentAtStart, lineWidth
|
|
|
51746
51927
|
if (overflow && onOverflow)
|
|
51747
51928
|
onOverflow();
|
|
51748
51929
|
if (folds.length === 0)
|
|
51749
|
-
return
|
|
51930
|
+
return text7;
|
|
51750
51931
|
if (onFold)
|
|
51751
51932
|
onFold();
|
|
51752
|
-
let res =
|
|
51933
|
+
let res = text7.slice(0, folds[0]);
|
|
51753
51934
|
for (let i3 = 0; i3 < folds.length; ++i3) {
|
|
51754
51935
|
const fold = folds[i3];
|
|
51755
|
-
const end2 = folds[i3 + 1] ||
|
|
51936
|
+
const end2 = folds[i3 + 1] || text7.length;
|
|
51756
51937
|
if (fold === 0)
|
|
51757
51938
|
res = `
|
|
51758
|
-
${indent}${
|
|
51939
|
+
${indent}${text7.slice(0, end2)}`;
|
|
51759
51940
|
else {
|
|
51760
51941
|
if (mode === FOLD_QUOTED && escapedFolds[fold])
|
|
51761
|
-
res += `${
|
|
51942
|
+
res += `${text7[fold]}\\`;
|
|
51762
51943
|
res += `
|
|
51763
|
-
${indent}${
|
|
51944
|
+
${indent}${text7.slice(fold + 1, end2)}`;
|
|
51764
51945
|
}
|
|
51765
51946
|
}
|
|
51766
51947
|
return res;
|
|
51767
51948
|
}
|
|
51768
|
-
function consumeMoreIndentedLines(
|
|
51949
|
+
function consumeMoreIndentedLines(text7, i2, indent) {
|
|
51769
51950
|
let end = i2;
|
|
51770
51951
|
let start = i2 + 1;
|
|
51771
|
-
let ch =
|
|
51952
|
+
let ch = text7[start];
|
|
51772
51953
|
while (ch === " " || ch === " ") {
|
|
51773
51954
|
if (i2 < start + indent) {
|
|
51774
|
-
ch =
|
|
51955
|
+
ch = text7[++i2];
|
|
51775
51956
|
} else {
|
|
51776
51957
|
do {
|
|
51777
|
-
ch =
|
|
51958
|
+
ch = text7[++i2];
|
|
51778
51959
|
} while (ch && ch !== "\n");
|
|
51779
51960
|
end = i2;
|
|
51780
51961
|
start = i2 + 1;
|
|
51781
|
-
ch =
|
|
51962
|
+
ch = text7[start];
|
|
51782
51963
|
}
|
|
51783
51964
|
}
|
|
51784
51965
|
return end;
|
|
@@ -57625,8 +57806,8 @@ var init_memory_policy = __esm({
|
|
|
57625
57806
|
|
|
57626
57807
|
// server/drivers/acp/hermes-memory-lock.ts
|
|
57627
57808
|
import { createHash as createHash16 } from "node:crypto";
|
|
57628
|
-
import { mkdirSync as mkdirSync24, readdirSync as
|
|
57629
|
-
import { join as
|
|
57809
|
+
import { mkdirSync as mkdirSync24, readdirSync as readdirSync9, readFileSync as readFileSync29, writeFileSync as writeFileSync20 } from "node:fs";
|
|
57810
|
+
import { join as join49 } from "node:path";
|
|
57630
57811
|
function readText2(path4) {
|
|
57631
57812
|
try {
|
|
57632
57813
|
return readFileSync29(path4, "utf8");
|
|
@@ -57634,10 +57815,10 @@ function readText2(path4) {
|
|
|
57634
57815
|
return null;
|
|
57635
57816
|
}
|
|
57636
57817
|
}
|
|
57637
|
-
function parseYamlSafe(
|
|
57638
|
-
if (
|
|
57818
|
+
function parseYamlSafe(text7) {
|
|
57819
|
+
if (text7 === null) return null;
|
|
57639
57820
|
try {
|
|
57640
|
-
return parse3(
|
|
57821
|
+
return parse3(text7);
|
|
57641
57822
|
} catch {
|
|
57642
57823
|
return null;
|
|
57643
57824
|
}
|
|
@@ -57648,29 +57829,29 @@ function record3(value) {
|
|
|
57648
57829
|
function memoryProviderPlugins(pluginsDir) {
|
|
57649
57830
|
let dirs;
|
|
57650
57831
|
try {
|
|
57651
|
-
dirs =
|
|
57832
|
+
dirs = readdirSync9(pluginsDir);
|
|
57652
57833
|
} catch {
|
|
57653
57834
|
return [];
|
|
57654
57835
|
}
|
|
57655
57836
|
return dirs.flatMap((dir) => {
|
|
57656
|
-
const source2 = (readText2(
|
|
57837
|
+
const source2 = (readText2(join49(pluginsDir, dir, "__init__.py")) ?? "").slice(0, 8192);
|
|
57657
57838
|
if (!source2.includes("register_memory_provider") && !source2.includes("MemoryProvider")) return [];
|
|
57658
|
-
const name = record3(parseYamlSafe(readText2(
|
|
57839
|
+
const name = record3(parseYamlSafe(readText2(join49(pluginsDir, dir, "plugin.yaml"))))?.name;
|
|
57659
57840
|
return typeof name === "string" && name.trim() && name.trim() !== dir ? [dir, name.trim()] : [dir];
|
|
57660
57841
|
});
|
|
57661
57842
|
}
|
|
57662
57843
|
function lockHermesMemory(env, home, dataDir = DATA_DIR) {
|
|
57663
|
-
const own = record3(record3(parseYamlSafe(readText2(
|
|
57844
|
+
const own = record3(record3(parseYamlSafe(readText2(join49(home, "config.yaml"))))?.plugins);
|
|
57664
57845
|
const disabled = new Set(Array.isArray(own?.disabled) ? own.disabled.map(String) : []);
|
|
57665
|
-
for (const name of memoryProviderPlugins(
|
|
57846
|
+
for (const name of memoryProviderPlugins(join49(home, "plugins"))) disabled.add(name);
|
|
57666
57847
|
for (const name of BLOCKED_HERMES_MEMORY_PLUGINS) disabled.add(name);
|
|
57667
57848
|
const overlay = stringify3({
|
|
57668
57849
|
memory: { provider: "", memory_enabled: false, user_profile_enabled: false },
|
|
57669
57850
|
plugins: { disabled: [...disabled].sort() }
|
|
57670
57851
|
});
|
|
57671
|
-
const dir =
|
|
57852
|
+
const dir = join49(dataDir, "hermes-managed", createHash16("sha256").update(home).digest("hex").slice(0, 16));
|
|
57672
57853
|
mkdirSync24(dir, { recursive: true });
|
|
57673
|
-
const file2 =
|
|
57854
|
+
const file2 = join49(dir, "config.yaml");
|
|
57674
57855
|
if (readText2(file2) !== overlay) writeFileSync20(file2, overlay);
|
|
57675
57856
|
env.HERMES_MANAGED_DIR = dir;
|
|
57676
57857
|
return dir;
|
|
@@ -57688,7 +57869,7 @@ var init_hermes_memory_lock = __esm({
|
|
|
57688
57869
|
import { spawn as spawn7 } from "node:child_process";
|
|
57689
57870
|
import { mkdirSync as mkdirSync25, readFileSync as readFileSync30, writeFileSync as writeFileSync21 } from "node:fs";
|
|
57690
57871
|
import { homedir as homedir26 } from "node:os";
|
|
57691
|
-
import { join as
|
|
57872
|
+
import { join as join50 } from "node:path";
|
|
57692
57873
|
function bindHermesScreenshotCompat(env, modelId) {
|
|
57693
57874
|
delete env[HERMES_OPENMAUS_SCREENSHOT_COMPAT];
|
|
57694
57875
|
delete env[HERMES_OPENMAUS_SCREENSHOT_COMPAT_MODEL];
|
|
@@ -57698,30 +57879,30 @@ function bindHermesScreenshotCompat(env, modelId) {
|
|
|
57698
57879
|
env[HERMES_OPENMAUS_SCREENSHOT_COMPAT_MODEL] = inject.model;
|
|
57699
57880
|
}
|
|
57700
57881
|
function hermesHome(env) {
|
|
57701
|
-
return env.HERMES_HOME ||
|
|
57882
|
+
return env.HERMES_HOME || join50(env.HOME || env.USERPROFILE || homedir26(), ".hermes");
|
|
57702
57883
|
}
|
|
57703
57884
|
function quoteYaml(value) {
|
|
57704
57885
|
if (/^[\w./:+-]+$/.test(value)) return value;
|
|
57705
57886
|
return JSON.stringify(value);
|
|
57706
57887
|
}
|
|
57707
|
-
function upsertHermesProvider(
|
|
57888
|
+
function upsertHermesProvider(text7, hostId, baseUrl, apiKey) {
|
|
57708
57889
|
const block2 = [` ${hostId}:`, ` base_url: ${quoteYaml(baseUrl)}`, ` api_key: ${quoteYaml(apiKey)}`, ""].join(
|
|
57709
57890
|
"\n"
|
|
57710
57891
|
);
|
|
57711
|
-
if (/^providers:\s*$/m.test(
|
|
57712
|
-
const replaced = replaceHermesHostBlock(
|
|
57892
|
+
if (/^providers:\s*$/m.test(text7)) {
|
|
57893
|
+
const replaced = replaceHermesHostBlock(text7, hostId, block2);
|
|
57713
57894
|
if (replaced !== null) return replaced;
|
|
57714
|
-
return
|
|
57895
|
+
return text7.replace(/^providers:\s*$/m, `providers:
|
|
57715
57896
|
${block2.trimEnd()}`);
|
|
57716
57897
|
}
|
|
57717
|
-
const prefix =
|
|
57718
|
-
` :
|
|
57898
|
+
const prefix = text7 && !text7.endsWith("\n") ? `${text7}
|
|
57899
|
+
` : text7;
|
|
57719
57900
|
return `${prefix}
|
|
57720
57901
|
providers:
|
|
57721
57902
|
${block2}`;
|
|
57722
57903
|
}
|
|
57723
|
-
function replaceHermesHostBlock(
|
|
57724
|
-
const lines =
|
|
57904
|
+
function replaceHermesHostBlock(text7, hostId, block2) {
|
|
57905
|
+
const lines = text7.split("\n");
|
|
57725
57906
|
const start = lines.findIndex((line) => line === ` ${hostId}:`);
|
|
57726
57907
|
if (start < 0) return null;
|
|
57727
57908
|
let end = start + 1;
|
|
@@ -57740,15 +57921,15 @@ function ensureHermesInjectProvider(modelId, env = process.env, home = hermesHom
|
|
|
57740
57921
|
if (!host) return modelId;
|
|
57741
57922
|
const dir = home;
|
|
57742
57923
|
mkdirSync25(dir, { recursive: true });
|
|
57743
|
-
const path4 =
|
|
57744
|
-
let
|
|
57924
|
+
const path4 = join50(dir, "config.yaml");
|
|
57925
|
+
let text7 = "";
|
|
57745
57926
|
try {
|
|
57746
|
-
|
|
57927
|
+
text7 = readFileSync30(path4, "utf8");
|
|
57747
57928
|
} catch {
|
|
57748
|
-
|
|
57929
|
+
text7 = "";
|
|
57749
57930
|
}
|
|
57750
|
-
const next = upsertHermesProvider(
|
|
57751
|
-
if (next !==
|
|
57931
|
+
const next = upsertHermesProvider(text7, inject.host, host.baseUrl, hostApiKey(host, env));
|
|
57932
|
+
if (next !== text7) writeFileSync21(path4, next);
|
|
57752
57933
|
return hermesAcpModelId(modelId) ?? modelId;
|
|
57753
57934
|
}
|
|
57754
57935
|
function hermesAcpModelId(modelId) {
|
|
@@ -57758,8 +57939,8 @@ function hermesAcpModelId(modelId) {
|
|
|
57758
57939
|
if (native && !native.includes(INJECT_SEP) && /^[a-z0-9_-]+:[\w./:-]+$/i.test(native)) return native;
|
|
57759
57940
|
return null;
|
|
57760
57941
|
}
|
|
57761
|
-
function nonEmptyDotenvValue(
|
|
57762
|
-
const match = new RegExp(`^[ \\t]*(?:export[ \\t]+)?${name}[ \\t]*=[ \\t]*([^\\r\\n]*)$`, "m").exec(
|
|
57942
|
+
function nonEmptyDotenvValue(text7, name) {
|
|
57943
|
+
const match = new RegExp(`^[ \\t]*(?:export[ \\t]+)?${name}[ \\t]*=[ \\t]*([^\\r\\n]*)$`, "m").exec(text7);
|
|
57763
57944
|
if (!match) return null;
|
|
57764
57945
|
const raw = match[1].trim();
|
|
57765
57946
|
if (!raw || raw.startsWith("#")) return null;
|
|
@@ -57776,10 +57957,10 @@ function nonEmptyDotenvValue(text6, name) {
|
|
|
57776
57957
|
function yamlString(value) {
|
|
57777
57958
|
return typeof value === "string" ? value.trim() : "";
|
|
57778
57959
|
}
|
|
57779
|
-
function hermesConfigDefault(
|
|
57960
|
+
function hermesConfigDefault(text7) {
|
|
57780
57961
|
let raw;
|
|
57781
57962
|
try {
|
|
57782
|
-
raw = parse3(
|
|
57963
|
+
raw = parse3(text7);
|
|
57783
57964
|
} catch {
|
|
57784
57965
|
return null;
|
|
57785
57966
|
}
|
|
@@ -57811,13 +57992,13 @@ function hermesConfiguredModel(env = process.env) {
|
|
|
57811
57992
|
const dir = hermesHome(env);
|
|
57812
57993
|
let secrets = "";
|
|
57813
57994
|
try {
|
|
57814
|
-
secrets = readFileSync30(
|
|
57995
|
+
secrets = readFileSync30(join50(dir, ".env"), "utf8");
|
|
57815
57996
|
} catch {
|
|
57816
57997
|
}
|
|
57817
57998
|
const hasHostedProviderKey = HERMES_HOSTED_PROVIDER_KEYS.some((name) => nonEmptyDotenvValue(secrets, name));
|
|
57818
57999
|
let configuredDefault = null;
|
|
57819
58000
|
try {
|
|
57820
|
-
configuredDefault = hermesConfigDefault(readFileSync30(
|
|
58001
|
+
configuredDefault = hermesConfigDefault(readFileSync30(join50(dir, "config.yaml"), "utf8"));
|
|
57821
58002
|
} catch {
|
|
57822
58003
|
}
|
|
57823
58004
|
const configuredProvider = configuredDefault?.provider.toLowerCase() ?? "";
|
|
@@ -57862,7 +58043,7 @@ function oauthRowSignedIn(row, now) {
|
|
|
57862
58043
|
return present(row.access_token) && notExpired(row, now);
|
|
57863
58044
|
}
|
|
57864
58045
|
function hermesSignedInProviders(env = process.env, now = Date.now()) {
|
|
57865
|
-
const store = record4(readJson(
|
|
58046
|
+
const store = record4(readJson(join50(hermesHome(env), "auth.json")));
|
|
57866
58047
|
const out = /* @__PURE__ */ new Set();
|
|
57867
58048
|
if (!store) return out;
|
|
57868
58049
|
const providers = record4(store.providers) ?? {};
|
|
@@ -57886,7 +58067,7 @@ function hermesZaiCodingPlan(env = process.env) {
|
|
|
57886
58067
|
const dir = hermesHome(env);
|
|
57887
58068
|
let secrets = "";
|
|
57888
58069
|
try {
|
|
57889
|
-
secrets = readFileSync30(
|
|
58070
|
+
secrets = readFileSync30(join50(dir, ".env"), "utf8");
|
|
57890
58071
|
} catch {
|
|
57891
58072
|
}
|
|
57892
58073
|
const keyed2 = ["GLM_API_KEY", "ZAI_API_KEY", "Z_AI_API_KEY"].some((name) => present(env[name]) || nonEmptyDotenvValue(secrets, name));
|
|
@@ -57894,21 +58075,21 @@ function hermesZaiCodingPlan(env = process.env) {
|
|
|
57894
58075
|
const coding = (url2) => typeof url2 === "string" && /\/api\/coding\/paas\//i.test(url2);
|
|
57895
58076
|
const override = present(env.GLM_BASE_URL) ? env.GLM_BASE_URL : nonEmptyDotenvValue(secrets, "GLM_BASE_URL");
|
|
57896
58077
|
if (override) return coding(override);
|
|
57897
|
-
const detected = record4(record4(record4(record4(readJson(
|
|
58078
|
+
const detected = record4(record4(record4(record4(readJson(join50(dir, "auth.json")))?.providers)?.zai)?.detected_endpoint);
|
|
57898
58079
|
return coding(detected?.base_url);
|
|
57899
58080
|
}
|
|
57900
58081
|
function hermesZaiPlanHosts(options, codingPlan) {
|
|
57901
58082
|
return codingPlan ? options.map((option) => option.provider === "zai" ? { ...option, provider: "zai-coding-plan" } : option) : [...options];
|
|
57902
58083
|
}
|
|
57903
58084
|
function hermesCachedModels(home, provider) {
|
|
57904
|
-
const catalog2 = record4(record4(record4(readJson(
|
|
58085
|
+
const catalog2 = record4(record4(record4(readJson(join50(home, "cache", "model_catalog.json")))?.providers)?.[provider]);
|
|
57905
58086
|
const name = String(record4(catalog2?.metadata)?.display_name ?? "").trim() || provider;
|
|
57906
58087
|
const rows = Array.isArray(catalog2?.models) ? catalog2.models.map(record4).filter((row) => row && present(row.id)) : [];
|
|
57907
58088
|
if (rows.length) {
|
|
57908
58089
|
const ordered = [...rows.filter((row) => row.default === true), ...rows.filter((row) => row.default !== true)];
|
|
57909
58090
|
return { ids: ordered.map((row) => String(row.id).trim()), name };
|
|
57910
58091
|
}
|
|
57911
|
-
const cached3 = record4(record4(readJson(
|
|
58092
|
+
const cached3 = record4(record4(readJson(join50(home, "provider_models_cache.json")))?.[provider])?.models;
|
|
57912
58093
|
return { ids: Array.isArray(cached3) ? cached3.filter(present).map((id) => String(id).trim()) : [], name };
|
|
57913
58094
|
}
|
|
57914
58095
|
function hermesAuthStoreModels(env = process.env, now = Date.now()) {
|
|
@@ -57926,7 +58107,7 @@ function hermesConfiguredHostModel(env = process.env) {
|
|
|
57926
58107
|
const home = hermesHome(env);
|
|
57927
58108
|
let configured = null;
|
|
57928
58109
|
try {
|
|
57929
|
-
configured = hermesConfigDefault(readFileSync30(
|
|
58110
|
+
configured = hermesConfigDefault(readFileSync30(join50(home, "config.yaml"), "utf8"));
|
|
57930
58111
|
} catch {
|
|
57931
58112
|
return null;
|
|
57932
58113
|
}
|
|
@@ -58101,6 +58282,8 @@ var init_hermes = __esm({
|
|
|
58101
58282
|
// a longer idle window than the default (a rejected key is caught sooner,
|
|
58102
58283
|
// from its log, by the core's stderr check).
|
|
58103
58284
|
promptIdleMs: 3e5,
|
|
58285
|
+
mcpServerLimit: { count: 16, bytes: 56e3 },
|
|
58286
|
+
// its gateway refuses a 17th, or 65536 bytes once it adds its own fields
|
|
58104
58287
|
loginNote: "Hermes CLI is not installed",
|
|
58105
58288
|
// No install command: setup never installs Hermes (Erick, 2026-11-08).
|
|
58106
58289
|
// Nous Research signs in with a Nous Portal API key instead
|
|
@@ -58127,12 +58310,7 @@ var init_hermes = __esm({
|
|
|
58127
58310
|
async configureSession({ request, sessionId, turn }) {
|
|
58128
58311
|
const native = hermesAcpModelId(turn.model);
|
|
58129
58312
|
if (!native) return;
|
|
58130
|
-
await applySetting2(
|
|
58131
|
-
request,
|
|
58132
|
-
"session/set_model",
|
|
58133
|
-
{ sessionId, modelId: native },
|
|
58134
|
-
`model "${native}"`
|
|
58135
|
-
);
|
|
58313
|
+
await applySetting2(request, "session/set_model", { sessionId, modelId: native }, `model "${native}"`);
|
|
58136
58314
|
},
|
|
58137
58315
|
buildPromptText: (turn) => turn.system ? `${turn.system}
|
|
58138
58316
|
|
|
@@ -58144,7 +58322,7 @@ ${turn.text}` : turn.text
|
|
|
58144
58322
|
|
|
58145
58323
|
// server/drivers/acp/custom.ts
|
|
58146
58324
|
import { homedir as homedir27 } from "node:os";
|
|
58147
|
-
import { basename as basename9, join as
|
|
58325
|
+
import { basename as basename9, join as join51 } from "node:path";
|
|
58148
58326
|
function isAtomicEngine(instanceId, cli) {
|
|
58149
58327
|
const program = (cli ?? "").trim().split(/\s+/)[0] ?? "";
|
|
58150
58328
|
return instanceId === "atomic-engine" || basename9(program) === "atomic";
|
|
@@ -58169,7 +58347,7 @@ async function customAcpSnapshot(env, cli, instanceId) {
|
|
|
58169
58347
|
return { state: "available", version: version2, authenticated: true };
|
|
58170
58348
|
}
|
|
58171
58349
|
function atomicEngineHome2(env) {
|
|
58172
|
-
return env.HERMES_HOME ||
|
|
58350
|
+
return env.HERMES_HOME || join51(env.HOME || env.USERPROFILE || homedir27(), ".atomic");
|
|
58173
58351
|
}
|
|
58174
58352
|
function applyAtomicEngineAccounts(env, instanceId, cli, accounts = currentAtomicEngineAccounts) {
|
|
58175
58353
|
if (!isAtomicEngine(instanceId, cli)) return;
|
|
@@ -58268,6 +58446,9 @@ var init_custom = __esm({
|
|
|
58268
58446
|
throw new Error(`Atomic Engine rejected model "${modelId}" via session/set_model: ${error51.message}`);
|
|
58269
58447
|
}
|
|
58270
58448
|
},
|
|
58449
|
+
// A cold Atomic Engine restores a saved session without its local provider
|
|
58450
|
+
// and then posts the prompt to api.anthropic.com: never session/load there.
|
|
58451
|
+
freshSessionForLocalModel: true,
|
|
58271
58452
|
defaultCli: "",
|
|
58272
58453
|
nativeSource: "custom.acp",
|
|
58273
58454
|
loginNote: CONFIGURE_HINT,
|
|
@@ -58294,6 +58475,8 @@ var init_custom = __esm({
|
|
|
58294
58475
|
driverKind: "atomicEngine",
|
|
58295
58476
|
displayName: "Atomic Engine",
|
|
58296
58477
|
defaultCli: DEFAULT_ATOMIC_ENGINE_CLI,
|
|
58478
|
+
// It gives each account 180 s of silence before it moves to its next one, and says nothing over ACP while it does.
|
|
58479
|
+
promptIdleMs: 6e5,
|
|
58297
58480
|
async configureSession(context) {
|
|
58298
58481
|
await support11.configureSession?.(context);
|
|
58299
58482
|
const modeId = context.turn.approvalMode === "plan" ? "atomic-plan-v1" : "default";
|
|
@@ -58405,7 +58588,7 @@ var init_ollama_cloud = __esm({
|
|
|
58405
58588
|
nativeLog: {
|
|
58406
58589
|
source: "ollama-cloud.chat.completions",
|
|
58407
58590
|
outgoing: (_turn, messages, model) => ({ model, messageCount: messages.length }),
|
|
58408
|
-
incoming: ({ text:
|
|
58591
|
+
incoming: ({ text: text7, reasoning, usage }) => ({ textLength: text7.length, reasoningLength: reasoning.length, usage })
|
|
58409
58592
|
}
|
|
58410
58593
|
});
|
|
58411
58594
|
}
|
|
@@ -58561,8 +58744,8 @@ var init_openai_compat = __esm({
|
|
|
58561
58744
|
nativeLog: {
|
|
58562
58745
|
source: "openai-compat.chat.completions",
|
|
58563
58746
|
outgoing: (_turn, messages, model) => ({ model, messageCount: messages.length }),
|
|
58564
|
-
incoming: ({ text:
|
|
58565
|
-
textLength:
|
|
58747
|
+
incoming: ({ text: text7, reasoning, usage }) => ({
|
|
58748
|
+
textLength: text7.length,
|
|
58566
58749
|
reasoningLength: reasoning.length,
|
|
58567
58750
|
usage
|
|
58568
58751
|
})
|
|
@@ -58574,9 +58757,9 @@ var init_openai_compat = __esm({
|
|
|
58574
58757
|
});
|
|
58575
58758
|
|
|
58576
58759
|
// server/drivers/pi.ts
|
|
58577
|
-
import { chmodSync as chmodSync7, existsSync as
|
|
58760
|
+
import { chmodSync as chmodSync7, existsSync as existsSync26, mkdirSync as mkdirSync26, mkdtempSync as mkdtempSync5, readFileSync as readFileSync31, rmSync as rmSync11, writeFileSync as writeFileSync22 } from "node:fs";
|
|
58578
58761
|
import { homedir as homedir28, tmpdir as tmpdir7 } from "node:os";
|
|
58579
|
-
import { join as
|
|
58762
|
+
import { join as join52 } from "node:path";
|
|
58580
58763
|
function readPiPromptImages(turn) {
|
|
58581
58764
|
return (turn.images ?? []).map((image) => ({
|
|
58582
58765
|
type: "image",
|
|
@@ -58698,7 +58881,7 @@ async function applyPiLocalCatalog(catalog2, env = process.env, fetchImpl = fetc
|
|
|
58698
58881
|
return preferPiInjectRows(await mergeLocalInject(catalog2, env, fetchImpl));
|
|
58699
58882
|
}
|
|
58700
58883
|
function piAgentDir(env) {
|
|
58701
|
-
return
|
|
58884
|
+
return join52(env.HOME || env.USERPROFILE || homedir28(), ".pi", "agent");
|
|
58702
58885
|
}
|
|
58703
58886
|
function ensurePiInjectModel(modelId, env = process.env) {
|
|
58704
58887
|
const split = splitPiModel(modelId);
|
|
@@ -58709,9 +58892,9 @@ function ensurePiInjectModel(modelId, env = process.env) {
|
|
|
58709
58892
|
if (!host) return split;
|
|
58710
58893
|
const dir = piAgentDir(env);
|
|
58711
58894
|
mkdirSync26(dir, { recursive: true });
|
|
58712
|
-
const path4 =
|
|
58895
|
+
const path4 = join52(dir, "models.json");
|
|
58713
58896
|
let root = { providers: {} };
|
|
58714
|
-
if (
|
|
58897
|
+
if (existsSync26(path4)) {
|
|
58715
58898
|
try {
|
|
58716
58899
|
const parsed = JSON.parse(readFileSync31(path4, "utf8"));
|
|
58717
58900
|
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
@@ -58929,9 +59112,9 @@ var init_pi = __esm({
|
|
|
58929
59112
|
const mcpServers = buildMcpServers(turn);
|
|
58930
59113
|
let mcpTempDir = null;
|
|
58931
59114
|
if (mcpServers) {
|
|
58932
|
-
mcpTempDir = mkdtempSync5(
|
|
59115
|
+
mcpTempDir = mkdtempSync5(join52(tmpdir7(), "omb-pi-mcp-"));
|
|
58933
59116
|
try {
|
|
58934
|
-
writeFileSync22(
|
|
59117
|
+
writeFileSync22(join52(mcpTempDir, "mcp.json"), JSON.stringify({ mcpServers }), { mode: 384 });
|
|
58935
59118
|
} catch (err) {
|
|
58936
59119
|
try {
|
|
58937
59120
|
rmSync11(mcpTempDir, { recursive: true, force: true });
|
|
@@ -58950,7 +59133,7 @@ var init_pi = __esm({
|
|
|
58950
59133
|
env: piEnvironment({
|
|
58951
59134
|
...process.env,
|
|
58952
59135
|
...input.environment,
|
|
58953
|
-
...mcpServers && mcpTempDir ? { OMB_MCP_CONFIG:
|
|
59136
|
+
...mcpServers && mcpTempDir ? { OMB_MCP_CONFIG: join52(mcpTempDir, "mcp.json") } : {}
|
|
58954
59137
|
})
|
|
58955
59138
|
});
|
|
58956
59139
|
} catch (err) {
|
|
@@ -58987,10 +59170,10 @@ var init_pi = __esm({
|
|
|
58987
59170
|
child.stdin.write(JSON.stringify(obj) + "\n");
|
|
58988
59171
|
};
|
|
58989
59172
|
const flushAssistantText = () => {
|
|
58990
|
-
const
|
|
59173
|
+
const text7 = assistantText;
|
|
58991
59174
|
assistantText = "";
|
|
58992
|
-
if (!
|
|
58993
|
-
emit({ ...base3(threadId, turnId), type: "item.completed", itemType: "assistant_text", text:
|
|
59175
|
+
if (!text7.trim()) return;
|
|
59176
|
+
emit({ ...base3(threadId, turnId), type: "item.completed", itemType: "assistant_text", text: text7 });
|
|
58994
59177
|
};
|
|
58995
59178
|
const settle = (ok, stopReason, usage) => {
|
|
58996
59179
|
if (settled) return;
|
|
@@ -59097,7 +59280,7 @@ var init_pi = __esm({
|
|
|
59097
59280
|
const mcpTool = isQuestion ? null : piMcpToolRef(
|
|
59098
59281
|
evt.title,
|
|
59099
59282
|
customServerNames,
|
|
59100
|
-
mcpTempDir ?
|
|
59283
|
+
mcpTempDir ? join52(mcpTempDir, PI_TOOL_HINTS_FILE) : null
|
|
59101
59284
|
);
|
|
59102
59285
|
emit({
|
|
59103
59286
|
...base3(threadId, turnId),
|
|
@@ -59421,7 +59604,7 @@ var init_mistral = __esm({
|
|
|
59421
59604
|
nativeLog: {
|
|
59422
59605
|
source: "mistral.chat.completions",
|
|
59423
59606
|
outgoing: (_turn, messages, model) => ({ model, messageCount: messages.length }),
|
|
59424
|
-
incoming: ({ text:
|
|
59607
|
+
incoming: ({ text: text7, usage }) => ({ textLength: text7.length, usage })
|
|
59425
59608
|
}
|
|
59426
59609
|
});
|
|
59427
59610
|
}
|
|
@@ -59432,14 +59615,14 @@ var init_mistral = __esm({
|
|
|
59432
59615
|
// server/drivers/minimax.ts
|
|
59433
59616
|
import { readFileSync as readFileSync32 } from "node:fs";
|
|
59434
59617
|
import { homedir as homedir29 } from "node:os";
|
|
59435
|
-
import { join as
|
|
59618
|
+
import { join as join53 } from "node:path";
|
|
59436
59619
|
function normalizedApiUrl(value) {
|
|
59437
59620
|
const root = value.trim().replace(/\/+$/, "");
|
|
59438
59621
|
return root.endsWith("/v1") ? root : `${root}/v1`;
|
|
59439
59622
|
}
|
|
59440
59623
|
function loadLocalMiniMaxConfig(home = homedir29()) {
|
|
59441
59624
|
try {
|
|
59442
|
-
const raw = localConfigSchema.parse(JSON.parse(readFileSync32(
|
|
59625
|
+
const raw = localConfigSchema.parse(JSON.parse(readFileSync32(join53(home, ".mmx", "config.json"), "utf8")));
|
|
59443
59626
|
const configuredUrl = raw.base_url?.trim() ? raw.base_url : raw.region === "cn" ? CN_URL : DEFAULT_URL3;
|
|
59444
59627
|
return {
|
|
59445
59628
|
apiKey: raw.api_key?.trim() ?? "",
|
|
@@ -59535,7 +59718,7 @@ var init_minimax = __esm({
|
|
|
59535
59718
|
nativeLog: {
|
|
59536
59719
|
source: "minimax.chat.completions",
|
|
59537
59720
|
outgoing: (_turn, messages, model) => ({ model, messageCount: messages.length }),
|
|
59538
|
-
incoming: ({ text:
|
|
59721
|
+
incoming: ({ text: text7, usage }) => ({ textLength: text7.length, usage })
|
|
59539
59722
|
}
|
|
59540
59723
|
});
|
|
59541
59724
|
}
|
|
@@ -59546,7 +59729,7 @@ var init_minimax = __esm({
|
|
|
59546
59729
|
// server/apple-intelligence.ts
|
|
59547
59730
|
import { spawn as spawn8 } from "node:child_process";
|
|
59548
59731
|
import { accessSync, constants as constants3 } from "node:fs";
|
|
59549
|
-
import { join as
|
|
59732
|
+
import { join as join54 } from "node:path";
|
|
59550
59733
|
function intelligenceErrorMessage(code) {
|
|
59551
59734
|
return MESSAGES[code] ?? `Apple Intelligence failed (${code}).`;
|
|
59552
59735
|
}
|
|
@@ -59554,9 +59737,9 @@ function resolveIntelligenceHelper(env = process.env, platform = process.platfor
|
|
|
59554
59737
|
if (platform !== "darwin" || arch !== "arm64") return null;
|
|
59555
59738
|
const candidates = [
|
|
59556
59739
|
env.ATOMIC_INTELLIGENCE_HELPER,
|
|
59557
|
-
env.OMB_RESOURCES_PATH &&
|
|
59558
|
-
|
|
59559
|
-
|
|
59740
|
+
env.OMB_RESOURCES_PATH && join54(env.OMB_RESOURCES_PATH, HELPER),
|
|
59741
|
+
join54(serverRoot, "..", HELPER),
|
|
59742
|
+
join54(serverRoot, "..", "dist-native", "arm64", HELPER)
|
|
59560
59743
|
];
|
|
59561
59744
|
for (const candidate of candidates) {
|
|
59562
59745
|
if (!candidate) continue;
|
|
@@ -59744,7 +59927,7 @@ var init_apple_intelligence = __esm({
|
|
|
59744
59927
|
"concurrent-requests": "Apple Intelligence is busy. Try again in a moment.",
|
|
59745
59928
|
"timeout": "Apple Intelligence took too long to answer."
|
|
59746
59929
|
};
|
|
59747
|
-
HELPER =
|
|
59930
|
+
HELPER = join54("Atomic Intelligence.app", "Contents", "MacOS", "intelligence-helper");
|
|
59748
59931
|
}
|
|
59749
59932
|
});
|
|
59750
59933
|
|
|
@@ -59814,9 +59997,9 @@ function createAppleIntelligenceInstance(input, deps = {}) {
|
|
|
59814
59997
|
let failure;
|
|
59815
59998
|
try {
|
|
59816
59999
|
const request = shapeRequest(turn, inputBudget(availability.contextSize));
|
|
59817
|
-
const
|
|
59818
|
-
if (!
|
|
59819
|
-
emit({ ...base3(turn.threadId, turnId), type: "item.completed", itemType: "assistant_text", text:
|
|
60000
|
+
const text7 = await client.stream(request, (delta) => emit({ ...base3(turn.threadId, turnId), type: "content.delta", streamKind: "assistant_text", delta }), abort.signal);
|
|
60001
|
+
if (!text7.trim()) throw new Error("Apple Intelligence returned an empty response.");
|
|
60002
|
+
emit({ ...base3(turn.threadId, turnId), type: "item.completed", itemType: "assistant_text", text: text7 });
|
|
59820
60003
|
ok = true;
|
|
59821
60004
|
} catch (error51) {
|
|
59822
60005
|
failure = error51 instanceof Error ? error51.message : String(error51);
|
|
@@ -59893,10 +60076,10 @@ var init_apple_intelligence2 = __esm({
|
|
|
59893
60076
|
INPUT_TOKEN_BUDGET = 6e3;
|
|
59894
60077
|
REPLY_TOKENS = 1500;
|
|
59895
60078
|
CHARS_PER_TOKEN = 4;
|
|
59896
|
-
estimateTokens = (
|
|
59897
|
-
clip = (
|
|
60079
|
+
estimateTokens = (text7) => Math.ceil(text7.length / CHARS_PER_TOKEN);
|
|
60080
|
+
clip = (text7, tokens) => {
|
|
59898
60081
|
const chars = Math.max(0, tokens * CHARS_PER_TOKEN);
|
|
59899
|
-
return
|
|
60082
|
+
return text7.length <= chars ? text7 : `${text7.slice(0, Math.max(0, chars - 1))}\u2026`;
|
|
59900
60083
|
};
|
|
59901
60084
|
configSchema4 = external_exports.object({}).passthrough();
|
|
59902
60085
|
AppleIntelligenceDriver = {
|
|
@@ -60103,7 +60286,7 @@ __export(cli_setup_exports, {
|
|
|
60103
60286
|
});
|
|
60104
60287
|
import { spawn as spawn9 } from "node:child_process";
|
|
60105
60288
|
import { readFileSync as readFileSync33 } from "node:fs";
|
|
60106
|
-
import { join as
|
|
60289
|
+
import { join as join55, resolve as resolve12 } from "node:path";
|
|
60107
60290
|
import { randomUUID as randomUUID17 } from "node:crypto";
|
|
60108
60291
|
async function inspect2(id, entry) {
|
|
60109
60292
|
const registry2 = new ProviderRegistry(BUILT_IN_DRIVERS);
|
|
@@ -60140,7 +60323,7 @@ function assertDataDir(dataDir) {
|
|
|
60140
60323
|
}
|
|
60141
60324
|
function checkStoredConfig(dataDir) {
|
|
60142
60325
|
try {
|
|
60143
|
-
parseStoredConfig(JSON.parse(readFileSync33(
|
|
60326
|
+
parseStoredConfig(JSON.parse(readFileSync33(join55(dataDir, "config.json"), "utf8")));
|
|
60144
60327
|
} catch (error51) {
|
|
60145
60328
|
if (error51.code === "ENOENT") return;
|
|
60146
60329
|
throw new Error("Existing config.json could not be read or validated. Setup has not changed it; repair it before continuing.");
|
|
@@ -60552,9 +60735,9 @@ async function runTerminal(options, io2) {
|
|
|
60552
60735
|
var import_qrcode_terminal = __toESM(require_main(), 1);
|
|
60553
60736
|
import { spawn as spawn10 } from "node:child_process";
|
|
60554
60737
|
import { randomBytes as randomBytes4 } from "node:crypto";
|
|
60555
|
-
import { closeSync as
|
|
60738
|
+
import { closeSync as closeSync7, existsSync as existsSync27, mkdirSync as mkdirSync27, openSync as openSync7, readFileSync as readFileSync34 } from "node:fs";
|
|
60556
60739
|
import { homedir as homedir30 } from "node:os";
|
|
60557
|
-
import { dirname as dirname13, join as
|
|
60740
|
+
import { dirname as dirname13, join as join56, resolve as resolve13 } from "node:path";
|
|
60558
60741
|
import { createInterface as createInterface2 } from "node:readline/promises";
|
|
60559
60742
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
60560
60743
|
|
|
@@ -61187,10 +61370,10 @@ async function verifyHostedEndpoint(endpoint, { fetchImpl, timeoutSignal, timeou
|
|
|
61187
61370
|
signal: cancellationSignal ? AbortSignal.any([requestSignal, cancellationSignal]) : requestSignal
|
|
61188
61371
|
});
|
|
61189
61372
|
if (!response.ok) return false;
|
|
61190
|
-
const
|
|
61191
|
-
if (Buffer.byteLength(
|
|
61373
|
+
const text7 = await response.text();
|
|
61374
|
+
if (Buffer.byteLength(text7) > 4096) return false;
|
|
61192
61375
|
try {
|
|
61193
|
-
return JSON.parse(
|
|
61376
|
+
return JSON.parse(text7)?.app === "openmausbot";
|
|
61194
61377
|
} catch {
|
|
61195
61378
|
return false;
|
|
61196
61379
|
}
|
|
@@ -62103,8 +62286,8 @@ function isSecretParameter(name) {
|
|
|
62103
62286
|
function keyLikeSegment(segment) {
|
|
62104
62287
|
return (segment.match(/[A-Za-z0-9]{16,}/g) ?? []).some((run2) => /\d/.test(run2) && /[A-Za-z]/.test(run2));
|
|
62105
62288
|
}
|
|
62106
|
-
function maskUrlSecrets(
|
|
62107
|
-
return
|
|
62289
|
+
function maskUrlSecrets(text7) {
|
|
62290
|
+
return text7.replace(/\b([a-z][\w+.-]*:\/\/)([^\s/?#]*)([^\s?#]*)([^\s]*)/gi, (_all, scheme, authority, path4, rest) => {
|
|
62108
62291
|
const at2 = authority.lastIndexOf("@");
|
|
62109
62292
|
const host = at2 >= 0 ? `${HIDDEN}@${authority.slice(at2 + 1)}` : authority;
|
|
62110
62293
|
const maskedPath = path4.split("/").map((segment) => keyLikeSegment(segment) ? HIDDEN : segment).join("/");
|
|
@@ -62142,8 +62325,8 @@ function auditValues(values) {
|
|
|
62142
62325
|
const last = segments.at(-1) ?? path4;
|
|
62143
62326
|
const opaque = segments.slice(0, -1).some((segment) => OPAQUE_MAP.test(segment));
|
|
62144
62327
|
const scrubbed = (isSecretName3(last) || opaque) && value !== void 0 && value !== null && value !== "" ? HIDDEN : scrub(value, 0, OPAQUE_MAP.test(last));
|
|
62145
|
-
const
|
|
62146
|
-
out[path4] =
|
|
62328
|
+
const text7 = JSON.stringify(scrubbed);
|
|
62329
|
+
out[path4] = text7 !== void 0 && text7.length > MAX_VALUE_CHARS ? "[large value]" : scrubbed ?? null;
|
|
62147
62330
|
}
|
|
62148
62331
|
return out;
|
|
62149
62332
|
}
|
|
@@ -62537,9 +62720,9 @@ async function startCaddy(options) {
|
|
|
62537
62720
|
});
|
|
62538
62721
|
let output = "";
|
|
62539
62722
|
const receive = (chunk) => {
|
|
62540
|
-
const
|
|
62541
|
-
if (output.length < 16384) output +=
|
|
62542
|
-
for (const line of
|
|
62723
|
+
const text7 = chunk.toString("utf8");
|
|
62724
|
+
if (output.length < 16384) output += text7;
|
|
62725
|
+
for (const line of text7.split(/\r?\n/)) {
|
|
62543
62726
|
if (!line.trim()) continue;
|
|
62544
62727
|
if (/"level":"(warn|error)"/.test(line) || /^\S+\s+(WARN|ERROR)/.test(line) || !line.startsWith("{")) options.log?.(`caddy: ${line.slice(0, 400)}`);
|
|
62545
62728
|
}
|
|
@@ -62891,16 +63074,16 @@ var TEXT_COLORS = {
|
|
|
62891
63074
|
dark: { accent: [[0, 179, 152], 36], gold: [[242, 169, 0], 214] },
|
|
62892
63075
|
unknown: { accent: [[0, 128, 108], 30], gold: [[168, 100, 0], 130] }
|
|
62893
63076
|
};
|
|
62894
|
-
function paint(
|
|
62895
|
-
if (depth === "none") return
|
|
63077
|
+
function paint(text7, role, depth, background, bold) {
|
|
63078
|
+
if (depth === "none") return text7;
|
|
62896
63079
|
const weight = bold ? "1;" : "";
|
|
62897
|
-
if (depth === "16") return `\x1B[${weight}${role === "accent" ? 36 : 33}m${
|
|
63080
|
+
if (depth === "16") return `\x1B[${weight}${role === "accent" ? 36 : 33}m${text7}\x1B[0m`;
|
|
62898
63081
|
const [triple, index] = TEXT_COLORS[background][role];
|
|
62899
|
-
if (depth === "256") return `\x1B[${weight}38;5;${index}m${
|
|
62900
|
-
return `\x1B[${weight}38;2;${triple.join(";")}m${
|
|
63082
|
+
if (depth === "256") return `\x1B[${weight}38;5;${index}m${text7}\x1B[0m`;
|
|
63083
|
+
return `\x1B[${weight}38;2;${triple.join(";")}m${text7}\x1B[0m`;
|
|
62901
63084
|
}
|
|
62902
|
-
function quiet(
|
|
62903
|
-
return depth === "none" ?
|
|
63085
|
+
function quiet(text7, depth) {
|
|
63086
|
+
return depth === "none" ? text7 : `\x1B[2m${text7}\x1B[0m`;
|
|
62904
63087
|
}
|
|
62905
63088
|
function renderBanner(input) {
|
|
62906
63089
|
const random = input.random ?? Math.random;
|
|
@@ -62908,7 +63091,7 @@ function renderBanner(input) {
|
|
|
62908
63091
|
const greeting = pick2(GREETINGS);
|
|
62909
63092
|
const tip = pick2(TIPS);
|
|
62910
63093
|
const { depth, background } = input;
|
|
62911
|
-
const
|
|
63094
|
+
const text7 = [
|
|
62912
63095
|
`${paint("Atomic", "accent", depth, background, true)} by Chibitek`,
|
|
62913
63096
|
quiet(`Version ${input.version}`, depth),
|
|
62914
63097
|
input.account ? `Signed in as ${input.account}` : quiet("Not signed in to an Atomic account", depth),
|
|
@@ -62917,19 +63100,19 @@ function renderBanner(input) {
|
|
|
62917
63100
|
`${paint("Tip:", "gold", depth, background, true)} ${tip}`
|
|
62918
63101
|
];
|
|
62919
63102
|
const columns = input.columns ?? 80;
|
|
62920
|
-
if (columns < 20) return `${
|
|
63103
|
+
if (columns < 20) return `${text7.join("\n")}
|
|
62921
63104
|
`;
|
|
62922
63105
|
const mark = chibiAnsiLines(depth, background === "light" ? "light" : "dark");
|
|
62923
63106
|
const widest = Math.max(...[greeting, `Tip: ${tip}`, input.account ? `Signed in as ${input.account}` : ""].map((l) => l.length));
|
|
62924
63107
|
if (columns < 16 + 3 + Math.min(widest, 44)) return `${mark.map((line) => line.trimEnd()).join("\n")}
|
|
62925
63108
|
|
|
62926
|
-
${
|
|
63109
|
+
${text7.join("\n")}
|
|
62927
63110
|
`;
|
|
62928
|
-
const rows = Math.max(mark.length,
|
|
63111
|
+
const rows = Math.max(mark.length, text7.length);
|
|
62929
63112
|
const lines = [];
|
|
62930
63113
|
for (let i2 = 0; i2 < rows; i2 += 1) {
|
|
62931
63114
|
const left = mark[i2] ?? " ".repeat(16);
|
|
62932
|
-
const right =
|
|
63115
|
+
const right = text7[i2] ?? "";
|
|
62933
63116
|
lines.push(right ? `${left} ${right}` : left.trimEnd());
|
|
62934
63117
|
}
|
|
62935
63118
|
return `${lines.join("\n")}
|
|
@@ -63015,8 +63198,8 @@ function agentUnit(spec) {
|
|
|
63015
63198
|
function emptyRegistry(domain2) {
|
|
63016
63199
|
return { version: 1, domain: domain2, nextPort: FLEET_FIRST_PORT, workspaces: {} };
|
|
63017
63200
|
}
|
|
63018
|
-
function parseRegistry(
|
|
63019
|
-
const value = JSON.parse(
|
|
63201
|
+
function parseRegistry(text7) {
|
|
63202
|
+
const value = JSON.parse(text7);
|
|
63020
63203
|
const record6 = value && typeof value === "object" ? value : null;
|
|
63021
63204
|
if (!record6 || record6.version !== 1 || typeof record6.domain !== "string" || typeof record6.nextPort !== "number" || !record6.workspaces || typeof record6.workspaces !== "object") {
|
|
63022
63205
|
throw new Error("fleet.json is not a fleet registry this version understands");
|
|
@@ -63621,14 +63804,14 @@ async function executePlan(steps, deps, io2) {
|
|
|
63621
63804
|
}
|
|
63622
63805
|
function failed(io2, what, output) {
|
|
63623
63806
|
io2.error(`fleet: could not ${what}`);
|
|
63624
|
-
const
|
|
63625
|
-
if (
|
|
63807
|
+
const tail3 = output.trim().split("\n").slice(-6).join("\n");
|
|
63808
|
+
if (tail3) io2.error(tail3);
|
|
63626
63809
|
return 1;
|
|
63627
63810
|
}
|
|
63628
63811
|
function loadRegistry(layout, deps) {
|
|
63629
|
-
const
|
|
63630
|
-
if (
|
|
63631
|
-
return parseRegistry(
|
|
63812
|
+
const text7 = deps.readText(layout.registryFile);
|
|
63813
|
+
if (text7 === null) throw new Error(`no fleet on this server yet: run \`chibi fleet init --domain your.domain\` first`);
|
|
63814
|
+
return parseRegistry(text7);
|
|
63632
63815
|
}
|
|
63633
63816
|
function planFleetAction(input, deps) {
|
|
63634
63817
|
const layout = fleetLayout(input.root ?? "/");
|
|
@@ -63802,15 +63985,15 @@ import { dirname as dirname5 } from "node:path";
|
|
|
63802
63985
|
var MAX_BODY = 256 * 1024;
|
|
63803
63986
|
function readBody(req) {
|
|
63804
63987
|
return new Promise((resolve14, reject) => {
|
|
63805
|
-
let
|
|
63988
|
+
let text7 = "";
|
|
63806
63989
|
req.on("data", (chunk) => {
|
|
63807
|
-
|
|
63808
|
-
if (
|
|
63990
|
+
text7 += chunk.toString("utf8");
|
|
63991
|
+
if (text7.length > MAX_BODY) reject(Object.assign(new Error("request too large"), { status: 413 }));
|
|
63809
63992
|
});
|
|
63810
63993
|
req.on("end", () => {
|
|
63811
|
-
if (!
|
|
63994
|
+
if (!text7.trim()) return resolve14({});
|
|
63812
63995
|
try {
|
|
63813
|
-
const value = JSON.parse(
|
|
63996
|
+
const value = JSON.parse(text7);
|
|
63814
63997
|
resolve14(value && typeof value === "object" && !Array.isArray(value) ? value : {});
|
|
63815
63998
|
} catch {
|
|
63816
63999
|
reject(Object.assign(new Error("body must be JSON"), { status: 400 }));
|
|
@@ -64027,8 +64210,8 @@ function tailnetNameBlocksHttps(name) {
|
|
|
64027
64210
|
|
|
64028
64211
|
// server/tailscale.ts
|
|
64029
64212
|
init_procs();
|
|
64030
|
-
function classifyTailscaleStderr(
|
|
64031
|
-
const t2 =
|
|
64213
|
+
function classifyTailscaleStderr(text7) {
|
|
64214
|
+
const t2 = text7.toLowerCase();
|
|
64032
64215
|
if (/not logged in|logged out|needs login|please log in/.test(t2)) return "not-logged-in";
|
|
64033
64216
|
if (/is tailscale running|tailscaled is not running|connection refused|failed to connect to local tailscaled/.test(t2)) return "not-running";
|
|
64034
64217
|
if (/rejectedidentifier|reserved format|r-ldh/.test(t2)) return "reserved-name";
|
|
@@ -64483,7 +64666,7 @@ function parseArgs2(argv, env = process.env) {
|
|
|
64483
64666
|
const options = {
|
|
64484
64667
|
command: command === "--help" || command === "-h" ? "help" : command,
|
|
64485
64668
|
port: Number(env.OMB_PORT || 8799),
|
|
64486
|
-
dataDir: env.OMB_DATA_DIR ||
|
|
64669
|
+
dataDir: env.OMB_DATA_DIR || join56(homedir30(), ".atomic-app"),
|
|
64487
64670
|
tailscale: false,
|
|
64488
64671
|
tunnel: false,
|
|
64489
64672
|
client: false,
|
|
@@ -64624,7 +64807,7 @@ async function isWorkspaceRunning(options) {
|
|
|
64624
64807
|
try {
|
|
64625
64808
|
const { status, body } = await api(options.port, "/api/health");
|
|
64626
64809
|
if (status !== 200 || body?.app !== "openmausbot") return false;
|
|
64627
|
-
const expected = readFileSync34(
|
|
64810
|
+
const expected = readFileSync34(join56(options.dataDir, "environment-id"), "utf8").trim();
|
|
64628
64811
|
const descriptor = await api(options.port, "/.well-known/openmausbot/environment");
|
|
64629
64812
|
return /^[0-9a-f-]{36}$/i.test(expected) && descriptor.status === 200 && descriptor.body?.environmentId === expected;
|
|
64630
64813
|
} catch {
|
|
@@ -64736,9 +64919,9 @@ function originOf(link) {
|
|
|
64736
64919
|
return null;
|
|
64737
64920
|
}
|
|
64738
64921
|
}
|
|
64739
|
-
function qrToString(
|
|
64922
|
+
function qrToString(text7) {
|
|
64740
64923
|
let out = "";
|
|
64741
|
-
import_qrcode_terminal.default.generate(
|
|
64924
|
+
import_qrcode_terminal.default.generate(text7, { small: true }, (rendered) => {
|
|
64742
64925
|
out = rendered;
|
|
64743
64926
|
});
|
|
64744
64927
|
return out;
|
|
@@ -64863,9 +65046,9 @@ async function runStatus(options, io2 = defaultIo()) {
|
|
|
64863
65046
|
return code;
|
|
64864
65047
|
}
|
|
64865
65048
|
async function runAccess(options, io2 = defaultIo()) {
|
|
64866
|
-
const file2 =
|
|
65049
|
+
const file2 = join56(options.dataDir, "config.json");
|
|
64867
65050
|
let raw = {};
|
|
64868
|
-
if (
|
|
65051
|
+
if (existsSync27(file2)) {
|
|
64869
65052
|
try {
|
|
64870
65053
|
const parsed = JSON.parse(readFileSync34(file2, "utf8"));
|
|
64871
65054
|
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) throw new Error("not an object");
|
|
@@ -64994,16 +65177,16 @@ async function runLogout(options, io2 = defaultIo()) {
|
|
|
64994
65177
|
return 0;
|
|
64995
65178
|
}
|
|
64996
65179
|
function serverEntry(here = HERE2) {
|
|
64997
|
-
const bundled =
|
|
65180
|
+
const bundled = join56(here, "index.js");
|
|
64998
65181
|
const root = resolve13(here, "..");
|
|
64999
|
-
if (
|
|
65000
|
-
const staticDir2 = [
|
|
65001
|
-
const skillsDir =
|
|
65182
|
+
if (existsSync27(bundled)) {
|
|
65183
|
+
const staticDir2 = [join56(root, "dist"), join56(here, "..", "ui")].find((d) => existsSync27(join56(d, "index.html"))) ?? null;
|
|
65184
|
+
const skillsDir = existsSync27(join56(root, "skills")) ? join56(root, "skills") : null;
|
|
65002
65185
|
return { command: process.execPath, args: [bundled], staticDir: staticDir2, skillsDir };
|
|
65003
65186
|
}
|
|
65004
|
-
const source2 =
|
|
65005
|
-
const staticDir =
|
|
65006
|
-
return { command: process.execPath, args: ["--experimental-strip-types", source2], staticDir, skillsDir:
|
|
65187
|
+
const source2 = join56(here, "index.ts");
|
|
65188
|
+
const staticDir = existsSync27(join56(root, "dist", "index.html")) ? join56(root, "dist") : null;
|
|
65189
|
+
return { command: process.execPath, args: ["--experimental-strip-types", source2], staticDir, skillsDir: existsSync27(join56(root, "skills")) ? join56(root, "skills") : null };
|
|
65007
65190
|
}
|
|
65008
65191
|
async function planTunnel(options, log) {
|
|
65009
65192
|
let access2 = null;
|
|
@@ -65046,7 +65229,7 @@ async function runServe(options, log = console.log) {
|
|
|
65046
65229
|
console.error(`something already answers on http://127.0.0.1:${options.port}; use \`chibi pair\` against it, or --port for a second server`);
|
|
65047
65230
|
return 1;
|
|
65048
65231
|
}
|
|
65049
|
-
if (await reportBusyPort(options.port, options.dataDir ===
|
|
65232
|
+
if (await reportBusyPort(options.port, options.dataDir === join56(homedir30(), ".atomic-app") ? "" : ` --data-dir ${options.dataDir}`)) return 1;
|
|
65050
65233
|
let publicUrl = options.publicUrl;
|
|
65051
65234
|
let tailscale = null;
|
|
65052
65235
|
if (options.tailscale) {
|
|
@@ -65108,10 +65291,10 @@ async function runServe(options, log = console.log) {
|
|
|
65108
65291
|
let child;
|
|
65109
65292
|
try {
|
|
65110
65293
|
if (options.guided) {
|
|
65111
|
-
const logsDir =
|
|
65294
|
+
const logsDir = join56(options.dataDir, "logs");
|
|
65112
65295
|
mkdirSync27(logsDir, { recursive: true, mode: 448 });
|
|
65113
|
-
logPath =
|
|
65114
|
-
logFd =
|
|
65296
|
+
logPath = join56(logsDir, `server-${Date.now()}-${process.pid}.log`);
|
|
65297
|
+
logFd = openSync7(logPath, "wx", 384);
|
|
65115
65298
|
log("\nStarting your workspace\u2026");
|
|
65116
65299
|
}
|
|
65117
65300
|
if (tailscale) {
|
|
@@ -65142,7 +65325,7 @@ async function runServe(options, log = console.log) {
|
|
|
65142
65325
|
}
|
|
65143
65326
|
throw error51;
|
|
65144
65327
|
} finally {
|
|
65145
|
-
if (logFd !== void 0)
|
|
65328
|
+
if (logFd !== void 0) closeSync7(logFd);
|
|
65146
65329
|
process.removeListener("SIGINT", cancelStartup);
|
|
65147
65330
|
process.removeListener("SIGTERM", cancelStartup);
|
|
65148
65331
|
}
|
|
@@ -65314,7 +65497,7 @@ async function runOnboardingCommand(options, io2 = defaultIo(), startServer = ru
|
|
|
65314
65497
|
saveCliStartup2(options.dataDir, startupPreferences(launch));
|
|
65315
65498
|
}
|
|
65316
65499
|
if (options.command === "setup") {
|
|
65317
|
-
const flags = [options.dataDir !==
|
|
65500
|
+
const flags = [options.dataDir !== join56(homedir30(), ".atomic-app") && ` --data-dir ${options.dataDir}`, options.port !== 8799 && ` --port ${options.port}`].filter(Boolean).join("");
|
|
65318
65501
|
io2.log(`
|
|
65319
65502
|
All set. Start with: chibi${flags ? ` start${flags}` : ""} (or npx @chibitek/chibi without a global install).`);
|
|
65320
65503
|
return 0;
|
|
@@ -65354,15 +65537,15 @@ ${welcomeBanner(options)}
|
|
|
65354
65537
|
switch (options.command) {
|
|
65355
65538
|
case "command":
|
|
65356
65539
|
case "goal": {
|
|
65357
|
-
const
|
|
65358
|
-
const roomGoal = options.groupId ? /^\/goal(?:\s+([\s\S]*))?$/.exec(
|
|
65540
|
+
const text7 = options.command === "goal" ? `/goal ${options.commandText}` : options.commandText;
|
|
65541
|
+
const roomGoal = options.groupId ? /^\/goal(?:\s+([\s\S]*))?$/.exec(text7 ?? "") : null;
|
|
65359
65542
|
if (roomGoal && (!roomGoal[1]?.trim() || (roomGoal[1].startsWith("--") || /^(status|pause|resume|stop|help)(?:\s|$)/.test(roomGoal[1])))) {
|
|
65360
65543
|
console.error("Room goals accept an objective. Personal goal controls and budgets require --bot.");
|
|
65361
65544
|
return 2;
|
|
65362
65545
|
}
|
|
65363
65546
|
const result = await api(options.port, `/api/${options.groupId ? "groups" : "bots"}/${encodeURIComponent(options.groupId ?? options.botId)}/messages`, {
|
|
65364
65547
|
method: "POST",
|
|
65365
|
-
body: JSON.stringify({ threadId: options.threadId, text: roomGoal ? roomGoal[1] :
|
|
65548
|
+
body: JSON.stringify({ threadId: options.threadId, text: roomGoal ? roomGoal[1] : text7, ...roomGoal ? { mode: "goal" } : {}, sendId: randomBytes4(16).toString("hex") })
|
|
65366
65549
|
});
|
|
65367
65550
|
if (result.status >= 400) {
|
|
65368
65551
|
console.error(result.body.error ?? `Server returned ${result.status}`);
|