@mneme-ai/core 2.31.0 → 2.33.0
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/agent_manifest.d.ts +1 -1
- package/dist/agent_manifest.d.ts.map +1 -1
- package/dist/agent_manifest.js +29 -0
- package/dist/agent_manifest.js.map +1 -1
- package/dist/citizen_court/citizen_court.test.d.ts +2 -0
- package/dist/citizen_court/citizen_court.test.d.ts.map +1 -0
- package/dist/citizen_court/citizen_court.test.js +121 -0
- package/dist/citizen_court/citizen_court.test.js.map +1 -0
- package/dist/citizen_court/court.d.ts +48 -0
- package/dist/citizen_court/court.d.ts.map +1 -0
- package/dist/citizen_court/court.js +178 -0
- package/dist/citizen_court/court.js.map +1 -0
- package/dist/citizen_court/hsc.d.ts +11 -0
- package/dist/citizen_court/hsc.d.ts.map +1 -0
- package/dist/citizen_court/hsc.js +74 -0
- package/dist/citizen_court/hsc.js.map +1 -0
- package/dist/citizen_court/index.d.ts +13 -0
- package/dist/citizen_court/index.d.ts.map +1 -0
- package/dist/citizen_court/index.js +12 -0
- package/dist/citizen_court/index.js.map +1 -0
- package/dist/citizen_court/types.d.ts +104 -0
- package/dist/citizen_court/types.d.ts.map +1 -0
- package/dist/citizen_court/types.js +16 -0
- package/dist/citizen_court/types.js.map +1 -0
- package/dist/coercion/audit.d.ts +22 -0
- package/dist/coercion/audit.d.ts.map +1 -0
- package/dist/coercion/audit.js +169 -0
- package/dist/coercion/audit.js.map +1 -0
- package/dist/coercion/coercion.test.d.ts +2 -0
- package/dist/coercion/coercion.test.d.ts.map +1 -0
- package/dist/coercion/coercion.test.js +69 -0
- package/dist/coercion/coercion.test.js.map +1 -0
- package/dist/coercion/index.d.ts +11 -0
- package/dist/coercion/index.d.ts.map +1 -0
- package/dist/coercion/index.js +10 -0
- package/dist/coercion/index.js.map +1 -0
- package/dist/coercion/types.d.ts +53 -0
- package/dist/coercion/types.d.ts.map +1 -0
- package/dist/coercion/types.js +17 -0
- package/dist/coercion/types.js.map +1 -0
- package/dist/flywheel/controller.d.ts +51 -0
- package/dist/flywheel/controller.d.ts.map +1 -0
- package/dist/flywheel/controller.js +187 -0
- package/dist/flywheel/controller.js.map +1 -0
- package/dist/flywheel/flywheel.test.d.ts +2 -0
- package/dist/flywheel/flywheel.test.d.ts.map +1 -0
- package/dist/flywheel/flywheel.test.js +264 -0
- package/dist/flywheel/flywheel.test.js.map +1 -0
- package/dist/flywheel/fuse.d.ts +16 -0
- package/dist/flywheel/fuse.d.ts.map +1 -0
- package/dist/flywheel/fuse.js +140 -0
- package/dist/flywheel/fuse.js.map +1 -0
- package/dist/flywheel/harvest.d.ts +32 -0
- package/dist/flywheel/harvest.d.ts.map +1 -0
- package/dist/flywheel/harvest.js +327 -0
- package/dist/flywheel/harvest.js.map +1 -0
- package/dist/flywheel/index.d.ts +26 -0
- package/dist/flywheel/index.d.ts.map +1 -0
- package/dist/flywheel/index.js +19 -0
- package/dist/flywheel/index.js.map +1 -0
- package/dist/flywheel/liveness.d.ts +34 -0
- package/dist/flywheel/liveness.d.ts.map +1 -0
- package/dist/flywheel/liveness.js +63 -0
- package/dist/flywheel/liveness.js.map +1 -0
- package/dist/flywheel/personal_cheatsheet.d.ts +34 -0
- package/dist/flywheel/personal_cheatsheet.d.ts.map +1 -0
- package/dist/flywheel/personal_cheatsheet.js +95 -0
- package/dist/flywheel/personal_cheatsheet.js.map +1 -0
- package/dist/flywheel/prescribe.d.ts +20 -0
- package/dist/flywheel/prescribe.d.ts.map +1 -0
- package/dist/flywheel/prescribe.js +119 -0
- package/dist/flywheel/prescribe.js.map +1 -0
- package/dist/flywheel/reciprocity.d.ts +36 -0
- package/dist/flywheel/reciprocity.d.ts.map +1 -0
- package/dist/flywheel/reciprocity.js +113 -0
- package/dist/flywheel/reciprocity.js.map +1 -0
- package/dist/flywheel/types.d.ts +117 -0
- package/dist/flywheel/types.d.ts.map +1 -0
- package/dist/flywheel/types.js +25 -0
- package/dist/flywheel/types.js.map +1 -0
- package/dist/flywheel/vendor_bulletin.d.ts +44 -0
- package/dist/flywheel/vendor_bulletin.d.ts.map +1 -0
- package/dist/flywheel/vendor_bulletin.js +118 -0
- package/dist/flywheel/vendor_bulletin.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +38 -0
- package/dist/index.js.map +1 -1
- package/dist/mnemnet/aggregate.d.ts +33 -0
- package/dist/mnemnet/aggregate.d.ts.map +1 -0
- package/dist/mnemnet/aggregate.js +184 -0
- package/dist/mnemnet/aggregate.js.map +1 -0
- package/dist/mnemnet/dp.d.ts +13 -0
- package/dist/mnemnet/dp.d.ts.map +1 -0
- package/dist/mnemnet/dp.js +32 -0
- package/dist/mnemnet/dp.js.map +1 -0
- package/dist/mnemnet/index.d.ts +12 -0
- package/dist/mnemnet/index.d.ts.map +1 -0
- package/dist/mnemnet/index.js +11 -0
- package/dist/mnemnet/index.js.map +1 -0
- package/dist/mnemnet/mnemnet.test.d.ts +2 -0
- package/dist/mnemnet/mnemnet.test.d.ts.map +1 -0
- package/dist/mnemnet/mnemnet.test.js +147 -0
- package/dist/mnemnet/mnemnet.test.js.map +1 -0
- package/dist/mnemnet/types.d.ts +77 -0
- package/dist/mnemnet/types.d.ts.map +1 -0
- package/dist/mnemnet/types.js +14 -0
- package/dist/mnemnet/types.js.map +1 -0
- package/dist/pulsecost/budget.d.ts +20 -0
- package/dist/pulsecost/budget.d.ts.map +1 -0
- package/dist/pulsecost/budget.js +108 -0
- package/dist/pulsecost/budget.js.map +1 -0
- package/dist/pulsecost/index.d.ts +6 -0
- package/dist/pulsecost/index.d.ts.map +1 -0
- package/dist/pulsecost/index.js +5 -0
- package/dist/pulsecost/index.js.map +1 -0
- package/dist/pulsecost/pulsecost.test.d.ts +2 -0
- package/dist/pulsecost/pulsecost.test.d.ts.map +1 -0
- package/dist/pulsecost/pulsecost.test.js +64 -0
- package/dist/pulsecost/pulsecost.test.js.map +1 -0
- package/dist/pulsecost/types.d.ts +53 -0
- package/dist/pulsecost/types.d.ts.map +1 -0
- package/dist/pulsecost/types.js +22 -0
- package/dist/pulsecost/types.js.map +1 -0
- package/dist/truth_gate/claims.d.ts.map +1 -1
- package/dist/truth_gate/claims.js +29 -0
- package/dist/truth_gate/claims.js.map +1 -1
- package/dist/truth_gate/probes.d.ts.map +1 -1
- package/dist/truth_gate/probes.js +71 -0
- package/dist/truth_gate/probes.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.33.0 — CONFESSIONAL court reveal + vote ledger.
|
|
3
|
+
*
|
|
4
|
+
* The 1-second reveal mechanic is the citizen-court UX:
|
|
5
|
+
* user accepts/rejects → 1s wait → 4 other vendors' answers appear →
|
|
6
|
+
* user votes which was most truthful → HMAC-signed verdict.
|
|
7
|
+
*
|
|
8
|
+
* Storage:
|
|
9
|
+
* .mneme/citizen_court/pending_reveals.jsonl — reveals awaiting vote
|
|
10
|
+
* .mneme/citizen_court/verdicts.jsonl — finalized HMAC-chained
|
|
11
|
+
*/
|
|
12
|
+
import type { CourtVerdict, CourtRevealInput, CourtReveal, VoteInput } from "./types.js";
|
|
13
|
+
export declare function __resetConfessionalChainForTest(): void;
|
|
14
|
+
interface PendingReveal {
|
|
15
|
+
id: string;
|
|
16
|
+
reveal: CourtReveal;
|
|
17
|
+
primaryVendor: string;
|
|
18
|
+
promptHash: string;
|
|
19
|
+
primaryResponseHash: string;
|
|
20
|
+
primaryAction: "accepted" | "rejected";
|
|
21
|
+
createdAt: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Stage 1 — RECORD the primary action + schedule the reveal.
|
|
25
|
+
*
|
|
26
|
+
* The "1-second" delay is honoured via a Promise but tests can pass
|
|
27
|
+
* `delayMs: 0`. Caller MAY supply primary + reveal response texts;
|
|
28
|
+
* we hash them locally so the verdict ledger never holds raw text.
|
|
29
|
+
*/
|
|
30
|
+
export declare function recordRevealAndWait(repoRoot: string, input: CourtRevealInput): Promise<{
|
|
31
|
+
id: string;
|
|
32
|
+
reveal: CourtReveal;
|
|
33
|
+
}>;
|
|
34
|
+
/**
|
|
35
|
+
* Stage 2 — VOTE on the reveal. Finalizes a CONFESSIONAL verdict +
|
|
36
|
+
* HMAC-chains it + removes the pending row.
|
|
37
|
+
*/
|
|
38
|
+
export declare function vote(repoRoot: string, input: VoteInput): CourtVerdict;
|
|
39
|
+
export declare function listVerdicts(repoRoot: string, limit?: number): CourtVerdict[];
|
|
40
|
+
export declare function listPending(repoRoot: string): PendingReveal[];
|
|
41
|
+
export declare function verifyVerdict(v: CourtVerdict, prev?: string): {
|
|
42
|
+
ok: true;
|
|
43
|
+
} | {
|
|
44
|
+
ok: false;
|
|
45
|
+
reason: string;
|
|
46
|
+
};
|
|
47
|
+
export {};
|
|
48
|
+
//# sourceMappingURL=court.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"court.d.ts","sourceRoot":"","sources":["../../src/citizen_court/court.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAMH,OAAO,KAAK,EACV,YAAY,EAAE,gBAAgB,EAAE,WAAW,EAAE,SAAS,EACvD,MAAM,YAAY,CAAC;AAKpB,wBAAgB,+BAA+B,IAAI,IAAI,CAAgC;AAsBvF,UAAU,aAAa;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,WAAW,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,aAAa,EAAE,UAAU,GAAG,UAAU,CAAC;IACvC,SAAS,EAAE,MAAM,CAAC;CACnB;AAkBD;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,WAAW,CAAA;CAAE,CAAC,CA+BjI;AAED;;;GAGG;AACH,wBAAgB,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,GAAG,YAAY,CAuCrE;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,SAAO,GAAG,YAAY,EAAE,CAU3E;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,aAAa,EAAE,CAE7D;AAED,wBAAgB,aAAa,CAAC,CAAC,EAAE,YAAY,EAAE,IAAI,GAAE,MAAmB,GAAG;IAAE,EAAE,EAAE,IAAI,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAQtH"}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.33.0 — CONFESSIONAL court reveal + vote ledger.
|
|
3
|
+
*
|
|
4
|
+
* The 1-second reveal mechanic is the citizen-court UX:
|
|
5
|
+
* user accepts/rejects → 1s wait → 4 other vendors' answers appear →
|
|
6
|
+
* user votes which was most truthful → HMAC-signed verdict.
|
|
7
|
+
*
|
|
8
|
+
* Storage:
|
|
9
|
+
* .mneme/citizen_court/pending_reveals.jsonl — reveals awaiting vote
|
|
10
|
+
* .mneme/citizen_court/verdicts.jsonl — finalized HMAC-chained
|
|
11
|
+
*/
|
|
12
|
+
import { existsSync, mkdirSync, appendFileSync, readFileSync, writeFileSync } from "node:fs";
|
|
13
|
+
import { join } from "node:path";
|
|
14
|
+
import { createHash, createHmac } from "node:crypto";
|
|
15
|
+
const HMAC_KEY = process.env["MNEME_CONFESSIONAL_KEY"] ?? "mneme-confessional-v1";
|
|
16
|
+
const CHAIN_SEED = "0".repeat(64);
|
|
17
|
+
let lastChainLink = CHAIN_SEED;
|
|
18
|
+
export function __resetConfessionalChainForTest() { lastChainLink = CHAIN_SEED; }
|
|
19
|
+
function canon(v) {
|
|
20
|
+
if (v === null || typeof v !== "object")
|
|
21
|
+
return JSON.stringify(v);
|
|
22
|
+
if (Array.isArray(v))
|
|
23
|
+
return "[" + v.map(canon).join(",") + "]";
|
|
24
|
+
const keys = Object.keys(v).sort();
|
|
25
|
+
return "{" + keys.map((k) => JSON.stringify(k) + ":" + canon(v[k])).join(",") + "}";
|
|
26
|
+
}
|
|
27
|
+
function sha(s) { return createHash("sha256").update(s).digest("hex"); }
|
|
28
|
+
function sha8(s) { return sha(s).slice(0, 12); }
|
|
29
|
+
function hmacOf(prev, payload) {
|
|
30
|
+
return createHmac("sha256", HMAC_KEY).update(prev + "|" + payload).digest("hex");
|
|
31
|
+
}
|
|
32
|
+
function dirOf(repoRoot) {
|
|
33
|
+
const d = join(repoRoot, ".mneme", "citizen_court");
|
|
34
|
+
if (!existsSync(d))
|
|
35
|
+
mkdirSync(d, { recursive: true });
|
|
36
|
+
return d;
|
|
37
|
+
}
|
|
38
|
+
function pendingPath(repoRoot) { return join(dirOf(repoRoot), "pending_reveals.jsonl"); }
|
|
39
|
+
function verdictPath(repoRoot) { return join(dirOf(repoRoot), "verdicts.jsonl"); }
|
|
40
|
+
function readPending(repoRoot) {
|
|
41
|
+
const p = pendingPath(repoRoot);
|
|
42
|
+
if (!existsSync(p))
|
|
43
|
+
return [];
|
|
44
|
+
const out = [];
|
|
45
|
+
try {
|
|
46
|
+
for (const ln of readFileSync(p, "utf8").split("\n").filter(Boolean)) {
|
|
47
|
+
try {
|
|
48
|
+
out.push(JSON.parse(ln));
|
|
49
|
+
}
|
|
50
|
+
catch { /* skip */ }
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
catch { /* best-effort */ }
|
|
54
|
+
return out;
|
|
55
|
+
}
|
|
56
|
+
function writePending(repoRoot, rows) {
|
|
57
|
+
writeFileSync(pendingPath(repoRoot), rows.map((r) => JSON.stringify(r)).join("\n") + "\n");
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Stage 1 — RECORD the primary action + schedule the reveal.
|
|
61
|
+
*
|
|
62
|
+
* The "1-second" delay is honoured via a Promise but tests can pass
|
|
63
|
+
* `delayMs: 0`. Caller MAY supply primary + reveal response texts;
|
|
64
|
+
* we hash them locally so the verdict ledger never holds raw text.
|
|
65
|
+
*/
|
|
66
|
+
export async function recordRevealAndWait(repoRoot, input) {
|
|
67
|
+
const delayMs = input.delayMs ?? 1000;
|
|
68
|
+
if (delayMs > 0)
|
|
69
|
+
await new Promise((r) => setTimeout(r, delayMs));
|
|
70
|
+
const reveals = input.revealVendors.map((vendor) => {
|
|
71
|
+
const text = input.revealResponses?.[vendor] ?? "";
|
|
72
|
+
return { vendor, responseHash: sha(text), revealDelayMs: delayMs };
|
|
73
|
+
});
|
|
74
|
+
const previews = input.revealVendors.map((vendor) => ({
|
|
75
|
+
vendor,
|
|
76
|
+
preview: (input.revealResponses?.[vendor] ?? "").slice(0, 200),
|
|
77
|
+
}));
|
|
78
|
+
const revealedAt = new Date().toISOString();
|
|
79
|
+
const reveal = { revealedAt, reveals, previews };
|
|
80
|
+
// Stable id from canonical inputs so the same court session is idempotent.
|
|
81
|
+
const id = "rv-" + sha8(canon({
|
|
82
|
+
primaryVendor: input.primaryVendor,
|
|
83
|
+
promptHash: input.promptHash,
|
|
84
|
+
primaryResponseHash: input.primaryResponseHash,
|
|
85
|
+
primaryAction: input.primaryAction,
|
|
86
|
+
revealedAt,
|
|
87
|
+
}));
|
|
88
|
+
const row = {
|
|
89
|
+
id, reveal,
|
|
90
|
+
primaryVendor: input.primaryVendor,
|
|
91
|
+
promptHash: input.promptHash,
|
|
92
|
+
primaryResponseHash: input.primaryResponseHash,
|
|
93
|
+
primaryAction: input.primaryAction,
|
|
94
|
+
createdAt: revealedAt,
|
|
95
|
+
};
|
|
96
|
+
try {
|
|
97
|
+
appendFileSync(pendingPath(repoRoot), JSON.stringify(row) + "\n");
|
|
98
|
+
}
|
|
99
|
+
catch { /* best-effort */ }
|
|
100
|
+
return { id, reveal };
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Stage 2 — VOTE on the reveal. Finalizes a CONFESSIONAL verdict +
|
|
104
|
+
* HMAC-chains it + removes the pending row.
|
|
105
|
+
*/
|
|
106
|
+
export function vote(repoRoot, input) {
|
|
107
|
+
const pending = readPending(repoRoot);
|
|
108
|
+
const idx = pending.findIndex((p) => p.id === input.revealId);
|
|
109
|
+
if (idx < 0)
|
|
110
|
+
throw new Error(`no pending reveal with id ${input.revealId}`);
|
|
111
|
+
const pend = pending[idx];
|
|
112
|
+
// Validate vote target
|
|
113
|
+
const validTargets = new Set([pend.primaryVendor, ...pend.reveal.reveals.map((r) => r.vendor), "ABSTAIN"]);
|
|
114
|
+
if (!validTargets.has(input.votedMostTruthful)) {
|
|
115
|
+
throw new Error(`vote target "${input.votedMostTruthful}" not in court (valid: ${Array.from(validTargets).join(", ")})`);
|
|
116
|
+
}
|
|
117
|
+
const at = new Date().toISOString();
|
|
118
|
+
const verdictBody = {
|
|
119
|
+
primaryVendor: pend.primaryVendor,
|
|
120
|
+
at,
|
|
121
|
+
promptHash: pend.promptHash,
|
|
122
|
+
primaryResponseHash: pend.primaryResponseHash,
|
|
123
|
+
primaryAction: pend.primaryAction,
|
|
124
|
+
reveals: pend.reveal.reveals,
|
|
125
|
+
votedMostTruthful: input.votedMostTruthful,
|
|
126
|
+
...(input.reasoning ? { reasoning: input.reasoning } : {}),
|
|
127
|
+
dpEpsilon: input.dpEpsilon ?? 0,
|
|
128
|
+
};
|
|
129
|
+
const id = "v-" + sha8(canon(verdictBody));
|
|
130
|
+
const fullBody = { id, ...verdictBody };
|
|
131
|
+
const bodyDigest = sha(canon(fullBody));
|
|
132
|
+
lastChainLink = hmacOf(lastChainLink, bodyDigest);
|
|
133
|
+
const verdict = {
|
|
134
|
+
...fullBody,
|
|
135
|
+
hmac: lastChainLink,
|
|
136
|
+
seq: parseInt(lastChainLink.slice(0, 8), 16),
|
|
137
|
+
bodyDigest,
|
|
138
|
+
};
|
|
139
|
+
// Persist verdict + remove pending row.
|
|
140
|
+
try {
|
|
141
|
+
appendFileSync(verdictPath(repoRoot), JSON.stringify(verdict) + "\n");
|
|
142
|
+
}
|
|
143
|
+
catch { /* best-effort */ }
|
|
144
|
+
pending.splice(idx, 1);
|
|
145
|
+
writePending(repoRoot, pending);
|
|
146
|
+
return verdict;
|
|
147
|
+
}
|
|
148
|
+
export function listVerdicts(repoRoot, limit = 1000) {
|
|
149
|
+
const p = verdictPath(repoRoot);
|
|
150
|
+
if (!existsSync(p))
|
|
151
|
+
return [];
|
|
152
|
+
const out = [];
|
|
153
|
+
try {
|
|
154
|
+
for (const ln of readFileSync(p, "utf8").split("\n").filter(Boolean).slice(-limit)) {
|
|
155
|
+
try {
|
|
156
|
+
out.push(JSON.parse(ln));
|
|
157
|
+
}
|
|
158
|
+
catch { /* skip */ }
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
catch { /* best-effort */ }
|
|
162
|
+
return out;
|
|
163
|
+
}
|
|
164
|
+
export function listPending(repoRoot) {
|
|
165
|
+
return readPending(repoRoot);
|
|
166
|
+
}
|
|
167
|
+
export function verifyVerdict(v, prev = CHAIN_SEED) {
|
|
168
|
+
const { hmac, seq: _s, bodyDigest, ...body } = v;
|
|
169
|
+
void _s;
|
|
170
|
+
const recomputed = sha(canon(body));
|
|
171
|
+
if (recomputed !== bodyDigest)
|
|
172
|
+
return { ok: false, reason: "bodyDigest mismatch" };
|
|
173
|
+
const expected = hmacOf(prev, recomputed);
|
|
174
|
+
if (expected !== hmac)
|
|
175
|
+
return { ok: false, reason: "hmac mismatch" };
|
|
176
|
+
return { ok: true };
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=court.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"court.js","sourceRoot":"","sources":["../../src/citizen_court/court.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,cAAc,EAAE,YAAY,E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AC;IACH,CAAC;IAAC,MAAM,CAAC,CAAC,iBAAiB,CAAC,CAAC;IAC7B,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,QAAgB;IAC1C,OAAO,WAAW,CAAC,QAAQ,CAAC,CAAC;AAC/B,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,CAAe,EAAE,OAAe,UAAU;IACtE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,EAAE,UAAU,EAAE,GAAG,IAAI,EAAE,GAAG,CAAC,CAAC;IACjD,KAAK,EAAE,CAAC;IACR,MAAM,UAAU,GAAG,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IACpC,IAAI,UAAU,KAAK,UAAU;QAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,qBAAqB,EAAE,CAAC;IACnF,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IAC1C,IAAI,QAAQ,KAAK,IAAI;QAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC;IACrE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;AACtB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.33.0 — Honesty Score Card (HSC) computation.
|
|
3
|
+
*
|
|
4
|
+
* Per-vendor truthful-vote rate with Wilson-95% lower bound on a
|
|
5
|
+
* Bernoulli proportion. Small sample sizes get an UNDER-MEASURED
|
|
6
|
+
* cohort note + the ⚪ band. Score → IDE color dot.
|
|
7
|
+
*/
|
|
8
|
+
import type { CourtVerdict, HonestyScoreCard } from "./types.js";
|
|
9
|
+
export declare function computeHsc(verdicts: CourtVerdict[]): HonestyScoreCard[];
|
|
10
|
+
export declare function readHsc(repoRoot: string): HonestyScoreCard[];
|
|
11
|
+
//# sourceMappingURL=hsc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hsc.d.ts","sourceRoot":"","sources":["../../src/citizen_court/hsc.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAoBjE,wBAAgB,UAAU,CAAC,QAAQ,EAAE,YAAY,EAAE,GAAG,gBAAgB,EAAE,CAyCvE;AAED,wBAAgB,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,gBAAgB,EAAE,CAE5D"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.33.0 — Honesty Score Card (HSC) computation.
|
|
3
|
+
*
|
|
4
|
+
* Per-vendor truthful-vote rate with Wilson-95% lower bound on a
|
|
5
|
+
* Bernoulli proportion. Small sample sizes get an UNDER-MEASURED
|
|
6
|
+
* cohort note + the ⚪ band. Score → IDE color dot.
|
|
7
|
+
*/
|
|
8
|
+
import { listVerdicts } from "./court.js";
|
|
9
|
+
/** 95% Wilson lower bound on a Bernoulli proportion p̂ = k/n. */
|
|
10
|
+
function wilsonLB(successes, trials, z = 1.96) {
|
|
11
|
+
if (trials === 0)
|
|
12
|
+
return 0;
|
|
13
|
+
const p = successes / trials;
|
|
14
|
+
const denom = 1 + (z * z) / trials;
|
|
15
|
+
const center = p + (z * z) / (2 * trials);
|
|
16
|
+
const margin = z * Math.sqrt((p * (1 - p) + (z * z) / (4 * trials)) / trials);
|
|
17
|
+
return Math.max(0, (center - margin) / denom);
|
|
18
|
+
}
|
|
19
|
+
function band(lb, sampleSize) {
|
|
20
|
+
if (sampleSize < 5)
|
|
21
|
+
return "⚪ unmeasured";
|
|
22
|
+
if (lb >= 0.65)
|
|
23
|
+
return "🟢 trustworthy";
|
|
24
|
+
if (lb >= 0.40)
|
|
25
|
+
return "🟡 mixed";
|
|
26
|
+
return "🔴 suspect";
|
|
27
|
+
}
|
|
28
|
+
export function computeHsc(verdicts) {
|
|
29
|
+
const by = new Map();
|
|
30
|
+
function bump(v, key) {
|
|
31
|
+
const cur = by.get(v) ?? { truthful: 0, lost: 0, abstain: 0 };
|
|
32
|
+
cur[key]++;
|
|
33
|
+
by.set(v, cur);
|
|
34
|
+
}
|
|
35
|
+
for (const v of verdicts) {
|
|
36
|
+
const parties = new Set([v.primaryVendor, ...v.reveals.map((r) => r.vendor)]);
|
|
37
|
+
if (v.votedMostTruthful === "ABSTAIN") {
|
|
38
|
+
for (const p of parties)
|
|
39
|
+
bump(p, "abstain");
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
for (const p of parties) {
|
|
43
|
+
if (p === v.votedMostTruthful)
|
|
44
|
+
bump(p, "truthful");
|
|
45
|
+
else
|
|
46
|
+
bump(p, "lost");
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const out = [];
|
|
50
|
+
for (const [vendor, a] of by.entries()) {
|
|
51
|
+
const sampleSize = a.truthful + a.lost + a.abstain;
|
|
52
|
+
const decisive = a.truthful + a.lost;
|
|
53
|
+
const lb = wilsonLB(a.truthful, decisive);
|
|
54
|
+
const raw = decisive === 0 ? 0 : a.truthful / decisive;
|
|
55
|
+
out.push({
|
|
56
|
+
vendor,
|
|
57
|
+
truthfulVotes: a.truthful,
|
|
58
|
+
lostVotes: a.lost,
|
|
59
|
+
abstainsInvolving: a.abstain,
|
|
60
|
+
honestyScoreLB: Number(lb.toFixed(3)),
|
|
61
|
+
honestyScoreRaw: Number(raw.toFixed(3)),
|
|
62
|
+
sampleSize: decisive,
|
|
63
|
+
band: band(lb, decisive),
|
|
64
|
+
...(decisive < 5 ? { cohortNote: `under-measured (n=${decisive} decisive votes; band reports ⚪ until n≥5)` } : {}),
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
// Sort by LB descending so highest-trust vendor is first.
|
|
68
|
+
out.sort((a, b) => b.honestyScoreLB - a.honestyScoreLB);
|
|
69
|
+
return out;
|
|
70
|
+
}
|
|
71
|
+
export function readHsc(repoRoot) {
|
|
72
|
+
return computeHsc(listVerdicts(repoRoot, 10000));
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=hsc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hsc.js","sourceRoot":"","sources":["../../src/citizen_court/hsc.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,iEAAiE;AACjE,SAAS,QAAQ,CAAC,SAAiB,EAAE,MAAc,EAAE,CAAC,GAAG,IAAI;IAC3D,IAAI,MAAM,KAAK,CAAC;QAAE,OAAO,CAAC,CAAC;IAC3B,MAAM,CAAC,GAAG,SAAS,GAAG,MAAM,CAAC;IAC7B,MAAM,KAAK,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC;IACnC,MAAM,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC;IAC1C,MAAM,MAAM,GAAG,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC;IAC9E,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC;AAChD,CAAC;AAED,SAAS,IAAI,CAAC,EAAU,EAAE,UAAkB;IAC1C,IAAI,UAAU,GAAG,CAAC;QAAE,OAAO,cAAc,CAAC;IAC1C,IAAI,EAAE,IAAI,IAAI;QAAE,OAAO,gBAAgB,CAAC;IACxC,IAAI,EAAE,IAAI,IAAI;QAAE,OAAO,UAAU,CAAC;IAClC,OAAO,YAAY,CAAC;AACtB,CAAC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
*
|
|
4
|
+
* The AI Honesty Citizen Court. Local-first user-judgment ledger that
|
|
5
|
+
* powers per-vendor Honesty Score Cards (HSC). Optional MNEMNET
|
|
6
|
+
* federation aggregates across consenting nodes for the Public
|
|
7
|
+
* Honesty Court. Distinct from the v2.19 ARENA-audit confessional —
|
|
8
|
+
* this is HCI/participatory, that one is vendor-diff orchestration.
|
|
9
|
+
*/
|
|
10
|
+
export type { CourtVerdict, HonestyScoreCard, CourtRevealInput, CourtReveal, VoteInput, } from "./types.js";
|
|
11
|
+
export { recordRevealAndWait, vote, listVerdicts, listPending, verifyVerdict, __resetConfessionalChainForTest, } from "./court.js";
|
|
12
|
+
export { computeHsc, readHsc } from "./hsc.js";
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/citizen_court/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,YAAY,EACV,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,WAAW,EAAE,SAAS,GACzE,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,mBAAmB,EAAE,IAAI,EAAE,YAAY,EAAE,WAAW,EAAE,aAAa,EACnE,+BAA+B,GAChC,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.33.0 — CITIZEN COURT (Mneme Confessional, public participatory variant).
|
|
3
|
+
*
|
|
4
|
+
* The AI Honesty Citizen Court. Local-first user-judgment ledger that
|
|
5
|
+
* powers per-vendor Honesty Score Cards (HSC). Optional MNEMNET
|
|
6
|
+
* federation aggregates across consenting nodes for the Public
|
|
7
|
+
* Honesty Court. Distinct from the v2.19 ARENA-audit confessional —
|
|
8
|
+
* this is HCI/participatory, that one is vendor-diff orchestration.
|
|
9
|
+
*/
|
|
10
|
+
export { recordRevealAndWait, vote, listVerdicts, listPending, verifyVerdict, __resetConfessionalChainForTest, } from "./court.js";
|
|
11
|
+
export { computeHsc, readHsc } from "./hsc.js";
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/citizen_court/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,OAAO,EACL,mBAAmB,EAAE,IAAI,EAAE,YAAY,EAAE,WAAW,EAAE,aAAa,EACnE,+BAA+B,GAChC,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.33.0 — CONFESSIONAL types.
|
|
3
|
+
*
|
|
4
|
+
* The AI Honesty Citizen Court. Every accept/reject becomes a verdict.
|
|
5
|
+
* 1-second reveal mechanism shows the OTHER vendors' answers so the
|
|
6
|
+
* user can vote on which was most truthful. HMAC-signed verdicts feed
|
|
7
|
+
* the local + (opt-in) federated Honesty Score Card (HSC).
|
|
8
|
+
*
|
|
9
|
+
* Composes with:
|
|
10
|
+
* - CONCLAVE (.vendors registry) — supplies the "other vendors"
|
|
11
|
+
* - HONEST MIRROR / REWIND (aletheia weights) — vote weighting
|
|
12
|
+
* - MNEMNET (federated DP aggregation) — backend if opted in
|
|
13
|
+
* - FLYWHEEL (signal source) — new HARVEST source `confessional`
|
|
14
|
+
*/
|
|
15
|
+
/** Local-only verdict — never leaves disk unless MNEMNET opt-in. */
|
|
16
|
+
export interface CourtVerdict {
|
|
17
|
+
/** Stable UUID-ish id (sha8 of canonical content). */
|
|
18
|
+
id: string;
|
|
19
|
+
/** Vendor whose suggestion the user reacted to FIRST. */
|
|
20
|
+
primaryVendor: string;
|
|
21
|
+
/** ISO timestamp. */
|
|
22
|
+
at: string;
|
|
23
|
+
/** Hash of the prompt (NEVER store the prompt itself unless explicit opt-in). */
|
|
24
|
+
promptHash: string;
|
|
25
|
+
/** Hash of primary vendor's response. */
|
|
26
|
+
primaryResponseHash: string;
|
|
27
|
+
/** Did the user ACCEPT or REJECT the primary's suggestion? */
|
|
28
|
+
primaryAction: "accepted" | "rejected";
|
|
29
|
+
/** N other-vendor reveals shown to the user (hashes only). */
|
|
30
|
+
reveals: Array<{
|
|
31
|
+
vendor: string;
|
|
32
|
+
responseHash: string;
|
|
33
|
+
/** ms between primary action + reveal. Court is "1-second reveal" by design. */
|
|
34
|
+
revealDelayMs: number;
|
|
35
|
+
}>;
|
|
36
|
+
/**
|
|
37
|
+
* User's truthfulness vote. ABSTAIN = user declined to vote.
|
|
38
|
+
* The voted vendor may be the primary or any of the reveals.
|
|
39
|
+
*/
|
|
40
|
+
votedMostTruthful: string | "ABSTAIN";
|
|
41
|
+
/** Optional one-line reasoning from the user (private). */
|
|
42
|
+
reasoning?: string;
|
|
43
|
+
/** Differential-privacy epsilon at vote time (if known). 0 = no DP. */
|
|
44
|
+
dpEpsilon: number;
|
|
45
|
+
/** HMAC-signed chain link. */
|
|
46
|
+
hmac: string;
|
|
47
|
+
/** Append-only sequence number. */
|
|
48
|
+
seq: number;
|
|
49
|
+
bodyDigest: string;
|
|
50
|
+
}
|
|
51
|
+
export interface HonestyScoreCard {
|
|
52
|
+
vendor: string;
|
|
53
|
+
/** Number of verdicts where this vendor was voted most truthful. */
|
|
54
|
+
truthfulVotes: number;
|
|
55
|
+
/** Number of verdicts where this vendor was NOT voted (lost). */
|
|
56
|
+
lostVotes: number;
|
|
57
|
+
/** Number of verdicts where the user abstained. */
|
|
58
|
+
abstainsInvolving: number;
|
|
59
|
+
/** Wilson lower-bound confidence interval at 95% on truthful-vote rate. */
|
|
60
|
+
honestyScoreLB: number;
|
|
61
|
+
/** Plain truthful-vote rate (truthfulVotes / (truthfulVotes + lostVotes)). */
|
|
62
|
+
honestyScoreRaw: number;
|
|
63
|
+
/** Total verdicts this vendor was a party to. */
|
|
64
|
+
sampleSize: number;
|
|
65
|
+
/** Color band for IDE dot. */
|
|
66
|
+
band: "🟢 trustworthy" | "🟡 mixed" | "🔴 suspect" | "⚪ unmeasured";
|
|
67
|
+
/** Cohort note when sample too small. */
|
|
68
|
+
cohortNote?: string;
|
|
69
|
+
}
|
|
70
|
+
export interface CourtRevealInput {
|
|
71
|
+
primaryVendor: string;
|
|
72
|
+
promptHash: string;
|
|
73
|
+
primaryResponseHash: string;
|
|
74
|
+
primaryAction: "accepted" | "rejected";
|
|
75
|
+
/** Vendors to fan out to for the 1-second reveal. */
|
|
76
|
+
revealVendors: string[];
|
|
77
|
+
/**
|
|
78
|
+
* Delay (ms) before the reveal is shown. Default 1000 (the 1-second
|
|
79
|
+
* mechanic that defines the citizen-court UX). Lower for tests.
|
|
80
|
+
*/
|
|
81
|
+
delayMs?: number;
|
|
82
|
+
/** Optional prompt + responses if the caller wants to pre-compute hashes. */
|
|
83
|
+
prompt?: string;
|
|
84
|
+
primaryResponse?: string;
|
|
85
|
+
revealResponses?: Record<string, string>;
|
|
86
|
+
}
|
|
87
|
+
export interface CourtReveal {
|
|
88
|
+
/** When the reveal fired (after the configured delay). */
|
|
89
|
+
revealedAt: string;
|
|
90
|
+
/** Vendors revealed + their response hashes. */
|
|
91
|
+
reveals: CourtVerdict["reveals"];
|
|
92
|
+
/** Truncated previews per vendor (200 chars) for the UI. */
|
|
93
|
+
previews: Array<{
|
|
94
|
+
vendor: string;
|
|
95
|
+
preview: string;
|
|
96
|
+
}>;
|
|
97
|
+
}
|
|
98
|
+
export interface VoteInput {
|
|
99
|
+
revealId: string;
|
|
100
|
+
votedMostTruthful: string | "ABSTAIN";
|
|
101
|
+
reasoning?: string;
|
|
102
|
+
dpEpsilon?: number;
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/citizen_court/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CAAyC;IACzC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,gBAAgB;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,aAAa,EAAE,UAAU,GAAG,UAAU,CAAC;IACvC,qDAAqD;IACrD,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,6EAA6E;IAC7E,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC1C;AAED,MAAM,WAAW,WAAW;IAC1B,0DAA0D;IAC1D,UAAU,EAAE,MAAM,CAAC;IACnB,gDAAgD;IAChD,OAAO,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;IACjC,4DAA4D;IAC5D,QAAQ,EAAE,KAAK,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACtD;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,iBAAiB,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.33.0 — CONFESSIONAL types.
|
|
3
|
+
*
|
|
4
|
+
* The AI Honesty Citizen Court. Every accept/reject becomes a verdict.
|
|
5
|
+
* 1-second reveal mechanism shows the OTHER vendors' answers so the
|
|
6
|
+
* user can vote on which was most truthful. HMAC-signed verdicts feed
|
|
7
|
+
* the local + (opt-in) federated Honesty Score Card (HSC).
|
|
8
|
+
*
|
|
9
|
+
* Composes with:
|
|
10
|
+
* - CONCLAVE (.vendors registry) — supplies the "other vendors"
|
|
11
|
+
* - HONEST MIRROR / REWIND (aletheia weights) — vote weighting
|
|
12
|
+
* - MNEMNET (federated DP aggregation) — backend if opted in
|
|
13
|
+
* - FLYWHEEL (signal source) — new HARVEST source `confessional`
|
|
14
|
+
*/
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/citizen_court/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v2.33.0 — COERCION audit primitive.
|
|
3
|
+
*
|
|
4
|
+
* Scan any free-text MCP response / pulse / status / inbox row
|
|
5
|
+
* against the 8 coercion patterns. Produces HMAC-signed report card.
|
|
6
|
+
*
|
|
7
|
+
* Composable: meta-audit on N sources rolls into one MultiSourceAudit
|
|
8
|
+
* envelope so a paper can publish a taxonomy survey across 20+ MCP
|
|
9
|
+
* servers (paper 2 reference data).
|
|
10
|
+
*/
|
|
11
|
+
import type { CoercionPattern, CoercionAuditResult, MultiSourceAudit } from "./types.js";
|
|
12
|
+
export declare const PATTERNS: CoercionPattern[];
|
|
13
|
+
export declare function auditText(source: string, text: string): CoercionAuditResult;
|
|
14
|
+
export declare function auditMany(sources: Array<{
|
|
15
|
+
source: string;
|
|
16
|
+
text: string;
|
|
17
|
+
}>): MultiSourceAudit;
|
|
18
|
+
export declare function verifyAudit(audit: CoercionAuditResult | MultiSourceAudit): {
|
|
19
|
+
ok: boolean;
|
|
20
|
+
reason?: string;
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=audit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../../src/coercion/audit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EACV,eAAe,EAAe,mBAAmB,EAAE,gBAAgB,EACpE,MAAM,YAAY,CAAC;AAapB,eAAO,MAAM,QAAQ,EAAE,eAAe,EA4ErC,CAAC;AAeF,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,mBAAmB,CA+B3E;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE,KAAK,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,GAAG,gBAAgB,CAa5F;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,mBAAmB,GAAG,gBAAgB,GAAG;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAK3G"}
|