@johnhenry/browsermesh-core 0.11.0 → 0.11.1

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/README.md CHANGED
@@ -17,7 +17,7 @@ Identity, crypto, peer management, and trust primitives for BrowserMesh.
17
17
 
18
18
  ## Provenance
19
19
 
20
- Extracted from the private `clawser` monorepo (previously `packages/browsermesh-core`), where it was manually published to npm, unscoped, as `browsermesh-core@0.1.0` (2026-07-17) with no CI ever automating that publish. This is its first release as part of the `@johnhenry/browsermesh` monorepo; the version restarts at `0.0.0` per family convention.
20
+ Extracted from a private monorepo (previously `packages/browsermesh-core`), where it was manually published to npm, unscoped, as `browsermesh-core@0.1.0` (2026-07-17) with no CI ever automating that publish. This is its first release as part of the `@johnhenry/browsermesh` monorepo; the version restarts at `0.0.0` per family convention.
21
21
 
22
22
 
23
23
  ## Modules
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@johnhenry/browsermesh-core",
3
- "version": "0.11.0",
3
+ "version": "0.11.1",
4
4
  "description": "Identity, crypto, peer management, and trust primitives for BrowserMesh",
5
5
  "type": "module",
6
6
  "main": "./src/index.mjs",
package/src/acl.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
- // STATUS: INTEGRATED — wired into ClawserPod lifecycle, proven via E2E testing
3
- * clawser-mesh-acl.js -- Remote access control for BrowserMesh.
2
+ // STATUS: INTEGRATED — wired into Pod (@johnhenry/browsermesh-pod) lifecycle, proven via E2E testing
3
+ * acl.mjs -- Remote access control for BrowserMesh.
4
4
  *
5
5
  * ScopeTemplate bundles, roster management, invitation tokens, and
6
6
  * access checking. Wraps mesh-primitives ACLEngine with higher-level
@@ -9,7 +9,7 @@
9
9
  * No browser-only imports at module level.
10
10
  *
11
11
  * Run tests:
12
- * node --import ./web/test/_setup-globals.mjs --test web/test/clawser-mesh-acl.test.mjs
12
+ * cd packages/browsermesh-core && node --import ./test/_setup-globals.mjs --test test/acl.test.mjs
13
13
  */
14
14
 
15
15
  import {
@@ -1,6 +1,6 @@
1
1
  /**
2
- // STATUS: INTEGRATED — wired into ClawserPod lifecycle, proven via E2E testing
3
- * clawser-mesh-capabilities.js -- Capability Attenuation & WASM Sandbox.
2
+ // STATUS: INTEGRATED — wired into Pod (@johnhenry/browsermesh-pod) lifecycle, proven via E2E testing
3
+ * capabilities.mjs -- Capability Attenuation & WASM Sandbox.
4
4
  *
5
5
  * Implements the object-capability (ocap) model for BrowserMesh:
6
6
  *
@@ -14,7 +14,7 @@
14
14
  * No browser-only imports at module level.
15
15
  *
16
16
  * Run tests:
17
- * node --import ./web/test/_setup-globals.mjs --test web/test/clawser-mesh-capabilities.test.mjs
17
+ * cd packages/browsermesh-core && node --import ./test/_setup-globals.mjs --test test/capabilities.test.mjs
18
18
  */
19
19
 
20
20
  import { encodeBase64url, decodeBase64url } from '@johnhenry/browsermesh-primitives';
package/src/compat.mjs CHANGED
@@ -1,10 +1,11 @@
1
1
  /**
2
2
  * compat.mjs -- BrowserTool shim for standalone use.
3
3
  *
4
- * In clawser, BrowserTool is the base class for AI-agent-callable tools.
4
+ * In the host application, BrowserTool is the base class for
5
+ * AI-agent-callable tools.
5
6
  * Subclasses override name/description/parameters/permission as GETTERS
6
- * (not constructor-assigned properties) — this shim mirrors that exactly
7
- * (see web/clawser-tools.js). An earlier version of this shim tried to
7
+ * (not constructor-assigned properties) — this shim mirrors that exactly.
8
+ * An earlier version of this shim tried to
8
9
  * assign `this.name = ...` in the constructor, which threw
9
10
  * "Cannot set property name of #<Tool> which has only a getter" for
10
11
  * every real subclass, since none of them define a setter.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * clawser-mesh-group-keys.js -- Symmetric group encryption for multi-party sessions.
2
+ * group-keys.mjs -- Symmetric group encryption for multi-party sessions.
3
3
  *
4
4
  * Epoch-based key rotation with AES-GCM-256. Forward secrecy on member removal
5
5
  * by generating a new epoch key and distributing it only to remaining members.
@@ -10,7 +10,7 @@
10
10
  * No browser-only imports at module level.
11
11
  *
12
12
  * Run tests:
13
- * node --import ./web/test/_setup-globals.mjs --test web/test/clawser-mesh-group-keys.test.mjs
13
+ * cd packages/browsermesh-core && node --import ./test/_setup-globals.mjs --test test/group-keys.test.mjs
14
14
  */
15
15
 
16
16
  import { padTo, unpad } from '@johnhenry/browsermesh-primitives'
package/src/handshake.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { silentCatch } from './silent-catch.mjs'
2
2
  /**
3
- // STATUS: INTEGRATED — wired into ClawserPod lifecycle, proven via E2E testing
4
- * clawser-mesh-handshake.js -- Connection Handshake Protocol.
3
+ // STATUS: INTEGRATED — wired into Pod (@johnhenry/browsermesh-pod) lifecycle, proven via E2E testing
4
+ * handshake.mjs -- Connection Handshake Protocol.
5
5
  *
6
6
  * Coordinates signaling, direct input exchange (QR + clipboard), and
7
7
  * session establishment between two mesh peers.
@@ -22,7 +22,7 @@ import { silentCatch } from './silent-catch.mjs'
22
22
  * via constructor.
23
23
  *
24
24
  * Run tests:
25
- * node --import ./web/test/_setup-globals.mjs --test web/test/clawser-mesh-handshake.test.mjs
25
+ * cd packages/browsermesh-core && node --import ./test/_setup-globals.mjs --test test/handshake.test.mjs
26
26
  */
27
27
 
28
28
  // ---------------------------------------------------------------------------
@@ -240,7 +240,7 @@ export class SignalingClient {
240
240
  this.#ws.removeEventListener('message', this.#handleMessage)
241
241
  this.#ws.removeEventListener('close', this.#handleClose)
242
242
  this.#ws.close()
243
- } catch (e) { silentCatch('clawser-mesh-handshake', 'ignore-close-errors', e) }
243
+ } catch (e) { silentCatch('handshake', 'ignore-close-errors', e) }
244
244
  this.#ws = null
245
245
  this.#onLog(2, 'SignalingClient disconnected')
246
246
  }
@@ -370,7 +370,7 @@ export class SignalingClient {
370
370
  const data = typeof ev.data === 'string' ? JSON.parse(ev.data) : ev.data
371
371
  if (!data || !data.type) return
372
372
  this.#fire(data.type, data)
373
- } catch (e) { silentCatch('clawser-mesh-handshake', 'ignore-malformed-messages', e) }
373
+ } catch (e) { silentCatch('handshake', 'ignore-malformed-messages', e) }
374
374
  }
375
375
 
376
376
  /** @type {() => void} */
@@ -398,7 +398,7 @@ export class SignalingClient {
398
398
  // direct server messages (e.g. `registered`) that have no `source`.
399
399
  const fromPodId = data.source ?? data.from
400
400
  for (const cb of set) {
401
- try { cb(data, fromPodId) } catch (e) { silentCatch('clawser-mesh-handshake', 'swallow-listener-errors', e) }
401
+ try { cb(data, fromPodId) } catch (e) { silentCatch('handshake', 'swallow-listener-errors', e) }
402
402
  }
403
403
  }
404
404
  }
@@ -1256,7 +1256,7 @@ export class HandshakeCoordinator {
1256
1256
  const set = this.#listeners.get(event)
1257
1257
  if (!set) return
1258
1258
  for (const cb of set) {
1259
- try { cb(data) } catch (e) { silentCatch('clawser-mesh-handshake', 'swallow-listener-errors', e) }
1259
+ try { cb(data) } catch (e) { silentCatch('handshake', 'swallow-listener-errors', e) }
1260
1260
  }
1261
1261
  }
1262
1262
  }
package/src/hardening.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { silentCatch } from './silent-catch.mjs'
2
2
  /**
3
3
  // STATUS: EXPERIMENTAL — production hardening for BrowserMesh transports
4
- * clawser-mesh-hardening.js -- Production Hardening Layer.
4
+ * hardening.mjs -- Production Hardening Layer.
5
5
  *
6
6
  * Additive hardening primitives that compose with existing MeshTransport
7
7
  * and MeshTransportNegotiator without breaking backward compatibility.
@@ -14,7 +14,7 @@ import { silentCatch } from './silent-catch.mjs'
14
14
  * 5. TransportFailover — graceful degradation across transport types
15
15
  *
16
16
  * Run tests:
17
- * node --import ./web/test/_setup-globals.mjs --test web/test/clawser-mesh-hardening.test.mjs
17
+ * cd packages/browsermesh-core && node --import ./test/_setup-globals.mjs --test test/hardening.test.mjs
18
18
  */
19
19
 
20
20
  // ---------------------------------------------------------------------------
@@ -463,7 +463,7 @@ export class TransportHealthCheck {
463
463
  const set = this.#listeners.get(event);
464
464
  if (!set) return;
465
465
  for (const cb of [...set]) {
466
- try { cb(data); } catch (e) { silentCatch('clawser-mesh-hardening', 'swallow', e) }
466
+ try { cb(data); } catch (e) { silentCatch('hardening', 'swallow', e) }
467
467
  }
468
468
  }
469
469
  }
@@ -563,7 +563,7 @@ export class ConnectionPool {
563
563
 
564
564
  const evicted = entries.splice(idleIdx, 1)[0];
565
565
  if (typeof evicted.transport.close === 'function') {
566
- try { evicted.transport.close(); } catch (e) { silentCatch('clawser-mesh-hardening', 'evicted.transport.close', e) }
566
+ try { evicted.transport.close(); } catch (e) { silentCatch('hardening', 'evicted.transport.close', e) }
567
567
  }
568
568
  }
569
569
 
@@ -713,7 +713,7 @@ export class ConnectionPool {
713
713
  const entry = entries[i];
714
714
  if (!entry.acquired && (now - entry.lastUsed) > this.#idleTimeoutMs) {
715
715
  if (typeof entry.transport.close === 'function') {
716
- try { entry.transport.close(); } catch (e) { silentCatch('clawser-mesh-hardening', 'entry.transport.close', e) }
716
+ try { entry.transport.close(); } catch (e) { silentCatch('hardening', 'entry.transport.close', e) }
717
717
  }
718
718
  entries.splice(i, 1);
719
719
  evicted++;
@@ -734,7 +734,7 @@ export class ConnectionPool {
734
734
  for (const [, entries] of this.#pools) {
735
735
  for (const entry of entries) {
736
736
  if (typeof entry.transport.close === 'function') {
737
- try { entry.transport.close(); } catch (e) { silentCatch('clawser-mesh-hardening', 'entry.transport.close', e) }
737
+ try { entry.transport.close(); } catch (e) { silentCatch('hardening', 'entry.transport.close', e) }
738
738
  }
739
739
  }
740
740
  }
@@ -1119,7 +1119,7 @@ export class TransportFailover {
1119
1119
  }
1120
1120
  // Close the old transport
1121
1121
  if (typeof this.#activeTransport.close === 'function') {
1122
- try { this.#activeTransport.close(); } catch (e) { silentCatch('clawser-mesh-hardening', 'this', e) }
1122
+ try { this.#activeTransport.close(); } catch (e) { silentCatch('hardening', 'this', e) }
1123
1123
  }
1124
1124
  this.#activeTransport = null;
1125
1125
  }
@@ -1207,7 +1207,7 @@ export class TransportFailover {
1207
1207
  const set = this.#listeners.get(event);
1208
1208
  if (!set) return;
1209
1209
  for (const cb of [...set]) {
1210
- try { cb(data); } catch (e) { silentCatch('clawser-mesh-hardening', 'swallow', e) }
1210
+ try { cb(data); } catch (e) { silentCatch('hardening', 'swallow', e) }
1211
1211
  }
1212
1212
  }
1213
1213
  }
@@ -1,4 +1,4 @@
1
- // clawser-identity.js — Agent Identity System (AIEOS v1.1)
1
+ // identity-base.mjs — Agent Identity System (AIEOS v1.1)
2
2
  //
3
3
  // Supports three identity formats:
4
4
  // - plain: single system prompt string
@@ -1,11 +1,11 @@
1
1
  /**
2
- * clawser-mesh-identity-tools.js -- Identity BrowserTools for mesh.
2
+ * identity-tools.mjs -- Identity BrowserTools for mesh.
3
3
  *
4
4
  * 8 BrowserTool subclasses for managing mesh identities via the agent.
5
- * Follows the pattern in clawser-mesh-tools.js.
5
+ * Follows the pattern in peer-tools.mjs.
6
6
  *
7
7
  * Run tests:
8
- * node --import ./web/test/_setup-globals.mjs --test web/test/clawser-mesh-identity-tools.test.mjs
8
+ * cd packages/browsermesh-core && node --import ./test/_setup-globals.mjs --test test/identity-tools.test.mjs
9
9
  */
10
10
 
11
11
  import { BrowserTool } from './compat.mjs';
@@ -1,5 +1,5 @@
1
1
  /**
2
- * clawser-identity-wallet.js -- High-level multi-identity wallet.
2
+ * identity-wallet.mjs -- High-level multi-identity wallet.
3
3
  *
4
4
  * Wraps MeshIdentityManager and IdentitySelector to provide a unified
5
5
  * API for identity lifecycle, contact management, and access grants.
@@ -7,7 +7,7 @@
7
7
  * No browser-only imports at module level.
8
8
  *
9
9
  * Run tests:
10
- * node --import ./web/test/_setup-globals.mjs --test web/test/clawser-identity-wallet.test.mjs
10
+ * cd packages/browsermesh-core && node --import ./test/_setup-globals.mjs --test test/identity-wallet.test.mjs
11
11
  */
12
12
 
13
13
  // ---------------------------------------------------------------------------
package/src/identity.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * clawser-mesh-identity.js -- Mesh identity management.
2
+ * identity.mjs -- Mesh identity management.
3
3
  *
4
4
  * Manages multiple Ed25519 cryptographic identities with vault-encrypted
5
5
  * storage. Imports primitives from mesh-primitives; adds persistence,
@@ -9,7 +9,7 @@
9
9
  * Storage adapter pattern allows OPFS in browser, in-memory in tests.
10
10
  *
11
11
  * Run tests:
12
- * node --import ./web/test/_setup-globals.mjs --test web/test/clawser-mesh-identity.test.mjs
12
+ * cd packages/browsermesh-core && node --import ./test/_setup-globals.mjs --test test/identity.test.mjs
13
13
  */
14
14
 
15
15
  import { silentCatch } from './silent-catch.mjs'
@@ -1000,7 +1000,7 @@ export class VaultIdentityStorage {
1000
1000
  encryptedPrivateKey: await encryptWithPassphrase(plaintext, passphrase, VAULT_TYPE),
1001
1001
  });
1002
1002
  } catch (err) {
1003
- silentCatch('clawser-mesh-identity', 'vault-upgrade', err);
1003
+ silentCatch('identity', 'vault-upgrade', err);
1004
1004
  }
1005
1005
  }
1006
1006
  }
@@ -1145,7 +1145,7 @@ export class IdentitySyncCoordinator {
1145
1145
 
1146
1146
  if (msg.type === 'created' || msg.type === 'deleted') {
1147
1147
  for (const cb of this.#changeListeners) {
1148
- try { cb(msg); } catch (e) { silentCatch('clawser-mesh-identity', 'swallow', e) }
1148
+ try { cb(msg); } catch (e) { silentCatch('identity', 'swallow', e) }
1149
1149
  }
1150
1150
  }
1151
1151
  }
@@ -1257,7 +1257,7 @@ export class AutoIdentityManager {
1257
1257
  this.#identityManager.setDefault(podId);
1258
1258
 
1259
1259
  for (const cb of this.#switchListeners) {
1260
- try { cb({ oldId, newId: podId }); } catch (e) { silentCatch('clawser-mesh-identity', 'swallow', e) }
1260
+ try { cb({ oldId, newId: podId }); } catch (e) { silentCatch('identity', 'swallow', e) }
1261
1261
  }
1262
1262
  }
1263
1263
 
package/src/keyring.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * clawser-mesh-keyring.js -- Key hierarchy and linking.
2
+ * keyring.mjs -- Key hierarchy and linking.
3
3
  *
4
4
  * Manages parent-child relationships between mesh identities
5
5
  * (device, delegate, org, alias, recovery). Provides chain
@@ -1,11 +1,11 @@
1
1
  /**
2
- * clawser-mesh-peer-tools.js — BrowserTool subclasses for mesh peer subsystems
2
+ * peer-tools.mjs — BrowserTool subclasses for mesh peer subsystems
3
3
  *
4
4
  * Exposes chat, compute, scheduling, health, escrow, routing, timestamp,
5
5
  * stealth, delta-sync, gateway, torrent, IPFS, ACL, and capability tools
6
6
  * to the AI agent.
7
7
  *
8
- * @module clawser-mesh-peer-tools
8
+ * @module peer-tools
9
9
  */
10
10
 
11
11
  import { BrowserTool } from './compat.mjs'
package/src/peer.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  // STATUS: EXPERIMENTAL — complete implementation, not yet integrated into main application
3
- * clawser-mesh-peer.js -- Peer Connection Manager.
3
+ * peer.mjs -- Peer Connection Manager.
4
4
  *
5
5
  * Discovers, connects to, and maintains connections with mesh peers.
6
6
  * Does not handle the actual transport -- delegates to MeshTransportManager.
@@ -8,7 +8,7 @@
8
8
  * Peer status lifecycle: disconnected -> connecting -> connected -> authenticated
9
9
  *
10
10
  * Run tests:
11
- * node --import ./web/test/_setup-globals.mjs --test web/test/clawser-mesh-peer.test.mjs
11
+ * cd packages/browsermesh-core && node --import ./test/_setup-globals.mjs --test test/peer.test.mjs
12
12
  */
13
13
 
14
14
  // ---------------------------------------------------------------------------
@@ -2,31 +2,43 @@
2
2
  * silent-catch.mjs — debug-gated structured logger for the
3
3
  * `try { … } catch { /* ignore *\/ }` pattern.
4
4
  *
5
- * Vendored from clawser-silent-catch.mjs (fully standalone, no other
6
- * clawser-app imports) so this package doesn't need to reach into web/.
5
+ * Standalone module (no other imports) so this package is self-contained.
7
6
  *
8
7
  * Replaces silent catches with an opt-in inspectable record. Default
9
8
  * behaviour is unchanged (silent), so this is a drop-in replacement.
10
9
  * Users surface the events by enabling debug mode:
11
10
  *
12
- * localStorage.setItem('clawser_debug', 'true') // persistent
13
- * // or, in DevTools: clawserDebug.enable()
11
+ * localStorage.setItem('browsermesh_debug', 'true') // persistent
12
+ * // or, in DevTools: browsermeshDebug.enable()
13
+ *
14
+ * The old `clawser_debug` localStorage key and `clawserDebug` global are
15
+ * deprecated aliases, kept for compatibility.
14
16
  */
15
17
 
18
+ /** localStorage key that enables debug mode. */
19
+ const DEBUG_KEY = 'browsermesh_debug';
20
+ /** Deprecated alias for DEBUG_KEY, kept for compatibility. */
21
+ const LEGACY_DEBUG_KEY = 'clawser_debug';
22
+
23
+ function readDebugFlag() {
24
+ return localStorage.getItem(DEBUG_KEY) === 'true'
25
+ || localStorage.getItem(LEGACY_DEBUG_KEY) === 'true';
26
+ }
27
+
16
28
  let enabled = false;
17
29
  try {
18
30
  if (typeof localStorage !== 'undefined') {
19
- enabled = localStorage.getItem('clawser_debug') === 'true';
31
+ enabled = readDebugFlag();
20
32
  }
21
33
  } catch {
22
34
  // localStorage may throw in privacy / sandbox contexts — treat as disabled
23
35
  }
24
36
 
25
- /** Re-check the localStorage flag; called by clawserDebug.enable/disable. */
37
+ /** Re-check the localStorage flag; called by browsermeshDebug.enable/disable. */
26
38
  export function refreshSilentCatchState() {
27
39
  try {
28
40
  if (typeof localStorage !== 'undefined') {
29
- enabled = localStorage.getItem('clawser_debug') === 'true';
41
+ enabled = readDebugFlag();
30
42
  }
31
43
  } catch {
32
44
  enabled = false;
@@ -36,7 +48,7 @@ export function refreshSilentCatchState() {
36
48
  /**
37
49
  * Log a silent-catch event. No-op unless debug mode is enabled.
38
50
  *
39
- * @param {string} module — file/component (e.g. 'clawser-pod')
51
+ * @param {string} module — file/component (e.g. 'pod')
40
52
  * @param {string} operation — what was attempted (e.g. 'relay-disconnect')
41
53
  * @param {*} error — the caught value
42
54
  * @param {object} [context] — extra structured fields
@@ -51,5 +63,5 @@ export function silentCatch(module, operation, error, context) {
51
63
  }
52
64
  const entry = { module, operation, error: error?.message || String(error) };
53
65
  if (context) Object.assign(entry, context);
54
- console.warn('[clawser:silent-catch]', entry);
66
+ console.warn('[browsermesh:silent-catch]', entry);
55
67
  }
package/src/trust.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * clawser-mesh-trust.js -- Trust graph management.
2
+ * trust.mjs -- Trust graph management.
3
3
  *
4
4
  * Float [0.0, 1.0] trust with multiplicative transitive decay,
5
5
  * scope intersection, and reputation aggregation.
@@ -11,7 +11,7 @@
11
11
  * No browser-only imports at module level.
12
12
  *
13
13
  * Run tests:
14
- * node --import ./web/test/_setup-globals.mjs --test web/test/clawser-mesh-trust.test.mjs
14
+ * cd packages/browsermesh-core && node --import ./test/_setup-globals.mjs --test test/trust.test.mjs
15
15
  */
16
16
 
17
17
  import {