@stage-labs/metro 0.1.0-beta.3 → 0.1.0-beta.300
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 +128 -0
- package/dist/api.js +11 -0
- package/dist/automation.js +56 -0
- package/dist/background.js +141 -0
- package/dist/claude-settings.js +40 -0
- package/dist/claude.js +204 -0
- package/dist/cli.js +109 -258
- package/dist/control.js +74 -0
- package/dist/hold.js +210 -0
- package/dist/local.js +43 -0
- package/dist/mcp-config.js +27 -0
- package/dist/memory.js +222 -0
- package/dist/native-recovery-scan.js +246 -0
- package/dist/native-recovery-state.js +154 -0
- package/dist/native-recovery.js +164 -0
- package/dist/node-name.js +71 -0
- package/dist/onboarding.js +44 -0
- package/dist/provider-flags.js +9 -0
- package/dist/root-release-io.js +161 -0
- package/dist/root-release.js +74 -0
- package/dist/route.js +66 -0
- package/dist/runtime-install.js +114 -0
- package/dist/runtime.js +71 -0
- package/dist/serve.js +157 -0
- package/dist/service.js +328 -0
- package/dist/tail.js +119 -0
- package/dist/update.js +45 -0
- package/dist/version.js +97 -0
- package/dist/voice.js +56 -0
- package/package.json +14 -22
- package/runtime/marketplace/.claude-plugin/marketplace.json +12 -0
- package/runtime/marketplace/plugin/.claude-plugin/plugin.json +17 -0
- package/runtime/marketplace/plugin/.mcp.json +1 -0
- package/runtime/marketplace/plugin/MEMORY.md +78 -0
- package/runtime/marketplace/plugin/METRO.md +26 -0
- package/runtime/marketplace/plugin/STAGE.md +109 -0
- package/runtime/marketplace/plugin/bin/guard.mjs +75 -0
- package/runtime/marketplace/plugin/bin/metro-plugin.mjs +30 -0
- package/runtime/marketplace/plugin/bin/policy.mjs +105 -0
- package/runtime/marketplace/plugin/bin/session-start.mjs +31 -0
- package/runtime/marketplace/plugin/hooks/hooks.json +25 -0
- package/runtime/node_modules/@metro-labs/core/package.json +59 -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/connector-sync.ts +17 -0
- package/runtime/node_modules/@metro-labs/core/src/endpoints.ts +7 -0
- package/runtime/node_modules/@metro-labs/core/src/events.ts +165 -0
- package/runtime/node_modules/@metro-labs/core/src/ids.ts +28 -0
- package/runtime/node_modules/@metro-labs/core/src/is-record.ts +2 -0
- package/runtime/node_modules/@metro-labs/core/src/lines.ts +78 -0
- package/runtime/node_modules/@metro-labs/core/src/log.ts +42 -0
- package/runtime/node_modules/@metro-labs/core/src/protocol.ts +227 -0
- package/runtime/node_modules/@metro-labs/core/src/runner-activity.ts +263 -0
- package/runtime/node_modules/@metro-labs/core/src/secure-fs.ts +74 -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/core/src/stations/attachments.ts +202 -0
- 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/core/src/stations/station-runtime.ts +59 -0
- 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/core/src/stations/types.ts +126 -0
- package/runtime/node_modules/@metro-labs/core/src/str.ts +5 -0
- package/runtime/node_modules/@metro-labs/core/src/tickets.ts +44 -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 +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 +113 -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 +92 -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 +91 -0
- package/runtime/node_modules/@metro-labs/daemon/src/agent-user/view.ts +93 -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 +133 -0
- package/runtime/node_modules/@metro-labs/daemon/src/agents/bundle.ts +132 -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/daemon/src/agents/keys.ts +35 -0
- 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/daemon/src/agents/scope.ts +64 -0
- 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 +189 -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 +250 -0
- package/runtime/node_modules/@metro-labs/daemon/src/boot/connect-hint.ts +36 -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 +21 -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 +26 -0
- package/runtime/node_modules/@metro-labs/daemon/src/channels/inbound.ts +390 -0
- package/runtime/node_modules/@metro-labs/daemon/src/channels/media-note.ts +89 -0
- package/runtime/node_modules/@metro-labs/daemon/src/channels/pending.ts +87 -0
- package/runtime/node_modules/@metro-labs/daemon/src/channels/react-note.ts +13 -0
- package/runtime/node_modules/@metro-labs/daemon/src/channels/relay.ts +133 -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 +316 -0
- package/runtime/node_modules/@metro-labs/daemon/src/claude/channel-check.ts +56 -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 +259 -0
- package/runtime/node_modules/@metro-labs/daemon/src/claude/github-validate.ts +53 -0
- package/runtime/node_modules/@metro-labs/daemon/src/claude/login.ts +242 -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 +60 -0
- package/runtime/node_modules/@metro-labs/daemon/src/claude/pinned.ts +16 -0
- package/runtime/node_modules/@metro-labs/daemon/src/claude/plugin-install.ts +149 -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/runner.ts +45 -0
- package/runtime/node_modules/@metro-labs/daemon/src/claude/session-continuity.ts +57 -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 +382 -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 +161 -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 +346 -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/claude/version.ts +76 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/agent-key.ts +148 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/api.ts +316 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/config.ts +105 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/enroll-api.ts +101 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/gates.ts +114 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/health.ts +18 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/metro-api.ts +93 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/migration-api.ts +60 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/migration-control.ts +366 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/migration-guard.ts +95 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/migration-operations.ts +226 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/migration-preview.ts +235 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/migration-source.ts +42 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/migration-state.ts +142 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/migration-url.ts +9 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/oauth-routes.ts +178 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/oauth.ts +171 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/org-relay.ts +61 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/org-runtime-discovery.ts +115 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/org-runtime.ts +327 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/org-sync-api.ts +25 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/org-sync-control.ts +191 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/org-sync-setting.ts +60 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/org-sync-watch.ts +53 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/org-sync.ts +208 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/plugin-sync.ts +170 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/publication.ts +61 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/relay-id.ts +2 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/relay-passive.ts +96 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/relay-policy.ts +90 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/relay-session.ts +11 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/relay-target.ts +4 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/relay.ts +392 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/server-keys.ts +46 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/store.ts +393 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/tools.ts +1 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/transfer-api.ts +116 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/transfer-crypto.ts +44 -0
- package/runtime/node_modules/@metro-labs/daemon/src/connectors/transfer-store.ts +46 -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-reaper.ts +174 -0
- package/runtime/node_modules/@metro-labs/daemon/src/files/attach-serve.ts +123 -0
- package/runtime/node_modules/@metro-labs/daemon/src/files/upload-api.ts +278 -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 +233 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/claude-logins.ts +168 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/codex-auth.ts +219 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/codex-device.ts +119 -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 +143 -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 +147 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/forward.ts +285 -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 +396 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/gemini-auth.ts +160 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/gemini-client.ts +46 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/gemini-setup.ts +150 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/gemini-stream.ts +139 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/gemini-translate.ts +236 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/gemini.ts +208 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/model-api.ts +259 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/model-config.ts +362 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/model-lists.ts +57 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/model-signin.ts +157 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/model-store.ts +83 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/openrouter-login.ts +192 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/openrouter-signin.ts +64 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/openrouter.ts +104 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/pkce.ts +36 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/provider-models.ts +117 -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 +35 -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 +115 -0
- package/runtime/node_modules/@metro-labs/daemon/src/gateway/usage.ts +343 -0
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/accounts.ts +165 -0
- 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/daemon/src/mcp/call-tools.ts +253 -0
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/channel-tool.ts +80 -0
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/ctx.ts +62 -0
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/diagnostics.ts +102 -0
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/event-store.ts +97 -0
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/frame-schema.ts +44 -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 +169 -0
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/instructions.ts +30 -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-prompt.ts +108 -0
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/permission-relay.ts +109 -0
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/policy-gate.ts +87 -0
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/policy-snapshot.ts +79 -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/daemon/src/mcp/raw-get-stream.ts +245 -0
- 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/session-slot.ts +141 -0
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/session.ts +270 -0
- 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 +96 -0
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/tool-def.ts +9 -0
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/tool-dispatch.ts +232 -0
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/tool-schemas.ts +370 -0
- package/runtime/node_modules/@metro-labs/daemon/src/mcp/upload-tool.ts +61 -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 +119 -0
- package/runtime/node_modules/@metro-labs/daemon/src/routes/bearer.ts +38 -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/daemon/src/routes/http.ts +371 -0
- package/runtime/node_modules/@metro-labs/daemon/src/routes/local-mode.ts +229 -0
- package/runtime/node_modules/@metro-labs/daemon/src/routes/session-apis.ts +82 -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/daemon/src/stations/attach-inline.ts +128 -0
- package/runtime/node_modules/@metro-labs/daemon/src/stations/attach-interactive.ts +135 -0
- package/runtime/node_modules/@metro-labs/daemon/src/stations/attach-resolve.ts +271 -0
- package/runtime/node_modules/@metro-labs/daemon/src/stations/attach-session.ts +314 -0
- package/runtime/node_modules/@metro-labs/daemon/src/stations/attach-xmtp.ts +110 -0
- package/runtime/node_modules/@metro-labs/daemon/src/stations/attach.ts +248 -0
- package/runtime/node_modules/@metro-labs/daemon/src/stations/materialize.ts +267 -0
- package/runtime/node_modules/@metro-labs/daemon/src/stations/registry.ts +53 -0
- package/runtime/node_modules/@metro-labs/daemon/src/stations/runtime-deps.ts +135 -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/threema-callbacks.ts +32 -0
- package/runtime/node_modules/@metro-labs/daemon/src/stations/train-call.ts +22 -0
- 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/approvals.ts +38 -0
- package/runtime/node_modules/@metro-labs/daemon/src/voice/audio.ts +193 -0
- package/runtime/node_modules/@metro-labs/daemon/src/voice/brain.ts +146 -0
- package/runtime/node_modules/@metro-labs/daemon/src/voice/call.ts +274 -0
- package/runtime/node_modules/@metro-labs/daemon/src/voice/calls.ts +156 -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 +200 -0
- package/runtime/node_modules/@metro-labs/daemon/src/voice/speakable.ts +54 -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 +129 -0
- package/runtime/node_modules/@metro-labs/daemon/src/voice/store.ts +116 -0
- package/runtime/node_modules/@metro-labs/daemon/src/voice/talk.ts +264 -0
- package/runtime/node_modules/@metro-labs/discord-bot/package.json +26 -0
- package/runtime/node_modules/@metro-labs/discord-bot/src/accounts.ts +99 -0
- package/runtime/node_modules/@metro-labs/discord-bot/src/actions.ts +222 -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/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 +169 -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 +121 -0
- package/runtime/node_modules/@metro-labs/discord-bot/src/members.ts +215 -0
- 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 +42 -0
- package/runtime/node_modules/@metro-labs/discord-bot/src/station.ts +24 -0
- package/runtime/node_modules/@metro-labs/discord-bot/src/verify.ts +82 -0
- 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 +43 -0
- package/runtime/node_modules/@metro-labs/http/src/agent-signature.ts +110 -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 +147 -0
- package/runtime/node_modules/@metro-labs/http/src/connector-delivery-validation.ts +116 -0
- package/runtime/node_modules/@metro-labs/http/src/connector-delivery.ts +19 -0
- package/runtime/node_modules/@metro-labs/http/src/connector-discovery.ts +150 -0
- package/runtime/node_modules/@metro-labs/http/src/connector-grant.ts +59 -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/http/src/connector-migration.ts +178 -0
- package/runtime/node_modules/@metro-labs/http/src/connector-oauth.ts +182 -0
- 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 +94 -0
- package/runtime/node_modules/@metro-labs/http/src/connector-url.ts +37 -0
- package/runtime/node_modules/@metro-labs/http/src/cors.ts +29 -0
- package/runtime/node_modules/@metro-labs/http/src/ed25519.ts +56 -0
- package/runtime/node_modules/@metro-labs/http/src/mode-api.ts +31 -0
- 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/transfer-crypto.ts +44 -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 +26 -0
- package/runtime/node_modules/@metro-labs/telegram/src/accounts.ts +62 -0
- package/runtime/node_modules/@metro-labs/telegram/src/actions.ts +275 -0
- package/runtime/node_modules/@metro-labs/telegram/src/attachments.ts +87 -0
- package/runtime/node_modules/@metro-labs/telegram/src/channels.ts +58 -0
- package/runtime/node_modules/@metro-labs/telegram/src/client.ts +77 -0
- package/runtime/node_modules/@metro-labs/telegram/src/format.ts +126 -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 +57 -0
- package/runtime/node_modules/@metro-labs/telegram/src/index.ts +7 -0
- package/runtime/node_modules/@metro-labs/telegram/src/login.ts +166 -0
- package/runtime/node_modules/@metro-labs/telegram/src/media-actions.ts +79 -0
- package/runtime/node_modules/@metro-labs/telegram/src/members.ts +75 -0
- package/runtime/node_modules/@metro-labs/telegram/src/profile.ts +70 -0
- package/runtime/node_modules/@metro-labs/telegram/src/reactions.ts +167 -0
- package/runtime/node_modules/@metro-labs/telegram/src/station.ts +28 -0
- package/runtime/node_modules/@metro-labs/telegram/src/types.ts +6 -0
- package/runtime/node_modules/@metro-labs/telegram-bot/package.json +25 -0
- package/runtime/node_modules/@metro-labs/telegram-bot/src/accounts.ts +86 -0
- package/runtime/node_modules/@metro-labs/telegram-bot/src/actions.ts +242 -0
- package/runtime/node_modules/@metro-labs/telegram-bot/src/attachments.ts +128 -0
- 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 +170 -0
- package/runtime/node_modules/@metro-labs/telegram-bot/src/index.ts +74 -0
- package/runtime/node_modules/@metro-labs/telegram-bot/src/media-actions.ts +90 -0
- package/runtime/node_modules/@metro-labs/telegram-bot/src/members.ts +47 -0
- 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 +25 -0
- package/runtime/node_modules/@metro-labs/telegram-bot/src/types.ts +83 -0
- package/runtime/node_modules/@metro-labs/telegram-bot/src/updates.ts +26 -0
- package/runtime/node_modules/@metro-labs/telegram-bot/src/verify.ts +38 -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 +23 -0
- package/runtime/node_modules/@metro-labs/webhook/src/station.ts +37 -0
- package/runtime/node_modules/@metro-labs/whatsapp/package.json +26 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/accounts.ts +45 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/ack.ts +101 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/actions.ts +263 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/app-state.ts +49 -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/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 +400 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/delivery.ts +49 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/format.ts +81 -0
- 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 +40 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/index.ts +7 -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/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/outbox.ts +38 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/parse.ts +185 -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 +40 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/token-store.ts +94 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/types.ts +5 -0
- package/runtime/node_modules/@metro-labs/xmtp/package.json +34 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/accounts.ts +103 -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 +130 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/actions-meta.ts +151 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/actions.ts +266 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/attachments.ts +150 -0
- 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 +282 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/conv-helpers.ts +254 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/delete-requests.ts +34 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/emit-payloads.ts +346 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/emit.ts +68 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/frames.ts +190 -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 +47 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/index.ts +73 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/labels.ts +209 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/member-args.ts +40 -0
- 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 +21 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/stream.ts +66 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/tools-handlers.ts +90 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/tools.ts +235 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/transcribe.ts +88 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/verify.ts +98 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/wallet.ts +28 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/wire.ts +49 -0
- package/runtime/patches/5bca2c07d5852d3f58453cff0448dd85da13d3665b61e3d758905b298d432d7c.patch +31 -0
- package/runtime/runtime.json +3 -0
- package/runtime/sdk-runner/node_modules/@metro-labs/core/package.json +59 -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/connector-sync.ts +17 -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 +263 -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 +131 -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 +55 -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 +357 -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/runtime/trains/.keep +0 -0
- package/LICENSE +0 -21
- package/README.md +0 -114
- package/dist/agents/claude.js +0 -229
- package/dist/agents/codex.js +0 -282
- package/dist/agents/types.js +0 -3
- package/dist/channels/discord.js +0 -142
- package/dist/channels/telegram.js +0 -209
- package/dist/lib/dotenv.js +0 -31
- package/dist/lib/scope-cache.js +0 -85
- package/dist/lib/streaming.js +0 -207
- package/dist/log.js +0 -12
- package/dist/orchestrator.js +0 -399
- package/dist/paths.js +0 -33
package/dist/cli.js
CHANGED
|
@@ -1,266 +1,117 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
2
|
+
import { whoisAuthorized } from './api.js';
|
|
3
|
+
import { stopAll } from './control.js';
|
|
4
|
+
import { tailEvents } from './tail.js';
|
|
5
|
+
import { agentSession } from './agent.js';
|
|
6
|
+
import { automationCommand } from './automation.js';
|
|
7
|
+
import { launchClaude } from './claude.js';
|
|
8
|
+
import { memoryPaths, memoryRoutine } from './memory.js';
|
|
9
|
+
import { update } from './update.js';
|
|
10
|
+
import { serve } from './serve.js';
|
|
11
|
+
import { service, serviceStopHint } from './service.js';
|
|
12
|
+
import { currentVersion } from './version.js';
|
|
13
|
+
import { voiceSession } from './voice.js';
|
|
14
|
+
const USAGE = `metro: run your agent on this machine
|
|
12
15
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
metro
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
metro serve [--port <n>] [--owner <organization id>]
|
|
17
|
+
run the daemon: the agent, its channels and its connectors live in
|
|
18
|
+
~/.metro/agents here, and it is published through Tailscale Funnel at a
|
|
19
|
+
permanent https://<machine>.<tailnet>.ts.net (Tailscale installed and
|
|
20
|
+
signed in on this machine); the page at metro.box manages it through the
|
|
21
|
+
link it prints; --owner names the organization whose members may sign
|
|
22
|
+
in, needed on the first start only; Stop on the page parks the daemon and keeps the
|
|
23
|
+
address, so Start works from the page too
|
|
24
|
+
metro service install [--port <n>] [--owner <organization id>] [--user metro]
|
|
25
|
+
run metro serve as a service (systemd on Linux, launchd on macOS): it
|
|
26
|
+
starts at boot and after a crash, so the page can stop, start and
|
|
27
|
+
restart it with no shell; on Linux, root passes --user metro so Metro
|
|
28
|
+
runs as its own user and Claude Code as the user agent;
|
|
29
|
+
metro service uninstall and status as well
|
|
30
|
+
metro stop stop metro on this machine, metro serve included
|
|
31
|
+
metro tail [agent-id]
|
|
32
|
+
follow this machine's inbound events, one JSON line each
|
|
33
|
+
metro whoami print the agent this machine runs
|
|
34
|
+
metro claude [args...]
|
|
35
|
+
open Claude Code with the metro channel and the metro MCP server, its
|
|
36
|
+
inference routed through the daemon's model gateway (the Model page);
|
|
37
|
+
every argument is passed through the same
|
|
38
|
+
metro agent run chat, calls and background workers in one Agent SDK conversation,
|
|
39
|
+
when the Harness runner is Agent SDK, using the Model page's model;
|
|
40
|
+
resume it after a restart; call audio runs independently
|
|
41
|
+
metro agent --prepare [cli|sdk]
|
|
42
|
+
check the runner before selecting it; install the SDK runtime if needed,
|
|
43
|
+
without starting a session or connecting to chat
|
|
44
|
+
metro task submit <routine> <prompt-file> [--slot <UTC ISO timestamp>] [--dry-run]
|
|
45
|
+
metro task status [routine]
|
|
46
|
+
metro task finish <uuid> <token> completed|blocked
|
|
47
|
+
queue work without starting a session, or read safe local task metadata;
|
|
48
|
+
default slot is the current UTC hour; use --slot for other cadences;
|
|
49
|
+
accepted is saved, not executed; finish awaits runner verification;
|
|
50
|
+
--dry-run writes nothing; local authorization is not fresh owner approval
|
|
51
|
+
metro memory [skill file]
|
|
52
|
+
run the memory routine once: when Claude Code transcripts changed since
|
|
53
|
+
the last run, Claude Code reads the memory skill (or the file given) and
|
|
54
|
+
files them into its memory, with no metro tools and writes only inside
|
|
55
|
+
the memory folder
|
|
56
|
+
metro voice --model <model>
|
|
57
|
+
the agent's side of a voice call, which the daemon starts when a call
|
|
58
|
+
comes in: Claude Code reads the call's words as stream-json on stdin and
|
|
59
|
+
streams its replies on stdout, with the agent's memory, skills, plugin,
|
|
60
|
+
connectors and metro tools (on /mcp/voice, so the chat session keeps its
|
|
61
|
+
slot) but no metro channel; tool approvals come back on stdout
|
|
62
|
+
metro update update to the newest published version (--check only reports)
|
|
63
|
+
metro version print this CLI's version
|
|
25
64
|
|
|
26
|
-
|
|
27
|
-
|
|
65
|
+
METRO_WEBHOOK_PORT the daemon's port (default 8420)
|
|
66
|
+
METRO_AGENTS_DIR where the agents live (default ~/.metro/agents)
|
|
67
|
+
METRO_AGENT_KEY the key metro tail presents, instead of the agent file's
|
|
68
|
+
METRO_RUNTIME_DIR run the daemon from this directory instead of the bundled one
|
|
28
69
|
`;
|
|
29
|
-
function
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
flags[a.slice(2, eq)] = a.slice(eq + 1);
|
|
42
|
-
continue;
|
|
43
|
-
}
|
|
44
|
-
const key = a.slice(2);
|
|
45
|
-
const next = argv[i + 1];
|
|
46
|
-
if (next !== undefined && !next.startsWith('--')) {
|
|
47
|
-
flags[key] = next;
|
|
48
|
-
i++;
|
|
49
|
-
}
|
|
50
|
-
else
|
|
51
|
-
flags[key] = true;
|
|
52
|
-
}
|
|
53
|
-
return { positional, flags };
|
|
54
|
-
}
|
|
55
|
-
const isJson = (f) => f.json === true;
|
|
56
|
-
const emitResult = (f, human, structured) => {
|
|
57
|
-
process.stdout.write(isJson(f) ? JSON.stringify(structured) + '\n' : human + '\n');
|
|
58
|
-
};
|
|
59
|
-
function maskToken(t) {
|
|
60
|
-
if (!t)
|
|
61
|
-
return '';
|
|
62
|
-
if (t.length <= 8)
|
|
63
|
-
return '••••';
|
|
64
|
-
return `${t.slice(0, 6)}…${t.slice(-2)}`;
|
|
65
|
-
}
|
|
66
|
-
const TOKEN_KEYS = { telegram: 'TELEGRAM_BOT_TOKEN', discord: 'DISCORD_BOT_TOKEN' };
|
|
67
|
-
async function cmdSetup(positional, flags) {
|
|
68
|
-
const [sub, value] = positional;
|
|
69
|
-
if (!sub)
|
|
70
|
-
return cmdSetupStatus(flags);
|
|
71
|
-
if (sub === 'telegram' || sub === 'discord') {
|
|
72
|
-
if (!value)
|
|
73
|
-
throw new Error(`metro setup ${sub} <token> — token is required`);
|
|
74
|
-
const trimmed = value.trim();
|
|
75
|
-
let identity;
|
|
76
|
-
if (!flags['no-validate']) {
|
|
77
|
-
process.env[TOKEN_KEYS[sub]] = trimmed;
|
|
78
|
-
try {
|
|
79
|
-
identity = sub === 'telegram' ? `@${(await telegram.getMe()).username}` : (await discord.getMe()).username;
|
|
80
|
-
}
|
|
81
|
-
catch (err) {
|
|
82
|
-
delete process.env[TOKEN_KEYS[sub]];
|
|
83
|
-
throw exitErr(`token rejected by ${sub}: ${errMsg(err)} (use --no-validate to save anyway)`, 3);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
const env = readDotenv(CONFIG_ENV_FILE);
|
|
87
|
-
env[TOKEN_KEYS[sub]] = trimmed;
|
|
88
|
-
writeDotenv(CONFIG_ENV_FILE, env);
|
|
89
|
-
const human = identity
|
|
90
|
-
? `saved ${TOKEN_KEYS[sub]} (verified as ${identity}) to ${CONFIG_ENV_FILE} (chmod 0600)`
|
|
91
|
-
: `saved ${TOKEN_KEYS[sub]} to ${CONFIG_ENV_FILE} (chmod 0600)`;
|
|
92
|
-
emitResult(flags, human, { ok: true, saved: TOKEN_KEYS[sub], verified_as: identity ?? null });
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
if (sub === 'clear') {
|
|
96
|
-
const target = value ?? 'all';
|
|
97
|
-
const env = readDotenv(CONFIG_ENV_FILE);
|
|
98
|
-
if (target === 'all') {
|
|
99
|
-
delete env.TELEGRAM_BOT_TOKEN;
|
|
100
|
-
delete env.DISCORD_BOT_TOKEN;
|
|
101
|
-
}
|
|
102
|
-
else if (target === 'telegram' || target === 'discord')
|
|
103
|
-
delete env[TOKEN_KEYS[target]];
|
|
104
|
-
else
|
|
105
|
-
throw new Error(`metro setup clear <telegram|discord|all> — got '${target}'`);
|
|
106
|
-
writeDotenv(CONFIG_ENV_FILE, env);
|
|
107
|
-
emitResult(flags, `cleared ${target === 'all' ? 'all metro tokens' : TOKEN_KEYS[target]}`, { ok: true, cleared: target });
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
throw new Error(`unknown setup subcommand '${sub}' (try: telegram, discord, clear)`);
|
|
111
|
-
}
|
|
112
|
-
async function cmdSetupStatus(flags) {
|
|
113
|
-
loadMetroEnv();
|
|
114
|
-
const tg = process.env.TELEGRAM_BOT_TOKEN ?? '';
|
|
115
|
-
const dc = process.env.DISCORD_BOT_TOKEN ?? '';
|
|
116
|
-
if (isJson(flags)) {
|
|
117
|
-
process.stdout.write(JSON.stringify({
|
|
118
|
-
version: pkg.version,
|
|
119
|
-
config_env_file: CONFIG_ENV_FILE,
|
|
120
|
-
tokens: {
|
|
121
|
-
telegram: { set: !!tg, masked: maskToken(tg) },
|
|
122
|
-
discord: { set: !!dc, masked: maskToken(dc) },
|
|
123
|
-
},
|
|
124
|
-
}) + '\n');
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
process.stdout.write(`metro ${pkg.version}\n\n` +
|
|
128
|
-
`config: ${CONFIG_ENV_FILE}${existsSync(CONFIG_ENV_FILE) ? '' : ' (not yet written)'}\n\n` +
|
|
129
|
-
` TELEGRAM_BOT_TOKEN ${tg ? `set (${maskToken(tg)})` : 'not set'}\n` +
|
|
130
|
-
` DISCORD_BOT_TOKEN ${dc ? `set (${maskToken(dc)})` : 'not set'}\n\n`);
|
|
131
|
-
if (!tg && !dc) {
|
|
132
|
-
process.stdout.write('Get started:\n' +
|
|
133
|
-
' 1. metro setup telegram <token> # https://t.me/BotFather\n' +
|
|
134
|
-
' metro setup discord <token> # https://discord.com/developers/applications\n' +
|
|
135
|
-
' 2. metro doctor # verify\n' +
|
|
136
|
-
' 3. metro # run the orchestrator\n');
|
|
137
|
-
}
|
|
138
|
-
else {
|
|
139
|
-
process.stdout.write('Run `metro` to start the orchestrator, or `metro doctor` to verify.\n');
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
async function cmdDoctor(flags) {
|
|
143
|
-
loadMetroEnv();
|
|
144
|
-
const checks = [];
|
|
145
|
-
const cfg = configuredPlatforms();
|
|
146
|
-
checks.push({
|
|
147
|
-
name: 'tokens',
|
|
148
|
-
ok: cfg.telegram || cfg.discord,
|
|
149
|
-
detail: cfg.telegram || cfg.discord
|
|
150
|
-
? `loaded from ${existsSync(CONFIG_ENV_FILE) ? CONFIG_ENV_FILE : 'process env'}`
|
|
151
|
-
: 'no platform configured — run `metro setup telegram|discord <token>`',
|
|
152
|
-
});
|
|
153
|
-
for (const [platform, getMe] of [['telegram', telegram.getMe], ['discord', discord.getMe]]) {
|
|
154
|
-
if (!cfg[platform]) {
|
|
155
|
-
checks.push({ name: platform, ok: null, detail: 'not configured' });
|
|
156
|
-
continue;
|
|
157
|
-
}
|
|
158
|
-
try {
|
|
159
|
-
const me = await getMe();
|
|
160
|
-
checks.push({ name: platform, ok: true, detail: `getMe → ${platform === 'telegram' ? '@' : ''}${me.username}` });
|
|
161
|
-
}
|
|
162
|
-
catch (err) {
|
|
163
|
-
checks.push({ name: platform, ok: false, detail: errMsg(err) });
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
const lockFile = join(STATE_DIR, '.tail-lock');
|
|
167
|
-
if (!existsSync(lockFile)) {
|
|
168
|
-
checks.push({ name: 'orchestrator', ok: null, detail: 'not running' });
|
|
169
|
-
}
|
|
170
|
-
else {
|
|
171
|
-
try {
|
|
172
|
-
const pid = Number(readFileSync(lockFile, 'utf8').trim());
|
|
173
|
-
if (!Number.isInteger(pid) || pid <= 0)
|
|
174
|
-
throw new Error('invalid pid');
|
|
175
|
-
process.kill(pid, 0);
|
|
176
|
-
checks.push({ name: 'orchestrator', ok: true, detail: `running (pid ${pid})` });
|
|
177
|
-
}
|
|
178
|
-
catch {
|
|
179
|
-
checks.push({ name: 'orchestrator', ok: null, detail: 'stale lockfile (will auto-reclaim on next start)' });
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
if (isJson(flags)) {
|
|
183
|
-
process.stdout.write(JSON.stringify({ checks }) + '\n');
|
|
184
|
-
}
|
|
185
|
-
else {
|
|
186
|
-
process.stdout.write('metro doctor\n\n');
|
|
187
|
-
for (const c of checks) {
|
|
188
|
-
const icon = c.ok === true ? '✓' : c.ok === false ? '✗' : '–';
|
|
189
|
-
process.stdout.write(` ${icon} ${c.name.padEnd(15)} ${c.detail}\n`);
|
|
190
|
-
}
|
|
191
|
-
process.stdout.write('\n');
|
|
192
|
-
}
|
|
193
|
-
if (checks.some(c => c.ok === false))
|
|
194
|
-
throw exitErr('one or more checks failed', 3);
|
|
195
|
-
}
|
|
196
|
-
async function cmdUpdate(flags) {
|
|
197
|
-
const tag = pkg.version.includes('-') ? 'beta' : 'latest';
|
|
198
|
-
const res = await fetch('https://registry.npmjs.org/@stage-labs/metro', { signal: AbortSignal.timeout(15_000) });
|
|
199
|
-
if (!res.ok)
|
|
200
|
-
throw new Error(`npm registry: ${res.status}`);
|
|
201
|
-
const data = (await res.json());
|
|
202
|
-
const latest = data['dist-tags']?.[tag];
|
|
203
|
-
if (!latest)
|
|
204
|
-
throw new Error(`no '${tag}' dist-tag for @stage-labs/metro`);
|
|
205
|
-
if (latest === pkg.version) {
|
|
206
|
-
emitResult(flags, `already on ${pkg.version} (latest ${tag})`, { ok: true, current: pkg.version, latest, upgraded: false });
|
|
207
|
-
return;
|
|
208
|
-
}
|
|
209
|
-
const argv1 = process.argv[1] ?? '';
|
|
210
|
-
const spec = `@stage-labs/metro@${tag}`;
|
|
211
|
-
const argv = argv1.includes('/.bun/') || argv1.includes('\\bun\\') ? ['bun', 'add', '-g', spec]
|
|
212
|
-
: argv1.includes('/pnpm/') || argv1.includes('\\pnpm\\') ? ['pnpm', 'add', '-g', spec]
|
|
213
|
-
: ['npm', 'install', '-g', spec];
|
|
214
|
-
if (isJson(flags)) {
|
|
215
|
-
process.stdout.write(JSON.stringify({ ok: true, current: pkg.version, latest, command: argv.join(' ') }) + '\n');
|
|
216
|
-
}
|
|
217
|
-
else {
|
|
218
|
-
process.stdout.write(`metro ${pkg.version} → ${latest}\n$ ${argv.join(' ')}\n`);
|
|
219
|
-
}
|
|
220
|
-
await new Promise((resolve, reject) => {
|
|
221
|
-
const child = spawn(argv[0], argv.slice(1), { stdio: isJson(flags) ? 'ignore' : 'inherit' });
|
|
222
|
-
child.on('exit', code => (code === 0 ? resolve() : reject(new Error(`${argv[0]} exited ${code}`))));
|
|
223
|
-
child.on('error', reject);
|
|
224
|
-
});
|
|
70
|
+
async function stopDaemon() {
|
|
71
|
+
const stopped = await stopAll();
|
|
72
|
+
if (stopped.length === 0) {
|
|
73
|
+
process.stderr.write('no metro daemon is running on this machine\n');
|
|
74
|
+
return 1;
|
|
75
|
+
}
|
|
76
|
+
for (const d of stopped)
|
|
77
|
+
process.stderr.write(`Stopped metro (pid ${String(d.pid)}, via ${d.via})\n`);
|
|
78
|
+
const hint = serviceStopHint();
|
|
79
|
+
if (hint !== null)
|
|
80
|
+
process.stderr.write(`${hint}\n`);
|
|
81
|
+
return 0;
|
|
225
82
|
}
|
|
83
|
+
const HELP = new Set([undefined, 'help', '--help', '-h']);
|
|
226
84
|
const COMMANDS = {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
85
|
+
whoami: async () => {
|
|
86
|
+
const { agent, where } = await whoisAuthorized();
|
|
87
|
+
process.stdout.write(`agent ${agent} on ${where}\n`);
|
|
88
|
+
return 0;
|
|
89
|
+
},
|
|
90
|
+
serve: () => serve(process.argv.slice(3)),
|
|
91
|
+
service: () => service(process.argv.slice(3)),
|
|
92
|
+
stop: stopDaemon,
|
|
93
|
+
tail: () => tailEvents(process.argv.slice(3)),
|
|
94
|
+
claude: () => launchClaude(process.argv.slice(3)),
|
|
95
|
+
agent: () => agentSession(process.argv.slice(3)),
|
|
96
|
+
task: () => automationCommand(process.argv.slice(3)),
|
|
97
|
+
memory: () => memoryRoutine(memoryPaths(process.env, process.argv[3])),
|
|
98
|
+
voice: () => voiceSession(process.argv.slice(3)),
|
|
99
|
+
update: () => update(process.argv.slice(3)),
|
|
100
|
+
version: async () => {
|
|
101
|
+
process.stdout.write(`${currentVersion()}\n`);
|
|
102
|
+
return Promise.resolve(0);
|
|
103
|
+
},
|
|
230
104
|
};
|
|
231
|
-
async function
|
|
232
|
-
const
|
|
233
|
-
if (
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
if (cmd === '--help' || cmd === '-h') {
|
|
238
|
-
process.stdout.write(USAGE);
|
|
239
|
-
return;
|
|
240
|
-
}
|
|
241
|
-
// Bare `metro` runs the orchestrator (the daemon's the default).
|
|
242
|
-
if (!cmd) {
|
|
243
|
-
await import('./orchestrator.js');
|
|
244
|
-
return;
|
|
245
|
-
}
|
|
246
|
-
const handler = COMMANDS[cmd];
|
|
247
|
-
if (!handler) {
|
|
248
|
-
process.stderr.write(`unknown command '${cmd}'\n\n${USAGE}`);
|
|
249
|
-
process.exit(1);
|
|
250
|
-
}
|
|
251
|
-
const { positional, flags } = parseArgs(process.argv.slice(3));
|
|
252
|
-
try {
|
|
253
|
-
await handler(positional, flags);
|
|
254
|
-
}
|
|
255
|
-
catch (err) {
|
|
256
|
-
const code = err.code;
|
|
257
|
-
if (isJson(flags)) {
|
|
258
|
-
process.stdout.write(JSON.stringify({ ok: false, error: errMsg(err), code: code ?? 1 }) + '\n');
|
|
259
|
-
}
|
|
260
|
-
else {
|
|
261
|
-
process.stderr.write(`error: ${errMsg(err)}\n`);
|
|
262
|
-
}
|
|
263
|
-
process.exit(typeof code === 'number' ? code : 1);
|
|
264
|
-
}
|
|
105
|
+
async function run(command) {
|
|
106
|
+
const handler = command === undefined ? undefined : COMMANDS[command];
|
|
107
|
+
if (handler !== undefined)
|
|
108
|
+
return handler();
|
|
109
|
+
process.stderr.write(USAGE);
|
|
110
|
+
return Promise.resolve(HELP.has(command) ? 0 : 1);
|
|
265
111
|
}
|
|
266
|
-
await
|
|
112
|
+
const code = await run(process.argv[2]).catch((err) => {
|
|
113
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
114
|
+
process.stderr.write(`metro: ${message}\n`);
|
|
115
|
+
return 1;
|
|
116
|
+
});
|
|
117
|
+
process.exit(code);
|
package/dist/control.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process';
|
|
2
|
+
import { readFileSync, rmSync } from 'node:fs';
|
|
3
|
+
import { homedir } from 'node:os';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
export function serveStateDir() {
|
|
6
|
+
const xdg = process.env.XDG_CACHE_HOME?.trim();
|
|
7
|
+
const base = xdg === undefined || xdg === '' ? join(homedir(), '.cache') : xdg;
|
|
8
|
+
return join(base, 'metro', 'serve');
|
|
9
|
+
}
|
|
10
|
+
const serveLockPath = () => join(serveStateDir(), '.tail-lock');
|
|
11
|
+
function isAlive(pid) {
|
|
12
|
+
try {
|
|
13
|
+
process.kill(pid, 0);
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
async function stopPid(pid, waitMs) {
|
|
21
|
+
process.kill(pid, 'SIGTERM');
|
|
22
|
+
const until = Date.now() + waitMs;
|
|
23
|
+
while (Date.now() < until) {
|
|
24
|
+
if (!isAlive(pid))
|
|
25
|
+
return;
|
|
26
|
+
await new Promise((r) => setTimeout(r, 100));
|
|
27
|
+
}
|
|
28
|
+
process.kill(pid, 'SIGKILL');
|
|
29
|
+
}
|
|
30
|
+
const lockPath = () => process.env.METRO_STATE_DIR?.trim()
|
|
31
|
+
? join(process.env.METRO_STATE_DIR.trim(), '.tail-lock')
|
|
32
|
+
: join(homedir(), '.cache', 'metro', '.tail-lock');
|
|
33
|
+
function commandOf(pid) {
|
|
34
|
+
try {
|
|
35
|
+
return execFileSync('ps', ['-o', 'command=', '-p', String(pid)], {
|
|
36
|
+
encoding: 'utf8',
|
|
37
|
+
stdio: ['ignore', 'pipe', 'ignore'],
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return '';
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const looksLikeMetro = (command) => command.includes('server.ts') || command.includes('metro');
|
|
45
|
+
function holderOf(lockFile) {
|
|
46
|
+
let pid;
|
|
47
|
+
try {
|
|
48
|
+
pid = Number(readFileSync(lockFile, 'utf8').trim());
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
if (!Number.isInteger(pid) || pid <= 0 || !isAlive(pid))
|
|
54
|
+
return null;
|
|
55
|
+
return looksLikeMetro(commandOf(pid)) ? pid : null;
|
|
56
|
+
}
|
|
57
|
+
export const lockedBy = () => holderOf(lockPath());
|
|
58
|
+
export const serveLockedBy = () => holderOf(serveLockPath());
|
|
59
|
+
export async function stopAll(waitMs = 10_000) {
|
|
60
|
+
const stopped = [];
|
|
61
|
+
const holder = lockedBy();
|
|
62
|
+
if (holder !== null) {
|
|
63
|
+
await stopPid(holder, waitMs);
|
|
64
|
+
rmSync(lockPath(), { force: true });
|
|
65
|
+
stopped.push({ pid: holder, via: 'the machine lock' });
|
|
66
|
+
}
|
|
67
|
+
const served = serveLockedBy();
|
|
68
|
+
if (served !== null && served !== holder) {
|
|
69
|
+
await stopPid(served, waitMs);
|
|
70
|
+
rmSync(serveLockPath(), { force: true });
|
|
71
|
+
stopped.push({ pid: served, via: 'metro serve' });
|
|
72
|
+
}
|
|
73
|
+
return stopped;
|
|
74
|
+
}
|
package/dist/hold.js
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
|
+
import { readFileSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { createServer } from 'node:http';
|
|
4
|
+
const FUNNEL_RETRY_MS = 2_000;
|
|
5
|
+
const FUNNEL_EXIT_WAIT_MS = 5_000;
|
|
6
|
+
const LISTEN_ATTEMPTS = 10;
|
|
7
|
+
const LISTEN_RETRY_MS = 500;
|
|
8
|
+
const STOPPED = 503;
|
|
9
|
+
export const STOPPED_MESSAGE = 'metro is stopped on this machine. Start it from the Server page on metro.box, or run metro serve.';
|
|
10
|
+
const wait = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
11
|
+
function corsHeaders(req) {
|
|
12
|
+
return {
|
|
13
|
+
'access-control-allow-origin': req.headers.origin ?? '*',
|
|
14
|
+
'access-control-allow-methods': 'GET, POST, PUT, DELETE, OPTIONS',
|
|
15
|
+
'access-control-allow-headers': 'Authorization, Content-Type',
|
|
16
|
+
'access-control-allow-private-network': 'true',
|
|
17
|
+
'access-control-max-age': '86400',
|
|
18
|
+
vary: 'Origin',
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function sendJson(req, res, status, body) {
|
|
22
|
+
res.writeHead(status, {
|
|
23
|
+
'content-type': 'application/json',
|
|
24
|
+
'cache-control': 'no-store',
|
|
25
|
+
...corsHeaders(req),
|
|
26
|
+
});
|
|
27
|
+
res.end(JSON.stringify(body));
|
|
28
|
+
}
|
|
29
|
+
function holdRequest(req, res, info, onStart) {
|
|
30
|
+
const path = (req.url ?? '').split('?')[0] ?? '';
|
|
31
|
+
if (req.method === 'OPTIONS') {
|
|
32
|
+
res.writeHead(204, corsHeaders(req)).end();
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (path === '/api/mode' && req.method === 'GET') {
|
|
36
|
+
sendJson(req, res, 200, {
|
|
37
|
+
mode: 'local',
|
|
38
|
+
owner: info.owner,
|
|
39
|
+
version: info.version,
|
|
40
|
+
stopped: true,
|
|
41
|
+
});
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (path === '/api/start') {
|
|
45
|
+
if (req.method !== 'POST') {
|
|
46
|
+
sendJson(req, res, 405, { error: 'method not allowed' });
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
sendJson(req, res, 200, { starting: true });
|
|
50
|
+
onStart();
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (path === '/health' || path === '/healthz') {
|
|
54
|
+
sendJson(req, res, STOPPED, { status: 'stopped', version: info.version });
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
sendJson(req, res, STOPPED, { error: STOPPED_MESSAGE, stopped: true });
|
|
58
|
+
}
|
|
59
|
+
export const holdServer = (info, onStart) => createServer((req, res) => {
|
|
60
|
+
holdRequest(req, res, info, onStart);
|
|
61
|
+
});
|
|
62
|
+
const lastLine = (chunk) => String(chunk).trim().split('\n').at(-1) ?? '';
|
|
63
|
+
class HeldFunnel {
|
|
64
|
+
bin;
|
|
65
|
+
port;
|
|
66
|
+
log;
|
|
67
|
+
child = null;
|
|
68
|
+
closed = false;
|
|
69
|
+
timer = null;
|
|
70
|
+
exits = 0;
|
|
71
|
+
constructor(bin, port, log) {
|
|
72
|
+
this.bin = bin;
|
|
73
|
+
this.port = port;
|
|
74
|
+
this.log = log;
|
|
75
|
+
}
|
|
76
|
+
start() {
|
|
77
|
+
if (this.closed)
|
|
78
|
+
return;
|
|
79
|
+
const child = spawn(this.bin, ['funnel', String(this.port)], { stdio: ['ignore', 'pipe', 'pipe'] });
|
|
80
|
+
this.child = child;
|
|
81
|
+
let last = '';
|
|
82
|
+
const read = (chunk) => {
|
|
83
|
+
const line = lastLine(chunk);
|
|
84
|
+
if (line !== '')
|
|
85
|
+
last = line;
|
|
86
|
+
};
|
|
87
|
+
child.stdout?.on('data', read);
|
|
88
|
+
child.stderr?.on('data', read);
|
|
89
|
+
child.on('error', (err) => {
|
|
90
|
+
this.child = null;
|
|
91
|
+
this.closed = true;
|
|
92
|
+
this.log(`funnel could not start (${err.message}); the loopback address is still held`);
|
|
93
|
+
});
|
|
94
|
+
child.on('exit', () => {
|
|
95
|
+
this.child = null;
|
|
96
|
+
if (this.closed)
|
|
97
|
+
return;
|
|
98
|
+
this.exits += 1;
|
|
99
|
+
if (this.exits > 1)
|
|
100
|
+
this.log(`funnel exited (${last}); retrying in ${String(FUNNEL_RETRY_MS / 1000)}s`);
|
|
101
|
+
this.timer = setTimeout(() => {
|
|
102
|
+
this.start();
|
|
103
|
+
}, FUNNEL_RETRY_MS);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
async stop() {
|
|
107
|
+
this.closed = true;
|
|
108
|
+
if (this.timer !== null)
|
|
109
|
+
clearTimeout(this.timer);
|
|
110
|
+
const child = this.child;
|
|
111
|
+
this.child = null;
|
|
112
|
+
if (child === null)
|
|
113
|
+
return;
|
|
114
|
+
if (child.exitCode !== null || child.signalCode !== null)
|
|
115
|
+
return;
|
|
116
|
+
await new Promise((resolve) => {
|
|
117
|
+
const kill = setTimeout(() => {
|
|
118
|
+
child.kill('SIGKILL');
|
|
119
|
+
}, FUNNEL_EXIT_WAIT_MS);
|
|
120
|
+
child.once('exit', () => {
|
|
121
|
+
clearTimeout(kill);
|
|
122
|
+
resolve();
|
|
123
|
+
});
|
|
124
|
+
child.kill('SIGINT');
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
async function listen(server, info) {
|
|
129
|
+
for (let attempt = 1;; attempt += 1) {
|
|
130
|
+
try {
|
|
131
|
+
await new Promise((resolve, reject) => {
|
|
132
|
+
server.once('error', reject);
|
|
133
|
+
server.listen(info.port, info.host, () => {
|
|
134
|
+
server.off('error', reject);
|
|
135
|
+
resolve();
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
catch (err) {
|
|
141
|
+
if (attempt >= LISTEN_ATTEMPTS)
|
|
142
|
+
throw err;
|
|
143
|
+
await wait(LISTEN_RETRY_MS);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
const CLOSE_WAIT_MS = 2_000;
|
|
148
|
+
const close = (server) => new Promise((resolve) => {
|
|
149
|
+
const timer = setTimeout(resolve, CLOSE_WAIT_MS);
|
|
150
|
+
server.close(() => {
|
|
151
|
+
clearTimeout(timer);
|
|
152
|
+
resolve();
|
|
153
|
+
});
|
|
154
|
+
server.closeAllConnections();
|
|
155
|
+
});
|
|
156
|
+
function releaseLock(lockFile) {
|
|
157
|
+
try {
|
|
158
|
+
if (readFileSync(lockFile, 'utf8').trim() === String(process.pid))
|
|
159
|
+
rmSync(lockFile, { force: true });
|
|
160
|
+
}
|
|
161
|
+
catch {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
function armFunnel(info, log, ending) {
|
|
166
|
+
if (info.funnel === null || ending !== null)
|
|
167
|
+
return null;
|
|
168
|
+
const funnel = new HeldFunnel(info.funnel, info.port, log);
|
|
169
|
+
funnel.start();
|
|
170
|
+
return funnel;
|
|
171
|
+
}
|
|
172
|
+
export const holdBanner = (info) => `metro is stopped. Holding http://${info.host}:${String(info.port)}${info.funnel === null ? '' : ' and the Funnel address'} ` +
|
|
173
|
+
'until Start on the Server page; Ctrl-C or metro stop ends metro serve';
|
|
174
|
+
export async function holdUntilStart(info, deps = {}) {
|
|
175
|
+
const signals = deps.signals ?? process;
|
|
176
|
+
const log = deps.log ??
|
|
177
|
+
((line) => {
|
|
178
|
+
process.stderr.write(`${line}\n`);
|
|
179
|
+
});
|
|
180
|
+
let finish = () => undefined;
|
|
181
|
+
let ending = null;
|
|
182
|
+
const ended = new Promise((resolve) => {
|
|
183
|
+
finish = (end) => {
|
|
184
|
+
ending ??= end;
|
|
185
|
+
resolve(end);
|
|
186
|
+
};
|
|
187
|
+
});
|
|
188
|
+
const server = holdServer(info, () => {
|
|
189
|
+
finish('start');
|
|
190
|
+
});
|
|
191
|
+
const onSignal = () => {
|
|
192
|
+
finish('exit');
|
|
193
|
+
};
|
|
194
|
+
signals.on('SIGINT', onSignal);
|
|
195
|
+
signals.on('SIGTERM', onSignal);
|
|
196
|
+
if (info.lockFile !== null)
|
|
197
|
+
writeFileSync(info.lockFile, String(process.pid));
|
|
198
|
+
await listen(server, info);
|
|
199
|
+
const funnel = armFunnel(info, log, ending);
|
|
200
|
+
if (ending === null)
|
|
201
|
+
log(holdBanner(info));
|
|
202
|
+
const end = await ended;
|
|
203
|
+
signals.off('SIGINT', onSignal);
|
|
204
|
+
signals.off('SIGTERM', onSignal);
|
|
205
|
+
await funnel?.stop();
|
|
206
|
+
await close(server);
|
|
207
|
+
if (info.lockFile !== null)
|
|
208
|
+
releaseLock(info.lockFile);
|
|
209
|
+
return end;
|
|
210
|
+
}
|