@engramx/client 0.16.0-rc.20 → 0.16.0-rc.22

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.
@@ -31,11 +31,39 @@
31
31
  //
32
32
  // This module holds the whole command so a test can drive it with a stub engram and no network;
33
33
  // cli.ts only parses flags and passes the terminal in.
34
+ //
35
+ // ⟨ADDED 2026-11-02, the child build's stage 8 — the owner's rulings "1-4 all as you recommended",
36
+ // "choice 4 without hand over" and "1 yes, but the child can ask again", and the build's resolution
37
+ // L20⟩ THE SIGN-IN, THE SEAL AND THE VERSION CHECK. An engram opened this way is born with a sign-in:
38
+ // the person running the agent, on a second credential. The sign-in approves what the key file
39
+ // cannot (payments over the limits, sellers, trading keys, lifting freezes, guardians) and alone opens
40
+ // the sealed copy of this key; the key file keeps every everyday act and can loosen nothing. The
41
+ // command now:
42
+ // 2a reads the version of the engram it opens through and REFUSES one older than
43
+ // SIGN_IN_FLOOR_VERSION (L20) — an older engram cannot carry a sign-in to the registry, and an
44
+ // engram opened with none keeps small limits for life;
45
+ // 2b settles the sign-in BEFORE anything is spent: `--sign-in <principal>` (checked by
46
+ // `signInRefusal`), `--no-sign-in` (the "small limits for life, no recovery" warning), or — only
47
+ // at a terminal and without `--yes` — the registry's offer (`getChildSignInOffer`, read as the
48
+ // lasting key) printed in full with "is this yours?", else a pasted principal. A run with no
49
+ // terminal, or with `--yes`, and neither flag is REFUSED: `--yes` alone never picks a sign-in,
50
+ // because nobody would have confirmed it;
51
+ // 4 opens with that sign-in (`openChild({ signIn })` on the engram);
52
+ // 4b seals a copy of the lasting key to the sign-in and stores it in the opened engram as its owner
53
+ // (`sealOpenedEngram`), retried for up to a minute (the engram is seconds old). A failed seal
54
+ // does not fail the command: the engram is open, and the printed `seal-key` command finishes it.
55
+ // WHAT WOULD MAKE THIS WRONG: the engram's door accepting a sign-in this kit refuses or the reverse
56
+ // (both follow the registry's three rules plus the session key); the offer disclosing an owner for an
57
+ // engram that is not a first engram (the registry answers none then, and the kit never offers one).
34
58
  import * as fs from 'fs';
35
59
  import * as path from 'path';
60
+ import { Actor, HttpAgent } from '@icp-sdk/core/agent';
61
+ import { Principal } from '@icp-sdk/core/principal';
36
62
  import { loadSessionKey } from './auth.js';
37
63
  import { EngramClient } from './EngramClient.js';
38
- import { CanisterRefusal } from './wire.js';
64
+ import { sealToPrincipal } from './encryption.js';
65
+ import { registrySubset } from './idl.js';
66
+ import { CanisterRefusal, unwrapResult } from './wire.js';
39
67
  import { VERSION, pairCommand } from './version.js';
40
68
  /**
41
69
  * ⟨2026-10-06⟩ A path as one shell word: as-is when it holds only characters no shell treats
@@ -49,6 +77,84 @@ export function shellWord(s) {
49
77
  /** The sentence printed when the owner has allowed nothing. Exported for the test. */
50
78
  export const NOT_ALLOWED = 'The owner of the wallet has not allowed this agent to open an engram of its own. ' +
51
79
  'Ask the owner to set it on the Access page.';
80
+ /**
81
+ * ⟨ADDED 2026-11-02, the build's resolution L20⟩ The first release whose engram carries a sign-in to
82
+ * the registry when it opens another (`openChild({ signIn })`). An engram older than this cannot: an
83
+ * rc.21 engram serves only `openChildEngram()` and would open with NO sign-in — for life — so the
84
+ * command refuses before anything is spent.
85
+ * WHAT WOULD MAKE THIS WRONG: the release that ships the sign-in being cut under another number
86
+ * (then this constant moves with it, in the same commit as the cut).
87
+ */
88
+ export const SIGN_IN_FLOOR_VERSION = '0.16.0-rc.22';
89
+ /** ⟨ADDED 2026-11-02, stage 8⟩ Printed before opening with no sign-in. Exported for the test. */
90
+ export const NO_SIGN_IN_WARNING = 'Opening with no sign-in: this engram keeps small limits for life. Nothing can approve a payment ' +
91
+ 'over them, add a seller or lift a freeze, and no sealed copy of this key is kept, so a lost key ' +
92
+ 'file cannot be recovered. Nobody can add a sign-in later.';
93
+ /** ⟨ADDED 2026-11-02, stage 8⟩ Printed when the stored copy is confirmed. Exported for the test. */
94
+ export const SEALED_LINE = 'A sealed copy of this key is stored in the engram; only your sign-in can open it.';
95
+ /**
96
+ * ⟨ADDED 2026-11-02, stage 8⟩ Compare two release versions (`major.minor.patch` with an optional
97
+ * `-rc.N`; a release candidate sorts BEFORE its release, and rc numbers compare as numbers, so rc.3 is
98
+ * older than rc.22). Negative, zero or positive like a sort comparator; null when either is not of
99
+ * that form — the caller then refuses, because it cannot tell.
100
+ */
101
+ export function compareVersions(a, b) {
102
+ const parse = (v) => {
103
+ const m = /^(\d+)\.(\d+)\.(\d+)(?:-rc\.(\d+))?$/.exec(v.trim());
104
+ if (!m)
105
+ return null;
106
+ return [Number(m[1]), Number(m[2]), Number(m[3]), m[4] === undefined ? Infinity : Number(m[4])];
107
+ };
108
+ const x = parse(a);
109
+ const y = parse(b);
110
+ if (!x || !y)
111
+ return null;
112
+ for (let i = 0; i < 4; i++) {
113
+ if (x[i] !== y[i])
114
+ return x[i] < y[i] ? -1 : 1;
115
+ }
116
+ return 0;
117
+ }
118
+ /** The management canister's id and any opaque canister id — the registry's `Funnel.isCanisterPrincipal`
119
+ * (1 to 10 bytes, the last one 1), plus the empty id, as the engram's `OwnerSignIn.candidateRefusal`. */
120
+ function isCanister(p) {
121
+ const b = p.toUint8Array();
122
+ return b.length === 0 || (b.length <= 10 && b[b.length - 1] === 1);
123
+ }
124
+ /**
125
+ * ⟨ADDED 2026-11-02, stage 8⟩ Why `text` cannot be the opened engram's sign-in, or null when it can.
126
+ * The registry's and the engram's doors refuse the same (defence in depth: this refusal comes before
127
+ * anything is spent and names the remedy):
128
+ * · text that is not a principal;
129
+ * · the anonymous principal — nobody can sign in as it;
130
+ * · the lasting key — the sign-in is a SECOND credential, never the key file that owns the engram;
131
+ * · the session key — a key the agent's software holds would approve its own requests;
132
+ * · a canister, the management canister included — a canister is never a person's sign-in.
133
+ */
134
+ export function signInRefusal(text, keys) {
135
+ let p;
136
+ try {
137
+ p = Principal.fromText(text.trim());
138
+ }
139
+ catch {
140
+ return `"${text}" is not a principal. A sign-in's principal looks like xxxxx-xxxxx-…-xxx.`;
141
+ }
142
+ if (p.isAnonymous()) {
143
+ return 'The sign-in named is the anonymous principal, which nobody can sign in as.';
144
+ }
145
+ if (p.toText() === keys.root.toText()) {
146
+ return ("The sign-in named is this agent's lasting key — the key file that will own the engram. " +
147
+ 'The sign-in is your second credential, never that key.');
148
+ }
149
+ if (p.toText() === keys.session.toText()) {
150
+ return ('The sign-in named is the key this agent calls with. The sign-in is your own sign-in, never a ' +
151
+ "key the agent's software holds.");
152
+ }
153
+ if (isCanister(p)) {
154
+ return 'The sign-in named is a canister, not a person’s sign-in.';
155
+ }
156
+ return null;
157
+ }
52
158
  function resolveHome(p) {
53
159
  return p.startsWith('~') ? path.join(process.env['HOME'] || '', p.slice(1)) : p;
54
160
  }
@@ -76,6 +182,95 @@ function refusalText(e) {
76
182
  return e.text;
77
183
  return e instanceof Error ? e.message : String(e);
78
184
  }
185
+ const sameBytes = (a, b) => a.length === b.length && a.every((x, i) => x === b[i]);
186
+ /** The lasting key: its identity and its 32 bytes (the seal's plaintext). Throws with the reason. */
187
+ function loadLastingKey(rootFile) {
188
+ const identity = loadSessionKey(rootFile); // checks: no symlink, mode 0600, 32 bytes
189
+ return { identity, seed: new Uint8Array(fs.readFileSync(rootFile)) };
190
+ }
191
+ /** The registry's offer read, signed by the lasting key (the door's own admission fact: that key has
192
+ * an open engagement on the engram it opens through). A narrowed view of the generated interface. */
193
+ function registryAs(identity, host) {
194
+ return (registryId) => {
195
+ const agent = HttpAgent.createSync({ identity, host, shouldFetchRootKey: isLocalHost(host) });
196
+ const actor = Actor.createActor(registrySubset(['getChildSignInOffer']), {
197
+ agent,
198
+ canisterId: registryId,
199
+ });
200
+ return {
201
+ async getChildSignInOffer(parent) {
202
+ const ok = unwrapResult(await actor['getChildSignInOffer'](parent), 'getChildSignInOffer');
203
+ return {
204
+ parentOwner: ok.parentOwner[0] ?? null,
205
+ parentIsFirstEngram: ok.parentIsFirstEngram,
206
+ parentActive: ok.parentActive,
207
+ };
208
+ },
209
+ };
210
+ };
211
+ }
212
+ const SEAL_RETRY_FOR_MS = 60000;
213
+ const SEAL_RETRY_EVERY_MS = 5000;
214
+ /**
215
+ * ⟨ADDED 2026-11-02, stage 8⟩ Seal the lasting key to `signIn` and store it in the opened engram as
216
+ * its owner, then read the stored copy back and require it to be the copy made here. Retried for up to
217
+ * a minute on anything that may pass (a network error, `#Unavailable`). A `#Conflict` on the store
218
+ * means a copy is already held: if it is byte for byte the one made here, an earlier attempt landed
219
+ * (its reply was lost) and the seal is done; otherwise someone else stored first — a copy this kit
220
+ * cannot check, which it says (the Challenge's C2.11), never "sealed". Any other refusal stops at once.
221
+ * Returns null on success, else the reason.
222
+ */
223
+ async function sealOpenedEngram(opened, ownerKey, signIn, deps) {
224
+ const deadline = deps.now() + SEAL_RETRY_FOR_MS;
225
+ let ciphertext = null;
226
+ for (;;) {
227
+ try {
228
+ if (!ciphertext) {
229
+ const verificationKey = await opened.getKeyBackupVerificationKey();
230
+ ciphertext = await deps.seal(ownerKey, verificationKey, signIn);
231
+ }
232
+ // ⟨CORRECTED 2026-11-03, the pre-gate fixes (stage-8 review m2), beside the comment below⟩ A
233
+ // `#Conflict` is not only "a copy is already held": the store also answers it for "no sign-in
234
+ // seated" (the named person declined in the seconds before the seal) and "a first engram". So
235
+ // the store's own sentence is kept, and when the read-back then finds no copy at all, THAT
236
+ // sentence is the reason — never the read-back's "holds no sealed copy", which hid why.
237
+ let conflict = null;
238
+ try {
239
+ await opened.storeKeyBackup(ciphertext);
240
+ }
241
+ catch (e) {
242
+ if (!(e instanceof CanisterRefusal && e.kind === 'Conflict'))
243
+ throw e;
244
+ // A copy is already held: ours (an earlier attempt landed) or someone else's.
245
+ conflict = e.text;
246
+ }
247
+ let stored;
248
+ try {
249
+ stored = await opened.getKeyBackupCiphertext();
250
+ }
251
+ catch (e) {
252
+ if (conflict !== null && e instanceof CanisterRefusal && e.kind === 'NotFound')
253
+ return conflict;
254
+ throw e;
255
+ }
256
+ if (sameBytes(stored, ciphertext))
257
+ return null;
258
+ // ⟨2026-11-03, the pre-gate fixes⟩ The last sentence now says HOW the sign-in finds out: both
259
+ // ways it can open the copy check that it opens to this engram's owner key, and say so if not.
260
+ return ('the engram already holds a sealed copy that is not the one made here, so this kit cannot ' +
261
+ 'tell whether it is a copy of this key. Only your sign-in can find out, by opening it — an ' +
262
+ "owner console's check of the sealed copy, or the owner kit's --recover-key — each of which " +
263
+ "says whether it opens to this engram's owner key.");
264
+ }
265
+ catch (e) {
266
+ const why = refusalText(e);
267
+ const passes = !(e instanceof CanisterRefusal) || e.kind === 'Unavailable' || e.kind === 'Other';
268
+ if (!passes || deps.now() >= deadline)
269
+ return why;
270
+ await deps.sleep(SEAL_RETRY_EVERY_MS);
271
+ }
272
+ }
273
+ }
79
274
  /**
80
275
  * Open an engram of this agent's own through the engram it works in. Prints what it does; returns
81
276
  * the exit code (and, on success, what was opened). Never throws for a refusal — every refusal is
@@ -86,6 +281,7 @@ export async function openEngram(options, deps) {
86
281
  const keyPath = options.keyPath || '~/.engramx/session.key';
87
282
  const rootKeyPath = options.rootKeyPath || '~/.engramx/root.key';
88
283
  const rootFile = path.resolve(resolveHome(rootKeyPath));
284
+ const host = options.host || 'https://ic0.app';
89
285
  // 1. The lasting key: it must already exist. It is never created here — a new lasting key is a
90
286
  // new agent, and it would own the engram this opens.
91
287
  if (!present(rootFile)) {
@@ -94,24 +290,26 @@ export async function openEngram(options, deps) {
94
290
  'If the lasting key is in another file, pass --root-key <path>.');
95
291
  return { exitCode: 1 };
96
292
  }
97
- let rootPrincipal;
293
+ let root;
98
294
  try {
99
- rootPrincipal = loadSessionKey(rootFile).getPrincipal().toText();
295
+ root = loadLastingKey(rootFile);
100
296
  }
101
297
  catch (e) {
102
298
  io.err(`Cannot use the lasting key at ${rootFile}: ${e.message}. ` +
103
299
  'Nothing was opened, and the file was not changed.');
104
300
  return { exitCode: 1 };
105
301
  }
302
+ const rootPrincipal = root.identity.getPrincipal();
303
+ // ⟨2026-11-02, stage 8⟩ Two names for the sign-in is no name: refused before anything is read.
304
+ if (options.signIn !== undefined && options.noSignIn) {
305
+ io.err('--sign-in and --no-sign-in were both given; pass one. Nothing was opened.');
306
+ return { exitCode: 1 };
307
+ }
106
308
  let engram;
107
309
  try {
108
310
  engram =
109
311
  deps.engram ??
110
- new EngramClient({
111
- canisterId: options.canisterId,
112
- sessionKeyPath: keyPath,
113
- host: options.host || 'https://ic0.app',
114
- });
312
+ new EngramClient({ canisterId: options.canisterId, sessionKeyPath: keyPath, host });
115
313
  }
116
314
  catch (e) {
117
315
  io.err(`Cannot use the key for this engram (${keyPath}): ${e.message}`);
@@ -133,18 +331,112 @@ export async function openEngram(options, deps) {
133
331
  // The engram makes the lasting key it holds for this agent the owner. If that is not the key in
134
332
  // this file, the file could not act as the owner of what is opened — stop before anything leaves.
135
333
  const recordedRoot = allowance.root.toText();
136
- if (recordedRoot !== rootPrincipal) {
137
- io.err(`The lasting key at ${rootFile} is ${rootPrincipal}, but this agent was paired with ` +
334
+ if (recordedRoot !== rootPrincipal.toText()) {
335
+ io.err(`The lasting key at ${rootFile} is ${rootPrincipal.toText()}, but this agent was paired with ` +
138
336
  `${options.canisterId} under the lasting key ${recordedRoot}, and the engram would make ` +
139
337
  `${recordedRoot} the owner of what it opens. Pass --root-key with the file that holds ` +
140
338
  `${recordedRoot}. Nothing was opened.`);
141
339
  return { exitCode: 1 };
142
340
  }
341
+ // 2a. ⟨2026-11-02, L20⟩ The engram opened through must carry a sign-in to the registry.
342
+ let version;
343
+ try {
344
+ version = (await engram.status()).version;
345
+ }
346
+ catch (e) {
347
+ io.err(`Could not read the version of the engram you open through (${refusalText(e)}). ` +
348
+ 'Nothing was opened.');
349
+ return { exitCode: 1 };
350
+ }
351
+ const cmp = compareVersions(version, SIGN_IN_FLOOR_VERSION);
352
+ if (cmp === null || cmp < 0) {
353
+ io.err(`The engram you open through runs ${version || 'an unnamed version'}; opening an engram through ` +
354
+ `it needs ${SIGN_IN_FLOOR_VERSION} or later, because an older one cannot give what it opens ` +
355
+ 'a sign-in. Upgrade the engram you open through first. Nothing was opened.');
356
+ return { exitCode: 1 };
357
+ }
358
+ // The registry that opens it: read here because the offer comes from it, and printed afterwards in
359
+ // the owner kit's command. Public; a failure is said, never invented.
360
+ const registry = await engram.getSpawnedBy().then((p) => p?.toText() ?? null, () => null);
361
+ // 2b. ⟨2026-11-02, stage 8⟩ The sign-in, settled before anything is spent.
362
+ const keys = { root: rootPrincipal, session: engram.getPrincipal() };
363
+ const asking = Boolean(options.interactive) && !options.yes;
364
+ let signIn;
365
+ if (options.signIn !== undefined) {
366
+ const why = signInRefusal(options.signIn, keys);
367
+ if (why) {
368
+ io.err(`${why} Nothing was opened.`);
369
+ return { exitCode: 1 };
370
+ }
371
+ signIn = Principal.fromText(options.signIn.trim());
372
+ }
373
+ else if (options.noSignIn) {
374
+ io.out(NO_SIGN_IN_WARNING);
375
+ signIn = null;
376
+ }
377
+ else if (!asking) {
378
+ io.err('Name this engram’s sign-in: pass --sign-in <principal> (your own sign-in, a second ' +
379
+ 'credential) or --no-sign-in (small limits for life, and no recovery of this key). ' +
380
+ '--yes never picks one. Nothing was opened.');
381
+ return { exitCode: 1 };
382
+ }
383
+ else {
384
+ let offered = null;
385
+ if (registry) {
386
+ try {
387
+ const offer = await (deps.registry ?? registryAs(root.identity, host))(registry).getChildSignInOffer(Principal.fromText(options.canisterId));
388
+ if (offer.parentIsFirstEngram && offer.parentOwner)
389
+ offered = offer.parentOwner;
390
+ }
391
+ catch (e) {
392
+ io.out(`(The owner of the engram you open through could not be read: ${refusalText(e)})`);
393
+ }
394
+ }
395
+ let chosen = null;
396
+ if (offered) {
397
+ const p = offered.toText();
398
+ // ⟨CORRECTED 2026-11-03, the pre-gate fixes (stage-8 review m3; the Challenge's C2.10: "the copy
399
+ // must say so")⟩ The offer ended "…lifts freezes and opens the sealed copy of this key." It did
400
+ // not say what opening the copy MEANS: the sign-in can restore this key and act as this engram's
401
+ // owner in full. This is the sentence where a "y" hands someone the engram, so it says so now.
402
+ io.out(`The engram you open through belongs to ${p}. If that is you, it becomes this engram's ` +
403
+ 'sign-in: it approves payments over the limits, adds sellers, approves trading keys, lifts ' +
404
+ 'freezes and opens the sealed copy of this key — so it can restore this key and act as ' +
405
+ "this engram's owner in full. Say yes only if that is you.");
406
+ if (await io.confirm(`Is ${p} yours?`))
407
+ chosen = p;
408
+ }
409
+ if (chosen === null) {
410
+ const pasted = (await io.ask("Paste the principal of your sign-in (your Internet Identity's, or a second key file's), " +
411
+ 'or press Enter to open without one:')).trim();
412
+ if (pasted === '') {
413
+ io.out(NO_SIGN_IN_WARNING);
414
+ if (!(await io.confirm('Open it with no sign-in?'))) {
415
+ io.out('Nothing was opened.');
416
+ return { exitCode: 0 };
417
+ }
418
+ }
419
+ else {
420
+ chosen = pasted;
421
+ }
422
+ }
423
+ if (chosen !== null) {
424
+ const why = signInRefusal(chosen, keys);
425
+ if (why) {
426
+ io.err(`${why} Nothing was opened.`);
427
+ return { exitCode: 1 };
428
+ }
429
+ signIn = Principal.fromText(chosen);
430
+ }
431
+ else {
432
+ signIn = null;
433
+ }
434
+ }
143
435
  // 3. The one warning the owner kit already carries, before anything happens.
144
436
  io.out(`The engram you are about to open will be owned by this agent's lasting key, which lives on ` +
145
437
  `this machine (${rootFile}). Whoever holds that file owns that engram. Back it up; loss is ` +
146
438
  'permanent loss of ownership.');
147
- if (!options.yes && options.interactive) {
439
+ if (asking) {
148
440
  if (!(await io.confirm('Open it?'))) {
149
441
  io.out('Nothing was opened.');
150
442
  return { exitCode: 0 };
@@ -153,22 +445,47 @@ export async function openEngram(options, deps) {
153
445
  // 4. Ask.
154
446
  let opened;
155
447
  try {
156
- opened = await engram.openChildEngram();
448
+ opened = await engram.openChildEngram(signIn ?? undefined);
157
449
  }
158
450
  catch (e) {
159
451
  io.err(refusalText(e));
160
452
  return { exitCode: 1 };
161
453
  }
162
454
  const openedText = opened.toText();
163
- const registry = await engram.getSpawnedBy().then((p) => p?.toText() ?? null, () => null);
164
- const host = options.host;
165
- const hostFlags = host ? (isLocalHost(host) ? ` --local --host ${host}` : ` --host ${host}`) : '';
455
+ const hostFlags = options.host
456
+ ? isLocalHost(options.host)
457
+ ? ` --local --host ${options.host}`
458
+ : ` --host ${options.host}`
459
+ : '';
166
460
  const registryFlag = registry ? ` --registry ${registry}` : '';
167
461
  // ⟨2026-10-06⟩ Pinned to this build's version and the key file printed as one shell word — the
168
462
  // header's dated correction says why.
169
463
  const ownerCommand = `npx @engramx/owner@${VERSION} --connect --key-file ${shellWord(rootFile)}${registryFlag}${hostFlags}`;
170
464
  io.out(`Opened an engram of your own: ${openedText}`);
171
- io.out(`Owner: this agent's lasting key (${rootPrincipal})`);
465
+ io.out(`Owner: this agent's lasting key (${rootPrincipal.toText()})`);
466
+ // 4b. ⟨2026-11-02, stage 8⟩ The seal. The opening cannot be undone; the seal can be retried.
467
+ let sealed = false;
468
+ if (signIn) {
469
+ io.out(`Sign-in: ${signIn.toText()}`);
470
+ const why = await sealOpenedEngram((deps.opened ??
471
+ ((id) => new EngramClient({ canisterId: id, sessionKeySeed: root.seed, host })))(openedText), root.seed, signIn, {
472
+ seal: deps.seal ?? sealToPrincipal,
473
+ sleep: deps.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms))),
474
+ now: deps.now ?? Date.now,
475
+ });
476
+ if (why === null) {
477
+ sealed = true;
478
+ io.out(SEALED_LINE);
479
+ }
480
+ else {
481
+ io.err(`The sealed copy of this key was not stored: ${why}`);
482
+ io.err('The engram is open. Store the copy with:');
483
+ io.err(` npx @engramx/client@${VERSION} seal-key --engram ${openedText} --root-key ${shellWord(rootFile)} --sign-in ${signIn.toText()}${options.host ? ` --host ${options.host}` : ''}`);
484
+ }
485
+ }
486
+ else {
487
+ io.out('Sign-in: none — this engram keeps small limits for life.');
488
+ }
172
489
  io.out('');
173
490
  io.out('Pair an agent of your own into it:');
174
491
  io.out(` ${ownerCommand}`);
@@ -176,10 +493,88 @@ export async function openEngram(options, deps) {
176
493
  io.out(' (The registry could not be read just now: add --registry with its id, or set ENGRAMX_REGISTRY.)');
177
494
  }
178
495
  io.out(' (It prints the pairing command for that agent; add --agent-name to label it.)');
179
- io.out('Set its limits, ceiling and guardians as its owner by calling the engram with the same key');
496
+ // ⟨CORRECTED 2026-11-02, stage 8⟩ Said "Set its limits, ceiling and guardians as its owner by
497
+ // calling the engram with the same key" — false for an engram opened this way from rc.22: its key
498
+ // file can loosen nothing, and guardians are seated by its sign-in.
499
+ io.out('As its owner, the same key file pays within its limits, pairs agents, freezes and tightens; it ' +
500
+ 'loosens nothing — approvals, sellers, lifting a freeze and guardians are for its sign-in');
180
501
  // ⟨CORRECTED 2026-10-06⟩ Said "(the owner kit creates and connects; …)" — false from rc.3: the
181
502
  // kit no longer creates engrams (the owner's ruling of 2026-10-05).
182
503
  io.out('(the owner kit shows that engram and connects agents to it; every other owner method is a direct call — see its README, "Acting as an owner").');
183
- return { exitCode: 0, opened: openedText, owner: rootPrincipal };
504
+ return {
505
+ exitCode: 0,
506
+ opened: openedText,
507
+ owner: rootPrincipal.toText(),
508
+ signIn: signIn ? signIn.toText() : null,
509
+ sealed,
510
+ };
511
+ }
512
+ /**
513
+ * ⟨ADDED 2026-11-02, stage 8⟩ `seal-key`: the seal alone, for an engram whose opening printed that the
514
+ * copy was not stored. Signed by the lasting key (the engram's owner). It seals ONLY for the sign-in
515
+ * the engram has seated — a copy sealed for anyone else could never be opened, and the store is set
516
+ * once — and refuses an engram that already holds a copy.
517
+ */
518
+ export async function sealKey(options, deps) {
519
+ const { io } = deps;
520
+ const rootFile = path.resolve(resolveHome(options.rootKeyPath || '~/.engramx/root.key'));
521
+ const host = options.host || 'https://ic0.app';
522
+ let root;
523
+ try {
524
+ root = loadLastingKey(rootFile);
525
+ }
526
+ catch (e) {
527
+ io.err(`Cannot use the lasting key at ${rootFile}: ${e.message}. Nothing was stored.`);
528
+ return { exitCode: 1 };
529
+ }
530
+ const opened = (deps.opened ?? ((id) => new EngramClient({ canisterId: id, sessionKeySeed: root.seed, host })))(options.canisterId);
531
+ let view;
532
+ try {
533
+ view = await opened.getOwnerSignIn();
534
+ }
535
+ catch (e) {
536
+ io.err(`${refusalText(e)} Nothing was stored.`);
537
+ return { exitCode: 1 };
538
+ }
539
+ if (view.openedFrom.length === 0) {
540
+ io.err(`Engram ${options.canisterId} was not opened through another engram; its owner holds its own ` +
541
+ 'key, and there is no sign-in to seal a copy for. Nothing was stored.');
542
+ return { exitCode: 1 };
543
+ }
544
+ const seated = view.ownerSignIn[0] ?? null;
545
+ if (!seated) {
546
+ io.err(`Engram ${options.canisterId} has no sign-in seated, so nobody could open a copy. Nothing was stored.`);
547
+ return { exitCode: 1 };
548
+ }
549
+ if (options.signIn !== undefined && options.signIn.trim() !== seated.toText()) {
550
+ io.err(`The engram's sign-in is ${seated.toText()}, not ${options.signIn.trim()}; a copy sealed for ` +
551
+ 'anyone else could never be opened. Nothing was stored.');
552
+ return { exitCode: 1 };
553
+ }
554
+ let status;
555
+ try {
556
+ status = await opened.getKeyBackupStatus();
557
+ }
558
+ catch (e) {
559
+ io.err(`${refusalText(e)} Nothing was stored.`);
560
+ return { exitCode: 1 };
561
+ }
562
+ if (status.sealed) {
563
+ const forWhom = status.sealedFor[0]?.toText() ?? 'nobody named';
564
+ io.err(`Engram ${options.canisterId} already holds a sealed copy (for ${forWhom}); the copy is stored ` +
565
+ `once.${status.matchesSignIn ? '' : ' It is not sealed for the sign-in seated now.'} Nothing was stored.`);
566
+ return { exitCode: 1 };
567
+ }
568
+ const why = await sealOpenedEngram(opened, root.seed, seated, {
569
+ seal: deps.seal ?? sealToPrincipal,
570
+ sleep: deps.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms))),
571
+ now: deps.now ?? Date.now,
572
+ });
573
+ if (why !== null) {
574
+ io.err(`The sealed copy of this key was not stored: ${why}`);
575
+ return { exitCode: 1 };
576
+ }
577
+ io.out(SEALED_LINE);
578
+ return { exitCode: 0 };
184
579
  }
185
580
  //# sourceMappingURL=openEngram.js.map
@@ -1 +1 @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;IACF,+FAA+F;IAC/F,oEAAoE;IACpE,EAAE,CAAC,GAAG,CACJ,gJAAgJ,CACjJ,CAAC;IACF,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC;AACnE,CAAC"}
1
+ {"version":3,"file":"openEngram.js","sourceRoot":"","sources":["../src/openEngram.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,EAAE;AACF,kGAAkG;AAClG,mGAAmG;AACnG,2FAA2F;AAC3F,4FAA4F;AAC5F,mGAAmG;AACnG,6EAA6E;AAC7E,EAAE;AACF,qGAAqG;AACrG,mGAAmG;AACnG,oGAAoG;AACpG,gGAAgG;AAChG,+FAA+F;AAC/F,iEAAiE;AACjE,kGAAkG;AAClG,kGAAkG;AAClG,oGAAoG;AACpG,mFAAmF;AACnF,oGAAoG;AACpG,6FAA6F;AAC7F,sGAAsG;AACtG,gGAAgG;AAChG,kGAAkG;AAClG,mGAAmG;AACnG,qGAAqG;AACrG,iGAAiG;AACjG,iGAAiG;AACjG,2FAA2F;AAC3F,uEAAuE;AACvE,EAAE;AACF,gGAAgG;AAChG,uDAAuD;AAEvD,EAAE;AACF,mGAAmG;AACnG,oGAAoG;AACpG,sGAAsG;AACtG,+FAA+F;AAC/F,uGAAuG;AACvG,iGAAiG;AACjG,eAAe;AACf,oFAAoF;AACpF,qGAAqG;AACrG,6DAA6D;AAC7D,0FAA0F;AAC1F,uGAAuG;AACvG,qGAAqG;AACrG,mGAAmG;AACnG,qGAAqG;AACrG,gDAAgD;AAChD,yEAAyE;AACzE,uGAAuG;AACvG,oGAAoG;AACpG,uGAAuG;AACvG,oGAAoG;AACpG,sGAAsG;AACtG,oGAAoG;AAEpG,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAE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EAAE,CAAC,EAAE,CAAC;IACzB,CAAC;IACD,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IACpB,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;AACzB,CAAC"}
package/dist/types.d.ts CHANGED
@@ -64,6 +64,14 @@ export type BackupMetadata = Engram.BackupMetadata;
64
64
  export type BackupRetention = Engram.BackupRetention;
65
65
  export type ApprovalStatus = Engram.ApprovalStatus;
66
66
  export type ApprovalRequest = Engram.ApprovalRequest;
67
+ /** ⟨2026-11-02, the child build's stage 8⟩ What `getOwnerSignIn()` answers: whether the engram was
68
+ * opened through another, its sign-in (the owner's second credential), whether the caller is it, and
69
+ * any decline or waiting ask. Named caller: the `seal-key` command (openEngram.ts), which seals only
70
+ * for the sign-in the engram has seated. */
71
+ export type OwnerSignInView = Engram.OwnerSignInView;
72
+ /** ⟨2026-11-02, stage 8⟩ What `getKeyBackupStatus()` answers: whether the engram holds a sealed copy
73
+ * of its owner's key, for whom, since when, and whether it is sealed for the sign-in seated now. */
74
+ export type KeyBackupStatus = Engram.KeyBackupStatus;
67
75
  /** A memory file with its content decoded to text (decrypted first on an encrypted engram). */
68
76
  export interface MemoryFile {
69
77
  path: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@engramx/client",
3
- "version": "0.16.0-rc.20",
3
+ "version": "0.16.0-rc.22",
4
4
  "description": "Client SDK for EngramX — persistent, decentralized memory for AI agents on the Internet Computer",
5
5
  "license": "Apache-2.0",
6
6
  "author": "EngramX <developer@engramx.ai>",
@@ -53,7 +53,7 @@
53
53
  "@icp-sdk/core": "^6.1.1"
54
54
  },
55
55
  "dependencies": {
56
- "@engramx/idl": "0.16.0-rc.20",
56
+ "@engramx/idl": "0.16.0-rc.22",
57
57
  "@icp-sdk/core": "^6.1.1",
58
58
  "@icp-sdk/vetkeys": "0.7.0",
59
59
  "@noble/curves": "^2.4.0"