@tangle-network/agent-runtime 0.51.0 → 0.52.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.
package/dist/agent.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-7JITYN6T.js";
4
4
  import {
5
5
  createSandboxForSpec
6
- } from "./chunk-FQH33M5N.js";
6
+ } from "./chunk-2OU7ZQPD.js";
7
7
  import {
8
8
  mapSandboxEvent
9
9
  } from "./chunk-GSUO5QS6.js";
@@ -710,6 +710,17 @@ function readAnalystFindings(settled) {
710
710
  }
711
711
  return out;
712
712
  }
713
+ function registryScopeAnalyst(registry, buildInputs) {
714
+ return {
715
+ async analyze(input) {
716
+ const projection = buildInputs(input);
717
+ const result = await registry.run(projection.runId, projection.inputs, projection.opts);
718
+ const findings = result.findings;
719
+ assertTraceDerivedFindings(findings);
720
+ return findings;
721
+ }
722
+ };
723
+ }
713
724
  function buildSteerContext(findings, settledSoFar) {
714
725
  assertTraceDerivedFindings(findings);
715
726
  const lastValidScore = observedBestScore(settledSoFar);
@@ -2691,6 +2702,7 @@ function loopUntil(seed, spec) {
2691
2702
  async act(task, scope) {
2692
2703
  let state = { round: 0, value: seed };
2693
2704
  const blockers = [];
2705
+ const settledSoFar = [];
2694
2706
  for (; ; ) {
2695
2707
  const label = spec.label ? spec.label(state.round) : `step:${state.round}`;
2696
2708
  const child = ctx.spawnChild(label, ctx.persona.root);
@@ -2704,8 +2716,10 @@ function loopUntil(seed, spec) {
2704
2716
  }
2705
2717
  const settled = await drainOne(scope, label);
2706
2718
  if (settled.kind === "down") blockers.push(blockerFromDown(settled));
2719
+ settledSoFar.push(settled);
2707
2720
  state = spec.fold(state, settled);
2708
- const reached = spec.until(state, []);
2721
+ const findings = ctx.analyst ? await ctx.analyst.analyze({ task, settledSoFar, nodeId: scope.view.root }) : [];
2722
+ const reached = spec.until(state, findings);
2709
2723
  if (reached) return reached;
2710
2724
  state = { round: state.round + 1, value: state.value };
2711
2725
  }
@@ -2817,7 +2831,12 @@ function widen(spec) {
2817
2831
  let widenIndex = 0;
2818
2832
  for (let s = await scope.next(); s !== null; s = await scope.next()) {
2819
2833
  gathered.push(s);
2820
- const decision = spec.gate.decide(s, [], scope.budget);
2834
+ const findings = ctx.analyst ? await ctx.analyst.analyze({
2835
+ task: _task,
2836
+ settledSoFar: gathered,
2837
+ nodeId: scope.view.root
2838
+ }) : [];
2839
+ const decision = spec.gate.decide(s, findings, scope.budget);
2821
2840
  if (decision.kind !== "widen") continue;
2822
2841
  const label = `widen:${widenIndex}`;
2823
2842
  widenIndex += 1;
@@ -4215,10 +4234,11 @@ function definePersona(input) {
4215
4234
  ...input.extensions ? { extensions: input.extensions } : {}
4216
4235
  });
4217
4236
  }
4218
- function createShapeContext(persona, budget) {
4237
+ function createShapeContext(persona, budget, analyst) {
4219
4238
  return {
4220
4239
  persona,
4221
4240
  budget,
4241
+ ...analyst ? { analyst } : {},
4222
4242
  spawnChild(name, spec) {
4223
4243
  const agent = {
4224
4244
  name,
@@ -4244,7 +4264,7 @@ async function runPersonified(options) {
4244
4264
  const { persona } = options;
4245
4265
  const shape = resolveShape(options.shape);
4246
4266
  const shapeBudget = resolveShapeBudget(options.budget, options.shapeBudget);
4247
- const ctx = createShapeContext(persona, shapeBudget);
4267
+ const ctx = createShapeContext(persona, shapeBudget, options.analyst);
4248
4268
  const rootAgent = shape(ctx);
4249
4269
  const executors = personaRegistry(persona);
4250
4270
  const supervisor = createSupervisor();
@@ -6453,6 +6473,7 @@ export {
6453
6473
  deterministicCompletion,
6454
6474
  assertTraceDerivedFindings,
6455
6475
  createScopeAnalyst,
6476
+ registryScopeAnalyst,
6456
6477
  buildSteerContext,
6457
6478
  createDriver,
6458
6479
  renderAnalyses,
@@ -6528,4 +6549,4 @@ export {
6528
6549
  gitWorkspace,
6529
6550
  jjWorkspace
6530
6551
  };
6531
- //# sourceMappingURL=chunk-FQH33M5N.js.map
6552
+ //# sourceMappingURL=chunk-2OU7ZQPD.js.map