@stage-labs/metro 0.1.0-beta.7 → 0.1.0-beta.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api.js +14 -0
- package/dist/bedrock-eventstream.js +120 -0
- package/dist/bedrock-proxy.js +260 -0
- package/dist/bedrock-upstream.js +72 -0
- package/dist/bedrock.js +37 -0
- package/dist/claude-settings.js +40 -0
- package/dist/claude.js +107 -0
- package/dist/cli.js +101 -0
- package/dist/control.js +74 -0
- package/dist/hold.js +211 -0
- package/dist/local.js +93 -0
- package/dist/node-name.js +51 -0
- package/dist/plugin.js +80 -0
- package/dist/provider-flags.js +9 -0
- package/dist/runtime-install.js +84 -0
- package/dist/runtime.js +70 -0
- package/dist/serve.js +147 -0
- package/dist/service.js +224 -0
- package/dist/tail.js +119 -0
- package/dist/update.js +45 -0
- package/dist/version.js +97 -0
- package/package.json +14 -25
- package/runtime/node_modules/@metro-labs/discord-bot/package.json +28 -0
- package/runtime/node_modules/@metro-labs/discord-bot/src/accounts.ts +118 -0
- package/runtime/node_modules/@metro-labs/discord-bot/src/actions.ts +388 -0
- package/runtime/node_modules/@metro-labs/discord-bot/src/api-base.ts +1 -0
- package/runtime/node_modules/@metro-labs/discord-bot/src/attachments.ts +29 -0
- package/runtime/node_modules/@metro-labs/discord-bot/src/format.ts +220 -0
- package/runtime/node_modules/@metro-labs/discord-bot/src/group-actions.ts +50 -0
- package/runtime/node_modules/@metro-labs/discord-bot/src/group.ts +115 -0
- package/runtime/node_modules/@metro-labs/discord-bot/src/index.ts +127 -0
- package/runtime/node_modules/@metro-labs/discord-bot/src/members.ts +215 -0
- package/runtime/node_modules/@metro-labs/discord-bot/src/send-files.ts +43 -0
- package/runtime/node_modules/@metro-labs/discord-bot/src/station.ts +19 -0
- package/runtime/node_modules/@metro-labs/discord-bot/src/verify.ts +82 -0
- package/runtime/node_modules/@metro-labs/discord-bot/src/voice-speak.ts +195 -0
- package/runtime/node_modules/@metro-labs/discord-bot/src/voice-transcribe.ts +292 -0
- package/runtime/node_modules/@metro-labs/discord-bot/src/voice.ts +197 -0
- package/runtime/node_modules/@metro-labs/discord-bot/src/wire.ts +5 -0
- package/runtime/node_modules/@metro-labs/mcp/package.json +64 -0
- package/runtime/node_modules/@metro-labs/mcp/src/channels/addressed.ts +25 -0
- package/runtime/node_modules/@metro-labs/mcp/src/channels/dedupe.ts +24 -0
- package/runtime/node_modules/@metro-labs/mcp/src/channels/inbound.ts +377 -0
- package/runtime/node_modules/@metro-labs/mcp/src/channels/media-note.ts +85 -0
- package/runtime/node_modules/@metro-labs/mcp/src/channels/pending.ts +75 -0
- package/runtime/node_modules/@metro-labs/mcp/src/channels/relay.ts +129 -0
- package/runtime/node_modules/@metro-labs/mcp/src/channels/webhook-note.ts +51 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/account-api.ts +311 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/agent-api.ts +302 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/api-error.ts +8 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/api-http.ts +95 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/attach-grant.ts +99 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/attach-owner.ts +32 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/attach-serve.ts +128 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/attach-session.ts +280 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/boot.ts +204 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/bundle-api.ts +111 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/claude-api.ts +97 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/claude-files.ts +329 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/connect-hint.ts +39 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/connector-api.ts +307 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/connector-json.ts +21 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/connector-oauth-routes.ts +157 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/connector-oauth.ts +127 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/connector-tools.ts +98 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/connector-url.ts +70 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/connector-verify.ts +330 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/control-api.ts +64 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/cors.ts +29 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/crash-guard.ts +49 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/events.ts +120 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/http.ts +390 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/identity-key.ts +33 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/identity-registry.ts +13 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/identity-routes.ts +54 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/identity.ts +7 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/is-record.ts +2 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/local-cli-api.ts +63 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/local-mode.ts +187 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/local-owner.ts +14 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/log.ts +42 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/machine-api.ts +61 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/mode-api.ts +32 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/model-api.ts +169 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/oauth-client.ts +159 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/oauth-discovery.ts +117 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/oauth-pending.ts +65 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/paths.ts +109 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/protocol.ts +226 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/relay.ts +295 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/return-to.ts +21 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/runtime-deps.ts +82 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/secure-fs.ts +57 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/server-types.ts +21 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/servers-api.ts +80 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/session-api.ts +29 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/session-apis.ts +66 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/signed-identity.ts +36 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/supervisor-io.ts +97 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/supervisor.ts +320 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/terminal-api.ts +71 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/terminal-tickets.ts +40 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/terminal-ws.ts +114 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/train-call.ts +22 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/train-error.ts +53 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/tunnel.ts +352 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/update-api.ts +116 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/upload-api.ts +294 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/upload-store.ts +181 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/vault-api.ts +78 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/vault-types.ts +12 -0
- package/runtime/node_modules/@metro-labs/mcp/src/daemon/version.ts +2 -0
- package/runtime/node_modules/@metro-labs/mcp/src/db/account-attach.ts +19 -0
- package/runtime/node_modules/@metro-labs/mcp/src/db/address.ts +6 -0
- package/runtime/node_modules/@metro-labs/mcp/src/db/agent-admin.ts +43 -0
- package/runtime/node_modules/@metro-labs/mcp/src/db/agent-map.ts +84 -0
- package/runtime/node_modules/@metro-labs/mcp/src/db/agent-scope.ts +64 -0
- package/runtime/node_modules/@metro-labs/mcp/src/db/client.ts +32 -0
- package/runtime/node_modules/@metro-labs/mcp/src/db/connector-config.ts +144 -0
- package/runtime/node_modules/@metro-labs/mcp/src/db/connector-relay.ts +39 -0
- package/runtime/node_modules/@metro-labs/mcp/src/db/connectors.ts +69 -0
- package/runtime/node_modules/@metro-labs/mcp/src/db/file-admin.ts +329 -0
- package/runtime/node_modules/@metro-labs/mcp/src/db/file-source.ts +155 -0
- package/runtime/node_modules/@metro-labs/mcp/src/db/ids.ts +21 -0
- package/runtime/node_modules/@metro-labs/mcp/src/db/key-map.ts +45 -0
- package/runtime/node_modules/@metro-labs/mcp/src/db/local-connectors.ts +277 -0
- package/runtime/node_modules/@metro-labs/mcp/src/db/materialize.ts +253 -0
- package/runtime/node_modules/@metro-labs/mcp/src/db/schema.ts +33 -0
- package/runtime/node_modules/@metro-labs/mcp/src/db/servers.ts +83 -0
- package/runtime/node_modules/@metro-labs/mcp/src/db/stations.ts +12 -0
- package/runtime/node_modules/@metro-labs/mcp/src/db/vault.ts +109 -0
- package/runtime/node_modules/@metro-labs/mcp/src/gateway/bedrock.ts +252 -0
- package/runtime/node_modules/@metro-labs/mcp/src/gateway/codex-auth.ts +231 -0
- package/runtime/node_modules/@metro-labs/mcp/src/gateway/codex-device.ts +91 -0
- package/runtime/node_modules/@metro-labs/mcp/src/gateway/codex-stream.ts +288 -0
- package/runtime/node_modules/@metro-labs/mcp/src/gateway/codex-translate.ts +203 -0
- package/runtime/node_modules/@metro-labs/mcp/src/gateway/codex.ts +211 -0
- package/runtime/node_modules/@metro-labs/mcp/src/gateway/eventstream.ts +123 -0
- package/runtime/node_modules/@metro-labs/mcp/src/gateway/forward.ts +169 -0
- package/runtime/node_modules/@metro-labs/mcp/src/gateway/gateway.ts +193 -0
- package/runtime/node_modules/@metro-labs/mcp/src/gateway/model-config.ts +180 -0
- package/runtime/node_modules/@metro-labs/mcp/src/mcp/accounts.ts +141 -0
- package/runtime/node_modules/@metro-labs/mcp/src/mcp/call-tools.ts +216 -0
- package/runtime/node_modules/@metro-labs/mcp/src/mcp/channel-owner.ts +29 -0
- package/runtime/node_modules/@metro-labs/mcp/src/mcp/ctx.ts +62 -0
- package/runtime/node_modules/@metro-labs/mcp/src/mcp/event-store.ts +91 -0
- package/runtime/node_modules/@metro-labs/mcp/src/mcp/frame-scope.ts +21 -0
- package/runtime/node_modules/@metro-labs/mcp/src/mcp/group-tools.ts +129 -0
- package/runtime/node_modules/@metro-labs/mcp/src/mcp/index.ts +191 -0
- package/runtime/node_modules/@metro-labs/mcp/src/mcp/member-tools.ts +72 -0
- package/runtime/node_modules/@metro-labs/mcp/src/mcp/permission-relay.ts +66 -0
- package/runtime/node_modules/@metro-labs/mcp/src/mcp/raw-get-stream.ts +207 -0
- package/runtime/node_modules/@metro-labs/mcp/src/mcp/request-identity.ts +47 -0
- package/runtime/node_modules/@metro-labs/mcp/src/mcp/session-registry.ts +172 -0
- package/runtime/node_modules/@metro-labs/mcp/src/mcp/session-route.ts +43 -0
- package/runtime/node_modules/@metro-labs/mcp/src/mcp/session.ts +215 -0
- package/runtime/node_modules/@metro-labs/mcp/src/mcp/str.ts +5 -0
- package/runtime/node_modules/@metro-labs/mcp/src/mcp/tool-dispatch.ts +215 -0
- package/runtime/node_modules/@metro-labs/mcp/src/mcp/tool-schemas.ts +400 -0
- package/runtime/node_modules/@metro-labs/mcp/src/mcp/upload-tool.ts +66 -0
- package/runtime/node_modules/@metro-labs/mcp/src/monitor/api.ts +237 -0
- package/runtime/node_modules/@metro-labs/mcp/src/server.ts +2 -0
- package/runtime/node_modules/@metro-labs/mcp/src/stations/account-store.ts +60 -0
- package/runtime/node_modules/@metro-labs/mcp/src/stations/attach-inline.ts +100 -0
- package/runtime/node_modules/@metro-labs/mcp/src/stations/attach-interactive.ts +161 -0
- package/runtime/node_modules/@metro-labs/mcp/src/stations/attach-resolve.ts +200 -0
- package/runtime/node_modules/@metro-labs/mcp/src/stations/attach-xmtp.ts +111 -0
- package/runtime/node_modules/@metro-labs/mcp/src/stations/attach.ts +184 -0
- package/runtime/node_modules/@metro-labs/mcp/src/stations/attachments.ts +196 -0
- package/runtime/node_modules/@metro-labs/mcp/src/stations/lines.ts +82 -0
- package/runtime/node_modules/@metro-labs/mcp/src/stations/messaging-normalize.ts +88 -0
- package/runtime/node_modules/@metro-labs/mcp/src/stations/registry.ts +35 -0
- package/runtime/node_modules/@metro-labs/mcp/src/stations/station-runtime.ts +64 -0
- package/runtime/node_modules/@metro-labs/mcp/src/stations/types.ts +107 -0
- package/runtime/node_modules/@metro-labs/telegram/package.json +26 -0
- package/runtime/node_modules/@metro-labs/telegram/src/accounts.ts +80 -0
- package/runtime/node_modules/@metro-labs/telegram/src/actions.ts +254 -0
- package/runtime/node_modules/@metro-labs/telegram/src/attachments.ts +87 -0
- package/runtime/node_modules/@metro-labs/telegram/src/client.ts +77 -0
- package/runtime/node_modules/@metro-labs/telegram/src/format.ts +156 -0
- package/runtime/node_modules/@metro-labs/telegram/src/group.ts +261 -0
- package/runtime/node_modules/@metro-labs/telegram/src/history.ts +52 -0
- package/runtime/node_modules/@metro-labs/telegram/src/inbound.ts +78 -0
- package/runtime/node_modules/@metro-labs/telegram/src/index.ts +46 -0
- package/runtime/node_modules/@metro-labs/telegram/src/login.ts +166 -0
- package/runtime/node_modules/@metro-labs/telegram/src/media-actions.ts +80 -0
- package/runtime/node_modules/@metro-labs/telegram/src/members.ts +75 -0
- package/runtime/node_modules/@metro-labs/telegram/src/normalize.ts +22 -0
- package/runtime/node_modules/@metro-labs/telegram/src/reactions.ts +167 -0
- package/runtime/node_modules/@metro-labs/telegram/src/station.ts +24 -0
- package/runtime/node_modules/@metro-labs/telegram/src/types.ts +7 -0
- package/runtime/node_modules/@metro-labs/telegram/src/wire.ts +1 -0
- package/runtime/node_modules/@metro-labs/telegram-bot/package.json +25 -0
- package/runtime/node_modules/@metro-labs/telegram-bot/src/accounts.ts +120 -0
- package/runtime/node_modules/@metro-labs/telegram-bot/src/actions.ts +295 -0
- package/runtime/node_modules/@metro-labs/telegram-bot/src/attachments.ts +128 -0
- package/runtime/node_modules/@metro-labs/telegram-bot/src/format.ts +201 -0
- package/runtime/node_modules/@metro-labs/telegram-bot/src/index.ts +109 -0
- package/runtime/node_modules/@metro-labs/telegram-bot/src/media-actions.ts +166 -0
- package/runtime/node_modules/@metro-labs/telegram-bot/src/members.ts +47 -0
- package/runtime/node_modules/@metro-labs/telegram-bot/src/station.ts +17 -0
- package/runtime/node_modules/@metro-labs/telegram-bot/src/types.ts +58 -0
- package/runtime/node_modules/@metro-labs/telegram-bot/src/verify.ts +38 -0
- package/runtime/node_modules/@metro-labs/telegram-bot/src/wire.ts +3 -0
- package/runtime/node_modules/@metro-labs/webhook/package.json +23 -0
- package/runtime/node_modules/@metro-labs/webhook/src/station.ts +37 -0
- package/runtime/node_modules/@metro-labs/whatsapp/package.json +27 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/accounts.ts +66 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/ack.ts +101 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/actions.ts +178 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/attachments.ts +72 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/auth-state.ts +129 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/client.ts +327 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/delivery.ts +49 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/format.ts +138 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/inbound.ts +57 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/index.ts +40 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/keys.ts +59 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/logger.ts +60 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/login.ts +176 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/media.ts +84 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/normalize.ts +22 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/outbox.ts +38 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/parse.ts +185 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/station.ts +17 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/token-store.ts +98 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/types.ts +6 -0
- package/runtime/node_modules/@metro-labs/whatsapp/src/wire.ts +5 -0
- package/runtime/node_modules/@metro-labs/xmtp/package.json +33 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/accounts.ts +112 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/actions-close.ts +110 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/actions-conv.ts +299 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/actions-meta.ts +157 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/actions-push.ts +87 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/actions.ts +375 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/attachments.ts +107 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/codecs.ts +171 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/conv-helpers.ts +239 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/emit-core.ts +55 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/emit-payloads.ts +335 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/emit.ts +80 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/group-members.ts +34 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/group.ts +56 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/identity.ts +33 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/index.ts +125 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/labels.ts +157 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/member-args.ts +40 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/push.ts +349 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/station.ts +13 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/tools-handlers.ts +126 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/tools.ts +212 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/transcribe.ts +90 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/verify.ts +84 -0
- package/runtime/node_modules/@metro-labs/xmtp/src/wire.ts +53 -0
- package/runtime/runtime.json +3 -0
- package/runtime/stations.json +36 -0
- package/runtime/trains/.keep +0 -0
- package/LICENSE +0 -21
- package/README.md +0 -193
- package/dist/cache.js +0 -75
- package/dist/cli/actions.js +0 -139
- package/dist/cli/config.js +0 -185
- package/dist/cli/index.js +0 -159
- package/dist/cli/skill.js +0 -62
- package/dist/cli/util.js +0 -72
- package/dist/codex-rc.js +0 -236
- package/dist/dispatcher.js +0 -95
- package/dist/history.js +0 -84
- package/dist/ipc.js +0 -72
- package/dist/log.js +0 -15
- package/dist/paths.js +0 -68
- package/dist/stations/discord.js +0 -200
- package/dist/stations/index.js +0 -73
- package/dist/stations/telegram-md.js +0 -34
- package/dist/stations/telegram-upload.js +0 -113
- package/dist/stations/telegram.js +0 -213
- package/docs/agents.md +0 -185
- package/docs/uri-scheme.md +0 -71
- package/skills/metro/SKILL.md +0 -241
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
export type Line = string & { readonly __line: unique symbol };
|
|
2
|
+
export const asLine = (s: string): Line => s as Line;
|
|
3
|
+
|
|
4
|
+
const PREFIX = 'metro://';
|
|
5
|
+
const build = (station: string, ...seg: (string | number)[]): Line =>
|
|
6
|
+
asLine(`${PREFIX}${station}/${seg.map(String).join('/')}`);
|
|
7
|
+
|
|
8
|
+
function parseAccountScoped(
|
|
9
|
+
line: Line | string,
|
|
10
|
+
station: string,
|
|
11
|
+
validate?: (resource: string) => boolean,
|
|
12
|
+
): { accountId: string; resource: string } | null {
|
|
13
|
+
const p = Line.parse(line);
|
|
14
|
+
if (p?.station !== station) return null;
|
|
15
|
+
let accountId: string, resource: string;
|
|
16
|
+
if (p.path.length === 2 && p.path[0] !== undefined && p.path[1] !== undefined) {
|
|
17
|
+
accountId = p.path[0];
|
|
18
|
+
resource = p.path[1];
|
|
19
|
+
} else if (p.path.length === 1 && p.path[0] !== undefined) {
|
|
20
|
+
accountId = 'default';
|
|
21
|
+
resource = p.path[0];
|
|
22
|
+
} else return null;
|
|
23
|
+
if (validate && !validate(resource)) return null;
|
|
24
|
+
return { accountId, resource };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const isSnowflake = (s: string): boolean => /^\d+$/.test(s);
|
|
28
|
+
const isSignedInt = (s: string): boolean => /^-?\d+$/.test(s);
|
|
29
|
+
|
|
30
|
+
function splitTelegramAccount(path: string[]): { accountId: string; rest: string[] } {
|
|
31
|
+
const first = path[0];
|
|
32
|
+
if (path.length >= 2 && first !== undefined && !isSignedInt(first))
|
|
33
|
+
return { accountId: first, rest: path.slice(1) };
|
|
34
|
+
return { accountId: 'default', rest: path };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function parseTelegramLine(
|
|
38
|
+
line: Line | string,
|
|
39
|
+
): { accountId: string; chatId: number; topicId?: number } | null {
|
|
40
|
+
const p = Line.parse(line);
|
|
41
|
+
if (p?.station !== 'telegram-bot') return null;
|
|
42
|
+
const { accountId, rest } = splitTelegramAccount(p.path);
|
|
43
|
+
const [chatId, topicId] = rest;
|
|
44
|
+
if (rest.length < 1 || rest.length > 2 || chatId === undefined || !isSignedInt(chatId))
|
|
45
|
+
return null;
|
|
46
|
+
if (topicId !== undefined && !isSnowflake(topicId)) return null;
|
|
47
|
+
return {
|
|
48
|
+
accountId,
|
|
49
|
+
chatId: Number(chatId),
|
|
50
|
+
...(topicId !== undefined ? { topicId: Number(topicId) } : {}),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export const Line = {
|
|
55
|
+
claude: (orgId: string, sessionId: string): Line =>
|
|
56
|
+
build('claude', orgId, sessionId),
|
|
57
|
+
webhook: (endpointId: string): Line => build('webhook', endpointId),
|
|
58
|
+
user: (station: string, id: string | number): Line =>
|
|
59
|
+
build(station, 'user', id),
|
|
60
|
+
|
|
61
|
+
parse(line: Line | string): { station: string; path: string[] } | null {
|
|
62
|
+
if (!line.startsWith(PREFIX)) return null;
|
|
63
|
+
const rest = line.slice(PREFIX.length);
|
|
64
|
+
const slash = rest.indexOf('/');
|
|
65
|
+
if (slash <= 0) return null;
|
|
66
|
+
const path = rest
|
|
67
|
+
.slice(slash + 1)
|
|
68
|
+
.split('/')
|
|
69
|
+
.filter(Boolean);
|
|
70
|
+
return path.length ? { station: rest.slice(0, slash), path } : null;
|
|
71
|
+
},
|
|
72
|
+
station: (line: Line | string): string | null =>
|
|
73
|
+
Line.parse(line)?.station ?? null,
|
|
74
|
+
isLocal: (line: Line | string): boolean => Line.station(line) === 'claude',
|
|
75
|
+
|
|
76
|
+
parseXmtp: (line: Line | string) => parseAccountScoped(line, 'xmtp'),
|
|
77
|
+
|
|
78
|
+
parseDiscord: (line: Line | string) =>
|
|
79
|
+
parseAccountScoped(line, 'discord-bot', isSnowflake),
|
|
80
|
+
|
|
81
|
+
parseTelegram: (line: Line | string) => parseTelegramLine(line),
|
|
82
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
type Args = Record<string, unknown>;
|
|
2
|
+
export interface Normalized {
|
|
3
|
+
action: string;
|
|
4
|
+
args: Args;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
interface Attachment {
|
|
8
|
+
kind?: string;
|
|
9
|
+
path?: string;
|
|
10
|
+
url?: string;
|
|
11
|
+
data?: string;
|
|
12
|
+
mime?: string;
|
|
13
|
+
name?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface DiscordFile {
|
|
17
|
+
file: string;
|
|
18
|
+
kind: string;
|
|
19
|
+
name: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const discordFile = (a: Attachment): DiscordFile | null => {
|
|
23
|
+
const file = a.path ?? a.url;
|
|
24
|
+
if (typeof file !== 'string') return null;
|
|
25
|
+
return { file, kind: a.kind ?? 'file', name: a.name ?? '' };
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
function discordAttachments(att: Attachment[]): Args {
|
|
29
|
+
const usable = att
|
|
30
|
+
.map(discordFile)
|
|
31
|
+
.filter((f): f is DiscordFile => f !== null);
|
|
32
|
+
if (!usable.length) return {};
|
|
33
|
+
return {
|
|
34
|
+
files: usable.map((f) => f.file),
|
|
35
|
+
attachmentKinds: usable.map((f) => f.kind),
|
|
36
|
+
attachmentNames: usable.map((f) => f.name),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function normalizeDiscord(action: string, env: Args): Normalized {
|
|
41
|
+
const att = (env.attachments as Attachment[] | undefined) ?? [];
|
|
42
|
+
if (action === 'send') {
|
|
43
|
+
return { action: 'send', args: { ...env, ...discordAttachments(att) } };
|
|
44
|
+
}
|
|
45
|
+
if (action === 'reply') {
|
|
46
|
+
const replyTo = env.replyTo ?? env.messageId;
|
|
47
|
+
return {
|
|
48
|
+
action: 'send',
|
|
49
|
+
args: { ...env, replyTo, ...discordAttachments(att) },
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
if (action === 'unreact')
|
|
53
|
+
return { action: 'react', args: { ...env, emoji: '' } };
|
|
54
|
+
if (action === 'read') {
|
|
55
|
+
return {
|
|
56
|
+
action: 'fetch',
|
|
57
|
+
args: { line: env.line, limit: env.limit, before: env.before },
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
return { action, args: env };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function normalizeTelegram(action: string, env: Args): Normalized {
|
|
64
|
+
if (action === 'reply') {
|
|
65
|
+
return {
|
|
66
|
+
action: 'send',
|
|
67
|
+
args: {
|
|
68
|
+
line: env.line,
|
|
69
|
+
text: env.text,
|
|
70
|
+
replyTo: env.replyTo,
|
|
71
|
+
attachments: env.attachments,
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
if (action === 'unreact')
|
|
76
|
+
return { action: 'react', args: { ...env, emoji: '' } };
|
|
77
|
+
return { action, args: env };
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function normalizeXmtp(action: string, env: Args): Normalized {
|
|
81
|
+
if (action === 'unreact') {
|
|
82
|
+
return { action: 'react', args: { ...env, action: 'removed' } };
|
|
83
|
+
}
|
|
84
|
+
if (action === 'read') {
|
|
85
|
+
return { action: 'query', args: { line: env.line, limit: env.limit } };
|
|
86
|
+
}
|
|
87
|
+
return { action, args: env };
|
|
88
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Station } from './types.js';
|
|
2
|
+
import { Line } from './lines.js';
|
|
3
|
+
import { xmtpStation } from '@metro-labs/xmtp';
|
|
4
|
+
import { telegramBotStation } from '@metro-labs/telegram-bot';
|
|
5
|
+
import { telegramStation } from '@metro-labs/telegram';
|
|
6
|
+
import { discordBotStation } from '@metro-labs/discord-bot';
|
|
7
|
+
import { whatsappStation } from '@metro-labs/whatsapp';
|
|
8
|
+
import { webhookStation } from '@metro-labs/webhook';
|
|
9
|
+
|
|
10
|
+
export const STATIONS: readonly Station[] = [
|
|
11
|
+
xmtpStation,
|
|
12
|
+
telegramBotStation,
|
|
13
|
+
telegramStation,
|
|
14
|
+
discordBotStation,
|
|
15
|
+
whatsappStation,
|
|
16
|
+
webhookStation,
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
export const stationByName = (name: string): Station | undefined =>
|
|
20
|
+
STATIONS.find((s) => s.name === name);
|
|
21
|
+
|
|
22
|
+
export const stationForLine = (line: string): Station | undefined => {
|
|
23
|
+
const s = Line.station(line);
|
|
24
|
+
return s ? stationByName(s) : undefined;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const accountStationNames = (): string[] =>
|
|
28
|
+
STATIONS.filter((s) => s.hasAccounts).map((s) => s.name);
|
|
29
|
+
|
|
30
|
+
export const accountStationCapabilities = (): Record<string, string[]> => {
|
|
31
|
+
const out: Record<string, string[]> = {};
|
|
32
|
+
for (const s of STATIONS)
|
|
33
|
+
if (s.hasAccounts) out[s.name] = [...s.messageVerbs].sort();
|
|
34
|
+
return out;
|
|
35
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { serializeTrainError, type TrainErrorInfo } from '../daemon/train-error.js';
|
|
2
|
+
import type { Normalized } from './messaging-normalize.js';
|
|
3
|
+
|
|
4
|
+
export const emit = (e: unknown): void =>
|
|
5
|
+
void process.stdout.write(JSON.stringify(e) + '\n');
|
|
6
|
+
|
|
7
|
+
export const respond = (
|
|
8
|
+
id: string,
|
|
9
|
+
body: { result?: unknown; error?: string; errorInfo?: TrainErrorInfo },
|
|
10
|
+
): void =>
|
|
11
|
+
void process.stdout.write(
|
|
12
|
+
JSON.stringify({ op: 'response', id, ...body }) + '\n',
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
export const mintId = (): string =>
|
|
16
|
+
`msg_${Math.random().toString(36).slice(2, 10)}`;
|
|
17
|
+
|
|
18
|
+
type Args = Record<string, unknown>;
|
|
19
|
+
|
|
20
|
+
export interface CallMsg {
|
|
21
|
+
op: 'call';
|
|
22
|
+
id: string;
|
|
23
|
+
action: string;
|
|
24
|
+
args: Args;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type StationHandler = (id: string, args: Args) => void | Promise<void>;
|
|
28
|
+
|
|
29
|
+
export interface StationConfig {
|
|
30
|
+
handlers: Record<string, StationHandler>;
|
|
31
|
+
normalize: (action: string, args: Args) => Normalized;
|
|
32
|
+
preDispatch?: (id: string, action: string) => boolean;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const lineTag = (args: Args): string =>
|
|
36
|
+
typeof args.line === 'string' ? args.line : '?';
|
|
37
|
+
|
|
38
|
+
export function makeStation({ handlers, normalize, preDispatch }: StationConfig) {
|
|
39
|
+
const known = Object.keys(handlers).join(', ');
|
|
40
|
+
return async function handleCall(msg: CallMsg): Promise<void> {
|
|
41
|
+
const { id } = msg;
|
|
42
|
+
let action = msg.action;
|
|
43
|
+
let args: Args = msg.args;
|
|
44
|
+
try {
|
|
45
|
+
({ action, args } = normalize(msg.action, msg.args));
|
|
46
|
+
emit({ op: 'log', text: `call ${action} recv (line=${lineTag(args)})` });
|
|
47
|
+
if (preDispatch?.(id, action)) return;
|
|
48
|
+
const handler = handlers[action];
|
|
49
|
+
if (!handler) {
|
|
50
|
+
respond(id, { error: `unknown action '${action}' (have: ${known})` });
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
await handler(id, args);
|
|
54
|
+
emit({ op: 'log', text: `call ${action} done (line=${lineTag(args)})` });
|
|
55
|
+
} catch (err) {
|
|
56
|
+
const info = serializeTrainError(err);
|
|
57
|
+
emit({
|
|
58
|
+
op: 'log',
|
|
59
|
+
text: `call ${action} FAILED (line=${lineTag(args)}): ${info.error}`,
|
|
60
|
+
});
|
|
61
|
+
respond(id, info);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
export type Verb =
|
|
2
|
+
| 'send'
|
|
3
|
+
| 'reply'
|
|
4
|
+
| 'react'
|
|
5
|
+
| 'unreact'
|
|
6
|
+
| 'edit'
|
|
7
|
+
| 'delete'
|
|
8
|
+
| 'read';
|
|
9
|
+
|
|
10
|
+
export interface ToolResult {
|
|
11
|
+
content: { type: 'text'; text: string }[];
|
|
12
|
+
isError?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface CanonicalAttachment {
|
|
16
|
+
path?: string;
|
|
17
|
+
url?: string;
|
|
18
|
+
data?: string;
|
|
19
|
+
upload?: string;
|
|
20
|
+
mime?: string;
|
|
21
|
+
name?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface ToolContext {
|
|
25
|
+
call(
|
|
26
|
+
action: string,
|
|
27
|
+
args: Record<string, unknown>,
|
|
28
|
+
): Promise<{ result: unknown }>;
|
|
29
|
+
ok(text: string): ToolResult;
|
|
30
|
+
okJson(value: unknown): ToolResult;
|
|
31
|
+
err(text: string): ToolResult;
|
|
32
|
+
readFile(path: string): Promise<Buffer>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface StationTool {
|
|
36
|
+
name: string;
|
|
37
|
+
description: string;
|
|
38
|
+
inputSchema: Record<string, unknown>;
|
|
39
|
+
handle(args: Record<string, unknown>, ctx: ToolContext): Promise<ToolResult>;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface MetroMember {
|
|
43
|
+
id: string;
|
|
44
|
+
name?: string;
|
|
45
|
+
display_name?: string;
|
|
46
|
+
address?: string;
|
|
47
|
+
roles?: string[];
|
|
48
|
+
is_admin?: boolean;
|
|
49
|
+
is_bot?: boolean;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface MemberCapability {
|
|
53
|
+
supported: boolean;
|
|
54
|
+
complete: boolean;
|
|
55
|
+
reason?: string;
|
|
56
|
+
total?: number;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface MemberList {
|
|
60
|
+
members: MetroMember[];
|
|
61
|
+
capability: MemberCapability;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export type GroupOp =
|
|
65
|
+
| 'create_group'
|
|
66
|
+
| 'add_members'
|
|
67
|
+
| 'remove_members'
|
|
68
|
+
| 'invite_link';
|
|
69
|
+
|
|
70
|
+
export type MemberOutcomeStatus = 'added' | 'invited' | 'removed' | 'failed';
|
|
71
|
+
|
|
72
|
+
export interface MemberOutcome {
|
|
73
|
+
id: string;
|
|
74
|
+
status: MemberOutcomeStatus;
|
|
75
|
+
reason?: string;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface GroupCapability {
|
|
79
|
+
supported: boolean;
|
|
80
|
+
reason?: string;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface GroupResult {
|
|
84
|
+
capability: GroupCapability;
|
|
85
|
+
line?: string;
|
|
86
|
+
id?: string;
|
|
87
|
+
name?: string;
|
|
88
|
+
members?: MemberOutcome[];
|
|
89
|
+
inviteLink?: string;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export type AttachmentMode = 'canonical' | 'native' | 'none';
|
|
93
|
+
|
|
94
|
+
export interface Station {
|
|
95
|
+
name: string;
|
|
96
|
+
hasAccounts: boolean;
|
|
97
|
+
hasTrain: boolean;
|
|
98
|
+
messageVerbs: ReadonlySet<Verb>;
|
|
99
|
+
groupOps?: ReadonlySet<GroupOp>;
|
|
100
|
+
attachmentMode: AttachmentMode;
|
|
101
|
+
sendAttachments?(
|
|
102
|
+
line: string,
|
|
103
|
+
atts: CanonicalAttachment[],
|
|
104
|
+
ctx: ToolContext,
|
|
105
|
+
): Promise<string[]>;
|
|
106
|
+
tools: StationTool[];
|
|
107
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@metro-labs/telegram",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": "./src/station.ts",
|
|
8
|
+
"./train": "./src/index.ts",
|
|
9
|
+
"./login": "./src/login.ts"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsc",
|
|
13
|
+
"test": "tsc --noEmit && bun test test/"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@metro-labs/mcp": "workspace:*",
|
|
17
|
+
"@mtcute/bun": "0.30.1"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@stage-labs/config": "0.1.0-beta.2",
|
|
21
|
+
"eslint": "^10.3.0",
|
|
22
|
+
"knip": "^6.15.0",
|
|
23
|
+
"madge": "^8.0.0",
|
|
24
|
+
"typescript": "^5"
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { homedir } from 'node:os';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import {
|
|
4
|
+
makeAccountStore,
|
|
5
|
+
resolveAccountId,
|
|
6
|
+
type Die,
|
|
7
|
+
} from '@metro-labs/mcp/stations/account-store';
|
|
8
|
+
import type { UserAccount } from './types.js';
|
|
9
|
+
|
|
10
|
+
const ACCOUNTS_FILE =
|
|
11
|
+
process.env.TELEGRAM_ACCOUNTS_FILE ??
|
|
12
|
+
join(homedir(), '.metro', 'telegram-accounts.json');
|
|
13
|
+
|
|
14
|
+
const isSignedInt = (s: string): boolean => /^-?\d+$/.test(s);
|
|
15
|
+
const isTopic = (s: string): boolean => /^\d+$/.test(s);
|
|
16
|
+
|
|
17
|
+
function validateAccount(a: UserAccount, seen: Set<string>, die: Die): void {
|
|
18
|
+
if (!a.id) die('account missing id');
|
|
19
|
+
if (!a.session || typeof a.session !== 'string')
|
|
20
|
+
die(`account '${a.id}' missing session`);
|
|
21
|
+
if (!Number.isInteger(a.apiId) || (a.apiId ?? 0) <= 0)
|
|
22
|
+
die(`account '${a.id}' missing apiId`);
|
|
23
|
+
if (!a.apiHash || typeof a.apiHash !== 'string')
|
|
24
|
+
die(`account '${a.id}' missing apiHash`);
|
|
25
|
+
if (seen.has(a.id)) die(`duplicate account id '${a.id}'`);
|
|
26
|
+
seen.add(a.id);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const { loadAccounts } = makeAccountStore<UserAccount>({
|
|
30
|
+
prefix: 'telegram',
|
|
31
|
+
file: ACCOUNTS_FILE,
|
|
32
|
+
validate(raw, die) {
|
|
33
|
+
const seen = new Set<string>();
|
|
34
|
+
for (const a of raw) validateAccount(a, seen, die);
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
export const accounts = new Map<string, UserAccount>();
|
|
39
|
+
|
|
40
|
+
export function accountFor(args: { account?: string; line?: string }): string {
|
|
41
|
+
return resolveAccountId(accounts, args, (line) => targetOf(line)?.accountId);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function lineOf(
|
|
45
|
+
accountId: string,
|
|
46
|
+
chatId: number | string,
|
|
47
|
+
topicId?: number,
|
|
48
|
+
): string {
|
|
49
|
+
const tail = topicId !== undefined ? `${chatId}/${topicId}` : `${chatId}`;
|
|
50
|
+
return `metro://telegram/${accountId}/${tail}`;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
interface Target {
|
|
54
|
+
accountId: string;
|
|
55
|
+
chatId: number;
|
|
56
|
+
topicId?: number;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function splitScoped(path: string[]): { accountId: string; rest: string[] } {
|
|
60
|
+
const first = path[0];
|
|
61
|
+
if (path.length >= 2 && first !== undefined && !isSignedInt(first))
|
|
62
|
+
return { accountId: first, rest: path.slice(1) };
|
|
63
|
+
return { accountId: 'default', rest: path };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function targetOf(line: string): Target | undefined {
|
|
67
|
+
const prefix = 'metro://telegram/';
|
|
68
|
+
if (!line.startsWith(prefix)) return undefined;
|
|
69
|
+
const path = line.slice(prefix.length).split('/').filter(Boolean);
|
|
70
|
+
const { accountId, rest } = splitScoped(path);
|
|
71
|
+
const [chatId, topicId] = rest;
|
|
72
|
+
if (rest.length < 1 || rest.length > 2 || chatId === undefined) return undefined;
|
|
73
|
+
if (!isSignedInt(chatId)) return undefined;
|
|
74
|
+
if (topicId !== undefined && !isTopic(topicId)) return undefined;
|
|
75
|
+
return {
|
|
76
|
+
accountId,
|
|
77
|
+
chatId: Number(chatId),
|
|
78
|
+
...(topicId !== undefined ? { topicId: Number(topicId) } : {}),
|
|
79
|
+
};
|
|
80
|
+
}
|