@mikeargento/bitgraph-mcp 0.3.0 → 0.4.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/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 +265 -83
- 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 +56 -26
- 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 +45 -14
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +286 -122
- 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 +280 -96
- package/src/api.ts +36 -77
- package/src/format.ts +96 -36
- package/src/scan.ts +173 -0
- package/src/server.ts +355 -134
- package/src/types.ts +23 -1
package/dist/api.d.ts
CHANGED
|
@@ -1,19 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
* @mikeargento/bitgraph-mcp: HTTP client for the hosted BitGraph API.
|
|
3
|
-
*
|
|
4
|
-
* All recording goes through the website's /api/commit proxy rather than the
|
|
5
|
-
* TEE directly: the proxy is what maintains the per-position by-digest index
|
|
6
|
-
* that makes every causal position of a file discoverable afterward.
|
|
7
|
-
*/
|
|
8
|
-
import type { BatchCheckResponse, BitGraphProof, ProofDetailResponse, SearchResponse } from "./types.js";
|
|
1
|
+
import type { BatchCheckResponse, ProofDetailResponse, SearchResponse, SetIndexResponse } from "./types.js";
|
|
9
2
|
export interface ApiConfig {
|
|
10
3
|
baseUrl: string;
|
|
11
4
|
apiKey?: string;
|
|
12
5
|
}
|
|
13
6
|
/** Read configuration from the environment at call time (testable via env). */
|
|
14
7
|
export declare function configFromEnv(): ApiConfig;
|
|
15
|
-
/** Matches the website client: 50 digests per commit request (~1s of TEE work each). */
|
|
16
|
-
export declare const COMMIT_CHUNK_SIZE = 50;
|
|
17
8
|
/** Matches the batch endpoint's MAX_DIGESTS. */
|
|
18
9
|
export declare const BATCH_CHECK_LIMIT = 500;
|
|
19
10
|
export declare class ApiError extends Error {
|
|
@@ -23,30 +14,27 @@ export declare class ApiError extends Error {
|
|
|
23
14
|
}
|
|
24
15
|
/**
|
|
25
16
|
* Look up which digests are on record. Input digests must be URL-safe base64;
|
|
26
|
-
* the response is keyed by the exact strings sent.
|
|
17
|
+
* the response is keyed by the exact strings sent. Pages of up to 500, a few
|
|
18
|
+
* in flight at once.
|
|
27
19
|
*/
|
|
28
20
|
export declare function batchCheck(config: ApiConfig, urlSafeDigests: readonly string[]): Promise<BatchCheckResponse>;
|
|
21
|
+
/** One request's worth of a set/2's member evidence, for the site to index. */
|
|
22
|
+
export interface SetIndexRequest {
|
|
23
|
+
/** The set proof's artifact digest, URL-safe base64. */
|
|
24
|
+
setDigest: string;
|
|
25
|
+
/** The set proof's epoch id, URL-safe base64. */
|
|
26
|
+
epoch: string;
|
|
27
|
+
/** The set proof's commit counter. */
|
|
28
|
+
counter: string;
|
|
29
|
+
members: unknown[];
|
|
30
|
+
}
|
|
29
31
|
/**
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* On a mid-batch failure the error carries how many proofs were already
|
|
35
|
-
* minted (those are permanent); the caller must report partial results
|
|
36
|
-
* honestly rather than pretending all-or-nothing.
|
|
32
|
+
* Index members of a set/2 from their evidence. The site reads the set proof
|
|
33
|
+
* from its own position, binds the root document, and checks every member's
|
|
34
|
+
* path before writing a key; a row that does not bind is rejected, never
|
|
35
|
+
* written.
|
|
37
36
|
*/
|
|
38
|
-
export declare function
|
|
39
|
-
name?: string | undefined;
|
|
40
|
-
title?: string | undefined;
|
|
41
|
-
message?: string | undefined;
|
|
42
|
-
}): Promise<BitGraphProof[]>;
|
|
43
|
-
/** A commit batch failed partway: `minted` proofs are already permanent. */
|
|
44
|
-
export declare class PartialCommitError extends Error {
|
|
45
|
-
readonly minted: BitGraphProof[];
|
|
46
|
-
readonly requested: number;
|
|
47
|
-
readonly cause2: unknown;
|
|
48
|
-
constructor(minted: BitGraphProof[], requested: number, cause: unknown);
|
|
49
|
-
}
|
|
37
|
+
export declare function indexSetMembers(config: ApiConfig, body: SetIndexRequest): Promise<SetIndexResponse>;
|
|
50
38
|
/** Full detail for one digest: proof, all causal positions, anchor window. */
|
|
51
39
|
export declare function getProofDetail(config: ApiConfig, urlSafeDigest: string, counter?: string, urlSafeEpoch?: string): Promise<ProofDetailResponse>;
|
|
52
40
|
/** Resolve a BitGraph number (or digest string) to a digest via /api/search. */
|
package/dist/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE5G,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,+EAA+E;AAC/E,wBAAgB,aAAa,IAAI,SAAS,CAIzC;AAED,gDAAgD;AAChD,eAAO,MAAM,iBAAiB,MAAM,CAAC;AAOrC,qBAAa,QAAS,SAAQ,KAAK;IACjC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;gBAE1B,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,aAAa,GAAE,MAAM,GAAG,IAAW;CAKjF;AA0DD;;;;GAIG;AACH,wBAAsB,UAAU,CAC9B,MAAM,EAAE,SAAS,EACjB,cAAc,EAAE,SAAS,MAAM,EAAE,GAChC,OAAO,CAAC,kBAAkB,CAAC,CAW7B;AAED,+EAA+E;AAC/E,MAAM,WAAW,eAAe;IAC9B,wDAAwD;IACxD,SAAS,EAAE,MAAM,CAAC;IAClB,iDAAiD;IACjD,KAAK,EAAE,MAAM,CAAC;IACd,sCAAsC;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,OAAO,EAAE,CAAC;CACpB;AAED;;;;;GAKG;AACH,wBAAsB,eAAe,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAEzG;AAED,8EAA8E;AAC9E,wBAAsB,cAAc,CAClC,MAAM,EAAE,SAAS,EACjB,aAAa,EAAE,MAAM,EACrB,OAAO,CAAC,EAAE,MAAM,EAChB,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,mBAAmB,CAAC,CAU9B;AAED,gFAAgF;AAChF,wBAAsB,MAAM,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAMlF"}
|
package/dist/api.js
CHANGED
|
@@ -1,16 +1,26 @@
|
|
|
1
1
|
// Copyright (c) 2024-2026 Mike Argento. Licensed under the MIT License. See LICENSE.
|
|
2
|
+
/**
|
|
3
|
+
* @mikeargento/bitgraph-mcp: HTTP client for the hosted BitGraph API.
|
|
4
|
+
*
|
|
5
|
+
* The reads: the batch lookup, the proof detail, the number search. Making a
|
|
6
|
+
* BitGraph goes through the core package's own transport against the same
|
|
7
|
+
* site (its /api/fuse routes), which is what maintains the per-position
|
|
8
|
+
* by-digest index that makes every member of a set discoverable afterward;
|
|
9
|
+
* the one write here is a set/2's member evidence, indexed after the commit.
|
|
10
|
+
*/
|
|
11
|
+
import { mapConcurrent } from "./encoding.js";
|
|
2
12
|
/** Read configuration from the environment at call time (testable via env). */
|
|
3
13
|
export function configFromEnv() {
|
|
4
14
|
const baseUrl = (process.env["BITGRAPH_API_URL"] ?? "https://bitgraph.ing").replace(/\/+$/, "");
|
|
5
15
|
const apiKey = process.env["BITGRAPH_API_KEY"];
|
|
6
16
|
return apiKey ? { baseUrl, apiKey } : { baseUrl };
|
|
7
17
|
}
|
|
8
|
-
/** Matches the website client: 50 digests per commit request (~1s of TEE work each). */
|
|
9
|
-
export const COMMIT_CHUNK_SIZE = 50;
|
|
10
18
|
/** Matches the batch endpoint's MAX_DIGESTS. */
|
|
11
19
|
export const BATCH_CHECK_LIMIT = 500;
|
|
20
|
+
/** Batch lookups in flight at once: a large folder is many pages. */
|
|
21
|
+
const BATCH_CHECK_CONCURRENCY = 4;
|
|
12
22
|
const CHECK_TIMEOUT_MS = 30_000;
|
|
13
|
-
const
|
|
23
|
+
const SET_INDEX_TIMEOUT_MS = 60_000;
|
|
14
24
|
export class ApiError extends Error {
|
|
15
25
|
status;
|
|
16
26
|
retryAfterSec;
|
|
@@ -71,61 +81,28 @@ async function postJson(config, path, body, timeoutMs, authenticated) {
|
|
|
71
81
|
}
|
|
72
82
|
/**
|
|
73
83
|
* Look up which digests are on record. Input digests must be URL-safe base64;
|
|
74
|
-
* the response is keyed by the exact strings sent.
|
|
84
|
+
* the response is keyed by the exact strings sent. Pages of up to 500, a few
|
|
85
|
+
* in flight at once.
|
|
75
86
|
*/
|
|
76
87
|
export async function batchCheck(config, urlSafeDigests) {
|
|
77
|
-
const
|
|
88
|
+
const chunks = [];
|
|
78
89
|
for (let offset = 0; offset < urlSafeDigests.length; offset += BATCH_CHECK_LIMIT) {
|
|
79
|
-
|
|
80
|
-
const page = await postJson(config, "/api/proofs/batch", { digests: chunk }, CHECK_TIMEOUT_MS, false);
|
|
81
|
-
Object.assign(merged.results, page.results);
|
|
90
|
+
chunks.push(urlSafeDigests.slice(offset, offset + BATCH_CHECK_LIMIT));
|
|
82
91
|
}
|
|
92
|
+
const pages = await mapConcurrent(chunks, BATCH_CHECK_CONCURRENCY, (chunk) => postJson(config, "/api/proofs/batch", { digests: chunk }, CHECK_TIMEOUT_MS, false));
|
|
93
|
+
const merged = { results: {} };
|
|
94
|
+
for (const page of pages)
|
|
95
|
+
Object.assign(merged.results, page.results);
|
|
83
96
|
return merged;
|
|
84
97
|
}
|
|
85
98
|
/**
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
* On a mid-batch failure the error carries how many proofs were already
|
|
91
|
-
* minted (those are permanent); the caller must report partial results
|
|
92
|
-
* honestly rather than pretending all-or-nothing.
|
|
99
|
+
* Index members of a set/2 from their evidence. The site reads the set proof
|
|
100
|
+
* from its own position, binds the root document, and checks every member's
|
|
101
|
+
* path before writing a key; a row that does not bind is rejected, never
|
|
102
|
+
* written.
|
|
93
103
|
*/
|
|
94
|
-
export async function
|
|
95
|
-
|
|
96
|
-
for (let offset = 0; offset < standardDigests.length; offset += COMMIT_CHUNK_SIZE) {
|
|
97
|
-
const chunk = standardDigests.slice(offset, offset + COMMIT_CHUNK_SIZE);
|
|
98
|
-
const body = {
|
|
99
|
-
digests: chunk.map((digestB64) => ({ digestB64, hashAlg: "sha256" })),
|
|
100
|
-
chainId: "bitgraph:main",
|
|
101
|
-
};
|
|
102
|
-
if (attribution)
|
|
103
|
-
body["attribution"] = attribution;
|
|
104
|
-
try {
|
|
105
|
-
const raw = await postJson(config, "/api/commit", body, COMMIT_TIMEOUT_MS, true);
|
|
106
|
-
proofs.push(...(Array.isArray(raw) ? raw : [raw]));
|
|
107
|
-
}
|
|
108
|
-
catch (err) {
|
|
109
|
-
throw new PartialCommitError(proofs, standardDigests.length, err);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
return proofs;
|
|
113
|
-
}
|
|
114
|
-
/** A commit batch failed partway: `minted` proofs are already permanent. */
|
|
115
|
-
export class PartialCommitError extends Error {
|
|
116
|
-
minted;
|
|
117
|
-
requested;
|
|
118
|
-
cause2;
|
|
119
|
-
constructor(minted, requested, cause) {
|
|
120
|
-
const reason = cause instanceof Error ? cause.message : String(cause);
|
|
121
|
-
super(`Recording stopped after ${minted.length} of ${requested} digests: ${reason}` +
|
|
122
|
-
(cause instanceof ApiError && cause.retryAfterSec !== null
|
|
123
|
-
? ` (retry after ${cause.retryAfterSec}s)`
|
|
124
|
-
: ""));
|
|
125
|
-
this.minted = minted;
|
|
126
|
-
this.requested = requested;
|
|
127
|
-
this.cause2 = cause;
|
|
128
|
-
}
|
|
104
|
+
export async function indexSetMembers(config, body) {
|
|
105
|
+
return postJson(config, "/api/fuse/set-index", body, SET_INDEX_TIMEOUT_MS, false);
|
|
129
106
|
}
|
|
130
107
|
/** Full detail for one digest: proof, all causal positions, anchor window. */
|
|
131
108
|
export async function getProofDetail(config, urlSafeDigest, counter, urlSafeEpoch) {
|
package/dist/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,qFAAqF;
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,qFAAqF;AAErF;;;;;;;;GAQG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAQ9C,+EAA+E;AAC/E,MAAM,UAAU,aAAa;IAC3B,MAAM,OAAO,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,IAAI,sBAAsB,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EA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,KAAK,UAAU,eAAe,CAAC,MAAiB,EAAE,IAAqB;IAC5E,OAAO,QAAQ,CAAmB,MAAM,EAAE,qBAAqB,EAAE,IAAI,EAAE,oBAAoB,EAAE,KAAK,CAAC,CAAC;AACtG,CAAC;AAED,8EAA8E;AAC9E,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,MAAiB,EACjB,aAAqB,EACrB,OAAgB,EAChB,YAAqB;IAErB,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;IACrC,IAAI,OAAO,KAAK,SAAS;QAAE,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAC1D,IAAI,YAAY,KAAK,SAAS;QAAE,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IAClE,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IAC7D,OAAO,OAAO,CACZ,MAAM,EACN,sBAAsB,kBAAkB,CAAC,aAAa,CAAC,GAAG,KAAK,EAAE,EACjE,gBAAgB,CACjB,CAAC;AACJ,CAAC;AAED,gFAAgF;AAChF,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,MAAiB,EAAE,CAAS;IACvD,OAAO,OAAO,CACZ,MAAM,EACN,iBAAiB,kBAAkB,CAAC,CAAC,CAAC,EAAE,EACxC,gBAAgB,CACjB,CAAC;AACJ,CAAC"}
|
package/dist/format.d.ts
CHANGED
|
@@ -1,28 +1,54 @@
|
|
|
1
|
-
import type { BitGraphProof, ProofDetailResponse } from "./types.js";
|
|
1
|
+
import type { BitGraphProof, ProofDetailResponse, SetMemberView } from "./types.js";
|
|
2
2
|
export declare const CHARACTER_LIMIT = 25000;
|
|
3
|
+
/** Rows per group a markdown summary lists before "and N more". */
|
|
4
|
+
export declare const MARKDOWN_ROWS = 50;
|
|
3
5
|
/** Public proof page URL for a digest, optionally pinned to one causal position. */
|
|
4
6
|
export declare function proofUrl(baseUrl: string, standardDigest: string, counter?: string, standardEpochId?: string): string;
|
|
5
7
|
/**
|
|
6
|
-
* One outcome per path, in the product's own vocabulary. "fused":
|
|
7
|
-
*
|
|
8
|
-
* record": the bytes already had a recording or a
|
|
9
|
-
* as origin, and nothing was
|
|
10
|
-
* claim "on record" for
|
|
8
|
+
* One outcome per path, in the product's own vocabulary. "fused": the file is
|
|
9
|
+
* a member of the set just made, its new fused bytes listed by digest in the
|
|
10
|
+
* committed artifact. "on record": the bytes already had a recording or a
|
|
11
|
+
* fused artifact naming them as origin, and nothing was made. "not fused":
|
|
12
|
+
* the attempt failed or the file was left out; never claim "on record" for
|
|
13
|
+
* bytes that have no proof.
|
|
11
14
|
*/
|
|
12
15
|
export interface RecordOutcome {
|
|
13
16
|
path: string;
|
|
14
|
-
/** The file's own digest (URL-safe): the origin of
|
|
17
|
+
/** The file's own digest (URL-safe): the origin of its fused bytes. */
|
|
15
18
|
digest: string;
|
|
16
19
|
outcome: "fused" | "on record" | "not fused";
|
|
17
|
-
/** The
|
|
20
|
+
/** The member's fused digest (URL-safe), present on a "fused" outcome. */
|
|
18
21
|
artifact_digest: string | null;
|
|
19
22
|
placement: string | null;
|
|
20
23
|
counter: string | null;
|
|
21
24
|
epoch: string | null;
|
|
25
|
+
/** The file's row in the set just made, 1-based, of member_count. */
|
|
26
|
+
member: number | null;
|
|
27
|
+
member_count: number | null;
|
|
22
28
|
total_positions: number;
|
|
23
29
|
proof_url: string | null;
|
|
24
30
|
error?: string;
|
|
25
31
|
}
|
|
32
|
+
/** The one BitGraph a record call makes: a set, one position for every fused row. */
|
|
33
|
+
export interface SetOutcome {
|
|
34
|
+
/** "set/1": the committed artifact lists every member. "set/2": it is a Merkle root over the rows, and each member's evidence is indexed on the site. */
|
|
35
|
+
set: "set/1" | "set/2";
|
|
36
|
+
count: number;
|
|
37
|
+
counter: string | null;
|
|
38
|
+
epoch: string | null;
|
|
39
|
+
/** The committed artifact's digest (URL-safe): the manifest or the root document. */
|
|
40
|
+
artifact_digest: string;
|
|
41
|
+
proof_url: string;
|
|
42
|
+
/** True when the boundary echoed the committed artifact in the proof's metadata, so the ledger's copy carries it. */
|
|
43
|
+
manifest_echoed: boolean;
|
|
44
|
+
/** True when the commit response was lost and the proof was read back by digest. */
|
|
45
|
+
recovered: boolean;
|
|
46
|
+
/** set/2 only: members whose evidence the site has indexed, and members still waiting. */
|
|
47
|
+
index: {
|
|
48
|
+
written: number;
|
|
49
|
+
pending: number;
|
|
50
|
+
} | null;
|
|
51
|
+
}
|
|
26
52
|
export interface CheckOutcome {
|
|
27
53
|
input: string;
|
|
28
54
|
digest: string;
|
|
@@ -30,6 +56,7 @@ export interface CheckOutcome {
|
|
|
30
56
|
positions: Array<{
|
|
31
57
|
counter: string | null;
|
|
32
58
|
epoch: string | null;
|
|
59
|
+
member?: SetMemberView;
|
|
33
60
|
}>;
|
|
34
61
|
proof_url: string | null;
|
|
35
62
|
}
|
|
@@ -37,7 +64,7 @@ export declare function positionOf(proof: BitGraphProof): {
|
|
|
37
64
|
counter: string | null;
|
|
38
65
|
epoch: string | null;
|
|
39
66
|
};
|
|
40
|
-
export declare function renderRecordMarkdown(outcomes: readonly RecordOutcome[]): string;
|
|
67
|
+
export declare function renderRecordMarkdown(outcomes: readonly RecordOutcome[], set?: SetOutcome | null, omitted?: number): string;
|
|
41
68
|
export declare function renderCheckMarkdown(outcomes: readonly CheckOutcome[]): string;
|
|
42
69
|
export declare function renderProofMarkdown(detail: ProofDetailResponse, baseUrl: string): string;
|
|
43
70
|
/**
|
package/dist/format.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,aAAa,EAAgB,mBAAmB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot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const CHARACTER_LIMIT = 25_000;
|
|
11
|
+
/** Rows per group a markdown summary lists before "and N more". */
|
|
12
|
+
export const MARKDOWN_ROWS = 50;
|
|
11
13
|
/** Public proof page URL for a digest, optionally pinned to one causal position. */
|
|
12
14
|
export function proofUrl(baseUrl, standardDigest, counter, standardEpochId) {
|
|
13
15
|
let url = `${baseUrl}/proof/${encodeURIComponent(toUrlSafeB64(standardDigest))}`;
|
|
@@ -24,51 +26,74 @@ export function positionOf(proof) {
|
|
|
24
26
|
const epochId = proof.commit?.epochId;
|
|
25
27
|
return { counter, epoch: epochId !== undefined ? toUrlSafeB64(epochId) : null };
|
|
26
28
|
}
|
|
27
|
-
|
|
29
|
+
const fmt = (n) => n.toLocaleString("en-US");
|
|
30
|
+
function memberNote(m) {
|
|
31
|
+
return m ? ` (member ${fmt(m.index + 1)} of ${fmt(m.count)})` : "";
|
|
32
|
+
}
|
|
33
|
+
export function renderRecordMarkdown(outcomes, set = null, omitted = 0) {
|
|
28
34
|
const fused = outcomes.filter((o) => o.outcome === "fused");
|
|
29
35
|
const onRecord = outcomes.filter((o) => o.outcome === "on record");
|
|
30
36
|
const notFused = outcomes.filter((o) => o.outcome === "not fused");
|
|
31
37
|
const lines = [];
|
|
32
|
-
|
|
33
|
-
if (
|
|
34
|
-
|
|
38
|
+
const parts = [];
|
|
39
|
+
if (set !== null && fused.length > 0) {
|
|
40
|
+
parts.push(`${fmt(fused.length)} file${fused.length === 1 ? "" : "s"} BitGraphed as one set at #${set.counter ?? "?"} (set of ${fmt(set.count)})`);
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
parts.push(`${fmt(fused.length)} fused`);
|
|
35
44
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
45
|
+
parts.push(`${fmt(onRecord.length)} already on record`);
|
|
46
|
+
if (notFused.length > 0)
|
|
47
|
+
parts.push(`${fmt(notFused.length)} NOT fused`);
|
|
48
|
+
lines.push(`${parts.join(", ")}.`);
|
|
49
|
+
if (set !== null && fused.length > 0) {
|
|
50
|
+
lines.push(`- #${set.counter ?? "?"} · set of ${fmt(set.count)} · ${set.proof_url}`);
|
|
51
|
+
if (set.index !== null && set.index.pending > 0) {
|
|
52
|
+
lines.push(` The set is on the ledger, but the evidence for ${fmt(set.index.pending)} of its ${fmt(set.count)} members is not indexed yet, so those files are not findable by hash until it is. It is sent again at the start of the next bitgraph_record call.`);
|
|
53
|
+
}
|
|
54
|
+
if (!set.manifest_echoed) {
|
|
55
|
+
lines.push(` The boundary did not echo the committed artifact; the ledger's copy of this proof carries no member list. Keep the set's proof page.`);
|
|
41
56
|
}
|
|
42
|
-
const note = o.outcome === "on record"
|
|
43
|
-
? o.total_positions > 1
|
|
44
|
-
? ` (${o.total_positions} positions, earliest shown)`
|
|
45
|
-
: ""
|
|
46
|
-
: o.placement
|
|
47
|
-
? ` (${o.placement})`
|
|
48
|
-
: "";
|
|
49
|
-
lines.push(`- ${o.outcome} · #${o.counter ?? "?"} · ${o.path}${note}\n ${o.proof_url}`);
|
|
50
57
|
}
|
|
58
|
+
const group = (rows, render, more) => {
|
|
59
|
+
for (const o of rows.slice(0, MARKDOWN_ROWS))
|
|
60
|
+
lines.push(render(o));
|
|
61
|
+
if (rows.length > MARKDOWN_ROWS)
|
|
62
|
+
lines.push(`- ${more(rows.length - MARKDOWN_ROWS)}`);
|
|
63
|
+
};
|
|
64
|
+
group(notFused, (o) => `- not fused · ${o.path}${o.error ? `: ${o.error}` : ""}`, (n) => `and ${fmt(n)} more not fused`);
|
|
65
|
+
group(onRecord, (o) => {
|
|
66
|
+
const note = o.total_positions > 1 ? ` (${fmt(o.total_positions)} positions, earliest shown)` : "";
|
|
67
|
+
const row = o.member !== null && o.member_count !== null ? ` (member ${fmt(o.member)} of ${fmt(o.member_count)})` : "";
|
|
68
|
+
return `- on record · #${o.counter ?? "?"}${row} · ${o.path}${note}\n ${o.proof_url}`;
|
|
69
|
+
}, (n) => `and ${fmt(n)} more already on record`);
|
|
70
|
+
group(fused, (o) => `- fused · ${o.path} (${fmt(o.member ?? 0)} of ${fmt(o.member_count ?? 0)}, ${o.placement ?? "?"})`, (n) => `and ${fmt(n)} more files in the same set`);
|
|
51
71
|
if (fused.length > 0) {
|
|
52
|
-
lines.push("\
|
|
72
|
+
lines.push("\nOne BitGraph holds every file made here: one slot, one position, and the committed artifact lists each file's new fused bytes by digest. Those bytes were hashed on this machine and never written or uploaded; the file itself is unchanged, and the original plus the set proof rebuilds them. A lookup by any file's own digest finds the set.");
|
|
53
73
|
}
|
|
54
74
|
if (onRecord.length > 0) {
|
|
55
|
-
lines.push("\nFiles already on record were left alone. To make a new
|
|
75
|
+
lines.push("\nFiles already on record were left alone. To make a new BitGraph of them deliberately, call bitgraph_record with again=true.");
|
|
76
|
+
}
|
|
77
|
+
if (omitted > 0) {
|
|
78
|
+
lines.push(`\nThe structured result lists the first rows only (${fmt(omitted)} omitted); every fused file shares the set's position above.`);
|
|
56
79
|
}
|
|
57
80
|
return lines.join("\n");
|
|
58
81
|
}
|
|
59
82
|
export function renderCheckMarkdown(outcomes) {
|
|
60
83
|
const found = outcomes.filter((o) => o.on_record).length;
|
|
61
|
-
const lines = [`${found} of ${outcomes.length} on record.`];
|
|
62
|
-
for (const o of outcomes) {
|
|
84
|
+
const lines = [`${fmt(found)} of ${fmt(outcomes.length)} on record.`];
|
|
85
|
+
for (const o of outcomes.slice(0, MARKDOWN_ROWS)) {
|
|
63
86
|
if (o.on_record) {
|
|
64
87
|
const first = o.positions[0];
|
|
65
|
-
const extra = o.positions.length > 1 ? ` and ${o.positions.length - 1} more position(s)` : "";
|
|
66
|
-
lines.push(`- on record · #${first?.counter ?? "?"}${extra} · ${o.input}\n ${o.proof_url}`);
|
|
88
|
+
const extra = o.positions.length > 1 ? ` and ${fmt(o.positions.length - 1)} more position(s)` : "";
|
|
89
|
+
lines.push(`- on record · #${first?.counter ?? "?"}${memberNote(first?.member)}${extra} · ${o.input}\n ${o.proof_url}`);
|
|
67
90
|
}
|
|
68
91
|
else {
|
|
69
92
|
lines.push(`- not on record · ${o.input}`);
|
|
70
93
|
}
|
|
71
94
|
}
|
|
95
|
+
if (outcomes.length > MARKDOWN_ROWS)
|
|
96
|
+
lines.push(`- and ${fmt(outcomes.length - MARKDOWN_ROWS)} more; the structured result lists every one`);
|
|
72
97
|
return lines.join("\n");
|
|
73
98
|
}
|
|
74
99
|
function renderWindow(detail) {
|
|
@@ -94,12 +119,18 @@ export function renderProofMarkdown(detail, baseUrl) {
|
|
|
94
119
|
return "No proof found for that digest.";
|
|
95
120
|
const digest = proof.artifact?.digestB64 ?? "";
|
|
96
121
|
const { counter, epoch } = positionOf(proof);
|
|
122
|
+
const positions = detail.positions ?? [];
|
|
123
|
+
const here = positions.find((p) => p.counter === counter) ?? positions[0];
|
|
97
124
|
const lines = [];
|
|
98
125
|
lines.push(`# BitGraph #${counter ?? "?"}`);
|
|
99
126
|
lines.push("");
|
|
100
127
|
lines.push(`- Digest (SHA-256): ${toUrlSafeB64(digest)}`);
|
|
101
128
|
if (epoch)
|
|
102
129
|
lines.push(`- Position: counter ${counter ?? "?"} in epoch ${epoch.slice(0, 12)}…`);
|
|
130
|
+
if (here?.member) {
|
|
131
|
+
const role = here.member.role === "fused" ? "its new fused bytes" : "the original";
|
|
132
|
+
lines.push(`- Set: member ${fmt(here.member.index + 1)} of ${fmt(here.member.count)}, as ${role}${here.placement ? ` (${here.placement})` : ""}`);
|
|
133
|
+
}
|
|
103
134
|
const window = renderWindow(detail);
|
|
104
135
|
if (window)
|
|
105
136
|
lines.push(`- ${window}`);
|
|
@@ -116,14 +147,13 @@ export function renderProofMarkdown(detail, baseUrl) {
|
|
|
116
147
|
.join(": ");
|
|
117
148
|
lines.push(`- Submitter's note (self-attributed, not verified): ${note}`);
|
|
118
149
|
}
|
|
119
|
-
const positions = detail.positions ?? [];
|
|
120
150
|
if (positions.length > 1) {
|
|
121
151
|
lines.push("");
|
|
122
|
-
lines.push(`## Causal positions (${positions.length})`);
|
|
152
|
+
lines.push(`## Causal positions (${fmt(positions.length)})`);
|
|
123
153
|
positions.forEach((p, i) => {
|
|
124
154
|
const label = i === 0 ? " · original" : "";
|
|
125
155
|
const bracket = p.lowerTime && p.upperTime ? ` · between ${p.lowerTime} and ${p.upperTime}` : "";
|
|
126
|
-
lines.push(`- #${p.counter ?? "?"}${label}${bracket}`);
|
|
156
|
+
lines.push(`- #${p.counter ?? "?"}${label}${p.member ? ` · set of ${fmt(p.member.count)}` : ""}${bracket}`);
|
|
127
157
|
});
|
|
128
158
|
}
|
|
129
159
|
lines.push("");
|
package/dist/format.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.js","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA,qFAAqF;AAErF;;;;;;GAMG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAG7C,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC;AAEtC,oFAAoF;AACpF,MAAM,UAAU,QAAQ,CACtB,OAAe,EACf,cAAsB,EACtB,OAAgB,EAChB,eAAwB;IAExB,IAAI,GAAG,GAAG,GAAG,OAAO,UAAU,kBAAkB,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC,EAAE,CAAC;IACjF,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,GAAG,IAAI,YAAY,kBAAkB,CAAC,OAAO,CAAC,EAAE,CAAC;QACjD,IAAI,eAAe,KAAK,SAAS,EAAE,CAAC;YAClC,GAAG,IAAI,UAAU,kBAAkB,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC,EAAE,CAAC;QACvE,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAgCD,MAAM,UAAU,UAAU,CAAC,KAAoB;IAC7C,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,EAAE,OAAO,IAAI,IAAI,CAAC;IAC9C,MAAM,OAAO,GAAG,KA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.d.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @mikeargento/bitgraph-mcp: the scan.
|
|
3
|
+
*
|
|
4
|
+
* One pass over each file yields its SHA-256 (the member's origin) and a
|
|
5
|
+
* hasher left open after the placement's prefix and the file's last byte, so
|
|
6
|
+
* the member's fused digest can be finished later, for whatever slot the set
|
|
7
|
+
* is made under, without reading the file again. A placement is prefix,
|
|
8
|
+
* original, suffix (its frame): trailer/1 has no prefix and container/2's is
|
|
9
|
+
* the original's tar header, which depends on the size alone; the suffix
|
|
10
|
+
* carries the commitment and is hashed at BitGraph time. Node's SHA-256 is
|
|
11
|
+
* the platform's own, and a Hash can be copied mid-stream, which is the whole
|
|
12
|
+
* trick: the copy takes the suffix, so no file is read twice or held in
|
|
13
|
+
* memory, and the original is never touched.
|
|
14
|
+
*/
|
|
15
|
+
import { type Hash } from "node:crypto";
|
|
16
|
+
/** The placements the scan makes: chosen from the bytes by the core, never from the name. */
|
|
17
|
+
export type ScanPlacement = "trailer/1" | "container/2";
|
|
18
|
+
export interface ScannedFile {
|
|
19
|
+
path: string;
|
|
20
|
+
name: string;
|
|
21
|
+
size: number;
|
|
22
|
+
/** SHA-256 of the file, standard base64: the member's origin. */
|
|
23
|
+
digestB64: string;
|
|
24
|
+
originDigest: Uint8Array;
|
|
25
|
+
placement: ScanPlacement;
|
|
26
|
+
/**
|
|
27
|
+
* The hasher after the placement's prefix and the file's bytes, still open.
|
|
28
|
+
* Null when the file's length changed while it was read: its fused digest
|
|
29
|
+
* then needs the bytes again.
|
|
30
|
+
*/
|
|
31
|
+
state: Hash | null;
|
|
32
|
+
}
|
|
33
|
+
/** Hash one file in a single pass. Throws, before any network call, when the path is not a regular file. */
|
|
34
|
+
export declare function scanFile(path: string): Promise<ScannedFile>;
|
|
35
|
+
/**
|
|
36
|
+
* A member's fused digest for a slot: the open hasher, copied, finished with
|
|
37
|
+
* the placement's suffix for that slot's commitment. The hash of prefix,
|
|
38
|
+
* original, suffix is exactly the hash of the placement's own build, which
|
|
39
|
+
* a test pins.
|
|
40
|
+
*/
|
|
41
|
+
export declare function fusedDigestFor(file: ScannedFile, commitment: Uint8Array): Uint8Array;
|
|
42
|
+
export interface Expansion {
|
|
43
|
+
/** Regular files in the order given; a directory contributes its files sorted by name, depth first. */
|
|
44
|
+
files: string[];
|
|
45
|
+
/** How many of the inputs were directories. */
|
|
46
|
+
directories: number;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Paths to files: a regular file is itself; a directory is every regular
|
|
50
|
+
* file under it, recursively, with hidden entries (names starting with a
|
|
51
|
+
* dot) and symbolic links left out. The same file twice is one file. A path
|
|
52
|
+
* that is missing or neither kind, or more than `limit` files in all, throws
|
|
53
|
+
* before any network call; the message names every path that failed.
|
|
54
|
+
*/
|
|
55
|
+
export declare function expandPaths(paths: readonly string[], limit: number): Promise<Expansion>;
|
|
56
|
+
//# sourceMappingURL=scan.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scan.d.ts","sourceRoot":"","sources":["../src/scan.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAc,KAAK,IAAI,EAAE,MAAM,aAAa,CAAC;AAOpD,6FAA6F;AAC7F,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG,aAAa,CAAC;AAExD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,iEAAiE;IACjE,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,UAAU,CAAC;IACzB,SAAS,EAAE,aAAa,CAAC;IACzB;;;;OAIG;IACH,KAAK,EAAE,IAAI,GAAG,IAAI,CAAC;CACpB;AAKD,4GAA4G;AAC5G,wBAAsB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAoDjE;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,GAAG,UAAU,CAMpF;AAED,MAAM,WAAW,SAAS;IACxB,uGAAuG;IACvG,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,+CAA+C;IAC/C,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;GAMG;AACH,wBAAsB,WAAW,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CA2C7F"}
|