agentic-engineering-harness 0.6.14 → 0.6.15
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/operations/liveness.d.ts +1 -35
- package/dist/operations/liveness.js +1 -307
- package/dist/operations/liveness.js.map +1 -1
- package/dist/operations/livenessV2.d.ts +34 -0
- package/dist/operations/livenessV2.js +339 -0
- package/dist/operations/livenessV2.js.map +1 -0
- package/dist/operations/mcp.d.ts +1 -0
- package/dist/operations/mcp.js +13 -3
- package/dist/operations/mcp.js.map +1 -1
- package/dist/operations/supervisor.js +82 -29
- package/dist/operations/supervisor.js.map +1 -1
- package/dist/operations/wakeBudget.d.ts +15 -0
- package/dist/operations/wakeBudget.js +142 -0
- package/dist/operations/wakeBudget.js.map +1 -0
- package/package.json +1 -1
|
@@ -1,35 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { dispatchManagedPaseoAgent, inspectManagedPaseoAgent } from "../paseo/runtime.js";
|
|
3
|
-
import { recordPaseoTrace } from "../paseo/trace.js";
|
|
4
|
-
import { type OperationRecordV2 } from "./state.js";
|
|
5
|
-
export type OperationWakeReason = "progress" | "blocked" | "stalled" | "terminal";
|
|
6
|
-
export interface OperationLivenessPolicy {
|
|
7
|
-
pollIntervalMs: number;
|
|
8
|
-
progressWakeIntervalMs: number;
|
|
9
|
-
stallThresholdMs: number;
|
|
10
|
-
supervisorStallWakeLimit: number;
|
|
11
|
-
retryDelaysMs: number[];
|
|
12
|
-
}
|
|
13
|
-
export interface OperationWakeDecision {
|
|
14
|
-
reason?: OperationWakeReason;
|
|
15
|
-
target: "none" | "lead" | "supervisor";
|
|
16
|
-
revision: number;
|
|
17
|
-
message: string;
|
|
18
|
-
}
|
|
19
|
-
export interface OperationLivenessDeps {
|
|
20
|
-
dispatch?: typeof dispatchManagedPaseoAgent;
|
|
21
|
-
inspect?: typeof inspectManagedPaseoAgent;
|
|
22
|
-
trace?: typeof recordPaseoTrace;
|
|
23
|
-
now?: () => number;
|
|
24
|
-
sleep?: (ms: number) => Promise<void>;
|
|
25
|
-
/** Number of supervisor watchdog wakes already accepted for this exact revision. */
|
|
26
|
-
stallSupervisorWakeCount?: number;
|
|
27
|
-
}
|
|
28
|
-
export declare function operationLivenessPolicy(config: HarnessProjectConfig): OperationLivenessPolicy;
|
|
29
|
-
export declare function operationRevisionAcknowledged(operation: OperationRecordV2): boolean;
|
|
30
|
-
export declare function evaluateOperationWake(operation: OperationRecordV2, policy: OperationLivenessPolicy, nowMs?: number, stallSupervisorWakeCount?: number): OperationWakeDecision;
|
|
31
|
-
export declare function runOperationLivenessCheck(root: string, config: HarnessProjectConfig, operationId: string, deps?: OperationLivenessDeps): Promise<OperationWakeDecision>;
|
|
32
|
-
/** Detached liveness owner. It outlives the operation controller and exits only
|
|
33
|
-
* after terminal state has been acknowledged by the currently bound lead. */
|
|
34
|
-
export declare function monitorOperationLiveness(root: string, config: HarnessProjectConfig, operationId: string, deps?: OperationLivenessDeps): Promise<void>;
|
|
35
|
-
export declare function startOperationWatchdog(root: string, config: HarnessProjectConfig, operationId: string, deps?: OperationLivenessDeps): () => void;
|
|
1
|
+
export * from "./livenessV2.js";
|
|
@@ -1,308 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { recordPaseoTrace } from "../paseo/trace.js";
|
|
3
|
-
import { loadOperationCompletionTarget, notifyOperationCompletion } from "./completion.js";
|
|
4
|
-
import { syncOperationPortfolio } from "./portfolio.js";
|
|
5
|
-
import { activeOperationSupervisor, isTerminalOperation, loadOperation, patchOperationMetadata } from "./state.js";
|
|
6
|
-
export function operationLivenessPolicy(config) {
|
|
7
|
-
const orchestration = config.orchestration;
|
|
8
|
-
const configured = orchestration?.operations?.liveness;
|
|
9
|
-
return {
|
|
10
|
-
pollIntervalMs: positive(configured?.pollIntervalMs, 15_000),
|
|
11
|
-
progressWakeIntervalMs: positive(configured?.progressWakeIntervalMs, 45_000),
|
|
12
|
-
stallThresholdMs: positive(configured?.stallThresholdMs, 120_000),
|
|
13
|
-
supervisorStallWakeLimit: positive(configured?.supervisorStallWakeLimit, 2),
|
|
14
|
-
retryDelaysMs: configured?.retryDelaysMs?.filter((value) => Number.isFinite(value) && value >= 0) ?? [0, 500, 1_500]
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
export function operationRevisionAcknowledged(operation) {
|
|
18
|
-
return Boolean(operation.lead && operation.lead.acknowledgedRevision >= operation.revision);
|
|
19
|
-
}
|
|
20
|
-
export function evaluateOperationWake(operation, policy, nowMs = Date.now(), stallSupervisorWakeCount = 0) {
|
|
21
|
-
const terminal = isTerminalOperation(operation.status);
|
|
22
|
-
if (terminal) {
|
|
23
|
-
if (!operation.lead?.agentId)
|
|
24
|
-
return { target: "none", revision: operation.revision, message: "terminal operation has no bound lead" };
|
|
25
|
-
if (operationRevisionAcknowledged(operation))
|
|
26
|
-
return { target: "none", revision: operation.revision, message: "terminal revision was acknowledged by the lead" };
|
|
27
|
-
const lastWakeMs = operation.notification.lastLeadWakeAt ? Date.parse(operation.notification.lastLeadWakeAt) : 0;
|
|
28
|
-
if (!operation.notification.terminalDelivered || nowMs - lastWakeMs >= policy.progressWakeIntervalMs) {
|
|
29
|
-
return {
|
|
30
|
-
reason: "terminal",
|
|
31
|
-
target: "lead",
|
|
32
|
-
revision: operation.revision,
|
|
33
|
-
message: operation.notification.terminalDelivered
|
|
34
|
-
? "terminal wake was accepted previously but the bound lead has not acknowledged this revision"
|
|
35
|
-
: "terminal operation has not been delivered to the lead"
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
return { target: "none", revision: operation.revision, message: "terminal wake accepted; awaiting lead acknowledgement" };
|
|
39
|
-
}
|
|
40
|
-
const blocked = Object.values(operation.stages).some((stage) => stage.status === "BLOCKED") || operation.progress.blocked > 0;
|
|
41
|
-
if (blocked && operation.revision > operation.notification.lastLeadWakeRevision) {
|
|
42
|
-
return { reason: "blocked", target: "lead", revision: operation.revision, message: "operation is blocked and the lead has not seen this revision" };
|
|
43
|
-
}
|
|
44
|
-
// A stalled operation is a stronger liveness condition than ordinary unseen
|
|
45
|
-
// progress. Route it to the operation-local supervisor first. If that
|
|
46
|
-
// supervisor has already accepted bounded watchdog wakes for the same exact
|
|
47
|
-
// revision without producing durable progress, escalate to the lead instead
|
|
48
|
-
// of suppressing the stalled revision forever.
|
|
49
|
-
const progressAt = Date.parse(operation.lastProgressAt);
|
|
50
|
-
if (operation.status === "RUNNING" && Number.isFinite(progressAt) && nowMs - progressAt >= policy.stallThresholdMs) {
|
|
51
|
-
const supervisor = activeOperationSupervisor(operation);
|
|
52
|
-
const supervisorBudgetRemaining = Boolean(supervisor?.agentId) && stallSupervisorWakeCount < policy.supervisorStallWakeLimit;
|
|
53
|
-
return {
|
|
54
|
-
reason: "stalled",
|
|
55
|
-
target: supervisorBudgetRemaining ? "supervisor" : "lead",
|
|
56
|
-
revision: operation.revision,
|
|
57
|
-
message: `operation has made no durable progress for ${Math.round((nowMs - progressAt) / 1000)}s${supervisor?.agentId ? `; supervisor watchdog wakes for this revision=${stallSupervisorWakeCount}/${policy.supervisorStallWakeLimit}` : ""}`
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
const lastWakeMs = operation.notification.lastLeadWakeAt ? Date.parse(operation.notification.lastLeadWakeAt) : 0;
|
|
61
|
-
const unseen = operation.revision > operation.notification.lastLeadWakeRevision;
|
|
62
|
-
if (unseen && nowMs - lastWakeMs >= policy.progressWakeIntervalMs) {
|
|
63
|
-
return { reason: "progress", target: "lead", revision: operation.revision, message: "operation has unseen durable progress" };
|
|
64
|
-
}
|
|
65
|
-
return { target: "none", revision: operation.revision, message: "no liveness action required" };
|
|
66
|
-
}
|
|
67
|
-
export async function runOperationLivenessCheck(root, config, operationId, deps = {}) {
|
|
68
|
-
const operation = await loadOperation(root, operationId);
|
|
69
|
-
await syncOperationPortfolio(root, config.project.name, operation).catch(() => undefined);
|
|
70
|
-
const policy = operationLivenessPolicy(config);
|
|
71
|
-
const now = (deps.now ?? Date.now)();
|
|
72
|
-
const decision = evaluateOperationWake(operation, policy, now, deps.stallSupervisorWakeCount ?? 0);
|
|
73
|
-
if (!decision.reason || decision.target === "none")
|
|
74
|
-
return decision;
|
|
75
|
-
const trace = deps.trace ?? recordPaseoTrace;
|
|
76
|
-
if (decision.reason === "terminal" && !operation.notification.terminalDelivered) {
|
|
77
|
-
await notifyOperationCompletion(root, operation, { dispatch: deps.dispatch, trace, retryDelaysMs: policy.retryDelaysMs, sleep: deps.sleep });
|
|
78
|
-
const latest = await loadOperation(root, operationId);
|
|
79
|
-
await syncOperationPortfolio(root, config.project.name, latest).catch(() => undefined);
|
|
80
|
-
return decision;
|
|
81
|
-
}
|
|
82
|
-
if (decision.target === "supervisor") {
|
|
83
|
-
const supervisor = activeOperationSupervisor(operation);
|
|
84
|
-
if (supervisor?.agentId && !(await isBusy(root, supervisor.agentId, deps.inspect))) {
|
|
85
|
-
const result = await retryDispatch(root, supervisor.agentId, supervisorWatchdogPrompt(operation, decision), policy.retryDelaysMs, deps);
|
|
86
|
-
await trace(root, "operation.watchdog.supervisor", {
|
|
87
|
-
operationId,
|
|
88
|
-
revision: operation.revision,
|
|
89
|
-
supervisorAgentId: supervisor.agentId,
|
|
90
|
-
success: result.success,
|
|
91
|
-
attempts: result.attempts,
|
|
92
|
-
acceptedWakeCount: (deps.stallSupervisorWakeCount ?? 0) + (result.success ? 1 : 0),
|
|
93
|
-
error: result.error ?? ""
|
|
94
|
-
});
|
|
95
|
-
if (result.success)
|
|
96
|
-
return decision;
|
|
97
|
-
// Dispatch failure is a transport/runtime failure, so fall through and
|
|
98
|
-
// wake the lead immediately rather than consuming the semantic wake budget.
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
const leadId = operation.lead?.agentId;
|
|
102
|
-
if (!leadId) {
|
|
103
|
-
await trace(root, "operation.watchdog.no-lead", { operationId, revision: operation.revision, reason: decision.reason });
|
|
104
|
-
return decision;
|
|
105
|
-
}
|
|
106
|
-
if (await isBusy(root, leadId, deps.inspect)) {
|
|
107
|
-
await trace(root, "operation.watchdog.lead-busy", { operationId, revision: operation.revision, leadAgentId: leadId, reason: decision.reason });
|
|
108
|
-
return decision;
|
|
109
|
-
}
|
|
110
|
-
const result = await retryDispatch(root, leadId, leadWakePrompt(operation, decision), policy.retryDelaysMs, deps);
|
|
111
|
-
const latest = await loadOperation(root, operationId);
|
|
112
|
-
const updated = await patchOperationMetadata(root, operationId, {
|
|
113
|
-
notification: {
|
|
114
|
-
...latest.notification,
|
|
115
|
-
lastLeadWakeRevision: result.success ? operation.revision : latest.notification.lastLeadWakeRevision,
|
|
116
|
-
lastLeadWakeAt: result.success ? new Date(now).toISOString() : latest.notification.lastLeadWakeAt,
|
|
117
|
-
lastLeadWakeReason: result.success ? decision.reason : latest.notification.lastLeadWakeReason,
|
|
118
|
-
terminalDelivered: latest.notification.terminalDelivered || (decision.reason === "terminal" && result.success),
|
|
119
|
-
attempts: latest.notification.attempts + result.attempts,
|
|
120
|
-
lastError: result.error
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
await syncOperationPortfolio(root, config.project.name, updated).catch(() => undefined);
|
|
124
|
-
await trace(root, "operation.watchdog.lead", {
|
|
125
|
-
operationId,
|
|
126
|
-
revision: operation.revision,
|
|
127
|
-
leadAgentId: leadId,
|
|
128
|
-
reason: decision.reason,
|
|
129
|
-
success: result.success,
|
|
130
|
-
attempts: result.attempts,
|
|
131
|
-
acknowledged: operationRevisionAcknowledged(updated),
|
|
132
|
-
error: result.error ?? ""
|
|
133
|
-
});
|
|
134
|
-
return decision;
|
|
135
|
-
}
|
|
136
|
-
/** Detached liveness owner. It outlives the operation controller and exits only
|
|
137
|
-
* after terminal state has been acknowledged by the currently bound lead. */
|
|
138
|
-
export async function monitorOperationLiveness(root, config, operationId, deps = {}) {
|
|
139
|
-
const policy = operationLivenessPolicy(config);
|
|
140
|
-
const sleep = deps.sleep ?? delay;
|
|
141
|
-
const trace = deps.trace ?? recordPaseoTrace;
|
|
142
|
-
let stallRevision;
|
|
143
|
-
let supervisorWakeCount = 0;
|
|
144
|
-
let lastStallWakeAt = 0;
|
|
145
|
-
await trace(root, "operation.watchdog.started", {
|
|
146
|
-
operationId,
|
|
147
|
-
pollIntervalMs: policy.pollIntervalMs,
|
|
148
|
-
progressWakeIntervalMs: policy.progressWakeIntervalMs,
|
|
149
|
-
stallThresholdMs: policy.stallThresholdMs,
|
|
150
|
-
supervisorStallWakeLimit: policy.supervisorStallWakeLimit
|
|
151
|
-
});
|
|
152
|
-
for (;;) {
|
|
153
|
-
const operation = await loadOperation(root, operationId);
|
|
154
|
-
await syncOperationPortfolio(root, config.project.name, operation).catch(() => undefined);
|
|
155
|
-
if (isTerminalOperation(operation.status)) {
|
|
156
|
-
if (!operation.lead?.agentId) {
|
|
157
|
-
await trace(root, "operation.watchdog.stopped", { operationId, reason: "terminal-without-lead" });
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
if (operationRevisionAcknowledged(operation)) {
|
|
161
|
-
await trace(root, "operation.watchdog.stopped", { operationId, reason: "terminal-acknowledged", revision: operation.revision });
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
const target = await loadOperationCompletionTarget(root, operationId).catch(() => undefined);
|
|
165
|
-
if (target?.status === "DISABLED") {
|
|
166
|
-
await trace(root, "operation.watchdog.stopped", { operationId, reason: "completion-disabled" });
|
|
167
|
-
return;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
if (stallRevision !== operation.revision) {
|
|
171
|
-
stallRevision = undefined;
|
|
172
|
-
supervisorWakeCount = 0;
|
|
173
|
-
lastStallWakeAt = 0;
|
|
174
|
-
}
|
|
175
|
-
const now = (deps.now ?? Date.now)();
|
|
176
|
-
const decision = evaluateOperationWake(operation, policy, now, supervisorWakeCount);
|
|
177
|
-
if (decision.reason === "stalled" && stallRevision === operation.revision && now - lastStallWakeAt < policy.progressWakeIntervalMs) {
|
|
178
|
-
await sleep(policy.pollIntervalMs);
|
|
179
|
-
continue;
|
|
180
|
-
}
|
|
181
|
-
try {
|
|
182
|
-
const executed = await runOperationLivenessCheck(root, config, operationId, {
|
|
183
|
-
...deps,
|
|
184
|
-
stallSupervisorWakeCount: supervisorWakeCount
|
|
185
|
-
});
|
|
186
|
-
if (executed.reason === "stalled") {
|
|
187
|
-
stallRevision = operation.revision;
|
|
188
|
-
lastStallWakeAt = now;
|
|
189
|
-
if (executed.target === "supervisor")
|
|
190
|
-
supervisorWakeCount += 1;
|
|
191
|
-
}
|
|
192
|
-
else if (executed.reason) {
|
|
193
|
-
stallRevision = undefined;
|
|
194
|
-
supervisorWakeCount = 0;
|
|
195
|
-
lastStallWakeAt = 0;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
catch (error) {
|
|
199
|
-
await trace(root, "operation.watchdog.error", { operationId, error: error instanceof Error ? error.message : String(error) }).catch(() => undefined);
|
|
200
|
-
}
|
|
201
|
-
await sleep(policy.pollIntervalMs);
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
export function startOperationWatchdog(root, config, operationId, deps = {}) {
|
|
205
|
-
const policy = operationLivenessPolicy(config);
|
|
206
|
-
let stopped = false;
|
|
207
|
-
let running = false;
|
|
208
|
-
let stallRevision;
|
|
209
|
-
let supervisorWakeCount = 0;
|
|
210
|
-
let lastStallWakeAt = 0;
|
|
211
|
-
const timer = setInterval(() => {
|
|
212
|
-
if (stopped || running)
|
|
213
|
-
return;
|
|
214
|
-
running = true;
|
|
215
|
-
void (async () => {
|
|
216
|
-
const operation = await loadOperation(root, operationId);
|
|
217
|
-
const now = (deps.now ?? Date.now)();
|
|
218
|
-
if (stallRevision !== operation.revision) {
|
|
219
|
-
stallRevision = undefined;
|
|
220
|
-
supervisorWakeCount = 0;
|
|
221
|
-
lastStallWakeAt = 0;
|
|
222
|
-
}
|
|
223
|
-
const decision = evaluateOperationWake(operation, policy, now, supervisorWakeCount);
|
|
224
|
-
if (decision.reason === "stalled" && stallRevision === operation.revision && now - lastStallWakeAt < policy.progressWakeIntervalMs)
|
|
225
|
-
return;
|
|
226
|
-
const executed = await runOperationLivenessCheck(root, config, operationId, { ...deps, stallSupervisorWakeCount: supervisorWakeCount });
|
|
227
|
-
if (executed.reason === "stalled") {
|
|
228
|
-
stallRevision = operation.revision;
|
|
229
|
-
lastStallWakeAt = now;
|
|
230
|
-
if (executed.target === "supervisor")
|
|
231
|
-
supervisorWakeCount += 1;
|
|
232
|
-
}
|
|
233
|
-
else if (executed.reason) {
|
|
234
|
-
stallRevision = undefined;
|
|
235
|
-
supervisorWakeCount = 0;
|
|
236
|
-
lastStallWakeAt = 0;
|
|
237
|
-
}
|
|
238
|
-
})()
|
|
239
|
-
.catch(async (error) => {
|
|
240
|
-
await (deps.trace ?? recordPaseoTrace)(root, "operation.watchdog.error", { operationId, error: error instanceof Error ? error.message : String(error) }).catch(() => undefined);
|
|
241
|
-
})
|
|
242
|
-
.finally(() => { running = false; });
|
|
243
|
-
}, policy.pollIntervalMs);
|
|
244
|
-
timer.unref?.();
|
|
245
|
-
return () => { stopped = true; clearInterval(timer); };
|
|
246
|
-
}
|
|
247
|
-
function leadWakePrompt(operation, decision) {
|
|
248
|
-
if (decision.reason === "terminal") {
|
|
249
|
-
return [
|
|
250
|
-
"[AEH_OPERATION_COMPLETED_UNACKNOWLEDGED]",
|
|
251
|
-
`Operation ${operation.id} (${operation.kind}) is terminal at revision ${operation.revision}: status=${operation.status}, phase=${operation.phase}.`,
|
|
252
|
-
decision.message,
|
|
253
|
-
"Do not start a duplicate operation. Read the existing OperationRecord and result/report artifact now. Use aeh_operation_status so AEH can acknowledge this exact revision, then complete the original pending user-facing request."
|
|
254
|
-
].join("\n");
|
|
255
|
-
}
|
|
256
|
-
const instruction = decision.reason === "blocked"
|
|
257
|
-
? "Inspect the durable block/exception and involve the user only if the state requires a product/external decision."
|
|
258
|
-
: decision.reason === "stalled"
|
|
259
|
-
? "The operation-local supervisor did not restore durable progress within its bounded watchdog budget. Inspect the OperationRecord/supervisor generation and recover or escalate without starting a duplicate operation."
|
|
260
|
-
: "If the operation is healthy and non-terminal, do not create user-facing status noise; acknowledge the durable revision internally and return idle.";
|
|
261
|
-
return [
|
|
262
|
-
`[AEH_OPERATION_${decision.reason?.toUpperCase()}]`,
|
|
263
|
-
`Operation ${operation.id} (${operation.kind}) revision ${operation.revision}: status=${operation.status}, phase=${operation.phase}.`,
|
|
264
|
-
`Progress: completed=${operation.progress.completed}, running=${operation.progress.running}, failed=${operation.progress.failed}, blocked=${operation.progress.blocked}.`,
|
|
265
|
-
decision.message,
|
|
266
|
-
"Do not start a duplicate operation. Read the existing OperationRecord/artifacts if more detail is required.",
|
|
267
|
-
instruction
|
|
268
|
-
].join("\n");
|
|
269
|
-
}
|
|
270
|
-
function supervisorWatchdogPrompt(operation, decision) {
|
|
271
|
-
return [
|
|
272
|
-
"[AEH_OPERATION_WATCHDOG]",
|
|
273
|
-
`Your operation ${operation.id} has stalled at revision ${operation.revision}, phase=${operation.phase}.`,
|
|
274
|
-
decision.message,
|
|
275
|
-
"Inspect only your existing children and durable OperationRecord/artifacts. Do not start another AEH operation. Produce a bounded diagnosis/follow-up that causes durable progress when possible. If no semantic action is required, say so explicitly; repeated no-progress watchdog wakes will escalate to the lead."
|
|
276
|
-
].join("\n");
|
|
277
|
-
}
|
|
278
|
-
async function retryDispatch(root, agentId, prompt, delays, deps) {
|
|
279
|
-
const dispatch = deps.dispatch ?? dispatchManagedPaseoAgent;
|
|
280
|
-
const sleep = deps.sleep ?? delay;
|
|
281
|
-
let error;
|
|
282
|
-
let attempts = 0;
|
|
283
|
-
for (const wait of delays.length ? delays : [0]) {
|
|
284
|
-
if (wait > 0)
|
|
285
|
-
await sleep(wait);
|
|
286
|
-
attempts += 1;
|
|
287
|
-
try {
|
|
288
|
-
const result = await dispatch(root, agentId, prompt, 60);
|
|
289
|
-
if (result.exitCode === 0)
|
|
290
|
-
return { success: true, attempts };
|
|
291
|
-
error = result.stderr || result.stdout || `dispatch exited ${result.exitCode}`;
|
|
292
|
-
}
|
|
293
|
-
catch (caught) {
|
|
294
|
-
error = caught instanceof Error ? caught.message : String(caught);
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
return { success: false, attempts, error };
|
|
298
|
-
}
|
|
299
|
-
async function isBusy(root, agentId, inspect) {
|
|
300
|
-
const snapshot = await (inspect ?? inspectManagedPaseoAgent)(root, agentId).catch(() => undefined);
|
|
301
|
-
const status = snapshot?.status?.toLowerCase();
|
|
302
|
-
return status === "running" || status === "working" || status === "streaming" || status === "initializing";
|
|
303
|
-
}
|
|
304
|
-
function positive(value, fallback) {
|
|
305
|
-
return typeof value === "number" && Number.isFinite(value) && value > 0 ? Math.floor(value) : fallback;
|
|
306
|
-
}
|
|
307
|
-
function delay(ms) { return new Promise((resolve) => setTimeout(resolve, ms)); }
|
|
1
|
+
export * from "./livenessV2.js";
|
|
308
2
|
//# sourceMappingURL=liveness.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"liveness.js","sourceRoot":"","sources":["../../src/operations/liveness.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC1F,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,6BAA6B,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAC3F,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,aAAa,EAAE,sBAAsB,EAA0B,MAAM,YAAY,CAAC;AAqC3I,MAAM,UAAU,uBAAuB,CAAC,MAA4B;IAClE,MAAM,aAAa,GAAG,MAAM,CAAC,aAA8F,CAAC;IAC5H,MAAM,UAAU,GAAG,aAAa,EAAE,UAAU,EAAE,QAAQ,CAAC;IACvD,OAAO;QACL,cAAc,EAAE,QAAQ,CAAC,UAAU,EAAE,cAAc,EAAE,MAAM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GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;IACnG,MAAM,MAAM,GAAG,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;IAC/C,OAAO,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,WAAW,IAAI,MAAM,KAAK,cAAc,CAAC;AAC7G,CAAC;AACD,SAAS,QAAQ,CAAC,KAAyB,EAAE,QAAgB;IAC3D,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;AACzG,CAAC;AACD,SAAS,KAAK,CAAC,EAAU,IAAmB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"liveness.js","sourceRoot":"","sources":["../../src/operations/liveness.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { HarnessProjectConfig } from "../core/types.js";
|
|
2
|
+
import { dispatchManagedPaseoAgent, inspectManagedPaseoAgent } from "../paseo/runtime.js";
|
|
3
|
+
import { recordPaseoTrace } from "../paseo/trace.js";
|
|
4
|
+
import { type OperationRecordV2 } from "./state.js";
|
|
5
|
+
export type OperationWakeReason = "progress" | "blocked" | "stalled" | "terminal";
|
|
6
|
+
export interface OperationLivenessPolicy {
|
|
7
|
+
pollIntervalMs: number;
|
|
8
|
+
progressWakeIntervalMs: number;
|
|
9
|
+
stallThresholdMs: number;
|
|
10
|
+
supervisorStallWakeLimit: number;
|
|
11
|
+
leadWakeLimit: number;
|
|
12
|
+
terminalLeadWakeLimit: number;
|
|
13
|
+
retryDelaysMs: number[];
|
|
14
|
+
}
|
|
15
|
+
export interface OperationWakeDecision {
|
|
16
|
+
reason?: OperationWakeReason;
|
|
17
|
+
target: "none" | "lead" | "supervisor";
|
|
18
|
+
revision: number;
|
|
19
|
+
message: string;
|
|
20
|
+
}
|
|
21
|
+
export interface OperationLivenessDeps {
|
|
22
|
+
dispatch?: typeof dispatchManagedPaseoAgent;
|
|
23
|
+
inspect?: typeof inspectManagedPaseoAgent;
|
|
24
|
+
trace?: typeof recordPaseoTrace;
|
|
25
|
+
now?: () => number;
|
|
26
|
+
sleep?: (ms: number) => Promise<void>;
|
|
27
|
+
stallSupervisorWakeCount?: number;
|
|
28
|
+
}
|
|
29
|
+
export declare function operationLivenessPolicy(config: HarnessProjectConfig): OperationLivenessPolicy;
|
|
30
|
+
export declare function operationRevisionAcknowledged(operation: OperationRecordV2): boolean;
|
|
31
|
+
export declare function evaluateOperationWake(operation: OperationRecordV2, policy: OperationLivenessPolicy, nowMs?: number, stallSupervisorWakeCount?: number, leadWakeCount?: number, terminalLeadWakeCount?: number): OperationWakeDecision;
|
|
32
|
+
export declare function runOperationLivenessCheck(root: string, config: HarnessProjectConfig, operationId: string, deps?: OperationLivenessDeps): Promise<OperationWakeDecision>;
|
|
33
|
+
export declare function monitorOperationLiveness(root: string, config: HarnessProjectConfig, operationId: string, deps?: OperationLivenessDeps): Promise<void>;
|
|
34
|
+
export declare function startOperationWatchdog(root: string, config: HarnessProjectConfig, operationId: string, deps?: OperationLivenessDeps): () => void;
|