@narumitw/pi-sync-daemon 0.0.0-stage → 0.2.0
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 +13 -0
- package/LICENSE +21 -0
- package/README.md +89 -2
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +128 -0
- package/dist/client.d.ts +55 -0
- package/dist/client.js +484 -0
- package/dist/consent.d.ts +24 -0
- package/dist/consent.js +205 -0
- package/dist/document.d.ts +10 -0
- package/dist/document.js +6 -0
- package/dist/endpoint.d.ts +8 -0
- package/dist/endpoint.js +91 -0
- package/dist/engine/backends/backend-factory.d.ts +6 -0
- package/dist/engine/backends/backend-factory.js +16 -0
- package/dist/engine/backends/backend-identity.d.ts +3 -0
- package/dist/engine/backends/backend-identity.js +38 -0
- package/dist/engine/backends/backend-types.d.ts +70 -0
- package/dist/engine/backends/backend-types.js +1 -0
- package/dist/engine/backends/git/git-backend.d.ts +55 -0
- package/dist/engine/backends/git/git-backend.js +700 -0
- package/dist/engine/backends/git/git-config.d.ts +5 -0
- package/dist/engine/backends/git/git-config.js +118 -0
- package/dist/engine/backends/git/git-runner.d.ts +25 -0
- package/dist/engine/backends/git/git-runner.js +232 -0
- package/dist/engine/backends/git/git-storage.d.ts +39 -0
- package/dist/engine/backends/git/git-storage.js +226 -0
- package/dist/engine/backends/s3/s3-backend.d.ts +32 -0
- package/dist/engine/backends/s3/s3-backend.js +436 -0
- package/dist/engine/backends/s3/s3-client.d.ts +36 -0
- package/dist/engine/backends/s3/s3-client.js +352 -0
- package/dist/engine/backends/s3/s3-conditions.d.ts +4 -0
- package/dist/engine/backends/s3/s3-conditions.js +66 -0
- package/dist/engine/backends/snapshot-pointer.d.ts +6 -0
- package/dist/engine/backends/snapshot-pointer.js +22 -0
- package/dist/engine/backends/sync-backend.d.ts +71 -0
- package/dist/engine/backends/sync-backend.js +23 -0
- package/dist/engine/backends/webdav/webdav-backend.d.ts +34 -0
- package/dist/engine/backends/webdav/webdav-backend.js +534 -0
- package/dist/engine/backends/webdav/webdav-client.d.ts +36 -0
- package/dist/engine/backends/webdav/webdav-client.js +326 -0
- package/dist/engine/backends/webdav/webdav-config.d.ts +5 -0
- package/dist/engine/backends/webdav/webdav-config.js +73 -0
- package/dist/engine/commands/command-types.d.ts +31 -0
- package/dist/engine/commands/command-types.js +1 -0
- package/dist/engine/host.d.ts +70 -0
- package/dist/engine/host.js +16 -0
- package/dist/engine/paths.d.ts +9 -0
- package/dist/engine/paths.js +71 -0
- package/dist/engine/settings/config-errors.d.ts +1 -0
- package/dist/engine/settings/config-errors.js +4 -0
- package/dist/engine/settings/config-file.d.ts +33 -0
- package/dist/engine/settings/config-file.js +630 -0
- package/dist/engine/settings/config.d.ts +24 -0
- package/dist/engine/settings/config.js +200 -0
- package/dist/engine/settings/settings-management.d.ts +24 -0
- package/dist/engine/settings/settings-management.js +191 -0
- package/dist/engine/settings/settings-store.d.ts +8 -0
- package/dist/engine/settings/settings-store.js +41 -0
- package/dist/engine/settings/settings-types.d.ts +134 -0
- package/dist/engine/settings/settings-types.js +1 -0
- package/dist/engine/settings/settings-validation.d.ts +15 -0
- package/dist/engine/settings/settings-validation.js +356 -0
- package/dist/engine/snapshot/session-paths.d.ts +12 -0
- package/dist/engine/snapshot/session-paths.js +91 -0
- package/dist/engine/snapshot/snapshot-apply.d.ts +22 -0
- package/dist/engine/snapshot/snapshot-apply.js +262 -0
- package/dist/engine/snapshot/snapshot-case-replacement.d.ts +15 -0
- package/dist/engine/snapshot/snapshot-case-replacement.js +82 -0
- package/dist/engine/snapshot/snapshot-codec.d.ts +6 -0
- package/dist/engine/snapshot/snapshot-codec.js +53 -0
- package/dist/engine/snapshot/snapshot-exclude-safety.d.ts +7 -0
- package/dist/engine/snapshot/snapshot-exclude-safety.js +47 -0
- package/dist/engine/snapshot/snapshot-mutation-queues.d.ts +9 -0
- package/dist/engine/snapshot/snapshot-mutation-queues.js +133 -0
- package/dist/engine/snapshot/snapshot-paths.d.ts +1 -0
- package/dist/engine/snapshot/snapshot-paths.js +11 -0
- package/dist/engine/snapshot/snapshot-root-transition.d.ts +25 -0
- package/dist/engine/snapshot/snapshot-root-transition.js +122 -0
- package/dist/engine/snapshot/snapshot-transaction-directory.d.ts +2 -0
- package/dist/engine/snapshot/snapshot-transaction-directory.js +16 -0
- package/dist/engine/snapshot/snapshot-transaction-plan.d.ts +12 -0
- package/dist/engine/snapshot/snapshot-transaction-plan.js +68 -0
- package/dist/engine/snapshot/snapshot-transaction.d.ts +15 -0
- package/dist/engine/snapshot/snapshot-transaction.js +787 -0
- package/dist/engine/snapshot/snapshot-types.d.ts +48 -0
- package/dist/engine/snapshot/snapshot-types.js +1 -0
- package/dist/engine/snapshot/snapshot.d.ts +30 -0
- package/dist/engine/snapshot/snapshot.js +364 -0
- package/dist/engine/state/json-file.d.ts +6 -0
- package/dist/engine/state/json-file.js +49 -0
- package/dist/engine/state/lock-policy.d.ts +2 -0
- package/dist/engine/state/lock-policy.js +2 -0
- package/dist/engine/state/lock.d.ts +20 -0
- package/dist/engine/state/lock.js +259 -0
- package/dist/engine/state/lockfile-fs.d.ts +13 -0
- package/dist/engine/state/lockfile-fs.js +13 -0
- package/dist/engine/state/merge-baseline-store.d.ts +11 -0
- package/dist/engine/state/merge-baseline-store.js +187 -0
- package/dist/engine/state/mutation-directory-sync.d.ts +5 -0
- package/dist/engine/state/mutation-directory-sync.js +34 -0
- package/dist/engine/state/operation-availability.d.ts +49 -0
- package/dist/engine/state/operation-availability.js +40 -0
- package/dist/engine/state/state-directory.d.ts +14 -0
- package/dist/engine/state/state-directory.js +225 -0
- package/dist/engine/state/state-types.d.ts +27 -0
- package/dist/engine/state/state-types.js +1 -0
- package/dist/engine/state/sync-state-store.d.ts +11 -0
- package/dist/engine/state/sync-state-store.js +54 -0
- package/dist/engine/sync/agent-candidate.d.ts +44 -0
- package/dist/engine/sync/agent-candidate.js +207 -0
- package/dist/engine/sync/agent-plan.d.ts +8 -0
- package/dist/engine/sync/agent-plan.js +84 -0
- package/dist/engine/sync/agent-policy.d.ts +9 -0
- package/dist/engine/sync/agent-policy.js +10 -0
- package/dist/engine/sync/agent-refusal-retry.d.ts +4 -0
- package/dist/engine/sync/agent-refusal-retry.js +39 -0
- package/dist/engine/sync/agent-request.d.ts +14 -0
- package/dist/engine/sync/agent-request.js +13 -0
- package/dist/engine/sync/agent-runner.d.ts +6 -0
- package/dist/engine/sync/agent-runner.js +183 -0
- package/dist/engine/sync/agent-store.d.ts +7 -0
- package/dist/engine/sync/agent-store.js +177 -0
- package/dist/engine/sync/agent-sync.d.ts +4 -0
- package/dist/engine/sync/agent-sync.js +132 -0
- package/dist/engine/sync/apply-review.d.ts +8 -0
- package/dist/engine/sync/apply-review.js +51 -0
- package/dist/engine/sync/conflict-artifact-ownership.d.ts +4 -0
- package/dist/engine/sync/conflict-artifact-ownership.js +53 -0
- package/dist/engine/sync/conflict-artifacts.d.ts +32 -0
- package/dist/engine/sync/conflict-artifacts.js +158 -0
- package/dist/engine/sync/conflict-groups.d.ts +9 -0
- package/dist/engine/sync/conflict-groups.js +76 -0
- package/dist/engine/sync/conflict-preview.d.ts +4 -0
- package/dist/engine/sync/conflict-preview.js +53 -0
- package/dist/engine/sync/conflict-resolution.d.ts +13 -0
- package/dist/engine/sync/conflict-resolution.js +53 -0
- package/dist/engine/sync/conflict-retention.d.ts +5 -0
- package/dist/engine/sync/conflict-retention.js +61 -0
- package/dist/engine/sync/conflict-review.d.ts +4 -0
- package/dist/engine/sync/conflict-review.js +73 -0
- package/dist/engine/sync/content-conflicts.d.ts +10 -0
- package/dist/engine/sync/content-conflicts.js +70 -0
- package/dist/engine/sync/continuous-errors.d.ts +14 -0
- package/dist/engine/sync/continuous-errors.js +66 -0
- package/dist/engine/sync/continuous-lease.d.ts +9 -0
- package/dist/engine/sync/continuous-lease.js +206 -0
- package/dist/engine/sync/continuous-record.d.ts +31 -0
- package/dist/engine/sync/continuous-record.js +199 -0
- package/dist/engine/sync/continuous-storage.d.ts +14 -0
- package/dist/engine/sync/continuous-storage.js +59 -0
- package/dist/engine/sync/continuous-sync.d.ts +15 -0
- package/dist/engine/sync/continuous-sync.js +496 -0
- package/dist/engine/sync/continuous-watch.d.ts +3 -0
- package/dist/engine/sync/continuous-watch.js +65 -0
- package/dist/engine/sync/exclude-policy.d.ts +5 -0
- package/dist/engine/sync/exclude-policy.js +79 -0
- package/dist/engine/sync/field-migration.d.ts +5 -0
- package/dist/engine/sync/field-migration.js +20 -0
- package/dist/engine/sync/file-merge-planner.d.ts +36 -0
- package/dist/engine/sync/file-merge-planner.js +123 -0
- package/dist/engine/sync/initialization.d.ts +12 -0
- package/dist/engine/sync/initialization.js +75 -0
- package/dist/engine/sync/json-document.d.ts +29 -0
- package/dist/engine/sync/json-document.js +172 -0
- package/dist/engine/sync/local-field-policy.d.ts +2 -0
- package/dist/engine/sync/local-field-policy.js +26 -0
- package/dist/engine/sync/local-fields.d.ts +9 -0
- package/dist/engine/sync/local-fields.js +116 -0
- package/dist/engine/sync/merge-apply.d.ts +5 -0
- package/dist/engine/sync/merge-apply.js +386 -0
- package/dist/engine/sync/merge-journal.d.ts +31 -0
- package/dist/engine/sync/merge-journal.js +179 -0
- package/dist/engine/sync/merge-transfer-error.d.ts +3 -0
- package/dist/engine/sync/merge-transfer-error.js +64 -0
- package/dist/engine/sync/merged-sync.d.ts +6 -0
- package/dist/engine/sync/merged-sync.js +618 -0
- package/dist/engine/sync/mutation-owner.d.ts +2 -0
- package/dist/engine/sync/mutation-owner.js +18 -0
- package/dist/engine/sync/package-merge.d.ts +3 -0
- package/dist/engine/sync/package-merge.js +82 -0
- package/dist/engine/sync/partial-progress.d.ts +15 -0
- package/dist/engine/sync/partial-progress.js +39 -0
- package/dist/engine/sync/remote-snapshot.d.ts +28 -0
- package/dist/engine/sync/remote-snapshot.js +62 -0
- package/dist/engine/sync/resolver-stream.d.ts +4 -0
- package/dist/engine/sync/resolver-stream.js +34 -0
- package/dist/engine/sync/session-merge.d.ts +3 -0
- package/dist/engine/sync/session-merge.js +178 -0
- package/dist/engine/sync/session-push.d.ts +5 -0
- package/dist/engine/sync/session-push.js +32 -0
- package/dist/engine/sync/settings-conflicts.d.ts +8 -0
- package/dist/engine/sync/settings-conflicts.js +56 -0
- package/dist/engine/sync/settings-merge.d.ts +13 -0
- package/dist/engine/sync/settings-merge.js +93 -0
- package/dist/engine/sync/signals.d.ts +2 -0
- package/dist/engine/sync/signals.js +8 -0
- package/dist/engine/sync/startup-timings.d.ts +11 -0
- package/dist/engine/sync/startup-timings.js +44 -0
- package/dist/engine/sync/sync-decision.d.ts +35 -0
- package/dist/engine/sync/sync-decision.js +66 -0
- package/dist/engine/sync/sync-error-guidance.d.ts +2 -0
- package/dist/engine/sync/sync-error-guidance.js +55 -0
- package/dist/engine/sync/sync-errors.d.ts +9 -0
- package/dist/engine/sync/sync-errors.js +18 -0
- package/dist/engine/sync/sync-inspection.d.ts +26 -0
- package/dist/engine/sync/sync-inspection.js +40 -0
- package/dist/engine/sync/sync-loaders.d.ts +7 -0
- package/dist/engine/sync/sync-loaders.js +8 -0
- package/dist/engine/sync/sync-local.d.ts +5 -0
- package/dist/engine/sync/sync-local.js +40 -0
- package/dist/engine/sync/sync-mutations.d.ts +30 -0
- package/dist/engine/sync/sync-mutations.js +589 -0
- package/dist/engine/sync/sync-operations.d.ts +2 -0
- package/dist/engine/sync/sync-operations.js +3 -0
- package/dist/engine/sync/sync-policy.d.ts +85 -0
- package/dist/engine/sync/sync-policy.js +356 -0
- package/dist/engine/sync/sync-queries.d.ts +7 -0
- package/dist/engine/sync/sync-queries.js +195 -0
- package/dist/engine/sync/sync-state.d.ts +31 -0
- package/dist/engine/sync/sync-state.js +92 -0
- package/dist/engine/sync/text-merge.d.ts +19 -0
- package/dist/engine/sync/text-merge.js +124 -0
- package/dist/engine/types.d.ts +5 -0
- package/dist/engine/types.js +2 -0
- package/dist/engine/ui/merge-review.d.ts +2 -0
- package/dist/engine/ui/merge-review.js +7 -0
- package/dist/engine/ui/merged-sync-summary.d.ts +25 -0
- package/dist/engine/ui/merged-sync-summary.js +86 -0
- package/dist/engine/ui/sync-format.d.ts +13 -0
- package/dist/engine/ui/sync-format.js +150 -0
- package/dist/engine/ui/sync-status.d.ts +9 -0
- package/dist/engine/ui/sync-status.js +30 -0
- package/dist/engine/ui/terminal-text.d.ts +3 -0
- package/dist/engine/ui/terminal-text.js +9 -0
- package/dist/engine/ui/transfer-changes.d.ts +12 -0
- package/dist/engine/ui/transfer-changes.js +24 -0
- package/dist/engine/ui/transfer-review.d.ts +3 -0
- package/dist/engine/ui/transfer-review.js +19 -0
- package/dist/engine-service.d.ts +11 -0
- package/dist/engine-service.js +315 -0
- package/dist/identity.d.ts +20 -0
- package/dist/identity.js +133 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +4 -0
- package/dist/lifecycle-log.d.ts +7 -0
- package/dist/lifecycle-log.js +53 -0
- package/dist/lifecycle.d.ts +2 -0
- package/dist/lifecycle.js +21 -0
- package/dist/model-signature.d.ts +2 -0
- package/dist/model-signature.js +7 -0
- package/dist/monitor.d.ts +11 -0
- package/dist/monitor.js +245 -0
- package/dist/participant-admission.d.ts +5 -0
- package/dist/participant-admission.js +30 -0
- package/dist/protocol.d.ts +97 -0
- package/dist/protocol.js +90 -0
- package/dist/resolver-host.d.ts +11 -0
- package/dist/resolver-host.js +78 -0
- package/dist/server.d.ts +18 -0
- package/dist/server.js +724 -0
- package/dist/service-host.d.ts +7 -0
- package/dist/service-host.js +174 -0
- package/docs/architecture.md +133 -0
- package/package.json +54 -4
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
import { normalizeEndpointIdentity } from "../backends/backend-identity.js";
|
|
2
|
+
import { normalizeGitBranch, normalizeGitDirectory, normalizeGitRemote, normalizeGitRemoteIdentity, } from "../backends/git/git-config.js";
|
|
3
|
+
import { normalizeWebDavIdentityUrl, normalizeWebDavPath, normalizeWebDavUrl, validateWebDavCredentials, } from "../backends/webdav/webdav-config.js";
|
|
4
|
+
import { normalizeSyncExclude } from "../sync/exclude-policy.js";
|
|
5
|
+
import { normalizeLocalFields } from "../sync/local-field-policy.js";
|
|
6
|
+
import { normalizeSyncInclude } from "../sync/sync-policy.js";
|
|
7
|
+
import { CONFIG_FILE_NAME } from "./config-file.js";
|
|
8
|
+
export const DEFAULT_ON_SWITCH = "ask-before-pull";
|
|
9
|
+
export function normalizeOnSwitch(value) {
|
|
10
|
+
if (value === "ask-before-pull" || value === "pull-after-switch" || value === "switch-only") {
|
|
11
|
+
return value;
|
|
12
|
+
}
|
|
13
|
+
throw new Error('Invalid pi-sync settings: onSwitch must be "ask-before-pull", "pull-after-switch", or "switch-only".');
|
|
14
|
+
}
|
|
15
|
+
export function validateSettingsDocument(value) {
|
|
16
|
+
if (value.version !== 3 && value.version !== 4 && value.version !== 5 && value.version !== 6) {
|
|
17
|
+
throw new Error(`Unsupported pi-sync settings: version 3, 4, 5 or 6 is required. Keep the existing ${CONFIG_FILE_NAME} for recovery and use a compatible pi-sync client or review a separate supported setup; do not downgrade portable field policies. pi-sync will not migrate or overwrite unsupported settings.`);
|
|
18
|
+
}
|
|
19
|
+
rejectLegacyFields(value, [
|
|
20
|
+
"profiles",
|
|
21
|
+
"targets",
|
|
22
|
+
"activeTarget",
|
|
23
|
+
"targetSwitchAction",
|
|
24
|
+
"endpoint",
|
|
25
|
+
"bucket",
|
|
26
|
+
"region",
|
|
27
|
+
"accessKeyId",
|
|
28
|
+
"secretAccessKey",
|
|
29
|
+
"sessionToken",
|
|
30
|
+
"profile",
|
|
31
|
+
"prefix",
|
|
32
|
+
"autoSync",
|
|
33
|
+
"syncFiles",
|
|
34
|
+
"syncSessions",
|
|
35
|
+
"extraFiles",
|
|
36
|
+
], "top level");
|
|
37
|
+
normalizeOnSwitch(value.onSwitch);
|
|
38
|
+
if (value.skipSecretScan !== undefined && typeof value.skipSecretScan !== "boolean") {
|
|
39
|
+
throw new Error("Invalid pi-sync settings: skipSecretScan must be boolean.");
|
|
40
|
+
}
|
|
41
|
+
if (value.showStatus !== undefined && typeof value.showStatus !== "boolean") {
|
|
42
|
+
throw new Error("Invalid pi-sync settings: showStatus must be boolean.");
|
|
43
|
+
}
|
|
44
|
+
if (value.debug !== undefined && typeof value.debug !== "boolean") {
|
|
45
|
+
throw new Error("Invalid pi-sync settings: debug must be boolean.");
|
|
46
|
+
}
|
|
47
|
+
const storageConnections = requireNamedObjectMap(value.storageConnections, "storageConnections", "storage connection");
|
|
48
|
+
const syncSetups = requireNamedObjectMap(value.syncSetups, "syncSetups", "sync setup");
|
|
49
|
+
for (const name of Object.keys(storageConnections)) {
|
|
50
|
+
validateStorageConnection(name, requireOwnObject(storageConnections, name, "storage connection"));
|
|
51
|
+
}
|
|
52
|
+
for (const name of Object.keys(syncSetups)) {
|
|
53
|
+
validateSyncSetup(name, requireOwnObject(syncSetups, name, "sync setup"), storageConnections);
|
|
54
|
+
}
|
|
55
|
+
const names = Object.keys(syncSetups);
|
|
56
|
+
const activeSyncSetup = optionalCanonicalReference(value.activeSyncSetup, "activeSyncSetup");
|
|
57
|
+
if (names.length === 0) {
|
|
58
|
+
if (activeSyncSetup !== undefined) {
|
|
59
|
+
throw new Error("Invalid pi-sync settings: empty syncSetups cannot have activeSyncSetup.");
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
else if (!activeSyncSetup || !Object.hasOwn(syncSetups, activeSyncSetup)) {
|
|
63
|
+
throw new Error("Invalid pi-sync settings: activeSyncSetup must reference an existing own-property sync setup.");
|
|
64
|
+
}
|
|
65
|
+
for (const setup of Object.values(syncSetups)) {
|
|
66
|
+
const policy = setup.sync;
|
|
67
|
+
if (policy.localFields !== undefined && value.version !== 4 && value.version !== 5 && value.version !== 6)
|
|
68
|
+
throw new Error("localFields requires explicit settings version 4; older binaries must refuse portable state.");
|
|
69
|
+
}
|
|
70
|
+
for (const setup of Object.values(syncSetups)) {
|
|
71
|
+
const policy = setup.sync;
|
|
72
|
+
if (policy.exclude !== undefined && value.version !== 6)
|
|
73
|
+
throw new Error("sync.exclude requires explicit settings version 6; older clients must refuse excluded content.");
|
|
74
|
+
if ((policy.mergeContent || policy.partialSync) && value.version !== 5 && value.version !== 6)
|
|
75
|
+
throw new Error("Content/partial sync requires explicit settings version 5.");
|
|
76
|
+
}
|
|
77
|
+
validateUniqueRemoteSyncSetups(syncSetups, storageConnections);
|
|
78
|
+
return value;
|
|
79
|
+
}
|
|
80
|
+
function validateStorageConnection(name, value) {
|
|
81
|
+
rejectLegacyFields(value, ["kind", "accessKeyId", "secretAccessKey", "sessionToken", "username", "password"], `storage connection “${name}”`);
|
|
82
|
+
const type = requiredString(value.type, `storage connection “${name}” type`);
|
|
83
|
+
if (type !== "s3" && type !== "git" && type !== "webdav") {
|
|
84
|
+
throw new Error(`Invalid pi-sync settings: storage connection “${name}” has unsupported type.`);
|
|
85
|
+
}
|
|
86
|
+
const known = ["endpoint", "region", "remote", "url", "credentials"];
|
|
87
|
+
const allowed = type === "s3"
|
|
88
|
+
? new Set(["endpoint", "region", "credentials"])
|
|
89
|
+
: type === "git"
|
|
90
|
+
? new Set(["remote"])
|
|
91
|
+
: new Set(["url", "credentials"]);
|
|
92
|
+
if (known.some((field) => Object.hasOwn(value, field) && !allowed.has(field))) {
|
|
93
|
+
throw new Error(`Invalid pi-sync settings: ${type.toUpperCase()} storage connection “${name}” mixes backend fields.`);
|
|
94
|
+
}
|
|
95
|
+
if (type === "git") {
|
|
96
|
+
if (!normalizeGitRemote(requiredString(value.remote, `Git remote for “${name}”`))) {
|
|
97
|
+
throw new Error(`Invalid pi-sync settings: Git remote for “${name}” is required.`);
|
|
98
|
+
}
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const credentials = requireRecord(value.credentials, `credentials for storage connection “${name}”`);
|
|
102
|
+
if (type === "webdav") {
|
|
103
|
+
normalizeWebDavUrl(requiredString(value.url, `WebDAV URL for “${name}”`));
|
|
104
|
+
const username = requiredString(credentials.username, `WebDAV username for “${name}”`);
|
|
105
|
+
const password = requiredSecret(credentials.password, `WebDAV password for “${name}”`);
|
|
106
|
+
if (["accessKeyId", "secretAccessKey", "sessionToken"].some((field) => Object.hasOwn(credentials, field))) {
|
|
107
|
+
throw new Error(`Invalid pi-sync settings: WebDAV credentials for “${name}” mix fields.`);
|
|
108
|
+
}
|
|
109
|
+
validateWebDavCredentials(username, password);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
normalizeS3Endpoint(requiredString(value.endpoint, `S3 endpoint for “${name}”`));
|
|
113
|
+
requiredString(value.region, `S3 region for “${name}”`);
|
|
114
|
+
requiredString(credentials.accessKeyId, `S3 access key id for “${name}”`);
|
|
115
|
+
requiredSecret(credentials.secretAccessKey, `S3 secret access key for “${name}”`);
|
|
116
|
+
optionalString(credentials.sessionToken, `S3 session token for “${name}”`);
|
|
117
|
+
if (["username", "password"].some((field) => Object.hasOwn(credentials, field))) {
|
|
118
|
+
throw new Error(`Invalid pi-sync settings: S3 credentials for “${name}” mix fields.`);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function validateSyncSetup(name, value, connections) {
|
|
122
|
+
rejectLegacyFields(value, [
|
|
123
|
+
"profile",
|
|
124
|
+
"bucket",
|
|
125
|
+
"branch",
|
|
126
|
+
"path",
|
|
127
|
+
"prefix",
|
|
128
|
+
"directory",
|
|
129
|
+
"namespace",
|
|
130
|
+
"autoSync",
|
|
131
|
+
"syncFiles",
|
|
132
|
+
"syncSessions",
|
|
133
|
+
"extraFiles",
|
|
134
|
+
], `sync setup “${name}”`);
|
|
135
|
+
const storage = requireRecord(value.storage, `storage for sync setup “${name}”`);
|
|
136
|
+
const sync = requireRecord(value.sync, `sync policy for sync setup “${name}”`);
|
|
137
|
+
rejectLegacyFields(storage, ["profile", "prefix", "directory", "namespace"], `storage for sync setup “${name}”`);
|
|
138
|
+
rejectLegacyFields(sync, ["autoSync", "syncFiles", "syncSessions", "extraFiles"], `sync policy for sync setup “${name}”`);
|
|
139
|
+
const connectionName = requiredCanonicalReference(storage.connection, `storage connection reference for sync setup “${name}”`);
|
|
140
|
+
validateConfigName(connectionName, "storage connection reference");
|
|
141
|
+
const connection = ownObject(connections, connectionName);
|
|
142
|
+
if (!connection) {
|
|
143
|
+
throw new Error(`Invalid pi-sync settings: sync setup “${name}” references missing storage connection “${connectionName}”.`);
|
|
144
|
+
}
|
|
145
|
+
const type = connection.type;
|
|
146
|
+
normalizeStoragePath(requiredString(storage.path, `storage path for sync setup “${name}”`));
|
|
147
|
+
if (type === "s3") {
|
|
148
|
+
normalizeS3Bucket(requiredString(storage.bucket, `S3 bucket for sync setup “${name}”`));
|
|
149
|
+
if (Object.hasOwn(storage, "branch"))
|
|
150
|
+
mixedSetupError("S3", name);
|
|
151
|
+
}
|
|
152
|
+
else if (type === "git") {
|
|
153
|
+
normalizeGitBranch(requiredString(storage.branch, `Git branch for sync setup “${name}”`));
|
|
154
|
+
if (Object.hasOwn(storage, "bucket"))
|
|
155
|
+
mixedSetupError("Git", name);
|
|
156
|
+
}
|
|
157
|
+
else if (type === "webdav") {
|
|
158
|
+
if (Object.hasOwn(storage, "bucket") || Object.hasOwn(storage, "branch")) {
|
|
159
|
+
mixedSetupError("WebDAV", name);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
if (!Object.hasOwn(sync, "include")) {
|
|
163
|
+
throw new Error(`Invalid pi-sync settings: sync setup “${name}” is missing sync.include.`);
|
|
164
|
+
}
|
|
165
|
+
const include = normalizeSyncInclude(sync.include);
|
|
166
|
+
normalizeSyncExclude(sync.exclude);
|
|
167
|
+
const localFields = normalizeLocalFields(sync.localFields);
|
|
168
|
+
if (localFields.length > 0 && !include.includes("settings.json"))
|
|
169
|
+
throw new Error("Nonempty localFields requires settings.json in sync.include.");
|
|
170
|
+
for (const key of ["mergeContent", "partialSync", "agentMode", "continuous"])
|
|
171
|
+
if (sync[key] !== undefined && typeof sync[key] !== "boolean")
|
|
172
|
+
throw new Error(`${key} must be boolean.`);
|
|
173
|
+
if (sync.mergeSettings !== undefined && typeof sync.mergeSettings !== "boolean")
|
|
174
|
+
throw new Error("mergeSettings must be boolean.");
|
|
175
|
+
if (sync.automaticTransfer !== undefined && typeof sync.automaticTransfer !== "boolean") {
|
|
176
|
+
throw new Error(`Invalid pi-sync settings: sync setup “${name}” sync.automaticTransfer must be boolean.`);
|
|
177
|
+
}
|
|
178
|
+
if (typeof sync.automatic !== "boolean") {
|
|
179
|
+
throw new Error(`Invalid pi-sync settings: sync setup “${name}” sync.automatic must be boolean.`);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
function mixedSetupError(type, name) {
|
|
183
|
+
throw new Error(`Invalid pi-sync settings: ${type} sync setup “${name}” mixes backend fields.`);
|
|
184
|
+
}
|
|
185
|
+
export function validateUniqueRemoteSyncSetups(setups, connections) {
|
|
186
|
+
const identities = new Map();
|
|
187
|
+
for (const name of Object.keys(setups)) {
|
|
188
|
+
const setup = requireOwnObject(setups, name, "sync setup");
|
|
189
|
+
const connection = requireOwnObject(connections, setup.storage.connection, "storage connection");
|
|
190
|
+
const identity = effectiveSyncSetupRemoteIdentity(setup, connection);
|
|
191
|
+
const existing = identities.get(identity);
|
|
192
|
+
if (existing) {
|
|
193
|
+
throw new Error(`Invalid pi-sync settings: sync setups “${existing}” and “${name}” use the same normalized remote location.`);
|
|
194
|
+
}
|
|
195
|
+
identities.set(identity, name);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
export function effectiveSyncSetupRemoteIdentity(setup, connection) {
|
|
199
|
+
const storagePath = normalizeStoragePath(setup.storage.path);
|
|
200
|
+
if (connection.type === "git") {
|
|
201
|
+
return JSON.stringify([
|
|
202
|
+
"git",
|
|
203
|
+
normalizeGitRemoteIdentity(connection.remote),
|
|
204
|
+
normalizeGitBranch(setup.storage.branch),
|
|
205
|
+
normalizeGitDirectory(storagePath),
|
|
206
|
+
]);
|
|
207
|
+
}
|
|
208
|
+
if (connection.type === "webdav") {
|
|
209
|
+
return JSON.stringify([
|
|
210
|
+
"webdav",
|
|
211
|
+
normalizeWebDavIdentityUrl(connection.url),
|
|
212
|
+
connection.credentials.username.trim(),
|
|
213
|
+
normalizeWebDavPath(storagePath),
|
|
214
|
+
]);
|
|
215
|
+
}
|
|
216
|
+
return JSON.stringify([
|
|
217
|
+
"s3",
|
|
218
|
+
normalizeEndpointIdentity(connection.endpoint),
|
|
219
|
+
normalizeS3Bucket(setup.storage.bucket),
|
|
220
|
+
storagePath,
|
|
221
|
+
]);
|
|
222
|
+
}
|
|
223
|
+
function rejectLegacyFields(value, fields, context) {
|
|
224
|
+
const field = fields.find((candidate) => Object.hasOwn(value, candidate));
|
|
225
|
+
if (field) {
|
|
226
|
+
throw new Error(`Invalid pi-sync settings: ${context} contains unsupported version 1/2 field “${field}”.`);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
function requireNamedObjectMap(value, field, itemLabel) {
|
|
230
|
+
const result = requireRecord(value, field);
|
|
231
|
+
for (const name of Object.keys(result))
|
|
232
|
+
validateConfigName(name, itemLabel);
|
|
233
|
+
return result;
|
|
234
|
+
}
|
|
235
|
+
function requireOwnObject(value, key, label) {
|
|
236
|
+
const item = ownObject(value, key);
|
|
237
|
+
if (!item)
|
|
238
|
+
throw new Error(`Invalid pi-sync settings: ${label} “${key}” must be an object.`);
|
|
239
|
+
return item;
|
|
240
|
+
}
|
|
241
|
+
export function ownObject(value, key) {
|
|
242
|
+
if (!Object.hasOwn(value, key))
|
|
243
|
+
return undefined;
|
|
244
|
+
const item = value[key];
|
|
245
|
+
return item && typeof item === "object" && !Array.isArray(item) ? item : undefined;
|
|
246
|
+
}
|
|
247
|
+
function requireRecord(value, field) {
|
|
248
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
249
|
+
throw new Error(`Invalid pi-sync settings: ${field} must be an object.`);
|
|
250
|
+
}
|
|
251
|
+
return value;
|
|
252
|
+
}
|
|
253
|
+
export function validateConfigName(value, field) {
|
|
254
|
+
if (!value.trim() ||
|
|
255
|
+
value !== value.trim() ||
|
|
256
|
+
value.length > 100 ||
|
|
257
|
+
value === "__proto__" ||
|
|
258
|
+
value === "prototype" ||
|
|
259
|
+
value === "constructor" ||
|
|
260
|
+
hasControlCharacter(value)) {
|
|
261
|
+
throw new Error(`Invalid pi-sync settings: invalid ${field} name.`);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
export function requiredString(value, field) {
|
|
265
|
+
if (typeof value !== "string" || !value.trim() || hasControlCharacter(value)) {
|
|
266
|
+
throw new Error(`Invalid pi-sync settings: ${field} must be a non-empty string.`);
|
|
267
|
+
}
|
|
268
|
+
return value.trim();
|
|
269
|
+
}
|
|
270
|
+
function requiredCanonicalReference(value, field) {
|
|
271
|
+
const normalized = requiredString(value, field);
|
|
272
|
+
if (value !== normalized) {
|
|
273
|
+
throw new Error(`Invalid pi-sync settings: ${field} must not have surrounding whitespace.`);
|
|
274
|
+
}
|
|
275
|
+
return normalized;
|
|
276
|
+
}
|
|
277
|
+
function optionalCanonicalReference(value, field) {
|
|
278
|
+
const normalized = optionalString(value, field);
|
|
279
|
+
if (normalized !== undefined && value !== normalized) {
|
|
280
|
+
throw new Error(`Invalid pi-sync settings: ${field} must not have surrounding whitespace.`);
|
|
281
|
+
}
|
|
282
|
+
return normalized;
|
|
283
|
+
}
|
|
284
|
+
function requiredSecret(value, field) {
|
|
285
|
+
if (typeof value !== "string" || !value || hasControlCharacter(value)) {
|
|
286
|
+
throw new Error(`Invalid pi-sync settings: ${field} must be configured.`);
|
|
287
|
+
}
|
|
288
|
+
return value;
|
|
289
|
+
}
|
|
290
|
+
export function optionalString(value, field) {
|
|
291
|
+
if (value === undefined)
|
|
292
|
+
return undefined;
|
|
293
|
+
if (typeof value !== "string" || hasControlCharacter(value)) {
|
|
294
|
+
throw new Error(`Invalid pi-sync settings: ${field} must be a string.`);
|
|
295
|
+
}
|
|
296
|
+
return value.trim() || undefined;
|
|
297
|
+
}
|
|
298
|
+
export function normalizeStoragePath(value) {
|
|
299
|
+
if (value.trim() === "." || value.trim() === "./")
|
|
300
|
+
return "./";
|
|
301
|
+
const normalized = value.trim().replace(/^\/+|\/+$/gu, "");
|
|
302
|
+
if (!normalized ||
|
|
303
|
+
normalized.length > 1024 ||
|
|
304
|
+
normalized.startsWith("-") ||
|
|
305
|
+
normalized.includes("\\") ||
|
|
306
|
+
hasControlCharacter(normalized) ||
|
|
307
|
+
normalized.split("/").some((segment) => !segment || segment === "." || segment === "..")) {
|
|
308
|
+
throw new Error("Invalid pi-sync settings: storage.path must be a safe relative path.");
|
|
309
|
+
}
|
|
310
|
+
return normalized;
|
|
311
|
+
}
|
|
312
|
+
export function normalizeS3Endpoint(value) {
|
|
313
|
+
let url;
|
|
314
|
+
try {
|
|
315
|
+
url = new URL(value.trim());
|
|
316
|
+
}
|
|
317
|
+
catch {
|
|
318
|
+
throw new Error("Invalid pi-sync S3 endpoint.");
|
|
319
|
+
}
|
|
320
|
+
const loopback = url.hostname === "127.0.0.1" || url.hostname === "localhost" || url.hostname === "[::1]";
|
|
321
|
+
if ((url.protocol !== "https:" && !(url.protocol === "http:" && loopback)) ||
|
|
322
|
+
url.username ||
|
|
323
|
+
url.password ||
|
|
324
|
+
url.search ||
|
|
325
|
+
url.hash) {
|
|
326
|
+
throw new Error("Invalid pi-sync S3 endpoint: HTTPS is required except for loopback.");
|
|
327
|
+
}
|
|
328
|
+
url.pathname = url.pathname.replace(/\/+$/gu, "");
|
|
329
|
+
return url.toString().replace(/\/$/u, "");
|
|
330
|
+
}
|
|
331
|
+
export function normalizeS3Bucket(value) {
|
|
332
|
+
const bucket = requiredString(value, "S3 bucket");
|
|
333
|
+
if (bucket.includes("/") || bucket.includes("\\") || bucket.startsWith("-")) {
|
|
334
|
+
throw new Error("Invalid pi-sync S3 bucket.");
|
|
335
|
+
}
|
|
336
|
+
return bucket;
|
|
337
|
+
}
|
|
338
|
+
function hasControlCharacter(value) {
|
|
339
|
+
// biome-ignore lint/suspicious/noControlCharactersInRegex: Stored settings cannot contain controls.
|
|
340
|
+
return /[\u0000-\u001f\u007f-\u009f]/u.test(value);
|
|
341
|
+
}
|
|
342
|
+
export function isCloudflareR2Endpoint(endpoint) {
|
|
343
|
+
const value = endpoint?.trim();
|
|
344
|
+
if (!value)
|
|
345
|
+
return false;
|
|
346
|
+
try {
|
|
347
|
+
const hostname = new URL(value).hostname.toLowerCase();
|
|
348
|
+
return hostname === "r2.cloudflarestorage.com" || hostname.endsWith(".r2.cloudflarestorage.com");
|
|
349
|
+
}
|
|
350
|
+
catch {
|
|
351
|
+
return false;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
export function ownRecord(value) {
|
|
355
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : undefined;
|
|
356
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type EngineContext as ExtensionCommandContext, type EngineContext as ExtensionContext } from "../host.js";
|
|
2
|
+
import type { AnySyncConfig } from "../settings/settings-types.js";
|
|
3
|
+
import type { Snapshot, SnapshotOptions } from "./snapshot-types.js";
|
|
4
|
+
export declare function sessionDirFromContext(ctx: ExtensionCommandContext | ExtensionContext): string | undefined;
|
|
5
|
+
export declare function configuredSessionDir(): Promise<string | undefined>;
|
|
6
|
+
export declare function effectiveSessionRoot(ctx: ExtensionCommandContext | ExtensionContext): Promise<string>;
|
|
7
|
+
export declare function sessionDirForApply(ctx: ExtensionCommandContext | ExtensionContext, snapshot: Snapshot): Promise<string | undefined>;
|
|
8
|
+
/** Hash-only merge plans cannot describe installation into a different session root. */
|
|
9
|
+
export declare function requireStableMergeSessionRoot(before: Snapshot, after: Snapshot): void;
|
|
10
|
+
export declare function agentDir(): string;
|
|
11
|
+
export declare function expandSessionDir(value: string): string;
|
|
12
|
+
export declare function snapshotOptionsForContext(ctx: ExtensionCommandContext | ExtensionContext, config: AnySyncConfig): SnapshotOptions;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { getEngineRoot as getAgentDir, } from "../host.js";
|
|
5
|
+
import { sessionStorageRoot } from "./snapshot-paths.js";
|
|
6
|
+
export function sessionDirFromContext(ctx) {
|
|
7
|
+
const manager = ctx.sessionManager;
|
|
8
|
+
const usesDefaultSessionDir = manager.usesDefaultSessionDir;
|
|
9
|
+
if (typeof usesDefaultSessionDir === "function" && usesDefaultSessionDir.call(manager)) {
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
const getSessionDir = manager.getSessionDir;
|
|
13
|
+
return typeof getSessionDir === "function" ? getSessionDir.call(manager) : undefined;
|
|
14
|
+
}
|
|
15
|
+
export async function configuredSessionDir() {
|
|
16
|
+
let content;
|
|
17
|
+
try {
|
|
18
|
+
content = await fs.readFile(path.join(agentDir(), "settings.json"), "utf8");
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
if (error.code === "ENOENT")
|
|
22
|
+
return undefined;
|
|
23
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
let settings;
|
|
26
|
+
try {
|
|
27
|
+
// Pi accepts a leading UTF-8 BOM in its settings file; snapshot bytes stay unchanged.
|
|
28
|
+
settings = JSON.parse(content.replace(/^\uFEFF/u, ""));
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
throw new SyntaxError("Pi settings.json cannot be parsed; repair the file before syncing.");
|
|
32
|
+
}
|
|
33
|
+
return settings?.sessionDir ? expandSessionDir(settings.sessionDir) : undefined;
|
|
34
|
+
}
|
|
35
|
+
export async function effectiveSessionRoot(ctx) {
|
|
36
|
+
return path.resolve(sessionStorageRoot(agentDir(), sessionDirFromContext(ctx) ?? (await configuredSessionDir())));
|
|
37
|
+
}
|
|
38
|
+
export async function sessionDirForApply(ctx, snapshot) {
|
|
39
|
+
const contextSessionDir = sessionDirFromContext(ctx);
|
|
40
|
+
const localSessionDir = await configuredSessionDir();
|
|
41
|
+
if (contextSessionDir && path.resolve(contextSessionDir) !== path.resolve(localSessionDir ?? "")) {
|
|
42
|
+
return contextSessionDir;
|
|
43
|
+
}
|
|
44
|
+
return sessionDirFromSnapshot(snapshot) ?? contextSessionDir;
|
|
45
|
+
}
|
|
46
|
+
/** Hash-only merge plans cannot describe installation into a different session root. */
|
|
47
|
+
export function requireStableMergeSessionRoot(before, after) {
|
|
48
|
+
const root = agentDir();
|
|
49
|
+
if (path.resolve(sessionStorageRoot(root, sessionDirFromSnapshot(before))) !==
|
|
50
|
+
path.resolve(sessionStorageRoot(root, sessionDirFromSnapshot(after)))) {
|
|
51
|
+
throw new Error("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.");
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function sessionDirFromSnapshot(snapshot) {
|
|
55
|
+
const settingsFile = snapshot.files.find((file) => file.path === "settings.json");
|
|
56
|
+
if (!settingsFile)
|
|
57
|
+
return undefined;
|
|
58
|
+
let settings;
|
|
59
|
+
try {
|
|
60
|
+
settings = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(decodeBase64Strict(settingsFile.contentBase64, settingsFile.path)));
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
// JSON parser errors can quote private settings values; never surface their payload.
|
|
64
|
+
throw new Error("Merged settings cannot be parsed; review a directional recovery.");
|
|
65
|
+
}
|
|
66
|
+
if (!settings || typeof settings !== "object" || Array.isArray(settings))
|
|
67
|
+
throw new Error("Merged settings must be a JSON object; review a directional recovery.");
|
|
68
|
+
const sessionDir = settings.sessionDir;
|
|
69
|
+
if (sessionDir !== undefined && typeof sessionDir !== "string")
|
|
70
|
+
throw new Error("Merged sessionDir must be a string; review a directional recovery.");
|
|
71
|
+
return sessionDir ? expandSessionDir(sessionDir) : undefined;
|
|
72
|
+
}
|
|
73
|
+
function decodeBase64Strict(value, filePath) {
|
|
74
|
+
if (!/^[A-Za-z0-9+/]*={0,2}$/.test(value) || value.length % 4 !== 0) {
|
|
75
|
+
throw new Error(`Invalid base64 content in snapshot file: ${filePath}`);
|
|
76
|
+
}
|
|
77
|
+
return Buffer.from(value, "base64");
|
|
78
|
+
}
|
|
79
|
+
export function agentDir() {
|
|
80
|
+
return getAgentDir();
|
|
81
|
+
}
|
|
82
|
+
export function expandSessionDir(value) {
|
|
83
|
+
return value === "~" || value.startsWith("~/") ? path.join(os.homedir(), value.slice(2)) : value;
|
|
84
|
+
}
|
|
85
|
+
export function snapshotOptionsForContext(ctx, config) {
|
|
86
|
+
return {
|
|
87
|
+
include: config.include,
|
|
88
|
+
...(config.exclude === undefined ? {} : { exclude: config.exclude }),
|
|
89
|
+
sessionDir: sessionDirFromContext(ctx),
|
|
90
|
+
};
|
|
91
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Snapshot, SnapshotApplyPlan, SnapshotOptions } from "./snapshot-types.js";
|
|
2
|
+
export declare function applySnapshot(snapshot: Snapshot, protectedRelativePaths?: Set<string>, options?: Pick<SnapshotOptions, "include" | "exclude" | "sessionDir" | "syncFiles" | "syncSessions" | "extraFiles" | "signal" | "validateMutation" | "expectedFileHashes">): Promise<{
|
|
3
|
+
[k: string]: string;
|
|
4
|
+
}>;
|
|
5
|
+
export declare function preflightSnapshotApply(root: string, snapshot: Snapshot, current: Snapshot, options?: {
|
|
6
|
+
sessionDir?: string;
|
|
7
|
+
exclude?: string[];
|
|
8
|
+
}): SnapshotApplyPlan;
|
|
9
|
+
export declare function protectSnapshotApplyPlan(root: string, plan: SnapshotApplyPlan, protectedRelativePaths: Set<string>, sessionDir?: string): SnapshotApplyPlan;
|
|
10
|
+
export declare function addTopLevelCaseVariantDeletes(root: string, plan: SnapshotApplyPlan, snapshot: Pick<Snapshot, "files">): Promise<SnapshotApplyPlan>;
|
|
11
|
+
export declare function appliedFileHashMap(snapshot: Snapshot, current: Snapshot, protectedRelativePaths: Set<string>): {
|
|
12
|
+
[k: string]: string;
|
|
13
|
+
};
|
|
14
|
+
type MutationGuards = Pick<SnapshotOptions, "signal" | "validateMutation" | "exclude">;
|
|
15
|
+
export declare function preflightSnapshotMutations(root: string, plan: {
|
|
16
|
+
deletes: string[];
|
|
17
|
+
writes: Array<{
|
|
18
|
+
target: string;
|
|
19
|
+
content: Buffer;
|
|
20
|
+
}>;
|
|
21
|
+
}, sessionDir?: string, options?: MutationGuards): Promise<void>;
|
|
22
|
+
export {};
|