@chibitek/chibi 0.1.177 → 0.1.178
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-dWHl3jkm.js} +1 -1
- package/dist/assets/{arc-Chl6g0yq.js → arc-CZzCs6es.js} +1 -1
- package/dist/assets/{architectureDiagram-NJMV4G6O-ChT8017v.js → architectureDiagram-NJMV4G6O-YwZAu6Y7.js} +1 -1
- package/dist/assets/{blockDiagram-BEXU5L5S-DSOAtPXh.js → blockDiagram-BEXU5L5S-WmC_extb.js} +1 -1
- package/dist/assets/{c4Diagram-YGBWAQC7-CAyzcis4.js → c4Diagram-YGBWAQC7-B65Jnm1V.js} +1 -1
- package/dist/assets/channel-ClZ5TVsZ.js +1 -0
- package/dist/assets/{chunk-2Q5K7J3B-DG7zWvl1.js → chunk-2Q5K7J3B-CKo9M6W3.js} +1 -1
- package/dist/assets/{chunk-3FUC2YCW-CNQ37WCV.js → chunk-3FUC2YCW-7yQVJbNw.js} +2 -2
- package/dist/assets/{chunk-5VM5RSS4-Dvv3U9Ci.js → chunk-5VM5RSS4-De0KYP62.js} +1 -1
- package/dist/assets/{chunk-GTNCS2PH-DyQrY0Ij.js → chunk-GTNCS2PH-CLr-nzve.js} +1 -1
- package/dist/assets/{chunk-GWA4HPMP-BLgrTe-Y.js → chunk-GWA4HPMP-CtuDeI-a.js} +1 -1
- package/dist/assets/{chunk-JWPE2WC7-Bi7RU6mT.js → chunk-JWPE2WC7-y52neVCm.js} +1 -1
- package/dist/assets/{chunk-NETBCI7D-bBBVBfAd.js → chunk-NETBCI7D-CTQRNeEv.js} +1 -1
- package/dist/assets/{chunk-WEXAMYUT-CE_h60fU.js → chunk-WEXAMYUT-7zNFA7Tc.js} +1 -1
- package/dist/assets/{chunk-XXDRQBXY-f6P9rCRq.js → chunk-XXDRQBXY-CF0jLMvs.js} +1 -1
- package/dist/assets/{classDiagram-v2-NBCMYWYE-6Uq3JzmJ.js → classDiagram-v2-NBCMYWYE-WBfBG6F9.js} +1 -1
- package/dist/assets/{cose-bilkent-JH36ORCC-BxvkL31E.js → cose-bilkent-JH36ORCC-BN-OWUOQ.js} +1 -1
- package/dist/assets/{cynefin-OW5HDTMX-Dlcwlw2F.js → cynefin-OW5HDTMX-icxZUnEx.js} +1 -1
- package/dist/assets/{cynefinDiagram-VND7K2PF-D3NOeWUy.js → cynefinDiagram-VND7K2PF-Clgujiet.js} +1 -1
- package/dist/assets/{dagre-6A5THRUB-IGmT7nsP.js → dagre-6A5THRUB-B-mr-ojn.js} +1 -1
- package/dist/assets/{diagram-22UHCM2B-D0K8tG3k.js → diagram-22UHCM2B-0VKN1h9d.js} +1 -1
- package/dist/assets/{diagram-3UASUU5V-CSkDkOvw.js → diagram-3UASUU5V-9Nvuaj11.js} +1 -1
- package/dist/assets/{diagram-ATOU4E4O-CX5EXBJ_.js → diagram-ATOU4E4O-B-uzDb8p.js} +1 -1
- package/dist/assets/{diagram-CDSNMT55-D0FQ7x1J.js → diagram-CDSNMT55-CTvDjLvE.js} +1 -1
- package/dist/assets/{diagram-MLGK6HIB-BymN_w7h.js → diagram-MLGK6HIB-DxDrNPv6.js} +1 -1
- package/dist/assets/{diagram-MPIPVDR6-ugKqp8yy.js → diagram-MPIPVDR6-CGHXB_-s.js} +1 -1
- package/dist/assets/{ebnfDiagram-ZINNZB2B-DROFb0r3.js → ebnfDiagram-ZINNZB2B-DNkShTCq.js} +1 -1
- package/dist/assets/{elk-276RUBZZ-CNVCU2l7.js → elk-276RUBZZ-CNZgZP06.js} +1 -1
- package/dist/assets/{erDiagram-OPXOYQCR-BQj5bZ7y.js → erDiagram-OPXOYQCR-CVlJu0RH.js} +1 -1
- package/dist/assets/{flowDiagram-KWPJA3E3-C3cBXKRL.js → flowDiagram-KWPJA3E3-ZWXAAVoE.js} +1 -1
- package/dist/assets/{ganttDiagram-FUAMR5RP-CdNdC_Vp.js → ganttDiagram-FUAMR5RP-BaPFE0m8.js} +1 -1
- package/dist/assets/{gitGraphDiagram-X574FWY7-v_LM9fGO.js → gitGraphDiagram-X574FWY7-B__eRHIL.js} +1 -1
- package/dist/assets/index-CI0vGAif.css +1 -0
- package/dist/assets/{index-fnHp_1ly.js → index-CluLWh67.js} +1 -1
- package/dist/assets/{index-UICHeO5x.js → index-DxRLJ091.js} +197 -195
- package/dist/assets/{infoDiagram-VRGFBTTK-0fzWO21Z.js → infoDiagram-VRGFBTTK-DQkxDIsw.js} +1 -1
- package/dist/assets/{ishikawaDiagram-OU5B5YK6-BmqyKWCK.js → ishikawaDiagram-OU5B5YK6-dc12aZx1.js} +1 -1
- package/dist/assets/{journeyDiagram-ZHPQQLJL-BSihTjOI.js → journeyDiagram-ZHPQQLJL-BUQgOHxW.js} +1 -1
- package/dist/assets/{kanban-definition-PNTS6WVX-LAP03jiI.js → kanban-definition-PNTS6WVX-0G8FTiwC.js} +1 -1
- package/dist/assets/{linear-BoSfZT4X.js → linear-BsZ0eCh6.js} +1 -1
- package/dist/assets/{mermaid.core-KciMRs_R.js → mermaid.core-CBJIrEjV.js} +5 -5
- package/dist/assets/{mindmap-definition-NLK3R4M7-CEGLBEfc.js → mindmap-definition-NLK3R4M7-oSFMOeAf.js} +1 -1
- package/dist/assets/{pegDiagram-GJSIUBJH-DLwMHvoR.js → pegDiagram-GJSIUBJH-DfF1Bylk.js} +1 -1
- package/dist/assets/{pieDiagram-5QR66LMP-DHnlu96s.js → pieDiagram-5QR66LMP-B75tQFJV.js} +1 -1
- package/dist/assets/{quadrantDiagram-O4NWA36T-C_aIseXA.js → quadrantDiagram-O4NWA36T-Bzost4vl.js} +1 -1
- package/dist/assets/{railroadDiagram-XR7U4H2S-DOXDQ14n.js → railroadDiagram-XR7U4H2S-Kj-_EJse.js} +1 -1
- package/dist/assets/{requirementDiagram-PLB6GJNP-C49u1hle.js → requirementDiagram-PLB6GJNP-DgGyLbhO.js} +1 -1
- package/dist/assets/{sankeyDiagram-IPEJSGJF-TO8i3aYk.js → sankeyDiagram-IPEJSGJF-Ds7nNV4g.js} +1 -1
- package/dist/assets/{sequenceDiagram-PO4LG4MO-CqByM3om.js → sequenceDiagram-PO4LG4MO-BherGJTE.js} +1 -1
- package/dist/assets/{sizeCapture-INFHLROL-BVsTiKjg.js → sizeCapture-INFHLROL-his3_ohk.js} +1 -1
- package/dist/assets/{stateDiagram-v2-GCMORJYK-0AUlHnV-.js → stateDiagram-v2-GCMORJYK-Dm1QWOxb.js} +1 -1
- package/dist/assets/{swimlanes-2SLR337P-D_wUrvq4.js → swimlanes-2SLR337P-CCDiiGy4.js} +1 -1
- package/dist/assets/swimlanesDiagram-TC7HE7FX-7bU41JJL.js +8 -0
- package/dist/assets/{timeline-definition-EJHVYXUP-qf2wxQef.js → timeline-definition-EJHVYXUP-CTgG6kVO.js} +1 -1
- package/dist/assets/{usecaseDiagram-POWQR4AR-Blqc8FjE.js → usecaseDiagram-POWQR4AR-B9FjIil8.js} +1 -1
- package/dist/assets/{vennDiagram-UO4OBE2U-Df3HJl0f.js → vennDiagram-UO4OBE2U-D_WKiutd.js} +1 -1
- package/dist/assets/{wardleyDiagram-VNRHLVJA-B-QhMirM.js → wardleyDiagram-VNRHLVJA-DqAabdPt.js} +1 -1
- package/dist/assets/{xychartDiagram-PMCCYNJV-DsZdyUlm.js → xychartDiagram-PMCCYNJV-CYpL8DXw.js} +1 -1
- package/dist/index.html +2 -2
- package/dist-server/drivers/agents-proxy.js +3 -2
- package/dist-server/index.js +1822 -1618
- package/dist-server/openmausbot.js +649 -490
- package/dist-server/pair-cli.js +649 -490
- 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-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 +40 -21
- 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
package/dist-server/pair-cli.js
CHANGED
|
@@ -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;
|
|
@@ -25927,49 +25931,49 @@ var init_engine_failure = __esm({
|
|
|
25927
25931
|
RESET_WORD = String.raw`\b(?:resets?|try again|retry|available again|renews?|refresh(?:es)?)\b`;
|
|
25928
25932
|
RESET_READERS = [
|
|
25929
25933
|
// Claude Code's "usage limit reached|1759348800".
|
|
25930
|
-
function* epochPipe(
|
|
25931
|
-
for (const m3 of
|
|
25934
|
+
function* epochPipe(text5) {
|
|
25935
|
+
for (const m3 of text5.matchAll(/(?:usage limit reached\s*)?\|\s*(\d{10})(\d{3})?(?!\d)/gi)) {
|
|
25932
25936
|
yield { at: Number(m3[1]) * 1e3, phrase: m3[0] };
|
|
25933
25937
|
}
|
|
25934
25938
|
},
|
|
25935
25939
|
// A structured reset instant: Codex's "resets_at": 1759348800, a
|
|
25936
25940
|
// "resetsAt", the unified rate-limit header.
|
|
25937
|
-
function* epochField(
|
|
25938
|
-
for (const m3 of
|
|
25941
|
+
function* epochField(text5) {
|
|
25942
|
+
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
25943
|
yield { at: m3[1].length === 13 ? Number(m3[1]) : Number(m3[1]) * 1e3, phrase: m3[0] };
|
|
25940
25944
|
}
|
|
25941
25945
|
},
|
|
25942
25946
|
// "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
|
|
25947
|
+
function* isoTimestamp(text5) {
|
|
25948
|
+
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
25949
|
const [, y, mo2, d, h2, mi2, sec, frac, zoneText] = m3;
|
|
25946
|
-
const start = leadIn(
|
|
25950
|
+
const start = leadIn(text5, m3.index);
|
|
25947
25951
|
if (!zoneText && start === m3.index) continue;
|
|
25948
|
-
const after = zoneText ? void 0 : zoneAfter(
|
|
25952
|
+
const after = zoneText ? void 0 : zoneAfter(text5.slice(m3.index + m3[0].length));
|
|
25949
25953
|
const zone = zoneText ? parseZone(zoneText) : after?.zone ?? localZone();
|
|
25950
25954
|
if (!zone) continue;
|
|
25951
25955
|
const ms2 = frac ? Math.round(Number(`0.${frac}`) * 1e3) : 0;
|
|
25952
25956
|
const at2 = wallToInstant(Number(y), Number(mo2), Number(d), Number(h2), Number(mi2), zone, Number(sec ?? 0) * 1e3 + ms2);
|
|
25953
|
-
yield { at: at2, phrase:
|
|
25957
|
+
yield { at: at2, phrase: text5.slice(start, m3.index + m3[0].length + (after?.length ?? 0)) };
|
|
25954
25958
|
}
|
|
25955
25959
|
},
|
|
25956
25960
|
// "Retry-After: 120", "retry after 3600 seconds".
|
|
25957
|
-
function* retryAfter(
|
|
25958
|
-
for (const m3 of
|
|
25961
|
+
function* retryAfter(text5, now) {
|
|
25962
|
+
for (const m3 of text5.matchAll(new RegExp(String.raw`\bretry[- ]after:?\s*(\d+(?:\.\d+)?)\s*(${UNIT})?`, "gi"))) {
|
|
25959
25963
|
yield { at: now + (m3[2] ? durationMs(`${m3[1]}${m3[2]}`) : Number(m3[1]) * 1e3), phrase: m3[0] };
|
|
25960
25964
|
}
|
|
25961
25965
|
},
|
|
25962
25966
|
// Structured durations: Gemini's "retryDelay": "41s", Codex's
|
|
25963
25967
|
// "resets_in_seconds": 3600, a "retry_after": 30.
|
|
25964
|
-
function* durationField(
|
|
25965
|
-
for (const m3 of
|
|
25968
|
+
function* durationField(text5, now) {
|
|
25969
|
+
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
25970
|
yield { at: now + Number(m3[2]) * (m3[3]?.toLowerCase() === "ms" ? 1 : 1e3), phrase: m3[0] };
|
|
25967
25971
|
}
|
|
25968
25972
|
},
|
|
25969
25973
|
// "try again in 2 days 4 hours 12 minutes", "resets in 37m", "Please
|
|
25970
25974
|
// retry in 41.5s", "resets in 2d 4h 30m".
|
|
25971
|
-
function* relative(
|
|
25972
|
-
for (const m3 of
|
|
25975
|
+
function* relative(text5, now) {
|
|
25976
|
+
for (const m3 of text5.matchAll(new RegExp(String.raw`${RESET_WORD}\s+in\s+(${DURATION})`, "gi"))) {
|
|
25973
25977
|
const total = durationMs(m3[1]);
|
|
25974
25978
|
if (total > 0) yield { at: now + total, phrase: m3[0] };
|
|
25975
25979
|
}
|
|
@@ -25977,11 +25981,11 @@ var init_engine_failure = __esm({
|
|
|
25977
25981
|
// A time of day, maybe with a date: "resets 3pm (America/New_York)",
|
|
25978
25982
|
// "resets Oct 3, 9am", "try again tomorrow at 9:00", "resets Thursday
|
|
25979
25983
|
// 9am", "Access resets at 3:45 PM EDT", "15:05 on 26 Sep 2026".
|
|
25980
|
-
function* clock2(
|
|
25981
|
-
for (const m3 of
|
|
25984
|
+
function* clock2(text5, now) {
|
|
25985
|
+
for (const m3 of text5.matchAll(new RegExp(RESET_WORD, "gi"))) {
|
|
25982
25986
|
const start = m3.index + m3[0].length;
|
|
25983
|
-
const found = readClock(
|
|
25984
|
-
if (found) yield { at: found.at, phrase:
|
|
25987
|
+
const found = readClock(text5.slice(start, start + 120), now);
|
|
25988
|
+
if (found) yield { at: found.at, phrase: text5.slice(m3.index, start + found.length) };
|
|
25985
25989
|
}
|
|
25986
25990
|
}
|
|
25987
25991
|
];
|
|
@@ -26043,13 +26047,13 @@ function isModelRejection(error51, requested) {
|
|
|
26043
26047
|
return MODEL_REJECTION.test(message2) || requested.length > 0 && message2.includes(requested) && /\bmodel\b/i.test(message2);
|
|
26044
26048
|
}
|
|
26045
26049
|
function classifyError(err) {
|
|
26046
|
-
const
|
|
26047
|
-
if (isProviderSafetyBlock(
|
|
26048
|
-
if (CREDENTIAL_REFRESH_CONFLICT.test(
|
|
26050
|
+
const text5 = messageOf(err);
|
|
26051
|
+
if (isProviderSafetyBlock(text5)) return { transient: false, reason: "provider_safety" };
|
|
26052
|
+
if (CREDENTIAL_REFRESH_CONFLICT.test(text5)) {
|
|
26049
26053
|
if (err && "exitCode" in err && err.exitCode !== null && err.exitCode < 0) return { transient: false, reason: "interrupted" };
|
|
26050
26054
|
return { transient: true, reason: "credential_refresh" };
|
|
26051
26055
|
}
|
|
26052
|
-
const failure = classifyEngineFailure(
|
|
26056
|
+
const failure = classifyEngineFailure(text5);
|
|
26053
26057
|
if (failure?.kind === "rate_limited") {
|
|
26054
26058
|
if (err && "exitCode" in err && err.exitCode !== null && err.exitCode < 0) return { transient: false, reason: "interrupted" };
|
|
26055
26059
|
return { transient: true, reason: "rate_limited" };
|
|
@@ -26059,18 +26063,18 @@ function classifyError(err) {
|
|
|
26059
26063
|
const { exitCode: code } = err;
|
|
26060
26064
|
if (code !== null && code < 0) return { transient: false, reason: "interrupted" };
|
|
26061
26065
|
for (const { pattern, reason } of TRANSIENT_PATTERNS) {
|
|
26062
|
-
if (pattern.test(
|
|
26066
|
+
if (pattern.test(text5)) return { transient: true, reason };
|
|
26063
26067
|
}
|
|
26064
26068
|
for (const { pattern, reason } of TERMINAL_PATTERNS) {
|
|
26065
|
-
if (pattern.test(
|
|
26069
|
+
if (pattern.test(text5)) return { transient: false, reason };
|
|
26066
26070
|
}
|
|
26067
26071
|
return { transient: false, reason: "terminal_exit" };
|
|
26068
26072
|
}
|
|
26069
26073
|
for (const { pattern, reason } of TERMINAL_PATTERNS) {
|
|
26070
|
-
if (pattern.test(
|
|
26074
|
+
if (pattern.test(text5)) return { transient: false, reason };
|
|
26071
26075
|
}
|
|
26072
26076
|
for (const { pattern, reason } of TRANSIENT_PATTERNS) {
|
|
26073
|
-
if (pattern.test(
|
|
26077
|
+
if (pattern.test(text5)) return { transient: true, reason };
|
|
26074
26078
|
}
|
|
26075
26079
|
return { transient: false, reason: "unknown" };
|
|
26076
26080
|
}
|
|
@@ -26226,8 +26230,8 @@ var init_turn_mcp = __esm({
|
|
|
26226
26230
|
// server/drivers/volatile-notes.ts
|
|
26227
26231
|
function volatileSectionsOf(turn) {
|
|
26228
26232
|
if (turn.systemVolatileSections) return turn.systemVolatileSections.filter((section) => section.text.trim());
|
|
26229
|
-
const
|
|
26230
|
-
return
|
|
26233
|
+
const text5 = turn.systemVolatile ?? "";
|
|
26234
|
+
return text5.trim() ? [{ id: "volatile", label: "Notes", text: text5 }] : [];
|
|
26231
26235
|
}
|
|
26232
26236
|
function volatileNote(sections, delivered, first) {
|
|
26233
26237
|
const parts = [];
|
|
@@ -26252,11 +26256,11 @@ ${lead}
|
|
|
26252
26256
|
${parts.join("\n\n")}
|
|
26253
26257
|
</system-reminder>`;
|
|
26254
26258
|
}
|
|
26255
|
-
function withNote(
|
|
26256
|
-
if (!note) return
|
|
26257
|
-
return
|
|
26259
|
+
function withNote(text5, note) {
|
|
26260
|
+
if (!note) return text5;
|
|
26261
|
+
return text5 ? `${note}
|
|
26258
26262
|
|
|
26259
|
-
${
|
|
26263
|
+
${text5}` : note;
|
|
26260
26264
|
}
|
|
26261
26265
|
var init_volatile_notes = __esm({
|
|
26262
26266
|
"server/drivers/volatile-notes.ts"() {
|
|
@@ -26264,6 +26268,135 @@ var init_volatile_notes = __esm({
|
|
|
26264
26268
|
}
|
|
26265
26269
|
});
|
|
26266
26270
|
|
|
26271
|
+
// server/drivers/acp/tool-log.ts
|
|
26272
|
+
function sanitizeToolLogValue(value, budget, depth = 0) {
|
|
26273
|
+
if (depth > 12 || budget.nodes-- <= 0) return void 0;
|
|
26274
|
+
if (typeof value === "string") {
|
|
26275
|
+
if (/^data:image\//iu.test(value) || budget.text <= 0) return void 0;
|
|
26276
|
+
const limit = Math.min(TOOL_LOG_TEXT_LIMIT, budget.text);
|
|
26277
|
+
const text5 = value.length <= limit ? value : `[Earlier output truncated]
|
|
26278
|
+
|
|
26279
|
+
${value.slice(-limit)}`;
|
|
26280
|
+
budget.text -= text5.length;
|
|
26281
|
+
return text5;
|
|
26282
|
+
}
|
|
26283
|
+
if (Array.isArray(value)) {
|
|
26284
|
+
return value.flatMap((entry) => {
|
|
26285
|
+
const sanitized = sanitizeToolLogValue(entry, budget, depth + 1);
|
|
26286
|
+
return sanitized === void 0 ? [] : [sanitized];
|
|
26287
|
+
});
|
|
26288
|
+
}
|
|
26289
|
+
if (!value || typeof value !== "object") return value;
|
|
26290
|
+
const record6 = value;
|
|
26291
|
+
return Object.fromEntries(Object.entries(record6).flatMap(([key, entry]) => {
|
|
26292
|
+
if (record6.type === "image" && (key === "data" || key === "blob") || key === "blob" && typeof record6.mimeType === "string" && record6.mimeType.startsWith("image/")) return [];
|
|
26293
|
+
const sanitized = sanitizeToolLogValue(entry, budget, depth + 1);
|
|
26294
|
+
return sanitized === void 0 ? [] : [[key, sanitized]];
|
|
26295
|
+
}));
|
|
26296
|
+
}
|
|
26297
|
+
function sanitizeAcpToolMessage(message2) {
|
|
26298
|
+
const m3 = message2;
|
|
26299
|
+
const isToolUpdate = m3?.method === "session/update" && ["tool_call", "tool_call_update"].includes(m3?.params?.update?.sessionUpdate);
|
|
26300
|
+
const isPermission = m3?.method === "session/request_permission";
|
|
26301
|
+
if (!isToolUpdate && !isPermission) return message2;
|
|
26302
|
+
return sanitizeToolLogValue(message2, { nodes: 512, text: TOOL_LOG_TEXT_LIMIT });
|
|
26303
|
+
}
|
|
26304
|
+
var TOOL_LOG_TEXT_LIMIT;
|
|
26305
|
+
var init_tool_log = __esm({
|
|
26306
|
+
"server/drivers/acp/tool-log.ts"() {
|
|
26307
|
+
"use strict";
|
|
26308
|
+
TOOL_LOG_TEXT_LIMIT = 64e3;
|
|
26309
|
+
}
|
|
26310
|
+
});
|
|
26311
|
+
|
|
26312
|
+
// shared/approval-readback.ts
|
|
26313
|
+
function compareEffectiveMode(ladder, requested, reported) {
|
|
26314
|
+
const want = text3(requested);
|
|
26315
|
+
const got = text3(reported);
|
|
26316
|
+
const ranks = MODE_LADDERS[ladder];
|
|
26317
|
+
if (want === null || got === null) return { status: "unverified", requested: want, reported: got };
|
|
26318
|
+
const wantRank = ranks?.[want];
|
|
26319
|
+
const gotRank = ranks?.[got];
|
|
26320
|
+
if (wantRank === void 0 || gotRank === void 0) {
|
|
26321
|
+
return { status: want === got ? "ok" : "unverified", requested: want, reported: got };
|
|
26322
|
+
}
|
|
26323
|
+
return { status: gotRank < wantRank ? "looser" : "ok", requested: want, reported: got };
|
|
26324
|
+
}
|
|
26325
|
+
function looserModeMessage(engine, readback) {
|
|
26326
|
+
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.`;
|
|
26327
|
+
}
|
|
26328
|
+
function assertEffectiveModeNotLooser(engine, ladder, requested, reported) {
|
|
26329
|
+
const readback = compareEffectiveMode(ladder, requested, reported);
|
|
26330
|
+
if (readback.status === "looser") {
|
|
26331
|
+
throw Object.assign(new Error(looserModeMessage(engine, readback)), { code: "APPROVAL_MODE_LOOSER", readback });
|
|
26332
|
+
}
|
|
26333
|
+
return readback;
|
|
26334
|
+
}
|
|
26335
|
+
var MODE_LADDERS, text3;
|
|
26336
|
+
var init_approval_readback = __esm({
|
|
26337
|
+
"shared/approval-readback.ts"() {
|
|
26338
|
+
"use strict";
|
|
26339
|
+
MODE_LADDERS = {
|
|
26340
|
+
kimiAgent: { plan: 4, default: 3, yolo: 1, auto: 0 },
|
|
26341
|
+
droidAgent: { spec: 4, normal: 3, "auto-low": 2, "auto-medium": 1, "auto-high": 0 },
|
|
26342
|
+
vibeAgent: { plan: 4, ask: 3, "accept-edits": 2, "smart-approve": 1, "auto-approve": 0 },
|
|
26343
|
+
qwenAgent: { plan: 4, default: 3, "auto-edit": 2, autoEdit: 2, auto: 1, yolo: 0 },
|
|
26344
|
+
geminiAgent: { plan: 4, default: 3, autoEdit: 2, auto_edit: 2, "auto-edit": 2, yolo: 0 }
|
|
26345
|
+
};
|
|
26346
|
+
text3 = (value) => typeof value === "string" && value.trim() ? value.trim() : null;
|
|
26347
|
+
}
|
|
26348
|
+
});
|
|
26349
|
+
|
|
26350
|
+
// server/drivers/acp/mode-readback.ts
|
|
26351
|
+
function noteModeReport(session, result) {
|
|
26352
|
+
const id = result?.modes?.currentModeId;
|
|
26353
|
+
if (typeof id === "string" && id) stateOf(session).reported = id;
|
|
26354
|
+
}
|
|
26355
|
+
function noteModeUpdate(session, raw) {
|
|
26356
|
+
const params = raw;
|
|
26357
|
+
if (params?.update?.sessionUpdate !== "current_mode_update") return false;
|
|
26358
|
+
if (session.sessionId && params.sessionId === session.sessionId && typeof params.update.currentModeId === "string") {
|
|
26359
|
+
const state2 = stateOf(session);
|
|
26360
|
+
state2.reported = params.update.currentModeId;
|
|
26361
|
+
state2.onReported?.();
|
|
26362
|
+
}
|
|
26363
|
+
return true;
|
|
26364
|
+
}
|
|
26365
|
+
function forgetStaleModeReport(session, support12) {
|
|
26366
|
+
if (support12.approvalModeReadback?.setsModeOverWire) stateOf(session).reported = null;
|
|
26367
|
+
}
|
|
26368
|
+
function approvalReadbackFor(support12, config2, turn, reported) {
|
|
26369
|
+
const rules = support12.approvalModeReadback;
|
|
26370
|
+
if (!rules) return { status: "unverified", requested: null, reported };
|
|
26371
|
+
return compareEffectiveMode(rules.ladder, rules.expected(config2, turn), reported);
|
|
26372
|
+
}
|
|
26373
|
+
function armModeReadback(input) {
|
|
26374
|
+
const { support: support12, session, config: config2, turn } = input;
|
|
26375
|
+
const state2 = stateOf(session);
|
|
26376
|
+
const now = approvalReadbackFor(support12, config2, turn, state2.reported);
|
|
26377
|
+
if (now.status === "looser") throw new Error(looserModeMessage(support12.displayName, now));
|
|
26378
|
+
if (now.status === "unverified") input.log(now);
|
|
26379
|
+
state2.onReported = () => {
|
|
26380
|
+
if (!input.isCurrent()) return;
|
|
26381
|
+
const later = approvalReadbackFor(support12, config2, turn, state2.reported);
|
|
26382
|
+
input.log(later);
|
|
26383
|
+
if (later.status === "looser") input.stop(looserModeMessage(support12.displayName, later));
|
|
26384
|
+
};
|
|
26385
|
+
}
|
|
26386
|
+
var states, stateOf;
|
|
26387
|
+
var init_mode_readback = __esm({
|
|
26388
|
+
"server/drivers/acp/mode-readback.ts"() {
|
|
26389
|
+
"use strict";
|
|
26390
|
+
init_approval_readback();
|
|
26391
|
+
states = /* @__PURE__ */ new WeakMap();
|
|
26392
|
+
stateOf = (session) => {
|
|
26393
|
+
let state2 = states.get(session);
|
|
26394
|
+
if (!state2) states.set(session, state2 = { reported: null });
|
|
26395
|
+
return state2;
|
|
26396
|
+
};
|
|
26397
|
+
}
|
|
26398
|
+
});
|
|
26399
|
+
|
|
26267
26400
|
// server/drivers/acp/core.ts
|
|
26268
26401
|
import { homedir as homedir7 } from "node:os";
|
|
26269
26402
|
import { lstat, mkdir as mkdir3, readFile, realpath, stat as stat2, writeFile } from "node:fs/promises";
|
|
@@ -26340,37 +26473,6 @@ async function readAcpImageBlocks(images) {
|
|
|
26340
26473
|
mimeType: image.mime
|
|
26341
26474
|
})));
|
|
26342
26475
|
}
|
|
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
26476
|
function decodeAcpConfig(defaultCli) {
|
|
26375
26477
|
return (raw) => {
|
|
26376
26478
|
const o = raw ?? {};
|
|
@@ -26818,6 +26920,7 @@ function createAcpDriver(support12) {
|
|
|
26818
26920
|
if (current && !current.state.settled && session.sessionId && p3.sessionId === session.sessionId) current.receiveModelVariants(p3.update);
|
|
26819
26921
|
return;
|
|
26820
26922
|
}
|
|
26923
|
+
if (noteModeUpdate(session, p3)) return;
|
|
26821
26924
|
if (!current || !current.state.promptSent) return;
|
|
26822
26925
|
const u5 = p3.update ?? {};
|
|
26823
26926
|
switch (u5.sessionUpdate) {
|
|
@@ -27082,11 +27185,11 @@ function createAcpDriver(support12) {
|
|
|
27082
27185
|
return option;
|
|
27083
27186
|
};
|
|
27084
27187
|
const flushAssistantText = () => {
|
|
27085
|
-
const
|
|
27188
|
+
const text5 = state2.text;
|
|
27086
27189
|
state2.text = "";
|
|
27087
|
-
if (!
|
|
27190
|
+
if (!text5.trim()) return;
|
|
27088
27191
|
state2.producedItem = true;
|
|
27089
|
-
emit({ ...base2(threadId, turnId), type: "item.completed", itemType: "assistant_text", text:
|
|
27192
|
+
emit({ ...base2(threadId, turnId), type: "item.completed", itemType: "assistant_text", text: text5 });
|
|
27090
27193
|
};
|
|
27091
27194
|
const current = {
|
|
27092
27195
|
turnId,
|
|
@@ -27184,6 +27287,7 @@ function createAcpDriver(support12) {
|
|
|
27184
27287
|
loaded = true;
|
|
27185
27288
|
session.sessionId = cursor3;
|
|
27186
27289
|
session.sessionKey = sessionKey;
|
|
27290
|
+
noteModeReport(session, result2);
|
|
27187
27291
|
receiveModelVariants(result2);
|
|
27188
27292
|
}
|
|
27189
27293
|
}
|
|
@@ -27220,6 +27324,7 @@ function createAcpDriver(support12) {
|
|
|
27220
27324
|
sessionResult = await request("session/new", { cwd, mcpServers: sessionServers }, NEW_SESSION_TIMEOUT, (result2) => {
|
|
27221
27325
|
session.sessionId = typeof result2?.sessionId === "string" ? result2.sessionId : null;
|
|
27222
27326
|
session.sessionKey = sessionKey;
|
|
27327
|
+
noteModeReport(session, result2);
|
|
27223
27328
|
receiveModelVariants(result2);
|
|
27224
27329
|
});
|
|
27225
27330
|
break;
|
|
@@ -27259,6 +27364,7 @@ function createAcpDriver(support12) {
|
|
|
27259
27364
|
}
|
|
27260
27365
|
}
|
|
27261
27366
|
if (support12.configureSession) {
|
|
27367
|
+
forgetStaleModeReport(session, support12);
|
|
27262
27368
|
const sessionModels = Array.isArray(sessionResult?.models?.availableModels) ? sessionResult.models.availableModels : [];
|
|
27263
27369
|
const configure = (model) => support12.configureSession({
|
|
27264
27370
|
request: (method, params, timeoutMs) => request(method, params, timeoutMs ?? SESSION_CONFIG_TIMEOUT),
|
|
@@ -27314,7 +27420,7 @@ function createAcpDriver(support12) {
|
|
|
27314
27420
|
}
|
|
27315
27421
|
emitSessionStarted();
|
|
27316
27422
|
const instructed = promptWithInstructions(threadId, sessionId, createdNativeSession, promptTurn);
|
|
27317
|
-
const
|
|
27423
|
+
const text5 = support12.buildPromptText ? support12.buildPromptText(instructed) : instructed.system ? `${instructed.system}
|
|
27318
27424
|
|
|
27319
27425
|
${instructed.text}` : instructed.text;
|
|
27320
27426
|
const imageBlocks = support12.images === true && runtimeAcceptsImages ? await readAcpImageBlocks(turn.images ?? []) : [];
|
|
@@ -27324,11 +27430,23 @@ ${instructed.text}` : instructed.text;
|
|
|
27324
27430
|
if (turn.variant !== void 0 && requestedVariantOption().currentValue !== turn.variant) {
|
|
27325
27431
|
throw new Error(`${support12.displayName} changed variant before the prompt`);
|
|
27326
27432
|
}
|
|
27433
|
+
armModeReadback({
|
|
27434
|
+
support: support12,
|
|
27435
|
+
session,
|
|
27436
|
+
config: turnConfig,
|
|
27437
|
+
turn: cliTurn,
|
|
27438
|
+
isCurrent: () => session.current === current && !current.state.settled,
|
|
27439
|
+
log: (readback) => appendNative(threadId, { dir: "out", source: SOURCE, msg: { approvalReadback: readback } }),
|
|
27440
|
+
stop: (message2) => {
|
|
27441
|
+
emit({ ...base2(threadId, turnId), type: "runtime.error", message: message2 });
|
|
27442
|
+
interrupt();
|
|
27443
|
+
}
|
|
27444
|
+
});
|
|
27327
27445
|
state2.promptSent = true;
|
|
27328
27446
|
const promptIdleMs = promptIdleTimeoutMs(support12, cliTurn.model);
|
|
27329
27447
|
const result = await request(
|
|
27330
27448
|
"session/prompt",
|
|
27331
|
-
{ sessionId, prompt: [{ type: "text", text:
|
|
27449
|
+
{ sessionId, prompt: [{ type: "text", text: text5 }, ...imageBlocks] },
|
|
27332
27450
|
void 0,
|
|
27333
27451
|
void 0,
|
|
27334
27452
|
promptIdleMs,
|
|
@@ -27450,7 +27568,7 @@ ${instructed.text}` : instructed.text;
|
|
|
27450
27568
|
}
|
|
27451
27569
|
};
|
|
27452
27570
|
}
|
|
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
|
|
27571
|
+
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
27572
|
var init_core3 = __esm({
|
|
27455
27573
|
"server/drivers/acp/core.ts"() {
|
|
27456
27574
|
"use strict";
|
|
@@ -27472,6 +27590,8 @@ var init_core3 = __esm({
|
|
|
27472
27590
|
init_engine_failure();
|
|
27473
27591
|
init_turn_mcp();
|
|
27474
27592
|
init_volatile_notes();
|
|
27593
|
+
init_tool_log();
|
|
27594
|
+
init_mode_readback();
|
|
27475
27595
|
envOr = (key, fallback) => Number(process.env[key] ?? fallback);
|
|
27476
27596
|
INIT_TIMEOUT = envOr("OPENMAUS_ACP_INIT_TIMEOUT_MS", 3e5);
|
|
27477
27597
|
SESSION_CONFIG_TIMEOUT = envOr("OPENMAUS_ACP_SESSION_CONFIG_TIMEOUT_MS", 3e5);
|
|
@@ -27497,7 +27617,6 @@ var init_core3 = __esm({
|
|
|
27497
27617
|
return Number.isFinite(ms2) && ms2 > 0 ? ms2 : 60 * 6e4;
|
|
27498
27618
|
};
|
|
27499
27619
|
CLIENT_FILE_MAX_BYTES = 8 * 1024 * 1024;
|
|
27500
|
-
TOOL_LOG_TEXT_LIMIT = 64e3;
|
|
27501
27620
|
}
|
|
27502
27621
|
});
|
|
27503
27622
|
|
|
@@ -27611,11 +27730,11 @@ function validateAntigravityCallbackUrl(pending, callbackUrl) {
|
|
|
27611
27730
|
throw new Error("Paste the complete redirect URL from Google.");
|
|
27612
27731
|
}
|
|
27613
27732
|
const expected = new URL(pending.redirectUri);
|
|
27614
|
-
const
|
|
27733
|
+
const states2 = callback.searchParams.getAll("state");
|
|
27615
27734
|
const codes = callback.searchParams.getAll("code");
|
|
27616
27735
|
const errors = callback.searchParams.getAll("error");
|
|
27617
27736
|
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 ||
|
|
27737
|
+
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
27738
|
return callback;
|
|
27620
27739
|
}
|
|
27621
27740
|
function forwardAntigravityCallback(callback) {
|
|
@@ -28772,14 +28891,14 @@ var init_boxagent = __esm({
|
|
|
28772
28891
|
let pendingText = "";
|
|
28773
28892
|
let problem = null;
|
|
28774
28893
|
const flushAssistantText = () => {
|
|
28775
|
-
const
|
|
28894
|
+
const text5 = pendingText;
|
|
28776
28895
|
pendingText = "";
|
|
28777
|
-
if (!
|
|
28778
|
-
emit({ ...base2(threadId, turnId), type: "item.completed", itemType: "assistant_text", text:
|
|
28896
|
+
if (!text5.trim()) return;
|
|
28897
|
+
emit({ ...base2(threadId, turnId), type: "item.completed", itemType: "assistant_text", text: text5 });
|
|
28779
28898
|
};
|
|
28780
|
-
const ingest = (
|
|
28781
|
-
const delta =
|
|
28782
|
-
lastText =
|
|
28899
|
+
const ingest = (text5) => {
|
|
28900
|
+
const delta = text5.startsWith(lastText) ? text5.slice(lastText.length) : text5;
|
|
28901
|
+
lastText = text5;
|
|
28783
28902
|
if (!delta) return;
|
|
28784
28903
|
pendingText += delta;
|
|
28785
28904
|
emit({ ...base2(threadId, turnId), type: "content.delta", streamKind: "assistant_text", delta });
|
|
@@ -28797,9 +28916,9 @@ var init_boxagent = __esm({
|
|
|
28797
28916
|
seen.add(id);
|
|
28798
28917
|
appendNative(threadId, { dir: "in", source: "box.events", msg: ev });
|
|
28799
28918
|
const kind = String(ev.type ?? ev.kind ?? "");
|
|
28800
|
-
const
|
|
28801
|
-
if (/assistant|message|output|response/i.test(kind) && typeof
|
|
28802
|
-
ingest(
|
|
28919
|
+
const text5 = ev.text ?? ev.message ?? ev.data?.text ?? ev.data?.content ?? null;
|
|
28920
|
+
if (/assistant|message|output|response/i.test(kind) && typeof text5 === "string" && text5.trim()) {
|
|
28921
|
+
ingest(text5);
|
|
28803
28922
|
} else if (/usage_limit|error|fail/i.test(kind)) {
|
|
28804
28923
|
const why = ev.data?.summary ?? ev.data?.message ?? ev.data?.error ?? ev.message;
|
|
28805
28924
|
if (typeof why === "string" && why.trim()) problem = why.trim();
|
|
@@ -29418,8 +29537,8 @@ var init_rtk_rewrite = __esm({
|
|
|
29418
29537
|
|
|
29419
29538
|
// server/drivers/claude-stdin.ts
|
|
29420
29539
|
import { readFileSync as readFileSync9 } from "node:fs";
|
|
29421
|
-
function claudeUserMessage(
|
|
29422
|
-
if (!images?.length) return { type: "user", message: { role: "user", content:
|
|
29540
|
+
function claudeUserMessage(text5, images) {
|
|
29541
|
+
if (!images?.length) return { type: "user", message: { role: "user", content: text5 } };
|
|
29423
29542
|
const content = images.map((image) => ({
|
|
29424
29543
|
type: "image",
|
|
29425
29544
|
source: {
|
|
@@ -29428,7 +29547,7 @@ function claudeUserMessage(text4, images) {
|
|
|
29428
29547
|
data: readFileSync9(image.path).toString("base64")
|
|
29429
29548
|
}
|
|
29430
29549
|
}));
|
|
29431
|
-
if (
|
|
29550
|
+
if (text5) content.push({ type: "text", text: text5 });
|
|
29432
29551
|
return { type: "user", message: { role: "user", content } };
|
|
29433
29552
|
}
|
|
29434
29553
|
function diagnosticClaudeUserMessage(message2) {
|
|
@@ -29468,9 +29587,9 @@ function isControl(char) {
|
|
|
29468
29587
|
}
|
|
29469
29588
|
function oneLine(value) {
|
|
29470
29589
|
if (typeof value !== "string") return null;
|
|
29471
|
-
const
|
|
29472
|
-
if (!
|
|
29473
|
-
return
|
|
29590
|
+
const text5 = Array.from(value, (char) => isControl(char) ? " " : char).join("").replace(/\s+/g, " ").trim();
|
|
29591
|
+
if (!text5) return null;
|
|
29592
|
+
return text5.length > MAX_MESSAGE ? `${text5.slice(0, MAX_MESSAGE - 1)}\u2026` : text5;
|
|
29474
29593
|
}
|
|
29475
29594
|
function yesValue(field) {
|
|
29476
29595
|
if (field.type === "boolean") return true;
|
|
@@ -29588,7 +29707,7 @@ var init_claude_elicitation = __esm({
|
|
|
29588
29707
|
});
|
|
29589
29708
|
|
|
29590
29709
|
// shared/ask-question.ts
|
|
29591
|
-
function
|
|
29710
|
+
function text4(value, limit) {
|
|
29592
29711
|
if (typeof value !== "string") return void 0;
|
|
29593
29712
|
const trimmed = value.trim();
|
|
29594
29713
|
return trimmed ? trimmed.slice(0, limit) : void 0;
|
|
@@ -29598,18 +29717,18 @@ function isRecord3(value) {
|
|
|
29598
29717
|
}
|
|
29599
29718
|
function parseOption(value) {
|
|
29600
29719
|
if (typeof value === "string") {
|
|
29601
|
-
const label2 =
|
|
29720
|
+
const label2 = text4(value, MAX_LABEL);
|
|
29602
29721
|
return label2 ? { label: label2 } : null;
|
|
29603
29722
|
}
|
|
29604
29723
|
if (!isRecord3(value)) return null;
|
|
29605
|
-
const label =
|
|
29724
|
+
const label = text4(value.label, MAX_LABEL);
|
|
29606
29725
|
if (!label) return null;
|
|
29607
|
-
const description =
|
|
29726
|
+
const description = text4(value.description, MAX_DESCRIPTION);
|
|
29608
29727
|
return description ? { label, description } : { label };
|
|
29609
29728
|
}
|
|
29610
29729
|
function parseQuestion(value) {
|
|
29611
29730
|
if (!isRecord3(value)) return null;
|
|
29612
|
-
const question =
|
|
29731
|
+
const question = text4(value.question, MAX_QUESTION_TEXT);
|
|
29613
29732
|
if (!question) return null;
|
|
29614
29733
|
const options = [];
|
|
29615
29734
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -29620,7 +29739,7 @@ function parseQuestion(value) {
|
|
|
29620
29739
|
options.push(option);
|
|
29621
29740
|
if (options.length === MAX_OPTIONS) break;
|
|
29622
29741
|
}
|
|
29623
|
-
const header =
|
|
29742
|
+
const header = text4(value.header, MAX_LABEL);
|
|
29624
29743
|
return {
|
|
29625
29744
|
question,
|
|
29626
29745
|
...header ? { header } : {},
|
|
@@ -29649,7 +29768,7 @@ function parseChoices(input, limit = MAX_CHOICES) {
|
|
|
29649
29768
|
const choices = [];
|
|
29650
29769
|
const seen = /* @__PURE__ */ new Set();
|
|
29651
29770
|
for (const raw of input) {
|
|
29652
|
-
const label = typeof raw === "string" ?
|
|
29771
|
+
const label = typeof raw === "string" ? text4(raw, MAX_LABEL) : isRecord3(raw) ? text4(raw.label, MAX_LABEL) : void 0;
|
|
29653
29772
|
if (!label || seen.has(label)) continue;
|
|
29654
29773
|
seen.add(label);
|
|
29655
29774
|
choices.push(label);
|
|
@@ -29706,19 +29825,19 @@ function resolveClaudeConfigDir(configDir2, env = process.env) {
|
|
|
29706
29825
|
}
|
|
29707
29826
|
return normalize(expanded);
|
|
29708
29827
|
}
|
|
29709
|
-
function claudeAuthFailure(frame,
|
|
29828
|
+
function claudeAuthFailure(frame, text5) {
|
|
29710
29829
|
if (frame.is_api_error_message !== true && typeof frame.error !== "string") return false;
|
|
29711
|
-
return frame.error === "authentication_failed" || classifyError({ text:
|
|
29830
|
+
return frame.error === "authentication_failed" || classifyError({ text: text5 }).reason === "auth_failed";
|
|
29712
29831
|
}
|
|
29713
|
-
function claudeCredentialRefreshConflict(frame,
|
|
29832
|
+
function claudeCredentialRefreshConflict(frame, text5) {
|
|
29714
29833
|
if (frame.is_api_error_message !== true && typeof frame.error !== "string") return false;
|
|
29715
|
-
return CREDENTIAL_REFRESH_CONFLICT.test(
|
|
29834
|
+
return CREDENTIAL_REFRESH_CONFLICT.test(text5);
|
|
29716
29835
|
}
|
|
29717
29836
|
function claudeResultStopReason(o) {
|
|
29718
|
-
const
|
|
29719
|
-
if (o.is_error !== true) return
|
|
29720
|
-
const subtype =
|
|
29721
|
-
return
|
|
29837
|
+
const text5 = (value) => typeof value === "string" && value.trim() ? value.trim() : null;
|
|
29838
|
+
if (o.is_error !== true) return text5(o.stop_reason) ?? text5(o.terminal_reason);
|
|
29839
|
+
const subtype = text5(o.subtype);
|
|
29840
|
+
return text5(o.terminal_reason) ?? (subtype && subtype !== "success" ? subtype : null) ?? "error";
|
|
29722
29841
|
}
|
|
29723
29842
|
function claudeEnvironment(model, source2 = process.env, configDir2, instanceEnvironment = {}) {
|
|
29724
29843
|
const env = { ...source2, PATH: augmentedPath(), NPM_CONFIG_LOGLEVEL: "error" };
|
|
@@ -30898,24 +31017,24 @@ var init_claude = __esm({
|
|
|
30898
31017
|
level: typeof msg.model === "string" ? "response-reported" : "unknown"
|
|
30899
31018
|
});
|
|
30900
31019
|
}
|
|
30901
|
-
const
|
|
30902
|
-
if (claudeAuthFailure(o,
|
|
31020
|
+
const text5 = firstText(msg.content);
|
|
31021
|
+
if (claudeAuthFailure(o, text5)) {
|
|
30903
31022
|
if (session.turn) session.turn.authFailed = true;
|
|
30904
|
-
emit({ ...base2(threadId, currentTurnId()), type: "runtime.error", message:
|
|
31023
|
+
emit({ ...base2(threadId, currentTurnId()), type: "runtime.error", message: text5, setup: true, failure: "auth_failed" });
|
|
30905
31024
|
break;
|
|
30906
31025
|
}
|
|
30907
|
-
if (claudeCredentialRefreshConflict(o,
|
|
30908
|
-
if (session.turn) session.turn.refreshConflict =
|
|
31026
|
+
if (claudeCredentialRefreshConflict(o, text5)) {
|
|
31027
|
+
if (session.turn) session.turn.refreshConflict = text5.trim();
|
|
30909
31028
|
break;
|
|
30910
31029
|
}
|
|
30911
|
-
if (
|
|
30912
|
-
if (
|
|
31030
|
+
if (text5.trim() && o.is_api_error_message !== true && typeof o.error !== "string" && session.turn) session.turn.produced = true;
|
|
31031
|
+
if (text5.trim()) {
|
|
30913
31032
|
const synthetic = o.is_api_error_message === true || typeof o.error === "string" ? { synthetic: true } : {};
|
|
30914
31033
|
if (!session.turn?.sawStreamDelta) {
|
|
30915
|
-
emit({ ...base2(threadId, currentTurnId()), ...synthetic, type: "content.delta", streamKind: "assistant_text", delta:
|
|
31034
|
+
emit({ ...base2(threadId, currentTurnId()), ...synthetic, type: "content.delta", streamKind: "assistant_text", delta: text5 });
|
|
30916
31035
|
}
|
|
30917
31036
|
if (session.turn) session.turn.sawStreamDelta = false;
|
|
30918
|
-
emit({ ...base2(threadId, currentTurnId()), ...synthetic, type: "item.completed", itemType: "assistant_text", text:
|
|
31037
|
+
emit({ ...base2(threadId, currentTurnId()), ...synthetic, type: "item.completed", itemType: "assistant_text", text: text5 });
|
|
30919
31038
|
}
|
|
30920
31039
|
for (const b3 of Array.isArray(msg.content) ? msg.content : []) {
|
|
30921
31040
|
if (b3.type === "tool_use") {
|
|
@@ -31166,12 +31285,12 @@ var init_claude = __esm({
|
|
|
31166
31285
|
}
|
|
31167
31286
|
return { turnId };
|
|
31168
31287
|
};
|
|
31169
|
-
const steer = async (threadId,
|
|
31288
|
+
const steer = async (threadId, text5) => {
|
|
31170
31289
|
const s4 = sessions.get(threadId);
|
|
31171
31290
|
if (!s4 || !s4.turn || s4.turn.settled || s4.closing || s4.child.exitCode !== null) return "refused";
|
|
31172
31291
|
const turn = s4.turn;
|
|
31173
31292
|
turn.pendingSteers = (turn.pendingSteers ?? 0) + 1;
|
|
31174
|
-
if (await writeUser(s4, threadId, claudeUserMessage(
|
|
31293
|
+
if (await writeUser(s4, threadId, claudeUserMessage(text5, void 0))) return "steered";
|
|
31175
31294
|
turn.pendingSteers = Math.max(0, turn.pendingSteers - 1);
|
|
31176
31295
|
return "refused";
|
|
31177
31296
|
};
|
|
@@ -31406,42 +31525,42 @@ var init_codex_tool_surface = __esm({
|
|
|
31406
31525
|
});
|
|
31407
31526
|
|
|
31408
31527
|
// server/toml-lite.ts
|
|
31409
|
-
function parseTomlLite(
|
|
31528
|
+
function parseTomlLite(text5) {
|
|
31410
31529
|
const root = {};
|
|
31411
31530
|
let current = root;
|
|
31412
31531
|
let pos = 0;
|
|
31413
|
-
const peek = () =>
|
|
31532
|
+
const peek = () => text5[pos];
|
|
31414
31533
|
const skipSpaces = () => {
|
|
31415
|
-
while (pos <
|
|
31534
|
+
while (pos < text5.length && (text5[pos] === " " || text5[pos] === " ")) pos += 1;
|
|
31416
31535
|
};
|
|
31417
31536
|
const skipComment = () => {
|
|
31418
|
-
if (
|
|
31537
|
+
if (text5[pos] === "#") while (pos < text5.length && text5[pos] !== "\n") pos += 1;
|
|
31419
31538
|
};
|
|
31420
31539
|
const skipBlank = () => {
|
|
31421
31540
|
for (; ; ) {
|
|
31422
31541
|
const before = pos;
|
|
31423
|
-
while (pos <
|
|
31542
|
+
while (pos < text5.length && /[ \t\r\n]/.test(text5[pos])) pos += 1;
|
|
31424
31543
|
skipComment();
|
|
31425
31544
|
if (pos === before) return;
|
|
31426
31545
|
}
|
|
31427
31546
|
};
|
|
31428
31547
|
const skipLine = () => {
|
|
31429
|
-
while (pos <
|
|
31548
|
+
while (pos < text5.length && text5[pos] !== "\n") pos += 1;
|
|
31430
31549
|
};
|
|
31431
31550
|
const basicString = () => {
|
|
31432
|
-
const multi =
|
|
31551
|
+
const multi = text5.startsWith('"""', pos);
|
|
31433
31552
|
pos += multi ? 3 : 1;
|
|
31434
|
-
if (multi &&
|
|
31553
|
+
if (multi && text5[pos] === "\n") pos += 1;
|
|
31435
31554
|
let out = "";
|
|
31436
|
-
while (pos <
|
|
31437
|
-
if (multi ?
|
|
31555
|
+
while (pos < text5.length) {
|
|
31556
|
+
if (multi ? text5.startsWith('"""', pos) : text5[pos] === '"') {
|
|
31438
31557
|
pos += multi ? 3 : 1;
|
|
31439
31558
|
return out;
|
|
31440
31559
|
}
|
|
31441
|
-
const ch =
|
|
31560
|
+
const ch = text5[pos];
|
|
31442
31561
|
if (!multi && ch === "\n") throw new TomlError("unterminated string");
|
|
31443
31562
|
if (ch === "\\") {
|
|
31444
|
-
const next =
|
|
31563
|
+
const next = text5[pos + 1];
|
|
31445
31564
|
pos += 2;
|
|
31446
31565
|
if (next === "n") out += "\n";
|
|
31447
31566
|
else if (next === "t") out += " ";
|
|
@@ -31449,10 +31568,10 @@ function parseTomlLite(text4) {
|
|
|
31449
31568
|
else if (next === '"' || next === "\\") out += next;
|
|
31450
31569
|
else if (next === "u" || next === "U") {
|
|
31451
31570
|
const length = next === "u" ? 4 : 8;
|
|
31452
|
-
out += String.fromCodePoint(parseInt(
|
|
31571
|
+
out += String.fromCodePoint(parseInt(text5.slice(pos, pos + length), 16));
|
|
31453
31572
|
pos += length;
|
|
31454
31573
|
} else if (multi && next === "\n") {
|
|
31455
|
-
while (pos <
|
|
31574
|
+
while (pos < text5.length && /[ \t\r\n]/.test(text5[pos])) pos += 1;
|
|
31456
31575
|
} else out += next ?? "";
|
|
31457
31576
|
continue;
|
|
31458
31577
|
}
|
|
@@ -31462,12 +31581,12 @@ function parseTomlLite(text4) {
|
|
|
31462
31581
|
throw new TomlError("unterminated string");
|
|
31463
31582
|
};
|
|
31464
31583
|
const literalString = () => {
|
|
31465
|
-
const multi =
|
|
31584
|
+
const multi = text5.startsWith("'''", pos);
|
|
31466
31585
|
pos += multi ? 3 : 1;
|
|
31467
|
-
if (multi &&
|
|
31468
|
-
const end =
|
|
31586
|
+
if (multi && text5[pos] === "\n") pos += 1;
|
|
31587
|
+
const end = text5.indexOf(multi ? "'''" : "'", pos);
|
|
31469
31588
|
if (end < 0) throw new TomlError("unterminated string");
|
|
31470
|
-
const value2 =
|
|
31589
|
+
const value2 = text5.slice(pos, end);
|
|
31471
31590
|
if (!multi && value2.includes("\n")) throw new TomlError("unterminated string");
|
|
31472
31591
|
pos = end + (multi ? 3 : 1);
|
|
31473
31592
|
return value2;
|
|
@@ -31477,9 +31596,9 @@ function parseTomlLite(text4) {
|
|
|
31477
31596
|
if (peek() === '"') return basicString();
|
|
31478
31597
|
if (peek() === "'") return literalString();
|
|
31479
31598
|
const start = pos;
|
|
31480
|
-
while (pos <
|
|
31599
|
+
while (pos < text5.length && /[A-Za-z0-9_-]/.test(text5[pos])) pos += 1;
|
|
31481
31600
|
if (pos === start) throw new TomlError("expected a key");
|
|
31482
|
-
return
|
|
31601
|
+
return text5.slice(start, pos);
|
|
31483
31602
|
};
|
|
31484
31603
|
const keyPath = () => {
|
|
31485
31604
|
const parts = [key()];
|
|
@@ -31531,8 +31650,8 @@ function parseTomlLite(text4) {
|
|
|
31531
31650
|
}
|
|
31532
31651
|
}
|
|
31533
31652
|
const start = pos;
|
|
31534
|
-
while (pos <
|
|
31535
|
-
const raw =
|
|
31653
|
+
while (pos < text5.length && !/[,\]}\r\n#]/.test(text5[pos])) pos += 1;
|
|
31654
|
+
const raw = text5.slice(start, pos).trim();
|
|
31536
31655
|
if (raw === "true") return true;
|
|
31537
31656
|
if (raw === "false") return false;
|
|
31538
31657
|
const number5 = Number(raw.replace(/_/g, ""));
|
|
@@ -31557,12 +31676,12 @@ function parseTomlLite(text4) {
|
|
|
31557
31676
|
const parent = tableAt(base2, path4.slice(0, -1));
|
|
31558
31677
|
parent[path4[path4.length - 1]] = item;
|
|
31559
31678
|
}
|
|
31560
|
-
while (pos <
|
|
31679
|
+
while (pos < text5.length) {
|
|
31561
31680
|
skipBlank();
|
|
31562
|
-
if (pos >=
|
|
31681
|
+
if (pos >= text5.length) break;
|
|
31563
31682
|
const lineStart = pos;
|
|
31564
31683
|
try {
|
|
31565
|
-
if (
|
|
31684
|
+
if (text5.startsWith("[[", pos)) {
|
|
31566
31685
|
pos += 2;
|
|
31567
31686
|
keyPath();
|
|
31568
31687
|
current = {};
|
|
@@ -32137,7 +32256,7 @@ function unquote(raw) {
|
|
|
32137
32256
|
}
|
|
32138
32257
|
return value;
|
|
32139
32258
|
}
|
|
32140
|
-
function parseCodexToml(
|
|
32259
|
+
function parseCodexToml(text5) {
|
|
32141
32260
|
const result = { providers: [] };
|
|
32142
32261
|
const byId = /* @__PURE__ */ new Map();
|
|
32143
32262
|
let section = "root";
|
|
@@ -32150,7 +32269,7 @@ function parseCodexToml(text4) {
|
|
|
32150
32269
|
}
|
|
32151
32270
|
return provider;
|
|
32152
32271
|
};
|
|
32153
|
-
for (const line of
|
|
32272
|
+
for (const line of text5.split(/\r?\n/)) {
|
|
32154
32273
|
const stripped = line.trim();
|
|
32155
32274
|
if (!stripped || stripped.startsWith("#")) continue;
|
|
32156
32275
|
if (stripped.startsWith("[") && stripped.endsWith("]")) {
|
|
@@ -33411,14 +33530,14 @@ var init_codex = __esm({
|
|
|
33411
33530
|
emit({ ...base2(threadId, turnId), type: "runtime.error", message: "codex did not shut down after termination was requested" });
|
|
33412
33531
|
}
|
|
33413
33532
|
};
|
|
33414
|
-
const steerActiveTurn = async (
|
|
33533
|
+
const steerActiveTurn = async (text5) => {
|
|
33415
33534
|
if (state2.settled || abandoned || stopRequested || !codexThreadId || !codexTurnId) return "refused";
|
|
33416
33535
|
if (child.exitCode !== null || child.signalCode !== null) return "refused";
|
|
33417
33536
|
try {
|
|
33418
33537
|
const steerTimeoutMs = Math.max(1, Number(process.env.FAKE_CODEX_STEER_TIMEOUT_MS ?? 1e4) || 1e4);
|
|
33419
33538
|
await request("turn/steer", {
|
|
33420
33539
|
threadId: codexThreadId,
|
|
33421
|
-
input: [{ type: "text", text:
|
|
33540
|
+
input: [{ type: "text", text: text5 }],
|
|
33422
33541
|
expectedTurnId: codexTurnId
|
|
33423
33542
|
}, steerTimeoutMs);
|
|
33424
33543
|
return "steered";
|
|
@@ -34025,9 +34144,9 @@ ${status.stderr}`)) {
|
|
|
34025
34144
|
interruptTurn: async (threadId) => {
|
|
34026
34145
|
await active.get(threadId)?.stop();
|
|
34027
34146
|
},
|
|
34028
|
-
steer: async (threadId,
|
|
34147
|
+
steer: async (threadId, text5) => {
|
|
34029
34148
|
const turn = active.get(threadId);
|
|
34030
|
-
return turn?.steer ? await turn.steer(
|
|
34149
|
+
return turn?.steer ? await turn.steer(text5) : "refused";
|
|
34031
34150
|
},
|
|
34032
34151
|
respondToRequest: async (threadId, requestId, decision) => {
|
|
34033
34152
|
const turn = active.get(threadId);
|
|
@@ -38648,7 +38767,7 @@ var require_core = __commonJS({
|
|
|
38648
38767
|
errorsText(errors = this.errors, { separator = ", ", dataVar = "data" } = {}) {
|
|
38649
38768
|
if (!errors || errors.length === 0)
|
|
38650
38769
|
return "No errors";
|
|
38651
|
-
return errors.map((e) => `${dataVar}${e.instancePath} ${e.message}`).reduce((
|
|
38770
|
+
return errors.map((e) => `${dataVar}${e.instancePath} ${e.message}`).reduce((text5, msg) => text5 + separator + msg);
|
|
38652
38771
|
}
|
|
38653
38772
|
$dataMetaSchema(metaSchema, keywordsJsonPointers) {
|
|
38654
38773
|
const rules = this.RULES.all;
|
|
@@ -43134,6 +43253,7 @@ var init_chat_box_tools = __esm({
|
|
|
43134
43253
|
});
|
|
43135
43254
|
|
|
43136
43255
|
// server/drivers/chat-mcp-tools.ts
|
|
43256
|
+
import { homedir as homedir16 } from "node:os";
|
|
43137
43257
|
function object2(value) {
|
|
43138
43258
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
43139
43259
|
}
|
|
@@ -43168,7 +43288,17 @@ function boundedText(value) {
|
|
|
43168
43288
|
return `${bytes.subarray(0, end).toString()}
|
|
43169
43289
|
[MCP result truncated at 50KB; request less output.]`;
|
|
43170
43290
|
}
|
|
43171
|
-
|
|
43291
|
+
function namesBlockedPath(args, roots, home = homedir16()) {
|
|
43292
|
+
const slash = (text5) => text5.replaceAll("\\", "/").toLowerCase();
|
|
43293
|
+
const needles = roots.flatMap((root) => {
|
|
43294
|
+
const full = slash(root).replace(/\/+$/, "");
|
|
43295
|
+
const base2 = slash(home).replace(/\/+$/, "");
|
|
43296
|
+
return full.startsWith(`${base2}/`) ? [full, `~/${full.slice(base2.length + 1)}`, full.slice(base2.length + 1)] : [full];
|
|
43297
|
+
});
|
|
43298
|
+
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;
|
|
43299
|
+
return needles.length > 0 && visit3(args);
|
|
43300
|
+
}
|
|
43301
|
+
async function mountChatTools(integrations, signal, computerUse = false, report = reportMcpFailure, blockedPaths = []) {
|
|
43172
43302
|
const servers = [];
|
|
43173
43303
|
if (computerUse && integrations?.computer) servers.push(["computer", integrations.computer]);
|
|
43174
43304
|
if (computerUse && integrations?.localComputer) servers.push(["computer", integrations.localComputer]);
|
|
@@ -43286,6 +43416,9 @@ async function mountChatTools(integrations, signal, computerUse = false, report
|
|
|
43286
43416
|
if (!tool2) throw new Error("The requested tool was not advertised for this turn");
|
|
43287
43417
|
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
43418
|
if (!object2(args) || !tool2.schema(args)) throw new Error("Tool arguments do not match the advertised input schema; use its required fields and types");
|
|
43419
|
+
if (namesBlockedPath(args, blockedPaths)) {
|
|
43420
|
+
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.");
|
|
43421
|
+
}
|
|
43289
43422
|
};
|
|
43290
43423
|
return {
|
|
43291
43424
|
definitions,
|
|
@@ -43749,7 +43882,7 @@ function createOpenAIChatRuntime(options) {
|
|
|
43749
43882
|
if (!response.body) {
|
|
43750
43883
|
throw new Error(options.noBodyError ?? `${options.httpErrorLabel} returned no response body`);
|
|
43751
43884
|
}
|
|
43752
|
-
let
|
|
43885
|
+
let text5 = "";
|
|
43753
43886
|
let reasoning = "";
|
|
43754
43887
|
let protocolReasoning = "";
|
|
43755
43888
|
let usage = null;
|
|
@@ -43791,7 +43924,7 @@ function createOpenAIChatRuntime(options) {
|
|
|
43791
43924
|
onDelta?.(reasoningDelta, "reasoning_text");
|
|
43792
43925
|
}
|
|
43793
43926
|
if (contentDelta) {
|
|
43794
|
-
|
|
43927
|
+
text5 += contentDelta;
|
|
43795
43928
|
onDelta?.(contentDelta, "assistant_text");
|
|
43796
43929
|
}
|
|
43797
43930
|
if (chunk.usage) usage = usageFrom(chunk.usage);
|
|
@@ -43833,7 +43966,7 @@ function createOpenAIChatRuntime(options) {
|
|
|
43833
43966
|
}
|
|
43834
43967
|
activeSignal.throwIfAborted();
|
|
43835
43968
|
if (!sawChoice) throw new ChatProtocolError("provider returned no streaming completion choice");
|
|
43836
|
-
return { text:
|
|
43969
|
+
return { text: text5, reasoning, usage, toolCalls: calls.finish(finishReason, malformedFrame), finishReason, protocolReasoning, protocolReasoningDetails: details.blocks };
|
|
43837
43970
|
} finally {
|
|
43838
43971
|
if (idleTimer) clearTimeout(idleTimer);
|
|
43839
43972
|
}
|
|
@@ -43866,8 +43999,8 @@ function createOpenAIChatRuntime(options) {
|
|
|
43866
43999
|
}
|
|
43867
44000
|
}
|
|
43868
44001
|
}
|
|
43869
|
-
const safeText = (
|
|
43870
|
-
let safe =
|
|
44002
|
+
const safeText = (text5) => {
|
|
44003
|
+
let safe = text5;
|
|
43871
44004
|
for (const secret of secrets) if (secret) safe = safe.split(secret).join("[redacted]");
|
|
43872
44005
|
return redactSecretsInText(safe);
|
|
43873
44006
|
};
|
|
@@ -43915,7 +44048,7 @@ function createOpenAIChatRuntime(options) {
|
|
|
43915
44048
|
const denials = [];
|
|
43916
44049
|
const seenCalls = /* @__PURE__ */ new Set();
|
|
43917
44050
|
try {
|
|
43918
|
-
tools = await mountChatTools(options.tools === false ? void 0 : turn.integrations, abort.signal, options.computerUse);
|
|
44051
|
+
tools = await mountChatTools(options.tools === false ? void 0 : turn.integrations, abort.signal, options.computerUse, void 0, turn.blockedPaths);
|
|
43919
44052
|
for (let round = 0; round < 16; round++) {
|
|
43920
44053
|
abort.signal.throwIfAborted();
|
|
43921
44054
|
native("out", options.nativeLog.outgoing(turn, messages, model));
|
|
@@ -43924,8 +44057,8 @@ function createOpenAIChatRuntime(options) {
|
|
|
43924
44057
|
for (; ; ) {
|
|
43925
44058
|
let streamed = false;
|
|
43926
44059
|
const pending = { assistant_text: "", reasoning_text: "" };
|
|
43927
|
-
const delta = (
|
|
43928
|
-
let combined = pending[streamKind] +
|
|
44060
|
+
const delta = (text5, streamKind, flush = false) => {
|
|
44061
|
+
let combined = pending[streamKind] + text5;
|
|
43929
44062
|
for (const secret of secrets) if (secret) combined = combined.split(secret).join("[redacted]");
|
|
43930
44063
|
let hold = 0;
|
|
43931
44064
|
if (!flush) for (const secret of secrets) {
|
|
@@ -43944,9 +44077,9 @@ function createOpenAIChatRuntime(options) {
|
|
|
43944
44077
|
const callId = newId();
|
|
43945
44078
|
emit({ ...base2(turn.threadId, turnId), type: "model.call", callId });
|
|
43946
44079
|
let previousIdentity = "";
|
|
43947
|
-
completion = await complete(messages, model, true, abort.signal, (
|
|
44080
|
+
completion = await complete(messages, model, true, abort.signal, (text5, streamKind) => {
|
|
43948
44081
|
streamed = true;
|
|
43949
|
-
delta(
|
|
44082
|
+
delta(text5, streamKind);
|
|
43950
44083
|
}, tools.definitions, (reportedModel, responseId) => {
|
|
43951
44084
|
const identity = JSON.stringify([reportedModel, responseId]);
|
|
43952
44085
|
if (identity === previousIdentity) return;
|
|
@@ -44047,11 +44180,11 @@ function createOpenAIChatRuntime(options) {
|
|
|
44047
44180
|
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
44181
|
}
|
|
44049
44182
|
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:
|
|
44183
|
+
const text5 = safeText(result.text);
|
|
44184
|
+
const output = preview({ ok: result.ok, result: text5 });
|
|
44052
44185
|
emit({ ...base2(turn.threadId, turnId), type: "item.completed", itemType: "tool", itemId: call.id, ok: result.ok, output });
|
|
44053
44186
|
if (!result.ok) toolFailed = true;
|
|
44054
|
-
messages.push({ role: "tool", tool_call_id: call.id, content: JSON.stringify({ ok: result.ok, result:
|
|
44187
|
+
messages.push({ role: "tool", tool_call_id: call.id, content: JSON.stringify({ ok: result.ok, result: text5 }) });
|
|
44055
44188
|
screenshotParts.push(...chatToolImages(call.id, result.images));
|
|
44056
44189
|
abort.signal.throwIfAborted();
|
|
44057
44190
|
if (fatal) throw fatal;
|
|
@@ -44143,9 +44276,9 @@ function createOpenAIChatRuntime(options) {
|
|
|
44143
44276
|
},
|
|
44144
44277
|
generateText: async (prompt, { signal } = {}) => {
|
|
44145
44278
|
const model = options.generateModel?.() ?? options.models().default;
|
|
44146
|
-
const { text:
|
|
44279
|
+
const { text: text5, reasoning, toolCalls } = await complete([{ role: "user", content: prompt }], model, false, signal);
|
|
44147
44280
|
if (toolCalls.length) throw new ChatProtocolError("provider returned tool calls to a text-only helper");
|
|
44148
|
-
return
|
|
44281
|
+
return text5.trim() ? text5 : reasoning;
|
|
44149
44282
|
},
|
|
44150
44283
|
dispose: async () => {
|
|
44151
44284
|
const turns = [...active.values()];
|
|
@@ -44226,7 +44359,7 @@ var init_grok = __esm({
|
|
|
44226
44359
|
nativeLog: {
|
|
44227
44360
|
source: "xai.chat.completions",
|
|
44228
44361
|
outgoing: (_turn, messages, model) => ({ model, messages }),
|
|
44229
|
-
incoming: ({ text:
|
|
44362
|
+
incoming: ({ text: text5, usage }) => ({ text: text5, usage })
|
|
44230
44363
|
}
|
|
44231
44364
|
});
|
|
44232
44365
|
}
|
|
@@ -44236,14 +44369,14 @@ var init_grok = __esm({
|
|
|
44236
44369
|
|
|
44237
44370
|
// server/drivers/acp/grok.ts
|
|
44238
44371
|
import { existsSync as existsSync16, readFileSync as readFileSync19, writeFileSync as writeFileSync12 } from "node:fs";
|
|
44239
|
-
import { homedir as
|
|
44372
|
+
import { homedir as homedir17 } from "node:os";
|
|
44240
44373
|
import { join as join35 } from "node:path";
|
|
44241
|
-
function decodeGrokModelText(
|
|
44242
|
-
if (/\bnot authenticated\b/i.test(
|
|
44374
|
+
function decodeGrokModelText(text5) {
|
|
44375
|
+
if (/\bnot authenticated\b/i.test(text5)) return null;
|
|
44243
44376
|
const options = [];
|
|
44244
44377
|
let listed = null;
|
|
44245
44378
|
let stated = null;
|
|
44246
|
-
for (const raw of
|
|
44379
|
+
for (const raw of text5.split(/\r?\n/)) {
|
|
44247
44380
|
const line = raw.trim();
|
|
44248
44381
|
const header = /^default model:\s*(\S+)/i.exec(line);
|
|
44249
44382
|
if (header) {
|
|
@@ -44271,7 +44404,7 @@ function fetchGrokModels(cli, env, run2 = execCli) {
|
|
|
44271
44404
|
}
|
|
44272
44405
|
function grokHome(env) {
|
|
44273
44406
|
if (env.GROK_HOME) return env.GROK_HOME;
|
|
44274
|
-
return join35(env.HOME || env.USERPROFILE ||
|
|
44407
|
+
return join35(env.HOME || env.USERPROFILE || homedir17(), ".grok");
|
|
44275
44408
|
}
|
|
44276
44409
|
function unquote2(raw) {
|
|
44277
44410
|
const value = raw.trim();
|
|
@@ -44282,9 +44415,9 @@ function unquote2(raw) {
|
|
|
44282
44415
|
}
|
|
44283
44416
|
function readGrokModelCatalog(env = process.env, base2 = STATIC_GROK_MODELS) {
|
|
44284
44417
|
const path4 = join35(grokHome(env), "config.toml");
|
|
44285
|
-
let
|
|
44418
|
+
let text5 = "";
|
|
44286
44419
|
try {
|
|
44287
|
-
|
|
44420
|
+
text5 = readFileSync19(path4, "utf8");
|
|
44288
44421
|
} catch {
|
|
44289
44422
|
return base2;
|
|
44290
44423
|
}
|
|
@@ -44302,7 +44435,7 @@ function readGrokModelCatalog(env = process.env, base2 = STATIC_GROK_MODELS) {
|
|
|
44302
44435
|
options.push({ id: current.slug, label: current.name || current.slug, custom: true });
|
|
44303
44436
|
current = null;
|
|
44304
44437
|
};
|
|
44305
|
-
for (const line of
|
|
44438
|
+
for (const line of text5.split(/\r?\n/)) {
|
|
44306
44439
|
const stripped = line.trim();
|
|
44307
44440
|
if (stripped === "[models]") {
|
|
44308
44441
|
flush();
|
|
@@ -44338,8 +44471,8 @@ function readGrokModelCatalog(env = process.env, base2 = STATIC_GROK_MODELS) {
|
|
|
44338
44471
|
function classifyGrokError(error51) {
|
|
44339
44472
|
const message2 = error51 instanceof Error ? error51.message : String(error51 ?? "");
|
|
44340
44473
|
const data = error51 && typeof error51 === "object" ? error51.data : void 0;
|
|
44341
|
-
const
|
|
44342
|
-
return classifyEngineFailure(
|
|
44474
|
+
const text5 = `${message2} ${typeof data === "string" ? data : data ? JSON.stringify(data) : ""}`;
|
|
44475
|
+
return classifyEngineFailure(text5)?.kind === "usage_limited" ? "quota_or_region_restriction" : void 0;
|
|
44343
44476
|
}
|
|
44344
44477
|
function suggestGrokSlug(host, model, taken) {
|
|
44345
44478
|
let base2 = `${host}-${model}`.toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
@@ -44361,11 +44494,11 @@ function ensureGrokInjectSlug(modelId, env = process.env) {
|
|
|
44361
44494
|
const host = localHost(inject.host);
|
|
44362
44495
|
if (!host) return modelId;
|
|
44363
44496
|
const path4 = join35(grokHome(env), "config.toml");
|
|
44364
|
-
let
|
|
44497
|
+
let text5 = "";
|
|
44365
44498
|
try {
|
|
44366
|
-
|
|
44499
|
+
text5 = readFileSync19(path4, "utf8");
|
|
44367
44500
|
} catch {
|
|
44368
|
-
|
|
44501
|
+
text5 = "";
|
|
44369
44502
|
}
|
|
44370
44503
|
const taken = new Set(STATIC_GROK_MODELS.options.map((option) => option.id));
|
|
44371
44504
|
let current = null;
|
|
@@ -44378,7 +44511,7 @@ function ensureGrokInjectSlug(modelId, env = process.env) {
|
|
|
44378
44511
|
current = null;
|
|
44379
44512
|
};
|
|
44380
44513
|
let found = null;
|
|
44381
|
-
for (const line of
|
|
44514
|
+
for (const line of text5.split(/\r?\n/)) {
|
|
44382
44515
|
const stripped = line.trim();
|
|
44383
44516
|
if (stripped.startsWith("[model.") && stripped.endsWith("]")) {
|
|
44384
44517
|
flush();
|
|
@@ -44411,9 +44544,9 @@ function ensureGrokInjectSlug(modelId, env = process.env) {
|
|
|
44411
44544
|
`api_key = ${quoteToml(hostApiKey(host, env))}`,
|
|
44412
44545
|
""
|
|
44413
44546
|
].join("\n");
|
|
44414
|
-
const next =
|
|
44547
|
+
const next = text5 && !text5.endsWith("\n") ? `${text5}
|
|
44415
44548
|
|
|
44416
|
-
${block2}` : `${
|
|
44549
|
+
${block2}` : `${text5}${text5 ? "\n" : ""}${block2}`;
|
|
44417
44550
|
writeFileSync12(path4, next);
|
|
44418
44551
|
return slug;
|
|
44419
44552
|
}
|
|
@@ -44516,7 +44649,7 @@ var init_grok2 = __esm({
|
|
|
44516
44649
|
pickAuthMethod: (methods) => methods.some((m3) => m3.id === "cached_token") ? "cached_token" : null,
|
|
44517
44650
|
authFailure: "fail",
|
|
44518
44651
|
classifyError: classifyGrokError,
|
|
44519
|
-
isAuthenticated: (env) => existsSync16(env.GROK_HOME ? join35(env.GROK_HOME, "auth.json") : join35(
|
|
44652
|
+
isAuthenticated: (env) => existsSync16(env.GROK_HOME ? join35(env.GROK_HOME, "auth.json") : join35(homedir17(), ".grok", "auth.json")),
|
|
44520
44653
|
// `--append-system-prompt`/`--rules` are accepted by the CLI but do NOT
|
|
44521
44654
|
// reach the agent-stdio system prompt (verified against 1.0.0), so the
|
|
44522
44655
|
// persona is prepended codex-style.
|
|
@@ -44530,11 +44663,11 @@ ${turn.text}` : turn.text
|
|
|
44530
44663
|
|
|
44531
44664
|
// server/drivers/acp/gemini.ts
|
|
44532
44665
|
import { existsSync as existsSync17, readFileSync as readFileSync20 } from "node:fs";
|
|
44533
|
-
import { homedir as
|
|
44666
|
+
import { homedir as homedir18 } from "node:os";
|
|
44534
44667
|
import { join as join36 } from "node:path";
|
|
44535
44668
|
function liveOauthCredential() {
|
|
44536
44669
|
try {
|
|
44537
|
-
const creds = JSON.parse(readFileSync20(join36(
|
|
44670
|
+
const creds = JSON.parse(readFileSync20(join36(homedir18(), ".gemini", "oauth_creds.json"), "utf8"));
|
|
44538
44671
|
if (typeof creds.access_token !== "string" || creds.access_token.trim().length === 0) return false;
|
|
44539
44672
|
const hasRefresh = typeof creds.refresh_token === "string" && creds.refresh_token.trim().length > 0;
|
|
44540
44673
|
if (creds.expiry_date !== void 0) {
|
|
@@ -44547,13 +44680,18 @@ function liveOauthCredential() {
|
|
|
44547
44680
|
}
|
|
44548
44681
|
}
|
|
44549
44682
|
function geminiIsAuthenticated(env) {
|
|
44550
|
-
return nonBlank(env.GEMINI_API_KEY) || nonBlank(env.GOOGLE_API_KEY) || existsSync17(join36(
|
|
44683
|
+
return nonBlank(env.GEMINI_API_KEY) || nonBlank(env.GOOGLE_API_KEY) || existsSync17(join36(homedir18(), ".gemini", "oauth_creds.json")) && liveOauthCredential();
|
|
44551
44684
|
}
|
|
44552
44685
|
function geminiApprovalArgs(fullAuto, approvalMode) {
|
|
44553
44686
|
if (fullAuto) return ["--yolo"];
|
|
44554
44687
|
if (approvalMode === "edits") return ["--approval-mode", "auto_edit"];
|
|
44555
44688
|
return [];
|
|
44556
44689
|
}
|
|
44690
|
+
function geminiExpectedMode(fullAuto, approvalMode) {
|
|
44691
|
+
if (fullAuto) return "yolo";
|
|
44692
|
+
if (approvalMode === "edits") return "autoEdit";
|
|
44693
|
+
return "default";
|
|
44694
|
+
}
|
|
44557
44695
|
var AUTH_PREFERENCE, nonBlank, support3, GeminiAgentDriver;
|
|
44558
44696
|
var init_gemini = __esm({
|
|
44559
44697
|
"server/drivers/acp/gemini.ts"() {
|
|
@@ -44563,6 +44701,8 @@ var init_gemini = __esm({
|
|
|
44563
44701
|
nonBlank = (value) => Boolean(value?.trim());
|
|
44564
44702
|
support3 = {
|
|
44565
44703
|
driverKind: "geminiAgent",
|
|
44704
|
+
// Gemini takes the mode on argv; session/new reports the one it applied.
|
|
44705
|
+
approvalModeReadback: { ladder: "geminiAgent", expected: (config2, turn) => geminiExpectedMode(config2.fullAuto, turn.approvalMode) },
|
|
44566
44706
|
displayName: "Gemini",
|
|
44567
44707
|
models: {
|
|
44568
44708
|
default: "gemini-2.5-pro",
|
|
@@ -44595,13 +44735,13 @@ ${turn.text}` : turn.text
|
|
|
44595
44735
|
|
|
44596
44736
|
// server/drivers/acp/kimi.ts
|
|
44597
44737
|
import { existsSync as existsSync18, mkdirSync as mkdirSync17, readFileSync as readFileSync21, writeFileSync as writeFileSync13 } from "node:fs";
|
|
44598
|
-
import { homedir as
|
|
44738
|
+
import { homedir as homedir19 } from "node:os";
|
|
44599
44739
|
import { join as join37 } from "node:path";
|
|
44600
44740
|
function isLocalInjectAlias(slug) {
|
|
44601
44741
|
return LOCAL_PROVIDER_PREFIXES.some((prefix) => slug.startsWith(prefix));
|
|
44602
44742
|
}
|
|
44603
44743
|
function kimiDataRoot(env) {
|
|
44604
|
-
return env.KIMI_CODE_HOME || join37(env.HOME || env.USERPROFILE ||
|
|
44744
|
+
return env.KIMI_CODE_HOME || join37(env.HOME || env.USERPROFILE || homedir19(), ".kimi-code");
|
|
44605
44745
|
}
|
|
44606
44746
|
function credentialsPath(env) {
|
|
44607
44747
|
return join37(kimiDataRoot(env), "credentials", "kimi-code.json");
|
|
@@ -44630,18 +44770,18 @@ function stripTomlLineComment(line) {
|
|
|
44630
44770
|
}
|
|
44631
44771
|
return line;
|
|
44632
44772
|
}
|
|
44633
|
-
function takeTomlBasicEscape(
|
|
44634
|
-
const code =
|
|
44773
|
+
function takeTomlBasicEscape(text5, i2) {
|
|
44774
|
+
const code = text5[i2 + 1];
|
|
44635
44775
|
if (code === void 0) return { ok: false };
|
|
44636
44776
|
if (code === "u") {
|
|
44637
|
-
const hex3 =
|
|
44777
|
+
const hex3 = text5.slice(i2 + 2, i2 + 6);
|
|
44638
44778
|
if (!/^[0-9a-fA-F]{4}$/.test(hex3)) return { ok: false };
|
|
44639
44779
|
const point = parseInt(hex3, 16);
|
|
44640
44780
|
if (point >= 55296 && point <= 57343) return { ok: false };
|
|
44641
44781
|
return { ok: true, value: String.fromCharCode(point), next: i2 + 6 };
|
|
44642
44782
|
}
|
|
44643
44783
|
if (code === "U") {
|
|
44644
|
-
const hex3 =
|
|
44784
|
+
const hex3 = text5.slice(i2 + 2, i2 + 10);
|
|
44645
44785
|
if (!/^[0-9a-fA-F]{8}$/.test(hex3)) return { ok: false };
|
|
44646
44786
|
const point = parseInt(hex3, 16);
|
|
44647
44787
|
if (point > 1114111 || point >= 55296 && point <= 57343) return { ok: false };
|
|
@@ -44713,14 +44853,14 @@ function tomlRowKey(row) {
|
|
|
44713
44853
|
const eq = row.indexOf("=");
|
|
44714
44854
|
return unquoteTomlKey(eq < 0 ? row : row.slice(0, eq));
|
|
44715
44855
|
}
|
|
44716
|
-
function tomlTables(
|
|
44856
|
+
function tomlTables(text5) {
|
|
44717
44857
|
const headings = [];
|
|
44718
44858
|
let mode = "out";
|
|
44719
44859
|
let i2 = 0;
|
|
44720
|
-
const atLineStart = (idx) => idx === 0 ||
|
|
44721
|
-
while (i2 <
|
|
44860
|
+
const atLineStart = (idx) => idx === 0 || text5[idx - 1] === "\n";
|
|
44861
|
+
while (i2 < text5.length) {
|
|
44722
44862
|
if (mode === "mlbasic") {
|
|
44723
|
-
if (
|
|
44863
|
+
if (text5.startsWith('"""', i2)) {
|
|
44724
44864
|
mode = "out";
|
|
44725
44865
|
i2 += 3;
|
|
44726
44866
|
continue;
|
|
@@ -44729,7 +44869,7 @@ function tomlTables(text4) {
|
|
|
44729
44869
|
continue;
|
|
44730
44870
|
}
|
|
44731
44871
|
if (mode === "mllit") {
|
|
44732
|
-
if (
|
|
44872
|
+
if (text5.startsWith("'''", i2)) {
|
|
44733
44873
|
mode = "out";
|
|
44734
44874
|
i2 += 3;
|
|
44735
44875
|
continue;
|
|
@@ -44738,61 +44878,61 @@ function tomlTables(text4) {
|
|
|
44738
44878
|
continue;
|
|
44739
44879
|
}
|
|
44740
44880
|
if (mode === "basic") {
|
|
44741
|
-
if (
|
|
44881
|
+
if (text5[i2] === "\n") {
|
|
44742
44882
|
mode = "out";
|
|
44743
44883
|
i2 += 1;
|
|
44744
44884
|
continue;
|
|
44745
44885
|
}
|
|
44746
|
-
if (
|
|
44886
|
+
if (text5[i2] === "\\") {
|
|
44747
44887
|
i2 += 2;
|
|
44748
44888
|
continue;
|
|
44749
44889
|
}
|
|
44750
|
-
if (
|
|
44890
|
+
if (text5[i2] === '"') mode = "out";
|
|
44751
44891
|
i2 += 1;
|
|
44752
44892
|
continue;
|
|
44753
44893
|
}
|
|
44754
44894
|
if (mode === "literal") {
|
|
44755
|
-
if (
|
|
44895
|
+
if (text5[i2] === "\n") {
|
|
44756
44896
|
mode = "out";
|
|
44757
44897
|
i2 += 1;
|
|
44758
44898
|
continue;
|
|
44759
44899
|
}
|
|
44760
|
-
if (
|
|
44900
|
+
if (text5[i2] === "'") mode = "out";
|
|
44761
44901
|
i2 += 1;
|
|
44762
44902
|
continue;
|
|
44763
44903
|
}
|
|
44764
|
-
if (
|
|
44904
|
+
if (text5.startsWith('"""', i2)) {
|
|
44765
44905
|
mode = "mlbasic";
|
|
44766
44906
|
i2 += 3;
|
|
44767
44907
|
continue;
|
|
44768
44908
|
}
|
|
44769
|
-
if (
|
|
44909
|
+
if (text5.startsWith("'''", i2)) {
|
|
44770
44910
|
mode = "mllit";
|
|
44771
44911
|
i2 += 3;
|
|
44772
44912
|
continue;
|
|
44773
44913
|
}
|
|
44774
|
-
if (
|
|
44914
|
+
if (text5[i2] === '"') {
|
|
44775
44915
|
mode = "basic";
|
|
44776
44916
|
i2 += 1;
|
|
44777
44917
|
continue;
|
|
44778
44918
|
}
|
|
44779
|
-
if (
|
|
44919
|
+
if (text5[i2] === "'") {
|
|
44780
44920
|
mode = "literal";
|
|
44781
44921
|
i2 += 1;
|
|
44782
44922
|
continue;
|
|
44783
44923
|
}
|
|
44784
|
-
if (
|
|
44785
|
-
const nl =
|
|
44786
|
-
i2 = nl < 0 ?
|
|
44924
|
+
if (text5[i2] === "#") {
|
|
44925
|
+
const nl = text5.indexOf("\n", i2);
|
|
44926
|
+
i2 = nl < 0 ? text5.length : nl + 1;
|
|
44787
44927
|
continue;
|
|
44788
44928
|
}
|
|
44789
44929
|
if (atLineStart(i2)) {
|
|
44790
44930
|
let j2 = i2;
|
|
44791
|
-
while (j2 <
|
|
44792
|
-
if (
|
|
44793
|
-
const nl =
|
|
44794
|
-
const lineEnd = nl < 0 ?
|
|
44795
|
-
const raw =
|
|
44931
|
+
while (j2 < text5.length && (text5[j2] === " " || text5[j2] === " ")) j2 += 1;
|
|
44932
|
+
if (text5[j2] === "[") {
|
|
44933
|
+
const nl = text5.indexOf("\n", j2);
|
|
44934
|
+
const lineEnd = nl < 0 ? text5.length : nl;
|
|
44935
|
+
const raw = text5.slice(j2, lineEnd).replace(/\r$/, "");
|
|
44796
44936
|
const stripped = stripTomlLineComment(raw).trim();
|
|
44797
44937
|
const array2 = stripped.startsWith("[[");
|
|
44798
44938
|
const name = array2 ? canonicalizeTomlHeading(`[${stripped.replace(/^\s*\[\[/, "").replace(/\]\]\s*$/, "")}]`) : canonicalizeTomlHeading(raw);
|
|
@@ -44805,11 +44945,11 @@ function tomlTables(text4) {
|
|
|
44805
44945
|
}
|
|
44806
44946
|
return headings.map((heading, index) => ({
|
|
44807
44947
|
heading,
|
|
44808
|
-
end: index + 1 < headings.length ? headings[index + 1].lineStart :
|
|
44948
|
+
end: index + 1 < headings.length ? headings[index + 1].lineStart : text5.length
|
|
44809
44949
|
})).filter((entry) => entry.heading.patchable && entry.heading.name).map((entry) => ({
|
|
44810
44950
|
name: entry.heading.name,
|
|
44811
44951
|
headingStart: entry.heading.lineStart,
|
|
44812
|
-
bodyStart: entry.heading.lineEnd + (
|
|
44952
|
+
bodyStart: entry.heading.lineEnd + (text5[entry.heading.lineEnd] === "\n" ? 1 : 0),
|
|
44813
44953
|
end: entry.end
|
|
44814
44954
|
}));
|
|
44815
44955
|
}
|
|
@@ -44865,22 +45005,22 @@ function tomlKeys(block2) {
|
|
|
44865
45005
|
take(block2.length);
|
|
44866
45006
|
return keys;
|
|
44867
45007
|
}
|
|
44868
|
-
function hasTomlTable(
|
|
45008
|
+
function hasTomlTable(text5, heading) {
|
|
44869
45009
|
const name = canonicalizeTomlHeading(heading);
|
|
44870
|
-
return name !== null && tomlTables(
|
|
45010
|
+
return name !== null && tomlTables(text5).some((table) => table.name === name);
|
|
44871
45011
|
}
|
|
44872
|
-
function patchTomlTable(
|
|
45012
|
+
function patchTomlTable(text5, heading, rows) {
|
|
44873
45013
|
const name = canonicalizeTomlHeading(heading);
|
|
44874
|
-
if (!name) return
|
|
44875
|
-
const table = tomlTables(
|
|
44876
|
-
if (!table) return
|
|
44877
|
-
const keys = tomlKeys(
|
|
45014
|
+
if (!name) return text5;
|
|
45015
|
+
const table = tomlTables(text5).find((entry) => entry.name === name);
|
|
45016
|
+
if (!table) return text5;
|
|
45017
|
+
const keys = tomlKeys(text5.slice(table.bodyStart, table.end));
|
|
44878
45018
|
const missing = rows.filter((row) => !keys.has(tomlRowKey(row)));
|
|
44879
|
-
if (!missing.length) return
|
|
45019
|
+
if (!missing.length) return text5;
|
|
44880
45020
|
let insertAt = table.end;
|
|
44881
|
-
while (insertAt > table.bodyStart && (
|
|
44882
|
-
const before =
|
|
44883
|
-
const after =
|
|
45021
|
+
while (insertAt > table.bodyStart && (text5[insertAt - 1] === "\n" || text5[insertAt - 1] === "\r")) insertAt -= 1;
|
|
45022
|
+
const before = text5.slice(0, insertAt);
|
|
45023
|
+
const after = text5.slice(insertAt);
|
|
44884
45024
|
const pad = before.endsWith("\n") || before.length === 0 ? "" : "\n";
|
|
44885
45025
|
return `${before}${pad}${missing.join("\n")}${after.startsWith("\n") ? "" : "\n"}${after}`;
|
|
44886
45026
|
}
|
|
@@ -44893,17 +45033,17 @@ function ensureKimiInjectAlias(modelId, env = process.env) {
|
|
|
44893
45033
|
const dataRoot = kimiDataRoot(env);
|
|
44894
45034
|
mkdirSync17(dataRoot, { recursive: true });
|
|
44895
45035
|
const path4 = join37(dataRoot, "config.toml");
|
|
44896
|
-
let
|
|
45036
|
+
let text5 = "";
|
|
44897
45037
|
try {
|
|
44898
|
-
|
|
45038
|
+
text5 = readFileSync21(path4, "utf8");
|
|
44899
45039
|
} catch {
|
|
44900
|
-
|
|
45040
|
+
text5 = "";
|
|
44901
45041
|
}
|
|
44902
|
-
const original =
|
|
45042
|
+
const original = text5;
|
|
44903
45043
|
const providerHeading = `[providers.${inject.host}]`;
|
|
44904
45044
|
const modelHeading = `[models.${quoteTomlKey(alias)}]`;
|
|
44905
45045
|
const blocks = [];
|
|
44906
|
-
if (!hasTomlTable(
|
|
45046
|
+
if (!hasTomlTable(text5, providerHeading)) {
|
|
44907
45047
|
blocks.push(
|
|
44908
45048
|
[
|
|
44909
45049
|
providerHeading,
|
|
@@ -44914,8 +45054,8 @@ function ensureKimiInjectAlias(modelId, env = process.env) {
|
|
|
44914
45054
|
].join("\n")
|
|
44915
45055
|
);
|
|
44916
45056
|
}
|
|
44917
|
-
if (hasTomlTable(
|
|
44918
|
-
|
|
45057
|
+
if (hasTomlTable(text5, modelHeading)) {
|
|
45058
|
+
text5 = patchTomlTable(text5, modelHeading, [`protocol = "openai"`, `max_context_size = 262144`]);
|
|
44919
45059
|
} else {
|
|
44920
45060
|
blocks.push(
|
|
44921
45061
|
[
|
|
@@ -44929,13 +45069,13 @@ function ensureKimiInjectAlias(modelId, env = process.env) {
|
|
|
44929
45069
|
);
|
|
44930
45070
|
}
|
|
44931
45071
|
if (blocks.length) {
|
|
44932
|
-
const prefix =
|
|
45072
|
+
const prefix = text5 && !text5.endsWith("\n") ? `${text5}
|
|
44933
45073
|
|
|
44934
|
-
` :
|
|
45074
|
+
` : text5 ? `${text5}
|
|
44935
45075
|
` : "";
|
|
44936
45076
|
writeFileSync13(path4, `${prefix}${blocks.join("\n")}`);
|
|
44937
|
-
} else if (
|
|
44938
|
-
writeFileSync13(path4,
|
|
45077
|
+
} else if (text5 !== original) {
|
|
45078
|
+
writeFileSync13(path4, text5);
|
|
44939
45079
|
}
|
|
44940
45080
|
return alias;
|
|
44941
45081
|
}
|
|
@@ -44955,9 +45095,9 @@ function stripKimiModelEnv(env) {
|
|
|
44955
45095
|
}
|
|
44956
45096
|
function readKimiModelCatalog(env) {
|
|
44957
45097
|
const dataRoot = kimiDataRoot(env);
|
|
44958
|
-
let
|
|
45098
|
+
let text5 = "";
|
|
44959
45099
|
try {
|
|
44960
|
-
|
|
45100
|
+
text5 = readFileSync21(join37(dataRoot, "config.toml"), "utf8");
|
|
44961
45101
|
} catch {
|
|
44962
45102
|
return STATIC_KIMI_MODELS;
|
|
44963
45103
|
}
|
|
@@ -44973,7 +45113,7 @@ function readKimiModelCatalog(env) {
|
|
|
44973
45113
|
options.push({ id: current.slug, label: current.name || current.slug, custom: true });
|
|
44974
45114
|
current = null;
|
|
44975
45115
|
};
|
|
44976
|
-
for (const line of
|
|
45116
|
+
for (const line of text5.split(/\r?\n/)) {
|
|
44977
45117
|
const stripped = line.trim();
|
|
44978
45118
|
if ((stripped.startsWith("[model.") || stripped.startsWith("[models.")) && stripped.endsWith("]")) {
|
|
44979
45119
|
flush();
|
|
@@ -45025,6 +45165,7 @@ var init_kimi = __esm({
|
|
|
45025
45165
|
];
|
|
45026
45166
|
support4 = {
|
|
45027
45167
|
driverKind: "kimiAgent",
|
|
45168
|
+
approvalModeReadback: { ladder: "kimiAgent", expected: (config2) => kimiSessionMode(config2.fullAuto), setsModeOverWire: true },
|
|
45028
45169
|
displayName: "Kimi",
|
|
45029
45170
|
// Aliases from the CLI's own catalog (~/.kimi-code/config.toml
|
|
45030
45171
|
// [models."kimi-code/…"] — `kimi provider list` reports the same four).
|
|
@@ -45105,10 +45246,10 @@ ${turn.text}` : turn.text
|
|
|
45105
45246
|
|
|
45106
45247
|
// server/drivers/acp/droid.ts
|
|
45107
45248
|
import { existsSync as existsSync19, mkdirSync as mkdirSync18, readFileSync as readFileSync22, writeFileSync as writeFileSync14 } from "node:fs";
|
|
45108
|
-
import { homedir as
|
|
45249
|
+
import { homedir as homedir20 } from "node:os";
|
|
45109
45250
|
import { join as join38 } from "node:path";
|
|
45110
45251
|
function authFilePaths(env) {
|
|
45111
|
-
const home = env.FACTORY_HOME_OVERRIDE || env.HOME ||
|
|
45252
|
+
const home = env.FACTORY_HOME_OVERRIDE || env.HOME || homedir20();
|
|
45112
45253
|
return AUTH_FILES.map((name) => join38(home, ".factory", name));
|
|
45113
45254
|
}
|
|
45114
45255
|
function droidInjectId(host, model) {
|
|
@@ -45116,7 +45257,7 @@ function droidInjectId(host, model) {
|
|
|
45116
45257
|
return `${INJECT_ID_PREFIX}${safe}`;
|
|
45117
45258
|
}
|
|
45118
45259
|
function factoryHome(env) {
|
|
45119
|
-
return env.FACTORY_HOME_OVERRIDE || env.HOME || env.USERPROFILE ||
|
|
45260
|
+
return env.FACTORY_HOME_OVERRIDE || env.HOME || env.USERPROFILE || homedir20();
|
|
45120
45261
|
}
|
|
45121
45262
|
function ensureDroidInjectModel(modelId, env = process.env) {
|
|
45122
45263
|
const inject = decodeInjectId(modelId);
|
|
@@ -45227,6 +45368,7 @@ var init_droid = __esm({
|
|
|
45227
45368
|
};
|
|
45228
45369
|
support5 = {
|
|
45229
45370
|
driverKind: "droidAgent",
|
|
45371
|
+
approvalModeReadback: { ladder: "droidAgent", expected: (config2) => config2.fullAuto ? MODE_FULL_AUTO : MODE_DEFAULT, setsModeOverWire: true },
|
|
45230
45372
|
displayName: "Droid",
|
|
45231
45373
|
models: MODELS3,
|
|
45232
45374
|
defaultCli: "droid",
|
|
@@ -45294,8 +45436,8 @@ function resolveCursorAcpModelId(available, wanted) {
|
|
|
45294
45436
|
}
|
|
45295
45437
|
return null;
|
|
45296
45438
|
}
|
|
45297
|
-
function firstJsonValue(
|
|
45298
|
-
const trimmed =
|
|
45439
|
+
function firstJsonValue(text5) {
|
|
45440
|
+
const trimmed = text5.trim();
|
|
45299
45441
|
if (!trimmed) return null;
|
|
45300
45442
|
try {
|
|
45301
45443
|
return JSON.parse(trimmed);
|
|
@@ -45369,12 +45511,12 @@ function stripModelMarkers(label) {
|
|
|
45369
45511
|
}
|
|
45370
45512
|
return { label: cleaned, isDefault, isCurrent };
|
|
45371
45513
|
}
|
|
45372
|
-
function decodeCursorModelText(
|
|
45514
|
+
function decodeCursorModelText(text5) {
|
|
45373
45515
|
const options = [];
|
|
45374
45516
|
const seen = /* @__PURE__ */ new Set();
|
|
45375
45517
|
let markedDefault;
|
|
45376
45518
|
let markedCurrent;
|
|
45377
|
-
for (const raw of
|
|
45519
|
+
for (const raw of text5.split(/\r?\n/)) {
|
|
45378
45520
|
const line = raw.trim();
|
|
45379
45521
|
if (!line || line.startsWith("#") || /^available\s+models?\b/i.test(line) || /^models?\b/i.test(line)) continue;
|
|
45380
45522
|
const stripped = line.replace(/^[\s*•-]+\s*/, "");
|
|
@@ -45427,8 +45569,8 @@ function decodeCursorAuthStatus(payload) {
|
|
|
45427
45569
|
}
|
|
45428
45570
|
return null;
|
|
45429
45571
|
}
|
|
45430
|
-
function decodeCursorAuthText(
|
|
45431
|
-
const normalized =
|
|
45572
|
+
function decodeCursorAuthText(text5) {
|
|
45573
|
+
const normalized = text5.trim().toLowerCase();
|
|
45432
45574
|
if (!normalized) return null;
|
|
45433
45575
|
if (/not (?:logged|signed) in|not authenticated|unauthenticated|logged out/.test(normalized)) return false;
|
|
45434
45576
|
if (/login successful|logged in|signed in|authenticated/.test(normalized)) return true;
|
|
@@ -45637,18 +45779,18 @@ import { createHash as createHash12 } from "node:crypto";
|
|
|
45637
45779
|
function requestKey(id) {
|
|
45638
45780
|
return `${typeof id === "number" ? "number" : "string"}:${String(id)}`;
|
|
45639
45781
|
}
|
|
45640
|
-
function utf8ByteLength(
|
|
45782
|
+
function utf8ByteLength(text5) {
|
|
45641
45783
|
let bytes = 0;
|
|
45642
|
-
for (const scalar of
|
|
45784
|
+
for (const scalar of text5) {
|
|
45643
45785
|
const point = scalar.codePointAt(0);
|
|
45644
45786
|
bytes += point <= 127 ? 1 : point <= 2047 ? 2 : point <= 65535 ? 3 : 4;
|
|
45645
45787
|
}
|
|
45646
45788
|
return bytes;
|
|
45647
45789
|
}
|
|
45648
|
-
function truncateToUtf8Bytes(
|
|
45790
|
+
function truncateToUtf8Bytes(text5, limitBytes) {
|
|
45649
45791
|
let bytes = 0;
|
|
45650
45792
|
let end = 0;
|
|
45651
|
-
for (const scalar of
|
|
45793
|
+
for (const scalar of text5) {
|
|
45652
45794
|
const point = scalar.codePointAt(0);
|
|
45653
45795
|
const width = point <= 127 ? 1 : point <= 2047 ? 2 : point <= 65535 ? 3 : 4;
|
|
45654
45796
|
if (bytes + width > limitBytes)
|
|
@@ -45656,7 +45798,7 @@ function truncateToUtf8Bytes(text4, limitBytes) {
|
|
|
45656
45798
|
bytes += width;
|
|
45657
45799
|
end += scalar.length;
|
|
45658
45800
|
}
|
|
45659
|
-
return
|
|
45801
|
+
return text5.slice(0, end);
|
|
45660
45802
|
}
|
|
45661
45803
|
function canonical(value) {
|
|
45662
45804
|
if (Array.isArray(value))
|
|
@@ -47054,11 +47196,11 @@ var init_muse_code_login = __esm({
|
|
|
47054
47196
|
// server/drivers/muse-code.ts
|
|
47055
47197
|
import { existsSync as existsSync20, mkdtempSync as mkdtempSync4, readFileSync as readFileSync23, rmSync as rmSync8, statSync as statSync5 } from "node:fs";
|
|
47056
47198
|
import { readFile as readFile4 } from "node:fs/promises";
|
|
47057
|
-
import { homedir as
|
|
47199
|
+
import { homedir as homedir21, tmpdir as tmpdir5 } from "node:os";
|
|
47058
47200
|
import { join as join39 } from "node:path";
|
|
47059
47201
|
function museCredentialPath(env, platform = process.platform) {
|
|
47060
47202
|
if (env.MUSE_AUTH_PATH?.trim()) return env.MUSE_AUTH_PATH.trim();
|
|
47061
|
-
const home = (platform === "win32" ? env.USERPROFILE || env.HOME : env.HOME) ||
|
|
47203
|
+
const home = (platform === "win32" ? env.USERPROFILE || env.HOME : env.HOME) || homedir21();
|
|
47062
47204
|
return join39(env.XDG_CONFIG_HOME?.trim() || join39(home, ".config"), "muse", "auth.json");
|
|
47063
47205
|
}
|
|
47064
47206
|
function museCredential(path4) {
|
|
@@ -47153,8 +47295,8 @@ function museToolStart(item) {
|
|
|
47153
47295
|
}
|
|
47154
47296
|
function museToolOutput(item) {
|
|
47155
47297
|
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}.` : "",
|
|
47298
|
+
const text5 = item.visibleOutput ?? item.result?.summary ?? item.text ?? item.summary?.join("\n") ?? item.fallbackText ?? "";
|
|
47299
|
+
const output = [item.status !== "completed" ? item.failureReason || `Muse reported ${item.status}.` : "", text5].filter(Boolean).join("\n");
|
|
47158
47300
|
return { ok, ...output ? { output: redactSecretsInText(output.slice(0, MAX_TOOL_OUTPUT)) } : {} };
|
|
47159
47301
|
}
|
|
47160
47302
|
function museQuestions(raw) {
|
|
@@ -47422,12 +47564,12 @@ var init_muse_code = __esm({
|
|
|
47422
47564
|
active.items.set(item.itemId, item);
|
|
47423
47565
|
if (item.kind === "agentMessage") {
|
|
47424
47566
|
if (item.status !== "completed" || item.retracted) return;
|
|
47425
|
-
const
|
|
47567
|
+
const text5 = item.text ?? "";
|
|
47426
47568
|
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:
|
|
47569
|
+
if (text5.startsWith(streamed) && text5.length > streamed.length) {
|
|
47570
|
+
emit({ type: "content.delta", threadId, turnId: active.turnId, itemId: item.itemId, streamKind: "assistant_text", delta: text5.slice(streamed.length) });
|
|
47429
47571
|
}
|
|
47430
|
-
if (
|
|
47572
|
+
if (text5) emit({ type: "item.completed", threadId, turnId: active.turnId, itemId: item.itemId, itemType: "assistant_text", text: text5 });
|
|
47431
47573
|
} else if (item.kind === "reasoning") {
|
|
47432
47574
|
if (!seen) emit({ type: "item.started", threadId, turnId: active.turnId, itemId: item.itemId, itemType: "reasoning" });
|
|
47433
47575
|
} else if (TOOL_KINDS.has(item.kind)) {
|
|
@@ -47624,16 +47766,16 @@ var init_muse_code = __esm({
|
|
|
47624
47766
|
const rebuilt = Boolean(resumeId && turn.recoveryText);
|
|
47625
47767
|
return { text: rebuilt ? turn.recoveryText : turn.text, rebuilt, started: true };
|
|
47626
47768
|
};
|
|
47627
|
-
const withInstructions = (state2, turn,
|
|
47769
|
+
const withInstructions = (state2, turn, text5, started) => {
|
|
47628
47770
|
const sessionId = state2.sessionId;
|
|
47629
47771
|
if (turn.systemStable === void 0) return turn.system && started ? `${turn.system}
|
|
47630
47772
|
|
|
47631
|
-
${
|
|
47773
|
+
${text5}` : text5;
|
|
47632
47774
|
let entry = state2.instructions;
|
|
47633
47775
|
const resend = started || !entry || entry.sessionId !== sessionId || entry.stable !== turn.systemStable || entry.turns >= INSTRUCTIONS_REFRESH_TURNS;
|
|
47634
47776
|
if (resend) entry = state2.instructions = { sessionId, stable: turn.systemStable, turns: 0, seen: /* @__PURE__ */ new Map() };
|
|
47635
47777
|
entry.turns++;
|
|
47636
|
-
const body = withNote(
|
|
47778
|
+
const body = withNote(text5, volatileNote(volatileSectionsOf(turn), entry.seen, entry.seen.size === 0));
|
|
47637
47779
|
return resend && turn.systemStable ? `${turn.systemStable}
|
|
47638
47780
|
|
|
47639
47781
|
${body}` : body;
|
|
@@ -47651,7 +47793,7 @@ ${body}` : body;
|
|
|
47651
47793
|
await host.connection.command("session/setModel", { sessionId, model: { modelId: turn.model, providerId: config2.provider } });
|
|
47652
47794
|
state2.model = turn.model;
|
|
47653
47795
|
}
|
|
47654
|
-
const
|
|
47796
|
+
const text5 = withInstructions(state2, turn, session.text, session.started);
|
|
47655
47797
|
const images = turn.images?.length ? await Promise.all(turn.images.map(async (image) => ({
|
|
47656
47798
|
type: "image",
|
|
47657
47799
|
mediaType: image.mime,
|
|
@@ -47663,7 +47805,7 @@ ${body}` : body;
|
|
|
47663
47805
|
active.nativeTurnId = host.connection.mintCommandId();
|
|
47664
47806
|
await host.connection.command("turn/start", {
|
|
47665
47807
|
sessionId,
|
|
47666
|
-
input: [{ type: "text", text:
|
|
47808
|
+
input: [{ type: "text", text: text5 }, ...images],
|
|
47667
47809
|
...effort ? { reasoningEffort: effort } : {}
|
|
47668
47810
|
}, { commandId: active.nativeTurnId });
|
|
47669
47811
|
} catch (error51) {
|
|
@@ -47743,7 +47885,7 @@ ${body}` : body;
|
|
|
47743
47885
|
return "unavailable";
|
|
47744
47886
|
}
|
|
47745
47887
|
},
|
|
47746
|
-
async steer(threadId,
|
|
47888
|
+
async steer(threadId, text5) {
|
|
47747
47889
|
const state2 = threads.get(threadId);
|
|
47748
47890
|
const active = state2?.active;
|
|
47749
47891
|
if (!state2?.host || !state2.sessionId || !active?.nativeTurnId || active.finished) return "refused";
|
|
@@ -47751,7 +47893,7 @@ ${body}` : body;
|
|
|
47751
47893
|
await state2.host.connection.command("turn/steer", {
|
|
47752
47894
|
sessionId: state2.sessionId,
|
|
47753
47895
|
expectedTurnId: active.nativeTurnId,
|
|
47754
|
-
input: [{ type: "text", text:
|
|
47896
|
+
input: [{ type: "text", text: text5 }]
|
|
47755
47897
|
});
|
|
47756
47898
|
return "steered";
|
|
47757
47899
|
} catch (error51) {
|
|
@@ -47818,7 +47960,7 @@ ${body}` : body;
|
|
|
47818
47960
|
|
|
47819
47961
|
// server/drivers/acp/opencode-go.ts
|
|
47820
47962
|
import { existsSync as existsSync21, mkdirSync as mkdirSync19, readFileSync as readFileSync24, writeFileSync as writeFileSync15 } from "node:fs";
|
|
47821
|
-
import { homedir as
|
|
47963
|
+
import { homedir as homedir22 } from "node:os";
|
|
47822
47964
|
import { join as join40 } from "node:path";
|
|
47823
47965
|
function labelForModel(id) {
|
|
47824
47966
|
return id.split(/[-_.]+/g).filter(Boolean).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
|
|
@@ -47921,7 +48063,7 @@ async function discoverOpenCodeModels(environment, cli = "opencode") {
|
|
|
47921
48063
|
}
|
|
47922
48064
|
}
|
|
47923
48065
|
function opencodeConfigDir(env) {
|
|
47924
|
-
const home = env.HOME || env.USERPROFILE ||
|
|
48066
|
+
const home = env.HOME || env.USERPROFILE || homedir22();
|
|
47925
48067
|
return join40(env.XDG_CONFIG_HOME || join40(home, ".config"), "opencode");
|
|
47926
48068
|
}
|
|
47927
48069
|
function ensureOpenCodeInjectModel(modelId, env = process.env) {
|
|
@@ -47968,7 +48110,7 @@ function ensureOpenCodeInjectModel(modelId, env = process.env) {
|
|
|
47968
48110
|
return native;
|
|
47969
48111
|
}
|
|
47970
48112
|
function storedAuthPaths(env) {
|
|
47971
|
-
const home = env.HOME || env.USERPROFILE ||
|
|
48113
|
+
const home = env.HOME || env.USERPROFILE || homedir22();
|
|
47972
48114
|
const roots = [
|
|
47973
48115
|
env.XDG_DATA_HOME || join40(home, ".local", "share"),
|
|
47974
48116
|
process.platform === "darwin" ? join40(home, "Library", "Application Support") : process.platform === "win32" ? env.LOCALAPPDATA || join40(home, "AppData", "Local") : ""
|
|
@@ -48131,10 +48273,10 @@ ${turn.text}` : turn.text
|
|
|
48131
48273
|
// server/drivers/acp/qwen.ts
|
|
48132
48274
|
import { chmodSync as chmodSync5, existsSync as existsSync22, mkdirSync as mkdirSync20, readFileSync as readFileSync25, writeFileSync as writeFileSync16 } from "node:fs";
|
|
48133
48275
|
import { createHash as createHash13 } from "node:crypto";
|
|
48134
|
-
import { homedir as
|
|
48276
|
+
import { homedir as homedir23 } from "node:os";
|
|
48135
48277
|
import { join as join41 } from "node:path";
|
|
48136
48278
|
function qwenHome(env) {
|
|
48137
|
-
const home = process.platform === "win32" ? env.USERPROFILE || env.HOME ||
|
|
48279
|
+
const home = process.platform === "win32" ? env.USERPROFILE || env.HOME || homedir23() : env.HOME || env.USERPROFILE || homedir23();
|
|
48138
48280
|
return join41(home, ".qwen");
|
|
48139
48281
|
}
|
|
48140
48282
|
function isRecord5(value) {
|
|
@@ -48307,6 +48449,12 @@ function qwenApprovalArgs(fullAuto, approvalMode) {
|
|
|
48307
48449
|
if (approvalMode === "edits") return ["--approval-mode", "auto-edit"];
|
|
48308
48450
|
return [];
|
|
48309
48451
|
}
|
|
48452
|
+
function qwenExpectedMode(fullAuto, approvalMode) {
|
|
48453
|
+
if (fullAuto) return "yolo";
|
|
48454
|
+
if (approvalMode === "auto") return "auto";
|
|
48455
|
+
if (approvalMode === "edits") return "auto-edit";
|
|
48456
|
+
return "default";
|
|
48457
|
+
}
|
|
48310
48458
|
var EMPTY, PROTOCOLS, support8, QwenAgentDriver;
|
|
48311
48459
|
var init_qwen = __esm({
|
|
48312
48460
|
"server/drivers/acp/qwen.ts"() {
|
|
@@ -48317,6 +48465,8 @@ var init_qwen = __esm({
|
|
|
48317
48465
|
PROTOCOLS = /* @__PURE__ */ new Set(["openai", "anthropic", "gemini", "vertex-ai"]);
|
|
48318
48466
|
support8 = {
|
|
48319
48467
|
driverKind: "qwenAgent",
|
|
48468
|
+
// Qwen takes the mode on argv; session/new reports the one it applied.
|
|
48469
|
+
approvalModeReadback: { ladder: "qwenAgent", expected: (config2, turn) => qwenExpectedMode(config2.fullAuto, turn.approvalMode) },
|
|
48320
48470
|
displayName: "Qwen",
|
|
48321
48471
|
access: "custom",
|
|
48322
48472
|
models: EMPTY,
|
|
@@ -48368,9 +48518,9 @@ function mistralSignInLink(value) {
|
|
|
48368
48518
|
return host === "mistral.ai" || host.endsWith(".mistral.ai") ? url2.href : null;
|
|
48369
48519
|
}
|
|
48370
48520
|
function vibeSignInFailure(error51) {
|
|
48371
|
-
const
|
|
48372
|
-
if (/denied/i.test(
|
|
48373
|
-
if (/expired|timed out/i.test(
|
|
48521
|
+
const text5 = error51 instanceof VibeRequestError ? error51.message : "";
|
|
48522
|
+
if (/denied/i.test(text5)) return "The Mistral sign-in was declined. Start sign-in again to try another account.";
|
|
48523
|
+
if (/expired|timed out/i.test(text5)) return "The Mistral sign-in expired. Start sign-in again.";
|
|
48374
48524
|
if (error51 instanceof Error && !(error51 instanceof VibeRequestError)) return error51.message;
|
|
48375
48525
|
return "Mistral Vibe sign-in did not finish. Check this computer's connection and that Vibe is up to date, then try again.";
|
|
48376
48526
|
}
|
|
@@ -48445,8 +48595,8 @@ var init_vibe_login = __esm({
|
|
|
48445
48595
|
}
|
|
48446
48596
|
if (this.child.exitCode === null && this.child.signalCode === null) void killCliTree(this.child).catch(() => false);
|
|
48447
48597
|
}
|
|
48448
|
-
receive(
|
|
48449
|
-
this.buffer +=
|
|
48598
|
+
receive(text5) {
|
|
48599
|
+
this.buffer += text5;
|
|
48450
48600
|
if (this.buffer.length > MAX_LINE) {
|
|
48451
48601
|
this.close(new Error("Mistral Vibe returned an unexpected answer. Update Vibe and try again."));
|
|
48452
48602
|
return;
|
|
@@ -48570,6 +48720,12 @@ var init_vibe_login = __esm({
|
|
|
48570
48720
|
});
|
|
48571
48721
|
|
|
48572
48722
|
// server/drivers/acp/vibe.ts
|
|
48723
|
+
function vibeReportedMode(reply) {
|
|
48724
|
+
const options = reply?.configOptions;
|
|
48725
|
+
if (!Array.isArray(options)) return null;
|
|
48726
|
+
const mode = options.find((option) => option && typeof option === "object" && option.id === "mode");
|
|
48727
|
+
return typeof mode?.currentValue === "string" ? mode.currentValue : null;
|
|
48728
|
+
}
|
|
48573
48729
|
function vibeSessionMode(fullAuto, approvalMode) {
|
|
48574
48730
|
if (fullAuto) return "auto-approve";
|
|
48575
48731
|
if (approvalMode === "auto") return "smart-approve";
|
|
@@ -48599,6 +48755,7 @@ var init_vibe = __esm({
|
|
|
48599
48755
|
init_env_path();
|
|
48600
48756
|
init_vibe_login();
|
|
48601
48757
|
init_core3();
|
|
48758
|
+
init_approval_readback();
|
|
48602
48759
|
VIBE_DRIVER_KIND = "vibeAgent";
|
|
48603
48760
|
MODELS4 = {
|
|
48604
48761
|
default: "mistral-medium-3.5",
|
|
@@ -48634,11 +48791,13 @@ var init_vibe = __esm({
|
|
|
48634
48791
|
isAuthenticated: (env, config2, instanceId) => cachedSignedIn(`${instanceId}:${env.VIBE_HOME ?? ""}`, () => vibeSignedIn(config2.cli || "vibe-acp", env)),
|
|
48635
48792
|
async configureSession({ request, sessionId, config: config2, turn }) {
|
|
48636
48793
|
const value = vibeSessionMode(config2.fullAuto, turn.approvalMode);
|
|
48794
|
+
let reply;
|
|
48637
48795
|
try {
|
|
48638
|
-
await request("session/set_config_option", { sessionId, configId: "mode", value });
|
|
48796
|
+
reply = await request("session/set_config_option", { sessionId, configId: "mode", value });
|
|
48639
48797
|
} catch (e) {
|
|
48640
48798
|
throw new Error(`Mistral Vibe rejected permission mode "${value}": ${e.message}. Update Mistral Vibe (3.0 or newer).`);
|
|
48641
48799
|
}
|
|
48800
|
+
assertEffectiveModeNotLooser("Mistral Vibe", "vibeAgent", value, vibeReportedMode(reply));
|
|
48642
48801
|
},
|
|
48643
48802
|
buildPromptText: (turn) => turn.system ? `${turn.system}
|
|
48644
48803
|
|
|
@@ -48719,13 +48878,13 @@ var init_claude_accounts = __esm({
|
|
|
48719
48878
|
|
|
48720
48879
|
// server/atomic-engine-accounts.ts
|
|
48721
48880
|
import { mkdirSync as mkdirSync21, readFileSync as readFileSync26, writeFileSync as writeFileSync17 } from "node:fs";
|
|
48722
|
-
import { homedir as
|
|
48881
|
+
import { homedir as homedir24 } from "node:os";
|
|
48723
48882
|
import { join as join42 } from "node:path";
|
|
48724
48883
|
function rawConfig2(entry) {
|
|
48725
48884
|
return entry.config && typeof entry.config === "object" && !Array.isArray(entry.config) ? entry.config : {};
|
|
48726
48885
|
}
|
|
48727
48886
|
function expandHome(path4) {
|
|
48728
|
-
return path4 === "~" ?
|
|
48887
|
+
return path4 === "~" ? homedir24() : path4.startsWith("~/") ? join42(homedir24(), path4.slice(2)) : path4;
|
|
48729
48888
|
}
|
|
48730
48889
|
function asAccount(id, entry) {
|
|
48731
48890
|
if (entry.enabled === false) return null;
|
|
@@ -48757,7 +48916,7 @@ function asAccount(id, entry) {
|
|
|
48757
48916
|
kind: "codex-cli",
|
|
48758
48917
|
label,
|
|
48759
48918
|
billing: "subscription",
|
|
48760
|
-
home: home ? expandHome(home) : join42(
|
|
48919
|
+
home: home ? expandHome(home) : join42(homedir24(), ".codex"),
|
|
48761
48920
|
model: FAILOVER_MODEL["openai-codex"]
|
|
48762
48921
|
} };
|
|
48763
48922
|
}
|
|
@@ -48817,16 +48976,16 @@ function atomicEngineAccounts(input) {
|
|
|
48817
48976
|
}
|
|
48818
48977
|
function writeAtomicEngineAccountsFile(engineHome, accounts) {
|
|
48819
48978
|
const shareable = accounts.map(({ restingUntil: _resting, ...account }) => account);
|
|
48820
|
-
const
|
|
48979
|
+
const text5 = `${JSON.stringify({ version: 1, accounts: shareable }, null, 2)}
|
|
48821
48980
|
`;
|
|
48822
48981
|
const path4 = join42(engineHome, ACCOUNTS_FILE);
|
|
48823
48982
|
try {
|
|
48824
|
-
if (readFileSync26(path4, "utf8") ===
|
|
48983
|
+
if (readFileSync26(path4, "utf8") === text5) return;
|
|
48825
48984
|
} catch {
|
|
48826
48985
|
}
|
|
48827
48986
|
try {
|
|
48828
48987
|
mkdirSync21(engineHome, { recursive: true, mode: 448 });
|
|
48829
|
-
writeFileSync17(path4,
|
|
48988
|
+
writeFileSync17(path4, text5, { mode: 384 });
|
|
48830
48989
|
} catch (error51) {
|
|
48831
48990
|
console.warn(`[atomic-engine] could not write ${path4}: ${error51.message}`);
|
|
48832
48991
|
}
|
|
@@ -49949,14 +50108,14 @@ var init_stringifyComment = __esm({
|
|
|
49949
50108
|
});
|
|
49950
50109
|
|
|
49951
50110
|
// node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/stringify/foldFlowLines.js
|
|
49952
|
-
function foldFlowLines(
|
|
50111
|
+
function foldFlowLines(text5, indent, mode = "flow", { indentAtStart, lineWidth = 80, minContentWidth = 20, onFold, onOverflow } = {}) {
|
|
49953
50112
|
if (!lineWidth || lineWidth < 0)
|
|
49954
|
-
return
|
|
50113
|
+
return text5;
|
|
49955
50114
|
if (lineWidth < minContentWidth)
|
|
49956
50115
|
minContentWidth = 0;
|
|
49957
50116
|
const endStep = Math.max(1 + minContentWidth, 1 + lineWidth - indent.length);
|
|
49958
|
-
if (
|
|
49959
|
-
return
|
|
50117
|
+
if (text5.length <= endStep)
|
|
50118
|
+
return text5;
|
|
49960
50119
|
const folds = [];
|
|
49961
50120
|
const escapedFolds = {};
|
|
49962
50121
|
let end = lineWidth - indent.length;
|
|
@@ -49973,14 +50132,14 @@ function foldFlowLines(text4, indent, mode = "flow", { indentAtStart, lineWidth
|
|
|
49973
50132
|
let escStart = -1;
|
|
49974
50133
|
let escEnd = -1;
|
|
49975
50134
|
if (mode === FOLD_BLOCK) {
|
|
49976
|
-
i2 = consumeMoreIndentedLines(
|
|
50135
|
+
i2 = consumeMoreIndentedLines(text5, i2, indent.length);
|
|
49977
50136
|
if (i2 !== -1)
|
|
49978
50137
|
end = i2 + endStep;
|
|
49979
50138
|
}
|
|
49980
|
-
for (let ch; ch =
|
|
50139
|
+
for (let ch; ch = text5[i2 += 1]; ) {
|
|
49981
50140
|
if (mode === FOLD_QUOTED && ch === "\\") {
|
|
49982
50141
|
escStart = i2;
|
|
49983
|
-
switch (
|
|
50142
|
+
switch (text5[i2 + 1]) {
|
|
49984
50143
|
case "x":
|
|
49985
50144
|
i2 += 3;
|
|
49986
50145
|
break;
|
|
@@ -49997,12 +50156,12 @@ function foldFlowLines(text4, indent, mode = "flow", { indentAtStart, lineWidth
|
|
|
49997
50156
|
}
|
|
49998
50157
|
if (ch === "\n") {
|
|
49999
50158
|
if (mode === FOLD_BLOCK)
|
|
50000
|
-
i2 = consumeMoreIndentedLines(
|
|
50159
|
+
i2 = consumeMoreIndentedLines(text5, i2, indent.length);
|
|
50001
50160
|
end = i2 + indent.length + endStep;
|
|
50002
50161
|
split = void 0;
|
|
50003
50162
|
} else {
|
|
50004
50163
|
if (ch === " " && prev && prev !== " " && prev !== "\n" && prev !== " ") {
|
|
50005
|
-
const next =
|
|
50164
|
+
const next = text5[i2 + 1];
|
|
50006
50165
|
if (next && next !== " " && next !== "\n" && next !== " ")
|
|
50007
50166
|
split = i2;
|
|
50008
50167
|
}
|
|
@@ -50014,12 +50173,12 @@ function foldFlowLines(text4, indent, mode = "flow", { indentAtStart, lineWidth
|
|
|
50014
50173
|
} else if (mode === FOLD_QUOTED) {
|
|
50015
50174
|
while (prev === " " || prev === " ") {
|
|
50016
50175
|
prev = ch;
|
|
50017
|
-
ch =
|
|
50176
|
+
ch = text5[i2 += 1];
|
|
50018
50177
|
overflow = true;
|
|
50019
50178
|
}
|
|
50020
50179
|
const j2 = i2 > escEnd + 1 ? i2 - 2 : escStart - 1;
|
|
50021
50180
|
if (escapedFolds[j2])
|
|
50022
|
-
return
|
|
50181
|
+
return text5;
|
|
50023
50182
|
folds.push(j2);
|
|
50024
50183
|
escapedFolds[j2] = true;
|
|
50025
50184
|
end = j2 + endStep;
|
|
@@ -50034,39 +50193,39 @@ function foldFlowLines(text4, indent, mode = "flow", { indentAtStart, lineWidth
|
|
|
50034
50193
|
if (overflow && onOverflow)
|
|
50035
50194
|
onOverflow();
|
|
50036
50195
|
if (folds.length === 0)
|
|
50037
|
-
return
|
|
50196
|
+
return text5;
|
|
50038
50197
|
if (onFold)
|
|
50039
50198
|
onFold();
|
|
50040
|
-
let res =
|
|
50199
|
+
let res = text5.slice(0, folds[0]);
|
|
50041
50200
|
for (let i3 = 0; i3 < folds.length; ++i3) {
|
|
50042
50201
|
const fold = folds[i3];
|
|
50043
|
-
const end2 = folds[i3 + 1] ||
|
|
50202
|
+
const end2 = folds[i3 + 1] || text5.length;
|
|
50044
50203
|
if (fold === 0)
|
|
50045
50204
|
res = `
|
|
50046
|
-
${indent}${
|
|
50205
|
+
${indent}${text5.slice(0, end2)}`;
|
|
50047
50206
|
else {
|
|
50048
50207
|
if (mode === FOLD_QUOTED && escapedFolds[fold])
|
|
50049
|
-
res += `${
|
|
50208
|
+
res += `${text5[fold]}\\`;
|
|
50050
50209
|
res += `
|
|
50051
|
-
${indent}${
|
|
50210
|
+
${indent}${text5.slice(fold + 1, end2)}`;
|
|
50052
50211
|
}
|
|
50053
50212
|
}
|
|
50054
50213
|
return res;
|
|
50055
50214
|
}
|
|
50056
|
-
function consumeMoreIndentedLines(
|
|
50215
|
+
function consumeMoreIndentedLines(text5, i2, indent) {
|
|
50057
50216
|
let end = i2;
|
|
50058
50217
|
let start = i2 + 1;
|
|
50059
|
-
let ch =
|
|
50218
|
+
let ch = text5[start];
|
|
50060
50219
|
while (ch === " " || ch === " ") {
|
|
50061
50220
|
if (i2 < start + indent) {
|
|
50062
|
-
ch =
|
|
50221
|
+
ch = text5[++i2];
|
|
50063
50222
|
} else {
|
|
50064
50223
|
do {
|
|
50065
|
-
ch =
|
|
50224
|
+
ch = text5[++i2];
|
|
50066
50225
|
} while (ch && ch !== "\n");
|
|
50067
50226
|
end = i2;
|
|
50068
50227
|
start = i2 + 1;
|
|
50069
|
-
ch =
|
|
50228
|
+
ch = text5[start];
|
|
50070
50229
|
}
|
|
50071
50230
|
}
|
|
50072
50231
|
return end;
|
|
@@ -55922,10 +56081,10 @@ function readText2(path4) {
|
|
|
55922
56081
|
return null;
|
|
55923
56082
|
}
|
|
55924
56083
|
}
|
|
55925
|
-
function parseYamlSafe(
|
|
55926
|
-
if (
|
|
56084
|
+
function parseYamlSafe(text5) {
|
|
56085
|
+
if (text5 === null) return null;
|
|
55927
56086
|
try {
|
|
55928
|
-
return parse3(
|
|
56087
|
+
return parse3(text5);
|
|
55929
56088
|
} catch {
|
|
55930
56089
|
return null;
|
|
55931
56090
|
}
|
|
@@ -55975,7 +56134,7 @@ var init_hermes_memory_lock = __esm({
|
|
|
55975
56134
|
// server/drivers/acp/hermes.ts
|
|
55976
56135
|
import { spawn as spawn7 } from "node:child_process";
|
|
55977
56136
|
import { mkdirSync as mkdirSync24, readFileSync as readFileSync29, writeFileSync as writeFileSync20 } from "node:fs";
|
|
55978
|
-
import { homedir as
|
|
56137
|
+
import { homedir as homedir25 } from "node:os";
|
|
55979
56138
|
import { join as join45 } from "node:path";
|
|
55980
56139
|
function bindHermesScreenshotCompat(env, modelId) {
|
|
55981
56140
|
delete env[HERMES_OPENMAUS_SCREENSHOT_COMPAT];
|
|
@@ -55986,30 +56145,30 @@ function bindHermesScreenshotCompat(env, modelId) {
|
|
|
55986
56145
|
env[HERMES_OPENMAUS_SCREENSHOT_COMPAT_MODEL] = inject.model;
|
|
55987
56146
|
}
|
|
55988
56147
|
function hermesHome(env) {
|
|
55989
|
-
return env.HERMES_HOME || join45(env.HOME || env.USERPROFILE ||
|
|
56148
|
+
return env.HERMES_HOME || join45(env.HOME || env.USERPROFILE || homedir25(), ".hermes");
|
|
55990
56149
|
}
|
|
55991
56150
|
function quoteYaml(value) {
|
|
55992
56151
|
if (/^[\w./:+-]+$/.test(value)) return value;
|
|
55993
56152
|
return JSON.stringify(value);
|
|
55994
56153
|
}
|
|
55995
|
-
function upsertHermesProvider(
|
|
56154
|
+
function upsertHermesProvider(text5, hostId, baseUrl, apiKey) {
|
|
55996
56155
|
const block2 = [` ${hostId}:`, ` base_url: ${quoteYaml(baseUrl)}`, ` api_key: ${quoteYaml(apiKey)}`, ""].join(
|
|
55997
56156
|
"\n"
|
|
55998
56157
|
);
|
|
55999
|
-
if (/^providers:\s*$/m.test(
|
|
56000
|
-
const replaced = replaceHermesHostBlock(
|
|
56158
|
+
if (/^providers:\s*$/m.test(text5)) {
|
|
56159
|
+
const replaced = replaceHermesHostBlock(text5, hostId, block2);
|
|
56001
56160
|
if (replaced !== null) return replaced;
|
|
56002
|
-
return
|
|
56161
|
+
return text5.replace(/^providers:\s*$/m, `providers:
|
|
56003
56162
|
${block2.trimEnd()}`);
|
|
56004
56163
|
}
|
|
56005
|
-
const prefix =
|
|
56006
|
-
` :
|
|
56164
|
+
const prefix = text5 && !text5.endsWith("\n") ? `${text5}
|
|
56165
|
+
` : text5;
|
|
56007
56166
|
return `${prefix}
|
|
56008
56167
|
providers:
|
|
56009
56168
|
${block2}`;
|
|
56010
56169
|
}
|
|
56011
|
-
function replaceHermesHostBlock(
|
|
56012
|
-
const lines =
|
|
56170
|
+
function replaceHermesHostBlock(text5, hostId, block2) {
|
|
56171
|
+
const lines = text5.split("\n");
|
|
56013
56172
|
const start = lines.findIndex((line) => line === ` ${hostId}:`);
|
|
56014
56173
|
if (start < 0) return null;
|
|
56015
56174
|
let end = start + 1;
|
|
@@ -56029,14 +56188,14 @@ function ensureHermesInjectProvider(modelId, env = process.env, home = hermesHom
|
|
|
56029
56188
|
const dir = home;
|
|
56030
56189
|
mkdirSync24(dir, { recursive: true });
|
|
56031
56190
|
const path4 = join45(dir, "config.yaml");
|
|
56032
|
-
let
|
|
56191
|
+
let text5 = "";
|
|
56033
56192
|
try {
|
|
56034
|
-
|
|
56193
|
+
text5 = readFileSync29(path4, "utf8");
|
|
56035
56194
|
} catch {
|
|
56036
|
-
|
|
56195
|
+
text5 = "";
|
|
56037
56196
|
}
|
|
56038
|
-
const next = upsertHermesProvider(
|
|
56039
|
-
if (next !==
|
|
56197
|
+
const next = upsertHermesProvider(text5, inject.host, host.baseUrl, hostApiKey(host, env));
|
|
56198
|
+
if (next !== text5) writeFileSync20(path4, next);
|
|
56040
56199
|
return hermesAcpModelId(modelId) ?? modelId;
|
|
56041
56200
|
}
|
|
56042
56201
|
function hermesAcpModelId(modelId) {
|
|
@@ -56046,8 +56205,8 @@ function hermesAcpModelId(modelId) {
|
|
|
56046
56205
|
if (native && !native.includes(INJECT_SEP) && /^[a-z0-9_-]+:[\w./:-]+$/i.test(native)) return native;
|
|
56047
56206
|
return null;
|
|
56048
56207
|
}
|
|
56049
|
-
function nonEmptyDotenvValue(
|
|
56050
|
-
const match = new RegExp(`^[ \\t]*(?:export[ \\t]+)?${name}[ \\t]*=[ \\t]*([^\\r\\n]*)$`, "m").exec(
|
|
56208
|
+
function nonEmptyDotenvValue(text5, name) {
|
|
56209
|
+
const match = new RegExp(`^[ \\t]*(?:export[ \\t]+)?${name}[ \\t]*=[ \\t]*([^\\r\\n]*)$`, "m").exec(text5);
|
|
56051
56210
|
if (!match) return null;
|
|
56052
56211
|
const raw = match[1].trim();
|
|
56053
56212
|
if (!raw || raw.startsWith("#")) return null;
|
|
@@ -56064,10 +56223,10 @@ function nonEmptyDotenvValue(text4, name) {
|
|
|
56064
56223
|
function yamlString(value) {
|
|
56065
56224
|
return typeof value === "string" ? value.trim() : "";
|
|
56066
56225
|
}
|
|
56067
|
-
function hermesConfigDefault(
|
|
56226
|
+
function hermesConfigDefault(text5) {
|
|
56068
56227
|
let raw;
|
|
56069
56228
|
try {
|
|
56070
|
-
raw = parse3(
|
|
56229
|
+
raw = parse3(text5);
|
|
56071
56230
|
} catch {
|
|
56072
56231
|
return null;
|
|
56073
56232
|
}
|
|
@@ -56300,7 +56459,7 @@ async function fetchHermesAcpModels(cli, env) {
|
|
|
56300
56459
|
}
|
|
56301
56460
|
if (msg?.id === initId) {
|
|
56302
56461
|
if (!msg.result) return done([]);
|
|
56303
|
-
sessionId = send("session/new", { cwd: env.HOME || env.USERPROFILE ||
|
|
56462
|
+
sessionId = send("session/new", { cwd: env.HOME || env.USERPROFILE || homedir25(), mcpServers: [] });
|
|
56304
56463
|
} else if (sessionId && msg?.id === sessionId) {
|
|
56305
56464
|
const list = Array.isArray(msg.result?.models?.availableModels) ? msg.result.models.availableModels : [];
|
|
56306
56465
|
done(
|
|
@@ -56436,7 +56595,7 @@ ${turn.text}` : turn.text
|
|
|
56436
56595
|
});
|
|
56437
56596
|
|
|
56438
56597
|
// server/drivers/acp/custom.ts
|
|
56439
|
-
import { homedir as
|
|
56598
|
+
import { homedir as homedir26 } from "node:os";
|
|
56440
56599
|
import { basename as basename9, join as join46 } from "node:path";
|
|
56441
56600
|
function isAtomicEngine(instanceId, cli) {
|
|
56442
56601
|
const program = (cli ?? "").trim().split(/\s+/)[0] ?? "";
|
|
@@ -56462,7 +56621,7 @@ async function customAcpSnapshot(env, cli, instanceId) {
|
|
|
56462
56621
|
return { state: "available", version: version2, authenticated: true };
|
|
56463
56622
|
}
|
|
56464
56623
|
function atomicEngineHome2(env) {
|
|
56465
|
-
return env.HERMES_HOME || join46(env.HOME || env.USERPROFILE ||
|
|
56624
|
+
return env.HERMES_HOME || join46(env.HOME || env.USERPROFILE || homedir26(), ".atomic");
|
|
56466
56625
|
}
|
|
56467
56626
|
function applyAtomicEngineAccounts(env, instanceId, cli, accounts = currentAtomicEngineAccounts) {
|
|
56468
56627
|
if (!isAtomicEngine(instanceId, cli)) return;
|
|
@@ -56694,7 +56853,7 @@ var init_ollama_cloud = __esm({
|
|
|
56694
56853
|
nativeLog: {
|
|
56695
56854
|
source: "ollama-cloud.chat.completions",
|
|
56696
56855
|
outgoing: (_turn, messages, model) => ({ model, messageCount: messages.length }),
|
|
56697
|
-
incoming: ({ text:
|
|
56856
|
+
incoming: ({ text: text5, reasoning, usage }) => ({ textLength: text5.length, reasoningLength: reasoning.length, usage })
|
|
56698
56857
|
}
|
|
56699
56858
|
});
|
|
56700
56859
|
}
|
|
@@ -56850,8 +57009,8 @@ var init_openai_compat = __esm({
|
|
|
56850
57009
|
nativeLog: {
|
|
56851
57010
|
source: "openai-compat.chat.completions",
|
|
56852
57011
|
outgoing: (_turn, messages, model) => ({ model, messageCount: messages.length }),
|
|
56853
|
-
incoming: ({ text:
|
|
56854
|
-
textLength:
|
|
57012
|
+
incoming: ({ text: text5, reasoning, usage }) => ({
|
|
57013
|
+
textLength: text5.length,
|
|
56855
57014
|
reasoningLength: reasoning.length,
|
|
56856
57015
|
usage
|
|
56857
57016
|
})
|
|
@@ -56864,7 +57023,7 @@ var init_openai_compat = __esm({
|
|
|
56864
57023
|
|
|
56865
57024
|
// server/drivers/pi.ts
|
|
56866
57025
|
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
|
|
57026
|
+
import { homedir as homedir27, tmpdir as tmpdir6 } from "node:os";
|
|
56868
57027
|
import { join as join47 } from "node:path";
|
|
56869
57028
|
function readPiPromptImages(turn) {
|
|
56870
57029
|
return (turn.images ?? []).map((image) => ({
|
|
@@ -56987,7 +57146,7 @@ async function applyPiLocalCatalog(catalog2, env = process.env, fetchImpl = fetc
|
|
|
56987
57146
|
return preferPiInjectRows(await mergeLocalInject(catalog2, env, fetchImpl));
|
|
56988
57147
|
}
|
|
56989
57148
|
function piAgentDir(env) {
|
|
56990
|
-
return join47(env.HOME || env.USERPROFILE ||
|
|
57149
|
+
return join47(env.HOME || env.USERPROFILE || homedir27(), ".pi", "agent");
|
|
56991
57150
|
}
|
|
56992
57151
|
function ensurePiInjectModel(modelId, env = process.env) {
|
|
56993
57152
|
const split = splitPiModel(modelId);
|
|
@@ -57052,7 +57211,7 @@ function ensurePiInjectModel(modelId, env = process.env) {
|
|
|
57052
57211
|
return split;
|
|
57053
57212
|
}
|
|
57054
57213
|
function readPiDefaultModel(env) {
|
|
57055
|
-
const home = env.HOME || env.USERPROFILE ||
|
|
57214
|
+
const home = env.HOME || env.USERPROFILE || homedir27();
|
|
57056
57215
|
try {
|
|
57057
57216
|
const s4 = JSON.parse(readFileSync30(`${home}/.pi/agent/settings.json`, "utf8"));
|
|
57058
57217
|
return s4.defaultProvider && s4.defaultModel ? `${s4.defaultProvider}/${s4.defaultModel}` : "";
|
|
@@ -57276,10 +57435,10 @@ var init_pi = __esm({
|
|
|
57276
57435
|
child.stdin.write(JSON.stringify(obj) + "\n");
|
|
57277
57436
|
};
|
|
57278
57437
|
const flushAssistantText = () => {
|
|
57279
|
-
const
|
|
57438
|
+
const text5 = assistantText;
|
|
57280
57439
|
assistantText = "";
|
|
57281
|
-
if (!
|
|
57282
|
-
emit({ ...base2(threadId, turnId), type: "item.completed", itemType: "assistant_text", text:
|
|
57440
|
+
if (!text5.trim()) return;
|
|
57441
|
+
emit({ ...base2(threadId, turnId), type: "item.completed", itemType: "assistant_text", text: text5 });
|
|
57283
57442
|
};
|
|
57284
57443
|
const settle = (ok, stopReason, usage) => {
|
|
57285
57444
|
if (settled) return;
|
|
@@ -57710,7 +57869,7 @@ var init_mistral = __esm({
|
|
|
57710
57869
|
nativeLog: {
|
|
57711
57870
|
source: "mistral.chat.completions",
|
|
57712
57871
|
outgoing: (_turn, messages, model) => ({ model, messageCount: messages.length }),
|
|
57713
|
-
incoming: ({ text:
|
|
57872
|
+
incoming: ({ text: text5, usage }) => ({ textLength: text5.length, usage })
|
|
57714
57873
|
}
|
|
57715
57874
|
});
|
|
57716
57875
|
}
|
|
@@ -57720,13 +57879,13 @@ var init_mistral = __esm({
|
|
|
57720
57879
|
|
|
57721
57880
|
// server/drivers/minimax.ts
|
|
57722
57881
|
import { readFileSync as readFileSync31 } from "node:fs";
|
|
57723
|
-
import { homedir as
|
|
57882
|
+
import { homedir as homedir28 } from "node:os";
|
|
57724
57883
|
import { join as join48 } from "node:path";
|
|
57725
57884
|
function normalizedApiUrl(value) {
|
|
57726
57885
|
const root = value.trim().replace(/\/+$/, "");
|
|
57727
57886
|
return root.endsWith("/v1") ? root : `${root}/v1`;
|
|
57728
57887
|
}
|
|
57729
|
-
function loadLocalMiniMaxConfig(home =
|
|
57888
|
+
function loadLocalMiniMaxConfig(home = homedir28()) {
|
|
57730
57889
|
try {
|
|
57731
57890
|
const raw = localConfigSchema.parse(JSON.parse(readFileSync31(join48(home, ".mmx", "config.json"), "utf8")));
|
|
57732
57891
|
const configuredUrl = raw.base_url?.trim() ? raw.base_url : raw.region === "cn" ? CN_URL : DEFAULT_URL3;
|
|
@@ -57824,7 +57983,7 @@ var init_minimax = __esm({
|
|
|
57824
57983
|
nativeLog: {
|
|
57825
57984
|
source: "minimax.chat.completions",
|
|
57826
57985
|
outgoing: (_turn, messages, model) => ({ model, messageCount: messages.length }),
|
|
57827
|
-
incoming: ({ text:
|
|
57986
|
+
incoming: ({ text: text5, usage }) => ({ textLength: text5.length, usage })
|
|
57828
57987
|
}
|
|
57829
57988
|
});
|
|
57830
57989
|
}
|
|
@@ -58103,9 +58262,9 @@ function createAppleIntelligenceInstance(input, deps = {}) {
|
|
|
58103
58262
|
let failure;
|
|
58104
58263
|
try {
|
|
58105
58264
|
const request = shapeRequest(turn, inputBudget(availability.contextSize));
|
|
58106
|
-
const
|
|
58107
|
-
if (!
|
|
58108
|
-
emit({ ...base2(turn.threadId, turnId), type: "item.completed", itemType: "assistant_text", text:
|
|
58265
|
+
const text5 = await client.stream(request, (delta) => emit({ ...base2(turn.threadId, turnId), type: "content.delta", streamKind: "assistant_text", delta }), abort.signal);
|
|
58266
|
+
if (!text5.trim()) throw new Error("Apple Intelligence returned an empty response.");
|
|
58267
|
+
emit({ ...base2(turn.threadId, turnId), type: "item.completed", itemType: "assistant_text", text: text5 });
|
|
58109
58268
|
ok = true;
|
|
58110
58269
|
} catch (error51) {
|
|
58111
58270
|
failure = error51 instanceof Error ? error51.message : String(error51);
|
|
@@ -58182,10 +58341,10 @@ var init_apple_intelligence2 = __esm({
|
|
|
58182
58341
|
INPUT_TOKEN_BUDGET = 6e3;
|
|
58183
58342
|
REPLY_TOKENS = 1500;
|
|
58184
58343
|
CHARS_PER_TOKEN = 4;
|
|
58185
|
-
estimateTokens = (
|
|
58186
|
-
clip = (
|
|
58344
|
+
estimateTokens = (text5) => Math.ceil(text5.length / CHARS_PER_TOKEN);
|
|
58345
|
+
clip = (text5, tokens) => {
|
|
58187
58346
|
const chars = Math.max(0, tokens * CHARS_PER_TOKEN);
|
|
58188
|
-
return
|
|
58347
|
+
return text5.length <= chars ? text5 : `${text5.slice(0, Math.max(0, chars - 1))}\u2026`;
|
|
58189
58348
|
};
|
|
58190
58349
|
configSchema4 = external_exports.object({}).passthrough();
|
|
58191
58350
|
AppleIntelligenceDriver = {
|
|
@@ -58840,7 +58999,7 @@ __export(browser_engine_exports, {
|
|
|
58840
58999
|
});
|
|
58841
59000
|
import { createHash as createHash16, randomBytes as randomBytes3, randomUUID as randomUUID17 } from "node:crypto";
|
|
58842
59001
|
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
|
|
59002
|
+
import { homedir as homedir29, tmpdir as tmpdir7 } from "node:os";
|
|
58844
59003
|
import { delimiter as delimiter7, dirname as dirname12, join as join53, resolve as resolve12 } from "node:path";
|
|
58845
59004
|
function browserRestoreKey(session) {
|
|
58846
59005
|
if (!/^[A-Za-z0-9_.-]{1,96}$/.test(session)) throw new Error("Invalid browser session.");
|
|
@@ -58849,7 +59008,7 @@ function browserRestoreKey(session) {
|
|
|
58849
59008
|
function browserSessionsDirectory(env) {
|
|
58850
59009
|
const namespace = env.AGENT_BROWSER_NAMESPACE;
|
|
58851
59010
|
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) ||
|
|
59011
|
+
const home = (process.platform === "win32" ? env.USERPROFILE : env.HOME) || homedir29();
|
|
58853
59012
|
const stateRoot = namespace ? join53(home, ".agent-browser", "namespaces", namespace, "state") : join53(home, ".agent-browser");
|
|
58854
59013
|
return join53(stateRoot, "sessions");
|
|
58855
59014
|
}
|
|
@@ -59405,7 +59564,7 @@ var import_qrcode_terminal = __toESM(require_main(), 1);
|
|
|
59405
59564
|
import { spawn as spawn10 } from "node:child_process";
|
|
59406
59565
|
import { randomBytes as randomBytes4 } from "node:crypto";
|
|
59407
59566
|
import { closeSync as closeSync6, existsSync as existsSync26, mkdirSync as mkdirSync27, openSync as openSync6, readFileSync as readFileSync34 } from "node:fs";
|
|
59408
|
-
import { homedir as
|
|
59567
|
+
import { homedir as homedir30 } from "node:os";
|
|
59409
59568
|
import { dirname as dirname13, join as join54, resolve as resolve13 } from "node:path";
|
|
59410
59569
|
import { createInterface as createInterface2 } from "node:readline/promises";
|
|
59411
59570
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
@@ -60039,10 +60198,10 @@ async function verifyHostedEndpoint(endpoint, { fetchImpl, timeoutSignal, timeou
|
|
|
60039
60198
|
signal: cancellationSignal ? AbortSignal.any([requestSignal, cancellationSignal]) : requestSignal
|
|
60040
60199
|
});
|
|
60041
60200
|
if (!response.ok) return false;
|
|
60042
|
-
const
|
|
60043
|
-
if (Buffer.byteLength(
|
|
60201
|
+
const text5 = await response.text();
|
|
60202
|
+
if (Buffer.byteLength(text5) > 4096) return false;
|
|
60044
60203
|
try {
|
|
60045
|
-
return JSON.parse(
|
|
60204
|
+
return JSON.parse(text5)?.app === "openmausbot";
|
|
60046
60205
|
} catch {
|
|
60047
60206
|
return false;
|
|
60048
60207
|
}
|
|
@@ -60955,8 +61114,8 @@ function isSecretParameter(name) {
|
|
|
60955
61114
|
function keyLikeSegment(segment) {
|
|
60956
61115
|
return (segment.match(/[A-Za-z0-9]{16,}/g) ?? []).some((run2) => /\d/.test(run2) && /[A-Za-z]/.test(run2));
|
|
60957
61116
|
}
|
|
60958
|
-
function maskUrlSecrets(
|
|
60959
|
-
return
|
|
61117
|
+
function maskUrlSecrets(text5) {
|
|
61118
|
+
return text5.replace(/\b([a-z][\w+.-]*:\/\/)([^\s/?#]*)([^\s?#]*)([^\s]*)/gi, (_all, scheme, authority, path4, rest) => {
|
|
60960
61119
|
const at2 = authority.lastIndexOf("@");
|
|
60961
61120
|
const host = at2 >= 0 ? `${HIDDEN}@${authority.slice(at2 + 1)}` : authority;
|
|
60962
61121
|
const maskedPath = path4.split("/").map((segment) => keyLikeSegment(segment) ? HIDDEN : segment).join("/");
|
|
@@ -60994,8 +61153,8 @@ function auditValues(values) {
|
|
|
60994
61153
|
const last = segments.at(-1) ?? path4;
|
|
60995
61154
|
const opaque = segments.slice(0, -1).some((segment) => OPAQUE_MAP.test(segment));
|
|
60996
61155
|
const scrubbed = (isSecretName2(last) || opaque) && value !== void 0 && value !== null && value !== "" ? HIDDEN : scrub(value, 0, OPAQUE_MAP.test(last));
|
|
60997
|
-
const
|
|
60998
|
-
out[path4] =
|
|
61156
|
+
const text5 = JSON.stringify(scrubbed);
|
|
61157
|
+
out[path4] = text5 !== void 0 && text5.length > MAX_VALUE_CHARS ? "[large value]" : scrubbed ?? null;
|
|
60999
61158
|
}
|
|
61000
61159
|
return out;
|
|
61001
61160
|
}
|
|
@@ -61180,9 +61339,9 @@ async function startCaddy(options) {
|
|
|
61180
61339
|
});
|
|
61181
61340
|
let output = "";
|
|
61182
61341
|
const receive = (chunk) => {
|
|
61183
|
-
const
|
|
61184
|
-
if (output.length < 16384) output +=
|
|
61185
|
-
for (const line of
|
|
61342
|
+
const text5 = chunk.toString("utf8");
|
|
61343
|
+
if (output.length < 16384) output += text5;
|
|
61344
|
+
for (const line of text5.split(/\r?\n/)) {
|
|
61186
61345
|
if (!line.trim()) continue;
|
|
61187
61346
|
if (/"level":"(warn|error)"/.test(line) || /^\S+\s+(WARN|ERROR)/.test(line) || !line.startsWith("{")) options.log?.(`caddy: ${line.slice(0, 400)}`);
|
|
61188
61347
|
}
|
|
@@ -61534,16 +61693,16 @@ var TEXT_COLORS = {
|
|
|
61534
61693
|
dark: { accent: [[0, 179, 152], 36], gold: [[242, 169, 0], 214] },
|
|
61535
61694
|
unknown: { accent: [[0, 128, 108], 30], gold: [[168, 100, 0], 130] }
|
|
61536
61695
|
};
|
|
61537
|
-
function paint(
|
|
61538
|
-
if (depth === "none") return
|
|
61696
|
+
function paint(text5, role, depth, background, bold) {
|
|
61697
|
+
if (depth === "none") return text5;
|
|
61539
61698
|
const weight = bold ? "1;" : "";
|
|
61540
|
-
if (depth === "16") return `\x1B[${weight}${role === "accent" ? 36 : 33}m${
|
|
61699
|
+
if (depth === "16") return `\x1B[${weight}${role === "accent" ? 36 : 33}m${text5}\x1B[0m`;
|
|
61541
61700
|
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${
|
|
61701
|
+
if (depth === "256") return `\x1B[${weight}38;5;${index}m${text5}\x1B[0m`;
|
|
61702
|
+
return `\x1B[${weight}38;2;${triple.join(";")}m${text5}\x1B[0m`;
|
|
61544
61703
|
}
|
|
61545
|
-
function quiet(
|
|
61546
|
-
return depth === "none" ?
|
|
61704
|
+
function quiet(text5, depth) {
|
|
61705
|
+
return depth === "none" ? text5 : `\x1B[2m${text5}\x1B[0m`;
|
|
61547
61706
|
}
|
|
61548
61707
|
function renderBanner(input) {
|
|
61549
61708
|
const random = input.random ?? Math.random;
|
|
@@ -61551,7 +61710,7 @@ function renderBanner(input) {
|
|
|
61551
61710
|
const greeting = pick2(GREETINGS);
|
|
61552
61711
|
const tip = pick2(TIPS);
|
|
61553
61712
|
const { depth, background } = input;
|
|
61554
|
-
const
|
|
61713
|
+
const text5 = [
|
|
61555
61714
|
`${paint("Atomic", "accent", depth, background, true)} by Chibitek`,
|
|
61556
61715
|
quiet(`Version ${input.version}`, depth),
|
|
61557
61716
|
input.account ? `Signed in as ${input.account}` : quiet("Not signed in to an Atomic account", depth),
|
|
@@ -61560,19 +61719,19 @@ function renderBanner(input) {
|
|
|
61560
61719
|
`${paint("Tip:", "gold", depth, background, true)} ${tip}`
|
|
61561
61720
|
];
|
|
61562
61721
|
const columns = input.columns ?? 80;
|
|
61563
|
-
if (columns < 20) return `${
|
|
61722
|
+
if (columns < 20) return `${text5.join("\n")}
|
|
61564
61723
|
`;
|
|
61565
61724
|
const mark = chibiAnsiLines(depth, background === "light" ? "light" : "dark");
|
|
61566
61725
|
const widest = Math.max(...[greeting, `Tip: ${tip}`, input.account ? `Signed in as ${input.account}` : ""].map((l) => l.length));
|
|
61567
61726
|
if (columns < 16 + 3 + Math.min(widest, 44)) return `${mark.map((line) => line.trimEnd()).join("\n")}
|
|
61568
61727
|
|
|
61569
|
-
${
|
|
61728
|
+
${text5.join("\n")}
|
|
61570
61729
|
`;
|
|
61571
|
-
const rows = Math.max(mark.length,
|
|
61730
|
+
const rows = Math.max(mark.length, text5.length);
|
|
61572
61731
|
const lines = [];
|
|
61573
61732
|
for (let i2 = 0; i2 < rows; i2 += 1) {
|
|
61574
61733
|
const left = mark[i2] ?? " ".repeat(16);
|
|
61575
|
-
const right =
|
|
61734
|
+
const right = text5[i2] ?? "";
|
|
61576
61735
|
lines.push(right ? `${left} ${right}` : left.trimEnd());
|
|
61577
61736
|
}
|
|
61578
61737
|
return `${lines.join("\n")}
|
|
@@ -61658,8 +61817,8 @@ function agentUnit(spec) {
|
|
|
61658
61817
|
function emptyRegistry(domain2) {
|
|
61659
61818
|
return { version: 1, domain: domain2, nextPort: FLEET_FIRST_PORT, workspaces: {} };
|
|
61660
61819
|
}
|
|
61661
|
-
function parseRegistry(
|
|
61662
|
-
const value = JSON.parse(
|
|
61820
|
+
function parseRegistry(text5) {
|
|
61821
|
+
const value = JSON.parse(text5);
|
|
61663
61822
|
const record6 = value && typeof value === "object" ? value : null;
|
|
61664
61823
|
if (!record6 || record6.version !== 1 || typeof record6.domain !== "string" || typeof record6.nextPort !== "number" || !record6.workspaces || typeof record6.workspaces !== "object") {
|
|
61665
61824
|
throw new Error("fleet.json is not a fleet registry this version understands");
|
|
@@ -62269,9 +62428,9 @@ function failed(io2, what, output) {
|
|
|
62269
62428
|
return 1;
|
|
62270
62429
|
}
|
|
62271
62430
|
function loadRegistry(layout, deps) {
|
|
62272
|
-
const
|
|
62273
|
-
if (
|
|
62274
|
-
return parseRegistry(
|
|
62431
|
+
const text5 = deps.readText(layout.registryFile);
|
|
62432
|
+
if (text5 === null) throw new Error(`no fleet on this server yet: run \`chibi fleet init --domain your.domain\` first`);
|
|
62433
|
+
return parseRegistry(text5);
|
|
62275
62434
|
}
|
|
62276
62435
|
function planFleetAction(input, deps) {
|
|
62277
62436
|
const layout = fleetLayout(input.root ?? "/");
|
|
@@ -62445,15 +62604,15 @@ import { dirname as dirname3 } from "node:path";
|
|
|
62445
62604
|
var MAX_BODY = 256 * 1024;
|
|
62446
62605
|
function readBody(req) {
|
|
62447
62606
|
return new Promise((resolve14, reject) => {
|
|
62448
|
-
let
|
|
62607
|
+
let text5 = "";
|
|
62449
62608
|
req.on("data", (chunk) => {
|
|
62450
|
-
|
|
62451
|
-
if (
|
|
62609
|
+
text5 += chunk.toString("utf8");
|
|
62610
|
+
if (text5.length > MAX_BODY) reject(Object.assign(new Error("request too large"), { status: 413 }));
|
|
62452
62611
|
});
|
|
62453
62612
|
req.on("end", () => {
|
|
62454
|
-
if (!
|
|
62613
|
+
if (!text5.trim()) return resolve14({});
|
|
62455
62614
|
try {
|
|
62456
|
-
const value = JSON.parse(
|
|
62615
|
+
const value = JSON.parse(text5);
|
|
62457
62616
|
resolve14(value && typeof value === "object" && !Array.isArray(value) ? value : {});
|
|
62458
62617
|
} catch {
|
|
62459
62618
|
reject(Object.assign(new Error("body must be JSON"), { status: 400 }));
|
|
@@ -62670,8 +62829,8 @@ function tailnetNameBlocksHttps(name) {
|
|
|
62670
62829
|
|
|
62671
62830
|
// server/tailscale.ts
|
|
62672
62831
|
init_procs();
|
|
62673
|
-
function classifyTailscaleStderr(
|
|
62674
|
-
const t2 =
|
|
62832
|
+
function classifyTailscaleStderr(text5) {
|
|
62833
|
+
const t2 = text5.toLowerCase();
|
|
62675
62834
|
if (/not logged in|logged out|needs login|please log in/.test(t2)) return "not-logged-in";
|
|
62676
62835
|
if (/is tailscale running|tailscaled is not running|connection refused|failed to connect to local tailscaled/.test(t2)) return "not-running";
|
|
62677
62836
|
if (/rejectedidentifier|reserved format|r-ldh/.test(t2)) return "reserved-name";
|
|
@@ -63126,7 +63285,7 @@ function parseArgs2(argv, env = process.env) {
|
|
|
63126
63285
|
const options = {
|
|
63127
63286
|
command: command === "--help" || command === "-h" ? "help" : command,
|
|
63128
63287
|
port: Number(env.OMB_PORT || 8799),
|
|
63129
|
-
dataDir: env.OMB_DATA_DIR || join54(
|
|
63288
|
+
dataDir: env.OMB_DATA_DIR || join54(homedir30(), ".atomic-app"),
|
|
63130
63289
|
tailscale: false,
|
|
63131
63290
|
tunnel: false,
|
|
63132
63291
|
client: false,
|
|
@@ -63377,9 +63536,9 @@ function originOf(link) {
|
|
|
63377
63536
|
return null;
|
|
63378
63537
|
}
|
|
63379
63538
|
}
|
|
63380
|
-
function qrToString(
|
|
63539
|
+
function qrToString(text5) {
|
|
63381
63540
|
let out = "";
|
|
63382
|
-
import_qrcode_terminal.default.generate(
|
|
63541
|
+
import_qrcode_terminal.default.generate(text5, { small: true }, (rendered) => {
|
|
63383
63542
|
out = rendered;
|
|
63384
63543
|
});
|
|
63385
63544
|
return out;
|
|
@@ -63722,7 +63881,7 @@ async function runServe(options, log = console.log) {
|
|
|
63722
63881
|
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
63882
|
return 1;
|
|
63724
63883
|
}
|
|
63725
|
-
if (await reportBusyPort(options.port, options.dataDir === join54(
|
|
63884
|
+
if (await reportBusyPort(options.port, options.dataDir === join54(homedir30(), ".atomic-app") ? "" : ` --data-dir ${options.dataDir}`)) return 1;
|
|
63726
63885
|
let publicUrl = options.publicUrl;
|
|
63727
63886
|
let tailscale = null;
|
|
63728
63887
|
if (options.tailscale) {
|
|
@@ -63990,7 +64149,7 @@ async function runOnboardingCommand(options, io2 = defaultIo(), startServer = ru
|
|
|
63990
64149
|
saveCliStartup2(options.dataDir, startupPreferences(launch));
|
|
63991
64150
|
}
|
|
63992
64151
|
if (options.command === "setup") {
|
|
63993
|
-
const flags = [options.dataDir !== join54(
|
|
64152
|
+
const flags = [options.dataDir !== join54(homedir30(), ".atomic-app") && ` --data-dir ${options.dataDir}`, options.port !== 8799 && ` --port ${options.port}`].filter(Boolean).join("");
|
|
63994
64153
|
io2.log(`
|
|
63995
64154
|
All set. Start with: chibi${flags ? ` start${flags}` : ""} (or npx @chibitek/chibi without a global install).`);
|
|
63996
64155
|
return 0;
|
|
@@ -64030,15 +64189,15 @@ ${welcomeBanner(options)}
|
|
|
64030
64189
|
switch (options.command) {
|
|
64031
64190
|
case "command":
|
|
64032
64191
|
case "goal": {
|
|
64033
|
-
const
|
|
64034
|
-
const roomGoal = options.groupId ? /^\/goal(?:\s+([\s\S]*))?$/.exec(
|
|
64192
|
+
const text5 = options.command === "goal" ? `/goal ${options.commandText}` : options.commandText;
|
|
64193
|
+
const roomGoal = options.groupId ? /^\/goal(?:\s+([\s\S]*))?$/.exec(text5 ?? "") : null;
|
|
64035
64194
|
if (roomGoal && (!roomGoal[1]?.trim() || (roomGoal[1].startsWith("--") || /^(status|pause|resume|stop|help)(?:\s|$)/.test(roomGoal[1])))) {
|
|
64036
64195
|
console.error("Room goals accept an objective. Personal goal controls and budgets require --bot.");
|
|
64037
64196
|
return 2;
|
|
64038
64197
|
}
|
|
64039
64198
|
const result = await api(options.port, `/api/${options.groupId ? "groups" : "bots"}/${encodeURIComponent(options.groupId ?? options.botId)}/messages`, {
|
|
64040
64199
|
method: "POST",
|
|
64041
|
-
body: JSON.stringify({ threadId: options.threadId, text: roomGoal ? roomGoal[1] :
|
|
64200
|
+
body: JSON.stringify({ threadId: options.threadId, text: roomGoal ? roomGoal[1] : text5, ...roomGoal ? { mode: "goal" } : {}, sendId: randomBytes4(16).toString("hex") })
|
|
64042
64201
|
});
|
|
64043
64202
|
if (result.status >= 400) {
|
|
64044
64203
|
console.error(result.body.error ?? `Server returned ${result.status}`);
|