peerband 0.2.0 → 0.2.2
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 +64 -4
- package/dist/peerband.mjs +72 -11
- package/herdr-plugin.toml +1 -1
- package/package.json +1 -1
- package/protocol/README.md +2 -0
package/README.md
CHANGED
|
@@ -1,13 +1,48 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://peerband.com">
|
|
3
|
+
<picture>
|
|
4
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/kshvidler/peerband-cli/main/docs/assets/peerband-logo-dark.svg">
|
|
5
|
+
<img src="https://raw.githubusercontent.com/kshvidler/peerband-cli/main/docs/assets/peerband-logo.svg" alt="PeerBand" width="72" height="72">
|
|
6
|
+
</picture>
|
|
7
|
+
</a>
|
|
8
|
+
</p>
|
|
2
9
|
|
|
3
|
-
|
|
10
|
+
<h1 align="center">PeerBand</h1>
|
|
11
|
+
|
|
12
|
+
<p align="center"><strong>A direct line to your local AI agents.</strong></p>
|
|
13
|
+
|
|
14
|
+
<p align="center">
|
|
15
|
+
<a href="https://www.npmjs.com/package/peerband"><img src="https://img.shields.io/npm/v/peerband?color=111&label=npm" alt="npm version"></a>
|
|
16
|
+
<a href="LICENSE"><img src="https://img.shields.io/badge/license-Apache--2.0-111" alt="Apache-2.0 license"></a>
|
|
17
|
+
<img src="https://img.shields.io/badge/node-%E2%89%A522.13-111" alt="Node.js 22.13 or newer">
|
|
18
|
+
</p>
|
|
19
|
+
|
|
20
|
+
<p align="center">
|
|
21
|
+
<a href="https://peerband.com">Website</a> ·
|
|
22
|
+
<a href="https://peerband.com/guide">Guide</a> ·
|
|
23
|
+
<a href="https://peerband.com/docs">Docs</a> ·
|
|
24
|
+
<a href="https://peerband.com/dashboard">Dashboard</a>
|
|
25
|
+
</p>
|
|
26
|
+
|
|
27
|
+
PeerBand connects ChatGPT, Claude or any MCP client to the coding agents (Claude Code, Codex, Gemini CLI, OpenCode and others) running in [Herdr](https://herdr.dev) on your machine. Ask what they're doing, send the next instruction, share access with a teammate, and get a note in Slack, Discord or your own endpoint when an agent needs you.
|
|
28
|
+
|
|
29
|
+
This repository is the open-source client: the `peerband` command-line tool and the Herdr plugin. It runs on your machine and connects out to the PeerBand relay; nothing connects in.
|
|
4
30
|
|
|
5
31
|
```
|
|
6
32
|
MCP client --> PeerBand relay <== outbound WebSocket == peerband connector --> Herdr
|
|
7
|
-
(
|
|
33
|
+
(ChatGPT, Claude) (peerband.com) (on your machine) (your agents)
|
|
8
34
|
```
|
|
9
35
|
|
|
10
|
-
|
|
36
|
+
## What you can do
|
|
37
|
+
|
|
38
|
+
- **Check in from anywhere.** Add one URL to ChatGPT, Claude or Claude Code and ask what your agents are doing. Your client lists agents and reads their status and bounded recent output.
|
|
39
|
+
- **Send the next instruction.** Messages go to an explicit agent, only with your consent (`agents:message`), and every message tells the agent who sent it.
|
|
40
|
+
- **Share a machine.** `peerband share` creates an invite link for a teammate or a review bot: read only, or read and message. Your agent treats guests as coworkers.
|
|
41
|
+
- **Get told when an agent needs you.** Agents send you notes with `peerband notify`. Webhooks deliver status changes and notes to Slack, Discord, or your own endpoint, signed with [Standard Webhooks](https://www.standardwebhooks.com). Send a note to one webhook with `--channel`.
|
|
42
|
+
- **No polling.** The connector streams agent status changes, so the dashboard and MCP clients read output only when something changed. `wait_for_agent` waits for an agent to finish or block without reading its output.
|
|
43
|
+
- **Safe by default.** Outbound connection only, metadata-only activity logs, one switch to make a machine read only, and best-effort secret redaction.
|
|
44
|
+
|
|
45
|
+
This project is unofficial and is not affiliated with Herdr or Amazon.
|
|
11
46
|
|
|
12
47
|
## Requirements
|
|
13
48
|
|
|
@@ -56,6 +91,21 @@ No browser available? Pass a one-time grant from the PeerBand dashboard instead:
|
|
|
56
91
|
|
|
57
92
|
1. `npm install -g peerband && peerband setup`. Confirm the code shown in your terminal when your browser opens, and press Enter to accept the Herdr plugin and the agent skill. Setup then opens the PeerBand Relay tab; press Space there if it is not connected yet.
|
|
58
93
|
2. Add the MCP server URL that `peerband setup`, `peerband relay` and `peerband status` print (`https://mcp.peerband.com/mcp`) to your MCP client: a custom connector in ChatGPT or Claude, or `claude mcp add --transport http peerband https://mcp.peerband.com/mcp` in Claude Code. Sign in and approve access when the client asks.
|
|
94
|
+
3. Ask your client something like "What are my agents doing?".
|
|
95
|
+
|
|
96
|
+
## MCP tools
|
|
97
|
+
|
|
98
|
+
| Tool | Scope | What it does |
|
|
99
|
+
| --- | --- | --- |
|
|
100
|
+
| `list_machines` | `agents:read` | Your machines (and machines shared with you), their installation IDs and whether each is online. Call it first |
|
|
101
|
+
| `list_agents` | `agents:read` | The agents on a machine, with status, label, workspace and Herdr location (space and tab) |
|
|
102
|
+
| `get_agent_status` | `agents:read` | The status of one agent: `idle`, `working`, `blocked`, `done` or `unknown` |
|
|
103
|
+
| `get_agent_output` | `agents:read` | A bounded excerpt of an agent's recent output |
|
|
104
|
+
| `wait_for_agent` | `agents:read` | Wait up to 50 seconds for an agent to reach a status (default: idle, blocked or done), without polling or reading output |
|
|
105
|
+
| `send_agent_message` | `agents:message` | Send a message to an explicit agent ID. Fails with `write_disabled` on a read-only machine |
|
|
106
|
+
| `get_request_status` | `agents:read` | The delivery receipt of an earlier message |
|
|
107
|
+
|
|
108
|
+
The agent tools take an optional `installation_id`; it can be left out when you have one machine, or exactly one online. Clients that support MCP Events can subscribe to agent status changes and notes instead of waiting. Full reference: [peerband.com/docs](https://peerband.com/docs#tools).
|
|
59
109
|
|
|
60
110
|
## Logging in
|
|
61
111
|
|
|
@@ -151,6 +201,16 @@ peerband notify "Migration finished, 3 tests failing"
|
|
|
151
201
|
|
|
152
202
|
The note goes to the machine owner only (never to people you shared the machine with). Control characters are removed and likely secrets are redacted, best effort, like agent output. It needs the Relay tab's helper to be running and connected; a note sent while it is offline fails with an error instead of being queued. The [agent skill](#agent-skill) tells agents when to use it. The wire format is in [protocol/](protocol/README.md).
|
|
153
203
|
|
|
204
|
+
### Webhooks
|
|
205
|
+
|
|
206
|
+
Add webhooks in the PeerBand dashboard under Webhooks. Each one has a name, an HTTPS URL, a format and a filter:
|
|
207
|
+
|
|
208
|
+
- **Formats.** `slack` and `discord` post a one-line message to an incoming webhook. `standard` posts a JSON envelope signed with [Standard Webhooks](https://www.standardwebhooks.com) (`webhook-id`, `webhook-timestamp`, `webhook-signature` headers), so you can verify it with any Standard Webhooks library and the secret shown once when you create the webhook.
|
|
209
|
+
- **Events.** `agent.status_changed` (filter by status, for example only `blocked`), `agent.notified` (notes), `machine.online` and `machine.offline` (held for 30 seconds, so a short network drop pages nobody). The Test button sends `webhook.test`. Webhooks go to the machine owner only, never to people you shared the machine with.
|
|
210
|
+
- **Machines.** All your machines, or a chosen few.
|
|
211
|
+
|
|
212
|
+
Failed deliveries are retried for about a day with backoff, and the dashboard shows every attempt. Webhook payloads carry metadata and note text only, never terminal output.
|
|
213
|
+
|
|
154
214
|
### Channels
|
|
155
215
|
|
|
156
216
|
A channel is one of your PeerBand webhooks, addressed by its name: for example a Slack or Discord incoming webhook, or your own endpoint. Add them in the PeerBand dashboard under Webhooks; the webhook's name is the channel name. A note always shows in the dashboard. Without a channel, it also goes to every webhook that takes notes; with one, it goes to that one webhook instead (the dashboard shows which channel it was sent to):
|
package/dist/peerband.mjs
CHANGED
|
@@ -12044,7 +12044,7 @@ var ConnectorCore = class {
|
|
|
12044
12044
|
}
|
|
12045
12045
|
const result = await this.adapter.readOutput(agent.id, options);
|
|
12046
12046
|
const safe = sanitizeOutput(result.text, options);
|
|
12047
|
-
return { ...safe, observedAt: result.observedAt, truncated: safe.truncated || result.truncated, ...result.nextCursor ? { nextCursor: result.nextCursor } : {} };
|
|
12047
|
+
return { ...safe, ...result.source === "visible" ? { source: result.source } : {}, observedAt: result.observedAt, truncated: safe.truncated || result.truncated, ...result.nextCursor ? { nextCursor: result.nextCursor } : {} };
|
|
12048
12048
|
}
|
|
12049
12049
|
async sendMessage(args, principal) {
|
|
12050
12050
|
assertKeys(args, ["agentId", "message", "idempotencyKey"]);
|
|
@@ -14241,7 +14241,17 @@ function isRecord3(value) {
|
|
|
14241
14241
|
}
|
|
14242
14242
|
|
|
14243
14243
|
// src/runtime-herdr/events.ts
|
|
14244
|
-
var LIST_SUBSCRIPTIONS = [
|
|
14244
|
+
var LIST_SUBSCRIPTIONS = [
|
|
14245
|
+
"pane.created",
|
|
14246
|
+
"pane.closed",
|
|
14247
|
+
"pane.exited",
|
|
14248
|
+
"pane.agent_detected",
|
|
14249
|
+
"pane.moved",
|
|
14250
|
+
"tab.renamed",
|
|
14251
|
+
"tab.moved",
|
|
14252
|
+
"workspace.renamed",
|
|
14253
|
+
"workspace.reordered"
|
|
14254
|
+
];
|
|
14245
14255
|
var UNSUPPORTED = /* @__PURE__ */ new Set(["invalid_request", "unknown_method", "method_not_found", "unsupported_capability", "schema_mismatch"]);
|
|
14246
14256
|
var normalizeName = (name) => name.replaceAll(".", "_");
|
|
14247
14257
|
var HerdrEventBridge = class {
|
|
@@ -14750,7 +14760,8 @@ var HerdrAdapter = class {
|
|
|
14750
14760
|
}
|
|
14751
14761
|
async refreshAgents() {
|
|
14752
14762
|
const { client } = await this.initialize();
|
|
14753
|
-
const
|
|
14763
|
+
const [listed, layout] = await Promise.all([client.request("agent.list", {}), readLayout(client)]);
|
|
14764
|
+
const result = asObject(listed);
|
|
14754
14765
|
if (result.type !== "agent_list" || !Array.isArray(result.agents)) throw this.schemaMismatch("agent.list returned an unexpected result type");
|
|
14755
14766
|
const marker = this.socketPath ? await readEndpointMarker(this.socketPath) : void 0;
|
|
14756
14767
|
const reconnected = marker !== void 0 && this.endpointMarker !== void 0 && marker !== this.endpointMarker;
|
|
@@ -14769,14 +14780,18 @@ var HerdrAdapter = class {
|
|
|
14769
14780
|
const live = { id, fingerprint, agent: raw };
|
|
14770
14781
|
next.set(raw.pane_id, live);
|
|
14771
14782
|
nextIds.add(id);
|
|
14772
|
-
records.push(toRecord(live, this.machineId, promptTarget(raw, rawAgents) !== void 0));
|
|
14783
|
+
records.push(toRecord(live, this.machineId, promptTarget(raw, rawAgents) !== void 0, layout));
|
|
14773
14784
|
}
|
|
14774
14785
|
for (const previous of previousTargets) if (!nextIds.has(previous.id)) this.retired.add(previous.id);
|
|
14775
14786
|
const idsChanged = this.listed && (nextIds.size !== previousTargets.length || previousTargets.some((item) => !nextIds.has(item.id)));
|
|
14787
|
+
const layoutChanged = this.listed && records.some((record) => {
|
|
14788
|
+
const before = this.records.get(record.id);
|
|
14789
|
+
return before !== void 0 && JSON.stringify(before.location) !== JSON.stringify(record.location);
|
|
14790
|
+
});
|
|
14776
14791
|
this.current = next;
|
|
14777
14792
|
this.records = new Map(records.map((record) => [record.id, record]));
|
|
14778
14793
|
this.listed = true;
|
|
14779
|
-
this.bridge?.agentsRefreshed(idsChanged);
|
|
14794
|
+
this.bridge?.agentsRefreshed(idsChanged || layoutChanged);
|
|
14780
14795
|
return records;
|
|
14781
14796
|
}
|
|
14782
14797
|
/** Status and list-change events from Herdr's events.subscribe (metadata only, never pane text). */
|
|
@@ -14820,17 +14835,26 @@ var HerdrAdapter = class {
|
|
|
14820
14835
|
if (!live) throw new ConnectError("stale_target", "This Herdr agent handle is no longer current.", "Refresh the agent list and select its current occupant.");
|
|
14821
14836
|
const lines = clampInteger(options.lines, 80, 1, 500);
|
|
14822
14837
|
const { client } = await this.initialize();
|
|
14823
|
-
const
|
|
14838
|
+
const params = {
|
|
14824
14839
|
target: live.agent.pane_id,
|
|
14825
14840
|
source: "recent",
|
|
14826
14841
|
format: "text",
|
|
14827
14842
|
lines,
|
|
14828
14843
|
strip_ansi: true
|
|
14829
|
-
}
|
|
14844
|
+
};
|
|
14845
|
+
let result;
|
|
14846
|
+
let visibleOnly = false;
|
|
14847
|
+
try {
|
|
14848
|
+
result = asObject(await client.request("agent.read", params));
|
|
14849
|
+
} catch (error) {
|
|
14850
|
+
if (!(error instanceof ConnectError) || error.code !== "agent_not_idle") throw error;
|
|
14851
|
+
result = asObject(await client.request("agent.read", { ...params, source: "visible" }));
|
|
14852
|
+
visibleOnly = true;
|
|
14853
|
+
}
|
|
14830
14854
|
if (result.type !== "pane_read" || !result.read || typeof result.read !== "object" || typeof result.read.text !== "string") throw this.schemaMismatch("agent.read returned an unexpected result type");
|
|
14831
14855
|
const output = sanitizeOutput(result.read.text, { ...options, lines, bytes: clampInteger(options.bytes, 16384, 1, 32768) });
|
|
14832
14856
|
await this.getAgent(id);
|
|
14833
|
-
return { ...output, truncated: output.truncated || result.read.truncated === true, observedAt: (/* @__PURE__ */ new Date()).toISOString(), untrusted: true };
|
|
14857
|
+
return { ...output, ...visibleOnly ? { source: "visible" } : {}, truncated: visibleOnly || output.truncated || result.read.truncated === true, observedAt: (/* @__PURE__ */ new Date()).toISOString(), untrusted: true };
|
|
14834
14858
|
}
|
|
14835
14859
|
async sendMessage(id, message) {
|
|
14836
14860
|
if (typeof message !== "string" || message.length === 0 || Buffer.byteLength(message, "utf8") > 16384) {
|
|
@@ -14888,7 +14912,43 @@ var HerdrAdapter = class {
|
|
|
14888
14912
|
return new ConnectError("schema_mismatch", `Herdr response did not match the selected API schema: ${message}`, "Use the API schema shipped with the connected Herdr version.");
|
|
14889
14913
|
}
|
|
14890
14914
|
};
|
|
14891
|
-
function
|
|
14915
|
+
async function readLayout(client) {
|
|
14916
|
+
const [spaces, tabs] = await Promise.all([
|
|
14917
|
+
client.request("workspace.list", {}).then((result) => layoutEntries(result, "workspace_list", "workspaces", "workspace_id"), () => /* @__PURE__ */ new Map()),
|
|
14918
|
+
client.request("tab.list", {}).then((result) => layoutEntries(result, "tab_list", "tabs", "tab_id"), () => /* @__PURE__ */ new Map())
|
|
14919
|
+
]);
|
|
14920
|
+
return { spaces, tabs };
|
|
14921
|
+
}
|
|
14922
|
+
function layoutEntries(result, type, key, idKey) {
|
|
14923
|
+
const entries = /* @__PURE__ */ new Map();
|
|
14924
|
+
if (!result || typeof result !== "object") return entries;
|
|
14925
|
+
const value = result;
|
|
14926
|
+
if (value.type !== type || !Array.isArray(value[key])) return entries;
|
|
14927
|
+
for (const item of value[key]) {
|
|
14928
|
+
if (!item || typeof item !== "object") continue;
|
|
14929
|
+
const row = item;
|
|
14930
|
+
if (typeof row[idKey] !== "string") continue;
|
|
14931
|
+
entries.set(row[idKey], {
|
|
14932
|
+
label: layoutLabel(row.label),
|
|
14933
|
+
number: Number.isSafeInteger(row.number) && row.number >= 0 ? row.number : null
|
|
14934
|
+
});
|
|
14935
|
+
}
|
|
14936
|
+
return entries;
|
|
14937
|
+
}
|
|
14938
|
+
function layoutLabel(value) {
|
|
14939
|
+
if (typeof value !== "string") return null;
|
|
14940
|
+
const label = value.replace(/[\u0000-\u001f\u007f-\u009f]/g, " ").trim().slice(0, 128);
|
|
14941
|
+
return label || null;
|
|
14942
|
+
}
|
|
14943
|
+
function toLocation(agent, layout) {
|
|
14944
|
+
const space = layout.spaces.get(agent.workspace_id);
|
|
14945
|
+
const tab = layout.tabs.get(agent.tab_id);
|
|
14946
|
+
return {
|
|
14947
|
+
space: { id: agent.workspace_id, label: space?.label ?? null, number: space?.number ?? null },
|
|
14948
|
+
tab: { id: agent.tab_id, label: tab?.label ?? null, number: tab?.number ?? null }
|
|
14949
|
+
};
|
|
14950
|
+
}
|
|
14951
|
+
function toRecord(live, machineId, canSend, layout) {
|
|
14892
14952
|
const agent = live.agent;
|
|
14893
14953
|
const label = agent.display_agent ?? agent.name ?? agent.agent ?? agent.terminal_title_stripped ?? agent.title ?? "Herdr agent";
|
|
14894
14954
|
const status = ["idle", "working", "blocked", "done", "unknown"].includes(agent.agent_status) ? agent.agent_status : "unknown";
|
|
@@ -14903,7 +14963,8 @@ function toRecord(live, machineId, canSend) {
|
|
|
14903
14963
|
rawStatus: agent.agent_status,
|
|
14904
14964
|
observedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
14905
14965
|
stale: false,
|
|
14906
|
-
capabilities: { readOutput: true, sendMessage: canSend, ...canSend ? {} : { reason: "A unique valid live name or pane target is required for prompt targeting." } }
|
|
14966
|
+
capabilities: { readOutput: true, sendMessage: canSend, ...canSend ? {} : { reason: "A unique valid live name or pane target is required for prompt targeting." } },
|
|
14967
|
+
location: toLocation(agent, layout)
|
|
14907
14968
|
};
|
|
14908
14969
|
}
|
|
14909
14970
|
function isValidAlias(value) {
|
|
@@ -16844,7 +16905,7 @@ function herdrGroupHelp(s) {
|
|
|
16844
16905
|
}
|
|
16845
16906
|
|
|
16846
16907
|
// src/cli/cli.ts
|
|
16847
|
-
var VERSION = true ? "0.2.
|
|
16908
|
+
var VERSION = true ? "0.2.2" : "0.0.0-dev";
|
|
16848
16909
|
function createContext(overrides = {}) {
|
|
16849
16910
|
const env = overrides.env ?? process.env;
|
|
16850
16911
|
const stdout = overrides.stdout ?? process.stdout;
|
package/herdr-plugin.toml
CHANGED
package/package.json
CHANGED
package/protocol/README.md
CHANGED
|
@@ -34,6 +34,8 @@ The grant flow (`enrollment-redeem.schema.json`) remains available for headless
|
|
|
34
34
|
|
|
35
35
|
The client only reports metadata (tool, target id, outcome, latency) to its local activity log; message bodies and agent output are never logged.
|
|
36
36
|
|
|
37
|
+
`get_agent_output` normally reads recent terminal history. If Herdr rejects that read with `agent_not_idle`, the client retries once using the current visible screen without scrolling. That result includes the optional field `source: "visible"` and `truncated: true`, so consumers can explain that older history is unavailable in this excerpt. Output limits, sanitization and occupant checks still apply. Other read errors are returned without this retry.
|
|
38
|
+
|
|
37
39
|
## Versioning
|
|
38
40
|
|
|
39
41
|
The protocol has no explicit version field today. Changes are additive: new optional fields, new `tool` values and new frame types may appear, so implementations must ignore unknown fields and unknown frame types on received messages. The `event` frame is such an addition: servers that do not know it ignore it, and the `x-peerband-features` upgrade header tells servers that do which clients emit events. A breaking change would use a new endpoint path or a `hello` negotiation message and be documented here with a bump of the schema `$id`. Schemas are published with each client release in `protocol/`.
|