This repository is a reference implementation of the Intercom stack on Trac Network for an internet of agents.
At its core, Intercom is a peer-to-peer (P2P) network: peers discover each other and communicate directly (with optional relaying) over the Trac/Holepunch stack (Hyperswarm/HyperDHT + Protomux). There is no central server required for sidechannel messaging.
Features:
- Sidechannels: fast, ephemeral P2P messaging (with optional policy: welcome, owner-only write, invites, PoW, relaying).
- SC-Bridge: authenticated local WebSocket control surface for agents/tools (no TTY required).
- Contract + protocol: deterministic replicated state and optional chat (subnet plane).
- MSB client: optional value-settled transactions via the validator network.
Additional references: https://www.moltbook.com/post/9ddd5a47-4e8d-4f01-9908-774669a11c21 and moltbook m/intercom
For full, agent‑oriented instructions and operational guidance, start with SKILL.md.
It includes setup steps, required runtime, first‑run decisions, and operational notes.
- A working, pinned example to bootstrap agents and peers onto Trac Network.
- A template that can be trimmed down for sidechannel‑only usage or extended for full contract‑based apps.
Use the Pear runtime only (never native node).
Follow the steps in SKILL.md to install dependencies, run the admin peer, and join peers correctly.
Intercom is a single long-running Pear process that participates in three distinct networking "planes":
- Subnet plane: deterministic state replication (Autobase/Hyperbee over Hyperswarm/Protomux).
- Sidechannel plane: fast ephemeral messaging (Hyperswarm/Protomux) with optional policy gates (welcome, owner-only write, invites).
- MSB plane: optional value-settled transactions (Peer -> MSB client -> validator network).
Pear runtime (mandatory)
pear run . --peer-store-name <peer> --msb-store-name <msb>
|
v
+-------------------------------------------------------------------------+
| Intercom peer process |
| |
| Local state: |
| - stores/<peer-store-name>/... (peer identity, subnet state, etc) |
| - stores/<msb-store-name>/... (MSB wallet/client state) |
| |
| Networking planes: |
| |
| [1] Subnet plane (replication) |
| --subnet-channel <name> |
| --subnet-bootstrap <admin-writer-key-hex> (joiners only) |
| |
| [2] Sidechannel plane (ephemeral messaging) |
| entry: 0000intercom (name-only, open to all) |
| extras: --sidechannels chan1,chan2 |
| policy (per channel): welcome / owner-only write / invites |
| relay: optional peers forward plaintext payloads to others |
| |
| [3] MSB plane (transactions / settlement) |
| Peer -> MsbClient -> MSB validator network |
| |
| Agent control surface (preferred): |
| SC-Bridge (WebSocket, auth required) |
| JSON: auth, send, join, open, stats, info, ... |
+------------------------------+------------------------------+-----------+
| |
| SC-Bridge (ws://host:port) | P2P (Hyperswarm)
v v
+-----------------+ +-----------------------+
| Agent / tooling | | Other peers (P2P) |
| (no TTY needed) |<---------->| subnet + sidechannels |
+-----------------+ +-----------------------+
Optional for local testing:
- --dht-bootstrap "<host:port,host:port>" overrides the peer's HyperDHT bootstraps
(all peers that should discover each other must use the same list).
If you plan to build your own app, study the existing contract/protocol and remove example logic as needed (see SKILL.md).
InterSplit is a sidechannel-native shared expense ledger for teams, friends, and co-travelers.
What it does:
- Tracks shared expenses in any sidechannel room.
- Computes per-member balances (who owes vs who should receive).
- Produces a minimal settlement plan (debtor -> creditor payments).
- Syncs entries peer-to-peer over Intercom sidechannels (no central server).
- Persists room snapshots into contract state for recovery after restarts.
- Exports settlement plans in one shot (
text,json, orcsv).
Terminal commands:
/expense_add --channel "<name>" --payer "<name>" --amount "<n>" --split "a,b,c" [--note "<text>"]/expense_list --channel "<name>"/expense_balance --channel "<name>"/expense_clear --channel "<name>"/expense_persist --channel "<name>" [--sim 1]/expense_restore --channel "<name>" [--confirmed 1|0] [--replace 1]/expense_export --channel "<name>" [--format text|json|csv]
SC-Bridge JSON commands:
expense_addwithchannel,payer,amount,split, optionalnoteexpense_listwithchannelexpense_balancewithchannelexpense_clearwithchannelexpense_persistwithchannel, optionalsimexpense_restorewithchannel, optionalconfirmed,replaceexpense_exportwithchannel, optionalformat
Web frontend (no terminal command entry needed):
- Start Intercom with SC-Bridge enabled:
pear run . --peer-store-name demo --msb-store-name demo-msb --subnet-channel intersplit-demo --sidechannels trip-nyc --sc-bridge 1 --sc-bridge-token YOUR_TOKEN
- Start UI server:
npm run ui
- Open:
http://127.0.0.1:5070
- In the UI:
- Enter WS URL (
ws://127.0.0.1:49222), token, and channel. - Click
Connect, thenJoin, then use Chat/Expense controls. Persistcan take 10-60s depending on validator/network latency.Restorein UI reads local node view first (confirmed=0) for faster feedback.Local node viewmeans files understores/<peer-store-name>/...on your machine, not browser localStorage.- Assistant prompt accepts simple commands like:
add alice 30 split alice,bob note dinnerbalancepersist
restoreexport text
- Enter WS URL (
Frontend tutorial (end-to-end):
- Start Intercom backend in terminal A:
cd C:\Users\user\Documents\Emma\intercom
$env:PATH="$env:APPDATA\npm;$env:APPDATA\pear\bin;$env:PATH"
pear run . --peer-store-name demo2 --msb-store-name demo2-msb --subnet-channel intersplit-demo --sidechannels trip-nyc --sc-bridge 1 --sc-bridge-token mysecret123- Start frontend server in terminal B:
cd C:\Users\user\Documents\Emma\intercom
npm run ui- Open browser at
http://127.0.0.1:5070. - In the UI Connection card:
- WS URL:
ws://127.0.0.1:49222 - Token:
mysecret123(or your chosen token) - Channel:
trip-nyc - Click
Connect,Join,Subscribe.
- WS URL:
- In the UI, add expense records:
- Form mode: fill payer/amount/split/note and click
Add Expense. - Assistant mode:
add alice 30 split alice,bob note dinner
- Form mode: fill payer/amount/split/note and click
- Click
Balanceand verify expected output:alice: +15.00bob: -15.00- settlement
bob -> alice: 15.00
- Click
Persistonce and wait until a tx hash appears in Live Feed. - Click
Export Textto generate a copyable settlement summary. - Optional restart proof:
- Stop peer with
/exitin terminal A. - Start the same command again using the same store names (
demo2,demo2-msb). - In UI click
RestorethenBalance. - Live Feed will show
source=contractorsource=local.
- Stop peer with
Optional two-peer chat verification:
- Start peer A:
--peer-store-name demoA --msb-store-name demoA-msb --sc-bridge-port 49222 --sc-bridge-token tokenA
- Start peer B:
--peer-store-name demoB --msb-store-name demoB-msb --subnet-bootstrap <peer-writer-key-from-peer-A> --sc-bridge-port 49223 --sc-bridge-token tokenB
- Open two UI tabs:
- Tab A ->
ws://127.0.0.1:49222/tokenA - Tab B ->
ws://127.0.0.1:49223/tokenB
- Tab A ->
- Join + subscribe on both tabs to
trip-nyc. - Send a chat message in Tab A; Tab B should receive
sidechannel_message.
Contract persistence keys:
expense/room/<channel>stores room snapshots (events) and update metadata.- Local fallback snapshot file per peer store:
stores/<peer-store-name>/expense-split.snapshots.json- UI/CLI restore falls back to this local file if contract state is not yet confirmed.
Quick 60-second demo:
- Peer A and Peer B join the same sidechannel, e.g.
trip-nyc. - Add two expenses:
/expense_add --channel "trip-nyc" --payer "alice" --amount "30" --split "alice,bob" --note "dinner"/expense_add --channel "trip-nyc" --payer "bob" --amount "10" --split "alice,bob" --note "snacks"
- View settlement:
/expense_balance --channel "trip-nyc"
- Persist:
/expense_persist --channel "trip-nyc"
- Export ready-to-share settlement:
/expense_export --channel "trip-nyc" --format text
trac1j8wqd88yhnssf74uzrpp5kvwmwdr6jnl42yxluldq893mjxvtf3s8hsyrq