@engramx/client 0.16.0-rc.2 → 0.16.0-rc.21

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.
Files changed (95) hide show
  1. package/README.md +69 -8
  2. package/dist/EngramClient.d.ts +60 -16
  3. package/dist/EngramClient.js +139 -70
  4. package/dist/EngramClient.js.map +1 -1
  5. package/dist/MarketClient.js.map +1 -1
  6. package/dist/ProfileManager.d.ts +3 -19
  7. package/dist/ProfileManager.js +1 -58
  8. package/dist/ProfileManager.js.map +1 -1
  9. package/dist/SessionManager.d.ts +1 -1
  10. package/dist/SessionManager.js.map +1 -1
  11. package/dist/actionReceipt.d.ts +8 -0
  12. package/dist/actionReceipt.js +8 -0
  13. package/dist/actionReceipt.js.map +1 -1
  14. package/dist/birthChain.d.ts +87 -0
  15. package/dist/birthChain.js +233 -0
  16. package/dist/birthChain.js.map +1 -0
  17. package/dist/cache.js.map +1 -1
  18. package/dist/certifiedAudit.d.ts +31 -0
  19. package/dist/certifiedAudit.js +124 -0
  20. package/dist/certifiedAudit.js.map +1 -1
  21. package/dist/claude-setup.d.ts +15 -6
  22. package/dist/claude-setup.js +30 -17
  23. package/dist/claude-setup.js.map +1 -1
  24. package/dist/cli.d.ts +7 -1
  25. package/dist/cli.js +212 -187
  26. package/dist/cli.js.map +1 -1
  27. package/dist/connect-config.d.ts +109 -0
  28. package/dist/connect-config.js +251 -0
  29. package/dist/connect-config.js.map +1 -0
  30. package/dist/encryption.d.ts +4 -0
  31. package/dist/encryption.js +7 -1
  32. package/dist/encryption.js.map +1 -1
  33. package/dist/evidence.d.ts +94 -0
  34. package/dist/evidence.js +352 -0
  35. package/dist/evidence.js.map +1 -0
  36. package/dist/idl.d.ts +21 -3
  37. package/dist/idl.js +34 -4
  38. package/dist/idl.js.map +1 -1
  39. package/dist/index.d.ts +13 -6
  40. package/dist/index.js +22 -5
  41. package/dist/index.js.map +1 -1
  42. package/dist/ledgerfsHash.d.ts +0 -2
  43. package/dist/ledgerfsHash.js +0 -2
  44. package/dist/ledgerfsHash.js.map +1 -1
  45. package/dist/lineage.d.ts +7 -1
  46. package/dist/lineage.js +7 -1
  47. package/dist/lineage.js.map +1 -1
  48. package/dist/memoryArchive.d.ts +77 -98
  49. package/dist/memoryArchive.js +58 -31
  50. package/dist/memoryArchive.js.map +1 -1
  51. package/dist/migrate.d.ts +18 -30
  52. package/dist/migrate.js +42 -136
  53. package/dist/migrate.js.map +1 -1
  54. package/dist/openEngram.d.ts +7 -0
  55. package/dist/openEngram.js +27 -3
  56. package/dist/openEngram.js.map +1 -1
  57. package/dist/openclaw-local.d.ts +86 -0
  58. package/dist/openclaw-local.js +332 -0
  59. package/dist/openclaw-local.js.map +1 -0
  60. package/dist/openclaw-setup.d.ts +82 -3
  61. package/dist/openclaw-setup.js +162 -50
  62. package/dist/openclaw-setup.js.map +1 -1
  63. package/dist/pair.js.map +1 -1
  64. package/dist/path-utils.d.ts +0 -16
  65. package/dist/path-utils.js +4 -27
  66. package/dist/path-utils.js.map +1 -1
  67. package/dist/publicRecord.d.ts +5 -0
  68. package/dist/publicRecord.js +52 -0
  69. package/dist/publicRecord.js.map +1 -0
  70. package/dist/recordChain.d.ts +69 -0
  71. package/dist/recordChain.js +145 -0
  72. package/dist/recordChain.js.map +1 -0
  73. package/dist/schema.d.ts +11 -22
  74. package/dist/schema.js +6 -28
  75. package/dist/schema.js.map +1 -1
  76. package/dist/types.d.ts +67 -451
  77. package/dist/verify.d.ts +8 -0
  78. package/dist/verify.js +19 -0
  79. package/dist/verify.js.map +1 -0
  80. package/dist/version.d.ts +22 -0
  81. package/dist/version.js +22 -0
  82. package/dist/version.js.map +1 -1
  83. package/package.json +27 -12
  84. package/dist/generated/engram.idl.d.ts +0 -6
  85. package/dist/generated/engram.idl.js +0 -1366
  86. package/dist/generated/engram.idl.js.map +0 -1
  87. package/dist/generated/market.idl.d.ts +0 -6
  88. package/dist/generated/market.idl.js +0 -557
  89. package/dist/generated/market.idl.js.map +0 -1
  90. package/dist/generated/registry.idl.d.ts +0 -6
  91. package/dist/generated/registry.idl.js +0 -510
  92. package/dist/generated/registry.idl.js.map +0 -1
  93. package/dist/offline.d.ts +0 -21
  94. package/dist/offline.js +0 -104
  95. package/dist/offline.js.map +0 -1
@@ -0,0 +1,233 @@
1
+ // birthChain.ts — verify an engram's BIRTH CHAIN: where it came from, proven against the IC root key
2
+ // without trusting the registry that minted it or the engram that holds it.
3
+ //
4
+ // WHAT A BIRTH CHAIN IS. Every engram a registry opens gets a birth record: which engram it is, which
5
+ // engram it was opened from (none for a first engram), its engram number, when it was born, a 32-byte
6
+ // random secret, and the fingerprint of its parent's record. The engram holds its own record and
7
+ // copies of its ancestors' records — root first, its own last — and serves them to its OWNER only
8
+ // (`getBirthChain`); the owner decides whom to show them to. The registry certifies each record's
9
+ // FINGERPRINT, and nothing else about it, as a leaf of its certified tree under
10
+ // ["births", <fingerprint>] with the constant value [0x01] (`getCertifiedBirth`, public).
11
+ //
12
+ // WHAT THIS CHECKS, every step required (a false `verified` names the first failure in `why`):
13
+ // 1. the chain is not empty and every record is version 1 and encodable;
14
+ // 2. each adjacent pair LINKS: the later record names the earlier one as its parent AND carries the
15
+ // earlier record's fingerprint — recomputed here from the canonical encoding, never read off the
16
+ // wire;
17
+ // 3. each fingerprint's witness verifies up to the registry's subnet-signed certified data
18
+ // (`verifyCertifiedLeaf`), with the leaf bytes equal to [0x01];
19
+ // 4. `expectChild`, when given, is the chain's last record.
20
+ // `complete` says whether the chain starts at a first engram (no parent, no parent fingerprint). A run
21
+ // that starts part-way is allowed and still `verified`: an owner may show any contiguous run, and an
22
+ // engram whose oldest ancestors were born before birth records existed holds one.
23
+ //
24
+ // WHAT IT CANNOT TELL YOU. That the records name the engrams you think they do beyond the ids they
25
+ // carry, or anything about who owns them — a record holds no person's identity, by design. Absence:
26
+ // the registry serves no certified proof that a fingerprint is NOT in its tree, so an uncertified
27
+ // link is "not proven", never "proven false".
28
+ //
29
+ // THE ENCODING is the registry's (`BirthRecord.encode`), byte for byte; the golden vector in
30
+ // test/birth-chain.test.ts is the same one the Motoko suite asserts, and a repository test holds the
31
+ // two hex literals equal.
32
+ //
33
+ // Browser-safe: WebCrypto SHA-256, no Node imports.
34
+ import { Actor } from '@icp-sdk/core/agent';
35
+ import { verifyCertifiedLeaf } from './certifiedAudit.js';
36
+ import { registrySubset } from './idl.js';
37
+ export function fromCandidBirthRecord(c) {
38
+ return {
39
+ version: c.version,
40
+ child: c.child,
41
+ parent: c.parent.length ? c.parent[0] : null,
42
+ number: c.number,
43
+ bornAtNs: c.bornAtNs,
44
+ secret: Uint8Array.from(c.secret),
45
+ parentFingerprint: c.parentFingerprint.length ? Uint8Array.from(c.parentFingerprint[0]) : null,
46
+ };
47
+ }
48
+ const DOMAIN_TAG = new TextEncoder().encode('engramx/birth/v1');
49
+ const TWO_64 = 1n << 64n;
50
+ function u64(n, what) {
51
+ if (n < 0n || n >= TWO_64)
52
+ throw new Error(`${what} does not fit in an unsigned 64-bit integer`);
53
+ const out = [];
54
+ for (let i = 7; i >= 0; i--)
55
+ out.push(Number((n >> BigInt(i * 8)) & 0xffn));
56
+ return out;
57
+ }
58
+ /**
59
+ * The canonical encoding, version 1 (big-endian, no Candid):
60
+ *
61
+ * "engramx/birth/v1" 16 ASCII bytes
62
+ * u8 len(child) ‖ child bytes
63
+ * u8 0 | u8 1 ‖ u8 len(parent) ‖ parent bytes
64
+ * u64 number
65
+ * u64 bornAtNs (never negative)
66
+ * u8 len(secret) ‖ secret (len = 32)
67
+ * u8 0 | u8 1 ‖ 32 bytes parentFingerprint
68
+ *
69
+ * Throws on a record the registry could never have minted (wrong version, a secret or parent
70
+ * fingerprint that is not 32 bytes, a negative or oversized number or time).
71
+ */
72
+ export function encodeBirthRecord(r) {
73
+ if (r.version !== 1n)
74
+ throw new Error(`birth record version ${r.version} is not 1`);
75
+ if (r.secret.length !== 32)
76
+ throw new Error(`birth record secret is ${r.secret.length} bytes, not 32`);
77
+ if (r.parentFingerprint && r.parentFingerprint.length !== 32)
78
+ throw new Error('birth record parent fingerprint is not 32 bytes');
79
+ const out = [...DOMAIN_TAG];
80
+ const child = r.child.toUint8Array();
81
+ out.push(child.length, ...child);
82
+ if (r.parent) {
83
+ const p = r.parent.toUint8Array();
84
+ out.push(1, p.length, ...p);
85
+ }
86
+ else
87
+ out.push(0);
88
+ out.push(...u64(r.number, 'the engram number'), ...u64(r.bornAtNs, 'the birth time'));
89
+ out.push(r.secret.length, ...r.secret);
90
+ if (r.parentFingerprint)
91
+ out.push(1, ...r.parentFingerprint);
92
+ else
93
+ out.push(0);
94
+ return Uint8Array.from(out);
95
+ }
96
+ /** SHA-256 of the canonical encoding (WebCrypto) — the key of the record's certified leaf. */
97
+ export async function birthFingerprint(r) {
98
+ const digest = await globalThis.crypto.subtle.digest('SHA-256', encodeBirthRecord(r));
99
+ return new Uint8Array(digest);
100
+ }
101
+ const hex = (b) => Array.from(b, (x) => x.toString(16).padStart(2, '0')).join('');
102
+ const sameBytes = (a, b) => a === null || b === null ? a === b : a.length === b.length && a.every((x, i) => x === b[i]);
103
+ const asText = (p) => (typeof p === 'string' ? p : p.toText());
104
+ const registryBirthIdl = registrySubset(['getCertifiedBirth']);
105
+ /**
106
+ * The default witness fetcher: the registry's public `getCertifiedBirth`, through a narrowed view of
107
+ * the GENERATED registry interface (`registrySubset`), so its signature can never drift from what the
108
+ * registry serves. Anonymous agents are fine — the read is public and reveals only presence.
109
+ */
110
+ export function registryBirthWitness(agent, registryId) {
111
+ const registry = Actor.createActor(registryBirthIdl, { agent, canisterId: registryId });
112
+ return async (fingerprint) => {
113
+ const r = (await registry['getCertifiedBirth'](fingerprint));
114
+ return r.length ? r[0] : null;
115
+ };
116
+ }
117
+ /**
118
+ * Verify a birth chain (root first, the engram's own record last) against the registry's certified
119
+ * fingerprints.
120
+ *
121
+ * `fetchWitness` is INJECTED: it is called with each record's fingerprint and returns the registry's
122
+ * `getCertifiedBirth` reply (or null). Typically
123
+ * `(fp) => registryActor.getCertifiedBirth(fp).then((r) => (r.length ? r[0] : null))`.
124
+ * ⟨2026-10-26⟩ TODO(Finish phase): a default fetcher over `registrySubset(['getCertifiedBirth'])`
125
+ * needs the regenerated registry IDL — `projectService` throws on a method the generated interface
126
+ * does not carry yet — so it is added when `gen-did.sh` has run.
127
+ * ⟨DONE 2026-10-26, Finish phase⟩ `gen-did.sh` ran; `fetchWitness` is now optional and defaults to
128
+ * `registryBirthWitness(agent, registryId)`, a narrowed view of the generated registry interface —
129
+ * never a hand-declared shape (the drift class ADR-0018 answers).
130
+ *
131
+ * The agent's root key must be set (`fetchRootKey()` first, on a local replica only).
132
+ */
133
+ export async function verifyBirthChain(agent, registryId, records, opts = {}) {
134
+ const fetchWitness = opts.fetchWitness ?? registryBirthWitness(agent, registryId);
135
+ const first = records[0];
136
+ const last = records[records.length - 1];
137
+ const endsAt = last ? last.child.toText() : null;
138
+ const complete = first !== undefined && first.parent === null && first.parentFingerprint === null;
139
+ const fail = (why, links = []) => ({
140
+ verified: false,
141
+ complete,
142
+ endsAt,
143
+ links,
144
+ why,
145
+ });
146
+ if (records.length === 0)
147
+ return fail('the chain is empty — there is nothing to verify');
148
+ // Fingerprints, recomputed from the canonical encoding — never taken from the wire.
149
+ const rows = [];
150
+ for (const [i, rec] of records.entries()) {
151
+ try {
152
+ rows.push({ rec, fp: await birthFingerprint(rec) });
153
+ }
154
+ catch (e) {
155
+ return fail(`record ${i} (${rec.child.toText()}) cannot be encoded: ${e.message}`);
156
+ }
157
+ }
158
+ // Links: each record names the one before it as its parent AND carries its fingerprint.
159
+ let linkBreak = null;
160
+ rows.reduce((prev, cur, i) => {
161
+ if (prev !== null && linkBreak === null) {
162
+ if (cur.rec.parent === null || cur.rec.parent.toText() !== prev.rec.child.toText()) {
163
+ linkBreak = `record ${i} (${cur.rec.child.toText()}) does not name record ${i - 1} (${prev.rec.child.toText()}) as its parent`;
164
+ }
165
+ else if (!sameBytes(cur.rec.parentFingerprint, prev.fp)) {
166
+ linkBreak = `record ${i} (${cur.rec.child.toText()}) does not carry the fingerprint of record ${i - 1}`;
167
+ }
168
+ }
169
+ return cur;
170
+ }, null);
171
+ // Witnesses: each fingerprint must be a certified leaf with the constant value [0x01].
172
+ const utf8 = (s) => new TextEncoder().encode(s);
173
+ const links = [];
174
+ for (const { rec, fp } of rows) {
175
+ const child = rec.child.toText();
176
+ const fingerprintHex = hex(fp);
177
+ let reply;
178
+ try {
179
+ reply = await fetchWitness(fp);
180
+ }
181
+ catch (e) {
182
+ links.push({
183
+ child,
184
+ fingerprintHex,
185
+ certified: false,
186
+ why: `the witness could not be fetched: ${e.message}`,
187
+ });
188
+ continue;
189
+ }
190
+ if (!reply) {
191
+ links.push({
192
+ child,
193
+ fingerprintHex,
194
+ certified: false,
195
+ why: 'the registry holds no certified leaf for this fingerprint (no proof either way — an absence is not certified)',
196
+ });
197
+ continue;
198
+ }
199
+ const leaf = await verifyCertifiedLeaf(agent, registryId, reply, [utf8('births'), fp]);
200
+ if (!leaf.verified || !leaf.valueBytes) {
201
+ links.push({ child, fingerprintHex, certified: false, why: leaf.why });
202
+ }
203
+ else if (!(leaf.valueBytes.length === 1 && leaf.valueBytes[0] === 1)) {
204
+ links.push({
205
+ child,
206
+ fingerprintHex,
207
+ certified: false,
208
+ why: 'the certified leaf is not the constant [0x01]',
209
+ });
210
+ }
211
+ else {
212
+ links.push({ child, fingerprintHex, certified: true, why: 'ok' });
213
+ }
214
+ }
215
+ if (linkBreak !== null)
216
+ return fail(linkBreak, links);
217
+ const uncertified = links.find((l) => !l.certified);
218
+ if (uncertified)
219
+ return fail(`the record of ${uncertified.child} is not certified: ${uncertified.why}`, links);
220
+ if (opts.expectChild !== undefined && asText(opts.expectChild) !== endsAt) {
221
+ return fail(`the chain ends at ${endsAt}, not at the expected engram ${asText(opts.expectChild)}`, links);
222
+ }
223
+ return {
224
+ verified: true,
225
+ complete,
226
+ endsAt,
227
+ links,
228
+ why: complete
229
+ ? 'ok — every record certified and linked, from a first engram'
230
+ : 'ok — every record certified and linked; the chain starts part-way (an ancestor before it is not shown)',
231
+ };
232
+ }
233
+ //# sourceMappingURL=birthChain.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"birthChain.js","sourceRoot":"","sources":["../src/birthChain.ts"],"names":[],"mappings":"AAAA,qGAAqG;AACrG,4EAA4E;AAC5E,EAAE;AACF,sGAAsG;AACtG,sGAAsG;AACtG,iGAAiG;AACjG,kGAAkG;AAClG,kGAAkG;AAClG,gFAAgF;AAChF,0FAA0F;AAC1F,EAAE;AACF,+FAA+F;AAC/F,2EAA2E;AAC3E,sGAAsG;AACtG,sGAAsG;AACtG,aAAa;AACb,6FAA6F;AAC7F,qEAAqE;AACrE,8DAA8D;AAC9D,uGAAuG;AACvG,qGAAqG;AACrG,kFAAkF;AAClF,EAAE;AACF,mGAAmG;AACnG,oGAAoG;AACpG,kGAAkG;AAClG,8CAA8C;AAC9C,EAAE;AACF,6FAA6F;AAC7F,qGAAqG;AACrG,0BAA0B;AAC1B,EAAE;AACF,oDAAoD;AAEpD,OAAO,EAAE,KAAK,EAAkB,MAAM,qBAAqB,CAAC;AAE5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAuB1C,MAAM,UAAU,qBAAqB,CAAC,CAAoB;IACxD,OAAO;QACL,OAAO,EAAE,CAAC,CAAC,OAAO;QAClB,KAAK,EAAE,CAAC,CAAC,KAAK;QACd,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI;QAC5C,MAAM,EAAE,CAAC,CAAC,MAAM;QAChB,QAAQ,EAAE,CAAC,CAAC,QAAQ;QACpB,MAAM,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC;QACjC,iBAAiB,EAAE,CAAC,CAAC,iB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,CAAC,GAAG,CAAC,GAAG,EAAE;YAClB,KAAK;YACL,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,KAAK,IAAI,IAAI,CAAC,UAAU,CAAC;SACnD,CAAC,CAAC;IACL,CAAC;IAED,UAAU,CAAC,GAAW;QACpB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IACzB,CAAC;IAED,KAAK;QACH,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;IACzB,CAAC;CACF"}
@@ -88,3 +88,34 @@ export declare function verifyCertifiedAnchor(agent: HttpAgent, registryId: Prin
88
88
  certificate: [] | [Uint8Array | number[]];
89
89
  witness: [] | [Uint8Array | number[]] | Uint8Array | number[];
90
90
  }): Promise<CertifiedLeaf>;
91
+ /** The IC mainnet root key (133 bytes, DER), pinned. SHA-256 737ba355…f4b6b3 — the same value the
92
+ * agent library carries as its mainnet default; test/record-chain.test.ts holds the two equal. */
93
+ export declare const IC_MAINNET_ROOT_KEY_HEX = "308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100814c0e6ec71fab583b08bd81373c255c3c371b2e84863c98a4f1e08b74235d14fb5d9c0cd546d9685f913a0c0b2cc5341583bf4b4392e467db96d65b9bb4cb717112f8472e0d5a4d14505ffd7484b01291091c5f87b98883463f98091a0baaae";
94
+ export interface HistoricalCertificate {
95
+ verified: boolean;
96
+ /** Self-classifying: names the link that failed. Never act on the other fields unless `verified`. */
97
+ why: string;
98
+ /** The canister's certified data the subnet signed (a bare head, or a tree root). */
99
+ certifiedData: Uint8Array | null;
100
+ /** The certificate's own signed time, nanoseconds since the epoch. */
101
+ signedTimeNs: bigint | null;
102
+ /** With a witness and a leaf path (the registry's tree format): the leaf proven under the root. */
103
+ leaf: Uint8Array | null;
104
+ }
105
+ /**
106
+ * Verify a certificate of ANY age for one canister and read what it certifies and when.
107
+ *
108
+ * Checks, every one required: the BLS signature and its delegation chain verify against `rootKey`
109
+ * (default: the pinned mainnet key — a local replica's certificate, or one under any other key,
110
+ * fails here); the delegation covers `canisterId`; the tree carries `/canister/<id>/certified_data`
111
+ * (a certificate another canister obtained does not — it fails with that said); `/time` is present.
112
+ * With `witness` and `leafPath`, the witness must reconstruct to the certified root and hold the leaf.
113
+ * Freshness is NOT checked, by design (the header above says why). Fails closed with a reason.
114
+ */
115
+ export declare function verifyHistoricalCertificate(args: {
116
+ certificate: Uint8Array | number[];
117
+ canisterId: Principal | string;
118
+ rootKey?: Uint8Array;
119
+ witness?: Uint8Array | number[] | null;
120
+ leafPath?: Uint8Array[];
121
+ }): Promise<HistoricalCertificate>;
@@ -204,4 +204,128 @@ export async function verifyCertifiedAnchor(agent, registryId, engramId, reply)
204
204
  engram.toUint8Array(),
205
205
  ]);
206
206
  }
207
+ // ── Historical certificates (2026-10-15, the owner's ruling 6B of 2026-10-14) ──────────────────────
208
+ //
209
+ // EVERY VERIFIER ABOVE IS FRESH-ONLY, and that is right for them: they answer "is this head the one
210
+ // the subnet signs NOW", and `Certificate.create`'s default refuses a certificate more than five
211
+ // minutes old. It is wrong for evidence. What proves "this entry existed by time T" is a certificate
212
+ // whose SIGNED time is T and which covers a head the entry is in — captured right after the write
213
+ // and checked weeks later, by someone who was not there. Nobody can forge the subnet's signature over
214
+ // a past time, so an old certificate is not weaker than a fresh one; it is the point. So this check
215
+ // is EXPLICIT and separate: it accepts a certificate of any age, verifies the signature against a
216
+ // pinned root key (never one fetched from the network being checked), reads the certificate's own
217
+ // signed `/time`, and hands back the certified bytes. The fresh verifiers keep their default.
218
+ //
219
+ // No entry has a certified time of its own: an entry's certified time is the signed time of the
220
+ // earliest certificate one keeps that covers it.
221
+ /** The IC mainnet root key (133 bytes, DER), pinned. SHA-256 737ba355…f4b6b3 — the same value the
222
+ * agent library carries as its mainnet default; test/record-chain.test.ts holds the two equal. */
223
+ export const IC_MAINNET_ROOT_KEY_HEX = '308182301d060d2b0601040182dc7c0503010201060c2b0601040182dc7c05030201036100814c0e6ec71fab583b08bd81373c255c3c371b2e84863c98a4f1e08b74235d14fb5d9c0cd546d9685f913a0c0b2cc5341583bf4b4392e467db96d65b9bb4cb717112f8472e0d5a4d14505ffd7484b01291091c5f87b98883463f98091a0baaae';
224
+ const hexBytes = (h) => {
225
+ const clean = h.trim().toLowerCase();
226
+ if (!/^([0-9a-f]{2})*$/.test(clean))
227
+ throw new Error('not an even-length hex string');
228
+ return Uint8Array.from(clean.match(/../g) ?? [], (b) => parseInt(b, 16));
229
+ };
230
+ /** Unsigned LEB128 — how the state tree encodes `/time` (nanoseconds since the epoch). */
231
+ function leb128(buf) {
232
+ let out = 0n;
233
+ let shift = 0n;
234
+ for (const byte of buf) {
235
+ out |= BigInt(byte & 0x7f) << shift;
236
+ if ((byte & 0x80) === 0)
237
+ break;
238
+ shift += 7n;
239
+ }
240
+ return out;
241
+ }
242
+ /**
243
+ * Verify a certificate of ANY age for one canister and read what it certifies and when.
244
+ *
245
+ * Checks, every one required: the BLS signature and its delegation chain verify against `rootKey`
246
+ * (default: the pinned mainnet key — a local replica's certificate, or one under any other key,
247
+ * fails here); the delegation covers `canisterId`; the tree carries `/canister/<id>/certified_data`
248
+ * (a certificate another canister obtained does not — it fails with that said); `/time` is present.
249
+ * With `witness` and `leafPath`, the witness must reconstruct to the certified root and hold the leaf.
250
+ * Freshness is NOT checked, by design (the header above says why). Fails closed with a reason.
251
+ */
252
+ export async function verifyHistoricalCertificate(args) {
253
+ const fail = (why) => ({
254
+ verified: false,
255
+ why,
256
+ certifiedData: null,
257
+ signedTimeNs: null,
258
+ leaf: null,
259
+ });
260
+ const principal = typeof args.canisterId === 'string' ? Principal.fromText(args.canisterId) : args.canisterId;
261
+ const rootKey = args.rootKey ?? hexBytes(IC_MAINNET_ROOT_KEY_HEX);
262
+ const certBytes = Uint8Array.from(args.certificate);
263
+ if (certBytes.length === 0)
264
+ return fail('no certificate');
265
+ let cert;
266
+ try {
267
+ cert = await Certificate.create({
268
+ certificate: certBytes,
269
+ rootKey,
270
+ principal: { canisterId: principal },
271
+ disableTimeVerification: true,
272
+ });
273
+ }
274
+ catch (e) {
275
+ return fail(`the certificate does not verify against ${args.rootKey ? 'the given' : 'the pinned IC mainnet'} root key for canister ${principal.toText()} ` +
276
+ `(a local replica's certificate, one issued on another subnet, or altered bytes): ${e.message}`);
277
+ }
278
+ let timeLookup;
279
+ let dataLookup;
280
+ try {
281
+ timeLookup = cert.lookup_path(['time']);
282
+ dataLookup = cert.lookup_path(['canister', principal.toUint8Array(), 'certified_data']);
283
+ }
284
+ catch (e) {
285
+ return fail(`certificate tree walk failed: ${e.message}`);
286
+ }
287
+ if (timeLookup.status !== LookupPathStatus.Found)
288
+ return fail('the certificate carries no /time');
289
+ const signedTimeNs = leb128(new Uint8Array(lookupResultToBuffer(timeLookup)));
290
+ if (dataLookup.status !== LookupPathStatus.Found) {
291
+ return fail(`the certificate carries no certified data for ${principal.toText()}: it was issued for another canister`);
292
+ }
293
+ const certifiedData = new Uint8Array(lookupResultToBuffer(dataLookup));
294
+ if (args.witness == null || args.leafPath == null) {
295
+ return { verified: true, why: 'ok', certifiedData, signedTimeNs, leaf: null };
296
+ }
297
+ let tree;
298
+ try {
299
+ tree = Cbor.decode(Uint8Array.from(args.witness));
300
+ }
301
+ catch {
302
+ return fail('witness is not decodable CBOR');
303
+ }
304
+ let root;
305
+ try {
306
+ root = new Uint8Array(await reconstruct(tree));
307
+ }
308
+ catch {
309
+ return fail('witness is decodable CBOR but not a hash tree');
310
+ }
311
+ if (root.length !== certifiedData.length || !root.every((b, i) => b === certifiedData[i])) {
312
+ return fail('the witness root does not match the certified data: the witness is not for this certificate');
313
+ }
314
+ let leafLookup;
315
+ try {
316
+ leafLookup = lookup_path(args.leafPath, tree);
317
+ }
318
+ catch {
319
+ return fail('witness tree is malformed at the requested path');
320
+ }
321
+ if (leafLookup.status !== LookupPathStatus.Found)
322
+ return fail('the leaf is not in the witness');
323
+ return {
324
+ verified: true,
325
+ why: 'ok',
326
+ certifiedData,
327
+ signedTimeNs,
328
+ leaf: new Uint8Array(lookupResultToBuffer(leafLookup)),
329
+ };
330
+ }
207
331
  //# sourceMappingURL=certifiedAudit.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"certifiedAudit.js","sourceRoot":"","sources":["../src/certifiedAudit.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,EAAE;AACF,iGAAiG;AACjG,mGAAmG;AACnG,kGAAkG;AAClG,iGAAiG;AACjG,EAAE;AACF,mGAAmG;AACnG,mGAAmG;AACnG,8FAA8F;AAC9F,iGAAiG;AACjG,4EAA4E;AAE5E,OAAO,EACL,WAAW,EACX,oBAAoB,EACpB,gBAAgB,GAEjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAqBpD;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,KAAgB,EAChB,UAA8B,EAC9B,OAA2B;IAE3B,MAAM,IAAI,GAAsB,EAAE,IAAI,EAAE,IAAI,UAAU,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IACjG,IAAI,CAAC,OAAO,CAAC,WAAW;QAAE,OAAO,IAAI,CAAC,CAAC,yDAAyD;IAEhG,MAAM,SAAS,GAAG,OAAO,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;IAE/F,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC;IAC9B,IAAI,OAAO,IAAI,IAAI,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CACb,oGAAoG,CACrG,CAAC;IACJ,CAAC;IAED,IAAI,IAAiB,CAAC;IACtB,IAAI,CAAC;QACH,mFAAm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L,QAAQ,EAAE,IAAI;QACd,GAAG,EAAE,IAAI;QACT,aAAa;QACb,YAAY;QACZ,IAAI,EAAE,IAAI,UAAU,CAAC,oBAAoB,CAAC,UAAU,CAAE,CAAC;KACxD,CAAC;AACJ,CAAC"}
@@ -1,18 +1,27 @@
1
1
  /**
2
2
  * Claude setup — generates MCP config for Claude Code and Claude Cowork.
3
+ *
4
+ * ⟨2026-10-13, the bloat audit⟩ ONE generator, ONE writer. This file built its own
5
+ * `mcpServers.engramx` entry while @engramx/mcp's `connect` built another (connect-config.ts), and
6
+ * the two had drifted: this path was macOS-only, the other per-OS; this one wrote atomically, the
7
+ * other did not; the mainnet spellings and the session-key variable differed. The entry now comes
8
+ * from connect-config.ts (`claudeDesktopConfig`), the Claude Desktop path is per-OS here, and
9
+ * `installMcpConfig` — atomic, refusing a config it cannot parse — is the one writer, which
10
+ * `@engramx/mcp connect --write` uses too.
3
11
  */
12
+ import { type StdioServerEntry } from './connect-config.js';
4
13
  export interface ClaudeSetupOptions {
5
14
  canisterId: string;
6
- sessionKeyPath: string;
15
+ /** The key file the server reads; omitted, the server reads ~/.engramx/session.key. */
16
+ sessionKeyPath?: string;
7
17
  host?: string;
18
+ /** The @engramx/mcp version the entry runs. Default: this package's (the packages share one);
19
+ * `@engramx/mcp connect` passes its own, since npm can pair it with a later client. */
20
+ version?: string;
8
21
  }
9
22
  export interface McpConfig {
10
23
  mcpServers: {
11
- engramx: {
12
- command: string;
13
- args: string[];
14
- env: Record<string, string>;
15
- };
24
+ engramx: StdioServerEntry;
16
25
  };
17
26
  }
18
27
  /** Generate the MCP server config block for Claude. */
@@ -1,37 +1,50 @@
1
1
  /**
2
2
  * Claude setup — generates MCP config for Claude Code and Claude Cowork.
3
+ *
4
+ * ⟨2026-10-13, the bloat audit⟩ ONE generator, ONE writer. This file built its own
5
+ * `mcpServers.engramx` entry while @engramx/mcp's `connect` built another (connect-config.ts), and
6
+ * the two had drifted: this path was macOS-only, the other per-OS; this one wrote atomically, the
7
+ * other did not; the mainnet spellings and the session-key variable differed. The entry now comes
8
+ * from connect-config.ts (`claudeDesktopConfig`), the Claude Desktop path is per-OS here, and
9
+ * `installMcpConfig` — atomic, refusing a config it cannot parse — is the one writer, which
10
+ * `@engramx/mcp connect --write` uses too.
3
11
  */
4
12
  import * as fs from 'fs';
13
+ import * as os from 'os';
5
14
  import * as path from 'path';
6
15
  import { atomicWriteFileSync } from './path-utils.js';
16
+ import { VERSION } from './version.js';
17
+ import { claudeDesktopConfig } from './connect-config.js';
7
18
  /** Generate the MCP server config block for Claude. */
8
19
  export function generateMcpConfig(options) {
9
- const env = {
10
- ENGRAM_CANISTER_ID: options.canisterId,
11
- ENGRAM_SESSION_KEY_PATH: options.sessionKeyPath,
12
- };
13
- if (options.host && options.host !== 'https://ic0.app') {
14
- env['ENGRAM_HOST'] = options.host;
20
+ return claudeDesktopConfig({
21
+ canisterId: options.canisterId,
22
+ host: options.host,
23
+ clientVersion: options.version ?? VERSION,
24
+ sessionKeyPath: options.sessionKeyPath,
25
+ });
26
+ }
27
+ /** The default claude_desktop_config.json path for this OS. */
28
+ function claudeDesktopConfigPath(home) {
29
+ switch (os.platform()) {
30
+ case 'darwin':
31
+ return path.join(home, 'Library', 'Application Support', 'Claude', 'claude_desktop_config.json');
32
+ case 'win32':
33
+ return path.join(process.env['APPDATA'] || path.join(home, 'AppData', 'Roaming'), 'Claude', 'claude_desktop_config.json');
34
+ default:
35
+ return path.join(home, '.config', 'Claude', 'claude_desktop_config.json');
15
36
  }
16
- return {
17
- mcpServers: {
18
- engramx: {
19
- command: 'npx',
20
- args: ['-y', '@engramx/mcp'],
21
- env,
22
- },
23
- },
24
- };
25
37
  }
26
38
  /** Return the config paths for each Claude product. */
27
39
  export function claudeConfigPaths() {
28
- const home = process.env['HOME'] || '';
40
+ const home = process.env['HOME'] || os.homedir();
29
41
  return {
30
42
  // Claude Code reads user-scope MCP servers from ~/.claude.json (the file
31
43
  // `claude mcp add --scope user` writes). ~/.claude/settings.json does NOT
32
44
  // carry mcpServers — writing there is a silent no-op for the user.
33
45
  claudeCode: path.join(home, '.claude.json'),
34
- claudeDesktop: path.join(home, 'Library', 'Application Support', 'Claude', 'claude_desktop_config.json'),
46
+ // ⟨2026-10-13⟩ Per-OS; it was the macOS path everywhere until the two generators merged.
47
+ claudeDesktop: claudeDesktopConfigPath(home),
35
48
  };
36
49
  }
37
50
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"claude-setup.js","sourceRoot":"","sources":["../src/claude-setup.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAkBtD,uDAAuD;AACvD,MAAM,UAAU,iBAAiB,CAAC,OAA2B;IAC3D,MAAM,GAAG,GAA2B;QAClC,kBAAkB,EAAE,OAAO,CAAC,UAAU;QACtC,uBAAuB,EAAE,OAAO,CAAC,cAAc;KAChD,CAAC;IACF,IAAI,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,KAAK,iBAAiB,EAAE,CAAC;QACvD,GAAG,CAAC,aAAa,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IACpC,CAAC;IAED,OAAO;QACL,UAAU,EAAE;YACV,OAAO,EAAE;gBACP,OAAO,EAAE,KAAK;gBACd,IAAI,EAAE,CAAC,IAAI,EAAE,cAAc,CAAC;gBAC5B,GAAG;aACJ;SACF;KACF,CAAC;AACJ,CAAC;AAED,uDAAuD;AACvD,MAAM,UAAU,iBAAiB;IAC/B,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IACvC,OAAO;QACL,yEAAyE;QACzE,0EAA0E;QAC1E,mEAAmE;QACnE,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC;QAC3C,aAAa,EAAE,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,QAAQ,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC;IAEjC,yEAAyE;IACzE,4EAA4E;IAC5E,mBAAmB,CAAC,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;AAC9E,CAAC"}
package/dist/cli.d.ts CHANGED
@@ -1,2 +1,8 @@
1
1
  #!/usr/bin/env node
2
- export {};
2
+ /**
3
+ * The run this module starts when it is loaded — the command line's whole life.
4
+ * ⟨2026-10-13⟩ Exported so a test can load the CLI with stubbed network modules and wait for the
5
+ * command to END (test/pair-migrate.test.ts); before, a test could only wait one tick, which is
6
+ * enough for --help and not for pair.
7
+ */
8
+ export declare const finished: Promise<void>;