@lucern/mcp 0.2.0-alpha.5 → 0.2.0-alpha.7
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/gateway.d.ts +128 -103
- package/dist/gateway.js +851 -364
- package/dist/gateway.js.map +1 -1
- package/dist/index.d.ts +7 -7
- package/dist/index.js +540 -225
- package/dist/index.js.map +1 -1
- package/dist/runtime.js +944 -4274
- package/dist/runtime.js.map +1 -1
- package/package.json +4 -5
package/dist/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/
|
|
|
3
3
|
import { McpServer, ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
4
4
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
5
5
|
import { z } from 'zod';
|
|
6
|
+
import { opinionFromBaseRate, opinionFromDogmatic, opinionFromProjected } from '@lucern/confidence';
|
|
6
7
|
import 'crypto';
|
|
7
8
|
import * as fs from 'fs';
|
|
8
9
|
import { existsSync } from 'fs';
|
|
@@ -1259,33 +1260,168 @@ function createAuditClient(config = {}) {
|
|
|
1259
1260
|
}
|
|
1260
1261
|
};
|
|
1261
1262
|
}
|
|
1262
|
-
|
|
1263
|
-
|
|
1263
|
+
function asRecord2(value) {
|
|
1264
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
1265
|
+
}
|
|
1266
|
+
function readString(value) {
|
|
1267
|
+
if (typeof value !== "string") {
|
|
1268
|
+
return void 0;
|
|
1269
|
+
}
|
|
1270
|
+
const normalized = value.trim();
|
|
1271
|
+
return normalized.length > 0 ? normalized : void 0;
|
|
1272
|
+
}
|
|
1273
|
+
function readNumber(value) {
|
|
1274
|
+
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
1275
|
+
}
|
|
1276
|
+
function clamp01(value) {
|
|
1277
|
+
return Math.max(0, Math.min(1, value));
|
|
1278
|
+
}
|
|
1279
|
+
function normalizeOpinionTuple(record) {
|
|
1280
|
+
const opinion = asRecord2(record.opinion);
|
|
1281
|
+
const rawBelief = readNumber(opinion.b) ?? readNumber(record.belief);
|
|
1282
|
+
const rawDisbelief = readNumber(opinion.d) ?? readNumber(record.disbelief);
|
|
1283
|
+
const rawUncertainty = readNumber(opinion.u) ?? readNumber(record.uncertainty);
|
|
1284
|
+
const rawBaseRate = readNumber(opinion.a) ?? readNumber(record.baseRate);
|
|
1285
|
+
if (rawBelief === void 0 && rawDisbelief === void 0 && rawUncertainty === void 0) {
|
|
1286
|
+
const projected = clamp01(readNumber(record.confidence) ?? 0);
|
|
1287
|
+
return {
|
|
1288
|
+
b: projected,
|
|
1289
|
+
d: 1 - projected,
|
|
1290
|
+
u: 0,
|
|
1291
|
+
a: 0.5
|
|
1292
|
+
};
|
|
1293
|
+
}
|
|
1294
|
+
return {
|
|
1295
|
+
b: clamp01(rawBelief ?? 0),
|
|
1296
|
+
d: clamp01(rawDisbelief ?? 0),
|
|
1297
|
+
u: clamp01(rawUncertainty ?? 0),
|
|
1298
|
+
a: clamp01(rawBaseRate ?? 0.5)
|
|
1299
|
+
};
|
|
1300
|
+
}
|
|
1301
|
+
function mapOpinionHistoryEntriesFromGatewayData(payload) {
|
|
1302
|
+
const entries = Array.isArray(payload.entries) ? payload.entries : [];
|
|
1303
|
+
return entries.map((value) => {
|
|
1304
|
+
const record = asRecord2(value);
|
|
1305
|
+
const tuple = normalizeOpinionTuple(record);
|
|
1306
|
+
const projected = readNumber(record.confidence) ?? clamp01(tuple.b + tuple.a * tuple.u);
|
|
1307
|
+
const triggeringEvidenceId = readString(record.triggeringEvidenceId);
|
|
1308
|
+
const triggeringWorktreeId = readString(record.triggeringWorktreeId);
|
|
1309
|
+
return {
|
|
1310
|
+
t: readNumber(record.timestamp) ?? readNumber(record.assessedAt) ?? 0,
|
|
1311
|
+
b: tuple.b,
|
|
1312
|
+
d: tuple.d,
|
|
1313
|
+
u: tuple.u,
|
|
1314
|
+
a: tuple.a,
|
|
1315
|
+
P: clamp01(projected),
|
|
1316
|
+
trigger: readString(record.trigger) ?? "manual",
|
|
1317
|
+
...triggeringEvidenceId ? {
|
|
1318
|
+
triggeringRef: {
|
|
1319
|
+
kind: "evidence",
|
|
1320
|
+
id: triggeringEvidenceId
|
|
1321
|
+
}
|
|
1322
|
+
} : triggeringWorktreeId ? {
|
|
1323
|
+
triggeringRef: {
|
|
1324
|
+
kind: "worktree",
|
|
1325
|
+
id: triggeringWorktreeId
|
|
1326
|
+
}
|
|
1327
|
+
} : {},
|
|
1328
|
+
...readString(record.rationale) ? { rationale: readString(record.rationale) } : {},
|
|
1329
|
+
...readString(record.userId) ? { userId: readString(record.userId) } : {},
|
|
1330
|
+
...readString(record.slOperator) ? { slOperator: readString(record.slOperator) } : {}
|
|
1331
|
+
};
|
|
1332
|
+
}).sort((left, right) => left.t - right.t);
|
|
1333
|
+
}
|
|
1334
|
+
function normalizeModulateConfidenceInput(input) {
|
|
1335
|
+
const opinion = "opinion" in input ? input.opinion : input.interpretation === "base_rate" ? opinionFromBaseRate(input.confidence) : input.interpretation === "dogmatic" ? opinionFromDogmatic(input.confidence, input.baseRate) : opinionFromProjected(
|
|
1336
|
+
input.confidence,
|
|
1337
|
+
input.uncertainty,
|
|
1338
|
+
input.baseRate
|
|
1339
|
+
);
|
|
1340
|
+
return {
|
|
1341
|
+
belief: opinion.b,
|
|
1342
|
+
disbelief: opinion.d,
|
|
1343
|
+
uncertainty: opinion.u,
|
|
1344
|
+
baseRate: opinion.a,
|
|
1345
|
+
trigger: input.trigger,
|
|
1346
|
+
rationale: input.rationale,
|
|
1347
|
+
maxInlinePropagationTargets: input.maxInlinePropagationTargets
|
|
1348
|
+
};
|
|
1349
|
+
}
|
|
1264
1350
|
function createBeliefsClient(config = {}) {
|
|
1265
1351
|
const gateway = createGatewayRequestClient(config);
|
|
1352
|
+
function requireBaseRate2(value) {
|
|
1353
|
+
const baseRate = readNumber(value);
|
|
1354
|
+
if (baseRate === void 0) {
|
|
1355
|
+
throw new Error("baseRate is required for belief creation.");
|
|
1356
|
+
}
|
|
1357
|
+
if (baseRate < 0 || baseRate > 1) {
|
|
1358
|
+
throw new Error("baseRate must be within [0, 1].");
|
|
1359
|
+
}
|
|
1360
|
+
return baseRate;
|
|
1361
|
+
}
|
|
1362
|
+
const modulateConfidence = async (beliefId, input, idempotencyKey) => gateway.request({
|
|
1363
|
+
path: `/api/platform/v1/beliefs/${encodeURIComponent(beliefId)}/confidence`,
|
|
1364
|
+
method: "POST",
|
|
1365
|
+
body: normalizeModulateConfidenceInput(input),
|
|
1366
|
+
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
1367
|
+
});
|
|
1368
|
+
async function getOpinionHistory(beliefId) {
|
|
1369
|
+
const response = await gateway.request({
|
|
1370
|
+
path: `/api/platform/v1/beliefs/${encodeURIComponent(beliefId)}/confidence-history`
|
|
1371
|
+
});
|
|
1372
|
+
return mapOpinionHistoryEntriesFromGatewayData(response.data);
|
|
1373
|
+
}
|
|
1266
1374
|
return {
|
|
1267
1375
|
/**
|
|
1268
1376
|
* Create a belief within a topic scope.
|
|
1269
1377
|
*/
|
|
1270
1378
|
async createBelief(input, idempotencyKey) {
|
|
1379
|
+
const baseRate = requireBaseRate2(input.baseRate);
|
|
1271
1380
|
return gateway.request({
|
|
1272
1381
|
path: "/api/platform/v1/beliefs",
|
|
1273
1382
|
method: "POST",
|
|
1274
|
-
body:
|
|
1383
|
+
body: {
|
|
1384
|
+
...normalizeNodeWriteInput(input),
|
|
1385
|
+
baseRate
|
|
1386
|
+
},
|
|
1275
1387
|
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
1276
1388
|
});
|
|
1277
1389
|
},
|
|
1278
1390
|
/**
|
|
1279
|
-
*
|
|
1391
|
+
* Refine a draft belief in place.
|
|
1280
1392
|
*/
|
|
1281
|
-
async
|
|
1393
|
+
async refineBelief(beliefId, input, idempotencyKey) {
|
|
1282
1394
|
return gateway.request({
|
|
1283
|
-
path: `/api/platform/v1/beliefs/${encodeURIComponent(beliefId)}
|
|
1284
|
-
method: "
|
|
1285
|
-
body: input,
|
|
1395
|
+
path: `/api/platform/v1/beliefs/${encodeURIComponent(beliefId)}`,
|
|
1396
|
+
method: "PATCH",
|
|
1397
|
+
body: normalizeNodeWriteInput(input),
|
|
1286
1398
|
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
1287
1399
|
});
|
|
1288
1400
|
},
|
|
1401
|
+
/**
|
|
1402
|
+
* Record a confidence change for an existing belief.
|
|
1403
|
+
*/
|
|
1404
|
+
modulateConfidence,
|
|
1405
|
+
/**
|
|
1406
|
+
* Returns the belief's confidence trajectory as a chronological array.
|
|
1407
|
+
*
|
|
1408
|
+
* Canonical UI trend shape (what every trend component consumes):
|
|
1409
|
+
* { t: number, b: number, d: number, u: number, a: number, P: number, trigger: string, triggeringRef?: { kind: "evidence" | "worktree"; id: string } }[]
|
|
1410
|
+
*
|
|
1411
|
+
* Where:
|
|
1412
|
+
* t = assessedAt (epoch ms)
|
|
1413
|
+
* b, d, u, a = Opinion 4-tuple components
|
|
1414
|
+
* P = projected probability = b + a*u (precomputed for UI convenience)
|
|
1415
|
+
* trigger = cause of the score change
|
|
1416
|
+
* triggeringRef = optional pointer to the evidence or worktree that drove the change
|
|
1417
|
+
*/
|
|
1418
|
+
async getOpinionHistory(beliefId) {
|
|
1419
|
+
return getOpinionHistory(beliefId);
|
|
1420
|
+
},
|
|
1421
|
+
/** @deprecated Use getOpinionHistory(). */
|
|
1422
|
+
async getConfidenceHistory(beliefId) {
|
|
1423
|
+
return getOpinionHistory(beliefId);
|
|
1424
|
+
},
|
|
1289
1425
|
/**
|
|
1290
1426
|
* Fork a scored belief into a new formulation.
|
|
1291
1427
|
*/
|
|
@@ -1376,6 +1512,57 @@ function createBeliefsClient(config = {}) {
|
|
|
1376
1512
|
}
|
|
1377
1513
|
};
|
|
1378
1514
|
}
|
|
1515
|
+
|
|
1516
|
+
// ../sdk/src/sourcesClient.ts
|
|
1517
|
+
function createSourcesClient(config = {}) {
|
|
1518
|
+
const gateway = createGatewayRequestClient(config);
|
|
1519
|
+
return {
|
|
1520
|
+
async upsert(spec, idempotencyKey = randomIdempotencyKey()) {
|
|
1521
|
+
return gateway.request({
|
|
1522
|
+
path: "/api/platform/v1/sources/upsert",
|
|
1523
|
+
method: "POST",
|
|
1524
|
+
body: spec,
|
|
1525
|
+
idempotencyKey
|
|
1526
|
+
});
|
|
1527
|
+
},
|
|
1528
|
+
async get(sourceId) {
|
|
1529
|
+
return gateway.request({
|
|
1530
|
+
path: `/api/platform/v1/sources/${encodeURIComponent(sourceId)}`
|
|
1531
|
+
});
|
|
1532
|
+
}
|
|
1533
|
+
};
|
|
1534
|
+
}
|
|
1535
|
+
|
|
1536
|
+
// ../sdk/src/evidenceClient.ts
|
|
1537
|
+
function createEvidenceClient(config = {}) {
|
|
1538
|
+
const gateway = createGatewayRequestClient(config);
|
|
1539
|
+
return {
|
|
1540
|
+
async classifyEvidence(beliefId, evidenceId, classificationConfig, idempotencyKey) {
|
|
1541
|
+
return gateway.request({
|
|
1542
|
+
path: "/api/platform/v1/evidence/classify",
|
|
1543
|
+
method: "POST",
|
|
1544
|
+
body: {
|
|
1545
|
+
beliefId,
|
|
1546
|
+
evidenceId,
|
|
1547
|
+
config: classificationConfig
|
|
1548
|
+
},
|
|
1549
|
+
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
1550
|
+
});
|
|
1551
|
+
},
|
|
1552
|
+
async classifyEvidenceBatch(beliefId, evidence, classificationConfig, idempotencyKey) {
|
|
1553
|
+
return gateway.request({
|
|
1554
|
+
path: "/api/platform/v1/evidence/classify-batch",
|
|
1555
|
+
method: "POST",
|
|
1556
|
+
body: {
|
|
1557
|
+
beliefId,
|
|
1558
|
+
evidence,
|
|
1559
|
+
config: classificationConfig
|
|
1560
|
+
},
|
|
1561
|
+
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
1562
|
+
});
|
|
1563
|
+
}
|
|
1564
|
+
};
|
|
1565
|
+
}
|
|
1379
1566
|
var DEFAULT_CUSTOM_NAMESPACE = "custom";
|
|
1380
1567
|
var RESERVED_NAMESPACES = /* @__PURE__ */ new Set(["lucern"]);
|
|
1381
1568
|
var CustomToolRegistryError = class extends Error {
|
|
@@ -2165,14 +2352,14 @@ function createIdentityClient(config = {}) {
|
|
|
2165
2352
|
}
|
|
2166
2353
|
|
|
2167
2354
|
// ../sdk/src/topicsClient.ts
|
|
2168
|
-
function
|
|
2355
|
+
function asRecord3(value) {
|
|
2169
2356
|
return value && typeof value === "object" ? value : {};
|
|
2170
2357
|
}
|
|
2171
2358
|
function cleanString2(value) {
|
|
2172
2359
|
return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
|
|
2173
2360
|
}
|
|
2174
2361
|
function normalizeTopicRecord(value) {
|
|
2175
|
-
const record =
|
|
2362
|
+
const record = asRecord3(value);
|
|
2176
2363
|
const topicId = cleanString2(record.topicId) ?? cleanString2(record.id) ?? cleanString2(record._id);
|
|
2177
2364
|
return withTopicAlias({
|
|
2178
2365
|
...record,
|
|
@@ -2197,7 +2384,7 @@ function createTopicsClient(config = {}) {
|
|
|
2197
2384
|
})}`
|
|
2198
2385
|
}).then(
|
|
2199
2386
|
(response) => mapGatewayData(response, (data) => {
|
|
2200
|
-
const record =
|
|
2387
|
+
const record = asRecord3(data);
|
|
2201
2388
|
const items = Array.isArray(record.topics) ? record.topics.map(normalizeTopicRecord) : [];
|
|
2202
2389
|
return {
|
|
2203
2390
|
...createListResult(items, "topics"),
|
|
@@ -2214,7 +2401,7 @@ function createTopicsClient(config = {}) {
|
|
|
2214
2401
|
}).then(
|
|
2215
2402
|
(response) => mapGatewayData(
|
|
2216
2403
|
response,
|
|
2217
|
-
(data) => normalizeTopicRecord(
|
|
2404
|
+
(data) => normalizeTopicRecord(asRecord3(data).topic ?? data)
|
|
2218
2405
|
)
|
|
2219
2406
|
);
|
|
2220
2407
|
},
|
|
@@ -2250,7 +2437,7 @@ function createTopicsClient(config = {}) {
|
|
|
2250
2437
|
)}`
|
|
2251
2438
|
}).then(
|
|
2252
2439
|
(response) => mapGatewayData(response, (data) => {
|
|
2253
|
-
const record =
|
|
2440
|
+
const record = asRecord3(data);
|
|
2254
2441
|
return {
|
|
2255
2442
|
tree: Array.isArray(record.tree) ? record.tree.map(normalizeTopicTreeNode) : []
|
|
2256
2443
|
};
|
|
@@ -2284,6 +2471,22 @@ function createTopicsClient(config = {}) {
|
|
|
2284
2471
|
}
|
|
2285
2472
|
|
|
2286
2473
|
// ../sdk/src/gatewayFacades.ts
|
|
2474
|
+
function normalizeBeliefConfidenceInput(input) {
|
|
2475
|
+
const opinion = "opinion" in input ? input.opinion : input.interpretation === "base_rate" ? opinionFromBaseRate(input.confidence) : input.interpretation === "dogmatic" ? opinionFromDogmatic(input.confidence, input.baseRate) : opinionFromProjected(
|
|
2476
|
+
input.confidence,
|
|
2477
|
+
input.uncertainty,
|
|
2478
|
+
input.baseRate
|
|
2479
|
+
);
|
|
2480
|
+
return {
|
|
2481
|
+
belief: opinion.b,
|
|
2482
|
+
disbelief: opinion.d,
|
|
2483
|
+
uncertainty: opinion.u,
|
|
2484
|
+
baseRate: opinion.a,
|
|
2485
|
+
trigger: input.trigger,
|
|
2486
|
+
rationale: input.rationale,
|
|
2487
|
+
maxInlinePropagationTargets: input.maxInlinePropagationTargets
|
|
2488
|
+
};
|
|
2489
|
+
}
|
|
2287
2490
|
function serializeTypes(types) {
|
|
2288
2491
|
return Array.isArray(types) && types.length > 0 ? types.join(",") : void 0;
|
|
2289
2492
|
}
|
|
@@ -2335,7 +2538,7 @@ function createBeliefsFacade(config = {}) {
|
|
|
2335
2538
|
return gateway.request({
|
|
2336
2539
|
path: `/api/platform/v1/beliefs/${encodeURIComponent(id)}/confidence`,
|
|
2337
2540
|
method: "POST",
|
|
2338
|
-
body: input,
|
|
2541
|
+
body: normalizeBeliefConfidenceInput(input),
|
|
2339
2542
|
idempotencyKey
|
|
2340
2543
|
});
|
|
2341
2544
|
},
|
|
@@ -2413,6 +2616,11 @@ function createBeliefsFacade(config = {}) {
|
|
|
2413
2616
|
path: `/api/platform/v1/beliefs/${encodeURIComponent(id)}/confidence-history`
|
|
2414
2617
|
});
|
|
2415
2618
|
},
|
|
2619
|
+
async opinionHistory(id) {
|
|
2620
|
+
return gateway.request({
|
|
2621
|
+
path: `/api/platform/v1/beliefs/${encodeURIComponent(id)}/confidence-history`
|
|
2622
|
+
});
|
|
2623
|
+
},
|
|
2416
2624
|
async createContract(id, input, idempotencyKey = randomIdempotencyKey()) {
|
|
2417
2625
|
return gateway.request({
|
|
2418
2626
|
path: `/api/platform/v1/beliefs/${encodeURIComponent(id)}/contracts`,
|
|
@@ -4892,13 +5100,24 @@ function requireText(args) {
|
|
|
4892
5100
|
}
|
|
4893
5101
|
return text;
|
|
4894
5102
|
}
|
|
5103
|
+
function requireBaseRate(args) {
|
|
5104
|
+
if (typeof args.baseRate !== "number" || !Number.isFinite(args.baseRate)) {
|
|
5105
|
+
throw new Error("baseRate is required.");
|
|
5106
|
+
}
|
|
5107
|
+
if (args.baseRate < 0 || args.baseRate > 1) {
|
|
5108
|
+
throw new Error("baseRate must be within [0, 1].");
|
|
5109
|
+
}
|
|
5110
|
+
return args.baseRate;
|
|
5111
|
+
}
|
|
4895
5112
|
function exposeGatewayData(response) {
|
|
4896
5113
|
return Object.assign({}, response, response.data);
|
|
4897
5114
|
}
|
|
4898
5115
|
function createLucernClient(config = {}) {
|
|
4899
5116
|
const gatewayConfig = toGatewayConfig(config);
|
|
4900
5117
|
const beliefsClient = createBeliefsClient(gatewayConfig);
|
|
5118
|
+
const sourcesClient = createSourcesClient(gatewayConfig);
|
|
4901
5119
|
const beliefsFacade = createBeliefsFacade(gatewayConfig);
|
|
5120
|
+
const evidenceClient = createEvidenceClient(gatewayConfig);
|
|
4902
5121
|
const graphClient = createGraphClient(gatewayConfig);
|
|
4903
5122
|
const graphFacade = createGraphFacade(gatewayConfig);
|
|
4904
5123
|
const decisionsClient = createDecisionsClient(gatewayConfig);
|
|
@@ -5139,6 +5358,10 @@ function createLucernClient(config = {}) {
|
|
|
5139
5358
|
async function getConfidenceHistory(nodeId) {
|
|
5140
5359
|
return beliefsFacade.confidenceHistory(nodeId).then(exposeGatewayData);
|
|
5141
5360
|
}
|
|
5361
|
+
async function getOpinionHistory(nodeId) {
|
|
5362
|
+
const response = await beliefsFacade.opinionHistory(nodeId);
|
|
5363
|
+
return mapOpinionHistoryEntriesFromGatewayData(response.data);
|
|
5364
|
+
}
|
|
5142
5365
|
async function getAuditTrail(nodeId, limit = 50) {
|
|
5143
5366
|
const events = await auditClient.listEvents({ limit });
|
|
5144
5367
|
const entries = asListItems(events.data, "events").filter((event) => matchesAuditNodeReference(event, nodeId)).slice(0, limit).map((event) => {
|
|
@@ -5324,6 +5547,7 @@ function createLucernClient(config = {}) {
|
|
|
5324
5547
|
rationale: input.rationale,
|
|
5325
5548
|
worktreeId: input.worktreeId,
|
|
5326
5549
|
pillar: input.pillar,
|
|
5550
|
+
baseRate: requireBaseRate(input),
|
|
5327
5551
|
sourceBeliefIds: input.sourceBeliefIds,
|
|
5328
5552
|
sourceType: input.sourceType,
|
|
5329
5553
|
beliefType: input.beliefType,
|
|
@@ -5397,6 +5621,9 @@ function createLucernClient(config = {}) {
|
|
|
5397
5621
|
confidenceHistory(nodeId) {
|
|
5398
5622
|
return beliefsFacade.confidenceHistory(nodeId).then(exposeGatewayData);
|
|
5399
5623
|
},
|
|
5624
|
+
opinionHistory(nodeId) {
|
|
5625
|
+
return getOpinionHistory(nodeId);
|
|
5626
|
+
},
|
|
5400
5627
|
createContract(nodeId, input) {
|
|
5401
5628
|
return beliefsFacade.createContract(nodeId, input).then(exposeGatewayData);
|
|
5402
5629
|
},
|
|
@@ -5528,6 +5755,12 @@ function createLucernClient(config = {}) {
|
|
|
5528
5755
|
beliefId: args.beliefId
|
|
5529
5756
|
}));
|
|
5530
5757
|
},
|
|
5758
|
+
classifyEvidence(beliefId, evidenceId, config2, idempotencyKey) {
|
|
5759
|
+
return evidenceClient.classifyEvidence(beliefId, evidenceId, config2, idempotencyKey).then(exposeGatewayData);
|
|
5760
|
+
},
|
|
5761
|
+
classifyEvidenceBatch(beliefId, evidence, config2, idempotencyKey) {
|
|
5762
|
+
return evidenceClient.classifyEvidenceBatch(beliefId, evidence, config2, idempotencyKey).then(exposeGatewayData);
|
|
5763
|
+
},
|
|
5531
5764
|
updateStatus(input, idempotencyKey) {
|
|
5532
5765
|
return evidenceFacade.updateStatus(input, idempotencyKey).then(exposeGatewayData);
|
|
5533
5766
|
},
|
|
@@ -5544,6 +5777,14 @@ function createLucernClient(config = {}) {
|
|
|
5544
5777
|
return evidenceFacade.updateVerificationStatus(input, idempotencyKey).then(exposeGatewayData);
|
|
5545
5778
|
}
|
|
5546
5779
|
},
|
|
5780
|
+
sources: {
|
|
5781
|
+
upsert(input, idempotencyKey) {
|
|
5782
|
+
return sourcesClient.upsert(input, idempotencyKey).then(exposeGatewayData);
|
|
5783
|
+
},
|
|
5784
|
+
get(sourceId) {
|
|
5785
|
+
return sourcesClient.get(sourceId).then(exposeGatewayData);
|
|
5786
|
+
}
|
|
5787
|
+
},
|
|
5547
5788
|
questions: {
|
|
5548
5789
|
create(args) {
|
|
5549
5790
|
return questionsFacade.create({
|
|
@@ -5669,6 +5910,7 @@ function createLucernClient(config = {}) {
|
|
|
5669
5910
|
},
|
|
5670
5911
|
queryLineage,
|
|
5671
5912
|
getConfidenceHistory,
|
|
5913
|
+
getOpinionHistory,
|
|
5672
5914
|
getAuditTrail,
|
|
5673
5915
|
traverse(args) {
|
|
5674
5916
|
return graphFacade.traverse({
|
|
@@ -6371,6 +6613,8 @@ function createLucernClient(config = {}) {
|
|
|
6371
6613
|
extensions: extensionNamespaces,
|
|
6372
6614
|
raw: {
|
|
6373
6615
|
beliefs: beliefsClient,
|
|
6616
|
+
sources: sourcesClient,
|
|
6617
|
+
evidence: evidenceClient,
|
|
6374
6618
|
graph: graphClient,
|
|
6375
6619
|
decisions: decisionsClient,
|
|
6376
6620
|
workflow: workflowClient,
|
|
@@ -6569,13 +6813,17 @@ var LENS_PERSPECTIVE_TYPES = [
|
|
|
6569
6813
|
// ../sdk/src/contracts/mcp-tools.contract.ts
|
|
6570
6814
|
var CREATE_BELIEF = {
|
|
6571
6815
|
name: "create_belief",
|
|
6572
|
-
description: "Commit a new belief (knowledge unit) to the reasoning graph. Like `git commit` \u2014 creates an atomic, traceable knowledge object.
|
|
6816
|
+
description: "Commit a new belief (knowledge unit) to the reasoning graph. Like `git commit` \u2014 creates an atomic, traceable knowledge object with a mandatory prior. Creation stores the vacuous opinion `(0, 0, 1, a)`; use modulate_confidence to record the first evidential update.",
|
|
6573
6817
|
parameters: {
|
|
6574
6818
|
canonicalText: {
|
|
6575
6819
|
type: "string",
|
|
6576
6820
|
description: "The belief statement \u2014 what the agent holds to be true"
|
|
6577
6821
|
},
|
|
6578
6822
|
topicId: { type: "string", description: "Topic scope for the belief" },
|
|
6823
|
+
baseRate: {
|
|
6824
|
+
type: "number",
|
|
6825
|
+
description: "Required prior probability used to seed the vacuous opinion `(0, 0, 1, a)` at creation time."
|
|
6826
|
+
},
|
|
6579
6827
|
beliefType: {
|
|
6580
6828
|
type: "string",
|
|
6581
6829
|
description: "Belief type (e.g., hypothesis, belief, principle, invariant, tenet, forecast). Validated against schemaEnumConfig."
|
|
@@ -6585,7 +6833,7 @@ var CREATE_BELIEF = {
|
|
|
6585
6833
|
description: "Optional extra metadata merged into the node (e.g., { codeAnchors: ['path/to/file.ts'] } for coding intelligence)"
|
|
6586
6834
|
}
|
|
6587
6835
|
},
|
|
6588
|
-
required: ["canonicalText", "topicId"],
|
|
6836
|
+
required: ["canonicalText", "topicId", "baseRate"],
|
|
6589
6837
|
response: {
|
|
6590
6838
|
description: "The created canonical belief record",
|
|
6591
6839
|
fields: {
|
|
@@ -6648,17 +6896,43 @@ var REFINE_BELIEF = {
|
|
|
6648
6896
|
};
|
|
6649
6897
|
var MODULATE_CONFIDENCE = {
|
|
6650
6898
|
name: "modulate_confidence",
|
|
6651
|
-
description: "Record a confidence change for a belief. Like `git commit` to the credence log \u2014 an atomic, append-only write. Each modulation is a new entry in the history, not an overwrite. Scoring happens via merge; this tool records the individual data points. Triggers: evidence_added, contradiction_detected,
|
|
6899
|
+
description: "Record a confidence change for a belief. Like `git commit` to the credence log \u2014 an atomic, append-only write. Each modulation is a new entry in the history, not an overwrite. Scoring happens via merge; this tool records the individual data points. Pass the full subjective-logic tuple (`belief`, `disbelief`, `uncertainty`, `baseRate`) directly. If a caller only has a scalar probability, use `@lucern/sdk` helpers `opinionFromBaseRate`, `opinionFromDogmatic`, or `opinionFromProjected` to name the intended interpretation before calling this tool. Triggers: evidence_added, evidence_removed, contradiction_detected, contradiction_resolved, agent_assessment, worktree_outcome, worktree_completed, fusion, discount, deduction, manual, decay.",
|
|
6652
6900
|
parameters: {
|
|
6653
6901
|
nodeId: { type: "string", description: "The belief to score" },
|
|
6654
|
-
|
|
6902
|
+
belief: {
|
|
6903
|
+
type: "number",
|
|
6904
|
+
description: "Subjective-logic belief mass `b` in [0, 1]"
|
|
6905
|
+
},
|
|
6906
|
+
disbelief: {
|
|
6907
|
+
type: "number",
|
|
6908
|
+
description: "Subjective-logic disbelief mass `d` in [0, 1]"
|
|
6909
|
+
},
|
|
6910
|
+
uncertainty: {
|
|
6911
|
+
type: "number",
|
|
6912
|
+
description: "Subjective-logic uncertainty mass `u` in [0, 1]"
|
|
6913
|
+
},
|
|
6914
|
+
baseRate: {
|
|
6915
|
+
type: "number",
|
|
6916
|
+
description: "Subjective-logic base rate `a` in [0, 1]. Required for tuple payloads."
|
|
6917
|
+
},
|
|
6918
|
+
confidence: {
|
|
6919
|
+
type: "number",
|
|
6920
|
+
description: "Deprecated scalar confidence value in [0, 1]. Scalar-only payloads are rejected as AMBIGUOUS_SCALAR."
|
|
6921
|
+
},
|
|
6655
6922
|
trigger: {
|
|
6656
6923
|
type: "string",
|
|
6657
6924
|
description: "What caused this confidence change",
|
|
6658
6925
|
enum: [
|
|
6659
6926
|
"evidence_added",
|
|
6927
|
+
"evidence_removed",
|
|
6660
6928
|
"contradiction_detected",
|
|
6661
|
-
"
|
|
6929
|
+
"contradiction_resolved",
|
|
6930
|
+
"agent_assessment",
|
|
6931
|
+
"worktree_outcome",
|
|
6932
|
+
"worktree_completed",
|
|
6933
|
+
"fusion",
|
|
6934
|
+
"discount",
|
|
6935
|
+
"deduction",
|
|
6662
6936
|
"manual",
|
|
6663
6937
|
"decay"
|
|
6664
6938
|
]
|
|
@@ -6668,7 +6942,7 @@ var MODULATE_CONFIDENCE = {
|
|
|
6668
6942
|
description: "Human-readable explanation of why confidence changed"
|
|
6669
6943
|
}
|
|
6670
6944
|
},
|
|
6671
|
-
required: ["nodeId", "
|
|
6945
|
+
required: ["nodeId", "trigger", "rationale"],
|
|
6672
6946
|
response: {
|
|
6673
6947
|
description: "Confidence modulation result",
|
|
6674
6948
|
fields: {
|
|
@@ -7310,7 +7584,7 @@ var RECORD_JUDGMENT = {
|
|
|
7310
7584
|
status: "string \u2014 'issued'"
|
|
7311
7585
|
}
|
|
7312
7586
|
},
|
|
7313
|
-
ownerModule: "
|
|
7587
|
+
ownerModule: "decisions",
|
|
7314
7588
|
ontologyPrimitive: "judgment",
|
|
7315
7589
|
tier: "showcase"
|
|
7316
7590
|
};
|
|
@@ -8579,7 +8853,7 @@ var INGEST_OBSERVATION = {
|
|
|
8579
8853
|
contextResourceUri: "string"
|
|
8580
8854
|
}
|
|
8581
8855
|
},
|
|
8582
|
-
ownerModule: "agent-
|
|
8856
|
+
ownerModule: "agent-frameworks",
|
|
8583
8857
|
ontologyPrimitive: "graph",
|
|
8584
8858
|
tier: "workhorse"
|
|
8585
8859
|
};
|
|
@@ -8609,7 +8883,7 @@ var GET_OBSERVATION_CONTEXT = {
|
|
|
8609
8883
|
generatedAt: "number"
|
|
8610
8884
|
}
|
|
8611
8885
|
},
|
|
8612
|
-
ownerModule: "agent-
|
|
8886
|
+
ownerModule: "agent-frameworks",
|
|
8613
8887
|
ontologyPrimitive: "graph",
|
|
8614
8888
|
tier: "workhorse"
|
|
8615
8889
|
};
|
|
@@ -9594,11 +9868,13 @@ SDK_MCP_PARITY_METHODS.map(
|
|
|
9594
9868
|
var McpHandlerError = class extends Error {
|
|
9595
9869
|
code;
|
|
9596
9870
|
status;
|
|
9597
|
-
|
|
9871
|
+
suggestion;
|
|
9872
|
+
constructor(message, code = "INVALID_REQUEST", status = 400, suggestion) {
|
|
9598
9873
|
super(message);
|
|
9599
9874
|
this.name = "McpHandlerError";
|
|
9600
9875
|
this.code = code;
|
|
9601
9876
|
this.status = status;
|
|
9877
|
+
this.suggestion = suggestion;
|
|
9602
9878
|
}
|
|
9603
9879
|
};
|
|
9604
9880
|
|
|
@@ -9615,7 +9891,7 @@ function isMissing(value) {
|
|
|
9615
9891
|
}
|
|
9616
9892
|
return false;
|
|
9617
9893
|
}
|
|
9618
|
-
function
|
|
9894
|
+
function readString2(params, key, options = {}) {
|
|
9619
9895
|
const value = params[key];
|
|
9620
9896
|
if (value === void 0 || value === null) {
|
|
9621
9897
|
if (options.required) {
|
|
@@ -9632,7 +9908,7 @@ function readString(params, key, options = {}) {
|
|
|
9632
9908
|
}
|
|
9633
9909
|
return trimmed || void 0;
|
|
9634
9910
|
}
|
|
9635
|
-
function
|
|
9911
|
+
function readNumber2(params, key, options = {}) {
|
|
9636
9912
|
const value = params[key];
|
|
9637
9913
|
if (value === void 0 || value === null) {
|
|
9638
9914
|
if (options.required) {
|
|
@@ -9701,7 +9977,8 @@ function toMcpError(error) {
|
|
|
9701
9977
|
text: JSON.stringify({
|
|
9702
9978
|
code: error.code,
|
|
9703
9979
|
status: error.status,
|
|
9704
|
-
message: error.message
|
|
9980
|
+
message: error.message,
|
|
9981
|
+
suggestion: error.suggestion ?? null
|
|
9705
9982
|
})
|
|
9706
9983
|
}
|
|
9707
9984
|
]
|
|
@@ -9770,6 +10047,45 @@ function contractToHandler(contract, executor) {
|
|
|
9770
10047
|
}
|
|
9771
10048
|
|
|
9772
10049
|
// src/handlers/beliefs.ts
|
|
10050
|
+
var AMBIGUOUS_SCALAR_SUGGESTION = "Use opinion tuple (b, d, u, a) or an @lucern/sdk opinionFromBaseRate/opinionFromDogmatic/opinionFromProjected helper.";
|
|
10051
|
+
function readOpinionTuple(params) {
|
|
10052
|
+
const belief = readNumber2(params, "belief");
|
|
10053
|
+
const disbelief = readNumber2(params, "disbelief");
|
|
10054
|
+
const uncertainty = readNumber2(params, "uncertainty");
|
|
10055
|
+
const baseRate = readNumber2(params, "baseRate");
|
|
10056
|
+
const tupleValues = [belief, disbelief, uncertainty, baseRate];
|
|
10057
|
+
const providedCount = tupleValues.filter(
|
|
10058
|
+
(value) => value !== void 0
|
|
10059
|
+
).length;
|
|
10060
|
+
if (providedCount === 0) {
|
|
10061
|
+
if (readNumber2(params, "confidence") !== void 0) {
|
|
10062
|
+
throw new McpHandlerError(
|
|
10063
|
+
"Scalar confidence input is ambiguous without an explicit subjective-logic interpretation.",
|
|
10064
|
+
"AMBIGUOUS_SCALAR",
|
|
10065
|
+
400,
|
|
10066
|
+
AMBIGUOUS_SCALAR_SUGGESTION
|
|
10067
|
+
);
|
|
10068
|
+
}
|
|
10069
|
+
throw new McpHandlerError(
|
|
10070
|
+
"Missing required opinion tuple: belief, disbelief, uncertainty, and baseRate are required.",
|
|
10071
|
+
"INVALID_REQUEST",
|
|
10072
|
+
400
|
|
10073
|
+
);
|
|
10074
|
+
}
|
|
10075
|
+
if (providedCount !== tupleValues.length) {
|
|
10076
|
+
throw new McpHandlerError(
|
|
10077
|
+
"Incomplete opinion tuple: belief, disbelief, uncertainty, and baseRate must all be provided together.",
|
|
10078
|
+
"INVALID_REQUEST",
|
|
10079
|
+
400
|
|
10080
|
+
);
|
|
10081
|
+
}
|
|
10082
|
+
return {
|
|
10083
|
+
b: belief,
|
|
10084
|
+
d: disbelief,
|
|
10085
|
+
u: uncertainty,
|
|
10086
|
+
a: baseRate
|
|
10087
|
+
};
|
|
10088
|
+
}
|
|
9773
10089
|
function createBeliefHandlers(context) {
|
|
9774
10090
|
const beliefs = createBeliefsClient(context.sdkConfig);
|
|
9775
10091
|
const graph = createGraphClient(context.sdkConfig);
|
|
@@ -9778,13 +10094,14 @@ function createBeliefHandlers(context) {
|
|
|
9778
10094
|
MCP_TOOL_CONTRACTS.create_belief,
|
|
9779
10095
|
async (params) => {
|
|
9780
10096
|
const result = await beliefs.createBelief({
|
|
9781
|
-
canonicalText:
|
|
10097
|
+
canonicalText: readString2(params, "canonicalText", {
|
|
9782
10098
|
required: true
|
|
9783
10099
|
}),
|
|
9784
10100
|
topicId: readTopicId(params, { required: true }),
|
|
9785
|
-
layer:
|
|
9786
|
-
domain:
|
|
9787
|
-
subtype:
|
|
10101
|
+
layer: readString2(params, "layer"),
|
|
10102
|
+
domain: readString2(params, "domain"),
|
|
10103
|
+
subtype: readString2(params, "nodeType"),
|
|
10104
|
+
baseRate: readNumber2(params, "baseRate", { required: true })
|
|
9788
10105
|
});
|
|
9789
10106
|
return {
|
|
9790
10107
|
nodeId: result.data.nodeId,
|
|
@@ -9796,51 +10113,49 @@ function createBeliefHandlers(context) {
|
|
|
9796
10113
|
refine_belief: contractToHandler(
|
|
9797
10114
|
MCP_TOOL_CONTRACTS.refine_belief,
|
|
9798
10115
|
async (params) => {
|
|
9799
|
-
const nodeId =
|
|
9800
|
-
const canonicalText =
|
|
10116
|
+
const nodeId = readString2(params, "nodeId", { required: true });
|
|
10117
|
+
const canonicalText = readString2(params, "canonicalText", {
|
|
9801
10118
|
required: true
|
|
9802
10119
|
});
|
|
9803
|
-
const rationale =
|
|
9804
|
-
const result = await
|
|
9805
|
-
nodeId,
|
|
10120
|
+
const rationale = readString2(params, "rationale");
|
|
10121
|
+
const result = await beliefs.refineBelief(nodeId, {
|
|
9806
10122
|
canonicalText,
|
|
9807
|
-
|
|
9808
|
-
lastRefinementRationale: rationale
|
|
9809
|
-
} : void 0
|
|
10123
|
+
rationale
|
|
9810
10124
|
});
|
|
9811
10125
|
return {
|
|
9812
10126
|
nodeId: result.data.nodeId ?? nodeId,
|
|
9813
10127
|
canonicalText: result.data.canonicalText ?? canonicalText,
|
|
9814
|
-
updatedAt: Date.now()
|
|
10128
|
+
updatedAt: result.data.updatedAt ?? Date.now()
|
|
9815
10129
|
};
|
|
9816
10130
|
}
|
|
9817
10131
|
),
|
|
9818
10132
|
modulate_confidence: contractToHandler(
|
|
9819
10133
|
MCP_TOOL_CONTRACTS.modulate_confidence,
|
|
9820
10134
|
async (params) => {
|
|
9821
|
-
const nodeId =
|
|
10135
|
+
const nodeId = readString2(params, "nodeId", { required: true });
|
|
10136
|
+
const opinion = readOpinionTuple(params);
|
|
9822
10137
|
const result = await beliefs.modulateConfidence(nodeId, {
|
|
9823
|
-
|
|
9824
|
-
trigger:
|
|
9825
|
-
rationale:
|
|
10138
|
+
opinion,
|
|
10139
|
+
trigger: readString2(params, "trigger", { required: true }),
|
|
10140
|
+
rationale: readString2(params, "rationale", { required: true })
|
|
9826
10141
|
});
|
|
9827
10142
|
return {
|
|
9828
10143
|
nodeId,
|
|
9829
|
-
newConfidence: result.data.newConfidence ?? result.data.confidence ??
|
|
10144
|
+
newConfidence: result.data.newConfidence ?? result.data.confidence ?? opinion.b + opinion.a * opinion.u,
|
|
9830
10145
|
previousConfidence: result.data.previousConfidence ?? null,
|
|
9831
|
-
trigger:
|
|
10146
|
+
trigger: readString2(params, "trigger", { required: true })
|
|
9832
10147
|
};
|
|
9833
10148
|
}
|
|
9834
10149
|
),
|
|
9835
10150
|
fork_belief: contractToHandler(
|
|
9836
10151
|
MCP_TOOL_CONTRACTS.fork_belief,
|
|
9837
10152
|
async (params) => {
|
|
9838
|
-
const nodeId =
|
|
9839
|
-
const forkReason =
|
|
10153
|
+
const nodeId = readString2(params, "nodeId", { required: true });
|
|
10154
|
+
const forkReason = readString2(params, "forkReason", {
|
|
9840
10155
|
required: true
|
|
9841
10156
|
});
|
|
9842
10157
|
const result = await beliefs.forkBelief(nodeId, {
|
|
9843
|
-
newFormulation:
|
|
10158
|
+
newFormulation: readString2(params, "newFormulation", {
|
|
9844
10159
|
required: true
|
|
9845
10160
|
}),
|
|
9846
10161
|
forkReason
|
|
@@ -9855,8 +10170,8 @@ function createBeliefHandlers(context) {
|
|
|
9855
10170
|
archive_belief: contractToHandler(
|
|
9856
10171
|
MCP_TOOL_CONTRACTS.archive_belief,
|
|
9857
10172
|
async (params) => {
|
|
9858
|
-
const nodeId =
|
|
9859
|
-
const rationale =
|
|
10173
|
+
const nodeId = readString2(params, "nodeId", { required: true });
|
|
10174
|
+
const rationale = readString2(params, "rationale");
|
|
9860
10175
|
const result = await graph.updateNode({
|
|
9861
10176
|
nodeId,
|
|
9862
10177
|
status: "archived",
|
|
@@ -9883,13 +10198,13 @@ function createContextHandlers(context) {
|
|
|
9883
10198
|
const response = await compiler.compile(
|
|
9884
10199
|
readTopicId(params, { required: true }),
|
|
9885
10200
|
{
|
|
9886
|
-
...
|
|
9887
|
-
...
|
|
9888
|
-
...
|
|
9889
|
-
ranking:
|
|
10201
|
+
...readString2(params, "query") ? { query: readString2(params, "query") } : {},
|
|
10202
|
+
...readNumber2(params, "budget") !== void 0 ? { budget: readNumber2(params, "budget") } : {},
|
|
10203
|
+
...readString2(params, "ranking") ? {
|
|
10204
|
+
ranking: readString2(params, "ranking")
|
|
9890
10205
|
} : {},
|
|
9891
|
-
...
|
|
9892
|
-
...
|
|
10206
|
+
...readNumber2(params, "limit") !== void 0 ? { limit: readNumber2(params, "limit") } : {},
|
|
10207
|
+
...readNumber2(params, "maxDepth") !== void 0 ? { maxDepth: readNumber2(params, "maxDepth") } : {},
|
|
9893
10208
|
...readBoolean(params, "includeEntities") !== void 0 ? { includeEntities: readBoolean(params, "includeEntities") } : {}
|
|
9894
10209
|
}
|
|
9895
10210
|
);
|
|
@@ -9906,14 +10221,14 @@ function createContradictionHandlers(context) {
|
|
|
9906
10221
|
flag_contradiction: contractToHandler(
|
|
9907
10222
|
MCP_TOOL_CONTRACTS.flag_contradiction,
|
|
9908
10223
|
async (params) => {
|
|
9909
|
-
const beliefA =
|
|
9910
|
-
const beliefB =
|
|
9911
|
-
const description =
|
|
10224
|
+
const beliefA = readString2(params, "beliefA", { required: true });
|
|
10225
|
+
const beliefB = readString2(params, "beliefB", { required: true });
|
|
10226
|
+
const description = readString2(params, "description", {
|
|
9912
10227
|
required: true
|
|
9913
10228
|
});
|
|
9914
10229
|
const topicId = readTopicId(params, { required: true });
|
|
9915
|
-
const severity =
|
|
9916
|
-
const defeatType =
|
|
10230
|
+
const severity = readString2(params, "severity") ?? "medium";
|
|
10231
|
+
const defeatType = readString2(params, "defeatType") ?? "rebuts";
|
|
9917
10232
|
const contradiction = await lucern.contradictions.flag({
|
|
9918
10233
|
beliefA,
|
|
9919
10234
|
beliefB,
|
|
@@ -9940,12 +10255,12 @@ function createEdgeHandlers(context) {
|
|
|
9940
10255
|
create_edge: contractToHandler(
|
|
9941
10256
|
MCP_TOOL_CONTRACTS.create_edge,
|
|
9942
10257
|
async (params) => {
|
|
9943
|
-
const sourceId =
|
|
9944
|
-
const targetId =
|
|
9945
|
-
const edgeType =
|
|
9946
|
-
const confidence =
|
|
9947
|
-
const weight =
|
|
9948
|
-
const contextText =
|
|
10258
|
+
const sourceId = readString2(params, "sourceId", { required: true });
|
|
10259
|
+
const targetId = readString2(params, "targetId", { required: true });
|
|
10260
|
+
const edgeType = readString2(params, "edgeType", { required: true });
|
|
10261
|
+
const confidence = readNumber2(params, "confidence");
|
|
10262
|
+
const weight = readNumber2(params, "weight");
|
|
10263
|
+
const contextText = readString2(params, "context") ?? readString2(params, "reasoning");
|
|
9949
10264
|
const edge = await lucern.edges.create({
|
|
9950
10265
|
sourceId,
|
|
9951
10266
|
targetId,
|
|
@@ -9978,15 +10293,15 @@ function createEvidenceHandlers(context) {
|
|
|
9978
10293
|
async (params) => {
|
|
9979
10294
|
const response = await lucern.evidence.create({
|
|
9980
10295
|
topicId: readTopicId(params, { required: true }),
|
|
9981
|
-
text:
|
|
9982
|
-
source:
|
|
9983
|
-
targetId:
|
|
9984
|
-
weight:
|
|
10296
|
+
text: readString2(params, "text", { required: true }),
|
|
10297
|
+
source: readString2(params, "source"),
|
|
10298
|
+
targetId: readString2(params, "targetId"),
|
|
10299
|
+
weight: readNumber2(params, "weight"),
|
|
9985
10300
|
metadata: readMetadata(params),
|
|
9986
|
-
title:
|
|
9987
|
-
content:
|
|
9988
|
-
contentType:
|
|
9989
|
-
kind:
|
|
10301
|
+
title: readString2(params, "title"),
|
|
10302
|
+
content: readString2(params, "content"),
|
|
10303
|
+
contentType: readString2(params, "contentType"),
|
|
10304
|
+
kind: readString2(params, "kind")
|
|
9990
10305
|
});
|
|
9991
10306
|
return response.data;
|
|
9992
10307
|
}
|
|
@@ -9995,7 +10310,7 @@ function createEvidenceHandlers(context) {
|
|
|
9995
10310
|
MCP_TOOL_CONTRACTS.get_evidence,
|
|
9996
10311
|
async (params) => {
|
|
9997
10312
|
const response = await lucern.evidence.get(
|
|
9998
|
-
|
|
10313
|
+
readString2(params, "id", { required: true })
|
|
9999
10314
|
);
|
|
10000
10315
|
return response.data;
|
|
10001
10316
|
}
|
|
@@ -10005,9 +10320,9 @@ function createEvidenceHandlers(context) {
|
|
|
10005
10320
|
async (params) => {
|
|
10006
10321
|
const response = await lucern.evidence.list({
|
|
10007
10322
|
topicId: readTopicId(params),
|
|
10008
|
-
targetId:
|
|
10009
|
-
limit:
|
|
10010
|
-
cursor:
|
|
10323
|
+
targetId: readString2(params, "targetId"),
|
|
10324
|
+
limit: readNumber2(params, "limit"),
|
|
10325
|
+
cursor: readString2(params, "cursor")
|
|
10011
10326
|
});
|
|
10012
10327
|
return response.data;
|
|
10013
10328
|
}
|
|
@@ -10016,10 +10331,10 @@ function createEvidenceHandlers(context) {
|
|
|
10016
10331
|
MCP_TOOL_CONTRACTS.link_evidence,
|
|
10017
10332
|
async (params) => {
|
|
10018
10333
|
const response = await lucern.evidence.link({
|
|
10019
|
-
evidenceId:
|
|
10020
|
-
targetId:
|
|
10021
|
-
weight:
|
|
10022
|
-
rationale:
|
|
10334
|
+
evidenceId: readString2(params, "evidenceId", { required: true }),
|
|
10335
|
+
targetId: readString2(params, "targetId", { required: true }),
|
|
10336
|
+
weight: readNumber2(params, "weight"),
|
|
10337
|
+
rationale: readString2(params, "rationale")
|
|
10023
10338
|
});
|
|
10024
10339
|
return response.data;
|
|
10025
10340
|
}
|
|
@@ -10028,11 +10343,11 @@ function createEvidenceHandlers(context) {
|
|
|
10028
10343
|
MCP_TOOL_CONTRACTS.search_evidence,
|
|
10029
10344
|
async (params) => {
|
|
10030
10345
|
const response = await lucern.evidence.search({
|
|
10031
|
-
q:
|
|
10346
|
+
q: readString2(params, "q") ?? readString2(params, "query", { required: true }),
|
|
10032
10347
|
topicId: readTopicId(params),
|
|
10033
|
-
targetId:
|
|
10034
|
-
limit:
|
|
10035
|
-
cursor:
|
|
10348
|
+
targetId: readString2(params, "targetId"),
|
|
10349
|
+
limit: readNumber2(params, "limit"),
|
|
10350
|
+
cursor: readString2(params, "cursor")
|
|
10036
10351
|
});
|
|
10037
10352
|
return response.data;
|
|
10038
10353
|
}
|
|
@@ -10041,17 +10356,17 @@ function createEvidenceHandlers(context) {
|
|
|
10041
10356
|
MCP_TOOL_CONTRACTS.add_evidence,
|
|
10042
10357
|
async (params) => {
|
|
10043
10358
|
return lucern.evidence.add({
|
|
10044
|
-
canonicalText:
|
|
10359
|
+
canonicalText: readString2(params, "canonicalText", { required: true }),
|
|
10045
10360
|
topicId: readTopicId(params, { required: true }),
|
|
10046
|
-
sourceUrl:
|
|
10361
|
+
sourceUrl: readString2(params, "sourceUrl"),
|
|
10047
10362
|
supports: {
|
|
10048
|
-
nodeId:
|
|
10049
|
-
weight:
|
|
10050
|
-
reasoning:
|
|
10363
|
+
nodeId: readString2(params, "targetNodeId", { required: true }),
|
|
10364
|
+
weight: readNumber2(params, "weight") ?? 1,
|
|
10365
|
+
reasoning: readString2(params, "reasoning")
|
|
10051
10366
|
},
|
|
10052
|
-
title:
|
|
10053
|
-
content:
|
|
10054
|
-
contentType:
|
|
10367
|
+
title: readString2(params, "title"),
|
|
10368
|
+
content: readString2(params, "content"),
|
|
10369
|
+
contentType: readString2(params, "contentType"),
|
|
10055
10370
|
metadata: readMetadata(params)
|
|
10056
10371
|
});
|
|
10057
10372
|
}
|
|
@@ -10060,10 +10375,10 @@ function createEvidenceHandlers(context) {
|
|
|
10060
10375
|
MCP_TOOL_CONTRACTS.link_evidence_to_belief,
|
|
10061
10376
|
async (params) => {
|
|
10062
10377
|
return lucern.evidence.linkToBelief({
|
|
10063
|
-
evidenceId:
|
|
10064
|
-
beliefId:
|
|
10065
|
-
weight:
|
|
10066
|
-
rationale:
|
|
10378
|
+
evidenceId: readString2(params, "evidenceId", { required: true }),
|
|
10379
|
+
beliefId: readString2(params, "beliefId", { required: true }),
|
|
10380
|
+
weight: readNumber2(params, "weight", { required: true }),
|
|
10381
|
+
rationale: readString2(params, "rationale")
|
|
10067
10382
|
});
|
|
10068
10383
|
}
|
|
10069
10384
|
)
|
|
@@ -10178,8 +10493,8 @@ function createGraphHandlers(context) {
|
|
|
10178
10493
|
query_lineage: contractToHandler(
|
|
10179
10494
|
MCP_TOOL_CONTRACTS.query_lineage,
|
|
10180
10495
|
async (params) => {
|
|
10181
|
-
const nodeId =
|
|
10182
|
-
const depth =
|
|
10496
|
+
const nodeId = readString2(params, "nodeId", { required: true });
|
|
10497
|
+
const depth = readNumber2(params, "depth") ?? 5;
|
|
10183
10498
|
const [parentEdgesResponse, childEdgesResponse] = await Promise.all([
|
|
10184
10499
|
graph.queryEdges({
|
|
10185
10500
|
toNodeId: nodeId,
|
|
@@ -10216,7 +10531,7 @@ function createGraphHandlers(context) {
|
|
|
10216
10531
|
get_confidence_history: contractToHandler(
|
|
10217
10532
|
MCP_TOOL_CONTRACTS.get_confidence_history,
|
|
10218
10533
|
async (params) => {
|
|
10219
|
-
const nodeId =
|
|
10534
|
+
const nodeId = readString2(params, "nodeId", { required: true });
|
|
10220
10535
|
const entries = await getConfidenceEntries(nodeId);
|
|
10221
10536
|
return { entries };
|
|
10222
10537
|
}
|
|
@@ -10224,8 +10539,8 @@ function createGraphHandlers(context) {
|
|
|
10224
10539
|
get_audit_trail: contractToHandler(
|
|
10225
10540
|
MCP_TOOL_CONTRACTS.get_audit_trail,
|
|
10226
10541
|
async (params) => {
|
|
10227
|
-
const nodeId =
|
|
10228
|
-
const limit =
|
|
10542
|
+
const nodeId = readString2(params, "nodeId", { required: true });
|
|
10543
|
+
const limit = readNumber2(params, "limit") ?? 50;
|
|
10229
10544
|
const events = await audit.listEvents({ limit: Math.max(1, limit) });
|
|
10230
10545
|
const entries = asAuditArray(events.data).filter((entry) => matchesAuditNodeReference2(entry, nodeId)).slice(0, limit).map((entry) => ({
|
|
10231
10546
|
action: entry.action ?? "unknown",
|
|
@@ -10242,9 +10557,9 @@ function createGraphHandlers(context) {
|
|
|
10242
10557
|
MCP_TOOL_CONTRACTS.traverse_graph,
|
|
10243
10558
|
async (params) => {
|
|
10244
10559
|
const response = await graph.traverse({
|
|
10245
|
-
startNode:
|
|
10246
|
-
direction:
|
|
10247
|
-
maxDepth:
|
|
10560
|
+
startNode: readString2(params, "startNode", { required: true }),
|
|
10561
|
+
direction: readString2(params, "direction"),
|
|
10562
|
+
maxDepth: readNumber2(params, "maxDepth"),
|
|
10248
10563
|
topicId: readTopicId(params)
|
|
10249
10564
|
});
|
|
10250
10565
|
return response.data;
|
|
@@ -10255,9 +10570,9 @@ function createGraphHandlers(context) {
|
|
|
10255
10570
|
async (params) => {
|
|
10256
10571
|
const globalIds = readStringArray(params, "globalIds");
|
|
10257
10572
|
const response = await graph.neighborhood({
|
|
10258
|
-
globalId:
|
|
10573
|
+
globalId: readString2(params, "globalId"),
|
|
10259
10574
|
globalIds: globalIds ? globalIds.join(",") : void 0,
|
|
10260
|
-
maxDepth:
|
|
10575
|
+
maxDepth: readNumber2(params, "maxDepth")
|
|
10261
10576
|
});
|
|
10262
10577
|
return response.data;
|
|
10263
10578
|
}
|
|
@@ -10265,11 +10580,11 @@ function createGraphHandlers(context) {
|
|
|
10265
10580
|
search_beliefs: contractToHandler(
|
|
10266
10581
|
MCP_TOOL_CONTRACTS.search_beliefs,
|
|
10267
10582
|
async (params) => {
|
|
10268
|
-
const query =
|
|
10583
|
+
const query = readString2(params, "query", { required: true });
|
|
10269
10584
|
const topicId = readTopicId(params);
|
|
10270
|
-
const status =
|
|
10271
|
-
const minConfidence =
|
|
10272
|
-
const limit =
|
|
10585
|
+
const status = readString2(params, "status");
|
|
10586
|
+
const minConfidence = readNumber2(params, "minConfidence");
|
|
10587
|
+
const limit = readNumber2(params, "limit") ?? 10;
|
|
10273
10588
|
if (!topicId) {
|
|
10274
10589
|
return { results: [] };
|
|
10275
10590
|
}
|
|
@@ -10295,8 +10610,8 @@ function createGraphHandlers(context) {
|
|
|
10295
10610
|
MCP_TOOL_CONTRACTS.find_contradictions,
|
|
10296
10611
|
async (params) => {
|
|
10297
10612
|
const topicId = readTopicId(params);
|
|
10298
|
-
const nodeId =
|
|
10299
|
-
const status =
|
|
10613
|
+
const nodeId = readString2(params, "nodeId");
|
|
10614
|
+
const status = readString2(params, "status");
|
|
10300
10615
|
if (!topicId && !nodeId) {
|
|
10301
10616
|
return { contradictions: [] };
|
|
10302
10617
|
}
|
|
@@ -10328,8 +10643,8 @@ function createGraphHandlers(context) {
|
|
|
10328
10643
|
bisect_confidence: contractToHandler(
|
|
10329
10644
|
MCP_TOOL_CONTRACTS.bisect_confidence,
|
|
10330
10645
|
async (params) => {
|
|
10331
|
-
const nodeId =
|
|
10332
|
-
const expectedDirection =
|
|
10646
|
+
const nodeId = readString2(params, "nodeId", { required: true });
|
|
10647
|
+
const expectedDirection = readString2(params, "expectedDirection", {
|
|
10333
10648
|
required: true
|
|
10334
10649
|
});
|
|
10335
10650
|
const entries = await getConfidenceEntries(nodeId);
|
|
@@ -10352,7 +10667,7 @@ function createGraphHandlers(context) {
|
|
|
10352
10667
|
if (!await isTopicReadable(topicId)) {
|
|
10353
10668
|
return { topicId, beliefs: [] };
|
|
10354
10669
|
}
|
|
10355
|
-
const threshold =
|
|
10670
|
+
const threshold = readNumber2(params, "threshold") ?? 0.7;
|
|
10356
10671
|
const analytics = await graph.bias({
|
|
10357
10672
|
topicId,
|
|
10358
10673
|
threshold,
|
|
@@ -10426,7 +10741,7 @@ function createGraphHandlers(context) {
|
|
|
10426
10741
|
}
|
|
10427
10742
|
return lucern.graph.gaps({
|
|
10428
10743
|
topicId,
|
|
10429
|
-
minConfidence:
|
|
10744
|
+
minConfidence: readNumber2(params, "minConfidence")
|
|
10430
10745
|
});
|
|
10431
10746
|
}
|
|
10432
10747
|
),
|
|
@@ -10437,9 +10752,9 @@ function createGraphHandlers(context) {
|
|
|
10437
10752
|
if (!await isTopicReadable(topicId)) {
|
|
10438
10753
|
return { beliefs: [] };
|
|
10439
10754
|
}
|
|
10440
|
-
const status =
|
|
10441
|
-
const minConfidence =
|
|
10442
|
-
const worktreeId =
|
|
10755
|
+
const status = readString2(params, "status");
|
|
10756
|
+
const minConfidence = readNumber2(params, "minConfidence");
|
|
10757
|
+
const worktreeId = readString2(params, "worktreeId");
|
|
10443
10758
|
const response = await graph.queryNodes({
|
|
10444
10759
|
topicId,
|
|
10445
10760
|
nodeType: "belief",
|
|
@@ -10486,10 +10801,10 @@ function createJudgmentHandlers(context) {
|
|
|
10486
10801
|
record_judgment: contractToHandler(
|
|
10487
10802
|
MCP_TOOL_CONTRACTS.record_judgment,
|
|
10488
10803
|
async (params) => {
|
|
10489
|
-
const title =
|
|
10490
|
-
const rationale =
|
|
10804
|
+
const title = readString2(params, "title", { required: true });
|
|
10805
|
+
const rationale = readString2(params, "rationale", { required: true });
|
|
10491
10806
|
const topicId = readTopicId(params, { required: true });
|
|
10492
|
-
const confidence =
|
|
10807
|
+
const confidence = readNumber2(params, "confidence");
|
|
10493
10808
|
const beliefIds = readStringArray(params, "beliefIds");
|
|
10494
10809
|
const result = await decisions.recordJudgment({
|
|
10495
10810
|
title,
|
|
@@ -10536,14 +10851,14 @@ function createObservationHandlers(context) {
|
|
|
10536
10851
|
const topicId = readTopicId(params, {
|
|
10537
10852
|
required: true
|
|
10538
10853
|
});
|
|
10539
|
-
const observationType =
|
|
10854
|
+
const observationType = readString2(params, "observationType", {
|
|
10540
10855
|
required: true
|
|
10541
10856
|
});
|
|
10542
|
-
const summary =
|
|
10857
|
+
const summary = readString2(params, "summary", {
|
|
10543
10858
|
required: true
|
|
10544
10859
|
});
|
|
10545
|
-
const source =
|
|
10546
|
-
const confidence =
|
|
10860
|
+
const source = readString2(params, "source");
|
|
10861
|
+
const confidence = readNumber2(params, "confidence");
|
|
10547
10862
|
const tags = readStringArray(params, "tags");
|
|
10548
10863
|
const metadata = readObject(params, "metadata");
|
|
10549
10864
|
const allowedTypes = [
|
|
@@ -10602,8 +10917,8 @@ function createObservationHandlers(context) {
|
|
|
10602
10917
|
const topicId = readTopicId(params, {
|
|
10603
10918
|
required: true
|
|
10604
10919
|
});
|
|
10605
|
-
const query =
|
|
10606
|
-
const limit =
|
|
10920
|
+
const query = readString2(params, "query");
|
|
10921
|
+
const limit = readNumber2(params, "limit");
|
|
10607
10922
|
return observationStore.getContext({
|
|
10608
10923
|
topicId,
|
|
10609
10924
|
query,
|
|
@@ -10622,9 +10937,9 @@ function createPolicyHandlers(context) {
|
|
|
10622
10937
|
MCP_TOOL_CONTRACTS.check_permission,
|
|
10623
10938
|
async (params) => {
|
|
10624
10939
|
const topicId = readTopicId(params, { required: true });
|
|
10625
|
-
const permission =
|
|
10626
|
-
const principal =
|
|
10627
|
-
const beliefClusterId =
|
|
10940
|
+
const permission = readString2(params, "permission", { required: true }) ?? "read";
|
|
10941
|
+
const principal = readString2(params, "principal");
|
|
10942
|
+
const beliefClusterId = readString2(params, "beliefClusterId");
|
|
10628
10943
|
const result = await policy.checkPermission({
|
|
10629
10944
|
topicId,
|
|
10630
10945
|
permission,
|
|
@@ -10646,10 +10961,10 @@ function createPolicyHandlers(context) {
|
|
|
10646
10961
|
MCP_TOOL_CONTRACTS.filter_by_permission,
|
|
10647
10962
|
async (params) => {
|
|
10648
10963
|
const topicIds = readStringArray(params, "topicIds") ?? [];
|
|
10649
|
-
const permission =
|
|
10964
|
+
const permission = readString2(params, "permission", {
|
|
10650
10965
|
required: true
|
|
10651
10966
|
}) ?? "read";
|
|
10652
|
-
const principal =
|
|
10967
|
+
const principal = readString2(params, "principal");
|
|
10653
10968
|
const result = await policy.filterByPermission({
|
|
10654
10969
|
topicIds,
|
|
10655
10970
|
permission,
|
|
@@ -10680,10 +10995,10 @@ function createQuestionHandlers(context) {
|
|
|
10680
10995
|
MCP_TOOL_CONTRACTS.create_question,
|
|
10681
10996
|
async (params) => {
|
|
10682
10997
|
const response = await lucern.questions.create({
|
|
10683
|
-
text:
|
|
10998
|
+
text: readString2(params, "text", { required: true }),
|
|
10684
10999
|
topicId: readTopicId(params, { required: true }),
|
|
10685
|
-
priority:
|
|
10686
|
-
linkedBeliefId:
|
|
11000
|
+
priority: readString2(params, "priority"),
|
|
11001
|
+
linkedBeliefId: readString2(params, "linkedBeliefId"),
|
|
10687
11002
|
metadata: readMetadata2(params)
|
|
10688
11003
|
});
|
|
10689
11004
|
return response.data;
|
|
@@ -10693,7 +11008,7 @@ function createQuestionHandlers(context) {
|
|
|
10693
11008
|
MCP_TOOL_CONTRACTS.get_question,
|
|
10694
11009
|
async (params) => {
|
|
10695
11010
|
const response = await lucern.questions.get(
|
|
10696
|
-
|
|
11011
|
+
readString2(params, "id", { required: true })
|
|
10697
11012
|
);
|
|
10698
11013
|
return response.data;
|
|
10699
11014
|
}
|
|
@@ -10703,11 +11018,11 @@ function createQuestionHandlers(context) {
|
|
|
10703
11018
|
async (params) => {
|
|
10704
11019
|
const response = await lucern.questions.list({
|
|
10705
11020
|
topicId: readTopicId(params, { required: true }),
|
|
10706
|
-
status:
|
|
10707
|
-
priority:
|
|
10708
|
-
worktreeId:
|
|
10709
|
-
limit:
|
|
10710
|
-
cursor:
|
|
11021
|
+
status: readString2(params, "status"),
|
|
11022
|
+
priority: readString2(params, "priority"),
|
|
11023
|
+
worktreeId: readString2(params, "worktreeId"),
|
|
11024
|
+
limit: readNumber2(params, "limit"),
|
|
11025
|
+
cursor: readString2(params, "cursor")
|
|
10711
11026
|
});
|
|
10712
11027
|
return response.data;
|
|
10713
11028
|
}
|
|
@@ -10716,12 +11031,12 @@ function createQuestionHandlers(context) {
|
|
|
10716
11031
|
MCP_TOOL_CONTRACTS.answer_question,
|
|
10717
11032
|
async (params) => {
|
|
10718
11033
|
const response = await lucern.questions.answer(
|
|
10719
|
-
|
|
11034
|
+
readString2(params, "id", { required: true }),
|
|
10720
11035
|
{
|
|
10721
|
-
text:
|
|
10722
|
-
confidence:
|
|
11036
|
+
text: readString2(params, "text", { required: true }),
|
|
11037
|
+
confidence: readString2(params, "confidence"),
|
|
10723
11038
|
evidenceIds: readStringArray(params, "evidenceIds"),
|
|
10724
|
-
rationale:
|
|
11039
|
+
rationale: readString2(params, "rationale")
|
|
10725
11040
|
}
|
|
10726
11041
|
);
|
|
10727
11042
|
return response.data;
|
|
@@ -10731,9 +11046,9 @@ function createQuestionHandlers(context) {
|
|
|
10731
11046
|
MCP_TOOL_CONTRACTS.refine_question,
|
|
10732
11047
|
async (params) => {
|
|
10733
11048
|
const response = await lucern.questions.refine(
|
|
10734
|
-
|
|
10735
|
-
|
|
10736
|
-
|
|
11049
|
+
readString2(params, "id") ?? readString2(params, "questionId", { required: true }),
|
|
11050
|
+
readString2(params, "text", { required: true }),
|
|
11051
|
+
readString2(params, "rationale") ?? readString2(params, "refinementReason")
|
|
10737
11052
|
);
|
|
10738
11053
|
return response.data;
|
|
10739
11054
|
}
|
|
@@ -10742,9 +11057,9 @@ function createQuestionHandlers(context) {
|
|
|
10742
11057
|
MCP_TOOL_CONTRACTS.update_question_status,
|
|
10743
11058
|
async (params) => {
|
|
10744
11059
|
const response = await lucern.questions.updateStatus(
|
|
10745
|
-
|
|
10746
|
-
|
|
10747
|
-
|
|
11060
|
+
readString2(params, "id") ?? readString2(params, "questionId", { required: true }),
|
|
11061
|
+
readString2(params, "status", { required: true }),
|
|
11062
|
+
readString2(params, "rationale")
|
|
10748
11063
|
);
|
|
10749
11064
|
return response.data;
|
|
10750
11065
|
}
|
|
@@ -10753,8 +11068,8 @@ function createQuestionHandlers(context) {
|
|
|
10753
11068
|
MCP_TOOL_CONTRACTS.archive_question,
|
|
10754
11069
|
async (params) => {
|
|
10755
11070
|
return lucern.questions.archive(
|
|
10756
|
-
|
|
10757
|
-
|
|
11071
|
+
readString2(params, "questionId", { required: true }),
|
|
11072
|
+
readString2(params, "reason")
|
|
10758
11073
|
);
|
|
10759
11074
|
}
|
|
10760
11075
|
),
|
|
@@ -10762,10 +11077,10 @@ function createQuestionHandlers(context) {
|
|
|
10762
11077
|
MCP_TOOL_CONTRACTS.link_evidence_to_question,
|
|
10763
11078
|
async (params) => {
|
|
10764
11079
|
return lucern.questions.linkEvidence({
|
|
10765
|
-
evidenceId:
|
|
10766
|
-
questionId:
|
|
10767
|
-
relevance:
|
|
10768
|
-
rationale:
|
|
11080
|
+
evidenceId: readString2(params, "evidenceId", { required: true }),
|
|
11081
|
+
questionId: readString2(params, "questionId", { required: true }),
|
|
11082
|
+
relevance: readNumber2(params, "relevance") ?? 1,
|
|
11083
|
+
rationale: readString2(params, "rationale")
|
|
10769
11084
|
});
|
|
10770
11085
|
}
|
|
10771
11086
|
),
|
|
@@ -10774,7 +11089,7 @@ function createQuestionHandlers(context) {
|
|
|
10774
11089
|
async (params) => {
|
|
10775
11090
|
return lucern.questions.getHighPriority({
|
|
10776
11091
|
topicId: readTopicId(params, { required: true }),
|
|
10777
|
-
limit:
|
|
11092
|
+
limit: readNumber2(params, "limit"),
|
|
10778
11093
|
includeAnswered: readBoolean(params, "includeAnswered")
|
|
10779
11094
|
});
|
|
10780
11095
|
}
|
|
@@ -10784,7 +11099,7 @@ function createQuestionHandlers(context) {
|
|
|
10784
11099
|
async (params) => {
|
|
10785
11100
|
return lucern.questions.findMissing({
|
|
10786
11101
|
topicId: readTopicId(params, { required: true }),
|
|
10787
|
-
minConfidence:
|
|
11102
|
+
minConfidence: readNumber2(params, "minConfidence")
|
|
10788
11103
|
});
|
|
10789
11104
|
}
|
|
10790
11105
|
)
|
|
@@ -10806,7 +11121,7 @@ function asSourceArray(data) {
|
|
|
10806
11121
|
function createResearchHandlers(context) {
|
|
10807
11122
|
const graph = createGraphClient(context.sdkConfig);
|
|
10808
11123
|
const searchSources = async (params) => {
|
|
10809
|
-
const query =
|
|
11124
|
+
const query = readString2(params, "query", { required: true });
|
|
10810
11125
|
const topicId = readTopicId(params);
|
|
10811
11126
|
const sourceTypes = readStringArray(params, "sources") ?? [];
|
|
10812
11127
|
if (!topicId) {
|
|
@@ -10845,9 +11160,9 @@ function createResearchHandlers(context) {
|
|
|
10845
11160
|
execute_deep_research: contractToHandler(
|
|
10846
11161
|
MCP_TOOL_CONTRACTS.execute_deep_research,
|
|
10847
11162
|
async (params) => {
|
|
10848
|
-
const query =
|
|
11163
|
+
const query = readString2(params, "query", { required: true });
|
|
10849
11164
|
const topicId = readTopicId(params, { required: true });
|
|
10850
|
-
const depth =
|
|
11165
|
+
const depth = readString2(params, "depth") ?? "standard";
|
|
10851
11166
|
const sources = await searchSources({
|
|
10852
11167
|
query,
|
|
10853
11168
|
topicId,
|
|
@@ -10883,13 +11198,13 @@ function createSearchHandlers(context) {
|
|
|
10883
11198
|
search_resources: contractToHandler(
|
|
10884
11199
|
MCP_TOOL_CONTRACTS.search_resources,
|
|
10885
11200
|
async (params) => {
|
|
10886
|
-
return lucern.search(
|
|
11201
|
+
return lucern.search(readString2(params, "q", { required: true }), {
|
|
10887
11202
|
topicId: readTopicId(params, { required: true }),
|
|
10888
11203
|
types: readStringArray(params, "types"),
|
|
10889
|
-
status:
|
|
10890
|
-
minConfidence:
|
|
10891
|
-
limit:
|
|
10892
|
-
cursor:
|
|
11204
|
+
status: readString2(params, "status"),
|
|
11205
|
+
minConfidence: readNumber2(params, "minConfidence"),
|
|
11206
|
+
limit: readNumber2(params, "limit"),
|
|
11207
|
+
cursor: readString2(params, "cursor")
|
|
10893
11208
|
});
|
|
10894
11209
|
}
|
|
10895
11210
|
)
|
|
@@ -10903,11 +11218,11 @@ function createTaskHandlers(context) {
|
|
|
10903
11218
|
create_task: contractToHandler(
|
|
10904
11219
|
MCP_TOOL_CONTRACTS.create_task,
|
|
10905
11220
|
async (params) => {
|
|
10906
|
-
const title =
|
|
11221
|
+
const title = readString2(params, "title", { required: true });
|
|
10907
11222
|
const topicId = readTopicId(params, { required: true });
|
|
10908
|
-
const taskType =
|
|
10909
|
-
const linkedQuestionId =
|
|
10910
|
-
const linkedWorktreeId =
|
|
11223
|
+
const taskType = readString2(params, "taskType");
|
|
11224
|
+
const linkedQuestionId = readString2(params, "linkedQuestionId");
|
|
11225
|
+
const linkedWorktreeId = readString2(params, "linkedWorktreeId");
|
|
10911
11226
|
const result = await workflow.createTask({
|
|
10912
11227
|
title,
|
|
10913
11228
|
topicId,
|
|
@@ -10925,8 +11240,8 @@ function createTaskHandlers(context) {
|
|
|
10925
11240
|
complete_task: contractToHandler(
|
|
10926
11241
|
MCP_TOOL_CONTRACTS.complete_task,
|
|
10927
11242
|
async (params) => {
|
|
10928
|
-
const taskId =
|
|
10929
|
-
const outputSummary =
|
|
11243
|
+
const taskId = readString2(params, "taskId", { required: true });
|
|
11244
|
+
const outputSummary = readString2(params, "outputSummary", {
|
|
10930
11245
|
required: true
|
|
10931
11246
|
});
|
|
10932
11247
|
const evidenceCreated = readBoolean(params, "evidenceCreated");
|
|
@@ -10944,15 +11259,15 @@ function createTaskHandlers(context) {
|
|
|
10944
11259
|
update_task: contractToHandler(
|
|
10945
11260
|
MCP_TOOL_CONTRACTS.update_task,
|
|
10946
11261
|
async (params) => {
|
|
10947
|
-
const taskId =
|
|
10948
|
-
const title =
|
|
10949
|
-
const description =
|
|
10950
|
-
const linkedBeliefId =
|
|
10951
|
-
const linkedQuestionId =
|
|
10952
|
-
const linkedWorktreeId =
|
|
10953
|
-
const rawPriority =
|
|
11262
|
+
const taskId = readString2(params, "taskId", { required: true });
|
|
11263
|
+
const title = readString2(params, "title");
|
|
11264
|
+
const description = readString2(params, "description");
|
|
11265
|
+
const linkedBeliefId = readString2(params, "linkedBeliefId");
|
|
11266
|
+
const linkedQuestionId = readString2(params, "linkedQuestionId");
|
|
11267
|
+
const linkedWorktreeId = readString2(params, "linkedWorktreeId");
|
|
11268
|
+
const rawPriority = readString2(params, "priority");
|
|
10954
11269
|
const priority = rawPriority === "critical" || rawPriority === "high" || rawPriority === "medium" || rawPriority === "low" ? rawPriority : void 0;
|
|
10955
|
-
const rawStatus =
|
|
11270
|
+
const rawStatus = readString2(params, "status");
|
|
10956
11271
|
const status = rawStatus === "todo" || rawStatus === "in_progress" || rawStatus === "blocked" || rawStatus === "done" ? rawStatus : void 0;
|
|
10957
11272
|
const result = await workflow.updateTask(taskId, {
|
|
10958
11273
|
title,
|
|
@@ -10990,11 +11305,11 @@ function createWorktreeHandlers(context) {
|
|
|
10990
11305
|
return {
|
|
10991
11306
|
create_lens: contractToHandler(MCP_TOOL_CONTRACTS.create_lens, async (params) => {
|
|
10992
11307
|
const result = await workflow.createLens({
|
|
10993
|
-
name:
|
|
10994
|
-
workspaceId:
|
|
11308
|
+
name: readString2(params, "name", { required: true }),
|
|
11309
|
+
workspaceId: readString2(params, "workspaceId"),
|
|
10995
11310
|
topicId: readTopicId(params),
|
|
10996
|
-
description:
|
|
10997
|
-
perspectiveType:
|
|
11311
|
+
description: readString2(params, "description"),
|
|
11312
|
+
perspectiveType: readString2(params, "perspectiveType", {
|
|
10998
11313
|
required: true
|
|
10999
11314
|
}),
|
|
11000
11315
|
promptTemplates: Array.isArray(params.promptTemplates) ? params.promptTemplates : void 0,
|
|
@@ -11004,17 +11319,17 @@ function createWorktreeHandlers(context) {
|
|
|
11004
11319
|
});
|
|
11005
11320
|
return {
|
|
11006
11321
|
lensId: result.data.lensId ?? "",
|
|
11007
|
-
name: result.data.name ??
|
|
11008
|
-
workspaceId: result.data.workspaceId ??
|
|
11322
|
+
name: result.data.name ?? readString2(params, "name", { required: true }),
|
|
11323
|
+
workspaceId: result.data.workspaceId ?? readString2(params, "workspaceId") ?? null,
|
|
11009
11324
|
status: result.data.status ?? "active"
|
|
11010
11325
|
};
|
|
11011
11326
|
}),
|
|
11012
11327
|
list_lenses: contractToHandler(MCP_TOOL_CONTRACTS.list_lenses, async (params) => {
|
|
11013
11328
|
const result = await workflow.listLenses({
|
|
11014
|
-
workspaceId:
|
|
11329
|
+
workspaceId: readString2(params, "workspaceId"),
|
|
11015
11330
|
topicId: readTopicId(params),
|
|
11016
|
-
status:
|
|
11017
|
-
perspectiveType:
|
|
11331
|
+
status: readString2(params, "status"),
|
|
11332
|
+
perspectiveType: readString2(params, "perspectiveType")
|
|
11018
11333
|
});
|
|
11019
11334
|
return {
|
|
11020
11335
|
lenses: result.data.items ?? ("lenses" in result.data && Array.isArray(result.data.lenses) ? result.data.lenses : [])
|
|
@@ -11024,7 +11339,7 @@ function createWorktreeHandlers(context) {
|
|
|
11024
11339
|
MCP_TOOL_CONTRACTS.apply_lens_to_topic,
|
|
11025
11340
|
async (params) => {
|
|
11026
11341
|
const topicId = readTopicId(params, { required: true });
|
|
11027
|
-
const lensId =
|
|
11342
|
+
const lensId = readString2(params, "lensId", { required: true });
|
|
11028
11343
|
const result = await workflow.applyLensToTopic({
|
|
11029
11344
|
lensId,
|
|
11030
11345
|
topicId,
|
|
@@ -11042,7 +11357,7 @@ function createWorktreeHandlers(context) {
|
|
|
11042
11357
|
MCP_TOOL_CONTRACTS.remove_lens_from_topic,
|
|
11043
11358
|
async (params) => {
|
|
11044
11359
|
const topicId = readTopicId(params, { required: true });
|
|
11045
|
-
const lensId =
|
|
11360
|
+
const lensId = readString2(params, "lensId", { required: true });
|
|
11046
11361
|
const result = await workflow.removeLensFromTopic({
|
|
11047
11362
|
lensId,
|
|
11048
11363
|
topicId
|
|
@@ -11063,18 +11378,18 @@ function createWorktreeHandlers(context) {
|
|
|
11063
11378
|
throw new Error("add_worktree requires topicId");
|
|
11064
11379
|
}
|
|
11065
11380
|
const result = await workflow.addWorktree({
|
|
11066
|
-
title:
|
|
11381
|
+
title: readString2(params, "title", { required: true }),
|
|
11067
11382
|
topicId,
|
|
11068
|
-
branchId:
|
|
11069
|
-
objective:
|
|
11070
|
-
hypothesis:
|
|
11383
|
+
branchId: readString2(params, "branchId"),
|
|
11384
|
+
objective: readString2(params, "objective"),
|
|
11385
|
+
hypothesis: readString2(params, "hypothesis"),
|
|
11071
11386
|
beliefIds: readStringArray(params, "beliefIds"),
|
|
11072
11387
|
autoShape: readBoolean(params, "autoShape"),
|
|
11073
|
-
domainPackId:
|
|
11388
|
+
domainPackId: readString2(params, "domainPackId"),
|
|
11074
11389
|
executionOrder: typeof params.executionOrder === "number" ? params.executionOrder : void 0,
|
|
11075
11390
|
dependsOn: readStringArray(params, "dependsOn"),
|
|
11076
11391
|
blocks: readStringArray(params, "blocks"),
|
|
11077
|
-
gate:
|
|
11392
|
+
gate: readString2(params, "gate")
|
|
11078
11393
|
});
|
|
11079
11394
|
return {
|
|
11080
11395
|
worktreeId: result.data.worktreeId,
|
|
@@ -11091,11 +11406,11 @@ function createWorktreeHandlers(context) {
|
|
|
11091
11406
|
}
|
|
11092
11407
|
),
|
|
11093
11408
|
merge: contractToHandler(MCP_TOOL_CONTRACTS.merge, async (params) => {
|
|
11094
|
-
const worktreeId =
|
|
11409
|
+
const worktreeId = readString2(params, "worktreeId", { required: true });
|
|
11095
11410
|
const outcomes = Array.isArray(params.outcomes) ? params.outcomes : [];
|
|
11096
11411
|
const result = await workflow.merge(worktreeId, {
|
|
11097
11412
|
outcomes,
|
|
11098
|
-
summary:
|
|
11413
|
+
summary: readString2(params, "summary")
|
|
11099
11414
|
});
|
|
11100
11415
|
return {
|
|
11101
11416
|
worktreeId: result.data.worktreeId ?? worktreeId,
|
|
@@ -11104,8 +11419,8 @@ function createWorktreeHandlers(context) {
|
|
|
11104
11419
|
};
|
|
11105
11420
|
}),
|
|
11106
11421
|
push: contractToHandler(MCP_TOOL_CONTRACTS.push, async (params) => {
|
|
11107
|
-
const worktreeId =
|
|
11108
|
-
const targetContext =
|
|
11422
|
+
const worktreeId = readString2(params, "worktreeId", { required: true });
|
|
11423
|
+
const targetContext = readString2(params, "targetContext", {
|
|
11109
11424
|
required: true
|
|
11110
11425
|
});
|
|
11111
11426
|
const result = await workflow.push(worktreeId, {
|
|
@@ -11121,10 +11436,10 @@ function createWorktreeHandlers(context) {
|
|
|
11121
11436
|
open_pull_request: contractToHandler(
|
|
11122
11437
|
MCP_TOOL_CONTRACTS.open_pull_request,
|
|
11123
11438
|
async (params) => {
|
|
11124
|
-
const worktreeId =
|
|
11439
|
+
const worktreeId = readString2(params, "worktreeId", {
|
|
11125
11440
|
required: true
|
|
11126
11441
|
});
|
|
11127
|
-
const summary =
|
|
11442
|
+
const summary = readString2(params, "summary", { required: true });
|
|
11128
11443
|
const reviewers = readStringArray(params, "reviewers");
|
|
11129
11444
|
const result = await workflow.openPullRequest(worktreeId, {
|
|
11130
11445
|
summary,
|
|
@@ -11141,7 +11456,7 @@ function createWorktreeHandlers(context) {
|
|
|
11141
11456
|
MCP_TOOL_CONTRACTS.list_worktrees,
|
|
11142
11457
|
async (params) => {
|
|
11143
11458
|
const topicId = readTopicId(params, { required: true });
|
|
11144
|
-
const status = mapWorktreeStatus(
|
|
11459
|
+
const status = mapWorktreeStatus(readString2(params, "status"));
|
|
11145
11460
|
const result = await workflow.listWorktrees({
|
|
11146
11461
|
topicId,
|
|
11147
11462
|
status
|
|
@@ -12181,7 +12496,7 @@ async function runLucernMcpCli(argv = process.argv.slice(2)) {
|
|
|
12181
12496
|
}
|
|
12182
12497
|
}
|
|
12183
12498
|
|
|
12184
|
-
// src/
|
|
12499
|
+
// src/toolContracts.ts
|
|
12185
12500
|
function pickToolContracts(names) {
|
|
12186
12501
|
return Object.fromEntries(
|
|
12187
12502
|
names.flatMap((name) => {
|
|
@@ -12224,16 +12539,16 @@ var SCOPE_MCP_TOOLS = pickToolContracts([
|
|
|
12224
12539
|
"trigger_belief_review"
|
|
12225
12540
|
]);
|
|
12226
12541
|
|
|
12227
|
-
// src/
|
|
12228
|
-
var
|
|
12542
|
+
// src/authenticatedHandlers.ts
|
|
12543
|
+
var GATEWAY_HANDLER_TOOL_NAMES = [
|
|
12229
12544
|
...Object.keys(SCOPE_MCP_TOOLS),
|
|
12230
12545
|
...Object.keys(COORDINATION_MCP_TOOLS),
|
|
12231
12546
|
...Object.keys(EPISTEMIC_CONTRACT_MCP_TOOLS),
|
|
12232
12547
|
...Object.keys(BOOTSTRAP_MCP_TOOLS)
|
|
12233
12548
|
];
|
|
12234
|
-
function
|
|
12549
|
+
function buildGatewayClient(ctx) {
|
|
12235
12550
|
if (!ctx.gatewayBaseUrl || !ctx.getAuthHeaders) {
|
|
12236
|
-
throw new Error("
|
|
12551
|
+
throw new Error("MCP gateway bridge requires auth headers.");
|
|
12237
12552
|
}
|
|
12238
12553
|
return createGatewayRequestClient({
|
|
12239
12554
|
baseUrl: ctx.gatewayBaseUrl,
|
|
@@ -12246,12 +12561,12 @@ function withSessionId(args, ctx) {
|
|
|
12246
12561
|
__sdkSessionId: ctx.sessionId
|
|
12247
12562
|
};
|
|
12248
12563
|
}
|
|
12249
|
-
async function
|
|
12564
|
+
async function buildAuthenticatedHandlerMap() {
|
|
12250
12565
|
return Object.fromEntries(
|
|
12251
|
-
|
|
12566
|
+
GATEWAY_HANDLER_TOOL_NAMES.map((toolName) => [
|
|
12252
12567
|
toolName,
|
|
12253
12568
|
async (args, ctx) => {
|
|
12254
|
-
const gateway =
|
|
12569
|
+
const gateway = buildGatewayClient(ctx);
|
|
12255
12570
|
const response = await gateway.request({
|
|
12256
12571
|
path: `/api/platform/v1/mcp-tools/${encodeURIComponent(toolName)}`,
|
|
12257
12572
|
method: "POST",
|
|
@@ -12320,7 +12635,7 @@ function parseCredentialsFile(filePath) {
|
|
|
12320
12635
|
}
|
|
12321
12636
|
return result;
|
|
12322
12637
|
}
|
|
12323
|
-
function
|
|
12638
|
+
function resolveMcpCredentials() {
|
|
12324
12639
|
if (process.env.LUCERN_CONVEX_URL && process.env.LUCERN_DEPLOY_KEY) {
|
|
12325
12640
|
return {
|
|
12326
12641
|
lucernResolved: true,
|
|
@@ -12438,7 +12753,7 @@ function initializeLucernScriptEnv() {
|
|
|
12438
12753
|
}
|
|
12439
12754
|
}
|
|
12440
12755
|
}
|
|
12441
|
-
|
|
12756
|
+
resolveMcpCredentials();
|
|
12442
12757
|
lucernScriptEnvInitialized = true;
|
|
12443
12758
|
}
|
|
12444
12759
|
function readArg(name, fallback) {
|
|
@@ -12485,7 +12800,7 @@ async function createLucernMcpClient() {
|
|
|
12485
12800
|
const deployKey = requireEnv("LUCERN_DEPLOY_KEY");
|
|
12486
12801
|
const transport = new StdioClientTransport({
|
|
12487
12802
|
command: "npx",
|
|
12488
|
-
args: ["tsx", "
|
|
12803
|
+
args: ["tsx", "apps/mcp-server/src/index.ts"],
|
|
12489
12804
|
env: {
|
|
12490
12805
|
...process.env,
|
|
12491
12806
|
LUCERN_CONVEX_URL: convexUrl,
|
|
@@ -12509,7 +12824,7 @@ function createLucernAdminClient() {
|
|
|
12509
12824
|
}
|
|
12510
12825
|
async function resolveMcpSessionTenantId() {
|
|
12511
12826
|
initializeLucernScriptEnv();
|
|
12512
|
-
const apiKey =
|
|
12827
|
+
const apiKey = resolveMcpCredentials().rawLucernApiKey;
|
|
12513
12828
|
if (!apiKey) {
|
|
12514
12829
|
return void 0;
|
|
12515
12830
|
}
|
|
@@ -12538,8 +12853,8 @@ async function closeMcpClient(client) {
|
|
|
12538
12853
|
await client.close();
|
|
12539
12854
|
}
|
|
12540
12855
|
|
|
12541
|
-
// src/
|
|
12542
|
-
async function
|
|
12856
|
+
// src/discovery.ts
|
|
12857
|
+
async function loadDiscoveryHandlers() {
|
|
12543
12858
|
return {
|
|
12544
12859
|
async discover(args, ctx) {
|
|
12545
12860
|
const query = typeof args.query === "string" ? args.query : "";
|
|
@@ -12862,6 +13177,6 @@ function validateContextPackSchema2(payload) {
|
|
|
12862
13177
|
};
|
|
12863
13178
|
}
|
|
12864
13179
|
|
|
12865
|
-
export { BOOTSTRAP_MCP_TOOLS, COORDINATION_MCP_TOOLS, EPISTEMIC_CONTRACT_MCP_TOOLS, LUCERN_AGENT_MD, LUCERN_MCP_RESOURCE_URIS, LUCERN_MCP_TOOL_NAMES, LUCERN_OBSERVER_PROMPT_NAME, McpObservationStore, SCOPE_MCP_TOOLS,
|
|
13180
|
+
export { BOOTSTRAP_MCP_TOOLS, COORDINATION_MCP_TOOLS, EPISTEMIC_CONTRACT_MCP_TOOLS, LUCERN_AGENT_MD, LUCERN_MCP_RESOURCE_URIS, LUCERN_MCP_TOOL_NAMES, LUCERN_OBSERVER_PROMPT_NAME, McpObservationStore, SCOPE_MCP_TOOLS, buildAuthenticatedHandlerMap, buildLucernObserverPrompt, callMcpTool, classifyTransportParityDrift, closeMcpClient, createLucernAdminClient, createLucernMcpClient, createLucernMcpHttpRequestHandler, createLucernMcpServer, createLucernStandaloneMcpServer, createMcpHandlerRegistry, createToolExecutionEnvelope, executeToolWithEnvelope, initializeLucernScriptEnv, loadDiscoveryHandlers, parseToolExecutionMetadata, readArg, resolveMcpCredentials, resolveMcpSessionTenantId, runLucernMcpCli, startLucernMcpHttpServer, startLucernMcpStdioServer, validateContextPackSchema2 as validateContextPackSchema };
|
|
12866
13181
|
//# sourceMappingURL=index.js.map
|
|
12867
13182
|
//# sourceMappingURL=index.js.map
|