@lucern/mcp 0.2.0-alpha.7 → 0.2.0-alpha.9
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 +2 -29
- package/dist/gateway.js +7941 -7919
- package/dist/gateway.js.map +1 -1
- package/dist/index.js +43 -9
- package/dist/index.js.map +1 -1
- package/dist/runtime.js +21 -20
- package/dist/runtime.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3,7 +3,6 @@ import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/
|
|
|
3
3
|
import { McpServer, ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
4
4
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
5
5
|
import { z } from 'zod';
|
|
6
|
-
import { opinionFromBaseRate, opinionFromDogmatic, opinionFromProjected } from '@lucern/confidence';
|
|
7
6
|
import 'crypto';
|
|
8
7
|
import * as fs from 'fs';
|
|
9
8
|
import { existsSync } from 'fs';
|
|
@@ -264,6 +263,38 @@ function scoreObservation(record, terms) {
|
|
|
264
263
|
return score;
|
|
265
264
|
}
|
|
266
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
|
+
|
|
267
298
|
// ../sdk/src/coreClient.ts
|
|
268
299
|
var LucernApiError = class extends Error {
|
|
269
300
|
code;
|
|
@@ -1260,6 +1291,8 @@ function createAuditClient(config = {}) {
|
|
|
1260
1291
|
}
|
|
1261
1292
|
};
|
|
1262
1293
|
}
|
|
1294
|
+
|
|
1295
|
+
// ../sdk/src/beliefsClient.ts
|
|
1263
1296
|
function asRecord2(value) {
|
|
1264
1297
|
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
1265
1298
|
}
|
|
@@ -1273,7 +1306,7 @@ function readString(value) {
|
|
|
1273
1306
|
function readNumber(value) {
|
|
1274
1307
|
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
1275
1308
|
}
|
|
1276
|
-
function
|
|
1309
|
+
function clamp012(value) {
|
|
1277
1310
|
return Math.max(0, Math.min(1, value));
|
|
1278
1311
|
}
|
|
1279
1312
|
function normalizeOpinionTuple(record) {
|
|
@@ -1283,7 +1316,7 @@ function normalizeOpinionTuple(record) {
|
|
|
1283
1316
|
const rawUncertainty = readNumber(opinion.u) ?? readNumber(record.uncertainty);
|
|
1284
1317
|
const rawBaseRate = readNumber(opinion.a) ?? readNumber(record.baseRate);
|
|
1285
1318
|
if (rawBelief === void 0 && rawDisbelief === void 0 && rawUncertainty === void 0) {
|
|
1286
|
-
const projected =
|
|
1319
|
+
const projected = clamp012(readNumber(record.confidence) ?? 0);
|
|
1287
1320
|
return {
|
|
1288
1321
|
b: projected,
|
|
1289
1322
|
d: 1 - projected,
|
|
@@ -1292,10 +1325,10 @@ function normalizeOpinionTuple(record) {
|
|
|
1292
1325
|
};
|
|
1293
1326
|
}
|
|
1294
1327
|
return {
|
|
1295
|
-
b:
|
|
1296
|
-
d:
|
|
1297
|
-
u:
|
|
1298
|
-
a:
|
|
1328
|
+
b: clamp012(rawBelief ?? 0),
|
|
1329
|
+
d: clamp012(rawDisbelief ?? 0),
|
|
1330
|
+
u: clamp012(rawUncertainty ?? 0),
|
|
1331
|
+
a: clamp012(rawBaseRate ?? 0.5)
|
|
1299
1332
|
};
|
|
1300
1333
|
}
|
|
1301
1334
|
function mapOpinionHistoryEntriesFromGatewayData(payload) {
|
|
@@ -1303,7 +1336,7 @@ function mapOpinionHistoryEntriesFromGatewayData(payload) {
|
|
|
1303
1336
|
return entries.map((value) => {
|
|
1304
1337
|
const record = asRecord2(value);
|
|
1305
1338
|
const tuple = normalizeOpinionTuple(record);
|
|
1306
|
-
const projected = readNumber(record.confidence) ??
|
|
1339
|
+
const projected = readNumber(record.confidence) ?? clamp012(tuple.b + tuple.a * tuple.u);
|
|
1307
1340
|
const triggeringEvidenceId = readString(record.triggeringEvidenceId);
|
|
1308
1341
|
const triggeringWorktreeId = readString(record.triggeringWorktreeId);
|
|
1309
1342
|
return {
|
|
@@ -1312,7 +1345,7 @@ function mapOpinionHistoryEntriesFromGatewayData(payload) {
|
|
|
1312
1345
|
d: tuple.d,
|
|
1313
1346
|
u: tuple.u,
|
|
1314
1347
|
a: tuple.a,
|
|
1315
|
-
P:
|
|
1348
|
+
P: clamp012(projected),
|
|
1316
1349
|
trigger: readString(record.trigger) ?? "manual",
|
|
1317
1350
|
...triggeringEvidenceId ? {
|
|
1318
1351
|
triggeringRef: {
|
|
@@ -9801,6 +9834,7 @@ var MCP_TOOL_CONTRACTS = {
|
|
|
9801
9834
|
deprecate_ontology_version: DEPRECATE_ONTOLOGY_VERSION,
|
|
9802
9835
|
resolve_effective_ontology: RESOLVE_EFFECTIVE_ONTOLOGY
|
|
9803
9836
|
};
|
|
9837
|
+
globalThis.process?.env;
|
|
9804
9838
|
|
|
9805
9839
|
// ../sdk/src/mcpParitySurface.ts
|
|
9806
9840
|
var SDK_MCP_PARITY_METHODS = [
|