@leitwerk-dev/watcher-utils 0.1.0 → 0.1.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/dist/duration-parse.d.ts +3 -2
- package/dist/duration-parse.js +6 -15
- package/dist/duration-parse.js.map +1 -1
- package/dist/index.d.ts +19 -8
- package/dist/index.js +81 -7
- package/dist/index.js.map +1 -1
- package/dist/poll-loop.d.ts +6 -5
- package/dist/poll-loop.js +9 -58
- package/dist/poll-loop.js.map +1 -1
- package/dist/process-helpers.d.ts +9 -7
- package/dist/process-helpers.js +10 -32
- package/dist/process-helpers.js.map +1 -1
- package/dist/watcher-coordinator.d.ts +28 -26
- package/dist/watcher-coordinator.js +21 -130
- package/dist/watcher-coordinator.js.map +1 -1
- package/package.json +4 -4
- package/dist/duration-parse.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/poll-loop.d.ts.map +0 -1
- package/dist/process-helpers.d.ts.map +0 -1
- package/dist/trigger-files.d.ts +0 -10
- package/dist/trigger-files.d.ts.map +0 -1
- package/dist/trigger-files.js +0 -31
- package/dist/trigger-files.js.map +0 -1
- package/dist/watcher-coordinator.d.ts.map +0 -1
package/dist/duration-parse.d.ts
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
* `options.allowHours` is retained for existing callers; the underlying `ms`
|
|
6
6
|
* parser supports hours and other common duration units by default.
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
declare function parseDurationMs(value: string, defaultMs: number, _options?: {
|
|
9
9
|
allowHours?: boolean;
|
|
10
10
|
}): number;
|
|
11
|
-
|
|
11
|
+
|
|
12
|
+
export { parseDurationMs };
|
package/dist/duration-parse.js
CHANGED
|
@@ -1,16 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* parser supports hours and other common duration units by default.
|
|
8
|
-
*/
|
|
9
|
-
export function parseDurationMs(value, defaultMs, _options = {}) {
|
|
10
|
-
const parsed = ms(value.trim());
|
|
11
|
-
if (!Number.isFinite(parsed) || parsed < 0) {
|
|
12
|
-
return defaultMs;
|
|
13
|
-
}
|
|
14
|
-
return parsed;
|
|
15
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
parseDurationMs
|
|
3
|
+
} from "./chunk-IU3L35PC.js";
|
|
4
|
+
export {
|
|
5
|
+
parseDurationMs
|
|
6
|
+
};
|
|
16
7
|
//# sourceMappingURL=duration-parse.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
export { EnsureWriteResult, ExternalWriteLogRecordInput, ExternalWriteLogRepoLike, WriteIdentity, createWriteIdentity, ensureWrite, recordWriteIfMissing } from '@leitwerk-dev/external-writes';
|
|
2
|
+
export { parseDurationMs } from './duration-parse.js';
|
|
3
|
+
export { PollLoop, PollResult, createPollLoop, emptyPollResult } from './poll-loop.js';
|
|
4
|
+
export { ProcessEventRepoLike, WorkerSupervisorLike, ensureWorkerForActiveAgent, hasProcessEvent, processNeedsWorker } from './process-helpers.js';
|
|
5
|
+
export { AgentRepoAccessorLike, BroadcasterLike, CompletionReconciliationOptions, CompletionReconciliationResult, ContinueWatcherAgentStartupOptions, DiscoveryPassOptions, WatcherCommandResult, WatcherCommandServiceLike, WatcherStartupDeps, continueWatcherAgentStartup, deferWatcherLaunchStart, launchFailureMessage, requireWatcherStartTurnId, runWatcherAbortReconciliation, runWatcherCompletionReconciliation, runWatcherDiscoveryPass, shouldEnsureWorkerForExistingActiveAgent } from './watcher-coordinator.js';
|
|
6
|
+
import '@leitwerk-dev/domain';
|
|
7
|
+
import '@leitwerk-dev/protocol';
|
|
8
|
+
|
|
9
|
+
type TriggerFileReadResult = {
|
|
10
|
+
exists: false;
|
|
11
|
+
} | {
|
|
12
|
+
exists: true;
|
|
13
|
+
content: string;
|
|
14
|
+
};
|
|
15
|
+
declare function errorCode(error: unknown): string | null;
|
|
16
|
+
declare function readTriggerFile(filePath: string): Promise<TriggerFileReadResult>;
|
|
17
|
+
declare function consumeTriggerFile(filePath: string): Promise<void>;
|
|
18
|
+
|
|
19
|
+
export { type TriggerFileReadResult, consumeTriggerFile, errorCode, readTriggerFile };
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,82 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import {
|
|
2
|
+
createPollLoop,
|
|
3
|
+
emptyPollResult
|
|
4
|
+
} from "./chunk-XF2QQLPO.js";
|
|
5
|
+
import {
|
|
6
|
+
parseDurationMs
|
|
7
|
+
} from "./chunk-IU3L35PC.js";
|
|
8
|
+
import {
|
|
9
|
+
continueWatcherAgentStartup,
|
|
10
|
+
deferWatcherLaunchStart,
|
|
11
|
+
launchFailureMessage,
|
|
12
|
+
requireWatcherStartTurnId,
|
|
13
|
+
runWatcherAbortReconciliation,
|
|
14
|
+
runWatcherCompletionReconciliation,
|
|
15
|
+
runWatcherDiscoveryPass,
|
|
16
|
+
shouldEnsureWorkerForExistingActiveAgent
|
|
17
|
+
} from "./chunk-XLVMFO6W.js";
|
|
18
|
+
import {
|
|
19
|
+
ensureWorkerForActiveAgent,
|
|
20
|
+
hasProcessEvent,
|
|
21
|
+
processNeedsWorker
|
|
22
|
+
} from "./chunk-3KGAUQIG.js";
|
|
23
|
+
|
|
24
|
+
// src/index.ts
|
|
25
|
+
import {
|
|
26
|
+
createWriteIdentity,
|
|
27
|
+
ensureWrite,
|
|
28
|
+
recordWriteIfMissing
|
|
29
|
+
} from "@leitwerk-dev/external-writes";
|
|
30
|
+
|
|
31
|
+
// src/trigger-files.ts
|
|
32
|
+
import { readFile, unlink } from "fs/promises";
|
|
33
|
+
function errorCode(error) {
|
|
34
|
+
if (typeof error !== "object" || error === null || !("code" in error)) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
const code = error.code;
|
|
38
|
+
return typeof code === "string" ? code : null;
|
|
39
|
+
}
|
|
40
|
+
async function readTriggerFile(filePath) {
|
|
41
|
+
try {
|
|
42
|
+
return { exists: true, content: await readFile(filePath, "utf8") };
|
|
43
|
+
} catch (error) {
|
|
44
|
+
if (errorCode(error) === "ENOENT") {
|
|
45
|
+
return { exists: false };
|
|
46
|
+
}
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
async function consumeTriggerFile(filePath) {
|
|
51
|
+
try {
|
|
52
|
+
await unlink(filePath);
|
|
53
|
+
} catch (error) {
|
|
54
|
+
if (errorCode(error) === "ENOENT") {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
throw error;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
export {
|
|
61
|
+
consumeTriggerFile,
|
|
62
|
+
continueWatcherAgentStartup,
|
|
63
|
+
createPollLoop,
|
|
64
|
+
createWriteIdentity,
|
|
65
|
+
deferWatcherLaunchStart,
|
|
66
|
+
emptyPollResult,
|
|
67
|
+
ensureWorkerForActiveAgent,
|
|
68
|
+
ensureWrite,
|
|
69
|
+
errorCode,
|
|
70
|
+
hasProcessEvent,
|
|
71
|
+
launchFailureMessage,
|
|
72
|
+
parseDurationMs,
|
|
73
|
+
processNeedsWorker,
|
|
74
|
+
readTriggerFile,
|
|
75
|
+
recordWriteIfMissing,
|
|
76
|
+
requireWatcherStartTurnId,
|
|
77
|
+
runWatcherAbortReconciliation,
|
|
78
|
+
runWatcherCompletionReconciliation,
|
|
79
|
+
runWatcherDiscoveryPass,
|
|
80
|
+
shouldEnsureWorkerForExistingActiveAgent
|
|
81
|
+
};
|
|
8
82
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/trigger-files.ts"],"sourcesContent":["/** @deprecated Import external-write idempotency from `@leitwerk-dev/external-writes`. */\nexport {\n\tcreateWriteIdentity,\n\ttype EnsureWriteResult,\n\ttype ExternalWriteLogRecordInput,\n\ttype ExternalWriteLogRepoLike,\n\tensureWrite,\n\trecordWriteIfMissing,\n\ttype WriteIdentity,\n} from \"@leitwerk-dev/external-writes\";\nexport { parseDurationMs } from \"./duration-parse.js\";\nexport {\n\tcreatePollLoop,\n\temptyPollResult,\n\ttype PollLoop,\n\ttype PollResult,\n} from \"./poll-loop.js\";\nexport {\n\tensureWorkerForActiveAgent,\n\thasProcessEvent,\n\ttype ProcessEventRepoLike,\n\tprocessNeedsWorker,\n\ttype WorkerSupervisorLike,\n} from \"./process-helpers.js\";\nexport {\n\tconsumeTriggerFile,\n\terrorCode,\n\treadTriggerFile,\n\ttype TriggerFileReadResult,\n} from \"./trigger-files.js\";\nexport {\n\ttype AgentRepoAccessorLike,\n\ttype BroadcasterLike,\n\ttype CompletionReconciliationOptions,\n\ttype CompletionReconciliationResult,\n\ttype ContinueWatcherAgentStartupOptions,\n\tcontinueWatcherAgentStartup,\n\ttype DiscoveryPassOptions,\n\tdeferWatcherLaunchStart,\n\tlaunchFailureMessage,\n\trequireWatcherStartTurnId,\n\trunWatcherAbortReconciliation,\n\trunWatcherCompletionReconciliation,\n\trunWatcherDiscoveryPass,\n\tshouldEnsureWorkerForExistingActiveAgent,\n\ttype WatcherCommandResult,\n\ttype WatcherCommandServiceLike,\n\ttype WatcherStartupDeps,\n} from \"./watcher-coordinator.js\";\n","import { readFile, unlink } from \"node:fs/promises\";\n\nexport type TriggerFileReadResult = { exists: false } | { exists: true; content: string };\n\nexport function errorCode(error: unknown): string | null {\n\tif (typeof error !== \"object\" || error === null || !(\"code\" in error)) {\n\t\treturn null;\n\t}\n\tconst code = (error as { code?: unknown }).code;\n\treturn typeof code === \"string\" ? code : null;\n}\n\nexport async function readTriggerFile(filePath: string): Promise<TriggerFileReadResult> {\n\ttry {\n\t\treturn { exists: true, content: await readFile(filePath, \"utf8\") };\n\t} catch (error) {\n\t\tif (errorCode(error) === \"ENOENT\") {\n\t\t\treturn { exists: false };\n\t\t}\n\t\tthrow error;\n\t}\n}\n\nexport async function consumeTriggerFile(filePath: string): Promise<void> {\n\ttry {\n\t\tawait unlink(filePath);\n\t} catch (error) {\n\t\tif (errorCode(error) === \"ENOENT\") {\n\t\t\treturn;\n\t\t}\n\t\tthrow error;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AACA;AAAA,EACC;AAAA,EAIA;AAAA,EACA;AAAA,OAEM;;;ACTP,SAAS,UAAU,cAAc;AAI1B,SAAS,UAAU,OAA+B;AACxD,MAAI,OAAO,UAAU,YAAY,UAAU,QAAQ,EAAE,UAAU,QAAQ;AACtE,WAAO;AAAA,EACR;AACA,QAAM,OAAQ,MAA6B;AAC3C,SAAO,OAAO,SAAS,WAAW,OAAO;AAC1C;AAEA,eAAsB,gBAAgB,UAAkD;AACvF,MAAI;AACH,WAAO,EAAE,QAAQ,MAAM,SAAS,MAAM,SAAS,UAAU,MAAM,EAAE;AAAA,EAClE,SAAS,OAAO;AACf,QAAI,UAAU,KAAK,MAAM,UAAU;AAClC,aAAO,EAAE,QAAQ,MAAM;AAAA,IACxB;AACA,UAAM;AAAA,EACP;AACD;AAEA,eAAsB,mBAAmB,UAAiC;AACzE,MAAI;AACH,UAAM,OAAO,QAAQ;AAAA,EACtB,SAAS,OAAO;AACf,QAAI,UAAU,KAAK,MAAM,UAAU;AAClC;AAAA,IACD;AACA,UAAM;AAAA,EACP;AACD;","names":[]}
|
package/dist/poll-loop.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
interface PollResult {
|
|
2
2
|
created: string[];
|
|
3
3
|
aborted: string[];
|
|
4
4
|
labelExchanged: string[];
|
|
5
5
|
skipped: string[];
|
|
6
6
|
errors: string[];
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
declare function emptyPollResult(): PollResult;
|
|
9
|
+
interface PollLoop<T extends PollResult = PollResult> {
|
|
10
10
|
poll(): Promise<T>;
|
|
11
11
|
start(): void;
|
|
12
12
|
stop(): void;
|
|
@@ -15,10 +15,11 @@ export interface PollLoop<T extends PollResult = PollResult> {
|
|
|
15
15
|
* Create a non-overlapping polling loop. `pollOnce` is the actual work;
|
|
16
16
|
* concurrent calls to `poll()` coalesce into the in-flight promise.
|
|
17
17
|
*/
|
|
18
|
-
|
|
18
|
+
declare function createPollLoop<T extends PollResult>(opts: {
|
|
19
19
|
pollOnce: () => Promise<T>;
|
|
20
20
|
isEnabled: () => boolean;
|
|
21
21
|
pollInterval: () => string;
|
|
22
22
|
defaultIntervalMs?: number;
|
|
23
23
|
}): PollLoop<T>;
|
|
24
|
-
|
|
24
|
+
|
|
25
|
+
export { type PollLoop, type PollResult, createPollLoop, emptyPollResult };
|
package/dist/poll-loop.js
CHANGED
|
@@ -1,59 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Create a non-overlapping polling loop. `pollOnce` is the actual work;
|
|
13
|
-
* concurrent calls to `poll()` coalesce into the in-flight promise.
|
|
14
|
-
*/
|
|
15
|
-
export function createPollLoop(opts) {
|
|
16
|
-
let timer = null;
|
|
17
|
-
let pollInFlight = null;
|
|
18
|
-
const defaultMs = opts.defaultIntervalMs ?? 60_000;
|
|
19
|
-
async function poll() {
|
|
20
|
-
if (pollInFlight) {
|
|
21
|
-
return pollInFlight;
|
|
22
|
-
}
|
|
23
|
-
const running = (async () => {
|
|
24
|
-
try {
|
|
25
|
-
return await opts.pollOnce();
|
|
26
|
-
}
|
|
27
|
-
finally {
|
|
28
|
-
pollInFlight = null;
|
|
29
|
-
}
|
|
30
|
-
})();
|
|
31
|
-
pollInFlight = running;
|
|
32
|
-
return running;
|
|
33
|
-
}
|
|
34
|
-
function pollAndIgnoreUnhandledRejection() {
|
|
35
|
-
void poll().catch(() => undefined);
|
|
36
|
-
}
|
|
37
|
-
return {
|
|
38
|
-
poll,
|
|
39
|
-
start() {
|
|
40
|
-
if (timer) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
if (!opts.isEnabled()) {
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
const ms = parseDurationMs(opts.pollInterval(), defaultMs);
|
|
47
|
-
timer = setInterval(pollAndIgnoreUnhandledRejection, ms);
|
|
48
|
-
pollAndIgnoreUnhandledRejection();
|
|
49
|
-
},
|
|
50
|
-
stop() {
|
|
51
|
-
if (!timer) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
clearInterval(timer);
|
|
55
|
-
timer = null;
|
|
56
|
-
},
|
|
57
|
-
};
|
|
58
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
createPollLoop,
|
|
3
|
+
emptyPollResult
|
|
4
|
+
} from "./chunk-XF2QQLPO.js";
|
|
5
|
+
import "./chunk-IU3L35PC.js";
|
|
6
|
+
export {
|
|
7
|
+
createPollLoop,
|
|
8
|
+
emptyPollResult
|
|
9
|
+
};
|
|
59
10
|
//# sourceMappingURL=poll-loop.js.map
|
package/dist/poll-loop.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { ProcessInstance } from '@leitwerk-dev/domain';
|
|
2
|
+
|
|
3
|
+
interface ProcessEventRepoLike {
|
|
3
4
|
create(input: {
|
|
4
5
|
instanceId: string;
|
|
5
6
|
eventType: string;
|
|
@@ -9,22 +10,23 @@ export interface ProcessEventRepoLike {
|
|
|
9
10
|
eventType: string;
|
|
10
11
|
}>;
|
|
11
12
|
}
|
|
12
|
-
|
|
13
|
+
interface WorkerSupervisorLike {
|
|
13
14
|
spawnWorker(instanceId: string): Promise<unknown>;
|
|
14
15
|
getWorker(instanceId: string): unknown | undefined;
|
|
15
16
|
}
|
|
16
17
|
/**
|
|
17
18
|
* Check whether a process already has an event of the given type.
|
|
18
19
|
*/
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
declare function hasProcessEvent(events: ProcessEventRepoLike, instanceId: string, eventType: string): boolean;
|
|
21
|
+
declare function processNeedsWorker(process: Pick<ProcessInstance, "selectedTurnId" | "lifecycleStatus">): boolean;
|
|
21
22
|
/**
|
|
22
23
|
* Spawn a worker for a process whose selected turn is runnable but currently has
|
|
23
24
|
* no running worker. No-ops when the process is not worker-runnable or already
|
|
24
25
|
* has a worker.
|
|
25
26
|
*/
|
|
26
|
-
|
|
27
|
+
declare function ensureWorkerForActiveAgent(deps: {
|
|
27
28
|
events: ProcessEventRepoLike;
|
|
28
29
|
supervisor: WorkerSupervisorLike;
|
|
29
30
|
}, process: ProcessInstance): Promise<void>;
|
|
30
|
-
|
|
31
|
+
|
|
32
|
+
export { type ProcessEventRepoLike, type WorkerSupervisorLike, ensureWorkerForActiveAgent, hasProcessEvent, processNeedsWorker };
|
package/dist/process-helpers.js
CHANGED
|
@@ -1,33 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
* Spawn a worker for a process whose selected turn is runnable but currently has
|
|
12
|
-
* no running worker. No-ops when the process is not worker-runnable or already
|
|
13
|
-
* has a worker.
|
|
14
|
-
*/
|
|
15
|
-
export async function ensureWorkerForActiveAgent(deps, process) {
|
|
16
|
-
if (!processNeedsWorker(process) || deps.supervisor.getWorker(process.id)) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
try {
|
|
20
|
-
await deps.supervisor.spawnWorker(process.id);
|
|
21
|
-
}
|
|
22
|
-
catch (error) {
|
|
23
|
-
deps.events.create({
|
|
24
|
-
instanceId: process.id,
|
|
25
|
-
eventType: "worker_spawn_failed",
|
|
26
|
-
data: {
|
|
27
|
-
reason: error instanceof Error ? error.message : "Failed to spawn worker",
|
|
28
|
-
},
|
|
29
|
-
});
|
|
30
|
-
throw error;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
ensureWorkerForActiveAgent,
|
|
3
|
+
hasProcessEvent,
|
|
4
|
+
processNeedsWorker
|
|
5
|
+
} from "./chunk-3KGAUQIG.js";
|
|
6
|
+
export {
|
|
7
|
+
ensureWorkerForActiveAgent,
|
|
8
|
+
hasProcessEvent,
|
|
9
|
+
processNeedsWorker
|
|
10
|
+
};
|
|
33
11
|
//# sourceMappingURL=process-helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,32 +1,33 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
|
|
1
|
+
import { ProcessInstance, TurnId } from '@leitwerk-dev/domain';
|
|
2
|
+
import { ExternalWriteLogRepoLike, WriteIdentity } from '@leitwerk-dev/external-writes';
|
|
3
|
+
import { KnownDurableWsFrameType, WsPayloadByType } from '@leitwerk-dev/protocol';
|
|
4
|
+
import { PollResult } from './poll-loop.js';
|
|
5
|
+
import { ProcessEventRepoLike, WorkerSupervisorLike } from './process-helpers.js';
|
|
6
|
+
|
|
7
|
+
interface AgentRepoAccessorLike {
|
|
7
8
|
getById(id: string): ProcessInstance | null;
|
|
8
9
|
}
|
|
9
|
-
|
|
10
|
+
interface BroadcasterLike {
|
|
10
11
|
sendDurable<T extends KnownDurableWsFrameType>(type: T, payload: WsPayloadByType[T], instanceId?: string): void;
|
|
11
12
|
}
|
|
12
|
-
|
|
13
|
+
interface WatcherCommandResult {
|
|
13
14
|
ok: boolean;
|
|
14
15
|
code?: string;
|
|
15
16
|
message?: string;
|
|
16
17
|
process?: ProcessInstance | null;
|
|
17
18
|
}
|
|
18
|
-
|
|
19
|
+
interface WatcherCommandServiceLike {
|
|
19
20
|
startProcess(instanceId: string, startTurnId: TurnId): Promise<WatcherCommandResult>;
|
|
20
21
|
abortProcess(instanceId: string): Promise<WatcherCommandResult>;
|
|
21
22
|
}
|
|
22
|
-
|
|
23
|
+
interface WatcherStartupDeps {
|
|
23
24
|
processes: AgentRepoAccessorLike;
|
|
24
25
|
events: ProcessEventRepoLike;
|
|
25
26
|
broadcaster: BroadcasterLike;
|
|
26
27
|
commands: WatcherCommandServiceLike;
|
|
27
28
|
supervisor: WorkerSupervisorLike;
|
|
28
29
|
}
|
|
29
|
-
|
|
30
|
+
interface ContinueWatcherAgentStartupOptions {
|
|
30
31
|
process: ProcessInstance;
|
|
31
32
|
startTurnId: TurnId;
|
|
32
33
|
createdEventData: Record<string, unknown>;
|
|
@@ -36,13 +37,13 @@ export interface ContinueWatcherAgentStartupOptions {
|
|
|
36
37
|
afterCreatedEvent?: (process: ProcessInstance) => Promise<void> | void;
|
|
37
38
|
beforeStart?: (process: ProcessInstance) => Promise<void>;
|
|
38
39
|
}
|
|
39
|
-
|
|
40
|
+
declare function requireWatcherStartTurnId(launchPlan: {
|
|
40
41
|
launcherId: string;
|
|
41
42
|
startTurnId: TurnId | null;
|
|
42
43
|
}, targetLabel: string): TurnId;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
declare function continueWatcherAgentStartup(deps: WatcherStartupDeps, opts: ContinueWatcherAgentStartupOptions): Promise<string>;
|
|
45
|
+
type DiscoveryResumeResult = "handled" | "skipped" | undefined;
|
|
46
|
+
type DiscoveryCreateResult = {
|
|
46
47
|
outcome: "created";
|
|
47
48
|
instanceId: string;
|
|
48
49
|
} | {
|
|
@@ -50,7 +51,7 @@ export type DiscoveryCreateResult = {
|
|
|
50
51
|
} | {
|
|
51
52
|
outcome: "handled";
|
|
52
53
|
} | null | undefined;
|
|
53
|
-
|
|
54
|
+
interface DiscoveryPassOptions<TItem> {
|
|
54
55
|
items: readonly TItem[];
|
|
55
56
|
result: PollResult;
|
|
56
57
|
findExistingAgent(item: TItem): ProcessInstance | null;
|
|
@@ -60,8 +61,8 @@ export interface DiscoveryPassOptions<TItem> {
|
|
|
60
61
|
ensureWorkerForExistingAgent?(process: ProcessInstance, item: TItem): Promise<boolean>;
|
|
61
62
|
formatError(item: TItem, error: unknown): string;
|
|
62
63
|
}
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
declare function runWatcherDiscoveryPass<TItem>(opts: DiscoveryPassOptions<TItem>): Promise<void>;
|
|
65
|
+
interface AbortReconciliationOptions {
|
|
65
66
|
candidates: readonly ProcessInstance[];
|
|
66
67
|
result: PollResult;
|
|
67
68
|
events: ProcessEventRepoLike;
|
|
@@ -71,13 +72,13 @@ export interface AbortReconciliationOptions {
|
|
|
71
72
|
getErrorLabel(process: ProcessInstance): string;
|
|
72
73
|
getAbortedEventData(process: ProcessInstance): Record<string, unknown>;
|
|
73
74
|
}
|
|
74
|
-
|
|
75
|
-
|
|
75
|
+
declare function runWatcherAbortReconciliation(opts: AbortReconciliationOptions): Promise<void>;
|
|
76
|
+
interface CompletionReconciliationResult {
|
|
76
77
|
changed: boolean;
|
|
77
78
|
writeIdentity?: WriteIdentity;
|
|
78
79
|
metadata?: Record<string, unknown>;
|
|
79
80
|
}
|
|
80
|
-
|
|
81
|
+
interface CompletionReconciliationOptions {
|
|
81
82
|
candidates: readonly ProcessInstance[];
|
|
82
83
|
result: PollResult;
|
|
83
84
|
externalWrites: ExternalWriteLogRepoLike;
|
|
@@ -85,15 +86,16 @@ export interface CompletionReconciliationOptions {
|
|
|
85
86
|
getResultLabel(process: ProcessInstance): string;
|
|
86
87
|
getErrorLabel(process: ProcessInstance): string;
|
|
87
88
|
}
|
|
88
|
-
|
|
89
|
-
|
|
89
|
+
declare function runWatcherCompletionReconciliation(opts: CompletionReconciliationOptions): Promise<void>;
|
|
90
|
+
declare function shouldEnsureWorkerForExistingActiveAgent(deps: {
|
|
90
91
|
supervisor: WorkerSupervisorLike;
|
|
91
92
|
}, process: ProcessInstance): boolean;
|
|
92
|
-
|
|
93
|
+
declare function deferWatcherLaunchStart<TLaunchPlan extends {
|
|
93
94
|
startTurnId: unknown;
|
|
94
95
|
}>(launchPlan: TLaunchPlan): TLaunchPlan;
|
|
95
|
-
|
|
96
|
+
declare function launchFailureMessage(result: {
|
|
96
97
|
status: number;
|
|
97
98
|
body: Record<string, unknown>;
|
|
98
99
|
}): string;
|
|
99
|
-
|
|
100
|
+
|
|
101
|
+
export { type AbortReconciliationOptions, type AgentRepoAccessorLike, type BroadcasterLike, type CompletionReconciliationOptions, type CompletionReconciliationResult, type ContinueWatcherAgentStartupOptions, type DiscoveryCreateResult, type DiscoveryPassOptions, type DiscoveryResumeResult, type WatcherCommandResult, type WatcherCommandServiceLike, type WatcherStartupDeps, continueWatcherAgentStartup, deferWatcherLaunchStart, launchFailureMessage, requireWatcherStartTurnId, runWatcherAbortReconciliation, runWatcherCompletionReconciliation, runWatcherDiscoveryPass, shouldEnsureWorkerForExistingActiveAgent };
|
|
@@ -1,131 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const startResult = await deps.commands.startProcess(currentProcess.id, opts.startTurnId);
|
|
23
|
-
if (!startResult.ok) {
|
|
24
|
-
currentProcess = startResult.process ?? currentProcess;
|
|
25
|
-
throw new Error(startResult.message ?? "Failed to start process");
|
|
26
|
-
}
|
|
27
|
-
currentProcess = startResult.process ?? currentProcess;
|
|
28
|
-
if (opts.broadcastCreated !== false) {
|
|
29
|
-
deps.broadcaster.sendDurable("process.created", {
|
|
30
|
-
process: currentProcess,
|
|
31
|
-
processId: currentProcess.processId,
|
|
32
|
-
...opts.createdBroadcastData,
|
|
33
|
-
}, currentProcess.id);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
await ensureWorkerForActiveAgent(deps, currentProcess);
|
|
37
|
-
return currentProcess.id;
|
|
38
|
-
}
|
|
39
|
-
export async function runWatcherDiscoveryPass(opts) {
|
|
40
|
-
for (const item of opts.items) {
|
|
41
|
-
try {
|
|
42
|
-
const existingAgent = opts.findExistingAgent(item);
|
|
43
|
-
if (existingAgent) {
|
|
44
|
-
if (existingAgent.lifecycleStatus === "discovered") {
|
|
45
|
-
const resumeResult = await opts.resumeDiscoveredAgent(existingAgent, item);
|
|
46
|
-
if (resumeResult === "skipped") {
|
|
47
|
-
opts.result.skipped.push(opts.getResultLabel(item));
|
|
48
|
-
}
|
|
49
|
-
continue;
|
|
50
|
-
}
|
|
51
|
-
if (opts.ensureWorkerForExistingAgent) {
|
|
52
|
-
const handled = await opts.ensureWorkerForExistingAgent(existingAgent, item);
|
|
53
|
-
if (handled) {
|
|
54
|
-
continue;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
opts.result.skipped.push(opts.getResultLabel(item));
|
|
58
|
-
continue;
|
|
59
|
-
}
|
|
60
|
-
const createResult = await opts.createAgent(item);
|
|
61
|
-
if (createResult?.outcome === "created") {
|
|
62
|
-
opts.result.created.push(opts.getResultLabel(item));
|
|
63
|
-
continue;
|
|
64
|
-
}
|
|
65
|
-
if (createResult?.outcome === "skipped") {
|
|
66
|
-
opts.result.skipped.push(opts.getResultLabel(item));
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
catch (error) {
|
|
70
|
-
opts.result.errors.push(opts.formatError(item, error));
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
export async function runWatcherAbortReconciliation(opts) {
|
|
75
|
-
for (const process of opts.candidates) {
|
|
76
|
-
try {
|
|
77
|
-
const shouldAbort = await opts.shouldAbort(process);
|
|
78
|
-
if (!shouldAbort) {
|
|
79
|
-
continue;
|
|
80
|
-
}
|
|
81
|
-
const abortResult = await opts.commands.abortProcess(process.id);
|
|
82
|
-
if (!abortResult.ok) {
|
|
83
|
-
if (abortResult.code === "worker_reconcile_failed") {
|
|
84
|
-
throw new Error(abortResult.message ?? "Failed to abort process");
|
|
85
|
-
}
|
|
86
|
-
continue;
|
|
87
|
-
}
|
|
88
|
-
const abortedAgent = abortResult.process ?? process;
|
|
89
|
-
if (!hasProcessEvent(opts.events, abortedAgent.id, "aborted_label_removed")) {
|
|
90
|
-
opts.events.create({
|
|
91
|
-
instanceId: abortedAgent.id,
|
|
92
|
-
eventType: "aborted_label_removed",
|
|
93
|
-
data: opts.getAbortedEventData(abortedAgent),
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
opts.result.aborted.push(opts.getResultLabel(process));
|
|
97
|
-
}
|
|
98
|
-
catch (error) {
|
|
99
|
-
opts.result.errors.push(`${opts.getErrorLabel(process)}: ${error instanceof Error ? error.message : String(error)}`);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
export async function runWatcherCompletionReconciliation(opts) {
|
|
104
|
-
for (const process of opts.candidates) {
|
|
105
|
-
try {
|
|
106
|
-
const reconciliation = await opts.reconcile(process);
|
|
107
|
-
if (!reconciliation.changed) {
|
|
108
|
-
continue;
|
|
109
|
-
}
|
|
110
|
-
if (reconciliation.writeIdentity) {
|
|
111
|
-
recordWriteIfMissing(opts.externalWrites, process.id, reconciliation.writeIdentity, reconciliation.metadata);
|
|
112
|
-
}
|
|
113
|
-
opts.result.labelExchanged.push(opts.getResultLabel(process));
|
|
114
|
-
}
|
|
115
|
-
catch (error) {
|
|
116
|
-
opts.result.errors.push(`${opts.getErrorLabel(process)}: ${error instanceof Error ? error.message : String(error)}`);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
export function shouldEnsureWorkerForExistingActiveAgent(deps, process) {
|
|
121
|
-
return processNeedsWorker(process) && !deps.supervisor.getWorker(process.id);
|
|
122
|
-
}
|
|
123
|
-
export function deferWatcherLaunchStart(launchPlan) {
|
|
124
|
-
return launchPlan.startTurnId === null ? launchPlan : { ...launchPlan, startTurnId: null };
|
|
125
|
-
}
|
|
126
|
-
export function launchFailureMessage(result) {
|
|
127
|
-
return typeof result.body.error === "string" && result.body.error.trim().length > 0
|
|
128
|
-
? result.body.error
|
|
129
|
-
: `Process launch failed with status ${result.status}`;
|
|
130
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
continueWatcherAgentStartup,
|
|
3
|
+
deferWatcherLaunchStart,
|
|
4
|
+
launchFailureMessage,
|
|
5
|
+
requireWatcherStartTurnId,
|
|
6
|
+
runWatcherAbortReconciliation,
|
|
7
|
+
runWatcherCompletionReconciliation,
|
|
8
|
+
runWatcherDiscoveryPass,
|
|
9
|
+
shouldEnsureWorkerForExistingActiveAgent
|
|
10
|
+
} from "./chunk-XLVMFO6W.js";
|
|
11
|
+
import "./chunk-3KGAUQIG.js";
|
|
12
|
+
export {
|
|
13
|
+
continueWatcherAgentStartup,
|
|
14
|
+
deferWatcherLaunchStart,
|
|
15
|
+
launchFailureMessage,
|
|
16
|
+
requireWatcherStartTurnId,
|
|
17
|
+
runWatcherAbortReconciliation,
|
|
18
|
+
runWatcherCompletionReconciliation,
|
|
19
|
+
runWatcherDiscoveryPass,
|
|
20
|
+
shouldEnsureWorkerForExistingActiveAgent
|
|
21
|
+
};
|
|
131
22
|
//# sourceMappingURL=watcher-coordinator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leitwerk-dev/watcher-utils",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/leitwerk-dev/leitwerk.git",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"build": "tsup --silent"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@leitwerk-dev/domain": "0.1.
|
|
22
|
-
"@leitwerk-dev/external-writes": "0.1.
|
|
23
|
-
"@leitwerk-dev/protocol": "0.1.
|
|
21
|
+
"@leitwerk-dev/domain": "0.1.2",
|
|
22
|
+
"@leitwerk-dev/external-writes": "0.1.2",
|
|
23
|
+
"@leitwerk-dev/protocol": "0.1.2",
|
|
24
24
|
"ms": "^2.1.3"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"duration-parse.d.ts","sourceRoot":"","sources":["../src/duration-parse.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,wBAAgB,eAAe,CAC9B,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,QAAQ,GAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAO,GACrC,MAAM,CAOR"}
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAC1F,OAAO,EACN,mBAAmB,EACnB,KAAK,iBAAiB,EACtB,KAAK,2BAA2B,EAChC,KAAK,wBAAwB,EAC7B,WAAW,EACX,oBAAoB,EACpB,KAAK,aAAa,GAClB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EACN,cAAc,EACd,eAAe,EACf,KAAK,QAAQ,EACb,KAAK,UAAU,GACf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACN,0BAA0B,EAC1B,eAAe,EACf,KAAK,oBAAoB,EACzB,kBAAkB,EAClB,KAAK,oBAAoB,GACzB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACN,kBAAkB,EAClB,SAAS,EACT,eAAe,EACf,KAAK,qBAAqB,GAC1B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACN,KAAK,qBAAqB,EAC1B,KAAK,eAAe,EACpB,KAAK,+BAA+B,EACpC,KAAK,8BAA8B,EACnC,KAAK,kCAAkC,EACvC,2BAA2B,EAC3B,KAAK,oBAAoB,EACzB,uBAAuB,EACvB,oBAAoB,EACpB,yBAAyB,EACzB,6BAA6B,EAC7B,kCAAkC,EAClC,uBAAuB,EACvB,wCAAwC,EACxC,KAAK,oBAAoB,EACzB,KAAK,yBAAyB,EAC9B,KAAK,kBAAkB,GACvB,MAAM,0BAA0B,CAAC"}
|
package/dist/poll-loop.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"poll-loop.d.ts","sourceRoot":"","sources":["../src/poll-loop.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,UAAU;IAC1B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,MAAM,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,wBAAgB,eAAe,IAAI,UAAU,CAQ5C;AAED,MAAM,WAAW,QAAQ,CAAC,CAAC,SAAS,UAAU,GAAG,UAAU;IAC1D,IAA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EAAE,IAAI,CAAC,eAAe,EAAE,gBAAgB,GAAG,iBAAiB,CAAC,GAClE,OAAO,CAET;AAED;;;;GAIG;AACH,wBAAsB,0BAA0B,CAC/C,IAAI,EAAE;IAAE,MAAM,EAAE,oBAAoB,CAAC;IAAC,UAAU,EAAE,oBAAoB,CAAA;CAAE,EACxE,OAAO,EAAE,eAAe,GACtB,OAAO,CAAC,IAAI,CAAC,CAgBf"}
|
package/dist/trigger-files.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export type TriggerFileReadResult = {
|
|
2
|
-
exists: false;
|
|
3
|
-
} | {
|
|
4
|
-
exists: true;
|
|
5
|
-
content: string;
|
|
6
|
-
};
|
|
7
|
-
export declare function errorCode(error: unknown): string | null;
|
|
8
|
-
export declare function readTriggerFile(filePath: string): Promise<TriggerFileReadResult>;
|
|
9
|
-
export declare function consumeTriggerFile(filePath: string): Promise<void>;
|
|
10
|
-
//# sourceMappingURL=trigger-files.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"trigger-files.d.ts","sourceRoot":"","sources":["../src/trigger-files.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,qBAAqB,GAAG;IAAE,MAAM,EAAE,KAAK,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1F,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAMvD;AAED,wBAAsB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAStF;AAED,wBAAsB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CASxE"}
|
package/dist/trigger-files.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { readFile, unlink } from "node:fs/promises";
|
|
2
|
-
export function errorCode(error) {
|
|
3
|
-
if (typeof error !== "object" || error === null || !("code" in error)) {
|
|
4
|
-
return null;
|
|
5
|
-
}
|
|
6
|
-
const code = error.code;
|
|
7
|
-
return typeof code === "string" ? code : null;
|
|
8
|
-
}
|
|
9
|
-
export async function readTriggerFile(filePath) {
|
|
10
|
-
try {
|
|
11
|
-
return { exists: true, content: await readFile(filePath, "utf8") };
|
|
12
|
-
}
|
|
13
|
-
catch (error) {
|
|
14
|
-
if (errorCode(error) === "ENOENT") {
|
|
15
|
-
return { exists: false };
|
|
16
|
-
}
|
|
17
|
-
throw error;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
export async function consumeTriggerFile(filePath) {
|
|
21
|
-
try {
|
|
22
|
-
await unlink(filePath);
|
|
23
|
-
}
|
|
24
|
-
catch (error) {
|
|
25
|
-
if (errorCode(error) === "ENOENT") {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
throw error;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
//# sourceMappingURL=trigger-files.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"trigger-files.js","sourceRoot":"","sources":["../src/trigger-files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAIpD,MAAM,UAAU,SAAS,CAAC,KAAc;IACvC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,CAAC,MAAM,IAAI,KAAK,CAAC,EAAE,CAAC;QACvE,OAAO,IAAI,CAAC;IACb,CAAC;IACD,MAAM,IAAI,GAAI,KAA4B,CAAC,IAAI,CAAC;IAChD,OAAO,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;AAC/C,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,QAAgB;IACrD,IAAI,CAAC;QACJ,OAAO,EAAE,MAAM,EA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