@narumitw/pi-sync 0.57.12 → 0.58.1
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 +16 -0
- package/README.md +5 -1
- package/dist/chunks/{agent-sync-P6AWQXGK.ts → agent-sync-2R4GG2MF.ts} +3 -3
- package/dist/chunks/{chunk-ZDDBZH72.ts → chunk-JYILGR3K.ts} +2 -2
- package/dist/chunks/{chunk-OKPPZA4D.ts → chunk-MG66XM5U.ts} +3 -3
- package/dist/chunks/{chunk-OKPPZA4D.ts.map → chunk-MG66XM5U.ts.map} +2 -2
- package/dist/chunks/{chunk-Q23JJW7E.ts → chunk-REMGB255.ts} +32 -11
- package/dist/chunks/chunk-REMGB255.ts.map +7 -0
- package/dist/chunks/{chunk-ZC3IHFNM.ts → chunk-WQMYV4DW.ts} +3 -3
- package/dist/chunks/chunk-WQMYV4DW.ts.map +7 -0
- package/dist/chunks/chunk-YIPK23JW.ts +171 -0
- package/dist/chunks/chunk-YIPK23JW.ts.map +7 -0
- package/dist/chunks/{command-handler-VKLZBRLO.ts → command-handler-MRXE5AKK.ts} +7 -6
- package/dist/chunks/{command-handler-VKLZBRLO.ts.map → command-handler-MRXE5AKK.ts.map} +2 -2
- package/dist/chunks/{continuous-sync-TTOSJCQU.ts → continuous-sync-FAFNLEUW.ts} +18 -10
- package/dist/chunks/continuous-sync-FAFNLEUW.ts.map +7 -0
- package/dist/chunks/{manager-result-dispatcher-6W52NM7F.ts → manager-result-dispatcher-XCYPW7RC.ts} +4 -4
- package/dist/chunks/{manager-ui-INVMAFEN.ts → manager-ui-AY34N4UY.ts} +8 -8
- package/dist/chunks/{remote-selection-ui-TD4C4W3J.ts → remote-selection-ui-MYM2YCPF.ts} +3 -3
- package/dist/chunks/{sync-operations-TMGQHBF5.ts → sync-operations-45APGOL3.ts} +6 -6
- package/dist/chunks/sync-operations-45APGOL3.ts.map +7 -0
- package/dist/index.ts +78 -63
- package/dist/index.ts.map +2 -2
- package/docs/tui-contract.md +37 -0
- package/package.json +2 -2
- package/skills/configure-pi-sync/references/configuration.md +13 -1
- package/src/commands/command-handler.ts +1 -0
- package/src/sync/agent-sync.ts +1 -1
- package/src/sync/continuous-sync.ts +15 -6
- package/src/sync/startup-check.ts +1 -1
- package/src/sync/sync-mutations.ts +2 -2
- package/src/sync/sync-queries.ts +2 -2
- package/src/sync-extension.ts +71 -57
- package/src/ui/remote-selection-ui.ts +1 -1
- package/src/ui/sync-attention.ts +36 -12
- package/src/ui/sync-status.ts +214 -3
- package/dist/chunks/chunk-K3RIEL6J.ts +0 -20
- package/dist/chunks/chunk-K3RIEL6J.ts.map +0 -7
- package/dist/chunks/chunk-Q23JJW7E.ts.map +0 -7
- package/dist/chunks/chunk-ZC3IHFNM.ts.map +0 -7
- package/dist/chunks/continuous-sync-TTOSJCQU.ts.map +0 -7
- package/dist/chunks/sync-operations-TMGQHBF5.ts.map +0 -7
- /package/dist/chunks/{agent-sync-P6AWQXGK.ts.map → agent-sync-2R4GG2MF.ts.map} +0 -0
- /package/dist/chunks/{chunk-ZDDBZH72.ts.map → chunk-JYILGR3K.ts.map} +0 -0
- /package/dist/chunks/{manager-result-dispatcher-6W52NM7F.ts.map → manager-result-dispatcher-XCYPW7RC.ts.map} +0 -0
- /package/dist/chunks/{manager-ui-INVMAFEN.ts.map → manager-ui-AY34N4UY.ts.map} +0 -0
- /package/dist/chunks/{remote-selection-ui-TD4C4W3J.ts.map → remote-selection-ui-MYM2YCPF.ts.map} +0 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
// @generated by scripts/build-runtime.mjs; do not edit.
|
|
2
|
+
// @ts-nocheck -- generated JavaScript uses a .ts extension for Pi's Jiti loader.
|
|
3
|
+
|
|
4
|
+
// src/ui/sync-status.ts
|
|
5
|
+
var STATUS_KEY = "sync";
|
|
6
|
+
var failureReasons = {
|
|
7
|
+
transient: "temp",
|
|
8
|
+
contention: "busy",
|
|
9
|
+
stale: "stale",
|
|
10
|
+
authentication: "auth",
|
|
11
|
+
storage: "storage",
|
|
12
|
+
unsafe: "review",
|
|
13
|
+
model: "model",
|
|
14
|
+
budget: "limit",
|
|
15
|
+
unknown: "unknown"
|
|
16
|
+
};
|
|
17
|
+
function syncStatusFailureReason(kind) {
|
|
18
|
+
return typeof kind === "string" && Object.hasOwn(failureReasons, kind) ? failureReasons[kind] : "unknown";
|
|
19
|
+
}
|
|
20
|
+
var enabledBySession = /* @__PURE__ */ new WeakMap();
|
|
21
|
+
var publishersBySession = /* @__PURE__ */ new WeakMap();
|
|
22
|
+
function statusPresentation(presentation) {
|
|
23
|
+
if (!presentation) return;
|
|
24
|
+
try {
|
|
25
|
+
const { activity, reason } = presentation;
|
|
26
|
+
if (activity === "retry" || activity === "blocked") {
|
|
27
|
+
if (typeof reason === "string" && /^[a-z][a-z0-9-]{0,31}$/u.exec(reason)?.[0] === reason)
|
|
28
|
+
return { activity, reason };
|
|
29
|
+
} else if ([
|
|
30
|
+
"idle",
|
|
31
|
+
"checking",
|
|
32
|
+
"working",
|
|
33
|
+
"pushing",
|
|
34
|
+
"pulling",
|
|
35
|
+
"resolving",
|
|
36
|
+
"local-change",
|
|
37
|
+
"remote-change",
|
|
38
|
+
"review"
|
|
39
|
+
].includes(activity) && reason === void 0) {
|
|
40
|
+
return { activity };
|
|
41
|
+
}
|
|
42
|
+
} catch {
|
|
43
|
+
}
|
|
44
|
+
return void 0;
|
|
45
|
+
}
|
|
46
|
+
function createSyncStatusPublisher(events) {
|
|
47
|
+
let active;
|
|
48
|
+
let used = false;
|
|
49
|
+
let activation = 0;
|
|
50
|
+
const emit = (payload) => {
|
|
51
|
+
try {
|
|
52
|
+
events?.emit("extension-status:v1:update", payload);
|
|
53
|
+
} catch {
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const bind = (ctx) => {
|
|
57
|
+
if (!ctx.hasUI || !active && used || active && active.sessionManager !== ctx.sessionManager) return () => {
|
|
58
|
+
};
|
|
59
|
+
const { sessionManager } = ctx;
|
|
60
|
+
if (active) {
|
|
61
|
+
return publishersBySession.get(sessionManager) === active.binding ? active.binding.release : () => {
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
const owner = activation;
|
|
65
|
+
used = true;
|
|
66
|
+
publishersBySession.get(sessionManager)?.release();
|
|
67
|
+
if (activation !== owner || publishersBySession.has(sessionManager)) return () => {
|
|
68
|
+
};
|
|
69
|
+
let current;
|
|
70
|
+
let revision = 0;
|
|
71
|
+
let unsubscribe;
|
|
72
|
+
const isCurrent = () => publishersBySession.get(sessionManager) === binding;
|
|
73
|
+
const publish = (requestId) => {
|
|
74
|
+
emit({
|
|
75
|
+
version: 1,
|
|
76
|
+
sessionManager,
|
|
77
|
+
key: STATUS_KEY,
|
|
78
|
+
...current ?? { value: void 0 },
|
|
79
|
+
...requestId === void 0 ? {} : { requestId }
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
const binding = {
|
|
83
|
+
update(value, presentation) {
|
|
84
|
+
if (!isCurrent()) return;
|
|
85
|
+
const owner2 = ++revision;
|
|
86
|
+
const safePresentation = statusPresentation(presentation);
|
|
87
|
+
if (!isCurrent() || revision !== owner2) return;
|
|
88
|
+
current = value && safePresentation ? { value, ...safePresentation } : void 0;
|
|
89
|
+
publish();
|
|
90
|
+
},
|
|
91
|
+
release() {
|
|
92
|
+
const owned = isCurrent();
|
|
93
|
+
revision++;
|
|
94
|
+
if (owned) {
|
|
95
|
+
publishersBySession.delete(sessionManager);
|
|
96
|
+
current = void 0;
|
|
97
|
+
}
|
|
98
|
+
if (active?.binding === binding) active = void 0;
|
|
99
|
+
const stop = unsubscribe;
|
|
100
|
+
unsubscribe = void 0;
|
|
101
|
+
try {
|
|
102
|
+
stop?.();
|
|
103
|
+
} catch {
|
|
104
|
+
}
|
|
105
|
+
if (owned && !publishersBySession.has(sessionManager)) publish();
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
active = { sessionManager, binding };
|
|
109
|
+
used = true;
|
|
110
|
+
publishersBySession.set(sessionManager, binding);
|
|
111
|
+
try {
|
|
112
|
+
unsubscribe = events?.on("extension-status:v1:request", (payload) => {
|
|
113
|
+
try {
|
|
114
|
+
if (!isCurrent() || !payload || typeof payload !== "object" || Array.isArray(payload)) return;
|
|
115
|
+
const {
|
|
116
|
+
version,
|
|
117
|
+
sessionManager: manager,
|
|
118
|
+
requestId
|
|
119
|
+
} = payload;
|
|
120
|
+
if (!isCurrent() || version !== 1 || manager !== sessionManager || !requestId || typeof requestId !== "object")
|
|
121
|
+
return;
|
|
122
|
+
publish(requestId);
|
|
123
|
+
} catch {
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
} catch {
|
|
127
|
+
}
|
|
128
|
+
return binding.release;
|
|
129
|
+
};
|
|
130
|
+
return {
|
|
131
|
+
bind,
|
|
132
|
+
start(ctx) {
|
|
133
|
+
const owner = ++activation;
|
|
134
|
+
const { sessionManager } = ctx;
|
|
135
|
+
const previous = publishersBySession.get(sessionManager);
|
|
136
|
+
active?.binding.release();
|
|
137
|
+
if (activation !== owner || publishersBySession.has(sessionManager) && publishersBySession.get(sessionManager) !== previous)
|
|
138
|
+
return () => {
|
|
139
|
+
};
|
|
140
|
+
used = false;
|
|
141
|
+
const release = bind(ctx);
|
|
142
|
+
used = true;
|
|
143
|
+
return activation === owner ? release : () => {
|
|
144
|
+
};
|
|
145
|
+
},
|
|
146
|
+
cleanupFor(ctx) {
|
|
147
|
+
return active?.sessionManager === ctx.sessionManager ? active.binding.release : () => {
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
function configureSyncStatus(ctx, enabled) {
|
|
153
|
+
enabledBySession.set(ctx.sessionManager, enabled);
|
|
154
|
+
if (!enabled) {
|
|
155
|
+
if (ctx.hasUI) ctx.ui.setStatus(STATUS_KEY, void 0);
|
|
156
|
+
publishersBySession.get(ctx.sessionManager)?.update(void 0);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
function setSyncStatus(ctx, value, presentation) {
|
|
160
|
+
if (!ctx.hasUI || value !== void 0 && enabledBySession.get(ctx.sessionManager) === false) return;
|
|
161
|
+
ctx.ui.setStatus(STATUS_KEY, value);
|
|
162
|
+
publishersBySession.get(ctx.sessionManager)?.update(value, presentation);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export {
|
|
166
|
+
syncStatusFailureReason,
|
|
167
|
+
createSyncStatusPublisher,
|
|
168
|
+
configureSyncStatus,
|
|
169
|
+
setSyncStatus
|
|
170
|
+
};
|
|
171
|
+
//# sourceMappingURL=chunk-YIPK23JW.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/ui/sync-status.ts"],
|
|
4
|
+
"sourcesContent": ["import type { ExtensionAPI, ExtensionContext } from \"@earendil-works/pi-coding-agent\";\nimport type { ContinuousErrorKind } from \"../sync/continuous-errors.js\";\n\nconst STATUS_KEY = \"sync\";\n\ntype SyncStatusContext = Pick<ExtensionContext, \"hasUI\" | \"sessionManager\" | \"ui\">;\n\nexport type SyncStatusPresentation =\n | {\n activity:\n | \"idle\"\n | \"checking\"\n | \"working\"\n | \"pushing\"\n | \"pulling\"\n | \"resolving\"\n | \"local-change\"\n | \"remote-change\"\n | \"review\";\n reason?: never;\n }\n | { activity: \"retry\" | \"blocked\"; reason: SyncStatusReason };\n\ntype SyncStatusReason =\n | \"temp\"\n | \"busy\"\n | \"stale\"\n | \"auth\"\n | \"storage\"\n | \"review\"\n | \"model\"\n | \"limit\"\n | \"unknown\"\n | \"repair\";\n\nconst failureReasons: Record<ContinuousErrorKind, SyncStatusReason> = {\n transient: \"temp\",\n contention: \"busy\",\n stale: \"stale\",\n authentication: \"auth\",\n storage: \"storage\",\n unsafe: \"review\",\n model: \"model\",\n budget: \"limit\",\n unknown: \"unknown\",\n};\n\nexport function syncStatusFailureReason(kind: ContinuousErrorKind | undefined): SyncStatusReason {\n return typeof kind === \"string\" && Object.hasOwn(failureReasons, kind) ? failureReasons[kind] : \"unknown\";\n}\n\nconst enabledBySession = new WeakMap<ExtensionContext[\"sessionManager\"], boolean>();\nconst publishersBySession = new WeakMap<ExtensionContext[\"sessionManager\"], StatusBinding>();\n\ninterface StatusBinding {\n update(value: string | undefined, presentation?: SyncStatusPresentation): void;\n release(): void;\n}\n\nfunction statusPresentation(presentation: SyncStatusPresentation | undefined): SyncStatusPresentation | undefined {\n if (!presentation) return;\n try {\n const { activity, reason } = presentation;\n if (activity === \"retry\" || activity === \"blocked\") {\n if (typeof reason === \"string\" && /^[a-z][a-z0-9-]{0,31}$/u.exec(reason)?.[0] === reason)\n return { activity, reason };\n } else if (\n [\n \"idle\",\n \"checking\",\n \"working\",\n \"pushing\",\n \"pulling\",\n \"resolving\",\n \"local-change\",\n \"remote-change\",\n \"review\",\n ].includes(activity) &&\n reason === undefined\n ) {\n return { activity };\n }\n } catch {\n // Invalid optional annotations withdraw metadata, not the readable status.\n }\n return undefined;\n}\n\n/** Optional extension-status v1 publisher; it owns no domain work or captured context. */\nexport function createSyncStatusPublisher(events: ExtensionAPI[\"events\"] | undefined) {\n let active: { sessionManager: ExtensionContext[\"sessionManager\"]; binding: StatusBinding } | undefined;\n let used = false;\n let activation = 0;\n const emit = (payload: object) => {\n try {\n events?.emit(\"extension-status:v1:update\", payload);\n } catch {\n // Optional delivery must not interrupt sync, including on minimal test buses.\n }\n };\n const bind = (ctx: SyncStatusContext): (() => void) => {\n if (!ctx.hasUI || (!active && used) || (active && active.sessionManager !== ctx.sessionManager)) return () => {};\n const { sessionManager } = ctx;\n if (active) {\n return publishersBySession.get(sessionManager) === active.binding ? active.binding.release : () => {};\n }\n const owner = activation;\n // Reserve first use before foreign cleanup can reenter this factory.\n used = true;\n publishersBySession.get(sessionManager)?.release();\n if (activation !== owner || publishersBySession.has(sessionManager)) return () => {};\n let current: ({ value: string } & SyncStatusPresentation) | undefined;\n let revision = 0;\n let unsubscribe: (() => void) | undefined;\n const isCurrent = () => publishersBySession.get(sessionManager) === binding;\n const publish = (requestId?: object) => {\n emit({\n version: 1,\n sessionManager,\n key: STATUS_KEY,\n ...(current ?? { value: undefined }),\n ...(requestId === undefined ? {} : { requestId }),\n });\n };\n const binding: StatusBinding = {\n update(value, presentation) {\n if (!isCurrent()) return;\n const owner = ++revision;\n const safePresentation = statusPresentation(presentation);\n if (!isCurrent() || revision !== owner) return;\n current = value && safePresentation ? { value, ...safePresentation } : undefined;\n publish();\n },\n release() {\n const owned = isCurrent();\n revision++;\n if (owned) {\n publishersBySession.delete(sessionManager);\n current = undefined;\n }\n // Retire before optional callbacks; withdrawal observers cannot revive first-use binding.\n if (active?.binding === binding) active = undefined;\n const stop = unsubscribe;\n unsubscribe = undefined;\n try {\n stop?.();\n } catch {\n // A failing optional unsubscribe cannot stop lifecycle cleanup.\n }\n if (owned && !publishersBySession.has(sessionManager)) publish();\n },\n };\n active = { sessionManager, binding };\n used = true;\n publishersBySession.set(sessionManager, binding);\n try {\n unsubscribe = events?.on(\"extension-status:v1:request\", (payload) => {\n try {\n if (!isCurrent() || !payload || typeof payload !== \"object\" || Array.isArray(payload)) return;\n const {\n version,\n sessionManager: manager,\n requestId,\n } = payload as {\n version?: unknown;\n sessionManager?: unknown;\n requestId?: unknown;\n };\n if (\n !isCurrent() ||\n version !== 1 ||\n manager !== sessionManager ||\n !requestId ||\n typeof requestId !== \"object\"\n )\n return;\n publish(requestId);\n } catch {\n // Malformed requests and optional delivery cannot affect sync.\n }\n });\n } catch {\n // Raw status remains available when optional subscription fails.\n }\n return binding.release;\n };\n return {\n bind,\n start(ctx: SyncStatusContext) {\n const owner = ++activation;\n const { sessionManager } = ctx;\n const previous = publishersBySession.get(sessionManager);\n active?.binding.release();\n if (\n activation !== owner ||\n (publishersBySession.has(sessionManager) && publishersBySession.get(sessionManager) !== previous)\n )\n return () => {};\n // Only an explicit lifecycle start can reactivate a released publisher.\n used = false;\n const release = bind(ctx);\n used = true;\n // A superseded start must not receive the newer activation's cleanup capability.\n return activation === owner ? release : () => {};\n },\n cleanupFor(ctx: SyncStatusContext) {\n return active?.sessionManager === ctx.sessionManager ? active.binding.release : () => {};\n },\n };\n}\n\nexport function configureSyncStatus(ctx: SyncStatusContext, enabled: boolean) {\n enabledBySession.set(ctx.sessionManager, enabled);\n if (!enabled) {\n if (ctx.hasUI) ctx.ui.setStatus(STATUS_KEY, undefined);\n publishersBySession.get(ctx.sessionManager)?.update(undefined);\n }\n}\n\nexport function setSyncStatus(\n ctx: SyncStatusContext,\n value: string | undefined,\n presentation?: SyncStatusPresentation,\n) {\n if (!ctx.hasUI || (value !== undefined && enabledBySession.get(ctx.sessionManager) === false)) return;\n ctx.ui.setStatus(STATUS_KEY, value);\n publishersBySession.get(ctx.sessionManager)?.update(value, presentation);\n}\n"],
|
|
5
|
+
"mappings": ";;;;AAGA,IAAM,aAAa;AAgCnB,IAAM,iBAAgE;AAAA,EACpE,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,OAAO;AAAA,EACP,gBAAgB;AAAA,EAChB,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,SAAS;AACX;AAEO,SAAS,wBAAwB,MAAyD;AAC/F,SAAO,OAAO,SAAS,YAAY,OAAO,OAAO,gBAAgB,IAAI,IAAI,eAAe,IAAI,IAAI;AAClG;AAEA,IAAM,mBAAmB,oBAAI,QAAqD;AAClF,IAAM,sBAAsB,oBAAI,QAA2D;AAO3F,SAAS,mBAAmB,cAAsF;AAChH,MAAI,CAAC,aAAc;AACnB,MAAI;AACF,UAAM,EAAE,UAAU,OAAO,IAAI;AAC7B,QAAI,aAAa,WAAW,aAAa,WAAW;AAClD,UAAI,OAAO,WAAW,YAAY,0BAA0B,KAAK,MAAM,IAAI,CAAC,MAAM;AAChF,eAAO,EAAE,UAAU,OAAO;AAAA,IAC9B,WACE;AAAA,MACE;AAAA,MACA;AAAA,MACA;AAAA,MACA;A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;AAAA,QAAC;AAEhB,aAAO;AACP,YAAM,UAAU,KAAK,GAAG;AACxB,aAAO;AAEP,aAAO,eAAe,QAAQ,UAAU,MAAM;AAAA,MAAC;AAAA,IACjD;AAAA,IACA,WAAW,KAAwB;AACjC,aAAO,QAAQ,mBAAmB,IAAI,iBAAiB,OAAO,QAAQ,UAAU,MAAM;AAAA,MAAC;AAAA,IACzF;AAAA,EACF;AACF;AAEO,SAAS,oBAAoB,KAAwB,SAAkB;AAC5E,mBAAiB,IAAI,IAAI,gBAAgB,OAAO;AAChD,MAAI,CAAC,SAAS;AACZ,QAAI,IAAI,MAAO,KAAI,GAAG,UAAU,YAAY,MAAS;AACrD,wBAAoB,IAAI,IAAI,cAAc,GAAG,OAAO,MAAS;AAAA,EAC/D;AACF;AAEO,SAAS,cACd,KACA,OACA,cACA;AACA,MAAI,CAAC,IAAI,SAAU,UAAU,UAAa,iBAAiB,IAAI,IAAI,cAAc,MAAM,MAAQ;AAC/F,MAAI,GAAG,UAAU,YAAY,KAAK;AAClC,sBAAoB,IAAI,IAAI,cAAc,GAAG,OAAO,OAAO,YAAY;AACzE;",
|
|
6
|
+
"names": ["owner"]
|
|
7
|
+
}
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
} from "./chunk-ECYCNZOE.ts";
|
|
6
6
|
import {
|
|
7
7
|
withAgentSyncLock
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-WQMYV4DW.ts";
|
|
9
9
|
import "./chunk-3ST7RSYN.ts";
|
|
10
10
|
import {
|
|
11
11
|
syncErrorGuidance
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
import {
|
|
14
14
|
observationMatchesConfig,
|
|
15
15
|
syncAttentionMatchesConfig
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-REMGB255.ts";
|
|
17
17
|
import {
|
|
18
18
|
parseOptions,
|
|
19
19
|
resolveSyncCommand,
|
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
} from "./chunk-AMJRUXFT.ts";
|
|
28
28
|
import {
|
|
29
29
|
setSyncStatus
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-YIPK23JW.ts";
|
|
31
31
|
import {
|
|
32
32
|
SetupPullRequiresUiError,
|
|
33
33
|
errorMessage,
|
|
@@ -413,8 +413,9 @@ async function handleCommand(rawArgs, ctx, sessionSignal, loaders, attention, on
|
|
|
413
413
|
);
|
|
414
414
|
};
|
|
415
415
|
if (!rawArgs.trim()) {
|
|
416
|
+
attention.expand();
|
|
416
417
|
try {
|
|
417
|
-
const { showSyncManager } = await import("./manager-ui-
|
|
418
|
+
const { showSyncManager } = await import("./manager-ui-AY34N4UY.ts");
|
|
418
419
|
if (sessionSignal.aborted) return;
|
|
419
420
|
await showSyncManager(ctx, run, sessionSignal, {
|
|
420
421
|
getAttention: () => attention.current(),
|
|
@@ -514,7 +515,7 @@ function directSelectionOrigin(rawArgs) {
|
|
|
514
515
|
async function resolveSelectionAttention(ctx, attention, signal, loaders, options = {}) {
|
|
515
516
|
const current = attention.current();
|
|
516
517
|
if (!current || signal.aborted) return;
|
|
517
|
-
const { dispatchManagerResult } = await import("./manager-result-dispatcher-
|
|
518
|
+
const { dispatchManagerResult } = await import("./manager-result-dispatcher-XCYPW7RC.ts");
|
|
518
519
|
if (signal.aborted || attention.current() !== current) return;
|
|
519
520
|
await dispatchManagerResult(
|
|
520
521
|
ctx,
|
|
@@ -545,4 +546,4 @@ export {
|
|
|
545
546
|
handleCommand,
|
|
546
547
|
resolveSelectionAttention
|
|
547
548
|
};
|
|
548
|
-
//# sourceMappingURL=command-handler-
|
|
549
|
+
//# sourceMappingURL=command-handler-MRXE5AKK.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/ui/operation-dialogs.ts", "../../src/commands/command-execution.ts", "../../src/commands/command-handler.ts"],
|
|
4
|
-
"sourcesContent": ["import type { ExtensionContext } from \"@earendil-works/pi-coding-agent\";\n\n/** Track History's Pi-owned selector/confirmation lifetime without inspecting renderer internals. */\nexport function trackOperationDialogs<Context extends ExtensionContext>(\n ctx: Context,\n onDialog?: (active: boolean) => void,\n): Context {\n if (!onDialog) return ctx;\n const runDialog = async <Value>(task: () => Promise<Value>): Promise<Value> => {\n onDialog(true);\n try {\n return await task();\n } finally {\n onDialog(false);\n }\n };\n const ui: ExtensionContext[\"ui\"] = {\n ...ctx.ui,\n select: (...args) => runDialog(() => ctx.ui.select(...args)),\n confirm: (...args) => runDialog(() => ctx.ui.confirm(...args)),\n };\n // Forward live context properties: copying the context would hide session\n // replacement from mutation-owner revalidation after a dialog settles.\n return new Proxy(ctx, {\n get(target, key, receiver) {\n return key === \"ui\" ? ui : Reflect.get(target, key, receiver);\n },\n });\n}\n", "import type { ExtensionCommandContext, ExtensionContext } from \"@earendil-works/pi-coding-agent\";\nimport { loadConfig, sessionTokenWarnings, syncSessionsWarnings } from \"../settings/config.js\";\nimport { activeLocalConfigPath, createLocalConfigDocument, localConfigPath } from \"../settings/config-file.js\";\nimport { localConfigTemplate, readLocalConfigObject } from \"../settings/settings-store.js\";\nimport type { AnySyncConfig } from \"../settings/settings-types.js\";\nimport { unlock, withLock } from \"../state/lock.js\";\nimport { migrateLegacyStateDirectory, stateDirectoryMigrationNotice } from \"../state/state-directory.js\";\nimport { withAgentSyncLock } from \"../sync/agent-sync.js\";\nimport { throwIfAborted } from \"../sync/signals.js\";\nimport { syncErrorGuidance } from \"../sync/sync-error-guidance.js\";\nimport { isSyncDecisionRequiredError, SetupPullRequiresUiError } from \"../sync/sync-errors.js\";\nimport type { SyncLoaders } from \"../sync/sync-loaders.js\";\nimport { RemoteSelectionMismatchError } from \"../sync/sync-policy.js\";\nimport { automaticSyncSummary } from \"../ui/automatic-sync-summary.js\";\nimport type { RunRouteResult } from \"../ui/cancellable-operation.js\";\nimport { trackOperationDialogs } from \"../ui/operation-dialogs.js\";\nimport { startupTransferSummary } from \"../ui/sync-behavior.js\";\nimport { setSyncStatus } from \"../ui/sync-status.js\";\nimport { safeTerminalText } from \"../ui/terminal-text.js\";\nimport { parseOptions, resolveSyncCommand, splitArgs, usage, validateCommandOptions } from \"./command.js\";\nimport type { CommandOptions } from \"./command-types.js\";\n\nexport async function executeRecoveryCommand(\n rawArgs: string,\n ctx: ExtensionContext,\n signal: AbortSignal | undefined,\n loaders: SyncLoaders,\n onCommit?: () => void,\n setup?: string,\n): Promise<RunRouteResult> {\n try {\n const [subcommand, ...rest] = splitArgs(rawArgs);\n if (subcommand !== \"sync\" && subcommand !== \"pull\" && subcommand !== \"push\") {\n throw new Error(`Unsupported sync recovery route: ${subcommand ?? \"missing\"}`);\n }\n const options = parseOptions(rest);\n if (setup !== undefined) options.setup = setup;\n if (signal) options.signal = signal;\n if (onCommit) options.onCommit = onCommit;\n options.reload = false;\n options.auto = false;\n validateCommandOptions(subcommand, options);\n const operations = await loaders.operations();\n throwIfAborted(options.signal);\n if (subcommand === \"push\") {\n const outcome = await withLock(\"push\", () => operations.push(ctx, options));\n return { kind: \"completed\", ...(outcome ? { outcome } : {}) };\n }\n if (subcommand === \"pull\") {\n const outcome = await withLock(\"pull\", () => operations.pull(ctx, options));\n return { kind: \"completed\", ...(outcome ? { outcome } : {}) };\n }\n await withAgentSyncLock(ctx, options, (current) => operations.syncBoth(ctx, current));\n return { kind: \"completed\" };\n } catch (error) {\n if (signal?.aborted) return { kind: \"failed\" };\n setSyncStatus(ctx, undefined);\n if (error instanceof RemoteSelectionMismatchError) {\n return { kind: \"remote-selection-required\", decision: error.decision };\n }\n if (isSyncDecisionRequiredError(error)) {\n return { kind: \"decision-required\", decision: error.decision };\n }\n ctx.ui.notify(syncErrorGuidance(error), \"error\");\n return { kind: \"failed\" };\n }\n}\n\nexport async function executeCommand(\n rawArgs: string,\n ctx: ExtensionCommandContext,\n signal: AbortSignal | undefined,\n loaders: SyncLoaders,\n onCommit?: () => void,\n setup?: string,\n onDialog?: (active: boolean) => void,\n retryRefusal = false,\n): Promise<RunRouteResult> {\n ctx = trackOperationDialogs(ctx, onDialog);\n try {\n const command = await resolveSyncCommand(rawArgs, ctx);\n if (signal?.aborted || !command) return { kind: \"completed\" };\n const { subcommand, rest } = command;\n const options = parseOptions(rest);\n if (setup !== undefined) options.setup = setup;\n if (signal) options.signal = signal;\n if (onCommit) options.onCommit = onCommit;\n validateCommandOptions(subcommand, options);\n if (retryRefusal) {\n if (subcommand !== \"sync\") throw new Error(\"A refused-model retry is available only for merged sync.\");\n options.agentRetryRefusal = true;\n }\n\n switch (subcommand) {\n case \"help\":\n ctx.ui.notify(usage(), \"info\");\n return { kind: \"completed\" };\n case \"use\": {\n const { useSyncSetup } = await loaders.setupSwitch();\n throwIfAborted(options.signal);\n await useSyncSetup(\n ctx,\n options.args[0] ?? \"\",\n async (selectedSetup) => {\n const operations = await loaders.operations();\n throwIfAborted(options.signal);\n return withLock(\"pull\", () => operations.pull(ctx, { ...options, setup: selectedSetup }));\n },\n undefined,\n options.signal,\n );\n return { kind: \"completed\" };\n }\n case \"init\":\n await initConfig(ctx, signal);\n return { kind: \"completed\" };\n case \"config\":\n await showConfig(ctx, options);\n return { kind: \"completed\" };\n case \"files\": {\n const { showFileSelection } = await import(\"../ui/file-selection.js\");\n throwIfAborted(options.signal);\n await showFileSelection(ctx, options.setup, options.signal);\n return { kind: \"completed\" };\n }\n case \"status\": {\n const operations = await loaders.operations();\n throwIfAborted(options.signal);\n await operations.status(ctx, options);\n return { kind: \"completed\" };\n }\n case \"diff\": {\n const operations = await loaders.operations();\n throwIfAborted(options.signal);\n await operations.diff(ctx, options);\n return { kind: \"completed\" };\n }\n case \"conflicts\": {\n const { showConflicts } = await import(\"../sync/conflict-review.js\");\n throwIfAborted(options.signal);\n await withLock(\"sync\", () => showConflicts(ctx, options));\n return { kind: \"completed\" };\n }\n case \"doctor\": {\n const operations = await loaders.operations();\n throwIfAborted(options.signal);\n await operations.doctor(ctx, options);\n return { kind: \"completed\" };\n }\n case \"push\": {\n const operations = await loaders.operations();\n throwIfAborted(options.signal);\n const outcome = await withLock(\"push\", () => operations.push(ctx, options));\n return { kind: \"completed\", ...(outcome ? { outcome } : {}) };\n }\n case \"pull\": {\n const operations = await loaders.operations();\n throwIfAborted(options.signal);\n const outcome = await withLock(\"pull\", () => operations.pull(ctx, options));\n return { kind: \"completed\", ...(outcome ? { outcome } : {}) };\n }\n case \"sync\": {\n const operations = await loaders.operations();\n throwIfAborted(options.signal);\n const outcome = await withAgentSyncLock(ctx, options, (current) => operations.syncBoth(ctx, current));\n return { kind: \"completed\", ...(retryRefusal && outcome ? { outcome } : {}) };\n }\n case \"history\": {\n const operations = await loaders.operations();\n throwIfAborted(options.signal);\n await operations.history(ctx, options);\n return { kind: \"completed\" };\n }\n case \"rollback\": {\n const operations = await loaders.operations();\n throwIfAborted(options.signal);\n await withLock(\"rollback\", () => operations.rollback(ctx, options));\n return { kind: \"completed\" };\n }\n case \"migrate-state\":\n await migrateStateDirectory(ctx, options);\n return { kind: \"completed\" };\n case \"unlock\":\n await unlock(ctx, options);\n return { kind: \"completed\" };\n default:\n ctx.ui.notify(`Unknown /sync command: ${subcommand}\\n\\n${usage()}`, \"warning\");\n return { kind: \"failed\" };\n }\n } catch (error) {\n if (signal?.aborted) return { kind: \"failed\" };\n setSyncStatus(ctx, undefined);\n if (error instanceof SetupPullRequiresUiError) throw error;\n if (error instanceof RemoteSelectionMismatchError) {\n return { kind: \"remote-selection-required\", decision: error.decision };\n }\n if (isSyncDecisionRequiredError(error)) {\n return { kind: \"decision-required\", decision: error.decision };\n }\n ctx.ui.notify(syncErrorGuidance(error), \"error\");\n return { kind: \"failed\" };\n }\n}\n\nasync function migrateStateDirectory(ctx: ExtensionCommandContext, options: CommandOptions) {\n const notice = stateDirectoryMigrationNotice();\n if (!notice) {\n ctx.ui.notify(\"pi-sync already uses the canonical pi-sync/ state directory.\", \"info\");\n return;\n }\n if (\n !options.yes &&\n !(await ctx.ui.confirm(\n \"Migrate pi-sync state directory\",\n \"Confirm that every other Pi process is closed. pi-sync will atomically rename .pisync/ to pi-sync/ without merging or deleting either root.\",\n { signal: options.signal },\n ))\n ) {\n ctx.ui.notify(\"pi-sync state migration cancelled.\", \"info\");\n return;\n }\n throwIfAborted(options.signal);\n const result = await migrateLegacyStateDirectory();\n throwIfAborted(options.signal);\n if (result.status === \"ready\") {\n ctx.ui.notify(\"pi-sync already uses the canonical pi-sync/ state directory.\", \"info\");\n return;\n }\n ctx.ui.notify(result.message, result.status === \"migrated\" ? \"info\" : \"warning\");\n}\n\nasync function initConfig(ctx: ExtensionCommandContext, signal?: AbortSignal) {\n const configPath = localConfigPath();\n const existing = await readLocalConfigObject();\n throwIfAborted(signal);\n if (existing) {\n const activePath = await activeLocalConfigPath();\n throwIfAborted(signal);\n ctx.ui.notify(`Config already exists: ${activePath}`, \"info\");\n return;\n }\n\n if (ctx.mode === \"tui\") {\n const { showSetupWizard } = await import(\"../ui/setup/setup-wizard.js\");\n throwIfAborted(signal);\n await showSetupWizard(ctx, signal);\n return;\n }\n await createLocalConfigDocument(localConfigTemplate(), signal);\n throwIfAborted(signal);\n ctx.ui.notify(`Created ${configPath}. Add a storage connection and sync setup before syncing.`, \"info\");\n}\n\nasync function showConfig(ctx: ExtensionCommandContext, options: CommandOptions) {\n const config = await loadConfig(options.setup);\n const warnings = [\n ...(config.backend.type === \"s3\" ? sessionTokenWarnings(config.backend.profile) : []),\n ...syncSessionsWarnings(config),\n ];\n const storageLines = configStorageLines(config);\n ctx.ui.notify(\n [\n \"pi-sync config:\",\n `sync setup: ${config.setupName}`,\n `storage connection: ${config.connectionName}`,\n ...storageLines,\n `storage path: ${config.storagePath}`,\n `automatic sync: ${automaticSyncSummary(config.automatic)}`,\n `settings field merge: ${config.mergeSettings ? \"On\" : \"Off\"}`,\n `machine-local settings.json fields: ${(config.localFields ?? []).map(safeTerminalText).join(\", \") || \"none\"}`,\n `startup transfer: ${startupTransferSummary(config)}`,\n `autonomous sync: ${config.agentMode ? \"On\" : \"Off\"}`,\n `continuous sync: ${config.continuous ? (config.agentMode ? \"On\" : \"paused; Autonomous sync is Off\") : \"Off\"}`,\n `included content: ${config.include.join(\", \") || \"none\"}`,\n `sessions: ${config.include.includes(\"sessions\") ? \"included\" : \"not included\"}`,\n `settings file: ${localConfigPath()}`,\n ...warnings,\n ].join(\"\\n\"),\n warnings.length > 0 ? \"warning\" : \"info\",\n );\n}\n\nfunction configStorageLines(config: AnySyncConfig) {\n switch (config.backend.type) {\n case \"git\":\n return [\n \"kind: git\",\n `remote: ${displayGitRemote(config.backend.profile.remote)}`,\n \"authentication: existing Git/SSH credentials (not stored)\",\n `branch: ${config.backend.destination.branch}`,\n ];\n case \"webdav\":\n return [\n \"kind: webdav\",\n `url: ${displayWebDavUrl(config.backend.profile.url, config.backend.profile.username)}`,\n \"username: configured (value hidden)\",\n \"password: configured\",\n ];\n case \"s3\":\n return [\n \"kind: s3\",\n `endpoint: ${config.backend.profile.endpoint}`,\n `bucket: ${config.backend.destination.bucket}`,\n `region: ${config.backend.profile.region}`,\n \"access key id: configured\",\n \"secret access key: configured\",\n `session token: ${config.backend.profile.sessionToken ? \"configured\" : \"not configured\"}`,\n ];\n }\n}\n\nfunction displayGitRemote(value: string | undefined) {\n if (!value) return \"missing\";\n try {\n const url = new URL(value);\n url.username = \"\";\n url.password = \"\";\n url.search = \"\";\n url.hash = \"\";\n return url.toString();\n } catch {\n return value.replace(/^(?:[^@\\s]+@)?(?<host>[^:]+):.+$/u, \"$<host>:\u2026\");\n }\n}\n\nfunction displayWebDavUrl(value: string | undefined, username: string | undefined) {\n if (!value) return \"missing\";\n try {\n const url = new URL(value);\n url.username = \"\";\n url.password = \"\";\n url.search = \"\";\n url.hash = \"\";\n return username ? `${url.origin}/\u2026` : `${url.origin}${url.pathname}`;\n } catch {\n return \"invalid (value hidden)\";\n }\n}\n", "import type { ExtensionCommandContext, ExtensionContext } from \"@earendil-works/pi-coding-agent\";\nimport { loadConfig } from \"../settings/config.js\";\nimport { readStateForConfig, syncStateFingerprint } from \"../state/sync-state-store.js\";\nimport { combineSignals } from \"../sync/signals.js\";\nimport { errorMessage } from \"../sync/sync-errors.js\";\nimport type { SyncLoaders } from \"../sync/sync-loaders.js\";\nimport { formatRemoteSelectionMismatch } from \"../sync/sync-policy.js\";\nimport type { RunRouteResult } from \"../ui/cancellable-operation.js\";\nimport {\n observationMatchesConfig,\n type SyncAttentionController,\n type SyncAttentionOrigin,\n syncAttentionMatchesConfig,\n} from \"../ui/sync-attention.js\";\nimport { setSyncStatus } from \"../ui/sync-status.js\";\nimport { parseOptions, splitArgs, validateCommandOptions } from \"./command.js\";\nimport { executeCommand, executeRecoveryCommand } from \"./command-execution.js\";\n\nexport async function handleCommand(\n rawArgs: string,\n ctx: ExtensionCommandContext,\n sessionSignal: AbortSignal,\n loaders: SyncLoaders,\n attention: SyncAttentionController,\n onExplicitSync?: (setup?: string) => void,\n) {\n await reconcileObservation(attention, sessionSignal);\n if (sessionSignal.aborted) return;\n const run = (\n route: string,\n signal?: AbortSignal,\n onCommit?: () => void,\n target?: string,\n onDialog?: (active: boolean) => void,\n retryRefusal = false,\n ) => {\n const [command, ...args] = splitArgs(route);\n if (command === \"sync\" && !retryRefusal) {\n try {\n const options = parseOptions(args);\n validateCommandOptions(\"sync\", options);\n onExplicitSync?.(target ?? options.setup);\n } catch {\n /* Invalid routes do not request an automatic retry. */\n }\n }\n return executeCommand(\n route,\n ctx,\n combineSignals(sessionSignal, signal),\n loaders,\n observationCommitCallback(attention, sessionSignal, onCommit),\n target,\n onDialog,\n retryRefusal,\n );\n };\n if (!rawArgs.trim()) {\n try {\n const { showSyncManager } = await import(\"../ui/manager-ui.js\");\n if (sessionSignal.aborted) return;\n await showSyncManager(ctx, run, sessionSignal, {\n getAttention: () => attention.current(),\n getObservation: () => attention.observation(),\n onObservationInvalidated: () => attention.clearObservation(),\n onSelectionResolved: (expected) => {\n if (attention.current() === expected) attention.clear(ctx);\n },\n });\n } catch (error) {\n if (sessionSignal.aborted) return;\n setSyncStatus(ctx, undefined);\n ctx.ui.notify(errorMessage(error), \"error\");\n }\n await reconcileObservation(attention, sessionSignal);\n if (!sessionSignal.aborted) await attention.publish(ctx, sessionSignal);\n return;\n }\n const result = await run(rawArgs);\n if (result.kind === \"decision-required\") {\n ctx.ui.notify(result.decision.directMessage, \"error\");\n } else if (result.kind === \"remote-selection-required\") {\n const origin = directSelectionOrigin(rawArgs);\n if (origin) attention.set(result.decision, origin);\n const deterministic = splitArgs(rawArgs).some((arg) => arg === \"--yes\" || arg === \"-y\");\n if (origin && ctx.mode === \"tui\" && !deterministic) {\n await resolveSelectionAttention(ctx, attention, sessionSignal, loaders);\n } else {\n ctx.ui.notify(\n formatRemoteSelectionMismatch(\n result.decision.setupName,\n result.decision.localInclude,\n result.decision.remoteInclude,\n ),\n \"error\",\n );\n }\n }\n await clearAttentionAfterCompletedOperation(rawArgs, result, ctx, attention, sessionSignal);\n await reconcileSelectionAttention(ctx, attention, sessionSignal);\n await reconcileObservation(attention, sessionSignal);\n if (!sessionSignal.aborted) await attention.publish(ctx, sessionSignal);\n}\n\nfunction observationCommitCallback(\n attention: SyncAttentionController,\n sessionSignal: AbortSignal,\n onCommit?: () => void,\n) {\n const observed = attention.observation();\n return () => {\n // Opening or cancelling a review changes nothing. A commit may change data\n // even if later publication/baseline cleanup fails; never restore old hints.\n if (!sessionSignal.aborted && attention.observation() === observed) attention.clearObservation();\n onCommit?.();\n };\n}\n\nasync function reconcileObservation(attention: SyncAttentionController, signal: AbortSignal) {\n const observed = attention.observation();\n if (!observed || signal.aborted) return;\n try {\n const config = await loadConfig();\n if (signal.aborted || attention.observation() !== observed) return;\n if (!observationMatchesConfig(observed, config)) {\n attention.clearObservation();\n return;\n }\n const state = await readStateForConfig(config);\n if (signal.aborted || attention.observation() !== observed) return;\n if (syncStateFingerprint(state) !== observed.inspection.stateIdentity) attention.clearObservation();\n } catch {\n if (!signal.aborted && attention.observation() === observed) attention.clearObservation();\n }\n}\n\nasync function clearAttentionAfterCompletedOperation(\n rawArgs: string,\n result: RunRouteResult,\n ctx: ExtensionContext,\n attention: SyncAttentionController,\n signal: AbortSignal,\n) {\n if (result.kind !== \"completed\" || result.outcome === \"cancelled\" || signal.aborted) return;\n const [command, ...rest] = splitArgs(rawArgs);\n if (command !== \"sync\" && command !== \"pull\" && command !== \"push\") return;\n const current = attention.current();\n if (!current) return;\n try {\n const options = parseOptions(rest);\n const setupName = options.setup ?? (await loadConfig()).setupName;\n if (signal.aborted || attention.current() !== current) return;\n if (current.decision.setupName === setupName) attention.clear(ctx);\n } catch {\n // Attention reconciliation below owns malformed or concurrently changed settings.\n }\n}\n\nasync function reconcileSelectionAttention(\n ctx: ExtensionContext,\n attention: SyncAttentionController,\n signal: AbortSignal,\n) {\n const current = attention.current();\n if (!current || signal.aborted) return;\n try {\n const config = await loadConfig(current.decision.setupName);\n if (signal.aborted || attention.current() !== current) return;\n if (!syncAttentionMatchesConfig(current, config)) attention.clear(ctx);\n } catch {\n if (!signal.aborted && attention.current() === current) attention.clear(ctx);\n }\n}\n\nfunction directSelectionOrigin(rawArgs: string): SyncAttentionOrigin | undefined {\n const command = splitArgs(rawArgs)[0];\n return command === \"sync\" || command === \"pull\" || command === \"push\" ? command : undefined;\n}\n\nexport async function resolveSelectionAttention(\n ctx: ExtensionContext,\n attention: SyncAttentionController,\n signal: AbortSignal,\n loaders: SyncLoaders,\n options: {\n cancelLabel?: string;\n withStateAccess?: <T>(task: () => Promise<T>) => Promise<T>;\n } = {},\n) {\n const current = attention.current();\n if (!current || signal.aborted) return;\n const { dispatchManagerResult } = await import(\"../ui/manager-result-dispatcher.js\");\n if (signal.aborted || attention.current() !== current) return;\n await dispatchManagerResult(\n ctx,\n { kind: \"remote-selection-required\", decision: current.decision },\n current.origin,\n (route, actionSignal, onCommit, target) => {\n const execute = () =>\n executeRecoveryCommand(\n route,\n ctx,\n combineSignals(signal, actionSignal),\n loaders,\n observationCommitCallback(attention, signal, onCommit),\n target,\n );\n return options.withStateAccess ? options.withStateAccess(execute) : execute();\n },\n signal,\n {\n cancelLabel: options.cancelLabel,\n withStateAccess: options.withStateAccess,\n onSelectionResolved: () => {\n if (attention.current() === current) attention.clear(ctx);\n },\n },\n );\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGO,SAAS,sBACd,KACA,UACS;AACT,MAAI,CAAC,SAAU,QAAO;AACtB,QAAM,YAAY,OAAc,SAA+C;AAC7E,aAAS,IAAI;AACb,QAAI;AACF,aAAO,MAAM,KAAK;AAAA,IACpB,UAAE;AACA,eAAS,KAAK;AAAA,IAChB;AAAA,EACF;AACA,QAAM,KAA6B;AAAA,IACjC,GAAG,IAAI;AAAA,IACP,QAAQ,IAAI,SAAS,UAAU,MAAM,IAAI,GAAG,OAAO,GAAG,IAAI,CAAC;AAAA,IAC3D,SAAS,IAAI,SAAS,UAAU,MAAM,IAAI,GAAG,QAAQ,GAAG,IAAI,CAAC;AAAA,EAC/D;AAGA,SAAO,IAAI,MAAM,KAAK;AAAA,IACpB,IAAI,QAAQ,KAAK,UAAU;AACzB,aAAO,QAAQ,OAAO,KAAK,QAAQ,IAAI,QAAQ,KAAK,QAAQ;AAAA,IAC9D;AAAA,EACF,CAAC;AACH;;;ACNA,eAAsB,uBACpB,SACA,KACA,QACA,SACA,UACA,OACyB;AACzB,MAAI;AACF,UAAM,CAAC,YAAY,GAAG,IAAI,IAAI,UAAU,OAAO;AAC/C,QAAI,eAAe,UAAU,eAAe,UAAU,eAAe,QAAQ;AAC3E,YAAM,IAAI,MAAM,oCAAoC,cAAc,SAAS,EAAE;AAAA,IAC/E;AACA,UAAM,UAAU,aAAa,IAAI;AACjC,QAAI,UAAU,OAAW,SAAQ,QAAQ;AACzC,QAAI,OAAQ,SAAQ,SAAS;AAC7B,QAAI,SAAU,SAAQ,WAAW;AACjC,YAAQ,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AQ;AAAA,IACR,CAAC,OAAO,cAAc,UAAU,WAAW;AACzC,YAAM,UAAU,MACd;AAAA,QACE;AAAA,QACA;AAAA,QACA,eAAe,QAAQ,YAAY;AAAA,QACnC;AAAA,QACA,0BAA0B,WAAW,QAAQ,QAAQ;AAAA,QACrD;AAAA,MACF;AACF,aAAO,QAAQ,kBAAkB,QAAQ,gBAAgB,OAAO,IAAI,QAAQ;AAAA,IAC9E;AAAA,IACA;AAAA,IACA;AAAA,MACE,aAAa,QAAQ;AAAA,MACrB,iBAAiB,QAAQ;AAAA,MACzB,qBAAqB,MAAM;AACzB,YAAI,UAAU,QAAQ,MAAM,QAAS,WAAU,MAAM,GAAG;AAAA,MAC1D;AAAA,IACF;AAAA,EACF;AACF;",
|
|
4
|
+
"sourcesContent": ["import type { ExtensionContext } from \"@earendil-works/pi-coding-agent\";\n\n/** Track History's Pi-owned selector/confirmation lifetime without inspecting renderer internals. */\nexport function trackOperationDialogs<Context extends ExtensionContext>(\n ctx: Context,\n onDialog?: (active: boolean) => void,\n): Context {\n if (!onDialog) return ctx;\n const runDialog = async <Value>(task: () => Promise<Value>): Promise<Value> => {\n onDialog(true);\n try {\n return await task();\n } finally {\n onDialog(false);\n }\n };\n const ui: ExtensionContext[\"ui\"] = {\n ...ctx.ui,\n select: (...args) => runDialog(() => ctx.ui.select(...args)),\n confirm: (...args) => runDialog(() => ctx.ui.confirm(...args)),\n };\n // Forward live context properties: copying the context would hide session\n // replacement from mutation-owner revalidation after a dialog settles.\n return new Proxy(ctx, {\n get(target, key, receiver) {\n return key === \"ui\" ? ui : Reflect.get(target, key, receiver);\n },\n });\n}\n", "import type { ExtensionCommandContext, ExtensionContext } from \"@earendil-works/pi-coding-agent\";\nimport { loadConfig, sessionTokenWarnings, syncSessionsWarnings } from \"../settings/config.js\";\nimport { activeLocalConfigPath, createLocalConfigDocument, localConfigPath } from \"../settings/config-file.js\";\nimport { localConfigTemplate, readLocalConfigObject } from \"../settings/settings-store.js\";\nimport type { AnySyncConfig } from \"../settings/settings-types.js\";\nimport { unlock, withLock } from \"../state/lock.js\";\nimport { migrateLegacyStateDirectory, stateDirectoryMigrationNotice } from \"../state/state-directory.js\";\nimport { withAgentSyncLock } from \"../sync/agent-sync.js\";\nimport { throwIfAborted } from \"../sync/signals.js\";\nimport { syncErrorGuidance } from \"../sync/sync-error-guidance.js\";\nimport { isSyncDecisionRequiredError, SetupPullRequiresUiError } from \"../sync/sync-errors.js\";\nimport type { SyncLoaders } from \"../sync/sync-loaders.js\";\nimport { RemoteSelectionMismatchError } from \"../sync/sync-policy.js\";\nimport { automaticSyncSummary } from \"../ui/automatic-sync-summary.js\";\nimport type { RunRouteResult } from \"../ui/cancellable-operation.js\";\nimport { trackOperationDialogs } from \"../ui/operation-dialogs.js\";\nimport { startupTransferSummary } from \"../ui/sync-behavior.js\";\nimport { setSyncStatus } from \"../ui/sync-status.js\";\nimport { safeTerminalText } from \"../ui/terminal-text.js\";\nimport { parseOptions, resolveSyncCommand, splitArgs, usage, validateCommandOptions } from \"./command.js\";\nimport type { CommandOptions } from \"./command-types.js\";\n\nexport async function executeRecoveryCommand(\n rawArgs: string,\n ctx: ExtensionContext,\n signal: AbortSignal | undefined,\n loaders: SyncLoaders,\n onCommit?: () => void,\n setup?: string,\n): Promise<RunRouteResult> {\n try {\n const [subcommand, ...rest] = splitArgs(rawArgs);\n if (subcommand !== \"sync\" && subcommand !== \"pull\" && subcommand !== \"push\") {\n throw new Error(`Unsupported sync recovery route: ${subcommand ?? \"missing\"}`);\n }\n const options = parseOptions(rest);\n if (setup !== undefined) options.setup = setup;\n if (signal) options.signal = signal;\n if (onCommit) options.onCommit = onCommit;\n options.reload = false;\n options.auto = false;\n validateCommandOptions(subcommand, options);\n const operations = await loaders.operations();\n throwIfAborted(options.signal);\n if (subcommand === \"push\") {\n const outcome = await withLock(\"push\", () => operations.push(ctx, options));\n return { kind: \"completed\", ...(outcome ? { outcome } : {}) };\n }\n if (subcommand === \"pull\") {\n const outcome = await withLock(\"pull\", () => operations.pull(ctx, options));\n return { kind: \"completed\", ...(outcome ? { outcome } : {}) };\n }\n await withAgentSyncLock(ctx, options, (current) => operations.syncBoth(ctx, current));\n return { kind: \"completed\" };\n } catch (error) {\n if (signal?.aborted) return { kind: \"failed\" };\n setSyncStatus(ctx, undefined);\n if (error instanceof RemoteSelectionMismatchError) {\n return { kind: \"remote-selection-required\", decision: error.decision };\n }\n if (isSyncDecisionRequiredError(error)) {\n return { kind: \"decision-required\", decision: error.decision };\n }\n ctx.ui.notify(syncErrorGuidance(error), \"error\");\n return { kind: \"failed\" };\n }\n}\n\nexport async function executeCommand(\n rawArgs: string,\n ctx: ExtensionCommandContext,\n signal: AbortSignal | undefined,\n loaders: SyncLoaders,\n onCommit?: () => void,\n setup?: string,\n onDialog?: (active: boolean) => void,\n retryRefusal = false,\n): Promise<RunRouteResult> {\n ctx = trackOperationDialogs(ctx, onDialog);\n try {\n const command = await resolveSyncCommand(rawArgs, ctx);\n if (signal?.aborted || !command) return { kind: \"completed\" };\n const { subcommand, rest } = command;\n const options = parseOptions(rest);\n if (setup !== undefined) options.setup = setup;\n if (signal) options.signal = signal;\n if (onCommit) options.onCommit = onCommit;\n validateCommandOptions(subcommand, options);\n if (retryRefusal) {\n if (subcommand !== \"sync\") throw new Error(\"A refused-model retry is available only for merged sync.\");\n options.agentRetryRefusal = true;\n }\n\n switch (subcommand) {\n case \"help\":\n ctx.ui.notify(usage(), \"info\");\n return { kind: \"completed\" };\n case \"use\": {\n const { useSyncSetup } = await loaders.setupSwitch();\n throwIfAborted(options.signal);\n await useSyncSetup(\n ctx,\n options.args[0] ?? \"\",\n async (selectedSetup) => {\n const operations = await loaders.operations();\n throwIfAborted(options.signal);\n return withLock(\"pull\", () => operations.pull(ctx, { ...options, setup: selectedSetup }));\n },\n undefined,\n options.signal,\n );\n return { kind: \"completed\" };\n }\n case \"init\":\n await initConfig(ctx, signal);\n return { kind: \"completed\" };\n case \"config\":\n await showConfig(ctx, options);\n return { kind: \"completed\" };\n case \"files\": {\n const { showFileSelection } = await import(\"../ui/file-selection.js\");\n throwIfAborted(options.signal);\n await showFileSelection(ctx, options.setup, options.signal);\n return { kind: \"completed\" };\n }\n case \"status\": {\n const operations = await loaders.operations();\n throwIfAborted(options.signal);\n await operations.status(ctx, options);\n return { kind: \"completed\" };\n }\n case \"diff\": {\n const operations = await loaders.operations();\n throwIfAborted(options.signal);\n await operations.diff(ctx, options);\n return { kind: \"completed\" };\n }\n case \"conflicts\": {\n const { showConflicts } = await import(\"../sync/conflict-review.js\");\n throwIfAborted(options.signal);\n await withLock(\"sync\", () => showConflicts(ctx, options));\n return { kind: \"completed\" };\n }\n case \"doctor\": {\n const operations = await loaders.operations();\n throwIfAborted(options.signal);\n await operations.doctor(ctx, options);\n return { kind: \"completed\" };\n }\n case \"push\": {\n const operations = await loaders.operations();\n throwIfAborted(options.signal);\n const outcome = await withLock(\"push\", () => operations.push(ctx, options));\n return { kind: \"completed\", ...(outcome ? { outcome } : {}) };\n }\n case \"pull\": {\n const operations = await loaders.operations();\n throwIfAborted(options.signal);\n const outcome = await withLock(\"pull\", () => operations.pull(ctx, options));\n return { kind: \"completed\", ...(outcome ? { outcome } : {}) };\n }\n case \"sync\": {\n const operations = await loaders.operations();\n throwIfAborted(options.signal);\n const outcome = await withAgentSyncLock(ctx, options, (current) => operations.syncBoth(ctx, current));\n return { kind: \"completed\", ...(retryRefusal && outcome ? { outcome } : {}) };\n }\n case \"history\": {\n const operations = await loaders.operations();\n throwIfAborted(options.signal);\n await operations.history(ctx, options);\n return { kind: \"completed\" };\n }\n case \"rollback\": {\n const operations = await loaders.operations();\n throwIfAborted(options.signal);\n await withLock(\"rollback\", () => operations.rollback(ctx, options));\n return { kind: \"completed\" };\n }\n case \"migrate-state\":\n await migrateStateDirectory(ctx, options);\n return { kind: \"completed\" };\n case \"unlock\":\n await unlock(ctx, options);\n return { kind: \"completed\" };\n default:\n ctx.ui.notify(`Unknown /sync command: ${subcommand}\\n\\n${usage()}`, \"warning\");\n return { kind: \"failed\" };\n }\n } catch (error) {\n if (signal?.aborted) return { kind: \"failed\" };\n setSyncStatus(ctx, undefined);\n if (error instanceof SetupPullRequiresUiError) throw error;\n if (error instanceof RemoteSelectionMismatchError) {\n return { kind: \"remote-selection-required\", decision: error.decision };\n }\n if (isSyncDecisionRequiredError(error)) {\n return { kind: \"decision-required\", decision: error.decision };\n }\n ctx.ui.notify(syncErrorGuidance(error), \"error\");\n return { kind: \"failed\" };\n }\n}\n\nasync function migrateStateDirectory(ctx: ExtensionCommandContext, options: CommandOptions) {\n const notice = stateDirectoryMigrationNotice();\n if (!notice) {\n ctx.ui.notify(\"pi-sync already uses the canonical pi-sync/ state directory.\", \"info\");\n return;\n }\n if (\n !options.yes &&\n !(await ctx.ui.confirm(\n \"Migrate pi-sync state directory\",\n \"Confirm that every other Pi process is closed. pi-sync will atomically rename .pisync/ to pi-sync/ without merging or deleting either root.\",\n { signal: options.signal },\n ))\n ) {\n ctx.ui.notify(\"pi-sync state migration cancelled.\", \"info\");\n return;\n }\n throwIfAborted(options.signal);\n const result = await migrateLegacyStateDirectory();\n throwIfAborted(options.signal);\n if (result.status === \"ready\") {\n ctx.ui.notify(\"pi-sync already uses the canonical pi-sync/ state directory.\", \"info\");\n return;\n }\n ctx.ui.notify(result.message, result.status === \"migrated\" ? \"info\" : \"warning\");\n}\n\nasync function initConfig(ctx: ExtensionCommandContext, signal?: AbortSignal) {\n const configPath = localConfigPath();\n const existing = await readLocalConfigObject();\n throwIfAborted(signal);\n if (existing) {\n const activePath = await activeLocalConfigPath();\n throwIfAborted(signal);\n ctx.ui.notify(`Config already exists: ${activePath}`, \"info\");\n return;\n }\n\n if (ctx.mode === \"tui\") {\n const { showSetupWizard } = await import(\"../ui/setup/setup-wizard.js\");\n throwIfAborted(signal);\n await showSetupWizard(ctx, signal);\n return;\n }\n await createLocalConfigDocument(localConfigTemplate(), signal);\n throwIfAborted(signal);\n ctx.ui.notify(`Created ${configPath}. Add a storage connection and sync setup before syncing.`, \"info\");\n}\n\nasync function showConfig(ctx: ExtensionCommandContext, options: CommandOptions) {\n const config = await loadConfig(options.setup);\n const warnings = [\n ...(config.backend.type === \"s3\" ? sessionTokenWarnings(config.backend.profile) : []),\n ...syncSessionsWarnings(config),\n ];\n const storageLines = configStorageLines(config);\n ctx.ui.notify(\n [\n \"pi-sync config:\",\n `sync setup: ${config.setupName}`,\n `storage connection: ${config.connectionName}`,\n ...storageLines,\n `storage path: ${config.storagePath}`,\n `automatic sync: ${automaticSyncSummary(config.automatic)}`,\n `settings field merge: ${config.mergeSettings ? \"On\" : \"Off\"}`,\n `machine-local settings.json fields: ${(config.localFields ?? []).map(safeTerminalText).join(\", \") || \"none\"}`,\n `startup transfer: ${startupTransferSummary(config)}`,\n `autonomous sync: ${config.agentMode ? \"On\" : \"Off\"}`,\n `continuous sync: ${config.continuous ? (config.agentMode ? \"On\" : \"paused; Autonomous sync is Off\") : \"Off\"}`,\n `included content: ${config.include.join(\", \") || \"none\"}`,\n `sessions: ${config.include.includes(\"sessions\") ? \"included\" : \"not included\"}`,\n `settings file: ${localConfigPath()}`,\n ...warnings,\n ].join(\"\\n\"),\n warnings.length > 0 ? \"warning\" : \"info\",\n );\n}\n\nfunction configStorageLines(config: AnySyncConfig) {\n switch (config.backend.type) {\n case \"git\":\n return [\n \"kind: git\",\n `remote: ${displayGitRemote(config.backend.profile.remote)}`,\n \"authentication: existing Git/SSH credentials (not stored)\",\n `branch: ${config.backend.destination.branch}`,\n ];\n case \"webdav\":\n return [\n \"kind: webdav\",\n `url: ${displayWebDavUrl(config.backend.profile.url, config.backend.profile.username)}`,\n \"username: configured (value hidden)\",\n \"password: configured\",\n ];\n case \"s3\":\n return [\n \"kind: s3\",\n `endpoint: ${config.backend.profile.endpoint}`,\n `bucket: ${config.backend.destination.bucket}`,\n `region: ${config.backend.profile.region}`,\n \"access key id: configured\",\n \"secret access key: configured\",\n `session token: ${config.backend.profile.sessionToken ? \"configured\" : \"not configured\"}`,\n ];\n }\n}\n\nfunction displayGitRemote(value: string | undefined) {\n if (!value) return \"missing\";\n try {\n const url = new URL(value);\n url.username = \"\";\n url.password = \"\";\n url.search = \"\";\n url.hash = \"\";\n return url.toString();\n } catch {\n return value.replace(/^(?:[^@\\s]+@)?(?<host>[^:]+):.+$/u, \"$<host>:\u2026\");\n }\n}\n\nfunction displayWebDavUrl(value: string | undefined, username: string | undefined) {\n if (!value) return \"missing\";\n try {\n const url = new URL(value);\n url.username = \"\";\n url.password = \"\";\n url.search = \"\";\n url.hash = \"\";\n return username ? `${url.origin}/\u2026` : `${url.origin}${url.pathname}`;\n } catch {\n return \"invalid (value hidden)\";\n }\n}\n", "import type { ExtensionCommandContext, ExtensionContext } from \"@earendil-works/pi-coding-agent\";\nimport { loadConfig } from \"../settings/config.js\";\nimport { readStateForConfig, syncStateFingerprint } from \"../state/sync-state-store.js\";\nimport { combineSignals } from \"../sync/signals.js\";\nimport { errorMessage } from \"../sync/sync-errors.js\";\nimport type { SyncLoaders } from \"../sync/sync-loaders.js\";\nimport { formatRemoteSelectionMismatch } from \"../sync/sync-policy.js\";\nimport type { RunRouteResult } from \"../ui/cancellable-operation.js\";\nimport {\n observationMatchesConfig,\n type SyncAttentionController,\n type SyncAttentionOrigin,\n syncAttentionMatchesConfig,\n} from \"../ui/sync-attention.js\";\nimport { setSyncStatus } from \"../ui/sync-status.js\";\nimport { parseOptions, splitArgs, validateCommandOptions } from \"./command.js\";\nimport { executeCommand, executeRecoveryCommand } from \"./command-execution.js\";\n\nexport async function handleCommand(\n rawArgs: string,\n ctx: ExtensionCommandContext,\n sessionSignal: AbortSignal,\n loaders: SyncLoaders,\n attention: SyncAttentionController,\n onExplicitSync?: (setup?: string) => void,\n) {\n await reconcileObservation(attention, sessionSignal);\n if (sessionSignal.aborted) return;\n const run = (\n route: string,\n signal?: AbortSignal,\n onCommit?: () => void,\n target?: string,\n onDialog?: (active: boolean) => void,\n retryRefusal = false,\n ) => {\n const [command, ...args] = splitArgs(route);\n if (command === \"sync\" && !retryRefusal) {\n try {\n const options = parseOptions(args);\n validateCommandOptions(\"sync\", options);\n onExplicitSync?.(target ?? options.setup);\n } catch {\n /* Invalid routes do not request an automatic retry. */\n }\n }\n return executeCommand(\n route,\n ctx,\n combineSignals(sessionSignal, signal),\n loaders,\n observationCommitCallback(attention, sessionSignal, onCommit),\n target,\n onDialog,\n retryRefusal,\n );\n };\n if (!rawArgs.trim()) {\n attention.expand();\n try {\n const { showSyncManager } = await import(\"../ui/manager-ui.js\");\n if (sessionSignal.aborted) return;\n await showSyncManager(ctx, run, sessionSignal, {\n getAttention: () => attention.current(),\n getObservation: () => attention.observation(),\n onObservationInvalidated: () => attention.clearObservation(),\n onSelectionResolved: (expected) => {\n if (attention.current() === expected) attention.clear(ctx);\n },\n });\n } catch (error) {\n if (sessionSignal.aborted) return;\n setSyncStatus(ctx, undefined);\n ctx.ui.notify(errorMessage(error), \"error\");\n }\n await reconcileObservation(attention, sessionSignal);\n if (!sessionSignal.aborted) await attention.publish(ctx, sessionSignal);\n return;\n }\n const result = await run(rawArgs);\n if (result.kind === \"decision-required\") {\n ctx.ui.notify(result.decision.directMessage, \"error\");\n } else if (result.kind === \"remote-selection-required\") {\n const origin = directSelectionOrigin(rawArgs);\n if (origin) attention.set(result.decision, origin);\n const deterministic = splitArgs(rawArgs).some((arg) => arg === \"--yes\" || arg === \"-y\");\n if (origin && ctx.mode === \"tui\" && !deterministic) {\n await resolveSelectionAttention(ctx, attention, sessionSignal, loaders);\n } else {\n ctx.ui.notify(\n formatRemoteSelectionMismatch(\n result.decision.setupName,\n result.decision.localInclude,\n result.decision.remoteInclude,\n ),\n \"error\",\n );\n }\n }\n await clearAttentionAfterCompletedOperation(rawArgs, result, ctx, attention, sessionSignal);\n await reconcileSelectionAttention(ctx, attention, sessionSignal);\n await reconcileObservation(attention, sessionSignal);\n if (!sessionSignal.aborted) await attention.publish(ctx, sessionSignal);\n}\n\nfunction observationCommitCallback(\n attention: SyncAttentionController,\n sessionSignal: AbortSignal,\n onCommit?: () => void,\n) {\n const observed = attention.observation();\n return () => {\n // Opening or cancelling a review changes nothing. A commit may change data\n // even if later publication/baseline cleanup fails; never restore old hints.\n if (!sessionSignal.aborted && attention.observation() === observed) attention.clearObservation();\n onCommit?.();\n };\n}\n\nasync function reconcileObservation(attention: SyncAttentionController, signal: AbortSignal) {\n const observed = attention.observation();\n if (!observed || signal.aborted) return;\n try {\n const config = await loadConfig();\n if (signal.aborted || attention.observation() !== observed) return;\n if (!observationMatchesConfig(observed, config)) {\n attention.clearObservation();\n return;\n }\n const state = await readStateForConfig(config);\n if (signal.aborted || attention.observation() !== observed) return;\n if (syncStateFingerprint(state) !== observed.inspection.stateIdentity) attention.clearObservation();\n } catch {\n if (!signal.aborted && attention.observation() === observed) attention.clearObservation();\n }\n}\n\nasync function clearAttentionAfterCompletedOperation(\n rawArgs: string,\n result: RunRouteResult,\n ctx: ExtensionContext,\n attention: SyncAttentionController,\n signal: AbortSignal,\n) {\n if (result.kind !== \"completed\" || result.outcome === \"cancelled\" || signal.aborted) return;\n const [command, ...rest] = splitArgs(rawArgs);\n if (command !== \"sync\" && command !== \"pull\" && command !== \"push\") return;\n const current = attention.current();\n if (!current) return;\n try {\n const options = parseOptions(rest);\n const setupName = options.setup ?? (await loadConfig()).setupName;\n if (signal.aborted || attention.current() !== current) return;\n if (current.decision.setupName === setupName) attention.clear(ctx);\n } catch {\n // Attention reconciliation below owns malformed or concurrently changed settings.\n }\n}\n\nasync function reconcileSelectionAttention(\n ctx: ExtensionContext,\n attention: SyncAttentionController,\n signal: AbortSignal,\n) {\n const current = attention.current();\n if (!current || signal.aborted) return;\n try {\n const config = await loadConfig(current.decision.setupName);\n if (signal.aborted || attention.current() !== current) return;\n if (!syncAttentionMatchesConfig(current, config)) attention.clear(ctx);\n } catch {\n if (!signal.aborted && attention.current() === current) attention.clear(ctx);\n }\n}\n\nfunction directSelectionOrigin(rawArgs: string): SyncAttentionOrigin | undefined {\n const command = splitArgs(rawArgs)[0];\n return command === \"sync\" || command === \"pull\" || command === \"push\" ? command : undefined;\n}\n\nexport async function resolveSelectionAttention(\n ctx: ExtensionContext,\n attention: SyncAttentionController,\n signal: AbortSignal,\n loaders: SyncLoaders,\n options: {\n cancelLabel?: string;\n withStateAccess?: <T>(task: () => Promise<T>) => Promise<T>;\n } = {},\n) {\n const current = attention.current();\n if (!current || signal.aborted) return;\n const { dispatchManagerResult } = await import(\"../ui/manager-result-dispatcher.js\");\n if (signal.aborted || attention.current() !== current) return;\n await dispatchManagerResult(\n ctx,\n { kind: \"remote-selection-required\", decision: current.decision },\n current.origin,\n (route, actionSignal, onCommit, target) => {\n const execute = () =>\n executeRecoveryCommand(\n route,\n ctx,\n combineSignals(signal, actionSignal),\n loaders,\n observationCommitCallback(attention, signal, onCommit),\n target,\n );\n return options.withStateAccess ? options.withStateAccess(execute) : execute();\n },\n signal,\n {\n cancelLabel: options.cancelLabel,\n withStateAccess: options.withStateAccess,\n onSelectionResolved: () => {\n if (attention.current() === current) attention.clear(ctx);\n },\n },\n );\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGO,SAAS,sBACd,KACA,UACS;AACT,MAAI,CAAC,SAAU,QAAO;AACtB,QAAM,YAAY,OAAc,SAA+C;AAC7E,aAAS,IAAI;AACb,QAAI;AACF,aAAO,MAAM,KAAK;AAAA,IACpB,UAAE;AACA,eAAS,KAAK;AAAA,IAChB;AAAA,EACF;AACA,QAAM,KAA6B;AAAA,IACjC,GAAG,IAAI;AAAA,IACP,QAAQ,IAAI,SAAS,UAAU,MAAM,IAAI,GAAG,OAAO,GAAG,IAAI,CAAC;AAAA,IAC3D,SAAS,IAAI,SAAS,UAAU,MAAM,IAAI,GAAG,QAAQ,GAAG,IAAI,CAAC;AAAA,EAC/D;AAGA,SAAO,IAAI,MAAM,KAAK;AAAA,IACpB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23
|
import "./chunk-FLHCOJCD.ts";
|
|
24
24
|
import "./chunk-MKSMJPVA.ts";
|
|
@@ -29,8 +29,9 @@ import {
|
|
|
29
29
|
captureMutationOwner
|
|
30
30
|
} from "./chunk-GNYGNHFF.ts";
|
|
31
31
|
import {
|
|
32
|
-
setSyncStatus
|
|
33
|
-
|
|
32
|
+
setSyncStatus,
|
|
33
|
+
syncStatusFailureReason
|
|
34
|
+
} from "./chunk-YIPK23JW.ts";
|
|
34
35
|
import {
|
|
35
36
|
loadConfigForCheck,
|
|
36
37
|
syncCheckConfigFingerprint
|
|
@@ -168,7 +169,10 @@ function createContinuousSync(loaders, clock = systemClock, publish) {
|
|
|
168
169
|
if (signal.aborted) return;
|
|
169
170
|
try {
|
|
170
171
|
validateContext();
|
|
171
|
-
setSyncStatus(ctx, "sync blocked: private state or settings need repair"
|
|
172
|
+
setSyncStatus(ctx, "sync blocked: private state or settings need repair", {
|
|
173
|
+
activity: "blocked",
|
|
174
|
+
reason: "repair"
|
|
175
|
+
});
|
|
172
176
|
if (!repairNotices.has(ctx.sessionManager)) {
|
|
173
177
|
repairNotices.add(ctx.sessionManager);
|
|
174
178
|
ctx.ui.notify(
|
|
@@ -219,7 +223,7 @@ function createContinuousSync(loaders, clock = systemClock, publish) {
|
|
|
219
223
|
if (lease) {
|
|
220
224
|
await monitor(ctx, config, binding, lease, signal, explicitRetry, startup);
|
|
221
225
|
explicitRetry = false;
|
|
222
|
-
} else setSyncStatus(ctx, "sync waiting: another local owner");
|
|
226
|
+
} else setSyncStatus(ctx, "sync waiting: another local owner", { activity: "idle" });
|
|
223
227
|
} finally {
|
|
224
228
|
await lease?.release();
|
|
225
229
|
}
|
|
@@ -228,7 +232,10 @@ function createContinuousSync(loaders, clock = systemClock, publish) {
|
|
|
228
232
|
if (signal.aborted) return;
|
|
229
233
|
const failure = continuousFailure(error);
|
|
230
234
|
if (!failure.retry && !(error instanceof Error && error.name === "AbortError")) throw error;
|
|
231
|
-
setSyncStatus(ctx, `sync retry scheduled: ${failure.kind}
|
|
235
|
+
setSyncStatus(ctx, `sync retry scheduled: ${failure.kind}`, {
|
|
236
|
+
activity: "retry",
|
|
237
|
+
reason: syncStatusFailureReason(failure.kind)
|
|
238
|
+
});
|
|
232
239
|
}
|
|
233
240
|
validateOwner();
|
|
234
241
|
if (!continuousEnabled(await loadConfigForCheck())) return;
|
|
@@ -404,7 +411,8 @@ function createContinuousSync(loaders, clock = systemClock, publish) {
|
|
|
404
411
|
validate();
|
|
405
412
|
setSyncStatus(
|
|
406
413
|
ctx,
|
|
407
|
-
state.phase === "blocked" ? `sync blocked: ${state.error}` : state.phase === "retry" ? `sync retry scheduled: ${state.error}` : "sync waiting for changes"
|
|
414
|
+
state.phase === "blocked" ? `sync blocked: ${state.error}` : state.phase === "retry" ? `sync retry scheduled: ${state.error}` : "sync waiting for changes",
|
|
415
|
+
state.phase === "blocked" || state.phase === "retry" ? { activity: state.phase, reason: syncStatusFailureReason(state.error) } : { activity: "idle" }
|
|
408
416
|
);
|
|
409
417
|
if (state.phase === "retry") pollDue = Math.min(pollDue, state.next);
|
|
410
418
|
const next = Math.max(
|
|
@@ -433,7 +441,7 @@ function createContinuousSync(loaders, clock = systemClock, publish) {
|
|
|
433
441
|
validate();
|
|
434
442
|
if (!force && !pending && current.phase === "blocked" && ["authentication", "storage", "unknown"].includes(current.error ?? ""))
|
|
435
443
|
return;
|
|
436
|
-
setSyncStatus(ctx, "sync checking");
|
|
444
|
+
setSyncStatus(ctx, "sync checking", { activity: "checking" });
|
|
437
445
|
const inspectionModule = await timings.measure("inspection import", () => loaders.inspection());
|
|
438
446
|
validate();
|
|
439
447
|
const observed = await timings.measure(
|
|
@@ -495,7 +503,7 @@ function createContinuousSync(loaders, clock = systemClock, publish) {
|
|
|
495
503
|
if (observed.journal || observed.inspection.localChanged || observed.inspection.remoteChanged) {
|
|
496
504
|
const operations = await timings.measure("operations import", () => loaders.operations());
|
|
497
505
|
validate();
|
|
498
|
-
setSyncStatus(ctx, "sync syncing");
|
|
506
|
+
setSyncStatus(ctx, "sync syncing", { activity: "working" });
|
|
499
507
|
const result = await timings.measure(
|
|
500
508
|
"automatic transfer",
|
|
501
509
|
() => withStateDirectoryAccess(
|
|
@@ -574,4 +582,4 @@ export {
|
|
|
574
582
|
continuousEnabled,
|
|
575
583
|
createContinuousSync
|
|
576
584
|
};
|
|
577
|
-
//# sourceMappingURL=continuous-sync-
|
|
585
|
+
//# sourceMappingURL=continuous-sync-FAFNLEUW.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/sync/continuous-watch.ts", "../../src/sync/continuous-sync.ts"],
|
|
4
|
+
"sourcesContent": ["import { type FSWatcher, watch } from \"node:fs\";\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { getAgentDir } from \"@earendil-works/pi-coding-agent\";\nimport { isDeniedPath } from \"../paths.js\";\nimport type { AnySyncConfig } from \"../settings/settings-types.js\";\n\n/** Hints only. The scheduler's periodic snapshot scan remains required. */\nexport async function watchContinuous(\n config: AnySyncConfig,\n changed: (settings: boolean) => void,\n): Promise<() => void> {\n const root = getAgentDir();\n const watchers: FSWatcher[] = [];\n const selected = config.include.map((item) => path.resolve(root, item));\n const relevant = (target: string) =>\n selected.some(\n (item) => target === item || target.startsWith(`${item}${path.sep}`) || item.startsWith(`${target}${path.sep}`),\n );\n const add = (directory: string, recursive: boolean) => {\n try {\n const watcher = watch(directory, { recursive, persistent: false }, (_event, file) => {\n // Unknown names can be our own private writes. Periodic scans cover them.\n if (!file) return;\n const target = path.resolve(directory, String(file));\n if (target === path.join(root, \"pi-sync.json\")) changed(true);\n else if (isDeniedPath(path.relative(root, target))) return;\n else if (relevant(target)) changed(false);\n });\n watcher.on(\"error\", () => watcher.close());\n watchers.push(watcher);\n } catch {\n /* Periodic scans cover unavailable or unsupported watchers. */\n }\n };\n add(root, false);\n const directories = new Set<string>();\n try {\n for (const target of selected) {\n try {\n const stat = await fs.lstat(target);\n if (stat.isSymbolicLink()) continue;\n const directory = stat.isDirectory() ? target : path.dirname(target);\n if (directory === root || directories.has(directory)) continue;\n directories.add(directory);\n add(directory, stat.isDirectory());\n } catch (error) {\n if ((error as NodeJS.ErrnoException).code !== \"ENOENT\") continue;\n // Missing targets are found by the parent hint or the next periodic scan.\n }\n }\n return () => {\n for (const watcher of watchers) watcher.close();\n };\n } catch (error) {\n for (const watcher of watchers) watcher.close();\n throw error;\n }\n}\n", "import type { ExtensionContext } from \"@earendil-works/pi-coding-agent\";\nimport { loadConfigForCheck, syncCheckConfigFingerprint } from \"../settings/config.js\";\nimport type { AnySyncConfig } from \"../settings/settings-types.js\";\nimport { snapshotOptionsForContext } from \"../snapshot/session-paths.js\";\nimport { withLock } from \"../state/lock.js\";\nimport { withStateDirectoryAccess } from \"../state/state-directory.js\";\nimport { readStateForConfig } from \"../state/sync-state-store.js\";\nimport { setSyncStatus, syncStatusFailureReason } from \"../ui/sync-status.js\";\nimport { withAgentSyncLock } from \"./agent-sync.js\";\nimport { ContinuousError, continuousFailure } from \"./continuous-errors.js\";\nimport { acquireContinuousLease, type ContinuousLease } from \"./continuous-lease.js\";\nimport {\n normalizeContinuousClock,\n readContinuousRecord,\n reserveContinuousRequest,\n updateContinuousRecord,\n} from \"./continuous-record.js\";\nimport { continuousBinding, hashContinuous } from \"./continuous-storage.js\";\nimport { watchContinuous } from \"./continuous-watch.js\";\nimport { readMergeJournal } from \"./merge-journal.js\";\nimport { createStartupTimings, type StartupTimingPublisher, type StartupTimings } from \"./startup-timings.js\";\nimport type { SyncLoaders } from \"./sync-loaders.js\";\nimport { captureMutationOwner } from \"./sync-local.js\";\nimport { fileHashMap } from \"./sync-state.js\";\n\nexport function continuousEnabled(config: Pick<AnySyncConfig, \"continuous\" | \"agentMode\">) {\n return Boolean(config.continuous && config.agentMode);\n}\nexport interface ContinuousClock {\n now(): number;\n random(): number;\n schedule(ms: number, run: () => void, kind?: \"wait\" | \"authorization\"): () => void;\n}\nconst systemClock: ContinuousClock = {\n now: () => Date.now(),\n random: () => Math.random(),\n schedule: (ms, run) => {\n const timer = setTimeout(run, ms);\n timer.unref?.();\n return () => clearTimeout(timer);\n },\n};\nconst LOCAL_CHECK_MS = 5_000;\nconst POLL_MS = 60_000;\nconst DEBOUNCE_MS = 1_000;\n\ninterface ContinuousStartup {\n signal: AbortSignal;\n debug: boolean;\n reported: boolean;\n}\n\n/** Created on first enabled session. No module/factory-owned timers or watchers. */\nexport function createContinuousSync(\n loaders: SyncLoaders,\n clock: ContinuousClock = systemClock,\n publish?: StartupTimingPublisher,\n) {\n const startups = new WeakMap<ExtensionContext[\"sessionManager\"], ContinuousStartup>();\n const repairNotices = new WeakSet<ExtensionContext[\"sessionManager\"]>();\n let task:\n | { owner: ExtensionContext[\"sessionManager\"]; controller: AbortController; promise: Promise<void>; clear(): void }\n | undefined;\n return {\n start(ctx: ExtensionContext, sessionSignal: AbortSignal, explicitRetry = false, debug = false) {\n if (!ctx.hasUI || (ctx.mode !== \"tui\" && ctx.mode !== \"rpc\") || sessionSignal.aborted || task) return;\n const controller = new AbortController();\n const signal = AbortSignal.any([sessionSignal, controller.signal]);\n const validateContext = captureMutationOwner(ctx);\n // The caller supplies the session-start debug value, including first activation after settings edits.\n const previousStartup = startups.get(ctx.sessionManager);\n const startup: ContinuousStartup =\n previousStartup?.signal === sessionSignal ? previousStartup : { signal: sessionSignal, debug, reported: false };\n startups.set(ctx.sessionManager, startup);\n const current = {\n owner: ctx.sessionManager,\n controller,\n promise: Promise.resolve(),\n clear: () => {\n try {\n validateContext();\n setSyncStatus(ctx, undefined);\n } catch {\n /* replaced session */\n }\n },\n };\n task = current;\n current.promise = (async () => {\n let explicit = explicitRetry;\n while (!signal.aborted) {\n try {\n await run(ctx, signal, explicit, startup);\n return;\n } catch {\n if (signal.aborted) return;\n try {\n validateContext();\n setSyncStatus(ctx, \"sync blocked: private state or settings need repair\", {\n activity: \"blocked\",\n reason: \"repair\",\n });\n if (!repairNotices.has(ctx.sessionManager)) {\n repairNotices.add(ctx.sessionManager);\n ctx.ui.notify(\n \"Continuous sync blocked: private state or settings need repair. Use /sync. Evidence was retained.\",\n \"warning\",\n );\n }\n } catch {\n return;\n }\n }\n explicit = false;\n // Only local prerequisites are retried here. No remote/model request can\n // pass a malformed settings/state read. A repair can resume monitoring.\n await wait(clock, LOCAL_CHECK_MS, signal);\n }\n })()\n .catch(() => {\n /* Cancellation/UI disposal must not leak a detached rejection. */\n })\n .finally(() => {\n if (task === current) task = undefined;\n });\n },\n async stop(owner?: ExtensionContext[\"sessionManager\"]) {\n const current = task;\n if (!current || (owner && current.owner !== owner)) return;\n current.controller.abort(new DOMException(\"Continuous sync interrupted\", \"AbortError\"));\n current.clear();\n await current.promise;\n },\n };\n\n async function run(ctx: ExtensionContext, signal: AbortSignal, explicitRetry: boolean, startup: ContinuousStartup) {\n const validateOwner = captureMutationOwner(ctx, signal);\n try {\n while (!signal.aborted) {\n validateOwner();\n const config = await loadConfigForCheck();\n validateOwner();\n if (!continuousEnabled(config)) return;\n try {\n if (ctx.isIdle()) {\n let lease: ContinuousLease | undefined;\n let binding = \"\";\n try {\n await withStateDirectoryAccess(async () => {\n validateOwner();\n binding = await continuousBinding(config);\n validateOwner();\n lease = await acquireContinuousLease(binding);\n validateOwner();\n });\n if (lease) {\n await monitor(ctx, config, binding, lease, signal, explicitRetry, startup);\n explicitRetry = false;\n } else setSyncStatus(ctx, \"sync waiting: another local owner\", { activity: \"idle\" });\n } finally {\n await lease?.release();\n }\n }\n } catch (error) {\n if (signal.aborted) return;\n const failure = continuousFailure(error);\n if (!failure.retry && !(error instanceof Error && error.name === \"AbortError\")) throw error;\n setSyncStatus(ctx, `sync retry scheduled: ${failure.kind}`, {\n activity: \"retry\",\n reason: syncStatusFailureReason(failure.kind),\n });\n }\n validateOwner();\n if (!continuousEnabled(await loadConfigForCheck())) return;\n validateOwner();\n await wait(clock, LOCAL_CHECK_MS, signal);\n }\n } finally {\n // Shutdown/replacement owns clearing the old UI; do not call it from a stale continuation.\n if (!signal.aborted) {\n try {\n validateOwner();\n setSyncStatus(ctx, undefined);\n } catch {\n /* stale context */\n }\n }\n }\n }\n\n async function monitor(\n ctx: ExtensionContext,\n initial: AnySyncConfig,\n binding: string,\n lease: ContinuousLease,\n parent: AbortSignal,\n explicitRetry: boolean,\n startup: ContinuousStartup,\n ) {\n const signal = AbortSignal.any([parent, lease.signal]);\n const validateOwner = captureMutationOwner(ctx, signal);\n let config = initial;\n let closeWatch = () => {};\n let wake = () => {};\n let dirtyAt: number | undefined;\n let cycle: AbortController | undefined;\n const changed = (settings: boolean) => {\n dirtyAt = clock.now();\n if (settings) cycle?.abort(new DOMException(\"Continuous settings changed\", \"AbortError\"));\n wake();\n };\n const validate = () => {\n validateOwner();\n lease.assert();\n if (!ctx.isIdle()) throw new DOMException(\"Owning session became busy\", \"AbortError\");\n };\n const stopWatch = () => {\n closeWatch();\n wake();\n };\n signal.addEventListener(\"abort\", stopWatch, { once: true });\n let pollDue = 0;\n try {\n closeWatch = await watchContinuous(config, changed);\n validate();\n while (!signal.aborted && ctx.isIdle()) {\n validate();\n const latest = await loadConfigForCheck();\n validate();\n if (!continuousEnabled(latest) || (await continuousBinding(latest)) !== binding) return;\n validate();\n if (syncCheckConfigFingerprint(latest) !== syncCheckConfigFingerprint(config)) {\n closeWatch();\n config = latest;\n closeWatch = await watchContinuous(config, changed);\n validate();\n pollDue = 0;\n }\n const record = await readContinuousRecord(binding);\n validate();\n const now = clock.now();\n const oldClock = JSON.stringify([record.next, record.calls]);\n normalizeContinuousClock(record, now);\n if (oldClock !== JSON.stringify([record.next, record.calls])) {\n await updateContinuousRecord(binding, lease, (current) => normalizeContinuousClock(current, now));\n validate();\n }\n const configuration = hashContinuous([{ ...config, showStatus: undefined, debug: undefined }, ctx.model]);\n const controlChanged = record.configuration !== configuration;\n if (controlChanged || explicitRetry) {\n record.next = 0;\n pollDue = 0;\n }\n const hintDue = dirtyAt === undefined ? Number.POSITIVE_INFINITY : dirtyAt + DEBOUNCE_MS;\n const due = Math.max(record.error === \"budget\" ? 0 : record.next, Math.min(pollDue, hintDue));\n if (now >= due) {\n const timings = createStartupTimings(publish);\n const report = !startup.reported && startup.debug;\n startup.reported = true;\n let outcome: \"completed\" | \"stopped\" = \"stopped\";\n const force = explicitRetry || controlChanged;\n explicitRetry = false;\n const expectedModel = hashContinuous(ctx.model);\n const expectedConfig = syncCheckConfigFingerprint(config);\n dirtyAt = undefined;\n cycle = new AbortController();\n const cancelDeadline = clock.schedule(30_000, () =>\n cycle?.abort(new DOMException(\"Continuous cycle timed out\", \"TimeoutError\")),\n );\n const guard = new AbortController();\n const guardSignal = AbortSignal.any([signal, cycle.signal, guard.signal]);\n const activeCycle = cycle;\n // Transfer entrypoints supply each fresh settings read. Never let a new\n // transfer adopt authorization that changed after this cycle's inspection.\n const validateCycle = (latest?: AnySyncConfig) => {\n validate();\n if (\n (latest && syncCheckConfigFingerprint(latest) !== expectedConfig) ||\n hashContinuous(ctx.model) !== expectedModel\n )\n activeCycle.abort(new DOMException(\"Continuous authorization changed\", \"AbortError\"));\n activeCycle.signal.throwIfAborted();\n };\n const guardTask = (async () => {\n while (!guardSignal.aborted) {\n await wait(clock, LOCAL_CHECK_MS, guardSignal, undefined, \"authorization\");\n if (guardSignal.aborted) return;\n try {\n validate();\n const latest = await loadConfigForCheck();\n if (guardSignal.aborted) return;\n validateCycle(latest);\n } catch {\n activeCycle.abort(new DOMException(\"Continuous authorization unavailable\", \"AbortError\"));\n }\n }\n })().catch(() => {});\n try {\n await performCycle(\n ctx,\n config,\n binding,\n lease,\n AbortSignal.any([signal, cycle.signal]),\n validateCycle,\n configuration,\n force,\n timings,\n );\n outcome = \"completed\";\n } catch (error) {\n if (signal.aborted || !ctx.isIdle()) return;\n // A settings hint interrupts the old authorization; load it afresh, not as a failed transfer.\n if (cycle.signal.aborted && cycle.signal.reason?.name !== \"TimeoutError\") {\n pollDue = 0;\n continue;\n }\n const failure = continuousFailure(error);\n let announce = false;\n await updateContinuousRecord(binding, lease, (current) => {\n const now = clock.now();\n normalizeContinuousClock(current, now);\n const notice = hashContinuous([failure.kind, current.evidence, configuration]);\n announce = current.notice !== notice;\n if (!failure.retry) current.notice = notice;\n current.configuration = configuration;\n current.pending = true;\n current.error = failure.kind;\n current.phase = failure.retry ? \"retry\" : \"blocked\";\n current.failures = Math.min(30, current.failures + 1);\n const base = Math.min(300_000, 5_000 * 2 ** Math.min(6, current.failures - 1));\n const delay = Math.min(300_000, base + Math.floor(clock.random() * base * 0.2));\n current.next = now + Math.max(delay, failure.delay ?? 0);\n });\n validate();\n if (announce && !failure.retry)\n ctx.ui.notify(\n `Continuous sync blocked (${failure.kind}). Review /sync or repair the setup. Evidence was retained.`,\n \"warning\",\n );\n } finally {\n cancelDeadline();\n guard.abort();\n await guardTask;\n cycle = undefined;\n timings.publish(ctx, report, signal, \"continuous startup\", outcome);\n }\n pollDue = clock.now() + POLL_MS + Math.floor(clock.random() * 6_000);\n closeWatch();\n closeWatch = () => {};\n closeWatch = await watchContinuous(config, changed);\n validate();\n }\n validate();\n const state = await readContinuousRecord(binding);\n validate();\n setSyncStatus(\n ctx,\n state.phase === \"blocked\"\n ? `sync blocked: ${state.error}`\n : state.phase === \"retry\"\n ? `sync retry scheduled: ${state.error}`\n : \"sync waiting for changes\",\n state.phase === \"blocked\" || state.phase === \"retry\"\n ? { activity: state.phase, reason: syncStatusFailureReason(state.error) }\n : { activity: \"idle\" },\n );\n if (state.phase === \"retry\") pollDue = Math.min(pollDue, state.next);\n const next = Math.max(\n state.error === \"budget\" ? 0 : state.next,\n Math.min(pollDue, dirtyAt === undefined ? Number.POSITIVE_INFINITY : dirtyAt + DEBOUNCE_MS),\n );\n await wait(clock, Math.max(1, Math.min(LOCAL_CHECK_MS, next - clock.now())), signal, (callback) => {\n wake = callback;\n });\n }\n } finally {\n signal.removeEventListener(\"abort\", stopWatch);\n closeWatch();\n cycle?.abort();\n }\n }\n\n async function performCycle(\n ctx: ExtensionContext,\n config: AnySyncConfig,\n binding: string,\n lease: ContinuousLease,\n signal: AbortSignal,\n validateOwner: (config?: AnySyncConfig) => void,\n configuration: string,\n force: boolean,\n timings: StartupTimings,\n ) {\n const validate = (latest?: AnySyncConfig) => {\n signal.throwIfAborted();\n validateOwner(latest);\n };\n validate();\n const current = await readContinuousRecord(binding);\n validate();\n // A newly pending journal may prove an uncertain commit. It is never authority to republish.\n const pending = await guardedLock(\"continuous-journal\", () => readMergeJournal(config));\n validate();\n if (\n !force &&\n !pending &&\n current.phase === \"blocked\" &&\n [\"authentication\", \"storage\", \"unknown\"].includes(current.error ?? \"\")\n )\n return;\n setSyncStatus(ctx, \"sync checking\", { activity: \"checking\" });\n const inspectionModule = await timings.measure(\"inspection import\", () => loaders.inspection());\n validate();\n const observed = await timings.measure(\"inspection and guards\", () =>\n guardedLock(\"continuous-check\", async () => {\n validate();\n const inspection = await inspectionModule.inspectSync(\n config,\n snapshotOptionsForContext(ctx, config),\n signal,\n undefined,\n timings,\n );\n validate();\n let localIdentity = inspection.localIdentity;\n if (!localIdentity) {\n const snapshotModule = await loaders.snapshot();\n validate();\n const local = await snapshotModule.createSnapshot(config.snapshotIdentity, {\n ...snapshotOptionsForContext(ctx, config),\n signal,\n });\n validate();\n localIdentity = hashContinuous(fileHashMap(local));\n }\n const journal = await readMergeJournal(config);\n validate();\n return { inspection, journal, localIdentity };\n }),\n );\n validate();\n const evidence = hashContinuous([\n configuration,\n observed.localIdentity,\n observed.inspection.head?.revision,\n observed.inspection.stateIdentity,\n ]);\n const recovery = observed.journal ? hashContinuous([evidence, observed.journal]) : undefined;\n const blocked =\n !force &&\n current.evidence === evidence &&\n ((current.phase === \"blocked\" && (!recovery || recovery === current.recovery)) ||\n (current.error === \"budget\" && current.next > clock.now() && !observed.journal));\n await updateContinuousRecord(binding, lease, (record) => {\n if (record.configuration !== configuration) {\n record.failures = 0;\n record.next = 0;\n }\n record.configuration = configuration;\n record.checked = clock.now();\n record.evidence = evidence;\n if (!blocked) {\n if (record.phase !== \"blocked\") record.phase = \"syncing\";\n record.pending = true;\n if (recovery) record.recovery = recovery;\n }\n });\n validate();\n if (blocked) return;\n if (\n !observed.journal &&\n (observed.inspection.firstSync ||\n !observed.inspection.head ||\n observed.inspection.selectionState?.kind !== \"same\")\n )\n throw new ContinuousError(\"unsafe\", \"Continuous sync needs an accepted baseline and matching remote selection.\");\n let transferred = false;\n if (observed.journal || observed.inspection.localChanged || observed.inspection.remoteChanged) {\n const operations = await timings.measure(\"operations import\", () => loaders.operations());\n validate();\n setSyncStatus(ctx, \"sync syncing\", { activity: \"working\" });\n const result = await timings.measure(\"automatic transfer\", () =>\n withStateDirectoryAccess(() =>\n withAgentSyncLock(\n ctx,\n {\n args: [],\n yes: true,\n force: false,\n stale: false,\n silent: true,\n reload: false,\n auto: true,\n signal,\n startupTimings: timings,\n background: {\n validate,\n reserve: (key, requestSignal) =>\n reserveContinuousRequest(binding, lease, key, () => clock.now(), requestSignal),\n },\n },\n (options) => operations.syncBoth(ctx, options),\n ),\n ),\n );\n validate();\n transferred = result === \"applied\";\n }\n const state = await guardedLock(\"continuous-result\", () => readStateForConfig(config));\n validate();\n const unresolved = state.unresolved;\n let announcePartial = false;\n await updateContinuousRecord(binding, lease, (record) => {\n record.phase = unresolved?.length ? \"blocked\" : \"waiting\";\n record.pending = Boolean(unresolved?.length);\n record.failures = 0;\n record.next = 0;\n if (unresolved?.length) {\n record.error = \"unsafe\";\n const notice = hashContinuous([\"partial\", unresolved, configuration]);\n announcePartial = record.notice !== notice;\n record.notice = notice;\n } else {\n delete record.error;\n delete record.notice;\n }\n if (transferred) record.transferred = clock.now();\n });\n validate();\n if (announcePartial)\n ctx.ui.notify(\n \"Continuous sync retained unresolved groups. Review /sync conflicts; independent partial progress was preserved.\",\n \"warning\",\n );\n }\n}\n\nfunction guardedLock<T>(command: string, run: () => Promise<T>) {\n return withStateDirectoryAccess(() => withLock(command, run));\n}\n\nfunction wait(\n clock: ContinuousClock,\n ms: number,\n signal: AbortSignal,\n expose?: (wake: () => void) => void,\n kind: \"wait\" | \"authorization\" = \"wait\",\n) {\n signal.throwIfAborted();\n return new Promise<void>((resolve) => {\n const done = () => {\n cancel();\n signal.removeEventListener(\"abort\", done);\n expose?.(() => {});\n resolve();\n };\n const cancel = clock.schedule(ms, done, kind);\n signal.addEventListener(\"abort\", done, { once: true });\n expose?.(done);\n if (signal.aborted) done();\n });\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAyB,aAAa;AACtC,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,mBAAmB;AAK5B,eAAsB,gBACpB,QACA,SACqB;AACrB,QAAM,OAAO,YAAY;AACzB,QAAM,WAAwB,CAAC;AAC/B,QAAM,WAAW,OAAO,QAAQ,IAAI,CAAC,SAAS,KAAK,QAAQ,MAAM,IAAI,CAAC;AACtE,QAAM,WAAW,CAAC,WAChB,SAAS;AAAA,IACP,CAAC,SAAS,WAAW,QAAQ,OAAO,WAAW,GAAG,IAAI,GAAG,KAAK,GAAG,EAAE,KAAK,KAAK,WAAW,GAAG,MAAM,GAAG,KAAK,GAAG,EAAE;AAAA,EAChH;AACF,QAAM,MAAM,CAAC,WAAmB,cAAuB;AACrD,QAAI;AACF,YAAM,UAAU,MAAM,WAAW,EAAE,WAAW,YAAY,MAAM,GAAG,CAAC,QAAQ,SAAS;AAEnF,YAAI,CAAC,KAAM;AACX,cAAM,SAAS,KAAK,QAAQ,WAAW,OAAO,IAAI,CAAC;AACnD,YAAI,WAAW,KAAK,KAAK,MAAM,cAAc,EAAG,SAAQ,IAAI;AAAA,iBACnD,aAAa,KAAK,SAAS,MAAM,MAAM,CAAC,EAAG;AAAA,iBAC3C,SAAS,MAAM,EAAG,SAAQ,KAAK;AAAA,MAC1C,CAAC;AACD,cAAQ,GAAG,SAAS,M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