mneme-ai 2.144.0 → 2.146.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.
@@ -0,0 +1,13 @@
1
+ /**
2
+ * `mneme gateway` (v2.146.0) — THE INTENT GATEWAY. Type free natural language
3
+ * (any language, EN/Thai); the Gateway picks the right Mneme command, compiles a
4
+ * runnable invocation, or asks to clarify when it's unsure. Users never memorize
5
+ * a command.
6
+ *
7
+ * mneme gateway "stop all the bots, something feels off"
8
+ * mneme gateway "ดูแลเรื่องงบ 5 หมื่น ห้ามโพสต์ด่าใคร ปล่อยบอทเลย"
9
+ * mneme gateway bench # the signed before→after accuracy benchmark
10
+ */
11
+ import type { Command } from "commander";
12
+ export declare function registerGatewayCommands(program: Command): void;
13
+ //# sourceMappingURL=gateway.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gateway.d.ts","sourceRoot":"","sources":["../../src/commands/gateway.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAKzC,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA4C9D"}
@@ -0,0 +1,89 @@
1
+ /**
2
+ * `mneme gateway` (v2.146.0) — THE INTENT GATEWAY. Type free natural language
3
+ * (any language, EN/Thai); the Gateway picks the right Mneme command, compiles a
4
+ * runnable invocation, or asks to clarify when it's unsure. Users never memorize
5
+ * a command.
6
+ *
7
+ * mneme gateway "stop all the bots, something feels off"
8
+ * mneme gateway "ดูแลเรื่องงบ 5 หมื่น ห้ามโพสต์ด่าใคร ปล่อยบอทเลย"
9
+ * mneme gateway bench # the signed before→after accuracy benchmark
10
+ */
11
+ import { intentGateway as gw, notary } from "@mneme-ai/core";
12
+ function out(s) { process.stdout.write(s + "\n"); }
13
+ export function registerGatewayCommands(program) {
14
+ const g = program
15
+ .command("gateway")
16
+ .alias("interpret")
17
+ .argument("[text...]", "free natural language — any language")
18
+ .description("🧭 INTENT GATEWAY — type free natural language (any language, EN/Thai); Mneme picks the RIGHT command for the best result, compiles a runnable invocation, or asks to clarify when unsure (never a confident misfire). You never memorize a command. Curated bilingual concept-map + IDF catalog fallback + abstention; measured (see `mneme gateway bench`).")
19
+ .option("--json", "JSON output (signed)")
20
+ .action((text, opts) => {
21
+ const q = Array.isArray(text) ? text.join(" ") : String(text ?? "");
22
+ if (!q.trim()) {
23
+ out("usage: mneme gateway \"<what you want, in your own words>\"");
24
+ process.exitCode = 2;
25
+ return;
26
+ }
27
+ const r = gw.route(q);
28
+ let receipt = null;
29
+ try {
30
+ receipt = notary.issueReceipt(process.cwd(), { kind: "claim-verdict", subject: `gateway:${r.verdict}`, payload: { verdict: r.verdict, command: r.command, confidence: r.confidence }, includePayload: true });
31
+ }
32
+ catch { /* */ }
33
+ if (opts.json) {
34
+ out(JSON.stringify({ ...r, signed: receipt }, null, 2));
35
+ process.exitCode = r.verdict === "ROUTED" ? 0 : 2;
36
+ return;
37
+ }
38
+ if (r.verdict === "ROUTED") {
39
+ out(`🟢 ${r.command} (confidence ${(r.confidence * 100).toFixed(0)}%)`);
40
+ if (r.invocation && r.invocation !== r.command)
41
+ out(` → run: ${r.invocation}`);
42
+ const e = r.entities;
43
+ const ent = [];
44
+ if (e.budget)
45
+ ent.push(`budget=${e.budget}`);
46
+ if (e.forbidden?.length)
47
+ ent.push(`forbidden=${e.forbidden.join(",")}`);
48
+ if (e.scope?.length)
49
+ ent.push(`scope=${e.scope.join(",")}`);
50
+ if (ent.length)
51
+ out(` detected: ${ent.join(" · ")}`);
52
+ }
53
+ else if (r.verdict === "CLARIFY") {
54
+ out(`❔ Not sure — did you mean one of these?`);
55
+ for (const c of r.candidates)
56
+ out(` • ${c.command} (${(c.score).toFixed(2)})`);
57
+ }
58
+ else {
59
+ out(`❔ I couldn't map that to a Mneme command — try rephrasing, or 'mneme gateway bench' / 'mneme boot' to see what's possible.`);
60
+ }
61
+ process.exitCode = r.verdict === "ROUTED" ? 0 : 2;
62
+ });
63
+ g.command("bench")
64
+ .description("the signed before→after accuracy benchmark (new Gateway vs the old keyword router) over a labeled EN+Thai corpus.")
65
+ .option("--json", "JSON output")
66
+ .action((opts) => {
67
+ const b = gw.benchmark();
68
+ let receipt = null;
69
+ try {
70
+ receipt = notary.issueReceipt(process.cwd(), { kind: "reasoning-trace", subject: `gateway.bench:${(b.newAcc * 100).toFixed(0)}pct`, payload: { newAcc: b.newAcc, oldAcc: b.oldAcc, n: b.n }, includePayload: true });
71
+ }
72
+ catch { /* */ }
73
+ if (opts.json) {
74
+ out(JSON.stringify({ ...b, signed: receipt }, null, 2));
75
+ return;
76
+ }
77
+ out(`🧭 INTENT GATEWAY — accuracy on ${b.n} labeled EN+Thai queries:`);
78
+ out(` NEW gateway: ${b.newTop1}/${b.n} top-1 = ${(b.newAcc * 100).toFixed(0)}%`);
79
+ out(` OLD keyword: ${b.oldTop1}/${b.n} top-1 = ${(b.oldAcc * 100).toFixed(0)}%`);
80
+ out(` abstained (asked to clarify): ${b.abstained}`);
81
+ if (b.newMisses.length) {
82
+ out(" remaining misses:");
83
+ for (const m of b.newMisses)
84
+ out(` ${m}`);
85
+ }
86
+ out(` ${receipt ? "✓ signed · " : ""}measured + re-runnable; 100% NL routing is impossible — the target is high top-1 + abstain on the rest.`);
87
+ });
88
+ }
89
+ //# sourceMappingURL=gateway.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gateway.js","sourceRoot":"","sources":["../../src/commands/gateway.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,aAAa,IAAI,EAAE,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE7D,SAAS,GAAG,CAAC,CAAS,IAAU,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;AAEjE,MAAM,UAAU,uBAAuB,CAAC,OAAgB;IACtD,MAAM,CAAC,G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,CAAC;YAAC,OAAO;QAAC,CAAC;QACnF,GAAG,CAAC,mCAAmC,CAAC,CAAC,CAAC,2BAA2B,CAAC,CAAC;QACvE,GAAG,CAAC,mBAAmB,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QACnF,GAAG,CAAC,mBAAmB,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;QACnF,GAAG,CAAC,oCAAoC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC;QACvD,IAAI,CAAC,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;YAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;YAAC,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,SAAS;gBAAE,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QAAC,CAAC;QACvG,GAAG,CAAC,MAAM,OAAO,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,yGAAyG,CAAC,CAAC;IACnJ,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * `mneme govern` (v2.145.0) — THE AGENT GOVERNOR. The orchestrator-agnostic
3
+ * governance kernel: ratify a Charter once, then run a fleet's action queue as a
4
+ * continuous AUTO-OPERATION BATCH — autonomous + audited actions flow without
5
+ * per-step human input; only irreversible / out-of-envelope / forbidden actions
6
+ * escalate; a circuit-breaker pauses the fleet on mission drift. Signed.
7
+ *
8
+ * mneme govern charter-init > charter.json
9
+ * mneme govern decide --charter charter.json --action '{"id":"a","kind":"edit",...}'
10
+ * mneme govern batch --charter charter.json --actions queue.jsonl
11
+ * mneme govern amend --charter charter.json --clean 20 --regretted 0
12
+ *
13
+ * batch/decide exit 2 if anything ESCALATEs/BLOCKs (CI-gate). HONEST: the Governor
14
+ * DECIDES + SEQUENCES + ESCALATES + COMPENSATES; the orchestrator executes per
15
+ * the verdicts (Mneme is the kernel, not the executor).
16
+ */
17
+ import type { Command } from "commander";
18
+ export declare function registerGovernCommands(program: Command): void;
19
+ //# sourceMappingURL=govern.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"govern.d.ts","sourceRoot":"","sources":["../../src/commands/govern.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAUzC,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAoE7D"}
@@ -0,0 +1,128 @@
1
+ /**
2
+ * `mneme govern` (v2.145.0) — THE AGENT GOVERNOR. The orchestrator-agnostic
3
+ * governance kernel: ratify a Charter once, then run a fleet's action queue as a
4
+ * continuous AUTO-OPERATION BATCH — autonomous + audited actions flow without
5
+ * per-step human input; only irreversible / out-of-envelope / forbidden actions
6
+ * escalate; a circuit-breaker pauses the fleet on mission drift. Signed.
7
+ *
8
+ * mneme govern charter-init > charter.json
9
+ * mneme govern decide --charter charter.json --action '{"id":"a","kind":"edit",...}'
10
+ * mneme govern batch --charter charter.json --actions queue.jsonl
11
+ * mneme govern amend --charter charter.json --clean 20 --regretted 0
12
+ *
13
+ * batch/decide exit 2 if anything ESCALATEs/BLOCKs (CI-gate). HONEST: the Governor
14
+ * DECIDES + SEQUENCES + ESCALATES + COMPENSATES; the orchestrator executes per
15
+ * the verdicts (Mneme is the kernel, not the executor).
16
+ */
17
+ import { existsSync, readFileSync } from "node:fs";
18
+ import { agentGovernor as gov, notary } from "@mneme-ai/core";
19
+ function out(s) { process.stdout.write(s + "\n"); }
20
+ function readCharter(file) {
21
+ try {
22
+ if (file && existsSync(file))
23
+ return JSON.parse(readFileSync(file, "utf8"));
24
+ }
25
+ catch { /* */ }
26
+ return { mission: "(none)", scopeGlobs: [], riskEnvelope: "read", budget: { maxActions: 100 }, forbidden: [] };
27
+ }
28
+ export function registerGovernCommands(program) {
29
+ const g = program
30
+ .command("govern")
31
+ .description("🏛 THE AGENT GOVERNOR — the orchestrator-agnostic governance kernel that sits UNDER any agent platform (Astra / Claude Code / Tycoon / AutoGen) and makes a fleet of autonomous agents provably safe + accountable, automatically. Ratify a Charter once; then run the action queue as a continuous AUTO-OPERATION BATCH (autonomous + audited flow untouched; only irreversible / out-of-envelope / forbidden escalate; a circuit-breaker pauses the fleet on mission drift). Composes CERBERUS · CRUCIBLE · TELOS · REGRET · ELLEIPSIS into one signed verdict. HONEST: the Governor decides + sequences + escalates + compensates — the orchestrator executes per the verdicts.");
32
+ g.command("charter-init")
33
+ .description("print a Charter template (mission · scope · risk envelope · budget · forbidden).")
34
+ .action(() => out(JSON.stringify({ mission: "describe the fleet's mission", scopeGlobs: ["src/**"], riskEnvelope: "write", budget: { maxActions: 100, maxTokens: 2000000 }, forbidden: ["delete production", "post publicly", "rotate credentials"] }, null, 2)));
35
+ g.command("decide")
36
+ .description("govern ONE action → ALLOW_AUTONOMOUS / ALLOW_WITH_AUDIT / ESCALATE_HUMAN / BLOCK (exit 2 if not autonomous).")
37
+ .requiredOption("--charter <file>", "charter JSON")
38
+ .requiredOption("--action <json>", "the action object (or '-' for stdin)")
39
+ .option("--json", "JSON output (signed)")
40
+ .action((opts) => {
41
+ const charter = readCharter(opts.charter);
42
+ let action;
43
+ try {
44
+ action = JSON.parse(opts.action === "-" ? readFileSync(0, "utf8") : opts.action);
45
+ }
46
+ catch {
47
+ out("✗ bad --action JSON");
48
+ process.exitCode = 2;
49
+ return;
50
+ }
51
+ const d = gov.governAction(charter, action);
52
+ let receipt = null;
53
+ try {
54
+ receipt = notary.issueReceipt(process.cwd(), { kind: "claim-verdict", subject: `govern:${d.verdict}`, payload: { id: d.id, verdict: d.verdict }, includePayload: true });
55
+ }
56
+ catch { /* */ }
57
+ if (opts.json) {
58
+ out(JSON.stringify({ ...d, signed: receipt }, null, 2));
59
+ process.exitCode = d.autonomous ? 0 : 2;
60
+ return;
61
+ }
62
+ const icon = d.verdict === "ALLOW_AUTONOMOUS" ? "🟢" : d.verdict === "ALLOW_WITH_AUDIT" ? "🟡" : d.verdict === "ESCALATE_HUMAN" ? "✋" : "🛑";
63
+ out(`${icon} ${d.verdict} — ${d.id}`);
64
+ for (const r of d.reasons)
65
+ out(` • ${r}`);
66
+ if (receipt)
67
+ out(" ✓ signed");
68
+ process.exitCode = d.autonomous ? 0 : 2;
69
+ });
70
+ g.command("batch")
71
+ .description("run a fleet's action queue as a continuous AUTO-OPERATION BATCH; reports autonomous / audited / escalated / blocked + circuit-breaker. Exit 2 if anything escalated/blocked or the breaker tripped.")
72
+ .requiredOption("--charter <file>", "charter JSON")
73
+ .requiredOption("--actions <file>", "JSONL of actions ({id,kind,summary,files,reversible,inverse,signals,tokensEst}); '-' = stdin")
74
+ .option("--regret-rate <n>", "current fleet regret rate 0..1 (feeds the circuit-breaker)", (v) => parseFloat(v))
75
+ .option("--json", "JSON output (signed)")
76
+ .action((opts) => {
77
+ const charter = readCharter(opts.charter);
78
+ const raw = opts.actions === "-" ? readFileSync(0, "utf8") : (existsSync(opts.actions) ? readFileSync(opts.actions, "utf8") : "");
79
+ const actions = raw.split("\n").filter((l) => l.trim()).map((l, i) => { try {
80
+ const j = JSON.parse(l);
81
+ return { id: j.id ?? `a${i}`, kind: j.kind ?? "action", summary: j.summary ?? "", files: j.files, reversible: j.reversible, inverse: j.inverse, tokensEst: j.tokensEst, signals: j.signals ?? {} };
82
+ }
83
+ catch {
84
+ return null;
85
+ } }).filter(Boolean);
86
+ const rep = gov.governBatch(charter, actions, opts.regretRate !== undefined ? { regretRate: opts.regretRate } : undefined);
87
+ let receipt = null;
88
+ try {
89
+ receipt = notary.issueReceipt(process.cwd(), { kind: "claim-verdict", subject: `govern.batch:${rep.executed.length}/${rep.total}`, payload: { total: rep.total, autonomous: rep.autonomous, audited: rep.audited, escalated: rep.escalated.length, blocked: rep.blocked.length, breakerTripped: rep.breakerTripped }, includePayload: true });
90
+ }
91
+ catch { /* */ }
92
+ if (opts.json) {
93
+ out(JSON.stringify({ ...rep, signed: receipt }, null, 2));
94
+ process.exitCode = (rep.escalated.length || rep.blocked.length || rep.breakerTripped) ? 2 : 0;
95
+ return;
96
+ }
97
+ out(`🏛 AGENT GOVERNOR — batch of ${rep.total}`);
98
+ out(` 🟢 ${rep.autonomous} autonomous · 🟡 ${rep.audited} audited · ✋ ${rep.escalated.length} escalated · 🛑 ${rep.blocked.length} blocked`);
99
+ out(` budget used: ${rep.budgetUsed.actions} actions / ${rep.budgetUsed.tokens} tokens`);
100
+ if (rep.breakerTripped)
101
+ out(` ⚡ CIRCUIT-BREAKER TRIPPED @ ${rep.stoppedAt}: ${rep.breakerReason}`);
102
+ for (const e of rep.escalated.slice(0, 10))
103
+ out(` ✋ ${e.id}: ${e.reasons.join("; ")}`);
104
+ for (const b of rep.blocked.slice(0, 10))
105
+ out(` 🛑 ${b.id}: ${b.reasons.join("; ")}`);
106
+ out(` ${receipt ? "✓ signed · " : ""}${rep.note}`);
107
+ process.exitCode = (rep.escalated.length || rep.blocked.length || rep.breakerTripped) ? 2 : 0;
108
+ });
109
+ g.command("amend")
110
+ .description("Living Charter — propose widening/narrowing the autonomy envelope from evidence (clean approvals vs regrets).")
111
+ .requiredOption("--charter <file>", "charter JSON")
112
+ .option("--clean <n>", "count of clean human-approved actions", (v) => parseInt(v, 10), 0)
113
+ .option("--regretted <n>", "count of regretted actions", (v) => parseInt(v, 10), 0)
114
+ .option("--json", "JSON output")
115
+ .action((opts) => {
116
+ const charter = readCharter(opts.charter);
117
+ const a = gov.proposeAmendment(charter, { approvedClean: opts.clean, regretted: opts.regretted });
118
+ if (opts.json) {
119
+ out(JSON.stringify(a, null, 2));
120
+ return;
121
+ }
122
+ const icon = a.direction === "widen" ? "📈" : a.direction === "narrow" ? "📉" : "⏸";
123
+ out(`${icon} envelope ${a.current} → ${a.proposed} (${a.direction})`);
124
+ out(` ${a.reason}`);
125
+ out(` (a proposal — the human ratifies; the envelope never auto-widens to destructive.)`);
126
+ });
127
+ }
128
+ //# sourceMappingURL=govern.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"govern.js","sourceRoot":"","sources":["../../src/commands/govern.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,aAAa,IAAI,GAAG,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE9D,SAAS,GAAG,CAAC,CAAS,IAAU,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;AACjE,SAAS,WAAW,CAAC,IAAa;IAChC,IAAI,CAAC;QAAC,IAAI,IAAI,IAAI,UAAU,CAAC,IAAI,CAAC;YAAE,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;IAAC,CAAC;IAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC;IACpG,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;AACjH,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,OAAgB;IACrD,MAAM,CAAC,GAAG,OAAO;SACd,OAAO,CAAC,QAAQ,CAAC;SACjB,WAAW,CAAC,opBAAopB,CAAC,CAAC;IAErqB,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC;SACtB,WAAW,CAAC,kFAAkF,CAAC;SAC/F,MAAM,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE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AG,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;QACtB,GAAG,CAAC,sFAAsF,CAAC,CAAC;IAC9F,CAAC,CAAC,CAAC;AACP,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAqKA,wBAAsB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAqkNvD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAuKA,wBAAsB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAukNvD"}
package/dist/index.js CHANGED
@@ -97,6 +97,8 @@ import { registerPceCommands } from "./commands/pce.js";
97
97
  import { registerHauntCommands } from "./commands/haunt.js";
98
98
  import { registerCrucibleCommands } from "./commands/crucible.js";
99
99
  import { registerDriftCommands } from "./commands/drift.js";
100
+ import { registerGovernCommands } from "./commands/govern.js";
101
+ import { registerGatewayCommands } from "./commands/gateway.js";
100
102
  import { attachRegretOracle } from "./commands/regret.js";
101
103
  import { registerTrustCommands } from "./commands/trust.js";
102
104
  import { registerNuclearCommands } from "./commands/nuclear-cli.js";
@@ -4747,6 +4749,8 @@ export async function run(argv) {
4747
4749
  registerHauntCommands(program);
4748
4750
  registerCrucibleCommands(program);
4749
4751
  registerDriftCommands(program);
4752
+ registerGovernCommands(program);
4753
+ registerGatewayCommands(program);
4750
4754
  // ─── Trust calibrator (v1.31.0) -- per-subsystem precision/recall/band
4751
4755
  registerTrustCommands(program);
4752
4756
  // ─── Wisdom reactor (v1.33.0) -- five nuclear-physics formulas as Mneme metrics