@productbrain/mcp 0.0.1-beta.13263 → 0.0.1-beta.13276
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.
|
@@ -1571,12 +1571,12 @@ function nextLines(action, entryId, refusal) {
|
|
|
1571
1571
|
function coherencyRefusedResult(toolName, entryId, refusal) {
|
|
1572
1572
|
const action = toolName.endsWith("action=update") ? "update" : "accept";
|
|
1573
1573
|
const stays = action === "accept" ? LINK_REFUSAL_WORDS.notAccepted(entryId) : LINK_REFUSAL_WORDS.notChanged(entryId);
|
|
1574
|
-
const
|
|
1574
|
+
const reason2 = refusal.reason ?? LINK_REFUSAL_WORDS.unlinked;
|
|
1575
1575
|
const next = nextLines(action, entryId, refusal);
|
|
1576
1576
|
return failureResult(
|
|
1577
|
-
withAcceptPrompt([stays,
|
|
1577
|
+
withAcceptPrompt([stays, reason2, ...next].join("\n"), [refusal]),
|
|
1578
1578
|
"COHERENCY_REFUSED",
|
|
1579
|
-
`${stays} ${
|
|
1579
|
+
`${stays} ${reason2}`,
|
|
1580
1580
|
next.join("\n") || void 0,
|
|
1581
1581
|
void 0,
|
|
1582
1582
|
{ entryId, refusal }
|
|
@@ -1797,7 +1797,7 @@ ${mcp}`, "QUALITY_HELD", mcp.split("\n")[0] ?? mcp, mcp.split("\n")[1] ?? mcp, v
|
|
|
1797
1797
|
}, next)
|
|
1798
1798
|
};
|
|
1799
1799
|
}
|
|
1800
|
-
async function handleCommitEntry({ entryId, preview, steeringOverrideReason, qualityOverrideReason, coherencyAcknowledgement, replaces, reason }, toolName = "entries") {
|
|
1800
|
+
async function handleCommitEntry({ entryId, preview, steeringOverrideReason, qualityOverrideReason, coherencyAcknowledgement, replaces, reason: reason2 }, toolName = "entries") {
|
|
1801
1801
|
requireWriteAccess();
|
|
1802
1802
|
const entry = await kernelQuery("chain.getEntry", { entryId });
|
|
1803
1803
|
if (!entry) {
|
|
@@ -1816,15 +1816,15 @@ async function handleCommitEntry({ entryId, preview, steeringOverrideReason, qua
|
|
|
1816
1816
|
...qualityOverrideReason ? { qualityOverrideReason } : {},
|
|
1817
1817
|
// TASK-954
|
|
1818
1818
|
...coherencyAcknowledgement ? { coherencyAcknowledgement } : {},
|
|
1819
|
-
...replaces ? { replaces, ...
|
|
1819
|
+
...replaces ? { replaces, ...reason2 !== void 0 ? { replacesReason: reason2 } : {} } : {}
|
|
1820
1820
|
// TASK-1030; DEC-2006: the reason rides with it
|
|
1821
1821
|
}).catch((err) => {
|
|
1822
1822
|
const { code, details } = err;
|
|
1823
1823
|
const fix = code === "GROUNDING_GATE_BLOCKED" ? refusalFixOf(details) : null;
|
|
1824
1824
|
if (!fix) throw err;
|
|
1825
|
-
const
|
|
1825
|
+
const reason3 = err.message.replace(/^MCP call "[^"]+" failed \(\d+\): /s, "");
|
|
1826
1826
|
const acceptRefusal = details?.find((d) => typeof d === "object" && d !== null && "acceptRefusal" in d);
|
|
1827
|
-
return { status: "coherency_refused", refusal: { reason:
|
|
1827
|
+
return { status: "coherency_refused", refusal: { reason: reason3, fix, acceptRefusal: acceptRefusal?.acceptRefusal } };
|
|
1828
1828
|
});
|
|
1829
1829
|
if (result2?.status === "coherency_refused" && result2?.refusal) {
|
|
1830
1830
|
return coherencyRefusedResult(`${toolName} action=accept`, entryId, result2.refusal);
|
|
@@ -1847,7 +1847,7 @@ async function handleCommitEntry({ entryId, preview, steeringOverrideReason, qua
|
|
|
1847
1847
|
...typeof result2.conflictCheck === "string" ? { conflictCheck: result2.conflictCheck } : {}
|
|
1848
1848
|
// TASK-1040: as a real accept says it
|
|
1849
1849
|
},
|
|
1850
|
-
[{ tool: toolName, description: "Accept for real", parameters: { action: "accept", entryId, ...replaces ? { replaces, ...
|
|
1850
|
+
[{ tool: toolName, description: "Accept for real", parameters: { action: "accept", entryId, ...replaces ? { replaces, ...reason2 !== void 0 ? { reason: reason2 } : {} } : {} } }]
|
|
1851
1851
|
// TASK-1030
|
|
1852
1852
|
);
|
|
1853
1853
|
if (result2.contract) {
|
|
@@ -2229,14 +2229,14 @@ async function handleVerifyChain(server, { collection, mode: mode2 }) {
|
|
|
2229
2229
|
if (!cleaned) continue;
|
|
2230
2230
|
const kind = classifyRef(cleaned);
|
|
2231
2231
|
let result2;
|
|
2232
|
-
let
|
|
2232
|
+
let reason2;
|
|
2233
2233
|
if (kind === "file") {
|
|
2234
|
-
({ result: result2, reason } = checkFileRef(cleaned, projectRoot));
|
|
2234
|
+
({ result: result2, reason: reason2 } = checkFileRef(cleaned, projectRoot));
|
|
2235
2235
|
} else if (kind === "schema") {
|
|
2236
|
-
({ result: result2, reason } = checkSchemaRef(cleaned, schema));
|
|
2236
|
+
({ result: result2, reason: reason2 } = checkSchemaRef(cleaned, schema));
|
|
2237
2237
|
} else {
|
|
2238
2238
|
result2 = "unverifiable";
|
|
2239
|
-
|
|
2239
|
+
reason2 = "conceptual reference";
|
|
2240
2240
|
}
|
|
2241
2241
|
mappingChecks.push({
|
|
2242
2242
|
entryId: eid,
|
|
@@ -2244,7 +2244,7 @@ async function handleVerifyChain(server, { collection, mode: mode2 }) {
|
|
|
2244
2244
|
field: rawRef.trim(),
|
|
2245
2245
|
kind,
|
|
2246
2246
|
result: result2,
|
|
2247
|
-
reason,
|
|
2247
|
+
reason: reason2,
|
|
2248
2248
|
currentStatus: cm.status ?? "unknown"
|
|
2249
2249
|
});
|
|
2250
2250
|
}
|
|
@@ -2408,12 +2408,12 @@ var replaceEntrySchema = z10.object({
|
|
|
2408
2408
|
newEntryId: z10.string().max(200).describe("Human entry ID of the accepted entry of the same kind that replaces it."),
|
|
2409
2409
|
reason: z10.string().max(2e3).optional().describe("Why it is replaced, one line (required; the kernel refuses without one).")
|
|
2410
2410
|
});
|
|
2411
|
-
async function handleReplaceEntry({ entryId, newEntryId, reason }) {
|
|
2411
|
+
async function handleReplaceEntry({ entryId, newEntryId, reason: reason2 }) {
|
|
2412
2412
|
requireWriteAccess();
|
|
2413
2413
|
const agentSessionId = getAgentSessionId();
|
|
2414
2414
|
const result2 = await kernelMutation(
|
|
2415
2415
|
"chain.replaceEntry",
|
|
2416
|
-
{ oldEntryId: entryId, newEntryId, ...
|
|
2416
|
+
{ oldEntryId: entryId, newEntryId, ...reason2 !== void 0 ? { reason: reason2 } : {}, ...agentSessionId ? { sessionId: agentSessionId } : {} }
|
|
2417
2417
|
);
|
|
2418
2418
|
const message = [
|
|
2419
2419
|
`${sanitizeSingleLineField(result2.name)} (${sanitizeSingleLineField(result2.entryId)})`,
|
|
@@ -3821,8 +3821,8 @@ var LOOKUP_LINE = {
|
|
|
3821
3821
|
var INDENT = " ";
|
|
3822
3822
|
function siblingLine(kr, clean) {
|
|
3823
3823
|
const current = kr.readingUnresolved ? 'current unresolved, not "never read"' : kr.currentValue === null ? "no reading yet" : `current ${kr.currentValue}`;
|
|
3824
|
-
const
|
|
3825
|
-
return `${clean(kr.entryId)} \u2014 ${clean(kr.name)} (${current}${
|
|
3824
|
+
const target2 = kr.targetValue === null ? "" : `, target ${kr.targetValue}`;
|
|
3825
|
+
return `${clean(kr.entryId)} \u2014 ${clean(kr.name)} (${current}${target2})`;
|
|
3826
3826
|
}
|
|
3827
3827
|
function formatOutcomeObjectiveLines(view, clean) {
|
|
3828
3828
|
const o = view.objective;
|
|
@@ -6410,11 +6410,11 @@ async function runCoherenceCheck(projectRoot) {
|
|
|
6410
6410
|
});
|
|
6411
6411
|
return { status: "ok", report: result2.report, snapshot: result2.snapshot };
|
|
6412
6412
|
} catch (err) {
|
|
6413
|
-
const
|
|
6413
|
+
const reason2 = describeGatewayFailure(err);
|
|
6414
6414
|
if (process.env.DEBUG_COHERENCE) {
|
|
6415
|
-
console.debug("[coherence] chain.evaluateCoherence gateway call failed:",
|
|
6415
|
+
console.debug("[coherence] chain.evaluateCoherence gateway call failed:", reason2);
|
|
6416
6416
|
}
|
|
6417
|
-
return { status: "skipped", reason };
|
|
6417
|
+
return { status: "skipped", reason: reason2 };
|
|
6418
6418
|
}
|
|
6419
6419
|
}
|
|
6420
6420
|
function renderCoherenceLines(report) {
|
|
@@ -8865,8 +8865,8 @@ async function handleGetRun(runId, workflowId) {
|
|
|
8865
8865
|
});
|
|
8866
8866
|
}
|
|
8867
8867
|
if (!run) {
|
|
8868
|
-
const
|
|
8869
|
-
return validationResult(`No persisted run found for ${
|
|
8868
|
+
const target2 = runId ? `workflow run '${runId}'` : `workflow '${workflowId}' in the current session`;
|
|
8869
|
+
return validationResult(`No persisted run found for ${target2}.`);
|
|
8870
8870
|
}
|
|
8871
8871
|
if (workflowId && run.workflowId !== workflowId) {
|
|
8872
8872
|
return validationResult(
|
|
@@ -9382,8 +9382,8 @@ function readSpineVerdict(value) {
|
|
|
9382
9382
|
}
|
|
9383
9383
|
function describeSpineStaleness(changedMemberCount, membershipTruncated = false, relationsChanged = false) {
|
|
9384
9384
|
if (changedMemberCount > 0) {
|
|
9385
|
-
const
|
|
9386
|
-
return
|
|
9385
|
+
const reason2 = `${membershipTruncated ? "at least " : ""}${changedMemberCount} entr${changedMemberCount === 1 ? "y" : "ies"} changed, joined or left the direction since this was checked`;
|
|
9386
|
+
return reason2 + (membershipTruncated ? "; membership scan incomplete" : "");
|
|
9387
9387
|
}
|
|
9388
9388
|
if (relationsChanged) {
|
|
9389
9389
|
return "a part_of or validates link changed since this check ran" + (membershipTruncated ? "; membership scan incomplete" : "");
|
|
@@ -11153,22 +11153,43 @@ function registerFeedbackTool(server) {
|
|
|
11153
11153
|
|
|
11154
11154
|
// src/tools/conflicts.ts
|
|
11155
11155
|
import { z as z33 } from "zod/v3";
|
|
11156
|
+
|
|
11157
|
+
// src/lib/conflictResolution.ts
|
|
11158
|
+
var CONFLICT_RESOLUTIONS = ["replaces", "refines", "unrelated"];
|
|
11159
|
+
var CONFLICT_RESOLUTION_REASON_MAX = 200;
|
|
11160
|
+
var signed = (line) => line;
|
|
11161
|
+
var RESOLUTION_WORDS = {
|
|
11162
|
+
choose: signed(`Choose ${CONFLICT_RESOLUTIONS.slice(0, -1).join(", ")} or ${CONFLICT_RESOLUTIONS[CONFLICT_RESOLUTIONS.length - 1]}.`),
|
|
11163
|
+
both: signed("Give either the answer (real or false alarm) or the choice, not both."),
|
|
11164
|
+
reasonTooLong: signed(`Keep the reason to one line of ${CONFLICT_RESOLUTION_REASON_MAX} characters or fewer.`),
|
|
11165
|
+
target: "replaces or refines: the entry it replaces or refines, one of the two",
|
|
11166
|
+
reason: `For unrelated: one line on why (${CONFLICT_RESOLUTION_REASON_MAX} characters at most); for an amendment: why the answer changes`,
|
|
11167
|
+
recorded: (choice2) => `Recorded: ${choice2}.`
|
|
11168
|
+
};
|
|
11169
|
+
|
|
11170
|
+
// src/tools/conflicts.ts
|
|
11156
11171
|
var ACTIONS = ["list", "resolve"];
|
|
11157
11172
|
var mode = z33.enum(["actionable", "all"]);
|
|
11158
11173
|
var verdict = z33.enum(["real", "noise"]);
|
|
11174
|
+
var choice = z33.enum(CONFLICT_RESOLUTIONS, { errorMap: () => ({ message: RESOLUTION_WORDS.choose }) });
|
|
11175
|
+
var target = z33.string().max(200).optional();
|
|
11176
|
+
var reason = z33.string().max(CONFLICT_RESOLUTION_REASON_MAX, RESOLUTION_WORDS.reasonTooLong).optional();
|
|
11159
11177
|
var conflictsSchema = z33.object({
|
|
11160
11178
|
action: z33.enum(ACTIONS),
|
|
11161
|
-
mode: mode.optional().describe("list: all adds judged
|
|
11162
|
-
issueId: z33.string().max(200).optional().describe("resolve:
|
|
11163
|
-
|
|
11179
|
+
mode: mode.optional().describe("list: all adds judged."),
|
|
11180
|
+
issueId: z33.string().max(200).optional().describe("resolve: id from list."),
|
|
11181
|
+
choice: choice.optional(),
|
|
11182
|
+
target,
|
|
11183
|
+
reason,
|
|
11184
|
+
verdict: verdict.optional()
|
|
11164
11185
|
});
|
|
11165
11186
|
var conflictsActionUnion = z33.discriminatedUnion("action", [
|
|
11166
11187
|
z33.object({ action: z33.literal("list"), mode: mode.optional() }),
|
|
11167
|
-
z33.object({ action: z33.literal("resolve"), issueId: z33.string().min(1).max(200), verdict })
|
|
11188
|
+
z33.object({ action: z33.literal("resolve"), issueId: z33.string().min(1).max(200), choice: choice.optional(), target, reason, verdict: verdict.optional() })
|
|
11168
11189
|
]);
|
|
11169
11190
|
var CONFLICTS_ACTION_SPECS = {
|
|
11170
|
-
list: { params: ["mode"], description: "mode
|
|
11171
|
-
resolve: { params: ["issueId", "verdict"], description: "issueId and
|
|
11191
|
+
list: { params: ["mode"], description: "mode: actionable by default." },
|
|
11192
|
+
resolve: { params: ["issueId", "choice", "target", "reason", "verdict"], description: "issueId and choice (or verdict)." }
|
|
11172
11193
|
};
|
|
11173
11194
|
async function handleConflictsList(listMode = "actionable") {
|
|
11174
11195
|
const rows = await kernelCall("conflicts.list", { mode: listMode });
|
|
@@ -11176,12 +11197,23 @@ async function handleConflictsList(listMode = "actionable") {
|
|
|
11176
11197
|
const lines = rows.map((r) => `${r.id} \xB7 ${side(r.entryAName, r.entryAId)} \u2194 ${side(r.entryBName, r.entryBId)} \xB7 ${r.conflictType} ${r.confidence.toFixed(2)}${r.rankLabel ? ` \xB7 ${sanitizeSingleLineField(r.rankLabel)}` : ""} \xB7 ${sanitizeSingleLineField(r.explanation)}` + (r.guidance ? ` \xB7 ${sanitizeSingleLineField(r.guidance)}` : ""));
|
|
11177
11198
|
const truncated = rows[0]?.listTruncated === true;
|
|
11178
11199
|
const count = `${rows.length}${truncated ? "+" : ""} contradiction${rows.length === 1 && !truncated ? "" : "s"}`;
|
|
11179
|
-
const summary = rows.length === 0 ? listMode === "all" ? "No open contradictions." : "No contradictions await your verdict. mode=all shows judged and snoozed rows." : listMode === "all" ? `${count} open, judged and snoozed included.` : `${count}. Resolve one: conflicts action=resolve issueId=<id>
|
|
11200
|
+
const summary = rows.length === 0 ? listMode === "all" ? "No open contradictions." : "No contradictions await your verdict. mode=all shows judged and snoozed rows." : listMode === "all" ? `${count} open, judged and snoozed included.` : `${count}. Resolve one: conflicts action=resolve issueId=<id> choice=${CONFLICT_RESOLUTIONS.join("|")}`;
|
|
11180
11201
|
const order = rows[0]?.rankOrderNote ? [sanitizeSingleLineField(rows[0].rankOrderNote)] : [];
|
|
11181
11202
|
return successResult([summary, ...order, ...lines].join("\n"), summary, { mode: listMode, rows });
|
|
11182
11203
|
}
|
|
11183
|
-
async function handleConflictsResolve(issueId, word) {
|
|
11204
|
+
async function handleConflictsResolve(issueId, { choice: pick, target: entry, reason: why, verdict: word }) {
|
|
11205
|
+
if (!pick === !word) return validationResult(pick ? RESOLUTION_WORDS.both : RESOLUTION_WORDS.choose);
|
|
11184
11206
|
requireWriteAccess();
|
|
11207
|
+
if (pick) {
|
|
11208
|
+
const result3 = await kernelCall("conflicts.resolve", {
|
|
11209
|
+
issueId,
|
|
11210
|
+
resolution: pick,
|
|
11211
|
+
...entry ? { resolutionTarget: entry } : {},
|
|
11212
|
+
...why ? { resolutionReason: why } : {}
|
|
11213
|
+
});
|
|
11214
|
+
const line = "line" in result3 && typeof result3.line === "string" ? sanitizeSingleLineField(result3.line) : RESOLUTION_WORDS.recorded(pick);
|
|
11215
|
+
return successResult(line, line, { issueId, choice: pick, result: result3 });
|
|
11216
|
+
}
|
|
11185
11217
|
const result2 = await kernelCall("conflicts.resolve", {
|
|
11186
11218
|
issueId,
|
|
11187
11219
|
verdict: word === "noise" ? "false_alarm" : "real"
|
|
@@ -11192,11 +11224,11 @@ async function handleConflictsResolve(issueId, word) {
|
|
|
11192
11224
|
function registerConflictsTool(server) {
|
|
11193
11225
|
const handlers = {
|
|
11194
11226
|
list: (data) => handleConflictsList(data.mode),
|
|
11195
|
-
resolve: (data) => handleConflictsResolve(data.issueId, data
|
|
11227
|
+
resolve: (data) => handleConflictsResolve(data.issueId, data)
|
|
11196
11228
|
};
|
|
11197
11229
|
server.registerTool("conflicts", {
|
|
11198
11230
|
title: "Conflicts",
|
|
11199
|
-
description: "Contradictions
|
|
11231
|
+
description: "Contradictions between entries: list or resolve them.",
|
|
11200
11232
|
inputSchema: conflictsSchema,
|
|
11201
11233
|
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false }
|
|
11202
11234
|
}, thinWrapper(async (args) => {
|
|
@@ -11313,15 +11345,15 @@ async function handleQuestionAnswer(entryId, text, answerEntryId) {
|
|
|
11313
11345
|
return questionErrorResult(err, "answer", { entryId, text, answerEntryId });
|
|
11314
11346
|
}
|
|
11315
11347
|
}
|
|
11316
|
-
async function handleQuestionForceClose(entryId,
|
|
11348
|
+
async function handleQuestionForceClose(entryId, reason2) {
|
|
11317
11349
|
requireWriteAccess();
|
|
11318
11350
|
try {
|
|
11319
11351
|
const resolvedEntryId = await resolveEntryRef(entryId, "Entry");
|
|
11320
|
-
const result2 = await kernelMutation("question.forceClose", { entryId: resolvedEntryId, reason, sessionId: getAgentSessionId() ?? void 0 });
|
|
11352
|
+
const result2 = await kernelMutation("question.forceClose", { entryId: resolvedEntryId, reason: reason2, sessionId: getAgentSessionId() ?? void 0 });
|
|
11321
11353
|
const message = result2.idempotent ? `${entryId} is already closed \u2014 no change.` : "Force-closed. Reason recorded.";
|
|
11322
11354
|
return successResult(message, message, result2);
|
|
11323
11355
|
} catch (err) {
|
|
11324
|
-
return questionErrorResult(err, "force-close", { entryId, reason });
|
|
11356
|
+
return questionErrorResult(err, "force-close", { entryId, reason: reason2 });
|
|
11325
11357
|
}
|
|
11326
11358
|
}
|
|
11327
11359
|
async function handleQuestionList(mine) {
|
|
@@ -11954,7 +11986,7 @@ async function validateOrRefuse(sessionId) {
|
|
|
11954
11986
|
} catch (err) {
|
|
11955
11987
|
const { code, message, recovery } = classifyError(err);
|
|
11956
11988
|
const firstLine = message.split("\n")[0].trim();
|
|
11957
|
-
const
|
|
11989
|
+
const reason2 = /^[A-Z]\w*Error\b|validator/i.test(firstLine) ? null : firstLine.replace(/\.?\s*$/, ".");
|
|
11958
11990
|
const ended = err instanceof KernelCallError && err.code !== void 0 && ENDED_SESSION_CODES.has(err.code);
|
|
11959
11991
|
const result2 = ended ? failureResult(
|
|
11960
11992
|
errorText({ message, recovery: PASS_SESSION_ID }),
|
|
@@ -11963,9 +11995,9 @@ async function validateOrRefuse(sessionId) {
|
|
|
11963
11995
|
PASS_SESSION_ID,
|
|
11964
11996
|
[{ tool: "session", description: "Start a session", parameters: { action: "start" } }]
|
|
11965
11997
|
) : err instanceof KernelCallError && err.status >= 400 && err.status < 500 && err.status !== 429 && err.code !== WORKSPACE_CLOSED ? failureResult(
|
|
11966
|
-
errorText({ message: `The sessionId you passed [${sessionId}] was refused${
|
|
11998
|
+
errorText({ message: `The sessionId you passed [${sessionId}] was refused${reason2 ? `: ${reason2}` : "."}`, recovery: PASS_SESSION_ID }),
|
|
11967
11999
|
"SESSION_INVALID",
|
|
11968
|
-
`sessionId refused${
|
|
12000
|
+
`sessionId refused${reason2 ? `: ${reason2}` : "."}`,
|
|
11969
12001
|
PASS_SESSION_ID,
|
|
11970
12002
|
[{ tool: "session", description: "Start a session", parameters: { action: "start" } }]
|
|
11971
12003
|
) : failureResult(errorText({ message, recovery }), code, message, recovery);
|
|
@@ -12004,4 +12036,4 @@ export {
|
|
|
12004
12036
|
SERVER_VERSION,
|
|
12005
12037
|
createProductBrainServer
|
|
12006
12038
|
};
|
|
12007
|
-
//# sourceMappingURL=chunk-
|
|
12039
|
+
//# sourceMappingURL=chunk-DP5CIXMS.js.map
|