@chibitek/chibi 0.1.183 → 0.1.184
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-D63grDEy.js} +1 -1
- package/dist/assets/{arc-CZc_uW-u.js → arc-bQvylCdS.js} +1 -1
- package/dist/assets/{architectureDiagram-NJMV4G6O-DNLaTXeO.js → architectureDiagram-NJMV4G6O-BOAFaaj7.js} +1 -1
- package/dist/assets/{blockDiagram-BEXU5L5S-DLXsik0_.js → blockDiagram-BEXU5L5S-ewLAgFlb.js} +1 -1
- package/dist/assets/{c4Diagram-YGBWAQC7-DG6hN1C0.js → c4Diagram-YGBWAQC7-Dn_C6A7b.js} +1 -1
- package/dist/assets/channel-DaRjZag9.js +1 -0
- package/dist/assets/{chunk-2Q5K7J3B-D5Yjh7-1.js → chunk-2Q5K7J3B-DpB_wNSI.js} +1 -1
- package/dist/assets/{chunk-3FUC2YCW-Bxyjopy0.js → chunk-3FUC2YCW-DIelvlCV.js} +2 -2
- package/dist/assets/{chunk-5VM5RSS4-DDQZDrcU.js → chunk-5VM5RSS4-O-aALIul.js} +1 -1
- package/dist/assets/{chunk-GTNCS2PH-OwVykJDf.js → chunk-GTNCS2PH-Dqe5r4Ji.js} +1 -1
- package/dist/assets/{chunk-GWA4HPMP-BJRJdRRn.js → chunk-GWA4HPMP-FzFr6U_I.js} +1 -1
- package/dist/assets/{chunk-JWPE2WC7-D0rQf2t4.js → chunk-JWPE2WC7-BuJO0Fyh.js} +1 -1
- package/dist/assets/{chunk-NETBCI7D-DbgIhGxq.js → chunk-NETBCI7D-DMgFuMgZ.js} +1 -1
- package/dist/assets/{chunk-WEXAMYUT-NVC6qgIT.js → chunk-WEXAMYUT-BYXYAyMu.js} +1 -1
- package/dist/assets/{chunk-XXDRQBXY-B9iYAoH7.js → chunk-XXDRQBXY-s_OT2iv7.js} +1 -1
- package/dist/assets/{classDiagram-v2-NBCMYWYE-Cma68soF.js → classDiagram-v2-NBCMYWYE-Cdbr4CZV.js} +1 -1
- package/dist/assets/{cose-bilkent-JH36ORCC-BrXaARl8.js → cose-bilkent-JH36ORCC-CXjx4058.js} +1 -1
- package/dist/assets/{cynefin-OW5HDTMX-DaxVySTi.js → cynefin-OW5HDTMX-Cc2YqzW6.js} +1 -1
- package/dist/assets/{cynefinDiagram-VND7K2PF-BhqakyPn.js → cynefinDiagram-VND7K2PF-Cze_i1Vk.js} +1 -1
- package/dist/assets/{dagre-6A5THRUB-C1GSPYtM.js → dagre-6A5THRUB-oPouQ7XU.js} +1 -1
- package/dist/assets/{diagram-22UHCM2B-BJ3lUPTt.js → diagram-22UHCM2B-DNRc977u.js} +1 -1
- package/dist/assets/{diagram-3UASUU5V-B15DdW5N.js → diagram-3UASUU5V-B8vBo05Y.js} +1 -1
- package/dist/assets/{diagram-ATOU4E4O-CXiw2lST.js → diagram-ATOU4E4O-dCch9eKa.js} +1 -1
- package/dist/assets/{diagram-CDSNMT55-DoqH99bW.js → diagram-CDSNMT55-CYJSen9G.js} +1 -1
- package/dist/assets/{diagram-MLGK6HIB-snN4K-CB.js → diagram-MLGK6HIB-RxYVGgc6.js} +1 -1
- package/dist/assets/{diagram-MPIPVDR6-DgJvwpZO.js → diagram-MPIPVDR6-B-UyrObe.js} +1 -1
- package/dist/assets/{ebnfDiagram-ZINNZB2B-AO646Cux.js → ebnfDiagram-ZINNZB2B-CxGXwVT7.js} +1 -1
- package/dist/assets/{elk-276RUBZZ-BQwiFuXz.js → elk-276RUBZZ-CHGRRKuJ.js} +1 -1
- package/dist/assets/{erDiagram-OPXOYQCR-B5VI88HR.js → erDiagram-OPXOYQCR-BMJusoDl.js} +1 -1
- package/dist/assets/{flowDiagram-KWPJA3E3-BNaAddPG.js → flowDiagram-KWPJA3E3-DtiBETZe.js} +1 -1
- package/dist/assets/{ganttDiagram-FUAMR5RP-C_ZoEfA5.js → ganttDiagram-FUAMR5RP-DAXqRUQM.js} +1 -1
- package/dist/assets/{gitGraphDiagram-X574FWY7-xthNWdmM.js → gitGraphDiagram-X574FWY7-Cx_M7do1.js} +1 -1
- package/dist/assets/{index-DmYwoh4R.js → index-COCy7XsD.js} +133 -133
- package/dist/assets/{index-ASohJJer.js → index-DKt9qb9g.js} +1 -1
- package/dist/assets/{infoDiagram-VRGFBTTK-Qhrkz09J.js → infoDiagram-VRGFBTTK-CNgfLxed.js} +1 -1
- package/dist/assets/{ishikawaDiagram-OU5B5YK6-DzU3-GrV.js → ishikawaDiagram-OU5B5YK6-BvdGqyOz.js} +1 -1
- package/dist/assets/{journeyDiagram-ZHPQQLJL-Dif-aG4a.js → journeyDiagram-ZHPQQLJL-atzjOsJ2.js} +1 -1
- package/dist/assets/{kanban-definition-PNTS6WVX-NJ0l6rbK.js → kanban-definition-PNTS6WVX-miq8ywtS.js} +1 -1
- package/dist/assets/{linear-DpEaZ_8H.js → linear-3skQIwEd.js} +1 -1
- package/dist/assets/{mermaid.core-DOBTmT-1.js → mermaid.core-CcefVt63.js} +5 -5
- package/dist/assets/{mindmap-definition-NLK3R4M7-kPRBSQ6K.js → mindmap-definition-NLK3R4M7-CyJLiFXW.js} +1 -1
- package/dist/assets/{pegDiagram-GJSIUBJH-BgX62j0G.js → pegDiagram-GJSIUBJH-DdBX63bl.js} +1 -1
- package/dist/assets/{pieDiagram-5QR66LMP-DpC0-6hx.js → pieDiagram-5QR66LMP-DNO9-2f5.js} +1 -1
- package/dist/assets/{quadrantDiagram-O4NWA36T-CNrmwxvV.js → quadrantDiagram-O4NWA36T-BciZP71K.js} +1 -1
- package/dist/assets/{railroadDiagram-XR7U4H2S-wl7o4Y2J.js → railroadDiagram-XR7U4H2S-4IdVOKPa.js} +1 -1
- package/dist/assets/{requirementDiagram-PLB6GJNP-D2qhVvpT.js → requirementDiagram-PLB6GJNP-DFdsFYy-.js} +1 -1
- package/dist/assets/{sankeyDiagram-IPEJSGJF-DZOSOZWs.js → sankeyDiagram-IPEJSGJF-HH2WFlmw.js} +1 -1
- package/dist/assets/{sequenceDiagram-PO4LG4MO-eBogKj3g.js → sequenceDiagram-PO4LG4MO-CP91Sy-s.js} +1 -1
- package/dist/assets/{sizeCapture-INFHLROL-Dp_Vdw0m.js → sizeCapture-INFHLROL-DhZiuL4S.js} +1 -1
- package/dist/assets/{stateDiagram-v2-GCMORJYK-K79Em0_p.js → stateDiagram-v2-GCMORJYK-DIa0uzhR.js} +1 -1
- package/dist/assets/{swimlanes-2SLR337P-ByKYlFa_.js → swimlanes-2SLR337P-CXr7kql9.js} +1 -1
- package/dist/assets/swimlanesDiagram-TC7HE7FX-CtuksGU4.js +8 -0
- package/dist/assets/{timeline-definition-EJHVYXUP-CzeMeYU0.js → timeline-definition-EJHVYXUP-BidOWl1X.js} +1 -1
- package/dist/assets/{usecaseDiagram-POWQR4AR-uQjp5Yz3.js → usecaseDiagram-POWQR4AR-Dt0DqsBc.js} +1 -1
- package/dist/assets/{vennDiagram-UO4OBE2U-De8_78dQ.js → vennDiagram-UO4OBE2U-DMfDgcZH.js} +1 -1
- package/dist/assets/{wardleyDiagram-VNRHLVJA-Dk_VO2LR.js → wardleyDiagram-VNRHLVJA-jgsJZ4n4.js} +1 -1
- package/dist/assets/{xychartDiagram-PMCCYNJV-DMx2Y7qW.js → xychartDiagram-PMCCYNJV-AllqBdcw.js} +1 -1
- package/dist/handbook/atomic-handbook.html +1 -5
- package/dist/index.html +1 -1
- package/dist-server/index.js +149 -113
- 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
|
@@ -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");
|
|
@@ -8,11 +8,11 @@ import { homedir } from "node:os";
|
|
|
8
8
|
import { backup, DatabaseSync } from "node:sqlite";
|
|
9
9
|
import * as tar from "tar";
|
|
10
10
|
import { fromMarkdown } from "mdast-util-from-markdown";
|
|
11
|
-
import { copyRegular } from "./workspace-backup-copy.js";
|
|
12
|
-
import { writeFileAtomic } from "./atomic.js";
|
|
11
|
+
import { copyRegular, entryExists, privateJson, writeJson, MAX_METADATA_BYTES } from "./workspace-backup-copy.js";
|
|
13
12
|
import { escapeAttribute, splitTranscriptAttachments } from "../src/lib/composer-attachments.js";
|
|
14
13
|
import { WORKSPACE_BACKUP_CLIENT_KEYS } from "../shared/workspace-backup-client.js";
|
|
15
14
|
import { ephemeralWorkspaceTokenPath, excludedWorkspaceAuthPath, portableWorkspaceConfig, restoredWorkspaceConfig } from "./workspace-backup-policy.js";
|
|
15
|
+
import { workspaceRestorePart, validWorkspaceRestoreKeep } from "../shared/workspace-backup.js";
|
|
16
16
|
import { privateBotIds, privateBotPath, scrubPrivateMessages } from "./workspace-backup-private.js";
|
|
17
17
|
import { MAX_WORKSPACE_BACKUP_BYTES, passwordKey, readArchive, writeArchive } from "./workspace-backup-archive.js";
|
|
18
18
|
import { SECRET_TOP_LEVEL, secretWorkspacePath, validSecretsBundle } from "./workspace-backup-secrets.js";
|
|
@@ -20,7 +20,6 @@ import { absolutePath, rebaseFields, rebasePath, rebaseTree, reclonableCheckout,
|
|
|
20
20
|
export { MAX_WORKSPACE_BACKUP_BYTES, MAX_WORKSPACE_BACKUP_UPLOAD_BYTES } from "./workspace-backup-archive.js";
|
|
21
21
|
export { privateBotIds, privateBotPath } from "./workspace-backup-private.js";
|
|
22
22
|
export const MAX_WORKSPACE_BACKUP_FILES = 100_000;
|
|
23
|
-
const MAX_METADATA_BYTES = 16 * 1024 ** 2;
|
|
24
23
|
const MAX_REPORTED_PATHS = 200;
|
|
25
24
|
const ID = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
|
|
26
25
|
const EXCLUDED = new Set([
|
|
@@ -32,6 +31,7 @@ const EXCLUDED = new Set([
|
|
|
32
31
|
/** Dependency and build folders a project reinstalls with one command. They
|
|
33
32
|
* hold package-manager symbolic links and can exceed the entry limit on
|
|
34
33
|
* their own, so they are left out at any depth. */
|
|
34
|
+
const ANTIGRAVITY_TOOL_CATALOG = /^providers\/antigravity\/[^/]+\/antigravity-acp\/brain\/[^/]+\/mcp$/;
|
|
35
35
|
const REINSTALLABLE_DIRS = new Set(["node_modules", ".pnpm-store", ".venv", "venv", "__pycache__", ".next", ".turbo", "DerivedData", ".build"]);
|
|
36
36
|
/** Links a running browser creates to mark its profile in use; they point
|
|
37
37
|
* at a process, not at data, and a restored profile must not carry them. */
|
|
@@ -108,35 +108,6 @@ function newJob(dataDir) {
|
|
|
108
108
|
function record(value) {
|
|
109
109
|
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
110
110
|
}
|
|
111
|
-
function entryExists(path) {
|
|
112
|
-
try {
|
|
113
|
-
lstatSync(path);
|
|
114
|
-
return true;
|
|
115
|
-
}
|
|
116
|
-
catch (error) {
|
|
117
|
-
if (error.code === "ENOENT")
|
|
118
|
-
return false;
|
|
119
|
-
throw error;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
function privateJson(path) {
|
|
123
|
-
const fd = openSync(path, constants.O_RDONLY | constants.O_NOFOLLOW);
|
|
124
|
-
try {
|
|
125
|
-
const stat = fstatSync(fd);
|
|
126
|
-
if (!stat.isFile() || stat.size > MAX_METADATA_BYTES)
|
|
127
|
-
throw new Error("Workspace backup metadata is too large or is not a regular file.");
|
|
128
|
-
return JSON.parse(readFileSync(fd, "utf8"));
|
|
129
|
-
}
|
|
130
|
-
finally {
|
|
131
|
-
closeSync(fd);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
function writeJson(path, value) {
|
|
135
|
-
const text = JSON.stringify(value);
|
|
136
|
-
if (Buffer.byteLength(text) > MAX_METADATA_BYTES)
|
|
137
|
-
throw new Error("Workspace backup metadata exceeds the size limit.");
|
|
138
|
-
writeFileAtomic(path, text, { mode: 0o600 });
|
|
139
|
-
}
|
|
140
111
|
function privateMetadata(manifest) {
|
|
141
112
|
return { summary: manifest.summary, clientState: manifest.clientState };
|
|
142
113
|
}
|
|
@@ -326,6 +297,10 @@ export async function createWorkspaceBackup(dataDir, options) {
|
|
|
326
297
|
}
|
|
327
298
|
if ((prefix && REINSTALLABLE_DIRS.has(name) && (stat.isDirectory() || stat.isSymbolicLink())) || (path.startsWith("task-workspaces/") && (name === ".git" || (stat.isDirectory() && /^(?:.+-derived|.+\.xcarchive|dist.*|release)$/.test(name)))))
|
|
328
299
|
continue;
|
|
300
|
+
// Antigravity rewrites one JSON per MCP tool into every session it
|
|
301
|
+
// starts (hundreds each); real session files sit beside them.
|
|
302
|
+
if (stat.isDirectory() && ANTIGRAVITY_TOOL_CATALOG.test(path))
|
|
303
|
+
continue;
|
|
329
304
|
if (stat.isSymbolicLink() && BROWSER_LOCK_LINKS.has(name))
|
|
330
305
|
continue;
|
|
331
306
|
if (stat.isSymbolicLink()) {
|
|
@@ -670,7 +645,9 @@ export function readStagedWorkspaceBackup(dataDir, id) {
|
|
|
670
645
|
const manifest = validateManifest(privateJson(join(directory, "staged", "manifest.json")));
|
|
671
646
|
return { id, ...privateMetadata(manifest) };
|
|
672
647
|
}
|
|
673
|
-
|
|
648
|
+
/** Restores the backup's copy of the chosen parts; `keep` stays as it is here. */
|
|
649
|
+
export function commitPendingWorkspaceRestore(dataDir, id, keep = []) {
|
|
650
|
+
keep = validWorkspaceRestoreKeep(keep);
|
|
674
651
|
const root = backupRoot(dataDir);
|
|
675
652
|
if (existsSync(join(root, "pending-restore.json")))
|
|
676
653
|
throw new Error("A workspace restore is already waiting for restart.");
|
|
@@ -680,8 +657,11 @@ export function commitPendingWorkspaceRestore(dataDir, id) {
|
|
|
680
657
|
const manifest = validateStaged(join(jobPath(dataDir, id), "staged"));
|
|
681
658
|
// Discover adaptation errors before persisting a restart request. A broken
|
|
682
659
|
// legacy transcript or scheduler file must not trap subsequent app boots.
|
|
683
|
-
|
|
684
|
-
|
|
660
|
+
const incoming = new Set(manifest.entries.map((entry) => workspaceRestorePart(entry.path.split("/")[0])));
|
|
661
|
+
if (keep.length && ![...incoming].some((part) => !keep.includes(part)))
|
|
662
|
+
throw new Error("Choose at least one part of this backup to restore.");
|
|
663
|
+
prepareRestore(dataDir, id, manifest, keep);
|
|
664
|
+
writeJson(join(root, "pending-restore.json"), { id, keep });
|
|
685
665
|
return { id, restartRequired: true, summary: metadata.summary };
|
|
686
666
|
}
|
|
687
667
|
export function readPendingWorkspaceRestoreMetadata(dataDir) {
|
|
@@ -777,10 +757,12 @@ function rebaseMessage(message, pairs) {
|
|
|
777
757
|
function pathPairs(dataDir, manifest) {
|
|
778
758
|
return restorePathPairs({ dataDir: manifest.sourceDataDir, home: manifest.sourceHome }, { dataDir: resolve(dataDir), home: homedir() });
|
|
779
759
|
}
|
|
780
|
-
function prepareRestore(dataDir, id, manifest) {
|
|
760
|
+
function prepareRestore(dataDir, id, manifest, keep) {
|
|
781
761
|
assertLocalAuthOutsideSnapshot(dataDir);
|
|
782
762
|
const pairs = pathPairs(dataDir, manifest);
|
|
783
|
-
|
|
763
|
+
// Keeping this computer's credentials makes it an ordinary restore: its
|
|
764
|
+
// own connection settings stay paired with the keys it still has.
|
|
765
|
+
const secrets = manifest.summary.secrets === true && !keep.includes("credentials");
|
|
784
766
|
const job = jobPath(dataDir, id);
|
|
785
767
|
const prepared = join(job, "apply", "data");
|
|
786
768
|
if (existsSync(join(job, "apply")))
|
|
@@ -790,7 +772,8 @@ function prepareRestore(dataDir, id, manifest) {
|
|
|
790
772
|
// recovery. Only this installation copy has paths/scheduling adapted.
|
|
791
773
|
// An archive from a release that exported per-turn hook tokens still
|
|
792
774
|
// restores; the dead tokens themselves are never installed.
|
|
793
|
-
const
|
|
775
|
+
const kept = (path) => keep.includes(workspaceRestorePart(path.split("/")[0]));
|
|
776
|
+
const installed = manifest.entries.filter((entry) => !ephemeralWorkspaceTokenPath(entry.path) && !kept(entry.path));
|
|
794
777
|
for (const entry of installed.filter((entry) => entry.type === "directory"))
|
|
795
778
|
folder(join(prepared, entry.path));
|
|
796
779
|
for (const entry of installed) {
|
|
@@ -801,9 +784,9 @@ function prepareRestore(dataDir, id, manifest) {
|
|
|
801
784
|
// Paths are judged against the copy being installed, as it will be.
|
|
802
785
|
const unresolved = { paths: new Set(), exists: (path) => {
|
|
803
786
|
const inside = relative(resolve(dataDir), path);
|
|
804
|
-
return inside && !inside.startsWith("..") && !isAbsolute(inside) ? entryExists(join(prepared, inside)) : existsSync(path);
|
|
787
|
+
return inside && !inside.startsWith("..") && !isAbsolute(inside) && !kept(inside) ? entryExists(join(prepared, inside)) : existsSync(path);
|
|
805
788
|
} };
|
|
806
|
-
const skippedLinks = restoreLinks(prepared, dataDir, manifest.links ?? [], pairs, unresolved.paths);
|
|
789
|
+
const skippedLinks = restoreLinks(prepared, dataDir, (manifest.links ?? []).filter((link) => !kept(link.path)), pairs, unresolved.paths);
|
|
807
790
|
if (pairs.length)
|
|
808
791
|
rebaseTree(prepared, pairs);
|
|
809
792
|
const changeJson = (name, change) => {
|
|
@@ -833,7 +816,7 @@ function prepareRestore(dataDir, id, manifest) {
|
|
|
833
816
|
// A secrets backup is a clone and brings its own, with every path rebased.
|
|
834
817
|
const oldConfig = join(dataDir, "config.json");
|
|
835
818
|
const newConfig = join(prepared, "config.json");
|
|
836
|
-
if (!secrets && (existsSync(oldConfig) || existsSync(newConfig))) {
|
|
819
|
+
if (!kept("config.json") && !secrets && (existsSync(oldConfig) || existsSync(newConfig))) {
|
|
837
820
|
writeJson(newConfig, restoredWorkspaceConfig(existsSync(newConfig) ? privateJson(newConfig) : {}, existsSync(oldConfig) ? privateJson(oldConfig) : {}));
|
|
838
821
|
}
|
|
839
822
|
changeJson("config.json", (value) => rebaseFields(value, pairs, unresolved));
|
|
@@ -848,9 +831,9 @@ function prepareRestore(dataDir, id, manifest) {
|
|
|
848
831
|
// Browser authentication lives alongside ordinary VM files. Copy only the
|
|
849
832
|
// destination's excluded subtrees into the install copy, never the archive.
|
|
850
833
|
// They then participate in the same top-level swap and crash rollback.
|
|
851
|
-
const browserHomes = ["vm-home"];
|
|
834
|
+
const browserHomes = kept("vm-home") ? [] : ["vm-home"];
|
|
852
835
|
const vmHomes = join(dataDir, "vm-homes");
|
|
853
|
-
if (entryExists(vmHomes)) {
|
|
836
|
+
if (!kept("vm-homes") && entryExists(vmHomes)) {
|
|
854
837
|
if (!lstatSync(vmHomes).isDirectory())
|
|
855
838
|
throw new Error("Stop managed desktops and repair the VM home directory before restoring.");
|
|
856
839
|
for (const name of readdirSync(vmHomes))
|
|
@@ -976,7 +959,7 @@ export function readLastWorkspaceRestore(dataDir) {
|
|
|
976
959
|
throw new Error("Invalid workspace restore receipt.");
|
|
977
960
|
return raw;
|
|
978
961
|
}
|
|
979
|
-
function finishRestore(dataDir, id, consumePending = true) {
|
|
962
|
+
function finishRestore(dataDir, id, consumePending = true, keep = []) {
|
|
980
963
|
const root = backupRoot(dataDir);
|
|
981
964
|
const { summary, clientState } = readStagedWorkspaceBackup(dataDir, id);
|
|
982
965
|
const draftAttachments = clientState["omb-draft-attachments"];
|
|
@@ -992,7 +975,7 @@ function finishRestore(dataDir, id, consumePending = true) {
|
|
|
992
975
|
const unresolvedFile = join(jobPath(dataDir, id), "unresolved.json");
|
|
993
976
|
const listed = existsSync(unresolvedFile) ? privateJson(unresolvedFile) : [];
|
|
994
977
|
const unresolvedPaths = Array.isArray(listed) ? listed.filter((path) => typeof path === "string") : [];
|
|
995
|
-
const result = { restored: true, id, safetyCopyPath: join(root, `safety-${id}`), summary, clientState, unresolvedPaths };
|
|
978
|
+
const result = { restored: true, id, safetyCopyPath: join(root, `safety-${id}`), summary, clientState, unresolvedPaths, keep };
|
|
996
979
|
writeJson(join(root, "last-restore.json"), result);
|
|
997
980
|
if (consumePending)
|
|
998
981
|
rmSync(join(root, "pending-restore.json"), { force: true });
|
|
@@ -1016,25 +999,28 @@ export function applyPendingWorkspaceRestore(dataDir) {
|
|
|
1016
999
|
if (previous.phase === "committed" && existsSync(pendingFile)) {
|
|
1017
1000
|
const pending = privateJson(pendingFile);
|
|
1018
1001
|
if (record(pending) && pending.id === previous.id) {
|
|
1019
|
-
return finishRestore(dataDir, previous.id);
|
|
1002
|
+
return finishRestore(dataDir, previous.id, true, validWorkspaceRestoreKeep(previous.keep));
|
|
1020
1003
|
}
|
|
1021
1004
|
}
|
|
1022
1005
|
}
|
|
1023
1006
|
const pending = readPendingWorkspaceRestoreMetadata(dataDir);
|
|
1024
1007
|
if (!pending)
|
|
1025
1008
|
return { restored: false };
|
|
1009
|
+
const keep = validWorkspaceRestoreKeep(privateJson(pendingFile).keep);
|
|
1010
|
+
// Kept categories never enter the replacement or rollback journal.
|
|
1011
|
+
const kept = (name) => keep.includes(workspaceRestorePart(name));
|
|
1026
1012
|
const staged = join(jobPath(dataDir, pending.id), "staged");
|
|
1027
1013
|
const manifest = validateStaged(staged);
|
|
1028
|
-
const prepared = prepareRestore(dataDir, pending.id, manifest);
|
|
1014
|
+
const prepared = prepareRestore(dataDir, pending.id, manifest, keep);
|
|
1029
1015
|
const safetyCopyPath = join(root, `safety-${pending.id}`);
|
|
1030
1016
|
if (existsSync(safetyCopyPath))
|
|
1031
1017
|
throw new Error("A safety copy already exists for this restore. Original files have not been changed.");
|
|
1032
1018
|
folder(join(safetyCopyPath, "data"));
|
|
1033
|
-
const secrets = manifest.summary.secrets === true;
|
|
1019
|
+
const secrets = manifest.summary.secrets === true && !keep.includes("credentials");
|
|
1034
1020
|
const journal = {
|
|
1035
1021
|
id: pending.id, phase: "applying",
|
|
1036
|
-
existing: readdirSync(dataDir).filter((name) => !preserved(name, secrets)).sort(),
|
|
1037
|
-
incoming: readdirSync(prepared).sort(), secrets,
|
|
1022
|
+
existing: readdirSync(dataDir).filter((name) => !preserved(name, secrets) && !kept(name)).sort(),
|
|
1023
|
+
incoming: readdirSync(prepared).filter((name) => !kept(name)).sort(), secrets, keep,
|
|
1038
1024
|
};
|
|
1039
1025
|
// Top-level source and destination names are checked before recording any
|
|
1040
1026
|
// move; a restored root never traverses an archive-controlled directory.
|
|
@@ -1052,7 +1038,7 @@ export function applyPendingWorkspaceRestore(dataDir) {
|
|
|
1052
1038
|
for (const name of journal.incoming)
|
|
1053
1039
|
if (entryExists(join(prepared, name)))
|
|
1054
1040
|
renameSync(join(prepared, name), join(dataDir, name));
|
|
1055
|
-
finishRestore(dataDir, pending.id, false);
|
|
1041
|
+
finishRestore(dataDir, pending.id, false, keep);
|
|
1056
1042
|
writeJson(journalFile, { ...journal, phase: "committed" });
|
|
1057
1043
|
}
|
|
1058
1044
|
catch (error) {
|
|
@@ -1061,7 +1047,7 @@ export function applyPendingWorkspaceRestore(dataDir) {
|
|
|
1061
1047
|
rmSync(pendingFile, { force: true });
|
|
1062
1048
|
throw new Error("The workspace restore failed and the previous workspace was recovered.", { cause: error });
|
|
1063
1049
|
}
|
|
1064
|
-
return finishRestore(dataDir, pending.id);
|
|
1050
|
+
return finishRestore(dataDir, pending.id, true, keep);
|
|
1065
1051
|
}
|
|
1066
1052
|
/** Delete only an unreferenced upload/export/staging job, never a safety copy
|
|
1067
1053
|
* or a job needed by a pending restore or its latest recovery receipt. */
|
|
@@ -1 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
/** What a restore can bring back separately. Anything not chosen keeps this
|
|
2
|
+
* computer's current copy. Everything not named below is "conversations". */
|
|
3
|
+
export const WORKSPACE_RESTORE_PARTS = ["conversations", "settings", "routines", "credentials", "desktops"];
|
|
4
|
+
const PART_BY_NAME = {
|
|
5
|
+
"config.json": "settings", "webhooks.json": "settings",
|
|
6
|
+
"routines.json": "routines", "calendar-calls.json": "routines",
|
|
7
|
+
"providers": "credentials", "workspace-credentials.json": "credentials", "instance-keys.json": "credentials", "external-runtimes.json": "credentials",
|
|
8
|
+
"vm-home": "desktops", "vm-homes": "desktops",
|
|
9
|
+
};
|
|
10
|
+
/** The part a top-level workspace entry belongs to. */
|
|
11
|
+
export function workspaceRestorePart(name) {
|
|
12
|
+
const key = name.toLowerCase();
|
|
13
|
+
return Object.hasOwn(PART_BY_NAME, key) ? PART_BY_NAME[key] : "conversations";
|
|
14
|
+
}
|
|
15
|
+
export function validWorkspaceRestoreKeep(value) {
|
|
16
|
+
if (value === undefined)
|
|
17
|
+
return [];
|
|
18
|
+
if (!Array.isArray(value) || !value.every((part) => WORKSPACE_RESTORE_PARTS.includes(part)) || new Set(value).size !== value.length)
|
|
19
|
+
throw new Error("Invalid restore choices.");
|
|
20
|
+
if (value.includes("settings") && !value.includes("credentials"))
|
|
21
|
+
throw new Error("Restore app settings with saved credentials, or keep both on this computer.");
|
|
22
|
+
return value;
|
|
23
|
+
}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{U as a,C as n}from"./mermaid.core-DOBTmT-1.js";const t=(r,o)=>a.lang.round(n.parse(r)[o]);export{t as c};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import{c as r,s as e}from"./flowDiagram-KWPJA3E3-BNaAddPG.js";import{_ as a}from"./mermaid.core-DOBTmT-1.js";import"./chunk-5VM5RSS4-DDQZDrcU.js";import"./chunk-XXDRQBXY-B9iYAoH7.js";import"./chunk-WEXAMYUT-NVC6qgIT.js";import"./chunk-GWA4HPMP-BJRJdRRn.js";import"./channel-DmcLphYK.js";import"./index-DmYwoh4R.js";var o=a(t=>`${e(t)}
|
|
2
|
-
.swimlane.cluster:not([data-color-id]) rect {
|
|
3
|
-
stroke: ${t.clusterBorder} !important;
|
|
4
|
-
}
|
|
5
|
-
[data-look="neo"].cluster rect {
|
|
6
|
-
filter: none;
|
|
7
|
-
}
|
|
8
|
-
`,"getStyles"),s=o,u=r({styles:s});export{u as diagram};
|