@tangle-network/agent-runtime 1.0.0 → 2.0.2

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.
Files changed (96) hide show
  1. package/dist/{activation-CFS31SWI.d.ts → activation-BuK2H7qx.d.ts} +2 -2
  2. package/dist/{activation-BwoSqHCc.js → activation-ZQWz04u8.js} +4 -4
  3. package/dist/{activation-BwoSqHCc.js.map → activation-ZQWz04u8.js.map} +1 -1
  4. package/dist/agent.d.ts +1 -1
  5. package/dist/agent.js +4 -3
  6. package/dist/agent.js.map +1 -1
  7. package/dist/{bundle-DeDkJbsr.js → bundle-PDYNXIEf.js} +2 -2
  8. package/dist/{bundle-DeDkJbsr.js.map → bundle-PDYNXIEf.js.map} +1 -1
  9. package/dist/candidate-execution/index.js +4 -4
  10. package/dist/{coordination-manager-ewBF777W.js → coordination-manager-BZLp9qpE.js} +8 -363
  11. package/dist/coordination-manager-BZLp9qpE.js.map +1 -0
  12. package/dist/coordination-map-routing-CUvwHAtv.js +362 -0
  13. package/dist/coordination-map-routing-CUvwHAtv.js.map +1 -0
  14. package/dist/{delegate-BiuSfwBa.js → delegate-C-MUU6ML.js} +2 -2
  15. package/dist/{delegate-BiuSfwBa.js.map → delegate-C-MUU6ML.js.map} +1 -1
  16. package/dist/durable-file-CksURHlH.js +1 -0
  17. package/dist/durable-file-DstVeHcj.js +228 -0
  18. package/dist/durable-file-DstVeHcj.js.map +1 -0
  19. package/dist/durable.d.ts +1 -1
  20. package/dist/durable.js +10 -8
  21. package/dist/durable.js.map +1 -1
  22. package/dist/{graph-D6FL1xze.js → graph-CM-6CV_K.js} +6 -5
  23. package/dist/{graph-D6FL1xze.js.map → graph-CM-6CV_K.js.map} +1 -1
  24. package/dist/graph-registry-72DlMnUl.js +585 -0
  25. package/dist/graph-registry-72DlMnUl.js.map +1 -0
  26. package/dist/graph-registry-CAX15LO6.js +1 -0
  27. package/dist/{improve-SiKDcz5_.js → improve-BuZ-I8DP.js} +9 -8
  28. package/dist/{improve-SiKDcz5_.js.map → improve-BuZ-I8DP.js.map} +1 -1
  29. package/dist/index.d.ts +3 -3
  30. package/dist/index.js +12 -11
  31. package/dist/index.js.map +1 -1
  32. package/dist/intelligence.d.ts +2 -2
  33. package/dist/intelligence.js +7 -7
  34. package/dist/{journal-store-BJPMUydp.js → journal-store-BpCOCDoO.js} +208 -635
  35. package/dist/journal-store-BpCOCDoO.js.map +1 -0
  36. package/dist/jsonl-file-BBP9Dz9w.js +429 -0
  37. package/dist/jsonl-file-BBP9Dz9w.js.map +1 -0
  38. package/dist/kernel.d.ts +1 -1
  39. package/dist/kernel.js +13 -12
  40. package/dist/{loop-runner-CqlcC0i4.js → loop-runner-BWD6v1rd.js} +2 -2
  41. package/dist/{loop-runner-CqlcC0i4.js.map → loop-runner-BWD6v1rd.js.map} +1 -1
  42. package/dist/{loop-runner-D9rcTNf2.d.ts → loop-runner-BpLTU_J4.d.ts} +2 -2
  43. package/dist/loop-runner-bin.d.ts +1 -1
  44. package/dist/loop-runner-bin.js +1 -1
  45. package/dist/mcp/bin.js +3 -3
  46. package/dist/mcp/index.d.ts +1 -1
  47. package/dist/mcp/index.js +5 -5
  48. package/dist/{prepare-XWwsOh8O.js → prepare-Bv6X2Wnx.js} +4 -4
  49. package/dist/{prepare-XWwsOh8O.js.map → prepare-Bv6X2Wnx.js.map} +1 -1
  50. package/dist/{profile-C01SQZKa.js → profile-Dir2A1_2.js} +2 -2
  51. package/dist/{profile-C01SQZKa.js.map → profile-Dir2A1_2.js.map} +1 -1
  52. package/dist/profiles.d.ts +1 -1
  53. package/dist/{provision-supervisor-DnwR0AyW.js → provision-supervisor-BWEeWag1.js} +8 -6
  54. package/dist/{provision-supervisor-DnwR0AyW.js.map → provision-supervisor-BWEeWag1.js.map} +1 -1
  55. package/dist/{run-cancellation-CoJRKvih.js → run-cancellation-Cpm-BIUu.js} +3 -2
  56. package/dist/{run-cancellation-CoJRKvih.js.map → run-cancellation-Cpm-BIUu.js.map} +1 -1
  57. package/dist/{runtime-DSYZeav8.js → runtime-Cnr3213E.js} +18 -15
  58. package/dist/{runtime-DSYZeav8.js.map → runtime-Cnr3213E.js.map} +1 -1
  59. package/dist/{sandbox-profile-compat-CXjozdWL.js → sandbox-profile-compat-DRiz9kME.js} +2 -2
  60. package/dist/{sandbox-profile-compat-CXjozdWL.js.map → sandbox-profile-compat-DRiz9kME.js.map} +1 -1
  61. package/dist/{search-executor-DcGAOrAh.js → search-executor-__X1VKnU.js} +5 -5
  62. package/dist/{search-executor-DcGAOrAh.js.map → search-executor-__X1VKnU.js.map} +1 -1
  63. package/dist/{server-SrPLb8w0.js → server-CntFSTpW.js} +4 -4
  64. package/dist/{server-SrPLb8w0.js.map → server-CntFSTpW.js.map} +1 -1
  65. package/dist/{structural-rollout-C_lg83-u.js → structural-rollout-s8W19Mws.js} +5 -5
  66. package/dist/{structural-rollout-C_lg83-u.js.map → structural-rollout-s8W19Mws.js.map} +1 -1
  67. package/dist/{supervise-BXw89Ajc.js → supervise-Cl0F57m9.js} +32 -647
  68. package/dist/supervise-Cl0F57m9.js.map +1 -0
  69. package/dist/{supervision-discovery-CewADdEs.js → supervision-discovery-C3t0Xw-T.js} +5 -158
  70. package/dist/supervision-discovery-C3t0Xw-T.js.map +1 -0
  71. package/dist/{supervisor-hHU3ZJnR.js → supervisor-L7u3pQ1j.js} +99 -150
  72. package/dist/supervisor-L7u3pQ1j.js.map +1 -0
  73. package/dist/task-queue-DbpZAp6C.js +49 -0
  74. package/dist/task-queue-DbpZAp6C.js.map +1 -0
  75. package/dist/task-queue.js +1 -49
  76. package/dist/testing.d.ts +1 -1
  77. package/dist/testing.js +13 -13
  78. package/dist/top-web-BXICdHgc.js +1121 -0
  79. package/dist/top-web-BXICdHgc.js.map +1 -0
  80. package/dist/tui/bin.js +4 -3
  81. package/dist/tui/bin.js.map +1 -1
  82. package/dist/tui/index.d.ts +22 -2
  83. package/dist/tui/index.js +3 -3
  84. package/dist/{types-DTHxh4X9.d.ts → types-BfnQq-_k.d.ts} +17 -21
  85. package/dist/{util-ebWMWzY0.js → util-BX20UJ9X.js} +2 -2
  86. package/dist/{util-ebWMWzY0.js.map → util-BX20UJ9X.js.map} +1 -1
  87. package/package.json +10 -10
  88. package/skills/agent-graphs/references/authoring.md +1 -0
  89. package/dist/coordination-manager-ewBF777W.js.map +0 -1
  90. package/dist/journal-store-BJPMUydp.js.map +0 -1
  91. package/dist/supervise-BXw89Ajc.js.map +0 -1
  92. package/dist/supervision-discovery-CewADdEs.js.map +0 -1
  93. package/dist/supervisor-hHU3ZJnR.js.map +0 -1
  94. package/dist/task-queue.js.map +0 -1
  95. package/dist/top-snapshot-DcV7VG4m.js +0 -520
  96. package/dist/top-snapshot-DcV7VG4m.js.map +0 -1
@@ -0,0 +1,228 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import { tryAcquireAtomicFileLock } from "@tangle-network/agent-eval/ledger-core";
3
+ import { closeSync, constants, existsSync, fchmodSync, fstatSync, fsyncSync, linkSync, lstatSync, openSync, readFileSync, renameSync, statSync, unlinkSync, writeFileSync, writeSync } from "node:fs";
4
+ import { dirname, join, relative, resolve } from "node:path";
5
+ import { AsyncLocalStorage } from "node:async_hooks";
6
+ // src/durable/run-fence.ts
7
+ const claims = new AsyncLocalStorage();
8
+ const publications = new AsyncLocalStorage();
9
+ /** Bind asynchronous work, including callbacks, to the generation that admitted it. @internal */
10
+ function runWithWriteClaim(claim, operation) {
11
+ return claims.run(claim, operation);
12
+ }
13
+ /** Capture a store's acquisition once, even when later called from an unrelated emitter. @internal */
14
+ function captureRunWriteContext() {
15
+ let claim = claims.getStore();
16
+ return (operation) => {
17
+ claim ??= claims.getStore();
18
+ return claims.run(claim, operation);
19
+ };
20
+ }
21
+ /** Serialize claim changes and file mutations under the same cross-process guard. @internal */
22
+ function mutateRunClaim(path, operation) {
23
+ const legacyGuard = `${path}.guard`;
24
+ if (existsSync(legacyGuard)) throw new Error(`supervisePursuit: cannot mutate ${path}; inspect ${legacyGuard} and remove it only after confirming no lock mutation is active`);
25
+ const deadline = performance.now() + 5e3;
26
+ const sleeper = new Int32Array(new SharedArrayBuffer(4));
27
+ for (;;) {
28
+ const acquisition = tryAcquireAtomicFileLock({ lockPath: `${path}.mutation` });
29
+ if (acquisition.acquired) try {
30
+ return operation();
31
+ } finally {
32
+ acquisition.lock.release();
33
+ }
34
+ if (performance.now() >= deadline) throw new Error(`run directory mutation is held: ${path}`);
35
+ Atomics.wait(sleeper, 0, 0, 10);
36
+ }
37
+ }
38
+ /**
39
+ * Fence an actual file mutation, not an earlier advisory check. No await occurs between the
40
+ * ownership check and publication, and acquire/release use this same guard. Unclaimed standalone
41
+ * stores retain their existing single-writer contract; pursuit-owned work always carries a claim.
42
+ * @internal
43
+ */
44
+ function fenceRunWrite(operation) {
45
+ const claim = claims.getStore();
46
+ if (claim === void 0) return operation();
47
+ const publication = publications.getStore();
48
+ if (publication?.active && publication.claim.path === claim.path && publication.claim.generation === claim.generation) return operation();
49
+ return mutateRunClaim(claim.path, () => {
50
+ let holder;
51
+ try {
52
+ const fd = openSync(claim.path, "r");
53
+ try {
54
+ const stat = fstatSync(fd, { bigint: true });
55
+ if (stat.dev.toString() !== claim.lock.dev || stat.ino.toString() !== claim.lock.ino || stat.birthtimeNs.toString() !== claim.lock.birthtimeNs) throw new Error("run lock inode changed");
56
+ holder = JSON.parse(readFileSync(fd, "utf8"));
57
+ } finally {
58
+ closeSync(fd);
59
+ }
60
+ } catch (cause) {
61
+ throw new Error(`run directory generation ${claim.generation} lost its claim`, { cause });
62
+ }
63
+ if (holder?.generation !== claim.generation || holder.lock?.dev !== claim.lock.dev || holder.lock?.ino !== claim.lock.ino || holder.lock?.birthtimeNs !== claim.lock.birthtimeNs) throw new Error(`run directory generation ${claim.generation} lost its claim`);
64
+ const publication = {
65
+ claim,
66
+ active: true
67
+ };
68
+ try {
69
+ return publications.run(publication, operation);
70
+ } finally {
71
+ publication.active = false;
72
+ }
73
+ });
74
+ }
75
+ /** Persistent generation counter survives a clean release of supervise.lock. @internal */
76
+ function runGenerationPath(runDir) {
77
+ return resolve(runDir, "supervise.generation");
78
+ }
79
+ // src/runtime/supervise/durable-file.ts
80
+ /**
81
+ * Small filesystem durability primitives for Runtime-owned state.
82
+ *
83
+ * Callers must validate their path and parent directory before invoking these functions.
84
+ * The exclusive writer protects a no-clobber publication race; the atomic writer replaces one
85
+ * state file after its temporary contents reach stable storage.
86
+ *
87
+ * @internal
88
+ */
89
+ /**
90
+ * Publish a new file without replacing a concurrent winner. The published entry is a hard link
91
+ * of the temporary file, so a content function sees the published file's inode.
92
+ */
93
+ function publishExclusiveDurableFile(filePath, content, options = {}) {
94
+ return fenceRunWrite(() => publishExclusiveDurableFileUnchecked(filePath, content, options));
95
+ }
96
+ function publishExclusiveDurableFileUnchecked(filePath, content, options = {}) {
97
+ const temporaryPath = `${filePath}.${randomUUID()}.tmp`;
98
+ let operationFailed = false;
99
+ let operationError;
100
+ let published = false;
101
+ try {
102
+ writeExclusiveDurableFile(temporaryPath, content, options);
103
+ try {
104
+ linkSync(temporaryPath, filePath);
105
+ syncDurableDirectory(dirname(filePath));
106
+ published = true;
107
+ } catch (error) {
108
+ if (!isAlreadyExistsError(error)) throw error;
109
+ }
110
+ } catch (error) {
111
+ operationFailed = true;
112
+ operationError = error;
113
+ }
114
+ let cleanupError;
115
+ try {
116
+ unlinkSync(temporaryPath);
117
+ } catch (error) {
118
+ if (!isNoEntryError(error)) cleanupError = error;
119
+ }
120
+ if (operationFailed) throw operationError;
121
+ if (cleanupError !== void 0) throw cleanupError;
122
+ return published;
123
+ }
124
+ /** Fsync a directory after publishing a durable file entry. */
125
+ function syncDurableDirectory(directoryPath) {
126
+ const fd = openSync(directoryPath, "r");
127
+ try {
128
+ fsyncSync(fd);
129
+ } finally {
130
+ closeSync(fd);
131
+ }
132
+ }
133
+ /** Fsync one durable file after its contents reach stable storage. */
134
+ function syncDurableFile(filePath, exactMode) {
135
+ const fd = openSync(filePath, "r");
136
+ try {
137
+ if (exactMode !== void 0 && process.platform !== "win32") fchmodSync(fd, exactMode);
138
+ fsyncSync(fd);
139
+ } finally {
140
+ closeSync(fd);
141
+ }
142
+ }
143
+ /** Append one record with O_APPEND, then fsync the file and containing directory. */
144
+ function appendDurableFile(filePath, content, options = {}) {
145
+ fenceRunWrite(() => appendDurableFileUnchecked(filePath, content, options));
146
+ }
147
+ function appendDurableFileUnchecked(filePath, content, options = {}) {
148
+ const flags = constants.O_APPEND | constants.O_CREAT | constants.O_WRONLY | (typeof constants.O_NOFOLLOW === "number" ? constants.O_NOFOLLOW : 0);
149
+ const fd = openSync(filePath, flags, options.mode ?? 384);
150
+ try {
151
+ if (process.platform !== "win32") fchmodSync(fd, options.mode ?? 384);
152
+ const expectedBytes = Buffer.byteLength(content, "utf8");
153
+ const writtenBytes = writeSync(fd, content, void 0, "utf8");
154
+ if (writtenBytes !== expectedBytes) throw new Error(`durable append wrote ${writtenBytes} of ${expectedBytes} bytes to '${filePath}'`);
155
+ fsyncSync(fd);
156
+ } finally {
157
+ closeSync(fd);
158
+ }
159
+ syncDurableDirectory(dirname(filePath));
160
+ }
161
+ /** Reject a path that escapes its run directory or traverses a symbolic link. */
162
+ function assertNoSymlinkDescendant(root, target, label = "path") {
163
+ const base = resolve(root);
164
+ const exact = resolve(target);
165
+ const rel = relative(base, exact);
166
+ if (rel === ".." || rel.startsWith(`..${process.platform === "win32" ? "\\" : "/"}`)) throw new Error(`${label} path escapes its run directory`);
167
+ if (existsSync(base) && lstatSync(base).isSymbolicLink()) throw new Error(`${label} path contains a symbolic link: ${base}`);
168
+ let current = base;
169
+ for (const part of rel.split(/[\\/]/u).filter(Boolean)) {
170
+ current = join(current, part);
171
+ if (!existsSync(current)) continue;
172
+ if (lstatSync(current).isSymbolicLink()) throw new Error(`${label} path contains a symbolic link: ${current}`);
173
+ }
174
+ }
175
+ /** Write, fsync, atomically replace, and fsync one Runtime-owned state file.
176
+ * preserveMode retains ordinary access permissions despite the current umask; a new
177
+ * file keeps normal creation semantics. Callers still own path validation and write exclusion. */
178
+ function writeAtomicDurableFile(filePath, content, options = {}) {
179
+ fenceRunWrite(() => writeAtomicDurableFileUnchecked(filePath, content, options));
180
+ }
181
+ function writeAtomicDurableFileUnchecked(filePath, content, options = {}) {
182
+ const temporaryPath = `${filePath}.${randomUUID()}.tmp`;
183
+ let operationFailed = false;
184
+ let operationError;
185
+ try {
186
+ let mode = options.mode;
187
+ let exactMode = false;
188
+ if (options.preserveMode) try {
189
+ mode = statSync(filePath).mode & 511;
190
+ exactMode = true;
191
+ } catch (error) {
192
+ if (!isNoEntryError(error)) throw error;
193
+ }
194
+ writeExclusiveDurableFile(temporaryPath, content, { mode }, exactMode);
195
+ renameSync(temporaryPath, filePath);
196
+ syncDurableDirectory(dirname(filePath));
197
+ } catch (error) {
198
+ operationFailed = true;
199
+ operationError = error;
200
+ }
201
+ let cleanupError;
202
+ try {
203
+ unlinkSync(temporaryPath);
204
+ } catch (error) {
205
+ if (!isNoEntryError(error)) cleanupError = error;
206
+ }
207
+ if (operationFailed) throw operationError;
208
+ if (cleanupError !== void 0) throw cleanupError;
209
+ }
210
+ function writeExclusiveDurableFile(filePath, content, options, exactMode = false) {
211
+ const fd = openSync(filePath, "wx", options.mode ?? 438);
212
+ try {
213
+ const text = typeof content === "string" ? content : content(fstatSync(fd, { bigint: true }));
214
+ writeFileSync(fd, text, "utf8");
215
+ } finally {
216
+ closeSync(fd);
217
+ }
218
+ syncDurableFile(filePath, exactMode ? options.mode : void 0);
219
+ }
220
+ function isAlreadyExistsError(error) {
221
+ return error !== null && typeof error === "object" && "code" in error && error.code === "EEXIST";
222
+ }
223
+ function isNoEntryError(error) {
224
+ return error !== null && typeof error === "object" && "code" in error && error.code === "ENOENT";
225
+ }
226
+ export { writeAtomicDurableFile as a, mutateRunClaim as c, syncDurableDirectory as i, runGenerationPath as l, assertNoSymlinkDescendant as n, captureRunWriteContext as o, publishExclusiveDurableFile as r, fenceRunWrite as s, appendDurableFile as t, runWithWriteClaim as u };
227
+
228
+ //# sourceMappingURL=durable-file-DstVeHcj.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"durable-file-DstVeHcj.js","names":["fsConstants"],"sources":["../src/durable/run-fence.ts","../src/runtime/supervise/durable-file.ts"],"sourcesContent":["import { AsyncLocalStorage } from 'node:async_hooks'\nimport { closeSync, existsSync, fstatSync, openSync, readFileSync } from 'node:fs'\nimport { resolve } from 'node:path'\nimport { tryAcquireAtomicFileLock } from '@tangle-network/agent-eval/ledger-core'\nimport type { LockIdentity } from '@tangle-network/agent-eval/lock-holder'\n\n/** The immutable claim carried by every write in one directory execution. @internal */\nexport interface RunWriteClaim {\n readonly path: string\n readonly generation: number\n readonly lock: LockIdentity\n}\n\nconst claims = new AsyncLocalStorage<RunWriteClaim | undefined>()\nconst publications = new AsyncLocalStorage<{ readonly claim: RunWriteClaim; active: boolean }>()\n\n/** Bind asynchronous work, including callbacks, to the generation that admitted it. @internal */\nexport function runWithWriteClaim<T>(claim: RunWriteClaim, operation: () => T): T {\n return claims.run(claim, operation)\n}\n\n/** Capture a store's acquisition once, even when later called from an unrelated emitter. @internal */\nexport function captureRunWriteContext(): <T>(operation: () => T) => T {\n let claim = claims.getStore()\n return <T>(operation: () => T): T => {\n claim ??= claims.getStore()\n return claims.run(claim, operation)\n }\n}\n\n/** Serialize claim changes and file mutations under the same cross-process guard. @internal */\nexport function mutateRunClaim<T>(path: string, operation: () => T): T {\n // Old writers use an unowned directory guard. Never race one or guess that it is stale.\n const legacyGuard = `${path}.guard`\n if (existsSync(legacyGuard)) {\n throw new Error(\n `supervisePursuit: cannot mutate ${path}; inspect ${legacyGuard} and remove it only after confirming no lock mutation is active`,\n )\n }\n const deadline = performance.now() + 5_000\n const sleeper = new Int32Array(new SharedArrayBuffer(4))\n for (;;) {\n const acquisition = tryAcquireAtomicFileLock({ lockPath: `${path}.mutation` })\n if (acquisition.acquired) {\n try {\n return operation()\n } finally {\n acquisition.lock.release()\n }\n }\n if (performance.now() >= deadline) throw new Error(`run directory mutation is held: ${path}`)\n Atomics.wait(sleeper, 0, 0, 10)\n }\n}\n\n/**\n * Fence an actual file mutation, not an earlier advisory check. No await occurs between the\n * ownership check and publication, and acquire/release use this same guard. Unclaimed standalone\n * stores retain their existing single-writer contract; pursuit-owned work always carries a claim.\n * @internal\n */\nexport function fenceRunWrite<T>(operation: () => T): T {\n const claim = claims.getStore()\n if (claim === undefined) return operation()\n const publication = publications.getStore()\n if (\n publication?.active &&\n publication.claim.path === claim.path &&\n publication.claim.generation === claim.generation\n )\n return operation()\n return mutateRunClaim(claim.path, () => {\n let holder: Partial<RunWriteClaim> | undefined\n try {\n const fd = openSync(claim.path, 'r')\n try {\n const stat = fstatSync(fd, { bigint: true })\n if (\n stat.dev.toString() !== claim.lock.dev ||\n stat.ino.toString() !== claim.lock.ino ||\n stat.birthtimeNs.toString() !== claim.lock.birthtimeNs\n ) {\n throw new Error('run lock inode changed')\n }\n holder = JSON.parse(readFileSync(fd, 'utf8')) as Partial<RunWriteClaim>\n } finally {\n closeSync(fd)\n }\n } catch (cause) {\n throw new Error(`run directory generation ${claim.generation} lost its claim`, { cause })\n }\n if (\n holder?.generation !== claim.generation ||\n holder.lock?.dev !== claim.lock.dev ||\n holder.lock?.ino !== claim.lock.ino ||\n holder.lock?.birthtimeNs !== claim.lock.birthtimeNs\n ) {\n throw new Error(`run directory generation ${claim.generation} lost its claim`)\n }\n // Nested synchronous primitives share the guard. A callback queued here keeps its claim,\n // but cannot inherit a live guard after this publication has returned.\n const publication = { claim, active: true }\n try {\n return publications.run(publication, operation)\n } finally {\n publication.active = false\n }\n })\n}\n\n/** Persistent generation counter survives a clean release of supervise.lock. @internal */\nexport function runGenerationPath(runDir: string): string {\n return resolve(runDir, 'supervise.generation')\n}\n","/**\n * Small filesystem durability primitives for Runtime-owned state.\n *\n * Callers must validate their path and parent directory before invoking these functions.\n * The exclusive writer protects a no-clobber publication race; the atomic writer replaces one\n * state file after its temporary contents reach stable storage.\n *\n * @internal\n */\n\nimport { randomUUID } from 'node:crypto'\nimport {\n type BigIntStats,\n closeSync,\n existsSync,\n fchmodSync,\n constants as fsConstants,\n fstatSync,\n fsyncSync,\n linkSync,\n lstatSync,\n openSync,\n renameSync,\n statSync,\n unlinkSync,\n writeFileSync,\n writeSync,\n} from 'node:fs'\nimport { dirname, join, relative, resolve } from 'node:path'\nimport { fenceRunWrite } from '../../durable/run-fence'\n\ninterface DurableFileOptions {\n readonly mode?: number\n}\n\n/**\n * File content, or content computed from the new file's own stat when it must name the file's\n * inode (a lock record that later proves it was written for this very file).\n */\ntype DurableFileContent = string | ((file: BigIntStats) => string)\n\n/**\n * Publish a new file without replacing a concurrent winner. The published entry is a hard link\n * of the temporary file, so a content function sees the published file's inode.\n */\nexport function publishExclusiveDurableFile(\n filePath: string,\n content: DurableFileContent,\n options: DurableFileOptions = {},\n): boolean {\n return fenceRunWrite(() => publishExclusiveDurableFileUnchecked(filePath, content, options))\n}\n\nfunction publishExclusiveDurableFileUnchecked(\n filePath: string,\n content: DurableFileContent,\n options: DurableFileOptions = {},\n): boolean {\n const temporaryPath = `${filePath}.${randomUUID()}.tmp`\n let operationFailed = false\n let operationError: unknown\n let published = false\n try {\n writeExclusiveDurableFile(temporaryPath, content, options)\n try {\n linkSync(temporaryPath, filePath)\n syncDurableDirectory(dirname(filePath))\n published = true\n } catch (error) {\n if (!isAlreadyExistsError(error)) throw error\n }\n } catch (error) {\n operationFailed = true\n operationError = error\n }\n let cleanupError: unknown\n try {\n unlinkSync(temporaryPath)\n } catch (error) {\n if (!isNoEntryError(error)) cleanupError = error\n }\n if (operationFailed) throw operationError\n if (cleanupError !== undefined) throw cleanupError\n return published\n}\n\n/** Fsync a directory after publishing a durable file entry. */\nexport function syncDurableDirectory(directoryPath: string): void {\n const fd = openSync(directoryPath, 'r')\n try {\n fsyncSync(fd)\n } finally {\n closeSync(fd)\n }\n}\n\n/** Fsync one durable file after its contents reach stable storage. */\nfunction syncDurableFile(filePath: string, exactMode?: number): void {\n const fd = openSync(filePath, 'r')\n try {\n if (exactMode !== undefined && process.platform !== 'win32') fchmodSync(fd, exactMode)\n fsyncSync(fd)\n } finally {\n closeSync(fd)\n }\n}\n\n/** Append one record with O_APPEND, then fsync the file and containing directory. */\nexport function appendDurableFile(\n filePath: string,\n content: string,\n options: DurableFileOptions = {},\n): void {\n fenceRunWrite(() => appendDurableFileUnchecked(filePath, content, options))\n}\n\nfunction appendDurableFileUnchecked(\n filePath: string,\n content: string,\n options: DurableFileOptions = {},\n): void {\n const flags =\n fsConstants.O_APPEND |\n fsConstants.O_CREAT |\n fsConstants.O_WRONLY |\n (typeof fsConstants.O_NOFOLLOW === 'number' ? fsConstants.O_NOFOLLOW : 0)\n const fd = openSync(filePath, flags, options.mode ?? 0o600)\n try {\n if (process.platform !== 'win32') fchmodSync(fd, options.mode ?? 0o600)\n const expectedBytes = Buffer.byteLength(content, 'utf8')\n const writtenBytes = writeSync(fd, content, undefined, 'utf8')\n if (writtenBytes !== expectedBytes) {\n throw new Error(\n `durable append wrote ${writtenBytes} of ${expectedBytes} bytes to '${filePath}'`,\n )\n }\n fsyncSync(fd)\n } finally {\n closeSync(fd)\n }\n syncDurableDirectory(dirname(filePath))\n}\n\n/** Reject a path that escapes its run directory or traverses a symbolic link. */\nexport function assertNoSymlinkDescendant(root: string, target: string, label = 'path'): void {\n const base = resolve(root)\n const exact = resolve(target)\n const rel = relative(base, exact)\n if (rel === '..' || rel.startsWith(`..${process.platform === 'win32' ? '\\\\' : '/'}`)) {\n throw new Error(`${label} path escapes its run directory`)\n }\n if (existsSync(base) && lstatSync(base).isSymbolicLink()) {\n throw new Error(`${label} path contains a symbolic link: ${base}`)\n }\n let current = base\n for (const part of rel.split(/[\\\\/]/u).filter(Boolean)) {\n current = join(current, part)\n if (!existsSync(current)) continue\n if (lstatSync(current).isSymbolicLink()) {\n throw new Error(`${label} path contains a symbolic link: ${current}`)\n }\n }\n}\n\n/** Write, fsync, atomically replace, and fsync one Runtime-owned state file.\n * preserveMode retains ordinary access permissions despite the current umask; a new\n * file keeps normal creation semantics. Callers still own path validation and write exclusion. */\nexport function writeAtomicDurableFile(\n filePath: string,\n content: string,\n options: DurableFileOptions & { readonly preserveMode?: boolean } = {},\n): void {\n fenceRunWrite(() => writeAtomicDurableFileUnchecked(filePath, content, options))\n}\n\nfunction writeAtomicDurableFileUnchecked(\n filePath: string,\n content: string,\n options: DurableFileOptions & { readonly preserveMode?: boolean } = {},\n): void {\n const temporaryPath = `${filePath}.${randomUUID()}.tmp`\n let operationFailed = false\n let operationError: unknown\n try {\n let mode = options.mode\n let exactMode = false\n if (options.preserveMode) {\n try {\n mode = statSync(filePath).mode & 0o777\n exactMode = true\n } catch (error) {\n if (!isNoEntryError(error)) throw error\n }\n }\n writeExclusiveDurableFile(temporaryPath, content, { mode }, exactMode)\n renameSync(temporaryPath, filePath)\n syncDurableDirectory(dirname(filePath))\n } catch (error) {\n operationFailed = true\n operationError = error\n }\n let cleanupError: unknown\n try {\n unlinkSync(temporaryPath)\n } catch (error) {\n if (!isNoEntryError(error)) cleanupError = error\n // A successful rename removes the temporary directory entry.\n }\n if (operationFailed) throw operationError\n if (cleanupError !== undefined) throw cleanupError\n}\n\nfunction writeExclusiveDurableFile(\n filePath: string,\n content: DurableFileContent,\n options: DurableFileOptions,\n exactMode = false,\n): void {\n const fd = openSync(filePath, 'wx', options.mode ?? 0o666)\n try {\n const text = typeof content === 'string' ? content : content(fstatSync(fd, { bigint: true }))\n writeFileSync(fd, text, 'utf8')\n } finally {\n closeSync(fd)\n }\n syncDurableFile(filePath, exactMode ? options.mode : undefined)\n}\n\nfunction isAlreadyExistsError(error: unknown): boolean {\n return (\n error !== null &&\n typeof error === 'object' &&\n 'code' in error &&\n (error as { code?: unknown }).code === 'EEXIST'\n )\n}\n\nfunction isNoEntryError(error: unknown): boolean {\n return (\n error !== null &&\n typeof error === 'object' &&\n 'code' in error &&\n (error as { code?: unknown }).code === 'ENOENT'\n )\n}\n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;CACA,IAAI;CACJ,IAAI;EACF,WAAW,aAAa;CAC1B,SAAS,OAAO;EACd,IAAI,CAAC,eAAe,KAAK,GAAG,eAAe;CAE7C;CACA,IAAI,iBAAiB,MAAM;CAC3B,IAAI,iBAAiB,KAAA,GAAW,MAAM;AACxC;AAEA,SAAS,0BACP,UACA,SACA,SACA,YAAY,OACN;CACN,MAAM,KAAK,SAAS,UAAU,MAAM,QAAQ,QAAQ,GAAK;CACzD,IAAI;EACF,MAAM,OAAO,OAAO,YAAY,WAAW,UAAU,QAAQ,UAAU,IAAI,EAAE,QAAQ,KAAK,CAAC,CAAC;EAC5F,cAAc,IAAI,MAAM,MAAM;CAChC,UAAU;EACR,UAAU,EAAE;CACd;CACA,gBAAgB,UAAU,YAAY,QAAQ,OAAO,KAAA,CAAS;AAChE;AAEA,SAAS,qBAAqB,OAAyB;CACrD,OACE,UAAU,QACV,OAAO,UAAU,YACjB,UAAU,SACT,MAA6B,SAAS;AAE3C;AAEA,SAAS,eAAe,OAAyB;CAC/C,OACE,UAAU,QACV,OAAO,UAAU,YACjB,UAAU,SACT,MAA6B,SAAS;AAE3C"}
package/dist/durable.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { $d as SeatSelectionInput, $u as observerRecordDigest, Ad as RUN_FORK_CORRELATION_KEYS, Au as SuperviseGraphPursuitOptions, Bu as PursuitNodePlatform, Cu as PursuitVersionChain, D as RetainedPendingCause, Dp as CoordinationPublicAddress, Du as VersionJudge, Eh as ToolLoopCompactionOptions, Eu as SettledPursuitVersion, Fd as AuthorizedSpawn, Ff as readRootStream, Fu as supervisePursuit, Gu as PursuitRunProjection, Hf as DriveHarnessOwnerContext, Hu as PursuitNodeTiming, Id as AuthorizedSpawnContext, If as readRootStreamReceipt, Iu as RunReopen, Ju as projectPursuit, Ku as PursuitRunTotals, Lu as PursuitObserverDelivery, Mp as CoordinationRejectReason, Mu as SupervisePursuitOptions, Nu as SupervisedPursuitResult, Op as CoordinationReadAccess, Ou as VersionVerdict, Pf as RootStreamRecord, Pu as superviseGraphPursuit, Qd as SeatSelection, Qf as ManagerWakePolicy, Qu as ObserverRecordKind, Qv as QuestionEscalationOutcome, Ru as PursuitCostProvenance, Su as NextPursuitVersionInput, Tu as PursuitVersions, Uu as PursuitNodeUsage, V as NodeId, Vu as PursuitNodeProjection, Wf as ResolveDriveHarness, Wu as PursuitProjection, Xu as ObserverJournal, Yu as FileObserverJournal, Yv as EscalateQuestion, Zu as ObserverRecord, _f as ParkedRun, _y as MapOnSettleRoute, bf as RunParkingRecord, bu as JudgedPursuitVersion, cy as AuthorizedDownMessage, dy as DownMessageAuthorizationInput, gf as DeadlineCheckIn, it as SupervisedResult, jp as CoordinationHttpAudit, ju as SupervisePursuitError, kd as PursuitFork, kp as CoordinationTransportOptions, ku as assertPursuitVersions, qu as PursuitStatus, rb as AnalyzeOnSettleRoute, rt as RootStreamReceipt, tf as SelectSeat, uy as ContinuityMode, vf as RunParkedError, wp as CoordinationAuthentication, wu as PursuitVersionStop, xf as readRunParking, xu as NextPursuitVersion, yf as RunParkingPolicy, zd as WorkerSlots, zu as PursuitNodeCost, zv as WorkerWatchOptions } from "./types-DTHxh4X9.js";
1
+ import { $d as SeatSelectionInput, $u as observerRecordDigest, Ad as RUN_FORK_CORRELATION_KEYS, Au as SuperviseGraphPursuitOptions, Bu as PursuitNodePlatform, Cu as PursuitVersionChain, D as RetainedPendingCause, Dp as CoordinationPublicAddress, Du as VersionJudge, Eh as ToolLoopCompactionOptions, Eu as SettledPursuitVersion, Fd as AuthorizedSpawn, Ff as readRootStream, Fu as supervisePursuit, Gu as PursuitRunProjection, Hf as DriveHarnessOwnerContext, Hu as PursuitNodeTiming, Id as AuthorizedSpawnContext, If as readRootStreamReceipt, Iu as RunReopen, Ju as projectPursuit, Ku as PursuitRunTotals, Lu as PursuitObserverDelivery, Mp as CoordinationRejectReason, Mu as SupervisePursuitOptions, Nu as SupervisedPursuitResult, Op as CoordinationReadAccess, Ou as VersionVerdict, Pf as RootStreamRecord, Pu as superviseGraphPursuit, Qd as SeatSelection, Qf as ManagerWakePolicy, Qu as ObserverRecordKind, Qv as QuestionEscalationOutcome, Ru as PursuitCostProvenance, Su as NextPursuitVersionInput, Tu as PursuitVersions, Uu as PursuitNodeUsage, V as NodeId, Vu as PursuitNodeProjection, Wf as ResolveDriveHarness, Wu as PursuitProjection, Xu as ObserverJournal, Yu as FileObserverJournal, Yv as EscalateQuestion, Zu as ObserverRecord, _f as ParkedRun, _y as MapOnSettleRoute, bf as RunParkingRecord, bu as JudgedPursuitVersion, cy as AuthorizedDownMessage, dy as DownMessageAuthorizationInput, gf as DeadlineCheckIn, it as SupervisedResult, jp as CoordinationHttpAudit, ju as SupervisePursuitError, kd as PursuitFork, kp as CoordinationTransportOptions, ku as assertPursuitVersions, qu as PursuitStatus, rb as AnalyzeOnSettleRoute, rt as RootStreamReceipt, tf as SelectSeat, uy as ContinuityMode, vf as RunParkedError, wp as CoordinationAuthentication, wu as PursuitVersionStop, xf as readRunParking, xu as NextPursuitVersion, yf as RunParkingPolicy, zd as WorkerSlots, zu as PursuitNodeCost, zv as WorkerWatchOptions } from "./types-BfnQq-_k.js";
2
2
  import { n as RuntimeDecisionKind, r as RuntimeDecisionPoint, t as RuntimeDecisionEvidenceRef } from "./runtime-hooks-ZQqPw-0g.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 { LockIdentity } from "@tangle-network/agent-eval/lock-holder";
package/dist/durable.js CHANGED
@@ -1,14 +1,16 @@
1
- import { C as runGenerationPath, D as runtimeFailureCause, S as mutateRunClaim, Tt as assertValidBudget, _ as publishExclusiveDurableFile, a as isNoEntError, rt as contentAddress, t as FileSpawnJournal, v as syncDurableDirectory, w as runWithWriteClaim, x as fenceRunWrite, y as writeAtomicDurableFile } from "./journal-store-BJPMUydp.js";
2
- import { Jr as authoredProfileDigest, i as RunParkedError, lr as failedItems, pt as loadSpawnForest, r as assertResumeLimits, s as readRunParking, ur as isFiniteNumber } from "./supervisor-hHU3ZJnR.js";
1
+ import { cr as failedItems, i as RunParkedError, lr as isFiniteNumber, pt as loadSpawnForest, qr as authoredProfileDigest, r as assertResumeLimits, s as readRunParking } from "./supervisor-L7u3pQ1j.js";
3
2
  import { f as RuntimeRunStateError, m as ValidationError } from "./errors-AzSuGI23.js";
4
- import { c as errorMessage } from "./util-ebWMWzY0.js";
3
+ import { c as errorMessage } from "./util-BX20UJ9X.js";
4
+ import { H as contentAddress, d as createFileObserverHooks, f as observerRecordDigest, h as runtimeFailureCause, nt as assertValidBudget, t as FileSpawnJournal, u as FileObserverJournal } from "./journal-store-BpCOCDoO.js";
5
+ import { n as isNoEntError } from "./jsonl-file-BBP9Dz9w.js";
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";
5
7
  import { a as withPursuitContext, t as composeRuntimeHooks } from "./runtime-hooks-CsW2pfFk.js";
6
- import { a as applyExactAgentProfileDiff } from "./profile-C01SQZKa.js";
7
- import { a as superviseRootProfile, gt as readRootStreamReceipt, ht as readRootStream, t as supervise } from "./supervise-BXw89Ajc.js";
8
- import { a as runCancelRequestFile, o as runCancellationFile, v as supervisorRunDir, x as workerCancellationsDir } from "./run-cancellation-CoJRKvih.js";
9
- import { a as graphExecutionOptions, i as superviseAgentGraph } from "./graph-D6FL1xze.js";
8
+ import { a as applyExactAgentProfileDiff } from "./profile-Dir2A1_2.js";
9
+ import { J as readRootStreamReceipt, a as superviseRootProfile, q as readRootStream, t as supervise } from "./supervise-Cl0F57m9.js";
10
+ import { a as runCancelRequestFile, o as runCancellationFile, v as supervisorRunDir, x as workerCancellationsDir } from "./run-cancellation-Cpm-BIUu.js";
11
+ import { a as graphExecutionOptions, i as superviseAgentGraph } from "./graph-CM-6CV_K.js";
10
12
  import { n as handleChatTurn, t as deriveExecutionId } from "./execution-handle-Bd2_nUB6.js";
11
- import { a as observerRecordDigest, i as createFileObserverHooks, n as projectPursuit, r as FileObserverJournal, t as discoverDurableSupervisionRun } from "./supervision-discovery-CewADdEs.js";
13
+ import { n as projectPursuit, t as discoverDurableSupervisionRun } from "./supervision-discovery-C3t0Xw-T.js";
12
14
  import { agentProfileSchema, canonicalAgentProfileDigest, canonicalCandidateDigest, canonicalCandidateJson, sha256Bytes } from "@tangle-network/agent-interface";
13
15
  import { closeSync, existsSync, fstatSync, mkdirSync, openSync, readFileSync, readdirSync, renameSync, unlinkSync } from "node:fs";
14
16
  import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";