@lucern/sdk 0.2.0-alpha.10 → 0.2.0-alpha.12
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/audience/index.d.ts +38 -0
- package/dist/audience/index.js +110 -0
- package/dist/audience/index.js.map +1 -0
- package/dist/beliefs/index.d.ts +465 -0
- package/dist/beliefs/index.js +6433 -0
- package/dist/beliefs/index.js.map +1 -0
- package/dist/beliefs/lifecycle.d.ts +24 -0
- package/dist/beliefs/lifecycle.js +98 -0
- package/dist/beliefs/lifecycle.js.map +1 -0
- package/dist/beliefsClient.d.ts +2 -3
- package/dist/beliefsClient.js +40 -10
- package/dist/beliefsClient.js.map +1 -1
- package/dist/client.d.ts +3 -3
- package/dist/client.js +42 -9
- package/dist/client.js.map +1 -1
- package/dist/contradictions/index.d.ts +158 -0
- package/dist/contradictions/index.js +6427 -0
- package/dist/contradictions/index.js.map +1 -0
- package/dist/decisions/index.d.ts +68 -0
- package/dist/decisions/index.js +6429 -0
- package/dist/decisions/index.js.map +1 -0
- package/dist/edges/index.d.ts +204 -0
- package/dist/edges/index.js +6428 -0
- package/dist/edges/index.js.map +1 -0
- package/dist/events.js +7 -5
- package/dist/events.js.map +1 -1
- package/dist/evidence/index.d.ts +295 -0
- package/dist/evidence/index.js +6428 -0
- package/dist/evidence/index.js.map +1 -0
- package/dist/gatewayFacades.d.ts +1 -1
- package/dist/gatewayFacades.js +32 -2
- package/dist/gatewayFacades.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +55 -23
- package/dist/index.js.map +1 -1
- package/dist/lenses/index.d.ts +194 -0
- package/dist/lenses/index.js +6427 -0
- package/dist/lenses/index.js.map +1 -0
- package/dist/nodes/index.d.ts +62 -0
- package/dist/nodes/index.js +6429 -0
- package/dist/nodes/index.js.map +1 -0
- package/dist/ontologies/index.d.ts +178 -0
- package/dist/ontologies/index.js +6430 -0
- package/dist/ontologies/index.js.map +1 -0
- package/dist/opinion.d.ts +11 -0
- package/dist/opinion.js +35 -0
- package/dist/opinion.js.map +1 -0
- package/dist/questions/index.d.ts +297 -0
- package/dist/questions/index.js +6430 -0
- package/dist/questions/index.js.map +1 -0
- package/dist/topics/index.d.ts +68 -0
- package/dist/topics/index.js +6428 -0
- package/dist/topics/index.js.map +1 -0
- package/dist/worktrees/index.d.ts +210 -0
- package/dist/worktrees/index.js +6430 -0
- package/dist/worktrees/index.js.map +1 -0
- package/package.json +53 -2
package/dist/client.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { opinionFromBaseRate, opinionFromDogmatic, opinionFromProjected } from '@lucern/confidence';
|
|
2
1
|
import { z } from 'zod';
|
|
3
2
|
|
|
4
3
|
// src/coreClient.ts
|
|
@@ -997,6 +996,40 @@ function createAuditClient(config = {}) {
|
|
|
997
996
|
}
|
|
998
997
|
};
|
|
999
998
|
}
|
|
999
|
+
|
|
1000
|
+
// src/opinion.ts
|
|
1001
|
+
function clamp01(value) {
|
|
1002
|
+
if (!Number.isFinite(value)) {
|
|
1003
|
+
return 0;
|
|
1004
|
+
}
|
|
1005
|
+
return Math.max(0, Math.min(1, value));
|
|
1006
|
+
}
|
|
1007
|
+
function vacuous(baseRate = 0.5) {
|
|
1008
|
+
return { b: 0, d: 0, u: 1, a: clamp01(baseRate) };
|
|
1009
|
+
}
|
|
1010
|
+
function dogmatic(probability, baseRate = 0.5) {
|
|
1011
|
+
const p = clamp01(probability);
|
|
1012
|
+
return { b: p, d: 1 - p, u: 0, a: clamp01(baseRate) };
|
|
1013
|
+
}
|
|
1014
|
+
function opinionFromBaseRate(probability) {
|
|
1015
|
+
return vacuous(clamp01(probability));
|
|
1016
|
+
}
|
|
1017
|
+
function opinionFromDogmatic(probability, baseRate = 0.5) {
|
|
1018
|
+
return dogmatic(clamp01(probability), clamp01(baseRate));
|
|
1019
|
+
}
|
|
1020
|
+
function opinionFromProjected(probability, uncertainty, baseRate = 0.5) {
|
|
1021
|
+
const p = clamp01(probability);
|
|
1022
|
+
const u = clamp01(uncertainty);
|
|
1023
|
+
const remainingMass = 1 - u;
|
|
1024
|
+
return {
|
|
1025
|
+
b: p * remainingMass,
|
|
1026
|
+
d: (1 - p) * remainingMass,
|
|
1027
|
+
u,
|
|
1028
|
+
a: clamp01(baseRate)
|
|
1029
|
+
};
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
// src/beliefsClient.ts
|
|
1000
1033
|
function asRecord2(value) {
|
|
1001
1034
|
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
1002
1035
|
}
|
|
@@ -1010,7 +1043,7 @@ function readString(value) {
|
|
|
1010
1043
|
function readNumber(value) {
|
|
1011
1044
|
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
1012
1045
|
}
|
|
1013
|
-
function
|
|
1046
|
+
function clamp012(value) {
|
|
1014
1047
|
return Math.max(0, Math.min(1, value));
|
|
1015
1048
|
}
|
|
1016
1049
|
function normalizeOpinionTuple(record) {
|
|
@@ -1020,7 +1053,7 @@ function normalizeOpinionTuple(record) {
|
|
|
1020
1053
|
const rawUncertainty = readNumber(opinion.u) ?? readNumber(record.uncertainty);
|
|
1021
1054
|
const rawBaseRate = readNumber(opinion.a) ?? readNumber(record.baseRate);
|
|
1022
1055
|
if (rawBelief === void 0 && rawDisbelief === void 0 && rawUncertainty === void 0) {
|
|
1023
|
-
const projected =
|
|
1056
|
+
const projected = clamp012(readNumber(record.confidence) ?? 0);
|
|
1024
1057
|
return {
|
|
1025
1058
|
b: projected,
|
|
1026
1059
|
d: 1 - projected,
|
|
@@ -1029,10 +1062,10 @@ function normalizeOpinionTuple(record) {
|
|
|
1029
1062
|
};
|
|
1030
1063
|
}
|
|
1031
1064
|
return {
|
|
1032
|
-
b:
|
|
1033
|
-
d:
|
|
1034
|
-
u:
|
|
1035
|
-
a:
|
|
1065
|
+
b: clamp012(rawBelief ?? 0),
|
|
1066
|
+
d: clamp012(rawDisbelief ?? 0),
|
|
1067
|
+
u: clamp012(rawUncertainty ?? 0),
|
|
1068
|
+
a: clamp012(rawBaseRate ?? 0.5)
|
|
1036
1069
|
};
|
|
1037
1070
|
}
|
|
1038
1071
|
function mapOpinionHistoryEntriesFromGatewayData(payload) {
|
|
@@ -1040,7 +1073,7 @@ function mapOpinionHistoryEntriesFromGatewayData(payload) {
|
|
|
1040
1073
|
return entries.map((value) => {
|
|
1041
1074
|
const record = asRecord2(value);
|
|
1042
1075
|
const tuple = normalizeOpinionTuple(record);
|
|
1043
|
-
const projected = readNumber(record.confidence) ??
|
|
1076
|
+
const projected = readNumber(record.confidence) ?? clamp012(tuple.b + tuple.a * tuple.u);
|
|
1044
1077
|
const triggeringEvidenceId = readString(record.triggeringEvidenceId);
|
|
1045
1078
|
const triggeringWorktreeId = readString(record.triggeringWorktreeId);
|
|
1046
1079
|
return {
|
|
@@ -1049,7 +1082,7 @@ function mapOpinionHistoryEntriesFromGatewayData(payload) {
|
|
|
1049
1082
|
d: tuple.d,
|
|
1050
1083
|
u: tuple.u,
|
|
1051
1084
|
a: tuple.a,
|
|
1052
|
-
P:
|
|
1085
|
+
P: clamp012(projected),
|
|
1053
1086
|
trigger: readString(record.trigger) ?? "manual",
|
|
1054
1087
|
...triggeringEvidenceId ? {
|
|
1055
1088
|
triggeringRef: {
|