@productbrain/mcp 0.0.1-beta.171 → 0.0.1-beta.173
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.
|
@@ -994,7 +994,7 @@ var metaSchema = z.object({
|
|
|
994
994
|
perEntryAvgMs: z.number().optional()
|
|
995
995
|
}).passthrough().optional()
|
|
996
996
|
}).optional();
|
|
997
|
-
function
|
|
997
|
+
function thinWrapper(handler) {
|
|
998
998
|
return async (args) => {
|
|
999
999
|
const start = Date.now();
|
|
1000
1000
|
try {
|
|
@@ -1009,17 +1009,7 @@ function withEnvelope(handler) {
|
|
|
1009
1009
|
...sc.ok === false ? { isError: true } : {}
|
|
1010
1010
|
};
|
|
1011
1011
|
}
|
|
1012
|
-
|
|
1013
|
-
return {
|
|
1014
|
-
content: result.content ?? [],
|
|
1015
|
-
structuredContent: {
|
|
1016
|
-
...success(
|
|
1017
|
-
result.content?.[0]?.text?.slice(0, 100) ?? "",
|
|
1018
|
-
sc ?? {}
|
|
1019
|
-
),
|
|
1020
|
-
_meta: { durationMs }
|
|
1021
|
-
}
|
|
1022
|
-
};
|
|
1012
|
+
throw new Error(`[thinWrapper] Handler '${handler.name || "<anonymous>"}' returned without envelope shape \u2014 migration incomplete.`);
|
|
1023
1013
|
} catch (err) {
|
|
1024
1014
|
const durationMs = Date.now() - start;
|
|
1025
1015
|
const classified = classifyError(err);
|
|
@@ -2294,7 +2284,7 @@ function registerSmartCaptureTools(server) {
|
|
|
2294
2284
|
inputSchema: captureSchema.shape,
|
|
2295
2285
|
annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: false }
|
|
2296
2286
|
},
|
|
2297
|
-
|
|
2287
|
+
thinWrapper(async ({ collection, name, description, context, entryId, canonicalKey, data: userData, links, autoCommit, sourceRef, sourceExcerpt, preview, suggestOnly, format }) => {
|
|
2298
2288
|
requireWriteAccess();
|
|
2299
2289
|
const timingStart = Date.now();
|
|
2300
2290
|
const wsCtx = await getWorkspaceContext();
|
|
@@ -3098,7 +3088,7 @@ Use \`entries action=get\` to inspect the existing entry, or \`update-entry\` to
|
|
|
3098
3088
|
inputSchema: batchCaptureSchema.shape,
|
|
3099
3089
|
annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: false }
|
|
3100
3090
|
},
|
|
3101
|
-
|
|
3091
|
+
thinWrapper(async ({ entries, autoCommit, preview }) => {
|
|
3102
3092
|
requireWriteAccess();
|
|
3103
3093
|
const batchTimingStart = Date.now();
|
|
3104
3094
|
const agentId = getAgentSessionId();
|
|
@@ -3880,7 +3870,7 @@ function registerKnowledgeTools(server) {
|
|
|
3880
3870
|
inputSchema: updateEntrySchema,
|
|
3881
3871
|
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false }
|
|
3882
3872
|
},
|
|
3883
|
-
|
|
3873
|
+
thinWrapper(async ({ entryId, name, status: rawStatus, workflowStatus: rawWorkflowStatus, data, order, canonicalKey, autoPublish, changeNote, sourceRef, sourceExcerpt }) => {
|
|
3884
3874
|
requireWriteAccess();
|
|
3885
3875
|
const fieldsProvided = [];
|
|
3886
3876
|
if (name !== void 0) fieldsProvided.push("name");
|
|
@@ -3988,7 +3978,7 @@ function registerKnowledgeTools(server) {
|
|
|
3988
3978
|
inputSchema: getHistorySchema,
|
|
3989
3979
|
annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: false }
|
|
3990
3980
|
},
|
|
3991
|
-
|
|
3981
|
+
thinWrapper(async ({ entryId }) => {
|
|
3992
3982
|
const history = await kernelQuery("chain.listEntryHistory", { entryId });
|
|
3993
3983
|
if (history.length === 0) {
|
|
3994
3984
|
return successResult(
|
|
@@ -4021,7 +4011,7 @@ ${formatted}` }],
|
|
|
4021
4011
|
inputSchema: commitEntrySchema,
|
|
4022
4012
|
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false }
|
|
4023
4013
|
},
|
|
4024
|
-
|
|
4014
|
+
thinWrapper(async ({ entryId, preview }) => {
|
|
4025
4015
|
requireWriteAccess();
|
|
4026
4016
|
const entry = await kernelQuery("chain.getEntry", { entryId });
|
|
4027
4017
|
if (!entry) {
|
|
@@ -4347,7 +4337,7 @@ function registerEntriesTools(server) {
|
|
|
4347
4337
|
inputSchema: entriesSchema,
|
|
4348
4338
|
annotations: { idempotentHint: false, openWorldHint: false }
|
|
4349
4339
|
},
|
|
4350
|
-
|
|
4340
|
+
thinWrapper(async (args) => {
|
|
4351
4341
|
const parsed = parseOrFail(entriesSchema, args);
|
|
4352
4342
|
if (!parsed.ok) return parsed.result;
|
|
4353
4343
|
const { action, entryId, entryIds, collection, toCollection, status, tag, label, query } = parsed.data;
|
|
@@ -4784,7 +4774,7 @@ function registerGraphTools(server) {
|
|
|
4784
4774
|
inputSchema: graphSchema,
|
|
4785
4775
|
annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: false }
|
|
4786
4776
|
},
|
|
4787
|
-
|
|
4777
|
+
thinWrapper(async (args) => {
|
|
4788
4778
|
const parsed = parseOrFail(graphSchema, args);
|
|
4789
4779
|
if (!parsed.ok) return parsed.result;
|
|
4790
4780
|
const { action, entryId, direction, limit, depth } = parsed.data;
|
|
@@ -5015,7 +5005,7 @@ function registerRelationsTools(server) {
|
|
|
5015
5005
|
inputSchema: relationsSchema,
|
|
5016
5006
|
annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false }
|
|
5017
5007
|
},
|
|
5018
|
-
|
|
5008
|
+
thinWrapper(async (args) => {
|
|
5019
5009
|
const parsed = parseOrFail(relationsSchema, args);
|
|
5020
5010
|
if (!parsed.ok) return parsed.result;
|
|
5021
5011
|
const { action, from, to, type, score, relations, preview } = parsed.data;
|
|
@@ -5299,7 +5289,7 @@ function registerContextTools(server) {
|
|
|
5299
5289
|
inputSchema: contextSchema,
|
|
5300
5290
|
annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: false }
|
|
5301
5291
|
},
|
|
5302
|
-
|
|
5292
|
+
thinWrapper(async (args) => {
|
|
5303
5293
|
const parsed = parseOrFail(contextSchema, args);
|
|
5304
5294
|
if (!parsed.ok) return parsed.result;
|
|
5305
5295
|
const { action, entryId, mapEntryId, task, since, direction, relationType, mode, maxHops, maxResults, strategy, skill, briefType } = parsed.data;
|
|
@@ -6377,7 +6367,7 @@ function registerCollectionsTools(server) {
|
|
|
6377
6367
|
inputSchema: collectionsSchema,
|
|
6378
6368
|
annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false }
|
|
6379
6369
|
},
|
|
6380
|
-
|
|
6370
|
+
thinWrapper(async (args) => {
|
|
6381
6371
|
const parsed = parseOrFail(collectionsSchema, args);
|
|
6382
6372
|
if (!parsed.ok) return parsed.result;
|
|
6383
6373
|
const { action, slug, name, description, purpose, icon, navGroup, fields, defaultCanonicalKey, defaultWorkflowStatus, validWorkflowStatuses, classificationCheck, classificationPriority, qualityCriteria, usageGuidance } = parsed.data;
|
|
@@ -6722,7 +6712,7 @@ function registerLabelTools(server) {
|
|
|
6722
6712
|
inputSchema: labelsSchema,
|
|
6723
6713
|
annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false }
|
|
6724
6714
|
},
|
|
6725
|
-
|
|
6715
|
+
thinWrapper(async ({ action, slug, name, color, description, parentSlug, isGroup, order, entryId }) => {
|
|
6726
6716
|
if (action === "list") {
|
|
6727
6717
|
const labels = await kernelQuery("chain.listLabels");
|
|
6728
6718
|
if (labels.length === 0) {
|
|
@@ -7471,7 +7461,12 @@ async function runWrapupReview() {
|
|
|
7471
7461
|
if (getApiKeyScope() === "read") {
|
|
7472
7462
|
return { text: "Read-only session \u2014 nothing to review.", data: null, suggestions: [], failureCode: "READONLY_SCOPE" };
|
|
7473
7463
|
}
|
|
7474
|
-
const
|
|
7464
|
+
const { workspaceId } = await getWorkspaceContext();
|
|
7465
|
+
const kernelEnvelope = await kernelCallEnvelope("agentKnowledge.wrapupEnvelope", {
|
|
7466
|
+
workspaceId,
|
|
7467
|
+
sessionId,
|
|
7468
|
+
action: "review"
|
|
7469
|
+
});
|
|
7475
7470
|
const data = kernelEnvelope.data;
|
|
7476
7471
|
if (data.wrapupCompletedAt) {
|
|
7477
7472
|
return { text: "Wrapup already completed this session.", data, suggestions: [], failureCode: "ALREADY_COMPLETED" };
|
|
@@ -7782,7 +7777,17 @@ function registerWrapupTools(server) {
|
|
|
7782
7777
|
);
|
|
7783
7778
|
}
|
|
7784
7779
|
const useCachedReview = lastReviewSessionId === sessionId;
|
|
7785
|
-
|
|
7780
|
+
let data2;
|
|
7781
|
+
if (useCachedReview && lastReviewData) {
|
|
7782
|
+
data2 = lastReviewData;
|
|
7783
|
+
} else {
|
|
7784
|
+
const { workspaceId } = await getWorkspaceContext();
|
|
7785
|
+
data2 = (await kernelCallEnvelope("agentKnowledge.wrapupEnvelope", {
|
|
7786
|
+
workspaceId,
|
|
7787
|
+
sessionId,
|
|
7788
|
+
action: "review"
|
|
7789
|
+
})).data;
|
|
7790
|
+
}
|
|
7786
7791
|
if (data2.drafts.length === 0) {
|
|
7787
7792
|
return failureResult("No uncommitted drafts to commit.", "NOT_FOUND", "No uncommitted drafts to commit.", "Nothing to commit.");
|
|
7788
7793
|
}
|
|
@@ -7843,7 +7848,7 @@ ${text}` : text;
|
|
|
7843
7848
|
description: WRAPUP_TOOL_DESCRIPTION + " Also known as: wrapup, finish.",
|
|
7844
7849
|
annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: false },
|
|
7845
7850
|
inputSchema: wrapupSchema
|
|
7846
|
-
},
|
|
7851
|
+
}, thinWrapper(async (args) => {
|
|
7847
7852
|
const parsed = parseOrFail(wrapupSchema, args);
|
|
7848
7853
|
if (!parsed.ok) return parsed.result;
|
|
7849
7854
|
const act = parsed.data.action ?? "review";
|
|
@@ -7871,7 +7876,7 @@ function registerSessionTools(server) {
|
|
|
7871
7876
|
inputSchema: sessionSchema,
|
|
7872
7877
|
annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: false }
|
|
7873
7878
|
},
|
|
7874
|
-
|
|
7879
|
+
thinWrapper(async (args) => {
|
|
7875
7880
|
const parsed = parseOrFail(sessionSchema, args);
|
|
7876
7881
|
if (!parsed.ok) return parsed.result;
|
|
7877
7882
|
const { action } = parsed.data;
|
|
@@ -8087,7 +8092,7 @@ function registerQualityTools(server) {
|
|
|
8087
8092
|
inputSchema: qualitySchema,
|
|
8088
8093
|
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false }
|
|
8089
8094
|
},
|
|
8090
|
-
|
|
8095
|
+
thinWrapper(async (args) => {
|
|
8091
8096
|
const parsed = parseOrFail(qualitySchema, args);
|
|
8092
8097
|
if (!parsed.ok) return parsed.result;
|
|
8093
8098
|
const { action, entryId, context } = parsed.data;
|
|
@@ -9175,7 +9180,7 @@ function registerWorkflowTools(server) {
|
|
|
9175
9180
|
inputSchema: workflowsSchema,
|
|
9176
9181
|
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false }
|
|
9177
9182
|
},
|
|
9178
|
-
|
|
9183
|
+
thinWrapper(async (args) => {
|
|
9179
9184
|
const parsed = parseOrFail(workflowsSchema, args);
|
|
9180
9185
|
if (!parsed.ok) return parsed.result;
|
|
9181
9186
|
const {
|
|
@@ -9866,71 +9871,6 @@ function buildStudioUrl(workspaceSlug, entryId) {
|
|
|
9866
9871
|
const appUrl = process.env.PRODUCTBRAIN_APP_URL ?? "https://work.productbrain.io";
|
|
9867
9872
|
return `${appUrl}/${workspaceSlug}/legacy/entries/${entryId}`;
|
|
9868
9873
|
}
|
|
9869
|
-
async function loadBetEntry(entryId) {
|
|
9870
|
-
try {
|
|
9871
|
-
return await kernelQuery("chain.getEntry", { entryId });
|
|
9872
|
-
} catch {
|
|
9873
|
-
return null;
|
|
9874
|
-
}
|
|
9875
|
-
}
|
|
9876
|
-
async function loadConstellationState(betEntryId, betInternalId) {
|
|
9877
|
-
try {
|
|
9878
|
-
const relations = await kernelQuery("chain.listEntryRelations", {
|
|
9879
|
-
entryId: betEntryId
|
|
9880
|
-
});
|
|
9881
|
-
const internalId = betInternalId ?? (await loadBetEntry(betEntryId))?._id;
|
|
9882
|
-
const elementCount = relations.filter(
|
|
9883
|
-
(r) => r.type === "part_of" && r.toId === internalId
|
|
9884
|
-
).length;
|
|
9885
|
-
const riskCount = relations.filter(
|
|
9886
|
-
(r) => r.type === "constrains" && r.toId === internalId
|
|
9887
|
-
).length;
|
|
9888
|
-
const decisionCount = relations.filter(
|
|
9889
|
-
(r) => r.type === "informs" && r.toId === internalId
|
|
9890
|
-
).length;
|
|
9891
|
-
return { relations, elementCount, riskCount, decisionCount };
|
|
9892
|
-
} catch {
|
|
9893
|
-
return { relations: [], elementCount: 0, riskCount: 0, decisionCount: 0 };
|
|
9894
|
-
}
|
|
9895
|
-
}
|
|
9896
|
-
var RELATION_TO_COLLECTION = {
|
|
9897
|
-
part_of: "features",
|
|
9898
|
-
constrains: "tensions",
|
|
9899
|
-
informs: "decisions"
|
|
9900
|
-
};
|
|
9901
|
-
async function loadSessionDrafts(betEntryId, betInternalId) {
|
|
9902
|
-
try {
|
|
9903
|
-
const relations = await kernelQuery("chain.listEntryRelations", {
|
|
9904
|
-
entryId: betEntryId
|
|
9905
|
-
});
|
|
9906
|
-
const internalId = betInternalId ?? (await loadBetEntry(betEntryId))?._id;
|
|
9907
|
-
const incoming = relations.filter(
|
|
9908
|
-
(r) => r.toId === internalId && ["part_of", "constrains", "informs"].includes(r.type)
|
|
9909
|
-
);
|
|
9910
|
-
const drafts = [];
|
|
9911
|
-
for (const rel of incoming.slice(0, 15)) {
|
|
9912
|
-
try {
|
|
9913
|
-
const entry = await kernelQuery(
|
|
9914
|
-
"chain.getEntry",
|
|
9915
|
-
{ id: rel.fromId }
|
|
9916
|
-
);
|
|
9917
|
-
if (entry?.entryId) {
|
|
9918
|
-
drafts.push({
|
|
9919
|
-
entryId: entry.entryId,
|
|
9920
|
-
name: entry.name,
|
|
9921
|
-
collection: RELATION_TO_COLLECTION[rel.type] ?? "unknown",
|
|
9922
|
-
relationType: rel.type,
|
|
9923
|
-
status: entry.status ?? "draft"
|
|
9924
|
-
});
|
|
9925
|
-
}
|
|
9926
|
-
} catch {
|
|
9927
|
-
}
|
|
9928
|
-
}
|
|
9929
|
-
return drafts;
|
|
9930
|
-
} catch {
|
|
9931
|
-
return [];
|
|
9932
|
-
}
|
|
9933
|
-
}
|
|
9934
9874
|
function registerFacilitateTools(server) {
|
|
9935
9875
|
server.registerTool(
|
|
9936
9876
|
"facilitate",
|
|
@@ -9945,7 +9885,7 @@ function registerFacilitateTools(server) {
|
|
|
9945
9885
|
openWorldHint: false
|
|
9946
9886
|
}
|
|
9947
9887
|
},
|
|
9948
|
-
|
|
9888
|
+
thinWrapper(async (args) => {
|
|
9949
9889
|
const parsed = facilitateSchema.safeParse(args);
|
|
9950
9890
|
if (!parsed.success) {
|
|
9951
9891
|
const issues = parsed.error.issues.map((i) => `${i.path.join(".")}: ${i.message}`).join("; ");
|
|
@@ -9970,55 +9910,44 @@ async function handleResume(args) {
|
|
|
9970
9910
|
if (!betId) {
|
|
9971
9911
|
return validationResult("`betEntryId` is required for resume action.");
|
|
9972
9912
|
}
|
|
9973
|
-
const
|
|
9974
|
-
|
|
9975
|
-
|
|
9976
|
-
|
|
9977
|
-
|
|
9978
|
-
|
|
9979
|
-
|
|
9980
|
-
|
|
9981
|
-
|
|
9982
|
-
|
|
9983
|
-
|
|
9984
|
-
const
|
|
9985
|
-
|
|
9986
|
-
|
|
9987
|
-
|
|
9988
|
-
|
|
9989
|
-
const
|
|
9990
|
-
const
|
|
9991
|
-
|
|
9992
|
-
|
|
9993
|
-
|
|
9994
|
-
|
|
9995
|
-
const output = [
|
|
9996
|
-
`# Session State \u2014 ${betEntry.name}`,
|
|
9913
|
+
const { workspaceId, workspaceSlug } = await getWorkspaceContext();
|
|
9914
|
+
const envelope = await kernelCallEnvelope("agentKnowledge.facilitateEnvelope", {
|
|
9915
|
+
workspaceId,
|
|
9916
|
+
action: "resume",
|
|
9917
|
+
betEntryId: betId
|
|
9918
|
+
});
|
|
9919
|
+
const enrichedData = {
|
|
9920
|
+
...envelope.data,
|
|
9921
|
+
studioUrl: buildStudioUrl(workspaceSlug, betId)
|
|
9922
|
+
};
|
|
9923
|
+
const bet = enrichedData.betEntry;
|
|
9924
|
+
const cx = enrichedData.constellation;
|
|
9925
|
+
const constellationParts = [];
|
|
9926
|
+
if (cx.elementCount > 0) constellationParts.push(`${cx.elementCount} element(s)`);
|
|
9927
|
+
if (cx.riskCount > 0) constellationParts.push(`${cx.riskCount} risk(s)`);
|
|
9928
|
+
if (cx.decisionCount > 0) constellationParts.push(`${cx.decisionCount} decision(s)`);
|
|
9929
|
+
const constellationSummary = constellationParts.length > 0 ? constellationParts.join(", ") : "no entries captured yet";
|
|
9930
|
+
const draftLines = enrichedData.sessionDrafts.slice(0, 10).map(
|
|
9931
|
+
(d) => `- \`${d.entryId}\` ${d.name} [${d.collection}] (${d.status})`
|
|
9932
|
+
);
|
|
9933
|
+
const textLines = [
|
|
9934
|
+
`# ${bet.name}`,
|
|
9997
9935
|
"",
|
|
9998
|
-
`**
|
|
9999
|
-
`**Cortex:** ${studioUrl}
|
|
10000
|
-
|
|
10001
|
-
|
|
10002
|
-
|
|
10003
|
-
].filter(
|
|
9936
|
+
`**ID:** \`${bet.betEntryId}\` \xB7 **Status:** ${bet.status}`,
|
|
9937
|
+
enrichedData.studioUrl ? `**Cortex:** ${enrichedData.studioUrl}` : "",
|
|
9938
|
+
"",
|
|
9939
|
+
`**Constellation:** ${constellationSummary}`,
|
|
9940
|
+
...draftLines.length > 0 ? ["", "**Session drafts:**", ...draftLines] : []
|
|
9941
|
+
].filter((l) => l !== void 0);
|
|
10004
9942
|
return {
|
|
10005
|
-
content: [{ type: "text", text:
|
|
10006
|
-
structuredContent:
|
|
10007
|
-
|
|
10008
|
-
|
|
10009
|
-
|
|
10010
|
-
|
|
10011
|
-
|
|
10012
|
-
|
|
10013
|
-
studioUrl,
|
|
10014
|
-
constellation: {
|
|
10015
|
-
elementCount: constellation.elementCount,
|
|
10016
|
-
riskCount: constellation.riskCount,
|
|
10017
|
-
decisionCount: constellation.decisionCount
|
|
10018
|
-
},
|
|
10019
|
-
sessionDrafts
|
|
10020
|
-
}
|
|
10021
|
-
)
|
|
9943
|
+
content: [{ type: "text", text: textLines.join("\n") }],
|
|
9944
|
+
structuredContent: {
|
|
9945
|
+
ok: true,
|
|
9946
|
+
summary: envelope.summary,
|
|
9947
|
+
data: enrichedData,
|
|
9948
|
+
next: envelope.next,
|
|
9949
|
+
_meta: envelope._meta
|
|
9950
|
+
}
|
|
10022
9951
|
};
|
|
10023
9952
|
}
|
|
10024
9953
|
async function handleCommitConstellation(args) {
|
|
@@ -10027,55 +9956,25 @@ async function handleCommitConstellation(args) {
|
|
|
10027
9956
|
if (!betId) {
|
|
10028
9957
|
return validationResult("`betEntryId` is required for commit-constellation action.");
|
|
10029
9958
|
}
|
|
10030
|
-
const
|
|
10031
|
-
|
|
10032
|
-
|
|
10033
|
-
|
|
10034
|
-
|
|
10035
|
-
|
|
10036
|
-
|
|
10037
|
-
|
|
10038
|
-
|
|
10039
|
-
|
|
10040
|
-
|
|
10041
|
-
|
|
10042
|
-
|
|
10043
|
-
|
|
10044
|
-
|
|
10045
|
-
|
|
10046
|
-
|
|
10047
|
-
content: [{
|
|
10048
|
-
type: "text",
|
|
10049
|
-
text: [
|
|
10050
|
-
`# Cannot commit constellation`,
|
|
10051
|
-
"",
|
|
10052
|
-
`**${commitBlockerItems.length} blocker(s) found** \u2014 fix these before committing:`,
|
|
10053
|
-
...commitBlockerItems.map((b) => `- ${b.blocker} \u2192 \`${b.fix}\``),
|
|
10054
|
-
"",
|
|
10055
|
-
"No entries were committed."
|
|
10056
|
-
].join("\n")
|
|
10057
|
-
}],
|
|
10058
|
-
structuredContent: failure(
|
|
10059
|
-
"VALIDATION_ERROR",
|
|
10060
|
-
`${commitBlockerItems.length} blocker(s) found. Fix before committing.`,
|
|
10061
|
-
commitBlockerItems.map((b) => `${b.blocker} \u2192 ${b.fix}`).join("; "),
|
|
10062
|
-
void 0,
|
|
10063
|
-
{
|
|
10064
|
-
operationId,
|
|
10065
|
-
blockers: commitBlockerItems,
|
|
10066
|
-
committedIds: [],
|
|
10067
|
-
totalRelations
|
|
10068
|
-
}
|
|
10069
|
-
)
|
|
10070
|
-
};
|
|
9959
|
+
const { workspaceId } = await getWorkspaceContext();
|
|
9960
|
+
const sessionId = getAgentSessionId();
|
|
9961
|
+
const operationId = args.operationId ?? `${betId}:${sessionId ?? "sessionless"}:${Date.now()}`;
|
|
9962
|
+
let betName = betId;
|
|
9963
|
+
let betDesc = "";
|
|
9964
|
+
let betCollectionHint;
|
|
9965
|
+
try {
|
|
9966
|
+
const betEnvelope = await kernelCallEnvelope("chain.getEntry", { entryId: betId });
|
|
9967
|
+
const entry = betEnvelope.data;
|
|
9968
|
+
if (entry) {
|
|
9969
|
+
betName = entry.name ?? betId;
|
|
9970
|
+
const d = entry.data ?? {};
|
|
9971
|
+
const links = d["links"];
|
|
9972
|
+
betDesc = d.problem ?? links?.problem ?? d.description ?? "";
|
|
9973
|
+
betCollectionHint = entry.collectionSlug ?? entry.collection?.slug ?? entry.collection?.name;
|
|
9974
|
+
}
|
|
9975
|
+
} catch {
|
|
10071
9976
|
}
|
|
10072
|
-
const
|
|
10073
|
-
const descField = betData.problem ?? links?.problem ?? betData.description ?? "";
|
|
10074
|
-
const preflight = await runConflictPreflight(
|
|
10075
|
-
betEntry.name ?? betId,
|
|
10076
|
-
descField,
|
|
10077
|
-
betEntry.collectionSlug ?? betEntry.collection?.slug ?? betEntry.collection?.name
|
|
10078
|
-
);
|
|
9977
|
+
const preflight = await runConflictPreflight(betName, betDesc, betCollectionHint);
|
|
10079
9978
|
if (preflight.blockingContradictions.length > 0) {
|
|
10080
9979
|
await recordSessionActivity({ contradictionWarning: true });
|
|
10081
9980
|
const conflictLines = preflight.blockingContradictions.map((c) => `- ${c.chainEntryName} (${c.chainEntryId}) \u2014 ${c.explanation}`).join("\n");
|
|
@@ -10107,20 +10006,16 @@ async function handleCommitConstellation(args) {
|
|
|
10107
10006
|
if (preflight.source === "semantic" ? preflight.conflicts.length > 0 : preflight.advisoryWarnings.length > 0) {
|
|
10108
10007
|
await recordSessionActivity({ contradictionWarning: true });
|
|
10109
10008
|
}
|
|
10110
|
-
|
|
10111
|
-
const sessionId = getAgentSessionId() ?? void 0;
|
|
10112
|
-
let kernelEnvelope;
|
|
10113
|
-
let result;
|
|
10009
|
+
let envelope;
|
|
10114
10010
|
try {
|
|
10115
|
-
|
|
10011
|
+
envelope = await kernelCallEnvelope("agentKnowledge.facilitateEnvelope", {
|
|
10012
|
+
workspaceId,
|
|
10013
|
+
action: "commit-constellation",
|
|
10116
10014
|
betEntryId: betId,
|
|
10117
|
-
author,
|
|
10118
|
-
sessionId,
|
|
10119
10015
|
operationId,
|
|
10120
|
-
|
|
10121
|
-
|
|
10016
|
+
sessionId: sessionId ?? void 0,
|
|
10017
|
+
author: sessionId ? `agent:${sessionId}` : "kernel:facilitate"
|
|
10122
10018
|
});
|
|
10123
|
-
result = kernelEnvelope.data;
|
|
10124
10019
|
} catch (err) {
|
|
10125
10020
|
const msg = err instanceof Error ? err.message : String(err);
|
|
10126
10021
|
return {
|
|
@@ -10140,26 +10035,17 @@ No constellation entries were committed.`
|
|
|
10140
10035
|
)
|
|
10141
10036
|
};
|
|
10142
10037
|
}
|
|
10143
|
-
|
|
10144
|
-
|
|
10145
|
-
committedIds: result.committedIds ?? [],
|
|
10146
|
-
alreadyCommittedIds: result.alreadyCommittedIds ?? [],
|
|
10147
|
-
proposedIds: result.proposedIds ?? [],
|
|
10148
|
-
failedIds: result.failedIds ?? [],
|
|
10149
|
-
conflictIds: result.conflictIds ?? []
|
|
10150
|
-
};
|
|
10151
|
-
for (const entryId of result.committedIds) {
|
|
10038
|
+
await recordSessionActivity({ contradictionWarning: preflight.blockingContradictions.length > 0 });
|
|
10039
|
+
for (const docId of envelope.data?.result?.committedIds ?? []) {
|
|
10152
10040
|
try {
|
|
10153
|
-
|
|
10154
|
-
const docId = committedEntry?._id;
|
|
10155
|
-
if (typeof docId === "string" && docId.length > 0) {
|
|
10156
|
-
await recordSessionActivity({ entryModified: docId });
|
|
10157
|
-
}
|
|
10041
|
+
await recordSessionActivity({ entryModified: docId });
|
|
10158
10042
|
} catch {
|
|
10159
10043
|
}
|
|
10160
10044
|
}
|
|
10045
|
+
const result = envelope.data.result;
|
|
10046
|
+
const suggestions = { conflictPreflightSource: preflight.source };
|
|
10161
10047
|
const lines = [];
|
|
10162
|
-
const hasIssues = result.failedIds
|
|
10048
|
+
const hasIssues = (result.failedIds?.length ?? 0) > 0 || (result.conflictIds?.length ?? 0) > 0;
|
|
10163
10049
|
if (result.proposalCreated) {
|
|
10164
10050
|
lines.push(
|
|
10165
10051
|
hasIssues ? `# Proposal created with issues` : `# Proposal created`,
|
|
@@ -10171,50 +10057,54 @@ No constellation entries were committed.`
|
|
|
10171
10057
|
lines.push(
|
|
10172
10058
|
hasIssues ? `# Published with issues` : `# Published`,
|
|
10173
10059
|
"",
|
|
10174
|
-
`**${result.committedIds
|
|
10060
|
+
`**${result.committedIds?.length ?? 0} entries** committed to the Chain, **${result.totalRelations} connections** preserved.`,
|
|
10175
10061
|
hasIssues ? `\`${betId}\` was partially committed. Review conflicts/failed entries below before considering the constellation complete.` : `\`${betId}\` and its full constellation are now source of truth.`
|
|
10176
10062
|
);
|
|
10177
10063
|
}
|
|
10178
|
-
|
|
10179
|
-
|
|
10064
|
+
if (preflight.source === "semantic" && preflight.conflicts.length > 0) {
|
|
10065
|
+
lines.push(
|
|
10066
|
+
"",
|
|
10067
|
+
`\u26A0 **Semantic conflict preflight** (advisory):`,
|
|
10068
|
+
...preflight.conflicts.map((c) => `- \`${c.chainEntryId}\` ${c.chainEntryName}: ${c.explanation}`)
|
|
10069
|
+
);
|
|
10070
|
+
} else if (preflight.source === "heuristic" && preflight.advisoryWarnings.length > 0) {
|
|
10180
10071
|
lines.push(
|
|
10181
10072
|
"",
|
|
10182
|
-
|
|
10183
|
-
...preflight.
|
|
10073
|
+
`\u26A0 **Contradiction warnings** (advisory):`,
|
|
10074
|
+
...preflight.advisoryWarnings.map(
|
|
10184
10075
|
(w) => `- \`${w.entryId}\` ${w.name} [${w.collection}] (${w.governsCount} governs relation${w.governsCount === 1 ? "" : "s"})`
|
|
10185
10076
|
)
|
|
10186
10077
|
);
|
|
10187
10078
|
}
|
|
10188
|
-
if (result.committedIds
|
|
10079
|
+
if ((result.committedIds?.length ?? 0) > 0) {
|
|
10189
10080
|
lines.push("", `**Committed:** ${result.committedIds.join(", ")}`);
|
|
10190
10081
|
}
|
|
10191
|
-
if (result.alreadyCommittedIds
|
|
10082
|
+
if ((result.alreadyCommittedIds?.length ?? 0) > 0) {
|
|
10192
10083
|
lines.push("", `**Already committed:** ${result.alreadyCommittedIds.join(", ")}`);
|
|
10193
10084
|
}
|
|
10194
|
-
if (result.proposedIds
|
|
10085
|
+
if ((result.proposedIds?.length ?? 0) > 0) {
|
|
10195
10086
|
lines.push("", `**Proposed (not yet committed):** ${result.proposedIds.join(", ")}`);
|
|
10196
10087
|
}
|
|
10197
|
-
if (result.conflictIds
|
|
10088
|
+
if ((result.conflictIds?.length ?? 0) > 0) {
|
|
10198
10089
|
lines.push("", `**${result.conflictIds.length} conflicts:**`);
|
|
10199
10090
|
for (const c of result.conflictIds) {
|
|
10200
10091
|
lines.push(`- \`${c.entryId}\` ${c.name}: ${c.reason}`);
|
|
10201
10092
|
}
|
|
10202
10093
|
}
|
|
10203
|
-
if (result.failedIds
|
|
10094
|
+
if ((result.failedIds?.length ?? 0) > 0) {
|
|
10204
10095
|
lines.push("", `**${result.failedIds.length} failed:**`);
|
|
10205
10096
|
for (const f of result.failedIds) {
|
|
10206
10097
|
lines.push(`- \`${f.entryId}\` ${f.name}: ${f.error}`);
|
|
10207
10098
|
}
|
|
10208
10099
|
}
|
|
10209
|
-
const suggestions = { contradictionWarnings, conflictPreflightSource: preflight.source };
|
|
10210
10100
|
return {
|
|
10211
10101
|
content: [{ type: "text", text: lines.join("\n") }],
|
|
10212
10102
|
structuredContent: {
|
|
10213
10103
|
ok: true,
|
|
10214
|
-
summary:
|
|
10104
|
+
summary: envelope.summary,
|
|
10215
10105
|
data: { result, suggestions },
|
|
10216
|
-
next:
|
|
10217
|
-
_meta:
|
|
10106
|
+
next: envelope.next,
|
|
10107
|
+
_meta: envelope._meta
|
|
10218
10108
|
}
|
|
10219
10109
|
};
|
|
10220
10110
|
}
|
|
@@ -10370,7 +10260,7 @@ function registerVerifyTools(server) {
|
|
|
10370
10260
|
inputSchema: verifySchema,
|
|
10371
10261
|
annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false }
|
|
10372
10262
|
},
|
|
10373
|
-
|
|
10263
|
+
thinWrapper(async ({ collection, mode }) => {
|
|
10374
10264
|
const projectRoot = resolveProjectRoot();
|
|
10375
10265
|
if (!projectRoot) {
|
|
10376
10266
|
return failureResult(
|
|
@@ -10558,7 +10448,7 @@ function registerVerifyTools(server) {
|
|
|
10558
10448
|
inputSchema: verifyEntrySchema,
|
|
10559
10449
|
annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: false }
|
|
10560
10450
|
},
|
|
10561
|
-
|
|
10451
|
+
thinWrapper(async ({ entryId }) => {
|
|
10562
10452
|
const result = await kernelMutation("chain.verifyEntry", { entryId });
|
|
10563
10453
|
return success(`Entry ${entryId} verified.`, result);
|
|
10564
10454
|
})
|
|
@@ -11292,7 +11182,7 @@ function registerStartTools(server) {
|
|
|
11292
11182
|
inputSchema: startSchema,
|
|
11293
11183
|
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false }
|
|
11294
11184
|
},
|
|
11295
|
-
|
|
11185
|
+
thinWrapper(async ({ preset, task }) => {
|
|
11296
11186
|
const errors = [];
|
|
11297
11187
|
const agentSessionId = getAgentSessionId();
|
|
11298
11188
|
let wsCtx = null;
|
|
@@ -11830,7 +11720,7 @@ function registerUsageTools(server) {
|
|
|
11830
11720
|
inputSchema: usageSummarySchema,
|
|
11831
11721
|
annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: false }
|
|
11832
11722
|
},
|
|
11833
|
-
|
|
11723
|
+
thinWrapper(async ({ periodDays }) => {
|
|
11834
11724
|
const ws = await getWorkspaceContext();
|
|
11835
11725
|
const sessionId = getAgentSessionId();
|
|
11836
11726
|
const summary = await kernelQuery("usage.getWorkspaceSummary", {
|
|
@@ -11954,7 +11844,7 @@ function registerGitChainTools(server) {
|
|
|
11954
11844
|
inputSchema: chainSchema,
|
|
11955
11845
|
annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: false }
|
|
11956
11846
|
},
|
|
11957
|
-
|
|
11847
|
+
thinWrapper(async ({ action, chainEntryId, title, chainTypeId, description, linkId, content, status, author }) => {
|
|
11958
11848
|
if (action === "create") {
|
|
11959
11849
|
if (!title) {
|
|
11960
11850
|
return validationResult("A `title` is required to create a process.");
|
|
@@ -12093,7 +11983,7 @@ Use \`chain action=get\` to see the full chain with updated scores.`
|
|
|
12093
11983
|
inputSchema: chainVersionSchema,
|
|
12094
11984
|
annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: false }
|
|
12095
11985
|
},
|
|
12096
|
-
|
|
11986
|
+
thinWrapper(async ({ action, chainEntryId, commitMessage, versionA, versionB, toVersion, author }) => {
|
|
12097
11987
|
if (action === "commit") {
|
|
12098
11988
|
if (!commitMessage) {
|
|
12099
11989
|
return validationResult("A `commitMessage` is required.");
|
|
@@ -12243,7 +12133,7 @@ ${formatted}` }],
|
|
|
12243
12133
|
inputSchema: chainBranchSchema,
|
|
12244
12134
|
annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: false }
|
|
12245
12135
|
},
|
|
12246
|
-
|
|
12136
|
+
thinWrapper(async ({ action, chainEntryId, branchName, strategy, author }) => {
|
|
12247
12137
|
if (action === "create") {
|
|
12248
12138
|
const result = await kernelMutation("gitchain.createBranch", { chainEntryId, name: branchName, author });
|
|
12249
12139
|
return {
|
|
@@ -12363,7 +12253,7 @@ Resolve conflicts before merging.`
|
|
|
12363
12253
|
inputSchema: chainReviewSchema,
|
|
12364
12254
|
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false }
|
|
12365
12255
|
},
|
|
12366
|
-
|
|
12256
|
+
thinWrapper(async ({ action, chainEntryId, commitMessage, versionNumber, linkId, body, commentId, author }) => {
|
|
12367
12257
|
if (action === "gate") {
|
|
12368
12258
|
const gate = await kernelQuery("gitchain.runGate", { chainEntryId, commitMessage });
|
|
12369
12259
|
const checkLines = gate.checks.map((c) => `- ${c.pass ? "PASS" : "FAIL"} **${c.name}**: ${c.detail}`).join("\n");
|
|
@@ -12518,7 +12408,7 @@ function registerMapTools(server) {
|
|
|
12518
12408
|
inputSchema: createAudienceMapSetSchema,
|
|
12519
12409
|
annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: false }
|
|
12520
12410
|
},
|
|
12521
|
-
|
|
12411
|
+
thinWrapper(async ({ audienceEntryId }) => {
|
|
12522
12412
|
const result = await kernelMutation(
|
|
12523
12413
|
"maps.createAudienceMapSet",
|
|
12524
12414
|
{ audienceEntryId }
|
|
@@ -12564,7 +12454,7 @@ Use map-slot to add ingredients. View at /empathy, /narrowing, and /jobs.`
|
|
|
12564
12454
|
inputSchema: mapSchema,
|
|
12565
12455
|
annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: false }
|
|
12566
12456
|
},
|
|
12567
|
-
|
|
12457
|
+
thinWrapper(async ({ action, mapEntryId, title, templateId, description, slotIds, status }) => {
|
|
12568
12458
|
if (action === "create") {
|
|
12569
12459
|
if (!title) {
|
|
12570
12460
|
return validationResult("A `title` is required to create a map.");
|
|
@@ -12676,7 +12566,7 @@ ${lines.join("\n")}` }],
|
|
|
12676
12566
|
inputSchema: mapSlotSchema,
|
|
12677
12567
|
annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false }
|
|
12678
12568
|
},
|
|
12679
|
-
|
|
12569
|
+
thinWrapper(async ({
|
|
12680
12570
|
action,
|
|
12681
12571
|
mapEntryId,
|
|
12682
12572
|
slotId,
|
|
@@ -12781,7 +12671,7 @@ ${slotSummary(map.slots)}` }],
|
|
|
12781
12671
|
inputSchema: mapVersionSchema,
|
|
12782
12672
|
annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: false }
|
|
12783
12673
|
},
|
|
12784
|
-
|
|
12674
|
+
thinWrapper(async ({ action, mapEntryId, commitMessage, author }) => {
|
|
12785
12675
|
if (action === "commit") {
|
|
12786
12676
|
const result = await kernelMutation("maps.commitMap", {
|
|
12787
12677
|
mapEntryId,
|
|
@@ -12845,7 +12735,7 @@ ${lines.join("\n")}` }],
|
|
|
12845
12735
|
inputSchema: mapSuggestSchema,
|
|
12846
12736
|
annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: false }
|
|
12847
12737
|
},
|
|
12848
|
-
|
|
12738
|
+
thinWrapper(async ({ mapEntryId, slotId, query }) => {
|
|
12849
12739
|
const map = await kernelQuery("maps.getMap", { mapEntryId });
|
|
12850
12740
|
if (!map) {
|
|
12851
12741
|
return {
|
|
@@ -13039,7 +12929,7 @@ function registerArchitectureTools(server) {
|
|
|
13039
12929
|
inputSchema: architectureSchema,
|
|
13040
12930
|
annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: false }
|
|
13041
12931
|
},
|
|
13042
|
-
|
|
12932
|
+
thinWrapper(async ({ action, template, layer, flow }) => {
|
|
13043
12933
|
await ensureCollection();
|
|
13044
12934
|
const all = await listArchEntries();
|
|
13045
12935
|
if (action === "show") {
|
|
@@ -13190,7 +13080,7 @@ ${nodeDetail}${flowLines}`
|
|
|
13190
13080
|
inputSchema: architectureAdminSchema,
|
|
13191
13081
|
annotations: { readOnlyHint: false, destructiveHint: true, openWorldHint: false }
|
|
13192
13082
|
},
|
|
13193
|
-
|
|
13083
|
+
thinWrapper(async ({ action }) => {
|
|
13194
13084
|
if (action === "seed") {
|
|
13195
13085
|
await ensureCollection();
|
|
13196
13086
|
const existing = await listArchEntries();
|
|
@@ -13609,7 +13499,7 @@ function registerOrientTool(server) {
|
|
|
13609
13499
|
inputSchema: orientSchema,
|
|
13610
13500
|
annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: false }
|
|
13611
13501
|
},
|
|
13612
|
-
|
|
13502
|
+
thinWrapper(async ({ mode = "full", task, scope }) => {
|
|
13613
13503
|
const errors = [];
|
|
13614
13504
|
if (scope && !task) {
|
|
13615
13505
|
errors.push("--scope requires --task to filter governance. Scope was ignored.");
|
|
@@ -14729,7 +14619,7 @@ function registerHealthTools(server) {
|
|
|
14729
14619
|
inputSchema: healthSchema,
|
|
14730
14620
|
annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: false }
|
|
14731
14621
|
},
|
|
14732
|
-
|
|
14622
|
+
thinWrapper(async (args) => {
|
|
14733
14623
|
const parsed = parseOrFail(healthSchema, args);
|
|
14734
14624
|
if (!parsed.ok) return parsed.result;
|
|
14735
14625
|
const { action, limit } = parsed.data;
|
|
@@ -14766,7 +14656,7 @@ function registerAuditTools(server) {
|
|
|
14766
14656
|
inputSchema: auditSchema,
|
|
14767
14657
|
annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: false }
|
|
14768
14658
|
},
|
|
14769
|
-
|
|
14659
|
+
thinWrapper(async (args) => {
|
|
14770
14660
|
const parsed = parseOrFail(auditSchema, args);
|
|
14771
14661
|
if (!parsed.ok) return parsed.result;
|
|
14772
14662
|
const { entryId, phase = "shaping" } = parsed.data;
|
|
@@ -14881,7 +14771,7 @@ function registerGovernanceTools(server) {
|
|
|
14881
14771
|
inputSchema: governanceSchema,
|
|
14882
14772
|
annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: false }
|
|
14883
14773
|
},
|
|
14884
|
-
|
|
14774
|
+
thinWrapper(async ({ action, proposalId, verdict, reason, status }) => {
|
|
14885
14775
|
const wsCtx = await getWorkspaceContext();
|
|
14886
14776
|
const enabled = await isFeatureEnabled(
|
|
14887
14777
|
"bet-221-governance-at-scale",
|
|
@@ -15809,4 +15699,4 @@ export {
|
|
|
15809
15699
|
SERVER_VERSION,
|
|
15810
15700
|
createProductBrainServer
|
|
15811
15701
|
};
|
|
15812
|
-
//# sourceMappingURL=chunk-
|
|
15702
|
+
//# sourceMappingURL=chunk-VD2UZKWN.js.map
|