@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,433 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "本機檔案模式"
|
|
3
|
+
description: "使用本機 Markdown、MDX 和其他儲存庫檔案作為事實來源執行代理本機應用 - 包括帶有自訂元件的黑曜石風格 MDX 檔案。"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# 本機檔案模式
|
|
7
|
+
|
|
8
|
+
本機檔案模式允許代理本機應用程式附加其正常的 UI 和操作介面
|
|
9
|
+
直接到儲存庫或工作區中的檔案。該應用程式仍然感覺像是託管的
|
|
10
|
+
產品,但其列表視圖、編輯器和代理工具可讀寫本機檔案
|
|
11
|
+
而不是 SQL 支持的應用紀錄。
|
|
12
|
+
|
|
13
|
+
第一個實現是在內容範本中:左側邊欄是
|
|
14
|
+
從本機 `.md` 和 `.mdx` 檔案填充,選取一個頁面開啟標準
|
|
15
|
+
內容編輯器,並儲存寫回到所選檔案。相同的檔案可以
|
|
16
|
+
也可以由 Codex、Claude 程式碼、Agent-Native 側邊欄代理或普通編輯
|
|
17
|
+
編輯器。
|
|
18
|
+
|
|
19
|
+
對於內容,這使得該產品感覺像是 MDX 的開來源黑曜石:
|
|
20
|
+
您的檔案以檔案形式存在,而應用程式新增了可視化編輯器、代理 actions,
|
|
21
|
+
可共用的副本,以及丰富的互動式 MDX 元件。
|
|
22
|
+
|
|
23
|
+
當您想要回購優先的工作流程時,請使用本機檔案模式:
|
|
24
|
+
|
|
25
|
+
- `docs/*.mdx` 的檔案儲存庫
|
|
26
|
+
- `blog/*.mdx` 的博客
|
|
27
|
+
- `resources/*.md` 中的定位、訊息傳遞或團隊筆記等資源
|
|
28
|
+
- 個人黑曜石風格的知識庫,具有更丰富的MDX編輯器
|
|
29
|
+
- 需要從本機 React 程式碼生成的互動式自訂 MDX 塊的檔案
|
|
30
|
+
- 應用程式工件應該易於編碼代理檢查和修補
|
|
31
|
+
|
|
32
|
+
當您需要託管協作應用程式體驗時,請使用資料庫模式:
|
|
33
|
+
多使用者共用、SQL 支持的權限、評論、版本歷史紀錄和
|
|
34
|
+
沒有本機檔案系統存取權限的正式環境託管。
|
|
35
|
+
|
|
36
|
+
## 心智模型
|
|
37
|
+
|
|
38
|
+
有兩種真相來源模式:
|
|
39
|
+
|
|
40
|
+
| 模式 | 事實來源 | 最適合 |
|
|
41
|
+
| ------------ | --------------------------------- | ------------------------------------------------------- |
|
|
42
|
+
| 資料庫模式 | SQL 行至 Drizzle | 託管應用、協作、共用、評論、版本歷史紀錄 |
|
|
43
|
+
| 本機檔案模式 | `agent-native.json`聲明的Repo檔案 | 本機/開發工作流程、Git 審核、編碼代理編輯、檔案本機內容 |
|
|
44
|
+
|
|
45
|
+
UI 和特工 actions 在兩種模式下都應保持相同的形狀。內容
|
|
46
|
+
編輯器仍然編輯檔案;區別在於這些檔案是否解析
|
|
47
|
+
到 SQL 行或本機檔案。
|
|
48
|
+
|
|
49
|
+
```an-diagram title="相同的行為,兩個事實來源" summary="UI 和代理在兩種模式下調用相同的操作。操作層決定每個調用是否解析為 SQL 行或儲存庫檔案。"
|
|
50
|
+
{
|
|
51
|
+
"html": "<div class=\"diagram-mode\"><div class=\"diagram-col entry\"><div class=\"diagram-node\">內容 UI</div><div class=\"diagram-node\">代理 + actions<br><small class=\"diagram-muted\">list/get/update-document</small></div></div><div class=\"diagram-arrow diagram-muted\" aria-hidden=\"true\">→</div><div class=\"diagram-row resolve\"><div class=\"diagram-panel\" data-rough><span class=\"diagram-pill accent\">資料庫模式</span><small class=\"diagram-muted\">SQL rows via Drizzle</small><small class=\"diagram-muted\">託管 · 分享 · 評論 · 歷史</small></div><div class=\"diagram-panel\" data-rough><span class=\"diagram-pill ok\">Local File Mode</span><small class=\"diagram-muted\">repo files via agent-native.json</small><small class=\"diagram-muted\">Git 評審 · 編碼代理編輯</small></div></div></div>",
|
|
52
|
+
"css": ".diagram-mode{display:flex;align-items:center;gap:14px;flex-wrap:wrap}.diagram-mode .diagram-col{display:flex;flex-direction:column;gap:10px}.diagram-mode .diagram-arrow{font-size:22px;line-height:1}.diagram-mode .resolve{display:flex;gap:12px;flex-wrap:wrap}.diagram-mode .diagram-panel{display:flex;flex-direction:column;gap:4px;padding:12px 14px}"
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## 範例儲存庫
|
|
57
|
+
|
|
58
|
+
內容工作區可以像這樣小:
|
|
59
|
+
|
|
60
|
+
```an-file-tree title="一個 Content workspace repo"
|
|
61
|
+
{
|
|
62
|
+
"entries": [
|
|
63
|
+
{ "path": "agent-native.json", "note": "聲明哪些資料夾是內容根以及它們的型別" },
|
|
64
|
+
{ "path": "docs/", "note": "內容根:在側邊欄中顯示為頁面" },
|
|
65
|
+
{ "path": "docs/getting-started.mdx" },
|
|
66
|
+
{ "path": "docs/guides/custom-components.mdx" },
|
|
67
|
+
{ "path": "blog/", "note": "內容根" },
|
|
68
|
+
{ "path": "blog/launch-post.mdx" },
|
|
69
|
+
{ "path": "resources/", "note": "內容根" },
|
|
70
|
+
{ "path": "resources/messaging/positioning.md" },
|
|
71
|
+
{ "path": "components/", "note": "不是內容根:MDX 可匯入的 preview 元件庫" },
|
|
72
|
+
{ "path": "components/FrameworkTabs.tsx" },
|
|
73
|
+
{ "path": "components/Callout.tsx" },
|
|
74
|
+
{ "path": "extensions/", "note": "不是內容根:本機 extension 庫(沙盒 widgets)" },
|
|
75
|
+
{ "path": "extensions/doc-status/extension.json" },
|
|
76
|
+
{ "path": "extensions/doc-status/index.html" }
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
在本機檔案模式下,內容側邊欄顯示 `docs/`、`blog/` 和
|
|
82
|
+
`resources/` 樹為頁面。選取 `docs/getting-started.mdx` 開啟
|
|
83
|
+
標準內容編輯器中的檔案;在 UI 中編輯寫回
|
|
84
|
+
`docs/getting-started.mdx`.
|
|
85
|
+
|
|
86
|
+
`components/` 不是內容根。 MDX
|
|
87
|
+
檔案可以匯入或引用。編輯器可以渲染簡單的本機MDX元件
|
|
88
|
+
無需您克隆或分叉整個內容應用。
|
|
89
|
+
|
|
90
|
+
`extensions/` 也不是內容根。它是一個本機擴充功能庫:
|
|
91
|
+
小型沙盒小部件,可以在應用程式槽中呈現,同時其來源保留在
|
|
92
|
+
儲存庫。
|
|
93
|
+
|
|
94
|
+
## 將內容安裝到儲存庫中
|
|
95
|
+
|
|
96
|
+
對於現有檔案、博客或 MDX 工作區,安裝內容本機檔案
|
|
97
|
+
技能:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
npx @agent-native/core@latest skills add content --mode local-files --scope project
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
這會將 `content` 技能複製到儲存庫的代理技能資料夾中並寫入
|
|
104
|
+
或使用內容預設值更新 `agent-native.json`:
|
|
105
|
+
|
|
106
|
+
- 工作區級別的 `mode: "local-files"`
|
|
107
|
+
- `apps.content.mode: "local-files"`
|
|
108
|
+
- `docs/`、`blog/`、`content/` 和 `resources/` 的內容根
|
|
109
|
+
- `components/` 用於本機 MDX 元件
|
|
110
|
+
- `extensions/` 用於本機擴充功能小部件
|
|
111
|
+
|
|
112
|
+
安裝的技能告訴編碼代理使用內容actions
|
|
113
|
+
(`list-documents`, `get-document`, `edit-document`, `update-document`,
|
|
114
|
+
`share-local-file-document` 和元件檔案 actions)(當本機內容應用時)
|
|
115
|
+
或 Agent Native 桌面橋公開它們。如果沒有橋在執行,則該技能
|
|
116
|
+
退回到安全的直接儲存庫編輯,同時保留 frontmatter、匯入、JSX,
|
|
117
|
+
和未知的 MDX。
|
|
118
|
+
|
|
119
|
+
## 設定
|
|
120
|
+
|
|
121
|
+
將 `agent-native.json` 新增到儲存庫或工作區根目錄:
|
|
122
|
+
|
|
123
|
+
```json
|
|
124
|
+
{
|
|
125
|
+
"version": 1,
|
|
126
|
+
"apps": {
|
|
127
|
+
"content": {
|
|
128
|
+
"mode": "local-files",
|
|
129
|
+
"roots": [
|
|
130
|
+
{
|
|
131
|
+
"name": "Docs",
|
|
132
|
+
"path": "docs",
|
|
133
|
+
"kind": "docs",
|
|
134
|
+
"extensions": [".md", ".mdx"]
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
"name": "Blog",
|
|
138
|
+
"path": "blog",
|
|
139
|
+
"kind": "blog",
|
|
140
|
+
"extensions": [".md", ".mdx"]
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
"name": "Resources",
|
|
144
|
+
"path": "resources",
|
|
145
|
+
"kind": "resources",
|
|
146
|
+
"extensions": [".md", ".mdx"]
|
|
147
|
+
}
|
|
148
|
+
],
|
|
149
|
+
"components": "components",
|
|
150
|
+
"extensions": "extensions",
|
|
151
|
+
"hide": ["**/_*.md", "**/_*.mdx"]
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
您還可以使用 `AGENT_NATIVE_MODE=local-files` 或啟用本機檔案
|
|
158
|
+
`AGENT_NATIVE_DATA_MODE=local-files`;清單是首選,因為它
|
|
159
|
+
在儲存庫本身中紀錄資料夾合同。
|
|
160
|
+
|
|
161
|
+
## 內容檔案格式
|
|
162
|
+
|
|
163
|
+
內容為 Markdown 和 MDX。 Frontmatter 儲存頁面元資料,內文為
|
|
164
|
+
可編輯檔案:
|
|
165
|
+
|
|
166
|
+
```mdx
|
|
167
|
+
---
|
|
168
|
+
title: "開始使用"
|
|
169
|
+
icon: "sparkles"
|
|
170
|
+
isFavorite: true
|
|
171
|
+
updatedAt: "2026-06-12T20:00:00.000Z"
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
# 開始使用
|
|
175
|
+
|
|
176
|
+
Use <FrameworkTabs value="react" /> to show framework-specific code.
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
標題來自 `title` frontmatter(如果存在),否則來自
|
|
180
|
+
檔案名。編輯器保留了 MDX 來源程式碼,但尚無法進行可視化編輯,因此
|
|
181
|
+
編碼代理和普通文本編輯器仍然是安全的逃生艙口。
|
|
182
|
+
|
|
183
|
+
## 自訂 MDX 元件
|
|
184
|
+
|
|
185
|
+
內容可以從設定的 `components` 資料夾中預覽本機元件。
|
|
186
|
+
這適用於檔案樣式的 MDX 元件,例如分頁、標注、包
|
|
187
|
+
安裝片段或特定於框架的程式碼塊。
|
|
188
|
+
|
|
189
|
+
例如,在您的內容旁邊新增一個互動式元件:
|
|
190
|
+
|
|
191
|
+
```tsx
|
|
192
|
+
// components/ImpactCounter.tsx
|
|
193
|
+
import { useState } from "react";
|
|
194
|
+
|
|
195
|
+
export function ImpactCounter({
|
|
196
|
+
label = "points",
|
|
197
|
+
accent = "blue",
|
|
198
|
+
featured = false,
|
|
199
|
+
}: {
|
|
200
|
+
label?: string;
|
|
201
|
+
accent?: "blue" | "green" | "purple";
|
|
202
|
+
featured?: boolean;
|
|
203
|
+
}) {
|
|
204
|
+
const [count, setCount] = useState(3);
|
|
205
|
+
const accentClass =
|
|
206
|
+
accent === "green"
|
|
207
|
+
? "border-green-300 bg-green-50"
|
|
208
|
+
: accent === "purple"
|
|
209
|
+
? "border-purple-300 bg-purple-50"
|
|
210
|
+
: "border-blue-300 bg-blue-50";
|
|
211
|
+
|
|
212
|
+
return (
|
|
213
|
+
<div className={`rounded-md border p-4 ${accentClass}`}>
|
|
214
|
+
<div className="text-sm text-muted-foreground">Launch impact</div>
|
|
215
|
+
<div className="mt-1 text-3xl font-semibold">
|
|
216
|
+
{count} {label}
|
|
217
|
+
</div>
|
|
218
|
+
{featured ? <div className="mt-1 text-sm">Featured metric</div> : null}
|
|
219
|
+
<button
|
|
220
|
+
type="button"
|
|
221
|
+
className="mt-3 rounded border px-3 py-1 text-sm"
|
|
222
|
+
onClick={() => setCount((value) => value + 1)}
|
|
223
|
+
>
|
|
224
|
+
Add point
|
|
225
|
+
</button>
|
|
226
|
+
</div>
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export const ImpactCounterInputs = {
|
|
231
|
+
label: {
|
|
232
|
+
type: "string",
|
|
233
|
+
label: "Metric label",
|
|
234
|
+
default: "points",
|
|
235
|
+
},
|
|
236
|
+
accent: {
|
|
237
|
+
type: "select",
|
|
238
|
+
label: "Accent",
|
|
239
|
+
options: ["blue", "green", "purple"],
|
|
240
|
+
default: "blue",
|
|
241
|
+
},
|
|
242
|
+
featured: {
|
|
243
|
+
type: "boolean",
|
|
244
|
+
label: "Featured",
|
|
245
|
+
default: false,
|
|
246
|
+
},
|
|
247
|
+
};
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
然後從任何本機 MDX 檔案使用它:
|
|
251
|
+
|
|
252
|
+
```mdx
|
|
253
|
+
---
|
|
254
|
+
title: "發布說明"
|
|
255
|
+
---
|
|
256
|
+
|
|
257
|
+
# 發布說明
|
|
258
|
+
|
|
259
|
+
<ImpactCounter label="wins" />
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
內容開發伺服器發現 PascalCase 命名匯出和 PascalCase 預設
|
|
263
|
+
從 `components/` 下的 `.tsx`、`.jsx`、`.ts` 和 `.js` 檔案匯出。那些
|
|
264
|
+
元件在編輯器內呈現並出現在
|
|
265
|
+
**本機元件**。斜線插入建立一個最小的標籤,例如
|
|
266
|
+
`<ImpactCounter />`;需要時在 MDX 來源中新增 props。
|
|
267
|
+
|
|
268
|
+
元件執行有意成為本機開發/桌面橋接功能,而不是
|
|
269
|
+
普通託管瀏覽器資料夾存取。如果你開啟`content.agent-native.com`,
|
|
270
|
+
選取**本機檔案**,並在Chrome中選取一個資料夾,應用程式可以讀寫
|
|
271
|
+
通過瀏覽器檔案系統存取`.md`和`.mdx`檔案API,但是
|
|
272
|
+
Chrome 不會公開 Vite 編譯的絕對資料夾路徑
|
|
273
|
+
`components/*.tsx`。要預覽和熱重載自訂 React 元件,請執行
|
|
274
|
+
本機內容或使用 Agent Native Desktop,以便受信任的本機網橋可以
|
|
275
|
+
將所選工作區註冊到本機內容開發伺服器。在該模式下,
|
|
276
|
+
通過Vite編輯現有元件檔案熱重載,並新增或
|
|
277
|
+
刪除元件檔案會重新載入元件註冊表和斜杠選單。
|
|
278
|
+
|
|
279
|
+
代理還可以使用這些已註冊的元件檔案。使用
|
|
280
|
+
`list-local-component-files` 找到註冊的工作空間id,然後
|
|
281
|
+
`write-local-component-file` 建立或更新 `.tsx`、`.jsx`、`.ts` 或
|
|
282
|
+
`.js` 檔案位於工作區的 `components/` 資料夾下。 MDX 檔案仍然是
|
|
283
|
+
元件使用的真實來源;元件檔案保持正常倉庫
|
|
284
|
+
使用 Git 審核來源檔案。
|
|
285
|
+
|
|
286
|
+
如果元件匯出輸入元資料,則在編輯器中選取該元件
|
|
287
|
+
在元件的右上角顯示一個編輯按鈕。支持的輸入型別
|
|
288
|
+
為 `string`、`textarea`、`number`、`boolean` 和 `select`。表格寫
|
|
289
|
+
更改回 MDX 標籤,因此本機檔案仍然是事實來源。
|
|
290
|
+
元資料可以匯出為 `ComponentNameInputs`、`ComponentNameConfig.inputs`、
|
|
291
|
+
`Component.inputs`,或`agentNative.inputs`。
|
|
292
|
+
|
|
293
|
+
帶有文字屬性的簡單元件標籤可以內聯預覽:
|
|
294
|
+
|
|
295
|
+
```mdx
|
|
296
|
+
<FrameworkTabs value="react" />
|
|
297
|
+
|
|
298
|
+
<Callout type="warning">This setting affects production deploys.</Callout>
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
複雜的 JSX 表達式保留在來源程式碼中。如果編輯者不能安全
|
|
302
|
+
預覽元件道具,它顯示一個警告預留位置而不是
|
|
303
|
+
默默地丟棄資料。
|
|
304
|
+
|
|
305
|
+
## 共用本機檔案
|
|
306
|
+
|
|
307
|
+
本機檔案不會直接共用,因為其他使用者無法讀取路徑
|
|
308
|
+
你的機器。內容工具列的共用按鈕建立或刷新
|
|
309
|
+
所選檔案的資料庫支持副本,導覽到該副本,然後開啟
|
|
310
|
+
正常共用快顯窗口。原始本機檔案保留在本機檔案下;
|
|
311
|
+
資料庫副本出現在本機檔案模式下的共用副本下,並使用
|
|
312
|
+
標準檔案共用模型。
|
|
313
|
+
|
|
314
|
+
## 本機擴充功能
|
|
315
|
+
|
|
316
|
+
本機檔案模式還可以從設定中載入儲存庫支持的擴充功能
|
|
317
|
+
`extensions` 資料夾。每個擴充功能都是一個帶有 `extension.json`
|
|
318
|
+
清單和 HTML 條目檔案:
|
|
319
|
+
|
|
320
|
+
```text
|
|
321
|
+
extensions/
|
|
322
|
+
doc-status/
|
|
323
|
+
extension.json
|
|
324
|
+
index.html
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
```json
|
|
328
|
+
{
|
|
329
|
+
"id": "doc-status",
|
|
330
|
+
"name": "Doc Status",
|
|
331
|
+
"description": "Shows metadata for the selected Content file.",
|
|
332
|
+
"entry": "index.html",
|
|
333
|
+
"slots": ["content.sidebar.bottom"],
|
|
334
|
+
"permissions": {
|
|
335
|
+
"appActions": ["list-documents"],
|
|
336
|
+
"extensionData": true
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
`index.html` 與普通使用的 Alpine/Tailwind 擴充功能主體格式相同
|
|
342
|
+
資料庫支持的擴充功能。當內容應用看到本機擴充功能時
|
|
343
|
+
聲明了 `content.sidebar.bottom`,它在底部呈現該擴充功能
|
|
344
|
+
內容側邊欄。主機通過選取的`window.slotContext`
|
|
345
|
+
檔案 ID、標題、來源元資料以及內容是否處於本機檔案模式。
|
|
346
|
+
|
|
347
|
+
本機擴充功能由應用程式預覽,但作為檔案進行編輯。擴充功能
|
|
348
|
+
列表顯示它們帶有本機檔案徽章,整頁面檢視器指向
|
|
349
|
+
入口檔案。 SQL 支持的擴充功能 actions,例如更新、刪除、共用和
|
|
350
|
+
歷史紀錄不適用;使用您的編輯器、Codex、Claude 程式碼或 Git 歷史紀錄
|
|
351
|
+
來源程式碼更改。
|
|
352
|
+
|
|
353
|
+
對於 v1,本機擴充功能有意保守:
|
|
354
|
+
|
|
355
|
+
- 他們可以將 `extensionData` 用於自己的小型執行時狀態
|
|
356
|
+
- 他們只能調用`extension.json`中列出的`appAction`
|
|
357
|
+
- 原始 SQL 助手和外部 `extensionFetch` 已停用
|
|
358
|
+
- slot 目標在 `extension.json` 中聲明,而不是通過 SQL 安裝
|
|
359
|
+
|
|
360
|
+
這為本機工作空間提供了類似黑曜石的外掛介面,而無需讓
|
|
361
|
+
任意儲存庫檔案繼承資料庫支持的擴充功能的所有功能。
|
|
362
|
+
|
|
363
|
+
## 應用程式如何使用它
|
|
364
|
+
|
|
365
|
+
本機檔案模式是通過框架的本機工件助手實現的。
|
|
366
|
+
應用程式聲明其擁有的工件型別的根,然後讀取和寫入
|
|
367
|
+
通過 UI 和代理已經使用的相同操作介面。
|
|
368
|
+
|
|
369
|
+
對於內容,這意味著:
|
|
370
|
+
|
|
371
|
+
- `list-documents` 列出設定的 `.md` 和 `.mdx` 檔案。
|
|
372
|
+
- `get-document` 讀取選定的本機檔案。
|
|
373
|
+
- `update-document` 寫入選定的本機檔案。
|
|
374
|
+
- `create-document` 在所選資料夾中建立新的本機 `.mdx` 檔案。
|
|
375
|
+
- `delete-document`刪除本機檔案。
|
|
376
|
+
- 搜尋在設定的本機檔案中執行。
|
|
377
|
+
|
|
378
|
+
不能從內容 UI 中行動、重命名和重新排序本機檔案頁面
|
|
379
|
+
尚支持。在工作區或使用編碼代理執行這些操作;
|
|
380
|
+
內容側邊欄將反映生成的檔案樹。
|
|
381
|
+
|
|
382
|
+
這使代理合約變得簡單:代理可以繼續使用內容 actions,
|
|
383
|
+
而這些 actions 決定目標是 SQL 支持的還是檔案支持的。
|
|
384
|
+
|
|
385
|
+
隨著時間的推移,其他應用程式可以采用相同的模式。幻燈片應用程式可以對應
|
|
386
|
+
`slides/*.mdx` 到甲板,計畫應用程式可以將 `plans/*` 對應到計畫檔案,以及
|
|
387
|
+
儀表板應用程式可以將 `dashboards/*.mdx` 對應到儀表板。那些特定於應用程式的
|
|
388
|
+
資料夾是位於同一本機工件合約之上的約定。
|
|
389
|
+
|
|
390
|
+
## 本機檔案與匯出/匯入
|
|
391
|
+
|
|
392
|
+
內容有兩種不同的檔案工作流程:
|
|
393
|
+
|
|
394
|
+
| 工作流程 | 發生了什么 |
|
|
395
|
+
| ------------------------ | ------------------------------------------------------------------------ |
|
|
396
|
+
| `/local-files` 匯出/匯入 | 資料庫模式仍然是事實來源。檔案是您匯出、編輯、預覽和匯入的顯式同步表面。 |
|
|
397
|
+
| 本機檔案模式 | 檔案是真相的來源。內容側邊欄和編輯器直接對本機檔案進行操作。 |
|
|
398
|
+
|
|
399
|
+
當您需要偶爾檢視託管工作區的檔案時,請使用匯出/匯入。
|
|
400
|
+
當儲存庫本身是工作區時,使用本機檔案模式。
|
|
401
|
+
|
|
402
|
+
## 歷史與合作
|
|
403
|
+
|
|
404
|
+
本機檔案模式依賴於檔案本機歷史紀錄:
|
|
405
|
+
|
|
406
|
+
- 向 Git 提交重要更改
|
|
407
|
+
- 使用拉取請求進行審核
|
|
408
|
+
- 讓編碼代理直接編輯相同的檔案
|
|
409
|
+
- 使用普通檔案差異來了解更改
|
|
410
|
+
|
|
411
|
+
資料庫模式仍然更適合託管協作功能,例如
|
|
412
|
+
共用、評論、SQL 支持的版本歷史紀錄和實時多使用者編輯。
|
|
413
|
+
|
|
414
|
+
提供者同步可以分層在任一模式之上。例如,檔案儲存庫可以
|
|
415
|
+
新增 actions,將內容從 CMS 提取到本機 MDX 檔案或推送所選內容
|
|
416
|
+
本機檔案返回到那個CMS。
|
|
417
|
+
|
|
418
|
+
## 安全正式環境
|
|
419
|
+
|
|
420
|
+
本機檔案模式為應用程式 actions 提供對設定的工作區的直接寫入存取權限
|
|
421
|
+
檔案。這適合本機開發和可信單租戶檔案
|
|
422
|
+
橋梁,但它不是預設的正式環境安全模型。
|
|
423
|
+
|
|
424
|
+
當 `NODE_ENV=production` 時,框架拒絕 `local-files` 模式,除非您
|
|
425
|
+
設定:
|
|
426
|
+
|
|
427
|
+
```bash
|
|
428
|
+
AGENT_NATIVE_ALLOW_LOCAL_FILES_IN_PRODUCTION=true
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
僅針對受信任的單租戶部署進行設定,其中每個人都可以使用
|
|
432
|
+
應用程式可以讀取和寫入設定的檔案。對於普通託管,
|
|
433
|
+
多使用者應用程式,使用資料庫模式和SQL支持的共用。
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "MCP 應用程式"
|
|
3
|
+
description: "使用真實應用路由、嵌入橋和主機橋 API,在 Claude、ChatGPT 和其他兼容主機中編寫和嵌入互動式 MCP 應用 UI。"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# MCP 應用程式
|
|
7
|
+
|
|
8
|
+
**此頁面:Claude/ChatGPT 中的內聯 UI。** 創作 MCP 應用程式資源以及在兼容主機的聊天中呈現真實應用程式路由的嵌入橋。此頁面也是**客戶支持矩陣** ([below](#client-support)) 的單一主頁面。
|
|
9
|
+
|
|
10
|
+
| 如果你想…… | 閱讀 |
|
|
11
|
+
| ------------------------------------------------- | ---------------------------------------- |
|
|
12
|
+
| 將外部代理/主機連線到您的應用 | [External Agents](/docs/external-agents) |
|
|
13
|
+
| 為您的代理提供更多工具(使用其他 MCP 伺服器) | [MCP Clients](/docs/mcp-clients) |
|
|
14
|
+
| 建置在 Claude/ChatGPT 中渲染的內聯 UI | **此頁面** — MCP 應用 |
|
|
15
|
+
| 較低級別的 MCP 伺服器參考(驗證、工具、自訂掛載) | [MCP Protocol](/docs/mcp-protocol) |
|
|
16
|
+
|
|
17
|
+
MCP 應用程式是官方的 `io.modelcontextprotocol/ui` 擴充功能,可讓兼容主機(Claude、Claude Desktop、ChatGPT、VS Code GitHub Copilot、Goose、Postman、MCPJam 和 Cursor)在聊天中渲染互動式 UI。在代理原生應用程式中,每個 MCP 應用程式都是**真正的 React 路由**,而不是單獨的普通 HTML 小部件。
|
|
18
|
+
|
|
19
|
+
在 Agent-Native 應用自己的聊天中,首選 [native chat renderers](/docs/native-chat-ui) 作為第一方小部件,例如表格、圖表、鍵入的結果和批準功能可供性。在 Claude、ChatGPT、Copilot、Cursor 和其他兼容主機中使用 MCP 應用程式進行外部/跨主機內聯 UI,並使用操作 `link` 作為通用深層連結回退。
|
|
20
|
+
|
|
21
|
+
## 創作:可選的 MCP 應用 UI {#mcp-apps}
|
|
22
|
+
|
|
23
|
+
對於支持 MCP 應用擴充功能的主機,操作還可以使用 `mcpApp` 通告內聯 UI 資源。這是對流程的漸進增強,外部代理應向使用者提供互動式介面而不僅僅是文本,例如檢視電子郵件草稿、編輯行事曆邀請或在生成的儀表板變體之間進行選取。
|
|
24
|
+
|
|
25
|
+
每當使用者需要 UI 時,將真正的 React 應用程式與 `embedRoute()` 或 `embedApp()` 一起使用。思維模型很簡單:操作的 `link` 目標也是 MCP 應用程式嵌入目標。將操作公開為正常操作/工具,返回與 `link` 相關的深層連結,並新增 `mcpApp.resource = embedApp(...)`,以便有能力的主機內聯載入相同的路由,而不是開啟新分頁。當兩者都應該從同一路由建置時,更喜歡 `embedRoute({ title, openLabel, path })`:它是一種方便的包裝器,可以從一次調用中返回匹配的 `link` 和 `mcpApp` 欄位,而 `embedApp(...)` 是您直接分配給 `mcpApp.resource` 的較低級別資源。
|
|
26
|
+
|
|
27
|
+
這意味著完整的應用程式嵌入可以執行路由開啟後可以執行的任何操作:檢視或編輯電子郵件草稿、顯示過濾的收件箱/搜尋、開啟行事曆事件或事件草稿、載入擴充功能頁面、檢查完整的分析儀表板或儲存的分析、在幻燈片編輯器中繼續幻燈片或開啟設計專案/編輯器。優先選取 URL/深層連結參數和現有的 `/_agent-native/open` 導覽/應用程式狀態橋,而不是為 MCP 應用程式發明第二個狀態協議。
|
|
28
|
+
|
|
29
|
+
在極少數情況下,正確的目標是渲染一個共用 React 元件而不是整個應用程式 shell 的集中應用程式路徑。 Analytics 的 `/chart` 路線就是模型:它在 URL 中采用緊湊的 `SqlPanel` 有效負載,並呈現儀表板使用的相同圖表元件。這仍然是一個應用程式嵌入,而不是一個普通的 HTML MCP 應用程式。通過正常操作 / `open_app({ path, embed: true })` 公開或調用它,保持 URL 的確定性,並讓 `embedApp()` 內聯渲染該路由。
|
|
30
|
+
|
|
31
|
+
請勿為產品 UI 手寫一次性普通 HTML MCP 應用程式;如果操作需要自訂介面,請首先新增或重用真實的應用程式路由/元件並嵌入該路由。
|
|
32
|
+
|
|
33
|
+
```an-diagram title="MCP 應用程式嵌入往返" summary="該操作的連結目標也是嵌入目標。有能力的主機內聯載入相同的簽名應用程式路由;其他人都回到深層連結。"
|
|
34
|
+
{
|
|
35
|
+
"html": "<div class=\"diagram-embed\"><div class=\"diagram-card\" data-rough><strong>Action</strong><small class=\"diagram-muted\">`link` target = MCP App embed target</small></div><div class=\"diagram-arrow diagram-muted\" aria-hidden=\"true\">→</div><div class=\"diagram-card\" data-rough><strong>embedApp()</strong><span class=\"diagram-pill accent\">create_embed_session</span><small class=\"diagram-muted\">mints short-lived embed session</small></div><div class=\"diagram-arrow diagram-muted\" aria-hidden=\"true\">→</div><div class=\"diagram-card\" data-rough><strong>/_agent-native/embed/start</strong><small class=\"diagram-muted\">交換一次性 SQL ticket</small></div><div class=\"diagram-arrow diagram-muted\" aria-hidden=\"true\">→</div><div class=\"diagram-card\" data-rough><strong>Signed app route</strong><span class=\"diagram-pill ok\">真實 React 路由</span><small class=\"diagram-muted\">short-lived browser session</small></div><div class=\"diagram-fallback\"><span class=\"diagram-pill warn\">不支持 MCP Apps</span><div class=\"diagram-arrow diagram-muted\" aria-hidden=\"true\">↓</div><div class=\"diagram-box\" data-rough>"Open in … →" deep link</div></div></div>",
|
|
36
|
+
"css": ".diagram-embed{display:flex;align-items:center;gap:12px;flex-wrap:wrap}.diagram-embed .diagram-card{display:flex;flex-direction:column;gap:6px;padding:14px 16px;min-width:140px}.diagram-embed .diagram-arrow{font-size:22px;line-height:1}.diagram-embed .diagram-fallback{display:flex;flex-direction:column;align-items:center;gap:6px;margin-inline-start:8px}"
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import { embedApp } from "@agent-native/core";
|
|
43
|
+
|
|
44
|
+
export default defineAction({
|
|
45
|
+
// ...description, schema, run, link...
|
|
46
|
+
mcpApp: {
|
|
47
|
+
resource: embedApp({
|
|
48
|
+
title: "Review draft",
|
|
49
|
+
description: "Open the generated draft in the real Mail compose UI.",
|
|
50
|
+
iframeTitle: "Agent-Native Mail",
|
|
51
|
+
openLabel: "Open in Mail",
|
|
52
|
+
}),
|
|
53
|
+
},
|
|
54
|
+
});
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
```an-annotated-code title="mcpApp 資源設定"
|
|
58
|
+
{
|
|
59
|
+
"filename": "actions/review-draft.ts",
|
|
60
|
+
"language": "ts",
|
|
61
|
+
"code": "import { embedApp } from \"@agent-native/core\";\n\nexport default defineAction({\n // ...description, schema, run, link...\n mcpApp: {\n resource: embedApp({\n title: \"Review draft\",\n description: \"Open the generated draft in the real Mail compose UI.\",\n iframeTitle: \"Agent-Native Mail\",\n openLabel: \"Open in Mail\",\n }),\n },\n});",
|
|
62
|
+
"annotations": [
|
|
63
|
+
{ "lines": "6", "label": "漸進增強", "note": "`mcpApp.resource` 為支持 MCP 應用擴充功能的主機宣傳內聯 UI。也保留操作的 `link` 建置器 - 僅 CLI 和較舊的主機會忽略 UI 元資料,但仍然需要深層連結。" },
|
|
64
|
+
{ "lines": "7", "label": "Embed = the link target", "note": "`embedApp()` uses the action's `link` as its launch target: it calls `create_embed_session`, exchanges a one-time SQL ticket at `/_agent-native/embed/start`, and navigates the MCP App frame to the same signed app route." },
|
|
65
|
+
{ "lines": "11", "label": "通用後備標籤", "note": "`openLabel` is the visible `\"Open in … →\"` text used as the deep-link escape hatch when a host does not render the inline iframe." }
|
|
66
|
+
]
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
MCP 伺服器通告擴充功能 `io.modelcontextprotocol/ui`,將 `_meta.ui.resourceUri` 和 `_meta["ui/resourceUri"]` 新增到 `tools/list`,並且還發出 ChatGPT 應用 SDK 兼容性元資料(`openai/outputTemplate`、小部件 CSP/描述/可存取性)。它通過 `resources/list`、`resources/templates/list` 和 `resources/read` 使用 MIME `text/html;profile=mcp-app` 公開 HTML。 stdio 代理從實時應用程式轉發這些資源處理程序,因此桌面和 CLI 用戶端可以看到與 HTTP 用戶端相同的資源。
|
|
71
|
+
|
|
72
|
+
即使新增 `mcpApp` 也保留現有的 `link` 建置器。僅 CLI 的用戶端、較舊的主機以及任何不呈現 MCP 應用程式的主機將忽略 UI 元資料,並且仍然需要 `"Open in … →"` 連結。 `embedApp()` 使用該連結作為其啟動目標,調用僅應用程式的 `create_embed_session` 幫助程序,在 `/_agent-native/embed/start` 交換一次性 SQL 票證,並通過短暫的瀏覽器工作階段以及同來源提取的承載回退將 MCP 應用程式框架導覽到目標路由。 `open_app({ app, path, embed: true })` 是用於完整儀表板、過濾收件箱、行事曆草稿視圖、分析和擴充功能頁面等路線的通用逃生口,當完整應用程式是最清晰的審查/編輯介面時,應廣泛使用。
|
|
73
|
+
|
|
74
|
+
`embedApp()` 在資源 CSP 中包含 MCP 請求來源,以便啟動器可以獲取並在明確請求時建置已簽名的第一方應用程式路由。 Dispatch 將授予的應用程式的確切來源新增到其 `open_app` 資源中,以便單個 Dispatch 連線器可以內聯郵件、行事曆、幻燈片和其他內容,而無需允許每個 HTTPS 來源。僅為真正嵌入第三方播放器或載入第三方資源的自訂 MCP 應用傳遞額外的框架或資源域。
|
|
75
|
+
|
|
76
|
+
在這些 `embedApp()` 路由中,`sendToAgentChat()` 是嵌入感知的。自動提交的提示會以 `ui/update-model-context` 加 `ui/message` 的形式中繼到 MCP 主機,因此嵌入式應用程式中的按鈕可以有意從所選應用程式狀態繼續 Claude/ChatGPT 對話。隱藏上下文作為模型上下文發送;可見的使用者轉向僅保留應用程式的提示,這避免了圍繞內部應用程式狀態檔案路徑的可怕的主機同意。 `submit: false` 保留本機預填充/審核行為。
|
|
77
|
+
|
|
78
|
+
## 一流的MCP應用橋 {#mcp-app-bridge}
|
|
79
|
+
|
|
80
|
+
MCP 應用嵌入是路線嵌入,而不是單獨的迷你產品。 `embedApp()` 從操作的 `link` 目標開始,建立一個短暫的嵌入工作階段,並啟動該簽名的應用程式路由。當主機可以直接水合路線時,標準 MCP 應用程式主機可以自行導覽 MCP 應用程式框架。
|
|
81
|
+
|
|
82
|
+
```an-diagram title="兩條主橋路徑,一條簽名路由" summary="克勞德移植了水合路線,使用直接ui/_bridge; ChatGPT 通過 window.openai 獲取受控 iframe,並通過 postMessage 中繼主機操作。兩者都指向同一個簽名的應用程式路由。"
|
|
83
|
+
{
|
|
84
|
+
"html": "<div class=\"diagram-bridge\"><div class=\"diagram-col\"><div class=\"diagram-card\" data-rough><strong>Claude web</strong><span class=\"diagram-pill accent\">single-frame transplant</span><small class=\"diagram-muted\">在 Claude iframe 中激活已簽名的應用 HTML,然後使用直接 `ui/_` 主機橋</small></div><div class=\"diagram-card\" data-rough><strong>ChatGPT web</strong><span class=\"diagram-pill accent\">controlled route iframe</span><small class=\"diagram-muted\">`window.openai`host APIs ·`agentNative.mcpHost.*` postMessage relay</small></div></div><div class=\"diagram-arrow diagram-muted\" aria-hidden=\"true\">→</div><div class=\"diagram-box\" data-rough>Same signed app route<br><small class=\"diagram-muted\">普通路由 + React 元件</small></div></div>",
|
|
85
|
+
"css": ".diagram-bridge{display:flex;align-items:center;gap:14px;flex-wrap:wrap}.diagram-bridge .diagram-col{display:flex;flex-direction:column;gap:12px}.diagram-bridge .diagram-card{display:flex;flex-direction:column;gap:6px;padding:14px 16px;max-width:300px}.diagram-bridge .diagram-arrow{font-size:22px;line-height:1}.diagram-bridge .diagram-box{padding:16px 18px;text-align:center}"
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Claude Web 使用單框架移植路徑:資源檔案獲取已簽名的應用程式 HTML 並將其水合到 Claude 的 MCP 應用程式 iframe 中,因為 Claude 無法可靠地允許應用程式擁有的子 iframe 或外部框架導覽。 ChatGPT Web 獲得受控路由 iframe,因為它的 Apps 橋為我們提供了穩定的 `window.openai` 主機 API 和有界高度控制。所有路徑都指向相同的簽名應用程式路由並渲染正常路由和 React 元件。設計嵌入式路由,以便使用相同簽名的 URL 重新載入可以重建相同的視圖。
|
|
91
|
+
|
|
92
|
+
對於同一應用程式 `open_app({ embed: true })`,框架在原始工具調用期間建立嵌入啟動票證,並將簽名的啟動 URL 存儲在隱藏的工具元資料中。定制actions可以返回`embedStartUrl`相同的快速路徑; MCP 層將票證 URL 從模型可見的 `structuredContent` 和正常的開放連結元資料中剝離。當不存在嵌入啟動 URL 時,資源將回退到僅應用程式的 `create_embed_session` 幫助程序。這使得正式環境主機能夠在直接路由上限制 iframe 發起的工具調用,而不會將一次性應用程式工作階段 URL 泄漏到紀錄中。如果使用者在一次性啟動票過期後重新開啟舊聊天,啟動路由將返回一個小刷新頁面並將 `agentNative.embedSessionExpired` 發布到包裝器; `embedApp()` 清除陳舊的開始 URL,並在仍具有原始應用程式路由的情況下通過 `create_embed_session` 鑄造新票。
|
|
93
|
+
|
|
94
|
+
ChatGPT通過`window.openai`獲得專用的兼容路徑:啟動檔案直接讀取`toolInput`、`toolOutput`和`toolResponseMetadata`,然後通過`window.openai.callTool(...)`調用`create_embed_session`。標準 MCP 應用程式主機使用 `ui/*` JSON-RPC 橋接器。直接水合路由可以通過主橋助手調用`ui/update-model-context`、`ui/message`、`ui/open-link`和`ui/request-display-mode`。 Claude的移植路線在水合後使用相同的直接`ui/*`主橋。當使用 ChatGPT 或顯式診斷 iframe 路徑時,包裝器通過 `agentNative.mcpHost.*` postMessage 請求中繼同一主機 actions。保持兩條路徑的結果形狀相同:返回集中的 `link` 和簡潔的結構化內容。
|
|
95
|
+
|
|
96
|
+
請勿將標準 `_meta.ui.domain` 設定為應用程式 URL。 MCP Apps 將該欄位視為特定於主機的欄位:Claude 驗證 `{hash}.claudemcpcontent.com` 樣式的沙箱域,而 ChatGPT 使用自己的 `openai/widgetDomain` 元資料。除非您故意發出特定於主機的值,否則請省略 `ui.domain`;主機將選取預設沙箱來源。
|
|
97
|
+
|
|
98
|
+
擴充功能頁面將其沙箱保留在 MCP 聊天嵌入中,而無需導覽第二個路由 iframe。正常應用程式使用會將 `/_agent-native/extensions/:id/render` 呈現為沙盒子 iframe。在 MCP 聊天橋模式下,框架在路由 iframe 內呈現與沙箱 `srcDoc` 相同的擴充功能檔案,避免主機 `frame-ancestors` / `X-Frame-Options` 故障,同時保留 `sandbox="allow-scripts allow-forms"`。
|
|
99
|
+
|
|
100
|
+
資源 shell 擁有外部主機大小。 `embedApp({ height })`預設為`560px`,將外殼夾到`320-900px`,並為小工具列保留`44px`,因此路線視口為`height - 44px`。保持嵌入式應用程式路由內部可滾動,並讓啟動器報告有界的固有高度而不是完整的檔案高度;否則主機自動調整大小可以將一個普通的應用頁面變成一個很高的聊天神器。更改的 shell 僅影響新的 MCP App 資源和新的工具調用。舊的 ChatGPT/Claude 對話框架可以保留以前的資源行為,因此在判斷修複之前使用新的內聯渲染驗證大小。
|
|
101
|
+
|
|
102
|
+
### 嵌入模式 {#embed-modes}
|
|
103
|
+
|
|
104
|
+
Claude預設使用單幀移植路徑。在偵錯主機模塊載入行為時,您還可以在具有 `embedMode: "transplant"` 或 `frame: "transplant"` 的其他主機中強制使用它。您可以使用 `embedMode: "iframe"`、`renderMode: "iframe"`、`nested: true` 或 `frame: "iframe"` 強制嵌套診斷 iframe。如果 iframe 被阻止,`embedApp()` 會將其替換為開放應用後備:使用者可以重試內聯、通過主機開啟新建立的嵌入工作階段,或使用可見路由 URL。保持動作的 `link` 目標本身有用,因為它仍然是通用逃生艙口。
|
|
105
|
+
|
|
106
|
+
通過 ngrok 測試 Claude 時,請使用正式環境版本(`npx @agent-native/core@latest build` 然後 `npx @agent-native/core@latest start`)或已部署的預覽/正式環境 URL。 Claude的單幀移植路徑適用於正式環境資產塊;原始 Vite 開發模塊(例如 `/app/root.tsx`)可以受到應用程式驗證的保護,並且無法從 Claude 資源來源進行動態匯入。
|
|
107
|
+
|
|
108
|
+
## 主橋API {#host-bridge}
|
|
109
|
+
|
|
110
|
+
主橋故意很小:
|
|
111
|
+
|
|
112
|
+
| 模式 | 訊息型別 | 使用它 |
|
|
113
|
+
| --------------------- | ------------------------------------- | --------------------------------- |
|
|
114
|
+
| 直接主機路由 | `ui/update-model-context` | 宿主模型的隱藏上下文 |
|
|
115
|
+
| 直接主機路由 | `ui/message` | 將可見使用者轉入主機 |
|
|
116
|
+
| 直接主機路由 | `ui/open-link` | 通過主機開啟外部或應用程式URL |
|
|
117
|
+
| 直接主機路由 | `ui/request-display-mode` | 請求`inline`、`fullscreen`或`pip` |
|
|
118
|
+
| Claude移植 | `ui/*` | 水合後相同的直接主橋 |
|
|
119
|
+
| ChatGPT / iframe 路由 | `agentNative.mcpHostContext` | 主題、區域設定、主機平台、維度 |
|
|
120
|
+
| ChatGPT / iframe 路由 | `agentNative.embeddedAppReady` | 確認路由iframe載入 |
|
|
121
|
+
| ChatGPT / iframe 路由 | `agentNative.mcpHost.*` / `.response` | 主機請求的包裝中繼 |
|
|
122
|
+
|
|
123
|
+
嵌入式路由可以使用 `@agent-native/core/client` 中的 `updateMcpAppModelContext()`、`openMcpAppHostLink()`、`requestMcpAppDisplayMode()`、`getMcpAppHostContext()` 和 `useMcpAppHostContext()`。 `sendToAgentChat()` 使用完整應用程式嵌入中的相同路徑來自動提交提示。
|
|
124
|
+
|
|
125
|
+
顯示模式是盡力而為。應用內 `McpAppRenderer` 目前報告內聯 Web 主機上下文和僅內聯顯示模式;外部主機可能會接受較大的顯示請求、忽略它們或回複不支持模式的錯誤。始終保持內聯路由可用。
|
|
126
|
+
|
|
127
|
+
## 用戶端支持和快取 {#client-support}
|
|
128
|
+
|
|
129
|
+
目前MCP Apps官方用戶端列表包括Claude、Claude Desktop、VS Code GitHub Copilot、Goose、Postman、MCPJam、ChatGPT、Cursor;主機支持仍然因計畫、發布渠道和用戶端版本而異,因此請檢查 [MCP extension support matrix](https://modelcontextprotocol.io/extensions/client-matrix)。 ChatGPT 自訂 MCP 應用程式可通過 ChatGPT Web 上的商業和企業/教育工作區的開發人員模式使用;請參閱 OpenAI 的 [developer mode and MCP apps](https://help.openai.com/en/articles/12584461-developer-mode-and-full-mcp-apps-in-chatgpt-beta) 注釋。
|
|
130
|
+
|
|
131
|
+
Claude Code、Codex 和其他 CLI/程式碼編輯器用戶端在支持 MCP 應用程式時仍會收到相同的資源和元資料,但將它們視為連結輸出主機,除非您已在該確切表面中驗證了內聯 iframe 渲染。當主機選取不渲染 iframe 時,深層連結仍然是可靠的後備方案。實際上,每個代理本機應用程式都應使用以下兩種方式編寫:用於在有能力的主機中進行內聯審核/編輯的 MCP 應用程式,以及用於通用往返返回完整應用程式的 `link` 應用程式。
|
|
132
|
+
|
|
133
|
+
Claude 和 ChatGPT 可以快取現有自訂連線器的工具和資源元資料。更改MCP App元資料後,使用新的工具調用進行驗證;如果主機仍使用舊描述符,請重新連線 Claude 連線器或重新掃描/檢查 ChatGPT 連線器,以便刷新目錄。如果部署後 Claude 在工具描述符上紀錄了有關 `_meta.ui.csp` 或 `_meta.ui.permissions` 的警告,則該連線器正在使用過時的元資料:刪除/重新連線 Claude 連線器並開始新的聊天。
|
|
134
|
+
|
|
135
|
+
## 測試 {#testing}
|
|
136
|
+
|
|
137
|
+
使用`embedApp()`和`McpAppRenderer`週圍的輕量級夾具測試MCP應用程式;它們涵蓋 CSP、主機上下文、應用程式啟動和橋接訊息行為,而無需真正的外部主機。驗證 ChatGPT 或 Claude Web 時,在 shell 更改後觸發新的工具調用並測量可見的 iframe。同一對話中先前渲染的幀可能仍會顯示快取的高度或啟動行為。
|
|
138
|
+
|
|
139
|
+
## 相關 {#related}
|
|
140
|
+
|
|
141
|
+
- [External Agents](/docs/external-agents) — 將 Claude、ChatGPT、Codex 和 Cursor 連線到託管應用程式; MCP 應用程式兼容性矩陣;目錄層;深層連結。
|
|
142
|
+
- [MCP Protocol](/docs/mcp-protocol) — 自動安裝的 MCP 伺服器、驗證、工具和 `ask-agent`。
|
|
143
|
+
- [Actions](/docs/actions) — `defineAction`,`link` 建置者,`publicAgent`。
|
|
144
|
+
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
```
|