@wibeco/bridge 0.2.9 → 0.2.10

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.
@@ -628,7 +628,7 @@ var JsonFileOfflineQueue = class {
628
628
  // src/presence.ts
629
629
  import { createHash, randomUUID as randomUUID3 } from "crypto";
630
630
  import { spawn } from "child_process";
631
- import { mkdir as mkdir2, readFile as readFile2, rm, writeFile as writeFile2 } from "fs/promises";
631
+ import { mkdir as mkdir2, readFile as readFile2, readdir, rm, writeFile as writeFile2 } from "fs/promises";
632
632
  import { homedir } from "os";
633
633
  import { join } from "path";
634
634
  var PRESENCE_HEARTBEAT_INTERVAL_MS = 45e3;
@@ -815,6 +815,35 @@ function presenceStatePath(source, sessionId, cwd = process.cwd()) {
815
815
  const key = createHash("sha256").update(`${source}\0${sessionId ?? ""}\0${cwd}`).digest("hex");
816
816
  return join(presenceDirectory(), `${key}.json`);
817
817
  }
818
+ async function resolveLatestPresenceSession(source, cwd = process.cwd(), maxAgeMs = 5 * 6e4) {
819
+ let names;
820
+ try {
821
+ names = await readdir(presenceDirectory());
822
+ } catch {
823
+ return void 0;
824
+ }
825
+ const now = Date.now();
826
+ let latest;
827
+ for (const name of names) {
828
+ if (!name.endsWith(".json")) continue;
829
+ const path = join(presenceDirectory(), name);
830
+ const state = await readPresenceState(path);
831
+ if (!state?.sessionId || state.source !== source || path !== presenceStatePath(source, state.sessionId, cwd)) {
832
+ continue;
833
+ }
834
+ const lastActivity = Date.parse(state.lastActivityAt);
835
+ if (!Number.isFinite(lastActivity) || lastActivity > now + 6e4 || now - lastActivity > maxAgeMs) {
836
+ continue;
837
+ }
838
+ if (!latest || state.lastActivityAt > latest.lastActivityAt) {
839
+ latest = {
840
+ sessionId: state.sessionId,
841
+ lastActivityAt: state.lastActivityAt
842
+ };
843
+ }
844
+ }
845
+ return latest?.sessionId;
846
+ }
818
847
  function presenceDirectory() {
819
848
  return process.env.WIBE_PRESENCE_DIR ?? join(homedir(), ".wibe", "presence");
820
849
  }
@@ -1417,6 +1446,7 @@ export {
1417
1446
  stopPresenceSession,
1418
1447
  runPresenceHeartbeat,
1419
1448
  presenceStatePath,
1449
+ resolveLatestPresenceSession,
1420
1450
  classifyHeadTransition,
1421
1451
  isObservedPush,
1422
1452
  detectRepository,
@@ -15,10 +15,11 @@ import {
15
15
  observeRepositoryTransitions,
16
16
  pollDeviceToken,
17
17
  requestDeviceAuthorization,
18
+ resolveLatestPresenceSession,
18
19
  startPresenceSession,
19
20
  stopPresenceSession,
20
21
  updatePresenceSession
21
- } from "./chunk-DSMXRUNM.js";
22
+ } from "./chunk-FIT6PBBW.js";
22
23
 
23
24
  // src/cli/commands.ts
24
25
  import { access, cp, mkdir, readFile, writeFile } from "fs/promises";
@@ -366,9 +367,14 @@ async function shareProgressCommand(options, cwd = process.cwd()) {
366
367
  }
367
368
  const repo = await detectRepository(cwd);
368
369
  const workingTree = repo ? await detectWorkingTreeMetrics(repo.root) : void 0;
370
+ const sessionId = await resolveLatestPresenceSession(
371
+ projectConfig.adapter,
372
+ cwd
373
+ );
369
374
  const event = createHookEvent({
370
375
  source: projectConfig.adapter,
371
376
  kind: "progress.shared",
377
+ ...sessionId ? { sessionId } : {},
372
378
  metadata: {
373
379
  summary,
374
380
  ...title ? { title } : {},
package/dist/cli.js CHANGED
@@ -6,10 +6,10 @@ import {
6
6
  setupCommand,
7
7
  shareProgressCommand,
8
8
  statusCommand
9
- } from "./chunk-6P6IVLMW.js";
9
+ } from "./chunk-ODX3HMDN.js";
10
10
  import {
11
11
  runPresenceHeartbeat
12
- } from "./chunk-DSMXRUNM.js";
12
+ } from "./chunk-FIT6PBBW.js";
13
13
 
14
14
  // src/cli.ts
15
15
  var HELP = `wibe-bridge <command>
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  emitCommand
4
- } from "./chunk-6P6IVLMW.js";
5
- import "./chunk-DSMXRUNM.js";
4
+ } from "./chunk-ODX3HMDN.js";
5
+ import "./chunk-FIT6PBBW.js";
6
6
 
7
7
  // src/codex-hook.ts
8
8
  async function main() {
package/dist/index.d.ts CHANGED
@@ -304,6 +304,7 @@ declare function updatePresenceSession(source: AgentSource, sessionId: string |
304
304
  declare function stopPresenceSession(source: AgentSource, sessionId: string | undefined, cwd?: string): Promise<PresenceMetrics | undefined>;
305
305
  declare function runPresenceHeartbeat(statePath: string, expectedInstanceId: string, emit: (source: AgentSource, eventName: string, payload: Record<string, unknown>) => Promise<unknown>, intervalMs?: number): Promise<void>;
306
306
  declare function presenceStatePath(source: AgentSource, sessionId: string | undefined, cwd?: string): string;
307
+ declare function resolveLatestPresenceSession(source: AgentSource, cwd?: string, maxAgeMs?: number): Promise<string | undefined>;
307
308
 
308
309
  interface RedactionOptions {
309
310
  allowContent?: boolean;
@@ -345,4 +346,4 @@ declare function sanitizeRemote(remote: string): string;
345
346
  declare function normalizeGitHubRepository(value: string): string | undefined;
346
347
  declare function matchesGitHubRepository(remote: string | undefined, expected: string): boolean;
347
348
 
348
- export { type AgentSource, type CanonicalHookEvent, type CredentialStore, type DeviceAuthorization, type DeviceTokenResponse, type FlushResult, type HookEventKind, JsonFileOfflineQueue, MemoryOfflineQueue, type OfflineQueue, PRESENCE_HEARTBEAT_INTERVAL_MS, type PresenceMetrics, type RedactionOptions, type RepositoryInfo, type RepositoryTransition, type SafeValue, SignedBatchClient, type SignedBatchClientOptions, type StoredCredential, SystemCredentialStore, type WorkingTreeMetrics, agentSourceSchema, canonicalHookEventSchema, classifyHeadTransition, createHookEvent, detectRepository, detectWorkingTreeMetrics, deviceAuthorizationSchema, deviceTokenResponseSchema, eventTypeForHook, hookEventKindSchema, isObservedPush, mapClaudeCodeHook, mapCodexHook, mapCursorHook, matchesGitHubRepository, normalizeGitHubRepository, observeRepositoryTransitions, pollDeviceToken, presenceStatePath, redact, requestDeviceAuthorization, runPresenceHeartbeat, safeMetadata, safeValueSchema, sanitizeRemote, startPresenceSession, stopPresenceSession, updatePresenceSession };
349
+ export { type AgentSource, type CanonicalHookEvent, type CredentialStore, type DeviceAuthorization, type DeviceTokenResponse, type FlushResult, type HookEventKind, JsonFileOfflineQueue, MemoryOfflineQueue, type OfflineQueue, PRESENCE_HEARTBEAT_INTERVAL_MS, type PresenceMetrics, type RedactionOptions, type RepositoryInfo, type RepositoryTransition, type SafeValue, SignedBatchClient, type SignedBatchClientOptions, type StoredCredential, SystemCredentialStore, type WorkingTreeMetrics, agentSourceSchema, canonicalHookEventSchema, classifyHeadTransition, createHookEvent, detectRepository, detectWorkingTreeMetrics, deviceAuthorizationSchema, deviceTokenResponseSchema, eventTypeForHook, hookEventKindSchema, isObservedPush, mapClaudeCodeHook, mapCodexHook, mapCursorHook, matchesGitHubRepository, normalizeGitHubRepository, observeRepositoryTransitions, pollDeviceToken, presenceStatePath, redact, requestDeviceAuthorization, resolveLatestPresenceSession, runPresenceHeartbeat, safeMetadata, safeValueSchema, sanitizeRemote, startPresenceSession, stopPresenceSession, updatePresenceSession };
package/dist/index.js CHANGED
@@ -25,6 +25,7 @@ import {
25
25
  presenceStatePath,
26
26
  redact,
27
27
  requestDeviceAuthorization,
28
+ resolveLatestPresenceSession,
28
29
  runPresenceHeartbeat,
29
30
  safeMetadata,
30
31
  safeValueSchema,
@@ -32,7 +33,7 @@ import {
32
33
  startPresenceSession,
33
34
  stopPresenceSession,
34
35
  updatePresenceSession
35
- } from "./chunk-DSMXRUNM.js";
36
+ } from "./chunk-FIT6PBBW.js";
36
37
  export {
37
38
  JsonFileOfflineQueue,
38
39
  MemoryOfflineQueue,
@@ -60,6 +61,7 @@ export {
60
61
  presenceStatePath,
61
62
  redact,
62
63
  requestDeviceAuthorization,
64
+ resolveLatestPresenceSession,
63
65
  runPresenceHeartbeat,
64
66
  safeMetadata,
65
67
  safeValueSchema,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wibeco/bridge",
3
- "version": "0.2.9",
3
+ "version": "0.2.10",
4
4
  "description": "Privacy-first live activity bridge for Cursor, Claude Code, and Codex.",
5
5
  "repository": {
6
6
  "type": "git",