mneme-ai 2.145.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"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAsKA,wBAAsB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAskNvD"}
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
@@ -98,6 +98,7 @@ import { registerHauntCommands } from "./commands/haunt.js";
98
98
  import { registerCrucibleCommands } from "./commands/crucible.js";
99
99
  import { registerDriftCommands } from "./commands/drift.js";
100
100
  import { registerGovernCommands } from "./commands/govern.js";
101
+ import { registerGatewayCommands } from "./commands/gateway.js";
101
102
  import { attachRegretOracle } from "./commands/regret.js";
102
103
  import { registerTrustCommands } from "./commands/trust.js";
103
104
  import { registerNuclearCommands } from "./commands/nuclear-cli.js";
@@ -4749,6 +4750,7 @@ export async function run(argv) {
4749
4750
  registerCrucibleCommands(program);
4750
4751
  registerDriftCommands(program);
4751
4752
  registerGovernCommands(program);
4753
+ registerGatewayCommands(program);
4752
4754
  // ─── Trust calibrator (v1.31.0) -- per-subsystem precision/recall/band
4753
4755
  registerTrustCommands(program);
4754
4756
  // ─── Wisdom reactor (v1.33.0) -- five nuclear-physics formulas as Mneme metrics