@mikeargento/bitgraph-mcp 0.7.0 → 0.8.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/scan.js DELETED
@@ -1,201 +0,0 @@
1
- // Copyright (c) 2024-2026 Argento Computing Inc. 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
- /**
23
- * Content Credentials detection, structural and cheap: a C2PA manifest lives
24
- * in a JUMBF box whose description ("jumd") is followed within a few bytes by
25
- * the store label "c2pa", in every container (JPEG APP11, PNG caBX, ISO BMFF).
26
- * Requiring the pair in order and near each other keeps a stray "c2pa" in
27
- * prose from counting. Detection, not judgment: the proof page parses and
28
- * displays the manifest itself.
29
- */
30
- const JUMD = Buffer.from("jumd", "ascii");
31
- const C2PA_LABEL = Buffer.from("c2pa", "ascii");
32
- const C2PA_NEAR = 96;
33
- function windowHasC2pa(buf) {
34
- for (let i = buf.indexOf(JUMD); i !== -1; i = buf.indexOf(JUMD, i + 1)) {
35
- const from = i + JUMD.length;
36
- const to = Math.min(buf.length, i + C2PA_NEAR);
37
- if (buf.subarray(from, to).indexOf(C2PA_LABEL) !== -1)
38
- return true;
39
- }
40
- return false;
41
- }
42
- class C2paSniffer {
43
- found = false;
44
- /** The last C2PA_NEAR + 4 bytes of the previous chunk, so a pair split across chunks is seen whole. */
45
- carry = Buffer.alloc(0);
46
- update(chunk) {
47
- if (this.found)
48
- return;
49
- const buf = this.carry.length > 0 ? Buffer.concat([this.carry, chunk]) : chunk;
50
- if (windowHasC2pa(buf)) {
51
- this.found = true;
52
- return;
53
- }
54
- const keep = Math.min(buf.length, C2PA_NEAR + JUMD.length);
55
- this.carry = Buffer.from(buf.subarray(buf.length - keep));
56
- }
57
- }
58
- /** One-shot form for bytes already in memory (a carrier's committed bytes). */
59
- export function sniffC2paBytes(bytes) {
60
- return windowHasC2pa(Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength));
61
- }
62
- /** Bytes the placement decision reads: every magic number sits in the first 16. */
63
- const SNIFF = 64;
64
- /** Hash one file in a single pass. Throws, before any network call, when the path is not a regular file. */
65
- export async function scanFile(path) {
66
- const info = await stat(path);
67
- if (!info.isFile())
68
- throw new Error(`Not a regular file: ${path}`);
69
- const size = info.size;
70
- const origin = createHash("sha256");
71
- // Held in one object: the closures below assign to it.
72
- const run = { fused: null, placement: null };
73
- let head = null;
74
- let bytes = 0;
75
- const start = (p) => {
76
- run.placement = p;
77
- // A second hasher runs over prefix and bytes when the prefix is not
78
- // empty; with an empty prefix the origin hasher's own state is the fused state.
79
- const prefix = getPlacement(p)?.scanPrefix?.(size) ?? null;
80
- if (prefix !== null && prefix.length > 0)
81
- run.fused = createHash("sha256").update(prefix);
82
- };
83
- const sniffer = new C2paSniffer();
84
- const feed = (chunk) => {
85
- origin.update(chunk);
86
- if (run.fused !== null)
87
- run.fused.update(chunk);
88
- sniffer.update(chunk);
89
- };
90
- for await (const raw of createReadStream(path)) {
91
- const chunk = raw;
92
- if (run.placement === null) {
93
- head = head === null ? chunk : Buffer.concat([head, chunk]);
94
- if (head.length >= SNIFF) {
95
- start(placementForBytes(new Uint8Array(head.subarray(0, SNIFF))));
96
- feed(head);
97
- head = null;
98
- }
99
- }
100
- else {
101
- feed(chunk);
102
- }
103
- bytes += chunk.length;
104
- }
105
- if (run.placement === null) {
106
- // A short file: decide from what there is, then hash it.
107
- start(placementForBytes(new Uint8Array(head ?? Buffer.alloc(0))));
108
- if (head !== null)
109
- feed(head);
110
- }
111
- const placement = run.placement;
112
- const state = bytes !== size ? null : (run.fused ?? origin);
113
- // When the origin hasher is the state its digest is taken from a copy, so it stays open.
114
- const digest = state === origin ? origin.copy().digest() : origin.digest();
115
- return {
116
- path,
117
- name: basename(path),
118
- size,
119
- digestB64: digest.toString("base64"),
120
- originDigest: Uint8Array.from(digest),
121
- placement,
122
- state,
123
- c2pa: sniffer.found,
124
- };
125
- }
126
- /**
127
- * A member's fused digest for a slot: the open hasher, copied, finished with
128
- * the placement's suffix for that slot's commitment. The hash of prefix,
129
- * original, suffix is exactly the hash of the placement's own build, which
130
- * a test pins.
131
- */
132
- export function fusedDigestFor(file, commitment) {
133
- if (file.state === null)
134
- throw new Error(`${file.path}: the file changed while it was read`);
135
- const placement = getPlacement(file.placement);
136
- if (placement?.frame === undefined)
137
- throw new Error(`placement ${file.placement} has no frame`);
138
- const { suffix } = placement.frame({ originalSize: file.size, originDigest: file.originDigest, commitment });
139
- return Uint8Array.from(file.state.copy().update(suffix).digest());
140
- }
141
- /**
142
- * Paths to files: a regular file is itself; a directory is every regular
143
- * file under it, recursively, with hidden entries (names starting with a
144
- * dot) and symbolic links left out. The same file twice is one file. A path
145
- * that is missing or neither kind, or more than `limit` files in all, throws
146
- * before any network call; the message names every path that failed.
147
- */
148
- export async function expandPaths(paths, limit) {
149
- const files = [];
150
- const seen = new Set();
151
- const failures = [];
152
- let directories = 0;
153
- const push = (p) => {
154
- if (seen.has(p))
155
- return;
156
- seen.add(p);
157
- files.push(p);
158
- if (files.length > limit)
159
- throw new Error(`more than ${limit} files; BitGraph fewer at a time`);
160
- };
161
- const walk = async (dir) => {
162
- const entries = (await readdir(dir, { withFileTypes: true }))
163
- .filter((e) => !e.name.startsWith("."))
164
- .sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));
165
- for (const e of entries) {
166
- const full = join(dir, e.name);
167
- if (e.isSymbolicLink())
168
- continue;
169
- if (e.isDirectory())
170
- await walk(full);
171
- else if (e.isFile())
172
- push(full);
173
- }
174
- };
175
- for (const p of paths) {
176
- try {
177
- const info = await stat(p);
178
- if (info.isDirectory()) {
179
- directories += 1;
180
- await walk(p);
181
- }
182
- else if (info.isFile()) {
183
- push(p);
184
- }
185
- else {
186
- throw new Error("not a regular file or a directory");
187
- }
188
- }
189
- catch (err) {
190
- const message = err instanceof Error ? err.message : String(err);
191
- if (message.startsWith("more than "))
192
- throw err;
193
- failures.push(`${p}: ${message}`);
194
- }
195
- }
196
- if (failures.length > 0) {
197
- 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.`);
198
- }
199
- return { files, directories };
200
- }
201
- //# sourceMappingURL=scan.js.map
package/dist/scan.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"scan.js","sourceRoot":"","sources":["../src/scan.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAE9F;;;;;;;;;;;;;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;AAuB5D;;;;;;;GAOG;AACH,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;A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AAC,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/task.d.ts DELETED
@@ -1,55 +0,0 @@
1
- import type { BitGraphProof, SlotAllocation } from "@mikeargento/bitgraph-verify";
2
- import { type ApiConfig } from "./api.js";
3
- export declare const SLOT_TTL_SECONDS = 120;
4
- export interface TaskState {
5
- v: 1;
6
- task: true;
7
- slot: SlotAllocation;
8
- }
9
- export declare function encodeTaskToken(state: TaskState): string;
10
- export declare function decodeTaskToken(token: string): TaskState | null;
11
- export interface Begun {
12
- token: string;
13
- /** Unpadded base64url: the string to put into the task. */
14
- commitment: string;
15
- commitmentB64: string;
16
- slotCounter: string;
17
- epoch: string;
18
- floor: {
19
- block: number;
20
- } | null;
21
- }
22
- /** Step one of the task form: a held slot and its commitment, before any work exists. */
23
- export declare function beginTask(config: ApiConfig): Promise<Begun>;
24
- export interface SealedTask {
25
- proof: BitGraphProof;
26
- artifactDigestB64: string;
27
- /** Byte offsets of the commitment string inside the task bytes, when the bytes were given. */
28
- offsets: number[] | null;
29
- }
30
- /**
31
- * Step two: the task bytes (a path, or the bytes themselves) sealed under
32
- * the held slot with the inline marker. When the bytes are in hand the
33
- * commitment is looked for BEFORE the commit, so a task that does not carry
34
- * it is refused without spending the slot.
35
- */
36
- export declare function sealTask(config: ApiConfig, state: TaskState, task: {
37
- path: string;
38
- } | {
39
- bytes: Uint8Array;
40
- } | {
41
- digestB64: string;
42
- }): Promise<SealedTask>;
43
- export declare const TASK_INSTRUCTIONS: string;
44
- /**
45
- * Write a sealed task's proof beside the file it is about, whole, and say
46
- * where. `make_task.txt` gets `make_task.proof.json`; a name already taken
47
- * gets the position's counter in it rather than being overwritten.
48
- *
49
- * ⚠️ THE SERVER WRITES IT, NOT THE AGENT. Handed the JSON to save, an agent
50
- * tidied it and dropped slotAllocation and environment, and the signature
51
- * had no body left to be checked against (Grok, 2026-09-13). A file this
52
- * process writes is the proof exactly as the boundary returned it.
53
- */
54
- export declare function writeProofBeside(sealedPath: string, proof: BitGraphProof): Promise<string>;
55
- //# sourceMappingURL=task.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"task.d.ts","sourceRoot":"","sources":["../src/task.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAClF,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,UAAU,CAAC;AAGpD,eAAO,MAAM,gBAAgB,MAAM,CAAC;AAKpC,MAAM,WAAW,SAAS;IACxB,CAAC,EAAE,CAAC,CAAC;IACL,IAAI,EAAE,IAAI,CAAC;IACX,IAAI,EAAE,cAAc,CAAC;CACtB;AASD,wBAAgB,eAAe,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CAExD;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAO/D;AAkBD,MAAM,WAAW,KAAK;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,2DAA2D;IAC3D,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;CACjC;AAED,yFAAyF;AACzF,wBAAsB,SAAS,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,KAAK,CAAC,CAcjE;AAED,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,aAAa,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,8FAA8F;IAC9F,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;CAC1B;AAED;;;;;GAKG;AACH,wBAAsB,QAAQ,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,UAAU,CAAA;CAAE,GAAG;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CA4B/J;AAkBD,eAAO,MAAM,iBAAiB,QAK0J,CAAC;AAEzL;;;;;;;;;GASG;AACH,wBAAsB,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,CAWhG"}
package/dist/task.js DELETED
@@ -1,182 +0,0 @@
1
- // Copyright (c) 2024-2026 Argento Computing Inc. Licensed under the MIT License. See LICENSE.
2
- /**
3
- * A position BEFORE the work: the task form of the stdio server.
4
- *
5
- * bitgraph_open with no files asks the site's own /api/fuse/allocate for a
6
- * slot and returns its commitment, and nothing else. The caller puts the
7
- * commitment into the task it is about to run (the prompt, the request, a
8
- * seed, a line in the document) and, within the slot's life, commits the
9
- * digest of those task bytes under the slot with the inline marker
10
- * (bitgraph-fuse/1, title base64url): a verifier recomputes the commitment
11
- * from the slot record and finds its base64url text inside the bytes.
12
- * Outputs are recorded afterwards with bitgraph_record and sit later.
13
- *
14
- * The slot allocation and the commit go through the same two site routes
15
- * the core package's fuse() uses; the recovery rule is the core's (read back
16
- * by digest, refuse a proof under any other slot).
17
- */
18
- import { readFile } from "node:fs/promises";
19
- import { createHash } from "node:crypto";
20
- import { bytesToBase64, computeSlotCommitment, findCommitment, inlineAttribution, verifyProofIntegrity, ENCODING_BASE64URL } from "@mikeargento/bitgraph-verify";
21
- import { ApiError } from "./api.js";
22
- import { toUrlSafeB64 } from "./encoding.js";
23
- export const SLOT_TTL_SECONDS = 120;
24
- const CHAIN = "bitgraph:main";
25
- const B64_32 = /^[A-Za-z0-9+/]{43}=$/;
26
- const B64_64 = /^[A-Za-z0-9+/]{86}==$/;
27
- function isSlotRecord(x) {
28
- if (x === null || typeof x !== "object" || Array.isArray(x))
29
- return false;
30
- const s = x;
31
- return s.version === "bitgraph/slot/1" && typeof s.nonceB64 === "string" && B64_32.test(s.nonceB64) && typeof s.counter === "string" && /^(0|[1-9][0-9]*)$/.test(s.counter)
32
- && typeof s.epochId === "string" && typeof s.publicKeyB64 === "string" && typeof s.signatureB64 === "string" && B64_64.test(s.signatureB64) && s.chainId === CHAIN;
33
- }
34
- export function encodeTaskToken(state) {
35
- return Buffer.from(JSON.stringify(state), "utf8").toString("base64url");
36
- }
37
- export function decodeTaskToken(token) {
38
- let parsed;
39
- try {
40
- parsed = JSON.parse(Buffer.from(token, "base64url").toString("utf8"));
41
- }
42
- catch {
43
- return null;
44
- }
45
- if (typeof parsed !== "object" || parsed === null)
46
- return null;
47
- const s = parsed;
48
- if (s.v !== 1 || s.task !== true || !isSlotRecord(s.slot))
49
- return null;
50
- return { v: 1, task: true, slot: s.slot };
51
- }
52
- async function post(config, path, body, timeoutMs) {
53
- const headers = { "content-type": "application/json", accept: "application/json" };
54
- if (config.apiKey)
55
- headers["authorization"] = `Bearer ${config.apiKey}`;
56
- const res = await fetch(`${config.baseUrl}${path}`, { method: "POST", headers, body: JSON.stringify(body), signal: AbortSignal.timeout(timeoutMs) });
57
- let json = null;
58
- try {
59
- json = await res.json();
60
- }
61
- catch { /* non-JSON */ }
62
- const raw = res.headers.get("retry-after");
63
- const retry = raw !== null ? Number.parseInt(raw, 10) : NaN;
64
- return { status: res.status, json, retryAfterSec: Number.isFinite(retry) ? retry : null };
65
- }
66
- const messageOf = (json, fallback) => {
67
- const e = json?.error;
68
- return typeof e === "string" ? e : fallback;
69
- };
70
- /** Step one of the task form: a held slot and its commitment, before any work exists. */
71
- export async function beginTask(config) {
72
- const r = await post(config, "/api/fuse/allocate", {}, 20_000);
73
- if (r.status !== 200)
74
- throw new ApiError(r.status, messageOf(r.json, `allocation refused (${r.status})`), r.retryAfterSec);
75
- const slot = r.json?.slot;
76
- if (!isSlotRecord(slot))
77
- throw new ApiError(502, "the allocation response is not a slot record on bitgraph:main");
78
- const commitmentB64 = bytesToBase64(computeSlotCommitment(slot));
79
- let floor = null;
80
- try {
81
- const res = await fetch(`${config.baseUrl}/api/proofs/anchors?counter=${encodeURIComponent(slot.counter)}&epoch=${encodeURIComponent(slot.epochId)}&before=1`, { headers: { accept: "application/json" }, signal: AbortSignal.timeout(10_000) });
82
- const data = res.status === 200 ? (await res.json()) : null;
83
- const b = data?.anchors?.[0]?.commit?.anchor?.blockNumber;
84
- if (typeof b === "number")
85
- floor = { block: b };
86
- }
87
- catch {
88
- floor = null;
89
- }
90
- return { token: encodeTaskToken({ v: 1, task: true, slot }), commitment: toUrlSafeB64(commitmentB64), commitmentB64, slotCounter: slot.counter, epoch: toUrlSafeB64(slot.epochId), floor };
91
- }
92
- /**
93
- * Step two: the task bytes (a path, or the bytes themselves) sealed under
94
- * the held slot with the inline marker. When the bytes are in hand the
95
- * commitment is looked for BEFORE the commit, so a task that does not carry
96
- * it is refused without spending the slot.
97
- */
98
- export async function sealTask(config, state, task) {
99
- const { slot } = state;
100
- const commitment = computeSlotCommitment(slot);
101
- let bytes = null;
102
- let artifactDigestB64;
103
- if ("digestB64" in task) {
104
- if (!B64_32.test(task.digestB64))
105
- throw new ApiError(400, "artifact digest must be a base64 SHA-256");
106
- artifactDigestB64 = task.digestB64;
107
- }
108
- else {
109
- bytes = "path" in task ? new Uint8Array(await readFile(task.path)) : task.bytes;
110
- artifactDigestB64 = createHash("sha256").update(bytes).digest("base64");
111
- }
112
- const offsets = bytes === null ? null : findCommitment(bytes, commitment, ENCODING_BASE64URL);
113
- if (offsets !== null && offsets.length === 0) {
114
- throw new ApiError(400, `the task bytes do not contain the commitment string ${toUrlSafeB64(bytesToBase64(commitment))}; put it in before sealing. Nothing was committed and the slot is still held.`);
115
- }
116
- const attribution = inlineAttribution();
117
- const r = await post(config, "/api/fuse/commit", { digests: [{ digestB64: artifactDigestB64, hashAlg: "sha256" }], slotId: slot.nonceB64, slot, chainId: CHAIN, attribution }, 40_000);
118
- let proof = null;
119
- if (r.status === 200)
120
- proof = (r.json?.proof ?? null);
121
- else if (r.status === 409 || r.status === 503)
122
- proof = await recover(config, artifactDigestB64, slot);
123
- if (proof === null)
124
- throw new ApiError(r.status, messageOf(r.json, `commit refused (${r.status})`), r.retryAfterSec);
125
- if (proof.artifact?.digestB64 !== artifactDigestB64 || proof.commit?.nonceB64 !== slot.nonceB64 || proof.slotAllocation?.nonceB64 !== slot.nonceB64)
126
- throw new ApiError(502, "the boundary returned a proof under a different slot; nothing is labelled sealed");
127
- const a = proof.attribution;
128
- if (a?.name !== attribution.name || a?.title !== attribution.title || a?.message !== undefined)
129
- throw new ApiError(502, "the returned proof does not carry the inline marker that was sent; nothing is labelled sealed");
130
- const integrity = await verifyProofIntegrity({ proof });
131
- if (!integrity.valid)
132
- throw new ApiError(502, `the returned proof does not verify: ${integrity.reason ?? "unknown reason"}`);
133
- return { proof, artifactDigestB64, offsets };
134
- }
135
- async function recover(config, artifactDigestB64, slot) {
136
- for (let attempt = 0; attempt < 4; attempt++) {
137
- if (attempt > 0)
138
- await new Promise((r) => setTimeout(r, 1500));
139
- try {
140
- const res = await fetch(`${config.baseUrl}/api/proofs/${encodeURIComponent(toUrlSafeB64(artifactDigestB64))}`, { headers: { accept: "application/json" }, signal: AbortSignal.timeout(15_000) });
141
- if (res.status !== 200)
142
- continue;
143
- const j = (await res.json());
144
- for (const e of j?.proofs ?? []) {
145
- const p = e.proof;
146
- if (p && p.artifact?.digestB64 === artifactDigestB64 && p.commit?.nonceB64 === slot.nonceB64)
147
- return p;
148
- }
149
- }
150
- catch { /* try again */ }
151
- }
152
- return null;
153
- }
154
- export const TASK_INSTRUCTIONS = "You hold a position and its commitment, and no work exists yet. Put the commitment string INSIDE THE OUTPUT you are about to make whenever its format can hold text (SVG, HTML, code, JSON, Markdown, CSV, a document): as a comment, a field, a line that stays in the file. " +
155
- `When the output exists, call bitgraph_commit with this fuse_token and the output file's path, within ${SLOT_TTL_SECONDS} seconds of opening: the output itself is sealed under the position, and the proof is written beside it. ` +
156
- "If the output cannot hold text (a PNG, audio, video) or will take longer than that to make, put the commitment into a task file instead (the exact prompt or request you send), seal that file the same way, and when the output exists record it with bitgraph_record: the task is sealed before the output existed, and the output is recorded after. " +
157
- "Keep the exact bytes that were sealed unchanged: a verifier recomputes the commitment from the proof and looks for the string inside them. " +
158
- "Leave the proof file as written, whole, every field, environment.attestation.reportB64 included: a proof missing slotAllocation, environment, or the attestation cannot be verified.";
159
- /**
160
- * Write a sealed task's proof beside the file it is about, whole, and say
161
- * where. `make_task.txt` gets `make_task.proof.json`; a name already taken
162
- * gets the position's counter in it rather than being overwritten.
163
- *
164
- * ⚠️ THE SERVER WRITES IT, NOT THE AGENT. Handed the JSON to save, an agent
165
- * tidied it and dropped slotAllocation and environment, and the signature
166
- * had no body left to be checked against (Grok, 2026-09-13). A file this
167
- * process writes is the proof exactly as the boundary returned it.
168
- */
169
- export async function writeProofBeside(sealedPath, proof) {
170
- const { writeFile, access } = await import("node:fs/promises");
171
- const { basename, dirname, extname, join } = await import("node:path");
172
- const dir = dirname(sealedPath);
173
- const base = basename(sealedPath);
174
- const stem = extname(base) === "" ? base : base.slice(0, -extname(base).length);
175
- const counter = proof.commit?.counter ?? "0";
176
- let target = join(dir, `${stem}.proof.json`);
177
- if (await access(target).then(() => true).catch(() => false))
178
- target = join(dir, `${stem}.proof.${counter}.json`);
179
- await writeFile(target, JSON.stringify(proof, null, 2) + "\n", { flag: "wx" });
180
- return target;
181
- }
182
- //# sourceMappingURL=task.js.map
package/dist/task.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"task.js","sourceRoot":"","sources":["../src/task.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAE9F;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,QAAQ,EAAE,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CAAC,GAAG,EAAE,GAAG,IAAI,UAAU,OAAO,OAAO,CAAC,CAAC;IAClH,MAAM,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAC/E,OAAO,MAAM,CAAC;AAChB,CAAC"}
package/dist/types.d.ts DELETED
@@ -1,108 +0,0 @@
1
- /**
2
- * @mikeargento/bitgraph-mcp: wire types.
3
- *
4
- * Minimal views of the bitgraph/1 schema and the bitgraph.ing API responses.
5
- * The canonical, fully documented schema lives in @mikeargento/bitgraph-verify.
6
- * Fields not needed for display are kept as unknown; proofs are passed through
7
- * verbatim when the caller asks for JSON.
8
- */
9
- export interface ProofCommit {
10
- counter?: string;
11
- epochId?: string;
12
- time?: number;
13
- slotCounter?: string;
14
- [k: string]: unknown;
15
- }
16
- export interface BitGraphProof {
17
- version?: string;
18
- artifact?: {
19
- hashAlg?: string;
20
- digestB64?: string;
21
- };
22
- commit?: ProofCommit;
23
- signer?: {
24
- publicKeyB64?: string;
25
- signatureB64?: string;
26
- };
27
- environment?: {
28
- enforcement?: string;
29
- measurement?: string;
30
- attestation?: {
31
- format?: string;
32
- reportB64?: string;
33
- };
34
- };
35
- attribution?: {
36
- name?: string;
37
- title?: string;
38
- message?: string;
39
- };
40
- metadata?: unknown;
41
- proofHash?: string;
42
- [k: string]: unknown;
43
- }
44
- /** A set member's row as the site reports it: which row of N these bytes are, and whether as the original or the new file. */
45
- export interface SetMemberView {
46
- index: number;
47
- count: number;
48
- role?: "origin" | "fused";
49
- }
50
- /** POST /api/proofs/batch response. Keyed by the digest exactly as sent (URL-safe). */
51
- export interface BatchCheckResponse {
52
- results: Record<string, {
53
- proofs: Array<{
54
- proof: BitGraphProof;
55
- kind?: "recorded" | "fused";
56
- member?: SetMemberView;
57
- setDigest?: string;
58
- }>;
59
- }>;
60
- }
61
- /** POST /api/fuse/set-index response: how many members' evidence the site wrote. */
62
- export interface SetIndexResponse {
63
- count?: number;
64
- written: number;
65
- failed: number;
66
- rejected: number;
67
- }
68
- export interface AnchorView {
69
- counter?: string;
70
- attrName?: string;
71
- blockNumber?: number | null;
72
- blockHash?: string | null;
73
- etherscanUrl?: string | null;
74
- blockTime?: string | null;
75
- }
76
- export interface PositionView {
77
- counter: string | null;
78
- epoch: string | null;
79
- lowerTime: string | null;
80
- upperTime: string | null;
81
- kind?: "recorded" | "fused";
82
- placement?: string | null;
83
- member?: SetMemberView;
84
- }
85
- /**
86
- * GET /api/proofs/digest/{digest} response.
87
- * causalWindow naming note: anchorBefore is the EARLIER Ethereum block (the
88
- * proof was BitGraphed after it, the lower time bound); anchorAfter is the
89
- * LATER block (the upper bound). Present time as "between lower and upper".
90
- */
91
- export interface ProofDetailResponse {
92
- proofs: Array<{
93
- proof: BitGraphProof;
94
- }>;
95
- positions?: PositionView[];
96
- causalWindow?: {
97
- anchorBefore: AnchorView | null;
98
- anchorAfter: AnchorView | null;
99
- } | null;
100
- anchorBlock?: AnchorView | null;
101
- }
102
- /** GET /api/search response. */
103
- export interface SearchResponse {
104
- found: boolean;
105
- digest?: string;
106
- counter?: string | null;
107
- }
108
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,MAAM,WAAW,WAAW;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,CAAC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ETED
@@ -1,3 +0,0 @@
1
- // Copyright (c) 2024-2026 Argento Computing Inc. Licensed under the MIT License. See LICENSE.
2
- export {};
3
- //# sourceMappingURL=types.js.map
package/dist/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,8FAA8F"}