@stage-labs/metro 0.1.0-beta.31 → 0.1.0-beta.310
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/agent.js +123 -0
- package/dist/api.js +9 -129
- package/dist/automation.js +56 -0
- package/dist/child.js +33 -0
- package/dist/claude-env.js +104 -0
- package/dist/claude-settings.js +40 -0
- package/dist/cli.js +62 -136
- package/dist/control.js +19 -103
- package/dist/hold.js +210 -0
- package/dist/local.js +43 -0
- package/dist/lock.js +62 -0
- package/dist/memory.js +206 -0
- package/dist/node-name.js +71 -0
- package/dist/provider-flags.js +9 -0
- package/dist/root-release-io.js +160 -0
- package/dist/root-release.js +74 -0
- package/dist/route.js +65 -0
- package/dist/runtime-install.js +106 -0
- package/dist/runtime.js +29 -52
- package/dist/serve.js +157 -0
- package/dist/service.js +328 -0
- package/dist/tail.js +10 -11
- package/dist/update.js +13 -1
- package/hooks/guard.mjs +77 -0
- package/hooks/policy.mjs +74 -0
- package/hooks/session-start.mjs +31 -0
- package/package.json +6 -25
- package/runtime/node_modules/@metro-labs/core/package.json +58 -0
- package/runtime/node_modules/@metro-labs/core/src/automation-files.ts +216 -0
- package/runtime/node_modules/@metro-labs/core/src/automation-store.ts +171 -0
- package/runtime/node_modules/@metro-labs/core/src/automation-types.ts +141 -0
- package/runtime/node_modules/@metro-labs/core/src/call.ts +81 -0
- package/runtime/node_modules/@metro-labs/core/src/endpoints.ts +7 -0
- package/runtime/node_modules/@metro-labs/{mcp/src/daemon → core/src}/events.ts +54 -6
- package/runtime/node_modules/@metro-labs/{mcp/src/db → core/src}/ids.ts +10 -1
- package/runtime/node_modules/@metro-labs/core/src/is-record.ts +2 -0
- package/runtime/node_modules/@metro-labs/{mcp/src/stations → core/src}/lines.ts +22 -26
- package/runtime/node_modules/@metro-labs/{mcp/src/daemon → core/src}/protocol.ts +7 -4
- package/runtime/node_modules/@metro-labs/core/src/runner-activity.ts +270 -0
- package/runtime/node_modules/@metro-labs/{mcp/src/daemon → core/src}/secure-fs.ts +17 -0
- package/runtime/node_modules/@metro-labs/core/src/skill-source.ts +96 -0
- package/runtime/node_modules/@metro-labs/core/src/station-names.ts +14 -0
- package/runtime/node_modules/@metro-labs/core/src/stations/account-files.ts +41 -0
- package/runtime/node_modules/@metro-labs/core/src/stations/account-store.ts +83 -0
- package/runtime/node_modules/@metro-labs/{mcp → core}/src/stations/attachments.ts +9 -3
- package/runtime/node_modules/@metro-labs/core/src/stations/channel-directory.ts +159 -0
- package/runtime/node_modules/@metro-labs/core/src/stations/channel-pages.ts +129 -0
- package/runtime/node_modules/@metro-labs/core/src/stations/mail-text.ts +72 -0
- package/runtime/node_modules/@metro-labs/core/src/stations/mail-trust.ts +29 -0
- package/runtime/node_modules/@metro-labs/core/src/stations/mail.ts +212 -0
- package/runtime/node_modules/@metro-labs/core/src/stations/messaging-normalize.ts +16 -0
- package/runtime/node_modules/@metro-labs/core/src/stations/oauth.ts +126 -0
- package/runtime/node_modules/@metro-labs/core/src/stations/profile.ts +58 -0
- package/runtime/node_modules/@metro-labs/core/src/stations/sender-profile.ts +64 -0
- package/runtime/node_modules/@metro-labs/{mcp → core}/src/stations/station-runtime.ts +6 -11
- package/runtime/node_modules/@metro-labs/core/src/stations/train-boot.ts +63 -0
- package/runtime/node_modules/@metro-labs/core/src/stations/train-events.ts +84 -0
- package/runtime/node_modules/@metro-labs/{mcp → core}/src/stations/types.ts +20 -1
- package/runtime/node_modules/@metro-labs/core/src/tickets.ts +44 -0
- package/runtime/node_modules/@metro-labs/core/src/version.ts +2 -0
- package/runtime/node_modules/@metro-labs/daemon/package.json +51 -0
- package/runtime/node_modules/@metro-labs/daemon/src/agent-user/agent-fs.ts +246 -0
- package/runtime/node_modules/@metro-labs/daemon/src/agent-user/crontab.ts +44 -0
- package/runtime/node_modules/@metro-labs/daemon/src/agent-user/files-api.ts +12 -0
- package/runtime/node_modules/@metro-labs/daemon/src/agent-user/files.ts +89 -0
- package/runtime/node_modules/@metro-labs/daemon/src/agent-user/home-fs.ts +86 -0
- package/runtime/node_modules/@metro-labs/daemon/src/agent-user/job-env.ts +39 -0
- package/runtime/node_modules/@metro-labs/daemon/src/agent-user/metro-home.ts +42 -0
- package/runtime/node_modules/@metro-labs/daemon/src/agent-user/provision.ts +57 -0
- package/runtime/node_modules/@metro-labs/daemon/src/agent-user/schedule-detail.ts +93 -0
- package/runtime/node_modules/@metro-labs/daemon/src/agent-user/schedules-api.ts +27 -0
- package/runtime/node_modules/@metro-labs/daemon/src/agent-user/schedules.ts +144 -0
- package/runtime/node_modules/@metro-labs/daemon/src/agent-user/unit-files.ts +43 -0
- package/runtime/node_modules/@metro-labs/daemon/src/agent-user/user.ts +110 -0
- package/runtime/node_modules/@metro-labs/daemon/src/agent-user/view.ts +90 -0
- package/runtime/node_modules/@metro-labs/daemon/src/agents/account-attach.ts +19 -0
- package/runtime/node_modules/@metro-labs/daemon/src/agents/account-lookups.ts +55 -0
- package/runtime/node_modules/@metro-labs/daemon/src/agents/account-routes.ts +76 -0
- package/runtime/node_modules/@metro-labs/daemon/src/agents/accounts-api.ts +362 -0
- package/runtime/node_modules/@metro-labs/daemon/src/agents/admin.ts +30 -0
- package/runtime/node_modules/@metro-labs/daemon/src/agents/allowlist.ts +59 -0
- package/runtime/node_modules/@metro-labs/daemon/src/agents/api.ts +131 -0
- package/runtime/node_modules/@metro-labs/daemon/src/agents/bundle.ts +124 -0
- package/runtime/node_modules/@metro-labs/daemon/src/agents/file-admin.ts +317 -0
- package/runtime/node_modules/@metro-labs/daemon/src/agents/files.ts +142 -0
- package/runtime/node_modules/@metro-labs/{mcp/src/db/key-map.ts → daemon/src/agents/keys.ts} +1 -11
- package/runtime/node_modules/@metro-labs/daemon/src/agents/map.ts +135 -0
- package/runtime/node_modules/@metro-labs/daemon/src/agents/policy-route.ts +27 -0
- package/runtime/node_modules/@metro-labs/{mcp/src/db/agent-scope.ts → daemon/src/agents/scope.ts} +2 -2
- package/runtime/node_modules/@metro-labs/daemon/src/agents/sender-cards.ts +94 -0
- package/runtime/node_modules/@metro-labs/daemon/src/agents/senders.ts +38 -0
- package/runtime/node_modules/@metro-labs/daemon/src/approvals/api.ts +55 -0
- package/runtime/node_modules/@metro-labs/daemon/src/approvals/owner-line.ts +45 -0
- package/runtime/node_modules/@metro-labs/daemon/src/approvals/pending.ts +190 -0
- package/runtime/node_modules/@metro-labs/daemon/src/approvals/preview.ts +66 -0
- package/runtime/node_modules/@metro-labs/daemon/src/boot/boot.ts +264 -0
- package/runtime/node_modules/@metro-labs/daemon/src/boot/connect-hint.ts +36 -0
- package/runtime/node_modules/@metro-labs/{mcp/src/daemon → daemon/src/boot}/crash-guard.ts +1 -1
- package/runtime/node_modules/@metro-labs/daemon/src/boot/local-owner.ts +21 -0
- package/runtime/node_modules/@metro-labs/{mcp/src/daemon → daemon/src/boot}/paths.ts +8 -36
- package/runtime/node_modules/@metro-labs/daemon/src/channels/addressed.ts +26 -0
- package/runtime/node_modules/@metro-labs/{mcp → daemon}/src/channels/inbound.ts +99 -73
- package/runtime/node_modules/@metro-labs/{mcp → daemon}/src/channels/media-note.ts +11 -7
- package/runtime/node_modules/@metro-labs/daemon/src/channels/notice.ts +22 -0
- package/runtime/node_modules/@metro-labs/{mcp → daemon}/src/channels/pending.ts +13 -1
- package/runtime/node_modules/@metro-labs/daemon/src/channels/react-note.ts +13 -0
- package/runtime/node_modules/@metro-labs/{mcp → daemon}/src/channels/relay.ts +6 -2
- package/runtime/node_modules/@metro-labs/daemon/src/claude/api.ts +304 -0
- package/runtime/node_modules/@metro-labs/daemon/src/claude/cli-files.ts +28 -0
- package/runtime/node_modules/@metro-labs/daemon/src/claude/files.ts +359 -0
- package/runtime/node_modules/@metro-labs/daemon/src/claude/github-api.ts +12 -0
- package/runtime/node_modules/@metro-labs/daemon/src/claude/github-fetch.ts +160 -0
- package/runtime/node_modules/@metro-labs/daemon/src/claude/github-skills.ts +255 -0
- package/runtime/node_modules/@metro-labs/daemon/src/claude/github-validate.ts +53 -0
- package/runtime/node_modules/@metro-labs/daemon/src/claude/hooks.ts +60 -0
- package/runtime/node_modules/@metro-labs/daemon/src/claude/login.ts +243 -0
- package/runtime/node_modules/@metro-labs/daemon/src/claude/memory-routine.ts +123 -0
- package/runtime/node_modules/@metro-labs/daemon/src/claude/memory.ts +32 -0
- package/runtime/node_modules/@metro-labs/daemon/src/claude/onboarding.ts +38 -0
- package/runtime/node_modules/@metro-labs/daemon/src/claude/runner-activity.ts +17 -0
- package/runtime/node_modules/@metro-labs/daemon/src/claude/runner-process.ts +52 -0
- package/runtime/node_modules/@metro-labs/daemon/src/claude/session-files.ts +75 -0
- package/runtime/node_modules/@metro-labs/daemon/src/claude/session.ts +303 -0
- package/runtime/node_modules/@metro-labs/daemon/src/claude/settings.ts +109 -0
- package/runtime/node_modules/@metro-labs/daemon/src/claude/setup-api.ts +114 -0
- package/runtime/node_modules/@metro-labs/daemon/src/claude/setup-state.ts +18 -0
- package/runtime/node_modules/@metro-labs/daemon/src/claude/setup.ts +323 -0
- package/runtime/node_modules/@metro-labs/daemon/src/claude/skills.ts +123 -0
- package/runtime/node_modules/@metro-labs/daemon/src/claude/usage-probe.ts +128 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/agent-key.ts +145 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/enroll-api.ts +99 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/leftovers.ts +59 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/metro-api.ts +93 -0
- package/runtime/node_modules/@metro-labs/{mcp/src/daemon → daemon/src/files}/attach-grant.ts +4 -4
- package/runtime/node_modules/@metro-labs/{mcp/src/daemon → daemon/src/files}/attach-owner.ts +3 -3
- package/runtime/node_modules/@metro-labs/daemon/src/files/attach-reaper.ts +174 -0
- package/runtime/node_modules/@metro-labs/{mcp/src/daemon → daemon/src/files}/attach-serve.ts +11 -17
- package/runtime/node_modules/@metro-labs/{mcp/src/daemon → daemon/src/files}/upload-api.ts +10 -27
- package/runtime/node_modules/@metro-labs/{mcp/src/daemon → daemon/src/files}/upload-store.ts +4 -4
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/bedrock.ts +228 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/claude-logins.ts +192 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/claude-store.ts +59 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/codex-stream.ts +179 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/codex-translate.ts +209 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/codex-version.ts +44 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/codex.ts +121 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/delivered.ts +82 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/effective.ts +43 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/effort.ts +103 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/eventstream.ts +123 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/fallback.ts +146 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/forward.ts +284 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/frames.ts +118 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/gateway.ts +356 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/model-api.ts +125 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/model-config.ts +159 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/model-leftovers.ts +42 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/model-lists.ts +40 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/openrouter.ts +25 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/org-models.ts +203 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/provider-models.ts +77 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/served.ts +18 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/subscription.ts +120 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/text.ts +33 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/tool-search.ts +126 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/usage-refresh.ts +95 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/usage.ts +330 -0
- package/runtime/node_modules/@metro-labs/{mcp → daemon}/src/mcp/accounts.ts +38 -18
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/attachment-schema.ts +91 -0
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/call-bridge.ts +45 -0
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/call-permission.ts +25 -0
- package/runtime/node_modules/@metro-labs/{mcp → daemon}/src/mcp/call-tools.ts +88 -38
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/channel-tool.ts +80 -0
- package/runtime/node_modules/@metro-labs/{mcp → daemon}/src/mcp/ctx.ts +4 -4
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/diagnostics.ts +102 -0
- package/runtime/node_modules/@metro-labs/{mcp → daemon}/src/mcp/event-store.ts +24 -18
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/frame-schema.ts +44 -0
- package/runtime/node_modules/@metro-labs/{mcp → daemon}/src/mcp/group-tools.ts +2 -2
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/index.ts +167 -0
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/instructions.ts +21 -0
- package/runtime/node_modules/@metro-labs/{mcp → daemon}/src/mcp/member-tools.ts +2 -2
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/permission-prompt.ts +115 -0
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/permission-relay.ts +111 -0
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/policy-gate.ts +88 -0
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/policy-snapshot.ts +65 -0
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/profile-lookup.ts +60 -0
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/profile-tool.ts +96 -0
- package/runtime/node_modules/@metro-labs/{mcp → daemon}/src/mcp/raw-get-stream.ts +54 -16
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/read-tool.ts +87 -0
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/request-identity.ts +48 -0
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/server-approvals.ts +108 -0
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/session-slot.ts +137 -0
- package/runtime/node_modules/@metro-labs/{mcp → daemon}/src/mcp/session.ts +103 -52
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/speech-schema.ts +11 -0
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/speech-send.ts +15 -0
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/tool-catalog.ts +108 -0
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/tool-def.ts +9 -0
- package/runtime/node_modules/@metro-labs/{mcp → daemon}/src/mcp/tool-dispatch.ts +74 -48
- package/runtime/node_modules/@metro-labs/{mcp → daemon}/src/mcp/tool-schemas.ts +87 -114
- package/runtime/node_modules/@metro-labs/{mcp → daemon}/src/mcp/upload-tool.ts +6 -11
- package/runtime/node_modules/@metro-labs/daemon/src/mcp-server/announced.ts +68 -0
- package/runtime/node_modules/@metro-labs/daemon/src/mcp-server/config.ts +29 -0
- package/runtime/node_modules/@metro-labs/daemon/src/mcp-server/connector-tools.ts +114 -0
- package/runtime/node_modules/@metro-labs/daemon/src/mcp-server/link.ts +197 -0
- package/runtime/node_modules/@metro-labs/daemon/src/mcp-server/rpc.ts +67 -0
- package/runtime/node_modules/@metro-labs/daemon/src/mcp-server/token.ts +50 -0
- package/runtime/node_modules/@metro-labs/daemon/src/metro-user/helper-script.ts +183 -0
- package/runtime/node_modules/@metro-labs/daemon/src/metro-user/imds.ts +16 -0
- package/runtime/node_modules/@metro-labs/daemon/src/metro-user/install.ts +78 -0
- package/runtime/node_modules/@metro-labs/daemon/src/metro-user/privilege.ts +50 -0
- package/runtime/node_modules/@metro-labs/daemon/src/metro-user/root-follow.ts +16 -0
- package/runtime/node_modules/@metro-labs/daemon/src/monitor/api.ts +132 -0
- package/runtime/node_modules/@metro-labs/daemon/src/monitor/run-event.ts +139 -0
- package/runtime/node_modules/@metro-labs/daemon/src/monitor/run-events.ts +101 -0
- package/runtime/node_modules/@metro-labs/daemon/src/net/tunnel.ts +323 -0
- package/runtime/node_modules/@metro-labs/daemon/src/policy/policy.ts +120 -0
- package/runtime/node_modules/@metro-labs/daemon/src/routes/bearer.ts +35 -0
- package/runtime/node_modules/@metro-labs/daemon/src/routes/body.ts +24 -0
- package/runtime/node_modules/@metro-labs/daemon/src/routes/gmail-attach.ts +67 -0
- package/runtime/node_modules/@metro-labs/daemon/src/routes/gmail-detach.ts +37 -0
- package/runtime/node_modules/@metro-labs/{mcp/src/daemon → daemon/src/routes}/http.ts +63 -54
- package/runtime/node_modules/@metro-labs/daemon/src/routes/local-mode.ts +149 -0
- package/runtime/node_modules/@metro-labs/daemon/src/routes/session-apis.ts +65 -0
- package/runtime/node_modules/@metro-labs/daemon/src/routes/session.ts +29 -0
- package/runtime/node_modules/@metro-labs/daemon/src/routes/threema-callback.ts +103 -0
- package/runtime/node_modules/@metro-labs/daemon/src/server/cloudwatch.ts +178 -0
- package/runtime/node_modules/@metro-labs/daemon/src/server/control.ts +39 -0
- package/runtime/node_modules/@metro-labs/daemon/src/server/machine.ts +58 -0
- package/runtime/node_modules/@metro-labs/daemon/src/server/owner.ts +26 -0
- package/runtime/node_modules/@metro-labs/daemon/src/server/update.ts +90 -0
- package/runtime/node_modules/@metro-labs/daemon/src/server.ts +2 -0
- package/runtime/node_modules/@metro-labs/daemon/src/stations/attach-browser.ts +107 -0
- package/runtime/node_modules/@metro-labs/daemon/src/stations/attach-driver.ts +42 -0
- package/runtime/node_modules/@metro-labs/daemon/src/stations/attach-gmail.ts +78 -0
- package/runtime/node_modules/@metro-labs/{mcp → daemon}/src/stations/attach-inline.ts +29 -1
- package/runtime/node_modules/@metro-labs/{mcp → daemon}/src/stations/attach-interactive.ts +5 -31
- package/runtime/node_modules/@metro-labs/{mcp → daemon}/src/stations/attach-resolve.ts +84 -13
- package/runtime/node_modules/@metro-labs/{mcp/src/daemon → daemon/src/stations}/attach-session.ts +61 -25
- package/runtime/node_modules/@metro-labs/{mcp → daemon}/src/stations/attach-xmtp.ts +8 -9
- package/runtime/node_modules/@metro-labs/{mcp → daemon}/src/stations/attach.ts +69 -3
- package/runtime/node_modules/@metro-labs/{mcp/src/db → daemon/src/stations}/materialize.ts +53 -175
- package/runtime/node_modules/@metro-labs/{mcp → daemon}/src/stations/registry.ts +20 -2
- package/runtime/node_modules/@metro-labs/daemon/src/stations/runtime-deps.ts +135 -0
- package/runtime/node_modules/@metro-labs/{mcp/src/daemon → daemon/src/stations}/supervisor-io.ts +3 -3
- package/runtime/node_modules/@metro-labs/{mcp/src/daemon → daemon/src/stations}/supervisor.ts +6 -9
- package/runtime/node_modules/@metro-labs/daemon/src/stations/threema-callbacks.ts +32 -0
- package/runtime/node_modules/@metro-labs/{mcp/src/daemon → daemon/src/stations}/train-call.ts +1 -1
- package/runtime/node_modules/@metro-labs/daemon/src/stations/webhook-endpoints.ts +51 -0
- package/runtime/node_modules/@metro-labs/daemon/src/terminal/api.ts +84 -0
- package/runtime/node_modules/@metro-labs/daemon/src/terminal/socket.ts +124 -0
- package/runtime/node_modules/@metro-labs/daemon/src/terminal/tickets.ts +15 -0
- package/runtime/node_modules/@metro-labs/daemon/src/vault/api.ts +45 -0
- package/runtime/node_modules/@metro-labs/daemon/src/vault/config.ts +51 -0
- package/runtime/node_modules/@metro-labs/daemon/src/vault/firewall.ts +9 -0
- package/runtime/node_modules/@metro-labs/daemon/src/vault/index.ts +96 -0
- package/runtime/node_modules/@metro-labs/daemon/src/vault/install.ts +56 -0
- package/runtime/node_modules/@metro-labs/daemon/src/vault/paths.ts +26 -0
- package/runtime/node_modules/@metro-labs/daemon/src/vault/proxy.ts +147 -0
- package/runtime/node_modules/@metro-labs/daemon/src/vault/store.ts +129 -0
- package/runtime/node_modules/@metro-labs/daemon/src/vault/trust.ts +44 -0
- package/runtime/node_modules/@metro-labs/daemon/src/voice/api.ts +14 -0
- package/runtime/node_modules/@metro-labs/daemon/src/voice/audio.ts +193 -0
- package/runtime/node_modules/@metro-labs/daemon/src/voice/call.ts +191 -0
- package/runtime/node_modules/@metro-labs/daemon/src/voice/calls.ts +153 -0
- package/runtime/node_modules/@metro-labs/daemon/src/voice/peer.ts +85 -0
- package/runtime/node_modules/@metro-labs/daemon/src/voice/scribe.ts +115 -0
- package/runtime/node_modules/@metro-labs/daemon/src/voice/shared-talk.ts +85 -0
- package/runtime/node_modules/@metro-labs/daemon/src/voice/shared.ts +198 -0
- package/runtime/node_modules/@metro-labs/daemon/src/voice/speech-queue.ts +200 -0
- package/runtime/node_modules/@metro-labs/daemon/src/voice/speech.ts +125 -0
- package/runtime/node_modules/@metro-labs/daemon/src/voice/store.ts +103 -0
- package/runtime/node_modules/@metro-labs/discord-bot/package.json +3 -5
- package/runtime/node_modules/@metro-labs/discord-bot/src/accounts.ts +3 -23
- package/runtime/node_modules/@metro-labs/discord-bot/src/actions.ts +21 -187
- package/runtime/node_modules/@metro-labs/discord-bot/src/attachments.ts +2 -2
- package/runtime/node_modules/@metro-labs/discord-bot/src/channel-source.ts +79 -0
- package/runtime/node_modules/@metro-labs/discord-bot/src/channels.ts +186 -0
- package/runtime/node_modules/@metro-labs/discord-bot/src/format.ts +26 -67
- package/runtime/node_modules/@metro-labs/discord-bot/src/group-actions.ts +1 -1
- package/runtime/node_modules/@metro-labs/discord-bot/src/group.ts +2 -2
- package/runtime/node_modules/@metro-labs/discord-bot/src/index.ts +8 -14
- package/runtime/node_modules/@metro-labs/discord-bot/src/members.ts +2 -2
- package/runtime/node_modules/@metro-labs/discord-bot/src/profile.ts +68 -0
- package/runtime/node_modules/@metro-labs/discord-bot/src/send-files.ts +12 -13
- package/runtime/node_modules/@metro-labs/discord-bot/src/station.ts +6 -1
- package/runtime/node_modules/@metro-labs/gmail/package.json +27 -0
- package/runtime/node_modules/@metro-labs/gmail/src/accounts.ts +133 -0
- package/runtime/node_modules/@metro-labs/gmail/src/actions.ts +20 -0
- package/runtime/node_modules/@metro-labs/gmail/src/api.ts +34 -0
- package/runtime/node_modules/@metro-labs/gmail/src/attachments.ts +38 -0
- package/runtime/node_modules/@metro-labs/gmail/src/auth.ts +115 -0
- package/runtime/node_modules/@metro-labs/gmail/src/channels.ts +66 -0
- package/runtime/node_modules/@metro-labs/gmail/src/config.ts +15 -0
- package/runtime/node_modules/@metro-labs/gmail/src/inbound.ts +97 -0
- package/runtime/node_modules/@metro-labs/gmail/src/index.ts +12 -0
- package/runtime/node_modules/@metro-labs/gmail/src/login.ts +39 -0
- package/runtime/node_modules/@metro-labs/gmail/src/managed-binding.ts +33 -0
- package/runtime/node_modules/@metro-labs/gmail/src/managed.ts +45 -0
- package/runtime/node_modules/@metro-labs/gmail/src/message.ts +125 -0
- package/runtime/node_modules/@metro-labs/gmail/src/mime.ts +70 -0
- package/runtime/node_modules/@metro-labs/gmail/src/outbound.ts +125 -0
- package/runtime/node_modules/@metro-labs/gmail/src/query.ts +101 -0
- package/runtime/node_modules/@metro-labs/gmail/src/state.ts +30 -0
- package/runtime/node_modules/@metro-labs/gmail/src/station.ts +16 -0
- package/runtime/node_modules/@metro-labs/gmail/src/trust.ts +42 -0
- package/runtime/node_modules/@metro-labs/http/package.json +44 -0
- package/runtime/node_modules/@metro-labs/http/src/agent-signature.ts +95 -0
- package/runtime/node_modules/@metro-labs/http/src/api-http.ts +146 -0
- package/runtime/node_modules/@metro-labs/{mcp/src/daemon/oauth-discovery.ts → http/src/connector-discovery.ts} +57 -27
- package/runtime/node_modules/@metro-labs/http/src/connector-grant.ts +8 -0
- package/runtime/node_modules/@metro-labs/http/src/connector-input.ts +73 -0
- package/runtime/node_modules/@metro-labs/http/src/connector-mcp.ts +108 -0
- package/runtime/node_modules/@metro-labs/{mcp/src/daemon/oauth-client.ts → http/src/connector-oauth.ts} +48 -28
- package/runtime/node_modules/@metro-labs/http/src/connector-policy.ts +92 -0
- package/runtime/node_modules/@metro-labs/http/src/connector-public-url.ts +64 -0
- package/runtime/node_modules/@metro-labs/http/src/connector-reach.ts +27 -0
- package/runtime/node_modules/@metro-labs/http/src/connector-resource.ts +108 -0
- package/runtime/node_modules/@metro-labs/http/src/connector-tools.ts +95 -0
- package/runtime/node_modules/@metro-labs/{mcp/src/daemon → http/src}/connector-url.ts +8 -28
- package/runtime/node_modules/@metro-labs/http/src/ed25519.ts +56 -0
- package/runtime/node_modules/@metro-labs/http/src/mcp-server-protocol.ts +86 -0
- package/runtime/node_modules/@metro-labs/http/src/mcp-server-tools.ts +93 -0
- package/runtime/node_modules/@metro-labs/{mcp/src/daemon/session-api.ts → http/src/mode-api.ts} +13 -9
- package/runtime/node_modules/@metro-labs/http/src/return-to.ts +25 -0
- package/runtime/node_modules/@metro-labs/http/src/sigv4.ts +90 -0
- package/runtime/node_modules/@metro-labs/http/src/workos-token.ts +149 -0
- package/runtime/node_modules/@metro-labs/outlook/package.json +25 -0
- package/runtime/node_modules/@metro-labs/outlook/src/accounts.ts +78 -0
- package/runtime/node_modules/@metro-labs/outlook/src/actions.ts +15 -0
- package/runtime/node_modules/@metro-labs/outlook/src/attachments.ts +81 -0
- package/runtime/node_modules/@metro-labs/outlook/src/auth.ts +120 -0
- package/runtime/node_modules/@metro-labs/outlook/src/browser.ts +42 -0
- package/runtime/node_modules/@metro-labs/outlook/src/channels.ts +60 -0
- package/runtime/node_modules/@metro-labs/outlook/src/config.ts +23 -0
- package/runtime/node_modules/@metro-labs/outlook/src/format.ts +59 -0
- package/runtime/node_modules/@metro-labs/outlook/src/graph.ts +55 -0
- package/runtime/node_modules/@metro-labs/outlook/src/inbound.ts +96 -0
- package/runtime/node_modules/@metro-labs/outlook/src/index.ts +12 -0
- package/runtime/node_modules/@metro-labs/outlook/src/login.ts +129 -0
- package/runtime/node_modules/@metro-labs/outlook/src/me.ts +31 -0
- package/runtime/node_modules/@metro-labs/outlook/src/outbound.ts +103 -0
- package/runtime/node_modules/@metro-labs/outlook/src/query.ts +84 -0
- package/runtime/node_modules/@metro-labs/outlook/src/state.ts +28 -0
- package/runtime/node_modules/@metro-labs/outlook/src/station.ts +16 -0
- package/runtime/node_modules/@metro-labs/outlook/src/trust.ts +41 -0
- package/runtime/node_modules/@metro-labs/telegram/package.json +2 -4
- package/runtime/node_modules/@metro-labs/telegram/src/accounts.ts +5 -24
- package/runtime/node_modules/@metro-labs/telegram/src/actions.ts +27 -6
- package/runtime/node_modules/@metro-labs/telegram/src/attachments.ts +1 -1
- package/runtime/node_modules/@metro-labs/telegram/src/channels.ts +58 -0
- package/runtime/node_modules/@metro-labs/telegram/src/client.ts +4 -4
- package/runtime/node_modules/@metro-labs/telegram/src/format.ts +19 -34
- package/runtime/node_modules/@metro-labs/telegram/src/group.ts +3 -3
- package/runtime/node_modules/@metro-labs/telegram/src/inbound.ts +13 -34
- package/runtime/node_modules/@metro-labs/telegram/src/index.ts +4 -43
- package/runtime/node_modules/@metro-labs/telegram/src/media-actions.ts +2 -3
- package/runtime/node_modules/@metro-labs/telegram/src/members.ts +1 -1
- package/runtime/node_modules/@metro-labs/telegram/src/profile.ts +70 -0
- package/runtime/node_modules/@metro-labs/telegram/src/reactions.ts +2 -2
- package/runtime/node_modules/@metro-labs/telegram/src/station.ts +5 -1
- package/runtime/node_modules/@metro-labs/telegram/src/types.ts +0 -1
- package/runtime/node_modules/@metro-labs/telegram-bot/package.json +2 -2
- package/runtime/node_modules/@metro-labs/telegram-bot/src/accounts.ts +7 -41
- package/runtime/node_modules/@metro-labs/telegram-bot/src/actions.ts +24 -77
- package/runtime/node_modules/@metro-labs/telegram-bot/src/attachments.ts +2 -2
- package/runtime/node_modules/@metro-labs/telegram-bot/src/channel-files.ts +3 -0
- package/runtime/node_modules/@metro-labs/telegram-bot/src/channels.ts +43 -0
- package/runtime/node_modules/@metro-labs/telegram-bot/src/format.ts +46 -48
- package/runtime/node_modules/@metro-labs/telegram-bot/src/index.ts +15 -44
- package/runtime/node_modules/@metro-labs/telegram-bot/src/media-actions.ts +6 -82
- package/runtime/node_modules/@metro-labs/telegram-bot/src/members.ts +1 -1
- package/runtime/node_modules/@metro-labs/telegram-bot/src/observed-chats.ts +172 -0
- package/runtime/node_modules/@metro-labs/telegram-bot/src/profile.ts +85 -0
- package/runtime/node_modules/@metro-labs/telegram-bot/src/station.ts +9 -1
- package/runtime/node_modules/@metro-labs/telegram-bot/src/types.ts +50 -15
- package/runtime/node_modules/@metro-labs/telegram-bot/src/updates.ts +26 -0
- package/runtime/node_modules/@metro-labs/threema/package.json +26 -0
- package/runtime/node_modules/@metro-labs/threema/src/accounts.ts +108 -0
- package/runtime/node_modules/@metro-labs/threema/src/actions.ts +130 -0
- package/runtime/node_modules/@metro-labs/threema/src/api.ts +152 -0
- package/runtime/node_modules/@metro-labs/threema/src/channels.ts +37 -0
- package/runtime/node_modules/@metro-labs/threema/src/chats.ts +88 -0
- package/runtime/node_modules/@metro-labs/threema/src/crypto.ts +100 -0
- package/runtime/node_modules/@metro-labs/threema/src/files.ts +47 -0
- package/runtime/node_modules/@metro-labs/threema/src/format.ts +164 -0
- package/runtime/node_modules/@metro-labs/threema/src/groups.ts +96 -0
- package/runtime/node_modules/@metro-labs/threema/src/ids.ts +21 -0
- package/runtime/node_modules/@metro-labs/threema/src/inbound.ts +92 -0
- package/runtime/node_modules/@metro-labs/threema/src/index.ts +24 -0
- package/runtime/node_modules/@metro-labs/threema/src/messages.ts +264 -0
- package/runtime/node_modules/@metro-labs/threema/src/outbound.ts +161 -0
- package/runtime/node_modules/@metro-labs/threema/src/station.ts +21 -0
- package/runtime/node_modules/@metro-labs/threema/src/verify.ts +117 -0
- package/runtime/node_modules/@metro-labs/webhook/package.json +2 -2
- package/runtime/node_modules/@metro-labs/webhook/src/station.ts +5 -8
- package/runtime/node_modules/@metro-labs/whatsapp/package.json +3 -6
- package/runtime/node_modules/@metro-labs/whatsapp/src/accounts.ts +6 -28
- package/runtime/node_modules/@metro-labs/whatsapp/src/ack.ts +1 -1
- package/runtime/node_modules/@metro-labs/whatsapp/src/actions.ts +97 -12
- package/runtime/node_modules/@metro-labs/whatsapp/src/app-state.ts +49 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/attachments.ts +2 -2
- package/runtime/node_modules/@metro-labs/whatsapp/src/auth-state.ts +1 -1
- package/runtime/node_modules/@metro-labs/whatsapp/src/channel-chats.ts +137 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/channels.ts +48 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/client-history.ts +31 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/client-types.ts +48 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/client.ts +145 -63
- package/runtime/node_modules/@metro-labs/whatsapp/src/format.ts +7 -58
- package/runtime/node_modules/@metro-labs/whatsapp/src/history-events.ts +127 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/history-files.ts +39 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/history-identity.ts +58 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/history-message.ts +161 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/history-state.ts +344 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/history-types.ts +91 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/history.ts +195 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/inbound.ts +11 -28
- package/runtime/node_modules/@metro-labs/whatsapp/src/index.ts +4 -37
- package/runtime/node_modules/@metro-labs/whatsapp/src/keys.ts +1 -1
- package/runtime/node_modules/@metro-labs/whatsapp/src/login.ts +1 -1
- package/runtime/node_modules/@metro-labs/whatsapp/src/media.ts +1 -1
- package/runtime/node_modules/@metro-labs/whatsapp/src/members.ts +94 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/messages.ts +70 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/names.ts +75 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/parse.ts +44 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/resolve.ts +52 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/send-expiry.ts +65 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/station.ts +24 -1
- package/runtime/node_modules/@metro-labs/whatsapp/src/token-store.ts +5 -9
- package/runtime/node_modules/@metro-labs/whatsapp/src/types.ts +0 -1
- package/runtime/node_modules/@metro-labs/xmtp/package.json +4 -3
- package/runtime/node_modules/@metro-labs/xmtp/src/accounts.ts +10 -20
- package/runtime/node_modules/@metro-labs/xmtp/src/actions-close.ts +2 -2
- package/runtime/node_modules/@metro-labs/xmtp/src/actions-conv.ts +55 -224
- package/runtime/node_modules/@metro-labs/xmtp/src/actions-meta.ts +47 -53
- package/runtime/node_modules/@metro-labs/xmtp/src/actions.ts +114 -223
- package/runtime/node_modules/@metro-labs/xmtp/src/attachments.ts +58 -15
- package/runtime/node_modules/@metro-labs/xmtp/src/call-leftovers.ts +48 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/channels.ts +56 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/codecs.ts +114 -3
- package/runtime/node_modules/@metro-labs/xmtp/src/conv-helpers.ts +35 -20
- package/runtime/node_modules/@metro-labs/xmtp/src/delete-requests.ts +34 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/emit-payloads.ts +38 -25
- package/runtime/node_modules/@metro-labs/xmtp/src/emit.ts +8 -18
- package/runtime/node_modules/@metro-labs/xmtp/src/frames.ts +190 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/group-members.ts +1 -1
- package/runtime/node_modules/@metro-labs/xmtp/src/group.ts +2 -2
- package/runtime/node_modules/@metro-labs/xmtp/src/identity.ts +30 -16
- package/runtime/node_modules/@metro-labs/xmtp/src/index.ts +18 -70
- package/runtime/node_modules/@metro-labs/xmtp/src/labels.ts +102 -50
- package/runtime/node_modules/@metro-labs/xmtp/src/member-args.ts +1 -1
- package/runtime/node_modules/@metro-labs/xmtp/src/names.ts +61 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/network.ts +114 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/profile.ts +160 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/read-attachments.ts +37 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/resolve.ts +44 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/sender.ts +112 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/smart.ts +79 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/station.ts +10 -2
- package/runtime/node_modules/@metro-labs/xmtp/src/stream.ts +66 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/tools-handlers.ts +22 -58
- package/runtime/node_modules/@metro-labs/xmtp/src/tools.ts +72 -49
- package/runtime/node_modules/@metro-labs/xmtp/src/transcribe.ts +4 -6
- package/runtime/node_modules/@metro-labs/xmtp/src/verify.ts +19 -5
- package/runtime/node_modules/@metro-labs/xmtp/src/wallet.ts +28 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/wire.ts +14 -4
- package/runtime/patches/5bca2c07d5852d3f58453cff0448dd85da13d3665b61e3d758905b298d432d7c.patch +31 -0
- package/runtime/runtime.json +1 -1
- package/runtime/sdk-runner/node_modules/@metro-labs/core/package.json +58 -0
- package/runtime/sdk-runner/node_modules/@metro-labs/core/src/automation-files.ts +216 -0
- package/runtime/sdk-runner/node_modules/@metro-labs/core/src/automation-store.ts +171 -0
- package/runtime/sdk-runner/node_modules/@metro-labs/core/src/automation-types.ts +141 -0
- package/runtime/sdk-runner/node_modules/@metro-labs/core/src/call.ts +81 -0
- package/runtime/sdk-runner/node_modules/@metro-labs/core/src/endpoints.ts +7 -0
- package/runtime/sdk-runner/node_modules/@metro-labs/core/src/events.ts +165 -0
- package/runtime/sdk-runner/node_modules/@metro-labs/core/src/ids.ts +28 -0
- package/runtime/sdk-runner/node_modules/@metro-labs/core/src/is-record.ts +2 -0
- package/runtime/sdk-runner/node_modules/@metro-labs/core/src/lines.ts +78 -0
- package/runtime/sdk-runner/node_modules/@metro-labs/core/src/log.ts +42 -0
- package/runtime/sdk-runner/node_modules/@metro-labs/core/src/protocol.ts +227 -0
- package/runtime/sdk-runner/node_modules/@metro-labs/core/src/runner-activity.ts +270 -0
- package/runtime/sdk-runner/node_modules/@metro-labs/core/src/secure-fs.ts +74 -0
- package/runtime/sdk-runner/node_modules/@metro-labs/core/src/skill-source.ts +96 -0
- package/runtime/sdk-runner/node_modules/@metro-labs/core/src/station-names.ts +14 -0
- package/runtime/sdk-runner/node_modules/@metro-labs/core/src/stations/account-files.ts +41 -0
- package/runtime/sdk-runner/node_modules/@metro-labs/core/src/stations/account-store.ts +83 -0
- package/runtime/sdk-runner/node_modules/@metro-labs/core/src/stations/attachments.ts +202 -0
- package/runtime/sdk-runner/node_modules/@metro-labs/core/src/stations/channel-directory.ts +159 -0
- package/runtime/sdk-runner/node_modules/@metro-labs/core/src/stations/channel-pages.ts +129 -0
- package/runtime/sdk-runner/node_modules/@metro-labs/core/src/stations/mail-text.ts +72 -0
- package/runtime/sdk-runner/node_modules/@metro-labs/core/src/stations/mail-trust.ts +29 -0
- package/runtime/sdk-runner/node_modules/@metro-labs/core/src/stations/mail.ts +212 -0
- package/runtime/sdk-runner/node_modules/@metro-labs/core/src/stations/messaging-normalize.ts +16 -0
- package/runtime/sdk-runner/node_modules/@metro-labs/core/src/stations/oauth.ts +126 -0
- package/runtime/sdk-runner/node_modules/@metro-labs/core/src/stations/profile.ts +58 -0
- package/runtime/sdk-runner/node_modules/@metro-labs/core/src/stations/sender-profile.ts +64 -0
- package/runtime/sdk-runner/node_modules/@metro-labs/core/src/stations/station-runtime.ts +59 -0
- package/runtime/sdk-runner/node_modules/@metro-labs/core/src/stations/train-boot.ts +63 -0
- package/runtime/sdk-runner/node_modules/@metro-labs/core/src/stations/train-events.ts +84 -0
- package/runtime/sdk-runner/node_modules/@metro-labs/core/src/stations/types.ts +126 -0
- package/runtime/sdk-runner/node_modules/@metro-labs/core/src/str.ts +5 -0
- package/runtime/sdk-runner/node_modules/@metro-labs/core/src/tickets.ts +44 -0
- package/runtime/sdk-runner/node_modules/@metro-labs/core/src/train-error.ts +53 -0
- package/runtime/sdk-runner/node_modules/@metro-labs/core/src/version.ts +2 -0
- package/runtime/sdk-runner/runner.json +10 -0
- package/runtime/sdk-runner/src/activity-tasks.ts +194 -0
- package/runtime/sdk-runner/src/activity.ts +391 -0
- package/runtime/sdk-runner/src/app.ts +87 -0
- package/runtime/sdk-runner/src/approvals.ts +37 -0
- package/runtime/sdk-runner/src/automation-cli.ts +10 -0
- package/runtime/sdk-runner/src/automation-command.ts +151 -0
- package/runtime/sdk-runner/src/automation.ts +145 -0
- package/runtime/sdk-runner/src/calls.ts +133 -0
- package/runtime/sdk-runner/src/channel-text.ts +26 -0
- package/runtime/sdk-runner/src/config.ts +50 -0
- package/runtime/sdk-runner/src/errors.ts +142 -0
- package/runtime/sdk-runner/src/inbox.ts +168 -0
- package/runtime/sdk-runner/src/input-queue.ts +77 -0
- package/runtime/sdk-runner/src/input-timing.ts +68 -0
- package/runtime/sdk-runner/src/link.ts +154 -0
- package/runtime/sdk-runner/src/main.ts +57 -0
- package/runtime/sdk-runner/src/recovery.ts +46 -0
- package/runtime/sdk-runner/src/rules.ts +28 -0
- package/runtime/sdk-runner/src/runner.ts +358 -0
- package/runtime/sdk-runner/src/session-store.ts +129 -0
- package/runtime/sdk-runner/src/session-watch.ts +158 -0
- package/runtime/sdk-runner/src/singleton.ts +15 -0
- package/runtime/sdk-runner/src/skill-work.ts +76 -0
- package/runtime/sdk-runner/src/skills-files.ts +169 -0
- package/runtime/sdk-runner/src/skills.ts +150 -0
- package/runtime/sdk-runner/src/task-ledger.ts +229 -0
- package/runtime/sdk-runner/src/task-recovery.ts +203 -0
- package/runtime/sdk-runner/src/task-state.ts +71 -0
- package/runtime/sdk-runner/src/tool-proxy.ts +40 -0
- package/runtime/server.ts +1 -0
- package/runtime/stations.json +43 -0
- package/skills/MEMORY.md +78 -0
- package/skills/METRO.md +33 -0
- package/skills/STAGE.md +109 -0
- package/dist/bedrock-eventstream.js +0 -120
- package/dist/bedrock-proxy.js +0 -260
- package/dist/bedrock-upstream.js +0 -72
- package/dist/bedrock.js +0 -106
- package/dist/claude.js +0 -15
- package/dist/plugin.js +0 -82
- package/dist/prompt.js +0 -61
- package/dist/store.js +0 -93
- package/runtime/node_modules/@metro-labs/discord-bot/src/voice-speak.ts +0 -195
- package/runtime/node_modules/@metro-labs/discord-bot/src/voice-transcribe.ts +0 -292
- package/runtime/node_modules/@metro-labs/discord-bot/src/voice.ts +0 -197
- package/runtime/node_modules/@metro-labs/discord-bot/src/wire.ts +0 -5
- package/runtime/node_modules/@metro-labs/mcp/package.json +0 -66
- package/runtime/node_modules/@metro-labs/mcp/src/channels/dedupe.ts +0 -24
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/account-api.ts +0 -311
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/agent-api.ts +0 -332
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/agent-connector-api.ts +0 -150
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/agent-pair.ts +0 -20
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/api-http.ts +0 -152
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/boot.ts +0 -330
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/cli-pair-api.ts +0 -125
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/connector-api.ts +0 -313
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/connector-json.ts +0 -21
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/connector-oauth-routes.ts +0 -157
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/connector-oauth.ts +0 -127
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/connector-tools.ts +0 -100
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/connector-verify.ts +0 -333
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/google-auth.ts +0 -164
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/google-oauth.ts +0 -208
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/identity.ts +0 -79
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/oauth-pending.ts +0 -65
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/pair-codes.ts +0 -58
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/project-api.ts +0 -214
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/relay.ts +0 -303
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/run-api.ts +0 -139
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/runtime-source.ts +0 -105
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/session-apis.ts +0 -48
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/session.ts +0 -218
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/tunnel.ts +0 -169
- package/runtime/node_modules/@metro-labs/mcp/src/db/account-attach.ts +0 -91
- package/runtime/node_modules/@metro-labs/mcp/src/db/agent-admin.ts +0 -215
- package/runtime/node_modules/@metro-labs/mcp/src/db/agent-connectors.ts +0 -143
- package/runtime/node_modules/@metro-labs/mcp/src/db/agent-map.ts +0 -71
- package/runtime/node_modules/@metro-labs/mcp/src/db/client.ts +0 -37
- package/runtime/node_modules/@metro-labs/mcp/src/db/connector-config.ts +0 -147
- package/runtime/node_modules/@metro-labs/mcp/src/db/connector-relay.ts +0 -126
- package/runtime/node_modules/@metro-labs/mcp/src/db/connectors.ts +0 -308
- package/runtime/node_modules/@metro-labs/mcp/src/db/projects.ts +0 -300
- package/runtime/node_modules/@metro-labs/mcp/src/db/runtime-admin.ts +0 -24
- package/runtime/node_modules/@metro-labs/mcp/src/db/runtimes.ts +0 -105
- package/runtime/node_modules/@metro-labs/mcp/src/db/schema.ts +0 -117
- package/runtime/node_modules/@metro-labs/mcp/src/db/token-carry.ts +0 -45
- package/runtime/node_modules/@metro-labs/mcp/src/db/users.ts +0 -62
- package/runtime/node_modules/@metro-labs/mcp/src/db/whatsapp-login.ts +0 -18
- package/runtime/node_modules/@metro-labs/mcp/src/mcp/channel-owner.ts +0 -29
- package/runtime/node_modules/@metro-labs/mcp/src/mcp/frame-scope.ts +0 -21
- package/runtime/node_modules/@metro-labs/mcp/src/mcp/index.ts +0 -192
- package/runtime/node_modules/@metro-labs/mcp/src/mcp/permission-relay.ts +0 -66
- package/runtime/node_modules/@metro-labs/mcp/src/mcp/request-identity.ts +0 -73
- package/runtime/node_modules/@metro-labs/mcp/src/mcp/session-registry.ts +0 -172
- package/runtime/node_modules/@metro-labs/mcp/src/mcp/session-route.ts +0 -43
- package/runtime/node_modules/@metro-labs/mcp/src/monitor/api.ts +0 -240
- package/runtime/node_modules/@metro-labs/mcp/src/server.ts +0 -2
- package/runtime/node_modules/@metro-labs/mcp/src/stations/account-store.ts +0 -80
- package/runtime/node_modules/@metro-labs/mcp/src/stations/messaging-normalize.ts +0 -88
- package/runtime/node_modules/@metro-labs/telegram/src/normalize.ts +0 -22
- package/runtime/node_modules/@metro-labs/telegram/src/wire.ts +0 -1
- package/runtime/node_modules/@metro-labs/telegram-bot/src/wire.ts +0 -3
- package/runtime/node_modules/@metro-labs/whatsapp/src/normalize.ts +0 -22
- package/runtime/node_modules/@metro-labs/whatsapp/src/wire.ts +0 -5
- package/runtime/node_modules/@metro-labs/xmtp/src/actions-push.ts +0 -87
- package/runtime/node_modules/@metro-labs/xmtp/src/emit-core.ts +0 -55
- package/runtime/node_modules/@metro-labs/xmtp/src/push.ts +0 -349
- /package/runtime/node_modules/@metro-labs/{mcp/src/daemon → core/src}/log.ts +0 -0
- /package/runtime/node_modules/@metro-labs/{mcp/src/mcp → core/src}/str.ts +0 -0
- /package/runtime/node_modules/@metro-labs/{mcp/src/daemon → core/src}/train-error.ts +0 -0
- /package/runtime/node_modules/@metro-labs/{mcp → daemon}/src/channels/webhook-note.ts +0 -0
- /package/runtime/node_modules/@metro-labs/{mcp/src/daemon → http/src}/api-error.ts +0 -0
- /package/runtime/node_modules/@metro-labs/{mcp/src/daemon → http/src}/cors.ts +0 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
|
+
import type { IncomingMessage } from 'node:http';
|
|
3
|
+
import { cameThroughProxy } from '@metro-labs/http/api-http';
|
|
4
|
+
import { agentIdForKey } from '../agents/keys.js';
|
|
5
|
+
|
|
6
|
+
export interface RequestIdentity {
|
|
7
|
+
kind: 'agent';
|
|
8
|
+
agentId: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const storage = new AsyncLocalStorage<RequestIdentity>();
|
|
12
|
+
|
|
13
|
+
export function runWithIdentity<T>(
|
|
14
|
+
identity: RequestIdentity,
|
|
15
|
+
fn: () => Promise<T>,
|
|
16
|
+
): Promise<T> {
|
|
17
|
+
return storage.run(identity, fn);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function currentIdentity(): RequestIdentity | undefined {
|
|
21
|
+
return storage.getStore();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function extractToken(req: IncomingMessage): string | undefined {
|
|
25
|
+
const header = req.headers.authorization;
|
|
26
|
+
if (header?.startsWith('Bearer ')) {
|
|
27
|
+
const t = header.slice(7).trim();
|
|
28
|
+
if (t) return t;
|
|
29
|
+
}
|
|
30
|
+
const qt = new URL(req.url ?? '/', 'http://localhost').searchParams.get(
|
|
31
|
+
'token',
|
|
32
|
+
);
|
|
33
|
+
return qt ?? undefined;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function authenticate(req: IncomingMessage): RequestIdentity | null {
|
|
37
|
+
if (cameThroughProxy(req)) return null;
|
|
38
|
+
const token = extractToken(req);
|
|
39
|
+
if (!token) return null;
|
|
40
|
+
const agentId = agentIdForKey(token);
|
|
41
|
+
return agentId === undefined ? null : { kind: 'agent', agentId };
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function allowedAgents(
|
|
45
|
+
identity: RequestIdentity | undefined,
|
|
46
|
+
): Set<string> {
|
|
47
|
+
return identity ? new Set([identity.agentId]) : new Set();
|
|
48
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type { MetroEvent } from '@metro-labs/core/events';
|
|
2
|
+
import { errMsg, log } from '@metro-labs/core/log';
|
|
3
|
+
import type { McpApproval, McpDecision } from '@metro-labs/http/mcp-server-protocol';
|
|
4
|
+
import { holdPrompt, isPromptHeld, type Behavior } from '../approvals/pending.js';
|
|
5
|
+
import { ownerLine } from '../approvals/owner-line.js';
|
|
6
|
+
import { metroNotice } from '../channels/notice.js';
|
|
7
|
+
import { announcedLine, noteAnnounced } from '../mcp-server/announced.js';
|
|
8
|
+
import type { AnswerOutcome } from '../mcp-server/link.js';
|
|
9
|
+
import { serverPromptBody } from './permission-prompt.js';
|
|
10
|
+
import { metroSend, relayLine } from './permission-relay.js';
|
|
11
|
+
import { channelLog, type McpSession } from './session.js';
|
|
12
|
+
|
|
13
|
+
const RECENT_MS = 10 * 60_000;
|
|
14
|
+
const RECENT_MAX = 1_000;
|
|
15
|
+
|
|
16
|
+
const owner = {};
|
|
17
|
+
const recent = new Map<string, number>();
|
|
18
|
+
let current: () => McpSession | undefined = () => undefined;
|
|
19
|
+
|
|
20
|
+
export function connectServerApprovals(session: () => McpSession | undefined): void {
|
|
21
|
+
current = session;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function promptLineFor(requestId: string): string | undefined {
|
|
25
|
+
const session = current();
|
|
26
|
+
if (session === undefined) return undefined;
|
|
27
|
+
return relayLine({ relay: session.relay, inScope: (line) => session.inScope(line), live: session.live, log: channelLog }, requestId);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const noticeLineFor = (line: string | undefined): string | undefined => line ?? current()?.relay.knownLine ?? ownerLine()?.line;
|
|
31
|
+
|
|
32
|
+
function remember(id: string, now = Date.now()): void {
|
|
33
|
+
for (const [seen, at] of recent) if (now - at >= RECENT_MS) recent.delete(seen);
|
|
34
|
+
recent.set(id, now);
|
|
35
|
+
while (recent.size > RECENT_MAX) {
|
|
36
|
+
const oldest = recent.keys().next();
|
|
37
|
+
if (oldest.done) break;
|
|
38
|
+
recent.delete(oldest.value);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const answeredRecently = (id: string, now = Date.now()): boolean => now - (recent.get(id) ?? -Infinity) < RECENT_MS;
|
|
43
|
+
|
|
44
|
+
const noticeText = (tool: string, id: string, behavior: Behavior): string =>
|
|
45
|
+
behavior === 'allow' ? `Approved: ${tool} (${id}). Call tool_call again with the same arguments and approval: "${id}".` : `Denied: ${tool} (${id}).`;
|
|
46
|
+
|
|
47
|
+
const requestedAt = (at: number, now = Date.now()): number => (Number.isFinite(at) && at > 0 ? Math.min(at, now) : now);
|
|
48
|
+
|
|
49
|
+
interface Held {
|
|
50
|
+
id: string;
|
|
51
|
+
tool: string;
|
|
52
|
+
line: string | undefined;
|
|
53
|
+
answer: (decision: McpDecision) => Promise<AnswerOutcome>;
|
|
54
|
+
publish: (event: MetroEvent) => void;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async function deliver(held: Held, behavior: Behavior): Promise<void> {
|
|
58
|
+
const outcome = await held.answer(behavior);
|
|
59
|
+
if (outcome !== 'acknowledged') {
|
|
60
|
+
log.info({ id: held.id, outcome }, 'mcp-server: the answer was not taken, so the agent is not told');
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const line = noticeLineFor(held.line);
|
|
64
|
+
if (line === undefined) {
|
|
65
|
+
log.warn({ id: held.id }, 'mcp-server: no chat is known to tell the agent the answer');
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
held.publish(metroNotice(line, noticeText(held.tool, held.id, behavior)));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function sender(held: Held): (behavior: Behavior) => Promise<void> {
|
|
72
|
+
return (behavior) => {
|
|
73
|
+
remember(held.id);
|
|
74
|
+
deliver(held, behavior).catch((err: unknown) => {
|
|
75
|
+
log.warn({ id: held.id, err: errMsg(err) }, 'mcp-server: the answer could not be delivered');
|
|
76
|
+
});
|
|
77
|
+
return Promise.resolve();
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function announce(id: string, line: string, text: string): void {
|
|
82
|
+
metroSend(line, text).then(() => {
|
|
83
|
+
noteAnnounced(id, line);
|
|
84
|
+
}).catch((err: unknown) => {
|
|
85
|
+
log.warn({ id, err: errMsg(err) }, 'mcp-server: the approval prompt could not be posted');
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function holdServerApproval(approval: McpApproval, answer: Held['answer'], publish: Held['publish']): boolean {
|
|
90
|
+
if (isPromptHeld(approval.id) || answeredRecently(approval.id)) return false;
|
|
91
|
+
const tool = `${approval.connector}.${approval.tool}`;
|
|
92
|
+
const announced = announcedLine(approval.id);
|
|
93
|
+
const line = announced ?? promptLineFor(approval.id);
|
|
94
|
+
const held: Held = { id: approval.id, tool, line, answer, publish };
|
|
95
|
+
holdPrompt(
|
|
96
|
+
{ requestId: approval.id, tool, description: approval.connector, preview: approval.preview, line, at: requestedAt(approval.requestedAt), origin: 'mcp-server' },
|
|
97
|
+
owner,
|
|
98
|
+
sender(held),
|
|
99
|
+
line === undefined ? undefined : async (text) => metroSend(line, text),
|
|
100
|
+
);
|
|
101
|
+
log.info({ id: approval.id, tool, inChat: line !== undefined, announced: announced !== undefined }, 'mcp-server: an approval is waiting for the owner');
|
|
102
|
+
if (line !== undefined && announced === undefined) announce(approval.id, line, serverPromptBody({ requestId: approval.id, tool, preview: approval.preview }));
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function forgetServerApprovals(): void {
|
|
107
|
+
recent.clear();
|
|
108
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { currentBusSeq } from '@metro-labs/core/events';
|
|
3
|
+
import { errMsg } from '@metro-labs/core/log';
|
|
4
|
+
import { newReplayLedger } from '../channels/relay.js';
|
|
5
|
+
import { McpSession, channelLog } from './session.js';
|
|
6
|
+
import { allowedAgents, type RequestIdentity } from './request-identity.js';
|
|
7
|
+
import { diagnosticTag, type SessionDiagnostic, type SlotDiagnostic } from './diagnostics.js';
|
|
8
|
+
|
|
9
|
+
interface SlotReplacement {
|
|
10
|
+
at: string;
|
|
11
|
+
reason: 'initialize' | 'adopt';
|
|
12
|
+
tag: string;
|
|
13
|
+
scope: Set<string>;
|
|
14
|
+
previousScope: Set<string>;
|
|
15
|
+
previous: SessionDiagnostic | null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const sharesScope = (left: Set<string>, right: Set<string>): boolean => [...left].some((id) => right.has(id));
|
|
19
|
+
|
|
20
|
+
export class SessionSlot {
|
|
21
|
+
private session: McpSession | undefined;
|
|
22
|
+
private readonly ledger = newReplayLedger();
|
|
23
|
+
private started = false;
|
|
24
|
+
private live: boolean;
|
|
25
|
+
private changing: Promise<void> = Promise.resolve();
|
|
26
|
+
private readonly replacements: SlotReplacement[] = [];
|
|
27
|
+
|
|
28
|
+
constructor(live = true) {
|
|
29
|
+
this.live = live;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
get current(): McpSession | undefined {
|
|
33
|
+
return this.session;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
get liveEvents(): boolean {
|
|
37
|
+
return this.live;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
diagnostics(scope: Set<string>): SlotDiagnostic {
|
|
41
|
+
return {
|
|
42
|
+
started: this.started,
|
|
43
|
+
liveEvents: this.live,
|
|
44
|
+
current: this.session !== undefined && sharesScope(scope, this.session.scope) ? this.session.diagnostics() : null,
|
|
45
|
+
replacements: this.replacements.filter((replacement) => sharesScope(scope, replacement.scope)).map((replacement) => ({
|
|
46
|
+
at: replacement.at,
|
|
47
|
+
reason: replacement.reason,
|
|
48
|
+
tag: replacement.tag,
|
|
49
|
+
previous: sharesScope(scope, replacement.previousScope) ? replacement.previous : null,
|
|
50
|
+
})),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
startInbound(): void {
|
|
55
|
+
if (this.started) return;
|
|
56
|
+
this.started = true;
|
|
57
|
+
if (this.ledger.startAt < 0) this.ledger.startAt = currentBusSeq();
|
|
58
|
+
if (this.live) this.session?.startChannel();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
setLive(on: boolean): void {
|
|
62
|
+
if (this.live === on) return;
|
|
63
|
+
this.live = on;
|
|
64
|
+
channelLog('inbound: live events', on ? 'on' : 'off');
|
|
65
|
+
if (!on) {
|
|
66
|
+
this.session?.stopChannel();
|
|
67
|
+
this.session?.relay.dropPending();
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
this.ledger.startAt = currentBusSeq();
|
|
71
|
+
if (this.started) this.session?.startChannel();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
open(identity: RequestIdentity, adoptId?: string): Promise<McpSession> {
|
|
75
|
+
return this.change(() => this.replace(identity, adoptId));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
private change<T>(run: () => Promise<T>): Promise<T> {
|
|
79
|
+
const changed = this.changing.then(run);
|
|
80
|
+
this.changing = changed.then(() => undefined).catch((err: unknown) => {
|
|
81
|
+
channelLog('session: change failed', errMsg(err));
|
|
82
|
+
});
|
|
83
|
+
return changed;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
private previousSlot(): Pick<SlotReplacement, 'previous' | 'previousScope'> {
|
|
87
|
+
return {
|
|
88
|
+
previous: this.session?.diagnostics() ?? null,
|
|
89
|
+
previousScope: this.session?.scope ?? new Set<string>(),
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
private recordReplacement(session: McpSession, adoptId: string | undefined, previous: Pick<SlotReplacement, 'previous' | 'previousScope'>): void {
|
|
94
|
+
this.replacements.push({
|
|
95
|
+
at: new Date().toISOString(),
|
|
96
|
+
reason: adoptId === undefined ? 'initialize' : 'adopt',
|
|
97
|
+
tag: diagnosticTag(session.id),
|
|
98
|
+
scope: session.scope,
|
|
99
|
+
...previous,
|
|
100
|
+
});
|
|
101
|
+
if (this.replacements.length > 8) this.replacements.shift();
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
private async replace(identity: RequestIdentity, adoptId?: string): Promise<McpSession> {
|
|
105
|
+
if (adoptId !== undefined && this.session?.id === adoptId) return this.session;
|
|
106
|
+
const previous = this.previousSlot();
|
|
107
|
+
await this.session?.close();
|
|
108
|
+
if (this.ledger.startAt < 0) this.ledger.startAt = currentBusSeq();
|
|
109
|
+
const id = adoptId ?? randomUUID();
|
|
110
|
+
const session = await McpSession.open({
|
|
111
|
+
id,
|
|
112
|
+
scope: allowedAgents(identity),
|
|
113
|
+
adopted: adoptId !== undefined,
|
|
114
|
+
ledger: this.ledger,
|
|
115
|
+
live: () => this.live,
|
|
116
|
+
onClosed: (s) => {
|
|
117
|
+
if (this.session === s) this.session = undefined;
|
|
118
|
+
s.channel.whenIdle().then(() => {
|
|
119
|
+
if (this.session?.streamAttached) this.session.replayMissed();
|
|
120
|
+
}).catch((err: unknown) => {
|
|
121
|
+
channelLog('session: handoff replay failed', errMsg(err));
|
|
122
|
+
});
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
this.session = session;
|
|
126
|
+
this.recordReplacement(session, adoptId, previous);
|
|
127
|
+
if (this.started && this.live) session.startChannel();
|
|
128
|
+
channelLog('session: opened', 'id', id, 'adopted', adoptId !== undefined);
|
|
129
|
+
return session;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
close(): Promise<void> {
|
|
133
|
+
return this.change(async () => {
|
|
134
|
+
await this.session?.close();
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
2
2
|
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
3
3
|
import { InboundRelay } from '../channels/inbound.js';
|
|
4
|
+
import { answerPrompt, forgetPromptsOf, promptLine } from '../approvals/pending.js';
|
|
5
|
+
import { noteOwnerLine } from '../approvals/owner-line.js';
|
|
4
6
|
import { ChannelRelay, type ReplayLedger } from '../channels/relay.js';
|
|
5
|
-
import { errMsg } from '
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
} from '
|
|
10
|
-
import { accountStationNames } from '../stations/registry.js';
|
|
11
|
-
import { MCP_INSTRUCTIONS } from './tool-schemas.js';
|
|
12
|
-
import { ChannelOwner } from './channel-owner.js';
|
|
7
|
+
import { errMsg } from '@metro-labs/core/log';
|
|
8
|
+
import { allowlistForLine, mayApprove, senderPermitted } from '../agents/map.js';
|
|
9
|
+
import { accountStationNames, stationByName } from '../stations/registry.js';
|
|
10
|
+
import { eventInScope } from '../agents/scope.js';
|
|
11
|
+
import { MCP_INSTRUCTIONS } from './instructions.js';
|
|
13
12
|
import { BoundedEventStore } from './event-store.js';
|
|
14
13
|
import { registerPermissionRelay } from './permission-relay.js';
|
|
15
14
|
import { registerToolHandlers, toolSchemaSignature } from './tool-dispatch.js';
|
|
16
15
|
import { web, type RawGetSink } from './raw-get-stream.js';
|
|
17
|
-
import
|
|
16
|
+
import { sharedCalls } from '../voice/shared.js';
|
|
17
|
+
import { CALL_STATE } from '@metro-labs/core/call';
|
|
18
|
+
import { clientDiagnostic, diagnosticTag, type SessionDiagnostic } from './diagnostics.js';
|
|
18
19
|
|
|
19
20
|
export const channelLog = (...a: unknown[]): void => {
|
|
20
21
|
console.error('[metro-mcp]', ...a);
|
|
@@ -22,11 +23,20 @@ export const channelLog = (...a: unknown[]): void => {
|
|
|
22
23
|
|
|
23
24
|
const getStations = (): Set<string> => new Set(accountStationNames());
|
|
24
25
|
|
|
25
|
-
const senderAllowed = (from: string, line: string): boolean =>
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
const senderAllowed = (from: string, line: string, verified?: boolean): boolean =>
|
|
27
|
+
senderPermitted(allowlistForLine(line), from, verified);
|
|
28
|
+
|
|
29
|
+
const approves = (station: string): boolean => stationByName(station)?.approvals !== false;
|
|
30
|
+
|
|
31
|
+
const noteDirect = (line: string, from: string): void => {
|
|
32
|
+
if (mayApprove(line, from)) noteOwnerLine(line, from);
|
|
28
33
|
};
|
|
29
34
|
|
|
35
|
+
async function answerPermission(requestId: string, behavior: 'allow' | 'deny', line: string, from: string): Promise<boolean> {
|
|
36
|
+
if (promptLine(requestId) !== line || !mayApprove(line, from)) return false;
|
|
37
|
+
return (await answerPrompt(requestId, behavior, 'chat', line)) !== undefined;
|
|
38
|
+
}
|
|
39
|
+
|
|
30
40
|
function makeTransport(
|
|
31
41
|
id: string,
|
|
32
42
|
eventStore: BoundedEventStore,
|
|
@@ -47,51 +57,48 @@ function makeTransport(
|
|
|
47
57
|
|
|
48
58
|
export interface SessionInit {
|
|
49
59
|
id: string;
|
|
50
|
-
|
|
60
|
+
scope: Set<string>;
|
|
51
61
|
adopted: boolean;
|
|
52
62
|
ledger: ReplayLedger;
|
|
63
|
+
live: () => boolean;
|
|
53
64
|
onClosed: (session: McpSession) => void;
|
|
54
65
|
}
|
|
55
66
|
|
|
56
67
|
export class McpSession {
|
|
57
68
|
readonly id: string;
|
|
58
|
-
readonly
|
|
59
|
-
readonly owner = new ChannelOwner();
|
|
69
|
+
readonly scope: Set<string>;
|
|
60
70
|
readonly eventStore: BoundedEventStore;
|
|
61
71
|
readonly transport: StreamableHTTPServerTransport;
|
|
62
72
|
readonly server: Server;
|
|
63
73
|
readonly relay: InboundRelay;
|
|
64
74
|
readonly channel: ChannelRelay;
|
|
65
|
-
|
|
75
|
+
readonly live: () => boolean;
|
|
66
76
|
private sink: RawGetSink | undefined;
|
|
67
77
|
private unsubscribe: (() => void) | undefined;
|
|
68
78
|
private closed = false;
|
|
69
79
|
private issuedSchema: string | undefined;
|
|
70
80
|
private announcing = false;
|
|
71
81
|
private readonly onClosed: (session: McpSession) => void;
|
|
82
|
+
private readonly openedAt = new Date().toISOString();
|
|
83
|
+
private clientInitializedAt: string | null = null;
|
|
84
|
+
private lastStreamAttachedAt: string | null = null;
|
|
85
|
+
private lastStreamDetachedAt: string | null = null;
|
|
72
86
|
|
|
73
87
|
private constructor(init: SessionInit) {
|
|
74
88
|
this.id = init.id;
|
|
75
|
-
this.
|
|
89
|
+
this.scope = init.scope;
|
|
90
|
+
this.live = init.live;
|
|
76
91
|
this.issuedSchema = init.adopted ? undefined : toolSchemaSignature();
|
|
77
92
|
this.onClosed = init.onClosed;
|
|
78
|
-
this.eventStore = new BoundedEventStore(
|
|
79
|
-
scopeOf: () => this.owner.scope(),
|
|
80
|
-
});
|
|
93
|
+
this.eventStore = new BoundedEventStore();
|
|
81
94
|
this.transport = makeTransport(init.id, this.eventStore, init.adopted);
|
|
82
95
|
this.server = new Server(
|
|
83
96
|
{ name: 'metro', version: '0.1.0' },
|
|
84
|
-
{
|
|
85
|
-
capabilities: {
|
|
86
|
-
experimental: {
|
|
87
|
-
'claude/channel': {},
|
|
88
|
-
'claude/channel/permission': {},
|
|
89
|
-
},
|
|
90
|
-
tools: { listChanged: true },
|
|
91
|
-
},
|
|
92
|
-
instructions: MCP_INSTRUCTIONS,
|
|
93
|
-
},
|
|
97
|
+
{ capabilities: { tools: { listChanged: true } }, instructions: MCP_INSTRUCTIONS },
|
|
94
98
|
);
|
|
99
|
+
this.server.oninitialized = (): void => {
|
|
100
|
+
this.clientInitializedAt = new Date().toISOString();
|
|
101
|
+
};
|
|
95
102
|
registerToolHandlers(this.server, {
|
|
96
103
|
markCurrent: (): void => {
|
|
97
104
|
this.issuedSchema = toolSchemaSignature();
|
|
@@ -99,23 +106,32 @@ export class McpSession {
|
|
|
99
106
|
deliver: (send): void => {
|
|
100
107
|
this.deliverSchemaNotice(send, 'request');
|
|
101
108
|
},
|
|
109
|
+
}, {
|
|
110
|
+
onSent: (id): void => {
|
|
111
|
+
this.relay.noteSent(id);
|
|
112
|
+
},
|
|
102
113
|
});
|
|
103
114
|
this.relay = new InboundRelay({
|
|
104
115
|
mcp: this.server,
|
|
105
116
|
log: channelLog,
|
|
106
117
|
getStations,
|
|
107
118
|
senderAllowed,
|
|
119
|
+
approves,
|
|
120
|
+
noteDirect,
|
|
121
|
+
answerPermission,
|
|
122
|
+
callMeta: (event) => sharedCalls.bindChat(event, this.scope),
|
|
108
123
|
});
|
|
109
124
|
registerPermissionRelay({
|
|
110
125
|
mcp: this.server,
|
|
111
126
|
relay: this.relay,
|
|
112
|
-
|
|
127
|
+
inScope: (line) => this.inScope(line),
|
|
128
|
+
live: this.live,
|
|
113
129
|
log: channelLog,
|
|
114
130
|
});
|
|
115
131
|
this.channel = new ChannelRelay({
|
|
116
132
|
relay: this.relay,
|
|
117
133
|
log: channelLog,
|
|
118
|
-
inScope: (line) => this.
|
|
134
|
+
inScope: (line) => this.live() && this.inScope(line),
|
|
119
135
|
ledger: init.ledger,
|
|
120
136
|
});
|
|
121
137
|
}
|
|
@@ -139,28 +155,70 @@ export class McpSession {
|
|
|
139
155
|
return this.sink;
|
|
140
156
|
}
|
|
141
157
|
|
|
142
|
-
|
|
143
|
-
|
|
158
|
+
diagnostics(): SessionDiagnostic {
|
|
159
|
+
return {
|
|
160
|
+
tag: diagnosticTag(this.id),
|
|
161
|
+
openedAt: this.openedAt,
|
|
162
|
+
transportInitialized: web(this.transport)?._initialized === true,
|
|
163
|
+
clientInitializedAt: this.clientInitializedAt,
|
|
164
|
+
client: clientDiagnostic(this.server.getClientVersion()),
|
|
165
|
+
subscribed: this.unsubscribe !== undefined,
|
|
166
|
+
streamAttached: this.streamAttached,
|
|
167
|
+
lastStreamAttachedAt: this.lastStreamAttachedAt,
|
|
168
|
+
lastStreamDetachedAt: this.lastStreamDetachedAt,
|
|
169
|
+
stream: this.sink?.diagnostics() ?? null,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
inScope(line: string): boolean {
|
|
174
|
+
return this.streamAttached && eventInScope(this.scope, line);
|
|
144
175
|
}
|
|
145
176
|
|
|
146
177
|
startChannel(): void {
|
|
147
178
|
this.unsubscribe ??= this.channel.start();
|
|
148
179
|
}
|
|
149
180
|
|
|
150
|
-
|
|
151
|
-
this.
|
|
152
|
-
|
|
153
|
-
|
|
181
|
+
stopChannel(): void {
|
|
182
|
+
this.unsubscribe?.();
|
|
183
|
+
this.unsubscribe = undefined;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
replayMissed(): void {
|
|
187
|
+
if (this.live()) this.channel.replayMissed();
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
bindSink(sink: RawGetSink | undefined): void {
|
|
191
|
+
if (this.closed) {
|
|
192
|
+
sink?.close();
|
|
154
193
|
return;
|
|
155
194
|
}
|
|
156
|
-
this.
|
|
157
|
-
this.
|
|
195
|
+
if (sink === undefined && this.sink !== undefined) this.lastStreamDetachedAt = new Date().toISOString();
|
|
196
|
+
this.sink = sink;
|
|
197
|
+
if (sink !== undefined) {
|
|
198
|
+
this.lastStreamAttachedAt = new Date().toISOString();
|
|
199
|
+
this.announceCallState();
|
|
200
|
+
this.announceToolSchema();
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
private announceCallState(): void {
|
|
205
|
+
if (!this.streamAttached || this.server.getClientVersion()?.name !== 'metro-sdk-runner') return;
|
|
206
|
+
const active = sharedCalls.snapshot();
|
|
207
|
+
const route = active !== null && this.scope.has(active.agentId) && eventInScope(this.scope, active.line) ? active : null;
|
|
208
|
+
this.server.notification({ method: CALL_STATE, params: { route, ...(route === null ? {} : { meta: { line: route.line } }) } }).catch((err: unknown) => {
|
|
209
|
+
channelLog('session: call state notification failed', errMsg(err));
|
|
210
|
+
if (route !== null) sharedCalls.end(route);
|
|
211
|
+
});
|
|
158
212
|
}
|
|
159
213
|
|
|
160
214
|
private get schemaNoticeDue(): boolean {
|
|
161
215
|
return this.issuedSchema !== toolSchemaSignature();
|
|
162
216
|
}
|
|
163
217
|
|
|
218
|
+
toolsChanged(): void {
|
|
219
|
+
this.announceToolSchema();
|
|
220
|
+
}
|
|
221
|
+
|
|
164
222
|
private announceToolSchema(): void {
|
|
165
223
|
if (!this.streamAttached) return;
|
|
166
224
|
this.deliverSchemaNotice(
|
|
@@ -172,15 +230,7 @@ export class McpSession {
|
|
|
172
230
|
private deliverSchemaNotice(send: () => Promise<void>, via: string): void {
|
|
173
231
|
if (!this.schemaNoticeDue || this.announcing) return;
|
|
174
232
|
this.announcing = true;
|
|
175
|
-
channelLog(
|
|
176
|
-
'session: tool list changed',
|
|
177
|
-
'id',
|
|
178
|
-
this.id,
|
|
179
|
-
'scope',
|
|
180
|
-
this.scopeKey,
|
|
181
|
-
'via',
|
|
182
|
-
via,
|
|
183
|
-
);
|
|
233
|
+
channelLog('session: tool list changed', 'id', this.id, 'via', via);
|
|
184
234
|
send()
|
|
185
235
|
.then(() => {
|
|
186
236
|
this.issuedSchema = toolSchemaSignature();
|
|
@@ -194,18 +244,19 @@ export class McpSession {
|
|
|
194
244
|
|
|
195
245
|
dropStream(): void {
|
|
196
246
|
const sink = this.sink;
|
|
247
|
+
if (sink !== undefined) this.lastStreamDetachedAt = new Date().toISOString();
|
|
197
248
|
this.sink = undefined;
|
|
198
|
-
this.owner.releaseStream();
|
|
199
249
|
sink?.close();
|
|
200
250
|
}
|
|
201
251
|
|
|
202
252
|
async close(): Promise<void> {
|
|
203
253
|
if (this.closed) return;
|
|
204
254
|
this.closed = true;
|
|
255
|
+
sharedCalls.revoke();
|
|
205
256
|
this.onClosed(this);
|
|
257
|
+
forgetPromptsOf(this.server);
|
|
206
258
|
this.dropStream();
|
|
207
|
-
this.
|
|
208
|
-
this.unsubscribe = undefined;
|
|
259
|
+
this.stopChannel();
|
|
209
260
|
await this.server.close().catch(() => undefined);
|
|
210
261
|
}
|
|
211
262
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const speechSchema = {
|
|
2
|
+
type: 'object',
|
|
3
|
+
description: 'Speak text only in the exact active Stage call, without posting it in chat. Copy callId, generation and sourceId from its authenticated call input or call_id, call_generation and call_source_id from the requesting channel message. Use only for a call reply or an explicit owner request to speak in that call. Normal chat and worker results stay silent. One action per source; retries do not repeat speech. Accepted or queued is not heard. Completed means audio transport drained, not proof the caller heard it.',
|
|
4
|
+
properties: {
|
|
5
|
+
callId: { type: 'string' },
|
|
6
|
+
generation: { type: 'string' },
|
|
7
|
+
sourceId: { type: 'string' },
|
|
8
|
+
},
|
|
9
|
+
required: ['callId', 'generation', 'sourceId'],
|
|
10
|
+
additionalProperties: false,
|
|
11
|
+
} as const;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { speechTarget } from '@metro-labs/core/call';
|
|
2
|
+
import type { ToolResult } from '@metro-labs/core/stations/types';
|
|
3
|
+
import { sharedCalls } from '../voice/shared.js';
|
|
4
|
+
import { allowedAgents, currentIdentity } from './request-identity.js';
|
|
5
|
+
import { errResult, okJson } from './ctx.js';
|
|
6
|
+
|
|
7
|
+
export function sendSpeech(line: string, args: Record<string, unknown>): ToolResult {
|
|
8
|
+
const target = speechTarget(args.speech);
|
|
9
|
+
if (target === null) return errResult('Call speech needs callId, generation and sourceId from its authenticated source.');
|
|
10
|
+
if (['reply_to', 'subject', 'attachments', 'frame', 'wallet', 'account'].some((key) => args[key] !== undefined))
|
|
11
|
+
return errResult('Call speech cannot include chat content, media or an account override. Nothing was sent.');
|
|
12
|
+
if (typeof args.text !== 'string') return errResult('Call speech needs text.');
|
|
13
|
+
const receipt = sharedCalls.speak(line, target, args.text, allowedAgents(currentIdentity()));
|
|
14
|
+
return okJson({ speech: receipt, delivery: 'Audio transport status only. No proof the caller heard it. No chat message was posted.' });
|
|
15
|
+
}
|