nexus-agents 2.98.0 → 2.99.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.
@@ -30,7 +30,7 @@ import {
30
30
  writeJobComplete,
31
31
  writeJobFailed,
32
32
  writeJobPending
33
- } from "./chunk-RCKLAJ2H.js";
33
+ } from "./chunk-AN3IGMJT.js";
34
34
  import {
35
35
  REGISTRY_PATH,
36
36
  getProjectRoot,
@@ -51,7 +51,7 @@ import {
51
51
  } from "./chunk-VD4TXDMR.js";
52
52
  import {
53
53
  withPrerequisite
54
- } from "./chunk-MKFLI5DK.js";
54
+ } from "./chunk-YREYQSYA.js";
55
55
  import {
56
56
  NOOP_NOTIFIER,
57
57
  RateLimiter,
@@ -70,7 +70,7 @@ import {
70
70
  withAccessPolicy,
71
71
  withProgressHeartbeat,
72
72
  wrapToolWithTimeout
73
- } from "./chunk-G4A7SSML.js";
73
+ } from "./chunk-JFFI54DW.js";
74
74
  import {
75
75
  generateSecurityPlan
76
76
  } from "./chunk-BKUKBOGV.js";
@@ -92,7 +92,7 @@ import {
92
92
  DEFAULT_TASK_TTL_MS,
93
93
  DEFAULT_TOOL_RATE_LIMITS,
94
94
  clampTaskTtl
95
- } from "./chunk-6ZXNMJEX.js";
95
+ } from "./chunk-VPH2M5H7.js";
96
96
  import {
97
97
  getAvailabilityCache,
98
98
  getCliForModelId,
@@ -23559,10 +23559,10 @@ function calculateZStatistic(params) {
23559
23559
  function calculateDifferenceCI(p1, p2, total1, total2, confidence) {
23560
23560
  const difference = p1 - p2;
23561
23561
  const seDiff = Math.sqrt(p1 * (1 - p1) / (total1 || 1) + p2 * (1 - p2) / (total2 || 1));
23562
- const z111 = getZScore(confidence);
23562
+ const z112 = getZScore(confidence);
23563
23563
  return {
23564
- lower: difference - z111 * seDiff,
23565
- upper: difference + z111 * seDiff,
23564
+ lower: difference - z112 * seDiff,
23565
+ upper: difference + z112 * seDiff,
23566
23566
  estimate: difference,
23567
23567
  confidence,
23568
23568
  n: total1 + total2,
@@ -23585,11 +23585,11 @@ function proportionConfidenceInterval(successes, total, options = {}) {
23585
23585
  standardError: 0
23586
23586
  };
23587
23587
  }
23588
- const z111 = getZScore(opts.confidence);
23589
- const z210 = z111 * z111;
23588
+ const z112 = getZScore(opts.confidence);
23589
+ const z210 = z112 * z112;
23590
23590
  const denominator = 1 + z210 / n;
23591
23591
  const center = (p + z210 / (2 * n)) / denominator;
23592
- const margin = z111 / denominator * Math.sqrt(p * (1 - p) / n + z210 / (4 * n * n));
23592
+ const margin = z112 / denominator * Math.sqrt(p * (1 - p) / n + z210 / (4 * n * n));
23593
23593
  const lower = Math.max(0, center - margin);
23594
23594
  const upper = Math.min(1, center + margin);
23595
23595
  const standardError = Math.sqrt(p * (1 - p) / n);
@@ -23619,8 +23619,8 @@ function meanConfidenceInterval(values, options = {}) {
23619
23619
  const variance = values.reduce((sum, v) => sum + (v - mean) ** 2, 0) / (n - 1 || 1);
23620
23620
  const stdDev = Math.sqrt(variance);
23621
23621
  const standardError = stdDev / Math.sqrt(n);
23622
- const z111 = getZScore(opts.confidence);
23623
- const margin = z111 * standardError;
23622
+ const z112 = getZScore(opts.confidence);
23623
+ const margin = z112 * standardError;
23624
23624
  return {
23625
23625
  lower: mean - margin,
23626
23626
  upper: mean + margin,
@@ -43433,7 +43433,7 @@ ${contextBlock}`;
43433
43433
  const strategy = config.votingStrategy ?? "higher_order";
43434
43434
  await postProgress(config, "Vote", `Running consensus with ${strategy} strategy...`);
43435
43435
  try {
43436
- const { executeVoting } = await import("./consensus-vote-Z3BWJLRE.js");
43436
+ const { executeVoting } = await import("./consensus-vote-5D7FNWYM.js");
43437
43437
  const votingResult = await executeVoting(
43438
43438
  {
43439
43439
  proposal: plan.slice(0, 4e3),
@@ -45905,12 +45905,204 @@ function registerCiHealthCheckTool(server, deps) {
45905
45905
  logger55.info("Registered ci_health_check tool");
45906
45906
  }
45907
45907
 
45908
+ // src/mcp/tools/quality-gate-tool.ts
45909
+ import { statSync as statSync3 } from "fs";
45910
+ import { z as z101 } from "zod";
45911
+
45912
+ // src/security/quality-gate.ts
45913
+ async function runCommandCheck(name, command, args) {
45914
+ const start = Date.now();
45915
+ try {
45916
+ const { execFile: execFile3 } = await import("child_process");
45917
+ const { promisify: promisify3 } = await import("util");
45918
+ const exec2 = promisify3(execFile3);
45919
+ await exec2(command, [...args], { timeout: 12e4 });
45920
+ return {
45921
+ name,
45922
+ verdict: "pass",
45923
+ details: `${name} completed successfully`,
45924
+ durationMs: Date.now() - start
45925
+ };
45926
+ } catch (error) {
45927
+ const msg = error instanceof Error ? error.message : String(error);
45928
+ return {
45929
+ name,
45930
+ verdict: "fail",
45931
+ details: msg.slice(0, 500),
45932
+ durationMs: Date.now() - start
45933
+ };
45934
+ }
45935
+ }
45936
+ function checkTypeCheck(projectDir) {
45937
+ return () => runCommandCheck("type_check", "npx", ["tsc", "--noEmit", "--project", projectDir]);
45938
+ }
45939
+ function checkLint(projectDir) {
45940
+ return () => runCommandCheck("lint", "npx", ["eslint", "--max-warnings", "0", projectDir]);
45941
+ }
45942
+ function checkTests(projectDir) {
45943
+ return () => runCommandCheck("tests", "npx", ["vitest", "run", "--dir", projectDir]);
45944
+ }
45945
+ function checkBuild() {
45946
+ return () => runCommandCheck("build", "pnpm", ["build"]);
45947
+ }
45948
+ function aggregateResults2(checks) {
45949
+ let pass = 0;
45950
+ let fail = 0;
45951
+ let skip = 0;
45952
+ for (const c of checks) {
45953
+ if (c.verdict === "pass") pass++;
45954
+ else if (c.verdict === "fail") fail++;
45955
+ else skip++;
45956
+ }
45957
+ return { verdict: fail > 0 ? "fail" : "pass", summary: { pass, fail, skip } };
45958
+ }
45959
+ function generateFeedback2(checks) {
45960
+ const failures = checks.filter((c) => c.verdict === "fail");
45961
+ if (failures.length === 0) return "All checks passed.";
45962
+ const lines = failures.map((f) => `- ${f.name}: ${f.details}`);
45963
+ return `${String(failures.length)} check(s) failed:
45964
+ ${lines.join("\n")}`;
45965
+ }
45966
+ async function runQualityGate(stage, checks, iteration = 1) {
45967
+ const results = [];
45968
+ for (const check of checks) {
45969
+ const result = await check();
45970
+ results.push(result);
45971
+ }
45972
+ const { verdict, summary } = aggregateResults2(results);
45973
+ return {
45974
+ stage,
45975
+ verdict,
45976
+ checks: results,
45977
+ summary,
45978
+ feedback: generateFeedback2(results),
45979
+ iteration
45980
+ };
45981
+ }
45982
+
45983
+ // src/mcp/tools/quality-gate-tool.ts
45984
+ var QualityCheckSchema = z101.enum(["typecheck", "lint", "tests", "build", "security"]);
45985
+ var DEFAULT_CHECKS = ["typecheck", "lint", "tests"];
45986
+ var RunQualityGateInputSchema = z101.object({
45987
+ /** Project directory to run checks against. Must resolve inside the repo/cwd root. */
45988
+ projectDir: z101.string().optional().describe(
45989
+ "Project directory to run checks against (default: cwd). Must stay inside the repo root."
45990
+ ),
45991
+ /** Which allowlisted checks to run. */
45992
+ checks: z101.array(QualityCheckSchema).nonempty().default([...DEFAULT_CHECKS]).describe("Allowlisted checks to run (default: ['typecheck','lint','tests'])."),
45993
+ /** 1-based iteration counter, forwarded to the engine for feedback context. */
45994
+ iteration: z101.number().int().min(1).default(1).describe("1-based iteration number (default 1).")
45995
+ });
45996
+ function validateProjectDir(raw) {
45997
+ const candidate = raw ?? process.cwd();
45998
+ const safe = resolveInsideRoot(candidate);
45999
+ if (safe === null) {
46000
+ return {
46001
+ error: toolStructuredError({
46002
+ errorCategory: "permission",
46003
+ message: `Invalid projectDir: "${candidate}" resolves outside the repository root (path traversal rejected).`
46004
+ })
46005
+ };
46006
+ }
46007
+ let stat5;
46008
+ try {
46009
+ stat5 = statSync3(safe);
46010
+ } catch {
46011
+ return {
46012
+ error: toolStructuredError({
46013
+ errorCategory: "validation",
46014
+ message: `Invalid projectDir: "${candidate}" does not exist.`
46015
+ })
46016
+ };
46017
+ }
46018
+ if (!stat5.isDirectory()) {
46019
+ return {
46020
+ error: toolStructuredError({
46021
+ errorCategory: "validation",
46022
+ message: `Invalid projectDir: "${candidate}" is not a directory.`
46023
+ })
46024
+ };
46025
+ }
46026
+ return { dir: safe };
46027
+ }
46028
+ function buildCheck(name, projectDir) {
46029
+ switch (name) {
46030
+ case "typecheck":
46031
+ return checkTypeCheck(projectDir);
46032
+ case "lint":
46033
+ return checkLint(projectDir);
46034
+ case "tests":
46035
+ return checkTests(projectDir);
46036
+ case "build":
46037
+ return checkBuild();
46038
+ case "security":
46039
+ return checkSecurityScan(projectDir);
46040
+ }
46041
+ }
46042
+ async function runQualityGateHandler(args, logger55) {
46043
+ const parsed = RunQualityGateInputSchema.safeParse(args);
46044
+ if (!parsed.success) {
46045
+ return toolStructuredError({
46046
+ errorCategory: "validation",
46047
+ message: `Validation error: ${formatZodError(parsed.error)}`
46048
+ });
46049
+ }
46050
+ const { projectDir, checks, iteration } = parsed.data;
46051
+ const validated = validateProjectDir(projectDir);
46052
+ if ("error" in validated) return validated.error;
46053
+ const checkFns = checks.map((name) => buildCheck(name, validated.dir));
46054
+ logger55.info("Running quality gate", { checks, iteration });
46055
+ try {
46056
+ const result = await runQualityGate("qa", checkFns, iteration);
46057
+ return toolSuccess(JSON.stringify(result, null, 2));
46058
+ } catch (err2) {
46059
+ return toolStructuredError({
46060
+ errorCategory: "internal",
46061
+ message: `Quality gate execution failed: ${err2 instanceof Error ? err2.message : String(err2)}`
46062
+ });
46063
+ }
46064
+ }
46065
+ var DESCRIPTION2 = "Run the QA quality gate (#1684 engine) against a project directory. Allowlisted checks: typecheck | lint | tests | build | security (default ['typecheck','lint','tests']). Returns the structured { stage, verdict, checks[], summary, feedback } verdict. projectDir must stay inside the repository root; per-check output is capped at 500 chars.";
46066
+ function registerRunQualityGateTool(server, deps) {
46067
+ const logger55 = deps.logger ?? createLogger({ tool: "run_quality_gate" });
46068
+ const toolSchema = {
46069
+ projectDir: z101.string().optional().describe(
46070
+ "Project directory to run checks against (default: cwd). Must stay inside the repo root."
46071
+ ),
46072
+ checks: z101.array(QualityCheckSchema).nonempty().optional().describe("Allowlisted checks to run (default: ['typecheck','lint','tests'])."),
46073
+ iteration: z101.number().int().min(1).optional().describe("1-based iteration number (default 1).")
46074
+ };
46075
+ const secureHandler = createSecureHandler(
46076
+ (args) => runQualityGateHandler(args, logger55),
46077
+ {
46078
+ toolName: "run_quality_gate",
46079
+ rateLimiter: deps.rateLimiter,
46080
+ logger: logger55
46081
+ }
46082
+ );
46083
+ const timeoutMs = getToolTimeout("run_quality_gate", deps.security);
46084
+ const wrappedHandler = wrapToolWithTimeout("run_quality_gate", secureHandler, {
46085
+ timeoutMs,
46086
+ logger: logger55
46087
+ });
46088
+ server.registerTool(
46089
+ "run_quality_gate",
46090
+ {
46091
+ description: DESCRIPTION2,
46092
+ inputSchema: toolSchema,
46093
+ annotations: getToolAnnotations("run_quality_gate")
46094
+ },
46095
+ toSdkCallback(wrappedHandler)
46096
+ );
46097
+ logger55.info("Registered run_quality_gate tool");
46098
+ }
46099
+
45908
46100
  // src/mcp/tools/verify-audit-chain-tool.ts
45909
46101
  import * as fs12 from "fs/promises";
45910
46102
  import * as path11 from "path";
45911
- import { z as z101 } from "zod";
45912
- var VerifyAuditChainInputSchema = z101.object({
45913
- logDir: z101.string().min(1).max(512).describe(
46103
+ import { z as z102 } from "zod";
46104
+ var VerifyAuditChainInputSchema = z102.object({
46105
+ logDir: z102.string().min(1).max(512).describe(
45914
46106
  "Filesystem path to the FileAuditStorage log directory. Tool reads all `audit-*.jsonl` files in lexicographic order and verifies the combined chain."
45915
46107
  )
45916
46108
  });
@@ -45987,7 +46179,7 @@ async function handler2(args, ctx) {
45987
46179
  function registerVerifyAuditChainTool(server, deps) {
45988
46180
  const logger55 = deps.logger ?? createLogger({ tool: "verify_audit_chain" });
45989
46181
  const toolSchema = {
45990
- logDir: z101.string().min(1).max(512).describe(
46182
+ logDir: z102.string().min(1).max(512).describe(
45991
46183
  "Filesystem path to the FileAuditStorage log directory. Tool reads all `audit-*.jsonl` files and verifies the combined hash chain."
45992
46184
  )
45993
46185
  };
@@ -46011,18 +46203,18 @@ function registerVerifyAuditChainTool(server, deps) {
46011
46203
  }
46012
46204
 
46013
46205
  // src/mcp/tools/pipeline-tool.ts
46014
- import { z as z102 } from "zod";
46206
+ import { z as z103 } from "zod";
46015
46207
  import * as fs13 from "fs";
46016
46208
  import * as path12 from "path";
46017
- var PipelineInputSchema = z102.object({
46209
+ var PipelineInputSchema = z103.object({
46018
46210
  /** The task to execute. */
46019
- task: z102.string().min(5).max(1e4).describe("Task description \u2014 pipeline template auto-selected based on content"),
46211
+ task: z103.string().min(5).max(1e4).describe("Task description \u2014 pipeline template auto-selected based on content"),
46020
46212
  /** Path to a spec file (.md, .yaml) to use as task input. */
46021
- specFile: z102.string().max(500).optional().describe("Path to a spec file \u2014 content prepended to task for greenfield projects"),
46213
+ specFile: z103.string().max(500).optional().describe("Path to a spec file \u2014 content prepended to task for greenfield projects"),
46022
46214
  /** Override template — see `listTemplateIds()` for the canonical list (#2728). Auto-detected if omitted. */
46023
- template: z102.string().max(50).optional().describe(`Pipeline template override. Available: ${listTemplateIds().join(", ")}`),
46215
+ template: z103.string().max(50).optional().describe(`Pipeline template override. Available: ${listTemplateIds().join(", ")}`),
46024
46216
  /** Voting strategy for consensus stages. */
46025
- votingStrategy: z102.enum([
46217
+ votingStrategy: z103.enum([
46026
46218
  "simple_majority",
46027
46219
  "supermajority",
46028
46220
  "unanimous",
@@ -46033,13 +46225,13 @@ var PipelineInputSchema = z102.object({
46033
46225
  "Voting strategy for plan approval. simple_majority (default), supermajority (67%), unanimous, higher_order (Bayesian), proof_of_learning, opinion_wise"
46034
46226
  ),
46035
46227
  /** Use 3 agents instead of 6 for faster voting. */
46036
- quickMode: z102.boolean().default(false).describe("Use 3 agents instead of 6 for faster consensus voting"),
46228
+ quickMode: z103.boolean().default(false).describe("Use 3 agents instead of 6 for faster consensus voting"),
46037
46229
  /** Maximum execution time per stage in milliseconds (min 30s, max 600s). */
46038
- timeoutMs: z102.number().int().min(3e4).max(6e5).optional().describe("Max time per stage in ms (30000-600000). Default: varies by stage complexity"),
46230
+ timeoutMs: z103.number().int().min(3e4).max(6e5).optional().describe("Max time per stage in ms (30000-600000). Default: varies by stage complexity"),
46039
46231
  /** Stop after planning/voting (no implementation). */
46040
- dryRun: z102.boolean().default(false).describe("Stop after vote stage (no implementation)"),
46232
+ dryRun: z103.boolean().default(false).describe("Stop after vote stage (no implementation)"),
46041
46233
  /** TESTS ONLY — random output, must not be used for real decisions. (#2319) */
46042
- simulateVotes: z102.boolean().default(false).describe("TESTS ONLY \u2014 random output, must not be used for real decisions (#2319)")
46234
+ simulateVotes: z103.boolean().default(false).describe("TESTS ONLY \u2014 random output, must not be used for real decisions (#2319)")
46043
46235
  });
46044
46236
  function buildOutput2(result) {
46045
46237
  return {
@@ -46141,7 +46333,7 @@ function registerPipelineTool(server, deps) {
46141
46333
  }
46142
46334
 
46143
46335
  // src/mcp/tools/supply-chain-tradeoff-panel.ts
46144
- import { z as z103 } from "zod";
46336
+ import { z as z104 } from "zod";
46145
46337
  var DEFAULT_AXES = [
46146
46338
  "build_time_determinism",
46147
46339
  "supply_chain_risk",
@@ -46161,16 +46353,16 @@ var FULL_PANEL = [
46161
46353
  "scope_steward"
46162
46354
  ];
46163
46355
  var QUICK_PANEL = ["architect", "security", "scope_steward"];
46164
- var SupplyChainTradeoffPanelInputSchema = z103.object({
46165
- proposal: z103.string().min(1).max(MAX_PROPOSAL_LENGTH).describe('The proposal under tradeoff review (e.g. "Should aegis-boot adopt cargo-nextest?")'),
46166
- axes: z103.array(z103.string().min(1).max(MAX_AXIS_NAME_LENGTH)).min(1).max(MAX_AXES).optional().describe(
46356
+ var SupplyChainTradeoffPanelInputSchema = z104.object({
46357
+ proposal: z104.string().min(1).max(MAX_PROPOSAL_LENGTH).describe('The proposal under tradeoff review (e.g. "Should aegis-boot adopt cargo-nextest?")'),
46358
+ axes: z104.array(z104.string().min(1).max(MAX_AXIS_NAME_LENGTH)).min(1).max(MAX_AXES).optional().describe(
46167
46359
  `Tradeoff axes to evaluate. Default: ${DEFAULT_AXES.join(", ")}. Custom axes accepted; max ${String(MAX_AXES)}.`
46168
46360
  ),
46169
- context: z103.string().max(MAX_CONTEXT_LENGTH).optional().describe(
46361
+ context: z104.string().max(MAX_CONTEXT_LENGTH).optional().describe(
46170
46362
  "Optional context: relevant repo state, dependency tree, vendor publishing patterns, etc."
46171
46363
  ),
46172
- quickMode: z103.boolean().optional().default(false).describe("Use 3 voters (architect, security, scope_steward) instead of 7"),
46173
- simulate: z103.boolean().optional().default(false).describe("Use simulated voters (testing only)")
46364
+ quickMode: z104.boolean().optional().default(false).describe("Use 3 voters (architect, security, scope_steward) instead of 7"),
46365
+ simulate: z104.boolean().optional().default(false).describe("Use simulated voters (testing only)")
46174
46366
  });
46175
46367
  function buildTradeoffProposal(input) {
46176
46368
  const axes = input.axes ?? DEFAULT_AXES;
@@ -46676,6 +46868,28 @@ var TOOL_ANNOTATIONS = {
46676
46868
  { category: "implicit", description: "Consumes rate limit quota" }
46677
46869
  ]
46678
46870
  },
46871
+ run_quality_gate: {
46872
+ annotations: {
46873
+ title: "Run Quality Gate",
46874
+ // Spawns build/test toolchains which can write artifacts — not read-only.
46875
+ readOnlyHint: false,
46876
+ destructiveHint: false,
46877
+ // Same checks against the same code yield the same verdict.
46878
+ idempotentHint: true,
46879
+ // build/test/security invoke local toolchains and may reach the network.
46880
+ openWorldHint: true
46881
+ },
46882
+ sideEffects: [
46883
+ {
46884
+ category: "implicit",
46885
+ description: "Spawns local toolchain processes (tsc/eslint/vitest/build) in the target project dir"
46886
+ },
46887
+ {
46888
+ category: "implicit",
46889
+ description: "build/test checks may write build artifacts and coverage output to disk"
46890
+ }
46891
+ ]
46892
+ },
46679
46893
  issue_triage: {
46680
46894
  annotations: {
46681
46895
  title: "Issue Triage",
@@ -47100,7 +47314,8 @@ var REGISTERED_TOOL_NAMES = [
47100
47314
  "run_pipeline",
47101
47315
  "pr_review",
47102
47316
  "supply_chain_tradeoff_panel",
47103
- "improvement_review"
47317
+ "improvement_review",
47318
+ "run_quality_gate"
47104
47319
  ];
47105
47320
  function registerTools(server, options) {
47106
47321
  const logger55 = options?.logger ?? createMcpLogger({ component: "tools" });
@@ -47235,40 +47450,40 @@ var RiskLevel = /* @__PURE__ */ ((RiskLevel2) => {
47235
47450
  })(RiskLevel || {});
47236
47451
 
47237
47452
  // src/mcp/safety/stpa-schemas.ts
47238
- import { z as z104 } from "zod";
47239
- var HazardCategorySchema = z104.enum(HazardCategory);
47240
- var HazardSeveritySchema = z104.enum(HazardSeverity);
47241
- var ConstraintPrioritySchema = z104.enum(ConstraintPriority);
47242
- var RiskLevelSchema = z104.enum(RiskLevel);
47243
- var TriggerPatternSchema = z104.object({
47244
- parameter: z104.string().min(1),
47245
- matchType: z104.enum(["contains", "regex", "equals", "startsWith", "endsWith"]),
47246
- pattern: z104.string(),
47247
- reason: z104.string()
47453
+ import { z as z105 } from "zod";
47454
+ var HazardCategorySchema = z105.enum(HazardCategory);
47455
+ var HazardSeveritySchema = z105.enum(HazardSeverity);
47456
+ var ConstraintPrioritySchema = z105.enum(ConstraintPriority);
47457
+ var RiskLevelSchema = z105.enum(RiskLevel);
47458
+ var TriggerPatternSchema = z105.object({
47459
+ parameter: z105.string().min(1),
47460
+ matchType: z105.enum(["contains", "regex", "equals", "startsWith", "endsWith"]),
47461
+ pattern: z105.string(),
47462
+ reason: z105.string()
47248
47463
  });
47249
- var HazardSchema = z104.object({
47250
- id: z104.string().min(1),
47251
- description: z104.string(),
47464
+ var HazardSchema = z105.object({
47465
+ id: z105.string().min(1),
47466
+ description: z105.string(),
47252
47467
  category: HazardCategorySchema,
47253
47468
  severity: HazardSeveritySchema,
47254
- likelihood: z104.enum(["almost_certain", "likely", "possible", "unlikely", "rare"]),
47255
- triggerConditions: z104.array(z104.string()),
47256
- consequences: z104.array(z104.string())
47469
+ likelihood: z105.enum(["almost_certain", "likely", "possible", "unlikely", "rare"]),
47470
+ triggerConditions: z105.array(z105.string()),
47471
+ consequences: z105.array(z105.string())
47257
47472
  });
47258
- var UnsafeControlActionSchema = z104.object({
47259
- id: z104.string().min(1),
47260
- toolName: z104.string().min(1),
47261
- type: z104.enum(["not_provided", "provided_causes_hazard", "wrong_timing", "wrong_duration"]),
47262
- description: z104.string(),
47263
- unsafeContext: z104.string(),
47264
- relatedHazards: z104.array(z104.string()),
47265
- triggerPatterns: z104.array(TriggerPatternSchema).optional()
47473
+ var UnsafeControlActionSchema = z105.object({
47474
+ id: z105.string().min(1),
47475
+ toolName: z105.string().min(1),
47476
+ type: z105.enum(["not_provided", "provided_causes_hazard", "wrong_timing", "wrong_duration"]),
47477
+ description: z105.string(),
47478
+ unsafeContext: z105.string(),
47479
+ relatedHazards: z105.array(z105.string()),
47480
+ triggerPatterns: z105.array(TriggerPatternSchema).optional()
47266
47481
  });
47267
- var SafetyConstraintSchema = z104.object({
47268
- id: z104.string().min(1),
47269
- description: z104.string(),
47270
- mitigates: z104.array(z104.string()),
47271
- enforcement: z104.enum([
47482
+ var SafetyConstraintSchema = z105.object({
47483
+ id: z105.string().min(1),
47484
+ description: z105.string(),
47485
+ mitigates: z105.array(z105.string()),
47486
+ enforcement: z105.enum([
47272
47487
  "prevent",
47273
47488
  "require_confirmation",
47274
47489
  "alert",
@@ -47276,54 +47491,54 @@ var SafetyConstraintSchema = z104.object({
47276
47491
  "rate_limit",
47277
47492
  "require_privilege"
47278
47493
  ]),
47279
- validationFunction: z104.string().optional(),
47494
+ validationFunction: z105.string().optional(),
47280
47495
  priority: ConstraintPrioritySchema
47281
47496
  });
47282
- var PropertySchemaSchema = z104.object({
47283
- type: z104.string(),
47284
- description: z104.string().optional(),
47285
- enum: z104.array(z104.unknown()).optional(),
47286
- pattern: z104.string().optional(),
47287
- minimum: z104.number().optional(),
47288
- maximum: z104.number().optional()
47497
+ var PropertySchemaSchema = z105.object({
47498
+ type: z105.string(),
47499
+ description: z105.string().optional(),
47500
+ enum: z105.array(z105.unknown()).optional(),
47501
+ pattern: z105.string().optional(),
47502
+ minimum: z105.number().optional(),
47503
+ maximum: z105.number().optional()
47289
47504
  });
47290
- var ToolInputSchemaSchema = z104.object({
47291
- type: z104.string(),
47292
- properties: z104.record(z104.string(), PropertySchemaSchema).optional(),
47293
- required: z104.array(z104.string()).optional(),
47294
- additionalProperties: z104.boolean().optional()
47505
+ var ToolInputSchemaSchema = z105.object({
47506
+ type: z105.string(),
47507
+ properties: z105.record(z105.string(), PropertySchemaSchema).optional(),
47508
+ required: z105.array(z105.string()).optional(),
47509
+ additionalProperties: z105.boolean().optional()
47295
47510
  });
47296
- var ToolDefinitionSchema = z104.object({
47297
- name: z104.string().min(1),
47298
- description: z104.string(),
47511
+ var ToolDefinitionSchema = z105.object({
47512
+ name: z105.string().min(1),
47513
+ description: z105.string(),
47299
47514
  inputSchema: ToolInputSchemaSchema
47300
47515
  });
47301
- var AnalysisConfigurationSchema = z104.object({
47302
- includeLowSeverity: z104.boolean().default(true),
47303
- generateAllConstraints: z104.boolean().default(true),
47304
- checkInteractions: z104.boolean().default(true),
47305
- maxHazardsPerTool: z104.number().int().min(1).max(100).default(50),
47306
- categories: z104.array(HazardCategorySchema).default([])
47516
+ var AnalysisConfigurationSchema = z105.object({
47517
+ includeLowSeverity: z105.boolean().default(true),
47518
+ generateAllConstraints: z105.boolean().default(true),
47519
+ checkInteractions: z105.boolean().default(true),
47520
+ maxHazardsPerTool: z105.number().int().min(1).max(100).default(50),
47521
+ categories: z105.array(HazardCategorySchema).default([])
47307
47522
  });
47308
- var ConstraintViolationSchema = z104.object({
47309
- constraintId: z104.string().min(1),
47310
- constraintDescription: z104.string(),
47523
+ var ConstraintViolationSchema = z105.object({
47524
+ constraintId: z105.string().min(1),
47525
+ constraintDescription: z105.string(),
47311
47526
  severity: HazardSeveritySchema,
47312
- details: z104.string(),
47313
- remediation: z104.string()
47527
+ details: z105.string(),
47528
+ remediation: z105.string()
47314
47529
  });
47315
- var ValidationWarningSchema = z104.object({
47316
- code: z104.string().min(1),
47317
- message: z104.string(),
47318
- affected: z104.string()
47530
+ var ValidationWarningSchema = z105.object({
47531
+ code: z105.string().min(1),
47532
+ message: z105.string(),
47533
+ affected: z105.string()
47319
47534
  });
47320
- var ValidationResultSchema = z104.object({
47321
- valid: z104.boolean(),
47322
- toolName: z104.string().min(1),
47323
- violations: z104.array(ConstraintViolationSchema),
47324
- passed: z104.array(z104.string()),
47325
- warnings: z104.array(ValidationWarningSchema),
47326
- validatedAt: z104.date()
47535
+ var ValidationResultSchema = z105.object({
47536
+ valid: z105.boolean(),
47537
+ toolName: z105.string().min(1),
47538
+ violations: z105.array(ConstraintViolationSchema),
47539
+ passed: z105.array(z105.string()),
47540
+ warnings: z105.array(ValidationWarningSchema),
47541
+ validatedAt: z105.date()
47327
47542
  });
47328
47543
 
47329
47544
  // src/mcp/safety/stpa-types.ts
@@ -48408,43 +48623,43 @@ var GeminiResponseParser = class {
48408
48623
  };
48409
48624
 
48410
48625
  // src/cli-adapters/router-types.ts
48411
- import { z as z105 } from "zod";
48412
- var RouterConfigSchema = z105.object({
48413
- minCapacityThreshold: z105.number().min(0).max(1).default(0.1),
48414
- preferCostEfficient: z105.boolean().default(false),
48415
- maxDecisionTimeMs: z105.number().min(1).max(1e3).default(100)
48626
+ import { z as z106 } from "zod";
48627
+ var RouterConfigSchema = z106.object({
48628
+ minCapacityThreshold: z106.number().min(0).max(1).default(0.1),
48629
+ preferCostEfficient: z106.boolean().default(false),
48630
+ maxDecisionTimeMs: z106.number().min(1).max(1e3).default(100)
48416
48631
  });
48417
48632
 
48418
48633
  // src/cli-adapters/agreement-cascade-types.ts
48419
- import { z as z106 } from "zod";
48420
- var AgreementCascadeConfigSchema = z106.object({
48421
- agreementThreshold: z106.number().min(0.5).max(1).default(0.7),
48422
- maxStages: z106.number().int().min(1).max(5).default(3),
48423
- modelTimeoutMs: z106.number().int().min(1e3).max(3e5).default(6e4)
48634
+ import { z as z107 } from "zod";
48635
+ var AgreementCascadeConfigSchema = z107.object({
48636
+ agreementThreshold: z107.number().min(0.5).max(1).default(0.7),
48637
+ maxStages: z107.number().int().min(1).max(5).default(3),
48638
+ modelTimeoutMs: z107.number().int().min(1e3).max(3e5).default(6e4)
48424
48639
  });
48425
48640
 
48426
48641
  // src/cli-adapters/agreement-cascade-router.ts
48427
48642
  var logger45 = createLogger({ component: "agreement-cascade-router" });
48428
48643
 
48429
48644
  // src/cli-adapters/task-classifier.ts
48430
- import { z as z107 } from "zod";
48431
- var ClassificationPatternsSchema = z107.object({
48432
- code: z107.array(z107.string()).readonly(),
48433
- research: z107.array(z107.string()).readonly(),
48434
- documentation: z107.array(z107.string()).readonly(),
48435
- analysis: z107.array(z107.string()).readonly()
48645
+ import { z as z108 } from "zod";
48646
+ var ClassificationPatternsSchema = z108.object({
48647
+ code: z108.array(z108.string()).readonly(),
48648
+ research: z108.array(z108.string()).readonly(),
48649
+ documentation: z108.array(z108.string()).readonly(),
48650
+ analysis: z108.array(z108.string()).readonly()
48436
48651
  });
48437
48652
 
48438
48653
  // src/cli-adapters/response-cache-types.ts
48439
- import { z as z108 } from "zod";
48440
- var ResponseCacheConfigSchema = z108.object({
48441
- defaultTTL: z108.number().min(1e3).max(36e5).default(3e5),
48654
+ import { z as z109 } from "zod";
48655
+ var ResponseCacheConfigSchema = z109.object({
48656
+ defaultTTL: z109.number().min(1e3).max(36e5).default(3e5),
48442
48657
  // 5 minutes
48443
- maxEntries: z108.number().min(10).max(1e5).default(1e3),
48444
- maxMemoryMB: z108.number().min(1).max(1e3).default(50),
48445
- cleanupInterval: z108.number().min(1e3).max(6e5).default(6e4),
48658
+ maxEntries: z109.number().min(10).max(1e5).default(1e3),
48659
+ maxMemoryMB: z109.number().min(1).max(1e3).default(50),
48660
+ cleanupInterval: z109.number().min(1e3).max(6e5).default(6e4),
48446
48661
  // 1 minute
48447
- enableLogging: z108.boolean().default(false)
48662
+ enableLogging: z109.boolean().default(false)
48448
48663
  });
48449
48664
 
48450
48665
  // src/cli-adapters/response-cache-utils.ts
@@ -48452,12 +48667,12 @@ import { createHash as createHash4 } from "crypto";
48452
48667
  var logger46 = createLogger({ component: "ResponseCacheUtils" });
48453
48668
 
48454
48669
  // src/cli-adapters/unified-routing-types.ts
48455
- import { z as z109 } from "zod";
48456
- var UnifiedRoutingDecisionSchema = z109.object({
48457
- selectedCli: z109.string(),
48458
- confidence: z109.number().min(0).max(1),
48459
- reason: z109.string(),
48460
- strategy: z109.enum([
48670
+ import { z as z110 } from "zod";
48671
+ var UnifiedRoutingDecisionSchema = z110.object({
48672
+ selectedCli: z110.string(),
48673
+ confidence: z110.number().min(0).max(1),
48674
+ reason: z110.string(),
48675
+ strategy: z110.enum([
48461
48676
  "composite",
48462
48677
  "quality",
48463
48678
  "budget",
@@ -48469,57 +48684,57 @@ var UnifiedRoutingDecisionSchema = z109.object({
48469
48684
  "linucb",
48470
48685
  "direct"
48471
48686
  ]),
48472
- decisionTimeMs: z109.number().nonnegative(),
48473
- alternatives: z109.array(z109.string()).readonly(),
48474
- stagesExecuted: z109.array(z109.string()).readonly(),
48475
- withinBudget: z109.boolean().optional(),
48476
- estimatedComplexity: z109.enum(["simple", "moderate", "complex", "expert"]).optional(),
48477
- estimatedTokens: z109.number().int().positive().optional(),
48478
- topsisScore: z109.number().optional(),
48479
- ucbScore: z109.number().optional(),
48480
- resolvedAtStage: z109.number().int().nonnegative().optional(),
48481
- consensusReached: z109.boolean().optional(),
48482
- agreementScore: z109.number().min(0).max(1).optional(),
48483
- metadata: z109.record(z109.string(), z109.unknown()).optional()
48687
+ decisionTimeMs: z110.number().nonnegative(),
48688
+ alternatives: z110.array(z110.string()).readonly(),
48689
+ stagesExecuted: z110.array(z110.string()).readonly(),
48690
+ withinBudget: z110.boolean().optional(),
48691
+ estimatedComplexity: z110.enum(["simple", "moderate", "complex", "expert"]).optional(),
48692
+ estimatedTokens: z110.number().int().positive().optional(),
48693
+ topsisScore: z110.number().optional(),
48694
+ ucbScore: z110.number().optional(),
48695
+ resolvedAtStage: z110.number().int().nonnegative().optional(),
48696
+ consensusReached: z110.boolean().optional(),
48697
+ agreementScore: z110.number().min(0).max(1).optional(),
48698
+ metadata: z110.record(z110.string(), z110.unknown()).optional()
48484
48699
  });
48485
48700
 
48486
48701
  // src/learning/outcome-feedback-types.ts
48487
- import { z as z110 } from "zod";
48488
- var QualitySignalsSchema = z110.object({
48489
- testsPass: z110.boolean().optional(),
48490
- lintErrors: z110.number().int().min(0).optional(),
48491
- userApproved: z110.boolean().optional(),
48492
- retryCount: z110.number().int().min(0).default(0),
48493
- completionRatio: z110.number().min(0).max(1).default(1),
48494
- validStructure: z110.boolean().optional(),
48495
- coherenceScore: z110.number().min(0).max(1).optional()
48702
+ import { z as z111 } from "zod";
48703
+ var QualitySignalsSchema = z111.object({
48704
+ testsPass: z111.boolean().optional(),
48705
+ lintErrors: z111.number().int().min(0).optional(),
48706
+ userApproved: z111.boolean().optional(),
48707
+ retryCount: z111.number().int().min(0).default(0),
48708
+ completionRatio: z111.number().min(0).max(1).default(1),
48709
+ validStructure: z111.boolean().optional(),
48710
+ coherenceScore: z111.number().min(0).max(1).optional()
48496
48711
  });
48497
- var RoutingDecisionSchema = z110.object({
48498
- id: z110.uuid(),
48499
- timestamp: z110.iso.datetime(),
48500
- query: z110.string(),
48501
- routerType: z110.enum(["linucb", "preference", "quality", "cascade", "topsis"]),
48502
- selectedModel: z110.string(),
48503
- selectedTier: z110.enum(["strong", "weak"]).optional(),
48504
- armIndex: z110.number().int().min(0).optional(),
48505
- banditContext: z110.record(z110.string(), z110.unknown()).optional(),
48506
- queryFeatures: z110.record(z110.string(), z110.unknown()).optional(),
48507
- ucbScore: z110.number().optional(),
48508
- confidence: z110.number().min(0).max(1).optional(),
48509
- traceId: z110.string(),
48510
- domain: z110.string().optional()
48712
+ var RoutingDecisionSchema = z111.object({
48713
+ id: z111.uuid(),
48714
+ timestamp: z111.iso.datetime(),
48715
+ query: z111.string(),
48716
+ routerType: z111.enum(["linucb", "preference", "quality", "cascade", "topsis"]),
48717
+ selectedModel: z111.string(),
48718
+ selectedTier: z111.enum(["strong", "weak"]).optional(),
48719
+ armIndex: z111.number().int().min(0).optional(),
48720
+ banditContext: z111.record(z111.string(), z111.unknown()).optional(),
48721
+ queryFeatures: z111.record(z111.string(), z111.unknown()).optional(),
48722
+ ucbScore: z111.number().optional(),
48723
+ confidence: z111.number().min(0).max(1).optional(),
48724
+ traceId: z111.string(),
48725
+ domain: z111.string().optional()
48511
48726
  });
48512
- var TaskOutcomeSchema = z110.object({
48513
- routingDecisionId: z110.uuid(),
48514
- timestamp: z110.iso.datetime(),
48515
- outcomeClass: z110.enum(["success", "partial", "failure", "timeout", "error"]),
48516
- success: z110.boolean(),
48517
- qualityScore: z110.number().min(0).max(1),
48518
- durationMs: z110.number().min(0),
48519
- tokenUsage: z110.number().int().min(0),
48520
- errorMessage: z110.string().optional(),
48727
+ var TaskOutcomeSchema = z111.object({
48728
+ routingDecisionId: z111.uuid(),
48729
+ timestamp: z111.iso.datetime(),
48730
+ outcomeClass: z111.enum(["success", "partial", "failure", "timeout", "error"]),
48731
+ success: z111.boolean(),
48732
+ qualityScore: z111.number().min(0).max(1),
48733
+ durationMs: z111.number().min(0),
48734
+ tokenUsage: z111.number().int().min(0),
48735
+ errorMessage: z111.string().optional(),
48521
48736
  qualitySignals: QualitySignalsSchema,
48522
- traceId: z110.string()
48737
+ traceId: z111.string()
48523
48738
  });
48524
48739
  var DEFAULT_FEEDBACK_COLLECTOR_CONFIG = {
48525
48740
  maxPendingDecisions: 1e3,
@@ -48534,17 +48749,17 @@ var DEFAULT_FEEDBACK_COLLECTOR_CONFIG = {
48534
48749
  targetTokenUsage: 2e3,
48535
48750
  maxHistorySize: 1e4
48536
48751
  };
48537
- var FeedbackCollectorConfigSchema = z110.object({
48538
- maxPendingDecisions: z110.number().int().positive().default(1e3),
48539
- pendingTimeoutMs: z110.number().positive().default(3e5),
48540
- enableAutoReward: z110.boolean().default(true),
48541
- qualityWeight: z110.number().min(0).max(1).default(0.5),
48542
- speedWeight: z110.number().min(0).max(1).default(0.2),
48543
- efficiencyWeight: z110.number().min(0).max(1).default(0.2),
48544
- retryPenalty: z110.number().min(0).max(1).default(0.1),
48545
- targetDurationMs: z110.number().positive().default(5e3),
48546
- targetTokenUsage: z110.number().positive().default(2e3),
48547
- maxHistorySize: z110.number().int().positive().default(1e4)
48752
+ var FeedbackCollectorConfigSchema = z111.object({
48753
+ maxPendingDecisions: z111.number().int().positive().default(1e3),
48754
+ pendingTimeoutMs: z111.number().positive().default(3e5),
48755
+ enableAutoReward: z111.boolean().default(true),
48756
+ qualityWeight: z111.number().min(0).max(1).default(0.5),
48757
+ speedWeight: z111.number().min(0).max(1).default(0.2),
48758
+ efficiencyWeight: z111.number().min(0).max(1).default(0.2),
48759
+ retryPenalty: z111.number().min(0).max(1).default(0.1),
48760
+ targetDurationMs: z111.number().positive().default(5e3),
48761
+ targetTokenUsage: z111.number().positive().default(2e3),
48762
+ maxHistorySize: z111.number().int().positive().default(1e4)
48548
48763
  });
48549
48764
 
48550
48765
  // src/learning/outcome-feedback-helpers.ts
@@ -50781,6 +50996,7 @@ export {
50781
50996
  registerListJobsTool,
50782
50997
  registerCancelJobTool,
50783
50998
  registerCiHealthCheckTool,
50999
+ registerRunQualityGateTool,
50784
51000
  AuditError,
50785
51001
  AuditCategorySchema,
50786
51002
  AuditSeveritySchema,
@@ -50864,4 +51080,4 @@ export {
50864
51080
  detectBackend,
50865
51081
  createTaskTracker
50866
51082
  };
50867
- //# sourceMappingURL=chunk-DE3J2HYT.js.map
51083
+ //# sourceMappingURL=chunk-O6EXYWHP.js.map