@chibitek/chibi 0.1.183 → 0.1.185
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{abnfDiagram-O67JEVCF-BJRKA6IQ.js → abnfDiagram-O67JEVCF-CVenv9f1.js} +1 -1
- package/dist/assets/{arc-CZc_uW-u.js → arc-CIRWjkSZ.js} +1 -1
- package/dist/assets/{architectureDiagram-NJMV4G6O-DNLaTXeO.js → architectureDiagram-NJMV4G6O-DmIpOaYd.js} +1 -1
- package/dist/assets/{blockDiagram-BEXU5L5S-DLXsik0_.js → blockDiagram-BEXU5L5S-BYhb8Ycm.js} +1 -1
- package/dist/assets/{c4Diagram-YGBWAQC7-DG6hN1C0.js → c4Diagram-YGBWAQC7-B9rBcCno.js} +1 -1
- package/dist/assets/channel-NYf_L8uU.js +1 -0
- package/dist/assets/{chunk-2Q5K7J3B-D5Yjh7-1.js → chunk-2Q5K7J3B-CV6TX9gt.js} +1 -1
- package/dist/assets/{chunk-3FUC2YCW-Bxyjopy0.js → chunk-3FUC2YCW-DiOotfQU.js} +2 -2
- package/dist/assets/{chunk-5VM5RSS4-DDQZDrcU.js → chunk-5VM5RSS4-Br5QWC-1.js} +1 -1
- package/dist/assets/{chunk-GTNCS2PH-OwVykJDf.js → chunk-GTNCS2PH-BmvI8RMK.js} +1 -1
- package/dist/assets/{chunk-GWA4HPMP-BJRJdRRn.js → chunk-GWA4HPMP-Do93bTCh.js} +1 -1
- package/dist/assets/{chunk-JWPE2WC7-D0rQf2t4.js → chunk-JWPE2WC7-qIjG-mTw.js} +1 -1
- package/dist/assets/{chunk-NETBCI7D-DbgIhGxq.js → chunk-NETBCI7D-DZFFFHT2.js} +1 -1
- package/dist/assets/{chunk-WEXAMYUT-NVC6qgIT.js → chunk-WEXAMYUT-qqsVaC1g.js} +1 -1
- package/dist/assets/{chunk-XXDRQBXY-B9iYAoH7.js → chunk-XXDRQBXY-EI-aQ-Wn.js} +1 -1
- package/dist/assets/{classDiagram-v2-NBCMYWYE-Cma68soF.js → classDiagram-v2-NBCMYWYE-D9D8dkAx.js} +1 -1
- package/dist/assets/{cose-bilkent-JH36ORCC-BrXaARl8.js → cose-bilkent-JH36ORCC-m575JDuA.js} +1 -1
- package/dist/assets/{cynefin-OW5HDTMX-DaxVySTi.js → cynefin-OW5HDTMX-BMm2bhgv.js} +1 -1
- package/dist/assets/{cynefinDiagram-VND7K2PF-BhqakyPn.js → cynefinDiagram-VND7K2PF-Dl2MlsqG.js} +1 -1
- package/dist/assets/{dagre-6A5THRUB-C1GSPYtM.js → dagre-6A5THRUB-Cw8yJ-SY.js} +1 -1
- package/dist/assets/{diagram-22UHCM2B-BJ3lUPTt.js → diagram-22UHCM2B-DyY0F1qK.js} +1 -1
- package/dist/assets/{diagram-3UASUU5V-B15DdW5N.js → diagram-3UASUU5V-sMOszbgV.js} +1 -1
- package/dist/assets/{diagram-ATOU4E4O-CXiw2lST.js → diagram-ATOU4E4O-DPo3fHpo.js} +1 -1
- package/dist/assets/{diagram-CDSNMT55-DoqH99bW.js → diagram-CDSNMT55-BAHqm-cq.js} +1 -1
- package/dist/assets/{diagram-MLGK6HIB-snN4K-CB.js → diagram-MLGK6HIB-BdI4Tf9M.js} +1 -1
- package/dist/assets/{diagram-MPIPVDR6-DgJvwpZO.js → diagram-MPIPVDR6-BxqEl_S5.js} +1 -1
- package/dist/assets/{ebnfDiagram-ZINNZB2B-AO646Cux.js → ebnfDiagram-ZINNZB2B-DLJ3VRtx.js} +1 -1
- package/dist/assets/{elk-276RUBZZ-BQwiFuXz.js → elk-276RUBZZ-Yhxabhx6.js} +1 -1
- package/dist/assets/{erDiagram-OPXOYQCR-B5VI88HR.js → erDiagram-OPXOYQCR-DZ4Es64N.js} +1 -1
- package/dist/assets/{flowDiagram-KWPJA3E3-BNaAddPG.js → flowDiagram-KWPJA3E3-E36WtrEY.js} +1 -1
- package/dist/assets/{ganttDiagram-FUAMR5RP-C_ZoEfA5.js → ganttDiagram-FUAMR5RP-OpUEVvtU.js} +1 -1
- package/dist/assets/{gitGraphDiagram-X574FWY7-xthNWdmM.js → gitGraphDiagram-X574FWY7-DTZFNsL8.js} +1 -1
- package/dist/assets/{index-DmYwoh4R.js → index-Bgf1dXAl.js} +133 -133
- package/dist/assets/{index-ASohJJer.js → index-Bzph058J.js} +1 -1
- package/dist/assets/{infoDiagram-VRGFBTTK-Qhrkz09J.js → infoDiagram-VRGFBTTK-mCP2UtfM.js} +1 -1
- package/dist/assets/{ishikawaDiagram-OU5B5YK6-DzU3-GrV.js → ishikawaDiagram-OU5B5YK6-M71dvinX.js} +1 -1
- package/dist/assets/{journeyDiagram-ZHPQQLJL-Dif-aG4a.js → journeyDiagram-ZHPQQLJL-B2VdVbYS.js} +1 -1
- package/dist/assets/{kanban-definition-PNTS6WVX-NJ0l6rbK.js → kanban-definition-PNTS6WVX-l4HpN_KC.js} +1 -1
- package/dist/assets/{linear-DpEaZ_8H.js → linear-CN0tWTVj.js} +1 -1
- package/dist/assets/{mermaid.core-DOBTmT-1.js → mermaid.core-DpBToEGQ.js} +5 -5
- package/dist/assets/{mindmap-definition-NLK3R4M7-kPRBSQ6K.js → mindmap-definition-NLK3R4M7--DJgZ72R.js} +1 -1
- package/dist/assets/{pegDiagram-GJSIUBJH-BgX62j0G.js → pegDiagram-GJSIUBJH-DmTBsA2I.js} +1 -1
- package/dist/assets/{pieDiagram-5QR66LMP-DpC0-6hx.js → pieDiagram-5QR66LMP-Cy6JwGMR.js} +1 -1
- package/dist/assets/{quadrantDiagram-O4NWA36T-CNrmwxvV.js → quadrantDiagram-O4NWA36T-DjTftbBA.js} +1 -1
- package/dist/assets/{railroadDiagram-XR7U4H2S-wl7o4Y2J.js → railroadDiagram-XR7U4H2S-DeKIQoik.js} +1 -1
- package/dist/assets/{requirementDiagram-PLB6GJNP-D2qhVvpT.js → requirementDiagram-PLB6GJNP-B02KsDuy.js} +1 -1
- package/dist/assets/{sankeyDiagram-IPEJSGJF-DZOSOZWs.js → sankeyDiagram-IPEJSGJF-4RLO5vMI.js} +1 -1
- package/dist/assets/{sequenceDiagram-PO4LG4MO-eBogKj3g.js → sequenceDiagram-PO4LG4MO-CcBW737M.js} +1 -1
- package/dist/assets/{sizeCapture-INFHLROL-Dp_Vdw0m.js → sizeCapture-INFHLROL-CaLSjl7R.js} +1 -1
- package/dist/assets/{stateDiagram-v2-GCMORJYK-K79Em0_p.js → stateDiagram-v2-GCMORJYK-blyzRgvD.js} +1 -1
- package/dist/assets/{swimlanes-2SLR337P-ByKYlFa_.js → swimlanes-2SLR337P-BIi-tuCD.js} +1 -1
- package/dist/assets/swimlanesDiagram-TC7HE7FX-DWtkSjpb.js +8 -0
- package/dist/assets/{timeline-definition-EJHVYXUP-CzeMeYU0.js → timeline-definition-EJHVYXUP-oNE7PiRv.js} +1 -1
- package/dist/assets/{usecaseDiagram-POWQR4AR-uQjp5Yz3.js → usecaseDiagram-POWQR4AR-DzmCYS5I.js} +1 -1
- package/dist/assets/{vennDiagram-UO4OBE2U-De8_78dQ.js → vennDiagram-UO4OBE2U-T51P02io.js} +1 -1
- package/dist/assets/{wardleyDiagram-VNRHLVJA-Dk_VO2LR.js → wardleyDiagram-VNRHLVJA-1GfD8Fys.js} +1 -1
- package/dist/assets/{xychartDiagram-PMCCYNJV-DMx2Y7qW.js → xychartDiagram-PMCCYNJV-BhNMe0uk.js} +1 -1
- package/dist/handbook/atomic-handbook.html +1 -5
- package/dist/index.html +1 -1
- package/dist-server/index.js +1087 -988
- package/dist-server/openmausbot.js +224 -176
- package/dist-server/pair-cli.js +224 -176
- package/dist-server/server/computer-stop-names.js +35 -0
- package/dist-server/server/connection-cap-failover.js +1 -1
- package/dist-server/server/drivers/claude-auth-status.js +25 -0
- package/dist-server/server/drivers/claude.js +6 -5
- package/dist-server/server/drivers/retry.js +1 -0
- package/dist-server/server/engine-failover.js +14 -5
- package/dist-server/server/engine-failure.js +4 -4
- package/dist-server/server/index.js +13 -14
- package/dist-server/server/injected-model-rest.js +9 -0
- package/dist-server/server/model-access-refusal.js +62 -0
- package/dist-server/server/workspace-backup-copy.js +34 -1
- package/dist-server/server/workspace-backup-http.js +8 -5
- package/dist-server/server/workspace-backup-secrets.js +2 -2
- package/dist-server/server/workspace-backup.js +38 -52
- package/dist-server/shared/workspace-backup.js +23 -1
- package/package.json +1 -1
- package/dist/assets/channel-DmcLphYK.js +0 -1
- package/dist/assets/swimlanesDiagram-TC7HE7FX-BnN5frkm.js +0 -8
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// The names a stop line gives, on a turn that must drive a computer, for the
|
|
2
|
+
// engines a ladder passed over (restingLine's `computer` argument). Both stop
|
|
3
|
+
// paths use it: restingStop at a turn's start and finalizeConnectionCapPick
|
|
4
|
+
// mid-turn.
|
|
5
|
+
import { canDriveComputer, engineHealth } from "./engine-tiers.js";
|
|
6
|
+
/** Of these engines, which cannot drive `computer`, and which could but were
|
|
7
|
+
* skipped as signed out or unavailable before any rest was read (once
|
|
8
|
+
* dropped from the line, 2026-11-10, so "Codex needs sign-in" never showed).
|
|
9
|
+
* Each engine once, by display name.
|
|
10
|
+
*
|
|
11
|
+
* The ladder's own skip reason decides, so an engine it passed over for
|
|
12
|
+
* something else (refused, no model, resting) is never named as one sign-in
|
|
13
|
+
* away. An entry with no reason (the bot's own engine, which the ladder does
|
|
14
|
+
* not list) is read from its health. */
|
|
15
|
+
export function computerStopNames(candidates, skipped, computer) {
|
|
16
|
+
const names = { engines: [], signedOut: [], unavailable: [] };
|
|
17
|
+
const reasons = new Map();
|
|
18
|
+
for (const skip of skipped)
|
|
19
|
+
reasons.set(skip.instanceId, reasons.get(skip.instanceId) ?? skip.reason);
|
|
20
|
+
for (const [instanceId, reason] of reasons) {
|
|
21
|
+
const candidate = candidates.find((entry) => entry.instanceId === instanceId);
|
|
22
|
+
if (!candidate)
|
|
23
|
+
continue;
|
|
24
|
+
if (!canDriveComputer(candidate, computer)) {
|
|
25
|
+
names.engines.push(candidate.displayName);
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
const why = reason ?? engineHealth(candidate);
|
|
29
|
+
if (why === "signed-out")
|
|
30
|
+
names.signedOut.push(candidate.displayName);
|
|
31
|
+
else if (why === "unavailable")
|
|
32
|
+
names.unavailable.push(candidate.displayName);
|
|
33
|
+
}
|
|
34
|
+
return names;
|
|
35
|
+
}
|
|
@@ -155,7 +155,7 @@ export function finalizeConnectionCapPick(input) {
|
|
|
155
155
|
const named = input.restingNamed([input.failedInstanceId, ...input.alreadyTried, ...resting]);
|
|
156
156
|
return {
|
|
157
157
|
line: restingLine(named, input.formatTime, input.cannotDrive, { capped: input.triedCount >= MAX_ENGINES_PER_TURN }),
|
|
158
|
-
category: named.some((engine) => engine.needsSignIn || engine.keyExpired) ? "account" : "failover_exhausted",
|
|
158
|
+
category: named.some((engine) => engine.needsSignIn || engine.keyExpired) || input.cannotDrive?.signedOut?.length ? "account" : "failover_exhausted",
|
|
159
159
|
};
|
|
160
160
|
}
|
|
161
161
|
if (input.failureKind === "usage_limited") {
|
|
@@ -1,4 +1,29 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
1
2
|
import { execCli } from "../procs.js";
|
|
3
|
+
/** Keep the CLI off the machine's Anthropic profile (the `ant` CLI's store,
|
|
4
|
+
* ~/.config/anthropic, chosen by `ANTHROPIC_PROFILE`) unless this account's
|
|
5
|
+
* own settings name one on purpose.
|
|
6
|
+
*
|
|
7
|
+
* 2026-11-10: that store held an access token that had expired in August
|
|
8
|
+
* and has no refresh token. Claude Code used it, `claude auth status`
|
|
9
|
+
* answered `loggedIn: true, authMethod: "oauth_token"` without checking the
|
|
10
|
+
* expiry, and every turn ended "Login expired · ... re-authenticate your
|
|
11
|
+
* Anthropic profile". Settings showed Claude signed in while it rested as
|
|
12
|
+
* "needs sign-in" every half hour for three days. Pointing the CLI's profile
|
|
13
|
+
* folder at one that never exists leaves it its own login (Keychain or
|
|
14
|
+
* CLAUDE_CONFIG_DIR), so the probe and the turn both tell the truth.
|
|
15
|
+
*
|
|
16
|
+
* The CLI's own tools inherit this, so `ant` or an SDK script a bot runs
|
|
17
|
+
* finds no profile either, like the API keys this launch already removes. */
|
|
18
|
+
export function isolateAnthropicProfile(env, instanceEnvironment, dataDir) {
|
|
19
|
+
if (choseAnthropicProfile(instanceEnvironment))
|
|
20
|
+
return;
|
|
21
|
+
delete env.ANTHROPIC_PROFILE;
|
|
22
|
+
env.ANTHROPIC_CONFIG_DIR = join(dataDir, "claude-no-anthropic-profile");
|
|
23
|
+
}
|
|
24
|
+
/** Whether this account's own settings name an Anthropic profile on purpose:
|
|
25
|
+
* then the profile's token is its sign-in, for a named account too. */
|
|
26
|
+
export const choseAnthropicProfile = (instanceEnvironment) => Boolean(instanceEnvironment.ANTHROPIC_PROFILE || instanceEnvironment.ANTHROPIC_CONFIG_DIR);
|
|
2
27
|
/** Whether a parsed `claude auth status --json` answer is this account's own
|
|
3
28
|
* sign-in.
|
|
4
29
|
*
|
|
@@ -22,12 +22,12 @@ import { brokerSocketPath, describeSpawnFailure, execCli, killCliTree, resolveCl
|
|
|
22
22
|
import { parseClaudeMcpList, parseClaudeMcpLocalNames } from "../claude-account-connectors.js";
|
|
23
23
|
import { classifyResumeFailure, mayReplay, recoveryPromptFor } from "../resume-recovery.js";
|
|
24
24
|
import { ClaudeLoginController } from "./claude-login-auth.js";
|
|
25
|
-
import { claudeAuthStatus } from "./claude-auth-status.js";
|
|
25
|
+
import { choseAnthropicProfile, claudeAuthStatus, isolateAnthropicProfile } from "./claude-auth-status.js";
|
|
26
26
|
export { claudeSignedIn } from "./claude-auth-status.js";
|
|
27
27
|
import { gateServer, resultBudget } from "../mcp-gate-config.js";
|
|
28
28
|
import { newEventId, newId } from "../contracts.js";
|
|
29
29
|
import { askInputSummary, commandSummary, toolDetailPreview } from "../tool-summary.js";
|
|
30
|
-
import { classifyError, computeBackoff, computeCredentialRefreshBackoff, CREDENTIAL_REFRESH_CONFLICT, interruptibleDelay, RETRY_MAX_ATTEMPTS, } from "./retry.js";
|
|
30
|
+
import { classifyError, computeBackoff, computeCredentialRefreshBackoff, CREDENTIAL_REFRESH_CONFLICT, interruptibleDelay, isModelAccessRefused, RETRY_MAX_ATTEMPTS, } from "./retry.js";
|
|
31
31
|
import { applyClaudeInject, decodeInjectId, mergeLocalInject, probeLocalInjects, resolveInjectId, } from "./local-inject.js";
|
|
32
32
|
import { appendNative } from "./native.js";
|
|
33
33
|
import { SPAWNED_PROXIES } from "../proxy-paths.js";
|
|
@@ -76,7 +76,7 @@ export function resolveClaudeConfigDir(configDir, env = process.env) {
|
|
|
76
76
|
export function claudeAuthFailure(frame, text) {
|
|
77
77
|
if (frame.is_api_error_message !== true && typeof frame.error !== "string")
|
|
78
78
|
return false;
|
|
79
|
-
return frame.error === "authentication_failed" || classifyError({ text }).reason === "auth_failed";
|
|
79
|
+
return !isModelAccessRefused(text) && (frame.error === "authentication_failed" || classifyError({ text }).reason === "auth_failed");
|
|
80
80
|
}
|
|
81
81
|
/** Whether a stream frame is the CLI reporting that it lost a race to renew
|
|
82
82
|
* the shared OAuth token ("Failed to refresh OAuth token: another Claude
|
|
@@ -118,7 +118,7 @@ export function claudeResultStopReason(o) {
|
|
|
118
118
|
* Keeping the probe and turn environments identical prevents setup from
|
|
119
119
|
* claiming an API-key login that the turn itself would deliberately remove.
|
|
120
120
|
*/
|
|
121
|
-
function claudeEnvironment(model, source = process.env, configDir, instanceEnvironment = {}) {
|
|
121
|
+
export function claudeEnvironment(model, source = process.env, configDir, instanceEnvironment = {}) {
|
|
122
122
|
const env = { ...source, PATH: augmentedPath(), NPM_CONFIG_LOGLEVEL: "error" };
|
|
123
123
|
if (configDir?.trim()) {
|
|
124
124
|
env.CLAUDE_CONFIG_DIR = resolveClaudeConfigDir(configDir, env);
|
|
@@ -135,6 +135,7 @@ function claudeEnvironment(model, source = process.env, configDir, instanceEnvir
|
|
|
135
135
|
}
|
|
136
136
|
delete env.CLAUDECODE;
|
|
137
137
|
delete env.CLAUDE_CODE_ENTRYPOINT;
|
|
138
|
+
isolateAnthropicProfile(env, instanceEnvironment, DATA_DIR);
|
|
138
139
|
// The harness process may hold workspace credentials (xai/box/voice keys,
|
|
139
140
|
// env-injected at boot); none of them are this CLI's to see.
|
|
140
141
|
stripWorkspaceCredentialEnv(env);
|
|
@@ -844,7 +845,7 @@ export const ClaudeDriver = {
|
|
|
844
845
|
const environment = (model) => claudeEnvironment(config.managed ? undefined : model, { ...process.env, ...input.environment }, config.configDir, input.environment);
|
|
845
846
|
const catalogEnv = environment();
|
|
846
847
|
// An account with its own folder signs in there, never on a borrowed login (claudeOwnLogin).
|
|
847
|
-
const namedAccount = Boolean(config.configDir?.trim());
|
|
848
|
+
const namedAccount = Boolean(config.configDir?.trim()) && !choseAnthropicProfile(input.environment);
|
|
848
849
|
// Say it once where a headless or source run reads its logs; the Engines
|
|
849
850
|
// page carries the same warning for the desktop (claudeInheritWarning).
|
|
850
851
|
if (inheritsUserConfig(catalogEnv)) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isProviderSafetyBlock } from "../../shared/provider-safety.js";
|
|
2
2
|
import { classifyEngineFailure } from "../engine-failure.js";
|
|
3
|
+
export { isModelAccessRefused } from "../model-access-refusal.js";
|
|
3
4
|
/** Retries after the first try (docs/chibitek/engine-tiers.md, "Automatic
|
|
4
5
|
* failover"): two, with backoff. */
|
|
5
6
|
export const RETRY_MAX_RETRIES = 2;
|
|
@@ -255,11 +255,20 @@ export function restingLine(engines, formatTime, computer, options = {}) {
|
|
|
255
255
|
: engine.needsSignIn ? `${engine.label} needs sign-in`
|
|
256
256
|
: engine.notResponding ? `${engine.label} is not responding`
|
|
257
257
|
: `${engine.label} is resting until ${formatTime(engine.until)}`));
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
258
|
+
// Engines that could work on the place but were passed over before any
|
|
259
|
+
// rest was read: signed out, or not ready on this computer. Named so the
|
|
260
|
+
// line never hides a way back (an engine one sign-in away).
|
|
261
|
+
const fresh = (labels) => (labels ?? []).filter((label) => !seen.has(label) && seen.add(label));
|
|
262
|
+
const signedOut = fresh(computer?.signedOut).map((label) => `${label} needs sign-in`);
|
|
263
|
+
const unavailable = fresh(computer?.unavailable).map((label) => `${label} is unavailable`);
|
|
264
|
+
const hint = listed.some((engine) => engine.keyExpired || engine.needsSignIn) || signedOut.length ? ` ${ACCOUNTS_HINT}` : "";
|
|
265
|
+
const cannot = fresh(computer?.engines).map((label) => `${label} can't control ${computer.place}`);
|
|
266
|
+
// After the two-try cap the cap line says more, unless an engine cannot
|
|
267
|
+
// control the place at all; the passed-over engines are named either way.
|
|
268
|
+
if (cannot.length || ((signedOut.length || unavailable.length) && !options.capped)) {
|
|
269
|
+
return `No engine that can work on ${computer.place} is free, so this turn stopped: ${[...parts, ...signedOut, ...unavailable, ...cannot].join("; ")}.${hint}`;
|
|
270
|
+
}
|
|
271
|
+
parts.push(...signedOut, ...unavailable);
|
|
263
272
|
// The two-try cap, not an empty ladder: say so, with what each engine hit.
|
|
264
273
|
if (options.capped) {
|
|
265
274
|
const count = MAX_ENGINES_PER_TURN === 2 ? "two" : String(MAX_ENGINES_PER_TURN);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AUTH_STATUS, isModelAccessRefused } from "./model-access-refusal.js";
|
|
1
2
|
/** resetAt and resetText, when the text states a reset; else, for a rolling
|
|
2
3
|
* window, its length. */
|
|
3
4
|
export function statedReset(text, now = Date.now()) {
|
|
@@ -109,13 +110,10 @@ const AUTH_FAILED = [
|
|
|
109
110
|
// Claude Code: "Not logged in · Please run /login", "Login expired · Run /login ...", "Invalid API key · ...";
|
|
110
111
|
// Anthropic API: 401 authentication_error "invalid x-api-key";
|
|
111
112
|
// OpenAI: "Incorrect API key provided"; ACP agents: -32000 "Authentication required".
|
|
112
|
-
|
|
113
|
+
...AUTH_STATUS, // a 401/403 as a status or beside sign-in words, never a bare number
|
|
113
114
|
/\bunauthori[sz]ed\b|\bunauthenticated\b|\bforbidden\b/i,
|
|
114
115
|
/\bauthentication[_ ](?:error|failed|required)\b|\binvalid_credentials\b|\bAUTH_REQUIRED\b/i,
|
|
115
116
|
/\b(?:invalid|incorrect)[ _-]?(?:x-)?api[ _-]?key\b|\bapi key (?:is )?(?:invalid|expired|revoked|not valid)\b/i,
|
|
116
|
-
// OpenCode, 2026-10-19, as a JSON-RPC internal error: "Internal error:
|
|
117
|
-
// This API key has expired. Create a new API key in OpenCode Console ..."
|
|
118
|
-
/\bapi[ _-]?key (?:has |was )(?:been )?(?:expired|revoked|disabled)\b/i,
|
|
119
117
|
/\bnot (?:logged|signed) in\b|\b(?:logged|signed) out\b|\b(?:please )?run \/login\b|\b(?:login|sign-?in) (?:has )?expired\b|\bmissing bearer\b/i,
|
|
120
118
|
/\b(?:token|session|credentials?) (?:has |have )?expired\b|\bexpired (?:token|session|credentials?)\b/i,
|
|
121
119
|
];
|
|
@@ -149,6 +147,8 @@ export function classifyEngineFailure(text, now = Date.now()) {
|
|
|
149
147
|
}
|
|
150
148
|
if (isCredentialDead(text))
|
|
151
149
|
return { kind: "auth_failed", permanent: true };
|
|
150
|
+
if (isModelAccessRefused(text))
|
|
151
|
+
return { kind: "request_rejected" }; // the model rests, not the login
|
|
152
152
|
if (AUTH_FAILED.some((pattern) => pattern.test(text)))
|
|
153
153
|
return { kind: "auth_failed" };
|
|
154
154
|
if (STALLED.some((pattern) => pattern.test(text)))
|
|
@@ -275,7 +275,7 @@ import { localHost, probeLocalInjects } from "./drivers/local-inject.js";
|
|
|
275
275
|
import { totalmem } from "node:os";
|
|
276
276
|
import { loadInstanceKeys } from "./instance-keys.js";
|
|
277
277
|
import { createProviderAccountRoutes } from "./routes/provider-accounts.js";
|
|
278
|
-
import { accountStops, injectedModel, restScope } from "./injected-model-rest.js";
|
|
278
|
+
import { accountStops, injectedModel, modelScope, refusedModelScope, restScope } from "./injected-model-rest.js";
|
|
279
279
|
import { accountProvider } from "../shared/provider-accounts.js";
|
|
280
280
|
import { createAccountRoutes } from "./routes/accounts.js";
|
|
281
281
|
import { installNativeVault } from "./vault/runtime.js";
|
|
@@ -302,6 +302,7 @@ import { MODEL_CLASSES, TIERS_THAT_MAY_DROP_A_CLASS, botEngineMode, isBotTier, m
|
|
|
302
302
|
import { EngineRestStore } from "./engine-rest.js";
|
|
303
303
|
import { bindAtomicEngineAccountSource } from "./atomic-engine-accounts.js";
|
|
304
304
|
import { classifyEngineFailure } from "./engine-failure.js";
|
|
305
|
+
import { computerStopNames } from "./computer-stop-names.js";
|
|
305
306
|
import { PayPerUseEpisodes } from "./pay-per-use.js";
|
|
306
307
|
import { PersonalBotMdm, connectionsFor, engineOwner, isPrivateChibiPair, migrateEngineOwners, ownerAllows, ownerPickRefusal, personalBotPatchRefusal, personalConfig, privateBotAccountView, privateBotInternalRefusal, privateChibiLinkAudit, privateChibiLinked, setPrivateChibiLinkReader, withChibiLink, withEngineOwner, withPersonalConnection, withReadWorkMemory, withUseLocalModels, withoutEngineOwner, } from "./personal-bot.js";
|
|
307
308
|
import { PERSONAL_BOT_REFUSALS, chibiPrivateBotLinkPrompt, isPersonalBot, personalStopLine, personalTime, privateBotPrompt } from "../shared/personal-bot.js";
|
|
@@ -3177,7 +3178,8 @@ function restingStop(candidates, skipped, ownId, computer) {
|
|
|
3177
3178
|
return entry ? [{ label: candidate?.displayName ?? instanceId, until: entry.until, needsSignIn: entry.needsSignIn, keyExpired: entry.keyExpired,
|
|
3178
3179
|
notResponding: entry.notResponding }] : [];
|
|
3179
3180
|
});
|
|
3180
|
-
|
|
3181
|
+
const named = cannotDriveNamed(candidates, [{ instanceId: ownId }, ...skipped], computer);
|
|
3182
|
+
return Object.assign(new Error(restingLine(engines, restTime, named)), { status: 409, code: "engines_resting", category: engines.some((engine) => engine.needsSignIn || engine.keyExpired) || named?.signedOut.length ? "account" : "failover_exhausted" });
|
|
3181
3183
|
}
|
|
3182
3184
|
/** The computer a turn's engine must drive itself: the bot's or the
|
|
3183
3185
|
* conversation's explicit "Works on" place, as dispatch mounts it. Auto, Off,
|
|
@@ -3191,16 +3193,12 @@ function turnComputer(bot, threadId, runOn) {
|
|
|
3191
3193
|
return "vps";
|
|
3192
3194
|
return undefined;
|
|
3193
3195
|
}
|
|
3194
|
-
/** For a stop line:
|
|
3195
|
-
*
|
|
3196
|
-
function cannotDriveNamed(candidates,
|
|
3196
|
+
/** For a stop line: what the turn's computer is called, and which engines cannot drive it or
|
|
3197
|
+
* could but were skipped as signed out or unavailable (computerStopNames). */
|
|
3198
|
+
function cannotDriveNamed(candidates, skipped, computer) {
|
|
3197
3199
|
if (!computer)
|
|
3198
3200
|
return undefined;
|
|
3199
|
-
|
|
3200
|
-
const candidate = candidates.find((entry) => entry.instanceId === instanceId);
|
|
3201
|
-
return candidate && !canDriveComputer(candidate, computer) ? [candidate.displayName] : [];
|
|
3202
|
-
});
|
|
3203
|
-
return { place: surfaceLabel(computer === "vps" ? "cloud" : computer), engines };
|
|
3201
|
+
return { place: surfaceLabel(computer === "vps" ? "cloud" : computer), ...computerStopNames(candidates, skipped, computer) };
|
|
3204
3202
|
}
|
|
3205
3203
|
// ── the Primary Bot sweep's engine (server/primary-bot.ts) ───────────────
|
|
3206
3204
|
// Chibi is always the Orchestrator, but a sweep is Routine work: it runs on
|
|
@@ -3455,7 +3453,7 @@ const engineProbes = new EngineProbes({
|
|
|
3455
3453
|
});
|
|
3456
3454
|
engineProbes.start();
|
|
3457
3455
|
const engineResting = (candidate, model) => restingOnRoute(candidate, model, engineSnapshots.current() ?? [], // twins: sameRoute
|
|
3458
|
-
(entry) => engineRests.resting(entry.instanceId, engineAccount(entry), restScope(entry, model), injectedModel(model))); // restScope: an `ollama::` model on Claude rests alone
|
|
3456
|
+
(entry) => engineRests.resting(entry.instanceId, engineAccount(entry), restScope(entry, model), injectedModel(model)) ?? engineRests.resting(entry.instanceId, engineAccount(entry), modelScope(model), true)); // restScope: an `ollama::` model on Claude rests alone; modelScope: so does a model the plan refused
|
|
3459
3457
|
/** A model's class, when a source or a person's override grades it (a local
|
|
3460
3458
|
* Ollama model is Añejo); undefined otherwise (server/model-levels). */
|
|
3461
3459
|
function modelClassOf(driverKind, model) {
|
|
@@ -3615,7 +3613,8 @@ function noteEngineBack(event) {
|
|
|
3615
3613
|
const candidate = engineSnapshots.current()?.find((entry) => entry.instanceId === instanceId);
|
|
3616
3614
|
const selection = directTurnBots.get(event.threadId)?.modelSelection;
|
|
3617
3615
|
const model = selection?.instanceId === instanceId ? selection.model : undefined;
|
|
3618
|
-
|
|
3616
|
+
for (const scope of new Set([candidate ? restScope(candidate, model) : undefined, modelScope(model)]))
|
|
3617
|
+
engineRests.noteBack(instanceId, candidate ? engineAccount(candidate) : undefined, scope);
|
|
3619
3618
|
}
|
|
3620
3619
|
/** Rest a refused engine and continue on an eligible engine, or show an actionable line. */
|
|
3621
3620
|
function engineFailover(turn, completion) {
|
|
@@ -3636,7 +3635,7 @@ function engineFailover(turn, completion) {
|
|
|
3636
3635
|
// that provider rests, the engine's others stay free. A stall is the engine's.
|
|
3637
3636
|
// A dead key is the whole account's, whichever provider the model ran on:
|
|
3638
3637
|
// the rest names no provider, so Atomic Engine skips the account too.
|
|
3639
|
-
const scope = failure.kind === "stalled" || failure.permanent || !failedCandidate ? undefined : restScope(failedCandidate, ran?.model);
|
|
3638
|
+
const scope = failure.kind === "stalled" || failure.permanent || !failedCandidate ? undefined : restScope(failedCandidate, ran?.model) ?? refusedModelScope(failure.message, ran?.model);
|
|
3640
3639
|
const restFailed = () => engineRests.rest(turn.instanceId, failedCandidate ? engineAccount(failedCandidate) : undefined, failure.kind, { resetAt: failure.resetAt, resetText: failure.resetText, windowMs: failure.windowMs, message: redactSecretsInText(failure.message),
|
|
3641
3640
|
...(failure.permanent ? { permanent: true } : {}), ...(scope ? { scope } : {}), ...(ran?.model ? { model: ran.model } : {}),
|
|
3642
3641
|
...(failure.kind === "auth_failed" && failedCandidate ? { reportedSignedIn: failedCandidate.snapshot.state === "available" && failedCandidate.snapshot.authenticated === true } : {}) });
|
|
@@ -3888,7 +3887,7 @@ function failoverPick(turn, profile, projected, candidates, failedCandidate, res
|
|
|
3888
3887
|
choice, fallback, subscriptionLine: subscriptionMove?.line, failureKind: turn.failure?.kind,
|
|
3889
3888
|
pausedUntil: payPerUse.pausedUntil(), skipped: resolution.skipped, payPerUsePausedLine, restingNamed,
|
|
3890
3889
|
failedInstanceId: turn.instanceId, alreadyTried: attempt.tried, triedCount: tried.size,
|
|
3891
|
-
cannotDrive: cannotDriveNamed(candidates, resolution.skipped
|
|
3890
|
+
cannotDrive: cannotDriveNamed(candidates, resolution.skipped, computer),
|
|
3892
3891
|
policy: connectionRunOutPolicy(cfg.engineTiers), paidApproved: Boolean(payPerUse.current()?.keptGoingAt),
|
|
3893
3892
|
local: Boolean(placed.local), currentLabel: engineLabel(candidates, attempt.selection),
|
|
3894
3893
|
nextLabel: choice ? engineLabel(candidates, choice.selection) : undefined,
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
// session limit was moved off its Ollama model onto another Claude account.
|
|
10
10
|
import { decodeInjectId } from "./drivers/local-inject.js";
|
|
11
11
|
import { modelProvider } from "./harness-import/engine-policy.js";
|
|
12
|
+
import { isModelAccessRefused } from "./model-access-refusal.js";
|
|
12
13
|
/** The rest scope of a model whose turns go to another host. */
|
|
13
14
|
export const INJECTED_SCOPE = "injected";
|
|
14
15
|
/** Whether this model goes to another host than the engine's own account. */
|
|
@@ -21,5 +22,13 @@ export function restScope(candidate, model) {
|
|
|
21
22
|
return undefined;
|
|
22
23
|
return injectedModel(model) ? INJECTED_SCOPE : modelProvider(candidate, model);
|
|
23
24
|
}
|
|
25
|
+
/** The scope of a rest for one model its account may not use, on an engine
|
|
26
|
+
* with no providers to rest instead (Claude, Codex): `model:<id>`. */
|
|
27
|
+
export const modelScope = (model) => (model ? `model:${model}` : undefined);
|
|
28
|
+
/** That scope when the failure is a model refusal (a plan that does not open
|
|
29
|
+
* the model, an unknown id; model-access-refusal.ts), else undefined. Without
|
|
30
|
+
* it the rest had no scope and one bot on a refused model benched every bot
|
|
31
|
+
* on the engine's other models. */
|
|
32
|
+
export const refusedModelScope = (message, model) => (message && isModelAccessRefused(message) ? modelScope(model) : undefined);
|
|
24
33
|
/** Whether the engine's account state (signed out, resting) stops this model. */
|
|
25
34
|
export const accountStops = (model) => !injectedModel(model);
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// When a provider's 401/403 means "signed out" and when it means "this
|
|
2
|
+
// model is not open to you" (server/engine-failure.ts reads both).
|
|
3
|
+
//
|
|
4
|
+
// Written 2026-11-10 while chasing "Claude needs sign-in" on a Mac whose
|
|
5
|
+
// Claude subscription was active. That stop turned out to be a real expired
|
|
6
|
+
// login (the borrowed Anthropic profile token; see isolateAnthropicProfile in
|
|
7
|
+
// server/drivers/claude-auth-status.ts), not a misread. What stays here is the
|
|
8
|
+
// guard the search showed was missing: the sign-in patterns matched a bare
|
|
9
|
+
// 401 or 403 anywhere in the text, and a model the signed-in plan does not
|
|
10
|
+
// open is not fixed by a new sign-in, so it must not rest the whole account.
|
|
11
|
+
/** A 401 or 403 that is a failed sign-in: written as a status ("API Error:
|
|
12
|
+
* 401", "HTTP 403", "status 401") or beside sign-in words, never a bare
|
|
13
|
+
* number in a usage, plan or new-model message. */
|
|
14
|
+
export const AUTH_STATUS = [
|
|
15
|
+
// "API Error: 401", "HTTP 403", "HTTP/1.1 403", "status code 401", "error
|
|
16
|
+
// code: 403", JSON "status":401. A bare "code" is not enough ("exited with
|
|
17
|
+
// code 403" is a process), and neither is a count ("Error 403 files").
|
|
18
|
+
/\b(?:api error|http(?:\/\d(?:\.\d)?)?|(?:status|error|response)(?:[ _]?code)?)\b["\s:=([]*40[13]\b(?!\s+(?:of|files?|rows?|items?|messages?|tokens?|results?|lines?|bytes|tests?|errors?|warnings?|seconds?|minutes?|ms|times)\b)|"code"\s*:\s*40[13]\b/i,
|
|
19
|
+
// OpenCode's ACP shape, "Upstream request failed: [401] ...". The bracket
|
|
20
|
+
// alone is not a status: "[403] indexing files" is a log line.
|
|
21
|
+
/\b(?:failed|error|rejected)\b[^\n[]{0,12}\[40[13]\]/i,
|
|
22
|
+
// "Request failed with 401", "Request failed (403)": the number ends the
|
|
23
|
+
// thought.
|
|
24
|
+
/\b(?:failed|rejected|responded|answered)(?: with)?(?: (?:a|an|status|http|code))* \(?40[13]\)?(?=\s*(?:$|[.,;:)\]]|from\b|error\b|response\b))/i,
|
|
25
|
+
// "received 403 from upstream". These verbs also count things ("returned
|
|
26
|
+
// 401."), so the number needs what it came from.
|
|
27
|
+
/\b(?:returned|received|got) (?:a |an )?\(?40[13]\)?(?=\s*(?:from\b|error\b|response\b))/i,
|
|
28
|
+
/\b40[13]\b[^\n]{0,160}\b(?:unauthori[sz]ed|unauthenticated|authenticat\w*|api[ _-]?key|oauth|(?:access |bearer )?token|credentials?|log(?:ged)?[ -]?in|sign(?:ed)?[ -]?in)\b/i,
|
|
29
|
+
];
|
|
30
|
+
// The shapes read. The second is Claude Code's own wording; the first is the
|
|
31
|
+
// Anthropic API's permission_error shape and was not captured from a live
|
|
32
|
+
// failure:
|
|
33
|
+
// "API Error: 403 {"type":"error","error":{"type":"permission_error",
|
|
34
|
+
// "message":"Your plan does not include access to claude-fable-5-2."}}"
|
|
35
|
+
// "There's an issue with the selected model (claude-fable-5-2). It may not
|
|
36
|
+
// exist or you may not have access to it. Run /model to pick a different
|
|
37
|
+
// model."
|
|
38
|
+
// Every pattern needs the word "model" or a model's own name. A product name
|
|
39
|
+
// alone does not count: "Your account does not have access to Claude. Please
|
|
40
|
+
// login again" is the wrong account signed in, which is a sign-in.
|
|
41
|
+
const MODEL_NAME = "model|claude-[\\w.-]+|gpt-[\\w.-]+|gemini-[\\w.-]+|grok-[\\w.-]+|opus|sonnet|haiku|fable";
|
|
42
|
+
const MODEL_ACCESS_REFUSED = [
|
|
43
|
+
/\bissue with the selected model\b|\bmodel\b[^\n]{0,120}\b(?:may|does) not exist or you (?:may |do )?not have access\b/i,
|
|
44
|
+
/\b(?:do(?:es)?n['’]?t|do(?:es)? not) (?:currently )?have access to (?:the |this |that )?(?:model\b|claude-|gpt-|gemini-|grok-|o\d)/i,
|
|
45
|
+
new RegExp(`\\b(?:plan|subscription|organi[sz]ation|account|tier) (?:does not|doesn['’]?t) (?:include|support|allow|have access to)\\b[^.\\n]{0,80}\\b(?:${MODEL_NAME})\\b`, "i"),
|
|
46
|
+
/\b(?:model|claude-[\w.-]+|opus|sonnet|haiku|fable)\b(?:[^.\n]|\.\d){0,80}\b(?:is |are )?(?:not available|unavailable|not included|not enabled|not supported) (?:on|in|for|with) (?:your|this|the) (?:current )?(?:plan|subscription|account|organi[sz]ation|tier)\b/i,
|
|
47
|
+
/\bmodel_not_found\b|\bnot_found_error\b[^\n]{0,200}\bmodel\b|\bmodel\b[^\n]{0,40}\bnot_found_error\b/i,
|
|
48
|
+
new RegExp(`\\bpermission_error\\b[^\\n]{0,240}\\b(?:${MODEL_NAME})\\b`, "i"),
|
|
49
|
+
];
|
|
50
|
+
// Real sign-in or dead-credential words win, whatever model the message
|
|
51
|
+
// names: "OAuth token expired", "token has been revoked", "login again",
|
|
52
|
+
// "OAuth token does not meet scope requirement".
|
|
53
|
+
const SIGN_IN_WORDS = /\bnot (?:logged|signed) in\b|\b(?:please )?run \/login\b|\blog ?in again\b|\bsign ?in again\b|\bre-?authenticat\w*|\b(?:login|sign-?in|token|session|credentials?) (?:has |have )?expired\b|\b(?:token|key|credentials?|session) (?:has |have |was |were )?(?:been )?revoked\b|\bauthentication_error\b|\boauth\b|\bscope requirement\b|\binvalid[ _-]?(?:x-)?api[ _-]?key\b|\bkey (?:has |was )?(?:been )?(?:expired|revoked)\b/i;
|
|
54
|
+
/** Whether the text says the signed-in account may not use this model (a
|
|
55
|
+
* plan, organization or model-id refusal). That model rests
|
|
56
|
+
* (request_rejected, scoped to it); the login and the engine's other models
|
|
57
|
+
* stay good. */
|
|
58
|
+
export function isModelAccessRefused(text) {
|
|
59
|
+
if (!text || SIGN_IN_WORDS.test(text))
|
|
60
|
+
return false;
|
|
61
|
+
return MODEL_ACCESS_REFUSED.some((pattern) => pattern.test(text));
|
|
62
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { writeFileAtomic } from "./atomic.js";
|
|
1
2
|
import { createHash } from "node:crypto";
|
|
2
|
-
import { closeSync, constants, fstatSync, fsyncSync, lstatSync, openSync, readSync, writeSync } from "node:fs";
|
|
3
|
+
import { closeSync, constants, fstatSync, fsyncSync, lstatSync, openSync, readFileSync, readSync, writeSync } from "node:fs";
|
|
3
4
|
import { MAX_WORKSPACE_BACKUP_BYTES } from "./workspace-backup-archive.js";
|
|
4
5
|
/** Export captures live files; restore keeps the strict staged-file check.
|
|
5
6
|
* Reads stay on the opened descriptor, never a replacement symlink. Each live
|
|
@@ -65,3 +66,35 @@ export function copyRegular(source, destination, onLiveChange) {
|
|
|
65
66
|
}
|
|
66
67
|
return captured ?? null;
|
|
67
68
|
}
|
|
69
|
+
// File indexes can exceed 16 MB well below the entry cap. Keep a bounded
|
|
70
|
+
// metadata budget large enough for ordinary 100,000-entry workspaces.
|
|
71
|
+
export const MAX_METADATA_BYTES = 64 * 1024 ** 2;
|
|
72
|
+
export function entryExists(path) {
|
|
73
|
+
try {
|
|
74
|
+
lstatSync(path);
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
if (error.code === "ENOENT")
|
|
79
|
+
return false;
|
|
80
|
+
throw error;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
export function privateJson(path) {
|
|
84
|
+
const fd = openSync(path, constants.O_RDONLY | constants.O_NOFOLLOW);
|
|
85
|
+
try {
|
|
86
|
+
const stat = fstatSync(fd);
|
|
87
|
+
if (!stat.isFile() || stat.size > MAX_METADATA_BYTES)
|
|
88
|
+
throw new Error("Workspace backup metadata is too large or is not a regular file.");
|
|
89
|
+
return JSON.parse(readFileSync(fd, "utf8"));
|
|
90
|
+
}
|
|
91
|
+
finally {
|
|
92
|
+
closeSync(fd);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
export function writeJson(path, value) {
|
|
96
|
+
const text = JSON.stringify(value);
|
|
97
|
+
if (Buffer.byteLength(text) > MAX_METADATA_BYTES)
|
|
98
|
+
throw new Error("Workspace backup metadata exceeds the size limit.");
|
|
99
|
+
writeFileAtomic(path, text, { mode: 0o600 });
|
|
100
|
+
}
|
|
@@ -7,6 +7,7 @@ import { z } from "zod";
|
|
|
7
7
|
import { WORKSPACE_BACKUP_CLIENT_KEYS } from "../shared/workspace-backup-client.js";
|
|
8
8
|
import { createWorkspaceBackup, stageWorkspaceBackup, commitPendingWorkspaceRestore, MAX_WORKSPACE_BACKUP_UPLOAD_BYTES, removeWorkspaceBackupJob, } from "./workspace-backup.js";
|
|
9
9
|
import { desktopWorkspaceSecrets } from "./workspace-backup-secrets.js";
|
|
10
|
+
import { WORKSPACE_RESTORE_PARTS } from "../shared/workspace-backup.js";
|
|
10
11
|
import { listSavedBackups, revealInFileManager, saveWorkspaceBackup, savedBackupPath, savedWorkspaceBackupFile } from "./atomic-backup.js";
|
|
11
12
|
const PREFIX = "/api/workspace-backup";
|
|
12
13
|
const MAX_UPLOAD_BYTES = MAX_WORKSPACE_BACKUP_UPLOAD_BYTES;
|
|
@@ -154,7 +155,7 @@ export function createWorkspaceBackupRoutes(options) {
|
|
|
154
155
|
safetyCopyPath: restored.safetyCopyPath ?? null,
|
|
155
156
|
// What Settings shows after a restore: what to sign in to or clone again.
|
|
156
157
|
lastRestore: restored.restored ? {
|
|
157
|
-
secretsIncluded: restored.summary?.secrets === true, secrets: restored.secrets ?? null,
|
|
158
|
+
secretsIncluded: restored.summary?.secrets === true && !restored.keep?.includes("credentials"), keep: restored.keep ?? [], secrets: restored.secrets ?? null,
|
|
158
159
|
unresolvedPaths: restored.unresolvedPaths ?? [], checkouts: restored.summary?.checkouts ?? [], exclusions: restored.summary?.exclusions ?? [],
|
|
159
160
|
} : null,
|
|
160
161
|
});
|
|
@@ -165,7 +166,7 @@ export function createWorkspaceBackupRoutes(options) {
|
|
|
165
166
|
check(req, auth);
|
|
166
167
|
if (!options.restored.restored || body.restoreId !== options.restored.id)
|
|
167
168
|
throw failure("This restore has not completed. Restart Atomic first.", 409);
|
|
168
|
-
json(res, 200, { clientState: options.restored.clientState ?? {} });
|
|
169
|
+
json(res, 200, { clientState: options.restored.clientState ?? {}, keep: options.restored.keep ?? [] });
|
|
169
170
|
return true;
|
|
170
171
|
}
|
|
171
172
|
if (method === "POST" && path === `${PREFIX}/export`) {
|
|
@@ -324,7 +325,9 @@ export function createWorkspaceBackupRoutes(options) {
|
|
|
324
325
|
return true;
|
|
325
326
|
}
|
|
326
327
|
if (method === "POST" && path === `${PREFIX}/restore`) {
|
|
327
|
-
const body = z.object({ id: z.string().uuid(), confirmation: z.literal("REPLACE") }).parse(await options.readBody(req));
|
|
328
|
+
const body = z.object({ id: z.string().uuid(), confirmation: z.literal("REPLACE"), keep: z.array(z.enum(WORKSPACE_RESTORE_PARTS)).max(WORKSPACE_RESTORE_PARTS.length).optional() }).parse(await options.readBody(req));
|
|
329
|
+
if (body.keep?.includes("settings") && !body.keep.includes("credentials"))
|
|
330
|
+
throw failure("Restore app settings with saved credentials, or keep both on this computer.", 400);
|
|
328
331
|
get(body.id, auth, "staged");
|
|
329
332
|
const result = await operate(() => options.exclusive(async () => {
|
|
330
333
|
check(req, auth);
|
|
@@ -332,9 +335,9 @@ export function createWorkspaceBackupRoutes(options) {
|
|
|
332
335
|
// are in place (next boot); refusing here leaves nothing changed.
|
|
333
336
|
const secrets = stagedSecrets.get(body.id);
|
|
334
337
|
const desktop = desktopWorkspaceSecrets();
|
|
335
|
-
if (secrets && desktop)
|
|
338
|
+
if (secrets && desktop && !body.keep?.includes("credentials"))
|
|
336
339
|
await desktop.stage(body.id, secrets);
|
|
337
|
-
return commitPendingWorkspaceRestore(options.dataDir, body.id);
|
|
340
|
+
return commitPendingWorkspaceRestore(options.dataDir, body.id, body.keep);
|
|
338
341
|
}, true));
|
|
339
342
|
artifacts.delete(body.id);
|
|
340
343
|
stagedSecrets.delete(body.id);
|
|
@@ -35,7 +35,7 @@ export function desktopWorkspaceSecrets() { return desktop; }
|
|
|
35
35
|
export function installWorkspaceSecrets(port, dataDir, restore) {
|
|
36
36
|
if (!port) {
|
|
37
37
|
// A server without the desktop app cannot install the credential store.
|
|
38
|
-
if (restore.restored && restore.id && restore.summary?.secrets)
|
|
38
|
+
if (restore.restored && restore.id && restore.summary?.secrets && !restore.keep?.includes("credentials"))
|
|
39
39
|
markRestoreSecrets(dataDir, restore, "failed");
|
|
40
40
|
return;
|
|
41
41
|
}
|
|
@@ -69,7 +69,7 @@ export function installWorkspaceSecrets(port, dataDir, restore) {
|
|
|
69
69
|
async stage(id, secrets) { await request({ action: "stage", id, secrets }); },
|
|
70
70
|
async apply(id) { return (await request({ action: "apply", id })).applied === true; },
|
|
71
71
|
};
|
|
72
|
-
if (restore.restored && restore.id && restore.summary?.secrets) {
|
|
72
|
+
if (restore.restored && restore.id && restore.summary?.secrets && !restore.keep?.includes("credentials")) {
|
|
73
73
|
void desktop.apply(restore.id).then((applied) => markRestoreSecrets(dataDir, restore, applied ? "applied" : "failed"), (error) => {
|
|
74
74
|
console.error(`[workspace-restore] secrets were not installed: ${error instanceof Error ? error.message : String(error)}`);
|
|
75
75
|
markRestoreSecrets(dataDir, restore, "failed");
|