@narumitw/pi-sync 0.60.1 → 0.60.4

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 (216) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/README.md +9 -5
  3. package/dist/chunks/{chunk-7AC2RX4M.ts → chunk-277VHM2P.ts} +2 -2
  4. package/dist/chunks/chunk-277VHM2P.ts.map +7 -0
  5. package/dist/chunks/{chunk-UBE6XWOM.ts → chunk-6W2SNZ5P.ts} +2 -2
  6. package/dist/chunks/chunk-6W2SNZ5P.ts.map +7 -0
  7. package/dist/chunks/{chunk-JZKCOM62.ts → chunk-EMRFVLZM.ts} +2 -2
  8. package/dist/chunks/chunk-EMRFVLZM.ts.map +7 -0
  9. package/dist/chunks/{chunk-NPT2G4FU.ts → chunk-HEB6YT64.ts} +2 -2
  10. package/dist/chunks/chunk-HEB6YT64.ts.map +7 -0
  11. package/dist/chunks/{chunk-J5COV5TY.ts → chunk-HLCML3OW.ts} +2 -2
  12. package/dist/chunks/{chunk-J5COV5TY.ts.map → chunk-HLCML3OW.ts.map} +1 -1
  13. package/dist/chunks/{chunk-UZUUUY7C.ts → chunk-IGDI5CIH.ts} +4 -4
  14. package/dist/chunks/{chunk-ZMNVNECV.ts → chunk-KPWZNMKM.ts} +2 -2
  15. package/dist/chunks/chunk-KPWZNMKM.ts.map +7 -0
  16. package/dist/chunks/{chunk-YWEYRRQI.ts → chunk-LAXTCSX4.ts} +11 -11
  17. package/dist/chunks/chunk-LAXTCSX4.ts.map +7 -0
  18. package/dist/chunks/{chunk-BGGKHHO4.ts → chunk-MCUZFUHY.ts} +7 -7
  19. package/dist/chunks/{chunk-M7RHV3H6.ts → chunk-OA4NZLSL.ts} +2 -2
  20. package/dist/chunks/chunk-OA4NZLSL.ts.map +7 -0
  21. package/dist/chunks/{chunk-ENFHHB5O.ts → chunk-OVCP2SOB.ts} +42 -6
  22. package/dist/chunks/chunk-OVCP2SOB.ts.map +7 -0
  23. package/dist/chunks/{chunk-6LHIRS5R.ts → chunk-RJZIKZI3.ts} +6 -6
  24. package/dist/chunks/chunk-RJZIKZI3.ts.map +7 -0
  25. package/dist/chunks/{chunk-CEMFCWIU.ts → chunk-RNIEVDTR.ts} +2 -2
  26. package/dist/chunks/chunk-RNIEVDTR.ts.map +7 -0
  27. package/dist/chunks/{chunk-PDBTD2K6.ts → chunk-S3R3W3KF.ts} +2 -2
  28. package/dist/chunks/chunk-S3R3W3KF.ts.map +7 -0
  29. package/dist/chunks/{chunk-4RNCZZY7.ts → chunk-SE7HHBKH.ts} +15 -11
  30. package/dist/chunks/{chunk-4RNCZZY7.ts.map → chunk-SE7HHBKH.ts.map} +2 -2
  31. package/dist/chunks/{chunk-CZNBKIM5.ts → chunk-SMVKMYLK.ts} +2 -2
  32. package/dist/chunks/chunk-SMVKMYLK.ts.map +7 -0
  33. package/dist/chunks/{chunk-JKBUYCPC.ts → chunk-V4AMI3VL.ts} +2 -2
  34. package/dist/chunks/chunk-V4AMI3VL.ts.map +7 -0
  35. package/dist/chunks/{chunk-BWWTOQOW.ts → chunk-VQRDL3SY.ts} +310 -90
  36. package/dist/chunks/chunk-VQRDL3SY.ts.map +7 -0
  37. package/dist/chunks/{chunk-VZCWYXRS.ts → chunk-WP2M67XZ.ts} +2 -2
  38. package/dist/chunks/chunk-WP2M67XZ.ts.map +7 -0
  39. package/dist/chunks/{chunk-HNKLBM3U.ts → chunk-ZIL6PW5L.ts} +2 -2
  40. package/dist/chunks/chunk-ZIL6PW5L.ts.map +7 -0
  41. package/dist/chunks/{command-handler-FO4XBBHF.ts → command-handler-TMH4US44.ts} +23 -21
  42. package/dist/chunks/command-handler-TMH4US44.ts.map +7 -0
  43. package/dist/chunks/{conflict-review-XBSME2ER.ts → conflict-review-QGUCODDH.ts} +5 -5
  44. package/dist/chunks/{continuous-record-ZHUXVO4E.ts → continuous-record-3XDXDOMV.ts} +2 -2
  45. package/dist/chunks/continuous-record-3XDXDOMV.ts.map +7 -0
  46. package/dist/chunks/{continuous-storage-SQBAXACF.ts → continuous-storage-HLKCHF6Z.ts} +2 -2
  47. package/dist/chunks/continuous-storage-HLKCHF6Z.ts.map +7 -0
  48. package/dist/chunks/{file-selection-S6CNNNQI.ts → file-selection-DD6X4J2K.ts} +6 -6
  49. package/dist/chunks/manager-result-dispatcher-YVVD44QD.ts +18 -0
  50. package/dist/chunks/{manager-ui-AY5ZU6B4.ts → manager-ui-Q54OHOPR.ts} +26 -26
  51. package/dist/chunks/manager-ui-Q54OHOPR.ts.map +7 -0
  52. package/dist/chunks/remote-selection-ui-ODSUHX5N.ts +17 -0
  53. package/dist/chunks/{setup-switch-M3BAFGJM.ts → setup-switch-SPZE7HIQ.ts} +8 -8
  54. package/dist/chunks/{setup-wizard-NFAWP4KF.ts → setup-wizard-5JYKAEIT.ts} +11 -11
  55. package/dist/chunks/{snapshot-D4SFDP5J.ts → snapshot-5HY3M2NL.ts} +2 -2
  56. package/dist/chunks/snapshot-5HY3M2NL.ts.map +7 -0
  57. package/dist/chunks/{snapshot-transaction-directory-TNKBQ3UQ.ts → snapshot-transaction-directory-OU2D7R7A.ts} +2 -2
  58. package/dist/chunks/snapshot-transaction-directory-OU2D7R7A.ts.map +7 -0
  59. package/dist/chunks/{state-directory-JZSZVVPX.ts → state-directory-XXHU73Z3.ts} +2 -2
  60. package/dist/chunks/{sync-inspection-BJ4KPPNO.ts → sync-inspection-ECUTWISE.ts} +6 -6
  61. package/dist/chunks/sync-inspection-ECUTWISE.ts.map +7 -0
  62. package/dist/chunks/{sync-operations-TLWER2TT.ts → sync-operations-REXODWZB.ts} +6 -6
  63. package/dist/chunks/{sync-operations-TLWER2TT.ts.map → sync-operations-REXODWZB.ts.map} +2 -2
  64. package/dist/chunks/{sync-state-FVCJJ7MY.ts → sync-state-2LMIXJ2C.ts} +2 -2
  65. package/dist/chunks/sync-state-2LMIXJ2C.ts.map +7 -0
  66. package/dist/index.ts +74 -55
  67. package/dist/index.ts.map +3 -3
  68. package/docs/agent-mode-verification.md +1 -1
  69. package/docs/agent-quality-verification.md +1 -1
  70. package/docs/continuous-sync-verification.md +1 -1
  71. package/docs/daemon-migration.md +90 -10
  72. package/docs/tui-contract.md +7 -1
  73. package/package.json +3 -3
  74. package/skills/configure-pi-sync/references/configuration.md +9 -4
  75. package/src/backends/backend-factory.ts +2 -2
  76. package/src/backends/backend-identity.ts +2 -2
  77. package/src/backends/backend-types.ts +1 -1
  78. package/src/backends/git/git-backend.ts +2 -2
  79. package/src/backends/git/git-config.ts +2 -2
  80. package/src/backends/git/git-runner.ts +2 -2
  81. package/src/backends/git/git-storage.ts +2 -2
  82. package/src/backends/s3/s3-backend.ts +2 -2
  83. package/src/backends/s3/s3-client.ts +6 -2
  84. package/src/backends/s3/s3-conditions.ts +2 -2
  85. package/src/backends/snapshot-pointer.ts +2 -2
  86. package/src/backends/sync-backend.ts +2 -2
  87. package/src/backends/webdav/webdav-backend.ts +2 -2
  88. package/src/backends/webdav/webdav-client.ts +2 -2
  89. package/src/backends/webdav/webdav-config.ts +2 -2
  90. package/src/commands/command-execution.ts +2 -2
  91. package/src/commands/command-handler.ts +2 -0
  92. package/src/commands/command.ts +1 -1
  93. package/src/daemon/apply-gate.ts +1 -1
  94. package/src/daemon/pi-client.ts +335 -95
  95. package/src/daemon/recovery.ts +1 -1
  96. package/src/paths.ts +2 -2
  97. package/src/settings/config-errors.ts +2 -2
  98. package/src/settings/config-file.ts +2 -2
  99. package/src/settings/config.ts +2 -2
  100. package/src/settings/settings-management.ts +2 -2
  101. package/src/settings/settings-store.ts +2 -2
  102. package/src/settings/settings-types.ts +1 -1
  103. package/src/settings/settings-validation.ts +2 -2
  104. package/src/snapshot/session-paths.ts +2 -2
  105. package/src/snapshot/snapshot-apply.ts +2 -2
  106. package/src/snapshot/snapshot-case-replacement.ts +2 -2
  107. package/src/snapshot/snapshot-codec.ts +2 -2
  108. package/src/snapshot/snapshot-exclude-safety.ts +2 -2
  109. package/src/snapshot/snapshot-mutation-queues.ts +2 -2
  110. package/src/snapshot/snapshot-paths.ts +2 -2
  111. package/src/snapshot/snapshot-root-transition.ts +2 -2
  112. package/src/snapshot/snapshot-transaction-directory.ts +2 -2
  113. package/src/snapshot/snapshot-transaction-plan.ts +2 -2
  114. package/src/snapshot/snapshot-transaction.ts +2 -2
  115. package/src/snapshot/snapshot-types.ts +1 -1
  116. package/src/snapshot/snapshot.ts +2 -2
  117. package/src/state/json-file.ts +2 -2
  118. package/src/state/lock-policy.ts +2 -2
  119. package/src/state/lock.ts +2 -2
  120. package/src/state/lockfile-fs.ts +2 -2
  121. package/src/state/merge-baseline-store.ts +2 -2
  122. package/src/state/mutation-directory-sync.ts +2 -2
  123. package/src/state/operation-availability.ts +2 -2
  124. package/src/state/state-directory.ts +2 -2
  125. package/src/state/state-types.ts +1 -1
  126. package/src/state/sync-state-store.ts +2 -2
  127. package/src/sync/agent-candidate.ts +2 -2
  128. package/src/sync/agent-plan.ts +2 -2
  129. package/src/sync/agent-policy.ts +2 -2
  130. package/src/sync/agent-refusal-retry.ts +2 -2
  131. package/src/sync/agent-request.ts +2 -2
  132. package/src/sync/agent-runner.ts +2 -2
  133. package/src/sync/agent-store.ts +2 -2
  134. package/src/sync/agent-sync.ts +2 -2
  135. package/src/sync/apply-review.ts +2 -2
  136. package/src/sync/conflict-artifact-ownership.ts +2 -2
  137. package/src/sync/conflict-artifacts.ts +2 -2
  138. package/src/sync/conflict-groups.ts +2 -2
  139. package/src/sync/conflict-preview.ts +2 -2
  140. package/src/sync/conflict-resolution.ts +2 -2
  141. package/src/sync/conflict-retention.ts +2 -2
  142. package/src/sync/content-conflicts.ts +2 -2
  143. package/src/sync/continuous-errors.ts +2 -2
  144. package/src/sync/continuous-lease.ts +2 -2
  145. package/src/sync/continuous-record.ts +2 -2
  146. package/src/sync/continuous-storage.ts +2 -2
  147. package/src/sync/continuous-sync.ts +2 -2
  148. package/src/sync/continuous-watch.ts +2 -2
  149. package/src/sync/exclude-policy.ts +2 -2
  150. package/src/sync/field-migration.ts +2 -2
  151. package/src/sync/file-merge-planner.ts +6 -2
  152. package/src/sync/json-document.ts +2 -2
  153. package/src/sync/local-field-policy.ts +2 -2
  154. package/src/sync/local-fields.ts +2 -2
  155. package/src/sync/merge-apply.ts +2 -2
  156. package/src/sync/merge-journal.ts +2 -2
  157. package/src/sync/merge-transfer-error.ts +2 -2
  158. package/src/sync/merged-sync.ts +2 -2
  159. package/src/sync/mutation-owner.ts +2 -2
  160. package/src/sync/package-merge.ts +2 -2
  161. package/src/sync/partial-progress.ts +2 -2
  162. package/src/sync/remote-snapshot.ts +2 -2
  163. package/src/sync/session-merge.ts +2 -2
  164. package/src/sync/settings-conflicts.ts +2 -2
  165. package/src/sync/settings-merge.ts +2 -2
  166. package/src/sync/signals.ts +2 -2
  167. package/src/sync/startup-timings.ts +2 -2
  168. package/src/sync/sync-decision.ts +2 -2
  169. package/src/sync/sync-error-guidance.ts +2 -2
  170. package/src/sync/sync-errors.ts +2 -2
  171. package/src/sync/sync-inspection.ts +2 -2
  172. package/src/sync/sync-local.ts +6 -2
  173. package/src/sync/sync-mutations.ts +2 -2
  174. package/src/sync/sync-operations.ts +1 -1
  175. package/src/sync/sync-policy.ts +2 -2
  176. package/src/sync/sync-queries.ts +2 -2
  177. package/src/sync/sync-state.ts +2 -2
  178. package/src/sync/text-merge.ts +2 -2
  179. package/src/sync-extension.ts +62 -41
  180. package/src/ui/sync-status.ts +47 -4
  181. package/dist/chunks/chunk-6LHIRS5R.ts.map +0 -7
  182. package/dist/chunks/chunk-7AC2RX4M.ts.map +0 -7
  183. package/dist/chunks/chunk-BWWTOQOW.ts.map +0 -7
  184. package/dist/chunks/chunk-CEMFCWIU.ts.map +0 -7
  185. package/dist/chunks/chunk-CZNBKIM5.ts.map +0 -7
  186. package/dist/chunks/chunk-ENFHHB5O.ts.map +0 -7
  187. package/dist/chunks/chunk-HNKLBM3U.ts.map +0 -7
  188. package/dist/chunks/chunk-JKBUYCPC.ts.map +0 -7
  189. package/dist/chunks/chunk-JZKCOM62.ts.map +0 -7
  190. package/dist/chunks/chunk-M7RHV3H6.ts.map +0 -7
  191. package/dist/chunks/chunk-NPT2G4FU.ts.map +0 -7
  192. package/dist/chunks/chunk-PDBTD2K6.ts.map +0 -7
  193. package/dist/chunks/chunk-UBE6XWOM.ts.map +0 -7
  194. package/dist/chunks/chunk-VZCWYXRS.ts.map +0 -7
  195. package/dist/chunks/chunk-YWEYRRQI.ts.map +0 -7
  196. package/dist/chunks/chunk-ZMNVNECV.ts.map +0 -7
  197. package/dist/chunks/command-handler-FO4XBBHF.ts.map +0 -7
  198. package/dist/chunks/continuous-record-ZHUXVO4E.ts.map +0 -7
  199. package/dist/chunks/continuous-storage-SQBAXACF.ts.map +0 -7
  200. package/dist/chunks/manager-result-dispatcher-I2AMCCE7.ts +0 -18
  201. package/dist/chunks/manager-ui-AY5ZU6B4.ts.map +0 -7
  202. package/dist/chunks/remote-selection-ui-GZHPDQ4L.ts +0 -17
  203. package/dist/chunks/snapshot-D4SFDP5J.ts.map +0 -7
  204. package/dist/chunks/snapshot-transaction-directory-TNKBQ3UQ.ts.map +0 -7
  205. package/dist/chunks/sync-inspection-BJ4KPPNO.ts.map +0 -7
  206. package/dist/chunks/sync-state-FVCJJ7MY.ts.map +0 -7
  207. package/docs/settings.md +0 -90
  208. /package/dist/chunks/{chunk-UZUUUY7C.ts.map → chunk-IGDI5CIH.ts.map} +0 -0
  209. /package/dist/chunks/{chunk-BGGKHHO4.ts.map → chunk-MCUZFUHY.ts.map} +0 -0
  210. /package/dist/chunks/{conflict-review-XBSME2ER.ts.map → conflict-review-QGUCODDH.ts.map} +0 -0
  211. /package/dist/chunks/{file-selection-S6CNNNQI.ts.map → file-selection-DD6X4J2K.ts.map} +0 -0
  212. /package/dist/chunks/{manager-result-dispatcher-I2AMCCE7.ts.map → manager-result-dispatcher-YVVD44QD.ts.map} +0 -0
  213. /package/dist/chunks/{remote-selection-ui-GZHPDQ4L.ts.map → remote-selection-ui-ODSUHX5N.ts.map} +0 -0
  214. /package/dist/chunks/{setup-switch-M3BAFGJM.ts.map → setup-switch-SPZE7HIQ.ts.map} +0 -0
  215. /package/dist/chunks/{setup-wizard-NFAWP4KF.ts.map → setup-wizard-5JYKAEIT.ts.map} +0 -0
  216. /package/dist/chunks/{state-directory-JZSZVVPX.ts.map → state-directory-XXHU73Z3.ts.map} +0 -0
@@ -8,6 +8,7 @@ import {
8
8
  type Callback,
9
9
  type ClientFacts,
10
10
  type ClientHandoff,
11
+ type ContactState,
11
12
  DaemonConnection,
12
13
  DaemonError,
13
14
  type DocumentView,
@@ -16,33 +17,39 @@ import {
16
17
  findDaemon,
17
18
  MAX_SETTINGS_BYTES,
18
19
  modelSignature,
19
- } from "@narumitw/sync-daemon";
20
- import { type ConfigAuthority, configureEngineHost } from "@narumitw/sync-daemon/engine/host";
21
- import { type LocalConfigDocument, peekLocalConfigDocument } from "@narumitw/sync-daemon/engine/settings/config-file";
22
- import { validateSettingsDocument } from "@narumitw/sync-daemon/engine/settings/settings-validation";
23
- import { sessionDirFromContext } from "@narumitw/sync-daemon/engine/snapshot/session-paths";
20
+ waitForDaemonExit,
21
+ } from "@narumitw/pi-sync-daemon";
22
+ import { type ConfigAuthority, configureEngineHost } from "@narumitw/pi-sync-daemon/engine/host";
23
+ import {
24
+ type LocalConfigDocument,
25
+ peekLocalConfigDocument,
26
+ } from "@narumitw/pi-sync-daemon/engine/settings/config-file";
27
+ import { validateSettingsDocument } from "@narumitw/pi-sync-daemon/engine/settings/settings-validation";
28
+ import { sessionDirFromContext } from "@narumitw/pi-sync-daemon/engine/snapshot/session-paths";
24
29
  import type { CommandOptions } from "../commands/command-types.js";
25
30
  import type { StartupTimingPublisher } from "../sync/startup-timings.js";
26
- import { SyncDecisionRequiredError } from "../sync/sync-errors.js";
31
+ import { errorMessage, SyncDecisionRequiredError } from "../sync/sync-errors.js";
27
32
  import { RemoteSelectionMismatchError } from "../sync/sync-policy.js";
28
- import { type SyncStatusPresentation, setSyncStatus } from "../ui/sync-status.js";
33
+ import { type SyncStatusPresentation, setSyncStatus, showSyncConnectionStatus } from "../ui/sync-status.js";
29
34
  import { safeTerminalText } from "../ui/terminal-text.js";
30
35
  import { PiApplyGate } from "./apply-gate.js";
31
36
  import { quarantineClient, recoverDetachedClients } from "./recovery.js";
32
37
 
33
- const scope = new AsyncLocalStorage<PiDaemonClient>();
38
+ const scope = new AsyncLocalStorage<{ client: PiDaemonClient; reload?: AbortController }>();
34
39
  const clients = new WeakMap<ExtensionContext["sessionManager"], PiDaemonClient>();
35
40
  export function currentPiDaemonClient() {
36
41
  return current();
37
42
  }
38
43
  function current() {
39
- const client = scope.getStore();
44
+ const client = scope.getStore()?.client;
40
45
  if (!client) throw new Error("Pi synchronization requires a current session-bound daemon client.");
41
46
  client.validate();
42
47
  return client;
43
48
  }
44
49
  function canonicalPath(value: string | undefined): string | undefined {
45
- if (value === undefined) return undefined;
50
+ // An in-memory session (`pi --no-session`) reports an empty session dir instead of
51
+ // omitting it, so an empty path means "no path to publish", not a broken caller.
52
+ if (value === undefined || value === "") return undefined;
46
53
  if (!path.isAbsolute(value)) throw new Error("Pi session paths must be absolute.");
47
54
  const parts: string[] = [];
48
55
  let cursor = path.resolve(value);
@@ -119,10 +126,10 @@ const authority: ConfigAuthority = {
119
126
  /** Factory registration installs only adapters; it starts no process and performs no I/O. */
120
127
  export function installPiDaemonHost() {
121
128
  configureEngineHost({
122
- root: () => scope.getStore()?.root ?? path.resolve(getAgentDir()),
129
+ root: () => scope.getStore()?.client.root ?? path.resolve(getAgentDir()),
123
130
  config: authority,
124
131
  mutate: async () => {
125
- throw new Error("File mutation belongs to sync-daemon; no in-process fallback is permitted.");
132
+ throw new Error("File mutation belongs to pi-sync-daemon; no in-process fallback is permitted.");
126
133
  },
127
134
  review: async () => {
128
135
  throw new Error("Engine reviews must arrive through the daemon API.");
@@ -143,8 +150,9 @@ export function piDaemonClient(ctx: ExtensionContext) {
143
150
  export function withPiDaemonClient<Context extends ExtensionContext, T>(
144
151
  ctx: Context,
145
152
  action: (owned: Context) => Promise<T>,
153
+ reload?: AbortController,
146
154
  ) {
147
- const client = piDaemonClient(ctx);
155
+ const owner = { client: piDaemonClient(ctx), reload };
148
156
  // TUI input arrives from Pi's event loop, outside the command's async call tree.
149
157
  // Bind public component methods so later menu actions retain this exact owner,
150
158
  // never a replacement session selected through a global fallback.
@@ -161,14 +169,14 @@ export function withPiDaemonClient<Context extends ExtensionContext, T>(
161
169
  if (typeof value !== "function") return value;
162
170
  const saved = methods.get(key);
163
171
  if (saved?.source === value) return saved.bound;
164
- const bound = (...values: unknown[]) => scope.run(client, () => Reflect.apply(value, original, values));
172
+ const bound = (...values: unknown[]) => scope.run(owner, () => Reflect.apply(value, original, values));
165
173
  methods.set(key, { source: value, bound });
166
174
  return bound;
167
175
  },
168
176
  });
169
177
  };
170
178
  const invoke = (...provided: Parameters<typeof factory>) => {
171
- const component = scope.run(client, () => factory(...provided));
179
+ const component = scope.run(owner, () => factory(...provided));
172
180
  return component instanceof Promise ? component.then(wrap) : wrap(component);
173
181
  };
174
182
  // Do not turn synchronous editors/reviews into asynchronous factories.
@@ -184,11 +192,14 @@ export function withPiDaemonClient<Context extends ExtensionContext, T>(
184
192
  return key === "ui" ? ui : Reflect.get(target, key, target);
185
193
  },
186
194
  });
187
- return scope.run(client, () => action(owned));
195
+ return scope.run(owner, () => action(owned));
188
196
  }
189
197
  export async function remoteOperation(ctx: ExtensionContext, operation: string, options: CommandOptions) {
190
198
  const client = piDaemonClient(ctx);
191
199
  const { signal, onCommit, args, setup } = options;
200
+ const owner = scope.getStore();
201
+ const reload = options.reload && owner?.client === client ? owner.reload : undefined;
202
+ reload?.signal.throwIfAborted();
192
203
  const payload = {
193
204
  args,
194
205
  ...(setup === undefined ? {} : { setup }),
@@ -196,28 +207,43 @@ export async function remoteOperation(ctx: ExtensionContext, operation: string,
196
207
  force: options.force,
197
208
  stale: options.stale,
198
209
  silent: options.silent,
199
- reload: options.reload,
210
+ reload: reload !== undefined,
200
211
  ...(options.agentRetryRefusal ? { agentRetryRefusal: true } : {}),
201
212
  };
202
- return client.run(operation, payload, signal, ctx, onCommit);
213
+ return client.run(operation, payload, signal, ctx, onCommit, reload);
214
+ }
215
+ function remoteErrorNamed(error: unknown, name: string) {
216
+ return error instanceof DaemonError && error.remote.name === name;
203
217
  }
218
+
204
219
  export class PiDaemonClient {
205
220
  private connection?: DaemonConnection;
221
+ private protectionOnly = false;
206
222
  private partialConnection?: DaemonConnection;
207
223
  private work = Promise.resolve();
208
224
  private closing = false;
209
225
  private paused = false;
210
226
  private pausing?: Promise<void>;
211
227
  private connecting?: Promise<DaemonConnection>;
228
+ private contactRepair?: { controller: AbortController; done: Promise<void> };
229
+ private contactAttempt?: { error?: unknown };
230
+ private contactFactsUnpublished = false;
231
+ private clearContactStatus?: (redraw?: boolean) => void;
212
232
  private disposed = false;
213
233
  private disposing?: Promise<void>;
214
234
  private uiContext: ExtensionContext;
215
- private reloadRequested = false;
235
+ private reloadRequest?: { received: boolean };
236
+ private pendingReload?: AbortController;
216
237
  private readonly busy = new Set<string>();
217
238
  private initialized = false;
218
239
  private startupDebug = false;
219
- readonly id = randomUUID();
220
- readonly generation = randomUUID();
240
+ private participantIdentity = { id: randomUUID(), generation: randomUUID() };
241
+ get id() {
242
+ return this.participantIdentity.id;
243
+ }
244
+ get generation() {
245
+ return this.participantIdentity.generation;
246
+ }
221
247
  readonly root: string;
222
248
  private readonly rawRoot: string;
223
249
  private readonly gate: PiApplyGate;
@@ -259,7 +285,7 @@ export class PiDaemonClient {
259
285
  return undefined;
260
286
  return { provider: model.provider, id: model.id, signature: modelSignature(model), authSource: source };
261
287
  }
262
- private facts(): ClientFacts {
288
+ private facts(protectionOnly = this.protectionOnly): ClientFacts {
263
289
  const manager = this.ctx.sessionManager;
264
290
  return {
265
291
  id: this.id,
@@ -267,14 +293,14 @@ export class PiDaemonClient {
267
293
  pid: process.pid,
268
294
  cwd: this.ctx.cwd,
269
295
  mode: this.ctx.mode,
270
- hasUI: this.ctx.hasUI,
271
- idle: !this.paused && !this.busy.size && this.ctx.isIdle(),
272
- ready: this.initialized,
296
+ hasUI: !protectionOnly && this.ctx.hasUI,
297
+ idle: !protectionOnly && !this.paused && !this.busy.size && this.ctx.isIdle(),
298
+ ready: !protectionOnly && this.initialized,
273
299
  startupDebug: this.startupDebug,
274
300
  sessionFile: canonicalPath(manager.getSessionFile?.()),
275
301
  sessionId: manager.getSessionId?.(),
276
302
  sessionDir: canonicalPath(sessionDirFromContext(this.ctx)),
277
- model: this.modelBinding(),
303
+ model: protectionOnly ? undefined : this.modelBinding(),
278
304
  };
279
305
  }
280
306
  async configured() {
@@ -288,6 +314,7 @@ export class PiDaemonClient {
288
314
  async pauseForSessionChange() {
289
315
  this.validate();
290
316
  this.paused = true;
317
+ this.stopContactRepair(true);
291
318
  this.gate.cancelPending();
292
319
  this.pausing ??= (async () => {
293
320
  const connection = this.connection ?? this.partialConnection ?? (await this.connecting?.catch(() => undefined));
@@ -298,76 +325,264 @@ export class PiDaemonClient {
298
325
  })();
299
326
  return this.pausing;
300
327
  }
301
- async attachExisting() {
328
+ async attachExisting({ allowUpgrade = false } = {}) {
302
329
  this.validate();
303
330
  const address = await findDaemon(this.root);
304
331
  this.validate();
305
- if (address) await this.connect(address);
332
+ if (!address) return false;
333
+ const upgrade = allowUpgrade && address.needsUpgrade && this.ctx.hasUI && ["tui", "rpc"].includes(this.ctx.mode);
334
+ let upgradeFailure: string | undefined;
335
+ if (upgrade) {
336
+ try {
337
+ await this.connect();
338
+ this.validate();
339
+ return true;
340
+ } catch (error) {
341
+ this.validate();
342
+ if (this.paused) throw error;
343
+ upgradeFailure = safeTerminalText(errorMessage(error));
344
+ }
345
+ }
346
+ try {
347
+ // If upgrade failed, try only the original owner, with its protection-only facts.
348
+ await this.connect(address);
349
+ } catch (error) {
350
+ this.validate();
351
+ if (remoteErrorNamed(error, "DaemonStoppingError")) return false;
352
+ throw error;
353
+ } finally {
354
+ if (upgradeFailure !== undefined) {
355
+ this.validate();
356
+ this.ctx.ui.notify(`pi-sync daemon upgrade failed: ${upgradeFailure}`, "error");
357
+ }
358
+ }
306
359
  this.validate();
307
- return Boolean(address);
360
+ // Headless, shutdown, and failed-upgrade paths must not schedule transfers on an older build.
361
+ return !this.protectionOnly;
308
362
  }
309
363
  async finishReattachment() {
310
364
  this.validate();
311
365
  if (this.connection) {
312
366
  await recoverDetachedClients({ paths: this.connection.paths, identity: this.connection.identity });
313
367
  this.validate();
314
- await this.connection.attach();
368
+ await this.connection.attach(this.signal);
315
369
  this.validate();
316
370
  }
317
371
  }
318
- async connect(existing?: Awaited<ReturnType<typeof ensureDaemon>>) {
319
- this.validate();
320
- if (this.connection) return this.connection;
372
+ async connect(existing?: Awaited<ReturnType<typeof ensureDaemon>>, requestSignal?: AbortSignal) {
373
+ const startupSignal = requestSignal ? AbortSignal.any([this.signal, requestSignal]) : this.signal;
374
+ const validateStartup = () => {
375
+ this.validate();
376
+ startupSignal.throwIfAborted();
377
+ };
378
+ validateStartup();
379
+ if (this.connection) {
380
+ if (!existing && this.protectionOnly)
381
+ throw new Error(
382
+ "This session is only protecting its files on an older Pi Sync daemon. Use /reload to upgrade.",
383
+ );
384
+ return this.connection;
385
+ }
321
386
  this.connecting ??= (async () => {
387
+ if (this.partialConnection) {
388
+ // A failed unpublished attempt may already be retired or own queue grants.
389
+ // Confirm drain before replacing its identity; failed cleanup must block retry.
390
+ await this.partialConnection.dispose();
391
+ // Finish acknowledged cleanup even if this new startup was cancelled meanwhile.
392
+ await this.gate.releaseAfterDrain();
393
+ validateStartup();
394
+ this.partialConnection = undefined;
395
+ this.participantIdentity = { id: randomUUID(), generation: randomUUID() };
396
+ }
322
397
  // Only explicit setup/command paths or a configured interactive session call connect.
323
398
  if (!existing) await fs.mkdir(this.root, { recursive: true, mode: 0o700 });
324
- this.validate();
325
- const daemon = existing ?? (await ensureDaemon(this.root, this.signal));
326
- this.validate();
327
- if (daemon.paths.root !== this.root) throw new Error("Daemon root changed before attach.");
328
- const connection = new DaemonConnection(daemon.paths, daemon.identity, this.facts(), {
329
- callback: (callback, signal) => this.callback(callback, signal),
330
- event: (event) => {
331
- if (event.kind === "commit") return;
332
- if (this.signal.aborted || this.disposed || this.closing || clients.get(this.manager) !== this) return;
333
- const payload = event.payload as {
334
- message?: string;
335
- level?: "info" | "warning" | "error";
336
- value?: string;
337
- presentation?: SyncStatusPresentation;
338
- };
339
- if (event.kind === "notify" && typeof payload?.message === "string")
340
- this.uiContext.ui.notify(safeTerminalText(payload.message), payload.level ?? "info");
341
- if (event.kind === "timings" && typeof (event.payload as { report?: unknown })?.report === "string") {
342
- this.publish?.(this.ctx, safeTerminalText((event.payload as { report: string }).report));
343
- }
344
- if (event.kind === "status")
345
- setSyncStatus(
346
- this.uiContext,
347
- typeof payload?.value === "string" ? safeTerminalText(payload.value) : undefined,
348
- payload.presentation,
349
- );
350
- },
351
- error: () => {
352
- if (!this.signal.aborted && !this.disposed && !this.closing && clients.get(this.manager) === this)
353
- setSyncStatus(this.ctx, "sync service unavailable", { activity: "blocked", reason: "repair" });
354
- },
355
- });
356
- this.partialConnection = connection;
357
- await connection.attach();
358
- this.validate();
359
- await recoverDetachedClients(daemon);
360
- if (this.signal.aborted || this.disposed || this.closing) {
361
- await connection.dispose();
399
+ validateStartup();
400
+ let retried = false;
401
+ for (;;) {
402
+ validateStartup();
403
+ const daemon = existing ?? (await ensureDaemon(this.root, startupSignal));
404
+ validateStartup();
405
+ if (daemon.paths.root !== this.root) throw new Error("Daemon root changed before attach.");
406
+ const protectionOnly = daemon.needsUpgrade === true;
407
+ const connection = new DaemonConnection(daemon.paths, daemon.identity, this.facts(protectionOnly), {
408
+ callback: (callback, signal) => this.callback(callback, signal, protectionOnly),
409
+ event: (event) => {
410
+ if (event.kind === "commit") return;
411
+ if (this.signal.aborted || this.disposed || this.closing || clients.get(this.manager) !== this) return;
412
+ const payload = event.payload as {
413
+ message?: string;
414
+ level?: "info" | "warning" | "error";
415
+ report?: string;
416
+ value?: string;
417
+ presentation?: SyncStatusPresentation;
418
+ };
419
+ if (event.kind === "notify" && typeof payload?.message === "string")
420
+ this.uiContext.ui.notify(safeTerminalText(payload.message), payload.level ?? "info");
421
+ if (event.kind === "timings" && typeof payload?.report === "string") {
422
+ this.publish?.(this.ctx, payload.report.split("\n").map(safeTerminalText).join("\n"));
423
+ }
424
+ if (event.kind === "status")
425
+ setSyncStatus(
426
+ this.uiContext,
427
+ typeof payload?.value === "string" ? safeTerminalText(payload.value) : undefined,
428
+ payload.presentation,
429
+ );
430
+ },
431
+ contact: (state) => this.observeContact(connection, state),
432
+ error: () => {
433
+ if (this.ownsContactUI()) this.showContactStatus("sync service unavailable", "blocked");
434
+ },
435
+ });
436
+ this.partialConnection = connection;
437
+ try {
438
+ await connection.attach(startupSignal);
439
+ } catch (error) {
440
+ if (!(error instanceof DaemonError) || error.remote.name !== "DaemonStoppingError") throw error;
441
+ // The final idle fence rejected publication, so this connection owns no queue grants.
442
+ await connection.dispose().catch(() => {});
443
+ this.partialConnection = undefined;
444
+ validateStartup();
445
+ if (existing || retried) throw error;
446
+ retried = true;
447
+ await waitForDaemonExit(daemon.identity, startupSignal);
448
+ validateStartup();
449
+ continue;
450
+ }
451
+ this.validate();
452
+ await recoverDetachedClients(daemon);
453
+ if (this.signal.aborted || this.disposed || this.closing) {
454
+ await connection.dispose();
455
+ this.validate();
456
+ }
362
457
  this.validate();
458
+ this.connection = connection;
459
+ this.protectionOnly = protectionOnly;
460
+ this.partialConnection = undefined;
461
+ return connection;
363
462
  }
364
- this.connection = connection;
365
- return connection;
366
463
  })().catch((error) => {
367
464
  this.connecting = undefined;
368
465
  throw error;
369
466
  });
370
- return this.connecting;
467
+ const connection = await this.connecting;
468
+ validateStartup();
469
+ if (!existing && this.protectionOnly)
470
+ throw new Error("This session is only protecting its files on an older Pi Sync daemon. Use /reload to upgrade.");
471
+ return connection;
472
+ }
473
+ private ownsContactUI() {
474
+ return (
475
+ !this.signal.aborted && !this.disposed && !this.closing && !this.paused && clients.get(this.manager) === this
476
+ );
477
+ }
478
+ private showContactStatus(text: string, activity: "retry" | "blocked") {
479
+ const previous = this.clearContactStatus;
480
+ this.clearContactStatus = showSyncConnectionStatus(this.ctx, text, {
481
+ activity,
482
+ reason: activity === "retry" ? "temp" : "repair",
483
+ });
484
+ previous?.();
485
+ }
486
+ private stopContactRepair(redraw: boolean) {
487
+ this.contactRepair?.controller.abort(new DOMException("Pi session is changing", "AbortError"));
488
+ this.clearContactStatus?.(redraw);
489
+ this.clearContactStatus = undefined;
490
+ }
491
+ private observeContact(connection: DaemonConnection, state: ContactState) {
492
+ if (connection !== this.connection || !this.ownsContactUI()) return;
493
+ if (state === "active") {
494
+ if (this.contactRepair || this.contactFactsUnpublished || connection.contactResumeState === "uncertain") return;
495
+ this.clearRestoredContact();
496
+ } else if (state === "expired" && connection.facts.hasUI && !this.contactAttempt && !this.contactRepair) {
497
+ if (this.gate.size || connection.hasPendingWork) return;
498
+ void this.resumeContact(connection).catch(() => {
499
+ // The owning repair updates the status; a later command reports the error.
500
+ });
501
+ }
502
+ }
503
+ private clearRestoredContact() {
504
+ this.contactAttempt = undefined;
505
+ this.contactFactsUnpublished = false;
506
+ this.clearContactStatus?.();
507
+ this.clearContactStatus = undefined;
508
+ }
509
+ private async resumeContact(connection: DaemonConnection) {
510
+ this.validate();
511
+ if (this.paused || this.connection !== connection) throw new Error("Pi Sync is paused for a session change.");
512
+ if (this.contactRepair) return this.contactRepair.done;
513
+ if (connection.contactState === "active" && connection.contactResumeState !== "uncertain") return;
514
+ if (this.gate.size || connection.hasPendingWork || connection.contactResumeState === "uncertain") {
515
+ throw new Error(
516
+ "Pi Sync cannot reconnect while previous work is still running or uncertain. Check sync recovery before retrying.",
517
+ );
518
+ }
519
+ const earlier = this.contactAttempt;
520
+ if (connection.contactState !== "expired" || earlier) {
521
+ throw new Error("Pi Sync could not restore contact. Review pending work before using /reload.", {
522
+ cause: earlier?.error,
523
+ });
524
+ }
525
+ const controller = new AbortController();
526
+ const signal = AbortSignal.any([this.signal, controller.signal]);
527
+ const attempt: { error?: unknown } = {};
528
+ this.contactAttempt = attempt;
529
+ const done = Promise.resolve().then(async () => {
530
+ try {
531
+ this.validate();
532
+ signal.throwIfAborted();
533
+ this.showContactStatus("sync reconnecting", "retry");
534
+ // Admission can wait behind an apply. Do not advertise readiness using
535
+ // facts sampled before that wait; publish current facts after the ack.
536
+ await connection.resumeContact({ ...this.facts(), idle: false, ready: false }, signal);
537
+ this.validate();
538
+ signal.throwIfAborted();
539
+ this.contactFactsUnpublished = true;
540
+ this.contactAttempt = undefined;
541
+ await connection.update(this.facts());
542
+ this.validate();
543
+ signal.throwIfAborted();
544
+ this.confirmContact(connection);
545
+ } catch (error) {
546
+ attempt.error = error;
547
+ if (this.ownsContactUI() && !signal.aborted)
548
+ this.showContactStatus("sync reconnect blocked; check /sync daemon status", "blocked");
549
+ throw error;
550
+ } finally {
551
+ if (this.contactRepair?.controller === controller) this.contactRepair = undefined;
552
+ }
553
+ });
554
+ this.contactRepair = { controller, done };
555
+ return done;
556
+ }
557
+ private async publishFacts(connection: DaemonConnection) {
558
+ if (this.contactRepair) await this.contactRepair.done;
559
+ this.validate();
560
+ if (this.paused) throw new Error("Pi Sync is paused for a session change.");
561
+ if (connection.contactResumeState === "uncertain")
562
+ throw new Error("Pi Sync cannot verify the previous reconnect. Review pending work before using /reload.");
563
+ try {
564
+ await connection.update(this.facts());
565
+ } catch (error) {
566
+ if (!connection.facts.hasUI || !remoteErrorNamed(error, "ClientContactExpiredError")) throw error;
567
+ await this.resumeContact(connection);
568
+ this.validate();
569
+ // A shared repair might have started before these facts changed.
570
+ await connection.update(this.facts());
571
+ }
572
+ this.validate();
573
+ this.confirmContact(connection);
574
+ }
575
+ private confirmContact(connection: DaemonConnection) {
576
+ if (connection.contactState === "expired" || connection.contactState === "inactive")
577
+ throw new Error("Pi Sync did not confirm active participation in the daemon.");
578
+ this.clearRestoredContact();
579
+ }
580
+ async verifyConnection(signal?: AbortSignal) {
581
+ const connection = await this.connect(undefined, signal);
582
+ signal?.throwIfAborted();
583
+ await this.publishFacts(connection);
584
+ signal?.throwIfAborted();
585
+ return connection;
371
586
  }
372
587
  async readSettings(repair = false) {
373
588
  this.validate();
@@ -381,8 +596,15 @@ export class PiDaemonClient {
381
596
  }
382
597
  return decode(await this.run(repair ? "settings.repair-read" : "settings.read", {}));
383
598
  }
384
- run(operation: string, payload: unknown, signal?: AbortSignal, ctx = this.ctx, onCommit?: () => void) {
385
- const result = this.work.then(() => this.runCurrent(operation, payload, signal, ctx, onCommit));
599
+ run(
600
+ operation: string,
601
+ payload: unknown,
602
+ signal?: AbortSignal,
603
+ ctx = this.ctx,
604
+ onCommit?: () => void,
605
+ reload?: AbortController,
606
+ ) {
607
+ const result = this.work.then(() => this.runCurrent(operation, payload, signal, ctx, onCommit, reload));
386
608
  this.work = result.then(
387
609
  () => {},
388
610
  () => {},
@@ -395,30 +617,45 @@ export class PiDaemonClient {
395
617
  signal?: AbortSignal,
396
618
  ctx = this.ctx,
397
619
  onCommit?: () => void,
620
+ reload?: AbortController,
398
621
  ) {
399
622
  this.validate();
400
623
  signal?.throwIfAborted();
624
+ reload?.signal.throwIfAborted();
625
+ if (this.pendingReload) throw new Error("Pi resources are about to reload.");
401
626
  if (this.paused && operation !== "shutdown")
402
627
  throw new Error("Synchronization is paused for a session change; if it was cancelled, use /reload to reattach.");
403
- const connection = await this.connect();
628
+ const connection = await this.connect(undefined, signal);
404
629
  if (this.paused && operation === "shutdown") {
405
630
  Object.assign(connection.facts, { ...this.facts(), idle: false, ready: false });
406
- await connection.attach();
631
+ await connection.attach(signal ? AbortSignal.any([signal, this.signal]) : this.signal);
407
632
  this.validate();
408
633
  }
409
634
  this.validate();
410
635
  signal?.throwIfAborted();
411
- await connection.update(this.facts());
636
+ if (this.paused)
637
+ await connection.update(this.facts()); // Existing, explicitly attached shutdown path.
638
+ else await this.publishFacts(connection);
412
639
  this.validate();
413
640
  signal?.throwIfAborted();
414
641
  this.uiContext = ctx;
642
+ // The daemon directs reload only to the submitting client, and run() serializes its jobs.
643
+ const request = reload ? { received: false } : undefined;
644
+ this.reloadRequest = request;
415
645
  try {
416
- return await connection.run(
646
+ const result = await connection.run(
417
647
  operation,
418
648
  payload,
419
649
  signal ? AbortSignal.any([signal, this.signal]) : this.signal,
420
650
  onCommit,
421
651
  );
652
+ if (request?.received && reload && !this.paused && !reload.signal.aborted && !signal?.aborted) {
653
+ this.validate();
654
+ this.pendingReload = reload;
655
+ // Close the command's UI, not the session. Pi reload must run after this job and its UI drain.
656
+ reload.abort(new DOMException("Pi resource reload requested", "AbortError"));
657
+ }
658
+ return result;
422
659
  } catch (error) {
423
660
  if (error instanceof DaemonError) {
424
661
  const prototype =
@@ -437,18 +674,17 @@ export class PiDaemonClient {
437
674
  throw error;
438
675
  } finally {
439
676
  this.uiContext = this.ctx;
440
- if (
441
- this.reloadRequested &&
442
- !this.signal.aborted &&
443
- !this.disposed &&
444
- !this.closing &&
445
- clients.get(this.manager) === this
446
- ) {
447
- this.reloadRequested = false;
448
- if ("reload" in ctx && typeof ctx.reload === "function") await ctx.reload();
449
- }
677
+ this.reloadRequest = undefined;
450
678
  }
451
679
  }
680
+ canReload(owner: AbortController) {
681
+ if (this.pendingReload !== owner || this.paused) return false;
682
+ this.validate();
683
+ return true;
684
+ }
685
+ releaseReload(owner: AbortController) {
686
+ if (this.pendingReload === owner) this.pendingReload = undefined;
687
+ }
452
688
  async markReady(debug: boolean) {
453
689
  this.validate();
454
690
  this.startupDebug = debug;
@@ -456,18 +692,18 @@ export class PiDaemonClient {
456
692
  await this.update();
457
693
  this.validate();
458
694
  }
459
- async setBusy(reason: string, busy: boolean) {
695
+ async setBusy(reason: string, busy: boolean, publish = true) {
460
696
  this.validate();
461
697
  if (busy) this.busy.add(reason);
462
698
  else this.busy.delete(reason);
463
- await this.update();
699
+ if (publish) await this.update();
464
700
  this.validate();
465
701
  }
466
702
  async update() {
467
703
  if (this.connection && !this.paused && !this.disposed && !this.signal.aborted)
468
- await this.connection.update(this.facts());
704
+ await this.publishFacts(this.connection);
469
705
  }
470
- private async callback(callback: Callback, signal: AbortSignal) {
706
+ private async callback(callback: Callback, signal: AbortSignal, protectionOnly: boolean) {
471
707
  const payload = callback.payload as {
472
708
  reservation?: string;
473
709
  targets?: string[];
@@ -490,6 +726,7 @@ export class PiDaemonClient {
490
726
  signal.throwIfAborted();
491
727
  if (this.paused) throw new Error("Pi session is changing; no new work is authorized.");
492
728
  if (callback.kind === "queue-acquire") {
729
+ if (this.pendingReload) throw new Error("Pi resources are about to reload.");
493
730
  if (payload.background && !this.facts().idle) throw new Error("Pi is busy; background apply was not granted.");
494
731
  if (
495
732
  payload.generation !== this.generation ||
@@ -502,6 +739,7 @@ export class PiDaemonClient {
502
739
  const ctx = this.uiContext;
503
740
  const combined = AbortSignal.any([signal, this.signal]);
504
741
  if (callback.kind === "model-binding") {
742
+ if (protectionOnly) return null;
505
743
  const facts = this.facts();
506
744
  const connection = this.connection ?? this.partialConnection;
507
745
  if (connection && JSON.stringify(connection.facts.model) !== JSON.stringify(facts.model)) {
@@ -511,7 +749,8 @@ export class PiDaemonClient {
511
749
  return payload.background && !facts.idle ? null : (facts.model ?? null);
512
750
  }
513
751
  if (callback.kind === "reload") {
514
- this.reloadRequested = true;
752
+ if (!this.reloadRequest) throw new Error("No active Pi command can reload resources.");
753
+ this.reloadRequest.received = true;
515
754
  return true;
516
755
  }
517
756
  if (!ctx.hasUI || !["tui", "rpc"].includes(ctx.mode)) throw new Error("This client cannot present safety reviews.");
@@ -568,6 +807,7 @@ export class PiDaemonClient {
568
807
  async dispose(handoff?: ClientHandoff) {
569
808
  if (this.disposing) return this.disposing;
570
809
  this.closing = true;
810
+ this.stopContactRepair(false);
571
811
  this.disposing = (async () => {
572
812
  const connection = this.connection ?? this.partialConnection ?? (await this.connecting?.catch(() => undefined));
573
813
  let confirmed = false;
@@ -1,4 +1,4 @@
1
- import { type ClientFacts, DaemonConnection, findDaemon, type Identity } from "@narumitw/sync-daemon";
1
+ import { type ClientFacts, DaemonConnection, findDaemon, type Identity } from "@narumitw/pi-sync-daemon";
2
2
  import type { PiApplyGate } from "./apply-gate.js";
3
3
 
4
4
  type Address = { paths: DaemonConnection["paths"]; identity: Identity };