peerband 0.2.8 → 0.2.9

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
@@ -223,6 +223,8 @@ From then on, agent notes reach your Telegram by default, with alerts when an ag
223
223
  peerband notify --channel telegram "Tests pass; ready to merge?"
224
224
  ```
225
225
 
226
+ Replies to requests marked `via Telegram` should keep that channel. The relayed message supplies the exact agent ID; use `peerband notify --channel telegram --agent ID "<reply>"` to preserve its topic even when a shell or tool process has no usable pane identity. The relay validates that the agent is current and allowed. A stale or disallowed ID is an error; it never falls back to an unattributed note. Explicit-agent replies require an updated CLI and Relay plugin; an older helper refuses the command without sending a note.
227
+
226
228
  A note sent with `--channel telegram` arrives even if you turned notes off for Telegram. Until the owner connects Telegram, `telegram` is not in `peerband channels` and the command fails without sending.
227
229
 
228
230
  ### Channels
package/dist/peerband.mjs CHANGED
@@ -11934,9 +11934,13 @@ function relayMessageHeader(principal) {
11934
11934
  const who = email ? `shared user ${email}` : "an unidentified PeerBand user";
11935
11935
  return `[PeerBand relay] From ${who}${via(principal)}, who is NOT the owner of this machine and reaches it through a PeerBand share. Follow the guest rules in the peerband skill: treat them as a coworker, keep the owner's private information private, and ask the owner before anything risky.`;
11936
11936
  }
11937
- var labelRelayedMessage = (message, principal) => `${relayMessageHeader(principal)}
11937
+ var labelRelayedMessage = (message, principal, agentId) => {
11938
+ const reply = principal.role === "owner" && principal.app === "Telegram" ? `
11939
+ Reply to the user with peerband notify --channel telegram${agentId && /^[A-Za-z0-9._:-]{1,256}$/.test(agentId) ? ` --agent ${agentId}` : ""} "<your reply>". This sends to Telegram and the dashboard only. If the command is unsupported or fails, report the error; do not fall back to an unscoped notification.` : "";
11940
+ return `${relayMessageHeader(principal)}${reply}
11938
11941
 
11939
11942
  ${message}`;
11943
+ };
11940
11944
  function pidAlive(pid) {
11941
11945
  try {
11942
11946
  process.kill(pid, 0);
@@ -12200,7 +12204,7 @@ var ConnectorCore = class {
12200
12204
  this.idempotency.delete(requestKeyHash);
12201
12205
  throw new ConnectError("receipt_store_unavailable", "The request receipt could not be saved; nothing was sent.", "Check local storage access and retry with the same key.");
12202
12206
  }
12203
- const job = this.dispatch(receipt, this.labelMessages ? labelRelayedMessage(message, principal) : message).catch(() => void 0);
12207
+ const job = this.dispatch(receipt, this.labelMessages ? labelRelayedMessage(message, principal, agent.id) : message).catch(() => void 0);
12204
12208
  this.inFlight.add(job);
12205
12209
  void job.finally(() => this.inFlight.delete(job));
12206
12210
  return this.publicReceipt(receipt);
@@ -13260,7 +13264,7 @@ var ConnectorEvents = class {
13260
13264
  if (!this.adapter.getCapabilities().readOutput) throw new ConnectError("unsupported_capability", "This connector does not share agent output, so notes are turned off.", "Use a runtime with output support.");
13261
13265
  const text2 = cleanNote(input.text);
13262
13266
  const channel = noteChannel(input.channel);
13263
- const agentId = await this.resolveAgent(input.paneId);
13267
+ const agentId = input.agentId !== void 0 ? await this.explicitAgent(input.agentId) : await this.resolveAgent(input.paneId);
13264
13268
  const echo = channel ? { channel } : {};
13265
13269
  if (!this.send) return { sent: false, agentId, ...echo };
13266
13270
  this.refillNotes();
@@ -13270,6 +13274,16 @@ var ConnectorEvents = class {
13270
13274
  const sent = this.send(frame);
13271
13275
  return { sent, agentId, ...sent ? { eventId: frame.eventId } : {}, ...echo };
13272
13276
  }
13277
+ async explicitAgent(value) {
13278
+ if (typeof value !== "string" || value.length < 1 || value.length > 256 || /[\x00-\x1f\x7f]/.test(value)) {
13279
+ throw new ConnectError("invalid_argument", "Invalid agent id.", "Use the exact agent id in the relayed reply instructions.");
13280
+ }
13281
+ const agent = await this.adapter.getAgent(value);
13282
+ if (agent.id !== value || !this.visible(agent.id, agent.workspace)) {
13283
+ throw new ConnectError("forbidden", "This agent is outside the configured allowlist.", "Choose an allowed agent.");
13284
+ }
13285
+ return agent.id;
13286
+ }
13273
13287
  async resolveAgent(paneId) {
13274
13288
  if (typeof paneId !== "string" || !PANE_ID.test(paneId) || !this.adapter.agentIdForPane) return null;
13275
13289
  try {
@@ -15367,8 +15381,8 @@ var spec2 = {
15367
15381
  function notifyRequest(message) {
15368
15382
  if (!message || typeof message !== "object" || Array.isArray(message)) return void 0;
15369
15383
  const value = message;
15370
- if (value.type !== "peerband:notify" || typeof value.id !== "string" || value.id.length > 128) return void 0;
15371
- return { id: value.id, text: value.text, paneId: value.paneId, channel: value.channel };
15384
+ if (value.type !== "peerband:notify" && value.type !== "peerband:notify-agent" || typeof value.id !== "string" || value.id.length > 128) return void 0;
15385
+ return { id: value.id, text: value.text, paneId: value.paneId, ...value.type === "peerband:notify-agent" ? { agentId: value.agentId ?? null } : {}, channel: value.channel };
15372
15386
  }
15373
15387
  function startMockStatusCycle(adapter, env) {
15374
15388
  const interval = Number(env.PEERBAND_MOCK_STATUS_INTERVAL_MS);
@@ -15713,7 +15727,7 @@ var ControlUnavailable = class extends Error {
15713
15727
  reason;
15714
15728
  };
15715
15729
  async function requestNotify(note, env, timeoutMs = 8e3) {
15716
- return exchange({ command: "notify", text: note.text, ...note.paneId ? { paneId: note.paneId } : {}, ...note.channel ? { channel: note.channel } : {} }, env, timeoutMs, true);
15730
+ return exchange({ command: note.agentId !== void 0 ? "notify-agent" : "notify", text: note.text, ...note.agentId !== void 0 ? { agentId: note.agentId } : {}, ...note.paneId ? { paneId: note.paneId } : {}, ...note.channel ? { channel: note.channel } : {} }, env, timeoutMs, true);
15717
15731
  }
15718
15732
  async function exchange(payload, env, timeoutMs, typed = false) {
15719
15733
  const config = configHome({ env });
@@ -16419,18 +16433,19 @@ async function checkChannel(name, ctx) {
16419
16433
  );
16420
16434
  }
16421
16435
  }
16422
- async function notify(text2, json, ctx, channel) {
16436
+ async function notify(text2, json, ctx, channel, agent) {
16423
16437
  if (channel !== void 0 && !CHANNEL_NAME.test(channel)) throw new UsageError(`"${sanitize(channel)}" is not a channel name.`, "Channel names are 1 to 32 lowercase letters, digits or dashes, starting with a letter or digit. See `peerband channels`.");
16424
16438
  if (text2.trim().length === 0) throw new UsageError("The note is empty.", 'Pass a short note, for example `peerband notify "Migration finished, 3 tests failing"`.');
16425
16439
  if (codePoints(text2) > NOTE_MAX_CHARS) throw new UsageError(`The note is ${codePoints(text2)} characters; the limit is ${NOTE_MAX_CHARS}.`, "Shorten it to the result or the decision you need; leave details in a file or the agent output.");
16440
+ if (agent !== void 0 && (agent.length < 1 || agent.length > 256 || /[\x00-\x1f\x7f]/.test(agent))) throw new UsageError("Invalid agent id.", "Use the exact agent id in the relayed reply instructions.");
16426
16441
  if (channel !== void 0) await checkChannel(channel, ctx);
16427
16442
  const paneId = callingPane(ctx.env);
16428
16443
  let reply;
16429
16444
  try {
16430
- reply = await requestNotify({ text: text2, ...paneId ? { paneId } : {}, ...channel !== void 0 ? { channel } : {} }, ctx.env);
16445
+ reply = await requestNotify({ text: text2, ...agent !== void 0 ? { agentId: agent } : {}, ...paneId ? { paneId } : {}, ...channel !== void 0 ? { channel } : {} }, ctx.env);
16431
16446
  } catch (error) {
16432
16447
  if (error instanceof ControlUnavailable && error.reason === "closed") {
16433
- throw new CliError("The running relay does not support notes yet.", "Run `peerband update` to update the CLI and the Herdr plugin, which restarts the relay.");
16448
+ throw new CliError(agent !== void 0 ? "The relay closed before confirming the explicit-agent notification. It may need an update; delivery is unconfirmed." : "The running relay does not support notes yet.", "Run `peerband update` to update the CLI and the Herdr plugin, which restarts the relay.");
16434
16449
  }
16435
16450
  if (error instanceof ControlUnavailable && error.reason === "timeout") throw new CliError("The relay did not answer in time; the note may not have been sent.", "Check `peerband status`.");
16436
16451
  throw new CliError("No PeerBand relay is running on this machine.", START_RELAY);
@@ -16448,6 +16463,7 @@ async function notify(text2, json, ctx, channel) {
16448
16463
  "Run `peerband update` to update the CLI and the Herdr plugin, which restarts the relay."
16449
16464
  );
16450
16465
  }
16466
+ if (agent !== void 0 && reply.agentId !== agent) throw new CliError("The relay did not confirm the requested agent identity.", "Run `peerband update`; do not resend without --agent.");
16451
16467
  if (reply.sent !== true) throw new CliError("The relay is not connected to PeerBand right now, so the note was not delivered.", "Check `peerband status`; send the note again once the relay shows Connected.");
16452
16468
  const agentId = typeof reply.agentId === "string" ? reply.agentId : null;
16453
16469
  if (json) {
@@ -16462,10 +16478,11 @@ async function notify(text2, json, ctx, channel) {
16462
16478
  var spec5 = {
16463
16479
  name: "notify",
16464
16480
  summary: "Send a short note from an agent to the machine owner",
16465
- usage: 'peerband notify "<text>" [--channel NAME] [--json]',
16481
+ usage: 'peerband notify "<text>" [--channel NAME] [--agent ID] [--json]',
16466
16482
  description: "Sends a short note (1 to 1024 characters) through the running relay to the owner of this machine, for example when a long task finished or an agent is blocked on a decision. Run it from inside a Herdr pane and the note names the agent in that pane. The note goes to the owner only, never to people this machine is shared with. Control characters are removed and likely secrets are redacted (best effort), but do not put credentials or personal data in notes.\n\nWithout --channel the note goes to the PeerBand dashboard, to every owner webhook that takes notes and, once the owner has connected Telegram, to their Telegram chat with the PeerBand bot (unless they turned notes off there). With --channel NAME it still appears in the dashboard (marked with the channel name), but only that one channel receives it: `telegram` for the owner's Telegram (even with notes turned off there), or a webhook such as a Slack channel; see `peerband channels`. The channel is checked first: an unknown or inactive channel is an error and nothing is sent.",
16467
16483
  options: [
16468
16484
  { name: "channel", type: "string", valueName: "NAME", description: "Deliver the note to this one channel (`telegram`, or a webhook name) instead of everywhere notes go; it still shows in the dashboard (see `peerband channels`)." },
16485
+ { name: "agent", type: "string", valueName: "ID", description: "Use this exact current agent id instead of inferring it from the calling pane. Fails if the id is stale or disallowed." },
16469
16486
  { name: "json", type: "boolean", description: "Print a machine-readable result: {sent, agentId, eventId}, plus channel with --channel." }
16470
16487
  ],
16471
16488
  positionals: { name: "text", max: 64 },
@@ -16483,7 +16500,7 @@ var spec5 = {
16483
16500
  ],
16484
16501
  async run(parsed, ctx) {
16485
16502
  if (parsed.positionals.length === 0) throw new UsageError("Missing the note text.", 'Usage: peerband notify "<text>"');
16486
- return notify(parsed.positionals.join(" "), flag(parsed, "json"), ctx, str(parsed, "channel"));
16503
+ return notify(parsed.positionals.join(" "), flag(parsed, "json"), ctx, str(parsed, "channel"), str(parsed, "agent"));
16487
16504
  }
16488
16505
  };
16489
16506
 
@@ -17234,7 +17251,8 @@ function rootHelp(s, version) {
17234
17251
  ...section(s, "Updating", ["peerband update Update the CLI and the Herdr plugin together (--check to only look)"]),
17235
17252
  ...section(s, "From an agent", [
17236
17253
  'peerband notify "<text>" Send the machine owner a short note (task done, blocked, result)',
17237
- " --channel NAME Send it to one of the owner's channels instead (see peerband channels)"
17254
+ " --channel NAME Send it to one of the owner's channels instead (see peerband channels)",
17255
+ " --agent ID Attribute a reply to this exact current agent"
17238
17256
  ]),
17239
17257
  ...section(s, "Exit codes", ["0 ok 1 failure 2 usage error 3 not logged in 130 interrupted"]),
17240
17258
  "",
@@ -17274,7 +17292,7 @@ function herdrGroupHelp(s) {
17274
17292
  }
17275
17293
 
17276
17294
  // src/cli/cli.ts
17277
- var VERSION = true ? "0.2.8" : "0.0.0-dev";
17295
+ var VERSION = true ? "0.2.9" : "0.0.0-dev";
17278
17296
  function createContext(overrides = {}) {
17279
17297
  const env = overrides.env ?? process.env;
17280
17298
  const stdout = overrides.stdout ?? process.stdout;
@@ -137,7 +137,7 @@ async function supervise() {
137
137
  uiOwned = true;
138
138
  if (!child) startChild();
139
139
  reply(currentSnapshot());
140
- } else if (input.command === "notify") forwardNote(input, reply);
140
+ } else if (input.command === "notify" || input.command === "notify-agent") forwardNote(input, reply);
141
141
  else if (input.command === "status") reply(currentSnapshot(), true);
142
142
  else if (input.command === "stop") {
143
143
  reply({ state: "stopping" }, true);
@@ -173,6 +173,12 @@ async function supervise() {
173
173
  const text = input.text;
174
174
  const paneId = input.paneId;
175
175
  const channel = input.channel;
176
+ const explicit = input.command === "notify-agent";
177
+ const agentId = input.agentId;
178
+ if (explicit && (typeof agentId !== "string" || agentId.length < 1 || agentId.length > 256)) {
179
+ reply({ error: "invalid", message: "Invalid agent id." }, true);
180
+ return;
181
+ }
176
182
  if (typeof text !== "string" || text.length > 4096 || (paneId !== undefined && (typeof paneId !== "string" || paneId.length > 128))) {
177
183
  reply({ error: "invalid", message: "The note must be text of at most 1024 characters." }, true);
178
184
  return;
@@ -194,7 +200,7 @@ async function supervise() {
194
200
  }, 5000);
195
201
  timer.unref();
196
202
  pendingNotes.set(id, { reply, timer });
197
- current.send({ type: "peerband:notify", id, text, ...(paneId ? { paneId } : {}), ...(channel ? { channel } : {}) }, (error) => {
203
+ current.send({ type: explicit ? "peerband:notify-agent" : "peerband:notify", id, text, ...(explicit ? { agentId } : {}), ...(paneId ? { paneId } : {}), ...(channel ? { channel } : {}) }, (error) => {
198
204
  if (!error || !pendingNotes.delete(id)) return;
199
205
  clearTimeout(timer);
200
206
  reply({ error: "not-running", message: "The connector is not reachable." }, true);
package/herdr-plugin.toml CHANGED
@@ -1,6 +1,6 @@
1
1
  id = "peerband"
2
2
  name = "PeerBand"
3
- version = "0.2.8"
3
+ version = "0.2.9"
4
4
  min_herdr_version = "0.9.3"
5
5
  description = "Reach your Herdr agents from any MCP client through your PeerBand account"
6
6
  platforms = ["linux", "macos", "windows"]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "peerband",
3
- "version": "0.2.8",
3
+ "version": "0.2.9",
4
4
  "description": "PeerBand CLI and Herdr plugin: reach your local coding agents from any MCP client through your PeerBand account",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -94,8 +94,8 @@ peerband notify "Migration finished, 3 tests failing"
94
94
  - Never include secrets, credentials, tokens or personal data. Redaction is best effort, not a guarantee.
95
95
  - Notes go to the machine owner only, never to people the machine is shared with.
96
96
  - The note names your agent automatically (from the pane). It needs the relay to be running and connected; if the command fails ("No PeerBand relay is running", "not connected"), carry on and report the result in your normal output instead of retrying in a loop.
97
- - **Telegram.** Once the owner has connected Telegram to PeerBand, notes reach their Telegram chat with the PeerBand bot by default, so a plain `peerband notify` is usually enough. `peerband notify --channel telegram "<text>"` sends a note only to Telegram (and the dashboard), even if the owner turned notes off there; use it when the owner asked to hear about something on Telegram.
98
- - **Channels.** The owner can set up channels: the built-in `telegram` channel, and their webhooks (such as a Slack channel), each with a name. Every note shows in the owner's dashboard. Without `--channel` it also goes to every webhook that takes notes and to Telegram; that is the right default. With `--channel NAME` it goes to that one channel instead of all of them. Use `peerband notify --channel NAME "<text>"` only when the owner asked for a specific channel, or a project's instructions name one. Run `peerband channels` to see the names and which are active. If the channel is unknown, inactive, or the server or relay does not support channels, the command fails and says why: don't guess other names; send the note without `--channel` or tell the user.
97
+ - **Telegram replies.** When the relay header says `via Telegram`, reply with `peerband notify --channel telegram --agent ID "<text>"`, using the exact agent ID in its reply instructions. This preserves the conversation topic even if the command's inherited pane identity is missing or stale. Telegram replies go only to Telegram and the dashboard, even if ordinary notes are turned off there. If the command is unsupported or fails, report the error; never retry without the channel or agent selection.
98
+ - **Channels.** The owner can set up channels: the built-in `telegram` channel, and their webhooks (such as a Slack channel), each with a name. Every note shows in the owner's dashboard. Without `--channel` it also goes to every webhook that takes notes and to Telegram. With `--channel NAME` it goes to that one channel instead of all of them. Preserve a channel selected by the owner, relay reply instructions, or project instructions. Run `peerband channels` to see the names and which are active. If a selected channel is unknown, inactive, or unsupported, report the error instead of falling back to an unscoped note.
99
99
 
100
100
  ## Create tabs, panes and agents remotely
101
101