@tangle-network/agent-runtime 0.350.2 → 0.352.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/dist/{activation-DyiHrTlS.d.ts → activation-BidzGkUQ.d.ts} +2 -2
  2. package/dist/{activation-CfJMyzEs.js → activation-C6zNC2kx.js} +4 -4
  3. package/dist/{activation-CfJMyzEs.js.map → activation-C6zNC2kx.js.map} +1 -1
  4. package/dist/agent.d.ts +1 -1
  5. package/dist/agent.js +3 -3
  6. package/dist/{bundle-Ze8pd07a.js → bundle-DeDkJbsr.js} +2 -2
  7. package/dist/{bundle-Ze8pd07a.js.map → bundle-DeDkJbsr.js.map} +1 -1
  8. package/dist/candidate-execution/index.js +4 -4
  9. package/dist/chat-turn.d.ts +2 -0
  10. package/dist/chat-turn.js +1 -0
  11. package/dist/{coordination-manager-BkVfWlMz.js → coordination-manager-B7QadgrI.js} +4 -4
  12. package/dist/{coordination-manager-BkVfWlMz.js.map → coordination-manager-B7QadgrI.js.map} +1 -1
  13. package/dist/{delegate-DgEie4ad.js → delegate-CoscoyEo.js} +3 -3
  14. package/dist/{delegate-DgEie4ad.js.map → delegate-CoscoyEo.js.map} +1 -1
  15. package/dist/durable.d.ts +7 -130
  16. package/dist/durable.js +24 -952
  17. package/dist/durable.js.map +1 -1
  18. package/dist/{errors-wuhGvpE3.js → errors-AzSuGI23.js} +4 -1
  19. package/dist/errors-AzSuGI23.js.map +1 -0
  20. package/dist/execution-handle-Bd2_nUB6.js +167 -0
  21. package/dist/execution-handle-Bd2_nUB6.js.map +1 -0
  22. package/dist/execution-handle-CujvqgCn.d.ts +130 -0
  23. package/dist/{graph-Cx0FhKSE.js → graph-mojMML8e.js} +7 -6
  24. package/dist/{graph-Cx0FhKSE.js.map → graph-mojMML8e.js.map} +1 -1
  25. package/dist/{improve-i0HU1-aa.js → improve-Dm5ZE8mr.js} +10 -9
  26. package/dist/{improve-i0HU1-aa.js.map → improve-Dm5ZE8mr.js.map} +1 -1
  27. package/dist/index.d.ts +3 -3
  28. package/dist/index.js +13 -11
  29. package/dist/index.js.map +1 -1
  30. package/dist/intelligence.d.ts +2 -2
  31. package/dist/intelligence.js +7 -6
  32. package/dist/intelligence.js.map +1 -1
  33. package/dist/journal-store-BJPMUydp.js +3925 -0
  34. package/dist/journal-store-BJPMUydp.js.map +1 -0
  35. package/dist/kernel.d.ts +1 -1
  36. package/dist/kernel.js +11 -10
  37. package/dist/{loop-runner-BwN9MhdP.js → loop-runner-5cL_vZi0.js} +3 -3
  38. package/dist/{loop-runner-BwN9MhdP.js.map → loop-runner-5cL_vZi0.js.map} +1 -1
  39. package/dist/{loop-runner-DvfOXVx9.d.ts → loop-runner-DyLD-aNb.d.ts} +2 -2
  40. package/dist/loop-runner-bin.d.ts +1 -1
  41. package/dist/loop-runner-bin.js +1 -1
  42. package/dist/mcp/bin.js +4 -4
  43. package/dist/mcp/index.d.ts +1 -1
  44. package/dist/mcp/index.js +8 -8
  45. package/dist/mcp/memory-bin.js +2 -2
  46. package/dist/{model-policy-GSxWwP-b.js → model-policy-C-RGAUW4.js} +2 -2
  47. package/dist/{model-policy-GSxWwP-b.js.map → model-policy-C-RGAUW4.js.map} +1 -1
  48. package/dist/{prepare-DE8TQnLu.js → prepare-XWwsOh8O.js} +4 -3
  49. package/dist/{prepare-DE8TQnLu.js.map → prepare-XWwsOh8O.js.map} +1 -1
  50. package/dist/{profile-CAhZDW2T.js → profile-C01SQZKa.js} +3 -3
  51. package/dist/{profile-CAhZDW2T.js.map → profile-C01SQZKa.js.map} +1 -1
  52. package/dist/profiles.d.ts +1 -1
  53. package/dist/profiles.js +2 -2
  54. package/dist/{provision-supervisor-Bde_FF0R.js → provision-supervisor-D9pO-iPl.js} +7 -7
  55. package/dist/{provision-supervisor-Bde_FF0R.js.map → provision-supervisor-D9pO-iPl.js.map} +1 -1
  56. package/dist/{run-cancellation-BLy_Zz-w.js → run-cancellation-CoJRKvih.js} +2 -2
  57. package/dist/{run-cancellation-BLy_Zz-w.js.map → run-cancellation-CoJRKvih.js.map} +1 -1
  58. package/dist/{runtime-6Ec9sHRe.js → runtime-BJPXHWbc.js} +41 -37
  59. package/dist/{runtime-6Ec9sHRe.js.map → runtime-BJPXHWbc.js.map} +1 -1
  60. package/dist/{sandbox-profile-compat-BxMQ1VXv.js → sandbox-profile-compat-CXjozdWL.js} +4 -623
  61. package/dist/{sandbox-profile-compat-BxMQ1VXv.js.map → sandbox-profile-compat-CXjozdWL.js.map} +1 -1
  62. package/dist/{search-executor-B7g_5Wjl.js → search-executor-CQEHMXoT.js} +7 -5
  63. package/dist/{search-executor-B7g_5Wjl.js.map → search-executor-CQEHMXoT.js.map} +1 -1
  64. package/dist/{server-fvEMwGMQ.js → server-U9NGgudQ.js} +6 -6
  65. package/dist/{server-fvEMwGMQ.js.map → server-U9NGgudQ.js.map} +1 -1
  66. package/dist/{structural-rollout-B86bSixU.js → structural-rollout-wMSxE7bn.js} +7 -5
  67. package/dist/{structural-rollout-B86bSixU.js.map → structural-rollout-wMSxE7bn.js.map} +1 -1
  68. package/dist/{supervise-CaeZcgAW.js → supervise-CNNhX0ab.js} +9 -9
  69. package/dist/{supervise-CaeZcgAW.js.map → supervise-CNNhX0ab.js.map} +1 -1
  70. package/dist/supervision-discovery-CewADdEs.js +772 -0
  71. package/dist/supervision-discovery-CewADdEs.js.map +1 -0
  72. package/dist/{supervisor-C1OePYE-.js → supervisor-rK5Y8en6.js} +105 -3789
  73. package/dist/supervisor-rK5Y8en6.js.map +1 -0
  74. package/dist/testing.d.ts +1 -1
  75. package/dist/testing.js +13 -13
  76. package/dist/{tool-server-CwuYeW_Z.js → tool-server-CZWd_Opp.js} +2 -2
  77. package/dist/{tool-server-CwuYeW_Z.js.map → tool-server-CZWd_Opp.js.map} +1 -1
  78. package/dist/{top-snapshot-ChwpTr7A.js → top-snapshot-DcV7VG4m.js} +178 -161
  79. package/dist/top-snapshot-DcV7VG4m.js.map +1 -0
  80. package/dist/tui/bin.js +45 -74
  81. package/dist/tui/bin.js.map +1 -1
  82. package/dist/tui/index.d.ts +25 -54
  83. package/dist/tui/index.js +2 -2
  84. package/dist/{types-Fowuwdz2.d.ts → types-0uzVKtFW.d.ts} +30 -7
  85. package/dist/util-ebWMWzY0.js +624 -0
  86. package/dist/util-ebWMWzY0.js.map +1 -0
  87. package/dist/workspace-store/index.js +9 -3
  88. package/dist/workspace-store/index.js.map +1 -1
  89. package/package.json +17 -12
  90. package/dist/errors-wuhGvpE3.js.map +0 -1
  91. package/dist/record-events-B2GUgYdz.js +0 -261
  92. package/dist/record-events-B2GUgYdz.js.map +0 -1
  93. package/dist/supervisor-C1OePYE-.js.map +0 -1
  94. package/dist/top-snapshot-ChwpTr7A.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors-wuhGvpE3.js","names":[],"sources":["../src/errors.ts"],"sourcesContent":["/**\n *\n * Error taxonomy for `@tangle-network/agent-runtime`.\n *\n * Public contract: every error this package throws as part of its consumer-\n * facing API either extends `AgentEvalError` (re-exported here for ergonomic\n * `instanceof` checks at the runtime boundary) or extends one of the\n * runtime-specific subclasses below.\n *\n * Internal invariant guards (`throw new Error('this should never happen')`)\n * remain plain `Error` — they are programmer-mistake assertions, not\n * consumer-catchable contract failures.\n *\n * Subclassing strategy: where a runtime-specific failure maps cleanly to an\n * agent-eval code (validation, config, not_found), we re-use the agent-eval\n * subclass. Runtime-only failure modes (session resume against the wrong\n * backend, backend transport errors) get fresh subclasses that still carry an\n * `AgentEvalErrorCode` so cross-package handlers can pattern-match without\n * importing the runtime.\n *\n * @stable\n */\n\nimport { AgentEvalError } from '@tangle-network/agent-eval'\nimport type {\n AgentInteractiveSessionRef,\n AgentInteractiveSessionStart,\n AgentInteractiveSessionStatus,\n} from '@tangle-network/agent-interface'\nimport type {\n RetainedInteractiveAdmission,\n RetainedRunAdmission,\n} from './runtime/retained-run-types'\n\nexport {\n AgentEvalError,\n type AgentEvalErrorCode,\n ConfigError,\n JudgeError,\n NotFoundError,\n ValidationError,\n} from '@tangle-network/agent-eval'\n\n/**\n *\n * Caller asked to resume a session against a backend whose `kind` does not\n * match the session's recorded backend. This is a routing bug — the same\n * session id was reused across two different backend implementations — and\n * is not retryable without picking the right backend.\n *\n * @stable\n */\nexport class SessionMismatchError extends AgentEvalError {\n readonly sessionBackend: string\n readonly requestedBackend: string\n\n constructor(sessionBackend: string, requestedBackend: string, options?: { cause?: unknown }) {\n super(\n 'validation',\n `Cannot resume ${sessionBackend} session with ${requestedBackend} backend`,\n options,\n )\n this.sessionBackend = sessionBackend\n this.requestedBackend = requestedBackend\n }\n}\n\n/**\n *\n * A backend transport call (HTTP, gRPC, sidecar IPC) failed with a non-success\n * status. Distinct from `JudgeError` (which is structural / unrecoverable)\n * because backend failures are sometimes retryable and consumers may want to\n * branch on the upstream status code.\n *\n * @stable\n */\nexport class BackendTransportError extends AgentEvalError {\n readonly backend: string\n readonly status?: number\n /**\n * Router-owned proof that a rejected request never reached a provider.\n *\n * This is intentionally one-sided. An absent value, or any value this\n * package does not understand, remains unknown to Runtime.\n */\n readonly providerDispatch?: 'not_started'\n /**\n * The upstream's own error class when it names one (the bridge's `parse_error`,\n * `not_configured`, a provider's `invalid_request_error`). A class the upstream never\n * retries is a decision about the request, so a retry policy may read it where no\n * status arrived.\n */\n readonly upstreamCode?: string\n /**\n * Truncated upstream response body (≤2 KiB) when available. Diagnostic\n * only — surfaces in `backend_error.error.body` and `final.error.body`\n * so operators can see \"free_tier_limit\", \"invalid_api_key\", etc. without\n * cracking the log line open.\n */\n readonly body?: string\n\n constructor(\n backend: string,\n message: string,\n options?: {\n cause?: unknown\n status?: number\n upstreamCode?: string\n body?: string\n providerDispatch?: 'not_started'\n },\n ) {\n super('config', message, options)\n this.backend = backend\n this.status = options?.status\n this.upstreamCode = options?.upstreamCode\n this.body = options?.body\n this.providerDispatch = options?.providerDispatch\n }\n}\n\n/**\n *\n * A runtime-run lifecycle method was called in an order the state machine does\n * not allow: `persist()` before `complete()`, `complete()` twice, etc.\n *\n * @stable\n */\nexport class RuntimeRunStateError extends AgentEvalError {\n constructor(message: string, options?: { cause?: unknown }) {\n super('validation', message, options)\n }\n}\n\n/**\n *\n * The dynamic-loop planner returned an unusable topology move — the LLM emitted\n * no parseable envelope, an unknown `kind`, or a structurally-invalid move\n * (e.g. a fanout with zero tasks). This is a structural failure of the\n * agent-authored topology, not a config mistake: the planner ran but its output\n * cannot drive the kernel. Carries `validation` so cross-package handlers can\n * pattern-match without importing the runtime. Fail loud — never substitute a\n * default move, or the loop silently runs a topology nobody chose.\n *\n * @stable\n */\nexport class PlannerError extends AgentEvalError {\n constructor(message: string, options?: { cause?: unknown }) {\n super('validation', message, options)\n }\n}\n\n/**\n * The analyst loop could not read or run over a round's trace — e.g. an empty round\n * (no iterations to analyze) or a malformed trace projection. Fail loud: a silent empty\n * store would mask a broken capture path and the driver would steer on nothing.\n */\nexport class AnalystError extends AgentEvalError {\n constructor(message: string, options?: { cause?: unknown }) {\n super('validation', message, options)\n }\n}\n\n/**\n *\n * The caller's `onAdmission` durability hook rejected, so a retained run's\n * admission record is not durable. For a pre-create intent, no provider work\n * has started. For a later record, provider state may already be live and the\n * environment remains available for recovery. Carries `capture_integrity`\n * because the required recovery record was not written.\n *\n * @stable\n */\nabstract class RetainedAdmissionError<\n TAdmission extends RetainedRunAdmission | RetainedInteractiveAdmission,\n> extends AgentEvalError {\n readonly phase: TAdmission['phase']\n /** The exact record the hook failed to persist, for direct recovery. */\n readonly admission: TAdmission\n\n constructor(admission: TAdmission, options?: { cause?: unknown }) {\n const recovery =\n admission.phase === 'intent' || admission.phase === 'interactive_intent'\n ? 'no provider work has started'\n : 'the environment is kept for recovery'\n super(\n 'capture_integrity',\n `retained run admission (${admission.phase}) was not persisted; ${recovery}`,\n options,\n )\n this.phase = admission.phase\n this.admission = admission\n }\n}\n\n/** The caller could not persist one detached-run recovery record. @stable */\nexport class RetainedRunAdmissionError extends RetainedAdmissionError<RetainedRunAdmission> {}\n\n/** The caller could not persist one exact interactive-process recovery record. @stable */\nexport class RetainedInteractiveAdmissionError extends RetainedAdmissionError<RetainedInteractiveAdmission> {}\n\n/**\n * A provider returned a valid interactive reference that does not bind to the\n * exact start request, or returned data that could not be parsed as one.\n *\n * The requested start and any valid provider reference are detached snapshots.\n * Malformed provider data is never copied into the error, so the error remains\n * safe to persist while the environment remains available for orphan cleanup.\n *\n * @stable\n */\nexport class RetainedInteractiveBindingError extends AgentEvalError {\n /** The exact native-process start request sent to the provider. */\n readonly requested: AgentInteractiveSessionStart\n /** The valid provider data, when the provider returned a parseable value. */\n readonly returned: {\n readonly ref?: AgentInteractiveSessionRef\n readonly status?: AgentInteractiveSessionStatus\n }\n\n constructor(\n requested: AgentInteractiveSessionStart,\n returned: RetainedInteractiveBindingError['returned'],\n options?: { cause?: unknown },\n ) {\n super(\n 'backend_integrity',\n 'provider returned interactive data that does not bind to the requested start; the environment is kept for diagnosis and cleanup',\n options,\n )\n this.requested = Object.freeze(requested)\n this.returned = Object.freeze(returned)\n }\n}\n\n/**\n *\n * A retained dispatch answered with coordinates that do not bind to the\n * identity the runtime requested, or failed exact verification. The\n * environment-phase admission is already durable at this point, so its\n * coordinates plus the provider reference carried here are the manual\n * recovery path. The environment is intentionally kept. Carries\n * `backend_integrity` because the provider violated its dispatch contract.\n *\n * @stable\n */\nexport class RetainedRunDispatchBindingError extends AgentEvalError {\n /** The coordinates the runtime sent with the dispatch. */\n readonly requested: {\n readonly provider: string\n readonly environmentId: string\n readonly sessionId: string\n readonly executionId: string\n }\n /** The loose reference the provider actually returned, for triage. */\n readonly returned: {\n readonly id?: string\n readonly provider?: string\n readonly controlRef?: unknown\n }\n\n constructor(\n requested: RetainedRunDispatchBindingError['requested'],\n returned: RetainedRunDispatchBindingError['returned'],\n options?: { cause?: unknown },\n ) {\n super(\n 'backend_integrity',\n 'retained dispatch did not bind to the requested identity; the durable environment admission and the returned reference on this error are the recovery path',\n options,\n )\n this.requested = requested\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AAb,cAAqD,eAAe;;CAElE;;CAEA;CAKA,YACE,WACA,UACA,SACA;EACA,MACE,qBACA,mIACA,OACF;EACA,KAAK,YAAY,OAAO,OAAO,SAAS;EACxC,KAAK,WAAW,OAAO,OAAO,QAAQ;CACxC;AACF;;;;;;;;;;;;AAaA,IAAa,kCAAb,cAAqD,eAAe;;CAElE;;CAOA;CAMA,YACE,WACA,UACA,SACA;EACA,MACE,qBACA,8JACA,OACF;EACA,KAAK,YAAY;EACjB,KAAK,WAAW;CAClB;AACF"}
@@ -1,261 +0,0 @@
1
- import { isRecord } from "@tangle-network/agent-core";
2
- import { createHash, randomUUID } from "node:crypto";
3
- import { tryAcquireAtomicFileLock } from "@tangle-network/agent-eval/ledger-core";
4
- import { closeSync, constants, existsSync, fchmodSync, fstatSync, fsyncSync, linkSync, lstatSync, openSync, readFileSync, renameSync, statSync, unlinkSync, writeFileSync, writeSync } from "node:fs";
5
- import { dirname, join, relative, resolve } from "node:path";
6
- import { AsyncLocalStorage } from "node:async_hooks";
7
- // \0rolldown/runtime.js
8
- var __defProp = Object.defineProperty;
9
- var __exportAll = (all, no_symbols) => {
10
- let target = {};
11
- for (var name in all) __defProp(target, name, {
12
- get: all[name],
13
- enumerable: true
14
- });
15
- if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
16
- return target;
17
- };
18
- // src/content-digest.ts
19
- function sha256(value) {
20
- return createHash("sha256").update(value).digest("hex");
21
- }
22
- // src/durable/run-fence.ts
23
- const claims = new AsyncLocalStorage();
24
- const publications = new AsyncLocalStorage();
25
- /** Bind asynchronous work, including callbacks, to the generation that admitted it. @internal */
26
- function runWithWriteClaim(claim, operation) {
27
- return claims.run(claim, operation);
28
- }
29
- /** Capture a store's acquisition once, even when later called from an unrelated emitter. @internal */
30
- function captureRunWriteContext() {
31
- let claim = claims.getStore();
32
- return (operation) => {
33
- claim ??= claims.getStore();
34
- return claims.run(claim, operation);
35
- };
36
- }
37
- /** Serialize claim changes and file mutations under the same cross-process guard. @internal */
38
- function mutateRunClaim(path, operation) {
39
- const legacyGuard = `${path}.guard`;
40
- if (existsSync(legacyGuard)) throw new Error(`supervisePursuit: cannot mutate ${path}; inspect ${legacyGuard} and remove it only after confirming no lock mutation is active`);
41
- const deadline = performance.now() + 5e3;
42
- const sleeper = new Int32Array(new SharedArrayBuffer(4));
43
- for (;;) {
44
- const acquisition = tryAcquireAtomicFileLock({ lockPath: `${path}.mutation` });
45
- if (acquisition.acquired) try {
46
- return operation();
47
- } finally {
48
- acquisition.lock.release();
49
- }
50
- if (performance.now() >= deadline) throw new Error(`run directory mutation is held: ${path}`);
51
- Atomics.wait(sleeper, 0, 0, 10);
52
- }
53
- }
54
- /**
55
- * Fence an actual file mutation, not an earlier advisory check. No await occurs between the
56
- * ownership check and publication, and acquire/release use this same guard. Unclaimed standalone
57
- * stores retain their existing single-writer contract; pursuit-owned work always carries a claim.
58
- * @internal
59
- */
60
- function fenceRunWrite(operation) {
61
- const claim = claims.getStore();
62
- if (claim === void 0) return operation();
63
- const publication = publications.getStore();
64
- if (publication?.active && publication.claim.path === claim.path && publication.claim.generation === claim.generation) return operation();
65
- return mutateRunClaim(claim.path, () => {
66
- let holder;
67
- try {
68
- const fd = openSync(claim.path, "r");
69
- try {
70
- const stat = fstatSync(fd, { bigint: true });
71
- 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");
72
- holder = JSON.parse(readFileSync(fd, "utf8"));
73
- } finally {
74
- closeSync(fd);
75
- }
76
- } catch (cause) {
77
- throw new Error(`run directory generation ${claim.generation} lost its claim`, { cause });
78
- }
79
- 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`);
80
- const publication = {
81
- claim,
82
- active: true
83
- };
84
- try {
85
- return publications.run(publication, operation);
86
- } finally {
87
- publication.active = false;
88
- }
89
- });
90
- }
91
- /** Persistent generation counter survives a clean release of supervise.lock. @internal */
92
- function runGenerationPath(runDir) {
93
- return resolve(runDir, "supervise.generation");
94
- }
95
- // src/runtime/supervise/durable-file.ts
96
- /**
97
- * Small filesystem durability primitives for Runtime-owned state.
98
- *
99
- * Callers must validate their path and parent directory before invoking these functions.
100
- * The exclusive writer protects a no-clobber publication race; the atomic writer replaces one
101
- * state file after its temporary contents reach stable storage.
102
- *
103
- * @internal
104
- */
105
- var durable_file_exports = /* @__PURE__ */ __exportAll({
106
- appendDurableFile: () => appendDurableFile,
107
- assertNoSymlinkDescendant: () => assertNoSymlinkDescendant,
108
- publishExclusiveDurableFile: () => publishExclusiveDurableFile,
109
- syncDurableDirectory: () => syncDurableDirectory,
110
- writeAtomicDurableFile: () => writeAtomicDurableFile
111
- });
112
- /**
113
- * Publish a new file without replacing a concurrent winner. The published entry is a hard link
114
- * of the temporary file, so a content function sees the published file's inode.
115
- */
116
- function publishExclusiveDurableFile(filePath, content, options = {}) {
117
- return fenceRunWrite(() => publishExclusiveDurableFileUnchecked(filePath, content, options));
118
- }
119
- function publishExclusiveDurableFileUnchecked(filePath, content, options = {}) {
120
- const temporaryPath = `${filePath}.${randomUUID()}.tmp`;
121
- let operationFailed = false;
122
- let operationError;
123
- let published = false;
124
- try {
125
- writeExclusiveDurableFile(temporaryPath, content, options);
126
- try {
127
- linkSync(temporaryPath, filePath);
128
- syncDurableDirectory(dirname(filePath));
129
- published = true;
130
- } catch (error) {
131
- if (!isAlreadyExistsError(error)) throw error;
132
- }
133
- } catch (error) {
134
- operationFailed = true;
135
- operationError = error;
136
- }
137
- let cleanupError;
138
- try {
139
- unlinkSync(temporaryPath);
140
- } catch (error) {
141
- if (!isNoEntryError(error)) cleanupError = error;
142
- }
143
- if (operationFailed) throw operationError;
144
- if (cleanupError !== void 0) throw cleanupError;
145
- return published;
146
- }
147
- /** Fsync a directory after publishing a durable file entry. */
148
- function syncDurableDirectory(directoryPath) {
149
- const fd = openSync(directoryPath, "r");
150
- try {
151
- fsyncSync(fd);
152
- } finally {
153
- closeSync(fd);
154
- }
155
- }
156
- /** Fsync one durable file after its contents reach stable storage. */
157
- function syncDurableFile(filePath, exactMode) {
158
- const fd = openSync(filePath, "r");
159
- try {
160
- if (exactMode !== void 0 && process.platform !== "win32") fchmodSync(fd, exactMode);
161
- fsyncSync(fd);
162
- } finally {
163
- closeSync(fd);
164
- }
165
- }
166
- /** Append one record with O_APPEND, then fsync the file and containing directory. */
167
- function appendDurableFile(filePath, content, options = {}) {
168
- fenceRunWrite(() => appendDurableFileUnchecked(filePath, content, options));
169
- }
170
- function appendDurableFileUnchecked(filePath, content, options = {}) {
171
- const flags = constants.O_APPEND | constants.O_CREAT | constants.O_WRONLY | (typeof constants.O_NOFOLLOW === "number" ? constants.O_NOFOLLOW : 0);
172
- const fd = openSync(filePath, flags, options.mode ?? 384);
173
- try {
174
- if (process.platform !== "win32") fchmodSync(fd, options.mode ?? 384);
175
- const expectedBytes = Buffer.byteLength(content, "utf8");
176
- const writtenBytes = writeSync(fd, content, void 0, "utf8");
177
- if (writtenBytes !== expectedBytes) throw new Error(`durable append wrote ${writtenBytes} of ${expectedBytes} bytes to '${filePath}'`);
178
- fsyncSync(fd);
179
- } finally {
180
- closeSync(fd);
181
- }
182
- syncDurableDirectory(dirname(filePath));
183
- }
184
- /** Reject a path that escapes its run directory or traverses a symbolic link. */
185
- function assertNoSymlinkDescendant(root, target, label = "path") {
186
- const base = resolve(root);
187
- const exact = resolve(target);
188
- const rel = relative(base, exact);
189
- if (rel === ".." || rel.startsWith(`..${process.platform === "win32" ? "\\" : "/"}`)) throw new Error(`${label} path escapes its run directory`);
190
- if (existsSync(base) && lstatSync(base).isSymbolicLink()) throw new Error(`${label} path contains a symbolic link: ${base}`);
191
- let current = base;
192
- for (const part of rel.split(/[\\/]/u).filter(Boolean)) {
193
- current = join(current, part);
194
- if (!existsSync(current)) continue;
195
- if (lstatSync(current).isSymbolicLink()) throw new Error(`${label} path contains a symbolic link: ${current}`);
196
- }
197
- }
198
- /** Write, fsync, atomically replace, and fsync one Runtime-owned state file.
199
- * preserveMode retains ordinary access permissions despite the current umask; a new
200
- * file keeps normal creation semantics. Callers still own path validation and write exclusion. */
201
- function writeAtomicDurableFile(filePath, content, options = {}) {
202
- fenceRunWrite(() => writeAtomicDurableFileUnchecked(filePath, content, options));
203
- }
204
- function writeAtomicDurableFileUnchecked(filePath, content, options = {}) {
205
- const temporaryPath = `${filePath}.${randomUUID()}.tmp`;
206
- let operationFailed = false;
207
- let operationError;
208
- try {
209
- let mode = options.mode;
210
- let exactMode = false;
211
- if (options.preserveMode) try {
212
- mode = statSync(filePath).mode & 511;
213
- exactMode = true;
214
- } catch (error) {
215
- if (!isNoEntryError(error)) throw error;
216
- }
217
- writeExclusiveDurableFile(temporaryPath, content, { mode }, exactMode);
218
- renameSync(temporaryPath, filePath);
219
- syncDurableDirectory(dirname(filePath));
220
- } catch (error) {
221
- operationFailed = true;
222
- operationError = error;
223
- }
224
- let cleanupError;
225
- try {
226
- unlinkSync(temporaryPath);
227
- } catch (error) {
228
- if (!isNoEntryError(error)) cleanupError = error;
229
- }
230
- if (operationFailed) throw operationError;
231
- if (cleanupError !== void 0) throw cleanupError;
232
- }
233
- function writeExclusiveDurableFile(filePath, content, options, exactMode = false) {
234
- const fd = openSync(filePath, "wx", options.mode ?? 438);
235
- try {
236
- const text = typeof content === "string" ? content : content(fstatSync(fd, { bigint: true }));
237
- writeFileSync(fd, text, "utf8");
238
- } finally {
239
- closeSync(fd);
240
- }
241
- syncDurableFile(filePath, exactMode ? options.mode : void 0);
242
- }
243
- function isAlreadyExistsError(error) {
244
- return error !== null && typeof error === "object" && "code" in error && error.code === "EEXIST";
245
- }
246
- function isNoEntryError(error) {
247
- return error !== null && typeof error === "object" && "code" in error && error.code === "ENOENT";
248
- }
249
- // src/durable/spawn-journal/record-events.ts
250
- /** Decode the file journal's historical single-event and atomic-group envelopes. @internal */
251
- function spawnJournalRecordEvents(record) {
252
- if (!isRecord(record)) throw new Error("spawn journal corrupted: record must be an object");
253
- if (record.kind === "begin") return [];
254
- if (record.kind === "event") return [record.event];
255
- if (record.kind !== "events") throw new Error(`spawn journal corrupted: unknown record kind '${String(record.kind)}'`);
256
- if (!Array.isArray(record.events)) throw new Error("spawn journal group has no events array");
257
- return record.events;
258
- }
259
- export { publishExclusiveDurableFile as a, captureRunWriteContext as c, runGenerationPath as d, runWithWriteClaim as f, durable_file_exports as i, fenceRunWrite as l, __exportAll as m, appendDurableFile as n, syncDurableDirectory as o, sha256 as p, assertNoSymlinkDescendant as r, writeAtomicDurableFile as s, spawnJournalRecordEvents as t, mutateRunClaim as u };
260
-
261
- //# sourceMappingURL=record-events-B2GUgYdz.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"record-events-B2GUgYdz.js","names":["fsConstants"],"sources":["../src/content-digest.ts","../src/durable/run-fence.ts","../src/runtime/supervise/durable-file.ts","../src/durable/spawn-journal/record-events.ts"],"sourcesContent":["import { createHash } from 'node:crypto'\n\nexport function sha256(value: string): string {\n return createHash('sha256').update(value).digest('hex')\n}\n","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","import { isRecord } from '@tangle-network/agent-core'\nimport type { SpawnEvent } from '../../runtime/supervise/types'\n\n/** Decode the file journal's historical single-event and atomic-group envelopes. @internal */\nexport function spawnJournalRecordEvents(record: unknown): ReadonlyArray<SpawnEvent> {\n if (!isRecord(record)) throw new Error('spawn journal corrupted: record must be an object')\n if (record.kind === 'begin') return []\n if (record.kind === 'event') return [record.event as SpawnEvent]\n if (record.kind !== 'events') {\n throw new Error(`spawn journal corrupted: unknown record kind '${String(record.kind)}'`)\n }\n if (!Array.isArray(record.events)) throw new Error('spawn journal group has no events array')\n return record.events as SpawnEvent[]\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAEA,SAAgB,OAAO,OAAuB;CAC5C,OAAO,WAAW,QAAQ,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,OAAO,KAAK;AACxD;;ACSA,MAAM,SAAS,IAAI,kBAA6C;AAChE,MAAM,eAAe,IAAI,kBAAsE;;AAG/F,SAAgB,kBAAqB,OAAsB,WAAuB;CAChF,OAAO,OAAO,IAAI,OAAO,SAAS;AACpC;;AAGA,SAAgB,yBAAuD;C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