@agent-native/core 0.95.0 → 0.96.0
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/corpus/README.md +2 -2
- package/corpus/core/CHANGELOG.md +35 -0
- package/corpus/core/docs/content/locales/ar-SA/template-design.mdx +13 -0
- package/corpus/core/docs/content/locales/de-DE/template-design.mdx +18 -0
- package/corpus/core/docs/content/locales/es-ES/template-design.mdx +16 -0
- package/corpus/core/docs/content/locales/fr-FR/template-design.mdx +17 -0
- package/corpus/core/docs/content/locales/hi-IN/template-design.mdx +16 -0
- package/corpus/core/docs/content/locales/ja-JP/template-design.mdx +17 -0
- package/corpus/core/docs/content/locales/ko-KR/template-design.mdx +15 -0
- package/corpus/core/docs/content/locales/pt-BR/template-design.mdx +16 -0
- package/corpus/core/docs/content/locales/zh-CN/template-design.mdx +11 -0
- package/corpus/core/docs/content/locales/zh-TW/template-design.mdx +12 -0
- package/corpus/core/docs/content/template-design.mdx +16 -0
- package/corpus/core/package.json +4 -2
- package/corpus/core/src/a2a/client.ts +11 -1
- package/corpus/core/src/agent/production-agent.ts +107 -27
- package/corpus/core/src/agent/thread-data-builder.ts +48 -22
- package/corpus/core/src/chat-threads/store.ts +20 -1
- package/corpus/core/src/cli/code-agent-executor.ts +1 -0
- package/corpus/core/src/cli/code-agent-runs.ts +14 -0
- package/corpus/core/src/client/AgentPanel.tsx +32 -25
- package/corpus/core/src/client/AssistantChat.tsx +286 -45
- package/corpus/core/src/client/MultiTabAssistantChat.tsx +141 -90
- package/corpus/core/src/client/chat/ChatHistoryList.tsx +404 -0
- package/corpus/core/src/client/chat/index.ts +6 -0
- package/corpus/core/src/client/chat/tool-call-display.tsx +38 -4
- package/corpus/core/src/client/chat/use-reconnect-reader-owner.ts +28 -0
- package/corpus/core/src/client/code-agent-chat-adapter.ts +72 -4
- package/corpus/core/src/client/composer/RealtimeVoiceMode.tsx +52 -11
- package/corpus/core/src/client/composer/TiptapComposer.tsx +157 -20
- package/corpus/core/src/client/composer/VoiceButton.tsx +28 -0
- package/corpus/core/src/client/composer/useRealtimeVoiceMode.tsx +5 -0
- package/corpus/core/src/client/conversation/code-agent-transcript.ts +4 -5
- package/corpus/core/src/client/guided-questions.tsx +11 -2
- package/corpus/core/src/client/index.ts +11 -0
- package/corpus/core/src/client/integrations/IntegrationsPanel.tsx +6 -7
- package/corpus/core/src/client/sse-event-processor.ts +90 -21
- package/corpus/core/src/client/use-chat-threads.ts +10 -1
- package/corpus/core/src/client/voice-provider-status.ts +44 -0
- package/corpus/core/src/code-agents/transcript-normalizer.ts +76 -0
- package/corpus/core/src/connections/catalog.ts +2 -2
- package/corpus/core/src/deploy/build.ts +12 -8
- package/corpus/core/src/integrations/a2a-continuation-processor.ts +35 -5
- package/corpus/core/src/integrations/adapters/slack.ts +74 -21
- package/corpus/core/src/integrations/catalog.ts +2 -2
- package/corpus/core/src/integrations/webhook-handler.ts +14 -0
- package/corpus/core/src/localization/default-messages.ts +6 -0
- package/corpus/core/src/observability/hosted-model-experiment.ts +118 -0
- package/corpus/core/src/observability/routes.ts +17 -0
- package/corpus/core/src/observability/store.ts +4 -1
- package/corpus/core/src/observability/traces.ts +41 -2
- package/corpus/core/src/scripts/agent-engines/list-agent-engines.ts +19 -1
- package/corpus/core/src/scripts/call-agent.ts +53 -3
- package/corpus/core/src/scripts/chat/search-chats.ts +11 -8
- package/corpus/core/src/secrets/register-framework-secrets.ts +1 -1
- package/corpus/core/src/server/agent-chat-plugin.ts +41 -6
- package/corpus/core/src/server/auth.ts +1 -1
- package/corpus/core/src/server/core-routes-plugin.ts +15 -0
- package/corpus/core/src/server/credential-provider.ts +7 -3
- package/corpus/core/src/server/realtime-voice.ts +71 -24
- package/corpus/core/src/server/voice-providers-status.ts +4 -3
- package/corpus/core/src/shared/cache-control.ts +4 -4
- package/corpus/core/src/styles/agent-native.css +1 -0
- package/corpus/core/src/styles/chat-history-list.css +313 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/observability/SKILL.md +20 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/voice-transcription/SKILL.md +8 -4
- package/corpus/core/src/vite/client.ts +1 -0
- package/corpus/templates/analytics/AGENTS.md +7 -0
- package/corpus/templates/analytics/actions/bigquery.ts +26 -2
- package/corpus/templates/analytics/actions/data-source-status.ts +18 -0
- package/corpus/templates/analytics/app/components/layout/Sidebar.tsx +5 -4
- package/corpus/templates/analytics/app/global.css +10 -0
- package/corpus/templates/analytics/app/lib/data-sources.ts +5 -4
- package/corpus/templates/analytics/app/pages/Ask.tsx +25 -2
- package/corpus/templates/analytics/changelog/2026-07-10-analytics-answers-simple-time-bounded-metrics-without-unnece.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-10-analytics-chat-reliably-uses-connected-data-sources-across-s.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-10-chat-threads-now-stay-clear-of-top-actions-and-fade-smoothly.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-10-context-chips-can-now-be-selected-and-removed-one-at-a-time-.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-10-slack-token-setup-marked-legacy.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-10-the-ask-composer-no-longer-carries-dashboard-or-panel-contex.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-10-the-ask-section-stays-highlighted-while-its-chat-history-is-.md +6 -0
- package/corpus/templates/analytics/server/lib/bigquery.ts +90 -14
- package/corpus/templates/analytics/server/lib/credential-keys.ts +6 -2
- package/corpus/templates/analytics/server/plugins/agent-chat.ts +82 -7
- package/corpus/templates/brain/changelog/2026-07-10-slack-backfill-token-marked-legacy.md +6 -0
- package/corpus/templates/brain/server/register-secrets.ts +2 -2
- package/corpus/templates/clips/app/components/library/library-layout.tsx +7 -1
- package/corpus/templates/clips/app/components/library/page-header.tsx +19 -3
- package/corpus/templates/clips/app/routes/_app.library._index.tsx +16 -12
- package/corpus/templates/clips/changelog/2026-07-10-new-recording-appears-once-when-the-library-sidebar-is-open.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-10-slack-token-fallback-guidance.md +6 -0
- package/corpus/templates/clips/server/register-secrets.ts +1 -1
- package/corpus/templates/content/app/components/editor/DocumentEditor.tsx +0 -66
- package/corpus/templates/content/app/routes/_app.local-files.tsx +7 -47
- package/corpus/templates/content/changelog/2026-07-10-local-folders-now-wait-for-an-explicit-pull-before-content-r.md +6 -0
- package/corpus/templates/content/package.json +1 -1
- package/corpus/templates/design/actions/generate-design.ts +128 -31
- package/corpus/templates/design/actions/present-design-variants.ts +37 -9
- package/corpus/templates/design/app/components/design/DesignCanvas.tsx +9 -3
- package/corpus/templates/design/app/components/design/MultiScreenCanvas.tsx +32 -10
- package/corpus/templates/design/app/components/design/QuestionFlow.tsx +2 -2
- package/corpus/templates/design/app/components/design/TweaksPanel.tsx +9 -1
- package/corpus/templates/design/app/components/design/bridge/editor-chrome.bridge.ts +7 -5
- package/corpus/templates/design/app/components/design/multi-screen/types.ts +3 -0
- package/corpus/templates/design/app/global.css +10 -0
- package/corpus/templates/design/app/hooks/use-question-flow.ts +9 -2
- package/corpus/templates/design/app/i18n/zh-TW.ts +1 -0
- package/corpus/templates/design/app/i18n-data.ts +21 -11
- package/corpus/templates/design/changelog/2026-07-10-editor-panels-are-easier-to-distinguish-and-design-intake-qu.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-interact-mode-now-stays-on-the-full-canvas-matches-edit-visu.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-new-web-designs-open-at-desktop-size-and-adapt-across-mobile.md +6 -0
- package/corpus/templates/design/changelog/2026-07-10-tweaks-now-link-to-full-documentation.md +6 -0
- package/corpus/templates/design/server/plugins/agent-chat.ts +2 -0
- package/corpus/templates/mail/app/i18n/ar-SA.ts +3 -3
- package/corpus/templates/mail/app/i18n/de-DE.ts +3 -3
- package/corpus/templates/mail/app/i18n/en-US.ts +4 -3
- package/corpus/templates/mail/app/i18n/es-ES.ts +3 -3
- package/corpus/templates/mail/app/i18n/fr-FR.ts +3 -3
- package/corpus/templates/mail/app/i18n/hi-IN.ts +3 -3
- package/corpus/templates/mail/app/i18n/ja-JP.ts +3 -3
- package/corpus/templates/mail/app/i18n/ko-KR.ts +3 -3
- package/corpus/templates/mail/app/i18n/pt-BR.ts +3 -3
- package/corpus/templates/mail/app/i18n/zh-CN.ts +3 -3
- package/corpus/templates/mail/app/i18n/zh-TW.ts +3 -3
- package/corpus/templates/mail/changelog/2026-07-10-slack-intake-marked-legacy.md +6 -0
- package/corpus/templates/mail/server/lib/env-config.ts +5 -4
- package/corpus/templates/plan/package.json +1 -1
- package/dist/a2a/client.d.ts +7 -0
- package/dist/a2a/client.d.ts.map +1 -1
- package/dist/a2a/client.js +2 -1
- package/dist/a2a/client.js.map +1 -1
- package/dist/agent/production-agent.d.ts +6 -0
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +83 -26
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/agent/thread-data-builder.d.ts +1 -0
- package/dist/agent/thread-data-builder.d.ts.map +1 -1
- package/dist/agent/thread-data-builder.js +42 -23
- package/dist/agent/thread-data-builder.js.map +1 -1
- package/dist/chat-threads/store.d.ts +10 -0
- package/dist/chat-threads/store.d.ts.map +1 -1
- package/dist/chat-threads/store.js +6 -0
- package/dist/chat-threads/store.js.map +1 -1
- package/dist/cli/code-agent-executor.d.ts.map +1 -1
- package/dist/cli/code-agent-executor.js +1 -0
- package/dist/cli/code-agent-executor.js.map +1 -1
- package/dist/cli/code-agent-runs.d.ts +12 -0
- package/dist/cli/code-agent-runs.d.ts.map +1 -1
- package/dist/cli/code-agent-runs.js +1 -0
- package/dist/cli/code-agent-runs.js.map +1 -1
- package/dist/client/AgentPanel.d.ts.map +1 -1
- package/dist/client/AgentPanel.js +3 -3
- package/dist/client/AgentPanel.js.map +1 -1
- package/dist/client/AssistantChat.d.ts +14 -1
- package/dist/client/AssistantChat.d.ts.map +1 -1
- package/dist/client/AssistantChat.js +207 -32
- package/dist/client/AssistantChat.js.map +1 -1
- package/dist/client/MultiTabAssistantChat.d.ts.map +1 -1
- package/dist/client/MultiTabAssistantChat.js +83 -10
- package/dist/client/MultiTabAssistantChat.js.map +1 -1
- package/dist/client/chat/ChatHistoryList.d.ts +88 -0
- package/dist/client/chat/ChatHistoryList.d.ts.map +1 -0
- package/dist/client/chat/ChatHistoryList.js +83 -0
- package/dist/client/chat/ChatHistoryList.js.map +1 -0
- package/dist/client/chat/index.d.ts +1 -0
- package/dist/client/chat/index.d.ts.map +1 -1
- package/dist/client/chat/index.js +1 -0
- package/dist/client/chat/index.js.map +1 -1
- package/dist/client/chat/tool-call-display.d.ts +13 -1
- package/dist/client/chat/tool-call-display.d.ts.map +1 -1
- package/dist/client/chat/tool-call-display.js +11 -3
- package/dist/client/chat/tool-call-display.js.map +1 -1
- package/dist/client/chat/use-reconnect-reader-owner.d.ts +11 -0
- package/dist/client/chat/use-reconnect-reader-owner.d.ts.map +1 -0
- package/dist/client/chat/use-reconnect-reader-owner.js +21 -0
- package/dist/client/chat/use-reconnect-reader-owner.js.map +1 -0
- package/dist/client/code-agent-chat-adapter.d.ts +17 -1
- package/dist/client/code-agent-chat-adapter.d.ts.map +1 -1
- package/dist/client/code-agent-chat-adapter.js +47 -3
- package/dist/client/code-agent-chat-adapter.js.map +1 -1
- package/dist/client/composer/RealtimeVoiceMode.d.ts +11 -1
- package/dist/client/composer/RealtimeVoiceMode.d.ts.map +1 -1
- package/dist/client/composer/RealtimeVoiceMode.js +5 -3
- package/dist/client/composer/RealtimeVoiceMode.js.map +1 -1
- package/dist/client/composer/TiptapComposer.d.ts +25 -2
- package/dist/client/composer/TiptapComposer.d.ts.map +1 -1
- package/dist/client/composer/TiptapComposer.js +96 -5
- package/dist/client/composer/TiptapComposer.js.map +1 -1
- package/dist/client/composer/VoiceButton.d.ts.map +1 -1
- package/dist/client/composer/VoiceButton.js +21 -1
- package/dist/client/composer/VoiceButton.js.map +1 -1
- package/dist/client/composer/useRealtimeVoiceMode.d.ts.map +1 -1
- package/dist/client/composer/useRealtimeVoiceMode.js +5 -0
- package/dist/client/composer/useRealtimeVoiceMode.js.map +1 -1
- package/dist/client/conversation/code-agent-transcript.d.ts +2 -0
- package/dist/client/conversation/code-agent-transcript.d.ts.map +1 -1
- package/dist/client/conversation/code-agent-transcript.js +3 -5
- package/dist/client/conversation/code-agent-transcript.js.map +1 -1
- package/dist/client/guided-questions.d.ts.map +1 -1
- package/dist/client/guided-questions.js +7 -2
- package/dist/client/guided-questions.js.map +1 -1
- package/dist/client/index.d.ts +3 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +3 -1
- package/dist/client/index.js.map +1 -1
- package/dist/client/integrations/IntegrationsPanel.d.ts.map +1 -1
- package/dist/client/integrations/IntegrationsPanel.js +5 -7
- package/dist/client/integrations/IntegrationsPanel.js.map +1 -1
- package/dist/client/sse-event-processor.d.ts.map +1 -1
- package/dist/client/sse-event-processor.js +67 -20
- package/dist/client/sse-event-processor.js.map +1 -1
- package/dist/client/use-chat-threads.d.ts.map +1 -1
- package/dist/client/use-chat-threads.js +9 -1
- package/dist/client/use-chat-threads.js.map +1 -1
- package/dist/client/voice-provider-status.d.ts +10 -0
- package/dist/client/voice-provider-status.d.ts.map +1 -0
- package/dist/client/voice-provider-status.js +32 -0
- package/dist/client/voice-provider-status.js.map +1 -0
- package/dist/code-agents/transcript-normalizer.d.ts +29 -0
- package/dist/code-agents/transcript-normalizer.d.ts.map +1 -1
- package/dist/code-agents/transcript-normalizer.js +55 -0
- package/dist/code-agents/transcript-normalizer.js.map +1 -1
- package/dist/collab/struct-routes.d.ts +1 -1
- package/dist/connections/catalog.d.ts +2 -2
- package/dist/connections/catalog.js +2 -2
- package/dist/connections/catalog.js.map +1 -1
- package/dist/deploy/build.d.ts.map +1 -1
- package/dist/deploy/build.js +12 -8
- package/dist/deploy/build.js.map +1 -1
- package/dist/integrations/a2a-continuation-processor.d.ts.map +1 -1
- package/dist/integrations/a2a-continuation-processor.js +25 -5
- package/dist/integrations/a2a-continuation-processor.js.map +1 -1
- package/dist/integrations/adapters/slack.d.ts.map +1 -1
- package/dist/integrations/adapters/slack.js +55 -21
- package/dist/integrations/adapters/slack.js.map +1 -1
- package/dist/integrations/catalog.js +2 -2
- package/dist/integrations/catalog.js.map +1 -1
- package/dist/integrations/webhook-handler.d.ts.map +1 -1
- package/dist/integrations/webhook-handler.js +11 -0
- package/dist/integrations/webhook-handler.js.map +1 -1
- package/dist/localization/default-messages.d.ts +5 -0
- package/dist/localization/default-messages.d.ts.map +1 -1
- package/dist/localization/default-messages.js +5 -0
- package/dist/localization/default-messages.js.map +1 -1
- package/dist/observability/hosted-model-experiment.d.ts +39 -0
- package/dist/observability/hosted-model-experiment.d.ts.map +1 -0
- package/dist/observability/hosted-model-experiment.js +90 -0
- package/dist/observability/hosted-model-experiment.js.map +1 -0
- package/dist/observability/routes.d.ts.map +1 -1
- package/dist/observability/routes.js +16 -0
- package/dist/observability/routes.js.map +1 -1
- package/dist/observability/store.d.ts.map +1 -1
- package/dist/observability/store.js +4 -1
- package/dist/observability/store.js.map +1 -1
- package/dist/observability/traces.d.ts +6 -0
- package/dist/observability/traces.d.ts.map +1 -1
- package/dist/observability/traces.js +28 -2
- package/dist/observability/traces.js.map +1 -1
- package/dist/provider-api/corpus-jobs.d.ts +2 -2
- package/dist/scripts/agent-engines/list-agent-engines.d.ts.map +1 -1
- package/dist/scripts/agent-engines/list-agent-engines.js +19 -1
- package/dist/scripts/agent-engines/list-agent-engines.js.map +1 -1
- package/dist/scripts/call-agent.d.ts.map +1 -1
- package/dist/scripts/call-agent.js +43 -3
- package/dist/scripts/call-agent.js.map +1 -1
- package/dist/scripts/chat/search-chats.d.ts +1 -1
- package/dist/scripts/chat/search-chats.d.ts.map +1 -1
- package/dist/scripts/chat/search-chats.js +11 -8
- package/dist/scripts/chat/search-chats.js.map +1 -1
- package/dist/secrets/register-framework-secrets.js +1 -1
- package/dist/secrets/register-framework-secrets.js.map +1 -1
- package/dist/server/agent-chat-plugin.d.ts +11 -0
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +27 -6
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/server/auth.js +1 -1
- package/dist/server/auth.js.map +1 -1
- package/dist/server/core-routes-plugin.d.ts +3 -0
- package/dist/server/core-routes-plugin.d.ts.map +1 -1
- package/dist/server/core-routes-plugin.js +13 -0
- package/dist/server/core-routes-plugin.js.map +1 -1
- package/dist/server/credential-provider.d.ts +5 -3
- package/dist/server/credential-provider.d.ts.map +1 -1
- package/dist/server/credential-provider.js +7 -3
- package/dist/server/credential-provider.js.map +1 -1
- package/dist/server/realtime-voice.d.ts.map +1 -1
- package/dist/server/realtime-voice.js +55 -21
- package/dist/server/realtime-voice.js.map +1 -1
- package/dist/server/voice-providers-status.d.ts.map +1 -1
- package/dist/server/voice-providers-status.js +2 -3
- package/dist/server/voice-providers-status.js.map +1 -1
- package/dist/shared/cache-control.d.ts +6 -6
- package/dist/shared/cache-control.d.ts.map +1 -1
- package/dist/shared/cache-control.js +3 -3
- package/dist/shared/cache-control.js.map +1 -1
- package/dist/styles/agent-native.css +1 -0
- package/dist/styles/chat-history-list.css +313 -0
- package/dist/templates/workspace-core/.agents/skills/observability/SKILL.md +20 -0
- package/dist/templates/workspace-core/.agents/skills/voice-transcription/SKILL.md +8 -4
- package/dist/vite/client.d.ts.map +1 -1
- package/dist/vite/client.js +1 -0
- package/dist/vite/client.js.map +1 -1
- package/docs/content/locales/ar-SA/template-design.mdx +13 -0
- package/docs/content/locales/de-DE/template-design.mdx +18 -0
- package/docs/content/locales/es-ES/template-design.mdx +16 -0
- package/docs/content/locales/fr-FR/template-design.mdx +17 -0
- package/docs/content/locales/hi-IN/template-design.mdx +16 -0
- package/docs/content/locales/ja-JP/template-design.mdx +17 -0
- package/docs/content/locales/ko-KR/template-design.mdx +15 -0
- package/docs/content/locales/pt-BR/template-design.mdx +16 -0
- package/docs/content/locales/zh-CN/template-design.mdx +11 -0
- package/docs/content/locales/zh-TW/template-design.mdx +12 -0
- package/docs/content/template-design.mdx +16 -0
- package/package.json +4 -2
- package/src/templates/workspace-core/.agents/skills/observability/SKILL.md +20 -0
- package/src/templates/workspace-core/.agents/skills/voice-transcription/SKILL.md +8 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"a2a-continuation-processor.d.ts","sourceRoot":"","sources":["../../src/integrations/a2a-continuation-processor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"a2a-continuation-processor.d.ts","sourceRoot":"","sources":["../../src/integrations/a2a-continuation-processor.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAEV,eAAe,EAEhB,MAAM,YAAY,CAAC;AAkBpB,wBAAsB,uBAAuB,CAC3C,cAAc,EAAE,MAAM,EACtB,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,IAAI,CAAC,CAqDf;AAmBD,wBAAsB,0BAA0B,CAC9C,cAAc,EAAE,MAAM,EACtB,OAAO,EAAE;IAAE,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;CAAE,GAClD,OAAO,CAAC,IAAI,CAAC,CAMf;AAED,wBAAsB,0BAA0B,CAAC,OAAO,EAAE;IACxD,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CAAC,IAAI,CAAC,CAUhB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { appendA2AArtifactLinks } from "../a2a/artifact-response.js";
|
|
2
2
|
import { A2AClient, signA2AToken } from "../a2a/client.js";
|
|
3
|
-
import { formatLlmCredentialErrorMessage, isLlmCredentialError, } from "../agent/engine/credential-errors.js";
|
|
3
|
+
import { formatLlmCredentialErrorMessage, isLlmCredentialError, LLM_MISSING_CREDENTIALS_ERROR_CODE, } from "../agent/engine/credential-errors.js";
|
|
4
4
|
import { withConfiguredAppBasePath } from "../server/app-base-path.js";
|
|
5
5
|
import { FRAMEWORK_ROUTE_PREFIX } from "../server/core-routes-plugin.js";
|
|
6
6
|
import { claimA2AContinuation, claimA2AContinuationDelivery, claimDueA2AContinuations, completeA2AContinuation, failA2AContinuation, getA2AContinuation, rescheduleA2AContinuation, } from "./a2a-continuations-store.js";
|
|
@@ -279,12 +279,32 @@ async function completeAfterSuccessfulDelivery(continuation) {
|
|
|
279
279
|
"but marking it completed failed. Leaving it in delivering for stale-delivery recovery.", lastError);
|
|
280
280
|
}
|
|
281
281
|
function formatContinuationFailureMessage(continuation, reason) {
|
|
282
|
-
|
|
283
|
-
|
|
282
|
+
const explicitCode = extractFailureCode(reason);
|
|
283
|
+
const diagnostics = formatContinuationFailureDiagnostics(continuation, reason);
|
|
284
|
+
if (isLlmCredentialError(reason, explicitCode)) {
|
|
285
|
+
return (formatLlmCredentialErrorMessage({
|
|
284
286
|
agentName: continuation.agentName,
|
|
285
|
-
});
|
|
287
|
+
}) + diagnostics);
|
|
286
288
|
}
|
|
287
|
-
return `The ${continuation.agentName} agent could not finish this request: ${sanitizeFailureReason(reason)}`;
|
|
289
|
+
return `The ${continuation.agentName} agent could not finish this request: ${sanitizeFailureReason(reason)}${diagnostics}`;
|
|
290
|
+
}
|
|
291
|
+
function formatContinuationFailureDiagnostics(continuation, reason) {
|
|
292
|
+
return `\n\nError code: \`${continuationFailureCode(reason)}\`\nRequest ID: \`${continuation.integrationTaskId}\`\nContinuation ID: \`${continuation.id}\`\nDownstream task ID: \`${continuation.a2aTaskId}\``;
|
|
293
|
+
}
|
|
294
|
+
function continuationFailureCode(reason) {
|
|
295
|
+
const explicitCode = extractFailureCode(reason);
|
|
296
|
+
if (explicitCode)
|
|
297
|
+
return explicitCode;
|
|
298
|
+
if (isLlmCredentialError(reason, explicitCode)) {
|
|
299
|
+
return LLM_MISSING_CREDENTIALS_ERROR_CODE;
|
|
300
|
+
}
|
|
301
|
+
if (/\btimed out polling\b/i.test(reason))
|
|
302
|
+
return "a2a_remote_timeout";
|
|
303
|
+
return "a2a_downstream_error";
|
|
304
|
+
}
|
|
305
|
+
function extractFailureCode(reason) {
|
|
306
|
+
const match = /\bcode\s*[:=]\s*[`"']?([a-z][a-z0-9_]{0,79})\b/i.exec(reason);
|
|
307
|
+
return match?.[1]?.toLowerCase() ?? null;
|
|
288
308
|
}
|
|
289
309
|
function isRemoteWorkExpired(continuation) {
|
|
290
310
|
return Date.now() - continuation.createdAt >= MAX_REMOTE_WORK_MS;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"a2a-continuation-processor.js","sourceRoot":"","sources":["../../src/integrations/a2a-continuation-processor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAE3D,OAAO,EACL,+BAA+B,EAC/B,oBAAoB,GACrB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EACL,oBAAoB,EACpB,4BAA4B,EAC5B,wBAAwB,EACxB,uBAAuB,EACvB,mBAAmB,EACnB,kBAAkB,EAClB,yBAAyB,GAE1B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAOxD,MAAM,cAAc,GAAG,GAAG,sBAAsB,wCAAwC,CAAC;AACzF,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC;AACrE,MAAM,YAAY,GAAG,EAAE,CAAC;AACxB,MAAM,kBAAkB,GAAG,EAAE,GAAG,MAAM,CAAC;AACvC,8EAA8E;AAC9E,+EAA+E;AAC/E,mCAAmC;AACnC,MAAM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gBACb,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC,IAAI,GAAG;gBAC1C,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC;QAC9C,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC;QAChB,GAAG,CAAC,IAAI,GAAG,EAAE,CAAC;QACd,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAC3C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACrC,CAAC;AACH,CAAC","sourcesContent":["import { appendA2AArtifactLinks } from \"../a2a/artifact-response.js\";\nimport { A2AClient, signA2AToken } from \"../a2a/client.js\";\nimport type { Task } from \"../a2a/types.js\";\nimport {\n formatLlmCredentialErrorMessage,\n isLlmCredentialError,\n} from \"../agent/engine/credential-errors.js\";\nimport { withConfiguredAppBasePath } from \"../server/app-base-path.js\";\nimport { FRAMEWORK_ROUTE_PREFIX } from \"../server/core-routes-plugin.js\";\nimport {\n claimA2AContinuation,\n claimA2AContinuationDelivery,\n claimDueA2AContinuations,\n completeA2AContinuation,\n failA2AContinuation,\n getA2AContinuation,\n rescheduleA2AContinuation,\n type A2AContinuation,\n} from \"./a2a-continuations-store.js\";\nimport { signInternalToken } from \"./internal-token.js\";\nimport type {\n OutgoingMessage,\n PlatformAdapter,\n PlatformRunProgress,\n} from \"./types.js\";\n\nconst PROCESSOR_PATH = `${FRAMEWORK_ROUTE_PREFIX}/integrations/process-a2a-continuation`;\nconst TERMINAL_STATES = new Set([\"completed\", \"failed\", \"canceled\"]);\nconst MAX_ATTEMPTS = 30;\nconst MAX_REMOTE_WORK_MS = 20 * 60_000;\n// Re-dispatch continuations after a short delay. Serverless hosts do not keep\n// in-memory interval sweepers alive between requests, so delayed self-dispatch\n// is the portable retry mechanism.\nconst RESCHEDULE_DELAY_MS = 20_000;\nconst MAX_PRE_CLAIM_WAIT_MS = 25_000;\nconst POLL_INTERVAL_MS = 2_000;\nconst PROCESSOR_WAIT_MS = 10_000;\nconst POLL_REQUEST_TIMEOUT_MS = 8_000;\nconst PLATFORM_SEND_TIMEOUT_MS = 12_000;\nconst DISPATCH_SETTLE_WAIT_MS = 2_000;\nconst COMPLETE_AFTER_DELIVERY_ATTEMPTS = 3;\n\nexport async function dispatchA2AContinuation(\n continuationId: string,\n webhookBaseUrl?: string,\n): Promise<void> {\n const baseUrl =\n webhookBaseUrl ||\n process.env.WEBHOOK_BASE_URL ||\n process.env.APP_URL ||\n process.env.URL ||\n process.env.DEPLOY_URL ||\n `http://localhost:${process.env.PORT || 3000}`;\n\n const url = `${withConfiguredAppBasePath(baseUrl)}${PROCESSOR_PATH}`;\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n };\n try {\n headers[\"Authorization\"] = `Bearer ${signInternalToken(continuationId)}`;\n } catch (err) {\n if (process.env.NODE_ENV === \"production\") {\n console.error(\n `[integrations] Refusing to dispatch A2A continuation ${continuationId} — A2A_SECRET not configured.`,\n );\n return;\n }\n if (err instanceof Error && !/A2A_SECRET/i.test(err.message)) {\n console.error(\n `[integrations] signInternalToken failed unexpectedly for ${continuationId}:`,\n err,\n );\n }\n }\n\n const dispatchPromise = fetch(url, {\n method: \"POST\",\n headers,\n body: JSON.stringify({ continuationId }),\n })\n .then(async (response) => {\n if (!response.ok) {\n await logFailedDispatchResponse(continuationId, response);\n }\n })\n .catch((err) => {\n console.error(\n `[integrations] Failed to dispatch A2A continuation ${continuationId}:`,\n err,\n );\n });\n\n await Promise.race([\n dispatchPromise,\n new Promise<void>((resolve) =>\n setTimeout(resolve, DISPATCH_SETTLE_WAIT_MS),\n ),\n ]);\n}\n\nasync function logFailedDispatchResponse(\n continuationId: string,\n response: Response,\n): Promise<void> {\n let body = \"\";\n try {\n body = await response.text();\n } catch {}\n\n const trimmedBody = body.trim();\n console.error(\n `[integrations] A2A continuation ${continuationId} processor dispatch returned HTTP ` +\n `${response.status}${response.statusText ? ` ${response.statusText}` : \"\"}` +\n `${trimmedBody ? `: ${trimmedBody.slice(0, 500)}` : \"\"}`,\n );\n}\n\nexport async function processA2AContinuationById(\n continuationId: string,\n options: { adapters: Map<string, PlatformAdapter> },\n): Promise<void> {\n const shouldClaim = await waitForContinuationDue(continuationId);\n if (!shouldClaim) return;\n const continuation = await claimA2AContinuation(continuationId);\n if (!continuation) return;\n await processClaimedContinuation(continuation, options);\n}\n\nexport async function processDueA2AContinuations(options: {\n adapters: Map<string, PlatformAdapter>;\n limit?: number;\n}): Promise<void> {\n const continuations = await claimDueA2AContinuations(options.limit ?? 5);\n for (const continuation of continuations) {\n await processClaimedContinuation(continuation, options).catch((err) =>\n console.error(\n `[integrations] A2A continuation ${continuation.id} failed:`,\n err,\n ),\n );\n }\n}\n\nasync function processClaimedContinuation(\n continuation: A2AContinuation,\n options: { adapters: Map<string, PlatformAdapter> },\n): Promise<void> {\n const adapter = options.adapters.get(continuation.platform);\n if (!adapter) {\n await failA2AContinuation(\n continuation.id,\n `Unknown platform: ${continuation.platform}`,\n );\n return;\n }\n\n const progress = await resumeA2AContinuationProgress(continuation, adapter);\n\n const auth = await signContinuationToken(continuation);\n const client = new A2AClient(continuation.agentUrl, auth.apiKey, {\n requestTimeoutMs: POLL_REQUEST_TIMEOUT_MS,\n ...(auth.apiKeyFallbacks ? { fallbackApiKeys: auth.apiKeyFallbacks } : {}),\n });\n const deadline = Date.now() + PROCESSOR_WAIT_MS;\n let task: Task | null = null;\n\n try {\n while (Date.now() < deadline) {\n task = await client.getTask(continuation.a2aTaskId);\n if (TERMINAL_STATES.has(task.status.state)) break;\n await reportA2AContinuationProgress(continuation, progress, task);\n await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL_MS));\n }\n } catch (err) {\n if (isTransientA2APollError(err)) {\n if (shouldStopPollingRemoteTask(continuation)) {\n await notifyAndFailA2AContinuation(\n continuation,\n adapter,\n remotePollFailureReason(continuation),\n progress,\n );\n return;\n }\n await rescheduleAndRedispatchA2AContinuation(continuation.id);\n return;\n }\n if (continuation.attempts >= MAX_ATTEMPTS) {\n await notifyAndFailA2AContinuation(\n continuation,\n adapter,\n err instanceof Error ? err.message : String(err),\n progress,\n );\n return;\n }\n await rescheduleAndRedispatchA2AContinuation(continuation.id);\n return;\n }\n\n if (!task || !TERMINAL_STATES.has(task.status.state)) {\n if (shouldStopPollingRemoteTask(continuation)) {\n await notifyAndFailA2AContinuation(\n continuation,\n adapter,\n remotePollFailureReason(continuation),\n progress,\n );\n return;\n }\n await rescheduleAndRedispatchA2AContinuation(continuation.id);\n return;\n }\n\n if (task.status.state !== \"completed\") {\n const reason =\n extractTaskText(task) ||\n `Remote A2A task ${continuation.a2aTaskId} ended with state ${task.status.state}`;\n await notifyAndFailA2AContinuation(continuation, adapter, reason, progress);\n return;\n }\n\n const text = formatContinuationArtifactText(\n extractTaskText(task),\n continuation.agentUrl,\n );\n if (!text.trim()) {\n await notifyAndFailA2AContinuation(\n continuation,\n adapter,\n `Remote A2A task ${continuation.a2aTaskId} completed without text`,\n progress,\n );\n return;\n }\n\n await deliverAndCompleteA2AContinuation(\n continuation,\n adapter,\n text,\n progress,\n );\n}\n\nasync function resumeA2AContinuationProgress(\n continuation: A2AContinuation,\n adapter: PlatformAdapter,\n): Promise<PlatformRunProgress | null> {\n if (!continuation.progressRef || !adapter.resumeRunProgress) return null;\n try {\n const progress = await adapter.resumeRunProgress(\n continuation.incoming,\n continuation.progressRef,\n );\n if (!progress) return null;\n await progress.onEvent({\n type: \"agent_call_progress\",\n agent: continuation.agentName,\n state: \"working\",\n elapsedSeconds: Math.max(\n 0,\n Math.round((Date.now() - continuation.createdAt) / 1_000),\n ),\n detail: \"Continuing in the background\",\n });\n return progress;\n } catch {\n // A continuation still has a normal reply fallback. Do not log the\n // opaque provider reference or the inbound message payload.\n return null;\n }\n}\n\nasync function reportA2AContinuationProgress(\n continuation: A2AContinuation,\n progress: PlatformRunProgress | null,\n task: Task,\n): Promise<void> {\n if (!progress) return;\n await progress.onEvent({\n type: \"agent_call_progress\",\n agent: continuation.agentName,\n state: task.status.state,\n elapsedSeconds: Math.max(\n 0,\n Math.round((Date.now() - continuation.createdAt) / 1_000),\n ),\n detail: \"Still working on the delegated request\",\n });\n}\n\nasync function waitForContinuationDue(\n continuationId: string,\n): Promise<boolean> {\n const continuation = await getA2AContinuation(continuationId);\n if (!continuation) return false;\n if (continuation.status === \"completed\" || continuation.status === \"failed\") {\n return false;\n }\n if (continuation.status !== \"pending\") return true;\n\n const waitMs = continuation.nextCheckAt - Date.now();\n if (waitMs <= 0) return true;\n\n if (waitMs > MAX_PRE_CLAIM_WAIT_MS) return false;\n\n await sleep(waitMs);\n return true;\n}\n\nasync function notifyAndFailA2AContinuation(\n continuation: A2AContinuation,\n adapter: PlatformAdapter,\n reason: string,\n progress: PlatformRunProgress | null = null,\n): Promise<void> {\n const deliveryContinuation = await claimA2AContinuationDelivery(\n continuation.id,\n );\n if (!deliveryContinuation) return;\n\n const message = formatContinuationFailureMessage(\n deliveryContinuation,\n reason,\n );\n try {\n const outgoing = adapter.formatAgentResponse(message);\n await withTimeout(\n deliverA2AContinuationResponse(\n adapter,\n deliveryContinuation,\n outgoing,\n progress,\n \"error\",\n ),\n PLATFORM_SEND_TIMEOUT_MS,\n `${deliveryContinuation.platform} failure notification timed out`,\n );\n } catch (err) {\n console.error(\n `[integrations] Failed to notify ${deliveryContinuation.platform} about failed A2A continuation ${deliveryContinuation.id}:`,\n err,\n );\n }\n\n await failA2AContinuation(deliveryContinuation.id, reason);\n}\n\nasync function deliverAndCompleteA2AContinuation(\n continuation: A2AContinuation,\n adapter: PlatformAdapter,\n text: string,\n progress: PlatformRunProgress | null = null,\n): Promise<void> {\n const deliveryContinuation = await claimA2AContinuationDelivery(\n continuation.id,\n );\n if (!deliveryContinuation) return;\n\n try {\n const outgoing = adapter.formatAgentResponse(text);\n await withTimeout(\n deliverA2AContinuationResponse(\n adapter,\n deliveryContinuation,\n outgoing,\n progress,\n \"done\",\n ),\n PLATFORM_SEND_TIMEOUT_MS,\n `${deliveryContinuation.platform} response delivery timed out`,\n );\n } catch (err) {\n if (deliveryContinuation.attempts >= MAX_ATTEMPTS) {\n await failA2AContinuation(\n deliveryContinuation.id,\n err instanceof Error ? err.message : String(err),\n );\n return;\n }\n await rescheduleAndRedispatchA2AContinuation(deliveryContinuation.id);\n return;\n }\n\n await completeAfterSuccessfulDelivery(deliveryContinuation);\n}\n\nasync function deliverA2AContinuationResponse(\n adapter: PlatformAdapter,\n continuation: A2AContinuation,\n message: OutgoingMessage,\n progress: PlatformRunProgress | null,\n status: \"done\" | \"error\",\n): Promise<void> {\n if (progress) {\n try {\n await progress.onEvent({\n type: \"agent_call\",\n agent: continuation.agentName,\n status,\n });\n await progress.complete(message);\n return;\n } catch {\n // A resumed Slack stream can no longer be finalized (for example when\n // chat.stopStream rejects). Preserve the final answer with the same\n // thread reply fallback used by the initial webhook run. Also ask the\n // adapter to terminate the native stream: otherwise Slack can keep the\n // task card in its working state after the thread fallback succeeds.\n try {\n await progress.fail?.(\n \"I couldn't update the live response, but I posted the final result in this thread.\",\n );\n } catch {\n // The thread reply below is still the authoritative final answer.\n }\n }\n }\n await adapter.sendResponse(message, continuation.incoming, {\n placeholderRef: continuation.placeholderRef ?? undefined,\n });\n}\n\nasync function rescheduleAndRedispatchA2AContinuation(\n continuationId: string,\n): Promise<void> {\n await rescheduleA2AContinuation(continuationId, RESCHEDULE_DELAY_MS);\n await dispatchA2AContinuation(continuationId).catch((err) => {\n console.error(\n `[integrations] Failed to redispatch A2A continuation ${continuationId}:`,\n err,\n );\n });\n}\n\nasync function completeAfterSuccessfulDelivery(\n continuation: A2AContinuation,\n): Promise<void> {\n let lastError: unknown;\n for (let attempt = 0; attempt < COMPLETE_AFTER_DELIVERY_ATTEMPTS; attempt++) {\n try {\n await completeA2AContinuation(continuation.id);\n return;\n } catch (err) {\n lastError = err;\n }\n }\n\n console.error(\n `[integrations] ${continuation.platform} accepted A2A continuation ${continuation.id}, ` +\n \"but marking it completed failed. Leaving it in delivering for stale-delivery recovery.\",\n lastError,\n );\n}\n\nfunction formatContinuationFailureMessage(\n continuation: A2AContinuation,\n reason: string,\n): string {\n if (isLlmCredentialError(reason)) {\n return formatLlmCredentialErrorMessage({\n agentName: continuation.agentName,\n });\n }\n\n return `The ${continuation.agentName} agent could not finish this request: ${sanitizeFailureReason(\n reason,\n )}`;\n}\n\nfunction isRemoteWorkExpired(continuation: A2AContinuation): boolean {\n return Date.now() - continuation.createdAt >= MAX_REMOTE_WORK_MS;\n}\n\nfunction shouldStopPollingRemoteTask(continuation: A2AContinuation): boolean {\n return (\n continuation.attempts >= MAX_ATTEMPTS || isRemoteWorkExpired(continuation)\n );\n}\n\nfunction isTransientA2APollError(err: unknown): boolean {\n if (!(err instanceof Error)) return false;\n if (err.name === \"AbortError\") return true;\n return /operation was aborted|aborted|timed out|timeout|Invalid or expired A2A token|A2A request failed \\((?:401|508)\\)/i.test(\n err.message,\n );\n}\n\nfunction remotePollFailureReason(continuation: A2AContinuation): string {\n if (isRemoteWorkExpired(continuation)) {\n return `Timed out polling the ${continuation.agentName} A2A task ${continuation.a2aTaskId} after ${Math.round(\n MAX_REMOTE_WORK_MS / 60_000,\n )} minutes. The downstream agent did not return a final result.`;\n }\n\n return `Timed out polling the ${continuation.agentName} A2A task ${continuation.a2aTaskId} after ${MAX_ATTEMPTS} attempts. The downstream agent did not return a final result.`;\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nasync function withTimeout<T>(\n promise: Promise<T>,\n timeoutMs: number,\n message: string,\n): Promise<T> {\n let timer: ReturnType<typeof setTimeout> | undefined;\n try {\n return await Promise.race([\n promise,\n new Promise<never>((_, reject) => {\n timer = setTimeout(() => reject(new Error(message)), timeoutMs);\n }),\n ]);\n } finally {\n if (timer) clearTimeout(timer);\n }\n}\n\nfunction sanitizeFailureReason(reason: string): string {\n const oneLine = reason.replace(/\\s+/g, \" \").trim();\n const withoutEnvNames = oneLine.replace(\n /\\b[A-Z][A-Z0-9_]*(?:API_KEY|PRIVATE_KEY|SECRET|TOKEN)\\b/g,\n \"a required credential\",\n );\n return (\n withoutEnvNames.slice(0, 500) ||\n \"the downstream agent returned an empty error\"\n );\n}\n\nasync function signContinuationToken(\n continuation: A2AContinuation,\n): Promise<{ apiKey?: string; apiKeyFallbacks?: string[] }> {\n if (continuation.a2aAuthToken === \"\") {\n return {};\n }\n\n const storedToken = continuation.a2aAuthToken;\n if (storedToken && !isLikelyJwt(storedToken)) return { apiKey: storedToken };\n\n const freshTokens = await signFreshContinuationTokens(continuation);\n if (freshTokens.length > 0) {\n return {\n apiKey: freshTokens[0],\n ...(freshTokens.length > 1\n ? { apiKeyFallbacks: freshTokens.slice(1) }\n : {}),\n };\n }\n if (!storedToken) return {};\n\n // Older continuations may have persisted the initial short-lived JWT. Avoid\n // replaying it forever after expiry; opaque legacy bearer keys can still be\n // reused because we cannot re-mint those.\n if (isLikelyJwt(storedToken)) return {};\n return { apiKey: storedToken };\n}\n\nasync function signFreshContinuationTokens(\n continuation: A2AContinuation,\n): Promise<string[]> {\n let orgDomain: string | undefined;\n let orgSecret: string | undefined;\n if (continuation.orgId) {\n try {\n const { getOrgDomain, getOrgA2ASecret } =\n await import(\"../org/context.js\");\n orgDomain = (await getOrgDomain(continuation.orgId)) ?? undefined;\n orgSecret = (await getOrgA2ASecret(continuation.orgId)) ?? undefined;\n } catch {}\n }\n\n if (!continuation.ownerEmail || !(orgSecret || process.env.A2A_SECRET)) {\n return [];\n }\n\n const tokens: string[] = [];\n const add = (token: string | undefined) => {\n if (token && !tokens.includes(token)) tokens.push(token);\n };\n\n if (process.env.A2A_SECRET?.trim()) {\n try {\n add(\n await signA2AToken(continuation.ownerEmail, orgDomain, orgSecret, {\n expiresIn: \"30m\",\n preferGlobalSecret: true,\n }),\n );\n } catch {}\n }\n if (orgSecret) {\n try {\n add(\n await signA2AToken(continuation.ownerEmail, orgDomain, orgSecret, {\n expiresIn: \"30m\",\n preferGlobalSecret: false,\n }),\n );\n } catch {}\n }\n return tokens;\n}\n\nfunction isLikelyJwt(token: string): boolean {\n return token.split(\".\").length === 3;\n}\n\nfunction extractTaskText(task: Task): string {\n const parts = task.status.message?.parts ?? [];\n return parts\n .filter((part): part is { type: \"text\"; text: string } => {\n return part.type === \"text\" && typeof part.text === \"string\";\n })\n .map((part) => part.text)\n .join(\"\\n\");\n}\n\nfunction formatContinuationArtifactText(\n text: string,\n agentUrl: string,\n): string {\n const expandedText = expandRelativeUrls(text, agentUrl);\n return appendA2AArtifactLinks(\n expandedText,\n [{ tool: \"call-agent\", result: expandedText }],\n { baseUrl: resolveArtifactBaseUrl() },\n );\n}\n\nfunction resolveArtifactBaseUrl(): string | undefined {\n const baseUrl =\n process.env.APP_URL || process.env.URL || process.env.DEPLOY_URL;\n return baseUrl ? withConfiguredAppBasePath(baseUrl) : undefined;\n}\n\nfunction expandRelativeUrls(text: string, agentUrl: string): string {\n if (!text || !agentUrl) return text;\n const base = publicAgentBaseUrl(agentUrl);\n return text.replace(\n /(^|[\\s([<\"'`])(\\/[a-z0-9_-][a-z0-9_/?&=%#.,:-]*)/gi,\n (_match, lead, path) => `${lead}${base}${path}`,\n );\n}\n\nfunction publicAgentBaseUrl(agentUrl: string): string {\n try {\n const url = new URL(agentUrl);\n const routeIndex = url.pathname.indexOf(FRAMEWORK_ROUTE_PREFIX);\n url.pathname =\n routeIndex >= 0\n ? url.pathname.slice(0, routeIndex) || \"/\"\n : url.pathname.replace(/\\/+$/, \"\") || \"/\";\n url.search = \"\";\n url.hash = \"\";\n return url.toString().replace(/\\/$/, \"\");\n } catch {\n return agentUrl.replace(/\\/$/, \"\");\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"a2a-continuation-processor.js","sourceRoot":"","sources":["../../src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AAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAC;IACpC,MAAM,IAAI,GAAG,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IAC1C,OAAO,IAAI,CAAC,OAAO,CACjB,oDAAoD,EACpD,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,EAAE,CAChD,CAAC;AACJ,CAAC;AAED,SAAS,kBAAkB,CAAC,QAAgB;IAC1C,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC9B,MAAM,UAAU,GAAG,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAC;QAChE,GAAG,CAAC,QAAQ;YACV,UAAU,IAAI,CAAC;gBACb,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC,IAAI,GAAG;gBAC1C,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC;QAC9C,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC;QAChB,GAAG,CAAC,IAAI,GAAG,EAAE,CAAC;QACd,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAC3C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACrC,CAAC;AACH,CAAC","sourcesContent":["import { appendA2AArtifactLinks } from \"../a2a/artifact-response.js\";\nimport { A2AClient, signA2AToken } from \"../a2a/client.js\";\nimport type { Task } from \"../a2a/types.js\";\nimport {\n formatLlmCredentialErrorMessage,\n isLlmCredentialError,\n LLM_MISSING_CREDENTIALS_ERROR_CODE,\n} from \"../agent/engine/credential-errors.js\";\nimport { withConfiguredAppBasePath } from \"../server/app-base-path.js\";\nimport { FRAMEWORK_ROUTE_PREFIX } from \"../server/core-routes-plugin.js\";\nimport {\n claimA2AContinuation,\n claimA2AContinuationDelivery,\n claimDueA2AContinuations,\n completeA2AContinuation,\n failA2AContinuation,\n getA2AContinuation,\n rescheduleA2AContinuation,\n type A2AContinuation,\n} from \"./a2a-continuations-store.js\";\nimport { signInternalToken } from \"./internal-token.js\";\nimport type {\n OutgoingMessage,\n PlatformAdapter,\n PlatformRunProgress,\n} from \"./types.js\";\n\nconst PROCESSOR_PATH = `${FRAMEWORK_ROUTE_PREFIX}/integrations/process-a2a-continuation`;\nconst TERMINAL_STATES = new Set([\"completed\", \"failed\", \"canceled\"]);\nconst MAX_ATTEMPTS = 30;\nconst MAX_REMOTE_WORK_MS = 20 * 60_000;\n// Re-dispatch continuations after a short delay. Serverless hosts do not keep\n// in-memory interval sweepers alive between requests, so delayed self-dispatch\n// is the portable retry mechanism.\nconst RESCHEDULE_DELAY_MS = 20_000;\nconst MAX_PRE_CLAIM_WAIT_MS = 25_000;\nconst POLL_INTERVAL_MS = 2_000;\nconst PROCESSOR_WAIT_MS = 10_000;\nconst POLL_REQUEST_TIMEOUT_MS = 8_000;\nconst PLATFORM_SEND_TIMEOUT_MS = 12_000;\nconst DISPATCH_SETTLE_WAIT_MS = 2_000;\nconst COMPLETE_AFTER_DELIVERY_ATTEMPTS = 3;\n\nexport async function dispatchA2AContinuation(\n continuationId: string,\n webhookBaseUrl?: string,\n): Promise<void> {\n const baseUrl =\n webhookBaseUrl ||\n process.env.WEBHOOK_BASE_URL ||\n process.env.APP_URL ||\n process.env.URL ||\n process.env.DEPLOY_URL ||\n `http://localhost:${process.env.PORT || 3000}`;\n\n const url = `${withConfiguredAppBasePath(baseUrl)}${PROCESSOR_PATH}`;\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n };\n try {\n headers[\"Authorization\"] = `Bearer ${signInternalToken(continuationId)}`;\n } catch (err) {\n if (process.env.NODE_ENV === \"production\") {\n console.error(\n `[integrations] Refusing to dispatch A2A continuation ${continuationId} — A2A_SECRET not configured.`,\n );\n return;\n }\n if (err instanceof Error && !/A2A_SECRET/i.test(err.message)) {\n console.error(\n `[integrations] signInternalToken failed unexpectedly for ${continuationId}:`,\n err,\n );\n }\n }\n\n const dispatchPromise = fetch(url, {\n method: \"POST\",\n headers,\n body: JSON.stringify({ continuationId }),\n })\n .then(async (response) => {\n if (!response.ok) {\n await logFailedDispatchResponse(continuationId, response);\n }\n })\n .catch((err) => {\n console.error(\n `[integrations] Failed to dispatch A2A continuation ${continuationId}:`,\n err,\n );\n });\n\n await Promise.race([\n dispatchPromise,\n new Promise<void>((resolve) =>\n setTimeout(resolve, DISPATCH_SETTLE_WAIT_MS),\n ),\n ]);\n}\n\nasync function logFailedDispatchResponse(\n continuationId: string,\n response: Response,\n): Promise<void> {\n let body = \"\";\n try {\n body = await response.text();\n } catch {}\n\n const trimmedBody = body.trim();\n console.error(\n `[integrations] A2A continuation ${continuationId} processor dispatch returned HTTP ` +\n `${response.status}${response.statusText ? ` ${response.statusText}` : \"\"}` +\n `${trimmedBody ? `: ${trimmedBody.slice(0, 500)}` : \"\"}`,\n );\n}\n\nexport async function processA2AContinuationById(\n continuationId: string,\n options: { adapters: Map<string, PlatformAdapter> },\n): Promise<void> {\n const shouldClaim = await waitForContinuationDue(continuationId);\n if (!shouldClaim) return;\n const continuation = await claimA2AContinuation(continuationId);\n if (!continuation) return;\n await processClaimedContinuation(continuation, options);\n}\n\nexport async function processDueA2AContinuations(options: {\n adapters: Map<string, PlatformAdapter>;\n limit?: number;\n}): Promise<void> {\n const continuations = await claimDueA2AContinuations(options.limit ?? 5);\n for (const continuation of continuations) {\n await processClaimedContinuation(continuation, options).catch((err) =>\n console.error(\n `[integrations] A2A continuation ${continuation.id} failed:`,\n err,\n ),\n );\n }\n}\n\nasync function processClaimedContinuation(\n continuation: A2AContinuation,\n options: { adapters: Map<string, PlatformAdapter> },\n): Promise<void> {\n const adapter = options.adapters.get(continuation.platform);\n if (!adapter) {\n await failA2AContinuation(\n continuation.id,\n `Unknown platform: ${continuation.platform}`,\n );\n return;\n }\n\n const progress = await resumeA2AContinuationProgress(continuation, adapter);\n\n const auth = await signContinuationToken(continuation);\n const client = new A2AClient(continuation.agentUrl, auth.apiKey, {\n requestTimeoutMs: POLL_REQUEST_TIMEOUT_MS,\n ...(auth.apiKeyFallbacks ? { fallbackApiKeys: auth.apiKeyFallbacks } : {}),\n });\n const deadline = Date.now() + PROCESSOR_WAIT_MS;\n let task: Task | null = null;\n\n try {\n while (Date.now() < deadline) {\n task = await client.getTask(continuation.a2aTaskId);\n if (TERMINAL_STATES.has(task.status.state)) break;\n await reportA2AContinuationProgress(continuation, progress, task);\n await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL_MS));\n }\n } catch (err) {\n if (isTransientA2APollError(err)) {\n if (shouldStopPollingRemoteTask(continuation)) {\n await notifyAndFailA2AContinuation(\n continuation,\n adapter,\n remotePollFailureReason(continuation),\n progress,\n );\n return;\n }\n await rescheduleAndRedispatchA2AContinuation(continuation.id);\n return;\n }\n if (continuation.attempts >= MAX_ATTEMPTS) {\n await notifyAndFailA2AContinuation(\n continuation,\n adapter,\n err instanceof Error ? err.message : String(err),\n progress,\n );\n return;\n }\n await rescheduleAndRedispatchA2AContinuation(continuation.id);\n return;\n }\n\n if (!task || !TERMINAL_STATES.has(task.status.state)) {\n if (shouldStopPollingRemoteTask(continuation)) {\n await notifyAndFailA2AContinuation(\n continuation,\n adapter,\n remotePollFailureReason(continuation),\n progress,\n );\n return;\n }\n await rescheduleAndRedispatchA2AContinuation(continuation.id);\n return;\n }\n\n if (task.status.state !== \"completed\") {\n const reason =\n extractTaskText(task) ||\n `Remote A2A task ${continuation.a2aTaskId} ended with state ${task.status.state}`;\n await notifyAndFailA2AContinuation(continuation, adapter, reason, progress);\n return;\n }\n\n const text = formatContinuationArtifactText(\n extractTaskText(task),\n continuation.agentUrl,\n );\n if (!text.trim()) {\n await notifyAndFailA2AContinuation(\n continuation,\n adapter,\n `Remote A2A task ${continuation.a2aTaskId} completed without text`,\n progress,\n );\n return;\n }\n\n await deliverAndCompleteA2AContinuation(\n continuation,\n adapter,\n text,\n progress,\n );\n}\n\nasync function resumeA2AContinuationProgress(\n continuation: A2AContinuation,\n adapter: PlatformAdapter,\n): Promise<PlatformRunProgress | null> {\n if (!continuation.progressRef || !adapter.resumeRunProgress) return null;\n try {\n const progress = await adapter.resumeRunProgress(\n continuation.incoming,\n continuation.progressRef,\n );\n if (!progress) return null;\n await progress.onEvent({\n type: \"agent_call_progress\",\n agent: continuation.agentName,\n state: \"working\",\n elapsedSeconds: Math.max(\n 0,\n Math.round((Date.now() - continuation.createdAt) / 1_000),\n ),\n detail: \"Continuing in the background\",\n });\n return progress;\n } catch {\n // A continuation still has a normal reply fallback. Do not log the\n // opaque provider reference or the inbound message payload.\n return null;\n }\n}\n\nasync function reportA2AContinuationProgress(\n continuation: A2AContinuation,\n progress: PlatformRunProgress | null,\n task: Task,\n): Promise<void> {\n if (!progress) return;\n await progress.onEvent({\n type: \"agent_call_progress\",\n agent: continuation.agentName,\n state: task.status.state,\n elapsedSeconds: Math.max(\n 0,\n Math.round((Date.now() - continuation.createdAt) / 1_000),\n ),\n detail: \"Still working on the delegated request\",\n });\n}\n\nasync function waitForContinuationDue(\n continuationId: string,\n): Promise<boolean> {\n const continuation = await getA2AContinuation(continuationId);\n if (!continuation) return false;\n if (continuation.status === \"completed\" || continuation.status === \"failed\") {\n return false;\n }\n if (continuation.status !== \"pending\") return true;\n\n const waitMs = continuation.nextCheckAt - Date.now();\n if (waitMs <= 0) return true;\n\n if (waitMs > MAX_PRE_CLAIM_WAIT_MS) return false;\n\n await sleep(waitMs);\n return true;\n}\n\nasync function notifyAndFailA2AContinuation(\n continuation: A2AContinuation,\n adapter: PlatformAdapter,\n reason: string,\n progress: PlatformRunProgress | null = null,\n): Promise<void> {\n const deliveryContinuation = await claimA2AContinuationDelivery(\n continuation.id,\n );\n if (!deliveryContinuation) return;\n\n const message = formatContinuationFailureMessage(\n deliveryContinuation,\n reason,\n );\n try {\n const outgoing = adapter.formatAgentResponse(message);\n await withTimeout(\n deliverA2AContinuationResponse(\n adapter,\n deliveryContinuation,\n outgoing,\n progress,\n \"error\",\n ),\n PLATFORM_SEND_TIMEOUT_MS,\n `${deliveryContinuation.platform} failure notification timed out`,\n );\n } catch (err) {\n console.error(\n `[integrations] Failed to notify ${deliveryContinuation.platform} about failed A2A continuation ${deliveryContinuation.id}:`,\n err,\n );\n }\n\n await failA2AContinuation(deliveryContinuation.id, reason);\n}\n\nasync function deliverAndCompleteA2AContinuation(\n continuation: A2AContinuation,\n adapter: PlatformAdapter,\n text: string,\n progress: PlatformRunProgress | null = null,\n): Promise<void> {\n const deliveryContinuation = await claimA2AContinuationDelivery(\n continuation.id,\n );\n if (!deliveryContinuation) return;\n\n try {\n const outgoing = adapter.formatAgentResponse(text);\n await withTimeout(\n deliverA2AContinuationResponse(\n adapter,\n deliveryContinuation,\n outgoing,\n progress,\n \"done\",\n ),\n PLATFORM_SEND_TIMEOUT_MS,\n `${deliveryContinuation.platform} response delivery timed out`,\n );\n } catch (err) {\n if (deliveryContinuation.attempts >= MAX_ATTEMPTS) {\n await failA2AContinuation(\n deliveryContinuation.id,\n err instanceof Error ? err.message : String(err),\n );\n return;\n }\n await rescheduleAndRedispatchA2AContinuation(deliveryContinuation.id);\n return;\n }\n\n await completeAfterSuccessfulDelivery(deliveryContinuation);\n}\n\nasync function deliverA2AContinuationResponse(\n adapter: PlatformAdapter,\n continuation: A2AContinuation,\n message: OutgoingMessage,\n progress: PlatformRunProgress | null,\n status: \"done\" | \"error\",\n): Promise<void> {\n if (progress) {\n try {\n await progress.onEvent({\n type: \"agent_call\",\n agent: continuation.agentName,\n status,\n });\n await progress.complete(message);\n return;\n } catch {\n // A resumed Slack stream can no longer be finalized (for example when\n // chat.stopStream rejects). Preserve the final answer with the same\n // thread reply fallback used by the initial webhook run. Also ask the\n // adapter to terminate the native stream: otherwise Slack can keep the\n // task card in its working state after the thread fallback succeeds.\n try {\n await progress.fail?.(\n \"I couldn't update the live response, but I posted the final result in this thread.\",\n );\n } catch {\n // The thread reply below is still the authoritative final answer.\n }\n }\n }\n await adapter.sendResponse(message, continuation.incoming, {\n placeholderRef: continuation.placeholderRef ?? undefined,\n });\n}\n\nasync function rescheduleAndRedispatchA2AContinuation(\n continuationId: string,\n): Promise<void> {\n await rescheduleA2AContinuation(continuationId, RESCHEDULE_DELAY_MS);\n await dispatchA2AContinuation(continuationId).catch((err) => {\n console.error(\n `[integrations] Failed to redispatch A2A continuation ${continuationId}:`,\n err,\n );\n });\n}\n\nasync function completeAfterSuccessfulDelivery(\n continuation: A2AContinuation,\n): Promise<void> {\n let lastError: unknown;\n for (let attempt = 0; attempt < COMPLETE_AFTER_DELIVERY_ATTEMPTS; attempt++) {\n try {\n await completeA2AContinuation(continuation.id);\n return;\n } catch (err) {\n lastError = err;\n }\n }\n\n console.error(\n `[integrations] ${continuation.platform} accepted A2A continuation ${continuation.id}, ` +\n \"but marking it completed failed. Leaving it in delivering for stale-delivery recovery.\",\n lastError,\n );\n}\n\nfunction formatContinuationFailureMessage(\n continuation: A2AContinuation,\n reason: string,\n): string {\n const explicitCode = extractFailureCode(reason);\n const diagnostics = formatContinuationFailureDiagnostics(\n continuation,\n reason,\n );\n if (isLlmCredentialError(reason, explicitCode)) {\n return (\n formatLlmCredentialErrorMessage({\n agentName: continuation.agentName,\n }) + diagnostics\n );\n }\n\n return `The ${continuation.agentName} agent could not finish this request: ${sanitizeFailureReason(\n reason,\n )}${diagnostics}`;\n}\n\nfunction formatContinuationFailureDiagnostics(\n continuation: A2AContinuation,\n reason: string,\n): string {\n return `\\n\\nError code: \\`${continuationFailureCode(reason)}\\`\\nRequest ID: \\`${continuation.integrationTaskId}\\`\\nContinuation ID: \\`${continuation.id}\\`\\nDownstream task ID: \\`${continuation.a2aTaskId}\\``;\n}\n\nfunction continuationFailureCode(reason: string): string {\n const explicitCode = extractFailureCode(reason);\n if (explicitCode) return explicitCode;\n if (isLlmCredentialError(reason, explicitCode)) {\n return LLM_MISSING_CREDENTIALS_ERROR_CODE;\n }\n if (/\\btimed out polling\\b/i.test(reason)) return \"a2a_remote_timeout\";\n return \"a2a_downstream_error\";\n}\n\nfunction extractFailureCode(reason: string): string | null {\n const match = /\\bcode\\s*[:=]\\s*[`\"']?([a-z][a-z0-9_]{0,79})\\b/i.exec(reason);\n return match?.[1]?.toLowerCase() ?? null;\n}\n\nfunction isRemoteWorkExpired(continuation: A2AContinuation): boolean {\n return Date.now() - continuation.createdAt >= MAX_REMOTE_WORK_MS;\n}\n\nfunction shouldStopPollingRemoteTask(continuation: A2AContinuation): boolean {\n return (\n continuation.attempts >= MAX_ATTEMPTS || isRemoteWorkExpired(continuation)\n );\n}\n\nfunction isTransientA2APollError(err: unknown): boolean {\n if (!(err instanceof Error)) return false;\n if (err.name === \"AbortError\") return true;\n return /operation was aborted|aborted|timed out|timeout|Invalid or expired A2A token|A2A request failed \\((?:401|508)\\)/i.test(\n err.message,\n );\n}\n\nfunction remotePollFailureReason(continuation: A2AContinuation): string {\n if (isRemoteWorkExpired(continuation)) {\n return `Timed out polling the ${continuation.agentName} A2A task ${continuation.a2aTaskId} after ${Math.round(\n MAX_REMOTE_WORK_MS / 60_000,\n )} minutes. The downstream agent did not return a final result.`;\n }\n\n return `Timed out polling the ${continuation.agentName} A2A task ${continuation.a2aTaskId} after ${MAX_ATTEMPTS} attempts. The downstream agent did not return a final result.`;\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nasync function withTimeout<T>(\n promise: Promise<T>,\n timeoutMs: number,\n message: string,\n): Promise<T> {\n let timer: ReturnType<typeof setTimeout> | undefined;\n try {\n return await Promise.race([\n promise,\n new Promise<never>((_, reject) => {\n timer = setTimeout(() => reject(new Error(message)), timeoutMs);\n }),\n ]);\n } finally {\n if (timer) clearTimeout(timer);\n }\n}\n\nfunction sanitizeFailureReason(reason: string): string {\n const oneLine = reason.replace(/\\s+/g, \" \").trim();\n const withoutEnvNames = oneLine.replace(\n /\\b[A-Z][A-Z0-9_]*(?:API_KEY|PRIVATE_KEY|SECRET|TOKEN)\\b/g,\n \"a required credential\",\n );\n return (\n withoutEnvNames.slice(0, 500) ||\n \"the downstream agent returned an empty error\"\n );\n}\n\nasync function signContinuationToken(\n continuation: A2AContinuation,\n): Promise<{ apiKey?: string; apiKeyFallbacks?: string[] }> {\n if (continuation.a2aAuthToken === \"\") {\n return {};\n }\n\n const storedToken = continuation.a2aAuthToken;\n if (storedToken && !isLikelyJwt(storedToken)) return { apiKey: storedToken };\n\n const freshTokens = await signFreshContinuationTokens(continuation);\n if (freshTokens.length > 0) {\n return {\n apiKey: freshTokens[0],\n ...(freshTokens.length > 1\n ? { apiKeyFallbacks: freshTokens.slice(1) }\n : {}),\n };\n }\n if (!storedToken) return {};\n\n // Older continuations may have persisted the initial short-lived JWT. Avoid\n // replaying it forever after expiry; opaque legacy bearer keys can still be\n // reused because we cannot re-mint those.\n if (isLikelyJwt(storedToken)) return {};\n return { apiKey: storedToken };\n}\n\nasync function signFreshContinuationTokens(\n continuation: A2AContinuation,\n): Promise<string[]> {\n let orgDomain: string | undefined;\n let orgSecret: string | undefined;\n if (continuation.orgId) {\n try {\n const { getOrgDomain, getOrgA2ASecret } =\n await import(\"../org/context.js\");\n orgDomain = (await getOrgDomain(continuation.orgId)) ?? undefined;\n orgSecret = (await getOrgA2ASecret(continuation.orgId)) ?? undefined;\n } catch {}\n }\n\n if (!continuation.ownerEmail || !(orgSecret || process.env.A2A_SECRET)) {\n return [];\n }\n\n const tokens: string[] = [];\n const add = (token: string | undefined) => {\n if (token && !tokens.includes(token)) tokens.push(token);\n };\n\n if (process.env.A2A_SECRET?.trim()) {\n try {\n add(\n await signA2AToken(continuation.ownerEmail, orgDomain, orgSecret, {\n expiresIn: \"30m\",\n preferGlobalSecret: true,\n }),\n );\n } catch {}\n }\n if (orgSecret) {\n try {\n add(\n await signA2AToken(continuation.ownerEmail, orgDomain, orgSecret, {\n expiresIn: \"30m\",\n preferGlobalSecret: false,\n }),\n );\n } catch {}\n }\n return tokens;\n}\n\nfunction isLikelyJwt(token: string): boolean {\n return token.split(\".\").length === 3;\n}\n\nfunction extractTaskText(task: Task): string {\n const parts = task.status.message?.parts ?? [];\n return parts\n .filter((part): part is { type: \"text\"; text: string } => {\n return part.type === \"text\" && typeof part.text === \"string\";\n })\n .map((part) => part.text)\n .join(\"\\n\");\n}\n\nfunction formatContinuationArtifactText(\n text: string,\n agentUrl: string,\n): string {\n const expandedText = expandRelativeUrls(text, agentUrl);\n return appendA2AArtifactLinks(\n expandedText,\n [{ tool: \"call-agent\", result: expandedText }],\n { baseUrl: resolveArtifactBaseUrl() },\n );\n}\n\nfunction resolveArtifactBaseUrl(): string | undefined {\n const baseUrl =\n process.env.APP_URL || process.env.URL || process.env.DEPLOY_URL;\n return baseUrl ? withConfiguredAppBasePath(baseUrl) : undefined;\n}\n\nfunction expandRelativeUrls(text: string, agentUrl: string): string {\n if (!text || !agentUrl) return text;\n const base = publicAgentBaseUrl(agentUrl);\n return text.replace(\n /(^|[\\s([<\"'`])(\\/[a-z0-9_-][a-z0-9_/?&=%#.,:-]*)/gi,\n (_match, lead, path) => `${lead}${base}${path}`,\n );\n}\n\nfunction publicAgentBaseUrl(agentUrl: string): string {\n try {\n const url = new URL(agentUrl);\n const routeIndex = url.pathname.indexOf(FRAMEWORK_ROUTE_PREFIX);\n url.pathname =\n routeIndex >= 0\n ? url.pathname.slice(0, routeIndex) || \"/\"\n : url.pathname.replace(/\\/+$/, \"\") || \"/\";\n url.search = \"\";\n url.hash = \"\";\n return url.toString().replace(/\\/$/, \"\");\n } catch {\n return agentUrl.replace(/\\/$/, \"\");\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slack.d.ts","sourceRoot":"","sources":["../../../src/integrations/adapters/slack.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EACV,eAAe,EACf,eAAe,EAQhB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"slack.d.ts","sourceRoot":"","sources":["../../../src/integrations/adapters/slack.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EACV,eAAe,EACf,eAAe,EAQhB,MAAM,aAAa,CAAC;AAcrB,MAAM,WAAW,mBAAmB;IAClC,8DAA8D;IAC9D,eAAe,CAAC,EAAE,CAAC,QAAQ,EAAE,eAAe,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAC7E,kEAAkE;IAClE,cAAc,CAAC,EAAE,CAAC,QAAQ,EAAE,eAAe,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACjE,oEAAoE;IACpE,oBAAoB,CAAC,EAAE,CAAC,QAAQ,EAAE,eAAe,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CACxE;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,YAAY,CAC1B,OAAO,GAAE,mBAAwB,GAChC,eAAe,CA2fjB"}
|
|
@@ -17,6 +17,7 @@ const SLACK_API_TIMEOUT_MS = 10_000;
|
|
|
17
17
|
const SLACK_PERMALINK_TIMEOUT_MS = 1_000;
|
|
18
18
|
const SLACK_CONTEXT_MESSAGE_LIMIT = 15;
|
|
19
19
|
const SLACK_CONTEXT_TEXT_LIMIT = 2_000;
|
|
20
|
+
const SLACK_CALM_PROGRESS_THRESHOLD_SECONDS = 30;
|
|
20
21
|
/**
|
|
21
22
|
* Create a Slack platform adapter.
|
|
22
23
|
*
|
|
@@ -258,12 +259,10 @@ export function slackAdapter(options = {}) {
|
|
|
258
259
|
: [];
|
|
259
260
|
},
|
|
260
261
|
async postProcessingPlaceholder(incoming) {
|
|
261
|
-
// No placeholder reply in the thread — Slack's native assistant
|
|
262
|
-
//
|
|
263
|
-
//
|
|
264
|
-
//
|
|
265
|
-
// We just set the native status and return null so sendResponse posts
|
|
266
|
-
// the final reply as a fresh message.
|
|
262
|
+
// No placeholder reply in the thread — Slack's native assistant status
|
|
263
|
+
// bar and the task stream are the loading affordance. Keep the status
|
|
264
|
+
// specific about intent instead of presenting the generic thinking
|
|
265
|
+
// state while the native plan is opening.
|
|
267
266
|
const token = await resolveBotToken(incoming);
|
|
268
267
|
if (!token)
|
|
269
268
|
return null;
|
|
@@ -271,11 +270,11 @@ export function slackAdapter(options = {}) {
|
|
|
271
270
|
const threadTs = incoming.platformContext.threadTs;
|
|
272
271
|
if (!channelId || !threadTs)
|
|
273
272
|
return null;
|
|
274
|
-
// Best-effort: flip the native Agent
|
|
273
|
+
// Best-effort: flip the native Agent status bar in the
|
|
275
274
|
// channel input area. Slack accepts chat:write for this method. The
|
|
276
275
|
// canonical manifest separately requests assistant:write for Agent View
|
|
277
276
|
// and app_context_changed events.
|
|
278
|
-
setSlackAssistantStatus(token, channelId, threadTs, "
|
|
277
|
+
setSlackAssistantStatus(token, channelId, threadTs, "I’m looking into this now…");
|
|
279
278
|
return null;
|
|
280
279
|
},
|
|
281
280
|
async hydrateIncomingMessage(incoming) {
|
|
@@ -1043,6 +1042,33 @@ function shortTaskTitle(value) {
|
|
|
1043
1042
|
const text = typeof value === "string" ? value : "Working";
|
|
1044
1043
|
return text.replace(/[-_]/g, " ").slice(0, 200);
|
|
1045
1044
|
}
|
|
1045
|
+
function delegatedTaskTitle(agent) {
|
|
1046
|
+
return `Contact ${shortTaskTitle(agent)}`;
|
|
1047
|
+
}
|
|
1048
|
+
function formatElapsedSeconds(elapsedSeconds) {
|
|
1049
|
+
const totalSeconds = Math.max(0, Math.round(elapsedSeconds));
|
|
1050
|
+
const minutes = Math.floor(totalSeconds / 60);
|
|
1051
|
+
const seconds = totalSeconds % 60;
|
|
1052
|
+
return minutes > 0 ? `${minutes}m ${seconds}s` : `${seconds}s`;
|
|
1053
|
+
}
|
|
1054
|
+
function formatProgressState(state) {
|
|
1055
|
+
if (state === "submitted")
|
|
1056
|
+
return "Queued";
|
|
1057
|
+
if (state === "working")
|
|
1058
|
+
return "Working";
|
|
1059
|
+
return shortTaskTitle(state);
|
|
1060
|
+
}
|
|
1061
|
+
function delegatedProgressDetails(agent, state, elapsedSeconds, detail) {
|
|
1062
|
+
const elapsed = formatElapsedSeconds(elapsedSeconds);
|
|
1063
|
+
const progress = `${formatProgressState(state)} · ${elapsed}`;
|
|
1064
|
+
const update = detail ? shortTaskTitle(detail) : "";
|
|
1065
|
+
if (elapsedSeconds >= SLACK_CALM_PROGRESS_THRESHOLD_SECONDS) {
|
|
1066
|
+
const agentName = shortTaskTitle(agent);
|
|
1067
|
+
const context = update ? ` — ${update}.` : ".";
|
|
1068
|
+
return `${progress}${context} This is taking longer than usual, but ${agentName} is still working. I’ll post the result here.`;
|
|
1069
|
+
}
|
|
1070
|
+
return update ? `${progress} — ${update}` : progress;
|
|
1071
|
+
}
|
|
1046
1072
|
async function postSlackJson(token, method, body) {
|
|
1047
1073
|
const response = await slackApiFetch(`https://slack.com/api/${method}`, {
|
|
1048
1074
|
method: "POST",
|
|
@@ -1083,18 +1109,18 @@ async function startSlackRunProgress(token, incoming) {
|
|
|
1083
1109
|
...(incoming.tenantId ? { recipient_team_id: incoming.tenantId } : {}),
|
|
1084
1110
|
...(incoming.senderId ? { recipient_user_id: incoming.senderId } : {}),
|
|
1085
1111
|
task_display_mode: "plan",
|
|
1086
|
-
markdown_text: "
|
|
1112
|
+
markdown_text: "I’m looking into this for you.",
|
|
1087
1113
|
chunks: [
|
|
1088
1114
|
{
|
|
1089
1115
|
type: "plan_update",
|
|
1090
|
-
title: "
|
|
1116
|
+
title: "I’m looking into this for you",
|
|
1091
1117
|
},
|
|
1092
1118
|
{
|
|
1093
1119
|
type: "task_update",
|
|
1094
1120
|
id: "agent-native:context",
|
|
1095
|
-
title: "
|
|
1121
|
+
title: "Review the request",
|
|
1096
1122
|
status: "in_progress",
|
|
1097
|
-
details: "
|
|
1123
|
+
details: "Finding the information needed for an answer",
|
|
1098
1124
|
},
|
|
1099
1125
|
],
|
|
1100
1126
|
});
|
|
@@ -1128,7 +1154,7 @@ function createSlackRunProgress(token, incoming, channel, threadTs, streamTs) {
|
|
|
1128
1154
|
const toolTaskIds = new Map();
|
|
1129
1155
|
const agentTaskIds = new Map();
|
|
1130
1156
|
tasks.set("agent-native:context", {
|
|
1131
|
-
title: "
|
|
1157
|
+
title: "Review the request",
|
|
1132
1158
|
status: "in_progress",
|
|
1133
1159
|
});
|
|
1134
1160
|
let sequence = 0;
|
|
@@ -1284,9 +1310,19 @@ function createSlackRunProgress(token, incoming, channel, threadTs, streamTs) {
|
|
|
1284
1310
|
: event.status === "done"
|
|
1285
1311
|
? "complete"
|
|
1286
1312
|
: "error";
|
|
1287
|
-
const title =
|
|
1313
|
+
const title = delegatedTaskTitle(event.agent);
|
|
1288
1314
|
tasks.set(id, { title, status });
|
|
1289
|
-
await append({
|
|
1315
|
+
await append({
|
|
1316
|
+
type: "task_update",
|
|
1317
|
+
id,
|
|
1318
|
+
title,
|
|
1319
|
+
status,
|
|
1320
|
+
...(event.status === "start"
|
|
1321
|
+
? {
|
|
1322
|
+
details: `I’m contacting ${shortTaskTitle(event.agent)} for an answer.`,
|
|
1323
|
+
}
|
|
1324
|
+
: {}),
|
|
1325
|
+
});
|
|
1290
1326
|
}
|
|
1291
1327
|
else if (event.type === "agent_call_progress") {
|
|
1292
1328
|
// A2A calls can stay healthy for minutes. Keep the same native Slack
|
|
@@ -1294,10 +1330,8 @@ function createSlackRunProgress(token, incoming, channel, threadTs, streamTs) {
|
|
|
1294
1330
|
// a new card per tick or leaving the user with a stale spinner.
|
|
1295
1331
|
const id = agentTaskIds.get(event.agent) ?? taskId("agent", event.agent);
|
|
1296
1332
|
agentTaskIds.set(event.agent, id);
|
|
1297
|
-
const title =
|
|
1298
|
-
const details = event.detail
|
|
1299
|
-
? shortTaskTitle(event.detail)
|
|
1300
|
-
: `Still ${event.state} after ${event.elapsedSeconds}s`;
|
|
1333
|
+
const title = delegatedTaskTitle(event.agent);
|
|
1334
|
+
const details = delegatedProgressDetails(event.agent, event.state, event.elapsedSeconds, event.detail);
|
|
1301
1335
|
tasks.set(id, { title, status: "in_progress" });
|
|
1302
1336
|
await append({
|
|
1303
1337
|
type: "task_update",
|
|
@@ -1311,9 +1345,9 @@ function createSlackRunProgress(token, incoming, channel, threadTs, streamTs) {
|
|
|
1311
1345
|
await append({
|
|
1312
1346
|
type: "task_update",
|
|
1313
1347
|
id: "agent-native:context",
|
|
1314
|
-
title: "
|
|
1348
|
+
title: "Review the request",
|
|
1315
1349
|
status: "in_progress",
|
|
1316
|
-
details: shortTaskTitle(event.label)
|
|
1350
|
+
details: `Working · ${shortTaskTitle(event.label)}`,
|
|
1317
1351
|
});
|
|
1318
1352
|
}
|
|
1319
1353
|
},
|