@ceccec/millennium-solutions 9.7.4 → 9.8.2
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/README.md +299 -100
- package/dist/data/discovered.json +148928 -0
- package/dist/data/formulas.jsonld +468319 -0
- package/dist/mcp.bin.d.ts +2 -0
- package/dist/mcp.bin.js +63 -0
- package/dist/src/0/index.d.ts +3 -0
- package/dist/src/0/index.js +9 -5
- package/dist/src/face/index.d.ts +41 -0
- package/dist/src/face/index.js +32 -0
- package/dist/src/handle/index.d.ts +9 -0
- package/dist/src/handle/index.js +10 -0
- package/dist/src/mcp/index.d.ts +707 -0
- package/dist/src/mcp/index.js +112 -0
- package/dist/src/mcp/serve.d.ts +90 -0
- package/dist/src/mcp/serve.js +217 -0
- package/dist/src/the/rosetta/index.d.ts +3 -0
- package/dist/src/the/rosetta/index.js +25 -0
- package/package.json +68 -29
package/dist/mcp.bin.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createInterface } from 'node:readline';
|
|
3
|
+
import { readFileSync, existsSync } from 'node:fs';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { dirname, join } from 'node:path';
|
|
6
|
+
import { run, served, withLedger, withFormulas } from './src/mcp/serve.js';
|
|
7
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
8
|
+
for (const p of [join(here, 'data', 'discovered.json'), join(here, '..', 'src', 'proof', 'discovered.json')]) {
|
|
9
|
+
if (!existsSync(p))
|
|
10
|
+
continue;
|
|
11
|
+
try {
|
|
12
|
+
withLedger(JSON.parse(readFileSync(p, 'utf8')));
|
|
13
|
+
break;
|
|
14
|
+
}
|
|
15
|
+
catch { }
|
|
16
|
+
}
|
|
17
|
+
for (const p of [join(here, 'data', 'formulas.jsonld'), join(here, '..', 'public', 'formulas.jsonld')]) {
|
|
18
|
+
if (!existsSync(p))
|
|
19
|
+
continue;
|
|
20
|
+
try {
|
|
21
|
+
const j = JSON.parse(readFileSync(p, 'utf8'));
|
|
22
|
+
const rows = (j.itemListElement ?? []).map((e) => {
|
|
23
|
+
const i = (e.item ?? e);
|
|
24
|
+
return { name: i.name, statement: i.description, key: i.identifier, source: i.source, wing: i.wing, proof: i.proof };
|
|
25
|
+
}).filter((r) => r.name);
|
|
26
|
+
if (rows.length) {
|
|
27
|
+
withFormulas(rows);
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
catch { }
|
|
32
|
+
}
|
|
33
|
+
const send = (m) => process.stdout.write(JSON.stringify(m) + '\n');
|
|
34
|
+
const rl = createInterface({ input: process.stdin });
|
|
35
|
+
rl.on('line', (line) => {
|
|
36
|
+
if (!line.trim())
|
|
37
|
+
return;
|
|
38
|
+
let id = null;
|
|
39
|
+
try {
|
|
40
|
+
const req = JSON.parse(line);
|
|
41
|
+
id = req.id ?? null;
|
|
42
|
+
const ok = (result) => send({ jsonrpc: '2.0', id, result });
|
|
43
|
+
if (req.method === 'initialize') {
|
|
44
|
+
return ok({ protocolVersion: '2024-11-05', capabilities: { tools: {} },
|
|
45
|
+
serverInfo: { name: 'millennium-solutions (self-sufficient entry)', version: 'from the published package' } });
|
|
46
|
+
}
|
|
47
|
+
if (req.method === 'tools/list') {
|
|
48
|
+
return ok({ tools: [
|
|
49
|
+
{ name: 'list_tools', description: 'What this entry serves, and what each tool it does not serve needs instead.', inputSchema: { type: 'object', properties: { name: { type: 'string' } } } },
|
|
50
|
+
{ name: 'call_tool', description: 'Call one of the served tools.', inputSchema: { type: 'object', properties: { name: { type: 'string', enum: served() }, arguments: { type: 'object' } }, required: ['name'] } },
|
|
51
|
+
] });
|
|
52
|
+
}
|
|
53
|
+
if (req.method === 'tools/call') {
|
|
54
|
+
return ok({ content: [{ type: 'text', text: run(String(req.params?.name ?? ''), req.params?.arguments ?? {}) }] });
|
|
55
|
+
}
|
|
56
|
+
if (req.method?.startsWith('notifications/'))
|
|
57
|
+
return;
|
|
58
|
+
send({ jsonrpc: '2.0', id, error: { code: -32601, message: `method not found: ${String(req.method)}` } });
|
|
59
|
+
}
|
|
60
|
+
catch (e) {
|
|
61
|
+
send({ jsonrpc: '2.0', id, error: { code: -32603, message: e instanceof Error ? e.message : String(e) } });
|
|
62
|
+
}
|
|
63
|
+
});
|
package/dist/src/0/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export declare function toUuid(seed: string): string;
|
|
2
2
|
export declare function strictUuidna(value: unknown): string;
|
|
3
3
|
export declare function merge(a: string, b: string): string;
|
|
4
|
+
export declare const merkleLeaf: (x: string) => string;
|
|
5
|
+
export declare const merkleNode: (a: string, b: string) => string;
|
|
4
6
|
export declare function gcdBigInt(a: bigint, b: bigint): bigint;
|
|
5
7
|
export declare function foldPair(a: string, b: string): {
|
|
6
8
|
forward: string;
|
|
@@ -31,3 +33,4 @@ export declare function units(): number[];
|
|
|
31
33
|
export declare function triad(): number[];
|
|
32
34
|
export declare function vortexOrbit(): number[];
|
|
33
35
|
export declare const A432_STEP: number;
|
|
36
|
+
export declare const hue: (d: number) => number;
|
package/dist/src/0/index.js
CHANGED
|
@@ -48,9 +48,12 @@ export function toUuid(seed) {
|
|
|
48
48
|
export function strictUuidna(value) {
|
|
49
49
|
return toUuid('uuidna:' + String(value).normalize('NFC').trim());
|
|
50
50
|
}
|
|
51
|
+
const part = (s) => `${s.length}:${s}`;
|
|
51
52
|
export function merge(a, b) {
|
|
52
|
-
return toUuid(
|
|
53
|
+
return toUuid(`pair:${part(a)}${part(b)}`);
|
|
53
54
|
}
|
|
55
|
+
export const merkleLeaf = (x) => toUuid(`merkle:leaf:${part(x)}`);
|
|
56
|
+
export const merkleNode = (a, b) => toUuid(`merkle:node:${part(a)}${part(b)}`);
|
|
54
57
|
export function gcdBigInt(a, b) {
|
|
55
58
|
return b === 0n ? a : gcdBigInt(b, a % b);
|
|
56
59
|
}
|
|
@@ -60,15 +63,15 @@ export function foldPair(a, b) {
|
|
|
60
63
|
return { forward, reverse, bidirectional: forward !== reverse, merged: merge(forward, reverse) };
|
|
61
64
|
}
|
|
62
65
|
export function merkleFold(leaves) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
+
if (leaves.length === 0)
|
|
67
|
+
return toUuid('merkle:empty');
|
|
68
|
+
let layer = [...leaves].sort().map(merkleLeaf);
|
|
66
69
|
while (layer.length > 1) {
|
|
67
70
|
const next = [];
|
|
68
71
|
for (let i = 0; i < layer.length; i += 2) {
|
|
69
72
|
const a = layer[i];
|
|
70
73
|
const b = layer[i + 1];
|
|
71
|
-
next.push(b === undefined ? a :
|
|
74
|
+
next.push(b === undefined ? a : merkleNode(a, b));
|
|
72
75
|
}
|
|
73
76
|
layer = next;
|
|
74
77
|
}
|
|
@@ -135,3 +138,4 @@ export function vortexOrbit() {
|
|
|
135
138
|
return orbit;
|
|
136
139
|
}
|
|
137
140
|
export const A432_STEP = 360 / BASE;
|
|
141
|
+
export const hue = (d) => (d * A432_STEP) % 360;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export type Metric = {
|
|
2
|
+
key: string;
|
|
3
|
+
claim: string;
|
|
4
|
+
value: string;
|
|
5
|
+
command: string;
|
|
6
|
+
receipt: string;
|
|
7
|
+
};
|
|
8
|
+
export type Face = {
|
|
9
|
+
repo: string;
|
|
10
|
+
definition: string;
|
|
11
|
+
protocol?: unknown;
|
|
12
|
+
generatedFrom?: string;
|
|
13
|
+
specWitness?: {
|
|
14
|
+
seed: string;
|
|
15
|
+
receipt: string;
|
|
16
|
+
};
|
|
17
|
+
rows: Metric[];
|
|
18
|
+
root: string;
|
|
19
|
+
};
|
|
20
|
+
export declare const PROTOCOL: {
|
|
21
|
+
readonly id: 'millennium-solutions/metric-face/2';
|
|
22
|
+
readonly covers: readonly ['key', 'claim', 'value', 'command'];
|
|
23
|
+
readonly chained: false;
|
|
24
|
+
readonly receipt: 'toUuid(key + LF + claim + LF + value + LF + command)';
|
|
25
|
+
readonly merge: "toUuid(utf8(a + ':' + b)) — COLON U+003A";
|
|
26
|
+
readonly address: string;
|
|
27
|
+
readonly specWitness: 'see the specWitness field on the face itself: the verbatim seed of row 0 and its receipt';
|
|
28
|
+
readonly root: string;
|
|
29
|
+
readonly orderInvariant: true;
|
|
30
|
+
};
|
|
31
|
+
export declare const protocolId: (p: unknown) => string;
|
|
32
|
+
export declare const receiptOf: (key: string, claim: string, value: string, command?: string) => string;
|
|
33
|
+
export declare const rootOf: (rows: Metric[]) => string;
|
|
34
|
+
export type Verdict = 'intact' | 'altered' | 'different-convention';
|
|
35
|
+
export declare function checkFace(f: Face): {
|
|
36
|
+
verdict: Verdict;
|
|
37
|
+
ok: boolean;
|
|
38
|
+
altered: string[];
|
|
39
|
+
root: string;
|
|
40
|
+
failingGates: string[];
|
|
41
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { toUuid, merkleFold } from '../0/index.js';
|
|
2
|
+
export const PROTOCOL = {
|
|
3
|
+
id: 'millennium-solutions/metric-face/2',
|
|
4
|
+
covers: ['key', 'claim', 'value', 'command'],
|
|
5
|
+
chained: false,
|
|
6
|
+
receipt: 'toUuid(key + LF + claim + LF + value + LF + command)',
|
|
7
|
+
merge: "toUuid(utf8(a + ':' + b)) — COLON U+003A",
|
|
8
|
+
address: 'uuidv8 shaped per RFC 9562 §5.8 (version nibble 8, variant 10x) over FNV-1a — NOT SHA-2: '
|
|
9
|
+
+ 'four 32-bit FNV-1a passes over the UTF-16 code units, each starting at the FNV OFFSET BASIS 0x811c9dc5 '
|
|
10
|
+
+ 'XOR the pass seed — seeds 0, 0x9e3779b9, 0x243f6a88, 0xb7e15162, so h begins at (0x811c9dc5 ^ seed) and '
|
|
11
|
+
+ 'NOT at the seed itself, which is the one line an implementer cannot guess. '
|
|
12
|
+
+ 'with an xor-shift-13 per code unit and a two-round murmur finalizer (0x85ebca6b, 0xc2b2ae35, then >>> 16), '
|
|
13
|
+
+ 'concatenated big-endian to 16 octets. Non-cryptographic: integrity against accident, not against an '
|
|
14
|
+
+ 'adversary.',
|
|
15
|
+
specWitness: 'see the specWitness field on the face itself: the verbatim seed of row 0 and its receipt',
|
|
16
|
+
root: 'merkleFold: leaves sorted lexicographically, then pairwise merge up the tree; an odd element '
|
|
17
|
+
+ "carries up unchanged; zero rows fold to toUuid('empty-mind')",
|
|
18
|
+
orderInvariant: true,
|
|
19
|
+
};
|
|
20
|
+
export const protocolId = (p) => typeof p === 'string' ? p : (p && typeof p === 'object' && 'id' in p ? String(p.id) : '(none declared)');
|
|
21
|
+
export const receiptOf = (key, claim, value, command = '') => toUuid(key + '\n' + claim + '\n' + value + '\n' + command);
|
|
22
|
+
export const rootOf = (rows) => merkleFold(rows.map((r) => r.receipt));
|
|
23
|
+
export function checkFace(f) {
|
|
24
|
+
const altered = f.rows.filter((r) => receiptOf(r.key, r.claim, r.value, r.command) !== r.receipt).map((r) => r.key);
|
|
25
|
+
const root = rootOf(f.rows);
|
|
26
|
+
const rootMatches = root === f.root;
|
|
27
|
+
const wholesale = f.rows.length > 1 && altered.length === f.rows.length && !rootMatches;
|
|
28
|
+
const stated = f.protocol !== undefined && protocolId(f.protocol) !== PROTOCOL.id;
|
|
29
|
+
const verdict = altered.length === 0 && rootMatches ? 'intact'
|
|
30
|
+
: (wholesale || stated) ? 'different-convention' : 'altered';
|
|
31
|
+
return { verdict, ok: verdict === 'intact', altered, root, failingGates: f.rows.filter((r) => r.value === 'FAIL').map((r) => r.key) };
|
|
32
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const HANDLE_HEX = 4;
|
|
2
|
+
export declare const HANDLE_OFFSET = 0;
|
|
3
|
+
export declare const handleOf: (uuid: string) => string;
|
|
4
|
+
export declare const handle: (message: string) => string;
|
|
5
|
+
export declare const carries: (h: string, message: string) => boolean;
|
|
6
|
+
export declare const resolve: (h: string, message: string) => {
|
|
7
|
+
uuid: string;
|
|
8
|
+
carries: boolean;
|
|
9
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { toUuid } from '../0/index.js';
|
|
2
|
+
export const HANDLE_HEX = 4;
|
|
3
|
+
export const HANDLE_OFFSET = 0;
|
|
4
|
+
export const handleOf = (uuid) => uuid.replace(/-/g, '').slice(HANDLE_OFFSET, HANDLE_OFFSET + HANDLE_HEX);
|
|
5
|
+
export const handle = (message) => handleOf(toUuid(message));
|
|
6
|
+
export const carries = (h, message) => handle(message) === h.toLowerCase();
|
|
7
|
+
export const resolve = (h, message) => {
|
|
8
|
+
const uuid = toUuid(message);
|
|
9
|
+
return { uuid, carries: handleOf(uuid) === h.toLowerCase() };
|
|
10
|
+
};
|