@stage-labs/metro 0.1.0-beta.8 → 0.1.0-beta.80
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/dist/api.js +14 -0
- package/dist/claude-settings.js +40 -0
- package/dist/claude.js +107 -0
- package/dist/cli.js +101 -0
- package/dist/control.js +74 -0
- package/dist/hold.js +211 -0
- package/dist/local.js +93 -0
- package/dist/node-name.js +71 -0
- package/dist/plugin.js +80 -0
- package/dist/provider-flags.js +9 -0
- package/dist/runtime-install.js +87 -0
- package/dist/runtime.js +74 -0
- package/dist/serve.js +146 -0
- package/dist/service.js +242 -0
- package/dist/tail.js +119 -0
- package/dist/update.js +45 -0
- package/dist/version.js +97 -0
- package/package.json +14 -25
- package/runtime/node_modules/@metro-labs/core/package.json +43 -0
- package/runtime/node_modules/@metro-labs/core/src/address.ts +6 -0
- package/runtime/node_modules/@metro-labs/core/src/endpoints.ts +7 -0
- package/runtime/node_modules/@metro-labs/core/src/events.ts +120 -0
- package/runtime/node_modules/@metro-labs/core/src/identity.ts +7 -0
- package/runtime/node_modules/@metro-labs/core/src/ids.ts +21 -0
- package/runtime/node_modules/@metro-labs/core/src/is-record.ts +2 -0
- package/runtime/node_modules/@metro-labs/core/src/lines.ts +82 -0
- package/runtime/node_modules/@metro-labs/core/src/log.ts +42 -0
- package/runtime/node_modules/@metro-labs/core/src/protocol.ts +226 -0
- package/runtime/node_modules/@metro-labs/core/src/secure-fs.ts +57 -0
- package/runtime/node_modules/@metro-labs/core/src/station-names.ts +12 -0
- package/runtime/node_modules/@metro-labs/core/src/stations/account-store.ts +60 -0
- package/runtime/node_modules/@metro-labs/core/src/stations/attachments.ts +196 -0
- package/runtime/node_modules/@metro-labs/core/src/stations/messaging-normalize.ts +88 -0
- package/runtime/node_modules/@metro-labs/core/src/stations/station-runtime.ts +64 -0
- package/runtime/node_modules/@metro-labs/core/src/stations/types.ts +107 -0
- package/runtime/node_modules/@metro-labs/core/src/str.ts +5 -0
- package/runtime/node_modules/@metro-labs/core/src/train-error.ts +53 -0
- package/runtime/node_modules/@metro-labs/core/src/version.ts +2 -0
- package/runtime/node_modules/@metro-labs/daemon/package.json +47 -0
- package/runtime/node_modules/@metro-labs/daemon/src/agents/account-attach.ts +19 -0
- package/runtime/node_modules/@metro-labs/daemon/src/agents/accounts-api.ts +311 -0
- package/runtime/node_modules/@metro-labs/daemon/src/agents/admin.ts +43 -0
- package/runtime/node_modules/@metro-labs/daemon/src/agents/api.ts +302 -0
- package/runtime/node_modules/@metro-labs/daemon/src/agents/bundle.ts +111 -0
- package/runtime/node_modules/@metro-labs/daemon/src/agents/file-admin.ts +329 -0
- package/runtime/node_modules/@metro-labs/daemon/src/agents/files.ts +155 -0
- package/runtime/node_modules/@metro-labs/daemon/src/agents/keys.ts +45 -0
- package/runtime/node_modules/@metro-labs/daemon/src/agents/map.ts +84 -0
- package/runtime/node_modules/@metro-labs/daemon/src/agents/scope.ts +64 -0
- package/runtime/node_modules/@metro-labs/daemon/src/boot/boot.ts +176 -0
- package/runtime/node_modules/@metro-labs/daemon/src/boot/connect-hint.ts +39 -0
- package/runtime/node_modules/@metro-labs/daemon/src/boot/crash-guard.ts +49 -0
- package/runtime/node_modules/@metro-labs/daemon/src/boot/local-owner.ts +14 -0
- package/runtime/node_modules/@metro-labs/daemon/src/boot/paths.ts +106 -0
- package/runtime/node_modules/@metro-labs/daemon/src/channels/addressed.ts +25 -0
- package/runtime/node_modules/@metro-labs/daemon/src/channels/dedupe.ts +24 -0
- package/runtime/node_modules/@metro-labs/daemon/src/channels/inbound.ts +377 -0
- package/runtime/node_modules/@metro-labs/daemon/src/channels/media-note.ts +85 -0
- package/runtime/node_modules/@metro-labs/daemon/src/channels/pending.ts +75 -0
- package/runtime/node_modules/@metro-labs/daemon/src/channels/relay.ts +129 -0
- package/runtime/node_modules/@metro-labs/daemon/src/channels/webhook-note.ts +51 -0
- package/runtime/node_modules/@metro-labs/daemon/src/claude/api.ts +148 -0
- package/runtime/node_modules/@metro-labs/daemon/src/claude/files.ts +329 -0
- package/runtime/node_modules/@metro-labs/daemon/src/claude/login.ts +167 -0
- package/runtime/node_modules/@metro-labs/daemon/src/claude/settings.ts +117 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/api.ts +307 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/cli-api.ts +63 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/config.ts +144 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/json.ts +21 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/model.ts +69 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/oauth-client.ts +159 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/oauth-discovery.ts +117 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/oauth-pending.ts +65 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/oauth-routes.ts +157 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/oauth.ts +127 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/relay-target.ts +39 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/relay.ts +295 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/store.ts +277 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/tools.ts +98 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/url.ts +70 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/verify.ts +330 -0
- package/runtime/node_modules/@metro-labs/daemon/src/files/attach-grant.ts +99 -0
- package/runtime/node_modules/@metro-labs/daemon/src/files/attach-owner.ts +32 -0
- package/runtime/node_modules/@metro-labs/daemon/src/files/attach-serve.ts +121 -0
- package/runtime/node_modules/@metro-labs/daemon/src/files/upload-api.ts +294 -0
- package/runtime/node_modules/@metro-labs/daemon/src/files/upload-store.ts +181 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/bedrock.ts +252 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/codex-auth.ts +231 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/codex-device.ts +91 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/codex-stream.ts +288 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/codex-translate.ts +203 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/codex.ts +220 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/eventstream.ts +123 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/forward.ts +182 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/gateway.ts +197 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/model-api.ts +195 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/model-config.ts +198 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/openrouter.ts +40 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/served.ts +17 -0
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/accounts.ts +137 -0
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/call-tools.ts +216 -0
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/channel-owner.ts +29 -0
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/ctx.ts +62 -0
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/event-store.ts +91 -0
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/frame-scope.ts +21 -0
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/group-tools.ts +129 -0
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/index.ts +191 -0
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/member-tools.ts +72 -0
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/permission-relay.ts +66 -0
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/raw-get-stream.ts +207 -0
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/request-identity.ts +47 -0
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/session-registry.ts +172 -0
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/session-route.ts +43 -0
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/session.ts +215 -0
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/tool-dispatch.ts +215 -0
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/tool-schemas.ts +400 -0
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/upload-tool.ts +66 -0
- package/runtime/node_modules/@metro-labs/daemon/src/monitor/api.ts +237 -0
- package/runtime/node_modules/@metro-labs/daemon/src/net/tunnel.ts +389 -0
- package/runtime/node_modules/@metro-labs/daemon/src/routes/http.ts +390 -0
- package/runtime/node_modules/@metro-labs/daemon/src/routes/identity.ts +54 -0
- package/runtime/node_modules/@metro-labs/daemon/src/routes/local-mode.ts +187 -0
- package/runtime/node_modules/@metro-labs/daemon/src/routes/session-apis.ts +60 -0
- package/runtime/node_modules/@metro-labs/daemon/src/routes/session.ts +29 -0
- package/runtime/node_modules/@metro-labs/daemon/src/server/control.ts +64 -0
- package/runtime/node_modules/@metro-labs/daemon/src/server/machine.ts +61 -0
- package/runtime/node_modules/@metro-labs/daemon/src/server/update.ts +116 -0
- package/runtime/node_modules/@metro-labs/daemon/src/server.ts +2 -0
- package/runtime/node_modules/@metro-labs/daemon/src/stations/attach-inline.ts +100 -0
- package/runtime/node_modules/@metro-labs/daemon/src/stations/attach-interactive.ts +161 -0
- package/runtime/node_modules/@metro-labs/daemon/src/stations/attach-resolve.ts +202 -0
- package/runtime/node_modules/@metro-labs/daemon/src/stations/attach-session.ts +280 -0
- package/runtime/node_modules/@metro-labs/daemon/src/stations/attach-xmtp.ts +111 -0
- package/runtime/node_modules/@metro-labs/daemon/src/stations/attach.ts +184 -0
- package/runtime/node_modules/@metro-labs/daemon/src/stations/materialize.ts +248 -0
- package/runtime/node_modules/@metro-labs/daemon/src/stations/registry.ts +35 -0
- package/runtime/node_modules/@metro-labs/daemon/src/stations/runtime-deps.ts +82 -0
- package/runtime/node_modules/@metro-labs/daemon/src/stations/supervisor-io.ts +97 -0
- package/runtime/node_modules/@metro-labs/daemon/src/stations/supervisor.ts +320 -0
- package/runtime/node_modules/@metro-labs/daemon/src/stations/train-call.ts +22 -0
- package/runtime/node_modules/@metro-labs/daemon/src/terminal/api.ts +71 -0
- package/runtime/node_modules/@metro-labs/daemon/src/terminal/socket.ts +123 -0
- package/runtime/node_modules/@metro-labs/daemon/src/terminal/tickets.ts +40 -0
- package/runtime/node_modules/@metro-labs/discord-bot/package.json +28 -0
- package/runtime/node_modules/@metro-labs/discord-bot/src/accounts.ts +118 -0
- package/runtime/node_modules/@metro-labs/discord-bot/src/actions.ts +388 -0
- package/runtime/node_modules/@metro-labs/discord-bot/src/api-base.ts +1 -0
- package/runtime/node_modules/@metro-labs/discord-bot/src/attachments.ts +29 -0
- package/runtime/node_modules/@metro-labs/discord-bot/src/format.ts +220 -0
- package/runtime/node_modules/@metro-labs/discord-bot/src/group-actions.ts +50 -0
- package/runtime/node_modules/@metro-labs/discord-bot/src/group.ts +115 -0
- package/runtime/node_modules/@metro-labs/discord-bot/src/index.ts +127 -0
- package/runtime/node_modules/@metro-labs/discord-bot/src/members.ts +215 -0
- package/runtime/node_modules/@metro-labs/discord-bot/src/send-files.ts +43 -0
- package/runtime/node_modules/@metro-labs/discord-bot/src/station.ts +19 -0
- package/runtime/node_modules/@metro-labs/discord-bot/src/verify.ts +82 -0
- package/runtime/node_modules/@metro-labs/discord-bot/src/voice-speak.ts +195 -0
- package/runtime/node_modules/@metro-labs/discord-bot/src/voice-transcribe.ts +292 -0
- package/runtime/node_modules/@metro-labs/discord-bot/src/voice.ts +197 -0
- package/runtime/node_modules/@metro-labs/discord-bot/src/wire.ts +5 -0
- package/runtime/node_modules/@metro-labs/http/package.json +33 -0
- package/runtime/node_modules/@metro-labs/http/src/api-error.ts +8 -0
- package/runtime/node_modules/@metro-labs/http/src/api-http.ts +95 -0
- package/runtime/node_modules/@metro-labs/http/src/cors.ts +29 -0
- package/runtime/node_modules/@metro-labs/http/src/identity-key.ts +33 -0
- package/runtime/node_modules/@metro-labs/http/src/identity-registry.ts +13 -0
- package/runtime/node_modules/@metro-labs/http/src/mode-api.ts +32 -0
- package/runtime/node_modules/@metro-labs/http/src/return-to.ts +21 -0
- package/runtime/node_modules/@metro-labs/http/src/signed-identity.ts +36 -0
- package/runtime/node_modules/@metro-labs/telegram/package.json +26 -0
- package/runtime/node_modules/@metro-labs/telegram/src/accounts.ts +80 -0
- package/runtime/node_modules/@metro-labs/telegram/src/actions.ts +254 -0
- package/runtime/node_modules/@metro-labs/telegram/src/attachments.ts +87 -0
- package/runtime/node_modules/@metro-labs/telegram/src/client.ts +77 -0
- package/runtime/node_modules/@metro-labs/telegram/src/format.ts +156 -0
- package/runtime/node_modules/@metro-labs/telegram/src/group.ts +261 -0
- package/runtime/node_modules/@metro-labs/telegram/src/history.ts +52 -0
- package/runtime/node_modules/@metro-labs/telegram/src/inbound.ts +78 -0
- package/runtime/node_modules/@metro-labs/telegram/src/index.ts +46 -0
- package/runtime/node_modules/@metro-labs/telegram/src/login.ts +166 -0
- package/runtime/node_modules/@metro-labs/telegram/src/media-actions.ts +80 -0
- package/runtime/node_modules/@metro-labs/telegram/src/members.ts +75 -0
- package/runtime/node_modules/@metro-labs/telegram/src/normalize.ts +22 -0
- package/runtime/node_modules/@metro-labs/telegram/src/reactions.ts +167 -0
- package/runtime/node_modules/@metro-labs/telegram/src/station.ts +24 -0
- package/runtime/node_modules/@metro-labs/telegram/src/types.ts +7 -0
- package/runtime/node_modules/@metro-labs/telegram/src/wire.ts +1 -0
- package/runtime/node_modules/@metro-labs/telegram-bot/package.json +25 -0
- package/runtime/node_modules/@metro-labs/telegram-bot/src/accounts.ts +120 -0
- package/runtime/node_modules/@metro-labs/telegram-bot/src/actions.ts +295 -0
- package/runtime/node_modules/@metro-labs/telegram-bot/src/attachments.ts +128 -0
- package/runtime/node_modules/@metro-labs/telegram-bot/src/format.ts +201 -0
- package/runtime/node_modules/@metro-labs/telegram-bot/src/index.ts +109 -0
- package/runtime/node_modules/@metro-labs/telegram-bot/src/media-actions.ts +166 -0
- package/runtime/node_modules/@metro-labs/telegram-bot/src/members.ts +47 -0
- package/runtime/node_modules/@metro-labs/telegram-bot/src/station.ts +17 -0
- package/runtime/node_modules/@metro-labs/telegram-bot/src/types.ts +58 -0
- package/runtime/node_modules/@metro-labs/telegram-bot/src/verify.ts +38 -0
- package/runtime/node_modules/@metro-labs/telegram-bot/src/wire.ts +3 -0
- package/runtime/node_modules/@metro-labs/webhook/package.json +23 -0
- package/runtime/node_modules/@metro-labs/webhook/src/station.ts +37 -0
- package/runtime/node_modules/@metro-labs/whatsapp/package.json +27 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/accounts.ts +66 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/ack.ts +101 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/actions.ts +178 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/attachments.ts +72 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/auth-state.ts +129 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/client.ts +327 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/delivery.ts +49 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/format.ts +138 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/inbound.ts +57 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/index.ts +40 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/keys.ts +59 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/logger.ts +60 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/login.ts +176 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/media.ts +84 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/normalize.ts +22 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/outbox.ts +38 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/parse.ts +185 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/station.ts +17 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/token-store.ts +98 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/types.ts +6 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/wire.ts +5 -0
- package/runtime/node_modules/@metro-labs/xmtp/package.json +33 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/accounts.ts +112 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/actions-close.ts +110 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/actions-conv.ts +299 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/actions-meta.ts +157 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/actions-push.ts +87 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/actions.ts +375 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/attachments.ts +107 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/codecs.ts +171 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/conv-helpers.ts +239 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/emit-core.ts +55 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/emit-payloads.ts +335 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/emit.ts +80 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/group-members.ts +34 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/group.ts +56 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/identity.ts +33 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/index.ts +125 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/labels.ts +157 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/member-args.ts +40 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/push.ts +349 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/station.ts +13 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/tools-handlers.ts +126 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/tools.ts +212 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/transcribe.ts +90 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/verify.ts +84 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/wire.ts +53 -0
- package/runtime/runtime.json +3 -0
- package/runtime/server.ts +1 -0
- package/runtime/stations.json +36 -0
- package/runtime/trains/.keep +0 -0
- package/LICENSE +0 -21
- package/README.md +0 -249
- package/dist/cache.js +0 -75
- package/dist/cli/actions.js +0 -139
- package/dist/cli/config.js +0 -185
- package/dist/cli/index.js +0 -177
- package/dist/cli/skill.js +0 -62
- package/dist/cli/util.js +0 -72
- package/dist/cli/webhook.js +0 -83
- package/dist/codex-rc.js +0 -245
- package/dist/dispatcher.js +0 -122
- package/dist/history.js +0 -99
- package/dist/ipc.js +0 -72
- package/dist/log.js +0 -15
- package/dist/paths.js +0 -68
- package/dist/registry.js +0 -48
- package/dist/stations/claude.js +0 -45
- package/dist/stations/codex.js +0 -68
- package/dist/stations/discord.js +0 -200
- package/dist/stations/index.js +0 -133
- package/dist/stations/telegram-md.js +0 -34
- package/dist/stations/telegram-upload.js +0 -113
- package/dist/stations/telegram.js +0 -213
- package/dist/stations/webhook.js +0 -100
- package/dist/tunnel.js +0 -49
- package/dist/webhooks.js +0 -40
- package/docs/agents.md +0 -216
- package/docs/uri-scheme.md +0 -125
- package/skills/metro/SKILL.md +0 -249
package/docs/agents.md
DELETED
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
# Metro: a guide for coding agents
|
|
2
|
-
|
|
3
|
-
You are running inside a session that has **launched `metro`** in the background. Metro emits a live stream of JSON events from Discord, Telegram, third-party webhooks (GitHub, Intercom, …), and other agents on its stdout. Your job is to consume that stream and post replies back via subcommands.
|
|
4
|
-
|
|
5
|
-
## Starting the bridge
|
|
6
|
-
|
|
7
|
-
The launch mechanics differ by runtime — pick the one that matches yours.
|
|
8
|
-
|
|
9
|
-
### Claude Code
|
|
10
|
-
|
|
11
|
-
```
|
|
12
|
-
Bash(command: "metro", run_in_background: true)
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
Then attach `Monitor` to its stdout. Each line is one JSON event you act on.
|
|
16
|
-
|
|
17
|
-
### Codex
|
|
18
|
-
|
|
19
|
-
```
|
|
20
|
-
shell(command: "METRO_CODEX_RC=ws://127.0.0.1:8421 metro", run_in_background: true)
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
Don't watch its stdout — Codex has no Monitor equivalent. Metro pushes each event into your thread via JSON-RPC `turn/start`, so events arrive as user input on your next turn. The user must have a daemon and TUI running for this to work:
|
|
24
|
-
|
|
25
|
-
```
|
|
26
|
-
codex app-server --listen ws://127.0.0.1:8421 # daemon (terminal 1)
|
|
27
|
-
codex --remote ws://127.0.0.1:8421 # TUI (this session — terminal 2)
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
Run `metro doctor` if anything seems off.
|
|
31
|
-
|
|
32
|
-
## Event shape
|
|
33
|
-
|
|
34
|
-
Every event is a **history entry** — the same record that's appended to `history.jsonl`. Fields: `kind` (`inbound`/`notification`/`outbound`/`edit`/`react`), `id` (`msg_…`), `ts`, `station`, `line` (conversation), `lineName?`, `from` (participant URI), `fromName?`, `to`, `text`, `messageId?` (platform-side id; inbound/outbound only), `payload?` (raw platform message; inbound only).
|
|
35
|
-
|
|
36
|
-
```json
|
|
37
|
-
{"kind":"inbound","id":"msg_aB3xY7zP","ts":"2026-05-14T12:00:00Z","station":"telegram","line":"metro://telegram/-100…/247","lineName":"infra","from":"metro://telegram/user/12345","fromName":"@alice","to":"metro://claude/user/9bfc7af0-…","messageId":"4567","text":"hello [image]","payload":{"message_id":4567,"chat":{"id":-100,"type":"supergroup","is_forum":true},"from":{"id":12345,"username":"alice"},"text":"hello","entities":[{"type":"mention","offset":0,"length":6}],"photo":[{"file_id":"…"}],"reply_to_message":{"message_id":4500,"text":"earlier","from":{"id":99,"username":"bob"}}}}
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
```json
|
|
41
|
-
{"kind":"notification","id":"msg_pQ4r5sT0","ts":"…","station":"claude","line":"metro://claude/9bfc7af0-…/50b00d11-…","from":"metro://codex/user/8119ecb1-…","to":"metro://claude/9bfc7af0-…/50b00d11-…","text":"deploy succeeded"}
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
### `payload` by station
|
|
45
|
-
|
|
46
|
-
`payload` is the platform's native message shape. Narrow on `event.station`:
|
|
47
|
-
|
|
48
|
-
- **`discord`** — discord.js `Message.toJSON()`: camelCase fields (`channelId`, `guildId`, `content`, `author`, `mentions: { users[], roles[], everyone }`, `attachments[]`, `reference`, …). Collections come back as **arrays of IDs**. `referencedMessage` (also `toJSON()`-shaped) is added inline on replies (auto-fetched).
|
|
49
|
-
- **`telegram`** — raw Bot API `Message` (snake_case): `{ message_id, chat, from, text, caption, entities[], photo[], document, voice, audio, reply_to_message, … }`. `reply_to_message` is inline on replies.
|
|
50
|
-
- **`webhook`** — `{ headers: Record<string,string>, body: <parsed JSON | raw string> }`. Narrow further on the provider — GitHub sets `headers['x-github-event']` (`push`, `pull_request`, `issues`, …) and includes a `repository`/`sender` in body; Intercom sets `x-intercom-topic` etc. `text` is a short summary; full event is always in `payload.body`.
|
|
51
|
-
|
|
52
|
-
Use `payload` for anything the envelope doesn't surface — mentions, reply chains, embeds, stickers, entities.
|
|
53
|
-
|
|
54
|
-
Both `from` and `to` are **participant URIs** (the conversation lives in `line`): `metro://<station>/user/<id>` for a person, `metro://claude/user/<orgId>` for a Claude Code agent (orgId = stable Anthropic-account UUID), `metro://codex/user/<accountId>` for a Codex agent (accountId = stable ChatGPT-account UUID), `metro://<station>/<channelId>` as a fallback `to` when sending to a group with no single recipient.
|
|
55
|
-
|
|
56
|
-
When **you** call `metro send`/`reply`/`edit`/`react`, metro auto-stamps `from` to your runtime — `metro://claude/user/<orgId>` (when `$CLAUDECODE` is set; orgId comes from `claude auth status --json`) or `metro://codex/user/<accountId>` (when `$METRO_CODEX_RC`/`$CODEX_HOME` is set; accountId comes from `$CODEX_HOME/auth.json`, `tokens.account_id`). Both identities are account-scoped, not install-scoped: switch accounts with `claude auth login` / `codex login` and the next event uses the new id (within ~5 s for the daemon, immediately for one-shot CLI calls). Override with `--from=<uri>` or `$METRO_FROM`. When replying/reacting, `to` is auto-set to the original sender (history lookup).
|
|
57
|
-
|
|
58
|
-
- `kind: "inbound"` — a human (or another bot) posted on a chat platform **or a third-party service POSTed to a registered webhook endpoint** (`station: "webhook"`, `payload: { headers, body }`).
|
|
59
|
-
- `kind: "notification"` — another agent called `metro send` against your agent line. This is how Codex pings Claude Code and vice versa.
|
|
60
|
-
|
|
61
|
-
`text` may include `[image]` / `[voice]` / `[audio]` / `[file: <name>]` placeholders alongside the real text — non-image attachments are opaque markers, images can be materialized via `metro download`.
|
|
62
|
-
|
|
63
|
-
## Required flow on every event
|
|
64
|
-
|
|
65
|
-
1. **Echo the event** to your visible output: `[<line>#<messageId>] <text>`. Both Monitor and Codex collapse tool output, so this echo is the only thing the user sees without expanding cards.
|
|
66
|
-
2. **Decide and act** using the subcommands below.
|
|
67
|
-
|
|
68
|
-
## Detecting "is this for me?"
|
|
69
|
-
|
|
70
|
-
Derive from `payload`. Bot id per station is in `$METRO_STATE_DIR/bot-ids.json` (`{discord:"<userId>", telegram:"<userId>"}`).
|
|
71
|
-
|
|
72
|
-
- **`discord`** — DM if `payload.guildId == null`; otherwise pinged if `payload.mentions.users.includes(<bot-id>)`.
|
|
73
|
-
- **`telegram`** — DM if `payload.chat.type === 'private'`; otherwise pinged if any entity in `payload.entities` (or `caption_entities`) is `{type:"mention"}` matching `@<bot-username>`, or `{type:"text_mention", user:{id:<bot-id>}}`.
|
|
74
|
-
- **`webhook`** — every POST is for you (you registered the endpoint). Route on `payload.headers['x-github-event']` / `x-intercom-topic` etc. to know which provider event it is.
|
|
75
|
-
|
|
76
|
-
Default for chat: only reply on DM or ping; otherwise stay silent or `metro react` to ack. Webhooks just consume — no ack mechanism.
|
|
77
|
-
|
|
78
|
-
## Subcommands
|
|
79
|
-
|
|
80
|
-
| Action | Command |
|
|
81
|
-
|---|---|
|
|
82
|
-
| Quote-reply (threads under original) | `metro reply <line> <messageId> <text>` |
|
|
83
|
-
| Send a fresh message (no reply context) | `metro send <line> <text>` |
|
|
84
|
-
| Edit a message you previously sent | `metro edit <line> <messageId> <text>` |
|
|
85
|
-
| Reaction (empty emoji clears it) | `metro react <line> <messageId> <emoji>` |
|
|
86
|
-
| Download `[image]` attachments | `metro download <line> <messageId> [--out=<dir>]` |
|
|
87
|
-
| Recent-message lookback (Discord only) | `metro fetch <line> [--limit=20]` |
|
|
88
|
-
| Cross-agent ping | `metro send <agent-line> <text> [--from=<line>]` |
|
|
89
|
-
| Register webhook endpoint | `metro webhook add <label> [--secret=<hmac-secret>]` |
|
|
90
|
-
| List / remove webhook endpoints | `metro webhook list` · `metro webhook remove <id>` |
|
|
91
|
-
| Configure Cloudflare named tunnel | `metro tunnel setup <tunnel-name> <hostname>` |
|
|
92
|
-
|
|
93
|
-
`reply` / `send` / `edit` accept multi-line text via stdin (heredoc). Webhooks are receive-only — there's no `reply` for them, just consume the event.
|
|
94
|
-
|
|
95
|
-
### Rich content flags
|
|
96
|
-
|
|
97
|
-
`send` and `reply` accept these flags; `edit` accepts `--buttons` only.
|
|
98
|
-
|
|
99
|
-
- `--image=<path>` — local image. **Repeatable** for albums: `--image=a.png --image=b.png` (or comma-separated). Up to 10 / message. Text becomes the caption (on the first image for albums).
|
|
100
|
-
- `--document=<path>` — local file (PDF, log, csv, …). Same repeat/comma syntax.
|
|
101
|
-
- `--voice=<path>` — single voice message (`.ogg` Opus or `.mp3`). On Telegram renders as a voice bubble; on Discord uploaded as audio attachment.
|
|
102
|
-
- `--buttons='[[{"text":"…","url":"…"}]]'` — inline URL-button keyboard (2D rows × buttons). Pass `'[]'` to `edit` to clear.
|
|
103
|
-
|
|
104
|
-
```bash
|
|
105
|
-
metro send <line> "screenshot" --image=/tmp/build.png
|
|
106
|
-
metro send <line> "before/after" --image=/tmp/before.png --image=/tmp/after.png
|
|
107
|
-
metro reply <line> <id> "voice note" --voice=/tmp/note.ogg
|
|
108
|
-
metro send <line> "approve?" --buttons='[[{"text":"Open PR","url":"https://github.com/x/y/pull/1"}]]'
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
Limits: 20 MB / file. Telegram albums are single-type (photos OR documents per album); mixing kinds still works — metro splits into two messages. Buttons are dropped on multi-attachment Telegram sends. URL buttons only for now.
|
|
112
|
-
|
|
113
|
-
Append `--json` to any command for a single JSON line you can parse.
|
|
114
|
-
|
|
115
|
-
## When to use `reply` vs `send`
|
|
116
|
-
|
|
117
|
-
- **`reply`** — responding to a specific inbound message. Threads under it. Default when handling an `inbound` event.
|
|
118
|
-
- **`send`** — initiating without a triggering message: a long task you kicked off finished, a follow-up the user asked you to deliver later, or posting to an agent line (`metro://claude/...`, `metro://codex/...`) to notify a peer.
|
|
119
|
-
|
|
120
|
-
## Universal message IDs
|
|
121
|
-
|
|
122
|
-
The `id` field on every event and `metro history` row is metro's **universal ID** (`msg_<8 chars>`). It works anywhere a `<message_id>` is expected — `metro reply`, `edit`, `react`, `download` — and resolves to the platform's own id via the history file. Use it for chaining commands or referring back across stations.
|
|
123
|
-
|
|
124
|
-
## `metro history` — read the universal message log
|
|
125
|
-
|
|
126
|
-
Every inbound, outbound, edit, react, and notification is appended to `$METRO_STATE_DIR/history.jsonl` automatically.
|
|
127
|
-
|
|
128
|
-
```bash
|
|
129
|
-
metro history --limit=20 # recent 20, newest first
|
|
130
|
-
metro history --line=metro://discord/123 # only this conversation
|
|
131
|
-
metro history --kind=inbound --since=2026-05-14 # inbounds since that day
|
|
132
|
-
metro history --station=telegram --text=deploy # all Telegram entries containing "deploy"
|
|
133
|
-
metro history --from='@alice' --json # everything from alice, JSON
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
Filters: `--limit` (default 50), `--line`, `--station`, `--kind` (`inbound`/`outbound`/`edit`/`react`/`notification`), `--from`, `--text`, `--since` (ISO), `--json`.
|
|
137
|
-
|
|
138
|
-
## Discovery
|
|
139
|
-
|
|
140
|
-
### `metro lines`
|
|
141
|
-
|
|
142
|
-
```
|
|
143
|
-
$ metro lines
|
|
144
|
-
2m ago metro://discord/1234567890 infra
|
|
145
|
-
5m ago metro://telegram/-100123/42 design-review
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
Lines sorted by recency. Use when the user says "the Telegram channel" or "that PR thread."
|
|
149
|
-
|
|
150
|
-
### `metro stations`
|
|
151
|
-
|
|
152
|
-
```
|
|
153
|
-
$ metro stations
|
|
154
|
-
✓ discord chat in: text+image · out: text · features: reply, send, edit, react, download, fetch
|
|
155
|
-
DISCORD_BOT_TOKEN
|
|
156
|
-
✓ telegram chat in: text+image · out: text · features: reply, send, edit, react, download, fetch
|
|
157
|
-
TELEGRAM_BOT_TOKEN
|
|
158
|
-
✓ claude agent in: text · out: text · features: send, notify
|
|
159
|
-
account: 9bfc7af0-… · seen 1 agent, 2 sessions
|
|
160
|
-
seen: 9bfc7af0-… · sessions: 2
|
|
161
|
-
✗ codex agent in: text · out: text · features: send, notify
|
|
162
|
-
set METRO_CODEX_RC=ws://… to push
|
|
163
|
-
✓ webhook service in: text · out: – · features: –
|
|
164
|
-
2 endpoints · base https://webhook.example.com
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
`✓` = ready (env/runtime detected), `✗` = configured-but-broken or runtime not detected, `·` = informational. The detail line under each agent row shows the resolved account id plus the per-agent count of sessions metro has observed — pull addressable agent lines from those.
|
|
168
|
-
|
|
169
|
-
## Webhooks (receiving HTTP events)
|
|
170
|
-
|
|
171
|
-
When the user wants metro to receive events from a third-party service (GitHub PRs, Intercom conversations, Fireflies meetings, …):
|
|
172
|
-
|
|
173
|
-
1. **One-time tunnel setup** (only needed once per machine): `metro tunnel setup <tunnel-name> <hostname>`. Requires `cloudflared` on PATH (`brew install cloudflared`) and a Cloudflare account + domain on Cloudflare DNS. Run `cloudflared tunnel login` first if you haven't.
|
|
174
|
-
2. **Register an endpoint**: `metro webhook add <label> [--secret=<shared-secret>]`. Prints the public URL — paste it into the provider's webhook settings. For GitHub specifically, set **Content type: `application/json`** (form-encoded won't parse into `payload.body`).
|
|
175
|
-
3. **Run the daemon**: `metro`. With at least one endpoint registered, metro auto-binds the HTTP listener (port 8420, override `METRO_WEBHOOK_PORT`) and spawns `cloudflared tunnel run` if `tunnel.json` exists.
|
|
176
|
-
|
|
177
|
-
Each POST becomes an inbound event:
|
|
178
|
-
|
|
179
|
-
```json
|
|
180
|
-
{"kind":"inbound","station":"webhook","line":"metro://webhook/<id>","lineName":"github",
|
|
181
|
-
"from":"metro://webhook/<id>","to":"metro://claude/user/<orgId>",
|
|
182
|
-
"messageId":"<x-github-delivery>","text":"push POST /wh/<id>",
|
|
183
|
-
"payload":{"headers":{"x-github-event":"push",…},"body":{"ref":"refs/heads/main",…}}}
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
`text` is a short summary; the real event lives in `payload.body`. Use `payload.headers['x-github-event']` (or `x-intercom-topic` etc.) to narrow on provider event type. If you set `--secret`, metro verifies `X-Hub-Signature-256` and rejects bad signatures with 401 — agents see only authenticated events.
|
|
187
|
-
|
|
188
|
-
## Image attachments
|
|
189
|
-
|
|
190
|
-
When an inbound has an `[image]` tag in `text`:
|
|
191
|
-
|
|
192
|
-
1. `metro download <line> <messageId>` → prints absolute paths.
|
|
193
|
-
2. `Read` each path with your `Read` tool — the image enters your context as a vision input.
|
|
194
|
-
3. Reply normally via `metro reply`.
|
|
195
|
-
|
|
196
|
-
## Cross-agent notification
|
|
197
|
-
|
|
198
|
-
Both agents can post to each other's **agent line** — `metro://claude/<agent-id>/<session-id>` or `metro://codex/<agent-id>/<session-id>`. `<agent-id>` is the peer's stable account id (cross-device); `<session-id>` is one conversation. Discover both by running `metro stations` (which lists every agent + session metro has seen), or by reading `$METRO_STATE_DIR/agent-registry.json` directly. The daemon re-emits the post on its stdout stream (and pushes via codex-rc if configured), so the peer agent sees it as a notification:
|
|
199
|
-
|
|
200
|
-
```bash
|
|
201
|
-
metro send metro://claude/9bfc7af0-…/50b00d11-… "build green, ready to ship"
|
|
202
|
-
metro send metro://claude/9bfc7af0-…/50b00d11-… "build green" --from=metro://codex/user/8119ecb1-… # override sender
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
This requires the metro daemon to be running on the machine. Without a daemon, agent-line sends error with a clear message.
|
|
206
|
-
|
|
207
|
-
## Don'ts
|
|
208
|
-
|
|
209
|
-
- ❌ Spawning a second metro daemon — there's one per machine (lockfile-enforced).
|
|
210
|
-
- ❌ `metro send` to a line that isn't in `metro lines` unless the user gave it to you explicitly.
|
|
211
|
-
- ❌ Narrating the tool ("I'll now use metro reply to…"). The tool call is already visible.
|
|
212
|
-
|
|
213
|
-
## Further reading
|
|
214
|
-
|
|
215
|
-
- URI scheme: [`uri-scheme.md`](uri-scheme.md)
|
|
216
|
-
- Source: https://github.com/bonustrack/metro
|
package/docs/uri-scheme.md
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
# Metro URI scheme
|
|
2
|
-
|
|
3
|
-
Universal identifier for every conversational scope and notification sink in metro. Lines pass around as opaque strings; only the owning station parses its own paths.
|
|
4
|
-
|
|
5
|
-
## Grammar
|
|
6
|
-
|
|
7
|
-
```
|
|
8
|
-
line = "metro://" station "/" path
|
|
9
|
-
station = lowercase identifier (claude | codex | discord | telegram | webhook | …)
|
|
10
|
-
path = station-specific, "/"-separated segments
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
The URI parses cleanly with the WHATWG `URL` parser: `new URL(line)` gives `protocol="metro:"`, `host=<station>`, `pathname="/<path>"`.
|
|
14
|
-
|
|
15
|
-
## Registered stations
|
|
16
|
-
|
|
17
|
-
| Station | Kind | Pattern | Example |
|
|
18
|
-
|------------|---------|----------------------------------------------|------------------------------------------------------------------------|
|
|
19
|
-
| `discord` | chat | `metro://discord/<channel-id>` | `metro://discord/1234567890123456789` |
|
|
20
|
-
| `telegram` | chat | `metro://telegram/<chat-id>[/<topic-id>]` | `metro://telegram/-1001234567890/42` |
|
|
21
|
-
| `claude` | agent | `metro://claude/<agent-id>/<session-id>` | `metro://claude/9bfc7af0-…/50b00d11-…` |
|
|
22
|
-
| `codex` | agent | `metro://codex/<agent-id>/<session-id>` | `metro://codex/8119ecb1-…/01997d4b-…` |
|
|
23
|
-
| `webhook` | service | `metro://webhook/<endpoint-id>` | `metro://webhook/fwaCgTKJuLAjS2K0` |
|
|
24
|
-
|
|
25
|
-
Agent lines mirror the `<root>/<sub>` structure of `metro://telegram/<chat-id>/<topic-id>`: `<agent-id>` (the user's stable account id — same across devices) plays the role of `<chat-id>`, and `<session-id>` (one conversation) plays the role of `<topic-id>`. Both segments are derived per station (see [participants](#participants) below).
|
|
26
|
-
|
|
27
|
-
## Participants
|
|
28
|
-
|
|
29
|
-
Every chat station also exposes participant URIs — used as `from` on inbound/outbound events and history rows.
|
|
30
|
-
|
|
31
|
-
| Kind | Pattern | Example |
|
|
32
|
-
|--------|----------------------------------|---------------------------------------------------------------|
|
|
33
|
-
| user | `metro://<station>/user/<id>` | `metro://discord/user/87654321` |
|
|
34
|
-
| claude | `metro://claude/user/<orgId>` | `metro://claude/user/9bfc7af0-2117-44c5-baf2-d22ba382d065` |
|
|
35
|
-
| codex | `metro://codex/user/<accountId>` | `metro://codex/user/8119ecb1-b05e-48db-aa80-434584439df9` |
|
|
36
|
-
| webhook | `metro://webhook/<endpointId>` | `metro://webhook/fwaCgTKJuLAjS2K0` (line + `from` are the same — no HTTP-side user identity) |
|
|
37
|
-
|
|
38
|
-
`from` and `to` on history entries are always participant URIs. Discord/Telegram inbounds set `from` to the user URI; the daemon sets `to` to the agent identity:
|
|
39
|
-
|
|
40
|
-
- **Claude Code** (`$CLAUDECODE` set) — `metro://claude/user/<orgId>`. `<orgId>` is the stable Anthropic-account UUID, resolved by shelling out to `claude auth status --json`.
|
|
41
|
-
- **Codex** (`$METRO_CODEX_RC` or `$CODEX_HOME` set) — `metro://codex/user/<accountId>`. `<accountId>` is the ChatGPT-account UUID, read from `$CODEX_HOME/auth.json` (default `~/.codex/auth.json`) at the `tokens.account_id` field. Requires `auth_mode=chatgpt`; API-key-only Codex sessions have no account id and metro will error.
|
|
42
|
-
- **Neither** — `to` is the generic `metro://agent`.
|
|
43
|
-
|
|
44
|
-
Same account on any machine yields the same URI. Switching accounts via `claude auth login` / `codex login` flips the URI within ~5 s for the long-lived daemon (5 s TTL cache); one-shot CLI invocations re-resolve every run. On outbound, `from` = the same agent identity; `to` = the original sender for replies/reacts (looked up from history), or the channel `line` for fresh group sends. A `fromName` field carries the display name (`@alice`, `bonustrack_`).
|
|
45
|
-
|
|
46
|
-
Override with `--from=<uri>` on any write command, or set `$METRO_FROM` to pin a custom identity for the whole session.
|
|
47
|
-
|
|
48
|
-
Chat lines identify a Discord channel / Telegram chat (with optional forum topic). Agent lines now identify a *specific session* of a specific agent (`<agent-id>/<session-id>`) — posting to one re-emits the message on the daemon's stdout stream and (if configured) pushes it to the Codex app-server. They have no inherent "messages"; only events.
|
|
49
|
-
|
|
50
|
-
### Session derivation per station
|
|
51
|
-
|
|
52
|
-
| Station | `<agent-id>` | `<session-id>` |
|
|
53
|
-
|----------|----------------------------|-----------------------------------------------------------------|
|
|
54
|
-
| `claude` | `orgId` from `claude auth status --json` | `$CLAUDE_CODE_SESSION_ID` (set by Claude Code; stable across `--resume`)|
|
|
55
|
-
| `codex` | `tokens.account_id` from `$CODEX_HOME/auth.json` | codex-rc thread id from the JSON-RPC handshake (`thread/loaded/list` → `thread/start`) |
|
|
56
|
-
|
|
57
|
-
Override either segment with `METRO_AGENT_ID` / `METRO_AGENT_SESSION_ID` env vars.
|
|
58
|
-
|
|
59
|
-
### Agent registry
|
|
60
|
-
|
|
61
|
-
The daemon persists every `(station, agent-id, session)` tuple it sees to `$METRO_STATE_DIR/agent-registry.json`. `metro stations` prints the count of seen agents and sessions per station. Run it to discover what's reachable rather than guessing topic names.
|
|
62
|
-
|
|
63
|
-
## Webhook station
|
|
64
|
-
|
|
65
|
-
Receive-only HTTP endpoint for third-party services (GitHub, Intercom, Fireflies, …). Each registered endpoint is one `metro://webhook/<endpoint-id>` line.
|
|
66
|
-
|
|
67
|
-
- **Register:** `metro webhook add <label> [--secret=<shared-secret>]` mints a 16-char endpoint id (96 bits of entropy, persisted to `$METRO_STATE_DIR/webhooks.json`) and prints the receiving URL. `metro webhook list` / `remove <id>` for the obvious.
|
|
68
|
-
- **Listener:** the dispatcher binds `127.0.0.1:8420` (override with `METRO_WEBHOOK_PORT`) when ≥1 endpoint is registered. Routes `POST /wh/<endpoint-id>` to an inbound event with `payload: { headers, body }` — `body` is parsed JSON when the request `Content-Type` is JSON, raw string otherwise. `GET /wh/<endpoint-id>` returns 200 (for provider ping checks).
|
|
69
|
-
- **Envelope:** `messageId` falls back to `X-GitHub-Delivery` / `X-Request-ID` / a generated UUID for idempotency tracking. `text` is synthesized from `X-GitHub-Event` / `X-Intercom-Topic` plus method + path for at-a-glance routing; agents narrow on `payload.body` for full event details.
|
|
70
|
-
- **HMAC verification:** if `--secret` was set on `metro webhook add`, requests must include a matching `X-Hub-Signature-256: sha256=<hex>` (GitHub/Intercom format) — mismatches are rejected with 401 before reaching the stream.
|
|
71
|
-
- **Public reachability:** provided by a Cloudflare named tunnel — see [Tunneling](#tunneling) below. Without one, the listener stays loopback-only (useful for `curl` testing).
|
|
72
|
-
|
|
73
|
-
## Tunneling
|
|
74
|
-
|
|
75
|
-
Webhook providers need a public URL. Metro integrates with **Cloudflare named tunnels** (free, stable, account-scoped):
|
|
76
|
-
|
|
77
|
-
```bash
|
|
78
|
-
cloudflared tunnel login # one-time OAuth (browser)
|
|
79
|
-
metro tunnel setup metro webhook.yourdomain.com # creates the tunnel + DNS route
|
|
80
|
-
metro # daemon spawns `cloudflared tunnel run`
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
After setup, `metro webhook list` prints `https://webhook.yourdomain.com/wh/<id>` for each endpoint. The URL is stable across restarts (bound to the tunnel UUID in `~/.cloudflared/<uuid>.json`, not the cloudflared process). Tunnel config persists at `$METRO_STATE_DIR/tunnel.json`. Without setup, endpoints fall back to `http://127.0.0.1:8420/wh/<id>` (local-only, useful for curl testing).
|
|
84
|
-
|
|
85
|
-
## Message addressing
|
|
86
|
-
|
|
87
|
-
Messages on chat lines are referenced by **line + message id** (two args), not as part of the URI. So:
|
|
88
|
-
|
|
89
|
-
```bash
|
|
90
|
-
metro reply metro://discord/123… 4567 "ack"
|
|
91
|
-
metro edit metro://discord/123… 9876 "fixed typo"
|
|
92
|
-
metro react metro://telegram/-100…/42 4567 👍
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
## Properties
|
|
96
|
-
|
|
97
|
-
- **Stable**: a Line is valid for the lifetime of the scope.
|
|
98
|
-
- **Self-describing**: the station name is encoded; the dispatcher routes by station prefix.
|
|
99
|
-
- **Persistable**: safe as a JSON key on disk (used by `lines.json`).
|
|
100
|
-
- **Branded**: TypeScript type `Line` prevents mixing with arbitrary strings.
|
|
101
|
-
|
|
102
|
-
## API
|
|
103
|
-
|
|
104
|
-
```ts
|
|
105
|
-
import { Line } from './stations/index.js'; // value namespace + type
|
|
106
|
-
|
|
107
|
-
const l: Line = Line.discord('1234567890'); // typed Line
|
|
108
|
-
Line.parse(l); // { station: 'discord', path: ['1234567890'] } | null
|
|
109
|
-
Line.station(l); // 'discord'
|
|
110
|
-
Line.claude(orgId, sessionId); // metro://claude/<orgId>/<sessionId>
|
|
111
|
-
Line.codex(accountId, threadId); // metro://codex/<accountId>/<threadId>
|
|
112
|
-
Line.parseClaude(l); // { agentId, sessionId } | null
|
|
113
|
-
Line.parseCodex(l); // { agentId, sessionId } | null
|
|
114
|
-
Line.webhook(endpointId); // metro://webhook/<endpointId>
|
|
115
|
-
Line.parseWebhook(l); // string | null (the endpoint id)
|
|
116
|
-
Line.user(station, id); // metro://<station>/user/<id>
|
|
117
|
-
Line.bot(station, id); // metro://<station>/bot/<id>
|
|
118
|
-
Line.isAgent(l); // true for any metro://{claude,codex}/...
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
## Adding a new station
|
|
122
|
-
|
|
123
|
-
1. Pick a lowercase station name (`slack`, `matrix`, …).
|
|
124
|
-
2. Add a `Line.<station>(...)` formatter and a parser that returns your typed payload.
|
|
125
|
-
3. Document the path grammar in the table above.
|
package/skills/metro/SKILL.md
DELETED
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: metro
|
|
3
|
-
description: Run the metro Telegram/Discord/webhook bridge in this session — launch `metro` in the background, watch its stdout for inbound JSON events, and act on each. Use when the user asks to start/run/launch metro, when you see JSON lines on stdout shaped `{"kind":"inbound","station":...,"line":"metro://...","messageId":...,"text":...}`, or when handling a chat/webhook reply/edit/react/send/download/fetch/notify.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Metro — running the Telegram / Discord / webhook bridge
|
|
7
|
-
|
|
8
|
-
Metro is a CLI bridge between this agent session and external sources: Telegram, Discord, and HTTP webhooks from third parties (GitHub, Intercom, Fireflies, …). You launch `metro` once when the user asks, then act on each inbound JSON line via `metro <subcommand>`.
|
|
9
|
-
|
|
10
|
-
## Starting the bridge
|
|
11
|
-
|
|
12
|
-
When the user asks to run/start/launch metro:
|
|
13
|
-
|
|
14
|
-
### Claude Code
|
|
15
|
-
|
|
16
|
-
```
|
|
17
|
-
Bash(command: "metro", run_in_background: true)
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
Then attach `Monitor` to its stdout. Each line is one JSON event. Stderr is pino logs — don't act on it.
|
|
21
|
-
|
|
22
|
-
### Codex
|
|
23
|
-
|
|
24
|
-
```
|
|
25
|
-
shell(command: "METRO_CODEX_RC=ws://127.0.0.1:8421 metro", run_in_background: true)
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
Codex has no Monitor equivalent. Instead, metro pushes each event into your thread via JSON-RPC `turn/start`, so events arrive as user input on your next turn. The user must have a daemon + TUI running on the **same WebSocket URL**:
|
|
29
|
-
|
|
30
|
-
```
|
|
31
|
-
codex app-server --listen ws://127.0.0.1:8421 # daemon (terminal 1)
|
|
32
|
-
codex --remote ws://127.0.0.1:8421 # TUI (terminal 2) — type "hi" once to create a live thread
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
Then metro starts third. If metro exits immediately or you see `thread not found` retries on its stderr, the TUI didn't create a thread yet — tell the user to type something in the TUI.
|
|
36
|
-
|
|
37
|
-
### Diagnostics
|
|
38
|
-
|
|
39
|
-
If something seems off, run `metro doctor`. Common causes: missing tokens (`metro setup telegram <token>` / `metro setup discord <token>`), Discord Message Content Intent not toggled, stale lockfile, or (Codex) no live thread on the daemon.
|
|
40
|
-
|
|
41
|
-
## Event shape
|
|
42
|
-
|
|
43
|
-
Every line on stdout is one **history entry** — the same record appended to `history.jsonl`. Fields:
|
|
44
|
-
- `kind` — `"inbound"`, `"notification"`, `"outbound"`, `"edit"`, or `"react"`
|
|
45
|
-
- `id` (`msg_…`) — universal message ID minted by metro
|
|
46
|
-
- `ts` — ISO timestamp
|
|
47
|
-
- `station` — `"discord"`, `"telegram"`, `"claude"`, `"codex"`, `"webhook"`
|
|
48
|
-
- `line` — conversation URI; `lineName?` is the channel/topic display name (for webhooks: the label you gave it)
|
|
49
|
-
- `from` / `fromName?` — sender participant URI + optional display name
|
|
50
|
-
- `to` — recipient participant URI (agent for inbound, line for notification, original sender for replies/reacts)
|
|
51
|
-
- `text` — universal display projection. Includes `[image]`/`[file: …]`/`[voice]`/`[audio]` tags inline.
|
|
52
|
-
- `messageId?` — platform-side id (Discord snowflake, Telegram int). Set on inbound/outbound.
|
|
53
|
-
- `payload?` — raw platform-native message object. Set on inbound only. Shape varies per `station`.
|
|
54
|
-
|
|
55
|
-
```json
|
|
56
|
-
{"kind":"inbound","id":"msg_aB3xY7zP","ts":"2026-05-14T12:00:00Z","station":"telegram","line":"metro://telegram/-100…/247","lineName":"infra","from":"metro://telegram/user/12345","fromName":"@alice","to":"metro://claude/user/9bfc7af0-…","messageId":"4567","text":"hi [image]","payload":{"message_id":4567,"chat":{"id":-100,"type":"supergroup","is_forum":true},"from":{"id":12345,"username":"alice"},"text":"hi","photo":[{"file_id":"…"}],"reply_to_message":{"message_id":4500,"text":"earlier","from":{"id":99,"username":"bob"}}}}
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
```json
|
|
60
|
-
{"kind":"notification","id":"msg_pQ4r5sT0","ts":"…","station":"claude","line":"metro://claude/9bfc7af0-…/50b00d11-…","from":"metro://codex/user/8119ecb1-…","to":"metro://claude/9bfc7af0-…/50b00d11-…","text":"deploy green"}
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
### `payload` by station
|
|
64
|
-
|
|
65
|
-
`payload` is the platform's native message shape. Narrow on `event.station`:
|
|
66
|
-
|
|
67
|
-
- **`discord`** — discord.js `Message.toJSON()`: camelCase fields (`channelId`, `guildId`, `content`, `author`, `mentions: { users[], roles[], everyone }`, `attachments[]`, `reference`, …). Collections come back as **arrays of IDs**. `referencedMessage` is added inline on replies (auto-fetched).
|
|
68
|
-
- **`telegram`** — raw Bot API `Message` (snake_case): `{ message_id, chat, from, text, caption, entities[], photo[], document, voice, audio, reply_to_message, … }`. `reply_to_message` is inline on replies.
|
|
69
|
-
- **`webhook`** — `{ headers, body }`. The provider lives in `headers['x-github-event']`, `headers['x-intercom-topic']`, etc. Full event payload is `body` (parsed JSON when possible). `text` is a short summary; always narrow on `body` for real routing.
|
|
70
|
-
|
|
71
|
-
Use `payload` for anything the envelope doesn't surface — mentions, reply chains, embeds, entities.
|
|
72
|
-
|
|
73
|
-
## Detecting "is this for me?"
|
|
74
|
-
|
|
75
|
-
Derive from `payload`. Bot id per station is cached in `$METRO_STATE_DIR/bot-ids.json` (`{discord:"<userId>", telegram:"<userId>"}`, written by the daemon on start).
|
|
76
|
-
|
|
77
|
-
- **discord** — DM when `payload.guildId == null`; otherwise pinged when `payload.mentions.users.includes(<bot-id>)`.
|
|
78
|
-
- **telegram** — DM when `payload.chat.type === 'private'`; otherwise pinged when any entity in `payload.entities` (or `caption_entities`) is `{type:"mention"}` matching `@<bot-username>` or `{type:"text_mention", user:{id:<bot-id>}}`.
|
|
79
|
-
- **webhook** — every POST is "for you" by design (it's an endpoint you registered). Route on `payload.headers['x-github-event']` / `x-intercom-topic` etc. to decide which provider event you're handling.
|
|
80
|
-
|
|
81
|
-
Default for chat: only reply on DM or ping; otherwise stay silent or `metro react` to ack. Webhooks have no "ack" mechanism — just consume the event.
|
|
82
|
-
|
|
83
|
-
Both `from` and `to` are **participant URIs** (the conversation context lives in `line`):
|
|
84
|
-
- `metro://<station>/user/<id>` — a person on a chat platform
|
|
85
|
-
- `metro://claude/user/<orgId>` — a Claude Code agent (orgId = stable Anthropic-account UUID, same across devices for the same account)
|
|
86
|
-
- `metro://codex/user/<accountId>` — a Codex agent (accountId = stable ChatGPT-account UUID, same across devices)
|
|
87
|
-
- `metro://webhook/<endpoint-id>` — a webhook endpoint (line + `from` are the same — no HTTP-side user identity)
|
|
88
|
-
- `metro://<station>/<channelId>` — a channel (used as `to` for fresh sends to a group, where no single recipient)
|
|
89
|
-
|
|
90
|
-
When **you** send via `metro send`/`reply`/`edit`/`react`, metro auto-stamps `from = metro://claude/user/<orgId>` (when `$CLAUDECODE` is set; resolved from `claude auth status --json`) or `metro://codex/user/<accountId>` (from `$METRO_CODEX_RC` / `$CODEX_HOME`; resolved from `$CODEX_HOME/auth.json`). Switching accounts via `claude auth login` / `codex login` flips the id on the next event (within ~5 s for the daemon). Override with `--from=<uri>` or `$METRO_FROM`. When replying/reacting, `to` is automatically the original sender (looked up via the universal id).
|
|
91
|
-
|
|
92
|
-
The `id` is the **canonical handle** for that message across all stations — store it if you want to refer back to it later.
|
|
93
|
-
|
|
94
|
-
- `kind: "inbound"` — a human (or another bot) posted on a chat platform.
|
|
95
|
-
- `kind: "notification"` — another agent called `metro send` against your agent line. This is how Codex pings Claude Code and vice versa.
|
|
96
|
-
|
|
97
|
-
`text` may contain `[image]`, `[voice]`, `[audio]`, or `[file: <name>]` placeholders alongside the real text — non-image attachments are opaque markers; images can be materialized via `metro download`.
|
|
98
|
-
|
|
99
|
-
## Required flow on every event
|
|
100
|
-
|
|
101
|
-
1. **Echo to your visible output**: `[<line>#<messageId>] <text>` on its own line. Both Claude Code's Monitor and Codex collapse tool output, so this echo is the only way the user sees what arrived without expanding cards.
|
|
102
|
-
2. **Decide and act** using the subcommands below.
|
|
103
|
-
|
|
104
|
-
No server-side auto-reaction — don't expect 👀 to be on the user's message; add one yourself with `metro react` if you want to ack quickly.
|
|
105
|
-
|
|
106
|
-
## Subcommands
|
|
107
|
-
|
|
108
|
-
All take positional args (no `--to=`/`--text=` flags). Append `--json` to any for a parseable single-line result.
|
|
109
|
-
|
|
110
|
-
| Action | Command |
|
|
111
|
-
|---|---|
|
|
112
|
-
| Quote-reply (threads under original) | `metro reply <line> <messageId> <text>` |
|
|
113
|
-
| Send a fresh message (no reply context) | `metro send <line> <text>` |
|
|
114
|
-
| Edit a message you previously sent | `metro edit <line> <messageId> <text>` |
|
|
115
|
-
| Reaction (empty emoji clears) | `metro react <line> <messageId> <emoji>` |
|
|
116
|
-
| Download `[image]` attachments → paths | `metro download <line> <messageId> [--out=<dir>]` |
|
|
117
|
-
| Recent channel history (Discord only) | `metro fetch <line> [--limit=20]` |
|
|
118
|
-
| Ping another agent (cross-agent line) | `metro send metro://claude/<agent-id>/<session-id> <text> [--from=<line>]` |
|
|
119
|
-
| Register webhook endpoint | `metro webhook add <label> [--secret=<hmac-secret>]` |
|
|
120
|
-
| List / remove webhook endpoints | `metro webhook list` · `metro webhook remove <id>` |
|
|
121
|
-
| Configure Cloudflare named tunnel | `metro tunnel setup <tunnel-name> <hostname>` |
|
|
122
|
-
|
|
123
|
-
`reply` / `send` / `edit` accept multi-line text via stdin (heredoc).
|
|
124
|
-
|
|
125
|
-
### Rich content flags
|
|
126
|
-
|
|
127
|
-
`send` and `reply` accept these extra flags; `edit` accepts `--buttons` only.
|
|
128
|
-
|
|
129
|
-
- `--image=<path>` — upload a local image. **Repeatable** for albums: `--image=a.png --image=b.png`. Comma-separated also works: `--image='a.png,b.png'`. Up to 10 / message. Text becomes the caption (on the first image for albums).
|
|
130
|
-
- `--document=<path>` — upload any local file (PDF, log, csv, …). Same repeat/comma syntax.
|
|
131
|
-
- `--voice=<path>` — single voice message (`.ogg` Opus or `.mp3`). On Telegram renders as a voice bubble via `sendVoice`; on Discord uploaded as an audio attachment.
|
|
132
|
-
- `--buttons='[[{"text":"…","url":"https://…"}]]'` — attach an inline URL-button keyboard. 2D array: outer = rows, inner = buttons on that row.
|
|
133
|
-
|
|
134
|
-
```bash
|
|
135
|
-
metro send <line> "screenshot" --image=/tmp/build.png
|
|
136
|
-
metro send <line> "before/after" --image=/tmp/before.png --image=/tmp/after.png
|
|
137
|
-
metro reply <line> <id> "log + transcript" --document=/tmp/run.log --document=/tmp/transcript.txt
|
|
138
|
-
metro send <line> "have a listen" --voice=/tmp/note.ogg
|
|
139
|
-
metro send <line> "approve?" --buttons='[[{"text":"Open PR","url":"https://github.com/x/y/pull/1"}]]'
|
|
140
|
-
metro edit <line> <id> "still working…" --buttons='[]' # clears buttons
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
Limits / quirks:
|
|
144
|
-
- 20 MB per file (both platforms).
|
|
145
|
-
- Telegram albums are single-type (all photos OR all documents in one album). Mixing kinds in one send still works — metro splits into two album messages and returns the first id.
|
|
146
|
-
- Telegram drops `--buttons` when multiple attachments are sent (the bot API doesn't allow `reply_markup` on media groups).
|
|
147
|
-
- URL buttons only (no callback / interactive components yet).
|
|
148
|
-
|
|
149
|
-
## When to use `reply` vs `send`
|
|
150
|
-
|
|
151
|
-
- **`reply`** — responding to a specific inbound message. Threads under it. Default for handling an `inbound` event.
|
|
152
|
-
- **`send`** — initiating without a triggering message: a long task finished, a follow-up the user asked you to deliver later, or posting to an agent line (`metro://claude/...`, `metro://codex/...`) to notify a peer.
|
|
153
|
-
|
|
154
|
-
## Line URI scheme
|
|
155
|
-
|
|
156
|
-
`metro://<station>/<path>` — see [docs/uri-scheme.md](https://github.com/bonustrack/metro/blob/main/docs/uri-scheme.md) for the full grammar.
|
|
157
|
-
|
|
158
|
-
| Station | Pattern | Example |
|
|
159
|
-
|------------|-------------------------------------------|--------------------------------------|
|
|
160
|
-
| `discord` | `metro://discord/<channel-id>` | `metro://discord/1234567890` |
|
|
161
|
-
| `telegram` | `metro://telegram/<chat-id>[/<topic-id>]` | `metro://telegram/-1001234567890/42` |
|
|
162
|
-
| `claude` | `metro://claude/<agent-id>/<session-id>` | `metro://claude/9bfc7af0-…/50b00d11-…` |
|
|
163
|
-
| `codex` | `metro://codex/<agent-id>/<session-id>` | `metro://codex/8119ecb1-…/01997d4b-…` |
|
|
164
|
-
| `webhook` | `metro://webhook/<endpoint-id>` | `metro://webhook/fwaCgTKJuLAjS2K0` |
|
|
165
|
-
|
|
166
|
-
The `messageId` is **not** part of the URI — it's a separate positional arg for `reply` / `edit` / `react` / `download`.
|
|
167
|
-
|
|
168
|
-
## Image attachments
|
|
169
|
-
|
|
170
|
-
When an event's `text` contains `[image]`:
|
|
171
|
-
|
|
172
|
-
1. `metro download <line> <messageId>` — writes images to disk and prints absolute paths.
|
|
173
|
-
2. `Read` each path with your Read tool — the image enters your context as a vision input.
|
|
174
|
-
3. Reply normally with `metro reply`.
|
|
175
|
-
|
|
176
|
-
## Opaque attachment markers
|
|
177
|
-
|
|
178
|
-
`[voice]`, `[audio]`, and `[file: <name>]` are opaque — `metro download` only handles images. Acknowledge in text or ask the user to resend as a regular file.
|
|
179
|
-
|
|
180
|
-
## Cross-agent notification
|
|
181
|
-
|
|
182
|
-
Both agents can post to each other's "agent line":
|
|
183
|
-
|
|
184
|
-
```bash
|
|
185
|
-
metro send metro://claude/9bfc7af0-…/50b00d11-… "build green, ready to ship"
|
|
186
|
-
metro send metro://codex/8119ecb1-…/01997d4b-… "build green" --from=metro://claude/user/9bfc7af0-… # override sender
|
|
187
|
-
```
|
|
188
|
-
|
|
189
|
-
The daemon re-emits the post on its stdout stream (and pushes via codex-rc if configured), so the peer agent sees a `{"kind":"notification",...}` event. Requires the metro daemon to be running on the machine — agent-line sends error with `metro daemon is not running` otherwise.
|
|
190
|
-
|
|
191
|
-
## Discoverability
|
|
192
|
-
|
|
193
|
-
- `metro lines` — list recently-seen conversations (sorted by recency).
|
|
194
|
-
- `metro stations` — list stations + capability matrix.
|
|
195
|
-
- `metro history` — universal message log (every inbound + outbound + notification across all stations). Newest first. Filters:
|
|
196
|
-
- `--limit=N` (default 50)
|
|
197
|
-
- `--line=<metro://…>` — only this conversation
|
|
198
|
-
- `--station=<discord|telegram|claude|codex|webhook>`
|
|
199
|
-
- `--kind=<inbound|outbound|edit|react|notification>`
|
|
200
|
-
- `--from=<sender>`
|
|
201
|
-
- `--text=<substring>`
|
|
202
|
-
- `--since=<iso>` — e.g. `--since=2026-05-14T00:00:00Z`
|
|
203
|
-
- `--json` — machine-parseable
|
|
204
|
-
|
|
205
|
-
Every action you take is logged automatically — `metro send`/`reply`/`edit`/`react` append outbound entries, daemon-side inbounds + notifications append on arrival. Stored at `$METRO_STATE_DIR/history.jsonl`.
|
|
206
|
-
|
|
207
|
-
## Universal message IDs
|
|
208
|
-
|
|
209
|
-
The `id` from `metro history` or an event JSON works **anywhere a `<message_id>` argument is expected**:
|
|
210
|
-
|
|
211
|
-
```bash
|
|
212
|
-
# Either form works for reply/edit/react/download:
|
|
213
|
-
metro reply <line> 4567 "ack" # platform messageId (Telegram int)
|
|
214
|
-
metro reply <line> msg_aB3xY7zP "ack" # universal — resolves via history
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
Use universal IDs when chaining commands or referring back to a specific message across stations.
|
|
218
|
-
|
|
219
|
-
## Exit codes
|
|
220
|
-
|
|
221
|
-
- `0` success
|
|
222
|
-
- `1` usage error (bad args, unknown subcommand)
|
|
223
|
-
- `2` configuration error (no tokens — tell the user to run `metro setup`)
|
|
224
|
-
- `3` upstream error (rate limit, auth, network) — retry once after a few seconds before surfacing
|
|
225
|
-
|
|
226
|
-
`metro doctor` diagnoses tokens, gateways, dispatcher liveness, and codex-rc target.
|
|
227
|
-
|
|
228
|
-
## --json output
|
|
229
|
-
|
|
230
|
-
Every command supports `--json` for stable parseable output:
|
|
231
|
-
|
|
232
|
-
```bash
|
|
233
|
-
metro reply <line> <messageId> "ack" --json
|
|
234
|
-
# {"ok":true,"line":"metro://discord/...","replyTo":"...","messageId":"..."}
|
|
235
|
-
|
|
236
|
-
metro fetch metro://discord/1234 --limit=10 --json
|
|
237
|
-
# {"ok":true,"line":"...","messages":[{"messageId":"...","author":"...","text":"...","timestamp":"..."},...]}
|
|
238
|
-
|
|
239
|
-
metro download <line> <messageId> --json
|
|
240
|
-
# {"ok":true,"line":"...","files":[{"path":"/abs/...png","mediaType":"image/png"}]}
|
|
241
|
-
```
|
|
242
|
-
|
|
243
|
-
Use `--json` when you need to chain calls or capture the new `messageId` for a later edit.
|
|
244
|
-
|
|
245
|
-
## Don'ts
|
|
246
|
-
|
|
247
|
-
- ❌ Spawning a second metro daemon — there's one per machine (lockfile-enforced).
|
|
248
|
-
- ❌ Posting to a line that isn't in `metro lines` unless the user gave it to you explicitly.
|
|
249
|
-
- ❌ Narrating the tool ("I'll now use metro reply to…"). The tool call is already visible to the user.
|