@agent-native/core 0.79.2 → 0.79.5
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 +24 -0
- package/corpus/core/docs/content/locales/zh-TW/a2a-protocol.md +392 -0
- package/corpus/core/docs/content/locales/zh-TW/actions.md +583 -0
- package/corpus/core/docs/content/locales/zh-TW/agent-mentions.md +164 -0
- package/corpus/core/docs/content/locales/zh-TW/agent-surfaces.md +397 -0
- package/corpus/core/docs/content/locales/zh-TW/agent-teams.md +171 -0
- package/corpus/core/docs/content/locales/zh-TW/agent-web-surfaces.md +161 -0
- package/corpus/core/docs/content/locales/zh-TW/audit-log.md +111 -0
- package/corpus/core/docs/content/locales/zh-TW/authentication.md +332 -0
- package/corpus/core/docs/content/locales/zh-TW/automations.md +268 -0
- package/corpus/core/docs/content/locales/zh-TW/blueprint-installer.md +83 -0
- package/corpus/core/docs/content/locales/zh-TW/cli-adapters.md +129 -0
- package/corpus/core/docs/content/locales/zh-TW/client.md +398 -0
- package/corpus/core/docs/content/locales/zh-TW/cloneable-saas.md +114 -0
- package/corpus/core/docs/content/locales/zh-TW/code-agents-ui.md +436 -0
- package/corpus/core/docs/content/locales/zh-TW/components.md +368 -0
- package/corpus/core/docs/content/locales/zh-TW/context-awareness.md +373 -0
- package/corpus/core/docs/content/locales/zh-TW/creating-templates.md +411 -0
- package/corpus/core/docs/content/locales/zh-TW/cross-app-sso.md +188 -0
- package/corpus/core/docs/content/locales/zh-TW/database.md +183 -0
- package/corpus/core/docs/content/locales/zh-TW/deployment.md +348 -0
- package/corpus/core/docs/content/locales/zh-TW/dispatch.md +146 -0
- package/corpus/core/docs/content/locales/zh-TW/drop-in-agent.md +260 -0
- package/corpus/core/docs/content/locales/zh-TW/durable-resume.md +65 -0
- package/corpus/core/docs/content/locales/zh-TW/embedding-sdk.md +597 -0
- package/corpus/core/docs/content/locales/zh-TW/evals.md +155 -0
- package/corpus/core/docs/content/locales/zh-TW/extensions.md +360 -0
- package/corpus/core/docs/content/locales/zh-TW/external-agents.md +619 -0
- package/corpus/core/docs/content/locales/zh-TW/faq.md +142 -0
- package/corpus/core/docs/content/locales/zh-TW/file-uploads.md +122 -0
- package/corpus/core/docs/content/locales/zh-TW/frames.md +153 -0
- package/corpus/core/docs/content/locales/zh-TW/getting-started.md +199 -0
- package/corpus/core/docs/content/locales/zh-TW/harness-agents.md +349 -0
- package/corpus/core/docs/content/locales/zh-TW/human-approval.md +86 -0
- package/corpus/core/docs/content/locales/zh-TW/internationalization.md +147 -0
- package/corpus/core/docs/content/locales/zh-TW/key-concepts.md +312 -0
- package/corpus/core/docs/content/locales/zh-TW/local-file-mode.md +433 -0
- package/corpus/core/docs/content/locales/zh-TW/mcp-apps.md +147 -0
- package/corpus/core/docs/content/locales/zh-TW/mcp-clients.md +330 -0
- package/corpus/core/docs/content/locales/zh-TW/mcp-protocol.md +279 -0
- package/corpus/core/docs/content/locales/zh-TW/messaging.md +461 -0
- package/corpus/core/docs/content/locales/zh-TW/migration-workbench.md +33 -0
- package/corpus/core/docs/content/locales/zh-TW/multi-app-workspace.md +312 -0
- package/corpus/core/docs/content/locales/zh-TW/multi-tenancy.md +52 -0
- package/corpus/core/docs/content/locales/zh-TW/native-chat-ui.md +321 -0
- package/corpus/core/docs/content/locales/zh-TW/notifications.md +231 -0
- package/corpus/core/docs/content/locales/zh-TW/observability.md +294 -0
- package/corpus/core/docs/content/locales/zh-TW/observational-memory.md +77 -0
- package/corpus/core/docs/content/locales/zh-TW/onboarding.md +216 -0
- package/corpus/core/docs/content/locales/zh-TW/plan-plugin.md +200 -0
- package/corpus/core/docs/content/locales/zh-TW/pr-visual-recap.md +384 -0
- package/corpus/core/docs/content/locales/zh-TW/processors.md +106 -0
- package/corpus/core/docs/content/locales/zh-TW/progress.md +199 -0
- package/corpus/core/docs/content/locales/zh-TW/pure-agent-apps.md +39 -0
- package/corpus/core/docs/content/locales/zh-TW/real-time-collaboration.md +680 -0
- package/corpus/core/docs/content/locales/zh-TW/recurring-jobs.md +142 -0
- package/corpus/core/docs/content/locales/zh-TW/routing.md +79 -0
- package/corpus/core/docs/content/locales/zh-TW/sandbox-adapters.md +227 -0
- package/corpus/core/docs/content/locales/zh-TW/security.md +330 -0
- package/corpus/core/docs/content/locales/zh-TW/server.md +265 -0
- package/corpus/core/docs/content/locales/zh-TW/sharing.md +219 -0
- package/corpus/core/docs/content/locales/zh-TW/skills-guide.md +281 -0
- package/corpus/core/docs/content/locales/zh-TW/template-analytics.md +259 -0
- package/corpus/core/docs/content/locales/zh-TW/template-assets.md +303 -0
- package/corpus/core/docs/content/locales/zh-TW/template-brain.md +324 -0
- package/corpus/core/docs/content/locales/zh-TW/template-calendar.md +194 -0
- package/corpus/core/docs/content/locales/zh-TW/template-chat.md +129 -0
- package/corpus/core/docs/content/locales/zh-TW/template-clips.md +368 -0
- package/corpus/core/docs/content/locales/zh-TW/template-content.md +402 -0
- package/corpus/core/docs/content/locales/zh-TW/template-design.md +173 -0
- package/corpus/core/docs/content/locales/zh-TW/template-dispatch.md +220 -0
- package/corpus/core/docs/content/locales/zh-TW/template-forms.md +178 -0
- package/corpus/core/docs/content/locales/zh-TW/template-mail.md +239 -0
- package/corpus/core/docs/content/locales/zh-TW/template-plan.md +814 -0
- package/corpus/core/docs/content/locales/zh-TW/template-slides.md +293 -0
- package/corpus/core/docs/content/locales/zh-TW/template-videos.md +222 -0
- package/corpus/core/docs/content/locales/zh-TW/tracking.md +236 -0
- package/corpus/core/docs/content/locales/zh-TW/using-your-agent.md +71 -0
- package/corpus/core/docs/content/locales/zh-TW/voice-input.md +81 -0
- package/corpus/core/docs/content/locales/zh-TW/what-is-agent-native.md +202 -0
- package/corpus/core/docs/content/locales/zh-TW/workspace-connections.md +321 -0
- package/corpus/core/docs/content/locales/zh-TW/workspace-management.md +175 -0
- package/corpus/core/docs/content/locales/zh-TW/workspace.md +323 -0
- package/corpus/core/docs/content/locales/zh-TW/writing-agent-instructions.md +173 -0
- package/corpus/core/package.json +1 -1
- package/corpus/core/src/client/ErrorBoundary.tsx +10 -0
- package/corpus/core/src/client/FeedbackButton.tsx +12 -0
- package/corpus/core/src/client/blocks/library/block-copy.ts +32 -0
- package/corpus/core/src/client/extensions/ExtensionsSidebarSection.tsx +33 -0
- package/corpus/core/src/client/i18n.tsx +5 -0
- package/corpus/core/src/localization/actions/set-localization-preference.ts +2 -1
- package/corpus/core/src/localization/shared.ts +45 -0
- package/corpus/core/src/server/agent-chat-plugin.ts +38 -0
- package/corpus/core/src/server/onboarding-html.ts +99 -0
- package/corpus/core/src/templates/default/app/i18n/index.ts +2 -0
- package/corpus/core/src/templates/default/app/i18n/zh-TW.ts +466 -0
- package/corpus/core/src/templates/default/app/root.tsx +8 -0
- package/corpus/templates/analytics/app/i18n/index.ts +2 -0
- package/corpus/templates/analytics/app/i18n/zh-TW.ts +818 -0
- package/corpus/templates/analytics/app/i18n-data.ts +9 -0
- package/corpus/templates/assets/app/i18n/index.ts +2 -0
- package/corpus/templates/assets/app/i18n/zh-TW.ts +860 -0
- package/corpus/templates/assets/app/i18n-data.ts +3 -0
- package/corpus/templates/brain/app/i18n/index.ts +2 -0
- package/corpus/templates/brain/app/i18n/zh-TW.ts +709 -0
- package/corpus/templates/brain/app/i18n-data.ts +3 -0
- package/corpus/templates/calendar/app/i18n/zh-TW.ts +836 -0
- package/corpus/templates/calendar/app/i18n-data.ts +4 -0
- package/corpus/templates/chat/app/i18n/index.ts +2 -0
- package/corpus/templates/chat/app/i18n/zh-TW.ts +67 -0
- package/corpus/templates/chat/app/i18n-data.ts +3 -0
- package/corpus/templates/clips/app/i18n/index.ts +2 -0
- package/corpus/templates/clips/app/i18n/zh-TW.ts +1280 -0
- package/corpus/templates/content/app/i18n/index.ts +2 -0
- package/corpus/templates/content/app/i18n/zh-TW.ts +906 -0
- package/corpus/templates/content/app/i18n-data.ts +4 -0
- package/corpus/templates/design/app/i18n/index.ts +2 -0
- package/corpus/templates/design/app/i18n/zh-TW.ts +517 -0
- package/corpus/templates/design/app/i18n-data.ts +6 -0
- package/corpus/templates/dispatch/app/i18n/index.ts +2 -0
- package/corpus/templates/dispatch/app/i18n/zh-TW.ts +195 -0
- package/corpus/templates/dispatch/app/i18n-data.ts +3 -0
- package/corpus/templates/forms/app/i18n/index.ts +2 -0
- package/corpus/templates/forms/app/i18n/zh-TW.ts +349 -0
- package/corpus/templates/macros/app/i18n/index.ts +2 -0
- package/corpus/templates/macros/app/i18n/zh-TW.ts +224 -0
- package/corpus/templates/mail/app/i18n/index.ts +2 -0
- package/corpus/templates/mail/app/i18n/zh-TW.ts +562 -0
- package/corpus/templates/mail/app/root.tsx +6 -0
- package/corpus/templates/plan/app/i18n/index.ts +2 -0
- package/corpus/templates/plan/app/i18n/zh-TW.ts +712 -0
- package/corpus/templates/slides/app/i18n/index.ts +2 -0
- package/corpus/templates/slides/app/i18n/zh-TW.ts +531 -0
- package/corpus/templates/videos/app/i18n/index.ts +2 -0
- package/corpus/templates/videos/app/i18n/zh-TW.ts +435 -0
- package/dist/client/ErrorBoundary.d.ts.map +1 -1
- package/dist/client/ErrorBoundary.js +10 -0
- package/dist/client/ErrorBoundary.js.map +1 -1
- package/dist/client/FeedbackButton.d.ts.map +1 -1
- package/dist/client/FeedbackButton.js +12 -0
- package/dist/client/FeedbackButton.js.map +1 -1
- package/dist/client/blocks/library/block-copy.d.ts.map +1 -1
- package/dist/client/blocks/library/block-copy.js +32 -0
- package/dist/client/blocks/library/block-copy.js.map +1 -1
- package/dist/client/extensions/ExtensionsSidebarSection.d.ts.map +1 -1
- package/dist/client/extensions/ExtensionsSidebarSection.js +32 -0
- package/dist/client/extensions/ExtensionsSidebarSection.js.map +1 -1
- package/dist/client/i18n.d.ts.map +1 -1
- package/dist/client/i18n.js +5 -0
- package/dist/client/i18n.js.map +1 -1
- package/dist/collab/awareness.d.ts +2 -2
- package/dist/collab/awareness.d.ts.map +1 -1
- package/dist/collab/routes.d.ts +1 -1
- package/dist/localization/actions/set-localization-preference.d.ts.map +1 -1
- package/dist/localization/actions/set-localization-preference.js +2 -2
- package/dist/localization/actions/set-localization-preference.js.map +1 -1
- package/dist/localization/shared.d.ts +1 -1
- package/dist/localization/shared.d.ts.map +1 -1
- package/dist/localization/shared.js +43 -0
- package/dist/localization/shared.js.map +1 -1
- package/dist/notifications/routes.d.ts +3 -3
- package/dist/observability/routes.d.ts +3 -3
- package/dist/resources/handlers.d.ts +2 -2
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +39 -0
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/server/agent-engine-api-key-route.d.ts +2 -2
- package/dist/server/onboarding-html.d.ts.map +1 -1
- package/dist/server/onboarding-html.js +96 -0
- package/dist/server/onboarding-html.js.map +1 -1
- package/dist/templates/default/app/i18n/index.ts +2 -0
- package/dist/templates/default/app/i18n/zh-TW.ts +466 -0
- package/dist/templates/default/app/root.tsx +8 -0
- package/docs/content/locales/zh-TW/a2a-protocol.md +392 -0
- package/docs/content/locales/zh-TW/actions.md +583 -0
- package/docs/content/locales/zh-TW/agent-mentions.md +164 -0
- package/docs/content/locales/zh-TW/agent-surfaces.md +397 -0
- package/docs/content/locales/zh-TW/agent-teams.md +171 -0
- package/docs/content/locales/zh-TW/agent-web-surfaces.md +161 -0
- package/docs/content/locales/zh-TW/audit-log.md +111 -0
- package/docs/content/locales/zh-TW/authentication.md +332 -0
- package/docs/content/locales/zh-TW/automations.md +268 -0
- package/docs/content/locales/zh-TW/blueprint-installer.md +83 -0
- package/docs/content/locales/zh-TW/cli-adapters.md +129 -0
- package/docs/content/locales/zh-TW/client.md +398 -0
- package/docs/content/locales/zh-TW/cloneable-saas.md +114 -0
- package/docs/content/locales/zh-TW/code-agents-ui.md +436 -0
- package/docs/content/locales/zh-TW/components.md +368 -0
- package/docs/content/locales/zh-TW/context-awareness.md +373 -0
- package/docs/content/locales/zh-TW/creating-templates.md +411 -0
- package/docs/content/locales/zh-TW/cross-app-sso.md +188 -0
- package/docs/content/locales/zh-TW/database.md +183 -0
- package/docs/content/locales/zh-TW/deployment.md +348 -0
- package/docs/content/locales/zh-TW/dispatch.md +146 -0
- package/docs/content/locales/zh-TW/drop-in-agent.md +260 -0
- package/docs/content/locales/zh-TW/durable-resume.md +65 -0
- package/docs/content/locales/zh-TW/embedding-sdk.md +597 -0
- package/docs/content/locales/zh-TW/evals.md +155 -0
- package/docs/content/locales/zh-TW/extensions.md +360 -0
- package/docs/content/locales/zh-TW/external-agents.md +619 -0
- package/docs/content/locales/zh-TW/faq.md +142 -0
- package/docs/content/locales/zh-TW/file-uploads.md +122 -0
- package/docs/content/locales/zh-TW/frames.md +153 -0
- package/docs/content/locales/zh-TW/getting-started.md +199 -0
- package/docs/content/locales/zh-TW/harness-agents.md +349 -0
- package/docs/content/locales/zh-TW/human-approval.md +86 -0
- package/docs/content/locales/zh-TW/internationalization.md +147 -0
- package/docs/content/locales/zh-TW/key-concepts.md +312 -0
- package/docs/content/locales/zh-TW/local-file-mode.md +433 -0
- package/docs/content/locales/zh-TW/mcp-apps.md +147 -0
- package/docs/content/locales/zh-TW/mcp-clients.md +330 -0
- package/docs/content/locales/zh-TW/mcp-protocol.md +279 -0
- package/docs/content/locales/zh-TW/messaging.md +461 -0
- package/docs/content/locales/zh-TW/migration-workbench.md +33 -0
- package/docs/content/locales/zh-TW/multi-app-workspace.md +312 -0
- package/docs/content/locales/zh-TW/multi-tenancy.md +52 -0
- package/docs/content/locales/zh-TW/native-chat-ui.md +321 -0
- package/docs/content/locales/zh-TW/notifications.md +231 -0
- package/docs/content/locales/zh-TW/observability.md +294 -0
- package/docs/content/locales/zh-TW/observational-memory.md +77 -0
- package/docs/content/locales/zh-TW/onboarding.md +216 -0
- package/docs/content/locales/zh-TW/plan-plugin.md +200 -0
- package/docs/content/locales/zh-TW/pr-visual-recap.md +384 -0
- package/docs/content/locales/zh-TW/processors.md +106 -0
- package/docs/content/locales/zh-TW/progress.md +199 -0
- package/docs/content/locales/zh-TW/pure-agent-apps.md +39 -0
- package/docs/content/locales/zh-TW/real-time-collaboration.md +680 -0
- package/docs/content/locales/zh-TW/recurring-jobs.md +142 -0
- package/docs/content/locales/zh-TW/routing.md +79 -0
- package/docs/content/locales/zh-TW/sandbox-adapters.md +227 -0
- package/docs/content/locales/zh-TW/security.md +330 -0
- package/docs/content/locales/zh-TW/server.md +265 -0
- package/docs/content/locales/zh-TW/sharing.md +219 -0
- package/docs/content/locales/zh-TW/skills-guide.md +281 -0
- package/docs/content/locales/zh-TW/template-analytics.md +259 -0
- package/docs/content/locales/zh-TW/template-assets.md +303 -0
- package/docs/content/locales/zh-TW/template-brain.md +324 -0
- package/docs/content/locales/zh-TW/template-calendar.md +194 -0
- package/docs/content/locales/zh-TW/template-chat.md +129 -0
- package/docs/content/locales/zh-TW/template-clips.md +368 -0
- package/docs/content/locales/zh-TW/template-content.md +402 -0
- package/docs/content/locales/zh-TW/template-design.md +173 -0
- package/docs/content/locales/zh-TW/template-dispatch.md +220 -0
- package/docs/content/locales/zh-TW/template-forms.md +178 -0
- package/docs/content/locales/zh-TW/template-mail.md +239 -0
- package/docs/content/locales/zh-TW/template-plan.md +814 -0
- package/docs/content/locales/zh-TW/template-slides.md +293 -0
- package/docs/content/locales/zh-TW/template-videos.md +222 -0
- package/docs/content/locales/zh-TW/tracking.md +236 -0
- package/docs/content/locales/zh-TW/using-your-agent.md +71 -0
- package/docs/content/locales/zh-TW/voice-input.md +81 -0
- package/docs/content/locales/zh-TW/what-is-agent-native.md +202 -0
- package/docs/content/locales/zh-TW/workspace-connections.md +321 -0
- package/docs/content/locales/zh-TW/workspace-management.md +175 -0
- package/docs/content/locales/zh-TW/workspace.md +323 -0
- package/docs/content/locales/zh-TW/writing-agent-instructions.md +173 -0
- package/package.json +1 -1
- package/src/templates/default/app/i18n/index.ts +2 -0
- package/src/templates/default/app/i18n/zh-TW.ts +466 -0
- package/src/templates/default/app/root.tsx +8 -0
|
@@ -0,0 +1,461 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "訊息傳遞"
|
|
3
|
+
description: "通過 Slack、電子郵件、Telegram 或 WhatsApp 與您的客服人員交談 — 相同的客服人員、相同的內存、相同的工具。"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# 訊息傳遞
|
|
7
|
+
|
|
8
|
+
將您的代理連線到 Slack、電子郵件、Telegram 或 WhatsApp,以便您可以通過您已使用的應用程式與其聊天。這是同一個代理——相同的內存、相同的工具、相同的線程——只是可以從更多的地方存取。
|
|
9
|
+
|
|
10
|
+
> **使用調度範本?** 所有這些都已在 **設定 → 訊息傳送** 中為您做好準備。點選以連線每個平台 - 您無需閱讀本頁面的其餘部分,除非您正在自訂或建置自己的範本。請參閱 [Dispatch](/docs/dispatch) 或 [Dispatch template reference](/docs/template-dispatch)。
|
|
11
|
+
|
|
12
|
+
## 你能做什么 {#what-you-can-do}
|
|
13
|
+
|
|
14
|
+
- **向您的代理發送電子郵件**,地址如 `agent@yourcompany.com` - 它會線上程中回複,就像同事一樣。
|
|
15
|
+
- **在一個線程上抄送您的代理** — 當您提出要求時,它會跟著閱讀並跳入。
|
|
16
|
+
- **在 Slack** 上向代理發送私信,或在任何渠道中向 `@mention` 發送代理。
|
|
17
|
+
- **通過手機向 Telegram 或 WhatsApp 上的客服人員發送訊息**。
|
|
18
|
+
- **相同的代理,相同的內存。**無論您在 Slack 上告訴什么,當您稍後通過電子郵件發送時,都會記住它。網路聊天和外部訊息共用同一個線程歷史紀錄。
|
|
19
|
+
- 有關單向應用內提醒(響鈴圖標、webhooks),請參閱 [Notifications](/docs/notifications)。
|
|
20
|
+
|
|
21
|
+
```an-diagram title="多渠道,一位代理商" summary="每個平台都進入相同的代理循環和相同的 SQL 線程歷史紀錄 - 因此 Slack 私信 和電子郵件繼續相同的對話。"
|
|
22
|
+
{
|
|
23
|
+
"html": "<div class=\"msg-fanin\"><div class=\"diagram-col\"><div class=\"diagram-node\">Slack</div><div class=\"diagram-node\">Email</div><div class=\"diagram-node\">Telegram</div><div class=\"diagram-node\">WhatsApp</div></div><div class=\"diagram-arrow diagram-muted\" aria-hidden=\"true\">→</div><div class=\"diagram-panel center\" data-rough><span class=\"diagram-pill accent\">一個代理循環</span><small class=\"diagram-muted\">相同記憶 · 相同工具</small></div><div class=\"diagram-arrow diagram-muted\" aria-hidden=\"true\">→</div><div class=\"diagram-box\" data-rough>一條 SQL 線程歷史<br><small class=\"diagram-muted\">web chat + external messages share it</small></div></div>",
|
|
24
|
+
"css": ".msg-fanin{display:flex;align-items:center;gap:14px;flex-wrap:wrap}.msg-fanin .diagram-col{display:flex;flex-direction:column;gap:8px}.msg-fanin .center{display:flex;flex-direction:column;align-items:center;gap:4px}"
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## 設定Slack {#slack}
|
|
29
|
+
|
|
30
|
+
### 您需要什么
|
|
31
|
+
|
|
32
|
+
- Slack 工作區,您可以在其中安裝應用程式(管理員存取權限)
|
|
33
|
+
- 大約5分鐘
|
|
34
|
+
|
|
35
|
+
### 步驟
|
|
36
|
+
|
|
37
|
+
1. 轉到 **[api.slack.com/apps](https://api.slack.com/apps)** 並點選 **建立新應用程式** → **從頭開始**。為其命名(例如“Agent”)並選取您的工作區。
|
|
38
|
+
2. 在左側邊欄中,開啟 **OAuth 和權限**。在 **機器人權杖範圍** 下,新增:
|
|
39
|
+
- `chat:write` — 讓代理發送訊息
|
|
40
|
+
- `app_mentions:read` — 讓代理看到它何時被@提及(可選)
|
|
41
|
+
- `im:history` — 讓代理讀取發送給它的 DM
|
|
42
|
+
- `assistant:write` — 可選;讓 Slack 在助理線程中顯示本機“正在思考...”狀態
|
|
43
|
+
- `users:read.email` — 可選;幫助 Mail 等範本驗證 Slack 發件人電子郵件的草稿佇列身分
|
|
44
|
+
3. 點選該頁面頂部的“**安裝到工作區**”。 Slack 將為您提供一個以 `xoxb-` 開頭的 **機器人使用者 OAuth 權杖**。複製它。
|
|
45
|
+
4. 轉到側邊欄中的**基本資訊**並複製**簽名金鑰**。
|
|
46
|
+
5. 開啟應用的設定(或託管提供者的環境變數面板)並貼上:
|
|
47
|
+
- `SLACK_BOT_TOKEN` — `xoxb-…` 代幣
|
|
48
|
+
- `SLACK_SIGNING_SECRET` — 簽名秘密
|
|
49
|
+
- `SLACK_ALLOWED_TEAM_IDS` — 推薦用於正式環境;允許發送事件的以逗號分隔的 Slack 工作區/團隊 ID
|
|
50
|
+
- `SLACK_ALLOWED_API_APP_IDS` — 推薦用於多工作區應用程式;允許使用此簽名金鑰的以逗號分隔的 Slack 應用 ID
|
|
51
|
+
6. 返回 Slack,開啟**事件訂閱**,將其開啟,然後貼上此請求 URL:
|
|
52
|
+
|
|
53
|
+
```文本
|
|
54
|
+
https://your-app.example.com/_agent-native/integrations/slack/webhook
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
然後在**訂閱機器人事件**下,新增 `message.im`(對於 DM)和可選的 `app_mention`(對於頻道提及)。儲存。
|
|
58
|
+
|
|
59
|
+
7. 向您的機器人發送 Slack 中的 DM。它應該回複。
|
|
60
|
+
|
|
61
|
+
### 可選:應用程式展開
|
|
62
|
+
|
|
63
|
+
Slack應用程式展開,讓應用程式以更丰富的方式取代Slack的正常連結預覽
|
|
64
|
+
預覽。 Clips 使用它來進行 Loom 風格的可播放影片預覽。
|
|
65
|
+
|
|
66
|
+
當您的應用需要展開時新增這些額外的機器人範圍:
|
|
67
|
+
|
|
68
|
+
- `links:read` — 讓 Slack 在註冊域名發布時通知應用
|
|
69
|
+
- `links:write` — 讓應用替換 Slack 的預設預覽
|
|
70
|
+
- `links.embed:write` — 讓應用嵌入經批準的媒體/播放器 URL
|
|
71
|
+
|
|
72
|
+
然後訂閱 `link_shared` 活動並註冊您的公開應用域
|
|
73
|
+
在**應用程式展開域**下。對於僅限剪輯的可播放預覽,請設定 Slack
|
|
74
|
+
事件訂閱請求 URL 至:
|
|
75
|
+
|
|
76
|
+
```text
|
|
77
|
+
https://your-clips.example.com/api/slack/unfurl
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Slack 應用程式有一個事件 API 請求 URL。如果同一個 Slack 應用程式應該處理
|
|
81
|
+
代理聊天事件和剪輯都展開,通過一個小路由 Slack 事件
|
|
82
|
+
發送訊息事件到`/_agent-native/integrations/slack/webhook`的調度程序
|
|
83
|
+
和 `link_shared` 事件到 Clips 展開處理程序。
|
|
84
|
+
|
|
85
|
+
### 提示
|
|
86
|
+
|
|
87
|
+
- **頻道提及** - 機器人僅在被@提及時在頻道中做出回應,以避免噪音。
|
|
88
|
+
- **私信** — 每個私信都被視為與代理的私人對話。
|
|
89
|
+
- **相同的身分,所有渠道** — 如果 Slack 使用者與您應用中的註冊使用者具有相同的電子郵件地址,則代理會將他們視為同一個人。
|
|
90
|
+
- **正式環境允許列表** — 設定 `SLACK_ALLOWED_TEAM_IDS`,對於共用 Slack 應用,設定 `SLACK_ALLOWED_API_APP_IDS`,以便有效的簽名金鑰無法被意外的工作區重複使用。
|
|
91
|
+
- **Clips 應用程式展開** — 適用於 Slack 的可安裝 Agent-Native Clips 使用 `SLACK_CLIENT_ID`、`SLACK_CLIENT_SECRET`、`SLACK_SIGNING_SECRET` 和 `/api/slack/oauth/callback`。每個連線的 Slack 工作空間都會在 `app_secrets` 中獲得自己的加密機器人權杖; `SLACK_BOT_TOKEN` 只是傳統的單一工作區後備方案。
|
|
92
|
+
|
|
93
|
+
## 設定 Telegram {#telegram}
|
|
94
|
+
|
|
95
|
+
### 您需要什么
|
|
96
|
+
|
|
97
|
+
- 手機上的 Telegram 應用
|
|
98
|
+
- 約3分鐘
|
|
99
|
+
|
|
100
|
+
### 步驟
|
|
101
|
+
|
|
102
|
+
1. 開啟電報和訊息**[@BotFather](https://t.me/BotFather)**。
|
|
103
|
+
2. 發送 `/newbot` 並按照提示為您的機器人命名。 BotFather 將回複 **HTTP API 權杖**。複製它。
|
|
104
|
+
3. 在應用的環境變數中,設定:
|
|
105
|
+
- `TELEGRAM_BOT_TOKEN` — 來自 BotFather 的代幣
|
|
106
|
+
4. 部署後,通過 `POST`ing 將 Webhook 註冊到您的應用:
|
|
107
|
+
|
|
108
|
+
```文本
|
|
109
|
+
POST https://your-app.example.com/_agent-native/integrations/telegram/setup
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
這告訴 Telegram 將訊息發送到您應用的 Webhook。每次部署只需執行一次此操作。
|
|
113
|
+
|
|
114
|
+
5. 在 Telegram 中找到您的機器人(搜尋 BotFather 為您提供的使用者名)並向其發送訊息。
|
|
115
|
+
|
|
116
|
+
## 設定電子郵件 {#email}
|
|
117
|
+
|
|
118
|
+
電子郵件是最強大的整合 - 您的代理擁有自己的地址、線程內回複、可以在對話中抄送,並使用發件人的電子郵件作為其身分。不需要 `/link` 指令。
|
|
119
|
+
|
|
120
|
+
### 您需要什么
|
|
121
|
+
|
|
122
|
+
- 您控制的域(或者您可以使用免費的重新發送子域 - 見下文)
|
|
123
|
+
- 具有 **Resend** 或 **SendGrid** 的帳戶來處理入站 + 出站郵件
|
|
124
|
+
- 大約10分鐘
|
|
125
|
+
|
|
126
|
+
### 步驟(重新發送 - 最簡單)
|
|
127
|
+
|
|
128
|
+
1. 在 **[resend.com](https://resend.com)** 註冊。免費套餐足以開始使用。
|
|
129
|
+
2. 選取代理電子郵件地址的外觀:
|
|
130
|
+
- **最簡單:**使用免費的 `<your-slug>.resend.app` 地址 - 不需要 DNS。
|
|
131
|
+
- **品牌:**在重新發送的**域名**頁面中新增自訂域名(例如 `yourcompany.com`),並按照 DNS 步驟進行操作。
|
|
132
|
+
3. 在重新發送中,開啟 **Webhooks** → **新增端點** 並將其指向:
|
|
133
|
+
|
|
134
|
+
```文本
|
|
135
|
+
https://your-app.example.com/_agent-native/integrations/email/webhook
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
訂閱 **`email.received`** 事件。重新發送將為您提供一個簽名秘密 - 複製它。
|
|
139
|
+
|
|
140
|
+
4. 在應用的環境變數中,設定:
|
|
141
|
+
- `EMAIL_AGENT_ADDRESS` — 代理接收郵件的地址(例如 `agent@yourcompany.com`)
|
|
142
|
+
- `RESEND_API_KEY` — 您的重新發送 API 金鑰
|
|
143
|
+
- `EMAIL_INBOUND_WEBHOOK_SECRET` — 來自 Resend 的簽名金鑰(推薦;用於簽名驗證)
|
|
144
|
+
|
|
145
|
+
5. 向代理的地址發送電子郵件。它會在同一個線程中回複。
|
|
146
|
+
|
|
147
|
+
### 步驟(使用 SendGrid)
|
|
148
|
+
|
|
149
|
+
1. 在 **[sendgrid.com](https://sendgrid.com)** 註冊。
|
|
150
|
+
2. 新增您的域的 MX 紀錄,以便入站郵件流向 SendGrid:
|
|
151
|
+
```文本
|
|
152
|
+
MX yourcompany.com → mx.sendgrid.net(優先級 10)
|
|
153
|
+
```
|
|
154
|
+
3. 開啟**設定 → 入站解析**,點選**新增主機和 URL**,並將目標設定為:
|
|
155
|
+
|
|
156
|
+
```文本
|
|
157
|
+
https://your-app.example.com/_agent-native/integrations/email/webhook
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
4. 設定環境變數:
|
|
161
|
+
- `EMAIL_AGENT_ADDRESS` — 代理收到的地址
|
|
162
|
+
- `SENDGRID_API_KEY` — 您的 SendGrid API 金鑰
|
|
163
|
+
- `EMAIL_INBOUND_WEBHOOK_SECRET` — 可選的 Svix 簽名金鑰(如果您已設定簽名 webhooks)
|
|
164
|
+
|
|
165
|
+
5. 向代理的地址發送電子郵件。
|
|
166
|
+
|
|
167
|
+
### 提示
|
|
168
|
+
|
|
169
|
+
- **抄送代理**以將其帶入線程。當代理被抄送時,它將回複全部,以便整個線程都能看到回應。
|
|
170
|
+
- **線程正常工作** - 代理使用標準 `Message-ID` / `In-Reply-To` / `References` 標頭,因此回複會保留在任何電子郵件用戶端中的正確線程中。
|
|
171
|
+
- **身分是發件人的電子郵件。**如果 `alice@acme.com` 向代理發送電子郵件,則*就是*她的身分 - 沒有連結或註冊流程。
|
|
172
|
+
- **丰富的回複** - 代理回複中的降價在電子郵件中呈現為 HTML。
|
|
173
|
+
- **允許的域** — 通過在整合設定中設定 `allowedDomains` 來限制誰可以向代理發送電子郵件;來自其他域的訊息將被丟棄。
|
|
174
|
+
- **速率限制** — 每個發件人每小時 20 條入站訊息。
|
|
175
|
+
|
|
176
|
+
## 設定 WhatsApp {#whatsapp}
|
|
177
|
+
|
|
178
|
+
### 您需要什么
|
|
179
|
+
|
|
180
|
+
- Meta (Facebook) 開發者帳戶
|
|
181
|
+
- 您可以專用於機器人的電話號碼
|
|
182
|
+
- 大約15分鐘(Meta的設定步驟最多)
|
|
183
|
+
|
|
184
|
+
### 步驟
|
|
185
|
+
|
|
186
|
+
1. 轉到 **[Meta Developer Portal](https://developers.facebook.com/)**,點擊 **建立應用**,然後選取 **商業** 型別。
|
|
187
|
+
2. 將 **WhatsApp** 產品新增到您的應用並設定一個電話號碼用作發件人。
|
|
188
|
+
3. 從 WhatsApp 設定頁面,獲取:
|
|
189
|
+
- **存取權杖**(臨時權杖適合測試;上線前生成永久權杖)
|
|
190
|
+
- **電話號碼ID**
|
|
191
|
+
4. 選取任意隨機字串用作驗證權杖 - 您將在下面的兩個位置輸入相同的值。
|
|
192
|
+
5. 在應用的環境變數中,設定:
|
|
193
|
+
- `WHATSAPP_ACCESS_TOKEN` — 您的存取權杖
|
|
194
|
+
- `WHATSAPP_PHONE_NUMBER_ID` — 電話號碼 ID
|
|
195
|
+
- `WHATSAPP_VERIFY_TOKEN` — 您選取的隨機字串
|
|
196
|
+
6. 返回 Meta 的 WhatsApp 設定,開啟 Webhook 部分並設定:
|
|
197
|
+
|
|
198
|
+
```文本
|
|
199
|
+
回調URL:https://your-app.example.com/_agent-native/integrations/whatsapp/webhook
|
|
200
|
+
驗證權杖:與您設定為WHATSAPP_VERIFY_TOKEN的隨機字串相同
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
訂閱`messages`欄位。
|
|
204
|
+
|
|
205
|
+
7. 向機器人的電話號碼發送 WhatsApp 訊息。
|
|
206
|
+
|
|
207
|
+
## 使用 Dispatch 作為客服人員的中央收件箱 {#dispatch}
|
|
208
|
+
|
|
209
|
+
如果您正在執行多個代理本機應用(郵件、行事曆、分析等),建議的模式是在 **[Dispatch](/docs/dispatch)**(另請參閱 [template reference](/docs/template-dispatch))上設定訊息傳遞,並讓它通過 [A2A](/docs/a2a-protocol) 將工作路由到您的域應用。
|
|
210
|
+
|
|
211
|
+
為什么這很好:
|
|
212
|
+
|
|
213
|
+
- **一名客服人員,一個收件箱。**您的所有渠道(Slack、電子郵件、Telegram、WhatsApp)都會流入 Dispatch。您只需設定整合一次。
|
|
214
|
+
- **調度代表。** 詢問“總結上週的註冊情況” - Dispatch 調用分析代理。詢問“起草給 Alice 的回複”——Dispatch 呼叫郵件代理。
|
|
215
|
+
- **點擊,而不是設定。** Dispatch 的 **設定 → 訊息傳遞** 頁面具有針對每個平台的連線按鈕,並內置了 env-var 欄位。
|
|
216
|
+
|
|
217
|
+
如果您不需要協調器,任何單個範本都可以使用此頁面上的環境變數直接連線訊息傳遞。
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
## 對於開發者 {#for-developers}
|
|
222
|
+
|
|
223
|
+
以下內容均為技術參考。如果您已完成上述設定步驟,則可以在此停止,除非您要自訂整合外掛或建置自己的適配器。
|
|
224
|
+
|
|
225
|
+
### 它是如何工作的 {#how-it-works}
|
|
226
|
+
|
|
227
|
+
入站平台 webhooks 使用跨平台 SQL 佇列模式,因此它們可以在每個無伺服器主機(Netlify、Vercel、Cloudflare Workers、Fly、Render、Node)上執行,而不依賴於特定於平台的後台執行 API。
|
|
228
|
+
|
|
229
|
+
1. 平台從 `POST` 變為 `/_agent-native/integrations/<platform>/webhook`。處理程序驗證簽名,將有效負載解析為 `IncomingMessage`,並**使用 `status='pending'` 將一行插入 `integration_pending_tasks`**。
|
|
230
|
+
2. 處理程序觸發“即發即棄”`POST /_agent-native/integrations/process-task` 並立即返回 `200`,位於 Slack 的 3 秒 SLA 之內。
|
|
231
|
+
3. 處理器端點在**新函數執行**中執行,並具有自己的完整超時預算。它以原子方式聲明工作(`pending` → `processing` 通過 `claimPendingTask`),執行代理循環,通過適配器發布回複,並標記工作 `completed`。
|
|
232
|
+
4. 重複性重試作業(`startPendingTasksRetryJob`,每 60 秒)會清除卡在 `pending` > 90 秒或 `processing` > 5 分鐘內的工作,並重新啟動處理器。嘗試次數上限為 3 次,然後標記為 `failed`。
|
|
233
|
+
|
|
234
|
+
```an-diagram title="入站 Webhook 生命週期" summary="Webhook 僅驗證、入隊並返回 200。新的函數執行會耗盡佇列並執行代理循環,並以 60 秒的重試作業作為安全網。"
|
|
235
|
+
{
|
|
236
|
+
"html": "<div class=\"msg-flow\"><div class=\"msg-row\"><div class=\"diagram-node\">Platform<br><small class=\"diagram-muted\">Slack · 郵件 · 等</small></div><div class=\"diagram-arrow diagram-muted\" aria-hidden=\"true\">→</div><div class=\"diagram-box\" data-rough><strong>/webhook</strong><br><small class=\"diagram-muted\">verify signature + parse</small><br><span class=\"diagram-pill\">INSERT 待處理工作</span></div><div class=\"diagram-arrow diagram-muted\" aria-hidden=\"true\">→</div><div class=\"diagram-pill ok\">return 200</div></div><div class=\"msg-fire\"><span class=\"diagram-muted\">fire-and-forget</span> <span class=\"diagram-arrow diagram-muted\" aria-hidden=\"true\">↓</span></div><div class=\"msg-row\"><div class=\"diagram-box\" data-rough><strong>/process-task</strong><br><small class=\"diagram-muted\">全新執行 · 獨立超時</small></div><div class=\"diagram-arrow diagram-muted\" aria-hidden=\"true\">→</div><div class=\"diagram-pill accent\">claim</div><div class=\"diagram-arrow diagram-muted\" aria-hidden=\"true\">→</div><div class=\"diagram-pill accent\">agent loop</div><div class=\"diagram-arrow diagram-muted\" aria-hidden=\"true\">→</div><div class=\"diagram-pill accent\">adapter.sendResponse</div><div class=\"diagram-arrow diagram-muted\" aria-hidden=\"true\">→</div><div class=\"diagram-pill ok\">completed</div></div><div class=\"diagram-panel msg-retry\" data-rough><span class=\"diagram-pill warn\">every 60s</span> <span class=\"diagram-muted\">retry job sweeps stuck tasks (pending >90s · processing >5min) and re-fires /process-task — capped at 3 attempts, then <strong>failed</strong></span></div></div>",
|
|
237
|
+
"css": ".msg-flow{display:flex;flex-direction:column;gap:12px}.msg-flow .msg-row{display:flex;align-items:center;gap:10px;flex-wrap:wrap}.msg-flow .msg-fire{display:flex;align-items:center;gap:8px;padding-inline-start:12px}.msg-flow .msg-retry{display:flex;align-items:center;gap:8px;flex-wrap:wrap}"
|
|
238
|
+
}
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
入站和出站對話位於同一 SQL 線程中,因此您可以從 Web UI 繼續 Slack 私信,反之亦然。
|
|
242
|
+
|
|
243
|
+
```an-api
|
|
244
|
+
{
|
|
245
|
+
"method": "POST",
|
|
246
|
+
"path": "/_agent-native/integrations/slack/webhook",
|
|
247
|
+
"summary": "Slack 事件 API 入站 Webhook",
|
|
248
|
+
"description": "Receives Slack events (DMs and channel `app_mention`s). Verifies the request signature, parses the payload into an `IncomingMessage`, inserts a `pending` row into `integration_pending_tasks`, fires the fresh-execution processor, and returns **200 immediately** — well inside Slack's 3-second SLA. The same route shape exists per platform under `/_agent-native/integrations/<platform>/webhook`.",
|
|
249
|
+
"auth": "HMAC-SHA256 of the raw body using `SLACK_SIGNING_SECRET`, checked against the `X-Slack-Signature` header. In production also gated by `SLACK_ALLOWED_TEAM_IDS` / `SLACK_ALLOWED_API_APP_IDS`.",
|
|
250
|
+
"params": [
|
|
251
|
+
{ "name": "X-Slack-Signature", "in": "header", "type": "string", "required": true, "description": "Slack request signature, verified before any processing." },
|
|
252
|
+
{ "name": "X-Slack-Request-Timestamp", "in": "header", "type": "string", "required": true, "description": "Timestamp used in the signature base string." }
|
|
253
|
+
],
|
|
254
|
+
"request": {
|
|
255
|
+
"contentType": "application/json",
|
|
256
|
+
"example": "{\n \"type\": \"event_callback\",\n \"team_id\": \"T0123\",\n \"api_app_id\": \"A0123\",\n \"event\": {\n \"type\": \"message\",\n \"channel_type\": \"im\",\n \"user\": \"U0123\",\n \"text\": \"summarize last week's signups\"\n }\n}"
|
|
257
|
+
},
|
|
258
|
+
"responses": [
|
|
259
|
+
{ "status": "200", "description": "Acknowledged immediately. The agent loop runs in the separate /process-task execution. The first time a Request URL is saved, Slack POSTs a `url_verification` challenge and the adapter replies with the `challenge` value automatically.", "example": "{ \"ok\": true }" },
|
|
260
|
+
{ "status": "401", "description": "Signature verification failed, or the team/app id is not in the production allowlist." }
|
|
261
|
+
]
|
|
262
|
+
}
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
#### 為什么采用這種模式(而不是平台本機快捷方式) {#why-this-pattern}
|
|
266
|
+
|
|
267
|
+
無伺服器函數在發送回應時凍結。任何仍在執行的東西——包括一勞永逸的 Promise、延遲的 LLM 調用或執行中的工具——都會在執行過程中被終止。保持代理循環活動的唯一方法是為其啟動一個**新**函數執行,這就是自觸發的 `/process-task` POST 所做的。
|
|
268
|
+
|
|
269
|
+
NOT 是否使用以下任何替代方案:
|
|
270
|
+
|
|
271
|
+
- **Netlify 後台功能** — 僅 Netlify,需要 `-background.ts` 檔案名後綴,在所有其他主機上都會中斷。
|
|
272
|
+
- **Cloudflare `event.waitUntil()`** — 僅 CF Workers,不可移植。
|
|
273
|
+
- **Vercel `after()` / Fluid** - 僅 Vercel,在特定執行時門控。
|
|
274
|
+
- **`return` 之後的赤裸裸的即發即棄 Promise** — 當函數凍結時默默地被殺死;記錄中沒有錯誤,使用者只是永遠得不到回複。
|
|
275
|
+
|
|
276
|
+
SQL-queue + self-webhook + retry-job 組合是唯一在每個受支持的主機上都以相同方式工作的組合。重試作業是安全網——永遠不要假設在函數凍結之前初始調度已刷新。
|
|
277
|
+
|
|
278
|
+
### 整合外掛 {#plugin}
|
|
279
|
+
|
|
280
|
+
當不存在自訂版本時,外掛會自動安裝。要自訂,請建立:
|
|
281
|
+
|
|
282
|
+
```ts
|
|
283
|
+
// server/plugins/integrations.ts
|
|
284
|
+
import { createIntegrationsPlugin } from "@agent-native/core/server";
|
|
285
|
+
import { scriptRegistry } from "../../agent.config";
|
|
286
|
+
|
|
287
|
+
export default createIntegrationsPlugin({
|
|
288
|
+
actions: scriptRegistry,
|
|
289
|
+
systemPrompt: "You are a helpful assistant...",
|
|
290
|
+
});
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
哪些平台處於活動狀態取決於設定的環境變數。該外掛為 `/_agent-native/integrations/` 下的每一個註冊 webhook 路由。
|
|
294
|
+
|
|
295
|
+
### Webhook URLs {#webhook-urls}
|
|
296
|
+
|
|
297
|
+
```text
|
|
298
|
+
/_agent-native/integrations/slack/webhook
|
|
299
|
+
/_agent-native/integrations/telegram/webhook
|
|
300
|
+
/_agent-native/integrations/whatsapp/webhook
|
|
301
|
+
/_agent-native/integrations/email/webhook
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
Telegram 還公開了一個一次性設定端點:
|
|
305
|
+
|
|
306
|
+
```text
|
|
307
|
+
POST /_agent-native/integrations/telegram/setup
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
### 環境變數 {#env-vars}
|
|
311
|
+
|
|
312
|
+
| 平台 | 必填 | 可選 |
|
|
313
|
+
| -------- | ---------------------------------------------------------------------------- | ----------------------------------------------------- |
|
|
314
|
+
| Slack | `SLACK_BOT_TOKEN`, `SLACK_SIGNING_SECRET` | `SLACK_ALLOWED_TEAM_IDS`, `SLACK_ALLOWED_API_APP_IDS` |
|
|
315
|
+
| 電報 | `TELEGRAM_BOT_TOKEN` | — |
|
|
316
|
+
| 電子郵件 | `EMAIL_AGENT_ADDRESS`,加上 `RESEND_API_KEY` 或 `SENDGRID_API_KEY` 之一 | `EMAIL_INBOUND_WEBHOOK_SECRET` |
|
|
317
|
+
| WhatsApp | `WHATSAPP_ACCESS_TOKEN`, `WHATSAPP_VERIFY_TOKEN`, `WHATSAPP_PHONE_NUMBER_ID` | — |
|
|
318
|
+
|
|
319
|
+
所有憑證都存在於環境變數中——不是資料庫,也不是來源程式碼。使用側邊欄設定 UI 或託管提供者的環境面板。
|
|
320
|
+
|
|
321
|
+
### 線程和身分 {#threading-and-identity}
|
|
322
|
+
|
|
323
|
+
每個外部對話都對應到代理本機資料庫中的持久線程:
|
|
324
|
+
|
|
325
|
+
- **Slack 私信** → 每個 Slack 使用者一個線程。
|
|
326
|
+
- **Slack 通道 @mention** → 每個通道一個線程。
|
|
327
|
+
- **Telegram 聊天** → 每個 Telegram 聊天一個線程。
|
|
328
|
+
- **WhatsApp 對話** → 每個 WhatsApp 號碼一個線程。
|
|
329
|
+
- **電子郵件** → 從 `Message-ID` / `In-Reply-To` / `References` 標頭派生的線程。
|
|
330
|
+
|
|
331
|
+
外部線程與來源自網路的線程一起出現在網路 UI 中,並標記有其來源平台。身分解析:當 Slack/電子郵件使用者與註冊使用者(通常通過電子郵件)匹配時,他們就會連結到該帳戶。
|
|
332
|
+
|
|
333
|
+
### 安全 {#security}
|
|
334
|
+
|
|
335
|
+
每個傳入的 Webhook 在處理前都會經過簽名驗證:
|
|
336
|
+
|
|
337
|
+
- **Slack** — 使用 `SLACK_SIGNING_SECRET` 的主體的 HMAC-SHA256,對照 `X-Slack-Signature` 標頭進行檢查。當您第一次在 Slack 的事件訂閱面板中儲存請求 URL 時,Slack 會向其發布 `url_verification` 挑战;框架的適配器會檢測到這一點並自動回複 `challenge` 值,因此 URL 在 Slack 中變為綠色,而無需您進行任何額外的工作。
|
|
338
|
+
- **Telegram** — 註冊 webhook 時設定的秘密權杖。
|
|
339
|
+
- **WhatsApp** - Meta 的驗證挑战(使用 `WHATSAPP_VERIFY_TOKEN`)加上有效負載簽名。
|
|
340
|
+
- **Email** — 設定 `EMAIL_INBOUND_WEBHOOK_SECRET` 時的 Svix 風格簽名驗證(Resend 和 SendGrid 均使用此格式)。如果未設定密碼,則接受 Webhook,但會紀錄警告。
|
|
341
|
+
|
|
342
|
+
電子郵件適配器還強制執行:
|
|
343
|
+
|
|
344
|
+
- **允許的域** — 整合的 `integration_configs` 行中的可選 `allowedDomains` 陣列;列表之外的發件人將被刪除。
|
|
345
|
+
- **速率限制** — SQL 佇列支持的速率限制為每個發件人每小時 20 條入站訊息。
|
|
346
|
+
|
|
347
|
+
### 主動發送 {#proactive-sends}
|
|
348
|
+
|
|
349
|
+
代理可以通過調用 `send-platform-message` 操作(`platform` 欄位為 `"slack"`、`"telegram"`、`"whatsapp"` 或 `"email"`)來主動發送訊息(通知、提醒、計畫摘要)。該操作位於 `packages/dispatch/src/actions/send-platform-message.ts` 的 Dispatch 包中,您可以將其複製/改編為任何範本。
|
|
350
|
+
|
|
351
|
+
### 自訂適配器 {#custom-adapters}
|
|
352
|
+
|
|
353
|
+
要新增新的訊息傳遞平台,請實現 `PlatformAdapter` 介面:
|
|
354
|
+
|
|
355
|
+
```ts
|
|
356
|
+
import type { H3Event } from "h3";
|
|
357
|
+
import type {
|
|
358
|
+
PlatformAdapter,
|
|
359
|
+
IncomingMessage,
|
|
360
|
+
OutgoingMessage,
|
|
361
|
+
} from "@agent-native/core/server";
|
|
362
|
+
import type { EnvKeyConfig } from "@agent-native/core/server";
|
|
363
|
+
|
|
364
|
+
const myAdapter: PlatformAdapter = {
|
|
365
|
+
platform: "discord",
|
|
366
|
+
label: "Discord",
|
|
367
|
+
|
|
368
|
+
// Env keys this adapter needs (rendered in the settings UI)
|
|
369
|
+
getRequiredEnvKeys(): EnvKeyConfig[] {
|
|
370
|
+
return [
|
|
371
|
+
{ key: "DISCORD_BOT_TOKEN", label: "Discord Bot Token", required: true },
|
|
372
|
+
];
|
|
373
|
+
},
|
|
374
|
+
|
|
375
|
+
// Handle platform-specific verification challenges (e.g. Slack's
|
|
376
|
+
// url_verification). Return { handled: true, response } to short-circuit.
|
|
377
|
+
async handleVerification(event: H3Event) {
|
|
378
|
+
return { handled: false };
|
|
379
|
+
},
|
|
380
|
+
|
|
381
|
+
// Validate the webhook request signature
|
|
382
|
+
async verifyWebhook(event: H3Event): Promise<boolean> {
|
|
383
|
+
// Validate signature headers; return true if authentic
|
|
384
|
+
return true;
|
|
385
|
+
},
|
|
386
|
+
|
|
387
|
+
// Parse the webhook payload into a normalized IncomingMessage.
|
|
388
|
+
// Return null to silently ignore the event (bot messages, edits, etc.).
|
|
389
|
+
async parseIncomingMessage(event: H3Event): Promise<IncomingMessage | null> {
|
|
390
|
+
return {
|
|
391
|
+
platform: "discord",
|
|
392
|
+
externalThreadId: "channel-or-thread-id",
|
|
393
|
+
text: "the user's message",
|
|
394
|
+
senderId: "discord-user-id",
|
|
395
|
+
platformContext: { channelId: "channel-id" },
|
|
396
|
+
timestamp: Date.now(),
|
|
397
|
+
};
|
|
398
|
+
},
|
|
399
|
+
|
|
400
|
+
// Format plain agent text into a platform-appropriate OutgoingMessage.
|
|
401
|
+
// opts.threadDeepLinkUrl, when provided, is a URL back to the originating
|
|
402
|
+
// thread in the dispatch UI — render it as a button (Slack) or inline link.
|
|
403
|
+
formatAgentResponse(
|
|
404
|
+
text: string,
|
|
405
|
+
opts?: { threadDeepLinkUrl?: string },
|
|
406
|
+
): OutgoingMessage {
|
|
407
|
+
return { text, platformContext: {} };
|
|
408
|
+
},
|
|
409
|
+
|
|
410
|
+
// Post the agent's response back to the platform
|
|
411
|
+
async sendResponse(
|
|
412
|
+
message: OutgoingMessage,
|
|
413
|
+
context: IncomingMessage,
|
|
414
|
+
): Promise<void> {
|
|
415
|
+
// Call the platform's API, using context.platformContext for routing
|
|
416
|
+
},
|
|
417
|
+
|
|
418
|
+
// Return current connection/configuration status for the settings UI.
|
|
419
|
+
// baseUrl is the app's public URL, used for status checks that need it.
|
|
420
|
+
async getStatus(baseUrl?: string) {
|
|
421
|
+
return {
|
|
422
|
+
platform: "discord",
|
|
423
|
+
label: "Discord",
|
|
424
|
+
enabled: true,
|
|
425
|
+
configured: !!process.env.DISCORD_BOT_TOKEN,
|
|
426
|
+
};
|
|
427
|
+
},
|
|
428
|
+
};
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
在您的整合外掛中註冊它:
|
|
432
|
+
|
|
433
|
+
```ts
|
|
434
|
+
export default createIntegrationsPlugin({
|
|
435
|
+
actions: scriptRegistry,
|
|
436
|
+
systemPrompt: "You are a helpful assistant...",
|
|
437
|
+
adapters: [myAdapter],
|
|
438
|
+
});
|
|
439
|
+
```
|
|
440
|
+
|
|
441
|
+
`packages/core/src/integrations/adapters/`(`slack.ts`、`telegram.ts`、`whatsapp.ts`、`email.ts`)中的參考實現 - 電子郵件適配器是最完整的範例,包括簽名驗證、線程、速率限制和 HTML 渲染。
|
|
442
|
+
|
|
443
|
+
### 通過 Dispatch + A2A 延續實現可靠性 {#reliability}
|
|
444
|
+
|
|
445
|
+
當 [Dispatch](/docs/dispatch) 通過 [A2A](/docs/a2a-protocol#continuations) 將請求委托給另一個應用程式時,即使下游代理在執行過程中當機,連續恢復流程也能保證使用者獲得 Slack/電子郵件回複。原始 webhook 工作保留在 `processing` 中,直到延續解決或重試掃描將其標記為卡住;無論哪種方式,平台線程都會得到最終答複,而不是陷入沉默。
|
|
446
|
+
|
|
447
|
+
這意味著 Dispatch 前端的多應用工作區比直接連線到訊息傳遞的單個範本更具彈性 - 任何一個下游應用程式中的故障都會降級為正常的錯誤訊息,而不是丟棄回複。請參閱 [A2A continuations](/docs/a2a-protocol#continuations) 了解完整的交付保證故事。
|
|
448
|
+
|
|
449
|
+
### 常見陷阱 {#pitfalls}
|
|
450
|
+
|
|
451
|
+
- **不要重複讀取請求內文。** h3 v2 的內文流是一次性消耗的:如果在框架已經解析 `event.node.req.body` 後調用 `readBody(event)`(反之亦然),則第二次讀取將無限期地暫停請求。這種情況最常出現在 Resend 和 SendGrid 中 — 兩者都流式傳輸入站有效負載,並且懸空讀取永遠不會解析、平台超時,並且 Webhook 會重試,直到進行重複資料刪除。如果您將框架的 Webhook 處理程序包裝在自己的中間件中,請通過 `incoming` 選項傳遞已解析的 `IncomingMessage`,而不是讓處理程序重新解析。
|
|
452
|
+
- **不要在 webhook 處理程序內執行代理循環。**處理程序必須排隊並返回 - 代理循環在處理器的新執行中執行。將其內聯保證無伺服器凍結會終止執行。此外,面向公眾的網關整合(例如 Netlify 或 Vercel)強制執行嚴格的 HTTP 超時限制(例如 Netlify 的 10 秒請求限制)。由於代理執行和工具通常需要比此窗口更長的時間,因此嘗試在 Webhook 請求中同步執行循環將導致網關終止連線,從而導致執行中止並丟棄回複。 HMAC 簽名的自 Webhook `/process-task` 佇列模式是安全執行完整代理循環時滿足網關限制的唯一方法。
|
|
453
|
+
- **不要在冷啟動時依賴重複資料刪除內存。**重複資料刪除金鑰位於 SQL `(platform, external_event_key)` 唯一索引中,而不是進程內對應中。如果替換佇列,請保留 SQL 級別的重複資料刪除,否則重複的 Slack 重試將觸發重複的代理執行。
|
|
454
|
+
- **保持 self-webhook URL 可存取。**處理器 URL 是從 `APP_URL` / `URL` / `DEPLOY_URL` / `BETTER_AUTH_URL` 建置的,回退到入站請求標頭。在使用重寫主機名的預覽部署中,明確設定其中之一,否則調度將出現 404。
|
|
455
|
+
|
|
456
|
+
### 另請參閱 {#see-also}
|
|
457
|
+
|
|
458
|
+
- [Dispatch](/docs/dispatch) — 跨應用使用中央收件箱的概念概述
|
|
459
|
+
- [Dispatch template reference](/docs/template-dispatch) — 推薦用於多應用工作區的中央收件箱
|
|
460
|
+
- [A2A Protocol](/docs/a2a-protocol) — Dispatch 委托如何與其他代理一起工作,包括連續恢復
|
|
461
|
+
- [Agent Mentions](/docs/agent-mentions) - `@` - 在網路聊天中提及代理
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "遷移到 Agent-Native (/migrate)"
|
|
3
|
+
description: "遷移是 Agent-Native 程式碼工作區中的內置 /migrate 目標,而不是單獨的應用程式。請參閱 Agent-Native 程式碼 UI 獲取完整指南。"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# 遷移到 Agent-Native (/migrate)
|
|
7
|
+
|
|
8
|
+
遷移**不是單獨的產品或範本** - 它是內置的
|
|
9
|
+
[Agent-Native Code](/docs/code-agents-ui) 工作空間內的 `/migrate` 目標。
|
|
10
|
+
它作為正常的程式碼工作階段執行,您可以恢復、附加、檢查和停止。
|
|
11
|
+
|
|
12
|
+
```an-diagram title="/migrate 是一個程式碼工作階段,而不是一個單獨的應用程式" summary="路徑、URL 或描述進入;該執行與其他所有程式碼工作階段共用相同的存儲、腳本和控件,並且可以生成可移植的檔案。"
|
|
13
|
+
{
|
|
14
|
+
"html": "<div class=\"diagram-migrate\"><div class=\"diagram-col\"><div class=\"diagram-pill\">./local-app</div><div class=\"diagram-pill\">https://example.com</div><div class=\"diagram-pill\">--describe \\\"...\\\"</div></div><div class=\"diagram-arrow diagram-muted\" aria-hidden=\"true\">→</div><div class=\"diagram-panel center\" data-rough><span class=\"diagram-pill accent\">/migrate goal</span><small class=\"diagram-muted\">同一存儲 · 轉錄 · 執行控制</small></div><div class=\"diagram-arrow diagram-muted\" aria-hidden=\"true\">→</div><div class=\"diagram-col\"><div class=\"diagram-box\" data-rough>已遷移應用</div><div class=\"diagram-pill ok\">--emit dossier</div></div></div>",
|
|
15
|
+
"css": ".diagram-migrate{display:flex;align-items:center;gap:12px;flex-wrap:wrap}.diagram-migrate .diagram-col{display:flex;flex-direction:column;gap:8px}.diagram-migrate .diagram-arrow{font-size:22px;line-height:1}.diagram-migrate .center{display:flex;flex-direction:column;align-items:center;gap:4px}"
|
|
16
|
+
}
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npx @agent-native/core@latest code /migrate ./my-next-app --out ../migrated-app
|
|
21
|
+
npx @agent-native/core@latest code /migrate https://example.com --describe "marketing site plus dashboard"
|
|
22
|
+
npx @agent-native/core@latest migrate ./my-next-app --out ../migrated-app # shortcut into the same goal
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
完整指南 - 輸入形狀(路徑/URL/描述)、`--emit` 檔案,
|
|
26
|
+
計畫與自動模式、執行控件、憑證、桌面深層連結以及
|
|
27
|
+
`@agent-native/migrate` 包匯出 — 位於
|
|
28
|
+
[Agent-Native Code UI → Migrating to Agent-Native](/docs/code-agents-ui#migrate).
|
|
29
|
+
|
|
30
|
+
> [!NOTE]
|
|
31
|
+
> 舊版隱藏的 `migration` 詳細資訊應用程式已被刪除。使用程式碼
|
|
32
|
+
> 工作區、桌面程式碼分頁或發出的達析報告作為受支持
|
|
33
|
+
> 表面。
|