agent-valley 4.8.0 → 4.8.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/assets/plugin.json +1 -1
- package/dist/index.js +102 -5
- package/dist/supervisor.js +5 -0
- package/package.json +1 -1
package/dist/assets/plugin.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json",
|
|
3
3
|
"name": "av",
|
|
4
|
-
"version": "4.8.
|
|
4
|
+
"version": "4.8.1",
|
|
5
5
|
"description": "Delegate repository goals to Agent Valley and inspect mission progress and verification evidence.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Agent Valley"
|
package/dist/index.js
CHANGED
|
@@ -7527,6 +7527,11 @@ var init_operations = __esm(() => {
|
|
|
7527
7527
|
outcome: _enum(["pending", "passed", "rejected", "failed"]),
|
|
7528
7528
|
executionState: _enum(["running", "settled", "unknown"]).optional(),
|
|
7529
7529
|
executionRecovery: _enum(["local-process", "reconcile"]).optional(),
|
|
7530
|
+
routingExclusion: strictObject({
|
|
7531
|
+
reason: literal("coordinator-cancelled"),
|
|
7532
|
+
dispatchAt: exports_iso.datetime(),
|
|
7533
|
+
pauseAt: exports_iso.datetime()
|
|
7534
|
+
}).optional(),
|
|
7530
7535
|
routingReason: text3.optional(),
|
|
7531
7536
|
evidence: text3.optional(),
|
|
7532
7537
|
fingerprint: text3.optional()
|
|
@@ -53532,6 +53537,80 @@ import { createHash as createHash9 } from "node:crypto";
|
|
|
53532
53537
|
import { constants as constants5 } from "node:fs";
|
|
53533
53538
|
import { lstat as lstat8, open as open7, realpath as realpath9 } from "node:fs/promises";
|
|
53534
53539
|
import { relative as relative6, resolve as resolve16, sep as sep6 } from "node:path";
|
|
53540
|
+
|
|
53541
|
+
// ../../packages/core/src/chief/cancelled-work-run.ts
|
|
53542
|
+
var cancellationMessages = new Set([
|
|
53543
|
+
"Operator stopped the order. Its checks and worktree were retained; repair any interrupted effects before resuming with --retry.",
|
|
53544
|
+
"Mission interrupted. Its checks, budget and child workspace records were retained for resume.",
|
|
53545
|
+
"The OS-owned service is shutting down. Re-observe the saved execution before continuing the same goal within its original limits."
|
|
53546
|
+
]);
|
|
53547
|
+
function settledFailure(run) {
|
|
53548
|
+
return run.stage === "work" && !!run.taskId && run.outcome === "failed" && run.executionState === "settled" && run.executionRecovery === "local-process" && !run.evidence?.trim() && Number.isFinite(Date.parse(run.startedAt)) && Number.isFinite(Date.parse(run.finishedAt ?? "")) && Date.parse(run.finishedAt ?? "") >= Date.parse(run.startedAt);
|
|
53549
|
+
}
|
|
53550
|
+
function archivedWorkCancellation(run) {
|
|
53551
|
+
const proof = run.routingExclusion;
|
|
53552
|
+
if (settledFailure(run) && proof?.reason === "coordinator-cancelled" && Date.parse(proof.dispatchAt) <= Date.parse(run.startedAt) && Date.parse(proof.pauseAt) >= Date.parse(run.finishedAt ?? ""))
|
|
53553
|
+
return proof;
|
|
53554
|
+
}
|
|
53555
|
+
function cancelledWorkRunProofs(mission) {
|
|
53556
|
+
const runs = mission.operations?.runs ?? [];
|
|
53557
|
+
const history = mission.history ?? [];
|
|
53558
|
+
const proofs = new Map;
|
|
53559
|
+
for (const run of runs) {
|
|
53560
|
+
const proof = archivedWorkCancellation(run);
|
|
53561
|
+
if (proof)
|
|
53562
|
+
proofs.set(run.runId, proof);
|
|
53563
|
+
}
|
|
53564
|
+
for (const [pauseIndex, pause] of history.entries()) {
|
|
53565
|
+
if (pause.stage !== "paused" || pause.taskId || !cancellationMessages.has(pause.message))
|
|
53566
|
+
continue;
|
|
53567
|
+
const pausedAt = Date.parse(pause.at);
|
|
53568
|
+
if (!Number.isFinite(pausedAt))
|
|
53569
|
+
continue;
|
|
53570
|
+
for (const run of runs) {
|
|
53571
|
+
if (!settledFailure(run) || Date.parse(run.finishedAt ?? "") > pausedAt)
|
|
53572
|
+
continue;
|
|
53573
|
+
const state = mission.tasks?.find((task) => task.id === run.taskId);
|
|
53574
|
+
if (state?.effectState === "running" || state?.effectState === "unknown")
|
|
53575
|
+
continue;
|
|
53576
|
+
const dispatchIndex = history.findLastIndex((entry, index) => {
|
|
53577
|
+
const prefix = `Running ${run.taskId} with ${run.actorId}, attempt `;
|
|
53578
|
+
return index < pauseIndex && entry.stage === "work" && entry.taskId === run.taskId && entry.message.startsWith(prefix) && /^[1-9]\d*\.$/.test(entry.message.slice(prefix.length)) && Date.parse(entry.at) <= Date.parse(run.startedAt);
|
|
53579
|
+
});
|
|
53580
|
+
const dispatch = history[dispatchIndex];
|
|
53581
|
+
if (!dispatch)
|
|
53582
|
+
continue;
|
|
53583
|
+
const dispatchedAt = Date.parse(dispatch.at);
|
|
53584
|
+
if (runs.filter((entry) => {
|
|
53585
|
+
const start = Date.parse(entry.startedAt);
|
|
53586
|
+
if (!Number.isFinite(start))
|
|
53587
|
+
return true;
|
|
53588
|
+
if (start > pausedAt)
|
|
53589
|
+
return false;
|
|
53590
|
+
const finish = Date.parse(entry.finishedAt ?? "");
|
|
53591
|
+
return !Number.isFinite(finish) || finish >= dispatchedAt;
|
|
53592
|
+
}).length !== 1)
|
|
53593
|
+
continue;
|
|
53594
|
+
const intermediate = history.slice(dispatchIndex + 1, pauseIndex);
|
|
53595
|
+
const uninterrupted = intermediate.every((entry) => {
|
|
53596
|
+
if (entry.stage === "skill-compatibility")
|
|
53597
|
+
return true;
|
|
53598
|
+
if (entry.stage !== "oma-dispatch" || entry.taskId !== run.taskId)
|
|
53599
|
+
return false;
|
|
53600
|
+
try {
|
|
53601
|
+
const record = JSON.parse(entry.message);
|
|
53602
|
+
return record.attemptId === run.runId && record.actorId === run.actorId;
|
|
53603
|
+
} catch {
|
|
53604
|
+
return false;
|
|
53605
|
+
}
|
|
53606
|
+
});
|
|
53607
|
+
if (uninterrupted)
|
|
53608
|
+
proofs.set(run.runId, { reason: "coordinator-cancelled", dispatchAt: dispatch.at, pauseAt: pause.at });
|
|
53609
|
+
}
|
|
53610
|
+
}
|
|
53611
|
+
return proofs;
|
|
53612
|
+
}
|
|
53613
|
+
// ../../packages/core/src/chief/organization-outcomes.ts
|
|
53535
53614
|
init_organization_types();
|
|
53536
53615
|
|
|
53537
53616
|
// ../../packages/core/src/chief/review-gate-check.ts
|
|
@@ -53652,6 +53731,7 @@ async function recordMissionOrganizationOutcome(sourceRepo, mission) {
|
|
|
53652
53731
|
mission.verification?.ok,
|
|
53653
53732
|
mission.finalReview?.criteria
|
|
53654
53733
|
]);
|
|
53734
|
+
const cancellations = cancelledWorkRunProofs(mission);
|
|
53655
53735
|
return recordOrganizationOutcome(sourceRepo, {
|
|
53656
53736
|
missionId: mission.id,
|
|
53657
53737
|
missionVersion,
|
|
@@ -53662,7 +53742,10 @@ async function recordMissionOrganizationOutcome(sourceRepo, mission) {
|
|
|
53662
53742
|
summary: (mission.report?.summary ?? mission.error ?? `Mission ${mission.status}`).slice(0, 2000),
|
|
53663
53743
|
evidence: await deliveredArtifacts(mission.workspace.path),
|
|
53664
53744
|
observations: [],
|
|
53665
|
-
runs: mission.operations?.runs ?? []
|
|
53745
|
+
runs: (mission.operations?.runs ?? []).map((run) => {
|
|
53746
|
+
const routingExclusion = cancellations.get(run.runId);
|
|
53747
|
+
return routingExclusion ? { ...run, routingExclusion } : run;
|
|
53748
|
+
}),
|
|
53666
53749
|
verification: mission.verification ? {
|
|
53667
53750
|
ok: mission.verification.ok,
|
|
53668
53751
|
fingerprint: mission.verification.fingerprint,
|
|
@@ -53694,7 +53777,8 @@ async function getOrganizationRouteEvidence(sourceRepo) {
|
|
|
53694
53777
|
totalCostUsd: 0,
|
|
53695
53778
|
successfulDeliverableCostUsd: null
|
|
53696
53779
|
};
|
|
53697
|
-
|
|
53780
|
+
if (!archivedWorkCancellation(run))
|
|
53781
|
+
group.samples++;
|
|
53698
53782
|
if (run.outcome === "passed")
|
|
53699
53783
|
group.successes++;
|
|
53700
53784
|
group.totalCostUsd = group.totalCostUsd === null || run.costUsd === null ? null : group.totalCostUsd + run.costUsd;
|
|
@@ -54409,6 +54493,7 @@ function unavailableProviders(state) {
|
|
|
54409
54493
|
var routeKey = (entry) => `${entry.actorType}\x00${entry.model ?? ""}`;
|
|
54410
54494
|
function routeEvidence(mission) {
|
|
54411
54495
|
const evidence = new Map;
|
|
54496
|
+
const cancelled = cancelledWorkRunProofs(mission);
|
|
54412
54497
|
for (const item of mission.operations?.routingEvidence ?? [])
|
|
54413
54498
|
evidence.set(routeKey(item), { ...item });
|
|
54414
54499
|
for (const run of mission.operations?.runs ?? []) {
|
|
@@ -54423,7 +54508,8 @@ function routeEvidence(mission) {
|
|
|
54423
54508
|
totalCostUsd: 0,
|
|
54424
54509
|
successfulDeliverableCostUsd: null
|
|
54425
54510
|
};
|
|
54426
|
-
|
|
54511
|
+
if (!cancelled.has(run.runId))
|
|
54512
|
+
item.samples += 1;
|
|
54427
54513
|
if (run.outcome === "passed")
|
|
54428
54514
|
item.successes += 1;
|
|
54429
54515
|
item.totalCostUsd = item.totalCostUsd === null || run.costUsd === null ? null : item.totalCostUsd + run.costUsd;
|
|
@@ -54479,7 +54565,8 @@ function selectWorkActor(mission, actor, taskId, compatibleRoutes) {
|
|
|
54479
54565
|
const initial = measured?.candidate ?? [...eligible].sort((a, b) => price2(a) - price2(b)).at(0);
|
|
54480
54566
|
if (!initial)
|
|
54481
54567
|
throw new Error("Restore a ready work routing candidate before continuing this mission.");
|
|
54482
|
-
const
|
|
54568
|
+
const cancelled = cancelledWorkRunProofs(mission);
|
|
54569
|
+
const taskRuns = (mission.operations?.runs ?? []).filter((run) => run.stage === "work" && run.taskId === taskId && !cancelled.has(run.runId));
|
|
54483
54570
|
const failed = new Set;
|
|
54484
54571
|
for (let i = taskRuns.length - 1;i >= 0; i--) {
|
|
54485
54572
|
const run = taskRuns[i];
|
|
@@ -73169,13 +73256,17 @@ async function runContinuousOperation(operation, ports) {
|
|
|
73169
73256
|
};
|
|
73170
73257
|
if (operation.phase === "completed")
|
|
73171
73258
|
return operation;
|
|
73259
|
+
const observingResumedChild = ["paused", "running", "accepting"].includes(operation.phase) && operation.recovery?.target === "child" && operation.recovery.checkpointId === operation.currentMissionId && operation.recovery.disposition === "protected" && operation.recovery.reason === "The operation was cancelled; automatic recovery is stopped.";
|
|
73260
|
+
if (observingResumedChild && operation.recovery)
|
|
73261
|
+
operation.recovery.reason = "Operation resumed; observing the original child checkpoint before deciding recovery. Its saved protections and spent limits remain in force.";
|
|
73172
73262
|
if (operation.phase === "paused") {
|
|
73173
73263
|
operation.phase = operation.resumePhase ?? (operation.currentMissionId ? "running" : operation.nextRunAt ? "waiting" : "deciding");
|
|
73174
73264
|
operation.resumePhase = undefined;
|
|
73175
73265
|
operation.pauseKind = undefined;
|
|
73176
73266
|
operation.error = undefined;
|
|
73177
73267
|
await save();
|
|
73178
|
-
}
|
|
73268
|
+
} else if (observingResumedChild)
|
|
73269
|
+
await save();
|
|
73179
73270
|
try {
|
|
73180
73271
|
while (true) {
|
|
73181
73272
|
if (ports.signal?.aborted)
|
|
@@ -73217,6 +73308,12 @@ async function runContinuousOperation(operation, ports) {
|
|
|
73217
73308
|
return pause(`Completed child ${id} is missing. Restore its saved mission record before continuing.`);
|
|
73218
73309
|
mission = await ports.runMission(operation, id, decision.goal, operation.baseline.path);
|
|
73219
73310
|
} else if (mission.status !== "completed" && mission.status !== "paused" && mission.status !== "failed") {
|
|
73311
|
+
const recovery = operation.recovery;
|
|
73312
|
+
if (recovery?.target === "child" && recovery.checkpointId === id && recovery.disposition === "protected" && !mission.tasks.some((task) => task.effectState === "running") && automaticMissionRecovery(mission, Date.parse(now())).retry) {
|
|
73313
|
+
recovery.disposition = "retrying";
|
|
73314
|
+
recovery.reason = `The original child resumed ${mission.status}; joining its saved coordinator without spending another recovery attempt.`;
|
|
73315
|
+
await save();
|
|
73316
|
+
}
|
|
73220
73317
|
mission = await ports.runMission(operation, id, decision.goal, operation.baseline.path);
|
|
73221
73318
|
}
|
|
73222
73319
|
assertIdentity(mission);
|
package/dist/supervisor.js
CHANGED
|
@@ -7519,6 +7519,11 @@ var init_operations = __esm(() => {
|
|
|
7519
7519
|
outcome: _enum(["pending", "passed", "rejected", "failed"]),
|
|
7520
7520
|
executionState: _enum(["running", "settled", "unknown"]).optional(),
|
|
7521
7521
|
executionRecovery: _enum(["local-process", "reconcile"]).optional(),
|
|
7522
|
+
routingExclusion: strictObject({
|
|
7523
|
+
reason: literal("coordinator-cancelled"),
|
|
7524
|
+
dispatchAt: exports_iso.datetime(),
|
|
7525
|
+
pauseAt: exports_iso.datetime()
|
|
7526
|
+
}).optional(),
|
|
7522
7527
|
routingReason: text3.optional(),
|
|
7523
7528
|
evidence: text3.optional(),
|
|
7524
7529
|
fingerprint: text3.optional()
|