@tangle-network/agent-runtime 0.123.1 → 0.126.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 (32) hide show
  1. package/dist/agent.d.ts +1 -1
  2. package/dist/agent.js +2 -2
  3. package/dist/{index-4NcThsDc.d.ts → index-DIV33AF5.d.ts} +2 -2
  4. package/dist/{index-CQBioeAj.d.ts → index-D_M4d1_B.d.ts} +4 -4
  5. package/dist/{index-xP27vtnt.d.ts → index-EdjCQBV9.d.ts} +51 -127
  6. package/dist/index.d.ts +4 -4
  7. package/dist/index.js +4 -4
  8. package/dist/kernel.d.ts +2 -2
  9. package/dist/kernel.js +3 -3
  10. package/dist/{knowledge-BOHj6nGh.js → knowledge-EnuEqm_Y.js} +2 -2
  11. package/dist/{knowledge-BOHj6nGh.js.map → knowledge-EnuEqm_Y.js.map} +1 -1
  12. package/dist/knowledge.d.ts +1 -1
  13. package/dist/knowledge.js +1 -1
  14. package/dist/{loop-runner-bin-DMnNxZHw.d.ts → loop-runner-bin-Bo29_fiD.d.ts} +2 -2
  15. package/dist/{loop-runner-bin-DUM37LLw.js → loop-runner-bin-qwT_4F5I.js} +3 -3
  16. package/dist/{loop-runner-bin-DUM37LLw.js.map → loop-runner-bin-qwT_4F5I.js.map} +1 -1
  17. package/dist/loop-runner-bin.d.ts +1 -1
  18. package/dist/loop-runner-bin.js +1 -1
  19. package/dist/mcp/bin.js +1 -1
  20. package/dist/mcp/index.d.ts +1 -1
  21. package/dist/mcp/index.js +3 -3
  22. package/dist/{openai-tools-Bm1SDJIp.js → openai-tools-Bp1KSkP6.js} +2 -2
  23. package/dist/{openai-tools-Bm1SDJIp.js.map → openai-tools-Bp1KSkP6.js.map} +1 -1
  24. package/dist/primeintellect/index.d.ts +1 -1
  25. package/dist/{runtime-DZblIf3R.js → runtime-BzXz7OjS.js} +85 -124
  26. package/dist/runtime-BzXz7OjS.js.map +1 -0
  27. package/dist/{supervise-Cx24b3lw.js → supervise-Ds8FtyI9.js} +111 -8
  28. package/dist/supervise-Ds8FtyI9.js.map +1 -0
  29. package/dist/testing.js +8 -8
  30. package/package.json +4 -4
  31. package/dist/runtime-DZblIf3R.js.map +0 -1
  32. package/dist/supervise-Cx24b3lw.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import { c as RuntimeRunStateError, i as ConfigError, o as NotFoundError, t as AgentEvalError$1, u as ValidationError } from "./errors-DEAvWQPy.js";
2
- import { S as detachedSnapshot, b as workerTraceAnalysisStore, d as writeAllBytes, i as InMemorySpawnJournal, l as parseCommittedJsonLines, n as FileSpawnJournal, r as InMemoryResultBlobStore, t as FileResultBlobStore, u as prepareJsonlAppend, x as contentAddress } from "./spawn-journal-DsZKDqeh.js";
2
+ import { S as detachedSnapshot, b as workerTraceAnalysisStore, d as writeAllBytes, i as InMemorySpawnJournal, l as parseCommittedJsonLines, n as FileSpawnJournal, r as InMemoryResultBlobStore, t as FileResultBlobStore, u as prepareJsonlAppend, x as contentAddress, y as parseWorkerToolTraceArtifact } from "./spawn-journal-DsZKDqeh.js";
3
3
  import { a as randomSuffix, c as stringifySafe, d as withTimeout, f as zeroTokenUsage, i as mapWithConcurrency, l as throwAbort, n as deleteBoxSafe, o as randomUuid, s as sleep, t as addTokenUsage, u as throwIfAborted } from "./util-MVgdwuIS.js";
4
4
  import { $t as concreteProfileModel, At as controlProfileMaterialization, Ct as runWorktreeHarness, Dt as removeWorktree, Et as createWorktree, F as toOtelAttributes, Ft as promptModelProfileMaterialization, J as createActivityLog, Mt as fullProfileMaterialization, Nt as profileMaterializationAxes, O as createOtelExporter, Pt as promptControlProfileMaterialization, Q as freeSlots, Qt as concreteModelId, St as runWorktreeChecks, T as buildLoopSpanNodes, Tt as captureWorktreeDiff, Vt as worktreeCliProfileMaterialization, Xt as assertModelAllowed, Y as describeToolArgs, Zt as assertProfileModelsAllowed, _ as workerTraceEnv, _t as routerChatWithUsage, a as pickBestDelivered, at as assertValidBudget, b as mergeTraceEnv, bt as runBrainLoop, c as driverChild, ct as attestRuntimeOwnedExecutor, d as deriveNodeExecutionIdentity, dt as newExecutionAttemptId, en as isHarnessNativeModel, f as recordScopeOwnerMaterialization, ft as runtimeOwnedExecutorExecutionBinding, h as WORKER_TRACE_PROPAGATION, ht as routerBrain, it as workerTokenFloor, j as generateSpanId, jt as defineProfileMaterializationContract, kt as assertProfileMaterialization, l as withDriverExecutor, lt as attestRuntimeOwnedScopeOwner, mt as runtimeOwnedScopeOwnerRuntime, n as createSupervisor, nt as teardownExecutor, o as runFinalizer, p as scopeOwnerExecutorNodeContext, pt as runtimeOwnedExecutorMaterialization, r as bestDelivered, rt as WORKER_TOKEN_FLOOR, s as runTree, st as spendFromUsageEvents, tn as profileForExecution, tt as DEFAULT_SUCCESSFUL_SHUTDOWN_MS, ut as inheritRuntimeOwnedExecutorAttestation, wt as worktreeProfileExecutionPlan } from "./supervisor-DpjO0Gmy.js";
5
5
  import { i as notifyRuntimeHookEvent, t as composeRuntimeHooks } from "./runtime-hooks-C7iJOWm3.js";
@@ -5472,6 +5472,81 @@ function createCoordinationTools(opts) {
5472
5472
  unwatchWorker(w.id);
5473
5473
  };
5474
5474
  let pendingSettlement;
5475
+ const analystRuns = /* @__PURE__ */ new Map();
5476
+ let analystRunOrdinal = 0;
5477
+ /** The `finding` event an analyst-agent settlement becomes: its settle OUTPUT is the findings
5478
+ * (a failed run publishes the failure as findings — degraded beats vanished). */
5479
+ const analystRunFinding = (run, settled) => deepFreezeDetached({
5480
+ type: "finding",
5481
+ finding: canonicalFindingEvent({
5482
+ fromWorker: run.sourceWorker,
5483
+ analyst: run.route.kind,
5484
+ findings: settled.kind === "done" ? settled.out : { analystRunFailed: settled.reason }
5485
+ })
5486
+ });
5487
+ /**
5488
+ * Spawn one analyst-AGENT run over a settled worker's evidence, through the SAME spawn
5489
+ * machinery a driver spawn uses (`scope.spawn` + `makeWorkerAgent`): the analyst's spend
5490
+ * reserves from the conserved pool, its node is journaled/traced like any worker, and a
5491
+ * node-pinning seam sees `context.analyst`. Its task is the route directive plus the settled
5492
+ * worker's persisted tool-trace spans. A refused spawn publishes a finding RECORDING the
5493
+ * refusal — observable, never silent — and must never take down the settlement path.
5494
+ */
5495
+ const spawnAnalystRun = async (route, worker) => {
5496
+ let spansText = "";
5497
+ let spanCount = 0;
5498
+ if (worker.trace.status === "available") try {
5499
+ const artifact = parseWorkerToolTraceArtifact(await opts.blobs.get(worker.trace.traceRef), worker.trace.traceRef);
5500
+ spanCount = artifact.spans.length;
5501
+ spansText = safeJsonText(artifact.spans);
5502
+ } catch {
5503
+ spansText = "";
5504
+ }
5505
+ const task = [
5506
+ ...route.directive === void 0 || route.directive.length === 0 ? [] : [route.directive],
5507
+ `Evidence — settled worker '${worker.id}' tool trace (${spanCount} spans):`,
5508
+ spansText.length === 0 ? "(no tool spans available)" : spansText
5509
+ ].join("\n\n");
5510
+ const assignmentId = `analyst:${route.kind}:o${analystRunOrdinal++}`;
5511
+ const label = `analyst:${route.kind}`;
5512
+ const context = Object.freeze({
5513
+ assignmentId,
5514
+ parentNodeId: opts.scope.view.root,
5515
+ budget: opts.perWorker,
5516
+ task,
5517
+ label,
5518
+ analyst: route.kind
5519
+ });
5520
+ let refusal;
5521
+ let spawnedId;
5522
+ try {
5523
+ const res = opts.scope.spawn(() => opts.makeWorkerAgent(route.agent, context), task, {
5524
+ budget: opts.perWorker,
5525
+ label,
5526
+ assignmentId
5527
+ });
5528
+ if (res.ok) spawnedId = res.handle.id;
5529
+ else refusal = String(res.reason);
5530
+ } catch (cause) {
5531
+ refusal = cause instanceof Error ? cause.message : String(cause);
5532
+ }
5533
+ if (spawnedId === void 0) {
5534
+ await bus.publish({
5535
+ type: "finding",
5536
+ finding: canonicalFindingEvent({
5537
+ fromWorker: worker.id,
5538
+ analyst: route.kind,
5539
+ findings: { analystSpawnRefused: refusal ?? "unknown" }
5540
+ })
5541
+ });
5542
+ return;
5543
+ }
5544
+ analystRuns.set(spawnedId, {
5545
+ route,
5546
+ sourceWorker: worker.id
5547
+ });
5548
+ watchWorker(spawnedId);
5549
+ };
5475
5550
  const workerRouteNames = (workerId) => {
5476
5551
  const names = /* @__PURE__ */ new Set();
5477
5552
  const profileName = profileNameByWorker.get(workerId);
@@ -5543,15 +5618,28 @@ function createCoordinationTools(opts) {
5543
5618
  const pending = pendingSettlement;
5544
5619
  if (!pending) return false;
5545
5620
  await bus.publish(pending.event);
5621
+ if (pending.analystRun) {
5622
+ analystRuns.delete(pending.worker.id);
5623
+ unwatchWorker(pending.worker.id);
5624
+ pendingSettlement = void 0;
5625
+ const { route } = pending.analystRun;
5626
+ if (route.to !== void 0 && pending.event.type === "finding") await deliverRoutedFinding({
5627
+ kind: route.kind,
5628
+ to: route.to
5629
+ }, pending.event.finding.findings);
5630
+ return true;
5631
+ }
5546
5632
  commitSettled(pending.settled, pending.worker);
5547
5633
  pendingSettlement = void 0;
5548
- if (pending.analyze && pending.worker.status === "done" && pending.worker.trace.status === "available" && opts.analysts && opts.analyzeOnSettle?.length) {
5634
+ if (pending.analyze && pending.worker.status === "done" && pending.worker.trace.status === "available" && opts.analyzeOnSettle?.length) {
5549
5635
  const routes = opts.analyzeOnSettle.map(normalizeAnalyzeOnSettle);
5550
5636
  const sourceNames = workerRouteNames(pending.worker.id);
5551
5637
  const applicable = routes.filter((route) => route.over === void 0 || route.over.some((name) => sourceNames.has(name)));
5552
- if (applicable.length > 0) {
5638
+ const lensRoutes = applicable.filter((route) => route.agent === void 0);
5639
+ const agentRoutes = applicable.filter((route) => route.agent !== void 0);
5640
+ if (lensRoutes.length > 0 && opts.analysts) {
5553
5641
  const trace = await workerTraceAnalysisStore(pending.worker.trace, opts.blobs);
5554
- for (const route of applicable) {
5642
+ for (const route of lensRoutes) {
5555
5643
  const findings = await opts.analysts.run(route.kind, trace);
5556
5644
  await bus.publish({
5557
5645
  type: "finding",
@@ -5564,6 +5652,7 @@ function createCoordinationTools(opts) {
5564
5652
  if (route.to !== void 0) await deliverRoutedFinding(route, findings);
5565
5653
  }
5566
5654
  }
5655
+ for (const route of agentRoutes) await spawnAnalystRun(route, pending.worker);
5567
5656
  }
5568
5657
  return true;
5569
5658
  };
@@ -5572,7 +5661,14 @@ function createCoordinationTools(opts) {
5572
5661
  const settled = await opts.scope.next();
5573
5662
  if (!settled) return false;
5574
5663
  const worker = projectSettled(settled);
5575
- pendingSettlement = {
5664
+ const run = analystRuns.get(settled.handle.id);
5665
+ pendingSettlement = run ? {
5666
+ settled,
5667
+ worker,
5668
+ event: analystRunFinding(run, settled),
5669
+ analyze: false,
5670
+ analystRun: run
5671
+ } : {
5576
5672
  settled,
5577
5673
  worker,
5578
5674
  event: deepFreezeDetached({
@@ -5591,7 +5687,14 @@ function createCoordinationTools(opts) {
5591
5687
  const settled = await opts.scope.nextResolved();
5592
5688
  if (!settled) return drained;
5593
5689
  const worker = projectSettled(settled);
5594
- pendingSettlement = {
5690
+ const run = analystRuns.get(settled.handle.id);
5691
+ pendingSettlement = run ? {
5692
+ settled,
5693
+ worker,
5694
+ event: analystRunFinding(run, settled),
5695
+ analyze: false,
5696
+ analystRun: run
5697
+ } : {
5595
5698
  settled,
5596
5699
  worker,
5597
5700
  event: deepFreezeDetached({
@@ -6894,7 +6997,7 @@ function progressStop(tracker, rule, coord, scope, now, stallAfterMs) {
6894
6997
  function driverAgent(opts) {
6895
6998
  if (typeof opts.brain !== "function") throw new ValidationError("driverAgent: opts.brain must be a function");
6896
6999
  if ((opts.extraTools?.length ?? 0) > 0 && typeof opts.executeExtraTool !== "function") throw new ValidationError("driverAgent: extraTools requires executeExtraTool (how to run a work-tool call)");
6897
- if ((opts.analyzeOnSettle?.length ?? 0) > 0 && !opts.analysts) throw new ValidationError("driverAgent: analyzeOnSettle requires analysts (the lens registry the kinds resolve against)");
7000
+ if ((opts.analyzeOnSettle ?? []).map(normalizeAnalyzeOnSettle).some((route) => route.agent === void 0) && !opts.analysts) throw new ValidationError("driverAgent: analyzeOnSettle requires analysts (the lens registry the kinds resolve against)");
6898
7001
  const reserved = new Set(coordinationVerbNames);
6899
7002
  for (const tool of opts.nodeTools ?? []) {
6900
7003
  if (reserved.has(tool.name)) throw new ValidationError(`driverAgent: node tool "${tool.name}" collides with a coordination verb or another node tool`);
@@ -10110,4 +10213,4 @@ function supervise(profile, task, opts) {
10110
10213
  //#endregion
10111
10214
  export { allOf as $, naiveContinuationPrompt as $t, DELEGATE_DESCRIPTION as A, createSandboxForSpec as At, DELEGATION_TRACE_MAX_SPANS as B, assessAuthoredProfile as Bt, createDelegateUiAuditHandler as C, createWorktreeCliExecutor as Ct, DELEGATE_FEEDBACK_TOOL_NAME as D, decodeToolPart as Dt, DELEGATE_FEEDBACK_INPUT_SCHEMA as E, createPushTraceSource as Et, defaultDelegateBudget as F, probeSandboxCapabilities as Ft, DelegationPersistenceError as G, supervisorInstructions as Gt, capDelegationTrace as H, canonicalizeAuthoredProfile as Ht, delegate as I, acquireSandbox as It, InMemoryDelegationStore as J, delegatesWorkerBriefPrompt as Jt, DelegationStateCorruptError as K, analyzesFindingsReportPrompt as Kt, DelegationTaskQueue as L, FileCoordinationLog as Lt, DELEGATE_TOOL_NAME as M, runAgentRounds as Mt, createDelegateHandler as N, runLoop as Nt, createDelegateFeedbackHandler as O, sandboxSessionTraceSource as Ot, validateDelegateArgs as P, createSandboxLineage as Pt, finalizeBestDelivered as Q, kernelPromptRegistry as Qt, hashIdempotencyInput as R, createSupervisorSpanRecorder as Rt, DELEGATE_UI_AUDIT_TOOL_NAME as S, createExecutorRegistry as St, DELEGATE_FEEDBACK_DESCRIPTION as T, createSteerableSandboxSession as Tt, composeLoopTraceEmitters as U, defaultProfileRichnessThresholds as Ut, buildDelegationTraceSpans as V, authoredWorker as Vt, createDelegationTraceCollector as W, profileRichnessFinding as Wt, eventToSnapshot as X, dumbContinuationPassPrompt as Xt, InMemoryFeedbackStore as Y, dumbContinuationFailPrompt as Yt, driverAgent as Z, formatPromptHandle as Zt, DELEGATION_HISTORY_TOOL_NAME as _, watchTrace as _t, resolveSupervisorProfile as a, sampleFromSettled as at, DELEGATE_UI_AUDIT_DESCRIPTION as b, cliWorktreeExecutor as bt, createInProcessTransport as c, bestSoFar as ct, DELEGATION_STATUS_INPUT_SCHEMA as d, DEFAULT_AWAIT_EVENT_TIMEOUT_MS as dt, promptHandle as en, allWorkersStalled as et, DELEGATION_STATUS_TOOL_NAME as f, canonicalFindingEvent as ft, DELEGATION_HISTORY_INPUT_SCHEMA as g, defaultToolDetectors as gt, DELEGATION_HISTORY_DESCRIPTION as h, createEventBus as ht, assertCoordinationBinding as i, plateau as it, DELEGATE_INPUT_SCHEMA as j, defaultSelectWinner as jt, validateDelegateFeedbackArgs as k, createInbox as kt, createMcpServer as l, plateauLength as lt, validateDelegationStatusArgs as m, normalizeAnalyzeOnSettle as mt, supervise as n, gateOnDeliverable as nn, createProgressTracker as nt, supervisorAgent as o, anytimeReport as ot, createDelegationStatusHandler as p, createCoordinationTools as pt, FileDelegationStore as q, createPromptRegistry as qt, workerFromBackend as r, noProgressFor as rt, serveCoordinationMcp as s, areaUnderCurve as st, DEFAULT_AUTHORED_PROFILE_SECURITY_POLICY as t, supervisorPolicyPrompt as tn, anyOf as tt, DELEGATION_STATUS_DESCRIPTION as u, renderAnytimeTable as ut, createDelegationHistoryHandler as v, createFileRunContext as vt, validateDelegateUiAuditArgs as w, DEFAULT_SANDBOX_STEERING_MAX_TURNS as wt, DELEGATE_UI_AUDIT_INPUT_SCHEMA as x, createExecutor as xt, validateDelegationHistoryArgs as y, createInMemoryRunContext as yt, DELEGATION_TRACE_MAX_BYTES as z, asAuthoredProfile as zt };
10112
10215
 
10113
- //# sourceMappingURL=supervise-Cx24b3lw.js.map
10216
+ //# sourceMappingURL=supervise-Ds8FtyI9.js.map