nexus-agents 2.63.5 → 2.64.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-LDLLFUM4.js → chunk-KTL65MHM.js} +2 -2
- package/dist/{chunk-3K6O2OL5.js → chunk-Q3PDQ3FZ.js} +3 -3
- package/dist/{chunk-LQPW7LIC.js → chunk-RLLMWZAE.js} +1150 -477
- package/dist/chunk-RLLMWZAE.js.map +1 -0
- package/dist/cli.js +35 -13
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +0 -32
- package/dist/index.js +2 -2
- package/dist/{setup-command-F3NRMEDS.js → setup-command-MDGZYUW5.js} +3 -3
- package/package.json +1 -1
- package/dist/chunk-LQPW7LIC.js.map +0 -1
- /package/dist/{chunk-LDLLFUM4.js.map → chunk-KTL65MHM.js.map} +0 -0
- /package/dist/{chunk-3K6O2OL5.js.map → chunk-Q3PDQ3FZ.js.map} +0 -0
- /package/dist/{setup-command-F3NRMEDS.js.map → setup-command-MDGZYUW5.js.map} +0 -0
|
@@ -69,7 +69,7 @@ import {
|
|
|
69
69
|
clampTaskTtl,
|
|
70
70
|
getAvailabilityCache,
|
|
71
71
|
resolveFallback
|
|
72
|
-
} from "./chunk-
|
|
72
|
+
} from "./chunk-Q3PDQ3FZ.js";
|
|
73
73
|
import {
|
|
74
74
|
DEFAULTS
|
|
75
75
|
} from "./chunk-6MRF2PE2.js";
|
|
@@ -2468,13 +2468,13 @@ function makeCancelError(taskId) {
|
|
|
2468
2468
|
}
|
|
2469
2469
|
function executeWithTimeout(params) {
|
|
2470
2470
|
const { task, maxDurationMs, executeTask, transformError, signal } = params;
|
|
2471
|
-
return new Promise((
|
|
2471
|
+
return new Promise((resolve19) => {
|
|
2472
2472
|
let settled = false;
|
|
2473
2473
|
const settle = (result) => {
|
|
2474
2474
|
if (settled) return;
|
|
2475
2475
|
settled = true;
|
|
2476
2476
|
clearTimeout(timeoutId);
|
|
2477
|
-
|
|
2477
|
+
resolve19(result);
|
|
2478
2478
|
};
|
|
2479
2479
|
const timeoutId = setTimeout(() => {
|
|
2480
2480
|
settle(
|
|
@@ -4561,7 +4561,7 @@ var ConsensusProtocol = class {
|
|
|
4561
4561
|
requireUnanimous: config.requireUnanimous
|
|
4562
4562
|
});
|
|
4563
4563
|
const votingTask = createVotingTask(config.task);
|
|
4564
|
-
const
|
|
4564
|
+
const promises2 = config.experts.map(async (expertId) => {
|
|
4565
4565
|
const agent = agents.get(expertId);
|
|
4566
4566
|
if (agent === void 0) {
|
|
4567
4567
|
return { expertId, result: err(new AgentError(`Agent not found: ${expertId}`)) };
|
|
@@ -4569,7 +4569,7 @@ var ConsensusProtocol = class {
|
|
|
4569
4569
|
const result = await this.executeAgentTask(agent, votingTask);
|
|
4570
4570
|
return { expertId, result };
|
|
4571
4571
|
});
|
|
4572
|
-
const results = await Promise.all(
|
|
4572
|
+
const results = await Promise.all(promises2);
|
|
4573
4573
|
for (const { expertId, result } of results) {
|
|
4574
4574
|
if (result.ok) {
|
|
4575
4575
|
this.session.submitResult(expertId, result.value);
|
|
@@ -6137,7 +6137,7 @@ var ParallelProtocol = class extends BaseProtocol {
|
|
|
6137
6137
|
sessionId: config.sessionId,
|
|
6138
6138
|
expertCount: config.experts.length
|
|
6139
6139
|
});
|
|
6140
|
-
const
|
|
6140
|
+
const promises2 = config.experts.map(async (expertId) => {
|
|
6141
6141
|
const agent = agents.get(expertId);
|
|
6142
6142
|
if (agent === void 0) {
|
|
6143
6143
|
return { expertId, result: err(new AgentError(`Agent not found: ${expertId}`)) };
|
|
@@ -6145,7 +6145,7 @@ var ParallelProtocol = class extends BaseProtocol {
|
|
|
6145
6145
|
const result = await this.executeAgentTask(agent, config.task);
|
|
6146
6146
|
return { expertId, result };
|
|
6147
6147
|
});
|
|
6148
|
-
const results = await Promise.all(
|
|
6148
|
+
const results = await Promise.all(promises2);
|
|
6149
6149
|
for (const { expertId, result } of results) {
|
|
6150
6150
|
if (result.ok) {
|
|
6151
6151
|
session.submitResult(expertId, result.value);
|
|
@@ -7856,13 +7856,13 @@ var WaveScheduler = class {
|
|
|
7856
7856
|
}
|
|
7857
7857
|
async withTimeout(promise, timeoutMs, taskId) {
|
|
7858
7858
|
if (timeoutMs <= 0) return promise;
|
|
7859
|
-
return new Promise((
|
|
7859
|
+
return new Promise((resolve19, reject) => {
|
|
7860
7860
|
const timer = setTimeout(() => {
|
|
7861
7861
|
reject(new Error(`Task ${taskId} timed out after ${String(timeoutMs)}ms`));
|
|
7862
7862
|
}, timeoutMs);
|
|
7863
7863
|
promise.then((result) => {
|
|
7864
7864
|
clearTimeout(timer);
|
|
7865
|
-
|
|
7865
|
+
resolve19(result);
|
|
7866
7866
|
}).catch((error) => {
|
|
7867
7867
|
clearTimeout(timer);
|
|
7868
7868
|
reject(error instanceof Error ? error : new Error(String(error)));
|
|
@@ -13903,7 +13903,7 @@ function wouldCreateCycle(from, to, getNode) {
|
|
|
13903
13903
|
return canReach(to, from, /* @__PURE__ */ new Set(), getNode);
|
|
13904
13904
|
}
|
|
13905
13905
|
function findCyclePath(from, to, getNode) {
|
|
13906
|
-
const
|
|
13906
|
+
const path20 = [from, to];
|
|
13907
13907
|
const visited = /* @__PURE__ */ new Set([from]);
|
|
13908
13908
|
const findPath = (current) => {
|
|
13909
13909
|
if (current === from) return true;
|
|
@@ -13912,9 +13912,9 @@ function findCyclePath(from, to, getNode) {
|
|
|
13912
13912
|
for (const depId of node.dependencies.keys()) {
|
|
13913
13913
|
if (!visited.has(depId)) {
|
|
13914
13914
|
visited.add(depId);
|
|
13915
|
-
|
|
13915
|
+
path20.push(depId);
|
|
13916
13916
|
if (findPath(depId)) return true;
|
|
13917
|
-
|
|
13917
|
+
path20.pop();
|
|
13918
13918
|
} else if (depId === from) {
|
|
13919
13919
|
return true;
|
|
13920
13920
|
}
|
|
@@ -13922,7 +13922,7 @@ function findCyclePath(from, to, getNode) {
|
|
|
13922
13922
|
return false;
|
|
13923
13923
|
};
|
|
13924
13924
|
findPath(to);
|
|
13925
|
-
return
|
|
13925
|
+
return path20;
|
|
13926
13926
|
}
|
|
13927
13927
|
function detectCycleDFS(nodeId, visited, stack, getNode) {
|
|
13928
13928
|
visited.add(nodeId);
|
|
@@ -13941,29 +13941,29 @@ function detectCycleDFS(nodeId, visited, stack, getNode) {
|
|
|
13941
13941
|
return false;
|
|
13942
13942
|
}
|
|
13943
13943
|
function findCycleFromNode(startId, getNode) {
|
|
13944
|
-
const
|
|
13944
|
+
const path20 = [];
|
|
13945
13945
|
const visited = /* @__PURE__ */ new Set();
|
|
13946
13946
|
const dfs = (nodeId) => {
|
|
13947
|
-
if (
|
|
13948
|
-
const cycleStart =
|
|
13949
|
-
|
|
13950
|
-
|
|
13947
|
+
if (path20.includes(nodeId)) {
|
|
13948
|
+
const cycleStart = path20.indexOf(nodeId);
|
|
13949
|
+
path20.splice(0, cycleStart);
|
|
13950
|
+
path20.push(nodeId);
|
|
13951
13951
|
return true;
|
|
13952
13952
|
}
|
|
13953
13953
|
if (visited.has(nodeId)) return false;
|
|
13954
13954
|
visited.add(nodeId);
|
|
13955
|
-
|
|
13955
|
+
path20.push(nodeId);
|
|
13956
13956
|
const node = getNode(nodeId);
|
|
13957
13957
|
if (node) {
|
|
13958
13958
|
for (const depId of node.dependencies.keys()) {
|
|
13959
13959
|
if (dfs(depId)) return true;
|
|
13960
13960
|
}
|
|
13961
13961
|
}
|
|
13962
|
-
|
|
13962
|
+
path20.pop();
|
|
13963
13963
|
return false;
|
|
13964
13964
|
};
|
|
13965
13965
|
dfs(startId);
|
|
13966
|
-
return
|
|
13966
|
+
return path20;
|
|
13967
13967
|
}
|
|
13968
13968
|
|
|
13969
13969
|
// src/agents/skills/skill-dependency-graph.ts
|
|
@@ -18202,9 +18202,9 @@ var ExpertPool = class {
|
|
|
18202
18202
|
if (this.active < this.capacity) {
|
|
18203
18203
|
return this.issuePermit();
|
|
18204
18204
|
}
|
|
18205
|
-
return new Promise((
|
|
18205
|
+
return new Promise((resolve19, reject) => {
|
|
18206
18206
|
const timer = setTimeout(() => {
|
|
18207
|
-
const idx = this.queue.findIndex((e) => e.resolve ===
|
|
18207
|
+
const idx = this.queue.findIndex((e) => e.resolve === resolve19);
|
|
18208
18208
|
if (idx !== -1) {
|
|
18209
18209
|
this.queue.splice(idx, 1);
|
|
18210
18210
|
}
|
|
@@ -18214,7 +18214,7 @@ var ExpertPool = class {
|
|
|
18214
18214
|
)
|
|
18215
18215
|
);
|
|
18216
18216
|
}, this.acquireTimeoutMs);
|
|
18217
|
-
this.queue.push({ resolve:
|
|
18217
|
+
this.queue.push({ resolve: resolve19, reject, timer });
|
|
18218
18218
|
});
|
|
18219
18219
|
}
|
|
18220
18220
|
/** Release a permit back to the pool. */
|
|
@@ -18508,18 +18508,18 @@ var DependencyGraph = class {
|
|
|
18508
18508
|
}
|
|
18509
18509
|
const startNode = firstNode;
|
|
18510
18510
|
const visited = /* @__PURE__ */ new Set();
|
|
18511
|
-
const
|
|
18511
|
+
const path20 = [];
|
|
18512
18512
|
const dfs = (nodeId) => {
|
|
18513
|
-
if (
|
|
18514
|
-
const cycleStart =
|
|
18515
|
-
|
|
18513
|
+
if (path20.includes(nodeId)) {
|
|
18514
|
+
const cycleStart = path20.indexOf(nodeId);
|
|
18515
|
+
path20.splice(0, cycleStart);
|
|
18516
18516
|
return true;
|
|
18517
18517
|
}
|
|
18518
18518
|
if (visited.has(nodeId)) {
|
|
18519
18519
|
return false;
|
|
18520
18520
|
}
|
|
18521
18521
|
visited.add(nodeId);
|
|
18522
|
-
|
|
18522
|
+
path20.push(nodeId);
|
|
18523
18523
|
const node = this.nodes.get(nodeId);
|
|
18524
18524
|
if (node) {
|
|
18525
18525
|
for (const depId of node.dependencies) {
|
|
@@ -18530,11 +18530,11 @@ var DependencyGraph = class {
|
|
|
18530
18530
|
}
|
|
18531
18531
|
}
|
|
18532
18532
|
}
|
|
18533
|
-
|
|
18533
|
+
path20.pop();
|
|
18534
18534
|
return false;
|
|
18535
18535
|
};
|
|
18536
18536
|
dfs(startNode);
|
|
18537
|
-
return
|
|
18537
|
+
return path20.length > 0 ? path20 : cycleNodes.slice(0, 3);
|
|
18538
18538
|
}
|
|
18539
18539
|
/**
|
|
18540
18540
|
* Gets the execution order (topologically sorted step IDs).
|
|
@@ -18800,8 +18800,8 @@ var TaskQueue = class {
|
|
|
18800
18800
|
if (this.cancelled) {
|
|
18801
18801
|
return Promise.reject(new Error("Queue has been cancelled"));
|
|
18802
18802
|
}
|
|
18803
|
-
return new Promise((
|
|
18804
|
-
this.queue.push({ task, resolve:
|
|
18803
|
+
return new Promise((resolve19, reject) => {
|
|
18804
|
+
this.queue.push({ task, resolve: resolve19, reject });
|
|
18805
18805
|
this.processNext();
|
|
18806
18806
|
});
|
|
18807
18807
|
}
|
|
@@ -19077,16 +19077,16 @@ async function executeStepWithTimeout(step, context, stepExecutor, signal) {
|
|
|
19077
19077
|
return executeWithTimeout2(step, stepContext, stepExecutor, stepTimeout, startTime);
|
|
19078
19078
|
}
|
|
19079
19079
|
function executeWithTimeout2(step, context, executor, timeout, startTime) {
|
|
19080
|
-
return new Promise((
|
|
19080
|
+
return new Promise((resolve19) => {
|
|
19081
19081
|
const timeoutId = setTimeout(() => {
|
|
19082
|
-
|
|
19082
|
+
resolve19(createTimeoutResult(step.id, getTimeProvider().now() - startTime, timeout));
|
|
19083
19083
|
}, timeout);
|
|
19084
19084
|
executor(step, context).then((result) => {
|
|
19085
19085
|
clearTimeout(timeoutId);
|
|
19086
|
-
|
|
19086
|
+
resolve19(result);
|
|
19087
19087
|
}).catch((error) => {
|
|
19088
19088
|
clearTimeout(timeoutId);
|
|
19089
|
-
|
|
19089
|
+
resolve19(createErrorResult(step.id, getTimeProvider().now() - startTime, error));
|
|
19090
19090
|
});
|
|
19091
19091
|
});
|
|
19092
19092
|
}
|
|
@@ -19169,10 +19169,10 @@ async function executeParallel(steps, context, stepExecutor, options) {
|
|
|
19169
19169
|
}
|
|
19170
19170
|
}
|
|
19171
19171
|
async function runAllSteps(steps, context, stepExecutor, opts, state) {
|
|
19172
|
-
const
|
|
19172
|
+
const promises2 = steps.map(
|
|
19173
19173
|
(step) => executeStepInQueue(step, context, stepExecutor, opts, state)
|
|
19174
19174
|
);
|
|
19175
|
-
await Promise.allSettled(
|
|
19175
|
+
await Promise.allSettled(promises2);
|
|
19176
19176
|
}
|
|
19177
19177
|
async function executeStepInQueue(step, context, stepExecutor, opts, state) {
|
|
19178
19178
|
try {
|
|
@@ -19386,9 +19386,9 @@ function getBuiltInTemplatesPath() {
|
|
|
19386
19386
|
join3(dirname2(currentDir), "workflows", "templates"),
|
|
19387
19387
|
join3(dirname2(currentDir), "dist", "workflows", "templates")
|
|
19388
19388
|
];
|
|
19389
|
-
for (const
|
|
19390
|
-
if (existsSync3(
|
|
19391
|
-
return
|
|
19389
|
+
for (const path20 of possiblePaths) {
|
|
19390
|
+
if (existsSync3(path20)) {
|
|
19391
|
+
return path20;
|
|
19392
19392
|
}
|
|
19393
19393
|
}
|
|
19394
19394
|
return join3(currentDir, "templates");
|
|
@@ -19929,9 +19929,9 @@ function validateRequiredInputs(inputs, required) {
|
|
|
19929
19929
|
}
|
|
19930
19930
|
|
|
19931
19931
|
// src/workflows/expression-resolver-helpers.ts
|
|
19932
|
-
function getNestedValue(obj,
|
|
19932
|
+
function getNestedValue(obj, path20) {
|
|
19933
19933
|
let current = obj;
|
|
19934
|
-
for (const key of
|
|
19934
|
+
for (const key of path20) {
|
|
19935
19935
|
if (current === null || current === void 0) {
|
|
19936
19936
|
return void 0;
|
|
19937
19937
|
}
|
|
@@ -19942,24 +19942,24 @@ function getNestedValue(obj, path19) {
|
|
|
19942
19942
|
}
|
|
19943
19943
|
return current;
|
|
19944
19944
|
}
|
|
19945
|
-
function resolveInputs(
|
|
19946
|
-
const value = getNestedValue(context.inputs,
|
|
19945
|
+
function resolveInputs(path20, context) {
|
|
19946
|
+
const value = getNestedValue(context.inputs, path20);
|
|
19947
19947
|
if (value === void 0) {
|
|
19948
19948
|
return {
|
|
19949
19949
|
success: false,
|
|
19950
|
-
error: `Input '${
|
|
19950
|
+
error: `Input '${path20.join(".")}' not found`
|
|
19951
19951
|
};
|
|
19952
19952
|
}
|
|
19953
19953
|
return { success: true, value };
|
|
19954
19954
|
}
|
|
19955
|
-
function validateStepPath(
|
|
19956
|
-
if (
|
|
19955
|
+
function validateStepPath(path20) {
|
|
19956
|
+
if (path20.length < 2) {
|
|
19957
19957
|
return {
|
|
19958
19958
|
success: false,
|
|
19959
19959
|
error: "Steps expression requires at least stepId and output"
|
|
19960
19960
|
};
|
|
19961
19961
|
}
|
|
19962
|
-
if (
|
|
19962
|
+
if (path20[0] === void 0 || path20[1] === void 0) {
|
|
19963
19963
|
return {
|
|
19964
19964
|
success: false,
|
|
19965
19965
|
error: "Steps expression requires stepId and output"
|
|
@@ -19985,12 +19985,12 @@ function validateStepResult(stepId, outputKey, stepResult) {
|
|
|
19985
19985
|
}
|
|
19986
19986
|
return null;
|
|
19987
19987
|
}
|
|
19988
|
-
function resolveSteps(
|
|
19989
|
-
const pathError = validateStepPath(
|
|
19988
|
+
function resolveSteps(path20, context) {
|
|
19989
|
+
const pathError = validateStepPath(path20);
|
|
19990
19990
|
if (pathError !== null) return pathError;
|
|
19991
|
-
const stepId =
|
|
19992
|
-
const outputKey =
|
|
19993
|
-
const rest =
|
|
19991
|
+
const stepId = path20[0] ?? "";
|
|
19992
|
+
const outputKey = path20[1] ?? "";
|
|
19993
|
+
const rest = path20.slice(2);
|
|
19994
19994
|
const stepResult = context.stepResults.get(stepId);
|
|
19995
19995
|
const earlyReturn = validateStepResult(stepId, outputKey, stepResult);
|
|
19996
19996
|
if (earlyReturn !== null) return earlyReturn;
|
|
@@ -20006,15 +20006,15 @@ function resolveSteps(path19, context) {
|
|
|
20006
20006
|
}
|
|
20007
20007
|
return { success: true, value };
|
|
20008
20008
|
}
|
|
20009
|
-
function resolveVariables(
|
|
20010
|
-
if (
|
|
20009
|
+
function resolveVariables(path20, context) {
|
|
20010
|
+
if (path20.length === 0) {
|
|
20011
20011
|
return {
|
|
20012
20012
|
success: false,
|
|
20013
20013
|
error: "Variables expression requires a variable name"
|
|
20014
20014
|
};
|
|
20015
20015
|
}
|
|
20016
|
-
const varName =
|
|
20017
|
-
const rest =
|
|
20016
|
+
const varName = path20[0];
|
|
20017
|
+
const rest = path20.slice(1);
|
|
20018
20018
|
if (varName === void 0) {
|
|
20019
20019
|
return {
|
|
20020
20020
|
success: false,
|
|
@@ -21037,8 +21037,8 @@ var WorkflowEngine = class {
|
|
|
21037
21037
|
this.config = resolveConfig2(config);
|
|
21038
21038
|
}
|
|
21039
21039
|
/** Load workflow template from file. */
|
|
21040
|
-
async loadTemplate(
|
|
21041
|
-
return this.deps.loadWorkflowFile(
|
|
21040
|
+
async loadTemplate(path20) {
|
|
21041
|
+
return this.deps.loadWorkflowFile(path20);
|
|
21042
21042
|
}
|
|
21043
21043
|
/** Execute a workflow with inputs. */
|
|
21044
21044
|
async execute(workflow, inputs) {
|
|
@@ -21142,8 +21142,8 @@ var WorkflowEngine = class {
|
|
|
21142
21142
|
}
|
|
21143
21143
|
return Promise.resolve(templates);
|
|
21144
21144
|
}
|
|
21145
|
-
createTemplate(workflow,
|
|
21146
|
-
const t = { name: workflow.name, version: workflow.version, path:
|
|
21145
|
+
createTemplate(workflow, path20, category) {
|
|
21146
|
+
const t = { name: workflow.name, version: workflow.version, path: path20, category };
|
|
21147
21147
|
if (workflow.description !== void 0) t.description = workflow.description;
|
|
21148
21148
|
return t;
|
|
21149
21149
|
}
|
|
@@ -21429,8 +21429,8 @@ function createParseWorkflow() {
|
|
|
21429
21429
|
};
|
|
21430
21430
|
}
|
|
21431
21431
|
function createLoadWorkflowFile() {
|
|
21432
|
-
return async (
|
|
21433
|
-
const result = await loadWorkflowFile(
|
|
21432
|
+
return async (path20) => {
|
|
21433
|
+
const result = await loadWorkflowFile(path20);
|
|
21434
21434
|
if (!result.ok) {
|
|
21435
21435
|
if (result.error instanceof ParseError) {
|
|
21436
21436
|
return result;
|
|
@@ -23478,10 +23478,10 @@ function calculateZStatistic(params) {
|
|
|
23478
23478
|
function calculateDifferenceCI(p1, p2, total1, total2, confidence) {
|
|
23479
23479
|
const difference = p1 - p2;
|
|
23480
23480
|
const seDiff = Math.sqrt(p1 * (1 - p1) / (total1 || 1) + p2 * (1 - p2) / (total2 || 1));
|
|
23481
|
-
const
|
|
23481
|
+
const z107 = getZScore(confidence);
|
|
23482
23482
|
return {
|
|
23483
|
-
lower: difference -
|
|
23484
|
-
upper: difference +
|
|
23483
|
+
lower: difference - z107 * seDiff,
|
|
23484
|
+
upper: difference + z107 * seDiff,
|
|
23485
23485
|
estimate: difference,
|
|
23486
23486
|
confidence,
|
|
23487
23487
|
n: total1 + total2,
|
|
@@ -23504,11 +23504,11 @@ function proportionConfidenceInterval(successes, total, options = {}) {
|
|
|
23504
23504
|
standardError: 0
|
|
23505
23505
|
};
|
|
23506
23506
|
}
|
|
23507
|
-
const
|
|
23508
|
-
const z210 =
|
|
23507
|
+
const z107 = getZScore(opts.confidence);
|
|
23508
|
+
const z210 = z107 * z107;
|
|
23509
23509
|
const denominator = 1 + z210 / n;
|
|
23510
23510
|
const center = (p + z210 / (2 * n)) / denominator;
|
|
23511
|
-
const margin =
|
|
23511
|
+
const margin = z107 / denominator * Math.sqrt(p * (1 - p) / n + z210 / (4 * n * n));
|
|
23512
23512
|
const lower = Math.max(0, center - margin);
|
|
23513
23513
|
const upper = Math.min(1, center + margin);
|
|
23514
23514
|
const standardError = Math.sqrt(p * (1 - p) / n);
|
|
@@ -23538,8 +23538,8 @@ function meanConfidenceInterval(values, options = {}) {
|
|
|
23538
23538
|
const variance = values.reduce((sum, v) => sum + (v - mean) ** 2, 0) / (n - 1 || 1);
|
|
23539
23539
|
const stdDev = Math.sqrt(variance);
|
|
23540
23540
|
const standardError = stdDev / Math.sqrt(n);
|
|
23541
|
-
const
|
|
23542
|
-
const margin =
|
|
23541
|
+
const z107 = getZScore(opts.confidence);
|
|
23542
|
+
const margin = z107 * standardError;
|
|
23543
23543
|
return {
|
|
23544
23544
|
lower: mean - margin,
|
|
23545
23545
|
upper: mean + margin,
|
|
@@ -26804,8 +26804,8 @@ function applyStateUpdates(graph, state, updates) {
|
|
|
26804
26804
|
return newState;
|
|
26805
26805
|
}
|
|
26806
26806
|
async function executeNodes(graph, nodeIds, state, options) {
|
|
26807
|
-
const
|
|
26808
|
-
return Promise.all(
|
|
26807
|
+
const promises2 = nodeIds.map((id) => executeSingleNode(graph, id, state, options));
|
|
26808
|
+
return Promise.all(promises2);
|
|
26809
26809
|
}
|
|
26810
26810
|
function preconditionFailedResult(nodeId, results, startTime) {
|
|
26811
26811
|
const failed = results.find((r) => !r.passed);
|
|
@@ -26932,13 +26932,13 @@ function dedupe(ids) {
|
|
|
26932
26932
|
return [...new Set(ids)];
|
|
26933
26933
|
}
|
|
26934
26934
|
async function withTimeout2(promise, ms) {
|
|
26935
|
-
return new Promise((
|
|
26935
|
+
return new Promise((resolve19, reject) => {
|
|
26936
26936
|
const timer = setTimeout(() => {
|
|
26937
26937
|
reject(new Error(`Node timed out after ${String(ms)}ms`));
|
|
26938
26938
|
}, ms);
|
|
26939
26939
|
promise.then((result) => {
|
|
26940
26940
|
clearTimeout(timer);
|
|
26941
|
-
|
|
26941
|
+
resolve19(result);
|
|
26942
26942
|
}).catch((error) => {
|
|
26943
26943
|
clearTimeout(timer);
|
|
26944
26944
|
reject(error instanceof Error ? error : new Error(String(error)));
|
|
@@ -27071,31 +27071,31 @@ var GraphBuilder = class {
|
|
|
27071
27071
|
}
|
|
27072
27072
|
const visited = /* @__PURE__ */ new Set();
|
|
27073
27073
|
const stack = /* @__PURE__ */ new Set();
|
|
27074
|
-
const
|
|
27074
|
+
const path20 = [];
|
|
27075
27075
|
for (const nodeId of this.nodes.keys()) {
|
|
27076
|
-
const cycle = this.dfs(nodeId, adj, visited, stack,
|
|
27076
|
+
const cycle = this.dfs(nodeId, adj, visited, stack, path20);
|
|
27077
27077
|
if (cycle !== void 0) return cycle;
|
|
27078
27078
|
}
|
|
27079
27079
|
return void 0;
|
|
27080
27080
|
}
|
|
27081
|
-
dfs(nodeId, adj, visited, stack,
|
|
27081
|
+
dfs(nodeId, adj, visited, stack, path20) {
|
|
27082
27082
|
if (stack.has(nodeId)) {
|
|
27083
|
-
const cycleStart =
|
|
27084
|
-
const cyclePath =
|
|
27083
|
+
const cycleStart = path20.indexOf(nodeId);
|
|
27084
|
+
const cyclePath = path20.slice(cycleStart);
|
|
27085
27085
|
cyclePath.push(nodeId);
|
|
27086
27086
|
return { type: "cycle_detected", path: cyclePath };
|
|
27087
27087
|
}
|
|
27088
27088
|
if (visited.has(nodeId)) return void 0;
|
|
27089
27089
|
visited.add(nodeId);
|
|
27090
27090
|
stack.add(nodeId);
|
|
27091
|
-
|
|
27091
|
+
path20.push(nodeId);
|
|
27092
27092
|
const neighbors = adj.get(nodeId) ?? [];
|
|
27093
27093
|
for (const neighbor of neighbors) {
|
|
27094
|
-
const cycle = this.dfs(neighbor, adj, visited, stack,
|
|
27094
|
+
const cycle = this.dfs(neighbor, adj, visited, stack, path20);
|
|
27095
27095
|
if (cycle !== void 0) return cycle;
|
|
27096
27096
|
}
|
|
27097
27097
|
stack.delete(nodeId);
|
|
27098
|
-
|
|
27098
|
+
path20.pop();
|
|
27099
27099
|
return void 0;
|
|
27100
27100
|
}
|
|
27101
27101
|
checkReachability() {
|
|
@@ -27763,8 +27763,8 @@ function extractModelAttribution(event) {
|
|
|
27763
27763
|
};
|
|
27764
27764
|
}
|
|
27765
27765
|
function extractRoutingAttribution(event) {
|
|
27766
|
-
const
|
|
27767
|
-
return { modelId: event.selectedModel, reasoning: event.reasoning, decisionPath:
|
|
27766
|
+
const path20 = event.decisionPath !== void 0 ? [...event.decisionPath] : void 0;
|
|
27767
|
+
return { modelId: event.selectedModel, reasoning: event.reasoning, decisionPath: path20 };
|
|
27768
27768
|
}
|
|
27769
27769
|
function extractPipelineAttribution(event) {
|
|
27770
27770
|
if (event.type === "pipeline.completed") {
|
|
@@ -29190,10 +29190,10 @@ function createMockTechLead() {
|
|
|
29190
29190
|
async function raceAgainstDeadline(promise, deadlineMs, onTimeout) {
|
|
29191
29191
|
const startedAt = Date.now();
|
|
29192
29192
|
let timer;
|
|
29193
|
-
const timeoutP = new Promise((
|
|
29193
|
+
const timeoutP = new Promise((resolve19) => {
|
|
29194
29194
|
timer = setTimeout(
|
|
29195
29195
|
() => {
|
|
29196
|
-
|
|
29196
|
+
resolve19(onTimeout(Date.now() - startedAt));
|
|
29197
29197
|
},
|
|
29198
29198
|
Math.max(0, deadlineMs)
|
|
29199
29199
|
);
|
|
@@ -30373,11 +30373,11 @@ function createWorkerTask(entry, taskIndex, waveNumber, opts) {
|
|
|
30373
30373
|
}
|
|
30374
30374
|
const staggerMs = taskIndex * opts.staggerDelayMs;
|
|
30375
30375
|
if (staggerMs > 0) {
|
|
30376
|
-
await new Promise((
|
|
30376
|
+
await new Promise((resolve19) => setTimeout(resolve19, staggerMs));
|
|
30377
30377
|
}
|
|
30378
30378
|
const spacingDelay = opts.failureTracker.getSpacingDelay(entry.role);
|
|
30379
30379
|
if (spacingDelay > 0) {
|
|
30380
|
-
await new Promise((
|
|
30380
|
+
await new Promise((resolve19) => setTimeout(resolve19, spacingDelay));
|
|
30381
30381
|
}
|
|
30382
30382
|
const timeoutMs = opts.options.workerTimeoutMs ?? getExpertTaskTimeout(entry.subTask);
|
|
30383
30383
|
const result = await executeSafe({
|
|
@@ -30429,7 +30429,7 @@ async function maybeDelayForRateLimit(results, waveIdx, totalWaves) {
|
|
|
30429
30429
|
);
|
|
30430
30430
|
if (hasRateLimit) {
|
|
30431
30431
|
logger24.warn("Rate-limit detected \u2014 delaying next wave", { delayMs: RATE_LIMIT_WAVE_DELAY_MS });
|
|
30432
|
-
await new Promise((
|
|
30432
|
+
await new Promise((resolve19) => setTimeout(resolve19, RATE_LIMIT_WAVE_DELAY_MS));
|
|
30433
30433
|
}
|
|
30434
30434
|
}
|
|
30435
30435
|
function emitWaveStarted(ctx, workerCount, roles) {
|
|
@@ -30523,7 +30523,7 @@ async function maybeRetryAfterTriage(opts) {
|
|
|
30523
30523
|
}
|
|
30524
30524
|
const useAltCli = triage.action === "retry_different_cli" && altExecuteWorker !== void 0;
|
|
30525
30525
|
if (triage.action === "retry_different_cli") {
|
|
30526
|
-
await new Promise((
|
|
30526
|
+
await new Promise((resolve19) => setTimeout(resolve19, RATE_LIMIT_SPACING_MS));
|
|
30527
30527
|
}
|
|
30528
30528
|
const retryTimeout = triage.action === "extend_timeout" ? Math.min(timeoutMs * TIMEOUT_EXTENSION_FACTOR, MAX_WORKER_TIMEOUT_MS) : timeoutMs;
|
|
30529
30529
|
const retryExecutor = useAltCli ? altExecuteWorker : executeWorker;
|
|
@@ -36466,8 +36466,8 @@ async function saveSourcesRegistry(registry, rootDir) {
|
|
|
36466
36466
|
const pathResult = validatePath3(filePath, root);
|
|
36467
36467
|
if (!pathResult.ok) return pathResult;
|
|
36468
36468
|
try {
|
|
36469
|
-
const
|
|
36470
|
-
await fs6.writeFile(pathResult.value,
|
|
36469
|
+
const yaml4 = stringifyYaml(registry, { indent: 2 });
|
|
36470
|
+
await fs6.writeFile(pathResult.value, yaml4, "utf-8");
|
|
36471
36471
|
return { ok: true, value: void 0 };
|
|
36472
36472
|
} catch (error) {
|
|
36473
36473
|
return {
|
|
@@ -37009,7 +37009,7 @@ function createResearchQueryHandler(deps) {
|
|
|
37009
37009
|
const logger56 = deps.logger ?? createLogger({ tool: "research_query" });
|
|
37010
37010
|
return withToolError("Research query failed", logger56, async () => {
|
|
37011
37011
|
const result = await executeQuery(validationResult.data);
|
|
37012
|
-
return
|
|
37012
|
+
return toolSuccessStructured(result);
|
|
37013
37013
|
});
|
|
37014
37014
|
};
|
|
37015
37015
|
}
|
|
@@ -37033,9 +37033,14 @@ function registerResearchQueryTool(server, deps) {
|
|
|
37033
37033
|
timeoutMs,
|
|
37034
37034
|
logger: logger56
|
|
37035
37035
|
});
|
|
37036
|
+
const outputSchema = {
|
|
37037
|
+
action: z62.string(),
|
|
37038
|
+
success: z62.boolean(),
|
|
37039
|
+
data: z62.unknown()
|
|
37040
|
+
};
|
|
37036
37041
|
server.registerTool(
|
|
37037
37042
|
"research_query",
|
|
37038
|
-
{ description, inputSchema: toolSchema },
|
|
37043
|
+
{ description, inputSchema: toolSchema, outputSchema },
|
|
37039
37044
|
toSdkCallback(wrappedHandler)
|
|
37040
37045
|
);
|
|
37041
37046
|
logger56.info("Registered research_query tool with secure handler and timeout protection");
|
|
@@ -37101,7 +37106,7 @@ function createResearchAddHandler(deps) {
|
|
|
37101
37106
|
if (!result.success) {
|
|
37102
37107
|
return toolError(result.message);
|
|
37103
37108
|
}
|
|
37104
|
-
return
|
|
37109
|
+
return toolSuccessStructured(result);
|
|
37105
37110
|
});
|
|
37106
37111
|
};
|
|
37107
37112
|
}
|
|
@@ -37124,9 +37129,16 @@ function registerResearchAddTool(server, deps) {
|
|
|
37124
37129
|
timeoutMs,
|
|
37125
37130
|
logger: logger56
|
|
37126
37131
|
});
|
|
37132
|
+
const outputSchema = {
|
|
37133
|
+
success: z63.boolean(),
|
|
37134
|
+
paperId: z63.string().optional(),
|
|
37135
|
+
title: z63.string().optional(),
|
|
37136
|
+
message: z63.string(),
|
|
37137
|
+
dryRun: z63.boolean().optional()
|
|
37138
|
+
};
|
|
37127
37139
|
server.registerTool(
|
|
37128
37140
|
"research_add",
|
|
37129
|
-
{ description, inputSchema: toolSchema },
|
|
37141
|
+
{ description, inputSchema: toolSchema, outputSchema },
|
|
37130
37142
|
toSdkCallback(wrappedHandler)
|
|
37131
37143
|
);
|
|
37132
37144
|
logger56.info("Registered research_add tool with secure handler and timeout protection");
|
|
@@ -37283,7 +37295,7 @@ function createResearchAddSourceHandler(deps) {
|
|
|
37283
37295
|
if (!result.success) {
|
|
37284
37296
|
return toolError(result.message);
|
|
37285
37297
|
}
|
|
37286
|
-
return
|
|
37298
|
+
return toolSuccessStructured(result);
|
|
37287
37299
|
});
|
|
37288
37300
|
};
|
|
37289
37301
|
}
|
|
@@ -37322,10 +37334,19 @@ function registerResearchAddSourceTool(server, deps) {
|
|
|
37322
37334
|
});
|
|
37323
37335
|
server.registerTool(
|
|
37324
37336
|
"research_add_source",
|
|
37325
|
-
{ description, inputSchema: toolSchema },
|
|
37337
|
+
{ description, inputSchema: toolSchema, outputSchema: RESEARCH_ADD_SOURCE_OUTPUT_SCHEMA },
|
|
37326
37338
|
toSdkCallback(wrappedHandler)
|
|
37327
37339
|
);
|
|
37328
37340
|
}
|
|
37341
|
+
var RESEARCH_ADD_SOURCE_OUTPUT_SCHEMA = {
|
|
37342
|
+
success: z64.boolean(),
|
|
37343
|
+
sourceId: z64.string().optional(),
|
|
37344
|
+
name: z64.string().optional(),
|
|
37345
|
+
quality_score: z64.number().optional(),
|
|
37346
|
+
evidence_tier: z64.string().optional(),
|
|
37347
|
+
message: z64.string().optional(),
|
|
37348
|
+
dryRun: z64.boolean().optional()
|
|
37349
|
+
};
|
|
37329
37350
|
|
|
37330
37351
|
// src/mcp/tools/research-discover.ts
|
|
37331
37352
|
import { z as z65 } from "zod";
|
|
@@ -37593,7 +37614,7 @@ function createResearchDiscoverHandler(deps) {
|
|
|
37593
37614
|
const response = await withToolError("Discovery failed", logger56, async () => {
|
|
37594
37615
|
const result = await executeDiscovery(validationResult.data, logger56);
|
|
37595
37616
|
recordDiscoverySuccess(result.topic, result.newItems, result.sourcesQueried);
|
|
37596
|
-
return
|
|
37617
|
+
return toolSuccessStructured(result);
|
|
37597
37618
|
});
|
|
37598
37619
|
const durationMs = Date.now() - startMs;
|
|
37599
37620
|
if (response.isError === true) {
|
|
@@ -37638,11 +37659,21 @@ function registerResearchDiscoverTool(server, deps) {
|
|
|
37638
37659
|
});
|
|
37639
37660
|
server.registerTool(
|
|
37640
37661
|
"research_discover",
|
|
37641
|
-
{ description, inputSchema: toolSchema },
|
|
37662
|
+
{ description, inputSchema: toolSchema, outputSchema: RESEARCH_DISCOVER_OUTPUT_SCHEMA },
|
|
37642
37663
|
toSdkCallback(wrappedHandler)
|
|
37643
37664
|
);
|
|
37644
37665
|
logger56.info("Registered research_discover tool with secure handler and timeout protection");
|
|
37645
37666
|
}
|
|
37667
|
+
var RESEARCH_DISCOVER_OUTPUT_SCHEMA = {
|
|
37668
|
+
topic: z65.string().optional(),
|
|
37669
|
+
sourcesQueried: z65.array(z65.string()).optional(),
|
|
37670
|
+
failedSources: z65.array(z65.string()).optional(),
|
|
37671
|
+
items: z65.array(z65.unknown()).optional(),
|
|
37672
|
+
totalFound: z65.number().optional(),
|
|
37673
|
+
alreadyInRegistry: z65.number().optional(),
|
|
37674
|
+
newItems: z65.number().optional(),
|
|
37675
|
+
filteredByRelevance: z65.number().optional()
|
|
37676
|
+
};
|
|
37646
37677
|
|
|
37647
37678
|
// src/mcp/tools/research-analyze.ts
|
|
37648
37679
|
import { z as z66 } from "zod";
|
|
@@ -37885,7 +37916,7 @@ function createResearchAnalyzeHandler(deps) {
|
|
|
37885
37916
|
const logger56 = deps.logger ?? createLogger({ tool: "research_analyze" });
|
|
37886
37917
|
return withToolError("Analysis failed", logger56, async () => {
|
|
37887
37918
|
const result = await executeAnalysis(validationResult.data);
|
|
37888
|
-
return
|
|
37919
|
+
return toolSuccessStructured(result);
|
|
37889
37920
|
});
|
|
37890
37921
|
};
|
|
37891
37922
|
}
|
|
@@ -37906,9 +37937,15 @@ function registerResearchAnalyzeTool(server, deps) {
|
|
|
37906
37937
|
timeoutMs,
|
|
37907
37938
|
logger: logger56
|
|
37908
37939
|
});
|
|
37940
|
+
const outputSchema = {
|
|
37941
|
+
focus: z66.string().optional(),
|
|
37942
|
+
success: z66.boolean().optional(),
|
|
37943
|
+
analysis: z66.unknown().optional(),
|
|
37944
|
+
recommendations: z66.array(z66.string()).optional()
|
|
37945
|
+
};
|
|
37909
37946
|
server.registerTool(
|
|
37910
37947
|
"research_analyze",
|
|
37911
|
-
{ description, inputSchema: toolSchema },
|
|
37948
|
+
{ description, inputSchema: toolSchema, outputSchema },
|
|
37912
37949
|
toSdkCallback(wrappedHandler)
|
|
37913
37950
|
);
|
|
37914
37951
|
logger56.info("Registered research_analyze tool with secure handler and timeout protection");
|
|
@@ -38044,7 +38081,7 @@ function createCatalogReviewHandler(deps) {
|
|
|
38044
38081
|
if (!result.success) {
|
|
38045
38082
|
return toolError(result.message);
|
|
38046
38083
|
}
|
|
38047
|
-
return
|
|
38084
|
+
return toolSuccessStructured(result);
|
|
38048
38085
|
});
|
|
38049
38086
|
};
|
|
38050
38087
|
}
|
|
@@ -38067,9 +38104,15 @@ function registerResearchCatalogReviewTool(server, deps) {
|
|
|
38067
38104
|
timeoutMs,
|
|
38068
38105
|
logger: logger56
|
|
38069
38106
|
});
|
|
38107
|
+
const outputSchema = {
|
|
38108
|
+
action: z67.string().optional(),
|
|
38109
|
+
success: z67.boolean().optional(),
|
|
38110
|
+
message: z67.string().optional(),
|
|
38111
|
+
data: z67.unknown().optional()
|
|
38112
|
+
};
|
|
38070
38113
|
server.registerTool(
|
|
38071
38114
|
"research_catalog_review",
|
|
38072
|
-
{ description, inputSchema: toolSchema },
|
|
38115
|
+
{ description, inputSchema: toolSchema, outputSchema },
|
|
38073
38116
|
toSdkCallback(wrappedHandler)
|
|
38074
38117
|
);
|
|
38075
38118
|
logger56.info("Registered research_catalog_review tool");
|
|
@@ -38092,7 +38135,7 @@ function createResearchSynthesizeHandler(deps) {
|
|
|
38092
38135
|
if (!result.ok) {
|
|
38093
38136
|
return toolError(`Synthesis failed: ${result.error.message}`);
|
|
38094
38137
|
}
|
|
38095
|
-
return
|
|
38138
|
+
return toolSuccessStructured(result.value);
|
|
38096
38139
|
});
|
|
38097
38140
|
};
|
|
38098
38141
|
}
|
|
@@ -38112,9 +38155,15 @@ function registerResearchSynthesizeTool(server, deps) {
|
|
|
38112
38155
|
timeoutMs,
|
|
38113
38156
|
logger: logger56
|
|
38114
38157
|
});
|
|
38158
|
+
const outputSchema = {
|
|
38159
|
+
clusters: z68.array(z68.unknown()).optional(),
|
|
38160
|
+
alignmentSummary: z68.unknown().optional(),
|
|
38161
|
+
crossCuttingThemes: z68.array(z68.unknown()).optional(),
|
|
38162
|
+
generatedAt: z68.string().optional()
|
|
38163
|
+
};
|
|
38115
38164
|
server.registerTool(
|
|
38116
38165
|
"research_synthesize",
|
|
38117
|
-
{ description, inputSchema: toolSchema },
|
|
38166
|
+
{ description, inputSchema: toolSchema, outputSchema },
|
|
38118
38167
|
toSdkCallback(wrappedHandler)
|
|
38119
38168
|
);
|
|
38120
38169
|
logger56.info("Registered research_synthesize tool");
|
|
@@ -38744,12 +38793,12 @@ function extractFileReferences(markdown) {
|
|
|
38744
38793
|
let match;
|
|
38745
38794
|
FILE_REF_PATTERN.lastIndex = 0;
|
|
38746
38795
|
while ((match = FILE_REF_PATTERN.exec(markdown)) !== null) {
|
|
38747
|
-
const
|
|
38748
|
-
if (
|
|
38749
|
-
seen.add(
|
|
38796
|
+
const path20 = match[1];
|
|
38797
|
+
if (path20 === void 0 || seen.has(path20)) continue;
|
|
38798
|
+
seen.add(path20);
|
|
38750
38799
|
const lineStr = match[2];
|
|
38751
38800
|
const line = lineStr !== void 0 ? parseInt(lineStr, 10) : void 0;
|
|
38752
|
-
refs.push(line !== void 0 ? { path:
|
|
38801
|
+
refs.push(line !== void 0 ? { path: path20, line } : { path: path20 });
|
|
38753
38802
|
}
|
|
38754
38803
|
return refs;
|
|
38755
38804
|
}
|
|
@@ -39272,7 +39321,7 @@ async function memoryQueryHandler(args, ctx) {
|
|
|
39272
39321
|
}
|
|
39273
39322
|
return withToolError("Memory query failed", ctx.logger, async () => {
|
|
39274
39323
|
const result = await executeMemoryQuery(validationResult.data, ctx.logger);
|
|
39275
|
-
return
|
|
39324
|
+
return toolSuccessStructured(result);
|
|
39276
39325
|
});
|
|
39277
39326
|
}
|
|
39278
39327
|
function registerMemoryQueryTool(server, deps) {
|
|
@@ -39290,9 +39339,16 @@ function registerMemoryQueryTool(server, deps) {
|
|
|
39290
39339
|
});
|
|
39291
39340
|
const timeoutMs = getToolTimeout("memory_query", deps.security);
|
|
39292
39341
|
const wrappedHandler = wrapToolWithTimeout("memory_query", secureHandler, { timeoutMs, logger: logger56 });
|
|
39342
|
+
const outputSchema = {
|
|
39343
|
+
query: z72.string(),
|
|
39344
|
+
expandedQuery: z72.string().optional(),
|
|
39345
|
+
results: z72.array(z72.unknown()),
|
|
39346
|
+
count: z72.number(),
|
|
39347
|
+
source: z72.string()
|
|
39348
|
+
};
|
|
39293
39349
|
server.registerTool(
|
|
39294
39350
|
"memory_query",
|
|
39295
|
-
{ description, inputSchema: toolSchema },
|
|
39351
|
+
{ description, inputSchema: toolSchema, outputSchema },
|
|
39296
39352
|
toSdkCallback(wrappedHandler)
|
|
39297
39353
|
);
|
|
39298
39354
|
logger56.info("Registered memory_query tool");
|
|
@@ -39358,7 +39414,7 @@ async function memoryStatsHandler(args, ctx) {
|
|
|
39358
39414
|
}
|
|
39359
39415
|
return withToolError("Memory stats failed", ctx.logger, async () => {
|
|
39360
39416
|
const result = await collectMemoryStats(validationResult.data, ctx.logger);
|
|
39361
|
-
return
|
|
39417
|
+
return toolSuccessStructured(result);
|
|
39362
39418
|
});
|
|
39363
39419
|
}
|
|
39364
39420
|
function registerMemoryStatsTool(server, deps) {
|
|
@@ -39374,9 +39430,18 @@ function registerMemoryStatsTool(server, deps) {
|
|
|
39374
39430
|
});
|
|
39375
39431
|
const timeoutMs = getToolTimeout("memory_stats", deps.security);
|
|
39376
39432
|
const wrappedHandler = wrapToolWithTimeout("memory_stats", secureHandler, { timeoutMs, logger: logger56 });
|
|
39433
|
+
const outputSchema = {
|
|
39434
|
+
backends: z73.unknown(),
|
|
39435
|
+
session: z73.unknown().optional(),
|
|
39436
|
+
belief: z73.unknown().optional(),
|
|
39437
|
+
typed: z73.unknown().optional(),
|
|
39438
|
+
mobimem: z73.unknown().optional(),
|
|
39439
|
+
decay: z73.unknown().optional(),
|
|
39440
|
+
collectedAt: z73.string().optional()
|
|
39441
|
+
};
|
|
39377
39442
|
server.registerTool(
|
|
39378
39443
|
"memory_stats",
|
|
39379
|
-
{ description, inputSchema: toolSchema },
|
|
39444
|
+
{ description, inputSchema: toolSchema, outputSchema },
|
|
39380
39445
|
toSdkCallback(wrappedHandler)
|
|
39381
39446
|
);
|
|
39382
39447
|
logger56.info("Registered memory_stats tool");
|
|
@@ -39501,7 +39566,7 @@ async function memoryWriteHandler(args, ctx) {
|
|
|
39501
39566
|
if (!result.success) {
|
|
39502
39567
|
return toolError(JSON.stringify(result, null, 2));
|
|
39503
39568
|
}
|
|
39504
|
-
return
|
|
39569
|
+
return toolSuccessStructured(result);
|
|
39505
39570
|
});
|
|
39506
39571
|
}
|
|
39507
39572
|
function registerMemoryWriteTool(server, deps) {
|
|
@@ -39523,9 +39588,16 @@ function registerMemoryWriteTool(server, deps) {
|
|
|
39523
39588
|
});
|
|
39524
39589
|
const timeoutMs = getToolTimeout("memory_write", deps.security);
|
|
39525
39590
|
const wrappedHandler = wrapToolWithTimeout("memory_write", secureHandler, { timeoutMs, logger: logger56 });
|
|
39591
|
+
const outputSchema = {
|
|
39592
|
+
success: z74.boolean(),
|
|
39593
|
+
backend: z74.string(),
|
|
39594
|
+
key: z74.string(),
|
|
39595
|
+
deduplicated: z74.boolean().optional(),
|
|
39596
|
+
error: z74.string().optional()
|
|
39597
|
+
};
|
|
39526
39598
|
server.registerTool(
|
|
39527
39599
|
"memory_write",
|
|
39528
|
-
{ description, inputSchema: toolSchema },
|
|
39600
|
+
{ description, inputSchema: toolSchema, outputSchema },
|
|
39529
39601
|
toSdkCallback(wrappedHandler)
|
|
39530
39602
|
);
|
|
39531
39603
|
logger56.info("Registered memory_write tool");
|
|
@@ -40559,27 +40631,27 @@ var FileAuditStorage = class _FileAuditStorage {
|
|
|
40559
40631
|
const data = this.writeBuffer.join("");
|
|
40560
40632
|
this.writeBuffer = [];
|
|
40561
40633
|
const stream = this.writeStream;
|
|
40562
|
-
return new Promise((
|
|
40634
|
+
return new Promise((resolve19, reject) => {
|
|
40563
40635
|
stream.write(data, (err2) => {
|
|
40564
40636
|
if (err2 !== void 0 && err2 !== null) {
|
|
40565
40637
|
reject(new AuditError("Failed to flush audit log", { cause: err2 }));
|
|
40566
40638
|
} else {
|
|
40567
|
-
|
|
40639
|
+
resolve19();
|
|
40568
40640
|
}
|
|
40569
40641
|
});
|
|
40570
40642
|
});
|
|
40571
40643
|
}
|
|
40572
40644
|
async close() {
|
|
40573
40645
|
await this.flush();
|
|
40574
|
-
return new Promise((
|
|
40646
|
+
return new Promise((resolve19) => {
|
|
40575
40647
|
if (this.writeStream === null) {
|
|
40576
|
-
|
|
40648
|
+
resolve19();
|
|
40577
40649
|
return;
|
|
40578
40650
|
}
|
|
40579
40651
|
this.writeStream.end(() => {
|
|
40580
40652
|
this.writeStream = null;
|
|
40581
40653
|
this.logger.info("Audit storage closed");
|
|
40582
|
-
|
|
40654
|
+
resolve19();
|
|
40583
40655
|
});
|
|
40584
40656
|
});
|
|
40585
40657
|
}
|
|
@@ -42019,11 +42091,11 @@ function recordTriageLifecycle(findings, verdicts, entries) {
|
|
|
42019
42091
|
async function runOsvCheck(targetDir, enabled) {
|
|
42020
42092
|
if (!enabled) return [];
|
|
42021
42093
|
try {
|
|
42022
|
-
const
|
|
42023
|
-
const
|
|
42024
|
-
const pkgPath =
|
|
42025
|
-
if (!
|
|
42026
|
-
const pkg = JSON.parse(
|
|
42094
|
+
const fs21 = await import("fs");
|
|
42095
|
+
const path20 = await import("path");
|
|
42096
|
+
const pkgPath = path20.join(targetDir, "package.json");
|
|
42097
|
+
if (!fs21.existsSync(pkgPath)) return [];
|
|
42098
|
+
const pkg = JSON.parse(fs21.readFileSync(pkgPath, "utf-8"));
|
|
42027
42099
|
const deps = Object.entries(pkg.dependencies ?? {}).slice(0, 20).map(([name, version]) => ({
|
|
42028
42100
|
name,
|
|
42029
42101
|
version: version.replace(/^[\^~>=<]+/, "")
|
|
@@ -43134,11 +43206,11 @@ async function extractSymbolsForTask(task) {
|
|
|
43134
43206
|
const fileRefs = task.match(/(?:src|lib|packages)\/[^\s,)]+\.ts/g);
|
|
43135
43207
|
if (fileRefs === null || fileRefs.length === 0) return null;
|
|
43136
43208
|
const { extractSymbols: extractSymbols2 } = await import("./symbol-extractor-UEBANFSN.js");
|
|
43137
|
-
const
|
|
43209
|
+
const path20 = await import("path");
|
|
43138
43210
|
const summaries = [];
|
|
43139
43211
|
for (const ref of fileRefs.slice(0, 3)) {
|
|
43140
43212
|
try {
|
|
43141
|
-
const resolved =
|
|
43213
|
+
const resolved = path20.resolve(ref);
|
|
43142
43214
|
const result = await extractSymbols2(resolved);
|
|
43143
43215
|
const exported = result.symbols.filter((s) => s.exported);
|
|
43144
43216
|
if (exported.length > 0) {
|
|
@@ -43155,12 +43227,12 @@ async function extractSymbolsForTask(task) {
|
|
|
43155
43227
|
async function retrieveAdaptiveMemory(task) {
|
|
43156
43228
|
try {
|
|
43157
43229
|
const { AdaptiveMemoryBackend } = await import("./adaptive-memory-XD5O3TC4.js");
|
|
43158
|
-
const
|
|
43230
|
+
const path20 = await import("path");
|
|
43159
43231
|
const { nexusDataPath: nexusDataPath2 } = await import("./nexus-data-dir-M6DYKIHJ.js");
|
|
43160
43232
|
const baseDir = nexusDataPath2("memory");
|
|
43161
43233
|
const memory = new AdaptiveMemoryBackend({
|
|
43162
|
-
dbPath:
|
|
43163
|
-
markdownDir:
|
|
43234
|
+
dbPath: path20.join(baseDir, "adaptive.db"),
|
|
43235
|
+
markdownDir: path20.join(baseDir, "adaptive-md")
|
|
43164
43236
|
});
|
|
43165
43237
|
const key = task.slice(0, 50).replace(/\s+/g, "-").toLowerCase();
|
|
43166
43238
|
const result = await memory.retrieve(key);
|
|
@@ -43553,10 +43625,566 @@ function registerPrReviewTool(server, deps) {
|
|
|
43553
43625
|
logger56.info("Registered pr_review tool");
|
|
43554
43626
|
}
|
|
43555
43627
|
|
|
43556
|
-
// src/mcp/tools/
|
|
43628
|
+
// src/mcp/tools/survey-oss-landscape.ts
|
|
43557
43629
|
import { z as z91 } from "zod";
|
|
43558
|
-
var
|
|
43559
|
-
|
|
43630
|
+
var SurveyOssLandscapeInputSchema = z91.object({
|
|
43631
|
+
query: z91.string().min(1).max(200).describe('Free-text search query, e.g. "cargo nextest replacement" or "OSS SBOM tools"'),
|
|
43632
|
+
maxResults: z91.number().int().min(1).max(50).optional().default(10).describe("Maximum candidates to return (1-50; default 10)"),
|
|
43633
|
+
minStars: z91.number().int().min(0).optional().default(0).describe("Minimum star count to include (default 0; useful for filtering noise)"),
|
|
43634
|
+
language: z91.string().max(50).optional().describe('GitHub language filter, e.g. "rust" or "typescript"')
|
|
43635
|
+
});
|
|
43636
|
+
var GitHubRepoSchema2 = z91.object({
|
|
43637
|
+
full_name: z91.string().optional(),
|
|
43638
|
+
html_url: z91.string().optional(),
|
|
43639
|
+
description: z91.string().nullable().optional(),
|
|
43640
|
+
stargazers_count: z91.number().optional(),
|
|
43641
|
+
pushed_at: z91.string().nullable().optional(),
|
|
43642
|
+
language: z91.string().nullable().optional(),
|
|
43643
|
+
license: z91.object({
|
|
43644
|
+
spdx_id: z91.string().nullable().optional()
|
|
43645
|
+
}).nullable().optional()
|
|
43646
|
+
});
|
|
43647
|
+
var GitHubSearchResponseSchema2 = z91.object({
|
|
43648
|
+
total_count: z91.number().optional(),
|
|
43649
|
+
items: z91.array(GitHubRepoSchema2).optional()
|
|
43650
|
+
});
|
|
43651
|
+
var GITHUB_SEARCH_BASE = "https://api.github.com/search/repositories";
|
|
43652
|
+
function buildGithubQuery(input) {
|
|
43653
|
+
const parts = [input.query];
|
|
43654
|
+
if (input.language !== void 0 && input.language.length > 0) {
|
|
43655
|
+
parts.push(`language:${input.language}`);
|
|
43656
|
+
}
|
|
43657
|
+
if (input.minStars > 0) {
|
|
43658
|
+
parts.push(`stars:>=${String(input.minStars)}`);
|
|
43659
|
+
}
|
|
43660
|
+
return parts.join(" ");
|
|
43661
|
+
}
|
|
43662
|
+
function splitFullName(fullName) {
|
|
43663
|
+
if (fullName === void 0) return { owner: "", name: "" };
|
|
43664
|
+
const idx = fullName.indexOf("/");
|
|
43665
|
+
if (idx === -1) return { owner: "", name: fullName };
|
|
43666
|
+
return { owner: fullName.slice(0, idx), name: fullName.slice(idx + 1) };
|
|
43667
|
+
}
|
|
43668
|
+
function parseCandidates(data) {
|
|
43669
|
+
const items = data.items ?? [];
|
|
43670
|
+
const candidates = items.map((repo) => {
|
|
43671
|
+
const { owner, name } = splitFullName(repo.full_name);
|
|
43672
|
+
return {
|
|
43673
|
+
name,
|
|
43674
|
+
owner,
|
|
43675
|
+
url: repo.html_url ?? "",
|
|
43676
|
+
stars: repo.stargazers_count ?? 0,
|
|
43677
|
+
lastCommitAt: repo.pushed_at ?? null,
|
|
43678
|
+
license: repo.license?.spdx_id ?? null,
|
|
43679
|
+
language: repo.language ?? null,
|
|
43680
|
+
description: repo.description ?? null,
|
|
43681
|
+
source: "github"
|
|
43682
|
+
};
|
|
43683
|
+
});
|
|
43684
|
+
return { totalFound: data.total_count ?? candidates.length, candidates };
|
|
43685
|
+
}
|
|
43686
|
+
async function fetchGithubCandidates(input, logger56) {
|
|
43687
|
+
const query = encodeURIComponent(buildGithubQuery(input));
|
|
43688
|
+
const perPage = String(input.maxResults);
|
|
43689
|
+
const url = `${GITHUB_SEARCH_BASE}?q=${query}&sort=stars&order=desc&per_page=${perPage}`;
|
|
43690
|
+
const headers = {
|
|
43691
|
+
Accept: "application/vnd.github.v3+json",
|
|
43692
|
+
"User-Agent": "nexus-agents"
|
|
43693
|
+
};
|
|
43694
|
+
const tokenResult = await resolveToken({ platform: "github" });
|
|
43695
|
+
if (tokenResult.ok) {
|
|
43696
|
+
headers["Authorization"] = `Bearer ${tokenResult.value.value}`;
|
|
43697
|
+
} else {
|
|
43698
|
+
logger56.debug("No GitHub token; using unauthenticated rate limit (60/hr)");
|
|
43699
|
+
}
|
|
43700
|
+
const fetchResult = await fetchSource({ url, source: "github", headers });
|
|
43701
|
+
if (!fetchResult.ok) return fetchResult;
|
|
43702
|
+
let raw;
|
|
43703
|
+
try {
|
|
43704
|
+
raw = await fetchResult.value.json();
|
|
43705
|
+
} catch (err2) {
|
|
43706
|
+
return {
|
|
43707
|
+
ok: false,
|
|
43708
|
+
error: {
|
|
43709
|
+
code: "PARSE_ERROR",
|
|
43710
|
+
message: "GitHub response is not valid JSON",
|
|
43711
|
+
source: "github",
|
|
43712
|
+
cause: err2
|
|
43713
|
+
}
|
|
43714
|
+
};
|
|
43715
|
+
}
|
|
43716
|
+
const parsed = GitHubSearchResponseSchema2.safeParse(raw);
|
|
43717
|
+
if (!parsed.success) {
|
|
43718
|
+
return {
|
|
43719
|
+
ok: false,
|
|
43720
|
+
error: {
|
|
43721
|
+
code: "PARSE_ERROR",
|
|
43722
|
+
message: "GitHub API response did not match the expected schema",
|
|
43723
|
+
source: "github"
|
|
43724
|
+
}
|
|
43725
|
+
};
|
|
43726
|
+
}
|
|
43727
|
+
return { ok: true, value: parseCandidates(parsed.data) };
|
|
43728
|
+
}
|
|
43729
|
+
async function executeSurvey(input, logger56) {
|
|
43730
|
+
const sourcesQueried = ["github"];
|
|
43731
|
+
const sourcesFailed = [];
|
|
43732
|
+
const githubResult = await fetchGithubCandidates(input, logger56);
|
|
43733
|
+
if (!githubResult.ok) {
|
|
43734
|
+
logger56.warn("GitHub source failed", {
|
|
43735
|
+
code: githubResult.error.code,
|
|
43736
|
+
message: githubResult.error.message
|
|
43737
|
+
});
|
|
43738
|
+
sourcesFailed.push("github");
|
|
43739
|
+
return {
|
|
43740
|
+
query: input.query,
|
|
43741
|
+
totalFound: 0,
|
|
43742
|
+
candidates: [],
|
|
43743
|
+
sourcesQueried,
|
|
43744
|
+
sourcesFailed
|
|
43745
|
+
};
|
|
43746
|
+
}
|
|
43747
|
+
return {
|
|
43748
|
+
query: input.query,
|
|
43749
|
+
totalFound: githubResult.value.totalFound,
|
|
43750
|
+
candidates: githubResult.value.candidates,
|
|
43751
|
+
sourcesQueried,
|
|
43752
|
+
sourcesFailed
|
|
43753
|
+
};
|
|
43754
|
+
}
|
|
43755
|
+
function createSurveyHandler(deps) {
|
|
43756
|
+
return async (args, ctx) => {
|
|
43757
|
+
const validation = SurveyOssLandscapeInputSchema.safeParse(args);
|
|
43758
|
+
if (!validation.success) {
|
|
43759
|
+
return toolError(`Validation error: ${formatZodError(validation.error)}`);
|
|
43760
|
+
}
|
|
43761
|
+
const logger56 = deps.logger ?? createLogger({ tool: "survey_oss_landscape" });
|
|
43762
|
+
ctx.logger.debug("Surveying OSS landscape", {
|
|
43763
|
+
query: validation.data.query,
|
|
43764
|
+
maxResults: validation.data.maxResults
|
|
43765
|
+
});
|
|
43766
|
+
return withToolError("Survey failed", logger56, async () => {
|
|
43767
|
+
const result = await executeSurvey(validation.data, logger56);
|
|
43768
|
+
return toolSuccessStructured(result);
|
|
43769
|
+
});
|
|
43770
|
+
};
|
|
43771
|
+
}
|
|
43772
|
+
var SURVEY_OUTPUT_SCHEMA = {
|
|
43773
|
+
query: z91.string(),
|
|
43774
|
+
totalFound: z91.number(),
|
|
43775
|
+
candidates: z91.array(z91.unknown()),
|
|
43776
|
+
sourcesQueried: z91.array(z91.string()),
|
|
43777
|
+
sourcesFailed: z91.array(z91.string())
|
|
43778
|
+
};
|
|
43779
|
+
var SURVEY_DESCRIPTION = 'Transient OSS project search. Returns a ranked list of GitHub repositories with license, last-commit, star-count, and one-line description. Does NOT persist to the research registry \u2014 use `research_add_source` for that. Best for one-off engineering decisions like "what tools exist in this space?".';
|
|
43780
|
+
function registerSurveyOssLandscapeTool(server, deps) {
|
|
43781
|
+
const logger56 = deps.logger ?? createLogger({ tool: "survey_oss_landscape" });
|
|
43782
|
+
const secureHandler = createSecureHandler(createSurveyHandler(deps), {
|
|
43783
|
+
toolName: "survey_oss_landscape",
|
|
43784
|
+
rateLimiter: deps.rateLimiter,
|
|
43785
|
+
logger: logger56
|
|
43786
|
+
});
|
|
43787
|
+
const timeoutMs = getToolTimeout("survey_oss_landscape", deps.security);
|
|
43788
|
+
const wrappedHandler = wrapToolWithTimeout("survey_oss_landscape", secureHandler, {
|
|
43789
|
+
timeoutMs,
|
|
43790
|
+
logger: logger56
|
|
43791
|
+
});
|
|
43792
|
+
server.registerTool(
|
|
43793
|
+
"survey_oss_landscape",
|
|
43794
|
+
{
|
|
43795
|
+
description: SURVEY_DESCRIPTION,
|
|
43796
|
+
inputSchema: SurveyOssLandscapeInputSchema.shape,
|
|
43797
|
+
outputSchema: SURVEY_OUTPUT_SCHEMA
|
|
43798
|
+
},
|
|
43799
|
+
toSdkCallback(wrappedHandler)
|
|
43800
|
+
);
|
|
43801
|
+
logger56.info("Registered survey_oss_landscape tool");
|
|
43802
|
+
}
|
|
43803
|
+
|
|
43804
|
+
// src/mcp/tools/vendor-publishing-audit.ts
|
|
43805
|
+
import { z as z92 } from "zod";
|
|
43806
|
+
|
|
43807
|
+
// src/mcp/tools/vendor-publishing-seed.ts
|
|
43808
|
+
var VENDOR_PUBLISHING_SEED = {
|
|
43809
|
+
ubuntu: {
|
|
43810
|
+
vendor: "ubuntu",
|
|
43811
|
+
sha256SumsUrlPattern: "https://releases.ubuntu.com/{release}/SHA256SUMS",
|
|
43812
|
+
sha256SumsSignatureUrlPattern: "https://releases.ubuntu.com/{release}/SHA256SUMS.gpg",
|
|
43813
|
+
signaturePattern: "detached",
|
|
43814
|
+
gpgKeys: [
|
|
43815
|
+
{
|
|
43816
|
+
name: "Ubuntu CD Image Automatic Signing Key (2012)",
|
|
43817
|
+
fingerprint: "843938DF228D22F7B3742BC0D94AA3F0EFE21092",
|
|
43818
|
+
role: "release-signing",
|
|
43819
|
+
source: "https://help.ubuntu.com/community/VerifyIsoHowto"
|
|
43820
|
+
},
|
|
43821
|
+
{
|
|
43822
|
+
name: "Ubuntu CD Image Automatic Signing Key (2018)",
|
|
43823
|
+
fingerprint: "F6ECB3762474EDA9D21B7022871920D1991BC93C",
|
|
43824
|
+
role: "release-signing",
|
|
43825
|
+
source: "https://help.ubuntu.com/community/VerifyIsoHowto"
|
|
43826
|
+
}
|
|
43827
|
+
],
|
|
43828
|
+
releaseCadence: "LTS every 2 years (April even-numbered), interim every 6 months",
|
|
43829
|
+
keyRotationNotes: "2018 key signs current-and-recent releases; 2012 key still valid for older releases. Both keys are published on keyserver.ubuntu.com and ship in /usr/share/keyrings/ubuntu-archive-keyring.gpg on Ubuntu hosts.",
|
|
43830
|
+
vendorDocUrl: "https://help.ubuntu.com/community/VerifyIsoHowto",
|
|
43831
|
+
citedAt: "2026-05-04"
|
|
43832
|
+
},
|
|
43833
|
+
debian: {
|
|
43834
|
+
vendor: "debian",
|
|
43835
|
+
sha256SumsUrlPattern: "https://cdimage.debian.org/debian-cd/current/{arch}/iso-cd/SHA256SUMS",
|
|
43836
|
+
sha256SumsSignatureUrlPattern: "https://cdimage.debian.org/debian-cd/current/{arch}/iso-cd/SHA256SUMS.sign",
|
|
43837
|
+
signaturePattern: "detached",
|
|
43838
|
+
gpgKeys: [
|
|
43839
|
+
{
|
|
43840
|
+
name: "Debian CD signing key (DA87E80D6294BE9B)",
|
|
43841
|
+
fingerprint: "DF9B9C49EAA9298432589D76DA87E80D6294BE9B",
|
|
43842
|
+
role: "release-signing",
|
|
43843
|
+
source: "https://www.debian.org/CD/verify"
|
|
43844
|
+
}
|
|
43845
|
+
],
|
|
43846
|
+
releaseCadence: "Stable release approximately every 2 years; point releases ~quarterly",
|
|
43847
|
+
keyRotationNotes: "CD signing key rotates per stable release cycle. The vendor doc page lists the current fingerprint; older keys are kept in keyring.debian.org for historical verification.",
|
|
43848
|
+
vendorDocUrl: "https://www.debian.org/CD/verify",
|
|
43849
|
+
citedAt: "2026-05-04"
|
|
43850
|
+
},
|
|
43851
|
+
fedora: {
|
|
43852
|
+
vendor: "fedora",
|
|
43853
|
+
sha256SumsUrlPattern: "https://download.fedoraproject.org/pub/fedora/linux/releases/{release}/{edition}/{arch}/iso/Fedora-{edition}-{release}-{arch}-CHECKSUM",
|
|
43854
|
+
/** Fedora ships clearsigned CHECKSUM files; signature is inline. */
|
|
43855
|
+
signaturePattern: "clearsigned",
|
|
43856
|
+
gpgKeys: [
|
|
43857
|
+
{
|
|
43858
|
+
name: "Fedora project release-signing keys (per-release)",
|
|
43859
|
+
fingerprint: "see-source",
|
|
43860
|
+
role: "release-signing",
|
|
43861
|
+
source: "https://fedoraproject.org/security"
|
|
43862
|
+
}
|
|
43863
|
+
],
|
|
43864
|
+
releaseCadence: "Major release every ~6 months; supported for ~13 months",
|
|
43865
|
+
keyRotationNotes: "Per-release signing keys. Fingerprints rotate every release and are published on the Fedora security page and in the fedora-gpg-keys package. Use `gpg --keyserver hkp://keys.fedoraproject.org --recv-keys <ID>` to fetch a specific release key.",
|
|
43866
|
+
vendorDocUrl: "https://fedoraproject.org/security",
|
|
43867
|
+
citedAt: "2026-05-04"
|
|
43868
|
+
}
|
|
43869
|
+
};
|
|
43870
|
+
function isKnownVendor(vendor) {
|
|
43871
|
+
return vendor in VENDOR_PUBLISHING_SEED;
|
|
43872
|
+
}
|
|
43873
|
+
function listKnownVendors() {
|
|
43874
|
+
return Object.keys(VENDOR_PUBLISHING_SEED).sort();
|
|
43875
|
+
}
|
|
43876
|
+
|
|
43877
|
+
// src/mcp/tools/vendor-publishing-audit.ts
|
|
43878
|
+
var VendorPublishingAuditInputSchema = z92.object({
|
|
43879
|
+
vendor: z92.string().min(1).max(50).toLowerCase().describe('Vendor identifier, lowercase. e.g. "ubuntu", "debian", "fedora"')
|
|
43880
|
+
});
|
|
43881
|
+
function lookupVendor(vendor) {
|
|
43882
|
+
if (isKnownVendor(vendor)) {
|
|
43883
|
+
return { ...VENDOR_PUBLISHING_SEED[vendor], known: true };
|
|
43884
|
+
}
|
|
43885
|
+
const knownVendors = listKnownVendors();
|
|
43886
|
+
return {
|
|
43887
|
+
vendor,
|
|
43888
|
+
known: false,
|
|
43889
|
+
message: `No seed entry for vendor "${vendor}". Known vendors: ${knownVendors.join(", ")}. Adding a vendor is data-only \u2014 see packages/nexus-agents/src/mcp/tools/vendor-publishing-seed.ts.`,
|
|
43890
|
+
knownVendors
|
|
43891
|
+
};
|
|
43892
|
+
}
|
|
43893
|
+
function createVendorPublishingAuditHandler(deps) {
|
|
43894
|
+
return async (args, ctx) => {
|
|
43895
|
+
const validation = VendorPublishingAuditInputSchema.safeParse(args);
|
|
43896
|
+
if (!validation.success) {
|
|
43897
|
+
return toolError(`Validation error: ${formatZodError(validation.error)}`);
|
|
43898
|
+
}
|
|
43899
|
+
const logger56 = deps.logger ?? createLogger({ tool: "vendor_publishing_audit" });
|
|
43900
|
+
ctx.logger.debug("Vendor publishing audit", { vendor: validation.data.vendor });
|
|
43901
|
+
return withToolError("Vendor publishing audit failed", logger56, () => {
|
|
43902
|
+
const result = lookupVendor(validation.data.vendor);
|
|
43903
|
+
return Promise.resolve(toolSuccessStructured(result));
|
|
43904
|
+
});
|
|
43905
|
+
};
|
|
43906
|
+
}
|
|
43907
|
+
var VENDOR_PUBLISHING_OUTPUT_SCHEMA = {
|
|
43908
|
+
vendor: z92.string(),
|
|
43909
|
+
known: z92.boolean(),
|
|
43910
|
+
// Fields below populate when known=true; permissive optional for known=false.
|
|
43911
|
+
sha256SumsUrlPattern: z92.string().optional(),
|
|
43912
|
+
sha256SumsSignatureUrlPattern: z92.string().optional(),
|
|
43913
|
+
signaturePattern: z92.string().optional(),
|
|
43914
|
+
gpgKeys: z92.array(z92.unknown()).optional(),
|
|
43915
|
+
releaseCadence: z92.string().optional(),
|
|
43916
|
+
keyRotationNotes: z92.string().optional(),
|
|
43917
|
+
vendorDocUrl: z92.string().optional(),
|
|
43918
|
+
citedAt: z92.string().optional(),
|
|
43919
|
+
// Fields below populate when known=false.
|
|
43920
|
+
message: z92.string().optional(),
|
|
43921
|
+
knownVendors: z92.array(z92.string()).optional()
|
|
43922
|
+
};
|
|
43923
|
+
var VENDOR_PUBLISHING_DESCRIPTION = "Look up a vendor's published-artifact signing infrastructure: GPG key fingerprints, SHA256SUMS URL pattern, signature shape (clearsigned / detached / detached-on-iso), release cadence, key rotation notes, and the vendor doc citation. Static lookup against a curated seed dataset; the vendor doc URL is the authoritative source. Returns `{known: false, knownVendors: [...]}` for vendors without a seed entry. v1 covers ubuntu, debian, fedora.";
|
|
43924
|
+
function registerVendorPublishingAuditTool(server, deps) {
|
|
43925
|
+
const logger56 = deps.logger ?? createLogger({ tool: "vendor_publishing_audit" });
|
|
43926
|
+
const secureHandler = createSecureHandler(createVendorPublishingAuditHandler(deps), {
|
|
43927
|
+
toolName: "vendor_publishing_audit",
|
|
43928
|
+
rateLimiter: deps.rateLimiter,
|
|
43929
|
+
logger: logger56
|
|
43930
|
+
});
|
|
43931
|
+
const timeoutMs = getToolTimeout("vendor_publishing_audit", deps.security);
|
|
43932
|
+
const wrappedHandler = wrapToolWithTimeout("vendor_publishing_audit", secureHandler, {
|
|
43933
|
+
timeoutMs,
|
|
43934
|
+
logger: logger56
|
|
43935
|
+
});
|
|
43936
|
+
server.registerTool(
|
|
43937
|
+
"vendor_publishing_audit",
|
|
43938
|
+
{
|
|
43939
|
+
description: VENDOR_PUBLISHING_DESCRIPTION,
|
|
43940
|
+
inputSchema: VendorPublishingAuditInputSchema.shape,
|
|
43941
|
+
outputSchema: VENDOR_PUBLISHING_OUTPUT_SCHEMA
|
|
43942
|
+
},
|
|
43943
|
+
toSdkCallback(wrappedHandler)
|
|
43944
|
+
);
|
|
43945
|
+
logger56.info("Registered vendor_publishing_audit tool");
|
|
43946
|
+
}
|
|
43947
|
+
|
|
43948
|
+
// src/mcp/tools/compare-data-feeds.ts
|
|
43949
|
+
import { z as z93 } from "zod";
|
|
43950
|
+
import * as path10 from "path";
|
|
43951
|
+
import * as fs11 from "fs";
|
|
43952
|
+
import * as yaml3 from "yaml";
|
|
43953
|
+
var CompareDataFeedsInputSchema = z93.object({
|
|
43954
|
+
feedAPath: z93.string().min(1).max(1e3).describe("Filesystem path to feed A (YAML or JSON, auto-detected by extension)"),
|
|
43955
|
+
feedBPath: z93.string().min(1).max(1e3).describe("Filesystem path to feed B"),
|
|
43956
|
+
keyPath: z93.string().min(1).max(200).describe(
|
|
43957
|
+
'Dotted path to the entry key, e.g. "id" or "name". Each entry must have this field.'
|
|
43958
|
+
),
|
|
43959
|
+
compareFields: z93.array(z93.string().min(1).max(200)).max(20).optional().describe(
|
|
43960
|
+
'Optional dotted field paths to compare across matched entries (e.g. ["license", "sha256"])'
|
|
43961
|
+
)
|
|
43962
|
+
});
|
|
43963
|
+
function readDottedPath(obj, dottedPath) {
|
|
43964
|
+
const parts = dottedPath.split(".");
|
|
43965
|
+
let cursor = obj;
|
|
43966
|
+
for (const part of parts) {
|
|
43967
|
+
if (cursor === null || cursor === void 0) return void 0;
|
|
43968
|
+
if (typeof cursor !== "object") return void 0;
|
|
43969
|
+
cursor = cursor[part];
|
|
43970
|
+
}
|
|
43971
|
+
return cursor;
|
|
43972
|
+
}
|
|
43973
|
+
function parseFeedContent(content, sourcePath) {
|
|
43974
|
+
const ext = path10.extname(sourcePath).toLowerCase();
|
|
43975
|
+
if (ext === ".json") {
|
|
43976
|
+
return JSON.parse(content);
|
|
43977
|
+
}
|
|
43978
|
+
return yaml3.parse(content);
|
|
43979
|
+
}
|
|
43980
|
+
function asEntryArray(parsed) {
|
|
43981
|
+
if (Array.isArray(parsed)) return parsed;
|
|
43982
|
+
if (parsed !== null && typeof parsed === "object") {
|
|
43983
|
+
const obj = parsed;
|
|
43984
|
+
const arrayValues = Object.values(obj).filter((v) => Array.isArray(v));
|
|
43985
|
+
if (arrayValues.length === 1) {
|
|
43986
|
+
const first = arrayValues[0];
|
|
43987
|
+
if (first !== void 0) return first;
|
|
43988
|
+
}
|
|
43989
|
+
}
|
|
43990
|
+
throw new Error(
|
|
43991
|
+
"Feed must be a top-level array, or an object with exactly one array-valued field. Top-level objects with multiple array fields are ambiguous; flatten the feed first."
|
|
43992
|
+
);
|
|
43993
|
+
}
|
|
43994
|
+
function indexByKey(entries, keyPath) {
|
|
43995
|
+
const index = /* @__PURE__ */ new Map();
|
|
43996
|
+
const missingKeyAt = [];
|
|
43997
|
+
for (let i = 0; i < entries.length; i++) {
|
|
43998
|
+
const entry = entries[i];
|
|
43999
|
+
const key = readDottedPath(entry, keyPath);
|
|
44000
|
+
if (key === void 0 || key === null) {
|
|
44001
|
+
missingKeyAt.push(i);
|
|
44002
|
+
continue;
|
|
44003
|
+
}
|
|
44004
|
+
if (typeof key === "object") {
|
|
44005
|
+
missingKeyAt.push(i);
|
|
44006
|
+
continue;
|
|
44007
|
+
}
|
|
44008
|
+
const keyStr = typeof key === "string" ? key : typeof key === "number" ? String(key) : typeof key === "bigint" ? key.toString() : typeof key === "boolean" ? String(key) : "";
|
|
44009
|
+
if (keyStr === "") {
|
|
44010
|
+
missingKeyAt.push(i);
|
|
44011
|
+
continue;
|
|
44012
|
+
}
|
|
44013
|
+
index.set(keyStr, entry);
|
|
44014
|
+
}
|
|
44015
|
+
return { index, missingKeyAt };
|
|
44016
|
+
}
|
|
44017
|
+
function membershipDiff(indexA, indexB) {
|
|
44018
|
+
const onlyInA = [];
|
|
44019
|
+
const onlyInB = [];
|
|
44020
|
+
const inBoth = [];
|
|
44021
|
+
for (const key of indexA.keys()) {
|
|
44022
|
+
if (indexB.has(key)) inBoth.push(key);
|
|
44023
|
+
else onlyInA.push(key);
|
|
44024
|
+
}
|
|
44025
|
+
for (const key of indexB.keys()) {
|
|
44026
|
+
if (!indexA.has(key)) onlyInB.push(key);
|
|
44027
|
+
}
|
|
44028
|
+
onlyInA.sort();
|
|
44029
|
+
onlyInB.sort();
|
|
44030
|
+
inBoth.sort();
|
|
44031
|
+
return { onlyInA, onlyInB, inBoth };
|
|
44032
|
+
}
|
|
44033
|
+
function compareFields(inBothKeys, indexA, indexB, fields) {
|
|
44034
|
+
const out = [];
|
|
44035
|
+
for (const key of inBothKeys) {
|
|
44036
|
+
const a = indexA.get(key);
|
|
44037
|
+
const b = indexB.get(key);
|
|
44038
|
+
for (const field of fields) {
|
|
44039
|
+
const valueA = readDottedPath(a, field);
|
|
44040
|
+
const valueB = readDottedPath(b, field);
|
|
44041
|
+
if (!deepEqual(valueA, valueB)) {
|
|
44042
|
+
out.push({ key, field, valueA, valueB });
|
|
44043
|
+
}
|
|
44044
|
+
}
|
|
44045
|
+
}
|
|
44046
|
+
return out;
|
|
44047
|
+
}
|
|
44048
|
+
function deepEqualArrays(a, b) {
|
|
44049
|
+
if (a.length !== b.length) return false;
|
|
44050
|
+
return a.every((v, i) => deepEqual(v, b[i]));
|
|
44051
|
+
}
|
|
44052
|
+
function deepEqualObjects(a, b) {
|
|
44053
|
+
const aKeys = Object.keys(a).sort();
|
|
44054
|
+
const bKeys = Object.keys(b).sort();
|
|
44055
|
+
if (aKeys.length !== bKeys.length) return false;
|
|
44056
|
+
if (!aKeys.every((k, i) => k === bKeys[i])) return false;
|
|
44057
|
+
return aKeys.every((k) => deepEqual(a[k], b[k]));
|
|
44058
|
+
}
|
|
44059
|
+
function deepEqual(a, b) {
|
|
44060
|
+
if (a === b) return true;
|
|
44061
|
+
if (a === null || b === null) return false;
|
|
44062
|
+
if (typeof a !== typeof b) return false;
|
|
44063
|
+
if (typeof a !== "object") return false;
|
|
44064
|
+
if (Array.isArray(a) !== Array.isArray(b)) return false;
|
|
44065
|
+
if (Array.isArray(a) && Array.isArray(b)) return deepEqualArrays(a, b);
|
|
44066
|
+
return deepEqualObjects(a, b);
|
|
44067
|
+
}
|
|
44068
|
+
function buildSummary(feedAPath, feedBPath, diff, fieldDiffs, fields) {
|
|
44069
|
+
const lines = [];
|
|
44070
|
+
lines.push(`Feed A: ${feedAPath} (${String(diff.onlyInA.length)} only-in-A)`);
|
|
44071
|
+
lines.push(`Feed B: ${feedBPath} (${String(diff.onlyInB.length)} only-in-B)`);
|
|
44072
|
+
lines.push(`In both: ${String(diff.inBoth.length)} entries`);
|
|
44073
|
+
if (fields.length > 0) {
|
|
44074
|
+
lines.push(
|
|
44075
|
+
`Field comparison across ${String(fields.length)} field(s) found ${String(fieldDiffs.length)} differences in ${String(diff.inBoth.length)} matched entries`
|
|
44076
|
+
);
|
|
44077
|
+
}
|
|
44078
|
+
return lines.join("\n");
|
|
44079
|
+
}
|
|
44080
|
+
function loadFeed(feedPath) {
|
|
44081
|
+
const resolved = path10.resolve(feedPath);
|
|
44082
|
+
const cwdRoot = path10.resolve(".");
|
|
44083
|
+
if (!resolved.startsWith(cwdRoot)) {
|
|
44084
|
+
throw new Error(`Path traversal denied: ${feedPath} must be within ${cwdRoot}`);
|
|
44085
|
+
}
|
|
44086
|
+
if (!fs11.existsSync(resolved)) {
|
|
44087
|
+
throw new Error(`Feed file not found: ${resolved}`);
|
|
44088
|
+
}
|
|
44089
|
+
const content = fs11.readFileSync(resolved, "utf-8");
|
|
44090
|
+
const parsed = parseFeedContent(content, resolved);
|
|
44091
|
+
return asEntryArray(parsed);
|
|
44092
|
+
}
|
|
44093
|
+
function executeCompare(input) {
|
|
44094
|
+
const entriesA = loadFeed(input.feedAPath);
|
|
44095
|
+
const entriesB = loadFeed(input.feedBPath);
|
|
44096
|
+
const indexA = indexByKey(entriesA, input.keyPath).index;
|
|
44097
|
+
const indexB = indexByKey(entriesB, input.keyPath).index;
|
|
44098
|
+
const diff = membershipDiff(indexA, indexB);
|
|
44099
|
+
const fields = input.compareFields ?? [];
|
|
44100
|
+
const fieldDiffs = compareFields(diff.inBoth, indexA, indexB, fields);
|
|
44101
|
+
return {
|
|
44102
|
+
feedAPath: input.feedAPath,
|
|
44103
|
+
feedBPath: input.feedBPath,
|
|
44104
|
+
keyPath: input.keyPath,
|
|
44105
|
+
counts: {
|
|
44106
|
+
entriesInA: indexA.size,
|
|
44107
|
+
entriesInB: indexB.size,
|
|
44108
|
+
onlyInA: diff.onlyInA.length,
|
|
44109
|
+
onlyInB: diff.onlyInB.length,
|
|
44110
|
+
inBoth: diff.inBoth.length,
|
|
44111
|
+
fieldDifferences: fieldDiffs.length
|
|
44112
|
+
},
|
|
44113
|
+
coverage: {
|
|
44114
|
+
onlyInA: diff.onlyInA,
|
|
44115
|
+
onlyInB: diff.onlyInB,
|
|
44116
|
+
inBoth: diff.inBoth
|
|
44117
|
+
},
|
|
44118
|
+
fieldDifferences: fieldDiffs,
|
|
44119
|
+
summary: buildSummary(input.feedAPath, input.feedBPath, diff, fieldDiffs, fields)
|
|
44120
|
+
};
|
|
44121
|
+
}
|
|
44122
|
+
function createCompareDataFeedsHandler(deps) {
|
|
44123
|
+
return async (args, ctx) => {
|
|
44124
|
+
const validation = CompareDataFeedsInputSchema.safeParse(args);
|
|
44125
|
+
if (!validation.success) {
|
|
44126
|
+
return toolError(`Validation error: ${formatZodError(validation.error)}`);
|
|
44127
|
+
}
|
|
44128
|
+
const logger56 = deps.logger ?? createLogger({ tool: "compare_data_feeds" });
|
|
44129
|
+
ctx.logger.debug("Comparing data feeds", {
|
|
44130
|
+
feedAPath: validation.data.feedAPath,
|
|
44131
|
+
feedBPath: validation.data.feedBPath
|
|
44132
|
+
});
|
|
44133
|
+
return withToolError("Compare data feeds failed", logger56, () => {
|
|
44134
|
+
const result = executeCompare(validation.data);
|
|
44135
|
+
return Promise.resolve(toolSuccessStructured(result));
|
|
44136
|
+
});
|
|
44137
|
+
};
|
|
44138
|
+
}
|
|
44139
|
+
var COMPARE_OUTPUT_SCHEMA = {
|
|
44140
|
+
feedAPath: z93.string(),
|
|
44141
|
+
feedBPath: z93.string(),
|
|
44142
|
+
keyPath: z93.string(),
|
|
44143
|
+
counts: z93.object({
|
|
44144
|
+
entriesInA: z93.number(),
|
|
44145
|
+
entriesInB: z93.number(),
|
|
44146
|
+
onlyInA: z93.number(),
|
|
44147
|
+
onlyInB: z93.number(),
|
|
44148
|
+
inBoth: z93.number(),
|
|
44149
|
+
fieldDifferences: z93.number()
|
|
44150
|
+
}),
|
|
44151
|
+
coverage: z93.object({
|
|
44152
|
+
onlyInA: z93.array(z93.string()),
|
|
44153
|
+
onlyInB: z93.array(z93.string()),
|
|
44154
|
+
inBoth: z93.array(z93.string())
|
|
44155
|
+
}),
|
|
44156
|
+
fieldDifferences: z93.array(z93.unknown()),
|
|
44157
|
+
summary: z93.string()
|
|
44158
|
+
};
|
|
44159
|
+
var COMPARE_DESCRIPTION = "Diff two upstream data feeds (YAML or JSON files) along coverage and per-field axes. Returns which entries exist in A, B, both, plus optional field-level diffs across matched entries. v1 takes file paths only (no URL fetch \u2014 that needs an SSRF design pass). Both feeds must be a top-level array OR a top-level object with exactly one array field.";
|
|
44160
|
+
function registerCompareDataFeedsTool(server, deps) {
|
|
44161
|
+
const logger56 = deps.logger ?? createLogger({ tool: "compare_data_feeds" });
|
|
44162
|
+
const secureHandler = createSecureHandler(createCompareDataFeedsHandler(deps), {
|
|
44163
|
+
toolName: "compare_data_feeds",
|
|
44164
|
+
rateLimiter: deps.rateLimiter,
|
|
44165
|
+
logger: logger56
|
|
44166
|
+
});
|
|
44167
|
+
const timeoutMs = getToolTimeout("compare_data_feeds", deps.security);
|
|
44168
|
+
const wrappedHandler = wrapToolWithTimeout("compare_data_feeds", secureHandler, {
|
|
44169
|
+
timeoutMs,
|
|
44170
|
+
logger: logger56
|
|
44171
|
+
});
|
|
44172
|
+
server.registerTool(
|
|
44173
|
+
"compare_data_feeds",
|
|
44174
|
+
{
|
|
44175
|
+
description: COMPARE_DESCRIPTION,
|
|
44176
|
+
inputSchema: CompareDataFeedsInputSchema.shape,
|
|
44177
|
+
outputSchema: COMPARE_OUTPUT_SCHEMA
|
|
44178
|
+
},
|
|
44179
|
+
toSdkCallback(wrappedHandler)
|
|
44180
|
+
);
|
|
44181
|
+
logger56.info("Registered compare_data_feeds tool");
|
|
44182
|
+
}
|
|
44183
|
+
|
|
44184
|
+
// src/mcp/tools/query-task-state-tool.ts
|
|
44185
|
+
import { z as z94 } from "zod";
|
|
44186
|
+
var QueryTaskStateInputSchema = z94.object({
|
|
44187
|
+
taskId: z94.string().min(1).max(128).describe("Task ID whose structured state log should be read")
|
|
43560
44188
|
});
|
|
43561
44189
|
function queryTaskStateHandler(args, ctx) {
|
|
43562
44190
|
const parsed = QueryTaskStateInputSchema.safeParse(args);
|
|
@@ -43586,7 +44214,7 @@ function queryTaskStateHandler(args, ctx) {
|
|
|
43586
44214
|
function registerQueryTaskStateTool(server, deps) {
|
|
43587
44215
|
const logger56 = deps.logger ?? createLogger({ tool: "query_task_state" });
|
|
43588
44216
|
const toolSchema = {
|
|
43589
|
-
taskId:
|
|
44217
|
+
taskId: z94.string().min(1).max(128).describe("Task ID whose structured state log should be read")
|
|
43590
44218
|
};
|
|
43591
44219
|
const description = "Read the structured state log for a task ID and return the current snapshot. Includes Magentic-One Task Ledger (facts/guesses/openQuestions) and Progress Ledger (per-step reflections with suggestedAction) when orchestrators have written them. Structured state is only written when NEXUS_TASK_STATE_ENABLED=1 was set during the orchestrate invocation.";
|
|
43592
44220
|
const secureHandler = createSecureHandler(queryTaskStateHandler, {
|
|
@@ -43608,23 +44236,23 @@ function registerQueryTaskStateTool(server, deps) {
|
|
|
43608
44236
|
}
|
|
43609
44237
|
|
|
43610
44238
|
// src/mcp/tools/verify-audit-chain-tool.ts
|
|
43611
|
-
import * as
|
|
43612
|
-
import * as
|
|
43613
|
-
import { z as
|
|
43614
|
-
var VerifyAuditChainInputSchema =
|
|
43615
|
-
logDir:
|
|
44239
|
+
import * as fs12 from "fs/promises";
|
|
44240
|
+
import * as path11 from "path";
|
|
44241
|
+
import { z as z95 } from "zod";
|
|
44242
|
+
var VerifyAuditChainInputSchema = z95.object({
|
|
44243
|
+
logDir: z95.string().min(1).max(512).describe(
|
|
43616
44244
|
"Filesystem path to the FileAuditStorage log directory. Tool reads all `audit-*.jsonl` files in lexicographic order and verifies the combined chain."
|
|
43617
44245
|
)
|
|
43618
44246
|
});
|
|
43619
44247
|
async function loadAuditEvents(dir, logger56) {
|
|
43620
|
-
const entries = await
|
|
44248
|
+
const entries = await fs12.readdir(dir);
|
|
43621
44249
|
const auditFiles = entries.filter((name) => name.startsWith("audit-") && name.endsWith(".jsonl")).sort();
|
|
43622
44250
|
const events = [];
|
|
43623
44251
|
for (const filename of auditFiles) {
|
|
43624
|
-
const fullPath =
|
|
44252
|
+
const fullPath = path11.join(dir, filename);
|
|
43625
44253
|
let content;
|
|
43626
44254
|
try {
|
|
43627
|
-
content = await
|
|
44255
|
+
content = await fs12.readFile(fullPath, "utf-8");
|
|
43628
44256
|
} catch (cause) {
|
|
43629
44257
|
const msg = cause instanceof Error ? cause.message : String(cause);
|
|
43630
44258
|
logger56.warn("Skipping unreadable audit log file", { filename, error: msg });
|
|
@@ -43656,10 +44284,10 @@ async function handler2(args, ctx) {
|
|
|
43656
44284
|
if (!parsed.success) {
|
|
43657
44285
|
return toolError(`Validation error: ${formatZodError(parsed.error)}`);
|
|
43658
44286
|
}
|
|
43659
|
-
const resolvedDir =
|
|
44287
|
+
const resolvedDir = path11.resolve(parsed.data.logDir);
|
|
43660
44288
|
let dirStats;
|
|
43661
44289
|
try {
|
|
43662
|
-
dirStats = await
|
|
44290
|
+
dirStats = await fs12.stat(resolvedDir);
|
|
43663
44291
|
} catch (cause) {
|
|
43664
44292
|
const msg = cause instanceof Error ? cause.message : String(cause);
|
|
43665
44293
|
return toolError(`Cannot access logDir "${resolvedDir}": ${msg}`);
|
|
@@ -43680,7 +44308,7 @@ async function handler2(args, ctx) {
|
|
|
43680
44308
|
function registerVerifyAuditChainTool(server, deps) {
|
|
43681
44309
|
const logger56 = deps.logger ?? createLogger({ tool: "verify_audit_chain" });
|
|
43682
44310
|
const toolSchema = {
|
|
43683
|
-
logDir:
|
|
44311
|
+
logDir: z95.string().min(1).max(512).describe(
|
|
43684
44312
|
"Filesystem path to the FileAuditStorage log directory. Tool reads all `audit-*.jsonl` files and verifies the combined hash chain."
|
|
43685
44313
|
)
|
|
43686
44314
|
};
|
|
@@ -43704,18 +44332,18 @@ function registerVerifyAuditChainTool(server, deps) {
|
|
|
43704
44332
|
}
|
|
43705
44333
|
|
|
43706
44334
|
// src/mcp/tools/pipeline-tool.ts
|
|
43707
|
-
import { z as
|
|
43708
|
-
import * as
|
|
43709
|
-
import * as
|
|
43710
|
-
var PipelineInputSchema =
|
|
44335
|
+
import { z as z96 } from "zod";
|
|
44336
|
+
import * as fs13 from "fs";
|
|
44337
|
+
import * as path12 from "path";
|
|
44338
|
+
var PipelineInputSchema = z96.object({
|
|
43711
44339
|
/** The task to execute. */
|
|
43712
|
-
task:
|
|
44340
|
+
task: z96.string().min(5).max(1e4).describe("Task description \u2014 pipeline template auto-selected based on content"),
|
|
43713
44341
|
/** Path to a spec file (.md, .yaml) to use as task input. */
|
|
43714
|
-
specFile:
|
|
44342
|
+
specFile: z96.string().max(500).optional().describe("Path to a spec file \u2014 content prepended to task for greenfield projects"),
|
|
43715
44343
|
/** Override template (dev, research, audit, greenfield). Auto-detected if omitted. */
|
|
43716
|
-
template:
|
|
44344
|
+
template: z96.string().max(50).optional().describe(`Pipeline template override. Available: ${listTemplateIds().join(", ")}`),
|
|
43717
44345
|
/** Voting strategy for consensus stages. */
|
|
43718
|
-
votingStrategy:
|
|
44346
|
+
votingStrategy: z96.enum([
|
|
43719
44347
|
"simple_majority",
|
|
43720
44348
|
"supermajority",
|
|
43721
44349
|
"unanimous",
|
|
@@ -43726,13 +44354,13 @@ var PipelineInputSchema = z93.object({
|
|
|
43726
44354
|
"Voting strategy for plan approval. simple_majority (default), supermajority (67%), unanimous, higher_order (Bayesian), proof_of_learning, opinion_wise"
|
|
43727
44355
|
),
|
|
43728
44356
|
/** Use 3 agents instead of 6 for faster voting. */
|
|
43729
|
-
quickMode:
|
|
44357
|
+
quickMode: z96.boolean().default(false).describe("Use 3 agents instead of 6 for faster consensus voting"),
|
|
43730
44358
|
/** Maximum execution time per stage in milliseconds (min 30s, max 600s). */
|
|
43731
|
-
timeoutMs:
|
|
44359
|
+
timeoutMs: z96.number().int().min(3e4).max(6e5).optional().describe("Max time per stage in ms (30000-600000). Default: varies by stage complexity"),
|
|
43732
44360
|
/** Stop after planning/voting (no implementation). */
|
|
43733
|
-
dryRun:
|
|
44361
|
+
dryRun: z96.boolean().default(false).describe("Stop after vote stage (no implementation)"),
|
|
43734
44362
|
/** TESTS ONLY — random output, must not be used for real decisions. (#2319) */
|
|
43735
|
-
simulateVotes:
|
|
44363
|
+
simulateVotes: z96.boolean().default(false).describe("TESTS ONLY \u2014 random output, must not be used for real decisions (#2319)")
|
|
43736
44364
|
});
|
|
43737
44365
|
function buildOutput2(result) {
|
|
43738
44366
|
return {
|
|
@@ -43747,22 +44375,26 @@ function buildOutput2(result) {
|
|
|
43747
44375
|
rateLimitHint: result.error?.toLowerCase().includes("rate limit") === true ? "Consider using quickMode or increasing delay between pipeline runs" : void 0
|
|
43748
44376
|
};
|
|
43749
44377
|
}
|
|
43750
|
-
function resolveTask(task, specFile) {
|
|
44378
|
+
async function resolveTask(task, specFile) {
|
|
43751
44379
|
if (specFile === void 0) return task;
|
|
43752
|
-
const resolved =
|
|
43753
|
-
const cwdRoot =
|
|
44380
|
+
const resolved = path12.resolve(specFile);
|
|
44381
|
+
const cwdRoot = path12.resolve(".");
|
|
43754
44382
|
if (!resolved.startsWith(cwdRoot)) {
|
|
43755
44383
|
throw new Error(`Path traversal denied: specFile must be within ${cwdRoot}`);
|
|
43756
44384
|
}
|
|
43757
|
-
|
|
43758
|
-
|
|
43759
|
-
|
|
43760
|
-
const specContent = fs12.readFileSync(resolved, "utf-8");
|
|
43761
|
-
return `${specContent}
|
|
44385
|
+
try {
|
|
44386
|
+
const specContent = await fs13.promises.readFile(resolved, "utf-8");
|
|
44387
|
+
return `${specContent}
|
|
43762
44388
|
|
|
43763
44389
|
---
|
|
43764
44390
|
|
|
43765
44391
|
${task}`;
|
|
44392
|
+
} catch (err2) {
|
|
44393
|
+
if (err2.code === "ENOENT") {
|
|
44394
|
+
throw new Error(`Spec file not found: ${resolved}`);
|
|
44395
|
+
}
|
|
44396
|
+
throw err2;
|
|
44397
|
+
}
|
|
43766
44398
|
}
|
|
43767
44399
|
function selectStageRegistry(template, task, agentStages) {
|
|
43768
44400
|
const effectiveTemplate = template ?? classifyTask(task).pipelineType;
|
|
@@ -43785,7 +44417,7 @@ function registerPipelineTool(server, _deps) {
|
|
|
43785
44417
|
warnIfSimulatedOutsideTests("run_pipeline", createLogger({ tool: "run_pipeline" }));
|
|
43786
44418
|
}
|
|
43787
44419
|
try {
|
|
43788
|
-
const task = resolveTask(input.task, input.specFile);
|
|
44420
|
+
const task = await resolveTask(input.task, input.specFile);
|
|
43789
44421
|
const agentStages = createAgentStages({
|
|
43790
44422
|
simulateVotes: input.simulateVotes,
|
|
43791
44423
|
votingStrategy: input.votingStrategy,
|
|
@@ -43813,7 +44445,7 @@ function registerPipelineTool(server, _deps) {
|
|
|
43813
44445
|
}
|
|
43814
44446
|
|
|
43815
44447
|
// src/mcp/tools/supply-chain-tradeoff-panel.ts
|
|
43816
|
-
import { z as
|
|
44448
|
+
import { z as z97 } from "zod";
|
|
43817
44449
|
var DEFAULT_AXES = [
|
|
43818
44450
|
"build_time_determinism",
|
|
43819
44451
|
"supply_chain_risk",
|
|
@@ -43823,16 +44455,16 @@ var MAX_AXES = 6;
|
|
|
43823
44455
|
var MAX_AXIS_NAME_LENGTH = 64;
|
|
43824
44456
|
var MAX_PROPOSAL_LENGTH = 4e3;
|
|
43825
44457
|
var MAX_CONTEXT_LENGTH = 4e3;
|
|
43826
|
-
var SupplyChainTradeoffPanelInputSchema =
|
|
43827
|
-
proposal:
|
|
43828
|
-
axes:
|
|
44458
|
+
var SupplyChainTradeoffPanelInputSchema = z97.object({
|
|
44459
|
+
proposal: z97.string().min(1).max(MAX_PROPOSAL_LENGTH).describe('The proposal under tradeoff review (e.g. "Should aegis-boot adopt cargo-nextest?")'),
|
|
44460
|
+
axes: z97.array(z97.string().min(1).max(MAX_AXIS_NAME_LENGTH)).min(1).max(MAX_AXES).optional().describe(
|
|
43829
44461
|
`Tradeoff axes to evaluate. Default: ${DEFAULT_AXES.join(", ")}. Custom axes accepted; max ${String(MAX_AXES)}.`
|
|
43830
44462
|
),
|
|
43831
|
-
context:
|
|
44463
|
+
context: z97.string().max(MAX_CONTEXT_LENGTH).optional().describe(
|
|
43832
44464
|
"Optional context: relevant repo state, dependency tree, vendor publishing patterns, etc."
|
|
43833
44465
|
),
|
|
43834
|
-
quickMode:
|
|
43835
|
-
simulate:
|
|
44466
|
+
quickMode: z97.boolean().optional().default(false).describe("Use 3 voters (architect, security, scope_steward) instead of 7"),
|
|
44467
|
+
simulate: z97.boolean().optional().default(false).describe("Use simulated voters (testing only)")
|
|
43836
44468
|
});
|
|
43837
44469
|
|
|
43838
44470
|
// src/mcp/tools/tool-annotations.ts
|
|
@@ -43974,6 +44606,40 @@ var TOOL_ANNOTATIONS = {
|
|
|
43974
44606
|
{ category: "coupling", description: "Auto-catalogs discovered references" }
|
|
43975
44607
|
]
|
|
43976
44608
|
},
|
|
44609
|
+
survey_oss_landscape: {
|
|
44610
|
+
annotations: {
|
|
44611
|
+
title: "Survey OSS Landscape",
|
|
44612
|
+
readOnlyHint: true,
|
|
44613
|
+
destructiveHint: false,
|
|
44614
|
+
// Same query may return different results day-to-day as star counts
|
|
44615
|
+
// and last-commit dates evolve; idempotentHint=false matches reality.
|
|
44616
|
+
idempotentHint: false,
|
|
44617
|
+
openWorldHint: true
|
|
44618
|
+
},
|
|
44619
|
+
sideEffects: [{ category: "implicit", description: "Queries the GitHub search API" }]
|
|
44620
|
+
},
|
|
44621
|
+
vendor_publishing_audit: {
|
|
44622
|
+
annotations: {
|
|
44623
|
+
title: "Vendor Publishing Audit",
|
|
44624
|
+
readOnlyHint: true,
|
|
44625
|
+
destructiveHint: false,
|
|
44626
|
+
// Pure static lookup against the in-process seed dataset.
|
|
44627
|
+
idempotentHint: true,
|
|
44628
|
+
openWorldHint: false
|
|
44629
|
+
},
|
|
44630
|
+
sideEffects: [{ category: "implicit", description: "Consumes rate limit quota" }]
|
|
44631
|
+
},
|
|
44632
|
+
compare_data_feeds: {
|
|
44633
|
+
annotations: {
|
|
44634
|
+
title: "Compare Data Feeds",
|
|
44635
|
+
readOnlyHint: true,
|
|
44636
|
+
destructiveHint: false,
|
|
44637
|
+
// Same input → same output; pure file diff with no external calls.
|
|
44638
|
+
idempotentHint: true,
|
|
44639
|
+
openWorldHint: false
|
|
44640
|
+
},
|
|
44641
|
+
sideEffects: [{ category: "implicit", description: "Reads two files from the workspace" }]
|
|
44642
|
+
},
|
|
43977
44643
|
research_analyze: {
|
|
43978
44644
|
annotations: {
|
|
43979
44645
|
title: "Research Analyze",
|
|
@@ -44214,48 +44880,52 @@ function wrapWithObservability(toolName, cb, eventBus) {
|
|
|
44214
44880
|
}
|
|
44215
44881
|
|
|
44216
44882
|
// src/mcp/tools/index.ts
|
|
44883
|
+
var REGISTERED_TOOL_NAMES = [
|
|
44884
|
+
"orchestrate",
|
|
44885
|
+
"create_expert",
|
|
44886
|
+
"execute_expert",
|
|
44887
|
+
"run_workflow",
|
|
44888
|
+
"delegate_to_model",
|
|
44889
|
+
"list_experts",
|
|
44890
|
+
"list_workflows",
|
|
44891
|
+
"consensus_vote",
|
|
44892
|
+
"research_query",
|
|
44893
|
+
"research_add",
|
|
44894
|
+
"research_add_source",
|
|
44895
|
+
"research_discover",
|
|
44896
|
+
"research_analyze",
|
|
44897
|
+
"research_catalog_review",
|
|
44898
|
+
"research_synthesize",
|
|
44899
|
+
"survey_oss_landscape",
|
|
44900
|
+
"vendor_publishing_audit",
|
|
44901
|
+
"compare_data_feeds",
|
|
44902
|
+
"memory_query",
|
|
44903
|
+
"memory_stats",
|
|
44904
|
+
"memory_write",
|
|
44905
|
+
"weather_report",
|
|
44906
|
+
"issue_triage",
|
|
44907
|
+
"run_graph_workflow",
|
|
44908
|
+
"execute_spec",
|
|
44909
|
+
"registry_import",
|
|
44910
|
+
"query_trace",
|
|
44911
|
+
"query_task_state",
|
|
44912
|
+
"verify_audit_chain",
|
|
44913
|
+
"repo_analyze",
|
|
44914
|
+
"repo_security_plan",
|
|
44915
|
+
"extract_symbols",
|
|
44916
|
+
"search_codebase",
|
|
44917
|
+
"run_dev_pipeline",
|
|
44918
|
+
"run_pipeline",
|
|
44919
|
+
"pr_review",
|
|
44920
|
+
"supply_chain_tradeoff_panel"
|
|
44921
|
+
];
|
|
44217
44922
|
function registerTools(server, options) {
|
|
44218
44923
|
const logger56 = options?.logger ?? createMcpLogger({ component: "tools" });
|
|
44219
44924
|
const rateLimiter = options?.rateLimiter ?? createDefaultRateLimiter("mcp-tools", logger56);
|
|
44220
44925
|
logger56.info("Tool registration infrastructure initialized");
|
|
44221
44926
|
void server;
|
|
44222
44927
|
return {
|
|
44223
|
-
tools: [
|
|
44224
|
-
"orchestrate",
|
|
44225
|
-
"create_expert",
|
|
44226
|
-
"execute_expert",
|
|
44227
|
-
"run_workflow",
|
|
44228
|
-
"delegate_to_model",
|
|
44229
|
-
"list_experts",
|
|
44230
|
-
"list_workflows",
|
|
44231
|
-
"consensus_vote",
|
|
44232
|
-
"research_query",
|
|
44233
|
-
"research_add",
|
|
44234
|
-
"research_add_source",
|
|
44235
|
-
"research_discover",
|
|
44236
|
-
"research_analyze",
|
|
44237
|
-
"research_catalog_review",
|
|
44238
|
-
"research_synthesize",
|
|
44239
|
-
"memory_query",
|
|
44240
|
-
"memory_stats",
|
|
44241
|
-
"memory_write",
|
|
44242
|
-
"weather_report",
|
|
44243
|
-
"issue_triage",
|
|
44244
|
-
"run_graph_workflow",
|
|
44245
|
-
"execute_spec",
|
|
44246
|
-
"registry_import",
|
|
44247
|
-
"query_trace",
|
|
44248
|
-
"query_task_state",
|
|
44249
|
-
"verify_audit_chain",
|
|
44250
|
-
"repo_analyze",
|
|
44251
|
-
"repo_security_plan",
|
|
44252
|
-
"extract_symbols",
|
|
44253
|
-
"search_codebase",
|
|
44254
|
-
"run_dev_pipeline",
|
|
44255
|
-
"run_pipeline",
|
|
44256
|
-
"pr_review",
|
|
44257
|
-
"supply_chain_tradeoff_panel"
|
|
44258
|
-
],
|
|
44928
|
+
tools: [...REGISTERED_TOOL_NAMES],
|
|
44259
44929
|
logger: logger56,
|
|
44260
44930
|
rateLimiter
|
|
44261
44931
|
};
|
|
@@ -44382,40 +45052,40 @@ var RiskLevel = /* @__PURE__ */ ((RiskLevel2) => {
|
|
|
44382
45052
|
})(RiskLevel || {});
|
|
44383
45053
|
|
|
44384
45054
|
// src/mcp/safety/stpa-schemas.ts
|
|
44385
|
-
import { z as
|
|
44386
|
-
var HazardCategorySchema =
|
|
44387
|
-
var HazardSeveritySchema =
|
|
44388
|
-
var ConstraintPrioritySchema =
|
|
44389
|
-
var RiskLevelSchema =
|
|
44390
|
-
var TriggerPatternSchema =
|
|
44391
|
-
parameter:
|
|
44392
|
-
matchType:
|
|
44393
|
-
pattern:
|
|
44394
|
-
reason:
|
|
45055
|
+
import { z as z98 } from "zod";
|
|
45056
|
+
var HazardCategorySchema = z98.enum(HazardCategory);
|
|
45057
|
+
var HazardSeveritySchema = z98.enum(HazardSeverity);
|
|
45058
|
+
var ConstraintPrioritySchema = z98.enum(ConstraintPriority);
|
|
45059
|
+
var RiskLevelSchema = z98.enum(RiskLevel);
|
|
45060
|
+
var TriggerPatternSchema = z98.object({
|
|
45061
|
+
parameter: z98.string().min(1),
|
|
45062
|
+
matchType: z98.enum(["contains", "regex", "equals", "startsWith", "endsWith"]),
|
|
45063
|
+
pattern: z98.string(),
|
|
45064
|
+
reason: z98.string()
|
|
44395
45065
|
});
|
|
44396
|
-
var HazardSchema =
|
|
44397
|
-
id:
|
|
44398
|
-
description:
|
|
45066
|
+
var HazardSchema = z98.object({
|
|
45067
|
+
id: z98.string().min(1),
|
|
45068
|
+
description: z98.string(),
|
|
44399
45069
|
category: HazardCategorySchema,
|
|
44400
45070
|
severity: HazardSeveritySchema,
|
|
44401
|
-
likelihood:
|
|
44402
|
-
triggerConditions:
|
|
44403
|
-
consequences:
|
|
45071
|
+
likelihood: z98.enum(["almost_certain", "likely", "possible", "unlikely", "rare"]),
|
|
45072
|
+
triggerConditions: z98.array(z98.string()),
|
|
45073
|
+
consequences: z98.array(z98.string())
|
|
44404
45074
|
});
|
|
44405
|
-
var UnsafeControlActionSchema =
|
|
44406
|
-
id:
|
|
44407
|
-
toolName:
|
|
44408
|
-
type:
|
|
44409
|
-
description:
|
|
44410
|
-
unsafeContext:
|
|
44411
|
-
relatedHazards:
|
|
44412
|
-
triggerPatterns:
|
|
45075
|
+
var UnsafeControlActionSchema = z98.object({
|
|
45076
|
+
id: z98.string().min(1),
|
|
45077
|
+
toolName: z98.string().min(1),
|
|
45078
|
+
type: z98.enum(["not_provided", "provided_causes_hazard", "wrong_timing", "wrong_duration"]),
|
|
45079
|
+
description: z98.string(),
|
|
45080
|
+
unsafeContext: z98.string(),
|
|
45081
|
+
relatedHazards: z98.array(z98.string()),
|
|
45082
|
+
triggerPatterns: z98.array(TriggerPatternSchema).optional()
|
|
44413
45083
|
});
|
|
44414
|
-
var SafetyConstraintSchema =
|
|
44415
|
-
id:
|
|
44416
|
-
description:
|
|
44417
|
-
mitigates:
|
|
44418
|
-
enforcement:
|
|
45084
|
+
var SafetyConstraintSchema = z98.object({
|
|
45085
|
+
id: z98.string().min(1),
|
|
45086
|
+
description: z98.string(),
|
|
45087
|
+
mitigates: z98.array(z98.string()),
|
|
45088
|
+
enforcement: z98.enum([
|
|
44419
45089
|
"prevent",
|
|
44420
45090
|
"require_confirmation",
|
|
44421
45091
|
"alert",
|
|
@@ -44423,54 +45093,54 @@ var SafetyConstraintSchema = z95.object({
|
|
|
44423
45093
|
"rate_limit",
|
|
44424
45094
|
"require_privilege"
|
|
44425
45095
|
]),
|
|
44426
|
-
validationFunction:
|
|
45096
|
+
validationFunction: z98.string().optional(),
|
|
44427
45097
|
priority: ConstraintPrioritySchema
|
|
44428
45098
|
});
|
|
44429
|
-
var PropertySchemaSchema =
|
|
44430
|
-
type:
|
|
44431
|
-
description:
|
|
44432
|
-
enum:
|
|
44433
|
-
pattern:
|
|
44434
|
-
minimum:
|
|
44435
|
-
maximum:
|
|
45099
|
+
var PropertySchemaSchema = z98.object({
|
|
45100
|
+
type: z98.string(),
|
|
45101
|
+
description: z98.string().optional(),
|
|
45102
|
+
enum: z98.array(z98.unknown()).optional(),
|
|
45103
|
+
pattern: z98.string().optional(),
|
|
45104
|
+
minimum: z98.number().optional(),
|
|
45105
|
+
maximum: z98.number().optional()
|
|
44436
45106
|
});
|
|
44437
|
-
var ToolInputSchemaSchema =
|
|
44438
|
-
type:
|
|
44439
|
-
properties:
|
|
44440
|
-
required:
|
|
44441
|
-
additionalProperties:
|
|
45107
|
+
var ToolInputSchemaSchema = z98.object({
|
|
45108
|
+
type: z98.string(),
|
|
45109
|
+
properties: z98.record(z98.string(), PropertySchemaSchema).optional(),
|
|
45110
|
+
required: z98.array(z98.string()).optional(),
|
|
45111
|
+
additionalProperties: z98.boolean().optional()
|
|
44442
45112
|
});
|
|
44443
|
-
var ToolDefinitionSchema =
|
|
44444
|
-
name:
|
|
44445
|
-
description:
|
|
45113
|
+
var ToolDefinitionSchema = z98.object({
|
|
45114
|
+
name: z98.string().min(1),
|
|
45115
|
+
description: z98.string(),
|
|
44446
45116
|
inputSchema: ToolInputSchemaSchema
|
|
44447
45117
|
});
|
|
44448
|
-
var AnalysisConfigurationSchema =
|
|
44449
|
-
includeLowSeverity:
|
|
44450
|
-
generateAllConstraints:
|
|
44451
|
-
checkInteractions:
|
|
44452
|
-
maxHazardsPerTool:
|
|
44453
|
-
categories:
|
|
45118
|
+
var AnalysisConfigurationSchema = z98.object({
|
|
45119
|
+
includeLowSeverity: z98.boolean().default(true),
|
|
45120
|
+
generateAllConstraints: z98.boolean().default(true),
|
|
45121
|
+
checkInteractions: z98.boolean().default(true),
|
|
45122
|
+
maxHazardsPerTool: z98.number().int().min(1).max(100).default(50),
|
|
45123
|
+
categories: z98.array(HazardCategorySchema).default([])
|
|
44454
45124
|
});
|
|
44455
|
-
var ConstraintViolationSchema =
|
|
44456
|
-
constraintId:
|
|
44457
|
-
constraintDescription:
|
|
45125
|
+
var ConstraintViolationSchema = z98.object({
|
|
45126
|
+
constraintId: z98.string().min(1),
|
|
45127
|
+
constraintDescription: z98.string(),
|
|
44458
45128
|
severity: HazardSeveritySchema,
|
|
44459
|
-
details:
|
|
44460
|
-
remediation:
|
|
45129
|
+
details: z98.string(),
|
|
45130
|
+
remediation: z98.string()
|
|
44461
45131
|
});
|
|
44462
|
-
var ValidationWarningSchema =
|
|
44463
|
-
code:
|
|
44464
|
-
message:
|
|
44465
|
-
affected:
|
|
45132
|
+
var ValidationWarningSchema = z98.object({
|
|
45133
|
+
code: z98.string().min(1),
|
|
45134
|
+
message: z98.string(),
|
|
45135
|
+
affected: z98.string()
|
|
44466
45136
|
});
|
|
44467
|
-
var ValidationResultSchema =
|
|
44468
|
-
valid:
|
|
44469
|
-
toolName:
|
|
44470
|
-
violations:
|
|
44471
|
-
passed:
|
|
44472
|
-
warnings:
|
|
44473
|
-
validatedAt:
|
|
45137
|
+
var ValidationResultSchema = z98.object({
|
|
45138
|
+
valid: z98.boolean(),
|
|
45139
|
+
toolName: z98.string().min(1),
|
|
45140
|
+
violations: z98.array(ConstraintViolationSchema),
|
|
45141
|
+
passed: z98.array(z98.string()),
|
|
45142
|
+
warnings: z98.array(ValidationWarningSchema),
|
|
45143
|
+
validatedAt: z98.date()
|
|
44474
45144
|
});
|
|
44475
45145
|
|
|
44476
45146
|
// src/mcp/safety/stpa-types.ts
|
|
@@ -45555,22 +46225,22 @@ var GeminiResponseParser = class {
|
|
|
45555
46225
|
};
|
|
45556
46226
|
|
|
45557
46227
|
// src/cli-adapters/task-analyzer.ts
|
|
45558
|
-
import { z as
|
|
45559
|
-
var TaskProfileSchema =
|
|
46228
|
+
import { z as z99 } from "zod";
|
|
46229
|
+
var TaskProfileSchema = z99.object({
|
|
45560
46230
|
/** Estimated input tokens required */
|
|
45561
|
-
contextRequired:
|
|
46231
|
+
contextRequired: z99.number().min(0),
|
|
45562
46232
|
/** Reasoning complexity on 0-10 scale */
|
|
45563
|
-
reasoningComplexity:
|
|
46233
|
+
reasoningComplexity: z99.number().min(0).max(10),
|
|
45564
46234
|
/** Whether task involves code generation */
|
|
45565
|
-
codeGeneration:
|
|
46235
|
+
codeGeneration: z99.boolean(),
|
|
45566
46236
|
/** Whether task involves multimodal content (images, etc.) */
|
|
45567
|
-
multimodal:
|
|
46237
|
+
multimodal: z99.boolean(),
|
|
45568
46238
|
/** Whether task can be split into parallel subtasks */
|
|
45569
|
-
parallelizable:
|
|
46239
|
+
parallelizable: z99.boolean(),
|
|
45570
46240
|
/** Whether cost should be minimized */
|
|
45571
|
-
budgetSensitive:
|
|
46241
|
+
budgetSensitive: z99.boolean(),
|
|
45572
46242
|
/** Primary task type classification */
|
|
45573
|
-
taskType:
|
|
46243
|
+
taskType: z99.enum([
|
|
45574
46244
|
"architecture",
|
|
45575
46245
|
"code_implementation",
|
|
45576
46246
|
"code_review",
|
|
@@ -45584,53 +46254,53 @@ var TaskProfileSchema = z96.object({
|
|
|
45584
46254
|
});
|
|
45585
46255
|
|
|
45586
46256
|
// src/cli-adapters/router-types.ts
|
|
45587
|
-
import { z as
|
|
45588
|
-
var RouterConfigSchema =
|
|
45589
|
-
minCapacityThreshold:
|
|
45590
|
-
preferCostEfficient:
|
|
45591
|
-
maxDecisionTimeMs:
|
|
46257
|
+
import { z as z100 } from "zod";
|
|
46258
|
+
var RouterConfigSchema = z100.object({
|
|
46259
|
+
minCapacityThreshold: z100.number().min(0).max(1).default(0.1),
|
|
46260
|
+
preferCostEfficient: z100.boolean().default(false),
|
|
46261
|
+
maxDecisionTimeMs: z100.number().min(1).max(1e3).default(100)
|
|
45592
46262
|
});
|
|
45593
46263
|
|
|
45594
46264
|
// src/cli-adapters/agreement-cascade-types.ts
|
|
45595
|
-
import { z as
|
|
45596
|
-
var AgreementCascadeConfigSchema =
|
|
45597
|
-
agreementThreshold:
|
|
45598
|
-
maxStages:
|
|
45599
|
-
modelTimeoutMs:
|
|
46265
|
+
import { z as z101 } from "zod";
|
|
46266
|
+
var AgreementCascadeConfigSchema = z101.object({
|
|
46267
|
+
agreementThreshold: z101.number().min(0.5).max(1).default(0.7),
|
|
46268
|
+
maxStages: z101.number().int().min(1).max(5).default(3),
|
|
46269
|
+
modelTimeoutMs: z101.number().int().min(1e3).max(3e5).default(6e4)
|
|
45600
46270
|
});
|
|
45601
46271
|
|
|
45602
46272
|
// src/cli-adapters/agreement-cascade-router.ts
|
|
45603
46273
|
var logger42 = createLogger({ component: "agreement-cascade-router" });
|
|
45604
46274
|
|
|
45605
46275
|
// src/cli-adapters/daao-types.ts
|
|
45606
|
-
import { z as
|
|
45607
|
-
var EncodedFeaturesSchema =
|
|
46276
|
+
import { z as z102 } from "zod";
|
|
46277
|
+
var EncodedFeaturesSchema = z102.object({
|
|
45608
46278
|
/** Lexical complexity score (vocabulary diversity, rare words) */
|
|
45609
|
-
lexicalComplexity:
|
|
46279
|
+
lexicalComplexity: z102.number().min(0).max(1),
|
|
45610
46280
|
/** Syntactic complexity score (sentence structure, nesting) */
|
|
45611
|
-
syntacticComplexity:
|
|
46281
|
+
syntacticComplexity: z102.number().min(0).max(1),
|
|
45612
46282
|
/** Semantic density score (concept density, abstraction level) */
|
|
45613
|
-
semanticDensity:
|
|
46283
|
+
semanticDensity: z102.number().min(0).max(1),
|
|
45614
46284
|
/** Technical specificity (domain-specific terminology) */
|
|
45615
|
-
technicalSpecificity:
|
|
46285
|
+
technicalSpecificity: z102.number().min(0).max(1),
|
|
45616
46286
|
/** Task scope (breadth of requirements) */
|
|
45617
|
-
taskScope:
|
|
46287
|
+
taskScope: z102.number().min(0).max(1),
|
|
45618
46288
|
/** Constraint complexity (constraints, edge cases, requirements) */
|
|
45619
|
-
constraintComplexity:
|
|
46289
|
+
constraintComplexity: z102.number().min(0).max(1),
|
|
45620
46290
|
/** Ambiguity level (inverse - higher means more clear/specific) */
|
|
45621
|
-
clarity:
|
|
46291
|
+
clarity: z102.number().min(0).max(1),
|
|
45622
46292
|
/** Output complexity expectation */
|
|
45623
|
-
outputComplexity:
|
|
46293
|
+
outputComplexity: z102.number().min(0).max(1)
|
|
45624
46294
|
});
|
|
45625
|
-
var FeatureWeightsSchema =
|
|
45626
|
-
lexicalComplexity:
|
|
45627
|
-
syntacticComplexity:
|
|
45628
|
-
semanticDensity:
|
|
45629
|
-
technicalSpecificity:
|
|
45630
|
-
taskScope:
|
|
45631
|
-
constraintComplexity:
|
|
45632
|
-
clarity:
|
|
45633
|
-
outputComplexity:
|
|
46295
|
+
var FeatureWeightsSchema = z102.object({
|
|
46296
|
+
lexicalComplexity: z102.number().min(0).max(1),
|
|
46297
|
+
syntacticComplexity: z102.number().min(0).max(1),
|
|
46298
|
+
semanticDensity: z102.number().min(0).max(1),
|
|
46299
|
+
technicalSpecificity: z102.number().min(0).max(1),
|
|
46300
|
+
taskScope: z102.number().min(0).max(1),
|
|
46301
|
+
constraintComplexity: z102.number().min(0).max(1),
|
|
46302
|
+
clarity: z102.number().min(0).max(1),
|
|
46303
|
+
outputComplexity: z102.number().min(0).max(1)
|
|
45634
46304
|
});
|
|
45635
46305
|
var DEFAULT_FEATURE_WEIGHTS = {
|
|
45636
46306
|
lexicalComplexity: 0.1,
|
|
@@ -45652,50 +46322,50 @@ var DEFAULT_DAAO_TIER_TO_CLIS = {
|
|
|
45652
46322
|
balanced: ["codex", "opencode", "gemini", "claude"],
|
|
45653
46323
|
powerful: ["claude", "codex", "opencode", "gemini"]
|
|
45654
46324
|
};
|
|
45655
|
-
var DAAOConfigSchema =
|
|
46325
|
+
var DAAOConfigSchema = z102.object({
|
|
45656
46326
|
/** Difficulty thresholds for level classification */
|
|
45657
|
-
thresholds:
|
|
45658
|
-
easyUpperBound:
|
|
45659
|
-
hardLowerBound:
|
|
46327
|
+
thresholds: z102.object({
|
|
46328
|
+
easyUpperBound: z102.number().min(0).max(1),
|
|
46329
|
+
hardLowerBound: z102.number().min(0).max(1)
|
|
45660
46330
|
}).default(DEFAULT_DAAO_THRESHOLDS),
|
|
45661
46331
|
/** Feature weights for difficulty aggregation */
|
|
45662
46332
|
weights: FeatureWeightsSchema.default(DEFAULT_FEATURE_WEIGHTS),
|
|
45663
46333
|
/** Mapping from model tier to CLI preference order */
|
|
45664
|
-
tierToClis:
|
|
45665
|
-
|
|
45666
|
-
|
|
46334
|
+
tierToClis: z102.record(
|
|
46335
|
+
z102.enum(["fast", "balanced", "powerful"]),
|
|
46336
|
+
z102.array(z102.enum(["claude", "gemini", "codex", "opencode"]))
|
|
45667
46337
|
).default(DEFAULT_DAAO_TIER_TO_CLIS),
|
|
45668
46338
|
/** Enable adaptive calibration from outcomes */
|
|
45669
|
-
enableCalibration:
|
|
46339
|
+
enableCalibration: z102.boolean().default(true),
|
|
45670
46340
|
/** Maximum outcomes to store for calibration */
|
|
45671
|
-
maxCalibrationOutcomes:
|
|
46341
|
+
maxCalibrationOutcomes: z102.number().int().positive().default(1e3),
|
|
45672
46342
|
/** Minimum outcomes before applying calibration adjustments */
|
|
45673
|
-
minCalibrationOutcomes:
|
|
46343
|
+
minCalibrationOutcomes: z102.number().int().positive().default(50),
|
|
45674
46344
|
/** Reconstruction error threshold for typical patterns */
|
|
45675
|
-
typicalPatternThreshold:
|
|
46345
|
+
typicalPatternThreshold: z102.number().min(0).max(1).default(0.3),
|
|
45676
46346
|
/** Verbose logging */
|
|
45677
|
-
verbose:
|
|
46347
|
+
verbose: z102.boolean().default(false)
|
|
45678
46348
|
});
|
|
45679
46349
|
|
|
45680
46350
|
// src/cli-adapters/task-classifier.ts
|
|
45681
|
-
import { z as
|
|
45682
|
-
var ClassificationPatternsSchema =
|
|
45683
|
-
code:
|
|
45684
|
-
research:
|
|
45685
|
-
documentation:
|
|
45686
|
-
analysis:
|
|
46351
|
+
import { z as z103 } from "zod";
|
|
46352
|
+
var ClassificationPatternsSchema = z103.object({
|
|
46353
|
+
code: z103.array(z103.string()).readonly(),
|
|
46354
|
+
research: z103.array(z103.string()).readonly(),
|
|
46355
|
+
documentation: z103.array(z103.string()).readonly(),
|
|
46356
|
+
analysis: z103.array(z103.string()).readonly()
|
|
45687
46357
|
});
|
|
45688
46358
|
|
|
45689
46359
|
// src/cli-adapters/response-cache-types.ts
|
|
45690
|
-
import { z as
|
|
45691
|
-
var ResponseCacheConfigSchema =
|
|
45692
|
-
defaultTTL:
|
|
46360
|
+
import { z as z104 } from "zod";
|
|
46361
|
+
var ResponseCacheConfigSchema = z104.object({
|
|
46362
|
+
defaultTTL: z104.number().min(1e3).max(36e5).default(3e5),
|
|
45693
46363
|
// 5 minutes
|
|
45694
|
-
maxEntries:
|
|
45695
|
-
maxMemoryMB:
|
|
45696
|
-
cleanupInterval:
|
|
46364
|
+
maxEntries: z104.number().min(10).max(1e5).default(1e3),
|
|
46365
|
+
maxMemoryMB: z104.number().min(1).max(1e3).default(50),
|
|
46366
|
+
cleanupInterval: z104.number().min(1e3).max(6e5).default(6e4),
|
|
45697
46367
|
// 1 minute
|
|
45698
|
-
enableLogging:
|
|
46368
|
+
enableLogging: z104.boolean().default(false)
|
|
45699
46369
|
});
|
|
45700
46370
|
|
|
45701
46371
|
// src/cli-adapters/response-cache-utils.ts
|
|
@@ -45703,12 +46373,12 @@ import { createHash as createHash4 } from "crypto";
|
|
|
45703
46373
|
var logger43 = createLogger({ component: "ResponseCacheUtils" });
|
|
45704
46374
|
|
|
45705
46375
|
// src/cli-adapters/unified-routing-types.ts
|
|
45706
|
-
import { z as
|
|
45707
|
-
var UnifiedRoutingDecisionSchema =
|
|
45708
|
-
selectedCli:
|
|
45709
|
-
confidence:
|
|
45710
|
-
reason:
|
|
45711
|
-
strategy:
|
|
46376
|
+
import { z as z105 } from "zod";
|
|
46377
|
+
var UnifiedRoutingDecisionSchema = z105.object({
|
|
46378
|
+
selectedCli: z105.string(),
|
|
46379
|
+
confidence: z105.number().min(0).max(1),
|
|
46380
|
+
reason: z105.string(),
|
|
46381
|
+
strategy: z105.enum([
|
|
45712
46382
|
"composite",
|
|
45713
46383
|
"quality",
|
|
45714
46384
|
"budget",
|
|
@@ -45720,57 +46390,57 @@ var UnifiedRoutingDecisionSchema = z102.object({
|
|
|
45720
46390
|
"linucb",
|
|
45721
46391
|
"direct"
|
|
45722
46392
|
]),
|
|
45723
|
-
decisionTimeMs:
|
|
45724
|
-
alternatives:
|
|
45725
|
-
stagesExecuted:
|
|
45726
|
-
withinBudget:
|
|
45727
|
-
estimatedComplexity:
|
|
45728
|
-
estimatedTokens:
|
|
45729
|
-
topsisScore:
|
|
45730
|
-
ucbScore:
|
|
45731
|
-
resolvedAtStage:
|
|
45732
|
-
consensusReached:
|
|
45733
|
-
agreementScore:
|
|
45734
|
-
metadata:
|
|
46393
|
+
decisionTimeMs: z105.number().nonnegative(),
|
|
46394
|
+
alternatives: z105.array(z105.string()).readonly(),
|
|
46395
|
+
stagesExecuted: z105.array(z105.string()).readonly(),
|
|
46396
|
+
withinBudget: z105.boolean().optional(),
|
|
46397
|
+
estimatedComplexity: z105.enum(["simple", "moderate", "complex", "expert"]).optional(),
|
|
46398
|
+
estimatedTokens: z105.number().int().positive().optional(),
|
|
46399
|
+
topsisScore: z105.number().optional(),
|
|
46400
|
+
ucbScore: z105.number().optional(),
|
|
46401
|
+
resolvedAtStage: z105.number().int().nonnegative().optional(),
|
|
46402
|
+
consensusReached: z105.boolean().optional(),
|
|
46403
|
+
agreementScore: z105.number().min(0).max(1).optional(),
|
|
46404
|
+
metadata: z105.record(z105.string(), z105.unknown()).optional()
|
|
45735
46405
|
});
|
|
45736
46406
|
|
|
45737
46407
|
// src/learning/outcome-feedback-types.ts
|
|
45738
|
-
import { z as
|
|
45739
|
-
var QualitySignalsSchema =
|
|
45740
|
-
testsPass:
|
|
45741
|
-
lintErrors:
|
|
45742
|
-
userApproved:
|
|
45743
|
-
retryCount:
|
|
45744
|
-
completionRatio:
|
|
45745
|
-
validStructure:
|
|
45746
|
-
coherenceScore:
|
|
46408
|
+
import { z as z106 } from "zod";
|
|
46409
|
+
var QualitySignalsSchema = z106.object({
|
|
46410
|
+
testsPass: z106.boolean().optional(),
|
|
46411
|
+
lintErrors: z106.number().int().min(0).optional(),
|
|
46412
|
+
userApproved: z106.boolean().optional(),
|
|
46413
|
+
retryCount: z106.number().int().min(0).default(0),
|
|
46414
|
+
completionRatio: z106.number().min(0).max(1).default(1),
|
|
46415
|
+
validStructure: z106.boolean().optional(),
|
|
46416
|
+
coherenceScore: z106.number().min(0).max(1).optional()
|
|
45747
46417
|
});
|
|
45748
|
-
var RoutingDecisionSchema =
|
|
45749
|
-
id:
|
|
45750
|
-
timestamp:
|
|
45751
|
-
query:
|
|
45752
|
-
routerType:
|
|
45753
|
-
selectedModel:
|
|
45754
|
-
selectedTier:
|
|
45755
|
-
armIndex:
|
|
45756
|
-
banditContext:
|
|
45757
|
-
queryFeatures:
|
|
45758
|
-
ucbScore:
|
|
45759
|
-
confidence:
|
|
45760
|
-
traceId:
|
|
45761
|
-
domain:
|
|
46418
|
+
var RoutingDecisionSchema = z106.object({
|
|
46419
|
+
id: z106.uuid(),
|
|
46420
|
+
timestamp: z106.iso.datetime(),
|
|
46421
|
+
query: z106.string(),
|
|
46422
|
+
routerType: z106.enum(["linucb", "preference", "quality", "cascade", "topsis"]),
|
|
46423
|
+
selectedModel: z106.string(),
|
|
46424
|
+
selectedTier: z106.enum(["strong", "weak"]).optional(),
|
|
46425
|
+
armIndex: z106.number().int().min(0).optional(),
|
|
46426
|
+
banditContext: z106.record(z106.string(), z106.unknown()).optional(),
|
|
46427
|
+
queryFeatures: z106.record(z106.string(), z106.unknown()).optional(),
|
|
46428
|
+
ucbScore: z106.number().optional(),
|
|
46429
|
+
confidence: z106.number().min(0).max(1).optional(),
|
|
46430
|
+
traceId: z106.string(),
|
|
46431
|
+
domain: z106.string().optional()
|
|
45762
46432
|
});
|
|
45763
|
-
var TaskOutcomeSchema =
|
|
45764
|
-
routingDecisionId:
|
|
45765
|
-
timestamp:
|
|
45766
|
-
outcomeClass:
|
|
45767
|
-
success:
|
|
45768
|
-
qualityScore:
|
|
45769
|
-
durationMs:
|
|
45770
|
-
tokenUsage:
|
|
45771
|
-
errorMessage:
|
|
46433
|
+
var TaskOutcomeSchema = z106.object({
|
|
46434
|
+
routingDecisionId: z106.uuid(),
|
|
46435
|
+
timestamp: z106.iso.datetime(),
|
|
46436
|
+
outcomeClass: z106.enum(["success", "partial", "failure", "timeout", "error"]),
|
|
46437
|
+
success: z106.boolean(),
|
|
46438
|
+
qualityScore: z106.number().min(0).max(1),
|
|
46439
|
+
durationMs: z106.number().min(0),
|
|
46440
|
+
tokenUsage: z106.number().int().min(0),
|
|
46441
|
+
errorMessage: z106.string().optional(),
|
|
45772
46442
|
qualitySignals: QualitySignalsSchema,
|
|
45773
|
-
traceId:
|
|
46443
|
+
traceId: z106.string()
|
|
45774
46444
|
});
|
|
45775
46445
|
var DEFAULT_FEEDBACK_COLLECTOR_CONFIG = {
|
|
45776
46446
|
maxPendingDecisions: 1e3,
|
|
@@ -45785,17 +46455,17 @@ var DEFAULT_FEEDBACK_COLLECTOR_CONFIG = {
|
|
|
45785
46455
|
targetTokenUsage: 2e3,
|
|
45786
46456
|
maxHistorySize: 1e4
|
|
45787
46457
|
};
|
|
45788
|
-
var FeedbackCollectorConfigSchema =
|
|
45789
|
-
maxPendingDecisions:
|
|
45790
|
-
pendingTimeoutMs:
|
|
45791
|
-
enableAutoReward:
|
|
45792
|
-
qualityWeight:
|
|
45793
|
-
speedWeight:
|
|
45794
|
-
efficiencyWeight:
|
|
45795
|
-
retryPenalty:
|
|
45796
|
-
targetDurationMs:
|
|
45797
|
-
targetTokenUsage:
|
|
45798
|
-
maxHistorySize:
|
|
46458
|
+
var FeedbackCollectorConfigSchema = z106.object({
|
|
46459
|
+
maxPendingDecisions: z106.number().int().positive().default(1e3),
|
|
46460
|
+
pendingTimeoutMs: z106.number().positive().default(3e5),
|
|
46461
|
+
enableAutoReward: z106.boolean().default(true),
|
|
46462
|
+
qualityWeight: z106.number().min(0).max(1).default(0.5),
|
|
46463
|
+
speedWeight: z106.number().min(0).max(1).default(0.2),
|
|
46464
|
+
efficiencyWeight: z106.number().min(0).max(1).default(0.2),
|
|
46465
|
+
retryPenalty: z106.number().min(0).max(1).default(0.1),
|
|
46466
|
+
targetDurationMs: z106.number().positive().default(5e3),
|
|
46467
|
+
targetTokenUsage: z106.number().positive().default(2e3),
|
|
46468
|
+
maxHistorySize: z106.number().int().positive().default(1e4)
|
|
45799
46469
|
});
|
|
45800
46470
|
|
|
45801
46471
|
// src/learning/outcome-feedback-helpers.ts
|
|
@@ -46859,7 +47529,7 @@ function getPolicy(id) {
|
|
|
46859
47529
|
// src/security/sandbox/sandbox-executor.ts
|
|
46860
47530
|
import { execFile as execFile2 } from "child_process";
|
|
46861
47531
|
import { promisify as promisify2 } from "util";
|
|
46862
|
-
import { resolve as
|
|
47532
|
+
import { resolve as resolve17, normalize as normalize2, sep as sep6 } from "path";
|
|
46863
47533
|
var execFileAsync2 = promisify2(execFile2);
|
|
46864
47534
|
var logger45 = createLogger({ component: "sandbox-executor" });
|
|
46865
47535
|
function parseExecError(error) {
|
|
@@ -46939,9 +47609,9 @@ var PolicySandboxExecutor = class {
|
|
|
46939
47609
|
*/
|
|
46940
47610
|
validateCwd(cwd, policy) {
|
|
46941
47611
|
if (cwd === void 0) return null;
|
|
46942
|
-
const normalizedCwd = normalize2(
|
|
47612
|
+
const normalizedCwd = normalize2(resolve17(cwd));
|
|
46943
47613
|
const isAllowed = policy.pathRules.some((rule) => {
|
|
46944
|
-
const normalizedRule = normalize2(
|
|
47614
|
+
const normalizedRule = normalize2(resolve17(rule.path));
|
|
46945
47615
|
const isUnderRule = normalizedCwd === normalizedRule || normalizedCwd.startsWith(normalizedRule + sep6);
|
|
46946
47616
|
return isUnderRule && rule.access !== "none";
|
|
46947
47617
|
});
|
|
@@ -47808,10 +48478,10 @@ var PredictionWriter = class {
|
|
|
47808
48478
|
* Opens the output file for writing.
|
|
47809
48479
|
*/
|
|
47810
48480
|
async open() {
|
|
47811
|
-
const
|
|
48481
|
+
const fs21 = await import("fs/promises");
|
|
47812
48482
|
try {
|
|
47813
48483
|
const flags = this.options.append ? "a" : "w";
|
|
47814
|
-
this.fileHandle = await
|
|
48484
|
+
this.fileHandle = await fs21.open(this.options.outputPath, flags);
|
|
47815
48485
|
return { ok: true, value: void 0 };
|
|
47816
48486
|
} catch (err2) {
|
|
47817
48487
|
return {
|
|
@@ -47885,11 +48555,11 @@ var PredictionWriter = class {
|
|
|
47885
48555
|
}
|
|
47886
48556
|
};
|
|
47887
48557
|
async function writePredictions(predictions, outputPath, options = {}) {
|
|
47888
|
-
const
|
|
48558
|
+
const fs21 = await import("fs/promises");
|
|
47889
48559
|
try {
|
|
47890
48560
|
const lines = predictions.map(formatPrediction).join("\n") + "\n";
|
|
47891
48561
|
const flags = options.append === true ? "a" : "w";
|
|
47892
|
-
await
|
|
48562
|
+
await fs21.writeFile(outputPath, lines, { flag: flags });
|
|
47893
48563
|
return { ok: true, value: predictions.length };
|
|
47894
48564
|
} catch (err2) {
|
|
47895
48565
|
return {
|
|
@@ -47914,9 +48584,9 @@ function parsePredictionLine(line) {
|
|
|
47914
48584
|
}
|
|
47915
48585
|
}
|
|
47916
48586
|
async function readPredictions(inputPath) {
|
|
47917
|
-
const
|
|
48587
|
+
const fs21 = await import("fs/promises");
|
|
47918
48588
|
try {
|
|
47919
|
-
const content = await
|
|
48589
|
+
const content = await fs21.readFile(inputPath, "utf-8");
|
|
47920
48590
|
const lines = content.trim().split("\n").filter(Boolean);
|
|
47921
48591
|
const predictions = [];
|
|
47922
48592
|
for (const line of lines) {
|
|
@@ -48189,13 +48859,13 @@ function createEmptyContext() {
|
|
|
48189
48859
|
approachHistory: []
|
|
48190
48860
|
};
|
|
48191
48861
|
}
|
|
48192
|
-
function assignRelevance(
|
|
48862
|
+
function assignRelevance(path20, response) {
|
|
48193
48863
|
const lowerResponse = response.toLowerCase();
|
|
48194
|
-
const lowerPath =
|
|
48864
|
+
const lowerPath = path20.toLowerCase();
|
|
48195
48865
|
const idx = lowerResponse.indexOf(lowerPath);
|
|
48196
48866
|
if (idx === -1) return "low";
|
|
48197
48867
|
const surroundStart = Math.max(0, idx - 100);
|
|
48198
|
-
const surroundEnd = Math.min(lowerResponse.length, idx +
|
|
48868
|
+
const surroundEnd = Math.min(lowerResponse.length, idx + path20.length + 100);
|
|
48199
48869
|
const surrounding = lowerResponse.slice(surroundStart, surroundEnd);
|
|
48200
48870
|
if (/(?:root cause|bug|fix|patch|change|modify|edit)/i.test(surrounding)) {
|
|
48201
48871
|
return "high";
|
|
@@ -48338,10 +49008,10 @@ var GIT_TIMEOUT_MS = 3e5;
|
|
|
48338
49008
|
var SAFE_COMMIT_RE = /^[0-9a-f]{7,40}$/i;
|
|
48339
49009
|
var SAFE_REPO_RE = /^[a-zA-Z0-9_.-]+\/[a-zA-Z0-9_.-]+$/;
|
|
48340
49010
|
async function tryExistingClone(repoDir, commit, exec5) {
|
|
48341
|
-
const
|
|
48342
|
-
const
|
|
49011
|
+
const fs21 = await import("fs/promises");
|
|
49012
|
+
const path20 = await import("path");
|
|
48343
49013
|
try {
|
|
48344
|
-
await
|
|
49014
|
+
await fs21.access(path20.join(repoDir, ".git"));
|
|
48345
49015
|
await exec5(`git checkout -- .`, { cwd: repoDir, timeout: GIT_TIMEOUT_MS });
|
|
48346
49016
|
await exec5(`git clean -fd`, { cwd: repoDir, timeout: GIT_TIMEOUT_MS });
|
|
48347
49017
|
try {
|
|
@@ -48360,8 +49030,8 @@ async function tryExistingClone(repoDir, commit, exec5) {
|
|
|
48360
49030
|
}
|
|
48361
49031
|
}
|
|
48362
49032
|
async function cloneRepository(repo, commit, workDir) {
|
|
48363
|
-
const
|
|
48364
|
-
const
|
|
49033
|
+
const path20 = await import("path");
|
|
49034
|
+
const fs21 = await import("fs/promises");
|
|
48365
49035
|
const childProcess = await import("child_process");
|
|
48366
49036
|
const { promisify: promisify9 } = await import("util");
|
|
48367
49037
|
const exec5 = promisify9(childProcess.exec);
|
|
@@ -48371,9 +49041,9 @@ async function cloneRepository(repo, commit, workDir) {
|
|
|
48371
49041
|
if (!SAFE_COMMIT_RE.test(commit)) {
|
|
48372
49042
|
return { ok: false, error: new AgentRunnerError(`Invalid commit hash: ${commit}`) };
|
|
48373
49043
|
}
|
|
48374
|
-
const repoDir =
|
|
49044
|
+
const repoDir = path20.join(workDir, repo.replaceAll("/", "__"));
|
|
48375
49045
|
try {
|
|
48376
|
-
await
|
|
49046
|
+
await fs21.mkdir(workDir, { recursive: true });
|
|
48377
49047
|
const cloned = await tryExistingClone(repoDir, commit, exec5);
|
|
48378
49048
|
if (cloned) return { ok: true, value: repoDir };
|
|
48379
49049
|
await exec5(`git clone --filter=blob:none --no-tags https://github.com/${repo}.git ${repoDir}`, {
|
|
@@ -48389,19 +49059,19 @@ async function applyPatch(repoDir, patch) {
|
|
|
48389
49059
|
const childProcess = await import("child_process");
|
|
48390
49060
|
const { promisify: promisify9 } = await import("util");
|
|
48391
49061
|
const exec5 = promisify9(childProcess.exec);
|
|
48392
|
-
const
|
|
48393
|
-
const
|
|
48394
|
-
const patchFile =
|
|
49062
|
+
const fs21 = await import("fs/promises");
|
|
49063
|
+
const path20 = await import("path");
|
|
49064
|
+
const patchFile = path20.join(repoDir, ".agent_patch.diff");
|
|
48395
49065
|
try {
|
|
48396
|
-
await
|
|
49066
|
+
await fs21.writeFile(patchFile, patch);
|
|
48397
49067
|
await exec5(`git apply --whitespace=fix ${patchFile}`, {
|
|
48398
49068
|
cwd: repoDir,
|
|
48399
49069
|
timeout: GIT_TIMEOUT_MS
|
|
48400
49070
|
});
|
|
48401
|
-
await
|
|
49071
|
+
await fs21.unlink(patchFile);
|
|
48402
49072
|
return { ok: true, value: void 0 };
|
|
48403
49073
|
} catch (err2) {
|
|
48404
|
-
await
|
|
49074
|
+
await fs21.unlink(patchFile).catch((e) => {
|
|
48405
49075
|
logger50.debug("Failed to clean up patch file", {
|
|
48406
49076
|
error: e instanceof Error ? e.message : String(e)
|
|
48407
49077
|
});
|
|
@@ -49425,7 +50095,7 @@ async function getDockerVersion(logger56) {
|
|
|
49425
50095
|
}
|
|
49426
50096
|
|
|
49427
50097
|
// src/swe-bench/harness-output-parsing.ts
|
|
49428
|
-
import * as
|
|
50098
|
+
import * as fs14 from "fs/promises";
|
|
49429
50099
|
function parseHarnessOutput(output2, logger56) {
|
|
49430
50100
|
try {
|
|
49431
50101
|
const parsed = JSON.parse(output2);
|
|
@@ -49446,7 +50116,7 @@ function isValidHarnessOutput(obj) {
|
|
|
49446
50116
|
}
|
|
49447
50117
|
async function parseHarnessLogFile(logPath, logger56) {
|
|
49448
50118
|
try {
|
|
49449
|
-
const content = await
|
|
50119
|
+
const content = await fs14.readFile(logPath, "utf-8");
|
|
49450
50120
|
return parseHarnessOutput(content, logger56);
|
|
49451
50121
|
} catch (err2) {
|
|
49452
50122
|
logger56?.warn("Failed to read harness log file", { logPath, error: String(err2) });
|
|
@@ -49528,8 +50198,8 @@ function transformHarnessOutput(raw) {
|
|
|
49528
50198
|
|
|
49529
50199
|
// src/swe-bench/harness-file-operations.ts
|
|
49530
50200
|
import { spawn } from "child_process";
|
|
49531
|
-
import * as
|
|
49532
|
-
import * as
|
|
50201
|
+
import * as fs15 from "fs/promises";
|
|
50202
|
+
import * as path13 from "path";
|
|
49533
50203
|
var capitalizeFirst = capitalize;
|
|
49534
50204
|
function buildHarnessArgs(config) {
|
|
49535
50205
|
const args = [
|
|
@@ -49571,11 +50241,11 @@ function countValidPredictions(content) {
|
|
|
49571
50241
|
}
|
|
49572
50242
|
async function validatePredictionsFile(predictionsPath, logger56) {
|
|
49573
50243
|
try {
|
|
49574
|
-
const stat6 = await
|
|
50244
|
+
const stat6 = await fs15.stat(predictionsPath);
|
|
49575
50245
|
if (!stat6.isFile()) {
|
|
49576
50246
|
return { valid: false, lineCount: 0, error: "Path is not a file" };
|
|
49577
50247
|
}
|
|
49578
|
-
const content = await
|
|
50248
|
+
const content = await fs15.readFile(predictionsPath, "utf-8");
|
|
49579
50249
|
const validCount = countValidPredictions(content);
|
|
49580
50250
|
if (validCount === 0) {
|
|
49581
50251
|
return { valid: false, lineCount: 0, error: "No valid predictions found" };
|
|
@@ -49589,7 +50259,7 @@ async function validatePredictionsFile(predictionsPath, logger56) {
|
|
|
49589
50259
|
}
|
|
49590
50260
|
async function ensureOutputDir(outputDir, logger56) {
|
|
49591
50261
|
try {
|
|
49592
|
-
await
|
|
50262
|
+
await fs15.mkdir(outputDir, { recursive: true });
|
|
49593
50263
|
logger56?.debug("Output directory ensured", { path: outputDir });
|
|
49594
50264
|
} catch (err2) {
|
|
49595
50265
|
logger56?.warn("Failed to create output directory", { path: outputDir, error: String(err2) });
|
|
@@ -49626,7 +50296,7 @@ function createInitialProgress(totalCount) {
|
|
|
49626
50296
|
};
|
|
49627
50297
|
}
|
|
49628
50298
|
function getResultsFilePath(config) {
|
|
49629
|
-
return
|
|
50299
|
+
return path13.join(config.outputDir, config.runId, "results.json");
|
|
49630
50300
|
}
|
|
49631
50301
|
|
|
49632
50302
|
// src/swe-bench/harness-process-runner.ts
|
|
@@ -49676,13 +50346,13 @@ function handleStdoutChunk(chunk, currentProgress, startTime, onProgress) {
|
|
|
49676
50346
|
}
|
|
49677
50347
|
}
|
|
49678
50348
|
function handleProcessClose(options) {
|
|
49679
|
-
const { code, config, stderr, context, resolve:
|
|
50349
|
+
const { code, config, stderr, context, resolve: resolve19, reject } = options;
|
|
49680
50350
|
if (context.isCancelled) {
|
|
49681
50351
|
reject(new HarnessExecutorError("Execution cancelled", "CANCELLED"));
|
|
49682
50352
|
return;
|
|
49683
50353
|
}
|
|
49684
50354
|
handleProcessExitAsync(code, config, stderr, context.logger).then((result) => {
|
|
49685
|
-
|
|
50355
|
+
resolve19(result);
|
|
49686
50356
|
}).catch((err2) => {
|
|
49687
50357
|
if (err2 instanceof HarnessExecutorError) {
|
|
49688
50358
|
reject(err2);
|
|
@@ -49723,7 +50393,7 @@ async function parseResultsFile(config, logger56) {
|
|
|
49723
50393
|
};
|
|
49724
50394
|
}
|
|
49725
50395
|
function runHarnessProcess(config, totalInstances, context, onProgress) {
|
|
49726
|
-
return new Promise((
|
|
50396
|
+
return new Promise((resolve19, reject) => {
|
|
49727
50397
|
const startTime = performance.now();
|
|
49728
50398
|
let progress = createInitialProgress(totalInstances);
|
|
49729
50399
|
progress = { ...progress, state: "starting" };
|
|
@@ -49745,7 +50415,7 @@ function runHarnessProcess(config, totalInstances, context, onProgress) {
|
|
|
49745
50415
|
config,
|
|
49746
50416
|
stderr: stderrCollector.value,
|
|
49747
50417
|
context,
|
|
49748
|
-
resolve:
|
|
50418
|
+
resolve: resolve19,
|
|
49749
50419
|
reject
|
|
49750
50420
|
});
|
|
49751
50421
|
});
|
|
@@ -49899,7 +50569,7 @@ var HarnessExecutor = class {
|
|
|
49899
50569
|
const proc = this.currentProcess;
|
|
49900
50570
|
if (proc !== null) {
|
|
49901
50571
|
proc.kill("SIGTERM");
|
|
49902
|
-
await new Promise((
|
|
50572
|
+
await new Promise((resolve19) => setTimeout(resolve19, 1e3));
|
|
49903
50573
|
if (!proc.killed) {
|
|
49904
50574
|
proc.kill("SIGKILL");
|
|
49905
50575
|
}
|
|
@@ -51021,8 +51691,8 @@ var SWEBenchRunner = class {
|
|
|
51021
51691
|
return { ok: true, value: null };
|
|
51022
51692
|
}
|
|
51023
51693
|
try {
|
|
51024
|
-
const
|
|
51025
|
-
const content = await
|
|
51694
|
+
const fs21 = await import("fs/promises");
|
|
51695
|
+
const content = await fs21.readFile(this.config.checkpointPath, "utf-8");
|
|
51026
51696
|
const checkpoint = JSON.parse(content);
|
|
51027
51697
|
this.config.onMessage?.(
|
|
51028
51698
|
`Resuming from checkpoint: ${String(checkpoint.completed_instances.length)} completed`
|
|
@@ -51051,8 +51721,8 @@ var SWEBenchRunner = class {
|
|
|
51051
51721
|
last_updated: getTimeProvider().nowIso()
|
|
51052
51722
|
};
|
|
51053
51723
|
try {
|
|
51054
|
-
const
|
|
51055
|
-
await
|
|
51724
|
+
const fs21 = await import("fs/promises");
|
|
51725
|
+
await fs21.writeFile(this.config.checkpointPath, JSON.stringify(checkpoint, null, 2));
|
|
51056
51726
|
return { ok: true, value: void 0 };
|
|
51057
51727
|
} catch (err2) {
|
|
51058
51728
|
return {
|
|
@@ -51363,18 +52033,18 @@ function parsePatch(patch) {
|
|
|
51363
52033
|
// src/swe-bench/patch-applicator-executor.ts
|
|
51364
52034
|
import { execFile as execFile5 } from "child_process";
|
|
51365
52035
|
import { promisify as promisify7 } from "util";
|
|
51366
|
-
import * as
|
|
51367
|
-
import * as
|
|
52036
|
+
import * as fs16 from "fs/promises";
|
|
52037
|
+
import * as path14 from "path";
|
|
51368
52038
|
var execFileAsync5 = promisify7(execFile5);
|
|
51369
52039
|
var MAX_OUTPUT_BUFFER = 5 * 1024 * 1024;
|
|
51370
52040
|
async function writeTempPatch(patch, workDir) {
|
|
51371
|
-
const tempPath =
|
|
51372
|
-
await
|
|
52041
|
+
const tempPath = path14.join(workDir, `.patch-${String(getTimeProvider().now())}.patch`);
|
|
52042
|
+
await fs16.writeFile(tempPath, patch, "utf-8");
|
|
51373
52043
|
return tempPath;
|
|
51374
52044
|
}
|
|
51375
52045
|
async function cleanupTempFile(patchPath) {
|
|
51376
52046
|
try {
|
|
51377
|
-
await
|
|
52047
|
+
await fs16.unlink(patchPath);
|
|
51378
52048
|
} catch (cleanupErr) {
|
|
51379
52049
|
void cleanupErr;
|
|
51380
52050
|
}
|
|
@@ -51618,12 +52288,12 @@ var TestRunnerError = class extends Error {
|
|
|
51618
52288
|
};
|
|
51619
52289
|
|
|
51620
52290
|
// src/swe-bench/test-runner-parser.ts
|
|
51621
|
-
import * as
|
|
51622
|
-
import * as
|
|
52291
|
+
import * as fs17 from "fs/promises";
|
|
52292
|
+
import * as path15 from "path";
|
|
51623
52293
|
async function readJsonResults(workDir) {
|
|
51624
|
-
const jsonPath =
|
|
52294
|
+
const jsonPath = path15.join(workDir, "test-results.json");
|
|
51625
52295
|
try {
|
|
51626
|
-
const content = await
|
|
52296
|
+
const content = await fs17.readFile(jsonPath, "utf-8");
|
|
51627
52297
|
return JSON.parse(content);
|
|
51628
52298
|
} catch {
|
|
51629
52299
|
return null;
|
|
@@ -51784,7 +52454,7 @@ function executeInDocker(options) {
|
|
|
51784
52454
|
const image = config.dockerImage ?? "python:3.11-slim";
|
|
51785
52455
|
logger56.debug("Executing tests in Docker", { image, command });
|
|
51786
52456
|
const dockerArgs = buildDockerArgs(command, config, image);
|
|
51787
|
-
return new Promise((
|
|
52457
|
+
return new Promise((resolve19) => {
|
|
51788
52458
|
const proc = spawn2("docker", dockerArgs, {
|
|
51789
52459
|
stdio: ["ignore", "pipe", "pipe"]
|
|
51790
52460
|
});
|
|
@@ -51797,17 +52467,17 @@ function executeInDocker(options) {
|
|
|
51797
52467
|
clearTimeout(timeoutId);
|
|
51798
52468
|
state.currentProcess = null;
|
|
51799
52469
|
if (state.isCancelled) {
|
|
51800
|
-
|
|
52470
|
+
resolve19(createCancelledResult2(startTime));
|
|
51801
52471
|
return;
|
|
51802
52472
|
}
|
|
51803
52473
|
const output2 = `${getStdout()}
|
|
51804
52474
|
${getStderr()}`.trim();
|
|
51805
|
-
void parseTestResults(output2, startTime, config.workDir).then(
|
|
52475
|
+
void parseTestResults(output2, startTime, config.workDir).then(resolve19);
|
|
51806
52476
|
});
|
|
51807
52477
|
proc.on("error", (err2) => {
|
|
51808
52478
|
clearTimeout(timeoutId);
|
|
51809
52479
|
state.currentProcess = null;
|
|
51810
|
-
|
|
52480
|
+
resolve19(handleTestError(err2, startTime));
|
|
51811
52481
|
});
|
|
51812
52482
|
});
|
|
51813
52483
|
}
|
|
@@ -51815,8 +52485,8 @@ ${getStderr()}`.trim();
|
|
|
51815
52485
|
// src/swe-bench/test-runner.ts
|
|
51816
52486
|
import { exec as exec3 } from "child_process";
|
|
51817
52487
|
import { promisify as promisify8 } from "util";
|
|
51818
|
-
import * as
|
|
51819
|
-
import * as
|
|
52488
|
+
import * as fs18 from "fs/promises";
|
|
52489
|
+
import * as path16 from "path";
|
|
51820
52490
|
var execAsync3 = promisify8(exec3);
|
|
51821
52491
|
var FRAMEWORK_CONFIG_FILES = {
|
|
51822
52492
|
pytest: ["pytest.ini", "pyproject.toml", "setup.cfg", "conftest.py", "tox.ini"],
|
|
@@ -51922,9 +52592,9 @@ var TestRunner = class {
|
|
|
51922
52592
|
async findConfigFiles(workDir, configFiles) {
|
|
51923
52593
|
const found = [];
|
|
51924
52594
|
for (const file of configFiles) {
|
|
51925
|
-
const filePath =
|
|
52595
|
+
const filePath = path16.join(workDir, file);
|
|
51926
52596
|
try {
|
|
51927
|
-
await
|
|
52597
|
+
await fs18.access(filePath);
|
|
51928
52598
|
found.push(file);
|
|
51929
52599
|
} catch (accessErr) {
|
|
51930
52600
|
void accessErr;
|
|
@@ -52074,8 +52744,8 @@ async function detectTestFramework(workDir) {
|
|
|
52074
52744
|
}
|
|
52075
52745
|
|
|
52076
52746
|
// src/swe-bench/report-generator.ts
|
|
52077
|
-
import * as
|
|
52078
|
-
import * as
|
|
52747
|
+
import * as fs19 from "fs/promises";
|
|
52748
|
+
import * as path17 from "path";
|
|
52079
52749
|
|
|
52080
52750
|
// src/swe-bench/report-renderer.ts
|
|
52081
52751
|
function renderReport(report, format) {
|
|
@@ -52431,8 +53101,8 @@ var ReportGenerator = class {
|
|
|
52431
53101
|
async save(report, config) {
|
|
52432
53102
|
this.logger.info("Saving report", { outputPath: config.outputPath });
|
|
52433
53103
|
const content = await this.render(report, config.format);
|
|
52434
|
-
await
|
|
52435
|
-
await
|
|
53104
|
+
await fs19.mkdir(path17.dirname(config.outputPath), { recursive: true });
|
|
53105
|
+
await fs19.writeFile(config.outputPath, content, "utf-8");
|
|
52436
53106
|
this.logger.info("Report saved", { path: config.outputPath, format: config.format });
|
|
52437
53107
|
}
|
|
52438
53108
|
/**
|
|
@@ -52651,14 +53321,14 @@ async function exportReport(result, outputPath, config) {
|
|
|
52651
53321
|
|
|
52652
53322
|
// src/swe-bench/trace-logger.ts
|
|
52653
53323
|
import { appendFile, writeFile as writeFile6 } from "fs/promises";
|
|
52654
|
-
import * as
|
|
53324
|
+
import * as path18 from "path";
|
|
52655
53325
|
function deriveTracePath(outputPath) {
|
|
52656
|
-
const ext =
|
|
53326
|
+
const ext = path18.extname(outputPath);
|
|
52657
53327
|
const base = outputPath.slice(0, outputPath.length - ext.length);
|
|
52658
53328
|
return `${base}-trace.jsonl`;
|
|
52659
53329
|
}
|
|
52660
53330
|
function deriveStatusPath(outputPath) {
|
|
52661
|
-
const ext =
|
|
53331
|
+
const ext = path18.extname(outputPath);
|
|
52662
53332
|
const base = outputPath.slice(0, outputPath.length - ext.length);
|
|
52663
53333
|
return `${base}-status.json`;
|
|
52664
53334
|
}
|
|
@@ -52863,8 +53533,8 @@ function getStdinLifecycleMonitor() {
|
|
|
52863
53533
|
}
|
|
52864
53534
|
|
|
52865
53535
|
// src/pipeline/task-tracker.ts
|
|
52866
|
-
import * as
|
|
52867
|
-
import * as
|
|
53536
|
+
import * as fs20 from "fs";
|
|
53537
|
+
import * as path19 from "path";
|
|
52868
53538
|
var logger55 = createLogger({ component: "task-tracker" });
|
|
52869
53539
|
async function exec4(cmd, args, timeout = 15e3) {
|
|
52870
53540
|
const { execFile: execFile6 } = await import("child_process");
|
|
@@ -52942,8 +53612,8 @@ var JsonTaskTracker = class {
|
|
|
52942
53612
|
outputPath;
|
|
52943
53613
|
constructor(config) {
|
|
52944
53614
|
const dir = config.outputDir ?? ".nexus-pipeline";
|
|
52945
|
-
this.outputPath =
|
|
52946
|
-
|
|
53615
|
+
this.outputPath = path19.resolve(dir, "tasks.json");
|
|
53616
|
+
fs20.mkdirSync(path19.dirname(this.outputPath), { recursive: true });
|
|
52947
53617
|
}
|
|
52948
53618
|
async createTask(title, body) {
|
|
52949
53619
|
const id = String(this.nextId++);
|
|
@@ -52975,7 +53645,7 @@ var JsonTaskTracker = class {
|
|
|
52975
53645
|
comments: Object.fromEntries(this.comments),
|
|
52976
53646
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
52977
53647
|
};
|
|
52978
|
-
|
|
53648
|
+
fs20.writeFileSync(this.outputPath, JSON.stringify(data, null, 2));
|
|
52979
53649
|
}
|
|
52980
53650
|
};
|
|
52981
53651
|
async function detectBackend() {
|
|
@@ -53449,6 +54119,9 @@ export {
|
|
|
53449
54119
|
registerResearchAddTool,
|
|
53450
54120
|
ResearchAddSourceInputSchema,
|
|
53451
54121
|
registerResearchAddSourceTool,
|
|
54122
|
+
registerSurveyOssLandscapeTool,
|
|
54123
|
+
registerVendorPublishingAuditTool,
|
|
54124
|
+
registerCompareDataFeedsTool,
|
|
53452
54125
|
ResearchDiscoverInputSchema,
|
|
53453
54126
|
registerResearchDiscoverTool,
|
|
53454
54127
|
ResearchAnalyzeInputSchema,
|
|
@@ -53703,4 +54376,4 @@ export {
|
|
|
53703
54376
|
detectBackend,
|
|
53704
54377
|
createTaskTracker
|
|
53705
54378
|
};
|
|
53706
|
-
//# sourceMappingURL=chunk-
|
|
54379
|
+
//# sourceMappingURL=chunk-RLLMWZAE.js.map
|