@shepai/cli 1.180.0-pr548.764147 → 1.181.0-pr512.ba01d33
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/apis/json-schema/MessagingCommand.yaml +28 -0
- package/apis/json-schema/MessagingCommandType.yaml +17 -0
- package/apis/json-schema/MessagingConfig.yaml +40 -0
- package/apis/json-schema/MessagingFrameType.yaml +8 -0
- package/apis/json-schema/MessagingNotification.yaml +22 -0
- package/apis/json-schema/MessagingPlatform.yaml +7 -0
- package/apis/json-schema/MessagingPlatformConfig.yaml +38 -0
- package/apis/json-schema/Settings.yaml +3 -0
- package/dist/packages/core/src/application/ports/output/services/gateway-client.interface.d.ts +58 -0
- package/dist/packages/core/src/application/ports/output/services/gateway-client.interface.d.ts.map +1 -0
- package/dist/packages/core/src/application/ports/output/services/gateway-client.interface.js +10 -0
- package/dist/packages/core/src/application/ports/output/services/message-sender.interface.d.ts +18 -0
- package/dist/packages/core/src/application/ports/output/services/message-sender.interface.d.ts.map +1 -0
- package/dist/packages/core/src/application/ports/output/services/message-sender.interface.js +9 -0
- package/dist/packages/core/src/application/ports/output/services/messaging-service.interface.d.ts +34 -0
- package/dist/packages/core/src/application/ports/output/services/messaging-service.interface.d.ts.map +1 -0
- package/dist/packages/core/src/application/ports/output/services/messaging-service.interface.js +12 -0
- package/dist/packages/core/src/application/ports/output/services/telegram-client.interface.d.ts +19 -0
- package/dist/packages/core/src/application/ports/output/services/telegram-client.interface.d.ts.map +1 -0
- package/dist/packages/core/src/application/ports/output/services/telegram-client.interface.js +8 -0
- package/dist/packages/core/src/application/use-cases/messaging/begin-pairing.use-case.d.ts +46 -0
- package/dist/packages/core/src/application/use-cases/messaging/begin-pairing.use-case.d.ts.map +1 -0
- package/dist/packages/core/src/application/use-cases/messaging/begin-pairing.use-case.js +148 -0
- package/dist/packages/core/src/application/use-cases/messaging/confirm-pairing.use-case.d.ts +19 -0
- package/dist/packages/core/src/application/use-cases/messaging/confirm-pairing.use-case.d.ts.map +1 -0
- package/dist/packages/core/src/application/use-cases/messaging/confirm-pairing.use-case.js +63 -0
- package/dist/packages/core/src/application/use-cases/messaging/disconnect-messaging.use-case.d.ts +19 -0
- package/dist/packages/core/src/application/use-cases/messaging/disconnect-messaging.use-case.d.ts.map +1 -0
- package/dist/packages/core/src/application/use-cases/messaging/disconnect-messaging.use-case.js +65 -0
- package/dist/packages/core/src/domain/generated/output.d.ts +155 -0
- package/dist/packages/core/src/domain/generated/output.d.ts.map +1 -1
- package/dist/packages/core/src/domain/generated/output.js +26 -0
- package/dist/packages/core/src/infrastructure/di/container.d.ts.map +1 -1
- package/dist/packages/core/src/infrastructure/di/container.js +117 -0
- package/dist/packages/core/src/infrastructure/persistence/sqlite/mappers/settings.mapper.d.ts +24 -0
- package/dist/packages/core/src/infrastructure/persistence/sqlite/mappers/settings.mapper.d.ts.map +1 -1
- package/dist/packages/core/src/infrastructure/persistence/sqlite/mappers/settings.mapper.js +117 -0
- package/dist/packages/core/src/infrastructure/persistence/sqlite/migrations/056-add-messaging-remote-control.d.ts +22 -0
- package/dist/packages/core/src/infrastructure/persistence/sqlite/migrations/056-add-messaging-remote-control.d.ts.map +1 -0
- package/dist/packages/core/src/infrastructure/persistence/sqlite/migrations/056-add-messaging-remote-control.js +62 -0
- package/dist/packages/core/src/infrastructure/repositories/sqlite-settings.repository.d.ts.map +1 -1
- package/dist/packages/core/src/infrastructure/repositories/sqlite-settings.repository.js +43 -3
- package/dist/packages/core/src/infrastructure/services/agents/feature-agent/nodes/node-helpers.d.ts.map +1 -1
- package/dist/packages/core/src/infrastructure/services/agents/feature-agent/nodes/node-helpers.js +1 -4
- package/dist/packages/core/src/infrastructure/services/agents/feature-agent/nodes/prompts/merge-prompts.d.ts.map +1 -1
- package/dist/packages/core/src/infrastructure/services/agents/feature-agent/nodes/prompts/merge-prompts.js +6 -11
- package/dist/packages/core/src/infrastructure/services/agents/feature-agent/nodes/prompts/pr-branding.d.ts +2 -2
- package/dist/packages/core/src/infrastructure/services/agents/feature-agent/nodes/prompts/pr-branding.d.ts.map +1 -1
- package/dist/packages/core/src/infrastructure/services/agents/feature-agent/nodes/prompts/pr-branding.js +2 -2
- package/dist/packages/core/src/infrastructure/services/git/git-pr.service.d.ts.map +1 -1
- package/dist/packages/core/src/infrastructure/services/git/git-pr.service.js +2 -3
- package/dist/packages/core/src/infrastructure/services/git/pr-branding.d.ts +5 -16
- package/dist/packages/core/src/infrastructure/services/git/pr-branding.d.ts.map +1 -1
- package/dist/packages/core/src/infrastructure/services/git/pr-branding.js +7 -38
- package/dist/packages/core/src/infrastructure/services/messaging/chat-relay.d.ts +45 -0
- package/dist/packages/core/src/infrastructure/services/messaging/chat-relay.d.ts.map +1 -0
- package/dist/packages/core/src/infrastructure/services/messaging/chat-relay.js +100 -0
- package/dist/packages/core/src/infrastructure/services/messaging/command-executor.d.ts +53 -0
- package/dist/packages/core/src/infrastructure/services/messaging/command-executor.d.ts.map +1 -0
- package/dist/packages/core/src/infrastructure/services/messaging/command-executor.js +200 -0
- package/dist/packages/core/src/infrastructure/services/messaging/content-sanitizer.d.ts +23 -0
- package/dist/packages/core/src/infrastructure/services/messaging/content-sanitizer.d.ts.map +1 -0
- package/dist/packages/core/src/infrastructure/services/messaging/content-sanitizer.js +39 -0
- package/dist/packages/core/src/infrastructure/services/messaging/http-gateway.client.d.ts +19 -0
- package/dist/packages/core/src/infrastructure/services/messaging/http-gateway.client.d.ts.map +1 -0
- package/dist/packages/core/src/infrastructure/services/messaging/http-gateway.client.js +124 -0
- package/dist/packages/core/src/infrastructure/services/messaging/http-telegram.client.d.ts +18 -0
- package/dist/packages/core/src/infrastructure/services/messaging/http-telegram.client.d.ts.map +1 -0
- package/dist/packages/core/src/infrastructure/services/messaging/http-telegram.client.js +60 -0
- package/dist/packages/core/src/infrastructure/services/messaging/messaging-tunnel.adapter.d.ts +68 -0
- package/dist/packages/core/src/infrastructure/services/messaging/messaging-tunnel.adapter.d.ts.map +1 -0
- package/dist/packages/core/src/infrastructure/services/messaging/messaging-tunnel.adapter.js +262 -0
- package/dist/packages/core/src/infrastructure/services/messaging/messaging.service.d.ts +78 -0
- package/dist/packages/core/src/infrastructure/services/messaging/messaging.service.d.ts.map +1 -0
- package/dist/packages/core/src/infrastructure/services/messaging/messaging.service.js +279 -0
- package/dist/packages/core/src/infrastructure/services/messaging/notification-emitter.d.ts +33 -0
- package/dist/packages/core/src/infrastructure/services/messaging/notification-emitter.d.ts.map +1 -0
- package/dist/packages/core/src/infrastructure/services/messaging/notification-emitter.js +79 -0
- package/dist/packages/core/src/infrastructure/services/messaging/stub-gateway.client.d.ts +12 -0
- package/dist/packages/core/src/infrastructure/services/messaging/stub-gateway.client.d.ts.map +1 -0
- package/dist/packages/core/src/infrastructure/services/messaging/stub-gateway.client.js +26 -0
- package/dist/packages/core/src/infrastructure/services/messaging/telegram-message-sender.d.ts +26 -0
- package/dist/packages/core/src/infrastructure/services/messaging/telegram-message-sender.d.ts.map +1 -0
- package/dist/packages/core/src/infrastructure/services/messaging/telegram-message-sender.js +49 -0
- package/dist/packages/core/src/infrastructure/services/messaging/telegram-webhook.parser.d.ts +28 -0
- package/dist/packages/core/src/infrastructure/services/messaging/telegram-webhook.parser.d.ts.map +1 -0
- package/dist/packages/core/src/infrastructure/services/messaging/telegram-webhook.parser.js +45 -0
- package/dist/packages/core/src/infrastructure/services/messaging/tunnel-protocol.d.ts +102 -0
- package/dist/packages/core/src/infrastructure/services/messaging/tunnel-protocol.d.ts.map +1 -0
- package/dist/packages/core/src/infrastructure/services/messaging/tunnel-protocol.js +16 -0
- package/dist/packages/core/src/infrastructure/services/messaging/whatsapp-webhook.parser.d.ts +39 -0
- package/dist/packages/core/src/infrastructure/services/messaging/whatsapp-webhook.parser.d.ts.map +1 -0
- package/dist/packages/core/src/infrastructure/services/messaging/whatsapp-webhook.parser.js +56 -0
- package/dist/src/presentation/cli/commands/_serve.command.d.ts.map +1 -1
- package/dist/src/presentation/cli/commands/_serve.command.js +6 -0
- package/dist/src/presentation/cli/commands/app/del.command.d.ts +14 -0
- package/dist/src/presentation/cli/commands/app/del.command.d.ts.map +1 -0
- package/dist/src/presentation/cli/commands/app/del.command.js +58 -0
- package/dist/src/presentation/cli/commands/app/index.d.ts +20 -0
- package/dist/src/presentation/cli/commands/app/index.d.ts.map +1 -0
- package/dist/src/presentation/cli/commands/app/index.js +33 -0
- package/dist/src/presentation/cli/commands/app/ls.command.d.ts +11 -0
- package/dist/src/presentation/cli/commands/app/ls.command.d.ts.map +1 -0
- package/dist/src/presentation/cli/commands/app/ls.command.js +74 -0
- package/dist/src/presentation/cli/commands/app/new.command.d.ts +17 -0
- package/dist/src/presentation/cli/commands/app/new.command.d.ts.map +1 -0
- package/dist/src/presentation/cli/commands/app/new.command.js +58 -0
- package/dist/src/presentation/cli/commands/app/resolve-application.d.ts +10 -0
- package/dist/src/presentation/cli/commands/app/resolve-application.d.ts.map +1 -0
- package/dist/src/presentation/cli/commands/app/resolve-application.js +33 -0
- package/dist/src/presentation/cli/commands/app/show.command.d.ts +11 -0
- package/dist/src/presentation/cli/commands/app/show.command.d.ts.map +1 -0
- package/dist/src/presentation/cli/commands/app/show.command.js +95 -0
- package/dist/src/presentation/cli/commands/settings/index.d.ts.map +1 -1
- package/dist/src/presentation/cli/commands/settings/index.js +3 -1
- package/dist/src/presentation/cli/commands/settings/messaging.command.d.ts +17 -0
- package/dist/src/presentation/cli/commands/settings/messaging.command.d.ts.map +1 -0
- package/dist/src/presentation/cli/commands/settings/messaging.command.js +187 -0
- package/dist/src/presentation/cli/index.js +2 -0
- package/dist/src/presentation/web/app/actions/messaging.d.ts +29 -0
- package/dist/src/presentation/web/app/actions/messaging.d.ts.map +1 -0
- package/dist/src/presentation/web/app/actions/messaging.js +55 -0
- package/dist/src/presentation/web/components/features/settings/messaging-settings-section.d.ts +6 -0
- package/dist/src/presentation/web/components/features/settings/messaging-settings-section.d.ts.map +1 -0
- package/dist/src/presentation/web/components/features/settings/messaging-settings-section.js +206 -0
- package/dist/src/presentation/web/components/features/settings/messaging-settings-section.stories.d.ts +17 -0
- package/dist/src/presentation/web/components/features/settings/messaging-settings-section.stories.d.ts.map +1 -0
- package/dist/src/presentation/web/components/features/settings/messaging-settings-section.stories.js +55 -0
- package/dist/src/presentation/web/components/features/settings/settings-page-client.d.ts.map +1 -1
- package/dist/src/presentation/web/components/features/settings/settings-page-client.js +9 -2
- package/dist/src/presentation/web/dev-server.js +27 -0
- package/dist/translations/ar/cli.json +63 -0
- package/dist/translations/ar/web.json +2 -1
- package/dist/translations/de/cli.json +63 -0
- package/dist/translations/de/web.json +2 -1
- package/dist/translations/en/cli.json +63 -0
- package/dist/translations/en/web.json +13 -12
- package/dist/translations/es/cli.json +63 -0
- package/dist/translations/es/web.json +2 -1
- package/dist/translations/fr/cli.json +63 -0
- package/dist/translations/fr/web.json +2 -1
- package/dist/translations/he/cli.json +63 -0
- package/dist/translations/he/web.json +2 -1
- package/dist/translations/pt/cli.json +63 -0
- package/dist/translations/pt/web.json +2 -1
- package/dist/translations/ru/cli.json +63 -0
- package/dist/translations/ru/web.json +2 -1
- package/dist/translations/uk/cli.json +63 -0
- package/dist/translations/uk/web.json +2 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +3 -1
- package/web/.next/BUILD_ID +1 -1
- package/web/.next/build-manifest.json +2 -2
- package/web/.next/fallback-build-manifest.json +2 -2
- package/web/.next/prerender-manifest.json +3 -3
- package/web/.next/required-server-files.js +2 -2
- package/web/.next/required-server-files.json +2 -2
- package/web/.next/server/app/(dashboard)/@drawer/adopt/page/server-reference-manifest.json +32 -32
- package/web/.next/server/app/(dashboard)/@drawer/adopt/page.js.nft.json +1 -1
- package/web/.next/server/app/(dashboard)/@drawer/adopt/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/@drawer/chat/page/server-reference-manifest.json +30 -30
- package/web/.next/server/app/(dashboard)/@drawer/chat/page.js.nft.json +1 -1
- package/web/.next/server/app/(dashboard)/@drawer/chat/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/@drawer/create/page/server-reference-manifest.json +33 -33
- package/web/.next/server/app/(dashboard)/@drawer/create/page.js.nft.json +1 -1
- package/web/.next/server/app/(dashboard)/@drawer/create/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/@drawer/feature/[featureId]/[tab]/page/server-reference-manifest.json +41 -41
- package/web/.next/server/app/(dashboard)/@drawer/feature/[featureId]/[tab]/page.js.nft.json +1 -1
- package/web/.next/server/app/(dashboard)/@drawer/feature/[featureId]/[tab]/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/@drawer/feature/[featureId]/page/server-reference-manifest.json +41 -41
- package/web/.next/server/app/(dashboard)/@drawer/feature/[featureId]/page.js.nft.json +1 -1
- package/web/.next/server/app/(dashboard)/@drawer/feature/[featureId]/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/@drawer/repository/[repositoryId]/[tab]/page/server-reference-manifest.json +31 -31
- package/web/.next/server/app/(dashboard)/@drawer/repository/[repositoryId]/[tab]/page.js.nft.json +1 -1
- package/web/.next/server/app/(dashboard)/@drawer/repository/[repositoryId]/[tab]/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/@drawer/repository/[repositoryId]/page/server-reference-manifest.json +31 -31
- package/web/.next/server/app/(dashboard)/@drawer/repository/[repositoryId]/page.js.nft.json +1 -1
- package/web/.next/server/app/(dashboard)/@drawer/repository/[repositoryId]/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/chat/page/server-reference-manifest.json +30 -30
- package/web/.next/server/app/(dashboard)/chat/page.js.nft.json +1 -1
- package/web/.next/server/app/(dashboard)/chat/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/create/page/server-reference-manifest.json +33 -33
- package/web/.next/server/app/(dashboard)/create/page.js.nft.json +1 -1
- package/web/.next/server/app/(dashboard)/create/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/feature/[featureId]/[tab]/page/server-reference-manifest.json +41 -41
- package/web/.next/server/app/(dashboard)/feature/[featureId]/[tab]/page.js.nft.json +1 -1
- package/web/.next/server/app/(dashboard)/feature/[featureId]/[tab]/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/feature/[featureId]/page/server-reference-manifest.json +41 -41
- package/web/.next/server/app/(dashboard)/feature/[featureId]/page.js.nft.json +1 -1
- package/web/.next/server/app/(dashboard)/feature/[featureId]/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/page/server-reference-manifest.json +30 -30
- package/web/.next/server/app/(dashboard)/page.js.nft.json +1 -1
- package/web/.next/server/app/(dashboard)/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/repository/[repositoryId]/[tab]/page/server-reference-manifest.json +31 -31
- package/web/.next/server/app/(dashboard)/repository/[repositoryId]/[tab]/page.js.nft.json +1 -1
- package/web/.next/server/app/(dashboard)/repository/[repositoryId]/[tab]/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/(dashboard)/repository/[repositoryId]/page/server-reference-manifest.json +31 -31
- package/web/.next/server/app/(dashboard)/repository/[repositoryId]/page.js.nft.json +1 -1
- package/web/.next/server/app/(dashboard)/repository/[repositoryId]/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/_global-error.html +2 -2
- package/web/.next/server/app/_global-error.rsc +1 -1
- package/web/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/web/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/web/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/web/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/web/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/web/.next/server/app/_not-found/page/server-reference-manifest.json +7 -7
- package/web/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/web/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/api/attachments/preview/route.js.nft.json +1 -1
- package/web/.next/server/app/api/evidence/route.js.nft.json +1 -1
- package/web/.next/server/app/api/graph-data/route.js.nft.json +1 -1
- package/web/.next/server/app/api/interactive/chat/[featureId]/messages/route.js.nft.json +1 -1
- package/web/.next/server/app/application/[id]/page/server-reference-manifest.json +15 -15
- package/web/.next/server/app/application/[id]/page.js.nft.json +1 -1
- package/web/.next/server/app/application/[id]/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/features/page/server-reference-manifest.json +7 -7
- package/web/.next/server/app/features/page.js.nft.json +1 -1
- package/web/.next/server/app/features/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/settings/page/server-reference-manifest.json +65 -20
- package/web/.next/server/app/settings/page.js +1 -1
- package/web/.next/server/app/settings/page.js.nft.json +1 -1
- package/web/.next/server/app/settings/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/skills/page/server-reference-manifest.json +15 -15
- package/web/.next/server/app/skills/page.js.nft.json +1 -1
- package/web/.next/server/app/skills/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/tools/page/server-reference-manifest.json +13 -13
- package/web/.next/server/app/tools/page.js.nft.json +1 -1
- package/web/.next/server/app/tools/page_client-reference-manifest.js +1 -1
- package/web/.next/server/app/version/page/server-reference-manifest.json +7 -7
- package/web/.next/server/app/version/page.js.nft.json +1 -1
- package/web/.next/server/app/version/page_client-reference-manifest.js +1 -1
- package/web/.next/server/chunks/[root-of-the-server]__a402b567._.js +1 -1
- package/web/.next/server/chunks/[root-of-the-server]__b2a4bfcc._.js +1 -1
- package/web/.next/server/chunks/[root-of-the-server]__b2a4bfcc._.js.map +1 -1
- package/web/.next/server/chunks/[root-of-the-server]__cd67a84c._.js +1 -1
- package/web/.next/server/chunks/[root-of-the-server]__cd67a84c._.js.map +1 -1
- package/web/.next/server/chunks/ssr/744ca_web_components_common_control-center-drawer_create-drawer-client_tsx_5e26fc0a._.js +1 -1
- package/web/.next/server/chunks/ssr/744ca_web_components_common_control-center-drawer_create-drawer-client_tsx_5e26fc0a._.js.map +1 -1
- package/web/.next/server/chunks/ssr/744ca_web_components_common_control-center-drawer_feature-drawer-client_tsx_e9755fc8._.js +2 -2
- package/web/.next/server/chunks/ssr/744ca_web_components_common_control-center-drawer_feature-drawer-client_tsx_e9755fc8._.js.map +1 -1
- package/web/.next/server/chunks/ssr/{7f428_lucide-react_dist_esm_icons_5da25833._.js → 7f428_lucide-react_dist_esm_icons_469d51b7._.js} +2 -2
- package/web/.next/server/chunks/ssr/7f428_lucide-react_dist_esm_icons_469d51b7._.js.map +1 -0
- package/web/.next/server/chunks/ssr/[root-of-the-server]__013a0318._.js +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__013a0318._.js.map +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__17dadd08._.js +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__17dadd08._.js.map +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__1925bef0._.js +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__1a9687c4._.js +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__1a9687c4._.js.map +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__24756fa9._.js +2 -2
- package/web/.next/server/chunks/ssr/[root-of-the-server]__24756fa9._.js.map +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__42d066e1._.js +3 -0
- package/web/.next/server/chunks/ssr/[root-of-the-server]__42d066e1._.js.map +1 -0
- package/web/.next/server/chunks/ssr/[root-of-the-server]__4ee8be85._.js +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__70986695._.js +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__70986695._.js.map +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__a5ea76a6._.js +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__a5ea76a6._.js.map +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__dd3e834e._.js +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__dd3e834e._.js.map +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__e265da61._.js +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__f3ca7bea._.js +1 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__f3ca7bea._.js.map +1 -1
- package/web/.next/server/chunks/ssr/{[root-of-the-server]__bb391c45._.js → [root-of-the-server]__f4f07ee6._.js} +2 -2
- package/web/.next/server/chunks/ssr/[root-of-the-server]__f4f07ee6._.js.map +1 -0
- package/web/.next/server/chunks/ssr/_0277d3b5._.js +1 -1
- package/web/.next/server/chunks/ssr/_0277d3b5._.js.map +1 -1
- package/web/.next/server/chunks/ssr/{_96718a00._.js → _1a4c514f._.js} +2 -2
- package/web/.next/server/chunks/ssr/{_96718a00._.js.map → _1a4c514f._.js.map} +1 -1
- package/web/.next/server/chunks/ssr/{_948d3cc6._.js → _33bab16e._.js} +2 -2
- package/web/.next/server/chunks/ssr/{_948d3cc6._.js.map → _33bab16e._.js.map} +1 -1
- package/web/.next/server/chunks/ssr/_45496654._.js.map +1 -1
- package/web/.next/server/chunks/ssr/_56b9d60f._.js +1 -1
- package/web/.next/server/chunks/ssr/_56b9d60f._.js.map +1 -1
- package/web/.next/server/chunks/ssr/{_ff6f3257._.js → _5d41b1f7._.js} +2 -2
- package/web/.next/server/chunks/ssr/{_ff6f3257._.js.map → _5d41b1f7._.js.map} +1 -1
- package/web/.next/server/chunks/ssr/_708a9069._.js +3 -0
- package/web/.next/server/chunks/ssr/_708a9069._.js.map +1 -0
- package/web/.next/server/chunks/ssr/{_9df33116._.js → _81197d1b._.js} +2 -2
- package/web/.next/server/chunks/ssr/{_9df33116._.js.map → _81197d1b._.js.map} +1 -1
- package/web/.next/server/chunks/ssr/{_295fffde._.js → _86bb5eb1._.js} +6 -2
- package/web/.next/server/chunks/ssr/_86bb5eb1._.js.map +1 -0
- package/web/.next/server/chunks/ssr/_946a7fc6._.js +1 -1
- package/web/.next/server/chunks/ssr/_946a7fc6._.js.map +1 -1
- package/web/.next/server/chunks/ssr/_bad61758._.js +3 -0
- package/web/.next/server/chunks/ssr/_bad61758._.js.map +1 -0
- package/web/.next/server/chunks/ssr/{_ee88b448._.js → _ce70bfa0._.js} +2 -2
- package/web/.next/server/chunks/ssr/{_ee88b448._.js.map → _ce70bfa0._.js.map} +1 -1
- package/web/.next/server/chunks/ssr/_d7d82308._.js +3 -0
- package/web/.next/server/chunks/ssr/_d7d82308._.js.map +1 -0
- package/web/.next/server/chunks/ssr/_dd852eae._.js +3 -0
- package/web/.next/server/chunks/ssr/_dd852eae._.js.map +1 -0
- package/web/.next/server/chunks/ssr/_eff1b518._.js +1 -1
- package/web/.next/server/chunks/ssr/_eff1b518._.js.map +1 -1
- package/web/.next/server/chunks/ssr/_f227429a._.js +1 -1
- package/web/.next/server/chunks/ssr/_f227429a._.js.map +1 -1
- package/web/.next/server/chunks/ssr/_f6b812ec._.js +9 -0
- package/web/.next/server/chunks/ssr/_f6b812ec._.js.map +1 -0
- package/web/.next/server/chunks/ssr/_f86fc1bf._.js +1 -1
- package/web/.next/server/chunks/ssr/_f86fc1bf._.js.map +1 -1
- package/web/.next/server/chunks/ssr/_f8c55130._.js +1 -1
- package/web/.next/server/chunks/ssr/b1a17_presentation_web_components_features_settings_settings-page-client_tsx_6ed9d5f8._.js +1 -1
- package/web/.next/server/chunks/ssr/b1a17_presentation_web_components_features_settings_settings-page-client_tsx_6ed9d5f8._.js.map +1 -1
- package/web/.next/server/chunks/ssr/f3a1f_components_common_control-center-drawer_repository-drawer-client_tsx_39a00c03._.js +1 -1
- package/web/.next/server/chunks/ssr/f3a1f_components_common_control-center-drawer_repository-drawer-client_tsx_39a00c03._.js.map +1 -1
- package/web/.next/server/chunks/ssr/node_modules__pnpm_64cc95e9._.js +3 -0
- package/web/.next/server/chunks/ssr/node_modules__pnpm_64cc95e9._.js.map +1 -0
- package/web/.next/server/chunks/ssr/src_presentation_web_36f2bc45._.js +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_36f2bc45._.js.map +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_486908de._.js +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_486908de._.js.map +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_5c3596bc._.js +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_5c3596bc._.js.map +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_6159fef8._.js +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_6159fef8._.js.map +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_6326f81e._.js +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_6326f81e._.js.map +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_6b2fdcd8._.js +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_6b2fdcd8._.js.map +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_74703c9f._.js +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_74703c9f._.js.map +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_a8056dac._.js +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_a8056dac._.js.map +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_ad42cc73._.js +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_ad42cc73._.js.map +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_app_actions_open-ide_ts_baaca5d5._.js +3 -3
- package/web/.next/server/chunks/ssr/src_presentation_web_app_actions_open-ide_ts_baaca5d5._.js.map +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_b00bfb08._.js +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_b00bfb08._.js.map +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_components_895e5bfa._.js +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_components_895e5bfa._.js.map +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_components_common_base-drawer_base-drawer_tsx_97dfbbc8._.js +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_components_common_base-drawer_base-drawer_tsx_97dfbbc8._.js.map +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_components_features_control-center_7ac3562e._.js +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_components_features_control-center_7ac3562e._.js.map +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_components_features_skills_8a174cac._.js +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_components_features_skills_8a174cac._.js.map +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_f1edcf5e._.js +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_f1edcf5e._.js.map +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_f9436804._.js +1 -1
- package/web/.next/server/chunks/ssr/src_presentation_web_f9436804._.js.map +1 -1
- package/web/.next/server/chunks/ssr/translations_23dd5e7e._.js +1 -1
- package/web/.next/server/chunks/ssr/translations_23dd5e7e._.js.map +1 -1
- package/web/.next/server/pages/500.html +2 -2
- package/web/.next/server/server-reference-manifest.js +1 -1
- package/web/.next/server/server-reference-manifest.json +109 -64
- package/web/.next/static/chunks/0239d68df2738a2a.js +1 -0
- package/web/.next/static/chunks/{b17c2d874c373d4e.js → 05d641009a42e94b.js} +1 -1
- package/web/.next/static/chunks/{ee9a716c6424ff25.js → 0d04391861f2a381.js} +1 -1
- package/web/.next/static/chunks/{2a64d4b1a285fac5.js → 151d16c2c65a4356.js} +1 -1
- package/web/.next/static/chunks/19008d82be3a09a5.js +5 -0
- package/web/.next/static/chunks/{f7a55ba1f789c55f.js → 193d8b761fec697e.js} +1 -1
- package/web/.next/static/chunks/2bad6607c1e0f153.js +7 -0
- package/web/.next/static/chunks/{7c3fe3c694874dea.js → 32940aa08b947f66.js} +1 -1
- package/web/.next/static/chunks/{0a67d6e50e27452e.js → 368809962c4cd597.js} +1 -1
- package/web/.next/static/chunks/{8f783e12274578c2.js → 475e5bd4e8bafc6f.js} +1 -1
- package/web/.next/static/chunks/{c1559152cf2ab9c6.js → 55e59f912fff1858.js} +1 -1
- package/web/.next/static/chunks/{fcf27468f8026dbd.js → 66d72ca561bb91ca.js} +1 -1
- package/web/.next/static/chunks/6da04daaac881f27.js +1 -0
- package/web/.next/static/chunks/{2fe20598e1b4793a.js → 75eb5f94364a44bf.js} +2 -2
- package/web/.next/static/chunks/{e8444bf5f6c35f8b.js → 7bbe49d9daedd94d.js} +5 -1
- package/web/.next/static/chunks/{3ee4449e73eb4917.js → 83ea5b5b0d0a8477.js} +1 -1
- package/web/.next/static/chunks/8fe70d4e73e1fe31.css +1 -0
- package/web/.next/static/chunks/9d70c74c84d24724.js +1 -0
- package/web/.next/static/chunks/{010215070d22b4e6.js → a6d8276c88451abf.js} +2 -2
- package/web/.next/static/chunks/b3fa9a303332e7d6.js +3 -0
- package/web/.next/static/chunks/b9b3a6d83e07b213.js +1 -0
- package/web/.next/static/chunks/c92bc820f657f9d9.js +1 -0
- package/web/.next/static/chunks/dd5ab4e1762b5812.js +1 -0
- package/web/.next/static/chunks/{2ddda685a9100fd8.js → e7b870347bdfe35d.js} +1 -1
- package/web/.next/static/chunks/ecafea5bc026ed41.js +1 -0
- package/web/.next/server/chunks/ssr/7f428_lucide-react_dist_esm_icons_5da25833._.js.map +0 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__a6f2b763._.js +0 -3
- package/web/.next/server/chunks/ssr/[root-of-the-server]__a6f2b763._.js.map +0 -1
- package/web/.next/server/chunks/ssr/[root-of-the-server]__bb391c45._.js.map +0 -1
- package/web/.next/server/chunks/ssr/_295fffde._.js.map +0 -1
- package/web/.next/server/chunks/ssr/_44531b76._.js +0 -9
- package/web/.next/server/chunks/ssr/_44531b76._.js.map +0 -1
- package/web/.next/server/chunks/ssr/_5bf2415e._.js +0 -7
- package/web/.next/server/chunks/ssr/_5bf2415e._.js.map +0 -1
- package/web/.next/server/chunks/ssr/_869a3a15._.js +0 -3
- package/web/.next/server/chunks/ssr/_869a3a15._.js.map +0 -1
- package/web/.next/server/chunks/ssr/_b227ff50._.js +0 -3
- package/web/.next/server/chunks/ssr/_b227ff50._.js.map +0 -1
- package/web/.next/server/chunks/ssr/_e071ba48._.js +0 -3
- package/web/.next/server/chunks/ssr/_e071ba48._.js.map +0 -1
- package/web/.next/server/chunks/ssr/node_modules__pnpm_747b43ac._.js +0 -3
- package/web/.next/server/chunks/ssr/node_modules__pnpm_747b43ac._.js.map +0 -1
- package/web/.next/static/chunks/06b9d6dbf635c370.css +0 -1
- package/web/.next/static/chunks/1ae0cf5be30ef398.js +0 -1
- package/web/.next/static/chunks/6ecbcce796343f44.js +0 -1
- package/web/.next/static/chunks/8492d8e0b5f9a4e8.js +0 -1
- package/web/.next/static/chunks/927442d2628f6e22.js +0 -1
- package/web/.next/static/chunks/9370d114ce5b69fb.js +0 -7
- package/web/.next/static/chunks/b2a010b2ba8710f4.js +0 -1
- package/web/.next/static/chunks/b99506a6f7bc2fa8.js +0 -1
- package/web/.next/static/chunks/d2182843a406b5a7.js +0 -5
- package/web/.next/static/chunks/edf812d5efffa096.js +0 -7
- /package/web/.next/static/{ex3OTWRXHxfwD9RkifALI → Rb8tiiSfY1LEpEkuZLtTr}/_buildManifest.js +0 -0
- /package/web/.next/static/{ex3OTWRXHxfwD9RkifALI → Rb8tiiSfY1LEpEkuZLtTr}/_clientMiddlewareManifest.json +0 -0
- /package/web/.next/static/{ex3OTWRXHxfwD9RkifALI → Rb8tiiSfY1LEpEkuZLtTr}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Messaging Service
|
|
3
|
+
*
|
|
4
|
+
* Core orchestrator for the external messaging remote control feature.
|
|
5
|
+
* Wires together:
|
|
6
|
+
* - Commands.com Gateway tunnel (inbound webhook delivery)
|
|
7
|
+
* - Telegram Bot API client (outbound replies + notifications)
|
|
8
|
+
* - Command executor (parses slash commands, runs use cases)
|
|
9
|
+
* - Notification emitter (debounced forwarding from the local event bus)
|
|
10
|
+
* - Chat relay (interactive agent ↔ messenger bridge)
|
|
11
|
+
* - Pairing auto-confirm (matches /pair <code> against pending codes)
|
|
12
|
+
*
|
|
13
|
+
* Lifecycle:
|
|
14
|
+
* 1. `isConfigured()` checks settings for required fields.
|
|
15
|
+
* 2. `start()` opens the tunnel and subscribes to the notification bus.
|
|
16
|
+
* 3. Inbound `tunnel.request` frames are parsed as Telegram Update objects
|
|
17
|
+
* and dispatched to either the pair confirm flow or the command executor.
|
|
18
|
+
* 4. `stop()` tears everything down.
|
|
19
|
+
*/
|
|
20
|
+
import { MessagingPlatform, MessagingFrameType, MessagingCommandType, } from '../../../domain/generated/output.js';
|
|
21
|
+
import { MessagingTunnelAdapter } from './messaging-tunnel.adapter.js';
|
|
22
|
+
import { MessagingCommandExecutor } from './command-executor.js';
|
|
23
|
+
import { MessagingNotificationEmitter } from './notification-emitter.js';
|
|
24
|
+
import { MessagingChatRelay } from './chat-relay.js';
|
|
25
|
+
import { TelegramMessageSender } from './telegram-message-sender.js';
|
|
26
|
+
import { parseTelegramUpdate, parsePairCommand } from './telegram-webhook.parser.js';
|
|
27
|
+
import { parseWhatsAppUpdate } from './whatsapp-webhook.parser.js';
|
|
28
|
+
const COMMAND_REGEX = /^\/(new|approve|reject|stop|resume|status|list|chat|end|mute|unmute|help)(?:@\w+)?(?:\s+(\S+))?(?:\s+(.+))?$/i;
|
|
29
|
+
const COMMANDS_TAKING_FEATURE_ID = [
|
|
30
|
+
MessagingCommandType.Approve,
|
|
31
|
+
MessagingCommandType.Reject,
|
|
32
|
+
MessagingCommandType.Stop,
|
|
33
|
+
MessagingCommandType.Resume,
|
|
34
|
+
MessagingCommandType.Status,
|
|
35
|
+
MessagingCommandType.Chat,
|
|
36
|
+
];
|
|
37
|
+
function parseSlashCommand(text) {
|
|
38
|
+
const match = text.trim().match(COMMAND_REGEX);
|
|
39
|
+
if (!match)
|
|
40
|
+
return null;
|
|
41
|
+
const command = match[1].toLowerCase();
|
|
42
|
+
const second = match[2];
|
|
43
|
+
const rest = match[3];
|
|
44
|
+
if (COMMANDS_TAKING_FEATURE_ID.includes(command) && second) {
|
|
45
|
+
return { command, featureId: second, args: rest };
|
|
46
|
+
}
|
|
47
|
+
const args = [second, rest].filter(Boolean).join(' ');
|
|
48
|
+
return { command, args: args || undefined };
|
|
49
|
+
}
|
|
50
|
+
export class MessagingService {
|
|
51
|
+
deps;
|
|
52
|
+
tunnelAdapter = null;
|
|
53
|
+
commandExecutor = null;
|
|
54
|
+
notificationEmitter = null;
|
|
55
|
+
chatRelay = null;
|
|
56
|
+
sender = null;
|
|
57
|
+
started = false;
|
|
58
|
+
constructor(deps) {
|
|
59
|
+
this.deps = deps;
|
|
60
|
+
}
|
|
61
|
+
isConfigured() {
|
|
62
|
+
const { config } = this.deps;
|
|
63
|
+
if (!config.enabled || !config.gatewayUrl || !config.deviceId)
|
|
64
|
+
return false;
|
|
65
|
+
// The tunnel must start as soon as a route exists — not only after the
|
|
66
|
+
// user is fully paired. The auto-confirm flow requires this: the daemon
|
|
67
|
+
// needs to be receiving tunnel.request frames in order to see the
|
|
68
|
+
// inbound `/pair <code>` message from the user's first DM and call
|
|
69
|
+
// ConfirmMessagingPairingUseCase. If we gated on `paired && chatId`
|
|
70
|
+
// the user could never complete pairing without a manual chatId entry
|
|
71
|
+
// in the UI.
|
|
72
|
+
const telegramReady = !!config.telegram?.routeId;
|
|
73
|
+
const whatsappReady = !!config.whatsapp?.routeId;
|
|
74
|
+
return telegramReady || whatsappReady;
|
|
75
|
+
}
|
|
76
|
+
isConnected() {
|
|
77
|
+
return this.tunnelAdapter?.isConnected() ?? false;
|
|
78
|
+
}
|
|
79
|
+
async start() {
|
|
80
|
+
if (this.started || !this.isConfigured())
|
|
81
|
+
return;
|
|
82
|
+
const { config, accessToken, telegramClient, notificationBus, featureRepo } = this.deps;
|
|
83
|
+
const routeIds = this.collectRouteIds();
|
|
84
|
+
this.tunnelAdapter = new MessagingTunnelAdapter({
|
|
85
|
+
gatewayUrl: config.gatewayUrl,
|
|
86
|
+
accessToken,
|
|
87
|
+
deviceId: config.deviceId,
|
|
88
|
+
routeIds,
|
|
89
|
+
});
|
|
90
|
+
this.sender = new TelegramMessageSender(telegramClient, () => {
|
|
91
|
+
const chatId = this.deps.config.telegram?.chatId;
|
|
92
|
+
const botToken = this.deps.telegramBotToken;
|
|
93
|
+
if (!chatId || !botToken)
|
|
94
|
+
return null;
|
|
95
|
+
return { chatId, botToken };
|
|
96
|
+
});
|
|
97
|
+
this.commandExecutor = new MessagingCommandExecutor(featureRepo, this.deps.createFeature, this.deps.approveAgentRun, this.deps.rejectAgentRun, this.deps.stopAgentRun, this.deps.resumeFeature, this.deps.listFeatures, this.deps.showFeature, this.deps.listRepositories);
|
|
98
|
+
this.notificationEmitter = new MessagingNotificationEmitter(this.sender, notificationBus, config.debounceMs ?? 5_000);
|
|
99
|
+
this.chatRelay = new MessagingChatRelay(this.sender, config.chatBufferMs ?? 3_000);
|
|
100
|
+
this.tunnelAdapter.onRequest((req) => this.handleTunnelRequest(req));
|
|
101
|
+
try {
|
|
102
|
+
await this.tunnelAdapter.connect();
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
// Connection failure is non-fatal — the adapter reconnects automatically.
|
|
106
|
+
}
|
|
107
|
+
this.notificationEmitter.start();
|
|
108
|
+
this.started = true;
|
|
109
|
+
}
|
|
110
|
+
async stop() {
|
|
111
|
+
if (!this.started)
|
|
112
|
+
return;
|
|
113
|
+
this.notificationEmitter?.stop();
|
|
114
|
+
this.chatRelay?.stop();
|
|
115
|
+
await this.tunnelAdapter?.disconnect();
|
|
116
|
+
this.tunnelAdapter = null;
|
|
117
|
+
this.commandExecutor = null;
|
|
118
|
+
this.notificationEmitter = null;
|
|
119
|
+
this.chatRelay = null;
|
|
120
|
+
this.sender = null;
|
|
121
|
+
this.started = false;
|
|
122
|
+
}
|
|
123
|
+
async sendNotification(notification) {
|
|
124
|
+
await this.sender?.send(notification);
|
|
125
|
+
}
|
|
126
|
+
collectRouteIds() {
|
|
127
|
+
const out = [];
|
|
128
|
+
const { config } = this.deps;
|
|
129
|
+
if (config.telegram?.routeId)
|
|
130
|
+
out.push(config.telegram.routeId);
|
|
131
|
+
if (config.whatsapp?.routeId)
|
|
132
|
+
out.push(config.whatsapp.routeId);
|
|
133
|
+
return out;
|
|
134
|
+
}
|
|
135
|
+
async handleTunnelRequest(req) {
|
|
136
|
+
// Per-route → platform resolution.
|
|
137
|
+
const platform = this.platformForRoute(req.routeId);
|
|
138
|
+
if (!platform) {
|
|
139
|
+
return { status: 404 };
|
|
140
|
+
}
|
|
141
|
+
const parsed = platform === MessagingPlatform.Telegram
|
|
142
|
+
? parseTelegramUpdate(req.body)
|
|
143
|
+
: parseWhatsAppUpdate(req.body);
|
|
144
|
+
if (!parsed) {
|
|
145
|
+
return { status: 200 };
|
|
146
|
+
}
|
|
147
|
+
// 1. Handle /pair <code> auto-confirmation before anything else.
|
|
148
|
+
const pair = parsePairCommand(parsed.text);
|
|
149
|
+
if (pair) {
|
|
150
|
+
await this.handlePairConfirm(platform, parsed.chatId, pair.code);
|
|
151
|
+
return { status: 200 };
|
|
152
|
+
}
|
|
153
|
+
// 2. Dispatch slash commands via the command executor. /chat and /end
|
|
154
|
+
// are handled specially because they manipulate the chat relay.
|
|
155
|
+
const slash = parseSlashCommand(parsed.text);
|
|
156
|
+
if (slash) {
|
|
157
|
+
if (slash.command === MessagingCommandType.Chat) {
|
|
158
|
+
await this.handleChatStart(platform, parsed.chatId, slash.featureId);
|
|
159
|
+
return { status: 200 };
|
|
160
|
+
}
|
|
161
|
+
if (slash.command === MessagingCommandType.End) {
|
|
162
|
+
await this.handleChatEnd(parsed.chatId);
|
|
163
|
+
return { status: 200 };
|
|
164
|
+
}
|
|
165
|
+
if (this.commandExecutor) {
|
|
166
|
+
const cmd = {
|
|
167
|
+
type: MessagingFrameType.Command,
|
|
168
|
+
command: slash.command,
|
|
169
|
+
featureId: slash.featureId,
|
|
170
|
+
args: slash.args,
|
|
171
|
+
chatId: parsed.chatId,
|
|
172
|
+
platform,
|
|
173
|
+
};
|
|
174
|
+
try {
|
|
175
|
+
const reply = await this.commandExecutor.execute(cmd);
|
|
176
|
+
await this.sendReply(parsed.chatId, reply);
|
|
177
|
+
}
|
|
178
|
+
catch (err) {
|
|
179
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
180
|
+
await this.sendReply(parsed.chatId, `Command failed: ${msg}`);
|
|
181
|
+
}
|
|
182
|
+
return { status: 200 };
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
// 3. If there's an active chat relay, forward the message to the
|
|
186
|
+
// interactive session.
|
|
187
|
+
if (this.chatRelay?.hasActiveRelay()) {
|
|
188
|
+
await this.handleChatMessage(parsed.chatId, parsed.text);
|
|
189
|
+
return { status: 200 };
|
|
190
|
+
}
|
|
191
|
+
// 4. Unknown message — ignore silently.
|
|
192
|
+
return { status: 200 };
|
|
193
|
+
}
|
|
194
|
+
async handleChatStart(platform, chatId, featureId) {
|
|
195
|
+
if (!featureId) {
|
|
196
|
+
await this.sendReply(chatId, 'Usage: /chat <feature_id>');
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
if (!this.chatRelay)
|
|
200
|
+
return;
|
|
201
|
+
const feature = await this.deps.featureRepo.findById(featureId);
|
|
202
|
+
if (!feature) {
|
|
203
|
+
await this.sendReply(chatId, `Feature ${featureId} not found.`);
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
if (!feature.worktreePath) {
|
|
207
|
+
await this.sendReply(chatId, `Feature ${featureId} has no worktree yet — it may not be checked out.`);
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
// Subscribe to the interactive session's stream and forward deltas to
|
|
211
|
+
// the chat relay buffer. The unsubscribe handle is owned by the relay.
|
|
212
|
+
const unsubscribe = this.deps.interactiveSessionService.subscribeByFeature(feature.id, (chunk) => {
|
|
213
|
+
if (chunk.delta) {
|
|
214
|
+
this.chatRelay?.bufferAgentOutput(chunk.delta);
|
|
215
|
+
}
|
|
216
|
+
if (chunk.done) {
|
|
217
|
+
this.chatRelay?.flushBuffer();
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
const message = this.chatRelay.startRelay(feature.id, chatId, platform, feature.worktreePath, unsubscribe);
|
|
221
|
+
await this.sendReply(chatId, message);
|
|
222
|
+
}
|
|
223
|
+
async handleChatEnd(chatId) {
|
|
224
|
+
if (!this.chatRelay)
|
|
225
|
+
return;
|
|
226
|
+
const message = this.chatRelay.endRelay();
|
|
227
|
+
await this.sendReply(chatId, message);
|
|
228
|
+
}
|
|
229
|
+
async handleChatMessage(_chatId, text) {
|
|
230
|
+
if (!this.chatRelay?.hasActiveRelay())
|
|
231
|
+
return;
|
|
232
|
+
const featureId = this.chatRelay.getActiveFeatureId();
|
|
233
|
+
const worktreePath = this.chatRelay.getActiveWorktreePath();
|
|
234
|
+
if (!featureId || !worktreePath)
|
|
235
|
+
return;
|
|
236
|
+
try {
|
|
237
|
+
await this.deps.interactiveSessionService.sendUserMessage(featureId, text, worktreePath);
|
|
238
|
+
}
|
|
239
|
+
catch {
|
|
240
|
+
// Delivery failures surface as missing agent replies — no point
|
|
241
|
+
// spamming the user's chat with error toasts.
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
platformForRoute(routeId) {
|
|
245
|
+
const { config } = this.deps;
|
|
246
|
+
if (config.telegram?.routeId === routeId)
|
|
247
|
+
return MessagingPlatform.Telegram;
|
|
248
|
+
if (config.whatsapp?.routeId === routeId)
|
|
249
|
+
return MessagingPlatform.WhatsApp;
|
|
250
|
+
return null;
|
|
251
|
+
}
|
|
252
|
+
async handlePairConfirm(platform, chatId, code) {
|
|
253
|
+
const { config } = this.deps;
|
|
254
|
+
const platformCfg = platform === MessagingPlatform.Telegram ? config.telegram : config.whatsapp;
|
|
255
|
+
if (!platformCfg?.pendingPairingCode || platformCfg.pendingPairingCode !== code) {
|
|
256
|
+
await this.sendReply(chatId, 'Invalid or expired pairing code.');
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
try {
|
|
260
|
+
await this.deps.confirmPairing.execute({ platform, chatId });
|
|
261
|
+
await this.sendReply(chatId, 'Paired with Shep. You can now send commands like /status, /list, or /help.');
|
|
262
|
+
}
|
|
263
|
+
catch (err) {
|
|
264
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
265
|
+
await this.sendReply(chatId, `Pairing failed: ${msg}`);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
async sendReply(chatId, text) {
|
|
269
|
+
const botToken = this.deps.telegramBotToken;
|
|
270
|
+
if (!botToken || !text)
|
|
271
|
+
return;
|
|
272
|
+
try {
|
|
273
|
+
await this.deps.telegramClient.sendMessage({ botToken, chatId, text });
|
|
274
|
+
}
|
|
275
|
+
catch {
|
|
276
|
+
// Non-fatal — swallow so the tunnel response still completes.
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Messaging Notification Emitter
|
|
3
|
+
*
|
|
4
|
+
* Subscribes to Shep's existing NotificationEventBus and pushes
|
|
5
|
+
* events through the Gateway tunnel for delivery to messaging apps.
|
|
6
|
+
*
|
|
7
|
+
* Features:
|
|
8
|
+
* - Debouncing: events for the same feature+type are collapsed within
|
|
9
|
+
* a configurable window (default 5s) to avoid flooding
|
|
10
|
+
* - Content sanitization: all messages are scrubbed of paths, code, and secrets
|
|
11
|
+
* - Gate events are never debounced — delivered immediately
|
|
12
|
+
*/
|
|
13
|
+
import type { NotificationBus } from '../notifications/notification-bus.js';
|
|
14
|
+
import type { IMessageSender } from '../../../application/ports/output/services/message-sender.interface.js';
|
|
15
|
+
/**
|
|
16
|
+
* Subscribes to the notification event bus and forwards events
|
|
17
|
+
* to the messaging tunnel for delivery to the user's phone.
|
|
18
|
+
*/
|
|
19
|
+
export declare class MessagingNotificationEmitter {
|
|
20
|
+
private readonly sender;
|
|
21
|
+
private readonly notificationBus;
|
|
22
|
+
private readonly debounceMs;
|
|
23
|
+
private debounceTimers;
|
|
24
|
+
private listening;
|
|
25
|
+
private handler;
|
|
26
|
+
constructor(sender: IMessageSender, notificationBus: NotificationBus, debounceMs?: number);
|
|
27
|
+
/** Start listening for notification events */
|
|
28
|
+
start(): void;
|
|
29
|
+
/** Stop listening for notification events */
|
|
30
|
+
stop(): void;
|
|
31
|
+
private emitDebounced;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=notification-emitter.d.ts.map
|
package/dist/packages/core/src/infrastructure/services/messaging/notification-emitter.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notification-emitter.d.ts","sourceRoot":"","sources":["../../../../../../../packages/core/src/infrastructure/services/messaging/notification-emitter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAE5E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wEAAwE,CAAC;AAI7G;;;GAGG;AACH,qBAAa,4BAA4B;IAMrC,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,UAAU;IAP7B,OAAO,CAAC,cAAc,CAAoD;IAC1E,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,OAAO,CAAqD;gBAGjD,MAAM,EAAE,cAAc,EACtB,eAAe,EAAE,eAAe,EAChC,UAAU,GAAE,MAA4B;IAG3D,8CAA8C;IAC9C,KAAK,IAAI,IAAI;IAwBb,6CAA6C;IAC7C,IAAI,IAAI,IAAI;IAgBZ,OAAO,CAAC,aAAa;CAiBtB"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Messaging Notification Emitter
|
|
3
|
+
*
|
|
4
|
+
* Subscribes to Shep's existing NotificationEventBus and pushes
|
|
5
|
+
* events through the Gateway tunnel for delivery to messaging apps.
|
|
6
|
+
*
|
|
7
|
+
* Features:
|
|
8
|
+
* - Debouncing: events for the same feature+type are collapsed within
|
|
9
|
+
* a configurable window (default 5s) to avoid flooding
|
|
10
|
+
* - Content sanitization: all messages are scrubbed of paths, code, and secrets
|
|
11
|
+
* - Gate events are never debounced — delivered immediately
|
|
12
|
+
*/
|
|
13
|
+
import { sanitizeForMessaging } from './content-sanitizer.js';
|
|
14
|
+
const DEFAULT_DEBOUNCE_MS = 5_000;
|
|
15
|
+
/**
|
|
16
|
+
* Subscribes to the notification event bus and forwards events
|
|
17
|
+
* to the messaging tunnel for delivery to the user's phone.
|
|
18
|
+
*/
|
|
19
|
+
export class MessagingNotificationEmitter {
|
|
20
|
+
sender;
|
|
21
|
+
notificationBus;
|
|
22
|
+
debounceMs;
|
|
23
|
+
debounceTimers = new Map();
|
|
24
|
+
listening = false;
|
|
25
|
+
handler = null;
|
|
26
|
+
constructor(sender, notificationBus, debounceMs = DEFAULT_DEBOUNCE_MS) {
|
|
27
|
+
this.sender = sender;
|
|
28
|
+
this.notificationBus = notificationBus;
|
|
29
|
+
this.debounceMs = debounceMs;
|
|
30
|
+
}
|
|
31
|
+
/** Start listening for notification events */
|
|
32
|
+
start() {
|
|
33
|
+
if (this.listening)
|
|
34
|
+
return;
|
|
35
|
+
this.handler = (event) => {
|
|
36
|
+
const notification = {
|
|
37
|
+
event: event.eventType,
|
|
38
|
+
featureId: event.featureId,
|
|
39
|
+
title: event.featureName,
|
|
40
|
+
message: sanitizeForMessaging(event.message),
|
|
41
|
+
};
|
|
42
|
+
// Gate/approval events are always delivered immediately
|
|
43
|
+
if (event.eventType === 'waiting_approval') {
|
|
44
|
+
void this.sender.send(notification);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
this.emitDebounced(event.featureId, event.eventType, notification);
|
|
48
|
+
};
|
|
49
|
+
this.notificationBus.on('notification', this.handler);
|
|
50
|
+
this.listening = true;
|
|
51
|
+
}
|
|
52
|
+
/** Stop listening for notification events */
|
|
53
|
+
stop() {
|
|
54
|
+
if (!this.listening)
|
|
55
|
+
return;
|
|
56
|
+
if (this.handler) {
|
|
57
|
+
this.notificationBus.off('notification', this.handler);
|
|
58
|
+
this.handler = null;
|
|
59
|
+
}
|
|
60
|
+
// Clear all pending debounce timers
|
|
61
|
+
for (const timer of this.debounceTimers.values()) {
|
|
62
|
+
clearTimeout(timer);
|
|
63
|
+
}
|
|
64
|
+
this.debounceTimers.clear();
|
|
65
|
+
this.listening = false;
|
|
66
|
+
}
|
|
67
|
+
emitDebounced(featureId, eventType, notification) {
|
|
68
|
+
const key = `${featureId}:${eventType}`;
|
|
69
|
+
const existing = this.debounceTimers.get(key);
|
|
70
|
+
if (existing)
|
|
71
|
+
clearTimeout(existing);
|
|
72
|
+
const timer = setTimeout(() => {
|
|
73
|
+
void this.sender.send(notification);
|
|
74
|
+
this.debounceTimers.delete(key);
|
|
75
|
+
}, this.debounceMs);
|
|
76
|
+
timer.unref();
|
|
77
|
+
this.debounceTimers.set(key, timer);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stub Gateway Client
|
|
3
|
+
*
|
|
4
|
+
* Returns deterministic fake responses for E2E tests where no real
|
|
5
|
+
* Commands.com Gateway is available. Activated via SHEP_MOCK_GATEWAY=1.
|
|
6
|
+
*/
|
|
7
|
+
import type { IGatewayClient, FetchTokenInput, GatewayOAuthToken, CreateIntegrationRouteInput, GatewayIntegrationRoute } from '../../../application/ports/output/services/gateway-client.interface.js';
|
|
8
|
+
export declare class StubGatewayClient implements IGatewayClient {
|
|
9
|
+
fetchAccessToken(_input: FetchTokenInput): Promise<GatewayOAuthToken>;
|
|
10
|
+
createIntegrationRoute(gatewayUrl: string, _accessToken: string, input: CreateIntegrationRouteInput): Promise<GatewayIntegrationRoute>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=stub-gateway.client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stub-gateway.client.d.ts","sourceRoot":"","sources":["../../../../../../../packages/core/src/infrastructure/services/messaging/stub-gateway.client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,eAAe,EACf,iBAAiB,EACjB,2BAA2B,EAC3B,uBAAuB,EACxB,MAAM,wEAAwE,CAAC;AAEhF,qBAAa,iBAAkB,YAAW,cAAc;IAChD,gBAAgB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAQrE,sBAAsB,CAC1B,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,2BAA2B,GACjC,OAAO,CAAC,uBAAuB,CAAC;CAWpC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stub Gateway Client
|
|
3
|
+
*
|
|
4
|
+
* Returns deterministic fake responses for E2E tests where no real
|
|
5
|
+
* Commands.com Gateway is available. Activated via SHEP_MOCK_GATEWAY=1.
|
|
6
|
+
*/
|
|
7
|
+
export class StubGatewayClient {
|
|
8
|
+
async fetchAccessToken(_input) {
|
|
9
|
+
return {
|
|
10
|
+
accessToken: 'stub-access-token',
|
|
11
|
+
tokenType: 'Bearer',
|
|
12
|
+
expiresAt: Date.now() + 3600 * 1000,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
async createIntegrationRoute(gatewayUrl, _accessToken, input) {
|
|
16
|
+
const routeId = `stub-route-${input.interfaceType}`;
|
|
17
|
+
const routeToken = `stub-token-${Date.now()}`;
|
|
18
|
+
return {
|
|
19
|
+
routeId,
|
|
20
|
+
routeToken,
|
|
21
|
+
publicUrl: `${gatewayUrl}/integrations/${routeId}/${routeToken}`,
|
|
22
|
+
deviceId: input.deviceId,
|
|
23
|
+
interfaceType: input.interfaceType,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Telegram Message Sender
|
|
3
|
+
*
|
|
4
|
+
* Concrete IMessageSender that delivers notifications to a paired Telegram
|
|
5
|
+
* chat via the Telegram Bot API. Looks up the bot token + chat id from the
|
|
6
|
+
* messaging config on every send so that pairing changes propagate without
|
|
7
|
+
* restarting the daemon.
|
|
8
|
+
*
|
|
9
|
+
* This sender silently no-ops when Telegram is not paired — callers don't
|
|
10
|
+
* need to guard individually.
|
|
11
|
+
*/
|
|
12
|
+
import type { IMessageSender } from '../../../application/ports/output/services/message-sender.interface.js';
|
|
13
|
+
import type { ITelegramClient } from '../../../application/ports/output/services/telegram-client.interface.js';
|
|
14
|
+
import type { MessagingNotification } from '../../../domain/generated/output.js';
|
|
15
|
+
export interface TelegramMessageSenderConfig {
|
|
16
|
+
botToken: string;
|
|
17
|
+
chatId: string;
|
|
18
|
+
}
|
|
19
|
+
export type TelegramConfigResolver = () => TelegramMessageSenderConfig | null;
|
|
20
|
+
export declare class TelegramMessageSender implements IMessageSender {
|
|
21
|
+
private readonly telegramClient;
|
|
22
|
+
private readonly resolveConfig;
|
|
23
|
+
constructor(telegramClient: ITelegramClient, resolveConfig: TelegramConfigResolver);
|
|
24
|
+
send(notification: MessagingNotification): Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=telegram-message-sender.d.ts.map
|
package/dist/packages/core/src/infrastructure/services/messaging/telegram-message-sender.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telegram-message-sender.d.ts","sourceRoot":"","sources":["../../../../../../../packages/core/src/infrastructure/services/messaging/telegram-message-sender.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wEAAwE,CAAC;AAC7G,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yEAAyE,CAAC;AAC/G,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAEjF,MAAM,WAAW,2BAA2B;IAC1C,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,sBAAsB,GAAG,MAAM,2BAA2B,GAAG,IAAI,CAAC;AAU9E,qBAAa,qBAAsB,YAAW,cAAc;IAExD,OAAO,CAAC,QAAQ,CAAC,cAAc;IAC/B,OAAO,CAAC,QAAQ,CAAC,aAAa;gBADb,cAAc,EAAE,eAAe,EAC/B,aAAa,EAAE,sBAAsB;IAGlD,IAAI,CAAC,YAAY,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;CAmB/D"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Telegram Message Sender
|
|
3
|
+
*
|
|
4
|
+
* Concrete IMessageSender that delivers notifications to a paired Telegram
|
|
5
|
+
* chat via the Telegram Bot API. Looks up the bot token + chat id from the
|
|
6
|
+
* messaging config on every send so that pairing changes propagate without
|
|
7
|
+
* restarting the daemon.
|
|
8
|
+
*
|
|
9
|
+
* This sender silently no-ops when Telegram is not paired — callers don't
|
|
10
|
+
* need to guard individually.
|
|
11
|
+
*/
|
|
12
|
+
function formatNotification(notification) {
|
|
13
|
+
const lines = [];
|
|
14
|
+
if (notification.title)
|
|
15
|
+
lines.push(`*${notification.title}*`);
|
|
16
|
+
if (notification.message)
|
|
17
|
+
lines.push(notification.message);
|
|
18
|
+
if (notification.event && !notification.title)
|
|
19
|
+
lines.push(`[${notification.event}]`);
|
|
20
|
+
return lines.join('\n');
|
|
21
|
+
}
|
|
22
|
+
export class TelegramMessageSender {
|
|
23
|
+
telegramClient;
|
|
24
|
+
resolveConfig;
|
|
25
|
+
constructor(telegramClient, resolveConfig) {
|
|
26
|
+
this.telegramClient = telegramClient;
|
|
27
|
+
this.resolveConfig = resolveConfig;
|
|
28
|
+
}
|
|
29
|
+
async send(notification) {
|
|
30
|
+
const config = this.resolveConfig();
|
|
31
|
+
if (!config?.botToken || !config.chatId)
|
|
32
|
+
return;
|
|
33
|
+
const text = formatNotification(notification);
|
|
34
|
+
if (!text.trim())
|
|
35
|
+
return;
|
|
36
|
+
try {
|
|
37
|
+
await this.telegramClient.sendMessage({
|
|
38
|
+
botToken: config.botToken,
|
|
39
|
+
chatId: config.chatId,
|
|
40
|
+
text,
|
|
41
|
+
parseMode: 'Markdown',
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
// Delivery failures are non-fatal — the daemon keeps running and
|
|
46
|
+
// future notifications will retry on their own cadence.
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Telegram Webhook Parser
|
|
3
|
+
*
|
|
4
|
+
* Converts a raw Telegram `Update` object (posted to our webhook ingress URL)
|
|
5
|
+
* into a domain-level ChatMessage that the messaging service can dispatch.
|
|
6
|
+
*
|
|
7
|
+
* Reference: https://core.telegram.org/bots/api#update
|
|
8
|
+
*
|
|
9
|
+
* We only care about the `message` variant for now — inline queries,
|
|
10
|
+
* callback queries, edited messages, and channel posts are all ignored and
|
|
11
|
+
* return `null`, which causes the tunnel adapter to reply 200 without
|
|
12
|
+
* further side effects.
|
|
13
|
+
*/
|
|
14
|
+
export interface ParsedTelegramMessage {
|
|
15
|
+
chatId: string;
|
|
16
|
+
/** Telegram user ID of the sender. */
|
|
17
|
+
senderId?: string;
|
|
18
|
+
/** Username without leading @. */
|
|
19
|
+
senderUsername?: string;
|
|
20
|
+
text: string;
|
|
21
|
+
}
|
|
22
|
+
export declare function parseTelegramUpdate(rawBody: string): ParsedTelegramMessage | null;
|
|
23
|
+
export interface PairCommand {
|
|
24
|
+
code: string;
|
|
25
|
+
}
|
|
26
|
+
/** Match `/pair 123456` (with optional `@botname` suffix). */
|
|
27
|
+
export declare function parsePairCommand(text: string): PairCommand | null;
|
|
28
|
+
//# sourceMappingURL=telegram-webhook.parser.d.ts.map
|
package/dist/packages/core/src/infrastructure/services/messaging/telegram-webhook.parser.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telegram-webhook.parser.d.ts","sourceRoot":"","sources":["../../../../../../../packages/core/src/infrastructure/services/messaging/telegram-webhook.parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,sCAAsC;IACtC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kCAAkC;IAClC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;CACd;AAYD,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,qBAAqB,GAAG,IAAI,CAuBjF;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;CACd;AAID,8DAA8D;AAC9D,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI,CAIjE"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Telegram Webhook Parser
|
|
3
|
+
*
|
|
4
|
+
* Converts a raw Telegram `Update` object (posted to our webhook ingress URL)
|
|
5
|
+
* into a domain-level ChatMessage that the messaging service can dispatch.
|
|
6
|
+
*
|
|
7
|
+
* Reference: https://core.telegram.org/bots/api#update
|
|
8
|
+
*
|
|
9
|
+
* We only care about the `message` variant for now — inline queries,
|
|
10
|
+
* callback queries, edited messages, and channel posts are all ignored and
|
|
11
|
+
* return `null`, which causes the tunnel adapter to reply 200 without
|
|
12
|
+
* further side effects.
|
|
13
|
+
*/
|
|
14
|
+
export function parseTelegramUpdate(rawBody) {
|
|
15
|
+
if (!rawBody)
|
|
16
|
+
return null;
|
|
17
|
+
let update;
|
|
18
|
+
try {
|
|
19
|
+
update = JSON.parse(rawBody);
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
const message = update.message;
|
|
25
|
+
if (!message)
|
|
26
|
+
return null;
|
|
27
|
+
const chatId = message.chat?.id !== undefined ? String(message.chat.id) : undefined;
|
|
28
|
+
const text = typeof message.text === 'string' ? message.text : '';
|
|
29
|
+
if (!chatId || !text)
|
|
30
|
+
return null;
|
|
31
|
+
return {
|
|
32
|
+
chatId,
|
|
33
|
+
senderId: message.from?.id !== undefined ? String(message.from.id) : undefined,
|
|
34
|
+
senderUsername: message.from?.username,
|
|
35
|
+
text,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
const PAIR_REGEX = /^\/pair(?:@\w+)?\s+(\d{6})\b/;
|
|
39
|
+
/** Match `/pair 123456` (with optional `@botname` suffix). */
|
|
40
|
+
export function parsePairCommand(text) {
|
|
41
|
+
const match = text.trim().match(PAIR_REGEX);
|
|
42
|
+
if (!match)
|
|
43
|
+
return null;
|
|
44
|
+
return { code: match[1] };
|
|
45
|
+
}
|