@mneme-ai/core 1.70.0 → 1.72.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.
Files changed (76) hide show
  1. package/dist/diaspora/diaspora.test.d.ts +5 -0
  2. package/dist/diaspora/diaspora.test.d.ts.map +1 -0
  3. package/dist/diaspora/diaspora.test.js +232 -0
  4. package/dist/diaspora/diaspora.test.js.map +1 -0
  5. package/dist/diaspora/gitignore_writer.d.ts +43 -0
  6. package/dist/diaspora/gitignore_writer.d.ts.map +1 -0
  7. package/dist/diaspora/gitignore_writer.js +161 -0
  8. package/dist/diaspora/gitignore_writer.js.map +1 -0
  9. package/dist/diaspora/http_bridge.d.ts +54 -0
  10. package/dist/diaspora/http_bridge.d.ts.map +1 -0
  11. package/dist/diaspora/http_bridge.js +229 -0
  12. package/dist/diaspora/http_bridge.js.map +1 -0
  13. package/dist/diaspora/index.d.ts +26 -0
  14. package/dist/diaspora/index.d.ts.map +1 -0
  15. package/dist/diaspora/index.js +26 -0
  16. package/dist/diaspora/index.js.map +1 -0
  17. package/dist/diaspora/session_capsule.d.ts +78 -0
  18. package/dist/diaspora/session_capsule.d.ts.map +1 -0
  19. package/dist/diaspora/session_capsule.js +193 -0
  20. package/dist/diaspora/session_capsule.js.map +1 -0
  21. package/dist/diaspora/spore_autostart.d.ts +53 -0
  22. package/dist/diaspora/spore_autostart.d.ts.map +1 -0
  23. package/dist/diaspora/spore_autostart.js +102 -0
  24. package/dist/diaspora/spore_autostart.js.map +1 -0
  25. package/dist/index.d.ts +2 -0
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +11 -0
  28. package/dist/index.js.map +1 -1
  29. package/dist/parasite/bridge.d.ts.map +1 -1
  30. package/dist/parasite/bridge.js +10 -0
  31. package/dist/parasite/bridge.js.map +1 -1
  32. package/dist/precog/adversarial_mutation.d.ts +39 -0
  33. package/dist/precog/adversarial_mutation.d.ts.map +1 -0
  34. package/dist/precog/adversarial_mutation.js +71 -0
  35. package/dist/precog/adversarial_mutation.js.map +1 -0
  36. package/dist/precog/council_mutation.test.d.ts +5 -0
  37. package/dist/precog/council_mutation.test.d.ts.map +1 -0
  38. package/dist/precog/council_mutation.test.js +82 -0
  39. package/dist/precog/council_mutation.test.js.map +1 -0
  40. package/dist/precog/index.d.ts +4 -0
  41. package/dist/precog/index.d.ts.map +1 -1
  42. package/dist/precog/index.js +4 -0
  43. package/dist/precog/index.js.map +1 -1
  44. package/dist/precog/multi_voice_council.d.ts +50 -0
  45. package/dist/precog/multi_voice_council.d.ts.map +1 -0
  46. package/dist/precog/multi_voice_council.js +105 -0
  47. package/dist/precog/multi_voice_council.js.map +1 -0
  48. package/dist/sentinel/audit_ledger.d.ts +46 -0
  49. package/dist/sentinel/audit_ledger.d.ts.map +1 -0
  50. package/dist/sentinel/audit_ledger.js +115 -0
  51. package/dist/sentinel/audit_ledger.js.map +1 -0
  52. package/dist/sentinel/command_detector.d.ts +59 -0
  53. package/dist/sentinel/command_detector.d.ts.map +1 -0
  54. package/dist/sentinel/command_detector.js +265 -0
  55. package/dist/sentinel/command_detector.js.map +1 -0
  56. package/dist/sentinel/index.d.ts +43 -0
  57. package/dist/sentinel/index.d.ts.map +1 -0
  58. package/dist/sentinel/index.js +105 -0
  59. package/dist/sentinel/index.js.map +1 -0
  60. package/dist/sentinel/risk_scorer.d.ts +34 -0
  61. package/dist/sentinel/risk_scorer.d.ts.map +1 -0
  62. package/dist/sentinel/risk_scorer.js +92 -0
  63. package/dist/sentinel/risk_scorer.js.map +1 -0
  64. package/dist/sentinel/scope_enforcer.d.ts +38 -0
  65. package/dist/sentinel/scope_enforcer.d.ts.map +1 -0
  66. package/dist/sentinel/scope_enforcer.js +145 -0
  67. package/dist/sentinel/scope_enforcer.js.map +1 -0
  68. package/dist/sentinel/sentinel.d.ts +63 -0
  69. package/dist/sentinel/sentinel.d.ts.map +1 -0
  70. package/dist/sentinel/sentinel.js +123 -0
  71. package/dist/sentinel/sentinel.js.map +1 -0
  72. package/dist/sentinel/sentinel.test.d.ts +5 -0
  73. package/dist/sentinel/sentinel.test.d.ts.map +1 -0
  74. package/dist/sentinel/sentinel.test.js +179 -0
  75. package/dist/sentinel/sentinel.test.js.map +1 -0
  76. package/package.json +1 -1
@@ -0,0 +1,50 @@
1
+ /**
2
+ * v1.71.0 -- PRECOG +C1: MULTI-VOICE COUNCIL.
3
+ *
4
+ * Push PRECOG catch rate from 92.9% toward 98%+. Instead of a single
5
+ * verifier-pass, run the claim through FIVE distinct voices, each
6
+ * with a different cognitive bias:
7
+ *
8
+ * V1 PACKAGE-PEDANT extra strict on package names + versions
9
+ * V2 TEMPORAL-PARANOID extra strict on time claims
10
+ * V3 HUMILITY-ZEALOT extra strict on absolute speech
11
+ * V4 CITATION-NIGGLE requires every entity to have a citation
12
+ * V5 NOVELTY-SUSPICION flags shapes not seen in repo history
13
+ *
14
+ * Majority vote -> hedge if 3+/5 voices say "suspect". Breaks the
15
+ * "PRECOG missed because one regex didn't fire" failure mode by
16
+ * needing redundant agreement.
17
+ *
18
+ * The wild bit: voices use DIFFERENT THRESHOLDS for the same
19
+ * underlying checker. V1 might flag "X@1.0.0" at 0.4 confidence
20
+ * while the default PRECOG only flags at 0.6. The council compares
21
+ * how many voices agree at THEIR individual threshold.
22
+ */
23
+ export type VoiceId = "V1-package-pedant" | "V2-temporal-paranoid" | "V3-humility-zealot" | "V4-citation-niggle" | "V5-novelty-suspicion";
24
+ export interface VoiceVote {
25
+ voice: VoiceId;
26
+ /** This voice's verdict: "hedge" / "pass" / "abstain". */
27
+ vote: "hedge" | "pass" | "abstain";
28
+ /** Confidence in this vote 0..1. */
29
+ confidence: number;
30
+ /** Plain-English why. */
31
+ reason: string;
32
+ }
33
+ export interface CouncilVerdict {
34
+ votes: VoiceVote[];
35
+ hedgeVotes: number;
36
+ passVotes: number;
37
+ abstainVotes: number;
38
+ /** Final verdict: HEDGE if hedge >= majorityThreshold (default 3). */
39
+ verdict: "HEDGE" | "PASS" | "TIE";
40
+ /** Plain-English headline. */
41
+ headline: string;
42
+ }
43
+ export interface CouncilOptions {
44
+ /** Majority threshold (default 3 of 5). */
45
+ majority?: number;
46
+ /** Skip specific voices. */
47
+ skipVoices?: VoiceId[];
48
+ }
49
+ export declare function runCouncil(repoRoot: string, claim: string, opts?: CouncilOptions): CouncilVerdict;
50
+ //# sourceMappingURL=multi_voice_council.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multi_voice_council.d.ts","sourceRoot":"","sources":["../../src/precog/multi_voice_council.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAOH,MAAM,MAAM,OAAO,GAAG,mBAAmB,GAAG,sBAAsB,GAAG,oBAAoB,GAAG,oBAAoB,GAAG,sBAAsB,CAAC;AAE1I,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,OAAO,CAAC;IACf,0DAA0D;IAC1D,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;IACnC,oCAAoC;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,yBAAyB;IACzB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,sEAAsE;IACtE,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC;IAClC,8BAA8B;IAC9B,QAAQ,EAAE,MAAM,CAAC;CAClB;AAiDD,MAAM,WAAW,cAAc;IAC7B,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,4BAA4B;IAC5B,UAAU,CAAC,EAAE,OAAO,EAAE,CAAC;CACxB;AAED,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,cAAc,GAAG,cAAc,CAsBjG"}
@@ -0,0 +1,105 @@
1
+ /**
2
+ * v1.71.0 -- PRECOG +C1: MULTI-VOICE COUNCIL.
3
+ *
4
+ * Push PRECOG catch rate from 92.9% toward 98%+. Instead of a single
5
+ * verifier-pass, run the claim through FIVE distinct voices, each
6
+ * with a different cognitive bias:
7
+ *
8
+ * V1 PACKAGE-PEDANT extra strict on package names + versions
9
+ * V2 TEMPORAL-PARANOID extra strict on time claims
10
+ * V3 HUMILITY-ZEALOT extra strict on absolute speech
11
+ * V4 CITATION-NIGGLE requires every entity to have a citation
12
+ * V5 NOVELTY-SUSPICION flags shapes not seen in repo history
13
+ *
14
+ * Majority vote -> hedge if 3+/5 voices say "suspect". Breaks the
15
+ * "PRECOG missed because one regex didn't fire" failure mode by
16
+ * needing redundant agreement.
17
+ *
18
+ * The wild bit: voices use DIFFERENT THRESHOLDS for the same
19
+ * underlying checker. V1 might flag "X@1.0.0" at 0.4 confidence
20
+ * while the default PRECOG only flags at 0.6. The council compares
21
+ * how many voices agree at THEIR individual threshold.
22
+ */
23
+ import { verifyPackages } from "./package_verifier.js";
24
+ import { verifyFacts } from "./sha_version_verifier.js";
25
+ import { verifyTemporal } from "./temporal_verifier.js";
26
+ import { priorFor } from "./bayesian_priors.js";
27
+ const ABSOLUTES = ["always", "never", "guaranteed", "100%", "absolutely", "perfect", "flawless", "every", "all", "none"];
28
+ function v1_packagePedant(repoRoot, claim) {
29
+ const r = verifyPackages(repoRoot, claim);
30
+ // Pedant lowers threshold: even single suspect package = hedge.
31
+ if (r.suspects.length === 0)
32
+ return { voice: "V1-package-pedant", vote: "abstain", confidence: 1, reason: "no package refs found" };
33
+ return { voice: "V1-package-pedant", vote: "hedge", confidence: 0.95, reason: `pedant: ${r.suspects.length} suspect package(s)` };
34
+ }
35
+ function v2_temporalParanoid(repoRoot, claim) {
36
+ const r = verifyTemporal(repoRoot, claim);
37
+ if (r.refs.length === 0)
38
+ return { voice: "V2-temporal-paranoid", vote: "abstain", confidence: 1, reason: "no temporal claims" };
39
+ // Paranoid: ANY un-corroborated temporal claim hedges, even if just 1 of N.
40
+ if (r.suspects.length >= 1)
41
+ return { voice: "V2-temporal-paranoid", vote: "hedge", confidence: 0.9, reason: `paranoid: ${r.suspects.length} un-corroborated temporal claim(s)` };
42
+ return { voice: "V2-temporal-paranoid", vote: "pass", confidence: 0.85, reason: "all temporal claims corroborated by git log" };
43
+ }
44
+ function v3_humilityZealot(_repoRoot, claim) {
45
+ let absCount = 0;
46
+ const lower = claim.toLowerCase();
47
+ for (const a of ABSOLUTES) {
48
+ const re = new RegExp(`\\b${a}\\b`, "g");
49
+ const m = lower.match(re);
50
+ if (m)
51
+ absCount += m.length;
52
+ }
53
+ if (absCount >= 2)
54
+ return { voice: "V3-humility-zealot", vote: "hedge", confidence: 0.9, reason: `zealot: ${absCount} absolute terms` };
55
+ if (absCount === 1)
56
+ return { voice: "V3-humility-zealot", vote: "hedge", confidence: 0.6, reason: `zealot: 1 absolute term` };
57
+ return { voice: "V3-humility-zealot", vote: "pass", confidence: 0.8, reason: "no absolutes" };
58
+ }
59
+ function v4_citationNiggle(repoRoot, claim) {
60
+ // Use the fact-verifier as the citation proxy: any unverifiable
61
+ // entity = niggle hedges.
62
+ const r = verifyFacts(repoRoot, claim);
63
+ if (r.refs.length === 0)
64
+ return { voice: "V4-citation-niggle", vote: "abstain", confidence: 1, reason: "no fact refs to cite" };
65
+ if (r.suspects.length > 0)
66
+ return { voice: "V4-citation-niggle", vote: "hedge", confidence: 0.85, reason: `niggle: ${r.suspects.length} uncited fact(s)` };
67
+ return { voice: "V4-citation-niggle", vote: "pass", confidence: 0.85, reason: "all facts cited" };
68
+ }
69
+ function v5_noveltySuspicion(repoRoot, claim) {
70
+ const p = priorFor(repoRoot, claim);
71
+ // Novelty: claims whose simhash matches PAST FAILURES are suspect.
72
+ if (p.posterior >= 0.3)
73
+ return { voice: "V5-novelty-suspicion", vote: "hedge", confidence: 0.8, reason: `novelty: posterior ${p.posterior.toFixed(2)} matches past failures` };
74
+ if (p.topNeighbors.length === 0)
75
+ return { voice: "V5-novelty-suspicion", vote: "abstain", confidence: 0.6, reason: "no failure history" };
76
+ return { voice: "V5-novelty-suspicion", vote: "pass", confidence: 0.7, reason: "no near-neighbor failures" };
77
+ }
78
+ export function runCouncil(repoRoot, claim, opts) {
79
+ const majority = opts?.majority ?? 3;
80
+ const skip = new Set(opts?.skipVoices ?? []);
81
+ const votes = [];
82
+ if (!skip.has("V1-package-pedant"))
83
+ votes.push(v1_packagePedant(repoRoot, claim));
84
+ if (!skip.has("V2-temporal-paranoid"))
85
+ votes.push(v2_temporalParanoid(repoRoot, claim));
86
+ if (!skip.has("V3-humility-zealot"))
87
+ votes.push(v3_humilityZealot(repoRoot, claim));
88
+ if (!skip.has("V4-citation-niggle"))
89
+ votes.push(v4_citationNiggle(repoRoot, claim));
90
+ if (!skip.has("V5-novelty-suspicion"))
91
+ votes.push(v5_noveltySuspicion(repoRoot, claim));
92
+ const hedge = votes.filter((v) => v.vote === "hedge").length;
93
+ const pass = votes.filter((v) => v.vote === "pass").length;
94
+ const abst = votes.filter((v) => v.vote === "abstain").length;
95
+ let verdict;
96
+ if (hedge >= majority)
97
+ verdict = "HEDGE";
98
+ else if (pass >= majority)
99
+ verdict = "PASS";
100
+ else
101
+ verdict = "TIE";
102
+ const headline = `Council: ${hedge} hedge / ${pass} pass / ${abst} abstain -> ${verdict}.`;
103
+ return { votes, hedgeVotes: hedge, passVotes: pass, abstainVotes: abst, verdict, headline };
104
+ }
105
+ //# sourceMappingURL=multi_voice_council.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"multi_voice_council.js","sourceRoot":"","sources":["../../src/precog/multi_voice_council.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,cAAc,EA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,CAAC,MAAM,CAAC;IAE9D,IAAI,OAAkC,CAAC;IACvC,IAAI,KAAK,IAAI,QAAQ;QAAE,OAAO,GAAG,OAAO,CAAC;SACpC,IAAI,IAAI,IAAI,QAAQ;QAAE,OAAO,GAAG,MAAM,CAAC;;QACvC,OAAO,GAAG,KAAK,CAAC;IAErB,MAAM,QAAQ,GAAG,YAAY,KAAK,YAAY,IAAI,WAAW,IAAI,eAAe,OAAO,GAAG,CAAC;IAE3F,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;AAC9F,CAAC"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * v1.71.0 -- SENTINEL S4: HMAC AUDIT LEDGER.
3
+ *
4
+ * Every detected dangerous command is logged with HMAC signature so
5
+ * the audit trail is tamper-evident. The "black box" of AI actions:
6
+ * if an AI ever does something irreversibly bad, the ledger shows
7
+ * exactly which command + when + risk score.
8
+ *
9
+ * Storage: .mneme/sentinel/audit.jsonl
10
+ * Secret: .mneme/sentinel/secret (random 32 bytes, per-repo)
11
+ */
12
+ import type { RecommendedAction, RiskScoreReport } from "./risk_scorer.js";
13
+ export interface AuditEntry {
14
+ id: string;
15
+ ts: string;
16
+ command: string;
17
+ score: number;
18
+ action: RecommendedAction;
19
+ /** Class labels that fired. */
20
+ classes: string[];
21
+ /** Vendor (AI agent) that proposed the command. */
22
+ vendor: string;
23
+ /** Whether the command actually ran (caller flips this AFTER decision). */
24
+ executed: boolean;
25
+ /** HMAC over canonical payload. */
26
+ hmac: string;
27
+ }
28
+ export interface AuditOptions {
29
+ vendor?: string;
30
+ executed?: boolean;
31
+ }
32
+ export declare function appendAudit(repoRoot: string, command: string, report: RiskScoreReport, opts?: AuditOptions): AuditEntry;
33
+ export type VerifyVerdict = "VALID" | "INVALID_HMAC" | "NOT_FOUND";
34
+ export declare function verifyAuditEntry(repoRoot: string, entry: AuditEntry): VerifyVerdict;
35
+ export declare function readAuditLog(repoRoot: string): AuditEntry[];
36
+ export interface AuditSummary {
37
+ total: number;
38
+ byAction: Record<RecommendedAction, number>;
39
+ byClass: Record<string, number>;
40
+ byVendor: Record<string, number>;
41
+ tamperedCount: number;
42
+ lastEntry: AuditEntry | null;
43
+ headline: string;
44
+ }
45
+ export declare function summarizeAudit(repoRoot: string): AuditSummary;
46
+ //# sourceMappingURL=audit_ledger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audit_ledger.d.ts","sourceRoot":"","sources":["../../src/sentinel/audit_ledger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAMH,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAM3E,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,iBAAiB,CAAC;IAC1B,+BAA+B;IAC/B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,mDAAmD;IACnD,MAAM,EAAE,MAAM,CAAC;IACf,2EAA2E;IAC3E,QAAQ,EAAE,OAAO,CAAC;IAClB,mCAAmC;IACnC,IAAI,EAAE,MAAM,CAAC;CACd;AAwBD,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,EAAE,IAAI,CAAC,EAAE,YAAY,GAAG,UAAU,CAsBvH;AAED,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,cAAc,GAAG,WAAW,CAAC;AAEnE,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,aAAa,CAKnF;AAED,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,UAAU,EAAE,CAW3D;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC,iBAAiB,EAAE,MAAM,CAAC,CAAC;IAC5C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,UAAU,GAAG,IAAI,CAAC;IAC7B,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,YAAY,CAmB7D"}
@@ -0,0 +1,115 @@
1
+ /**
2
+ * v1.71.0 -- SENTINEL S4: HMAC AUDIT LEDGER.
3
+ *
4
+ * Every detected dangerous command is logged with HMAC signature so
5
+ * the audit trail is tamper-evident. The "black box" of AI actions:
6
+ * if an AI ever does something irreversibly bad, the ledger shows
7
+ * exactly which command + when + risk score.
8
+ *
9
+ * Storage: .mneme/sentinel/audit.jsonl
10
+ * Secret: .mneme/sentinel/secret (random 32 bytes, per-repo)
11
+ */
12
+ import { existsSync, readFileSync, writeFileSync, mkdirSync, appendFileSync } from "node:fs";
13
+ import { createHash, createHmac, randomBytes } from "node:crypto";
14
+ import { join } from "node:path";
15
+ const SENTINEL_DIR = ".mneme/sentinel";
16
+ const AUDIT_LOG = ".mneme/sentinel/audit.jsonl";
17
+ const SECRET_FILE = ".mneme/sentinel/secret";
18
+ function ensureSecret(repoRoot) {
19
+ const p = join(repoRoot, SECRET_FILE);
20
+ if (existsSync(p))
21
+ return readFileSync(p, "utf8").trim();
22
+ const dir = join(repoRoot, SENTINEL_DIR);
23
+ if (!existsSync(dir))
24
+ mkdirSync(dir, { recursive: true });
25
+ const s = randomBytes(32).toString("hex");
26
+ try {
27
+ writeFileSync(p, s, "utf8");
28
+ }
29
+ catch { /* */ }
30
+ return s;
31
+ }
32
+ function canonical(payload) {
33
+ return JSON.stringify({
34
+ ts: payload.ts,
35
+ command: payload.command,
36
+ score: payload.score,
37
+ action: payload.action,
38
+ classes: [...payload.classes].sort(),
39
+ vendor: payload.vendor,
40
+ executed: payload.executed,
41
+ });
42
+ }
43
+ export function appendAudit(repoRoot, command, report, opts) {
44
+ const secret = ensureSecret(repoRoot);
45
+ const ts = new Date().toISOString();
46
+ const payload = {
47
+ ts,
48
+ command: command.slice(0, 500),
49
+ score: report.score,
50
+ action: report.recommendedAction,
51
+ classes: report.detection.classes,
52
+ vendor: opts?.vendor ?? "unknown",
53
+ executed: opts?.executed ?? false,
54
+ };
55
+ const canon = canonical(payload);
56
+ const hmac = createHmac("sha256", secret).update(canon).digest("hex");
57
+ const id = createHash("sha256").update(canon).digest("hex").slice(0, 16);
58
+ const entry = { ...payload, id, hmac };
59
+ try {
60
+ const dir = join(repoRoot, SENTINEL_DIR);
61
+ if (!existsSync(dir))
62
+ mkdirSync(dir, { recursive: true });
63
+ appendFileSync(join(repoRoot, AUDIT_LOG), JSON.stringify(entry) + "\n", "utf8");
64
+ }
65
+ catch { /* */ }
66
+ return entry;
67
+ }
68
+ export function verifyAuditEntry(repoRoot, entry) {
69
+ const secret = ensureSecret(repoRoot);
70
+ const expected = createHmac("sha256", secret).update(canonical(entry)).digest("hex");
71
+ if (expected !== entry.hmac)
72
+ return "INVALID_HMAC";
73
+ return "VALID";
74
+ }
75
+ export function readAuditLog(repoRoot) {
76
+ const p = join(repoRoot, AUDIT_LOG);
77
+ if (!existsSync(p))
78
+ return [];
79
+ const out = [];
80
+ try {
81
+ for (const line of readFileSync(p, "utf8").split("\n")) {
82
+ if (!line.trim())
83
+ continue;
84
+ try {
85
+ out.push(JSON.parse(line));
86
+ }
87
+ catch { /* */ }
88
+ }
89
+ }
90
+ catch { /* */ }
91
+ return out;
92
+ }
93
+ export function summarizeAudit(repoRoot) {
94
+ const entries = readAuditLog(repoRoot);
95
+ const byAction = { ALLOW: 0, AUDIT: 0, WARN: 0, BLOCK: 0 };
96
+ const byClass = {};
97
+ const byVendor = {};
98
+ let tampered = 0;
99
+ for (const e of entries) {
100
+ byAction[e.action] = (byAction[e.action] ?? 0) + 1;
101
+ for (const c of e.classes)
102
+ byClass[c] = (byClass[c] ?? 0) + 1;
103
+ byVendor[e.vendor] = (byVendor[e.vendor] ?? 0) + 1;
104
+ if (verifyAuditEntry(repoRoot, e) === "INVALID_HMAC")
105
+ tampered += 1;
106
+ }
107
+ return {
108
+ total: entries.length,
109
+ byAction, byClass, byVendor,
110
+ tamperedCount: tampered,
111
+ lastEntry: entries[entries.length - 1] ?? null,
112
+ headline: `${entries.length} audit entry/ies (${tampered} tampered). BLOCK=${byAction.BLOCK}, WARN=${byAction.WARN}, AUDIT=${byAction.AUDIT}.`,
113
+ };
114
+ }
115
+ //# sourceMappingURL=audit_ledger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"audit_ledger.js","sourceRoot":"","sources":["../../src/sentinel/audit_ledger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC7F,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAIjC,MAAM,YAAY,GAAG,iBAAiB,CAAC;AACvC,MAAM,SAAS,GAAG,6BAA6B,CAAC;AAChD,MAAM,WAAW,GAAG,wBAAwB,CAAC;AAkB7C,SAAS,YAAY,CAAC,QAAgB;IACpC,MAAM,CAAC,GAAG,IAAI,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;IACtC,IAAI,UAAU,CAAC,CAAC,CAAC;QAAE,OAAO,YAAY,CAAC,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AAQ,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QACnD,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO;YAAE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QAC9D,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;QACnD,IAAI,gBAAgB,CAAC,QAAQ,EAAE,CAAC,CAAC,KAAK,cAAc;YAAE,QAAQ,IAAI,CAAC,CAAC;IACtE,CAAC;IACD,OAAO;QACL,KAAK,EAAE,OAAO,CAAC,MAAM;QACrB,QAAQ,EAAE,OAAO,EAAE,QAAQ;QAC3B,aAAa,EAAE,QAAQ;QACvB,SAAS,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,IAAI;QAC9C,QAAQ,EAAE,GAAG,OAAO,CAAC,MAAM,qBAAqB,QAAQ,qBAAqB,QAAQ,CAAC,KAAK,UAAU,QAAQ,CAAC,IAAI,WAAW,QAAQ,CAAC,KAAK,GAAG;KAC/I,CAAC;AACJ,CAAC"}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * v1.71.0 -- SENTINEL S1: DANGEROUS COMMAND DETECTOR.
3
+ *
4
+ * PRECOG was about CLAIMS (hallucinated facts). SENTINEL is about
5
+ * ACTIONS (dangerous commands). The same intercept pattern, applied
6
+ * to the MCP boundary: every shell command the AI proposes passes
7
+ * through SENTINEL before execution.
8
+ *
9
+ * Catalog of 30+ dangerous patterns, organized into 8 risk classes:
10
+ * - mass-delete rm -rf /, find -delete on / | $HOME
11
+ * - pipe-to-shell curl URL | sh, wget URL | bash
12
+ * - fork-bomb :(){:|:&};:
13
+ * - disk-wipe dd if=... of=/dev/sda
14
+ * - permission-bomb chmod 777 /, chown nobody /
15
+ * - exfiltration tar ... | nc, scp to unknown
16
+ * - net-scan nmap, masscan, nikto, sqlmap
17
+ * - credential-leak cat .env | curl, .ssh access
18
+ *
19
+ * Each detection carries a RISK LEVEL (low/medium/high/critical) so
20
+ * the orchestrator can decide block vs warn vs allow-with-audit.
21
+ */
22
+ export type RiskClass = "mass-delete" | "pipe-to-shell" | "fork-bomb" | "disk-wipe" | "permission-bomb" | "exfiltration" | "net-scan" | "credential-leak" | "privilege-escalation" | "process-kill" | "history-tamper";
23
+ export type RiskLevel = "low" | "medium" | "high" | "critical";
24
+ export interface DangerSignature {
25
+ id: string;
26
+ /** Regex on the full command. */
27
+ pattern: RegExp;
28
+ risk: RiskLevel;
29
+ class: RiskClass;
30
+ /** Plain-English why this is dangerous. */
31
+ rationale: string;
32
+ /** Optional safe-context override -- if this regex ALSO matches, the
33
+ * command is LIKELY safe even though the main pattern fired. */
34
+ safeContext?: RegExp;
35
+ }
36
+ export declare const DANGER_CATALOG: DangerSignature[];
37
+ export interface DetectionMatch {
38
+ signature: DangerSignature;
39
+ /** What part of the command actually matched. */
40
+ matchedText: string;
41
+ /** Offset in the input. */
42
+ offset: number;
43
+ }
44
+ export interface CommandDetectionReport {
45
+ command: string;
46
+ matches: DetectionMatch[];
47
+ /** Highest risk-level among matches. */
48
+ highestRisk: RiskLevel | null;
49
+ /** All matched classes. */
50
+ classes: RiskClass[];
51
+ /** Plain-English headline. */
52
+ headline: string;
53
+ /** ms. */
54
+ ms: number;
55
+ }
56
+ export declare function detectDangerous(command: string): CommandDetectionReport;
57
+ /** Return only the catalog entries for a class, for inspection. */
58
+ export declare function listByClass(cls: RiskClass): DangerSignature[];
59
+ //# sourceMappingURL=command_detector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command_detector.d.ts","sourceRoot":"","sources":["../../src/sentinel/command_detector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,MAAM,MAAM,SA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