@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.
Files changed (74) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +5 -3
  3. package/dist/chunks/{chunk-3XN4FR72.ts → chunk-4A34OGXY.ts} +9 -9
  4. package/dist/chunks/{chunk-7NQ7SFZK.ts → chunk-5BE6LBDC.ts} +15 -15
  5. package/dist/chunks/chunk-A43CJYG4.ts +26 -0
  6. package/dist/chunks/chunk-A43CJYG4.ts.map +7 -0
  7. package/dist/chunks/{chunk-JPTI4HFC.ts → chunk-AXN3B5KC.ts} +22 -22
  8. package/dist/chunks/{chunk-SPXEDJ2G.ts → chunk-KN4NY2VV.ts} +15 -42
  9. package/dist/chunks/chunk-KN4NY2VV.ts.map +7 -0
  10. package/dist/chunks/{chunk-N24HEZSA.ts → chunk-VERMBZGL.ts} +7 -7
  11. package/dist/chunks/{chunk-V4IGBXBA.ts → chunk-WE3KJ7JS.ts} +9 -8
  12. package/dist/chunks/chunk-WE3KJ7JS.ts.map +7 -0
  13. package/dist/chunks/{chunk-5T4ZOHYF.ts → chunk-WRS3SUNZ.ts} +4 -18
  14. package/dist/chunks/chunk-WRS3SUNZ.ts.map +7 -0
  15. package/dist/chunks/client-debug-F4WFP2YJ.ts +40 -0
  16. package/dist/chunks/client-debug-F4WFP2YJ.ts.map +7 -0
  17. package/dist/chunks/{command-handler-4XHK5PVX.ts → command-handler-GERC7LOE.ts} +34 -32
  18. package/dist/chunks/{command-handler-4XHK5PVX.ts.map → command-handler-GERC7LOE.ts.map} +1 -1
  19. package/dist/chunks/{conflict-review-QI77P7KL.ts → conflict-review-XZI7RYZX.ts} +3 -3
  20. package/dist/chunks/debug-tool-execution-7N4H6K3X.ts +67 -0
  21. package/dist/chunks/debug-tool-execution-7N4H6K3X.ts.map +7 -0
  22. package/dist/chunks/{diff-review-SOLP33TQ.ts → diff-review-FLWC5VOT.ts} +3 -3
  23. package/dist/chunks/{diff-review-ILRZDQ4S.ts → diff-review-GB4NO53B.ts} +4 -4
  24. package/dist/chunks/{file-selection-2H3J2HTX.ts → file-selection-DGC5UJVI.ts} +9 -9
  25. package/dist/chunks/{manager-result-dispatcher-YXSDLTLV.ts → manager-result-dispatcher-6MOJPLIS.ts} +7 -7
  26. package/dist/chunks/{manager-ui-RQSZLMJ5.ts → manager-ui-3CQU37XY.ts} +90 -68
  27. package/dist/chunks/manager-ui-3CQU37XY.ts.map +7 -0
  28. package/dist/chunks/{remote-selection-ui-AE6FOEXH.ts → remote-selection-ui-2V53UBHM.ts} +6 -6
  29. package/dist/chunks/{setup-switch-LJPEZONY.ts → setup-switch-WSKVGW7L.ts} +4 -4
  30. package/dist/chunks/{setup-wizard-FBX7RTZ6.ts → setup-wizard-FRIR2EOR.ts} +9 -9
  31. package/dist/chunks/{sync-inspection-TZ4EMSBN.ts → sync-inspection-ECI4BY5N.ts} +6 -6
  32. package/dist/chunks/{sync-operations-QIQ3G66S.ts → sync-operations-KWXZZEPT.ts} +4 -4
  33. package/dist/chunks/sync-state-store-TZE7XDV5.ts +23 -0
  34. package/dist/chunks/sync-state-store-TZE7XDV5.ts.map +7 -0
  35. package/dist/daemon/dist/build-id.json +1 -1
  36. package/dist/daemon/dist/cli.js +3 -2
  37. package/dist/daemon/dist/client.js +55 -14
  38. package/dist/daemon/dist/daemon-startup.js +2 -14
  39. package/dist/daemon/dist/daemon-upgrade-error.js +14 -0
  40. package/dist/daemon/dist/engine/sync/directional-conflict.js +0 -2
  41. package/dist/daemon/dist/index.js +20 -3
  42. package/dist/daemon/package.json +1 -1
  43. package/dist/index.ts +41 -83
  44. package/dist/index.ts.map +2 -2
  45. package/docs/daemon-migration.md +2 -0
  46. package/docs/tui-contract.md +2 -2
  47. package/package.json +2 -2
  48. package/src/daemon/client-debug.ts +2 -0
  49. package/src/daemon/pi-client.ts +15 -7
  50. package/src/sync/automatic-sync.ts +3 -1
  51. package/src/sync/debug-tool-execution.ts +66 -0
  52. package/src/sync/debug-tool.ts +4 -51
  53. package/src/sync/startup-check.ts +3 -1
  54. package/src/sync-extension.ts +2 -1
  55. package/src/ui/manager-ui.ts +41 -20
  56. package/src/ui/sync-resolution-ui.ts +3 -0
  57. package/dist/chunks/chunk-5T4ZOHYF.ts.map +0 -7
  58. package/dist/chunks/chunk-SPXEDJ2G.ts.map +0 -7
  59. package/dist/chunks/chunk-V4IGBXBA.ts.map +0 -7
  60. package/dist/chunks/manager-ui-RQSZLMJ5.ts.map +0 -7
  61. /package/dist/chunks/{chunk-3XN4FR72.ts.map → chunk-4A34OGXY.ts.map} +0 -0
  62. /package/dist/chunks/{chunk-7NQ7SFZK.ts.map → chunk-5BE6LBDC.ts.map} +0 -0
  63. /package/dist/chunks/{chunk-JPTI4HFC.ts.map → chunk-AXN3B5KC.ts.map} +0 -0
  64. /package/dist/chunks/{chunk-N24HEZSA.ts.map → chunk-VERMBZGL.ts.map} +0 -0
  65. /package/dist/chunks/{conflict-review-QI77P7KL.ts.map → conflict-review-XZI7RYZX.ts.map} +0 -0
  66. /package/dist/chunks/{diff-review-SOLP33TQ.ts.map → diff-review-FLWC5VOT.ts.map} +0 -0
  67. /package/dist/chunks/{diff-review-ILRZDQ4S.ts.map → diff-review-GB4NO53B.ts.map} +0 -0
  68. /package/dist/chunks/{file-selection-2H3J2HTX.ts.map → file-selection-DGC5UJVI.ts.map} +0 -0
  69. /package/dist/chunks/{manager-result-dispatcher-YXSDLTLV.ts.map → manager-result-dispatcher-6MOJPLIS.ts.map} +0 -0
  70. /package/dist/chunks/{remote-selection-ui-AE6FOEXH.ts.map → remote-selection-ui-2V53UBHM.ts.map} +0 -0
  71. /package/dist/chunks/{setup-switch-LJPEZONY.ts.map → setup-switch-WSKVGW7L.ts.map} +0 -0
  72. /package/dist/chunks/{setup-wizard-FBX7RTZ6.ts.map → setup-wizard-FRIR2EOR.ts.map} +0 -0
  73. /package/dist/chunks/{sync-inspection-TZ4EMSBN.ts.map → sync-inspection-ECI4BY5N.ts.map} +0 -0
  74. /package/dist/chunks/{sync-operations-QIQ3G66S.ts.map → sync-operations-KWXZZEPT.ts.map} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @narumitw/pi-sync
2
2
 
3
+ ## 0.70.6
4
+
5
+ ### Patch Changes
6
+
7
+ - a71f120: Reduce cold Pi Sync startup work by loading client diagnostics only when enabled or used, and loading the sync state reader only when a check or command needs it. Session protection, daemon admission, and recovery still finish at the same readiness boundaries.
8
+
9
+ ## 0.70.5
10
+
11
+ ### Patch Changes
12
+
13
+ - 6e50a48: Offer a read-only comparison or an explicitly confirmed Force pull or Force push when a directional transfer would discard destination changes, including on first sync. Make the initial source choices easier to find from the first-sync difference review.
14
+
3
15
  ## 0.70.4
4
16
 
5
17
  ### Patch Changes
package/README.md CHANGED
@@ -86,9 +86,11 @@ Remote status: Not checked
86
86
  Last applied snapshot: Never synced
87
87
  ```
88
88
 
89
- Use **Sync…** (**Sync now** in RPC) to merge both ways. **Push to remote** uses this device's version for managed files; **Pull from remote** uses the remote version. After daemon handover, choosing either action transfers without another confirmation if it will not discard a destination change since the last accepted sync. This includes protecting local edits when only this device changed. Use **View differences** first if you want to review all changes, including additions and deletions. If the destination has conflicting content but no accepted baseline, use **Sync…** for first-sync review.
89
+ Use **Sync…** (**Sync now** in RPC) to merge both ways. **Push to remote** uses this device's version for managed files; **Pull from remote** uses the remote version. After daemon handover, these two actions transfer without another confirmation if they will not discard destination changes.
90
90
 
91
- If a transfer stops before writing because it would discard a destination change, choose **Review Force push…** or **Review Force pull…**. Review the exact changes before confirming; cancellation is the default. A stale preview cannot authorize a write, and unrelated errors do not offer Force. Push preserves the previous remote version in **History**; Pull creates a local backup before applying changes. See [Recover excluded files from History](#recover-excluded-files-from-history) for files the current rules no longer select.
91
+ If either action would discard destination changes, including on first sync, choose **Review differences** to compare without transferring, or **Force pull…** / **Force push…** to review the exact changes and confirm replacement. Pull backs up local files before applying. Push preserves the previous remote version in **History**; see [Recover excluded files from History](#recover-excluded-files-from-history) for files the current rules no longer select.
92
+
93
+ A stale preview cannot authorize a write, and unrelated errors do not offer Force.
92
94
 
93
95
  Selecting a direction does not authorize background transfers or model use. If a file-queue release cannot be confirmed, Pi Sync [recovers the original job when it can](./docs/daemon-migration.md#recover-from-uncertain-daemon-cleanup). It never repeats a known commit, guesses when the write outcome is unknown, or reuses a Force approval for another attempt. For a pending journal from the retired ignore-file policy, follow the [manual recovery guide](./skills/configure-pi-sync/references/configuration.md#retired-ignore-file-policy).
94
96
 
@@ -158,7 +160,7 @@ Then choose one reviewed direction:
158
160
  It applies the [secret-scan setting](./skills/configure-pi-sync/references/configuration.md#secret-scanning), shows the exact remote publication effect, re-reads a changed remote head, and asks again if the reviewed plan changed.
159
161
  - **Use remote content and replace local…** uses the existing forced-pull path.
160
162
  It shows exact local writes and deletions, protects the live session, and creates a local backup before applying.
161
- - First sync uses **Use local as initial source…** and **Use remote as initial source…** labels.
163
+ - On first sync, select **Choose initial source** from the difference review to return to **Use local as initial source…** and **Use remote as initial source…**. This does not start a transfer.
162
164
  An empty remote offers **Push local content…** only.
163
165
 
164
166
  Cancelling a preparation or confirmation returns to conflict resolution with no side effects.
@@ -7,12 +7,18 @@ import {
7
7
  configuredSyncSetupNames,
8
8
  updateLocalConfig
9
9
  } from "./chunk-R7PN3KIY.ts";
10
+ import {
11
+ captureMutationOwner
12
+ } from "./chunk-GELYN4UC.ts";
10
13
  import {
11
14
  setSyncSetupCompletions
12
15
  } from "./chunk-VQTYTUBU.ts";
13
16
  import {
14
- captureMutationOwner
15
- } from "./chunk-GELYN4UC.ts";
17
+ SetupPullRequiresUiError
18
+ } from "./chunk-6YKOHBSC.ts";
19
+ import {
20
+ safeTerminalText
21
+ } from "./chunk-AMJRUXFT.ts";
16
22
  import {
17
23
  configFromSettings,
18
24
  loadConfigForCheck,
@@ -20,12 +26,6 @@ import {
20
26
  syncCheckConfigFingerprint,
21
27
  syncConfigReviewIdentity
22
28
  } from "./chunk-LNZRNXNQ.ts";
23
- import {
24
- SetupPullRequiresUiError
25
- } from "./chunk-6YKOHBSC.ts";
26
- import {
27
- safeTerminalText
28
- } from "./chunk-AMJRUXFT.ts";
29
29
 
30
30
  // src/sync/setup-switch.ts
31
31
  var SETUP_SWITCH_ACTION_OPTIONS = [
@@ -143,4 +143,4 @@ export {
143
143
  saveOnSwitch,
144
144
  useSyncSetup
145
145
  };
146
- //# sourceMappingURL=chunk-3XN4FR72.ts.map
146
+ //# sourceMappingURL=chunk-4A34OGXY.ts.map
@@ -1,12 +1,5 @@
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
- throwIfAborted
5
- } from "./chunk-UMPA5S7X.ts";
6
- import {
7
- runCancellableOperation,
8
- runCancellableTask
9
- } from "./chunk-ZWP6HAYV.ts";
10
3
  import {
11
4
  SyncSetupReviewChangedError,
12
5
  updateSyncSetup
@@ -17,26 +10,33 @@ import {
17
10
  import {
18
11
  sameSyncExclude
19
12
  } from "./chunk-ZO52JM4H.ts";
20
- import {
21
- loadConfig,
22
- syncCheckConfigFingerprint,
23
- syncConfigReviewFingerprint
24
- } from "./chunk-LNZRNXNQ.ts";
25
13
  import {
26
14
  setSyncStatus
27
15
  } from "./chunk-H7VOTY5N.ts";
28
16
  import {
29
- errorMessage
30
- } from "./chunk-6YKOHBSC.ts";
17
+ throwIfAborted
18
+ } from "./chunk-UMPA5S7X.ts";
31
19
  import {
32
20
  compareSyncInclude,
33
21
  inspectRemoteSelection,
34
22
  sameSyncInclude,
35
23
  syncDirectoryPolicyKey
36
24
  } from "./chunk-R3SAMXB6.ts";
25
+ import {
26
+ errorMessage
27
+ } from "./chunk-6YKOHBSC.ts";
28
+ import {
29
+ runCancellableOperation,
30
+ runCancellableTask
31
+ } from "./chunk-ZWP6HAYV.ts";
37
32
  import {
38
33
  safeTerminalText
39
34
  } from "./chunk-AMJRUXFT.ts";
35
+ import {
36
+ loadConfig,
37
+ syncCheckConfigFingerprint,
38
+ syncConfigReviewFingerprint
39
+ } from "./chunk-LNZRNXNQ.ts";
40
40
 
41
41
  // src/ui/remote-selection-ui.ts
42
42
  import { defineMenu, runMenu } from "@narumitw/pi-tui-kit";
@@ -689,4 +689,4 @@ function combineSignals(sessionSignal, actionSignal) {
689
689
  export {
690
690
  showRemoteSelectionReview
691
691
  };
692
- //# sourceMappingURL=chunk-7NQ7SFZK.ts.map
692
+ //# sourceMappingURL=chunk-5BE6LBDC.ts.map
@@ -0,0 +1,26 @@
1
+ // @generated by scripts/build-runtime.mjs; do not edit.
2
+ // @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
3
+
4
+ // src/state/sync-state-store.ts
5
+ import {
6
+ ensureStateDir,
7
+ lockPath,
8
+ readState,
9
+ readStateForConfig,
10
+ statePathForConfig,
11
+ syncStateFingerprint,
12
+ writeState,
13
+ writeStateForConfig
14
+ } from "#pi-sync-daemon/engine/state/sync-state-store";
15
+
16
+ export {
17
+ ensureStateDir,
18
+ lockPath,
19
+ readState,
20
+ readStateForConfig,
21
+ statePathForConfig,
22
+ syncStateFingerprint,
23
+ writeState,
24
+ writeStateForConfig
25
+ };
26
+ //# sourceMappingURL=chunk-A43CJYG4.ts.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/state/sync-state-store.ts"],
4
+ "sourcesContent": ["export type * from \"@narumitw/pi-sync-daemon/engine/state/sync-state-store\";\nexport {\n ensureStateDir,\n lockPath,\n readState,\n readStateForConfig,\n statePathForConfig,\n syncStateFingerprint,\n writeState,\n writeStateForConfig,\n} from \"@narumitw/pi-sync-daemon/engine/state/sync-state-store\";\n"],
5
+ "mappings": ";;;;AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;",
6
+ "names": []
7
+ }
@@ -1,5 +1,19 @@
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
+ acknowledgeSessions,
5
+ directoryScopeLines,
6
+ promptDirectoryRules,
7
+ saveReviewedDraft,
8
+ starterDirectoryRules
9
+ } from "./chunk-HFMGK6A6.ts";
10
+ import {
11
+ addStorageConnection,
12
+ addSyncSetup,
13
+ saveNewV3Settings,
14
+ updateStorageConnection,
15
+ updateSyncSetup
16
+ } from "./chunk-NXWHPVXR.ts";
3
17
  import {
4
18
  effectiveSyncSetupRemoteIdentity,
5
19
  normalizeS3Bucket,
@@ -13,36 +27,22 @@ import {
13
27
  configuredSyncSetupNames,
14
28
  readLocalConfigObject
15
29
  } from "./chunk-R7PN3KIY.ts";
30
+ import {
31
+ captureMutationOwner
32
+ } from "./chunk-GELYN4UC.ts";
16
33
  import {
17
34
  throwIfAborted
18
35
  } from "./chunk-UMPA5S7X.ts";
36
+ import {
37
+ DEFAULT_SYNC_INCLUDE
38
+ } from "./chunk-R3SAMXB6.ts";
19
39
  import {
20
40
  AUTOMATIC_SYNC_DESCRIPTION,
21
41
  setSyncSetupCompletions
22
42
  } from "./chunk-VQTYTUBU.ts";
23
- import {
24
- acknowledgeSessions,
25
- directoryScopeLines,
26
- promptDirectoryRules,
27
- saveReviewedDraft,
28
- starterDirectoryRules
29
- } from "./chunk-HFMGK6A6.ts";
30
- import {
31
- addStorageConnection,
32
- addSyncSetup,
33
- saveNewV3Settings,
34
- updateStorageConnection,
35
- updateSyncSetup
36
- } from "./chunk-NXWHPVXR.ts";
37
- import {
38
- captureMutationOwner
39
- } from "./chunk-GELYN4UC.ts";
40
43
  import {
41
44
  errorMessage
42
45
  } from "./chunk-6YKOHBSC.ts";
43
- import {
44
- DEFAULT_SYNC_INCLUDE
45
- } from "./chunk-R3SAMXB6.ts";
46
46
  import {
47
47
  safeTerminalText
48
48
  } from "./chunk-AMJRUXFT.ts";
@@ -289,7 +289,7 @@ async function finishSetup(ctx, name, message, join, signal) {
289
289
  if (signal?.aborted) return;
290
290
  ctx.ui.notify(message, "info");
291
291
  if (!join) return;
292
- const { showRemoteSelectionReview } = await import("./remote-selection-ui-AE6FOEXH.ts");
292
+ const { showRemoteSelectionReview } = await import("./remote-selection-ui-2V53UBHM.ts");
293
293
  if (signal?.aborted) return;
294
294
  await showRemoteSelectionReview(ctx, name, signal, void 0, { origin: "settings" });
295
295
  }
@@ -1038,4 +1038,4 @@ export {
1038
1038
  showAddWebDavStorageProfile,
1039
1039
  showEditWebDavStorageProfile
1040
1040
  };
1041
- //# sourceMappingURL=chunk-JPTI4HFC.ts.map
1041
+ //# sourceMappingURL=chunk-AXN3B5KC.ts.map
@@ -5,13 +5,13 @@ import {
5
5
  showSyncConnectionStatus,
6
6
  showSyncQueueReleaseRecovery
7
7
  } from "./chunk-H7VOTY5N.ts";
8
+ import {
9
+ RemoteSelectionMismatchError
10
+ } from "./chunk-R3SAMXB6.ts";
8
11
  import {
9
12
  SyncDecisionRequiredError,
10
13
  errorMessage
11
14
  } from "./chunk-6YKOHBSC.ts";
12
- import {
13
- RemoteSelectionMismatchError
14
- } from "./chunk-R3SAMXB6.ts";
15
15
  import {
16
16
  safeTerminalText
17
17
  } from "./chunk-AMJRUXFT.ts";
@@ -36,7 +36,6 @@ import {
36
36
  requestDaemon as requestDaemon2,
37
37
  waitForDaemonExit
38
38
  } from "#pi-sync-daemon";
39
- import { appendDebugEvent } from "#pi-sync-daemon/engine/debug-log";
40
39
  import { configureEngineHost } from "#pi-sync-daemon/engine/host";
41
40
  import {
42
41
  peekLocalConfigDocument
@@ -171,38 +170,6 @@ var PiApplyGate = class {
171
170
  }
172
171
  };
173
172
 
174
- // src/daemon/client-debug.ts
175
- import { debugJobResult, debugOperation } from "#pi-sync-daemon/engine/debug-log";
176
- function observeDebugJob(operation, append) {
177
- const kind = debugOperation(operation);
178
- if (!kind) return void 0;
179
- let operationId;
180
- const record = (outcome) => append({ event: "job", operation: kind, outcome, ...operationId ? { operationId } : {} });
181
- return {
182
- onSubmit(id) {
183
- if (operationId && operationId !== id) record("blocked");
184
- operationId = id;
185
- record("started");
186
- },
187
- returned(result, interrupted = false) {
188
- const outcome = debugJobResult(kind, result);
189
- if (interrupted && outcome !== "completed") record("cancelled");
190
- else if (outcome) record(outcome);
191
- else if (result === "archived" || kind === "initialize" && typeof result === "object" && result !== null && "handoverRequired" in result && result.handoverRequired === true)
192
- record("blocked");
193
- else if (kind === "migrate-state" && typeof result === "object" && result !== null && "status" in result && result.status === "cancelled")
194
- record("cancelled");
195
- else record("completed");
196
- },
197
- rejected(error, cancelled) {
198
- if (cancelled || error instanceof Error && error.name === "AbortError") record("cancelled");
199
- else if (error instanceof Error && (error.name === "SyncDecisionRequiredError" || error.name === "RemoteSelectionMismatchError"))
200
- record("blocked");
201
- else record("failed");
202
- }
203
- };
204
- }
205
-
206
173
  // src/daemon/directional-recovery.ts
207
174
  function isForegroundDirection(operation) {
208
175
  return operation === "push.foreground" || operation === "pull.foreground";
@@ -686,6 +653,7 @@ var PiDaemonClient = class {
686
653
  initialized = false;
687
654
  startupDebug = false;
688
655
  debug = false;
656
+ diagnostics;
689
657
  participantIdentity = { id: randomUUID2(), generation: randomUUID2() };
690
658
  get id() {
691
659
  return this.participantIdentity.id;
@@ -715,14 +683,18 @@ var PiDaemonClient = class {
715
683
  if (!this.debug || !this.ownsContactUI() || this.pendingReload)
716
684
  throw new Error("Pi Sync debug is not available in this session.");
717
685
  }
718
- setDebugPreference(debug) {
686
+ async setDebugPreference(debug) {
719
687
  this.debug = debug && this.ctx.hasUI && (this.ctx.mode === "tui" || this.ctx.mode === "rpc");
688
+ if (!this.debug || this.diagnostics) return;
689
+ const diagnostics = await import("./client-debug-F4WFP2YJ.ts").catch(() => void 0);
690
+ this.validate();
691
+ if (this.debug) this.diagnostics = diagnostics;
720
692
  }
721
693
  recordDebug(event) {
722
- if (!this.debug || this.protectionOnly || this.pendingReload || !this.ownsContactUI()) return;
694
+ if (!this.debug || !this.diagnostics || this.protectionOnly || this.pendingReload || !this.ownsContactUI()) return;
723
695
  try {
724
696
  this.validate();
725
- appendDebugEvent(this.root, "pi-sync", event);
697
+ this.diagnostics.appendDebugEvent(this.root, "pi-sync", event);
726
698
  } catch {
727
699
  }
728
700
  }
@@ -1176,7 +1148,7 @@ var PiDaemonClient = class {
1176
1148
  this.cleanupRequired = true;
1177
1149
  }
1178
1150
  run(operation, payload, signal, ctx = this.ctx, onCommit, reload) {
1179
- const diagnostics = this.debug ? observeDebugJob(operation, (event) => this.recordDebug(event)) : void 0;
1151
+ const diagnostics = this.debug ? this.diagnostics?.observeDebugJob(operation, (event) => this.recordDebug(event)) : void 0;
1180
1152
  const result = this.work.then(() => this.runCurrent(operation, payload, signal, ctx, onCommit, reload, diagnostics)).catch((error) => {
1181
1153
  diagnostics?.rejected(error, Boolean(signal?.aborted || reload?.signal.aborted));
1182
1154
  this.recordOwnershipFailure(error);
@@ -1382,9 +1354,10 @@ var PiDaemonClient = class {
1382
1354
  });
1383
1355
  }
1384
1356
  async markReady(debug) {
1357
+ this.validate();
1358
+ await this.setDebugPreference(debug);
1385
1359
  this.validate();
1386
1360
  this.startupDebug = debug;
1387
- this.setDebugPreference(debug);
1388
1361
  this.initialized = true;
1389
1362
  await this.update();
1390
1363
  this.validate();
@@ -1548,4 +1521,4 @@ export {
1548
1521
  withPiDaemonClient,
1549
1522
  remoteOperation
1550
1523
  };
1551
- //# sourceMappingURL=chunk-SPXEDJ2G.ts.map
1524
+ //# sourceMappingURL=chunk-KN4NY2VV.ts.map