@mneme-ai/core 2.105.0 → 2.107.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,78 @@
1
+ /**
2
+ * v2.106.0 — SHELL AUTOPILOT (the last piece of the Zero-Effort Flow).
3
+ *
4
+ * The user keeps typing on the same black terminal. When a command FAILS,
5
+ * Mneme shows a faint phantom recovery suggestion; one keystroke runs it.
6
+ * No command to memorise — the safety net is just there.
7
+ *
8
+ * THE WILD-BUT-HONEST INNOVATION: the recovery is not a frozen heuristic.
9
+ * When a failure is followed by a command that SUCCEEDS, Mneme learns
10
+ * (failure-signature → recovery) and signs it into the COGNITIVE CORTEX —
11
+ * so the suggestion gets smarter from the user's OWN "dark data" (their
12
+ * real terminal history, never uploaded), and a recovery PROVEN on this
13
+ * machine becomes a signed fact EVERY agent (any vendor) can recall. The
14
+ * autopilot is the surface of the Sovereign Memory Bus. Built-in rules are
15
+ * the cold-start; the cortex is the flywheel.
16
+ *
17
+ * This module is PURE + total (108-error rule): signature + suggestion are
18
+ * deterministic functions, no I/O, never throw. The CLI wires the cortex
19
+ * lookup + the shell hook; the engine here is fully unit-testable.
20
+ */
21
+ /**
22
+ * Normalise a failed command + exit code into a stable SIGNATURE, so
23
+ * "git push origin feature-x" and "git push origin feature-y" share one
24
+ * learned recovery. Variable parts (paths, hashes, quoted args, numbers)
25
+ * are masked. Deterministic.
26
+ */
27
+ export declare function failureSignature(cmd: string, code: number, stderr?: string): string;
28
+ export interface RecoveryRule {
29
+ id: string;
30
+ /** does this rule apply? */
31
+ match: (verb: string, code: number, errClass: string, cmd: string) => boolean;
32
+ /** the suggested recovery command. */
33
+ recovery: (cmd: string) => string;
34
+ reason: string;
35
+ }
36
+ /** Built-in, deterministic cold-start recovery rules for common failures.
37
+ * All advisory — the user runs them by choice. Order = priority. */
38
+ export declare const RECOVERY_RULES: ReadonlyArray<RecoveryRule>;
39
+ export interface Suggestion {
40
+ recovery: string | null;
41
+ source: "learned" | "rule" | "none";
42
+ confidence: "high" | "medium" | "low";
43
+ reason: string;
44
+ signature: string;
45
+ }
46
+ /**
47
+ * Suggest a recovery for a failed command. LEARNED recoveries (proven on
48
+ * this machine, from the cortex) win over the built-in rules. Pure + total:
49
+ * garbage in → a "none" suggestion, never a throw, never a destructive auto-run.
50
+ */
51
+ export declare function suggestRecovery(cmd: string, code: number, stderr?: string, learned?: Record<string, string>): Suggestion;
52
+ export type ShellKind = "powershell" | "bash" | "zsh";
53
+ /** The cortex key under which a learned recovery for a signature is stored. */
54
+ export declare function recoveryKey(signature: string): string;
55
+ /**
56
+ * Generate the shell hook script (sentinel-bracketed, fail-open,
57
+ * non-destructive). It prints a faint suggestion after a failed command and
58
+ * binds a hotkey to insert it — it NEVER auto-runs anything. `binInvoke` is
59
+ * how to call mneme (default "mneme"; tests/CI may pass a node+path form).
60
+ * Total + deterministic.
61
+ */
62
+ export declare function generateHook(shell: ShellKind, binInvoke?: string): string;
63
+ export interface AutopilotGauntlet {
64
+ /** known failures map to the right recovery (deterministic). */
65
+ rulesFire: boolean;
66
+ /** a learned recovery overrides the built-in rule. */
67
+ learnedWins: boolean;
68
+ /** the signature is stable across variable args. */
69
+ signatureStable: boolean;
70
+ /** hook scripts are non-destructive (no auto-run) + sentinel-bracketed. */
71
+ hookSafe: boolean;
72
+ /** total on garbage. */
73
+ stable: boolean;
74
+ score: number;
75
+ }
76
+ /** Prove the autopilot engine. Total + deterministic. */
77
+ export declare function autopilotGauntlet(): AutopilotGauntlet;
78
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/shell_autopilot/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAA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,CAAC;IACzB,2EAA2E;IAC3E,QAAQ,EAAE,OAAO,CAAC;IAClB,wBAAwB;IACxB,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,yDAAyD;AACzD,wBAAgB,iBAAiB,IAAI,iBAAiB,CAgBrD"}
@@ -0,0 +1,181 @@
1
+ /**
2
+ * v2.106.0 — SHELL AUTOPILOT (the last piece of the Zero-Effort Flow).
3
+ *
4
+ * The user keeps typing on the same black terminal. When a command FAILS,
5
+ * Mneme shows a faint phantom recovery suggestion; one keystroke runs it.
6
+ * No command to memorise — the safety net is just there.
7
+ *
8
+ * THE WILD-BUT-HONEST INNOVATION: the recovery is not a frozen heuristic.
9
+ * When a failure is followed by a command that SUCCEEDS, Mneme learns
10
+ * (failure-signature → recovery) and signs it into the COGNITIVE CORTEX —
11
+ * so the suggestion gets smarter from the user's OWN "dark data" (their
12
+ * real terminal history, never uploaded), and a recovery PROVEN on this
13
+ * machine becomes a signed fact EVERY agent (any vendor) can recall. The
14
+ * autopilot is the surface of the Sovereign Memory Bus. Built-in rules are
15
+ * the cold-start; the cortex is the flywheel.
16
+ *
17
+ * This module is PURE + total (108-error rule): signature + suggestion are
18
+ * deterministic functions, no I/O, never throw. The CLI wires the cortex
19
+ * lookup + the shell hook; the engine here is fully unit-testable.
20
+ */
21
+ /**
22
+ * Normalise a failed command + exit code into a stable SIGNATURE, so
23
+ * "git push origin feature-x" and "git push origin feature-y" share one
24
+ * learned recovery. Variable parts (paths, hashes, quoted args, numbers)
25
+ * are masked. Deterministic.
26
+ */
27
+ export function failureSignature(cmd, code, stderr) {
28
+ const c = typeof cmd === "string" ? cmd.trim() : "";
29
+ const toks = c.split(/\s+/).filter(Boolean);
30
+ const verb = (toks[0] ?? "").toLowerCase();
31
+ const sub = (toks[1] && /^[a-z][a-z-]*$/i.test(toks[1]) ? toks[1].toLowerCase() : "");
32
+ // a coarse error class mined from stderr (first matching keyword)
33
+ const err = (typeof stderr === "string" ? stderr : "").toLowerCase();
34
+ let errClass = "";
35
+ for (const [k, cls] of ERR_CLASSES)
36
+ if (err.includes(k)) {
37
+ errClass = cls;
38
+ break;
39
+ }
40
+ const codeN = Number.isFinite(code) ? code : 0;
41
+ return [verb, sub, codeN, errClass].filter((x) => x !== "").join(":");
42
+ }
43
+ const ERR_CLASSES = [
44
+ ["command not found", "not-found"], ["is not recognized", "not-found"],
45
+ ["no upstream", "no-upstream"], ["set the remote", "no-upstream"],
46
+ ["updates were rejected", "rejected"], ["non-fast-forward", "rejected"],
47
+ ["permission denied", "perm"], ["eacces", "perm"],
48
+ ["cannot find module", "missing-module"], ["modulenotfounderror", "missing-module"],
49
+ ["address already in use", "port-busy"], ["eaddrinuse", "port-busy"],
50
+ ["enoent", "enoent"], ["no such file", "enoent"],
51
+ ["merge conflict", "conflict"], ["detached head", "detached"],
52
+ ];
53
+ /** Built-in, deterministic cold-start recovery rules for common failures.
54
+ * All advisory — the user runs them by choice. Order = priority. */
55
+ export const RECOVERY_RULES = [
56
+ { id: "git-no-upstream", match: (v, _c, e) => v === "git" && e === "no-upstream", recovery: () => "git push -u origin HEAD", reason: "the branch has no upstream — push + set it" },
57
+ { id: "git-rejected", match: (v, _c, e) => v === "git" && e === "rejected", recovery: () => "git pull --rebase", reason: "remote has commits you don't — rebase onto them, then push" },
58
+ { id: "node-missing-module", match: (_v, _c, e) => e === "missing-module", recovery: () => "npm install", reason: "a module isn't installed — install dependencies" },
59
+ { id: "port-busy", match: (_v, _c, e) => e === "port-busy", recovery: () => "npx kill-port 3000 # change the port number to the busy one", reason: "the port is already in use — free it (verify the port first)" },
60
+ { id: "perm", match: (_v, _c, e) => e === "perm", recovery: (cmd) => `chmod +x ${(cmd.split(/\s+/).pop() ?? "<file>")} # or re-run with the right permissions`, reason: "permission denied — adjust permissions (review before running)" },
61
+ { id: "enoent-pkg", match: (v, _c, e) => v === "npm" && e === "enoent", recovery: () => "cd <your-project-dir> # run npm where package.json lives", reason: "npm couldn't find package.json — you're likely in the wrong directory" },
62
+ { id: "not-found", match: (_v, _c, e) => e === "not-found", recovery: (cmd) => `# '${(cmd.split(/\s+/)[0] ?? "")}' isn't on PATH — check the spelling or install it`, reason: "command not found — typo or not installed" },
63
+ ];
64
+ /**
65
+ * Suggest a recovery for a failed command. LEARNED recoveries (proven on
66
+ * this machine, from the cortex) win over the built-in rules. Pure + total:
67
+ * garbage in → a "none" suggestion, never a throw, never a destructive auto-run.
68
+ */
69
+ export function suggestRecovery(cmd, code, stderr, learned) {
70
+ try {
71
+ const c = typeof cmd === "string" ? cmd : "";
72
+ const codeN = Number.isFinite(code) ? code : 0;
73
+ if (!c.trim() || codeN === 0)
74
+ return { recovery: null, source: "none", confidence: "low", reason: "no failed command", signature: "" };
75
+ const sig = failureSignature(c, codeN, stderr);
76
+ // 1) learned (proven) recovery from the user's own dark data wins.
77
+ if (learned && typeof learned[sig] === "string" && learned[sig].length > 0) {
78
+ return { recovery: learned[sig], source: "learned", confidence: "high", reason: "proven on this machine before (recalled from the shared cortex)", signature: sig };
79
+ }
80
+ // 2) built-in deterministic rule.
81
+ const verb = (c.trim().split(/\s+/)[0] ?? "").toLowerCase();
82
+ const err = (typeof stderr === "string" ? stderr : "").toLowerCase();
83
+ let errClass = "";
84
+ for (const [k, cls] of ERR_CLASSES)
85
+ if (err.includes(k)) {
86
+ errClass = cls;
87
+ break;
88
+ }
89
+ for (const r of RECOVERY_RULES) {
90
+ if (r.match(verb, codeN, errClass, c))
91
+ return { recovery: r.recovery(c), source: "rule", confidence: "medium", reason: r.reason, signature: sig };
92
+ }
93
+ return { recovery: null, source: "none", confidence: "low", reason: "no known recovery — left to the user", signature: sig };
94
+ }
95
+ catch {
96
+ return { recovery: null, source: "none", confidence: "low", reason: "engine error (safe)", signature: "" };
97
+ }
98
+ }
99
+ /** The cortex key under which a learned recovery for a signature is stored. */
100
+ export function recoveryKey(signature) { return `shell.recovery:${signature}`; }
101
+ /**
102
+ * Generate the shell hook script (sentinel-bracketed, fail-open,
103
+ * non-destructive). It prints a faint suggestion after a failed command and
104
+ * binds a hotkey to insert it — it NEVER auto-runs anything. `binInvoke` is
105
+ * how to call mneme (default "mneme"; tests/CI may pass a node+path form).
106
+ * Total + deterministic.
107
+ */
108
+ export function generateHook(shell, binInvoke = "mneme") {
109
+ const BEGIN = "# >>> mneme shell autopilot >>>";
110
+ const END = "# <<< mneme shell autopilot <<<";
111
+ if (shell === "powershell") {
112
+ return [
113
+ BEGIN,
114
+ "# Non-destructive: prints a faint recovery after a failed command; Alt+r inserts it (never auto-runs). Fail-open.",
115
+ "if (-not (Test-Path variable:global:__mneme_prevPrompt)) { $global:__mneme_prevPrompt = $function:prompt }",
116
+ "function global:prompt {",
117
+ " try {",
118
+ " $code = $LASTEXITCODE",
119
+ " if ($code -ne $null -and $code -ne 0) {",
120
+ " $last = (Get-History -Count 1 -ErrorAction SilentlyContinue).CommandLine",
121
+ " if ($last) {",
122
+ ` $j = & ${binInvoke} shell suggest --cmd "$last" --code $code --json 2>$null | ConvertFrom-Json`,
123
+ " if ($j.recovery) { Write-Host \" mneme ↻ $($j.recovery) [Alt+r]\" -ForegroundColor DarkGray; $global:__mneme_suggestion = $j.recovery }",
124
+ " }",
125
+ " }",
126
+ " } catch { }",
127
+ " & $global:__mneme_prevPrompt",
128
+ "}",
129
+ "if (Get-Module -ListAvailable PSReadLine) { Set-PSReadLineKeyHandler -Chord 'Alt+r' -ScriptBlock { if ($global:__mneme_suggestion) { [Microsoft.PowerShell.PSConsoleReadLine]::Insert($global:__mneme_suggestion) } } }",
130
+ END,
131
+ ].join("\n");
132
+ }
133
+ // bash / zsh share the same precmd-style logic.
134
+ const widget = shell === "zsh";
135
+ return [
136
+ BEGIN,
137
+ "# Non-destructive: prints a faint recovery after a failed command; the suggestion is in $MNEME_SUGGESTION (never auto-runs). Fail-open.",
138
+ "__mneme_autopilot() {",
139
+ " local code=$?",
140
+ ` [ "$code" -eq 0 ] && return`,
141
+ " local last; last=$(fc -ln -1 2>/dev/null | sed 's/^[[:space:]]*//')",
142
+ ` [ -z "$last" ] && return`,
143
+ ` local s; s=$(${binInvoke} shell suggest --cmd "$last" --code "$code" --field recovery 2>/dev/null)`,
144
+ ` if [ -n "$s" ]; then export MNEME_SUGGESTION="$s"; printf ' \\033[2mmneme \\342\\206\\273 %s\\033[0m\\n' "$s"; fi`,
145
+ "}",
146
+ widget
147
+ ? "autoload -Uz add-zsh-hook 2>/dev/null && add-zsh-hook precmd __mneme_autopilot"
148
+ : "case \"$PROMPT_COMMAND\" in *__mneme_autopilot*) ;; *) PROMPT_COMMAND=\"__mneme_autopilot;${PROMPT_COMMAND}\" ;; esac",
149
+ END,
150
+ ].join("\n");
151
+ }
152
+ /** Prove the autopilot engine. Total + deterministic. */
153
+ export function autopilotGauntlet() {
154
+ try {
155
+ const git = suggestRecovery("git push", 1, "fatal: The current branch has no upstream branch");
156
+ const rulesFire = git.source === "rule" && git.recovery === "git push -u origin HEAD";
157
+ const learned = { [failureSignature("git push", 1, "no upstream")]: "git push --set-upstream origin HEAD" };
158
+ const l = suggestRecovery("git push", 1, "no upstream branch", learned);
159
+ const learnedWins = l.source === "learned" && l.recovery === "git push --set-upstream origin HEAD";
160
+ const signatureStable = failureSignature("git push origin feat-a", 1, "no upstream") === failureSignature("git push origin feat-b", 1, "no upstream");
161
+ const ps = generateHook("powershell");
162
+ const bash = generateHook("bash");
163
+ const hookSafe = ps.includes(">>> mneme shell autopilot >>>") && ps.includes("Alt+r") && !ps.includes("Invoke-Expression")
164
+ && bash.includes("__mneme_autopilot") && !/eval .\$s/.test(bash);
165
+ let stable = true;
166
+ try {
167
+ suggestRecovery(null, null);
168
+ failureSignature(null, null);
169
+ generateHook("bash");
170
+ }
171
+ catch {
172
+ stable = false;
173
+ }
174
+ const perfect = rulesFire && learnedWins && signatureStable && hookSafe && stable;
175
+ return { rulesFire, learnedWins, signatureStable, hookSafe, stable, score: perfect ? 100 : 0 };
176
+ }
177
+ catch {
178
+ return { rulesFire: false, learnedWins: false, signatureStable: false, hookSafe: false, stable: false, score: 0 };
179
+ }
180
+ }
181
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/shell_autopilot/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAAC,GAAW,EAAE,IAAY,EAAE,MAAe;IACzE,MAAM,CAAC,GAAG,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACpD,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC5C,MAAM,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;IAC3C,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACtF,kEAAkE;IAClE,MAAM,GAAG,GAAG,CAAC,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;IACrE,IAAI,QAAQ,GAAG,EAAE,CAAC;IAClB,KAAK,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,IAAI,WAAW;QAAE,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;YAAC,QAAQ,GAAG,GAAG,CAAC;YAAC,MAAM;QAAC,CAAC;IACnF,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,C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,WAAW,EAAE,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;IAAC,CAAC;AAChI,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=shell_autopilot.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shell_autopilot.test.d.ts","sourceRoot":"","sources":["../../src/shell_autopilot/shell_autopilot.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,57 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import { failureSignature, suggestRecovery, generateHook, recoveryKey, autopilotGauntlet, RECOVERY_RULES } from "./index.js";
3
+ describe("v2.106 SHELL AUTOPILOT — phantom recovery engine", () => {
4
+ it("a successful command (exit 0) yields no suggestion", () => {
5
+ expect(suggestRecovery("npm test", 0).recovery).toBeNull();
6
+ });
7
+ it("built-in rules fire for common failures (deterministic)", () => {
8
+ expect(suggestRecovery("git push", 1, "fatal: The current branch has no upstream branch").recovery).toBe("git push -u origin HEAD");
9
+ expect(suggestRecovery("git push", 1, "Updates were rejected because the remote contains work").recovery).toBe("git pull --rebase");
10
+ expect(suggestRecovery("node app.js", 1, "Error: Cannot find module 'express'").recovery).toBe("npm install");
11
+ expect(suggestRecovery("foobar", 127, "command not found: foobar").source).toBe("rule");
12
+ });
13
+ it("THE INNOVATION — a LEARNED recovery (from the user's dark data) beats the rule", () => {
14
+ const sig = failureSignature("git push", 1, "no upstream");
15
+ const learned = { [sig]: "git push --set-upstream origin HEAD" };
16
+ const s = suggestRecovery("git push", 1, "no upstream branch", learned);
17
+ expect(s.source).toBe("learned");
18
+ expect(s.recovery).toBe("git push --set-upstream origin HEAD");
19
+ expect(s.confidence).toBe("high");
20
+ });
21
+ it("signature is STABLE across variable args (so one recovery covers many commands)", () => {
22
+ expect(failureSignature("git push origin feature-a", 1, "no upstream"))
23
+ .toBe(failureSignature("git push origin feature-b", 1, "no upstream"));
24
+ expect(recoveryKey("git:push:1:no-upstream")).toBe("shell.recovery:git:push:1:no-upstream");
25
+ });
26
+ it("generates NON-DESTRUCTIVE, sentinel-bracketed hooks for all 3 OS shells", () => {
27
+ for (const shell of ["powershell", "bash", "zsh"]) {
28
+ const h = generateHook(shell);
29
+ expect(h).toContain(">>> mneme shell autopilot >>>");
30
+ expect(h).toContain("<<< mneme shell autopilot <<<");
31
+ // never auto-runs the suggestion
32
+ expect(h).not.toContain("Invoke-Expression");
33
+ expect(/eval\s+["']?\$s/.test(h)).toBe(false);
34
+ }
35
+ // powershell preserves the user's existing prompt (non-clobbering)
36
+ expect(generateHook("powershell")).toContain("__mneme_prevPrompt");
37
+ // a custom bin invocation flows through
38
+ expect(generateHook("bash", "node /x/mneme.js")).toContain("node /x/mneme.js shell suggest");
39
+ });
40
+ it("autopilot gauntlet scores 100", () => {
41
+ const g = autopilotGauntlet();
42
+ expect(g.rulesFire).toBe(true);
43
+ expect(g.learnedWins).toBe(true);
44
+ expect(g.signatureStable).toBe(true);
45
+ expect(g.hookSafe).toBe(true);
46
+ expect(g.stable).toBe(true);
47
+ expect(g.score).toBe(100);
48
+ });
49
+ it("STABILITY — total on garbage", () => {
50
+ expect(() => suggestRecovery(null, null)).not.toThrow();
51
+ expect(suggestRecovery(null, null).source).toBe("none");
52
+ expect(() => failureSignature(null, null)).not.toThrow();
53
+ expect(() => generateHook("bash")).not.toThrow();
54
+ expect(RECOVERY_RULES.length).toBeGreaterThan(0);
55
+ });
56
+ });
57
+ //# sourceMappingURL=shell_autopilot.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shell_autopilot.test.js","sourceRoot":"","sources":["../../src/shell_autopilot/shell_autopilot.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,YAAY,EAAE,WAAW,EAA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1 @@
1
- {"version":3,"file":"probes.d.ts","sourceRoot":"","sources":["../../src/truth_gate/probes.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAq6FnE,eAAO,MAAM,UAAU,EAAE,aAAa,CAAC,KAAK,CAAU,CAAC;AAEvD,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS,CAEvD;AAED,wBAAsB,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC,CAQlF"}
1
+ {"version":3,"file":"probes.d.ts","sourceRoot":"","sources":["../../src/truth_gate/probes.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAi8FnE,eAAO,MAAM,UAAU,EAAE,aAAa,CAAC,KAAK,CAAU,CAAC;AAEvD,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS,CAEvD;AAED,wBAAsB,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC,CAQlF"}
@@ -386,6 +386,42 @@ const probes = [
386
386
  }
387
387
  },
388
388
  },
389
+ {
390
+ id: "probe.archaeology.signed_provenance",
391
+ kind: "boolean",
392
+ description: "DATA ARCHAEOLOGY (v2.107.0 — the honest core of the 'data archaeology' idea, NOT a scraper): every fact that enters the local brain from a public source carries SIGNED, verifiable PROVENANCE (source URL + content hash + time), is distilled from raw content (chatter dropped), and is gated by a robots.txt + rate-limit policy so ingest stays legitimate. NOT dark-web crawling, NOT 'decryption' — accountable knowledge alchemy. This probe asserts the archaeology gauntlet = 100: robots respected ∧ rate-limited ∧ distills ∧ signed-provenance ∧ a forged source is caught ∧ total.",
393
+ run: async (ctx) => {
394
+ const t0 = Date.now();
395
+ void ctx;
396
+ try {
397
+ const A = await import("../archaeology/index.js");
398
+ const g = A.archaeologyGauntlet(process.cwd(), 1700000000000);
399
+ const ok = g.score === 100 && g.robotsRespected && g.rateLimits && g.distills && g.signedProvenance && g.forgeryCaught && g.stable;
400
+ return { value: ok ? 1 : 0, evidence: `score=${g.score} robots=${g.robotsRespected} rate=${g.rateLimits} distills=${g.distills} signedProvenance=${g.signedProvenance} forgeryCaught=${g.forgeryCaught}`, dtMs: Date.now() - t0 };
401
+ }
402
+ catch (e) {
403
+ return { value: 0, evidence: `threw: ${e.message}`, dtMs: Date.now() - t0 };
404
+ }
405
+ },
406
+ },
407
+ {
408
+ id: "probe.shell.autopilot",
409
+ kind: "boolean",
410
+ description: "SHELL AUTOPILOT (v2.106.0 — the last piece of the Zero-Effort Flow): after a failed command, a faint phantom recovery suggestion appears; one keystroke runs it (it never auto-runs). The innovation: the recovery LEARNS from the user's own terminal history — a recovery proven on this machine is signed into the Cognitive Cortex and recalled for EVERY agent (any vendor). Built-in deterministic rules are the cold-start; a learned recovery beats them. Hooks generate for Windows (PowerShell) + macOS/Linux (zsh/bash), non-destructive + sentinel-bracketed, never auto-running anything. This probe asserts the autopilot gauntlet = 100 (rules fire ∧ learned-wins ∧ stable signature ∧ safe hooks ∧ total).",
411
+ run: async (ctx) => {
412
+ const t0 = Date.now();
413
+ void ctx;
414
+ try {
415
+ const S = await import("../shell_autopilot/index.js");
416
+ const g = S.autopilotGauntlet();
417
+ const ok = g.score === 100 && g.rulesFire && g.learnedWins && g.signatureStable && g.hookSafe && g.stable;
418
+ return { value: ok ? 1 : 0, evidence: `score=${g.score} rulesFire=${g.rulesFire} learnedWins=${g.learnedWins} signatureStable=${g.signatureStable} hookSafe=${g.hookSafe}`, dtMs: Date.now() - t0 };
419
+ }
420
+ catch (e) {
421
+ return { value: 0, evidence: `threw: ${e.message}`, dtMs: Date.now() - t0 };
422
+ }
423
+ },
424
+ },
389
425
  {
390
426
  id: "probe.cortex.sovereign_memory_bus",
391
427
  kind: "boolean",