@leitwerk-dev/watcher-utils 0.1.9 → 0.2.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/dist/{chunk-XF2QQLPO.js → chunk-BO52GPAV.js} +22 -11
- package/dist/chunk-BO52GPAV.js.map +1 -0
- package/dist/{chunk-IU3L35PC.js → chunk-D57H46H7.js} +1 -1
- package/dist/chunk-D57H46H7.js.map +1 -0
- package/dist/{chunk-3KGAUQIG.js → chunk-EWA6E2ZM.js} +1 -1
- package/dist/chunk-EWA6E2ZM.js.map +1 -0
- package/dist/chunk-ZW3LXDBX.js +46 -0
- package/dist/chunk-ZW3LXDBX.js.map +1 -0
- package/dist/duration-parse.d.ts +2 -0
- package/dist/duration-parse.d.ts.map +1 -1
- package/dist/duration-parse.js +6 -15
- package/dist/duration-parse.js.map +1 -1
- package/dist/index.d.ts +3 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +48 -5
- package/dist/index.js.map +1 -1
- package/dist/poll-loop.d.ts +30 -3
- package/dist/poll-loop.d.ts.map +1 -1
- package/dist/poll-loop.js +11 -58
- package/dist/poll-loop.js.map +1 -1
- package/dist/polling-coordinator.d.ts +38 -0
- package/dist/polling-coordinator.d.ts.map +1 -0
- package/dist/polling-coordinator.js +9 -0
- package/dist/polling-coordinator.js.map +1 -0
- package/dist/process-helpers.d.ts +15 -0
- package/dist/process-helpers.d.ts.map +1 -1
- package/dist/process-helpers.js +10 -32
- package/dist/process-helpers.js.map +1 -1
- package/dist/trigger-files.d.ts +7 -0
- package/dist/trigger-files.d.ts.map +1 -1
- package/dist/watcher-coordinator.d.ts +77 -2
- package/dist/watcher-coordinator.d.ts.map +1 -1
- package/dist/watcher-coordinator.js +142 -114
- package/dist/watcher-coordinator.js.map +1 -1
- package/package.json +5 -5
- package/src/duration-parse.ts +5 -1
- package/src/index.ts +2 -30
- package/src/poll-loop.ts +50 -12
- package/src/polling-coordinator.ts +83 -0
- package/src/process-helpers.ts +30 -3
- package/src/trigger-files.ts +15 -1
- package/src/watcher-coordinator.ts +99 -11
- package/dist/chunk-3KGAUQIG.js.map +0 -1
- package/dist/chunk-IU3L35PC.js.map +0 -1
- package/dist/chunk-XF2QQLPO.js.map +0 -1
- package/dist/chunk-XLVMFO6W.js +0 -160
- package/dist/chunk-XLVMFO6W.js.map +0 -1
- package/dist/trigger-files.js +0 -31
- package/dist/trigger-files.js.map +0 -1
|
@@ -1,99 +1,174 @@
|
|
|
1
1
|
import type { ProcessInstance, TurnId } from "@leitwerk-dev/domain";
|
|
2
|
-
import
|
|
2
|
+
import type { WriteIdentity } from "@leitwerk-dev/external-writes";
|
|
3
|
+
import { type ExternalWriteLogRepoLike } from "@leitwerk-dev/external-writes/internal";
|
|
3
4
|
import type { KnownDurableWsFrameType, WsPayloadByType } from "@leitwerk-dev/protocol";
|
|
4
5
|
import type { PollResult } from "./poll-loop.js";
|
|
5
6
|
import { type ProcessEventRepoLike, type WorkerSupervisorLike } from "./process-helpers.js";
|
|
7
|
+
/** @internal */
|
|
6
8
|
export interface AgentRepoAccessorLike {
|
|
9
|
+
/** @internal */
|
|
7
10
|
getById(id: string): ProcessInstance | null;
|
|
8
11
|
}
|
|
12
|
+
/** @internal */
|
|
9
13
|
export interface BroadcasterLike {
|
|
14
|
+
/** @internal */
|
|
10
15
|
sendDurable<T extends KnownDurableWsFrameType>(type: T, payload: WsPayloadByType[T], instanceId?: string): void;
|
|
11
16
|
}
|
|
17
|
+
/** @internal */
|
|
12
18
|
export interface WatcherCommandResult {
|
|
19
|
+
/** @internal */
|
|
13
20
|
ok: boolean;
|
|
21
|
+
/** @internal */
|
|
14
22
|
code?: string;
|
|
23
|
+
/** @internal */
|
|
15
24
|
message?: string;
|
|
25
|
+
/** @internal */
|
|
16
26
|
process?: ProcessInstance | null;
|
|
17
27
|
}
|
|
28
|
+
/** @internal */
|
|
18
29
|
export interface WatcherCommandServiceLike {
|
|
30
|
+
/** @internal */
|
|
19
31
|
startProcess(instanceId: string, startTurnId: TurnId): Promise<WatcherCommandResult>;
|
|
32
|
+
/** @internal */
|
|
20
33
|
abortProcess(instanceId: string): Promise<WatcherCommandResult>;
|
|
21
34
|
}
|
|
35
|
+
/** @internal */
|
|
22
36
|
export interface WatcherStartupDeps {
|
|
37
|
+
/** @internal */
|
|
23
38
|
processes: AgentRepoAccessorLike;
|
|
39
|
+
/** @internal */
|
|
24
40
|
events: ProcessEventRepoLike;
|
|
41
|
+
/** @internal */
|
|
25
42
|
broadcaster: BroadcasterLike;
|
|
43
|
+
/** @internal */
|
|
26
44
|
commands: WatcherCommandServiceLike;
|
|
45
|
+
/** @internal */
|
|
27
46
|
supervisor: WorkerSupervisorLike;
|
|
28
47
|
}
|
|
48
|
+
/** @internal */
|
|
29
49
|
export interface ContinueWatcherAgentStartupOptions {
|
|
50
|
+
/** @internal */
|
|
30
51
|
process: ProcessInstance;
|
|
52
|
+
/** @internal */
|
|
31
53
|
startTurnId: TurnId;
|
|
54
|
+
/** @internal */
|
|
32
55
|
createdEventData: Record<string, unknown>;
|
|
56
|
+
/** @internal */
|
|
33
57
|
createdBroadcastData: Record<string, unknown>;
|
|
34
|
-
/** Defaults to true. Set false when the shared launch executor already emitted process.created. */
|
|
58
|
+
/** Defaults to true. Set false when the shared launch executor already emitted process.created. @internal */
|
|
35
59
|
broadcastCreated?: boolean;
|
|
60
|
+
/** @internal */
|
|
36
61
|
afterCreatedEvent?: (process: ProcessInstance) => Promise<void> | void;
|
|
62
|
+
/** @internal */
|
|
37
63
|
beforeStart?: (process: ProcessInstance) => Promise<void>;
|
|
38
64
|
}
|
|
65
|
+
/** @internal */
|
|
39
66
|
export declare function requireWatcherStartTurnId(launchPlan: {
|
|
67
|
+
/** @internal */
|
|
40
68
|
launcherId: string;
|
|
69
|
+
/** @internal */
|
|
41
70
|
startTurnId: TurnId | null;
|
|
42
71
|
}, targetLabel: string): TurnId;
|
|
72
|
+
/** @internal */
|
|
43
73
|
export declare function continueWatcherAgentStartup(deps: WatcherStartupDeps, opts: ContinueWatcherAgentStartupOptions): Promise<string>;
|
|
74
|
+
/** @internal */
|
|
44
75
|
export type DiscoveryResumeResult = "handled" | "skipped" | undefined;
|
|
76
|
+
/** @internal */
|
|
45
77
|
export type DiscoveryCreateResult = {
|
|
78
|
+
/** @internal */
|
|
46
79
|
outcome: "created";
|
|
80
|
+
/** @internal */
|
|
47
81
|
instanceId: string;
|
|
48
82
|
} | {
|
|
83
|
+
/** @internal */
|
|
49
84
|
outcome: "skipped";
|
|
50
85
|
} | {
|
|
86
|
+
/** @internal */
|
|
51
87
|
outcome: "handled";
|
|
52
88
|
} | null | undefined;
|
|
89
|
+
/** @internal */
|
|
53
90
|
export interface DiscoveryPassOptions<TItem> {
|
|
91
|
+
/** @internal */
|
|
54
92
|
items: readonly TItem[];
|
|
93
|
+
/** @internal */
|
|
55
94
|
result: PollResult;
|
|
95
|
+
/** @internal */
|
|
56
96
|
findExistingAgent(item: TItem): ProcessInstance | null;
|
|
97
|
+
/** @internal */
|
|
57
98
|
getResultLabel(item: TItem): string;
|
|
99
|
+
/** @internal */
|
|
58
100
|
resumeDiscoveredAgent(process: ProcessInstance, item: TItem): Promise<DiscoveryResumeResult>;
|
|
101
|
+
/** @internal */
|
|
59
102
|
createAgent(item: TItem): Promise<DiscoveryCreateResult>;
|
|
103
|
+
/** @internal */
|
|
60
104
|
ensureWorkerForExistingAgent?(process: ProcessInstance, item: TItem): Promise<boolean>;
|
|
105
|
+
/** @internal */
|
|
61
106
|
formatError(item: TItem, error: unknown): string;
|
|
62
107
|
}
|
|
108
|
+
/** @internal */
|
|
63
109
|
export declare function runWatcherDiscoveryPass<TItem>(opts: DiscoveryPassOptions<TItem>): Promise<void>;
|
|
110
|
+
/** @internal */
|
|
64
111
|
export interface AbortReconciliationOptions {
|
|
112
|
+
/** @internal */
|
|
65
113
|
candidates: readonly ProcessInstance[];
|
|
114
|
+
/** @internal */
|
|
66
115
|
result: PollResult;
|
|
116
|
+
/** @internal */
|
|
67
117
|
events: ProcessEventRepoLike;
|
|
118
|
+
/** @internal */
|
|
68
119
|
commands: WatcherCommandServiceLike;
|
|
120
|
+
/** @internal */
|
|
69
121
|
shouldAbort(process: ProcessInstance): Promise<boolean>;
|
|
122
|
+
/** @internal */
|
|
70
123
|
getResultLabel(process: ProcessInstance): string;
|
|
124
|
+
/** @internal */
|
|
71
125
|
getErrorLabel(process: ProcessInstance): string;
|
|
126
|
+
/** @internal */
|
|
72
127
|
getAbortedEventData(process: ProcessInstance): Record<string, unknown>;
|
|
73
128
|
}
|
|
129
|
+
/** @internal */
|
|
74
130
|
export declare function runWatcherAbortReconciliation(opts: AbortReconciliationOptions): Promise<void>;
|
|
131
|
+
/** @internal */
|
|
75
132
|
export interface CompletionReconciliationResult {
|
|
133
|
+
/** @internal */
|
|
76
134
|
changed: boolean;
|
|
135
|
+
/** @internal */
|
|
77
136
|
writeIdentity?: WriteIdentity;
|
|
137
|
+
/** @internal */
|
|
78
138
|
metadata?: Record<string, unknown>;
|
|
79
139
|
}
|
|
140
|
+
/** @internal */
|
|
80
141
|
export interface CompletionReconciliationOptions {
|
|
142
|
+
/** @internal */
|
|
81
143
|
candidates: readonly ProcessInstance[];
|
|
144
|
+
/** @internal */
|
|
82
145
|
result: PollResult;
|
|
146
|
+
/** @internal */
|
|
83
147
|
externalWrites: ExternalWriteLogRepoLike;
|
|
148
|
+
/** @internal */
|
|
84
149
|
reconcile(process: ProcessInstance): Promise<CompletionReconciliationResult>;
|
|
150
|
+
/** @internal */
|
|
85
151
|
getResultLabel(process: ProcessInstance): string;
|
|
152
|
+
/** @internal */
|
|
86
153
|
getErrorLabel(process: ProcessInstance): string;
|
|
87
154
|
}
|
|
155
|
+
/** @internal */
|
|
88
156
|
export declare function runWatcherCompletionReconciliation(opts: CompletionReconciliationOptions): Promise<void>;
|
|
157
|
+
/** @internal */
|
|
89
158
|
export declare function shouldEnsureWorkerForExistingActiveAgent(deps: {
|
|
159
|
+
/** @internal */
|
|
90
160
|
supervisor: WorkerSupervisorLike;
|
|
91
161
|
}, process: ProcessInstance): boolean;
|
|
162
|
+
/** @internal */
|
|
92
163
|
export declare function deferWatcherLaunchStart<TLaunchPlan extends {
|
|
164
|
+
/** @internal */
|
|
93
165
|
startTurnId: unknown;
|
|
94
166
|
}>(launchPlan: TLaunchPlan): TLaunchPlan;
|
|
167
|
+
/** @internal */
|
|
95
168
|
export declare function launchFailureMessage(result: {
|
|
169
|
+
/** @internal */
|
|
96
170
|
status: number;
|
|
171
|
+
/** @internal */
|
|
97
172
|
body: Record<string, unknown>;
|
|
98
173
|
}): string;
|
|
99
174
|
//# sourceMappingURL=watcher-coordinator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watcher-coordinator.d.ts","sourceRoot":"","sources":["../src/watcher-coordinator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,
|
|
1
|
+
{"version":3,"file":"watcher-coordinator.d.ts","sourceRoot":"","sources":["../src/watcher-coordinator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EACN,KAAK,wBAAwB,EAE7B,MAAM,wCAAwC,CAAC;AAChD,OAAO,KAAK,EAAE,uBAAuB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACvF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAGN,KAAK,oBAAoB,EAEzB,KAAK,oBAAoB,EACzB,MAAM,sBAAsB,CAAC;AAE9B,gBAAgB;AAChB,MAAM,WAAW,qBAAqB;IACrC,gBAAgB;IAChB,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI,CAAC;CAC5C;AAED,gBAAgB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I,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC9B,GAAG,MAAM,CAIT"}
|
|
@@ -1,131 +1,159 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import {
|
|
2
|
+
ensureWorkerForActiveAgent,
|
|
3
|
+
hasProcessEvent,
|
|
4
|
+
processNeedsWorker
|
|
5
|
+
} from "./chunk-EWA6E2ZM.js";
|
|
6
|
+
|
|
7
|
+
// src/watcher-coordinator.ts
|
|
8
|
+
import {
|
|
9
|
+
recordWriteIfMissing
|
|
10
|
+
} from "@leitwerk-dev/external-writes/internal";
|
|
11
|
+
function requireWatcherStartTurnId(launchPlan, targetLabel) {
|
|
12
|
+
if (launchPlan.startTurnId) {
|
|
13
|
+
return launchPlan.startTurnId;
|
|
14
|
+
}
|
|
15
|
+
throw new Error(
|
|
16
|
+
`Watcher launcher '${launchPlan.launcherId}' did not declare a startTurnId for ${targetLabel}`
|
|
17
|
+
);
|
|
8
18
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
19
|
+
async function continueWatcherAgentStartup(deps, opts) {
|
|
20
|
+
const { process } = opts;
|
|
21
|
+
if (!hasProcessEvent(deps.events, process.id, "agent_created")) {
|
|
22
|
+
deps.events.create({
|
|
23
|
+
instanceId: process.id,
|
|
24
|
+
eventType: "agent_created",
|
|
25
|
+
data: opts.createdEventData
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
await opts.afterCreatedEvent?.(process);
|
|
29
|
+
await opts.beforeStart?.(process);
|
|
30
|
+
let currentProcess = deps.processes.getById(process.id) ?? process;
|
|
31
|
+
if (currentProcess.lifecycleStatus === "discovered") {
|
|
32
|
+
const startResult = await deps.commands.startProcess(currentProcess.id, opts.startTurnId);
|
|
33
|
+
if (!startResult.ok) {
|
|
34
|
+
currentProcess = startResult.process ?? currentProcess;
|
|
35
|
+
throw new Error(startResult.message ?? "Failed to start process");
|
|
17
36
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
currentProcess
|
|
28
|
-
|
|
29
|
-
deps.broadcaster.sendDurable("process.created", {
|
|
30
|
-
process: currentProcess,
|
|
31
|
-
processId: currentProcess.processId,
|
|
32
|
-
...opts.createdBroadcastData,
|
|
33
|
-
}, currentProcess.id);
|
|
34
|
-
}
|
|
37
|
+
currentProcess = startResult.process ?? currentProcess;
|
|
38
|
+
if (opts.broadcastCreated !== false) {
|
|
39
|
+
deps.broadcaster.sendDurable(
|
|
40
|
+
"process.created",
|
|
41
|
+
{
|
|
42
|
+
process: currentProcess,
|
|
43
|
+
processId: currentProcess.processId,
|
|
44
|
+
...opts.createdBroadcastData
|
|
45
|
+
},
|
|
46
|
+
currentProcess.id
|
|
47
|
+
);
|
|
35
48
|
}
|
|
36
|
-
|
|
37
|
-
|
|
49
|
+
}
|
|
50
|
+
await ensureWorkerForActiveAgent(deps, currentProcess);
|
|
51
|
+
return currentProcess.id;
|
|
38
52
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
}
|
|
53
|
+
async function runWatcherDiscoveryPass(opts) {
|
|
54
|
+
for (const item of opts.items) {
|
|
55
|
+
try {
|
|
56
|
+
const existingAgent = opts.findExistingAgent(item);
|
|
57
|
+
if (existingAgent) {
|
|
58
|
+
if (existingAgent.lifecycleStatus === "discovered") {
|
|
59
|
+
const resumeResult = await opts.resumeDiscoveredAgent(existingAgent, item);
|
|
60
|
+
if (resumeResult === "skipped") {
|
|
61
|
+
opts.result.skipped.push(opts.getResultLabel(item));
|
|
62
|
+
}
|
|
63
|
+
continue;
|
|
68
64
|
}
|
|
69
|
-
|
|
70
|
-
|
|
65
|
+
if (opts.ensureWorkerForExistingAgent) {
|
|
66
|
+
const handled = await opts.ensureWorkerForExistingAgent(existingAgent, item);
|
|
67
|
+
if (handled) {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
71
70
|
}
|
|
71
|
+
opts.result.skipped.push(opts.getResultLabel(item));
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
const createResult = await opts.createAgent(item);
|
|
75
|
+
if (createResult?.outcome === "created") {
|
|
76
|
+
opts.result.created.push(opts.getResultLabel(item));
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
if (createResult?.outcome === "skipped") {
|
|
80
|
+
opts.result.skipped.push(opts.getResultLabel(item));
|
|
81
|
+
}
|
|
82
|
+
} catch (error) {
|
|
83
|
+
opts.result.errors.push(opts.formatError(item, error));
|
|
72
84
|
}
|
|
85
|
+
}
|
|
73
86
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
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)}`);
|
|
87
|
+
async function runWatcherAbortReconciliation(opts) {
|
|
88
|
+
for (const process of opts.candidates) {
|
|
89
|
+
try {
|
|
90
|
+
const shouldAbort = await opts.shouldAbort(process);
|
|
91
|
+
if (!shouldAbort) {
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
const abortResult = await opts.commands.abortProcess(process.id);
|
|
95
|
+
if (!abortResult.ok) {
|
|
96
|
+
if (abortResult.code === "worker_reconcile_failed") {
|
|
97
|
+
throw new Error(abortResult.message ?? "Failed to abort process");
|
|
100
98
|
}
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
const abortedAgent = abortResult.process ?? process;
|
|
102
|
+
if (!hasProcessEvent(opts.events, abortedAgent.id, "aborted_label_removed")) {
|
|
103
|
+
opts.events.create({
|
|
104
|
+
instanceId: abortedAgent.id,
|
|
105
|
+
eventType: "aborted_label_removed",
|
|
106
|
+
data: opts.getAbortedEventData(abortedAgent)
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
opts.result.aborted.push(opts.getResultLabel(process));
|
|
110
|
+
} catch (error) {
|
|
111
|
+
opts.result.errors.push(
|
|
112
|
+
`${opts.getErrorLabel(process)}: ${error instanceof Error ? error.message : String(error)}`
|
|
113
|
+
);
|
|
101
114
|
}
|
|
115
|
+
}
|
|
102
116
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
117
|
+
async function runWatcherCompletionReconciliation(opts) {
|
|
118
|
+
for (const process of opts.candidates) {
|
|
119
|
+
try {
|
|
120
|
+
const reconciliation = await opts.reconcile(process);
|
|
121
|
+
if (!reconciliation.changed) {
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
if (reconciliation.writeIdentity) {
|
|
125
|
+
recordWriteIfMissing(
|
|
126
|
+
opts.externalWrites,
|
|
127
|
+
process.id,
|
|
128
|
+
reconciliation.writeIdentity,
|
|
129
|
+
reconciliation.metadata
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
opts.result.labelExchanged.push(opts.getResultLabel(process));
|
|
133
|
+
} catch (error) {
|
|
134
|
+
opts.result.errors.push(
|
|
135
|
+
`${opts.getErrorLabel(process)}: ${error instanceof Error ? error.message : String(error)}`
|
|
136
|
+
);
|
|
118
137
|
}
|
|
138
|
+
}
|
|
119
139
|
}
|
|
120
|
-
|
|
121
|
-
|
|
140
|
+
function shouldEnsureWorkerForExistingActiveAgent(deps, process) {
|
|
141
|
+
return processNeedsWorker(process) && !deps.supervisor.getWorker(process.id);
|
|
122
142
|
}
|
|
123
|
-
|
|
124
|
-
|
|
143
|
+
function deferWatcherLaunchStart(launchPlan) {
|
|
144
|
+
return launchPlan.startTurnId === null ? launchPlan : { ...launchPlan, startTurnId: null };
|
|
125
145
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
? result.body.error
|
|
129
|
-
: `Process launch failed with status ${result.status}`;
|
|
146
|
+
function launchFailureMessage(result) {
|
|
147
|
+
return typeof result.body.error === "string" && result.body.error.trim().length > 0 ? result.body.error : `Process launch failed with status ${result.status}`;
|
|
130
148
|
}
|
|
149
|
+
export {
|
|
150
|
+
continueWatcherAgentStartup,
|
|
151
|
+
deferWatcherLaunchStart,
|
|
152
|
+
launchFailureMessage,
|
|
153
|
+
requireWatcherStartTurnId,
|
|
154
|
+
runWatcherAbortReconciliation,
|
|
155
|
+
runWatcherCompletionReconciliation,
|
|
156
|
+
runWatcherDiscoveryPass,
|
|
157
|
+
shouldEnsureWorkerForExistingActiveAgent
|
|
158
|
+
};
|
|
131
159
|
//# sourceMappingURL=watcher-coordinator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watcher-coordinator.js","sourceRoot":"","sources":["../src/watcher-coordinator.ts"],"names":[],"mappings":"AACA,OAAO,EAEN,oBAAoB,GAEpB,MAAM,+BAA+B,CAAC;AAGvC,OAAO,EACN,0BAA0B,EAC1B,eAAe,EAEf,kBAAkB,GAElB,MAAM,sBAAsB,CAAC;AA6C9B,MAAM,UAAU,yBAAyB,CACxC,UAA8D,EAC9D,WAAmB;IAEnB,IAAI,UAAU,CAAC,WAAW,EAAE,CAAC;QAC5B,OAAO,UAAU,CAAC,WAAW,CAAC;IAC/B,CAAC;IACD,MAAM,IAAI,KAAK,CACd,qBAAqB,UAAU,CAAC,UAAU,uCAAuC,WAAW,EAAE,CAC9F,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAChD,IAAwB,EACxB,IAAwC;IAExC,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAEzB,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAAE,eAAe,CAAC,EAAE,CAAC;QAChE,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;YAClB,UAAU,EAAE,OAAO,CAAC,EAAE;YACtB,SAAS,EAAE,eAAe;YAC1B,IAAI,EAAE,IAAI,CAAC,gBAAgB;SAC3B,CAAC,CAAC;IACJ,CAAC;IAED,MAAM,IAAI,CAAC,iBAAiB,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K,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,GAAG,UAAU,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;AAC5F,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,MAGpC;IACA,OAAO,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC;QAClF,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK;QACnB,CAAC,CAAC,qCAAqC,MAAM,CAAC,MAAM,EAAE,CAAC;AACzD,CAAC"}
|
|
1
|
+
{"version":3,"sources":["../src/watcher-coordinator.ts"],"sourcesContent":["import type { ProcessInstance, TurnId } from \"@leitwerk-dev/domain\";\nimport type { WriteIdentity } from \"@leitwerk-dev/external-writes\";\nimport {\n\ttype ExternalWriteLogRepoLike,\n\trecordWriteIfMissing,\n} from \"@leitwerk-dev/external-writes/internal\";\nimport type { KnownDurableWsFrameType, WsPayloadByType } from \"@leitwerk-dev/protocol\";\nimport type { PollResult } from \"./poll-loop.js\";\nimport {\n\tensureWorkerForActiveAgent,\n\thasProcessEvent,\n\ttype ProcessEventRepoLike,\n\tprocessNeedsWorker,\n\ttype WorkerSupervisorLike,\n} from \"./process-helpers.js\";\n\n/** @internal */\nexport interface AgentRepoAccessorLike {\n\t/** @internal */\n\tgetById(id: string): ProcessInstance | null;\n}\n\n/** @internal */\nexport interface BroadcasterLike {\n\t/** @internal */\n\tsendDurable<T extends KnownDurableWsFrameType>(\n\t\ttype: T,\n\t\tpayload: WsPayloadByType[T],\n\t\tinstanceId?: string,\n\t): void;\n}\n\n/** @internal */\nexport interface WatcherCommandResult {\n\t/** @internal */\n\tok: boolean;\n\t/** @internal */\n\tcode?: string;\n\t/** @internal */\n\tmessage?: string;\n\t/** @internal */\n\tprocess?: ProcessInstance | null;\n}\n\n/** @internal */\nexport interface WatcherCommandServiceLike {\n\t/** @internal */\n\tstartProcess(instanceId: string, startTurnId: TurnId): Promise<WatcherCommandResult>;\n\t/** @internal */\n\tabortProcess(instanceId: string): Promise<WatcherCommandResult>;\n}\n\n/** @internal */\nexport interface WatcherStartupDeps {\n\t/** @internal */\n\tprocesses: AgentRepoAccessorLike;\n\t/** @internal */\n\tevents: ProcessEventRepoLike;\n\t/** @internal */\n\tbroadcaster: BroadcasterLike;\n\t/** @internal */\n\tcommands: WatcherCommandServiceLike;\n\t/** @internal */\n\tsupervisor: WorkerSupervisorLike;\n}\n\n/** @internal */\nexport interface ContinueWatcherAgentStartupOptions {\n\t/** @internal */\n\tprocess: ProcessInstance;\n\t/** @internal */\n\tstartTurnId: TurnId;\n\t/** @internal */\n\tcreatedEventData: Record<string, unknown>;\n\t/** @internal */\n\tcreatedBroadcastData: Record<string, unknown>;\n\t/** Defaults to true. Set false when the shared launch executor already emitted process.created. @internal */\n\tbroadcastCreated?: boolean;\n\t/** @internal */\n\tafterCreatedEvent?: (process: ProcessInstance) => Promise<void> | void;\n\t/** @internal */\n\tbeforeStart?: (process: ProcessInstance) => Promise<void>;\n}\n\n/** @internal */\nexport function requireWatcherStartTurnId(\n\tlaunchPlan: {\n\t\t/** @internal */\n\t\tlauncherId: string;\n\t\t/** @internal */\n\t\tstartTurnId: TurnId | null;\n\t},\n\ttargetLabel: string,\n): TurnId {\n\tif (launchPlan.startTurnId) {\n\t\treturn launchPlan.startTurnId;\n\t}\n\tthrow new Error(\n\t\t`Watcher launcher '${launchPlan.launcherId}' did not declare a startTurnId for ${targetLabel}`,\n\t);\n}\n\n/** @internal */\nexport async function continueWatcherAgentStartup(\n\tdeps: WatcherStartupDeps,\n\topts: ContinueWatcherAgentStartupOptions,\n): Promise<string> {\n\tconst { process } = opts;\n\n\tif (!hasProcessEvent(deps.events, process.id, \"agent_created\")) {\n\t\tdeps.events.create({\n\t\t\tinstanceId: process.id,\n\t\t\teventType: \"agent_created\",\n\t\t\tdata: opts.createdEventData,\n\t\t});\n\t}\n\n\tawait opts.afterCreatedEvent?.(process);\n\tawait opts.beforeStart?.(process);\n\n\tlet currentProcess = deps.processes.getById(process.id) ?? process;\n\tif (currentProcess.lifecycleStatus === \"discovered\") {\n\t\tconst startResult = await deps.commands.startProcess(currentProcess.id, opts.startTurnId);\n\t\tif (!startResult.ok) {\n\t\t\tcurrentProcess = startResult.process ?? currentProcess;\n\t\t\tthrow new Error(startResult.message ?? \"Failed to start process\");\n\t\t}\n\t\tcurrentProcess = startResult.process ?? currentProcess;\n\t\tif (opts.broadcastCreated !== false) {\n\t\t\tdeps.broadcaster.sendDurable(\n\t\t\t\t\"process.created\",\n\t\t\t\t{\n\t\t\t\t\tprocess: currentProcess,\n\t\t\t\t\tprocessId: currentProcess.processId,\n\t\t\t\t\t...opts.createdBroadcastData,\n\t\t\t\t},\n\t\t\t\tcurrentProcess.id,\n\t\t\t);\n\t\t}\n\t}\n\n\tawait ensureWorkerForActiveAgent(deps, currentProcess);\n\treturn currentProcess.id;\n}\n\n/** @internal */\nexport type DiscoveryResumeResult = \"handled\" | \"skipped\" | undefined;\n\n/** @internal */\nexport type DiscoveryCreateResult =\n\t| {\n\t\t\t/** @internal */\n\t\t\toutcome: \"created\";\n\t\t\t/** @internal */\n\t\t\tinstanceId: string;\n\t }\n\t| {\n\t\t\t/** @internal */\n\t\t\toutcome: \"skipped\";\n\t }\n\t| {\n\t\t\t/** @internal */\n\t\t\toutcome: \"handled\";\n\t }\n\t| null\n\t| undefined;\n\n/** @internal */\nexport interface DiscoveryPassOptions<TItem> {\n\t/** @internal */\n\titems: readonly TItem[];\n\t/** @internal */\n\tresult: PollResult;\n\t/** @internal */\n\tfindExistingAgent(item: TItem): ProcessInstance | null;\n\t/** @internal */\n\tgetResultLabel(item: TItem): string;\n\t/** @internal */\n\tresumeDiscoveredAgent(process: ProcessInstance, item: TItem): Promise<DiscoveryResumeResult>;\n\t/** @internal */\n\tcreateAgent(item: TItem): Promise<DiscoveryCreateResult>;\n\t/** @internal */\n\tensureWorkerForExistingAgent?(process: ProcessInstance, item: TItem): Promise<boolean>;\n\t/** @internal */\n\tformatError(item: TItem, error: unknown): string;\n}\n\n/** @internal */\nexport async function runWatcherDiscoveryPass<TItem>(\n\topts: DiscoveryPassOptions<TItem>,\n): Promise<void> {\n\tfor (const item of opts.items) {\n\t\ttry {\n\t\t\tconst existingAgent = opts.findExistingAgent(item);\n\t\t\tif (existingAgent) {\n\t\t\t\tif (existingAgent.lifecycleStatus === \"discovered\") {\n\t\t\t\t\tconst resumeResult = await opts.resumeDiscoveredAgent(existingAgent, item);\n\t\t\t\t\tif (resumeResult === \"skipped\") {\n\t\t\t\t\t\topts.result.skipped.push(opts.getResultLabel(item));\n\t\t\t\t\t}\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tif (opts.ensureWorkerForExistingAgent) {\n\t\t\t\t\tconst handled = await opts.ensureWorkerForExistingAgent(existingAgent, item);\n\t\t\t\t\tif (handled) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\topts.result.skipped.push(opts.getResultLabel(item));\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst createResult = await opts.createAgent(item);\n\t\t\tif (createResult?.outcome === \"created\") {\n\t\t\t\topts.result.created.push(opts.getResultLabel(item));\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (createResult?.outcome === \"skipped\") {\n\t\t\t\topts.result.skipped.push(opts.getResultLabel(item));\n\t\t\t}\n\t\t} catch (error) {\n\t\t\topts.result.errors.push(opts.formatError(item, error));\n\t\t}\n\t}\n}\n\n/** @internal */\nexport interface AbortReconciliationOptions {\n\t/** @internal */\n\tcandidates: readonly ProcessInstance[];\n\t/** @internal */\n\tresult: PollResult;\n\t/** @internal */\n\tevents: ProcessEventRepoLike;\n\t/** @internal */\n\tcommands: WatcherCommandServiceLike;\n\t/** @internal */\n\tshouldAbort(process: ProcessInstance): Promise<boolean>;\n\t/** @internal */\n\tgetResultLabel(process: ProcessInstance): string;\n\t/** @internal */\n\tgetErrorLabel(process: ProcessInstance): string;\n\t/** @internal */\n\tgetAbortedEventData(process: ProcessInstance): Record<string, unknown>;\n}\n\n/** @internal */\nexport async function runWatcherAbortReconciliation(\n\topts: AbortReconciliationOptions,\n): Promise<void> {\n\tfor (const process of opts.candidates) {\n\t\ttry {\n\t\t\tconst shouldAbort = await opts.shouldAbort(process);\n\t\t\tif (!shouldAbort) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst abortResult = await opts.commands.abortProcess(process.id);\n\t\t\tif (!abortResult.ok) {\n\t\t\t\tif (abortResult.code === \"worker_reconcile_failed\") {\n\t\t\t\t\tthrow new Error(abortResult.message ?? \"Failed to abort process\");\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst abortedAgent = abortResult.process ?? process;\n\t\t\tif (!hasProcessEvent(opts.events, abortedAgent.id, \"aborted_label_removed\")) {\n\t\t\t\topts.events.create({\n\t\t\t\t\tinstanceId: abortedAgent.id,\n\t\t\t\t\teventType: \"aborted_label_removed\",\n\t\t\t\t\tdata: opts.getAbortedEventData(abortedAgent),\n\t\t\t\t});\n\t\t\t}\n\t\t\topts.result.aborted.push(opts.getResultLabel(process));\n\t\t} catch (error) {\n\t\t\topts.result.errors.push(\n\t\t\t\t`${opts.getErrorLabel(process)}: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t);\n\t\t}\n\t}\n}\n\n/** @internal */\nexport interface CompletionReconciliationResult {\n\t/** @internal */\n\tchanged: boolean;\n\t/** @internal */\n\twriteIdentity?: WriteIdentity;\n\t/** @internal */\n\tmetadata?: Record<string, unknown>;\n}\n\n/** @internal */\nexport interface CompletionReconciliationOptions {\n\t/** @internal */\n\tcandidates: readonly ProcessInstance[];\n\t/** @internal */\n\tresult: PollResult;\n\t/** @internal */\n\texternalWrites: ExternalWriteLogRepoLike;\n\t/** @internal */\n\treconcile(process: ProcessInstance): Promise<CompletionReconciliationResult>;\n\t/** @internal */\n\tgetResultLabel(process: ProcessInstance): string;\n\t/** @internal */\n\tgetErrorLabel(process: ProcessInstance): string;\n}\n\n/** @internal */\nexport async function runWatcherCompletionReconciliation(\n\topts: CompletionReconciliationOptions,\n): Promise<void> {\n\tfor (const process of opts.candidates) {\n\t\ttry {\n\t\t\tconst reconciliation = await opts.reconcile(process);\n\t\t\tif (!reconciliation.changed) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (reconciliation.writeIdentity) {\n\t\t\t\trecordWriteIfMissing(\n\t\t\t\t\topts.externalWrites,\n\t\t\t\t\tprocess.id,\n\t\t\t\t\treconciliation.writeIdentity,\n\t\t\t\t\treconciliation.metadata,\n\t\t\t\t);\n\t\t\t}\n\t\t\topts.result.labelExchanged.push(opts.getResultLabel(process));\n\t\t} catch (error) {\n\t\t\topts.result.errors.push(\n\t\t\t\t`${opts.getErrorLabel(process)}: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t);\n\t\t}\n\t}\n}\n\n/** @internal */\nexport function shouldEnsureWorkerForExistingActiveAgent(\n\tdeps: {\n\t\t/** @internal */\n\t\tsupervisor: WorkerSupervisorLike;\n\t},\n\tprocess: ProcessInstance,\n): boolean {\n\treturn processNeedsWorker(process) && !deps.supervisor.getWorker(process.id);\n}\n\n/** @internal */\nexport function deferWatcherLaunchStart<\n\tTLaunchPlan extends {\n\t\t/** @internal */\n\t\tstartTurnId: unknown;\n\t},\n>(launchPlan: TLaunchPlan): TLaunchPlan {\n\treturn launchPlan.startTurnId === null ? launchPlan : { ...launchPlan, startTurnId: null };\n}\n\n/** @internal */\nexport function launchFailureMessage(result: {\n\t/** @internal */\n\tstatus: number;\n\t/** @internal */\n\tbody: Record<string, unknown>;\n}): string {\n\treturn typeof result.body.error === \"string\" && result.body.error.trim().length > 0\n\t\t? result.body.error\n\t\t: `Process launch failed with status ${result.status}`;\n}\n"],"mappings":";;;;;;;AAEA;AAAA,EAEC;AAAA,OACM;AAgFA,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|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
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.2.1",
|
|
22
|
+
"@leitwerk-dev/external-writes": "0.2.1",
|
|
23
|
+
"@leitwerk-dev/protocol": "0.2.1",
|
|
24
24
|
"ms": "^2.1.3"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"access": "public"
|
|
33
33
|
},
|
|
34
34
|
"engines": {
|
|
35
|
-
"node": ">=
|
|
35
|
+
"node": ">=26 <27"
|
|
36
36
|
},
|
|
37
37
|
"files": [
|
|
38
38
|
"dist/**",
|
package/src/duration-parse.ts
CHANGED
|
@@ -7,10 +7,14 @@ import ms from "ms";
|
|
|
7
7
|
* `options.allowHours` is retained for existing callers; the underlying `ms`
|
|
8
8
|
* parser supports hours and other common duration units by default.
|
|
9
9
|
*/
|
|
10
|
+
/** @public */
|
|
10
11
|
export function parseDurationMs(
|
|
11
12
|
value: string,
|
|
12
13
|
defaultMs: number,
|
|
13
|
-
_options: {
|
|
14
|
+
_options: {
|
|
15
|
+
/** @public */
|
|
16
|
+
allowHours?: boolean;
|
|
17
|
+
} = {},
|
|
14
18
|
): number {
|
|
15
19
|
const parsed = ms(value.trim() as ms.StringValue);
|
|
16
20
|
if (!Number.isFinite(parsed) || parsed < 0) {
|
package/src/index.ts
CHANGED
|
@@ -1,39 +1,11 @@
|
|
|
1
1
|
export { parseDurationMs } from "./duration-parse.js";
|
|
2
2
|
export {
|
|
3
|
-
|
|
3
|
+
createPollSchedule,
|
|
4
4
|
emptyPollResult,
|
|
5
|
-
type PollLoop,
|
|
6
5
|
type PollResult,
|
|
7
6
|
} from "./poll-loop.js";
|
|
8
|
-
export {
|
|
9
|
-
ensureWorkerForActiveAgent,
|
|
10
|
-
hasProcessEvent,
|
|
11
|
-
type ProcessEventRepoLike,
|
|
12
|
-
processNeedsWorker,
|
|
13
|
-
type WorkerSupervisorLike,
|
|
14
|
-
} from "./process-helpers.js";
|
|
7
|
+
export { createPollingCoordinator } from "./polling-coordinator.js";
|
|
15
8
|
export {
|
|
16
9
|
consumeTriggerFile,
|
|
17
|
-
errorCode,
|
|
18
10
|
readTriggerFile,
|
|
19
|
-
type TriggerFileReadResult,
|
|
20
11
|
} from "./trigger-files.js";
|
|
21
|
-
export {
|
|
22
|
-
type AgentRepoAccessorLike,
|
|
23
|
-
type BroadcasterLike,
|
|
24
|
-
type CompletionReconciliationOptions,
|
|
25
|
-
type CompletionReconciliationResult,
|
|
26
|
-
type ContinueWatcherAgentStartupOptions,
|
|
27
|
-
continueWatcherAgentStartup,
|
|
28
|
-
type DiscoveryPassOptions,
|
|
29
|
-
deferWatcherLaunchStart,
|
|
30
|
-
launchFailureMessage,
|
|
31
|
-
requireWatcherStartTurnId,
|
|
32
|
-
runWatcherAbortReconciliation,
|
|
33
|
-
runWatcherCompletionReconciliation,
|
|
34
|
-
runWatcherDiscoveryPass,
|
|
35
|
-
shouldEnsureWorkerForExistingActiveAgent,
|
|
36
|
-
type WatcherCommandResult,
|
|
37
|
-
type WatcherCommandServiceLike,
|
|
38
|
-
type WatcherStartupDeps,
|
|
39
|
-
} from "./watcher-coordinator.js";
|