@narumitw/pi-sync 0.67.1 → 0.67.2
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 +6 -0
- package/dist/chunks/{chunk-CQXGMESM.ts → chunk-2MSJDLSM.ts} +2 -2
- package/dist/chunks/{chunk-XPKHWTGT.ts → chunk-C3E75DXW.ts} +8 -6
- package/dist/chunks/chunk-C3E75DXW.ts.map +7 -0
- package/dist/chunks/{chunk-W7DSN33J.ts → chunk-GRXNUC6O.ts} +3 -3
- package/dist/chunks/{chunk-JNTDIVP6.ts → chunk-I72HGZJJ.ts} +2 -2
- package/dist/chunks/{chunk-3CO7QIYB.ts → chunk-UF2HU2NM.ts} +2 -2
- package/dist/chunks/{command-handler-H5X3BX5D.ts → command-handler-HWRPH3K3.ts} +6 -6
- package/dist/chunks/{conflict-review-SSY37F4P.ts → conflict-review-OBBBSVQD.ts} +2 -2
- package/dist/chunks/{ignore-file-ui-UY2TEK4C.ts → ignore-file-ui-5BWA6LBC.ts} +3 -3
- package/dist/chunks/{manager-result-dispatcher-PEVIGLOS.ts → manager-result-dispatcher-MJ6G2CEI.ts} +3 -3
- package/dist/chunks/{manager-ui-R5XHYRXK.ts → manager-ui-Z3B5ZTA6.ts} +9 -9
- package/dist/chunks/{remote-selection-ui-WFLX6MAJ.ts → remote-selection-ui-34WC7OFE.ts} +2 -2
- package/dist/chunks/{setup-wizard-5OMFSFPJ.ts → setup-wizard-YOXLXLBY.ts} +4 -4
- package/dist/chunks/{sync-inspection-S2GHDBAD.ts → sync-inspection-NIITROKS.ts} +2 -2
- package/dist/chunks/{sync-operations-LQ63CU2T.ts → sync-operations-FFI4ZZQL.ts} +2 -2
- package/dist/daemon/dist/engine/debug-log.js +19 -0
- package/dist/daemon/dist/server.js +2 -2
- package/dist/daemon/package.json +1 -1
- package/dist/index.ts +4 -4
- package/package.json +2 -2
- package/skills/configure-pi-sync/references/configuration.md +2 -0
- package/src/daemon/client-debug.ts +6 -3
- package/src/daemon/pi-client.ts +1 -2
- package/dist/chunks/chunk-XPKHWTGT.ts.map +0 -7
- /package/dist/chunks/{chunk-CQXGMESM.ts.map → chunk-2MSJDLSM.ts.map} +0 -0
- /package/dist/chunks/{chunk-W7DSN33J.ts.map → chunk-GRXNUC6O.ts.map} +0 -0
- /package/dist/chunks/{chunk-JNTDIVP6.ts.map → chunk-I72HGZJJ.ts.map} +0 -0
- /package/dist/chunks/{chunk-3CO7QIYB.ts.map → chunk-UF2HU2NM.ts.map} +0 -0
- /package/dist/chunks/{command-handler-H5X3BX5D.ts.map → command-handler-HWRPH3K3.ts.map} +0 -0
- /package/dist/chunks/{conflict-review-SSY37F4P.ts.map → conflict-review-OBBBSVQD.ts.map} +0 -0
- /package/dist/chunks/{ignore-file-ui-UY2TEK4C.ts.map → ignore-file-ui-5BWA6LBC.ts.map} +0 -0
- /package/dist/chunks/{manager-result-dispatcher-PEVIGLOS.ts.map → manager-result-dispatcher-MJ6G2CEI.ts.map} +0 -0
- /package/dist/chunks/{manager-ui-R5XHYRXK.ts.map → manager-ui-Z3B5ZTA6.ts.map} +0 -0
- /package/dist/chunks/{remote-selection-ui-WFLX6MAJ.ts.map → remote-selection-ui-34WC7OFE.ts.map} +0 -0
- /package/dist/chunks/{setup-wizard-5OMFSFPJ.ts.map → setup-wizard-YOXLXLBY.ts.map} +0 -0
- /package/dist/chunks/{sync-inspection-S2GHDBAD.ts.map → sync-inspection-NIITROKS.ts.map} +0 -0
- /package/dist/chunks/{sync-operations-LQ63CU2T.ts.map → sync-operations-FFI4ZZQL.ts.map} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @narumitw/pi-sync
|
|
2
2
|
|
|
3
|
+
## 0.67.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 489bc7a: Record foreground Push and Pull attempts in the private debug log, including resumed ignore-rule Pulls. Match client and daemon records by operation ID without logging raw errors or transfer data.
|
|
8
|
+
|
|
3
9
|
## 0.67.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
|
|
3
3
|
import {
|
|
4
4
|
showRemoteSelectionReview
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-UF2HU2NM.ts";
|
|
6
6
|
import {
|
|
7
7
|
runCancellableOperation
|
|
8
8
|
} from "./chunk-PUSMSKIM.ts";
|
|
@@ -208,4 +208,4 @@ async function dispatchManagerResult(ctx, initialResult, origin, runRoute, signa
|
|
|
208
208
|
export {
|
|
209
209
|
dispatchManagerResult
|
|
210
210
|
};
|
|
211
|
-
//# sourceMappingURL=chunk-
|
|
211
|
+
//# sourceMappingURL=chunk-2MSJDLSM.ts.map
|
|
@@ -170,7 +170,7 @@ var PiApplyGate = class {
|
|
|
170
170
|
};
|
|
171
171
|
|
|
172
172
|
// src/daemon/client-debug.ts
|
|
173
|
-
import { debugOperation } from "#pi-sync-daemon/engine/debug-log";
|
|
173
|
+
import { debugJobResult, debugOperation } from "#pi-sync-daemon/engine/debug-log";
|
|
174
174
|
function observeDebugJob(operation, append) {
|
|
175
175
|
const kind = debugOperation(operation);
|
|
176
176
|
if (!kind) return void 0;
|
|
@@ -178,11 +178,14 @@ function observeDebugJob(operation, append) {
|
|
|
178
178
|
const record = (outcome) => append({ event: "job", operation: kind, outcome, ...operationId ? { operationId } : {} });
|
|
179
179
|
return {
|
|
180
180
|
onSubmit(id) {
|
|
181
|
+
if (operationId && operationId !== id) record("blocked");
|
|
181
182
|
operationId = id;
|
|
182
183
|
record("started");
|
|
183
184
|
},
|
|
184
|
-
returned(result) {
|
|
185
|
-
|
|
185
|
+
returned(result, interrupted = false) {
|
|
186
|
+
const outcome = debugJobResult(kind, result);
|
|
187
|
+
if (interrupted && outcome !== "completed") record("cancelled");
|
|
188
|
+
else if (outcome) record(outcome);
|
|
186
189
|
else if (result === "archived" || kind === "initialize" && typeof result === "object" && result !== null && "handoverRequired" in result && result.handoverRequired === true)
|
|
187
190
|
record("blocked");
|
|
188
191
|
else if (kind === "migrate-state" && typeof result === "object" && result !== null && "status" in result && result.status === "cancelled")
|
|
@@ -1282,8 +1285,7 @@ var PiDaemonClient = class {
|
|
|
1282
1285
|
}
|
|
1283
1286
|
}
|
|
1284
1287
|
) : await connection.run(operation, payload, runSignal, onCommit, diagnostics?.onSubmit);
|
|
1285
|
-
|
|
1286
|
-
else diagnostics?.returned(result);
|
|
1288
|
+
diagnostics?.returned(result, runSignal.aborted || reload?.signal.aborted);
|
|
1287
1289
|
if (request?.received && reload && !this.paused && !reload.signal.aborted && !signal?.aborted) {
|
|
1288
1290
|
this.validate();
|
|
1289
1291
|
this.pendingReload = reload;
|
|
@@ -1549,4 +1551,4 @@ export {
|
|
|
1549
1551
|
withPiDaemonClient,
|
|
1550
1552
|
remoteOperation
|
|
1551
1553
|
};
|
|
1552
|
-
//# sourceMappingURL=chunk-
|
|
1554
|
+
//# sourceMappingURL=chunk-C3E75DXW.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/daemon/pi-client.ts", "../../src/daemon/apply-gate.ts", "../../src/daemon/client-debug.ts", "../../src/daemon/directional-recovery.ts", "../../src/daemon/queue-release-ui.ts", "../../src/daemon/recovery.ts", "../../src/daemon/startup-bootstrap-client.ts"],
|
|
4
|
+
"sourcesContent": ["import { AsyncLocalStorage } from \"node:async_hooks\";\nimport { randomUUID } from \"node:crypto\";\nimport { lstatSync, realpathSync } from \"node:fs\";\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { type ExtensionContext, getAgentDir } from \"@earendil-works/pi-coding-agent\";\nimport {\n type Callback,\n type ClientFacts,\n type ClientHandoff,\n type ContactState,\n DaemonConnection,\n DaemonError,\n type DaemonRecoveryTarget,\n type DocumentView,\n documentFingerprint,\n ensureDaemon,\n findDaemon,\n MAX_SETTINGS_BYTES,\n modelSignature,\n OWNERSHIP_CLEANUP_REQUIRED,\n waitForDaemonExit,\n} from \"@narumitw/pi-sync-daemon\";\nimport { appendDebugEvent, type DebugEvent } from \"@narumitw/pi-sync-daemon/engine/debug-log\";\nimport { type ConfigAuthority, configureEngineHost } from \"@narumitw/pi-sync-daemon/engine/host\";\nimport {\n type LocalConfigDocument,\n peekLocalConfigDocument,\n} from \"@narumitw/pi-sync-daemon/engine/settings/config-file\";\nimport { validateSettingsDocument } from \"@narumitw/pi-sync-daemon/engine/settings/settings-validation\";\nimport { sessionDirFromContext } from \"@narumitw/pi-sync-daemon/engine/snapshot/session-paths\";\nimport type { CommandOptions } from \"../commands/command-types.js\";\nimport type { StartupTimingPublisher } from \"../sync/startup-timings.js\";\nimport { errorMessage, SyncDecisionRequiredError } from \"../sync/sync-errors.js\";\nimport { RemoteSelectionMismatchError } from \"../sync/sync-policy.js\";\nimport {\n type SyncStatusPresentation,\n setSyncStatus,\n showSyncConnectionStatus,\n showSyncQueueReleaseRecovery,\n} from \"../ui/sync-status.js\";\nimport { safeTerminalText } from \"../ui/terminal-text.js\";\nimport { PiApplyGate } from \"./apply-gate.js\";\nimport { observeDebugJob } from \"./client-debug.js\";\nimport {\n type DirectionalCheckpoint,\n isForegroundDirection,\n type PendingAdoptionRecovery,\n runDirectionalRecovery,\n} from \"./directional-recovery.js\";\nimport { createQueueReleaseUI, type QueueReleaseEvent } from \"./queue-release-ui.js\";\nimport { quarantineClient, recoverDetachedClients } from \"./recovery.js\";\nimport { requestStartupBootstrap } from \"./startup-bootstrap-client.js\";\n\nconst scope = new AsyncLocalStorage<{ client: PiDaemonClient; reload?: AbortController }>();\nconst clients = new WeakMap<ExtensionContext[\"sessionManager\"], PiDaemonClient>();\nexport function currentPiDaemonClient() {\n return current();\n}\nfunction current() {\n const client = scope.getStore()?.client;\n if (!client) throw new Error(\"Pi synchronization requires a current session-bound daemon client.\");\n client.validate();\n return client;\n}\nfunction canonicalPath(value: string | undefined): string | undefined {\n // An in-memory session (`pi --no-session`) reports an empty session dir instead of\n // omitting it, so an empty path means \"no path to publish\", not a broken caller.\n if (value === undefined || value === \"\") return undefined;\n if (!path.isAbsolute(value)) throw new Error(\"Pi session paths must be absolute.\");\n const parts: string[] = [];\n let cursor = path.resolve(value);\n for (;;) {\n try {\n return path.join(realpathSync(cursor), ...parts.toReversed());\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ENOENT\" || path.dirname(cursor) === cursor) throw error;\n parts.push(path.basename(cursor));\n cursor = path.dirname(cursor);\n }\n }\n}\nfunction decode(value: unknown): LocalConfigDocument | undefined {\n if (value === null) return undefined;\n const document = value as DocumentView;\n if (\n !document ||\n typeof document.path !== \"string\" ||\n typeof document.bytes !== \"string\" ||\n !document.identity ||\n !document.parsed\n )\n throw new Error(\"Invalid settings response.\");\n return { ...document, bytes: Buffer.from(document.bytes, \"base64\") };\n}\nfunction fingerprint(document: LocalConfigDocument | undefined) {\n return documentFingerprint(\n document ? { bytes: document.bytes.toString(\"base64\"), identity: document.identity } : undefined,\n );\n}\nlet settingsQueue = Promise.resolve();\nconst authority: ConfigAuthority = {\n read: (repair) => {\n const client = current();\n return settingsQueue.then(() => {\n client.validate();\n return client.readSettings(repair);\n });\n },\n update: <T extends Record<string, unknown>>(\n fallback: T,\n update: (value: T) => T,\n validate: (value: Record<string, unknown>) => void,\n signal?: AbortSignal,\n ): Promise<T> => {\n const client = current();\n // Capture ownership and invocation order before prerequisite awaits.\n const operation = settingsQueue.then(async () => {\n client.validate();\n signal?.throwIfAborted();\n const document = await client.readSettings(true);\n client.validate();\n signal?.throwIfAborted();\n if (document) validate(document.parsed);\n const next = update(structuredClone(document?.parsed ?? fallback) as T);\n validate(next);\n await client.run(\"settings.cas\", { expected: fingerprint(document), next }, signal);\n client.validate();\n return next;\n });\n settingsQueue = operation.then(\n () => undefined,\n () => undefined,\n );\n return operation;\n },\n create: async (next, signal) => {\n await current().run(\"settings.cas\", { expected: null, next }, signal);\n },\n replace: async (document, next) => {\n await current().run(\"settings.cas\", { expected: fingerprint(document), next });\n },\n};\n/** Factory registration installs only adapters; it starts no process and performs no I/O. */\nexport function installPiDaemonHost() {\n configureEngineHost({\n root: () => scope.getStore()?.client.root ?? path.resolve(getAgentDir()),\n config: authority,\n mutate: async () => {\n throw new Error(\"File mutation belongs to pi-sync-daemon; no in-process fallback is permitted.\");\n },\n review: async () => {\n throw new Error(\"Engine reviews must arrive through the daemon API.\");\n },\n });\n}\nexport function bindPiDaemonClient(ctx: ExtensionContext, signal: AbortSignal, publish?: StartupTimingPublisher) {\n const client = new PiDaemonClient(ctx, signal, publish);\n clients.set(ctx.sessionManager, client);\n return client;\n}\nexport function piDaemonClient(ctx: ExtensionContext) {\n const client = clients.get(ctx.sessionManager);\n if (!client) throw new Error(\"The Pi synchronization client is not attached to this session.\");\n client.validate();\n return client;\n}\nexport function withPiDaemonClient<Context extends ExtensionContext, T>(\n ctx: Context,\n action: (owned: Context) => Promise<T>,\n reload?: AbortController,\n) {\n const owner = { client: piDaemonClient(ctx), reload };\n // TUI input arrives from Pi's event loop, outside the command's async call tree.\n // Bind public component methods so later menu actions retain this exact owner,\n // never a replacement session selected through a global fallback.\n const ui = new Proxy(ctx.ui, {\n get(target, property) {\n if (property !== \"custom\") return Reflect.get(target, property, target);\n return (...args: Parameters<ExtensionContext[\"ui\"][\"custom\"]>) => {\n const [factory, options] = args;\n const wrap = (component: Awaited<ReturnType<typeof factory>>) => {\n const methods = new Map<PropertyKey, { source: unknown; bound: unknown }>();\n return new Proxy(component, {\n get(original, key) {\n const value: unknown = Reflect.get(original, key, original);\n if (typeof value !== \"function\") return value;\n const saved = methods.get(key);\n if (saved?.source === value) return saved.bound;\n const bound = (...values: unknown[]) => scope.run(owner, () => Reflect.apply(value, original, values));\n methods.set(key, { source: value, bound });\n return bound;\n },\n });\n };\n const invoke = (...provided: Parameters<typeof factory>) => {\n const component = scope.run(owner, () => factory(...provided));\n return component instanceof Promise ? component.then(wrap) : wrap(component);\n };\n // Do not turn synchronous editors/reviews into asynchronous factories.\n return target.custom(\n factory.constructor.name === \"AsyncFunction\" ? async (...provided) => invoke(...provided) : invoke,\n options,\n );\n };\n },\n });\n const owned = new Proxy(ctx, {\n get(target, key) {\n return key === \"ui\" ? ui : Reflect.get(target, key, target);\n },\n });\n return scope.run(owner, () => action(owned));\n}\nexport async function remoteOperation(ctx: ExtensionContext, operation: string, options: CommandOptions) {\n const client = piDaemonClient(ctx);\n const { signal, onCommit, args, setup } = options;\n const owner = scope.getStore();\n const reload = options.reload && owner?.client === client ? owner.reload : undefined;\n reload?.signal.throwIfAborted();\n const payload = {\n args,\n ...(setup === undefined ? {} : { setup }),\n ...(options.automaticFingerprint === undefined ? {} : { automaticFingerprint: options.automaticFingerprint }),\n yes: options.yes,\n force: options.force,\n stale: options.stale,\n silent: options.silent,\n reload: reload !== undefined,\n ...(options.agentRetryRefusal ? { agentRetryRefusal: true } : {}),\n };\n return client.run(operation, payload, signal, ctx, onCommit, reload);\n}\nfunction remoteErrorNamed(error: unknown, name: string) {\n return error instanceof DaemonError && error.remote.name === name;\n}\n\nexport class PiDaemonClient {\n private connection?: DaemonConnection;\n private protectionOnly = false;\n private partialConnection?: DaemonConnection;\n private work = Promise.resolve();\n private factsQueue = Promise.resolve();\n private closing = false;\n private paused = false;\n private pausing?: Promise<void>;\n private connecting?: Promise<DaemonConnection>;\n private contactRepair?: { controller: AbortController; done: Promise<void> };\n private contactAttempt?: { error?: unknown };\n private contactFactsUnpublished = false;\n private contactStatus?: { clear(redraw?: boolean): void; unavailable: boolean };\n private releaseUIEnabled = true;\n private runSignal?: AbortSignal;\n private readonly releaseUI = createQueueReleaseUI(\n () => {\n const ctx = this.releaseContext();\n if (ctx) return showSyncQueueReleaseRecovery(ctx);\n },\n () =>\n this.releaseContext()?.ui.notify(\n \"Pi Sync could not confirm the file write queue release. Sync may be paused; check /sync daemon status before retrying.\",\n \"warning\",\n ),\n );\n private readonly stopReleaseUI = () => {\n // Withdraw while the SDK owner is still active, but never redraw through a replaced context.\n this.releaseUIEnabled = false;\n this.releaseUI.clear(Boolean(this.releaseContext(true)));\n };\n private disposed = false;\n private disposing?: Promise<void>;\n private uiContext: ExtensionContext;\n private reloadRequest?: { received: boolean };\n private pendingReload?: AbortController;\n private directionalCheckpoint?: DirectionalCheckpoint;\n private adoptionRecovery?: {\n pending: PendingAdoptionRecovery;\n review: { setupName: string; fingerprint: string };\n assertRoot(): void;\n };\n private recoveringDirectionalOwner = false;\n private readonly busy = new Set<string>();\n private initialized = false;\n private startupDebug = false;\n private debug = false;\n private participantIdentity = { id: randomUUID(), generation: randomUUID() };\n get id() {\n return this.participantIdentity.id;\n }\n get generation() {\n return this.participantIdentity.generation;\n }\n readonly root: string;\n private cleanupRequired = false;\n private recoveredOwner?: DaemonRecoveryTarget;\n private readonly rawRoot: string;\n private readonly gate: PiApplyGate;\n private readonly manager: ExtensionContext[\"sessionManager\"];\n constructor(\n private readonly ctx: ExtensionContext,\n private readonly signal: AbortSignal,\n private readonly publish?: StartupTimingPublisher,\n ) {\n this.uiContext = ctx;\n this.manager = ctx.sessionManager;\n this.rawRoot = getAgentDir();\n const root = canonicalPath(path.resolve(this.rawRoot));\n if (!root) throw new Error(\"Agent directory is unavailable.\");\n this.root = root;\n this.gate = new PiApplyGate(() => this.validate());\n this.signal.addEventListener(\"abort\", this.stopReleaseUI, { once: true });\n }\n validate() {\n this.signal.throwIfAborted();\n if (this.disposed || this.closing || clients.get(this.manager) !== this)\n throw new Error(\"Synchronization session was replaced.\");\n // Public context access verifies the SDK runner is still active after awaits.\n this.ctx.isIdle();\n if (getAgentDir() !== this.rawRoot || canonicalPath(path.resolve(this.rawRoot)) !== this.root)\n throw new Error(\"Agent directory changed; reload before synchronization.\");\n }\n get debugEnabled() {\n return this.debug;\n }\n setDebugPreference(debug: boolean) {\n this.debug = debug && this.ctx.hasUI && (this.ctx.mode === \"tui\" || this.ctx.mode === \"rpc\");\n }\n recordDebug(event: DebugEvent) {\n if (!this.debug || this.protectionOnly || this.pendingReload || !this.ownsContactUI()) return;\n try {\n this.validate();\n appendDebugEvent(this.root, \"pi-sync\", event);\n } catch {}\n }\n private modelBinding(): ClientFacts[\"model\"] {\n const model = this.ctx.model;\n if (!model) return undefined;\n const registry = this.ctx.modelRegistry;\n if (registry.getRegisteredProviderIds().includes(model.provider)) return undefined;\n const source = registry.getProviderAuthStatus(model.provider).source;\n if (\n source !== \"stored\" &&\n source !== \"environment\" &&\n source !== \"models_json_key\" &&\n source !== \"models_json_command\"\n )\n return undefined;\n return { provider: model.provider, id: model.id, signature: modelSignature(model), authSource: source };\n }\n private facts(protectionOnly = this.protectionOnly): ClientFacts {\n const manager = this.ctx.sessionManager;\n return {\n id: this.id,\n generation: this.generation,\n pid: process.pid,\n cwd: this.ctx.cwd,\n mode: this.ctx.mode,\n hasUI: !protectionOnly && this.ctx.hasUI,\n idle: !protectionOnly && !this.recoveringDirectionalOwner && !this.paused && !this.busy.size && this.ctx.isIdle(),\n ready: !protectionOnly && !this.recoveringDirectionalOwner && this.initialized,\n startupDebug: this.startupDebug,\n sessionFile: canonicalPath(manager.getSessionFile?.()),\n sessionId: manager.getSessionId?.(),\n sessionDir: canonicalPath(sessionDirFromContext(this.ctx)),\n model: protectionOnly ? undefined : this.modelBinding(),\n };\n }\n async configured(matches?: (settings: ReturnType<typeof validateSettingsDocument>) => boolean) {\n this.validate();\n await settingsQueue;\n this.validate();\n const document = await peekLocalConfigDocument();\n this.validate();\n const settings = document && validateSettingsDocument(document.parsed);\n return Boolean(settings?.activeSyncSetup && (matches?.(settings) ?? true));\n }\n async pauseForSessionChange() {\n this.validate();\n this.paused = true;\n this.stopReleaseUI();\n this.stopContactRepair(true);\n this.gate.cancelPending();\n this.pausing ??= (async () => {\n const connection = this.connection ?? this.partialConnection ?? (await this.connecting?.catch(() => undefined));\n if (connection) {\n await connection.pause();\n await this.gate.releaseAfterDrain();\n }\n })();\n return this.pausing;\n }\n async attachExisting({ allowUpgrade = false } = {}) {\n this.validate();\n this.assertNoDirectionalRecovery();\n if (!allowUpgrade && !this.paused && this.connection?.contactState === \"active\") return !this.protectionOnly;\n const address = await findDaemon(this.root).catch((error: unknown) => {\n this.recordDebug({ event: \"connection\", outcome: \"failed\" });\n throw error;\n });\n this.validate();\n this.assertNoDirectionalRecovery();\n if (!address) {\n this.recordDebug({ event: \"connection\", outcome: \"skipped\" });\n return false;\n }\n const upgrade = allowUpgrade && address.needsUpgrade && this.ctx.hasUI && [\"tui\", \"rpc\"].includes(this.ctx.mode);\n let upgradeFailure: string | undefined;\n if (upgrade) {\n try {\n await this.connect();\n this.validate();\n return true;\n } catch (error) {\n this.validate();\n if (this.paused || this.recoveringDirectionalOwner) throw error;\n upgradeFailure = safeTerminalText(errorMessage(error));\n }\n }\n try {\n // If upgrade failed, try only the original owner, with its protection-only facts.\n await this.connect(address);\n } catch (error) {\n this.validate();\n if (remoteErrorNamed(error, \"DaemonStoppingError\")) return false;\n throw error;\n } finally {\n if (upgradeFailure !== undefined) {\n this.validate();\n this.ctx.ui.notify(`pi-sync daemon upgrade failed: ${upgradeFailure}`, \"error\");\n }\n }\n this.validate();\n // Headless, shutdown, and failed-upgrade paths must not schedule transfers on an older build.\n return !this.protectionOnly;\n }\n async finishReattachment() {\n this.validate();\n const connection = this.connection;\n if (!connection) return;\n await recoverDetachedClients(connection);\n await this.queueFacts(async () => {\n this.validateFactsScope(connection);\n await connection.attach(this.signal);\n this.validateFactsScope(connection);\n });\n }\n private assertNoDirectionalRecovery() {\n if (this.recoveringDirectionalOwner)\n throw new Error(\"Pi Sync is recovering the daemon for a transfer. Retry after recovery finishes.\");\n }\n async connect(existing?: Awaited<ReturnType<typeof ensureDaemon>>, requestSignal?: AbortSignal) {\n this.assertNoDirectionalRecovery();\n return this.attachConnection(existing, requestSignal);\n }\n private async attachConnection(existing?: Awaited<ReturnType<typeof ensureDaemon>>, requestSignal?: AbortSignal) {\n const startupSignal = requestSignal ? AbortSignal.any([this.signal, requestSignal]) : this.signal;\n const validateStartup = () => {\n this.validate();\n startupSignal.throwIfAborted();\n };\n validateStartup();\n if (this.connection) {\n if (!existing && this.protectionOnly)\n throw new Error(\n \"This session is only protecting its files on an older Pi Sync daemon. Use /reload to upgrade.\",\n );\n return this.connection;\n }\n this.connecting ??= (async () => {\n if (this.partialConnection) {\n // A failed unpublished attempt may already be retired or own queue grants.\n // Confirm drain before replacing its identity; failed cleanup must block retry.\n await this.partialConnection.dispose();\n // Finish acknowledged cleanup even if this new startup was cancelled meanwhile.\n await this.gate.releaseAfterDrain();\n validateStartup();\n this.partialConnection = undefined;\n this.participantIdentity = { id: randomUUID(), generation: randomUUID() };\n }\n // Only explicit setup/command paths or a configured interactive session call connect.\n if (!existing) await fs.mkdir(this.root, { recursive: true, mode: 0o700 });\n validateStartup();\n let retried = false;\n for (;;) {\n validateStartup();\n const daemon = existing ?? (await ensureDaemon(this.root, startupSignal));\n validateStartup();\n if (daemon.paths.root !== this.root) throw new Error(\"Daemon root changed before attach.\");\n const protectionOnly = daemon.needsUpgrade === true;\n const connection = new DaemonConnection(daemon.paths, daemon.identity, this.facts(protectionOnly), {\n callback: (callback, signal) => this.callback(connection, callback, signal, protectionOnly),\n mergeReview:\n !protectionOnly && this.ctx.hasUI\n ? (callback, loadDetails, signal) => this.pagedMergeReview(connection, callback, loadDetails, signal)\n : undefined,\n event: (event) => {\n if (event.kind === \"commit\") return;\n if (this.signal.aborted || this.disposed || this.closing || clients.get(this.manager) !== this) return;\n const payload = event.payload as {\n message?: string;\n level?: \"info\" | \"warning\" | \"error\";\n report?: string;\n value?: string;\n presentation?: SyncStatusPresentation;\n };\n if (event.kind === \"notify\" && typeof payload?.message === \"string\")\n this.uiContext.ui.notify(safeTerminalText(payload.message), payload.level ?? \"info\");\n if (event.kind === \"timings\" && typeof payload?.report === \"string\") {\n this.publish?.(this.ctx, payload.report.split(\"\\n\").map(safeTerminalText).join(\"\\n\"));\n }\n if (event.kind === \"status\")\n setSyncStatus(\n this.uiContext,\n typeof payload?.value === \"string\" ? safeTerminalText(payload.value) : undefined,\n payload.presentation,\n );\n },\n contact: (state) => this.observeContact(connection, state),\n queueRelease: (event) => this.observeQueueRelease(connection, event),\n error: () => {\n if (\n !this.recoveringDirectionalOwner &&\n this.ownsContactUI() &&\n connection.facts.hasUI &&\n !this.releaseUI.retrying\n )\n this.showContactStatus(\"sync service unavailable\", \"blocked\", true);\n },\n });\n this.partialConnection = connection;\n try {\n await connection.attach(startupSignal);\n } catch (error) {\n if (!(error instanceof DaemonError) || error.remote.name !== \"DaemonStoppingError\") throw error;\n // The final idle fence rejected publication, so this connection owns no queue grants.\n await connection.dispose().catch(() => {});\n this.partialConnection = undefined;\n validateStartup();\n if (existing || retried) throw error;\n retried = true;\n await waitForDaemonExit(daemon.identity, startupSignal);\n validateStartup();\n continue;\n }\n this.validate();\n await recoverDetachedClients(daemon);\n if (this.signal.aborted || this.disposed || this.closing) {\n await connection.dispose();\n this.validate();\n }\n this.validate();\n this.connection = connection;\n this.protectionOnly = protectionOnly;\n this.partialConnection = undefined;\n return connection;\n }\n })().then(\n (connection) => {\n this.recordDebug({ event: \"connection\", outcome: startupSignal.aborted ? \"cancelled\" : \"completed\" });\n return connection;\n },\n (error: unknown) => {\n this.connecting = undefined;\n const outcome = startupSignal.aborted\n ? \"cancelled\"\n : existing && remoteErrorNamed(error, \"DaemonStoppingError\")\n ? \"skipped\"\n : \"failed\";\n this.recordDebug({ event: \"connection\", outcome });\n throw error;\n },\n );\n const connection = await this.connecting;\n validateStartup();\n if (!existing && this.protectionOnly)\n throw new Error(\"This session is only protecting its files on an older Pi Sync daemon. Use /reload to upgrade.\");\n return connection;\n }\n private ownsContactUI() {\n return (\n !this.signal.aborted && !this.disposed && !this.closing && !this.paused && clients.get(this.manager) === this\n );\n }\n private releaseContext(cleanup = false) {\n if (clients.get(this.manager) !== this) return;\n if (!cleanup && (!this.releaseUIEnabled || !this.ownsContactUI() || this.busy.has(\"shutdown\"))) return;\n try {\n this.ctx.isIdle(); // Also verifies the SDK context has not been retired.\n if (this.ctx.hasUI && (this.ctx.mode === \"tui\" || this.ctx.mode === \"rpc\")) return this.ctx;\n } catch {\n // Detached cleanup can outlive its UI.\n }\n }\n disableQueueReleaseUI() {\n this.stopReleaseUI();\n }\n private observeQueueRelease(connection: DaemonConnection, event: QueueReleaseEvent) {\n if (connection !== this.connection || !connection.facts.hasUI || !this.releaseContext()) return;\n if (event.state === \"retrying\" && this.contactStatus?.unavailable) this.clearConnectionStatus();\n this.releaseUI.observe(event, this.busy.has(\"command\"), !this.runSignal || this.runSignal.aborted);\n }\n private showContactStatus(text: string, activity: \"retry\" | \"blocked\", unavailable = false) {\n const previous = this.contactStatus;\n this.contactStatus = {\n clear: showSyncConnectionStatus(this.ctx, text, { activity, reason: activity === \"retry\" ? \"temp\" : \"repair\" }),\n unavailable,\n };\n previous?.clear();\n }\n private clearConnectionStatus(redraw = true) {\n const status = this.contactStatus;\n this.contactStatus = undefined;\n status?.clear(redraw);\n }\n private stopContactRepair(redraw: boolean) {\n this.contactRepair?.controller.abort(new DOMException(\"Pi session is changing\", \"AbortError\"));\n this.clearConnectionStatus(redraw);\n }\n private observeContact(connection: DaemonConnection, state: ContactState) {\n if (connection !== this.connection || !this.ownsContactUI()) return;\n if (state === \"active\") {\n if (this.contactRepair || this.contactFactsUnpublished || connection.contactResumeState === \"uncertain\") return;\n this.clearRestoredContact();\n } else if (state === \"expired\" && connection.facts.hasUI && !this.contactAttempt && !this.contactRepair) {\n if (this.gate.size || connection.hasPendingWork || this.releaseUI.retrying) return;\n void this.resumeContact(connection).catch(() => {\n // The owning repair updates the status; a later command reports the error.\n });\n }\n }\n private clearRestoredContact() {\n this.contactAttempt = undefined;\n this.contactFactsUnpublished = false;\n this.clearConnectionStatus();\n }\n private queueFacts<T>(publish: () => Promise<T>): Promise<T> {\n const result = this.factsQueue.then(publish);\n this.factsQueue = result.then(\n () => {},\n () => {},\n );\n return result;\n }\n private async queueFactsWithAbortableWait<T>(signal: AbortSignal, publish: () => Promise<T>): Promise<T> {\n signal.throwIfAborted();\n const cancelled = Promise.withResolvers<never>();\n const abort = () => cancelled.reject(signal.reason);\n signal.addEventListener(\"abort\", abort, { once: true });\n const queued = this.queueFacts(() => {\n signal.removeEventListener(\"abort\", abort);\n signal.throwIfAborted();\n return publish();\n });\n return Promise.race([queued, cancelled.promise]);\n }\n private validateFactsScope(connection?: DaemonConnection, signal?: AbortSignal) {\n this.validate();\n signal?.throwIfAborted();\n if (this.paused) throw new Error(\"Pi Sync is paused for a session change.\");\n if (connection && connection !== (this.connection ?? this.partialConnection))\n throw new Error(\"Synchronization session was replaced.\");\n }\n private async resumeContact(connection: DaemonConnection) {\n this.validateFactsScope(connection);\n if (this.contactRepair) return this.contactRepair.done;\n const controller = new AbortController();\n const signal = AbortSignal.any([this.signal, controller.signal]);\n const done = this.queueFacts(async () => {\n this.validateFactsScope(connection, signal);\n if (connection.contactState === \"active\" && connection.contactResumeState !== \"uncertain\") return;\n if (this.gate.size || connection.hasPendingWork || connection.contactResumeState === \"uncertain\") {\n throw new Error(\n \"Pi Sync cannot reconnect while previous work is still running or uncertain. Check sync recovery before retrying.\",\n );\n }\n const earlier = this.contactAttempt;\n if (connection.contactState !== \"expired\" || earlier) {\n throw new Error(\"Pi Sync could not restore contact. Review pending work before using /reload.\", {\n cause: earlier?.error,\n });\n }\n const attempt: { error?: unknown } = {};\n this.contactAttempt = attempt;\n try {\n this.showContactStatus(\"sync reconnecting\", \"retry\");\n // Admission can wait behind an apply. Do not advertise readiness using\n // facts sampled before that wait; publish current facts after the ack.\n await connection.resumeContact({ ...this.facts(), idle: false, ready: false }, signal);\n this.validateFactsScope(connection, signal);\n this.contactFactsUnpublished = true;\n this.contactAttempt = undefined;\n await this.publishCurrentFacts(connection, signal);\n this.recordDebug({ event: \"connection\", outcome: \"completed\" });\n } catch (error) {\n this.recordDebug({ event: \"connection\", outcome: signal.aborted ? \"cancelled\" : \"failed\" });\n attempt.error = error;\n if (this.ownsContactUI() && !signal.aborted) {\n this.validateFactsScope(connection, signal);\n this.showContactStatus(\"sync reconnect blocked; check /sync daemon status\", \"blocked\");\n }\n throw error;\n }\n }).finally(() => {\n if (this.contactRepair?.controller === controller) this.contactRepair = undefined;\n });\n this.contactRepair = { controller, done };\n return done;\n }\n private async publishCurrentFacts(connection: DaemonConnection, signal?: AbortSignal) {\n this.validateFactsScope(connection, signal);\n if (connection.contactResumeState === \"uncertain\")\n throw new Error(\"Pi Sync cannot verify the previous reconnect. Review pending work before using /reload.\");\n await connection.update(this.facts());\n this.validateFactsScope(connection, signal);\n this.confirmContact(connection);\n }\n private async publishFacts(connection: DaemonConnection, signal?: AbortSignal) {\n if (this.contactRepair) await this.contactRepair.done;\n const publish = () => this.queueFacts(() => this.publishCurrentFacts(connection, signal));\n try {\n await publish();\n } catch (error) {\n this.validateFactsScope(connection, signal);\n if (!connection.facts.hasUI || !remoteErrorNamed(error, \"ClientContactExpiredError\")) throw error;\n await this.resumeContact(connection);\n // A shared repair might have started before these facts changed.\n await publish();\n }\n }\n private confirmContact(connection: DaemonConnection) {\n if (connection.contactState === \"expired\" || connection.contactState === \"inactive\")\n throw new Error(\"Pi Sync did not confirm active participation in the daemon.\");\n this.clearRestoredContact();\n }\n async verifyConnection(signal?: AbortSignal) {\n const connection = await this.connect(undefined, signal);\n this.validateFactsScope(connection, signal);\n this.assertNoDirectionalRecovery();\n await this.publishFacts(connection, signal);\n this.validateFactsScope(connection, signal);\n this.assertNoDirectionalRecovery();\n return connection;\n }\n async readSettings(repair = false) {\n this.validate();\n if (!this.connection || this.paused) {\n const document = await peekLocalConfigDocument();\n this.validate();\n if (document && document.bytes.length > MAX_SETTINGS_BYTES)\n throw new Error(\"Settings exceed the local API byte limit; the source document is unchanged.\");\n if (document && !repair) validateSettingsDocument(document.parsed);\n return document;\n }\n return decode(await this.run(repair ? \"settings.repair-read\" : \"settings.read\", {}));\n }\n canReportDirectionalResult() {\n try {\n this.validateFactsScope();\n return !this.pendingReload;\n } catch {\n return false;\n }\n }\n get ownershipCleanupRequired() {\n return this.cleanupRequired;\n }\n get pendingPullReview() {\n const recovery = this.adoptionRecovery;\n if (\n !this.cleanupRequired ||\n !recovery ||\n this.paused ||\n recovery.pending.owner !== this.connection ||\n !recovery.pending.owner.canRecoverForeground(recovery.pending.job)\n )\n return undefined;\n return recovery.review;\n }\n confirmRecoveryExit(owner: DaemonRecoveryTarget) {\n this.adoptionRecovery = undefined;\n this.cleanupRequired = true;\n this.recoveredOwner = owner;\n }\n recordOwnershipFailure(error: unknown) {\n if (\n (error instanceof DaemonError && error.remote.properties?.code === OWNERSHIP_CLEANUP_REQUIRED) ||\n (error instanceof Error &&\n ((\"code\" in error && error.code === OWNERSHIP_CLEANUP_REQUIRED) ||\n error.message === \"Daemon ownership cleanup is uncertain; stop and reconcile before restarting.\" ||\n error.message === \"Daemon ownership cleanup is uncertain; stop and reconcile before retrying.\" ||\n error.message ===\n \"File-queue release is uncertain; stop the daemon and keep grants quarantined until owner exit.\"))\n )\n this.cleanupRequired = true;\n }\n run(\n operation: string,\n payload: unknown,\n signal?: AbortSignal,\n ctx = this.ctx,\n onCommit?: () => void,\n reload?: AbortController,\n requirePendingAdoption = false,\n ) {\n const diagnostics = this.debug ? observeDebugJob(operation, (event) => this.recordDebug(event)) : undefined;\n const adoptionRecovery =\n operation === \"pull.foreground\" && this.pendingPullReview ? this.adoptionRecovery : undefined;\n const result = this.work\n .then(() => {\n if (requirePendingAdoption && !adoptionRecovery)\n throw new Error(\"The original Pull is no longer available for automatic recovery.\");\n return this.runCurrent(operation, payload, signal, ctx, onCommit, reload, diagnostics, adoptionRecovery);\n })\n .catch((error: unknown) => {\n diagnostics?.rejected(error, Boolean(signal?.aborted || reload?.signal.aborted));\n this.recordOwnershipFailure(error);\n throw error;\n });\n this.work = result.then(\n () => {},\n () => {},\n );\n return result;\n }\n private async recoverDirectionalOwner(\n connection: DaemonConnection,\n job: string,\n signal: AbortSignal,\n assertRoot: () => void,\n ) {\n this.validateFactsScope(connection, signal);\n this.recoveringDirectionalOwner = true;\n try {\n this.stopContactRepair(true);\n await this.factsQueue;\n this.validateFactsScope(connection, signal);\n await connection.recoverForeground(job, signal);\n if (this.connection !== connection) throw new Error(\"The Pi participant changed during daemon recovery.\");\n this.confirmRecoveryExit(connection.identity);\n await this.gate.releaseAfterDrain();\n this.connection = undefined;\n this.connecting = undefined;\n this.cleanupRequired = false;\n this.validateFactsScope(undefined, signal);\n assertRoot();\n const replacement = await ensureDaemon(this.root, signal, { compatibleOnly: true });\n this.validateFactsScope(undefined, signal);\n assertRoot();\n const attached = await this.attachConnection(replacement, signal);\n this.validateFactsScope(attached, signal);\n assertRoot();\n return attached;\n } finally {\n this.recoveringDirectionalOwner = false;\n }\n }\n private async runCurrent(\n operation: string,\n payload: unknown,\n signal?: AbortSignal,\n ctx = this.ctx,\n onCommit?: () => void,\n reload?: AbortController,\n diagnostics?: ReturnType<typeof observeDebugJob>,\n adoptionRecovery?: PiDaemonClient[\"adoptionRecovery\"],\n ) {\n this.validate();\n if (adoptionRecovery && (this.adoptionRecovery !== adoptionRecovery || !this.pendingPullReview))\n throw new Error(\"The original Pull is no longer available for automatic recovery.\");\n signal?.throwIfAborted();\n reload?.signal.throwIfAborted();\n if (this.pendingReload) throw new Error(\"Pi resources are about to reload.\");\n if (this.paused && operation !== \"shutdown\")\n throw new Error(\"Synchronization is paused for a session change; if it was cancelled, use /reload to reattach.\");\n const connection = await this.connect(undefined, signal);\n if (this.paused && operation === \"shutdown\") {\n Object.assign(connection.facts, { ...this.facts(), idle: false, ready: false });\n await connection.attach(signal ? AbortSignal.any([signal, this.signal]) : this.signal);\n this.validate();\n }\n this.validate();\n signal?.throwIfAborted();\n if (this.paused)\n await connection.update(this.facts()); // Existing, explicitly attached shutdown path.\n else await this.publishFacts(connection, signal);\n this.validate();\n signal?.throwIfAborted();\n this.uiContext = ctx;\n // The daemon directs reload only to the submitting client, and run() serializes its jobs.\n const request = reload ? { received: false } : undefined;\n this.reloadRequest = request;\n const runSignal = signal ? AbortSignal.any([signal, this.signal]) : this.signal;\n this.runSignal = runSignal;\n const clearForeground = () => this.releaseUI.finishForeground(Boolean(this.releaseContext()));\n runSignal.addEventListener(\"abort\", clearForeground, { once: true });\n try {\n const root = isForegroundDirection(operation) ? lstatSync(this.root) : undefined;\n const assertRoot =\n adoptionRecovery?.assertRoot ??\n (() => {\n const current = lstatSync(this.root);\n if (!root || !current.isDirectory() || current.dev !== root.dev || current.ino !== root.ino)\n throw new Error(\"The agent directory changed during the transfer.\");\n });\n const intent = root ? structuredClone(payload) : payload;\n const pull = operation === \"pull.foreground\" ? (intent as { setup: string; fingerprint: string }) : undefined;\n if (\n adoptionRecovery &&\n (!pull ||\n pull.setup !== adoptionRecovery.review.setupName ||\n pull.fingerprint !== adoptionRecovery.review.fingerprint)\n )\n throw new Error(\"The sync setup changed before Pull recovery.\");\n if (adoptionRecovery) {\n assertRoot();\n const { createSettingsConfigView, syncCheckConfigFingerprint } = await import(\"../settings/config.js\");\n this.validateFactsScope(connection, runSignal);\n const document = await peekLocalConfigDocument();\n this.validateFactsScope(connection, runSignal);\n const config = document && (await createSettingsConfigView(document).observe(undefined, runSignal));\n this.validateFactsScope(connection, runSignal);\n assertRoot();\n if (!config || syncCheckConfigFingerprint(config) !== adoptionRecovery.review.fingerprint)\n throw new Error(\"The sync setup changed before Pull recovery.\");\n }\n const result = root\n ? await runDirectionalRecovery(\n connection,\n runSignal,\n async (checkpoint, retryCheckpoint, retryAdoptionJournal) => {\n const current = checkpoint.connection;\n this.validateFactsScope(current, runSignal);\n assertRoot();\n this.directionalCheckpoint = checkpoint;\n try {\n return await current.run(\n operation,\n retryAdoptionJournal !== undefined\n ? { ...pull, retryAdoptionJournal }\n : retryCheckpoint === undefined\n ? intent\n : { ...(intent as object), retryCheckpoint },\n runSignal,\n onCommit,\n (id) => {\n checkpoint.job = id;\n diagnostics?.onSubmit(id);\n },\n );\n } finally {\n this.directionalCheckpoint = undefined;\n }\n },\n (owner, job, recoverySignal) => this.recoverDirectionalOwner(owner, job, recoverySignal, assertRoot),\n () => {\n this.cleanupRequired = true;\n },\n pull && {\n pending: adoptionRecovery?.pending,\n retain: (pending) => {\n this.adoptionRecovery = pending && {\n pending,\n review: { setupName: pull.setup, fingerprint: pull.fingerprint },\n assertRoot,\n };\n },\n },\n )\n : await connection.run(operation, payload, runSignal, onCommit, diagnostics?.onSubmit);\n diagnostics?.returned(result, runSignal.aborted || reload?.signal.aborted);\n if (request?.received && reload && !this.paused && !reload.signal.aborted && !signal?.aborted) {\n this.validate();\n this.pendingReload = reload;\n // Close the command's UI, not the session. Pi reload must run after this job and its UI drain.\n reload.abort(new DOMException(\"Pi resource reload requested\", \"AbortError\"));\n }\n return result;\n } catch (error) {\n if (error instanceof DaemonError) {\n const prototype =\n error.name === \"RemoteSelectionMismatchError\"\n ? RemoteSelectionMismatchError.prototype\n : error.name === \"SyncDecisionRequiredError\"\n ? SyncDecisionRequiredError.prototype\n : undefined;\n if (prototype) {\n const restored = Object.create(prototype) as Error;\n Object.assign(restored, error.remote.properties, { name: error.name, message: error.message });\n throw restored;\n }\n Object.assign(error, error.remote.properties);\n }\n throw error;\n } finally {\n runSignal.removeEventListener(\"abort\", clearForeground);\n clearForeground();\n this.runSignal = undefined;\n this.uiContext = this.ctx;\n this.reloadRequest = undefined;\n }\n }\n canReload(owner: AbortController) {\n if (this.pendingReload !== owner || this.paused) return false;\n this.validate();\n return true;\n }\n releaseReload(owner: AbortController) {\n if (this.pendingReload === owner) this.pendingReload = undefined;\n }\n async readStartupSettings(signal: AbortSignal) {\n this.validate();\n await settingsQueue;\n this.validate();\n signal.throwIfAborted();\n const document = await peekLocalConfigDocument();\n this.validate();\n signal.throwIfAborted();\n if (document && document.bytes.length > MAX_SETTINGS_BYTES)\n throw new Error(\"Settings exceed the local API byte limit; the source document is unchanged.\");\n return { document, settings: document && validateSettingsDocument(document.parsed) };\n }\n tryStartupBootstrap(document: LocalConfigDocument, debug: boolean, signal: AbortSignal) {\n const ownedSignal = AbortSignal.any([signal, this.signal]);\n let retirement: Promise<void> | undefined;\n const operation = this.work.then(async () => {\n const verify = (connection?: DaemonConnection) => {\n this.validateFactsScope(connection, ownedSignal);\n if (this.pendingReload) throw new Error(\"Pi Sync is paused for a session change.\");\n };\n verify();\n const connection = await this.connect(undefined, ownedSignal);\n return this.queueFacts(async () => {\n verify(connection);\n if (connection.contactState !== \"active\" || connection.contactResumeState !== \"idle\") return false;\n const settingsFingerprint = fingerprint(document);\n let mayHavePublished = true;\n try {\n const ready = await requestStartupBootstrap(connection, settingsFingerprint, debug, ownedSignal);\n mayHavePublished = ready;\n verify(connection);\n if (!ready) return false;\n if (connection.contactState === \"active\") this.confirmContact(connection);\n this.startupDebug = debug;\n this.initialized = true;\n Object.assign(connection.facts, { ready: true, startupDebug: debug });\n return true;\n } catch (error) {\n if (mayHavePublished) {\n retirement = this.dispose();\n void retirement.catch(() => {});\n }\n throw error;\n }\n });\n });\n this.work = operation.then(\n () => {},\n () => {},\n );\n return operation.catch(async (error: unknown) => {\n try {\n await retirement;\n } catch (cause) {\n throw new AggregateError(\n [error, cause],\n \"Startup readiness is uncertain; reconcile the daemon before reconnecting.\",\n );\n }\n throw error;\n });\n }\n async markReady(debug: boolean) {\n this.validate();\n this.startupDebug = debug;\n this.setDebugPreference(debug);\n this.initialized = true;\n await this.update();\n this.validate();\n }\n async setBusy(reason: string, busy: boolean, publish = true) {\n this.validate();\n if (busy) this.busy.add(reason);\n else if (this.busy.delete(reason) && reason === \"command\") {\n // Local command completion does not depend on publishing idle facts.\n this.releaseUI.flushWarnings();\n }\n if (publish) await this.update();\n this.validate();\n }\n async update() {\n if (this.connection && !this.recoveringDirectionalOwner && !this.paused && !this.disposed && !this.signal.aborted)\n await this.publishFacts(this.connection);\n }\n private async pagedMergeReview(\n connection: DaemonConnection,\n callback: Callback,\n loadDetails: (signal?: AbortSignal) => Promise<string>,\n signal: AbortSignal,\n ) {\n const ctx = this.uiContext;\n const generation = this.generation;\n const combined = AbortSignal.any([signal, this.signal]);\n const isCurrent = () =>\n !combined.aborted &&\n this.ownsContactUI() &&\n this.uiContext === ctx &&\n this.generation === generation &&\n (this.connection ?? this.partialConnection) === connection;\n if (!isCurrent()) return false;\n this.validate();\n if (!ctx.hasUI || ![\"tui\", \"rpc\"].includes(ctx.mode)) throw new Error(\"This client cannot present safety reviews.\");\n const { title, confirmationLabel, summaryLines } = callback.payload as {\n title: string;\n confirmationLabel?: string;\n summaryLines: readonly string[];\n };\n const { confirmMergeReview } = await import(\"../ui/merge-review.js\");\n if (!isCurrent()) return false;\n this.validate();\n const result = await confirmMergeReview(\n ctx,\n title,\n loadDetails,\n combined,\n isCurrent,\n confirmationLabel,\n summaryLines,\n );\n if (!isCurrent()) return false;\n this.validate();\n return result;\n }\n private async callback(\n connection: DaemonConnection,\n callback: Callback,\n signal: AbortSignal,\n protectionOnly: boolean,\n ) {\n const payload = callback.payload as {\n reservation?: string;\n targets?: string[];\n generation?: string;\n title?: string;\n message?: string;\n content?: string;\n confirmationLabel?: string;\n summaryLines?: string[];\n items?: string[];\n helpText?: string;\n background?: boolean;\n fingerprint?: string;\n adoptionRecovery?: number;\n };\n if (callback.kind === \"queue-release\") {\n if (typeof payload?.reservation !== \"string\") throw new Error(\"Invalid queue release.\");\n await this.gate.releaseRequest(payload.reservation);\n return true;\n }\n this.validate();\n signal.throwIfAborted();\n if (this.paused) throw new Error(\"Pi session is changing; no new work is authorized.\");\n if (callback.kind === \"directional-checkpoint\") {\n this.validateFactsScope(connection, this.runSignal);\n if (protectionOnly || this.directionalCheckpoint?.accept(connection, callback.job, payload?.fingerprint) !== true)\n return false;\n return payload.adoptionRecovery === 1 ? { adoptionRecovery: 1 } : true;\n }\n if (callback.kind === \"queue-acquire\") {\n if (this.pendingReload) throw new Error(\"Pi resources are about to reload.\");\n if (payload.background && !this.facts().idle) throw new Error(\"Pi is busy; background apply was not granted.\");\n if (\n payload.generation !== this.generation ||\n typeof payload.reservation !== \"string\" ||\n !Array.isArray(payload.targets)\n )\n throw new Error(\"Stale file-queue request.\");\n return this.gate.acquire(payload.reservation, payload.targets, AbortSignal.any([signal, this.signal]));\n }\n const ctx = this.uiContext;\n const combined = AbortSignal.any([signal, this.signal]);\n if (callback.kind === \"model-binding\") {\n if (protectionOnly) return null;\n return this.queueFactsWithAbortableWait(combined, async () => {\n this.validateFactsScope(connection, combined);\n let facts = this.facts();\n if (JSON.stringify(connection.facts.model) !== JSON.stringify(facts.model)) {\n await connection.update(facts);\n this.validateFactsScope(connection, combined);\n facts = this.facts();\n }\n return (payload.background && !facts.idle) ||\n JSON.stringify(connection.facts.model) !== JSON.stringify(facts.model)\n ? null\n : (facts.model ?? null);\n });\n }\n if (callback.kind === \"reload\") {\n if (!this.reloadRequest) throw new Error(\"No active Pi command can reload resources.\");\n this.reloadRequest.received = true;\n return true;\n }\n if (!ctx.hasUI || ![\"tui\", \"rpc\"].includes(ctx.mode)) throw new Error(\"This client cannot present safety reviews.\");\n let result: unknown;\n if (callback.kind === \"merge-review\" && typeof payload.title === \"string\" && typeof payload.content === \"string\") {\n const { confirmMergeReview } = await import(\"../ui/merge-review.js\");\n this.validate();\n combined.throwIfAborted();\n result = await confirmMergeReview(\n ctx,\n payload.title,\n payload.content,\n combined,\n () => !combined.aborted && !this.disposed,\n payload.confirmationLabel,\n payload.summaryLines,\n );\n } else if (\n callback.kind === \"confirm\" &&\n typeof payload.title === \"string\" &&\n typeof payload.message === \"string\"\n ) {\n result = await ctx.ui.confirm(safeTerminalText(payload.title), safeTerminalText(payload.message), {\n signal: combined,\n });\n } else if (\n callback.kind === \"select\" &&\n typeof payload.title === \"string\" &&\n Array.isArray(payload.items) &&\n payload.items.every((item) => typeof item === \"string\")\n ) {\n const labels = payload.items.map(safeTerminalText);\n if (new Set(labels).size !== labels.length) throw new Error(\"Daemon choices have ambiguous terminal labels.\");\n const selected = await ctx.ui.select(safeTerminalText(payload.title), labels, { signal: combined });\n const index = selected === undefined ? -1 : labels.indexOf(selected);\n result = index < 0 ? undefined : payload.items[index];\n } else throw new Error(\"Unsupported daemon UI callback.\");\n this.validate();\n combined.throwIfAborted();\n return result;\n }\n disposeForShutdown(reason: string | undefined, targetFile?: string) {\n const facts = this.connection?.facts ?? this.partialConnection?.facts;\n return this.dispose({\n kind: [\"new\", \"resume\", \"fork\", \"reload\"].includes(reason ?? \"\") ? \"replace\" : \"exit\",\n ...(targetFile !== undefined\n ? { file: canonicalPath(targetFile) }\n : reason === \"reload\"\n ? { file: facts?.sessionFile, sessionId: facts?.sessionId }\n : {}),\n cwd: facts?.cwd,\n });\n }\n async dispose(handoff?: ClientHandoff) {\n if (this.disposing) return this.disposing;\n this.closing = true;\n this.signal.removeEventListener(\"abort\", this.stopReleaseUI);\n this.stopReleaseUI();\n this.stopContactRepair(false);\n this.disposing = (async () => {\n const connection = this.connection ?? this.partialConnection ?? (await this.connecting?.catch(() => undefined));\n let confirmed = false;\n try {\n await connection?.dispose(handoff);\n confirmed = Boolean(connection);\n } catch (error) {\n if (\n !connection ||\n connection.identity.root !== this.recoveredOwner?.root ||\n connection.identity.instance !== this.recoveredOwner.instance ||\n connection.identity.pid !== this.recoveredOwner.pid\n )\n throw error;\n } finally {\n this.disposed = true;\n if (clients.get(this.manager) === this) clients.delete(this.manager);\n const gate = this.gate;\n gate.detach();\n if (connection) {\n if (confirmed) await gate.releaseAfterDrain();\n else quarantineClient(gate, connection.paths.root, connection.identity, connection.facts);\n }\n await Promise.all([this.work, this.factsQueue]);\n }\n })();\n return this.disposing;\n }\n}\n", "import { randomUUID } from \"node:crypto\";\nimport path from \"node:path\";\nimport { withFileMutationQueue } from \"@earendil-works/pi-coding-agent\";\nimport { withTargetQueues } from \"@narumitw/pi-sync-daemon/engine/snapshot/snapshot-mutation-queues\";\n\ninterface Gate {\n token: string;\n paths: readonly string[];\n entered: Promise<string>;\n task: Promise<void>;\n granted: boolean;\n cancelled: boolean;\n reject(error: unknown): void;\n release(): void;\n}\n/**\n * Holds the running Pi's actual public file queues; it does not authorize filesystem writes.\n * The engine owns reviewed destinations, which can differ from every participant's current roots.\n */\nexport class PiApplyGate {\n private gates = new Map<string, Gate>();\n constructor(private validate: () => void) {}\n async acquire(requestId: string, targets: readonly string[], signal?: AbortSignal) {\n this.validate();\n signal?.throwIfAborted();\n if (\n !targets.length ||\n targets.length > 16_384 ||\n targets.some((target) => typeof target !== \"string\" || target.includes(\"\\0\") || !path.isAbsolute(target))\n )\n throw new Error(\"Invalid daemon mutation targets.\");\n const normalized = [...new Set(targets.map((target) => path.resolve(target)))].sort();\n const existing = this.gates.get(requestId);\n if (existing) {\n if (JSON.stringify(existing.paths) !== JSON.stringify(normalized)) throw new Error(\"File-queue request changed.\");\n return existing.entered;\n }\n const token = randomUUID();\n let entered!: (token: string) => void;\n let rejected!: (error: unknown) => void;\n const ready = new Promise<string>((resolve, reject) => {\n entered = resolve;\n rejected = reject;\n });\n let release!: () => void;\n const held = new Promise<void>((resolve) => {\n release = resolve;\n });\n const gate: Gate = {\n token,\n paths: normalized,\n entered: ready,\n task: Promise.resolve(),\n release,\n reject: rejected,\n granted: false,\n cancelled: false,\n };\n this.gates.set(requestId, gate);\n const validate = () => {\n if (gate.cancelled) throw new DOMException(\"File-queue reservation was cancelled\", \"AbortError\");\n this.validate();\n };\n gate.task = withTargetQueues(\n normalized,\n { signal, validateMutation: validate },\n async () => {\n validate();\n signal?.throwIfAborted();\n gate.granted = true;\n entered(token);\n // Prompt cancellation cannot revoke a grant while a remote writer may still run.\n await held;\n },\n { mutate: withFileMutationQueue },\n )\n .catch((error) => {\n rejected(error);\n })\n .finally(() => {\n if (this.gates.get(requestId) === gate) this.gates.delete(requestId);\n });\n const abort = () => {\n if (!gate.granted) {\n gate.cancelled = true;\n rejected(signal?.reason);\n release();\n }\n };\n signal?.addEventListener(\"abort\", abort, { once: true });\n void gate.task.finally(() => signal?.removeEventListener(\"abort\", abort));\n return ready;\n }\n async release(token: string) {\n const gate = [...this.gates.values()].find((value) => value.token === token);\n if (!gate) throw new Error(\"Unknown file-queue grant.\");\n await this.releaseGate(gate);\n }\n private async releaseGate(gate: Gate) {\n if (!gate.granted) {\n gate.cancelled = true;\n gate.reject(new DOMException(\"File-queue reservation was released\", \"AbortError\"));\n }\n gate.release();\n // A queued, ungranted placeholder cannot write after cancellation and need not\n // wait for another Pi tool to finish before acknowledgement.\n if (gate.granted) await gate.task;\n }\n async releaseRequest(requestId: string) {\n const gate = this.gates.get(requestId);\n if (!gate) return;\n await this.releaseGate(gate);\n }\n detach() {\n const failure = new DOMException(\"Pi session detached\", \"AbortError\");\n this.validate = () => {\n throw failure;\n };\n this.cancelPending(failure);\n }\n cancelPending(failure: unknown = new DOMException(\"Pi session changing\", \"AbortError\")) {\n for (const gate of this.gates.values())\n if (!gate.granted) {\n gate.cancelled = true;\n gate.reject(failure);\n gate.release();\n }\n }\n get size() {\n return [...this.gates.values()].filter((gate) => gate.granted || !gate.cancelled).length;\n }\n /** Release only after establishing that the associated service cannot still write. */\n async releaseAfterOwnerExit(pid: number) {\n try {\n process.kill(pid, 0);\n throw new Error(\"Daemon owner is still alive; grants remain held.\");\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ESRCH\") throw error;\n }\n await this.releaseAfterDrain();\n }\n /** Caller must first receive an authenticated same-owner detach/drain acknowledgement. */\n async releaseAfterDrain() {\n await Promise.all([...this.gates.values()].map((gate) => this.releaseGate(gate)));\n }\n}\n", "import { type DebugEvent, debugJobResult, debugOperation } from \"@narumitw/pi-sync-daemon/engine/debug-log\";\n\nexport function observeDebugJob(operation: string, append: (event: DebugEvent) => void) {\n const kind = debugOperation(operation);\n if (!kind) return undefined;\n let operationId: string | undefined;\n const record = (outcome: Extract<DebugEvent, { event: \"job\" }>[\"outcome\"]) =>\n append({ event: \"job\", operation: kind, outcome, ...(operationId ? { operationId } : {}) });\n return {\n onSubmit(id: string) {\n if (operationId && operationId !== id) record(\"blocked\");\n operationId = id;\n record(\"started\");\n },\n returned(result: unknown, interrupted = false) {\n const outcome = debugJobResult(kind, result);\n if (interrupted && outcome !== \"completed\") record(\"cancelled\");\n else if (outcome) record(outcome);\n else if (\n result === \"archived\" ||\n (kind === \"initialize\" &&\n typeof result === \"object\" &&\n result !== null &&\n \"handoverRequired\" in result &&\n result.handoverRequired === true)\n )\n record(\"blocked\");\n else if (\n kind === \"migrate-state\" &&\n typeof result === \"object\" &&\n result !== null &&\n \"status\" in result &&\n result.status === \"cancelled\"\n )\n record(\"cancelled\");\n else record(\"completed\");\n },\n rejected(error: unknown, cancelled: boolean) {\n if (cancelled || (error instanceof Error && error.name === \"AbortError\")) record(\"cancelled\");\n else if (\n error instanceof Error &&\n (error.name === \"SyncDecisionRequiredError\" || error.name === \"RemoteSelectionMismatchError\")\n )\n record(\"blocked\");\n else record(\"failed\");\n },\n };\n}\n", "import type { DaemonConnection } from \"@narumitw/pi-sync-daemon\";\nimport { errorMessage } from \"../sync/sync-errors.js\";\n\nexport function isForegroundDirection(operation: string) {\n return operation === \"push.foreground\" || operation === \"pull.foreground\";\n}\n\nexport class DirectionalCheckpoint {\n job?: string;\n fingerprint?: string;\n\n constructor(\n readonly connection: DaemonConnection,\n private readonly expected?: string,\n ) {}\n\n accept(connection: DaemonConnection, job: string, fingerprint: unknown) {\n if (\n connection !== this.connection ||\n this.job !== job ||\n typeof fingerprint !== \"string\" ||\n !/^[a-f0-9]{64}$/u.test(fingerprint) ||\n (this.expected !== undefined && fingerprint !== this.expected) ||\n (this.fingerprint !== undefined && fingerprint !== this.fingerprint)\n )\n return false;\n this.fingerprint = fingerprint;\n return true;\n }\n}\n\nfunction recoveryOutcome(value: unknown) {\n if (!value || typeof value !== \"object\" || !(\"foregroundQueueCleanup\" in value)) return;\n if (value.foregroundQueueCleanup === \"before-mutation\") return { phase: \"unchanged\" as const };\n if (value.foregroundQueueCleanup === \"resume-adoption\") {\n if (!(\"journal\" in value) || typeof value.journal !== \"string\" || !/^[a-f0-9]{64}$/u.test(value.journal))\n throw new Error(\"The recorded Pull could not be verified. Use /sync daemon recover.\");\n return { phase: \"adoption\" as const, journal: value.journal };\n }\n if (value.foregroundQueueCleanup === \"verified-result\" && \"result\" in value)\n return { phase: \"completed\" as const, result: value.result };\n}\n\nfunction restoreMessage(value: unknown): string {\n return value && typeof value === \"object\" && \"message\" in value && typeof value.message === \"string\"\n ? ` ${value.message}`\n : \"\";\n}\n\nexport class CompletedDirectionalRecoveryError extends Error {}\n\nfunction cancelledAfterCompletion(result: unknown, cause: unknown) {\n const error = new CompletedDirectionalRecoveryError(\n `The transfer finished, but file-queue recovery was cancelled.${restoreMessage(result)}`,\n { cause },\n );\n error.name = \"AbortError\";\n return error;\n}\n\nexport interface PendingAdoptionRecovery {\n owner: DaemonConnection;\n job: string;\n journal: string;\n}\n\nexport async function runDirectionalRecovery(\n connection: DaemonConnection,\n signal: AbortSignal,\n run: (checkpoint: DirectionalCheckpoint, retryCheckpoint?: string, retryAdoptionJournal?: string) => Promise<unknown>,\n recover: (connection: DaemonConnection, job: string, signal: AbortSignal) => Promise<DaemonConnection>,\n markCleanupRequired: () => void,\n adoption?: { pending?: PendingAdoptionRecovery; retain(value: PendingAdoptionRecovery | undefined): void },\n) {\n signal.throwIfAborted();\n const pending = adoption?.pending;\n if (pending && pending.owner !== connection) throw new Error(\"The daemon changed before Pull recovery.\");\n const attempt = new DirectionalCheckpoint(connection);\n attempt.job = pending?.job;\n const result = pending ? { foregroundQueueCleanup: \"resume-adoption\", journal: pending.journal } : await run(attempt);\n const primary = recoveryOutcome(result);\n if (!primary) return result;\n markCleanupRequired();\n let replacement: DaemonConnection;\n const bounded = AbortSignal.any([signal, AbortSignal.timeout(45_000)]);\n try {\n bounded.throwIfAborted();\n if (\n !attempt.job ||\n (primary.phase === \"unchanged\" && !attempt.fingerprint) ||\n (primary.phase === \"adoption\" && (!adoption || (!pending && !attempt.fingerprint)))\n )\n throw new Error(\"The original transfer scope could not be verified.\");\n if (primary.phase === \"adoption\")\n adoption?.retain({ owner: connection, job: attempt.job, journal: primary.journal });\n replacement = await recover(connection, attempt.job, bounded);\n if (primary.phase === \"adoption\") adoption?.retain(undefined);\n bounded.throwIfAborted();\n } catch (error) {\n if (signal.aborted) {\n if (primary.phase === \"completed\") throw cancelledAfterCompletion(primary.result, signal.reason);\n throw signal.reason;\n }\n const detail = bounded.aborted ? \"The daemon did not recover in time.\" : errorMessage(error);\n if (primary.phase === \"completed\")\n throw new CompletedDirectionalRecoveryError(\n `The transfer finished, but file-queue recovery stopped. ${detail}${restoreMessage(primary.result)}`,\n { cause: error },\n );\n if (primary.phase === \"adoption\")\n throw new Error(`Pull recovery stopped. The adoption journal was kept. ${detail}`, { cause: error });\n throw new Error(`No transfer was applied, but file-queue recovery stopped. ${detail}`, { cause: error });\n }\n if (primary.phase === \"completed\") return primary.result;\n const retryCheckpoint = primary.phase === \"unchanged\" ? attempt.fingerprint : undefined;\n const retry = new DirectionalCheckpoint(replacement, retryCheckpoint);\n const retried = await run(retry, retryCheckpoint, primary.phase === \"adoption\" ? primary.journal : undefined);\n const remaining = recoveryOutcome(retried);\n if (!remaining) return retried;\n markCleanupRequired();\n if (remaining.phase === \"completed\") {\n if (signal.aborted) throw cancelledAfterCompletion(remaining.result, signal.reason);\n throw new CompletedDirectionalRecoveryError(\n `Transfer finished, but file-queue cleanup is still uncertain after one recovery attempt.${restoreMessage(remaining.result)}`,\n );\n }\n if (remaining.phase === \"adoption\") {\n if (retry.job && retry.fingerprint)\n adoption?.retain({ owner: replacement, job: retry.job, journal: remaining.journal });\n throw new Error(\"File-queue cleanup is still uncertain after one recovery attempt. The adoption journal was kept.\");\n }\n throw new Error(\"File-queue release could not be verified after one recovery attempt. No transfer was applied.\");\n}\n", "import type { ConnectionOptions } from \"@narumitw/pi-sync-daemon\";\n\nexport type QueueReleaseEvent = Parameters<NonNullable<ConnectionOptions[\"queueRelease\"]>>[0];\ntype ClearStatus = (redraw?: boolean) => void;\n\n/** Session-owned presentation only; it neither controls delivery nor infers a job's outcome. */\nexport function createQueueReleaseUI(show: () => ClearStatus | undefined, warn: () => void) {\n const retries = new Map<string, { job: string; foreground: boolean }>();\n const handledJobs = new Set<string>();\n const deferredWarnings = new Set<string>();\n let timer: ReturnType<typeof setTimeout> | undefined;\n let clearStatus: ClearStatus | undefined;\n\n function remember(job: string) {\n deferredWarnings.delete(job);\n if (handledJobs.has(job)) return false;\n if (handledJobs.size >= 128) {\n const oldest = handledJobs.values().next();\n if (!oldest.done) handledJobs.delete(oldest.value);\n }\n handledJobs.add(job);\n return true;\n }\n function clearPresentation(redraw: boolean) {\n clearTimeout(timer);\n timer = undefined;\n const release = clearStatus;\n clearStatus = undefined;\n release?.(redraw);\n }\n\n return {\n get retrying() {\n return retries.size > 0;\n },\n observe({ id, job, state, foreground }: QueueReleaseEvent, commandBusy: boolean, cancelled: boolean) {\n if (state === \"retrying\") {\n if (foreground && cancelled) {\n remember(job);\n return;\n }\n if (retries.has(id)) return;\n retries.set(id, { job, foreground });\n if (retries.size !== 1) return;\n timer = setTimeout(() => {\n timer = undefined;\n const release = show();\n if (retries.size) clearStatus = release;\n else release?.(false); // Presentation may have synchronously reentered lifecycle cleanup.\n }, 2_000);\n timer.unref?.();\n return;\n }\n const retry = retries.get(id);\n retries.delete(id);\n if (!retries.size) clearPresentation(true);\n if (state !== \"unconfirmed\") return;\n const background = !foreground && !retry?.foreground;\n if (background && commandBusy) {\n if (!handledJobs.has(job)) deferredWarnings.add(job);\n } else if (remember(job) && background) warn();\n },\n flushWarnings() {\n if (!deferredWarnings.size) return;\n // One warning covers the background releases deferred by this command.\n for (const job of deferredWarnings) remember(job);\n try {\n warn();\n } catch {\n // Presentation must not interrupt publication of the new idle state.\n }\n },\n finishForeground(redraw: boolean) {\n for (const [id, { job, foreground }] of retries) {\n if (!foreground) continue;\n retries.delete(id);\n remember(job); // Late observations of this job should not duplicate its command result.\n }\n if (!retries.size) clearPresentation(redraw);\n },\n clear(redraw: boolean) {\n retries.clear();\n handledJobs.clear();\n deferredWarnings.clear();\n clearPresentation(redraw);\n },\n };\n}\n", "import { type ClientFacts, DaemonConnection, findDaemon, type Identity } from \"@narumitw/pi-sync-daemon\";\nimport type { PiApplyGate } from \"./apply-gate.js\";\n\ntype Address = { paths: DaemonConnection[\"paths\"]; identity: Identity };\ninterface Recovery {\n gate: PiApplyGate;\n root: string;\n identity: Identity;\n facts: ClientFacts;\n timer?: ReturnType<typeof setInterval>;\n attempt?: Promise<boolean>;\n}\nconst recoveries = new Set<Recovery>();\nfunction alive(pid: number) {\n try {\n process.kill(pid, 0);\n return true;\n } catch (error) {\n return (error as NodeJS.ErrnoException).code !== \"ESRCH\";\n }\n}\nfunction finish(record: Recovery) {\n if (record.timer) clearInterval(record.timer);\n recoveries.delete(record);\n}\nfunction attempt(record: Recovery, known?: Address): Promise<boolean> {\n record.attempt ??= (async () => {\n const exited = !alive(record.identity.pid);\n if (exited) await record.gate.releaseAfterOwnerExit(record.identity.pid);\n const address = known ?? (await findDaemon(record.root));\n if (!address || (!exited && address.identity.instance !== record.identity.instance)) return false;\n // Only plain closed-session facts and detached grants cross this recovery boundary.\n // Reclaim the obsolete participant on a compatible owner, reject all new work,\n // and service release callbacks until an authenticated detach confirms drain.\n const connection = new DaemonConnection(\n address.paths,\n address.identity,\n {\n ...record.facts,\n hasUI: false,\n idle: false,\n ready: false,\n },\n {\n callback: async (callback) => {\n const data = callback.payload;\n if (\n callback.kind === \"queue-release\" &&\n data !== null &&\n typeof data === \"object\" &&\n \"reservation\" in data &&\n typeof data.reservation === \"string\"\n ) {\n await record.gate.releaseRequest(data.reservation);\n return true;\n }\n throw new Error(\"Closed Pi participant cannot authorize new work.\");\n },\n },\n );\n try {\n // Cleanup polling does not attach or recreate a retired participant.\n await connection.dispose();\n await record.gate.releaseAfterDrain();\n finish(record);\n return true;\n } finally {\n await connection.dispose();\n }\n })()\n .catch(() => false)\n .finally(() => {\n record.attempt = undefined;\n });\n return record.attempt;\n}\n\n/** Intentionally shared cleanup may outlive a session, but never retains its ctx or UI. */\nexport function quarantineClient(gate: PiApplyGate, root: string, identity: Identity, facts: ClientFacts) {\n gate.detach();\n const record: Recovery = { gate, root, identity: structuredClone(identity), facts: structuredClone(facts) };\n recoveries.add(record);\n record.timer = setInterval(() => {\n void attempt(record);\n }, 1000);\n record.timer.unref();\n void attempt(record);\n}\n\n/** A newly attached client stays unready until obsolete local participants are retired. */\nexport async function recoverDetachedClients(address: Address) {\n const pending = [...recoveries].filter((record) => record.root === address.paths.root);\n const results = await Promise.all(\n pending.map(async (record) => {\n const done = await attempt(record, address);\n return done || !recoveries.has(record) || (await attempt(record, address));\n }),\n );\n if (results.some((done) => !done))\n throw new Error(\n \"Previous Pi cleanup is still uncertain; stop or repair the existing daemon before retrying /reload.\",\n );\n}\n", "import { type DaemonConnection, DaemonError, requestDaemon } from \"@narumitw/pi-sync-daemon\";\n\nexport async function requestStartupBootstrap(\n connection: DaemonConnection,\n fingerprint: string | null,\n debug: boolean,\n signal: AbortSignal,\n): Promise<boolean> {\n let result: unknown;\n try {\n const { id: client, generation } = connection.facts;\n result = await requestDaemon(\n connection.paths,\n connection.identity,\n \"startup.bootstrap\",\n { client, generation, fingerprint, debug },\n signal,\n );\n } catch (error) {\n if (error instanceof DaemonError && error.name === \"Error\" && error.message === \"Unknown daemon method.\")\n return false;\n throw error;\n }\n if (typeof result !== \"boolean\") throw new Error(\"Invalid startup bootstrap response.\");\n return result;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA,SAAS,yBAAyB;AAClC,SAAS,cAAAA,mBAAkB;AAC3B,SAAS,WAAW,oBAAoB;AACxC,OAAO,QAAQ;AACf,OAAOC,WAAU;AACjB,SAAgC,mBAAmB;AACnD;AAAA,EAKE,oBAAAC;AAAA,EACA,eAAAC;AAAA,EAGA;AAAA,EACA;AAAA,EACA,cAAAC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,S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e;AAEhD,gBAAM;AAAA,MACV,UAAE;AACA,aAAK,WAAW;AAChB,YAAI,QAAQ,IAAI,KAAK,OAAO,MAAM,KAAM,SAAQ,OAAO,KAAK,OAAO;AACnE,cAAM,OAAO,KAAK;AAClB,aAAK,OAAO;AACZ,YAAI,YAAY;AACd,cAAI,UAAW,OAAM,KAAK,kBAAkB;AAAA,cACvC,kBAAiB,MAAM,WAAW,MAAM,MAAM,WAAW,UAAU,WAAW,KAAK;AAAA,QAC1F;AACA,cAAM,QAAQ,IAAI,CAAC,KAAK,MAAM,KAAK,UAAU,CAAC;AAAA,MAChD;AAAA,IACF,GAAG;AACH,WAAO,KAAK;AAAA,EACd;AACF;",
|
|
6
|
+
"names": ["randomUUID", "path", "DaemonConnection", "DaemonError", "findDaemon", "fingerprint", "attempt", "fingerprint", "path", "DaemonError", "randomUUID", "findDaemon", "connection", "DaemonConnection", "attempt", "current"]
|
|
7
|
+
}
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
} from "./chunk-ECYCNZOE.ts";
|
|
6
6
|
import {
|
|
7
7
|
ignoreFileSettingsAvailable
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-I72HGZJJ.ts";
|
|
9
9
|
import {
|
|
10
10
|
effectiveSyncSetupRemoteIdentity,
|
|
11
11
|
normalizeS3Bucket,
|
|
@@ -318,7 +318,7 @@ async function finishSetup(ctx, name, message, join, signal) {
|
|
|
318
318
|
if (signal?.aborted) return;
|
|
319
319
|
ctx.ui.notify(message, "info");
|
|
320
320
|
if (!join) return;
|
|
321
|
-
const { showRemoteSelectionReview } = await import("./remote-selection-ui-
|
|
321
|
+
const { showRemoteSelectionReview } = await import("./remote-selection-ui-34WC7OFE.ts");
|
|
322
322
|
if (signal?.aborted) return;
|
|
323
323
|
await showRemoteSelectionReview(ctx, name, signal, void 0, {
|
|
324
324
|
origin: "settings",
|
|
@@ -1069,4 +1069,4 @@ export {
|
|
|
1069
1069
|
showAddWebDavStorageProfile,
|
|
1070
1070
|
showEditWebDavStorageProfile
|
|
1071
1071
|
};
|
|
1072
|
-
//# sourceMappingURL=chunk-
|
|
1072
|
+
//# sourceMappingURL=chunk-GRXNUC6O.ts.map
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
} from "./chunk-KNEUL4XN.ts";
|
|
6
6
|
import {
|
|
7
7
|
piDaemonClient
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-C3E75DXW.ts";
|
|
9
9
|
import {
|
|
10
10
|
runCancellableTask
|
|
11
11
|
} from "./chunk-PUSMSKIM.ts";
|
|
@@ -103,4 +103,4 @@ export {
|
|
|
103
103
|
portableIgnoreRulesAvailable,
|
|
104
104
|
showIgnoreFileAction
|
|
105
105
|
};
|
|
106
|
-
//# sourceMappingURL=chunk-
|
|
106
|
+
//# sourceMappingURL=chunk-I72HGZJJ.ts.map
|
|
@@ -160,7 +160,7 @@ async function showRemoteSelectionReview(ctx, setupName, signal, factory = creat
|
|
|
160
160
|
async function showSelectionDifference(ctx, initialDecision, origin, runRoute, sessionSignal, factory, options, validateOwner) {
|
|
161
161
|
const isCurrent = () => isReviewOwnerCurrent(validateOwner);
|
|
162
162
|
const canReviewPull = Boolean(
|
|
163
|
-
runRoute && !options.readOnly && initialDecision.ignorePolicyComparison === "mismatch" && await (await import("./ignore-file-ui-
|
|
163
|
+
runRoute && !options.readOnly && initialDecision.ignorePolicyComparison === "mismatch" && await (await import("./ignore-file-ui-5BWA6LBC.ts")).portableIgnoreRulesAvailable(ctx, sessionSignal)
|
|
164
164
|
);
|
|
165
165
|
if (!isCurrent()) return { kind: "stale" };
|
|
166
166
|
let flowState = { decision: initialDecision, saved: false };
|
|
@@ -768,4 +768,4 @@ function combineSignals(sessionSignal, actionSignal) {
|
|
|
768
768
|
export {
|
|
769
769
|
showRemoteSelectionReview
|
|
770
770
|
};
|
|
771
|
-
//# sourceMappingURL=chunk-
|
|
771
|
+
//# sourceMappingURL=chunk-UF2HU2NM.ts.map
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
currentPiDaemonClient,
|
|
22
22
|
piDaemonClient,
|
|
23
23
|
remoteOperation
|
|
24
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-C3E75DXW.ts";
|
|
25
25
|
import {
|
|
26
26
|
combineSignals,
|
|
27
27
|
throwIfAborted
|
|
@@ -214,7 +214,7 @@ ${guidance}`,
|
|
|
214
214
|
return { kind: "completed" };
|
|
215
215
|
}
|
|
216
216
|
case "conflicts": {
|
|
217
|
-
const { showConflicts } = await import("./conflict-review-
|
|
217
|
+
const { showConflicts } = await import("./conflict-review-OBBBSVQD.ts");
|
|
218
218
|
throwIfAborted(options.signal);
|
|
219
219
|
await showConflicts(ctx, options);
|
|
220
220
|
return { kind: "completed" };
|
|
@@ -325,7 +325,7 @@ async function initConfig(ctx, signal) {
|
|
|
325
325
|
return;
|
|
326
326
|
}
|
|
327
327
|
if (ctx.mode === "tui") {
|
|
328
|
-
const { showSetupWizard } = await import("./setup-wizard-
|
|
328
|
+
const { showSetupWizard } = await import("./setup-wizard-YOXLXLBY.ts");
|
|
329
329
|
throwIfAborted(signal);
|
|
330
330
|
await showSetupWizard(ctx, signal);
|
|
331
331
|
return;
|
|
@@ -457,7 +457,7 @@ async function handleCommand(rawArgs, ctx, sessionSignal, loaders, attention, on
|
|
|
457
457
|
if (!rawArgs.trim()) {
|
|
458
458
|
attention.expand();
|
|
459
459
|
try {
|
|
460
|
-
const { showSyncManager } = await import("./manager-ui-
|
|
460
|
+
const { showSyncManager } = await import("./manager-ui-Z3B5ZTA6.ts");
|
|
461
461
|
if (sessionSignal.aborted) return;
|
|
462
462
|
await showSyncManager(ctx, run, sessionSignal, {
|
|
463
463
|
needsDaemonRecovery,
|
|
@@ -561,7 +561,7 @@ function directSelectionOrigin(rawArgs) {
|
|
|
561
561
|
async function resolveSelectionAttention(ctx, attention, signal, loaders, options = {}) {
|
|
562
562
|
const current = attention.current();
|
|
563
563
|
if (!current || signal.aborted) return;
|
|
564
|
-
const { dispatchManagerResult } = await import("./manager-result-dispatcher-
|
|
564
|
+
const { dispatchManagerResult } = await import("./manager-result-dispatcher-MJ6G2CEI.ts");
|
|
565
565
|
if (signal.aborted || attention.current() !== current) return;
|
|
566
566
|
await dispatchManagerResult(
|
|
567
567
|
ctx,
|
|
@@ -592,4 +592,4 @@ export {
|
|
|
592
592
|
handleCommand,
|
|
593
593
|
resolveSelectionAttention
|
|
594
594
|
};
|
|
595
|
-
//# sourceMappingURL=command-handler-
|
|
595
|
+
//# sourceMappingURL=command-handler-HWRPH3K3.ts.map
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
|
|
3
3
|
import {
|
|
4
4
|
remoteOperation
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-C3E75DXW.ts";
|
|
6
6
|
import "./chunk-H7VOTY5N.ts";
|
|
7
7
|
import "./chunk-6YKOHBSC.ts";
|
|
8
8
|
import "./chunk-R3SAMXB6.ts";
|
|
@@ -15,4 +15,4 @@ async function showConflicts(ctx, options) {
|
|
|
15
15
|
export {
|
|
16
16
|
showConflicts
|
|
17
17
|
};
|
|
18
|
-
//# sourceMappingURL=conflict-review-
|
|
18
|
+
//# sourceMappingURL=conflict-review-OBBBSVQD.ts.map
|
|
@@ -4,9 +4,9 @@ import {
|
|
|
4
4
|
ignoreFileSettingsAvailable,
|
|
5
5
|
portableIgnoreRulesAvailable,
|
|
6
6
|
showIgnoreFileAction
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-I72HGZJJ.ts";
|
|
8
8
|
import "./chunk-KNEUL4XN.ts";
|
|
9
|
-
import "./chunk-
|
|
9
|
+
import "./chunk-C3E75DXW.ts";
|
|
10
10
|
import "./chunk-H7VOTY5N.ts";
|
|
11
11
|
import "./chunk-PUSMSKIM.ts";
|
|
12
12
|
import "./chunk-6YKOHBSC.ts";
|
|
@@ -18,4 +18,4 @@ export {
|
|
|
18
18
|
portableIgnoreRulesAvailable,
|
|
19
19
|
showIgnoreFileAction
|
|
20
20
|
};
|
|
21
|
-
//# sourceMappingURL=ignore-file-ui-
|
|
21
|
+
//# sourceMappingURL=ignore-file-ui-5BWA6LBC.ts.map
|
package/dist/chunks/{manager-result-dispatcher-PEVIGLOS.ts → manager-result-dispatcher-MJ6G2CEI.ts}
RENAMED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
|
|
3
3
|
import {
|
|
4
4
|
dispatchManagerResult
|
|
5
|
-
} from "./chunk-
|
|
6
|
-
import "./chunk-
|
|
5
|
+
} from "./chunk-2MSJDLSM.ts";
|
|
6
|
+
import "./chunk-UF2HU2NM.ts";
|
|
7
7
|
import "./chunk-UMPA5S7X.ts";
|
|
8
8
|
import "./chunk-H7VOTY5N.ts";
|
|
9
9
|
import "./chunk-PUSMSKIM.ts";
|
|
@@ -17,4 +17,4 @@ import "./chunk-2JNFEZ3V.ts";
|
|
|
17
17
|
export {
|
|
18
18
|
dispatchManagerResult
|
|
19
19
|
};
|
|
20
|
-
//# sourceMappingURL=manager-result-dispatcher-
|
|
20
|
+
//# sourceMappingURL=manager-result-dispatcher-MJ6G2CEI.ts.map
|
|
@@ -18,19 +18,19 @@ import {
|
|
|
18
18
|
showEditS3Target,
|
|
19
19
|
showEditWebDavStorageProfile,
|
|
20
20
|
showEditWebDavTarget
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-GRXNUC6O.ts";
|
|
22
22
|
import {
|
|
23
23
|
automaticSyncSummary
|
|
24
24
|
} from "./chunk-ECYCNZOE.ts";
|
|
25
25
|
import {
|
|
26
26
|
ignoreFileSettingsAvailable,
|
|
27
27
|
showIgnoreFileAction
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-I72HGZJJ.ts";
|
|
29
29
|
import "./chunk-KNEUL4XN.ts";
|
|
30
30
|
import {
|
|
31
31
|
dispatchManagerResult
|
|
32
|
-
} from "./chunk-
|
|
33
|
-
import "./chunk-
|
|
32
|
+
} from "./chunk-2MSJDLSM.ts";
|
|
33
|
+
import "./chunk-UF2HU2NM.ts";
|
|
34
34
|
import {
|
|
35
35
|
SETUP_SWITCH_ACTION_OPTIONS,
|
|
36
36
|
saveOnSwitch,
|
|
@@ -62,7 +62,7 @@ import {
|
|
|
62
62
|
} from "./chunk-3Q3DMMID.ts";
|
|
63
63
|
import {
|
|
64
64
|
piDaemonClient
|
|
65
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-C3E75DXW.ts";
|
|
66
66
|
import {
|
|
67
67
|
throwIfAborted
|
|
68
68
|
} from "./chunk-UMPA5S7X.ts";
|
|
@@ -224,7 +224,7 @@ function blockedSyncMenuItem(label, manager) {
|
|
|
224
224
|
};
|
|
225
225
|
}
|
|
226
226
|
async function showManagerAttention(ctx, attention, runRoute, signal, onSelectionResolved) {
|
|
227
|
-
const { showRemoteSelectionReview } = await import("./remote-selection-ui-
|
|
227
|
+
const { showRemoteSelectionReview } = await import("./remote-selection-ui-34WC7OFE.ts");
|
|
228
228
|
if (signal?.aborted) return "close";
|
|
229
229
|
const review = await showRemoteSelectionReview(ctx, attention.decision.setupName, signal, void 0, {
|
|
230
230
|
decision: attention.decision,
|
|
@@ -2072,7 +2072,7 @@ async function showSyncSettings(ctx, runRoute, signal, reviewedSetup) {
|
|
|
2072
2072
|
"remote-include": async ({ state, signal: actionSignal }) => {
|
|
2073
2073
|
if (state.reservedIgnoreNames !== void 0 && !ignoreAvailable) return { kind: "rejected" };
|
|
2074
2074
|
const reviewSignal = signal ? AbortSignal.any([signal, actionSignal]) : actionSignal;
|
|
2075
|
-
const { showRemoteSelectionReview } = await import("./remote-selection-ui-
|
|
2075
|
+
const { showRemoteSelectionReview } = await import("./remote-selection-ui-34WC7OFE.ts");
|
|
2076
2076
|
if (reviewSignal.aborted) return { kind: "rejected" };
|
|
2077
2077
|
const review = await showRemoteSelectionReview(ctx, setupName, reviewSignal, void 0, {
|
|
2078
2078
|
origin: "settings",
|
|
@@ -2330,7 +2330,7 @@ async function showSyncManager(ctx, runRoute, sessionSignal, options = {}) {
|
|
|
2330
2330
|
if (!attention) {
|
|
2331
2331
|
const observation = state.manager.observation;
|
|
2332
2332
|
if (!observation) return { kind: "stay" };
|
|
2333
|
-
const { showRemoteSelectionReview } = await import("./remote-selection-ui-
|
|
2333
|
+
const { showRemoteSelectionReview } = await import("./remote-selection-ui-34WC7OFE.ts");
|
|
2334
2334
|
if (sessionSignal?.aborted) return { kind: "close" };
|
|
2335
2335
|
const config = await loadConfig();
|
|
2336
2336
|
if (sessionSignal?.aborted) return { kind: "close" };
|
|
@@ -2681,4 +2681,4 @@ function syncMainMenuItem(label) {
|
|
|
2681
2681
|
export {
|
|
2682
2682
|
showSyncManager
|
|
2683
2683
|
};
|
|
2684
|
-
//# sourceMappingURL=manager-ui-
|
|
2684
|
+
//# sourceMappingURL=manager-ui-Z3B5ZTA6.ts.map
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
|
|
3
3
|
import {
|
|
4
4
|
showRemoteSelectionReview
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-UF2HU2NM.ts";
|
|
6
6
|
import "./chunk-UMPA5S7X.ts";
|
|
7
7
|
import "./chunk-H7VOTY5N.ts";
|
|
8
8
|
import "./chunk-PUSMSKIM.ts";
|
|
@@ -16,4 +16,4 @@ import "./chunk-2JNFEZ3V.ts";
|
|
|
16
16
|
export {
|
|
17
17
|
showRemoteSelectionReview
|
|
18
18
|
};
|
|
19
|
-
//# sourceMappingURL=remote-selection-ui-
|
|
19
|
+
//# sourceMappingURL=remote-selection-ui-34WC7OFE.ts.map
|
|
@@ -5,15 +5,15 @@ import {
|
|
|
5
5
|
showGitSetup,
|
|
6
6
|
showS3Setup,
|
|
7
7
|
showWebDavSetup
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-GRXNUC6O.ts";
|
|
9
9
|
import "./chunk-ECYCNZOE.ts";
|
|
10
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-I72HGZJJ.ts";
|
|
11
11
|
import "./chunk-KNEUL4XN.ts";
|
|
12
12
|
import {
|
|
13
13
|
validateConfigName
|
|
14
14
|
} from "./chunk-APZVJAEW.ts";
|
|
15
15
|
import "./chunk-WBIOSK76.ts";
|
|
16
|
-
import "./chunk-
|
|
16
|
+
import "./chunk-C3E75DXW.ts";
|
|
17
17
|
import {
|
|
18
18
|
throwIfAborted
|
|
19
19
|
} from "./chunk-UMPA5S7X.ts";
|
|
@@ -95,4 +95,4 @@ async function showSetupWizard(ctx, signal) {
|
|
|
95
95
|
export {
|
|
96
96
|
showSetupWizard
|
|
97
97
|
};
|
|
98
|
-
//# sourceMappingURL=setup-wizard-
|
|
98
|
+
//# sourceMappingURL=setup-wizard-YOXLXLBY.ts.map
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
|
|
3
3
|
import {
|
|
4
4
|
currentPiDaemonClient
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-C3E75DXW.ts";
|
|
6
6
|
import "./chunk-H7VOTY5N.ts";
|
|
7
7
|
import "./chunk-6YKOHBSC.ts";
|
|
8
8
|
import "./chunk-R3SAMXB6.ts";
|
|
@@ -20,4 +20,4 @@ var inspectSync = async (config, _options, signal) => await currentPiDaemonClien
|
|
|
20
20
|
export {
|
|
21
21
|
inspectSync
|
|
22
22
|
};
|
|
23
|
-
//# sourceMappingURL=sync-inspection-
|
|
23
|
+
//# sourceMappingURL=sync-inspection-NIITROKS.ts.map
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
|
|
3
3
|
import {
|
|
4
4
|
remoteOperation
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-C3E75DXW.ts";
|
|
6
6
|
import "./chunk-H7VOTY5N.ts";
|
|
7
7
|
import "./chunk-6YKOHBSC.ts";
|
|
8
8
|
import "./chunk-R3SAMXB6.ts";
|
|
@@ -46,4 +46,4 @@ export {
|
|
|
46
46
|
status,
|
|
47
47
|
syncBoth
|
|
48
48
|
};
|
|
49
|
-
//# sourceMappingURL=sync-operations-
|
|
49
|
+
//# sourceMappingURL=sync-operations-FFI4ZZQL.ts.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { closeSync, constants, fstatSync, lstatSync, openSync, realpathSync, writeSync, } from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
+
import { isForegroundDirection, isForegroundQueueOutcome } from "../foreground-queue-outcome.js";
|
|
3
4
|
import { DEBUG_LOG_FILENAME } from "./paths.js";
|
|
4
5
|
import { isStartupTimingReport } from "./sync/startup-timings.js";
|
|
5
6
|
const OPERATIONS = [
|
|
@@ -11,6 +12,8 @@ const OPERATIONS = [
|
|
|
11
12
|
"history",
|
|
12
13
|
"push",
|
|
13
14
|
"pull",
|
|
15
|
+
"push.foreground",
|
|
16
|
+
"pull.foreground",
|
|
14
17
|
"sync",
|
|
15
18
|
"startup-transfer",
|
|
16
19
|
"shutdown",
|
|
@@ -39,6 +42,22 @@ const CYCLE_REASONS = [
|
|
|
39
42
|
export function debugOperation(operation) {
|
|
40
43
|
return OPERATIONS.find((known) => known === operation);
|
|
41
44
|
}
|
|
45
|
+
export function debugJobResult(operation, result) {
|
|
46
|
+
if (!isForegroundDirection(operation))
|
|
47
|
+
return result === "cancelled" ? "cancelled" : undefined;
|
|
48
|
+
if (isForegroundQueueOutcome(result)) {
|
|
49
|
+
if (result.foregroundQueueCleanup !== "verified-result")
|
|
50
|
+
return "blocked";
|
|
51
|
+
result = result.result;
|
|
52
|
+
}
|
|
53
|
+
if (result && typeof result === "object" && "outcome" in result) {
|
|
54
|
+
if (result.outcome === "applied")
|
|
55
|
+
return "completed";
|
|
56
|
+
if (result.outcome === "cancelled")
|
|
57
|
+
return "cancelled";
|
|
58
|
+
}
|
|
59
|
+
return "failed";
|
|
60
|
+
}
|
|
42
61
|
function safeFields(event) {
|
|
43
62
|
switch (event.event) {
|
|
44
63
|
case "startup-timings":
|
|
@@ -7,7 +7,7 @@ import lockfile from "proper-lockfile";
|
|
|
7
7
|
import { DAEMON_BUILD_VERSION } from "./build-version.js";
|
|
8
8
|
import { ConsentPublicationError, readConsent } from "./consent.js";
|
|
9
9
|
import { endpointOwner } from "./endpoint.js";
|
|
10
|
-
import { debugOperation } from "./engine/debug-log.js";
|
|
10
|
+
import { debugJobResult, debugOperation } from "./engine/debug-log.js";
|
|
11
11
|
import { SyncDecisionRequiredError } from "./engine/sync/sync-errors.js";
|
|
12
12
|
import { isForegroundDirection, isForegroundQueueOutcome } from "./foreground-queue-outcome.js";
|
|
13
13
|
import { canonicalRootGuard, daemonPaths, matchesPublishedIdentity, privateDirectory, processExists, publishIdentity, readIdentity, readJsonBody, readUpgradeOwner, runtimePaths, } from "./identity.js";
|
|
@@ -411,7 +411,7 @@ export async function startServer(root, execute, hooks = {}) {
|
|
|
411
411
|
}
|
|
412
412
|
job.view.result = result;
|
|
413
413
|
job.view.phase = "done";
|
|
414
|
-
note(result
|
|
414
|
+
note(debugJobResult(operation, result) ?? job.debugOutcome ?? "completed");
|
|
415
415
|
})
|
|
416
416
|
.catch((error) => {
|
|
417
417
|
if (error instanceof ConsentPublicationError)
|
package/dist/daemon/package.json
CHANGED
package/dist/index.ts
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
installPiDaemonHost,
|
|
14
14
|
piDaemonClient,
|
|
15
15
|
withPiDaemonClient
|
|
16
|
-
} from "./chunks/chunk-
|
|
16
|
+
} from "./chunks/chunk-C3E75DXW.ts";
|
|
17
17
|
import {
|
|
18
18
|
combineSignals,
|
|
19
19
|
throwIfAborted
|
|
@@ -334,12 +334,12 @@ function createStartupCheck(loaders, attention, timeoutMs = 3e4, publish) {
|
|
|
334
334
|
// src/sync/sync-loaders.ts
|
|
335
335
|
function createSyncLoaders(dependencies) {
|
|
336
336
|
const loaders = {
|
|
337
|
-
commands: cachedModuleLoader(dependencies.loadCommandHandler ?? (() => import("./chunks/command-handler-
|
|
338
|
-
inspection: cachedModuleLoader(dependencies.loadSyncInspection ?? (() => import("./chunks/sync-inspection-
|
|
337
|
+
commands: cachedModuleLoader(dependencies.loadCommandHandler ?? (() => import("./chunks/command-handler-HWRPH3K3.ts"))),
|
|
338
|
+
inspection: cachedModuleLoader(dependencies.loadSyncInspection ?? (() => import("./chunks/sync-inspection-NIITROKS.ts"))),
|
|
339
339
|
setupSwitch: cachedModuleLoader(dependencies.loadSetupSwitch ?? (() => import("./chunks/setup-switch-JZDFQPVW.ts"))),
|
|
340
340
|
snapshot: cachedModuleLoader(dependencies.loadSnapshot ?? (() => import("./chunks/snapshot-ZUJJZCFW.ts"))),
|
|
341
341
|
syncState: cachedModuleLoader(dependencies.loadSyncState ?? (() => import("./chunks/sync-state-QIT64TKV.ts"))),
|
|
342
|
-
operations: cachedModuleLoader(dependencies.loadSyncOperations ?? (() => import("./chunks/sync-operations-
|
|
342
|
+
operations: cachedModuleLoader(dependencies.loadSyncOperations ?? (() => import("./chunks/sync-operations-FFI4ZZQL.ts")))
|
|
343
343
|
};
|
|
344
344
|
return loaders;
|
|
345
345
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@narumitw/pi-sync",
|
|
3
|
-
"version": "0.67.
|
|
3
|
+
"version": "0.67.2",
|
|
4
4
|
"description": "Pi extension that syncs Pi configuration through Git, WebDAV, Cloudflare R2, or S3-compatible storage.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@earendil-works/pi-coding-agent": "1.6.0",
|
|
59
59
|
"@earendil-works/pi-tui": "1.6.0",
|
|
60
|
-
"@narumitw/pi-sync-daemon": "^0.13.
|
|
60
|
+
"@narumitw/pi-sync-daemon": "^0.13.2",
|
|
61
61
|
"@types/proper-lockfile": "^4.1.4",
|
|
62
62
|
"@types/semver": "^7.8.0",
|
|
63
63
|
"esbuild": "0.28.2",
|
|
@@ -254,6 +254,8 @@ Pi uses the saved value from session start, including `/reload`, new, resume, an
|
|
|
254
254
|
|
|
255
255
|
Pi Sync and the daemon append directly to one private file, `<getAgentDir()>/pi-sync.log` (normally `~/.pi/agent/pi-sync.log`). Each line is a JSON record. Filter the `source` field for `pi-sync` to see client initialization, connection and request outcomes, or `pi-sync-daemon` to see daemon owner, timing, job and Continuous sync outcomes. The daemon can record work that was already authorized to continue after Pi exits. Repeated successful unchanged polls do not add records. Print and JSON modes add no client log writes and do not launch a daemon to log.
|
|
256
256
|
|
|
257
|
+
Manager actions use `push.foreground` and `pull.foreground`, including a resumed ignore-rule Pull. Match the `operationId` across sources for each attempt. A retry uses a new ID. The daemon can record a completed transfer even if the client reports that queue recovery failed afterward. `started` alone does not show that a transfer ran; the action may still be waiting for review.
|
|
258
|
+
|
|
257
259
|
Records use fixed events and outcomes rather than error text. They can include timestamps, process IDs, durations, counts, and an opaque operation ID when available, but not credentials, local paths, remote addresses, synced content, subprocess output, or model data. Neither timestamps nor file order prove which action caused another. The file is private (`0600` on POSIX when created). Logging is best effort: an unsafe file or write failure can leave records missing without causing a sync failure. The daemon's bounded operational `lifecycle.log` is separate and not controlled by Debug mode. Neither file is a recovery journal.
|
|
258
260
|
|
|
259
261
|
`pi-sync.log` at the agent root stays local regardless of the selection policy. Include and re-include rules cannot override this protection; the log cannot be used as an ignore file. If an older setup or remote snapshot included this name, preserve the local and remote data and review the reported settings or snapshot error. Do not force a pull or use the error as a reason to rewrite remote history. Protection does not erase previously retained snapshots.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type DebugEvent, debugOperation } from "@narumitw/pi-sync-daemon/engine/debug-log";
|
|
1
|
+
import { type DebugEvent, debugJobResult, debugOperation } from "@narumitw/pi-sync-daemon/engine/debug-log";
|
|
2
2
|
|
|
3
3
|
export function observeDebugJob(operation: string, append: (event: DebugEvent) => void) {
|
|
4
4
|
const kind = debugOperation(operation);
|
|
@@ -8,11 +8,14 @@ export function observeDebugJob(operation: string, append: (event: DebugEvent) =
|
|
|
8
8
|
append({ event: "job", operation: kind, outcome, ...(operationId ? { operationId } : {}) });
|
|
9
9
|
return {
|
|
10
10
|
onSubmit(id: string) {
|
|
11
|
+
if (operationId && operationId !== id) record("blocked");
|
|
11
12
|
operationId = id;
|
|
12
13
|
record("started");
|
|
13
14
|
},
|
|
14
|
-
returned(result: unknown) {
|
|
15
|
-
|
|
15
|
+
returned(result: unknown, interrupted = false) {
|
|
16
|
+
const outcome = debugJobResult(kind, result);
|
|
17
|
+
if (interrupted && outcome !== "completed") record("cancelled");
|
|
18
|
+
else if (outcome) record(outcome);
|
|
16
19
|
else if (
|
|
17
20
|
result === "archived" ||
|
|
18
21
|
(kind === "initialize" &&
|
package/src/daemon/pi-client.ts
CHANGED
|
@@ -967,8 +967,7 @@ export class PiDaemonClient {
|
|
|
967
967
|
},
|
|
968
968
|
)
|
|
969
969
|
: await connection.run(operation, payload, runSignal, onCommit, diagnostics?.onSubmit);
|
|
970
|
-
|
|
971
|
-
else diagnostics?.returned(result);
|
|
970
|
+
diagnostics?.returned(result, runSignal.aborted || reload?.signal.aborted);
|
|
972
971
|
if (request?.received && reload && !this.paused && !reload.signal.aborted && !signal?.aborted) {
|
|
973
972
|
this.validate();
|
|
974
973
|
this.pendingReload = reload;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/daemon/pi-client.ts", "../../src/daemon/apply-gate.ts", "../../src/daemon/client-debug.ts", "../../src/daemon/directional-recovery.ts", "../../src/daemon/queue-release-ui.ts", "../../src/daemon/recovery.ts", "../../src/daemon/startup-bootstrap-client.ts"],
|
|
4
|
-
"sourcesContent": ["import { AsyncLocalStorage } from \"node:async_hooks\";\nimport { randomUUID } from \"node:crypto\";\nimport { lstatSync, realpathSync } from \"node:fs\";\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { type ExtensionContext, getAgentDir } from \"@earendil-works/pi-coding-agent\";\nimport {\n type Callback,\n type ClientFacts,\n type ClientHandoff,\n type ContactState,\n DaemonConnection,\n DaemonError,\n type DaemonRecoveryTarget,\n type DocumentView,\n documentFingerprint,\n ensureDaemon,\n findDaemon,\n MAX_SETTINGS_BYTES,\n modelSignature,\n OWNERSHIP_CLEANUP_REQUIRED,\n waitForDaemonExit,\n} from \"@narumitw/pi-sync-daemon\";\nimport { appendDebugEvent, type DebugEvent } from \"@narumitw/pi-sync-daemon/engine/debug-log\";\nimport { type ConfigAuthority, configureEngineHost } from \"@narumitw/pi-sync-daemon/engine/host\";\nimport {\n type LocalConfigDocument,\n peekLocalConfigDocument,\n} from \"@narumitw/pi-sync-daemon/engine/settings/config-file\";\nimport { validateSettingsDocument } from \"@narumitw/pi-sync-daemon/engine/settings/settings-validation\";\nimport { sessionDirFromContext } from \"@narumitw/pi-sync-daemon/engine/snapshot/session-paths\";\nimport type { CommandOptions } from \"../commands/command-types.js\";\nimport type { StartupTimingPublisher } from \"../sync/startup-timings.js\";\nimport { errorMessage, SyncDecisionRequiredError } from \"../sync/sync-errors.js\";\nimport { RemoteSelectionMismatchError } from \"../sync/sync-policy.js\";\nimport {\n type SyncStatusPresentation,\n setSyncStatus,\n showSyncConnectionStatus,\n showSyncQueueReleaseRecovery,\n} from \"../ui/sync-status.js\";\nimport { safeTerminalText } from \"../ui/terminal-text.js\";\nimport { PiApplyGate } from \"./apply-gate.js\";\nimport { observeDebugJob } from \"./client-debug.js\";\nimport {\n type DirectionalCheckpoint,\n isForegroundDirection,\n type PendingAdoptionRecovery,\n runDirectionalRecovery,\n} from \"./directional-recovery.js\";\nimport { createQueueReleaseUI, type QueueReleaseEvent } from \"./queue-release-ui.js\";\nimport { quarantineClient, recoverDetachedClients } from \"./recovery.js\";\nimport { requestStartupBootstrap } from \"./startup-bootstrap-client.js\";\n\nconst scope = new AsyncLocalStorage<{ client: PiDaemonClient; reload?: AbortController }>();\nconst clients = new WeakMap<ExtensionContext[\"sessionManager\"], PiDaemonClient>();\nexport function currentPiDaemonClient() {\n return current();\n}\nfunction current() {\n const client = scope.getStore()?.client;\n if (!client) throw new Error(\"Pi synchronization requires a current session-bound daemon client.\");\n client.validate();\n return client;\n}\nfunction canonicalPath(value: string | undefined): string | undefined {\n // An in-memory session (`pi --no-session`) reports an empty session dir instead of\n // omitting it, so an empty path means \"no path to publish\", not a broken caller.\n if (value === undefined || value === \"\") return undefined;\n if (!path.isAbsolute(value)) throw new Error(\"Pi session paths must be absolute.\");\n const parts: string[] = [];\n let cursor = path.resolve(value);\n for (;;) {\n try {\n return path.join(realpathSync(cursor), ...parts.toReversed());\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ENOENT\" || path.dirname(cursor) === cursor) throw error;\n parts.push(path.basename(cursor));\n cursor = path.dirname(cursor);\n }\n }\n}\nfunction decode(value: unknown): LocalConfigDocument | undefined {\n if (value === null) return undefined;\n const document = value as DocumentView;\n if (\n !document ||\n typeof document.path !== \"string\" ||\n typeof document.bytes !== \"string\" ||\n !document.identity ||\n !document.parsed\n )\n throw new Error(\"Invalid settings response.\");\n return { ...document, bytes: Buffer.from(document.bytes, \"base64\") };\n}\nfunction fingerprint(document: LocalConfigDocument | undefined) {\n return documentFingerprint(\n document ? { bytes: document.bytes.toString(\"base64\"), identity: document.identity } : undefined,\n );\n}\nlet settingsQueue = Promise.resolve();\nconst authority: ConfigAuthority = {\n read: (repair) => {\n const client = current();\n return settingsQueue.then(() => {\n client.validate();\n return client.readSettings(repair);\n });\n },\n update: <T extends Record<string, unknown>>(\n fallback: T,\n update: (value: T) => T,\n validate: (value: Record<string, unknown>) => void,\n signal?: AbortSignal,\n ): Promise<T> => {\n const client = current();\n // Capture ownership and invocation order before prerequisite awaits.\n const operation = settingsQueue.then(async () => {\n client.validate();\n signal?.throwIfAborted();\n const document = await client.readSettings(true);\n client.validate();\n signal?.throwIfAborted();\n if (document) validate(document.parsed);\n const next = update(structuredClone(document?.parsed ?? fallback) as T);\n validate(next);\n await client.run(\"settings.cas\", { expected: fingerprint(document), next }, signal);\n client.validate();\n return next;\n });\n settingsQueue = operation.then(\n () => undefined,\n () => undefined,\n );\n return operation;\n },\n create: async (next, signal) => {\n await current().run(\"settings.cas\", { expected: null, next }, signal);\n },\n replace: async (document, next) => {\n await current().run(\"settings.cas\", { expected: fingerprint(document), next });\n },\n};\n/** Factory registration installs only adapters; it starts no process and performs no I/O. */\nexport function installPiDaemonHost() {\n configureEngineHost({\n root: () => scope.getStore()?.client.root ?? path.resolve(getAgentDir()),\n config: authority,\n mutate: async () => {\n throw new Error(\"File mutation belongs to pi-sync-daemon; no in-process fallback is permitted.\");\n },\n review: async () => {\n throw new Error(\"Engine reviews must arrive through the daemon API.\");\n },\n });\n}\nexport function bindPiDaemonClient(ctx: ExtensionContext, signal: AbortSignal, publish?: StartupTimingPublisher) {\n const client = new PiDaemonClient(ctx, signal, publish);\n clients.set(ctx.sessionManager, client);\n return client;\n}\nexport function piDaemonClient(ctx: ExtensionContext) {\n const client = clients.get(ctx.sessionManager);\n if (!client) throw new Error(\"The Pi synchronization client is not attached to this session.\");\n client.validate();\n return client;\n}\nexport function withPiDaemonClient<Context extends ExtensionContext, T>(\n ctx: Context,\n action: (owned: Context) => Promise<T>,\n reload?: AbortController,\n) {\n const owner = { client: piDaemonClient(ctx), reload };\n // TUI input arrives from Pi's event loop, outside the command's async call tree.\n // Bind public component methods so later menu actions retain this exact owner,\n // never a replacement session selected through a global fallback.\n const ui = new Proxy(ctx.ui, {\n get(target, property) {\n if (property !== \"custom\") return Reflect.get(target, property, target);\n return (...args: Parameters<ExtensionContext[\"ui\"][\"custom\"]>) => {\n const [factory, options] = args;\n const wrap = (component: Awaited<ReturnType<typeof factory>>) => {\n const methods = new Map<PropertyKey, { source: unknown; bound: unknown }>();\n return new Proxy(component, {\n get(original, key) {\n const value: unknown = Reflect.get(original, key, original);\n if (typeof value !== \"function\") return value;\n const saved = methods.get(key);\n if (saved?.source === value) return saved.bound;\n const bound = (...values: unknown[]) => scope.run(owner, () => Reflect.apply(value, original, values));\n methods.set(key, { source: value, bound });\n return bound;\n },\n });\n };\n const invoke = (...provided: Parameters<typeof factory>) => {\n const component = scope.run(owner, () => factory(...provided));\n return component instanceof Promise ? component.then(wrap) : wrap(component);\n };\n // Do not turn synchronous editors/reviews into asynchronous factories.\n return target.custom(\n factory.constructor.name === \"AsyncFunction\" ? async (...provided) => invoke(...provided) : invoke,\n options,\n );\n };\n },\n });\n const owned = new Proxy(ctx, {\n get(target, key) {\n return key === \"ui\" ? ui : Reflect.get(target, key, target);\n },\n });\n return scope.run(owner, () => action(owned));\n}\nexport async function remoteOperation(ctx: ExtensionContext, operation: string, options: CommandOptions) {\n const client = piDaemonClient(ctx);\n const { signal, onCommit, args, setup } = options;\n const owner = scope.getStore();\n const reload = options.reload && owner?.client === client ? owner.reload : undefined;\n reload?.signal.throwIfAborted();\n const payload = {\n args,\n ...(setup === undefined ? {} : { setup }),\n ...(options.automaticFingerprint === undefined ? {} : { automaticFingerprint: options.automaticFingerprint }),\n yes: options.yes,\n force: options.force,\n stale: options.stale,\n silent: options.silent,\n reload: reload !== undefined,\n ...(options.agentRetryRefusal ? { agentRetryRefusal: true } : {}),\n };\n return client.run(operation, payload, signal, ctx, onCommit, reload);\n}\nfunction remoteErrorNamed(error: unknown, name: string) {\n return error instanceof DaemonError && error.remote.name === name;\n}\n\nexport class PiDaemonClient {\n private connection?: DaemonConnection;\n private protectionOnly = false;\n private partialConnection?: DaemonConnection;\n private work = Promise.resolve();\n private factsQueue = Promise.resolve();\n private closing = false;\n private paused = false;\n private pausing?: Promise<void>;\n private connecting?: Promise<DaemonConnection>;\n private contactRepair?: { controller: AbortController; done: Promise<void> };\n private contactAttempt?: { error?: unknown };\n private contactFactsUnpublished = false;\n private contactStatus?: { clear(redraw?: boolean): void; unavailable: boolean };\n private releaseUIEnabled = true;\n private runSignal?: AbortSignal;\n private readonly releaseUI = createQueueReleaseUI(\n () => {\n const ctx = this.releaseContext();\n if (ctx) return showSyncQueueReleaseRecovery(ctx);\n },\n () =>\n this.releaseContext()?.ui.notify(\n \"Pi Sync could not confirm the file write queue release. Sync may be paused; check /sync daemon status before retrying.\",\n \"warning\",\n ),\n );\n private readonly stopReleaseUI = () => {\n // Withdraw while the SDK owner is still active, but never redraw through a replaced context.\n this.releaseUIEnabled = false;\n this.releaseUI.clear(Boolean(this.releaseContext(true)));\n };\n private disposed = false;\n private disposing?: Promise<void>;\n private uiContext: ExtensionContext;\n private reloadRequest?: { received: boolean };\n private pendingReload?: AbortController;\n private directionalCheckpoint?: DirectionalCheckpoint;\n private adoptionRecovery?: {\n pending: PendingAdoptionRecovery;\n review: { setupName: string; fingerprint: string };\n assertRoot(): void;\n };\n private recoveringDirectionalOwner = false;\n private readonly busy = new Set<string>();\n private initialized = false;\n private startupDebug = false;\n private debug = false;\n private participantIdentity = { id: randomUUID(), generation: randomUUID() };\n get id() {\n return this.participantIdentity.id;\n }\n get generation() {\n return this.participantIdentity.generation;\n }\n readonly root: string;\n private cleanupRequired = false;\n private recoveredOwner?: DaemonRecoveryTarget;\n private readonly rawRoot: string;\n private readonly gate: PiApplyGate;\n private readonly manager: ExtensionContext[\"sessionManager\"];\n constructor(\n private readonly ctx: ExtensionContext,\n private readonly signal: AbortSignal,\n private readonly publish?: StartupTimingPublisher,\n ) {\n this.uiContext = ctx;\n this.manager = ctx.sessionManager;\n this.rawRoot = getAgentDir();\n const root = canonicalPath(path.resolve(this.rawRoot));\n if (!root) throw new Error(\"Agent directory is unavailable.\");\n this.root = root;\n this.gate = new PiApplyGate(() => this.validate());\n this.signal.addEventListener(\"abort\", this.stopReleaseUI, { once: true });\n }\n validate() {\n this.signal.throwIfAborted();\n if (this.disposed || this.closing || clients.get(this.manager) !== this)\n throw new Error(\"Synchronization session was replaced.\");\n // Public context access verifies the SDK runner is still active after awaits.\n this.ctx.isIdle();\n if (getAgentDir() !== this.rawRoot || canonicalPath(path.resolve(this.rawRoot)) !== this.root)\n throw new Error(\"Agent directory changed; reload before synchronization.\");\n }\n get debugEnabled() {\n return this.debug;\n }\n setDebugPreference(debug: boolean) {\n this.debug = debug && this.ctx.hasUI && (this.ctx.mode === \"tui\" || this.ctx.mode === \"rpc\");\n }\n recordDebug(event: DebugEvent) {\n if (!this.debug || this.protectionOnly || this.pendingReload || !this.ownsContactUI()) return;\n try {\n this.validate();\n appendDebugEvent(this.root, \"pi-sync\", event);\n } catch {}\n }\n private modelBinding(): ClientFacts[\"model\"] {\n const model = this.ctx.model;\n if (!model) return undefined;\n const registry = this.ctx.modelRegistry;\n if (registry.getRegisteredProviderIds().includes(model.provider)) return undefined;\n const source = registry.getProviderAuthStatus(model.provider).source;\n if (\n source !== \"stored\" &&\n source !== \"environment\" &&\n source !== \"models_json_key\" &&\n source !== \"models_json_command\"\n )\n return undefined;\n return { provider: model.provider, id: model.id, signature: modelSignature(model), authSource: source };\n }\n private facts(protectionOnly = this.protectionOnly): ClientFacts {\n const manager = this.ctx.sessionManager;\n return {\n id: this.id,\n generation: this.generation,\n pid: process.pid,\n cwd: this.ctx.cwd,\n mode: this.ctx.mode,\n hasUI: !protectionOnly && this.ctx.hasUI,\n idle: !protectionOnly && !this.recoveringDirectionalOwner && !this.paused && !this.busy.size && this.ctx.isIdle(),\n ready: !protectionOnly && !this.recoveringDirectionalOwner && this.initialized,\n startupDebug: this.startupDebug,\n sessionFile: canonicalPath(manager.getSessionFile?.()),\n sessionId: manager.getSessionId?.(),\n sessionDir: canonicalPath(sessionDirFromContext(this.ctx)),\n model: protectionOnly ? undefined : this.modelBinding(),\n };\n }\n async configured(matches?: (settings: ReturnType<typeof validateSettingsDocument>) => boolean) {\n this.validate();\n await settingsQueue;\n this.validate();\n const document = await peekLocalConfigDocument();\n this.validate();\n const settings = document && validateSettingsDocument(document.parsed);\n return Boolean(settings?.activeSyncSetup && (matches?.(settings) ?? true));\n }\n async pauseForSessionChange() {\n this.validate();\n this.paused = true;\n this.stopReleaseUI();\n this.stopContactRepair(true);\n this.gate.cancelPending();\n this.pausing ??= (async () => {\n const connection = this.connection ?? this.partialConnection ?? (await this.connecting?.catch(() => undefined));\n if (connection) {\n await connection.pause();\n await this.gate.releaseAfterDrain();\n }\n })();\n return this.pausing;\n }\n async attachExisting({ allowUpgrade = false } = {}) {\n this.validate();\n this.assertNoDirectionalRecovery();\n if (!allowUpgrade && !this.paused && this.connection?.contactState === \"active\") return !this.protectionOnly;\n const address = await findDaemon(this.root).catch((error: unknown) => {\n this.recordDebug({ event: \"connection\", outcome: \"failed\" });\n throw error;\n });\n this.validate();\n this.assertNoDirectionalRecovery();\n if (!address) {\n this.recordDebug({ event: \"connection\", outcome: \"skipped\" });\n return false;\n }\n const upgrade = allowUpgrade && address.needsUpgrade && this.ctx.hasUI && [\"tui\", \"rpc\"].includes(this.ctx.mode);\n let upgradeFailure: string | undefined;\n if (upgrade) {\n try {\n await this.connect();\n this.validate();\n return true;\n } catch (error) {\n this.validate();\n if (this.paused || this.recoveringDirectionalOwner) throw error;\n upgradeFailure = safeTerminalText(errorMessage(error));\n }\n }\n try {\n // If upgrade failed, try only the original owner, with its protection-only facts.\n await this.connect(address);\n } catch (error) {\n this.validate();\n if (remoteErrorNamed(error, \"DaemonStoppingError\")) return false;\n throw error;\n } finally {\n if (upgradeFailure !== undefined) {\n this.validate();\n this.ctx.ui.notify(`pi-sync daemon upgrade failed: ${upgradeFailure}`, \"error\");\n }\n }\n this.validate();\n // Headless, shutdown, and failed-upgrade paths must not schedule transfers on an older build.\n return !this.protectionOnly;\n }\n async finishReattachment() {\n this.validate();\n const connection = this.connection;\n if (!connection) return;\n await recoverDetachedClients(connection);\n await this.queueFacts(async () => {\n this.validateFactsScope(connection);\n await connection.attach(this.signal);\n this.validateFactsScope(connection);\n });\n }\n private assertNoDirectionalRecovery() {\n if (this.recoveringDirectionalOwner)\n throw new Error(\"Pi Sync is recovering the daemon for a transfer. Retry after recovery finishes.\");\n }\n async connect(existing?: Awaited<ReturnType<typeof ensureDaemon>>, requestSignal?: AbortSignal) {\n this.assertNoDirectionalRecovery();\n return this.attachConnection(existing, requestSignal);\n }\n private async attachConnection(existing?: Awaited<ReturnType<typeof ensureDaemon>>, requestSignal?: AbortSignal) {\n const startupSignal = requestSignal ? AbortSignal.any([this.signal, requestSignal]) : this.signal;\n const validateStartup = () => {\n this.validate();\n startupSignal.throwIfAborted();\n };\n validateStartup();\n if (this.connection) {\n if (!existing && this.protectionOnly)\n throw new Error(\n \"This session is only protecting its files on an older Pi Sync daemon. Use /reload to upgrade.\",\n );\n return this.connection;\n }\n this.connecting ??= (async () => {\n if (this.partialConnection) {\n // A failed unpublished attempt may already be retired or own queue grants.\n // Confirm drain before replacing its identity; failed cleanup must block retry.\n await this.partialConnection.dispose();\n // Finish acknowledged cleanup even if this new startup was cancelled meanwhile.\n await this.gate.releaseAfterDrain();\n validateStartup();\n this.partialConnection = undefined;\n this.participantIdentity = { id: randomUUID(), generation: randomUUID() };\n }\n // Only explicit setup/command paths or a configured interactive session call connect.\n if (!existing) await fs.mkdir(this.root, { recursive: true, mode: 0o700 });\n validateStartup();\n let retried = false;\n for (;;) {\n validateStartup();\n const daemon = existing ?? (await ensureDaemon(this.root, startupSignal));\n validateStartup();\n if (daemon.paths.root !== this.root) throw new Error(\"Daemon root changed before attach.\");\n const protectionOnly = daemon.needsUpgrade === true;\n const connection = new DaemonConnection(daemon.paths, daemon.identity, this.facts(protectionOnly), {\n callback: (callback, signal) => this.callback(connection, callback, signal, protectionOnly),\n mergeReview:\n !protectionOnly && this.ctx.hasUI\n ? (callback, loadDetails, signal) => this.pagedMergeReview(connection, callback, loadDetails, signal)\n : undefined,\n event: (event) => {\n if (event.kind === \"commit\") return;\n if (this.signal.aborted || this.disposed || this.closing || clients.get(this.manager) !== this) return;\n const payload = event.payload as {\n message?: string;\n level?: \"info\" | \"warning\" | \"error\";\n report?: string;\n value?: string;\n presentation?: SyncStatusPresentation;\n };\n if (event.kind === \"notify\" && typeof payload?.message === \"string\")\n this.uiContext.ui.notify(safeTerminalText(payload.message), payload.level ?? \"info\");\n if (event.kind === \"timings\" && typeof payload?.report === \"string\") {\n this.publish?.(this.ctx, payload.report.split(\"\\n\").map(safeTerminalText).join(\"\\n\"));\n }\n if (event.kind === \"status\")\n setSyncStatus(\n this.uiContext,\n typeof payload?.value === \"string\" ? safeTerminalText(payload.value) : undefined,\n payload.presentation,\n );\n },\n contact: (state) => this.observeContact(connection, state),\n queueRelease: (event) => this.observeQueueRelease(connection, event),\n error: () => {\n if (\n !this.recoveringDirectionalOwner &&\n this.ownsContactUI() &&\n connection.facts.hasUI &&\n !this.releaseUI.retrying\n )\n this.showContactStatus(\"sync service unavailable\", \"blocked\", true);\n },\n });\n this.partialConnection = connection;\n try {\n await connection.attach(startupSignal);\n } catch (error) {\n if (!(error instanceof DaemonError) || error.remote.name !== \"DaemonStoppingError\") throw error;\n // The final idle fence rejected publication, so this connection owns no queue grants.\n await connection.dispose().catch(() => {});\n this.partialConnection = undefined;\n validateStartup();\n if (existing || retried) throw error;\n retried = true;\n await waitForDaemonExit(daemon.identity, startupSignal);\n validateStartup();\n continue;\n }\n this.validate();\n await recoverDetachedClients(daemon);\n if (this.signal.aborted || this.disposed || this.closing) {\n await connection.dispose();\n this.validate();\n }\n this.validate();\n this.connection = connection;\n this.protectionOnly = protectionOnly;\n this.partialConnection = undefined;\n return connection;\n }\n })().then(\n (connection) => {\n this.recordDebug({ event: \"connection\", outcome: startupSignal.aborted ? \"cancelled\" : \"completed\" });\n return connection;\n },\n (error: unknown) => {\n this.connecting = undefined;\n const outcome = startupSignal.aborted\n ? \"cancelled\"\n : existing && remoteErrorNamed(error, \"DaemonStoppingError\")\n ? \"skipped\"\n : \"failed\";\n this.recordDebug({ event: \"connection\", outcome });\n throw error;\n },\n );\n const connection = await this.connecting;\n validateStartup();\n if (!existing && this.protectionOnly)\n throw new Error(\"This session is only protecting its files on an older Pi Sync daemon. Use /reload to upgrade.\");\n return connection;\n }\n private ownsContactUI() {\n return (\n !this.signal.aborted && !this.disposed && !this.closing && !this.paused && clients.get(this.manager) === this\n );\n }\n private releaseContext(cleanup = false) {\n if (clients.get(this.manager) !== this) return;\n if (!cleanup && (!this.releaseUIEnabled || !this.ownsContactUI() || this.busy.has(\"shutdown\"))) return;\n try {\n this.ctx.isIdle(); // Also verifies the SDK context has not been retired.\n if (this.ctx.hasUI && (this.ctx.mode === \"tui\" || this.ctx.mode === \"rpc\")) return this.ctx;\n } catch {\n // Detached cleanup can outlive its UI.\n }\n }\n disableQueueReleaseUI() {\n this.stopReleaseUI();\n }\n private observeQueueRelease(connection: DaemonConnection, event: QueueReleaseEvent) {\n if (connection !== this.connection || !connection.facts.hasUI || !this.releaseContext()) return;\n if (event.state === \"retrying\" && this.contactStatus?.unavailable) this.clearConnectionStatus();\n this.releaseUI.observe(event, this.busy.has(\"command\"), !this.runSignal || this.runSignal.aborted);\n }\n private showContactStatus(text: string, activity: \"retry\" | \"blocked\", unavailable = false) {\n const previous = this.contactStatus;\n this.contactStatus = {\n clear: showSyncConnectionStatus(this.ctx, text, { activity, reason: activity === \"retry\" ? \"temp\" : \"repair\" }),\n unavailable,\n };\n previous?.clear();\n }\n private clearConnectionStatus(redraw = true) {\n const status = this.contactStatus;\n this.contactStatus = undefined;\n status?.clear(redraw);\n }\n private stopContactRepair(redraw: boolean) {\n this.contactRepair?.controller.abort(new DOMException(\"Pi session is changing\", \"AbortError\"));\n this.clearConnectionStatus(redraw);\n }\n private observeContact(connection: DaemonConnection, state: ContactState) {\n if (connection !== this.connection || !this.ownsContactUI()) return;\n if (state === \"active\") {\n if (this.contactRepair || this.contactFactsUnpublished || connection.contactResumeState === \"uncertain\") return;\n this.clearRestoredContact();\n } else if (state === \"expired\" && connection.facts.hasUI && !this.contactAttempt && !this.contactRepair) {\n if (this.gate.size || connection.hasPendingWork || this.releaseUI.retrying) return;\n void this.resumeContact(connection).catch(() => {\n // The owning repair updates the status; a later command reports the error.\n });\n }\n }\n private clearRestoredContact() {\n this.contactAttempt = undefined;\n this.contactFactsUnpublished = false;\n this.clearConnectionStatus();\n }\n private queueFacts<T>(publish: () => Promise<T>): Promise<T> {\n const result = this.factsQueue.then(publish);\n this.factsQueue = result.then(\n () => {},\n () => {},\n );\n return result;\n }\n private async queueFactsWithAbortableWait<T>(signal: AbortSignal, publish: () => Promise<T>): Promise<T> {\n signal.throwIfAborted();\n const cancelled = Promise.withResolvers<never>();\n const abort = () => cancelled.reject(signal.reason);\n signal.addEventListener(\"abort\", abort, { once: true });\n const queued = this.queueFacts(() => {\n signal.removeEventListener(\"abort\", abort);\n signal.throwIfAborted();\n return publish();\n });\n return Promise.race([queued, cancelled.promise]);\n }\n private validateFactsScope(connection?: DaemonConnection, signal?: AbortSignal) {\n this.validate();\n signal?.throwIfAborted();\n if (this.paused) throw new Error(\"Pi Sync is paused for a session change.\");\n if (connection && connection !== (this.connection ?? this.partialConnection))\n throw new Error(\"Synchronization session was replaced.\");\n }\n private async resumeContact(connection: DaemonConnection) {\n this.validateFactsScope(connection);\n if (this.contactRepair) return this.contactRepair.done;\n const controller = new AbortController();\n const signal = AbortSignal.any([this.signal, controller.signal]);\n const done = this.queueFacts(async () => {\n this.validateFactsScope(connection, signal);\n if (connection.contactState === \"active\" && connection.contactResumeState !== \"uncertain\") return;\n if (this.gate.size || connection.hasPendingWork || connection.contactResumeState === \"uncertain\") {\n throw new Error(\n \"Pi Sync cannot reconnect while previous work is still running or uncertain. Check sync recovery before retrying.\",\n );\n }\n const earlier = this.contactAttempt;\n if (connection.contactState !== \"expired\" || earlier) {\n throw new Error(\"Pi Sync could not restore contact. Review pending work before using /reload.\", {\n cause: earlier?.error,\n });\n }\n const attempt: { error?: unknown } = {};\n this.contactAttempt = attempt;\n try {\n this.showContactStatus(\"sync reconnecting\", \"retry\");\n // Admission can wait behind an apply. Do not advertise readiness using\n // facts sampled before that wait; publish current facts after the ack.\n await connection.resumeContact({ ...this.facts(), idle: false, ready: false }, signal);\n this.validateFactsScope(connection, signal);\n this.contactFactsUnpublished = true;\n this.contactAttempt = undefined;\n await this.publishCurrentFacts(connection, signal);\n this.recordDebug({ event: \"connection\", outcome: \"completed\" });\n } catch (error) {\n this.recordDebug({ event: \"connection\", outcome: signal.aborted ? \"cancelled\" : \"failed\" });\n attempt.error = error;\n if (this.ownsContactUI() && !signal.aborted) {\n this.validateFactsScope(connection, signal);\n this.showContactStatus(\"sync reconnect blocked; check /sync daemon status\", \"blocked\");\n }\n throw error;\n }\n }).finally(() => {\n if (this.contactRepair?.controller === controller) this.contactRepair = undefined;\n });\n this.contactRepair = { controller, done };\n return done;\n }\n private async publishCurrentFacts(connection: DaemonConnection, signal?: AbortSignal) {\n this.validateFactsScope(connection, signal);\n if (connection.contactResumeState === \"uncertain\")\n throw new Error(\"Pi Sync cannot verify the previous reconnect. Review pending work before using /reload.\");\n await connection.update(this.facts());\n this.validateFactsScope(connection, signal);\n this.confirmContact(connection);\n }\n private async publishFacts(connection: DaemonConnection, signal?: AbortSignal) {\n if (this.contactRepair) await this.contactRepair.done;\n const publish = () => this.queueFacts(() => this.publishCurrentFacts(connection, signal));\n try {\n await publish();\n } catch (error) {\n this.validateFactsScope(connection, signal);\n if (!connection.facts.hasUI || !remoteErrorNamed(error, \"ClientContactExpiredError\")) throw error;\n await this.resumeContact(connection);\n // A shared repair might have started before these facts changed.\n await publish();\n }\n }\n private confirmContact(connection: DaemonConnection) {\n if (connection.contactState === \"expired\" || connection.contactState === \"inactive\")\n throw new Error(\"Pi Sync did not confirm active participation in the daemon.\");\n this.clearRestoredContact();\n }\n async verifyConnection(signal?: AbortSignal) {\n const connection = await this.connect(undefined, signal);\n this.validateFactsScope(connection, signal);\n this.assertNoDirectionalRecovery();\n await this.publishFacts(connection, signal);\n this.validateFactsScope(connection, signal);\n this.assertNoDirectionalRecovery();\n return connection;\n }\n async readSettings(repair = false) {\n this.validate();\n if (!this.connection || this.paused) {\n const document = await peekLocalConfigDocument();\n this.validate();\n if (document && document.bytes.length > MAX_SETTINGS_BYTES)\n throw new Error(\"Settings exceed the local API byte limit; the source document is unchanged.\");\n if (document && !repair) validateSettingsDocument(document.parsed);\n return document;\n }\n return decode(await this.run(repair ? \"settings.repair-read\" : \"settings.read\", {}));\n }\n canReportDirectionalResult() {\n try {\n this.validateFactsScope();\n return !this.pendingReload;\n } catch {\n return false;\n }\n }\n get ownershipCleanupRequired() {\n return this.cleanupRequired;\n }\n get pendingPullReview() {\n const recovery = this.adoptionRecovery;\n if (\n !this.cleanupRequired ||\n !recovery ||\n this.paused ||\n recovery.pending.owner !== this.connection ||\n !recovery.pending.owner.canRecoverForeground(recovery.pending.job)\n )\n return undefined;\n return recovery.review;\n }\n confirmRecoveryExit(owner: DaemonRecoveryTarget) {\n this.adoptionRecovery = undefined;\n this.cleanupRequired = true;\n this.recoveredOwner = owner;\n }\n recordOwnershipFailure(error: unknown) {\n if (\n (error instanceof DaemonError && error.remote.properties?.code === OWNERSHIP_CLEANUP_REQUIRED) ||\n (error instanceof Error &&\n ((\"code\" in error && error.code === OWNERSHIP_CLEANUP_REQUIRED) ||\n error.message === \"Daemon ownership cleanup is uncertain; stop and reconcile before restarting.\" ||\n error.message === \"Daemon ownership cleanup is uncertain; stop and reconcile before retrying.\" ||\n error.message ===\n \"File-queue release is uncertain; stop the daemon and keep grants quarantined until owner exit.\"))\n )\n this.cleanupRequired = true;\n }\n run(\n operation: string,\n payload: unknown,\n signal?: AbortSignal,\n ctx = this.ctx,\n onCommit?: () => void,\n reload?: AbortController,\n requirePendingAdoption = false,\n ) {\n const diagnostics = this.debug ? observeDebugJob(operation, (event) => this.recordDebug(event)) : undefined;\n const adoptionRecovery =\n operation === \"pull.foreground\" && this.pendingPullReview ? this.adoptionRecovery : undefined;\n const result = this.work\n .then(() => {\n if (requirePendingAdoption && !adoptionRecovery)\n throw new Error(\"The original Pull is no longer available for automatic recovery.\");\n return this.runCurrent(operation, payload, signal, ctx, onCommit, reload, diagnostics, adoptionRecovery);\n })\n .catch((error: unknown) => {\n diagnostics?.rejected(error, Boolean(signal?.aborted || reload?.signal.aborted));\n this.recordOwnershipFailure(error);\n throw error;\n });\n this.work = result.then(\n () => {},\n () => {},\n );\n return result;\n }\n private async recoverDirectionalOwner(\n connection: DaemonConnection,\n job: string,\n signal: AbortSignal,\n assertRoot: () => void,\n ) {\n this.validateFactsScope(connection, signal);\n this.recoveringDirectionalOwner = true;\n try {\n this.stopContactRepair(true);\n await this.factsQueue;\n this.validateFactsScope(connection, signal);\n await connection.recoverForeground(job, signal);\n if (this.connection !== connection) throw new Error(\"The Pi participant changed during daemon recovery.\");\n this.confirmRecoveryExit(connection.identity);\n await this.gate.releaseAfterDrain();\n this.connection = undefined;\n this.connecting = undefined;\n this.cleanupRequired = false;\n this.validateFactsScope(undefined, signal);\n assertRoot();\n const replacement = await ensureDaemon(this.root, signal, { compatibleOnly: true });\n this.validateFactsScope(undefined, signal);\n assertRoot();\n const attached = await this.attachConnection(replacement, signal);\n this.validateFactsScope(attached, signal);\n assertRoot();\n return attached;\n } finally {\n this.recoveringDirectionalOwner = false;\n }\n }\n private async runCurrent(\n operation: string,\n payload: unknown,\n signal?: AbortSignal,\n ctx = this.ctx,\n onCommit?: () => void,\n reload?: AbortController,\n diagnostics?: ReturnType<typeof observeDebugJob>,\n adoptionRecovery?: PiDaemonClient[\"adoptionRecovery\"],\n ) {\n this.validate();\n if (adoptionRecovery && (this.adoptionRecovery !== adoptionRecovery || !this.pendingPullReview))\n throw new Error(\"The original Pull is no longer available for automatic recovery.\");\n signal?.throwIfAborted();\n reload?.signal.throwIfAborted();\n if (this.pendingReload) throw new Error(\"Pi resources are about to reload.\");\n if (this.paused && operation !== \"shutdown\")\n throw new Error(\"Synchronization is paused for a session change; if it was cancelled, use /reload to reattach.\");\n const connection = await this.connect(undefined, signal);\n if (this.paused && operation === \"shutdown\") {\n Object.assign(connection.facts, { ...this.facts(), idle: false, ready: false });\n await connection.attach(signal ? AbortSignal.any([signal, this.signal]) : this.signal);\n this.validate();\n }\n this.validate();\n signal?.throwIfAborted();\n if (this.paused)\n await connection.update(this.facts()); // Existing, explicitly attached shutdown path.\n else await this.publishFacts(connection, signal);\n this.validate();\n signal?.throwIfAborted();\n this.uiContext = ctx;\n // The daemon directs reload only to the submitting client, and run() serializes its jobs.\n const request = reload ? { received: false } : undefined;\n this.reloadRequest = request;\n const runSignal = signal ? AbortSignal.any([signal, this.signal]) : this.signal;\n this.runSignal = runSignal;\n const clearForeground = () => this.releaseUI.finishForeground(Boolean(this.releaseContext()));\n runSignal.addEventListener(\"abort\", clearForeground, { once: true });\n try {\n const root = isForegroundDirection(operation) ? lstatSync(this.root) : undefined;\n const assertRoot =\n adoptionRecovery?.assertRoot ??\n (() => {\n const current = lstatSync(this.root);\n if (!root || !current.isDirectory() || current.dev !== root.dev || current.ino !== root.ino)\n throw new Error(\"The agent directory changed during the transfer.\");\n });\n const intent = root ? structuredClone(payload) : payload;\n const pull = operation === \"pull.foreground\" ? (intent as { setup: string; fingerprint: string }) : undefined;\n if (\n adoptionRecovery &&\n (!pull ||\n pull.setup !== adoptionRecovery.review.setupName ||\n pull.fingerprint !== adoptionRecovery.review.fingerprint)\n )\n throw new Error(\"The sync setup changed before Pull recovery.\");\n if (adoptionRecovery) {\n assertRoot();\n const { createSettingsConfigView, syncCheckConfigFingerprint } = await import(\"../settings/config.js\");\n this.validateFactsScope(connection, runSignal);\n const document = await peekLocalConfigDocument();\n this.validateFactsScope(connection, runSignal);\n const config = document && (await createSettingsConfigView(document).observe(undefined, runSignal));\n this.validateFactsScope(connection, runSignal);\n assertRoot();\n if (!config || syncCheckConfigFingerprint(config) !== adoptionRecovery.review.fingerprint)\n throw new Error(\"The sync setup changed before Pull recovery.\");\n }\n const result = root\n ? await runDirectionalRecovery(\n connection,\n runSignal,\n async (checkpoint, retryCheckpoint, retryAdoptionJournal) => {\n const current = checkpoint.connection;\n this.validateFactsScope(current, runSignal);\n assertRoot();\n this.directionalCheckpoint = checkpoint;\n try {\n return await current.run(\n operation,\n retryAdoptionJournal !== undefined\n ? { ...pull, retryAdoptionJournal }\n : retryCheckpoint === undefined\n ? intent\n : { ...(intent as object), retryCheckpoint },\n runSignal,\n onCommit,\n (id) => {\n checkpoint.job = id;\n diagnostics?.onSubmit(id);\n },\n );\n } finally {\n this.directionalCheckpoint = undefined;\n }\n },\n (owner, job, recoverySignal) => this.recoverDirectionalOwner(owner, job, recoverySignal, assertRoot),\n () => {\n this.cleanupRequired = true;\n },\n pull && {\n pending: adoptionRecovery?.pending,\n retain: (pending) => {\n this.adoptionRecovery = pending && {\n pending,\n review: { setupName: pull.setup, fingerprint: pull.fingerprint },\n assertRoot,\n };\n },\n },\n )\n : await connection.run(operation, payload, runSignal, onCommit, diagnostics?.onSubmit);\n if (runSignal.aborted || reload?.signal.aborted) diagnostics?.rejected(undefined, true);\n else diagnostics?.returned(result);\n if (request?.received && reload && !this.paused && !reload.signal.aborted && !signal?.aborted) {\n this.validate();\n this.pendingReload = reload;\n // Close the command's UI, not the session. Pi reload must run after this job and its UI drain.\n reload.abort(new DOMException(\"Pi resource reload requested\", \"AbortError\"));\n }\n return result;\n } catch (error) {\n if (error instanceof DaemonError) {\n const prototype =\n error.name === \"RemoteSelectionMismatchError\"\n ? RemoteSelectionMismatchError.prototype\n : error.name === \"SyncDecisionRequiredError\"\n ? SyncDecisionRequiredError.prototype\n : undefined;\n if (prototype) {\n const restored = Object.create(prototype) as Error;\n Object.assign(restored, error.remote.properties, { name: error.name, message: error.message });\n throw restored;\n }\n Object.assign(error, error.remote.properties);\n }\n throw error;\n } finally {\n runSignal.removeEventListener(\"abort\", clearForeground);\n clearForeground();\n this.runSignal = undefined;\n this.uiContext = this.ctx;\n this.reloadRequest = undefined;\n }\n }\n canReload(owner: AbortController) {\n if (this.pendingReload !== owner || this.paused) return false;\n this.validate();\n return true;\n }\n releaseReload(owner: AbortController) {\n if (this.pendingReload === owner) this.pendingReload = undefined;\n }\n async readStartupSettings(signal: AbortSignal) {\n this.validate();\n await settingsQueue;\n this.validate();\n signal.throwIfAborted();\n const document = await peekLocalConfigDocument();\n this.validate();\n signal.throwIfAborted();\n if (document && document.bytes.length > MAX_SETTINGS_BYTES)\n throw new Error(\"Settings exceed the local API byte limit; the source document is unchanged.\");\n return { document, settings: document && validateSettingsDocument(document.parsed) };\n }\n tryStartupBootstrap(document: LocalConfigDocument, debug: boolean, signal: AbortSignal) {\n const ownedSignal = AbortSignal.any([signal, this.signal]);\n let retirement: Promise<void> | undefined;\n const operation = this.work.then(async () => {\n const verify = (connection?: DaemonConnection) => {\n this.validateFactsScope(connection, ownedSignal);\n if (this.pendingReload) throw new Error(\"Pi Sync is paused for a session change.\");\n };\n verify();\n const connection = await this.connect(undefined, ownedSignal);\n return this.queueFacts(async () => {\n verify(connection);\n if (connection.contactState !== \"active\" || connection.contactResumeState !== \"idle\") return false;\n const settingsFingerprint = fingerprint(document);\n let mayHavePublished = true;\n try {\n const ready = await requestStartupBootstrap(connection, settingsFingerprint, debug, ownedSignal);\n mayHavePublished = ready;\n verify(connection);\n if (!ready) return false;\n if (connection.contactState === \"active\") this.confirmContact(connection);\n this.startupDebug = debug;\n this.initialized = true;\n Object.assign(connection.facts, { ready: true, startupDebug: debug });\n return true;\n } catch (error) {\n if (mayHavePublished) {\n retirement = this.dispose();\n void retirement.catch(() => {});\n }\n throw error;\n }\n });\n });\n this.work = operation.then(\n () => {},\n () => {},\n );\n return operation.catch(async (error: unknown) => {\n try {\n await retirement;\n } catch (cause) {\n throw new AggregateError(\n [error, cause],\n \"Startup readiness is uncertain; reconcile the daemon before reconnecting.\",\n );\n }\n throw error;\n });\n }\n async markReady(debug: boolean) {\n this.validate();\n this.startupDebug = debug;\n this.setDebugPreference(debug);\n this.initialized = true;\n await this.update();\n this.validate();\n }\n async setBusy(reason: string, busy: boolean, publish = true) {\n this.validate();\n if (busy) this.busy.add(reason);\n else if (this.busy.delete(reason) && reason === \"command\") {\n // Local command completion does not depend on publishing idle facts.\n this.releaseUI.flushWarnings();\n }\n if (publish) await this.update();\n this.validate();\n }\n async update() {\n if (this.connection && !this.recoveringDirectionalOwner && !this.paused && !this.disposed && !this.signal.aborted)\n await this.publishFacts(this.connection);\n }\n private async pagedMergeReview(\n connection: DaemonConnection,\n callback: Callback,\n loadDetails: (signal?: AbortSignal) => Promise<string>,\n signal: AbortSignal,\n ) {\n const ctx = this.uiContext;\n const generation = this.generation;\n const combined = AbortSignal.any([signal, this.signal]);\n const isCurrent = () =>\n !combined.aborted &&\n this.ownsContactUI() &&\n this.uiContext === ctx &&\n this.generation === generation &&\n (this.connection ?? this.partialConnection) === connection;\n if (!isCurrent()) return false;\n this.validate();\n if (!ctx.hasUI || ![\"tui\", \"rpc\"].includes(ctx.mode)) throw new Error(\"This client cannot present safety reviews.\");\n const { title, confirmationLabel, summaryLines } = callback.payload as {\n title: string;\n confirmationLabel?: string;\n summaryLines: readonly string[];\n };\n const { confirmMergeReview } = await import(\"../ui/merge-review.js\");\n if (!isCurrent()) return false;\n this.validate();\n const result = await confirmMergeReview(\n ctx,\n title,\n loadDetails,\n combined,\n isCurrent,\n confirmationLabel,\n summaryLines,\n );\n if (!isCurrent()) return false;\n this.validate();\n return result;\n }\n private async callback(\n connection: DaemonConnection,\n callback: Callback,\n signal: AbortSignal,\n protectionOnly: boolean,\n ) {\n const payload = callback.payload as {\n reservation?: string;\n targets?: string[];\n generation?: string;\n title?: string;\n message?: string;\n content?: string;\n confirmationLabel?: string;\n summaryLines?: string[];\n items?: string[];\n helpText?: string;\n background?: boolean;\n fingerprint?: string;\n adoptionRecovery?: number;\n };\n if (callback.kind === \"queue-release\") {\n if (typeof payload?.reservation !== \"string\") throw new Error(\"Invalid queue release.\");\n await this.gate.releaseRequest(payload.reservation);\n return true;\n }\n this.validate();\n signal.throwIfAborted();\n if (this.paused) throw new Error(\"Pi session is changing; no new work is authorized.\");\n if (callback.kind === \"directional-checkpoint\") {\n this.validateFactsScope(connection, this.runSignal);\n if (protectionOnly || this.directionalCheckpoint?.accept(connection, callback.job, payload?.fingerprint) !== true)\n return false;\n return payload.adoptionRecovery === 1 ? { adoptionRecovery: 1 } : true;\n }\n if (callback.kind === \"queue-acquire\") {\n if (this.pendingReload) throw new Error(\"Pi resources are about to reload.\");\n if (payload.background && !this.facts().idle) throw new Error(\"Pi is busy; background apply was not granted.\");\n if (\n payload.generation !== this.generation ||\n typeof payload.reservation !== \"string\" ||\n !Array.isArray(payload.targets)\n )\n throw new Error(\"Stale file-queue request.\");\n return this.gate.acquire(payload.reservation, payload.targets, AbortSignal.any([signal, this.signal]));\n }\n const ctx = this.uiContext;\n const combined = AbortSignal.any([signal, this.signal]);\n if (callback.kind === \"model-binding\") {\n if (protectionOnly) return null;\n return this.queueFactsWithAbortableWait(combined, async () => {\n this.validateFactsScope(connection, combined);\n let facts = this.facts();\n if (JSON.stringify(connection.facts.model) !== JSON.stringify(facts.model)) {\n await connection.update(facts);\n this.validateFactsScope(connection, combined);\n facts = this.facts();\n }\n return (payload.background && !facts.idle) ||\n JSON.stringify(connection.facts.model) !== JSON.stringify(facts.model)\n ? null\n : (facts.model ?? null);\n });\n }\n if (callback.kind === \"reload\") {\n if (!this.reloadRequest) throw new Error(\"No active Pi command can reload resources.\");\n this.reloadRequest.received = true;\n return true;\n }\n if (!ctx.hasUI || ![\"tui\", \"rpc\"].includes(ctx.mode)) throw new Error(\"This client cannot present safety reviews.\");\n let result: unknown;\n if (callback.kind === \"merge-review\" && typeof payload.title === \"string\" && typeof payload.content === \"string\") {\n const { confirmMergeReview } = await import(\"../ui/merge-review.js\");\n this.validate();\n combined.throwIfAborted();\n result = await confirmMergeReview(\n ctx,\n payload.title,\n payload.content,\n combined,\n () => !combined.aborted && !this.disposed,\n payload.confirmationLabel,\n payload.summaryLines,\n );\n } else if (\n callback.kind === \"confirm\" &&\n typeof payload.title === \"string\" &&\n typeof payload.message === \"string\"\n ) {\n result = await ctx.ui.confirm(safeTerminalText(payload.title), safeTerminalText(payload.message), {\n signal: combined,\n });\n } else if (\n callback.kind === \"select\" &&\n typeof payload.title === \"string\" &&\n Array.isArray(payload.items) &&\n payload.items.every((item) => typeof item === \"string\")\n ) {\n const labels = payload.items.map(safeTerminalText);\n if (new Set(labels).size !== labels.length) throw new Error(\"Daemon choices have ambiguous terminal labels.\");\n const selected = await ctx.ui.select(safeTerminalText(payload.title), labels, { signal: combined });\n const index = selected === undefined ? -1 : labels.indexOf(selected);\n result = index < 0 ? undefined : payload.items[index];\n } else throw new Error(\"Unsupported daemon UI callback.\");\n this.validate();\n combined.throwIfAborted();\n return result;\n }\n disposeForShutdown(reason: string | undefined, targetFile?: string) {\n const facts = this.connection?.facts ?? this.partialConnection?.facts;\n return this.dispose({\n kind: [\"new\", \"resume\", \"fork\", \"reload\"].includes(reason ?? \"\") ? \"replace\" : \"exit\",\n ...(targetFile !== undefined\n ? { file: canonicalPath(targetFile) }\n : reason === \"reload\"\n ? { file: facts?.sessionFile, sessionId: facts?.sessionId }\n : {}),\n cwd: facts?.cwd,\n });\n }\n async dispose(handoff?: ClientHandoff) {\n if (this.disposing) return this.disposing;\n this.closing = true;\n this.signal.removeEventListener(\"abort\", this.stopReleaseUI);\n this.stopReleaseUI();\n this.stopContactRepair(false);\n this.disposing = (async () => {\n const connection = this.connection ?? this.partialConnection ?? (await this.connecting?.catch(() => undefined));\n let confirmed = false;\n try {\n await connection?.dispose(handoff);\n confirmed = Boolean(connection);\n } catch (error) {\n if (\n !connection ||\n connection.identity.root !== this.recoveredOwner?.root ||\n connection.identity.instance !== this.recoveredOwner.instance ||\n connection.identity.pid !== this.recoveredOwner.pid\n )\n throw error;\n } finally {\n this.disposed = true;\n if (clients.get(this.manager) === this) clients.delete(this.manager);\n const gate = this.gate;\n gate.detach();\n if (connection) {\n if (confirmed) await gate.releaseAfterDrain();\n else quarantineClient(gate, connection.paths.root, connection.identity, connection.facts);\n }\n await Promise.all([this.work, this.factsQueue]);\n }\n })();\n return this.disposing;\n }\n}\n", "import { randomUUID } from \"node:crypto\";\nimport path from \"node:path\";\nimport { withFileMutationQueue } from \"@earendil-works/pi-coding-agent\";\nimport { withTargetQueues } from \"@narumitw/pi-sync-daemon/engine/snapshot/snapshot-mutation-queues\";\n\ninterface Gate {\n token: string;\n paths: readonly string[];\n entered: Promise<string>;\n task: Promise<void>;\n granted: boolean;\n cancelled: boolean;\n reject(error: unknown): void;\n release(): void;\n}\n/**\n * Holds the running Pi's actual public file queues; it does not authorize filesystem writes.\n * The engine owns reviewed destinations, which can differ from every participant's current roots.\n */\nexport class PiApplyGate {\n private gates = new Map<string, Gate>();\n constructor(private validate: () => void) {}\n async acquire(requestId: string, targets: readonly string[], signal?: AbortSignal) {\n this.validate();\n signal?.throwIfAborted();\n if (\n !targets.length ||\n targets.length > 16_384 ||\n targets.some((target) => typeof target !== \"string\" || target.includes(\"\\0\") || !path.isAbsolute(target))\n )\n throw new Error(\"Invalid daemon mutation targets.\");\n const normalized = [...new Set(targets.map((target) => path.resolve(target)))].sort();\n const existing = this.gates.get(requestId);\n if (existing) {\n if (JSON.stringify(existing.paths) !== JSON.stringify(normalized)) throw new Error(\"File-queue request changed.\");\n return existing.entered;\n }\n const token = randomUUID();\n let entered!: (token: string) => void;\n let rejected!: (error: unknown) => void;\n const ready = new Promise<string>((resolve, reject) => {\n entered = resolve;\n rejected = reject;\n });\n let release!: () => void;\n const held = new Promise<void>((resolve) => {\n release = resolve;\n });\n const gate: Gate = {\n token,\n paths: normalized,\n entered: ready,\n task: Promise.resolve(),\n release,\n reject: rejected,\n granted: false,\n cancelled: false,\n };\n this.gates.set(requestId, gate);\n const validate = () => {\n if (gate.cancelled) throw new DOMException(\"File-queue reservation was cancelled\", \"AbortError\");\n this.validate();\n };\n gate.task = withTargetQueues(\n normalized,\n { signal, validateMutation: validate },\n async () => {\n validate();\n signal?.throwIfAborted();\n gate.granted = true;\n entered(token);\n // Prompt cancellation cannot revoke a grant while a remote writer may still run.\n await held;\n },\n { mutate: withFileMutationQueue },\n )\n .catch((error) => {\n rejected(error);\n })\n .finally(() => {\n if (this.gates.get(requestId) === gate) this.gates.delete(requestId);\n });\n const abort = () => {\n if (!gate.granted) {\n gate.cancelled = true;\n rejected(signal?.reason);\n release();\n }\n };\n signal?.addEventListener(\"abort\", abort, { once: true });\n void gate.task.finally(() => signal?.removeEventListener(\"abort\", abort));\n return ready;\n }\n async release(token: string) {\n const gate = [...this.gates.values()].find((value) => value.token === token);\n if (!gate) throw new Error(\"Unknown file-queue grant.\");\n await this.releaseGate(gate);\n }\n private async releaseGate(gate: Gate) {\n if (!gate.granted) {\n gate.cancelled = true;\n gate.reject(new DOMException(\"File-queue reservation was released\", \"AbortError\"));\n }\n gate.release();\n // A queued, ungranted placeholder cannot write after cancellation and need not\n // wait for another Pi tool to finish before acknowledgement.\n if (gate.granted) await gate.task;\n }\n async releaseRequest(requestId: string) {\n const gate = this.gates.get(requestId);\n if (!gate) return;\n await this.releaseGate(gate);\n }\n detach() {\n const failure = new DOMException(\"Pi session detached\", \"AbortError\");\n this.validate = () => {\n throw failure;\n };\n this.cancelPending(failure);\n }\n cancelPending(failure: unknown = new DOMException(\"Pi session changing\", \"AbortError\")) {\n for (const gate of this.gates.values())\n if (!gate.granted) {\n gate.cancelled = true;\n gate.reject(failure);\n gate.release();\n }\n }\n get size() {\n return [...this.gates.values()].filter((gate) => gate.granted || !gate.cancelled).length;\n }\n /** Release only after establishing that the associated service cannot still write. */\n async releaseAfterOwnerExit(pid: number) {\n try {\n process.kill(pid, 0);\n throw new Error(\"Daemon owner is still alive; grants remain held.\");\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ESRCH\") throw error;\n }\n await this.releaseAfterDrain();\n }\n /** Caller must first receive an authenticated same-owner detach/drain acknowledgement. */\n async releaseAfterDrain() {\n await Promise.all([...this.gates.values()].map((gate) => this.releaseGate(gate)));\n }\n}\n", "import { type DebugEvent, debugOperation } from \"@narumitw/pi-sync-daemon/engine/debug-log\";\n\nexport function observeDebugJob(operation: string, append: (event: DebugEvent) => void) {\n const kind = debugOperation(operation);\n if (!kind) return undefined;\n let operationId: string | undefined;\n const record = (outcome: Extract<DebugEvent, { event: \"job\" }>[\"outcome\"]) =>\n append({ event: \"job\", operation: kind, outcome, ...(operationId ? { operationId } : {}) });\n return {\n onSubmit(id: string) {\n operationId = id;\n record(\"started\");\n },\n returned(result: unknown) {\n if (result === \"cancelled\") record(\"cancelled\");\n else if (\n result === \"archived\" ||\n (kind === \"initialize\" &&\n typeof result === \"object\" &&\n result !== null &&\n \"handoverRequired\" in result &&\n result.handoverRequired === true)\n )\n record(\"blocked\");\n else if (\n kind === \"migrate-state\" &&\n typeof result === \"object\" &&\n result !== null &&\n \"status\" in result &&\n result.status === \"cancelled\"\n )\n record(\"cancelled\");\n else record(\"completed\");\n },\n rejected(error: unknown, cancelled: boolean) {\n if (cancelled || (error instanceof Error && error.name === \"AbortError\")) record(\"cancelled\");\n else if (\n error instanceof Error &&\n (error.name === \"SyncDecisionRequiredError\" || error.name === \"RemoteSelectionMismatchError\")\n )\n record(\"blocked\");\n else record(\"failed\");\n },\n };\n}\n", "import type { DaemonConnection } from \"@narumitw/pi-sync-daemon\";\nimport { errorMessage } from \"../sync/sync-errors.js\";\n\nexport function isForegroundDirection(operation: string) {\n return operation === \"push.foreground\" || operation === \"pull.foreground\";\n}\n\nexport class DirectionalCheckpoint {\n job?: string;\n fingerprint?: string;\n\n constructor(\n readonly connection: DaemonConnection,\n private readonly expected?: string,\n ) {}\n\n accept(connection: DaemonConnection, job: string, fingerprint: unknown) {\n if (\n connection !== this.connection ||\n this.job !== job ||\n typeof fingerprint !== \"string\" ||\n !/^[a-f0-9]{64}$/u.test(fingerprint) ||\n (this.expected !== undefined && fingerprint !== this.expected) ||\n (this.fingerprint !== undefined && fingerprint !== this.fingerprint)\n )\n return false;\n this.fingerprint = fingerprint;\n return true;\n }\n}\n\nfunction recoveryOutcome(value: unknown) {\n if (!value || typeof value !== \"object\" || !(\"foregroundQueueCleanup\" in value)) return;\n if (value.foregroundQueueCleanup === \"before-mutation\") return { phase: \"unchanged\" as const };\n if (value.foregroundQueueCleanup === \"resume-adoption\") {\n if (!(\"journal\" in value) || typeof value.journal !== \"string\" || !/^[a-f0-9]{64}$/u.test(value.journal))\n throw new Error(\"The recorded Pull could not be verified. Use /sync daemon recover.\");\n return { phase: \"adoption\" as const, journal: value.journal };\n }\n if (value.foregroundQueueCleanup === \"verified-result\" && \"result\" in value)\n return { phase: \"completed\" as const, result: value.result };\n}\n\nfunction restoreMessage(value: unknown): string {\n return value && typeof value === \"object\" && \"message\" in value && typeof value.message === \"string\"\n ? ` ${value.message}`\n : \"\";\n}\n\nexport class CompletedDirectionalRecoveryError extends Error {}\n\nfunction cancelledAfterCompletion(result: unknown, cause: unknown) {\n const error = new CompletedDirectionalRecoveryError(\n `The transfer finished, but file-queue recovery was cancelled.${restoreMessage(result)}`,\n { cause },\n );\n error.name = \"AbortError\";\n return error;\n}\n\nexport interface PendingAdoptionRecovery {\n owner: DaemonConnection;\n job: string;\n journal: string;\n}\n\nexport async function runDirectionalRecovery(\n connection: DaemonConnection,\n signal: AbortSignal,\n run: (checkpoint: DirectionalCheckpoint, retryCheckpoint?: string, retryAdoptionJournal?: string) => Promise<unknown>,\n recover: (connection: DaemonConnection, job: string, signal: AbortSignal) => Promise<DaemonConnection>,\n markCleanupRequired: () => void,\n adoption?: { pending?: PendingAdoptionRecovery; retain(value: PendingAdoptionRecovery | undefined): void },\n) {\n signal.throwIfAborted();\n const pending = adoption?.pending;\n if (pending && pending.owner !== connection) throw new Error(\"The daemon changed before Pull recovery.\");\n const attempt = new DirectionalCheckpoint(connection);\n attempt.job = pending?.job;\n const result = pending ? { foregroundQueueCleanup: \"resume-adoption\", journal: pending.journal } : await run(attempt);\n const primary = recoveryOutcome(result);\n if (!primary) return result;\n markCleanupRequired();\n let replacement: DaemonConnection;\n const bounded = AbortSignal.any([signal, AbortSignal.timeout(45_000)]);\n try {\n bounded.throwIfAborted();\n if (\n !attempt.job ||\n (primary.phase === \"unchanged\" && !attempt.fingerprint) ||\n (primary.phase === \"adoption\" && (!adoption || (!pending && !attempt.fingerprint)))\n )\n throw new Error(\"The original transfer scope could not be verified.\");\n if (primary.phase === \"adoption\")\n adoption?.retain({ owner: connection, job: attempt.job, journal: primary.journal });\n replacement = await recover(connection, attempt.job, bounded);\n if (primary.phase === \"adoption\") adoption?.retain(undefined);\n bounded.throwIfAborted();\n } catch (error) {\n if (signal.aborted) {\n if (primary.phase === \"completed\") throw cancelledAfterCompletion(primary.result, signal.reason);\n throw signal.reason;\n }\n const detail = bounded.aborted ? \"The daemon did not recover in time.\" : errorMessage(error);\n if (primary.phase === \"completed\")\n throw new CompletedDirectionalRecoveryError(\n `The transfer finished, but file-queue recovery stopped. ${detail}${restoreMessage(primary.result)}`,\n { cause: error },\n );\n if (primary.phase === \"adoption\")\n throw new Error(`Pull recovery stopped. The adoption journal was kept. ${detail}`, { cause: error });\n throw new Error(`No transfer was applied, but file-queue recovery stopped. ${detail}`, { cause: error });\n }\n if (primary.phase === \"completed\") return primary.result;\n const retryCheckpoint = primary.phase === \"unchanged\" ? attempt.fingerprint : undefined;\n const retry = new DirectionalCheckpoint(replacement, retryCheckpoint);\n const retried = await run(retry, retryCheckpoint, primary.phase === \"adoption\" ? primary.journal : undefined);\n const remaining = recoveryOutcome(retried);\n if (!remaining) return retried;\n markCleanupRequired();\n if (remaining.phase === \"completed\") {\n if (signal.aborted) throw cancelledAfterCompletion(remaining.result, signal.reason);\n throw new CompletedDirectionalRecoveryError(\n `Transfer finished, but file-queue cleanup is still uncertain after one recovery attempt.${restoreMessage(remaining.result)}`,\n );\n }\n if (remaining.phase === \"adoption\") {\n if (retry.job && retry.fingerprint)\n adoption?.retain({ owner: replacement, job: retry.job, journal: remaining.journal });\n throw new Error(\"File-queue cleanup is still uncertain after one recovery attempt. The adoption journal was kept.\");\n }\n throw new Error(\"File-queue release could not be verified after one recovery attempt. No transfer was applied.\");\n}\n", "import type { ConnectionOptions } from \"@narumitw/pi-sync-daemon\";\n\nexport type QueueReleaseEvent = Parameters<NonNullable<ConnectionOptions[\"queueRelease\"]>>[0];\ntype ClearStatus = (redraw?: boolean) => void;\n\n/** Session-owned presentation only; it neither controls delivery nor infers a job's outcome. */\nexport function createQueueReleaseUI(show: () => ClearStatus | undefined, warn: () => void) {\n const retries = new Map<string, { job: string; foreground: boolean }>();\n const handledJobs = new Set<string>();\n const deferredWarnings = new Set<string>();\n let timer: ReturnType<typeof setTimeout> | undefined;\n let clearStatus: ClearStatus | undefined;\n\n function remember(job: string) {\n deferredWarnings.delete(job);\n if (handledJobs.has(job)) return false;\n if (handledJobs.size >= 128) {\n const oldest = handledJobs.values().next();\n if (!oldest.done) handledJobs.delete(oldest.value);\n }\n handledJobs.add(job);\n return true;\n }\n function clearPresentation(redraw: boolean) {\n clearTimeout(timer);\n timer = undefined;\n const release = clearStatus;\n clearStatus = undefined;\n release?.(redraw);\n }\n\n return {\n get retrying() {\n return retries.size > 0;\n },\n observe({ id, job, state, foreground }: QueueReleaseEvent, commandBusy: boolean, cancelled: boolean) {\n if (state === \"retrying\") {\n if (foreground && cancelled) {\n remember(job);\n return;\n }\n if (retries.has(id)) return;\n retries.set(id, { job, foreground });\n if (retries.size !== 1) return;\n timer = setTimeout(() => {\n timer = undefined;\n const release = show();\n if (retries.size) clearStatus = release;\n else release?.(false); // Presentation may have synchronously reentered lifecycle cleanup.\n }, 2_000);\n timer.unref?.();\n return;\n }\n const retry = retries.get(id);\n retries.delete(id);\n if (!retries.size) clearPresentation(true);\n if (state !== \"unconfirmed\") return;\n const background = !foreground && !retry?.foreground;\n if (background && commandBusy) {\n if (!handledJobs.has(job)) deferredWarnings.add(job);\n } else if (remember(job) && background) warn();\n },\n flushWarnings() {\n if (!deferredWarnings.size) return;\n // One warning covers the background releases deferred by this command.\n for (const job of deferredWarnings) remember(job);\n try {\n warn();\n } catch {\n // Presentation must not interrupt publication of the new idle state.\n }\n },\n finishForeground(redraw: boolean) {\n for (const [id, { job, foreground }] of retries) {\n if (!foreground) continue;\n retries.delete(id);\n remember(job); // Late observations of this job should not duplicate its command result.\n }\n if (!retries.size) clearPresentation(redraw);\n },\n clear(redraw: boolean) {\n retries.clear();\n handledJobs.clear();\n deferredWarnings.clear();\n clearPresentation(redraw);\n },\n };\n}\n", "import { type ClientFacts, DaemonConnection, findDaemon, type Identity } from \"@narumitw/pi-sync-daemon\";\nimport type { PiApplyGate } from \"./apply-gate.js\";\n\ntype Address = { paths: DaemonConnection[\"paths\"]; identity: Identity };\ninterface Recovery {\n gate: PiApplyGate;\n root: string;\n identity: Identity;\n facts: ClientFacts;\n timer?: ReturnType<typeof setInterval>;\n attempt?: Promise<boolean>;\n}\nconst recoveries = new Set<Recovery>();\nfunction alive(pid: number) {\n try {\n process.kill(pid, 0);\n return true;\n } catch (error) {\n return (error as NodeJS.ErrnoException).code !== \"ESRCH\";\n }\n}\nfunction finish(record: Recovery) {\n if (record.timer) clearInterval(record.timer);\n recoveries.delete(record);\n}\nfunction attempt(record: Recovery, known?: Address): Promise<boolean> {\n record.attempt ??= (async () => {\n const exited = !alive(record.identity.pid);\n if (exited) await record.gate.releaseAfterOwnerExit(record.identity.pid);\n const address = known ?? (await findDaemon(record.root));\n if (!address || (!exited && address.identity.instance !== record.identity.instance)) return false;\n // Only plain closed-session facts and detached grants cross this recovery boundary.\n // Reclaim the obsolete participant on a compatible owner, reject all new work,\n // and service release callbacks until an authenticated detach confirms drain.\n const connection = new DaemonConnection(\n address.paths,\n address.identity,\n {\n ...record.facts,\n hasUI: false,\n idle: false,\n ready: false,\n },\n {\n callback: async (callback) => {\n const data = callback.payload;\n if (\n callback.kind === \"queue-release\" &&\n data !== null &&\n typeof data === \"object\" &&\n \"reservation\" in data &&\n typeof data.reservation === \"string\"\n ) {\n await record.gate.releaseRequest(data.reservation);\n return true;\n }\n throw new Error(\"Closed Pi participant cannot authorize new work.\");\n },\n },\n );\n try {\n // Cleanup polling does not attach or recreate a retired participant.\n await connection.dispose();\n await record.gate.releaseAfterDrain();\n finish(record);\n return true;\n } finally {\n await connection.dispose();\n }\n })()\n .catch(() => false)\n .finally(() => {\n record.attempt = undefined;\n });\n return record.attempt;\n}\n\n/** Intentionally shared cleanup may outlive a session, but never retains its ctx or UI. */\nexport function quarantineClient(gate: PiApplyGate, root: string, identity: Identity, facts: ClientFacts) {\n gate.detach();\n const record: Recovery = { gate, root, identity: structuredClone(identity), facts: structuredClone(facts) };\n recoveries.add(record);\n record.timer = setInterval(() => {\n void attempt(record);\n }, 1000);\n record.timer.unref();\n void attempt(record);\n}\n\n/** A newly attached client stays unready until obsolete local participants are retired. */\nexport async function recoverDetachedClients(address: Address) {\n const pending = [...recoveries].filter((record) => record.root === address.paths.root);\n const results = await Promise.all(\n pending.map(async (record) => {\n const done = await attempt(record, address);\n return done || !recoveries.has(record) || (await attempt(record, address));\n }),\n );\n if (results.some((done) => !done))\n throw new Error(\n \"Previous Pi cleanup is still uncertain; stop or repair the existing daemon before retrying /reload.\",\n );\n}\n", "import { type DaemonConnection, DaemonError, requestDaemon } from \"@narumitw/pi-sync-daemon\";\n\nexport async function requestStartupBootstrap(\n connection: DaemonConnection,\n fingerprint: string | null,\n debug: boolean,\n signal: AbortSignal,\n): Promise<boolean> {\n let result: unknown;\n try {\n const { id: client, generation } = connection.facts;\n result = await requestDaemon(\n connection.paths,\n connection.identity,\n \"startup.bootstrap\",\n { client, generation, fingerprint, debug },\n signal,\n );\n } catch (error) {\n if (error instanceof DaemonError && error.name === \"Error\" && error.message === \"Unknown daemon method.\")\n return false;\n throw error;\n }\n if (typeof result !== \"boolean\") throw new Error(\"Invalid startup bootstrap response.\");\n return result;\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA,SAAS,yBAAyB;AAClC,S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AAU;AAAA,MAChC,SAAS,OAAO;AACd,YACE,CAAC,cACD,WAAW,SAAS,SAAS,KAAK,gBAAgB,QAClD,WAAW,SAAS,aAAa,KAAK,eAAe,YACrD,WAAW,SAAS,QAAQ,KAAK,eAAe;AAEhD,gBAAM;AAAA,MACV,UAAE;AACA,aAAK,WAAW;AAChB,YAAI,QAAQ,IAAI,KAAK,OAAO,MAAM,KAAM,SAAQ,OAAO,KAAK,OAAO;AACnE,cAAM,OAAO,KAAK;AAClB,aAAK,OAAO;AACZ,YAAI,YAAY;AACd,cAAI,UAAW,OAAM,KAAK,kBAAkB;AAAA,cACvC,kBAAiB,MAAM,WAAW,MAAM,MAAM,WAAW,UAAU,WAAW,KAAK;AAAA,QAC1F;AACA,cAAM,QAAQ,IAAI,CAAC,KAAK,MAAM,KAAK,UAAU,CAAC;AAAA,MAChD;AAAA,IACF,GAAG;AACH,WAAO,KAAK;AAAA,EACd;AACF;",
|
|
6
|
-
"names": ["randomUUID", "path", "DaemonConnection", "DaemonError", "findDaemon", "fingerprint", "attempt", "fingerprint", "path", "DaemonError", "randomUUID", "findDaemon", "connection", "DaemonConnection", "attempt", "current"]
|
|
7
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/chunks/{remote-selection-ui-WFLX6MAJ.ts.map → remote-selection-ui-34WC7OFE.ts.map}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|