nexus-agents 3.13.4 → 3.14.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/{chunk-4QJWK6DY.js → chunk-AV4X4YH3.js} +8 -3
- package/dist/{chunk-4QJWK6DY.js.map → chunk-AV4X4YH3.js.map} +1 -1
- package/dist/{chunk-IPHDQZR2.js → chunk-AYLYRBS6.js} +12 -8
- package/dist/{chunk-IPHDQZR2.js.map → chunk-AYLYRBS6.js.map} +1 -1
- package/dist/{chunk-GUDO6DBM.js → chunk-JTH44T6O.js} +235 -76
- package/dist/chunk-JTH44T6O.js.map +1 -0
- package/dist/{chunk-JOWMSVIM.js → chunk-MHLXBATW.js} +37 -173
- package/dist/chunk-MHLXBATW.js.map +1 -0
- package/dist/{chunk-XPXOP7AC.js → chunk-NF2LMA5A.js} +3 -3
- package/dist/{chunk-3ENIOANU.js → chunk-WZGXBPIY.js} +2 -2
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +77 -31
- package/dist/cli.js.map +1 -1
- package/dist/{consensus-vote-KO3YN346.js → consensus-vote-NFXP65ET.js} +3 -3
- package/dist/{consensus-vote-types-b-KD-0g_.d.ts → consensus-vote-types-DjPVrCIO.d.ts} +31 -1
- package/dist/{improvement-review-2IV2L7QI.js → improvement-review-AZHHCQ2Q.js} +3 -3
- package/dist/index.d.ts +10 -3
- package/dist/index.js +6 -6
- package/dist/{setup-command-XJHLFBD4.js → setup-command-NAXE7M4Q.js} +3 -3
- package/package.json +1 -1
- package/dist/chunk-GUDO6DBM.js.map +0 -1
- package/dist/chunk-JOWMSVIM.js.map +0 -1
- /package/dist/{chunk-XPXOP7AC.js.map → chunk-NF2LMA5A.js.map} +0 -0
- /package/dist/{chunk-3ENIOANU.js.map → chunk-WZGXBPIY.js.map} +0 -0
- /package/dist/{consensus-vote-KO3YN346.js.map → consensus-vote-NFXP65ET.js.map} +0 -0
- /package/dist/{improvement-review-2IV2L7QI.js.map → improvement-review-AZHHCQ2Q.js.map} +0 -0
- /package/dist/{setup-command-XJHLFBD4.js.map → setup-command-NAXE7M4Q.js.map} +0 -0
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
REJECTION_CATEGORIES,
|
|
3
|
+
UNATTRIBUTED_WORKSPACE,
|
|
3
4
|
createSecureHandler,
|
|
4
5
|
getToolAnnotations,
|
|
6
|
+
getToolFitnessLedger,
|
|
5
7
|
getToolTimeout,
|
|
6
8
|
toSdkCallback,
|
|
7
9
|
toolStructuredError,
|
|
8
10
|
toolSuccessStructured,
|
|
9
11
|
wrapToolWithTimeout
|
|
10
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-JTH44T6O.js";
|
|
11
13
|
import {
|
|
12
14
|
JsonlStore,
|
|
13
15
|
SECURITY_KEYWORDS,
|
|
@@ -29,7 +31,7 @@ import {
|
|
|
29
31
|
import { execFile as execFile2 } from "child_process";
|
|
30
32
|
import { readFile } from "fs/promises";
|
|
31
33
|
import { promisify as promisify2 } from "util";
|
|
32
|
-
import { z as
|
|
34
|
+
import { z as z2 } from "zod";
|
|
33
35
|
|
|
34
36
|
// src/mcp/middleware/tool-prerequisites.ts
|
|
35
37
|
import { execFile } from "child_process";
|
|
@@ -893,144 +895,6 @@ function consolidationSignal(stat, family, busiestTool, busiestCount, windowLabe
|
|
|
893
895
|
});
|
|
894
896
|
}
|
|
895
897
|
|
|
896
|
-
// src/governance/tool-fitness-ledger.ts
|
|
897
|
-
import { z } from "zod";
|
|
898
|
-
var ToolFitnessEventSchema = z.object({
|
|
899
|
-
/** Schema version. Forward-compat for on-disk evolution. */
|
|
900
|
-
v: z.literal(1),
|
|
901
|
-
/** ISO-8601 timestamp of the invocation. */
|
|
902
|
-
ts: z.iso.datetime(),
|
|
903
|
-
/** Tool identifier (e.g. the MCP tool name). */
|
|
904
|
-
tool: z.string().min(1).max(100),
|
|
905
|
-
/** Whether the invocation succeeded. Drives the success/failure correlation. */
|
|
906
|
-
success: z.boolean(),
|
|
907
|
-
/**
|
|
908
|
-
* Cost of the invocation in arbitrary units (e.g. tokens), when the calling
|
|
909
|
-
* surface exposes it. Placeholder until full cost accounting lands with
|
|
910
|
-
* Epic G — absent (not zero) when unknown so aggregates don't conflate
|
|
911
|
-
* "free" with "unmeasured".
|
|
912
|
-
*/
|
|
913
|
-
cost: z.number().nonnegative().optional(),
|
|
914
|
-
/**
|
|
915
|
-
* OPTIONAL workspace/repo dimension (#3852 concern 1 — context-poisoning).
|
|
916
|
-
* The ledger is homedir-global, so a tool that fails only in ONE workspace
|
|
917
|
-
* (local perms, missing deps, repo-specific config) would otherwise aggregate
|
|
918
|
-
* into a single global fitness number and could wrongly flag a tool that is
|
|
919
|
-
* healthy everywhere else. Recording the originating workspace lets the
|
|
920
|
-
* consumer scope/weight fitness so a one-workspace failure doesn't get
|
|
921
|
-
* globally penalized. BACKWARD-COMPATIBLE: optional, absent on legacy events
|
|
922
|
-
* (treated as the unattributed/global bucket by the consumer).
|
|
923
|
-
*/
|
|
924
|
-
workspace: z.string().min(1).max(256).optional()
|
|
925
|
-
});
|
|
926
|
-
var UNATTRIBUTED_WORKSPACE = "(unattributed)";
|
|
927
|
-
var DEFAULT_MAX_EVENTS = 5e4;
|
|
928
|
-
var LEDGER_SUBDIR = "tool-fitness";
|
|
929
|
-
var LEDGER_FILE = "ledger.jsonl";
|
|
930
|
-
var ToolFitnessLedger = class {
|
|
931
|
-
store;
|
|
932
|
-
constructor(config) {
|
|
933
|
-
this.store = new JsonlStore({
|
|
934
|
-
filePath: config?.filePath ?? nexusDataPath(LEDGER_SUBDIR, LEDGER_FILE),
|
|
935
|
-
schema: ToolFitnessEventSchema,
|
|
936
|
-
maxRecords: config?.maxEvents ?? DEFAULT_MAX_EVENTS,
|
|
937
|
-
component: "ToolFitnessLedger"
|
|
938
|
-
});
|
|
939
|
-
}
|
|
940
|
-
/**
|
|
941
|
-
* Record one tool invocation. `v`/`ts` are stamped here so callers pass only
|
|
942
|
-
* the observed signal. Best-effort durability (inherited from JsonlStore):
|
|
943
|
-
* never throws into the observed operation.
|
|
944
|
-
*/
|
|
945
|
-
record(event) {
|
|
946
|
-
const record = {
|
|
947
|
-
v: 1,
|
|
948
|
-
ts: event.ts ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
949
|
-
tool: event.tool,
|
|
950
|
-
success: event.success,
|
|
951
|
-
...event.cost !== void 0 ? { cost: event.cost } : {},
|
|
952
|
-
...event.workspace !== void 0 ? { workspace: event.workspace } : {}
|
|
953
|
-
};
|
|
954
|
-
this.store.append(record);
|
|
955
|
-
}
|
|
956
|
-
/** Total retained events across all tools. */
|
|
957
|
-
size() {
|
|
958
|
-
return this.store.count();
|
|
959
|
-
}
|
|
960
|
-
/**
|
|
961
|
-
* Aggregate stats for a single tool, or `undefined` when the tool has no
|
|
962
|
-
* recorded events (unknown tool / empty ledger). Pure over the current
|
|
963
|
-
* event set — no I/O.
|
|
964
|
-
*/
|
|
965
|
-
statFor(tool) {
|
|
966
|
-
const events = this.store.all().filter((e) => e.tool === tool);
|
|
967
|
-
if (events.length === 0) return void 0;
|
|
968
|
-
return aggregate(tool, events);
|
|
969
|
-
}
|
|
970
|
-
/**
|
|
971
|
-
* Aggregate stats for a single tool RESTRICTED to one workspace (#3852
|
|
972
|
-
* concern 1 — context-poisoning). Pass {@link UNATTRIBUTED_WORKSPACE} to
|
|
973
|
-
* select the legacy/global bucket of events that carried no `workspace`.
|
|
974
|
-
* Returns `undefined` when the tool has no events in that workspace.
|
|
975
|
-
*
|
|
976
|
-
* This is the primitive that lets the consumer answer "is this tool low-fitness
|
|
977
|
-
* EVERYWHERE, or only in one repo?" so a single-workspace failure can't
|
|
978
|
-
* globally mis-flag a healthy tool.
|
|
979
|
-
*/
|
|
980
|
-
statForInWorkspace(tool, workspace) {
|
|
981
|
-
const events = this.store.all().filter((e) => e.tool === tool && (e.workspace ?? UNATTRIBUTED_WORKSPACE) === workspace);
|
|
982
|
-
if (events.length === 0) return void 0;
|
|
983
|
-
return aggregate(tool, events);
|
|
984
|
-
}
|
|
985
|
-
/**
|
|
986
|
-
* Aggregate stats for every tool with at least one event, sorted by
|
|
987
|
-
* descending invocation count (most-used first) then tool name for a stable
|
|
988
|
-
* order. Returns `[]` for an empty ledger.
|
|
989
|
-
*/
|
|
990
|
-
report() {
|
|
991
|
-
const byTool = /* @__PURE__ */ new Map();
|
|
992
|
-
for (const event of this.store.all()) {
|
|
993
|
-
const bucket = byTool.get(event.tool);
|
|
994
|
-
if (bucket === void 0) byTool.set(event.tool, [event]);
|
|
995
|
-
else bucket.push(event);
|
|
996
|
-
}
|
|
997
|
-
const stats = [];
|
|
998
|
-
for (const [tool, events] of byTool) {
|
|
999
|
-
stats.push(aggregate(tool, events));
|
|
1000
|
-
}
|
|
1001
|
-
stats.sort((a, b) => b.invocationCount - a.invocationCount || a.tool.localeCompare(b.tool));
|
|
1002
|
-
return stats;
|
|
1003
|
-
}
|
|
1004
|
-
};
|
|
1005
|
-
function aggregate(tool, events) {
|
|
1006
|
-
let successCount = 0;
|
|
1007
|
-
let lastUsedAt = "";
|
|
1008
|
-
let totalCost;
|
|
1009
|
-
const workspaces = /* @__PURE__ */ new Set();
|
|
1010
|
-
for (const event of events) {
|
|
1011
|
-
if (event.success) successCount++;
|
|
1012
|
-
if (lastUsedAt === "" || Date.parse(event.ts) >= Date.parse(lastUsedAt)) lastUsedAt = event.ts;
|
|
1013
|
-
if (event.cost !== void 0) totalCost = (totalCost ?? 0) + event.cost;
|
|
1014
|
-
workspaces.add(event.workspace ?? UNATTRIBUTED_WORKSPACE);
|
|
1015
|
-
}
|
|
1016
|
-
const invocationCount = events.length;
|
|
1017
|
-
return {
|
|
1018
|
-
tool,
|
|
1019
|
-
invocationCount,
|
|
1020
|
-
successCount,
|
|
1021
|
-
failureCount: invocationCount - successCount,
|
|
1022
|
-
successRate: successCount / invocationCount,
|
|
1023
|
-
lastUsedAt,
|
|
1024
|
-
totalCost,
|
|
1025
|
-
workspaces: [...workspaces].sort((a, b) => a.localeCompare(b))
|
|
1026
|
-
};
|
|
1027
|
-
}
|
|
1028
|
-
var singleton;
|
|
1029
|
-
function getToolFitnessLedger() {
|
|
1030
|
-
singleton ??= new ToolFitnessLedger();
|
|
1031
|
-
return singleton;
|
|
1032
|
-
}
|
|
1033
|
-
|
|
1034
898
|
// src/mcp/tools/improvement-review-tool-fitness.ts
|
|
1035
899
|
function isHealthyInAnyOtherWorkspace(stat, statInWorkspace) {
|
|
1036
900
|
const realWorkspaces = stat.workspaces.filter((w) => w !== UNATTRIBUTED_WORKSPACE);
|
|
@@ -1261,7 +1125,7 @@ function improvementSignalsToTasks(signals, existingTaskIds) {
|
|
|
1261
1125
|
}
|
|
1262
1126
|
|
|
1263
1127
|
// src/mcp/tools/improvement-remediation-shadow.ts
|
|
1264
|
-
import { z
|
|
1128
|
+
import { z } from "zod";
|
|
1265
1129
|
|
|
1266
1130
|
// src/mcp/tools/diff-secret-scan.ts
|
|
1267
1131
|
var SECRET_PATTERNS = [
|
|
@@ -1346,30 +1210,30 @@ function recordRemediationShadow(signals, sink = getRemediationShadowSink()) {
|
|
|
1346
1210
|
for (const record of records) sink.record(record);
|
|
1347
1211
|
return records;
|
|
1348
1212
|
}
|
|
1349
|
-
var SoakVoteOutcomeSchema =
|
|
1350
|
-
approved:
|
|
1213
|
+
var SoakVoteOutcomeSchema = z.object({
|
|
1214
|
+
approved: z.boolean(),
|
|
1351
1215
|
/** Approval percentage at vote time, 0–100 (the consensus tally). */
|
|
1352
|
-
approvalPercentage:
|
|
1216
|
+
approvalPercentage: z.number()
|
|
1353
1217
|
});
|
|
1354
|
-
var RemediationSoakRecordSchema =
|
|
1218
|
+
var RemediationSoakRecordSchema = z.object({
|
|
1355
1219
|
/** ISO-8601 capture time. */
|
|
1356
|
-
timestamp:
|
|
1220
|
+
timestamp: z.string(),
|
|
1357
1221
|
/** The improvement signal's stable key. */
|
|
1358
|
-
signalKey:
|
|
1222
|
+
signalKey: z.string(),
|
|
1359
1223
|
/** The signal's category. */
|
|
1360
|
-
category:
|
|
1224
|
+
category: z.string(),
|
|
1361
1225
|
/** The classified remediation priority (p0–p4). */
|
|
1362
|
-
priority:
|
|
1226
|
+
priority: z.string(),
|
|
1363
1227
|
/** The signal's declared severity. */
|
|
1364
|
-
severity:
|
|
1228
|
+
severity: z.string(),
|
|
1365
1229
|
/** Vote outcome (approved/rejected + tally), undefined if the signal never reached a vote. */
|
|
1366
1230
|
voteOutcome: SoakVoteOutcomeSchema.optional(),
|
|
1367
1231
|
/** Number of plan steps research produced (0 if research/plan failed). */
|
|
1368
|
-
planStepCount:
|
|
1232
|
+
planStepCount: z.number(),
|
|
1369
1233
|
/** p0 dry-run result detail (scrubbed); undefined for non-p0 or when no dry-run ran. */
|
|
1370
|
-
dryRunResult:
|
|
1234
|
+
dryRunResult: z.string().optional(),
|
|
1371
1235
|
/** Human-readable verdict reason (scrubbed). */
|
|
1372
|
-
reason:
|
|
1236
|
+
reason: z.string()
|
|
1373
1237
|
});
|
|
1374
1238
|
var SOAK_MAX_RECORDS = 1e4;
|
|
1375
1239
|
function getRemediationSoakFile() {
|
|
@@ -1557,14 +1421,14 @@ function classifySignalPriority(signal) {
|
|
|
1557
1421
|
|
|
1558
1422
|
// src/mcp/tools/improvement-review.ts
|
|
1559
1423
|
var execFileAsync2 = promisify2(execFile2);
|
|
1560
|
-
var ImprovementReviewInputSchema =
|
|
1561
|
-
lookbackDays:
|
|
1562
|
-
fileIssues:
|
|
1424
|
+
var ImprovementReviewInputSchema = z2.object({
|
|
1425
|
+
lookbackDays: z2.number().int().min(1).max(90).optional().default(7).describe("Lookback window for outcome data, in days. Default 7."),
|
|
1426
|
+
fileIssues: z2.boolean().optional().default(false).describe(
|
|
1563
1427
|
"When true, file candidate issues via `gh issue create` for crossed thresholds (rate-limited to 5 per run, deduped against open issues). When false (default), return signals only."
|
|
1564
1428
|
),
|
|
1565
|
-
minSampleSize:
|
|
1566
|
-
fitnessFloor:
|
|
1567
|
-
selfEvalReportPath:
|
|
1429
|
+
minSampleSize: z2.number().int().min(1).max(1e3).optional().default(5).describe("Minimum sample size before a CLI/category signal can fire."),
|
|
1430
|
+
fitnessFloor: z2.number().int().min(0).max(100).optional().default(90).describe("Fitness score below this threshold triggers a tech-debt signal."),
|
|
1431
|
+
selfEvalReportPath: z2.string().optional().describe(
|
|
1568
1432
|
"Optional path to a self-eval JSON report (from `self-eval --json`). When set, high-confidence unanimous deprecate/refactor findings are surfaced as tech-debt signals through the same deduped/rate-limited issue path (#3224). Unreadable/malformed reports are skipped (no signal). Absent \u2192 no self-eval signals."
|
|
1569
1433
|
)
|
|
1570
1434
|
});
|
|
@@ -1843,14 +1707,14 @@ function detectFitnessSignals(audit, fitnessFloor) {
|
|
|
1843
1707
|
return signals;
|
|
1844
1708
|
}
|
|
1845
1709
|
var SELF_EVAL_CONFIDENCE_FLOOR = 0.8;
|
|
1846
|
-
var SelfEvalReportSchema =
|
|
1847
|
-
results:
|
|
1848
|
-
|
|
1849
|
-
component:
|
|
1850
|
-
finalRecommendation:
|
|
1851
|
-
confidence:
|
|
1852
|
-
dissent:
|
|
1853
|
-
evidenceQuality:
|
|
1710
|
+
var SelfEvalReportSchema = z2.object({
|
|
1711
|
+
results: z2.array(
|
|
1712
|
+
z2.object({
|
|
1713
|
+
component: z2.string(),
|
|
1714
|
+
finalRecommendation: z2.string(),
|
|
1715
|
+
confidence: z2.number(),
|
|
1716
|
+
dissent: z2.array(z2.unknown()).optional().default([]),
|
|
1717
|
+
evidenceQuality: z2.number().optional()
|
|
1854
1718
|
})
|
|
1855
1719
|
)
|
|
1856
1720
|
});
|
|
@@ -2073,13 +1937,13 @@ async function reviewHandler(args, ctx) {
|
|
|
2073
1937
|
}
|
|
2074
1938
|
var description = "Periodic threshold-gated observability-driven improvement loop. Reads OutcomeStore + fitness audit, surfaces patterns crossing documented thresholds as candidate findings. When fileIssues=true, files candidate GitHub issues via `gh issue create` (rate-limited to 5 per run, deduped against open issues). Never auto-merges. Replaces the deleted self-development engine (#2402).";
|
|
2075
1939
|
var TOOL_INPUT_SCHEMA = {
|
|
2076
|
-
lookbackDays:
|
|
2077
|
-
fileIssues:
|
|
1940
|
+
lookbackDays: z2.number().int().min(1).max(90).optional().describe("Lookback window for outcome data, in days. Default 7."),
|
|
1941
|
+
fileIssues: z2.boolean().optional().describe(
|
|
2078
1942
|
"When true, file candidate issues for crossed thresholds (default false \u2014 return signals only)"
|
|
2079
1943
|
),
|
|
2080
|
-
minSampleSize:
|
|
2081
|
-
fitnessFloor:
|
|
2082
|
-
selfEvalReportPath:
|
|
1944
|
+
minSampleSize: z2.number().int().min(1).max(1e3).optional().describe("Minimum sample size before a CLI/category signal fires (default 5)."),
|
|
1945
|
+
fitnessFloor: z2.number().int().min(0).max(100).optional().describe("Fitness score below this threshold triggers a tech-debt signal (default 90)."),
|
|
1946
|
+
selfEvalReportPath: z2.string().optional().describe(
|
|
2083
1947
|
"Optional path to a self-eval JSON report. High-confidence unanimous deprecate/refactor findings surface as tech-debt signals (#3224)."
|
|
2084
1948
|
)
|
|
2085
1949
|
};
|
|
@@ -2132,4 +1996,4 @@ export {
|
|
|
2132
1996
|
runImprovementReview,
|
|
2133
1997
|
registerImprovementReviewTool
|
|
2134
1998
|
};
|
|
2135
|
-
//# sourceMappingURL=chunk-
|
|
1999
|
+
//# sourceMappingURL=chunk-MHLXBATW.js.map
|