@chibitek/chibi 0.1.207 → 0.1.209
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{TerminalPanel-Cqjxle8G.js → TerminalPanel-CHGq3udb.js} +1 -1
- package/dist/assets/{abnfDiagram-O67JEVCF-XB80WX43.js → abnfDiagram-O67JEVCF-BMaKhJ-b.js} +1 -1
- package/dist/assets/{arc-BERcgYDi.js → arc-CYAiNWN8.js} +1 -1
- package/dist/assets/{architectureDiagram-NJMV4G6O-Dnc9s6SQ.js → architectureDiagram-NJMV4G6O-CxJFFlbO.js} +1 -1
- package/dist/assets/{blockDiagram-BEXU5L5S-Cxc21eYL.js → blockDiagram-BEXU5L5S-C7AbPjRB.js} +1 -1
- package/dist/assets/{c4Diagram-YGBWAQC7-CW-3gUcf.js → c4Diagram-YGBWAQC7-DfVnCJmT.js} +1 -1
- package/dist/assets/channel-DxL_mLhm.js +1 -0
- package/dist/assets/{chunk-2Q5K7J3B-Bs484eiW.js → chunk-2Q5K7J3B-CzAUFkgv.js} +1 -1
- package/dist/assets/{chunk-3FUC2YCW-qhnBgRDy.js → chunk-3FUC2YCW-BgeBXphm.js} +2 -2
- package/dist/assets/{chunk-5VM5RSS4-CsCqAEkH.js → chunk-5VM5RSS4-DPRdTAXc.js} +1 -1
- package/dist/assets/{chunk-GTNCS2PH-ChBgFjPw.js → chunk-GTNCS2PH-BS-_dIVl.js} +1 -1
- package/dist/assets/{chunk-GWA4HPMP-Df5-WClq.js → chunk-GWA4HPMP-D6I7xMmd.js} +1 -1
- package/dist/assets/{chunk-JWPE2WC7-BdMXRJhO.js → chunk-JWPE2WC7-BKSKe7C9.js} +1 -1
- package/dist/assets/{chunk-NETBCI7D-rmAqJ9nY.js → chunk-NETBCI7D-R48UYTRN.js} +1 -1
- package/dist/assets/{chunk-WEXAMYUT-DYmTw4lw.js → chunk-WEXAMYUT-C8z4mL-2.js} +1 -1
- package/dist/assets/{chunk-XXDRQBXY-C4o5SHm0.js → chunk-XXDRQBXY-Bml3ZRJ5.js} +1 -1
- package/dist/assets/{classDiagram-v2-NBCMYWYE-Bm-ZzDk5.js → classDiagram-v2-NBCMYWYE-w5wo22FO.js} +1 -1
- package/dist/assets/{cose-bilkent-JH36ORCC-CFMRSfMu.js → cose-bilkent-JH36ORCC-Cum9v--4.js} +1 -1
- package/dist/assets/{cynefin-OW5HDTMX-BDedZ5yW.js → cynefin-OW5HDTMX-BzN0-KsP.js} +1 -1
- package/dist/assets/{cynefinDiagram-VND7K2PF-i7KARSqF.js → cynefinDiagram-VND7K2PF-CkOpm32D.js} +1 -1
- package/dist/assets/{dagre-6A5THRUB-CwWpV0i_.js → dagre-6A5THRUB-BItQkKZD.js} +1 -1
- package/dist/assets/{diagram-22UHCM2B-CWIMT3-K.js → diagram-22UHCM2B-BI0zDn7c.js} +1 -1
- package/dist/assets/{diagram-3UASUU5V-C7HGc_ap.js → diagram-3UASUU5V-jwcDxsu6.js} +1 -1
- package/dist/assets/{diagram-ATOU4E4O-BeLM7ihN.js → diagram-ATOU4E4O-2RnY9egJ.js} +1 -1
- package/dist/assets/{diagram-CDSNMT55-CN1rVM-W.js → diagram-CDSNMT55-eVdEZmEF.js} +1 -1
- package/dist/assets/{diagram-MLGK6HIB-CuLcsx4e.js → diagram-MLGK6HIB-BCDGCJJ0.js} +1 -1
- package/dist/assets/{diagram-MPIPVDR6-Bie61r-h.js → diagram-MPIPVDR6-DtN5uO5w.js} +1 -1
- package/dist/assets/{ebnfDiagram-ZINNZB2B-ChMg86y3.js → ebnfDiagram-ZINNZB2B-B9GpXSEs.js} +1 -1
- package/dist/assets/{elk-276RUBZZ-DG9xXwoW.js → elk-276RUBZZ-Bk_eaK4T.js} +1 -1
- package/dist/assets/{erDiagram-OPXOYQCR-C9bl-nWK.js → erDiagram-OPXOYQCR-BiGoW6C6.js} +1 -1
- package/dist/assets/{flowDiagram-KWPJA3E3-DvdWxFI8.js → flowDiagram-KWPJA3E3-ZW5w0BaJ.js} +1 -1
- package/dist/assets/{ganttDiagram-FUAMR5RP-DDCNSEYc.js → ganttDiagram-FUAMR5RP-yyrKgsx1.js} +1 -1
- package/dist/assets/{gitGraphDiagram-X574FWY7-PFvmOSMd.js → gitGraphDiagram-X574FWY7-CeiDikzD.js} +1 -1
- package/dist/assets/{index-Ci2mINhA.js → index-CZGnshrJ.js} +83 -83
- package/dist/assets/{index-DnniNB7N.js → index-DUFlRZuA.js} +1 -1
- package/dist/assets/{infoDiagram-VRGFBTTK-HEZh-PnK.js → infoDiagram-VRGFBTTK-q2B-KJFm.js} +1 -1
- package/dist/assets/{ishikawaDiagram-OU5B5YK6-P3mmCGAU.js → ishikawaDiagram-OU5B5YK6-D8gXFuc0.js} +1 -1
- package/dist/assets/{journeyDiagram-ZHPQQLJL-dKG4AQu2.js → journeyDiagram-ZHPQQLJL-BmHL2mbq.js} +1 -1
- package/dist/assets/{kanban-definition-PNTS6WVX-BeIHeQTt.js → kanban-definition-PNTS6WVX-B9Ll2WkA.js} +1 -1
- package/dist/assets/{linear-DnEqDr6r.js → linear-CMVGYrKx.js} +1 -1
- package/dist/assets/{mermaid.core-D7hz6n4u.js → mermaid.core-qO11n1kV.js} +5 -5
- package/dist/assets/{mindmap-definition-NLK3R4M7-BxJ8p-DN.js → mindmap-definition-NLK3R4M7-CxLGFX45.js} +1 -1
- package/dist/assets/{pegDiagram-GJSIUBJH-CkQT2dHJ.js → pegDiagram-GJSIUBJH-CxK1MJG4.js} +1 -1
- package/dist/assets/{pieDiagram-5QR66LMP-DmVVhYaY.js → pieDiagram-5QR66LMP-H5jiF5Eu.js} +1 -1
- package/dist/assets/{quadrantDiagram-O4NWA36T-DsOz-qCY.js → quadrantDiagram-O4NWA36T-CKaqCruv.js} +1 -1
- package/dist/assets/{railroadDiagram-XR7U4H2S-CeYfvaki.js → railroadDiagram-XR7U4H2S-BCzKiQOd.js} +1 -1
- package/dist/assets/{requirementDiagram-PLB6GJNP-BCtM-2uN.js → requirementDiagram-PLB6GJNP-Cqtr43DT.js} +1 -1
- package/dist/assets/{sankeyDiagram-IPEJSGJF-Cu8ki35x.js → sankeyDiagram-IPEJSGJF-B2tQewX8.js} +1 -1
- package/dist/assets/{sequenceDiagram-PO4LG4MO-DKbS5Gcs.js → sequenceDiagram-PO4LG4MO-nggwQyrw.js} +1 -1
- package/dist/assets/{sizeCapture-INFHLROL-Ceut6PrE.js → sizeCapture-INFHLROL-qSPXJBv2.js} +1 -1
- package/dist/assets/{stateDiagram-v2-GCMORJYK-Bl5uMY2f.js → stateDiagram-v2-GCMORJYK-DraPbL2T.js} +1 -1
- package/dist/assets/{swimlanes-2SLR337P-CoMPbJ2k.js → swimlanes-2SLR337P-C6HVkIDA.js} +1 -1
- package/dist/assets/swimlanesDiagram-TC7HE7FX-gQUGsELo.js +8 -0
- package/dist/assets/{timeline-definition-EJHVYXUP-D0xkKp46.js → timeline-definition-EJHVYXUP-DZmPRTsx.js} +1 -1
- package/dist/assets/{usecaseDiagram-POWQR4AR-BCCL6QIf.js → usecaseDiagram-POWQR4AR-CsVuROW_.js} +1 -1
- package/dist/assets/{vennDiagram-UO4OBE2U-B7g3jK72.js → vennDiagram-UO4OBE2U-B9IRbuhp.js} +1 -1
- package/dist/assets/{wardleyDiagram-VNRHLVJA-DFhnqQKP.js → wardleyDiagram-VNRHLVJA-CGmVK53n.js} +1 -1
- package/dist/assets/{xychartDiagram-PMCCYNJV-mIXMscRS.js → xychartDiagram-PMCCYNJV-BAw-x9Y1.js} +1 -1
- package/dist/index.html +1 -1
- package/dist-server/index.js +3160 -2743
- package/dist-server/openmausbot.js +831 -654
- package/dist-server/pair-cli.js +831 -654
- package/dist-server/server/connection-cap-failover.js +8 -6
- package/dist-server/server/drivers/acp/core.js +20 -47
- package/dist-server/server/drivers/acp/custom.js +5 -0
- package/dist-server/server/drivers/acp/hermes-hosts.js +9 -0
- package/dist-server/server/drivers/acp/hermes.js +7 -9
- package/dist-server/server/drivers/acp/kimi-turn-failure.js +68 -0
- package/dist-server/server/drivers/acp/kimi.js +7 -0
- package/dist-server/server/drivers/acp/mcp-limit.js +47 -0
- package/dist-server/server/drivers/acp/rpc-error.js +35 -0
- package/dist-server/server/drivers/acp/setup-failure.js +9 -0
- package/dist-server/server/drivers/acp/vibe.js +11 -5
- package/dist-server/server/drivers/chat-text-only.js +47 -0
- package/dist-server/server/drivers/openai-chat-protocol.js +15 -0
- package/dist-server/server/drivers/openai-chat.js +8 -18
- package/dist-server/server/drivers/turn-mcp.js +3 -0
- package/dist-server/server/drivers/vibe-login.js +17 -8
- package/dist-server/server/engine-failover.js +16 -29
- package/dist-server/server/engine-rest.js +4 -3
- package/dist-server/server/engine-tiers.js +12 -9
- package/dist-server/server/index.js +16 -15
- package/dist-server/server/injected-model-rest.js +17 -0
- package/dist-server/server/model-levels/aliases.js +243 -38
- package/dist-server/server/model-levels/chibitek-rankings.js +8 -8
- package/dist-server/server/model-levels/classes.js +106 -38
- package/dist-server/server/model-levels/index.js +26 -14
- package/dist-server/server/model-levels/model-ids.js +91 -0
- package/dist-server/server/model-levels/overrides.js +7 -4
- package/dist-server/server/model-levels/sources.js +4 -1
- package/dist-server/server/pay-per-use.js +13 -1
- package/dist-server/shared/engine-tiers.js +0 -12
- package/package.json +1 -1
- package/dist/assets/channel-DaeKCO76.js +0 -1
- package/dist/assets/swimlanesDiagram-TC7HE7FX-DLJq0mAR.js +0 -8
|
@@ -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,14 +134,12 @@ export function finalizeConnectionCapPick(input) {
|
|
|
134
134
|
return { line: transientThrottleStopLine(input.currentLabel), category: "failover_exhausted" };
|
|
135
135
|
}
|
|
136
136
|
const { choice } = input;
|
|
137
|
-
// An engine's own error text passes through only while the turn may still
|
|
138
|
-
// move; at the cap the person gets the plain stopped line, not raw text.
|
|
139
|
-
if (!choice && input.failureKind === "provider_error" && input.triedCount < MAX_ENGINES_PER_TURN)
|
|
140
|
-
return { passthrough: true };
|
|
141
137
|
if (!choice) {
|
|
142
138
|
if (input.pausedUntil !== undefined && input.skipped.some((skip) => skip.reason === "paused")) {
|
|
143
139
|
return { line: input.payPerUsePausedLine(input.pausedUntil) };
|
|
144
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.
|
|
145
143
|
const waiting = decideNewTurnPlacement({
|
|
146
144
|
policy: input.policy, paidApproved: input.paidApproved,
|
|
147
145
|
skippedPausedKey: input.skipped.some((skip) => skip.reason === "paused"),
|
|
@@ -151,10 +149,14 @@ export function finalizeConnectionCapPick(input) {
|
|
|
151
149
|
input.announceWaiting?.();
|
|
152
150
|
return { line: waiting.line, category: "failover_exhausted" };
|
|
153
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 };
|
|
154
156
|
const resting = input.skipped.filter((skip) => skip.reason === "resting" || skip.reason === "tried").map((skip) => skip.instanceId);
|
|
155
157
|
const named = input.restingNamed([input.failedInstanceId, ...input.alreadyTried, ...resting]);
|
|
156
158
|
return {
|
|
157
|
-
line: restingLine(named, input.formatTime, input.cannotDrive, { capped: input.triedCount >=
|
|
159
|
+
line: restingLine(named, input.formatTime, input.cannotDrive, { capped: input.triedCount >= MAX_ENGINES_WALKED }),
|
|
158
160
|
category: named.some((engine) => engine.needsSignIn || engine.keyExpired) || input.cannotDrive?.signedOut?.length ? "account" : "failover_exhausted",
|
|
159
161
|
};
|
|
160
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";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// The providers Atomic runs through Hermes: Nous Research alone, whose
|
|
2
|
+
// subscription works only in its own harness (Erick, 2026-11-22). Every other
|
|
3
|
+
// provider Hermes is signed in to (OpenAI Codex, OpenCode, OpenRouter,
|
|
4
|
+
// DeepInfra, a local Ollama) has an engine of its own in Atomic, so routing it
|
|
5
|
+
// through Hermes only added a second, failing way to the same account.
|
|
6
|
+
export const HERMES_HOSTS = new Set(["nous"]);
|
|
7
|
+
/** The provider a Hermes ACP model id names (`nous:Hermes-4-405B` is "nous"). */
|
|
8
|
+
const hostOf = (modelId) => /^([a-z0-9_-]+):/i.exec(modelId)?.[1]?.toLowerCase();
|
|
9
|
+
export const hermesOnlyHosts = (options) => options.filter((option) => HERMES_HOSTS.has(hostOf(option.id) ?? option.provider ?? ""));
|
|
@@ -13,6 +13,7 @@ import { resolveCli } from "../../procs.js";
|
|
|
13
13
|
import { planOptions } from "../../spawn-command.js";
|
|
14
14
|
import { decodeInjectId, hostApiKey, INJECT_SEP, localHost, mergeLocalInject } from "../local-inject.js";
|
|
15
15
|
import { createAcpDriver } from "./core.js";
|
|
16
|
+
import { hermesOnlyHosts } from "./hermes-hosts.js";
|
|
16
17
|
import { lockHermesMemory } from "./hermes-memory-lock.js";
|
|
17
18
|
const EMPTY = { default: "", options: [] };
|
|
18
19
|
export const HERMES_OPENMAUS_SCREENSHOT_COMPAT = "HERMES_OPENMAUS_SCREENSHOT_COMPAT";
|
|
@@ -553,15 +554,11 @@ export async function resolveHermesModels(env, config) {
|
|
|
553
554
|
const listed = new Set(remote.map((o) => o.provider));
|
|
554
555
|
const stored = signedIn.filter((o) => !listed.has(o.provider));
|
|
555
556
|
const seen = new Set();
|
|
556
|
-
// The config default in its explicit `nous:<model>` form leads the host's
|
|
557
|
-
//
|
|
558
|
-
const listedOptions = [...(configured ? [configured] : []), ...(hostDefault ? [hostDefault] : []), ...remote, ...stored, ...catalog.options]
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
seen.add(o.id);
|
|
562
|
-
return true;
|
|
563
|
-
});
|
|
564
|
-
const options = hermesZaiPlanHosts(listedOptions, hermesZaiCodingPlan(env));
|
|
557
|
+
// The config default in its explicit `nous:<model>` form leads the host's models, so a Nous Research bot
|
|
558
|
+
// starts on the model picked in Hermes. Only Nous models are offered (hermes-hosts.ts).
|
|
559
|
+
const listedOptions = [...(configured ? [configured] : []), ...(hostDefault ? [hostDefault] : []), ...remote, ...stored, ...catalog.options]
|
|
560
|
+
.filter((o) => !seen.has(o.id) && Boolean(seen.add(o.id)));
|
|
561
|
+
const options = hermesOnlyHosts(hermesZaiPlanHosts(listedOptions, hermesZaiCodingPlan(env)));
|
|
565
562
|
return { default: options[0]?.id ?? "", options };
|
|
566
563
|
}
|
|
567
564
|
async function applySetting(request, method, params, what) {
|
|
@@ -595,6 +592,7 @@ const support = {
|
|
|
595
592
|
// a longer idle window than the default (a rejected key is caught sooner,
|
|
596
593
|
// from its log, by the core's stderr check).
|
|
597
594
|
promptIdleMs: 300_000,
|
|
595
|
+
mcpServerLimit: { count: 16, bytes: 56_000 }, // its gateway refuses a 17th, or 65536 bytes once it adds its own fields
|
|
598
596
|
loginNote: "Hermes CLI is not installed",
|
|
599
597
|
// No install command: setup never installs Hermes (Erick, 2026-11-08).
|
|
600
598
|
// 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 {
|
|
@@ -5,24 +5,10 @@ import { toolDetailPreview } from "../tool-summary.js";
|
|
|
5
5
|
import { ChatToolSessionError, mountChatTools } from "./chat-mcp-tools.js";
|
|
6
6
|
import { assertImageTransport, chatImageBudget, chatToolImages, chatUserContent } from "./chat-images.js";
|
|
7
7
|
import { createChatToolApproval } from "./chat-tool-approval.js";
|
|
8
|
-
import { ChatProtocolError, ChatReasoningDetails, ChatToolCalls, MAX_CHAT_TOOL_CALLS, object } from "./openai-chat-protocol.js";
|
|
8
|
+
import { ChatProtocolError, ChatReasoningDetails, ChatToolCalls, MAX_CHAT_TOOL_CALLS, object, providerError } from "./openai-chat-protocol.js";
|
|
9
|
+
import { hasImageParts, learnTextOnly, sendableMessages } from "./chat-text-only.js";
|
|
9
10
|
import { appendNative } from "./native.js";
|
|
10
11
|
import { classifyError, computeBackoff, interruptibleDelay, RETRY_MAX_ATTEMPTS } from "./retry.js";
|
|
11
|
-
/** The message of a JSON error body a provider returned with HTTP 200.
|
|
12
|
-
* MiniMax reports auth, balance, and parameter failures as `base_resp`. */
|
|
13
|
-
function providerError(json) {
|
|
14
|
-
if (typeof json.error === "string")
|
|
15
|
-
return json.error;
|
|
16
|
-
const error = object(json.error);
|
|
17
|
-
if (error)
|
|
18
|
-
return typeof error.message === "string" ? error.message : "unknown error";
|
|
19
|
-
const code = json.base_resp?.status_code;
|
|
20
|
-
if (typeof code === "number" && code !== 0) {
|
|
21
|
-
const msg = typeof json.base_resp?.status_msg === "string" ? json.base_resp.status_msg : "";
|
|
22
|
-
return `upstream error ${code}${msg ? `: ${msg}` : ""}`;
|
|
23
|
-
}
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
12
|
const usageFrom = (usage) => usage
|
|
27
13
|
? { input: usage.prompt_tokens ?? 0, output: usage.completion_tokens ?? 0 }
|
|
28
14
|
: null;
|
|
@@ -59,18 +45,22 @@ export function createOpenAIChatRuntime(options) {
|
|
|
59
45
|
const activeSignal = signal
|
|
60
46
|
? AbortSignal.any([signal, timeoutController.signal])
|
|
61
47
|
: timeoutController.signal;
|
|
48
|
+
const sendable = sendableMessages(options.apiUrl, model, messages);
|
|
62
49
|
const response = await fetch(`${options.apiUrl}/chat/completions`, {
|
|
63
50
|
method: "POST",
|
|
64
|
-
...(
|
|
51
|
+
...(hasImageParts(sendable) ? { redirect: "error" } : {}),
|
|
65
52
|
headers: { ...options.extraHeaders, authorization: `Bearer ${options.apiKey}`, "content-type": "application/json" },
|
|
66
53
|
body: JSON.stringify({
|
|
67
|
-
...options.requestBody(model,
|
|
54
|
+
...options.requestBody(model, sendable, stream),
|
|
68
55
|
...(tools.length ? { tools } : {}),
|
|
69
56
|
}),
|
|
70
57
|
signal: activeSignal,
|
|
71
58
|
});
|
|
72
59
|
if (!response.ok) {
|
|
73
60
|
const body = await response.text().catch(() => "");
|
|
61
|
+
// A text-only model refused the image parts: once more, with a note in their place.
|
|
62
|
+
if (learnTextOnly(options.apiUrl, model, response.status, body, sendable))
|
|
63
|
+
return await complete(messages, model, stream, signal, onDelta, tools, onIdentity);
|
|
74
64
|
throw new Error(`${options.httpErrorLabel} HTTP ${response.status}${body ? `: ${body.slice(0, 200)}` : ""}`);
|
|
75
65
|
}
|
|
76
66
|
if (!stream || response.headers.get("content-type")?.includes("application/json")) {
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { gateServer, resultBudget } from "../mcp-gate-config.js";
|
|
2
|
+
/** The names Atomic's own servers mount under (below); a person's server
|
|
3
|
+
* never takes one of them. */
|
|
4
|
+
export const ATOMIC_MCP_SERVERS = new Set(["agents", "atomic_accounts", "browser", "computer"]);
|
|
2
5
|
export function turnMcpServers(turn) {
|
|
3
6
|
const servers = [];
|
|
4
7
|
const agents = turn.integrations?.agents;
|