@chibitek/chibi 0.1.177 → 0.1.179
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/{abnfDiagram-O67JEVCF-D66KKLXq.js → abnfDiagram-O67JEVCF-BFpvXOmW.js} +1 -1
- package/dist/assets/{arc-Chl6g0yq.js → arc-0cz8QAA9.js} +1 -1
- package/dist/assets/{architectureDiagram-NJMV4G6O-ChT8017v.js → architectureDiagram-NJMV4G6O-DxG1U8Tf.js} +1 -1
- package/dist/assets/{blockDiagram-BEXU5L5S-DSOAtPXh.js → blockDiagram-BEXU5L5S-DdpIUUid.js} +1 -1
- package/dist/assets/{c4Diagram-YGBWAQC7-CAyzcis4.js → c4Diagram-YGBWAQC7-CNB5U3O1.js} +1 -1
- package/dist/assets/channel-DktfdxuU.js +1 -0
- package/dist/assets/{chunk-2Q5K7J3B-DG7zWvl1.js → chunk-2Q5K7J3B-DixTESOo.js} +1 -1
- package/dist/assets/{chunk-3FUC2YCW-CNQ37WCV.js → chunk-3FUC2YCW-9KbkQg_1.js} +2 -2
- package/dist/assets/{chunk-5VM5RSS4-Dvv3U9Ci.js → chunk-5VM5RSS4-DMNRleww.js} +1 -1
- package/dist/assets/{chunk-GTNCS2PH-DyQrY0Ij.js → chunk-GTNCS2PH-kxGMXg9R.js} +1 -1
- package/dist/assets/{chunk-GWA4HPMP-BLgrTe-Y.js → chunk-GWA4HPMP-B7sa9Us9.js} +1 -1
- package/dist/assets/{chunk-JWPE2WC7-Bi7RU6mT.js → chunk-JWPE2WC7-BF65Wqy-.js} +1 -1
- package/dist/assets/{chunk-NETBCI7D-bBBVBfAd.js → chunk-NETBCI7D-Du36YO_k.js} +1 -1
- package/dist/assets/{chunk-WEXAMYUT-CE_h60fU.js → chunk-WEXAMYUT-BMTNPIkJ.js} +1 -1
- package/dist/assets/{chunk-XXDRQBXY-f6P9rCRq.js → chunk-XXDRQBXY-BqdQPY5v.js} +1 -1
- package/dist/assets/{classDiagram-v2-NBCMYWYE-6Uq3JzmJ.js → classDiagram-v2-NBCMYWYE-DYSOprmY.js} +1 -1
- package/dist/assets/{cose-bilkent-JH36ORCC-BxvkL31E.js → cose-bilkent-JH36ORCC-DXKY6FnT.js} +1 -1
- package/dist/assets/{cynefin-OW5HDTMX-Dlcwlw2F.js → cynefin-OW5HDTMX-DamnOWMn.js} +1 -1
- package/dist/assets/{cynefinDiagram-VND7K2PF-D3NOeWUy.js → cynefinDiagram-VND7K2PF-Bb-wuGye.js} +1 -1
- package/dist/assets/{dagre-6A5THRUB-IGmT7nsP.js → dagre-6A5THRUB-DVMvGhu7.js} +1 -1
- package/dist/assets/{diagram-22UHCM2B-D0K8tG3k.js → diagram-22UHCM2B-BX4_NJ2M.js} +1 -1
- package/dist/assets/{diagram-3UASUU5V-CSkDkOvw.js → diagram-3UASUU5V-4J3gjVZn.js} +1 -1
- package/dist/assets/{diagram-ATOU4E4O-CX5EXBJ_.js → diagram-ATOU4E4O-Bbune_ll.js} +1 -1
- package/dist/assets/{diagram-CDSNMT55-D0FQ7x1J.js → diagram-CDSNMT55-EEDiwifm.js} +1 -1
- package/dist/assets/{diagram-MLGK6HIB-BymN_w7h.js → diagram-MLGK6HIB-D5lseSZO.js} +1 -1
- package/dist/assets/{diagram-MPIPVDR6-ugKqp8yy.js → diagram-MPIPVDR6-isxlwvOO.js} +1 -1
- package/dist/assets/{ebnfDiagram-ZINNZB2B-DROFb0r3.js → ebnfDiagram-ZINNZB2B-DXhf0QK8.js} +1 -1
- package/dist/assets/{elk-276RUBZZ-CNVCU2l7.js → elk-276RUBZZ-rR6aJBHM.js} +1 -1
- package/dist/assets/{erDiagram-OPXOYQCR-BQj5bZ7y.js → erDiagram-OPXOYQCR-DRIV4t6Y.js} +1 -1
- package/dist/assets/{flowDiagram-KWPJA3E3-C3cBXKRL.js → flowDiagram-KWPJA3E3-BT3z2JmZ.js} +1 -1
- package/dist/assets/{ganttDiagram-FUAMR5RP-CdNdC_Vp.js → ganttDiagram-FUAMR5RP-CR0drs2s.js} +1 -1
- package/dist/assets/{gitGraphDiagram-X574FWY7-v_LM9fGO.js → gitGraphDiagram-X574FWY7-BrjfMmlB.js} +1 -1
- package/dist/assets/{index-fnHp_1ly.js → index-BISPpSBx.js} +1 -1
- package/dist/assets/index-CI0vGAif.css +1 -0
- package/dist/assets/{index-UICHeO5x.js → index-DAGHO7rw.js} +197 -195
- package/dist/assets/{infoDiagram-VRGFBTTK-0fzWO21Z.js → infoDiagram-VRGFBTTK-fIajbwUK.js} +1 -1
- package/dist/assets/{ishikawaDiagram-OU5B5YK6-BmqyKWCK.js → ishikawaDiagram-OU5B5YK6-DlOC_sEC.js} +1 -1
- package/dist/assets/{journeyDiagram-ZHPQQLJL-BSihTjOI.js → journeyDiagram-ZHPQQLJL-BY4NF3Iq.js} +1 -1
- package/dist/assets/{kanban-definition-PNTS6WVX-LAP03jiI.js → kanban-definition-PNTS6WVX-CjcD7Qp-.js} +1 -1
- package/dist/assets/{linear-BoSfZT4X.js → linear-D2XvBjOb.js} +1 -1
- package/dist/assets/{mermaid.core-KciMRs_R.js → mermaid.core-DbXyvZNy.js} +5 -5
- package/dist/assets/{mindmap-definition-NLK3R4M7-CEGLBEfc.js → mindmap-definition-NLK3R4M7-rjla1J-s.js} +1 -1
- package/dist/assets/{pegDiagram-GJSIUBJH-DLwMHvoR.js → pegDiagram-GJSIUBJH-hvEPNypQ.js} +1 -1
- package/dist/assets/{pieDiagram-5QR66LMP-DHnlu96s.js → pieDiagram-5QR66LMP-D-jjzmff.js} +1 -1
- package/dist/assets/{quadrantDiagram-O4NWA36T-C_aIseXA.js → quadrantDiagram-O4NWA36T-DJsTKR54.js} +1 -1
- package/dist/assets/{railroadDiagram-XR7U4H2S-DOXDQ14n.js → railroadDiagram-XR7U4H2S-CgA8NcMY.js} +1 -1
- package/dist/assets/{requirementDiagram-PLB6GJNP-C49u1hle.js → requirementDiagram-PLB6GJNP-D5BkeVLA.js} +1 -1
- package/dist/assets/{sankeyDiagram-IPEJSGJF-TO8i3aYk.js → sankeyDiagram-IPEJSGJF-lEfgZleC.js} +1 -1
- package/dist/assets/{sequenceDiagram-PO4LG4MO-CqByM3om.js → sequenceDiagram-PO4LG4MO-iDpAQv2z.js} +1 -1
- package/dist/assets/{sizeCapture-INFHLROL-BVsTiKjg.js → sizeCapture-INFHLROL-hEJsAOhI.js} +1 -1
- package/dist/assets/{stateDiagram-v2-GCMORJYK-0AUlHnV-.js → stateDiagram-v2-GCMORJYK-CKDZvZXj.js} +1 -1
- package/dist/assets/{swimlanes-2SLR337P-D_wUrvq4.js → swimlanes-2SLR337P-_dOmzve2.js} +1 -1
- package/dist/assets/swimlanesDiagram-TC7HE7FX-BROCOsEt.js +8 -0
- package/dist/assets/{timeline-definition-EJHVYXUP-qf2wxQef.js → timeline-definition-EJHVYXUP-9GwS2a9Y.js} +1 -1
- package/dist/assets/{usecaseDiagram-POWQR4AR-Blqc8FjE.js → usecaseDiagram-POWQR4AR-CqJl0zf1.js} +1 -1
- package/dist/assets/{vennDiagram-UO4OBE2U-Df3HJl0f.js → vennDiagram-UO4OBE2U-CGQiSSZm.js} +1 -1
- package/dist/assets/{wardleyDiagram-VNRHLVJA-B-QhMirM.js → wardleyDiagram-VNRHLVJA-D4KBo3Q_.js} +1 -1
- package/dist/assets/{xychartDiagram-PMCCYNJV-DsZdyUlm.js → xychartDiagram-PMCCYNJV-BgvRJLNL.js} +1 -1
- package/dist/index.html +2 -2
- package/dist-server/drivers/agents-proxy.js +3 -2
- package/dist-server/index.js +1843 -1624
- package/dist-server/openmausbot.js +652 -491
- package/dist-server/pair-cli.js +652 -491
- package/dist-server/server/drivers/acp/core.js +10 -37
- package/dist-server/server/drivers/acp/droid.js +1 -0
- package/dist-server/server/drivers/acp/gemini.js +10 -0
- package/dist-server/server/drivers/acp/kimi.js +1 -0
- package/dist-server/server/drivers/acp/mode-readback.js +72 -0
- package/dist-server/server/drivers/acp/qwen.js +12 -0
- package/dist-server/server/drivers/acp/tool-log.js +40 -0
- package/dist-server/server/drivers/acp/vibe.js +14 -1
- package/dist-server/server/drivers/agents-catalog.js +2 -2
- package/dist-server/server/drivers/chat-mcp-tools.js +21 -1
- package/dist-server/server/drivers/openai-chat.js +1 -1
- package/dist-server/server/engine-failover.js +15 -0
- package/dist-server/server/engine-failure.js +1 -1
- package/dist-server/server/engine-tiers.js +1 -1
- package/dist-server/server/free-turn-guard.js +32 -0
- package/dist-server/server/incidents.js +9 -2
- package/dist-server/server/index.js +46 -26
- package/dist-server/server/mcp-secrets.js +33 -5
- package/dist-server/server/routes/engine-tiers.js +3 -1
- package/dist-server/server/vault/routes.js +1 -1
- package/dist-server/server/vault/store.js +1 -1
- package/dist-server/shared/approval-readback.js +52 -0
- package/dist-server/shared/provider-accounts.js +4 -4
- package/dist-server/shared/vault-csv.js +32 -10
- package/package.json +1 -1
- package/dist/assets/channel-DGEfaLnD.js +0 -1
- package/dist/assets/index-D17LLrYN.css +0 -1
- package/dist/assets/swimlanesDiagram-TC7HE7FX-HihkzjzX.js +0 -8
|
@@ -1111,9 +1111,9 @@ var require_main = __commonJS({
|
|
|
1111
1111
|
});
|
|
1112
1112
|
|
|
1113
1113
|
// shared/redact.ts
|
|
1114
|
-
function redactSecretsInText(
|
|
1115
|
-
if (!
|
|
1116
|
-
let out =
|
|
1114
|
+
function redactSecretsInText(text5) {
|
|
1115
|
+
if (!text5 || text5.length < 8) return text5;
|
|
1116
|
+
let out = text5;
|
|
1117
1117
|
out = out.replace(PEM_BLOCK, (_m, open2, body, close) => `${open2}
|
|
1118
1118
|
${mask(body.trim())}
|
|
1119
1119
|
${close}`);
|
|
@@ -8511,8 +8511,8 @@ var capitalizeFirstCharacter, error28;
|
|
|
8511
8511
|
var init_lt = __esm({
|
|
8512
8512
|
"node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/locales/lt.js"() {
|
|
8513
8513
|
init_util();
|
|
8514
|
-
capitalizeFirstCharacter = (
|
|
8515
|
-
return
|
|
8514
|
+
capitalizeFirstCharacter = (text5) => {
|
|
8515
|
+
return text5.charAt(0).toUpperCase() + text5.slice(1);
|
|
8516
8516
|
};
|
|
8517
8517
|
error28 = () => {
|
|
8518
8518
|
const Sizable = {
|
|
@@ -16470,11 +16470,11 @@ function isNodeScript(file2, host) {
|
|
|
16470
16470
|
return /\.[cm]?js$/i.test(file2) || !extname(file2) && hasNodeShebang(file2, host);
|
|
16471
16471
|
}
|
|
16472
16472
|
function parseCmdShim(shim, host) {
|
|
16473
|
-
const
|
|
16474
|
-
if (
|
|
16473
|
+
const text5 = host.readText(shim);
|
|
16474
|
+
if (text5 === null) return null;
|
|
16475
16475
|
const dir = dirname4(shim);
|
|
16476
|
-
const npmEntry = /^SET "NP[MX]_CLI_JS=%~dp0\\([^"]+)"/im.exec(
|
|
16477
|
-
const targets = [...npmEntry ? [npmEntry] : [], ...
|
|
16476
|
+
const npmEntry = /^SET "NP[MX]_CLI_JS=%~dp0\\([^"]+)"/im.exec(text5);
|
|
16477
|
+
const targets = [...npmEntry ? [npmEntry] : [], ...text5.matchAll(/"%~?dp0%?\\?([^"]+)"/g)].map((m3) => join8(dir, m3[1])).filter((p3) => host.isFile(p3) && basename4(p3).toLowerCase() !== "node.exe");
|
|
16478
16478
|
const script = targets.find((p3) => isNodeScript(p3, host));
|
|
16479
16479
|
if (script) return nodeLaunch(script, dir, host);
|
|
16480
16480
|
const exe = targets.find((p3) => [".exe", ".com"].includes(extname(p3).toLowerCase()));
|
|
@@ -16905,9 +16905,9 @@ function runBounded(resolved, opts, cb) {
|
|
|
16905
16905
|
const receive = (which) => (chunk) => {
|
|
16906
16906
|
if (done) return;
|
|
16907
16907
|
bytes += chunk.length;
|
|
16908
|
-
const
|
|
16909
|
-
if (which === "out") stdout2 +=
|
|
16910
|
-
else stderr +=
|
|
16908
|
+
const text5 = chunk.toString("utf8");
|
|
16909
|
+
if (which === "out") stdout2 += text5;
|
|
16910
|
+
else stderr += text5;
|
|
16911
16911
|
if (bytes > maxBuffer) {
|
|
16912
16912
|
stop(Object.assign(new Error(`${which === "out" ? "stdout" : "stderr"} maxBuffer length exceeded`), {
|
|
16913
16913
|
code: "ERR_CHILD_PROCESS_STDIO_MAXBUFFER",
|
|
@@ -16957,8 +16957,8 @@ function probeCli(cli, args, options) {
|
|
|
16957
16957
|
});
|
|
16958
16958
|
});
|
|
16959
16959
|
}
|
|
16960
|
-
function outputTail(
|
|
16961
|
-
return stripVTControlCharacters(
|
|
16960
|
+
function outputTail(text5, lines = 8, chars = 800) {
|
|
16961
|
+
return stripVTControlCharacters(text5).split(/\r?\n/).map((line) => line.trimEnd()).filter((line) => line.trim()).slice(-lines).join("\n").slice(-chars);
|
|
16962
16962
|
}
|
|
16963
16963
|
function describeProbeFailure(cli, args, probe) {
|
|
16964
16964
|
const command = `\`${[cli, ...args].join(" ")}\``;
|
|
@@ -19713,7 +19713,8 @@ var init_provider_accounts = __esm({
|
|
|
19713
19713
|
icon: "google",
|
|
19714
19714
|
config: { url: "https://generativelanguage.googleapis.com/v1beta/openai", apiKeyEnv: "GOOGLE_AI_STUDIO_FREE_API_KEY", model: "", provider: "" },
|
|
19715
19715
|
keyTest: { provider: "openaiCompat", url: "https://generativelanguage.googleapis.com/v1beta/openai" },
|
|
19716
|
-
keyUrl: "https://aistudio.google.com/apikey"
|
|
19716
|
+
keyUrl: "https://aistudio.google.com/apikey",
|
|
19717
|
+
signupUrl: "https://aistudio.google.com/"
|
|
19717
19718
|
},
|
|
19718
19719
|
{
|
|
19719
19720
|
id: "groqFree",
|
|
@@ -19724,7 +19725,8 @@ var init_provider_accounts = __esm({
|
|
|
19724
19725
|
envVar: "GROQ_FREE_API_KEY",
|
|
19725
19726
|
config: { url: "https://api.groq.com/openai/v1", apiKeyEnv: "GROQ_FREE_API_KEY", model: "", provider: "" },
|
|
19726
19727
|
keyTest: { provider: "openaiCompat", url: "https://api.groq.com/openai/v1" },
|
|
19727
|
-
keyUrl: "https://console.groq.com/keys"
|
|
19728
|
+
keyUrl: "https://console.groq.com/keys",
|
|
19729
|
+
signupUrl: "https://console.groq.com/"
|
|
19728
19730
|
},
|
|
19729
19731
|
{
|
|
19730
19732
|
id: "cerebrasFree",
|
|
@@ -19735,7 +19737,8 @@ var init_provider_accounts = __esm({
|
|
|
19735
19737
|
envVar: "CEREBRAS_FREE_API_KEY",
|
|
19736
19738
|
config: { url: "https://api.cerebras.ai/v1", apiKeyEnv: "CEREBRAS_FREE_API_KEY", model: "", provider: "" },
|
|
19737
19739
|
keyTest: { provider: "openaiCompat", url: "https://api.cerebras.ai/v1" },
|
|
19738
|
-
keyUrl: "https://cloud.cerebras.ai/platform/apikeys"
|
|
19740
|
+
keyUrl: "https://cloud.cerebras.ai/platform/apikeys",
|
|
19741
|
+
signupUrl: "https://cloud.cerebras.ai/"
|
|
19739
19742
|
},
|
|
19740
19743
|
{
|
|
19741
19744
|
id: "nvidiaFree",
|
|
@@ -19746,7 +19749,8 @@ var init_provider_accounts = __esm({
|
|
|
19746
19749
|
envVar: "NVIDIA_FREE_API_KEY",
|
|
19747
19750
|
config: { url: "https://integrate.api.nvidia.com/v1", apiKeyEnv: "NVIDIA_FREE_API_KEY", model: "", provider: "" },
|
|
19748
19751
|
keyTest: { provider: "openaiCompat", url: "https://integrate.api.nvidia.com/v1" },
|
|
19749
|
-
keyUrl: "https://build.nvidia.com/settings/api-keys"
|
|
19752
|
+
keyUrl: "https://build.nvidia.com/settings/api-keys",
|
|
19753
|
+
signupUrl: "https://build.nvidia.com/"
|
|
19750
19754
|
}
|
|
19751
19755
|
];
|
|
19752
19756
|
}
|
|
@@ -19923,16 +19927,16 @@ function isSecretName3(name) {
|
|
|
19923
19927
|
}
|
|
19924
19928
|
function looksLikeSecretValue(value) {
|
|
19925
19929
|
if (typeof value !== "string") return false;
|
|
19926
|
-
const
|
|
19927
|
-
if (
|
|
19928
|
-
return AUTH_SCHEME.test(
|
|
19930
|
+
const text5 = value.trim();
|
|
19931
|
+
if (text5.length < 8 || text5.includes("${")) return false;
|
|
19932
|
+
return AUTH_SCHEME.test(text5) || TOKEN_PREFIX.test(text5) || JWT.test(text5) || URL_PASSWORD.test(text5);
|
|
19929
19933
|
}
|
|
19930
19934
|
function isSecretEntry(name, value) {
|
|
19931
19935
|
if (typeof value !== "string") return false;
|
|
19932
|
-
const
|
|
19933
|
-
if (!
|
|
19934
|
-
if (looksLikeSecretValue(
|
|
19935
|
-
return isSecretName3(name) && !PATH_OR_URL.test(
|
|
19936
|
+
const text5 = value.trim();
|
|
19937
|
+
if (!text5 || text5 === MCP_SECRET_PLACEHOLDER || text5.includes("${")) return false;
|
|
19938
|
+
if (looksLikeSecretValue(text5)) return true;
|
|
19939
|
+
return isSecretName3(name) && !PATH_OR_URL.test(text5) && !PLAIN_SETTING.test(text5);
|
|
19936
19940
|
}
|
|
19937
19941
|
function sanitizeMcpSecrets(value) {
|
|
19938
19942
|
const out = {};
|
|
@@ -20080,7 +20084,7 @@ function mcpSecretState(env = process.env) {
|
|
|
20080
20084
|
secrets = {};
|
|
20081
20085
|
}
|
|
20082
20086
|
}
|
|
20083
|
-
const kind = claimed === "os" || claimed === "unavailable" ? claimed : "plaintext";
|
|
20087
|
+
const kind = claimed === "os" || claimed === "unavailable" || claimed === "insecure" ? claimed : "plaintext";
|
|
20084
20088
|
state = { kind, secrets };
|
|
20085
20089
|
return state;
|
|
20086
20090
|
}
|
|
@@ -20120,8 +20124,8 @@ var init_mcp_secrets2 = __esm({
|
|
|
20120
20124
|
});
|
|
20121
20125
|
|
|
20122
20126
|
// server/schema.ts
|
|
20123
|
-
function parseJson(
|
|
20124
|
-
return JSON.parse(
|
|
20127
|
+
function parseJson(text5) {
|
|
20128
|
+
return JSON.parse(text5);
|
|
20125
20129
|
}
|
|
20126
20130
|
function schemaIssue(error51, fallback) {
|
|
20127
20131
|
const issue2 = error51.issues[0];
|
|
@@ -25274,9 +25278,9 @@ var init_local_inject = __esm({
|
|
|
25274
25278
|
|
|
25275
25279
|
// server/drivers/prompt-shape.ts
|
|
25276
25280
|
function permissionKindOfLabel(label) {
|
|
25277
|
-
const
|
|
25278
|
-
if (REJECT_LABEL.test(
|
|
25279
|
-
if (ALLOW_LABEL.test(
|
|
25281
|
+
const text5 = label.trim();
|
|
25282
|
+
if (REJECT_LABEL.test(text5)) return ALWAYS_LABEL.test(text5) ? "reject_always" : "reject_once";
|
|
25283
|
+
if (ALLOW_LABEL.test(text5)) return ALWAYS_LABEL.test(text5) ? "allow_always" : "allow_once";
|
|
25280
25284
|
return null;
|
|
25281
25285
|
}
|
|
25282
25286
|
function isChoicePrompt(prompt) {
|
|
@@ -25456,10 +25460,10 @@ function toolDetailPreview(value) {
|
|
|
25456
25460
|
return result;
|
|
25457
25461
|
};
|
|
25458
25462
|
const safe = redactSecrets(bounded(value));
|
|
25459
|
-
const
|
|
25460
|
-
if (!
|
|
25461
|
-
return
|
|
25462
|
-
[\u2026 preview shortened]` :
|
|
25463
|
+
const text5 = typeof safe === "string" ? safe : JSON.stringify(safe, null, 2);
|
|
25464
|
+
if (!text5?.trim() || text5 === "{}" || text5 === "[]") return void 0;
|
|
25465
|
+
return text5.length > 6e3 ? `${text5.slice(0, 6e3)}
|
|
25466
|
+
[\u2026 preview shortened]` : text5;
|
|
25463
25467
|
}
|
|
25464
25468
|
function fieldsOf(input) {
|
|
25465
25469
|
if (input === null || typeof input !== "object" || Array.isArray(input)) return void 0;
|
|
@@ -25476,8 +25480,8 @@ function askInputSummary(input) {
|
|
|
25476
25480
|
if (typeof fields.question === "string") return cut(fields.question, QUESTION_LIMIT);
|
|
25477
25481
|
if (typeof fields.command === "string") return cut(fields.command, LIMIT);
|
|
25478
25482
|
if (typeof fields.url === "string") return cut(fields.url, LIMIT);
|
|
25479
|
-
const
|
|
25480
|
-
return
|
|
25483
|
+
const text5 = JSON.stringify(fields);
|
|
25484
|
+
return text5 === "{}" ? void 0 : cut(text5, LIMIT);
|
|
25481
25485
|
}
|
|
25482
25486
|
var QUESTION_LIMIT, LIMIT, cut;
|
|
25483
25487
|
var init_tool_summary = __esm({
|
|
@@ -25486,7 +25490,7 @@ var init_tool_summary = __esm({
|
|
|
25486
25490
|
init_redact2();
|
|
25487
25491
|
QUESTION_LIMIT = 300;
|
|
25488
25492
|
LIMIT = 200;
|
|
25489
|
-
cut = (
|
|
25493
|
+
cut = (text5, limit) => redactSecretsInText(text5).trim().slice(0, limit);
|
|
25490
25494
|
}
|
|
25491
25495
|
});
|
|
25492
25496
|
|
|
@@ -25512,17 +25516,17 @@ var init_mcp_tool_images = __esm({
|
|
|
25512
25516
|
|
|
25513
25517
|
// shared/mcp-tool-ref.ts
|
|
25514
25518
|
function mcpToolRefFromLabel(label, servers) {
|
|
25515
|
-
const
|
|
25516
|
-
if (!
|
|
25519
|
+
const text5 = label.trim();
|
|
25520
|
+
if (!text5) return null;
|
|
25517
25521
|
const ordered = [...servers].sort((a2, b3) => b3.length - a2.length);
|
|
25518
25522
|
const accept = (server, tool2) => MCP_TOOL_NAME.test(tool2) ? { server, tool: tool2 } : null;
|
|
25519
25523
|
for (const server of ordered) {
|
|
25520
25524
|
const claude = `mcp__${server}__`;
|
|
25521
|
-
if (
|
|
25522
|
-
const hit = accept(server,
|
|
25525
|
+
if (text5.startsWith(claude)) {
|
|
25526
|
+
const hit = accept(server, text5.slice(claude.length));
|
|
25523
25527
|
if (hit) return hit;
|
|
25524
25528
|
}
|
|
25525
|
-
const display = new RegExp(`^(\\S+) \\(${server.replace(/[.*+?^${}()|[\]\\-]/g, "\\$&")} MCP Server\\)$`).exec(
|
|
25529
|
+
const display = new RegExp(`^(\\S+) \\(${server.replace(/[.*+?^${}()|[\]\\-]/g, "\\$&")} MCP Server\\)$`).exec(text5);
|
|
25526
25530
|
if (display) {
|
|
25527
25531
|
const hit = accept(server, display[1]);
|
|
25528
25532
|
if (hit) return hit;
|
|
@@ -25530,8 +25534,8 @@ function mcpToolRefFromLabel(label, servers) {
|
|
|
25530
25534
|
}
|
|
25531
25535
|
for (const separator of ["__", ":", ".", "/", "_"]) {
|
|
25532
25536
|
for (const server of ordered) {
|
|
25533
|
-
if (!
|
|
25534
|
-
const hit = accept(server,
|
|
25537
|
+
if (!text5.startsWith(`${server}${separator}`)) continue;
|
|
25538
|
+
const hit = accept(server, text5.slice(server.length + separator.length));
|
|
25535
25539
|
if (hit) return hit;
|
|
25536
25540
|
}
|
|
25537
25541
|
}
|
|
@@ -25549,8 +25553,8 @@ var init_mcp_tool_ref = __esm({
|
|
|
25549
25553
|
function isBrokenAntigravityCheckpoint(driverKind, message2) {
|
|
25550
25554
|
return driverKind === "antigravityAgent" && message2.includes("could not find doneCh for checkpoint");
|
|
25551
25555
|
}
|
|
25552
|
-
function isAntigravityCheckpointReply(driverKind,
|
|
25553
|
-
return driverKind === "antigravityAgent" && /^Agent execution error: could not find doneCh for checkpoint\s*$/.test(
|
|
25556
|
+
function isAntigravityCheckpointReply(driverKind, text5) {
|
|
25557
|
+
return driverKind === "antigravityAgent" && /^Agent execution error: could not find doneCh for checkpoint\s*$/.test(text5.trim());
|
|
25554
25558
|
}
|
|
25555
25559
|
var init_checkpoint_recovery = __esm({
|
|
25556
25560
|
"server/checkpoint-recovery.ts"() {
|
|
@@ -25590,14 +25594,14 @@ var init_provider_safety = __esm({
|
|
|
25590
25594
|
});
|
|
25591
25595
|
|
|
25592
25596
|
// server/engine-failure.ts
|
|
25593
|
-
function statedReset(
|
|
25594
|
-
const reset = parseReset(
|
|
25597
|
+
function statedReset(text5, now = Date.now()) {
|
|
25598
|
+
const reset = parseReset(text5, now);
|
|
25595
25599
|
if (reset) return { resetAt: reset.at, resetText: reset.text };
|
|
25596
|
-
const windowMs = rollingWindowMs(
|
|
25597
|
-
return windowMs ? { windowMs, resetText: rollingWindowPhrase(
|
|
25600
|
+
const windowMs = rollingWindowMs(text5);
|
|
25601
|
+
return windowMs ? { windowMs, resetText: rollingWindowPhrase(text5) } : {};
|
|
25598
25602
|
}
|
|
25599
|
-
function rollingWindowMs(
|
|
25600
|
-
const m3 = ROLLING_WINDOW.exec(
|
|
25603
|
+
function rollingWindowMs(text5) {
|
|
25604
|
+
const m3 = ROLLING_WINDOW.exec(text5);
|
|
25601
25605
|
if (!m3) return void 0;
|
|
25602
25606
|
const amount = Number(m3[1] ?? m3[3]);
|
|
25603
25607
|
const unit = (m3[2] ?? m3[4]).toLowerCase();
|
|
@@ -25605,36 +25609,36 @@ function rollingWindowMs(text4) {
|
|
|
25605
25609
|
const ms2 = amount * scale;
|
|
25606
25610
|
return Number.isFinite(ms2) && ms2 > 0 ? Math.min(ms2, MAX_WINDOW_MS) : void 0;
|
|
25607
25611
|
}
|
|
25608
|
-
function rollingWindowPhrase(
|
|
25609
|
-
const m3 = ROLLING_WINDOW.exec(
|
|
25612
|
+
function rollingWindowPhrase(text5) {
|
|
25613
|
+
const m3 = ROLLING_WINDOW.exec(text5);
|
|
25610
25614
|
if (!m3) return void 0;
|
|
25611
|
-
const lead = /\b(?:usage\s+)?resets?\s+(?:over\s+)?(?:a\s+)?$/i.exec(
|
|
25615
|
+
const lead = /\b(?:usage\s+)?resets?\s+(?:over\s+)?(?:a\s+)?$/i.exec(text5.slice(Math.max(0, m3.index - 30), m3.index));
|
|
25612
25616
|
return resetPhrase(`${lead ? lead[0] : ""}${m3[0]}`);
|
|
25613
25617
|
}
|
|
25614
|
-
function isCredentialDead(
|
|
25615
|
-
return Boolean(
|
|
25618
|
+
function isCredentialDead(text5) {
|
|
25619
|
+
return Boolean(text5) && CREDENTIAL_DEAD.some((pattern) => pattern.test(text5));
|
|
25616
25620
|
}
|
|
25617
25621
|
function isOpaqueRequestRejection(message2) {
|
|
25618
25622
|
return OPAQUE_REQUEST_REJECTION.test(message2);
|
|
25619
25623
|
}
|
|
25620
|
-
function classifyEngineFailure(
|
|
25621
|
-
if (!
|
|
25622
|
-
const tooFast = TOO_FAST.some((pattern) => pattern.test(
|
|
25623
|
-
if (USAGE_LIMITED.some((pattern) => pattern.test(
|
|
25624
|
-
return { kind: "usage_limited", ...statedReset(
|
|
25625
|
-
}
|
|
25626
|
-
if (isCredentialDead(
|
|
25627
|
-
if (AUTH_FAILED.some((pattern) => pattern.test(
|
|
25628
|
-
if (STALLED.some((pattern) => pattern.test(
|
|
25629
|
-
if (tooFast || RATE_LIMITED.some((pattern) => pattern.test(
|
|
25630
|
-
const reset = parseReset(
|
|
25624
|
+
function classifyEngineFailure(text5, now = Date.now()) {
|
|
25625
|
+
if (!text5) return null;
|
|
25626
|
+
const tooFast = TOO_FAST.some((pattern) => pattern.test(text5));
|
|
25627
|
+
if (USAGE_LIMITED.some((pattern) => pattern.test(text5)) || !tooFast && EXHAUSTED.some((pattern) => pattern.test(text5))) {
|
|
25628
|
+
return { kind: "usage_limited", ...statedReset(text5, now) };
|
|
25629
|
+
}
|
|
25630
|
+
if (isCredentialDead(text5)) return { kind: "auth_failed", permanent: true };
|
|
25631
|
+
if (AUTH_FAILED.some((pattern) => pattern.test(text5))) return { kind: "auth_failed" };
|
|
25632
|
+
if (STALLED.some((pattern) => pattern.test(text5))) return { kind: "stalled" };
|
|
25633
|
+
if (tooFast || RATE_LIMITED.some((pattern) => pattern.test(text5))) {
|
|
25634
|
+
const reset = parseReset(text5, now);
|
|
25631
25635
|
return { kind: "rate_limited", ...reset ? { resetAt: reset.at, resetText: reset.text } : {} };
|
|
25632
25636
|
}
|
|
25633
25637
|
return null;
|
|
25634
25638
|
}
|
|
25635
|
-
function logAuthFailure(
|
|
25636
|
-
if (!
|
|
25637
|
-
for (const line of
|
|
25639
|
+
function logAuthFailure(text5) {
|
|
25640
|
+
if (!text5) return void 0;
|
|
25641
|
+
for (const line of text5.split(/\r?\n/)) {
|
|
25638
25642
|
if (LOG_AUTH_FAILED.some((pattern) => pattern.test(line))) return line.trim().slice(0, 300);
|
|
25639
25643
|
}
|
|
25640
25644
|
return void 0;
|
|
@@ -25650,13 +25654,13 @@ function engineFailureFromCodexInfo(info) {
|
|
|
25650
25654
|
if (name === "unauthorized") return "auth_failed";
|
|
25651
25655
|
return void 0;
|
|
25652
25656
|
}
|
|
25653
|
-
function parseResetAt(
|
|
25654
|
-
return parseReset(
|
|
25657
|
+
function parseResetAt(text5, now = Date.now()) {
|
|
25658
|
+
return parseReset(text5, now)?.at;
|
|
25655
25659
|
}
|
|
25656
|
-
function parseReset(
|
|
25657
|
-
if (!
|
|
25660
|
+
function parseReset(text5, now = Date.now()) {
|
|
25661
|
+
if (!text5) return void 0;
|
|
25658
25662
|
for (const read of RESET_READERS) {
|
|
25659
|
-
for (const found of read(
|
|
25663
|
+
for (const found of read(text5, now)) {
|
|
25660
25664
|
if (Number.isFinite(found.at) && found.at > now && found.at - now <= MAX_RESET_AHEAD_MS) {
|
|
25661
25665
|
return { at: Math.round(found.at), text: resetPhrase(found.phrase) };
|
|
25662
25666
|
}
|
|
@@ -25683,27 +25687,27 @@ function resetHintFromData(data) {
|
|
|
25683
25687
|
};
|
|
25684
25688
|
return walk(data, 0);
|
|
25685
25689
|
}
|
|
25686
|
-
function durationMs(
|
|
25690
|
+
function durationMs(text5) {
|
|
25687
25691
|
let total = 0;
|
|
25688
|
-
for (const part of
|
|
25692
|
+
for (const part of text5.matchAll(new RegExp(String.raw`(\d+(?:\.\d+)?)\s*(${UNIT})`, "gi"))) {
|
|
25689
25693
|
const unit = part[2].toLowerCase();
|
|
25690
25694
|
const scale = unit === "ms" || unit.startsWith("milli") ? 1 : unit[0] === "d" ? DAY_MS4 : unit[0] === "h" ? HOUR_MS : unit[0] === "m" ? MINUTE_MS : 1e3;
|
|
25691
25695
|
total += Number(part[1]) * scale;
|
|
25692
25696
|
}
|
|
25693
25697
|
return total;
|
|
25694
25698
|
}
|
|
25695
|
-
function leadIn(
|
|
25696
|
-
const before =
|
|
25699
|
+
function leadIn(text5, index) {
|
|
25700
|
+
const before = text5.slice(Math.max(0, index - 30), index);
|
|
25697
25701
|
const lead = new RegExp(String.raw`${RESET_WORD}(?:\s+(?:at|on|in))?[\s:=∙·-]*$`, "i").exec(before);
|
|
25698
25702
|
return lead ? index - (before.length - lead.index) : index;
|
|
25699
25703
|
}
|
|
25700
|
-
function readClock(
|
|
25704
|
+
function readClock(text5, now) {
|
|
25701
25705
|
const reading = {};
|
|
25702
25706
|
let i2 = 0;
|
|
25703
|
-
const skipFiller = () => i2 += CLOCK_FILLER.exec(
|
|
25707
|
+
const skipFiller = () => i2 += CLOCK_FILLER.exec(text5.slice(i2))[0].length;
|
|
25704
25708
|
skipFiller();
|
|
25705
25709
|
for (let parts = 0; parts < 4; parts++) {
|
|
25706
|
-
const rest =
|
|
25710
|
+
const rest = text5.slice(i2);
|
|
25707
25711
|
let m3;
|
|
25708
25712
|
if (!reading.dayWord && reading.weekday === void 0 && !reading.date && (m3 = CLOCK_PARTS.dayWord.exec(rest))) {
|
|
25709
25713
|
reading.dayWord = m3[1].toLowerCase();
|
|
@@ -25728,11 +25732,11 @@ function readClock(text4, now) {
|
|
|
25728
25732
|
i2 += m3[0].length;
|
|
25729
25733
|
const before = i2;
|
|
25730
25734
|
skipFiller();
|
|
25731
|
-
if (!Object.values(CLOCK_PARTS).some((part) => part.test(
|
|
25735
|
+
if (!Object.values(CLOCK_PARTS).some((part) => part.test(text5.slice(i2)))) i2 = before;
|
|
25732
25736
|
}
|
|
25733
25737
|
if (reading.hour === void 0 || reading.hour > 23 || reading.minute > 59) return void 0;
|
|
25734
25738
|
if (reading.date && (reading.date.month < 1 || reading.date.day < 1 || reading.date.day > 31)) return void 0;
|
|
25735
|
-
const after = zoneAfter(
|
|
25739
|
+
const after = zoneAfter(text5.slice(i2));
|
|
25736
25740
|
const zone = after?.zone ?? localZone();
|
|
25737
25741
|
const length = i2 + (after?.length ?? 0);
|
|
25738
25742
|
const today = zonedToday(now, zone);
|
|
@@ -25754,21 +25758,21 @@ function readClock(text4, now) {
|
|
|
25754
25758
|
return { at: found, length };
|
|
25755
25759
|
}
|
|
25756
25760
|
function parseZone(token) {
|
|
25757
|
-
const
|
|
25758
|
-
const offset = /^(?:UTC|GMT)?\s*([+-])\s*(\d{1,2})(?::?(\d{2}))?$/i.exec(
|
|
25761
|
+
const text5 = token.trim();
|
|
25762
|
+
const offset = /^(?:UTC|GMT)?\s*([+-])\s*(\d{1,2})(?::?(\d{2}))?$/i.exec(text5);
|
|
25759
25763
|
if (offset) {
|
|
25760
25764
|
const minutes = Number(offset[2]) * 60 + Number(offset[3] ?? 0);
|
|
25761
25765
|
return minutes <= 14 * 60 ? { offsetMinutes: offset[1] === "-" ? -minutes : minutes } : void 0;
|
|
25762
25766
|
}
|
|
25763
|
-
const upper =
|
|
25767
|
+
const upper = text5.toUpperCase();
|
|
25764
25768
|
if (upper in ZONE_ABBREVIATIONS) return { offsetMinutes: ZONE_ABBREVIATIONS[upper] };
|
|
25765
|
-
return
|
|
25769
|
+
return text5.includes("/") && validTimeZone(text5) ? { name: text5 } : void 0;
|
|
25766
25770
|
}
|
|
25767
|
-
function zoneAfter(
|
|
25768
|
-
const bare = new RegExp(String.raw`^\s*,?\s*(${ZONE_TOKEN})(?![A-Za-z0-9/])`).exec(
|
|
25771
|
+
function zoneAfter(text5) {
|
|
25772
|
+
const bare = new RegExp(String.raw`^\s*,?\s*(${ZONE_TOKEN})(?![A-Za-z0-9/])`).exec(text5);
|
|
25769
25773
|
const bareZone = bare ? parseZone(bare[1]) : void 0;
|
|
25770
25774
|
if (bare && bareZone) return { zone: bareZone, length: bare[0].length };
|
|
25771
|
-
const paren = /^[^()\n]{0,20}\(([^()\n]{1,60})\)/.exec(
|
|
25775
|
+
const paren = /^[^()\n]{0,20}\(([^()\n]{1,60})\)/.exec(text5);
|
|
25772
25776
|
if (paren) {
|
|
25773
25777
|
for (const token of paren[1].split(/[\s,;]+/).reverse()) {
|
|
25774
25778
|
const zone = parseZone(token);
|
|
@@ -25819,8 +25823,8 @@ function wallToInstant(year, month, day, hour, minute, zone, extraMs = 0) {
|
|
|
25819
25823
|
at2 = wall - offsetAt(at2);
|
|
25820
25824
|
return at2;
|
|
25821
25825
|
}
|
|
25822
|
-
function resetPhrase(
|
|
25823
|
-
const phrase =
|
|
25826
|
+
function resetPhrase(text5) {
|
|
25827
|
+
const phrase = text5.replace(/\s+/g, " ").trim().replace(/^[\s|,;:∙·-]+|[\s,;:.∙·-]+$/g, "");
|
|
25824
25828
|
return phrase.length > RESET_TEXT_MAX ? `${phrase.slice(0, RESET_TEXT_MAX - 1)}\u2026` : phrase;
|
|
25825
25829
|
}
|
|
25826
25830
|
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;
|
|
@@ -25874,7 +25878,9 @@ var init_engine_failure = __esm({
|
|
|
25874
25878
|
/\b(?:api[ _-]?)?key (?:has |is |was )?(?:been )?(?:expired|revoked|disabled|deactivated|deleted)\b/i,
|
|
25875
25879
|
/\b(?:expired|revoked|disabled|deactivated|deleted) (?:api[ _-]?)?key\b/i,
|
|
25876
25880
|
/\b(?:api_key_expired|key_expired|expired_api_key|revoked_api_key|api_key_revoked)\b/i,
|
|
25877
|
-
/\bsigning in again will not renew\b/i
|
|
25881
|
+
/\bsigning in again will not renew\b/i,
|
|
25882
|
+
/^Internal error: User not found\.? \(session\/prompt\b/
|
|
25883
|
+
// OpenRouter's dead key, via OpenCode
|
|
25878
25884
|
];
|
|
25879
25885
|
LOGIN_EXPIRED_REPLY = /^Login expired [·∙] Run \/login to sign in again, or re-authenticate your [^\r\n]{1,80} profile\.?$/i;
|
|
25880
25886
|
AUTH_FAILED = [
|
|
@@ -25927,49 +25933,49 @@ var init_engine_failure = __esm({
|
|
|
25927
25933
|
RESET_WORD = String.raw`\b(?:resets?|try again|retry|available again|renews?|refresh(?:es)?)\b`;
|
|
25928
25934
|
RESET_READERS = [
|
|
25929
25935
|
// Claude Code's "usage limit reached|1759348800".
|
|
25930
|
-
function* epochPipe(
|
|
25931
|
-
for (const m3 of
|
|
25936
|
+
function* epochPipe(text5) {
|
|
25937
|
+
for (const m3 of text5.matchAll(/(?:usage limit reached\s*)?\|\s*(\d{10})(\d{3})?(?!\d)/gi)) {
|
|
25932
25938
|
yield { at: Number(m3[1]) * 1e3, phrase: m3[0] };
|
|
25933
25939
|
}
|
|
25934
25940
|
},
|
|
25935
25941
|
// A structured reset instant: Codex's "resets_at": 1759348800, a
|
|
25936
25942
|
// "resetsAt", the unified rate-limit header.
|
|
25937
|
-
function* epochField(
|
|
25938
|
-
for (const m3 of
|
|
25943
|
+
function* epochField(text5) {
|
|
25944
|
+
for (const m3 of text5.matchAll(/["']?\b(?:resets_at|resetsAt|reset_at|resetAt|ratelimit-unified-reset)["']?\s*[:=]\s*["']?(\d{10}|\d{13})(?!\d)/gi)) {
|
|
25939
25945
|
yield { at: m3[1].length === 13 ? Number(m3[1]) : Number(m3[1]) * 1e3, phrase: m3[0] };
|
|
25940
25946
|
}
|
|
25941
25947
|
},
|
|
25942
25948
|
// "2026-09-25T18:00:00Z", "2026-10-03 09:00:00+02:00", "2026-08-08 00:00 UTC".
|
|
25943
|
-
function* isoTimestamp(
|
|
25944
|
-
for (const m3 of
|
|
25949
|
+
function* isoTimestamp(text5) {
|
|
25950
|
+
for (const m3 of text5.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)) {
|
|
25945
25951
|
const [, y, mo2, d, h2, mi2, sec, frac, zoneText] = m3;
|
|
25946
|
-
const start = leadIn(
|
|
25952
|
+
const start = leadIn(text5, m3.index);
|
|
25947
25953
|
if (!zoneText && start === m3.index) continue;
|
|
25948
|
-
const after = zoneText ? void 0 : zoneAfter(
|
|
25954
|
+
const after = zoneText ? void 0 : zoneAfter(text5.slice(m3.index + m3[0].length));
|
|
25949
25955
|
const zone = zoneText ? parseZone(zoneText) : after?.zone ?? localZone();
|
|
25950
25956
|
if (!zone) continue;
|
|
25951
25957
|
const ms2 = frac ? Math.round(Number(`0.${frac}`) * 1e3) : 0;
|
|
25952
25958
|
const at2 = wallToInstant(Number(y), Number(mo2), Number(d), Number(h2), Number(mi2), zone, Number(sec ?? 0) * 1e3 + ms2);
|
|
25953
|
-
yield { at: at2, phrase:
|
|
25959
|
+
yield { at: at2, phrase: text5.slice(start, m3.index + m3[0].length + (after?.length ?? 0)) };
|
|
25954
25960
|
}
|
|
25955
25961
|
},
|
|
25956
25962
|
// "Retry-After: 120", "retry after 3600 seconds".
|
|
25957
|
-
function* retryAfter(
|
|
25958
|
-
for (const m3 of
|
|
25963
|
+
function* retryAfter(text5, now) {
|
|
25964
|
+
for (const m3 of text5.matchAll(new RegExp(String.raw`\bretry[- ]after:?\s*(\d+(?:\.\d+)?)\s*(${UNIT})?`, "gi"))) {
|
|
25959
25965
|
yield { at: now + (m3[2] ? durationMs(`${m3[1]}${m3[2]}`) : Number(m3[1]) * 1e3), phrase: m3[0] };
|
|
25960
25966
|
}
|
|
25961
25967
|
},
|
|
25962
25968
|
// Structured durations: Gemini's "retryDelay": "41s", Codex's
|
|
25963
25969
|
// "resets_in_seconds": 3600, a "retry_after": 30.
|
|
25964
|
-
function* durationField(
|
|
25965
|
-
for (const m3 of
|
|
25970
|
+
function* durationField(text5, now) {
|
|
25971
|
+
for (const m3 of text5.matchAll(/["']?\b(retryDelay|retry_delay|retryAfter|retry_after(?:_seconds)?|resets_in_seconds|resetsInSeconds)["']?\s*[:=]\s*["']?(\d+(?:\.\d+)?)\s*(ms|s)?(?![a-z\d])/gi)) {
|
|
25966
25972
|
yield { at: now + Number(m3[2]) * (m3[3]?.toLowerCase() === "ms" ? 1 : 1e3), phrase: m3[0] };
|
|
25967
25973
|
}
|
|
25968
25974
|
},
|
|
25969
25975
|
// "try again in 2 days 4 hours 12 minutes", "resets in 37m", "Please
|
|
25970
25976
|
// retry in 41.5s", "resets in 2d 4h 30m".
|
|
25971
|
-
function* relative(
|
|
25972
|
-
for (const m3 of
|
|
25977
|
+
function* relative(text5, now) {
|
|
25978
|
+
for (const m3 of text5.matchAll(new RegExp(String.raw`${RESET_WORD}\s+in\s+(${DURATION})`, "gi"))) {
|
|
25973
25979
|
const total = durationMs(m3[1]);
|
|
25974
25980
|
if (total > 0) yield { at: now + total, phrase: m3[0] };
|
|
25975
25981
|
}
|
|
@@ -25977,11 +25983,11 @@ var init_engine_failure = __esm({
|
|
|
25977
25983
|
// A time of day, maybe with a date: "resets 3pm (America/New_York)",
|
|
25978
25984
|
// "resets Oct 3, 9am", "try again tomorrow at 9:00", "resets Thursday
|
|
25979
25985
|
// 9am", "Access resets at 3:45 PM EDT", "15:05 on 26 Sep 2026".
|
|
25980
|
-
function* clock2(
|
|
25981
|
-
for (const m3 of
|
|
25986
|
+
function* clock2(text5, now) {
|
|
25987
|
+
for (const m3 of text5.matchAll(new RegExp(RESET_WORD, "gi"))) {
|
|
25982
25988
|
const start = m3.index + m3[0].length;
|
|
25983
|
-
const found = readClock(
|
|
25984
|
-
if (found) yield { at: found.at, phrase:
|
|
25989
|
+
const found = readClock(text5.slice(start, start + 120), now);
|
|
25990
|
+
if (found) yield { at: found.at, phrase: text5.slice(m3.index, start + found.length) };
|
|
25985
25991
|
}
|
|
25986
25992
|
}
|
|
25987
25993
|
];
|
|
@@ -26043,13 +26049,13 @@ function isModelRejection(error51, requested) {
|
|
|
26043
26049
|
return MODEL_REJECTION.test(message2) || requested.length > 0 && message2.includes(requested) && /\bmodel\b/i.test(message2);
|
|
26044
26050
|
}
|
|
26045
26051
|
function classifyError(err) {
|
|
26046
|
-
const
|
|
26047
|
-
if (isProviderSafetyBlock(
|
|
26048
|
-
if (CREDENTIAL_REFRESH_CONFLICT.test(
|
|
26052
|
+
const text5 = messageOf(err);
|
|
26053
|
+
if (isProviderSafetyBlock(text5)) return { transient: false, reason: "provider_safety" };
|
|
26054
|
+
if (CREDENTIAL_REFRESH_CONFLICT.test(text5)) {
|
|
26049
26055
|
if (err && "exitCode" in err && err.exitCode !== null && err.exitCode < 0) return { transient: false, reason: "interrupted" };
|
|
26050
26056
|
return { transient: true, reason: "credential_refresh" };
|
|
26051
26057
|
}
|
|
26052
|
-
const failure = classifyEngineFailure(
|
|
26058
|
+
const failure = classifyEngineFailure(text5);
|
|
26053
26059
|
if (failure?.kind === "rate_limited") {
|
|
26054
26060
|
if (err && "exitCode" in err && err.exitCode !== null && err.exitCode < 0) return { transient: false, reason: "interrupted" };
|
|
26055
26061
|
return { transient: true, reason: "rate_limited" };
|
|
@@ -26059,18 +26065,18 @@ function classifyError(err) {
|
|
|
26059
26065
|
const { exitCode: code } = err;
|
|
26060
26066
|
if (code !== null && code < 0) return { transient: false, reason: "interrupted" };
|
|
26061
26067
|
for (const { pattern, reason } of TRANSIENT_PATTERNS) {
|
|
26062
|
-
if (pattern.test(
|
|
26068
|
+
if (pattern.test(text5)) return { transient: true, reason };
|
|
26063
26069
|
}
|
|
26064
26070
|
for (const { pattern, reason } of TERMINAL_PATTERNS) {
|
|
26065
|
-
if (pattern.test(
|
|
26071
|
+
if (pattern.test(text5)) return { transient: false, reason };
|
|
26066
26072
|
}
|
|
26067
26073
|
return { transient: false, reason: "terminal_exit" };
|
|
26068
26074
|
}
|
|
26069
26075
|
for (const { pattern, reason } of TERMINAL_PATTERNS) {
|
|
26070
|
-
if (pattern.test(
|
|
26076
|
+
if (pattern.test(text5)) return { transient: false, reason };
|
|
26071
26077
|
}
|
|
26072
26078
|
for (const { pattern, reason } of TRANSIENT_PATTERNS) {
|
|
26073
|
-
if (pattern.test(
|
|
26079
|
+
if (pattern.test(text5)) return { transient: true, reason };
|
|
26074
26080
|
}
|
|
26075
26081
|
return { transient: false, reason: "unknown" };
|
|
26076
26082
|
}
|
|
@@ -26226,8 +26232,8 @@ var init_turn_mcp = __esm({
|
|
|
26226
26232
|
// server/drivers/volatile-notes.ts
|
|
26227
26233
|
function volatileSectionsOf(turn) {
|
|
26228
26234
|
if (turn.systemVolatileSections) return turn.systemVolatileSections.filter((section) => section.text.trim());
|
|
26229
|
-
const
|
|
26230
|
-
return
|
|
26235
|
+
const text5 = turn.systemVolatile ?? "";
|
|
26236
|
+
return text5.trim() ? [{ id: "volatile", label: "Notes", text: text5 }] : [];
|
|
26231
26237
|
}
|
|
26232
26238
|
function volatileNote(sections, delivered, first) {
|
|
26233
26239
|
const parts = [];
|
|
@@ -26252,11 +26258,11 @@ ${lead}
|
|
|
26252
26258
|
${parts.join("\n\n")}
|
|
26253
26259
|
</system-reminder>`;
|
|
26254
26260
|
}
|
|
26255
|
-
function withNote(
|
|
26256
|
-
if (!note) return
|
|
26257
|
-
return
|
|
26261
|
+
function withNote(text5, note) {
|
|
26262
|
+
if (!note) return text5;
|
|
26263
|
+
return text5 ? `${note}
|
|
26258
26264
|
|
|
26259
|
-
${
|
|
26265
|
+
${text5}` : note;
|
|
26260
26266
|
}
|
|
26261
26267
|
var init_volatile_notes = __esm({
|
|
26262
26268
|
"server/drivers/volatile-notes.ts"() {
|
|
@@ -26264,6 +26270,135 @@ var init_volatile_notes = __esm({
|
|
|
26264
26270
|
}
|
|
26265
26271
|
});
|
|
26266
26272
|
|
|
26273
|
+
// server/drivers/acp/tool-log.ts
|
|
26274
|
+
function sanitizeToolLogValue(value, budget, depth = 0) {
|
|
26275
|
+
if (depth > 12 || budget.nodes-- <= 0) return void 0;
|
|
26276
|
+
if (typeof value === "string") {
|
|
26277
|
+
if (/^data:image\//iu.test(value) || budget.text <= 0) return void 0;
|
|
26278
|
+
const limit = Math.min(TOOL_LOG_TEXT_LIMIT, budget.text);
|
|
26279
|
+
const text5 = value.length <= limit ? value : `[Earlier output truncated]
|
|
26280
|
+
|
|
26281
|
+
${value.slice(-limit)}`;
|
|
26282
|
+
budget.text -= text5.length;
|
|
26283
|
+
return text5;
|
|
26284
|
+
}
|
|
26285
|
+
if (Array.isArray(value)) {
|
|
26286
|
+
return value.flatMap((entry) => {
|
|
26287
|
+
const sanitized = sanitizeToolLogValue(entry, budget, depth + 1);
|
|
26288
|
+
return sanitized === void 0 ? [] : [sanitized];
|
|
26289
|
+
});
|
|
26290
|
+
}
|
|
26291
|
+
if (!value || typeof value !== "object") return value;
|
|
26292
|
+
const record6 = value;
|
|
26293
|
+
return Object.fromEntries(Object.entries(record6).flatMap(([key, entry]) => {
|
|
26294
|
+
if (record6.type === "image" && (key === "data" || key === "blob") || key === "blob" && typeof record6.mimeType === "string" && record6.mimeType.startsWith("image/")) return [];
|
|
26295
|
+
const sanitized = sanitizeToolLogValue(entry, budget, depth + 1);
|
|
26296
|
+
return sanitized === void 0 ? [] : [[key, sanitized]];
|
|
26297
|
+
}));
|
|
26298
|
+
}
|
|
26299
|
+
function sanitizeAcpToolMessage(message2) {
|
|
26300
|
+
const m3 = message2;
|
|
26301
|
+
const isToolUpdate = m3?.method === "session/update" && ["tool_call", "tool_call_update"].includes(m3?.params?.update?.sessionUpdate);
|
|
26302
|
+
const isPermission = m3?.method === "session/request_permission";
|
|
26303
|
+
if (!isToolUpdate && !isPermission) return message2;
|
|
26304
|
+
return sanitizeToolLogValue(message2, { nodes: 512, text: TOOL_LOG_TEXT_LIMIT });
|
|
26305
|
+
}
|
|
26306
|
+
var TOOL_LOG_TEXT_LIMIT;
|
|
26307
|
+
var init_tool_log = __esm({
|
|
26308
|
+
"server/drivers/acp/tool-log.ts"() {
|
|
26309
|
+
"use strict";
|
|
26310
|
+
TOOL_LOG_TEXT_LIMIT = 64e3;
|
|
26311
|
+
}
|
|
26312
|
+
});
|
|
26313
|
+
|
|
26314
|
+
// shared/approval-readback.ts
|
|
26315
|
+
function compareEffectiveMode(ladder, requested, reported) {
|
|
26316
|
+
const want = text3(requested);
|
|
26317
|
+
const got = text3(reported);
|
|
26318
|
+
const ranks = MODE_LADDERS[ladder];
|
|
26319
|
+
if (want === null || got === null) return { status: "unverified", requested: want, reported: got };
|
|
26320
|
+
const wantRank = ranks?.[want];
|
|
26321
|
+
const gotRank = ranks?.[got];
|
|
26322
|
+
if (wantRank === void 0 || gotRank === void 0) {
|
|
26323
|
+
return { status: want === got ? "ok" : "unverified", requested: want, reported: got };
|
|
26324
|
+
}
|
|
26325
|
+
return { status: gotRank < wantRank ? "looser" : "ok", requested: want, reported: got };
|
|
26326
|
+
}
|
|
26327
|
+
function looserModeMessage(engine, readback) {
|
|
26328
|
+
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.`;
|
|
26329
|
+
}
|
|
26330
|
+
function assertEffectiveModeNotLooser(engine, ladder, requested, reported) {
|
|
26331
|
+
const readback = compareEffectiveMode(ladder, requested, reported);
|
|
26332
|
+
if (readback.status === "looser") {
|
|
26333
|
+
throw Object.assign(new Error(looserModeMessage(engine, readback)), { code: "APPROVAL_MODE_LOOSER", readback });
|
|
26334
|
+
}
|
|
26335
|
+
return readback;
|
|
26336
|
+
}
|
|
26337
|
+
var MODE_LADDERS, text3;
|
|
26338
|
+
var init_approval_readback = __esm({
|
|
26339
|
+
"shared/approval-readback.ts"() {
|
|
26340
|
+
"use strict";
|
|
26341
|
+
MODE_LADDERS = {
|
|
26342
|
+
kimiAgent: { plan: 4, default: 3, yolo: 1, auto: 0 },
|
|
26343
|
+
droidAgent: { spec: 4, normal: 3, "auto-low": 2, "auto-medium": 1, "auto-high": 0 },
|
|
26344
|
+
vibeAgent: { plan: 4, ask: 3, "accept-edits": 2, "smart-approve": 1, "auto-approve": 0 },
|
|
26345
|
+
qwenAgent: { plan: 4, default: 3, "auto-edit": 2, autoEdit: 2, auto: 1, yolo: 0 },
|
|
26346
|
+
geminiAgent: { plan: 4, default: 3, autoEdit: 2, auto_edit: 2, "auto-edit": 2, yolo: 0 }
|
|
26347
|
+
};
|
|
26348
|
+
text3 = (value) => typeof value === "string" && value.trim() ? value.trim() : null;
|
|
26349
|
+
}
|
|
26350
|
+
});
|
|
26351
|
+
|
|
26352
|
+
// server/drivers/acp/mode-readback.ts
|
|
26353
|
+
function noteModeReport(session, result) {
|
|
26354
|
+
const id = result?.modes?.currentModeId;
|
|
26355
|
+
if (typeof id === "string" && id) stateOf(session).reported = id;
|
|
26356
|
+
}
|
|
26357
|
+
function noteModeUpdate(session, raw) {
|
|
26358
|
+
const params = raw;
|
|
26359
|
+
if (params?.update?.sessionUpdate !== "current_mode_update") return false;
|
|
26360
|
+
if (session.sessionId && params.sessionId === session.sessionId && typeof params.update.currentModeId === "string") {
|
|
26361
|
+
const state2 = stateOf(session);
|
|
26362
|
+
state2.reported = params.update.currentModeId;
|
|
26363
|
+
state2.onReported?.();
|
|
26364
|
+
}
|
|
26365
|
+
return true;
|
|
26366
|
+
}
|
|
26367
|
+
function forgetStaleModeReport(session, support12) {
|
|
26368
|
+
if (support12.approvalModeReadback?.setsModeOverWire) stateOf(session).reported = null;
|
|
26369
|
+
}
|
|
26370
|
+
function approvalReadbackFor(support12, config2, turn, reported) {
|
|
26371
|
+
const rules = support12.approvalModeReadback;
|
|
26372
|
+
if (!rules) return { status: "unverified", requested: null, reported };
|
|
26373
|
+
return compareEffectiveMode(rules.ladder, rules.expected(config2, turn), reported);
|
|
26374
|
+
}
|
|
26375
|
+
function armModeReadback(input) {
|
|
26376
|
+
const { support: support12, session, config: config2, turn } = input;
|
|
26377
|
+
const state2 = stateOf(session);
|
|
26378
|
+
const now = approvalReadbackFor(support12, config2, turn, state2.reported);
|
|
26379
|
+
if (now.status === "looser") throw new Error(looserModeMessage(support12.displayName, now));
|
|
26380
|
+
if (now.status === "unverified") input.log(now);
|
|
26381
|
+
state2.onReported = () => {
|
|
26382
|
+
if (!input.isCurrent()) return;
|
|
26383
|
+
const later = approvalReadbackFor(support12, config2, turn, state2.reported);
|
|
26384
|
+
input.log(later);
|
|
26385
|
+
if (later.status === "looser") input.stop(looserModeMessage(support12.displayName, later));
|
|
26386
|
+
};
|
|
26387
|
+
}
|
|
26388
|
+
var states, stateOf;
|
|
26389
|
+
var init_mode_readback = __esm({
|
|
26390
|
+
"server/drivers/acp/mode-readback.ts"() {
|
|
26391
|
+
"use strict";
|
|
26392
|
+
init_approval_readback();
|
|
26393
|
+
states = /* @__PURE__ */ new WeakMap();
|
|
26394
|
+
stateOf = (session) => {
|
|
26395
|
+
let state2 = states.get(session);
|
|
26396
|
+
if (!state2) states.set(session, state2 = { reported: null });
|
|
26397
|
+
return state2;
|
|
26398
|
+
};
|
|
26399
|
+
}
|
|
26400
|
+
});
|
|
26401
|
+
|
|
26267
26402
|
// server/drivers/acp/core.ts
|
|
26268
26403
|
import { homedir as homedir7 } from "node:os";
|
|
26269
26404
|
import { lstat, mkdir as mkdir3, readFile, realpath, stat as stat2, writeFile } from "node:fs/promises";
|
|
@@ -26340,37 +26475,6 @@ async function readAcpImageBlocks(images) {
|
|
|
26340
26475
|
mimeType: image.mime
|
|
26341
26476
|
})));
|
|
26342
26477
|
}
|
|
26343
|
-
function sanitizeToolLogValue(value, budget, depth = 0) {
|
|
26344
|
-
if (depth > 12 || budget.nodes-- <= 0) return void 0;
|
|
26345
|
-
if (typeof value === "string") {
|
|
26346
|
-
if (/^data:image\//iu.test(value) || budget.text <= 0) return void 0;
|
|
26347
|
-
const limit = Math.min(TOOL_LOG_TEXT_LIMIT, budget.text);
|
|
26348
|
-
const text4 = value.length <= limit ? value : `[Earlier output truncated]
|
|
26349
|
-
|
|
26350
|
-
${value.slice(-limit)}`;
|
|
26351
|
-
budget.text -= text4.length;
|
|
26352
|
-
return text4;
|
|
26353
|
-
}
|
|
26354
|
-
if (Array.isArray(value)) {
|
|
26355
|
-
return value.flatMap((entry) => {
|
|
26356
|
-
const sanitized = sanitizeToolLogValue(entry, budget, depth + 1);
|
|
26357
|
-
return sanitized === void 0 ? [] : [sanitized];
|
|
26358
|
-
});
|
|
26359
|
-
}
|
|
26360
|
-
if (!value || typeof value !== "object") return value;
|
|
26361
|
-
const record6 = value;
|
|
26362
|
-
return Object.fromEntries(Object.entries(record6).flatMap(([key, entry]) => {
|
|
26363
|
-
if (record6.type === "image" && (key === "data" || key === "blob") || key === "blob" && typeof record6.mimeType === "string" && record6.mimeType.startsWith("image/")) return [];
|
|
26364
|
-
const sanitized = sanitizeToolLogValue(entry, budget, depth + 1);
|
|
26365
|
-
return sanitized === void 0 ? [] : [[key, sanitized]];
|
|
26366
|
-
}));
|
|
26367
|
-
}
|
|
26368
|
-
function sanitizeAcpToolMessage(message2) {
|
|
26369
|
-
const isToolUpdate = message2?.method === "session/update" && ["tool_call", "tool_call_update"].includes(message2?.params?.update?.sessionUpdate);
|
|
26370
|
-
const isPermission = message2?.method === "session/request_permission";
|
|
26371
|
-
if (!isToolUpdate && !isPermission) return message2;
|
|
26372
|
-
return sanitizeToolLogValue(message2, { nodes: 512, text: TOOL_LOG_TEXT_LIMIT });
|
|
26373
|
-
}
|
|
26374
26478
|
function decodeAcpConfig(defaultCli) {
|
|
26375
26479
|
return (raw) => {
|
|
26376
26480
|
const o = raw ?? {};
|
|
@@ -26818,6 +26922,7 @@ function createAcpDriver(support12) {
|
|
|
26818
26922
|
if (current && !current.state.settled && session.sessionId && p3.sessionId === session.sessionId) current.receiveModelVariants(p3.update);
|
|
26819
26923
|
return;
|
|
26820
26924
|
}
|
|
26925
|
+
if (noteModeUpdate(session, p3)) return;
|
|
26821
26926
|
if (!current || !current.state.promptSent) return;
|
|
26822
26927
|
const u5 = p3.update ?? {};
|
|
26823
26928
|
switch (u5.sessionUpdate) {
|
|
@@ -27082,11 +27187,11 @@ function createAcpDriver(support12) {
|
|
|
27082
27187
|
return option;
|
|
27083
27188
|
};
|
|
27084
27189
|
const flushAssistantText = () => {
|
|
27085
|
-
const
|
|
27190
|
+
const text5 = state2.text;
|
|
27086
27191
|
state2.text = "";
|
|
27087
|
-
if (!
|
|
27192
|
+
if (!text5.trim()) return;
|
|
27088
27193
|
state2.producedItem = true;
|
|
27089
|
-
emit({ ...base2(threadId, turnId), type: "item.completed", itemType: "assistant_text", text:
|
|
27194
|
+
emit({ ...base2(threadId, turnId), type: "item.completed", itemType: "assistant_text", text: text5 });
|
|
27090
27195
|
};
|
|
27091
27196
|
const current = {
|
|
27092
27197
|
turnId,
|
|
@@ -27184,6 +27289,7 @@ function createAcpDriver(support12) {
|
|
|
27184
27289
|
loaded = true;
|
|
27185
27290
|
session.sessionId = cursor3;
|
|
27186
27291
|
session.sessionKey = sessionKey;
|
|
27292
|
+
noteModeReport(session, result2);
|
|
27187
27293
|
receiveModelVariants(result2);
|
|
27188
27294
|
}
|
|
27189
27295
|
}
|
|
@@ -27220,6 +27326,7 @@ function createAcpDriver(support12) {
|
|
|
27220
27326
|
sessionResult = await request("session/new", { cwd, mcpServers: sessionServers }, NEW_SESSION_TIMEOUT, (result2) => {
|
|
27221
27327
|
session.sessionId = typeof result2?.sessionId === "string" ? result2.sessionId : null;
|
|
27222
27328
|
session.sessionKey = sessionKey;
|
|
27329
|
+
noteModeReport(session, result2);
|
|
27223
27330
|
receiveModelVariants(result2);
|
|
27224
27331
|
});
|
|
27225
27332
|
break;
|
|
@@ -27259,6 +27366,7 @@ function createAcpDriver(support12) {
|
|
|
27259
27366
|
}
|
|
27260
27367
|
}
|
|
27261
27368
|
if (support12.configureSession) {
|
|
27369
|
+
forgetStaleModeReport(session, support12);
|
|
27262
27370
|
const sessionModels = Array.isArray(sessionResult?.models?.availableModels) ? sessionResult.models.availableModels : [];
|
|
27263
27371
|
const configure = (model) => support12.configureSession({
|
|
27264
27372
|
request: (method, params, timeoutMs) => request(method, params, timeoutMs ?? SESSION_CONFIG_TIMEOUT),
|
|
@@ -27314,7 +27422,7 @@ function createAcpDriver(support12) {
|
|
|
27314
27422
|
}
|
|
27315
27423
|
emitSessionStarted();
|
|
27316
27424
|
const instructed = promptWithInstructions(threadId, sessionId, createdNativeSession, promptTurn);
|
|
27317
|
-
const
|
|
27425
|
+
const text5 = support12.buildPromptText ? support12.buildPromptText(instructed) : instructed.system ? `${instructed.system}
|
|
27318
27426
|
|
|
27319
27427
|
${instructed.text}` : instructed.text;
|
|
27320
27428
|
const imageBlocks = support12.images === true && runtimeAcceptsImages ? await readAcpImageBlocks(turn.images ?? []) : [];
|
|
@@ -27324,11 +27432,23 @@ ${instructed.text}` : instructed.text;
|
|
|
27324
27432
|
if (turn.variant !== void 0 && requestedVariantOption().currentValue !== turn.variant) {
|
|
27325
27433
|
throw new Error(`${support12.displayName} changed variant before the prompt`);
|
|
27326
27434
|
}
|
|
27435
|
+
armModeReadback({
|
|
27436
|
+
support: support12,
|
|
27437
|
+
session,
|
|
27438
|
+
config: turnConfig,
|
|
27439
|
+
turn: cliTurn,
|
|
27440
|
+
isCurrent: () => session.current === current && !current.state.settled,
|
|
27441
|
+
log: (readback) => appendNative(threadId, { dir: "out", source: SOURCE, msg: { approvalReadback: readback } }),
|
|
27442
|
+
stop: (message2) => {
|
|
27443
|
+
emit({ ...base2(threadId, turnId), type: "runtime.error", message: message2 });
|
|
27444
|
+
interrupt();
|
|
27445
|
+
}
|
|
27446
|
+
});
|
|
27327
27447
|
state2.promptSent = true;
|
|
27328
27448
|
const promptIdleMs = promptIdleTimeoutMs(support12, cliTurn.model);
|
|
27329
27449
|
const result = await request(
|
|
27330
27450
|
"session/prompt",
|
|
27331
|
-
{ sessionId, prompt: [{ type: "text", text:
|
|
27451
|
+
{ sessionId, prompt: [{ type: "text", text: text5 }, ...imageBlocks] },
|
|
27332
27452
|
void 0,
|
|
27333
27453
|
void 0,
|
|
27334
27454
|
promptIdleMs,
|
|
@@ -27450,7 +27570,7 @@ ${instructed.text}` : instructed.text;
|
|
|
27450
27570
|
}
|
|
27451
27571
|
};
|
|
27452
27572
|
}
|
|
27453
|
-
var envOr, INIT_TIMEOUT, SESSION_CONFIG_TIMEOUT, NEW_SESSION_TIMEOUT, LOAD_SESSION_TIMEOUT, DEFAULT_PROMPT_IDLE_MS, REASONING_PROMPT_IDLE_MS, REASONING_MODEL, promptIdleTimeoutMs, runningToolMaxMs, CLIENT_FILE_MAX_BYTES
|
|
27573
|
+
var envOr, INIT_TIMEOUT, SESSION_CONFIG_TIMEOUT, NEW_SESSION_TIMEOUT, LOAD_SESSION_TIMEOUT, DEFAULT_PROMPT_IDLE_MS, REASONING_PROMPT_IDLE_MS, REASONING_MODEL, promptIdleTimeoutMs, runningToolMaxMs, CLIENT_FILE_MAX_BYTES;
|
|
27454
27574
|
var init_core3 = __esm({
|
|
27455
27575
|
"server/drivers/acp/core.ts"() {
|
|
27456
27576
|
"use strict";
|
|
@@ -27472,6 +27592,8 @@ var init_core3 = __esm({
|
|
|
27472
27592
|
init_engine_failure();
|
|
27473
27593
|
init_turn_mcp();
|
|
27474
27594
|
init_volatile_notes();
|
|
27595
|
+
init_tool_log();
|
|
27596
|
+
init_mode_readback();
|
|
27475
27597
|
envOr = (key, fallback) => Number(process.env[key] ?? fallback);
|
|
27476
27598
|
INIT_TIMEOUT = envOr("OPENMAUS_ACP_INIT_TIMEOUT_MS", 3e5);
|
|
27477
27599
|
SESSION_CONFIG_TIMEOUT = envOr("OPENMAUS_ACP_SESSION_CONFIG_TIMEOUT_MS", 3e5);
|
|
@@ -27497,7 +27619,6 @@ var init_core3 = __esm({
|
|
|
27497
27619
|
return Number.isFinite(ms2) && ms2 > 0 ? ms2 : 60 * 6e4;
|
|
27498
27620
|
};
|
|
27499
27621
|
CLIENT_FILE_MAX_BYTES = 8 * 1024 * 1024;
|
|
27500
|
-
TOOL_LOG_TEXT_LIMIT = 64e3;
|
|
27501
27622
|
}
|
|
27502
27623
|
});
|
|
27503
27624
|
|
|
@@ -27611,11 +27732,11 @@ function validateAntigravityCallbackUrl(pending, callbackUrl) {
|
|
|
27611
27732
|
throw new Error("Paste the complete redirect URL from Google.");
|
|
27612
27733
|
}
|
|
27613
27734
|
const expected = new URL(pending.redirectUri);
|
|
27614
|
-
const
|
|
27735
|
+
const states2 = callback.searchParams.getAll("state");
|
|
27615
27736
|
const codes = callback.searchParams.getAll("code");
|
|
27616
27737
|
const errors = callback.searchParams.getAll("error");
|
|
27617
27738
|
const issuers = callback.searchParams.getAll("iss");
|
|
27618
|
-
if (callback.protocol !== "http:" || callback.hostname !== "127.0.0.1" || callback.origin !== expected.origin || callback.pathname !== expected.pathname || callback.username || callback.password || callback.hash ||
|
|
27739
|
+
if (callback.protocol !== "http:" || callback.hostname !== "127.0.0.1" || callback.origin !== expected.origin || callback.pathname !== expected.pathname || callback.username || callback.password || callback.hash || states2.length !== 1 || states2[0] !== pending.state || !(codes.length === 1 && codes[0] && errors.length === 0 || errors.length === 1 && errors[0] && codes.length === 0) || issuers.length > 1 || issuers.length === 1 && issuers[0] !== "https://accounts.google.com") throw new Error("This redirect URL does not belong to the current sign-in.");
|
|
27619
27740
|
return callback;
|
|
27620
27741
|
}
|
|
27621
27742
|
function forwardAntigravityCallback(callback) {
|
|
@@ -28772,14 +28893,14 @@ var init_boxagent = __esm({
|
|
|
28772
28893
|
let pendingText = "";
|
|
28773
28894
|
let problem = null;
|
|
28774
28895
|
const flushAssistantText = () => {
|
|
28775
|
-
const
|
|
28896
|
+
const text5 = pendingText;
|
|
28776
28897
|
pendingText = "";
|
|
28777
|
-
if (!
|
|
28778
|
-
emit({ ...base2(threadId, turnId), type: "item.completed", itemType: "assistant_text", text:
|
|
28898
|
+
if (!text5.trim()) return;
|
|
28899
|
+
emit({ ...base2(threadId, turnId), type: "item.completed", itemType: "assistant_text", text: text5 });
|
|
28779
28900
|
};
|
|
28780
|
-
const ingest = (
|
|
28781
|
-
const delta =
|
|
28782
|
-
lastText =
|
|
28901
|
+
const ingest = (text5) => {
|
|
28902
|
+
const delta = text5.startsWith(lastText) ? text5.slice(lastText.length) : text5;
|
|
28903
|
+
lastText = text5;
|
|
28783
28904
|
if (!delta) return;
|
|
28784
28905
|
pendingText += delta;
|
|
28785
28906
|
emit({ ...base2(threadId, turnId), type: "content.delta", streamKind: "assistant_text", delta });
|
|
@@ -28797,9 +28918,9 @@ var init_boxagent = __esm({
|
|
|
28797
28918
|
seen.add(id);
|
|
28798
28919
|
appendNative(threadId, { dir: "in", source: "box.events", msg: ev });
|
|
28799
28920
|
const kind = String(ev.type ?? ev.kind ?? "");
|
|
28800
|
-
const
|
|
28801
|
-
if (/assistant|message|output|response/i.test(kind) && typeof
|
|
28802
|
-
ingest(
|
|
28921
|
+
const text5 = ev.text ?? ev.message ?? ev.data?.text ?? ev.data?.content ?? null;
|
|
28922
|
+
if (/assistant|message|output|response/i.test(kind) && typeof text5 === "string" && text5.trim()) {
|
|
28923
|
+
ingest(text5);
|
|
28803
28924
|
} else if (/usage_limit|error|fail/i.test(kind)) {
|
|
28804
28925
|
const why = ev.data?.summary ?? ev.data?.message ?? ev.data?.error ?? ev.message;
|
|
28805
28926
|
if (typeof why === "string" && why.trim()) problem = why.trim();
|
|
@@ -29418,8 +29539,8 @@ var init_rtk_rewrite = __esm({
|
|
|
29418
29539
|
|
|
29419
29540
|
// server/drivers/claude-stdin.ts
|
|
29420
29541
|
import { readFileSync as readFileSync9 } from "node:fs";
|
|
29421
|
-
function claudeUserMessage(
|
|
29422
|
-
if (!images?.length) return { type: "user", message: { role: "user", content:
|
|
29542
|
+
function claudeUserMessage(text5, images) {
|
|
29543
|
+
if (!images?.length) return { type: "user", message: { role: "user", content: text5 } };
|
|
29423
29544
|
const content = images.map((image) => ({
|
|
29424
29545
|
type: "image",
|
|
29425
29546
|
source: {
|
|
@@ -29428,7 +29549,7 @@ function claudeUserMessage(text4, images) {
|
|
|
29428
29549
|
data: readFileSync9(image.path).toString("base64")
|
|
29429
29550
|
}
|
|
29430
29551
|
}));
|
|
29431
|
-
if (
|
|
29552
|
+
if (text5) content.push({ type: "text", text: text5 });
|
|
29432
29553
|
return { type: "user", message: { role: "user", content } };
|
|
29433
29554
|
}
|
|
29434
29555
|
function diagnosticClaudeUserMessage(message2) {
|
|
@@ -29468,9 +29589,9 @@ function isControl(char) {
|
|
|
29468
29589
|
}
|
|
29469
29590
|
function oneLine(value) {
|
|
29470
29591
|
if (typeof value !== "string") return null;
|
|
29471
|
-
const
|
|
29472
|
-
if (!
|
|
29473
|
-
return
|
|
29592
|
+
const text5 = Array.from(value, (char) => isControl(char) ? " " : char).join("").replace(/\s+/g, " ").trim();
|
|
29593
|
+
if (!text5) return null;
|
|
29594
|
+
return text5.length > MAX_MESSAGE ? `${text5.slice(0, MAX_MESSAGE - 1)}\u2026` : text5;
|
|
29474
29595
|
}
|
|
29475
29596
|
function yesValue(field) {
|
|
29476
29597
|
if (field.type === "boolean") return true;
|
|
@@ -29588,7 +29709,7 @@ var init_claude_elicitation = __esm({
|
|
|
29588
29709
|
});
|
|
29589
29710
|
|
|
29590
29711
|
// shared/ask-question.ts
|
|
29591
|
-
function
|
|
29712
|
+
function text4(value, limit) {
|
|
29592
29713
|
if (typeof value !== "string") return void 0;
|
|
29593
29714
|
const trimmed = value.trim();
|
|
29594
29715
|
return trimmed ? trimmed.slice(0, limit) : void 0;
|
|
@@ -29598,18 +29719,18 @@ function isRecord3(value) {
|
|
|
29598
29719
|
}
|
|
29599
29720
|
function parseOption(value) {
|
|
29600
29721
|
if (typeof value === "string") {
|
|
29601
|
-
const label2 =
|
|
29722
|
+
const label2 = text4(value, MAX_LABEL);
|
|
29602
29723
|
return label2 ? { label: label2 } : null;
|
|
29603
29724
|
}
|
|
29604
29725
|
if (!isRecord3(value)) return null;
|
|
29605
|
-
const label =
|
|
29726
|
+
const label = text4(value.label, MAX_LABEL);
|
|
29606
29727
|
if (!label) return null;
|
|
29607
|
-
const description =
|
|
29728
|
+
const description = text4(value.description, MAX_DESCRIPTION);
|
|
29608
29729
|
return description ? { label, description } : { label };
|
|
29609
29730
|
}
|
|
29610
29731
|
function parseQuestion(value) {
|
|
29611
29732
|
if (!isRecord3(value)) return null;
|
|
29612
|
-
const question =
|
|
29733
|
+
const question = text4(value.question, MAX_QUESTION_TEXT);
|
|
29613
29734
|
if (!question) return null;
|
|
29614
29735
|
const options = [];
|
|
29615
29736
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -29620,7 +29741,7 @@ function parseQuestion(value) {
|
|
|
29620
29741
|
options.push(option);
|
|
29621
29742
|
if (options.length === MAX_OPTIONS) break;
|
|
29622
29743
|
}
|
|
29623
|
-
const header =
|
|
29744
|
+
const header = text4(value.header, MAX_LABEL);
|
|
29624
29745
|
return {
|
|
29625
29746
|
question,
|
|
29626
29747
|
...header ? { header } : {},
|
|
@@ -29649,7 +29770,7 @@ function parseChoices(input, limit = MAX_CHOICES) {
|
|
|
29649
29770
|
const choices = [];
|
|
29650
29771
|
const seen = /* @__PURE__ */ new Set();
|
|
29651
29772
|
for (const raw of input) {
|
|
29652
|
-
const label = typeof raw === "string" ?
|
|
29773
|
+
const label = typeof raw === "string" ? text4(raw, MAX_LABEL) : isRecord3(raw) ? text4(raw.label, MAX_LABEL) : void 0;
|
|
29653
29774
|
if (!label || seen.has(label)) continue;
|
|
29654
29775
|
seen.add(label);
|
|
29655
29776
|
choices.push(label);
|
|
@@ -29706,19 +29827,19 @@ function resolveClaudeConfigDir(configDir2, env = process.env) {
|
|
|
29706
29827
|
}
|
|
29707
29828
|
return normalize(expanded);
|
|
29708
29829
|
}
|
|
29709
|
-
function claudeAuthFailure(frame,
|
|
29830
|
+
function claudeAuthFailure(frame, text5) {
|
|
29710
29831
|
if (frame.is_api_error_message !== true && typeof frame.error !== "string") return false;
|
|
29711
|
-
return frame.error === "authentication_failed" || classifyError({ text:
|
|
29832
|
+
return frame.error === "authentication_failed" || classifyError({ text: text5 }).reason === "auth_failed";
|
|
29712
29833
|
}
|
|
29713
|
-
function claudeCredentialRefreshConflict(frame,
|
|
29834
|
+
function claudeCredentialRefreshConflict(frame, text5) {
|
|
29714
29835
|
if (frame.is_api_error_message !== true && typeof frame.error !== "string") return false;
|
|
29715
|
-
return CREDENTIAL_REFRESH_CONFLICT.test(
|
|
29836
|
+
return CREDENTIAL_REFRESH_CONFLICT.test(text5);
|
|
29716
29837
|
}
|
|
29717
29838
|
function claudeResultStopReason(o) {
|
|
29718
|
-
const
|
|
29719
|
-
if (o.is_error !== true) return
|
|
29720
|
-
const subtype =
|
|
29721
|
-
return
|
|
29839
|
+
const text5 = (value) => typeof value === "string" && value.trim() ? value.trim() : null;
|
|
29840
|
+
if (o.is_error !== true) return text5(o.stop_reason) ?? text5(o.terminal_reason);
|
|
29841
|
+
const subtype = text5(o.subtype);
|
|
29842
|
+
return text5(o.terminal_reason) ?? (subtype && subtype !== "success" ? subtype : null) ?? "error";
|
|
29722
29843
|
}
|
|
29723
29844
|
function claudeEnvironment(model, source2 = process.env, configDir2, instanceEnvironment = {}) {
|
|
29724
29845
|
const env = { ...source2, PATH: augmentedPath(), NPM_CONFIG_LOGLEVEL: "error" };
|
|
@@ -30898,24 +31019,24 @@ var init_claude = __esm({
|
|
|
30898
31019
|
level: typeof msg.model === "string" ? "response-reported" : "unknown"
|
|
30899
31020
|
});
|
|
30900
31021
|
}
|
|
30901
|
-
const
|
|
30902
|
-
if (claudeAuthFailure(o,
|
|
31022
|
+
const text5 = firstText(msg.content);
|
|
31023
|
+
if (claudeAuthFailure(o, text5)) {
|
|
30903
31024
|
if (session.turn) session.turn.authFailed = true;
|
|
30904
|
-
emit({ ...base2(threadId, currentTurnId()), type: "runtime.error", message:
|
|
31025
|
+
emit({ ...base2(threadId, currentTurnId()), type: "runtime.error", message: text5, setup: true, failure: "auth_failed" });
|
|
30905
31026
|
break;
|
|
30906
31027
|
}
|
|
30907
|
-
if (claudeCredentialRefreshConflict(o,
|
|
30908
|
-
if (session.turn) session.turn.refreshConflict =
|
|
31028
|
+
if (claudeCredentialRefreshConflict(o, text5)) {
|
|
31029
|
+
if (session.turn) session.turn.refreshConflict = text5.trim();
|
|
30909
31030
|
break;
|
|
30910
31031
|
}
|
|
30911
|
-
if (
|
|
30912
|
-
if (
|
|
31032
|
+
if (text5.trim() && o.is_api_error_message !== true && typeof o.error !== "string" && session.turn) session.turn.produced = true;
|
|
31033
|
+
if (text5.trim()) {
|
|
30913
31034
|
const synthetic = o.is_api_error_message === true || typeof o.error === "string" ? { synthetic: true } : {};
|
|
30914
31035
|
if (!session.turn?.sawStreamDelta) {
|
|
30915
|
-
emit({ ...base2(threadId, currentTurnId()), ...synthetic, type: "content.delta", streamKind: "assistant_text", delta:
|
|
31036
|
+
emit({ ...base2(threadId, currentTurnId()), ...synthetic, type: "content.delta", streamKind: "assistant_text", delta: text5 });
|
|
30916
31037
|
}
|
|
30917
31038
|
if (session.turn) session.turn.sawStreamDelta = false;
|
|
30918
|
-
emit({ ...base2(threadId, currentTurnId()), ...synthetic, type: "item.completed", itemType: "assistant_text", text:
|
|
31039
|
+
emit({ ...base2(threadId, currentTurnId()), ...synthetic, type: "item.completed", itemType: "assistant_text", text: text5 });
|
|
30919
31040
|
}
|
|
30920
31041
|
for (const b3 of Array.isArray(msg.content) ? msg.content : []) {
|
|
30921
31042
|
if (b3.type === "tool_use") {
|
|
@@ -31166,12 +31287,12 @@ var init_claude = __esm({
|
|
|
31166
31287
|
}
|
|
31167
31288
|
return { turnId };
|
|
31168
31289
|
};
|
|
31169
|
-
const steer = async (threadId,
|
|
31290
|
+
const steer = async (threadId, text5) => {
|
|
31170
31291
|
const s4 = sessions.get(threadId);
|
|
31171
31292
|
if (!s4 || !s4.turn || s4.turn.settled || s4.closing || s4.child.exitCode !== null) return "refused";
|
|
31172
31293
|
const turn = s4.turn;
|
|
31173
31294
|
turn.pendingSteers = (turn.pendingSteers ?? 0) + 1;
|
|
31174
|
-
if (await writeUser(s4, threadId, claudeUserMessage(
|
|
31295
|
+
if (await writeUser(s4, threadId, claudeUserMessage(text5, void 0))) return "steered";
|
|
31175
31296
|
turn.pendingSteers = Math.max(0, turn.pendingSteers - 1);
|
|
31176
31297
|
return "refused";
|
|
31177
31298
|
};
|
|
@@ -31406,42 +31527,42 @@ var init_codex_tool_surface = __esm({
|
|
|
31406
31527
|
});
|
|
31407
31528
|
|
|
31408
31529
|
// server/toml-lite.ts
|
|
31409
|
-
function parseTomlLite(
|
|
31530
|
+
function parseTomlLite(text5) {
|
|
31410
31531
|
const root = {};
|
|
31411
31532
|
let current = root;
|
|
31412
31533
|
let pos = 0;
|
|
31413
|
-
const peek = () =>
|
|
31534
|
+
const peek = () => text5[pos];
|
|
31414
31535
|
const skipSpaces = () => {
|
|
31415
|
-
while (pos <
|
|
31536
|
+
while (pos < text5.length && (text5[pos] === " " || text5[pos] === " ")) pos += 1;
|
|
31416
31537
|
};
|
|
31417
31538
|
const skipComment = () => {
|
|
31418
|
-
if (
|
|
31539
|
+
if (text5[pos] === "#") while (pos < text5.length && text5[pos] !== "\n") pos += 1;
|
|
31419
31540
|
};
|
|
31420
31541
|
const skipBlank = () => {
|
|
31421
31542
|
for (; ; ) {
|
|
31422
31543
|
const before = pos;
|
|
31423
|
-
while (pos <
|
|
31544
|
+
while (pos < text5.length && /[ \t\r\n]/.test(text5[pos])) pos += 1;
|
|
31424
31545
|
skipComment();
|
|
31425
31546
|
if (pos === before) return;
|
|
31426
31547
|
}
|
|
31427
31548
|
};
|
|
31428
31549
|
const skipLine = () => {
|
|
31429
|
-
while (pos <
|
|
31550
|
+
while (pos < text5.length && text5[pos] !== "\n") pos += 1;
|
|
31430
31551
|
};
|
|
31431
31552
|
const basicString = () => {
|
|
31432
|
-
const multi =
|
|
31553
|
+
const multi = text5.startsWith('"""', pos);
|
|
31433
31554
|
pos += multi ? 3 : 1;
|
|
31434
|
-
if (multi &&
|
|
31555
|
+
if (multi && text5[pos] === "\n") pos += 1;
|
|
31435
31556
|
let out = "";
|
|
31436
|
-
while (pos <
|
|
31437
|
-
if (multi ?
|
|
31557
|
+
while (pos < text5.length) {
|
|
31558
|
+
if (multi ? text5.startsWith('"""', pos) : text5[pos] === '"') {
|
|
31438
31559
|
pos += multi ? 3 : 1;
|
|
31439
31560
|
return out;
|
|
31440
31561
|
}
|
|
31441
|
-
const ch =
|
|
31562
|
+
const ch = text5[pos];
|
|
31442
31563
|
if (!multi && ch === "\n") throw new TomlError("unterminated string");
|
|
31443
31564
|
if (ch === "\\") {
|
|
31444
|
-
const next =
|
|
31565
|
+
const next = text5[pos + 1];
|
|
31445
31566
|
pos += 2;
|
|
31446
31567
|
if (next === "n") out += "\n";
|
|
31447
31568
|
else if (next === "t") out += " ";
|
|
@@ -31449,10 +31570,10 @@ function parseTomlLite(text4) {
|
|
|
31449
31570
|
else if (next === '"' || next === "\\") out += next;
|
|
31450
31571
|
else if (next === "u" || next === "U") {
|
|
31451
31572
|
const length = next === "u" ? 4 : 8;
|
|
31452
|
-
out += String.fromCodePoint(parseInt(
|
|
31573
|
+
out += String.fromCodePoint(parseInt(text5.slice(pos, pos + length), 16));
|
|
31453
31574
|
pos += length;
|
|
31454
31575
|
} else if (multi && next === "\n") {
|
|
31455
|
-
while (pos <
|
|
31576
|
+
while (pos < text5.length && /[ \t\r\n]/.test(text5[pos])) pos += 1;
|
|
31456
31577
|
} else out += next ?? "";
|
|
31457
31578
|
continue;
|
|
31458
31579
|
}
|
|
@@ -31462,12 +31583,12 @@ function parseTomlLite(text4) {
|
|
|
31462
31583
|
throw new TomlError("unterminated string");
|
|
31463
31584
|
};
|
|
31464
31585
|
const literalString = () => {
|
|
31465
|
-
const multi =
|
|
31586
|
+
const multi = text5.startsWith("'''", pos);
|
|
31466
31587
|
pos += multi ? 3 : 1;
|
|
31467
|
-
if (multi &&
|
|
31468
|
-
const end =
|
|
31588
|
+
if (multi && text5[pos] === "\n") pos += 1;
|
|
31589
|
+
const end = text5.indexOf(multi ? "'''" : "'", pos);
|
|
31469
31590
|
if (end < 0) throw new TomlError("unterminated string");
|
|
31470
|
-
const value2 =
|
|
31591
|
+
const value2 = text5.slice(pos, end);
|
|
31471
31592
|
if (!multi && value2.includes("\n")) throw new TomlError("unterminated string");
|
|
31472
31593
|
pos = end + (multi ? 3 : 1);
|
|
31473
31594
|
return value2;
|
|
@@ -31477,9 +31598,9 @@ function parseTomlLite(text4) {
|
|
|
31477
31598
|
if (peek() === '"') return basicString();
|
|
31478
31599
|
if (peek() === "'") return literalString();
|
|
31479
31600
|
const start = pos;
|
|
31480
|
-
while (pos <
|
|
31601
|
+
while (pos < text5.length && /[A-Za-z0-9_-]/.test(text5[pos])) pos += 1;
|
|
31481
31602
|
if (pos === start) throw new TomlError("expected a key");
|
|
31482
|
-
return
|
|
31603
|
+
return text5.slice(start, pos);
|
|
31483
31604
|
};
|
|
31484
31605
|
const keyPath = () => {
|
|
31485
31606
|
const parts = [key()];
|
|
@@ -31531,8 +31652,8 @@ function parseTomlLite(text4) {
|
|
|
31531
31652
|
}
|
|
31532
31653
|
}
|
|
31533
31654
|
const start = pos;
|
|
31534
|
-
while (pos <
|
|
31535
|
-
const raw =
|
|
31655
|
+
while (pos < text5.length && !/[,\]}\r\n#]/.test(text5[pos])) pos += 1;
|
|
31656
|
+
const raw = text5.slice(start, pos).trim();
|
|
31536
31657
|
if (raw === "true") return true;
|
|
31537
31658
|
if (raw === "false") return false;
|
|
31538
31659
|
const number5 = Number(raw.replace(/_/g, ""));
|
|
@@ -31557,12 +31678,12 @@ function parseTomlLite(text4) {
|
|
|
31557
31678
|
const parent = tableAt(base2, path4.slice(0, -1));
|
|
31558
31679
|
parent[path4[path4.length - 1]] = item;
|
|
31559
31680
|
}
|
|
31560
|
-
while (pos <
|
|
31681
|
+
while (pos < text5.length) {
|
|
31561
31682
|
skipBlank();
|
|
31562
|
-
if (pos >=
|
|
31683
|
+
if (pos >= text5.length) break;
|
|
31563
31684
|
const lineStart = pos;
|
|
31564
31685
|
try {
|
|
31565
|
-
if (
|
|
31686
|
+
if (text5.startsWith("[[", pos)) {
|
|
31566
31687
|
pos += 2;
|
|
31567
31688
|
keyPath();
|
|
31568
31689
|
current = {};
|
|
@@ -32137,7 +32258,7 @@ function unquote(raw) {
|
|
|
32137
32258
|
}
|
|
32138
32259
|
return value;
|
|
32139
32260
|
}
|
|
32140
|
-
function parseCodexToml(
|
|
32261
|
+
function parseCodexToml(text5) {
|
|
32141
32262
|
const result = { providers: [] };
|
|
32142
32263
|
const byId = /* @__PURE__ */ new Map();
|
|
32143
32264
|
let section = "root";
|
|
@@ -32150,7 +32271,7 @@ function parseCodexToml(text4) {
|
|
|
32150
32271
|
}
|
|
32151
32272
|
return provider;
|
|
32152
32273
|
};
|
|
32153
|
-
for (const line of
|
|
32274
|
+
for (const line of text5.split(/\r?\n/)) {
|
|
32154
32275
|
const stripped = line.trim();
|
|
32155
32276
|
if (!stripped || stripped.startsWith("#")) continue;
|
|
32156
32277
|
if (stripped.startsWith("[") && stripped.endsWith("]")) {
|
|
@@ -33411,14 +33532,14 @@ var init_codex = __esm({
|
|
|
33411
33532
|
emit({ ...base2(threadId, turnId), type: "runtime.error", message: "codex did not shut down after termination was requested" });
|
|
33412
33533
|
}
|
|
33413
33534
|
};
|
|
33414
|
-
const steerActiveTurn = async (
|
|
33535
|
+
const steerActiveTurn = async (text5) => {
|
|
33415
33536
|
if (state2.settled || abandoned || stopRequested || !codexThreadId || !codexTurnId) return "refused";
|
|
33416
33537
|
if (child.exitCode !== null || child.signalCode !== null) return "refused";
|
|
33417
33538
|
try {
|
|
33418
33539
|
const steerTimeoutMs = Math.max(1, Number(process.env.FAKE_CODEX_STEER_TIMEOUT_MS ?? 1e4) || 1e4);
|
|
33419
33540
|
await request("turn/steer", {
|
|
33420
33541
|
threadId: codexThreadId,
|
|
33421
|
-
input: [{ type: "text", text:
|
|
33542
|
+
input: [{ type: "text", text: text5 }],
|
|
33422
33543
|
expectedTurnId: codexTurnId
|
|
33423
33544
|
}, steerTimeoutMs);
|
|
33424
33545
|
return "steered";
|
|
@@ -34025,9 +34146,9 @@ ${status.stderr}`)) {
|
|
|
34025
34146
|
interruptTurn: async (threadId) => {
|
|
34026
34147
|
await active.get(threadId)?.stop();
|
|
34027
34148
|
},
|
|
34028
|
-
steer: async (threadId,
|
|
34149
|
+
steer: async (threadId, text5) => {
|
|
34029
34150
|
const turn = active.get(threadId);
|
|
34030
|
-
return turn?.steer ? await turn.steer(
|
|
34151
|
+
return turn?.steer ? await turn.steer(text5) : "refused";
|
|
34031
34152
|
},
|
|
34032
34153
|
respondToRequest: async (threadId, requestId, decision) => {
|
|
34033
34154
|
const turn = active.get(threadId);
|
|
@@ -38648,7 +38769,7 @@ var require_core = __commonJS({
|
|
|
38648
38769
|
errorsText(errors = this.errors, { separator = ", ", dataVar = "data" } = {}) {
|
|
38649
38770
|
if (!errors || errors.length === 0)
|
|
38650
38771
|
return "No errors";
|
|
38651
|
-
return errors.map((e) => `${dataVar}${e.instancePath} ${e.message}`).reduce((
|
|
38772
|
+
return errors.map((e) => `${dataVar}${e.instancePath} ${e.message}`).reduce((text5, msg) => text5 + separator + msg);
|
|
38652
38773
|
}
|
|
38653
38774
|
$dataMetaSchema(metaSchema, keywordsJsonPointers) {
|
|
38654
38775
|
const rules = this.RULES.all;
|
|
@@ -43134,6 +43255,7 @@ var init_chat_box_tools = __esm({
|
|
|
43134
43255
|
});
|
|
43135
43256
|
|
|
43136
43257
|
// server/drivers/chat-mcp-tools.ts
|
|
43258
|
+
import { homedir as homedir16 } from "node:os";
|
|
43137
43259
|
function object2(value) {
|
|
43138
43260
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
43139
43261
|
}
|
|
@@ -43168,7 +43290,17 @@ function boundedText(value) {
|
|
|
43168
43290
|
return `${bytes.subarray(0, end).toString()}
|
|
43169
43291
|
[MCP result truncated at 50KB; request less output.]`;
|
|
43170
43292
|
}
|
|
43171
|
-
|
|
43293
|
+
function namesBlockedPath(args, roots, home = homedir16()) {
|
|
43294
|
+
const slash = (text5) => text5.replaceAll("\\", "/").toLowerCase();
|
|
43295
|
+
const needles = roots.flatMap((root) => {
|
|
43296
|
+
const full = slash(root).replace(/\/+$/, "");
|
|
43297
|
+
const base2 = slash(home).replace(/\/+$/, "");
|
|
43298
|
+
return full.startsWith(`${base2}/`) ? [full, `~/${full.slice(base2.length + 1)}`, full.slice(base2.length + 1)] : [full];
|
|
43299
|
+
});
|
|
43300
|
+
const visit3 = (value) => typeof value === "string" ? needles.some((needle) => slash(value).includes(needle)) : Array.isArray(value) ? value.some(visit3) : object2(value) ? Object.values(value).some(visit3) : false;
|
|
43301
|
+
return needles.length > 0 && visit3(args);
|
|
43302
|
+
}
|
|
43303
|
+
async function mountChatTools(integrations, signal, computerUse = false, report = reportMcpFailure, blockedPaths = []) {
|
|
43172
43304
|
const servers = [];
|
|
43173
43305
|
if (computerUse && integrations?.computer) servers.push(["computer", integrations.computer]);
|
|
43174
43306
|
if (computerUse && integrations?.localComputer) servers.push(["computer", integrations.localComputer]);
|
|
@@ -43286,6 +43418,9 @@ async function mountChatTools(integrations, signal, computerUse = false, report
|
|
|
43286
43418
|
if (!tool2) throw new Error("The requested tool was not advertised for this turn");
|
|
43287
43419
|
if (dropped.has(tool2.server)) throw new Error(`The "${tool2.server}" tools stopped working earlier in this turn and are unavailable now; carry on without them.`);
|
|
43288
43420
|
if (!object2(args) || !tool2.schema(args)) throw new Error("Tool arguments do not match the advertised input schema; use its required fields and types");
|
|
43421
|
+
if (namesBlockedPath(args, blockedPaths)) {
|
|
43422
|
+
throw new Error("This turn runs on a free model, so the PAW and ICM folders are off limits. Work only from the message itself.");
|
|
43423
|
+
}
|
|
43289
43424
|
};
|
|
43290
43425
|
return {
|
|
43291
43426
|
definitions,
|
|
@@ -43749,7 +43884,7 @@ function createOpenAIChatRuntime(options) {
|
|
|
43749
43884
|
if (!response.body) {
|
|
43750
43885
|
throw new Error(options.noBodyError ?? `${options.httpErrorLabel} returned no response body`);
|
|
43751
43886
|
}
|
|
43752
|
-
let
|
|
43887
|
+
let text5 = "";
|
|
43753
43888
|
let reasoning = "";
|
|
43754
43889
|
let protocolReasoning = "";
|
|
43755
43890
|
let usage = null;
|
|
@@ -43791,7 +43926,7 @@ function createOpenAIChatRuntime(options) {
|
|
|
43791
43926
|
onDelta?.(reasoningDelta, "reasoning_text");
|
|
43792
43927
|
}
|
|
43793
43928
|
if (contentDelta) {
|
|
43794
|
-
|
|
43929
|
+
text5 += contentDelta;
|
|
43795
43930
|
onDelta?.(contentDelta, "assistant_text");
|
|
43796
43931
|
}
|
|
43797
43932
|
if (chunk.usage) usage = usageFrom(chunk.usage);
|
|
@@ -43833,7 +43968,7 @@ function createOpenAIChatRuntime(options) {
|
|
|
43833
43968
|
}
|
|
43834
43969
|
activeSignal.throwIfAborted();
|
|
43835
43970
|
if (!sawChoice) throw new ChatProtocolError("provider returned no streaming completion choice");
|
|
43836
|
-
return { text:
|
|
43971
|
+
return { text: text5, reasoning, usage, toolCalls: calls.finish(finishReason, malformedFrame), finishReason, protocolReasoning, protocolReasoningDetails: details.blocks };
|
|
43837
43972
|
} finally {
|
|
43838
43973
|
if (idleTimer) clearTimeout(idleTimer);
|
|
43839
43974
|
}
|
|
@@ -43866,8 +44001,8 @@ function createOpenAIChatRuntime(options) {
|
|
|
43866
44001
|
}
|
|
43867
44002
|
}
|
|
43868
44003
|
}
|
|
43869
|
-
const safeText = (
|
|
43870
|
-
let safe =
|
|
44004
|
+
const safeText = (text5) => {
|
|
44005
|
+
let safe = text5;
|
|
43871
44006
|
for (const secret of secrets) if (secret) safe = safe.split(secret).join("[redacted]");
|
|
43872
44007
|
return redactSecretsInText(safe);
|
|
43873
44008
|
};
|
|
@@ -43915,7 +44050,7 @@ function createOpenAIChatRuntime(options) {
|
|
|
43915
44050
|
const denials = [];
|
|
43916
44051
|
const seenCalls = /* @__PURE__ */ new Set();
|
|
43917
44052
|
try {
|
|
43918
|
-
tools = await mountChatTools(options.tools === false ? void 0 : turn.integrations, abort.signal, options.computerUse);
|
|
44053
|
+
tools = await mountChatTools(options.tools === false ? void 0 : turn.integrations, abort.signal, options.computerUse, void 0, turn.blockedPaths);
|
|
43919
44054
|
for (let round = 0; round < 16; round++) {
|
|
43920
44055
|
abort.signal.throwIfAborted();
|
|
43921
44056
|
native("out", options.nativeLog.outgoing(turn, messages, model));
|
|
@@ -43924,8 +44059,8 @@ function createOpenAIChatRuntime(options) {
|
|
|
43924
44059
|
for (; ; ) {
|
|
43925
44060
|
let streamed = false;
|
|
43926
44061
|
const pending = { assistant_text: "", reasoning_text: "" };
|
|
43927
|
-
const delta = (
|
|
43928
|
-
let combined = pending[streamKind] +
|
|
44062
|
+
const delta = (text5, streamKind, flush = false) => {
|
|
44063
|
+
let combined = pending[streamKind] + text5;
|
|
43929
44064
|
for (const secret of secrets) if (secret) combined = combined.split(secret).join("[redacted]");
|
|
43930
44065
|
let hold = 0;
|
|
43931
44066
|
if (!flush) for (const secret of secrets) {
|
|
@@ -43944,9 +44079,9 @@ function createOpenAIChatRuntime(options) {
|
|
|
43944
44079
|
const callId = newId();
|
|
43945
44080
|
emit({ ...base2(turn.threadId, turnId), type: "model.call", callId });
|
|
43946
44081
|
let previousIdentity = "";
|
|
43947
|
-
completion = await complete(messages, model, true, abort.signal, (
|
|
44082
|
+
completion = await complete(messages, model, true, abort.signal, (text5, streamKind) => {
|
|
43948
44083
|
streamed = true;
|
|
43949
|
-
delta(
|
|
44084
|
+
delta(text5, streamKind);
|
|
43950
44085
|
}, tools.definitions, (reportedModel, responseId) => {
|
|
43951
44086
|
const identity = JSON.stringify([reportedModel, responseId]);
|
|
43952
44087
|
if (identity === previousIdentity) return;
|
|
@@ -44047,11 +44182,11 @@ function createOpenAIChatRuntime(options) {
|
|
|
44047
44182
|
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) };
|
|
44048
44183
|
}
|
|
44049
44184
|
if (!started) emit({ ...base2(turn.threadId, turnId), type: "item.started", itemType: "tool", itemId: call.id, title: call.function.name });
|
|
44050
|
-
const
|
|
44051
|
-
const output = preview({ ok: result.ok, result:
|
|
44185
|
+
const text5 = safeText(result.text);
|
|
44186
|
+
const output = preview({ ok: result.ok, result: text5 });
|
|
44052
44187
|
emit({ ...base2(turn.threadId, turnId), type: "item.completed", itemType: "tool", itemId: call.id, ok: result.ok, output });
|
|
44053
44188
|
if (!result.ok) toolFailed = true;
|
|
44054
|
-
messages.push({ role: "tool", tool_call_id: call.id, content: JSON.stringify({ ok: result.ok, result:
|
|
44189
|
+
messages.push({ role: "tool", tool_call_id: call.id, content: JSON.stringify({ ok: result.ok, result: text5 }) });
|
|
44055
44190
|
screenshotParts.push(...chatToolImages(call.id, result.images));
|
|
44056
44191
|
abort.signal.throwIfAborted();
|
|
44057
44192
|
if (fatal) throw fatal;
|
|
@@ -44143,9 +44278,9 @@ function createOpenAIChatRuntime(options) {
|
|
|
44143
44278
|
},
|
|
44144
44279
|
generateText: async (prompt, { signal } = {}) => {
|
|
44145
44280
|
const model = options.generateModel?.() ?? options.models().default;
|
|
44146
|
-
const { text:
|
|
44281
|
+
const { text: text5, reasoning, toolCalls } = await complete([{ role: "user", content: prompt }], model, false, signal);
|
|
44147
44282
|
if (toolCalls.length) throw new ChatProtocolError("provider returned tool calls to a text-only helper");
|
|
44148
|
-
return
|
|
44283
|
+
return text5.trim() ? text5 : reasoning;
|
|
44149
44284
|
},
|
|
44150
44285
|
dispose: async () => {
|
|
44151
44286
|
const turns = [...active.values()];
|
|
@@ -44226,7 +44361,7 @@ var init_grok = __esm({
|
|
|
44226
44361
|
nativeLog: {
|
|
44227
44362
|
source: "xai.chat.completions",
|
|
44228
44363
|
outgoing: (_turn, messages, model) => ({ model, messages }),
|
|
44229
|
-
incoming: ({ text:
|
|
44364
|
+
incoming: ({ text: text5, usage }) => ({ text: text5, usage })
|
|
44230
44365
|
}
|
|
44231
44366
|
});
|
|
44232
44367
|
}
|
|
@@ -44236,14 +44371,14 @@ var init_grok = __esm({
|
|
|
44236
44371
|
|
|
44237
44372
|
// server/drivers/acp/grok.ts
|
|
44238
44373
|
import { existsSync as existsSync16, readFileSync as readFileSync19, writeFileSync as writeFileSync12 } from "node:fs";
|
|
44239
|
-
import { homedir as
|
|
44374
|
+
import { homedir as homedir17 } from "node:os";
|
|
44240
44375
|
import { join as join35 } from "node:path";
|
|
44241
|
-
function decodeGrokModelText(
|
|
44242
|
-
if (/\bnot authenticated\b/i.test(
|
|
44376
|
+
function decodeGrokModelText(text5) {
|
|
44377
|
+
if (/\bnot authenticated\b/i.test(text5)) return null;
|
|
44243
44378
|
const options = [];
|
|
44244
44379
|
let listed = null;
|
|
44245
44380
|
let stated = null;
|
|
44246
|
-
for (const raw of
|
|
44381
|
+
for (const raw of text5.split(/\r?\n/)) {
|
|
44247
44382
|
const line = raw.trim();
|
|
44248
44383
|
const header = /^default model:\s*(\S+)/i.exec(line);
|
|
44249
44384
|
if (header) {
|
|
@@ -44271,7 +44406,7 @@ function fetchGrokModels(cli, env, run2 = execCli) {
|
|
|
44271
44406
|
}
|
|
44272
44407
|
function grokHome(env) {
|
|
44273
44408
|
if (env.GROK_HOME) return env.GROK_HOME;
|
|
44274
|
-
return join35(env.HOME || env.USERPROFILE ||
|
|
44409
|
+
return join35(env.HOME || env.USERPROFILE || homedir17(), ".grok");
|
|
44275
44410
|
}
|
|
44276
44411
|
function unquote2(raw) {
|
|
44277
44412
|
const value = raw.trim();
|
|
@@ -44282,9 +44417,9 @@ function unquote2(raw) {
|
|
|
44282
44417
|
}
|
|
44283
44418
|
function readGrokModelCatalog(env = process.env, base2 = STATIC_GROK_MODELS) {
|
|
44284
44419
|
const path4 = join35(grokHome(env), "config.toml");
|
|
44285
|
-
let
|
|
44420
|
+
let text5 = "";
|
|
44286
44421
|
try {
|
|
44287
|
-
|
|
44422
|
+
text5 = readFileSync19(path4, "utf8");
|
|
44288
44423
|
} catch {
|
|
44289
44424
|
return base2;
|
|
44290
44425
|
}
|
|
@@ -44302,7 +44437,7 @@ function readGrokModelCatalog(env = process.env, base2 = STATIC_GROK_MODELS) {
|
|
|
44302
44437
|
options.push({ id: current.slug, label: current.name || current.slug, custom: true });
|
|
44303
44438
|
current = null;
|
|
44304
44439
|
};
|
|
44305
|
-
for (const line of
|
|
44440
|
+
for (const line of text5.split(/\r?\n/)) {
|
|
44306
44441
|
const stripped = line.trim();
|
|
44307
44442
|
if (stripped === "[models]") {
|
|
44308
44443
|
flush();
|
|
@@ -44338,8 +44473,8 @@ function readGrokModelCatalog(env = process.env, base2 = STATIC_GROK_MODELS) {
|
|
|
44338
44473
|
function classifyGrokError(error51) {
|
|
44339
44474
|
const message2 = error51 instanceof Error ? error51.message : String(error51 ?? "");
|
|
44340
44475
|
const data = error51 && typeof error51 === "object" ? error51.data : void 0;
|
|
44341
|
-
const
|
|
44342
|
-
return classifyEngineFailure(
|
|
44476
|
+
const text5 = `${message2} ${typeof data === "string" ? data : data ? JSON.stringify(data) : ""}`;
|
|
44477
|
+
return classifyEngineFailure(text5)?.kind === "usage_limited" ? "quota_or_region_restriction" : void 0;
|
|
44343
44478
|
}
|
|
44344
44479
|
function suggestGrokSlug(host, model, taken) {
|
|
44345
44480
|
let base2 = `${host}-${model}`.toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
@@ -44361,11 +44496,11 @@ function ensureGrokInjectSlug(modelId, env = process.env) {
|
|
|
44361
44496
|
const host = localHost(inject.host);
|
|
44362
44497
|
if (!host) return modelId;
|
|
44363
44498
|
const path4 = join35(grokHome(env), "config.toml");
|
|
44364
|
-
let
|
|
44499
|
+
let text5 = "";
|
|
44365
44500
|
try {
|
|
44366
|
-
|
|
44501
|
+
text5 = readFileSync19(path4, "utf8");
|
|
44367
44502
|
} catch {
|
|
44368
|
-
|
|
44503
|
+
text5 = "";
|
|
44369
44504
|
}
|
|
44370
44505
|
const taken = new Set(STATIC_GROK_MODELS.options.map((option) => option.id));
|
|
44371
44506
|
let current = null;
|
|
@@ -44378,7 +44513,7 @@ function ensureGrokInjectSlug(modelId, env = process.env) {
|
|
|
44378
44513
|
current = null;
|
|
44379
44514
|
};
|
|
44380
44515
|
let found = null;
|
|
44381
|
-
for (const line of
|
|
44516
|
+
for (const line of text5.split(/\r?\n/)) {
|
|
44382
44517
|
const stripped = line.trim();
|
|
44383
44518
|
if (stripped.startsWith("[model.") && stripped.endsWith("]")) {
|
|
44384
44519
|
flush();
|
|
@@ -44411,9 +44546,9 @@ function ensureGrokInjectSlug(modelId, env = process.env) {
|
|
|
44411
44546
|
`api_key = ${quoteToml(hostApiKey(host, env))}`,
|
|
44412
44547
|
""
|
|
44413
44548
|
].join("\n");
|
|
44414
|
-
const next =
|
|
44549
|
+
const next = text5 && !text5.endsWith("\n") ? `${text5}
|
|
44415
44550
|
|
|
44416
|
-
${block2}` : `${
|
|
44551
|
+
${block2}` : `${text5}${text5 ? "\n" : ""}${block2}`;
|
|
44417
44552
|
writeFileSync12(path4, next);
|
|
44418
44553
|
return slug;
|
|
44419
44554
|
}
|
|
@@ -44516,7 +44651,7 @@ var init_grok2 = __esm({
|
|
|
44516
44651
|
pickAuthMethod: (methods) => methods.some((m3) => m3.id === "cached_token") ? "cached_token" : null,
|
|
44517
44652
|
authFailure: "fail",
|
|
44518
44653
|
classifyError: classifyGrokError,
|
|
44519
|
-
isAuthenticated: (env) => existsSync16(env.GROK_HOME ? join35(env.GROK_HOME, "auth.json") : join35(
|
|
44654
|
+
isAuthenticated: (env) => existsSync16(env.GROK_HOME ? join35(env.GROK_HOME, "auth.json") : join35(homedir17(), ".grok", "auth.json")),
|
|
44520
44655
|
// `--append-system-prompt`/`--rules` are accepted by the CLI but do NOT
|
|
44521
44656
|
// reach the agent-stdio system prompt (verified against 1.0.0), so the
|
|
44522
44657
|
// persona is prepended codex-style.
|
|
@@ -44530,11 +44665,11 @@ ${turn.text}` : turn.text
|
|
|
44530
44665
|
|
|
44531
44666
|
// server/drivers/acp/gemini.ts
|
|
44532
44667
|
import { existsSync as existsSync17, readFileSync as readFileSync20 } from "node:fs";
|
|
44533
|
-
import { homedir as
|
|
44668
|
+
import { homedir as homedir18 } from "node:os";
|
|
44534
44669
|
import { join as join36 } from "node:path";
|
|
44535
44670
|
function liveOauthCredential() {
|
|
44536
44671
|
try {
|
|
44537
|
-
const creds = JSON.parse(readFileSync20(join36(
|
|
44672
|
+
const creds = JSON.parse(readFileSync20(join36(homedir18(), ".gemini", "oauth_creds.json"), "utf8"));
|
|
44538
44673
|
if (typeof creds.access_token !== "string" || creds.access_token.trim().length === 0) return false;
|
|
44539
44674
|
const hasRefresh = typeof creds.refresh_token === "string" && creds.refresh_token.trim().length > 0;
|
|
44540
44675
|
if (creds.expiry_date !== void 0) {
|
|
@@ -44547,13 +44682,18 @@ function liveOauthCredential() {
|
|
|
44547
44682
|
}
|
|
44548
44683
|
}
|
|
44549
44684
|
function geminiIsAuthenticated(env) {
|
|
44550
|
-
return nonBlank(env.GEMINI_API_KEY) || nonBlank(env.GOOGLE_API_KEY) || existsSync17(join36(
|
|
44685
|
+
return nonBlank(env.GEMINI_API_KEY) || nonBlank(env.GOOGLE_API_KEY) || existsSync17(join36(homedir18(), ".gemini", "oauth_creds.json")) && liveOauthCredential();
|
|
44551
44686
|
}
|
|
44552
44687
|
function geminiApprovalArgs(fullAuto, approvalMode) {
|
|
44553
44688
|
if (fullAuto) return ["--yolo"];
|
|
44554
44689
|
if (approvalMode === "edits") return ["--approval-mode", "auto_edit"];
|
|
44555
44690
|
return [];
|
|
44556
44691
|
}
|
|
44692
|
+
function geminiExpectedMode(fullAuto, approvalMode) {
|
|
44693
|
+
if (fullAuto) return "yolo";
|
|
44694
|
+
if (approvalMode === "edits") return "autoEdit";
|
|
44695
|
+
return "default";
|
|
44696
|
+
}
|
|
44557
44697
|
var AUTH_PREFERENCE, nonBlank, support3, GeminiAgentDriver;
|
|
44558
44698
|
var init_gemini = __esm({
|
|
44559
44699
|
"server/drivers/acp/gemini.ts"() {
|
|
@@ -44563,6 +44703,8 @@ var init_gemini = __esm({
|
|
|
44563
44703
|
nonBlank = (value) => Boolean(value?.trim());
|
|
44564
44704
|
support3 = {
|
|
44565
44705
|
driverKind: "geminiAgent",
|
|
44706
|
+
// Gemini takes the mode on argv; session/new reports the one it applied.
|
|
44707
|
+
approvalModeReadback: { ladder: "geminiAgent", expected: (config2, turn) => geminiExpectedMode(config2.fullAuto, turn.approvalMode) },
|
|
44566
44708
|
displayName: "Gemini",
|
|
44567
44709
|
models: {
|
|
44568
44710
|
default: "gemini-2.5-pro",
|
|
@@ -44595,13 +44737,13 @@ ${turn.text}` : turn.text
|
|
|
44595
44737
|
|
|
44596
44738
|
// server/drivers/acp/kimi.ts
|
|
44597
44739
|
import { existsSync as existsSync18, mkdirSync as mkdirSync17, readFileSync as readFileSync21, writeFileSync as writeFileSync13 } from "node:fs";
|
|
44598
|
-
import { homedir as
|
|
44740
|
+
import { homedir as homedir19 } from "node:os";
|
|
44599
44741
|
import { join as join37 } from "node:path";
|
|
44600
44742
|
function isLocalInjectAlias(slug) {
|
|
44601
44743
|
return LOCAL_PROVIDER_PREFIXES.some((prefix) => slug.startsWith(prefix));
|
|
44602
44744
|
}
|
|
44603
44745
|
function kimiDataRoot(env) {
|
|
44604
|
-
return env.KIMI_CODE_HOME || join37(env.HOME || env.USERPROFILE ||
|
|
44746
|
+
return env.KIMI_CODE_HOME || join37(env.HOME || env.USERPROFILE || homedir19(), ".kimi-code");
|
|
44605
44747
|
}
|
|
44606
44748
|
function credentialsPath(env) {
|
|
44607
44749
|
return join37(kimiDataRoot(env), "credentials", "kimi-code.json");
|
|
@@ -44630,18 +44772,18 @@ function stripTomlLineComment(line) {
|
|
|
44630
44772
|
}
|
|
44631
44773
|
return line;
|
|
44632
44774
|
}
|
|
44633
|
-
function takeTomlBasicEscape(
|
|
44634
|
-
const code =
|
|
44775
|
+
function takeTomlBasicEscape(text5, i2) {
|
|
44776
|
+
const code = text5[i2 + 1];
|
|
44635
44777
|
if (code === void 0) return { ok: false };
|
|
44636
44778
|
if (code === "u") {
|
|
44637
|
-
const hex3 =
|
|
44779
|
+
const hex3 = text5.slice(i2 + 2, i2 + 6);
|
|
44638
44780
|
if (!/^[0-9a-fA-F]{4}$/.test(hex3)) return { ok: false };
|
|
44639
44781
|
const point = parseInt(hex3, 16);
|
|
44640
44782
|
if (point >= 55296 && point <= 57343) return { ok: false };
|
|
44641
44783
|
return { ok: true, value: String.fromCharCode(point), next: i2 + 6 };
|
|
44642
44784
|
}
|
|
44643
44785
|
if (code === "U") {
|
|
44644
|
-
const hex3 =
|
|
44786
|
+
const hex3 = text5.slice(i2 + 2, i2 + 10);
|
|
44645
44787
|
if (!/^[0-9a-fA-F]{8}$/.test(hex3)) return { ok: false };
|
|
44646
44788
|
const point = parseInt(hex3, 16);
|
|
44647
44789
|
if (point > 1114111 || point >= 55296 && point <= 57343) return { ok: false };
|
|
@@ -44713,14 +44855,14 @@ function tomlRowKey(row) {
|
|
|
44713
44855
|
const eq = row.indexOf("=");
|
|
44714
44856
|
return unquoteTomlKey(eq < 0 ? row : row.slice(0, eq));
|
|
44715
44857
|
}
|
|
44716
|
-
function tomlTables(
|
|
44858
|
+
function tomlTables(text5) {
|
|
44717
44859
|
const headings = [];
|
|
44718
44860
|
let mode = "out";
|
|
44719
44861
|
let i2 = 0;
|
|
44720
|
-
const atLineStart = (idx) => idx === 0 ||
|
|
44721
|
-
while (i2 <
|
|
44862
|
+
const atLineStart = (idx) => idx === 0 || text5[idx - 1] === "\n";
|
|
44863
|
+
while (i2 < text5.length) {
|
|
44722
44864
|
if (mode === "mlbasic") {
|
|
44723
|
-
if (
|
|
44865
|
+
if (text5.startsWith('"""', i2)) {
|
|
44724
44866
|
mode = "out";
|
|
44725
44867
|
i2 += 3;
|
|
44726
44868
|
continue;
|
|
@@ -44729,7 +44871,7 @@ function tomlTables(text4) {
|
|
|
44729
44871
|
continue;
|
|
44730
44872
|
}
|
|
44731
44873
|
if (mode === "mllit") {
|
|
44732
|
-
if (
|
|
44874
|
+
if (text5.startsWith("'''", i2)) {
|
|
44733
44875
|
mode = "out";
|
|
44734
44876
|
i2 += 3;
|
|
44735
44877
|
continue;
|
|
@@ -44738,61 +44880,61 @@ function tomlTables(text4) {
|
|
|
44738
44880
|
continue;
|
|
44739
44881
|
}
|
|
44740
44882
|
if (mode === "basic") {
|
|
44741
|
-
if (
|
|
44883
|
+
if (text5[i2] === "\n") {
|
|
44742
44884
|
mode = "out";
|
|
44743
44885
|
i2 += 1;
|
|
44744
44886
|
continue;
|
|
44745
44887
|
}
|
|
44746
|
-
if (
|
|
44888
|
+
if (text5[i2] === "\\") {
|
|
44747
44889
|
i2 += 2;
|
|
44748
44890
|
continue;
|
|
44749
44891
|
}
|
|
44750
|
-
if (
|
|
44892
|
+
if (text5[i2] === '"') mode = "out";
|
|
44751
44893
|
i2 += 1;
|
|
44752
44894
|
continue;
|
|
44753
44895
|
}
|
|
44754
44896
|
if (mode === "literal") {
|
|
44755
|
-
if (
|
|
44897
|
+
if (text5[i2] === "\n") {
|
|
44756
44898
|
mode = "out";
|
|
44757
44899
|
i2 += 1;
|
|
44758
44900
|
continue;
|
|
44759
44901
|
}
|
|
44760
|
-
if (
|
|
44902
|
+
if (text5[i2] === "'") mode = "out";
|
|
44761
44903
|
i2 += 1;
|
|
44762
44904
|
continue;
|
|
44763
44905
|
}
|
|
44764
|
-
if (
|
|
44906
|
+
if (text5.startsWith('"""', i2)) {
|
|
44765
44907
|
mode = "mlbasic";
|
|
44766
44908
|
i2 += 3;
|
|
44767
44909
|
continue;
|
|
44768
44910
|
}
|
|
44769
|
-
if (
|
|
44911
|
+
if (text5.startsWith("'''", i2)) {
|
|
44770
44912
|
mode = "mllit";
|
|
44771
44913
|
i2 += 3;
|
|
44772
44914
|
continue;
|
|
44773
44915
|
}
|
|
44774
|
-
if (
|
|
44916
|
+
if (text5[i2] === '"') {
|
|
44775
44917
|
mode = "basic";
|
|
44776
44918
|
i2 += 1;
|
|
44777
44919
|
continue;
|
|
44778
44920
|
}
|
|
44779
|
-
if (
|
|
44921
|
+
if (text5[i2] === "'") {
|
|
44780
44922
|
mode = "literal";
|
|
44781
44923
|
i2 += 1;
|
|
44782
44924
|
continue;
|
|
44783
44925
|
}
|
|
44784
|
-
if (
|
|
44785
|
-
const nl =
|
|
44786
|
-
i2 = nl < 0 ?
|
|
44926
|
+
if (text5[i2] === "#") {
|
|
44927
|
+
const nl = text5.indexOf("\n", i2);
|
|
44928
|
+
i2 = nl < 0 ? text5.length : nl + 1;
|
|
44787
44929
|
continue;
|
|
44788
44930
|
}
|
|
44789
44931
|
if (atLineStart(i2)) {
|
|
44790
44932
|
let j2 = i2;
|
|
44791
|
-
while (j2 <
|
|
44792
|
-
if (
|
|
44793
|
-
const nl =
|
|
44794
|
-
const lineEnd = nl < 0 ?
|
|
44795
|
-
const raw =
|
|
44933
|
+
while (j2 < text5.length && (text5[j2] === " " || text5[j2] === " ")) j2 += 1;
|
|
44934
|
+
if (text5[j2] === "[") {
|
|
44935
|
+
const nl = text5.indexOf("\n", j2);
|
|
44936
|
+
const lineEnd = nl < 0 ? text5.length : nl;
|
|
44937
|
+
const raw = text5.slice(j2, lineEnd).replace(/\r$/, "");
|
|
44796
44938
|
const stripped = stripTomlLineComment(raw).trim();
|
|
44797
44939
|
const array2 = stripped.startsWith("[[");
|
|
44798
44940
|
const name = array2 ? canonicalizeTomlHeading(`[${stripped.replace(/^\s*\[\[/, "").replace(/\]\]\s*$/, "")}]`) : canonicalizeTomlHeading(raw);
|
|
@@ -44805,11 +44947,11 @@ function tomlTables(text4) {
|
|
|
44805
44947
|
}
|
|
44806
44948
|
return headings.map((heading, index) => ({
|
|
44807
44949
|
heading,
|
|
44808
|
-
end: index + 1 < headings.length ? headings[index + 1].lineStart :
|
|
44950
|
+
end: index + 1 < headings.length ? headings[index + 1].lineStart : text5.length
|
|
44809
44951
|
})).filter((entry) => entry.heading.patchable && entry.heading.name).map((entry) => ({
|
|
44810
44952
|
name: entry.heading.name,
|
|
44811
44953
|
headingStart: entry.heading.lineStart,
|
|
44812
|
-
bodyStart: entry.heading.lineEnd + (
|
|
44954
|
+
bodyStart: entry.heading.lineEnd + (text5[entry.heading.lineEnd] === "\n" ? 1 : 0),
|
|
44813
44955
|
end: entry.end
|
|
44814
44956
|
}));
|
|
44815
44957
|
}
|
|
@@ -44865,22 +45007,22 @@ function tomlKeys(block2) {
|
|
|
44865
45007
|
take(block2.length);
|
|
44866
45008
|
return keys;
|
|
44867
45009
|
}
|
|
44868
|
-
function hasTomlTable(
|
|
45010
|
+
function hasTomlTable(text5, heading) {
|
|
44869
45011
|
const name = canonicalizeTomlHeading(heading);
|
|
44870
|
-
return name !== null && tomlTables(
|
|
45012
|
+
return name !== null && tomlTables(text5).some((table) => table.name === name);
|
|
44871
45013
|
}
|
|
44872
|
-
function patchTomlTable(
|
|
45014
|
+
function patchTomlTable(text5, heading, rows) {
|
|
44873
45015
|
const name = canonicalizeTomlHeading(heading);
|
|
44874
|
-
if (!name) return
|
|
44875
|
-
const table = tomlTables(
|
|
44876
|
-
if (!table) return
|
|
44877
|
-
const keys = tomlKeys(
|
|
45016
|
+
if (!name) return text5;
|
|
45017
|
+
const table = tomlTables(text5).find((entry) => entry.name === name);
|
|
45018
|
+
if (!table) return text5;
|
|
45019
|
+
const keys = tomlKeys(text5.slice(table.bodyStart, table.end));
|
|
44878
45020
|
const missing = rows.filter((row) => !keys.has(tomlRowKey(row)));
|
|
44879
|
-
if (!missing.length) return
|
|
45021
|
+
if (!missing.length) return text5;
|
|
44880
45022
|
let insertAt = table.end;
|
|
44881
|
-
while (insertAt > table.bodyStart && (
|
|
44882
|
-
const before =
|
|
44883
|
-
const after =
|
|
45023
|
+
while (insertAt > table.bodyStart && (text5[insertAt - 1] === "\n" || text5[insertAt - 1] === "\r")) insertAt -= 1;
|
|
45024
|
+
const before = text5.slice(0, insertAt);
|
|
45025
|
+
const after = text5.slice(insertAt);
|
|
44884
45026
|
const pad = before.endsWith("\n") || before.length === 0 ? "" : "\n";
|
|
44885
45027
|
return `${before}${pad}${missing.join("\n")}${after.startsWith("\n") ? "" : "\n"}${after}`;
|
|
44886
45028
|
}
|
|
@@ -44893,17 +45035,17 @@ function ensureKimiInjectAlias(modelId, env = process.env) {
|
|
|
44893
45035
|
const dataRoot = kimiDataRoot(env);
|
|
44894
45036
|
mkdirSync17(dataRoot, { recursive: true });
|
|
44895
45037
|
const path4 = join37(dataRoot, "config.toml");
|
|
44896
|
-
let
|
|
45038
|
+
let text5 = "";
|
|
44897
45039
|
try {
|
|
44898
|
-
|
|
45040
|
+
text5 = readFileSync21(path4, "utf8");
|
|
44899
45041
|
} catch {
|
|
44900
|
-
|
|
45042
|
+
text5 = "";
|
|
44901
45043
|
}
|
|
44902
|
-
const original =
|
|
45044
|
+
const original = text5;
|
|
44903
45045
|
const providerHeading = `[providers.${inject.host}]`;
|
|
44904
45046
|
const modelHeading = `[models.${quoteTomlKey(alias)}]`;
|
|
44905
45047
|
const blocks = [];
|
|
44906
|
-
if (!hasTomlTable(
|
|
45048
|
+
if (!hasTomlTable(text5, providerHeading)) {
|
|
44907
45049
|
blocks.push(
|
|
44908
45050
|
[
|
|
44909
45051
|
providerHeading,
|
|
@@ -44914,8 +45056,8 @@ function ensureKimiInjectAlias(modelId, env = process.env) {
|
|
|
44914
45056
|
].join("\n")
|
|
44915
45057
|
);
|
|
44916
45058
|
}
|
|
44917
|
-
if (hasTomlTable(
|
|
44918
|
-
|
|
45059
|
+
if (hasTomlTable(text5, modelHeading)) {
|
|
45060
|
+
text5 = patchTomlTable(text5, modelHeading, [`protocol = "openai"`, `max_context_size = 262144`]);
|
|
44919
45061
|
} else {
|
|
44920
45062
|
blocks.push(
|
|
44921
45063
|
[
|
|
@@ -44929,13 +45071,13 @@ function ensureKimiInjectAlias(modelId, env = process.env) {
|
|
|
44929
45071
|
);
|
|
44930
45072
|
}
|
|
44931
45073
|
if (blocks.length) {
|
|
44932
|
-
const prefix =
|
|
45074
|
+
const prefix = text5 && !text5.endsWith("\n") ? `${text5}
|
|
44933
45075
|
|
|
44934
|
-
` :
|
|
45076
|
+
` : text5 ? `${text5}
|
|
44935
45077
|
` : "";
|
|
44936
45078
|
writeFileSync13(path4, `${prefix}${blocks.join("\n")}`);
|
|
44937
|
-
} else if (
|
|
44938
|
-
writeFileSync13(path4,
|
|
45079
|
+
} else if (text5 !== original) {
|
|
45080
|
+
writeFileSync13(path4, text5);
|
|
44939
45081
|
}
|
|
44940
45082
|
return alias;
|
|
44941
45083
|
}
|
|
@@ -44955,9 +45097,9 @@ function stripKimiModelEnv(env) {
|
|
|
44955
45097
|
}
|
|
44956
45098
|
function readKimiModelCatalog(env) {
|
|
44957
45099
|
const dataRoot = kimiDataRoot(env);
|
|
44958
|
-
let
|
|
45100
|
+
let text5 = "";
|
|
44959
45101
|
try {
|
|
44960
|
-
|
|
45102
|
+
text5 = readFileSync21(join37(dataRoot, "config.toml"), "utf8");
|
|
44961
45103
|
} catch {
|
|
44962
45104
|
return STATIC_KIMI_MODELS;
|
|
44963
45105
|
}
|
|
@@ -44973,7 +45115,7 @@ function readKimiModelCatalog(env) {
|
|
|
44973
45115
|
options.push({ id: current.slug, label: current.name || current.slug, custom: true });
|
|
44974
45116
|
current = null;
|
|
44975
45117
|
};
|
|
44976
|
-
for (const line of
|
|
45118
|
+
for (const line of text5.split(/\r?\n/)) {
|
|
44977
45119
|
const stripped = line.trim();
|
|
44978
45120
|
if ((stripped.startsWith("[model.") || stripped.startsWith("[models.")) && stripped.endsWith("]")) {
|
|
44979
45121
|
flush();
|
|
@@ -45025,6 +45167,7 @@ var init_kimi = __esm({
|
|
|
45025
45167
|
];
|
|
45026
45168
|
support4 = {
|
|
45027
45169
|
driverKind: "kimiAgent",
|
|
45170
|
+
approvalModeReadback: { ladder: "kimiAgent", expected: (config2) => kimiSessionMode(config2.fullAuto), setsModeOverWire: true },
|
|
45028
45171
|
displayName: "Kimi",
|
|
45029
45172
|
// Aliases from the CLI's own catalog (~/.kimi-code/config.toml
|
|
45030
45173
|
// [models."kimi-code/…"] — `kimi provider list` reports the same four).
|
|
@@ -45105,10 +45248,10 @@ ${turn.text}` : turn.text
|
|
|
45105
45248
|
|
|
45106
45249
|
// server/drivers/acp/droid.ts
|
|
45107
45250
|
import { existsSync as existsSync19, mkdirSync as mkdirSync18, readFileSync as readFileSync22, writeFileSync as writeFileSync14 } from "node:fs";
|
|
45108
|
-
import { homedir as
|
|
45251
|
+
import { homedir as homedir20 } from "node:os";
|
|
45109
45252
|
import { join as join38 } from "node:path";
|
|
45110
45253
|
function authFilePaths(env) {
|
|
45111
|
-
const home = env.FACTORY_HOME_OVERRIDE || env.HOME ||
|
|
45254
|
+
const home = env.FACTORY_HOME_OVERRIDE || env.HOME || homedir20();
|
|
45112
45255
|
return AUTH_FILES.map((name) => join38(home, ".factory", name));
|
|
45113
45256
|
}
|
|
45114
45257
|
function droidInjectId(host, model) {
|
|
@@ -45116,7 +45259,7 @@ function droidInjectId(host, model) {
|
|
|
45116
45259
|
return `${INJECT_ID_PREFIX}${safe}`;
|
|
45117
45260
|
}
|
|
45118
45261
|
function factoryHome(env) {
|
|
45119
|
-
return env.FACTORY_HOME_OVERRIDE || env.HOME || env.USERPROFILE ||
|
|
45262
|
+
return env.FACTORY_HOME_OVERRIDE || env.HOME || env.USERPROFILE || homedir20();
|
|
45120
45263
|
}
|
|
45121
45264
|
function ensureDroidInjectModel(modelId, env = process.env) {
|
|
45122
45265
|
const inject = decodeInjectId(modelId);
|
|
@@ -45227,6 +45370,7 @@ var init_droid = __esm({
|
|
|
45227
45370
|
};
|
|
45228
45371
|
support5 = {
|
|
45229
45372
|
driverKind: "droidAgent",
|
|
45373
|
+
approvalModeReadback: { ladder: "droidAgent", expected: (config2) => config2.fullAuto ? MODE_FULL_AUTO : MODE_DEFAULT, setsModeOverWire: true },
|
|
45230
45374
|
displayName: "Droid",
|
|
45231
45375
|
models: MODELS3,
|
|
45232
45376
|
defaultCli: "droid",
|
|
@@ -45294,8 +45438,8 @@ function resolveCursorAcpModelId(available, wanted) {
|
|
|
45294
45438
|
}
|
|
45295
45439
|
return null;
|
|
45296
45440
|
}
|
|
45297
|
-
function firstJsonValue(
|
|
45298
|
-
const trimmed =
|
|
45441
|
+
function firstJsonValue(text5) {
|
|
45442
|
+
const trimmed = text5.trim();
|
|
45299
45443
|
if (!trimmed) return null;
|
|
45300
45444
|
try {
|
|
45301
45445
|
return JSON.parse(trimmed);
|
|
@@ -45369,12 +45513,12 @@ function stripModelMarkers(label) {
|
|
|
45369
45513
|
}
|
|
45370
45514
|
return { label: cleaned, isDefault, isCurrent };
|
|
45371
45515
|
}
|
|
45372
|
-
function decodeCursorModelText(
|
|
45516
|
+
function decodeCursorModelText(text5) {
|
|
45373
45517
|
const options = [];
|
|
45374
45518
|
const seen = /* @__PURE__ */ new Set();
|
|
45375
45519
|
let markedDefault;
|
|
45376
45520
|
let markedCurrent;
|
|
45377
|
-
for (const raw of
|
|
45521
|
+
for (const raw of text5.split(/\r?\n/)) {
|
|
45378
45522
|
const line = raw.trim();
|
|
45379
45523
|
if (!line || line.startsWith("#") || /^available\s+models?\b/i.test(line) || /^models?\b/i.test(line)) continue;
|
|
45380
45524
|
const stripped = line.replace(/^[\s*•-]+\s*/, "");
|
|
@@ -45427,8 +45571,8 @@ function decodeCursorAuthStatus(payload) {
|
|
|
45427
45571
|
}
|
|
45428
45572
|
return null;
|
|
45429
45573
|
}
|
|
45430
|
-
function decodeCursorAuthText(
|
|
45431
|
-
const normalized =
|
|
45574
|
+
function decodeCursorAuthText(text5) {
|
|
45575
|
+
const normalized = text5.trim().toLowerCase();
|
|
45432
45576
|
if (!normalized) return null;
|
|
45433
45577
|
if (/not (?:logged|signed) in|not authenticated|unauthenticated|logged out/.test(normalized)) return false;
|
|
45434
45578
|
if (/login successful|logged in|signed in|authenticated/.test(normalized)) return true;
|
|
@@ -45637,18 +45781,18 @@ import { createHash as createHash12 } from "node:crypto";
|
|
|
45637
45781
|
function requestKey(id) {
|
|
45638
45782
|
return `${typeof id === "number" ? "number" : "string"}:${String(id)}`;
|
|
45639
45783
|
}
|
|
45640
|
-
function utf8ByteLength(
|
|
45784
|
+
function utf8ByteLength(text5) {
|
|
45641
45785
|
let bytes = 0;
|
|
45642
|
-
for (const scalar of
|
|
45786
|
+
for (const scalar of text5) {
|
|
45643
45787
|
const point = scalar.codePointAt(0);
|
|
45644
45788
|
bytes += point <= 127 ? 1 : point <= 2047 ? 2 : point <= 65535 ? 3 : 4;
|
|
45645
45789
|
}
|
|
45646
45790
|
return bytes;
|
|
45647
45791
|
}
|
|
45648
|
-
function truncateToUtf8Bytes(
|
|
45792
|
+
function truncateToUtf8Bytes(text5, limitBytes) {
|
|
45649
45793
|
let bytes = 0;
|
|
45650
45794
|
let end = 0;
|
|
45651
|
-
for (const scalar of
|
|
45795
|
+
for (const scalar of text5) {
|
|
45652
45796
|
const point = scalar.codePointAt(0);
|
|
45653
45797
|
const width = point <= 127 ? 1 : point <= 2047 ? 2 : point <= 65535 ? 3 : 4;
|
|
45654
45798
|
if (bytes + width > limitBytes)
|
|
@@ -45656,7 +45800,7 @@ function truncateToUtf8Bytes(text4, limitBytes) {
|
|
|
45656
45800
|
bytes += width;
|
|
45657
45801
|
end += scalar.length;
|
|
45658
45802
|
}
|
|
45659
|
-
return
|
|
45803
|
+
return text5.slice(0, end);
|
|
45660
45804
|
}
|
|
45661
45805
|
function canonical(value) {
|
|
45662
45806
|
if (Array.isArray(value))
|
|
@@ -47054,11 +47198,11 @@ var init_muse_code_login = __esm({
|
|
|
47054
47198
|
// server/drivers/muse-code.ts
|
|
47055
47199
|
import { existsSync as existsSync20, mkdtempSync as mkdtempSync4, readFileSync as readFileSync23, rmSync as rmSync8, statSync as statSync5 } from "node:fs";
|
|
47056
47200
|
import { readFile as readFile4 } from "node:fs/promises";
|
|
47057
|
-
import { homedir as
|
|
47201
|
+
import { homedir as homedir21, tmpdir as tmpdir5 } from "node:os";
|
|
47058
47202
|
import { join as join39 } from "node:path";
|
|
47059
47203
|
function museCredentialPath(env, platform = process.platform) {
|
|
47060
47204
|
if (env.MUSE_AUTH_PATH?.trim()) return env.MUSE_AUTH_PATH.trim();
|
|
47061
|
-
const home = (platform === "win32" ? env.USERPROFILE || env.HOME : env.HOME) ||
|
|
47205
|
+
const home = (platform === "win32" ? env.USERPROFILE || env.HOME : env.HOME) || homedir21();
|
|
47062
47206
|
return join39(env.XDG_CONFIG_HOME?.trim() || join39(home, ".config"), "muse", "auth.json");
|
|
47063
47207
|
}
|
|
47064
47208
|
function museCredential(path4) {
|
|
@@ -47153,8 +47297,8 @@ function museToolStart(item) {
|
|
|
47153
47297
|
}
|
|
47154
47298
|
function museToolOutput(item) {
|
|
47155
47299
|
const ok = item.status === "completed" && (item.exitCode === void 0 || item.exitCode === 0);
|
|
47156
|
-
const
|
|
47157
|
-
const output = [item.status !== "completed" ? item.failureReason || `Muse reported ${item.status}.` : "",
|
|
47300
|
+
const text5 = item.visibleOutput ?? item.result?.summary ?? item.text ?? item.summary?.join("\n") ?? item.fallbackText ?? "";
|
|
47301
|
+
const output = [item.status !== "completed" ? item.failureReason || `Muse reported ${item.status}.` : "", text5].filter(Boolean).join("\n");
|
|
47158
47302
|
return { ok, ...output ? { output: redactSecretsInText(output.slice(0, MAX_TOOL_OUTPUT)) } : {} };
|
|
47159
47303
|
}
|
|
47160
47304
|
function museQuestions(raw) {
|
|
@@ -47422,12 +47566,12 @@ var init_muse_code = __esm({
|
|
|
47422
47566
|
active.items.set(item.itemId, item);
|
|
47423
47567
|
if (item.kind === "agentMessage") {
|
|
47424
47568
|
if (item.status !== "completed" || item.retracted) return;
|
|
47425
|
-
const
|
|
47569
|
+
const text5 = item.text ?? "";
|
|
47426
47570
|
const streamed = active.streamed.get(item.itemId) ?? "";
|
|
47427
|
-
if (
|
|
47428
|
-
emit({ type: "content.delta", threadId, turnId: active.turnId, itemId: item.itemId, streamKind: "assistant_text", delta:
|
|
47571
|
+
if (text5.startsWith(streamed) && text5.length > streamed.length) {
|
|
47572
|
+
emit({ type: "content.delta", threadId, turnId: active.turnId, itemId: item.itemId, streamKind: "assistant_text", delta: text5.slice(streamed.length) });
|
|
47429
47573
|
}
|
|
47430
|
-
if (
|
|
47574
|
+
if (text5) emit({ type: "item.completed", threadId, turnId: active.turnId, itemId: item.itemId, itemType: "assistant_text", text: text5 });
|
|
47431
47575
|
} else if (item.kind === "reasoning") {
|
|
47432
47576
|
if (!seen) emit({ type: "item.started", threadId, turnId: active.turnId, itemId: item.itemId, itemType: "reasoning" });
|
|
47433
47577
|
} else if (TOOL_KINDS.has(item.kind)) {
|
|
@@ -47624,16 +47768,16 @@ var init_muse_code = __esm({
|
|
|
47624
47768
|
const rebuilt = Boolean(resumeId && turn.recoveryText);
|
|
47625
47769
|
return { text: rebuilt ? turn.recoveryText : turn.text, rebuilt, started: true };
|
|
47626
47770
|
};
|
|
47627
|
-
const withInstructions = (state2, turn,
|
|
47771
|
+
const withInstructions = (state2, turn, text5, started) => {
|
|
47628
47772
|
const sessionId = state2.sessionId;
|
|
47629
47773
|
if (turn.systemStable === void 0) return turn.system && started ? `${turn.system}
|
|
47630
47774
|
|
|
47631
|
-
${
|
|
47775
|
+
${text5}` : text5;
|
|
47632
47776
|
let entry = state2.instructions;
|
|
47633
47777
|
const resend = started || !entry || entry.sessionId !== sessionId || entry.stable !== turn.systemStable || entry.turns >= INSTRUCTIONS_REFRESH_TURNS;
|
|
47634
47778
|
if (resend) entry = state2.instructions = { sessionId, stable: turn.systemStable, turns: 0, seen: /* @__PURE__ */ new Map() };
|
|
47635
47779
|
entry.turns++;
|
|
47636
|
-
const body = withNote(
|
|
47780
|
+
const body = withNote(text5, volatileNote(volatileSectionsOf(turn), entry.seen, entry.seen.size === 0));
|
|
47637
47781
|
return resend && turn.systemStable ? `${turn.systemStable}
|
|
47638
47782
|
|
|
47639
47783
|
${body}` : body;
|
|
@@ -47651,7 +47795,7 @@ ${body}` : body;
|
|
|
47651
47795
|
await host.connection.command("session/setModel", { sessionId, model: { modelId: turn.model, providerId: config2.provider } });
|
|
47652
47796
|
state2.model = turn.model;
|
|
47653
47797
|
}
|
|
47654
|
-
const
|
|
47798
|
+
const text5 = withInstructions(state2, turn, session.text, session.started);
|
|
47655
47799
|
const images = turn.images?.length ? await Promise.all(turn.images.map(async (image) => ({
|
|
47656
47800
|
type: "image",
|
|
47657
47801
|
mediaType: image.mime,
|
|
@@ -47663,7 +47807,7 @@ ${body}` : body;
|
|
|
47663
47807
|
active.nativeTurnId = host.connection.mintCommandId();
|
|
47664
47808
|
await host.connection.command("turn/start", {
|
|
47665
47809
|
sessionId,
|
|
47666
|
-
input: [{ type: "text", text:
|
|
47810
|
+
input: [{ type: "text", text: text5 }, ...images],
|
|
47667
47811
|
...effort ? { reasoningEffort: effort } : {}
|
|
47668
47812
|
}, { commandId: active.nativeTurnId });
|
|
47669
47813
|
} catch (error51) {
|
|
@@ -47743,7 +47887,7 @@ ${body}` : body;
|
|
|
47743
47887
|
return "unavailable";
|
|
47744
47888
|
}
|
|
47745
47889
|
},
|
|
47746
|
-
async steer(threadId,
|
|
47890
|
+
async steer(threadId, text5) {
|
|
47747
47891
|
const state2 = threads.get(threadId);
|
|
47748
47892
|
const active = state2?.active;
|
|
47749
47893
|
if (!state2?.host || !state2.sessionId || !active?.nativeTurnId || active.finished) return "refused";
|
|
@@ -47751,7 +47895,7 @@ ${body}` : body;
|
|
|
47751
47895
|
await state2.host.connection.command("turn/steer", {
|
|
47752
47896
|
sessionId: state2.sessionId,
|
|
47753
47897
|
expectedTurnId: active.nativeTurnId,
|
|
47754
|
-
input: [{ type: "text", text:
|
|
47898
|
+
input: [{ type: "text", text: text5 }]
|
|
47755
47899
|
});
|
|
47756
47900
|
return "steered";
|
|
47757
47901
|
} catch (error51) {
|
|
@@ -47818,7 +47962,7 @@ ${body}` : body;
|
|
|
47818
47962
|
|
|
47819
47963
|
// server/drivers/acp/opencode-go.ts
|
|
47820
47964
|
import { existsSync as existsSync21, mkdirSync as mkdirSync19, readFileSync as readFileSync24, writeFileSync as writeFileSync15 } from "node:fs";
|
|
47821
|
-
import { homedir as
|
|
47965
|
+
import { homedir as homedir22 } from "node:os";
|
|
47822
47966
|
import { join as join40 } from "node:path";
|
|
47823
47967
|
function labelForModel(id) {
|
|
47824
47968
|
return id.split(/[-_.]+/g).filter(Boolean).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
|
|
@@ -47921,7 +48065,7 @@ async function discoverOpenCodeModels(environment, cli = "opencode") {
|
|
|
47921
48065
|
}
|
|
47922
48066
|
}
|
|
47923
48067
|
function opencodeConfigDir(env) {
|
|
47924
|
-
const home = env.HOME || env.USERPROFILE ||
|
|
48068
|
+
const home = env.HOME || env.USERPROFILE || homedir22();
|
|
47925
48069
|
return join40(env.XDG_CONFIG_HOME || join40(home, ".config"), "opencode");
|
|
47926
48070
|
}
|
|
47927
48071
|
function ensureOpenCodeInjectModel(modelId, env = process.env) {
|
|
@@ -47968,7 +48112,7 @@ function ensureOpenCodeInjectModel(modelId, env = process.env) {
|
|
|
47968
48112
|
return native;
|
|
47969
48113
|
}
|
|
47970
48114
|
function storedAuthPaths(env) {
|
|
47971
|
-
const home = env.HOME || env.USERPROFILE ||
|
|
48115
|
+
const home = env.HOME || env.USERPROFILE || homedir22();
|
|
47972
48116
|
const roots = [
|
|
47973
48117
|
env.XDG_DATA_HOME || join40(home, ".local", "share"),
|
|
47974
48118
|
process.platform === "darwin" ? join40(home, "Library", "Application Support") : process.platform === "win32" ? env.LOCALAPPDATA || join40(home, "AppData", "Local") : ""
|
|
@@ -48131,10 +48275,10 @@ ${turn.text}` : turn.text
|
|
|
48131
48275
|
// server/drivers/acp/qwen.ts
|
|
48132
48276
|
import { chmodSync as chmodSync5, existsSync as existsSync22, mkdirSync as mkdirSync20, readFileSync as readFileSync25, writeFileSync as writeFileSync16 } from "node:fs";
|
|
48133
48277
|
import { createHash as createHash13 } from "node:crypto";
|
|
48134
|
-
import { homedir as
|
|
48278
|
+
import { homedir as homedir23 } from "node:os";
|
|
48135
48279
|
import { join as join41 } from "node:path";
|
|
48136
48280
|
function qwenHome(env) {
|
|
48137
|
-
const home = process.platform === "win32" ? env.USERPROFILE || env.HOME ||
|
|
48281
|
+
const home = process.platform === "win32" ? env.USERPROFILE || env.HOME || homedir23() : env.HOME || env.USERPROFILE || homedir23();
|
|
48138
48282
|
return join41(home, ".qwen");
|
|
48139
48283
|
}
|
|
48140
48284
|
function isRecord5(value) {
|
|
@@ -48307,6 +48451,12 @@ function qwenApprovalArgs(fullAuto, approvalMode) {
|
|
|
48307
48451
|
if (approvalMode === "edits") return ["--approval-mode", "auto-edit"];
|
|
48308
48452
|
return [];
|
|
48309
48453
|
}
|
|
48454
|
+
function qwenExpectedMode(fullAuto, approvalMode) {
|
|
48455
|
+
if (fullAuto) return "yolo";
|
|
48456
|
+
if (approvalMode === "auto") return "auto";
|
|
48457
|
+
if (approvalMode === "edits") return "auto-edit";
|
|
48458
|
+
return "default";
|
|
48459
|
+
}
|
|
48310
48460
|
var EMPTY, PROTOCOLS, support8, QwenAgentDriver;
|
|
48311
48461
|
var init_qwen = __esm({
|
|
48312
48462
|
"server/drivers/acp/qwen.ts"() {
|
|
@@ -48317,6 +48467,8 @@ var init_qwen = __esm({
|
|
|
48317
48467
|
PROTOCOLS = /* @__PURE__ */ new Set(["openai", "anthropic", "gemini", "vertex-ai"]);
|
|
48318
48468
|
support8 = {
|
|
48319
48469
|
driverKind: "qwenAgent",
|
|
48470
|
+
// Qwen takes the mode on argv; session/new reports the one it applied.
|
|
48471
|
+
approvalModeReadback: { ladder: "qwenAgent", expected: (config2, turn) => qwenExpectedMode(config2.fullAuto, turn.approvalMode) },
|
|
48320
48472
|
displayName: "Qwen",
|
|
48321
48473
|
access: "custom",
|
|
48322
48474
|
models: EMPTY,
|
|
@@ -48368,9 +48520,9 @@ function mistralSignInLink(value) {
|
|
|
48368
48520
|
return host === "mistral.ai" || host.endsWith(".mistral.ai") ? url2.href : null;
|
|
48369
48521
|
}
|
|
48370
48522
|
function vibeSignInFailure(error51) {
|
|
48371
|
-
const
|
|
48372
|
-
if (/denied/i.test(
|
|
48373
|
-
if (/expired|timed out/i.test(
|
|
48523
|
+
const text5 = error51 instanceof VibeRequestError ? error51.message : "";
|
|
48524
|
+
if (/denied/i.test(text5)) return "The Mistral sign-in was declined. Start sign-in again to try another account.";
|
|
48525
|
+
if (/expired|timed out/i.test(text5)) return "The Mistral sign-in expired. Start sign-in again.";
|
|
48374
48526
|
if (error51 instanceof Error && !(error51 instanceof VibeRequestError)) return error51.message;
|
|
48375
48527
|
return "Mistral Vibe sign-in did not finish. Check this computer's connection and that Vibe is up to date, then try again.";
|
|
48376
48528
|
}
|
|
@@ -48445,8 +48597,8 @@ var init_vibe_login = __esm({
|
|
|
48445
48597
|
}
|
|
48446
48598
|
if (this.child.exitCode === null && this.child.signalCode === null) void killCliTree(this.child).catch(() => false);
|
|
48447
48599
|
}
|
|
48448
|
-
receive(
|
|
48449
|
-
this.buffer +=
|
|
48600
|
+
receive(text5) {
|
|
48601
|
+
this.buffer += text5;
|
|
48450
48602
|
if (this.buffer.length > MAX_LINE) {
|
|
48451
48603
|
this.close(new Error("Mistral Vibe returned an unexpected answer. Update Vibe and try again."));
|
|
48452
48604
|
return;
|
|
@@ -48570,6 +48722,12 @@ var init_vibe_login = __esm({
|
|
|
48570
48722
|
});
|
|
48571
48723
|
|
|
48572
48724
|
// server/drivers/acp/vibe.ts
|
|
48725
|
+
function vibeReportedMode(reply) {
|
|
48726
|
+
const options = reply?.configOptions;
|
|
48727
|
+
if (!Array.isArray(options)) return null;
|
|
48728
|
+
const mode = options.find((option) => option && typeof option === "object" && option.id === "mode");
|
|
48729
|
+
return typeof mode?.currentValue === "string" ? mode.currentValue : null;
|
|
48730
|
+
}
|
|
48573
48731
|
function vibeSessionMode(fullAuto, approvalMode) {
|
|
48574
48732
|
if (fullAuto) return "auto-approve";
|
|
48575
48733
|
if (approvalMode === "auto") return "smart-approve";
|
|
@@ -48599,6 +48757,7 @@ var init_vibe = __esm({
|
|
|
48599
48757
|
init_env_path();
|
|
48600
48758
|
init_vibe_login();
|
|
48601
48759
|
init_core3();
|
|
48760
|
+
init_approval_readback();
|
|
48602
48761
|
VIBE_DRIVER_KIND = "vibeAgent";
|
|
48603
48762
|
MODELS4 = {
|
|
48604
48763
|
default: "mistral-medium-3.5",
|
|
@@ -48634,11 +48793,13 @@ var init_vibe = __esm({
|
|
|
48634
48793
|
isAuthenticated: (env, config2, instanceId) => cachedSignedIn(`${instanceId}:${env.VIBE_HOME ?? ""}`, () => vibeSignedIn(config2.cli || "vibe-acp", env)),
|
|
48635
48794
|
async configureSession({ request, sessionId, config: config2, turn }) {
|
|
48636
48795
|
const value = vibeSessionMode(config2.fullAuto, turn.approvalMode);
|
|
48796
|
+
let reply;
|
|
48637
48797
|
try {
|
|
48638
|
-
await request("session/set_config_option", { sessionId, configId: "mode", value });
|
|
48798
|
+
reply = await request("session/set_config_option", { sessionId, configId: "mode", value });
|
|
48639
48799
|
} catch (e) {
|
|
48640
48800
|
throw new Error(`Mistral Vibe rejected permission mode "${value}": ${e.message}. Update Mistral Vibe (3.0 or newer).`);
|
|
48641
48801
|
}
|
|
48802
|
+
assertEffectiveModeNotLooser("Mistral Vibe", "vibeAgent", value, vibeReportedMode(reply));
|
|
48642
48803
|
},
|
|
48643
48804
|
buildPromptText: (turn) => turn.system ? `${turn.system}
|
|
48644
48805
|
|
|
@@ -48719,13 +48880,13 @@ var init_claude_accounts = __esm({
|
|
|
48719
48880
|
|
|
48720
48881
|
// server/atomic-engine-accounts.ts
|
|
48721
48882
|
import { mkdirSync as mkdirSync21, readFileSync as readFileSync26, writeFileSync as writeFileSync17 } from "node:fs";
|
|
48722
|
-
import { homedir as
|
|
48883
|
+
import { homedir as homedir24 } from "node:os";
|
|
48723
48884
|
import { join as join42 } from "node:path";
|
|
48724
48885
|
function rawConfig2(entry) {
|
|
48725
48886
|
return entry.config && typeof entry.config === "object" && !Array.isArray(entry.config) ? entry.config : {};
|
|
48726
48887
|
}
|
|
48727
48888
|
function expandHome(path4) {
|
|
48728
|
-
return path4 === "~" ?
|
|
48889
|
+
return path4 === "~" ? homedir24() : path4.startsWith("~/") ? join42(homedir24(), path4.slice(2)) : path4;
|
|
48729
48890
|
}
|
|
48730
48891
|
function asAccount(id, entry) {
|
|
48731
48892
|
if (entry.enabled === false) return null;
|
|
@@ -48757,7 +48918,7 @@ function asAccount(id, entry) {
|
|
|
48757
48918
|
kind: "codex-cli",
|
|
48758
48919
|
label,
|
|
48759
48920
|
billing: "subscription",
|
|
48760
|
-
home: home ? expandHome(home) : join42(
|
|
48921
|
+
home: home ? expandHome(home) : join42(homedir24(), ".codex"),
|
|
48761
48922
|
model: FAILOVER_MODEL["openai-codex"]
|
|
48762
48923
|
} };
|
|
48763
48924
|
}
|
|
@@ -48817,16 +48978,16 @@ function atomicEngineAccounts(input) {
|
|
|
48817
48978
|
}
|
|
48818
48979
|
function writeAtomicEngineAccountsFile(engineHome, accounts) {
|
|
48819
48980
|
const shareable = accounts.map(({ restingUntil: _resting, ...account }) => account);
|
|
48820
|
-
const
|
|
48981
|
+
const text5 = `${JSON.stringify({ version: 1, accounts: shareable }, null, 2)}
|
|
48821
48982
|
`;
|
|
48822
48983
|
const path4 = join42(engineHome, ACCOUNTS_FILE);
|
|
48823
48984
|
try {
|
|
48824
|
-
if (readFileSync26(path4, "utf8") ===
|
|
48985
|
+
if (readFileSync26(path4, "utf8") === text5) return;
|
|
48825
48986
|
} catch {
|
|
48826
48987
|
}
|
|
48827
48988
|
try {
|
|
48828
48989
|
mkdirSync21(engineHome, { recursive: true, mode: 448 });
|
|
48829
|
-
writeFileSync17(path4,
|
|
48990
|
+
writeFileSync17(path4, text5, { mode: 384 });
|
|
48830
48991
|
} catch (error51) {
|
|
48831
48992
|
console.warn(`[atomic-engine] could not write ${path4}: ${error51.message}`);
|
|
48832
48993
|
}
|
|
@@ -49949,14 +50110,14 @@ var init_stringifyComment = __esm({
|
|
|
49949
50110
|
});
|
|
49950
50111
|
|
|
49951
50112
|
// node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/stringify/foldFlowLines.js
|
|
49952
|
-
function foldFlowLines(
|
|
50113
|
+
function foldFlowLines(text5, indent, mode = "flow", { indentAtStart, lineWidth = 80, minContentWidth = 20, onFold, onOverflow } = {}) {
|
|
49953
50114
|
if (!lineWidth || lineWidth < 0)
|
|
49954
|
-
return
|
|
50115
|
+
return text5;
|
|
49955
50116
|
if (lineWidth < minContentWidth)
|
|
49956
50117
|
minContentWidth = 0;
|
|
49957
50118
|
const endStep = Math.max(1 + minContentWidth, 1 + lineWidth - indent.length);
|
|
49958
|
-
if (
|
|
49959
|
-
return
|
|
50119
|
+
if (text5.length <= endStep)
|
|
50120
|
+
return text5;
|
|
49960
50121
|
const folds = [];
|
|
49961
50122
|
const escapedFolds = {};
|
|
49962
50123
|
let end = lineWidth - indent.length;
|
|
@@ -49973,14 +50134,14 @@ function foldFlowLines(text4, indent, mode = "flow", { indentAtStart, lineWidth
|
|
|
49973
50134
|
let escStart = -1;
|
|
49974
50135
|
let escEnd = -1;
|
|
49975
50136
|
if (mode === FOLD_BLOCK) {
|
|
49976
|
-
i2 = consumeMoreIndentedLines(
|
|
50137
|
+
i2 = consumeMoreIndentedLines(text5, i2, indent.length);
|
|
49977
50138
|
if (i2 !== -1)
|
|
49978
50139
|
end = i2 + endStep;
|
|
49979
50140
|
}
|
|
49980
|
-
for (let ch; ch =
|
|
50141
|
+
for (let ch; ch = text5[i2 += 1]; ) {
|
|
49981
50142
|
if (mode === FOLD_QUOTED && ch === "\\") {
|
|
49982
50143
|
escStart = i2;
|
|
49983
|
-
switch (
|
|
50144
|
+
switch (text5[i2 + 1]) {
|
|
49984
50145
|
case "x":
|
|
49985
50146
|
i2 += 3;
|
|
49986
50147
|
break;
|
|
@@ -49997,12 +50158,12 @@ function foldFlowLines(text4, indent, mode = "flow", { indentAtStart, lineWidth
|
|
|
49997
50158
|
}
|
|
49998
50159
|
if (ch === "\n") {
|
|
49999
50160
|
if (mode === FOLD_BLOCK)
|
|
50000
|
-
i2 = consumeMoreIndentedLines(
|
|
50161
|
+
i2 = consumeMoreIndentedLines(text5, i2, indent.length);
|
|
50001
50162
|
end = i2 + indent.length + endStep;
|
|
50002
50163
|
split = void 0;
|
|
50003
50164
|
} else {
|
|
50004
50165
|
if (ch === " " && prev && prev !== " " && prev !== "\n" && prev !== " ") {
|
|
50005
|
-
const next =
|
|
50166
|
+
const next = text5[i2 + 1];
|
|
50006
50167
|
if (next && next !== " " && next !== "\n" && next !== " ")
|
|
50007
50168
|
split = i2;
|
|
50008
50169
|
}
|
|
@@ -50014,12 +50175,12 @@ function foldFlowLines(text4, indent, mode = "flow", { indentAtStart, lineWidth
|
|
|
50014
50175
|
} else if (mode === FOLD_QUOTED) {
|
|
50015
50176
|
while (prev === " " || prev === " ") {
|
|
50016
50177
|
prev = ch;
|
|
50017
|
-
ch =
|
|
50178
|
+
ch = text5[i2 += 1];
|
|
50018
50179
|
overflow = true;
|
|
50019
50180
|
}
|
|
50020
50181
|
const j2 = i2 > escEnd + 1 ? i2 - 2 : escStart - 1;
|
|
50021
50182
|
if (escapedFolds[j2])
|
|
50022
|
-
return
|
|
50183
|
+
return text5;
|
|
50023
50184
|
folds.push(j2);
|
|
50024
50185
|
escapedFolds[j2] = true;
|
|
50025
50186
|
end = j2 + endStep;
|
|
@@ -50034,39 +50195,39 @@ function foldFlowLines(text4, indent, mode = "flow", { indentAtStart, lineWidth
|
|
|
50034
50195
|
if (overflow && onOverflow)
|
|
50035
50196
|
onOverflow();
|
|
50036
50197
|
if (folds.length === 0)
|
|
50037
|
-
return
|
|
50198
|
+
return text5;
|
|
50038
50199
|
if (onFold)
|
|
50039
50200
|
onFold();
|
|
50040
|
-
let res =
|
|
50201
|
+
let res = text5.slice(0, folds[0]);
|
|
50041
50202
|
for (let i3 = 0; i3 < folds.length; ++i3) {
|
|
50042
50203
|
const fold = folds[i3];
|
|
50043
|
-
const end2 = folds[i3 + 1] ||
|
|
50204
|
+
const end2 = folds[i3 + 1] || text5.length;
|
|
50044
50205
|
if (fold === 0)
|
|
50045
50206
|
res = `
|
|
50046
|
-
${indent}${
|
|
50207
|
+
${indent}${text5.slice(0, end2)}`;
|
|
50047
50208
|
else {
|
|
50048
50209
|
if (mode === FOLD_QUOTED && escapedFolds[fold])
|
|
50049
|
-
res += `${
|
|
50210
|
+
res += `${text5[fold]}\\`;
|
|
50050
50211
|
res += `
|
|
50051
|
-
${indent}${
|
|
50212
|
+
${indent}${text5.slice(fold + 1, end2)}`;
|
|
50052
50213
|
}
|
|
50053
50214
|
}
|
|
50054
50215
|
return res;
|
|
50055
50216
|
}
|
|
50056
|
-
function consumeMoreIndentedLines(
|
|
50217
|
+
function consumeMoreIndentedLines(text5, i2, indent) {
|
|
50057
50218
|
let end = i2;
|
|
50058
50219
|
let start = i2 + 1;
|
|
50059
|
-
let ch =
|
|
50220
|
+
let ch = text5[start];
|
|
50060
50221
|
while (ch === " " || ch === " ") {
|
|
50061
50222
|
if (i2 < start + indent) {
|
|
50062
|
-
ch =
|
|
50223
|
+
ch = text5[++i2];
|
|
50063
50224
|
} else {
|
|
50064
50225
|
do {
|
|
50065
|
-
ch =
|
|
50226
|
+
ch = text5[++i2];
|
|
50066
50227
|
} while (ch && ch !== "\n");
|
|
50067
50228
|
end = i2;
|
|
50068
50229
|
start = i2 + 1;
|
|
50069
|
-
ch =
|
|
50230
|
+
ch = text5[start];
|
|
50070
50231
|
}
|
|
50071
50232
|
}
|
|
50072
50233
|
return end;
|
|
@@ -55922,10 +56083,10 @@ function readText2(path4) {
|
|
|
55922
56083
|
return null;
|
|
55923
56084
|
}
|
|
55924
56085
|
}
|
|
55925
|
-
function parseYamlSafe(
|
|
55926
|
-
if (
|
|
56086
|
+
function parseYamlSafe(text5) {
|
|
56087
|
+
if (text5 === null) return null;
|
|
55927
56088
|
try {
|
|
55928
|
-
return parse3(
|
|
56089
|
+
return parse3(text5);
|
|
55929
56090
|
} catch {
|
|
55930
56091
|
return null;
|
|
55931
56092
|
}
|
|
@@ -55975,7 +56136,7 @@ var init_hermes_memory_lock = __esm({
|
|
|
55975
56136
|
// server/drivers/acp/hermes.ts
|
|
55976
56137
|
import { spawn as spawn7 } from "node:child_process";
|
|
55977
56138
|
import { mkdirSync as mkdirSync24, readFileSync as readFileSync29, writeFileSync as writeFileSync20 } from "node:fs";
|
|
55978
|
-
import { homedir as
|
|
56139
|
+
import { homedir as homedir25 } from "node:os";
|
|
55979
56140
|
import { join as join45 } from "node:path";
|
|
55980
56141
|
function bindHermesScreenshotCompat(env, modelId) {
|
|
55981
56142
|
delete env[HERMES_OPENMAUS_SCREENSHOT_COMPAT];
|
|
@@ -55986,30 +56147,30 @@ function bindHermesScreenshotCompat(env, modelId) {
|
|
|
55986
56147
|
env[HERMES_OPENMAUS_SCREENSHOT_COMPAT_MODEL] = inject.model;
|
|
55987
56148
|
}
|
|
55988
56149
|
function hermesHome(env) {
|
|
55989
|
-
return env.HERMES_HOME || join45(env.HOME || env.USERPROFILE ||
|
|
56150
|
+
return env.HERMES_HOME || join45(env.HOME || env.USERPROFILE || homedir25(), ".hermes");
|
|
55990
56151
|
}
|
|
55991
56152
|
function quoteYaml(value) {
|
|
55992
56153
|
if (/^[\w./:+-]+$/.test(value)) return value;
|
|
55993
56154
|
return JSON.stringify(value);
|
|
55994
56155
|
}
|
|
55995
|
-
function upsertHermesProvider(
|
|
56156
|
+
function upsertHermesProvider(text5, hostId, baseUrl, apiKey) {
|
|
55996
56157
|
const block2 = [` ${hostId}:`, ` base_url: ${quoteYaml(baseUrl)}`, ` api_key: ${quoteYaml(apiKey)}`, ""].join(
|
|
55997
56158
|
"\n"
|
|
55998
56159
|
);
|
|
55999
|
-
if (/^providers:\s*$/m.test(
|
|
56000
|
-
const replaced = replaceHermesHostBlock(
|
|
56160
|
+
if (/^providers:\s*$/m.test(text5)) {
|
|
56161
|
+
const replaced = replaceHermesHostBlock(text5, hostId, block2);
|
|
56001
56162
|
if (replaced !== null) return replaced;
|
|
56002
|
-
return
|
|
56163
|
+
return text5.replace(/^providers:\s*$/m, `providers:
|
|
56003
56164
|
${block2.trimEnd()}`);
|
|
56004
56165
|
}
|
|
56005
|
-
const prefix =
|
|
56006
|
-
` :
|
|
56166
|
+
const prefix = text5 && !text5.endsWith("\n") ? `${text5}
|
|
56167
|
+
` : text5;
|
|
56007
56168
|
return `${prefix}
|
|
56008
56169
|
providers:
|
|
56009
56170
|
${block2}`;
|
|
56010
56171
|
}
|
|
56011
|
-
function replaceHermesHostBlock(
|
|
56012
|
-
const lines =
|
|
56172
|
+
function replaceHermesHostBlock(text5, hostId, block2) {
|
|
56173
|
+
const lines = text5.split("\n");
|
|
56013
56174
|
const start = lines.findIndex((line) => line === ` ${hostId}:`);
|
|
56014
56175
|
if (start < 0) return null;
|
|
56015
56176
|
let end = start + 1;
|
|
@@ -56029,14 +56190,14 @@ function ensureHermesInjectProvider(modelId, env = process.env, home = hermesHom
|
|
|
56029
56190
|
const dir = home;
|
|
56030
56191
|
mkdirSync24(dir, { recursive: true });
|
|
56031
56192
|
const path4 = join45(dir, "config.yaml");
|
|
56032
|
-
let
|
|
56193
|
+
let text5 = "";
|
|
56033
56194
|
try {
|
|
56034
|
-
|
|
56195
|
+
text5 = readFileSync29(path4, "utf8");
|
|
56035
56196
|
} catch {
|
|
56036
|
-
|
|
56197
|
+
text5 = "";
|
|
56037
56198
|
}
|
|
56038
|
-
const next = upsertHermesProvider(
|
|
56039
|
-
if (next !==
|
|
56199
|
+
const next = upsertHermesProvider(text5, inject.host, host.baseUrl, hostApiKey(host, env));
|
|
56200
|
+
if (next !== text5) writeFileSync20(path4, next);
|
|
56040
56201
|
return hermesAcpModelId(modelId) ?? modelId;
|
|
56041
56202
|
}
|
|
56042
56203
|
function hermesAcpModelId(modelId) {
|
|
@@ -56046,8 +56207,8 @@ function hermesAcpModelId(modelId) {
|
|
|
56046
56207
|
if (native && !native.includes(INJECT_SEP) && /^[a-z0-9_-]+:[\w./:-]+$/i.test(native)) return native;
|
|
56047
56208
|
return null;
|
|
56048
56209
|
}
|
|
56049
|
-
function nonEmptyDotenvValue(
|
|
56050
|
-
const match = new RegExp(`^[ \\t]*(?:export[ \\t]+)?${name}[ \\t]*=[ \\t]*([^\\r\\n]*)$`, "m").exec(
|
|
56210
|
+
function nonEmptyDotenvValue(text5, name) {
|
|
56211
|
+
const match = new RegExp(`^[ \\t]*(?:export[ \\t]+)?${name}[ \\t]*=[ \\t]*([^\\r\\n]*)$`, "m").exec(text5);
|
|
56051
56212
|
if (!match) return null;
|
|
56052
56213
|
const raw = match[1].trim();
|
|
56053
56214
|
if (!raw || raw.startsWith("#")) return null;
|
|
@@ -56064,10 +56225,10 @@ function nonEmptyDotenvValue(text4, name) {
|
|
|
56064
56225
|
function yamlString(value) {
|
|
56065
56226
|
return typeof value === "string" ? value.trim() : "";
|
|
56066
56227
|
}
|
|
56067
|
-
function hermesConfigDefault(
|
|
56228
|
+
function hermesConfigDefault(text5) {
|
|
56068
56229
|
let raw;
|
|
56069
56230
|
try {
|
|
56070
|
-
raw = parse3(
|
|
56231
|
+
raw = parse3(text5);
|
|
56071
56232
|
} catch {
|
|
56072
56233
|
return null;
|
|
56073
56234
|
}
|
|
@@ -56300,7 +56461,7 @@ async function fetchHermesAcpModels(cli, env) {
|
|
|
56300
56461
|
}
|
|
56301
56462
|
if (msg?.id === initId) {
|
|
56302
56463
|
if (!msg.result) return done([]);
|
|
56303
|
-
sessionId = send("session/new", { cwd: env.HOME || env.USERPROFILE ||
|
|
56464
|
+
sessionId = send("session/new", { cwd: env.HOME || env.USERPROFILE || homedir25(), mcpServers: [] });
|
|
56304
56465
|
} else if (sessionId && msg?.id === sessionId) {
|
|
56305
56466
|
const list = Array.isArray(msg.result?.models?.availableModels) ? msg.result.models.availableModels : [];
|
|
56306
56467
|
done(
|
|
@@ -56436,7 +56597,7 @@ ${turn.text}` : turn.text
|
|
|
56436
56597
|
});
|
|
56437
56598
|
|
|
56438
56599
|
// server/drivers/acp/custom.ts
|
|
56439
|
-
import { homedir as
|
|
56600
|
+
import { homedir as homedir26 } from "node:os";
|
|
56440
56601
|
import { basename as basename9, join as join46 } from "node:path";
|
|
56441
56602
|
function isAtomicEngine(instanceId, cli) {
|
|
56442
56603
|
const program = (cli ?? "").trim().split(/\s+/)[0] ?? "";
|
|
@@ -56462,7 +56623,7 @@ async function customAcpSnapshot(env, cli, instanceId) {
|
|
|
56462
56623
|
return { state: "available", version: version2, authenticated: true };
|
|
56463
56624
|
}
|
|
56464
56625
|
function atomicEngineHome2(env) {
|
|
56465
|
-
return env.HERMES_HOME || join46(env.HOME || env.USERPROFILE ||
|
|
56626
|
+
return env.HERMES_HOME || join46(env.HOME || env.USERPROFILE || homedir26(), ".atomic");
|
|
56466
56627
|
}
|
|
56467
56628
|
function applyAtomicEngineAccounts(env, instanceId, cli, accounts = currentAtomicEngineAccounts) {
|
|
56468
56629
|
if (!isAtomicEngine(instanceId, cli)) return;
|
|
@@ -56694,7 +56855,7 @@ var init_ollama_cloud = __esm({
|
|
|
56694
56855
|
nativeLog: {
|
|
56695
56856
|
source: "ollama-cloud.chat.completions",
|
|
56696
56857
|
outgoing: (_turn, messages, model) => ({ model, messageCount: messages.length }),
|
|
56697
|
-
incoming: ({ text:
|
|
56858
|
+
incoming: ({ text: text5, reasoning, usage }) => ({ textLength: text5.length, reasoningLength: reasoning.length, usage })
|
|
56698
56859
|
}
|
|
56699
56860
|
});
|
|
56700
56861
|
}
|
|
@@ -56850,8 +57011,8 @@ var init_openai_compat = __esm({
|
|
|
56850
57011
|
nativeLog: {
|
|
56851
57012
|
source: "openai-compat.chat.completions",
|
|
56852
57013
|
outgoing: (_turn, messages, model) => ({ model, messageCount: messages.length }),
|
|
56853
|
-
incoming: ({ text:
|
|
56854
|
-
textLength:
|
|
57014
|
+
incoming: ({ text: text5, reasoning, usage }) => ({
|
|
57015
|
+
textLength: text5.length,
|
|
56855
57016
|
reasoningLength: reasoning.length,
|
|
56856
57017
|
usage
|
|
56857
57018
|
})
|
|
@@ -56864,7 +57025,7 @@ var init_openai_compat = __esm({
|
|
|
56864
57025
|
|
|
56865
57026
|
// server/drivers/pi.ts
|
|
56866
57027
|
import { chmodSync as chmodSync6, existsSync as existsSync24, mkdirSync as mkdirSync25, mkdtempSync as mkdtempSync5, readFileSync as readFileSync30, rmSync as rmSync10, writeFileSync as writeFileSync21 } from "node:fs";
|
|
56867
|
-
import { homedir as
|
|
57028
|
+
import { homedir as homedir27, tmpdir as tmpdir6 } from "node:os";
|
|
56868
57029
|
import { join as join47 } from "node:path";
|
|
56869
57030
|
function readPiPromptImages(turn) {
|
|
56870
57031
|
return (turn.images ?? []).map((image) => ({
|
|
@@ -56987,7 +57148,7 @@ async function applyPiLocalCatalog(catalog2, env = process.env, fetchImpl = fetc
|
|
|
56987
57148
|
return preferPiInjectRows(await mergeLocalInject(catalog2, env, fetchImpl));
|
|
56988
57149
|
}
|
|
56989
57150
|
function piAgentDir(env) {
|
|
56990
|
-
return join47(env.HOME || env.USERPROFILE ||
|
|
57151
|
+
return join47(env.HOME || env.USERPROFILE || homedir27(), ".pi", "agent");
|
|
56991
57152
|
}
|
|
56992
57153
|
function ensurePiInjectModel(modelId, env = process.env) {
|
|
56993
57154
|
const split = splitPiModel(modelId);
|
|
@@ -57052,7 +57213,7 @@ function ensurePiInjectModel(modelId, env = process.env) {
|
|
|
57052
57213
|
return split;
|
|
57053
57214
|
}
|
|
57054
57215
|
function readPiDefaultModel(env) {
|
|
57055
|
-
const home = env.HOME || env.USERPROFILE ||
|
|
57216
|
+
const home = env.HOME || env.USERPROFILE || homedir27();
|
|
57056
57217
|
try {
|
|
57057
57218
|
const s4 = JSON.parse(readFileSync30(`${home}/.pi/agent/settings.json`, "utf8"));
|
|
57058
57219
|
return s4.defaultProvider && s4.defaultModel ? `${s4.defaultProvider}/${s4.defaultModel}` : "";
|
|
@@ -57276,10 +57437,10 @@ var init_pi = __esm({
|
|
|
57276
57437
|
child.stdin.write(JSON.stringify(obj) + "\n");
|
|
57277
57438
|
};
|
|
57278
57439
|
const flushAssistantText = () => {
|
|
57279
|
-
const
|
|
57440
|
+
const text5 = assistantText;
|
|
57280
57441
|
assistantText = "";
|
|
57281
|
-
if (!
|
|
57282
|
-
emit({ ...base2(threadId, turnId), type: "item.completed", itemType: "assistant_text", text:
|
|
57442
|
+
if (!text5.trim()) return;
|
|
57443
|
+
emit({ ...base2(threadId, turnId), type: "item.completed", itemType: "assistant_text", text: text5 });
|
|
57283
57444
|
};
|
|
57284
57445
|
const settle = (ok, stopReason, usage) => {
|
|
57285
57446
|
if (settled) return;
|
|
@@ -57710,7 +57871,7 @@ var init_mistral = __esm({
|
|
|
57710
57871
|
nativeLog: {
|
|
57711
57872
|
source: "mistral.chat.completions",
|
|
57712
57873
|
outgoing: (_turn, messages, model) => ({ model, messageCount: messages.length }),
|
|
57713
|
-
incoming: ({ text:
|
|
57874
|
+
incoming: ({ text: text5, usage }) => ({ textLength: text5.length, usage })
|
|
57714
57875
|
}
|
|
57715
57876
|
});
|
|
57716
57877
|
}
|
|
@@ -57720,13 +57881,13 @@ var init_mistral = __esm({
|
|
|
57720
57881
|
|
|
57721
57882
|
// server/drivers/minimax.ts
|
|
57722
57883
|
import { readFileSync as readFileSync31 } from "node:fs";
|
|
57723
|
-
import { homedir as
|
|
57884
|
+
import { homedir as homedir28 } from "node:os";
|
|
57724
57885
|
import { join as join48 } from "node:path";
|
|
57725
57886
|
function normalizedApiUrl(value) {
|
|
57726
57887
|
const root = value.trim().replace(/\/+$/, "");
|
|
57727
57888
|
return root.endsWith("/v1") ? root : `${root}/v1`;
|
|
57728
57889
|
}
|
|
57729
|
-
function loadLocalMiniMaxConfig(home =
|
|
57890
|
+
function loadLocalMiniMaxConfig(home = homedir28()) {
|
|
57730
57891
|
try {
|
|
57731
57892
|
const raw = localConfigSchema.parse(JSON.parse(readFileSync31(join48(home, ".mmx", "config.json"), "utf8")));
|
|
57732
57893
|
const configuredUrl = raw.base_url?.trim() ? raw.base_url : raw.region === "cn" ? CN_URL : DEFAULT_URL3;
|
|
@@ -57824,7 +57985,7 @@ var init_minimax = __esm({
|
|
|
57824
57985
|
nativeLog: {
|
|
57825
57986
|
source: "minimax.chat.completions",
|
|
57826
57987
|
outgoing: (_turn, messages, model) => ({ model, messageCount: messages.length }),
|
|
57827
|
-
incoming: ({ text:
|
|
57988
|
+
incoming: ({ text: text5, usage }) => ({ textLength: text5.length, usage })
|
|
57828
57989
|
}
|
|
57829
57990
|
});
|
|
57830
57991
|
}
|
|
@@ -58103,9 +58264,9 @@ function createAppleIntelligenceInstance(input, deps = {}) {
|
|
|
58103
58264
|
let failure;
|
|
58104
58265
|
try {
|
|
58105
58266
|
const request = shapeRequest(turn, inputBudget(availability.contextSize));
|
|
58106
|
-
const
|
|
58107
|
-
if (!
|
|
58108
|
-
emit({ ...base2(turn.threadId, turnId), type: "item.completed", itemType: "assistant_text", text:
|
|
58267
|
+
const text5 = await client.stream(request, (delta) => emit({ ...base2(turn.threadId, turnId), type: "content.delta", streamKind: "assistant_text", delta }), abort.signal);
|
|
58268
|
+
if (!text5.trim()) throw new Error("Apple Intelligence returned an empty response.");
|
|
58269
|
+
emit({ ...base2(turn.threadId, turnId), type: "item.completed", itemType: "assistant_text", text: text5 });
|
|
58109
58270
|
ok = true;
|
|
58110
58271
|
} catch (error51) {
|
|
58111
58272
|
failure = error51 instanceof Error ? error51.message : String(error51);
|
|
@@ -58182,10 +58343,10 @@ var init_apple_intelligence2 = __esm({
|
|
|
58182
58343
|
INPUT_TOKEN_BUDGET = 6e3;
|
|
58183
58344
|
REPLY_TOKENS = 1500;
|
|
58184
58345
|
CHARS_PER_TOKEN = 4;
|
|
58185
|
-
estimateTokens = (
|
|
58186
|
-
clip = (
|
|
58346
|
+
estimateTokens = (text5) => Math.ceil(text5.length / CHARS_PER_TOKEN);
|
|
58347
|
+
clip = (text5, tokens) => {
|
|
58187
58348
|
const chars = Math.max(0, tokens * CHARS_PER_TOKEN);
|
|
58188
|
-
return
|
|
58349
|
+
return text5.length <= chars ? text5 : `${text5.slice(0, Math.max(0, chars - 1))}\u2026`;
|
|
58189
58350
|
};
|
|
58190
58351
|
configSchema4 = external_exports.object({}).passthrough();
|
|
58191
58352
|
AppleIntelligenceDriver = {
|
|
@@ -58840,7 +59001,7 @@ __export(browser_engine_exports, {
|
|
|
58840
59001
|
});
|
|
58841
59002
|
import { createHash as createHash16, randomBytes as randomBytes3, randomUUID as randomUUID17 } from "node:crypto";
|
|
58842
59003
|
import { chmodSync as chmodSync7, constants as constants3, copyFileSync, existsSync as existsSync25, mkdirSync as mkdirSync26, readFileSync as readFileSync33, readdirSync as readdirSync8, renameSync as renameSync8, rmSync as rmSync11, statSync as statSync6, unlinkSync as unlinkSync7, writeFileSync as writeFileSync22 } from "node:fs";
|
|
58843
|
-
import { homedir as
|
|
59004
|
+
import { homedir as homedir29, tmpdir as tmpdir7 } from "node:os";
|
|
58844
59005
|
import { delimiter as delimiter7, dirname as dirname12, join as join53, resolve as resolve12 } from "node:path";
|
|
58845
59006
|
function browserRestoreKey(session) {
|
|
58846
59007
|
if (!/^[A-Za-z0-9_.-]{1,96}$/.test(session)) throw new Error("Invalid browser session.");
|
|
@@ -58849,7 +59010,7 @@ function browserRestoreKey(session) {
|
|
|
58849
59010
|
function browserSessionsDirectory(env) {
|
|
58850
59011
|
const namespace = env.AGENT_BROWSER_NAMESPACE;
|
|
58851
59012
|
if (namespace && !/^[a-z0-9]+(?:[-_][a-z0-9]+)*$/.test(namespace)) throw new Error("Invalid browser namespace.");
|
|
58852
|
-
const home = (process.platform === "win32" ? env.USERPROFILE : env.HOME) ||
|
|
59013
|
+
const home = (process.platform === "win32" ? env.USERPROFILE : env.HOME) || homedir29();
|
|
58853
59014
|
const stateRoot = namespace ? join53(home, ".agent-browser", "namespaces", namespace, "state") : join53(home, ".agent-browser");
|
|
58854
59015
|
return join53(stateRoot, "sessions");
|
|
58855
59016
|
}
|
|
@@ -59405,7 +59566,7 @@ var import_qrcode_terminal = __toESM(require_main(), 1);
|
|
|
59405
59566
|
import { spawn as spawn10 } from "node:child_process";
|
|
59406
59567
|
import { randomBytes as randomBytes4 } from "node:crypto";
|
|
59407
59568
|
import { closeSync as closeSync6, existsSync as existsSync26, mkdirSync as mkdirSync27, openSync as openSync6, readFileSync as readFileSync34 } from "node:fs";
|
|
59408
|
-
import { homedir as
|
|
59569
|
+
import { homedir as homedir30 } from "node:os";
|
|
59409
59570
|
import { dirname as dirname13, join as join54, resolve as resolve13 } from "node:path";
|
|
59410
59571
|
import { createInterface as createInterface2 } from "node:readline/promises";
|
|
59411
59572
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
@@ -60039,10 +60200,10 @@ async function verifyHostedEndpoint(endpoint, { fetchImpl, timeoutSignal, timeou
|
|
|
60039
60200
|
signal: cancellationSignal ? AbortSignal.any([requestSignal, cancellationSignal]) : requestSignal
|
|
60040
60201
|
});
|
|
60041
60202
|
if (!response.ok) return false;
|
|
60042
|
-
const
|
|
60043
|
-
if (Buffer.byteLength(
|
|
60203
|
+
const text5 = await response.text();
|
|
60204
|
+
if (Buffer.byteLength(text5) > 4096) return false;
|
|
60044
60205
|
try {
|
|
60045
|
-
return JSON.parse(
|
|
60206
|
+
return JSON.parse(text5)?.app === "openmausbot";
|
|
60046
60207
|
} catch {
|
|
60047
60208
|
return false;
|
|
60048
60209
|
}
|
|
@@ -60955,8 +61116,8 @@ function isSecretParameter(name) {
|
|
|
60955
61116
|
function keyLikeSegment(segment) {
|
|
60956
61117
|
return (segment.match(/[A-Za-z0-9]{16,}/g) ?? []).some((run2) => /\d/.test(run2) && /[A-Za-z]/.test(run2));
|
|
60957
61118
|
}
|
|
60958
|
-
function maskUrlSecrets(
|
|
60959
|
-
return
|
|
61119
|
+
function maskUrlSecrets(text5) {
|
|
61120
|
+
return text5.replace(/\b([a-z][\w+.-]*:\/\/)([^\s/?#]*)([^\s?#]*)([^\s]*)/gi, (_all, scheme, authority, path4, rest) => {
|
|
60960
61121
|
const at2 = authority.lastIndexOf("@");
|
|
60961
61122
|
const host = at2 >= 0 ? `${HIDDEN}@${authority.slice(at2 + 1)}` : authority;
|
|
60962
61123
|
const maskedPath = path4.split("/").map((segment) => keyLikeSegment(segment) ? HIDDEN : segment).join("/");
|
|
@@ -60994,8 +61155,8 @@ function auditValues(values) {
|
|
|
60994
61155
|
const last = segments.at(-1) ?? path4;
|
|
60995
61156
|
const opaque = segments.slice(0, -1).some((segment) => OPAQUE_MAP.test(segment));
|
|
60996
61157
|
const scrubbed = (isSecretName2(last) || opaque) && value !== void 0 && value !== null && value !== "" ? HIDDEN : scrub(value, 0, OPAQUE_MAP.test(last));
|
|
60997
|
-
const
|
|
60998
|
-
out[path4] =
|
|
61158
|
+
const text5 = JSON.stringify(scrubbed);
|
|
61159
|
+
out[path4] = text5 !== void 0 && text5.length > MAX_VALUE_CHARS ? "[large value]" : scrubbed ?? null;
|
|
60999
61160
|
}
|
|
61000
61161
|
return out;
|
|
61001
61162
|
}
|
|
@@ -61180,9 +61341,9 @@ async function startCaddy(options) {
|
|
|
61180
61341
|
});
|
|
61181
61342
|
let output = "";
|
|
61182
61343
|
const receive = (chunk) => {
|
|
61183
|
-
const
|
|
61184
|
-
if (output.length < 16384) output +=
|
|
61185
|
-
for (const line of
|
|
61344
|
+
const text5 = chunk.toString("utf8");
|
|
61345
|
+
if (output.length < 16384) output += text5;
|
|
61346
|
+
for (const line of text5.split(/\r?\n/)) {
|
|
61186
61347
|
if (!line.trim()) continue;
|
|
61187
61348
|
if (/"level":"(warn|error)"/.test(line) || /^\S+\s+(WARN|ERROR)/.test(line) || !line.startsWith("{")) options.log?.(`caddy: ${line.slice(0, 400)}`);
|
|
61188
61349
|
}
|
|
@@ -61534,16 +61695,16 @@ var TEXT_COLORS = {
|
|
|
61534
61695
|
dark: { accent: [[0, 179, 152], 36], gold: [[242, 169, 0], 214] },
|
|
61535
61696
|
unknown: { accent: [[0, 128, 108], 30], gold: [[168, 100, 0], 130] }
|
|
61536
61697
|
};
|
|
61537
|
-
function paint(
|
|
61538
|
-
if (depth === "none") return
|
|
61698
|
+
function paint(text5, role, depth, background, bold) {
|
|
61699
|
+
if (depth === "none") return text5;
|
|
61539
61700
|
const weight = bold ? "1;" : "";
|
|
61540
|
-
if (depth === "16") return `\x1B[${weight}${role === "accent" ? 36 : 33}m${
|
|
61701
|
+
if (depth === "16") return `\x1B[${weight}${role === "accent" ? 36 : 33}m${text5}\x1B[0m`;
|
|
61541
61702
|
const [triple, index] = TEXT_COLORS[background][role];
|
|
61542
|
-
if (depth === "256") return `\x1B[${weight}38;5;${index}m${
|
|
61543
|
-
return `\x1B[${weight}38;2;${triple.join(";")}m${
|
|
61703
|
+
if (depth === "256") return `\x1B[${weight}38;5;${index}m${text5}\x1B[0m`;
|
|
61704
|
+
return `\x1B[${weight}38;2;${triple.join(";")}m${text5}\x1B[0m`;
|
|
61544
61705
|
}
|
|
61545
|
-
function quiet(
|
|
61546
|
-
return depth === "none" ?
|
|
61706
|
+
function quiet(text5, depth) {
|
|
61707
|
+
return depth === "none" ? text5 : `\x1B[2m${text5}\x1B[0m`;
|
|
61547
61708
|
}
|
|
61548
61709
|
function renderBanner(input) {
|
|
61549
61710
|
const random = input.random ?? Math.random;
|
|
@@ -61551,7 +61712,7 @@ function renderBanner(input) {
|
|
|
61551
61712
|
const greeting = pick2(GREETINGS);
|
|
61552
61713
|
const tip = pick2(TIPS);
|
|
61553
61714
|
const { depth, background } = input;
|
|
61554
|
-
const
|
|
61715
|
+
const text5 = [
|
|
61555
61716
|
`${paint("Atomic", "accent", depth, background, true)} by Chibitek`,
|
|
61556
61717
|
quiet(`Version ${input.version}`, depth),
|
|
61557
61718
|
input.account ? `Signed in as ${input.account}` : quiet("Not signed in to an Atomic account", depth),
|
|
@@ -61560,19 +61721,19 @@ function renderBanner(input) {
|
|
|
61560
61721
|
`${paint("Tip:", "gold", depth, background, true)} ${tip}`
|
|
61561
61722
|
];
|
|
61562
61723
|
const columns = input.columns ?? 80;
|
|
61563
|
-
if (columns < 20) return `${
|
|
61724
|
+
if (columns < 20) return `${text5.join("\n")}
|
|
61564
61725
|
`;
|
|
61565
61726
|
const mark = chibiAnsiLines(depth, background === "light" ? "light" : "dark");
|
|
61566
61727
|
const widest = Math.max(...[greeting, `Tip: ${tip}`, input.account ? `Signed in as ${input.account}` : ""].map((l) => l.length));
|
|
61567
61728
|
if (columns < 16 + 3 + Math.min(widest, 44)) return `${mark.map((line) => line.trimEnd()).join("\n")}
|
|
61568
61729
|
|
|
61569
|
-
${
|
|
61730
|
+
${text5.join("\n")}
|
|
61570
61731
|
`;
|
|
61571
|
-
const rows = Math.max(mark.length,
|
|
61732
|
+
const rows = Math.max(mark.length, text5.length);
|
|
61572
61733
|
const lines = [];
|
|
61573
61734
|
for (let i2 = 0; i2 < rows; i2 += 1) {
|
|
61574
61735
|
const left = mark[i2] ?? " ".repeat(16);
|
|
61575
|
-
const right =
|
|
61736
|
+
const right = text5[i2] ?? "";
|
|
61576
61737
|
lines.push(right ? `${left} ${right}` : left.trimEnd());
|
|
61577
61738
|
}
|
|
61578
61739
|
return `${lines.join("\n")}
|
|
@@ -61658,8 +61819,8 @@ function agentUnit(spec) {
|
|
|
61658
61819
|
function emptyRegistry(domain2) {
|
|
61659
61820
|
return { version: 1, domain: domain2, nextPort: FLEET_FIRST_PORT, workspaces: {} };
|
|
61660
61821
|
}
|
|
61661
|
-
function parseRegistry(
|
|
61662
|
-
const value = JSON.parse(
|
|
61822
|
+
function parseRegistry(text5) {
|
|
61823
|
+
const value = JSON.parse(text5);
|
|
61663
61824
|
const record6 = value && typeof value === "object" ? value : null;
|
|
61664
61825
|
if (!record6 || record6.version !== 1 || typeof record6.domain !== "string" || typeof record6.nextPort !== "number" || !record6.workspaces || typeof record6.workspaces !== "object") {
|
|
61665
61826
|
throw new Error("fleet.json is not a fleet registry this version understands");
|
|
@@ -62269,9 +62430,9 @@ function failed(io2, what, output) {
|
|
|
62269
62430
|
return 1;
|
|
62270
62431
|
}
|
|
62271
62432
|
function loadRegistry(layout, deps) {
|
|
62272
|
-
const
|
|
62273
|
-
if (
|
|
62274
|
-
return parseRegistry(
|
|
62433
|
+
const text5 = deps.readText(layout.registryFile);
|
|
62434
|
+
if (text5 === null) throw new Error(`no fleet on this server yet: run \`chibi fleet init --domain your.domain\` first`);
|
|
62435
|
+
return parseRegistry(text5);
|
|
62275
62436
|
}
|
|
62276
62437
|
function planFleetAction(input, deps) {
|
|
62277
62438
|
const layout = fleetLayout(input.root ?? "/");
|
|
@@ -62445,15 +62606,15 @@ import { dirname as dirname3 } from "node:path";
|
|
|
62445
62606
|
var MAX_BODY = 256 * 1024;
|
|
62446
62607
|
function readBody(req) {
|
|
62447
62608
|
return new Promise((resolve14, reject) => {
|
|
62448
|
-
let
|
|
62609
|
+
let text5 = "";
|
|
62449
62610
|
req.on("data", (chunk) => {
|
|
62450
|
-
|
|
62451
|
-
if (
|
|
62611
|
+
text5 += chunk.toString("utf8");
|
|
62612
|
+
if (text5.length > MAX_BODY) reject(Object.assign(new Error("request too large"), { status: 413 }));
|
|
62452
62613
|
});
|
|
62453
62614
|
req.on("end", () => {
|
|
62454
|
-
if (!
|
|
62615
|
+
if (!text5.trim()) return resolve14({});
|
|
62455
62616
|
try {
|
|
62456
|
-
const value = JSON.parse(
|
|
62617
|
+
const value = JSON.parse(text5);
|
|
62457
62618
|
resolve14(value && typeof value === "object" && !Array.isArray(value) ? value : {});
|
|
62458
62619
|
} catch {
|
|
62459
62620
|
reject(Object.assign(new Error("body must be JSON"), { status: 400 }));
|
|
@@ -62670,8 +62831,8 @@ function tailnetNameBlocksHttps(name) {
|
|
|
62670
62831
|
|
|
62671
62832
|
// server/tailscale.ts
|
|
62672
62833
|
init_procs();
|
|
62673
|
-
function classifyTailscaleStderr(
|
|
62674
|
-
const t2 =
|
|
62834
|
+
function classifyTailscaleStderr(text5) {
|
|
62835
|
+
const t2 = text5.toLowerCase();
|
|
62675
62836
|
if (/not logged in|logged out|needs login|please log in/.test(t2)) return "not-logged-in";
|
|
62676
62837
|
if (/is tailscale running|tailscaled is not running|connection refused|failed to connect to local tailscaled/.test(t2)) return "not-running";
|
|
62677
62838
|
if (/rejectedidentifier|reserved format|r-ldh/.test(t2)) return "reserved-name";
|
|
@@ -63126,7 +63287,7 @@ function parseArgs2(argv, env = process.env) {
|
|
|
63126
63287
|
const options = {
|
|
63127
63288
|
command: command === "--help" || command === "-h" ? "help" : command,
|
|
63128
63289
|
port: Number(env.OMB_PORT || 8799),
|
|
63129
|
-
dataDir: env.OMB_DATA_DIR || join54(
|
|
63290
|
+
dataDir: env.OMB_DATA_DIR || join54(homedir30(), ".atomic-app"),
|
|
63130
63291
|
tailscale: false,
|
|
63131
63292
|
tunnel: false,
|
|
63132
63293
|
client: false,
|
|
@@ -63377,9 +63538,9 @@ function originOf(link) {
|
|
|
63377
63538
|
return null;
|
|
63378
63539
|
}
|
|
63379
63540
|
}
|
|
63380
|
-
function qrToString(
|
|
63541
|
+
function qrToString(text5) {
|
|
63381
63542
|
let out = "";
|
|
63382
|
-
import_qrcode_terminal.default.generate(
|
|
63543
|
+
import_qrcode_terminal.default.generate(text5, { small: true }, (rendered) => {
|
|
63383
63544
|
out = rendered;
|
|
63384
63545
|
});
|
|
63385
63546
|
return out;
|
|
@@ -63722,7 +63883,7 @@ async function runServe(options, log = console.log) {
|
|
|
63722
63883
|
console.error(`something already answers on http://127.0.0.1:${options.port}; use \`chibi pair\` against it, or --port for a second server`);
|
|
63723
63884
|
return 1;
|
|
63724
63885
|
}
|
|
63725
|
-
if (await reportBusyPort(options.port, options.dataDir === join54(
|
|
63886
|
+
if (await reportBusyPort(options.port, options.dataDir === join54(homedir30(), ".atomic-app") ? "" : ` --data-dir ${options.dataDir}`)) return 1;
|
|
63726
63887
|
let publicUrl = options.publicUrl;
|
|
63727
63888
|
let tailscale = null;
|
|
63728
63889
|
if (options.tailscale) {
|
|
@@ -63990,7 +64151,7 @@ async function runOnboardingCommand(options, io2 = defaultIo(), startServer = ru
|
|
|
63990
64151
|
saveCliStartup2(options.dataDir, startupPreferences(launch));
|
|
63991
64152
|
}
|
|
63992
64153
|
if (options.command === "setup") {
|
|
63993
|
-
const flags = [options.dataDir !== join54(
|
|
64154
|
+
const flags = [options.dataDir !== join54(homedir30(), ".atomic-app") && ` --data-dir ${options.dataDir}`, options.port !== 8799 && ` --port ${options.port}`].filter(Boolean).join("");
|
|
63994
64155
|
io2.log(`
|
|
63995
64156
|
All set. Start with: chibi${flags ? ` start${flags}` : ""} (or npx @chibitek/chibi without a global install).`);
|
|
63996
64157
|
return 0;
|
|
@@ -64030,15 +64191,15 @@ ${welcomeBanner(options)}
|
|
|
64030
64191
|
switch (options.command) {
|
|
64031
64192
|
case "command":
|
|
64032
64193
|
case "goal": {
|
|
64033
|
-
const
|
|
64034
|
-
const roomGoal = options.groupId ? /^\/goal(?:\s+([\s\S]*))?$/.exec(
|
|
64194
|
+
const text5 = options.command === "goal" ? `/goal ${options.commandText}` : options.commandText;
|
|
64195
|
+
const roomGoal = options.groupId ? /^\/goal(?:\s+([\s\S]*))?$/.exec(text5 ?? "") : null;
|
|
64035
64196
|
if (roomGoal && (!roomGoal[1]?.trim() || (roomGoal[1].startsWith("--") || /^(status|pause|resume|stop|help)(?:\s|$)/.test(roomGoal[1])))) {
|
|
64036
64197
|
console.error("Room goals accept an objective. Personal goal controls and budgets require --bot.");
|
|
64037
64198
|
return 2;
|
|
64038
64199
|
}
|
|
64039
64200
|
const result = await api(options.port, `/api/${options.groupId ? "groups" : "bots"}/${encodeURIComponent(options.groupId ?? options.botId)}/messages`, {
|
|
64040
64201
|
method: "POST",
|
|
64041
|
-
body: JSON.stringify({ threadId: options.threadId, text: roomGoal ? roomGoal[1] :
|
|
64202
|
+
body: JSON.stringify({ threadId: options.threadId, text: roomGoal ? roomGoal[1] : text5, ...roomGoal ? { mode: "goal" } : {}, sendId: randomBytes4(16).toString("hex") })
|
|
64042
64203
|
});
|
|
64043
64204
|
if (result.status >= 400) {
|
|
64044
64205
|
console.error(result.body.error ?? `Server returned ${result.status}`);
|