@lucern/mcp 0.2.0-alpha.10 → 0.2.0-alpha.4
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 +131 -129
- package/dist/gateway.js +6422 -6931
- package/dist/gateway.js.map +1 -1
- package/dist/index.d.ts +7 -7
- package/dist/index.js +224 -572
- package/dist/index.js.map +1 -1
- package/dist/runtime.js +4276 -947
- package/dist/runtime.js.map +1 -1
- package/package.json +8 -7
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 '@lucern/reasoning-kernel/compat/contextPackPolicy';
|
|
6
7
|
import 'crypto';
|
|
7
8
|
import * as fs from 'fs';
|
|
8
9
|
import { existsSync } from 'fs';
|
|
@@ -263,38 +264,6 @@ function scoreObservation(record, terms) {
|
|
|
263
264
|
return score;
|
|
264
265
|
}
|
|
265
266
|
|
|
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
|
-
|
|
298
267
|
// ../sdk/src/coreClient.ts
|
|
299
268
|
var LucernApiError = class extends Error {
|
|
300
269
|
code;
|
|
@@ -1293,168 +1262,31 @@ function createAuditClient(config = {}) {
|
|
|
1293
1262
|
}
|
|
1294
1263
|
|
|
1295
1264
|
// ../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
|
-
}
|
|
1383
1265
|
function createBeliefsClient(config = {}) {
|
|
1384
1266
|
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
|
-
}
|
|
1407
1267
|
return {
|
|
1408
1268
|
/**
|
|
1409
1269
|
* Create a belief within a topic scope.
|
|
1410
1270
|
*/
|
|
1411
1271
|
async createBelief(input, idempotencyKey) {
|
|
1412
|
-
const baseRate = requireBaseRate2(input.baseRate);
|
|
1413
1272
|
return gateway.request({
|
|
1414
1273
|
path: "/api/platform/v1/beliefs",
|
|
1415
1274
|
method: "POST",
|
|
1416
|
-
body:
|
|
1417
|
-
...normalizeNodeWriteInput(input),
|
|
1418
|
-
baseRate
|
|
1419
|
-
},
|
|
1275
|
+
body: normalizeNodeWriteInput(input),
|
|
1420
1276
|
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
1421
1277
|
});
|
|
1422
1278
|
},
|
|
1423
1279
|
/**
|
|
1424
|
-
*
|
|
1280
|
+
* Record a confidence change for an existing belief.
|
|
1425
1281
|
*/
|
|
1426
|
-
async
|
|
1282
|
+
async modulateConfidence(beliefId, input, idempotencyKey) {
|
|
1427
1283
|
return gateway.request({
|
|
1428
|
-
path: `/api/platform/v1/beliefs/${encodeURIComponent(beliefId)}`,
|
|
1429
|
-
method: "
|
|
1430
|
-
body:
|
|
1284
|
+
path: `/api/platform/v1/beliefs/${encodeURIComponent(beliefId)}/confidence`,
|
|
1285
|
+
method: "POST",
|
|
1286
|
+
body: input,
|
|
1431
1287
|
idempotencyKey: idempotencyKey ?? randomIdempotencyKey()
|
|
1432
1288
|
});
|
|
1433
1289
|
},
|
|
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
|
-
},
|
|
1458
1290
|
/**
|
|
1459
1291
|
* Fork a scored belief into a new formulation.
|
|
1460
1292
|
*/
|
|
@@ -1545,57 +1377,6 @@ function createBeliefsClient(config = {}) {
|
|
|
1545
1377
|
}
|
|
1546
1378
|
};
|
|
1547
1379
|
}
|
|
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
|
-
}
|
|
1599
1380
|
var DEFAULT_CUSTOM_NAMESPACE = "custom";
|
|
1600
1381
|
var RESERVED_NAMESPACES = /* @__PURE__ */ new Set(["lucern"]);
|
|
1601
1382
|
var CustomToolRegistryError = class extends Error {
|
|
@@ -2385,14 +2166,14 @@ function createIdentityClient(config = {}) {
|
|
|
2385
2166
|
}
|
|
2386
2167
|
|
|
2387
2168
|
// ../sdk/src/topicsClient.ts
|
|
2388
|
-
function
|
|
2169
|
+
function asRecord2(value) {
|
|
2389
2170
|
return value && typeof value === "object" ? value : {};
|
|
2390
2171
|
}
|
|
2391
2172
|
function cleanString2(value) {
|
|
2392
2173
|
return typeof value === "string" && value.trim().length > 0 ? value.trim() : void 0;
|
|
2393
2174
|
}
|
|
2394
2175
|
function normalizeTopicRecord(value) {
|
|
2395
|
-
const record =
|
|
2176
|
+
const record = asRecord2(value);
|
|
2396
2177
|
const topicId = cleanString2(record.topicId) ?? cleanString2(record.id) ?? cleanString2(record._id);
|
|
2397
2178
|
return withTopicAlias({
|
|
2398
2179
|
...record,
|
|
@@ -2417,7 +2198,7 @@ function createTopicsClient(config = {}) {
|
|
|
2417
2198
|
})}`
|
|
2418
2199
|
}).then(
|
|
2419
2200
|
(response) => mapGatewayData(response, (data) => {
|
|
2420
|
-
const record =
|
|
2201
|
+
const record = asRecord2(data);
|
|
2421
2202
|
const items = Array.isArray(record.topics) ? record.topics.map(normalizeTopicRecord) : [];
|
|
2422
2203
|
return {
|
|
2423
2204
|
...createListResult(items, "topics"),
|
|
@@ -2434,7 +2215,7 @@ function createTopicsClient(config = {}) {
|
|
|
2434
2215
|
}).then(
|
|
2435
2216
|
(response) => mapGatewayData(
|
|
2436
2217
|
response,
|
|
2437
|
-
(data) => normalizeTopicRecord(
|
|
2218
|
+
(data) => normalizeTopicRecord(asRecord2(data).topic ?? data)
|
|
2438
2219
|
)
|
|
2439
2220
|
);
|
|
2440
2221
|
},
|
|
@@ -2470,7 +2251,7 @@ function createTopicsClient(config = {}) {
|
|
|
2470
2251
|
)}`
|
|
2471
2252
|
}).then(
|
|
2472
2253
|
(response) => mapGatewayData(response, (data) => {
|
|
2473
|
-
const record =
|
|
2254
|
+
const record = asRecord2(data);
|
|
2474
2255
|
return {
|
|
2475
2256
|
tree: Array.isArray(record.tree) ? record.tree.map(normalizeTopicTreeNode) : []
|
|
2476
2257
|
};
|
|
@@ -2504,22 +2285,6 @@ function createTopicsClient(config = {}) {
|
|
|
2504
2285
|
}
|
|
2505
2286
|
|
|
2506
2287
|
// ../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
|
-
}
|
|
2523
2288
|
function serializeTypes(types) {
|
|
2524
2289
|
return Array.isArray(types) && types.length > 0 ? types.join(",") : void 0;
|
|
2525
2290
|
}
|
|
@@ -2571,7 +2336,7 @@ function createBeliefsFacade(config = {}) {
|
|
|
2571
2336
|
return gateway.request({
|
|
2572
2337
|
path: `/api/platform/v1/beliefs/${encodeURIComponent(id)}/confidence`,
|
|
2573
2338
|
method: "POST",
|
|
2574
|
-
body:
|
|
2339
|
+
body: input,
|
|
2575
2340
|
idempotencyKey
|
|
2576
2341
|
});
|
|
2577
2342
|
},
|
|
@@ -2649,11 +2414,6 @@ function createBeliefsFacade(config = {}) {
|
|
|
2649
2414
|
path: `/api/platform/v1/beliefs/${encodeURIComponent(id)}/confidence-history`
|
|
2650
2415
|
});
|
|
2651
2416
|
},
|
|
2652
|
-
async opinionHistory(id) {
|
|
2653
|
-
return gateway.request({
|
|
2654
|
-
path: `/api/platform/v1/beliefs/${encodeURIComponent(id)}/confidence-history`
|
|
2655
|
-
});
|
|
2656
|
-
},
|
|
2657
2417
|
async createContract(id, input, idempotencyKey = randomIdempotencyKey()) {
|
|
2658
2418
|
return gateway.request({
|
|
2659
2419
|
path: `/api/platform/v1/beliefs/${encodeURIComponent(id)}/contracts`,
|
|
@@ -5133,24 +4893,13 @@ function requireText(args) {
|
|
|
5133
4893
|
}
|
|
5134
4894
|
return text;
|
|
5135
4895
|
}
|
|
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
|
-
}
|
|
5145
4896
|
function exposeGatewayData(response) {
|
|
5146
4897
|
return Object.assign({}, response, response.data);
|
|
5147
4898
|
}
|
|
5148
4899
|
function createLucernClient(config = {}) {
|
|
5149
4900
|
const gatewayConfig = toGatewayConfig(config);
|
|
5150
4901
|
const beliefsClient = createBeliefsClient(gatewayConfig);
|
|
5151
|
-
const sourcesClient = createSourcesClient(gatewayConfig);
|
|
5152
4902
|
const beliefsFacade = createBeliefsFacade(gatewayConfig);
|
|
5153
|
-
const evidenceClient = createEvidenceClient(gatewayConfig);
|
|
5154
4903
|
const graphClient = createGraphClient(gatewayConfig);
|
|
5155
4904
|
const graphFacade = createGraphFacade(gatewayConfig);
|
|
5156
4905
|
const decisionsClient = createDecisionsClient(gatewayConfig);
|
|
@@ -5391,10 +5140,6 @@ function createLucernClient(config = {}) {
|
|
|
5391
5140
|
async function getConfidenceHistory(nodeId) {
|
|
5392
5141
|
return beliefsFacade.confidenceHistory(nodeId).then(exposeGatewayData);
|
|
5393
5142
|
}
|
|
5394
|
-
async function getOpinionHistory(nodeId) {
|
|
5395
|
-
const response = await beliefsFacade.opinionHistory(nodeId);
|
|
5396
|
-
return mapOpinionHistoryEntriesFromGatewayData(response.data);
|
|
5397
|
-
}
|
|
5398
5143
|
async function getAuditTrail(nodeId, limit = 50) {
|
|
5399
5144
|
const events = await auditClient.listEvents({ limit });
|
|
5400
5145
|
const entries = asListItems(events.data, "events").filter((event) => matchesAuditNodeReference(event, nodeId)).slice(0, limit).map((event) => {
|
|
@@ -5580,7 +5325,6 @@ function createLucernClient(config = {}) {
|
|
|
5580
5325
|
rationale: input.rationale,
|
|
5581
5326
|
worktreeId: input.worktreeId,
|
|
5582
5327
|
pillar: input.pillar,
|
|
5583
|
-
baseRate: requireBaseRate(input),
|
|
5584
5328
|
sourceBeliefIds: input.sourceBeliefIds,
|
|
5585
5329
|
sourceType: input.sourceType,
|
|
5586
5330
|
beliefType: input.beliefType,
|
|
@@ -5654,9 +5398,6 @@ function createLucernClient(config = {}) {
|
|
|
5654
5398
|
confidenceHistory(nodeId) {
|
|
5655
5399
|
return beliefsFacade.confidenceHistory(nodeId).then(exposeGatewayData);
|
|
5656
5400
|
},
|
|
5657
|
-
opinionHistory(nodeId) {
|
|
5658
|
-
return getOpinionHistory(nodeId);
|
|
5659
|
-
},
|
|
5660
5401
|
createContract(nodeId, input) {
|
|
5661
5402
|
return beliefsFacade.createContract(nodeId, input).then(exposeGatewayData);
|
|
5662
5403
|
},
|
|
@@ -5788,12 +5529,6 @@ function createLucernClient(config = {}) {
|
|
|
5788
5529
|
beliefId: args.beliefId
|
|
5789
5530
|
}));
|
|
5790
5531
|
},
|
|
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
|
-
},
|
|
5797
5532
|
updateStatus(input, idempotencyKey) {
|
|
5798
5533
|
return evidenceFacade.updateStatus(input, idempotencyKey).then(exposeGatewayData);
|
|
5799
5534
|
},
|
|
@@ -5810,14 +5545,6 @@ function createLucernClient(config = {}) {
|
|
|
5810
5545
|
return evidenceFacade.updateVerificationStatus(input, idempotencyKey).then(exposeGatewayData);
|
|
5811
5546
|
}
|
|
5812
5547
|
},
|
|
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
|
-
},
|
|
5821
5548
|
questions: {
|
|
5822
5549
|
create(args) {
|
|
5823
5550
|
return questionsFacade.create({
|
|
@@ -5943,7 +5670,6 @@ function createLucernClient(config = {}) {
|
|
|
5943
5670
|
},
|
|
5944
5671
|
queryLineage,
|
|
5945
5672
|
getConfidenceHistory,
|
|
5946
|
-
getOpinionHistory,
|
|
5947
5673
|
getAuditTrail,
|
|
5948
5674
|
traverse(args) {
|
|
5949
5675
|
return graphFacade.traverse({
|
|
@@ -6646,8 +6372,6 @@ function createLucernClient(config = {}) {
|
|
|
6646
6372
|
extensions: extensionNamespaces,
|
|
6647
6373
|
raw: {
|
|
6648
6374
|
beliefs: beliefsClient,
|
|
6649
|
-
sources: sourcesClient,
|
|
6650
|
-
evidence: evidenceClient,
|
|
6651
6375
|
graph: graphClient,
|
|
6652
6376
|
decisions: decisionsClient,
|
|
6653
6377
|
workflow: workflowClient,
|
|
@@ -6846,17 +6570,13 @@ var LENS_PERSPECTIVE_TYPES = [
|
|
|
6846
6570
|
// ../sdk/src/contracts/mcp-tools.contract.ts
|
|
6847
6571
|
var CREATE_BELIEF = {
|
|
6848
6572
|
name: "create_belief",
|
|
6849
|
-
description: "Commit a new belief (knowledge unit) to the reasoning graph. Like `git commit` \u2014 creates an atomic, traceable knowledge object
|
|
6573
|
+
description: "Commit a new belief (knowledge unit) to the reasoning graph. Like `git commit` \u2014 creates an atomic, traceable knowledge object. The belief starts as unscored (draft). Score it with modulate_confidence to freeze the formulation.",
|
|
6850
6574
|
parameters: {
|
|
6851
6575
|
canonicalText: {
|
|
6852
6576
|
type: "string",
|
|
6853
6577
|
description: "The belief statement \u2014 what the agent holds to be true"
|
|
6854
6578
|
},
|
|
6855
6579
|
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
|
-
},
|
|
6860
6580
|
beliefType: {
|
|
6861
6581
|
type: "string",
|
|
6862
6582
|
description: "Belief type (e.g., hypothesis, belief, principle, invariant, tenet, forecast). Validated against schemaEnumConfig."
|
|
@@ -6866,7 +6586,7 @@ var CREATE_BELIEF = {
|
|
|
6866
6586
|
description: "Optional extra metadata merged into the node (e.g., { codeAnchors: ['path/to/file.ts'] } for coding intelligence)"
|
|
6867
6587
|
}
|
|
6868
6588
|
},
|
|
6869
|
-
required: ["canonicalText", "topicId"
|
|
6589
|
+
required: ["canonicalText", "topicId"],
|
|
6870
6590
|
response: {
|
|
6871
6591
|
description: "The created canonical belief record",
|
|
6872
6592
|
fields: {
|
|
@@ -6929,43 +6649,17 @@ var REFINE_BELIEF = {
|
|
|
6929
6649
|
};
|
|
6930
6650
|
var MODULATE_CONFIDENCE = {
|
|
6931
6651
|
name: "modulate_confidence",
|
|
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.
|
|
6652
|
+
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, merge_outcome, manual, decay.",
|
|
6933
6653
|
parameters: {
|
|
6934
6654
|
nodeId: { type: "string", description: "The belief to score" },
|
|
6935
|
-
|
|
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
|
+
confidence: { type: "number", description: "Confidence level in [0, 1]" },
|
|
6955
6656
|
trigger: {
|
|
6956
6657
|
type: "string",
|
|
6957
6658
|
description: "What caused this confidence change",
|
|
6958
6659
|
enum: [
|
|
6959
6660
|
"evidence_added",
|
|
6960
|
-
"evidence_removed",
|
|
6961
6661
|
"contradiction_detected",
|
|
6962
|
-
"
|
|
6963
|
-
"agent_assessment",
|
|
6964
|
-
"worktree_outcome",
|
|
6965
|
-
"worktree_completed",
|
|
6966
|
-
"fusion",
|
|
6967
|
-
"discount",
|
|
6968
|
-
"deduction",
|
|
6662
|
+
"merge_outcome",
|
|
6969
6663
|
"manual",
|
|
6970
6664
|
"decay"
|
|
6971
6665
|
]
|
|
@@ -6975,7 +6669,7 @@ var MODULATE_CONFIDENCE = {
|
|
|
6975
6669
|
description: "Human-readable explanation of why confidence changed"
|
|
6976
6670
|
}
|
|
6977
6671
|
},
|
|
6978
|
-
required: ["nodeId", "trigger", "rationale"],
|
|
6672
|
+
required: ["nodeId", "confidence", "trigger", "rationale"],
|
|
6979
6673
|
response: {
|
|
6980
6674
|
description: "Confidence modulation result",
|
|
6981
6675
|
fields: {
|
|
@@ -7617,7 +7311,7 @@ var RECORD_JUDGMENT = {
|
|
|
7617
7311
|
status: "string \u2014 'issued'"
|
|
7618
7312
|
}
|
|
7619
7313
|
},
|
|
7620
|
-
ownerModule: "
|
|
7314
|
+
ownerModule: "decision-state",
|
|
7621
7315
|
ontologyPrimitive: "judgment",
|
|
7622
7316
|
tier: "showcase"
|
|
7623
7317
|
};
|
|
@@ -8886,7 +8580,7 @@ var INGEST_OBSERVATION = {
|
|
|
8886
8580
|
contextResourceUri: "string"
|
|
8887
8581
|
}
|
|
8888
8582
|
},
|
|
8889
|
-
ownerModule: "agent-
|
|
8583
|
+
ownerModule: "agent-harness",
|
|
8890
8584
|
ontologyPrimitive: "graph",
|
|
8891
8585
|
tier: "workhorse"
|
|
8892
8586
|
};
|
|
@@ -8916,7 +8610,7 @@ var GET_OBSERVATION_CONTEXT = {
|
|
|
8916
8610
|
generatedAt: "number"
|
|
8917
8611
|
}
|
|
8918
8612
|
},
|
|
8919
|
-
ownerModule: "agent-
|
|
8613
|
+
ownerModule: "agent-harness",
|
|
8920
8614
|
ontologyPrimitive: "graph",
|
|
8921
8615
|
tier: "workhorse"
|
|
8922
8616
|
};
|
|
@@ -9834,7 +9528,6 @@ var MCP_TOOL_CONTRACTS = {
|
|
|
9834
9528
|
deprecate_ontology_version: DEPRECATE_ONTOLOGY_VERSION,
|
|
9835
9529
|
resolve_effective_ontology: RESOLVE_EFFECTIVE_ONTOLOGY
|
|
9836
9530
|
};
|
|
9837
|
-
globalThis.process?.env;
|
|
9838
9531
|
|
|
9839
9532
|
// ../sdk/src/mcpParitySurface.ts
|
|
9840
9533
|
var SDK_MCP_PARITY_METHODS = [
|
|
@@ -9902,13 +9595,11 @@ SDK_MCP_PARITY_METHODS.map(
|
|
|
9902
9595
|
var McpHandlerError = class extends Error {
|
|
9903
9596
|
code;
|
|
9904
9597
|
status;
|
|
9905
|
-
|
|
9906
|
-
constructor(message, code = "INVALID_REQUEST", status = 400, suggestion) {
|
|
9598
|
+
constructor(message, code = "INVALID_REQUEST", status = 400) {
|
|
9907
9599
|
super(message);
|
|
9908
9600
|
this.name = "McpHandlerError";
|
|
9909
9601
|
this.code = code;
|
|
9910
9602
|
this.status = status;
|
|
9911
|
-
this.suggestion = suggestion;
|
|
9912
9603
|
}
|
|
9913
9604
|
};
|
|
9914
9605
|
|
|
@@ -9925,7 +9616,7 @@ function isMissing(value) {
|
|
|
9925
9616
|
}
|
|
9926
9617
|
return false;
|
|
9927
9618
|
}
|
|
9928
|
-
function
|
|
9619
|
+
function readString(params, key, options = {}) {
|
|
9929
9620
|
const value = params[key];
|
|
9930
9621
|
if (value === void 0 || value === null) {
|
|
9931
9622
|
if (options.required) {
|
|
@@ -9942,7 +9633,7 @@ function readString2(params, key, options = {}) {
|
|
|
9942
9633
|
}
|
|
9943
9634
|
return trimmed || void 0;
|
|
9944
9635
|
}
|
|
9945
|
-
function
|
|
9636
|
+
function readNumber(params, key, options = {}) {
|
|
9946
9637
|
const value = params[key];
|
|
9947
9638
|
if (value === void 0 || value === null) {
|
|
9948
9639
|
if (options.required) {
|
|
@@ -10011,8 +9702,7 @@ function toMcpError(error) {
|
|
|
10011
9702
|
text: JSON.stringify({
|
|
10012
9703
|
code: error.code,
|
|
10013
9704
|
status: error.status,
|
|
10014
|
-
message: error.message
|
|
10015
|
-
suggestion: error.suggestion ?? null
|
|
9705
|
+
message: error.message
|
|
10016
9706
|
})
|
|
10017
9707
|
}
|
|
10018
9708
|
]
|
|
@@ -10081,45 +9771,6 @@ function contractToHandler(contract, executor) {
|
|
|
10081
9771
|
}
|
|
10082
9772
|
|
|
10083
9773
|
// 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
|
-
}
|
|
10123
9774
|
function createBeliefHandlers(context) {
|
|
10124
9775
|
const beliefs = createBeliefsClient(context.sdkConfig);
|
|
10125
9776
|
const graph = createGraphClient(context.sdkConfig);
|
|
@@ -10128,14 +9779,13 @@ function createBeliefHandlers(context) {
|
|
|
10128
9779
|
MCP_TOOL_CONTRACTS.create_belief,
|
|
10129
9780
|
async (params) => {
|
|
10130
9781
|
const result = await beliefs.createBelief({
|
|
10131
|
-
canonicalText:
|
|
9782
|
+
canonicalText: readString(params, "canonicalText", {
|
|
10132
9783
|
required: true
|
|
10133
9784
|
}),
|
|
10134
9785
|
topicId: readTopicId(params, { required: true }),
|
|
10135
|
-
layer:
|
|
10136
|
-
domain:
|
|
10137
|
-
subtype:
|
|
10138
|
-
baseRate: readNumber2(params, "baseRate", { required: true })
|
|
9786
|
+
layer: readString(params, "layer"),
|
|
9787
|
+
domain: readString(params, "domain"),
|
|
9788
|
+
subtype: readString(params, "nodeType")
|
|
10139
9789
|
});
|
|
10140
9790
|
return {
|
|
10141
9791
|
nodeId: result.data.nodeId,
|
|
@@ -10147,49 +9797,51 @@ function createBeliefHandlers(context) {
|
|
|
10147
9797
|
refine_belief: contractToHandler(
|
|
10148
9798
|
MCP_TOOL_CONTRACTS.refine_belief,
|
|
10149
9799
|
async (params) => {
|
|
10150
|
-
const nodeId =
|
|
10151
|
-
const canonicalText =
|
|
9800
|
+
const nodeId = readString(params, "nodeId", { required: true });
|
|
9801
|
+
const canonicalText = readString(params, "canonicalText", {
|
|
10152
9802
|
required: true
|
|
10153
9803
|
});
|
|
10154
|
-
const rationale =
|
|
10155
|
-
const result = await
|
|
9804
|
+
const rationale = readString(params, "rationale");
|
|
9805
|
+
const result = await graph.updateNode({
|
|
9806
|
+
nodeId,
|
|
10156
9807
|
canonicalText,
|
|
10157
|
-
rationale
|
|
9808
|
+
metadata: rationale ? {
|
|
9809
|
+
lastRefinementRationale: rationale
|
|
9810
|
+
} : void 0
|
|
10158
9811
|
});
|
|
10159
9812
|
return {
|
|
10160
9813
|
nodeId: result.data.nodeId ?? nodeId,
|
|
10161
9814
|
canonicalText: result.data.canonicalText ?? canonicalText,
|
|
10162
|
-
updatedAt:
|
|
9815
|
+
updatedAt: Date.now()
|
|
10163
9816
|
};
|
|
10164
9817
|
}
|
|
10165
9818
|
),
|
|
10166
9819
|
modulate_confidence: contractToHandler(
|
|
10167
9820
|
MCP_TOOL_CONTRACTS.modulate_confidence,
|
|
10168
9821
|
async (params) => {
|
|
10169
|
-
const nodeId =
|
|
10170
|
-
const opinion = readOpinionTuple(params);
|
|
9822
|
+
const nodeId = readString(params, "nodeId", { required: true });
|
|
10171
9823
|
const result = await beliefs.modulateConfidence(nodeId, {
|
|
10172
|
-
|
|
10173
|
-
trigger:
|
|
10174
|
-
rationale:
|
|
9824
|
+
confidence: readNumber(params, "confidence", { required: true }),
|
|
9825
|
+
trigger: readString(params, "trigger", { required: true }),
|
|
9826
|
+
rationale: readString(params, "rationale", { required: true })
|
|
10175
9827
|
});
|
|
10176
9828
|
return {
|
|
10177
9829
|
nodeId,
|
|
10178
|
-
newConfidence: result.data.newConfidence ?? result.data.confidence ??
|
|
9830
|
+
newConfidence: result.data.newConfidence ?? result.data.confidence ?? readNumber(params, "confidence", { required: true }),
|
|
10179
9831
|
previousConfidence: result.data.previousConfidence ?? null,
|
|
10180
|
-
trigger:
|
|
9832
|
+
trigger: readString(params, "trigger", { required: true })
|
|
10181
9833
|
};
|
|
10182
9834
|
}
|
|
10183
9835
|
),
|
|
10184
9836
|
fork_belief: contractToHandler(
|
|
10185
9837
|
MCP_TOOL_CONTRACTS.fork_belief,
|
|
10186
9838
|
async (params) => {
|
|
10187
|
-
const nodeId =
|
|
10188
|
-
const forkReason =
|
|
9839
|
+
const nodeId = readString(params, "nodeId", { required: true });
|
|
9840
|
+
const forkReason = readString(params, "forkReason", {
|
|
10189
9841
|
required: true
|
|
10190
9842
|
});
|
|
10191
9843
|
const result = await beliefs.forkBelief(nodeId, {
|
|
10192
|
-
newFormulation:
|
|
9844
|
+
newFormulation: readString(params, "newFormulation", {
|
|
10193
9845
|
required: true
|
|
10194
9846
|
}),
|
|
10195
9847
|
forkReason
|
|
@@ -10204,8 +9856,8 @@ function createBeliefHandlers(context) {
|
|
|
10204
9856
|
archive_belief: contractToHandler(
|
|
10205
9857
|
MCP_TOOL_CONTRACTS.archive_belief,
|
|
10206
9858
|
async (params) => {
|
|
10207
|
-
const nodeId =
|
|
10208
|
-
const rationale =
|
|
9859
|
+
const nodeId = readString(params, "nodeId", { required: true });
|
|
9860
|
+
const rationale = readString(params, "rationale");
|
|
10209
9861
|
const result = await graph.updateNode({
|
|
10210
9862
|
nodeId,
|
|
10211
9863
|
status: "archived",
|
|
@@ -10232,13 +9884,13 @@ function createContextHandlers(context) {
|
|
|
10232
9884
|
const response = await compiler.compile(
|
|
10233
9885
|
readTopicId(params, { required: true }),
|
|
10234
9886
|
{
|
|
10235
|
-
...
|
|
10236
|
-
...
|
|
10237
|
-
...
|
|
10238
|
-
ranking:
|
|
9887
|
+
...readString(params, "query") ? { query: readString(params, "query") } : {},
|
|
9888
|
+
...readNumber(params, "budget") !== void 0 ? { budget: readNumber(params, "budget") } : {},
|
|
9889
|
+
...readString(params, "ranking") ? {
|
|
9890
|
+
ranking: readString(params, "ranking")
|
|
10239
9891
|
} : {},
|
|
10240
|
-
...
|
|
10241
|
-
...
|
|
9892
|
+
...readNumber(params, "limit") !== void 0 ? { limit: readNumber(params, "limit") } : {},
|
|
9893
|
+
...readNumber(params, "maxDepth") !== void 0 ? { maxDepth: readNumber(params, "maxDepth") } : {},
|
|
10242
9894
|
...readBoolean(params, "includeEntities") !== void 0 ? { includeEntities: readBoolean(params, "includeEntities") } : {}
|
|
10243
9895
|
}
|
|
10244
9896
|
);
|
|
@@ -10255,14 +9907,14 @@ function createContradictionHandlers(context) {
|
|
|
10255
9907
|
flag_contradiction: contractToHandler(
|
|
10256
9908
|
MCP_TOOL_CONTRACTS.flag_contradiction,
|
|
10257
9909
|
async (params) => {
|
|
10258
|
-
const beliefA =
|
|
10259
|
-
const beliefB =
|
|
10260
|
-
const description =
|
|
9910
|
+
const beliefA = readString(params, "beliefA", { required: true });
|
|
9911
|
+
const beliefB = readString(params, "beliefB", { required: true });
|
|
9912
|
+
const description = readString(params, "description", {
|
|
10261
9913
|
required: true
|
|
10262
9914
|
});
|
|
10263
9915
|
const topicId = readTopicId(params, { required: true });
|
|
10264
|
-
const severity =
|
|
10265
|
-
const defeatType =
|
|
9916
|
+
const severity = readString(params, "severity") ?? "medium";
|
|
9917
|
+
const defeatType = readString(params, "defeatType") ?? "rebuts";
|
|
10266
9918
|
const contradiction = await lucern.contradictions.flag({
|
|
10267
9919
|
beliefA,
|
|
10268
9920
|
beliefB,
|
|
@@ -10289,12 +9941,12 @@ function createEdgeHandlers(context) {
|
|
|
10289
9941
|
create_edge: contractToHandler(
|
|
10290
9942
|
MCP_TOOL_CONTRACTS.create_edge,
|
|
10291
9943
|
async (params) => {
|
|
10292
|
-
const sourceId =
|
|
10293
|
-
const targetId =
|
|
10294
|
-
const edgeType =
|
|
10295
|
-
const confidence =
|
|
10296
|
-
const weight =
|
|
10297
|
-
const contextText =
|
|
9944
|
+
const sourceId = readString(params, "sourceId", { required: true });
|
|
9945
|
+
const targetId = readString(params, "targetId", { required: true });
|
|
9946
|
+
const edgeType = readString(params, "edgeType", { required: true });
|
|
9947
|
+
const confidence = readNumber(params, "confidence");
|
|
9948
|
+
const weight = readNumber(params, "weight");
|
|
9949
|
+
const contextText = readString(params, "context") ?? readString(params, "reasoning");
|
|
10298
9950
|
const edge = await lucern.edges.create({
|
|
10299
9951
|
sourceId,
|
|
10300
9952
|
targetId,
|
|
@@ -10327,15 +9979,15 @@ function createEvidenceHandlers(context) {
|
|
|
10327
9979
|
async (params) => {
|
|
10328
9980
|
const response = await lucern.evidence.create({
|
|
10329
9981
|
topicId: readTopicId(params, { required: true }),
|
|
10330
|
-
text:
|
|
10331
|
-
source:
|
|
10332
|
-
targetId:
|
|
10333
|
-
weight:
|
|
9982
|
+
text: readString(params, "text", { required: true }),
|
|
9983
|
+
source: readString(params, "source"),
|
|
9984
|
+
targetId: readString(params, "targetId"),
|
|
9985
|
+
weight: readNumber(params, "weight"),
|
|
10334
9986
|
metadata: readMetadata(params),
|
|
10335
|
-
title:
|
|
10336
|
-
content:
|
|
10337
|
-
contentType:
|
|
10338
|
-
kind:
|
|
9987
|
+
title: readString(params, "title"),
|
|
9988
|
+
content: readString(params, "content"),
|
|
9989
|
+
contentType: readString(params, "contentType"),
|
|
9990
|
+
kind: readString(params, "kind")
|
|
10339
9991
|
});
|
|
10340
9992
|
return response.data;
|
|
10341
9993
|
}
|
|
@@ -10344,7 +9996,7 @@ function createEvidenceHandlers(context) {
|
|
|
10344
9996
|
MCP_TOOL_CONTRACTS.get_evidence,
|
|
10345
9997
|
async (params) => {
|
|
10346
9998
|
const response = await lucern.evidence.get(
|
|
10347
|
-
|
|
9999
|
+
readString(params, "id", { required: true })
|
|
10348
10000
|
);
|
|
10349
10001
|
return response.data;
|
|
10350
10002
|
}
|
|
@@ -10354,9 +10006,9 @@ function createEvidenceHandlers(context) {
|
|
|
10354
10006
|
async (params) => {
|
|
10355
10007
|
const response = await lucern.evidence.list({
|
|
10356
10008
|
topicId: readTopicId(params),
|
|
10357
|
-
targetId:
|
|
10358
|
-
limit:
|
|
10359
|
-
cursor:
|
|
10009
|
+
targetId: readString(params, "targetId"),
|
|
10010
|
+
limit: readNumber(params, "limit"),
|
|
10011
|
+
cursor: readString(params, "cursor")
|
|
10360
10012
|
});
|
|
10361
10013
|
return response.data;
|
|
10362
10014
|
}
|
|
@@ -10365,10 +10017,10 @@ function createEvidenceHandlers(context) {
|
|
|
10365
10017
|
MCP_TOOL_CONTRACTS.link_evidence,
|
|
10366
10018
|
async (params) => {
|
|
10367
10019
|
const response = await lucern.evidence.link({
|
|
10368
|
-
evidenceId:
|
|
10369
|
-
targetId:
|
|
10370
|
-
weight:
|
|
10371
|
-
rationale:
|
|
10020
|
+
evidenceId: readString(params, "evidenceId", { required: true }),
|
|
10021
|
+
targetId: readString(params, "targetId", { required: true }),
|
|
10022
|
+
weight: readNumber(params, "weight"),
|
|
10023
|
+
rationale: readString(params, "rationale")
|
|
10372
10024
|
});
|
|
10373
10025
|
return response.data;
|
|
10374
10026
|
}
|
|
@@ -10377,11 +10029,11 @@ function createEvidenceHandlers(context) {
|
|
|
10377
10029
|
MCP_TOOL_CONTRACTS.search_evidence,
|
|
10378
10030
|
async (params) => {
|
|
10379
10031
|
const response = await lucern.evidence.search({
|
|
10380
|
-
q:
|
|
10032
|
+
q: readString(params, "q") ?? readString(params, "query", { required: true }),
|
|
10381
10033
|
topicId: readTopicId(params),
|
|
10382
|
-
targetId:
|
|
10383
|
-
limit:
|
|
10384
|
-
cursor:
|
|
10034
|
+
targetId: readString(params, "targetId"),
|
|
10035
|
+
limit: readNumber(params, "limit"),
|
|
10036
|
+
cursor: readString(params, "cursor")
|
|
10385
10037
|
});
|
|
10386
10038
|
return response.data;
|
|
10387
10039
|
}
|
|
@@ -10390,17 +10042,17 @@ function createEvidenceHandlers(context) {
|
|
|
10390
10042
|
MCP_TOOL_CONTRACTS.add_evidence,
|
|
10391
10043
|
async (params) => {
|
|
10392
10044
|
return lucern.evidence.add({
|
|
10393
|
-
canonicalText:
|
|
10045
|
+
canonicalText: readString(params, "canonicalText", { required: true }),
|
|
10394
10046
|
topicId: readTopicId(params, { required: true }),
|
|
10395
|
-
sourceUrl:
|
|
10047
|
+
sourceUrl: readString(params, "sourceUrl"),
|
|
10396
10048
|
supports: {
|
|
10397
|
-
nodeId:
|
|
10398
|
-
weight:
|
|
10399
|
-
reasoning:
|
|
10049
|
+
nodeId: readString(params, "targetNodeId", { required: true }),
|
|
10050
|
+
weight: readNumber(params, "weight") ?? 1,
|
|
10051
|
+
reasoning: readString(params, "reasoning")
|
|
10400
10052
|
},
|
|
10401
|
-
title:
|
|
10402
|
-
content:
|
|
10403
|
-
contentType:
|
|
10053
|
+
title: readString(params, "title"),
|
|
10054
|
+
content: readString(params, "content"),
|
|
10055
|
+
contentType: readString(params, "contentType"),
|
|
10404
10056
|
metadata: readMetadata(params)
|
|
10405
10057
|
});
|
|
10406
10058
|
}
|
|
@@ -10409,10 +10061,10 @@ function createEvidenceHandlers(context) {
|
|
|
10409
10061
|
MCP_TOOL_CONTRACTS.link_evidence_to_belief,
|
|
10410
10062
|
async (params) => {
|
|
10411
10063
|
return lucern.evidence.linkToBelief({
|
|
10412
|
-
evidenceId:
|
|
10413
|
-
beliefId:
|
|
10414
|
-
weight:
|
|
10415
|
-
rationale:
|
|
10064
|
+
evidenceId: readString(params, "evidenceId", { required: true }),
|
|
10065
|
+
beliefId: readString(params, "beliefId", { required: true }),
|
|
10066
|
+
weight: readNumber(params, "weight", { required: true }),
|
|
10067
|
+
rationale: readString(params, "rationale")
|
|
10416
10068
|
});
|
|
10417
10069
|
}
|
|
10418
10070
|
)
|
|
@@ -10527,8 +10179,8 @@ function createGraphHandlers(context) {
|
|
|
10527
10179
|
query_lineage: contractToHandler(
|
|
10528
10180
|
MCP_TOOL_CONTRACTS.query_lineage,
|
|
10529
10181
|
async (params) => {
|
|
10530
|
-
const nodeId =
|
|
10531
|
-
const depth =
|
|
10182
|
+
const nodeId = readString(params, "nodeId", { required: true });
|
|
10183
|
+
const depth = readNumber(params, "depth") ?? 5;
|
|
10532
10184
|
const [parentEdgesResponse, childEdgesResponse] = await Promise.all([
|
|
10533
10185
|
graph.queryEdges({
|
|
10534
10186
|
toNodeId: nodeId,
|
|
@@ -10565,7 +10217,7 @@ function createGraphHandlers(context) {
|
|
|
10565
10217
|
get_confidence_history: contractToHandler(
|
|
10566
10218
|
MCP_TOOL_CONTRACTS.get_confidence_history,
|
|
10567
10219
|
async (params) => {
|
|
10568
|
-
const nodeId =
|
|
10220
|
+
const nodeId = readString(params, "nodeId", { required: true });
|
|
10569
10221
|
const entries = await getConfidenceEntries(nodeId);
|
|
10570
10222
|
return { entries };
|
|
10571
10223
|
}
|
|
@@ -10573,8 +10225,8 @@ function createGraphHandlers(context) {
|
|
|
10573
10225
|
get_audit_trail: contractToHandler(
|
|
10574
10226
|
MCP_TOOL_CONTRACTS.get_audit_trail,
|
|
10575
10227
|
async (params) => {
|
|
10576
|
-
const nodeId =
|
|
10577
|
-
const limit =
|
|
10228
|
+
const nodeId = readString(params, "nodeId", { required: true });
|
|
10229
|
+
const limit = readNumber(params, "limit") ?? 50;
|
|
10578
10230
|
const events = await audit.listEvents({ limit: Math.max(1, limit) });
|
|
10579
10231
|
const entries = asAuditArray(events.data).filter((entry) => matchesAuditNodeReference2(entry, nodeId)).slice(0, limit).map((entry) => ({
|
|
10580
10232
|
action: entry.action ?? "unknown",
|
|
@@ -10591,9 +10243,9 @@ function createGraphHandlers(context) {
|
|
|
10591
10243
|
MCP_TOOL_CONTRACTS.traverse_graph,
|
|
10592
10244
|
async (params) => {
|
|
10593
10245
|
const response = await graph.traverse({
|
|
10594
|
-
startNode:
|
|
10595
|
-
direction:
|
|
10596
|
-
maxDepth:
|
|
10246
|
+
startNode: readString(params, "startNode", { required: true }),
|
|
10247
|
+
direction: readString(params, "direction"),
|
|
10248
|
+
maxDepth: readNumber(params, "maxDepth"),
|
|
10597
10249
|
topicId: readTopicId(params)
|
|
10598
10250
|
});
|
|
10599
10251
|
return response.data;
|
|
@@ -10604,9 +10256,9 @@ function createGraphHandlers(context) {
|
|
|
10604
10256
|
async (params) => {
|
|
10605
10257
|
const globalIds = readStringArray(params, "globalIds");
|
|
10606
10258
|
const response = await graph.neighborhood({
|
|
10607
|
-
globalId:
|
|
10259
|
+
globalId: readString(params, "globalId"),
|
|
10608
10260
|
globalIds: globalIds ? globalIds.join(",") : void 0,
|
|
10609
|
-
maxDepth:
|
|
10261
|
+
maxDepth: readNumber(params, "maxDepth")
|
|
10610
10262
|
});
|
|
10611
10263
|
return response.data;
|
|
10612
10264
|
}
|
|
@@ -10614,11 +10266,11 @@ function createGraphHandlers(context) {
|
|
|
10614
10266
|
search_beliefs: contractToHandler(
|
|
10615
10267
|
MCP_TOOL_CONTRACTS.search_beliefs,
|
|
10616
10268
|
async (params) => {
|
|
10617
|
-
const query =
|
|
10269
|
+
const query = readString(params, "query", { required: true });
|
|
10618
10270
|
const topicId = readTopicId(params);
|
|
10619
|
-
const status =
|
|
10620
|
-
const minConfidence =
|
|
10621
|
-
const limit =
|
|
10271
|
+
const status = readString(params, "status");
|
|
10272
|
+
const minConfidence = readNumber(params, "minConfidence");
|
|
10273
|
+
const limit = readNumber(params, "limit") ?? 10;
|
|
10622
10274
|
if (!topicId) {
|
|
10623
10275
|
return { results: [] };
|
|
10624
10276
|
}
|
|
@@ -10644,8 +10296,8 @@ function createGraphHandlers(context) {
|
|
|
10644
10296
|
MCP_TOOL_CONTRACTS.find_contradictions,
|
|
10645
10297
|
async (params) => {
|
|
10646
10298
|
const topicId = readTopicId(params);
|
|
10647
|
-
const nodeId =
|
|
10648
|
-
const status =
|
|
10299
|
+
const nodeId = readString(params, "nodeId");
|
|
10300
|
+
const status = readString(params, "status");
|
|
10649
10301
|
if (!topicId && !nodeId) {
|
|
10650
10302
|
return { contradictions: [] };
|
|
10651
10303
|
}
|
|
@@ -10677,8 +10329,8 @@ function createGraphHandlers(context) {
|
|
|
10677
10329
|
bisect_confidence: contractToHandler(
|
|
10678
10330
|
MCP_TOOL_CONTRACTS.bisect_confidence,
|
|
10679
10331
|
async (params) => {
|
|
10680
|
-
const nodeId =
|
|
10681
|
-
const expectedDirection =
|
|
10332
|
+
const nodeId = readString(params, "nodeId", { required: true });
|
|
10333
|
+
const expectedDirection = readString(params, "expectedDirection", {
|
|
10682
10334
|
required: true
|
|
10683
10335
|
});
|
|
10684
10336
|
const entries = await getConfidenceEntries(nodeId);
|
|
@@ -10701,7 +10353,7 @@ function createGraphHandlers(context) {
|
|
|
10701
10353
|
if (!await isTopicReadable(topicId)) {
|
|
10702
10354
|
return { topicId, beliefs: [] };
|
|
10703
10355
|
}
|
|
10704
|
-
const threshold =
|
|
10356
|
+
const threshold = readNumber(params, "threshold") ?? 0.7;
|
|
10705
10357
|
const analytics = await graph.bias({
|
|
10706
10358
|
topicId,
|
|
10707
10359
|
threshold,
|
|
@@ -10775,7 +10427,7 @@ function createGraphHandlers(context) {
|
|
|
10775
10427
|
}
|
|
10776
10428
|
return lucern.graph.gaps({
|
|
10777
10429
|
topicId,
|
|
10778
|
-
minConfidence:
|
|
10430
|
+
minConfidence: readNumber(params, "minConfidence")
|
|
10779
10431
|
});
|
|
10780
10432
|
}
|
|
10781
10433
|
),
|
|
@@ -10786,9 +10438,9 @@ function createGraphHandlers(context) {
|
|
|
10786
10438
|
if (!await isTopicReadable(topicId)) {
|
|
10787
10439
|
return { beliefs: [] };
|
|
10788
10440
|
}
|
|
10789
|
-
const status =
|
|
10790
|
-
const minConfidence =
|
|
10791
|
-
const worktreeId =
|
|
10441
|
+
const status = readString(params, "status");
|
|
10442
|
+
const minConfidence = readNumber(params, "minConfidence");
|
|
10443
|
+
const worktreeId = readString(params, "worktreeId");
|
|
10792
10444
|
const response = await graph.queryNodes({
|
|
10793
10445
|
topicId,
|
|
10794
10446
|
nodeType: "belief",
|
|
@@ -10835,10 +10487,10 @@ function createJudgmentHandlers(context) {
|
|
|
10835
10487
|
record_judgment: contractToHandler(
|
|
10836
10488
|
MCP_TOOL_CONTRACTS.record_judgment,
|
|
10837
10489
|
async (params) => {
|
|
10838
|
-
const title =
|
|
10839
|
-
const rationale =
|
|
10490
|
+
const title = readString(params, "title", { required: true });
|
|
10491
|
+
const rationale = readString(params, "rationale", { required: true });
|
|
10840
10492
|
const topicId = readTopicId(params, { required: true });
|
|
10841
|
-
const confidence =
|
|
10493
|
+
const confidence = readNumber(params, "confidence");
|
|
10842
10494
|
const beliefIds = readStringArray(params, "beliefIds");
|
|
10843
10495
|
const result = await decisions.recordJudgment({
|
|
10844
10496
|
title,
|
|
@@ -10885,14 +10537,14 @@ function createObservationHandlers(context) {
|
|
|
10885
10537
|
const topicId = readTopicId(params, {
|
|
10886
10538
|
required: true
|
|
10887
10539
|
});
|
|
10888
|
-
const observationType =
|
|
10540
|
+
const observationType = readString(params, "observationType", {
|
|
10889
10541
|
required: true
|
|
10890
10542
|
});
|
|
10891
|
-
const summary =
|
|
10543
|
+
const summary = readString(params, "summary", {
|
|
10892
10544
|
required: true
|
|
10893
10545
|
});
|
|
10894
|
-
const source =
|
|
10895
|
-
const confidence =
|
|
10546
|
+
const source = readString(params, "source");
|
|
10547
|
+
const confidence = readNumber(params, "confidence");
|
|
10896
10548
|
const tags = readStringArray(params, "tags");
|
|
10897
10549
|
const metadata = readObject(params, "metadata");
|
|
10898
10550
|
const allowedTypes = [
|
|
@@ -10951,8 +10603,8 @@ function createObservationHandlers(context) {
|
|
|
10951
10603
|
const topicId = readTopicId(params, {
|
|
10952
10604
|
required: true
|
|
10953
10605
|
});
|
|
10954
|
-
const query =
|
|
10955
|
-
const limit =
|
|
10606
|
+
const query = readString(params, "query");
|
|
10607
|
+
const limit = readNumber(params, "limit");
|
|
10956
10608
|
return observationStore.getContext({
|
|
10957
10609
|
topicId,
|
|
10958
10610
|
query,
|
|
@@ -10971,9 +10623,9 @@ function createPolicyHandlers(context) {
|
|
|
10971
10623
|
MCP_TOOL_CONTRACTS.check_permission,
|
|
10972
10624
|
async (params) => {
|
|
10973
10625
|
const topicId = readTopicId(params, { required: true });
|
|
10974
|
-
const permission =
|
|
10975
|
-
const principal =
|
|
10976
|
-
const beliefClusterId =
|
|
10626
|
+
const permission = readString(params, "permission", { required: true }) ?? "read";
|
|
10627
|
+
const principal = readString(params, "principal");
|
|
10628
|
+
const beliefClusterId = readString(params, "beliefClusterId");
|
|
10977
10629
|
const result = await policy.checkPermission({
|
|
10978
10630
|
topicId,
|
|
10979
10631
|
permission,
|
|
@@ -10995,10 +10647,10 @@ function createPolicyHandlers(context) {
|
|
|
10995
10647
|
MCP_TOOL_CONTRACTS.filter_by_permission,
|
|
10996
10648
|
async (params) => {
|
|
10997
10649
|
const topicIds = readStringArray(params, "topicIds") ?? [];
|
|
10998
|
-
const permission =
|
|
10650
|
+
const permission = readString(params, "permission", {
|
|
10999
10651
|
required: true
|
|
11000
10652
|
}) ?? "read";
|
|
11001
|
-
const principal =
|
|
10653
|
+
const principal = readString(params, "principal");
|
|
11002
10654
|
const result = await policy.filterByPermission({
|
|
11003
10655
|
topicIds,
|
|
11004
10656
|
permission,
|
|
@@ -11029,10 +10681,10 @@ function createQuestionHandlers(context) {
|
|
|
11029
10681
|
MCP_TOOL_CONTRACTS.create_question,
|
|
11030
10682
|
async (params) => {
|
|
11031
10683
|
const response = await lucern.questions.create({
|
|
11032
|
-
text:
|
|
10684
|
+
text: readString(params, "text", { required: true }),
|
|
11033
10685
|
topicId: readTopicId(params, { required: true }),
|
|
11034
|
-
priority:
|
|
11035
|
-
linkedBeliefId:
|
|
10686
|
+
priority: readString(params, "priority"),
|
|
10687
|
+
linkedBeliefId: readString(params, "linkedBeliefId"),
|
|
11036
10688
|
metadata: readMetadata2(params)
|
|
11037
10689
|
});
|
|
11038
10690
|
return response.data;
|
|
@@ -11042,7 +10694,7 @@ function createQuestionHandlers(context) {
|
|
|
11042
10694
|
MCP_TOOL_CONTRACTS.get_question,
|
|
11043
10695
|
async (params) => {
|
|
11044
10696
|
const response = await lucern.questions.get(
|
|
11045
|
-
|
|
10697
|
+
readString(params, "id", { required: true })
|
|
11046
10698
|
);
|
|
11047
10699
|
return response.data;
|
|
11048
10700
|
}
|
|
@@ -11052,11 +10704,11 @@ function createQuestionHandlers(context) {
|
|
|
11052
10704
|
async (params) => {
|
|
11053
10705
|
const response = await lucern.questions.list({
|
|
11054
10706
|
topicId: readTopicId(params, { required: true }),
|
|
11055
|
-
status:
|
|
11056
|
-
priority:
|
|
11057
|
-
worktreeId:
|
|
11058
|
-
limit:
|
|
11059
|
-
cursor:
|
|
10707
|
+
status: readString(params, "status"),
|
|
10708
|
+
priority: readString(params, "priority"),
|
|
10709
|
+
worktreeId: readString(params, "worktreeId"),
|
|
10710
|
+
limit: readNumber(params, "limit"),
|
|
10711
|
+
cursor: readString(params, "cursor")
|
|
11060
10712
|
});
|
|
11061
10713
|
return response.data;
|
|
11062
10714
|
}
|
|
@@ -11065,12 +10717,12 @@ function createQuestionHandlers(context) {
|
|
|
11065
10717
|
MCP_TOOL_CONTRACTS.answer_question,
|
|
11066
10718
|
async (params) => {
|
|
11067
10719
|
const response = await lucern.questions.answer(
|
|
11068
|
-
|
|
10720
|
+
readString(params, "id", { required: true }),
|
|
11069
10721
|
{
|
|
11070
|
-
text:
|
|
11071
|
-
confidence:
|
|
10722
|
+
text: readString(params, "text", { required: true }),
|
|
10723
|
+
confidence: readString(params, "confidence"),
|
|
11072
10724
|
evidenceIds: readStringArray(params, "evidenceIds"),
|
|
11073
|
-
rationale:
|
|
10725
|
+
rationale: readString(params, "rationale")
|
|
11074
10726
|
}
|
|
11075
10727
|
);
|
|
11076
10728
|
return response.data;
|
|
@@ -11080,9 +10732,9 @@ function createQuestionHandlers(context) {
|
|
|
11080
10732
|
MCP_TOOL_CONTRACTS.refine_question,
|
|
11081
10733
|
async (params) => {
|
|
11082
10734
|
const response = await lucern.questions.refine(
|
|
11083
|
-
|
|
11084
|
-
|
|
11085
|
-
|
|
10735
|
+
readString(params, "id") ?? readString(params, "questionId", { required: true }),
|
|
10736
|
+
readString(params, "text", { required: true }),
|
|
10737
|
+
readString(params, "rationale") ?? readString(params, "refinementReason")
|
|
11086
10738
|
);
|
|
11087
10739
|
return response.data;
|
|
11088
10740
|
}
|
|
@@ -11091,9 +10743,9 @@ function createQuestionHandlers(context) {
|
|
|
11091
10743
|
MCP_TOOL_CONTRACTS.update_question_status,
|
|
11092
10744
|
async (params) => {
|
|
11093
10745
|
const response = await lucern.questions.updateStatus(
|
|
11094
|
-
|
|
11095
|
-
|
|
11096
|
-
|
|
10746
|
+
readString(params, "id") ?? readString(params, "questionId", { required: true }),
|
|
10747
|
+
readString(params, "status", { required: true }),
|
|
10748
|
+
readString(params, "rationale")
|
|
11097
10749
|
);
|
|
11098
10750
|
return response.data;
|
|
11099
10751
|
}
|
|
@@ -11102,8 +10754,8 @@ function createQuestionHandlers(context) {
|
|
|
11102
10754
|
MCP_TOOL_CONTRACTS.archive_question,
|
|
11103
10755
|
async (params) => {
|
|
11104
10756
|
return lucern.questions.archive(
|
|
11105
|
-
|
|
11106
|
-
|
|
10757
|
+
readString(params, "questionId", { required: true }),
|
|
10758
|
+
readString(params, "reason")
|
|
11107
10759
|
);
|
|
11108
10760
|
}
|
|
11109
10761
|
),
|
|
@@ -11111,10 +10763,10 @@ function createQuestionHandlers(context) {
|
|
|
11111
10763
|
MCP_TOOL_CONTRACTS.link_evidence_to_question,
|
|
11112
10764
|
async (params) => {
|
|
11113
10765
|
return lucern.questions.linkEvidence({
|
|
11114
|
-
evidenceId:
|
|
11115
|
-
questionId:
|
|
11116
|
-
relevance:
|
|
11117
|
-
rationale:
|
|
10766
|
+
evidenceId: readString(params, "evidenceId", { required: true }),
|
|
10767
|
+
questionId: readString(params, "questionId", { required: true }),
|
|
10768
|
+
relevance: readNumber(params, "relevance") ?? 1,
|
|
10769
|
+
rationale: readString(params, "rationale")
|
|
11118
10770
|
});
|
|
11119
10771
|
}
|
|
11120
10772
|
),
|
|
@@ -11123,7 +10775,7 @@ function createQuestionHandlers(context) {
|
|
|
11123
10775
|
async (params) => {
|
|
11124
10776
|
return lucern.questions.getHighPriority({
|
|
11125
10777
|
topicId: readTopicId(params, { required: true }),
|
|
11126
|
-
limit:
|
|
10778
|
+
limit: readNumber(params, "limit"),
|
|
11127
10779
|
includeAnswered: readBoolean(params, "includeAnswered")
|
|
11128
10780
|
});
|
|
11129
10781
|
}
|
|
@@ -11133,7 +10785,7 @@ function createQuestionHandlers(context) {
|
|
|
11133
10785
|
async (params) => {
|
|
11134
10786
|
return lucern.questions.findMissing({
|
|
11135
10787
|
topicId: readTopicId(params, { required: true }),
|
|
11136
|
-
minConfidence:
|
|
10788
|
+
minConfidence: readNumber(params, "minConfidence")
|
|
11137
10789
|
});
|
|
11138
10790
|
}
|
|
11139
10791
|
)
|
|
@@ -11155,7 +10807,7 @@ function asSourceArray(data) {
|
|
|
11155
10807
|
function createResearchHandlers(context) {
|
|
11156
10808
|
const graph = createGraphClient(context.sdkConfig);
|
|
11157
10809
|
const searchSources = async (params) => {
|
|
11158
|
-
const query =
|
|
10810
|
+
const query = readString(params, "query", { required: true });
|
|
11159
10811
|
const topicId = readTopicId(params);
|
|
11160
10812
|
const sourceTypes = readStringArray(params, "sources") ?? [];
|
|
11161
10813
|
if (!topicId) {
|
|
@@ -11194,9 +10846,9 @@ function createResearchHandlers(context) {
|
|
|
11194
10846
|
execute_deep_research: contractToHandler(
|
|
11195
10847
|
MCP_TOOL_CONTRACTS.execute_deep_research,
|
|
11196
10848
|
async (params) => {
|
|
11197
|
-
const query =
|
|
10849
|
+
const query = readString(params, "query", { required: true });
|
|
11198
10850
|
const topicId = readTopicId(params, { required: true });
|
|
11199
|
-
const depth =
|
|
10851
|
+
const depth = readString(params, "depth") ?? "standard";
|
|
11200
10852
|
const sources = await searchSources({
|
|
11201
10853
|
query,
|
|
11202
10854
|
topicId,
|
|
@@ -11232,13 +10884,13 @@ function createSearchHandlers(context) {
|
|
|
11232
10884
|
search_resources: contractToHandler(
|
|
11233
10885
|
MCP_TOOL_CONTRACTS.search_resources,
|
|
11234
10886
|
async (params) => {
|
|
11235
|
-
return lucern.search(
|
|
10887
|
+
return lucern.search(readString(params, "q", { required: true }), {
|
|
11236
10888
|
topicId: readTopicId(params, { required: true }),
|
|
11237
10889
|
types: readStringArray(params, "types"),
|
|
11238
|
-
status:
|
|
11239
|
-
minConfidence:
|
|
11240
|
-
limit:
|
|
11241
|
-
cursor:
|
|
10890
|
+
status: readString(params, "status"),
|
|
10891
|
+
minConfidence: readNumber(params, "minConfidence"),
|
|
10892
|
+
limit: readNumber(params, "limit"),
|
|
10893
|
+
cursor: readString(params, "cursor")
|
|
11242
10894
|
});
|
|
11243
10895
|
}
|
|
11244
10896
|
)
|
|
@@ -11252,11 +10904,11 @@ function createTaskHandlers(context) {
|
|
|
11252
10904
|
create_task: contractToHandler(
|
|
11253
10905
|
MCP_TOOL_CONTRACTS.create_task,
|
|
11254
10906
|
async (params) => {
|
|
11255
|
-
const title =
|
|
10907
|
+
const title = readString(params, "title", { required: true });
|
|
11256
10908
|
const topicId = readTopicId(params, { required: true });
|
|
11257
|
-
const taskType =
|
|
11258
|
-
const linkedQuestionId =
|
|
11259
|
-
const linkedWorktreeId =
|
|
10909
|
+
const taskType = readString(params, "taskType");
|
|
10910
|
+
const linkedQuestionId = readString(params, "linkedQuestionId");
|
|
10911
|
+
const linkedWorktreeId = readString(params, "linkedWorktreeId");
|
|
11260
10912
|
const result = await workflow.createTask({
|
|
11261
10913
|
title,
|
|
11262
10914
|
topicId,
|
|
@@ -11274,8 +10926,8 @@ function createTaskHandlers(context) {
|
|
|
11274
10926
|
complete_task: contractToHandler(
|
|
11275
10927
|
MCP_TOOL_CONTRACTS.complete_task,
|
|
11276
10928
|
async (params) => {
|
|
11277
|
-
const taskId =
|
|
11278
|
-
const outputSummary =
|
|
10929
|
+
const taskId = readString(params, "taskId", { required: true });
|
|
10930
|
+
const outputSummary = readString(params, "outputSummary", {
|
|
11279
10931
|
required: true
|
|
11280
10932
|
});
|
|
11281
10933
|
const evidenceCreated = readBoolean(params, "evidenceCreated");
|
|
@@ -11293,15 +10945,15 @@ function createTaskHandlers(context) {
|
|
|
11293
10945
|
update_task: contractToHandler(
|
|
11294
10946
|
MCP_TOOL_CONTRACTS.update_task,
|
|
11295
10947
|
async (params) => {
|
|
11296
|
-
const taskId =
|
|
11297
|
-
const title =
|
|
11298
|
-
const description =
|
|
11299
|
-
const linkedBeliefId =
|
|
11300
|
-
const linkedQuestionId =
|
|
11301
|
-
const linkedWorktreeId =
|
|
11302
|
-
const rawPriority =
|
|
10948
|
+
const taskId = readString(params, "taskId", { required: true });
|
|
10949
|
+
const title = readString(params, "title");
|
|
10950
|
+
const description = readString(params, "description");
|
|
10951
|
+
const linkedBeliefId = readString(params, "linkedBeliefId");
|
|
10952
|
+
const linkedQuestionId = readString(params, "linkedQuestionId");
|
|
10953
|
+
const linkedWorktreeId = readString(params, "linkedWorktreeId");
|
|
10954
|
+
const rawPriority = readString(params, "priority");
|
|
11303
10955
|
const priority = rawPriority === "critical" || rawPriority === "high" || rawPriority === "medium" || rawPriority === "low" ? rawPriority : void 0;
|
|
11304
|
-
const rawStatus =
|
|
10956
|
+
const rawStatus = readString(params, "status");
|
|
11305
10957
|
const status = rawStatus === "todo" || rawStatus === "in_progress" || rawStatus === "blocked" || rawStatus === "done" ? rawStatus : void 0;
|
|
11306
10958
|
const result = await workflow.updateTask(taskId, {
|
|
11307
10959
|
title,
|
|
@@ -11339,11 +10991,11 @@ function createWorktreeHandlers(context) {
|
|
|
11339
10991
|
return {
|
|
11340
10992
|
create_lens: contractToHandler(MCP_TOOL_CONTRACTS.create_lens, async (params) => {
|
|
11341
10993
|
const result = await workflow.createLens({
|
|
11342
|
-
name:
|
|
11343
|
-
workspaceId:
|
|
10994
|
+
name: readString(params, "name", { required: true }),
|
|
10995
|
+
workspaceId: readString(params, "workspaceId"),
|
|
11344
10996
|
topicId: readTopicId(params),
|
|
11345
|
-
description:
|
|
11346
|
-
perspectiveType:
|
|
10997
|
+
description: readString(params, "description"),
|
|
10998
|
+
perspectiveType: readString(params, "perspectiveType", {
|
|
11347
10999
|
required: true
|
|
11348
11000
|
}),
|
|
11349
11001
|
promptTemplates: Array.isArray(params.promptTemplates) ? params.promptTemplates : void 0,
|
|
@@ -11353,17 +11005,17 @@ function createWorktreeHandlers(context) {
|
|
|
11353
11005
|
});
|
|
11354
11006
|
return {
|
|
11355
11007
|
lensId: result.data.lensId ?? "",
|
|
11356
|
-
name: result.data.name ??
|
|
11357
|
-
workspaceId: result.data.workspaceId ??
|
|
11008
|
+
name: result.data.name ?? readString(params, "name", { required: true }),
|
|
11009
|
+
workspaceId: result.data.workspaceId ?? readString(params, "workspaceId") ?? null,
|
|
11358
11010
|
status: result.data.status ?? "active"
|
|
11359
11011
|
};
|
|
11360
11012
|
}),
|
|
11361
11013
|
list_lenses: contractToHandler(MCP_TOOL_CONTRACTS.list_lenses, async (params) => {
|
|
11362
11014
|
const result = await workflow.listLenses({
|
|
11363
|
-
workspaceId:
|
|
11015
|
+
workspaceId: readString(params, "workspaceId"),
|
|
11364
11016
|
topicId: readTopicId(params),
|
|
11365
|
-
status:
|
|
11366
|
-
perspectiveType:
|
|
11017
|
+
status: readString(params, "status"),
|
|
11018
|
+
perspectiveType: readString(params, "perspectiveType")
|
|
11367
11019
|
});
|
|
11368
11020
|
return {
|
|
11369
11021
|
lenses: result.data.items ?? ("lenses" in result.data && Array.isArray(result.data.lenses) ? result.data.lenses : [])
|
|
@@ -11373,7 +11025,7 @@ function createWorktreeHandlers(context) {
|
|
|
11373
11025
|
MCP_TOOL_CONTRACTS.apply_lens_to_topic,
|
|
11374
11026
|
async (params) => {
|
|
11375
11027
|
const topicId = readTopicId(params, { required: true });
|
|
11376
|
-
const lensId =
|
|
11028
|
+
const lensId = readString(params, "lensId", { required: true });
|
|
11377
11029
|
const result = await workflow.applyLensToTopic({
|
|
11378
11030
|
lensId,
|
|
11379
11031
|
topicId,
|
|
@@ -11391,7 +11043,7 @@ function createWorktreeHandlers(context) {
|
|
|
11391
11043
|
MCP_TOOL_CONTRACTS.remove_lens_from_topic,
|
|
11392
11044
|
async (params) => {
|
|
11393
11045
|
const topicId = readTopicId(params, { required: true });
|
|
11394
|
-
const lensId =
|
|
11046
|
+
const lensId = readString(params, "lensId", { required: true });
|
|
11395
11047
|
const result = await workflow.removeLensFromTopic({
|
|
11396
11048
|
lensId,
|
|
11397
11049
|
topicId
|
|
@@ -11412,18 +11064,18 @@ function createWorktreeHandlers(context) {
|
|
|
11412
11064
|
throw new Error("add_worktree requires topicId");
|
|
11413
11065
|
}
|
|
11414
11066
|
const result = await workflow.addWorktree({
|
|
11415
|
-
title:
|
|
11067
|
+
title: readString(params, "title", { required: true }),
|
|
11416
11068
|
topicId,
|
|
11417
|
-
branchId:
|
|
11418
|
-
objective:
|
|
11419
|
-
hypothesis:
|
|
11069
|
+
branchId: readString(params, "branchId"),
|
|
11070
|
+
objective: readString(params, "objective"),
|
|
11071
|
+
hypothesis: readString(params, "hypothesis"),
|
|
11420
11072
|
beliefIds: readStringArray(params, "beliefIds"),
|
|
11421
11073
|
autoShape: readBoolean(params, "autoShape"),
|
|
11422
|
-
domainPackId:
|
|
11074
|
+
domainPackId: readString(params, "domainPackId"),
|
|
11423
11075
|
executionOrder: typeof params.executionOrder === "number" ? params.executionOrder : void 0,
|
|
11424
11076
|
dependsOn: readStringArray(params, "dependsOn"),
|
|
11425
11077
|
blocks: readStringArray(params, "blocks"),
|
|
11426
|
-
gate:
|
|
11078
|
+
gate: readString(params, "gate")
|
|
11427
11079
|
});
|
|
11428
11080
|
return {
|
|
11429
11081
|
worktreeId: result.data.worktreeId,
|
|
@@ -11440,11 +11092,11 @@ function createWorktreeHandlers(context) {
|
|
|
11440
11092
|
}
|
|
11441
11093
|
),
|
|
11442
11094
|
merge: contractToHandler(MCP_TOOL_CONTRACTS.merge, async (params) => {
|
|
11443
|
-
const worktreeId =
|
|
11095
|
+
const worktreeId = readString(params, "worktreeId", { required: true });
|
|
11444
11096
|
const outcomes = Array.isArray(params.outcomes) ? params.outcomes : [];
|
|
11445
11097
|
const result = await workflow.merge(worktreeId, {
|
|
11446
11098
|
outcomes,
|
|
11447
|
-
summary:
|
|
11099
|
+
summary: readString(params, "summary")
|
|
11448
11100
|
});
|
|
11449
11101
|
return {
|
|
11450
11102
|
worktreeId: result.data.worktreeId ?? worktreeId,
|
|
@@ -11453,8 +11105,8 @@ function createWorktreeHandlers(context) {
|
|
|
11453
11105
|
};
|
|
11454
11106
|
}),
|
|
11455
11107
|
push: contractToHandler(MCP_TOOL_CONTRACTS.push, async (params) => {
|
|
11456
|
-
const worktreeId =
|
|
11457
|
-
const targetContext =
|
|
11108
|
+
const worktreeId = readString(params, "worktreeId", { required: true });
|
|
11109
|
+
const targetContext = readString(params, "targetContext", {
|
|
11458
11110
|
required: true
|
|
11459
11111
|
});
|
|
11460
11112
|
const result = await workflow.push(worktreeId, {
|
|
@@ -11470,10 +11122,10 @@ function createWorktreeHandlers(context) {
|
|
|
11470
11122
|
open_pull_request: contractToHandler(
|
|
11471
11123
|
MCP_TOOL_CONTRACTS.open_pull_request,
|
|
11472
11124
|
async (params) => {
|
|
11473
|
-
const worktreeId =
|
|
11125
|
+
const worktreeId = readString(params, "worktreeId", {
|
|
11474
11126
|
required: true
|
|
11475
11127
|
});
|
|
11476
|
-
const summary =
|
|
11128
|
+
const summary = readString(params, "summary", { required: true });
|
|
11477
11129
|
const reviewers = readStringArray(params, "reviewers");
|
|
11478
11130
|
const result = await workflow.openPullRequest(worktreeId, {
|
|
11479
11131
|
summary,
|
|
@@ -11490,7 +11142,7 @@ function createWorktreeHandlers(context) {
|
|
|
11490
11142
|
MCP_TOOL_CONTRACTS.list_worktrees,
|
|
11491
11143
|
async (params) => {
|
|
11492
11144
|
const topicId = readTopicId(params, { required: true });
|
|
11493
|
-
const status = mapWorktreeStatus(
|
|
11145
|
+
const status = mapWorktreeStatus(readString(params, "status"));
|
|
11494
11146
|
const result = await workflow.listWorktrees({
|
|
11495
11147
|
topicId,
|
|
11496
11148
|
status
|
|
@@ -12530,7 +12182,7 @@ async function runLucernMcpCli(argv = process.argv.slice(2)) {
|
|
|
12530
12182
|
}
|
|
12531
12183
|
}
|
|
12532
12184
|
|
|
12533
|
-
// src/
|
|
12185
|
+
// src/legacyToolContracts.ts
|
|
12534
12186
|
function pickToolContracts(names) {
|
|
12535
12187
|
return Object.fromEntries(
|
|
12536
12188
|
names.flatMap((name) => {
|
|
@@ -12573,16 +12225,16 @@ var SCOPE_MCP_TOOLS = pickToolContracts([
|
|
|
12573
12225
|
"trigger_belief_review"
|
|
12574
12226
|
]);
|
|
12575
12227
|
|
|
12576
|
-
// src/
|
|
12577
|
-
var
|
|
12228
|
+
// src/legacyAuthenticatedHandlers.ts
|
|
12229
|
+
var LEGACY_HANDLER_TOOL_NAMES = [
|
|
12578
12230
|
...Object.keys(SCOPE_MCP_TOOLS),
|
|
12579
12231
|
...Object.keys(COORDINATION_MCP_TOOLS),
|
|
12580
12232
|
...Object.keys(EPISTEMIC_CONTRACT_MCP_TOOLS),
|
|
12581
12233
|
...Object.keys(BOOTSTRAP_MCP_TOOLS)
|
|
12582
12234
|
];
|
|
12583
|
-
function
|
|
12235
|
+
function buildLegacyGatewayClient(ctx) {
|
|
12584
12236
|
if (!ctx.gatewayBaseUrl || !ctx.getAuthHeaders) {
|
|
12585
|
-
throw new Error("MCP
|
|
12237
|
+
throw new Error("Legacy MCP bridge requires gateway auth headers.");
|
|
12586
12238
|
}
|
|
12587
12239
|
return createGatewayRequestClient({
|
|
12588
12240
|
baseUrl: ctx.gatewayBaseUrl,
|
|
@@ -12595,12 +12247,12 @@ function withSessionId(args, ctx) {
|
|
|
12595
12247
|
__sdkSessionId: ctx.sessionId
|
|
12596
12248
|
};
|
|
12597
12249
|
}
|
|
12598
|
-
async function
|
|
12250
|
+
async function buildLegacyAuthenticatedHandlerMap() {
|
|
12599
12251
|
return Object.fromEntries(
|
|
12600
|
-
|
|
12252
|
+
LEGACY_HANDLER_TOOL_NAMES.map((toolName) => [
|
|
12601
12253
|
toolName,
|
|
12602
12254
|
async (args, ctx) => {
|
|
12603
|
-
const gateway =
|
|
12255
|
+
const gateway = buildLegacyGatewayClient(ctx);
|
|
12604
12256
|
const response = await gateway.request({
|
|
12605
12257
|
path: `/api/platform/v1/mcp-tools/${encodeURIComponent(toolName)}`,
|
|
12606
12258
|
method: "POST",
|
|
@@ -12669,7 +12321,7 @@ function parseCredentialsFile(filePath) {
|
|
|
12669
12321
|
}
|
|
12670
12322
|
return result;
|
|
12671
12323
|
}
|
|
12672
|
-
function
|
|
12324
|
+
function resolveCredentials() {
|
|
12673
12325
|
if (process.env.LUCERN_CONVEX_URL && process.env.LUCERN_DEPLOY_KEY) {
|
|
12674
12326
|
return {
|
|
12675
12327
|
lucernResolved: true,
|
|
@@ -12787,7 +12439,7 @@ function initializeLucernScriptEnv() {
|
|
|
12787
12439
|
}
|
|
12788
12440
|
}
|
|
12789
12441
|
}
|
|
12790
|
-
|
|
12442
|
+
resolveCredentials();
|
|
12791
12443
|
lucernScriptEnvInitialized = true;
|
|
12792
12444
|
}
|
|
12793
12445
|
function readArg(name, fallback) {
|
|
@@ -12834,7 +12486,7 @@ async function createLucernMcpClient() {
|
|
|
12834
12486
|
const deployKey = requireEnv("LUCERN_DEPLOY_KEY");
|
|
12835
12487
|
const transport = new StdioClientTransport({
|
|
12836
12488
|
command: "npx",
|
|
12837
|
-
args: ["tsx", "apps/mcp-server/src/index.ts"],
|
|
12489
|
+
args: ["tsx", "lucern/apps/mcp-server/src/index.ts"],
|
|
12838
12490
|
env: {
|
|
12839
12491
|
...process.env,
|
|
12840
12492
|
LUCERN_CONVEX_URL: convexUrl,
|
|
@@ -12858,7 +12510,7 @@ function createLucernAdminClient() {
|
|
|
12858
12510
|
}
|
|
12859
12511
|
async function resolveMcpSessionTenantId() {
|
|
12860
12512
|
initializeLucernScriptEnv();
|
|
12861
|
-
const apiKey =
|
|
12513
|
+
const apiKey = resolveCredentials().rawLucernApiKey;
|
|
12862
12514
|
if (!apiKey) {
|
|
12863
12515
|
return void 0;
|
|
12864
12516
|
}
|
|
@@ -12887,8 +12539,8 @@ async function closeMcpClient(client) {
|
|
|
12887
12539
|
await client.close();
|
|
12888
12540
|
}
|
|
12889
12541
|
|
|
12890
|
-
// src/
|
|
12891
|
-
async function
|
|
12542
|
+
// src/legacyDiscovery.ts
|
|
12543
|
+
async function loadLegacyDiscoveryHandlers() {
|
|
12892
12544
|
return {
|
|
12893
12545
|
async discover(args, ctx) {
|
|
12894
12546
|
const query = typeof args.query === "string" ? args.query : "";
|
|
@@ -13211,6 +12863,6 @@ function validateContextPackSchema2(payload) {
|
|
|
13211
12863
|
};
|
|
13212
12864
|
}
|
|
13213
12865
|
|
|
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,
|
|
12866
|
+
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, buildLegacyAuthenticatedHandlerMap, buildLucernObserverPrompt, callMcpTool, classifyTransportParityDrift, closeMcpClient, createLucernAdminClient, createLucernMcpClient, createLucernMcpHttpRequestHandler, createLucernMcpServer, createLucernStandaloneMcpServer, createMcpHandlerRegistry, createToolExecutionEnvelope, executeToolWithEnvelope, initializeLucernScriptEnv, loadLegacyDiscoveryHandlers, parseToolExecutionMetadata, readArg, resolveCredentials as resolveLegacyMcpCredentials, resolveMcpSessionTenantId, runLucernMcpCli, startLucernMcpHttpServer, startLucernMcpStdioServer, validateContextPackSchema2 as validateContextPackSchema };
|
|
13215
12867
|
//# sourceMappingURL=index.js.map
|
|
13216
12868
|
//# sourceMappingURL=index.js.map
|