@narumitw/pi-sync 0.70.4 → 0.70.6
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 +5 -3
- package/dist/chunks/{chunk-3XN4FR72.ts → chunk-4A34OGXY.ts} +9 -9
- package/dist/chunks/{chunk-7NQ7SFZK.ts → chunk-5BE6LBDC.ts} +15 -15
- package/dist/chunks/chunk-A43CJYG4.ts +26 -0
- package/dist/chunks/chunk-A43CJYG4.ts.map +7 -0
- package/dist/chunks/{chunk-JPTI4HFC.ts → chunk-AXN3B5KC.ts} +22 -22
- package/dist/chunks/{chunk-SPXEDJ2G.ts → chunk-KN4NY2VV.ts} +15 -42
- package/dist/chunks/chunk-KN4NY2VV.ts.map +7 -0
- package/dist/chunks/{chunk-N24HEZSA.ts → chunk-VERMBZGL.ts} +7 -7
- package/dist/chunks/{chunk-V4IGBXBA.ts → chunk-WE3KJ7JS.ts} +9 -8
- package/dist/chunks/chunk-WE3KJ7JS.ts.map +7 -0
- package/dist/chunks/{chunk-5T4ZOHYF.ts → chunk-WRS3SUNZ.ts} +4 -18
- package/dist/chunks/chunk-WRS3SUNZ.ts.map +7 -0
- package/dist/chunks/client-debug-F4WFP2YJ.ts +40 -0
- package/dist/chunks/client-debug-F4WFP2YJ.ts.map +7 -0
- package/dist/chunks/{command-handler-4XHK5PVX.ts → command-handler-GERC7LOE.ts} +34 -32
- package/dist/chunks/{command-handler-4XHK5PVX.ts.map → command-handler-GERC7LOE.ts.map} +1 -1
- package/dist/chunks/{conflict-review-QI77P7KL.ts → conflict-review-XZI7RYZX.ts} +3 -3
- package/dist/chunks/debug-tool-execution-7N4H6K3X.ts +67 -0
- package/dist/chunks/debug-tool-execution-7N4H6K3X.ts.map +7 -0
- package/dist/chunks/{diff-review-SOLP33TQ.ts → diff-review-FLWC5VOT.ts} +3 -3
- package/dist/chunks/{diff-review-ILRZDQ4S.ts → diff-review-GB4NO53B.ts} +4 -4
- package/dist/chunks/{file-selection-2H3J2HTX.ts → file-selection-DGC5UJVI.ts} +9 -9
- package/dist/chunks/{manager-result-dispatcher-YXSDLTLV.ts → manager-result-dispatcher-6MOJPLIS.ts} +7 -7
- package/dist/chunks/{manager-ui-RQSZLMJ5.ts → manager-ui-3CQU37XY.ts} +90 -68
- package/dist/chunks/manager-ui-3CQU37XY.ts.map +7 -0
- package/dist/chunks/{remote-selection-ui-AE6FOEXH.ts → remote-selection-ui-2V53UBHM.ts} +6 -6
- package/dist/chunks/{setup-switch-LJPEZONY.ts → setup-switch-WSKVGW7L.ts} +4 -4
- package/dist/chunks/{setup-wizard-FBX7RTZ6.ts → setup-wizard-FRIR2EOR.ts} +9 -9
- package/dist/chunks/{sync-inspection-TZ4EMSBN.ts → sync-inspection-ECI4BY5N.ts} +6 -6
- package/dist/chunks/{sync-operations-QIQ3G66S.ts → sync-operations-KWXZZEPT.ts} +4 -4
- package/dist/chunks/sync-state-store-TZE7XDV5.ts +23 -0
- package/dist/chunks/sync-state-store-TZE7XDV5.ts.map +7 -0
- package/dist/daemon/dist/build-id.json +1 -1
- package/dist/daemon/dist/cli.js +3 -2
- package/dist/daemon/dist/client.js +55 -14
- package/dist/daemon/dist/daemon-startup.js +2 -14
- package/dist/daemon/dist/daemon-upgrade-error.js +14 -0
- package/dist/daemon/dist/engine/sync/directional-conflict.js +0 -2
- package/dist/daemon/dist/index.js +20 -3
- package/dist/daemon/package.json +1 -1
- package/dist/index.ts +41 -83
- package/dist/index.ts.map +2 -2
- package/docs/daemon-migration.md +2 -0
- package/docs/tui-contract.md +2 -2
- package/package.json +2 -2
- package/src/daemon/client-debug.ts +2 -0
- package/src/daemon/pi-client.ts +15 -7
- package/src/sync/automatic-sync.ts +3 -1
- package/src/sync/debug-tool-execution.ts +66 -0
- package/src/sync/debug-tool.ts +4 -51
- package/src/sync/startup-check.ts +3 -1
- package/src/sync-extension.ts +2 -1
- package/src/ui/manager-ui.ts +41 -20
- package/src/ui/sync-resolution-ui.ts +3 -0
- package/dist/chunks/chunk-5T4ZOHYF.ts.map +0 -7
- package/dist/chunks/chunk-SPXEDJ2G.ts.map +0 -7
- package/dist/chunks/chunk-V4IGBXBA.ts.map +0 -7
- package/dist/chunks/manager-ui-RQSZLMJ5.ts.map +0 -7
- /package/dist/chunks/{chunk-3XN4FR72.ts.map → chunk-4A34OGXY.ts.map} +0 -0
- /package/dist/chunks/{chunk-7NQ7SFZK.ts.map → chunk-5BE6LBDC.ts.map} +0 -0
- /package/dist/chunks/{chunk-JPTI4HFC.ts.map → chunk-AXN3B5KC.ts.map} +0 -0
- /package/dist/chunks/{chunk-N24HEZSA.ts.map → chunk-VERMBZGL.ts.map} +0 -0
- /package/dist/chunks/{conflict-review-QI77P7KL.ts.map → conflict-review-XZI7RYZX.ts.map} +0 -0
- /package/dist/chunks/{diff-review-SOLP33TQ.ts.map → diff-review-FLWC5VOT.ts.map} +0 -0
- /package/dist/chunks/{diff-review-ILRZDQ4S.ts.map → diff-review-GB4NO53B.ts.map} +0 -0
- /package/dist/chunks/{file-selection-2H3J2HTX.ts.map → file-selection-DGC5UJVI.ts.map} +0 -0
- /package/dist/chunks/{manager-result-dispatcher-YXSDLTLV.ts.map → manager-result-dispatcher-6MOJPLIS.ts.map} +0 -0
- /package/dist/chunks/{remote-selection-ui-AE6FOEXH.ts.map → remote-selection-ui-2V53UBHM.ts.map} +0 -0
- /package/dist/chunks/{setup-switch-LJPEZONY.ts.map → setup-switch-WSKVGW7L.ts.map} +0 -0
- /package/dist/chunks/{setup-wizard-FBX7RTZ6.ts.map → setup-wizard-FRIR2EOR.ts.map} +0 -0
- /package/dist/chunks/{sync-inspection-TZ4EMSBN.ts.map → sync-inspection-ECI4BY5N.ts.map} +0 -0
- /package/dist/chunks/{sync-operations-QIQ3G66S.ts.map → sync-operations-KWXZZEPT.ts.map} +0 -0
package/dist/daemon/dist/cli.js
CHANGED
|
@@ -3,8 +3,7 @@ import "./child-sdk.mjs";
|
|
|
3
3
|
import { setTimeout as delay } from "node:timers/promises";
|
|
4
4
|
import { DAEMON_BUILD_ID, DAEMON_BUILD_VERSION } from "./build-version.js";
|
|
5
5
|
import { requestDaemon } from "./client-transport.js";
|
|
6
|
-
import { DaemonUpgradeBlockedError
|
|
7
|
-
import { inspectDaemonStatus } from "./daemon-status.js";
|
|
6
|
+
import { DaemonUpgradeBlockedError } from "./daemon-upgrade-error.js";
|
|
8
7
|
import { privateDirectory, readIdentity, runtimePaths } from "./identity.js";
|
|
9
8
|
import { openLifecycleLog } from "./lifecycle-log.js";
|
|
10
9
|
async function retiredPolicyBlocker(root) {
|
|
@@ -112,11 +111,13 @@ export async function main(args) {
|
|
|
112
111
|
return;
|
|
113
112
|
}
|
|
114
113
|
if (command === "start" || command === "restart") {
|
|
114
|
+
const { ensureDaemon, restartDaemon } = await import("./daemon-startup.js");
|
|
115
115
|
const { identity } = await (command === "start" ? ensureDaemon(root) : restartDaemon(root));
|
|
116
116
|
console.log(JSON.stringify({ running: true, root: identity.root, instance: identity.instance, pid: identity.pid }));
|
|
117
117
|
return;
|
|
118
118
|
}
|
|
119
119
|
if (command === "status") {
|
|
120
|
+
const { inspectDaemonStatus } = await import("./daemon-status.js");
|
|
120
121
|
const status = await inspectDaemonStatus(root);
|
|
121
122
|
const retiredPolicy = await retiredPolicyBlocker(status.root);
|
|
122
123
|
console.log(JSON.stringify({ ...status, ...(retiredPolicy ? { retiredPolicy } : {}) }));
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { createHash, randomUUID } from "node:crypto";
|
|
2
2
|
import { setTimeout as delay } from "node:timers/promises";
|
|
3
3
|
import { DaemonError, requestDaemon } from "./client-transport.js";
|
|
4
|
-
import { stopDaemonAfterForegroundQueueFailure } from "./daemon-recovery.js";
|
|
5
4
|
import { sameDiffReviewBinding } from "./diff-review-binding.js";
|
|
6
5
|
import { DIFF_REVIEW_REQUEST_MS, isDiffReviewId, parseDiffReviewInventory, readDiffReviewPreview, } from "./diff-review-protocol.js";
|
|
7
6
|
import { isForegroundDirection, isForegroundQueueOutcome } from "./foreground-queue-outcome.js";
|
|
8
7
|
import { canonicalRootGuard, readProcessBirth } from "./identity.js";
|
|
9
8
|
import { withCleanup } from "./lifecycle.js";
|
|
10
|
-
import { presentPagedReview, reviewScope } from "./paged-review.js";
|
|
11
9
|
import { MAX_REVIEW_BYTES, OWNERSHIP_CLEANUP_REQUIRED, operationPrefix, REVIEW_PAGE_CHARS, record, UNKNOWN_JOB_RESULT, } from "./protocol.js";
|
|
12
10
|
import { STATE_WAIT_FAILURE_LIMIT, stateWaitJobs, stateWaitResult } from "./state-wait-jobs.js";
|
|
13
11
|
export { DaemonError, hello, requestDaemon } from "./client-transport.js";
|
|
@@ -490,11 +488,13 @@ export class DaemonConnection {
|
|
|
490
488
|
});
|
|
491
489
|
}
|
|
492
490
|
canRecoverForeground(job) {
|
|
491
|
+
return !this.foregroundRecovery?.attempted && this.ownsForegroundRecovery(job);
|
|
492
|
+
}
|
|
493
|
+
ownsForegroundRecovery(job) {
|
|
493
494
|
const target = this.foregroundRecovery;
|
|
494
495
|
return (!!target &&
|
|
495
496
|
target.job === job &&
|
|
496
497
|
target.generation === this.facts.generation &&
|
|
497
|
-
!target.attempted &&
|
|
498
498
|
this.attached &&
|
|
499
499
|
!this.closed &&
|
|
500
500
|
!this.admitting &&
|
|
@@ -511,8 +511,18 @@ export class DaemonConnection {
|
|
|
511
511
|
throw new Error("The current Pi session could not verify a completed transfer for daemon recovery.");
|
|
512
512
|
target.assertRoot();
|
|
513
513
|
target.attempted = true;
|
|
514
|
+
const facts = { ...this.facts };
|
|
515
|
+
const lifecycle = this.lifecycleRevision;
|
|
514
516
|
const owned = AbortSignal.any([signal, this.controller.signal, AbortSignal.timeout(FOREGROUND_RECOVERY_MS)]);
|
|
515
|
-
|
|
517
|
+
const { stopDaemonAfterForegroundQueueFailure } = await import("./daemon-recovery.js");
|
|
518
|
+
owned.throwIfAborted();
|
|
519
|
+
if (lifecycle !== this.lifecycleRevision ||
|
|
520
|
+
!sameDiffReviewBinding(facts, this.facts) ||
|
|
521
|
+
this.foregroundRecovery !== target ||
|
|
522
|
+
!this.ownsForegroundRecovery(job))
|
|
523
|
+
throw new Error("The current Pi session could not verify a completed transfer for daemon recovery.");
|
|
524
|
+
target.assertRoot();
|
|
525
|
+
await stopDaemonAfterForegroundQueueFailure(this.paths, this.identity, { ...target, client: facts.id }, owned);
|
|
516
526
|
await this.closeLocal();
|
|
517
527
|
target.assertRoot();
|
|
518
528
|
}
|
|
@@ -584,7 +594,9 @@ export class DaemonConnection {
|
|
|
584
594
|
this.uncertain = true;
|
|
585
595
|
const controller = new AbortController();
|
|
586
596
|
const foreground = this.pendingJobs.has(callback.job);
|
|
587
|
-
const
|
|
597
|
+
const reviewOwner = callback.review?.offer !== undefined
|
|
598
|
+
? { facts: { ...this.facts }, lifecycle: this.lifecycleRevision }
|
|
599
|
+
: undefined;
|
|
588
600
|
this.callbacks.set(callback.id, {
|
|
589
601
|
controller,
|
|
590
602
|
kind: callback.kind,
|
|
@@ -597,7 +609,9 @@ export class DaemonConnection {
|
|
|
597
609
|
try {
|
|
598
610
|
if ((this.uncertain || this.resumeUncertain) && callback.kind !== "queue-release")
|
|
599
611
|
throw new Error("Client is draining uncertain work.");
|
|
600
|
-
value = await
|
|
612
|
+
value = await (reviewOwner
|
|
613
|
+
? this.performExactReview(callback, controller.signal, reviewOwner)
|
|
614
|
+
: this.performCallback(callback, controller.signal));
|
|
601
615
|
}
|
|
602
616
|
catch {
|
|
603
617
|
failed = true;
|
|
@@ -611,10 +625,10 @@ export class DaemonConnection {
|
|
|
611
625
|
}
|
|
612
626
|
try {
|
|
613
627
|
await requestDaemon(this.paths, this.identity, "answer", {
|
|
614
|
-
client: this.facts.id,
|
|
628
|
+
client: reviewOwner?.facts.id ?? this.facts.id,
|
|
615
629
|
id: callback.id,
|
|
616
|
-
...(
|
|
617
|
-
...(failed || (
|
|
630
|
+
...(reviewOwner ? { generation: reviewOwner.facts.generation } : {}),
|
|
631
|
+
...(failed || (reviewOwner && !this.ownsExactReview(callback, controller.signal, reviewOwner))
|
|
618
632
|
? { error: "Client callback cancelled or failed." }
|
|
619
633
|
: { value }),
|
|
620
634
|
}, this.callbackIO.signal);
|
|
@@ -702,15 +716,42 @@ export class DaemonConnection {
|
|
|
702
716
|
this.reportRelease(callback, foreground, state);
|
|
703
717
|
}
|
|
704
718
|
}
|
|
719
|
+
ownsExactReview(callback, signal, owner) {
|
|
720
|
+
return (!signal.aborted &&
|
|
721
|
+
!this.callbackIO.signal.aborted &&
|
|
722
|
+
owner.lifecycle === this.lifecycleRevision &&
|
|
723
|
+
!this.closed &&
|
|
724
|
+
!this.pausing &&
|
|
725
|
+
!this.disposing &&
|
|
726
|
+
!this.uncertain &&
|
|
727
|
+
this.contactResumeState === "idle" &&
|
|
728
|
+
this.contactState !== "expired" &&
|
|
729
|
+
this.contactState !== "inactive" &&
|
|
730
|
+
this.callbacks.get(callback.id)?.controller.signal === signal &&
|
|
731
|
+
sameDiffReviewBinding(owner.facts, this.facts));
|
|
732
|
+
}
|
|
733
|
+
async performExactReview(callback, signal, owner) {
|
|
734
|
+
const present = this.options.mergeReview;
|
|
735
|
+
if (!present)
|
|
736
|
+
throw new Error("Exact review offer requires an opted-in presenter.");
|
|
737
|
+
const owned = AbortSignal.any([signal, this.callbackIO.signal]);
|
|
738
|
+
const requireCurrent = () => {
|
|
739
|
+
owned.throwIfAborted();
|
|
740
|
+
if (!this.ownsExactReview(callback, signal, owner))
|
|
741
|
+
throw new Error("Exact review participant changed.");
|
|
742
|
+
};
|
|
743
|
+
owned.throwIfAborted();
|
|
744
|
+
const { presentPagedReview, reviewScope } = await import("./paged-review.js");
|
|
745
|
+
requireCurrent();
|
|
746
|
+
return presentPagedReview(reviewScope(this.identity, owner.facts, callback), callback, owned, present, (params, pageSignal) => {
|
|
747
|
+
requireCurrent();
|
|
748
|
+
return requestDaemon(this.paths, this.identity, "review-page", params, pageSignal);
|
|
749
|
+
});
|
|
750
|
+
}
|
|
705
751
|
async performCallback(callback, signal) {
|
|
706
752
|
const reference = callback.review;
|
|
707
753
|
if (!reference)
|
|
708
754
|
return this.options.callback(callback, signal);
|
|
709
|
-
if (reference.offer !== undefined) {
|
|
710
|
-
if (!this.options.mergeReview)
|
|
711
|
-
throw new Error("Exact review offer requires an opted-in presenter.");
|
|
712
|
-
return presentPagedReview(reviewScope(this.identity, this.facts, callback), callback, AbortSignal.any([signal, this.callbackIO.signal]), this.options.mergeReview, (params, owned) => requestDaemon(this.paths, this.identity, "review-page", params, owned));
|
|
713
|
-
}
|
|
714
755
|
if (callback.kind !== "merge-review" ||
|
|
715
756
|
!record(callback.payload) ||
|
|
716
757
|
!Number.isSafeInteger(reference.pages) ||
|
|
@@ -6,22 +6,10 @@ import lockfile from "proper-lockfile";
|
|
|
6
6
|
import { gt } from "semver";
|
|
7
7
|
import { DAEMON_BUILD_ID, DAEMON_BUILD_VERSION, readInstalledDaemonBuild } from "./build-version.js";
|
|
8
8
|
import { DaemonError, hello, requestDaemon } from "./client-transport.js";
|
|
9
|
+
import { DaemonUpgradeBlockedError, upgradeBlockers } from "./daemon-upgrade-error.js";
|
|
9
10
|
import { canonicalRootGuard, clearUpgradeOwner, daemonPaths, privateDirectory, processExists, processExited, readIdentity, readProcessBirth, readUpgradeOwner, recordUpgradeOwner, runtimePaths, upgradeRepairStarted, } from "./identity.js";
|
|
10
11
|
import { OWNERSHIP_CLEANUP_REQUIRED, record } from "./protocol.js";
|
|
11
|
-
|
|
12
|
-
busy: "Daemon update deferred while sync work is active. Let it finish, then use /reload or retry the daemon CLI.",
|
|
13
|
-
repair: "Daemon update blocked by uncertain consent or queue cleanup. Follow the daemon recovery guide before retrying.",
|
|
14
|
-
unattended: "Review or revoke unattended Pi Sync permission before stopping or replacing the daemon.",
|
|
15
|
-
legacy: "This older daemon does not support guarded upgrades. Let sync work finish, run restart from the intended daemon CLI, then /reload.",
|
|
16
|
-
};
|
|
17
|
-
export class DaemonUpgradeBlockedError extends Error {
|
|
18
|
-
instance;
|
|
19
|
-
constructor(instance, reason) {
|
|
20
|
-
super(upgradeBlockers[reason]);
|
|
21
|
-
this.instance = instance;
|
|
22
|
-
this.name = "DaemonUpgradeBlockedError";
|
|
23
|
-
}
|
|
24
|
-
}
|
|
12
|
+
export { DaemonUpgradeBlockedError } from "./daemon-upgrade-error.js";
|
|
25
13
|
function matchesBuild(version, id) {
|
|
26
14
|
return version === DAEMON_BUILD_VERSION && id === DAEMON_BUILD_ID;
|
|
27
15
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const upgradeBlockers = {
|
|
2
|
+
busy: "Daemon update deferred while sync work is active. Let it finish, then use /reload or retry the daemon CLI.",
|
|
3
|
+
repair: "Daemon update blocked by uncertain consent or queue cleanup. Follow the daemon recovery guide before retrying.",
|
|
4
|
+
unattended: "Review or revoke unattended Pi Sync permission before stopping or replacing the daemon.",
|
|
5
|
+
legacy: "This older daemon does not support guarded upgrades. Let sync work finish, run restart from the intended daemon CLI, then /reload.",
|
|
6
|
+
};
|
|
7
|
+
export class DaemonUpgradeBlockedError extends Error {
|
|
8
|
+
instance;
|
|
9
|
+
constructor(instance, reason) {
|
|
10
|
+
super(upgradeBlockers[reason]);
|
|
11
|
+
this.instance = instance;
|
|
12
|
+
this.name = "DaemonUpgradeBlockedError";
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -15,8 +15,6 @@ export function needsDirectionalForce(intent, config, state, destination, candid
|
|
|
15
15
|
? new Map(Object.entries(stateHashMapForConfig(state, config)))
|
|
16
16
|
: new Map();
|
|
17
17
|
const conflicts = [...new Set([...accepted.keys(), ...current.keys()])].some((path) => !protectedPaths.has(path) && current.get(path) !== accepted.get(path) && current.get(path) !== proposed.get(path));
|
|
18
|
-
if (conflicts && !state.lastAppliedSnapshot)
|
|
19
|
-
throw new Error("This destination has no accepted sync baseline. Review first sync with Sync… before replacing content.");
|
|
20
18
|
if (!conflicts && intent === "review-force")
|
|
21
19
|
throw new Error("The destination no longer has a content conflict. Start a normal transfer again.");
|
|
22
20
|
return conflicts;
|
|
@@ -1,10 +1,27 @@
|
|
|
1
1
|
export { DaemonConnection, DaemonError, ensureDaemon, findDaemon, requestDaemon, stopDaemon, waitForDaemonExit, } from "./client.js";
|
|
2
|
-
export {
|
|
3
|
-
export { DaemonUpgradeBlockedError } from "./daemon-startup.js";
|
|
4
|
-
export { inspectDaemonStatus } from "./daemon-status.js";
|
|
2
|
+
export { DaemonUpgradeBlockedError } from "./daemon-upgrade-error.js";
|
|
5
3
|
export { parseDiffReviewInventory } from "./diff-review-protocol.js";
|
|
6
4
|
export { documentFingerprint } from "./document.js";
|
|
7
5
|
export { isDestinationConflict } from "./foreground-transfer.js";
|
|
8
6
|
export { modelSignature } from "./model-signature.js";
|
|
9
7
|
export { MAX_SETTINGS_BYTES, OWNERSHIP_CLEANUP_REQUIRED, PROTOCOL_VERSION } from "./protocol.js";
|
|
10
8
|
export { createSessionPresence } from "./session-presence.js";
|
|
9
|
+
export async function inspectDaemonStatus(root, signal) {
|
|
10
|
+
signal?.throwIfAborted();
|
|
11
|
+
const { inspectDaemonStatus } = await import("./daemon-status.js");
|
|
12
|
+
signal?.throwIfAborted();
|
|
13
|
+
return inspectDaemonStatus(root, signal);
|
|
14
|
+
}
|
|
15
|
+
export async function inspectDaemonRecovery(root, signal) {
|
|
16
|
+
signal?.throwIfAborted();
|
|
17
|
+
const { inspectDaemonRecovery } = await import("./daemon-recovery.js");
|
|
18
|
+
signal?.throwIfAborted();
|
|
19
|
+
return inspectDaemonRecovery(root, signal);
|
|
20
|
+
}
|
|
21
|
+
export async function stopDaemonForRecovery(target, signal) {
|
|
22
|
+
signal?.throwIfAborted();
|
|
23
|
+
const reviewed = { ...target };
|
|
24
|
+
const { stopDaemonForRecovery } = await import("./daemon-recovery.js");
|
|
25
|
+
signal?.throwIfAborted();
|
|
26
|
+
return stopDaemonForRecovery(reviewed, signal);
|
|
27
|
+
}
|
package/dist/daemon/package.json
CHANGED
package/dist/index.ts
CHANGED
|
@@ -1,53 +1,50 @@
|
|
|
1
1
|
// @generated by scripts/build-runtime.mjs; do not edit.
|
|
2
2
|
// @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
|
|
3
|
-
import {
|
|
4
|
-
createSyncAttentionController,
|
|
5
|
-
readStateForConfig,
|
|
6
|
-
syncStateFingerprint
|
|
7
|
-
} from "./chunks/chunk-5T4ZOHYF.ts";
|
|
8
|
-
import {
|
|
9
|
-
combineSignals,
|
|
10
|
-
throwIfAborted
|
|
11
|
-
} from "./chunks/chunk-UMPA5S7X.ts";
|
|
12
|
-
import {
|
|
13
|
-
completeSyncArguments,
|
|
14
|
-
retiredSyncCommandGuidance,
|
|
15
|
-
setSyncSetupCompletions,
|
|
16
|
-
splitArgs
|
|
17
|
-
} from "./chunks/chunk-VQTYTUBU.ts";
|
|
18
|
-
import {
|
|
19
|
-
withStateDirectoryAccess
|
|
20
|
-
} from "./chunks/chunk-T3LABNHF.ts";
|
|
21
3
|
import {
|
|
22
4
|
snapshotOptionsForContext
|
|
23
5
|
} from "./chunks/chunk-P4GI7LTT.ts";
|
|
24
|
-
import "./chunks/chunk-ZO52JM4H.ts";
|
|
25
|
-
import {
|
|
26
|
-
configFromSettings,
|
|
27
|
-
loadConfigForCheck,
|
|
28
|
-
syncCheckConfigFingerprint,
|
|
29
|
-
syncConfigReviewFingerprint
|
|
30
|
-
} from "./chunks/chunk-LNZRNXNQ.ts";
|
|
31
6
|
import {
|
|
32
7
|
bindPiDaemonClient,
|
|
33
8
|
installPiDaemonHost,
|
|
34
9
|
piDaemonClient,
|
|
35
10
|
withPiDaemonClient
|
|
36
|
-
} from "./chunks/chunk-
|
|
11
|
+
} from "./chunks/chunk-KN4NY2VV.ts";
|
|
12
|
+
import {
|
|
13
|
+
createSyncAttentionController
|
|
14
|
+
} from "./chunks/chunk-WRS3SUNZ.ts";
|
|
15
|
+
import "./chunks/chunk-ZO52JM4H.ts";
|
|
37
16
|
import {
|
|
38
17
|
configureSyncStatus,
|
|
39
18
|
createSyncStatusPublisher,
|
|
40
19
|
setSyncStatus
|
|
41
20
|
} from "./chunks/chunk-H7VOTY5N.ts";
|
|
42
21
|
import {
|
|
43
|
-
|
|
44
|
-
|
|
22
|
+
combineSignals,
|
|
23
|
+
throwIfAborted
|
|
24
|
+
} from "./chunks/chunk-UMPA5S7X.ts";
|
|
45
25
|
import {
|
|
46
26
|
syncSessionsSelected
|
|
47
27
|
} from "./chunks/chunk-R3SAMXB6.ts";
|
|
28
|
+
import {
|
|
29
|
+
completeSyncArguments,
|
|
30
|
+
retiredSyncCommandGuidance,
|
|
31
|
+
setSyncSetupCompletions,
|
|
32
|
+
splitArgs
|
|
33
|
+
} from "./chunks/chunk-VQTYTUBU.ts";
|
|
34
|
+
import {
|
|
35
|
+
errorMessage
|
|
36
|
+
} from "./chunks/chunk-6YKOHBSC.ts";
|
|
48
37
|
import {
|
|
49
38
|
safeTerminalText
|
|
50
39
|
} from "./chunks/chunk-AMJRUXFT.ts";
|
|
40
|
+
import {
|
|
41
|
+
withStateDirectoryAccess
|
|
42
|
+
} from "./chunks/chunk-T3LABNHF.ts";
|
|
43
|
+
import {
|
|
44
|
+
configFromSettings,
|
|
45
|
+
loadConfigForCheck,
|
|
46
|
+
syncCheckConfigFingerprint
|
|
47
|
+
} from "./chunks/chunk-LNZRNXNQ.ts";
|
|
51
48
|
|
|
52
49
|
// src/daemon/session-presence.ts
|
|
53
50
|
import { createSessionPresence } from "#pi-sync-daemon";
|
|
@@ -130,7 +127,9 @@ async function startSession(ctx, signal, publish) {
|
|
|
130
127
|
client.validate();
|
|
131
128
|
throwIfAborted(signal);
|
|
132
129
|
const debug = settings?.debug ?? false;
|
|
133
|
-
client.setDebugPreference(debug);
|
|
130
|
+
await client.setDebugPreference(debug);
|
|
131
|
+
client.validate();
|
|
132
|
+
throwIfAborted(signal);
|
|
134
133
|
configureSyncStatus(ctx, settings?.showStatus ?? true);
|
|
135
134
|
const { stateDirectoryMigrationNotice } = await import("./chunks/state-directory-CMAIF34J.ts");
|
|
136
135
|
client.validate();
|
|
@@ -219,14 +218,8 @@ async function autoPushSessions(ctx, signal, _loaders) {
|
|
|
219
218
|
|
|
220
219
|
// src/sync/debug-tool.ts
|
|
221
220
|
import { StringEnum } from "@earendil-works/pi-ai";
|
|
222
|
-
import { debugCheckFailure, summarizeDebugInspection } from "#pi-sync-daemon/engine/debug-check";
|
|
223
|
-
import { readLatestDebugCheck } from "#pi-sync-daemon/engine/debug-log";
|
|
224
221
|
import { Type } from "typebox";
|
|
225
222
|
var TOOL_NAME = "pi_sync_debug";
|
|
226
|
-
var RECHECK_TIMEOUT_MS = 3e4;
|
|
227
|
-
function toolResult(value) {
|
|
228
|
-
return { content: [{ type: "text", text: JSON.stringify(value) }], details: {} };
|
|
229
|
-
}
|
|
230
223
|
function registerPiSyncDebug(pi, getOwner) {
|
|
231
224
|
pi.registerTool({
|
|
232
225
|
name: TOOL_NAME,
|
|
@@ -251,52 +244,13 @@ function registerPiSyncDebug(pi, getOwner) {
|
|
|
251
244
|
throw new Error("The Pi Sync debug session is no longer available.");
|
|
252
245
|
}
|
|
253
246
|
};
|
|
254
|
-
async function readSetup() {
|
|
255
|
-
validate();
|
|
256
|
-
try {
|
|
257
|
-
const { settings } = await client.readStartupSettings(signal);
|
|
258
|
-
validate();
|
|
259
|
-
if (settings) return configFromSettings(settings);
|
|
260
|
-
} catch {
|
|
261
|
-
validate();
|
|
262
|
-
}
|
|
263
|
-
throw new Error("The current Pi Sync setup is not available. Review /sync \u2192 Settings.");
|
|
264
|
-
}
|
|
265
|
-
const setup = await readSetup();
|
|
266
247
|
validate();
|
|
267
|
-
|
|
268
|
-
const last = readLatestDebugCheck(client.root, syncConfigReviewFingerprint(setup));
|
|
269
|
-
if (last.kind === "unavailable") throw new Error("The private Pi Sync debug log is unavailable.");
|
|
270
|
-
if (last.kind === "no-record") return toolResult({ kind: "no-record" });
|
|
271
|
-
return toolResult({ kind: "historical", ...last.check });
|
|
272
|
-
}
|
|
273
|
-
if (action !== "recheck") throw new Error("Choose latest or recheck.");
|
|
274
|
-
if (client.ownershipCleanupRequired) throw new Error("Pi Sync needs recovery. Open /sync daemon status.");
|
|
275
|
-
const fingerprint = syncCheckConfigFingerprint(setup);
|
|
276
|
-
const deadline = AbortSignal.timeout(RECHECK_TIMEOUT_MS);
|
|
277
|
-
const recheckSignal = AbortSignal.any([signal, deadline]);
|
|
278
|
-
let result;
|
|
279
|
-
try {
|
|
280
|
-
result = await client.run(
|
|
281
|
-
"inspect",
|
|
282
|
-
{ setup: setup.setupName, fingerprint, origin: "recheck" },
|
|
283
|
-
recheckSignal,
|
|
284
|
-
ctx
|
|
285
|
-
);
|
|
286
|
-
} catch (error) {
|
|
248
|
+
const { executeDebugTool } = await import("./chunks/debug-tool-execution-7N4H6K3X.ts").catch(() => {
|
|
287
249
|
validate();
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
}
|
|
291
|
-
validate();
|
|
292
|
-
if (deadline.aborted) throw new Error("Pi Sync recheck failed: timeout.");
|
|
293
|
-
const latest = await readSetup();
|
|
250
|
+
throw new Error("Pi Sync debug could not load.");
|
|
251
|
+
});
|
|
294
252
|
validate();
|
|
295
|
-
|
|
296
|
-
throw new Error("Pi Sync setup changed during recheck. Ask to recheck the new setup.");
|
|
297
|
-
const summary = summarizeDebugInspection(result);
|
|
298
|
-
if (!summary) throw new Error("Pi Sync did not return a valid check result.");
|
|
299
|
-
return toolResult({ kind: "fresh", time: (/* @__PURE__ */ new Date()).toISOString(), origin: "recheck", summary });
|
|
253
|
+
return executeDebugTool(action, ctx, client, signal, validate);
|
|
300
254
|
}
|
|
301
255
|
});
|
|
302
256
|
return (enabled) => {
|
|
@@ -370,6 +324,9 @@ function createStartupCheck(loaders, attention, timeoutMs = 3e4, publish) {
|
|
|
370
324
|
() => inspectSync(captured, snapshotOptionsForContext(ctx, captured), signal, void 0, timings)
|
|
371
325
|
);
|
|
372
326
|
throwIfAborted(signal);
|
|
327
|
+
const { readStateForConfig, syncStateFingerprint } = await import("./chunks/sync-state-store-TZE7XDV5.ts");
|
|
328
|
+
throwIfAborted(signal);
|
|
329
|
+
if (!isCurrent()) return;
|
|
373
330
|
const latest = await loadConfigForCheck(void 0, signal);
|
|
374
331
|
throwIfAborted(signal);
|
|
375
332
|
if (syncCheckConfigFingerprint(latest) !== identity) return;
|
|
@@ -480,12 +437,12 @@ function createStartupCheck(loaders, attention, timeoutMs = 3e4, publish) {
|
|
|
480
437
|
// src/sync/sync-loaders.ts
|
|
481
438
|
function createSyncLoaders(dependencies) {
|
|
482
439
|
const loaders = {
|
|
483
|
-
commands: cachedModuleLoader(dependencies.loadCommandHandler ?? (() => import("./chunks/command-handler-
|
|
484
|
-
inspection: cachedModuleLoader(dependencies.loadSyncInspection ?? (() => import("./chunks/sync-inspection-
|
|
485
|
-
setupSwitch: cachedModuleLoader(dependencies.loadSetupSwitch ?? (() => import("./chunks/setup-switch-
|
|
440
|
+
commands: cachedModuleLoader(dependencies.loadCommandHandler ?? (() => import("./chunks/command-handler-GERC7LOE.ts"))),
|
|
441
|
+
inspection: cachedModuleLoader(dependencies.loadSyncInspection ?? (() => import("./chunks/sync-inspection-ECI4BY5N.ts"))),
|
|
442
|
+
setupSwitch: cachedModuleLoader(dependencies.loadSetupSwitch ?? (() => import("./chunks/setup-switch-WSKVGW7L.ts"))),
|
|
486
443
|
snapshot: cachedModuleLoader(dependencies.loadSnapshot ?? (() => import("./chunks/snapshot-ZUJJZCFW.ts"))),
|
|
487
444
|
syncState: cachedModuleLoader(dependencies.loadSyncState ?? (() => import("./chunks/sync-state-QIT64TKV.ts"))),
|
|
488
|
-
operations: cachedModuleLoader(dependencies.loadSyncOperations ?? (() => import("./chunks/sync-operations-
|
|
445
|
+
operations: cachedModuleLoader(dependencies.loadSyncOperations ?? (() => import("./chunks/sync-operations-KWXZZEPT.ts")))
|
|
489
446
|
};
|
|
490
447
|
return loaders;
|
|
491
448
|
}
|
|
@@ -793,7 +750,8 @@ function sync(pi, dependencies = {}) {
|
|
|
793
750
|
if (signal.aborted || owner !== client) return;
|
|
794
751
|
if (reason !== "reload") {
|
|
795
752
|
shutdownClient = bindPiDaemonClient(ctx, signal, publishTimings);
|
|
796
|
-
shutdownClient.setDebugPreference(client.debugEnabled);
|
|
753
|
+
await shutdownClient.setDebugPreference(client.debugEnabled);
|
|
754
|
+
if (signal.aborted || owner !== client) return;
|
|
797
755
|
await shutdownClient.setBusy("shutdown", true);
|
|
798
756
|
const attached = await shutdownClient.attachExisting();
|
|
799
757
|
if (!signal.aborted && owner === client && attached)
|