@mikeargento/bitgraph-mcp 0.3.0 → 0.4.1
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 +8 -8
- package/dist/__tests__/format.test.js +24 -3
- package/dist/__tests__/format.test.js.map +1 -1
- package/dist/__tests__/scan.test.d.ts +2 -0
- package/dist/__tests__/scan.test.d.ts.map +1 -0
- package/dist/__tests__/scan.test.js +73 -0
- package/dist/__tests__/scan.test.js.map +1 -0
- package/dist/__tests__/tools.test.js +287 -84
- package/dist/__tests__/tools.test.js.map +1 -1
- package/dist/api.d.ts +18 -30
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +27 -50
- package/dist/api.js.map +1 -1
- package/dist/format.d.ts +36 -9
- package/dist/format.d.ts.map +1 -1
- package/dist/format.js +64 -29
- package/dist/format.js.map +1 -1
- package/dist/scan.d.ts +56 -0
- package/dist/scan.d.ts.map +1 -0
- package/dist/scan.js +158 -0
- package/dist/scan.js.map +1 -0
- package/dist/server.d.ts +51 -9
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +336 -113
- package/dist/server.js.map +1 -1
- package/dist/types.d.ts +19 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -3
- package/src/__tests__/format.test.ts +25 -3
- package/src/__tests__/scan.test.ts +80 -0
- package/src/__tests__/tools.test.ts +302 -97
- package/src/api.ts +36 -77
- package/src/format.ts +104 -37
- package/src/scan.ts +173 -0
- package/src/server.ts +410 -120
- package/src/types.ts +23 -1
package/dist/scan.js
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
// Copyright (c) 2024-2026 Mike Argento. Licensed under the MIT License. See LICENSE.
|
|
2
|
+
/**
|
|
3
|
+
* @mikeargento/bitgraph-mcp: the scan.
|
|
4
|
+
*
|
|
5
|
+
* One pass over each file yields its SHA-256 (the member's origin) and a
|
|
6
|
+
* hasher left open after the placement's prefix and the file's last byte, so
|
|
7
|
+
* the member's fused digest can be finished later, for whatever slot the set
|
|
8
|
+
* is made under, without reading the file again. A placement is prefix,
|
|
9
|
+
* original, suffix (its frame): trailer/1 has no prefix and container/2's is
|
|
10
|
+
* the original's tar header, which depends on the size alone; the suffix
|
|
11
|
+
* carries the commitment and is hashed at BitGraph time. Node's SHA-256 is
|
|
12
|
+
* the platform's own, and a Hash can be copied mid-stream, which is the whole
|
|
13
|
+
* trick: the copy takes the suffix, so no file is read twice or held in
|
|
14
|
+
* memory, and the original is never touched.
|
|
15
|
+
*/
|
|
16
|
+
import { createHash } from "node:crypto";
|
|
17
|
+
import { createReadStream } from "node:fs";
|
|
18
|
+
import { readdir, stat } from "node:fs/promises";
|
|
19
|
+
import { basename, join } from "node:path";
|
|
20
|
+
import { placementForBytes } from "@mikeargento/bitgraph";
|
|
21
|
+
import { getPlacement } from "@mikeargento/bitgraph-verify";
|
|
22
|
+
/** Bytes the placement decision reads: every magic number sits in the first 16. */
|
|
23
|
+
const SNIFF = 64;
|
|
24
|
+
/** Hash one file in a single pass. Throws, before any network call, when the path is not a regular file. */
|
|
25
|
+
export async function scanFile(path) {
|
|
26
|
+
const info = await stat(path);
|
|
27
|
+
if (!info.isFile())
|
|
28
|
+
throw new Error(`Not a regular file: ${path}`);
|
|
29
|
+
const size = info.size;
|
|
30
|
+
const origin = createHash("sha256");
|
|
31
|
+
// Held in one object: the closures below assign to it.
|
|
32
|
+
const run = { fused: null, placement: null };
|
|
33
|
+
let head = null;
|
|
34
|
+
let bytes = 0;
|
|
35
|
+
const start = (p) => {
|
|
36
|
+
run.placement = p;
|
|
37
|
+
// A second hasher runs over prefix and bytes when the prefix is not
|
|
38
|
+
// empty; with an empty prefix the origin hasher's own state is the fused state.
|
|
39
|
+
const prefix = getPlacement(p)?.scanPrefix?.(size) ?? null;
|
|
40
|
+
if (prefix !== null && prefix.length > 0)
|
|
41
|
+
run.fused = createHash("sha256").update(prefix);
|
|
42
|
+
};
|
|
43
|
+
const feed = (chunk) => {
|
|
44
|
+
origin.update(chunk);
|
|
45
|
+
if (run.fused !== null)
|
|
46
|
+
run.fused.update(chunk);
|
|
47
|
+
};
|
|
48
|
+
for await (const raw of createReadStream(path)) {
|
|
49
|
+
const chunk = raw;
|
|
50
|
+
if (run.placement === null) {
|
|
51
|
+
head = head === null ? chunk : Buffer.concat([head, chunk]);
|
|
52
|
+
if (head.length >= SNIFF) {
|
|
53
|
+
start(placementForBytes(new Uint8Array(head.subarray(0, SNIFF))));
|
|
54
|
+
feed(head);
|
|
55
|
+
head = null;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
feed(chunk);
|
|
60
|
+
}
|
|
61
|
+
bytes += chunk.length;
|
|
62
|
+
}
|
|
63
|
+
if (run.placement === null) {
|
|
64
|
+
// A short file: decide from what there is, then hash it.
|
|
65
|
+
start(placementForBytes(new Uint8Array(head ?? Buffer.alloc(0))));
|
|
66
|
+
if (head !== null)
|
|
67
|
+
feed(head);
|
|
68
|
+
}
|
|
69
|
+
const placement = run.placement;
|
|
70
|
+
const state = bytes !== size ? null : (run.fused ?? origin);
|
|
71
|
+
// When the origin hasher is the state its digest is taken from a copy, so it stays open.
|
|
72
|
+
const digest = state === origin ? origin.copy().digest() : origin.digest();
|
|
73
|
+
return {
|
|
74
|
+
path,
|
|
75
|
+
name: basename(path),
|
|
76
|
+
size,
|
|
77
|
+
digestB64: digest.toString("base64"),
|
|
78
|
+
originDigest: Uint8Array.from(digest),
|
|
79
|
+
placement,
|
|
80
|
+
state,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* A member's fused digest for a slot: the open hasher, copied, finished with
|
|
85
|
+
* the placement's suffix for that slot's commitment. The hash of prefix,
|
|
86
|
+
* original, suffix is exactly the hash of the placement's own build, which
|
|
87
|
+
* a test pins.
|
|
88
|
+
*/
|
|
89
|
+
export function fusedDigestFor(file, commitment) {
|
|
90
|
+
if (file.state === null)
|
|
91
|
+
throw new Error(`${file.path}: the file changed while it was read`);
|
|
92
|
+
const placement = getPlacement(file.placement);
|
|
93
|
+
if (placement?.frame === undefined)
|
|
94
|
+
throw new Error(`placement ${file.placement} has no frame`);
|
|
95
|
+
const { suffix } = placement.frame({ originalSize: file.size, originDigest: file.originDigest, commitment });
|
|
96
|
+
return Uint8Array.from(file.state.copy().update(suffix).digest());
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Paths to files: a regular file is itself; a directory is every regular
|
|
100
|
+
* file under it, recursively, with hidden entries (names starting with a
|
|
101
|
+
* dot) and symbolic links left out. The same file twice is one file. A path
|
|
102
|
+
* that is missing or neither kind, or more than `limit` files in all, throws
|
|
103
|
+
* before any network call; the message names every path that failed.
|
|
104
|
+
*/
|
|
105
|
+
export async function expandPaths(paths, limit) {
|
|
106
|
+
const files = [];
|
|
107
|
+
const seen = new Set();
|
|
108
|
+
const failures = [];
|
|
109
|
+
let directories = 0;
|
|
110
|
+
const push = (p) => {
|
|
111
|
+
if (seen.has(p))
|
|
112
|
+
return;
|
|
113
|
+
seen.add(p);
|
|
114
|
+
files.push(p);
|
|
115
|
+
if (files.length > limit)
|
|
116
|
+
throw new Error(`more than ${limit} files; BitGraph fewer at a time`);
|
|
117
|
+
};
|
|
118
|
+
const walk = async (dir) => {
|
|
119
|
+
const entries = (await readdir(dir, { withFileTypes: true }))
|
|
120
|
+
.filter((e) => !e.name.startsWith("."))
|
|
121
|
+
.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));
|
|
122
|
+
for (const e of entries) {
|
|
123
|
+
const full = join(dir, e.name);
|
|
124
|
+
if (e.isSymbolicLink())
|
|
125
|
+
continue;
|
|
126
|
+
if (e.isDirectory())
|
|
127
|
+
await walk(full);
|
|
128
|
+
else if (e.isFile())
|
|
129
|
+
push(full);
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
for (const p of paths) {
|
|
133
|
+
try {
|
|
134
|
+
const info = await stat(p);
|
|
135
|
+
if (info.isDirectory()) {
|
|
136
|
+
directories += 1;
|
|
137
|
+
await walk(p);
|
|
138
|
+
}
|
|
139
|
+
else if (info.isFile()) {
|
|
140
|
+
push(p);
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
throw new Error("not a regular file or a directory");
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
catch (err) {
|
|
147
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
148
|
+
if (message.startsWith("more than "))
|
|
149
|
+
throw err;
|
|
150
|
+
failures.push(`${p}: ${message}`);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
if (failures.length > 0) {
|
|
154
|
+
throw new Error(`Could not read ${failures.length} path(s); nothing was BitGraphed.\n${failures.join("\n")}\nUse absolute paths to existing regular files or directories.`);
|
|
155
|
+
}
|
|
156
|
+
return { files, directories };
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=scan.js.map
|
package/dist/scan.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scan.js","sourceRoot":"","sources":["../src/scan.ts"],"names":[],"mappings":"AAAA,qFAAqF;AAErF;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,UAAU,EAAa,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAqB5D,mFAAmF;AACnF,MAAM,KAAK,GAAG,EAAE,CAAC;AAEjB,4GAA4G;AAC5G,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,IAAY;IACzC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9B,IAAI,CAAC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AI,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;gBACzB,IAAI,CAAC,CAAC,CAAC,CAAC;YACV,CAAC;iBAAM,CAAC;gBACN,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;YACvD,CAAC;QACH,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,OAAO,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACjE,IAAI,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC;gBAAE,MAAM,GAAG,CAAC;YAChD,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,OAAO,EAAE,CAAC,CAAC;QACpC,CAAC;IACH,CAAC;IACD,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,kBAAkB,QAAQ,CAAC,MAAM,sCAAsC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,gEAAgE,CAAC,CAAC;IAC9K,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC;AAChC,CAAC"}
|
package/dist/server.d.ts
CHANGED
|
@@ -1,17 +1,55 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @mikeargento/bitgraph-mcp: tool definitions.
|
|
3
3
|
*
|
|
4
|
-
* Three gestures, the same three the website has: make a BitGraph
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
4
|
+
* Three gestures, the same three the website has: make a BitGraph, check
|
|
5
|
+
* whether bytes are on record, fetch a proof. Making a BitGraph is one
|
|
6
|
+
* gesture for any number of files, the way a drop on the site is: a single
|
|
7
|
+
* file is fused on its own slot, and two or more become members of ONE set
|
|
8
|
+
* under ONE slot. For a set each file is read once, on this machine, for its
|
|
9
|
+
* digest and a hasher state; the new fused bytes are never written and never
|
|
10
|
+
* held, their digest is finished from that state once the slot exists; and
|
|
11
|
+
* the set's committed artifact is hashed and committed under the same slot.
|
|
12
|
+
* Only digests, that artifact and slot records leave the machine. File
|
|
13
|
+
* contents are never uploaded and files are never modified.
|
|
9
14
|
*/
|
|
10
15
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
16
|
+
import { type FuseSetProgress } from "@mikeargento/bitgraph";
|
|
11
17
|
import { type ApiConfig } from "./api.js";
|
|
18
|
+
import { type ScannedFile } from "./scan.js";
|
|
12
19
|
import type { BitGraphProof } from "./types.js";
|
|
13
|
-
export declare const SERVER_VERSION = "0.
|
|
14
|
-
/**
|
|
20
|
+
export declare const SERVER_VERSION = "0.4.1";
|
|
21
|
+
/** Files one call may BitGraph after directories expand: one set. The site's own ceiling for a set/2. */
|
|
22
|
+
export declare const MAX_MEMBERS = 100000;
|
|
23
|
+
/** Rows the structured result lists in full; every fused row shares the set's position. */
|
|
24
|
+
export declare const ROW_CAP = 500;
|
|
25
|
+
/** Members' evidence per set-index request: the site's own chunk. */
|
|
26
|
+
export declare const SET_INDEX_CHUNK = 2500;
|
|
27
|
+
/** What one set yields, in the shape the tool reports; tests inject a stand-in. */
|
|
28
|
+
export interface SetSummary {
|
|
29
|
+
set: "set/1" | "set/2";
|
|
30
|
+
proof: BitGraphProof;
|
|
31
|
+
/** Standard base64: the committed artifact's digest. */
|
|
32
|
+
artifactDigestB64: string;
|
|
33
|
+
count: number;
|
|
34
|
+
manifestEchoed: boolean;
|
|
35
|
+
recovered: boolean;
|
|
36
|
+
/** In the order the files were given. */
|
|
37
|
+
members: Array<{
|
|
38
|
+
index: number;
|
|
39
|
+
/** The row's ordinal in the committed artifact. */
|
|
40
|
+
manifestIndex: number;
|
|
41
|
+
placement: string;
|
|
42
|
+
originDigestB64: string;
|
|
43
|
+
artifactDigestB64: string;
|
|
44
|
+
/** set/2 only: the member's evidence, for the site's index. */
|
|
45
|
+
memberProof?: unknown;
|
|
46
|
+
}>;
|
|
47
|
+
}
|
|
48
|
+
export type FuseSetFn = (files: readonly ScannedFile[], config: ApiConfig, opts: {
|
|
49
|
+
set: "set/1" | "set/2";
|
|
50
|
+
onProgress?: (p: FuseSetProgress) => void;
|
|
51
|
+
}) => Promise<SetSummary>;
|
|
52
|
+
/** What fusing one file on its own yields. */
|
|
15
53
|
export interface FusedSummary {
|
|
16
54
|
proof: BitGraphProof;
|
|
17
55
|
frame: unknown;
|
|
@@ -19,10 +57,14 @@ export interface FusedSummary {
|
|
|
19
57
|
artifactDigestB64: string;
|
|
20
58
|
originDigestB64: string;
|
|
21
59
|
}
|
|
22
|
-
export type FuseFileFn = (
|
|
60
|
+
export type FuseFileFn = (file: ScannedFile, config: ApiConfig) => Promise<FusedSummary>;
|
|
23
61
|
export interface ServerDeps {
|
|
24
|
-
/** The
|
|
62
|
+
/** The set pipeline; tests inject a stand-in. Default: the core package's fuseSet() against the configured site. */
|
|
63
|
+
fuseSet?: FuseSetFn;
|
|
64
|
+
/** The single-file pipeline; tests inject a stand-in. Default: the core package's fuse() against the configured site. */
|
|
25
65
|
fuseFile?: FuseFileFn;
|
|
26
66
|
}
|
|
67
|
+
/** How many members' evidence is waiting to be indexed (tests read it). */
|
|
68
|
+
export declare function pendingIndexCount(): number;
|
|
27
69
|
export declare function buildServer(deps?: ServerDeps): McpServer;
|
|
28
70
|
//# sourceMappingURL=server.d.ts.map
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAKpE,OAAO,EAA4F,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACvJ,OAAO,EAOL,KAAK,SAAS,EACf,MAAM,UAAU,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