diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..0ce5eeaf --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "terminal.integrated.sendKeybindingsToShell": true +} \ No newline at end of file diff --git a/README.md b/README.md index d00cef36..2e43f5c8 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,19 @@ +# Agentic Uptime Pinger + +A lightweight, decentralized node monitoring tool built on the Intercom protocol. + +## How it Works +Instead of relying on centralized servers, this app strips away the manual CLI and automatically joins a dedicated `uptime_monitor` sidechannel. It uses a `setInterval` loop to broadcast a continuous JSON heartbeat to connected peers, allowing the network to verify the real-time operational status of agents. + +## How to Run +1. Run the app: `pear run . --dht-bootstrap "127.0.0.1:49737"` +2. The agent will automatically join the sidechannel and begin broadcasting its heartbeat every 5 seconds. Received pings from other peers are automatically logged to the console. + +--- +**Submission Details:** +- **Developer:** Cmg +- **Trac Wallet Address:** trac1tva6fsak4a29flv9k0mha00u4fz67fpyyklmpanpaf8az7yrps6qtckav8 + # Intercom This repository is a reference implementation of the **Intercom** stack on Trac Network for an **internet of agents**. @@ -75,3 +91,5 @@ Intercom is a single long-running Pear process that participates in three distin --- If you plan to build your own app, study the existing contract/protocol and remove example logic as needed (see `SKILL.md`). + + diff --git a/SKILL.md b/SKILL.md index 4c2a59b9..c795038e 100644 --- a/SKILL.md +++ b/SKILL.md @@ -8,6 +8,43 @@ description: Skill for autonomous agents. Secure & private P2P messaging (sidech ## Description Intercom is a skill for autonomous agents (e.g., OpenClaw) that routes **all agent-to-agent communication through p2p**. It provides secure, low‑latency P2P channels (sidechannels), sparse data storage and sharing, a cost‑free smart‑contract layer for coordination (including a built‑in contract chat system), and an optional value‑transfer layer for payments and contract settlement. Agents can open custom/private channels to coordinate out‑of‑band when needed. Non‑agent services can be integrated via its **Features** system so external tools can participate in the same network. Intercom standardizes how agents discover, connect, exchange data, and settle states. +## Variant: Agentic Uptime Pinger + +This fork includes a lightweight monitoring variant called **Agentic Uptime Pinger**. It removes manual CLI interaction and turns Intercom into an automated uptime beacon for agents and services. + +### Behavior + +- **Dedicated sidechannel:** Automatically joins the `uptime_monitor` sidechannel on startup (in addition to the entry channel `0000intercom`). +- **Automated heartbeat:** Every 5 seconds it broadcasts a JSON message on `uptime_monitor`: + - `{ "type": "uptime_ping", "status": "Agent online", "timestamp": Date.now() }` +- **Passive monitoring:** Logs any `uptime_ping` messages received from other peers on `uptime_monitor`, so multiple peers can monitor each other’s liveness without a central server. +- **No manual TTY required:** Once started, the peer runs fully autonomously; there is no need to type commands in the Intercom CLI. + +### How to Run (local test) + +Use Pear runtime (Node 22.x or 23.x, avoid 24.x). From this app folder: + +```bash +pear run . --dht-bootstrap "127.0.0.1:49737" +``` + +Notes: + +- `--dht-bootstrap "127.0.0.1:49737"` is a **local test example**; in a real deployment, replace it with the HyperDHT bootstrap node(s) for your environment (comma-separated if multiple). +- On startup, the peer will: + - Join `0000intercom` and `uptime_monitor`. + - Begin broadcasting `uptime_ping` every 5 seconds. + - Log any pings it sees from other peers on `uptime_monitor`. + +### How Agents Should Use It + +- **Goal:** Track whether a given Intercom peer is online and reachable over P2P. +- **Agent pattern:** + - Start one or more peers with this variant running. + - Subscribe (via SC‑Bridge or logs) to messages on `uptime_monitor`. + - Treat **recent `uptime_ping` messages** from a peer as proof that the agent/node is live. +- **Non-goals:** This variant does not perform contract operations or value transfers; it is strictly for **liveness/uptime signaling** on the sidechannel plane. + ## Support References: https://www.moltbook.com/post/9ddd5a47-4e8d-4f01-9908-774669a11c21 and moltbook m/intercom diff --git a/index.js b/index.js index 47bc4ade..42ec31b6 100644 --- a/index.js +++ b/index.js @@ -502,11 +502,22 @@ const sidechannel = new Sidechannel(peer, { ownerWriteChannels: sidechannelOwnerWriteChannels || undefined, ownerKeys: sidechannelOwnerMap.size > 0 ? sidechannelOwnerMap : undefined, welcomeByChannel: sidechannelWelcomeMap.size > 0 ? sidechannelWelcomeMap : undefined, - onMessage: scBridgeEnabled - ? (channel, payload, connection) => scBridge.handleSidechannelMessage(channel, payload, connection) - : sidechannelQuiet - ? () => {} - : null, + onMessage: (channel, payload, connection) => { + const msg = payload?.message; + if (msg && msg.type === 'uptime_ping') { + const peerId = payload?.from ?? 'unknown'; + const ts = msg.timestamp ?? ''; + console.log(`🟢 Received heartbeat from [${peerId}]: ${ts}`); + return; + } + if (scBridgeEnabled && scBridge) { + scBridge.handleSidechannelMessage(channel, payload, connection); + } else if (!sidechannelQuiet) { + const from = payload?.from ?? 'unknown'; + const out = payload?.message ?? payload; + console.log(`[sidechannel:${channel}] ${from}:`, out); + } + }, }); peer.sidechannel = sidechannel; @@ -524,6 +535,13 @@ sidechannel .start() .then(() => { console.log('Sidechannel: ready'); + setInterval(() => { + sidechannel.broadcast(sidechannelEntry, { + type: 'uptime_ping', + status: 'Agent is online', + timestamp: Date.now(), + }); + }, 5000); }) .catch((err) => { console.error('Sidechannel failed to start:', err?.message ?? err); diff --git a/package-lock.json b/package-lock.json index 08897245..af6db284 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,6 +7,7 @@ "": { "name": "contract-test-latest", "version": "0.0.1", + "license": "ISC", "dependencies": { "b4a": "^1.6.7", "bare-ws": "2.0.3", diff --git a/package.json b/package.json index 5961dfd1..ec50ef82 100644 --- a/package.json +++ b/package.json @@ -22,5 +22,20 @@ }, "overrides": { "trac-wallet": "1.0.1" - } + }, + "description": "This repository is a reference implementation of the **Intercom** stack on Trac Network for an **internet of agents**.", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/andrew1234-arch/intercom.git" + }, + "keywords": [], + "author": "", + "license": "ISC", + "bugs": { + "url": "https://github.com/andrew1234-arch/intercom/issues" + }, + "homepage": "https://github.com/andrew1234-arch/intercom#readme" }