@tangle-network/agent-runtime 10.0.1 → 10.0.3
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/CHANGELOG.md +14 -0
- package/dist/{activation-s6dGGify.d.ts → activation-DbSxPRUW.d.ts} +2 -2
- package/dist/{activation-C_BenzIu.js → activation-kitznAHo.js} +2 -2
- package/dist/{activation-C_BenzIu.js.map → activation-kitznAHo.js.map} +1 -1
- package/dist/agent.d.ts +1 -1
- package/dist/agent.js +3 -3
- package/dist/{continuation-CZaeHEzQ.js → continuation-BDeKJgV3.js} +3 -3
- package/dist/{continuation-CZaeHEzQ.js.map → continuation-BDeKJgV3.js.map} +1 -1
- package/dist/{delegate-BOren4c7.js → delegate-D8yX_2K7.js} +2 -2
- package/dist/{delegate-BOren4c7.js.map → delegate-D8yX_2K7.js.map} +1 -1
- package/dist/{driver-control-acknowledgers-ByKwAgCI.js → driver-control-acknowledgers-BTSr3Znq.js} +50 -12
- package/dist/driver-control-acknowledgers-BTSr3Znq.js.map +1 -0
- package/dist/durable-file-DUcTDWJD.js +498 -0
- package/dist/durable-file-DUcTDWJD.js.map +1 -0
- package/dist/durable-file-XqOyDf7q.js +1 -0
- package/dist/durable-writer-thread.d.ts +1 -0
- package/dist/durable-writer-thread.js +86 -0
- package/dist/durable-writer-thread.js.map +1 -0
- package/dist/durable.d.ts +1 -1
- package/dist/durable.js +15 -128
- package/dist/durable.js.map +1 -1
- package/dist/{graph-BXONYT1o.js → graph-4ep9laIH.js} +8 -8
- package/dist/{graph-BXONYT1o.js.map → graph-4ep9laIH.js.map} +1 -1
- package/dist/{graph-registry-DxhlgHdA.js → graph-registry-B-EGvJ-3.js} +1 -1
- package/dist/{graph-registry-j9t9J0KT.js → graph-registry-BxEBeihr.js} +4 -4
- package/dist/{graph-registry-j9t9J0KT.js.map → graph-registry-BxEBeihr.js.map} +1 -1
- package/dist/{improve-CS2GIF5O.js → improve-CJf87tBs.js} +8 -8
- package/dist/{improve-CS2GIF5O.js.map → improve-CJf87tBs.js.map} +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +10 -10
- package/dist/intelligence.d.ts +2 -2
- package/dist/intelligence.js +4 -4
- package/dist/{jsonl-file-BhuxeejY.js → jsonl-file-CVAWegN-.js} +53 -11
- package/dist/jsonl-file-CVAWegN-.js.map +1 -0
- package/dist/kernel.d.ts +2 -2
- package/dist/kernel.js +19 -17
- package/dist/{loop-runner-C0B3PexH.d.ts → loop-runner-CayC8e9K.d.ts} +2 -2
- package/dist/{loop-runner-ftyZP4st.js → loop-runner-Ckj-Zz3-.js} +2 -2
- package/dist/{loop-runner-ftyZP4st.js.map → loop-runner-Ckj-Zz3-.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 -6
- package/dist/{model-policy-CqDuBTq-.js → model-policy-DZnL8Yj9.js} +13 -2
- package/dist/{model-policy-CqDuBTq-.js.map → model-policy-DZnL8Yj9.js.map} +1 -1
- package/dist/profiles.d.ts +1 -1
- package/dist/profiles.js +1 -1
- package/dist/{provision-supervisor-CauovUHn.js → provision-supervisor-NjROV7AQ.js} +7 -7
- package/dist/{provision-supervisor-CauovUHn.js.map → provision-supervisor-NjROV7AQ.js.map} +1 -1
- package/dist/result-blob-store-BR-BVZrg.js +76 -0
- package/dist/result-blob-store-BR-BVZrg.js.map +1 -0
- package/dist/{run-cancellation-NMNVuYiO.js → run-cancellation-C9V1lYhq.js} +5 -209
- package/dist/run-cancellation-C9V1lYhq.js.map +1 -0
- package/dist/run-lock-Y3u9kwM0.js +193 -0
- package/dist/run-lock-Y3u9kwM0.js.map +1 -0
- package/dist/run-reopen-CHYTHk7x.js +134 -0
- package/dist/run-reopen-CHYTHk7x.js.map +1 -0
- package/dist/run-state-DgKo8_tO.js +180 -0
- package/dist/run-state-DgKo8_tO.js.map +1 -0
- package/dist/{runtime-DYaRDLKn.js → runtime-CdthBQUs.js} +22 -20
- package/dist/{runtime-DYaRDLKn.js.map → runtime-CdthBQUs.js.map} +1 -1
- package/dist/{search-executor-Drd_N9YO.js → search-executor-Bb0WuI_Z.js} +4 -4
- package/dist/{search-executor-Drd_N9YO.js.map → search-executor-Bb0WuI_Z.js.map} +1 -1
- package/dist/{server-Dk9B1WFf.js → server-BCtyL7jH.js} +3 -3
- package/dist/{server-Dk9B1WFf.js.map → server-BCtyL7jH.js.map} +1 -1
- package/dist/{settle-record-YdkkHzqw.js → settle-record-Beh-sXBW.js} +5 -4
- package/dist/settle-record-Beh-sXBW.js.map +1 -0
- package/dist/{structural-rollout-DbZAkHTq.js → structural-rollout-BRfSDPkv.js} +5 -5
- package/dist/{structural-rollout-DbZAkHTq.js.map → structural-rollout-BRfSDPkv.js.map} +1 -1
- package/dist/{supervise-B5hb0my3.js → supervise-DTUYxnoJ.js} +10 -9
- package/dist/{supervise-B5hb0my3.js.map → supervise-DTUYxnoJ.js.map} +1 -1
- package/dist/supervise-identity-eMF-h1uP.js +210 -0
- package/dist/supervise-identity-eMF-h1uP.js.map +1 -0
- package/dist/{supervision-discovery-ChkTxilL.js → supervision-discovery-CAUsSDno.js} +3 -3
- package/dist/{supervision-discovery-ChkTxilL.js.map → supervision-discovery-CAUsSDno.js.map} +1 -1
- package/dist/{supervisor-DpwcTrTh.js → supervisor-BtRRFbgF.js} +32 -187
- package/dist/supervisor-BtRRFbgF.js.map +1 -0
- package/dist/{supervisor-accounting-QiXnF-EW.js → supervisor-accounting-Cuehs4te.js} +60 -113
- package/dist/supervisor-accounting-Cuehs4te.js.map +1 -0
- package/dist/supervisor-root-contract-CmFKzPps.js +165 -0
- package/dist/supervisor-root-contract-CmFKzPps.js.map +1 -0
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +11 -11
- package/dist/{top-web-E85Fk8pH.js → top-web-D-wuEVdM.js} +7 -6
- package/dist/{top-web-E85Fk8pH.js.map → top-web-D-wuEVdM.js.map} +1 -1
- package/dist/tui/bin.js +3 -3
- package/dist/tui/index.d.ts +1 -1
- package/dist/tui/index.js +2 -2
- package/dist/{types-dv295cpm.d.ts → types-PBoTtcbX.d.ts} +15 -2
- package/package.json +1 -1
- package/dist/driver-control-acknowledgers-ByKwAgCI.js.map +0 -1
- package/dist/durable-file-CksURHlH.js +0 -1
- package/dist/durable-file-DstVeHcj.js +0 -228
- package/dist/durable-file-DstVeHcj.js.map +0 -1
- package/dist/jsonl-file-BhuxeejY.js.map +0 -1
- package/dist/run-cancellation-NMNVuYiO.js.map +0 -1
- package/dist/run-state-COyIVOVb.js +0 -357
- package/dist/run-state-COyIVOVb.js.map +0 -1
- package/dist/settle-record-YdkkHzqw.js.map +0 -1
- package/dist/supervisor-DpwcTrTh.js.map +0 -1
- package/dist/supervisor-accounting-QiXnF-EW.js.map +0 -1
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { C as runWithWriteClaim, c as publishExclusiveFenced, d as writeAtomicFenced, f as becomeDurableWriter, i as appendRunLinesFenced, t as appendDurableFenced } from "./durable-file-DUcTDWJD.js";
|
|
2
|
+
import { a as closeStreamFile, c as openStreamFileFenced, d as syncStreamFileFenced, f as writeStreamLinesFenced } from "./supervisor-accounting-Cuehs4te.js";
|
|
3
|
+
import { i as prepareJsonlTailFenced, u as appendCommittedLine } from "./jsonl-file-CVAWegN-.js";
|
|
4
|
+
import { i as acquireRunLockFenced, o as releaseRunLockFenced } from "./run-lock-Y3u9kwM0.js";
|
|
5
|
+
import { n as makeRunDirectoryFenced, r as reopenSettleFenced } from "./run-reopen-CHYTHk7x.js";
|
|
6
|
+
import { parentPort, workerData } from "node:worker_threads";
|
|
7
|
+
// src/durable/durable-writer-thread.ts
|
|
8
|
+
/**
|
|
9
|
+
* The durable writer thread's entry (durable-writer.ts): it runs each named operation it receives,
|
|
10
|
+
* in the order received, under the claim the caller held, with the same synchronous fence and
|
|
11
|
+
* fsync the caller's thread used to run. A synchronous caller is answered on its own port and woken
|
|
12
|
+
* through the shared signal; an asynchronous one through the thread's message port.
|
|
13
|
+
*
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
const OPERATIONS = {
|
|
17
|
+
acquireRunLock: acquireRunLockFenced,
|
|
18
|
+
appendCommittedLine,
|
|
19
|
+
appendDurableFile: appendDurableFenced,
|
|
20
|
+
appendRunLines: appendRunLinesFenced,
|
|
21
|
+
closeStreamFile,
|
|
22
|
+
makeRunDirectory: makeRunDirectoryFenced,
|
|
23
|
+
openStreamFile: openStreamFileFenced,
|
|
24
|
+
prepareJsonlAppend: prepareJsonlTailFenced,
|
|
25
|
+
publishExclusiveDurableFile: publishExclusiveFenced,
|
|
26
|
+
releaseRunLock: releaseRunLockFenced,
|
|
27
|
+
reopenSettle: reopenSettleFenced,
|
|
28
|
+
syncStreamFile: syncStreamFileFenced,
|
|
29
|
+
writeAtomicDurableFile: writeAtomicFenced,
|
|
30
|
+
writeStreamLines: writeStreamLinesFenced
|
|
31
|
+
};
|
|
32
|
+
function perform(operation) {
|
|
33
|
+
const run = OPERATIONS[operation.name];
|
|
34
|
+
if (run === void 0) throw new Error(`durable writer has no operation named ${operation.name}`);
|
|
35
|
+
return run(...operation.args);
|
|
36
|
+
}
|
|
37
|
+
/** The error's own fields that survive the thread boundary (a lock holder, a path). */
|
|
38
|
+
function cloneableFields(error) {
|
|
39
|
+
const fields = {};
|
|
40
|
+
for (const [key, value] of Object.entries(error)) {
|
|
41
|
+
if ([
|
|
42
|
+
"message",
|
|
43
|
+
"name",
|
|
44
|
+
"stack",
|
|
45
|
+
"code"
|
|
46
|
+
].includes(key)) continue;
|
|
47
|
+
try {
|
|
48
|
+
fields[key] = structuredClone(value);
|
|
49
|
+
} catch {}
|
|
50
|
+
}
|
|
51
|
+
return fields;
|
|
52
|
+
}
|
|
53
|
+
becomeDurableWriter(perform);
|
|
54
|
+
const { syncReplies, signal } = workerData;
|
|
55
|
+
parentPort.on("message", (request) => {
|
|
56
|
+
let reply;
|
|
57
|
+
try {
|
|
58
|
+
const value = request.claim === void 0 ? perform(request) : runWithWriteClaim(request.claim, () => perform(request));
|
|
59
|
+
reply = {
|
|
60
|
+
id: request.id,
|
|
61
|
+
ok: true,
|
|
62
|
+
value
|
|
63
|
+
};
|
|
64
|
+
} catch (error) {
|
|
65
|
+
const failure = error instanceof Error ? error : new Error(String(error));
|
|
66
|
+
reply = {
|
|
67
|
+
id: request.id,
|
|
68
|
+
ok: false,
|
|
69
|
+
error: {
|
|
70
|
+
message: failure.message,
|
|
71
|
+
name: failure.name,
|
|
72
|
+
...typeof Reflect.get(failure, "code") === "string" ? { code: Reflect.get(failure, "code") } : {},
|
|
73
|
+
...failure.stack === void 0 ? {} : { stack: failure.stack },
|
|
74
|
+
fields: cloneableFields(failure)
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
if (request.sync) {
|
|
79
|
+
syncReplies.postMessage(reply);
|
|
80
|
+
Atomics.store(signal, 0, 1);
|
|
81
|
+
Atomics.notify(signal, 0);
|
|
82
|
+
} else parentPort.postMessage(reply);
|
|
83
|
+
});
|
|
84
|
+
export {};
|
|
85
|
+
|
|
86
|
+
//# sourceMappingURL=durable-writer-thread.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"durable-writer-thread.js","names":[],"sources":["../src/durable/durable-writer-thread.ts"],"sourcesContent":["/**\n * The durable writer thread's entry (durable-writer.ts): it runs each named operation it receives,\n * in the order received, under the claim the caller held, with the same synchronous fence and\n * fsync the caller's thread used to run. A synchronous caller is answered on its own port and woken\n * through the shared signal; an asynchronous one through the thread's message port.\n *\n * @internal\n */\nimport { type MessagePort, parentPort, workerData } from 'node:worker_threads'\nimport {\n appendDurableFenced,\n appendRunLinesFenced,\n publishExclusiveFenced,\n writeAtomicFenced,\n} from '../runtime/supervise/durable-file'\nimport {\n closeStreamFile,\n openStreamFileFenced,\n syncStreamFileFenced,\n writeStreamLinesFenced,\n} from '../runtime/supervise/root-stream'\nimport {\n becomeDurableWriter,\n type DurableOperation,\n type DurableWriterReply,\n type DurableWriterRequest,\n} from './durable-writer'\nimport { appendCommittedLine } from './jsonl-append'\nimport { prepareJsonlTailFenced } from './jsonl-file'\nimport { runWithWriteClaim } from './run-fence'\nimport { acquireRunLockFenced, releaseRunLockFenced } from './run-lock'\nimport { makeRunDirectoryFenced, reopenSettleFenced } from './run-reopen'\n\n// Every operation a caller may send by name. Each takes its own fence; none takes a callback.\nconst OPERATIONS: Readonly<Record<string, (...args: never[]) => unknown>> = {\n acquireRunLock: acquireRunLockFenced,\n appendCommittedLine,\n appendDurableFile: appendDurableFenced,\n appendRunLines: appendRunLinesFenced,\n closeStreamFile,\n makeRunDirectory: makeRunDirectoryFenced,\n openStreamFile: openStreamFileFenced,\n prepareJsonlAppend: prepareJsonlTailFenced,\n publishExclusiveDurableFile: publishExclusiveFenced,\n releaseRunLock: releaseRunLockFenced,\n reopenSettle: reopenSettleFenced,\n syncStreamFile: syncStreamFileFenced,\n writeAtomicDurableFile: writeAtomicFenced,\n writeStreamLines: writeStreamLinesFenced,\n}\n\nfunction perform(operation: DurableOperation): unknown {\n const run = OPERATIONS[operation.name]\n if (run === undefined) throw new Error(`durable writer has no operation named ${operation.name}`)\n return (run as (...args: readonly unknown[]) => unknown)(...operation.args)\n}\n\n/** The error's own fields that survive the thread boundary (a lock holder, a path). */\nfunction cloneableFields(error: Error): Record<string, unknown> {\n const fields: Record<string, unknown> = {}\n for (const [key, value] of Object.entries(error)) {\n if (['message', 'name', 'stack', 'code'].includes(key)) continue\n try {\n fields[key] = structuredClone(value)\n } catch {\n // A field that cannot be cloned stays on this thread.\n }\n }\n return fields\n}\n\nbecomeDurableWriter(perform)\n\nconst { syncReplies, signal } = workerData as { syncReplies: MessagePort; signal: Int32Array }\n\nparentPort!.on('message', (request: DurableWriterRequest) => {\n let reply: DurableWriterReply\n try {\n const value =\n request.claim === undefined\n ? perform(request)\n : runWithWriteClaim(request.claim, () => perform(request))\n reply = { id: request.id, ok: true, value }\n } catch (error) {\n const failure = error instanceof Error ? error : new Error(String(error))\n reply = {\n id: request.id,\n ok: false,\n error: {\n message: failure.message,\n name: failure.name,\n ...(typeof Reflect.get(failure, 'code') === 'string'\n ? { code: Reflect.get(failure, 'code') as string }\n : {}),\n ...(failure.stack === undefined ? {} : { stack: failure.stack }),\n fields: cloneableFields(failure),\n },\n }\n }\n if (request.sync) {\n syncReplies.postMessage(reply)\n Atomics.store(signal, 0, 1)\n Atomics.notify(signal, 0)\n } else parentPort!.postMessage(reply)\n})\n"],"mappings":";;;;;;;;;;;;;;;AAkCA,MAAM,aAAsE;CAC1E,gBAAgB;CAChB;CACA,mBAAmB;CACnB,gBAAgB;CAChB;CACA,kBAAkB;CAClB,gBAAgB;CAChB,oBAAoB;CACpB,6BAA6B;CAC7B,gBAAgB;CAChB,cAAc;CACd,gBAAgB;CAChB,wBAAwB;CACxB,kBAAkB;AACpB;AAEA,SAAS,QAAQ,WAAsC;CACrD,MAAM,MAAM,WAAW,UAAU;CACjC,IAAI,QAAQ,KAAA,GAAW,MAAM,IAAI,MAAM,yCAAyC,UAAU,MAAM;CAChG,OAAQ,IAAiD,GAAG,UAAU,IAAI;AAC5E;;AAGA,SAAS,gBAAgB,OAAuC;CAC9D,MAAM,SAAkC,CAAC;CACzC,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,KAAK,GAAG;EAChD,IAAI;GAAC;GAAW;GAAQ;GAAS;EAAM,CAAC,CAAC,SAAS,GAAG,GAAG;EACxD,IAAI;GACF,OAAO,OAAO,gBAAgB,KAAK;EACrC,QAAQ,CAER;CACF;CACA,OAAO;AACT;AAEA,oBAAoB,OAAO;AAE3B,MAAM,EAAE,aAAa,WAAW;AAEhC,WAAY,GAAG,YAAY,YAAkC;CAC3D,IAAI;CACJ,IAAI;EACF,MAAM,QACJ,QAAQ,UAAU,KAAA,IACd,QAAQ,OAAO,IACf,kBAAkB,QAAQ,aAAa,QAAQ,OAAO,CAAC;EAC7D,QAAQ;GAAE,IAAI,QAAQ;GAAI,IAAI;GAAM;EAAM;CAC5C,SAAS,OAAO;EACd,MAAM,UAAU,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC;EACxE,QAAQ;GACN,IAAI,QAAQ;GACZ,IAAI;GACJ,OAAO;IACL,SAAS,QAAQ;IACjB,MAAM,QAAQ;IACd,GAAI,OAAO,QAAQ,IAAI,SAAS,MAAM,MAAM,WACxC,EAAE,MAAM,QAAQ,IAAI,SAAS,MAAM,EAAY,IAC/C,CAAC;IACL,GAAI,QAAQ,UAAU,KAAA,IAAY,CAAC,IAAI,EAAE,OAAO,QAAQ,MAAM;IAC9D,QAAQ,gBAAgB,OAAO;GACjC;EACF;CACF;CACA,IAAI,QAAQ,MAAM;EAChB,YAAY,YAAY,KAAK;EAC7B,QAAQ,MAAM,QAAQ,GAAG,CAAC;EAC1B,QAAQ,OAAO,QAAQ,CAAC;CAC1B,OAAO,WAAY,YAAY,KAAK;AACtC,CAAC"}
|
package/dist/durable.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $d as
|
|
1
|
+
import { $d as PursuitRunProjection, Ad as NextPursuitVersionInput, Bd as SupervisePursuitOptions, Bp as DeadlineCheckIn, Ca as SupervisedResult, Cm as ManagerWakePolicy, Eb as EscalateQuestion, F as NodeId, Fd as VersionJudge, Gd as PursuitObserverDelivery, Gp as readRunParking, Hb as DownMessageAuthorizationInput, Hd as superviseGraphPursuit, Hp as RunParkedError, Id as VersionVerdict, Jb as MapOnSettleRoute, Jd as PursuitNodePlatform, Jm as CoordinationReadAccess, Kd as PursuitCostProvenance, Ld as assertPursuitVersions, Md as PursuitVersionStop, Nd as PursuitVersions, Od as JudgedPursuitVersion, Pd as SettledPursuitVersion, Qd as PursuitProjection, Qm as CoordinationRejectReason, Rd as SuperviseGraphPursuitOptions, Rx as AnalyzeOnSettleRoute, Sa as RootStreamReceipt, Ud as supervisePursuit, Up as RunParkingPolicy, Vb as ContinuityMode, Vd as SupervisedPursuitResult, Vp as ParkedRun, Wd as RunReopen, Wm as CoordinationAuthentication, Wp as RunParkingRecord, Xd as PursuitNodeTiming, Yd as PursuitNodeProjection, Ym as CoordinationTransportOptions, Zd as PursuitNodeUsage, Zm as CoordinationHttpAudit, a_ as ToolLoopCompactionOptions, af as ObserverRecord, am as readRootStream, cf as PursuitFork, dS as SpawnJournalReadRecord, dp as SeatSelectionInput, ef as PursuitRunTotals, fS as SpawnJournalReadResult, gS as readRunState, hS as RunState, hb as WorkerWatchOptions, hf as AuthorizedSpawnContext, hm as ResolveDriveHarness, if as ObserverJournal, im as RootStreamRecord, jd as PursuitVersionChain, kb as QuestionEscalationOutcome, kd as NextPursuitVersion, lS as SpawnJournalCursor, lf as RUN_FORK_CORRELATION_KEYS, mf as AuthorizedSpawn, nf as projectPursuit, of as ObserverRecordKind, om as readRootStreamReceipt, pS as readSpawnJournal, pm as DriveHarnessOwnerContext, pp as SelectSeat, q as RetainedPendingCause, qd as PursuitNodeCost, qm as CoordinationPublicAddress, rf as FileObserverJournal, rw as LoopTokenUsage, sf as observerRecordDigest, tf as PursuitStatus, uS as SpawnJournalReadOptions, up as SeatSelection, vf as WorkerSlots, zb as AuthorizedDownMessage, zd as SupervisePursuitError } from "./types-PBoTtcbX.js";
|
|
2
2
|
import { n as RuntimeDecisionKind, r as RuntimeDecisionPoint, t as RuntimeDecisionEvidenceRef } from "./runtime-hooks-DPghSHV7.js";
|
|
3
3
|
import { a as ChatTurnProducer, c as handleChatTurn, i as ChatTurnIdentity, n as ChatStreamEvent, o as ChatTurnResult, r as ChatTurnHooks, s as RunChatTurnInput, t as deriveExecutionId } from "./execution-handle-CujvqgCn.js";
|
|
4
4
|
import { AgentProfile } from "@tangle-network/agent-interface";
|
package/dist/durable.js
CHANGED
|
@@ -1,28 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Fn as observerRecordDigest, J as FileSpawnJournal, Nn as FileObserverJournal, Nr as authoredProfileDigest, Pn as createFileObserverHooks, l as readRootStream, sn as loadSpawnForest, u as readRootStreamReceipt, w as supervisorRunDir } from "./supervisor-accounting-Cuehs4te.js";
|
|
2
|
+
import { r as RunParkedError, s as readRunParking } from "./supervisor-BtRRFbgF.js";
|
|
3
3
|
import { n as handleChatTurn, t as deriveExecutionId } from "./execution-handle-Bd2_nUB6.js";
|
|
4
|
-
import { n as projectPursuit, t as discoverDurableSupervisionRun } from "./supervision-discovery-
|
|
4
|
+
import { n as projectPursuit, t as discoverDurableSupervisionRun } from "./supervision-discovery-CAUsSDno.js";
|
|
5
5
|
import { a as applyExactAgentProfileDiff } from "./profile-Cxl_Ajl2.js";
|
|
6
6
|
import { f as RuntimeRunStateError, m as ValidationError } from "./errors-DG8yufqX.js";
|
|
7
|
-
import { o as failedItems, s as isFiniteNumber } from "./continuation-
|
|
7
|
+
import { o as failedItems, s as isFiniteNumber } from "./continuation-BDeKJgV3.js";
|
|
8
8
|
import { c as errorMessage } from "./util-qsH5cC9S.js";
|
|
9
|
-
import { t as isNoEntError } from "./jsonl-file-
|
|
10
|
-
import { a as readFailureRecord, c as writeFailureRecord, i as parseSettleRecord, l as writeSettleRecord, n as SETTLE_RECORD_FILE, o as readSettleRecord, r as SettledRunDirectoryError,
|
|
11
|
-
import { l as rootStreamToolSpans, s as ASSISTANT_REASONING_SPAN, t as supervise, u as runToolSpans, v as superviseRootProfile } from "./supervise-
|
|
12
|
-
import { M as contentAddress, n as runtimeFailureCause
|
|
13
|
-
import { a as
|
|
9
|
+
import { t as isNoEntError } from "./jsonl-file-CVAWegN-.js";
|
|
10
|
+
import { a as readFailureRecord, c as writeFailureRecord, i as parseSettleRecord, l as writeSettleRecord, n as SETTLE_RECORD_FILE, o as readSettleRecord, r as SettledRunDirectoryError, t as FAILURE_RECORD_FILE } from "./settle-record-Beh-sXBW.js";
|
|
11
|
+
import { l as rootStreamToolSpans, s as ASSISTANT_REASONING_SPAN, t as supervise, u as runToolSpans, v as superviseRootProfile } from "./supervise-DTUYxnoJ.js";
|
|
12
|
+
import { M as contentAddress, n as runtimeFailureCause } from "./failure-cause-DoCCGLDH.js";
|
|
13
|
+
import { a as readRunDirectoryLock, n as RunDirectoryLockedError, r as acquireRunDirectoryLock, s as runDirectoryHolderIsLive, t as RUN_DIRECTORY_LOCK_FILE } from "./run-lock-Y3u9kwM0.js";
|
|
14
14
|
import { u as defaultRedactor } from "./snapshot-BKI_w3JD.js";
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
15
|
+
import { t as FileResultBlobStore } from "./result-blob-store-BR-BVZrg.js";
|
|
16
|
+
import { n as readSpawnJournal, t as readRunState } from "./run-state-DgKo8_tO.js";
|
|
17
|
+
import { s as rootCoordinationOwner, u as FileCoordinationLog } from "./supervise-identity-eMF-h1uP.js";
|
|
18
|
+
import { i as superviseAgentGraph, s as graphExecutionOptions } from "./graph-4ep9laIH.js";
|
|
17
19
|
import { a as withPursuitContext, t as composeRuntimeHooks } from "./runtime-hooks-CsW2pfFk.js";
|
|
18
|
-
import { i as
|
|
20
|
+
import { i as reopenSettledRun, t as assertRunReopen } from "./run-reopen-CHYTHk7x.js";
|
|
19
21
|
import { agentProfileSchema, canonicalAgentProfileDigest, canonicalCandidateDigest, sha256Bytes } from "@tangle-network/agent-interface";
|
|
20
|
-
import { existsSync, mkdirSync, readFileSync, readdirSync, renameSync, unlinkSync } from "node:fs";
|
|
21
22
|
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
22
23
|
import { access, readFile, realpath } from "node:fs/promises";
|
|
23
24
|
import { stripVTControlCharacters } from "node:util";
|
|
24
|
-
import { SearchRecorder, developmentClaim, incumbent, openSearchLedger, parseSearchLedgerLine, runSearch, uniform } from "@tangle-network/agent-eval/campaign";
|
|
25
25
|
import { pathToFileURL } from "node:url";
|
|
26
|
+
import { SearchRecorder, developmentClaim, incumbent, openSearchLedger, parseSearchLedgerLine, runSearch, uniform } from "@tangle-network/agent-eval/campaign";
|
|
26
27
|
// src/durable/pursuit-version-evidence.ts
|
|
27
28
|
/** The chain's directory beside the first version's: the ledger and its content blobs. */
|
|
28
29
|
function pursuitVersionsLedgerPath(runDir) {
|
|
@@ -1372,120 +1373,6 @@ function startPursuitObserverDelivery(delivery, read, warn = (message) => consol
|
|
|
1372
1373
|
}
|
|
1373
1374
|
};
|
|
1374
1375
|
}
|
|
1375
|
-
// src/durable/run-reopen.ts
|
|
1376
|
-
/** The directory that holds a run's archived settle records. */
|
|
1377
|
-
const SETTLE_ARCHIVE_DIR = "settles";
|
|
1378
|
-
/** Refuse a reopen that names no operator or reason, or that is combined with a fork or versions. */
|
|
1379
|
-
function assertRunReopen(reopen, opts) {
|
|
1380
|
-
if (reopen.operator.trim().length === 0) throw new TypeError("supervisePursuit: reopen.operator must be non-empty");
|
|
1381
|
-
if (reopen.reason.trim().length === 0) throw new TypeError("supervisePursuit: reopen.reason must be non-empty");
|
|
1382
|
-
if (reopen.operationId.trim().length === 0) throw new TypeError("supervisePursuit: reopen.operationId must be non-empty");
|
|
1383
|
-
if (reopen.budget !== void 0) assertValidBudget(reopen.budget, "reopen.budget");
|
|
1384
|
-
if (opts.fork !== void 0 || opts.versions !== void 0) throw new TypeError("supervisePursuit: reopen continues this run under its own id; fork and versions start new runs");
|
|
1385
|
-
}
|
|
1386
|
-
/**
|
|
1387
|
-
* Archive the settled segment of the run at `runDir` and clear it for a resume. Runs under the
|
|
1388
|
-
* directory lock. Throws when there is nothing to reopen, or when `operationId` already reopened a
|
|
1389
|
-
* segment that has since settled again.
|
|
1390
|
-
*/
|
|
1391
|
-
async function reopenSettledRun(input) {
|
|
1392
|
-
const { runDir, runId, reopen, observer, pursuitId, now } = input;
|
|
1393
|
-
const operationId = reopen.operationId.trim();
|
|
1394
|
-
const settlePath = resolve(runDir, SETTLE_RECORD_FILE);
|
|
1395
|
-
const journal = input.journal ?? new FileSpawnJournal(resolve(runDir, "spawn-journal.jsonl"));
|
|
1396
|
-
const events = await journal.loadTree(runId) ?? [];
|
|
1397
|
-
const reopened = events.filter((event) => event.kind === "reopened" && event.id === runId);
|
|
1398
|
-
const mine = reopened.find((event) => event.operationId === operationId);
|
|
1399
|
-
const settled = await readBytes(settlePath);
|
|
1400
|
-
if (settled === void 0) {
|
|
1401
|
-
if (mine !== void 0) return;
|
|
1402
|
-
throw new Error(`supervisePursuit: ${runDir} holds no ${SETTLE_RECORD_FILE}; nothing to reopen; resume it`);
|
|
1403
|
-
}
|
|
1404
|
-
assertResumeLimits(events, {
|
|
1405
|
-
runId,
|
|
1406
|
-
budget: reopen.budget ?? input.limits.budget,
|
|
1407
|
-
...input.limits.reservationPolicy === void 0 ? {} : { reservationPolicy: input.limits.reservationPolicy }
|
|
1408
|
-
}, mine === void 0 ? reopen.budget : void 0);
|
|
1409
|
-
const result = JSON.parse(settled);
|
|
1410
|
-
const digest = settleRecordDigest(result);
|
|
1411
|
-
if (mine !== void 0 && mine.prior.digest !== digest) throw new Error(`supervisePursuit: reopen '${operationId}' already reopened run '${runId}', which has settled again; reopen it under a new operationId`);
|
|
1412
|
-
const archivedAs = mine?.prior.archivedAs ?? await archiveName(runDir, settled);
|
|
1413
|
-
const archivePath = resolve(runDir, archivedAs);
|
|
1414
|
-
if (!publishExclusiveDurableFile(archivePath, settled) && await readBytes(archivePath) !== settled) throw new Error(`supervisePursuit: ${archivePath} already holds a different settle record; reopen refused`);
|
|
1415
|
-
const at = new Date(now()).toISOString();
|
|
1416
|
-
if (mine === void 0) await journal.appendEvent(runId, {
|
|
1417
|
-
kind: "reopened",
|
|
1418
|
-
id: runId,
|
|
1419
|
-
operator: reopen.operator,
|
|
1420
|
-
reason: reopen.reason,
|
|
1421
|
-
operationId,
|
|
1422
|
-
prior: {
|
|
1423
|
-
kind: String(result.kind),
|
|
1424
|
-
...typeof result.reason === "string" ? { reason: result.reason } : {},
|
|
1425
|
-
digest,
|
|
1426
|
-
archivedAs
|
|
1427
|
-
},
|
|
1428
|
-
...reopen.budget === void 0 ? {} : { budget: reopen.budget },
|
|
1429
|
-
seq: reopened.length,
|
|
1430
|
-
at
|
|
1431
|
-
});
|
|
1432
|
-
const eventId = `${runId}:pursuit:reopened:${operationId}`;
|
|
1433
|
-
if (!(await observer.read()).some((record) => record.event?.id === eventId)) await observer.appendEvent({
|
|
1434
|
-
id: eventId,
|
|
1435
|
-
pursuitId,
|
|
1436
|
-
runId,
|
|
1437
|
-
target: "agent.run",
|
|
1438
|
-
phase: "event",
|
|
1439
|
-
timestamp: now(),
|
|
1440
|
-
payload: { reopened: {
|
|
1441
|
-
operator: reopen.operator,
|
|
1442
|
-
reason: reopen.reason,
|
|
1443
|
-
archivedAs
|
|
1444
|
-
} }
|
|
1445
|
-
});
|
|
1446
|
-
fenceRunWrite(() => {
|
|
1447
|
-
setCancellationAside(runDir, operationId);
|
|
1448
|
-
unlinkSync(settlePath);
|
|
1449
|
-
syncDurableDirectory(runDir);
|
|
1450
|
-
});
|
|
1451
|
-
}
|
|
1452
|
-
/** The next free `settles/<n>.json`, or the archive that already holds these bytes (a reopen that
|
|
1453
|
-
* crashed after archiving and before its journal row). */
|
|
1454
|
-
async function archiveName(runDir, settled) {
|
|
1455
|
-
const dir = resolve(runDir, SETTLE_ARCHIVE_DIR);
|
|
1456
|
-
fenceRunWrite(() => mkdirSync(dir, { recursive: true }));
|
|
1457
|
-
const numbers = readdirSync(dir).map((name) => /^(\d+)\.json$/u.exec(name)?.[1]).filter((n) => n !== void 0).map(Number).sort((a, b) => a - b);
|
|
1458
|
-
for (const n of numbers) if (await readBytes(join(dir, `${n}.json`)) === settled) return `${SETTLE_ARCHIVE_DIR}/${n}.json`;
|
|
1459
|
-
return `${SETTLE_ARCHIVE_DIR}/${(numbers.at(-1) ?? 0) + 1}.json`;
|
|
1460
|
-
}
|
|
1461
|
-
/** Move the settled run's cancel request and acknowledgement aside under the reopen's and the
|
|
1462
|
-
* request's operation ids, so the reopened run accepts a new `cancelRun`. Idempotent: an absent
|
|
1463
|
-
* file is skipped. A reopen's operation id names one segment, so a later segment cancelled under
|
|
1464
|
-
* the same cancel operation id lands beside this one instead of over it. */
|
|
1465
|
-
function setCancellationAside(runDir, reopenOperationId) {
|
|
1466
|
-
const requestFile = runCancelRequestFile(runDir);
|
|
1467
|
-
const ackFile = runCancellationFile(runDir);
|
|
1468
|
-
if (!existsSync(requestFile) && !existsSync(ackFile)) return;
|
|
1469
|
-
const source = existsSync(requestFile) ? requestFile : ackFile;
|
|
1470
|
-
const { operationId } = JSON.parse(readFileSync(source, "utf8"));
|
|
1471
|
-
const reopenedDir = join(workerCancellationsDir(runDir), "reopened");
|
|
1472
|
-
const aside = join(reopenedDir, encodeURIComponent(reopenOperationId), encodeURIComponent(operationId));
|
|
1473
|
-
mkdirSync(aside, { recursive: true });
|
|
1474
|
-
if (existsSync(ackFile)) renameSync(ackFile, join(aside, "run.json"));
|
|
1475
|
-
if (existsSync(requestFile)) renameSync(requestFile, join(aside, "run.request.json"));
|
|
1476
|
-
syncDurableDirectory(aside);
|
|
1477
|
-
syncDurableDirectory(join(reopenedDir, encodeURIComponent(reopenOperationId)));
|
|
1478
|
-
syncDurableDirectory(reopenedDir);
|
|
1479
|
-
syncDurableDirectory(workerCancellationsDir(runDir));
|
|
1480
|
-
}
|
|
1481
|
-
async function readBytes(path) {
|
|
1482
|
-
try {
|
|
1483
|
-
return await readFile(path, "utf8");
|
|
1484
|
-
} catch (error) {
|
|
1485
|
-
if (error.code === "ENOENT") return void 0;
|
|
1486
|
-
throw error;
|
|
1487
|
-
}
|
|
1488
|
-
}
|
|
1489
1376
|
// src/durable/supervise-pursuit.ts
|
|
1490
1377
|
/** A failed Runtime execution whose complete third-person projection was retained. */
|
|
1491
1378
|
var SupervisePursuitError = class extends Error {
|