@narumitw/pi-sync 0.67.2 → 0.68.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 +17 -0
- package/README.md +29 -49
- package/dist/chunks/{chunk-XUZV4OGI.ts → chunk-335XTMMZ.ts} +3 -2
- package/dist/chunks/{chunk-XUZV4OGI.ts.map → chunk-335XTMMZ.ts.map} +2 -2
- package/dist/chunks/{chunk-PUSMSKIM.ts → chunk-AYGMIMCV.ts} +2 -11
- package/dist/chunks/chunk-AYGMIMCV.ts.map +7 -0
- package/dist/chunks/{chunk-2MSJDLSM.ts → chunk-BCDBT4X3.ts} +7 -7
- package/dist/chunks/{chunk-GRXNUC6O.ts → chunk-FQKWGVMA.ts} +20 -54
- package/dist/chunks/chunk-FQKWGVMA.ts.map +7 -0
- package/dist/chunks/{chunk-DGVZYS7T.ts → chunk-FR6A7ASZ.ts} +8 -11
- package/dist/chunks/chunk-FR6A7ASZ.ts.map +7 -0
- package/dist/chunks/{chunk-3NS4PMCI.ts → chunk-J52GYZO6.ts} +2 -8
- package/dist/chunks/{chunk-3NS4PMCI.ts.map → chunk-J52GYZO6.ts.map} +2 -2
- package/dist/chunks/{chunk-2MUAR5GH.ts → chunk-KAIVTJIQ.ts} +7 -10
- package/dist/chunks/chunk-KAIVTJIQ.ts.map +7 -0
- package/dist/chunks/{chunk-WBIOSK76.ts → chunk-R7PN3KIY.ts} +1 -2
- package/dist/chunks/{chunk-3Q3DMMID.ts → chunk-TLYT6HVI.ts} +8 -8
- package/dist/chunks/{chunk-UF2HU2NM.ts → chunk-WCGLU526.ts} +39 -118
- package/dist/chunks/chunk-WCGLU526.ts.map +7 -0
- package/dist/chunks/{chunk-JREGWM2B.ts → chunk-XNUARYLR.ts} +1 -2
- package/dist/chunks/{chunk-C3E75DXW.ts → chunk-YV2R5SJU.ts} +73 -85
- package/dist/chunks/chunk-YV2R5SJU.ts.map +7 -0
- package/dist/chunks/{command-handler-HWRPH3K3.ts → command-handler-S6BRZMPW.ts} +117 -69
- package/dist/chunks/command-handler-S6BRZMPW.ts.map +7 -0
- package/dist/chunks/{conflict-review-OBBBSVQD.ts → conflict-review-3XMYDJIK.ts} +2 -2
- package/dist/chunks/{file-selection-GASCVN45.ts → file-selection-4BOQBXS7.ts} +10 -17
- package/dist/chunks/file-selection-4BOQBXS7.ts.map +7 -0
- package/dist/chunks/{manager-result-dispatcher-MJ6G2CEI.ts → manager-result-dispatcher-A4IWLS4J.ts} +7 -7
- package/dist/chunks/{manager-ui-Z3B5ZTA6.ts → manager-ui-KHMCSLLV.ts} +114 -581
- package/dist/chunks/manager-ui-KHMCSLLV.ts.map +7 -0
- package/dist/chunks/{chunk-ECUCXF5Y.ts → merge-review-LWMUE5IW.ts} +2 -3
- package/dist/chunks/{remote-selection-ui-34WC7OFE.ts → remote-selection-ui-F6NJBQ3Y.ts} +6 -6
- package/dist/chunks/{setup-switch-JZDFQPVW.ts → setup-switch-7LMIRMZ7.ts} +6 -6
- package/dist/chunks/{setup-wizard-YOXLXLBY.ts → setup-wizard-2NRPR433.ts} +11 -16
- package/dist/chunks/{setup-wizard-YOXLXLBY.ts.map → setup-wizard-2NRPR433.ts.map} +1 -1
- package/dist/chunks/{sync-inspection-NIITROKS.ts → sync-inspection-QGM54YCM.ts} +5 -5
- package/dist/chunks/{sync-operations-FFI4ZZQL.ts → sync-operations-DTQMKVRQ.ts} +2 -2
- package/dist/daemon/dist/build-id.json +1 -0
- package/dist/daemon/dist/build-version.js +24 -4
- package/dist/daemon/dist/cli.js +51 -67
- package/dist/daemon/dist/client-transport.js +15 -5
- package/dist/daemon/dist/client.js +2 -10
- package/dist/daemon/dist/consent.js +13 -126
- package/dist/daemon/dist/daemon-startup.js +135 -30
- package/dist/daemon/dist/daemon-status.js +56 -0
- package/dist/daemon/dist/engine/backends/git/git-backend.js +4 -17
- package/dist/daemon/dist/engine/backends/git/git-storage.js +11 -44
- package/dist/daemon/dist/engine/backends/s3/s3-backend.js +6 -6
- package/dist/daemon/dist/engine/backends/webdav/webdav-backend.js +6 -6
- package/dist/daemon/dist/engine/settings/config.js +16 -149
- package/dist/daemon/dist/engine/settings/retired-ignore-policy.js +16 -0
- package/dist/daemon/dist/engine/settings/retired-ignore-recovery.js +14 -0
- package/dist/daemon/dist/engine/settings/settings-management.js +2 -10
- package/dist/daemon/dist/engine/settings/settings-validation.js +8 -21
- package/dist/daemon/dist/engine/snapshot/session-paths.js +13 -41
- package/dist/daemon/dist/engine/snapshot/snapshot-apply.js +8 -24
- package/dist/daemon/dist/engine/snapshot/snapshot-codec.js +7 -11
- package/dist/daemon/dist/engine/snapshot/snapshot-exclude-safety.js +19 -76
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction-images.js +1 -7
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction-policy.js +8 -102
- package/dist/daemon/dist/engine/snapshot/snapshot-transaction.js +20 -100
- package/dist/daemon/dist/engine/snapshot/snapshot-types.js +1 -11
- package/dist/daemon/dist/engine/snapshot/snapshot.js +26 -78
- package/dist/daemon/dist/engine/state/sync-state-store.js +5 -1
- package/dist/daemon/dist/engine/sync/agent-plan.js +0 -1
- package/dist/daemon/dist/engine/sync/agent-policy.js +1 -1
- package/dist/daemon/dist/engine/sync/conflict-review.js +0 -2
- package/dist/daemon/dist/engine/sync/continuous-sync.js +2 -17
- package/dist/daemon/dist/engine/sync/continuous-watch.js +3 -7
- package/dist/daemon/dist/engine/sync/directional-action.js +3 -21
- package/dist/daemon/dist/engine/sync/initialization.js +4 -15
- package/dist/daemon/dist/engine/sync/local-fields.js +4 -65
- package/dist/daemon/dist/engine/sync/merge-apply.js +8 -31
- package/dist/daemon/dist/engine/sync/merge-journal.js +8 -118
- package/dist/daemon/dist/engine/sync/merged-sync.js +13 -70
- package/dist/daemon/dist/engine/sync/push-review.js +1 -16
- package/dist/daemon/dist/engine/sync/remote-snapshot.js +48 -65
- package/dist/daemon/dist/engine/sync/startup-bootstrap.js +3 -3
- package/dist/daemon/dist/engine/sync/sync-error-guidance.js +1 -1
- package/dist/daemon/dist/engine/sync/sync-inspection.js +1 -2
- package/dist/daemon/dist/engine/sync/sync-mutations.js +26 -118
- package/dist/daemon/dist/engine/sync/sync-policy.js +26 -150
- package/dist/daemon/dist/engine/sync/sync-queries.js +1 -8
- package/dist/daemon/dist/engine/sync/sync-rollback.js +12 -50
- package/dist/daemon/dist/engine/sync/sync-state.js +2 -15
- package/dist/daemon/dist/engine/sync/transfer-freshness.js +7 -17
- package/dist/daemon/dist/engine/sync/transfer-size-limits.js +3 -7
- package/dist/daemon/dist/engine-service.js +62 -205
- package/dist/daemon/dist/foreground-queue-outcome.js +0 -4
- package/dist/daemon/dist/index.js +2 -0
- package/dist/daemon/dist/legacy-consent-guard.js +34 -0
- package/dist/daemon/dist/server.js +99 -11
- package/dist/daemon/dist/service-host.js +3 -9
- package/dist/daemon/package.json +1 -1
- package/dist/index.ts +49 -49
- package/dist/index.ts.map +3 -3
- package/docs/agent-continuous-hardening.md +2 -0
- package/docs/continuous-sync-verification.md +1 -1
- package/docs/daemon-migration.md +17 -15
- package/docs/tui-contract.md +4 -6
- package/package.json +2 -3
- package/skills/configure-pi-sync/SKILL.md +23 -78
- package/skills/configure-pi-sync/references/configuration.md +59 -76
- package/src/commands/command-execution.ts +15 -38
- package/src/commands/command-handler.ts +0 -4
- package/src/commands/command.ts +2 -1
- package/src/daemon/daemon-status-ui.ts +64 -0
- package/src/daemon/directional-recovery.ts +4 -33
- package/src/daemon/pi-client.ts +87 -94
- package/src/settings/config.ts +0 -1
- package/src/sync/setup-switch.ts +1 -4
- package/src/sync-extension.ts +14 -27
- package/src/ui/cancellable-operation.ts +2 -13
- package/src/ui/excluded-paths-ui.ts +1 -4
- package/src/ui/file-selection.ts +0 -5
- package/src/ui/manager-state.ts +12 -75
- package/src/ui/manager-ui.ts +7 -96
- package/src/ui/remote-selection-ui.ts +29 -130
- package/src/ui/settings-ui.ts +169 -388
- package/src/ui/setup/setup-actions.ts +4 -16
- package/src/ui/setup/setup-prompts.ts +12 -49
- package/src/ui/setup/setup-switcher.ts +8 -14
- package/src/ui/storage-connections-ui.ts +21 -32
- package/src/ui/sync-setups-ui.ts +27 -53
- package/dist/chunks/chunk-2MUAR5GH.ts.map +0 -7
- package/dist/chunks/chunk-C3E75DXW.ts.map +0 -7
- package/dist/chunks/chunk-DGVZYS7T.ts.map +0 -7
- package/dist/chunks/chunk-EJDDRS6O.ts +0 -17
- package/dist/chunks/chunk-EJDDRS6O.ts.map +0 -7
- package/dist/chunks/chunk-GRXNUC6O.ts.map +0 -7
- package/dist/chunks/chunk-I72HGZJJ.ts +0 -106
- package/dist/chunks/chunk-I72HGZJJ.ts.map +0 -7
- package/dist/chunks/chunk-KNEUL4XN.ts +0 -30
- package/dist/chunks/chunk-KNEUL4XN.ts.map +0 -7
- package/dist/chunks/chunk-PUSMSKIM.ts.map +0 -7
- package/dist/chunks/chunk-UF2HU2NM.ts.map +0 -7
- package/dist/chunks/chunk-WFBHWYI6.ts +0 -18
- package/dist/chunks/chunk-WFBHWYI6.ts.map +0 -7
- package/dist/chunks/command-handler-HWRPH3K3.ts.map +0 -7
- package/dist/chunks/config-P54GGMXY.ts +0 -39
- package/dist/chunks/continuous-record-3SKJ6I3V.ts +0 -23
- package/dist/chunks/continuous-record-3SKJ6I3V.ts.map +0 -7
- package/dist/chunks/continuous-storage-3EU6I7Z3.ts +0 -27
- package/dist/chunks/continuous-storage-3EU6I7Z3.ts.map +0 -7
- package/dist/chunks/file-selection-GASCVN45.ts.map +0 -7
- package/dist/chunks/ignore-file-ui-5BWA6LBC.ts +0 -21
- package/dist/chunks/manager-ui-Z3B5ZTA6.ts.map +0 -7
- package/dist/chunks/merge-review-C2KETZKY.ts +0 -11
- package/dist/chunks/merge-review-C2KETZKY.ts.map +0 -7
- package/dist/chunks/remote-selection-ui-34WC7OFE.ts.map +0 -7
- package/dist/chunks/setup-switch-JZDFQPVW.ts.map +0 -7
- package/dist/daemon/dist/engine/ignore/adoption-journal.js +0 -146
- package/dist/daemon/dist/engine/ignore/effective-ignore-policy.js +0 -33
- package/dist/daemon/dist/engine/ignore/ignore-edit.js +0 -102
- package/dist/daemon/dist/engine/ignore/ignore-initialization.js +0 -288
- package/dist/daemon/dist/engine/ignore/ignore-migration-prompt.js +0 -139
- package/dist/daemon/dist/engine/ignore/ignore-settings.js +0 -391
- package/dist/daemon/dist/engine/ignore/ignore-source.js +0 -250
- package/dist/daemon/dist/engine/ignore/snapshot-ignore-rules.js +0 -39
- package/dist/daemon/dist/engine/sync/ignore-adoption-recovery.js +0 -50
- package/dist/daemon/dist/engine/sync/ignore-adoption.js +0 -416
- package/dist/daemon/dist/engine/sync/ignore-publication.js +0 -23
- package/dist/daemon/dist/engine/ui/ignore-rule-preview.js +0 -18
- package/dist/daemon/dist/monitor.js +0 -344
- package/src/ui/agent-mode-setting.ts +0 -99
- package/src/ui/ignore-file-guidance.ts +0 -7
- package/src/ui/ignore-file-ui.ts +0 -105
- package/src/ui/ignore-migration-prompt.ts +0 -65
- package/src/ui/settings-review.ts +0 -26
- /package/dist/chunks/{chunk-2MSJDLSM.ts.map → chunk-BCDBT4X3.ts.map} +0 -0
- /package/dist/chunks/{chunk-WBIOSK76.ts.map → chunk-R7PN3KIY.ts.map} +0 -0
- /package/dist/chunks/{chunk-3Q3DMMID.ts.map → chunk-TLYT6HVI.ts.map} +0 -0
- /package/dist/chunks/{chunk-JREGWM2B.ts.map → chunk-XNUARYLR.ts.map} +0 -0
- /package/dist/chunks/{conflict-review-OBBBSVQD.ts.map → conflict-review-3XMYDJIK.ts.map} +0 -0
- /package/dist/chunks/{config-P54GGMXY.ts.map → manager-result-dispatcher-A4IWLS4J.ts.map} +0 -0
- /package/dist/chunks/{chunk-ECUCXF5Y.ts.map → merge-review-LWMUE5IW.ts.map} +0 -0
- /package/dist/chunks/{ignore-file-ui-5BWA6LBC.ts.map → remote-selection-ui-F6NJBQ3Y.ts.map} +0 -0
- /package/dist/chunks/{manager-result-dispatcher-MJ6G2CEI.ts.map → setup-switch-7LMIRMZ7.ts.map} +0 -0
- /package/dist/chunks/{sync-inspection-NIITROKS.ts.map → sync-inspection-QGM54YCM.ts.map} +0 -0
- /package/dist/chunks/{sync-operations-FFI4ZZQL.ts.map → sync-operations-DTQMKVRQ.ts.map} +0 -0
|
@@ -26,12 +26,14 @@ import { getAgentDir } from "@earendil-works/pi-coding-agent";
|
|
|
26
26
|
import {
|
|
27
27
|
DaemonConnection as DaemonConnection2,
|
|
28
28
|
DaemonError as DaemonError2,
|
|
29
|
+
DaemonUpgradeBlockedError,
|
|
29
30
|
documentFingerprint,
|
|
30
31
|
ensureDaemon,
|
|
31
32
|
findDaemon as findDaemon2,
|
|
32
33
|
MAX_SETTINGS_BYTES,
|
|
33
34
|
modelSignature,
|
|
34
35
|
OWNERSHIP_CLEANUP_REQUIRED,
|
|
36
|
+
requestDaemon as requestDaemon2,
|
|
35
37
|
waitForDaemonExit
|
|
36
38
|
} from "#pi-sync-daemon";
|
|
37
39
|
import { appendDebugEvent } from "#pi-sync-daemon/engine/debug-log";
|
|
@@ -224,11 +226,6 @@ var DirectionalCheckpoint = class {
|
|
|
224
226
|
function recoveryOutcome(value) {
|
|
225
227
|
if (!value || typeof value !== "object" || !("foregroundQueueCleanup" in value)) return;
|
|
226
228
|
if (value.foregroundQueueCleanup === "before-mutation") return { phase: "unchanged" };
|
|
227
|
-
if (value.foregroundQueueCleanup === "resume-adoption") {
|
|
228
|
-
if (!("journal" in value) || typeof value.journal !== "string" || !/^[a-f0-9]{64}$/u.test(value.journal))
|
|
229
|
-
throw new Error("The recorded Pull could not be verified. Use /sync daemon recover.");
|
|
230
|
-
return { phase: "adoption", journal: value.journal };
|
|
231
|
-
}
|
|
232
229
|
if (value.foregroundQueueCleanup === "verified-result" && "result" in value)
|
|
233
230
|
return { phase: "completed", result: value.result };
|
|
234
231
|
}
|
|
@@ -245,13 +242,10 @@ function cancelledAfterCompletion(result, cause) {
|
|
|
245
242
|
error.name = "AbortError";
|
|
246
243
|
return error;
|
|
247
244
|
}
|
|
248
|
-
async function runDirectionalRecovery(connection, signal, run, recover, markCleanupRequired
|
|
245
|
+
async function runDirectionalRecovery(connection, signal, run, recover, markCleanupRequired) {
|
|
249
246
|
signal.throwIfAborted();
|
|
250
|
-
const pending = adoption?.pending;
|
|
251
|
-
if (pending && pending.owner !== connection) throw new Error("The daemon changed before Pull recovery.");
|
|
252
247
|
const attempt2 = new DirectionalCheckpoint(connection);
|
|
253
|
-
|
|
254
|
-
const result = pending ? { foregroundQueueCleanup: "resume-adoption", journal: pending.journal } : await run(attempt2);
|
|
248
|
+
const result = await run(attempt2);
|
|
255
249
|
const primary = recoveryOutcome(result);
|
|
256
250
|
if (!primary) return result;
|
|
257
251
|
markCleanupRequired();
|
|
@@ -259,12 +253,9 @@ async function runDirectionalRecovery(connection, signal, run, recover, markClea
|
|
|
259
253
|
const bounded = AbortSignal.any([signal, AbortSignal.timeout(45e3)]);
|
|
260
254
|
try {
|
|
261
255
|
bounded.throwIfAborted();
|
|
262
|
-
if (!attempt2.job || primary.phase === "unchanged" && !attempt2.fingerprint
|
|
256
|
+
if (!attempt2.job || primary.phase === "unchanged" && !attempt2.fingerprint)
|
|
263
257
|
throw new Error("The original transfer scope could not be verified.");
|
|
264
|
-
if (primary.phase === "adoption")
|
|
265
|
-
adoption?.retain({ owner: connection, job: attempt2.job, journal: primary.journal });
|
|
266
258
|
replacement = await recover(connection, attempt2.job, bounded);
|
|
267
|
-
if (primary.phase === "adoption") adoption?.retain(void 0);
|
|
268
259
|
bounded.throwIfAborted();
|
|
269
260
|
} catch (error) {
|
|
270
261
|
if (signal.aborted) {
|
|
@@ -277,14 +268,12 @@ async function runDirectionalRecovery(connection, signal, run, recover, markClea
|
|
|
277
268
|
`The transfer finished, but file-queue recovery stopped. ${detail}${restoreMessage(primary.result)}`,
|
|
278
269
|
{ cause: error }
|
|
279
270
|
);
|
|
280
|
-
if (primary.phase === "adoption")
|
|
281
|
-
throw new Error(`Pull recovery stopped. The adoption journal was kept. ${detail}`, { cause: error });
|
|
282
271
|
throw new Error(`No transfer was applied, but file-queue recovery stopped. ${detail}`, { cause: error });
|
|
283
272
|
}
|
|
284
273
|
if (primary.phase === "completed") return primary.result;
|
|
285
274
|
const retryCheckpoint = primary.phase === "unchanged" ? attempt2.fingerprint : void 0;
|
|
286
275
|
const retry = new DirectionalCheckpoint(replacement, retryCheckpoint);
|
|
287
|
-
const retried = await run(retry, retryCheckpoint
|
|
276
|
+
const retried = await run(retry, retryCheckpoint);
|
|
288
277
|
const remaining = recoveryOutcome(retried);
|
|
289
278
|
if (!remaining) return retried;
|
|
290
279
|
markCleanupRequired();
|
|
@@ -294,11 +283,6 @@ async function runDirectionalRecovery(connection, signal, run, recover, markClea
|
|
|
294
283
|
`Transfer finished, but file-queue cleanup is still uncertain after one recovery attempt.${restoreMessage(remaining.result)}`
|
|
295
284
|
);
|
|
296
285
|
}
|
|
297
|
-
if (remaining.phase === "adoption") {
|
|
298
|
-
if (retry.job && retry.fingerprint)
|
|
299
|
-
adoption?.retain({ owner: replacement, job: retry.job, journal: remaining.journal });
|
|
300
|
-
throw new Error("File-queue cleanup is still uncertain after one recovery attempt. The adoption journal was kept.");
|
|
301
|
-
}
|
|
302
286
|
throw new Error("File-queue release could not be verified after one recovery attempt. No transfer was applied.");
|
|
303
287
|
}
|
|
304
288
|
|
|
@@ -483,6 +467,7 @@ async function requestStartupBootstrap(connection, fingerprint2, debug, signal)
|
|
|
483
467
|
}
|
|
484
468
|
|
|
485
469
|
// src/daemon/pi-client.ts
|
|
470
|
+
var PROTECTION_ONLY_GUIDANCE = "This session is only protecting its files on an incompatible Pi Sync daemon. Stop it safely, then use /reload with the matching build.";
|
|
486
471
|
var scope = new AsyncLocalStorage();
|
|
487
472
|
var clients = /* @__PURE__ */ new WeakMap();
|
|
488
473
|
function currentPiDaemonClient() {
|
|
@@ -661,6 +646,7 @@ var PiDaemonClient = class {
|
|
|
661
646
|
publish;
|
|
662
647
|
connection;
|
|
663
648
|
protectionOnly = false;
|
|
649
|
+
blockedUpgrade;
|
|
664
650
|
partialConnection;
|
|
665
651
|
work = Promise.resolve();
|
|
666
652
|
factsQueue = Promise.resolve();
|
|
@@ -694,7 +680,6 @@ var PiDaemonClient = class {
|
|
|
694
680
|
reloadRequest;
|
|
695
681
|
pendingReload;
|
|
696
682
|
directionalCheckpoint;
|
|
697
|
-
adoptionRecovery;
|
|
698
683
|
recoveringDirectionalOwner = false;
|
|
699
684
|
busy = /* @__PURE__ */ new Set();
|
|
700
685
|
initialized = false;
|
|
@@ -787,6 +772,9 @@ var PiDaemonClient = class {
|
|
|
787
772
|
})();
|
|
788
773
|
return this.pausing;
|
|
789
774
|
}
|
|
775
|
+
blockedUpgradeReason(instance) {
|
|
776
|
+
return this.blockedUpgrade?.instance === instance ? this.blockedUpgrade.reason : void 0;
|
|
777
|
+
}
|
|
790
778
|
async attachExisting({ allowUpgrade = false } = {}) {
|
|
791
779
|
this.validate();
|
|
792
780
|
this.assertNoDirectionalRecovery();
|
|
@@ -810,8 +798,12 @@ var PiDaemonClient = class {
|
|
|
810
798
|
return true;
|
|
811
799
|
} catch (error) {
|
|
812
800
|
this.validate();
|
|
813
|
-
if (this.paused || this.recoveringDirectionalOwner) throw error;
|
|
801
|
+
if (this.paused || this.recoveringDirectionalOwner || this.blockedUpgrade?.error !== void 0) throw error;
|
|
814
802
|
upgradeFailure = safeTerminalText(errorMessage(error));
|
|
803
|
+
if (address.upgradeStop) {
|
|
804
|
+
this.blockedUpgrade = { instance: address.identity.instance, reason: upgradeFailure, error };
|
|
805
|
+
throw error;
|
|
806
|
+
}
|
|
815
807
|
}
|
|
816
808
|
}
|
|
817
809
|
try {
|
|
@@ -823,6 +815,7 @@ var PiDaemonClient = class {
|
|
|
823
815
|
} finally {
|
|
824
816
|
if (upgradeFailure !== void 0) {
|
|
825
817
|
this.validate();
|
|
818
|
+
this.blockedUpgrade = { instance: address.identity.instance, reason: upgradeFailure };
|
|
826
819
|
this.ctx.ui.notify(`pi-sync daemon upgrade failed: ${upgradeFailure}`, "error");
|
|
827
820
|
}
|
|
828
821
|
}
|
|
@@ -848,6 +841,36 @@ var PiDaemonClient = class {
|
|
|
848
841
|
this.assertNoDirectionalRecovery();
|
|
849
842
|
return this.attachConnection(existing, requestSignal);
|
|
850
843
|
}
|
|
844
|
+
async ensureWithSessionProtection(signal, validate) {
|
|
845
|
+
try {
|
|
846
|
+
return await ensureDaemon(this.root, signal);
|
|
847
|
+
} catch (error) {
|
|
848
|
+
if (!(error instanceof DaemonUpgradeBlockedError)) throw error;
|
|
849
|
+
validate();
|
|
850
|
+
if (this.paused || this.recoveringDirectionalOwner) throw error;
|
|
851
|
+
this.blockedUpgrade = { instance: error.instance, reason: error.message, error };
|
|
852
|
+
try {
|
|
853
|
+
const address = await findDaemon2(this.root, signal);
|
|
854
|
+
validate();
|
|
855
|
+
if (this.paused || this.recoveringDirectionalOwner) throw error;
|
|
856
|
+
if (address?.identity.instance !== error.instance || address.paths.root !== this.root || !address.needsUpgrade)
|
|
857
|
+
throw error;
|
|
858
|
+
if (!address.upgradeStop) return { ...address, replacedOwner: false };
|
|
859
|
+
const facts = this.facts(true);
|
|
860
|
+
if (facts.sessionFile) {
|
|
861
|
+
const result = await requestDaemon2(address.paths, address.identity, "protect-session", facts, signal);
|
|
862
|
+
validate();
|
|
863
|
+
if (!result || typeof result !== "object" || !("protected" in result) || result.protected !== true)
|
|
864
|
+
throw new Error("Daemon did not acknowledge session-file protection.");
|
|
865
|
+
}
|
|
866
|
+
} catch (cause) {
|
|
867
|
+
validate();
|
|
868
|
+
if (cause === error) throw error;
|
|
869
|
+
throw new Error(`${error.message} Session-file protection could not be confirmed.`, { cause });
|
|
870
|
+
}
|
|
871
|
+
throw error;
|
|
872
|
+
}
|
|
873
|
+
}
|
|
851
874
|
async attachConnection(existing, requestSignal) {
|
|
852
875
|
const startupSignal = requestSignal ? AbortSignal.any([this.signal, requestSignal]) : this.signal;
|
|
853
876
|
const validateStartup = () => {
|
|
@@ -855,11 +878,9 @@ var PiDaemonClient = class {
|
|
|
855
878
|
startupSignal.throwIfAborted();
|
|
856
879
|
};
|
|
857
880
|
validateStartup();
|
|
881
|
+
if (!existing && this.blockedUpgrade?.error !== void 0) throw this.blockedUpgrade.error;
|
|
858
882
|
if (this.connection) {
|
|
859
|
-
if (!existing && this.protectionOnly)
|
|
860
|
-
throw new Error(
|
|
861
|
-
"This session is only protecting its files on an older Pi Sync daemon. Use /reload to upgrade."
|
|
862
|
-
);
|
|
883
|
+
if (!existing && this.protectionOnly) throw new Error(PROTECTION_ONLY_GUIDANCE);
|
|
863
884
|
return this.connection;
|
|
864
885
|
}
|
|
865
886
|
this.connecting ??= (async () => {
|
|
@@ -875,10 +896,10 @@ var PiDaemonClient = class {
|
|
|
875
896
|
let retried = false;
|
|
876
897
|
for (; ; ) {
|
|
877
898
|
validateStartup();
|
|
878
|
-
const daemon = existing
|
|
899
|
+
const daemon = existing ? { ...existing, replacedOwner: false, buildVersion: void 0 } : await this.ensureWithSessionProtection(startupSignal, validateStartup);
|
|
879
900
|
validateStartup();
|
|
880
901
|
if (daemon.paths.root !== this.root) throw new Error("Daemon root changed before attach.");
|
|
881
|
-
const protectionOnly = daemon.needsUpgrade
|
|
902
|
+
const protectionOnly = daemon.needsUpgrade || !daemon.ignoreFilesRetired || !daemon.autonomousSyncRetired;
|
|
882
903
|
const connection2 = new DaemonConnection2(daemon.paths, daemon.identity, this.facts(protectionOnly), {
|
|
883
904
|
callback: (callback, signal) => this.callback(connection2, callback, signal, protectionOnly),
|
|
884
905
|
mergeReview: !protectionOnly && this.ctx.hasUI ? (callback, loadDetails, signal) => this.pagedMergeReview(connection2, callback, loadDetails, signal) : void 0,
|
|
@@ -914,7 +935,7 @@ var PiDaemonClient = class {
|
|
|
914
935
|
});
|
|
915
936
|
this.partialConnection = void 0;
|
|
916
937
|
validateStartup();
|
|
917
|
-
if (existing || retried) throw error;
|
|
938
|
+
if (existing || retried || this.blockedUpgrade?.error !== void 0) throw error;
|
|
918
939
|
retried = true;
|
|
919
940
|
await waitForDaemonExit(daemon.identity, startupSignal);
|
|
920
941
|
validateStartup();
|
|
@@ -929,7 +950,10 @@ var PiDaemonClient = class {
|
|
|
929
950
|
this.validate();
|
|
930
951
|
this.connection = connection2;
|
|
931
952
|
this.protectionOnly = protectionOnly;
|
|
953
|
+
if (!protectionOnly) this.blockedUpgrade = void 0;
|
|
932
954
|
this.partialConnection = void 0;
|
|
955
|
+
if (daemon.replacedOwner && daemon.buildVersion && this.ownsContactUI() && !startupSignal.aborted && this.ctx.hasUI && (this.ctx.mode === "tui" || this.ctx.mode === "rpc"))
|
|
956
|
+
this.ctx.ui.notify(`Pi Sync daemon replaced. Running version ${daemon.buildVersion}.`, "info");
|
|
933
957
|
return connection2;
|
|
934
958
|
}
|
|
935
959
|
})().then(
|
|
@@ -946,8 +970,8 @@ var PiDaemonClient = class {
|
|
|
946
970
|
);
|
|
947
971
|
const connection = await this.connecting;
|
|
948
972
|
validateStartup();
|
|
949
|
-
if (!existing && this.
|
|
950
|
-
|
|
973
|
+
if (!existing && this.blockedUpgrade?.error !== void 0) throw this.blockedUpgrade.error;
|
|
974
|
+
if (!existing && this.protectionOnly) throw new Error(PROTECTION_ONLY_GUIDANCE);
|
|
951
975
|
return connection;
|
|
952
976
|
}
|
|
953
977
|
ownsContactUI() {
|
|
@@ -1102,9 +1126,11 @@ var PiDaemonClient = class {
|
|
|
1102
1126
|
this.clearRestoredContact();
|
|
1103
1127
|
}
|
|
1104
1128
|
async verifyConnection(signal) {
|
|
1105
|
-
|
|
1106
|
-
this.validateFactsScope(connection, signal);
|
|
1129
|
+
this.validateFactsScope(void 0, signal);
|
|
1107
1130
|
this.assertNoDirectionalRecovery();
|
|
1131
|
+
const connection = this.connection;
|
|
1132
|
+
if (!connection) return;
|
|
1133
|
+
if (this.protectionOnly) throw new Error(PROTECTION_ONLY_GUIDANCE);
|
|
1108
1134
|
await this.publishFacts(connection, signal);
|
|
1109
1135
|
this.validateFactsScope(connection, signal);
|
|
1110
1136
|
this.assertNoDirectionalRecovery();
|
|
@@ -1133,14 +1159,7 @@ var PiDaemonClient = class {
|
|
|
1133
1159
|
get ownershipCleanupRequired() {
|
|
1134
1160
|
return this.cleanupRequired;
|
|
1135
1161
|
}
|
|
1136
|
-
get pendingPullReview() {
|
|
1137
|
-
const recovery = this.adoptionRecovery;
|
|
1138
|
-
if (!this.cleanupRequired || !recovery || this.paused || recovery.pending.owner !== this.connection || !recovery.pending.owner.canRecoverForeground(recovery.pending.job))
|
|
1139
|
-
return void 0;
|
|
1140
|
-
return recovery.review;
|
|
1141
|
-
}
|
|
1142
1162
|
confirmRecoveryExit(owner) {
|
|
1143
|
-
this.adoptionRecovery = void 0;
|
|
1144
1163
|
this.cleanupRequired = true;
|
|
1145
1164
|
this.recoveredOwner = owner;
|
|
1146
1165
|
}
|
|
@@ -1148,14 +1167,9 @@ var PiDaemonClient = class {
|
|
|
1148
1167
|
if (error instanceof DaemonError2 && error.remote.properties?.code === OWNERSHIP_CLEANUP_REQUIRED || error instanceof Error && ("code" in error && error.code === OWNERSHIP_CLEANUP_REQUIRED || error.message === "Daemon ownership cleanup is uncertain; stop and reconcile before restarting." || error.message === "Daemon ownership cleanup is uncertain; stop and reconcile before retrying." || error.message === "File-queue release is uncertain; stop the daemon and keep grants quarantined until owner exit."))
|
|
1149
1168
|
this.cleanupRequired = true;
|
|
1150
1169
|
}
|
|
1151
|
-
run(operation, payload, signal, ctx = this.ctx, onCommit, reload
|
|
1170
|
+
run(operation, payload, signal, ctx = this.ctx, onCommit, reload) {
|
|
1152
1171
|
const diagnostics = this.debug ? observeDebugJob(operation, (event) => this.recordDebug(event)) : void 0;
|
|
1153
|
-
const
|
|
1154
|
-
const result = this.work.then(() => {
|
|
1155
|
-
if (requirePendingAdoption && !adoptionRecovery)
|
|
1156
|
-
throw new Error("The original Pull is no longer available for automatic recovery.");
|
|
1157
|
-
return this.runCurrent(operation, payload, signal, ctx, onCommit, reload, diagnostics, adoptionRecovery);
|
|
1158
|
-
}).catch((error) => {
|
|
1172
|
+
const result = this.work.then(() => this.runCurrent(operation, payload, signal, ctx, onCommit, reload, diagnostics)).catch((error) => {
|
|
1159
1173
|
diagnostics?.rejected(error, Boolean(signal?.aborted || reload?.signal.aborted));
|
|
1160
1174
|
this.recordOwnershipFailure(error);
|
|
1161
1175
|
throw error;
|
|
@@ -1189,16 +1203,15 @@ var PiDaemonClient = class {
|
|
|
1189
1203
|
assertRoot();
|
|
1190
1204
|
const attached = await this.attachConnection(replacement, signal);
|
|
1191
1205
|
this.validateFactsScope(attached, signal);
|
|
1206
|
+
if (this.protectionOnly) throw new Error(PROTECTION_ONLY_GUIDANCE);
|
|
1192
1207
|
assertRoot();
|
|
1193
1208
|
return attached;
|
|
1194
1209
|
} finally {
|
|
1195
1210
|
this.recoveringDirectionalOwner = false;
|
|
1196
1211
|
}
|
|
1197
1212
|
}
|
|
1198
|
-
async runCurrent(operation, payload, signal, ctx = this.ctx, onCommit, reload, diagnostics
|
|
1213
|
+
async runCurrent(operation, payload, signal, ctx = this.ctx, onCommit, reload, diagnostics) {
|
|
1199
1214
|
this.validate();
|
|
1200
|
-
if (adoptionRecovery && (this.adoptionRecovery !== adoptionRecovery || !this.pendingPullReview))
|
|
1201
|
-
throw new Error("The original Pull is no longer available for automatic recovery.");
|
|
1202
1215
|
signal?.throwIfAborted();
|
|
1203
1216
|
reload?.signal.throwIfAborted();
|
|
1204
1217
|
if (this.pendingReload) throw new Error("Pi resources are about to reload.");
|
|
@@ -1226,31 +1239,16 @@ var PiDaemonClient = class {
|
|
|
1226
1239
|
runSignal.addEventListener("abort", clearForeground, { once: true });
|
|
1227
1240
|
try {
|
|
1228
1241
|
const root = isForegroundDirection(operation) ? lstatSync(this.root) : void 0;
|
|
1229
|
-
const assertRoot =
|
|
1242
|
+
const assertRoot = () => {
|
|
1230
1243
|
const current2 = lstatSync(this.root);
|
|
1231
1244
|
if (!root || !current2.isDirectory() || current2.dev !== root.dev || current2.ino !== root.ino)
|
|
1232
1245
|
throw new Error("The agent directory changed during the transfer.");
|
|
1233
|
-
}
|
|
1246
|
+
};
|
|
1234
1247
|
const intent = root ? structuredClone(payload) : payload;
|
|
1235
|
-
const pull = operation === "pull.foreground" ? intent : void 0;
|
|
1236
|
-
if (adoptionRecovery && (!pull || pull.setup !== adoptionRecovery.review.setupName || pull.fingerprint !== adoptionRecovery.review.fingerprint))
|
|
1237
|
-
throw new Error("The sync setup changed before Pull recovery.");
|
|
1238
|
-
if (adoptionRecovery) {
|
|
1239
|
-
assertRoot();
|
|
1240
|
-
const { createSettingsConfigView, syncCheckConfigFingerprint } = await import("./config-P54GGMXY.ts");
|
|
1241
|
-
this.validateFactsScope(connection, runSignal);
|
|
1242
|
-
const document = await peekLocalConfigDocument();
|
|
1243
|
-
this.validateFactsScope(connection, runSignal);
|
|
1244
|
-
const config = document && await createSettingsConfigView(document).observe(void 0, runSignal);
|
|
1245
|
-
this.validateFactsScope(connection, runSignal);
|
|
1246
|
-
assertRoot();
|
|
1247
|
-
if (!config || syncCheckConfigFingerprint(config) !== adoptionRecovery.review.fingerprint)
|
|
1248
|
-
throw new Error("The sync setup changed before Pull recovery.");
|
|
1249
|
-
}
|
|
1250
1248
|
const result = root ? await runDirectionalRecovery(
|
|
1251
1249
|
connection,
|
|
1252
1250
|
runSignal,
|
|
1253
|
-
async (checkpoint, retryCheckpoint
|
|
1251
|
+
async (checkpoint, retryCheckpoint) => {
|
|
1254
1252
|
const current2 = checkpoint.connection;
|
|
1255
1253
|
this.validateFactsScope(current2, runSignal);
|
|
1256
1254
|
assertRoot();
|
|
@@ -1258,7 +1256,7 @@ var PiDaemonClient = class {
|
|
|
1258
1256
|
try {
|
|
1259
1257
|
return await current2.run(
|
|
1260
1258
|
operation,
|
|
1261
|
-
|
|
1259
|
+
retryCheckpoint === void 0 ? intent : { ...intent, retryCheckpoint },
|
|
1262
1260
|
runSignal,
|
|
1263
1261
|
onCommit,
|
|
1264
1262
|
(id) => {
|
|
@@ -1273,16 +1271,6 @@ var PiDaemonClient = class {
|
|
|
1273
1271
|
(owner, job, recoverySignal) => this.recoverDirectionalOwner(owner, job, recoverySignal, assertRoot),
|
|
1274
1272
|
() => {
|
|
1275
1273
|
this.cleanupRequired = true;
|
|
1276
|
-
},
|
|
1277
|
-
pull && {
|
|
1278
|
-
pending: adoptionRecovery?.pending,
|
|
1279
|
-
retain: (pending) => {
|
|
1280
|
-
this.adoptionRecovery = pending && {
|
|
1281
|
-
pending,
|
|
1282
|
-
review: { setupName: pull.setup, fingerprint: pull.fingerprint },
|
|
1283
|
-
assertRoot
|
|
1284
|
-
};
|
|
1285
|
-
}
|
|
1286
1274
|
}
|
|
1287
1275
|
) : await connection.run(operation, payload, runSignal, onCommit, diagnostics?.onSubmit);
|
|
1288
1276
|
diagnostics?.returned(result, runSignal.aborted || reload?.signal.aborted);
|
|
@@ -1414,7 +1402,7 @@ var PiDaemonClient = class {
|
|
|
1414
1402
|
this.validate();
|
|
1415
1403
|
if (!ctx.hasUI || !["tui", "rpc"].includes(ctx.mode)) throw new Error("This client cannot present safety reviews.");
|
|
1416
1404
|
const { title, confirmationLabel, summaryLines } = callback.payload;
|
|
1417
|
-
const { confirmMergeReview } = await import("./merge-review-
|
|
1405
|
+
const { confirmMergeReview } = await import("./merge-review-LWMUE5IW.ts");
|
|
1418
1406
|
if (!isCurrent()) return false;
|
|
1419
1407
|
this.validate();
|
|
1420
1408
|
const result = await confirmMergeReview(
|
|
@@ -1444,7 +1432,7 @@ var PiDaemonClient = class {
|
|
|
1444
1432
|
this.validateFactsScope(connection, this.runSignal);
|
|
1445
1433
|
if (protectionOnly || this.directionalCheckpoint?.accept(connection, callback.job, payload?.fingerprint) !== true)
|
|
1446
1434
|
return false;
|
|
1447
|
-
return
|
|
1435
|
+
return true;
|
|
1448
1436
|
}
|
|
1449
1437
|
if (callback.kind === "queue-acquire") {
|
|
1450
1438
|
if (this.pendingReload) throw new Error("Pi resources are about to reload.");
|
|
@@ -1476,7 +1464,7 @@ var PiDaemonClient = class {
|
|
|
1476
1464
|
if (!ctx.hasUI || !["tui", "rpc"].includes(ctx.mode)) throw new Error("This client cannot present safety reviews.");
|
|
1477
1465
|
let result;
|
|
1478
1466
|
if (callback.kind === "merge-review" && typeof payload.title === "string" && typeof payload.content === "string") {
|
|
1479
|
-
const { confirmMergeReview } = await import("./merge-review-
|
|
1467
|
+
const { confirmMergeReview } = await import("./merge-review-LWMUE5IW.ts");
|
|
1480
1468
|
this.validate();
|
|
1481
1469
|
combined.throwIfAborted();
|
|
1482
1470
|
result = await confirmMergeReview(
|
|
@@ -1551,4 +1539,4 @@ export {
|
|
|
1551
1539
|
withPiDaemonClient,
|
|
1552
1540
|
remoteOperation
|
|
1553
1541
|
};
|
|
1554
|
-
//# sourceMappingURL=chunk-
|
|
1542
|
+
//# sourceMappingURL=chunk-YV2R5SJU.ts.map
|