openmausbot 0.1.74 → 0.1.75
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/{index-CwoQdM0z.js → index-BTlyRwLl.js} +1 -1
- package/dist/assets/index-CeMbvsgx.js +305 -0
- package/dist/assets/index-DH7Zax6L.css +1 -0
- package/dist/index.html +2 -2
- package/dist-server/index.js +817 -602
- package/dist-server/openmausbot.js +358 -208
- package/dist-server/pair-cli.js +358 -208
- package/dist-server/permission-proxy.js +119 -14
- package/dist-server/server/auto-approve.js +15 -0
- package/dist-server/server/drivers/acp/core.js +2 -1
- package/dist-server/server/drivers/acp/grok.js +12 -1
- package/dist-server/server/drivers/claude.js +60 -3
- package/dist-server/server/drivers/codex.js +15 -4
- package/dist-server/server/drivers/retry.js +4 -0
- package/dist-server/server/index.js +80 -10
- package/dist-server/server/permission-proxy.js +90 -15
- package/dist-server/server/setup-mode.js +6 -7
- package/dist-server/server/store.js +19 -0
- package/dist-server/server/thread-events.js +10 -1
- package/dist-server/server/workspace.js +13 -0
- package/dist-server/shared/ask-question.js +172 -0
- package/dist-server/shared/provider-safety.js +6 -0
- package/package.json +1 -1
- package/dist/assets/index-BRLHsQ5g.js +0 -298
- package/dist/assets/index-ByLQ7a3F.css +0 -1
|
@@ -9752,8 +9752,8 @@ var capitalizeFirstCharacter, error28;
|
|
|
9752
9752
|
var init_lt = __esm({
|
|
9753
9753
|
"node_modules/.pnpm/zod@4.4.3/node_modules/zod/v4/locales/lt.js"() {
|
|
9754
9754
|
init_util();
|
|
9755
|
-
capitalizeFirstCharacter = (
|
|
9756
|
-
return
|
|
9755
|
+
capitalizeFirstCharacter = (text4) => {
|
|
9756
|
+
return text4.charAt(0).toUpperCase() + text4.slice(1);
|
|
9757
9757
|
};
|
|
9758
9758
|
error28 = () => {
|
|
9759
9759
|
const Sizable = {
|
|
@@ -17585,8 +17585,8 @@ var init_mcp_registry = __esm({
|
|
|
17585
17585
|
});
|
|
17586
17586
|
|
|
17587
17587
|
// server/schema.ts
|
|
17588
|
-
function parseJson(
|
|
17589
|
-
return JSON.parse(
|
|
17588
|
+
function parseJson(text4) {
|
|
17589
|
+
return JSON.parse(text4);
|
|
17590
17590
|
}
|
|
17591
17591
|
function schemaIssue(error51, fallback) {
|
|
17592
17592
|
const issue2 = error51.issues[0];
|
|
@@ -18631,14 +18631,14 @@ function nodeExe(near) {
|
|
|
18631
18631
|
return process.versions.electron ? null : process.execPath;
|
|
18632
18632
|
}
|
|
18633
18633
|
function parseCmdShim(shim) {
|
|
18634
|
-
let
|
|
18634
|
+
let text4;
|
|
18635
18635
|
try {
|
|
18636
|
-
|
|
18636
|
+
text4 = readFileSync6(shim, "utf8");
|
|
18637
18637
|
} catch {
|
|
18638
18638
|
return null;
|
|
18639
18639
|
}
|
|
18640
18640
|
const dir = dirname4(shim);
|
|
18641
|
-
const targets = [...
|
|
18641
|
+
const targets = [...text4.matchAll(/"%~?dp0%?\\?([^"]+)"/g)].map((m) => join9(dir, m[1])).filter((p) => isFile(p) && basename2(p).toLowerCase() !== "node.exe");
|
|
18642
18642
|
const script = targets.find((p) => /\.[cm]?js$/i.test(p));
|
|
18643
18643
|
if (script) {
|
|
18644
18644
|
const node = nodeExe(dir);
|
|
@@ -19583,9 +19583,9 @@ function isSecretName(name) {
|
|
|
19583
19583
|
if (SECRET_KEY_PARTS.some((part) => lower.includes(part))) return true;
|
|
19584
19584
|
return /(^|[_.-])keys?$/.test(lower);
|
|
19585
19585
|
}
|
|
19586
|
-
function redactSecretsInText(
|
|
19587
|
-
if (!
|
|
19588
|
-
let out =
|
|
19586
|
+
function redactSecretsInText(text4) {
|
|
19587
|
+
if (!text4 || text4.length < 8) return text4;
|
|
19588
|
+
let out = text4;
|
|
19589
19589
|
out = out.replace(PEM_BLOCK, (_m, open2, body, close) => `${open2}
|
|
19590
19590
|
${mask(body.trim())}
|
|
19591
19591
|
${close}`);
|
|
@@ -19696,8 +19696,8 @@ function askInputSummary(input) {
|
|
|
19696
19696
|
if (typeof fields.question === "string") return cut(fields.question, QUESTION_LIMIT);
|
|
19697
19697
|
if (typeof fields.command === "string") return cut(fields.command, LIMIT);
|
|
19698
19698
|
if (typeof fields.url === "string") return cut(fields.url, LIMIT);
|
|
19699
|
-
const
|
|
19700
|
-
return
|
|
19699
|
+
const text4 = JSON.stringify(fields);
|
|
19700
|
+
return text4 === "{}" ? void 0 : cut(text4, LIMIT);
|
|
19701
19701
|
}
|
|
19702
19702
|
var QUESTION_LIMIT, LIMIT, cut;
|
|
19703
19703
|
var init_tool_summary = __esm({
|
|
@@ -19706,7 +19706,7 @@ var init_tool_summary = __esm({
|
|
|
19706
19706
|
init_redact();
|
|
19707
19707
|
QUESTION_LIMIT = 300;
|
|
19708
19708
|
LIMIT = 200;
|
|
19709
|
-
cut = (
|
|
19709
|
+
cut = (text4, limit) => redactSecretsInText(text4).trim().slice(0, limit);
|
|
19710
19710
|
}
|
|
19711
19711
|
});
|
|
19712
19712
|
|
|
@@ -19729,11 +19729,11 @@ function sanitizeToolLogValue(value, budget, depth = 0) {
|
|
|
19729
19729
|
if (typeof value === "string") {
|
|
19730
19730
|
if (/^data:image\//iu.test(value) || budget.text <= 0) return void 0;
|
|
19731
19731
|
const limit = Math.min(TOOL_LOG_TEXT_LIMIT, budget.text);
|
|
19732
|
-
const
|
|
19732
|
+
const text4 = value.length <= limit ? value : `[Earlier output truncated]
|
|
19733
19733
|
|
|
19734
19734
|
${value.slice(-limit)}`;
|
|
19735
|
-
budget.text -=
|
|
19736
|
-
return
|
|
19735
|
+
budget.text -= text4.length;
|
|
19736
|
+
return text4;
|
|
19737
19737
|
}
|
|
19738
19738
|
if (Array.isArray(value)) {
|
|
19739
19739
|
return value.flatMap((entry) => {
|
|
@@ -20040,10 +20040,10 @@ function createAcpDriver(support11) {
|
|
|
20040
20040
|
}
|
|
20041
20041
|
};
|
|
20042
20042
|
const flushAssistantText = () => {
|
|
20043
|
-
const
|
|
20043
|
+
const text4 = state.text;
|
|
20044
20044
|
state.text = "";
|
|
20045
|
-
if (!
|
|
20046
|
-
emit({ ...base2(threadId, turnId), type: "item.completed", itemType: "assistant_text", text:
|
|
20045
|
+
if (!text4.trim()) return;
|
|
20046
|
+
emit({ ...base2(threadId, turnId), type: "item.completed", itemType: "assistant_text", text: text4 });
|
|
20047
20047
|
};
|
|
20048
20048
|
const settle = (ok, stopReason) => {
|
|
20049
20049
|
if (state.settled) return;
|
|
@@ -20299,7 +20299,7 @@ function createAcpDriver(support11) {
|
|
|
20299
20299
|
}
|
|
20300
20300
|
}
|
|
20301
20301
|
const images = turn.images ?? [];
|
|
20302
|
-
const runtimeAcceptsImages = init?.agentCapabilities?.promptCapabilities?.image === true;
|
|
20302
|
+
const runtimeAcceptsImages = init?.agentCapabilities?.promptCapabilities?.image === true || support11.acceptsUnadvertisedImages?.(init) === true;
|
|
20303
20303
|
if (images.length && support11.images === true && !runtimeAcceptsImages) {
|
|
20304
20304
|
throw new Error(
|
|
20305
20305
|
`${support11.displayName} is configured for image attachments, but this installed runtime does not advertise ACP image input. Update the ${support11.displayName} CLI or send the message without an image.`
|
|
@@ -20372,13 +20372,13 @@ function createAcpDriver(support11) {
|
|
|
20372
20372
|
}
|
|
20373
20373
|
emitSessionStarted();
|
|
20374
20374
|
state.promptSent = true;
|
|
20375
|
-
const
|
|
20375
|
+
const text4 = support11.buildPromptText ? support11.buildPromptText(turn) : turn.system ? `${turn.system}
|
|
20376
20376
|
|
|
20377
20377
|
${turn.text}` : turn.text;
|
|
20378
20378
|
const imageBlocks = support11.images === true && runtimeAcceptsImages ? await readAcpImageBlocks(images) : [];
|
|
20379
20379
|
const result = await request("session/prompt", {
|
|
20380
20380
|
sessionId,
|
|
20381
|
-
prompt: [{ type: "text", text:
|
|
20381
|
+
prompt: [{ type: "text", text: text4 }, ...imageBlocks]
|
|
20382
20382
|
});
|
|
20383
20383
|
const usage = result?.usage ?? result?._meta ?? {};
|
|
20384
20384
|
if (typeof usage.inputTokens === "number" || typeof usage.outputTokens === "number") {
|
|
@@ -21706,14 +21706,14 @@ var init_boxagent = __esm({
|
|
|
21706
21706
|
let lastText = "";
|
|
21707
21707
|
let pendingText = "";
|
|
21708
21708
|
const flushAssistantText = () => {
|
|
21709
|
-
const
|
|
21709
|
+
const text4 = pendingText;
|
|
21710
21710
|
pendingText = "";
|
|
21711
|
-
if (!
|
|
21712
|
-
emit({ ...base2(threadId, turnId), type: "item.completed", itemType: "assistant_text", text:
|
|
21711
|
+
if (!text4.trim()) return;
|
|
21712
|
+
emit({ ...base2(threadId, turnId), type: "item.completed", itemType: "assistant_text", text: text4 });
|
|
21713
21713
|
};
|
|
21714
|
-
const ingest = (
|
|
21715
|
-
const delta =
|
|
21716
|
-
lastText =
|
|
21714
|
+
const ingest = (text4) => {
|
|
21715
|
+
const delta = text4.startsWith(lastText) ? text4.slice(lastText.length) : text4;
|
|
21716
|
+
lastText = text4;
|
|
21717
21717
|
if (!delta) return;
|
|
21718
21718
|
pendingText += delta;
|
|
21719
21719
|
emit({ ...base2(threadId, turnId), type: "content.delta", streamKind: "assistant_text", delta });
|
|
@@ -21730,9 +21730,9 @@ var init_boxagent = __esm({
|
|
|
21730
21730
|
seen.add(id);
|
|
21731
21731
|
appendNative(threadId, { dir: "in", source: "box.events", msg: ev });
|
|
21732
21732
|
const kind = String(ev.type ?? ev.kind ?? "");
|
|
21733
|
-
const
|
|
21734
|
-
if (/assistant|message|output|response/i.test(kind) && typeof
|
|
21735
|
-
ingest(
|
|
21733
|
+
const text4 = ev.text ?? ev.message ?? ev.data?.text ?? ev.data?.content ?? null;
|
|
21734
|
+
if (/assistant|message|output|response/i.test(kind) && typeof text4 === "string" && text4.trim()) {
|
|
21735
|
+
ingest(text4);
|
|
21736
21736
|
} else if (/tool|command|exec|browse/i.test(kind)) {
|
|
21737
21737
|
flushAssistantText();
|
|
21738
21738
|
emit({
|
|
@@ -22272,25 +22272,36 @@ var init_mcp_gate_config = __esm({
|
|
|
22272
22272
|
}
|
|
22273
22273
|
});
|
|
22274
22274
|
|
|
22275
|
+
// shared/provider-safety.ts
|
|
22276
|
+
function isProviderSafetyBlock(message2) {
|
|
22277
|
+
return /\bblocked by (?:our|the provider['’]s) safety systems\b|\bsafety monitoring\b.{0,100}\b(?:paused|ended|blocked)\b|\b(?:safety_check_failed|safety_policy_violation)\b/i.test(message2);
|
|
22278
|
+
}
|
|
22279
|
+
var init_provider_safety = __esm({
|
|
22280
|
+
"shared/provider-safety.ts"() {
|
|
22281
|
+
"use strict";
|
|
22282
|
+
}
|
|
22283
|
+
});
|
|
22284
|
+
|
|
22275
22285
|
// server/drivers/retry.ts
|
|
22276
22286
|
function classifyError(err) {
|
|
22277
|
-
const
|
|
22287
|
+
const text4 = messageOf(err);
|
|
22288
|
+
if (isProviderSafetyBlock(text4)) return { transient: false, reason: "provider_safety" };
|
|
22278
22289
|
if (err && "exitCode" in err) {
|
|
22279
22290
|
const { exitCode: code } = err;
|
|
22280
22291
|
if (code !== null && code < 0) return { transient: false, reason: "interrupted" };
|
|
22281
22292
|
for (const { pattern, reason } of TRANSIENT_PATTERNS) {
|
|
22282
|
-
if (pattern.test(
|
|
22293
|
+
if (pattern.test(text4)) return { transient: true, reason };
|
|
22283
22294
|
}
|
|
22284
22295
|
for (const { pattern, reason } of TERMINAL_PATTERNS) {
|
|
22285
|
-
if (pattern.test(
|
|
22296
|
+
if (pattern.test(text4)) return { transient: false, reason };
|
|
22286
22297
|
}
|
|
22287
22298
|
return { transient: false, reason: "terminal_exit" };
|
|
22288
22299
|
}
|
|
22289
22300
|
for (const { pattern, reason } of TERMINAL_PATTERNS) {
|
|
22290
|
-
if (pattern.test(
|
|
22301
|
+
if (pattern.test(text4)) return { transient: false, reason };
|
|
22291
22302
|
}
|
|
22292
22303
|
for (const { pattern, reason } of TRANSIENT_PATTERNS) {
|
|
22293
|
-
if (pattern.test(
|
|
22304
|
+
if (pattern.test(text4)) return { transient: true, reason };
|
|
22294
22305
|
}
|
|
22295
22306
|
return { transient: false, reason: "unknown" };
|
|
22296
22307
|
}
|
|
@@ -22321,6 +22332,7 @@ var RETRY_MAX_ATTEMPTS, BACKOFF_BASE_MS, TRANSIENT_PATTERNS, TERMINAL_PATTERNS,
|
|
|
22321
22332
|
var init_retry = __esm({
|
|
22322
22333
|
"server/drivers/retry.ts"() {
|
|
22323
22334
|
"use strict";
|
|
22335
|
+
init_provider_safety();
|
|
22324
22336
|
RETRY_MAX_ATTEMPTS = 3;
|
|
22325
22337
|
BACKOFF_BASE_MS = [1e3, 3e3, 8e3];
|
|
22326
22338
|
TRANSIENT_PATTERNS = [
|
|
@@ -22355,6 +22367,82 @@ var init_retry = __esm({
|
|
|
22355
22367
|
}
|
|
22356
22368
|
});
|
|
22357
22369
|
|
|
22370
|
+
// shared/ask-question.ts
|
|
22371
|
+
function text3(value, limit) {
|
|
22372
|
+
if (typeof value !== "string") return void 0;
|
|
22373
|
+
const trimmed = value.trim();
|
|
22374
|
+
return trimmed ? trimmed.slice(0, limit) : void 0;
|
|
22375
|
+
}
|
|
22376
|
+
function isRecord(value) {
|
|
22377
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22378
|
+
}
|
|
22379
|
+
function parseOption(value) {
|
|
22380
|
+
if (typeof value === "string") {
|
|
22381
|
+
const label2 = text3(value, MAX_LABEL);
|
|
22382
|
+
return label2 ? { label: label2 } : null;
|
|
22383
|
+
}
|
|
22384
|
+
if (!isRecord(value)) return null;
|
|
22385
|
+
const label = text3(value.label, MAX_LABEL);
|
|
22386
|
+
if (!label) return null;
|
|
22387
|
+
const description = text3(value.description, MAX_DESCRIPTION);
|
|
22388
|
+
return description ? { label, description } : { label };
|
|
22389
|
+
}
|
|
22390
|
+
function parseQuestion(value) {
|
|
22391
|
+
if (!isRecord(value)) return null;
|
|
22392
|
+
const question = text3(value.question, MAX_QUESTION_TEXT);
|
|
22393
|
+
if (!question) return null;
|
|
22394
|
+
const options = [];
|
|
22395
|
+
const seen = /* @__PURE__ */ new Set();
|
|
22396
|
+
for (const raw of Array.isArray(value.options) ? value.options : []) {
|
|
22397
|
+
const option = parseOption(raw);
|
|
22398
|
+
if (!option || seen.has(option.label)) continue;
|
|
22399
|
+
seen.add(option.label);
|
|
22400
|
+
options.push(option);
|
|
22401
|
+
if (options.length === MAX_OPTIONS) break;
|
|
22402
|
+
}
|
|
22403
|
+
const header = text3(value.header, MAX_LABEL);
|
|
22404
|
+
return {
|
|
22405
|
+
question,
|
|
22406
|
+
...header ? { header } : {},
|
|
22407
|
+
...value.multiSelect === true ? { multiSelect: true } : {},
|
|
22408
|
+
options
|
|
22409
|
+
};
|
|
22410
|
+
}
|
|
22411
|
+
function parseAskQuestions(input) {
|
|
22412
|
+
if (!isRecord(input) || !Array.isArray(input.questions)) return null;
|
|
22413
|
+
const questions = [];
|
|
22414
|
+
for (const raw of input.questions) {
|
|
22415
|
+
const question = parseQuestion(raw);
|
|
22416
|
+
if (!question) continue;
|
|
22417
|
+
questions.push(question);
|
|
22418
|
+
if (questions.length === MAX_QUESTIONS) break;
|
|
22419
|
+
}
|
|
22420
|
+
return questions.length ? questions : null;
|
|
22421
|
+
}
|
|
22422
|
+
function askQuestionSummary(questions) {
|
|
22423
|
+
const first = questions[0]?.question ?? "";
|
|
22424
|
+
const rest = questions.length - 1;
|
|
22425
|
+
return rest > 0 ? `${first} (+${rest} more question${rest > 1 ? "s" : ""})` : first;
|
|
22426
|
+
}
|
|
22427
|
+
function questionChoices(questions) {
|
|
22428
|
+
if (questions.length !== 1) return void 0;
|
|
22429
|
+
const only = questions[0];
|
|
22430
|
+
if (only.multiSelect || only.options.length < 2) return void 0;
|
|
22431
|
+
return only.options.map((option) => option.label);
|
|
22432
|
+
}
|
|
22433
|
+
var ASK_USER_QUESTION_TOOL, MAX_QUESTIONS, MAX_OPTIONS, MAX_QUESTION_TEXT, MAX_LABEL, MAX_DESCRIPTION;
|
|
22434
|
+
var init_ask_question = __esm({
|
|
22435
|
+
"shared/ask-question.ts"() {
|
|
22436
|
+
"use strict";
|
|
22437
|
+
ASK_USER_QUESTION_TOOL = "AskUserQuestion";
|
|
22438
|
+
MAX_QUESTIONS = 6;
|
|
22439
|
+
MAX_OPTIONS = 12;
|
|
22440
|
+
MAX_QUESTION_TEXT = 400;
|
|
22441
|
+
MAX_LABEL = 120;
|
|
22442
|
+
MAX_DESCRIPTION = 400;
|
|
22443
|
+
}
|
|
22444
|
+
});
|
|
22445
|
+
|
|
22358
22446
|
// server/drivers/claude.ts
|
|
22359
22447
|
import { createHash as createHash5, randomBytes as randomBytes2 } from "node:crypto";
|
|
22360
22448
|
import { chmodSync as chmodSync4, mkdtempSync as mkdtempSync2, readFileSync as readFileSync8, rmSync as rmSync4, unlinkSync as unlinkSync3, writeFileSync as writeFileSync6 } from "node:fs";
|
|
@@ -22395,9 +22483,9 @@ function resolveClaudeConfigDir(configDir, env = process.env) {
|
|
|
22395
22483
|
}
|
|
22396
22484
|
return normalize(expanded);
|
|
22397
22485
|
}
|
|
22398
|
-
function claudeAuthFailure(frame,
|
|
22486
|
+
function claudeAuthFailure(frame, text4) {
|
|
22399
22487
|
if (frame.is_api_error_message !== true && typeof frame.error !== "string") return false;
|
|
22400
|
-
return frame.error === "authentication_failed" || classifyError({ text:
|
|
22488
|
+
return frame.error === "authentication_failed" || classifyError({ text: text4 }).reason === "auth";
|
|
22401
22489
|
}
|
|
22402
22490
|
function claudeEnvironment(model, source = process.env, configDir, instanceEnvironment = {}) {
|
|
22403
22491
|
const env = { ...source, PATH: augmentedPath(), NPM_CONFIG_LOGLEVEL: "error" };
|
|
@@ -22421,6 +22509,24 @@ function claudeEnvironment(model, source = process.env, configDir, instanceEnvir
|
|
|
22421
22509
|
function inheritsUserConfig(env) {
|
|
22422
22510
|
return env.OMB_CLAUDE_INHERIT_USER_CONFIG === "1";
|
|
22423
22511
|
}
|
|
22512
|
+
function readClaudeAuthSettings(env, instanceEnvironment = {}) {
|
|
22513
|
+
if (CLAUDE_ACCOUNT_ENV_KEYS.some((key) => instanceEnvironment[key])) return {};
|
|
22514
|
+
try {
|
|
22515
|
+
const settings2 = JSON.parse(readFileSync8(join20(resolveClaudeConfigDir(void 0, env), "settings.json"), "utf8"));
|
|
22516
|
+
const authEnv = {};
|
|
22517
|
+
for (const key of CLAUDE_ACCOUNT_ENV_KEYS) {
|
|
22518
|
+
if (!key.endsWith("_FILE_DESCRIPTOR") && typeof settings2?.env?.[key] === "string") {
|
|
22519
|
+
authEnv[key] = settings2.env[key];
|
|
22520
|
+
}
|
|
22521
|
+
}
|
|
22522
|
+
return {
|
|
22523
|
+
...Object.keys(authEnv).length ? { env: authEnv } : {},
|
|
22524
|
+
...typeof settings2?.apiKeyHelper === "string" && settings2.apiKeyHelper.trim() ? { apiKeyHelper: settings2.apiKeyHelper } : {}
|
|
22525
|
+
};
|
|
22526
|
+
} catch {
|
|
22527
|
+
return {};
|
|
22528
|
+
}
|
|
22529
|
+
}
|
|
22424
22530
|
function projectMcpServers(cwd) {
|
|
22425
22531
|
let parsed;
|
|
22426
22532
|
try {
|
|
@@ -22525,7 +22631,12 @@ function removePrivateTempDir(filePath) {
|
|
|
22525
22631
|
function systemEndedReply(kind) {
|
|
22526
22632
|
return kind === "question" ? { behavior: "answer", message: "OpenMausBot: the turn is ending \u2014 wrap up." } : { behavior: "deny", message: "OpenMausBot: the turn ended" };
|
|
22527
22633
|
}
|
|
22634
|
+
function askQuestions(ask) {
|
|
22635
|
+
return ask.tool === ASK_USER_QUESTION_TOOL ? parseAskQuestions(ask.input) : null;
|
|
22636
|
+
}
|
|
22528
22637
|
function askSummary(ask) {
|
|
22638
|
+
const questions = askQuestions(ask);
|
|
22639
|
+
if (questions) return askQuestionSummary(questions).slice(0, 300);
|
|
22529
22640
|
return askInputSummary(ask.input) ?? ask.tool ?? "tool";
|
|
22530
22641
|
}
|
|
22531
22642
|
function permissionSocketPath(threadId) {
|
|
@@ -22596,7 +22707,9 @@ async function createPermissionBroker(opts) {
|
|
|
22596
22707
|
if (!pending.delete(askId)) return;
|
|
22597
22708
|
clearTimeout(timer);
|
|
22598
22709
|
try {
|
|
22599
|
-
conn.write(
|
|
22710
|
+
conn.write(
|
|
22711
|
+
JSON.stringify({ t: "answer", id: askId, behavior, message: message2, source, ...always ? { always: true } : {} }) + "\n"
|
|
22712
|
+
);
|
|
22600
22713
|
} catch {
|
|
22601
22714
|
}
|
|
22602
22715
|
opts.onResolve({ ...ask, behavior, source });
|
|
@@ -22735,19 +22848,19 @@ function firstText(content) {
|
|
|
22735
22848
|
}
|
|
22736
22849
|
return "";
|
|
22737
22850
|
}
|
|
22738
|
-
function withVolatileNote(
|
|
22851
|
+
function withVolatileNote(text4, volatile) {
|
|
22739
22852
|
const body = volatile.trim() ? `This part of your instructions changed since this session started. It replaces the earlier copy:
|
|
22740
22853
|
|
|
22741
22854
|
${volatile.trim()}` : "The notes that were in your instructions when this session started have been cleared.";
|
|
22742
22855
|
const note = `<system-reminder>
|
|
22743
22856
|
${body}
|
|
22744
22857
|
</system-reminder>`;
|
|
22745
|
-
return
|
|
22858
|
+
return text4 ? `${note}
|
|
22746
22859
|
|
|
22747
|
-
${
|
|
22860
|
+
${text4}` : note;
|
|
22748
22861
|
}
|
|
22749
|
-
function claudeUserMessage(
|
|
22750
|
-
if (!images?.length) return { type: "user", message: { role: "user", content:
|
|
22862
|
+
function claudeUserMessage(text4, images) {
|
|
22863
|
+
if (!images?.length) return { type: "user", message: { role: "user", content: text4 } };
|
|
22751
22864
|
const content = images.map((image) => ({
|
|
22752
22865
|
type: "image",
|
|
22753
22866
|
source: {
|
|
@@ -22756,7 +22869,7 @@ function claudeUserMessage(text3, images) {
|
|
|
22756
22869
|
data: readFileSync8(image.path).toString("base64")
|
|
22757
22870
|
}
|
|
22758
22871
|
}));
|
|
22759
|
-
if (
|
|
22872
|
+
if (text4) content.push({ type: "text", text: text4 });
|
|
22760
22873
|
return { type: "user", message: { role: "user", content } };
|
|
22761
22874
|
}
|
|
22762
22875
|
function diagnosticClaudeUserMessage(message2) {
|
|
@@ -22794,6 +22907,7 @@ var init_claude = __esm({
|
|
|
22794
22907
|
init_local_inject();
|
|
22795
22908
|
init_native();
|
|
22796
22909
|
init_proxy_paths();
|
|
22910
|
+
init_ask_question();
|
|
22797
22911
|
CLAUDE_ACCOUNT_ENV_KEYS = [
|
|
22798
22912
|
"CLAUDE_CODE_OAUTH_TOKEN",
|
|
22799
22913
|
"CLAUDE_CODE_OAUTH_REFRESH_TOKEN",
|
|
@@ -23058,9 +23172,12 @@ var init_claude = __esm({
|
|
|
23058
23172
|
args.push("--allowedTools", allowed.join(","));
|
|
23059
23173
|
}
|
|
23060
23174
|
const env = environment(turnModel);
|
|
23175
|
+
const authSettings = isolated && !injected.injected ? readClaudeAuthSettings(env, input.environment) : {};
|
|
23176
|
+
const authSettingsPath = mcpConfigPath && Object.keys(authSettings).length ? join20(dirname9(mcpConfigPath), "auth-settings.json") : null;
|
|
23177
|
+
if (authSettingsPath) args.push("--settings", authSettingsPath);
|
|
23061
23178
|
env.CLAUDE_CODE_DISABLE_BACKGROUND_TASKS = "1";
|
|
23062
23179
|
const cwd = turn.cwd ?? homedir9();
|
|
23063
|
-
const privateFileFlags = /* @__PURE__ */ new Set(["--mcp-config"]);
|
|
23180
|
+
const privateFileFlags = /* @__PURE__ */ new Set(["--mcp-config", "--settings"]);
|
|
23064
23181
|
const keyArgs = args.filter((a2, i2) => !privateFileFlags.has(a2) && !privateFileFlags.has(args[i2 - 1] ?? ""));
|
|
23065
23182
|
const argsKey = JSON.stringify({
|
|
23066
23183
|
args: keyArgs,
|
|
@@ -23071,7 +23188,12 @@ var init_claude = __esm({
|
|
|
23071
23188
|
cwd,
|
|
23072
23189
|
model: injected.model ?? null,
|
|
23073
23190
|
base: env.ANTHROPIC_BASE_URL ?? null,
|
|
23074
|
-
configDir: env.CLAUDE_CONFIG_DIR ?? null
|
|
23191
|
+
configDir: env.CLAUDE_CONFIG_DIR ?? null,
|
|
23192
|
+
// Rotating an account's key/helper must not reuse the old process.
|
|
23193
|
+
auth: createHash5("sha256").update(JSON.stringify({
|
|
23194
|
+
settings: authSettings,
|
|
23195
|
+
env: Object.fromEntries(CLAUDE_ACCOUNT_ENV_KEYS.map((key) => [key, env[key]]))
|
|
23196
|
+
})).digest("hex")
|
|
23075
23197
|
});
|
|
23076
23198
|
const live = sessions.get(threadId);
|
|
23077
23199
|
if (live && !live.turn && !live.closing && live.child.exitCode === null && live.argsKey === argsKey && (!sessionId || sessionId === live.sessionId)) {
|
|
@@ -23140,6 +23262,7 @@ var init_claude = __esm({
|
|
|
23140
23262
|
askTools.set(ask.id, typeof ask.tool === "string" ? ask.tool : void 0);
|
|
23141
23263
|
const nativeMode = sessions.get(threadId)?.nativePermissionMode ?? null;
|
|
23142
23264
|
const nativeReview = permissionMode === "auto" && nativeMode !== null ? nativeMode === "auto" ? "active" : "inactive" : void 0;
|
|
23265
|
+
const questions = askQuestions(ask);
|
|
23143
23266
|
emit({
|
|
23144
23267
|
...base2(threadId, eventTurnId),
|
|
23145
23268
|
type: "request.opened",
|
|
@@ -23152,7 +23275,10 @@ var init_claude = __esm({
|
|
|
23152
23275
|
// host control stays one action at a time
|
|
23153
23276
|
allowSession: ask.kind === "permission" && !(controlsHost && typeof ask.tool === "string" && ask.tool.startsWith("mcp__computer")) ? true : void 0,
|
|
23154
23277
|
approvalScope: typeof ask.tool === "string" && controlsHost && ask.tool.startsWith("mcp__computer") ? "local-computer" : void 0,
|
|
23155
|
-
|
|
23278
|
+
questions: questions ?? void 0,
|
|
23279
|
+
// A structured ask still offers flat labels, for the phone
|
|
23280
|
+
// companions and any client that predates the question card.
|
|
23281
|
+
choices: questions ? questionChoices(questions) : Array.isArray(ask.input?.choices) ? ask.input.choices.slice(0, 5) : void 0
|
|
23156
23282
|
});
|
|
23157
23283
|
},
|
|
23158
23284
|
onResolve: (resolved) => {
|
|
@@ -23175,6 +23301,9 @@ var init_claude = __esm({
|
|
|
23175
23301
|
if (mcpConfigPath) {
|
|
23176
23302
|
writeFileSync6(mcpConfigPath, JSON.stringify({ mcpServers }), { mode: 384 });
|
|
23177
23303
|
}
|
|
23304
|
+
if (authSettingsPath) {
|
|
23305
|
+
writeFileSync6(authSettingsPath, JSON.stringify(authSettings), { mode: 384 });
|
|
23306
|
+
}
|
|
23178
23307
|
if (sessionId) args.push("--resume", sessionId);
|
|
23179
23308
|
else args.push("--session-id", newSessionId);
|
|
23180
23309
|
} catch (error51) {
|
|
@@ -23265,18 +23394,18 @@ var init_claude = __esm({
|
|
|
23265
23394
|
}
|
|
23266
23395
|
case "assistant": {
|
|
23267
23396
|
const msg = o.message ?? {};
|
|
23268
|
-
const
|
|
23269
|
-
if (claudeAuthFailure(o,
|
|
23397
|
+
const text4 = firstText(msg.content);
|
|
23398
|
+
if (claudeAuthFailure(o, text4)) {
|
|
23270
23399
|
if (session.turn) session.turn.authFailed = true;
|
|
23271
|
-
emit({ ...base2(threadId, currentTurnId()), type: "runtime.error", message:
|
|
23400
|
+
emit({ ...base2(threadId, currentTurnId()), type: "runtime.error", message: text4, setup: true });
|
|
23272
23401
|
break;
|
|
23273
23402
|
}
|
|
23274
|
-
if (
|
|
23403
|
+
if (text4.trim()) {
|
|
23275
23404
|
if (!session.turn?.sawStreamDelta) {
|
|
23276
|
-
emit({ ...base2(threadId, currentTurnId()), type: "content.delta", streamKind: "assistant_text", delta:
|
|
23405
|
+
emit({ ...base2(threadId, currentTurnId()), type: "content.delta", streamKind: "assistant_text", delta: text4 });
|
|
23277
23406
|
}
|
|
23278
23407
|
if (session.turn) session.turn.sawStreamDelta = false;
|
|
23279
|
-
emit({ ...base2(threadId, currentTurnId()), type: "item.completed", itemType: "assistant_text", text:
|
|
23408
|
+
emit({ ...base2(threadId, currentTurnId()), type: "item.completed", itemType: "assistant_text", text: text4 });
|
|
23280
23409
|
}
|
|
23281
23410
|
for (const b of Array.isArray(msg.content) ? msg.content : []) {
|
|
23282
23411
|
if (b.type === "tool_use") {
|
|
@@ -23507,10 +23636,10 @@ var init_claude = __esm({
|
|
|
23507
23636
|
}
|
|
23508
23637
|
return { turnId };
|
|
23509
23638
|
};
|
|
23510
|
-
const steer = async (threadId,
|
|
23639
|
+
const steer = async (threadId, text4) => {
|
|
23511
23640
|
const s = sessions.get(threadId);
|
|
23512
23641
|
if (!s || !s.turn || s.turn.settled || s.closing || s.child.exitCode !== null) return false;
|
|
23513
|
-
return writeUser(s, threadId, claudeUserMessage(
|
|
23642
|
+
return writeUser(s, threadId, claudeUserMessage(text4, void 0));
|
|
23514
23643
|
};
|
|
23515
23644
|
const login = new ClaudeLoginController({ cli: config2.cli, environment, onAuthenticated: async () => {
|
|
23516
23645
|
await refreshModels();
|
|
@@ -23788,7 +23917,7 @@ function unquote(raw) {
|
|
|
23788
23917
|
}
|
|
23789
23918
|
return value;
|
|
23790
23919
|
}
|
|
23791
|
-
function parseCodexToml(
|
|
23920
|
+
function parseCodexToml(text4) {
|
|
23792
23921
|
const result = { providers: [] };
|
|
23793
23922
|
const byId = /* @__PURE__ */ new Map();
|
|
23794
23923
|
let section = "root";
|
|
@@ -23801,7 +23930,7 @@ function parseCodexToml(text3) {
|
|
|
23801
23930
|
}
|
|
23802
23931
|
return provider;
|
|
23803
23932
|
};
|
|
23804
|
-
for (const line of
|
|
23933
|
+
for (const line of text4.split(/\r?\n/)) {
|
|
23805
23934
|
const stripped = line.trim();
|
|
23806
23935
|
if (!stripped || stripped.startsWith("#")) continue;
|
|
23807
23936
|
if (stripped.startsWith("[") && stripped.endsWith("]")) {
|
|
@@ -24883,6 +25012,7 @@ var init_codex = __esm({
|
|
|
24883
25012
|
const earlyNotifications = [];
|
|
24884
25013
|
const state = {
|
|
24885
25014
|
settled: false,
|
|
25015
|
+
lastError: "",
|
|
24886
25016
|
lastText: "",
|
|
24887
25017
|
sawStreamDelta: false,
|
|
24888
25018
|
// codex reports token usage as a running THREAD total; the harness
|
|
@@ -25144,13 +25274,26 @@ var init_codex = __esm({
|
|
|
25144
25274
|
}
|
|
25145
25275
|
case "turn/completed": {
|
|
25146
25276
|
const t2 = p.turn ?? {};
|
|
25147
|
-
|
|
25277
|
+
const message2 = typeof t2.error?.message === "string" ? t2.error.message.slice(0, 400) : "";
|
|
25278
|
+
if (t2.status !== "completed" && message2 && message2 !== state.lastError) {
|
|
25279
|
+
state.lastError = message2;
|
|
25280
|
+
emit({
|
|
25281
|
+
...base2(threadId, turnId),
|
|
25282
|
+
type: "runtime.error",
|
|
25283
|
+
message: message2,
|
|
25284
|
+
...classifyError({ text: message2 }).reason === "auth" ? { setup: true } : {}
|
|
25285
|
+
});
|
|
25286
|
+
}
|
|
25287
|
+
void settle(t2.status === "completed", t2.status === "completed" ? null : classifyError({ text: message2 || state.lastError }).reason === "provider_safety" ? "provider_safety" : message2 || t2.status || "failed");
|
|
25148
25288
|
break;
|
|
25149
25289
|
}
|
|
25150
25290
|
case "error":
|
|
25151
25291
|
{
|
|
25152
25292
|
const message2 = p.message ?? p.error?.message;
|
|
25153
|
-
if (message2)
|
|
25293
|
+
if (message2) {
|
|
25294
|
+
state.lastError = String(message2).slice(0, 400);
|
|
25295
|
+
emit({ ...base2(threadId, turnId), type: "runtime.error", message: state.lastError });
|
|
25296
|
+
}
|
|
25154
25297
|
}
|
|
25155
25298
|
break;
|
|
25156
25299
|
}
|
|
@@ -25358,7 +25501,7 @@ var init_codex = __esm({
|
|
|
25358
25501
|
message: message2,
|
|
25359
25502
|
...needsAuth ? { setup: true } : {}
|
|
25360
25503
|
});
|
|
25361
|
-
await settle(false, needsAuth ? "auth_required" : "rpc_error");
|
|
25504
|
+
await settle(false, needsAuth ? "auth_required" : verdict.reason === "provider_safety" ? "provider_safety" : "rpc_error");
|
|
25362
25505
|
}
|
|
25363
25506
|
}
|
|
25364
25507
|
};
|
|
@@ -25495,7 +25638,7 @@ function createOpenAIChatRuntime(options) {
|
|
|
25495
25638
|
if (!response.body) {
|
|
25496
25639
|
throw new Error(options.noBodyError ?? `${options.httpErrorLabel} returned no response body`);
|
|
25497
25640
|
}
|
|
25498
|
-
let
|
|
25641
|
+
let text4 = "";
|
|
25499
25642
|
let reasoning = "";
|
|
25500
25643
|
let usage = null;
|
|
25501
25644
|
const reader = response.body.getReader();
|
|
@@ -25527,7 +25670,7 @@ function createOpenAIChatRuntime(options) {
|
|
|
25527
25670
|
onDelta?.(reasoningDelta, "reasoning_text");
|
|
25528
25671
|
}
|
|
25529
25672
|
if (contentDelta) {
|
|
25530
|
-
|
|
25673
|
+
text4 += contentDelta;
|
|
25531
25674
|
onDelta?.(contentDelta, "assistant_text");
|
|
25532
25675
|
}
|
|
25533
25676
|
if (chunk.usage) usage = usageFrom(chunk.usage);
|
|
@@ -25537,7 +25680,7 @@ function createOpenAIChatRuntime(options) {
|
|
|
25537
25680
|
await reader.cancel().catch(() => {
|
|
25538
25681
|
});
|
|
25539
25682
|
}
|
|
25540
|
-
return { text:
|
|
25683
|
+
return { text: text4, reasoning, usage };
|
|
25541
25684
|
};
|
|
25542
25685
|
const messagesFor = (turn) => [
|
|
25543
25686
|
...turn.system ? [{ role: "system", content: turn.system }] : [],
|
|
@@ -25654,8 +25797,8 @@ function createOpenAIChatRuntime(options) {
|
|
|
25654
25797
|
},
|
|
25655
25798
|
generateText: async (prompt) => {
|
|
25656
25799
|
const model = options.generateModel?.() ?? options.models().default;
|
|
25657
|
-
const { text:
|
|
25658
|
-
return
|
|
25800
|
+
const { text: text4, reasoning } = await complete([{ role: "user", content: prompt }], model, false);
|
|
25801
|
+
return text4.trim() ? text4 : reasoning;
|
|
25659
25802
|
},
|
|
25660
25803
|
dispose: async () => {
|
|
25661
25804
|
for (const abort of active.values()) abort.abort();
|
|
@@ -25723,7 +25866,7 @@ var init_grok = __esm({
|
|
|
25723
25866
|
nativeLog: {
|
|
25724
25867
|
source: "xai.chat.completions",
|
|
25725
25868
|
outgoing: (_turn, messages, model) => ({ model, messages }),
|
|
25726
|
-
incoming: ({ text:
|
|
25869
|
+
incoming: ({ text: text4, usage }) => ({ text: text4, usage })
|
|
25727
25870
|
}
|
|
25728
25871
|
});
|
|
25729
25872
|
}
|
|
@@ -25748,9 +25891,9 @@ function unquote2(raw) {
|
|
|
25748
25891
|
}
|
|
25749
25892
|
function readGrokModelCatalog(env = process.env) {
|
|
25750
25893
|
const path3 = join25(grokHome(env), "config.toml");
|
|
25751
|
-
let
|
|
25894
|
+
let text4 = "";
|
|
25752
25895
|
try {
|
|
25753
|
-
|
|
25896
|
+
text4 = readFileSync11(path3, "utf8");
|
|
25754
25897
|
} catch {
|
|
25755
25898
|
return STATIC_GROK_MODELS;
|
|
25756
25899
|
}
|
|
@@ -25768,7 +25911,7 @@ function readGrokModelCatalog(env = process.env) {
|
|
|
25768
25911
|
options.push({ id: current.slug, label: current.name || current.slug, custom: true });
|
|
25769
25912
|
current = null;
|
|
25770
25913
|
};
|
|
25771
|
-
for (const line of
|
|
25914
|
+
for (const line of text4.split(/\r?\n/)) {
|
|
25772
25915
|
const stripped = line.trim();
|
|
25773
25916
|
if (stripped === "[models]") {
|
|
25774
25917
|
flush();
|
|
@@ -25821,11 +25964,11 @@ function ensureGrokInjectSlug(modelId, env = process.env) {
|
|
|
25821
25964
|
const host = localHost(inject.host);
|
|
25822
25965
|
if (!host) return modelId;
|
|
25823
25966
|
const path3 = join25(grokHome(env), "config.toml");
|
|
25824
|
-
let
|
|
25967
|
+
let text4 = "";
|
|
25825
25968
|
try {
|
|
25826
|
-
|
|
25969
|
+
text4 = readFileSync11(path3, "utf8");
|
|
25827
25970
|
} catch {
|
|
25828
|
-
|
|
25971
|
+
text4 = "";
|
|
25829
25972
|
}
|
|
25830
25973
|
const taken = new Set(STATIC_GROK_MODELS.options.map((option) => option.id));
|
|
25831
25974
|
let current = null;
|
|
@@ -25838,7 +25981,7 @@ function ensureGrokInjectSlug(modelId, env = process.env) {
|
|
|
25838
25981
|
current = null;
|
|
25839
25982
|
};
|
|
25840
25983
|
let found = null;
|
|
25841
|
-
for (const line of
|
|
25984
|
+
for (const line of text4.split(/\r?\n/)) {
|
|
25842
25985
|
const stripped = line.trim();
|
|
25843
25986
|
if (stripped.startsWith("[model.") && stripped.endsWith("]")) {
|
|
25844
25987
|
flush();
|
|
@@ -25871,12 +26014,18 @@ function ensureGrokInjectSlug(modelId, env = process.env) {
|
|
|
25871
26014
|
`api_key = ${quoteToml(hostApiKey(host, env))}`,
|
|
25872
26015
|
""
|
|
25873
26016
|
].join("\n");
|
|
25874
|
-
const next =
|
|
26017
|
+
const next = text4 && !text4.endsWith("\n") ? `${text4}
|
|
25875
26018
|
|
|
25876
|
-
${block2}` : `${
|
|
26019
|
+
${block2}` : `${text4}${text4 ? "\n" : ""}${block2}`;
|
|
25877
26020
|
writeFileSync7(path3, next);
|
|
25878
26021
|
return slug;
|
|
25879
26022
|
}
|
|
26023
|
+
function grokAcceptsUnadvertisedImages(init) {
|
|
26024
|
+
const meta3 = init?._meta;
|
|
26025
|
+
if (meta3?.grokShell !== true || typeof meta3.agentVersion !== "string") return false;
|
|
26026
|
+
const version2 = /^1\.0\.(\d+)$/.exec(meta3.agentVersion);
|
|
26027
|
+
return Boolean(version2 && Number(version2[1]) >= 25);
|
|
26028
|
+
}
|
|
25880
26029
|
var STATIC_GROK_MODELS, SLUG, support2, GrokAgentDriver;
|
|
25881
26030
|
var init_grok2 = __esm({
|
|
25882
26031
|
"server/drivers/acp/grok.ts"() {
|
|
@@ -25894,7 +26043,8 @@ var init_grok2 = __esm({
|
|
|
25894
26043
|
support2 = {
|
|
25895
26044
|
driverKind: "grokAgent",
|
|
25896
26045
|
displayName: "Grok",
|
|
25897
|
-
images:
|
|
26046
|
+
images: true,
|
|
26047
|
+
acceptsUnadvertisedImages: grokAcceptsUnadvertisedImages,
|
|
25898
26048
|
models: STATIC_GROK_MODELS,
|
|
25899
26049
|
resolveModels: (env) => mergeLocalInject(readGrokModelCatalog(env), env),
|
|
25900
26050
|
// Grok's accepted levels vary by model and the CLI validates lazily — a
|
|
@@ -26068,18 +26218,18 @@ function stripTomlLineComment(line) {
|
|
|
26068
26218
|
}
|
|
26069
26219
|
return line;
|
|
26070
26220
|
}
|
|
26071
|
-
function takeTomlBasicEscape(
|
|
26072
|
-
const code =
|
|
26221
|
+
function takeTomlBasicEscape(text4, i2) {
|
|
26222
|
+
const code = text4[i2 + 1];
|
|
26073
26223
|
if (code === void 0) return { ok: false };
|
|
26074
26224
|
if (code === "u") {
|
|
26075
|
-
const hex3 =
|
|
26225
|
+
const hex3 = text4.slice(i2 + 2, i2 + 6);
|
|
26076
26226
|
if (!/^[0-9a-fA-F]{4}$/.test(hex3)) return { ok: false };
|
|
26077
26227
|
const point = parseInt(hex3, 16);
|
|
26078
26228
|
if (point >= 55296 && point <= 57343) return { ok: false };
|
|
26079
26229
|
return { ok: true, value: String.fromCharCode(point), next: i2 + 6 };
|
|
26080
26230
|
}
|
|
26081
26231
|
if (code === "U") {
|
|
26082
|
-
const hex3 =
|
|
26232
|
+
const hex3 = text4.slice(i2 + 2, i2 + 10);
|
|
26083
26233
|
if (!/^[0-9a-fA-F]{8}$/.test(hex3)) return { ok: false };
|
|
26084
26234
|
const point = parseInt(hex3, 16);
|
|
26085
26235
|
if (point > 1114111 || point >= 55296 && point <= 57343) return { ok: false };
|
|
@@ -26151,14 +26301,14 @@ function tomlRowKey(row) {
|
|
|
26151
26301
|
const eq = row.indexOf("=");
|
|
26152
26302
|
return unquoteTomlKey(eq < 0 ? row : row.slice(0, eq));
|
|
26153
26303
|
}
|
|
26154
|
-
function tomlTables(
|
|
26304
|
+
function tomlTables(text4) {
|
|
26155
26305
|
const headings = [];
|
|
26156
26306
|
let mode = "out";
|
|
26157
26307
|
let i2 = 0;
|
|
26158
|
-
const atLineStart = (idx) => idx === 0 ||
|
|
26159
|
-
while (i2 <
|
|
26308
|
+
const atLineStart = (idx) => idx === 0 || text4[idx - 1] === "\n";
|
|
26309
|
+
while (i2 < text4.length) {
|
|
26160
26310
|
if (mode === "mlbasic") {
|
|
26161
|
-
if (
|
|
26311
|
+
if (text4.startsWith('"""', i2)) {
|
|
26162
26312
|
mode = "out";
|
|
26163
26313
|
i2 += 3;
|
|
26164
26314
|
continue;
|
|
@@ -26167,7 +26317,7 @@ function tomlTables(text3) {
|
|
|
26167
26317
|
continue;
|
|
26168
26318
|
}
|
|
26169
26319
|
if (mode === "mllit") {
|
|
26170
|
-
if (
|
|
26320
|
+
if (text4.startsWith("'''", i2)) {
|
|
26171
26321
|
mode = "out";
|
|
26172
26322
|
i2 += 3;
|
|
26173
26323
|
continue;
|
|
@@ -26176,61 +26326,61 @@ function tomlTables(text3) {
|
|
|
26176
26326
|
continue;
|
|
26177
26327
|
}
|
|
26178
26328
|
if (mode === "basic") {
|
|
26179
|
-
if (
|
|
26329
|
+
if (text4[i2] === "\n") {
|
|
26180
26330
|
mode = "out";
|
|
26181
26331
|
i2 += 1;
|
|
26182
26332
|
continue;
|
|
26183
26333
|
}
|
|
26184
|
-
if (
|
|
26334
|
+
if (text4[i2] === "\\") {
|
|
26185
26335
|
i2 += 2;
|
|
26186
26336
|
continue;
|
|
26187
26337
|
}
|
|
26188
|
-
if (
|
|
26338
|
+
if (text4[i2] === '"') mode = "out";
|
|
26189
26339
|
i2 += 1;
|
|
26190
26340
|
continue;
|
|
26191
26341
|
}
|
|
26192
26342
|
if (mode === "literal") {
|
|
26193
|
-
if (
|
|
26343
|
+
if (text4[i2] === "\n") {
|
|
26194
26344
|
mode = "out";
|
|
26195
26345
|
i2 += 1;
|
|
26196
26346
|
continue;
|
|
26197
26347
|
}
|
|
26198
|
-
if (
|
|
26348
|
+
if (text4[i2] === "'") mode = "out";
|
|
26199
26349
|
i2 += 1;
|
|
26200
26350
|
continue;
|
|
26201
26351
|
}
|
|
26202
|
-
if (
|
|
26352
|
+
if (text4.startsWith('"""', i2)) {
|
|
26203
26353
|
mode = "mlbasic";
|
|
26204
26354
|
i2 += 3;
|
|
26205
26355
|
continue;
|
|
26206
26356
|
}
|
|
26207
|
-
if (
|
|
26357
|
+
if (text4.startsWith("'''", i2)) {
|
|
26208
26358
|
mode = "mllit";
|
|
26209
26359
|
i2 += 3;
|
|
26210
26360
|
continue;
|
|
26211
26361
|
}
|
|
26212
|
-
if (
|
|
26362
|
+
if (text4[i2] === '"') {
|
|
26213
26363
|
mode = "basic";
|
|
26214
26364
|
i2 += 1;
|
|
26215
26365
|
continue;
|
|
26216
26366
|
}
|
|
26217
|
-
if (
|
|
26367
|
+
if (text4[i2] === "'") {
|
|
26218
26368
|
mode = "literal";
|
|
26219
26369
|
i2 += 1;
|
|
26220
26370
|
continue;
|
|
26221
26371
|
}
|
|
26222
|
-
if (
|
|
26223
|
-
const nl =
|
|
26224
|
-
i2 = nl < 0 ?
|
|
26372
|
+
if (text4[i2] === "#") {
|
|
26373
|
+
const nl = text4.indexOf("\n", i2);
|
|
26374
|
+
i2 = nl < 0 ? text4.length : nl + 1;
|
|
26225
26375
|
continue;
|
|
26226
26376
|
}
|
|
26227
26377
|
if (atLineStart(i2)) {
|
|
26228
26378
|
let j = i2;
|
|
26229
|
-
while (j <
|
|
26230
|
-
if (
|
|
26231
|
-
const nl =
|
|
26232
|
-
const lineEnd = nl < 0 ?
|
|
26233
|
-
const raw =
|
|
26379
|
+
while (j < text4.length && (text4[j] === " " || text4[j] === " ")) j += 1;
|
|
26380
|
+
if (text4[j] === "[") {
|
|
26381
|
+
const nl = text4.indexOf("\n", j);
|
|
26382
|
+
const lineEnd = nl < 0 ? text4.length : nl;
|
|
26383
|
+
const raw = text4.slice(j, lineEnd).replace(/\r$/, "");
|
|
26234
26384
|
const stripped = stripTomlLineComment(raw).trim();
|
|
26235
26385
|
const array2 = stripped.startsWith("[[");
|
|
26236
26386
|
const name = array2 ? canonicalizeTomlHeading(`[${stripped.replace(/^\s*\[\[/, "").replace(/\]\]\s*$/, "")}]`) : canonicalizeTomlHeading(raw);
|
|
@@ -26243,11 +26393,11 @@ function tomlTables(text3) {
|
|
|
26243
26393
|
}
|
|
26244
26394
|
return headings.map((heading, index) => ({
|
|
26245
26395
|
heading,
|
|
26246
|
-
end: index + 1 < headings.length ? headings[index + 1].lineStart :
|
|
26396
|
+
end: index + 1 < headings.length ? headings[index + 1].lineStart : text4.length
|
|
26247
26397
|
})).filter((entry) => entry.heading.patchable && entry.heading.name).map((entry) => ({
|
|
26248
26398
|
name: entry.heading.name,
|
|
26249
26399
|
headingStart: entry.heading.lineStart,
|
|
26250
|
-
bodyStart: entry.heading.lineEnd + (
|
|
26400
|
+
bodyStart: entry.heading.lineEnd + (text4[entry.heading.lineEnd] === "\n" ? 1 : 0),
|
|
26251
26401
|
end: entry.end
|
|
26252
26402
|
}));
|
|
26253
26403
|
}
|
|
@@ -26303,22 +26453,22 @@ function tomlKeys(block2) {
|
|
|
26303
26453
|
take(block2.length);
|
|
26304
26454
|
return keys;
|
|
26305
26455
|
}
|
|
26306
|
-
function hasTomlTable(
|
|
26456
|
+
function hasTomlTable(text4, heading) {
|
|
26307
26457
|
const name = canonicalizeTomlHeading(heading);
|
|
26308
|
-
return name !== null && tomlTables(
|
|
26458
|
+
return name !== null && tomlTables(text4).some((table) => table.name === name);
|
|
26309
26459
|
}
|
|
26310
|
-
function patchTomlTable(
|
|
26460
|
+
function patchTomlTable(text4, heading, rows) {
|
|
26311
26461
|
const name = canonicalizeTomlHeading(heading);
|
|
26312
|
-
if (!name) return
|
|
26313
|
-
const table = tomlTables(
|
|
26314
|
-
if (!table) return
|
|
26315
|
-
const keys = tomlKeys(
|
|
26462
|
+
if (!name) return text4;
|
|
26463
|
+
const table = tomlTables(text4).find((entry) => entry.name === name);
|
|
26464
|
+
if (!table) return text4;
|
|
26465
|
+
const keys = tomlKeys(text4.slice(table.bodyStart, table.end));
|
|
26316
26466
|
const missing = rows.filter((row) => !keys.has(tomlRowKey(row)));
|
|
26317
|
-
if (!missing.length) return
|
|
26467
|
+
if (!missing.length) return text4;
|
|
26318
26468
|
let insertAt = table.end;
|
|
26319
|
-
while (insertAt > table.bodyStart && (
|
|
26320
|
-
const before =
|
|
26321
|
-
const after =
|
|
26469
|
+
while (insertAt > table.bodyStart && (text4[insertAt - 1] === "\n" || text4[insertAt - 1] === "\r")) insertAt -= 1;
|
|
26470
|
+
const before = text4.slice(0, insertAt);
|
|
26471
|
+
const after = text4.slice(insertAt);
|
|
26322
26472
|
const pad = before.endsWith("\n") || before.length === 0 ? "" : "\n";
|
|
26323
26473
|
return `${before}${pad}${missing.join("\n")}${after.startsWith("\n") ? "" : "\n"}${after}`;
|
|
26324
26474
|
}
|
|
@@ -26331,17 +26481,17 @@ function ensureKimiInjectAlias(modelId, env = process.env) {
|
|
|
26331
26481
|
const dataRoot = kimiDataRoot(env);
|
|
26332
26482
|
mkdirSync10(dataRoot, { recursive: true });
|
|
26333
26483
|
const path3 = join27(dataRoot, "config.toml");
|
|
26334
|
-
let
|
|
26484
|
+
let text4 = "";
|
|
26335
26485
|
try {
|
|
26336
|
-
|
|
26486
|
+
text4 = readFileSync13(path3, "utf8");
|
|
26337
26487
|
} catch {
|
|
26338
|
-
|
|
26488
|
+
text4 = "";
|
|
26339
26489
|
}
|
|
26340
|
-
const original =
|
|
26490
|
+
const original = text4;
|
|
26341
26491
|
const providerHeading = `[providers.${inject.host}]`;
|
|
26342
26492
|
const modelHeading = `[models.${quoteTomlKey(alias)}]`;
|
|
26343
26493
|
const blocks = [];
|
|
26344
|
-
if (!hasTomlTable(
|
|
26494
|
+
if (!hasTomlTable(text4, providerHeading)) {
|
|
26345
26495
|
blocks.push(
|
|
26346
26496
|
[
|
|
26347
26497
|
providerHeading,
|
|
@@ -26352,8 +26502,8 @@ function ensureKimiInjectAlias(modelId, env = process.env) {
|
|
|
26352
26502
|
].join("\n")
|
|
26353
26503
|
);
|
|
26354
26504
|
}
|
|
26355
|
-
if (hasTomlTable(
|
|
26356
|
-
|
|
26505
|
+
if (hasTomlTable(text4, modelHeading)) {
|
|
26506
|
+
text4 = patchTomlTable(text4, modelHeading, [`protocol = "openai"`, `max_context_size = 262144`]);
|
|
26357
26507
|
} else {
|
|
26358
26508
|
blocks.push(
|
|
26359
26509
|
[
|
|
@@ -26367,13 +26517,13 @@ function ensureKimiInjectAlias(modelId, env = process.env) {
|
|
|
26367
26517
|
);
|
|
26368
26518
|
}
|
|
26369
26519
|
if (blocks.length) {
|
|
26370
|
-
const prefix =
|
|
26520
|
+
const prefix = text4 && !text4.endsWith("\n") ? `${text4}
|
|
26371
26521
|
|
|
26372
|
-
` :
|
|
26522
|
+
` : text4 ? `${text4}
|
|
26373
26523
|
` : "";
|
|
26374
26524
|
writeFileSync8(path3, `${prefix}${blocks.join("\n")}`);
|
|
26375
|
-
} else if (
|
|
26376
|
-
writeFileSync8(path3,
|
|
26525
|
+
} else if (text4 !== original) {
|
|
26526
|
+
writeFileSync8(path3, text4);
|
|
26377
26527
|
}
|
|
26378
26528
|
return alias;
|
|
26379
26529
|
}
|
|
@@ -26393,9 +26543,9 @@ function stripKimiModelEnv(env) {
|
|
|
26393
26543
|
}
|
|
26394
26544
|
function readKimiModelCatalog(env) {
|
|
26395
26545
|
const dataRoot = kimiDataRoot(env);
|
|
26396
|
-
let
|
|
26546
|
+
let text4 = "";
|
|
26397
26547
|
try {
|
|
26398
|
-
|
|
26548
|
+
text4 = readFileSync13(join27(dataRoot, "config.toml"), "utf8");
|
|
26399
26549
|
} catch {
|
|
26400
26550
|
return STATIC_KIMI_MODELS;
|
|
26401
26551
|
}
|
|
@@ -26411,7 +26561,7 @@ function readKimiModelCatalog(env) {
|
|
|
26411
26561
|
options.push({ id: current.slug, label: current.name || current.slug, custom: true });
|
|
26412
26562
|
current = null;
|
|
26413
26563
|
};
|
|
26414
|
-
for (const line of
|
|
26564
|
+
for (const line of text4.split(/\r?\n/)) {
|
|
26415
26565
|
const stripped = line.trim();
|
|
26416
26566
|
if ((stripped.startsWith("[model.") || stripped.startsWith("[models.")) && stripped.endsWith("]")) {
|
|
26417
26567
|
flush();
|
|
@@ -26704,8 +26854,8 @@ function resolveCursorAcpModelId(available, wanted) {
|
|
|
26704
26854
|
}
|
|
26705
26855
|
return null;
|
|
26706
26856
|
}
|
|
26707
|
-
function firstJsonValue(
|
|
26708
|
-
const trimmed =
|
|
26857
|
+
function firstJsonValue(text4) {
|
|
26858
|
+
const trimmed = text4.trim();
|
|
26709
26859
|
if (!trimmed) return null;
|
|
26710
26860
|
try {
|
|
26711
26861
|
return JSON.parse(trimmed);
|
|
@@ -26779,12 +26929,12 @@ function stripModelMarkers(label) {
|
|
|
26779
26929
|
}
|
|
26780
26930
|
return { label: cleaned, isDefault, isCurrent };
|
|
26781
26931
|
}
|
|
26782
|
-
function decodeCursorModelText(
|
|
26932
|
+
function decodeCursorModelText(text4) {
|
|
26783
26933
|
const options = [];
|
|
26784
26934
|
const seen = /* @__PURE__ */ new Set();
|
|
26785
26935
|
let markedDefault;
|
|
26786
26936
|
let markedCurrent;
|
|
26787
|
-
for (const raw of
|
|
26937
|
+
for (const raw of text4.split(/\r?\n/)) {
|
|
26788
26938
|
const line = raw.trim();
|
|
26789
26939
|
if (!line || line.startsWith("#") || /^available\s+models?\b/i.test(line) || /^models?\b/i.test(line)) continue;
|
|
26790
26940
|
const stripped = line.replace(/^[\s*•-]+\s*/, "");
|
|
@@ -26837,8 +26987,8 @@ function decodeCursorAuthStatus(payload) {
|
|
|
26837
26987
|
}
|
|
26838
26988
|
return null;
|
|
26839
26989
|
}
|
|
26840
|
-
function decodeCursorAuthText(
|
|
26841
|
-
const normalized =
|
|
26990
|
+
function decodeCursorAuthText(text4) {
|
|
26991
|
+
const normalized = text4.trim().toLowerCase();
|
|
26842
26992
|
if (!normalized) return null;
|
|
26843
26993
|
if (/not (?:logged|signed) in|not authenticated|unauthenticated|logged out/.test(normalized)) return false;
|
|
26844
26994
|
if (/login successful|logged in|signed in|authenticated/.test(normalized)) return true;
|
|
@@ -27258,7 +27408,7 @@ function qwenHome(env) {
|
|
|
27258
27408
|
const home = process.platform === "win32" ? env.USERPROFILE || env.HOME || homedir19() : env.HOME || env.USERPROFILE || homedir19();
|
|
27259
27409
|
return join30(home, ".qwen");
|
|
27260
27410
|
}
|
|
27261
|
-
function
|
|
27411
|
+
function isRecord2(value) {
|
|
27262
27412
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
27263
27413
|
}
|
|
27264
27414
|
function qwenModelLabel(id, name) {
|
|
@@ -27272,15 +27422,15 @@ function readQwenRoutes(env) {
|
|
|
27272
27422
|
} catch {
|
|
27273
27423
|
return [];
|
|
27274
27424
|
}
|
|
27275
|
-
if (!
|
|
27425
|
+
if (!isRecord2(settings2) || !isRecord2(settings2.modelProviders)) return [];
|
|
27276
27426
|
const routes = [];
|
|
27277
27427
|
const seen = /* @__PURE__ */ new Set();
|
|
27278
|
-
const mappings =
|
|
27428
|
+
const mappings = isRecord2(settings2.providerProtocol) ? settings2.providerProtocol : {};
|
|
27279
27429
|
for (const [provider, rows] of Object.entries(settings2.modelProviders)) {
|
|
27280
27430
|
const protocol = Object.hasOwn(mappings, provider) ? mappings[provider] : provider;
|
|
27281
27431
|
if (typeof protocol !== "string" || !PROTOCOLS.has(protocol) || !Array.isArray(rows)) continue;
|
|
27282
27432
|
for (const row of rows) {
|
|
27283
|
-
if (!
|
|
27433
|
+
if (!isRecord2(row) || typeof row.id !== "string") continue;
|
|
27284
27434
|
const model = row.id;
|
|
27285
27435
|
if (!model.trim()) continue;
|
|
27286
27436
|
if (row.baseUrl !== void 0 && typeof row.baseUrl !== "string") continue;
|
|
@@ -28426,14 +28576,14 @@ var init_stringifyComment = __esm({
|
|
|
28426
28576
|
});
|
|
28427
28577
|
|
|
28428
28578
|
// node_modules/.pnpm/yaml@2.9.0/node_modules/yaml/browser/dist/stringify/foldFlowLines.js
|
|
28429
|
-
function foldFlowLines(
|
|
28579
|
+
function foldFlowLines(text4, indent, mode = "flow", { indentAtStart, lineWidth = 80, minContentWidth = 20, onFold, onOverflow } = {}) {
|
|
28430
28580
|
if (!lineWidth || lineWidth < 0)
|
|
28431
|
-
return
|
|
28581
|
+
return text4;
|
|
28432
28582
|
if (lineWidth < minContentWidth)
|
|
28433
28583
|
minContentWidth = 0;
|
|
28434
28584
|
const endStep = Math.max(1 + minContentWidth, 1 + lineWidth - indent.length);
|
|
28435
|
-
if (
|
|
28436
|
-
return
|
|
28585
|
+
if (text4.length <= endStep)
|
|
28586
|
+
return text4;
|
|
28437
28587
|
const folds = [];
|
|
28438
28588
|
const escapedFolds = {};
|
|
28439
28589
|
let end = lineWidth - indent.length;
|
|
@@ -28450,14 +28600,14 @@ function foldFlowLines(text3, indent, mode = "flow", { indentAtStart, lineWidth
|
|
|
28450
28600
|
let escStart = -1;
|
|
28451
28601
|
let escEnd = -1;
|
|
28452
28602
|
if (mode === FOLD_BLOCK) {
|
|
28453
|
-
i2 = consumeMoreIndentedLines(
|
|
28603
|
+
i2 = consumeMoreIndentedLines(text4, i2, indent.length);
|
|
28454
28604
|
if (i2 !== -1)
|
|
28455
28605
|
end = i2 + endStep;
|
|
28456
28606
|
}
|
|
28457
|
-
for (let ch; ch =
|
|
28607
|
+
for (let ch; ch = text4[i2 += 1]; ) {
|
|
28458
28608
|
if (mode === FOLD_QUOTED && ch === "\\") {
|
|
28459
28609
|
escStart = i2;
|
|
28460
|
-
switch (
|
|
28610
|
+
switch (text4[i2 + 1]) {
|
|
28461
28611
|
case "x":
|
|
28462
28612
|
i2 += 3;
|
|
28463
28613
|
break;
|
|
@@ -28474,12 +28624,12 @@ function foldFlowLines(text3, indent, mode = "flow", { indentAtStart, lineWidth
|
|
|
28474
28624
|
}
|
|
28475
28625
|
if (ch === "\n") {
|
|
28476
28626
|
if (mode === FOLD_BLOCK)
|
|
28477
|
-
i2 = consumeMoreIndentedLines(
|
|
28627
|
+
i2 = consumeMoreIndentedLines(text4, i2, indent.length);
|
|
28478
28628
|
end = i2 + indent.length + endStep;
|
|
28479
28629
|
split = void 0;
|
|
28480
28630
|
} else {
|
|
28481
28631
|
if (ch === " " && prev && prev !== " " && prev !== "\n" && prev !== " ") {
|
|
28482
|
-
const next =
|
|
28632
|
+
const next = text4[i2 + 1];
|
|
28483
28633
|
if (next && next !== " " && next !== "\n" && next !== " ")
|
|
28484
28634
|
split = i2;
|
|
28485
28635
|
}
|
|
@@ -28491,12 +28641,12 @@ function foldFlowLines(text3, indent, mode = "flow", { indentAtStart, lineWidth
|
|
|
28491
28641
|
} else if (mode === FOLD_QUOTED) {
|
|
28492
28642
|
while (prev === " " || prev === " ") {
|
|
28493
28643
|
prev = ch;
|
|
28494
|
-
ch =
|
|
28644
|
+
ch = text4[i2 += 1];
|
|
28495
28645
|
overflow = true;
|
|
28496
28646
|
}
|
|
28497
28647
|
const j = i2 > escEnd + 1 ? i2 - 2 : escStart - 1;
|
|
28498
28648
|
if (escapedFolds[j])
|
|
28499
|
-
return
|
|
28649
|
+
return text4;
|
|
28500
28650
|
folds.push(j);
|
|
28501
28651
|
escapedFolds[j] = true;
|
|
28502
28652
|
end = j + endStep;
|
|
@@ -28511,39 +28661,39 @@ function foldFlowLines(text3, indent, mode = "flow", { indentAtStart, lineWidth
|
|
|
28511
28661
|
if (overflow && onOverflow)
|
|
28512
28662
|
onOverflow();
|
|
28513
28663
|
if (folds.length === 0)
|
|
28514
|
-
return
|
|
28664
|
+
return text4;
|
|
28515
28665
|
if (onFold)
|
|
28516
28666
|
onFold();
|
|
28517
|
-
let res =
|
|
28667
|
+
let res = text4.slice(0, folds[0]);
|
|
28518
28668
|
for (let i3 = 0; i3 < folds.length; ++i3) {
|
|
28519
28669
|
const fold = folds[i3];
|
|
28520
|
-
const end2 = folds[i3 + 1] ||
|
|
28670
|
+
const end2 = folds[i3 + 1] || text4.length;
|
|
28521
28671
|
if (fold === 0)
|
|
28522
28672
|
res = `
|
|
28523
|
-
${indent}${
|
|
28673
|
+
${indent}${text4.slice(0, end2)}`;
|
|
28524
28674
|
else {
|
|
28525
28675
|
if (mode === FOLD_QUOTED && escapedFolds[fold])
|
|
28526
|
-
res += `${
|
|
28676
|
+
res += `${text4[fold]}\\`;
|
|
28527
28677
|
res += `
|
|
28528
|
-
${indent}${
|
|
28678
|
+
${indent}${text4.slice(fold + 1, end2)}`;
|
|
28529
28679
|
}
|
|
28530
28680
|
}
|
|
28531
28681
|
return res;
|
|
28532
28682
|
}
|
|
28533
|
-
function consumeMoreIndentedLines(
|
|
28683
|
+
function consumeMoreIndentedLines(text4, i2, indent) {
|
|
28534
28684
|
let end = i2;
|
|
28535
28685
|
let start = i2 + 1;
|
|
28536
|
-
let ch =
|
|
28686
|
+
let ch = text4[start];
|
|
28537
28687
|
while (ch === " " || ch === " ") {
|
|
28538
28688
|
if (i2 < start + indent) {
|
|
28539
|
-
ch =
|
|
28689
|
+
ch = text4[++i2];
|
|
28540
28690
|
} else {
|
|
28541
28691
|
do {
|
|
28542
|
-
ch =
|
|
28692
|
+
ch = text4[++i2];
|
|
28543
28693
|
} while (ch && ch !== "\n");
|
|
28544
28694
|
end = i2;
|
|
28545
28695
|
start = i2 + 1;
|
|
28546
|
-
ch =
|
|
28696
|
+
ch = text4[start];
|
|
28547
28697
|
}
|
|
28548
28698
|
}
|
|
28549
28699
|
return end;
|
|
@@ -34369,24 +34519,24 @@ function quoteYaml(value) {
|
|
|
34369
34519
|
if (/^[\w./:+-]+$/.test(value)) return value;
|
|
34370
34520
|
return JSON.stringify(value);
|
|
34371
34521
|
}
|
|
34372
|
-
function upsertHermesProvider(
|
|
34522
|
+
function upsertHermesProvider(text4, hostId, baseUrl, apiKey) {
|
|
34373
34523
|
const block2 = [` ${hostId}:`, ` base_url: ${quoteYaml(baseUrl)}`, ` api_key: ${quoteYaml(apiKey)}`, ""].join(
|
|
34374
34524
|
"\n"
|
|
34375
34525
|
);
|
|
34376
|
-
if (/^providers:\s*$/m.test(
|
|
34377
|
-
const replaced = replaceHermesHostBlock(
|
|
34526
|
+
if (/^providers:\s*$/m.test(text4)) {
|
|
34527
|
+
const replaced = replaceHermesHostBlock(text4, hostId, block2);
|
|
34378
34528
|
if (replaced !== null) return replaced;
|
|
34379
|
-
return
|
|
34529
|
+
return text4.replace(/^providers:\s*$/m, `providers:
|
|
34380
34530
|
${block2.trimEnd()}`);
|
|
34381
34531
|
}
|
|
34382
|
-
const prefix =
|
|
34383
|
-
` :
|
|
34532
|
+
const prefix = text4 && !text4.endsWith("\n") ? `${text4}
|
|
34533
|
+
` : text4;
|
|
34384
34534
|
return `${prefix}
|
|
34385
34535
|
providers:
|
|
34386
34536
|
${block2}`;
|
|
34387
34537
|
}
|
|
34388
|
-
function replaceHermesHostBlock(
|
|
34389
|
-
const lines =
|
|
34538
|
+
function replaceHermesHostBlock(text4, hostId, block2) {
|
|
34539
|
+
const lines = text4.split("\n");
|
|
34390
34540
|
const start = lines.findIndex((line) => line === ` ${hostId}:`);
|
|
34391
34541
|
if (start < 0) return null;
|
|
34392
34542
|
let end = start + 1;
|
|
@@ -34406,14 +34556,14 @@ function ensureHermesInjectProvider(modelId, env = process.env) {
|
|
|
34406
34556
|
const dir = hermesHome(env);
|
|
34407
34557
|
mkdirSync14(dir, { recursive: true });
|
|
34408
34558
|
const path3 = join31(dir, "config.yaml");
|
|
34409
|
-
let
|
|
34559
|
+
let text4 = "";
|
|
34410
34560
|
try {
|
|
34411
|
-
|
|
34561
|
+
text4 = readFileSync17(path3, "utf8");
|
|
34412
34562
|
} catch {
|
|
34413
|
-
|
|
34563
|
+
text4 = "";
|
|
34414
34564
|
}
|
|
34415
|
-
const next = upsertHermesProvider(
|
|
34416
|
-
if (next !==
|
|
34565
|
+
const next = upsertHermesProvider(text4, inject.host, host.baseUrl, hostApiKey(host, env));
|
|
34566
|
+
if (next !== text4) writeFileSync12(path3, next);
|
|
34417
34567
|
return hermesAcpModelId(modelId) ?? modelId;
|
|
34418
34568
|
}
|
|
34419
34569
|
function hermesAcpModelId(modelId) {
|
|
@@ -34423,8 +34573,8 @@ function hermesAcpModelId(modelId) {
|
|
|
34423
34573
|
if (native && !native.includes(INJECT_SEP) && /^[a-z0-9_-]+:[\w./:-]+$/i.test(native)) return native;
|
|
34424
34574
|
return null;
|
|
34425
34575
|
}
|
|
34426
|
-
function nonEmptyDotenvValue(
|
|
34427
|
-
const match = new RegExp(`^[ \\t]*(?:export[ \\t]+)?${name}[ \\t]*=[ \\t]*([^\\r\\n]*)$`, "m").exec(
|
|
34576
|
+
function nonEmptyDotenvValue(text4, name) {
|
|
34577
|
+
const match = new RegExp(`^[ \\t]*(?:export[ \\t]+)?${name}[ \\t]*=[ \\t]*([^\\r\\n]*)$`, "m").exec(text4);
|
|
34428
34578
|
if (!match) return null;
|
|
34429
34579
|
const raw = match[1].trim();
|
|
34430
34580
|
if (!raw || raw.startsWith("#")) return null;
|
|
@@ -34441,10 +34591,10 @@ function nonEmptyDotenvValue(text3, name) {
|
|
|
34441
34591
|
function yamlString(value) {
|
|
34442
34592
|
return typeof value === "string" ? value.trim() : "";
|
|
34443
34593
|
}
|
|
34444
|
-
function hermesConfigDefault(
|
|
34594
|
+
function hermesConfigDefault(text4) {
|
|
34445
34595
|
let raw;
|
|
34446
34596
|
try {
|
|
34447
|
-
raw = parse3(
|
|
34597
|
+
raw = parse3(text4);
|
|
34448
34598
|
} catch {
|
|
34449
34599
|
return null;
|
|
34450
34600
|
}
|
|
@@ -34789,8 +34939,8 @@ var init_openai_compat = __esm({
|
|
|
34789
34939
|
nativeLog: {
|
|
34790
34940
|
source: "openai-compat.chat.completions",
|
|
34791
34941
|
outgoing: (_turn, messages, model) => ({ model, messageCount: messages.length }),
|
|
34792
|
-
incoming: ({ text:
|
|
34793
|
-
textLength:
|
|
34942
|
+
incoming: ({ text: text4, reasoning, usage }) => ({
|
|
34943
|
+
textLength: text4.length,
|
|
34794
34944
|
reasoningLength: reasoning.length,
|
|
34795
34945
|
usage
|
|
34796
34946
|
})
|
|
@@ -35181,10 +35331,10 @@ var init_pi = __esm({
|
|
|
35181
35331
|
child.stdin.write(JSON.stringify(obj) + "\n");
|
|
35182
35332
|
};
|
|
35183
35333
|
const flushAssistantText = () => {
|
|
35184
|
-
const
|
|
35334
|
+
const text4 = assistantText;
|
|
35185
35335
|
assistantText = "";
|
|
35186
|
-
if (!
|
|
35187
|
-
emit({ ...base2(threadId, turnId), type: "item.completed", itemType: "assistant_text", text:
|
|
35336
|
+
if (!text4.trim()) return;
|
|
35337
|
+
emit({ ...base2(threadId, turnId), type: "item.completed", itemType: "assistant_text", text: text4 });
|
|
35188
35338
|
};
|
|
35189
35339
|
const settle = (ok, stopReason, usage) => {
|
|
35190
35340
|
if (settled) return;
|
|
@@ -35577,7 +35727,7 @@ var init_minimax = __esm({
|
|
|
35577
35727
|
nativeLog: {
|
|
35578
35728
|
source: "minimax.chat.completions",
|
|
35579
35729
|
outgoing: (_turn, messages, model) => ({ model, messageCount: messages.length }),
|
|
35580
|
-
incoming: ({ text:
|
|
35730
|
+
incoming: ({ text: text4, usage }) => ({ textLength: text4.length, usage })
|
|
35581
35731
|
}
|
|
35582
35732
|
});
|
|
35583
35733
|
}
|
|
@@ -37244,10 +37394,10 @@ async function verifyHostedEndpoint(endpoint, { fetchImpl, timeoutSignal, timeou
|
|
|
37244
37394
|
signal: cancellationSignal ? AbortSignal.any([requestSignal, cancellationSignal]) : requestSignal
|
|
37245
37395
|
});
|
|
37246
37396
|
if (!response.ok) return false;
|
|
37247
|
-
const
|
|
37248
|
-
if (Buffer.byteLength(
|
|
37397
|
+
const text4 = await response.text();
|
|
37398
|
+
if (Buffer.byteLength(text4) > 4096) return false;
|
|
37249
37399
|
try {
|
|
37250
|
-
return JSON.parse(
|
|
37400
|
+
return JSON.parse(text4)?.app === "openmausbot";
|
|
37251
37401
|
} catch {
|
|
37252
37402
|
return false;
|
|
37253
37403
|
}
|
|
@@ -38168,9 +38318,9 @@ async function startCaddy(options) {
|
|
|
38168
38318
|
});
|
|
38169
38319
|
let output = "";
|
|
38170
38320
|
const receive = (chunk) => {
|
|
38171
|
-
const
|
|
38172
|
-
if (output.length < 16384) output +=
|
|
38173
|
-
for (const line of
|
|
38321
|
+
const text4 = chunk.toString("utf8");
|
|
38322
|
+
if (output.length < 16384) output += text4;
|
|
38323
|
+
for (const line of text4.split(/\r?\n/)) {
|
|
38174
38324
|
if (!line.trim()) continue;
|
|
38175
38325
|
if (/"level":"(warn|error)"/.test(line) || /^\S+\s+(WARN|ERROR)/.test(line) || !line.startsWith("{")) options.log?.(`caddy: ${line.slice(0, 400)}`);
|
|
38176
38326
|
}
|
|
@@ -38437,8 +38587,8 @@ function agentUnit(spec) {
|
|
|
38437
38587
|
function emptyRegistry(domain2) {
|
|
38438
38588
|
return { version: 1, domain: domain2, nextPort: FLEET_FIRST_PORT, workspaces: {} };
|
|
38439
38589
|
}
|
|
38440
|
-
function parseRegistry(
|
|
38441
|
-
const value = JSON.parse(
|
|
38590
|
+
function parseRegistry(text4) {
|
|
38591
|
+
const value = JSON.parse(text4);
|
|
38442
38592
|
const record3 = value && typeof value === "object" ? value : null;
|
|
38443
38593
|
if (!record3 || record3.version !== 1 || typeof record3.domain !== "string" || typeof record3.nextPort !== "number" || !record3.workspaces || typeof record3.workspaces !== "object") {
|
|
38444
38594
|
throw new Error("fleet.json is not a fleet registry this version understands");
|
|
@@ -38862,9 +39012,9 @@ function failed(io, what, output) {
|
|
|
38862
39012
|
return 1;
|
|
38863
39013
|
}
|
|
38864
39014
|
function loadRegistry(layout, deps) {
|
|
38865
|
-
const
|
|
38866
|
-
if (
|
|
38867
|
-
return parseRegistry(
|
|
39015
|
+
const text4 = deps.readText(layout.registryFile);
|
|
39016
|
+
if (text4 === null) throw new Error(`no fleet on this server yet: run \`openmausbot fleet init --domain your.domain\` first`);
|
|
39017
|
+
return parseRegistry(text4);
|
|
38868
39018
|
}
|
|
38869
39019
|
function planFleetAction(input, deps) {
|
|
38870
39020
|
const layout = fleetLayout(input.root ?? "/");
|
|
@@ -39011,13 +39161,13 @@ function readUsage(dataDir, range) {
|
|
|
39011
39161
|
const from = range.from.getTime();
|
|
39012
39162
|
const to = range.to.getTime();
|
|
39013
39163
|
for (const key of monthsBetween(range.from, range.to)) {
|
|
39014
|
-
let
|
|
39164
|
+
let text4;
|
|
39015
39165
|
try {
|
|
39016
|
-
|
|
39166
|
+
text4 = readFileSync2(join4(dataDir, DIR, `${key}.jsonl`), "utf8");
|
|
39017
39167
|
} catch {
|
|
39018
39168
|
continue;
|
|
39019
39169
|
}
|
|
39020
|
-
for (const line of
|
|
39170
|
+
for (const line of text4.split("\n")) {
|
|
39021
39171
|
if (!line) continue;
|
|
39022
39172
|
try {
|
|
39023
39173
|
const value = JSON.parse(line);
|
|
@@ -39111,15 +39261,15 @@ function summarizeUsage(rows, groupBy, prices = null) {
|
|
|
39111
39261
|
var MAX_BODY = 256 * 1024;
|
|
39112
39262
|
function readBody(req) {
|
|
39113
39263
|
return new Promise((resolve13, reject) => {
|
|
39114
|
-
let
|
|
39264
|
+
let text4 = "";
|
|
39115
39265
|
req.on("data", (chunk) => {
|
|
39116
|
-
|
|
39117
|
-
if (
|
|
39266
|
+
text4 += chunk.toString("utf8");
|
|
39267
|
+
if (text4.length > MAX_BODY) reject(Object.assign(new Error("request too large"), { status: 413 }));
|
|
39118
39268
|
});
|
|
39119
39269
|
req.on("end", () => {
|
|
39120
|
-
if (!
|
|
39270
|
+
if (!text4.trim()) return resolve13({});
|
|
39121
39271
|
try {
|
|
39122
|
-
const value = JSON.parse(
|
|
39272
|
+
const value = JSON.parse(text4);
|
|
39123
39273
|
resolve13(value && typeof value === "object" && !Array.isArray(value) ? value : {});
|
|
39124
39274
|
} catch {
|
|
39125
39275
|
reject(Object.assign(new Error("body must be JSON"), { status: 400 }));
|
|
@@ -39290,8 +39440,8 @@ var tailscaleEnvironment = () => ({
|
|
|
39290
39440
|
});
|
|
39291
39441
|
|
|
39292
39442
|
// server/tailscale.ts
|
|
39293
|
-
function classifyTailscaleStderr(
|
|
39294
|
-
const t2 =
|
|
39443
|
+
function classifyTailscaleStderr(text4) {
|
|
39444
|
+
const t2 = text4.toLowerCase();
|
|
39295
39445
|
if (/not logged in|logged out|needs login|please log in/.test(t2)) return "not-logged-in";
|
|
39296
39446
|
if (/is tailscale running|tailscaled is not running|connection refused|failed to connect to local tailscaled/.test(t2)) return "not-running";
|
|
39297
39447
|
if (/access denied|permission denied|operator|must be root|not permitted/.test(t2)) return "needs-operator";
|
|
@@ -40022,9 +40172,9 @@ function pairingBlock(input) {
|
|
|
40022
40172
|
}
|
|
40023
40173
|
return lines.join("\n");
|
|
40024
40174
|
}
|
|
40025
|
-
function qrToString(
|
|
40175
|
+
function qrToString(text4) {
|
|
40026
40176
|
let out = "";
|
|
40027
|
-
import_qrcode_terminal.default.generate(
|
|
40177
|
+
import_qrcode_terminal.default.generate(text4, { small: true }, (rendered) => {
|
|
40028
40178
|
out = rendered;
|
|
40029
40179
|
});
|
|
40030
40180
|
return out;
|