@lucern/mcp 0.2.0-alpha.6 → 0.2.0-alpha.8
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 +129 -131
- package/dist/gateway.js +7265 -6756
- package/dist/gateway.js.map +1 -1
- package/dist/index.d.ts +7 -7
- package/dist/index.js +572 -223
- package/dist/index.js.map +1 -1
- package/dist/runtime.js +946 -4275
- package/dist/runtime.js.map +1 -1
- package/package.json +4 -5
package/dist/index.js
CHANGED
|
@@ -263,6 +263,38 @@ function scoreObservation(record, terms) {
|
|
|
263
263
|
return score;
|
|
264
264
|
}
|
|
265
265
|
|
|
266
|
+
// ../sdk/src/opinion.ts
|
|
267
|
+
function clamp01(value) {
|
|
268
|
+
if (!Number.isFinite(value)) {
|
|
269
|
+
return 0;
|
|
270
|
+
}
|
|
271
|
+
return Math.max(0, Math.min(1, value));
|
|
272
|
+
}
|
|
273
|
+
function vacuous(baseRate = 0.5) {
|
|
274
|
+
return { b: 0, d: 0, u: 1, a: clamp01(baseRate) };
|
|
275
|
+
}
|
|
276
|
+
function dogmatic(probability, baseRate = 0.5) {
|
|
277
|
+
const p = clamp01(probability);
|
|
278
|
+
return { b: p, d: 1 - p, u: 0, a: clamp01(baseRate) };
|
|
279
|
+
}
|
|
280
|
+
function opinionFromBaseRate(probability) {
|
|
281
|
+
return vacuous(clamp01(probability));
|
|
282
|
+
}
|
|
283
|
+
function opinionFromDogmatic(probability, baseRate = 0.5) {
|
|
284
|
+
return dogmatic(clamp01(probability), clamp01(baseRate));
|
|
285
|
+
}
|
|
286
|
+
function opinionFromProjected(probability, uncertainty, baseRate = 0.5) {
|
|
287
|
+
const p = clamp01(probability);
|
|
288
|
+
const u = clamp01(uncertainty);
|
|
289
|
+
const remainingMass = 1 - u;
|
|
290
|
+
return {
|
|
291
|
+
b: p * remainingMass,
|
|
292
|
+
d: (1 - p) * remainingMass,
|
|
293
|
+
u,
|
|
294
|
+
a: clamp01(baseRate)
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
|
|
266
298
|
// ../sdk/src/coreClient.ts
|
|
267
299
|
var LucernApiError = class extends Error {
|
|
268
300
|
code;
|
|
@@ -1261,31 +1293,168 @@ function createAuditClient(config = {}) {
|
|
|
1261
1293
|
}
|
|
1262
1294
|
|
|
1263
1295
|
// ../sdk/src/beliefsClient.ts
|
|
1296
|
+
function asRecord2(value) {
|
|
1297
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
1298
|
+
}
|
|
1299
|
+
function readString(value) {
|
|
1300
|
+
if (typeof value !== "string") {
|
|
1301
|
+
return void 0;
|
|
1302
|
+
}
|
|
1303
|
+
const normalized = value.trim();
|
|
1304
|
+
return normalized.length > 0 ? normalized : void 0;
|
|
1305
|
+
}
|
|
1306
|
+
function readNumber(value) {
|
|
1307
|
+
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
1308
|
+
}
|
|
1309
|
+
function clamp012(value) {
|
|
1310
|
+
return Math.max(0, Math.min(1, value));
|
|
1311
|
+
}
|
|
1312
|
+
function normalizeOpinionTuple(record) {
|
|
1313
|
+
const opinion = asRecord2(record.opinion);
|
|
1314
|
+
const rawBelief = readNumber(opinion.b) ?? readNumber(record.belief);
|
|
1315
|
+
const rawDisbelief = readNumber(opinion.d) ?? readNumber(record.disbelief);
|
|
1316
|
+
const rawUncertainty = readNumber(opinion.u) ?? readNumber(record.uncertainty);
|
|
1317
|
+
const rawBaseRate = readNumber(opinion.a) ?? readNumber(record.baseRate);
|
|
1318
|
+
if (rawBelief === void 0 && rawDisbelief === void 0 && rawUncertainty === void 0) {
|
|
1319
|
+
const projected = clamp012(readNumber(record.confidence) ?? 0);
|
|
1320
|
+
return {
|
|
1321
|
+
b: projected,
|
|
1322
|
+
d: 1 - projected,
|
|
1323
|
+
u: 0,
|
|
1324
|
+
a: 0.5
|
|
1325
|
+
};
|
|
1326
|
+
}
|
|
1327
|
+
return {
|
|
1328
|
+
b: clamp012(rawBelief ?? 0),
|
|
1329
|
+
d: clamp012(rawDisbelief ?? 0),
|
|
1330
|
+
u: clamp012(rawUncertainty ?? 0),
|
|
1331
|
+
a: clamp012(rawBaseRate ?? 0.5)
|
|
1332
|
+
};
|
|
1333
|
+
}
|
|
1334
|
+
function mapOpinionHistoryEntriesFromGatewayData(payload) {
|
|
1335
|
+
const entries = Array.isArray(payload.entries) ? payload.entries : [];
|
|
1336
|
+
return entries.map((value) => {
|
|
1337
|
+
const record = asRecord2(value);
|
|
1338
|
+
const tuple = normalizeOpinionTuple(record);
|
|
1339
|
+
const projected = readNumber(record.confidence) ?? clamp012(tuple.b + tuple.a * tuple.u);
|
|
1340
|
+
const triggeringEvidenceId = readString(record.triggeringEvidenceId);
|
|
1341
|
+
const triggeringWorktreeId = readString(record.triggeringWorktreeId);
|
|
1342
|
+
return {
|
|
1343
|
+
t: readNumber(record.timestamp) ?? readNumber(record.assessedAt) ?? 0,
|
|
1344
|
+
b: tuple.b,
|
|
1345
|
+
d: tuple.d,
|
|
1346
|
+
u: tuple.u,
|
|
1347
|
+
a: tuple.a,
|
|
1348
|
+
P: clamp012(projected),
|
|
1349
|
+
trigger: readString(record.trigger) ?? "manual",
|
|
1350
|
+
...triggeringEvidenceId ? {
|
|
1351
|
+
triggeringRef: {
|
|
1352
|
+
kind: "evidence",
|
|
1353
|
+
id: triggeringEvidenceId
|
|
1354
|
+
}
|
|
1355
|
+
} : triggeringWorktreeId ? {
|
|
1356
|
+
triggeringRef: {
|
|
1357
|
+
kind: "worktree",
|
|
1358
|
+
id: triggeringWorktreeId
|
|
1359
|
+
}
|
|
1360
|
+
} : {},
|
|
1361
|
+
...readString(record.rationale) ? { rationale: readString(record.rationale) } : {},
|
|
1362
|
+
...readString(record.userId) ? { userId: readString(record.userId) } : {},
|
|
1363
|
+
...readString(record.slOperator) ? { slOperator: readString(record.slOperator) } : {}
|
|
1364
|
+
};
|
|
1365
|
+
}).sort((left, right) => left.t - right.t);
|
|
1366
|
+
}
|
|
1367
|
+
function normalizeModulateConfidenceInput(input) {
|
|
1368
|
+
const opinion = "opinion" in input ? input.opinion : input.interpretation === "base_rate" ? opinionFromBaseRate(input.confidence) : input.interpretation === "dogmatic" ? opinionFromDogmatic(input.confidence, input.baseRate) : opinionFromProjected(
|
|
1369
|
+
input.confidence,
|
|
1370
|
+
input.uncertainty,
|
|
1371
|
+
input.baseRate
|
|
1372
|
+
);
|
|
1373
|
+
return {
|
|
1374
|
+
belief: opinion.b,
|
|
1375
|
+
disbelief: opinion.d,
|
|
1376
|
+
uncertainty: opinion.u,
|
|
1377
|
+
baseRate: opinion.a,
|
|
1378
|
+
trigger: input.trigger,
|
|
1379
|
+
rationale: input.rationale,
|
|
1380
|
+
maxInlinePropagationTargets: input.maxInlinePropagationTargets
|
|
1381
|
+
};
|
|
1382
|
+
}
|
|
1264
1383
|
function createBeliefsClient(config = {}) {
|
|
1265
1384
|
const gateway = createGatewayRequestClient(config);
|
|
1385
|
+
function requireBaseRate2(value) {
|
|
1386
|
+
const baseRate = readNumber(value);
|
|
1387
|
+
if (baseRate === void 0) {
|
|
1388
|
+
throw new Error("baseRate is required for belief creation.");
|
|
1389
|
+
}
|
|
1390
|
+
if (baseRate < 0 || baseRate > 1) {
|
|
1391
|
+
throw new Error("baseRate must be within [0, 1].");
|
|
1392
|
+
}
|
|
1393
|
+
return baseRate;
|
|
1394
|
+
}
|
|
1395
|
+
const modulateConfidence = async (beliefId, input, idempotencyKey) => gateway.request({
|
|
1396
|
+
path: `/api/platform/v1/beliefs/${encodeURIComponent(beliefId)}/confidence`,
|
|
1397
|
+
method: "POST",
|
|
1398
|
+
body: normalizeModulateConfidenceInput(input),
|
|
1399
|
+
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
1400
|
+
});
|
|
1401
|
+
async function getOpinionHistory(beliefId) {
|
|
1402
|
+
const response = await gateway.request({
|
|
1403
|
+
path: `/api/platform/v1/beliefs/${encodeURIComponent(beliefId)}/confidence-history`
|
|
1404
|
+
});
|
|
1405
|
+
return mapOpinionHistoryEntriesFromGatewayData(response.data);
|
|
1406
|
+
}
|
|
1266
1407
|
return {
|
|
1267
1408
|
/**
|
|
1268
1409
|
* Create a belief within a topic scope.
|
|
1269
1410
|
*/
|
|
1270
1411
|
async createBelief(input, idempotencyKey) {
|
|
1412
|
+
const baseRate = requireBaseRate2(input.baseRate);
|
|
1271
1413
|
return gateway.request({
|
|
1272
1414
|
path: "/api/platform/v1/beliefs",
|
|
1273
1415
|
method: "POST",
|
|
1274
|
-
body:
|
|
1416
|
+
body: {
|
|
1417
|
+
...normalizeNodeWriteInput(input),
|
|
1418
|
+
baseRate
|
|
1419
|
+
},
|
|
1275
1420
|
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
1276
1421
|
});
|
|
1277
1422
|
},
|
|
1278
1423
|
/**
|
|
1279
|
-
*
|
|
1424
|
+
* Refine a draft belief in place.
|
|
1280
1425
|
*/
|
|
1281
|
-
async
|
|
1426
|
+
async refineBelief(beliefId, input, idempotencyKey) {
|
|
1282
1427
|
return gateway.request({
|
|
1283
|
-
path: `/api/platform/v1/beliefs/${encodeURIComponent(beliefId)}
|
|
1284
|
-
method: "
|
|
1285
|
-
body: input,
|
|
1428
|
+
path: `/api/platform/v1/beliefs/${encodeURIComponent(beliefId)}`,
|
|
1429
|
+
method: "PATCH",
|
|
1430
|
+
body: normalizeNodeWriteInput(input),
|
|
1286
1431
|
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
1287
1432
|
});
|
|
1288
1433
|
},
|
|
1434
|
+
/**
|
|
1435
|
+
* Record a confidence change for an existing belief.
|
|
1436
|
+
*/
|
|
1437
|
+
modulateConfidence,
|
|
1438
|
+
/**
|
|
1439
|
+
* Returns the belief's confidence trajectory as a chronological array.
|
|
1440
|
+
*
|
|
1441
|
+
* Canonical UI trend shape (what every trend component consumes):
|
|
1442
|
+
* { t: number, b: number, d: number, u: number, a: number, P: number, trigger: string, triggeringRef?: { kind: "evidence" | "worktree"; id: string } }[]
|
|
1443
|
+
*
|
|
1444
|
+
* Where:
|
|
1445
|
+
* t = assessedAt (epoch ms)
|
|
1446
|
+
* b, d, u, a = Opinion 4-tuple components
|
|
1447
|
+
* P = projected probability = b + a*u (precomputed for UI convenience)
|
|
1448
|
+
* trigger = cause of the score change
|
|
1449
|
+
* triggeringRef = optional pointer to the evidence or worktree that drove the change
|
|
1450
|
+
*/
|
|
1451
|
+
async getOpinionHistory(beliefId) {
|
|
1452
|
+
return getOpinionHistory(beliefId);
|
|
1453
|
+
},
|
|
1454
|
+
/** @deprecated Use getOpinionHistory(). */
|
|
1455
|
+
async getConfidenceHistory(beliefId) {
|
|
1456
|
+
return getOpinionHistory(beliefId);
|
|
1457
|
+
},
|
|
1289
1458
|
/**
|
|
1290
1459
|
* Fork a scored belief into a new formulation.
|
|
1291
1460
|
*/
|
|
@@ -1376,6 +1545,57 @@ function createBeliefsClient(config = {}) {
|
|
|
1376
1545
|
}
|
|
1377
1546
|
};
|
|
1378
1547
|
}
|
|
1548
|
+
|
|
1549
|
+
// ../sdk/src/sourcesClient.ts
|
|
1550
|
+
function createSourcesClient(config = {}) {
|
|
1551
|
+
const gateway = createGatewayRequestClient(config);
|
|
1552
|
+
return {
|
|
1553
|
+
async upsert(spec, idempotencyKey = randomIdempotencyKey()) {
|
|
1554
|
+
return gateway.request({
|
|
1555
|
+
path: "/api/platform/v1/sources/upsert",
|
|
1556
|
+
method: "POST",
|
|
1557
|
+
body: spec,
|
|
1558
|
+
idempotencyKey
|
|
1559
|
+
});
|
|
1560
|
+
},
|
|
1561
|
+
async get(sourceId) {
|
|
1562
|
+
return gateway.request({
|
|
1563
|
+
path: `/api/platform/v1/sources/${encodeURIComponent(sourceId)}`
|
|
1564
|
+
});
|
|
1565
|
+
}
|
|
1566
|
+
};
|
|
1567
|
+
}
|
|
1568
|
+
|
|
1569
|
+
// ../sdk/src/evidenceClient.ts
|
|
1570
|
+
function createEvidenceClient(config = {}) {
|
|
1571
|
+
const gateway = createGatewayRequestClient(config);
|
|
1572
|
+
return {
|
|
1573
|
+
async classifyEvidence(beliefId, evidenceId, classificationConfig, idempotencyKey) {
|
|
1574
|
+
return gateway.request({
|
|
1575
|
+
path: "/api/platform/v1/evidence/classify",
|
|
1576
|
+
method: "POST",
|
|
1577
|
+
body: {
|
|
1578
|
+
beliefId,
|
|
1579
|
+
evidenceId,
|
|
1580
|
+
config: classificationConfig
|
|
1581
|
+
},
|
|
1582
|
+
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
1583
|
+
});
|
|
1584
|
+
},
|
|
1585
|
+
async classifyEvidenceBatch(beliefId, evidence, classificationConfig, idempotencyKey) {
|
|
1586
|
+
return gateway.request({
|
|
1587
|
+
path: "/api/platform/v1/evidence/classify-batch",
|
|
1588
|
+
method: "POST",
|
|
1589
|
+
body: {
|
|
1590
|
+
beliefId,
|
|
1591
|
+
evidence,
|
|
1592
|
+
config: classificationConfig
|
|
1593
|
+
},
|
|
1594
|
+
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
1595
|
+
});
|
|
1596
|
+
}
|
|
1597
|
+
};
|
|
1598
|
+
}
|
|
1379
1599
|
var DEFAULT_CUSTOM_NAMESPACE = "custom";
|
|
1380
1600
|
var RESERVED_NAMESPACES = /* @__PURE__ */ new Set(["lucern"]);
|
|
1381
1601
|
var CustomToolRegistryError = class extends Error {
|
|
@@ -2165,14 +2385,14 @@ function createIdentityClient(config = {}) {
|
|
|
2165
2385
|
}
|
|
2166
2386
|
|
|
2167
2387
|
// ../sdk/src/topicsClient.ts
|
|
2168
|
-
function
|
|
2388
|
+
function asRecord3(value) {
|
|
2169
2389
|
return value && typeof value === "object" ? value : {};
|
|
2170
2390
|
}
|
|
2171
2391
|
function cleanString2(value) {
|
|
2172
2392
|
return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
|
|
2173
2393
|
}
|
|
2174
2394
|
function normalizeTopicRecord(value) {
|
|
2175
|
-
const record =
|
|
2395
|
+
const record = asRecord3(value);
|
|
2176
2396
|
const topicId = cleanString2(record.topicId) ?? cleanString2(record.id) ?? cleanString2(record._id);
|
|
2177
2397
|
return withTopicAlias({
|
|
2178
2398
|
...record,
|
|
@@ -2197,7 +2417,7 @@ function createTopicsClient(config = {}) {
|
|
|
2197
2417
|
})}`
|
|
2198
2418
|
}).then(
|
|
2199
2419
|
(response) => mapGatewayData(response, (data) => {
|
|
2200
|
-
const record =
|
|
2420
|
+
const record = asRecord3(data);
|
|
2201
2421
|
const items = Array.isArray(record.topics) ? record.topics.map(normalizeTopicRecord) : [];
|
|
2202
2422
|
return {
|
|
2203
2423
|
...createListResult(items, "topics"),
|
|
@@ -2214,7 +2434,7 @@ function createTopicsClient(config = {}) {
|
|
|
2214
2434
|
}).then(
|
|
2215
2435
|
(response) => mapGatewayData(
|
|
2216
2436
|
response,
|
|
2217
|
-
(data) => normalizeTopicRecord(
|
|
2437
|
+
(data) => normalizeTopicRecord(asRecord3(data).topic ?? data)
|
|
2218
2438
|
)
|
|
2219
2439
|
);
|
|
2220
2440
|
},
|
|
@@ -2250,7 +2470,7 @@ function createTopicsClient(config = {}) {
|
|
|
2250
2470
|
)}`
|
|
2251
2471
|
}).then(
|
|
2252
2472
|
(response) => mapGatewayData(response, (data) => {
|
|
2253
|
-
const record =
|
|
2473
|
+
const record = asRecord3(data);
|
|
2254
2474
|
return {
|
|
2255
2475
|
tree: Array.isArray(record.tree) ? record.tree.map(normalizeTopicTreeNode) : []
|
|
2256
2476
|
};
|
|
@@ -2284,6 +2504,22 @@ function createTopicsClient(config = {}) {
|
|
|
2284
2504
|
}
|
|
2285
2505
|
|
|
2286
2506
|
// ../sdk/src/gatewayFacades.ts
|
|
2507
|
+
function normalizeBeliefConfidenceInput(input) {
|
|
2508
|
+
const opinion = "opinion" in input ? input.opinion : input.interpretation === "base_rate" ? opinionFromBaseRate(input.confidence) : input.interpretation === "dogmatic" ? opinionFromDogmatic(input.confidence, input.baseRate) : opinionFromProjected(
|
|
2509
|
+
input.confidence,
|
|
2510
|
+
input.uncertainty,
|
|
2511
|
+
input.baseRate
|
|
2512
|
+
);
|
|
2513
|
+
return {
|
|
2514
|
+
belief: opinion.b,
|
|
2515
|
+
disbelief: opinion.d,
|
|
2516
|
+
uncertainty: opinion.u,
|
|
2517
|
+
baseRate: opinion.a,
|
|
2518
|
+
trigger: input.trigger,
|
|
2519
|
+
rationale: input.rationale,
|
|
2520
|
+
maxInlinePropagationTargets: input.maxInlinePropagationTargets
|
|
2521
|
+
};
|
|
2522
|
+
}
|
|
2287
2523
|
function serializeTypes(types) {
|
|
2288
2524
|
return Array.isArray(types) && types.length > 0 ? types.join(",") : void 0;
|
|
2289
2525
|
}
|
|
@@ -2335,7 +2571,7 @@ function createBeliefsFacade(config = {}) {
|
|
|
2335
2571
|
return gateway.request({
|
|
2336
2572
|
path: `/api/platform/v1/beliefs/${encodeURIComponent(id)}/confidence`,
|
|
2337
2573
|
method: "POST",
|
|
2338
|
-
body: input,
|
|
2574
|
+
body: normalizeBeliefConfidenceInput(input),
|
|
2339
2575
|
idempotencyKey
|
|
2340
2576
|
});
|
|
2341
2577
|
},
|
|
@@ -2413,6 +2649,11 @@ function createBeliefsFacade(config = {}) {
|
|
|
2413
2649
|
path: `/api/platform/v1/beliefs/${encodeURIComponent(id)}/confidence-history`
|
|
2414
2650
|
});
|
|
2415
2651
|
},
|
|
2652
|
+
async opinionHistory(id) {
|
|
2653
|
+
return gateway.request({
|
|
2654
|
+
path: `/api/platform/v1/beliefs/${encodeURIComponent(id)}/confidence-history`
|
|
2655
|
+
});
|
|
2656
|
+
},
|
|
2416
2657
|
async createContract(id, input, idempotencyKey = randomIdempotencyKey()) {
|
|
2417
2658
|
return gateway.request({
|
|
2418
2659
|
path: `/api/platform/v1/beliefs/${encodeURIComponent(id)}/contracts`,
|
|
@@ -4892,13 +5133,24 @@ function requireText(args) {
|
|
|
4892
5133
|
}
|
|
4893
5134
|
return text;
|
|
4894
5135
|
}
|
|
5136
|
+
function requireBaseRate(args) {
|
|
5137
|
+
if (typeof args.baseRate !== "number" || !Number.isFinite(args.baseRate)) {
|
|
5138
|
+
throw new Error("baseRate is required.");
|
|
5139
|
+
}
|
|
5140
|
+
if (args.baseRate < 0 || args.baseRate > 1) {
|
|
5141
|
+
throw new Error("baseRate must be within [0, 1].");
|
|
5142
|
+
}
|
|
5143
|
+
return args.baseRate;
|
|
5144
|
+
}
|
|
4895
5145
|
function exposeGatewayData(response) {
|
|
4896
5146
|
return Object.assign({}, response, response.data);
|
|
4897
5147
|
}
|
|
4898
5148
|
function createLucernClient(config = {}) {
|
|
4899
5149
|
const gatewayConfig = toGatewayConfig(config);
|
|
4900
5150
|
const beliefsClient = createBeliefsClient(gatewayConfig);
|
|
5151
|
+
const sourcesClient = createSourcesClient(gatewayConfig);
|
|
4901
5152
|
const beliefsFacade = createBeliefsFacade(gatewayConfig);
|
|
5153
|
+
const evidenceClient = createEvidenceClient(gatewayConfig);
|
|
4902
5154
|
const graphClient = createGraphClient(gatewayConfig);
|
|
4903
5155
|
const graphFacade = createGraphFacade(gatewayConfig);
|
|
4904
5156
|
const decisionsClient = createDecisionsClient(gatewayConfig);
|
|
@@ -5139,6 +5391,10 @@ function createLucernClient(config = {}) {
|
|
|
5139
5391
|
async function getConfidenceHistory(nodeId) {
|
|
5140
5392
|
return beliefsFacade.confidenceHistory(nodeId).then(exposeGatewayData);
|
|
5141
5393
|
}
|
|
5394
|
+
async function getOpinionHistory(nodeId) {
|
|
5395
|
+
const response = await beliefsFacade.opinionHistory(nodeId);
|
|
5396
|
+
return mapOpinionHistoryEntriesFromGatewayData(response.data);
|
|
5397
|
+
}
|
|
5142
5398
|
async function getAuditTrail(nodeId, limit = 50) {
|
|
5143
5399
|
const events = await auditClient.listEvents({ limit });
|
|
5144
5400
|
const entries = asListItems(events.data, "events").filter((event) => matchesAuditNodeReference(event, nodeId)).slice(0, limit).map((event) => {
|
|
@@ -5324,6 +5580,7 @@ function createLucernClient(config = {}) {
|
|
|
5324
5580
|
rationale: input.rationale,
|
|
5325
5581
|
worktreeId: input.worktreeId,
|
|
5326
5582
|
pillar: input.pillar,
|
|
5583
|
+
baseRate: requireBaseRate(input),
|
|
5327
5584
|
sourceBeliefIds: input.sourceBeliefIds,
|
|
5328
5585
|
sourceType: input.sourceType,
|
|
5329
5586
|
beliefType: input.beliefType,
|
|
@@ -5397,6 +5654,9 @@ function createLucernClient(config = {}) {
|
|
|
5397
5654
|
confidenceHistory(nodeId) {
|
|
5398
5655
|
return beliefsFacade.confidenceHistory(nodeId).then(exposeGatewayData);
|
|
5399
5656
|
},
|
|
5657
|
+
opinionHistory(nodeId) {
|
|
5658
|
+
return getOpinionHistory(nodeId);
|
|
5659
|
+
},
|
|
5400
5660
|
createContract(nodeId, input) {
|
|
5401
5661
|
return beliefsFacade.createContract(nodeId, input).then(exposeGatewayData);
|
|
5402
5662
|
},
|
|
@@ -5528,6 +5788,12 @@ function createLucernClient(config = {}) {
|
|
|
5528
5788
|
beliefId: args.beliefId
|
|
5529
5789
|
}));
|
|
5530
5790
|
},
|
|
5791
|
+
classifyEvidence(beliefId, evidenceId, config2, idempotencyKey) {
|
|
5792
|
+
return evidenceClient.classifyEvidence(beliefId, evidenceId, config2, idempotencyKey).then(exposeGatewayData);
|
|
5793
|
+
},
|
|
5794
|
+
classifyEvidenceBatch(beliefId, evidence, config2, idempotencyKey) {
|
|
5795
|
+
return evidenceClient.classifyEvidenceBatch(beliefId, evidence, config2, idempotencyKey).then(exposeGatewayData);
|
|
5796
|
+
},
|
|
5531
5797
|
updateStatus(input, idempotencyKey) {
|
|
5532
5798
|
return evidenceFacade.updateStatus(input, idempotencyKey).then(exposeGatewayData);
|
|
5533
5799
|
},
|
|
@@ -5544,6 +5810,14 @@ function createLucernClient(config = {}) {
|
|
|
5544
5810
|
return evidenceFacade.updateVerificationStatus(input, idempotencyKey).then(exposeGatewayData);
|
|
5545
5811
|
}
|
|
5546
5812
|
},
|
|
5813
|
+
sources: {
|
|
5814
|
+
upsert(input, idempotencyKey) {
|
|
5815
|
+
return sourcesClient.upsert(input, idempotencyKey).then(exposeGatewayData);
|
|
5816
|
+
},
|
|
5817
|
+
get(sourceId) {
|
|
5818
|
+
return sourcesClient.get(sourceId).then(exposeGatewayData);
|
|
5819
|
+
}
|
|
5820
|
+
},
|
|
5547
5821
|
questions: {
|
|
5548
5822
|
create(args) {
|
|
5549
5823
|
return questionsFacade.create({
|
|
@@ -5669,6 +5943,7 @@ function createLucernClient(config = {}) {
|
|
|
5669
5943
|
},
|
|
5670
5944
|
queryLineage,
|
|
5671
5945
|
getConfidenceHistory,
|
|
5946
|
+
getOpinionHistory,
|
|
5672
5947
|
getAuditTrail,
|
|
5673
5948
|
traverse(args) {
|
|
5674
5949
|
return graphFacade.traverse({
|
|
@@ -6371,6 +6646,8 @@ function createLucernClient(config = {}) {
|
|
|
6371
6646
|
extensions: extensionNamespaces,
|
|
6372
6647
|
raw: {
|
|
6373
6648
|
beliefs: beliefsClient,
|
|
6649
|
+
sources: sourcesClient,
|
|
6650
|
+
evidence: evidenceClient,
|
|
6374
6651
|
graph: graphClient,
|
|
6375
6652
|
decisions: decisionsClient,
|
|
6376
6653
|
workflow: workflowClient,
|
|
@@ -6569,13 +6846,17 @@ var LENS_PERSPECTIVE_TYPES = [
|
|
|
6569
6846
|
// ../sdk/src/contracts/mcp-tools.contract.ts
|
|
6570
6847
|
var CREATE_BELIEF = {
|
|
6571
6848
|
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.
|
|
6849
|
+
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
6850
|
parameters: {
|
|
6574
6851
|
canonicalText: {
|
|
6575
6852
|
type: "string",
|
|
6576
6853
|
description: "The belief statement \u2014 what the agent holds to be true"
|
|
6577
6854
|
},
|
|
6578
6855
|
topicId: { type: "string", description: "Topic scope for the belief" },
|
|
6856
|
+
baseRate: {
|
|
6857
|
+
type: "number",
|
|
6858
|
+
description: "Required prior probability used to seed the vacuous opinion `(0, 0, 1, a)` at creation time."
|
|
6859
|
+
},
|
|
6579
6860
|
beliefType: {
|
|
6580
6861
|
type: "string",
|
|
6581
6862
|
description: "Belief type (e.g., hypothesis, belief, principle, invariant, tenet, forecast). Validated against schemaEnumConfig."
|
|
@@ -6585,7 +6866,7 @@ var CREATE_BELIEF = {
|
|
|
6585
6866
|
description: "Optional extra metadata merged into the node (e.g., { codeAnchors: ['path/to/file.ts'] } for coding intelligence)"
|
|
6586
6867
|
}
|
|
6587
6868
|
},
|
|
6588
|
-
required: ["canonicalText", "topicId"],
|
|
6869
|
+
required: ["canonicalText", "topicId", "baseRate"],
|
|
6589
6870
|
response: {
|
|
6590
6871
|
description: "The created canonical belief record",
|
|
6591
6872
|
fields: {
|
|
@@ -6648,17 +6929,43 @@ var REFINE_BELIEF = {
|
|
|
6648
6929
|
};
|
|
6649
6930
|
var MODULATE_CONFIDENCE = {
|
|
6650
6931
|
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,
|
|
6932
|
+
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
6933
|
parameters: {
|
|
6653
6934
|
nodeId: { type: "string", description: "The belief to score" },
|
|
6654
|
-
|
|
6935
|
+
belief: {
|
|
6936
|
+
type: "number",
|
|
6937
|
+
description: "Subjective-logic belief mass `b` in [0, 1]"
|
|
6938
|
+
},
|
|
6939
|
+
disbelief: {
|
|
6940
|
+
type: "number",
|
|
6941
|
+
description: "Subjective-logic disbelief mass `d` in [0, 1]"
|
|
6942
|
+
},
|
|
6943
|
+
uncertainty: {
|
|
6944
|
+
type: "number",
|
|
6945
|
+
description: "Subjective-logic uncertainty mass `u` in [0, 1]"
|
|
6946
|
+
},
|
|
6947
|
+
baseRate: {
|
|
6948
|
+
type: "number",
|
|
6949
|
+
description: "Subjective-logic base rate `a` in [0, 1]. Required for tuple payloads."
|
|
6950
|
+
},
|
|
6951
|
+
confidence: {
|
|
6952
|
+
type: "number",
|
|
6953
|
+
description: "Deprecated scalar confidence value in [0, 1]. Scalar-only payloads are rejected as AMBIGUOUS_SCALAR."
|
|
6954
|
+
},
|
|
6655
6955
|
trigger: {
|
|
6656
6956
|
type: "string",
|
|
6657
6957
|
description: "What caused this confidence change",
|
|
6658
6958
|
enum: [
|
|
6659
6959
|
"evidence_added",
|
|
6960
|
+
"evidence_removed",
|
|
6660
6961
|
"contradiction_detected",
|
|
6661
|
-
"
|
|
6962
|
+
"contradiction_resolved",
|
|
6963
|
+
"agent_assessment",
|
|
6964
|
+
"worktree_outcome",
|
|
6965
|
+
"worktree_completed",
|
|
6966
|
+
"fusion",
|
|
6967
|
+
"discount",
|
|
6968
|
+
"deduction",
|
|
6662
6969
|
"manual",
|
|
6663
6970
|
"decay"
|
|
6664
6971
|
]
|
|
@@ -6668,7 +6975,7 @@ var MODULATE_CONFIDENCE = {
|
|
|
6668
6975
|
description: "Human-readable explanation of why confidence changed"
|
|
6669
6976
|
}
|
|
6670
6977
|
},
|
|
6671
|
-
required: ["nodeId", "
|
|
6978
|
+
required: ["nodeId", "trigger", "rationale"],
|
|
6672
6979
|
response: {
|
|
6673
6980
|
description: "Confidence modulation result",
|
|
6674
6981
|
fields: {
|
|
@@ -7310,7 +7617,7 @@ var RECORD_JUDGMENT = {
|
|
|
7310
7617
|
status: "string \u2014 'issued'"
|
|
7311
7618
|
}
|
|
7312
7619
|
},
|
|
7313
|
-
ownerModule: "
|
|
7620
|
+
ownerModule: "decisions",
|
|
7314
7621
|
ontologyPrimitive: "judgment",
|
|
7315
7622
|
tier: "showcase"
|
|
7316
7623
|
};
|
|
@@ -8579,7 +8886,7 @@ var INGEST_OBSERVATION = {
|
|
|
8579
8886
|
contextResourceUri: "string"
|
|
8580
8887
|
}
|
|
8581
8888
|
},
|
|
8582
|
-
ownerModule: "agent-
|
|
8889
|
+
ownerModule: "agent-frameworks",
|
|
8583
8890
|
ontologyPrimitive: "graph",
|
|
8584
8891
|
tier: "workhorse"
|
|
8585
8892
|
};
|
|
@@ -8609,7 +8916,7 @@ var GET_OBSERVATION_CONTEXT = {
|
|
|
8609
8916
|
generatedAt: "number"
|
|
8610
8917
|
}
|
|
8611
8918
|
},
|
|
8612
|
-
ownerModule: "agent-
|
|
8919
|
+
ownerModule: "agent-frameworks",
|
|
8613
8920
|
ontologyPrimitive: "graph",
|
|
8614
8921
|
tier: "workhorse"
|
|
8615
8922
|
};
|
|
@@ -9527,6 +9834,7 @@ var MCP_TOOL_CONTRACTS = {
|
|
|
9527
9834
|
deprecate_ontology_version: DEPRECATE_ONTOLOGY_VERSION,
|
|
9528
9835
|
resolve_effective_ontology: RESOLVE_EFFECTIVE_ONTOLOGY
|
|
9529
9836
|
};
|
|
9837
|
+
globalThis.process?.env;
|
|
9530
9838
|
|
|
9531
9839
|
// ../sdk/src/mcpParitySurface.ts
|
|
9532
9840
|
var SDK_MCP_PARITY_METHODS = [
|
|
@@ -9594,11 +9902,13 @@ SDK_MCP_PARITY_METHODS.map(
|
|
|
9594
9902
|
var McpHandlerError = class extends Error {
|
|
9595
9903
|
code;
|
|
9596
9904
|
status;
|
|
9597
|
-
|
|
9905
|
+
suggestion;
|
|
9906
|
+
constructor(message, code = "INVALID_REQUEST", status = 400, suggestion) {
|
|
9598
9907
|
super(message);
|
|
9599
9908
|
this.name = "McpHandlerError";
|
|
9600
9909
|
this.code = code;
|
|
9601
9910
|
this.status = status;
|
|
9911
|
+
this.suggestion = suggestion;
|
|
9602
9912
|
}
|
|
9603
9913
|
};
|
|
9604
9914
|
|
|
@@ -9615,7 +9925,7 @@ function isMissing(value) {
|
|
|
9615
9925
|
}
|
|
9616
9926
|
return false;
|
|
9617
9927
|
}
|
|
9618
|
-
function
|
|
9928
|
+
function readString2(params, key, options = {}) {
|
|
9619
9929
|
const value = params[key];
|
|
9620
9930
|
if (value === void 0 || value === null) {
|
|
9621
9931
|
if (options.required) {
|
|
@@ -9632,7 +9942,7 @@ function readString(params, key, options = {}) {
|
|
|
9632
9942
|
}
|
|
9633
9943
|
return trimmed || void 0;
|
|
9634
9944
|
}
|
|
9635
|
-
function
|
|
9945
|
+
function readNumber2(params, key, options = {}) {
|
|
9636
9946
|
const value = params[key];
|
|
9637
9947
|
if (value === void 0 || value === null) {
|
|
9638
9948
|
if (options.required) {
|
|
@@ -9701,7 +10011,8 @@ function toMcpError(error) {
|
|
|
9701
10011
|
text: JSON.stringify({
|
|
9702
10012
|
code: error.code,
|
|
9703
10013
|
status: error.status,
|
|
9704
|
-
message: error.message
|
|
10014
|
+
message: error.message,
|
|
10015
|
+
suggestion: error.suggestion ?? null
|
|
9705
10016
|
})
|
|
9706
10017
|
}
|
|
9707
10018
|
]
|
|
@@ -9770,6 +10081,45 @@ function contractToHandler(contract, executor) {
|
|
|
9770
10081
|
}
|
|
9771
10082
|
|
|
9772
10083
|
// src/handlers/beliefs.ts
|
|
10084
|
+
var AMBIGUOUS_SCALAR_SUGGESTION = "Use opinion tuple (b, d, u, a) or an @lucern/sdk opinionFromBaseRate/opinionFromDogmatic/opinionFromProjected helper.";
|
|
10085
|
+
function readOpinionTuple(params) {
|
|
10086
|
+
const belief = readNumber2(params, "belief");
|
|
10087
|
+
const disbelief = readNumber2(params, "disbelief");
|
|
10088
|
+
const uncertainty = readNumber2(params, "uncertainty");
|
|
10089
|
+
const baseRate = readNumber2(params, "baseRate");
|
|
10090
|
+
const tupleValues = [belief, disbelief, uncertainty, baseRate];
|
|
10091
|
+
const providedCount = tupleValues.filter(
|
|
10092
|
+
(value) => value !== void 0
|
|
10093
|
+
).length;
|
|
10094
|
+
if (providedCount === 0) {
|
|
10095
|
+
if (readNumber2(params, "confidence") !== void 0) {
|
|
10096
|
+
throw new McpHandlerError(
|
|
10097
|
+
"Scalar confidence input is ambiguous without an explicit subjective-logic interpretation.",
|
|
10098
|
+
"AMBIGUOUS_SCALAR",
|
|
10099
|
+
400,
|
|
10100
|
+
AMBIGUOUS_SCALAR_SUGGESTION
|
|
10101
|
+
);
|
|
10102
|
+
}
|
|
10103
|
+
throw new McpHandlerError(
|
|
10104
|
+
"Missing required opinion tuple: belief, disbelief, uncertainty, and baseRate are required.",
|
|
10105
|
+
"INVALID_REQUEST",
|
|
10106
|
+
400
|
|
10107
|
+
);
|
|
10108
|
+
}
|
|
10109
|
+
if (providedCount !== tupleValues.length) {
|
|
10110
|
+
throw new McpHandlerError(
|
|
10111
|
+
"Incomplete opinion tuple: belief, disbelief, uncertainty, and baseRate must all be provided together.",
|
|
10112
|
+
"INVALID_REQUEST",
|
|
10113
|
+
400
|
|
10114
|
+
);
|
|
10115
|
+
}
|
|
10116
|
+
return {
|
|
10117
|
+
b: belief,
|
|
10118
|
+
d: disbelief,
|
|
10119
|
+
u: uncertainty,
|
|
10120
|
+
a: baseRate
|
|
10121
|
+
};
|
|
10122
|
+
}
|
|
9773
10123
|
function createBeliefHandlers(context) {
|
|
9774
10124
|
const beliefs = createBeliefsClient(context.sdkConfig);
|
|
9775
10125
|
const graph = createGraphClient(context.sdkConfig);
|
|
@@ -9778,13 +10128,14 @@ function createBeliefHandlers(context) {
|
|
|
9778
10128
|
MCP_TOOL_CONTRACTS.create_belief,
|
|
9779
10129
|
async (params) => {
|
|
9780
10130
|
const result = await beliefs.createBelief({
|
|
9781
|
-
canonicalText:
|
|
10131
|
+
canonicalText: readString2(params, "canonicalText", {
|
|
9782
10132
|
required: true
|
|
9783
10133
|
}),
|
|
9784
10134
|
topicId: readTopicId(params, { required: true }),
|
|
9785
|
-
layer:
|
|
9786
|
-
domain:
|
|
9787
|
-
subtype:
|
|
10135
|
+
layer: readString2(params, "layer"),
|
|
10136
|
+
domain: readString2(params, "domain"),
|
|
10137
|
+
subtype: readString2(params, "nodeType"),
|
|
10138
|
+
baseRate: readNumber2(params, "baseRate", { required: true })
|
|
9788
10139
|
});
|
|
9789
10140
|
return {
|
|
9790
10141
|
nodeId: result.data.nodeId,
|
|
@@ -9796,51 +10147,49 @@ function createBeliefHandlers(context) {
|
|
|
9796
10147
|
refine_belief: contractToHandler(
|
|
9797
10148
|
MCP_TOOL_CONTRACTS.refine_belief,
|
|
9798
10149
|
async (params) => {
|
|
9799
|
-
const nodeId =
|
|
9800
|
-
const canonicalText =
|
|
10150
|
+
const nodeId = readString2(params, "nodeId", { required: true });
|
|
10151
|
+
const canonicalText = readString2(params, "canonicalText", {
|
|
9801
10152
|
required: true
|
|
9802
10153
|
});
|
|
9803
|
-
const rationale =
|
|
9804
|
-
const result = await
|
|
9805
|
-
nodeId,
|
|
10154
|
+
const rationale = readString2(params, "rationale");
|
|
10155
|
+
const result = await beliefs.refineBelief(nodeId, {
|
|
9806
10156
|
canonicalText,
|
|
9807
|
-
|
|
9808
|
-
lastRefinementRationale: rationale
|
|
9809
|
-
} : void 0
|
|
10157
|
+
rationale
|
|
9810
10158
|
});
|
|
9811
10159
|
return {
|
|
9812
10160
|
nodeId: result.data.nodeId ?? nodeId,
|
|
9813
10161
|
canonicalText: result.data.canonicalText ?? canonicalText,
|
|
9814
|
-
updatedAt: Date.now()
|
|
10162
|
+
updatedAt: result.data.updatedAt ?? Date.now()
|
|
9815
10163
|
};
|
|
9816
10164
|
}
|
|
9817
10165
|
),
|
|
9818
10166
|
modulate_confidence: contractToHandler(
|
|
9819
10167
|
MCP_TOOL_CONTRACTS.modulate_confidence,
|
|
9820
10168
|
async (params) => {
|
|
9821
|
-
const nodeId =
|
|
10169
|
+
const nodeId = readString2(params, "nodeId", { required: true });
|
|
10170
|
+
const opinion = readOpinionTuple(params);
|
|
9822
10171
|
const result = await beliefs.modulateConfidence(nodeId, {
|
|
9823
|
-
|
|
9824
|
-
trigger:
|
|
9825
|
-
rationale:
|
|
10172
|
+
opinion,
|
|
10173
|
+
trigger: readString2(params, "trigger", { required: true }),
|
|
10174
|
+
rationale: readString2(params, "rationale", { required: true })
|
|
9826
10175
|
});
|
|
9827
10176
|
return {
|
|
9828
10177
|
nodeId,
|
|
9829
|
-
newConfidence: result.data.newConfidence ?? result.data.confidence ??
|
|
10178
|
+
newConfidence: result.data.newConfidence ?? result.data.confidence ?? opinion.b + opinion.a * opinion.u,
|
|
9830
10179
|
previousConfidence: result.data.previousConfidence ?? null,
|
|
9831
|
-
trigger:
|
|
10180
|
+
trigger: readString2(params, "trigger", { required: true })
|
|
9832
10181
|
};
|
|
9833
10182
|
}
|
|
9834
10183
|
),
|
|
9835
10184
|
fork_belief: contractToHandler(
|
|
9836
10185
|
MCP_TOOL_CONTRACTS.fork_belief,
|
|
9837
10186
|
async (params) => {
|
|
9838
|
-
const nodeId =
|
|
9839
|
-
const forkReason =
|
|
10187
|
+
const nodeId = readString2(params, "nodeId", { required: true });
|
|
10188
|
+
const forkReason = readString2(params, "forkReason", {
|
|
9840
10189
|
required: true
|
|
9841
10190
|
});
|
|
9842
10191
|
const result = await beliefs.forkBelief(nodeId, {
|
|
9843
|
-
newFormulation:
|
|
10192
|
+
newFormulation: readString2(params, "newFormulation", {
|
|
9844
10193
|
required: true
|
|
9845
10194
|
}),
|
|
9846
10195
|
forkReason
|
|
@@ -9855,8 +10204,8 @@ function createBeliefHandlers(context) {
|
|
|
9855
10204
|
archive_belief: contractToHandler(
|
|
9856
10205
|
MCP_TOOL_CONTRACTS.archive_belief,
|
|
9857
10206
|
async (params) => {
|
|
9858
|
-
const nodeId =
|
|
9859
|
-
const rationale =
|
|
10207
|
+
const nodeId = readString2(params, "nodeId", { required: true });
|
|
10208
|
+
const rationale = readString2(params, "rationale");
|
|
9860
10209
|
const result = await graph.updateNode({
|
|
9861
10210
|
nodeId,
|
|
9862
10211
|
status: "archived",
|
|
@@ -9883,13 +10232,13 @@ function createContextHandlers(context) {
|
|
|
9883
10232
|
const response = await compiler.compile(
|
|
9884
10233
|
readTopicId(params, { required: true }),
|
|
9885
10234
|
{
|
|
9886
|
-
...
|
|
9887
|
-
...
|
|
9888
|
-
...
|
|
9889
|
-
ranking:
|
|
10235
|
+
...readString2(params, "query") ? { query: readString2(params, "query") } : {},
|
|
10236
|
+
...readNumber2(params, "budget") !== void 0 ? { budget: readNumber2(params, "budget") } : {},
|
|
10237
|
+
...readString2(params, "ranking") ? {
|
|
10238
|
+
ranking: readString2(params, "ranking")
|
|
9890
10239
|
} : {},
|
|
9891
|
-
...
|
|
9892
|
-
...
|
|
10240
|
+
...readNumber2(params, "limit") !== void 0 ? { limit: readNumber2(params, "limit") } : {},
|
|
10241
|
+
...readNumber2(params, "maxDepth") !== void 0 ? { maxDepth: readNumber2(params, "maxDepth") } : {},
|
|
9893
10242
|
...readBoolean(params, "includeEntities") !== void 0 ? { includeEntities: readBoolean(params, "includeEntities") } : {}
|
|
9894
10243
|
}
|
|
9895
10244
|
);
|
|
@@ -9906,14 +10255,14 @@ function createContradictionHandlers(context) {
|
|
|
9906
10255
|
flag_contradiction: contractToHandler(
|
|
9907
10256
|
MCP_TOOL_CONTRACTS.flag_contradiction,
|
|
9908
10257
|
async (params) => {
|
|
9909
|
-
const beliefA =
|
|
9910
|
-
const beliefB =
|
|
9911
|
-
const description =
|
|
10258
|
+
const beliefA = readString2(params, "beliefA", { required: true });
|
|
10259
|
+
const beliefB = readString2(params, "beliefB", { required: true });
|
|
10260
|
+
const description = readString2(params, "description", {
|
|
9912
10261
|
required: true
|
|
9913
10262
|
});
|
|
9914
10263
|
const topicId = readTopicId(params, { required: true });
|
|
9915
|
-
const severity =
|
|
9916
|
-
const defeatType =
|
|
10264
|
+
const severity = readString2(params, "severity") ?? "medium";
|
|
10265
|
+
const defeatType = readString2(params, "defeatType") ?? "rebuts";
|
|
9917
10266
|
const contradiction = await lucern.contradictions.flag({
|
|
9918
10267
|
beliefA,
|
|
9919
10268
|
beliefB,
|
|
@@ -9940,12 +10289,12 @@ function createEdgeHandlers(context) {
|
|
|
9940
10289
|
create_edge: contractToHandler(
|
|
9941
10290
|
MCP_TOOL_CONTRACTS.create_edge,
|
|
9942
10291
|
async (params) => {
|
|
9943
|
-
const sourceId =
|
|
9944
|
-
const targetId =
|
|
9945
|
-
const edgeType =
|
|
9946
|
-
const confidence =
|
|
9947
|
-
const weight =
|
|
9948
|
-
const contextText =
|
|
10292
|
+
const sourceId = readString2(params, "sourceId", { required: true });
|
|
10293
|
+
const targetId = readString2(params, "targetId", { required: true });
|
|
10294
|
+
const edgeType = readString2(params, "edgeType", { required: true });
|
|
10295
|
+
const confidence = readNumber2(params, "confidence");
|
|
10296
|
+
const weight = readNumber2(params, "weight");
|
|
10297
|
+
const contextText = readString2(params, "context") ?? readString2(params, "reasoning");
|
|
9949
10298
|
const edge = await lucern.edges.create({
|
|
9950
10299
|
sourceId,
|
|
9951
10300
|
targetId,
|
|
@@ -9978,15 +10327,15 @@ function createEvidenceHandlers(context) {
|
|
|
9978
10327
|
async (params) => {
|
|
9979
10328
|
const response = await lucern.evidence.create({
|
|
9980
10329
|
topicId: readTopicId(params, { required: true }),
|
|
9981
|
-
text:
|
|
9982
|
-
source:
|
|
9983
|
-
targetId:
|
|
9984
|
-
weight:
|
|
10330
|
+
text: readString2(params, "text", { required: true }),
|
|
10331
|
+
source: readString2(params, "source"),
|
|
10332
|
+
targetId: readString2(params, "targetId"),
|
|
10333
|
+
weight: readNumber2(params, "weight"),
|
|
9985
10334
|
metadata: readMetadata(params),
|
|
9986
|
-
title:
|
|
9987
|
-
content:
|
|
9988
|
-
contentType:
|
|
9989
|
-
kind:
|
|
10335
|
+
title: readString2(params, "title"),
|
|
10336
|
+
content: readString2(params, "content"),
|
|
10337
|
+
contentType: readString2(params, "contentType"),
|
|
10338
|
+
kind: readString2(params, "kind")
|
|
9990
10339
|
});
|
|
9991
10340
|
return response.data;
|
|
9992
10341
|
}
|
|
@@ -9995,7 +10344,7 @@ function createEvidenceHandlers(context) {
|
|
|
9995
10344
|
MCP_TOOL_CONTRACTS.get_evidence,
|
|
9996
10345
|
async (params) => {
|
|
9997
10346
|
const response = await lucern.evidence.get(
|
|
9998
|
-
|
|
10347
|
+
readString2(params, "id", { required: true })
|
|
9999
10348
|
);
|
|
10000
10349
|
return response.data;
|
|
10001
10350
|
}
|
|
@@ -10005,9 +10354,9 @@ function createEvidenceHandlers(context) {
|
|
|
10005
10354
|
async (params) => {
|
|
10006
10355
|
const response = await lucern.evidence.list({
|
|
10007
10356
|
topicId: readTopicId(params),
|
|
10008
|
-
targetId:
|
|
10009
|
-
limit:
|
|
10010
|
-
cursor:
|
|
10357
|
+
targetId: readString2(params, "targetId"),
|
|
10358
|
+
limit: readNumber2(params, "limit"),
|
|
10359
|
+
cursor: readString2(params, "cursor")
|
|
10011
10360
|
});
|
|
10012
10361
|
return response.data;
|
|
10013
10362
|
}
|
|
@@ -10016,10 +10365,10 @@ function createEvidenceHandlers(context) {
|
|
|
10016
10365
|
MCP_TOOL_CONTRACTS.link_evidence,
|
|
10017
10366
|
async (params) => {
|
|
10018
10367
|
const response = await lucern.evidence.link({
|
|
10019
|
-
evidenceId:
|
|
10020
|
-
targetId:
|
|
10021
|
-
weight:
|
|
10022
|
-
rationale:
|
|
10368
|
+
evidenceId: readString2(params, "evidenceId", { required: true }),
|
|
10369
|
+
targetId: readString2(params, "targetId", { required: true }),
|
|
10370
|
+
weight: readNumber2(params, "weight"),
|
|
10371
|
+
rationale: readString2(params, "rationale")
|
|
10023
10372
|
});
|
|
10024
10373
|
return response.data;
|
|
10025
10374
|
}
|
|
@@ -10028,11 +10377,11 @@ function createEvidenceHandlers(context) {
|
|
|
10028
10377
|
MCP_TOOL_CONTRACTS.search_evidence,
|
|
10029
10378
|
async (params) => {
|
|
10030
10379
|
const response = await lucern.evidence.search({
|
|
10031
|
-
q:
|
|
10380
|
+
q: readString2(params, "q") ?? readString2(params, "query", { required: true }),
|
|
10032
10381
|
topicId: readTopicId(params),
|
|
10033
|
-
targetId:
|
|
10034
|
-
limit:
|
|
10035
|
-
cursor:
|
|
10382
|
+
targetId: readString2(params, "targetId"),
|
|
10383
|
+
limit: readNumber2(params, "limit"),
|
|
10384
|
+
cursor: readString2(params, "cursor")
|
|
10036
10385
|
});
|
|
10037
10386
|
return response.data;
|
|
10038
10387
|
}
|
|
@@ -10041,17 +10390,17 @@ function createEvidenceHandlers(context) {
|
|
|
10041
10390
|
MCP_TOOL_CONTRACTS.add_evidence,
|
|
10042
10391
|
async (params) => {
|
|
10043
10392
|
return lucern.evidence.add({
|
|
10044
|
-
canonicalText:
|
|
10393
|
+
canonicalText: readString2(params, "canonicalText", { required: true }),
|
|
10045
10394
|
topicId: readTopicId(params, { required: true }),
|
|
10046
|
-
sourceUrl:
|
|
10395
|
+
sourceUrl: readString2(params, "sourceUrl"),
|
|
10047
10396
|
supports: {
|
|
10048
|
-
nodeId:
|
|
10049
|
-
weight:
|
|
10050
|
-
reasoning:
|
|
10397
|
+
nodeId: readString2(params, "targetNodeId", { required: true }),
|
|
10398
|
+
weight: readNumber2(params, "weight") ?? 1,
|
|
10399
|
+
reasoning: readString2(params, "reasoning")
|
|
10051
10400
|
},
|
|
10052
|
-
title:
|
|
10053
|
-
content:
|
|
10054
|
-
contentType:
|
|
10401
|
+
title: readString2(params, "title"),
|
|
10402
|
+
content: readString2(params, "content"),
|
|
10403
|
+
contentType: readString2(params, "contentType"),
|
|
10055
10404
|
metadata: readMetadata(params)
|
|
10056
10405
|
});
|
|
10057
10406
|
}
|
|
@@ -10060,10 +10409,10 @@ function createEvidenceHandlers(context) {
|
|
|
10060
10409
|
MCP_TOOL_CONTRACTS.link_evidence_to_belief,
|
|
10061
10410
|
async (params) => {
|
|
10062
10411
|
return lucern.evidence.linkToBelief({
|
|
10063
|
-
evidenceId:
|
|
10064
|
-
beliefId:
|
|
10065
|
-
weight:
|
|
10066
|
-
rationale:
|
|
10412
|
+
evidenceId: readString2(params, "evidenceId", { required: true }),
|
|
10413
|
+
beliefId: readString2(params, "beliefId", { required: true }),
|
|
10414
|
+
weight: readNumber2(params, "weight", { required: true }),
|
|
10415
|
+
rationale: readString2(params, "rationale")
|
|
10067
10416
|
});
|
|
10068
10417
|
}
|
|
10069
10418
|
)
|
|
@@ -10178,8 +10527,8 @@ function createGraphHandlers(context) {
|
|
|
10178
10527
|
query_lineage: contractToHandler(
|
|
10179
10528
|
MCP_TOOL_CONTRACTS.query_lineage,
|
|
10180
10529
|
async (params) => {
|
|
10181
|
-
const nodeId =
|
|
10182
|
-
const depth =
|
|
10530
|
+
const nodeId = readString2(params, "nodeId", { required: true });
|
|
10531
|
+
const depth = readNumber2(params, "depth") ?? 5;
|
|
10183
10532
|
const [parentEdgesResponse, childEdgesResponse] = await Promise.all([
|
|
10184
10533
|
graph.queryEdges({
|
|
10185
10534
|
toNodeId: nodeId,
|
|
@@ -10216,7 +10565,7 @@ function createGraphHandlers(context) {
|
|
|
10216
10565
|
get_confidence_history: contractToHandler(
|
|
10217
10566
|
MCP_TOOL_CONTRACTS.get_confidence_history,
|
|
10218
10567
|
async (params) => {
|
|
10219
|
-
const nodeId =
|
|
10568
|
+
const nodeId = readString2(params, "nodeId", { required: true });
|
|
10220
10569
|
const entries = await getConfidenceEntries(nodeId);
|
|
10221
10570
|
return { entries };
|
|
10222
10571
|
}
|
|
@@ -10224,8 +10573,8 @@ function createGraphHandlers(context) {
|
|
|
10224
10573
|
get_audit_trail: contractToHandler(
|
|
10225
10574
|
MCP_TOOL_CONTRACTS.get_audit_trail,
|
|
10226
10575
|
async (params) => {
|
|
10227
|
-
const nodeId =
|
|
10228
|
-
const limit =
|
|
10576
|
+
const nodeId = readString2(params, "nodeId", { required: true });
|
|
10577
|
+
const limit = readNumber2(params, "limit") ?? 50;
|
|
10229
10578
|
const events = await audit.listEvents({ limit: Math.max(1, limit) });
|
|
10230
10579
|
const entries = asAuditArray(events.data).filter((entry) => matchesAuditNodeReference2(entry, nodeId)).slice(0, limit).map((entry) => ({
|
|
10231
10580
|
action: entry.action ?? "unknown",
|
|
@@ -10242,9 +10591,9 @@ function createGraphHandlers(context) {
|
|
|
10242
10591
|
MCP_TOOL_CONTRACTS.traverse_graph,
|
|
10243
10592
|
async (params) => {
|
|
10244
10593
|
const response = await graph.traverse({
|
|
10245
|
-
startNode:
|
|
10246
|
-
direction:
|
|
10247
|
-
maxDepth:
|
|
10594
|
+
startNode: readString2(params, "startNode", { required: true }),
|
|
10595
|
+
direction: readString2(params, "direction"),
|
|
10596
|
+
maxDepth: readNumber2(params, "maxDepth"),
|
|
10248
10597
|
topicId: readTopicId(params)
|
|
10249
10598
|
});
|
|
10250
10599
|
return response.data;
|
|
@@ -10255,9 +10604,9 @@ function createGraphHandlers(context) {
|
|
|
10255
10604
|
async (params) => {
|
|
10256
10605
|
const globalIds = readStringArray(params, "globalIds");
|
|
10257
10606
|
const response = await graph.neighborhood({
|
|
10258
|
-
globalId:
|
|
10607
|
+
globalId: readString2(params, "globalId"),
|
|
10259
10608
|
globalIds: globalIds ? globalIds.join(",") : void 0,
|
|
10260
|
-
maxDepth:
|
|
10609
|
+
maxDepth: readNumber2(params, "maxDepth")
|
|
10261
10610
|
});
|
|
10262
10611
|
return response.data;
|
|
10263
10612
|
}
|
|
@@ -10265,11 +10614,11 @@ function createGraphHandlers(context) {
|
|
|
10265
10614
|
search_beliefs: contractToHandler(
|
|
10266
10615
|
MCP_TOOL_CONTRACTS.search_beliefs,
|
|
10267
10616
|
async (params) => {
|
|
10268
|
-
const query =
|
|
10617
|
+
const query = readString2(params, "query", { required: true });
|
|
10269
10618
|
const topicId = readTopicId(params);
|
|
10270
|
-
const status =
|
|
10271
|
-
const minConfidence =
|
|
10272
|
-
const limit =
|
|
10619
|
+
const status = readString2(params, "status");
|
|
10620
|
+
const minConfidence = readNumber2(params, "minConfidence");
|
|
10621
|
+
const limit = readNumber2(params, "limit") ?? 10;
|
|
10273
10622
|
if (!topicId) {
|
|
10274
10623
|
return { results: [] };
|
|
10275
10624
|
}
|
|
@@ -10295,8 +10644,8 @@ function createGraphHandlers(context) {
|
|
|
10295
10644
|
MCP_TOOL_CONTRACTS.find_contradictions,
|
|
10296
10645
|
async (params) => {
|
|
10297
10646
|
const topicId = readTopicId(params);
|
|
10298
|
-
const nodeId =
|
|
10299
|
-
const status =
|
|
10647
|
+
const nodeId = readString2(params, "nodeId");
|
|
10648
|
+
const status = readString2(params, "status");
|
|
10300
10649
|
if (!topicId && !nodeId) {
|
|
10301
10650
|
return { contradictions: [] };
|
|
10302
10651
|
}
|
|
@@ -10328,8 +10677,8 @@ function createGraphHandlers(context) {
|
|
|
10328
10677
|
bisect_confidence: contractToHandler(
|
|
10329
10678
|
MCP_TOOL_CONTRACTS.bisect_confidence,
|
|
10330
10679
|
async (params) => {
|
|
10331
|
-
const nodeId =
|
|
10332
|
-
const expectedDirection =
|
|
10680
|
+
const nodeId = readString2(params, "nodeId", { required: true });
|
|
10681
|
+
const expectedDirection = readString2(params, "expectedDirection", {
|
|
10333
10682
|
required: true
|
|
10334
10683
|
});
|
|
10335
10684
|
const entries = await getConfidenceEntries(nodeId);
|
|
@@ -10352,7 +10701,7 @@ function createGraphHandlers(context) {
|
|
|
10352
10701
|
if (!await isTopicReadable(topicId)) {
|
|
10353
10702
|
return { topicId, beliefs: [] };
|
|
10354
10703
|
}
|
|
10355
|
-
const threshold =
|
|
10704
|
+
const threshold = readNumber2(params, "threshold") ?? 0.7;
|
|
10356
10705
|
const analytics = await graph.bias({
|
|
10357
10706
|
topicId,
|
|
10358
10707
|
threshold,
|
|
@@ -10426,7 +10775,7 @@ function createGraphHandlers(context) {
|
|
|
10426
10775
|
}
|
|
10427
10776
|
return lucern.graph.gaps({
|
|
10428
10777
|
topicId,
|
|
10429
|
-
minConfidence:
|
|
10778
|
+
minConfidence: readNumber2(params, "minConfidence")
|
|
10430
10779
|
});
|
|
10431
10780
|
}
|
|
10432
10781
|
),
|
|
@@ -10437,9 +10786,9 @@ function createGraphHandlers(context) {
|
|
|
10437
10786
|
if (!await isTopicReadable(topicId)) {
|
|
10438
10787
|
return { beliefs: [] };
|
|
10439
10788
|
}
|
|
10440
|
-
const status =
|
|
10441
|
-
const minConfidence =
|
|
10442
|
-
const worktreeId =
|
|
10789
|
+
const status = readString2(params, "status");
|
|
10790
|
+
const minConfidence = readNumber2(params, "minConfidence");
|
|
10791
|
+
const worktreeId = readString2(params, "worktreeId");
|
|
10443
10792
|
const response = await graph.queryNodes({
|
|
10444
10793
|
topicId,
|
|
10445
10794
|
nodeType: "belief",
|
|
@@ -10486,10 +10835,10 @@ function createJudgmentHandlers(context) {
|
|
|
10486
10835
|
record_judgment: contractToHandler(
|
|
10487
10836
|
MCP_TOOL_CONTRACTS.record_judgment,
|
|
10488
10837
|
async (params) => {
|
|
10489
|
-
const title =
|
|
10490
|
-
const rationale =
|
|
10838
|
+
const title = readString2(params, "title", { required: true });
|
|
10839
|
+
const rationale = readString2(params, "rationale", { required: true });
|
|
10491
10840
|
const topicId = readTopicId(params, { required: true });
|
|
10492
|
-
const confidence =
|
|
10841
|
+
const confidence = readNumber2(params, "confidence");
|
|
10493
10842
|
const beliefIds = readStringArray(params, "beliefIds");
|
|
10494
10843
|
const result = await decisions.recordJudgment({
|
|
10495
10844
|
title,
|
|
@@ -10536,14 +10885,14 @@ function createObservationHandlers(context) {
|
|
|
10536
10885
|
const topicId = readTopicId(params, {
|
|
10537
10886
|
required: true
|
|
10538
10887
|
});
|
|
10539
|
-
const observationType =
|
|
10888
|
+
const observationType = readString2(params, "observationType", {
|
|
10540
10889
|
required: true
|
|
10541
10890
|
});
|
|
10542
|
-
const summary =
|
|
10891
|
+
const summary = readString2(params, "summary", {
|
|
10543
10892
|
required: true
|
|
10544
10893
|
});
|
|
10545
|
-
const source =
|
|
10546
|
-
const confidence =
|
|
10894
|
+
const source = readString2(params, "source");
|
|
10895
|
+
const confidence = readNumber2(params, "confidence");
|
|
10547
10896
|
const tags = readStringArray(params, "tags");
|
|
10548
10897
|
const metadata = readObject(params, "metadata");
|
|
10549
10898
|
const allowedTypes = [
|
|
@@ -10602,8 +10951,8 @@ function createObservationHandlers(context) {
|
|
|
10602
10951
|
const topicId = readTopicId(params, {
|
|
10603
10952
|
required: true
|
|
10604
10953
|
});
|
|
10605
|
-
const query =
|
|
10606
|
-
const limit =
|
|
10954
|
+
const query = readString2(params, "query");
|
|
10955
|
+
const limit = readNumber2(params, "limit");
|
|
10607
10956
|
return observationStore.getContext({
|
|
10608
10957
|
topicId,
|
|
10609
10958
|
query,
|
|
@@ -10622,9 +10971,9 @@ function createPolicyHandlers(context) {
|
|
|
10622
10971
|
MCP_TOOL_CONTRACTS.check_permission,
|
|
10623
10972
|
async (params) => {
|
|
10624
10973
|
const topicId = readTopicId(params, { required: true });
|
|
10625
|
-
const permission =
|
|
10626
|
-
const principal =
|
|
10627
|
-
const beliefClusterId =
|
|
10974
|
+
const permission = readString2(params, "permission", { required: true }) ?? "read";
|
|
10975
|
+
const principal = readString2(params, "principal");
|
|
10976
|
+
const beliefClusterId = readString2(params, "beliefClusterId");
|
|
10628
10977
|
const result = await policy.checkPermission({
|
|
10629
10978
|
topicId,
|
|
10630
10979
|
permission,
|
|
@@ -10646,10 +10995,10 @@ function createPolicyHandlers(context) {
|
|
|
10646
10995
|
MCP_TOOL_CONTRACTS.filter_by_permission,
|
|
10647
10996
|
async (params) => {
|
|
10648
10997
|
const topicIds = readStringArray(params, "topicIds") ?? [];
|
|
10649
|
-
const permission =
|
|
10998
|
+
const permission = readString2(params, "permission", {
|
|
10650
10999
|
required: true
|
|
10651
11000
|
}) ?? "read";
|
|
10652
|
-
const principal =
|
|
11001
|
+
const principal = readString2(params, "principal");
|
|
10653
11002
|
const result = await policy.filterByPermission({
|
|
10654
11003
|
topicIds,
|
|
10655
11004
|
permission,
|
|
@@ -10680,10 +11029,10 @@ function createQuestionHandlers(context) {
|
|
|
10680
11029
|
MCP_TOOL_CONTRACTS.create_question,
|
|
10681
11030
|
async (params) => {
|
|
10682
11031
|
const response = await lucern.questions.create({
|
|
10683
|
-
text:
|
|
11032
|
+
text: readString2(params, "text", { required: true }),
|
|
10684
11033
|
topicId: readTopicId(params, { required: true }),
|
|
10685
|
-
priority:
|
|
10686
|
-
linkedBeliefId:
|
|
11034
|
+
priority: readString2(params, "priority"),
|
|
11035
|
+
linkedBeliefId: readString2(params, "linkedBeliefId"),
|
|
10687
11036
|
metadata: readMetadata2(params)
|
|
10688
11037
|
});
|
|
10689
11038
|
return response.data;
|
|
@@ -10693,7 +11042,7 @@ function createQuestionHandlers(context) {
|
|
|
10693
11042
|
MCP_TOOL_CONTRACTS.get_question,
|
|
10694
11043
|
async (params) => {
|
|
10695
11044
|
const response = await lucern.questions.get(
|
|
10696
|
-
|
|
11045
|
+
readString2(params, "id", { required: true })
|
|
10697
11046
|
);
|
|
10698
11047
|
return response.data;
|
|
10699
11048
|
}
|
|
@@ -10703,11 +11052,11 @@ function createQuestionHandlers(context) {
|
|
|
10703
11052
|
async (params) => {
|
|
10704
11053
|
const response = await lucern.questions.list({
|
|
10705
11054
|
topicId: readTopicId(params, { required: true }),
|
|
10706
|
-
status:
|
|
10707
|
-
priority:
|
|
10708
|
-
worktreeId:
|
|
10709
|
-
limit:
|
|
10710
|
-
cursor:
|
|
11055
|
+
status: readString2(params, "status"),
|
|
11056
|
+
priority: readString2(params, "priority"),
|
|
11057
|
+
worktreeId: readString2(params, "worktreeId"),
|
|
11058
|
+
limit: readNumber2(params, "limit"),
|
|
11059
|
+
cursor: readString2(params, "cursor")
|
|
10711
11060
|
});
|
|
10712
11061
|
return response.data;
|
|
10713
11062
|
}
|
|
@@ -10716,12 +11065,12 @@ function createQuestionHandlers(context) {
|
|
|
10716
11065
|
MCP_TOOL_CONTRACTS.answer_question,
|
|
10717
11066
|
async (params) => {
|
|
10718
11067
|
const response = await lucern.questions.answer(
|
|
10719
|
-
|
|
11068
|
+
readString2(params, "id", { required: true }),
|
|
10720
11069
|
{
|
|
10721
|
-
text:
|
|
10722
|
-
confidence:
|
|
11070
|
+
text: readString2(params, "text", { required: true }),
|
|
11071
|
+
confidence: readString2(params, "confidence"),
|
|
10723
11072
|
evidenceIds: readStringArray(params, "evidenceIds"),
|
|
10724
|
-
rationale:
|
|
11073
|
+
rationale: readString2(params, "rationale")
|
|
10725
11074
|
}
|
|
10726
11075
|
);
|
|
10727
11076
|
return response.data;
|
|
@@ -10731,9 +11080,9 @@ function createQuestionHandlers(context) {
|
|
|
10731
11080
|
MCP_TOOL_CONTRACTS.refine_question,
|
|
10732
11081
|
async (params) => {
|
|
10733
11082
|
const response = await lucern.questions.refine(
|
|
10734
|
-
|
|
10735
|
-
|
|
10736
|
-
|
|
11083
|
+
readString2(params, "id") ?? readString2(params, "questionId", { required: true }),
|
|
11084
|
+
readString2(params, "text", { required: true }),
|
|
11085
|
+
readString2(params, "rationale") ?? readString2(params, "refinementReason")
|
|
10737
11086
|
);
|
|
10738
11087
|
return response.data;
|
|
10739
11088
|
}
|
|
@@ -10742,9 +11091,9 @@ function createQuestionHandlers(context) {
|
|
|
10742
11091
|
MCP_TOOL_CONTRACTS.update_question_status,
|
|
10743
11092
|
async (params) => {
|
|
10744
11093
|
const response = await lucern.questions.updateStatus(
|
|
10745
|
-
|
|
10746
|
-
|
|
10747
|
-
|
|
11094
|
+
readString2(params, "id") ?? readString2(params, "questionId", { required: true }),
|
|
11095
|
+
readString2(params, "status", { required: true }),
|
|
11096
|
+
readString2(params, "rationale")
|
|
10748
11097
|
);
|
|
10749
11098
|
return response.data;
|
|
10750
11099
|
}
|
|
@@ -10753,8 +11102,8 @@ function createQuestionHandlers(context) {
|
|
|
10753
11102
|
MCP_TOOL_CONTRACTS.archive_question,
|
|
10754
11103
|
async (params) => {
|
|
10755
11104
|
return lucern.questions.archive(
|
|
10756
|
-
|
|
10757
|
-
|
|
11105
|
+
readString2(params, "questionId", { required: true }),
|
|
11106
|
+
readString2(params, "reason")
|
|
10758
11107
|
);
|
|
10759
11108
|
}
|
|
10760
11109
|
),
|
|
@@ -10762,10 +11111,10 @@ function createQuestionHandlers(context) {
|
|
|
10762
11111
|
MCP_TOOL_CONTRACTS.link_evidence_to_question,
|
|
10763
11112
|
async (params) => {
|
|
10764
11113
|
return lucern.questions.linkEvidence({
|
|
10765
|
-
evidenceId:
|
|
10766
|
-
questionId:
|
|
10767
|
-
relevance:
|
|
10768
|
-
rationale:
|
|
11114
|
+
evidenceId: readString2(params, "evidenceId", { required: true }),
|
|
11115
|
+
questionId: readString2(params, "questionId", { required: true }),
|
|
11116
|
+
relevance: readNumber2(params, "relevance") ?? 1,
|
|
11117
|
+
rationale: readString2(params, "rationale")
|
|
10769
11118
|
});
|
|
10770
11119
|
}
|
|
10771
11120
|
),
|
|
@@ -10774,7 +11123,7 @@ function createQuestionHandlers(context) {
|
|
|
10774
11123
|
async (params) => {
|
|
10775
11124
|
return lucern.questions.getHighPriority({
|
|
10776
11125
|
topicId: readTopicId(params, { required: true }),
|
|
10777
|
-
limit:
|
|
11126
|
+
limit: readNumber2(params, "limit"),
|
|
10778
11127
|
includeAnswered: readBoolean(params, "includeAnswered")
|
|
10779
11128
|
});
|
|
10780
11129
|
}
|
|
@@ -10784,7 +11133,7 @@ function createQuestionHandlers(context) {
|
|
|
10784
11133
|
async (params) => {
|
|
10785
11134
|
return lucern.questions.findMissing({
|
|
10786
11135
|
topicId: readTopicId(params, { required: true }),
|
|
10787
|
-
minConfidence:
|
|
11136
|
+
minConfidence: readNumber2(params, "minConfidence")
|
|
10788
11137
|
});
|
|
10789
11138
|
}
|
|
10790
11139
|
)
|
|
@@ -10806,7 +11155,7 @@ function asSourceArray(data) {
|
|
|
10806
11155
|
function createResearchHandlers(context) {
|
|
10807
11156
|
const graph = createGraphClient(context.sdkConfig);
|
|
10808
11157
|
const searchSources = async (params) => {
|
|
10809
|
-
const query =
|
|
11158
|
+
const query = readString2(params, "query", { required: true });
|
|
10810
11159
|
const topicId = readTopicId(params);
|
|
10811
11160
|
const sourceTypes = readStringArray(params, "sources") ?? [];
|
|
10812
11161
|
if (!topicId) {
|
|
@@ -10845,9 +11194,9 @@ function createResearchHandlers(context) {
|
|
|
10845
11194
|
execute_deep_research: contractToHandler(
|
|
10846
11195
|
MCP_TOOL_CONTRACTS.execute_deep_research,
|
|
10847
11196
|
async (params) => {
|
|
10848
|
-
const query =
|
|
11197
|
+
const query = readString2(params, "query", { required: true });
|
|
10849
11198
|
const topicId = readTopicId(params, { required: true });
|
|
10850
|
-
const depth =
|
|
11199
|
+
const depth = readString2(params, "depth") ?? "standard";
|
|
10851
11200
|
const sources = await searchSources({
|
|
10852
11201
|
query,
|
|
10853
11202
|
topicId,
|
|
@@ -10883,13 +11232,13 @@ function createSearchHandlers(context) {
|
|
|
10883
11232
|
search_resources: contractToHandler(
|
|
10884
11233
|
MCP_TOOL_CONTRACTS.search_resources,
|
|
10885
11234
|
async (params) => {
|
|
10886
|
-
return lucern.search(
|
|
11235
|
+
return lucern.search(readString2(params, "q", { required: true }), {
|
|
10887
11236
|
topicId: readTopicId(params, { required: true }),
|
|
10888
11237
|
types: readStringArray(params, "types"),
|
|
10889
|
-
status:
|
|
10890
|
-
minConfidence:
|
|
10891
|
-
limit:
|
|
10892
|
-
cursor:
|
|
11238
|
+
status: readString2(params, "status"),
|
|
11239
|
+
minConfidence: readNumber2(params, "minConfidence"),
|
|
11240
|
+
limit: readNumber2(params, "limit"),
|
|
11241
|
+
cursor: readString2(params, "cursor")
|
|
10893
11242
|
});
|
|
10894
11243
|
}
|
|
10895
11244
|
)
|
|
@@ -10903,11 +11252,11 @@ function createTaskHandlers(context) {
|
|
|
10903
11252
|
create_task: contractToHandler(
|
|
10904
11253
|
MCP_TOOL_CONTRACTS.create_task,
|
|
10905
11254
|
async (params) => {
|
|
10906
|
-
const title =
|
|
11255
|
+
const title = readString2(params, "title", { required: true });
|
|
10907
11256
|
const topicId = readTopicId(params, { required: true });
|
|
10908
|
-
const taskType =
|
|
10909
|
-
const linkedQuestionId =
|
|
10910
|
-
const linkedWorktreeId =
|
|
11257
|
+
const taskType = readString2(params, "taskType");
|
|
11258
|
+
const linkedQuestionId = readString2(params, "linkedQuestionId");
|
|
11259
|
+
const linkedWorktreeId = readString2(params, "linkedWorktreeId");
|
|
10911
11260
|
const result = await workflow.createTask({
|
|
10912
11261
|
title,
|
|
10913
11262
|
topicId,
|
|
@@ -10925,8 +11274,8 @@ function createTaskHandlers(context) {
|
|
|
10925
11274
|
complete_task: contractToHandler(
|
|
10926
11275
|
MCP_TOOL_CONTRACTS.complete_task,
|
|
10927
11276
|
async (params) => {
|
|
10928
|
-
const taskId =
|
|
10929
|
-
const outputSummary =
|
|
11277
|
+
const taskId = readString2(params, "taskId", { required: true });
|
|
11278
|
+
const outputSummary = readString2(params, "outputSummary", {
|
|
10930
11279
|
required: true
|
|
10931
11280
|
});
|
|
10932
11281
|
const evidenceCreated = readBoolean(params, "evidenceCreated");
|
|
@@ -10944,15 +11293,15 @@ function createTaskHandlers(context) {
|
|
|
10944
11293
|
update_task: contractToHandler(
|
|
10945
11294
|
MCP_TOOL_CONTRACTS.update_task,
|
|
10946
11295
|
async (params) => {
|
|
10947
|
-
const taskId =
|
|
10948
|
-
const title =
|
|
10949
|
-
const description =
|
|
10950
|
-
const linkedBeliefId =
|
|
10951
|
-
const linkedQuestionId =
|
|
10952
|
-
const linkedWorktreeId =
|
|
10953
|
-
const rawPriority =
|
|
11296
|
+
const taskId = readString2(params, "taskId", { required: true });
|
|
11297
|
+
const title = readString2(params, "title");
|
|
11298
|
+
const description = readString2(params, "description");
|
|
11299
|
+
const linkedBeliefId = readString2(params, "linkedBeliefId");
|
|
11300
|
+
const linkedQuestionId = readString2(params, "linkedQuestionId");
|
|
11301
|
+
const linkedWorktreeId = readString2(params, "linkedWorktreeId");
|
|
11302
|
+
const rawPriority = readString2(params, "priority");
|
|
10954
11303
|
const priority = rawPriority === "critical" || rawPriority === "high" || rawPriority === "medium" || rawPriority === "low" ? rawPriority : void 0;
|
|
10955
|
-
const rawStatus =
|
|
11304
|
+
const rawStatus = readString2(params, "status");
|
|
10956
11305
|
const status = rawStatus === "todo" || rawStatus === "in_progress" || rawStatus === "blocked" || rawStatus === "done" ? rawStatus : void 0;
|
|
10957
11306
|
const result = await workflow.updateTask(taskId, {
|
|
10958
11307
|
title,
|
|
@@ -10990,11 +11339,11 @@ function createWorktreeHandlers(context) {
|
|
|
10990
11339
|
return {
|
|
10991
11340
|
create_lens: contractToHandler(MCP_TOOL_CONTRACTS.create_lens, async (params) => {
|
|
10992
11341
|
const result = await workflow.createLens({
|
|
10993
|
-
name:
|
|
10994
|
-
workspaceId:
|
|
11342
|
+
name: readString2(params, "name", { required: true }),
|
|
11343
|
+
workspaceId: readString2(params, "workspaceId"),
|
|
10995
11344
|
topicId: readTopicId(params),
|
|
10996
|
-
description:
|
|
10997
|
-
perspectiveType:
|
|
11345
|
+
description: readString2(params, "description"),
|
|
11346
|
+
perspectiveType: readString2(params, "perspectiveType", {
|
|
10998
11347
|
required: true
|
|
10999
11348
|
}),
|
|
11000
11349
|
promptTemplates: Array.isArray(params.promptTemplates) ? params.promptTemplates : void 0,
|
|
@@ -11004,17 +11353,17 @@ function createWorktreeHandlers(context) {
|
|
|
11004
11353
|
});
|
|
11005
11354
|
return {
|
|
11006
11355
|
lensId: result.data.lensId ?? "",
|
|
11007
|
-
name: result.data.name ??
|
|
11008
|
-
workspaceId: result.data.workspaceId ??
|
|
11356
|
+
name: result.data.name ?? readString2(params, "name", { required: true }),
|
|
11357
|
+
workspaceId: result.data.workspaceId ?? readString2(params, "workspaceId") ?? null,
|
|
11009
11358
|
status: result.data.status ?? "active"
|
|
11010
11359
|
};
|
|
11011
11360
|
}),
|
|
11012
11361
|
list_lenses: contractToHandler(MCP_TOOL_CONTRACTS.list_lenses, async (params) => {
|
|
11013
11362
|
const result = await workflow.listLenses({
|
|
11014
|
-
workspaceId:
|
|
11363
|
+
workspaceId: readString2(params, "workspaceId"),
|
|
11015
11364
|
topicId: readTopicId(params),
|
|
11016
|
-
status:
|
|
11017
|
-
perspectiveType:
|
|
11365
|
+
status: readString2(params, "status"),
|
|
11366
|
+
perspectiveType: readString2(params, "perspectiveType")
|
|
11018
11367
|
});
|
|
11019
11368
|
return {
|
|
11020
11369
|
lenses: result.data.items ?? ("lenses" in result.data && Array.isArray(result.data.lenses) ? result.data.lenses : [])
|
|
@@ -11024,7 +11373,7 @@ function createWorktreeHandlers(context) {
|
|
|
11024
11373
|
MCP_TOOL_CONTRACTS.apply_lens_to_topic,
|
|
11025
11374
|
async (params) => {
|
|
11026
11375
|
const topicId = readTopicId(params, { required: true });
|
|
11027
|
-
const lensId =
|
|
11376
|
+
const lensId = readString2(params, "lensId", { required: true });
|
|
11028
11377
|
const result = await workflow.applyLensToTopic({
|
|
11029
11378
|
lensId,
|
|
11030
11379
|
topicId,
|
|
@@ -11042,7 +11391,7 @@ function createWorktreeHandlers(context) {
|
|
|
11042
11391
|
MCP_TOOL_CONTRACTS.remove_lens_from_topic,
|
|
11043
11392
|
async (params) => {
|
|
11044
11393
|
const topicId = readTopicId(params, { required: true });
|
|
11045
|
-
const lensId =
|
|
11394
|
+
const lensId = readString2(params, "lensId", { required: true });
|
|
11046
11395
|
const result = await workflow.removeLensFromTopic({
|
|
11047
11396
|
lensId,
|
|
11048
11397
|
topicId
|
|
@@ -11063,18 +11412,18 @@ function createWorktreeHandlers(context) {
|
|
|
11063
11412
|
throw new Error("add_worktree requires topicId");
|
|
11064
11413
|
}
|
|
11065
11414
|
const result = await workflow.addWorktree({
|
|
11066
|
-
title:
|
|
11415
|
+
title: readString2(params, "title", { required: true }),
|
|
11067
11416
|
topicId,
|
|
11068
|
-
branchId:
|
|
11069
|
-
objective:
|
|
11070
|
-
hypothesis:
|
|
11417
|
+
branchId: readString2(params, "branchId"),
|
|
11418
|
+
objective: readString2(params, "objective"),
|
|
11419
|
+
hypothesis: readString2(params, "hypothesis"),
|
|
11071
11420
|
beliefIds: readStringArray(params, "beliefIds"),
|
|
11072
11421
|
autoShape: readBoolean(params, "autoShape"),
|
|
11073
|
-
domainPackId:
|
|
11422
|
+
domainPackId: readString2(params, "domainPackId"),
|
|
11074
11423
|
executionOrder: typeof params.executionOrder === "number" ? params.executionOrder : void 0,
|
|
11075
11424
|
dependsOn: readStringArray(params, "dependsOn"),
|
|
11076
11425
|
blocks: readStringArray(params, "blocks"),
|
|
11077
|
-
gate:
|
|
11426
|
+
gate: readString2(params, "gate")
|
|
11078
11427
|
});
|
|
11079
11428
|
return {
|
|
11080
11429
|
worktreeId: result.data.worktreeId,
|
|
@@ -11091,11 +11440,11 @@ function createWorktreeHandlers(context) {
|
|
|
11091
11440
|
}
|
|
11092
11441
|
),
|
|
11093
11442
|
merge: contractToHandler(MCP_TOOL_CONTRACTS.merge, async (params) => {
|
|
11094
|
-
const worktreeId =
|
|
11443
|
+
const worktreeId = readString2(params, "worktreeId", { required: true });
|
|
11095
11444
|
const outcomes = Array.isArray(params.outcomes) ? params.outcomes : [];
|
|
11096
11445
|
const result = await workflow.merge(worktreeId, {
|
|
11097
11446
|
outcomes,
|
|
11098
|
-
summary:
|
|
11447
|
+
summary: readString2(params, "summary")
|
|
11099
11448
|
});
|
|
11100
11449
|
return {
|
|
11101
11450
|
worktreeId: result.data.worktreeId ?? worktreeId,
|
|
@@ -11104,8 +11453,8 @@ function createWorktreeHandlers(context) {
|
|
|
11104
11453
|
};
|
|
11105
11454
|
}),
|
|
11106
11455
|
push: contractToHandler(MCP_TOOL_CONTRACTS.push, async (params) => {
|
|
11107
|
-
const worktreeId =
|
|
11108
|
-
const targetContext =
|
|
11456
|
+
const worktreeId = readString2(params, "worktreeId", { required: true });
|
|
11457
|
+
const targetContext = readString2(params, "targetContext", {
|
|
11109
11458
|
required: true
|
|
11110
11459
|
});
|
|
11111
11460
|
const result = await workflow.push(worktreeId, {
|
|
@@ -11121,10 +11470,10 @@ function createWorktreeHandlers(context) {
|
|
|
11121
11470
|
open_pull_request: contractToHandler(
|
|
11122
11471
|
MCP_TOOL_CONTRACTS.open_pull_request,
|
|
11123
11472
|
async (params) => {
|
|
11124
|
-
const worktreeId =
|
|
11473
|
+
const worktreeId = readString2(params, "worktreeId", {
|
|
11125
11474
|
required: true
|
|
11126
11475
|
});
|
|
11127
|
-
const summary =
|
|
11476
|
+
const summary = readString2(params, "summary", { required: true });
|
|
11128
11477
|
const reviewers = readStringArray(params, "reviewers");
|
|
11129
11478
|
const result = await workflow.openPullRequest(worktreeId, {
|
|
11130
11479
|
summary,
|
|
@@ -11141,7 +11490,7 @@ function createWorktreeHandlers(context) {
|
|
|
11141
11490
|
MCP_TOOL_CONTRACTS.list_worktrees,
|
|
11142
11491
|
async (params) => {
|
|
11143
11492
|
const topicId = readTopicId(params, { required: true });
|
|
11144
|
-
const status = mapWorktreeStatus(
|
|
11493
|
+
const status = mapWorktreeStatus(readString2(params, "status"));
|
|
11145
11494
|
const result = await workflow.listWorktrees({
|
|
11146
11495
|
topicId,
|
|
11147
11496
|
status
|
|
@@ -12181,7 +12530,7 @@ async function runLucernMcpCli(argv = process.argv.slice(2)) {
|
|
|
12181
12530
|
}
|
|
12182
12531
|
}
|
|
12183
12532
|
|
|
12184
|
-
// src/
|
|
12533
|
+
// src/toolContracts.ts
|
|
12185
12534
|
function pickToolContracts(names) {
|
|
12186
12535
|
return Object.fromEntries(
|
|
12187
12536
|
names.flatMap((name) => {
|
|
@@ -12224,16 +12573,16 @@ var SCOPE_MCP_TOOLS = pickToolContracts([
|
|
|
12224
12573
|
"trigger_belief_review"
|
|
12225
12574
|
]);
|
|
12226
12575
|
|
|
12227
|
-
// src/
|
|
12228
|
-
var
|
|
12576
|
+
// src/authenticatedHandlers.ts
|
|
12577
|
+
var GATEWAY_HANDLER_TOOL_NAMES = [
|
|
12229
12578
|
...Object.keys(SCOPE_MCP_TOOLS),
|
|
12230
12579
|
...Object.keys(COORDINATION_MCP_TOOLS),
|
|
12231
12580
|
...Object.keys(EPISTEMIC_CONTRACT_MCP_TOOLS),
|
|
12232
12581
|
...Object.keys(BOOTSTRAP_MCP_TOOLS)
|
|
12233
12582
|
];
|
|
12234
|
-
function
|
|
12583
|
+
function buildGatewayClient(ctx) {
|
|
12235
12584
|
if (!ctx.gatewayBaseUrl || !ctx.getAuthHeaders) {
|
|
12236
|
-
throw new Error("
|
|
12585
|
+
throw new Error("MCP gateway bridge requires auth headers.");
|
|
12237
12586
|
}
|
|
12238
12587
|
return createGatewayRequestClient({
|
|
12239
12588
|
baseUrl: ctx.gatewayBaseUrl,
|
|
@@ -12246,12 +12595,12 @@ function withSessionId(args, ctx) {
|
|
|
12246
12595
|
__sdkSessionId: ctx.sessionId
|
|
12247
12596
|
};
|
|
12248
12597
|
}
|
|
12249
|
-
async function
|
|
12598
|
+
async function buildAuthenticatedHandlerMap() {
|
|
12250
12599
|
return Object.fromEntries(
|
|
12251
|
-
|
|
12600
|
+
GATEWAY_HANDLER_TOOL_NAMES.map((toolName) => [
|
|
12252
12601
|
toolName,
|
|
12253
12602
|
async (args, ctx) => {
|
|
12254
|
-
const gateway =
|
|
12603
|
+
const gateway = buildGatewayClient(ctx);
|
|
12255
12604
|
const response = await gateway.request({
|
|
12256
12605
|
path: `/api/platform/v1/mcp-tools/${encodeURIComponent(toolName)}`,
|
|
12257
12606
|
method: "POST",
|
|
@@ -12320,7 +12669,7 @@ function parseCredentialsFile(filePath) {
|
|
|
12320
12669
|
}
|
|
12321
12670
|
return result;
|
|
12322
12671
|
}
|
|
12323
|
-
function
|
|
12672
|
+
function resolveMcpCredentials() {
|
|
12324
12673
|
if (process.env.LUCERN_CONVEX_URL && process.env.LUCERN_DEPLOY_KEY) {
|
|
12325
12674
|
return {
|
|
12326
12675
|
lucernResolved: true,
|
|
@@ -12438,7 +12787,7 @@ function initializeLucernScriptEnv() {
|
|
|
12438
12787
|
}
|
|
12439
12788
|
}
|
|
12440
12789
|
}
|
|
12441
|
-
|
|
12790
|
+
resolveMcpCredentials();
|
|
12442
12791
|
lucernScriptEnvInitialized = true;
|
|
12443
12792
|
}
|
|
12444
12793
|
function readArg(name, fallback) {
|
|
@@ -12485,7 +12834,7 @@ async function createLucernMcpClient() {
|
|
|
12485
12834
|
const deployKey = requireEnv("LUCERN_DEPLOY_KEY");
|
|
12486
12835
|
const transport = new StdioClientTransport({
|
|
12487
12836
|
command: "npx",
|
|
12488
|
-
args: ["tsx", "
|
|
12837
|
+
args: ["tsx", "apps/mcp-server/src/index.ts"],
|
|
12489
12838
|
env: {
|
|
12490
12839
|
...process.env,
|
|
12491
12840
|
LUCERN_CONVEX_URL: convexUrl,
|
|
@@ -12509,7 +12858,7 @@ function createLucernAdminClient() {
|
|
|
12509
12858
|
}
|
|
12510
12859
|
async function resolveMcpSessionTenantId() {
|
|
12511
12860
|
initializeLucernScriptEnv();
|
|
12512
|
-
const apiKey =
|
|
12861
|
+
const apiKey = resolveMcpCredentials().rawLucernApiKey;
|
|
12513
12862
|
if (!apiKey) {
|
|
12514
12863
|
return void 0;
|
|
12515
12864
|
}
|
|
@@ -12538,8 +12887,8 @@ async function closeMcpClient(client) {
|
|
|
12538
12887
|
await client.close();
|
|
12539
12888
|
}
|
|
12540
12889
|
|
|
12541
|
-
// src/
|
|
12542
|
-
async function
|
|
12890
|
+
// src/discovery.ts
|
|
12891
|
+
async function loadDiscoveryHandlers() {
|
|
12543
12892
|
return {
|
|
12544
12893
|
async discover(args, ctx) {
|
|
12545
12894
|
const query = typeof args.query === "string" ? args.query : "";
|
|
@@ -12862,6 +13211,6 @@ function validateContextPackSchema2(payload) {
|
|
|
12862
13211
|
};
|
|
12863
13212
|
}
|
|
12864
13213
|
|
|
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,
|
|
13214
|
+
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
13215
|
//# sourceMappingURL=index.js.map
|
|
12867
13216
|
//# sourceMappingURL=index.js.map
|