@tangle-network/agent-runtime 2.3.8 → 2.3.11
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/{activation-Cks1h3Nw.d.ts → activation-B8dLwJj6.d.ts} +2 -2
- package/dist/{activation-CDPbi8JA.js → activation-BzNeFJDB.js} +4 -4
- package/dist/{activation-CDPbi8JA.js.map → activation-BzNeFJDB.js.map} +1 -1
- package/dist/agent.d.ts +1 -1
- package/dist/agent.js +3 -3
- package/dist/{bundle-PDYNXIEf.js → bundle-DhV73H6U.js} +2 -2
- package/dist/{bundle-PDYNXIEf.js.map → bundle-DhV73H6U.js.map} +1 -1
- package/dist/candidate-execution/index.js +4 -4
- package/dist/{coordination-manager-DNrb7zMg.js → coordination-manager-BluavEgY.js} +42 -152
- package/dist/coordination-manager-BluavEgY.js.map +1 -0
- package/dist/{coordination-map-routing-CUvwHAtv.js → coordination-map-routing-BllzcZov.js} +5 -2
- package/dist/coordination-map-routing-BllzcZov.js.map +1 -0
- package/dist/{delegate-CHdWyLz9.js → delegate-CYWL0MrO.js} +2 -2
- package/dist/{delegate-CHdWyLz9.js.map → delegate-CYWL0MrO.js.map} +1 -1
- package/dist/durable-file-DstVeHcj.js.map +1 -1
- package/dist/durable.d.ts +1 -1
- package/dist/durable.js +42 -202
- package/dist/durable.js.map +1 -1
- package/dist/{graph-oOdDpXFH.js → graph-ByNMeS0j.js} +8 -13
- package/dist/graph-ByNMeS0j.js.map +1 -0
- package/dist/{graph-registry-72DlMnUl.js → graph-registry-D6y6zffC.js} +2 -2
- package/dist/{graph-registry-72DlMnUl.js.map → graph-registry-D6y6zffC.js.map} +1 -1
- package/dist/{graph-registry-CAX15LO6.js → graph-registry-rV9mwxQO.js} +1 -1
- package/dist/{improve-BCjhWbVk.js → improve-D9A79N5a.js} +7 -7
- package/dist/{improve-BCjhWbVk.js.map → improve-D9A79N5a.js.map} +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +10 -11
- package/dist/index.js.map +1 -1
- package/dist/intelligence.d.ts +2 -2
- package/dist/intelligence.js +7 -6
- package/dist/intelligence.js.map +1 -1
- package/dist/kernel.d.ts +1 -1
- package/dist/kernel.js +12 -12
- package/dist/{loop-runner-Bkvx4Saw.d.ts → loop-runner-D9fuOb69.d.ts} +2 -2
- package/dist/{loop-runner-Cy1K7f-A.js → loop-runner-DiMfhI_z.js} +2 -2
- package/dist/{loop-runner-Cy1K7f-A.js.map → loop-runner-DiMfhI_z.js.map} +1 -1
- package/dist/loop-runner-bin.d.ts +1 -1
- package/dist/loop-runner-bin.js +1 -1
- package/dist/mcp/bin.js +3 -3
- package/dist/mcp/index.d.ts +1 -1
- package/dist/mcp/index.js +6 -5
- package/dist/mcp/index.js.map +1 -1
- package/dist/{prepare-Bv6X2Wnx.js → prepare-DrHOZFJy.js} +3 -4
- package/dist/{prepare-Bv6X2Wnx.js.map → prepare-DrHOZFJy.js.map} +1 -1
- package/dist/{profile-Dir2A1_2.js → profile-BzzmKuIX.js} +3 -2
- package/dist/{profile-Dir2A1_2.js.map → profile-BzzmKuIX.js.map} +1 -1
- package/dist/profiles.d.ts +1 -1
- package/dist/{provision-supervisor-Pd95wA1X.js → provision-supervisor-DP5U58V4.js} +13 -5
- package/dist/provision-supervisor-DP5U58V4.js.map +1 -0
- package/dist/{run-cancellation-CzQZUlHr.js → run-cancellation-BxoFCpJ_.js} +208 -5
- package/dist/run-cancellation-BxoFCpJ_.js.map +1 -0
- package/dist/{runtime-CWZ9q7lU.js → runtime-DS5AgACg.js} +15 -16
- package/dist/{runtime-CWZ9q7lU.js.map → runtime-DS5AgACg.js.map} +1 -1
- package/dist/sandbox-profile-compat-DxegoIK5.js +65 -0
- package/dist/sandbox-profile-compat-DxegoIK5.js.map +1 -0
- package/dist/scope-DRaBilEX.js +16734 -0
- package/dist/scope-DRaBilEX.js.map +1 -0
- package/dist/{search-executor-CMPbMvpr.js → search-executor-DLo_9jUv.js} +4 -5
- package/dist/{search-executor-CMPbMvpr.js.map → search-executor-DLo_9jUv.js.map} +1 -1
- package/dist/{server-DyTbsg7n.js → server-DfHV4ajw.js} +4 -4
- package/dist/{server-DyTbsg7n.js.map → server-DfHV4ajw.js.map} +1 -1
- package/dist/{structural-rollout-BUqZsIhX.js → structural-rollout-BIjjZ_XX.js} +4 -5
- package/dist/{structural-rollout-BUqZsIhX.js.map → structural-rollout-BIjjZ_XX.js.map} +1 -1
- package/dist/{supervise-D1eYde7p.js → supervise-6BCQ73Xa.js} +34 -136
- package/dist/supervise-6BCQ73Xa.js.map +1 -0
- package/dist/{supervision-discovery-DmDWHwLu.js → supervision-discovery-Da5zebY2.js} +130 -5
- package/dist/supervision-discovery-Da5zebY2.js.map +1 -0
- package/dist/{supervisor-B8beIEqH.js → supervisor-3JHXy3tz.js} +7336 -19680
- package/dist/supervisor-3JHXy3tz.js.map +1 -0
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +13 -13
- package/dist/{top-web-CUDlOKu0.js → top-web-DK6lTMHG.js} +89 -64
- package/dist/top-web-DK6lTMHG.js.map +1 -0
- package/dist/tui/bin.js +3 -3
- package/dist/tui/index.d.ts +14 -8
- package/dist/tui/index.js +2 -2
- package/dist/{types-DzS0kBeK.d.ts → types-S3RbyJ4x.d.ts} +51 -65
- package/dist/{sandbox-profile-compat-DRiz9kME.js → workspace-streams-Dep2L6XD.js} +617 -57
- package/dist/workspace-streams-Dep2L6XD.js.map +1 -0
- package/package.json +2 -2
- package/dist/coordination-manager-DNrb7zMg.js.map +0 -1
- package/dist/coordination-map-routing-CUvwHAtv.js.map +0 -1
- package/dist/graph-oOdDpXFH.js.map +0 -1
- package/dist/provision-supervisor-Pd95wA1X.js.map +0 -1
- package/dist/root-stream-Bsh5WFcg.js +0 -4252
- package/dist/root-stream-Bsh5WFcg.js.map +0 -1
- package/dist/run-cancellation-CzQZUlHr.js.map +0 -1
- package/dist/sandbox-profile-compat-DRiz9kME.js.map +0 -1
- package/dist/supervise-D1eYde7p.js.map +0 -1
- package/dist/supervision-discovery-DmDWHwLu.js.map +0 -1
- package/dist/supervisor-B8beIEqH.js.map +0 -1
- package/dist/top-web-CUDlOKu0.js.map +0 -1
- package/dist/util-BX20UJ9X.js +0 -624
- package/dist/util-BX20UJ9X.js.map +0 -1
package/dist/durable.js
CHANGED
|
@@ -1,150 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Kr as runtimeFailureCause, L as FileSpawnJournal, Vt as loadSpawnForest, _ as supervisorRunDir, a as readRootStream, br as authoredProfileDigest, dn as FileObserverJournal, fn as createFileObserverHooks, o as readRootStreamReceipt, pi as contentAddress, pn as observerRecordDigest, qt as FileResultBlobStore, wi as assertValidBudget, y as workerCancellationsDir } from "./scope-DRaBilEX.js";
|
|
2
2
|
import { f as RuntimeRunStateError, m as ValidationError } from "./errors-AzSuGI23.js";
|
|
3
|
-
import {
|
|
4
|
-
import { C as FileSpawnJournal, E as FileResultBlobStore, L as runtimeFailureCause, M as FileObserverJournal, N as createFileObserverHooks, P as observerRecordDigest, a as readRootStreamReceipt, g as supervisorRunDir, i as readRootStream, ut as contentAddress, v as workerCancellationsDir, wt as assertValidBudget } from "./root-stream-Bsh5WFcg.js";
|
|
3
|
+
import { J as errorMessage } from "./workspace-streams-Dep2L6XD.js";
|
|
5
4
|
import { n as isNoEntError } from "./jsonl-file-BBP9Dz9w.js";
|
|
5
|
+
import { Et as isFiniteNumber, Tt as failedItems, i as RunParkedError, r as assertResumeLimits, s as readRunParking } from "./supervisor-3JHXy3tz.js";
|
|
6
6
|
import { a as writeAtomicDurableFile, c as mutateRunClaim, i as syncDurableDirectory, l as runGenerationPath, r as publishExclusiveDurableFile, s as fenceRunWrite, u as runWithWriteClaim } from "./durable-file-DstVeHcj.js";
|
|
7
7
|
import { a as withPursuitContext, t as composeRuntimeHooks } from "./runtime-hooks-CsW2pfFk.js";
|
|
8
|
-
import { a as applyExactAgentProfileDiff } from "./profile-
|
|
9
|
-
import { a as
|
|
10
|
-
import { a as
|
|
11
|
-
import { a as graphExecutionOptions, i as superviseAgentGraph } from "./graph-
|
|
8
|
+
import { a as applyExactAgentProfileDiff } from "./profile-BzzmKuIX.js";
|
|
9
|
+
import { a as runCancelRequestFile, h as rootCoordinationOwner, o as runCancellationFile, v as FileCoordinationLog } from "./run-cancellation-BxoFCpJ_.js";
|
|
10
|
+
import { a as superviseRootProfile, p as runToolSpans, t as supervise } from "./supervise-6BCQ73Xa.js";
|
|
11
|
+
import { a as graphExecutionOptions, i as superviseAgentGraph } from "./graph-ByNMeS0j.js";
|
|
12
12
|
import { n as handleChatTurn, t as deriveExecutionId } from "./execution-handle-Bd2_nUB6.js";
|
|
13
|
-
import {
|
|
14
|
-
import { agentProfileSchema, canonicalAgentProfileDigest, canonicalCandidateDigest,
|
|
13
|
+
import { a as parseSettleRecord, c as settleRecordDigest, d as projectPursuit, i as SettledRunDirectoryError, l as writeFailureRecord, n as FAILURE_RECORD_FILE, o as readFailureRecord, r as SETTLE_RECORD_FILE, s as readSettleRecord, t as discoverDurableSupervisionRun, u as writeSettleRecord } from "./supervision-discovery-Da5zebY2.js";
|
|
14
|
+
import { agentProfileSchema, canonicalAgentProfileDigest, canonicalCandidateDigest, sha256Bytes } from "@tangle-network/agent-interface";
|
|
15
15
|
import { closeSync, existsSync, fstatSync, mkdirSync, openSync, readFileSync, readdirSync, renameSync, unlinkSync } from "node:fs";
|
|
16
16
|
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
17
17
|
import { access, readFile, realpath } from "node:fs/promises";
|
|
18
|
+
import { lockHolderVerdict, lockIdentity, parseLockHolderRecord, readLockHolderIdentity } from "@tangle-network/agent-eval/lock-holder";
|
|
18
19
|
import { SearchRecorder, developmentClaim, incumbent, openSearchLedger, parseSearchLedgerLine, runSearch, uniform } from "@tangle-network/agent-eval/campaign";
|
|
19
20
|
import { pathToFileURL } from "node:url";
|
|
20
21
|
import { setTimeout as setTimeout$1 } from "node:timers/promises";
|
|
21
|
-
import { lockHolderVerdict, lockIdentity, parseLockHolderRecord, readLockHolderIdentity } from "@tangle-network/agent-eval/lock-holder";
|
|
22
|
-
// src/durable/settle-record.ts
|
|
23
|
-
/** The settle record: the returned `SupervisedResult` as canonical JSON, written once. */
|
|
24
|
-
const SETTLE_RECORD_FILE = "result.json";
|
|
25
|
-
/** The failure record: the most recent throw, replaced by a later throw. */
|
|
26
|
-
const FAILURE_RECORD_FILE = "failure.json";
|
|
27
|
-
/** The directory already holds a settle record, so the run it records must not be re-entered. */
|
|
28
|
-
var SettledRunDirectoryError = class extends Error {
|
|
29
|
-
path;
|
|
30
|
-
/** The root of the recorded run, which is its `runId`. */
|
|
31
|
-
recordedRunId;
|
|
32
|
-
constructor(path, recordedRunId, requestedRunId) {
|
|
33
|
-
super(recordedRunId === requestedRunId ? `supervisePursuit: ${path} records that run '${recordedRunId}' already settled; a settled run is not re-entered unless the call passes reopen: { operator, reason, operationId }` : `supervisePursuit: ${path} records that run '${recordedRunId}' already settled in this directory; a directory holds one settle record, so run '${requestedRunId}' needs its own runDir`);
|
|
34
|
-
this.name = "SettledRunDirectoryError";
|
|
35
|
-
this.path = path;
|
|
36
|
-
this.recordedRunId = recordedRunId;
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
/** A result member whose JSON form would misstate it. */
|
|
40
|
-
var UnrecordableSettleValueError = class extends TypeError {
|
|
41
|
-
path;
|
|
42
|
-
constructor(path, kind) {
|
|
43
|
-
super(`supervisePursuit: result${path} is a ${kind}, which JSON cannot record faithfully; a settle record holds plain data only`);
|
|
44
|
-
this.name = "UnrecordableSettleValueError";
|
|
45
|
-
this.path = path;
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
const PLAIN_PROTOTYPES = /* @__PURE__ */ new Set([
|
|
49
|
-
Object.prototype,
|
|
50
|
-
Array.prototype,
|
|
51
|
-
null
|
|
52
|
-
]);
|
|
53
|
-
/**
|
|
54
|
-
* The JSON value of a result, or a throw naming the first member JSON would misstate. An
|
|
55
|
-
* `undefined` member and a function are dropped, exactly as any JSON consumer drops them; a Map,
|
|
56
|
-
* a Set, a Date, a typed array, or a class instance would be rewritten to `{}` or a string and
|
|
57
|
-
* so is refused.
|
|
58
|
-
*/
|
|
59
|
-
function jsonValue(result) {
|
|
60
|
-
const seen = [];
|
|
61
|
-
const visit = (value, path) => {
|
|
62
|
-
if (value === null || typeof value !== "object") return;
|
|
63
|
-
if (value instanceof Map) throw new UnrecordableSettleValueError(path, "Map");
|
|
64
|
-
if (value instanceof Set) throw new UnrecordableSettleValueError(path, "Set");
|
|
65
|
-
if (value instanceof Date) throw new UnrecordableSettleValueError(path, "Date");
|
|
66
|
-
if (ArrayBuffer.isView(value) || value instanceof ArrayBuffer) throw new UnrecordableSettleValueError(path, "binary buffer");
|
|
67
|
-
if (!PLAIN_PROTOTYPES.has(Object.getPrototypeOf(value))) throw new UnrecordableSettleValueError(path, "class instance");
|
|
68
|
-
if (seen.includes(value)) throw new UnrecordableSettleValueError(path, "cycle");
|
|
69
|
-
seen.push(value);
|
|
70
|
-
if (Array.isArray(value)) for (const [index, item] of value.entries()) visit(item, `${path}[${index}]`);
|
|
71
|
-
else for (const [key, item] of Object.entries(value)) visit(item, `${path}.${key}`);
|
|
72
|
-
seen.pop();
|
|
73
|
-
};
|
|
74
|
-
visit(result, "");
|
|
75
|
-
return JSON.parse(JSON.stringify(result));
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* The exact bytes `result.json` holds for a result: its JSON value serialized as RFC 8785
|
|
79
|
-
* canonical JSON. Throws `UnrecordableSettleValueError` before any byte is written when the
|
|
80
|
-
* result carries a value JSON would misstate.
|
|
81
|
-
*/
|
|
82
|
-
function settleRecordJson(result) {
|
|
83
|
-
return canonicalCandidateJson(jsonValue(result));
|
|
84
|
-
}
|
|
85
|
-
/** The digest the settle record's bytes hash to: the candidate digest of the result's JSON value. */
|
|
86
|
-
function settleRecordDigest(result) {
|
|
87
|
-
return canonicalCandidateDigest(jsonValue(result));
|
|
88
|
-
}
|
|
89
|
-
/** Publish `result.json` in the run directory once. Throws when a record is already there. */
|
|
90
|
-
async function writeSettleRecord(runDir, result) {
|
|
91
|
-
const path = resolve(runDir, SETTLE_RECORD_FILE);
|
|
92
|
-
if (!publishExclusiveDurableFile(path, settleRecordJson(result))) throw new Error(`supervisePursuit: ${path} already exists; a settle record is written once`);
|
|
93
|
-
return path;
|
|
94
|
-
}
|
|
95
|
-
/** Replace `failure.json` in the run directory with the most recent throw. */
|
|
96
|
-
async function writeFailureRecord(runDir, record) {
|
|
97
|
-
const path = resolve(runDir, FAILURE_RECORD_FILE);
|
|
98
|
-
writeAtomicDurableFile(path, `${JSON.stringify(record, null, 2)}\n`);
|
|
99
|
-
return path;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Read the settle record a run directory holds, or `undefined` when it holds none. A file that
|
|
103
|
-
* is present but is not a settle record is corruption and fails loud.
|
|
104
|
-
*/
|
|
105
|
-
async function readSettleRecord(runDir) {
|
|
106
|
-
const path = resolve(runDir, SETTLE_RECORD_FILE);
|
|
107
|
-
let text;
|
|
108
|
-
try {
|
|
109
|
-
text = await readFile(path, "utf8");
|
|
110
|
-
} catch (error) {
|
|
111
|
-
if (isNoEntError(error)) return void 0;
|
|
112
|
-
throw error;
|
|
113
|
-
}
|
|
114
|
-
return parseSettleRecord(text, path);
|
|
115
|
-
}
|
|
116
|
-
/** Parse settle-record bytes already read, so a caller hashes and parses the same bytes. */
|
|
117
|
-
function parseSettleRecord(text, path) {
|
|
118
|
-
let parsed;
|
|
119
|
-
try {
|
|
120
|
-
parsed = JSON.parse(text);
|
|
121
|
-
} catch (cause) {
|
|
122
|
-
throw new Error(`supervisePursuit: ${path} is not valid JSON`, { cause });
|
|
123
|
-
}
|
|
124
|
-
const record = parsed;
|
|
125
|
-
if (typeof record !== "object" || record === null || typeof record.kind !== "string" || typeof record.tree !== "object" || record.tree === null || typeof record.tree.root !== "string") throw new Error(`supervisePursuit: ${path} is not a settle record (no kind or tree.root)`);
|
|
126
|
-
return parsed;
|
|
127
|
-
}
|
|
128
|
-
/** Read the most recent failure record, or `undefined` when the directory holds none. */
|
|
129
|
-
async function readFailureRecord(runDir) {
|
|
130
|
-
const path = resolve(runDir, FAILURE_RECORD_FILE);
|
|
131
|
-
let text;
|
|
132
|
-
try {
|
|
133
|
-
text = await readFile(path, "utf8");
|
|
134
|
-
} catch (error) {
|
|
135
|
-
if (isNoEntError(error)) return void 0;
|
|
136
|
-
throw error;
|
|
137
|
-
}
|
|
138
|
-
let parsed;
|
|
139
|
-
try {
|
|
140
|
-
parsed = JSON.parse(text);
|
|
141
|
-
} catch (cause) {
|
|
142
|
-
throw new Error(`supervisePursuit: ${path} is not valid JSON`, { cause });
|
|
143
|
-
}
|
|
144
|
-
const record = parsed;
|
|
145
|
-
if (typeof record !== "object" || record === null || typeof record.runId !== "string" || typeof record.pursuitId !== "string" || typeof record.at !== "string" || typeof record.error?.name !== "string" || typeof record.error.message !== "string" || record.rootStream !== void 0 && (typeof record.rootStream.ref !== "string" || typeof record.rootStream.events !== "number")) throw new Error(`supervisePursuit: ${path} is not a failure record`);
|
|
146
|
-
return parsed;
|
|
147
|
-
}
|
|
148
22
|
// src/durable/pursuit-version-evidence.ts
|
|
149
23
|
/** The chain's directory beside the first version's: the ledger and its content blobs. */
|
|
150
24
|
function pursuitVersionsLedgerPath(runDir) {
|
|
@@ -1589,24 +1463,14 @@ var SupervisePursuitError = class extends Error {
|
|
|
1589
1463
|
}
|
|
1590
1464
|
};
|
|
1591
1465
|
/**
|
|
1592
|
-
*
|
|
1466
|
+
* Execute `supervise()` with a durable observer and return its verified pursuit projection.
|
|
1467
|
+
* Each `runDir` owns its lock and journals; Intelligence joins directories by `pursuitId`.
|
|
1468
|
+
* Agents never receive the observer path or projection.
|
|
1593
1469
|
*
|
|
1594
|
-
*
|
|
1595
|
-
*
|
|
1596
|
-
*
|
|
1597
|
-
*
|
|
1598
|
-
*
|
|
1599
|
-
* Every concrete execution writes only inside its own `runDir`. Cross-run pursuit
|
|
1600
|
-
* aggregation is therefore lock-free at the observer layer: reuse `pursuitId` across
|
|
1601
|
-
* run directories and let Intelligence join the independently verified projections.
|
|
1602
|
-
*
|
|
1603
|
-
* The directory's terminal state is recorded beside `observer.jsonl`: `result.json` holds the
|
|
1604
|
-
* returned result once the run settles and `failure.json` the most recent throw. A directory
|
|
1605
|
-
* whose `result.json` exists refuses re-entry before any compute; a failure record alone does
|
|
1606
|
-
* not, because a caller can correct its input and drive the same run again. For the life of the
|
|
1607
|
-
* call the directory is held by `supervise.lock`, so a second process on the same directory
|
|
1608
|
-
* refuses and names the holder instead of sharing one journal.
|
|
1609
|
-
* An abandoned `supervise.lock.guard` requires removal after confirming no lock mutation is active.
|
|
1470
|
+
* `result.json` seals a segment and refuses re-entry before compute; `failure.json` records
|
|
1471
|
+
* the latest throw and permits a corrected retry. Both pursuit entrypoints use the same
|
|
1472
|
+
* directory lifecycle below. A competing process is refused with the lock holder's identity;
|
|
1473
|
+
* an abandoned `supervise.lock.guard` requires confirmation of inactivity before removal.
|
|
1610
1474
|
*/
|
|
1611
1475
|
async function supervisePursuit(profile, task, opts) {
|
|
1612
1476
|
assertPursuitDirectory(opts, "supervisePursuit");
|
|
@@ -1624,32 +1488,13 @@ async function supervisePursuit(profile, task, opts) {
|
|
|
1624
1488
|
steerDir,
|
|
1625
1489
|
retainedAtSettlement: "release",
|
|
1626
1490
|
hooks
|
|
1627
|
-
}), (result) => result,
|
|
1628
|
-
runDir: opts.runDir.trim(),
|
|
1629
|
-
runId: opts.runId ?? "supervise",
|
|
1630
|
-
reopen,
|
|
1631
|
-
journal: opts.journal,
|
|
1632
|
-
limits: {
|
|
1633
|
-
budget: opts.budget,
|
|
1634
|
-
...opts.reservationPolicy === void 0 ? {} : { reservationPolicy: opts.reservationPolicy }
|
|
1635
|
-
},
|
|
1636
|
-
observer,
|
|
1637
|
-
pursuitId: opts.pursuitId.trim(),
|
|
1638
|
-
now: opts.now ?? Date.now
|
|
1639
|
-
}));
|
|
1491
|
+
}), (result) => result, opts.budget);
|
|
1640
1492
|
}
|
|
1641
1493
|
/**
|
|
1642
|
-
*
|
|
1643
|
-
*
|
|
1644
|
-
*
|
|
1645
|
-
*
|
|
1646
|
-
* recent throw, and refusal of a settled directory before any compute — and runs the graph through
|
|
1647
|
-
* `runGraph`'s own path, so the root node is a `supervise()` root and a restarted process resumes
|
|
1648
|
-
* the graph from its spawn journal. `result.json` holds the graph's supervised result, the same
|
|
1649
|
-
* record every supervised run leaves; the edge ledger is the journal's `edge` events and the
|
|
1650
|
-
* returned `result.ledger`. Version chains and forks are `supervisePursuit` features and are not
|
|
1651
|
-
* offered here. An explicit `reopen` uses the same archived-settle and resume contract as
|
|
1652
|
-
* `supervisePursuit`; ordinary re-entry of a settled graph stays refused.
|
|
1494
|
+
* Graph twin of `supervisePursuit`, using its directory lifecycle and `runGraph` execution.
|
|
1495
|
+
* The directory run id binds the supervised root; spawn-journal edge events own the ledger.
|
|
1496
|
+
* Explicit `reopen` archives the result and resumes this id; ordinary settled re-entry refuses.
|
|
1497
|
+
* Forks and version chains are offered by `supervisePursuit` only.
|
|
1653
1498
|
*/
|
|
1654
1499
|
async function superviseGraphPursuit(graph, opts) {
|
|
1655
1500
|
assertPursuitDirectory(opts, "superviseGraphPursuit");
|
|
@@ -1665,31 +1510,15 @@ async function superviseGraphPursuit(graph, opts) {
|
|
|
1665
1510
|
steerDir,
|
|
1666
1511
|
retainedAtSettlement: "release",
|
|
1667
1512
|
hooks
|
|
1668
|
-
}), brain), (result) => result.result,
|
|
1669
|
-
runDir: opts.runDir.trim(),
|
|
1670
|
-
runId: opts.runId ?? "supervise",
|
|
1671
|
-
reopen,
|
|
1672
|
-
journal: opts.journal,
|
|
1673
|
-
limits: {
|
|
1674
|
-
budget: graph.budget,
|
|
1675
|
-
...opts.reservationPolicy === void 0 ? {} : { reservationPolicy: opts.reservationPolicy }
|
|
1676
|
-
},
|
|
1677
|
-
observer,
|
|
1678
|
-
pursuitId: opts.pursuitId.trim(),
|
|
1679
|
-
now: opts.now ?? Date.now
|
|
1680
|
-
}));
|
|
1513
|
+
}), brain), (result) => result.result, graph.budget);
|
|
1681
1514
|
}
|
|
1682
1515
|
/** The pursuit identity and run directory both durable entries require. */
|
|
1683
1516
|
function assertPursuitDirectory(opts, entry) {
|
|
1684
1517
|
for (const field of ["pursuitId", "runDir"]) if (opts[field].trim().length === 0) throw new TypeError(`${entry}: ${field} must be non-empty`);
|
|
1685
1518
|
if (opts.retainedAtSettlement === "keep") throw new TypeError(`${entry}: retainedAtSettlement 'keep' cannot hold, because a settled pursuit is never re-entered`);
|
|
1686
1519
|
}
|
|
1687
|
-
/**
|
|
1688
|
-
|
|
1689
|
-
* journal, failure record and settle record. `execute` receives the observer-composed hooks and
|
|
1690
|
-
* the steer directory the run's control plane uses; `settled` names the value `result.json` holds.
|
|
1691
|
-
*/
|
|
1692
|
-
async function runDurablePursuit(opts, execute, settled, reopen) {
|
|
1520
|
+
/** Own the directory lock, terminal records and observer lifecycle for both pursuit entries. */
|
|
1521
|
+
async function runDurablePursuit(opts, execute, settled, budget) {
|
|
1693
1522
|
const pursuitId = opts.pursuitId.trim();
|
|
1694
1523
|
const runDir = opts.runDir.trim();
|
|
1695
1524
|
const observerPath = resolve(runDir, "observer.jsonl");
|
|
@@ -1703,12 +1532,26 @@ async function runDurablePursuit(opts, execute, settled, reopen) {
|
|
|
1703
1532
|
let terminalState = "failed";
|
|
1704
1533
|
try {
|
|
1705
1534
|
const observer = createFileObserverHooks(observerPath, pursuitId);
|
|
1706
|
-
if (reopen !== void 0) await
|
|
1535
|
+
if (opts.reopen !== void 0) await reopenSettledRun({
|
|
1536
|
+
runDir,
|
|
1537
|
+
runId,
|
|
1538
|
+
reopen: opts.reopen,
|
|
1539
|
+
journal: opts.journal,
|
|
1540
|
+
limits: {
|
|
1541
|
+
budget,
|
|
1542
|
+
...opts.reservationPolicy === void 0 ? {} : { reservationPolicy: opts.reservationPolicy }
|
|
1543
|
+
},
|
|
1544
|
+
observer: observer.journal,
|
|
1545
|
+
pursuitId,
|
|
1546
|
+
now
|
|
1547
|
+
});
|
|
1707
1548
|
else {
|
|
1708
1549
|
const prior = await readSettleRecord(runDir);
|
|
1709
1550
|
if (prior !== void 0) throw new SettledRunDirectoryError(settlePath, prior.tree.root, runId);
|
|
1710
1551
|
}
|
|
1711
|
-
await
|
|
1552
|
+
const root = (await (opts.journal ?? new FileSpawnJournal(resolve(runDir, "spawn-journal.jsonl"))).loadTree(runId) ?? []).find((event) => event.kind === "spawned" && event.id === runId);
|
|
1553
|
+
const prior = root?.kind === "spawned" && root.identity ? await new FileCoordinationLog(resolve(runDir, "coordination-log.jsonl")).load(runId, rootCoordinationOwner(root.identity)) : void 0;
|
|
1554
|
+
await observer.journal.appendEvent(rootEvent(pursuitId, runId, "before", now(), { coordinationOffset: prior?.records.length ?? 0 }));
|
|
1712
1555
|
delivery = opts.observerDelivery === void 0 ? void 0 : startPursuitObserverDelivery(opts.observerDelivery, async () => projectPursuit(await observer.journal.read()));
|
|
1713
1556
|
let result;
|
|
1714
1557
|
try {
|
|
@@ -1739,7 +1582,7 @@ async function runDurablePursuit(opts, execute, settled, reopen) {
|
|
|
1739
1582
|
pursuitId,
|
|
1740
1583
|
at: new Date(now()).toISOString(),
|
|
1741
1584
|
error: {
|
|
1742
|
-
name:
|
|
1585
|
+
name: error instanceof Error ? error.name : "NonError",
|
|
1743
1586
|
message: errorMessage(error)
|
|
1744
1587
|
},
|
|
1745
1588
|
...rootStream === void 0 ? {} : { rootStream }
|
|
@@ -1786,9 +1629,6 @@ function rootEvent(pursuitId, runId, phase, timestamp, payload) {
|
|
|
1786
1629
|
...payload ? { payload: Object.freeze({ ...payload }) } : {}
|
|
1787
1630
|
});
|
|
1788
1631
|
}
|
|
1789
|
-
function errorName(error) {
|
|
1790
|
-
return error instanceof Error ? error.name : "NonError";
|
|
1791
|
-
}
|
|
1792
1632
|
export { FileObserverJournal, RUN_FORK_CORRELATION_KEYS, RunDirectoryLockedError, RunParkedError, SettledRunDirectoryError, SupervisePursuitError, acquireRunDirectoryLock, assertPursuitVersions, deriveExecutionId, discoverDurableSupervisionRun, durableRunToolSpans, handleChatTurn, observerRecordDigest, projectPursuit, readFailureRecord, readRootStream, readRootStreamReceipt, readRunDirectoryLock, readRunParking, readSettleRecord, runDirectoryHolderIsLive, superviseGraphPursuit, supervisePursuit };
|
|
1793
1633
|
|
|
1794
1634
|
//# sourceMappingURL=durable.js.map
|