@agentvault/grok-bridge 0.4.4 → 0.4.5

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/index.js CHANGED
@@ -64004,6 +64004,8 @@ var init_mls_group = __esm2({
64004
64004
  continue;
64005
64005
  seenIdentities.push(identity);
64006
64006
  const leaf = this.memberLeafIndex(identity);
64007
+ if (leaf !== null && leaf === this.ownLeafIndex())
64008
+ continue;
64007
64009
  if (leaf !== null)
64008
64010
  leavesToRemove.push(leaf);
64009
64011
  }
@@ -64059,6 +64061,20 @@ var init_mls_group = __esm2({
64059
64061
  * then re-adds it with a fresh KeyPackage so it gets a Welcome at the
64060
64062
  * current epoch it can actually apply.
64061
64063
  */
64064
+ /**
64065
+ * The leaf index THIS manager occupies — the leaf whose private key it holds.
64066
+ *
64067
+ * Read from `privatePath.leafIndex`, which is the same value ts-mls uses to
64068
+ * decide whether a commit removes its own committer, so a caller checking
64069
+ * against this cannot disagree with the library about who "we" are.
64070
+ *
64071
+ * Exists so a fulfiller can tell a request from ANOTHER device apart from one
64072
+ * from itself (#1147) without any "who am I" plumbing: the manager already
64073
+ * knows, and a guard that reads it here cannot be forgotten by a call site.
64074
+ */
64075
+ ownLeafIndex() {
64076
+ return this._requireState().privatePath.leafIndex;
64077
+ }
64062
64078
  memberLeafIndex(identity) {
64063
64079
  const s2 = this._requireState();
64064
64080
  const tree = s2.ratchetTree;
@@ -64589,11 +64605,11 @@ var init_mls_kp_pool = __esm2({
64589
64605
  }
64590
64606
  });
64591
64607
  function ownIdentity() {
64592
- const v2 = true ? "0.23.31" : FALLBACK;
64608
+ const v2 = true ? "0.23.32" : FALLBACK;
64593
64609
  return `${PACKAGE}@${v2}`;
64594
64610
  }
64595
64611
  function buildSha() {
64596
- const raw = true ? "3e1243a-dirty" : "";
64612
+ const raw = true ? "564f8b1-dirty" : "";
64597
64613
  const cleaned = (raw ?? "").trim();
64598
64614
  return !cleaned || cleaned === "unknown" ? null : cleaned;
64599
64615
  }
@@ -66787,7 +66803,7 @@ var init_channel = __esm2({
66787
66803
  */
66788
66804
  sendActivitySpan(spanData) {
66789
66805
  if (!this._ws || this._ws.readyState !== WebSocket.OPEN) return;
66790
- const pluginVersion = true ? "0.23.31" : "0.0.0-dev";
66806
+ const pluginVersion = true ? "0.23.32" : "0.0.0-dev";
66791
66807
  const agentName = this.config.agentName ?? "Agent";
66792
66808
  const resource = {
66793
66809
  "service.name": "agentvault-agent",
@@ -68725,7 +68741,7 @@ var init_channel = __esm2({
68725
68741
  agentVersion: this.config.agentVersion ?? "0.0.0",
68726
68742
  // __AV_VERSION__ is injected by esbuild from package.json at build time.
68727
68743
  // Falls back to "0.0.0-dev" in non-bundled contexts (tests).
68728
- pluginVersion: true ? "0.23.31" : "0.0.0-dev"
68744
+ pluginVersion: true ? "0.23.32" : "0.0.0-dev"
68729
68745
  });
68730
68746
  this._telemetryReporter.startAutoFlush(3e4);
68731
68747
  }
@@ -69049,7 +69065,7 @@ var init_channel = __esm2({
69049
69065
  agentVersion: this.config.agentVersion ?? "0.0.0",
69050
69066
  // __AV_VERSION__ is injected by esbuild from package.json at build time.
69051
69067
  // Falls back to "0.0.0-dev" in non-bundled contexts (tests).
69052
- pluginVersion: true ? "0.23.31" : "0.0.0-dev"
69068
+ pluginVersion: true ? "0.23.32" : "0.0.0-dev"
69053
69069
  });
69054
69070
  this._telemetryReporter.startAutoFlush(3e4);
69055
69071
  }
@@ -69852,7 +69868,8 @@ ${baseText}`;
69852
69868
  async _downloadAndDecryptAttachment(info) {
69853
69869
  const attachDir = join4(this.config.dataDir, "attachments");
69854
69870
  await mkdir3(attachDir, { recursive: true });
69855
- const url22 = `${this.config.apiUrl}${info.blobUrl}`;
69871
+ const sep2 = info.blobUrl.includes("?") ? "&" : "?";
69872
+ const url22 = `${this.config.apiUrl}${info.blobUrl}${sep2}device_id=${encodeURIComponent(this._deviceId ?? "")}`;
69856
69873
  const res = await fetch(url22, {
69857
69874
  headers: { Authorization: `Bearer ${this._deviceJwt}` }
69858
69875
  });
@@ -70404,10 +70421,12 @@ ${baseText}`;
70404
70421
  const rawPlaintext = new TextDecoder().decode(result.plaintext);
70405
70422
  let messageText;
70406
70423
  let messageType;
70424
+ let roomAttachment = null;
70407
70425
  try {
70408
70426
  const parsed = JSON.parse(rawPlaintext);
70409
70427
  messageType = parsed.type || "message";
70410
70428
  messageText = parsed.text || rawPlaintext;
70429
+ if (parsed.attachment) roomAttachment = parsed.attachment;
70411
70430
  } catch {
70412
70431
  messageType = "message";
70413
70432
  messageText = rawPlaintext;
@@ -70447,6 +70466,9 @@ ${baseText}`;
70447
70466
  await this._refreshRoomRoster(resolvedRoomId);
70448
70467
  }
70449
70468
  }
70469
+ if (roomAttachment) {
70470
+ messageText = await this._augmentWithAttachment(roomAttachment, messageText);
70471
+ }
70450
70472
  const roomMembers = this._persisted?.rooms?.[resolvedRoomId]?.members ?? [];
70451
70473
  const senderMember = roomMembers.find((m2) => m2.deviceId === senderDeviceId);
70452
70474
  const senderIsAgent = senderMember?.entityType === "agent";
@@ -99403,7 +99425,7 @@ var init_index = __esm2({
99403
99425
  await init_skill_telemetry();
99404
99426
  await init_policy_enforcer();
99405
99427
  init_room_protocol();
99406
- VERSION = true ? "0.23.31" : "0.0.0-dev";
99428
+ VERSION = true ? "0.23.32" : "0.0.0-dev";
99407
99429
  }
99408
99430
  });
99409
99431
  await init_index();
@@ -100329,7 +100351,7 @@ async function main() {
100329
100351
  const info = parseInfoFlags(process.argv.slice(2));
100330
100352
  if (info.showVersion || info.showHelp) {
100331
100353
  const version2 = buildClientVersion2(
100332
- true ? "0.4.4" : void 0
100354
+ true ? "0.4.5" : void 0
100333
100355
  );
100334
100356
  if (info.showVersion) printLine(version2);
100335
100357
  if (info.showHelp) {
@@ -100382,7 +100404,7 @@ async function main() {
100382
100404
  agentName: cfg.agentName,
100383
100405
  platform: "node",
100384
100406
  clientVersion: buildClientVersion2(
100385
- true ? "0.4.4" : void 0
100407
+ true ? "0.4.5" : void 0
100386
100408
  )
100387
100409
  });
100388
100410
  channelRef = channel;
@@ -0,0 +1,57 @@
1
+ import { type BridgeConfig } from "../config.js";
2
+ import type { ReapResult } from "../reap.js";
3
+ import { type ServiceBackend } from "./backend.js";
4
+ export interface InstallOnReadyDeps {
5
+ entrypoint: string;
6
+ env: NodeJS.ProcessEnv;
7
+ backend?: ServiceBackend;
8
+ hasCreds?: (dataDir: string) => boolean;
9
+ /** Contents of the installed launcher, or undefined when none is installed. */
10
+ readLauncher?: (path: string) => string | undefined;
11
+ fenceAuthExists?: (fenceHome: string) => boolean;
12
+ /** Resolves when no turn is in flight (GrokSession.idle). See rule 2. */
13
+ waitForIdle?: () => Promise<void>;
14
+ /** Bound on that wait. The terminal coming back is the product promise, so a
15
+ * wedged turn must never hold the customer's shell open. */
16
+ idleTimeoutMs?: number;
17
+ /** The ONE teardown (src/reap.ts). Must complete before launchctl runs. */
18
+ reap: () => Promise<ReapResult>;
19
+ exit: (code: number) => void;
20
+ log: (msg: string) => void;
21
+ }
22
+ interface ReadyChannel {
23
+ on(ev: "ready", cb: () => void): unknown;
24
+ }
25
+ /**
26
+ * One-paste install: enrol in the foreground, hand off to the supervisor, exit —
27
+ * so the customer's terminal comes back and the agent survives a reboot.
28
+ *
29
+ * Four rules this module exists to enforce.
30
+ *
31
+ * 1. REFUSE BEFORE REAPING. Everything that can say no does so before anything is
32
+ * torn down. Refusing afterwards leaves the customer with an approved device,
33
+ * a spent invite token, and no running process — strictly worse than never
34
+ * having guarded at all.
35
+ *
36
+ * 2. REAP COMPLETELY, THEN BOOTSTRAP. `LaunchdBackend.install` runs bootout →
37
+ * poll-until-gone → bootstrap → kickstart synchronously, so the service is
38
+ * live the instant install returns. A partial teardown means two ACP sessions
39
+ * and two WebSockets on one device. `reap()` reports failure rather than
40
+ * swallowing it, and a failed reap is a refusal.
41
+ *
42
+ * 3. COMPARE, DON'T DETECT. `status().loaded` means only that a plist with this
43
+ * label exists. The old `install` subcommand never guarded its entrypoint
44
+ * (subcommand.ts), so a customer can hold a LOADED plist baked against a
45
+ * pruned npx cache; restarting that repairs nothing and reports success.
46
+ * Restart only when a service is loaded AND its baked entrypoint is the one we
47
+ * would install. Compare the ENTRYPOINT, never the whole launcher script —
48
+ * that embeds the install-time PATH and is volatile across shells.
49
+ *
50
+ * 4. VERIFY BEFORE CLAIMING. `backend.install` returns void, and launchd's
51
+ * implementation runs `kickstart` regardless of every `bootstrap` exit code.
52
+ * This log line is the customer's only feedback, so it comes after a
53
+ * `status()` that returned loaded:true.
54
+ */
55
+ export declare function installOnReady(channel: ReadyChannel, cfg: BridgeConfig, deps: InstallOnReadyDeps): void;
56
+ export {};
57
+ //# sourceMappingURL=install-on-ready.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install-on-ready.d.ts","sourceRoot":"","sources":["../../src/service/install-on-ready.ts"],"names":[],"mappings":"AAEA,OAAO,EAA4C,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAC3F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAG7C,OAAO,EAAiB,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAElE,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;IACvB,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC;IACxC,+EAA+E;IAC/E,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;IACpD,eAAe,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC;IACjD,yEAAyE;IACzE,WAAW,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAClC;iEAC6D;IAC7D,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,2EAA2E;IAC3E,IAAI,EAAE,MAAM,OAAO,CAAC,UAAU,CAAC,CAAC;IAChC,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7B,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CAC5B;AAMD,UAAU,YAAY;IACpB,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC;CAC1C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,YAAY,EACrB,GAAG,EAAE,YAAY,EACjB,IAAI,EAAE,kBAAkB,GACvB,IAAI,CAgHN"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentvault/grok-bridge",
3
- "version": "0.4.4",
3
+ "version": "0.4.5",
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",