@agentvault/grok-bridge 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/config.d.ts CHANGED
@@ -11,6 +11,17 @@
11
11
  * flag can never be mistaken for an invite token.
12
12
  */
13
13
  export declare const INSTALL_FLAG = "--install";
14
+ /** Informational flags. Handled BEFORE loadConfig in index.ts, because asking
15
+ * "what version is this?" must not require an invite token. Listed here too so
16
+ * the strict unknown-flag check does not reject them. */
17
+ export declare const VERSION_FLAGS: readonly ["--version", "-v"];
18
+ export declare const HELP_FLAGS: readonly ["--help", "-h"];
19
+ /** Pure argv read for the informational flags. Deliberately independent of
20
+ * loadConfig: that throws without a token, and `--version` must answer anyway. */
21
+ export declare function parseInfoFlags(argv: string[]): {
22
+ showVersion: boolean;
23
+ showHelp: boolean;
24
+ };
14
25
  /**
15
26
  * Package-manager scratch caches. `service/subcommand.ts` bakes `process.argv[1]`
16
27
  * into the launcher script, so a service installed from one of these points at a
@@ -68,6 +79,10 @@ export interface BridgeConfig {
68
79
  * then EXIT so the customer's terminal returns. False leaves a bare run
69
80
  * byte-for-byte as it behaves today. */
70
81
  installAfterEnroll: boolean;
82
+ /** --version / -v. index.ts answers these before loadConfig runs. */
83
+ showVersion: boolean;
84
+ /** --help / -h. Same. */
85
+ showHelp: boolean;
71
86
  }
72
87
  export declare function loadConfig(env: NodeJS.ProcessEnv, argv?: string[]): BridgeConfig;
73
88
  //# sourceMappingURL=config.d.ts.map
package/dist/index.js CHANGED
@@ -9,10 +9,61 @@ var __export = (target, all) => {
9
9
  __defProp(target, name, { get: all[name], enumerable: true });
10
10
  };
11
11
 
12
+ // src/pending-invite.ts
13
+ import { existsSync, mkdirSync, chmodSync, readFileSync as readFileSync2, writeFileSync, rmSync } from "node:fs";
14
+ import { join as join5 } from "node:path";
15
+ function pendingInvitePath(dataDir) {
16
+ return join5(dataDir, PENDING_INVITE_FILE);
17
+ }
18
+ function writePendingInvite(dataDir, token) {
19
+ mkdirSync(dataDir, { recursive: true, mode: DIR_MODE2 });
20
+ chmodSync(dataDir, DIR_MODE2);
21
+ const p2 = pendingInvitePath(dataDir);
22
+ writeFileSync(p2, token, { mode: FILE_MODE2 });
23
+ chmodSync(p2, FILE_MODE2);
24
+ }
25
+ function readPendingInvite(dataDir) {
26
+ const p2 = pendingInvitePath(dataDir);
27
+ if (!existsSync(p2)) return void 0;
28
+ try {
29
+ const raw = readFileSync2(p2, "utf-8").trim();
30
+ return raw.length > 0 ? raw : void 0;
31
+ } catch {
32
+ return void 0;
33
+ }
34
+ }
35
+ function clearPendingInvite(dataDir) {
36
+ try {
37
+ rmSync(pendingInvitePath(dataDir), { force: true });
38
+ } catch {
39
+ }
40
+ }
41
+ function clearPendingInviteIfConsumed(dataDir, credsExist) {
42
+ if (!existsSync(pendingInvitePath(dataDir))) return false;
43
+ if (!credsExist(dataDir)) return false;
44
+ clearPendingInvite(dataDir);
45
+ return true;
46
+ }
47
+ var DIR_MODE2, FILE_MODE2, PENDING_INVITE_FILE;
48
+ var init_pending_invite = __esm({
49
+ "src/pending-invite.ts"() {
50
+ "use strict";
51
+ DIR_MODE2 = 448;
52
+ FILE_MODE2 = 384;
53
+ PENDING_INVITE_FILE = "pending-invite";
54
+ }
55
+ });
56
+
12
57
  // src/config.ts
13
- import { existsSync, readFileSync as readFileSync2, mkdirSync, chmodSync } from "node:fs";
14
- import { join as join5, resolve as resolve2, sep, dirname } from "node:path";
58
+ import { existsSync as existsSync2, readFileSync as readFileSync3, mkdirSync as mkdirSync2, chmodSync as chmodSync2 } from "node:fs";
59
+ import { join as join6, resolve as resolve2, sep, dirname } from "node:path";
15
60
  import { tmpdir } from "node:os";
61
+ function parseInfoFlags(argv) {
62
+ return {
63
+ showVersion: argv.some((a2) => VERSION_FLAGS.includes(a2)),
64
+ showHelp: argv.some((a2) => HELP_FLAGS.includes(a2))
65
+ };
66
+ }
16
67
  function isEphemeralEntrypoint(entrypoint) {
17
68
  return entrypoint.includes("/_npx/") || entrypoint.includes("/dlx-") || entrypoint.includes("/.bun/install/cache/") || entrypoint.startsWith(tmpdir() + sep);
18
69
  }
@@ -26,14 +77,14 @@ function assertInstallableEntrypoint(entrypoint) {
26
77
  }
27
78
  function hasRecoverableBackup(dataDir) {
28
79
  try {
29
- const parsed = JSON.parse(readFileSync2(join5(dataDir, BACKUP_FILE), "utf-8"));
80
+ const parsed = JSON.parse(readFileSync3(join6(dataDir, BACKUP_FILE), "utf-8"));
30
81
  return !!(parsed && parsed.deviceId && parsed.deviceJwt && parsed.sessions && Object.keys(parsed.sessions).length > 0);
31
82
  } catch {
32
83
  return false;
33
84
  }
34
85
  }
35
86
  function hasPersistedCreds(dataDir) {
36
- if (CRED_FILES.some((f2) => existsSync(join5(dataDir, f2)))) return true;
87
+ if (CRED_FILES.some((f2) => existsSync2(join6(dataDir, f2)))) return true;
37
88
  return hasRecoverableBackup(dataDir);
38
89
  }
39
90
  function slugify2(name) {
@@ -41,19 +92,19 @@ function slugify2(name) {
41
92
  }
42
93
  function resolveDataDir(env) {
43
94
  if (env.AV_DATA_DIR) return { dataDir: env.AV_DATA_DIR, source: "explicit" };
44
- const base = join5(env.HOME ?? "", ".agentvault", "grok-room-bridge");
45
- return { dataDir: join5(base, slugify2(env.AV_AGENT_NAME ?? "grok")), source: "per-agent" };
95
+ const base = join6(env.HOME ?? "", ".agentvault", "grok-room-bridge");
96
+ return { dataDir: join6(base, slugify2(env.AV_AGENT_NAME ?? "grok")), source: "per-agent" };
46
97
  }
47
98
  function loadConfig(env, argv = []) {
48
99
  const { dataDir, source: dataDirSource } = resolveDataDir(env);
49
- const inviteToken = (argv[0] && !argv[0].startsWith("-") ? argv[0] : "") || env.AV_INVITE_TOKEN || "";
100
+ const inviteToken = (argv[0] && !argv[0].startsWith("-") ? argv[0] : "") || env.AV_INVITE_TOKEN || readPendingInvite(dataDir) || "";
50
101
  const unknownFlags = argv.filter((a2) => a2.startsWith("-") && !KNOWN_FLAGS.has(a2));
51
102
  if (unknownFlags.length) {
52
103
  throw new Error(
53
- `unknown option(s): ${unknownFlags.join(", ")} \u2014 the only supported flag is ${INSTALL_FLAG}`
104
+ `unknown option(s): ${unknownFlags.join(", ")} \u2014 supported flags are ${[...KNOWN_FLAGS].join(", ")}`
54
105
  );
55
106
  }
56
- const workspaceDir = env.AV_WORKSPACE_DIR || join5(dirname(dataDir), "workspaces", slugify2(env.AV_AGENT_NAME ?? "grok"));
107
+ const workspaceDir = env.AV_WORKSPACE_DIR || join6(dirname(dataDir), "workspaces", slugify2(env.AV_AGENT_NAME ?? "grok"));
57
108
  const wsReal = resolve2(workspaceDir);
58
109
  const ddReal = resolve2(dataDir);
59
110
  if (wsReal === ddReal || wsReal.startsWith(ddReal + sep) || ddReal.startsWith(wsReal + sep)) {
@@ -62,8 +113,8 @@ function loadConfig(env, argv = []) {
62
113
  );
63
114
  }
64
115
  try {
65
- mkdirSync(workspaceDir, { recursive: true, mode: 448 });
66
- chmodSync(workspaceDir, 448);
116
+ mkdirSync2(workspaceDir, { recursive: true, mode: 448 });
117
+ chmodSync2(workspaceDir, 448);
67
118
  } catch (e) {
68
119
  throw new Error(
69
120
  `Failed to create/secure the agent workspace at ${workspaceDir} (override with AV_WORKSPACE_DIR): ${e.message}`
@@ -81,6 +132,7 @@ function loadConfig(env, argv = []) {
81
132
  // One-paste install (--install): enrol, hand off to the supervisor, exit.
82
133
  // Default false keeps a bare `npx @agentvault/grok-bridge` run identical.
83
134
  installAfterEnroll: argv.includes(INSTALL_FLAG),
135
+ ...parseInfoFlags(argv),
84
136
  apiUrl: env.AV_API_URL ?? "https://api.agentvault.chat",
85
137
  // Identity shown to the agent's own session. Set this to the agent's
86
138
  // AgentVault name via AV_AGENT_NAME (the native connect command passes it).
@@ -92,17 +144,20 @@ function loadConfig(env, argv = []) {
92
144
  workspaceDir,
93
145
  grokPath: env.AV_GROK_PATH || void 0,
94
146
  sandboxProfile: env.GROK_SANDBOX ?? "workspace",
95
- fenceHome: env.AV_FENCE_HOME || join5(dataDir, "fence"),
147
+ fenceHome: env.AV_FENCE_HOME || join6(dataDir, "fence"),
96
148
  apiKey: env.XAI_API_KEY || void 0,
97
149
  systemPrompt: env.AV_SYSTEM_PROMPT || void 0
98
150
  };
99
151
  }
100
- var INSTALL_FLAG, KNOWN_FLAGS, CRED_FILES, BACKUP_FILE;
152
+ var INSTALL_FLAG, VERSION_FLAGS, HELP_FLAGS, KNOWN_FLAGS, CRED_FILES, BACKUP_FILE;
101
153
  var init_config = __esm({
102
154
  "src/config.ts"() {
103
155
  "use strict";
156
+ init_pending_invite();
104
157
  INSTALL_FLAG = "--install";
105
- KNOWN_FLAGS = /* @__PURE__ */ new Set([INSTALL_FLAG]);
158
+ VERSION_FLAGS = ["--version", "-v"];
159
+ HELP_FLAGS = ["--help", "-h"];
160
+ KNOWN_FLAGS = /* @__PURE__ */ new Set([INSTALL_FLAG, ...VERSION_FLAGS, ...HELP_FLAGS]);
106
161
  CRED_FILES = ["agentvault.json", "secure-channel.json"];
107
162
  BACKUP_FILE = "agentvault.json.bak";
108
163
  }
@@ -117,6 +172,9 @@ function stamp(message) {
117
172
  function logLine(...args) {
118
173
  console.error(stamp(format(...args)));
119
174
  }
175
+ function printLine(text) {
176
+ console.log(text);
177
+ }
120
178
  var init_log = __esm({
121
179
  "src/log.ts"() {
122
180
  "use strict";
@@ -185,7 +243,7 @@ var init_launcher = __esm({
185
243
  });
186
244
 
187
245
  // src/service/spec.ts
188
- import { join as join9 } from "node:path";
246
+ import { join as join10 } from "node:path";
189
247
  function buildServiceSpec(cfg, opts) {
190
248
  const env = {
191
249
  AV_AGENT_NAME: cfg.agentName,
@@ -197,7 +255,7 @@ function buildServiceSpec(cfg, opts) {
197
255
  if (cfg.workspaceDir) env.AV_WORKSPACE_DIR = cfg.workspaceDir;
198
256
  if (cfg.roomFilter) env.AV_ROOM_ID = cfg.roomFilter;
199
257
  if (cfg.grokPath) env.AV_GROK_PATH = cfg.grokPath;
200
- const launcherPath = join9(cfg.dataDir, "launch-grok-bridge.sh");
258
+ const launcherPath = join10(cfg.dataDir, "launch-grok-bridge.sh");
201
259
  return {
202
260
  label: `dev.agentvault.grok-${slugify2(cfg.agentName)}`,
203
261
  programArgs: [launcherPath],
@@ -205,8 +263,8 @@ function buildServiceSpec(cfg, opts) {
205
263
  launcherScript: renderLauncher({ installPath: opts.path, entrypoint: opts.entrypoint }),
206
264
  env,
207
265
  workingDir: cfg.workspaceDir ? cfg.workspaceDir : opts.home,
208
- logOut: join9(cfg.dataDir, "logs", "grok-bridge.log"),
209
- logErr: join9(cfg.dataDir, "logs", "grok-bridge.error.log"),
266
+ logOut: join10(cfg.dataDir, "logs", "grok-bridge.log"),
267
+ logErr: join10(cfg.dataDir, "logs", "grok-bridge.error.log"),
210
268
  keepAliveUnlessCleanExit: true,
211
269
  runAtLoad: true
212
270
  };
@@ -220,7 +278,7 @@ var init_spec = __esm({
220
278
  });
221
279
 
222
280
  // src/service/launchd.ts
223
- import { dirname as dirname3, join as join10 } from "node:path";
281
+ import { dirname as dirname3, join as join11 } from "node:path";
224
282
  function esc2(s2) {
225
283
  return s2.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
226
284
  }
@@ -265,8 +323,9 @@ var init_launchd = __esm({
265
323
  constructor(deps) {
266
324
  this.deps = deps;
267
325
  }
326
+ deps;
268
327
  plistPath(label) {
269
- return join10(this.deps.home, "Library", "LaunchAgents", `${label}.plist`);
328
+ return join11(this.deps.home, "Library", "LaunchAgents", `${label}.plist`);
270
329
  }
271
330
  domain() {
272
331
  return `gui/${this.deps.uid}`;
@@ -314,7 +373,7 @@ var init_launchd = __esm({
314
373
  });
315
374
 
316
375
  // src/service/systemd.ts
317
- import { dirname as dirname4, join as join11 } from "node:path";
376
+ import { dirname as dirname4, join as join12 } from "node:path";
318
377
  function q2(s2) {
319
378
  const esc3 = s2.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\t/g, "\\t").replace(/%/g, "%%");
320
379
  return `"${esc3}"`;
@@ -349,8 +408,9 @@ var init_systemd = __esm({
349
408
  constructor(deps) {
350
409
  this.deps = deps;
351
410
  }
411
+ deps;
352
412
  unitPath(label) {
353
- return join11(this.deps.home, ".config", "systemd", "user", `${label}.service`);
413
+ return join12(this.deps.home, ".config", "systemd", "user", `${label}.service`);
354
414
  }
355
415
  install(spec) {
356
416
  const path2 = this.unitPath(spec.label);
@@ -390,7 +450,7 @@ __export(backend_exports, {
390
450
  selectBackend: () => selectBackend
391
451
  });
392
452
  import { spawnSync } from "node:child_process";
393
- import { mkdirSync as mkdirSync4, writeFileSync as writeFileSync2, rmSync, existsSync as existsSync3, chmodSync as chmodSync4 } from "node:fs";
453
+ import { mkdirSync as mkdirSync5, writeFileSync as writeFileSync3, rmSync as rmSync2, existsSync as existsSync4, chmodSync as chmodSync5 } from "node:fs";
394
454
  import { userInfo } from "node:os";
395
455
  function defaultDeps() {
396
456
  return {
@@ -401,11 +461,11 @@ function defaultDeps() {
401
461
  const r2 = spawnSync(cmd, args, { encoding: "utf8" });
402
462
  return { code: r2.status ?? 1, stdout: r2.stdout ?? "" };
403
463
  },
404
- writeFile: (p2, d2) => writeFileSync2(p2, d2),
405
- mkdir: (p2) => mkdirSync4(p2, { recursive: true }),
406
- chmod: (p2, m2) => chmodSync4(p2, m2),
407
- rm: (p2) => rmSync(p2, { force: true }),
408
- exists: (p2) => existsSync3(p2)
464
+ writeFile: (p2, d2) => writeFileSync3(p2, d2),
465
+ mkdir: (p2) => mkdirSync5(p2, { recursive: true }),
466
+ chmod: (p2, m2) => chmodSync5(p2, m2),
467
+ rm: (p2) => rmSync2(p2, { force: true }),
468
+ exists: (p2) => existsSync4(p2)
409
469
  };
410
470
  }
411
471
  function selectBackend(platform, deps) {
@@ -435,17 +495,26 @@ function labelFor(env) {
435
495
  }
436
496
  function maybeRunServiceSubcommand(argv, env, deps) {
437
497
  const cmd = argv[2];
438
- if (!cmd || !SERVICE_CMDS.has(cmd)) return false;
498
+ if (!cmd) return false;
499
+ if (!SERVICE_CMDS.has(cmd)) {
500
+ const looksLikeToken = cmd.startsWith("av_tok_");
501
+ const looksLikeFlag = cmd.startsWith("-");
502
+ if (!looksLikeToken && !looksLikeFlag) {
503
+ throw new Error(
504
+ `unknown subcommand: ${cmd} \u2014 expected one of ${[...SERVICE_CMDS].join(", ")}, an invite token, or no argument at all`
505
+ );
506
+ }
507
+ return false;
508
+ }
439
509
  const backend = deps?.backend ?? selectBackend(process.platform);
440
510
  const entrypoint = deps?.entrypoint ?? process.argv[1];
441
511
  const log = deps?.log ?? ((m2) => logLine("[grok-bridge] " + m2));
442
512
  try {
443
513
  if (cmd === "install") {
444
514
  const cfg = loadConfig(env, []);
445
- if (!hasPersistedCreds(cfg.dataDir)) {
446
- throw new Error(
447
- "no credentials found \u2014 enroll first by running the bridge once (AV_INVITE_TOKEN=\u2026 npx @agentvault/grok-bridge), then re-run install"
448
- );
515
+ const firstBoot = !hasPersistedCreds(cfg.dataDir) && !!cfg.inviteToken;
516
+ if (firstBoot) {
517
+ writePendingInvite(cfg.dataDir, cfg.inviteToken);
449
518
  }
450
519
  const spec = buildServiceSpec(cfg, {
451
520
  entrypoint,
@@ -456,7 +525,11 @@ function maybeRunServiceSubcommand(argv, env, deps) {
456
525
  path: env.PATH ?? ""
457
526
  });
458
527
  backend.install(spec);
459
- log(`installed service ${spec.label} \u2014 logs: ${spec.logOut}`);
528
+ log(`installed service ${spec.label} \u2014 logs: ${spec.logErr}`);
529
+ if (firstBoot) {
530
+ log("now APPROVE the device in AgentVault \u2014 the service is waiting to enrol");
531
+ log("if it does not connect within a minute, the log above says why");
532
+ }
460
533
  log(`check it with: agentvault-grok-bridge status`);
461
534
  } else if (cmd === "uninstall") {
462
535
  const label = labelFor(env);
@@ -485,6 +558,7 @@ var init_subcommand = __esm({
485
558
  "src/service/subcommand.ts"() {
486
559
  "use strict";
487
560
  init_config();
561
+ init_pending_invite();
488
562
  init_log();
489
563
  init_spec();
490
564
  init_backend();
@@ -497,12 +571,12 @@ var install_on_ready_exports = {};
497
571
  __export(install_on_ready_exports, {
498
572
  installOnReady: () => installOnReady
499
573
  });
500
- import { existsSync as existsSync4, readFileSync as readFileSync3 } from "node:fs";
501
- import { join as join12 } from "node:path";
574
+ import { existsSync as existsSync5, readFileSync as readFileSync4 } from "node:fs";
575
+ import { join as join13 } from "node:path";
502
576
  function installOnReady(channel, cfg, deps) {
503
577
  const hasCreds = deps.hasCreds ?? hasPersistedCreds;
504
- const readLauncher = deps.readLauncher ?? ((p2) => existsSync4(p2) ? readFileSync3(p2, "utf8") : void 0);
505
- const fenceAuthExists = deps.fenceAuthExists ?? ((home) => existsSync4(join12(home, ".grok", "auth.json")));
578
+ const readLauncher = deps.readLauncher ?? ((p2) => existsSync5(p2) ? readFileSync4(p2, "utf8") : void 0);
579
+ const fenceAuthExists = deps.fenceAuthExists ?? ((home) => existsSync5(join13(home, ".grok", "auth.json")));
506
580
  let fired = false;
507
581
  channel.on("ready", () => {
508
582
  if (fired) return;
@@ -587,10 +661,10 @@ var init_install_on_ready = __esm({
587
661
 
588
662
  // src/index.ts
589
663
  import { spawn } from "node:child_process";
590
- import { mkdirSync as mkdirSync5 } from "node:fs";
591
- import { join as join13 } from "node:path";
664
+ import { mkdirSync as mkdirSync6 } from "node:fs";
665
+ import { join as join14 } from "node:path";
592
666
 
593
- // ../../../../packages/plugin/dist/index.js
667
+ // ../plugin/dist/index.js
594
668
  import * as nc from "node:crypto";
595
669
  import { chmod, mkdir, writeFile } from "node:fs/promises";
596
670
  import { readdir, readFile, rename, rm } from "node:fs/promises";
@@ -861,7 +935,7 @@ var init_libsodium_sumo = __esm2({
861
935
  }, Module: function(binary) {
862
936
  }, Instance: function(module2, info) {
863
937
  this.exports = // EMSCRIPTEN_START_ASM
864
- function instantiate(ea2) {
938
+ (function instantiate(ea2) {
865
939
  var a2;
866
940
  var b2 = new Uint8Array(123);
867
941
  for (var c2 = 25; c2 >= 0; --c2) {
@@ -40656,7 +40730,7 @@ var init_libsodium_sumo = __esm2({
40656
40730
  } } }), f: yi, g: ma2, h: Ba2, i: ma2, j: ka2, k: Le2, l: Je2, m: zg, n: yg, o: xg, p: wg, q: ka2, r: Ba2, s: ka2, t: ka2, u: Le2, v: ra2, w: vg, x: ug, y: tg, z: sg, A: Ba2, B: rg, C: qg, D: pg, E: ng, F: mg, G: lg, H: kg, I: jg, J: ka2, K: Ce2, L: Ba2, M: ma2, N: Ta2, O: ra2, P: ka2, Q: Oa2, R: Ba2, S: ma2, T: Ta2, U: ra2, V: ig, W: hg, X: gg, Y: fg, Z: ka2, _: Ma2, $: Ba2, aa: ma2, ba: Ta2, ca: ra2, da: ka2, ea: ka2, fa: Kg, ga: wd, ha: vd, ia: ra2, ja: ka2, ka: ka2, la: Cb, ma: ra2, na: Xa2, oa: eg, pa: qb, qa: dg, ra: cg, sa: ua2, ta: ka2, ua: Dc, va: ra2, wa: Va2, xa: ud, ya: Ya2, za: bg, Aa: ag, Ba: ka2, Ca: ka2, Da: Dc, Ea: ra2, Fa: ze2, Ga: ud, Ha: Ng, Ia: wd, Ja: vd, Ka: ka2, La: ka2, Ma: ka2, Na: ka2, Oa: Ma2, Pa: ka2, Qa: ma2, Ra: ma2, Sa: Ta2, Ta: dh2, Ua: ch, Va: bh, Wa: ah, Xa: Lb, Ya: Kb, Za: td, _a: sd, $a: rd, ab: $f, bb: _f, cb: Zf, db: qd, eb: Yf, fb: pd, gb: Xf, hb: Wf, ib: Uf, jb: Md, kb: tc, lb: nb, mb, nb: Lb, ob: Kb, pb: td, qb: sd, rb: ka2, sb: ka2, tb: ka2, ub: ka2, vb: Ma2, wb: ka2, xb: ma2, yb: ma2, zb: Ta2, Ab: Aa2, Bb: ka2, Cb: ma2, Db: ka2, Eb: ma2, Fb: Sa2, Gb: ka2, Hb: ma2, Ib: ka2, Jb: ma2, Kb: vb, Lb: ua2, Mb: ma2, Nb: ka2, Ob: ma2, Pb: ub, Qb: ua2, Rb: ma2, Sb: ka2, Tb: ma2, Ub: tb, Vb: ua2, Wb: ma2, Xb: ka2, Yb: ma2, Zb: ma2, _b: ua2, $b: ka2, ac: ma2, bc: ua2, cc: ka2, dc: Nd, ec: pe2, fc: od, gc: fh, hc: nd, ic: eh, jc: ra2, kc: ma2, lc: ua2, mc: ka2, nc: ma2, oc: ua2, pc: ka2, qc: ma2, rc: ma2, sc: pe2, tc: ra2, uc: od, vc: Tf, wc: Ja2, xc: xh, yc: nd, zc: Ia2, Ac: ua2, Bc: md, Cc: Lg, Dc: ka2, Ec: Ag, Fc: Ub, Gc: Sf, Hc: Ua2, Ic: Rf, Jc: ua2, Kc: Cb, Lc: Za2, Mc: ic, Nc: Ca2, Oc: md, Pc: ma2, Qc: ua2, Rc: Oa2, Sc: ka2, Tc: ld, Uc: Nd, Vc: ma2, Wc: ua2, Xc: Oa2, Yc: ka2, Zc: ld, _c: ra2, $c: Gh, ad: Fh, bd: Eh, cd: Dh, dd: ra2, ed: Ch, fd: ka2, gd: Ba2, hd: Bh, id: Cb, jd: ze2, kd: hi, ld: gi, md: fi, nd: ei, od: di, pd: ua2, qd: Ba2, rd: ci, sd: Dc, td: Gg, ud: nb, vd: Fg, wd: Eg, xd: ka2, yd: ka2, zd: ka2, Ad: ka2, Bd: Dg, Cd: Rc, Dd: ma2, Ed: ka2, Fd: kd, Gd: jd, Hd: Sg, Id: id, Jd: Rg, Kd: Qg, Ld: ra2, Md: kd, Nd: jd, Od: Ga2, Pd: id, Qd: Fa2, Rd: ma2, Sd: ka2, Td: Rc, Ud: ra2, Vd: Db, Wd: ma2, Xd: wa2, Yd: Ba2, Zd: wa2, _d: ma2, $d: yc, ae: wh, be: Vb, ce: wa2, de: xc, ee: wc, fe: vc, ge: me2, he: vh, ie: uh, je: Oa2, ke: th, le: Pf, me: Of, ne: Nf, oe: Mf, pe: Lf, qe: fb, re: ma2, se: wa2, te: Ba2, ue: wa2, ve: ma2, we: yc, xe: fe2, ye: Db, ze: wa2, Ae: xc, Be: wc, Ce: fb, De: ee2, Ee: Vb, Fe: de2, Ge: vc, He: uc, Ie: Kf, Je: hd, Ke: Jf, Le: Db, Me: fb, Ne: fb, Oe: ma2, Pe: wa2, Qe: Ba2, Re: wa2, Se: ma2, Te: yc, Ue: fe2, Ve: Db, We: wa2, Xe: xc, Ye: wc, Ze: fb, _e: ee2, $e: Vb, af: de2, bf: vc, cf: uc, df: Hf, ef: hd, ff: Gf, gf: Ff, hf: Ef, jf: sh, kf: Jg, lf: Ig, mf: Hg, nf: ka2, of: ka2, pf: Ea2, qf: wb, rf: ka2, sf: ka2, tf: ka2, uf: Ma2, vf: ka2, wf: ma2, xf: ma2, yf: Ta2, zf: Mg, Af: Lb, Bf: Kb, Cf: ra2, Df: rd, Ef: Df, Ff: qd, Gf: pd, Hf: Lb, If: Kb, Jf: ka2, Kf: Ma2, Lf: ka2, Mf: ma2, Nf: ma2, Of: Ta2, Pf: ra2, Qf: ra2, Rf: Mh, Sf: Lh, Tf: Kh, Uf: Cf, Vf: Bf, Wf: Jh, Xf: Ih, Yf: Ma2, Zf: ka2, _f: Hh, $f: Ba2, ag: Db, bg: fb, cg: Vb, dg: Oa2, eg: ma2, fg: Tg, gg: gd, hg: Je2, ig: Oa2, jg: ma2, kg: gd, lg: Cb, mg: ua2, ng: ka2, og: ka2, pg: ua2, qg: Wd, rg: lh, sg: kh, tg: jh, ug: fd, vg: ed, wg: dd, xg: cd, yg: ih, zg: ic, Ag: hh, Bg: gh, Cg: Cb, Dg: ua2, Eg: ka2, Fg: ka2, Gg: ua2, Hg: Wd, Ig: nh, Jg: mh, Kg: Vd, Lg: ic, Mg: Ud, Ng: Td, Og: Yd, Pg: Xd, Qg: ph, Rg: oh, Sg: cd, Tg: ed, Ug: dd, Vg: fd, Wg: ka2, Xg: Oa2, Yg: wa2, Zg: ka2, _g: Ce2, $g: wa2, ah: zf, bh: yf, ch: xf, dh: wf, eh: vf, fh: uf, gh: ra2, hh: ra2, ih: ka2, jh: Ma2, kh: wa2, lh: qh, mh: bd, nh: ad, oh: ra2, ph: ka2, qh: Oa2, rh: wa2, sh: tf, th: sf, uh: rf, vh: ra2, wh: bd, xh: qf, yh: ad, zh: ka2, Ah: Ma2, Bh: wa2, Ch: ra2, Dh: ma2, Eh: ka2, Fh: ua2, Gh: db, Hh: kb, Ih: xd, Jh: oi, Kh: ni, Lh: Ae2, Mh: mi, Nh: za2, Oh: li, Ph: ka2, Qh: ki, Rh: pf, Sh: Ah, Th: zh, Uh: yh, Vh: Bc, Wh: Ac, Xh: ti, Yh: ji, Zh: ii, _h: Cg, $h: Bg, ai: fb, bi: Ba2, ci: tc, di: nb, ei: rh, fi: $c, gi: of, hi: nf, ii: mf, ji: _c, ki: lf, li: Yc, mi: kf, ni: ka2, oi: ka2, pi: ka2, qi: ka2, ri: Ma2, si: ma2, ti: Ta2, ui: jf, vi: hf, wi: Md, xi: bi, yi: ai, zi: $h, Ai: _h, Bi: Zh, Ci: ye2, Di: xe2, Ei: we2, Fi: ve2, Gi: ue2, Hi: te2, Ii: se2, Ji: re2, Ki: ka2, Li: ua2, Mi: ka2, Ni: ua2, Oi: ka2, Pi: Yh, Qi: Xh, Ri: Wh, Si: Vh, Ti: Uh, Ui: Th, Vi: Sh, Wi: Rh, Xi: Qh, Yi: Ph, Zi: Oh, _i: re2, $i: Nh, aj: ka2, bj: ua2, cj: ua2, dj: ka2, ej: gf, fj: ma2, gj: wa2, hj: Ba2, ij: wa2, jj: ka2, kj: $g, lj: _g, mj: Zg, nj: wa2, oj: Ed, pj: wa2, qj: Yg, rj: Ed, sj: me2, tj: uc, uj: ff, vj: ef, wj: df, xj: cf, yj: Xg, zj: Wg, Aj: Vg, Bj: Ug, Cj: ka2, Dj: ka2, Ej: Pg, Fj: Og, Gj: ka2, Hj: ka2, Ij: $c, Jj: bf, Kj: _c, Lj: Yc, Mj: ka2, Nj: Ma2, Oj: ma2, Pj: Ta2, Qj: ma2, Rj: ma2, Sj: af, Tj: $e2, Uj: _e2, Vj: ka2, Wj: Oa2, Xj: wa2, Yj: ra2, Zj: Ze2, _j: Ye2, $j: ka2, ak: Oa2, bk: wa2, ck: ra2, dk: ka2, ek: Ma2, fk: wa2, gk: Xe2, hk: We2, ik: Ve2, jk: ra2, kk: Da2, lk: ta2 };
40657
40731
  }
40658
40732
  return da2(ea2);
40659
- }(info);
40733
+ })(info);
40660
40734
  }, instantiate: function(binary, info) {
40661
40735
  return { then: function(ok) {
40662
40736
  var module2 = new WebAssembly2.Module(binary);
@@ -70067,7 +70141,8 @@ ${messageText}`;
70067
70141
  const candidateCount = candidates.filter(Boolean).length;
70068
70142
  const joined = await joinWithFirstMatchingKp(welcomeBytes, candidates);
70069
70143
  if (!joined) {
70070
- console.error(`[SecureChannel] No matching KeyPackage found for Welcome \u2014 cannot join group ${groupId?.slice(0, 8)}. The Welcome is encrypted to a published KP's public key; none of our ${candidateCount} candidate bundle(s) decrypted it. The existing Welcome recovery mechanism will re-request.`);
70144
+ console.error(`[SecureChannel] No matching KeyPackage found for Welcome \u2014 cannot join group ${groupId?.slice(0, 8)}. The Welcome is encrypted to a published KP's public key; none of our ${candidateCount} candidate bundle(s) decrypted it. Requesting a re-Welcome with a fresh KeyPackage.`);
70145
+ if (groupId) void this._requestWelcomeSelfHeal(groupId);
70071
70146
  return;
70072
70147
  }
70073
70148
  const mgr = joined.mgr;
@@ -81231,7 +81306,7 @@ function _stringbool(Classes, _params) {
81231
81306
  type: "pipe",
81232
81307
  in: stringSchema,
81233
81308
  out: booleanSchema,
81234
- transform: (input, payload) => {
81309
+ transform: ((input, payload) => {
81235
81310
  let data = input;
81236
81311
  if (params.case !== "sensitive")
81237
81312
  data = data.toLowerCase();
@@ -81250,14 +81325,14 @@ function _stringbool(Classes, _params) {
81250
81325
  });
81251
81326
  return {};
81252
81327
  }
81253
- },
81254
- reverseTransform: (input, _payload) => {
81328
+ }),
81329
+ reverseTransform: ((input, _payload) => {
81255
81330
  if (input === true) {
81256
81331
  return truthyArray[0] || "true";
81257
81332
  } else {
81258
81333
  return falsyArray[0] || "false";
81259
81334
  }
81260
- },
81335
+ }),
81261
81336
  error: params.error
81262
81337
  });
81263
81338
  return codec2;
@@ -82313,10 +82388,10 @@ var init_schemas2 = __esm2({
82313
82388
  inst.with = inst.check;
82314
82389
  inst.clone = (_def, params) => clone(inst, _def, params);
82315
82390
  inst.brand = () => inst;
82316
- inst.register = (reg, meta3) => {
82391
+ inst.register = ((reg, meta3) => {
82317
82392
  reg.add(inst, meta3);
82318
82393
  return inst;
82319
- };
82394
+ });
82320
82395
  inst.apply = (fn) => fn(inst);
82321
82396
  });
82322
82397
  ZodMiniObject = /* @__PURE__ */ $constructor("ZodMiniObject", (inst, def) => {
@@ -83402,10 +83477,10 @@ var init_schemas3 = __esm2({
83402
83477
  inst.with = inst.check;
83403
83478
  inst.clone = (def2, params) => clone(inst, def2, params);
83404
83479
  inst.brand = () => inst;
83405
- inst.register = (reg, meta3) => {
83480
+ inst.register = ((reg, meta3) => {
83406
83481
  reg.add(inst, meta3);
83407
83482
  return inst;
83408
- };
83483
+ });
83409
83484
  inst.parse = (data, params) => parse2(inst, data, params, { callee: inst.parse });
83410
83485
  inst.safeParse = (data, params) => safeParse3(inst, data, params);
83411
83486
  inst.parseAsync = async (data, params) => parseAsync2(inst, data, params, { callee: inst.parseAsync });
@@ -84067,11 +84142,13 @@ function assertCompleteRequestPrompt(request) {
84067
84142
  if (request.params.ref.type !== "ref/prompt") {
84068
84143
  throw new TypeError(`Expected CompleteRequestPrompt, but got ${request.params.ref.type}`);
84069
84144
  }
84145
+ void request;
84070
84146
  }
84071
84147
  function assertCompleteRequestResourceTemplate(request) {
84072
84148
  if (request.params.ref.type !== "ref/resource") {
84073
84149
  throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${request.params.ref.type}`);
84074
84150
  }
84151
+ void request;
84075
84152
  }
84076
84153
  var LATEST_PROTOCOL_VERSION;
84077
84154
  var DEFAULT_NEGOTIATED_PROTOCOL_VERSION;
@@ -98202,28 +98279,29 @@ await init_index();
98202
98279
 
98203
98280
  // src/index.ts
98204
98281
  init_config();
98282
+ init_pending_invite();
98205
98283
  init_log();
98206
98284
 
98207
98285
  // src/fence-auth.ts
98208
- import { copyFileSync, chmodSync as chmodSync2, existsSync as existsSync2, mkdirSync as mkdirSync2 } from "node:fs";
98209
- import { join as join6 } from "node:path";
98286
+ import { copyFileSync, chmodSync as chmodSync3, existsSync as existsSync3, mkdirSync as mkdirSync3 } from "node:fs";
98287
+ import { join as join7 } from "node:path";
98210
98288
  function seedFenceCredential(opts) {
98211
98289
  const log = opts.log ?? (() => {
98212
98290
  });
98213
- const fenceGrok = join6(opts.fenceHome, ".grok");
98214
- const fenceAuth = join6(fenceGrok, "auth.json");
98215
- if (existsSync2(fenceAuth)) {
98291
+ const fenceGrok = join7(opts.fenceHome, ".grok");
98292
+ const fenceAuth = join7(fenceGrok, "auth.json");
98293
+ if (existsSync3(fenceAuth)) {
98216
98294
  log("[grok-bridge] fence credential already present; leaving it untouched");
98217
98295
  return "already-present";
98218
98296
  }
98219
- const hostAuth = join6(opts.hostHome, ".grok", "auth.json");
98220
- if (!existsSync2(hostAuth)) {
98297
+ const hostAuth = join7(opts.hostHome, ".grok", "auth.json");
98298
+ if (!existsSync3(hostAuth)) {
98221
98299
  log("[grok-bridge] no host credential to seed (run `grok login`, or set XAI_API_KEY)");
98222
98300
  return "no-host-credential";
98223
98301
  }
98224
- mkdirSync2(fenceGrok, { recursive: true });
98302
+ mkdirSync3(fenceGrok, { recursive: true });
98225
98303
  copyFileSync(hostAuth, fenceAuth);
98226
- chmodSync2(fenceAuth, 384);
98304
+ chmodSync3(fenceAuth, 384);
98227
98305
  log("[grok-bridge] seeded fence credential from the host grok login");
98228
98306
  return "seeded";
98229
98307
  }
@@ -98234,6 +98312,8 @@ var GrokSession = class {
98234
98312
  this.driver = driver2;
98235
98313
  this.opts = opts;
98236
98314
  }
98315
+ driver;
98316
+ opts;
98237
98317
  queue = [];
98238
98318
  running = false;
98239
98319
  /** The message whose turn is in flight, or null between turns. Null is a
@@ -98346,6 +98426,9 @@ var AcpChildDied = class extends Error {
98346
98426
  this.signal = signal;
98347
98427
  this.name = "AcpChildDied";
98348
98428
  }
98429
+ method;
98430
+ code;
98431
+ signal;
98349
98432
  };
98350
98433
  var AcpTimeout = class extends Error {
98351
98434
  constructor(method, ms) {
@@ -98354,6 +98437,8 @@ var AcpTimeout = class extends Error {
98354
98437
  this.ms = ms;
98355
98438
  this.name = "AcpTimeout";
98356
98439
  }
98440
+ method;
98441
+ ms;
98357
98442
  };
98358
98443
  var AcpConnection = class {
98359
98444
  constructor(child, opts) {
@@ -98371,6 +98456,7 @@ var AcpConnection = class {
98371
98456
  this.stdinErrors++;
98372
98457
  });
98373
98458
  }
98459
+ child;
98374
98460
  nextId = 1;
98375
98461
  pending = /* @__PURE__ */ new Map();
98376
98462
  /** Undecoded leftover. Decode UTF-8 only on complete lines so a 4-byte
@@ -98516,14 +98602,14 @@ var AcpConnection = class {
98516
98602
  };
98517
98603
 
98518
98604
  // src/grok-room-plugin.ts
98519
- import { mkdirSync as mkdirSync3, writeFileSync, chmodSync as chmodSync3 } from "node:fs";
98520
- import { join as join7 } from "node:path";
98605
+ import { mkdirSync as mkdirSync4, writeFileSync as writeFileSync2, chmodSync as chmodSync4 } from "node:fs";
98606
+ import { join as join8 } from "node:path";
98521
98607
  var SERVER_KEY = "room";
98522
98608
  var GROK_ROOM_SAY_TOOL_NAME = `${SERVER_KEY}__say`;
98523
98609
  function writeRoomPluginHttp(dir, url3) {
98524
- mkdirSync3(join7(dir, ".claude-plugin"), { recursive: true });
98525
- writeFileSync(
98526
- join7(dir, ".claude-plugin", "plugin.json"),
98610
+ mkdirSync4(join8(dir, ".claude-plugin"), { recursive: true });
98611
+ writeFileSync2(
98612
+ join8(dir, ".claude-plugin", "plugin.json"),
98527
98613
  JSON.stringify(
98528
98614
  {
98529
98615
  name: "avroom",
@@ -98535,12 +98621,12 @@ function writeRoomPluginHttp(dir, url3) {
98535
98621
  2
98536
98622
  ) + "\n"
98537
98623
  );
98538
- writeFileSync(
98539
- join7(dir, ".mcp.json"),
98624
+ writeFileSync2(
98625
+ join8(dir, ".mcp.json"),
98540
98626
  JSON.stringify({ mcpServers: { [SERVER_KEY]: { type: "http", url: url3 } } }, null, 2) + "\n",
98541
98627
  { mode: 384 }
98542
98628
  );
98543
- chmodSync3(join7(dir, ".mcp.json"), 384);
98629
+ chmodSync4(join8(dir, ".mcp.json"), 384);
98544
98630
  }
98545
98631
 
98546
98632
  // src/grok-driver.ts
@@ -98553,6 +98639,8 @@ var GrokDriver = class {
98553
98639
  this.acp.onNotification((method, params) => this.onNotification(method, params));
98554
98640
  this.acp.onRequest((method, params) => this.onAgentRequest(method, params));
98555
98641
  }
98642
+ child;
98643
+ opts;
98556
98644
  acp;
98557
98645
  session = null;
98558
98646
  /** State for the turn currently in flight. Null between turns, so a late
@@ -98673,7 +98761,7 @@ var GrokDriver = class {
98673
98761
  };
98674
98762
 
98675
98763
  // src/grok-spawn.ts
98676
- import { join as join8 } from "node:path";
98764
+ import { join as join9 } from "node:path";
98677
98765
  function grokSpawnArgs(opts) {
98678
98766
  const args = ["agent", "--no-leader"];
98679
98767
  if (opts.model) args.push("--model", opts.model);
@@ -98682,7 +98770,7 @@ function grokSpawnArgs(opts) {
98682
98770
  const env = {
98683
98771
  PATH: process.env.PATH,
98684
98772
  HOME: opts.fenceHome,
98685
- GROK_HOME: join8(opts.fenceHome, ".grok")
98773
+ GROK_HOME: join9(opts.fenceHome, ".grok")
98686
98774
  };
98687
98775
  if (opts.apiKey) env.XAI_API_KEY = opts.apiKey;
98688
98776
  return { command: opts.grokPath ?? "grok", args, env, cwd: opts.workspaceDir };
@@ -99044,14 +99132,55 @@ async function main() {
99044
99132
  })) {
99045
99133
  process.exit(process.exitCode ?? 0);
99046
99134
  }
99135
+ const info = parseInfoFlags(process.argv.slice(2));
99136
+ if (info.showVersion || info.showHelp) {
99137
+ const version2 = buildClientVersion2(
99138
+ true ? "0.3.0" : void 0
99139
+ );
99140
+ if (info.showVersion) printLine(version2);
99141
+ if (info.showHelp) {
99142
+ printLine(
99143
+ [
99144
+ "",
99145
+ `${version2}`,
99146
+ "",
99147
+ " Bridges a Grok agent into E2E-encrypted AgentVault DMs and rooms.",
99148
+ "",
99149
+ "USAGE",
99150
+ " agentvault-grok-bridge [<invite-token>] [--install]",
99151
+ " agentvault-grok-bridge <install|uninstall|restart|status|logs>",
99152
+ "",
99153
+ "FLAGS",
99154
+ " --install Enrol, install a supervised OS service, then EXIT so",
99155
+ " your terminal returns. Requires a global install:",
99156
+ " npm i -g @agentvault/grok-bridge",
99157
+ " --version, -v Print the version.",
99158
+ " --help, -h Print this.",
99159
+ "",
99160
+ "ENV",
99161
+ " AV_AGENT_NAME The agent's AgentVault name. Required.",
99162
+ " AV_INVITE_TOKEN First enrolment only; a saved data dir reconnects without it.",
99163
+ " AV_DATA_DIR Credential/state dir. Defaults per agent.",
99164
+ "",
99165
+ "NOTES",
99166
+ " Run `grok login` first. XAI_API_KEY from your shell is NOT inherited by a",
99167
+ " supervised service, so --install refuses rather than run mute.",
99168
+ " To restart later use `restart`, never `install` \u2014 install re-bakes the",
99169
+ " service from your current shell and drops env from the original install.",
99170
+ ""
99171
+ ].join("\n")
99172
+ );
99173
+ }
99174
+ process.exit(0);
99175
+ }
99047
99176
  const cfg = loadConfig(process.env, process.argv.slice(2));
99048
99177
  if (cfg.installAfterEnroll) {
99049
99178
  assertInstallableEntrypoint(process.argv[1]);
99050
99179
  const { selectBackend: selectBackend2 } = await Promise.resolve().then(() => (init_backend(), backend_exports));
99051
99180
  selectBackend2(process.platform);
99052
99181
  }
99053
- mkdirSync5(cfg.workspaceDir, { recursive: true });
99054
- mkdirSync5(cfg.fenceHome, { recursive: true });
99182
+ mkdirSync6(cfg.workspaceDir, { recursive: true });
99183
+ mkdirSync6(cfg.fenceHome, { recursive: true });
99055
99184
  seedFenceCredential({
99056
99185
  fenceHome: cfg.fenceHome,
99057
99186
  hostHome: process.env.HOME ?? "",
@@ -99064,7 +99193,7 @@ async function main() {
99064
99193
  agentName: cfg.agentName,
99065
99194
  platform: "node",
99066
99195
  clientVersion: buildClientVersion2(
99067
- true ? "0.2.0" : void 0
99196
+ true ? "0.3.0" : void 0
99068
99197
  )
99069
99198
  });
99070
99199
  channelRef = channel;
@@ -99085,7 +99214,7 @@ async function main() {
99085
99214
  },
99086
99215
  log: (m2) => logLine(m2)
99087
99216
  });
99088
- const pluginDir = join13(cfg.fenceHome, "av-room-plugin");
99217
+ const pluginDir = join14(cfg.fenceHome, "av-room-plugin");
99089
99218
  writeRoomPluginHttp(pluginDir, mcp.url);
99090
99219
  const spawnSpec = grokSpawnArgs({
99091
99220
  grokPath: cfg.grokPath,
@@ -99150,6 +99279,11 @@ async function main() {
99150
99279
  log: (m2) => logLine("[grok-bridge] " + m2),
99151
99280
  onTerminal: (_reason, o2) => void shutdown(o2.restart ? 1 : 0)
99152
99281
  });
99282
+ channel.on("ready", () => {
99283
+ if (clearPendingInviteIfConsumed(cfg.dataDir, hasPersistedCreds)) {
99284
+ logLine("[grok-bridge] enrolled \u2014 pending invite consumed and removed");
99285
+ }
99286
+ });
99153
99287
  if (cfg.installAfterEnroll) {
99154
99288
  const { installOnReady: installOnReady2 } = await Promise.resolve().then(() => (init_install_on_ready(), install_on_ready_exports));
99155
99289
  installOnReady2(channel, cfg, {
package/dist/log.d.ts CHANGED
@@ -19,4 +19,16 @@ export declare function stamp(message: string): string;
19
19
  * just anchored to a clock.
20
20
  */
21
21
  export declare function logLine(...args: unknown[]): void;
22
+ /**
23
+ * Plain stdout, no timestamp. For CLI answers a human or a script reads —
24
+ * `--version` and `--help` — not for daemon logging.
25
+ *
26
+ * `logLine` stamps every line and writes to stderr, which is right for a daemon
27
+ * and wrong here: `agentvault-grok-bridge --version` must print a version, not a
28
+ * version wearing a date. Anything a script would parse belongs on stdout.
29
+ *
30
+ * This lives in log.ts because the "no bare console sinks" guard test excludes
31
+ * only this file — the sink belongs here, and nowhere else.
32
+ */
33
+ export declare function printLine(text: string): void;
22
34
  //# sourceMappingURL=log.d.ts.map
@@ -0,0 +1,24 @@
1
+ export declare function pendingInvitePath(dataDir: string): string;
2
+ /** Persist the token for the service's first boot. Owner-only, unconditionally. */
3
+ export declare function writePendingInvite(dataDir: string, token: string): void;
4
+ /** The pending token, or undefined when there is none to consume. */
5
+ export declare function readPendingInvite(dataDir: string): string | undefined;
6
+ /** Remove it. Idempotent: nothing to remove is a success, not an error. */
7
+ export declare function clearPendingInvite(dataDir: string): void;
8
+ /**
9
+ * Delete the pending invite once there is EVIDENCE it was consumed — i.e.
10
+ * credentials have actually persisted to the data dir.
11
+ *
12
+ * Timing is the whole design here. Deleting on READ (inside loadConfig) would
13
+ * throw the token away before enrolment finished, so a process that died in
14
+ * between would leave a service that can never enrol and a customer whose
15
+ * single-use invite is gone. Never deleting leaves a credential on disk long
16
+ * after it is useless.
17
+ *
18
+ * `credsExist` is injected so the caller supplies `hasPersistedCreds` and this
19
+ * module stays free of a config import cycle.
20
+ *
21
+ * @returns true when a file was actually removed.
22
+ */
23
+ export declare function clearPendingInviteIfConsumed(dataDir: string, credsExist: (dataDir: string) => boolean): boolean;
24
+ //# sourceMappingURL=pending-invite.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"subcommand.d.ts","sourceRoot":"","sources":["../../src/service/subcommand.ts"],"names":[],"mappings":"AAGA,OAAO,EAAiB,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAElE,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7B;AAQD;;uFAEuF;AACvF,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,MAAM,EAAE,EACd,GAAG,EAAE,MAAM,CAAC,UAAU,EACtB,IAAI,CAAC,EAAE,cAAc,GACpB,OAAO,CA4DT"}
1
+ {"version":3,"file":"subcommand.d.ts","sourceRoot":"","sources":["../../src/service/subcommand.ts"],"names":[],"mappings":"AAIA,OAAO,EAAiB,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAElE,MAAM,WAAW,cAAc;IAC7B,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7B;AAQD;;uFAEuF;AACvF,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,MAAM,EAAE,EACd,GAAG,EAAE,MAAM,CAAC,UAAU,EACtB,IAAI,CAAC,EAAE,cAAc,GACpB,OAAO,CA6GT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentvault/grok-bridge",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "description": "AgentVault Grok Bridge — daemon bridging a Grok agent into E2E-encrypted AgentVault direct messages and rooms.",
6
6
  "main": "dist/index.js",