@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.
Files changed (80) hide show
  1. package/dist/assets/{abnfDiagram-O67JEVCF-BJRKA6IQ.js → abnfDiagram-O67JEVCF-CVenv9f1.js} +1 -1
  2. package/dist/assets/{arc-CZc_uW-u.js → arc-CIRWjkSZ.js} +1 -1
  3. package/dist/assets/{architectureDiagram-NJMV4G6O-DNLaTXeO.js → architectureDiagram-NJMV4G6O-DmIpOaYd.js} +1 -1
  4. package/dist/assets/{blockDiagram-BEXU5L5S-DLXsik0_.js → blockDiagram-BEXU5L5S-BYhb8Ycm.js} +1 -1
  5. package/dist/assets/{c4Diagram-YGBWAQC7-DG6hN1C0.js → c4Diagram-YGBWAQC7-B9rBcCno.js} +1 -1
  6. package/dist/assets/channel-NYf_L8uU.js +1 -0
  7. package/dist/assets/{chunk-2Q5K7J3B-D5Yjh7-1.js → chunk-2Q5K7J3B-CV6TX9gt.js} +1 -1
  8. package/dist/assets/{chunk-3FUC2YCW-Bxyjopy0.js → chunk-3FUC2YCW-DiOotfQU.js} +2 -2
  9. package/dist/assets/{chunk-5VM5RSS4-DDQZDrcU.js → chunk-5VM5RSS4-Br5QWC-1.js} +1 -1
  10. package/dist/assets/{chunk-GTNCS2PH-OwVykJDf.js → chunk-GTNCS2PH-BmvI8RMK.js} +1 -1
  11. package/dist/assets/{chunk-GWA4HPMP-BJRJdRRn.js → chunk-GWA4HPMP-Do93bTCh.js} +1 -1
  12. package/dist/assets/{chunk-JWPE2WC7-D0rQf2t4.js → chunk-JWPE2WC7-qIjG-mTw.js} +1 -1
  13. package/dist/assets/{chunk-NETBCI7D-DbgIhGxq.js → chunk-NETBCI7D-DZFFFHT2.js} +1 -1
  14. package/dist/assets/{chunk-WEXAMYUT-NVC6qgIT.js → chunk-WEXAMYUT-qqsVaC1g.js} +1 -1
  15. package/dist/assets/{chunk-XXDRQBXY-B9iYAoH7.js → chunk-XXDRQBXY-EI-aQ-Wn.js} +1 -1
  16. package/dist/assets/{classDiagram-v2-NBCMYWYE-Cma68soF.js → classDiagram-v2-NBCMYWYE-D9D8dkAx.js} +1 -1
  17. package/dist/assets/{cose-bilkent-JH36ORCC-BrXaARl8.js → cose-bilkent-JH36ORCC-m575JDuA.js} +1 -1
  18. package/dist/assets/{cynefin-OW5HDTMX-DaxVySTi.js → cynefin-OW5HDTMX-BMm2bhgv.js} +1 -1
  19. package/dist/assets/{cynefinDiagram-VND7K2PF-BhqakyPn.js → cynefinDiagram-VND7K2PF-Dl2MlsqG.js} +1 -1
  20. package/dist/assets/{dagre-6A5THRUB-C1GSPYtM.js → dagre-6A5THRUB-Cw8yJ-SY.js} +1 -1
  21. package/dist/assets/{diagram-22UHCM2B-BJ3lUPTt.js → diagram-22UHCM2B-DyY0F1qK.js} +1 -1
  22. package/dist/assets/{diagram-3UASUU5V-B15DdW5N.js → diagram-3UASUU5V-sMOszbgV.js} +1 -1
  23. package/dist/assets/{diagram-ATOU4E4O-CXiw2lST.js → diagram-ATOU4E4O-DPo3fHpo.js} +1 -1
  24. package/dist/assets/{diagram-CDSNMT55-DoqH99bW.js → diagram-CDSNMT55-BAHqm-cq.js} +1 -1
  25. package/dist/assets/{diagram-MLGK6HIB-snN4K-CB.js → diagram-MLGK6HIB-BdI4Tf9M.js} +1 -1
  26. package/dist/assets/{diagram-MPIPVDR6-DgJvwpZO.js → diagram-MPIPVDR6-BxqEl_S5.js} +1 -1
  27. package/dist/assets/{ebnfDiagram-ZINNZB2B-AO646Cux.js → ebnfDiagram-ZINNZB2B-DLJ3VRtx.js} +1 -1
  28. package/dist/assets/{elk-276RUBZZ-BQwiFuXz.js → elk-276RUBZZ-Yhxabhx6.js} +1 -1
  29. package/dist/assets/{erDiagram-OPXOYQCR-B5VI88HR.js → erDiagram-OPXOYQCR-DZ4Es64N.js} +1 -1
  30. package/dist/assets/{flowDiagram-KWPJA3E3-BNaAddPG.js → flowDiagram-KWPJA3E3-E36WtrEY.js} +1 -1
  31. package/dist/assets/{ganttDiagram-FUAMR5RP-C_ZoEfA5.js → ganttDiagram-FUAMR5RP-OpUEVvtU.js} +1 -1
  32. package/dist/assets/{gitGraphDiagram-X574FWY7-xthNWdmM.js → gitGraphDiagram-X574FWY7-DTZFNsL8.js} +1 -1
  33. package/dist/assets/{index-DmYwoh4R.js → index-Bgf1dXAl.js} +133 -133
  34. package/dist/assets/{index-ASohJJer.js → index-Bzph058J.js} +1 -1
  35. package/dist/assets/{infoDiagram-VRGFBTTK-Qhrkz09J.js → infoDiagram-VRGFBTTK-mCP2UtfM.js} +1 -1
  36. package/dist/assets/{ishikawaDiagram-OU5B5YK6-DzU3-GrV.js → ishikawaDiagram-OU5B5YK6-M71dvinX.js} +1 -1
  37. package/dist/assets/{journeyDiagram-ZHPQQLJL-Dif-aG4a.js → journeyDiagram-ZHPQQLJL-B2VdVbYS.js} +1 -1
  38. package/dist/assets/{kanban-definition-PNTS6WVX-NJ0l6rbK.js → kanban-definition-PNTS6WVX-l4HpN_KC.js} +1 -1
  39. package/dist/assets/{linear-DpEaZ_8H.js → linear-CN0tWTVj.js} +1 -1
  40. package/dist/assets/{mermaid.core-DOBTmT-1.js → mermaid.core-DpBToEGQ.js} +5 -5
  41. package/dist/assets/{mindmap-definition-NLK3R4M7-kPRBSQ6K.js → mindmap-definition-NLK3R4M7--DJgZ72R.js} +1 -1
  42. package/dist/assets/{pegDiagram-GJSIUBJH-BgX62j0G.js → pegDiagram-GJSIUBJH-DmTBsA2I.js} +1 -1
  43. package/dist/assets/{pieDiagram-5QR66LMP-DpC0-6hx.js → pieDiagram-5QR66LMP-Cy6JwGMR.js} +1 -1
  44. package/dist/assets/{quadrantDiagram-O4NWA36T-CNrmwxvV.js → quadrantDiagram-O4NWA36T-DjTftbBA.js} +1 -1
  45. package/dist/assets/{railroadDiagram-XR7U4H2S-wl7o4Y2J.js → railroadDiagram-XR7U4H2S-DeKIQoik.js} +1 -1
  46. package/dist/assets/{requirementDiagram-PLB6GJNP-D2qhVvpT.js → requirementDiagram-PLB6GJNP-B02KsDuy.js} +1 -1
  47. package/dist/assets/{sankeyDiagram-IPEJSGJF-DZOSOZWs.js → sankeyDiagram-IPEJSGJF-4RLO5vMI.js} +1 -1
  48. package/dist/assets/{sequenceDiagram-PO4LG4MO-eBogKj3g.js → sequenceDiagram-PO4LG4MO-CcBW737M.js} +1 -1
  49. package/dist/assets/{sizeCapture-INFHLROL-Dp_Vdw0m.js → sizeCapture-INFHLROL-CaLSjl7R.js} +1 -1
  50. package/dist/assets/{stateDiagram-v2-GCMORJYK-K79Em0_p.js → stateDiagram-v2-GCMORJYK-blyzRgvD.js} +1 -1
  51. package/dist/assets/{swimlanes-2SLR337P-ByKYlFa_.js → swimlanes-2SLR337P-BIi-tuCD.js} +1 -1
  52. package/dist/assets/swimlanesDiagram-TC7HE7FX-DWtkSjpb.js +8 -0
  53. package/dist/assets/{timeline-definition-EJHVYXUP-CzeMeYU0.js → timeline-definition-EJHVYXUP-oNE7PiRv.js} +1 -1
  54. package/dist/assets/{usecaseDiagram-POWQR4AR-uQjp5Yz3.js → usecaseDiagram-POWQR4AR-DzmCYS5I.js} +1 -1
  55. package/dist/assets/{vennDiagram-UO4OBE2U-De8_78dQ.js → vennDiagram-UO4OBE2U-T51P02io.js} +1 -1
  56. package/dist/assets/{wardleyDiagram-VNRHLVJA-Dk_VO2LR.js → wardleyDiagram-VNRHLVJA-1GfD8Fys.js} +1 -1
  57. package/dist/assets/{xychartDiagram-PMCCYNJV-DMx2Y7qW.js → xychartDiagram-PMCCYNJV-BhNMe0uk.js} +1 -1
  58. package/dist/handbook/atomic-handbook.html +1 -5
  59. package/dist/index.html +1 -1
  60. package/dist-server/index.js +1087 -988
  61. package/dist-server/openmausbot.js +224 -176
  62. package/dist-server/pair-cli.js +224 -176
  63. package/dist-server/server/computer-stop-names.js +35 -0
  64. package/dist-server/server/connection-cap-failover.js +1 -1
  65. package/dist-server/server/drivers/claude-auth-status.js +25 -0
  66. package/dist-server/server/drivers/claude.js +6 -5
  67. package/dist-server/server/drivers/retry.js +1 -0
  68. package/dist-server/server/engine-failover.js +14 -5
  69. package/dist-server/server/engine-failure.js +4 -4
  70. package/dist-server/server/index.js +13 -14
  71. package/dist-server/server/injected-model-rest.js +9 -0
  72. package/dist-server/server/model-access-refusal.js +62 -0
  73. package/dist-server/server/workspace-backup-copy.js +34 -1
  74. package/dist-server/server/workspace-backup-http.js +8 -5
  75. package/dist-server/server/workspace-backup-secrets.js +2 -2
  76. package/dist-server/server/workspace-backup.js +38 -52
  77. package/dist-server/shared/workspace-backup.js +23 -1
  78. package/package.json +1 -1
  79. package/dist/assets/channel-DmcLphYK.js +0 -1
  80. package/dist/assets/swimlanesDiagram-TC7HE7FX-BnN5frkm.js +0 -8
@@ -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
- export function commitPendingWorkspaceRestore(dataDir, id) {
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
- prepareRestore(dataDir, id, manifest);
684
- writeJson(join(root, "pending-restore.json"), { id });
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
- const secrets = manifest.summary.secrets === true;
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 installed = manifest.entries.filter((entry) => !ephemeralWorkspaceTokenPath(entry.path));
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
- export {};
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@chibitek/chibi",
3
- "version": "0.1.183",
3
+ "version": "0.1.185",
4
4
  "description": "Atomic by Chibitek: run your AI team's server anywhere and pair your devices to it",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -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};