@tangle-network/agent-runtime 0.115.0 → 0.116.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 (52) hide show
  1. package/dist/{activation-BNQQO-bc.js → activation-DuqQhee6.js} +2 -2
  2. package/dist/{activation-BNQQO-bc.js.map → activation-DuqQhee6.js.map} +1 -1
  3. package/dist/agent.d.ts +1 -1
  4. package/dist/agent.js +2 -2
  5. package/dist/{environment-provider-Cygthiy3.d.ts → environment-provider-CWsRh6Uz.d.ts} +365 -4
  6. package/dist/environment-provider.d.ts +1 -1
  7. package/dist/{improvement-cycle-CBLOgfsQ.js → improvement-cycle-C1cmjvPD.js} +3 -3
  8. package/dist/{improvement-cycle-CBLOgfsQ.js.map → improvement-cycle-C1cmjvPD.js.map} +1 -1
  9. package/dist/{index-BuzkRsOn.d.ts → index-COumPQka.d.ts} +49 -225
  10. package/dist/{index-I97xACXk.d.ts → index-CYkDeM5L.d.ts} +3 -3
  11. package/dist/{index-B_vcAAle.d.ts → index-DcLMNnG5.d.ts} +7 -6
  12. package/dist/index.d.ts +6 -7
  13. package/dist/index.js +7 -8
  14. package/dist/index.js.map +1 -1
  15. package/dist/intelligence.d.ts +3 -3
  16. package/dist/intelligence.js +3 -3
  17. package/dist/kernel.d.ts +4 -4
  18. package/dist/kernel.js +5 -5
  19. package/dist/{knowledge-DcIKJaPd.js → knowledge-DOzbywZT.js} +3 -3
  20. package/dist/{knowledge-DcIKJaPd.js.map → knowledge-DOzbywZT.js.map} +1 -1
  21. package/dist/knowledge.d.ts +1 -1
  22. package/dist/knowledge.js +1 -1
  23. package/dist/{local-harness-BnB1E9nM.d.ts → local-harness-t6cDWDQ2.d.ts} +3 -105
  24. package/dist/{loop-runner-bin-DgAXgQCI.d.ts → loop-runner-bin-BFrhPLKt.d.ts} +3 -3
  25. package/dist/{loop-runner-bin-C2GIqSUn.js → loop-runner-bin-BuQjc5DR.js} +3 -3
  26. package/dist/{loop-runner-bin-C2GIqSUn.js.map → loop-runner-bin-BuQjc5DR.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 +2 -2
  30. package/dist/mcp/index.d.ts +3 -2
  31. package/dist/mcp/index.js +4 -5
  32. package/dist/mcp/index.js.map +1 -1
  33. package/dist/{openai-tools-BWAEIHkZ.js → openai-tools-_Wyp4udO.js} +2 -2
  34. package/dist/{openai-tools-BWAEIHkZ.js.map → openai-tools-_Wyp4udO.js.map} +1 -1
  35. package/dist/primeintellect/index.d.ts +1 -1
  36. package/dist/{redact-BRaHUFMf.d.ts → redact-BEtQtvd6.d.ts} +2 -2
  37. package/dist/{runtime-C_g_SsXg.js → runtime-Ut1pkd2n.js} +4 -4
  38. package/dist/{runtime-C_g_SsXg.js.map → runtime-Ut1pkd2n.js.map} +1 -1
  39. package/dist/{structural-rollout-Cqm1dKa7.js → structural-rollout-CVY_0hJp.js} +2 -2
  40. package/dist/{structural-rollout-Cqm1dKa7.js.map → structural-rollout-CVY_0hJp.js.map} +1 -1
  41. package/dist/{supervise-BcCHhLrz.js → supervise-BUR9ByF7.js} +61 -22
  42. package/dist/supervise-BUR9ByF7.js.map +1 -0
  43. package/dist/{supervisor-CspDspod.js → supervisor-BBbPBXpe.js} +1019 -10
  44. package/dist/supervisor-BBbPBXpe.js.map +1 -0
  45. package/dist/testing.js +8 -8
  46. package/package.json +1 -1
  47. package/dist/otel-export-CPZTSADj.js +0 -852
  48. package/dist/otel-export-CPZTSADj.js.map +0 -1
  49. package/dist/supervise-BcCHhLrz.js.map +0 -1
  50. package/dist/supervisor-CspDspod.js.map +0 -1
  51. package/dist/trace-propagation-B-pL7xn_.js +0 -57
  52. package/dist/trace-propagation-B-pL7xn_.js.map +0 -1
@@ -1,10 +1,9 @@
1
1
  import { c as RuntimeRunStateError, i as ConfigError, o as NotFoundError, t as AgentEvalError$1, u as ValidationError } from "./errors-DEAvWQPy.js";
2
2
  import { a as mapWithConcurrency, c as sleep, d as throwIfAborted, f as withTimeout, l as stringifySafe, n as addTokenUsage, o as randomSuffix, p as zeroTokenUsage, r as deleteBoxSafe, s as randomUuid, t as abortError, u as throwAbort } from "./util-Cc9g9Y-o.js";
3
3
  import { a as contentAddress, i as InMemorySpawnJournal, n as FileSpawnJournal, r as InMemoryResultBlobStore, t as FileResultBlobStore } from "./spawn-journal-DCPbicXB.js";
4
- import { A as captureWorktreeDiff, C as routerChatWithUsage, E as runBrainLoop, M as removeWorktree, O as runWorktreeChecks, a as runFinalizer, i as pickBestDelivered, j as createWorktree, k as runWorktreeHarness, l as withDriverExecutor, n as bestDelivered, o as runTree, t as createSupervisor, x as routerBrain, y as createActivityLog } from "./supervisor-CspDspod.js";
4
+ import { $ as removeWorktree, B as createActivityLog, D as toOtelAttributes, H as routerBrain, Q as createWorktree, S as createOtelExporter, T as generateSpanId, W as routerChatWithUsage, X as runWorktreeHarness, Y as runWorktreeChecks, Z as captureWorktreeDiff, a as runFinalizer, b as buildLoopSpanNodes, i as pickBestDelivered, l as withDriverExecutor, m as workerTraceSeamKey, n as bestDelivered, o as runTree, p as workerTraceEnv, q as runBrainLoop, t as createSupervisor } from "./supervisor-BBbPBXpe.js";
5
5
  import { i as notifyRuntimeHookEvent, t as composeRuntimeHooks } from "./runtime-hooks-C7iJOWm3.js";
6
6
  import { a as notifySandboxEventObserver, n as extractLlmCallEvent } from "./sandbox-events-DeI5xX8P.js";
7
- import { a as createOtelExporter, c as generateSpanId, r as buildLoopSpanNodes, u as toOtelAttributes } from "./otel-export-CPZTSADj.js";
8
7
  import { i as resolveAgentEnvironmentProvider, n as providerAsExecutor, s as buildBackendOptions } from "./environment-provider-CCaEhA-l.js";
9
8
  import { t as createStdioToolServer } from "./tool-server-RcWgLIsL.js";
10
9
  import { n as UI_LENSES } from "./substrate-B0TYNrXn.js";
@@ -282,6 +281,12 @@ function createSupervisorSpanRecorder(opts) {
282
281
  } },
283
282
  traceId,
284
283
  rootSpanId,
284
+ workerTrace(spawningNodeId) {
285
+ return {
286
+ traceId,
287
+ parentSpanId: spanIdOf.get(spawningNodeId) ?? rootSpanId
288
+ };
289
+ },
285
290
  async finish(outcome) {
286
291
  if (finished) return;
287
292
  finished = true;
@@ -2238,6 +2243,7 @@ const piSeamKey = "pi";
2238
2243
  /** Build the `Executor` for one pi worker. Registered as runtime `'pi'`. */
2239
2244
  const piExecutor = (spec, ctx) => {
2240
2245
  const seam = readPiSeam(ctx);
2246
+ const traceEnv = workerTraceEnv(ctx);
2241
2247
  const inbox = createInbox();
2242
2248
  const activity = createActivityLog(seam.activityWindow ?? 12);
2243
2249
  const runId = `pi-${spec.profile.name ?? "worker"}-${Date.now()}`;
@@ -2271,6 +2277,7 @@ const piExecutor = (spec, ctx) => {
2271
2277
  signal,
2272
2278
  controller,
2273
2279
  seam,
2280
+ traceEnv,
2274
2281
  spec,
2275
2282
  runId,
2276
2283
  inbox,
@@ -2329,7 +2336,7 @@ async function* streamPiSession(args) {
2329
2336
  }
2330
2337
  let proc;
2331
2338
  try {
2332
- proc = spawnPi(seam, piMcp.args);
2339
+ proc = spawnPi(seam, piMcp.args, args.traceEnv);
2333
2340
  } catch (spawnFailure) {
2334
2341
  piMcp.mount?.cleanup();
2335
2342
  throw spawnFailure;
@@ -2649,8 +2656,14 @@ function taskText(task) {
2649
2656
  * the profile-derived extension flags (`--no-extensions` / `--extension`). Seam args go LAST so an
2650
2657
  * operator's explicit flag wins over a derived one under pi's last-flag-wins parsing; RPC mode has
2651
2658
  * no positional prompt, so nothing here has to precede an argument.
2659
+ *
2660
+ * `traceEnv` is the inherited `TRACE_ID` / `PARENT_SPAN_ID` pair (empty when the run records no
2661
+ * spans). It sits ABOVE the supervisor's ambient `process.env` — a supervisor that was itself
2662
+ * launched as someone's worker holds ids describing ITS place in an outer trace, which are the
2663
+ * wrong parent for this child — and BELOW `seam.env`, so an operator who sets either id explicitly
2664
+ * still wins. See `worker-trace.ts` for the full precedence rule.
2652
2665
  */
2653
- function spawnPi(seam, profileArgs = []) {
2666
+ function spawnPi(seam, profileArgs = [], traceEnv = {}) {
2654
2667
  const bin = seam.bin ?? "pi";
2655
2668
  const argv = ["--mode", "rpc"];
2656
2669
  if (seam.model) {
@@ -2664,6 +2677,7 @@ function spawnPi(seam, profileArgs = []) {
2664
2677
  ...seam.cwd ? { cwd: seam.cwd } : {},
2665
2678
  env: {
2666
2679
  ...process.env,
2680
+ ...traceEnv,
2667
2681
  ...seam.env ?? {}
2668
2682
  },
2669
2683
  stdio: [
@@ -2810,7 +2824,10 @@ function createSteerableSandboxSession(args) {
2810
2824
  profile: args.profile,
2811
2825
  taskToPrompt: args.taskToPrompt,
2812
2826
  name: args.profile.name ?? String(args.harness),
2813
- sandboxOverrides: { backend: { type: args.harness } }
2827
+ sandboxOverrides: {
2828
+ backend: { type: args.harness },
2829
+ ...args.traceEnv && Object.keys(args.traceEnv).length > 0 ? { env: args.traceEnv } : {}
2830
+ }
2814
2831
  };
2815
2832
  const promptOptions = readPromptOptions(args.loopCtx);
2816
2833
  const started = now();
@@ -3420,6 +3437,7 @@ const sandboxExecutor = (spec, ctx) => {
3420
3437
  if (!seam.sandboxClient || typeof seam.sandboxClient.create !== "function") throw new ValidationError("sandboxExecutor: SandboxSeam.sandboxClient.create required");
3421
3438
  const maxIterations = seam.maxIterations ?? 1;
3422
3439
  if (!Number.isFinite(maxIterations) || maxIterations <= 0) throw new ValidationError("sandboxExecutor: maxIterations must be > 0");
3440
+ const traceEnv = workerTraceEnv(ctx);
3423
3441
  const controller = new AbortController();
3424
3442
  const abortIfSignalled = () => {
3425
3443
  if (ctx.signal.aborted) controller.abort();
@@ -3438,6 +3456,7 @@ const sandboxExecutor = (spec, ctx) => {
3438
3456
  taskToPrompt: (t) => taskToPrompt(t),
3439
3457
  options: seam.steering,
3440
3458
  ...seam.loopCtx ? { loopCtx: seam.loopCtx } : {},
3459
+ ...Object.keys(traceEnv).length > 0 ? { traceEnv } : {},
3441
3460
  contentRef
3442
3461
  });
3443
3462
  return {
@@ -3478,6 +3497,7 @@ const sandboxExecutor = (spec, ctx) => {
3478
3497
  maxIterations,
3479
3498
  controller,
3480
3499
  loopCtx: seam.loopCtx,
3500
+ traceEnv,
3481
3501
  onArtifact: (a) => {
3482
3502
  artifact = a;
3483
3503
  }
@@ -3505,7 +3525,10 @@ async function* streamSandboxLeaf(args) {
3505
3525
  profile: args.spec.profile,
3506
3526
  taskToPrompt: (t) => taskToPrompt(t),
3507
3527
  name: args.spec.profile.name ?? args.harness,
3508
- sandboxOverrides: { backend: { type: args.harness } }
3528
+ sandboxOverrides: {
3529
+ backend: { type: args.harness },
3530
+ ...Object.keys(args.traceEnv).length > 0 ? { env: args.traceEnv } : {}
3531
+ }
3509
3532
  };
3510
3533
  const started = Date.now();
3511
3534
  const loopOptions = {
@@ -3569,6 +3592,7 @@ async function* streamSandboxLeaf(args) {
3569
3592
  const cliExecutor = (_spec, ctx) => {
3570
3593
  const seam = readSeam(ctx, cliSeamKey, "cli");
3571
3594
  if (!seam.bin) throw new ValidationError("cliExecutor: CliSeam.bin required");
3595
+ const traceEnv = workerTraceEnv(ctx);
3572
3596
  const controller = new AbortController();
3573
3597
  const abortIfSignalled = () => {
3574
3598
  if (ctx.signal.aborted) controller.abort();
@@ -3584,6 +3608,7 @@ const cliExecutor = (_spec, ctx) => {
3584
3608
  return streamCliLeaf({
3585
3609
  task,
3586
3610
  signal,
3611
+ traceEnv,
3587
3612
  seam,
3588
3613
  controller,
3589
3614
  onProc: (p) => {
@@ -3611,6 +3636,7 @@ async function* streamCliLeaf(args) {
3611
3636
  ...args.seam.cwd ? { cwd: args.seam.cwd } : {},
3612
3637
  env: {
3613
3638
  ...process.env,
3639
+ ...args.traceEnv,
3614
3640
  ...args.seam.env ?? {}
3615
3641
  },
3616
3642
  stdio: [
@@ -8573,10 +8599,20 @@ function routerBrainFromProfile(profile, deps) {
8573
8599
  }
8574
8600
  //#endregion
8575
8601
  //#region src/runtime/supervise/supervise.ts
8576
- /** Build the worker seam from a backend (WHERE workers run) + an optional completion oracle (the
8577
- * deliverable check that makes "settled delivered" true the guard against "ran but didn't
8578
- * deliver"). The ONE place a backend becomes a spawnable worker. */
8579
- function workerFromBackend(backend, deliverable) {
8602
+ /**
8603
+ * Build the worker seam from a backend (WHERE workers run) + an optional completion oracle (the
8604
+ * deliverable check that makes "settled delivered" true the guard against "ran but didn't
8605
+ * deliver"). The ONE place a backend becomes a spawnable worker.
8606
+ *
8607
+ * `seams` exists because this path builds the leaf executor EAGERLY and hands it back as a BYO
8608
+ * `executorSpec.executor`. The registry resolves a BYO executor without ever consulting the
8609
+ * per-child `ExecutorContext` the `Scope` seeds, so anything the scope would have supplied is
8610
+ * invisible here and has to be passed in. It is a FUNCTION because it is resolved once per worker
8611
+ * construction, so a caller may hand back something the run only learns later — which is exactly how
8612
+ * `supervise()` gives a traced run's workers their trace context without ordering the span recorder
8613
+ * ahead of the worker seam.
8614
+ */
8615
+ function workerFromBackend(backend, deliverable, seams) {
8580
8616
  return (rawProfile) => {
8581
8617
  const p = rawProfile ?? {};
8582
8618
  const name = typeof p.name === "string" && p.name.length > 0 ? p.name : "worker";
@@ -8586,7 +8622,7 @@ function workerFromBackend(backend, deliverable) {
8586
8622
  };
8587
8623
  const ctx = {
8588
8624
  signal: new AbortController().signal,
8589
- seams: {}
8625
+ seams: seams?.() ?? {}
8590
8626
  };
8591
8627
  const built = createExecutor(backend)(spec, ctx);
8592
8628
  const executor = deliverable ? gateOnDeliverable(built, deliverable) : built;
@@ -8633,15 +8669,16 @@ function supervise(profile, task, opts) {
8633
8669
  const ctx = opts.runDir !== void 0 ? createFileRunContext(opts.runDir, { withDriver: true }) : createInMemoryRunContext({ withDriver: true });
8634
8670
  const blobs = opts.blobs ?? ctx.blobs;
8635
8671
  const perWorker = opts.perWorker ?? defaultPerWorker(opts.budget);
8672
+ const runId = opts.runId ?? "supervise";
8673
+ const log = ctx.coordinationLog;
8674
+ const now = opts.now ?? Date.now;
8675
+ let spans;
8636
8676
  let makeWorkerAgent = opts.makeWorkerAgent;
8637
8677
  if (!makeWorkerAgent) {
8638
8678
  if (!opts.backend) throw new ValidationError("supervise: provide opts.backend (where workers run) or opts.makeWorkerAgent");
8639
- makeWorkerAgent = workerFromBackend(opts.backend, deliverable);
8679
+ makeWorkerAgent = workerFromBackend(opts.backend, deliverable, () => spans ? { [workerTraceSeamKey]: spans.workerTrace(runId) } : {});
8640
8680
  }
8641
8681
  const workerFactory = makeWorkerAgent;
8642
- const runId = opts.runId ?? "supervise";
8643
- const log = ctx.coordinationLog;
8644
- const now = opts.now ?? Date.now;
8645
8682
  const start = async () => {
8646
8683
  const priorCoordination = log ? await log.load(runId) : void 0;
8647
8684
  const agent = supervisorAgent(profile, {
@@ -8668,12 +8705,13 @@ function supervise(profile, task, opts) {
8668
8705
  ...opts.maxTurns !== void 0 ? { maxTurns: opts.maxTurns } : {},
8669
8706
  ...opts.compaction ? { compaction: opts.compaction } : {}
8670
8707
  });
8671
- const spans = opts.otel ? createSupervisorSpanRecorder({
8708
+ spans = opts.otel ? createSupervisorSpanRecorder({
8672
8709
  runId,
8673
8710
  ...opts.otel,
8674
8711
  now
8675
8712
  }) : void 0;
8676
- const hooks = spans ? composeRuntimeHooks(opts.hooks, spans.hooks) : opts.hooks;
8713
+ const recorder = spans;
8714
+ const hooks = recorder ? composeRuntimeHooks(opts.hooks, recorder.hooks) : opts.hooks;
8677
8715
  const run = createSupervisor().run(agent, task, {
8678
8716
  budget: opts.budget,
8679
8717
  runId,
@@ -8684,15 +8722,16 @@ function supervise(profile, task, opts) {
8684
8722
  ...probes ? { probes } : {},
8685
8723
  ...ctx.resume === true ? { resume: true } : {},
8686
8724
  ...opts.now ? { now: opts.now } : {},
8687
- ...hooks ? { hooks } : {}
8725
+ ...hooks ? { hooks } : {},
8726
+ ...recorder ? { workerTrace: recorder.workerTrace } : {}
8688
8727
  });
8689
- if (!spans) return run;
8728
+ if (!recorder) return run;
8690
8729
  try {
8691
8730
  const result = await run;
8692
- await spans.finish({ result });
8731
+ await recorder.finish({ result });
8693
8732
  return result;
8694
8733
  } catch (error) {
8695
- await spans.finish({ error });
8734
+ await recorder.finish({ error });
8696
8735
  throw error;
8697
8736
  }
8698
8737
  };
@@ -8701,4 +8740,4 @@ function supervise(profile, task, opts) {
8701
8740
  //#endregion
8702
8741
  export { InMemoryDelegationStore as $, FileCoordinationLog as $t, DELEGATE_INPUT_SCHEMA as A, createWorktreeCliExecutor as At, profileRichnessFinding as B, PI_MCP_ADAPTER_ENV as Bt, validateDelegateUiAuditArgs as C, defaultToolDetectors as Ct, createDelegateFeedbackHandler as D, cliWorktreeExecutor as Dt, DELEGATE_FEEDBACK_TOOL_NAME as E, createInMemoryRunContext as Et, delegate as F, piSeamKey as Ft, DELEGATION_TRACE_MAX_SPANS as G, createInbox as Gt, DelegationTaskQueue as H, buildPiMcpServers as Ht, asAuthoredProfile as I, createPushTraceSource as It, composeLoopTraceEmitters as J, runAgentRounds as Jt, buildDelegationTraceSpans as K, createSandboxForSpec as Kt, assessAuthoredProfile as L, decodeToolPart as Lt, createDelegateHandler as M, createSteerableSandboxSession as Mt, validateDelegateArgs as N, PI_RUNTIME as Nt, validateDelegateFeedbackArgs as O, createExecutor as Ot, defaultDelegateBudget as P, piExecutor as Pt, FileDelegationStore as Q, acquireSandbox as Qt, authoredWorker as R, sandboxSessionTraceSource as Rt, createDelegateUiAuditHandler as S, rollingDispatch as St, DELEGATE_FEEDBACK_INPUT_SCHEMA as T, createFileRunContext as Tt, hashIdempotencyInput as U, piMcpAdapterAvailable as Ut, supervisorInstructions as V, PI_MCP_CONFIG_FLAG as Vt, DELEGATION_TRACE_MAX_BYTES as W, preparePiMcp as Wt, DelegationPersistenceError as X, createSandboxLineage as Xt, createDelegationTraceCollector as Y, runLoop as Yt, DelegationStateCorruptError as Z, probeSandboxCapabilities as Zt, createDelegationHistoryHandler as _, createCoordinationTools as _t, supervisorAgent as a, allWorkersStalled as at, DELEGATE_UI_AUDIT_INPUT_SCHEMA as b, freeSlots as bt, createMcpServer as c, noProgressFor as ct, DELEGATION_STATUS_TOOL_NAME as d, anytimeReport as dt, createSupervisorSpanRecorder as en, InMemoryFeedbackStore as et, createDelegationStatusHandler as f, areaUnderCurve as ft, DELEGATION_HISTORY_TOOL_NAME as g, DEFAULT_AWAIT_EVENT_TIMEOUT_MS as gt, DELEGATION_HISTORY_INPUT_SCHEMA as h, renderAnytimeTable as ht, resolveSupervisorProfile as i, allOf as it, DELEGATE_TOOL_NAME as j, DEFAULT_SANDBOX_STEERING_MAX_TURNS as jt, DELEGATE_DESCRIPTION as k, createExecutorRegistry as kt, DELEGATION_STATUS_DESCRIPTION as l, plateau as lt, DELEGATION_HISTORY_DESCRIPTION as m, plateauLength as mt, workerFromBackend as n, gateOnDeliverable as nn, driverAgent as nt, serveCoordinationMcp as o, anyOf as ot, validateDelegationStatusArgs as p, bestSoFar as pt, capDelegationTrace as q, defaultSelectWinner as qt, assertCoordinationBinding as r, finalizeBestDelivered as rt, createInProcessTransport as s, createProgressTracker as st, supervise as t, assertModelAllowed as tn, eventToSnapshot as tt, DELEGATION_STATUS_INPUT_SCHEMA as u, sampleFromSettled as ut, validateDelegationHistoryArgs as v, createEventBus as vt, DELEGATE_FEEDBACK_DESCRIPTION as w, watchTrace as wt, DELEGATE_UI_AUDIT_TOOL_NAME as x, queueOf as xt, DELEGATE_UI_AUDIT_DESCRIPTION as y, effectiveConcurrency as yt, defaultProfileRichnessThresholds as z, PI_MCP_ADAPTER as zt };
8703
8742
 
8704
- //# sourceMappingURL=supervise-BcCHhLrz.js.map
8743
+ //# sourceMappingURL=supervise-BUR9ByF7.js.map