@chibitek/chibi 0.1.206 → 0.1.208
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{TerminalPanel-BBJ8EeT7.js → TerminalPanel-B5bwdaJ5.js} +1 -1
- package/dist/assets/{abnfDiagram-O67JEVCF-a06YszXx.js → abnfDiagram-O67JEVCF-BLKuHvdS.js} +1 -1
- package/dist/assets/{arc-Fe3WbFfc.js → arc-BeOf3Y3d.js} +1 -1
- package/dist/assets/{architectureDiagram-NJMV4G6O-DYcb0ZrL.js → architectureDiagram-NJMV4G6O-DnXr729a.js} +1 -1
- package/dist/assets/{blockDiagram-BEXU5L5S-xC5y8We2.js → blockDiagram-BEXU5L5S-CEiwrTaI.js} +1 -1
- package/dist/assets/{c4Diagram-YGBWAQC7-Dm81dUJa.js → c4Diagram-YGBWAQC7-C0-29khR.js} +1 -1
- package/dist/assets/channel-_JFliC5C.js +1 -0
- package/dist/assets/{chunk-2Q5K7J3B-CDVJUGUd.js → chunk-2Q5K7J3B-D8dKbbui.js} +1 -1
- package/dist/assets/{chunk-3FUC2YCW-BvPx7oJb.js → chunk-3FUC2YCW-fAEY1oOe.js} +2 -2
- package/dist/assets/{chunk-5VM5RSS4-kUQxxDSH.js → chunk-5VM5RSS4-Djza4B4b.js} +1 -1
- package/dist/assets/{chunk-GTNCS2PH-hmSLPBzT.js → chunk-GTNCS2PH-BWFGSXNt.js} +1 -1
- package/dist/assets/{chunk-GWA4HPMP-ivlnCC25.js → chunk-GWA4HPMP-BGo5oevY.js} +1 -1
- package/dist/assets/{chunk-JWPE2WC7-hjxL5olg.js → chunk-JWPE2WC7-DIdxOMOn.js} +1 -1
- package/dist/assets/{chunk-NETBCI7D-ClgHcSe7.js → chunk-NETBCI7D-Dc4tJ9uD.js} +1 -1
- package/dist/assets/{chunk-WEXAMYUT-1i-fNDpg.js → chunk-WEXAMYUT-DvZ9F5yw.js} +1 -1
- package/dist/assets/{chunk-XXDRQBXY-BhPdm5u4.js → chunk-XXDRQBXY-BYUVYcxq.js} +1 -1
- package/dist/assets/{classDiagram-v2-NBCMYWYE-BsL-gKkF.js → classDiagram-v2-NBCMYWYE-BtnsJQvT.js} +1 -1
- package/dist/assets/{cose-bilkent-JH36ORCC-piSPlA0p.js → cose-bilkent-JH36ORCC-DLDe1VHc.js} +1 -1
- package/dist/assets/{cynefin-OW5HDTMX-D2T5q7wD.js → cynefin-OW5HDTMX-a1GJE5iI.js} +1 -1
- package/dist/assets/{cynefinDiagram-VND7K2PF-CWHt2804.js → cynefinDiagram-VND7K2PF-DXxGLDlQ.js} +1 -1
- package/dist/assets/{dagre-6A5THRUB-BNioVBDz.js → dagre-6A5THRUB-DAW_YZe9.js} +1 -1
- package/dist/assets/{diagram-22UHCM2B-DULW9a3n.js → diagram-22UHCM2B-oq3saywD.js} +1 -1
- package/dist/assets/{diagram-3UASUU5V-EYvilvye.js → diagram-3UASUU5V-BhCP3hS9.js} +1 -1
- package/dist/assets/{diagram-ATOU4E4O-BRkFLoxi.js → diagram-ATOU4E4O-ByFRn1dW.js} +1 -1
- package/dist/assets/{diagram-CDSNMT55-B0IbbTpB.js → diagram-CDSNMT55-DWoCvkNH.js} +1 -1
- package/dist/assets/{diagram-MLGK6HIB-u7n_3e2v.js → diagram-MLGK6HIB-CSH5kSlk.js} +1 -1
- package/dist/assets/{diagram-MPIPVDR6-NegomnHr.js → diagram-MPIPVDR6-Cnpx1s-T.js} +1 -1
- package/dist/assets/{ebnfDiagram-ZINNZB2B-BPZmiseK.js → ebnfDiagram-ZINNZB2B-DPmX63Vg.js} +1 -1
- package/dist/assets/{elk-276RUBZZ-BcBEThvp.js → elk-276RUBZZ-DUtmO9kb.js} +1 -1
- package/dist/assets/{erDiagram-OPXOYQCR-BVAGByE5.js → erDiagram-OPXOYQCR-SxwJeJu-.js} +1 -1
- package/dist/assets/{flowDiagram-KWPJA3E3-ByZ1IyAE.js → flowDiagram-KWPJA3E3--QZAAUjB.js} +1 -1
- package/dist/assets/{ganttDiagram-FUAMR5RP-CEa3O2pJ.js → ganttDiagram-FUAMR5RP-CRz6i2Pe.js} +1 -1
- package/dist/assets/{gitGraphDiagram-X574FWY7-dul-ZoaX.js → gitGraphDiagram-X574FWY7-Dx9Cisl2.js} +1 -1
- package/dist/assets/{index-CFUbzTrj.js → index-BGkOob08.js} +1 -1
- package/dist/assets/{index-Tw4-5a-J.js → index-vIsgWbJW.js} +153 -153
- package/dist/assets/{infoDiagram-VRGFBTTK-Bt9KS597.js → infoDiagram-VRGFBTTK-CDLogk8N.js} +1 -1
- package/dist/assets/{ishikawaDiagram-OU5B5YK6-BjJTuEjh.js → ishikawaDiagram-OU5B5YK6-DsrF1wno.js} +1 -1
- package/dist/assets/{journeyDiagram-ZHPQQLJL-j07hDjg4.js → journeyDiagram-ZHPQQLJL-DUi8LEA6.js} +1 -1
- package/dist/assets/{kanban-definition-PNTS6WVX-DU8baSEs.js → kanban-definition-PNTS6WVX-BAdWXobw.js} +1 -1
- package/dist/assets/{linear-Dj1tr9Bh.js → linear-Dha948ns.js} +1 -1
- package/dist/assets/{mermaid.core-BeSGZMCl.js → mermaid.core-BqT1aUP9.js} +5 -5
- package/dist/assets/{mindmap-definition-NLK3R4M7-LiRl-Bq2.js → mindmap-definition-NLK3R4M7-XS1wDQ80.js} +1 -1
- package/dist/assets/{pegDiagram-GJSIUBJH-COL7EWof.js → pegDiagram-GJSIUBJH-BphuafcF.js} +1 -1
- package/dist/assets/{pieDiagram-5QR66LMP-BnMXaara.js → pieDiagram-5QR66LMP-JN9mbdiU.js} +1 -1
- package/dist/assets/{quadrantDiagram-O4NWA36T-BjLcZ6bG.js → quadrantDiagram-O4NWA36T-CkBF7Woa.js} +1 -1
- package/dist/assets/{railroadDiagram-XR7U4H2S-wKCzKLAA.js → railroadDiagram-XR7U4H2S-Ie1GVpj5.js} +1 -1
- package/dist/assets/{requirementDiagram-PLB6GJNP-BjoTwmZ-.js → requirementDiagram-PLB6GJNP-B8xGM6w4.js} +1 -1
- package/dist/assets/{sankeyDiagram-IPEJSGJF-CuGyR0Tn.js → sankeyDiagram-IPEJSGJF-BgTSlqMg.js} +1 -1
- package/dist/assets/{sequenceDiagram-PO4LG4MO-DxOzUuSx.js → sequenceDiagram-PO4LG4MO-B1J4EIne.js} +1 -1
- package/dist/assets/{sizeCapture-INFHLROL-B-bTrmx9.js → sizeCapture-INFHLROL-Cpcjc5oE.js} +1 -1
- package/dist/assets/{stateDiagram-v2-GCMORJYK-D6ZflrZQ.js → stateDiagram-v2-GCMORJYK-CtQKYLT4.js} +1 -1
- package/dist/assets/{swimlanes-2SLR337P-DKgdDJlH.js → swimlanes-2SLR337P-DpIk02zs.js} +1 -1
- package/dist/assets/swimlanesDiagram-TC7HE7FX-DPTl4zVS.js +8 -0
- package/dist/assets/{timeline-definition-EJHVYXUP-Dli4hqxc.js → timeline-definition-EJHVYXUP-DsA7dQhy.js} +1 -1
- package/dist/assets/{usecaseDiagram-POWQR4AR-CQ8Cc1rN.js → usecaseDiagram-POWQR4AR-BM42_rDz.js} +1 -1
- package/dist/assets/{vennDiagram-UO4OBE2U-JEu7ZkzA.js → vennDiagram-UO4OBE2U-DgLtqgJF.js} +1 -1
- package/dist/assets/{wardleyDiagram-VNRHLVJA-DkFigbd0.js → wardleyDiagram-VNRHLVJA-BKUUTKBJ.js} +1 -1
- package/dist/assets/{xychartDiagram-PMCCYNJV-DwOctln8.js → xychartDiagram-PMCCYNJV-B9RWvizV.js} +1 -1
- package/dist/index.html +1 -1
- package/dist-server/accounts-proxy.js +12 -2
- package/dist-server/browser-proxy.js +15 -2
- package/dist-server/drivers/phone-proxy.js +13 -4
- package/dist-server/index.js +3168 -2730
- package/dist-server/openmausbot.js +821 -638
- package/dist-server/pair-cli.js +821 -638
- package/dist-server/server/accounts-proxy.js +17 -2
- package/dist-server/server/agents-token-file.js +10 -7
- package/dist-server/server/browser-proxy.js +18 -2
- package/dist-server/server/connection-cap-failover.js +8 -4
- package/dist-server/server/drivers/acp/core.js +20 -47
- package/dist-server/server/drivers/acp/custom.js +5 -0
- package/dist-server/server/drivers/acp/hermes.js +1 -0
- package/dist-server/server/drivers/acp/kimi-turn-failure.js +68 -0
- package/dist-server/server/drivers/acp/kimi.js +7 -0
- package/dist-server/server/drivers/acp/mcp-limit.js +47 -0
- package/dist-server/server/drivers/acp/rpc-error.js +35 -0
- package/dist-server/server/drivers/acp/setup-failure.js +9 -0
- package/dist-server/server/drivers/acp/vibe.js +11 -5
- package/dist-server/server/drivers/chat-text-only.js +47 -0
- package/dist-server/server/drivers/openai-chat-protocol.js +15 -0
- package/dist-server/server/drivers/openai-chat.js +8 -18
- package/dist-server/server/drivers/phone-proxy.js +18 -4
- package/dist-server/server/drivers/turn-mcp.js +3 -0
- package/dist-server/server/drivers/vibe-login.js +17 -8
- package/dist-server/server/engine-failover.js +16 -24
- package/dist-server/server/engine-failure.js +3 -3
- package/dist-server/server/engine-rest.js +5 -3
- package/dist-server/server/engine-tiers.js +12 -9
- package/dist-server/server/harness/bus.js +7 -2
- package/dist-server/server/index.js +19 -18
- package/dist-server/server/injected-model-rest.js +17 -0
- package/dist-server/server/model-levels/aliases.js +243 -38
- package/dist-server/server/model-levels/chibitek-rankings.js +8 -8
- package/dist-server/server/model-levels/classes.js +106 -38
- package/dist-server/server/model-levels/index.js +26 -14
- package/dist-server/server/model-levels/model-ids.js +91 -0
- package/dist-server/server/model-levels/overrides.js +7 -4
- package/dist-server/server/model-levels/sources.js +4 -1
- package/dist-server/server/pay-per-use.js +13 -1
- package/package.json +1 -1
- package/dist/assets/channel-D3ihDYTR.js +0 -1
- package/dist/assets/swimlanesDiagram-TC7HE7FX-DSlLxTUH.js +0 -8
|
@@ -5,9 +5,24 @@
|
|
|
5
5
|
// the harness decides, per call, which accounts this bot may use.
|
|
6
6
|
//
|
|
7
7
|
// stdout is the MCP transport. Never log there.
|
|
8
|
+
import { readFileSync } from "node:fs";
|
|
8
9
|
import readline from "node:readline";
|
|
9
10
|
const HARNESS = process.env.OMB_HARNESS_URL ?? "http://127.0.0.1:8799";
|
|
10
|
-
const
|
|
11
|
+
const TOKEN_FILE = process.env.OMB_ACCOUNTS_TOKEN_FILE ?? "";
|
|
12
|
+
const SPAWN_TOKEN = process.env.OMB_ACCOUNTS_TOKEN ?? "";
|
|
13
|
+
// Read per call: the harness rewrites the file each turn, and a pooled engine
|
|
14
|
+
// keeps this process across turns, so the spawn-time token is revoked by turn
|
|
15
|
+
// two and every call would answer "this turn's tool access has expired".
|
|
16
|
+
const token = () => {
|
|
17
|
+
if (!TOKEN_FILE)
|
|
18
|
+
return SPAWN_TOKEN;
|
|
19
|
+
try {
|
|
20
|
+
return readFileSync(TOKEN_FILE, "utf8").trim() || SPAWN_TOKEN;
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return SPAWN_TOKEN;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
11
26
|
const TIMEOUT_MS = 3 * 60_000;
|
|
12
27
|
const MAX_RESPONSE_BYTES = 1024 * 1024;
|
|
13
28
|
const send = (message) => process.stdout.write(`${JSON.stringify(message)}\n`);
|
|
@@ -17,7 +32,7 @@ const textResult = (text, isError = false) => ({ content: [{ type: "text", text
|
|
|
17
32
|
async function harness(path, init = {}) {
|
|
18
33
|
const response = await fetch(`${HARNESS}${path}`, {
|
|
19
34
|
...init,
|
|
20
|
-
headers: { "content-type": "application/json", authorization: `Bearer ${
|
|
35
|
+
headers: { "content-type": "application/json", authorization: `Bearer ${token()}` },
|
|
21
36
|
signal: AbortSignal.timeout(TIMEOUT_MS),
|
|
22
37
|
});
|
|
23
38
|
const text = await response.text();
|
|
@@ -1,22 +1,25 @@
|
|
|
1
|
-
//
|
|
1
|
+
// A spawned proxy's current bearer, on disk. The harness rewrites it every
|
|
2
2
|
// turn; the proxy reads it per call. An ACP engine keeps the proxy process it
|
|
3
3
|
// connected at session/new for the whole pooled session (Hermes skips
|
|
4
4
|
// already-connected MCP names on session/load), so a token carried only in
|
|
5
|
-
// the spawn environment is revoked by turn two and every
|
|
6
|
-
// answers INTERNAL_CAPABILITY_EXPIRED until the session idles out.
|
|
5
|
+
// the spawn environment is revoked by turn two and every tool call through
|
|
6
|
+
// that proxy answers INTERNAL_CAPABILITY_EXPIRED until the session idles out.
|
|
7
|
+
// Applies to every turn-scoped proxy (agents, accounts, phone, browser). Same
|
|
7
8
|
// pattern as the Claude driver's hook tokens; never exported in a backup.
|
|
8
9
|
import { createHash } from "node:crypto";
|
|
9
10
|
import { mkdirSync } from "node:fs";
|
|
10
11
|
import { join } from "node:path";
|
|
11
12
|
import { writeFileAtomic } from "./atomic.js";
|
|
12
13
|
import { DATA_DIR } from "./config.js";
|
|
13
|
-
|
|
14
|
+
// "agents" keeps its historical bare name so a pooled agents proxy spawned by
|
|
15
|
+
// an older harness build still finds its file after an update.
|
|
16
|
+
export function agentsTokenFile(botId, threadId, dataDir = DATA_DIR, kind = "agents") {
|
|
14
17
|
const digest = createHash("sha256").update(`${botId}\0${threadId}`).digest("hex").slice(0, 24);
|
|
15
|
-
return join(dataDir, "agents-tokens", `${digest}.token`);
|
|
18
|
+
return join(dataDir, "agents-tokens", kind === "agents" ? `${digest}.token` : `${digest}.${kind}.token`);
|
|
16
19
|
}
|
|
17
20
|
/** Writes this turn's token (0600) and returns the path the proxy reads. */
|
|
18
|
-
export function writeAgentsTokenFile(botId, threadId, token, dataDir = DATA_DIR) {
|
|
19
|
-
const path = agentsTokenFile(botId, threadId, dataDir);
|
|
21
|
+
export function writeAgentsTokenFile(botId, threadId, token, dataDir = DATA_DIR, kind = "agents") {
|
|
22
|
+
const path = agentsTokenFile(botId, threadId, dataDir, kind);
|
|
20
23
|
mkdirSync(join(dataDir, "agents-tokens"), { recursive: true, mode: 0o700 });
|
|
21
24
|
writeFileAtomic(path, token, { mode: 0o600 });
|
|
22
25
|
return path;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Per-turn MCP entry point. Only a scoped browser capability crosses into the
|
|
2
2
|
// agent process; engine commands, session names, and credentials stay in OMB.
|
|
3
|
+
import { readFileSync } from "node:fs";
|
|
3
4
|
import { pathToFileURL } from "node:url";
|
|
4
5
|
const MAX_INPUT_BYTES = 1_048_576;
|
|
5
6
|
const MAX_OUTPUT_BYTES = 16_777_216;
|
|
@@ -75,7 +76,22 @@ export async function browserProxyRequest(frame, connection) {
|
|
|
75
76
|
}
|
|
76
77
|
}
|
|
77
78
|
function run() {
|
|
78
|
-
const
|
|
79
|
+
const url = process.env.OMB_HARNESS_URL ?? "";
|
|
80
|
+
const spawnToken = process.env.OMB_BROWSER_TOKEN ?? "";
|
|
81
|
+
const tokenFile = process.env.OMB_BROWSER_TOKEN_FILE ?? "";
|
|
82
|
+
// Read per call: the harness rewrites the file each turn, and a pooled
|
|
83
|
+
// engine keeps this process across turns, so the spawn-time token is
|
|
84
|
+
// revoked by turn two.
|
|
85
|
+
const connection = () => {
|
|
86
|
+
let token = spawnToken;
|
|
87
|
+
if (tokenFile) {
|
|
88
|
+
try {
|
|
89
|
+
token = readFileSync(tokenFile, "utf8").trim() || spawnToken;
|
|
90
|
+
}
|
|
91
|
+
catch { /* fall back */ }
|
|
92
|
+
}
|
|
93
|
+
return { url, token };
|
|
94
|
+
};
|
|
79
95
|
let input = Buffer.alloc(0);
|
|
80
96
|
let pending = 0;
|
|
81
97
|
const output = (message) => {
|
|
@@ -118,7 +134,7 @@ function run() {
|
|
|
118
134
|
continue;
|
|
119
135
|
}
|
|
120
136
|
pending++;
|
|
121
|
-
void browserProxyRequest(frame, connection).then(output).finally(() => { pending--; });
|
|
137
|
+
void browserProxyRequest(frame, connection()).then(output).finally(() => { pending--; });
|
|
122
138
|
}
|
|
123
139
|
if (input.length > MAX_INPUT_BYTES) {
|
|
124
140
|
process.stdin.destroy();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DEFAULT_CONNECTION_RUN_OUT, isConnectionRunOutPolicy, } from "../shared/engine-tiers.js";
|
|
2
2
|
import { redactSecretsInText } from "../shared/redact.js";
|
|
3
|
-
import {
|
|
3
|
+
import { MAX_ENGINES_WALKED, restingLine } from "./engine-failover.js";
|
|
4
4
|
import { computeBackoff, interruptibleDelay, RETRY_MAX_RETRIES } from "./drivers/retry.js";
|
|
5
5
|
export { DEFAULT_CONNECTION_RUN_OUT, interruptibleDelay };
|
|
6
6
|
/** Matches the driver retry budget so harness policy and CLI retries agree. */
|
|
@@ -134,12 +134,12 @@ export function finalizeConnectionCapPick(input) {
|
|
|
134
134
|
return { line: transientThrottleStopLine(input.currentLabel), category: "failover_exhausted" };
|
|
135
135
|
}
|
|
136
136
|
const { choice } = input;
|
|
137
|
-
if (!choice && input.failureKind === "provider_error")
|
|
138
|
-
return { passthrough: true };
|
|
139
137
|
if (!choice) {
|
|
140
138
|
if (input.pausedUntil !== undefined && input.skipped.some((skip) => skip.reason === "paused")) {
|
|
141
139
|
return { line: input.payPerUsePausedLine(input.pausedUntil) };
|
|
142
140
|
}
|
|
141
|
+
// A paid key is the one way left: ask before anything else, so the
|
|
142
|
+
// person gets the notice rather than an engine's raw error.
|
|
143
143
|
const waiting = decideNewTurnPlacement({
|
|
144
144
|
policy: input.policy, paidApproved: input.paidApproved,
|
|
145
145
|
skippedPausedKey: input.skipped.some((skip) => skip.reason === "paused"),
|
|
@@ -149,10 +149,14 @@ export function finalizeConnectionCapPick(input) {
|
|
|
149
149
|
input.announceWaiting?.();
|
|
150
150
|
return { line: waiting.line, category: "failover_exhausted" };
|
|
151
151
|
}
|
|
152
|
+
// The turn's only engine failed in a way nothing recognises and there is
|
|
153
|
+
// nowhere to move: its own words say more than "no engine is free".
|
|
154
|
+
if (input.failureKind === "provider_error" && input.triedCount <= 1)
|
|
155
|
+
return { passthrough: true };
|
|
152
156
|
const resting = input.skipped.filter((skip) => skip.reason === "resting" || skip.reason === "tried").map((skip) => skip.instanceId);
|
|
153
157
|
const named = input.restingNamed([input.failedInstanceId, ...input.alreadyTried, ...resting]);
|
|
154
158
|
return {
|
|
155
|
-
line: restingLine(named, input.formatTime, input.cannotDrive, { capped: input.triedCount >=
|
|
159
|
+
line: restingLine(named, input.formatTime, input.cannotDrive, { capped: input.triedCount >= MAX_ENGINES_WALKED }),
|
|
156
160
|
category: named.some((engine) => engine.needsSignIn || engine.keyExpired) || input.cannotDrive?.signedOut?.length ? "account" : "failover_exhausted",
|
|
157
161
|
};
|
|
158
162
|
}
|
|
@@ -47,44 +47,17 @@ import { appendNative } from "../native.js";
|
|
|
47
47
|
import { commandSummary, toolDetailPreview } from "../../tool-summary.js";
|
|
48
48
|
import { extractMcpImages } from "../../mcp-tool-images.js";
|
|
49
49
|
import { mcpToolRefFromLabel } from "../../../shared/mcp-tool-ref.js";
|
|
50
|
-
import { redactSecretsInText } from "../../redact.js";
|
|
51
50
|
import { isBrokenAntigravityCheckpoint, isAntigravityCheckpointReply } from "../../checkpoint-recovery.js";
|
|
52
51
|
import { recoveryPromptFor } from "../../resume-recovery.js";
|
|
53
52
|
import { isModelRejection } from "../retry.js";
|
|
54
|
-
import { engineFailureFromCode, isCredentialDead, isOpaqueRequestRejection, logAuthFailure
|
|
53
|
+
import { engineFailureFromCode, isCredentialDead, isOpaqueRequestRejection, logAuthFailure } from "../../engine-failure.js";
|
|
55
54
|
import { turnMcpServers } from "../turn-mcp.js";
|
|
56
55
|
import { volatileNote, volatileSectionsOf, withNote } from "../volatile-notes.js";
|
|
57
56
|
import { sanitizeAcpToolMessage } from "./tool-log.js";
|
|
57
|
+
import { acpRpcError } from "./rpc-error.js";
|
|
58
|
+
import { sessionMcpServers } from "./mcp-limit.js";
|
|
59
|
+
import { failureFields } from "./setup-failure.js";
|
|
58
60
|
import { armModeReadback, forgetStaleModeReport, noteModeReport, noteModeUpdate } from "./mode-readback.js";
|
|
59
|
-
/** ACP vendors put the actionable cause in error.data while keeping the
|
|
60
|
-
* JSON-RPC message generic. Only surface known text fields, never a response
|
|
61
|
-
* body/config dump, and redact before bounding the displayed diagnostic. */
|
|
62
|
-
function acpRpcError(value, method) {
|
|
63
|
-
const message = typeof value?.message === "string" ? value.message : "ACP request failed";
|
|
64
|
-
const data = value?.data;
|
|
65
|
-
const detail = typeof data === "string" ? data
|
|
66
|
-
: typeof data?.details === "string" ? data.details
|
|
67
|
-
: typeof data?.message === "string" ? data.message
|
|
68
|
-
: typeof data?.error?.message === "string" ? data.error.message
|
|
69
|
-
: "";
|
|
70
|
-
const context = [
|
|
71
|
-
method,
|
|
72
|
-
typeof data?.service === "string" ? `service: ${data.service}` : "",
|
|
73
|
-
typeof data?.errorName === "string" ? data.errorName : "",
|
|
74
|
-
].filter(Boolean).join(", ");
|
|
75
|
-
const said = detail && detail !== message ? `${message}: ${detail}` : message;
|
|
76
|
-
// A reset the agent sent only as data (Gemini's RetryInfo retryDelay, a
|
|
77
|
-
// resetsAt) joins the words, so the harness rests the engine until then.
|
|
78
|
-
const reset = parseResetAt(said) === undefined ? resetHintFromData(data) : undefined;
|
|
79
|
-
const diagnostic = `${said}${reset ? ` (${reset})` : ""} (${context})`;
|
|
80
|
-
const error = new Error(redactSecretsInText(diagnostic).slice(0, 1500));
|
|
81
|
-
return Object.assign(error, { code: value?.code, data,
|
|
82
|
-
// -32603 is JSON-RPC's internal error. Invalid params, unsupported
|
|
83
|
-
// methods and auth refusals are user/configuration issues, not evidence
|
|
84
|
-
// of a broken process. Preserve their session instead of retrying them.
|
|
85
|
-
acpSessionFailure: value?.code === -32603,
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
61
|
/** An agent's error as a provider code: the support's own classifier
|
|
89
62
|
* first, then the words themselves for a dead key, which every agent wraps
|
|
90
63
|
* differently (OpenCode: JSON-RPC -32603 "Internal error: This API key has
|
|
@@ -447,7 +420,7 @@ export function createAcpDriver(support) {
|
|
|
447
420
|
emit({
|
|
448
421
|
...base(threadId, current.turnId),
|
|
449
422
|
type: "runtime.error",
|
|
450
|
-
message: `${DRIVER_KIND} ended the turn with no reply, image, or tool result`,
|
|
423
|
+
message: current.emptyReason ?? `${DRIVER_KIND} ended the turn with no reply, image, or tool result`,
|
|
451
424
|
});
|
|
452
425
|
}
|
|
453
426
|
emit({ ...base(threadId, current.turnId), type: "turn.completed", ok: finalOk, stopReason: finalStopReason, cost: null });
|
|
@@ -959,11 +932,8 @@ export function createAcpDriver(support) {
|
|
|
959
932
|
session.dead = true;
|
|
960
933
|
const current = session.current;
|
|
961
934
|
if (current) {
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
type: "runtime.error",
|
|
965
|
-
message: `${DRIVER_KIND} exited ${code} before the prompt result${session.stderr ? `: ${session.stderr.trim().slice(-300)}` : ""}`,
|
|
966
|
-
});
|
|
935
|
+
const message = `${DRIVER_KIND} exited ${code} before the prompt result${session.stderr ? `: ${session.stderr.trim().slice(-300)}` : ""}`;
|
|
936
|
+
emit({ ...base(threadId, current.turnId), type: "runtime.error", message, ...failureFields(!current.state.promptSent && !session.closing, undefined, message) });
|
|
967
937
|
settle(threadId, session, false, "exit_before_result");
|
|
968
938
|
}
|
|
969
939
|
else if (sessions.get(threadId) === session) {
|
|
@@ -1222,9 +1192,11 @@ export function createAcpDriver(support) {
|
|
|
1222
1192
|
// stdio is every agent's baseline; a url server rides only with
|
|
1223
1193
|
// an agent that advertised its transport, so an agent without
|
|
1224
1194
|
// http/sse never sees an entry it would refuse the session over
|
|
1225
|
-
const sessionServers = mcpServers.filter((server) => !("type" in server) || init?.agentCapabilities?.mcpCapabilities?.[server.type] === true);
|
|
1195
|
+
const sessionServers = sessionMcpServers(support, mcpServers.filter((server) => !("type" in server) || init?.agentCapabilities?.mcpCapabilities?.[server.type] === true));
|
|
1226
1196
|
let loaded = false;
|
|
1227
|
-
|
|
1197
|
+
// only a cold child restores the session from disk (see freshSessionForLocalModel)
|
|
1198
|
+
const fresh = support.freshSessionForLocalModel === true && liveSessionId !== cursor && decodeInjectId(turn.model) !== null;
|
|
1199
|
+
if (cursor && !fresh) {
|
|
1228
1200
|
try {
|
|
1229
1201
|
await request(support.resumeMethod === "resume" ? "session/resume" : "session/load", { sessionId: cursor, cwd, mcpServers: sessionServers }, LOAD_SESSION_TIMEOUT, (result) => {
|
|
1230
1202
|
if (result) {
|
|
@@ -1410,6 +1382,7 @@ export function createAcpDriver(support) {
|
|
|
1410
1382
|
log: (readback) => appendNative(threadId, { dir: "out", source: SOURCE, msg: { approvalReadback: readback } }),
|
|
1411
1383
|
stop: (message) => { emit({ ...base(threadId, turnId), type: "runtime.error", message }); interrupt(); } });
|
|
1412
1384
|
state.promptSent = true;
|
|
1385
|
+
const promptedAt = Date.now();
|
|
1413
1386
|
const promptIdleMs = promptIdleTimeoutMs(support, cliTurn.model);
|
|
1414
1387
|
const result = await request("session/prompt", { sessionId, prompt: [{ type: "text", text }, ...imageBlocks] }, undefined, undefined, promptIdleMs, `${DRIVER_KIND} went fully silent ${Math.round(promptIdleMs / 1000)} s after the message and the turn was stopped. ` +
|
|
1415
1388
|
"Raise OPENMAUS_ACP_PROMPT_IDLE_TIMEOUT_MS if this model legitimately takes longer to answer.").catch((error) => {
|
|
@@ -1429,8 +1402,11 @@ export function createAcpDriver(support) {
|
|
|
1429
1402
|
});
|
|
1430
1403
|
}
|
|
1431
1404
|
const reason = result?.stopReason;
|
|
1432
|
-
if (reason === "end_turn")
|
|
1405
|
+
if (reason === "end_turn") {
|
|
1406
|
+
if (!state.producedItem && !state.text.trim())
|
|
1407
|
+
current.emptyReason = await support.explainEmptyTurn?.({ sessionId, since: promptedAt, env });
|
|
1433
1408
|
settle(threadId, session, true, null);
|
|
1409
|
+
}
|
|
1434
1410
|
else if (reason === "cancelled")
|
|
1435
1411
|
settle(threadId, session, true, "cancelled");
|
|
1436
1412
|
else {
|
|
@@ -1464,13 +1440,10 @@ export function createAcpDriver(support) {
|
|
|
1464
1440
|
// the harness rests the engine briefly and moves the turn.
|
|
1465
1441
|
const failure = needsAuth ? "auth_failed" : stalled ? "stalled"
|
|
1466
1442
|
: engineFailureFromCode(code) ?? (isOpaqueRequestRejection(message) ? "request_rejected" : undefined);
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
...(needsAuth ? { setup: true } : {}),
|
|
1472
|
-
...(failure ? { failure } : {}),
|
|
1473
|
-
});
|
|
1443
|
+
// Nothing ran on this engine when the prompt was never sent,
|
|
1444
|
+
// unless the session was closed from this side (a stop).
|
|
1445
|
+
const setup = needsAuth || (!state.promptSent && !session.closing);
|
|
1446
|
+
emit({ ...base(threadId, turnId), type: "runtime.error", message, ...failureFields(setup, failure, message) });
|
|
1474
1447
|
// Evict unusable sessions without replaying accepted prompts.
|
|
1475
1448
|
// The harness invalidates broken checkpoints durably so the
|
|
1476
1449
|
// next explicit turn rebuilds from the retained transcript.
|
|
@@ -138,6 +138,9 @@ const support = {
|
|
|
138
138
|
throw new Error(`Atomic Engine rejected model "${modelId}" via session/set_model: ${error.message}`);
|
|
139
139
|
}
|
|
140
140
|
},
|
|
141
|
+
// A cold Atomic Engine restores a saved session without its local provider
|
|
142
|
+
// and then posts the prompt to api.anthropic.com: never session/load there.
|
|
143
|
+
freshSessionForLocalModel: true,
|
|
141
144
|
defaultCli: "",
|
|
142
145
|
nativeSource: "custom.acp",
|
|
143
146
|
loginNote: CONFIGURE_HINT,
|
|
@@ -204,6 +207,8 @@ function customDriver(options) {
|
|
|
204
207
|
export const CustomAcpDriver = customDriver(support);
|
|
205
208
|
export const AtomicEngineDriver = customDriver({
|
|
206
209
|
...support, driverKind: "atomicEngine", displayName: "Atomic Engine", defaultCli: DEFAULT_ATOMIC_ENGINE_CLI,
|
|
210
|
+
// It gives each account 180 s of silence before it moves to its next one, and says nothing over ACP while it does.
|
|
211
|
+
promptIdleMs: 600_000,
|
|
207
212
|
async configureSession(context) {
|
|
208
213
|
await support.configureSession?.(context);
|
|
209
214
|
const modeId = context.turn.approvalMode === "plan" ? "atomic-plan-v1" : "default";
|
|
@@ -595,6 +595,7 @@ const support = {
|
|
|
595
595
|
// a longer idle window than the default (a rejected key is caught sooner,
|
|
596
596
|
// from its log, by the core's stderr check).
|
|
597
597
|
promptIdleMs: 300_000,
|
|
598
|
+
mcpServerLimit: { count: 16, bytes: 56_000 }, // its gateway refuses a 17th, or 65536 bytes once it adds its own fields
|
|
598
599
|
loginNote: "Hermes CLI is not installed",
|
|
599
600
|
// No install command: setup never installs Hermes (Erick, 2026-11-08).
|
|
600
601
|
// Nous Research signs in with a Nous Portal API key instead
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// Kimi Code ends a turn its provider refused with a plain end_turn and no
|
|
2
|
+
// content, so Atomic could only say "ended the turn with no reply". The
|
|
3
|
+
// reason (a 403 for a plan without Kimi Code access, a 401, an overloaded
|
|
4
|
+
// model) is in the session's own log, written as the turn ends:
|
|
5
|
+
//
|
|
6
|
+
// <root>/sessions/<workdir>/<sessionId>/logs/kimi-code.log
|
|
7
|
+
// 2026-11-22T12:10:22.928Z WARN acp: turn ended with failed reason error="{\"code\":\"provider.api_error\",\"message\":\"403 ...\",...}"
|
|
8
|
+
//
|
|
9
|
+
// (verified against kimi-code's logs of 2026-09-24 to 2026-11-22). The
|
|
10
|
+
// provider's message is reported as the turn's error, so the harness reads
|
|
11
|
+
// it like any other engine's refusal.
|
|
12
|
+
import { closeSync, existsSync, fstatSync, openSync, readdirSync, readSync } from "node:fs";
|
|
13
|
+
import { join } from "node:path";
|
|
14
|
+
import { redactSecretsInText } from "../../redact.js";
|
|
15
|
+
const FAILED_TURN = /^(\S+)\s+\w+\s+acp: turn ended with failed reason\s+error=("(?:[^"\\]|\\.)*")/;
|
|
16
|
+
const TAIL_BYTES = 256 * 1024;
|
|
17
|
+
function tail(path) {
|
|
18
|
+
const file = openSync(path, "r");
|
|
19
|
+
try {
|
|
20
|
+
const size = fstatSync(file).size;
|
|
21
|
+
const buffer = Buffer.alloc(Math.min(size, TAIL_BYTES));
|
|
22
|
+
readSync(file, buffer, 0, buffer.length, size - buffer.length);
|
|
23
|
+
return buffer.toString("utf8");
|
|
24
|
+
}
|
|
25
|
+
finally {
|
|
26
|
+
closeSync(file);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/** The provider's message from the session's newest failed-turn record, when
|
|
30
|
+
* that record is no older than `since` (epoch ms): an older one belongs to an
|
|
31
|
+
* earlier turn of the same session. Never throws. */
|
|
32
|
+
export function kimiTurnFailure(dataRoot, sessionId, since) {
|
|
33
|
+
try {
|
|
34
|
+
// the id becomes a path segment: nothing that could leave the sessions folder
|
|
35
|
+
if (!/^[\w-]+$/.test(sessionId))
|
|
36
|
+
return undefined;
|
|
37
|
+
const sessions = join(dataRoot, "sessions");
|
|
38
|
+
const log = readdirSync(sessions).map((workdir) => join(sessions, workdir, sessionId, "logs", "kimi-code.log")).find((path) => existsSync(path));
|
|
39
|
+
if (!log)
|
|
40
|
+
return undefined;
|
|
41
|
+
const lines = tail(log).split(/\r?\n/);
|
|
42
|
+
for (let index = lines.length - 1; index >= 0; index--) {
|
|
43
|
+
const record = FAILED_TURN.exec(lines[index]);
|
|
44
|
+
if (!record)
|
|
45
|
+
continue;
|
|
46
|
+
if (!(Date.parse(record[1]) >= since))
|
|
47
|
+
return undefined;
|
|
48
|
+
const error = JSON.parse(JSON.parse(record[2]));
|
|
49
|
+
const message = typeof error.message === "string" ? error.message.trim() : "";
|
|
50
|
+
return message ? redactSecretsInText(message).slice(0, 600) : undefined;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
// an unreadable or reshaped log explains nothing: the generic line stands
|
|
55
|
+
}
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
/** The same, waiting briefly for a record Kimi has not flushed yet: it logs
|
|
59
|
+
* the failure and answers end_turn in the same millisecond. */
|
|
60
|
+
export async function awaitKimiTurnFailure(dataRoot, sessionId, since, waitMs = 1_500) {
|
|
61
|
+
const deadline = Date.now() + waitMs;
|
|
62
|
+
for (;;) {
|
|
63
|
+
const message = kimiTurnFailure(dataRoot, sessionId, since);
|
|
64
|
+
if (message || Date.now() >= deadline)
|
|
65
|
+
return message;
|
|
66
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -11,6 +11,7 @@ import { homedir } from "node:os";
|
|
|
11
11
|
import { join } from "node:path";
|
|
12
12
|
import { decodeInjectId, hostApiKey, LOCAL_HOSTS, localHost, mergeLocalInject } from "../local-inject.js";
|
|
13
13
|
import { createAcpDriver } from "./core.js";
|
|
14
|
+
import { awaitKimiTurnFailure } from "./kimi-turn-failure.js";
|
|
14
15
|
const STATIC_KIMI_MODELS = {
|
|
15
16
|
default: "kimi-code/k3",
|
|
16
17
|
options: [
|
|
@@ -581,6 +582,12 @@ const support = {
|
|
|
581
582
|
}
|
|
582
583
|
},
|
|
583
584
|
buildPromptText: (turn) => (turn.system ? `${turn.system}\n\n${turn.text}` : turn.text),
|
|
585
|
+
// Kimi answers end_turn with nothing when its provider refused the turn
|
|
586
|
+
// (a 403 for a plan without Kimi Code access): the reason is in its log.
|
|
587
|
+
explainEmptyTurn: async ({ sessionId, since, env }) => {
|
|
588
|
+
const message = await awaitKimiTurnFailure(kimiDataRoot(env), sessionId, since);
|
|
589
|
+
return message ? `Kimi: ${message}` : undefined;
|
|
590
|
+
},
|
|
584
591
|
};
|
|
585
592
|
/** Kimi's ACP session mode for a turn: `yolo` for Full, `default` otherwise. */
|
|
586
593
|
export function kimiSessionMode(fullAuto) {
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// An agent that caps the MCP servers of one session refuses the whole session
|
|
2
|
+
// when it is sent more. Hermes' gateway answers session/new and session/load
|
|
3
|
+
// with "Internal error: invalid_params" past 16 servers, or past 65536 bytes
|
|
4
|
+
// of their serialized list (gateway/session_local_mcp.py, validate_servers).
|
|
5
|
+
// Atomic mounts up to four servers of its own and then every server the
|
|
6
|
+
// person configured, so a person with a dozen servers lost every turn on that
|
|
7
|
+
// engine. Under a limit Atomic's own servers are always sent, then the
|
|
8
|
+
// person's in their configured order for as long as they fit.
|
|
9
|
+
import { ATOMIC_MCP_SERVERS } from "../turn-mcp.js";
|
|
10
|
+
/** The size an agent measures: compact JSON with every non-ASCII code unit
|
|
11
|
+
* escaped, which is what Python's json.dumps writes. */
|
|
12
|
+
export function mcpListBytes(servers) {
|
|
13
|
+
return JSON.stringify(servers).replace(/[\u0080-\uffff]/g, "\\u0000").length;
|
|
14
|
+
}
|
|
15
|
+
/** `kept` is what the session gets, in the order given; `left` names the
|
|
16
|
+
* person's servers that did not fit. */
|
|
17
|
+
export function limitMcpServers(servers, limit) {
|
|
18
|
+
if (!limit)
|
|
19
|
+
return { kept: [...servers], left: [] };
|
|
20
|
+
const kept = new Set(servers.filter((server) => ATOMIC_MCP_SERVERS.has(server.name)));
|
|
21
|
+
const left = [];
|
|
22
|
+
for (const server of servers) {
|
|
23
|
+
if (kept.has(server))
|
|
24
|
+
continue;
|
|
25
|
+
const fits = kept.size < limit.count && (limit.bytes === undefined || mcpListBytes([...kept, server]) <= limit.bytes);
|
|
26
|
+
if (fits)
|
|
27
|
+
kept.add(server);
|
|
28
|
+
else
|
|
29
|
+
left.push(server.name);
|
|
30
|
+
}
|
|
31
|
+
return { kept: servers.filter((server) => kept.has(server)), left };
|
|
32
|
+
}
|
|
33
|
+
const reported = new Set();
|
|
34
|
+
/** The servers a session is established with. The harness mints fresh tokens
|
|
35
|
+
* every turn, so a session is established on most turns: the servers left out
|
|
36
|
+
* are logged once per engine and set of names, not once per turn. */
|
|
37
|
+
export function sessionMcpServers(support, servers, log = console.error) {
|
|
38
|
+
const { kept, left } = limitMcpServers(servers, support.mcpServerLimit);
|
|
39
|
+
const key = `${support.driverKind}\n${left.join("\n")}`;
|
|
40
|
+
if (left.length && !reported.has(key)) {
|
|
41
|
+
reported.add(key);
|
|
42
|
+
const cap = support.mcpServerLimit;
|
|
43
|
+
log(`[${support.driverKind}] ${support.displayName} takes at most ${cap.count} MCP servers per session` +
|
|
44
|
+
`${cap.bytes === undefined ? "" : ` (${cap.bytes} bytes)`}: left out ${left.join(", ")}`);
|
|
45
|
+
}
|
|
46
|
+
return kept;
|
|
47
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// The Error an ACP agent's JSON-RPC error becomes (server/drivers/acp/core.ts).
|
|
2
|
+
import { parseResetAt, resetHintFromData } from "../../engine-failure.js";
|
|
3
|
+
import { redactSecretsInText } from "../../redact.js";
|
|
4
|
+
const text = (value) => (typeof value === "string" ? value : "");
|
|
5
|
+
/** ACP vendors put the actionable cause in error.data while keeping the
|
|
6
|
+
* JSON-RPC message generic. Only surface known text fields, never a response
|
|
7
|
+
* body/config dump, and redact before bounding the displayed diagnostic. */
|
|
8
|
+
export function acpRpcError(value, method) {
|
|
9
|
+
const raw = (value && typeof value === "object" ? value : {});
|
|
10
|
+
const message = typeof raw.message === "string" ? raw.message : "ACP request failed";
|
|
11
|
+
const data = raw.data;
|
|
12
|
+
const fields = (data && typeof data === "object" ? data : {});
|
|
13
|
+
const nested = (fields.error && typeof fields.error === "object" ? fields.error : {});
|
|
14
|
+
const detail = typeof data === "string" ? data
|
|
15
|
+
: typeof fields.details === "string" ? fields.details
|
|
16
|
+
: typeof fields.message === "string" ? fields.message
|
|
17
|
+
: text(nested.message);
|
|
18
|
+
const context = [
|
|
19
|
+
method,
|
|
20
|
+
typeof fields.service === "string" ? `service: ${fields.service}` : "",
|
|
21
|
+
text(fields.errorName),
|
|
22
|
+
].filter(Boolean).join(", ");
|
|
23
|
+
const said = detail && detail !== message ? `${message}: ${detail}` : message;
|
|
24
|
+
// A reset the agent sent only as data (Gemini's RetryInfo retryDelay, a
|
|
25
|
+
// resetsAt) joins the words, so the harness rests the engine until then.
|
|
26
|
+
const reset = parseResetAt(said) === undefined ? resetHintFromData(data) : undefined;
|
|
27
|
+
const diagnostic = `${said}${reset ? ` (${reset})` : ""} (${context})`;
|
|
28
|
+
const error = new Error(redactSecretsInText(diagnostic).slice(0, 1500));
|
|
29
|
+
return Object.assign(error, { code: raw.code, data,
|
|
30
|
+
// -32603 is JSON-RPC's internal error. Invalid params, unsupported
|
|
31
|
+
// methods and auth refusals are user/configuration issues, not evidence
|
|
32
|
+
// of a broken process. Preserve their session instead of retrying them.
|
|
33
|
+
acpSessionFailure: raw.code === -32603,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { classifyEngineFailure } from "../../engine-failure.js";
|
|
2
|
+
/** The `setup` and `failure` fields of a runtime.error. The failover layer
|
|
3
|
+
* keeps `setup` only beside a failure it can name, and reads the message
|
|
4
|
+
* itself when the driver names none: a setup failure whose words say nothing
|
|
5
|
+
* to it is named `provider_error`, which is what it would have settled on. */
|
|
6
|
+
export function failureFields(setup, failure, message) {
|
|
7
|
+
const named = failure ?? (setup && !classifyEngineFailure(message) ? "provider_error" : undefined);
|
|
8
|
+
return { ...(setup ? { setup: true } : {}), ...(named ? { failure: named } : {}) };
|
|
9
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PROVIDER_CREDENTIAL_ENV, stripControlPlaneEnv, WORKSPACE_CREDENTIAL_ENV } from "../../config.js";
|
|
2
2
|
import { augmentedPath } from "../../env-path.js";
|
|
3
|
-
import { VibeLoginController, vibeSignedIn } from "../vibe-login.js";
|
|
3
|
+
import { VibeLoginController, vibeSignedIn, vibeSignInState } from "../vibe-login.js";
|
|
4
4
|
import { createAcpDriver } from "./core.js";
|
|
5
5
|
import { assertEffectiveModeNotLooser } from "../../../shared/approval-readback.js";
|
|
6
6
|
export const VIBE_DRIVER_KIND = "vibeAgent";
|
|
@@ -50,7 +50,7 @@ const support = {
|
|
|
50
50
|
models: MODELS,
|
|
51
51
|
defaultCli: "vibe-acp",
|
|
52
52
|
nativeSource: "vibe.acp",
|
|
53
|
-
loginNote: "Mistral Vibe is not
|
|
53
|
+
loginNote: "Mistral Vibe is not signed in: choose Sign in with Mistral on its engine card",
|
|
54
54
|
// Mistral's own installer (it installs uv, then mistral-vibe). Not a
|
|
55
55
|
// vendorScript: mistral.ai redirects it to raw.githubusercontent.com, a host
|
|
56
56
|
// vendor-install.ts cannot pin to Mistral. Mistral targets macOS and Linux;
|
|
@@ -65,11 +65,17 @@ const support = {
|
|
|
65
65
|
spawnArgs: () => [],
|
|
66
66
|
selectModel: { configId: "model" },
|
|
67
67
|
// Sign-in is the delegated browser flow on the engine card, never a
|
|
68
|
-
// prompt in the middle of a turn.
|
|
68
|
+
// prompt in the middle of a turn: no authenticate call is made. The
|
|
69
|
+
// sign-in gate is requireAuthenticationBeforeSpawn (Vibe's own
|
|
70
|
+
// `_auth/status`), so the handshake continues without one; "fail" here
|
|
71
|
+
// stopped every turn of a signed-in Vibe with loginNote.
|
|
69
72
|
pickAuthMethod: () => null,
|
|
70
|
-
authFailure: "
|
|
73
|
+
authFailure: "continue",
|
|
71
74
|
requireAuthenticationBeforeSpawn: true,
|
|
72
|
-
|
|
75
|
+
// A missing `vibe-acp` passes this gate on purpose: the spawn then says it
|
|
76
|
+
// is not installed, where loginNote would have blamed the sign-in. The
|
|
77
|
+
// engine list never asks here without a CLI (snapshot probes it first).
|
|
78
|
+
isAuthenticated: (env, config, instanceId) => cachedSignedIn(`${instanceId}:${env.VIBE_HOME ?? ""}`, async () => (await vibeSignInState(config.cli || "vibe-acp", env)) !== "signed-out"),
|
|
73
79
|
async configureSession({ request, sessionId, config, turn }) {
|
|
74
80
|
const value = vibeSessionMode(config.fullAuto, turn.approvalMode);
|
|
75
81
|
let reply;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export const IMAGE_OMITTED_NOTE = "[Image omitted: this model reads text only, so it cannot see the image.]";
|
|
2
|
+
/** What providers say when a model takes text parts only. */
|
|
3
|
+
const REFUSALS = [
|
|
4
|
+
// Z.ai (GLM-5.3, 2026-11)
|
|
5
|
+
/content\.type\b[^\n]{0,80}\ballowed values?\s*:\s*\[\s*['"]text['"]\s*\]/i,
|
|
6
|
+
// OpenAI: "Invalid content type. image_url is only supported by certain models."
|
|
7
|
+
/\bimage_url\b[^\n]{0,80}\b(?:only supported|not supported|unsupported)\b/i,
|
|
8
|
+
// llama.cpp, vLLM, Mistral and others, in their several wordings
|
|
9
|
+
/\b(?:does not|doesn't|do not|cannot|can't) (?:support|accept|process|handle) (?:image inputs?|images|vision|multimodal)\b/i,
|
|
10
|
+
/\b(?:image|vision|multimodal) (?:input|inputs|content) (?:is|are) not supported\b/i,
|
|
11
|
+
];
|
|
12
|
+
const textOnly = new Set();
|
|
13
|
+
const keyOf = (apiUrl, model) => `${apiUrl}\n${model}`;
|
|
14
|
+
export function hasImageParts(messages) {
|
|
15
|
+
return messages.some((message) => Array.isArray(message.content) && message.content.some((part) => part.type === "image_url"));
|
|
16
|
+
}
|
|
17
|
+
/** Whether a refused request (HTTP status and body) was refused for its image parts. */
|
|
18
|
+
export function isImagePartRefusal(status, body) {
|
|
19
|
+
return (status === 400 || status === 415 || status === 422) && REFUSALS.some((pattern) => pattern.test(body.slice(0, 4_000)));
|
|
20
|
+
}
|
|
21
|
+
/** The same messages with a note where each image was. Content that held an
|
|
22
|
+
* image becomes one string, which every text-only endpoint accepts. */
|
|
23
|
+
export function withoutImages(messages) {
|
|
24
|
+
return messages.map((message) => {
|
|
25
|
+
if (!Array.isArray(message.content) || !message.content.some((part) => part.type === "image_url"))
|
|
26
|
+
return message;
|
|
27
|
+
const text = message.content.map((part) => (part.type === "text" ? part.text : IMAGE_OMITTED_NOTE)).join("\n");
|
|
28
|
+
return { ...message, content: text };
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/** What to send this endpoint and model: the messages as they are, or without
|
|
32
|
+
* images once the model is known to read text only. */
|
|
33
|
+
export function sendableMessages(apiUrl, model, messages) {
|
|
34
|
+
return textOnly.has(keyOf(apiUrl, model)) && hasImageParts(messages) ? withoutImages(messages) : messages;
|
|
35
|
+
}
|
|
36
|
+
/** Called with a refused request. True when it carried images and was refused
|
|
37
|
+
* for them: the model is remembered as text-only and the caller sends again. */
|
|
38
|
+
export function learnTextOnly(apiUrl, model, status, body, sent) {
|
|
39
|
+
if (!hasImageParts(sent) || !isImagePartRefusal(status, body))
|
|
40
|
+
return false;
|
|
41
|
+
textOnly.add(keyOf(apiUrl, model));
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
/** Tests only. */
|
|
45
|
+
export function forgetTextOnlyModels() {
|
|
46
|
+
textOnly.clear();
|
|
47
|
+
}
|
|
@@ -6,6 +6,21 @@ export function object(value) {
|
|
|
6
6
|
return value !== null && typeof value === "object" && !Array.isArray(value)
|
|
7
7
|
? value : undefined;
|
|
8
8
|
}
|
|
9
|
+
/** The message of a JSON error body a provider returned with HTTP 200.
|
|
10
|
+
* MiniMax reports auth, balance, and parameter failures as `base_resp`. */
|
|
11
|
+
export function providerError(json) {
|
|
12
|
+
if (typeof json.error === "string")
|
|
13
|
+
return json.error;
|
|
14
|
+
const error = object(json.error);
|
|
15
|
+
if (error)
|
|
16
|
+
return typeof error.message === "string" ? error.message : "unknown error";
|
|
17
|
+
const code = json.base_resp?.status_code;
|
|
18
|
+
if (typeof code === "number" && code !== 0) {
|
|
19
|
+
const msg = typeof json.base_resp?.status_msg === "string" ? json.base_resp.status_msg : "";
|
|
20
|
+
return `upstream error ${code}${msg ? `: ${msg}` : ""}`;
|
|
21
|
+
}
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
9
24
|
/** Opaque provider reasoning blocks must keep their original order/signatures.
|
|
10
25
|
* OpenRouter streams the sequence as arrays of blocks, not tool-call deltas. */
|
|
11
26
|
export class ChatReasoningDetails {
|