nexus-agents 2.154.1 → 2.155.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.
@@ -18,7 +18,7 @@ import {
18
18
  DEFAULT_TASK_TTL_MS,
19
19
  DEFAULT_TOOL_RATE_LIMITS,
20
20
  clampTaskTtl
21
- } from "./chunk-RW5ZE7IC.js";
21
+ } from "./chunk-MJRIWG2E.js";
22
22
  import {
23
23
  executeExpert
24
24
  } from "./chunk-F5R53HDK.js";
@@ -46487,6 +46487,326 @@ function getShadowSink() {
46487
46487
  return singletonSink;
46488
46488
  }
46489
46489
 
46490
+ // src/orchestration/meta-strategy-eval.ts
46491
+ function groupByStrategy(corpus) {
46492
+ const groups = /* @__PURE__ */ new Map();
46493
+ for (const entry of corpus) {
46494
+ const list = groups.get(entry.expectedStrategy) ?? [];
46495
+ list.push(entry);
46496
+ groups.set(entry.expectedStrategy, list);
46497
+ }
46498
+ return groups;
46499
+ }
46500
+ function splitCorpus(corpus, testRatio) {
46501
+ const train = [];
46502
+ const test = [];
46503
+ for (const entries of groupByStrategy(corpus).values()) {
46504
+ const testN = Math.max(1, Math.round(entries.length * testRatio));
46505
+ const trainN = Math.max(0, entries.length - testN);
46506
+ train.push(...entries.slice(0, trainN));
46507
+ test.push(...entries.slice(trainN));
46508
+ }
46509
+ return { train, test };
46510
+ }
46511
+ function evaluateMetaStrategy(corpus, options = {}) {
46512
+ const testRatio = options.testRatio ?? 0.25;
46513
+ const { train, test } = splitCorpus(corpus, testRatio);
46514
+ const orchestrator = createMetaOrchestrator();
46515
+ const learned = createLearnedStrategySelector();
46516
+ for (const entry of train) {
46517
+ const decision = orchestrator.select({ goal: entry.goal });
46518
+ learned.recordOutcome(entry.expectedStrategy, decision, true);
46519
+ }
46520
+ let rulesCorrect = 0;
46521
+ let learnedCorrect = 0;
46522
+ for (const entry of test) {
46523
+ const decision = orchestrator.select({ goal: entry.goal });
46524
+ if (decision.strategy === entry.expectedStrategy) rulesCorrect++;
46525
+ if (learned.predict(decision).strategy === entry.expectedStrategy) learnedCorrect++;
46526
+ }
46527
+ const testCount = test.length;
46528
+ const rulesAccuracy = testCount === 0 ? 0 : rulesCorrect / testCount;
46529
+ const learnedAccuracy = testCount === 0 ? 0 : learnedCorrect / testCount;
46530
+ return {
46531
+ total: corpus.length,
46532
+ trainCount: train.length,
46533
+ testCount,
46534
+ rulesAccuracy,
46535
+ learnedAccuracy,
46536
+ delta: learnedAccuracy - rulesAccuracy
46537
+ };
46538
+ }
46539
+
46540
+ // src/orchestration/meta-strategy-corpus.ts
46541
+ var META_STRATEGY_CORPUS = [
46542
+ // single-shot — trivial single-step
46543
+ { goal: "rename the variable foo to bar in utils.ts", expectedStrategy: "single-shot" },
46544
+ { goal: "what does the git rebase --onto flag do?", expectedStrategy: "single-shot" },
46545
+ { goal: "format this JSON snippet", expectedStrategy: "single-shot" },
46546
+ { goal: "add a one-line comment explaining this regex", expectedStrategy: "single-shot" },
46547
+ { goal: "convert this value from Celsius to Fahrenheit", expectedStrategy: "single-shot" },
46548
+ {
46549
+ goal: "explain what the useEffect hook does in one paragraph",
46550
+ expectedStrategy: "single-shot"
46551
+ },
46552
+ { goal: "convert this markdown table to CSV", expectedStrategy: "single-shot" },
46553
+ {
46554
+ goal: "rename the function calcTotal to computeTotal in cart.ts",
46555
+ expectedStrategy: "single-shot"
46556
+ },
46557
+ { goal: "what is the time complexity of binary search?", expectedStrategy: "single-shot" },
46558
+ { goal: "format this SQL query for readability", expectedStrategy: "single-shot" },
46559
+ // dev-pipeline — code change needing the test/lint/typecheck gate
46560
+ {
46561
+ goal: "fix the off-by-one bug in pagination.ts and make sure the tests pass",
46562
+ expectedStrategy: "dev-pipeline"
46563
+ },
46564
+ {
46565
+ goal: "add input validation to the login handler with unit tests",
46566
+ expectedStrategy: "dev-pipeline"
46567
+ },
46568
+ { goal: "refactor the auth module and run lint and typecheck", expectedStrategy: "dev-pipeline" },
46569
+ { goal: "implement retry logic in the http client with tests", expectedStrategy: "dev-pipeline" },
46570
+ {
46571
+ goal: "patch the null-pointer in parser.ts and verify the build",
46572
+ expectedStrategy: "dev-pipeline"
46573
+ },
46574
+ {
46575
+ goal: "fix the memory leak in the websocket handler and make the tests green",
46576
+ expectedStrategy: "dev-pipeline"
46577
+ },
46578
+ {
46579
+ goal: "add a rate limiter to the API middleware with unit tests",
46580
+ expectedStrategy: "dev-pipeline"
46581
+ },
46582
+ {
46583
+ goal: "correct the timezone bug in the scheduler and run the test suite",
46584
+ expectedStrategy: "dev-pipeline"
46585
+ },
46586
+ {
46587
+ goal: "implement pagination on the users endpoint with tests and typecheck",
46588
+ expectedStrategy: "dev-pipeline"
46589
+ },
46590
+ {
46591
+ goal: "fix the flaky retry test in queue.ts and keep lint clean",
46592
+ expectedStrategy: "dev-pipeline"
46593
+ },
46594
+ // pipeline — multi-stage templated audit/general
46595
+ { goal: "run a security audit of the payments module", expectedStrategy: "pipeline" },
46596
+ { goal: "do a full quality audit of the API layer", expectedStrategy: "pipeline" },
46597
+ { goal: "produce an architecture review of the data pipeline", expectedStrategy: "pipeline" },
46598
+ { goal: "run the documentation-quality audit over the docs tree", expectedStrategy: "pipeline" },
46599
+ { goal: "perform a compliance audit of the logging subsystem", expectedStrategy: "pipeline" },
46600
+ { goal: "run a performance audit of the checkout flow", expectedStrategy: "pipeline" },
46601
+ { goal: "do a dependency-vulnerability audit of the whole repo", expectedStrategy: "pipeline" },
46602
+ { goal: "produce an accessibility audit of the web frontend", expectedStrategy: "pipeline" },
46603
+ { goal: "run a code-quality audit across the billing service", expectedStrategy: "pipeline" },
46604
+ { goal: "perform a test-coverage audit of the core package", expectedStrategy: "pipeline" },
46605
+ // graph-workflow — DAG / conditional-edge
46606
+ {
46607
+ goal: "build a conditional workflow that branches on the test result then deploys or rolls back",
46608
+ expectedStrategy: "graph-workflow"
46609
+ },
46610
+ {
46611
+ goal: "orchestrate a DAG fetch then transform then validate then load, halting at the validate gate on failure",
46612
+ expectedStrategy: "graph-workflow"
46613
+ },
46614
+ {
46615
+ goal: "create a multi-stage workflow with conditional edges depending on the lint outcome",
46616
+ expectedStrategy: "graph-workflow"
46617
+ },
46618
+ {
46619
+ goal: "wire a workflow where step C runs only if both A and B succeed",
46620
+ expectedStrategy: "graph-workflow"
46621
+ },
46622
+ {
46623
+ goal: "design a graph workflow with a fan-in join after three sequential gated branches",
46624
+ expectedStrategy: "graph-workflow"
46625
+ },
46626
+ {
46627
+ goal: "build a workflow that runs A then branches to B or C based on the security-scan verdict",
46628
+ expectedStrategy: "graph-workflow"
46629
+ },
46630
+ {
46631
+ goal: "create a DAG where build and lint run in parallel then merge into a gated deploy step",
46632
+ expectedStrategy: "graph-workflow"
46633
+ },
46634
+ {
46635
+ goal: "design a workflow with a retry-loop edge back to the fetch step on transient failure",
46636
+ expectedStrategy: "graph-workflow"
46637
+ },
46638
+ {
46639
+ goal: "wire a pipeline that skips the migration step when the schema-check passes",
46640
+ expectedStrategy: "graph-workflow"
46641
+ },
46642
+ {
46643
+ goal: "orchestrate a conditional graph: on approval go to publish, otherwise route to a rework node",
46644
+ expectedStrategy: "graph-workflow"
46645
+ },
46646
+ // orchestrate — pattern-based multi-agent
46647
+ {
46648
+ goal: "run a multi-agent wave over these modules to refactor them in parallel",
46649
+ expectedStrategy: "orchestrate"
46650
+ },
46651
+ {
46652
+ goal: "fan out independent subtasks across the codebase to add logging",
46653
+ expectedStrategy: "orchestrate"
46654
+ },
46655
+ {
46656
+ goal: "orchestrate a swarm of agents to triage the open issues",
46657
+ expectedStrategy: "orchestrate"
46658
+ },
46659
+ {
46660
+ goal: "use a multi-agent pattern to migrate each service independently",
46661
+ expectedStrategy: "orchestrate"
46662
+ },
46663
+ { goal: "dispatch a wave of agents to audit each microservice", expectedStrategy: "orchestrate" },
46664
+ {
46665
+ goal: "spawn a swarm of agents to add type annotations across every module in parallel",
46666
+ expectedStrategy: "orchestrate"
46667
+ },
46668
+ {
46669
+ goal: "fan out a wave of agents to update the copyright header in each file",
46670
+ expectedStrategy: "orchestrate"
46671
+ },
46672
+ {
46673
+ goal: "use a multi-agent pattern to generate unit tests for each untested component concurrently",
46674
+ expectedStrategy: "orchestrate"
46675
+ },
46676
+ {
46677
+ goal: "dispatch parallel agents to translate the docs into each supported language",
46678
+ expectedStrategy: "orchestrate"
46679
+ },
46680
+ {
46681
+ goal: "run a fan-out of agents to bump the dependency version in every package independently",
46682
+ expectedStrategy: "orchestrate"
46683
+ },
46684
+ // consensus — multi-perspective decision/vote
46685
+ { goal: "hold a consensus vote on whether to adopt GraphQL", expectedStrategy: "consensus" },
46686
+ { goal: "we need a consensus decision on the database choice", expectedStrategy: "consensus" },
46687
+ {
46688
+ goal: "get multiple perspectives via a vote on the API redesign",
46689
+ expectedStrategy: "consensus"
46690
+ },
46691
+ {
46692
+ goal: "run a consensus panel on the proposed authentication change",
46693
+ expectedStrategy: "consensus"
46694
+ },
46695
+ {
46696
+ goal: "do a multi-perspective review and vote on the migration plan",
46697
+ expectedStrategy: "consensus"
46698
+ },
46699
+ { goal: "hold a vote on which cloud provider to standardize on", expectedStrategy: "consensus" },
46700
+ {
46701
+ goal: "get a consensus decision on whether to drop support for Node 18",
46702
+ expectedStrategy: "consensus"
46703
+ },
46704
+ {
46705
+ goal: "run a multi-perspective panel to decide the caching strategy",
46706
+ expectedStrategy: "consensus"
46707
+ },
46708
+ { goal: "we need a consensus vote on the proposed pricing model", expectedStrategy: "consensus" },
46709
+ {
46710
+ goal: "gather multiple expert opinions and vote on the rollout timeline",
46711
+ expectedStrategy: "consensus"
46712
+ },
46713
+ // spec — greenfield from a written spec
46714
+ { goal: "build a greenfield todo app from this written spec", expectedStrategy: "spec" },
46715
+ {
46716
+ goal: "implement a new microservice from scratch per the attached spec document",
46717
+ expectedStrategy: "spec"
46718
+ },
46719
+ { goal: "create a brand-new CLI tool from this specification", expectedStrategy: "spec" },
46720
+ { goal: "scaffold a greenfield REST API from the provided spec", expectedStrategy: "spec" },
46721
+ {
46722
+ goal: "build the new notification service from scratch following the spec",
46723
+ expectedStrategy: "spec"
46724
+ },
46725
+ {
46726
+ goal: "build a new authentication service from scratch following this specification",
46727
+ expectedStrategy: "spec"
46728
+ },
46729
+ {
46730
+ goal: "scaffold a greenfield mobile backend from the attached spec document",
46731
+ expectedStrategy: "spec"
46732
+ },
46733
+ {
46734
+ goal: "implement a brand-new billing engine from this written spec",
46735
+ expectedStrategy: "spec"
46736
+ },
46737
+ {
46738
+ goal: "create a new GraphQL gateway from scratch per the provided spec",
46739
+ expectedStrategy: "spec"
46740
+ },
46741
+ {
46742
+ goal: "build the greenfield analytics dashboard from this specification",
46743
+ expectedStrategy: "spec"
46744
+ },
46745
+ // research — research-heavy investigation
46746
+ { goal: "research the best vector database for our use case", expectedStrategy: "research" },
46747
+ { goal: "investigate and compare OAuth libraries for Node", expectedStrategy: "research" },
46748
+ {
46749
+ goal: "do a deep research report on consensus algorithms for distributed systems",
46750
+ expectedStrategy: "research"
46751
+ },
46752
+ { goal: "survey the landscape of LLM evaluation frameworks", expectedStrategy: "research" },
46753
+ {
46754
+ goal: "research which benchmarks are worth adopting for our agents",
46755
+ expectedStrategy: "research"
46756
+ },
46757
+ {
46758
+ goal: "research the current best practices for prompt caching across LLM providers",
46759
+ expectedStrategy: "research"
46760
+ },
46761
+ {
46762
+ goal: "compare and evaluate message-queue technologies for our throughput needs",
46763
+ expectedStrategy: "research"
46764
+ },
46765
+ {
46766
+ goal: "survey the state of the art in retrieval-augmented generation",
46767
+ expectedStrategy: "research"
46768
+ },
46769
+ {
46770
+ goal: "investigate which observability stack fits our microservices best",
46771
+ expectedStrategy: "research"
46772
+ },
46773
+ {
46774
+ goal: "research the tradeoffs between monorepo and polyrepo for our team",
46775
+ expectedStrategy: "research"
46776
+ }
46777
+ ];
46778
+
46779
+ // src/orchestration/meta-strategy-readiness.ts
46780
+ var DEFAULT_META_STRATEGY_READINESS_CONFIG = {
46781
+ minTestCases: 20,
46782
+ minDelta: 0.05,
46783
+ minLearnedAccuracy: 0.7
46784
+ };
46785
+ function pctStr(n) {
46786
+ return String(Math.round(n * 100));
46787
+ }
46788
+ function evaluateMetaStrategyReadiness(result, config = DEFAULT_META_STRATEGY_READINESS_CONFIG) {
46789
+ const criteria = [
46790
+ {
46791
+ name: "volume",
46792
+ met: result.testCount >= config.minTestCases,
46793
+ detail: `${String(result.testCount)} held-out test cases (need \u2265 ${String(config.minTestCases)})`
46794
+ },
46795
+ {
46796
+ name: "learned-beats-rules",
46797
+ met: result.delta >= config.minDelta,
46798
+ detail: `learned\u2212rules delta ${result.delta.toFixed(2)} (need \u2265 ${config.minDelta.toFixed(2)})`
46799
+ },
46800
+ {
46801
+ name: "learned-accuracy-floor",
46802
+ met: result.learnedAccuracy >= config.minLearnedAccuracy,
46803
+ detail: `learned accuracy ${pctStr(result.learnedAccuracy)}% (need \u2265 ${pctStr(config.minLearnedAccuracy)}%)`
46804
+ }
46805
+ ];
46806
+ const blockers = criteria.filter((c) => !c.met).map((c) => c.name);
46807
+ return { ready: blockers.length === 0, criteria, blockers };
46808
+ }
46809
+
46490
46810
  // src/orchestration/meta-dispatcher.ts
46491
46811
  var MetaDispatchError = class extends Error {
46492
46812
  code;
@@ -47194,12 +47514,34 @@ function toMetaInput(input, mode) {
47194
47514
  ...input.forceStrategy !== void 0 ? { forceStrategy: input.forceStrategy } : {}
47195
47515
  };
47196
47516
  }
47517
+ var readinessLogged = false;
47518
+ function logMetaStrategyReadinessOnce(logger58) {
47519
+ if (readinessLogged) return;
47520
+ readinessLogged = true;
47521
+ try {
47522
+ const evalResult = evaluateMetaStrategy(META_STRATEGY_CORPUS);
47523
+ const verdict = evaluateMetaStrategyReadiness(evalResult);
47524
+ logger58.info("meta-strategy learned-selector readiness", {
47525
+ ready: verdict.ready,
47526
+ delta: evalResult.delta,
47527
+ learnedAccuracy: evalResult.learnedAccuracy,
47528
+ rulesAccuracy: evalResult.rulesAccuracy,
47529
+ testCount: evalResult.testCount,
47530
+ blockers: verdict.blockers
47531
+ });
47532
+ } catch (err2) {
47533
+ logger58.warn("meta-strategy readiness signal failed (non-fatal)", {
47534
+ error: getErrorMessage(err2)
47535
+ });
47536
+ }
47537
+ }
47197
47538
  function selectDecision(input, mode, logger58) {
47198
47539
  const meta = createMetaOrchestrator({
47199
47540
  ...logger58 !== void 0 ? { logger: logger58 } : {},
47200
47541
  shadowSelector: getShadowSelector(),
47201
47542
  shadowSink: getShadowSink()
47202
47543
  });
47544
+ logMetaStrategyReadinessOnce(logger58 ?? createLogger({ component: "RunTool" }));
47203
47545
  return meta.select(toMetaInput(input, mode));
47204
47546
  }
47205
47547
  function routeGoal(input, logger58) {
@@ -51446,4 +51788,4 @@ export {
51446
51788
  shutdownFeedbackSubscriber,
51447
51789
  createEventBusBridge
51448
51790
  };
51449
- //# sourceMappingURL=chunk-3P5WC7AV.js.map
51791
+ //# sourceMappingURL=chunk-KXTOVEZS.js.map