@narumitw/pi-sync 0.57.9 → 0.57.11
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/CHANGELOG.md +14 -0
- package/README.md +7 -1
- package/dist/chunks/{agent-candidate-GNEYR225.ts → agent-candidate-OCDPRI5G.ts} +12 -9
- package/dist/chunks/{agent-plan-3L7CRFDM.ts → agent-plan-P5B5RGZ7.ts} +22 -18
- package/dist/chunks/{agent-plan-3L7CRFDM.ts.map → agent-plan-P5B5RGZ7.ts.map} +1 -1
- package/dist/chunks/{agent-refusal-retry-RPTMUQXK.ts → agent-refusal-retry-476YGNU5.ts} +11 -8
- package/dist/chunks/{agent-refusal-retry-RPTMUQXK.ts.map → agent-refusal-retry-476YGNU5.ts.map} +1 -1
- package/dist/chunks/{agent-store-55CZOCPX.ts → agent-store-RJSMNOYP.ts} +12 -11
- package/dist/chunks/{agent-store-55CZOCPX.ts.map → agent-store-RJSMNOYP.ts.map} +1 -1
- package/dist/chunks/agent-sync-EUK2CPSS.ts +22 -0
- package/dist/chunks/{chunk-U3XRI2HF.ts → chunk-3IYAPMST.ts} +11 -11
- package/dist/chunks/{chunk-B4QZBDBT.ts → chunk-45COPAK7.ts} +10 -3
- package/dist/chunks/chunk-45COPAK7.ts.map +7 -0
- package/dist/chunks/chunk-5SFMBY5P.ts +26 -0
- package/dist/chunks/chunk-5SFMBY5P.ts.map +7 -0
- package/dist/chunks/{chunk-ED3TYIVW.ts → chunk-5TSCBBPP.ts} +5 -5
- package/dist/chunks/{chunk-5QAE3G3K.ts → chunk-67INJPKR.ts} +6 -6
- package/dist/chunks/{chunk-IWZH5KYS.ts → chunk-6LD5KX55.ts} +10 -10
- package/dist/chunks/{chunk-AAEEHR7H.ts → chunk-6O3EDBRL.ts} +2 -2
- package/dist/chunks/{chunk-CRKTAPSL.ts → chunk-7A35ZAVO.ts} +333 -237
- package/dist/chunks/chunk-7A35ZAVO.ts.map +7 -0
- package/dist/chunks/{chunk-6FVVRTL5.ts → chunk-7OLLPPLU.ts} +77 -63
- package/dist/chunks/chunk-7OLLPPLU.ts.map +7 -0
- package/dist/chunks/{chunk-PQW6GS4J.ts → chunk-7ZIYU5QS.ts} +12 -10
- package/dist/chunks/{chunk-PQW6GS4J.ts.map → chunk-7ZIYU5QS.ts.map} +1 -1
- package/dist/chunks/{chunk-S7QS4AWK.ts → chunk-AKMV47YC.ts} +5 -5
- package/dist/chunks/chunk-AR2DGDUI.ts +55 -0
- package/dist/chunks/chunk-AR2DGDUI.ts.map +7 -0
- package/dist/chunks/{chunk-GNH73BJ5.ts → chunk-BEST45H2.ts} +7 -7
- package/dist/chunks/chunk-CBLTWXAU.ts +114 -0
- package/dist/chunks/chunk-CBLTWXAU.ts.map +7 -0
- package/dist/chunks/{chunk-GP5DU62N.ts → chunk-CPT2BN6N.ts} +2 -2
- package/dist/chunks/{chunk-UPNVIUBN.ts → chunk-DN4IA7MR.ts} +6 -6
- package/dist/chunks/{chunk-PG7NMFP2.ts → chunk-DRTC4PKM.ts} +8 -8
- package/dist/chunks/chunk-ESKOPQVB.ts +348 -0
- package/dist/chunks/chunk-ESKOPQVB.ts.map +7 -0
- package/dist/chunks/{chunk-MKKF4IMY.ts → chunk-F7E3VFXU.ts} +5 -5
- package/dist/chunks/{chunk-HUZ5CR4W.ts → chunk-FHE2DCA2.ts} +3 -52
- package/dist/chunks/chunk-FHE2DCA2.ts.map +7 -0
- package/dist/chunks/{chunk-UBV24CG4.ts → chunk-FLHCOJCD.ts} +3 -3
- package/dist/chunks/chunk-GNYGNHFF.ts +27 -0
- package/dist/chunks/chunk-GNYGNHFF.ts.map +7 -0
- package/dist/chunks/chunk-KYTT7KV4.ts +319 -0
- package/dist/chunks/chunk-KYTT7KV4.ts.map +7 -0
- package/dist/chunks/{chunk-A6HU4ERM.ts → chunk-MKSMJPVA.ts} +6 -23
- package/dist/chunks/chunk-MKSMJPVA.ts.map +7 -0
- package/dist/chunks/{chunk-ORGBI36T.ts → chunk-OJARL2TG.ts} +4 -4
- package/dist/chunks/{chunk-JCH3VXIO.ts → chunk-OKPPZA4D.ts} +150 -91
- package/dist/chunks/chunk-OKPPZA4D.ts.map +7 -0
- package/dist/chunks/{chunk-QO333NM4.ts → chunk-OVBAW7KV.ts} +180 -133
- package/dist/chunks/chunk-OVBAW7KV.ts.map +7 -0
- package/dist/chunks/{chunk-GSNPASKB.ts → chunk-Q23JJW7E.ts} +6 -6
- package/dist/chunks/{chunk-YK52VDXG.ts → chunk-TIMWN2RH.ts} +10 -8
- package/dist/chunks/{chunk-YK52VDXG.ts.map → chunk-TIMWN2RH.ts.map} +1 -1
- package/dist/chunks/{chunk-UOHR7LRO.ts → chunk-TZC7GDJE.ts} +10 -22
- package/dist/chunks/chunk-TZC7GDJE.ts.map +7 -0
- package/dist/chunks/chunk-X7R6DCVF.ts +28 -0
- package/dist/chunks/chunk-X7R6DCVF.ts.map +7 -0
- package/dist/chunks/{chunk-76NB4R7U.ts → chunk-XJHQPB3E.ts} +2 -2
- package/dist/chunks/{chunk-BDB4IDM3.ts → chunk-Y4UVXOLQ.ts} +8 -6
- package/dist/chunks/{chunk-BDB4IDM3.ts.map → chunk-Y4UVXOLQ.ts.map} +1 -1
- package/dist/chunks/{chunk-P7DD5PWZ.ts → chunk-ZDDBZH72.ts} +3 -3
- package/dist/chunks/command-handler-F2E7A5T5.ts +548 -0
- package/dist/chunks/command-handler-F2E7A5T5.ts.map +7 -0
- package/dist/chunks/{config-KGIYTTXQ.ts → config-HYG7G5EM.ts} +7 -6
- package/dist/chunks/{conflict-artifacts-FXFIIBCB.ts → conflict-artifacts-J6WSDCWP.ts} +13 -9
- package/dist/chunks/{conflict-review-3X37QEIT.ts → conflict-review-2QMO2K6Q.ts} +31 -25
- package/dist/chunks/{conflict-review-3X37QEIT.ts.map → conflict-review-2QMO2K6Q.ts.map} +1 -1
- package/dist/chunks/{continuous-record-SQJ47CXN.ts → continuous-record-AH7JGYKM.ts} +8 -7
- package/dist/chunks/{continuous-sync-Q6QUD6TY.ts → continuous-sync-VRMXCA5X.ts} +33 -28
- package/dist/chunks/{continuous-sync-Q6QUD6TY.ts.map → continuous-sync-VRMXCA5X.ts.map} +1 -1
- package/dist/chunks/{file-selection-3JJYOVNR.ts → file-selection-IELTXSGZ.ts} +11 -10
- package/dist/chunks/{file-selection-3JJYOVNR.ts.map → file-selection-IELTXSGZ.ts.map} +1 -1
- package/dist/chunks/{git-backend-NYKSG5X6.ts → git-backend-KHD36W27.ts} +15 -12
- package/dist/chunks/{git-backend-NYKSG5X6.ts.map → git-backend-KHD36W27.ts.map} +1 -1
- package/dist/chunks/{local-fields-6DGYOOIK.ts → local-fields-JEKAPZKD.ts} +9 -5
- package/dist/chunks/manager-result-dispatcher-6W52NM7F.ts +32 -0
- package/dist/chunks/{manager-ui-ZH6DEC2G.ts → manager-ui-LM7DSJ2Y.ts} +124 -67
- package/dist/chunks/manager-ui-LM7DSJ2Y.ts.map +7 -0
- package/dist/chunks/{merge-baseline-store-RFCAH7KL.ts → merge-baseline-store-65GKUMXI.ts} +6 -5
- package/dist/chunks/remote-selection-ui-TD4C4W3J.ts +31 -0
- package/dist/chunks/{s3-backend-F7PR5FB3.ts → s3-backend-L24UZ6IK.ts} +24 -18
- package/dist/chunks/s3-backend-L24UZ6IK.ts.map +7 -0
- package/dist/chunks/{setup-switch-E7PHKI6J.ts → setup-switch-PIPXYPCW.ts} +6 -7
- package/dist/chunks/{setup-wizard-OVHZYXNW.ts → setup-wizard-RR5U3SUB.ts} +8 -9
- package/dist/chunks/{setup-wizard-OVHZYXNW.ts.map → setup-wizard-RR5U3SUB.ts.map} +1 -1
- package/dist/chunks/{snapshot-THS5EY2L.ts → snapshot-RGNDYT6A.ts} +10 -6
- package/dist/chunks/snapshot-transaction-26BQO36S.ts +24 -0
- package/dist/chunks/sync-inspection-MOMLGUTD.ts +25 -0
- package/dist/chunks/sync-inspection-MOMLGUTD.ts.map +7 -0
- package/dist/chunks/{sync-operations-Y72GNIQ2.ts → sync-operations-CV3TULLD.ts} +66 -57
- package/dist/chunks/{sync-operations-Y72GNIQ2.ts.map → sync-operations-CV3TULLD.ts.map} +1 -1
- package/dist/chunks/{sync-state-CFL4RRRB.ts → sync-state-7L4NT7W2.ts} +8 -5
- package/dist/chunks/sync-state-7L4NT7W2.ts.map +7 -0
- package/dist/chunks/{webdav-backend-TGFUH3SF.ts → webdav-backend-3ZCACILP.ts} +15 -12
- package/dist/chunks/{webdav-backend-TGFUH3SF.ts.map → webdav-backend-3ZCACILP.ts.map} +1 -1
- package/dist/index.ts +54 -537
- package/dist/index.ts.map +3 -3
- package/package.json +2 -2
- package/skills/configure-pi-sync/references/configuration.md +8 -1
- package/src/backends/s3/s3-client.ts +8 -1
- package/src/commands/command-execution.ts +8 -3
- package/src/paths.ts +6 -1
- package/src/settings/config-file.ts +205 -118
- package/src/settings/config.ts +2 -2
- package/src/settings/settings-management.ts +15 -1
- package/src/settings/settings-store.ts +0 -14
- package/src/settings/settings-validation.ts +1 -1
- package/src/snapshot/session-paths.ts +15 -2
- package/src/snapshot/snapshot-mutation-queues.ts +142 -0
- package/src/snapshot/snapshot-transaction-directory.ts +16 -0
- package/src/snapshot/snapshot-transaction.ts +123 -137
- package/src/sync/automatic-sync.ts +12 -6
- package/src/sync/local-field-policy.ts +29 -0
- package/src/sync/local-fields.ts +3 -29
- package/src/sync/merge-apply.ts +6 -0
- package/src/sync/mutation-owner.ts +22 -0
- package/src/sync/startup-check.ts +3 -2
- package/src/sync/sync-loaders.ts +4 -0
- package/src/sync/sync-local.ts +2 -19
- package/src/sync-extension.ts +7 -2
- package/src/ui/cancellable-operation.ts +36 -13
- package/src/ui/manager-state.ts +3 -1
- package/src/ui/manager-ui.ts +76 -24
- package/src/ui/remote-selection-ui.ts +131 -82
- package/src/ui/settings-ui.ts +2 -1
- package/dist/chunks/chunk-6FVVRTL5.ts.map +0 -7
- package/dist/chunks/chunk-A6HU4ERM.ts.map +0 -7
- package/dist/chunks/chunk-B4QZBDBT.ts.map +0 -7
- package/dist/chunks/chunk-CRKTAPSL.ts.map +0 -7
- package/dist/chunks/chunk-HUZ5CR4W.ts.map +0 -7
- package/dist/chunks/chunk-JCH3VXIO.ts.map +0 -7
- package/dist/chunks/chunk-QO333NM4.ts.map +0 -7
- package/dist/chunks/chunk-QOFMXPM5.ts +0 -735
- package/dist/chunks/chunk-QOFMXPM5.ts.map +0 -7
- package/dist/chunks/chunk-UOHR7LRO.ts.map +0 -7
- package/dist/chunks/manager-result-dispatcher-HOCM2GDA.ts +0 -24
- package/dist/chunks/manager-ui-ZH6DEC2G.ts.map +0 -7
- package/dist/chunks/remote-selection-ui-YFPGYGNE.ts +0 -23
- package/dist/chunks/s3-backend-F7PR5FB3.ts.map +0 -7
- package/dist/chunks/sync-inspection-J25EEKZK.ts +0 -21
- /package/dist/chunks/{agent-candidate-GNEYR225.ts.map → agent-candidate-OCDPRI5G.ts.map} +0 -0
- /package/dist/chunks/{config-KGIYTTXQ.ts.map → agent-sync-EUK2CPSS.ts.map} +0 -0
- /package/dist/chunks/{chunk-U3XRI2HF.ts.map → chunk-3IYAPMST.ts.map} +0 -0
- /package/dist/chunks/{chunk-ED3TYIVW.ts.map → chunk-5TSCBBPP.ts.map} +0 -0
- /package/dist/chunks/{chunk-5QAE3G3K.ts.map → chunk-67INJPKR.ts.map} +0 -0
- /package/dist/chunks/{chunk-IWZH5KYS.ts.map → chunk-6LD5KX55.ts.map} +0 -0
- /package/dist/chunks/{chunk-AAEEHR7H.ts.map → chunk-6O3EDBRL.ts.map} +0 -0
- /package/dist/chunks/{chunk-S7QS4AWK.ts.map → chunk-AKMV47YC.ts.map} +0 -0
- /package/dist/chunks/{chunk-GNH73BJ5.ts.map → chunk-BEST45H2.ts.map} +0 -0
- /package/dist/chunks/{chunk-GP5DU62N.ts.map → chunk-CPT2BN6N.ts.map} +0 -0
- /package/dist/chunks/{chunk-UPNVIUBN.ts.map → chunk-DN4IA7MR.ts.map} +0 -0
- /package/dist/chunks/{chunk-PG7NMFP2.ts.map → chunk-DRTC4PKM.ts.map} +0 -0
- /package/dist/chunks/{chunk-MKKF4IMY.ts.map → chunk-F7E3VFXU.ts.map} +0 -0
- /package/dist/chunks/{chunk-UBV24CG4.ts.map → chunk-FLHCOJCD.ts.map} +0 -0
- /package/dist/chunks/{chunk-ORGBI36T.ts.map → chunk-OJARL2TG.ts.map} +0 -0
- /package/dist/chunks/{chunk-GSNPASKB.ts.map → chunk-Q23JJW7E.ts.map} +0 -0
- /package/dist/chunks/{chunk-76NB4R7U.ts.map → chunk-XJHQPB3E.ts.map} +0 -0
- /package/dist/chunks/{chunk-P7DD5PWZ.ts.map → chunk-ZDDBZH72.ts.map} +0 -0
- /package/dist/chunks/{conflict-artifacts-FXFIIBCB.ts.map → config-HYG7G5EM.ts.map} +0 -0
- /package/dist/chunks/{continuous-record-SQJ47CXN.ts.map → conflict-artifacts-J6WSDCWP.ts.map} +0 -0
- /package/dist/chunks/{local-fields-6DGYOOIK.ts.map → continuous-record-AH7JGYKM.ts.map} +0 -0
- /package/dist/chunks/{manager-result-dispatcher-HOCM2GDA.ts.map → local-fields-JEKAPZKD.ts.map} +0 -0
- /package/dist/chunks/{merge-baseline-store-RFCAH7KL.ts.map → manager-result-dispatcher-6W52NM7F.ts.map} +0 -0
- /package/dist/chunks/{remote-selection-ui-YFPGYGNE.ts.map → merge-baseline-store-65GKUMXI.ts.map} +0 -0
- /package/dist/chunks/{setup-switch-E7PHKI6J.ts.map → remote-selection-ui-TD4C4W3J.ts.map} +0 -0
- /package/dist/chunks/{snapshot-THS5EY2L.ts.map → setup-switch-PIPXYPCW.ts.map} +0 -0
- /package/dist/chunks/{sync-inspection-J25EEKZK.ts.map → snapshot-RGNDYT6A.ts.map} +0 -0
- /package/dist/chunks/{sync-state-CFL4RRRB.ts.map → snapshot-transaction-26BQO36S.ts.map} +0 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// @generated by scripts/build-runtime.mjs; do not edit.
|
|
2
|
+
// @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
|
|
3
|
+
|
|
4
|
+
// src/snapshot/snapshot-paths.ts
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
function expandHome(value) {
|
|
7
|
+
if (value === "~") return process.env.HOME ?? value;
|
|
8
|
+
if (value.startsWith("~/")) return path.join(process.env.HOME ?? "~", value.slice(2));
|
|
9
|
+
return value;
|
|
10
|
+
}
|
|
11
|
+
function sessionStorageRoot(root, configuredSessionDir2) {
|
|
12
|
+
return configuredSessionDir2 ? path.resolve(expandHome(configuredSessionDir2)) : path.resolve(root, "sessions");
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// src/snapshot/session-paths.ts
|
|
16
|
+
import fs from "node:fs/promises";
|
|
17
|
+
import os from "node:os";
|
|
18
|
+
import path2 from "node:path";
|
|
19
|
+
import { getAgentDir } from "@earendil-works/pi-coding-agent";
|
|
20
|
+
function sessionDirFromContext(ctx) {
|
|
21
|
+
const manager = ctx.sessionManager;
|
|
22
|
+
const usesDefaultSessionDir = manager.usesDefaultSessionDir;
|
|
23
|
+
if (typeof usesDefaultSessionDir === "function" && usesDefaultSessionDir.call(manager)) {
|
|
24
|
+
return void 0;
|
|
25
|
+
}
|
|
26
|
+
const getSessionDir = manager.getSessionDir;
|
|
27
|
+
return typeof getSessionDir === "function" ? getSessionDir.call(manager) : void 0;
|
|
28
|
+
}
|
|
29
|
+
async function configuredSessionDir() {
|
|
30
|
+
let content;
|
|
31
|
+
try {
|
|
32
|
+
content = await fs.readFile(path2.join(agentDir(), "settings.json"), "utf8");
|
|
33
|
+
} catch (error) {
|
|
34
|
+
if (error.code === "ENOENT") return void 0;
|
|
35
|
+
throw error;
|
|
36
|
+
}
|
|
37
|
+
let settings;
|
|
38
|
+
try {
|
|
39
|
+
settings = JSON.parse(content.replace(/^\uFEFF/u, ""));
|
|
40
|
+
} catch {
|
|
41
|
+
throw new SyntaxError("Pi settings.json cannot be parsed; repair the file before syncing.");
|
|
42
|
+
}
|
|
43
|
+
return settings?.sessionDir ? expandSessionDir(settings.sessionDir) : void 0;
|
|
44
|
+
}
|
|
45
|
+
async function effectiveSessionRoot(ctx) {
|
|
46
|
+
return path2.resolve(sessionStorageRoot(agentDir(), sessionDirFromContext(ctx) ?? await configuredSessionDir()));
|
|
47
|
+
}
|
|
48
|
+
async function sessionDirForApply(ctx, snapshot) {
|
|
49
|
+
const contextSessionDir = sessionDirFromContext(ctx);
|
|
50
|
+
const localSessionDir = await configuredSessionDir();
|
|
51
|
+
if (contextSessionDir && path2.resolve(contextSessionDir) !== path2.resolve(localSessionDir ?? "")) {
|
|
52
|
+
return contextSessionDir;
|
|
53
|
+
}
|
|
54
|
+
return sessionDirFromSnapshot(snapshot) ?? contextSessionDir;
|
|
55
|
+
}
|
|
56
|
+
function requireStableMergeSessionRoot(before, after) {
|
|
57
|
+
const root = agentDir();
|
|
58
|
+
if (path2.resolve(sessionStorageRoot(root, sessionDirFromSnapshot(before))) !== path2.resolve(sessionStorageRoot(root, sessionDirFromSnapshot(after)))) {
|
|
59
|
+
throw new Error(
|
|
60
|
+
"Merged transfer changes the session root; no local apply or baseline acceptance is allowed. Review /sync diff and choose an explicit push or pull direction."
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function sessionDirFromSnapshot(snapshot) {
|
|
65
|
+
const settingsFile = snapshot.files.find((file) => file.path === "settings.json");
|
|
66
|
+
if (!settingsFile) return void 0;
|
|
67
|
+
let settings;
|
|
68
|
+
try {
|
|
69
|
+
settings = JSON.parse(
|
|
70
|
+
new TextDecoder("utf-8", { fatal: true }).decode(
|
|
71
|
+
decodeBase64Strict(settingsFile.contentBase64, settingsFile.path)
|
|
72
|
+
)
|
|
73
|
+
);
|
|
74
|
+
} catch {
|
|
75
|
+
throw new Error("Merged settings cannot be parsed; review a directional recovery.");
|
|
76
|
+
}
|
|
77
|
+
if (!settings || typeof settings !== "object" || Array.isArray(settings))
|
|
78
|
+
throw new Error("Merged settings must be a JSON object; review a directional recovery.");
|
|
79
|
+
const sessionDir = settings.sessionDir;
|
|
80
|
+
if (sessionDir !== void 0 && typeof sessionDir !== "string")
|
|
81
|
+
throw new Error("Merged sessionDir must be a string; review a directional recovery.");
|
|
82
|
+
return sessionDir ? expandSessionDir(sessionDir) : void 0;
|
|
83
|
+
}
|
|
84
|
+
function decodeBase64Strict(value, filePath) {
|
|
85
|
+
if (!/^[A-Za-z0-9+/]*={0,2}$/.test(value) || value.length % 4 !== 0) {
|
|
86
|
+
throw new Error(`Invalid base64 content in snapshot file: ${filePath}`);
|
|
87
|
+
}
|
|
88
|
+
return Buffer.from(value, "base64");
|
|
89
|
+
}
|
|
90
|
+
function agentDir() {
|
|
91
|
+
return getAgentDir();
|
|
92
|
+
}
|
|
93
|
+
function expandSessionDir(value) {
|
|
94
|
+
return value === "~" || value.startsWith("~/") ? path2.join(os.homedir(), value.slice(2)) : value;
|
|
95
|
+
}
|
|
96
|
+
function snapshotOptionsForContext(ctx, config) {
|
|
97
|
+
return {
|
|
98
|
+
include: config.include,
|
|
99
|
+
sessionDir: sessionDirFromContext(ctx)
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export {
|
|
104
|
+
sessionStorageRoot,
|
|
105
|
+
sessionDirFromContext,
|
|
106
|
+
configuredSessionDir,
|
|
107
|
+
effectiveSessionRoot,
|
|
108
|
+
sessionDirForApply,
|
|
109
|
+
requireStableMergeSessionRoot,
|
|
110
|
+
agentDir,
|
|
111
|
+
expandSessionDir,
|
|
112
|
+
snapshotOptionsForContext
|
|
113
|
+
};
|
|
114
|
+
//# sourceMappingURL=chunk-CBLTWXAU.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/snapshot/snapshot-paths.ts", "../../src/snapshot/session-paths.ts"],
|
|
4
|
+
"sourcesContent": ["import path from \"node:path\";\n\nfunction expandHome(value: string) {\n if (value === \"~\") return process.env.HOME ?? value;\n if (value.startsWith(\"~/\")) return path.join(process.env.HOME ?? \"~\", value.slice(2));\n return value;\n}\n\nexport function sessionStorageRoot(root: string, configuredSessionDir?: string) {\n return configuredSessionDir ? path.resolve(expandHome(configuredSessionDir)) : path.resolve(root, \"sessions\");\n}\n", "import fs from \"node:fs/promises\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport { type ExtensionCommandContext, type ExtensionContext, getAgentDir } from \"@earendil-works/pi-coding-agent\";\nimport type { AnySyncConfig } from \"../settings/settings-types.js\";\nimport { sessionStorageRoot } from \"./snapshot-paths.js\";\nimport type { Snapshot, SnapshotOptions } from \"./snapshot-types.js\";\n\nexport function sessionDirFromContext(ctx: ExtensionCommandContext | ExtensionContext) {\n const manager = ctx.sessionManager as typeof ctx.sessionManager & {\n usesDefaultSessionDir?: () => boolean;\n };\n const usesDefaultSessionDir = manager.usesDefaultSessionDir;\n if (typeof usesDefaultSessionDir === \"function\" && usesDefaultSessionDir.call(manager)) {\n return undefined;\n }\n const getSessionDir = manager.getSessionDir;\n return typeof getSessionDir === \"function\" ? (getSessionDir.call(manager) as string | undefined) : undefined;\n}\n\nexport async function configuredSessionDir() {\n let content: string;\n try {\n content = await fs.readFile(path.join(agentDir(), \"settings.json\"), \"utf8\");\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code === \"ENOENT\") return undefined;\n throw error;\n }\n let settings: { sessionDir?: string } | null;\n try {\n // Pi accepts a leading UTF-8 BOM in its settings file; snapshot bytes stay unchanged.\n settings = JSON.parse(content.replace(/^\\uFEFF/u, \"\")) as typeof settings;\n } catch {\n throw new SyntaxError(\"Pi settings.json cannot be parsed; repair the file before syncing.\");\n }\n return settings?.sessionDir ? expandSessionDir(settings.sessionDir) : undefined;\n}\n\nexport async function effectiveSessionRoot(ctx: ExtensionCommandContext | ExtensionContext) {\n return path.resolve(sessionStorageRoot(agentDir(), sessionDirFromContext(ctx) ?? (await configuredSessionDir())));\n}\n\nexport async function sessionDirForApply(ctx: ExtensionCommandContext | ExtensionContext, snapshot: Snapshot) {\n const contextSessionDir = sessionDirFromContext(ctx);\n const localSessionDir = await configuredSessionDir();\n if (contextSessionDir && path.resolve(contextSessionDir) !== path.resolve(localSessionDir ?? \"\")) {\n return contextSessionDir;\n }\n return sessionDirFromSnapshot(snapshot) ?? contextSessionDir;\n}\n\n/** Hash-only merge plans cannot describe installation into a different session root. */\nexport function requireStableMergeSessionRoot(before: Snapshot, after: Snapshot) {\n const root = agentDir();\n if (\n path.resolve(sessionStorageRoot(root, sessionDirFromSnapshot(before))) !==\n path.resolve(sessionStorageRoot(root, sessionDirFromSnapshot(after)))\n ) {\n throw new Error(\n \"Merged transfer changes the session root; no local apply or baseline acceptance is allowed. Review /sync diff and choose an explicit push or pull direction.\",\n );\n }\n}\n\nfunction sessionDirFromSnapshot(snapshot: Snapshot) {\n const settingsFile = snapshot.files.find((file) => file.path === \"settings.json\");\n if (!settingsFile) return undefined;\n let settings: unknown;\n try {\n settings = JSON.parse(\n new TextDecoder(\"utf-8\", { fatal: true }).decode(\n decodeBase64Strict(settingsFile.contentBase64, settingsFile.path),\n ),\n );\n } catch {\n // JSON parser errors can quote private settings values; never surface their payload.\n throw new Error(\"Merged settings cannot be parsed; review a directional recovery.\");\n }\n if (!settings || typeof settings !== \"object\" || Array.isArray(settings))\n throw new Error(\"Merged settings must be a JSON object; review a directional recovery.\");\n const sessionDir = (settings as { sessionDir?: unknown }).sessionDir;\n if (sessionDir !== undefined && typeof sessionDir !== \"string\")\n throw new Error(\"Merged sessionDir must be a string; review a directional recovery.\");\n return sessionDir ? expandSessionDir(sessionDir) : undefined;\n}\n\nfunction decodeBase64Strict(value: string, filePath: string) {\n if (!/^[A-Za-z0-9+/]*={0,2}$/.test(value) || value.length % 4 !== 0) {\n throw new Error(`Invalid base64 content in snapshot file: ${filePath}`);\n }\n return Buffer.from(value, \"base64\");\n}\n\nexport function agentDir() {\n return getAgentDir();\n}\n\nexport function expandSessionDir(value: string) {\n return value === \"~\" || value.startsWith(\"~/\") ? path.join(os.homedir(), value.slice(2)) : value;\n}\n\nexport function snapshotOptionsForContext(\n ctx: ExtensionCommandContext | ExtensionContext,\n config: AnySyncConfig,\n): SnapshotOptions {\n return {\n include: config.include,\n sessionDir: sessionDirFromContext(ctx),\n };\n}\n"],
|
|
5
|
+
"mappings": ";;;;AAAA,OAAO,UAAU;AAEjB,SAAS,WAAW,OAAe;AACjC,MAAI,UAAU,IAAK,QAAO,QAAQ,IAAI,QAAQ;AAC9C,MAAI,MAAM,WAAW,IAAI,EAAG,QAAO,KAAK,KAAK,QAAQ,IAAI,QAAQ,KAAK,MAAM,MAAM,CAAC,CAAC;AACpF,SAAO;AACT;AAEO,SAAS,mBAAmB,MAAcA,uBAA+B;AAC9E,SAAOA,wBAAuB,KAAK,QAAQ,WAAWA,qBAAoB,CAAC,IAAI,KAAK,QAAQ,MAAM,UAAU;AAC9G;;;ACVA,OAAO,QAAQ;AACf,OAAO,QAAQ;AACf,OAAOC,WAAU;AACjB,SAA8D,mBAAmB;AAK1E,SAAS,sBAAsB,KAAiD;AACrF,QAAM,UAAU,IAAI;AAGpB,QAAM,wBAAwB,QAAQ;AACtC,MAAI,OAAO,0BAA0B,cAAc,sBAAsB,KAAK,OAAO,GAAG;AACtF,WAAO;AAAA,EACT;AACA,QAAM,gBAAgB,QAAQ;AAC9B,SAAO,OAAO,kBAAkB,aAAc,cAAc,KAAK,OAAO,IAA2B;AACrG;AAEA,eAAsB,uBAAuB;AAC3C,MAAI;AACJ,MAAI;AACF,cAAU,MAAM,GAAG,SAASC,MAAK,KAAK,SAAS,GAAG,eAAe,GAAG,MAAM;AAAA,EAC5E,SAAS,OAAO;AACd,QAAK,MAAgC,SAAS,SAAU,QAAO;AAC/D,UAAM;AAAA,EACR;AACA,MAAI;AACJ,MAAI;AAEF,eAAW,KAAK,MAAM,QAAQ,QAAQ,YAAY,EAAE,CAAC;AAAA,EACvD,QAAQ;AACN,UAAM,IAAI,YAAY,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IAAI,MAAM,oEAAoE;AACtF,SAAO,aAAa,iBAAiB,UAAU,IAAI;AACrD;AAEA,SAAS,mBAAmB,OAAe,UAAkB;AAC3D,MAAI,CAAC,yBAAyB,KAAK,KAAK,KAAK,MAAM,SAAS,MAAM,GAAG;AACnE,UAAM,IAAI,MAAM,4CAA4C,QAAQ,EAAE;AAAA,EACxE;AACA,SAAO,OAAO,KAAK,OAAO,QAAQ;AACpC;AAEO,SAAS,WAAW;AACzB,SAAO,YAAY;AACrB;AAEO,SAAS,iBAAiB,OAAe;AAC9C,SAAO,UAAU,OAAO,MAAM,WAAW,IAAI,IAAIA,MAAK,KAAK,GAAG,QAAQ,GAAG,MAAM,MAAM,CAAC,CAAC,IAAI;AAC7F;AAEO,SAAS,0BACd,KACA,QACiB;AACjB,SAAO;AAAA,IACL,SAAS,OAAO;AAAA,IAChB,YAAY,sBAAsB,GAAG;AAAA,EACvC;AACF;",
|
|
6
|
+
"names": ["configuredSessionDir", "path", "path"]
|
|
7
|
+
}
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
syncConfigReviewIdentity,
|
|
17
17
|
syncSetupReviewIdentity,
|
|
18
18
|
updateLocalConfig
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-OVBAW7KV.ts";
|
|
20
20
|
import {
|
|
21
21
|
throwIfAborted
|
|
22
22
|
} from "./chunk-PWMWOJP4.ts";
|
|
@@ -124,4 +124,4 @@ export {
|
|
|
124
124
|
saveOnSwitch,
|
|
125
125
|
useSyncSetup
|
|
126
126
|
};
|
|
127
|
-
//# sourceMappingURL=chunk-
|
|
127
|
+
//# sourceMappingURL=chunk-CPT2BN6N.ts.map
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
// @generated by scripts/build-runtime.mjs; do not edit.
|
|
2
2
|
// @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
|
|
3
|
+
import {
|
|
4
|
+
readJsonIfExists,
|
|
5
|
+
writeJson
|
|
6
|
+
} from "./chunk-AR2DGDUI.ts";
|
|
3
7
|
import {
|
|
4
8
|
stateDir
|
|
5
9
|
} from "./chunk-SWRVXVFD.ts";
|
|
6
10
|
import {
|
|
7
11
|
backendIdentityCoordinates
|
|
8
12
|
} from "./chunk-2JZFHNLM.ts";
|
|
9
|
-
import {
|
|
10
|
-
readJsonIfExists,
|
|
11
|
-
writeJson
|
|
12
|
-
} from "./chunk-HUZ5CR4W.ts";
|
|
13
13
|
|
|
14
14
|
// src/state/sync-state-store.ts
|
|
15
15
|
import { createHash } from "node:crypto";
|
|
@@ -30,7 +30,7 @@ async function writeStateForConfig(config, state, snapshot, validate = () => {
|
|
|
30
30
|
}) {
|
|
31
31
|
validate();
|
|
32
32
|
if (snapshot) {
|
|
33
|
-
const { stageMergeBaseline } = await import("./merge-baseline-store-
|
|
33
|
+
const { stageMergeBaseline } = await import("./merge-baseline-store-65GKUMXI.ts");
|
|
34
34
|
validate();
|
|
35
35
|
await stageMergeBaseline(config, snapshot, state);
|
|
36
36
|
validate();
|
|
@@ -58,4 +58,4 @@ export {
|
|
|
58
58
|
lockPath,
|
|
59
59
|
ensureStateDir
|
|
60
60
|
};
|
|
61
|
-
//# sourceMappingURL=chunk-
|
|
61
|
+
//# sourceMappingURL=chunk-DN4IA7MR.ts.map
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
// @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
|
|
3
3
|
import {
|
|
4
4
|
withLock
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import {
|
|
7
|
-
ContinuousError
|
|
8
|
-
} from "./chunk-DT7M4VQS.ts";
|
|
5
|
+
} from "./chunk-6O3EDBRL.ts";
|
|
9
6
|
import {
|
|
10
7
|
ensureStateDir
|
|
11
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-DN4IA7MR.ts";
|
|
9
|
+
import {
|
|
10
|
+
writeJson
|
|
11
|
+
} from "./chunk-AR2DGDUI.ts";
|
|
12
12
|
import {
|
|
13
13
|
LOCKFILE_FS_ADAPTER,
|
|
14
14
|
stateDir,
|
|
@@ -18,8 +18,8 @@ import {
|
|
|
18
18
|
backendIdentityCoordinates
|
|
19
19
|
} from "./chunk-2JZFHNLM.ts";
|
|
20
20
|
import {
|
|
21
|
-
|
|
22
|
-
} from "./chunk-
|
|
21
|
+
ContinuousError
|
|
22
|
+
} from "./chunk-DT7M4VQS.ts";
|
|
23
23
|
|
|
24
24
|
// src/sync/continuous-lease.ts
|
|
25
25
|
import { randomUUID } from "node:crypto";
|
|
@@ -412,4 +412,4 @@ export {
|
|
|
412
412
|
reserveContinuousRequest,
|
|
413
413
|
continuousStatusLines
|
|
414
414
|
};
|
|
415
|
-
//# sourceMappingURL=chunk-
|
|
415
|
+
//# sourceMappingURL=chunk-DRTC4PKM.ts.map
|
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
// @generated by scripts/build-runtime.mjs; do not edit.
|
|
2
|
+
// @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
|
|
3
|
+
import {
|
|
4
|
+
DEFAULT_SYNC_INCLUDE,
|
|
5
|
+
canonicalSnapshotPathForConfig,
|
|
6
|
+
customIncludePathsByLower,
|
|
7
|
+
includeFromSelectionConfig,
|
|
8
|
+
isConfiguredSnapshotPath,
|
|
9
|
+
isPreservableUnmanagedSnapshotPath,
|
|
10
|
+
normalizeExtraFiles,
|
|
11
|
+
normalizeSyncFiles,
|
|
12
|
+
selectionForSnapshot,
|
|
13
|
+
snapshotSelectionInclude,
|
|
14
|
+
syncIncludeSelection
|
|
15
|
+
} from "./chunk-KYTT7KV4.ts";
|
|
16
|
+
import {
|
|
17
|
+
agentDir,
|
|
18
|
+
configuredSessionDir,
|
|
19
|
+
sessionStorageRoot
|
|
20
|
+
} from "./chunk-CBLTWXAU.ts";
|
|
21
|
+
import {
|
|
22
|
+
isDeniedPath,
|
|
23
|
+
posixJoin,
|
|
24
|
+
safeJoin,
|
|
25
|
+
toPosix
|
|
26
|
+
} from "./chunk-FHE2DCA2.ts";
|
|
27
|
+
|
|
28
|
+
// src/snapshot/snapshot.ts
|
|
29
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
30
|
+
import fs from "node:fs/promises";
|
|
31
|
+
import os from "node:os";
|
|
32
|
+
import path from "node:path";
|
|
33
|
+
var VERSION = 1;
|
|
34
|
+
var TOP_LEVEL_FILES = DEFAULT_SYNC_INCLUDE.filter((name) => name.includes("."));
|
|
35
|
+
var TOP_LEVEL_DIRS = new Set(DEFAULT_SYNC_INCLUDE.filter((name) => !name.includes(".")));
|
|
36
|
+
var SECRET_PATTERNS = [
|
|
37
|
+
/AWS_SECRET_ACCESS_KEY\s*[=:]\s*['"]?[A-Za-z0-9/+]{35,}/i,
|
|
38
|
+
/(ANTHROPIC|OPENAI|GEMINI|GOOGLE|FIRECRAWL|GITHUB|CLOUDFLARE|R2|S3)_[A-Z0-9_]*(KEY|TOKEN|SECRET)\s*[=:]\s*['"]?[^\s'"]{12,}/i,
|
|
39
|
+
/sk-ant-[A-Za-z0-9_-]{20,}/,
|
|
40
|
+
/sk-[A-Za-z0-9]{20,}/,
|
|
41
|
+
/gh[pousr]_[A-Za-z0-9_]{20,}/
|
|
42
|
+
];
|
|
43
|
+
function selectTopLevelFileEntry(entries, fileName) {
|
|
44
|
+
const exact = entries.find((entry) => entry.isFile() && entry.name === fileName);
|
|
45
|
+
if (exact) return exact;
|
|
46
|
+
const lower = fileName.toLowerCase();
|
|
47
|
+
return entries.filter((entry) => entry.isFile() && entry.name.toLowerCase() === lower).sort((left, right) => left.name.localeCompare(right.name))[0];
|
|
48
|
+
}
|
|
49
|
+
function sha256(value) {
|
|
50
|
+
return createHash("sha256").update(value).digest("hex");
|
|
51
|
+
}
|
|
52
|
+
function isSafeSnapshotPath(relativePath) {
|
|
53
|
+
if (relativePath.includes("\\")) return false;
|
|
54
|
+
const normalized = toPosix(relativePath);
|
|
55
|
+
return Boolean(normalized) && normalized !== "." && normalized !== ".." && !normalized.startsWith("../") && !path.posix.isAbsolute(normalized) && path.posix.normalize(normalized) === normalized && !isDeniedPath(normalized);
|
|
56
|
+
}
|
|
57
|
+
function snapshotsMatch(left, right) {
|
|
58
|
+
const leftHashes = new Map(left.files.map((file) => [file.path, file.sha256]));
|
|
59
|
+
const rightHashes = new Map(right.files.map((file) => [file.path, file.sha256]));
|
|
60
|
+
return left.syncSessions === right.syncSessions && sameOptionalInclude(snapshotSelectionInclude(left), snapshotSelectionInclude(right)) && leftHashes.size === rightHashes.size && [...leftHashes].every(([filePath, hash]) => rightHashes.get(filePath) === hash);
|
|
61
|
+
}
|
|
62
|
+
function snapshotId() {
|
|
63
|
+
return `${(/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-")}-${randomUUID().slice(0, 8)}`;
|
|
64
|
+
}
|
|
65
|
+
function regenerateSnapshotIdentity(snapshot) {
|
|
66
|
+
return {
|
|
67
|
+
...snapshot,
|
|
68
|
+
id: snapshotId(),
|
|
69
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
70
|
+
machine: os.hostname()
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
async function createSnapshot(profile, options = {}) {
|
|
74
|
+
options.signal?.throwIfAborted();
|
|
75
|
+
const include = effectiveInclude(options);
|
|
76
|
+
const syncSessions = include.includes("sessions");
|
|
77
|
+
const sessionDir = options.sessionDir ?? await configuredSessionDir();
|
|
78
|
+
options.signal?.throwIfAborted();
|
|
79
|
+
const files = await collectFiles(agentDir(), { include, sessionDir, signal: options.signal });
|
|
80
|
+
options.signal?.throwIfAborted();
|
|
81
|
+
return {
|
|
82
|
+
version: VERSION,
|
|
83
|
+
id: snapshotId(),
|
|
84
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
85
|
+
machine: os.hostname(),
|
|
86
|
+
profile,
|
|
87
|
+
syncSessions,
|
|
88
|
+
selection: selectionForSnapshot(include),
|
|
89
|
+
files
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function effectiveInclude(options) {
|
|
93
|
+
if (options.include) return options.include;
|
|
94
|
+
return [
|
|
95
|
+
...normalizeSyncFiles(options.syncFiles),
|
|
96
|
+
...normalizeExtraFiles(options.extraFiles),
|
|
97
|
+
...options.syncSessions ? ["sessions"] : []
|
|
98
|
+
];
|
|
99
|
+
}
|
|
100
|
+
async function collectFiles(root, options = {}) {
|
|
101
|
+
const signal = options.signal;
|
|
102
|
+
signal?.throwIfAborted();
|
|
103
|
+
const results = [];
|
|
104
|
+
const entries = await fs.readdir(root, { withFileTypes: true });
|
|
105
|
+
signal?.throwIfAborted();
|
|
106
|
+
const selection = syncIncludeSelection(effectiveInclude(options));
|
|
107
|
+
const selectedFiles = new Set(selection.builtIns);
|
|
108
|
+
for (const entry of entries) {
|
|
109
|
+
if (entry.isDirectory() && TOP_LEVEL_DIRS.has(entry.name) && selectedFiles.has(entry.name)) {
|
|
110
|
+
await collectDirectory(results, root, entry.name, { signal });
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
for (const fileName of TOP_LEVEL_FILES) {
|
|
114
|
+
if (!selectedFiles.has(fileName)) continue;
|
|
115
|
+
const entry = selectTopLevelFileEntry(entries, fileName);
|
|
116
|
+
if (entry) await addFile(results, root, entry.name, fileName, signal);
|
|
117
|
+
}
|
|
118
|
+
for (const relativePath of selection.custom) {
|
|
119
|
+
await collectIncludedPath(results, root, relativePath, signal);
|
|
120
|
+
}
|
|
121
|
+
if (selection.sessions) {
|
|
122
|
+
try {
|
|
123
|
+
await collectDirectory(results, sessionStorageRoot(root, options.sessionDir), "", {
|
|
124
|
+
sessionsOnly: true,
|
|
125
|
+
virtualPrefix: "sessions",
|
|
126
|
+
signal
|
|
127
|
+
});
|
|
128
|
+
} catch (error) {
|
|
129
|
+
if (error.code !== "ENOENT") throw error;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
signal?.throwIfAborted();
|
|
133
|
+
return results.sort((left, right) => left.path.localeCompare(right.path));
|
|
134
|
+
}
|
|
135
|
+
async function collectIncludedPath(results, root, relativePath, signal) {
|
|
136
|
+
signal?.throwIfAborted();
|
|
137
|
+
const absolutePath = safeJoin(root, relativePath);
|
|
138
|
+
try {
|
|
139
|
+
const stat = await fs.lstat(absolutePath);
|
|
140
|
+
signal?.throwIfAborted();
|
|
141
|
+
if (stat.isFile()) await addFile(results, root, relativePath, relativePath, signal);
|
|
142
|
+
else if (stat.isDirectory()) await collectDirectory(results, root, relativePath, { signal });
|
|
143
|
+
} catch (error) {
|
|
144
|
+
if (error.code !== "ENOENT") throw error;
|
|
145
|
+
if (!relativePath.includes("/")) {
|
|
146
|
+
const entries = await fs.readdir(root, { withFileTypes: true });
|
|
147
|
+
signal?.throwIfAborted();
|
|
148
|
+
const entry = selectTopLevelFileEntry(entries, relativePath);
|
|
149
|
+
if (entry) await addFile(results, root, entry.name, relativePath, signal);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
async function collectDirectory(results, root, relativeDirectory, options = {}) {
|
|
154
|
+
options.signal?.throwIfAborted();
|
|
155
|
+
const absoluteDirectory = path.join(root, relativeDirectory);
|
|
156
|
+
for (const entry of await fs.readdir(absoluteDirectory, { withFileTypes: true })) {
|
|
157
|
+
options.signal?.throwIfAborted();
|
|
158
|
+
const relativePath = relativeDirectory ? posixJoin(relativeDirectory, entry.name) : entry.name;
|
|
159
|
+
const snapshotPath = options.virtualPrefix ? posixJoin(options.virtualPrefix, relativePath) : relativePath;
|
|
160
|
+
if (isDeniedPath(snapshotPath)) continue;
|
|
161
|
+
if (entry.isDirectory()) {
|
|
162
|
+
await collectDirectory(results, root, relativePath, options);
|
|
163
|
+
} else if (entry.isFile() && (!options.sessionsOnly || isSessionFilePath(snapshotPath))) {
|
|
164
|
+
await addFile(results, root, relativePath, snapshotPath, options.signal);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
async function addFile(results, root, relativePath, snapshotPath = relativePath, signal) {
|
|
169
|
+
signal?.throwIfAborted();
|
|
170
|
+
if (!isSafeSnapshotPath(snapshotPath)) return;
|
|
171
|
+
const absolutePath = safeJoin(root, relativePath);
|
|
172
|
+
const content = await fs.readFile(absolutePath, { signal });
|
|
173
|
+
signal?.throwIfAborted();
|
|
174
|
+
results.push({
|
|
175
|
+
path: snapshotPath,
|
|
176
|
+
contentBase64: content.toString("base64"),
|
|
177
|
+
sha256: sha256(content)
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
function isSessionPath(relativePath) {
|
|
181
|
+
return toPosix(relativePath).startsWith("sessions/");
|
|
182
|
+
}
|
|
183
|
+
function isSessionFilePath(relativePath) {
|
|
184
|
+
const normalized = toPosix(relativePath);
|
|
185
|
+
return isSessionPath(normalized) && normalized.endsWith(".jsonl");
|
|
186
|
+
}
|
|
187
|
+
function sessionSnapshotPathFromAbsolute(sessionFile, configuredSessionDir2) {
|
|
188
|
+
const relativePath = toPosix(path.relative(sessionStorageRoot(agentDir(), configuredSessionDir2), sessionFile));
|
|
189
|
+
if (!relativePath || relativePath.startsWith("../") || path.posix.isAbsolute(relativePath)) {
|
|
190
|
+
return void 0;
|
|
191
|
+
}
|
|
192
|
+
const snapshotPath = posixJoin("sessions", relativePath);
|
|
193
|
+
return isSessionFilePath(snapshotPath) ? snapshotPath : void 0;
|
|
194
|
+
}
|
|
195
|
+
function snapshotTarget(root, relativePath, configuredSessionDir2) {
|
|
196
|
+
if (isSessionPath(relativePath)) {
|
|
197
|
+
return safeJoin(sessionStorageRoot(root, configuredSessionDir2), relativePath.slice("sessions/".length));
|
|
198
|
+
}
|
|
199
|
+
return safeJoin(root, relativePath);
|
|
200
|
+
}
|
|
201
|
+
function snapshotIncludesSessions(snapshot) {
|
|
202
|
+
return snapshot.syncSessions === true || snapshotSelectionInclude(snapshot)?.includes("sessions") === true || snapshot.files.some((file) => isSessionPath(file.path));
|
|
203
|
+
}
|
|
204
|
+
function filterSnapshotForConfigPolicy(snapshot, config, options = {}) {
|
|
205
|
+
const include = includeFromSelectionConfig(config);
|
|
206
|
+
const includePaths = customIncludePathsByLower(include);
|
|
207
|
+
const filtered = {
|
|
208
|
+
...snapshot,
|
|
209
|
+
syncSessions: include.includes("sessions") ? snapshot.syncSessions : false,
|
|
210
|
+
selection: selectionForSnapshot(include),
|
|
211
|
+
files: canonicalizeSnapshotFilesForConfig(snapshot.files, config, includePaths)
|
|
212
|
+
};
|
|
213
|
+
if (!options.regenerateId || snapshotsMatch(snapshot, filtered)) return filtered;
|
|
214
|
+
return {
|
|
215
|
+
...filtered,
|
|
216
|
+
id: snapshotId(),
|
|
217
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
218
|
+
machine: os.hostname()
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
function canonicalizeSnapshotFilesForConfig(files, config, includePaths) {
|
|
222
|
+
const configuredFiles = [];
|
|
223
|
+
const extraCandidates = /* @__PURE__ */ new Map();
|
|
224
|
+
for (const file of files) {
|
|
225
|
+
const normalized = toPosix(file.path);
|
|
226
|
+
if (!isSafeSnapshotPath(file.path) || !isConfiguredSnapshotPath(normalized, config)) {
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
if (normalized.includes("/")) {
|
|
230
|
+
configuredFiles.push(normalized === file.path ? file : { ...file, path: normalized });
|
|
231
|
+
continue;
|
|
232
|
+
}
|
|
233
|
+
const topLevelPath = canonicalSnapshotPathForConfig(normalized, includePaths);
|
|
234
|
+
const candidate = {
|
|
235
|
+
exact: normalized === topLevelPath,
|
|
236
|
+
file: { ...file, path: topLevelPath },
|
|
237
|
+
originalPath: normalized
|
|
238
|
+
};
|
|
239
|
+
const current = extraCandidates.get(topLevelPath.toLowerCase());
|
|
240
|
+
if (!current || isPreferredExtraCandidate(candidate, current)) {
|
|
241
|
+
extraCandidates.set(topLevelPath.toLowerCase(), candidate);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
return [...configuredFiles, ...[...extraCandidates.values()].map((candidate) => candidate.file)].sort(
|
|
245
|
+
(left, right) => left.path.localeCompare(right.path)
|
|
246
|
+
);
|
|
247
|
+
}
|
|
248
|
+
function isPreferredExtraCandidate(left, right) {
|
|
249
|
+
if (left.exact !== right.exact) return left.exact;
|
|
250
|
+
return left.originalPath.localeCompare(right.originalPath) < 0;
|
|
251
|
+
}
|
|
252
|
+
function snapshotWithoutSessions(snapshot) {
|
|
253
|
+
const files = snapshot.files.filter((file) => !isSessionPath(file.path));
|
|
254
|
+
const include = snapshotSelectionInclude(snapshot)?.filter((item) => item !== "sessions");
|
|
255
|
+
if (files.length === snapshot.files.length && snapshot.syncSessions !== true && include?.length === snapshot.selection?.include.length) {
|
|
256
|
+
return snapshot;
|
|
257
|
+
}
|
|
258
|
+
return {
|
|
259
|
+
...snapshot,
|
|
260
|
+
id: snapshotId(),
|
|
261
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
262
|
+
machine: os.hostname(),
|
|
263
|
+
syncSessions: false,
|
|
264
|
+
...include ? { selection: selectionForSnapshot(include) } : {},
|
|
265
|
+
files
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
function scanSnapshot(snapshot) {
|
|
269
|
+
const findings = [];
|
|
270
|
+
for (const file of snapshot.files) {
|
|
271
|
+
const content = Buffer.from(file.contentBase64, "base64");
|
|
272
|
+
if (content.includes(0)) continue;
|
|
273
|
+
const text = content.toString("utf8");
|
|
274
|
+
for (const pattern of SECRET_PATTERNS) {
|
|
275
|
+
if (pattern.test(text)) {
|
|
276
|
+
findings.push(file.path);
|
|
277
|
+
break;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
return findings;
|
|
282
|
+
}
|
|
283
|
+
function mergeRemotePreservedFiles(local, remote, config) {
|
|
284
|
+
const localPathNames = new Set(local.files.map((file) => file.path.toLowerCase()));
|
|
285
|
+
const preservedPathNames = /* @__PURE__ */ new Set();
|
|
286
|
+
const preserved = remote.files.filter((file) => {
|
|
287
|
+
const normalized = toPosix(file.path);
|
|
288
|
+
const lower = normalized.toLowerCase();
|
|
289
|
+
if (localPathNames.has(lower) || preservedPathNames.has(lower) || !isSafeSnapshotPath(file.path) || isConfiguredSnapshotPath(normalized, config) || !isPreservableUnmanagedSnapshotPath(normalized)) {
|
|
290
|
+
return false;
|
|
291
|
+
}
|
|
292
|
+
preservedPathNames.add(lower);
|
|
293
|
+
return true;
|
|
294
|
+
});
|
|
295
|
+
if (preserved.length === 0) return local;
|
|
296
|
+
return {
|
|
297
|
+
...local,
|
|
298
|
+
id: snapshotId(),
|
|
299
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
300
|
+
machine: os.hostname(),
|
|
301
|
+
syncSessions: snapshotIncludesSessions(local) || snapshotIncludesSessions(remote),
|
|
302
|
+
files: [...local.files, ...preserved].sort((left, right) => left.path.localeCompare(right.path))
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
function mergeRemoteSessionFiles(local, remote) {
|
|
306
|
+
const remoteSessions = remote.files.filter((file) => {
|
|
307
|
+
const normalized = toPosix(file.path);
|
|
308
|
+
return isSessionFilePath(normalized) && isSafeSnapshotPath(file.path);
|
|
309
|
+
});
|
|
310
|
+
if (remoteSessions.length === 0 && !snapshotIncludesSessions(remote)) return local;
|
|
311
|
+
const localInclude = snapshotSelectionInclude(local);
|
|
312
|
+
return {
|
|
313
|
+
...local,
|
|
314
|
+
id: snapshotId(),
|
|
315
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
316
|
+
machine: os.hostname(),
|
|
317
|
+
syncSessions: true,
|
|
318
|
+
...localInclude ? {
|
|
319
|
+
selection: selectionForSnapshot(
|
|
320
|
+
localInclude.includes("sessions") ? localInclude : [...localInclude, "sessions"]
|
|
321
|
+
)
|
|
322
|
+
} : {},
|
|
323
|
+
files: [...local.files.filter((file) => !isSessionPath(file.path)), ...remoteSessions].sort(
|
|
324
|
+
(left, right) => left.path.localeCompare(right.path)
|
|
325
|
+
)
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
function sameOptionalInclude(left, right) {
|
|
329
|
+
if (!left || !right) return left === right;
|
|
330
|
+
return left.length === right.length && left.every((item, index) => item === right[index]);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
export {
|
|
334
|
+
regenerateSnapshotIdentity,
|
|
335
|
+
createSnapshot,
|
|
336
|
+
collectFiles,
|
|
337
|
+
isSessionPath,
|
|
338
|
+
isSessionFilePath,
|
|
339
|
+
sessionSnapshotPathFromAbsolute,
|
|
340
|
+
snapshotTarget,
|
|
341
|
+
snapshotIncludesSessions,
|
|
342
|
+
filterSnapshotForConfigPolicy,
|
|
343
|
+
snapshotWithoutSessions,
|
|
344
|
+
scanSnapshot,
|
|
345
|
+
mergeRemotePreservedFiles,
|
|
346
|
+
mergeRemoteSessionFiles
|
|
347
|
+
};
|
|
348
|
+
//# sourceMappingURL=chunk-ESKOPQVB.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/snapshot/snapshot.ts"],
|
|
4
|
+
"sourcesContent": ["import { createHash, randomUUID } from \"node:crypto\";\nimport type { Dirent } from \"node:fs\";\nimport fs from \"node:fs/promises\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport { isDeniedPath, posixJoin, safeJoin, toPosix } from \"../paths.js\";\nimport { agentDir, configuredSessionDir } from \"./session-paths.js\";\nimport { sessionStorageRoot } from \"./snapshot-paths.js\";\n\nexport { isDeniedPath } from \"../paths.js\";\nexport { sessionStorageRoot } from \"./snapshot-paths.js\";\n\nimport {\n canonicalSnapshotPathForConfig,\n customIncludePathsByLower,\n DEFAULT_SYNC_INCLUDE,\n includeFromSelectionConfig,\n isConfiguredSnapshotPath,\n isPreservableUnmanagedSnapshotPath,\n normalizeExtraFiles,\n normalizeSyncFiles,\n type SyncSelectionConfig,\n selectionForSnapshot,\n snapshotSelectionInclude,\n syncIncludeSelection,\n} from \"../sync/sync-policy.js\";\nimport type { Snapshot, SnapshotFile, SnapshotOptions } from \"./snapshot-types.js\";\n\nexport { canonicalSnapshotPathForConfig, isConfiguredSnapshotPath } from \"../sync/sync-policy.js\";\n\nconst VERSION = 1;\nconst TOP_LEVEL_FILES: readonly string[] = DEFAULT_SYNC_INCLUDE.filter((name) => name.includes(\".\"));\nconst TOP_LEVEL_DIRS = new Set<string>(DEFAULT_SYNC_INCLUDE.filter((name) => !name.includes(\".\")));\nconst SECRET_PATTERNS = [\n /AWS_SECRET_ACCESS_KEY\\s*[=:]\\s*['\"]?[A-Za-z0-9/+]{35,}/i,\n /(ANTHROPIC|OPENAI|GEMINI|GOOGLE|FIRECRAWL|GITHUB|CLOUDFLARE|R2|S3)_[A-Z0-9_]*(KEY|TOKEN|SECRET)\\s*[=:]\\s*['\"]?[^\\s'\"]{12,}/i,\n /sk-ant-[A-Za-z0-9_-]{20,}/,\n /sk-[A-Za-z0-9]{20,}/,\n /gh[pousr]_[A-Za-z0-9_]{20,}/,\n];\n\nfunction selectTopLevelFileEntry(entries: Dirent[], fileName: string) {\n const exact = entries.find((entry) => entry.isFile() && entry.name === fileName);\n if (exact) return exact;\n const lower = fileName.toLowerCase();\n return entries\n .filter((entry) => entry.isFile() && entry.name.toLowerCase() === lower)\n .sort((left, right) => left.name.localeCompare(right.name))[0];\n}\n\nfunction sha256(value: Buffer) {\n return createHash(\"sha256\").update(value).digest(\"hex\");\n}\n\nfunction isSafeSnapshotPath(relativePath: string) {\n if (relativePath.includes(\"\\\\\")) return false;\n const normalized = toPosix(relativePath);\n return (\n Boolean(normalized) &&\n normalized !== \".\" &&\n normalized !== \"..\" &&\n !normalized.startsWith(\"../\") &&\n !path.posix.isAbsolute(normalized) &&\n path.posix.normalize(normalized) === normalized &&\n !isDeniedPath(normalized)\n );\n}\n\nfunction snapshotsMatch(left: Snapshot, right: Snapshot) {\n const leftHashes = new Map(left.files.map((file) => [file.path, file.sha256]));\n const rightHashes = new Map(right.files.map((file) => [file.path, file.sha256]));\n return (\n left.syncSessions === right.syncSessions &&\n sameOptionalInclude(snapshotSelectionInclude(left), snapshotSelectionInclude(right)) &&\n leftHashes.size === rightHashes.size &&\n [...leftHashes].every(([filePath, hash]) => rightHashes.get(filePath) === hash)\n );\n}\n\nfunction snapshotId() {\n return `${new Date().toISOString().replace(/[:.]/g, \"-\")}-${randomUUID().slice(0, 8)}`;\n}\n\nexport function regenerateSnapshotIdentity(snapshot: Snapshot): Snapshot {\n return {\n ...snapshot,\n id: snapshotId(),\n createdAt: new Date().toISOString(),\n machine: os.hostname(),\n };\n}\n\nexport async function createSnapshot(profile: string, options: SnapshotOptions = {}): Promise<Snapshot> {\n options.signal?.throwIfAborted();\n const include = effectiveInclude(options);\n const syncSessions = include.includes(\"sessions\");\n const sessionDir = options.sessionDir ?? (await configuredSessionDir());\n options.signal?.throwIfAborted();\n const files = await collectFiles(agentDir(), { include, sessionDir, signal: options.signal });\n options.signal?.throwIfAborted();\n return {\n version: VERSION,\n id: snapshotId(),\n createdAt: new Date().toISOString(),\n machine: os.hostname(),\n profile,\n syncSessions,\n selection: selectionForSnapshot(include),\n files,\n };\n}\n\nfunction effectiveInclude(options: SnapshotOptions) {\n if (options.include) return options.include;\n return [\n ...normalizeSyncFiles(options.syncFiles),\n ...normalizeExtraFiles(options.extraFiles),\n ...(options.syncSessions ? [\"sessions\"] : []),\n ];\n}\n\nexport async function collectFiles(root: string, options: SnapshotOptions = {}): Promise<SnapshotFile[]> {\n const signal = options.signal;\n signal?.throwIfAborted();\n const results: SnapshotFile[] = [];\n const entries = await fs.readdir(root, { withFileTypes: true });\n signal?.throwIfAborted();\n const selection = syncIncludeSelection(effectiveInclude(options));\n const selectedFiles = new Set<string>(selection.builtIns);\n for (const entry of entries) {\n if (entry.isDirectory() && TOP_LEVEL_DIRS.has(entry.name) && selectedFiles.has(entry.name)) {\n await collectDirectory(results, root, entry.name, { signal });\n }\n }\n for (const fileName of TOP_LEVEL_FILES) {\n if (!selectedFiles.has(fileName)) continue;\n const entry = selectTopLevelFileEntry(entries, fileName);\n if (entry) await addFile(results, root, entry.name, fileName, signal);\n }\n for (const relativePath of selection.custom) {\n await collectIncludedPath(results, root, relativePath, signal);\n }\n if (selection.sessions) {\n try {\n await collectDirectory(results, sessionStorageRoot(root, options.sessionDir), \"\", {\n sessionsOnly: true,\n virtualPrefix: \"sessions\",\n signal,\n });\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") throw error;\n }\n }\n signal?.throwIfAborted();\n return results.sort((left, right) => left.path.localeCompare(right.path));\n}\n\nasync function collectIncludedPath(results: SnapshotFile[], root: string, relativePath: string, signal?: AbortSignal) {\n signal?.throwIfAborted();\n const absolutePath = safeJoin(root, relativePath);\n try {\n const stat = await fs.lstat(absolutePath);\n signal?.throwIfAborted();\n if (stat.isFile()) await addFile(results, root, relativePath, relativePath, signal);\n else if (stat.isDirectory()) await collectDirectory(results, root, relativePath, { signal });\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") throw error;\n if (!relativePath.includes(\"/\")) {\n const entries = await fs.readdir(root, { withFileTypes: true });\n signal?.throwIfAborted();\n const entry = selectTopLevelFileEntry(entries, relativePath);\n if (entry) await addFile(results, root, entry.name, relativePath, signal);\n }\n }\n}\n\nasync function collectDirectory(\n results: SnapshotFile[],\n root: string,\n relativeDirectory: string,\n options: { sessionsOnly?: boolean; virtualPrefix?: string; signal?: AbortSignal } = {},\n) {\n options.signal?.throwIfAborted();\n const absoluteDirectory = path.join(root, relativeDirectory);\n for (const entry of await fs.readdir(absoluteDirectory, { withFileTypes: true })) {\n options.signal?.throwIfAborted();\n const relativePath = relativeDirectory ? posixJoin(relativeDirectory, entry.name) : entry.name;\n const snapshotPath = options.virtualPrefix ? posixJoin(options.virtualPrefix, relativePath) : relativePath;\n if (isDeniedPath(snapshotPath)) continue;\n if (entry.isDirectory()) {\n await collectDirectory(results, root, relativePath, options);\n } else if (entry.isFile() && (!options.sessionsOnly || isSessionFilePath(snapshotPath))) {\n await addFile(results, root, relativePath, snapshotPath, options.signal);\n }\n }\n}\n\nasync function addFile(\n results: SnapshotFile[],\n root: string,\n relativePath: string,\n snapshotPath = relativePath,\n signal?: AbortSignal,\n) {\n signal?.throwIfAborted();\n if (!isSafeSnapshotPath(snapshotPath)) return;\n const absolutePath = safeJoin(root, relativePath);\n const content = await fs.readFile(absolutePath, { signal });\n signal?.throwIfAborted();\n results.push({\n path: snapshotPath,\n contentBase64: content.toString(\"base64\"),\n sha256: sha256(content),\n });\n}\n\nexport function isSessionPath(relativePath: string) {\n return toPosix(relativePath).startsWith(\"sessions/\");\n}\n\nexport function isSessionFilePath(relativePath: string) {\n const normalized = toPosix(relativePath);\n return isSessionPath(normalized) && normalized.endsWith(\".jsonl\");\n}\n\nexport function sessionSnapshotPathFromAbsolute(sessionFile: string, configuredSessionDir?: string) {\n const relativePath = toPosix(path.relative(sessionStorageRoot(agentDir(), configuredSessionDir), sessionFile));\n if (!relativePath || relativePath.startsWith(\"../\") || path.posix.isAbsolute(relativePath)) {\n return undefined;\n }\n const snapshotPath = posixJoin(\"sessions\", relativePath);\n return isSessionFilePath(snapshotPath) ? snapshotPath : undefined;\n}\n\nexport function snapshotTarget(root: string, relativePath: string, configuredSessionDir?: string) {\n if (isSessionPath(relativePath)) {\n return safeJoin(sessionStorageRoot(root, configuredSessionDir), relativePath.slice(\"sessions/\".length));\n }\n return safeJoin(root, relativePath);\n}\n\nexport function snapshotIncludesSessions(snapshot: Snapshot) {\n return (\n snapshot.syncSessions === true ||\n snapshotSelectionInclude(snapshot)?.includes(\"sessions\") === true ||\n snapshot.files.some((file) => isSessionPath(file.path))\n );\n}\n\nexport function filterSnapshotForConfigPolicy(\n snapshot: Snapshot,\n config: SyncSelectionConfig,\n options: { regenerateId?: boolean } = {},\n) {\n const include = includeFromSelectionConfig(config);\n const includePaths = customIncludePathsByLower(include);\n const filtered = {\n ...snapshot,\n syncSessions: include.includes(\"sessions\") ? snapshot.syncSessions : false,\n selection: selectionForSnapshot(include),\n files: canonicalizeSnapshotFilesForConfig(snapshot.files, config, includePaths),\n };\n if (!options.regenerateId || snapshotsMatch(snapshot, filtered)) return filtered;\n return {\n ...filtered,\n id: snapshotId(),\n createdAt: new Date().toISOString(),\n machine: os.hostname(),\n };\n}\n\nfunction canonicalizeSnapshotFilesForConfig(\n files: SnapshotFile[],\n config: SyncSelectionConfig,\n includePaths: Map<string, string>,\n) {\n const configuredFiles: SnapshotFile[] = [];\n const extraCandidates = new Map<string, { exact: boolean; file: SnapshotFile; originalPath: string }>();\n for (const file of files) {\n const normalized = toPosix(file.path);\n if (!isSafeSnapshotPath(file.path) || !isConfiguredSnapshotPath(normalized, config)) {\n continue;\n }\n if (normalized.includes(\"/\")) {\n configuredFiles.push(normalized === file.path ? file : { ...file, path: normalized });\n continue;\n }\n const topLevelPath = canonicalSnapshotPathForConfig(normalized, includePaths);\n const candidate = {\n exact: normalized === topLevelPath,\n file: { ...file, path: topLevelPath },\n originalPath: normalized,\n };\n const current = extraCandidates.get(topLevelPath.toLowerCase());\n if (!current || isPreferredExtraCandidate(candidate, current)) {\n extraCandidates.set(topLevelPath.toLowerCase(), candidate);\n }\n }\n return [...configuredFiles, ...[...extraCandidates.values()].map((candidate) => candidate.file)].sort((left, right) =>\n left.path.localeCompare(right.path),\n );\n}\n\nfunction isPreferredExtraCandidate(\n left: { exact: boolean; originalPath: string },\n right: { exact: boolean; originalPath: string },\n) {\n if (left.exact !== right.exact) return left.exact;\n return left.originalPath.localeCompare(right.originalPath) < 0;\n}\n\nexport function snapshotWithoutSessions(snapshot: Snapshot) {\n const files = snapshot.files.filter((file) => !isSessionPath(file.path));\n const include = snapshotSelectionInclude(snapshot)?.filter((item) => item !== \"sessions\");\n if (\n files.length === snapshot.files.length &&\n snapshot.syncSessions !== true &&\n include?.length === snapshot.selection?.include.length\n ) {\n return snapshot;\n }\n return {\n ...snapshot,\n id: snapshotId(),\n createdAt: new Date().toISOString(),\n machine: os.hostname(),\n syncSessions: false,\n ...(include ? { selection: selectionForSnapshot(include) } : {}),\n files,\n };\n}\n\nexport function scanSnapshot(snapshot: Snapshot) {\n const findings: string[] = [];\n for (const file of snapshot.files) {\n const content = Buffer.from(file.contentBase64, \"base64\");\n if (content.includes(0)) continue;\n const text = content.toString(\"utf8\");\n for (const pattern of SECRET_PATTERNS) {\n if (pattern.test(text)) {\n findings.push(file.path);\n break;\n }\n }\n }\n return findings;\n}\n\nexport function mergeRemotePreservedFiles(local: Snapshot, remote: Snapshot, config: SyncSelectionConfig) {\n const localPathNames = new Set(local.files.map((file) => file.path.toLowerCase()));\n const preservedPathNames = new Set<string>();\n const preserved = remote.files.filter((file) => {\n const normalized = toPosix(file.path);\n const lower = normalized.toLowerCase();\n if (\n localPathNames.has(lower) ||\n preservedPathNames.has(lower) ||\n !isSafeSnapshotPath(file.path) ||\n isConfiguredSnapshotPath(normalized, config) ||\n !isPreservableUnmanagedSnapshotPath(normalized)\n ) {\n return false;\n }\n preservedPathNames.add(lower);\n return true;\n });\n if (preserved.length === 0) return local;\n return {\n ...local,\n id: snapshotId(),\n createdAt: new Date().toISOString(),\n machine: os.hostname(),\n syncSessions: snapshotIncludesSessions(local) || snapshotIncludesSessions(remote),\n files: [...local.files, ...preserved].sort((left, right) => left.path.localeCompare(right.path)),\n };\n}\n\nexport function mergeRemoteSessionFiles(local: Snapshot, remote: Snapshot) {\n const remoteSessions = remote.files.filter((file) => {\n const normalized = toPosix(file.path);\n return isSessionFilePath(normalized) && isSafeSnapshotPath(file.path);\n });\n if (remoteSessions.length === 0 && !snapshotIncludesSessions(remote)) return local;\n const localInclude = snapshotSelectionInclude(local);\n return {\n ...local,\n id: snapshotId(),\n createdAt: new Date().toISOString(),\n machine: os.hostname(),\n syncSessions: true,\n ...(localInclude\n ? {\n selection: selectionForSnapshot(\n localInclude.includes(\"sessions\") ? localInclude : [...localInclude, \"sessions\"],\n ),\n }\n : {}),\n files: [...local.files.filter((file) => !isSessionPath(file.path)), ...remoteSessions].sort((left, right) =>\n left.path.localeCompare(right.path),\n ),\n };\n}\n\nfunction sameOptionalInclude(left: string[] | undefined, right: string[] | undefined) {\n if (!left || !right) return left === right;\n return left.length === right.length && left.every((item, index) => item === right[index]);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAS,YAAY,kBAAkB;AAEvC,OAAO,QAAQ;AACf,OAAO,QAAQ;AACf,OAAO,UAAU;AA0BjB,IAAM,UAAU;AAChB,IAAM,kBAAqC,qBAAqB,OAAO,CAAC,SAAS,KAAK,SAAS,GAAG,CAAC;AACnG,IAAM,iBAAiB,IAAI,IAAY,qBAAqB,OAAO,CAAC,SAAS,CAAC,KAAK,SAAS,GAAG,CAAC,CAAC;AACjG,IAAM,kBAAkB;AAAA,EACtB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,SAAS,wBAAwB,SAAmB,UAAkB;AACpE,QAAM,QAAQ,QAAQ,KAAK,CAAC,UAAU,MAAM,OAAO,KAAK,MAAM,SAAS,QAAQ;AAC/E,MAAI,MAAO,QAAO;AAClB,QAAM,QAAQ,SAAS,YAAY;AACnC,SAAO,QACJ,OAAO,CAAC,UAAU,MAAM,OAAO,KAAK,MAAM,KAAK,YAAY,MAAM,KAAK,EACtE,KAAK,CAAC,MAAM,UAAU,KAAK,KAAK,cAAc,MAAM,IAAI,CAAC,EAAE,CAAC;AACjE;AAEA,SAAS,OAAO,OAAe;AAC7B,SAAO,WAAW,QAAQ,EAAE,OAAO,KAAK,EAAE,OAAO,KAAK;AACxD;AAEA,SAAS,mBAAmB,cAAsB;AAChD,MAAI,aAAa,SAAS,IAAI,EAAG,QAAO;AACxC,QAAM,aAAa,QAAQ,YAAY;AACvC,SACE,QAAQ,UAAU,KAClB,eAAe,OACf,eAAe,QACf,CAAC,WAAW,WAAW,KAAK,KAC5B,CAAC,KAAK,MAAM,WAAW,UAAU,KACjC,KAAK,MAAM,UAAU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AAK,IAAI;AACpC,WAAO,kBAAkB,UAAU,KAAK,mBAAmB,KAAK,IAAI;AAAA,EACtE,CAAC;AACD,MAAI,eAAe,WAAW,KAAK,CAAC,yBAAyB,MAAM,EAAG,QAAO;AAC7E,QAAM,eAAe,yBAAyB,KAAK;AACnD,SAAO;AAAA,IACL,GAAG;AAAA,IACH,IAAI,WAAW;AAAA,IACf,YAAW,oBAAI,KAAK,GAAE,YAAY;AAAA,IAClC,SAAS,GAAG,SAAS;AAAA,IACrB,cAAc;AAAA,IACd,GAAI,eACA;AAAA,MACE,WAAW;AAAA,QACT,aAAa,SAAS,UAAU,IAAI,eAAe,CAAC,GAAG,cAAc,UAAU;AAAA,MACjF;AAAA,IACF,IACA,CAAC;AAAA,IACL,OAAO,CAAC,GAAG,MAAM,MAAM,OAAO,CAAC,SAAS,CAAC,cAAc,KAAK,IAAI,CAAC,GAAG,GAAG,cAAc,EAAE;AAAA,MAAK,CAAC,MAAM,UACjG,KAAK,KAAK,cAAc,MAAM,IAAI;AAAA,IACpC;AAAA,EACF;AACF;AAEA,SAAS,oBAAoB,MAA4B,OAA6B;AACpF,MAAI,CAAC,QAAQ,CAAC,MAAO,QAAO,SAAS;AACrC,SAAO,KAAK,WAAW,MAAM,UAAU,KAAK,MAAM,CAAC,MAAM,UAAU,SAAS,MAAM,KAAK,CAAC;AAC1F;",
|
|
6
|
+
"names": ["configuredSessionDir"]
|
|
7
|
+
}
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
} from "./chunk-K3RIEL6J.ts";
|
|
9
9
|
import {
|
|
10
10
|
withLock
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-6O3EDBRL.ts";
|
|
12
12
|
import {
|
|
13
13
|
ContinuousError
|
|
14
14
|
} from "./chunk-DT7M4VQS.ts";
|
|
@@ -29,8 +29,8 @@ async function withAgentSyncLock(ctx, options, run) {
|
|
|
29
29
|
if (!(error instanceof AgentResolutionRequired)) throw error;
|
|
30
30
|
request = error;
|
|
31
31
|
}
|
|
32
|
-
const { withAgentClaim, readAgentCandidate, saveAgentCandidate, replaceRefusedAgentCandidate } = await import("./agent-store-
|
|
33
|
-
const { parseAgentCandidate } = await import("./agent-candidate-
|
|
32
|
+
const { withAgentClaim, readAgentCandidate, saveAgentCandidate, replaceRefusedAgentCandidate } = await import("./agent-store-RJSMNOYP.ts");
|
|
33
|
+
const { parseAgentCandidate } = await import("./agent-candidate-OCDPRI5G.ts");
|
|
34
34
|
const { runAgentResolver } = await import("./agent-runner-WMSCKSCB.ts");
|
|
35
35
|
return withAgentClaim(async (assertOwner) => {
|
|
36
36
|
const clearStatus = () => setSyncStatus(ctx, void 0);
|
|
@@ -69,7 +69,7 @@ async function withAgentSyncLock(ctx, options, run) {
|
|
|
69
69
|
expectedRefusal = parseAgentCandidate(JSON.stringify(cached), request.evidence);
|
|
70
70
|
if (!expectedRefusal.results.some((row) => "refuse" in row))
|
|
71
71
|
throw new Error("The current cached result is not a refusal. Use Sync now.");
|
|
72
|
-
const { confirmAgentRefusalRetry } = await import("./agent-refusal-retry-
|
|
72
|
+
const { confirmAgentRefusalRetry } = await import("./agent-refusal-retry-476YGNU5.ts");
|
|
73
73
|
options.signal?.throwIfAborted();
|
|
74
74
|
if (!await confirmAgentRefusalRetry(ctx, options.setup, request.evidence, validate, options.signal))
|
|
75
75
|
return "cancelled";
|
|
@@ -137,4 +137,4 @@ async function withAgentSyncLock(ctx, options, run) {
|
|
|
137
137
|
export {
|
|
138
138
|
withAgentSyncLock
|
|
139
139
|
};
|
|
140
|
-
//# sourceMappingURL=chunk-
|
|
140
|
+
//# sourceMappingURL=chunk-F7E3VFXU.ts.map
|