@narumitw/pi-sync 0.66.0 → 0.67.1
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 +12 -0
- package/README.md +11 -2
- package/dist/chunks/{chunk-BYVHABNR.ts → chunk-2MUAR5GH.ts} +2 -2
- package/dist/chunks/{chunk-5YOLQKNZ.ts → chunk-3CO7QIYB.ts} +14 -14
- package/dist/chunks/{chunk-DAZZ5BEJ.ts → chunk-3NS4PMCI.ts} +6 -2
- package/dist/chunks/{chunk-FI2F5JBS.ts → chunk-3Q3DMMID.ts} +8 -8
- package/dist/chunks/{chunk-BESRBKVO.ts → chunk-CQXGMESM.ts} +7 -7
- package/dist/chunks/{chunk-SZJOUVCL.ts → chunk-DGVZYS7T.ts} +5 -5
- package/dist/chunks/{chunk-WJQ4TGN5.ts → chunk-ECUCXF5Y.ts} +2 -2
- package/dist/chunks/{chunk-Z5JMOXJM.ts → chunk-JNTDIVP6.ts} +5 -5
- package/dist/chunks/{chunk-AYGMIMCV.ts → chunk-PUSMSKIM.ts} +11 -2
- package/dist/chunks/chunk-PUSMSKIM.ts.map +7 -0
- package/dist/chunks/{chunk-ASU3GZPW.ts → chunk-W7DSN33J.ts} +6 -6
- package/dist/chunks/{chunk-JQ5BAWW2.ts → chunk-XPKHWTGT.ts} +77 -16
- package/dist/chunks/chunk-XPKHWTGT.ts.map +7 -0
- package/dist/chunks/{command-handler-44EFGPWH.ts → command-handler-H5X3BX5D.ts} +40 -32
- package/dist/chunks/command-handler-H5X3BX5D.ts.map +7 -0
- package/dist/chunks/config-P54GGMXY.ts +39 -0
- package/dist/chunks/{conflict-review-J7L7S4AR.ts → conflict-review-SSY37F4P.ts} +2 -2
- package/dist/chunks/{file-selection-XWACUTAH.ts → file-selection-GASCVN45.ts} +6 -6
- package/dist/chunks/{ignore-file-ui-OHFISFVC.ts → ignore-file-ui-UY2TEK4C.ts} +5 -5
- package/dist/chunks/{manager-result-dispatcher-WXE2BAQO.ts → manager-result-dispatcher-PEVIGLOS.ts} +7 -7
- package/dist/chunks/{manager-ui-CVZLMXJ5.ts → manager-ui-R5XHYRXK.ts} +165 -34
- package/dist/chunks/manager-ui-R5XHYRXK.ts.map +7 -0
- package/dist/chunks/{merge-review-AAC674C6.ts → merge-review-C2KETZKY.ts} +3 -3
- package/dist/chunks/{remote-selection-ui-E4XZCQ7A.ts → remote-selection-ui-WFLX6MAJ.ts} +6 -6
- package/dist/chunks/{setup-switch-644T6KHG.ts → setup-switch-JZDFQPVW.ts} +4 -4
- package/dist/chunks/setup-switch-JZDFQPVW.ts.map +7 -0
- package/dist/chunks/{setup-wizard-IEW56AZE.ts → setup-wizard-5OMFSFPJ.ts} +9 -9
- package/dist/chunks/{sync-inspection-NBBTSMKR.ts → sync-inspection-S2GHDBAD.ts} +5 -5
- package/dist/chunks/{sync-operations-AIEM2KL2.ts → sync-operations-LQ63CU2T.ts} +2 -2
- package/dist/daemon/dist/client.js +32 -18
- package/dist/daemon/dist/daemon-recovery.js +5 -3
- package/dist/daemon/dist/engine/ignore/adoption-journal.js +6 -3
- package/dist/daemon/dist/engine/ignore/ignore-edit.js +2 -2
- package/dist/daemon/dist/engine/ignore/ignore-settings.js +2 -1
- package/dist/daemon/dist/engine/settings/config-file.js +3 -0
- package/dist/daemon/dist/engine/settings/config.js +5 -5
- package/dist/daemon/dist/engine/settings/settings-management.js +6 -1
- package/dist/daemon/dist/engine/settings/settings-validation.js +21 -2
- package/dist/daemon/dist/engine/sync/continuous-errors.js +6 -0
- package/dist/daemon/dist/engine/sync/continuous-sync.js +4 -2
- package/dist/daemon/dist/engine/sync/ignore-adoption.js +17 -2
- package/dist/daemon/dist/engine/sync/merge-apply.js +18 -1
- package/dist/daemon/dist/engine/sync/merged-sync.js +36 -4
- package/dist/daemon/dist/engine/sync/push-review.js +33 -0
- package/dist/daemon/dist/engine/sync/sync-mutations.js +42 -49
- package/dist/daemon/dist/engine/sync/sync-rollback.js +16 -2
- package/dist/daemon/dist/engine/sync/transfer-freshness.js +3 -2
- package/dist/daemon/dist/engine/sync/transfer-size-limits.js +92 -0
- package/dist/daemon/dist/engine-service.js +22 -6
- package/dist/daemon/dist/foreground-queue-outcome.js +4 -0
- package/dist/daemon/dist/server.js +2 -1
- package/dist/daemon/dist/service-host.js +7 -2
- package/dist/daemon/package.json +1 -1
- package/dist/index.ts +41 -32
- package/dist/index.ts.map +2 -2
- package/docs/daemon-migration.md +8 -0
- package/docs/tui-contract.md +4 -3
- package/package.json +2 -2
- package/skills/configure-pi-sync/SKILL.md +1 -1
- package/skills/configure-pi-sync/references/configuration.md +33 -6
- package/src/commands/command-execution.ts +10 -1
- package/src/commands/command-handler.ts +4 -0
- package/src/daemon/directional-recovery.ts +35 -5
- package/src/daemon/pi-client.ts +82 -12
- package/src/sync-extension.ts +17 -9
- package/src/ui/cancellable-operation.ts +13 -2
- package/src/ui/manager-state.ts +1 -0
- package/src/ui/manager-ui.ts +25 -4
- package/src/ui/settings-ui.ts +128 -4
- package/dist/chunks/chunk-AYGMIMCV.ts.map +0 -7
- package/dist/chunks/chunk-JQ5BAWW2.ts.map +0 -7
- package/dist/chunks/command-handler-44EFGPWH.ts.map +0 -7
- package/dist/chunks/manager-ui-CVZLMXJ5.ts.map +0 -7
- /package/dist/chunks/{chunk-BYVHABNR.ts.map → chunk-2MUAR5GH.ts.map} +0 -0
- /package/dist/chunks/{chunk-5YOLQKNZ.ts.map → chunk-3CO7QIYB.ts.map} +0 -0
- /package/dist/chunks/{chunk-DAZZ5BEJ.ts.map → chunk-3NS4PMCI.ts.map} +0 -0
- /package/dist/chunks/{chunk-FI2F5JBS.ts.map → chunk-3Q3DMMID.ts.map} +0 -0
- /package/dist/chunks/{chunk-BESRBKVO.ts.map → chunk-CQXGMESM.ts.map} +0 -0
- /package/dist/chunks/{chunk-SZJOUVCL.ts.map → chunk-DGVZYS7T.ts.map} +0 -0
- /package/dist/chunks/{chunk-WJQ4TGN5.ts.map → chunk-ECUCXF5Y.ts.map} +0 -0
- /package/dist/chunks/{chunk-Z5JMOXJM.ts.map → chunk-JNTDIVP6.ts.map} +0 -0
- /package/dist/chunks/{chunk-ASU3GZPW.ts.map → chunk-W7DSN33J.ts.map} +0 -0
- /package/dist/chunks/{ignore-file-ui-OHFISFVC.ts.map → config-P54GGMXY.ts.map} +0 -0
- /package/dist/chunks/{conflict-review-J7L7S4AR.ts.map → conflict-review-SSY37F4P.ts.map} +0 -0
- /package/dist/chunks/{file-selection-XWACUTAH.ts.map → file-selection-GASCVN45.ts.map} +0 -0
- /package/dist/chunks/{manager-result-dispatcher-WXE2BAQO.ts.map → ignore-file-ui-UY2TEK4C.ts.map} +0 -0
- /package/dist/chunks/{merge-review-AAC674C6.ts.map → manager-result-dispatcher-PEVIGLOS.ts.map} +0 -0
- /package/dist/chunks/{remote-selection-ui-E4XZCQ7A.ts.map → merge-review-C2KETZKY.ts.map} +0 -0
- /package/dist/chunks/{setup-switch-644T6KHG.ts.map → remote-selection-ui-WFLX6MAJ.ts.map} +0 -0
- /package/dist/chunks/{setup-wizard-IEW56AZE.ts.map → setup-wizard-5OMFSFPJ.ts.map} +0 -0
- /package/dist/chunks/{sync-inspection-NBBTSMKR.ts.map → sync-inspection-S2GHDBAD.ts.map} +0 -0
- /package/dist/chunks/{sync-operations-AIEM2KL2.ts.map → sync-operations-LQ63CU2T.ts.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createSyncBackend } from "../backends/backend-factory.js";
|
|
2
2
|
import { expectedRemoteHead, SyncBackendConflictError, } from "../backends/sync-backend.js";
|
|
3
|
-
import { loadAdoptionJournal, requireNoPendingAdoption } from "../ignore/adoption-journal.js";
|
|
3
|
+
import { adoptionJournalFingerprint, loadAdoptionJournal, requireNoPendingAdoption, } from "../ignore/adoption-journal.js";
|
|
4
4
|
import { loadConfig, loadConfigForCheck, syncCheckConfigFingerprint } from "../settings/config.js";
|
|
5
5
|
import { effectiveSessionRoot, requireStableMergeSessionRoot, resolvedSnapshotOptionsForContext, sessionDirForApply, } from "../snapshot/session-paths.js";
|
|
6
6
|
import { createSnapshot, filterSnapshotForConfigPolicy, scanSnapshot, snapshotIncludesSessions, } from "../snapshot/snapshot.js";
|
|
@@ -9,8 +9,7 @@ import { pendingTransactionEntries } from "../snapshot/snapshot-transaction-dire
|
|
|
9
9
|
import { ignorePolicyValidator } from "../snapshot/snapshot-transaction-policy.js";
|
|
10
10
|
import { pruneMergeBaselines } from "../state/merge-baseline-store.js";
|
|
11
11
|
import { readStateForConfig, syncStateFingerprint, writeStateForConfig } from "../state/sync-state-store.js";
|
|
12
|
-
import {
|
|
13
|
-
import { countPreservedRemoteFiles, formatPullSummary, formatPushSummary, formatTransferReview, } from "../ui/sync-format.js";
|
|
12
|
+
import { formatPullSummary } from "../ui/sync-format.js";
|
|
14
13
|
import { setSyncStatus } from "../ui/sync-status.js";
|
|
15
14
|
import { confirmTransferReview } from "../ui/transfer-review.js";
|
|
16
15
|
import { startupTransferEnabled } from "./agent-policy.js";
|
|
@@ -18,18 +17,20 @@ import { inspectCaseCleanup, revalidateCaseCleanup } from "./apply-review.js";
|
|
|
18
17
|
import { checkpointDirectionalAction, foregroundDirectionalAction, keepProtectedRemoteSessions, localRestoreGuidance, notifyDirectionalSuccess, remoteRestoreGuidance, requireDirectionalPullBoundary, requireDirectionalSelection, validateDirectionalSettings, } from "./directional-action.js";
|
|
19
18
|
import { confirmFieldMigration } from "./field-migration.js";
|
|
20
19
|
import { adoptionSettingsFingerprint, adoptRemoteRules, canReviewAdoption } from "./ignore-adoption.js";
|
|
21
|
-
import {
|
|
20
|
+
import { withPublishedIgnoreRules } from "./ignore-publication.js";
|
|
22
21
|
import { overlayLocalFields, portableSnapshot, sameLocalFields, validatePortableSnapshot } from "./local-fields.js";
|
|
23
22
|
import { readMergeJournal, requireNoMergeJournal, retireMergeJournal } from "./merge-journal.js";
|
|
24
23
|
import { mergeSync } from "./merged-sync.js";
|
|
24
|
+
import { confirmPush } from "./push-review.js";
|
|
25
25
|
import { readRemoteSnapshot, readRemoteSnapshotForUpload, readSnapshotForHead, requireCompatibleRemoteSelection, sameRemoteHead, snapshotForUpload, } from "./remote-snapshot.js";
|
|
26
26
|
import { throwIfAborted } from "./signals.js";
|
|
27
27
|
import { createSyncDecision } from "./sync-decision.js";
|
|
28
28
|
import { errorMessage, PublicationStatePersistenceError } from "./sync-errors.js";
|
|
29
29
|
import { backupDirectionalSnapshot, backupLocal, captureMutationOwner, LocalBackupVerificationError, maybeReload, protectedSessionPaths, } from "./sync-local.js";
|
|
30
|
-
import {
|
|
30
|
+
import { inspectRemoteSelection, syncSelectionHasContent, syncSessionsSelected } from "./sync-policy.js";
|
|
31
31
|
import { acceptedSelection, canPullRemoteSessionsOnFirstSync, canPullRemoteSettingsOnFirstSync, fileHashMap, hasLocalChanges, hasRemoteChanges, remoteChangedSinceState, sameHashes, shouldRefreshSyncedState, snapshotHashesMatchState, snapshotsMatch, syncPolicyChanged, } from "./sync-state.js";
|
|
32
32
|
import { checkLiveProtection, directionalApplyGuards, requireIgnoreBaselineReview, requireResolvedDirectionalProgress, validateDirectionalPublication, } from "./transfer-freshness.js";
|
|
33
|
+
import { requireTransferSize, selectedPublicationImage, selectedPullImage, transferSizeLimitsEnabled, } from "./transfer-size-limits.js";
|
|
33
34
|
const VERSION = 1;
|
|
34
35
|
export { PublicationStatePersistenceError, RollbackPublicationError } from "./sync-errors.js";
|
|
35
36
|
export { rollback } from "./sync-rollback.js";
|
|
@@ -120,6 +121,17 @@ export async function push(ctx, options, input, factory = createSyncBackend) {
|
|
|
120
121
|
return "cancelled";
|
|
121
122
|
}
|
|
122
123
|
const configIdentity = syncCheckConfigFingerprint(config);
|
|
124
|
+
const validateSettings = async () => {
|
|
125
|
+
if (action)
|
|
126
|
+
await validateDirectionalSettings(options, config, validateMutation);
|
|
127
|
+
else if (configIdentity !== syncCheckConfigFingerprint(await loadConfig(options.setup, options.signal)))
|
|
128
|
+
throw new Error("Settings changed during push review.");
|
|
129
|
+
validateMutation();
|
|
130
|
+
};
|
|
131
|
+
const checkUpload = (upload) => {
|
|
132
|
+
if (transferSizeLimitsEnabled(config))
|
|
133
|
+
requireTransferSize(config, selectedPublicationImage(upload, config, snapshotOptions.sessionDir));
|
|
134
|
+
};
|
|
123
135
|
let upload = await snapshotForUpload(backend, config, local, head, remoteForUpload, snapshotOptions);
|
|
124
136
|
if (action) {
|
|
125
137
|
upload = keepProtectedRemoteSessions(config, upload, remoteForUpload, snapshotOptions.sessionDir, reviewedProtectedPaths);
|
|
@@ -127,6 +139,7 @@ export async function push(ctx, options, input, factory = createSyncBackend) {
|
|
|
127
139
|
}
|
|
128
140
|
upload = await withPublishedIgnoreRules(upload, config, options.signal);
|
|
129
141
|
validateMutation();
|
|
142
|
+
checkUpload(upload);
|
|
130
143
|
if (!config.skipSecretScan) {
|
|
131
144
|
const secrets = scanSnapshot({ ...local, ...(upload.ignoreRules ? { ignoreRules: upload.ignoreRules } : {}) });
|
|
132
145
|
if (secrets.length > 0) {
|
|
@@ -165,17 +178,15 @@ export async function push(ctx, options, input, factory = createSyncBackend) {
|
|
|
165
178
|
}
|
|
166
179
|
validateMutation();
|
|
167
180
|
upload = await snapshotForUpload(backend, config, local, head, remoteForUpload, snapshotOptions);
|
|
181
|
+
validateMutation();
|
|
182
|
+
checkUpload(upload);
|
|
168
183
|
if (!(await confirmPush(ctx, options, config, backend, local, upload, head, remoteForUpload, validateMutation, "Remote changed during review. Push the refreshed plan?"))) {
|
|
169
184
|
return "cancelled";
|
|
170
185
|
}
|
|
171
186
|
}
|
|
172
187
|
}
|
|
173
188
|
validateMutation();
|
|
174
|
-
|
|
175
|
-
await validateDirectionalSettings(options, config, validateMutation);
|
|
176
|
-
else if (configIdentity !== syncCheckConfigFingerprint(await loadConfig(options.setup)))
|
|
177
|
-
throw new Error("Settings changed during push review.");
|
|
178
|
-
validateMutation();
|
|
189
|
+
await validateSettings();
|
|
179
190
|
if (!action &&
|
|
180
191
|
(config.scope === "agent-directory" ||
|
|
181
192
|
validateIgnorePolicy ||
|
|
@@ -194,11 +205,7 @@ export async function push(ctx, options, input, factory = createSyncBackend) {
|
|
|
194
205
|
snapshotOptions.sessionDir !== (await effectiveSessionRoot(ctx, config, options.signal)))
|
|
195
206
|
throw new Error("Pi session storage changed during push review.");
|
|
196
207
|
validateMutation();
|
|
197
|
-
|
|
198
|
-
await validateDirectionalSettings(options, config, validateMutation);
|
|
199
|
-
else if (configIdentity !== syncCheckConfigFingerprint(await loadConfig(options.setup)))
|
|
200
|
-
throw new Error("Settings changed during push review.");
|
|
201
|
-
validateMutation();
|
|
208
|
+
await validateSettings();
|
|
202
209
|
const validatePublication = validateIgnorePolicy || options.background || action
|
|
203
210
|
? async () => {
|
|
204
211
|
if (action && !sameRemoteHead(backend, head, await backend.readHead(options.signal)))
|
|
@@ -210,14 +217,9 @@ export async function push(ctx, options, input, factory = createSyncBackend) {
|
|
|
210
217
|
await validateDirectionalSettings(options, config, validateMutation);
|
|
211
218
|
checkLiveProtection(ctx, snapshotOptions.sessionDir, reviewedProtectedPaths);
|
|
212
219
|
}
|
|
213
|
-
: (validateIgnorePolicy ??
|
|
214
|
-
(async () => {
|
|
215
|
-
if (configIdentity !== syncCheckConfigFingerprint(await loadConfig(options.setup, options.signal)))
|
|
216
|
-
throw new Error("Settings changed before push publication.");
|
|
217
|
-
validateMutation();
|
|
218
|
-
})), "push", Boolean(action));
|
|
220
|
+
: (validateIgnorePolicy ?? validateSettings), "push", Boolean(action));
|
|
219
221
|
}
|
|
220
|
-
:
|
|
222
|
+
: validateSettings;
|
|
221
223
|
if (validateIgnorePolicy) {
|
|
222
224
|
validatePortableSnapshot(upload);
|
|
223
225
|
await validateIgnorePolicy();
|
|
@@ -240,7 +242,7 @@ export async function push(ctx, options, input, factory = createSyncBackend) {
|
|
|
240
242
|
startedPublication = true;
|
|
241
243
|
}
|
|
242
244
|
: options.onCommit,
|
|
243
|
-
|
|
245
|
+
validateIgnorePolicy: validatePublication,
|
|
244
246
|
});
|
|
245
247
|
}
|
|
246
248
|
catch (error) {
|
|
@@ -302,6 +304,9 @@ export async function pull(ctx, options, factory = createSyncBackend, initial) {
|
|
|
302
304
|
throw new Error("Single-action Pull cannot be used for initial-source selection.");
|
|
303
305
|
const adoptionReview = !initial && canReviewAdoption(ctx, options);
|
|
304
306
|
const journal = adoptionReview ? await loadAdoptionJournal() : undefined;
|
|
307
|
+
if (action?.expectedAdoptionJournal !== undefined &&
|
|
308
|
+
(!journal || adoptionJournalFingerprint(journal) !== action.expectedAdoptionJournal))
|
|
309
|
+
throw new Error("The recorded Pull changed during recovery. No transfer was started.");
|
|
305
310
|
if (!adoptionReview)
|
|
306
311
|
requireNoPendingAdoption();
|
|
307
312
|
const validateOwner = captureMutationOwner(ctx, options.signal);
|
|
@@ -421,6 +426,9 @@ export async function pull(ctx, options, factory = createSyncBackend, initial) {
|
|
|
421
426
|
if (action || config.scope === "agent-directory")
|
|
422
427
|
requireStableMergeSessionRoot(local, physical, config.scope);
|
|
423
428
|
const reviewedProtectedPaths = protectedSessionPaths(ctx, snapshotOptions.sessionDir);
|
|
429
|
+
const sizeLimited = transferSizeLimitsEnabled(config);
|
|
430
|
+
if (sizeLimited)
|
|
431
|
+
requireTransferSize(config, selectedPullImage(logical, local, reviewedProtectedPaths));
|
|
424
432
|
const remoteChanged = hasRemoteChanges(remote, state, config, reviewedProtectedPaths);
|
|
425
433
|
if (!action && localChanged && remoteChanged && state.lastAppliedSnapshot && !options.force) {
|
|
426
434
|
throw createSyncDecision({
|
|
@@ -516,6 +524,13 @@ export async function pull(ctx, options, factory = createSyncBackend, initial) {
|
|
|
516
524
|
await validateIgnorePolicy();
|
|
517
525
|
}
|
|
518
526
|
const protectedPaths = protectedSessionPaths(ctx, snapshotOptions.sessionDir);
|
|
527
|
+
const validateApplySettings = async () => {
|
|
528
|
+
if (configIdentity !== syncCheckConfigFingerprint(await loadConfig(options.setup, options.signal)))
|
|
529
|
+
throw new Error("Settings changed before pull apply.");
|
|
530
|
+
validateMutation();
|
|
531
|
+
if (sizeLimited)
|
|
532
|
+
checkLiveProtection(ctx, snapshotOptions.sessionDir, reviewedProtectedPaths);
|
|
533
|
+
};
|
|
519
534
|
const applyGuards = directionalApplyGuards({
|
|
520
535
|
ctx,
|
|
521
536
|
config,
|
|
@@ -539,6 +554,7 @@ export async function pull(ctx, options, factory = createSyncBackend, initial) {
|
|
|
539
554
|
await validateActionBoundary?.();
|
|
540
555
|
}
|
|
541
556
|
: validateIgnorePolicy,
|
|
557
|
+
validateSettings: action ? undefined : validateApplySettings,
|
|
542
558
|
effectiveRoot: Boolean(action),
|
|
543
559
|
});
|
|
544
560
|
applyGuards.validateMutation();
|
|
@@ -548,7 +564,9 @@ export async function pull(ctx, options, factory = createSyncBackend, initial) {
|
|
|
548
564
|
...snapshotOptions,
|
|
549
565
|
sessionDir: applySessionDir,
|
|
550
566
|
...applyGuards,
|
|
551
|
-
...(action || config.scope === "agent-directory" || validateIgnorePolicy
|
|
567
|
+
...(action || config.scope === "agent-directory" || validateIgnorePolicy || sizeLimited
|
|
568
|
+
? { reviewedLocal: local }
|
|
569
|
+
: {}),
|
|
552
570
|
expectedFileHashes: config.localFields?.length
|
|
553
571
|
? { "settings.json": fileHashMap(local)["settings.json"] ?? null }
|
|
554
572
|
: undefined,
|
|
@@ -758,31 +776,6 @@ export async function syncBoth(ctx, options, factory = createSyncBackend) {
|
|
|
758
776
|
if (!options.silent)
|
|
759
777
|
ctx.ui.notify("pi-sync is already up to date.", "info");
|
|
760
778
|
}
|
|
761
|
-
async function confirmPush(ctx, options, config, backend, local, upload, head, remote, validateMutation, title = snapshotIncludesSessions(upload) ? "Push pi settings and sessions?" : "Push pi settings?") {
|
|
762
|
-
validateMutation();
|
|
763
|
-
if (options.yes)
|
|
764
|
-
return true;
|
|
765
|
-
const summary = formatPushSummary(config, backend.destination, upload, head, countPreservedRemoteFiles(local, upload), remote);
|
|
766
|
-
const comparison = config.ignorePolicy && remote
|
|
767
|
-
? inspectRemoteSelection(config.include, remote, config.exclude, config).ignorePolicyComparison
|
|
768
|
-
: undefined;
|
|
769
|
-
const notice = ignorePublicationNotice(upload);
|
|
770
|
-
const overwrite = comparison !== undefined && comparison !== "match";
|
|
771
|
-
const confirmed = await confirmTransferReview(ctx, overwrite ? "Overwrite remote policy and push?" : title, formatTransferReview(...(overwrite
|
|
772
|
-
? [
|
|
773
|
-
formatIgnorePolicyComparison(comparison),
|
|
774
|
-
"This replaces the remote policy with this device's rules. Remote rules are not adopted on this device.",
|
|
775
|
-
`Sessions opt-in: ${remote?.selection?.version === 4 ? (remote.selection.sessions ? "on" : "off") : "legacy"} → ${config.ignorePolicy?.sessions ? "on" : "off"}.`,
|
|
776
|
-
formatRuleChanges(remote?.ignoreRules?.text, upload.ignoreRules?.text),
|
|
777
|
-
]
|
|
778
|
-
: []), ...(notice ? [notice, ""] : []), summary), options.signal, validateMutation);
|
|
779
|
-
throwIfAborted(options.signal);
|
|
780
|
-
if (confirmed)
|
|
781
|
-
return true;
|
|
782
|
-
setSyncStatus(ctx, undefined);
|
|
783
|
-
ctx.ui.notify("Push cancelled.", "info");
|
|
784
|
-
return false;
|
|
785
|
-
}
|
|
786
779
|
function matchesInitialHead(initial, backend, current) {
|
|
787
780
|
return sameRemoteHead(backend, initial.head, current);
|
|
788
781
|
}
|
|
@@ -21,7 +21,8 @@ import { PublicationStatePersistenceError, RollbackPublicationError } from "./sy
|
|
|
21
21
|
import { backupLocal, captureMutationOwner, maybeReload, protectedSessionPaths } from "./sync-local.js";
|
|
22
22
|
import { requireLegacyTransferPolicy, syncSessionsSelected } from "./sync-policy.js";
|
|
23
23
|
import { acceptedSelection, fileHashMap, sameHashes } from "./sync-state.js";
|
|
24
|
-
import { directionalApplyGuards, requireIgnoreBaselineReview, requireResolvedDirectionalProgress, validateDirectionalPublication, } from "./transfer-freshness.js";
|
|
24
|
+
import { checkLiveProtection, directionalApplyGuards, requireIgnoreBaselineReview, requireResolvedDirectionalProgress, validateDirectionalPublication, } from "./transfer-freshness.js";
|
|
25
|
+
import { requireTransferSize, selectedPublicationImage, selectedPullImage, transferSizeLimitsEnabled, } from "./transfer-size-limits.js";
|
|
25
26
|
const VERSION = 1;
|
|
26
27
|
const POST_LOCAL_COMMIT_TIMEOUT_MS = 30_000;
|
|
27
28
|
export async function rollback(ctx, options, factory = createSyncBackend, expectedSelection) {
|
|
@@ -86,6 +87,9 @@ export async function rollback(ctx, options, factory = createSyncBackend, expect
|
|
|
86
87
|
const caseCleanup = options.yes ? [] : await inspectCaseCleanup(physical, snapshotOptions);
|
|
87
88
|
validateMutation();
|
|
88
89
|
const reviewedProtectedPaths = protectedSessionPaths(ctx, snapshotOptions.sessionDir);
|
|
90
|
+
const sizeLimited = transferSizeLimitsEnabled(config);
|
|
91
|
+
if (sizeLimited)
|
|
92
|
+
requireTransferSize(config, selectedPullImage(remote, local, reviewedProtectedPaths), selectedPublicationImage(upload, config, snapshotOptions.sessionDir));
|
|
89
93
|
if (!options.yes) {
|
|
90
94
|
const title = snapshotIncludesSessions(remote) ? "Rollback pi settings and sessions?" : "Rollback pi settings?";
|
|
91
95
|
const summary = formatRollbackSummary(config, backend.destination, local, physical, target, reviewedProtectedPaths, caseCleanup.map((item) => item.path));
|
|
@@ -128,6 +132,8 @@ export async function rollback(ctx, options, factory = createSyncBackend, expect
|
|
|
128
132
|
await validateIgnorePolicy();
|
|
129
133
|
}
|
|
130
134
|
const protectedPaths = protectedSessionPaths(ctx, snapshotOptions.sessionDir);
|
|
135
|
+
if (sizeLimited)
|
|
136
|
+
checkLiveProtection(ctx, snapshotOptions.sessionDir, reviewedProtectedPaths);
|
|
131
137
|
const applyGuards = directionalApplyGuards({
|
|
132
138
|
ctx,
|
|
133
139
|
config,
|
|
@@ -140,6 +146,14 @@ export async function rollback(ctx, options, factory = createSyncBackend, expect
|
|
|
140
146
|
onCommit: options.onCommit,
|
|
141
147
|
validateMutation,
|
|
142
148
|
validateIgnorePolicy,
|
|
149
|
+
validateSettings: async () => {
|
|
150
|
+
if (syncCheckConfigFingerprint(config) !==
|
|
151
|
+
syncCheckConfigFingerprint(await loadConfig(options.setup, options.signal)))
|
|
152
|
+
throw new Error("Settings changed before rollback apply.");
|
|
153
|
+
validateMutation();
|
|
154
|
+
if (sizeLimited)
|
|
155
|
+
checkLiveProtection(ctx, snapshotOptions.sessionDir, reviewedProtectedPaths);
|
|
156
|
+
},
|
|
143
157
|
});
|
|
144
158
|
applyGuards.validateMutation();
|
|
145
159
|
if (!validateIgnorePolicy)
|
|
@@ -148,7 +162,7 @@ export async function rollback(ctx, options, factory = createSyncBackend, expect
|
|
|
148
162
|
...snapshotOptions,
|
|
149
163
|
sessionDir: applySessionDir,
|
|
150
164
|
...applyGuards,
|
|
151
|
-
...(config.scope === "agent-directory" || validateIgnorePolicy ? { reviewedLocal: local } : {}),
|
|
165
|
+
...(config.scope === "agent-directory" || validateIgnorePolicy || sizeLimited ? { reviewedLocal: local } : {}),
|
|
152
166
|
expectedFileHashes: config.localFields?.length
|
|
153
167
|
? { "settings.json": fileHashMap(local)["settings.json"] ?? null }
|
|
154
168
|
: undefined,
|
|
@@ -38,9 +38,9 @@ export function checkLiveProtection(ctx, sessionDir, reviewed) {
|
|
|
38
38
|
if (current.size !== reviewed.size || [...current].some((item) => !reviewed.has(item)))
|
|
39
39
|
throw new StaleIgnorePolicyError("Live session protection changed during review; reopen the review.");
|
|
40
40
|
}
|
|
41
|
-
export function directionalApplyGuards({ ctx, config, backend, state, sessionDir, head, protectedPaths, signal, validateMutation, validateIgnorePolicy, onCommit, effectiveRoot = false, }) {
|
|
41
|
+
export function directionalApplyGuards({ ctx, config, backend, state, sessionDir, head, protectedPaths, signal, validateMutation, validateIgnorePolicy, validateSettings, onCommit, effectiveRoot = false, }) {
|
|
42
42
|
if (!validateIgnorePolicy)
|
|
43
|
-
return { validateMutation };
|
|
43
|
+
return { validateMutation, validateApplyReview: validateSettings };
|
|
44
44
|
const validateOwner = () => {
|
|
45
45
|
validateMutation();
|
|
46
46
|
checkLiveProtection(ctx, sessionDir, protectedPaths);
|
|
@@ -58,6 +58,7 @@ export function directionalApplyGuards({ ctx, config, backend, state, sessionDir
|
|
|
58
58
|
? await effectiveSessionRoot(ctx, config, signal)
|
|
59
59
|
: (await resolvedSnapshotOptionsForContext(ctx, config, signal)).sessionDir))
|
|
60
60
|
throw new StaleIgnorePolicyError("Pi session storage changed before local apply; reopen the review.");
|
|
61
|
+
await validateSettings?.();
|
|
61
62
|
await validateIgnorePolicy();
|
|
62
63
|
validateOwner();
|
|
63
64
|
if (!committed) {
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { parentPaths } from "../paths.js";
|
|
2
|
+
import { filterSnapshotForConfigPolicy } from "../snapshot/snapshot.js";
|
|
3
|
+
import { snapshotBase64Size } from "../snapshot/snapshot-payload.js";
|
|
4
|
+
import { snapshotPathLabel } from "../ui/terminal-text.js";
|
|
5
|
+
import { TransferSizeError } from "./continuous-errors.js";
|
|
6
|
+
const MIB = 1024 ** 2;
|
|
7
|
+
const MAX_FINDINGS = 8;
|
|
8
|
+
export function transferSizeLimitsEnabled(config) {
|
|
9
|
+
return config.maxFileSizeMiB !== undefined || config.maxDirectorySizeMiB !== undefined;
|
|
10
|
+
}
|
|
11
|
+
export function selectedPublicationImage(snapshot, config, sessionDir) {
|
|
12
|
+
return {
|
|
13
|
+
side: "Remote",
|
|
14
|
+
files: filterSnapshotForConfigPolicy(snapshot, config, { sessionDir }).files,
|
|
15
|
+
ignoreRules: snapshot.ignoreRules,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export function selectedPullImage(incoming, local, protectedPaths, ignoreRules) {
|
|
19
|
+
return {
|
|
20
|
+
side: "Local",
|
|
21
|
+
files: protectedPaths.size
|
|
22
|
+
? [
|
|
23
|
+
...incoming.files.filter((file) => !protectedPaths.has(file.path)),
|
|
24
|
+
...local.files.filter((file) => protectedPaths.has(file.path)),
|
|
25
|
+
]
|
|
26
|
+
: incoming.files,
|
|
27
|
+
ignoreRules,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function compareFindings(a, b) {
|
|
31
|
+
if (a.side !== b.side)
|
|
32
|
+
return a.side < b.side ? -1 : 1;
|
|
33
|
+
if (a.path !== b.path)
|
|
34
|
+
return a.path < b.path ? -1 : 1;
|
|
35
|
+
return a.kind === b.kind ? 0 : a.kind < b.kind ? -1 : 1;
|
|
36
|
+
}
|
|
37
|
+
export function transferSizeDetails(config, images) {
|
|
38
|
+
if (!transferSizeLimitsEnabled(config))
|
|
39
|
+
return;
|
|
40
|
+
const fileLimit = (config.maxFileSizeMiB ?? Infinity) * MIB;
|
|
41
|
+
const directoryLimit = (config.maxDirectorySizeMiB ?? Infinity) * MIB;
|
|
42
|
+
const findings = [];
|
|
43
|
+
let count = 0;
|
|
44
|
+
for (const { side, files, ignoreRules } of images) {
|
|
45
|
+
const directories = new Map();
|
|
46
|
+
const seen = new Set();
|
|
47
|
+
const measure = (path, size, kind, limit) => {
|
|
48
|
+
if (size <= limit)
|
|
49
|
+
return;
|
|
50
|
+
count++;
|
|
51
|
+
const finding = { side, path, size, kind, limit };
|
|
52
|
+
if (findings.length === MAX_FINDINGS && compareFindings(finding, findings[MAX_FINDINGS - 1]) >= 0)
|
|
53
|
+
return;
|
|
54
|
+
findings.push(finding);
|
|
55
|
+
findings.sort(compareFindings);
|
|
56
|
+
if (findings.length > MAX_FINDINGS)
|
|
57
|
+
findings.pop();
|
|
58
|
+
};
|
|
59
|
+
const measureFile = (path, size) => {
|
|
60
|
+
if (seen.has(path))
|
|
61
|
+
return;
|
|
62
|
+
seen.add(path);
|
|
63
|
+
measure(path, size, "file", fileLimit);
|
|
64
|
+
if (directoryLimit !== Infinity)
|
|
65
|
+
for (const parent of parentPaths(path))
|
|
66
|
+
directories.set(parent, (directories.get(parent) ?? 0) + size);
|
|
67
|
+
};
|
|
68
|
+
if (ignoreRules)
|
|
69
|
+
measureFile(ignoreRules.filename, Buffer.byteLength(ignoreRules.text, "utf8"));
|
|
70
|
+
for (const file of files)
|
|
71
|
+
measureFile(file.path, snapshotBase64Size(file.contentBase64, file.path));
|
|
72
|
+
for (const [path, size] of directories)
|
|
73
|
+
measure(path, size, "directory", directoryLimit);
|
|
74
|
+
}
|
|
75
|
+
if (!count)
|
|
76
|
+
return;
|
|
77
|
+
const omitted = count - findings.length;
|
|
78
|
+
return [
|
|
79
|
+
...findings.map(({ path, side, size, kind, limit }) => {
|
|
80
|
+
const label = JSON.stringify(snapshotPathLabel(path.slice(0, 160))).slice(1, -1);
|
|
81
|
+
const shortened = path.length > 160 || label.length > 240;
|
|
82
|
+
return `${side} ${kind} "${label.slice(0, 240)}${shortened ? "…" : ""}": ${size} bytes (limit ${limit} bytes).`;
|
|
83
|
+
}),
|
|
84
|
+
...(omitted ? [`${omitted} additional ${omitted === 1 ? "finding" : "findings"} omitted.`] : []),
|
|
85
|
+
`Use /sync diff, adjust ${config.pathPolicy === "ignore-file" ? ".syncignore (or your configured rule file)" : "exclusions in /sync → Settings"}, then review a Push or Pull.`,
|
|
86
|
+
].join(" ");
|
|
87
|
+
}
|
|
88
|
+
export function requireTransferSize(config, ...images) {
|
|
89
|
+
const details = transferSizeDetails(config, images);
|
|
90
|
+
if (details)
|
|
91
|
+
throw new TransferSizeError(`Transfer blocked by size limits. ${details}`);
|
|
92
|
+
}
|
|
@@ -433,17 +433,22 @@ async function runForegroundDirectional(host, execution, ctx, direction, payload
|
|
|
433
433
|
!ctx.hasUI ||
|
|
434
434
|
!["tui", "rpc"].includes(ctx.mode) ||
|
|
435
435
|
!record(payload) ||
|
|
436
|
-
Object.keys(payload).some((key) => !["setup", "fingerprint", "retryCheckpoint"].includes(key)) ||
|
|
436
|
+
Object.keys(payload).some((key) => !["setup", "fingerprint", "retryCheckpoint", "retryAdoptionJournal"].includes(key)) ||
|
|
437
437
|
typeof payload.setup !== "string" ||
|
|
438
438
|
!payload.setup ||
|
|
439
439
|
payload.setup.length > 512 ||
|
|
440
440
|
typeof payload.fingerprint !== "string" ||
|
|
441
441
|
!fingerprintPattern.test(payload.fingerprint) ||
|
|
442
442
|
(payload.retryCheckpoint !== undefined &&
|
|
443
|
-
(typeof payload.retryCheckpoint !== "string" || !fingerprintPattern.test(payload.retryCheckpoint)))
|
|
443
|
+
(typeof payload.retryCheckpoint !== "string" || !fingerprintPattern.test(payload.retryCheckpoint))) ||
|
|
444
|
+
(payload.retryAdoptionJournal !== undefined &&
|
|
445
|
+
(direction !== "pull" ||
|
|
446
|
+
payload.retryCheckpoint !== undefined ||
|
|
447
|
+
typeof payload.retryAdoptionJournal !== "string" ||
|
|
448
|
+
!fingerprintPattern.test(payload.retryAdoptionJournal)))) {
|
|
444
449
|
throw new Error("Invalid foreground directional request.");
|
|
445
450
|
}
|
|
446
|
-
const { setup, fingerprint, retryCheckpoint } = payload;
|
|
451
|
+
const { setup, fingerprint, retryCheckpoint, retryAdoptionJournal } = payload;
|
|
447
452
|
const { withStateDirectoryAccess } = await import("./engine/state/state-directory.js");
|
|
448
453
|
const { withLock } = await import("./engine/state/lock.js");
|
|
449
454
|
const { loadConfigForCheck, syncCheckConfigFingerprint } = await import("./engine/settings/config.js");
|
|
@@ -456,7 +461,7 @@ async function runForegroundDirectional(host, execution, ctx, direction, payload
|
|
|
456
461
|
execution.validate();
|
|
457
462
|
return withStateDirectoryAccess(async () => {
|
|
458
463
|
validate(await loadConfigForCheck(undefined, execution.signal));
|
|
459
|
-
if (retryCheckpoint === undefined) {
|
|
464
|
+
if (retryCheckpoint === undefined && retryAdoptionJournal === undefined) {
|
|
460
465
|
await requireHandover(execution);
|
|
461
466
|
validate(await loadConfigForCheck(undefined, execution.signal));
|
|
462
467
|
await initialize(ctx, execution, false);
|
|
@@ -466,18 +471,29 @@ async function runForegroundDirectional(host, execution, ctx, direction, payload
|
|
|
466
471
|
throw new Error("Daemon handover is no longer valid; the transfer was not replayed.");
|
|
467
472
|
await requireStartupRecoveryCleared(execution);
|
|
468
473
|
}
|
|
469
|
-
return host.runForeground(execution, () => withLock(direction, async () => {
|
|
474
|
+
return host.runForeground(execution, (setAdoptionResume) => withLock(direction, async () => {
|
|
470
475
|
validate(await loadConfigForCheck(undefined, execution.signal));
|
|
471
476
|
let message;
|
|
477
|
+
let adoptionRecovery = false;
|
|
472
478
|
const outcome = await operations[direction](ctx, {
|
|
473
479
|
...optionsFrom({ setup, args: [] }, execution, false),
|
|
474
480
|
directionalAction: {
|
|
475
481
|
validate,
|
|
482
|
+
expectedAdoptionJournal: retryAdoptionJournal,
|
|
483
|
+
setAdoptionResume(journal) {
|
|
484
|
+
if (adoptionRecovery)
|
|
485
|
+
setAdoptionResume(journal);
|
|
486
|
+
},
|
|
476
487
|
async checkpoint(current) {
|
|
477
488
|
execution.validate();
|
|
478
489
|
if (retryCheckpoint !== undefined && retryCheckpoint !== current)
|
|
479
490
|
throw new Error("The transfer source or destination changed during recovery. The transfer was not replayed.");
|
|
480
|
-
|
|
491
|
+
const accepted = await execution.request("directional-checkpoint", {
|
|
492
|
+
fingerprint: current,
|
|
493
|
+
...(direction === "pull" ? { adoptionRecovery: 1 } : {}),
|
|
494
|
+
});
|
|
495
|
+
adoptionRecovery = direction === "pull" && record(accepted) && accepted.adoptionRecovery === 1;
|
|
496
|
+
if (accepted !== true && !adoptionRecovery)
|
|
481
497
|
throw new Error("The original transfer could not be retained for recovery. No transfer was started.");
|
|
482
498
|
execution.validate();
|
|
483
499
|
},
|
|
@@ -5,5 +5,9 @@ export function isForegroundQueueOutcome(value) {
|
|
|
5
5
|
if (!value || typeof value !== "object" || !("foregroundQueueCleanup" in value))
|
|
6
6
|
return false;
|
|
7
7
|
return (value.foregroundQueueCleanup === "before-mutation" ||
|
|
8
|
+
(value.foregroundQueueCleanup === "resume-adoption" &&
|
|
9
|
+
"journal" in value &&
|
|
10
|
+
typeof value.journal === "string" &&
|
|
11
|
+
/^[a-f0-9]{64}$/u.test(value.journal)) ||
|
|
8
12
|
(value.foregroundQueueCleanup === "verified-result" && Object.hasOwn(value, "result")));
|
|
9
13
|
}
|
|
@@ -402,7 +402,8 @@ export async function startServer(root, execute, hooks = {}) {
|
|
|
402
402
|
if (Buffer.byteLength(JSON.stringify(result ?? null)) > MAX_MESSAGE_BYTES / 2)
|
|
403
403
|
throw new Error("Operation result exceeds its byte limit; use bounded inspection.");
|
|
404
404
|
if (isForegroundDirection(operation) && isForegroundQueueOutcome(result)) {
|
|
405
|
-
if (result.foregroundQueueCleanup === "before-mutation" && job.committed)
|
|
405
|
+
if ((result.foregroundQueueCleanup === "before-mutation" && job.committed) ||
|
|
406
|
+
(result.foregroundQueueCleanup === "resume-adoption" && (!job.committed || operation !== "pull.foreground")))
|
|
406
407
|
throw Object.assign(new Error("File-queue release and transfer outcome could not be verified."), {
|
|
407
408
|
code: OWNERSHIP_CLEANUP_REQUIRED,
|
|
408
409
|
});
|
|
@@ -155,9 +155,12 @@ export function installServiceHost(root, ignoreFileOperationsAvailable) {
|
|
|
155
155
|
if (owner.execution !== execution || !execution.clientId || owner.held.size || owner.foreground)
|
|
156
156
|
throw new Error("Foreground queue recovery requires one attached directional job.");
|
|
157
157
|
const foreground = { entered: false, deferred: false };
|
|
158
|
+
let adoptionResume;
|
|
158
159
|
return scope.run({ ...owner, foreground }, async () => {
|
|
159
160
|
try {
|
|
160
|
-
const result = await action()
|
|
161
|
+
const result = await action((journal) => {
|
|
162
|
+
adoptionResume = journal;
|
|
163
|
+
});
|
|
161
164
|
if (foreground.deferred && poisoned === "queue")
|
|
162
165
|
return { foregroundQueueCleanup: "verified-result", result };
|
|
163
166
|
return result;
|
|
@@ -167,7 +170,9 @@ export function installServiceHost(root, ignoreFileOperationsAvailable) {
|
|
|
167
170
|
!execution.signal.aborted &&
|
|
168
171
|
error instanceof AggregateError &&
|
|
169
172
|
error.errors.includes(foreground.beforeMutation))
|
|
170
|
-
return
|
|
173
|
+
return adoptionResume === undefined
|
|
174
|
+
? { foregroundQueueCleanup: "before-mutation" }
|
|
175
|
+
: { foregroundQueueCleanup: "resume-adoption", journal: adoptionResume };
|
|
171
176
|
if (foreground.deferred && !(error instanceof OwnershipCleanupError)) {
|
|
172
177
|
const detail = error instanceof Error ? ` ${error.message}` : "";
|
|
173
178
|
throw new OwnershipCleanupError(`File-queue release was not confirmed.${detail}`, { cause: error });
|
package/dist/daemon/package.json
CHANGED
package/dist/index.ts
CHANGED
|
@@ -7,11 +7,22 @@ import {
|
|
|
7
7
|
createSyncAttentionController,
|
|
8
8
|
readStateForConfig,
|
|
9
9
|
syncStateFingerprint
|
|
10
|
-
} from "./chunks/chunk-
|
|
10
|
+
} from "./chunks/chunk-3Q3DMMID.ts";
|
|
11
|
+
import {
|
|
12
|
+
bindPiDaemonClient,
|
|
13
|
+
installPiDaemonHost,
|
|
14
|
+
piDaemonClient,
|
|
15
|
+
withPiDaemonClient
|
|
16
|
+
} from "./chunks/chunk-XPKHWTGT.ts";
|
|
11
17
|
import {
|
|
12
18
|
combineSignals,
|
|
13
19
|
throwIfAborted
|
|
14
20
|
} from "./chunks/chunk-UMPA5S7X.ts";
|
|
21
|
+
import {
|
|
22
|
+
configureSyncStatus,
|
|
23
|
+
createSyncStatusPublisher,
|
|
24
|
+
setSyncStatus
|
|
25
|
+
} from "./chunks/chunk-H7VOTY5N.ts";
|
|
15
26
|
import {
|
|
16
27
|
completeSyncArguments,
|
|
17
28
|
setSyncSetupCompletions,
|
|
@@ -20,32 +31,21 @@ import {
|
|
|
20
31
|
import {
|
|
21
32
|
withStateDirectoryAccess
|
|
22
33
|
} from "./chunks/chunk-T3LABNHF.ts";
|
|
34
|
+
import {
|
|
35
|
+
errorMessage
|
|
36
|
+
} from "./chunks/chunk-6YKOHBSC.ts";
|
|
23
37
|
import {
|
|
24
38
|
snapshotOptionsForContext
|
|
25
39
|
} from "./chunks/chunk-P4GI7LTT.ts";
|
|
26
40
|
import "./chunks/chunk-ZO52JM4H.ts";
|
|
41
|
+
import {
|
|
42
|
+
syncSessionsSelected
|
|
43
|
+
} from "./chunks/chunk-R3SAMXB6.ts";
|
|
27
44
|
import {
|
|
28
45
|
configFromSettings,
|
|
29
46
|
loadConfigForCheck,
|
|
30
47
|
syncCheckConfigFingerprint
|
|
31
|
-
} from "./chunks/chunk-
|
|
32
|
-
import {
|
|
33
|
-
bindPiDaemonClient,
|
|
34
|
-
installPiDaemonHost,
|
|
35
|
-
piDaemonClient,
|
|
36
|
-
withPiDaemonClient
|
|
37
|
-
} from "./chunks/chunk-JQ5BAWW2.ts";
|
|
38
|
-
import {
|
|
39
|
-
configureSyncStatus,
|
|
40
|
-
createSyncStatusPublisher,
|
|
41
|
-
setSyncStatus
|
|
42
|
-
} from "./chunks/chunk-H7VOTY5N.ts";
|
|
43
|
-
import {
|
|
44
|
-
errorMessage
|
|
45
|
-
} from "./chunks/chunk-6YKOHBSC.ts";
|
|
46
|
-
import {
|
|
47
|
-
syncSessionsSelected
|
|
48
|
-
} from "./chunks/chunk-R3SAMXB6.ts";
|
|
48
|
+
} from "./chunks/chunk-3NS4PMCI.ts";
|
|
49
49
|
import {
|
|
50
50
|
safeTerminalText
|
|
51
51
|
} from "./chunks/chunk-2JNFEZ3V.ts";
|
|
@@ -334,12 +334,12 @@ function createStartupCheck(loaders, attention, timeoutMs = 3e4, publish) {
|
|
|
334
334
|
// src/sync/sync-loaders.ts
|
|
335
335
|
function createSyncLoaders(dependencies) {
|
|
336
336
|
const loaders = {
|
|
337
|
-
commands: cachedModuleLoader(dependencies.loadCommandHandler ?? (() => import("./chunks/command-handler-
|
|
338
|
-
inspection: cachedModuleLoader(dependencies.loadSyncInspection ?? (() => import("./chunks/sync-inspection-
|
|
339
|
-
setupSwitch: cachedModuleLoader(dependencies.loadSetupSwitch ?? (() => import("./chunks/setup-switch-
|
|
337
|
+
commands: cachedModuleLoader(dependencies.loadCommandHandler ?? (() => import("./chunks/command-handler-H5X3BX5D.ts"))),
|
|
338
|
+
inspection: cachedModuleLoader(dependencies.loadSyncInspection ?? (() => import("./chunks/sync-inspection-S2GHDBAD.ts"))),
|
|
339
|
+
setupSwitch: cachedModuleLoader(dependencies.loadSetupSwitch ?? (() => import("./chunks/setup-switch-JZDFQPVW.ts"))),
|
|
340
340
|
snapshot: cachedModuleLoader(dependencies.loadSnapshot ?? (() => import("./chunks/snapshot-ZUJJZCFW.ts"))),
|
|
341
341
|
syncState: cachedModuleLoader(dependencies.loadSyncState ?? (() => import("./chunks/sync-state-QIT64TKV.ts"))),
|
|
342
|
-
operations: cachedModuleLoader(dependencies.loadSyncOperations ?? (() => import("./chunks/sync-operations-
|
|
342
|
+
operations: cachedModuleLoader(dependencies.loadSyncOperations ?? (() => import("./chunks/sync-operations-LQ63CU2T.ts")))
|
|
343
343
|
};
|
|
344
344
|
return loaders;
|
|
345
345
|
}
|
|
@@ -426,15 +426,24 @@ function sync(pi, dependencies = {}) {
|
|
|
426
426
|
}
|
|
427
427
|
const commands = await loaders.commands();
|
|
428
428
|
if (signal.aborted || owner !== client) return;
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
429
|
+
const recoveryMenu = !command && client.pendingPullReview;
|
|
430
|
+
if (recoveryMenu) await client.setBusy("command", true, false);
|
|
431
|
+
try {
|
|
432
|
+
if (signal.aborted || owner !== client) return;
|
|
433
|
+
await commands.handleCommand(
|
|
434
|
+
args,
|
|
435
|
+
ctx2,
|
|
436
|
+
commandSignal,
|
|
437
|
+
loaders,
|
|
438
|
+
attention,
|
|
439
|
+
void 0,
|
|
440
|
+
needsDaemonRecovery
|
|
441
|
+
);
|
|
442
|
+
} finally {
|
|
443
|
+
if (recoveryMenu && !signal.aborted && owner === client)
|
|
444
|
+
await client.setBusy("command", false, !needsDaemonRecovery()).catch(() => {
|
|
445
|
+
});
|
|
446
|
+
}
|
|
438
447
|
return;
|
|
439
448
|
}
|
|
440
449
|
const requiresContact = !["help", "unlock", "migrate-state"].includes(command ?? "");
|