@tangle-network/agent-runtime 0.237.0 → 0.238.0

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 (57) hide show
  1. package/dist/{activation-B1Ioaoxu.js → activation-Br1FRlyB.js} +2 -2
  2. package/dist/{activation-B1Ioaoxu.js.map → activation-Br1FRlyB.js.map} +1 -1
  3. package/dist/{activation-CJqtz9SS.d.ts → activation-CRDZUoUE.d.ts} +2 -2
  4. package/dist/agent.d.ts +2 -2
  5. package/dist/agent.js +2 -2
  6. package/dist/{coordination-driver-DD8ffHLE.js → coordination-driver-DbiCH5be.js} +3 -24
  7. package/dist/{coordination-driver-DD8ffHLE.js.map → coordination-driver-DbiCH5be.js.map} +1 -1
  8. package/dist/{delegate-C0G0SOif.js → delegate-C4rLxuv8.js} +2 -2
  9. package/dist/{delegate-C0G0SOif.js.map → delegate-C4rLxuv8.js.map} +1 -1
  10. package/dist/durable.d.ts +2 -2
  11. package/dist/durable.js +26 -37
  12. package/dist/durable.js.map +1 -1
  13. package/dist/{graph-DBemtsCf.js → graph-BHU73FnA.js} +3 -3
  14. package/dist/{graph-DBemtsCf.js.map → graph-BHU73FnA.js.map} +1 -1
  15. package/dist/{improvement-cycle-Ac5z5H7M.js → improvement-cycle-DkzbEzS5.js} +3 -3
  16. package/dist/{improvement-cycle-Ac5z5H7M.js.map → improvement-cycle-DkzbEzS5.js.map} +1 -1
  17. package/dist/{index-BfUDevdx.d.ts → index-B8Fmz26p.d.ts} +4 -4
  18. package/dist/index.d.ts +6 -6
  19. package/dist/index.js +8 -16
  20. package/dist/index.js.map +1 -1
  21. package/dist/intelligence.d.ts +3 -3
  22. package/dist/intelligence.js +3 -3
  23. package/dist/kernel.d.ts +3 -3
  24. package/dist/kernel.js +8 -8
  25. package/dist/{loop-runner-bin-B3NW0VPt.js → loop-runner-bin-BaQIyvh-.js} +3 -3
  26. package/dist/{loop-runner-bin-B3NW0VPt.js.map → loop-runner-bin-BaQIyvh-.js.map} +1 -1
  27. package/dist/{loop-runner-bin-DNVhcUz2.d.ts → loop-runner-bin-vGFnPXLM.d.ts} +3 -3
  28. package/dist/loop-runner-bin.d.ts +1 -1
  29. package/dist/loop-runner-bin.js +1 -1
  30. package/dist/mcp/bin.js +3 -3
  31. package/dist/mcp/index.d.ts +5 -5
  32. package/dist/mcp/index.js +4 -4
  33. package/dist/{openai-tools-C5SS8ngZ.d.ts → openai-tools-BPPAXxP2.d.ts} +2 -2
  34. package/dist/profiles.d.ts +2 -2
  35. package/dist/{provision-supervisor-Ch-vCAbq.js → provision-supervisor-Briw5tX4.js} +3 -3
  36. package/dist/{provision-supervisor-Ch-vCAbq.js.map → provision-supervisor-Briw5tX4.js.map} +1 -1
  37. package/dist/{runtime-BDwTXkDM.js → runtime-BzGKUqqY.js} +11 -20
  38. package/dist/runtime-BzGKUqqY.js.map +1 -0
  39. package/dist/{server-D4Ypvef9.js → server-CDn-i_GJ.js} +3 -3
  40. package/dist/{server-D4Ypvef9.js.map → server-CDn-i_GJ.js.map} +1 -1
  41. package/dist/{stream-agent-turn-DkiyfYi8.d.ts → stream-agent-turn-xgmm-M55.d.ts} +2 -2
  42. package/dist/{structural-rollout-D-Ougv7r.js → structural-rollout-B-EAO8C5.js} +2 -2
  43. package/dist/{structural-rollout-D-Ougv7r.js.map → structural-rollout-B-EAO8C5.js.map} +1 -1
  44. package/dist/{substrate-CfzWdBcq.d.ts → substrate-B_9stFWH.d.ts} +2 -2
  45. package/dist/{supervise-gSGndJJo.js → supervise-Dc2DjlZS.js} +30 -15
  46. package/dist/supervise-Dc2DjlZS.js.map +1 -0
  47. package/dist/{supervisor-B5wyKVRd.js → supervisor-BN3oMv_v.js} +135 -45
  48. package/dist/supervisor-BN3oMv_v.js.map +1 -0
  49. package/dist/testing.d.ts +2 -2
  50. package/dist/testing.js +12 -12
  51. package/dist/tui/index.d.ts +1 -1
  52. package/dist/tui/index.js +1 -1
  53. package/dist/{types-palY_bT_.d.ts → types-CE7ES_TD.d.ts} +10 -4
  54. package/package.json +1 -1
  55. package/dist/runtime-BDwTXkDM.js.map +0 -1
  56. package/dist/supervise-gSGndJJo.js.map +0 -1
  57. package/dist/supervisor-B5wyKVRd.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { Ur as Driver, Vr as AgentRunSpec, hi as Validator, ui as OutputAdapter } from "./types-palY_bT_.js";
1
+ import { Ur as Driver, Vr as AgentRunSpec, hi as Validator, ui as OutputAdapter } from "./types-CE7ES_TD.js";
2
2
  import { AgentProfile } from "@tangle-network/agent-interface";
3
3
  //#region src/profiles/coder.d.ts
4
4
  /**
@@ -281,4 +281,4 @@ interface UiFinding {
281
281
  }
282
282
  //#endregion
283
283
  export { CoderTask as _, UiFindingSeverity as a, KnowledgeUpdate as c, ResearchSource as d, ResearchTask as f, researcherProfile as g, multiHarnessResearcherFanout as h, UiFindingScreenshot as i, MultiHarnessResearcherFanoutOptions as l, createResearcherValidator as m, UI_LENSES as n, UiLens as o, ResearcherProfileOptions as p, UiFinding as r, KnowledgeItem as s, UI_FINDING_SEVERITIES as t, ResearchOutput as u, coderTaskToPrompt as v };
284
- //# sourceMappingURL=substrate-CfzWdBcq.d.ts.map
284
+ //# sourceMappingURL=substrate-B_9stFWH.d.ts.map
@@ -1,16 +1,16 @@
1
- import { $ as bindReusableExecutorExecutionId, $r as providerAttemptEvidence, An as RunCancellationReason, Ar as profileMaterializationAxes$1, At as spendFromUsageTotals, Bi as withTimeout, Br as worktreeCliProfileMaterialization, Bt as createInbox, C as scopeOwnerExecutorNodeContext, Cn as resolveAgentEnvironmentProvider, Di as addSpend, Dr as controlProfileMaterialization, Dt as meterUsageEvent, Er as assertProfileMaterialization, F as scopeRetainedOwnerPriorSpend, Fi as sleep, Gn as contentAddress, Hi as addResourceSpend, Hr as parseCommittedJsonLines, I as scopeRetainedOwnerResult, Ir as renderUnsupported, J as errMessage, Ji as DEFAULT_SUCCESSFUL_SHUTDOWN_MS, Kr as attestRuntimeOwnedScopeOwner, M as consumeScopeRetainedOwnerResult, Mn as linkAbort, Mr as promptModelProfileMaterialization, N as prepareScopeRetainedOwnerTask, Nn as runAbortable, On as registerRetainedExecutorPreparation, Or as defineProfileMaterializationContract, Ot as newUsageTotals, P as scopeRetainedOwnerContext, Qt as bridgeModelRouteRefusal, Rr as unsupportedProfileDimensions, S as restoreScopeOwnerAcceptedExecution, Tt as assertValidBudget, Ui as resourceTelemetry, Ur as prepareJsonlAppend, Vi as zeroSpend, Vr as isNoEntError, Wi as withBudgetResources, Xi as teardownExecutor, Yr as inheritRuntimeOwnedExecutorAttestation, Zt as bridgeAdmissionRefusal, ai as runtimeOwnedPendingExecutorMaterialization, at as snapshotExecutorConfig, b as meterRuntimeOwnedProviderAttempt, cr as toOtelAttributes, d as runDriverWithRetry, ei as recordRuntimeOwnedDriveHarnessProviderEvidence, et as captureReusableExecutorConfig, f as driverChild, fi as detachedSnapshot, g as beginScopeOwnerAttempt, hn as routerBrain, ii as runtimeOwnedExecutorProviderEvidence, in as bridgeStopSignalKey, ir as generateSpanId, j as bindScopeRetainedOwnerProvider, jr as promptControlProfileMaterialization, jt as WORKER_TRACE_PROPAGATION, kn as retainedExecutorSeamKey, kr as fullProfileMaterialization, m as isDriverSpec, n as createSupervisor, ni as runtimeOwnedExecutorExecutionBinding, o as runFinalizer, oi as runtimeOwnedScopeOwnerRuntime, p as driverExecutorFactory, r as bestDelivered, ri as runtimeOwnedExecutorMaterialization, rn as bridgeRuntimeAttachmentsKey, rt as createExecutor, s as runTree, t as createRootHandle, ti as runtimeOwnedDriveHarnessProviderEvidence, tr as createOtelExporter, u as defaultUnmetContractSteer, v as deriveNodeExecutionIdentity, x as recordScopeOwnerMaterialization, y as meterRuntimeOwnedAccounting, zi as unmeteredSpend } from "./supervisor-B5wyKVRd.js";
1
+ import { $t as bridgeAdmissionRefusal, An as registerRetainedExecutorPreparation, Ar as defineProfileMaterializationContract, Br as unsupportedProfileDimensions, C as restoreScopeOwnerAcceptedExecution, Et as assertValidBudget, F as scopeRetainedOwnerContext, Fn as runAbortable, Gi as resourceTelemetry, Gr as readCommittedJsonLines, Hi as withTimeout, Hr as worktreeCliProfileMaterialization, I as scopeRetainedOwnerPriorSpend, Jr as attestRuntimeOwnedScopeOwner, Ki as withBudgetResources, L as scopeRetainedOwnerResult, Li as sleep, M as bindScopeRetainedOwnerProvider, Mn as RunCancellationReason, Mr as profileMaterializationAxes$1, Mt as WORKER_TRACE_PROPAGATION, N as consumeScopeRetainedOwnerResult, Nr as promptControlProfileMaterialization, Or as assertProfileMaterialization, Ot as meterUsageEvent, P as prepareScopeRetainedOwnerTask, Pn as linkAbort, Pr as promptModelProfileMaterialization, Qi as teardownExecutor, Qt as executorFailure, Rr as renderUnsupported, S as recordScopeOwnerMaterialization, Tn as resolveAgentEnvironmentProvider, Ui as zeroSpend, Ur as isNoEntError, Vi as unmeteredSpend, Vt as createInbox, Wi as addResourceSpend, Wr as prepareJsonlAppend, Xi as DEFAULT_SUCCESSFUL_SHUTDOWN_MS, Y as errMessage, Zr as inheritRuntimeOwnedExecutorAttestation, _ as beginScopeOwnerAttempt, _n as routerBrain, ai as runtimeOwnedExecutorMaterialization, an as bridgeRuntimeAttachmentsKey, b as meterRuntimeOwnedAccounting, ci as runtimeOwnedScopeOwnerRuntime, d as defaultUnmetContractSteer, en as bridgeModelRouteRefusal, et as bindReusableExecutorExecutionId, f as runDriverWithRetry, h as isDriverSpec, ii as runtimeOwnedExecutorExecutionBinding, it as createExecutor, jn as retainedExecutorSeamKey, jr as fullProfileMaterialization, jt as spendFromUsageTotals, ki as addSpend, kr as controlProfileMaterialization, kt as newUsageTotals, l as HarnessTurnFailedError, m as driverExecutorFactory, mi as detachedSnapshot, n as createSupervisor, ni as recordRuntimeOwnedDriveHarnessProviderEvidence, o as runFinalizer, oi as runtimeOwnedExecutorProviderEvidence, on as bridgeStopSignalKey, or as generateSpanId, ot as snapshotExecutorConfig, p as driverChild, qn as contentAddress, r as bestDelivered, ri as runtimeOwnedDriveHarnessProviderEvidence, rr as createOtelExporter, s as runTree, si as runtimeOwnedPendingExecutorMaterialization, t as createRootHandle, ti as providerAttemptEvidence, tt as captureReusableExecutorConfig, ur as toOtelAttributes, w as scopeOwnerExecutorNodeContext, x as meterRuntimeOwnedProviderAttempt, y as deriveNodeExecutionIdentity } from "./supervisor-BN3oMv_v.js";
2
2
  import { f as RuntimeRunStateError, i as ConfigError, m as ValidationError } from "./errors-DodWX-cb.js";
3
3
  import { a as concreteProfileModel, c as profileModelExecutionSettings, d as agentHarness, f as harnessRunsAgent, n as assertModelAllowed, o as enforceTokenLimits, r as assertProfileModelsAllowed, s as profileBridgeWireModel, t as assertExecutableAgentProfile } from "./model-policy-BbSCSak0.js";
4
4
  import { t as composeRuntimeHooks } from "./runtime-hooks-tXpAarhW.js";
5
5
  import { n as assertNoSymlinkDescendant } from "./durable-file-D24y9zg7.js";
6
6
  import { n as createStdioToolServer, t as PROTOCOL_VERSION } from "./tool-server-x9NEhvHZ.js";
7
- import { D as coordinationVerbNames, O as createCoordinationTools, S as watchRunCancellation, c as createProgressTracker, d as progressStop, r as driverAgent, v as createFileRunContext, w as DEFAULT_AWAIT_EVENT_TIMEOUT_MS, x as applyRunCancellation, y as createInMemoryRunContext } from "./coordination-driver-DD8ffHLE.js";
7
+ import { D as coordinationVerbNames, O as createCoordinationTools, S as watchRunCancellation, c as createProgressTracker, d as progressStop, r as driverAgent, v as createFileRunContext, w as DEFAULT_AWAIT_EVENT_TIMEOUT_MS, x as applyRunCancellation, y as createInMemoryRunContext } from "./coordination-driver-DbiCH5be.js";
8
8
  import { k as writeRunCancellation, o as readRunCancelRequest, s as readRunCancellation } from "./run-layout-hZREkcfu.js";
9
9
  import { agentProfileSchema, canonicalAgentProfileDigest, canonicalCandidateDigest, canonicalCandidateJson, validateAgentProfileSecurity } from "@tangle-network/agent-interface";
10
10
  import { createHash, createHmac, randomBytes, randomUUID, timingSafeEqual } from "node:crypto";
11
11
  import { closeSync, constants, fsyncSync, openSync, writeSync } from "node:fs";
12
12
  import { resolve } from "node:path";
13
- import { mkdir, readFile } from "node:fs/promises";
13
+ import { mkdir } from "node:fs/promises";
14
14
  import { isMaterializerHarness } from "@tangle-network/agent-profile-materialize";
15
15
  import { createServer } from "node:http";
16
16
  //#region src/runtime/supervise/completion-gate.ts
@@ -1243,7 +1243,8 @@ function createRootStreamSink(runDir, now) {
1243
1243
  await mkdir(dir, { recursive: true });
1244
1244
  assertNoSymlinkDescendant(dir, path, "root stream");
1245
1245
  const needsSeparator = await prepareJsonlAppend(path);
1246
- seq = (await readRootStream(dir) ?? []).length;
1246
+ seq = 0;
1247
+ for await (const _record of readCommittedJsonLines(path, { allowMissing: true })) seq += 1;
1247
1248
  fd = openSync(path, constants.O_APPEND | constants.O_CREAT | constants.O_WRONLY | (typeof constants.O_NOFOLLOW === "number" ? constants.O_NOFOLLOW : 0), 384);
1248
1249
  if (needsSeparator) writeLine(fd, "");
1249
1250
  };
@@ -1322,30 +1323,33 @@ function writeLine(fd, line) {
1322
1323
  */
1323
1324
  async function readRootStreamReceipt(runDir) {
1324
1325
  const path = resolve(runDir, ROOT_STREAM_FILE);
1325
- let bytes;
1326
+ const hash = createHash("sha256");
1327
+ let events = 0;
1326
1328
  try {
1327
- bytes = await readFile(path);
1329
+ for await (const _record of readCommittedJsonLines(path, { onBytes: (bytes) => {
1330
+ hash.update(bytes);
1331
+ } })) events += 1;
1328
1332
  } catch (error) {
1329
1333
  if (isNoEntError(error)) return void 0;
1330
1334
  throw error;
1331
1335
  }
1332
1336
  return Object.freeze({
1333
- ref: `sha256:${createHash("sha256").update(bytes).digest("hex")}`,
1334
- events: parseCommittedJsonLines(bytes.toString("utf8"), path).length
1337
+ ref: `sha256:${hash.digest("hex")}`,
1338
+ events
1335
1339
  });
1336
1340
  }
1337
1341
  /** Every committed line of the root stream, in order, or `undefined` when there is no file. A
1338
1342
  * torn final line from a process that died mid-write is not a record and is left out. */
1339
1343
  async function readRootStream(runDir) {
1340
1344
  const path = resolve(runDir, ROOT_STREAM_FILE);
1341
- let text;
1345
+ const records = [];
1342
1346
  try {
1343
- text = await readFile(path, "utf8");
1347
+ for await (const record of readCommittedJsonLines(path)) records.push(record);
1344
1348
  } catch (error) {
1345
1349
  if (isNoEntError(error)) return void 0;
1346
1350
  throw error;
1347
1351
  }
1348
- return parseCommittedJsonLines(text, path);
1352
+ return records;
1349
1353
  }
1350
1354
  function errorMessage(error) {
1351
1355
  return error instanceof Error ? error.message : String(error);
@@ -2477,14 +2481,18 @@ function driveHarnessFromBackend(backend, executionId, now = Date.now, maxTurns,
2477
2481
  const turnCap = maxTurns ?? 0;
2478
2482
  const boundBackend = bindReusableExecutorExecutionId(captureReusableExecutorConfig(backend, "driveHarnessFromBackend"), executionId);
2479
2483
  const baseFactory = createExecutor(boundBackend);
2484
+ const ownerRuntime = boundBackend.backend === "provider" ? boundBackend.runtime ?? resolveAgentEnvironmentProvider(boundBackend.provider, boundBackend.registry).name : "cli";
2480
2485
  let activeExecutor;
2481
2486
  const drive = async ({ profile, authoredProfile, task, scope, coordinationMcpUrl, coordinationMcpHeaders, stopSignal, coordinationTools }) => {
2482
2487
  const retainedOwner = boundBackend.backend === "provider" ? scopeRetainedOwnerContext(scope) : void 0;
2483
2488
  if (retainedOwner && boundBackend.backend === "provider") bindScopeRetainedOwnerProvider(scope, resolveAgentEnvironmentProvider(boundBackend.provider, boundBackend.registry));
2484
2489
  const originalTask = retainedOwner ? await prepareScopeRetainedOwnerTask(scope, task) : task;
2485
- if (retainedOwner ? await scopeRetainedOwnerResult(scope) : void 0) {
2490
+ const acceptedOwner = retainedOwner ? await scopeRetainedOwnerResult(scope) : void 0;
2491
+ if (acceptedOwner) {
2486
2492
  await restoreScopeOwnerAcceptedExecution(scope);
2487
2493
  consumeScopeRetainedOwnerResult(scope);
2494
+ const replayedFailure = executorFailure(acceptedOwner);
2495
+ if (replayedFailure !== void 0) throw new HarnessTurnFailedError(ownerRuntime, replayedFailure);
2488
2496
  return;
2489
2497
  }
2490
2498
  const initialBudget = scope.budget;
@@ -2640,6 +2648,7 @@ function driveHarnessFromBackend(backend, executionId, now = Date.now, maxTurns,
2640
2648
  const pending = runtimeOwnedPendingExecutorMaterialization(executor);
2641
2649
  let failed = false;
2642
2650
  let failure;
2651
+ let turnFailure;
2643
2652
  let ownerMaterializationPublished = false;
2644
2653
  const ownerDeclaration = (exactDeclaration) => ({
2645
2654
  ...exactDeclaration,
@@ -2741,15 +2750,20 @@ function driveHarnessFromBackend(backend, executionId, now = Date.now, maxTurns,
2741
2750
  telemetry: "unknown"
2742
2751
  });
2743
2752
  terminalAccountingCaptured = true;
2753
+ const reported = executorFailure(artifact);
2754
+ if (reported !== void 0) turnFailure = new HarnessTurnFailedError(executor.runtime, reported);
2744
2755
  } else {
2756
+ const artifact = await run;
2745
2757
  await meterRuntimeOwnedProviderAttempt(scope, withBudgetResources({
2746
- ...(await run).spent,
2758
+ ...artifact.spent,
2747
2759
  iterations: 0
2748
2760
  }, scope.budget), providerEvidenceForNextMeter(), {
2749
2761
  role: "driver",
2750
2762
  runtime: executor.runtime
2751
2763
  });
2752
2764
  terminalAccountingCaptured = true;
2765
+ const reported = executorFailure(artifact);
2766
+ if (reported !== void 0) turnFailure = new HarnessTurnFailedError(executor.runtime, reported);
2753
2767
  }
2754
2768
  if (pending !== void 0 && !ownerMaterializationPublished) {
2755
2769
  const acknowledged = runtimeOwnedExecutorMaterialization(executor);
@@ -2822,6 +2836,7 @@ function driveHarnessFromBackend(backend, executionId, now = Date.now, maxTurns,
2822
2836
  if (activeExecutor === executor) activeExecutor = void 0;
2823
2837
  }
2824
2838
  if (failed) throw failure;
2839
+ if (turnFailure !== void 0) throw turnFailure;
2825
2840
  };
2826
2841
  drive.deliver = (message) => {
2827
2842
  const deliver = activeExecutor?.deliver;
@@ -2830,7 +2845,7 @@ function driveHarnessFromBackend(backend, executionId, now = Date.now, maxTurns,
2830
2845
  };
2831
2846
  drive.traceSource = () => activeExecutor?.traceSource?.();
2832
2847
  drive.progress = () => activeExecutor?.progress?.();
2833
- return attestRuntimeOwnedScopeOwner(drive, boundBackend.backend === "provider" ? boundBackend.runtime ?? resolveAgentEnvironmentProvider(boundBackend.provider, boundBackend.registry).name : "cli");
2848
+ return attestRuntimeOwnedScopeOwner(drive, ownerRuntime);
2834
2849
  }
2835
2850
  function isAsyncIterable(value) {
2836
2851
  return value !== null && typeof value === "object" && Symbol.asyncIterator in value && typeof value[Symbol.asyncIterator] === "function";
@@ -3674,4 +3689,4 @@ function rootProviderModelEvidenceFromExecution(evidence) {
3674
3689
  //#endregion
3675
3690
  export { createSupervisorSpanRecorder as _, isPreSpawnExecutorFailure as a, mapExecutorResult as b, withWorkerSpawnRetry as c, resolveSupervisorProfile as d, supervisorAgent as f, readRootStreamReceipt as g, readRootStream as h, workerFromBackend as i, assertCoordinationBinding as l, ROOT_STREAM_FILE as m, supervise as n, resolveWorkerSpawnRetry as o, supervisorAgentWithTestBrain as p, superviseWithTestBrain as r, retryPreSpawnRefusals as s, DEFAULT_AUTHORED_PROFILE_SECURITY_POLICY as t, coordinationProfileToolPrefix as u, serveCoordinationMcp as v, gateOnDeliverable as y };
3676
3691
 
3677
- //# sourceMappingURL=supervise-gSGndJJo.js.map
3692
+ //# sourceMappingURL=supervise-Dc2DjlZS.js.map