@tangle-network/agent-runtime 0.221.0 → 0.222.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 (52) hide show
  1. package/dist/{activation-B80dGdPw.js → activation-C3FIZinc.js} +2 -2
  2. package/dist/{activation-B80dGdPw.js.map → activation-C3FIZinc.js.map} +1 -1
  3. package/dist/{activation-CdwuD1wP.d.ts → activation-CoaTi81Q.d.ts} +2 -2
  4. package/dist/agent.d.ts +1 -1
  5. package/dist/agent.js +2 -2
  6. package/dist/{coordination-driver-imD3q4L5.js → coordination-driver-BMFwV_aM.js} +2 -2
  7. package/dist/{coordination-driver-imD3q4L5.js.map → coordination-driver-BMFwV_aM.js.map} +1 -1
  8. package/dist/{delegate-BokSjGmE.js → delegate-_MIPlySb.js} +2 -2
  9. package/dist/{delegate-BokSjGmE.js.map → delegate-_MIPlySb.js.map} +1 -1
  10. package/dist/durable.d.ts +5 -5
  11. package/dist/durable.js +27 -5
  12. package/dist/durable.js.map +1 -1
  13. package/dist/{graph-D4MFz-Cy.js → graph-DAzvl-CD.js} +3 -3
  14. package/dist/{graph-D4MFz-Cy.js.map → graph-DAzvl-CD.js.map} +1 -1
  15. package/dist/{improvement-cycle-C_Kdj9DB.js → improvement-cycle-DH28Q79j.js} +3 -3
  16. package/dist/{improvement-cycle-C_Kdj9DB.js.map → improvement-cycle-DH28Q79j.js.map} +1 -1
  17. package/dist/{index-CFzFVR5N.d.ts → index-ZJQ4RpP6.d.ts} +2 -2
  18. package/dist/index.d.ts +4 -4
  19. package/dist/index.js +7 -7
  20. package/dist/intelligence.d.ts +2 -2
  21. package/dist/intelligence.js +3 -3
  22. package/dist/kernel.d.ts +2 -2
  23. package/dist/kernel.js +8 -8
  24. package/dist/{loop-runner-bin-Deg_bFdg.d.ts → loop-runner-bin-CscIVOv-.d.ts} +3 -3
  25. package/dist/{loop-runner-bin-DK0Ov_15.js → loop-runner-bin-D5F5XAqC.js} +3 -3
  26. package/dist/{loop-runner-bin-DK0Ov_15.js.map → loop-runner-bin-D5F5XAqC.js.map} +1 -1
  27. package/dist/loop-runner-bin.d.ts +1 -1
  28. package/dist/loop-runner-bin.js +1 -1
  29. package/dist/mcp/bin.js +3 -3
  30. package/dist/mcp/index.d.ts +2 -2
  31. package/dist/mcp/index.js +4 -4
  32. package/dist/{provision-supervisor-C98UA-kI.js → provision-supervisor-ONy4pJ0l.js} +3 -3
  33. package/dist/{provision-supervisor-C98UA-kI.js.map → provision-supervisor-ONy4pJ0l.js.map} +1 -1
  34. package/dist/{runtime-B3YZlRti.js → runtime-CGZo3BpF.js} +8 -8
  35. package/dist/{runtime-B3YZlRti.js.map → runtime-CGZo3BpF.js.map} +1 -1
  36. package/dist/{server-DW_KDc40.js → server-Z-5x4YsU.js} +3 -3
  37. package/dist/{server-DW_KDc40.js.map → server-Z-5x4YsU.js.map} +1 -1
  38. package/dist/{stream-agent-turn-D_-kbzVn.d.ts → stream-agent-turn-CQf-EMwX.d.ts} +5 -1
  39. package/dist/{structural-rollout-CudZIAJv.js → structural-rollout-ysIAMLwb.js} +10 -4
  40. package/dist/structural-rollout-ysIAMLwb.js.map +1 -0
  41. package/dist/{supervise-CBYdifF2.js → supervise-l9fd1ZaI.js} +35 -14
  42. package/dist/supervise-l9fd1ZaI.js.map +1 -0
  43. package/dist/{supervisor-C0xW7oTl.js → supervisor-af7-tQrQ.js} +2437 -2377
  44. package/dist/supervisor-af7-tQrQ.js.map +1 -0
  45. package/dist/testing.d.ts +2 -2
  46. package/dist/testing.js +12 -12
  47. package/dist/tui/index.d.ts +1 -1
  48. package/dist/tui/index.js +1 -1
  49. package/package.json +1 -1
  50. package/dist/structural-rollout-CudZIAJv.js.map +0 -1
  51. package/dist/supervise-CBYdifF2.js.map +0 -1
  52. package/dist/supervisor-C0xW7oTl.js.map +0 -1
@@ -1,9 +1,9 @@
1
- import { $ as bindReusableExecutorExecutionId, Br as fullProfileMaterialization, C as scopeOwnerExecutorNodeContext, Ci as detachedSnapshot, Dt as spendFromUsageEvents, F as scopeRetainedOwnerResult, Fn as withTimeout, Gn as RunCancellationReason, Hr as promptControlProfileMaterialization, In as zeroSpend, Jn as runAbortable, Jt as bridgeAdmissionRefusal, Ln as addResourceSpend, Lr as assertProfileMaterialization, Lt as createInbox, M as prepareScopeRetainedOwnerTask, N as scopeRetainedOwnerContext, Ot as WORKER_TRACE_PROPAGATION, P as scopeRetainedOwnerPriorSpend, Pn as unmeteredSpend, Q as teardownExecutor, Rn as resourceTelemetry, Rr as controlProfileMaterialization, S as restoreScopeOwnerAcceptedExecution, Sn as addSpend, Tt as assertValidBudget, Un as registerRetainedExecutorPreparation, Ur as promptModelProfileMaterialization, Vr as profileMaterializationAxes$1, Wn as retainedExecutorSeamKey, Yr as unsupportedProfileDimensions, Yt as bridgeModelRouteRefusal, Z as DEFAULT_SUCCESSFUL_SHUTDOWN_MS, Zr as worktreeCliProfileMaterialization, _i as runtimeOwnedScopeOwnerRuntime, at as snapshotExecutorConfig, b as meterRuntimeOwnedProviderAttempt, bn as resolveAgentEnvironmentProvider, d as runDriverWithRetry, di as recordRuntimeOwnedDriveHarnessProviderEvidence, en as bridgeRuntimeAttachmentsKey, et as captureReusableExecutorConfig, f as driverChild, fi as runtimeOwnedDriveHarnessProviderEvidence, fn as routerBrain, fr as createOtelExporter, g as beginScopeOwnerAttempt, gi as runtimeOwnedPendingExecutorMaterialization, hi as runtimeOwnedExecutorProviderEvidence, hr as generateSpanId, j as consumeScopeRetainedOwnerResult, m as isDriverSpec, mi as runtimeOwnedExecutorMaterialization, n as createSupervisor, o as runFinalizer, oi as inheritRuntimeOwnedExecutorAttestation, p as driverExecutorFactory, pi as runtimeOwnedExecutorExecutionBinding, qr as renderUnsupported, r as bestDelivered, ri as attestRuntimeOwnedScopeOwner, rt as createExecutor, s as runTree, t as createRootHandle, tn as bridgeStopSignalKey, u as defaultUnmetContractSteer, ui as providerAttemptEvidence, v as deriveNodeExecutionIdentity, wt as contentAddress, x as recordScopeOwnerMaterialization, y as meterRuntimeOwnedAccounting, yr as toOtelAttributes, zn as withBudgetResources, zr as defineProfileMaterializationContract } from "./supervisor-C0xW7oTl.js";
1
+ import { $ as bindReusableExecutorExecutionId, $r as runtimeOwnedExecutorMaterialization, An as RunCancellationReason, At as spendFromUsageTotals, Bi as withBudgetResources, Bt as createInbox, C as scopeOwnerExecutorNodeContext, Ci as addSpend, Cn as resolveAgentEnvironmentProvider, Cr as controlProfileMaterialization, Dr as promptControlProfileMaterialization, Dt as meterUsageEvent, Er as profileMaterializationAxes$1, F as scopeRetainedOwnerResult, Fi as unmeteredSpend, Gr as inheritRuntimeOwnedExecutorAttestation, Hr as attestRuntimeOwnedScopeOwner, Ii as withTimeout, Ir as worktreeCliProfileMaterialization, Li as zeroSpend, M as prepareScopeRetainedOwnerTask, Mr as renderUnsupported, N as scopeRetainedOwnerContext, Nn as runAbortable, On as registerRetainedExecutorPreparation, Or as promptModelProfileMaterialization, Ot as newUsageTotals, P as scopeRetainedOwnerPriorSpend, Pr as unsupportedProfileDimensions, Q as teardownExecutor, Qr as runtimeOwnedExecutorExecutionBinding, Qt as bridgeModelRouteRefusal, Ri as addResourceSpend, S as restoreScopeOwnerAcceptedExecution, Sr as assertProfileMaterialization, Tr as fullProfileMaterialization, Tt as assertValidBudget, Xr as recordRuntimeOwnedDriveHarnessProviderEvidence, Yr as providerAttemptEvidence, Z as DEFAULT_SUCCESSFUL_SHUTDOWN_MS, Zn as createOtelExporter, Zr as runtimeOwnedDriveHarnessProviderEvidence, Zt as bridgeAdmissionRefusal, at as snapshotExecutorConfig, b as meterRuntimeOwnedProviderAttempt, ci as detachedSnapshot, d as runDriverWithRetry, ei as runtimeOwnedExecutorProviderEvidence, er as generateSpanId, et as captureReusableExecutorConfig, f as driverChild, g as beginScopeOwnerAttempt, hn as routerBrain, in as bridgeStopSignalKey, ir as toOtelAttributes, j as consumeScopeRetainedOwnerResult, jt as WORKER_TRACE_PROPAGATION, kn as retainedExecutorSeamKey, m as isDriverSpec, n as createSupervisor, ni as runtimeOwnedScopeOwnerRuntime, o as runFinalizer, p as driverExecutorFactory, r as bestDelivered, rn as bridgeRuntimeAttachmentsKey, rt as createExecutor, s as runTree, t as createRootHandle, ti as runtimeOwnedPendingExecutorMaterialization, u as defaultUnmetContractSteer, v as deriveNodeExecutionIdentity, wr as defineProfileMaterializationContract, wt as contentAddress, x as recordScopeOwnerMaterialization, y as meterRuntimeOwnedAccounting, zi as resourceTelemetry } from "./supervisor-af7-tQrQ.js";
2
2
  import { 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-DKDyr-fc.js";
4
4
  import { t as composeRuntimeHooks } from "./runtime-hooks-tXpAarhW.js";
5
5
  import { t as createStdioToolServer } from "./tool-server-BJbCPhoW.js";
6
- 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-imD3q4L5.js";
6
+ 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-BMFwV_aM.js";
7
7
  import { k as writeRunCancellation, o as readRunCancelRequest, s as readRunCancellation } from "./run-layout-hZREkcfu.js";
8
8
  import { agentProfileSchema, canonicalAgentProfileDigest, canonicalCandidateDigest, canonicalCandidateJson, validateAgentProfileSecurity } from "@tangle-network/agent-interface";
9
9
  import { createHash, createHmac, randomBytes, randomUUID, timingSafeEqual } from "node:crypto";
@@ -624,7 +624,10 @@ async function serveCoordinationMcp(opts) {
624
624
  backgroundActions: nodeTools.background,
625
625
  authorize: (req) => {
626
626
  if (!paths.has(req.url ?? "")) return 404;
627
- if (!audiences.has(req.headers.host ?? "")) return 403;
627
+ const address = req.socket.localAddress?.replace(/^::ffff:/, "");
628
+ const localAuthority = address?.includes(":") ? `[${address}]:${req.socket.localPort}` : `${address}:${req.socket.localPort}`;
629
+ const boundAuthority = audiences.size > 0 && (host === "0.0.0.0" || host === "::") && address !== void 0 && req.socket.localPort !== void 0 && req.headers.host === localAuthority;
630
+ if (!audiences.has(req.headers.host ?? "") && !boundAuthority) return 403;
628
631
  if (closed) return 401;
629
632
  if (!opts.authentication) return void 0;
630
633
  const authorization = req.headers.authorization;
@@ -2279,11 +2282,12 @@ function driveHarnessFromBackend(backend, executionId, now = Date.now, maxTurns)
2279
2282
  let started = false;
2280
2283
  let terminalAccountingCaptured = false;
2281
2284
  let pendingUsage = [];
2285
+ const ownerUsage = newUsageTotals();
2282
2286
  let observedOwnerSpend = zeroSpend();
2283
2287
  let committedOwnerSpend = retainedOwner ? await scopeRetainedOwnerPriorSpend(scope) : zeroSpend();
2284
- const ownerDelta = (total) => ({
2288
+ const ownerDelta = (total, committed = committedOwnerSpend) => ({
2285
2289
  ...addResourceSpend(total.resources === void 0 ? void 0 : Object.fromEntries(Object.entries(total.resources).map(([name, value]) => {
2286
- const prior = committedOwnerSpend.resources?.[name];
2290
+ const prior = committed.resources?.[name];
2287
2291
  if (prior && prior.unit !== value.unit) throw new ValidationError(`resource ${name}: unit mismatch`);
2288
2292
  return [name, {
2289
2293
  ...value,
@@ -2291,13 +2295,16 @@ function driveHarnessFromBackend(backend, executionId, now = Date.now, maxTurns)
2291
2295
  known: value.known && (prior?.known ?? true)
2292
2296
  }];
2293
2297
  }))),
2294
- iterations: Math.max(0, total.iterations - committedOwnerSpend.iterations),
2298
+ iterations: Math.max(0, total.iterations - committed.iterations),
2295
2299
  tokens: {
2296
- input: Math.max(0, total.tokens.input - committedOwnerSpend.tokens.input),
2297
- output: Math.max(0, total.tokens.output - committedOwnerSpend.tokens.output)
2300
+ input: Math.max(0, total.tokens.input - committed.tokens.input),
2301
+ output: Math.max(0, total.tokens.output - committed.tokens.output),
2302
+ ...unmeteredOwnerCache(total.tokens, committed.tokens)
2298
2303
  },
2299
- usd: Math.max(0, total.usd - committedOwnerSpend.usd),
2300
- ms: Math.max(0, total.ms - committedOwnerSpend.ms),
2304
+ usd: Math.max(0, total.usd - committed.usd),
2305
+ ...total.usdEstimated === void 0 ? {} : { usdEstimated: Math.min(Math.max(0, total.usd - committed.usd), Math.max(0, total.usdEstimated - (committed.usdEstimated ?? 0))) },
2306
+ ...total.tokensProvenance === void 0 ? {} : { tokensProvenance: total.tokensProvenance },
2307
+ ms: Math.max(0, total.ms - committed.ms),
2301
2308
  ...total.tokensKnown === false ? { tokensKnown: false } : {},
2302
2309
  ...total.usdKnown === false ? { usdKnown: false } : {}
2303
2310
  });
@@ -2342,9 +2349,10 @@ function driveHarnessFromBackend(backend, executionId, now = Date.now, maxTurns)
2342
2349
  }
2343
2350
  const batch = pendingUsage;
2344
2351
  pendingUsage = [];
2345
- const measured = spendFromUsageEvents(batch);
2346
- observedOwnerSpend = addSpend(observedOwnerSpend, measured);
2347
- const charge = retainedOwner ? ownerDelta(observedOwnerSpend) : measured;
2352
+ for (const event of batch) meterUsageEvent(ownerUsage, event);
2353
+ const measured = spendFromUsageTotals(ownerUsage);
2354
+ const charge = ownerDelta(measured, retainedOwner ? committedOwnerSpend : observedOwnerSpend);
2355
+ observedOwnerSpend = detachedSnapshot(measured, "metered owner spend");
2348
2356
  await meterRuntimeOwnedProviderAttempt(scope, forceUnknown ? {
2349
2357
  ...charge,
2350
2358
  tokensKnown: false,
@@ -3352,6 +3360,19 @@ function superviseInternal(profile, task, opts, testBrain) {
3352
3360
  };
3353
3361
  return start();
3354
3362
  }
3363
+ /** Historical unclassified input is already charged; replay cannot refund it with a class-only delta. */
3364
+ function unmeteredOwnerCache(total, committed) {
3365
+ const cache = {
3366
+ ...total.freshInput === void 0 ? {} : { freshInput: Math.max(0, total.freshInput - (committed.freshInput ?? 0)) },
3367
+ ...total.cacheRead === void 0 ? {} : { cacheRead: Math.max(0, total.cacheRead - (committed.cacheRead ?? 0)) },
3368
+ ...total.cacheWrite === void 0 ? {} : { cacheWrite: Math.max(0, total.cacheWrite - (committed.cacheWrite ?? 0)) }
3369
+ };
3370
+ if ((cache.freshInput ?? 0) + (cache.cacheRead ?? 0) + (cache.cacheWrite ?? 0) > Math.max(0, total.input - committed.input)) return { cacheBreakdownKnown: false };
3371
+ return {
3372
+ ...cache,
3373
+ ...total.cacheBreakdownKnown === false ? { cacheBreakdownKnown: false } : {}
3374
+ };
3375
+ }
3355
3376
  function rootProviderModelEvidence(observations) {
3356
3377
  const attempts = Object.freeze(observations.map((model) => Object.freeze({ observations: Object.freeze(model === void 0 ? [] : [model]) })));
3357
3378
  const models = [...new Set(observations.filter((model) => model !== void 0))];
@@ -3373,4 +3394,4 @@ function rootProviderModelEvidenceFromExecution(evidence) {
3373
3394
  //#endregion
3374
3395
  export { mapExecutorResult as _, isPreSpawnExecutorFailure as a, withWorkerSpawnRetry as c, resolveSupervisorProfile as d, supervisorAgent as f, gateOnDeliverable as g, serveCoordinationMcp as h, workerFromBackend as i, assertCoordinationBinding as l, createSupervisorSpanRecorder 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 };
3375
3396
 
3376
- //# sourceMappingURL=supervise-CBYdifF2.js.map
3397
+ //# sourceMappingURL=supervise-l9fd1ZaI.js.map