@chibitek/chibi 0.1.207 → 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-Cqjxle8G.js → TerminalPanel-B5bwdaJ5.js} +1 -1
- package/dist/assets/{abnfDiagram-O67JEVCF-XB80WX43.js → abnfDiagram-O67JEVCF-BLKuHvdS.js} +1 -1
- package/dist/assets/{arc-BERcgYDi.js → arc-BeOf3Y3d.js} +1 -1
- package/dist/assets/{architectureDiagram-NJMV4G6O-Dnc9s6SQ.js → architectureDiagram-NJMV4G6O-DnXr729a.js} +1 -1
- package/dist/assets/{blockDiagram-BEXU5L5S-Cxc21eYL.js → blockDiagram-BEXU5L5S-CEiwrTaI.js} +1 -1
- package/dist/assets/{c4Diagram-YGBWAQC7-CW-3gUcf.js → c4Diagram-YGBWAQC7-C0-29khR.js} +1 -1
- package/dist/assets/channel-_JFliC5C.js +1 -0
- package/dist/assets/{chunk-2Q5K7J3B-Bs484eiW.js → chunk-2Q5K7J3B-D8dKbbui.js} +1 -1
- package/dist/assets/{chunk-3FUC2YCW-qhnBgRDy.js → chunk-3FUC2YCW-fAEY1oOe.js} +2 -2
- package/dist/assets/{chunk-5VM5RSS4-CsCqAEkH.js → chunk-5VM5RSS4-Djza4B4b.js} +1 -1
- package/dist/assets/{chunk-GTNCS2PH-ChBgFjPw.js → chunk-GTNCS2PH-BWFGSXNt.js} +1 -1
- package/dist/assets/{chunk-GWA4HPMP-Df5-WClq.js → chunk-GWA4HPMP-BGo5oevY.js} +1 -1
- package/dist/assets/{chunk-JWPE2WC7-BdMXRJhO.js → chunk-JWPE2WC7-DIdxOMOn.js} +1 -1
- package/dist/assets/{chunk-NETBCI7D-rmAqJ9nY.js → chunk-NETBCI7D-Dc4tJ9uD.js} +1 -1
- package/dist/assets/{chunk-WEXAMYUT-DYmTw4lw.js → chunk-WEXAMYUT-DvZ9F5yw.js} +1 -1
- package/dist/assets/{chunk-XXDRQBXY-C4o5SHm0.js → chunk-XXDRQBXY-BYUVYcxq.js} +1 -1
- package/dist/assets/{classDiagram-v2-NBCMYWYE-Bm-ZzDk5.js → classDiagram-v2-NBCMYWYE-BtnsJQvT.js} +1 -1
- package/dist/assets/{cose-bilkent-JH36ORCC-CFMRSfMu.js → cose-bilkent-JH36ORCC-DLDe1VHc.js} +1 -1
- package/dist/assets/{cynefin-OW5HDTMX-BDedZ5yW.js → cynefin-OW5HDTMX-a1GJE5iI.js} +1 -1
- package/dist/assets/{cynefinDiagram-VND7K2PF-i7KARSqF.js → cynefinDiagram-VND7K2PF-DXxGLDlQ.js} +1 -1
- package/dist/assets/{dagre-6A5THRUB-CwWpV0i_.js → dagre-6A5THRUB-DAW_YZe9.js} +1 -1
- package/dist/assets/{diagram-22UHCM2B-CWIMT3-K.js → diagram-22UHCM2B-oq3saywD.js} +1 -1
- package/dist/assets/{diagram-3UASUU5V-C7HGc_ap.js → diagram-3UASUU5V-BhCP3hS9.js} +1 -1
- package/dist/assets/{diagram-ATOU4E4O-BeLM7ihN.js → diagram-ATOU4E4O-ByFRn1dW.js} +1 -1
- package/dist/assets/{diagram-CDSNMT55-CN1rVM-W.js → diagram-CDSNMT55-DWoCvkNH.js} +1 -1
- package/dist/assets/{diagram-MLGK6HIB-CuLcsx4e.js → diagram-MLGK6HIB-CSH5kSlk.js} +1 -1
- package/dist/assets/{diagram-MPIPVDR6-Bie61r-h.js → diagram-MPIPVDR6-Cnpx1s-T.js} +1 -1
- package/dist/assets/{ebnfDiagram-ZINNZB2B-ChMg86y3.js → ebnfDiagram-ZINNZB2B-DPmX63Vg.js} +1 -1
- package/dist/assets/{elk-276RUBZZ-DG9xXwoW.js → elk-276RUBZZ-DUtmO9kb.js} +1 -1
- package/dist/assets/{erDiagram-OPXOYQCR-C9bl-nWK.js → erDiagram-OPXOYQCR-SxwJeJu-.js} +1 -1
- package/dist/assets/{flowDiagram-KWPJA3E3-DvdWxFI8.js → flowDiagram-KWPJA3E3--QZAAUjB.js} +1 -1
- package/dist/assets/{ganttDiagram-FUAMR5RP-DDCNSEYc.js → ganttDiagram-FUAMR5RP-CRz6i2Pe.js} +1 -1
- package/dist/assets/{gitGraphDiagram-X574FWY7-PFvmOSMd.js → gitGraphDiagram-X574FWY7-Dx9Cisl2.js} +1 -1
- package/dist/assets/{index-DnniNB7N.js → index-BGkOob08.js} +1 -1
- package/dist/assets/{index-Ci2mINhA.js → index-vIsgWbJW.js} +83 -83
- package/dist/assets/{infoDiagram-VRGFBTTK-HEZh-PnK.js → infoDiagram-VRGFBTTK-CDLogk8N.js} +1 -1
- package/dist/assets/{ishikawaDiagram-OU5B5YK6-P3mmCGAU.js → ishikawaDiagram-OU5B5YK6-DsrF1wno.js} +1 -1
- package/dist/assets/{journeyDiagram-ZHPQQLJL-dKG4AQu2.js → journeyDiagram-ZHPQQLJL-DUi8LEA6.js} +1 -1
- package/dist/assets/{kanban-definition-PNTS6WVX-BeIHeQTt.js → kanban-definition-PNTS6WVX-BAdWXobw.js} +1 -1
- package/dist/assets/{linear-DnEqDr6r.js → linear-Dha948ns.js} +1 -1
- package/dist/assets/{mermaid.core-D7hz6n4u.js → mermaid.core-BqT1aUP9.js} +5 -5
- package/dist/assets/{mindmap-definition-NLK3R4M7-BxJ8p-DN.js → mindmap-definition-NLK3R4M7-XS1wDQ80.js} +1 -1
- package/dist/assets/{pegDiagram-GJSIUBJH-CkQT2dHJ.js → pegDiagram-GJSIUBJH-BphuafcF.js} +1 -1
- package/dist/assets/{pieDiagram-5QR66LMP-DmVVhYaY.js → pieDiagram-5QR66LMP-JN9mbdiU.js} +1 -1
- package/dist/assets/{quadrantDiagram-O4NWA36T-DsOz-qCY.js → quadrantDiagram-O4NWA36T-CkBF7Woa.js} +1 -1
- package/dist/assets/{railroadDiagram-XR7U4H2S-CeYfvaki.js → railroadDiagram-XR7U4H2S-Ie1GVpj5.js} +1 -1
- package/dist/assets/{requirementDiagram-PLB6GJNP-BCtM-2uN.js → requirementDiagram-PLB6GJNP-B8xGM6w4.js} +1 -1
- package/dist/assets/{sankeyDiagram-IPEJSGJF-Cu8ki35x.js → sankeyDiagram-IPEJSGJF-BgTSlqMg.js} +1 -1
- package/dist/assets/{sequenceDiagram-PO4LG4MO-DKbS5Gcs.js → sequenceDiagram-PO4LG4MO-B1J4EIne.js} +1 -1
- package/dist/assets/{sizeCapture-INFHLROL-Ceut6PrE.js → sizeCapture-INFHLROL-Cpcjc5oE.js} +1 -1
- package/dist/assets/{stateDiagram-v2-GCMORJYK-Bl5uMY2f.js → stateDiagram-v2-GCMORJYK-CtQKYLT4.js} +1 -1
- package/dist/assets/{swimlanes-2SLR337P-CoMPbJ2k.js → swimlanes-2SLR337P-DpIk02zs.js} +1 -1
- package/dist/assets/swimlanesDiagram-TC7HE7FX-DPTl4zVS.js +8 -0
- package/dist/assets/{timeline-definition-EJHVYXUP-D0xkKp46.js → timeline-definition-EJHVYXUP-DsA7dQhy.js} +1 -1
- package/dist/assets/{usecaseDiagram-POWQR4AR-BCCL6QIf.js → usecaseDiagram-POWQR4AR-BM42_rDz.js} +1 -1
- package/dist/assets/{vennDiagram-UO4OBE2U-B7g3jK72.js → vennDiagram-UO4OBE2U-DgLtqgJF.js} +1 -1
- package/dist/assets/{wardleyDiagram-VNRHLVJA-DFhnqQKP.js → wardleyDiagram-VNRHLVJA-BKUUTKBJ.js} +1 -1
- package/dist/assets/{xychartDiagram-PMCCYNJV-mIXMscRS.js → xychartDiagram-PMCCYNJV-B9RWvizV.js} +1 -1
- package/dist/index.html +1 -1
- package/dist-server/index.js +3150 -2724
- package/dist-server/openmausbot.js +816 -635
- package/dist-server/pair-cli.js +816 -635
- package/dist-server/server/connection-cap-failover.js +8 -6
- 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/turn-mcp.js +3 -0
- package/dist-server/server/drivers/vibe-login.js +17 -8
- package/dist-server/server/engine-failover.js +16 -29
- package/dist-server/server/engine-rest.js +4 -3
- package/dist-server/server/engine-tiers.js +12 -9
- package/dist-server/server/index.js +16 -15
- 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-DaeKCO76.js +0 -1
- package/dist/assets/swimlanesDiagram-TC7HE7FX-DLJq0mAR.js +0 -8
|
@@ -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;
|
|
@@ -27235,49 +27235,49 @@ var init_engine_failure = __esm({
|
|
|
27235
27235
|
RESET_WORD = String.raw`\b(?:resets?|try again|retry|available again|renews?|refresh(?:es)?)\b`;
|
|
27236
27236
|
RESET_READERS = [
|
|
27237
27237
|
// Claude Code's "usage limit reached|1759348800".
|
|
27238
|
-
function* epochPipe(
|
|
27239
|
-
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)) {
|
|
27240
27240
|
yield { at: Number(m3[1]) * 1e3, phrase: m3[0] };
|
|
27241
27241
|
}
|
|
27242
27242
|
},
|
|
27243
27243
|
// A structured reset instant: Codex's "resets_at": 1759348800, a
|
|
27244
27244
|
// "resetsAt", the unified rate-limit header.
|
|
27245
|
-
function* epochField(
|
|
27246
|
-
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)) {
|
|
27247
27247
|
yield { at: m3[1].length === 13 ? Number(m3[1]) : Number(m3[1]) * 1e3, phrase: m3[0] };
|
|
27248
27248
|
}
|
|
27249
27249
|
},
|
|
27250
27250
|
// "2026-09-25T18:00:00Z", "2026-10-03 09:00:00+02:00", "2026-08-08 00:00 UTC".
|
|
27251
|
-
function* isoTimestamp(
|
|
27252
|
-
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)) {
|
|
27253
27253
|
const [, y, mo2, d, h2, mi2, sec, frac, zoneText] = m3;
|
|
27254
|
-
const start = leadIn(
|
|
27254
|
+
const start = leadIn(text7, m3.index);
|
|
27255
27255
|
if (!zoneText && start === m3.index) continue;
|
|
27256
|
-
const after = zoneText ? void 0 : zoneAfter(
|
|
27256
|
+
const after = zoneText ? void 0 : zoneAfter(text7.slice(m3.index + m3[0].length));
|
|
27257
27257
|
const zone = zoneText ? parseZone(zoneText) : after?.zone ?? localZone();
|
|
27258
27258
|
if (!zone) continue;
|
|
27259
27259
|
const ms2 = frac ? Math.round(Number(`0.${frac}`) * 1e3) : 0;
|
|
27260
27260
|
const at2 = wallToInstant(Number(y), Number(mo2), Number(d), Number(h2), Number(mi2), zone, Number(sec ?? 0) * 1e3 + ms2);
|
|
27261
|
-
yield { at: at2, phrase:
|
|
27261
|
+
yield { at: at2, phrase: text7.slice(start, m3.index + m3[0].length + (after?.length ?? 0)) };
|
|
27262
27262
|
}
|
|
27263
27263
|
},
|
|
27264
27264
|
// "Retry-After: 120", "retry after 3600 seconds".
|
|
27265
|
-
function* retryAfter(
|
|
27266
|
-
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"))) {
|
|
27267
27267
|
yield { at: now + (m3[2] ? durationMs(`${m3[1]}${m3[2]}`) : Number(m3[1]) * 1e3), phrase: m3[0] };
|
|
27268
27268
|
}
|
|
27269
27269
|
},
|
|
27270
27270
|
// Structured durations: Gemini's "retryDelay": "41s", Codex's
|
|
27271
27271
|
// "resets_in_seconds": 3600, a "retry_after": 30.
|
|
27272
|
-
function* durationField(
|
|
27273
|
-
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)) {
|
|
27274
27274
|
yield { at: now + Number(m3[2]) * (m3[3]?.toLowerCase() === "ms" ? 1 : 1e3), phrase: m3[0] };
|
|
27275
27275
|
}
|
|
27276
27276
|
},
|
|
27277
27277
|
// "try again in 2 days 4 hours 12 minutes", "resets in 37m", "Please
|
|
27278
27278
|
// retry in 41.5s", "resets in 2d 4h 30m", Hermes's "resets in ~127h".
|
|
27279
|
-
function* relative(
|
|
27280
|
-
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"))) {
|
|
27281
27281
|
const total = durationMs(m3[1]);
|
|
27282
27282
|
if (total > 0) yield { at: now + total, phrase: m3[0] };
|
|
27283
27283
|
}
|
|
@@ -27285,11 +27285,11 @@ var init_engine_failure = __esm({
|
|
|
27285
27285
|
// A time of day, maybe with a date: "resets 3pm (America/New_York)",
|
|
27286
27286
|
// "resets Oct 3, 9am", "try again tomorrow at 9:00", "resets Thursday
|
|
27287
27287
|
// 9am", "Access resets at 3:45 PM EDT", "15:05 on 26 Sep 2026".
|
|
27288
|
-
function* clock2(
|
|
27289
|
-
for (const m3 of
|
|
27288
|
+
function* clock2(text7, now) {
|
|
27289
|
+
for (const m3 of text7.matchAll(new RegExp(RESET_WORD, "gi"))) {
|
|
27290
27290
|
const start = m3.index + m3[0].length;
|
|
27291
|
-
const found = readClock(
|
|
27292
|
-
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) };
|
|
27293
27293
|
}
|
|
27294
27294
|
}
|
|
27295
27295
|
];
|
|
@@ -27351,13 +27351,13 @@ function isModelRejection(error51, requested) {
|
|
|
27351
27351
|
return MODEL_REJECTION.test(message3) || requested.length > 0 && message3.includes(requested) && /\bmodel\b/i.test(message3);
|
|
27352
27352
|
}
|
|
27353
27353
|
function classifyError(err) {
|
|
27354
|
-
const
|
|
27355
|
-
if (isProviderSafetyBlock(
|
|
27356
|
-
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)) {
|
|
27357
27357
|
if (err && "exitCode" in err && err.exitCode !== null && err.exitCode < 0) return { transient: false, reason: "interrupted" };
|
|
27358
27358
|
return { transient: true, reason: "credential_refresh" };
|
|
27359
27359
|
}
|
|
27360
|
-
const failure = classifyEngineFailure(
|
|
27360
|
+
const failure = classifyEngineFailure(text7);
|
|
27361
27361
|
if (failure?.kind === "rate_limited") {
|
|
27362
27362
|
if (err && "exitCode" in err && err.exitCode !== null && err.exitCode < 0) return { transient: false, reason: "interrupted" };
|
|
27363
27363
|
return { transient: true, reason: "rate_limited" };
|
|
@@ -27367,18 +27367,18 @@ function classifyError(err) {
|
|
|
27367
27367
|
const { exitCode: code } = err;
|
|
27368
27368
|
if (code !== null && code < 0) return { transient: false, reason: "interrupted" };
|
|
27369
27369
|
for (const { pattern, reason } of TRANSIENT_PATTERNS) {
|
|
27370
|
-
if (pattern.test(
|
|
27370
|
+
if (pattern.test(text7)) return { transient: true, reason };
|
|
27371
27371
|
}
|
|
27372
27372
|
for (const { pattern, reason } of TERMINAL_PATTERNS) {
|
|
27373
|
-
if (pattern.test(
|
|
27373
|
+
if (pattern.test(text7)) return { transient: false, reason };
|
|
27374
27374
|
}
|
|
27375
27375
|
return { transient: false, reason: "terminal_exit" };
|
|
27376
27376
|
}
|
|
27377
27377
|
for (const { pattern, reason } of TERMINAL_PATTERNS) {
|
|
27378
|
-
if (pattern.test(
|
|
27378
|
+
if (pattern.test(text7)) return { transient: false, reason };
|
|
27379
27379
|
}
|
|
27380
27380
|
for (const { pattern, reason } of TRANSIENT_PATTERNS) {
|
|
27381
|
-
if (pattern.test(
|
|
27381
|
+
if (pattern.test(text7)) return { transient: true, reason };
|
|
27382
27382
|
}
|
|
27383
27383
|
return { transient: false, reason: "unknown" };
|
|
27384
27384
|
}
|
|
@@ -27516,18 +27516,20 @@ function turnMcpServers(turn) {
|
|
|
27516
27516
|
}
|
|
27517
27517
|
return servers;
|
|
27518
27518
|
}
|
|
27519
|
+
var ATOMIC_MCP_SERVERS;
|
|
27519
27520
|
var init_turn_mcp = __esm({
|
|
27520
27521
|
"server/drivers/turn-mcp.ts"() {
|
|
27521
27522
|
"use strict";
|
|
27522
27523
|
init_mcp_gate_config();
|
|
27524
|
+
ATOMIC_MCP_SERVERS = /* @__PURE__ */ new Set(["agents", "atomic_accounts", "browser", "computer"]);
|
|
27523
27525
|
}
|
|
27524
27526
|
});
|
|
27525
27527
|
|
|
27526
27528
|
// server/drivers/volatile-notes.ts
|
|
27527
27529
|
function volatileSectionsOf(turn) {
|
|
27528
27530
|
if (turn.systemVolatileSections) return turn.systemVolatileSections.filter((section) => section.text.trim());
|
|
27529
|
-
const
|
|
27530
|
-
return
|
|
27531
|
+
const text7 = turn.systemVolatile ?? "";
|
|
27532
|
+
return text7.trim() ? [{ id: "volatile", label: "Notes", text: text7 }] : [];
|
|
27531
27533
|
}
|
|
27532
27534
|
function volatileNote(sections, delivered, first) {
|
|
27533
27535
|
const parts = [];
|
|
@@ -27552,11 +27554,11 @@ ${lead}
|
|
|
27552
27554
|
${parts.join("\n\n")}
|
|
27553
27555
|
</system-reminder>`;
|
|
27554
27556
|
}
|
|
27555
|
-
function withNote(
|
|
27556
|
-
if (!note) return
|
|
27557
|
-
return
|
|
27557
|
+
function withNote(text7, note) {
|
|
27558
|
+
if (!note) return text7;
|
|
27559
|
+
return text7 ? `${note}
|
|
27558
27560
|
|
|
27559
|
-
${
|
|
27561
|
+
${text7}` : note;
|
|
27560
27562
|
}
|
|
27561
27563
|
var init_volatile_notes = __esm({
|
|
27562
27564
|
"server/drivers/volatile-notes.ts"() {
|
|
@@ -27570,11 +27572,11 @@ function sanitizeToolLogValue(value, budget, depth = 0) {
|
|
|
27570
27572
|
if (typeof value === "string") {
|
|
27571
27573
|
if (/^data:image\//iu.test(value) || budget.text <= 0) return void 0;
|
|
27572
27574
|
const limit = Math.min(TOOL_LOG_TEXT_LIMIT, budget.text);
|
|
27573
|
-
const
|
|
27575
|
+
const text7 = value.length <= limit ? value : `[Earlier output truncated]
|
|
27574
27576
|
|
|
27575
27577
|
${value.slice(-limit)}`;
|
|
27576
|
-
budget.text -=
|
|
27577
|
-
return
|
|
27578
|
+
budget.text -= text7.length;
|
|
27579
|
+
return text7;
|
|
27578
27580
|
}
|
|
27579
27581
|
if (Array.isArray(value)) {
|
|
27580
27582
|
return value.flatMap((entry) => {
|
|
@@ -27605,10 +27607,94 @@ var init_tool_log = __esm({
|
|
|
27605
27607
|
}
|
|
27606
27608
|
});
|
|
27607
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
|
+
|
|
27608
27694
|
// shared/approval-readback.ts
|
|
27609
|
-
function compareEffectiveMode(ladder, requested,
|
|
27610
|
-
const want =
|
|
27611
|
-
const got =
|
|
27695
|
+
function compareEffectiveMode(ladder, requested, reported2) {
|
|
27696
|
+
const want = text5(requested);
|
|
27697
|
+
const got = text5(reported2);
|
|
27612
27698
|
const ranks = MODE_LADDERS[ladder];
|
|
27613
27699
|
if (want === null || got === null) return { status: "unverified", requested: want, reported: got };
|
|
27614
27700
|
const wantRank = ranks?.[want];
|
|
@@ -27621,14 +27707,14 @@ function compareEffectiveMode(ladder, requested, reported) {
|
|
|
27621
27707
|
function looserModeMessage(engine, readback) {
|
|
27622
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.`;
|
|
27623
27709
|
}
|
|
27624
|
-
function assertEffectiveModeNotLooser(engine, ladder, requested,
|
|
27625
|
-
const readback = compareEffectiveMode(ladder, requested,
|
|
27710
|
+
function assertEffectiveModeNotLooser(engine, ladder, requested, reported2) {
|
|
27711
|
+
const readback = compareEffectiveMode(ladder, requested, reported2);
|
|
27626
27712
|
if (readback.status === "looser") {
|
|
27627
27713
|
throw Object.assign(new Error(looserModeMessage(engine, readback)), { code: "APPROVAL_MODE_LOOSER", readback });
|
|
27628
27714
|
}
|
|
27629
27715
|
return readback;
|
|
27630
27716
|
}
|
|
27631
|
-
var MODE_LADDERS,
|
|
27717
|
+
var MODE_LADDERS, text5;
|
|
27632
27718
|
var init_approval_readback = __esm({
|
|
27633
27719
|
"shared/approval-readback.ts"() {
|
|
27634
27720
|
"use strict";
|
|
@@ -27639,7 +27725,7 @@ var init_approval_readback = __esm({
|
|
|
27639
27725
|
qwenAgent: { plan: 4, default: 3, "auto-edit": 2, autoEdit: 2, auto: 1, yolo: 0 },
|
|
27640
27726
|
geminiAgent: { plan: 4, default: 3, autoEdit: 2, auto_edit: 2, "auto-edit": 2, yolo: 0 }
|
|
27641
27727
|
};
|
|
27642
|
-
|
|
27728
|
+
text5 = (value) => typeof value === "string" && value.trim() ? value.trim() : null;
|
|
27643
27729
|
}
|
|
27644
27730
|
});
|
|
27645
27731
|
|
|
@@ -27661,10 +27747,10 @@ function noteModeUpdate(session, raw) {
|
|
|
27661
27747
|
function forgetStaleModeReport(session, support12) {
|
|
27662
27748
|
if (support12.approvalModeReadback?.setsModeOverWire) stateOf(session).reported = null;
|
|
27663
27749
|
}
|
|
27664
|
-
function approvalReadbackFor(support12, config2, turn,
|
|
27750
|
+
function approvalReadbackFor(support12, config2, turn, reported2) {
|
|
27665
27751
|
const rules = support12.approvalModeReadback;
|
|
27666
|
-
if (!rules) return { status: "unverified", requested: null, reported };
|
|
27667
|
-
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);
|
|
27668
27754
|
}
|
|
27669
27755
|
function armModeReadback(input) {
|
|
27670
27756
|
const { support: support12, session, config: config2, turn } = input;
|
|
@@ -27701,28 +27787,6 @@ import { createHash as createHash5 } from "node:crypto";
|
|
|
27701
27787
|
function skipSubscriptionAuthForLocalInject(model) {
|
|
27702
27788
|
return Boolean(decodeInjectId(model));
|
|
27703
27789
|
}
|
|
27704
|
-
function acpRpcError(value, method) {
|
|
27705
|
-
const message3 = typeof value?.message === "string" ? value.message : "ACP request failed";
|
|
27706
|
-
const data = value?.data;
|
|
27707
|
-
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 : "";
|
|
27708
|
-
const context = [
|
|
27709
|
-
method,
|
|
27710
|
-
typeof data?.service === "string" ? `service: ${data.service}` : "",
|
|
27711
|
-
typeof data?.errorName === "string" ? data.errorName : ""
|
|
27712
|
-
].filter(Boolean).join(", ");
|
|
27713
|
-
const said = detail && detail !== message3 ? `${message3}: ${detail}` : message3;
|
|
27714
|
-
const reset = parseResetAt(said) === void 0 ? resetHintFromData(data) : void 0;
|
|
27715
|
-
const diagnostic = `${said}${reset ? ` (${reset})` : ""} (${context})`;
|
|
27716
|
-
const error51 = new Error(redactSecretsInText(diagnostic).slice(0, 1500));
|
|
27717
|
-
return Object.assign(error51, {
|
|
27718
|
-
code: value?.code,
|
|
27719
|
-
data,
|
|
27720
|
-
// -32603 is JSON-RPC's internal error. Invalid params, unsupported
|
|
27721
|
-
// methods and auth refusals are user/configuration issues, not evidence
|
|
27722
|
-
// of a broken process. Preserve their session instead of retrying them.
|
|
27723
|
-
acpSessionFailure: value?.code === -32603
|
|
27724
|
-
});
|
|
27725
|
-
}
|
|
27726
27790
|
function classifyAcpError(support12, error51) {
|
|
27727
27791
|
const code = support12.classifyError?.(error51);
|
|
27728
27792
|
if (code) return code;
|
|
@@ -27955,7 +28019,7 @@ function createAcpDriver(support12) {
|
|
|
27955
28019
|
emit({
|
|
27956
28020
|
...base3(threadId, current.turnId),
|
|
27957
28021
|
type: "runtime.error",
|
|
27958
|
-
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`
|
|
27959
28023
|
});
|
|
27960
28024
|
}
|
|
27961
28025
|
emit({ ...base3(threadId, current.turnId), type: "turn.completed", ok: finalOk, stopReason: finalStopReason, cost: null });
|
|
@@ -28376,11 +28440,8 @@ function createAcpDriver(support12) {
|
|
|
28376
28440
|
session.dead = true;
|
|
28377
28441
|
const current = session.current;
|
|
28378
28442
|
if (current) {
|
|
28379
|
-
|
|
28380
|
-
|
|
28381
|
-
type: "runtime.error",
|
|
28382
|
-
message: `${DRIVER_KIND8} exited ${code} before the prompt result${session.stderr ? `: ${session.stderr.trim().slice(-300)}` : ""}`
|
|
28383
|
-
});
|
|
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) });
|
|
28384
28445
|
settle(threadId, session, false, "exit_before_result");
|
|
28385
28446
|
} else if (sessions.get(threadId) === session) {
|
|
28386
28447
|
sessions.delete(threadId);
|
|
@@ -28481,11 +28542,11 @@ function createAcpDriver(support12) {
|
|
|
28481
28542
|
return option;
|
|
28482
28543
|
};
|
|
28483
28544
|
const flushAssistantText = () => {
|
|
28484
|
-
const
|
|
28545
|
+
const text7 = state2.text;
|
|
28485
28546
|
state2.text = "";
|
|
28486
|
-
if (!
|
|
28547
|
+
if (!text7.trim()) return;
|
|
28487
28548
|
state2.producedItem = true;
|
|
28488
|
-
emit({ ...base3(threadId, turnId), type: "item.completed", itemType: "assistant_text", text:
|
|
28549
|
+
emit({ ...base3(threadId, turnId), type: "item.completed", itemType: "assistant_text", text: text7 });
|
|
28489
28550
|
};
|
|
28490
28551
|
const current = {
|
|
28491
28552
|
turnId,
|
|
@@ -28570,9 +28631,10 @@ function createAcpDriver(support12) {
|
|
|
28570
28631
|
if (liveSessionId !== null && session.sessionKey === sessionKey && (cursor3 === null || cursor3 === liveSessionId)) {
|
|
28571
28632
|
break;
|
|
28572
28633
|
}
|
|
28573
|
-
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));
|
|
28574
28635
|
let loaded = false;
|
|
28575
|
-
|
|
28636
|
+
const fresh = support12.freshSessionForLocalModel === true && liveSessionId !== cursor3 && decodeInjectId(turn.model) !== null;
|
|
28637
|
+
if (cursor3 && !fresh) {
|
|
28576
28638
|
try {
|
|
28577
28639
|
await request(
|
|
28578
28640
|
support12.resumeMethod === "resume" ? "session/resume" : "session/load",
|
|
@@ -28716,7 +28778,7 @@ function createAcpDriver(support12) {
|
|
|
28716
28778
|
}
|
|
28717
28779
|
emitSessionStarted();
|
|
28718
28780
|
const instructed = promptWithInstructions(threadId, sessionId, createdNativeSession, promptTurn);
|
|
28719
|
-
const
|
|
28781
|
+
const text7 = support12.buildPromptText ? support12.buildPromptText(instructed) : instructed.system ? `${instructed.system}
|
|
28720
28782
|
|
|
28721
28783
|
${instructed.text}` : instructed.text;
|
|
28722
28784
|
const imageBlocks = support12.images === true && runtimeAcceptsImages ? await readAcpImageBlocks(turn.images ?? []) : [];
|
|
@@ -28739,10 +28801,11 @@ ${instructed.text}` : instructed.text;
|
|
|
28739
28801
|
}
|
|
28740
28802
|
});
|
|
28741
28803
|
state2.promptSent = true;
|
|
28804
|
+
const promptedAt = Date.now();
|
|
28742
28805
|
const promptIdleMs = promptIdleTimeoutMs(support12, cliTurn.model);
|
|
28743
28806
|
const result = await request(
|
|
28744
28807
|
"session/prompt",
|
|
28745
|
-
{ sessionId, prompt: [{ type: "text", text:
|
|
28808
|
+
{ sessionId, prompt: [{ type: "text", text: text7 }, ...imageBlocks] },
|
|
28746
28809
|
void 0,
|
|
28747
28810
|
void 0,
|
|
28748
28811
|
promptIdleMs,
|
|
@@ -28761,8 +28824,10 @@ ${instructed.text}` : instructed.text;
|
|
|
28761
28824
|
});
|
|
28762
28825
|
}
|
|
28763
28826
|
const reason = result?.stopReason;
|
|
28764
|
-
if (reason === "end_turn")
|
|
28765
|
-
|
|
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");
|
|
28766
28831
|
else {
|
|
28767
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"}`;
|
|
28768
28833
|
emit({
|
|
@@ -28781,13 +28846,8 @@ ${instructed.text}` : instructed.text;
|
|
|
28781
28846
|
const stalled = e?.acpPromptStall === true;
|
|
28782
28847
|
const needsAuth = code === "invalid_credentials" || code === "inactive_subscription" || message3 === support12.loginNote || logAuth;
|
|
28783
28848
|
const failure = needsAuth ? "auth_failed" : stalled ? "stalled" : engineFailureFromCode(code) ?? (isOpaqueRequestRejection(message3) ? "request_rejected" : void 0);
|
|
28784
|
-
|
|
28785
|
-
|
|
28786
|
-
type: "runtime.error",
|
|
28787
|
-
message: message3,
|
|
28788
|
-
...needsAuth ? { setup: true } : {},
|
|
28789
|
-
...failure ? { failure } : {}
|
|
28790
|
-
});
|
|
28849
|
+
const setup = needsAuth || !state2.promptSent && !session.closing;
|
|
28850
|
+
emit({ ...base3(threadId, turnId), type: "runtime.error", message: message3, ...failureFields(setup, failure, message3) });
|
|
28791
28851
|
if ((logAuth || !needsAuth && (stalled || isBrokenAntigravityCheckpoint(DRIVER_KIND8, message3) || e?.acpSessionFailure === true || code === "upstream_outage")) && session.child.exitCode === null && !session.closing) {
|
|
28792
28852
|
closeSession(threadId, logAuth ? "provider-auth" : stalled ? "prompt-stall" : "rpc-failure");
|
|
28793
28853
|
}
|
|
@@ -28879,7 +28939,6 @@ var init_core3 = __esm({
|
|
|
28879
28939
|
init_tool_summary();
|
|
28880
28940
|
init_mcp_tool_images();
|
|
28881
28941
|
init_mcp_tool_ref();
|
|
28882
|
-
init_redact2();
|
|
28883
28942
|
init_checkpoint_recovery();
|
|
28884
28943
|
init_resume_recovery();
|
|
28885
28944
|
init_retry();
|
|
@@ -28887,6 +28946,9 @@ var init_core3 = __esm({
|
|
|
28887
28946
|
init_turn_mcp();
|
|
28888
28947
|
init_volatile_notes();
|
|
28889
28948
|
init_tool_log();
|
|
28949
|
+
init_rpc_error();
|
|
28950
|
+
init_mcp_limit();
|
|
28951
|
+
init_setup_failure();
|
|
28890
28952
|
init_mode_readback();
|
|
28891
28953
|
envOr = (key, fallback) => Number(process.env[key] ?? fallback);
|
|
28892
28954
|
INIT_TIMEOUT = envOr("OPENMAUS_ACP_INIT_TIMEOUT_MS", 3e5);
|
|
@@ -29638,25 +29700,25 @@ async function pinnedZipEntries(path4) {
|
|
|
29638
29700
|
try {
|
|
29639
29701
|
const info = await handle.stat();
|
|
29640
29702
|
const tailBytes = Math.min(info.size, MAX_EOCD_BYTES);
|
|
29641
|
-
const
|
|
29703
|
+
const tail3 = Buffer.alloc(tailBytes);
|
|
29642
29704
|
const tailOffset = info.size - tailBytes;
|
|
29643
|
-
if ((await handle.read(
|
|
29705
|
+
if ((await handle.read(tail3, 0, tailBytes, tailOffset)).bytesRead !== tailBytes) {
|
|
29644
29706
|
throw new Error("The verified archive was truncated.");
|
|
29645
29707
|
}
|
|
29646
29708
|
let eocd = -1;
|
|
29647
|
-
for (let cursor4 =
|
|
29648
|
-
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) {
|
|
29649
29711
|
eocd = cursor4;
|
|
29650
29712
|
break;
|
|
29651
29713
|
}
|
|
29652
29714
|
}
|
|
29653
29715
|
if (eocd < 0) throw new Error("The verified archive has no valid ZIP directory.");
|
|
29654
|
-
const disk =
|
|
29655
|
-
const directoryDisk =
|
|
29656
|
-
const diskEntries =
|
|
29657
|
-
const entryCount =
|
|
29658
|
-
const directoryBytes =
|
|
29659
|
-
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);
|
|
29660
29722
|
const eocdOffset = tailOffset + eocd;
|
|
29661
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.");
|
|
29662
29724
|
const directory = Buffer.alloc(directoryBytes);
|
|
@@ -29793,7 +29855,7 @@ async function installOnce2(options) {
|
|
|
29793
29855
|
const handle = await open(archivePath, "wx", 384);
|
|
29794
29856
|
const hash2 = createHash7("sha256");
|
|
29795
29857
|
let downloaded = 0;
|
|
29796
|
-
let
|
|
29858
|
+
let reported2 = 0;
|
|
29797
29859
|
options.onProgress?.({ phase: "downloading", received: 0, total: asset.archiveBytes, detail: `Downloading ${asset.url}` });
|
|
29798
29860
|
try {
|
|
29799
29861
|
for await (const raw of response.body) {
|
|
@@ -29809,8 +29871,8 @@ async function installOnce2(options) {
|
|
|
29809
29871
|
}
|
|
29810
29872
|
hash2.update(chunk);
|
|
29811
29873
|
downloaded += chunk.length;
|
|
29812
|
-
if (downloaded -
|
|
29813
|
-
|
|
29874
|
+
if (downloaded - reported2 >= 4 * 1024 * 1024 || downloaded === asset.archiveBytes) {
|
|
29875
|
+
reported2 = downloaded;
|
|
29814
29876
|
options.onProgress?.({ phase: "downloading", received: downloaded, total: asset.archiveBytes });
|
|
29815
29877
|
}
|
|
29816
29878
|
}
|
|
@@ -30187,14 +30249,14 @@ var init_boxagent = __esm({
|
|
|
30187
30249
|
let pendingText = "";
|
|
30188
30250
|
let problem = null;
|
|
30189
30251
|
const flushAssistantText = () => {
|
|
30190
|
-
const
|
|
30252
|
+
const text7 = pendingText;
|
|
30191
30253
|
pendingText = "";
|
|
30192
|
-
if (!
|
|
30193
|
-
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 });
|
|
30194
30256
|
};
|
|
30195
|
-
const ingest = (
|
|
30196
|
-
const delta =
|
|
30197
|
-
lastText =
|
|
30257
|
+
const ingest = (text7) => {
|
|
30258
|
+
const delta = text7.startsWith(lastText) ? text7.slice(lastText.length) : text7;
|
|
30259
|
+
lastText = text7;
|
|
30198
30260
|
if (!delta) return;
|
|
30199
30261
|
pendingText += delta;
|
|
30200
30262
|
emit({ ...base3(threadId, turnId), type: "content.delta", streamKind: "assistant_text", delta });
|
|
@@ -30212,9 +30274,9 @@ var init_boxagent = __esm({
|
|
|
30212
30274
|
seen.add(id);
|
|
30213
30275
|
appendNative(threadId, { dir: "in", source: "box.events", msg: ev });
|
|
30214
30276
|
const kind = String(ev.type ?? ev.kind ?? "");
|
|
30215
|
-
const
|
|
30216
|
-
if (/assistant|message|output|response/i.test(kind) && typeof
|
|
30217
|
-
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);
|
|
30218
30280
|
} else if (/usage_limit|error|fail/i.test(kind)) {
|
|
30219
30281
|
const why = ev.data?.summary ?? ev.data?.message ?? ev.data?.error ?? ev.message;
|
|
30220
30282
|
if (typeof why === "string" && why.trim()) problem = why.trim();
|
|
@@ -30331,8 +30393,8 @@ function toolName(tool2) {
|
|
|
30331
30393
|
function bareTool(tool2) {
|
|
30332
30394
|
return toolName(tool2).toLowerCase();
|
|
30333
30395
|
}
|
|
30334
|
-
function collapse(
|
|
30335
|
-
return
|
|
30396
|
+
function collapse(text7) {
|
|
30397
|
+
return text7.trim().replace(/\s+/g, " ");
|
|
30336
30398
|
}
|
|
30337
30399
|
function isShellTool(tool2) {
|
|
30338
30400
|
return SHELL_TOOL.test(bareTool(tool2));
|
|
@@ -30891,8 +30953,8 @@ var init_rtk_rewrite = __esm({
|
|
|
30891
30953
|
|
|
30892
30954
|
// server/drivers/claude-stdin.ts
|
|
30893
30955
|
import { readFileSync as readFileSync10 } from "node:fs";
|
|
30894
|
-
function claudeUserMessage(
|
|
30895
|
-
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 } };
|
|
30896
30958
|
const content = images.map((image) => ({
|
|
30897
30959
|
type: "image",
|
|
30898
30960
|
source: {
|
|
@@ -30901,7 +30963,7 @@ function claudeUserMessage(text6, images) {
|
|
|
30901
30963
|
data: readFileSync10(image.path).toString("base64")
|
|
30902
30964
|
}
|
|
30903
30965
|
}));
|
|
30904
|
-
if (
|
|
30966
|
+
if (text7) content.push({ type: "text", text: text7 });
|
|
30905
30967
|
return { type: "user", message: { role: "user", content } };
|
|
30906
30968
|
}
|
|
30907
30969
|
function diagnosticClaudeUserMessage(message3) {
|
|
@@ -30941,9 +31003,9 @@ function isControl(char) {
|
|
|
30941
31003
|
}
|
|
30942
31004
|
function oneLine(value) {
|
|
30943
31005
|
if (typeof value !== "string") return null;
|
|
30944
|
-
const
|
|
30945
|
-
if (!
|
|
30946
|
-
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;
|
|
30947
31009
|
}
|
|
30948
31010
|
function yesValue(field) {
|
|
30949
31011
|
if (field.type === "boolean") return true;
|
|
@@ -31061,7 +31123,7 @@ var init_claude_elicitation = __esm({
|
|
|
31061
31123
|
});
|
|
31062
31124
|
|
|
31063
31125
|
// shared/ask-question.ts
|
|
31064
|
-
function
|
|
31126
|
+
function text6(value, limit) {
|
|
31065
31127
|
if (typeof value !== "string") return void 0;
|
|
31066
31128
|
const trimmed = value.trim();
|
|
31067
31129
|
return trimmed ? trimmed.slice(0, limit) : void 0;
|
|
@@ -31071,18 +31133,18 @@ function isRecord3(value) {
|
|
|
31071
31133
|
}
|
|
31072
31134
|
function parseOption(value) {
|
|
31073
31135
|
if (typeof value === "string") {
|
|
31074
|
-
const label2 =
|
|
31136
|
+
const label2 = text6(value, MAX_LABEL);
|
|
31075
31137
|
return label2 ? { label: label2 } : null;
|
|
31076
31138
|
}
|
|
31077
31139
|
if (!isRecord3(value)) return null;
|
|
31078
|
-
const label =
|
|
31140
|
+
const label = text6(value.label, MAX_LABEL);
|
|
31079
31141
|
if (!label) return null;
|
|
31080
|
-
const description =
|
|
31142
|
+
const description = text6(value.description, MAX_DESCRIPTION);
|
|
31081
31143
|
return description ? { label, description } : { label };
|
|
31082
31144
|
}
|
|
31083
31145
|
function parseQuestion(value) {
|
|
31084
31146
|
if (!isRecord3(value)) return null;
|
|
31085
|
-
const question =
|
|
31147
|
+
const question = text6(value.question, MAX_QUESTION_TEXT);
|
|
31086
31148
|
if (!question) return null;
|
|
31087
31149
|
const options = [];
|
|
31088
31150
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -31093,7 +31155,7 @@ function parseQuestion(value) {
|
|
|
31093
31155
|
options.push(option);
|
|
31094
31156
|
if (options.length === MAX_OPTIONS) break;
|
|
31095
31157
|
}
|
|
31096
|
-
const header =
|
|
31158
|
+
const header = text6(value.header, MAX_LABEL);
|
|
31097
31159
|
return {
|
|
31098
31160
|
question,
|
|
31099
31161
|
...header ? { header } : {},
|
|
@@ -31122,7 +31184,7 @@ function parseChoices(input, limit = MAX_CHOICES) {
|
|
|
31122
31184
|
const choices = [];
|
|
31123
31185
|
const seen = /* @__PURE__ */ new Set();
|
|
31124
31186
|
for (const raw of input) {
|
|
31125
|
-
const label = typeof raw === "string" ?
|
|
31187
|
+
const label = typeof raw === "string" ? text6(raw, MAX_LABEL) : isRecord3(raw) ? text6(raw.label, MAX_LABEL) : void 0;
|
|
31126
31188
|
if (!label || seen.has(label)) continue;
|
|
31127
31189
|
seen.add(label);
|
|
31128
31190
|
choices.push(label);
|
|
@@ -31179,19 +31241,19 @@ function resolveClaudeConfigDir(configDir2, env = process.env) {
|
|
|
31179
31241
|
}
|
|
31180
31242
|
return normalize(expanded);
|
|
31181
31243
|
}
|
|
31182
|
-
function claudeAuthFailure(frame,
|
|
31244
|
+
function claudeAuthFailure(frame, text7) {
|
|
31183
31245
|
if (frame.is_api_error_message !== true && typeof frame.error !== "string") return false;
|
|
31184
|
-
return !isModelAccessRefused(
|
|
31246
|
+
return !isModelAccessRefused(text7) && (frame.error === "authentication_failed" || classifyError({ text: text7 }).reason === "auth_failed");
|
|
31185
31247
|
}
|
|
31186
|
-
function claudeCredentialRefreshConflict(frame,
|
|
31248
|
+
function claudeCredentialRefreshConflict(frame, text7) {
|
|
31187
31249
|
if (frame.is_api_error_message !== true && typeof frame.error !== "string") return false;
|
|
31188
|
-
return CREDENTIAL_REFRESH_CONFLICT.test(
|
|
31250
|
+
return CREDENTIAL_REFRESH_CONFLICT.test(text7);
|
|
31189
31251
|
}
|
|
31190
31252
|
function claudeResultStopReason(o) {
|
|
31191
|
-
const
|
|
31192
|
-
if (o.is_error !== true) return
|
|
31193
|
-
const subtype =
|
|
31194
|
-
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";
|
|
31195
31257
|
}
|
|
31196
31258
|
function claudeEnvironment(model, source2 = process.env, configDir2, instanceEnvironment = {}) {
|
|
31197
31259
|
const env = { ...source2, PATH: augmentedPath(), NPM_CONFIG_LOGLEVEL: "error" };
|
|
@@ -32366,24 +32428,24 @@ var init_claude = __esm({
|
|
|
32366
32428
|
level: typeof msg.model === "string" ? "response-reported" : "unknown"
|
|
32367
32429
|
});
|
|
32368
32430
|
}
|
|
32369
|
-
const
|
|
32370
|
-
if (claudeAuthFailure(o,
|
|
32431
|
+
const text7 = firstText(msg.content);
|
|
32432
|
+
if (claudeAuthFailure(o, text7)) {
|
|
32371
32433
|
if (session.turn) session.turn.authFailed = true;
|
|
32372
|
-
emit({ ...base3(threadId, currentTurnId()), type: "runtime.error", message:
|
|
32434
|
+
emit({ ...base3(threadId, currentTurnId()), type: "runtime.error", message: text7, setup: true, failure: "auth_failed" });
|
|
32373
32435
|
break;
|
|
32374
32436
|
}
|
|
32375
|
-
if (claudeCredentialRefreshConflict(o,
|
|
32376
|
-
if (session.turn) session.turn.refreshConflict =
|
|
32437
|
+
if (claudeCredentialRefreshConflict(o, text7)) {
|
|
32438
|
+
if (session.turn) session.turn.refreshConflict = text7.trim();
|
|
32377
32439
|
break;
|
|
32378
32440
|
}
|
|
32379
|
-
if (
|
|
32380
|
-
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()) {
|
|
32381
32443
|
const synthetic = o.is_api_error_message === true || typeof o.error === "string" ? { synthetic: true } : {};
|
|
32382
32444
|
if (!session.turn?.sawStreamDelta) {
|
|
32383
|
-
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 });
|
|
32384
32446
|
}
|
|
32385
32447
|
if (session.turn) session.turn.sawStreamDelta = false;
|
|
32386
|
-
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 });
|
|
32387
32449
|
}
|
|
32388
32450
|
for (const b3 of Array.isArray(msg.content) ? msg.content : []) {
|
|
32389
32451
|
if (b3.type === "tool_use") {
|
|
@@ -32634,12 +32696,12 @@ var init_claude = __esm({
|
|
|
32634
32696
|
}
|
|
32635
32697
|
return { turnId };
|
|
32636
32698
|
};
|
|
32637
|
-
const steer = async (threadId,
|
|
32699
|
+
const steer = async (threadId, text7) => {
|
|
32638
32700
|
const s4 = sessions.get(threadId);
|
|
32639
32701
|
if (!s4 || !s4.turn || s4.turn.settled || s4.closing || s4.child.exitCode !== null) return "refused";
|
|
32640
32702
|
const turn = s4.turn;
|
|
32641
32703
|
turn.pendingSteers = (turn.pendingSteers ?? 0) + 1;
|
|
32642
|
-
if (await writeUser(s4, threadId, claudeUserMessage(
|
|
32704
|
+
if (await writeUser(s4, threadId, claudeUserMessage(text7, void 0))) return "steered";
|
|
32643
32705
|
turn.pendingSteers = Math.max(0, turn.pendingSteers - 1);
|
|
32644
32706
|
return "refused";
|
|
32645
32707
|
};
|
|
@@ -32874,42 +32936,42 @@ var init_codex_tool_surface = __esm({
|
|
|
32874
32936
|
});
|
|
32875
32937
|
|
|
32876
32938
|
// server/toml-lite.ts
|
|
32877
|
-
function parseTomlLite(
|
|
32939
|
+
function parseTomlLite(text7) {
|
|
32878
32940
|
const root = {};
|
|
32879
32941
|
let current = root;
|
|
32880
32942
|
let pos = 0;
|
|
32881
|
-
const peek = () =>
|
|
32943
|
+
const peek = () => text7[pos];
|
|
32882
32944
|
const skipSpaces = () => {
|
|
32883
|
-
while (pos <
|
|
32945
|
+
while (pos < text7.length && (text7[pos] === " " || text7[pos] === " ")) pos += 1;
|
|
32884
32946
|
};
|
|
32885
32947
|
const skipComment = () => {
|
|
32886
|
-
if (
|
|
32948
|
+
if (text7[pos] === "#") while (pos < text7.length && text7[pos] !== "\n") pos += 1;
|
|
32887
32949
|
};
|
|
32888
32950
|
const skipBlank = () => {
|
|
32889
32951
|
for (; ; ) {
|
|
32890
32952
|
const before = pos;
|
|
32891
|
-
while (pos <
|
|
32953
|
+
while (pos < text7.length && /[ \t\r\n]/.test(text7[pos])) pos += 1;
|
|
32892
32954
|
skipComment();
|
|
32893
32955
|
if (pos === before) return;
|
|
32894
32956
|
}
|
|
32895
32957
|
};
|
|
32896
32958
|
const skipLine = () => {
|
|
32897
|
-
while (pos <
|
|
32959
|
+
while (pos < text7.length && text7[pos] !== "\n") pos += 1;
|
|
32898
32960
|
};
|
|
32899
32961
|
const basicString = () => {
|
|
32900
|
-
const multi =
|
|
32962
|
+
const multi = text7.startsWith('"""', pos);
|
|
32901
32963
|
pos += multi ? 3 : 1;
|
|
32902
|
-
if (multi &&
|
|
32964
|
+
if (multi && text7[pos] === "\n") pos += 1;
|
|
32903
32965
|
let out = "";
|
|
32904
|
-
while (pos <
|
|
32905
|
-
if (multi ?
|
|
32966
|
+
while (pos < text7.length) {
|
|
32967
|
+
if (multi ? text7.startsWith('"""', pos) : text7[pos] === '"') {
|
|
32906
32968
|
pos += multi ? 3 : 1;
|
|
32907
32969
|
return out;
|
|
32908
32970
|
}
|
|
32909
|
-
const ch =
|
|
32971
|
+
const ch = text7[pos];
|
|
32910
32972
|
if (!multi && ch === "\n") throw new TomlError("unterminated string");
|
|
32911
32973
|
if (ch === "\\") {
|
|
32912
|
-
const next =
|
|
32974
|
+
const next = text7[pos + 1];
|
|
32913
32975
|
pos += 2;
|
|
32914
32976
|
if (next === "n") out += "\n";
|
|
32915
32977
|
else if (next === "t") out += " ";
|
|
@@ -32917,10 +32979,10 @@ function parseTomlLite(text6) {
|
|
|
32917
32979
|
else if (next === '"' || next === "\\") out += next;
|
|
32918
32980
|
else if (next === "u" || next === "U") {
|
|
32919
32981
|
const length = next === "u" ? 4 : 8;
|
|
32920
|
-
out += String.fromCodePoint(parseInt(
|
|
32982
|
+
out += String.fromCodePoint(parseInt(text7.slice(pos, pos + length), 16));
|
|
32921
32983
|
pos += length;
|
|
32922
32984
|
} else if (multi && next === "\n") {
|
|
32923
|
-
while (pos <
|
|
32985
|
+
while (pos < text7.length && /[ \t\r\n]/.test(text7[pos])) pos += 1;
|
|
32924
32986
|
} else out += next ?? "";
|
|
32925
32987
|
continue;
|
|
32926
32988
|
}
|
|
@@ -32930,12 +32992,12 @@ function parseTomlLite(text6) {
|
|
|
32930
32992
|
throw new TomlError("unterminated string");
|
|
32931
32993
|
};
|
|
32932
32994
|
const literalString = () => {
|
|
32933
|
-
const multi =
|
|
32995
|
+
const multi = text7.startsWith("'''", pos);
|
|
32934
32996
|
pos += multi ? 3 : 1;
|
|
32935
|
-
if (multi &&
|
|
32936
|
-
const end =
|
|
32997
|
+
if (multi && text7[pos] === "\n") pos += 1;
|
|
32998
|
+
const end = text7.indexOf(multi ? "'''" : "'", pos);
|
|
32937
32999
|
if (end < 0) throw new TomlError("unterminated string");
|
|
32938
|
-
const value2 =
|
|
33000
|
+
const value2 = text7.slice(pos, end);
|
|
32939
33001
|
if (!multi && value2.includes("\n")) throw new TomlError("unterminated string");
|
|
32940
33002
|
pos = end + (multi ? 3 : 1);
|
|
32941
33003
|
return value2;
|
|
@@ -32945,9 +33007,9 @@ function parseTomlLite(text6) {
|
|
|
32945
33007
|
if (peek() === '"') return basicString();
|
|
32946
33008
|
if (peek() === "'") return literalString();
|
|
32947
33009
|
const start = pos;
|
|
32948
|
-
while (pos <
|
|
33010
|
+
while (pos < text7.length && /[A-Za-z0-9_-]/.test(text7[pos])) pos += 1;
|
|
32949
33011
|
if (pos === start) throw new TomlError("expected a key");
|
|
32950
|
-
return
|
|
33012
|
+
return text7.slice(start, pos);
|
|
32951
33013
|
};
|
|
32952
33014
|
const keyPath = () => {
|
|
32953
33015
|
const parts = [key()];
|
|
@@ -32999,8 +33061,8 @@ function parseTomlLite(text6) {
|
|
|
32999
33061
|
}
|
|
33000
33062
|
}
|
|
33001
33063
|
const start = pos;
|
|
33002
|
-
while (pos <
|
|
33003
|
-
const raw =
|
|
33064
|
+
while (pos < text7.length && !/[,\]}\r\n#]/.test(text7[pos])) pos += 1;
|
|
33065
|
+
const raw = text7.slice(start, pos).trim();
|
|
33004
33066
|
if (raw === "true") return true;
|
|
33005
33067
|
if (raw === "false") return false;
|
|
33006
33068
|
const number5 = Number(raw.replace(/_/g, ""));
|
|
@@ -33025,12 +33087,12 @@ function parseTomlLite(text6) {
|
|
|
33025
33087
|
const parent = tableAt(base3, path4.slice(0, -1));
|
|
33026
33088
|
parent[path4[path4.length - 1]] = item;
|
|
33027
33089
|
}
|
|
33028
|
-
while (pos <
|
|
33090
|
+
while (pos < text7.length) {
|
|
33029
33091
|
skipBlank();
|
|
33030
|
-
if (pos >=
|
|
33092
|
+
if (pos >= text7.length) break;
|
|
33031
33093
|
const lineStart = pos;
|
|
33032
33094
|
try {
|
|
33033
|
-
if (
|
|
33095
|
+
if (text7.startsWith("[[", pos)) {
|
|
33034
33096
|
pos += 2;
|
|
33035
33097
|
keyPath();
|
|
33036
33098
|
current = {};
|
|
@@ -33636,7 +33698,7 @@ function unquote(raw) {
|
|
|
33636
33698
|
}
|
|
33637
33699
|
return value;
|
|
33638
33700
|
}
|
|
33639
|
-
function parseCodexToml(
|
|
33701
|
+
function parseCodexToml(text7) {
|
|
33640
33702
|
const result = { providers: [] };
|
|
33641
33703
|
const byId = /* @__PURE__ */ new Map();
|
|
33642
33704
|
let section = "root";
|
|
@@ -33649,7 +33711,7 @@ function parseCodexToml(text6) {
|
|
|
33649
33711
|
}
|
|
33650
33712
|
return provider;
|
|
33651
33713
|
};
|
|
33652
|
-
for (const line of
|
|
33714
|
+
for (const line of text7.split(/\r?\n/)) {
|
|
33653
33715
|
const stripped = line.trim();
|
|
33654
33716
|
if (!stripped || stripped.startsWith("#")) continue;
|
|
33655
33717
|
if (stripped.startsWith("[") && stripped.endsWith("]")) {
|
|
@@ -34327,8 +34389,8 @@ function codexRetryHttpStatus(info) {
|
|
|
34327
34389
|
function withCodexReset(message3, info) {
|
|
34328
34390
|
const hint = parseResetAt(message3) === void 0 ? resetHintFromData(info) : void 0;
|
|
34329
34391
|
if (!hint) return message3.slice(0, 400);
|
|
34330
|
-
const
|
|
34331
|
-
return `${message3.slice(0, 400 -
|
|
34392
|
+
const tail3 = ` (${hint})`;
|
|
34393
|
+
return `${message3.slice(0, 400 - tail3.length)}${tail3}`;
|
|
34332
34394
|
}
|
|
34333
34395
|
function missingNativeCodexThread(error51, cursor3) {
|
|
34334
34396
|
return error51 instanceof CodexRpcError && error51.code === -32600 && error51.message === `no rollout found for thread id ${cursor3}`;
|
|
@@ -34910,14 +34972,14 @@ var init_codex = __esm({
|
|
|
34910
34972
|
emit({ ...base3(threadId, turnId), type: "runtime.error", message: "codex did not shut down after termination was requested" });
|
|
34911
34973
|
}
|
|
34912
34974
|
};
|
|
34913
|
-
const steerActiveTurn = async (
|
|
34975
|
+
const steerActiveTurn = async (text7) => {
|
|
34914
34976
|
if (state2.settled || abandoned || stopRequested || !codexThreadId || !codexTurnId) return "refused";
|
|
34915
34977
|
if (child.exitCode !== null || child.signalCode !== null) return "refused";
|
|
34916
34978
|
try {
|
|
34917
34979
|
const steerTimeoutMs = Math.max(1, Number(process.env.FAKE_CODEX_STEER_TIMEOUT_MS ?? 1e4) || 1e4);
|
|
34918
34980
|
await request("turn/steer", {
|
|
34919
34981
|
threadId: codexThreadId,
|
|
34920
|
-
input: [{ type: "text", text:
|
|
34982
|
+
input: [{ type: "text", text: text7 }],
|
|
34921
34983
|
expectedTurnId: codexTurnId
|
|
34922
34984
|
}, steerTimeoutMs);
|
|
34923
34985
|
return "steered";
|
|
@@ -35524,9 +35586,9 @@ ${status.stderr}`)) {
|
|
|
35524
35586
|
interruptTurn: async (threadId) => {
|
|
35525
35587
|
await active.get(threadId)?.stop();
|
|
35526
35588
|
},
|
|
35527
|
-
steer: async (threadId,
|
|
35589
|
+
steer: async (threadId, text7) => {
|
|
35528
35590
|
const turn = active.get(threadId);
|
|
35529
|
-
return turn?.steer ? await turn.steer(
|
|
35591
|
+
return turn?.steer ? await turn.steer(text7) : "refused";
|
|
35530
35592
|
},
|
|
35531
35593
|
respondToRequest: async (threadId, requestId, decision) => {
|
|
35532
35594
|
const turn = active.get(threadId);
|
|
@@ -38713,8 +38775,8 @@ var require_utils = __commonJS({
|
|
|
38713
38775
|
}
|
|
38714
38776
|
if (bestLength < 2) return hextets.join(":");
|
|
38715
38777
|
const head = hextets.slice(0, bestStart).join(":");
|
|
38716
|
-
const
|
|
38717
|
-
return head + "::" +
|
|
38778
|
+
const tail3 = hextets.slice(bestStart + bestLength).join(":");
|
|
38779
|
+
return head + "::" + tail3;
|
|
38718
38780
|
}
|
|
38719
38781
|
function normalizeIPv6Address(input) {
|
|
38720
38782
|
const compression = input.indexOf("::");
|
|
@@ -40147,7 +40209,7 @@ var require_core = __commonJS({
|
|
|
40147
40209
|
errorsText(errors = this.errors, { separator = ", ", dataVar = "data" } = {}) {
|
|
40148
40210
|
if (!errors || errors.length === 0)
|
|
40149
40211
|
return "No errors";
|
|
40150
|
-
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);
|
|
40151
40213
|
}
|
|
40152
40214
|
$dataMetaSchema(metaSchema, keywordsJsonPointers) {
|
|
40153
40215
|
const rules = this.RULES.all;
|
|
@@ -44671,7 +44733,7 @@ function boundedText(value) {
|
|
|
44671
44733
|
[MCP result truncated at 50KB; request less output.]`;
|
|
44672
44734
|
}
|
|
44673
44735
|
function namesBlockedPath(args, roots, home = homedir17()) {
|
|
44674
|
-
const slash = (
|
|
44736
|
+
const slash = (text7) => text7.replaceAll("\\", "/").toLowerCase();
|
|
44675
44737
|
const needles = roots.flatMap((root) => {
|
|
44676
44738
|
const full = slash(root).replace(/\/+$/, "");
|
|
44677
44739
|
const base3 = slash(home).replace(/\/+$/, "");
|
|
@@ -45103,6 +45165,17 @@ var init_chat_tool_approval = __esm({
|
|
|
45103
45165
|
function object3(value) {
|
|
45104
45166
|
return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
45105
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
|
+
}
|
|
45106
45179
|
var MAX_CHAT_TOOL_CALLS, MAX_ARGUMENT_CHARS, ChatProtocolError, ChatReasoningDetails, ChatToolCalls;
|
|
45107
45180
|
var init_openai_chat_protocol = __esm({
|
|
45108
45181
|
"server/drivers/openai-chat-protocol.ts"() {
|
|
@@ -45182,18 +45255,49 @@ var init_openai_chat_protocol = __esm({
|
|
|
45182
45255
|
}
|
|
45183
45256
|
});
|
|
45184
45257
|
|
|
45185
|
-
// server/drivers/
|
|
45186
|
-
function
|
|
45187
|
-
|
|
45188
|
-
|
|
45189
|
-
|
|
45190
|
-
|
|
45191
|
-
|
|
45192
|
-
|
|
45193
|
-
|
|
45194
|
-
|
|
45195
|
-
|
|
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
|
+
});
|
|
45196
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
|
|
45197
45301
|
function createOpenAIChatRuntime(options) {
|
|
45198
45302
|
const { input } = options;
|
|
45199
45303
|
const listeners = /* @__PURE__ */ new Set();
|
|
@@ -45220,18 +45324,20 @@ function createOpenAIChatRuntime(options) {
|
|
|
45220
45324
|
resetIdleTimer();
|
|
45221
45325
|
try {
|
|
45222
45326
|
const activeSignal = signal ? AbortSignal.any([signal, timeoutController.signal]) : timeoutController.signal;
|
|
45327
|
+
const sendable = sendableMessages(options.apiUrl, model, messages);
|
|
45223
45328
|
const response = await fetch(`${options.apiUrl}/chat/completions`, {
|
|
45224
45329
|
method: "POST",
|
|
45225
|
-
...
|
|
45330
|
+
...hasImageParts(sendable) ? { redirect: "error" } : {},
|
|
45226
45331
|
headers: { ...options.extraHeaders, authorization: `Bearer ${options.apiKey}`, "content-type": "application/json" },
|
|
45227
45332
|
body: JSON.stringify({
|
|
45228
|
-
...options.requestBody(model,
|
|
45333
|
+
...options.requestBody(model, sendable, stream),
|
|
45229
45334
|
...tools.length ? { tools } : {}
|
|
45230
45335
|
}),
|
|
45231
45336
|
signal: activeSignal
|
|
45232
45337
|
});
|
|
45233
45338
|
if (!response.ok) {
|
|
45234
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);
|
|
45235
45341
|
throw new Error(`${options.httpErrorLabel} HTTP ${response.status}${body ? `: ${body.slice(0, 200)}` : ""}`);
|
|
45236
45342
|
}
|
|
45237
45343
|
if (!stream || response.headers.get("content-type")?.includes("application/json")) {
|
|
@@ -45264,7 +45370,7 @@ function createOpenAIChatRuntime(options) {
|
|
|
45264
45370
|
if (!response.body) {
|
|
45265
45371
|
throw new Error(options.noBodyError ?? `${options.httpErrorLabel} returned no response body`);
|
|
45266
45372
|
}
|
|
45267
|
-
let
|
|
45373
|
+
let text7 = "";
|
|
45268
45374
|
let reasoning = "";
|
|
45269
45375
|
let protocolReasoning = "";
|
|
45270
45376
|
let usage = null;
|
|
@@ -45306,7 +45412,7 @@ function createOpenAIChatRuntime(options) {
|
|
|
45306
45412
|
onDelta?.(reasoningDelta, "reasoning_text");
|
|
45307
45413
|
}
|
|
45308
45414
|
if (contentDelta) {
|
|
45309
|
-
|
|
45415
|
+
text7 += contentDelta;
|
|
45310
45416
|
onDelta?.(contentDelta, "assistant_text");
|
|
45311
45417
|
}
|
|
45312
45418
|
if (chunk.usage) usage = usageFrom(chunk.usage);
|
|
@@ -45348,7 +45454,7 @@ function createOpenAIChatRuntime(options) {
|
|
|
45348
45454
|
}
|
|
45349
45455
|
activeSignal.throwIfAborted();
|
|
45350
45456
|
if (!sawChoice) throw new ChatProtocolError("provider returned no streaming completion choice");
|
|
45351
|
-
return { text:
|
|
45457
|
+
return { text: text7, reasoning, usage, toolCalls: calls.finish(finishReason, malformedFrame), finishReason, protocolReasoning, protocolReasoningDetails: details.blocks };
|
|
45352
45458
|
} finally {
|
|
45353
45459
|
if (idleTimer) clearTimeout(idleTimer);
|
|
45354
45460
|
}
|
|
@@ -45381,8 +45487,8 @@ function createOpenAIChatRuntime(options) {
|
|
|
45381
45487
|
}
|
|
45382
45488
|
}
|
|
45383
45489
|
}
|
|
45384
|
-
const safeText = (
|
|
45385
|
-
let safe =
|
|
45490
|
+
const safeText = (text7) => {
|
|
45491
|
+
let safe = text7;
|
|
45386
45492
|
for (const secret of secrets) if (secret) safe = safe.split(secret).join("[redacted]");
|
|
45387
45493
|
return redactSecretsInText(safe);
|
|
45388
45494
|
};
|
|
@@ -45439,8 +45545,8 @@ function createOpenAIChatRuntime(options) {
|
|
|
45439
45545
|
for (; ; ) {
|
|
45440
45546
|
let streamed = false;
|
|
45441
45547
|
const pending = { assistant_text: "", reasoning_text: "" };
|
|
45442
|
-
const delta = (
|
|
45443
|
-
let combined = pending[streamKind] +
|
|
45548
|
+
const delta = (text7, streamKind, flush = false) => {
|
|
45549
|
+
let combined = pending[streamKind] + text7;
|
|
45444
45550
|
for (const secret of secrets) if (secret) combined = combined.split(secret).join("[redacted]");
|
|
45445
45551
|
let hold = 0;
|
|
45446
45552
|
if (!flush) for (const secret of secrets) {
|
|
@@ -45459,9 +45565,9 @@ function createOpenAIChatRuntime(options) {
|
|
|
45459
45565
|
const callId = newId();
|
|
45460
45566
|
emit({ ...base3(turn.threadId, turnId), type: "model.call", callId });
|
|
45461
45567
|
let previousIdentity = "";
|
|
45462
|
-
completion = await complete(messages, model, true, abort.signal, (
|
|
45568
|
+
completion = await complete(messages, model, true, abort.signal, (text7, streamKind) => {
|
|
45463
45569
|
streamed = true;
|
|
45464
|
-
delta(
|
|
45570
|
+
delta(text7, streamKind);
|
|
45465
45571
|
}, tools.definitions, (reportedModel, responseId) => {
|
|
45466
45572
|
const identity2 = JSON.stringify([reportedModel, responseId]);
|
|
45467
45573
|
if (identity2 === previousIdentity) return;
|
|
@@ -45562,11 +45668,11 @@ function createOpenAIChatRuntime(options) {
|
|
|
45562
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) };
|
|
45563
45669
|
}
|
|
45564
45670
|
if (!started) emit({ ...base3(turn.threadId, turnId), type: "item.started", itemType: "tool", itemId: call.id, title: call.function.name });
|
|
45565
|
-
const
|
|
45566
|
-
const output = preview({ ok: result.ok, result:
|
|
45671
|
+
const text7 = safeText(result.text);
|
|
45672
|
+
const output = preview({ ok: result.ok, result: text7 });
|
|
45567
45673
|
emit({ ...base3(turn.threadId, turnId), type: "item.completed", itemType: "tool", itemId: call.id, ok: result.ok, output });
|
|
45568
45674
|
if (!result.ok) toolFailed = true;
|
|
45569
|
-
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 }) });
|
|
45570
45676
|
screenshotParts.push(...chatToolImages(call.id, result.images));
|
|
45571
45677
|
abort.signal.throwIfAborted();
|
|
45572
45678
|
if (fatal) throw fatal;
|
|
@@ -45658,9 +45764,9 @@ function createOpenAIChatRuntime(options) {
|
|
|
45658
45764
|
},
|
|
45659
45765
|
generateText: async (prompt, { signal } = {}) => {
|
|
45660
45766
|
const model = options.generateModel?.() ?? options.models().default;
|
|
45661
|
-
const { text:
|
|
45767
|
+
const { text: text7, reasoning, toolCalls } = await complete([{ role: "user", content: prompt }], model, false, signal);
|
|
45662
45768
|
if (toolCalls.length) throw new ChatProtocolError("provider returned tool calls to a text-only helper");
|
|
45663
|
-
return
|
|
45769
|
+
return text7.trim() ? text7 : reasoning;
|
|
45664
45770
|
},
|
|
45665
45771
|
dispose: async () => {
|
|
45666
45772
|
const turns = [...active.values()];
|
|
@@ -45682,6 +45788,7 @@ var init_openai_chat = __esm({
|
|
|
45682
45788
|
init_chat_images();
|
|
45683
45789
|
init_chat_tool_approval();
|
|
45684
45790
|
init_openai_chat_protocol();
|
|
45791
|
+
init_chat_text_only();
|
|
45685
45792
|
init_native();
|
|
45686
45793
|
init_retry();
|
|
45687
45794
|
usageFrom = (usage) => usage ? { input: usage.prompt_tokens ?? 0, output: usage.completion_tokens ?? 0 } : null;
|
|
@@ -45741,7 +45848,7 @@ var init_grok = __esm({
|
|
|
45741
45848
|
nativeLog: {
|
|
45742
45849
|
source: "xai.chat.completions",
|
|
45743
45850
|
outgoing: (_turn, messages, model) => ({ model, messages }),
|
|
45744
|
-
incoming: ({ text:
|
|
45851
|
+
incoming: ({ text: text7, usage }) => ({ text: text7, usage })
|
|
45745
45852
|
}
|
|
45746
45853
|
});
|
|
45747
45854
|
}
|
|
@@ -45753,12 +45860,12 @@ var init_grok = __esm({
|
|
|
45753
45860
|
import { existsSync as existsSync17, readFileSync as readFileSync20, writeFileSync as writeFileSync13 } from "node:fs";
|
|
45754
45861
|
import { homedir as homedir18 } from "node:os";
|
|
45755
45862
|
import { join as join39 } from "node:path";
|
|
45756
|
-
function decodeGrokModelText(
|
|
45757
|
-
if (/\bnot authenticated\b/i.test(
|
|
45863
|
+
function decodeGrokModelText(text7) {
|
|
45864
|
+
if (/\bnot authenticated\b/i.test(text7)) return null;
|
|
45758
45865
|
const options = [];
|
|
45759
45866
|
let listed = null;
|
|
45760
45867
|
let stated = null;
|
|
45761
|
-
for (const raw of
|
|
45868
|
+
for (const raw of text7.split(/\r?\n/)) {
|
|
45762
45869
|
const line = raw.trim();
|
|
45763
45870
|
const header = /^default model:\s*(\S+)/i.exec(line);
|
|
45764
45871
|
if (header) {
|
|
@@ -45797,9 +45904,9 @@ function unquote2(raw) {
|
|
|
45797
45904
|
}
|
|
45798
45905
|
function readGrokModelCatalog(env = process.env, base3 = STATIC_GROK_MODELS) {
|
|
45799
45906
|
const path4 = join39(grokHome(env), "config.toml");
|
|
45800
|
-
let
|
|
45907
|
+
let text7 = "";
|
|
45801
45908
|
try {
|
|
45802
|
-
|
|
45909
|
+
text7 = readFileSync20(path4, "utf8");
|
|
45803
45910
|
} catch {
|
|
45804
45911
|
return base3;
|
|
45805
45912
|
}
|
|
@@ -45817,7 +45924,7 @@ function readGrokModelCatalog(env = process.env, base3 = STATIC_GROK_MODELS) {
|
|
|
45817
45924
|
options.push({ id: current.slug, label: current.name || current.slug, custom: true });
|
|
45818
45925
|
current = null;
|
|
45819
45926
|
};
|
|
45820
|
-
for (const line of
|
|
45927
|
+
for (const line of text7.split(/\r?\n/)) {
|
|
45821
45928
|
const stripped = line.trim();
|
|
45822
45929
|
if (stripped === "[models]") {
|
|
45823
45930
|
flush();
|
|
@@ -45853,8 +45960,8 @@ function readGrokModelCatalog(env = process.env, base3 = STATIC_GROK_MODELS) {
|
|
|
45853
45960
|
function classifyGrokError(error51) {
|
|
45854
45961
|
const message3 = error51 instanceof Error ? error51.message : String(error51 ?? "");
|
|
45855
45962
|
const data = error51 && typeof error51 === "object" ? error51.data : void 0;
|
|
45856
|
-
const
|
|
45857
|
-
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;
|
|
45858
45965
|
}
|
|
45859
45966
|
function suggestGrokSlug(host, model, taken) {
|
|
45860
45967
|
let base3 = `${host}-${model}`.toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
@@ -45876,11 +45983,11 @@ function ensureGrokInjectSlug(modelId, env = process.env) {
|
|
|
45876
45983
|
const host = localHost(inject.host);
|
|
45877
45984
|
if (!host) return modelId;
|
|
45878
45985
|
const path4 = join39(grokHome(env), "config.toml");
|
|
45879
|
-
let
|
|
45986
|
+
let text7 = "";
|
|
45880
45987
|
try {
|
|
45881
|
-
|
|
45988
|
+
text7 = readFileSync20(path4, "utf8");
|
|
45882
45989
|
} catch {
|
|
45883
|
-
|
|
45990
|
+
text7 = "";
|
|
45884
45991
|
}
|
|
45885
45992
|
const taken = new Set(STATIC_GROK_MODELS.options.map((option) => option.id));
|
|
45886
45993
|
let current = null;
|
|
@@ -45893,7 +46000,7 @@ function ensureGrokInjectSlug(modelId, env = process.env) {
|
|
|
45893
46000
|
current = null;
|
|
45894
46001
|
};
|
|
45895
46002
|
let found = null;
|
|
45896
|
-
for (const line of
|
|
46003
|
+
for (const line of text7.split(/\r?\n/)) {
|
|
45897
46004
|
const stripped = line.trim();
|
|
45898
46005
|
if (stripped.startsWith("[model.") && stripped.endsWith("]")) {
|
|
45899
46006
|
flush();
|
|
@@ -45926,9 +46033,9 @@ function ensureGrokInjectSlug(modelId, env = process.env) {
|
|
|
45926
46033
|
`api_key = ${quoteToml(hostApiKey(host, env))}`,
|
|
45927
46034
|
""
|
|
45928
46035
|
].join("\n");
|
|
45929
|
-
const next =
|
|
46036
|
+
const next = text7 && !text7.endsWith("\n") ? `${text7}
|
|
45930
46037
|
|
|
45931
|
-
${block2}` : `${
|
|
46038
|
+
${block2}` : `${text7}${text7 ? "\n" : ""}${block2}`;
|
|
45932
46039
|
writeFileSync13(path4, next);
|
|
45933
46040
|
return slug;
|
|
45934
46041
|
}
|
|
@@ -46115,18 +46222,69 @@ ${turn.text}` : turn.text
|
|
|
46115
46222
|
}
|
|
46116
46223
|
});
|
|
46117
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
|
+
|
|
46118
46276
|
// server/drivers/acp/kimi.ts
|
|
46119
|
-
import { existsSync as
|
|
46277
|
+
import { existsSync as existsSync20, mkdirSync as mkdirSync18, readFileSync as readFileSync22, writeFileSync as writeFileSync14 } from "node:fs";
|
|
46120
46278
|
import { homedir as homedir20 } from "node:os";
|
|
46121
|
-
import { join as
|
|
46279
|
+
import { join as join42 } from "node:path";
|
|
46122
46280
|
function isLocalInjectAlias(slug) {
|
|
46123
46281
|
return LOCAL_PROVIDER_PREFIXES.some((prefix) => slug.startsWith(prefix));
|
|
46124
46282
|
}
|
|
46125
46283
|
function kimiDataRoot(env) {
|
|
46126
|
-
return env.KIMI_CODE_HOME ||
|
|
46284
|
+
return env.KIMI_CODE_HOME || join42(env.HOME || env.USERPROFILE || homedir20(), ".kimi-code");
|
|
46127
46285
|
}
|
|
46128
46286
|
function credentialsPath(env) {
|
|
46129
|
-
return
|
|
46287
|
+
return join42(kimiDataRoot(env), "credentials", "kimi-code.json");
|
|
46130
46288
|
}
|
|
46131
46289
|
function quoteToml2(value) {
|
|
46132
46290
|
return `"${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
@@ -46152,18 +46310,18 @@ function stripTomlLineComment(line) {
|
|
|
46152
46310
|
}
|
|
46153
46311
|
return line;
|
|
46154
46312
|
}
|
|
46155
|
-
function takeTomlBasicEscape(
|
|
46156
|
-
const code =
|
|
46313
|
+
function takeTomlBasicEscape(text7, i2) {
|
|
46314
|
+
const code = text7[i2 + 1];
|
|
46157
46315
|
if (code === void 0) return { ok: false };
|
|
46158
46316
|
if (code === "u") {
|
|
46159
|
-
const hex3 =
|
|
46317
|
+
const hex3 = text7.slice(i2 + 2, i2 + 6);
|
|
46160
46318
|
if (!/^[0-9a-fA-F]{4}$/.test(hex3)) return { ok: false };
|
|
46161
46319
|
const point = parseInt(hex3, 16);
|
|
46162
46320
|
if (point >= 55296 && point <= 57343) return { ok: false };
|
|
46163
46321
|
return { ok: true, value: String.fromCharCode(point), next: i2 + 6 };
|
|
46164
46322
|
}
|
|
46165
46323
|
if (code === "U") {
|
|
46166
|
-
const hex3 =
|
|
46324
|
+
const hex3 = text7.slice(i2 + 2, i2 + 10);
|
|
46167
46325
|
if (!/^[0-9a-fA-F]{8}$/.test(hex3)) return { ok: false };
|
|
46168
46326
|
const point = parseInt(hex3, 16);
|
|
46169
46327
|
if (point > 1114111 || point >= 55296 && point <= 57343) return { ok: false };
|
|
@@ -46235,14 +46393,14 @@ function tomlRowKey(row) {
|
|
|
46235
46393
|
const eq = row.indexOf("=");
|
|
46236
46394
|
return unquoteTomlKey(eq < 0 ? row : row.slice(0, eq));
|
|
46237
46395
|
}
|
|
46238
|
-
function tomlTables(
|
|
46396
|
+
function tomlTables(text7) {
|
|
46239
46397
|
const headings = [];
|
|
46240
46398
|
let mode = "out";
|
|
46241
46399
|
let i2 = 0;
|
|
46242
|
-
const atLineStart = (idx) => idx === 0 ||
|
|
46243
|
-
while (i2 <
|
|
46400
|
+
const atLineStart = (idx) => idx === 0 || text7[idx - 1] === "\n";
|
|
46401
|
+
while (i2 < text7.length) {
|
|
46244
46402
|
if (mode === "mlbasic") {
|
|
46245
|
-
if (
|
|
46403
|
+
if (text7.startsWith('"""', i2)) {
|
|
46246
46404
|
mode = "out";
|
|
46247
46405
|
i2 += 3;
|
|
46248
46406
|
continue;
|
|
@@ -46251,7 +46409,7 @@ function tomlTables(text6) {
|
|
|
46251
46409
|
continue;
|
|
46252
46410
|
}
|
|
46253
46411
|
if (mode === "mllit") {
|
|
46254
|
-
if (
|
|
46412
|
+
if (text7.startsWith("'''", i2)) {
|
|
46255
46413
|
mode = "out";
|
|
46256
46414
|
i2 += 3;
|
|
46257
46415
|
continue;
|
|
@@ -46260,61 +46418,61 @@ function tomlTables(text6) {
|
|
|
46260
46418
|
continue;
|
|
46261
46419
|
}
|
|
46262
46420
|
if (mode === "basic") {
|
|
46263
|
-
if (
|
|
46421
|
+
if (text7[i2] === "\n") {
|
|
46264
46422
|
mode = "out";
|
|
46265
46423
|
i2 += 1;
|
|
46266
46424
|
continue;
|
|
46267
46425
|
}
|
|
46268
|
-
if (
|
|
46426
|
+
if (text7[i2] === "\\") {
|
|
46269
46427
|
i2 += 2;
|
|
46270
46428
|
continue;
|
|
46271
46429
|
}
|
|
46272
|
-
if (
|
|
46430
|
+
if (text7[i2] === '"') mode = "out";
|
|
46273
46431
|
i2 += 1;
|
|
46274
46432
|
continue;
|
|
46275
46433
|
}
|
|
46276
46434
|
if (mode === "literal") {
|
|
46277
|
-
if (
|
|
46435
|
+
if (text7[i2] === "\n") {
|
|
46278
46436
|
mode = "out";
|
|
46279
46437
|
i2 += 1;
|
|
46280
46438
|
continue;
|
|
46281
46439
|
}
|
|
46282
|
-
if (
|
|
46440
|
+
if (text7[i2] === "'") mode = "out";
|
|
46283
46441
|
i2 += 1;
|
|
46284
46442
|
continue;
|
|
46285
46443
|
}
|
|
46286
|
-
if (
|
|
46444
|
+
if (text7.startsWith('"""', i2)) {
|
|
46287
46445
|
mode = "mlbasic";
|
|
46288
46446
|
i2 += 3;
|
|
46289
46447
|
continue;
|
|
46290
46448
|
}
|
|
46291
|
-
if (
|
|
46449
|
+
if (text7.startsWith("'''", i2)) {
|
|
46292
46450
|
mode = "mllit";
|
|
46293
46451
|
i2 += 3;
|
|
46294
46452
|
continue;
|
|
46295
46453
|
}
|
|
46296
|
-
if (
|
|
46454
|
+
if (text7[i2] === '"') {
|
|
46297
46455
|
mode = "basic";
|
|
46298
46456
|
i2 += 1;
|
|
46299
46457
|
continue;
|
|
46300
46458
|
}
|
|
46301
|
-
if (
|
|
46459
|
+
if (text7[i2] === "'") {
|
|
46302
46460
|
mode = "literal";
|
|
46303
46461
|
i2 += 1;
|
|
46304
46462
|
continue;
|
|
46305
46463
|
}
|
|
46306
|
-
if (
|
|
46307
|
-
const nl =
|
|
46308
|
-
i2 = nl < 0 ?
|
|
46464
|
+
if (text7[i2] === "#") {
|
|
46465
|
+
const nl = text7.indexOf("\n", i2);
|
|
46466
|
+
i2 = nl < 0 ? text7.length : nl + 1;
|
|
46309
46467
|
continue;
|
|
46310
46468
|
}
|
|
46311
46469
|
if (atLineStart(i2)) {
|
|
46312
46470
|
let j2 = i2;
|
|
46313
|
-
while (j2 <
|
|
46314
|
-
if (
|
|
46315
|
-
const nl =
|
|
46316
|
-
const lineEnd = nl < 0 ?
|
|
46317
|
-
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$/, "");
|
|
46318
46476
|
const stripped = stripTomlLineComment(raw).trim();
|
|
46319
46477
|
const array2 = stripped.startsWith("[[");
|
|
46320
46478
|
const name = array2 ? canonicalizeTomlHeading(`[${stripped.replace(/^\s*\[\[/, "").replace(/\]\]\s*$/, "")}]`) : canonicalizeTomlHeading(raw);
|
|
@@ -46327,11 +46485,11 @@ function tomlTables(text6) {
|
|
|
46327
46485
|
}
|
|
46328
46486
|
return headings.map((heading, index) => ({
|
|
46329
46487
|
heading,
|
|
46330
|
-
end: index + 1 < headings.length ? headings[index + 1].lineStart :
|
|
46488
|
+
end: index + 1 < headings.length ? headings[index + 1].lineStart : text7.length
|
|
46331
46489
|
})).filter((entry) => entry.heading.patchable && entry.heading.name).map((entry) => ({
|
|
46332
46490
|
name: entry.heading.name,
|
|
46333
46491
|
headingStart: entry.heading.lineStart,
|
|
46334
|
-
bodyStart: entry.heading.lineEnd + (
|
|
46492
|
+
bodyStart: entry.heading.lineEnd + (text7[entry.heading.lineEnd] === "\n" ? 1 : 0),
|
|
46335
46493
|
end: entry.end
|
|
46336
46494
|
}));
|
|
46337
46495
|
}
|
|
@@ -46387,22 +46545,22 @@ function tomlKeys(block2) {
|
|
|
46387
46545
|
take(block2.length);
|
|
46388
46546
|
return keys;
|
|
46389
46547
|
}
|
|
46390
|
-
function hasTomlTable(
|
|
46548
|
+
function hasTomlTable(text7, heading) {
|
|
46391
46549
|
const name = canonicalizeTomlHeading(heading);
|
|
46392
|
-
return name !== null && tomlTables(
|
|
46550
|
+
return name !== null && tomlTables(text7).some((table) => table.name === name);
|
|
46393
46551
|
}
|
|
46394
|
-
function patchTomlTable(
|
|
46552
|
+
function patchTomlTable(text7, heading, rows) {
|
|
46395
46553
|
const name = canonicalizeTomlHeading(heading);
|
|
46396
|
-
if (!name) return
|
|
46397
|
-
const table = tomlTables(
|
|
46398
|
-
if (!table) return
|
|
46399
|
-
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));
|
|
46400
46558
|
const missing = rows.filter((row) => !keys.has(tomlRowKey(row)));
|
|
46401
|
-
if (!missing.length) return
|
|
46559
|
+
if (!missing.length) return text7;
|
|
46402
46560
|
let insertAt = table.end;
|
|
46403
|
-
while (insertAt > table.bodyStart && (
|
|
46404
|
-
const before =
|
|
46405
|
-
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);
|
|
46406
46564
|
const pad = before.endsWith("\n") || before.length === 0 ? "" : "\n";
|
|
46407
46565
|
return `${before}${pad}${missing.join("\n")}${after.startsWith("\n") ? "" : "\n"}${after}`;
|
|
46408
46566
|
}
|
|
@@ -46414,18 +46572,18 @@ function ensureKimiInjectAlias(modelId, env = process.env) {
|
|
|
46414
46572
|
const alias = `${inject.host}/${inject.model.replace(/\//g, "-")}`;
|
|
46415
46573
|
const dataRoot = kimiDataRoot(env);
|
|
46416
46574
|
mkdirSync18(dataRoot, { recursive: true });
|
|
46417
|
-
const path4 =
|
|
46418
|
-
let
|
|
46575
|
+
const path4 = join42(dataRoot, "config.toml");
|
|
46576
|
+
let text7 = "";
|
|
46419
46577
|
try {
|
|
46420
|
-
|
|
46578
|
+
text7 = readFileSync22(path4, "utf8");
|
|
46421
46579
|
} catch {
|
|
46422
|
-
|
|
46580
|
+
text7 = "";
|
|
46423
46581
|
}
|
|
46424
|
-
const original =
|
|
46582
|
+
const original = text7;
|
|
46425
46583
|
const providerHeading = `[providers.${inject.host}]`;
|
|
46426
46584
|
const modelHeading = `[models.${quoteTomlKey(alias)}]`;
|
|
46427
46585
|
const blocks = [];
|
|
46428
|
-
if (!hasTomlTable(
|
|
46586
|
+
if (!hasTomlTable(text7, providerHeading)) {
|
|
46429
46587
|
blocks.push(
|
|
46430
46588
|
[
|
|
46431
46589
|
providerHeading,
|
|
@@ -46436,8 +46594,8 @@ function ensureKimiInjectAlias(modelId, env = process.env) {
|
|
|
46436
46594
|
].join("\n")
|
|
46437
46595
|
);
|
|
46438
46596
|
}
|
|
46439
|
-
if (hasTomlTable(
|
|
46440
|
-
|
|
46597
|
+
if (hasTomlTable(text7, modelHeading)) {
|
|
46598
|
+
text7 = patchTomlTable(text7, modelHeading, [`protocol = "openai"`, `max_context_size = 262144`]);
|
|
46441
46599
|
} else {
|
|
46442
46600
|
blocks.push(
|
|
46443
46601
|
[
|
|
@@ -46451,13 +46609,13 @@ function ensureKimiInjectAlias(modelId, env = process.env) {
|
|
|
46451
46609
|
);
|
|
46452
46610
|
}
|
|
46453
46611
|
if (blocks.length) {
|
|
46454
|
-
const prefix =
|
|
46612
|
+
const prefix = text7 && !text7.endsWith("\n") ? `${text7}
|
|
46455
46613
|
|
|
46456
|
-
` :
|
|
46614
|
+
` : text7 ? `${text7}
|
|
46457
46615
|
` : "";
|
|
46458
46616
|
writeFileSync14(path4, `${prefix}${blocks.join("\n")}`);
|
|
46459
|
-
} else if (
|
|
46460
|
-
writeFileSync14(path4,
|
|
46617
|
+
} else if (text7 !== original) {
|
|
46618
|
+
writeFileSync14(path4, text7);
|
|
46461
46619
|
}
|
|
46462
46620
|
return alias;
|
|
46463
46621
|
}
|
|
@@ -46477,9 +46635,9 @@ function stripKimiModelEnv(env) {
|
|
|
46477
46635
|
}
|
|
46478
46636
|
function readKimiModelCatalog(env) {
|
|
46479
46637
|
const dataRoot = kimiDataRoot(env);
|
|
46480
|
-
let
|
|
46638
|
+
let text7 = "";
|
|
46481
46639
|
try {
|
|
46482
|
-
|
|
46640
|
+
text7 = readFileSync22(join42(dataRoot, "config.toml"), "utf8");
|
|
46483
46641
|
} catch {
|
|
46484
46642
|
return STATIC_KIMI_MODELS;
|
|
46485
46643
|
}
|
|
@@ -46495,7 +46653,7 @@ function readKimiModelCatalog(env) {
|
|
|
46495
46653
|
options.push({ id: current.slug, label: current.name || current.slug, custom: true });
|
|
46496
46654
|
current = null;
|
|
46497
46655
|
};
|
|
46498
|
-
for (const line of
|
|
46656
|
+
for (const line of text7.split(/\r?\n/)) {
|
|
46499
46657
|
const stripped = line.trim();
|
|
46500
46658
|
if ((stripped.startsWith("[model.") || stripped.startsWith("[models.")) && stripped.endsWith("]")) {
|
|
46501
46659
|
flush();
|
|
@@ -46527,6 +46685,7 @@ var init_kimi = __esm({
|
|
|
46527
46685
|
"use strict";
|
|
46528
46686
|
init_local_inject();
|
|
46529
46687
|
init_core3();
|
|
46688
|
+
init_kimi_turn_failure();
|
|
46530
46689
|
STATIC_KIMI_MODELS = {
|
|
46531
46690
|
default: "kimi-code/k3",
|
|
46532
46691
|
options: [
|
|
@@ -46597,7 +46756,7 @@ var init_kimi = __esm({
|
|
|
46597
46756
|
authFailure: "continue",
|
|
46598
46757
|
// Match the child CLI's own data-root precedence. A custom instance HOME or
|
|
46599
46758
|
// KIMI_CODE_HOME must not be checked against the server user's home instead.
|
|
46600
|
-
isAuthenticated: (env) =>
|
|
46759
|
+
isAuthenticated: (env) => existsSync20(credentialsPath(env)),
|
|
46601
46760
|
// Full rides Kimi's ACP session mode, not argv. `kimi acp` builds its
|
|
46602
46761
|
// harness without the global -y/--yolo and --auto flags and starts every
|
|
46603
46762
|
// ACP session in mode "default" (verified against kimi-code 0.28.1), so
|
|
@@ -46620,19 +46779,25 @@ var init_kimi = __esm({
|
|
|
46620
46779
|
},
|
|
46621
46780
|
buildPromptText: (turn) => turn.system ? `${turn.system}
|
|
46622
46781
|
|
|
46623
|
-
${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
|
+
}
|
|
46624
46789
|
};
|
|
46625
46790
|
KimiAgentDriver = createAcpDriver(support4);
|
|
46626
46791
|
}
|
|
46627
46792
|
});
|
|
46628
46793
|
|
|
46629
46794
|
// server/drivers/acp/droid.ts
|
|
46630
|
-
import { existsSync as
|
|
46795
|
+
import { existsSync as existsSync21, mkdirSync as mkdirSync19, readFileSync as readFileSync23, writeFileSync as writeFileSync15 } from "node:fs";
|
|
46631
46796
|
import { homedir as homedir21 } from "node:os";
|
|
46632
|
-
import { join as
|
|
46797
|
+
import { join as join43 } from "node:path";
|
|
46633
46798
|
function authFilePaths(env) {
|
|
46634
46799
|
const home = env.FACTORY_HOME_OVERRIDE || env.HOME || homedir21();
|
|
46635
|
-
return AUTH_FILES.map((name) =>
|
|
46800
|
+
return AUTH_FILES.map((name) => join43(home, ".factory", name));
|
|
46636
46801
|
}
|
|
46637
46802
|
function droidInjectId(host, model) {
|
|
46638
46803
|
const safe = `${host}-${model}`.replace(/[^a-zA-Z0-9._+-]+/g, "-").replace(/-+/g, "-");
|
|
@@ -46647,14 +46812,14 @@ function ensureDroidInjectModel(modelId, env = process.env) {
|
|
|
46647
46812
|
const host = localHost(inject.host);
|
|
46648
46813
|
if (!host) return modelId;
|
|
46649
46814
|
const id = droidInjectId(inject.host, inject.model);
|
|
46650
|
-
const dir =
|
|
46815
|
+
const dir = join43(factoryHome(env), ".factory");
|
|
46651
46816
|
mkdirSync19(dir, { recursive: true });
|
|
46652
|
-
const path4 =
|
|
46817
|
+
const path4 = join43(dir, "settings.json");
|
|
46653
46818
|
let settings2 = {};
|
|
46654
46819
|
try {
|
|
46655
46820
|
settings2 = JSON.parse(readFileSync23(path4, "utf8"));
|
|
46656
46821
|
} catch (error51) {
|
|
46657
|
-
if (
|
|
46822
|
+
if (existsSync21(path4)) throw error51;
|
|
46658
46823
|
}
|
|
46659
46824
|
const custom2 = Array.isArray(settings2.customModels) ? [...settings2.customModels] : [];
|
|
46660
46825
|
const match = custom2.find(
|
|
@@ -46685,11 +46850,11 @@ function ensureDroidInjectModel(modelId, env = process.env) {
|
|
|
46685
46850
|
function applyDroidLocalAuthEnv(env, modelId) {
|
|
46686
46851
|
if (!decodeInjectId(modelId)) return;
|
|
46687
46852
|
if (env.FACTORY_API_KEY?.trim()) return;
|
|
46688
|
-
if (authFilePaths(env).some(
|
|
46853
|
+
if (authFilePaths(env).some(existsSync21)) return;
|
|
46689
46854
|
env.FACTORY_API_KEY = "openmausbot-local";
|
|
46690
46855
|
}
|
|
46691
46856
|
function readSettings(env) {
|
|
46692
|
-
return JSON.parse(readFileSync23(
|
|
46857
|
+
return JSON.parse(readFileSync23(join43(factoryHome(env), ".factory", "settings.json"), "utf8"));
|
|
46693
46858
|
}
|
|
46694
46859
|
async function resolveModels(env) {
|
|
46695
46860
|
let catalog2 = MODELS3;
|
|
@@ -46777,7 +46942,7 @@ var init_droid = __esm({
|
|
|
46777
46942
|
// The signed-in CLI is the primary source; FACTORY_API_KEY is the fallback
|
|
46778
46943
|
// droid itself advertises, and it is checked last so an ambient key can
|
|
46779
46944
|
// never be what makes an otherwise logged-out instance look ready.
|
|
46780
|
-
isAuthenticated: (env) => authFilePaths(env).some(
|
|
46945
|
+
isAuthenticated: (env) => authFilePaths(env).some(existsSync21) || Boolean(env.FACTORY_API_KEY),
|
|
46781
46946
|
resolveModels,
|
|
46782
46947
|
resolveTurnModel: (model, env) => model ? ensureDroidInjectModel(model, env) : model,
|
|
46783
46948
|
applyTurnEnv: (env, { requestedModel }) => {
|
|
@@ -46818,8 +46983,8 @@ function resolveCursorAcpModelId(available, wanted) {
|
|
|
46818
46983
|
}
|
|
46819
46984
|
return null;
|
|
46820
46985
|
}
|
|
46821
|
-
function firstJsonValue(
|
|
46822
|
-
const trimmed =
|
|
46986
|
+
function firstJsonValue(text7) {
|
|
46987
|
+
const trimmed = text7.trim();
|
|
46823
46988
|
if (!trimmed) return null;
|
|
46824
46989
|
try {
|
|
46825
46990
|
return JSON.parse(trimmed);
|
|
@@ -46893,12 +47058,12 @@ function stripModelMarkers(label) {
|
|
|
46893
47058
|
}
|
|
46894
47059
|
return { label: cleaned, isDefault, isCurrent };
|
|
46895
47060
|
}
|
|
46896
|
-
function decodeCursorModelText(
|
|
47061
|
+
function decodeCursorModelText(text7) {
|
|
46897
47062
|
const options = [];
|
|
46898
47063
|
const seen = /* @__PURE__ */ new Set();
|
|
46899
47064
|
let markedDefault;
|
|
46900
47065
|
let markedCurrent;
|
|
46901
|
-
for (const raw of
|
|
47066
|
+
for (const raw of text7.split(/\r?\n/)) {
|
|
46902
47067
|
const line = raw.trim();
|
|
46903
47068
|
if (!line || line.startsWith("#") || /^available\s+models?\b/i.test(line) || /^models?\b/i.test(line)) continue;
|
|
46904
47069
|
const stripped = line.replace(/^[\s*•-]+\s*/, "");
|
|
@@ -46951,8 +47116,8 @@ function decodeCursorAuthStatus(payload) {
|
|
|
46951
47116
|
}
|
|
46952
47117
|
return null;
|
|
46953
47118
|
}
|
|
46954
|
-
function decodeCursorAuthText(
|
|
46955
|
-
const normalized =
|
|
47119
|
+
function decodeCursorAuthText(text7) {
|
|
47120
|
+
const normalized = text7.trim().toLowerCase();
|
|
46956
47121
|
if (!normalized) return null;
|
|
46957
47122
|
if (/not (?:logged|signed) in|not authenticated|unauthenticated|logged out/.test(normalized)) return false;
|
|
46958
47123
|
if (/login successful|logged in|signed in|authenticated/.test(normalized)) return true;
|
|
@@ -47161,18 +47326,18 @@ import { createHash as createHash13 } from "node:crypto";
|
|
|
47161
47326
|
function requestKey(id) {
|
|
47162
47327
|
return `${typeof id === "number" ? "number" : "string"}:${String(id)}`;
|
|
47163
47328
|
}
|
|
47164
|
-
function utf8ByteLength(
|
|
47329
|
+
function utf8ByteLength(text7) {
|
|
47165
47330
|
let bytes = 0;
|
|
47166
|
-
for (const scalar of
|
|
47331
|
+
for (const scalar of text7) {
|
|
47167
47332
|
const point = scalar.codePointAt(0);
|
|
47168
47333
|
bytes += point <= 127 ? 1 : point <= 2047 ? 2 : point <= 65535 ? 3 : 4;
|
|
47169
47334
|
}
|
|
47170
47335
|
return bytes;
|
|
47171
47336
|
}
|
|
47172
|
-
function truncateToUtf8Bytes(
|
|
47337
|
+
function truncateToUtf8Bytes(text7, limitBytes) {
|
|
47173
47338
|
let bytes = 0;
|
|
47174
47339
|
let end = 0;
|
|
47175
|
-
for (const scalar of
|
|
47340
|
+
for (const scalar of text7) {
|
|
47176
47341
|
const point = scalar.codePointAt(0);
|
|
47177
47342
|
const width = point <= 127 ? 1 : point <= 2047 ? 2 : point <= 65535 ? 3 : 4;
|
|
47178
47343
|
if (bytes + width > limitBytes)
|
|
@@ -47180,7 +47345,7 @@ function truncateToUtf8Bytes(text6, limitBytes) {
|
|
|
47180
47345
|
bytes += width;
|
|
47181
47346
|
end += scalar.length;
|
|
47182
47347
|
}
|
|
47183
|
-
return
|
|
47348
|
+
return text7.slice(0, end);
|
|
47184
47349
|
}
|
|
47185
47350
|
function canonical(value) {
|
|
47186
47351
|
if (Array.isArray(value))
|
|
@@ -47421,10 +47586,10 @@ var init_connection = __esm({
|
|
|
47421
47586
|
throw new ProtocolError("unreachable command retry state");
|
|
47422
47587
|
}
|
|
47423
47588
|
async close() {
|
|
47424
|
-
const
|
|
47589
|
+
const tail3 = this.#writeTail;
|
|
47425
47590
|
if (this.#transport.close !== void 0) {
|
|
47426
47591
|
await this.#transport.close(this.#submitTail);
|
|
47427
|
-
await
|
|
47592
|
+
await tail3;
|
|
47428
47593
|
} else {
|
|
47429
47594
|
this.#finish(new ProtocolError("connection closed"));
|
|
47430
47595
|
}
|
|
@@ -48576,14 +48741,14 @@ var init_muse_code_login = __esm({
|
|
|
48576
48741
|
});
|
|
48577
48742
|
|
|
48578
48743
|
// server/drivers/muse-code.ts
|
|
48579
|
-
import { existsSync as
|
|
48744
|
+
import { existsSync as existsSync22, mkdtempSync as mkdtempSync4, readFileSync as readFileSync24, rmSync as rmSync9, statSync as statSync6 } from "node:fs";
|
|
48580
48745
|
import { readFile as readFile4 } from "node:fs/promises";
|
|
48581
48746
|
import { homedir as homedir22, tmpdir as tmpdir6 } from "node:os";
|
|
48582
|
-
import { join as
|
|
48747
|
+
import { join as join44 } from "node:path";
|
|
48583
48748
|
function museCredentialPath(env, platform = process.platform) {
|
|
48584
48749
|
if (env.MUSE_AUTH_PATH?.trim()) return env.MUSE_AUTH_PATH.trim();
|
|
48585
48750
|
const home = (platform === "win32" ? env.USERPROFILE || env.HOME : env.HOME) || homedir22();
|
|
48586
|
-
return
|
|
48751
|
+
return join44(env.XDG_CONFIG_HOME?.trim() || join44(home, ".config"), "muse", "auth.json");
|
|
48587
48752
|
}
|
|
48588
48753
|
function museCredential(path4) {
|
|
48589
48754
|
let raw;
|
|
@@ -48677,8 +48842,8 @@ function museToolStart(item) {
|
|
|
48677
48842
|
}
|
|
48678
48843
|
function museToolOutput(item) {
|
|
48679
48844
|
const ok = item.status === "completed" && (item.exitCode === void 0 || item.exitCode === 0);
|
|
48680
|
-
const
|
|
48681
|
-
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");
|
|
48682
48847
|
return { ok, ...output ? { output: redactSecretsInText(output.slice(0, MAX_TOOL_OUTPUT)) } : {} };
|
|
48683
48848
|
}
|
|
48684
48849
|
function museQuestions(raw) {
|
|
@@ -48845,7 +49010,7 @@ var init_muse_code = __esm({
|
|
|
48845
49010
|
lastRefresh = Date.now();
|
|
48846
49011
|
});
|
|
48847
49012
|
const listModels = async () => {
|
|
48848
|
-
const cwd = mkdtempSync4(
|
|
49013
|
+
const cwd = mkdtempSync4(join44(tmpdir6(), "atomic-muse-models-"));
|
|
48849
49014
|
let host;
|
|
48850
49015
|
try {
|
|
48851
49016
|
host = await startHost(["serve", "--disable-shell", "--disable-write", "--no-session-log", "--contributor-mode", "off"], cwd, "models", false);
|
|
@@ -48946,12 +49111,12 @@ var init_muse_code = __esm({
|
|
|
48946
49111
|
active.items.set(item.itemId, item);
|
|
48947
49112
|
if (item.kind === "agentMessage") {
|
|
48948
49113
|
if (item.status !== "completed" || item.retracted) return;
|
|
48949
|
-
const
|
|
49114
|
+
const text7 = item.text ?? "";
|
|
48950
49115
|
const streamed = active.streamed.get(item.itemId) ?? "";
|
|
48951
|
-
if (
|
|
48952
|
-
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) });
|
|
48953
49118
|
}
|
|
48954
|
-
if (
|
|
49119
|
+
if (text7) emit({ type: "item.completed", threadId, turnId: active.turnId, itemId: item.itemId, itemType: "assistant_text", text: text7 });
|
|
48955
49120
|
} else if (item.kind === "reasoning") {
|
|
48956
49121
|
if (!seen) emit({ type: "item.started", threadId, turnId: active.turnId, itemId: item.itemId, itemType: "reasoning" });
|
|
48957
49122
|
} else if (TOOL_KINDS.has(item.kind)) {
|
|
@@ -49148,16 +49313,16 @@ var init_muse_code = __esm({
|
|
|
49148
49313
|
const rebuilt = Boolean(resumeId && turn.recoveryText);
|
|
49149
49314
|
return { text: rebuilt ? turn.recoveryText : turn.text, rebuilt, started: true };
|
|
49150
49315
|
};
|
|
49151
|
-
const withInstructions = (state2, turn,
|
|
49316
|
+
const withInstructions = (state2, turn, text7, started) => {
|
|
49152
49317
|
const sessionId = state2.sessionId;
|
|
49153
49318
|
if (turn.systemStable === void 0) return turn.system && started ? `${turn.system}
|
|
49154
49319
|
|
|
49155
|
-
${
|
|
49320
|
+
${text7}` : text7;
|
|
49156
49321
|
let entry = state2.instructions;
|
|
49157
49322
|
const resend = started || !entry || entry.sessionId !== sessionId || entry.stable !== turn.systemStable || entry.turns >= INSTRUCTIONS_REFRESH_TURNS;
|
|
49158
49323
|
if (resend) entry = state2.instructions = { sessionId, stable: turn.systemStable, turns: 0, seen: /* @__PURE__ */ new Map() };
|
|
49159
49324
|
entry.turns++;
|
|
49160
|
-
const body = withNote(
|
|
49325
|
+
const body = withNote(text7, volatileNote(volatileSectionsOf(turn), entry.seen, entry.seen.size === 0));
|
|
49161
49326
|
return resend && turn.systemStable ? `${turn.systemStable}
|
|
49162
49327
|
|
|
49163
49328
|
${body}` : body;
|
|
@@ -49175,7 +49340,7 @@ ${body}` : body;
|
|
|
49175
49340
|
await host.connection.command("session/setModel", { sessionId, model: { modelId: turn.model, providerId: config2.provider } });
|
|
49176
49341
|
state2.model = turn.model;
|
|
49177
49342
|
}
|
|
49178
|
-
const
|
|
49343
|
+
const text7 = withInstructions(state2, turn, session.text, session.started);
|
|
49179
49344
|
const images = turn.images?.length ? await Promise.all(turn.images.map(async (image) => ({
|
|
49180
49345
|
type: "image",
|
|
49181
49346
|
mediaType: image.mime,
|
|
@@ -49187,7 +49352,7 @@ ${body}` : body;
|
|
|
49187
49352
|
active.nativeTurnId = host.connection.mintCommandId();
|
|
49188
49353
|
await host.connection.command("turn/start", {
|
|
49189
49354
|
sessionId,
|
|
49190
|
-
input: [{ type: "text", text:
|
|
49355
|
+
input: [{ type: "text", text: text7 }, ...images],
|
|
49191
49356
|
...effort ? { reasoningEffort: effort } : {}
|
|
49192
49357
|
}, { commandId: active.nativeTurnId });
|
|
49193
49358
|
} catch (error51) {
|
|
@@ -49267,7 +49432,7 @@ ${body}` : body;
|
|
|
49267
49432
|
return "unavailable";
|
|
49268
49433
|
}
|
|
49269
49434
|
},
|
|
49270
|
-
async steer(threadId,
|
|
49435
|
+
async steer(threadId, text7) {
|
|
49271
49436
|
const state2 = threads.get(threadId);
|
|
49272
49437
|
const active = state2?.active;
|
|
49273
49438
|
if (!state2?.host || !state2.sessionId || !active?.nativeTurnId || active.finished) return "refused";
|
|
@@ -49275,7 +49440,7 @@ ${body}` : body;
|
|
|
49275
49440
|
await state2.host.connection.command("turn/steer", {
|
|
49276
49441
|
sessionId: state2.sessionId,
|
|
49277
49442
|
expectedTurnId: active.nativeTurnId,
|
|
49278
|
-
input: [{ type: "text", text:
|
|
49443
|
+
input: [{ type: "text", text: text7 }]
|
|
49279
49444
|
});
|
|
49280
49445
|
return "steered";
|
|
49281
49446
|
} catch (error51) {
|
|
@@ -49294,7 +49459,7 @@ ${body}` : body;
|
|
|
49294
49459
|
return () => listeners.delete(listener);
|
|
49295
49460
|
}
|
|
49296
49461
|
};
|
|
49297
|
-
if (
|
|
49462
|
+
if (existsSync22(credentialPath()) || existsSync22(config2.cli) || findCliCandidates(config2.cli).length) void refreshModels();
|
|
49298
49463
|
return {
|
|
49299
49464
|
instanceId,
|
|
49300
49465
|
driverKind: MUSE_CODE_DRIVER,
|
|
@@ -49341,9 +49506,9 @@ ${body}` : body;
|
|
|
49341
49506
|
});
|
|
49342
49507
|
|
|
49343
49508
|
// server/drivers/acp/opencode-go.ts
|
|
49344
|
-
import { existsSync as
|
|
49509
|
+
import { existsSync as existsSync23, mkdirSync as mkdirSync20, readFileSync as readFileSync25, writeFileSync as writeFileSync16 } from "node:fs";
|
|
49345
49510
|
import { homedir as homedir23 } from "node:os";
|
|
49346
|
-
import { join as
|
|
49511
|
+
import { join as join45 } from "node:path";
|
|
49347
49512
|
function labelForModel(id) {
|
|
49348
49513
|
return id.split(/[-_.]+/g).filter(Boolean).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
|
|
49349
49514
|
}
|
|
@@ -49446,7 +49611,7 @@ async function discoverOpenCodeModels(environment, cli = "opencode") {
|
|
|
49446
49611
|
}
|
|
49447
49612
|
function opencodeConfigDir(env) {
|
|
49448
49613
|
const home = env.HOME || env.USERPROFILE || homedir23();
|
|
49449
|
-
return
|
|
49614
|
+
return join45(env.XDG_CONFIG_HOME || join45(home, ".config"), "opencode");
|
|
49450
49615
|
}
|
|
49451
49616
|
function ensureOpenCodeInjectModel(modelId, env = process.env) {
|
|
49452
49617
|
const inject = decodeInjectId(modelId);
|
|
@@ -49456,9 +49621,9 @@ function ensureOpenCodeInjectModel(modelId, env = process.env) {
|
|
|
49456
49621
|
const native = `${inject.host}/${inject.model}`;
|
|
49457
49622
|
const dir = opencodeConfigDir(env);
|
|
49458
49623
|
mkdirSync20(dir, { recursive: true });
|
|
49459
|
-
const path4 =
|
|
49624
|
+
const path4 = join45(dir, "opencode.json");
|
|
49460
49625
|
let config2 = { $schema: "https://opencode.ai/config.json" };
|
|
49461
|
-
if (
|
|
49626
|
+
if (existsSync23(path4)) {
|
|
49462
49627
|
try {
|
|
49463
49628
|
config2 = JSON.parse(readFileSync25(path4, "utf8"));
|
|
49464
49629
|
} catch {
|
|
@@ -49494,10 +49659,10 @@ function ensureOpenCodeInjectModel(modelId, env = process.env) {
|
|
|
49494
49659
|
function storedAuthPaths(env) {
|
|
49495
49660
|
const home = env.HOME || env.USERPROFILE || homedir23();
|
|
49496
49661
|
const roots = [
|
|
49497
|
-
env.XDG_DATA_HOME ||
|
|
49498
|
-
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") : ""
|
|
49499
49664
|
].filter(Boolean);
|
|
49500
|
-
return [...new Set(roots)].map((root) =>
|
|
49665
|
+
return [...new Set(roots)].map((root) => join45(root, "opencode", "auth.json"));
|
|
49501
49666
|
}
|
|
49502
49667
|
function usableAuthEntry(parsed) {
|
|
49503
49668
|
return Object.values(parsed).some((auth) => {
|
|
@@ -49653,13 +49818,13 @@ ${turn.text}` : turn.text
|
|
|
49653
49818
|
});
|
|
49654
49819
|
|
|
49655
49820
|
// server/drivers/acp/qwen.ts
|
|
49656
|
-
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";
|
|
49657
49822
|
import { createHash as createHash14 } from "node:crypto";
|
|
49658
49823
|
import { homedir as homedir24 } from "node:os";
|
|
49659
|
-
import { join as
|
|
49824
|
+
import { join as join46 } from "node:path";
|
|
49660
49825
|
function qwenHome(env) {
|
|
49661
49826
|
const home = process.platform === "win32" ? env.USERPROFILE || env.HOME || homedir24() : env.HOME || env.USERPROFILE || homedir24();
|
|
49662
|
-
return
|
|
49827
|
+
return join46(home, ".qwen");
|
|
49663
49828
|
}
|
|
49664
49829
|
function isRecord5(value) {
|
|
49665
49830
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
@@ -49671,7 +49836,7 @@ function qwenModelLabel(id, name) {
|
|
|
49671
49836
|
function readQwenRoutes(env) {
|
|
49672
49837
|
let settings2;
|
|
49673
49838
|
try {
|
|
49674
|
-
settings2 = JSON.parse(readFileSync26(
|
|
49839
|
+
settings2 = JSON.parse(readFileSync26(join46(qwenHome(env), "settings.json"), "utf8"));
|
|
49675
49840
|
} catch {
|
|
49676
49841
|
return [];
|
|
49677
49842
|
}
|
|
@@ -49755,9 +49920,9 @@ function ensureQwenInjectModel(modelId, env = process.env) {
|
|
|
49755
49920
|
if (!host) return modelId;
|
|
49756
49921
|
const dir = qwenHome(env);
|
|
49757
49922
|
mkdirSync21(dir, { recursive: true });
|
|
49758
|
-
const path4 =
|
|
49923
|
+
const path4 = join46(dir, "settings.json");
|
|
49759
49924
|
let settings2 = {};
|
|
49760
|
-
if (
|
|
49925
|
+
if (existsSync24(path4)) {
|
|
49761
49926
|
try {
|
|
49762
49927
|
settings2 = JSON.parse(readFileSync26(path4, "utf8"));
|
|
49763
49928
|
} catch {
|
|
@@ -49900,29 +50065,32 @@ function mistralSignInLink(value) {
|
|
|
49900
50065
|
return host === "mistral.ai" || host.endsWith(".mistral.ai") ? url2.href : null;
|
|
49901
50066
|
}
|
|
49902
50067
|
function vibeSignInFailure(error51) {
|
|
49903
|
-
const
|
|
49904
|
-
if (/denied/i.test(
|
|
49905
|
-
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.";
|
|
49906
50071
|
if (error51 instanceof Error && !(error51 instanceof VibeRequestError)) return error51.message;
|
|
49907
50072
|
return "Mistral Vibe sign-in did not finish. Check this computer's connection and that Vibe is up to date, then try again.";
|
|
49908
50073
|
}
|
|
49909
|
-
async function
|
|
50074
|
+
async function vibeSignInState(cli, env, timeoutMs = 2e4) {
|
|
49910
50075
|
let client;
|
|
49911
50076
|
try {
|
|
49912
50077
|
client = new VibeAcpClient(cli, env);
|
|
49913
50078
|
} catch {
|
|
49914
|
-
return
|
|
50079
|
+
return "signed-out";
|
|
49915
50080
|
}
|
|
49916
50081
|
try {
|
|
49917
50082
|
await client.initialize(timeoutMs);
|
|
49918
50083
|
const status = await client.request("_auth/status", {}, timeoutMs);
|
|
49919
|
-
return status?.authenticated === true;
|
|
50084
|
+
return status?.authenticated === true ? "signed-in" : "signed-out";
|
|
49920
50085
|
} catch {
|
|
49921
|
-
return
|
|
50086
|
+
return client.missing ? "missing" : "signed-out";
|
|
49922
50087
|
} finally {
|
|
49923
50088
|
client.close();
|
|
49924
50089
|
}
|
|
49925
50090
|
}
|
|
50091
|
+
async function vibeSignedIn(cli, env, timeoutMs = 2e4) {
|
|
50092
|
+
return await vibeSignInState(cli, env, timeoutMs) === "signed-in";
|
|
50093
|
+
}
|
|
49926
50094
|
var MAX_LINE, DELEGATED, VibeAcpClient, VibeRequestError, VibeLoginController;
|
|
49927
50095
|
var init_vibe_login = __esm({
|
|
49928
50096
|
"server/drivers/vibe-login.ts"() {
|
|
@@ -49936,12 +50104,17 @@ var init_vibe_login = __esm({
|
|
|
49936
50104
|
nextId = 1;
|
|
49937
50105
|
buffer = "";
|
|
49938
50106
|
closed = false;
|
|
50107
|
+
/** The command was not found: nothing is installed to sign in to. */
|
|
50108
|
+
missing = false;
|
|
49939
50109
|
constructor(cli, env) {
|
|
49940
50110
|
this.child = spawnCli(cli, [], { env, stdio: ["pipe", "pipe", "pipe"] });
|
|
49941
50111
|
this.child.stderr?.resume();
|
|
49942
50112
|
this.child.stdout?.on("data", (chunk) => this.receive(chunk.toString("utf8")));
|
|
49943
50113
|
const fail = (message3) => this.close(new Error(message3));
|
|
49944
|
-
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
|
+
});
|
|
49945
50118
|
this.child.once("close", () => fail("Mistral Vibe stopped before it answered. Update Vibe and try again."));
|
|
49946
50119
|
}
|
|
49947
50120
|
/** initialize, opting in to the delegated browser sign-in. */
|
|
@@ -49977,8 +50150,8 @@ var init_vibe_login = __esm({
|
|
|
49977
50150
|
}
|
|
49978
50151
|
if (this.child.exitCode === null && this.child.signalCode === null) void killCliTree(this.child).catch(() => false);
|
|
49979
50152
|
}
|
|
49980
|
-
receive(
|
|
49981
|
-
this.buffer +=
|
|
50153
|
+
receive(text7) {
|
|
50154
|
+
this.buffer += text7;
|
|
49982
50155
|
if (this.buffer.length > MAX_LINE) {
|
|
49983
50156
|
this.close(new Error("Mistral Vibe returned an unexpected answer. Update Vibe and try again."));
|
|
49984
50157
|
return;
|
|
@@ -50151,7 +50324,7 @@ var init_vibe = __esm({
|
|
|
50151
50324
|
models: MODELS4,
|
|
50152
50325
|
defaultCli: "vibe-acp",
|
|
50153
50326
|
nativeSource: "vibe.acp",
|
|
50154
|
-
loginNote: "Mistral Vibe is not
|
|
50327
|
+
loginNote: "Mistral Vibe is not signed in: choose Sign in with Mistral on its engine card",
|
|
50155
50328
|
// Mistral's own installer (it installs uv, then mistral-vibe). Not a
|
|
50156
50329
|
// vendorScript: mistral.ai redirects it to raw.githubusercontent.com, a host
|
|
50157
50330
|
// vendor-install.ts cannot pin to Mistral. Mistral targets macOS and Linux;
|
|
@@ -50166,11 +50339,17 @@ var init_vibe = __esm({
|
|
|
50166
50339
|
spawnArgs: () => [],
|
|
50167
50340
|
selectModel: { configId: "model" },
|
|
50168
50341
|
// Sign-in is the delegated browser flow on the engine card, never a
|
|
50169
|
-
// 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.
|
|
50170
50346
|
pickAuthMethod: () => null,
|
|
50171
|
-
authFailure: "
|
|
50347
|
+
authFailure: "continue",
|
|
50172
50348
|
requireAuthenticationBeforeSpawn: true,
|
|
50173
|
-
|
|
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"),
|
|
50174
50353
|
async configureSession({ request, sessionId, config: config2, turn }) {
|
|
50175
50354
|
const value = vibeSessionMode(config2.fullAuto, turn.approvalMode);
|
|
50176
50355
|
let reply;
|
|
@@ -50399,12 +50578,12 @@ var init_atomic_engine_local = __esm({
|
|
|
50399
50578
|
// server/atomic-engine-accounts.ts
|
|
50400
50579
|
import { mkdirSync as mkdirSync22, readFileSync as readFileSync27, writeFileSync as writeFileSync18 } from "node:fs";
|
|
50401
50580
|
import { homedir as homedir25 } from "node:os";
|
|
50402
|
-
import { join as
|
|
50581
|
+
import { join as join47 } from "node:path";
|
|
50403
50582
|
function rawConfig2(entry) {
|
|
50404
50583
|
return entry.config && typeof entry.config === "object" && !Array.isArray(entry.config) ? entry.config : {};
|
|
50405
50584
|
}
|
|
50406
50585
|
function expandHome(path4) {
|
|
50407
|
-
return path4 === "~" ? homedir25() : path4.startsWith("~/") ?
|
|
50586
|
+
return path4 === "~" ? homedir25() : path4.startsWith("~/") ? join47(homedir25(), path4.slice(2)) : path4;
|
|
50408
50587
|
}
|
|
50409
50588
|
function asAccount(id, entry) {
|
|
50410
50589
|
if (entry.enabled === false) return null;
|
|
@@ -50436,7 +50615,7 @@ function asAccount(id, entry) {
|
|
|
50436
50615
|
kind: "codex-cli",
|
|
50437
50616
|
label,
|
|
50438
50617
|
billing: "subscription",
|
|
50439
|
-
home: home ? expandHome(home) :
|
|
50618
|
+
home: home ? expandHome(home) : join47(homedir25(), ".codex"),
|
|
50440
50619
|
model: FAILOVER_MODEL["openai-codex"]
|
|
50441
50620
|
} };
|
|
50442
50621
|
}
|
|
@@ -50515,16 +50694,16 @@ function atomicEngineAccounts(input) {
|
|
|
50515
50694
|
}
|
|
50516
50695
|
function writeAtomicEngineAccountsFile(engineHome, accounts) {
|
|
50517
50696
|
const shareable = accounts.map(({ restingUntil: _resting, ...account }) => account);
|
|
50518
|
-
const
|
|
50697
|
+
const text7 = `${JSON.stringify({ version: 1, accounts: shareable }, null, 2)}
|
|
50519
50698
|
`;
|
|
50520
|
-
const path4 =
|
|
50699
|
+
const path4 = join47(engineHome, ACCOUNTS_FILE);
|
|
50521
50700
|
try {
|
|
50522
|
-
if (readFileSync27(path4, "utf8") ===
|
|
50701
|
+
if (readFileSync27(path4, "utf8") === text7) return;
|
|
50523
50702
|
} catch {
|
|
50524
50703
|
}
|
|
50525
50704
|
try {
|
|
50526
50705
|
mkdirSync22(engineHome, { recursive: true, mode: 448 });
|
|
50527
|
-
writeFileSync18(path4,
|
|
50706
|
+
writeFileSync18(path4, text7, { mode: 384 });
|
|
50528
50707
|
} catch (error51) {
|
|
50529
50708
|
console.warn(`[atomic-engine] could not write ${path4}: ${error51.message}`);
|
|
50530
50709
|
}
|
|
@@ -50609,31 +50788,31 @@ var init_atomic_engine_release = __esm({
|
|
|
50609
50788
|
|
|
50610
50789
|
// server/atomic-engine-runtime.ts
|
|
50611
50790
|
import { createHash as createHash15, randomUUID as randomUUID16 } from "node:crypto";
|
|
50612
|
-
import { createWriteStream as createWriteStream2, existsSync as
|
|
50613
|
-
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";
|
|
50614
50793
|
import { Readable, Transform as Transform2 } from "node:stream";
|
|
50615
50794
|
import { pipeline as pipeline2 } from "node:stream/promises";
|
|
50616
50795
|
function atomicEngineHome(baseDir = DATA_DIR) {
|
|
50617
|
-
return
|
|
50796
|
+
return join48(baseDir, "tools", "atomic-engine");
|
|
50618
50797
|
}
|
|
50619
50798
|
function atomicEnginePython(root, platform = process.platform) {
|
|
50620
|
-
return platform === "win32" ?
|
|
50799
|
+
return platform === "win32" ? join48(root, "atomic-engine", "python", "python.exe") : join48(root, "atomic-engine", "python", "bin", "python3");
|
|
50621
50800
|
}
|
|
50622
50801
|
function managedAtomicEngine(baseDir = DATA_DIR, asset = atomicEngineAsset(), platform = process.platform) {
|
|
50623
50802
|
if (!asset) return null;
|
|
50624
|
-
const root =
|
|
50803
|
+
const root = join48(atomicEngineHome(baseDir), asset.version);
|
|
50625
50804
|
try {
|
|
50626
|
-
if (readFileSync28(
|
|
50805
|
+
if (readFileSync28(join48(root, MARKER2), "utf8").trim() !== asset.sha512) return null;
|
|
50627
50806
|
} catch {
|
|
50628
50807
|
return null;
|
|
50629
50808
|
}
|
|
50630
50809
|
const python = atomicEnginePython(root, platform);
|
|
50631
|
-
return
|
|
50810
|
+
return existsSync25(python) ? { version: asset.version, root, python } : null;
|
|
50632
50811
|
}
|
|
50633
50812
|
function systemTar(platform = process.platform) {
|
|
50634
50813
|
if (platform !== "win32") return "/usr/bin/tar";
|
|
50635
50814
|
const systemRoot = process.env.SystemRoot ?? process.env.SYSTEMROOT ?? "C:\\Windows";
|
|
50636
|
-
return
|
|
50815
|
+
return join48(systemRoot, "System32", "tar.exe");
|
|
50637
50816
|
}
|
|
50638
50817
|
async function download(asset, file2, options) {
|
|
50639
50818
|
let response;
|
|
@@ -50678,8 +50857,8 @@ async function installOnce3(options) {
|
|
|
50678
50857
|
const home = atomicEngineHome(baseDir);
|
|
50679
50858
|
mkdirSync23(home, { recursive: true });
|
|
50680
50859
|
const id = randomUUID16();
|
|
50681
|
-
const archive =
|
|
50682
|
-
const staging =
|
|
50860
|
+
const archive = join48(home, `.download-${id}.tar.gz`);
|
|
50861
|
+
const staging = join48(home, `.staging-${id}`);
|
|
50683
50862
|
try {
|
|
50684
50863
|
await download(asset, archive, options);
|
|
50685
50864
|
options.onProgress?.({ phase: "installing" });
|
|
@@ -50689,8 +50868,8 @@ async function installOnce3(options) {
|
|
|
50689
50868
|
} catch (error51) {
|
|
50690
50869
|
throw new AtomicEngineInstallError("install", `Could not unpack Atomic Engine: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
50691
50870
|
}
|
|
50692
|
-
if (!
|
|
50693
|
-
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);
|
|
50694
50873
|
rmSync10(root, { recursive: true, force: true });
|
|
50695
50874
|
await promoteDirectory(staging, root);
|
|
50696
50875
|
const python = atomicEnginePython(root);
|
|
@@ -50701,10 +50880,10 @@ async function installOnce3(options) {
|
|
|
50701
50880
|
await removeDirectoryQuietly(root, "Atomic Engine has no install marker there, so it is not used");
|
|
50702
50881
|
throw new AtomicEngineInstallError("install", `Atomic Engine did not start after installing: ${error51 instanceof Error ? error51.message : String(error51)}`);
|
|
50703
50882
|
}
|
|
50704
|
-
writeFileSync19(
|
|
50883
|
+
writeFileSync19(join48(root, MARKER2), `${asset.sha512}
|
|
50705
50884
|
`);
|
|
50706
|
-
for (const name of
|
|
50707
|
-
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 });
|
|
50708
50887
|
}
|
|
50709
50888
|
const installed = managedAtomicEngine(baseDir, asset);
|
|
50710
50889
|
if (!installed) throw new AtomicEngineInstallError("install", "Atomic Engine did not install completely");
|
|
@@ -51663,14 +51842,14 @@ var init_stringifyComment = __esm({
|
|
|
51663
51842
|
});
|
|
51664
51843
|
|
|
51665
51844
|
// ../atomic-harness-skills/node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/stringify/foldFlowLines.js
|
|
51666
|
-
function foldFlowLines(
|
|
51845
|
+
function foldFlowLines(text7, indent, mode = "flow", { indentAtStart, lineWidth = 80, minContentWidth = 20, onFold, onOverflow } = {}) {
|
|
51667
51846
|
if (!lineWidth || lineWidth < 0)
|
|
51668
|
-
return
|
|
51847
|
+
return text7;
|
|
51669
51848
|
if (lineWidth < minContentWidth)
|
|
51670
51849
|
minContentWidth = 0;
|
|
51671
51850
|
const endStep = Math.max(1 + minContentWidth, 1 + lineWidth - indent.length);
|
|
51672
|
-
if (
|
|
51673
|
-
return
|
|
51851
|
+
if (text7.length <= endStep)
|
|
51852
|
+
return text7;
|
|
51674
51853
|
const folds = [];
|
|
51675
51854
|
const escapedFolds = {};
|
|
51676
51855
|
let end = lineWidth - indent.length;
|
|
@@ -51687,14 +51866,14 @@ function foldFlowLines(text6, indent, mode = "flow", { indentAtStart, lineWidth
|
|
|
51687
51866
|
let escStart = -1;
|
|
51688
51867
|
let escEnd = -1;
|
|
51689
51868
|
if (mode === FOLD_BLOCK) {
|
|
51690
|
-
i2 = consumeMoreIndentedLines(
|
|
51869
|
+
i2 = consumeMoreIndentedLines(text7, i2, indent.length);
|
|
51691
51870
|
if (i2 !== -1)
|
|
51692
51871
|
end = i2 + endStep;
|
|
51693
51872
|
}
|
|
51694
|
-
for (let ch; ch =
|
|
51873
|
+
for (let ch; ch = text7[i2 += 1]; ) {
|
|
51695
51874
|
if (mode === FOLD_QUOTED && ch === "\\") {
|
|
51696
51875
|
escStart = i2;
|
|
51697
|
-
switch (
|
|
51876
|
+
switch (text7[i2 + 1]) {
|
|
51698
51877
|
case "x":
|
|
51699
51878
|
i2 += 3;
|
|
51700
51879
|
break;
|
|
@@ -51711,12 +51890,12 @@ function foldFlowLines(text6, indent, mode = "flow", { indentAtStart, lineWidth
|
|
|
51711
51890
|
}
|
|
51712
51891
|
if (ch === "\n") {
|
|
51713
51892
|
if (mode === FOLD_BLOCK)
|
|
51714
|
-
i2 = consumeMoreIndentedLines(
|
|
51893
|
+
i2 = consumeMoreIndentedLines(text7, i2, indent.length);
|
|
51715
51894
|
end = i2 + indent.length + endStep;
|
|
51716
51895
|
split = void 0;
|
|
51717
51896
|
} else {
|
|
51718
51897
|
if (ch === " " && prev && prev !== " " && prev !== "\n" && prev !== " ") {
|
|
51719
|
-
const next =
|
|
51898
|
+
const next = text7[i2 + 1];
|
|
51720
51899
|
if (next && next !== " " && next !== "\n" && next !== " ")
|
|
51721
51900
|
split = i2;
|
|
51722
51901
|
}
|
|
@@ -51728,12 +51907,12 @@ function foldFlowLines(text6, indent, mode = "flow", { indentAtStart, lineWidth
|
|
|
51728
51907
|
} else if (mode === FOLD_QUOTED) {
|
|
51729
51908
|
while (prev === " " || prev === " ") {
|
|
51730
51909
|
prev = ch;
|
|
51731
|
-
ch =
|
|
51910
|
+
ch = text7[i2 += 1];
|
|
51732
51911
|
overflow = true;
|
|
51733
51912
|
}
|
|
51734
51913
|
const j2 = i2 > escEnd + 1 ? i2 - 2 : escStart - 1;
|
|
51735
51914
|
if (escapedFolds[j2])
|
|
51736
|
-
return
|
|
51915
|
+
return text7;
|
|
51737
51916
|
folds.push(j2);
|
|
51738
51917
|
escapedFolds[j2] = true;
|
|
51739
51918
|
end = j2 + endStep;
|
|
@@ -51748,39 +51927,39 @@ function foldFlowLines(text6, indent, mode = "flow", { indentAtStart, lineWidth
|
|
|
51748
51927
|
if (overflow && onOverflow)
|
|
51749
51928
|
onOverflow();
|
|
51750
51929
|
if (folds.length === 0)
|
|
51751
|
-
return
|
|
51930
|
+
return text7;
|
|
51752
51931
|
if (onFold)
|
|
51753
51932
|
onFold();
|
|
51754
|
-
let res =
|
|
51933
|
+
let res = text7.slice(0, folds[0]);
|
|
51755
51934
|
for (let i3 = 0; i3 < folds.length; ++i3) {
|
|
51756
51935
|
const fold = folds[i3];
|
|
51757
|
-
const end2 = folds[i3 + 1] ||
|
|
51936
|
+
const end2 = folds[i3 + 1] || text7.length;
|
|
51758
51937
|
if (fold === 0)
|
|
51759
51938
|
res = `
|
|
51760
|
-
${indent}${
|
|
51939
|
+
${indent}${text7.slice(0, end2)}`;
|
|
51761
51940
|
else {
|
|
51762
51941
|
if (mode === FOLD_QUOTED && escapedFolds[fold])
|
|
51763
|
-
res += `${
|
|
51942
|
+
res += `${text7[fold]}\\`;
|
|
51764
51943
|
res += `
|
|
51765
|
-
${indent}${
|
|
51944
|
+
${indent}${text7.slice(fold + 1, end2)}`;
|
|
51766
51945
|
}
|
|
51767
51946
|
}
|
|
51768
51947
|
return res;
|
|
51769
51948
|
}
|
|
51770
|
-
function consumeMoreIndentedLines(
|
|
51949
|
+
function consumeMoreIndentedLines(text7, i2, indent) {
|
|
51771
51950
|
let end = i2;
|
|
51772
51951
|
let start = i2 + 1;
|
|
51773
|
-
let ch =
|
|
51952
|
+
let ch = text7[start];
|
|
51774
51953
|
while (ch === " " || ch === " ") {
|
|
51775
51954
|
if (i2 < start + indent) {
|
|
51776
|
-
ch =
|
|
51955
|
+
ch = text7[++i2];
|
|
51777
51956
|
} else {
|
|
51778
51957
|
do {
|
|
51779
|
-
ch =
|
|
51958
|
+
ch = text7[++i2];
|
|
51780
51959
|
} while (ch && ch !== "\n");
|
|
51781
51960
|
end = i2;
|
|
51782
51961
|
start = i2 + 1;
|
|
51783
|
-
ch =
|
|
51962
|
+
ch = text7[start];
|
|
51784
51963
|
}
|
|
51785
51964
|
}
|
|
51786
51965
|
return end;
|
|
@@ -57627,8 +57806,8 @@ var init_memory_policy = __esm({
|
|
|
57627
57806
|
|
|
57628
57807
|
// server/drivers/acp/hermes-memory-lock.ts
|
|
57629
57808
|
import { createHash as createHash16 } from "node:crypto";
|
|
57630
|
-
import { mkdirSync as mkdirSync24, readdirSync as
|
|
57631
|
-
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";
|
|
57632
57811
|
function readText2(path4) {
|
|
57633
57812
|
try {
|
|
57634
57813
|
return readFileSync29(path4, "utf8");
|
|
@@ -57636,10 +57815,10 @@ function readText2(path4) {
|
|
|
57636
57815
|
return null;
|
|
57637
57816
|
}
|
|
57638
57817
|
}
|
|
57639
|
-
function parseYamlSafe(
|
|
57640
|
-
if (
|
|
57818
|
+
function parseYamlSafe(text7) {
|
|
57819
|
+
if (text7 === null) return null;
|
|
57641
57820
|
try {
|
|
57642
|
-
return parse3(
|
|
57821
|
+
return parse3(text7);
|
|
57643
57822
|
} catch {
|
|
57644
57823
|
return null;
|
|
57645
57824
|
}
|
|
@@ -57650,29 +57829,29 @@ function record3(value) {
|
|
|
57650
57829
|
function memoryProviderPlugins(pluginsDir) {
|
|
57651
57830
|
let dirs;
|
|
57652
57831
|
try {
|
|
57653
|
-
dirs =
|
|
57832
|
+
dirs = readdirSync9(pluginsDir);
|
|
57654
57833
|
} catch {
|
|
57655
57834
|
return [];
|
|
57656
57835
|
}
|
|
57657
57836
|
return dirs.flatMap((dir) => {
|
|
57658
|
-
const source2 = (readText2(
|
|
57837
|
+
const source2 = (readText2(join49(pluginsDir, dir, "__init__.py")) ?? "").slice(0, 8192);
|
|
57659
57838
|
if (!source2.includes("register_memory_provider") && !source2.includes("MemoryProvider")) return [];
|
|
57660
|
-
const name = record3(parseYamlSafe(readText2(
|
|
57839
|
+
const name = record3(parseYamlSafe(readText2(join49(pluginsDir, dir, "plugin.yaml"))))?.name;
|
|
57661
57840
|
return typeof name === "string" && name.trim() && name.trim() !== dir ? [dir, name.trim()] : [dir];
|
|
57662
57841
|
});
|
|
57663
57842
|
}
|
|
57664
57843
|
function lockHermesMemory(env, home, dataDir = DATA_DIR) {
|
|
57665
|
-
const own = record3(record3(parseYamlSafe(readText2(
|
|
57844
|
+
const own = record3(record3(parseYamlSafe(readText2(join49(home, "config.yaml"))))?.plugins);
|
|
57666
57845
|
const disabled = new Set(Array.isArray(own?.disabled) ? own.disabled.map(String) : []);
|
|
57667
|
-
for (const name of memoryProviderPlugins(
|
|
57846
|
+
for (const name of memoryProviderPlugins(join49(home, "plugins"))) disabled.add(name);
|
|
57668
57847
|
for (const name of BLOCKED_HERMES_MEMORY_PLUGINS) disabled.add(name);
|
|
57669
57848
|
const overlay = stringify3({
|
|
57670
57849
|
memory: { provider: "", memory_enabled: false, user_profile_enabled: false },
|
|
57671
57850
|
plugins: { disabled: [...disabled].sort() }
|
|
57672
57851
|
});
|
|
57673
|
-
const dir =
|
|
57852
|
+
const dir = join49(dataDir, "hermes-managed", createHash16("sha256").update(home).digest("hex").slice(0, 16));
|
|
57674
57853
|
mkdirSync24(dir, { recursive: true });
|
|
57675
|
-
const file2 =
|
|
57854
|
+
const file2 = join49(dir, "config.yaml");
|
|
57676
57855
|
if (readText2(file2) !== overlay) writeFileSync20(file2, overlay);
|
|
57677
57856
|
env.HERMES_MANAGED_DIR = dir;
|
|
57678
57857
|
return dir;
|
|
@@ -57690,7 +57869,7 @@ var init_hermes_memory_lock = __esm({
|
|
|
57690
57869
|
import { spawn as spawn7 } from "node:child_process";
|
|
57691
57870
|
import { mkdirSync as mkdirSync25, readFileSync as readFileSync30, writeFileSync as writeFileSync21 } from "node:fs";
|
|
57692
57871
|
import { homedir as homedir26 } from "node:os";
|
|
57693
|
-
import { join as
|
|
57872
|
+
import { join as join50 } from "node:path";
|
|
57694
57873
|
function bindHermesScreenshotCompat(env, modelId) {
|
|
57695
57874
|
delete env[HERMES_OPENMAUS_SCREENSHOT_COMPAT];
|
|
57696
57875
|
delete env[HERMES_OPENMAUS_SCREENSHOT_COMPAT_MODEL];
|
|
@@ -57700,30 +57879,30 @@ function bindHermesScreenshotCompat(env, modelId) {
|
|
|
57700
57879
|
env[HERMES_OPENMAUS_SCREENSHOT_COMPAT_MODEL] = inject.model;
|
|
57701
57880
|
}
|
|
57702
57881
|
function hermesHome(env) {
|
|
57703
|
-
return env.HERMES_HOME ||
|
|
57882
|
+
return env.HERMES_HOME || join50(env.HOME || env.USERPROFILE || homedir26(), ".hermes");
|
|
57704
57883
|
}
|
|
57705
57884
|
function quoteYaml(value) {
|
|
57706
57885
|
if (/^[\w./:+-]+$/.test(value)) return value;
|
|
57707
57886
|
return JSON.stringify(value);
|
|
57708
57887
|
}
|
|
57709
|
-
function upsertHermesProvider(
|
|
57888
|
+
function upsertHermesProvider(text7, hostId, baseUrl, apiKey) {
|
|
57710
57889
|
const block2 = [` ${hostId}:`, ` base_url: ${quoteYaml(baseUrl)}`, ` api_key: ${quoteYaml(apiKey)}`, ""].join(
|
|
57711
57890
|
"\n"
|
|
57712
57891
|
);
|
|
57713
|
-
if (/^providers:\s*$/m.test(
|
|
57714
|
-
const replaced = replaceHermesHostBlock(
|
|
57892
|
+
if (/^providers:\s*$/m.test(text7)) {
|
|
57893
|
+
const replaced = replaceHermesHostBlock(text7, hostId, block2);
|
|
57715
57894
|
if (replaced !== null) return replaced;
|
|
57716
|
-
return
|
|
57895
|
+
return text7.replace(/^providers:\s*$/m, `providers:
|
|
57717
57896
|
${block2.trimEnd()}`);
|
|
57718
57897
|
}
|
|
57719
|
-
const prefix =
|
|
57720
|
-
` :
|
|
57898
|
+
const prefix = text7 && !text7.endsWith("\n") ? `${text7}
|
|
57899
|
+
` : text7;
|
|
57721
57900
|
return `${prefix}
|
|
57722
57901
|
providers:
|
|
57723
57902
|
${block2}`;
|
|
57724
57903
|
}
|
|
57725
|
-
function replaceHermesHostBlock(
|
|
57726
|
-
const lines =
|
|
57904
|
+
function replaceHermesHostBlock(text7, hostId, block2) {
|
|
57905
|
+
const lines = text7.split("\n");
|
|
57727
57906
|
const start = lines.findIndex((line) => line === ` ${hostId}:`);
|
|
57728
57907
|
if (start < 0) return null;
|
|
57729
57908
|
let end = start + 1;
|
|
@@ -57742,15 +57921,15 @@ function ensureHermesInjectProvider(modelId, env = process.env, home = hermesHom
|
|
|
57742
57921
|
if (!host) return modelId;
|
|
57743
57922
|
const dir = home;
|
|
57744
57923
|
mkdirSync25(dir, { recursive: true });
|
|
57745
|
-
const path4 =
|
|
57746
|
-
let
|
|
57924
|
+
const path4 = join50(dir, "config.yaml");
|
|
57925
|
+
let text7 = "";
|
|
57747
57926
|
try {
|
|
57748
|
-
|
|
57927
|
+
text7 = readFileSync30(path4, "utf8");
|
|
57749
57928
|
} catch {
|
|
57750
|
-
|
|
57929
|
+
text7 = "";
|
|
57751
57930
|
}
|
|
57752
|
-
const next = upsertHermesProvider(
|
|
57753
|
-
if (next !==
|
|
57931
|
+
const next = upsertHermesProvider(text7, inject.host, host.baseUrl, hostApiKey(host, env));
|
|
57932
|
+
if (next !== text7) writeFileSync21(path4, next);
|
|
57754
57933
|
return hermesAcpModelId(modelId) ?? modelId;
|
|
57755
57934
|
}
|
|
57756
57935
|
function hermesAcpModelId(modelId) {
|
|
@@ -57760,8 +57939,8 @@ function hermesAcpModelId(modelId) {
|
|
|
57760
57939
|
if (native && !native.includes(INJECT_SEP) && /^[a-z0-9_-]+:[\w./:-]+$/i.test(native)) return native;
|
|
57761
57940
|
return null;
|
|
57762
57941
|
}
|
|
57763
|
-
function nonEmptyDotenvValue(
|
|
57764
|
-
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);
|
|
57765
57944
|
if (!match) return null;
|
|
57766
57945
|
const raw = match[1].trim();
|
|
57767
57946
|
if (!raw || raw.startsWith("#")) return null;
|
|
@@ -57778,10 +57957,10 @@ function nonEmptyDotenvValue(text6, name) {
|
|
|
57778
57957
|
function yamlString(value) {
|
|
57779
57958
|
return typeof value === "string" ? value.trim() : "";
|
|
57780
57959
|
}
|
|
57781
|
-
function hermesConfigDefault(
|
|
57960
|
+
function hermesConfigDefault(text7) {
|
|
57782
57961
|
let raw;
|
|
57783
57962
|
try {
|
|
57784
|
-
raw = parse3(
|
|
57963
|
+
raw = parse3(text7);
|
|
57785
57964
|
} catch {
|
|
57786
57965
|
return null;
|
|
57787
57966
|
}
|
|
@@ -57813,13 +57992,13 @@ function hermesConfiguredModel(env = process.env) {
|
|
|
57813
57992
|
const dir = hermesHome(env);
|
|
57814
57993
|
let secrets = "";
|
|
57815
57994
|
try {
|
|
57816
|
-
secrets = readFileSync30(
|
|
57995
|
+
secrets = readFileSync30(join50(dir, ".env"), "utf8");
|
|
57817
57996
|
} catch {
|
|
57818
57997
|
}
|
|
57819
57998
|
const hasHostedProviderKey = HERMES_HOSTED_PROVIDER_KEYS.some((name) => nonEmptyDotenvValue(secrets, name));
|
|
57820
57999
|
let configuredDefault = null;
|
|
57821
58000
|
try {
|
|
57822
|
-
configuredDefault = hermesConfigDefault(readFileSync30(
|
|
58001
|
+
configuredDefault = hermesConfigDefault(readFileSync30(join50(dir, "config.yaml"), "utf8"));
|
|
57823
58002
|
} catch {
|
|
57824
58003
|
}
|
|
57825
58004
|
const configuredProvider = configuredDefault?.provider.toLowerCase() ?? "";
|
|
@@ -57864,7 +58043,7 @@ function oauthRowSignedIn(row, now) {
|
|
|
57864
58043
|
return present(row.access_token) && notExpired(row, now);
|
|
57865
58044
|
}
|
|
57866
58045
|
function hermesSignedInProviders(env = process.env, now = Date.now()) {
|
|
57867
|
-
const store = record4(readJson(
|
|
58046
|
+
const store = record4(readJson(join50(hermesHome(env), "auth.json")));
|
|
57868
58047
|
const out = /* @__PURE__ */ new Set();
|
|
57869
58048
|
if (!store) return out;
|
|
57870
58049
|
const providers = record4(store.providers) ?? {};
|
|
@@ -57888,7 +58067,7 @@ function hermesZaiCodingPlan(env = process.env) {
|
|
|
57888
58067
|
const dir = hermesHome(env);
|
|
57889
58068
|
let secrets = "";
|
|
57890
58069
|
try {
|
|
57891
|
-
secrets = readFileSync30(
|
|
58070
|
+
secrets = readFileSync30(join50(dir, ".env"), "utf8");
|
|
57892
58071
|
} catch {
|
|
57893
58072
|
}
|
|
57894
58073
|
const keyed2 = ["GLM_API_KEY", "ZAI_API_KEY", "Z_AI_API_KEY"].some((name) => present(env[name]) || nonEmptyDotenvValue(secrets, name));
|
|
@@ -57896,21 +58075,21 @@ function hermesZaiCodingPlan(env = process.env) {
|
|
|
57896
58075
|
const coding = (url2) => typeof url2 === "string" && /\/api\/coding\/paas\//i.test(url2);
|
|
57897
58076
|
const override = present(env.GLM_BASE_URL) ? env.GLM_BASE_URL : nonEmptyDotenvValue(secrets, "GLM_BASE_URL");
|
|
57898
58077
|
if (override) return coding(override);
|
|
57899
|
-
const detected = record4(record4(record4(record4(readJson(
|
|
58078
|
+
const detected = record4(record4(record4(record4(readJson(join50(dir, "auth.json")))?.providers)?.zai)?.detected_endpoint);
|
|
57900
58079
|
return coding(detected?.base_url);
|
|
57901
58080
|
}
|
|
57902
58081
|
function hermesZaiPlanHosts(options, codingPlan) {
|
|
57903
58082
|
return codingPlan ? options.map((option) => option.provider === "zai" ? { ...option, provider: "zai-coding-plan" } : option) : [...options];
|
|
57904
58083
|
}
|
|
57905
58084
|
function hermesCachedModels(home, provider) {
|
|
57906
|
-
const catalog2 = record4(record4(record4(readJson(
|
|
58085
|
+
const catalog2 = record4(record4(record4(readJson(join50(home, "cache", "model_catalog.json")))?.providers)?.[provider]);
|
|
57907
58086
|
const name = String(record4(catalog2?.metadata)?.display_name ?? "").trim() || provider;
|
|
57908
58087
|
const rows = Array.isArray(catalog2?.models) ? catalog2.models.map(record4).filter((row) => row && present(row.id)) : [];
|
|
57909
58088
|
if (rows.length) {
|
|
57910
58089
|
const ordered = [...rows.filter((row) => row.default === true), ...rows.filter((row) => row.default !== true)];
|
|
57911
58090
|
return { ids: ordered.map((row) => String(row.id).trim()), name };
|
|
57912
58091
|
}
|
|
57913
|
-
const cached3 = record4(record4(readJson(
|
|
58092
|
+
const cached3 = record4(record4(readJson(join50(home, "provider_models_cache.json")))?.[provider])?.models;
|
|
57914
58093
|
return { ids: Array.isArray(cached3) ? cached3.filter(present).map((id) => String(id).trim()) : [], name };
|
|
57915
58094
|
}
|
|
57916
58095
|
function hermesAuthStoreModels(env = process.env, now = Date.now()) {
|
|
@@ -57928,7 +58107,7 @@ function hermesConfiguredHostModel(env = process.env) {
|
|
|
57928
58107
|
const home = hermesHome(env);
|
|
57929
58108
|
let configured = null;
|
|
57930
58109
|
try {
|
|
57931
|
-
configured = hermesConfigDefault(readFileSync30(
|
|
58110
|
+
configured = hermesConfigDefault(readFileSync30(join50(home, "config.yaml"), "utf8"));
|
|
57932
58111
|
} catch {
|
|
57933
58112
|
return null;
|
|
57934
58113
|
}
|
|
@@ -58103,6 +58282,8 @@ var init_hermes = __esm({
|
|
|
58103
58282
|
// a longer idle window than the default (a rejected key is caught sooner,
|
|
58104
58283
|
// from its log, by the core's stderr check).
|
|
58105
58284
|
promptIdleMs: 3e5,
|
|
58285
|
+
mcpServerLimit: { count: 16, bytes: 56e3 },
|
|
58286
|
+
// its gateway refuses a 17th, or 65536 bytes once it adds its own fields
|
|
58106
58287
|
loginNote: "Hermes CLI is not installed",
|
|
58107
58288
|
// No install command: setup never installs Hermes (Erick, 2026-11-08).
|
|
58108
58289
|
// Nous Research signs in with a Nous Portal API key instead
|
|
@@ -58129,12 +58310,7 @@ var init_hermes = __esm({
|
|
|
58129
58310
|
async configureSession({ request, sessionId, turn }) {
|
|
58130
58311
|
const native = hermesAcpModelId(turn.model);
|
|
58131
58312
|
if (!native) return;
|
|
58132
|
-
await applySetting2(
|
|
58133
|
-
request,
|
|
58134
|
-
"session/set_model",
|
|
58135
|
-
{ sessionId, modelId: native },
|
|
58136
|
-
`model "${native}"`
|
|
58137
|
-
);
|
|
58313
|
+
await applySetting2(request, "session/set_model", { sessionId, modelId: native }, `model "${native}"`);
|
|
58138
58314
|
},
|
|
58139
58315
|
buildPromptText: (turn) => turn.system ? `${turn.system}
|
|
58140
58316
|
|
|
@@ -58146,7 +58322,7 @@ ${turn.text}` : turn.text
|
|
|
58146
58322
|
|
|
58147
58323
|
// server/drivers/acp/custom.ts
|
|
58148
58324
|
import { homedir as homedir27 } from "node:os";
|
|
58149
|
-
import { basename as basename9, join as
|
|
58325
|
+
import { basename as basename9, join as join51 } from "node:path";
|
|
58150
58326
|
function isAtomicEngine(instanceId, cli) {
|
|
58151
58327
|
const program = (cli ?? "").trim().split(/\s+/)[0] ?? "";
|
|
58152
58328
|
return instanceId === "atomic-engine" || basename9(program) === "atomic";
|
|
@@ -58171,7 +58347,7 @@ async function customAcpSnapshot(env, cli, instanceId) {
|
|
|
58171
58347
|
return { state: "available", version: version2, authenticated: true };
|
|
58172
58348
|
}
|
|
58173
58349
|
function atomicEngineHome2(env) {
|
|
58174
|
-
return env.HERMES_HOME ||
|
|
58350
|
+
return env.HERMES_HOME || join51(env.HOME || env.USERPROFILE || homedir27(), ".atomic");
|
|
58175
58351
|
}
|
|
58176
58352
|
function applyAtomicEngineAccounts(env, instanceId, cli, accounts = currentAtomicEngineAccounts) {
|
|
58177
58353
|
if (!isAtomicEngine(instanceId, cli)) return;
|
|
@@ -58270,6 +58446,9 @@ var init_custom = __esm({
|
|
|
58270
58446
|
throw new Error(`Atomic Engine rejected model "${modelId}" via session/set_model: ${error51.message}`);
|
|
58271
58447
|
}
|
|
58272
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,
|
|
58273
58452
|
defaultCli: "",
|
|
58274
58453
|
nativeSource: "custom.acp",
|
|
58275
58454
|
loginNote: CONFIGURE_HINT,
|
|
@@ -58296,6 +58475,8 @@ var init_custom = __esm({
|
|
|
58296
58475
|
driverKind: "atomicEngine",
|
|
58297
58476
|
displayName: "Atomic Engine",
|
|
58298
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,
|
|
58299
58480
|
async configureSession(context) {
|
|
58300
58481
|
await support11.configureSession?.(context);
|
|
58301
58482
|
const modeId = context.turn.approvalMode === "plan" ? "atomic-plan-v1" : "default";
|
|
@@ -58407,7 +58588,7 @@ var init_ollama_cloud = __esm({
|
|
|
58407
58588
|
nativeLog: {
|
|
58408
58589
|
source: "ollama-cloud.chat.completions",
|
|
58409
58590
|
outgoing: (_turn, messages, model) => ({ model, messageCount: messages.length }),
|
|
58410
|
-
incoming: ({ text:
|
|
58591
|
+
incoming: ({ text: text7, reasoning, usage }) => ({ textLength: text7.length, reasoningLength: reasoning.length, usage })
|
|
58411
58592
|
}
|
|
58412
58593
|
});
|
|
58413
58594
|
}
|
|
@@ -58563,8 +58744,8 @@ var init_openai_compat = __esm({
|
|
|
58563
58744
|
nativeLog: {
|
|
58564
58745
|
source: "openai-compat.chat.completions",
|
|
58565
58746
|
outgoing: (_turn, messages, model) => ({ model, messageCount: messages.length }),
|
|
58566
|
-
incoming: ({ text:
|
|
58567
|
-
textLength:
|
|
58747
|
+
incoming: ({ text: text7, reasoning, usage }) => ({
|
|
58748
|
+
textLength: text7.length,
|
|
58568
58749
|
reasoningLength: reasoning.length,
|
|
58569
58750
|
usage
|
|
58570
58751
|
})
|
|
@@ -58576,9 +58757,9 @@ var init_openai_compat = __esm({
|
|
|
58576
58757
|
});
|
|
58577
58758
|
|
|
58578
58759
|
// server/drivers/pi.ts
|
|
58579
|
-
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";
|
|
58580
58761
|
import { homedir as homedir28, tmpdir as tmpdir7 } from "node:os";
|
|
58581
|
-
import { join as
|
|
58762
|
+
import { join as join52 } from "node:path";
|
|
58582
58763
|
function readPiPromptImages(turn) {
|
|
58583
58764
|
return (turn.images ?? []).map((image) => ({
|
|
58584
58765
|
type: "image",
|
|
@@ -58700,7 +58881,7 @@ async function applyPiLocalCatalog(catalog2, env = process.env, fetchImpl = fetc
|
|
|
58700
58881
|
return preferPiInjectRows(await mergeLocalInject(catalog2, env, fetchImpl));
|
|
58701
58882
|
}
|
|
58702
58883
|
function piAgentDir(env) {
|
|
58703
|
-
return
|
|
58884
|
+
return join52(env.HOME || env.USERPROFILE || homedir28(), ".pi", "agent");
|
|
58704
58885
|
}
|
|
58705
58886
|
function ensurePiInjectModel(modelId, env = process.env) {
|
|
58706
58887
|
const split = splitPiModel(modelId);
|
|
@@ -58711,9 +58892,9 @@ function ensurePiInjectModel(modelId, env = process.env) {
|
|
|
58711
58892
|
if (!host) return split;
|
|
58712
58893
|
const dir = piAgentDir(env);
|
|
58713
58894
|
mkdirSync26(dir, { recursive: true });
|
|
58714
|
-
const path4 =
|
|
58895
|
+
const path4 = join52(dir, "models.json");
|
|
58715
58896
|
let root = { providers: {} };
|
|
58716
|
-
if (
|
|
58897
|
+
if (existsSync26(path4)) {
|
|
58717
58898
|
try {
|
|
58718
58899
|
const parsed = JSON.parse(readFileSync31(path4, "utf8"));
|
|
58719
58900
|
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
@@ -58931,9 +59112,9 @@ var init_pi = __esm({
|
|
|
58931
59112
|
const mcpServers = buildMcpServers(turn);
|
|
58932
59113
|
let mcpTempDir = null;
|
|
58933
59114
|
if (mcpServers) {
|
|
58934
|
-
mcpTempDir = mkdtempSync5(
|
|
59115
|
+
mcpTempDir = mkdtempSync5(join52(tmpdir7(), "omb-pi-mcp-"));
|
|
58935
59116
|
try {
|
|
58936
|
-
writeFileSync22(
|
|
59117
|
+
writeFileSync22(join52(mcpTempDir, "mcp.json"), JSON.stringify({ mcpServers }), { mode: 384 });
|
|
58937
59118
|
} catch (err) {
|
|
58938
59119
|
try {
|
|
58939
59120
|
rmSync11(mcpTempDir, { recursive: true, force: true });
|
|
@@ -58952,7 +59133,7 @@ var init_pi = __esm({
|
|
|
58952
59133
|
env: piEnvironment({
|
|
58953
59134
|
...process.env,
|
|
58954
59135
|
...input.environment,
|
|
58955
|
-
...mcpServers && mcpTempDir ? { OMB_MCP_CONFIG:
|
|
59136
|
+
...mcpServers && mcpTempDir ? { OMB_MCP_CONFIG: join52(mcpTempDir, "mcp.json") } : {}
|
|
58956
59137
|
})
|
|
58957
59138
|
});
|
|
58958
59139
|
} catch (err) {
|
|
@@ -58989,10 +59170,10 @@ var init_pi = __esm({
|
|
|
58989
59170
|
child.stdin.write(JSON.stringify(obj) + "\n");
|
|
58990
59171
|
};
|
|
58991
59172
|
const flushAssistantText = () => {
|
|
58992
|
-
const
|
|
59173
|
+
const text7 = assistantText;
|
|
58993
59174
|
assistantText = "";
|
|
58994
|
-
if (!
|
|
58995
|
-
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 });
|
|
58996
59177
|
};
|
|
58997
59178
|
const settle = (ok, stopReason, usage) => {
|
|
58998
59179
|
if (settled) return;
|
|
@@ -59099,7 +59280,7 @@ var init_pi = __esm({
|
|
|
59099
59280
|
const mcpTool = isQuestion ? null : piMcpToolRef(
|
|
59100
59281
|
evt.title,
|
|
59101
59282
|
customServerNames,
|
|
59102
|
-
mcpTempDir ?
|
|
59283
|
+
mcpTempDir ? join52(mcpTempDir, PI_TOOL_HINTS_FILE) : null
|
|
59103
59284
|
);
|
|
59104
59285
|
emit({
|
|
59105
59286
|
...base3(threadId, turnId),
|
|
@@ -59423,7 +59604,7 @@ var init_mistral = __esm({
|
|
|
59423
59604
|
nativeLog: {
|
|
59424
59605
|
source: "mistral.chat.completions",
|
|
59425
59606
|
outgoing: (_turn, messages, model) => ({ model, messageCount: messages.length }),
|
|
59426
|
-
incoming: ({ text:
|
|
59607
|
+
incoming: ({ text: text7, usage }) => ({ textLength: text7.length, usage })
|
|
59427
59608
|
}
|
|
59428
59609
|
});
|
|
59429
59610
|
}
|
|
@@ -59434,14 +59615,14 @@ var init_mistral = __esm({
|
|
|
59434
59615
|
// server/drivers/minimax.ts
|
|
59435
59616
|
import { readFileSync as readFileSync32 } from "node:fs";
|
|
59436
59617
|
import { homedir as homedir29 } from "node:os";
|
|
59437
|
-
import { join as
|
|
59618
|
+
import { join as join53 } from "node:path";
|
|
59438
59619
|
function normalizedApiUrl(value) {
|
|
59439
59620
|
const root = value.trim().replace(/\/+$/, "");
|
|
59440
59621
|
return root.endsWith("/v1") ? root : `${root}/v1`;
|
|
59441
59622
|
}
|
|
59442
59623
|
function loadLocalMiniMaxConfig(home = homedir29()) {
|
|
59443
59624
|
try {
|
|
59444
|
-
const raw = localConfigSchema.parse(JSON.parse(readFileSync32(
|
|
59625
|
+
const raw = localConfigSchema.parse(JSON.parse(readFileSync32(join53(home, ".mmx", "config.json"), "utf8")));
|
|
59445
59626
|
const configuredUrl = raw.base_url?.trim() ? raw.base_url : raw.region === "cn" ? CN_URL : DEFAULT_URL3;
|
|
59446
59627
|
return {
|
|
59447
59628
|
apiKey: raw.api_key?.trim() ?? "",
|
|
@@ -59537,7 +59718,7 @@ var init_minimax = __esm({
|
|
|
59537
59718
|
nativeLog: {
|
|
59538
59719
|
source: "minimax.chat.completions",
|
|
59539
59720
|
outgoing: (_turn, messages, model) => ({ model, messageCount: messages.length }),
|
|
59540
|
-
incoming: ({ text:
|
|
59721
|
+
incoming: ({ text: text7, usage }) => ({ textLength: text7.length, usage })
|
|
59541
59722
|
}
|
|
59542
59723
|
});
|
|
59543
59724
|
}
|
|
@@ -59548,7 +59729,7 @@ var init_minimax = __esm({
|
|
|
59548
59729
|
// server/apple-intelligence.ts
|
|
59549
59730
|
import { spawn as spawn8 } from "node:child_process";
|
|
59550
59731
|
import { accessSync, constants as constants3 } from "node:fs";
|
|
59551
|
-
import { join as
|
|
59732
|
+
import { join as join54 } from "node:path";
|
|
59552
59733
|
function intelligenceErrorMessage(code) {
|
|
59553
59734
|
return MESSAGES[code] ?? `Apple Intelligence failed (${code}).`;
|
|
59554
59735
|
}
|
|
@@ -59556,9 +59737,9 @@ function resolveIntelligenceHelper(env = process.env, platform = process.platfor
|
|
|
59556
59737
|
if (platform !== "darwin" || arch !== "arm64") return null;
|
|
59557
59738
|
const candidates = [
|
|
59558
59739
|
env.ATOMIC_INTELLIGENCE_HELPER,
|
|
59559
|
-
env.OMB_RESOURCES_PATH &&
|
|
59560
|
-
|
|
59561
|
-
|
|
59740
|
+
env.OMB_RESOURCES_PATH && join54(env.OMB_RESOURCES_PATH, HELPER),
|
|
59741
|
+
join54(serverRoot, "..", HELPER),
|
|
59742
|
+
join54(serverRoot, "..", "dist-native", "arm64", HELPER)
|
|
59562
59743
|
];
|
|
59563
59744
|
for (const candidate of candidates) {
|
|
59564
59745
|
if (!candidate) continue;
|
|
@@ -59746,7 +59927,7 @@ var init_apple_intelligence = __esm({
|
|
|
59746
59927
|
"concurrent-requests": "Apple Intelligence is busy. Try again in a moment.",
|
|
59747
59928
|
"timeout": "Apple Intelligence took too long to answer."
|
|
59748
59929
|
};
|
|
59749
|
-
HELPER =
|
|
59930
|
+
HELPER = join54("Atomic Intelligence.app", "Contents", "MacOS", "intelligence-helper");
|
|
59750
59931
|
}
|
|
59751
59932
|
});
|
|
59752
59933
|
|
|
@@ -59816,9 +59997,9 @@ function createAppleIntelligenceInstance(input, deps = {}) {
|
|
|
59816
59997
|
let failure;
|
|
59817
59998
|
try {
|
|
59818
59999
|
const request = shapeRequest(turn, inputBudget(availability.contextSize));
|
|
59819
|
-
const
|
|
59820
|
-
if (!
|
|
59821
|
-
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 });
|
|
59822
60003
|
ok = true;
|
|
59823
60004
|
} catch (error51) {
|
|
59824
60005
|
failure = error51 instanceof Error ? error51.message : String(error51);
|
|
@@ -59895,10 +60076,10 @@ var init_apple_intelligence2 = __esm({
|
|
|
59895
60076
|
INPUT_TOKEN_BUDGET = 6e3;
|
|
59896
60077
|
REPLY_TOKENS = 1500;
|
|
59897
60078
|
CHARS_PER_TOKEN = 4;
|
|
59898
|
-
estimateTokens = (
|
|
59899
|
-
clip = (
|
|
60079
|
+
estimateTokens = (text7) => Math.ceil(text7.length / CHARS_PER_TOKEN);
|
|
60080
|
+
clip = (text7, tokens) => {
|
|
59900
60081
|
const chars = Math.max(0, tokens * CHARS_PER_TOKEN);
|
|
59901
|
-
return
|
|
60082
|
+
return text7.length <= chars ? text7 : `${text7.slice(0, Math.max(0, chars - 1))}\u2026`;
|
|
59902
60083
|
};
|
|
59903
60084
|
configSchema4 = external_exports.object({}).passthrough();
|
|
59904
60085
|
AppleIntelligenceDriver = {
|
|
@@ -60105,7 +60286,7 @@ __export(cli_setup_exports, {
|
|
|
60105
60286
|
});
|
|
60106
60287
|
import { spawn as spawn9 } from "node:child_process";
|
|
60107
60288
|
import { readFileSync as readFileSync33 } from "node:fs";
|
|
60108
|
-
import { join as
|
|
60289
|
+
import { join as join55, resolve as resolve12 } from "node:path";
|
|
60109
60290
|
import { randomUUID as randomUUID17 } from "node:crypto";
|
|
60110
60291
|
async function inspect2(id, entry) {
|
|
60111
60292
|
const registry2 = new ProviderRegistry(BUILT_IN_DRIVERS);
|
|
@@ -60142,7 +60323,7 @@ function assertDataDir(dataDir) {
|
|
|
60142
60323
|
}
|
|
60143
60324
|
function checkStoredConfig(dataDir) {
|
|
60144
60325
|
try {
|
|
60145
|
-
parseStoredConfig(JSON.parse(readFileSync33(
|
|
60326
|
+
parseStoredConfig(JSON.parse(readFileSync33(join55(dataDir, "config.json"), "utf8")));
|
|
60146
60327
|
} catch (error51) {
|
|
60147
60328
|
if (error51.code === "ENOENT") return;
|
|
60148
60329
|
throw new Error("Existing config.json could not be read or validated. Setup has not changed it; repair it before continuing.");
|
|
@@ -60554,9 +60735,9 @@ async function runTerminal(options, io2) {
|
|
|
60554
60735
|
var import_qrcode_terminal = __toESM(require_main(), 1);
|
|
60555
60736
|
import { spawn as spawn10 } from "node:child_process";
|
|
60556
60737
|
import { randomBytes as randomBytes4 } from "node:crypto";
|
|
60557
|
-
import { closeSync as
|
|
60738
|
+
import { closeSync as closeSync7, existsSync as existsSync27, mkdirSync as mkdirSync27, openSync as openSync7, readFileSync as readFileSync34 } from "node:fs";
|
|
60558
60739
|
import { homedir as homedir30 } from "node:os";
|
|
60559
|
-
import { dirname as dirname13, join as
|
|
60740
|
+
import { dirname as dirname13, join as join56, resolve as resolve13 } from "node:path";
|
|
60560
60741
|
import { createInterface as createInterface2 } from "node:readline/promises";
|
|
60561
60742
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
60562
60743
|
|
|
@@ -61189,10 +61370,10 @@ async function verifyHostedEndpoint(endpoint, { fetchImpl, timeoutSignal, timeou
|
|
|
61189
61370
|
signal: cancellationSignal ? AbortSignal.any([requestSignal, cancellationSignal]) : requestSignal
|
|
61190
61371
|
});
|
|
61191
61372
|
if (!response.ok) return false;
|
|
61192
|
-
const
|
|
61193
|
-
if (Buffer.byteLength(
|
|
61373
|
+
const text7 = await response.text();
|
|
61374
|
+
if (Buffer.byteLength(text7) > 4096) return false;
|
|
61194
61375
|
try {
|
|
61195
|
-
return JSON.parse(
|
|
61376
|
+
return JSON.parse(text7)?.app === "openmausbot";
|
|
61196
61377
|
} catch {
|
|
61197
61378
|
return false;
|
|
61198
61379
|
}
|
|
@@ -62105,8 +62286,8 @@ function isSecretParameter(name) {
|
|
|
62105
62286
|
function keyLikeSegment(segment) {
|
|
62106
62287
|
return (segment.match(/[A-Za-z0-9]{16,}/g) ?? []).some((run2) => /\d/.test(run2) && /[A-Za-z]/.test(run2));
|
|
62107
62288
|
}
|
|
62108
|
-
function maskUrlSecrets(
|
|
62109
|
-
return
|
|
62289
|
+
function maskUrlSecrets(text7) {
|
|
62290
|
+
return text7.replace(/\b([a-z][\w+.-]*:\/\/)([^\s/?#]*)([^\s?#]*)([^\s]*)/gi, (_all, scheme, authority, path4, rest) => {
|
|
62110
62291
|
const at2 = authority.lastIndexOf("@");
|
|
62111
62292
|
const host = at2 >= 0 ? `${HIDDEN}@${authority.slice(at2 + 1)}` : authority;
|
|
62112
62293
|
const maskedPath = path4.split("/").map((segment) => keyLikeSegment(segment) ? HIDDEN : segment).join("/");
|
|
@@ -62144,8 +62325,8 @@ function auditValues(values) {
|
|
|
62144
62325
|
const last = segments.at(-1) ?? path4;
|
|
62145
62326
|
const opaque = segments.slice(0, -1).some((segment) => OPAQUE_MAP.test(segment));
|
|
62146
62327
|
const scrubbed = (isSecretName3(last) || opaque) && value !== void 0 && value !== null && value !== "" ? HIDDEN : scrub(value, 0, OPAQUE_MAP.test(last));
|
|
62147
|
-
const
|
|
62148
|
-
out[path4] =
|
|
62328
|
+
const text7 = JSON.stringify(scrubbed);
|
|
62329
|
+
out[path4] = text7 !== void 0 && text7.length > MAX_VALUE_CHARS ? "[large value]" : scrubbed ?? null;
|
|
62149
62330
|
}
|
|
62150
62331
|
return out;
|
|
62151
62332
|
}
|
|
@@ -62539,9 +62720,9 @@ async function startCaddy(options) {
|
|
|
62539
62720
|
});
|
|
62540
62721
|
let output = "";
|
|
62541
62722
|
const receive = (chunk) => {
|
|
62542
|
-
const
|
|
62543
|
-
if (output.length < 16384) output +=
|
|
62544
|
-
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/)) {
|
|
62545
62726
|
if (!line.trim()) continue;
|
|
62546
62727
|
if (/"level":"(warn|error)"/.test(line) || /^\S+\s+(WARN|ERROR)/.test(line) || !line.startsWith("{")) options.log?.(`caddy: ${line.slice(0, 400)}`);
|
|
62547
62728
|
}
|
|
@@ -62893,16 +63074,16 @@ var TEXT_COLORS = {
|
|
|
62893
63074
|
dark: { accent: [[0, 179, 152], 36], gold: [[242, 169, 0], 214] },
|
|
62894
63075
|
unknown: { accent: [[0, 128, 108], 30], gold: [[168, 100, 0], 130] }
|
|
62895
63076
|
};
|
|
62896
|
-
function paint(
|
|
62897
|
-
if (depth === "none") return
|
|
63077
|
+
function paint(text7, role, depth, background, bold) {
|
|
63078
|
+
if (depth === "none") return text7;
|
|
62898
63079
|
const weight = bold ? "1;" : "";
|
|
62899
|
-
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`;
|
|
62900
63081
|
const [triple, index] = TEXT_COLORS[background][role];
|
|
62901
|
-
if (depth === "256") return `\x1B[${weight}38;5;${index}m${
|
|
62902
|
-
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`;
|
|
62903
63084
|
}
|
|
62904
|
-
function quiet(
|
|
62905
|
-
return depth === "none" ?
|
|
63085
|
+
function quiet(text7, depth) {
|
|
63086
|
+
return depth === "none" ? text7 : `\x1B[2m${text7}\x1B[0m`;
|
|
62906
63087
|
}
|
|
62907
63088
|
function renderBanner(input) {
|
|
62908
63089
|
const random = input.random ?? Math.random;
|
|
@@ -62910,7 +63091,7 @@ function renderBanner(input) {
|
|
|
62910
63091
|
const greeting = pick2(GREETINGS);
|
|
62911
63092
|
const tip = pick2(TIPS);
|
|
62912
63093
|
const { depth, background } = input;
|
|
62913
|
-
const
|
|
63094
|
+
const text7 = [
|
|
62914
63095
|
`${paint("Atomic", "accent", depth, background, true)} by Chibitek`,
|
|
62915
63096
|
quiet(`Version ${input.version}`, depth),
|
|
62916
63097
|
input.account ? `Signed in as ${input.account}` : quiet("Not signed in to an Atomic account", depth),
|
|
@@ -62919,19 +63100,19 @@ function renderBanner(input) {
|
|
|
62919
63100
|
`${paint("Tip:", "gold", depth, background, true)} ${tip}`
|
|
62920
63101
|
];
|
|
62921
63102
|
const columns = input.columns ?? 80;
|
|
62922
|
-
if (columns < 20) return `${
|
|
63103
|
+
if (columns < 20) return `${text7.join("\n")}
|
|
62923
63104
|
`;
|
|
62924
63105
|
const mark = chibiAnsiLines(depth, background === "light" ? "light" : "dark");
|
|
62925
63106
|
const widest = Math.max(...[greeting, `Tip: ${tip}`, input.account ? `Signed in as ${input.account}` : ""].map((l) => l.length));
|
|
62926
63107
|
if (columns < 16 + 3 + Math.min(widest, 44)) return `${mark.map((line) => line.trimEnd()).join("\n")}
|
|
62927
63108
|
|
|
62928
|
-
${
|
|
63109
|
+
${text7.join("\n")}
|
|
62929
63110
|
`;
|
|
62930
|
-
const rows = Math.max(mark.length,
|
|
63111
|
+
const rows = Math.max(mark.length, text7.length);
|
|
62931
63112
|
const lines = [];
|
|
62932
63113
|
for (let i2 = 0; i2 < rows; i2 += 1) {
|
|
62933
63114
|
const left = mark[i2] ?? " ".repeat(16);
|
|
62934
|
-
const right =
|
|
63115
|
+
const right = text7[i2] ?? "";
|
|
62935
63116
|
lines.push(right ? `${left} ${right}` : left.trimEnd());
|
|
62936
63117
|
}
|
|
62937
63118
|
return `${lines.join("\n")}
|
|
@@ -63017,8 +63198,8 @@ function agentUnit(spec) {
|
|
|
63017
63198
|
function emptyRegistry(domain2) {
|
|
63018
63199
|
return { version: 1, domain: domain2, nextPort: FLEET_FIRST_PORT, workspaces: {} };
|
|
63019
63200
|
}
|
|
63020
|
-
function parseRegistry(
|
|
63021
|
-
const value = JSON.parse(
|
|
63201
|
+
function parseRegistry(text7) {
|
|
63202
|
+
const value = JSON.parse(text7);
|
|
63022
63203
|
const record6 = value && typeof value === "object" ? value : null;
|
|
63023
63204
|
if (!record6 || record6.version !== 1 || typeof record6.domain !== "string" || typeof record6.nextPort !== "number" || !record6.workspaces || typeof record6.workspaces !== "object") {
|
|
63024
63205
|
throw new Error("fleet.json is not a fleet registry this version understands");
|
|
@@ -63623,14 +63804,14 @@ async function executePlan(steps, deps, io2) {
|
|
|
63623
63804
|
}
|
|
63624
63805
|
function failed(io2, what, output) {
|
|
63625
63806
|
io2.error(`fleet: could not ${what}`);
|
|
63626
|
-
const
|
|
63627
|
-
if (
|
|
63807
|
+
const tail3 = output.trim().split("\n").slice(-6).join("\n");
|
|
63808
|
+
if (tail3) io2.error(tail3);
|
|
63628
63809
|
return 1;
|
|
63629
63810
|
}
|
|
63630
63811
|
function loadRegistry(layout, deps) {
|
|
63631
|
-
const
|
|
63632
|
-
if (
|
|
63633
|
-
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);
|
|
63634
63815
|
}
|
|
63635
63816
|
function planFleetAction(input, deps) {
|
|
63636
63817
|
const layout = fleetLayout(input.root ?? "/");
|
|
@@ -63804,15 +63985,15 @@ import { dirname as dirname5 } from "node:path";
|
|
|
63804
63985
|
var MAX_BODY = 256 * 1024;
|
|
63805
63986
|
function readBody(req) {
|
|
63806
63987
|
return new Promise((resolve14, reject) => {
|
|
63807
|
-
let
|
|
63988
|
+
let text7 = "";
|
|
63808
63989
|
req.on("data", (chunk) => {
|
|
63809
|
-
|
|
63810
|
-
if (
|
|
63990
|
+
text7 += chunk.toString("utf8");
|
|
63991
|
+
if (text7.length > MAX_BODY) reject(Object.assign(new Error("request too large"), { status: 413 }));
|
|
63811
63992
|
});
|
|
63812
63993
|
req.on("end", () => {
|
|
63813
|
-
if (!
|
|
63994
|
+
if (!text7.trim()) return resolve14({});
|
|
63814
63995
|
try {
|
|
63815
|
-
const value = JSON.parse(
|
|
63996
|
+
const value = JSON.parse(text7);
|
|
63816
63997
|
resolve14(value && typeof value === "object" && !Array.isArray(value) ? value : {});
|
|
63817
63998
|
} catch {
|
|
63818
63999
|
reject(Object.assign(new Error("body must be JSON"), { status: 400 }));
|
|
@@ -64029,8 +64210,8 @@ function tailnetNameBlocksHttps(name) {
|
|
|
64029
64210
|
|
|
64030
64211
|
// server/tailscale.ts
|
|
64031
64212
|
init_procs();
|
|
64032
|
-
function classifyTailscaleStderr(
|
|
64033
|
-
const t2 =
|
|
64213
|
+
function classifyTailscaleStderr(text7) {
|
|
64214
|
+
const t2 = text7.toLowerCase();
|
|
64034
64215
|
if (/not logged in|logged out|needs login|please log in/.test(t2)) return "not-logged-in";
|
|
64035
64216
|
if (/is tailscale running|tailscaled is not running|connection refused|failed to connect to local tailscaled/.test(t2)) return "not-running";
|
|
64036
64217
|
if (/rejectedidentifier|reserved format|r-ldh/.test(t2)) return "reserved-name";
|
|
@@ -64485,7 +64666,7 @@ function parseArgs2(argv, env = process.env) {
|
|
|
64485
64666
|
const options = {
|
|
64486
64667
|
command: command === "--help" || command === "-h" ? "help" : command,
|
|
64487
64668
|
port: Number(env.OMB_PORT || 8799),
|
|
64488
|
-
dataDir: env.OMB_DATA_DIR ||
|
|
64669
|
+
dataDir: env.OMB_DATA_DIR || join56(homedir30(), ".atomic-app"),
|
|
64489
64670
|
tailscale: false,
|
|
64490
64671
|
tunnel: false,
|
|
64491
64672
|
client: false,
|
|
@@ -64626,7 +64807,7 @@ async function isWorkspaceRunning(options) {
|
|
|
64626
64807
|
try {
|
|
64627
64808
|
const { status, body } = await api(options.port, "/api/health");
|
|
64628
64809
|
if (status !== 200 || body?.app !== "openmausbot") return false;
|
|
64629
|
-
const expected = readFileSync34(
|
|
64810
|
+
const expected = readFileSync34(join56(options.dataDir, "environment-id"), "utf8").trim();
|
|
64630
64811
|
const descriptor = await api(options.port, "/.well-known/openmausbot/environment");
|
|
64631
64812
|
return /^[0-9a-f-]{36}$/i.test(expected) && descriptor.status === 200 && descriptor.body?.environmentId === expected;
|
|
64632
64813
|
} catch {
|
|
@@ -64738,9 +64919,9 @@ function originOf(link) {
|
|
|
64738
64919
|
return null;
|
|
64739
64920
|
}
|
|
64740
64921
|
}
|
|
64741
|
-
function qrToString(
|
|
64922
|
+
function qrToString(text7) {
|
|
64742
64923
|
let out = "";
|
|
64743
|
-
import_qrcode_terminal.default.generate(
|
|
64924
|
+
import_qrcode_terminal.default.generate(text7, { small: true }, (rendered) => {
|
|
64744
64925
|
out = rendered;
|
|
64745
64926
|
});
|
|
64746
64927
|
return out;
|
|
@@ -64865,9 +65046,9 @@ async function runStatus(options, io2 = defaultIo()) {
|
|
|
64865
65046
|
return code;
|
|
64866
65047
|
}
|
|
64867
65048
|
async function runAccess(options, io2 = defaultIo()) {
|
|
64868
|
-
const file2 =
|
|
65049
|
+
const file2 = join56(options.dataDir, "config.json");
|
|
64869
65050
|
let raw = {};
|
|
64870
|
-
if (
|
|
65051
|
+
if (existsSync27(file2)) {
|
|
64871
65052
|
try {
|
|
64872
65053
|
const parsed = JSON.parse(readFileSync34(file2, "utf8"));
|
|
64873
65054
|
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) throw new Error("not an object");
|
|
@@ -64996,16 +65177,16 @@ async function runLogout(options, io2 = defaultIo()) {
|
|
|
64996
65177
|
return 0;
|
|
64997
65178
|
}
|
|
64998
65179
|
function serverEntry(here = HERE2) {
|
|
64999
|
-
const bundled =
|
|
65180
|
+
const bundled = join56(here, "index.js");
|
|
65000
65181
|
const root = resolve13(here, "..");
|
|
65001
|
-
if (
|
|
65002
|
-
const staticDir2 = [
|
|
65003
|
-
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;
|
|
65004
65185
|
return { command: process.execPath, args: [bundled], staticDir: staticDir2, skillsDir };
|
|
65005
65186
|
}
|
|
65006
|
-
const source2 =
|
|
65007
|
-
const staticDir =
|
|
65008
|
-
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 };
|
|
65009
65190
|
}
|
|
65010
65191
|
async function planTunnel(options, log) {
|
|
65011
65192
|
let access2 = null;
|
|
@@ -65048,7 +65229,7 @@ async function runServe(options, log = console.log) {
|
|
|
65048
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`);
|
|
65049
65230
|
return 1;
|
|
65050
65231
|
}
|
|
65051
|
-
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;
|
|
65052
65233
|
let publicUrl = options.publicUrl;
|
|
65053
65234
|
let tailscale = null;
|
|
65054
65235
|
if (options.tailscale) {
|
|
@@ -65110,10 +65291,10 @@ async function runServe(options, log = console.log) {
|
|
|
65110
65291
|
let child;
|
|
65111
65292
|
try {
|
|
65112
65293
|
if (options.guided) {
|
|
65113
|
-
const logsDir =
|
|
65294
|
+
const logsDir = join56(options.dataDir, "logs");
|
|
65114
65295
|
mkdirSync27(logsDir, { recursive: true, mode: 448 });
|
|
65115
|
-
logPath =
|
|
65116
|
-
logFd =
|
|
65296
|
+
logPath = join56(logsDir, `server-${Date.now()}-${process.pid}.log`);
|
|
65297
|
+
logFd = openSync7(logPath, "wx", 384);
|
|
65117
65298
|
log("\nStarting your workspace\u2026");
|
|
65118
65299
|
}
|
|
65119
65300
|
if (tailscale) {
|
|
@@ -65144,7 +65325,7 @@ async function runServe(options, log = console.log) {
|
|
|
65144
65325
|
}
|
|
65145
65326
|
throw error51;
|
|
65146
65327
|
} finally {
|
|
65147
|
-
if (logFd !== void 0)
|
|
65328
|
+
if (logFd !== void 0) closeSync7(logFd);
|
|
65148
65329
|
process.removeListener("SIGINT", cancelStartup);
|
|
65149
65330
|
process.removeListener("SIGTERM", cancelStartup);
|
|
65150
65331
|
}
|
|
@@ -65316,7 +65497,7 @@ async function runOnboardingCommand(options, io2 = defaultIo(), startServer = ru
|
|
|
65316
65497
|
saveCliStartup2(options.dataDir, startupPreferences(launch));
|
|
65317
65498
|
}
|
|
65318
65499
|
if (options.command === "setup") {
|
|
65319
|
-
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("");
|
|
65320
65501
|
io2.log(`
|
|
65321
65502
|
All set. Start with: chibi${flags ? ` start${flags}` : ""} (or npx @chibitek/chibi without a global install).`);
|
|
65322
65503
|
return 0;
|
|
@@ -65356,15 +65537,15 @@ ${welcomeBanner(options)}
|
|
|
65356
65537
|
switch (options.command) {
|
|
65357
65538
|
case "command":
|
|
65358
65539
|
case "goal": {
|
|
65359
|
-
const
|
|
65360
|
-
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;
|
|
65361
65542
|
if (roomGoal && (!roomGoal[1]?.trim() || (roomGoal[1].startsWith("--") || /^(status|pause|resume|stop|help)(?:\s|$)/.test(roomGoal[1])))) {
|
|
65362
65543
|
console.error("Room goals accept an objective. Personal goal controls and budgets require --bot.");
|
|
65363
65544
|
return 2;
|
|
65364
65545
|
}
|
|
65365
65546
|
const result = await api(options.port, `/api/${options.groupId ? "groups" : "bots"}/${encodeURIComponent(options.groupId ?? options.botId)}/messages`, {
|
|
65366
65547
|
method: "POST",
|
|
65367
|
-
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") })
|
|
65368
65549
|
});
|
|
65369
65550
|
if (result.status >= 400) {
|
|
65370
65551
|
console.error(result.body.error ?? `Server returned ${result.status}`);
|