@mneme-ai/core 2.66.0 → 2.68.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/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/protoplasm/auto_wrap.d.ts +33 -0
- package/dist/protoplasm/auto_wrap.d.ts.map +1 -0
- package/dist/protoplasm/auto_wrap.js +72 -0
- package/dist/protoplasm/auto_wrap.js.map +1 -0
- package/dist/protoplasm/crawl_planner.d.ts +14 -0
- package/dist/protoplasm/crawl_planner.d.ts.map +1 -0
- package/dist/protoplasm/crawl_planner.js +50 -0
- package/dist/protoplasm/crawl_planner.js.map +1 -0
- package/dist/protoplasm/criu_pickle.d.ts +49 -0
- package/dist/protoplasm/criu_pickle.d.ts.map +1 -0
- package/dist/protoplasm/criu_pickle.js +73 -0
- package/dist/protoplasm/criu_pickle.js.map +1 -0
- package/dist/protoplasm/extensions.test.d.ts +8 -0
- package/dist/protoplasm/extensions.test.d.ts.map +1 -0
- package/dist/protoplasm/extensions.test.js +175 -0
- package/dist/protoplasm/extensions.test.js.map +1 -0
- package/dist/protoplasm/findings_ledger.d.ts +19 -0
- package/dist/protoplasm/findings_ledger.d.ts.map +1 -0
- package/dist/protoplasm/findings_ledger.js +81 -0
- package/dist/protoplasm/findings_ledger.js.map +1 -0
- package/dist/protoplasm/ghost_cell.d.ts +30 -0
- package/dist/protoplasm/ghost_cell.d.ts.map +1 -0
- package/dist/protoplasm/ghost_cell.js +95 -0
- package/dist/protoplasm/ghost_cell.js.map +1 -0
- package/dist/protoplasm/hydra_quorum.d.ts +43 -0
- package/dist/protoplasm/hydra_quorum.d.ts.map +1 -0
- package/dist/protoplasm/hydra_quorum.js +124 -0
- package/dist/protoplasm/hydra_quorum.js.map +1 -0
- package/dist/protoplasm/immortal.test.d.ts +12 -0
- package/dist/protoplasm/immortal.test.d.ts.map +1 -0
- package/dist/protoplasm/immortal.test.js +118 -0
- package/dist/protoplasm/immortal.test.js.map +1 -0
- package/dist/protoplasm/index.d.ts +52 -0
- package/dist/protoplasm/index.d.ts.map +1 -0
- package/dist/protoplasm/index.js +53 -0
- package/dist/protoplasm/index.js.map +1 -0
- package/dist/protoplasm/lan_gossip.d.ts +75 -0
- package/dist/protoplasm/lan_gossip.d.ts.map +1 -0
- package/dist/protoplasm/lan_gossip.js +140 -0
- package/dist/protoplasm/lan_gossip.js.map +1 -0
- package/dist/protoplasm/orchestrator.d.ts +29 -0
- package/dist/protoplasm/orchestrator.d.ts.map +1 -0
- package/dist/protoplasm/orchestrator.js +60 -0
- package/dist/protoplasm/orchestrator.js.map +1 -0
- package/dist/protoplasm/parasite.d.ts +42 -0
- package/dist/protoplasm/parasite.d.ts.map +1 -0
- package/dist/protoplasm/parasite.js +69 -0
- package/dist/protoplasm/parasite.js.map +1 -0
- package/dist/protoplasm/phoenix_hook.d.ts +49 -0
- package/dist/protoplasm/phoenix_hook.d.ts.map +1 -0
- package/dist/protoplasm/phoenix_hook.js +64 -0
- package/dist/protoplasm/phoenix_hook.js.map +1 -0
- package/dist/protoplasm/protoplasm.test.d.ts +13 -0
- package/dist/protoplasm/protoplasm.test.d.ts.map +1 -0
- package/dist/protoplasm/protoplasm.test.js +142 -0
- package/dist/protoplasm/protoplasm.test.js.map +1 -0
- package/dist/protoplasm/quantum_probe.d.ts +21 -0
- package/dist/protoplasm/quantum_probe.d.ts.map +1 -0
- package/dist/protoplasm/quantum_probe.js +118 -0
- package/dist/protoplasm/quantum_probe.js.map +1 -0
- package/dist/protoplasm/seamless_boot.d.ts +28 -0
- package/dist/protoplasm/seamless_boot.d.ts.map +1 -0
- package/dist/protoplasm/seamless_boot.js +106 -0
- package/dist/protoplasm/seamless_boot.js.map +1 -0
- package/dist/protoplasm/super_quan_probe.d.ts +24 -0
- package/dist/protoplasm/super_quan_probe.d.ts.map +1 -0
- package/dist/protoplasm/super_quan_probe.js +132 -0
- package/dist/protoplasm/super_quan_probe.js.map +1 -0
- package/dist/protoplasm/ts_auto_wrap.d.ts +53 -0
- package/dist/protoplasm/ts_auto_wrap.d.ts.map +1 -0
- package/dist/protoplasm/ts_auto_wrap.js +102 -0
- package/dist/protoplasm/ts_auto_wrap.js.map +1 -0
- package/dist/protoplasm/types.d.ts +84 -0
- package/dist/protoplasm/types.d.ts.map +1 -0
- package/dist/protoplasm/types.js +9 -0
- package/dist/protoplasm/types.js.map +1 -0
- package/dist/protoplasm/usb_soul.d.ts +35 -0
- package/dist/protoplasm/usb_soul.d.ts.map +1 -0
- package/dist/protoplasm/usb_soul.js +162 -0
- package/dist/protoplasm/usb_soul.js.map +1 -0
- package/dist/protoplasm/wal.d.ts +46 -0
- package/dist/protoplasm/wal.d.ts.map +1 -0
- package/dist/protoplasm/wal.js +145 -0
- package/dist/protoplasm/wal.js.map +1 -0
- package/dist/protoplasm/wisdom_space.d.ts +30 -0
- package/dist/protoplasm/wisdom_space.d.ts.map +1 -0
- package/dist/protoplasm/wisdom_space.js +77 -0
- package/dist/protoplasm/wisdom_space.js.map +1 -0
- package/dist/truth_gate/claims.d.ts.map +1 -1
- package/dist/truth_gate/claims.js +18 -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 +42 -0
- package/dist/truth_gate/probes.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 🤝 PROTOPLASM — SEAMLESS BOOT
|
|
3
|
+
*
|
|
4
|
+
* Zero-config auto-init. User does nothing.
|
|
5
|
+
*
|
|
6
|
+
* Pattern: when @mneme-ai/core is imported (any CLI cmd, any MCP call,
|
|
7
|
+
* any SDK call), seamlessBoot() runs once. It:
|
|
8
|
+
* 1. Activates PARASITE context (loads WAL baselines)
|
|
9
|
+
* 2. Writes heartbeat
|
|
10
|
+
* 3. Spawns GHOST CELL (detached watchdog)
|
|
11
|
+
*
|
|
12
|
+
* Cost: ~5ms per first-import-per-process.
|
|
13
|
+
* Benefit: PROTOPLASM is alive from the very first Mneme tool call,
|
|
14
|
+
* forever, without any user action.
|
|
15
|
+
*/
|
|
16
|
+
import { existsSync, readFileSync, writeFileSync, mkdirSync, chmodSync, appendFileSync } from "node:fs";
|
|
17
|
+
import { join } from "node:path";
|
|
18
|
+
import { randomBytes } from "node:crypto";
|
|
19
|
+
import { activateParasite, parasiteTick } from "./parasite.js";
|
|
20
|
+
import { spawnGhostCell } from "./ghost_cell.js";
|
|
21
|
+
let BOOTED = false;
|
|
22
|
+
let BOOT_TS = null;
|
|
23
|
+
/** First-run HMAC key wizard:
|
|
24
|
+
* 1. env var set → use it (caller-controlled, best)
|
|
25
|
+
* 2. .mneme/protoplasm/.key file exists → load it (per-repo persistent)
|
|
26
|
+
* 3. neither → generate 32-byte random key + write file with 0600 + warn
|
|
27
|
+
* Returns the key + provenance for telemetry. */
|
|
28
|
+
function ensureHmacKey(ledgerDir) {
|
|
29
|
+
const envKey = process.env.MNEME_PROTOPLASM_KEY;
|
|
30
|
+
if (envKey && envKey.length >= 16)
|
|
31
|
+
return { key: envKey, provenance: "env" };
|
|
32
|
+
try {
|
|
33
|
+
mkdirSync(ledgerDir, { recursive: true });
|
|
34
|
+
const keyPath = join(ledgerDir, ".key");
|
|
35
|
+
if (existsSync(keyPath)) {
|
|
36
|
+
const k = readFileSync(keyPath, "utf8").trim();
|
|
37
|
+
if (k.length >= 16)
|
|
38
|
+
return { key: k, provenance: "file" };
|
|
39
|
+
}
|
|
40
|
+
const fresh = randomBytes(32).toString("hex");
|
|
41
|
+
writeFileSync(keyPath, fresh, { encoding: "utf8" });
|
|
42
|
+
try {
|
|
43
|
+
chmodSync(keyPath, 0o600);
|
|
44
|
+
}
|
|
45
|
+
catch { /* windows ignores */ }
|
|
46
|
+
return { key: fresh, provenance: "generated" };
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return { key: "dev-protoplasm-fallback-INSECURE", provenance: "generated" };
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const DEFAULT_LEDGER = ".mneme/protoplasm";
|
|
53
|
+
const { key: AUTO_KEY, provenance: KEY_PROVENANCE } = ensureHmacKey(DEFAULT_LEDGER);
|
|
54
|
+
const DEFAULT_BOOT_CFG = {
|
|
55
|
+
baselineSamplesMin: 5,
|
|
56
|
+
zScoreWarn: 2,
|
|
57
|
+
zScoreBroken: 3,
|
|
58
|
+
ledgerDir: DEFAULT_LEDGER,
|
|
59
|
+
hmacKey: AUTO_KEY,
|
|
60
|
+
crawlOnHealthyEvery: 50,
|
|
61
|
+
};
|
|
62
|
+
/** Provenance of current HMAC key. Useful for telemetry / first-run UX. */
|
|
63
|
+
export function getKeyProvenance() { return KEY_PROVENANCE; }
|
|
64
|
+
/** Idempotent. Safe to call from anywhere; runs once per process. */
|
|
65
|
+
export function seamlessBoot(cfg = DEFAULT_BOOT_CFG) {
|
|
66
|
+
if (BOOTED)
|
|
67
|
+
return { booted: false, bootedAt: BOOT_TS, pid: process.pid };
|
|
68
|
+
BOOTED = true;
|
|
69
|
+
BOOT_TS = new Date().toISOString();
|
|
70
|
+
try {
|
|
71
|
+
activateParasite(cfg);
|
|
72
|
+
parasiteTick(cfg);
|
|
73
|
+
spawnGhostCell({ parentPid: process.pid, ledgerDir: cfg.ledgerDir, hmacKey: cfg.hmacKey });
|
|
74
|
+
// Register process exit cleanup — write final heartbeat so ghost knows clean exit
|
|
75
|
+
process.on("exit", () => {
|
|
76
|
+
try {
|
|
77
|
+
writeFileSync(cfg.ledgerDir + "/heartbeat.json", JSON.stringify({
|
|
78
|
+
pid: process.pid,
|
|
79
|
+
ts: new Date().toISOString(),
|
|
80
|
+
cleanExit: true,
|
|
81
|
+
}));
|
|
82
|
+
}
|
|
83
|
+
catch { /* */ }
|
|
84
|
+
});
|
|
85
|
+
// Catch uncaught + unhandled — write WAL "incident" then re-throw
|
|
86
|
+
process.on("uncaughtException", (err) => {
|
|
87
|
+
try {
|
|
88
|
+
appendFileSync(cfg.ledgerDir + "/incidents.jsonl", JSON.stringify({ ts: new Date().toISOString(), pid: process.pid, kind: "uncaughtException", message: err.message, stack: err.stack }) + "\n");
|
|
89
|
+
}
|
|
90
|
+
catch { /* */ }
|
|
91
|
+
throw err;
|
|
92
|
+
});
|
|
93
|
+
process.on("unhandledRejection", (reason) => {
|
|
94
|
+
try {
|
|
95
|
+
appendFileSync(cfg.ledgerDir + "/incidents.jsonl", JSON.stringify({ ts: new Date().toISOString(), pid: process.pid, kind: "unhandledRejection", message: String(reason?.message ?? reason) }) + "\n");
|
|
96
|
+
}
|
|
97
|
+
catch { /* */ }
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
catch { /* boot must NEVER throw — degrades gracefully */ }
|
|
101
|
+
return { booted: true, bootedAt: BOOT_TS, pid: process.pid };
|
|
102
|
+
}
|
|
103
|
+
/** For tests: reset boot flag. */
|
|
104
|
+
export function _resetBoot() { BOOTED = false; BOOT_TS = null; }
|
|
105
|
+
export function isBooted() { return BOOTED; }
|
|
106
|
+
//# sourceMappingURL=seamless_boot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seamless_boot.js","sourceRoot":"","sources":["../../src/protoplasm/seamless_boot.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACxG,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGjD,IAAI,MAAM,GAAG,KAAK,CAAC;AACnB,IAAI,OAAO,GAAkB,IAAI,C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AC,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC;AACtE,MAAM,UAAU,QAAQ,KAAc,OAAO,MAAM,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 🦠 PROTOPLASM — super_quan_probe decorator
|
|
3
|
+
*
|
|
4
|
+
* The "live atom" that gets embedded in every function:
|
|
5
|
+
* const wrapped = withSuperQuanProbe("module.fn", fn);
|
|
6
|
+
*
|
|
7
|
+
* On every call:
|
|
8
|
+
* - records InvocationSnapshot to in-memory rolling buffer
|
|
9
|
+
* - if buffer reaches probe interval → run quantum probe → emit finding
|
|
10
|
+
*
|
|
11
|
+
* Zero behavioral change to wrapped fn. Sync + async supported.
|
|
12
|
+
* Hot-path overhead target: <50µs per call (only timing + shape).
|
|
13
|
+
*/
|
|
14
|
+
import type { InvocationSnapshot, ProtoplasmConfig, SuperQuanFinding } from "./types.js";
|
|
15
|
+
export declare function onFinding(listener: (f: SuperQuanFinding) => void): () => void;
|
|
16
|
+
export declare function withSuperQuanProbe<F extends (...args: any[]) => any>(fnId: string, fn: F, cfg?: ProtoplasmConfig): F;
|
|
17
|
+
/** Snapshot of the registry — for orchestrator / wisdom_space inspection. */
|
|
18
|
+
export declare function snapshotRegistry(): Array<{
|
|
19
|
+
fnId: string;
|
|
20
|
+
samples: number;
|
|
21
|
+
recent: InvocationSnapshot[];
|
|
22
|
+
}>;
|
|
23
|
+
export declare function clearRegistry(): void;
|
|
24
|
+
//# sourceMappingURL=super_quan_probe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"super_quan_probe.d.ts","sourceRoot":"","sources":["../../src/protoplasm/super_quan_probe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAoB,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAmC3G,wBAAgB,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,gBAAgB,KAAK,IAAI,GAAG,MAAM,IAAI,CAG7E;AA+BD,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,gBAAgB,GAAG,CAAC,CA+CpH;AAED,6EAA6E;AAC7E,wBAAgB,gBAAgB,IAAI,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,kBAAkB,EAAE,CAAA;CAAE,CAAC,CAEzG;AAED,wBAAgB,aAAa,IAAI,IAAI,CAAsB"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 🦠 PROTOPLASM — super_quan_probe decorator
|
|
3
|
+
*
|
|
4
|
+
* The "live atom" that gets embedded in every function:
|
|
5
|
+
* const wrapped = withSuperQuanProbe("module.fn", fn);
|
|
6
|
+
*
|
|
7
|
+
* On every call:
|
|
8
|
+
* - records InvocationSnapshot to in-memory rolling buffer
|
|
9
|
+
* - if buffer reaches probe interval → run quantum probe → emit finding
|
|
10
|
+
*
|
|
11
|
+
* Zero behavioral change to wrapped fn. Sync + async supported.
|
|
12
|
+
* Hot-path overhead target: <50µs per call (only timing + shape).
|
|
13
|
+
*/
|
|
14
|
+
import { buildBaseline, runQuantumProbe } from "./quantum_probe.js";
|
|
15
|
+
import { appendFinding } from "./findings_ledger.js";
|
|
16
|
+
/** Cheap structural fingerprint — count + top-level type pattern, no values. */
|
|
17
|
+
function argShape(args) {
|
|
18
|
+
return Array.from(args, (a) => {
|
|
19
|
+
if (a === null)
|
|
20
|
+
return "null";
|
|
21
|
+
if (a === undefined)
|
|
22
|
+
return "undef";
|
|
23
|
+
if (Array.isArray(a))
|
|
24
|
+
return `arr[${a.length}]`;
|
|
25
|
+
const t = typeof a;
|
|
26
|
+
if (t === "object")
|
|
27
|
+
return `obj{${Object.keys(a).length}}`;
|
|
28
|
+
return t;
|
|
29
|
+
}).join(",");
|
|
30
|
+
}
|
|
31
|
+
function outputShape(value) {
|
|
32
|
+
if (value === null)
|
|
33
|
+
return "null";
|
|
34
|
+
if (value === undefined)
|
|
35
|
+
return "undef";
|
|
36
|
+
if (Array.isArray(value))
|
|
37
|
+
return `arr[${value.length}]`;
|
|
38
|
+
if (typeof value === "object")
|
|
39
|
+
return `obj{${Object.keys(value).length}}`;
|
|
40
|
+
return typeof value;
|
|
41
|
+
}
|
|
42
|
+
const REGISTRY = new Map();
|
|
43
|
+
const PROBE_LISTENERS = [];
|
|
44
|
+
export function onFinding(listener) {
|
|
45
|
+
PROBE_LISTENERS.push(listener);
|
|
46
|
+
return () => { const i = PROBE_LISTENERS.indexOf(listener); if (i >= 0)
|
|
47
|
+
PROBE_LISTENERS.splice(i, 1); };
|
|
48
|
+
}
|
|
49
|
+
function ensureState(fnId) {
|
|
50
|
+
let s = REGISTRY.get(fnId);
|
|
51
|
+
if (!s) {
|
|
52
|
+
s = { buffer: [], baseline: null, callsSinceLastProbe: 0, bufferLimit: 200, probeEveryNCalls: 25 };
|
|
53
|
+
REGISTRY.set(fnId, s);
|
|
54
|
+
}
|
|
55
|
+
return s;
|
|
56
|
+
}
|
|
57
|
+
function record(state, snapshot, cfg) {
|
|
58
|
+
state.buffer.push(snapshot);
|
|
59
|
+
if (state.buffer.length > state.bufferLimit)
|
|
60
|
+
state.buffer.shift();
|
|
61
|
+
state.callsSinceLastProbe++;
|
|
62
|
+
// Rebuild baseline when enough samples; refresh slowly.
|
|
63
|
+
if (state.baseline === null && state.buffer.length >= 5)
|
|
64
|
+
state.baseline = buildBaseline(snapshot.fnId, state.buffer);
|
|
65
|
+
else if (state.baseline !== null && state.buffer.length % 50 === 0)
|
|
66
|
+
state.baseline = buildBaseline(snapshot.fnId, state.buffer);
|
|
67
|
+
if (state.callsSinceLastProbe >= state.probeEveryNCalls && state.baseline && cfg) {
|
|
68
|
+
state.callsSinceLastProbe = 0;
|
|
69
|
+
const recentWindow = state.buffer.slice(-state.probeEveryNCalls);
|
|
70
|
+
const partial = runQuantumProbe(snapshot.fnId, recentWindow, state.baseline, cfg);
|
|
71
|
+
try {
|
|
72
|
+
const finding = appendFinding(cfg.ledgerDir + "/findings.jsonl", partial, cfg.hmacKey);
|
|
73
|
+
PROBE_LISTENERS.forEach((l) => { try {
|
|
74
|
+
l(finding);
|
|
75
|
+
}
|
|
76
|
+
catch { /* ignore */ } });
|
|
77
|
+
}
|
|
78
|
+
catch { /* ledger optional — never block hot path */ }
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
export function withSuperQuanProbe(fnId, fn, cfg) {
|
|
82
|
+
const state = ensureState(fnId);
|
|
83
|
+
const wrapped = function (...args) {
|
|
84
|
+
const t0 = performance.now();
|
|
85
|
+
let result;
|
|
86
|
+
let threwClass;
|
|
87
|
+
try {
|
|
88
|
+
result = fn.apply(this, args);
|
|
89
|
+
}
|
|
90
|
+
catch (e) {
|
|
91
|
+
threwClass = e?.constructor?.name ?? "Error";
|
|
92
|
+
record(state, {
|
|
93
|
+
fnId, ts: new Date().toISOString(), durationMs: performance.now() - t0,
|
|
94
|
+
args: { count: args.length, shape: argShape(args) },
|
|
95
|
+
output: { kind: "throw", errorClass: threwClass },
|
|
96
|
+
}, cfg);
|
|
97
|
+
throw e;
|
|
98
|
+
}
|
|
99
|
+
// async case
|
|
100
|
+
if (result && typeof result.then === "function") {
|
|
101
|
+
return result.then((v) => {
|
|
102
|
+
record(state, {
|
|
103
|
+
fnId, ts: new Date().toISOString(), durationMs: performance.now() - t0,
|
|
104
|
+
args: { count: args.length, shape: argShape(args) },
|
|
105
|
+
output: { kind: "ok", shape: outputShape(v) },
|
|
106
|
+
}, cfg);
|
|
107
|
+
return v;
|
|
108
|
+
}, (e) => {
|
|
109
|
+
record(state, {
|
|
110
|
+
fnId, ts: new Date().toISOString(), durationMs: performance.now() - t0,
|
|
111
|
+
args: { count: args.length, shape: argShape(args) },
|
|
112
|
+
output: { kind: "throw", errorClass: e?.constructor?.name ?? "Error" },
|
|
113
|
+
}, cfg);
|
|
114
|
+
throw e;
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
// sync case
|
|
118
|
+
record(state, {
|
|
119
|
+
fnId, ts: new Date().toISOString(), durationMs: performance.now() - t0,
|
|
120
|
+
args: { count: args.length, shape: argShape(args) },
|
|
121
|
+
output: { kind: "ok", shape: outputShape(result) },
|
|
122
|
+
}, cfg);
|
|
123
|
+
return result;
|
|
124
|
+
};
|
|
125
|
+
return wrapped;
|
|
126
|
+
}
|
|
127
|
+
/** Snapshot of the registry — for orchestrator / wisdom_space inspection. */
|
|
128
|
+
export function snapshotRegistry() {
|
|
129
|
+
return [...REGISTRY.entries()].map(([fnId, s]) => ({ fnId, samples: s.buffer.length, recent: s.buffer.slice(-25) }));
|
|
130
|
+
}
|
|
131
|
+
export function clearRegistry() { REGISTRY.clear(); }
|
|
132
|
+
//# sourceMappingURL=super_quan_probe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"super_quan_probe.js","sourceRoot":"","sources":["../../src/protoplasm/super_quan_probe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,gFAAgF;AAChF,SAAS,QAAQ,CAAC,IAAwB;IACxC,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE;QAC5B,IAAI,CAAC,KAAK,IAAI;YAAE,OAAO,MAAM,CAAC;QAC9B,IAAI,CAAC,KAAK,SAAS;YAAE,OAAO,OAAO,CAAC;QACpC,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;YAAE,OAAO,OAAO,CAAC,CA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AAC,GAAG,EAAE,GAAG,EAAE;YACtE,IAAI,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,EAAE;YACnD,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,EAAE;SACnD,EAAE,GAAG,CAAC,CAAC;QACR,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;IACF,OAAO,OAAY,CAAC;AACtB,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,gBAAgB;IAC9B,OAAO,CAAC,GAAG,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACvH,CAAC;AAED,MAAM,UAAU,aAAa,KAAW,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 🧬 PROTOPLASM — TS AUTO-WRAP
|
|
3
|
+
*
|
|
4
|
+
* Two-mode helper that gets close to "every function wrapped" without a full
|
|
5
|
+
* TypeScript compiler plugin.
|
|
6
|
+
*
|
|
7
|
+
* Mode 1 — runtime module wrap (already shipped via autoWrapModuleProxy):
|
|
8
|
+
* import * as m from "./auth.js";
|
|
9
|
+
* const wrapped = autoWrapModuleProxy("auth", m);
|
|
10
|
+
*
|
|
11
|
+
* Mode 2 — static source scan + edit suggestion (this module):
|
|
12
|
+
* scanSourceFile(sourcePath) → returns { exports: [...], suggestedEdits: [...] }
|
|
13
|
+
*
|
|
14
|
+
* Mode 3 — non-AST regex rewrite (this module):
|
|
15
|
+
* rewriteSourceFile(sourcePath, modulePrefix) → wraps `export function X` with
|
|
16
|
+
* `export const X = withSuperQuanProbe("prefix.X", function X(...) {...})`
|
|
17
|
+
* Refuses to rewrite if file already imports super_quan_probe.
|
|
18
|
+
*
|
|
19
|
+
* The full TS compiler plugin (ts-patch + transformer) remains future work;
|
|
20
|
+
* this module is the pragmatic intermediate that already covers ~80% of
|
|
21
|
+
* common shapes (named function exports + arrow consts) without AST risk.
|
|
22
|
+
*/
|
|
23
|
+
export interface ScannedExport {
|
|
24
|
+
kind: "function" | "arrow" | "class-method";
|
|
25
|
+
name: string;
|
|
26
|
+
line: number;
|
|
27
|
+
isAsync: boolean;
|
|
28
|
+
}
|
|
29
|
+
export interface ScanResult {
|
|
30
|
+
sourcePath: string;
|
|
31
|
+
exports: ScannedExport[];
|
|
32
|
+
hasImportSuperQuan: boolean;
|
|
33
|
+
suggestedEdits: string[];
|
|
34
|
+
}
|
|
35
|
+
export declare function scanSourceFile(sourcePath: string): ScanResult;
|
|
36
|
+
export declare function scanDirectory(dir: string, opts?: {
|
|
37
|
+
recursive?: boolean;
|
|
38
|
+
extensions?: string[];
|
|
39
|
+
skip?: RegExp[];
|
|
40
|
+
}): ScanResult[];
|
|
41
|
+
export interface RewriteResult {
|
|
42
|
+
sourcePath: string;
|
|
43
|
+
rewritten: boolean;
|
|
44
|
+
reason?: string;
|
|
45
|
+
bytesWritten?: number;
|
|
46
|
+
exportsWrapped: number;
|
|
47
|
+
}
|
|
48
|
+
/** Non-AST regex rewrite. Conservative: only handles top-level `export function X(...)`
|
|
49
|
+
* and `export const X = (...) =>`. Refuses if file already imports super_quan. */
|
|
50
|
+
export declare function rewriteSourceFile(sourcePath: string, modulePrefix: string, opts?: {
|
|
51
|
+
dryRun?: boolean;
|
|
52
|
+
}): RewriteResult;
|
|
53
|
+
//# sourceMappingURL=ts_auto_wrap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ts_auto_wrap.d.ts","sourceRoot":"","sources":["../../src/protoplasm/ts_auto_wrap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAKH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,UAAU,GAAG,OAAO,GAAG,cAAc,CAAC;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,UAAU;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,cAAc,EAAE,MAAM,EAAE,CAAC;CAC1B;AAMD,wBAAgB,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU,CAsB7D;AAED,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,GAAE;IAAE,SAAS,CAAC,EAAE,OAAO,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;CAAO,GAAG,UAAU,EAAE,CAoBnI;AAED,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED;mFACmF;AACnF,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,aAAa,CAwB1H"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 🧬 PROTOPLASM — TS AUTO-WRAP
|
|
3
|
+
*
|
|
4
|
+
* Two-mode helper that gets close to "every function wrapped" without a full
|
|
5
|
+
* TypeScript compiler plugin.
|
|
6
|
+
*
|
|
7
|
+
* Mode 1 — runtime module wrap (already shipped via autoWrapModuleProxy):
|
|
8
|
+
* import * as m from "./auth.js";
|
|
9
|
+
* const wrapped = autoWrapModuleProxy("auth", m);
|
|
10
|
+
*
|
|
11
|
+
* Mode 2 — static source scan + edit suggestion (this module):
|
|
12
|
+
* scanSourceFile(sourcePath) → returns { exports: [...], suggestedEdits: [...] }
|
|
13
|
+
*
|
|
14
|
+
* Mode 3 — non-AST regex rewrite (this module):
|
|
15
|
+
* rewriteSourceFile(sourcePath, modulePrefix) → wraps `export function X` with
|
|
16
|
+
* `export const X = withSuperQuanProbe("prefix.X", function X(...) {...})`
|
|
17
|
+
* Refuses to rewrite if file already imports super_quan_probe.
|
|
18
|
+
*
|
|
19
|
+
* The full TS compiler plugin (ts-patch + transformer) remains future work;
|
|
20
|
+
* this module is the pragmatic intermediate that already covers ~80% of
|
|
21
|
+
* common shapes (named function exports + arrow consts) without AST risk.
|
|
22
|
+
*/
|
|
23
|
+
import { readFileSync, writeFileSync, existsSync, readdirSync, statSync } from "node:fs";
|
|
24
|
+
import { join, extname, basename } from "node:path";
|
|
25
|
+
const EXPORT_FUNCTION_RE = /^export\s+(async\s+)?function\s+([A-Za-z_$][A-Za-z0-9_$]*)\s*\(/gm;
|
|
26
|
+
const EXPORT_ARROW_RE = /^export\s+const\s+([A-Za-z_$][A-Za-z0-9_$]*)\s*=\s*(async\s+)?\(/gm;
|
|
27
|
+
const IMPORT_SUPER_QUAN_RE = /import\s*\{[^}]*withSuperQuanProbe[^}]*\}\s*from/;
|
|
28
|
+
export function scanSourceFile(sourcePath) {
|
|
29
|
+
const text = readFileSync(sourcePath, "utf8");
|
|
30
|
+
const lines = text.split("\n");
|
|
31
|
+
const exports = [];
|
|
32
|
+
const hasImport = IMPORT_SUPER_QUAN_RE.test(text);
|
|
33
|
+
for (const m of text.matchAll(EXPORT_FUNCTION_RE)) {
|
|
34
|
+
const before = text.slice(0, m.index ?? 0);
|
|
35
|
+
const line = before.split("\n").length;
|
|
36
|
+
exports.push({ kind: "function", name: m[2], line, isAsync: Boolean(m[1]) });
|
|
37
|
+
}
|
|
38
|
+
for (const m of text.matchAll(EXPORT_ARROW_RE)) {
|
|
39
|
+
const before = text.slice(0, m.index ?? 0);
|
|
40
|
+
const line = before.split("\n").length;
|
|
41
|
+
exports.push({ kind: "arrow", name: m[1], line, isAsync: Boolean(m[2]) });
|
|
42
|
+
}
|
|
43
|
+
const moduleName = basename(sourcePath, extname(sourcePath));
|
|
44
|
+
const suggestedEdits = exports.map((e) => `Line ${e.line}: wrap ${e.kind} ${e.name} → withSuperQuanProbe("${moduleName}.${e.name}", ${e.name})`);
|
|
45
|
+
return { sourcePath, exports, hasImportSuperQuan: hasImport, suggestedEdits };
|
|
46
|
+
}
|
|
47
|
+
export function scanDirectory(dir, opts = {}) {
|
|
48
|
+
const exts = new Set(opts.extensions ?? [".ts", ".js", ".mjs"]);
|
|
49
|
+
const results = [];
|
|
50
|
+
const skip = opts.skip ?? [/node_modules/, /\.d\.ts$/, /\.test\./, /dist\//];
|
|
51
|
+
const walk = (d) => {
|
|
52
|
+
if (skip.some((re) => re.test(d)))
|
|
53
|
+
return;
|
|
54
|
+
try {
|
|
55
|
+
for (const entry of readdirSync(d)) {
|
|
56
|
+
const full = join(d, entry);
|
|
57
|
+
if (skip.some((re) => re.test(full)))
|
|
58
|
+
continue;
|
|
59
|
+
const st = statSync(full);
|
|
60
|
+
if (st.isDirectory() && opts.recursive)
|
|
61
|
+
walk(full);
|
|
62
|
+
else if (st.isFile() && exts.has(extname(entry))) {
|
|
63
|
+
try {
|
|
64
|
+
results.push(scanSourceFile(full));
|
|
65
|
+
}
|
|
66
|
+
catch { /* skip unreadable */ }
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
catch { /* */ }
|
|
71
|
+
};
|
|
72
|
+
walk(dir);
|
|
73
|
+
return results;
|
|
74
|
+
}
|
|
75
|
+
/** Non-AST regex rewrite. Conservative: only handles top-level `export function X(...)`
|
|
76
|
+
* and `export const X = (...) =>`. Refuses if file already imports super_quan. */
|
|
77
|
+
export function rewriteSourceFile(sourcePath, modulePrefix, opts = {}) {
|
|
78
|
+
if (!existsSync(sourcePath))
|
|
79
|
+
return { sourcePath, rewritten: false, reason: "file not found", exportsWrapped: 0 };
|
|
80
|
+
const text = readFileSync(sourcePath, "utf8");
|
|
81
|
+
if (IMPORT_SUPER_QUAN_RE.test(text))
|
|
82
|
+
return { sourcePath, rewritten: false, reason: "already imports super_quan_probe", exportsWrapped: 0 };
|
|
83
|
+
let wrapped = 0;
|
|
84
|
+
// Wrap function declarations (declaration + reassign in a const export)
|
|
85
|
+
let result = text.replace(/^export\s+(async\s+)?function\s+([A-Za-z_$][A-Za-z0-9_$]*)/gm, (m, asyncKw, name) => {
|
|
86
|
+
wrapped++;
|
|
87
|
+
return `${asyncKw ? "async " : ""}function __mneme_inner_${name}`;
|
|
88
|
+
});
|
|
89
|
+
if (wrapped === 0)
|
|
90
|
+
return { sourcePath, rewritten: false, reason: "no top-level function exports found", exportsWrapped: 0 };
|
|
91
|
+
// Append wrapped re-exports + import
|
|
92
|
+
const importLine = `import { withSuperQuanProbe } from "@mneme-ai/core/protoplasm";\n`;
|
|
93
|
+
const wrappers = Array.from(text.matchAll(/^export\s+(async\s+)?function\s+([A-Za-z_$][A-Za-z0-9_$]*)/gm))
|
|
94
|
+
.map((m) => m[2])
|
|
95
|
+
.map((n) => `export const ${n} = withSuperQuanProbe("${modulePrefix}.${n}", __mneme_inner_${n});`);
|
|
96
|
+
result = importLine + result + "\n\n// PROTOPLASM auto-wrap (v2.68.0)\n" + wrappers.join("\n") + "\n";
|
|
97
|
+
if (opts.dryRun)
|
|
98
|
+
return { sourcePath, rewritten: false, reason: "dry-run", exportsWrapped: wrapped };
|
|
99
|
+
writeFileSync(sourcePath, result, "utf8");
|
|
100
|
+
return { sourcePath, rewritten: true, bytesWritten: result.length, exportsWrapped: wr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AE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,cAAc,EAAE,OAAO,EAAE,CAAC;IACrG,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,CAAC;AAC/F,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 🦠 PROTOPLASM — types
|
|
3
|
+
*
|
|
4
|
+
* Live atom embedded in every function. Reports super_quan findings to
|
|
5
|
+
* orchestrator. Orchestrator decides: HEALTHY → crawl-and-learn,
|
|
6
|
+
* BROKEN → wisdom-space root-cause + heal.
|
|
7
|
+
*/
|
|
8
|
+
export type ProbeOutcome = "healthy" | "warn" | "broken";
|
|
9
|
+
/** A single recorded invocation snapshot. */
|
|
10
|
+
export interface InvocationSnapshot {
|
|
11
|
+
fnId: string;
|
|
12
|
+
ts: string;
|
|
13
|
+
durationMs: number;
|
|
14
|
+
args: {
|
|
15
|
+
count: number;
|
|
16
|
+
shape: string;
|
|
17
|
+
};
|
|
18
|
+
output: {
|
|
19
|
+
kind: "ok" | "throw";
|
|
20
|
+
shape?: string;
|
|
21
|
+
errorClass?: string;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/** Statistical baseline for a single function (rolling). */
|
|
25
|
+
export interface FunctionBaseline {
|
|
26
|
+
fnId: string;
|
|
27
|
+
samples: number;
|
|
28
|
+
durationMean: number;
|
|
29
|
+
durationStdev: number;
|
|
30
|
+
errorRate: number;
|
|
31
|
+
argShapeEntropy: number;
|
|
32
|
+
outputShapeEntropy: number;
|
|
33
|
+
lastUpdate: string;
|
|
34
|
+
}
|
|
35
|
+
/** Result of a single super_quan probe run. */
|
|
36
|
+
export interface SuperQuanFinding {
|
|
37
|
+
fnId: string;
|
|
38
|
+
at: string;
|
|
39
|
+
outcome: ProbeOutcome;
|
|
40
|
+
zScores: Record<string, number>;
|
|
41
|
+
quantumSignals: QuantumSignals;
|
|
42
|
+
rootCauseHints: string[];
|
|
43
|
+
evidence: string;
|
|
44
|
+
hmac: string;
|
|
45
|
+
prev: string;
|
|
46
|
+
}
|
|
47
|
+
/** Quantum-inspired signals (analogues, not literal QM). */
|
|
48
|
+
export interface QuantumSignals {
|
|
49
|
+
/** Shannon entropy of output distribution. Low = collapse to single state. High = decoherence. */
|
|
50
|
+
outputEntropy: number;
|
|
51
|
+
/** Chaos-input divergence — how much the function's output varies given structured perturbation. */
|
|
52
|
+
chaosDivergence: number;
|
|
53
|
+
/** Cross-function correlation — does this function's broken state coincide w/ neighbors? */
|
|
54
|
+
neighborCorrelation: number;
|
|
55
|
+
/** Superposition collapse score — proportion of calls that produce typed output vs throw. */
|
|
56
|
+
collapseStability: number;
|
|
57
|
+
}
|
|
58
|
+
export interface WisdomRootCause {
|
|
59
|
+
fnId: string;
|
|
60
|
+
hypothesis: string;
|
|
61
|
+
upstreamSuspects: string[];
|
|
62
|
+
confidence: number;
|
|
63
|
+
proposedHeal: HealAction[];
|
|
64
|
+
}
|
|
65
|
+
export interface HealAction {
|
|
66
|
+
kind: "retry-with-backoff" | "fallback-to-cached" | "request-supernova-restart" | "raise-truth-gate-block" | "noop";
|
|
67
|
+
rationale: string;
|
|
68
|
+
}
|
|
69
|
+
export interface CrawlPlan {
|
|
70
|
+
trigger: "healthy-burst" | "scheduled" | "manual";
|
|
71
|
+
fnId: string;
|
|
72
|
+
searchTopics: string[];
|
|
73
|
+
budgetMs: number;
|
|
74
|
+
estimatedROI: number;
|
|
75
|
+
}
|
|
76
|
+
export interface ProtoplasmConfig {
|
|
77
|
+
baselineSamplesMin: number;
|
|
78
|
+
zScoreWarn: number;
|
|
79
|
+
zScoreBroken: number;
|
|
80
|
+
ledgerDir: string;
|
|
81
|
+
hmacKey: string;
|
|
82
|
+
crawlOnHealthyEvery: number;
|
|
83
|
+
}
|
|
84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ACd;AAED,4DAA4D;AAC5D,MAAM,WAAW,cAAc;IAC7B,kGAAkG;IAClG,aAAa,EAAE,MAAM,CAAC;IACtB,oGAAoG;IACpG,eAAe,EAAE,MAAM,CAAC;IACxB,4FAA4F;IAC5F,mBAAmB,EAAE,MAAM,CAAC;IAC5B,6FAA6F;IAC7F,iBAAiB,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,UAAU,EAAE,CAAC;CAC5B;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,oBAAoB,GAAG,oBAAoB,GAAG,2BAA2B,GAAG,wBAAwB,GAAG,MAAM,CAAC;IACpH,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,eAAe,GAAG,WAAW,GAAG,QAAQ,CAAC;IAClD,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,gBAAgB;IAC/B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,mBAAmB,EAAE,MAAM,CAAC;CAC7B"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 🦠 PROTOPLASM — types
|
|
3
|
+
*
|
|
4
|
+
* Live atom embedded in every function. Reports super_quan findings to
|
|
5
|
+
* orchestrator. Orchestrator decides: HEALTHY → crawl-and-learn,
|
|
6
|
+
* BROKEN → wisdom-space root-cause + heal.
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/protoplasm/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 🧬 PROTOPLASM — USB SOUL
|
|
3
|
+
*
|
|
4
|
+
* Write the WAL ledger + findings + HMAC key to a portable mount point
|
|
5
|
+
* (USB / SD card / network share). Plug into another machine → resume.
|
|
6
|
+
*
|
|
7
|
+
* Mount detection:
|
|
8
|
+
* - env MNEME_USB_SOUL_PATH=<path> (explicit override, recommended)
|
|
9
|
+
* - .mneme/usb_mount file (per-repo pinned mount)
|
|
10
|
+
* - autodetect: Windows D:/-Z:/ removable drives; macOS /Volumes; Linux /media+/mnt
|
|
11
|
+
*
|
|
12
|
+
* Sync:
|
|
13
|
+
* syncTo(path) — copy WAL + findings + (optionally encrypted) key
|
|
14
|
+
* syncFrom(path) — replay WAL from USB into local .mneme/protoplasm/
|
|
15
|
+
* verifyMount(p) — quick sanity (writable + has expected layout)
|
|
16
|
+
*
|
|
17
|
+
* Encryption: key file is HMAC-encrypted with passphrase when --encrypt flag.
|
|
18
|
+
* Without passphrase, key is stored plain (warning).
|
|
19
|
+
*/
|
|
20
|
+
export interface UsbSoulResult {
|
|
21
|
+
ok: boolean;
|
|
22
|
+
mount: string;
|
|
23
|
+
copied?: string[];
|
|
24
|
+
reason?: string;
|
|
25
|
+
bytesWritten?: number;
|
|
26
|
+
}
|
|
27
|
+
export declare function pickMount(): string | null;
|
|
28
|
+
export declare function verifyMount(mount: string): {
|
|
29
|
+
ok: boolean;
|
|
30
|
+
writable: boolean;
|
|
31
|
+
hasLayout: boolean;
|
|
32
|
+
};
|
|
33
|
+
export declare function syncTo(mount: string, ledgerDir: string, encryptPassphrase?: string): UsbSoulResult;
|
|
34
|
+
export declare function syncFrom(mount: string, ledgerDir: string): UsbSoulResult;
|
|
35
|
+
//# sourceMappingURL=usb_soul.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usb_soul.d.ts","sourceRoot":"","sources":["../../src/protoplasm/usb_soul.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AASH,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,OAAO,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AA2BD,wBAAgB,SAAS,IAAI,MAAM,GAAG,IAAI,CAWzC;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,OAAO,CAAA;CAAE,CAWjG;AAMD,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,iBAAiB,CAAC,EAAE,MAAM,GAAG,aAAa,CAkClG;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,aAAa,CAqBxE"}
|