vibedate 0.8.2 → 0.8.3

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.
@@ -778,11 +778,13 @@ function parseHandshake(raw) {
778
778
  function peersPath(dir) {
779
779
  return path4.join(dir, "peers.json");
780
780
  }
781
- function loadPeers(dir = defaultStateDir()) {
781
+ function loadPeers(dir = defaultStateDir(), maxAgeMs = 7 * 24 * 60 * 60 * 1e3) {
782
782
  try {
783
783
  const raw = readFileSync3(peersPath(dir), "utf8");
784
784
  const data = JSON.parse(raw);
785
- return Array.isArray(data.peers) ? data.peers : [];
785
+ if (!Array.isArray(data.peers)) return [];
786
+ const now = Date.now();
787
+ return data.peers.filter((p) => now - new Date(p.lastSeenAt).getTime() <= maxAgeMs);
786
788
  } catch {
787
789
  return [];
788
790
  }
@@ -798,7 +800,9 @@ function recordPeer(hello, dir = defaultStateDir(), now = /* @__PURE__ */ new Da
798
800
  ...hello.pubkey !== void 0 ? { pubkey: hello.pubkey } : {},
799
801
  ...hello.identityVerified !== void 0 ? { identityVerified: hello.identityVerified } : {}
800
802
  };
801
- const existing = peers.findIndex((p) => p.handle === clean.handle);
803
+ const existing = peers.findIndex(
804
+ (p) => clean.pubkey !== void 0 && p.pubkey !== void 0 ? p.pubkey === clean.pubkey : p.handle === clean.handle
805
+ );
802
806
  let isNew;
803
807
  let peer;
804
808
  if (existing >= 0) {
@@ -821,10 +825,12 @@ function recordPeer(hello, dir = defaultStateDir(), now = /* @__PURE__ */ new Da
821
825
  writeFileSync4(peersPath(dir), JSON.stringify({ peers }, null, 2) + "\n", "utf8");
822
826
  return { peer, isNew };
823
827
  }
824
- function recordPeerMessage(handle, dir = defaultStateDir(), now = /* @__PURE__ */ new Date()) {
828
+ function recordPeerMessage(peer, dir = defaultStateDir(), now = /* @__PURE__ */ new Date()) {
825
829
  try {
826
830
  const peers = loadPeers(dir);
827
- const idx = peers.findIndex((p) => p.handle === handle);
831
+ const idx = peers.findIndex(
832
+ (p) => peer.pubkey !== void 0 && p.pubkey !== void 0 ? p.pubkey === peer.pubkey : p.handle === peer.handle
833
+ );
828
834
  if (idx < 0) return false;
829
835
  peers[idx] = { ...peers[idx], lastMessageAt: now.toISOString() };
830
836
  mkdirSync3(dir, { recursive: true });
@@ -907,7 +913,7 @@ async function startDiscovery(opts) {
907
913
  if (onLink !== void 0) {
908
914
  const link = createPeerLink(socket, peer, buf);
909
915
  link.onMessage(() => {
910
- recordPeerMessage(peer.handle, stateDir);
916
+ recordPeerMessage(peer, stateDir);
911
917
  });
912
918
  onLink(link);
913
919
  }
@@ -29,7 +29,7 @@ import {
29
29
  signHelloClaims,
30
30
  startDiscovery,
31
31
  startRoom
32
- } from "./chunk-S7MO5OSO.js";
32
+ } from "./chunk-3FJDVN72.js";
33
33
 
34
34
  // src/mcp.ts
35
35
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
@@ -14959,6 +14959,21 @@ function createPairing() {
14959
14959
  return current;
14960
14960
  },
14961
14961
  add(link) {
14962
+ const isSamePeer = (a, b) => {
14963
+ if (a.hello.pubkey !== void 0 && b.hello.pubkey !== void 0) {
14964
+ return a.hello.pubkey === b.hello.pubkey;
14965
+ }
14966
+ return a.hello.handle === b.hello.handle;
14967
+ };
14968
+ const existingIdx = queue.findIndex((l) => isSamePeer(l, link));
14969
+ if (existingIdx >= 0) {
14970
+ const old = queue.splice(existingIdx, 1)[0];
14971
+ old.close();
14972
+ } else if (current !== void 0 && isSamePeer(current, link)) {
14973
+ const old = current;
14974
+ current = void 0;
14975
+ old.close();
14976
+ }
14962
14977
  watch(link);
14963
14978
  bindMessages(link);
14964
14979
  if (current === void 0) {
package/dist/cli.js CHANGED
@@ -10,7 +10,7 @@ import {
10
10
  stopDaemon,
11
11
  uninstallDaemonService,
12
12
  writeDaemonState
13
- } from "./chunk-JBADPOR5.js";
13
+ } from "./chunk-XUWNLMOY.js";
14
14
  import {
15
15
  CANDIDATES,
16
16
  LIVE_NOTICE,
@@ -46,7 +46,7 @@ import {
46
46
  signHelloClaims,
47
47
  startDiscovery,
48
48
  startRoom
49
- } from "./chunk-S7MO5OSO.js";
49
+ } from "./chunk-3FJDVN72.js";
50
50
 
51
51
  // src/cli.ts
52
52
  import readline from "readline";
@@ -2784,7 +2784,7 @@ async function handle(req, res, opts) {
2784
2784
  }
2785
2785
 
2786
2786
  // src/cli.ts
2787
- var VERSION = "0.8.2";
2787
+ var VERSION = "0.8.3";
2788
2788
  function parsePort(raw) {
2789
2789
  const n = Number(raw);
2790
2790
  if (!Number.isInteger(n) || n < 1 || n > 65535) return void 0;
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { UsageSnapshot, UsageSource, Harness, HarnessUsageOptions } from '@pooriaarab/vibe-core';
2
2
  export { Harness, UsageSnapshot, UsageSource, createConsentLedger } from '@pooriaarab/vibe-core';
3
- import { P as PeerHello, a as PeerLink } from './room-BStsMaeT.js';
4
- export { D as DiscoveryOptions, b as DiscoverySession, L as LIVE_NOTICE, R as ROOM_TOPIC_PREFIX, c as RoomMember, d as RoomMessage, e as RoomOptions, f as RoomSession, S as StoredPeer, T as TOPIC_PREFIX, l as leagueTopic, g as loadPeers, p as parseHandshake, r as recordPeer, h as recordPeerMessage, i as roomTopic, s as serializeHandshake, j as startDiscovery, k as startRoom } from './room-BStsMaeT.js';
3
+ import { P as PeerHello, a as PeerLink } from './room-DpZhNvuu.js';
4
+ export { D as DiscoveryOptions, b as DiscoverySession, L as LIVE_NOTICE, R as ROOM_TOPIC_PREFIX, c as RoomMember, d as RoomMessage, e as RoomOptions, f as RoomSession, S as StoredPeer, T as TOPIC_PREFIX, l as leagueTopic, g as loadPeers, p as parseHandshake, r as recordPeer, h as recordPeerMessage, i as roomTopic, s as serializeHandshake, j as startDiscovery, k as startRoom } from './room-DpZhNvuu.js';
5
5
  import { KeyObject } from 'node:crypto';
6
6
 
7
7
  /**
package/dist/index.js CHANGED
@@ -36,7 +36,7 @@ import {
36
36
  startDiscovery,
37
37
  startRoom,
38
38
  verifyHelloClaims
39
- } from "./chunk-S7MO5OSO.js";
39
+ } from "./chunk-3FJDVN72.js";
40
40
  export {
41
41
  BELOW_LEAGUE,
42
42
  CANDIDATES,
package/dist/mcp.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
- import { a as PeerLink, P as PeerHello, f as RoomSession, b as DiscoverySession, d as RoomMessage } from './room-BStsMaeT.js';
2
+ import { a as PeerLink, P as PeerHello, f as RoomSession, b as DiscoverySession, d as RoomMessage } from './room-DpZhNvuu.js';
3
3
  import '@pooriaarab/vibe-core';
4
4
 
5
5
  /**
package/dist/mcp.js CHANGED
@@ -3,8 +3,8 @@ import {
3
3
  createMcpServer,
4
4
  createSessionState,
5
5
  runMcp
6
- } from "./chunk-JBADPOR5.js";
7
- import "./chunk-S7MO5OSO.js";
6
+ } from "./chunk-XUWNLMOY.js";
7
+ import "./chunk-3FJDVN72.js";
8
8
  export {
9
9
  MCP_TOOL_NAMES,
10
10
  createMcpServer,
@@ -149,10 +149,10 @@ interface StoredPeer extends PeerHello {
149
149
  readonly lastMessageAt?: string;
150
150
  }
151
151
  /** Load persisted live peers, or `[]` if none/corrupt. Local-only data. */
152
- declare function loadPeers(dir?: string): StoredPeer[];
152
+ declare function loadPeers(dir?: string, maxAgeMs?: number): StoredPeer[];
153
153
  /**
154
- * Record a successfully handshaken peer, keyed by handle (a peer may reconnect
155
- * from a different key). Returns whether this handle is NEW (first time seen).
154
+ * Record a successfully handshaken peer, keyed by pubkey (if verified) or handle (legacy).
155
+ * Returns whether this peer is NEW (first time seen).
156
156
  */
157
157
  declare function recordPeer(hello: PeerHello, dir?: string, now?: Date): {
158
158
  peer: StoredPeer;
@@ -163,7 +163,7 @@ declare function recordPeer(hello: PeerHello, dir?: string, now?: Date): {
163
163
  * Local metadata only; never on the wire. Returns false when the handle isn't
164
164
  * a known peer. Never throws — best-effort bookkeeping.
165
165
  */
166
- declare function recordPeerMessage(handle: string, dir?: string, now?: Date): boolean;
166
+ declare function recordPeerMessage(peer: PeerHello, dir?: string, now?: Date): boolean;
167
167
  /** Injection point for the match notification (defaults to vibe-core notify). */
168
168
  type NotifySink = (event: VibeEvent) => void;
169
169
  interface DiscoveryOptions {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vibedate",
3
- "version": "0.8.2",
3
+ "version": "0.8.3",
4
4
  "description": "Dating by tokens — matched by usage league across agentic CLIs. Raw usage stays local; only your league is shared. CLI + local web app + MCP. Local-first.",
5
5
  "type": "module",
6
6
  "license": "MIT",