@agent-native/core 0.112.0 → 0.114.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/agent-native.eject.json +164 -0
- package/corpus/README.md +4 -2
- package/corpus/core/CHANGELOG.md +33 -0
- package/corpus/core/README.md +61 -174
- package/corpus/core/agent-native.eject.json +164 -0
- package/corpus/core/docs/AGENTS.md +7 -0
- package/corpus/core/docs/content/agent-native-toolkit.mdx +38 -0
- package/corpus/core/docs/content/integrations.mdx +63 -2
- package/corpus/core/docs/content/package-lifecycle.mdx +54 -4
- package/corpus/core/docs/design/provider-integration-authority.md +117 -0
- package/corpus/core/package.json +20 -2
- package/corpus/core/scripts/materialize-source-corpus.mjs +9 -2
- package/corpus/core/src/cli/atomic-json-file.ts +324 -0
- package/corpus/core/src/cli/claude-code-participant.ts +515 -0
- package/corpus/core/src/cli/code-agent-executor.ts +18 -10
- package/corpus/core/src/cli/code-agent-runs.concurrent-worker.ts +33 -0
- package/corpus/core/src/cli/code-agent-runs.ts +55 -62
- package/corpus/core/src/cli/codex-cli-participant.ts +496 -0
- package/corpus/core/src/cli/eject.ts +1594 -0
- package/corpus/core/src/cli/index.ts +16 -0
- package/corpus/core/src/cli/multi-frontier-runs.ts +1246 -135
- package/corpus/core/src/client/chat/ChatHistoryList.tsx +7 -404
- package/corpus/core/src/client/index.ts +4 -0
- package/corpus/core/src/client/resources/McpConnectionSuggestion.tsx +8 -2
- package/corpus/core/src/client/resources/McpIntegrationDialog.tsx +7 -2
- package/corpus/core/src/client/resources/ResourcesPanel.tsx +17 -3
- package/corpus/core/src/client/resources/index.ts +19 -0
- package/corpus/core/src/client/resources/mcp-integration-catalog.ts +9 -1
- package/corpus/core/src/client/resources/runtime.ts +1 -0
- package/corpus/core/src/client/setup-connections/catalog.ts +6 -0
- package/corpus/core/src/client/setup-connections/index.ts +1 -0
- package/corpus/core/src/client/setup-connections/runtime.ts +1 -0
- package/corpus/core/src/connections/catalog.ts +41 -24
- package/corpus/core/src/connections/index.ts +1 -0
- package/corpus/core/src/connections/runtime.ts +1 -0
- package/corpus/core/src/eject/provider-api-definitions.ts +193 -0
- package/corpus/core/src/eject/remote-mcp-presets.ts +137 -0
- package/corpus/core/src/eject/setup-readiness-ui.tsx +29 -0
- package/corpus/core/src/eject/workspace-connections.ts +92 -0
- package/corpus/core/src/index.ts +1 -0
- package/corpus/core/src/integrations/adapter-overrides.ts +12 -0
- package/corpus/core/src/integrations/eject/messaging-adapters.ts +85 -0
- package/corpus/core/src/integrations/index.ts +15 -1
- package/corpus/core/src/integrations/plugin.ts +34 -12
- package/corpus/core/src/integrations/runtime.ts +1 -0
- package/corpus/core/src/integrations/slack-oauth.ts +1 -0
- package/corpus/core/src/integrations/types.ts +3 -1
- package/corpus/core/src/integrations/webhook-delivery.ts +55 -0
- package/corpus/core/src/notifications/channels.ts +4 -10
- package/corpus/core/src/package-lifecycle/eject-manifest.ts +345 -0
- package/corpus/core/src/package-lifecycle/index.ts +1 -0
- package/corpus/core/src/provider-api/actions/custom-provider-registration.ts +197 -0
- package/corpus/core/src/provider-api/actions/delete-staged-dataset.ts +3 -42
- package/corpus/core/src/provider-api/actions/list-staged-datasets.ts +3 -45
- package/corpus/core/src/provider-api/actions/provider-api-audit.ts +88 -0
- package/corpus/core/src/provider-api/actions/provider-api.ts +460 -0
- package/corpus/core/src/provider-api/actions/query-staged-dataset.ts +3 -140
- package/corpus/core/src/provider-api/actions/staged-datasets.ts +359 -0
- package/corpus/core/src/provider-api/gong.ts +108 -0
- package/corpus/core/src/provider-api/index.ts +46 -12
- package/corpus/core/src/provider-api/runtime.ts +1 -0
- package/corpus/core/src/scripts/docs/source-search.ts +2 -1
- package/corpus/core/src/server/google-oauth-credentials.ts +80 -3
- package/corpus/core/src/server/index.ts +6 -0
- package/corpus/core/src/setup-connections/index.ts +1 -0
- package/corpus/core/src/shared/merge-by-id.ts +14 -0
- package/corpus/core/src/styles/chat-history-list.css +1 -313
- package/corpus/core/src/templates/default/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/core/src/templates/default/.agents/skills/agent-native-docs/SKILL.md +21 -9
- package/corpus/core/src/templates/default/.agents/skills/customizing-agent-native/SKILL.md +145 -0
- package/corpus/core/src/templates/default/.agents/skills/integration-webhooks/SKILL.md +323 -0
- package/corpus/core/src/templates/default/.agents/skills/onboarding/SKILL.md +56 -0
- package/corpus/core/src/templates/default/.agents/skills/secrets/SKILL.md +273 -0
- package/corpus/core/src/templates/default/.agents/skills/self-modifying-code/SKILL.md +14 -2
- package/corpus/core/src/templates/default/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/core/src/templates/default/AGENTS.md +26 -18
- package/corpus/core/src/templates/headless/.agents/skills/actions/SKILL.md +512 -0
- package/corpus/core/src/templates/headless/.agents/skills/agent-native-docs/SKILL.md +21 -9
- package/corpus/core/src/templates/headless/.agents/skills/customizing-agent-native/SKILL.md +145 -0
- package/corpus/core/src/templates/headless/.agents/skills/integration-webhooks/SKILL.md +323 -0
- package/corpus/core/src/templates/headless/.agents/skills/secrets/SKILL.md +273 -0
- package/corpus/core/src/templates/headless/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/core/src/templates/headless/AGENTS.md +8 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/core/src/templates/workspace-core/.agents/skills/agent-native-docs/SKILL.md +21 -9
- package/corpus/core/src/templates/workspace-core/.agents/skills/agent-native-toolkit/SKILL.md +7 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/customizing-agent-native/SKILL.md +145 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/self-modifying-code/SKILL.md +14 -2
- package/corpus/core/src/templates/workspace-core/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/core/src/templates/workspace-core/AGENTS.md +4 -0
- package/corpus/core/src/templates/workspace-root/AGENTS.md +4 -0
- package/corpus/core/src/vite/client.ts +25 -2
- package/corpus/templates/analytics/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/analytics/.agents/skills/customizing-agent-native/SKILL.md +145 -0
- package/corpus/templates/analytics/.agents/skills/self-modifying-code/SKILL.md +14 -2
- package/corpus/templates/analytics/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/analytics/actions/delete-staged-dataset.ts +3 -23
- package/corpus/templates/analytics/actions/list-staged-datasets.ts +3 -27
- package/corpus/templates/analytics/actions/provider-api-catalog.ts +16 -19
- package/corpus/templates/analytics/actions/provider-api-docs.ts +3 -5
- package/corpus/templates/analytics/actions/provider-api-request.ts +162 -185
- package/corpus/templates/analytics/actions/query-staged-dataset.ts +3 -47
- package/corpus/templates/analytics/app/components/layout/Sidebar.tsx +52 -161
- package/corpus/templates/assets/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/assets/.agents/skills/customizing-agent-native/SKILL.md +145 -0
- package/corpus/templates/assets/.agents/skills/self-modifying-code/SKILL.md +14 -2
- package/corpus/templates/assets/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/assets/app/components/layout/Sidebar.tsx +63 -160
- package/corpus/templates/brain/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/brain/.agents/skills/customizing-agent-native/SKILL.md +145 -0
- package/corpus/templates/brain/.agents/skills/self-modifying-code/SKILL.md +14 -2
- package/corpus/templates/brain/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/brain/actions/_schemas.ts +13 -7
- package/corpus/templates/brain/actions/delete-staged-dataset.ts +3 -24
- package/corpus/templates/brain/actions/list-staged-datasets.ts +3 -28
- package/corpus/templates/brain/actions/provider-api-catalog.ts +5 -11
- package/corpus/templates/brain/actions/provider-api-docs.ts +3 -5
- package/corpus/templates/brain/actions/provider-api-request.ts +3 -37
- package/corpus/templates/brain/actions/query-staged-dataset.ts +3 -48
- package/corpus/templates/brain/actions/remediate-legacy-capture-audiences.ts +167 -0
- package/corpus/templates/brain/actions/update-source.ts +5 -1
- package/corpus/templates/brain/app/components/layout/Sidebar.tsx +48 -154
- package/corpus/templates/brain/app/lib/brain-chat-readiness.ts +6 -0
- package/corpus/templates/brain/app/lib/brain.ts +55 -0
- package/corpus/templates/brain/app/lib/ingest-handoff.ts +35 -0
- package/corpus/templates/brain/app/routes/_index.tsx +8 -0
- package/corpus/templates/brain/app/routes.ts +1 -0
- package/corpus/templates/brain/changelog/2026-07-19-ask-starts-immediately-when-builder-s-managed-ai-connection-.md +6 -0
- package/corpus/templates/brain/changelog/2026-07-19-slack-and-granola-backfills-now-process-captures-concurrentl.md +6 -0
- package/corpus/templates/brain/changelog/2026-07-19-slack-backfills-can-now-join-configured-public-channels-befo.md +6 -0
- package/corpus/templates/brain/changelog/2026-07-19-slack-backfills-now-continue-across-the-configured-number-of.md +6 -0
- package/corpus/templates/brain/changelog/2026-07-19-slack-backfills-now-start-with-a-safe-four-week-window-and-r.md +6 -0
- package/corpus/templates/brain/changelog/2026-07-19-source-review-settings-now-control-knowledge-approval.md +6 -0
- package/corpus/templates/brain/changelog/2026-07-19-the-manage-agent-page-now-opens-correctly-from-brain-navigat.md +6 -0
- package/corpus/templates/brain/server/db/schema.ts +3 -0
- package/corpus/templates/brain/server/lib/brain.ts +41 -2
- package/corpus/templates/brain/server/lib/connectors.ts +432 -115
- package/corpus/templates/brain/server/lib/meeting-audience.ts +38 -0
- package/corpus/templates/brain/server/lib/slack-channel-membership.ts +44 -0
- package/corpus/templates/brain/server/plugins/db.ts +10 -0
- package/corpus/templates/brain/server/routes/api/_agent-native/brain/ingest.post.ts +6 -4
- package/corpus/templates/brain/shared/slack-source-config.ts +60 -0
- package/corpus/templates/calendar/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/calendar/.agents/skills/customizing-agent-native/SKILL.md +145 -0
- package/corpus/templates/calendar/.agents/skills/self-modifying-code/SKILL.md +14 -2
- package/corpus/templates/calendar/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/calendar/actions/delete-staged-dataset.ts +3 -24
- package/corpus/templates/calendar/actions/list-staged-datasets.ts +3 -28
- package/corpus/templates/calendar/actions/provider-api-catalog.ts +5 -11
- package/corpus/templates/calendar/actions/provider-api-docs.ts +3 -5
- package/corpus/templates/calendar/actions/provider-api-request.ts +3 -37
- package/corpus/templates/calendar/actions/query-staged-dataset.ts +3 -48
- package/corpus/templates/calendar/server/handlers/gong.ts +6 -61
- package/corpus/templates/calendar/server/handlers/google-auth.ts +10 -8
- package/corpus/templates/calendar/server/lib/google-calendar.ts +7 -45
- package/corpus/templates/chat/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/chat/.agents/skills/agent-native-docs/SKILL.md +21 -9
- package/corpus/templates/chat/.agents/skills/customizing-agent-native/SKILL.md +145 -0
- package/corpus/templates/chat/.agents/skills/self-modifying-code/SKILL.md +14 -2
- package/corpus/templates/chat/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/chat/AGENTS.md +6 -2
- package/corpus/templates/chat/app/components/layout/Sidebar.tsx +51 -157
- package/corpus/templates/clips/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/clips/.agents/skills/customizing-agent-native/SKILL.md +145 -0
- package/corpus/templates/clips/.agents/skills/self-modifying-code/SKILL.md +14 -2
- package/corpus/templates/clips/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/clips/AGENTS.md +11 -0
- package/corpus/templates/clips/actions/export-to-brain.ts +505 -171
- package/corpus/templates/clips/changelog/2026-07-19-ready-clips-transcripts-can-be-backfilled-to-brain-for-a-bou.md +6 -0
- package/corpus/templates/clips/server/lib/calendar-event-meetings.ts +1 -1
- package/corpus/templates/clips/server/lib/google-calendar-client.ts +12 -22
- package/corpus/templates/clips/server/lib/google-calendar-oauth.ts +9 -6
- package/corpus/templates/clips/server/lib/slack-oauth.ts +12 -47
- package/corpus/templates/clips/server/routes/_agent-native/google/auth-url.get.ts +2 -6
- package/corpus/templates/clips/server/routes/api/auth/google-calendar.get.ts +4 -4
- package/corpus/templates/content/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/content/.agents/skills/customizing-agent-native/SKILL.md +145 -0
- package/corpus/templates/content/.agents/skills/self-modifying-code/SKILL.md +14 -2
- package/corpus/templates/content/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/content/actions/delete-staged-dataset.ts +3 -24
- package/corpus/templates/content/actions/list-staged-datasets.ts +3 -28
- package/corpus/templates/content/actions/provider-api-catalog.ts +5 -11
- package/corpus/templates/content/actions/provider-api-docs.ts +3 -5
- package/corpus/templates/content/actions/provider-api-request.ts +3 -37
- package/corpus/templates/content/actions/query-staged-dataset.ts +3 -48
- package/corpus/templates/design/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/design/.agents/skills/customizing-agent-native/SKILL.md +145 -0
- package/corpus/templates/design/.agents/skills/self-modifying-code/SKILL.md +14 -2
- package/corpus/templates/design/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/design/actions/delete-staged-dataset.ts +4 -23
- package/corpus/templates/design/actions/list-staged-datasets.ts +4 -27
- package/corpus/templates/design/actions/provider-api-catalog.ts +15 -18
- package/corpus/templates/design/actions/provider-api-docs.ts +57 -48
- package/corpus/templates/design/actions/provider-api-request.ts +140 -164
- package/corpus/templates/design/actions/query-staged-dataset.ts +4 -47
- package/corpus/templates/dispatch/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/dispatch/.agents/skills/customizing-agent-native/SKILL.md +145 -0
- package/corpus/templates/dispatch/.agents/skills/self-modifying-code/SKILL.md +14 -2
- package/corpus/templates/dispatch/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/dispatch/actions/delete-staged-dataset.ts +4 -23
- package/corpus/templates/dispatch/actions/list-staged-datasets.ts +4 -30
- package/corpus/templates/dispatch/actions/provider-api-catalog.ts +15 -18
- package/corpus/templates/dispatch/actions/provider-api-docs.ts +57 -48
- package/corpus/templates/dispatch/actions/provider-api-request.ts +138 -163
- package/corpus/templates/dispatch/actions/query-staged-dataset.ts +4 -47
- package/corpus/templates/forms/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/forms/.agents/skills/customizing-agent-native/SKILL.md +145 -0
- package/corpus/templates/forms/.agents/skills/self-modifying-code/SKILL.md +14 -2
- package/corpus/templates/forms/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/forms/server/lib/integrations.ts +23 -22
- package/corpus/templates/macros/.agents/skills/customizing-agent-native/SKILL.md +145 -0
- package/corpus/templates/macros/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/mail/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/mail/.agents/skills/customizing-agent-native/SKILL.md +145 -0
- package/corpus/templates/mail/.agents/skills/self-modifying-code/SKILL.md +14 -2
- package/corpus/templates/mail/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/mail/actions/delete-staged-dataset.ts +4 -23
- package/corpus/templates/mail/actions/list-staged-datasets.ts +4 -27
- package/corpus/templates/mail/actions/provider-api-catalog.ts +15 -18
- package/corpus/templates/mail/actions/provider-api-docs.ts +57 -48
- package/corpus/templates/mail/actions/provider-api-request.ts +146 -173
- package/corpus/templates/mail/actions/query-staged-dataset.ts +4 -47
- package/corpus/templates/mail/server/handlers/gong.ts +6 -61
- package/corpus/templates/mail/server/lib/google-auth.ts +10 -13
- package/corpus/templates/plan/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/plan/.agents/skills/customizing-agent-native/SKILL.md +145 -0
- package/corpus/templates/plan/.agents/skills/self-modifying-code/SKILL.md +14 -2
- package/corpus/templates/plan/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/plan/app/components/layout/Sidebar.tsx +47 -156
- package/corpus/templates/slides/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/slides/.agents/skills/customizing-agent-native/SKILL.md +145 -0
- package/corpus/templates/slides/.agents/skills/self-modifying-code/SKILL.md +14 -2
- package/corpus/templates/slides/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/templates/slides/actions/delete-staged-dataset.ts +4 -23
- package/corpus/templates/slides/actions/list-staged-datasets.ts +4 -27
- package/corpus/templates/slides/actions/provider-api-catalog.ts +15 -18
- package/corpus/templates/slides/actions/provider-api-docs.ts +57 -48
- package/corpus/templates/slides/actions/provider-api-request.ts +145 -172
- package/corpus/templates/slides/actions/query-staged-dataset.ts +4 -47
- package/corpus/templates/slides/server/lib/google-docs-oauth.ts +11 -36
- package/corpus/templates/tasks/.agents/skills/actions/SKILL.md +32 -12
- package/corpus/templates/tasks/.agents/skills/agent-native-docs/SKILL.md +21 -9
- package/corpus/templates/tasks/.agents/skills/customizing-agent-native/SKILL.md +145 -0
- package/corpus/templates/tasks/.agents/skills/self-modifying-code/SKILL.md +14 -2
- package/corpus/templates/tasks/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/corpus/toolkit/CHANGELOG.md +131 -0
- package/corpus/toolkit/README.md +60 -0
- package/corpus/toolkit/agent-native.eject.json +411 -0
- package/corpus/toolkit/export-snapshot.json +35 -0
- package/corpus/toolkit/migration-manifest.json +4 -0
- package/corpus/toolkit/package.json +284 -0
- package/corpus/toolkit/scripts/finalize-build.mjs +55 -0
- package/corpus/toolkit/src/app-shell/header-actions.tsx +84 -0
- package/corpus/toolkit/src/app-shell/index.ts +1 -0
- package/corpus/toolkit/src/chat-history/ChatHistoryList.tsx +469 -0
- package/corpus/toolkit/src/chat-history/index.ts +7 -0
- package/corpus/toolkit/src/chat-history.css +314 -0
- package/corpus/toolkit/src/collab-ui/AgentPresenceChip.tsx +69 -0
- package/corpus/toolkit/src/collab-ui/LiveCursorOverlay.tsx +241 -0
- package/corpus/toolkit/src/collab-ui/PresenceBar.tsx +346 -0
- package/corpus/toolkit/src/collab-ui/RecentEditHighlights.tsx +225 -0
- package/corpus/toolkit/src/collab-ui/RemoteSelectionRings.tsx +227 -0
- package/corpus/toolkit/src/collab-ui/agent-identity.ts +16 -0
- package/corpus/toolkit/src/collab-ui/index.ts +39 -0
- package/corpus/toolkit/src/collab-ui/lead-client.ts +32 -0
- package/corpus/toolkit/src/collab-ui/types.ts +96 -0
- package/corpus/toolkit/src/composer/AgentComposerFrame.tsx +59 -0
- package/corpus/toolkit/src/composer/ComposerPlusMenu.tsx +983 -0
- package/corpus/toolkit/src/composer/MentionPopover.tsx +412 -0
- package/corpus/toolkit/src/composer/PastedTextChip.tsx +150 -0
- package/corpus/toolkit/src/composer/PromptComposer.tsx +718 -0
- package/corpus/toolkit/src/composer/RealtimeVoiceMode.tsx +856 -0
- package/corpus/toolkit/src/composer/TiptapComposer.tsx +2936 -0
- package/corpus/toolkit/src/composer/VoiceButton.tsx +255 -0
- package/corpus/toolkit/src/composer/asset-picker-url.ts +80 -0
- package/corpus/toolkit/src/composer/attachment-accept.ts +71 -0
- package/corpus/toolkit/src/composer/draft-key.ts +7 -0
- package/corpus/toolkit/src/composer/extensions/FileReference.tsx +55 -0
- package/corpus/toolkit/src/composer/extensions/MentionReference.tsx +93 -0
- package/corpus/toolkit/src/composer/extensions/SkillReference.tsx +56 -0
- package/corpus/toolkit/src/composer/index.ts +79 -0
- package/corpus/toolkit/src/composer/pasted-text.ts +160 -0
- package/corpus/toolkit/src/composer/prompt-attachments.ts +93 -0
- package/corpus/toolkit/src/composer/realtime-voice-audio-level.ts +64 -0
- package/corpus/toolkit/src/composer/realtime-voice-transcript.ts +134 -0
- package/corpus/toolkit/src/composer/runtime-adapters.tsx +343 -0
- package/corpus/toolkit/src/composer/types.ts +66 -0
- package/corpus/toolkit/src/composer/use-file-search.ts +64 -0
- package/corpus/toolkit/src/composer/use-mention-search.ts +90 -0
- package/corpus/toolkit/src/composer/use-skills.ts +45 -0
- package/corpus/toolkit/src/composer/useRealtimeVoiceMode.tsx +2117 -0
- package/corpus/toolkit/src/composer/useVoiceDictation.ts +1191 -0
- package/corpus/toolkit/src/context-ui/ContextMeter.tsx +101 -0
- package/corpus/toolkit/src/context-ui/ContextSegmentRow.tsx +184 -0
- package/corpus/toolkit/src/context-ui/ContextTreemap.tsx +125 -0
- package/corpus/toolkit/src/context-ui/ContextXRayPanel.tsx +377 -0
- package/corpus/toolkit/src/context-ui/format.ts +42 -0
- package/corpus/toolkit/src/context-ui/index.ts +15 -0
- package/corpus/toolkit/src/context-ui/types.ts +43 -0
- package/corpus/toolkit/src/design-tweaks/index.ts +1 -0
- package/corpus/toolkit/src/design-tweaks/visual-style-controls.tsx +1084 -0
- package/corpus/toolkit/src/editor/BubbleToolbar.tsx +253 -0
- package/corpus/toolkit/src/editor/CodeBlockNode.tsx +254 -0
- package/corpus/toolkit/src/editor/DragHandle.ts +1437 -0
- package/corpus/toolkit/src/editor/ImageExtension.ts +306 -0
- package/corpus/toolkit/src/editor/RegistryBlockContext.tsx +107 -0
- package/corpus/toolkit/src/editor/RegistryBlockNode.tsx +652 -0
- package/corpus/toolkit/src/editor/RichMarkdownEditor.tsx +81 -0
- package/corpus/toolkit/src/editor/RunId.ts +61 -0
- package/corpus/toolkit/src/editor/SharedRichEditor.tsx +321 -0
- package/corpus/toolkit/src/editor/SlashCommandMenu.tsx +310 -0
- package/corpus/toolkit/src/editor/extensions.ts +402 -0
- package/corpus/toolkit/src/editor/gfmDoc.ts +92 -0
- package/corpus/toolkit/src/editor/index.ts +93 -0
- package/corpus/toolkit/src/editor/registrySlashCommands.ts +131 -0
- package/corpus/toolkit/src/editor/surgical-apply.ts +192 -0
- package/corpus/toolkit/src/editor/useCollabReconcile.ts +589 -0
- package/corpus/toolkit/src/editor.css +510 -0
- package/corpus/toolkit/src/hooks/index.ts +2 -0
- package/corpus/toolkit/src/hooks/use-mobile.tsx +21 -0
- package/corpus/toolkit/src/hooks/use-toast.ts +188 -0
- package/corpus/toolkit/src/index.ts +8 -0
- package/corpus/toolkit/src/onboarding/index.ts +1 -0
- package/corpus/toolkit/src/provider.tsx +47 -0
- package/corpus/toolkit/src/sharing/VisibilityBadge.tsx +37 -0
- package/corpus/toolkit/src/sharing/index.ts +4 -0
- package/corpus/toolkit/src/styles.css +21 -0
- package/corpus/toolkit/src/ui/accordion.tsx +56 -0
- package/corpus/toolkit/src/ui/alert-dialog.tsx +141 -0
- package/corpus/toolkit/src/ui/alert.tsx +59 -0
- package/corpus/toolkit/src/ui/aspect-ratio.tsx +5 -0
- package/corpus/toolkit/src/ui/avatar.tsx +48 -0
- package/corpus/toolkit/src/ui/badge.tsx +37 -0
- package/corpus/toolkit/src/ui/breadcrumb.tsx +115 -0
- package/corpus/toolkit/src/ui/button.tsx +78 -0
- package/corpus/toolkit/src/ui/calendar.tsx +214 -0
- package/corpus/toolkit/src/ui/card.tsx +86 -0
- package/corpus/toolkit/src/ui/carousel.tsx +260 -0
- package/corpus/toolkit/src/ui/chart.tsx +375 -0
- package/corpus/toolkit/src/ui/checkbox.tsx +28 -0
- package/corpus/toolkit/src/ui/collapsible.tsx +9 -0
- package/corpus/toolkit/src/ui/command.tsx +174 -0
- package/corpus/toolkit/src/ui/context-menu.tsx +202 -0
- package/corpus/toolkit/src/ui/date-picker.tsx +64 -0
- package/corpus/toolkit/src/ui/dialog.tsx +146 -0
- package/corpus/toolkit/src/ui/drawer.tsx +126 -0
- package/corpus/toolkit/src/ui/dropdown-menu.tsx +218 -0
- package/corpus/toolkit/src/ui/form.tsx +177 -0
- package/corpus/toolkit/src/ui/hover-card.tsx +27 -0
- package/corpus/toolkit/src/ui/index.ts +52 -0
- package/corpus/toolkit/src/ui/input-otp.tsx +69 -0
- package/corpus/toolkit/src/ui/input.tsx +22 -0
- package/corpus/toolkit/src/ui/label.tsx +24 -0
- package/corpus/toolkit/src/ui/logo.tsx +36 -0
- package/corpus/toolkit/src/ui/menubar.tsx +235 -0
- package/corpus/toolkit/src/ui/navigation-menu.tsx +128 -0
- package/corpus/toolkit/src/ui/pagination.tsx +121 -0
- package/corpus/toolkit/src/ui/popover.tsx +44 -0
- package/corpus/toolkit/src/ui/progress.tsx +26 -0
- package/corpus/toolkit/src/ui/radio-group.tsx +42 -0
- package/corpus/toolkit/src/ui/resizable.tsx +43 -0
- package/corpus/toolkit/src/ui/scroll-area.tsx +46 -0
- package/corpus/toolkit/src/ui/select.tsx +158 -0
- package/corpus/toolkit/src/ui/separator.tsx +29 -0
- package/corpus/toolkit/src/ui/sheet.tsx +160 -0
- package/corpus/toolkit/src/ui/sidebar.tsx +777 -0
- package/corpus/toolkit/src/ui/skeleton.tsx +18 -0
- package/corpus/toolkit/src/ui/slider.tsx +26 -0
- package/corpus/toolkit/src/ui/sonner.tsx +58 -0
- package/corpus/toolkit/src/ui/spinner.tsx +17 -0
- package/corpus/toolkit/src/ui/switch.tsx +27 -0
- package/corpus/toolkit/src/ui/table.tsx +117 -0
- package/corpus/toolkit/src/ui/tabs.tsx +53 -0
- package/corpus/toolkit/src/ui/textarea.tsx +23 -0
- package/corpus/toolkit/src/ui/toast.tsx +127 -0
- package/corpus/toolkit/src/ui/toaster.tsx +33 -0
- package/corpus/toolkit/src/ui/toggle-group.tsx +59 -0
- package/corpus/toolkit/src/ui/toggle.tsx +43 -0
- package/corpus/toolkit/src/ui/tooltip.tsx +53 -0
- package/corpus/toolkit/src/ui/use-toast.ts +3 -0
- package/corpus/toolkit/src/utils.ts +8 -0
- package/corpus/toolkit/tsconfig.json +23 -0
- package/dist/cli/atomic-json-file.d.ts +30 -0
- package/dist/cli/atomic-json-file.d.ts.map +1 -0
- package/dist/cli/atomic-json-file.js +240 -0
- package/dist/cli/atomic-json-file.js.map +1 -0
- package/dist/cli/claude-code-participant.d.ts +77 -0
- package/dist/cli/claude-code-participant.d.ts.map +1 -0
- package/dist/cli/claude-code-participant.js +355 -0
- package/dist/cli/claude-code-participant.js.map +1 -0
- package/dist/cli/code-agent-executor.d.ts.map +1 -1
- package/dist/cli/code-agent-executor.js +18 -10
- package/dist/cli/code-agent-executor.js.map +1 -1
- package/dist/cli/code-agent-runs.concurrent-worker.d.ts +2 -0
- package/dist/cli/code-agent-runs.concurrent-worker.d.ts.map +1 -0
- package/dist/cli/code-agent-runs.concurrent-worker.js +32 -0
- package/dist/cli/code-agent-runs.concurrent-worker.js.map +1 -0
- package/dist/cli/code-agent-runs.d.ts.map +1 -1
- package/dist/cli/code-agent-runs.js +43 -56
- package/dist/cli/code-agent-runs.js.map +1 -1
- package/dist/cli/codex-cli-participant.d.ts +77 -0
- package/dist/cli/codex-cli-participant.d.ts.map +1 -0
- package/dist/cli/codex-cli-participant.js +354 -0
- package/dist/cli/codex-cli-participant.js.map +1 -0
- package/dist/cli/eject.d.ts +21 -0
- package/dist/cli/eject.d.ts.map +1 -0
- package/dist/cli/eject.js +1145 -0
- package/dist/cli/eject.js.map +1 -0
- package/dist/cli/index.js +15 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/multi-frontier-runs.d.ts +115 -0
- package/dist/cli/multi-frontier-runs.d.ts.map +1 -1
- package/dist/cli/multi-frontier-runs.js +831 -113
- package/dist/cli/multi-frontier-runs.js.map +1 -1
- package/dist/client/chat/ChatHistoryList.d.ts +1 -87
- package/dist/client/chat/ChatHistoryList.d.ts.map +1 -1
- package/dist/client/chat/ChatHistoryList.js +1 -82
- package/dist/client/chat/ChatHistoryList.js.map +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client/index.js.map +1 -1
- package/dist/client/resources/McpConnectionSuggestion.d.ts +4 -3
- package/dist/client/resources/McpConnectionSuggestion.d.ts.map +1 -1
- package/dist/client/resources/McpConnectionSuggestion.js +3 -3
- package/dist/client/resources/McpConnectionSuggestion.js.map +1 -1
- package/dist/client/resources/McpIntegrationDialog.d.ts +4 -3
- package/dist/client/resources/McpIntegrationDialog.d.ts.map +1 -1
- package/dist/client/resources/McpIntegrationDialog.js +2 -2
- package/dist/client/resources/McpIntegrationDialog.js.map +1 -1
- package/dist/client/resources/ResourcesPanel.d.ts +4 -1
- package/dist/client/resources/ResourcesPanel.d.ts.map +1 -1
- package/dist/client/resources/ResourcesPanel.js +9 -7
- package/dist/client/resources/ResourcesPanel.js.map +1 -1
- package/dist/client/resources/index.d.ts +3 -0
- package/dist/client/resources/index.d.ts.map +1 -1
- package/dist/client/resources/index.js +3 -0
- package/dist/client/resources/index.js.map +1 -1
- package/dist/client/resources/mcp-integration-catalog.d.ts +2 -1
- package/dist/client/resources/mcp-integration-catalog.d.ts.map +1 -1
- package/dist/client/resources/mcp-integration-catalog.js +6 -2
- package/dist/client/resources/mcp-integration-catalog.js.map +1 -1
- package/dist/client/resources/runtime.d.ts +2 -0
- package/dist/client/resources/runtime.d.ts.map +1 -0
- package/dist/client/resources/runtime.js +2 -0
- package/dist/client/resources/runtime.js.map +1 -0
- package/dist/client/setup-connections/catalog.d.ts +2 -0
- package/dist/client/setup-connections/catalog.d.ts.map +1 -0
- package/dist/client/setup-connections/catalog.js +7 -0
- package/dist/client/setup-connections/catalog.js.map +1 -0
- package/dist/client/setup-connections/index.d.ts +1 -0
- package/dist/client/setup-connections/index.d.ts.map +1 -1
- package/dist/client/setup-connections/index.js +1 -0
- package/dist/client/setup-connections/index.js.map +1 -1
- package/dist/client/setup-connections/runtime.d.ts +2 -0
- package/dist/client/setup-connections/runtime.d.ts.map +1 -0
- package/dist/client/setup-connections/runtime.js +2 -0
- package/dist/client/setup-connections/runtime.js.map +1 -0
- 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/connections/catalog.d.ts +5 -3
- package/dist/connections/catalog.d.ts.map +1 -1
- package/dist/connections/catalog.js +16 -8
- package/dist/connections/catalog.js.map +1 -1
- package/dist/connections/index.d.ts +1 -1
- package/dist/connections/index.d.ts.map +1 -1
- package/dist/connections/index.js +1 -1
- package/dist/connections/index.js.map +1 -1
- package/dist/connections/runtime.d.ts +2 -0
- package/dist/connections/runtime.d.ts.map +1 -0
- package/dist/connections/runtime.js +2 -0
- package/dist/connections/runtime.js.map +1 -0
- package/dist/eject/provider-api-definitions.d.ts +34 -0
- package/dist/eject/provider-api-definitions.d.ts.map +1 -0
- package/dist/eject/provider-api-definitions.js +88 -0
- package/dist/eject/provider-api-definitions.js.map +1 -0
- package/dist/eject/remote-mcp-presets.d.ts +17 -0
- package/dist/eject/remote-mcp-presets.d.ts.map +1 -0
- package/dist/eject/remote-mcp-presets.js +81 -0
- package/dist/eject/remote-mcp-presets.js.map +1 -0
- package/dist/eject/setup-readiness-ui.d.ts +7 -0
- package/dist/eject/setup-readiness-ui.d.ts.map +1 -0
- package/dist/eject/setup-readiness-ui.js +13 -0
- package/dist/eject/setup-readiness-ui.js.map +1 -0
- package/dist/eject/workspace-connections.d.ts +11 -0
- package/dist/eject/workspace-connections.d.ts.map +1 -0
- package/dist/eject/workspace-connections.js +47 -0
- package/dist/eject/workspace-connections.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/integrations/adapter-overrides.d.ts +3 -0
- package/dist/integrations/adapter-overrides.d.ts.map +1 -0
- package/dist/integrations/adapter-overrides.js +7 -0
- package/dist/integrations/adapter-overrides.js.map +1 -0
- package/dist/integrations/eject/messaging-adapters.d.ts +12 -0
- package/dist/integrations/eject/messaging-adapters.d.ts.map +1 -0
- package/dist/integrations/eject/messaging-adapters.js +49 -0
- package/dist/integrations/eject/messaging-adapters.js.map +1 -0
- package/dist/integrations/index.d.ts +5 -3
- package/dist/integrations/index.d.ts.map +1 -1
- package/dist/integrations/index.js +4 -2
- package/dist/integrations/index.js.map +1 -1
- package/dist/integrations/plugin.d.ts +32 -1
- package/dist/integrations/plugin.d.ts.map +1 -1
- package/dist/integrations/plugin.js +19 -12
- package/dist/integrations/plugin.js.map +1 -1
- package/dist/integrations/runtime.d.ts +2 -0
- package/dist/integrations/runtime.d.ts.map +1 -0
- package/dist/integrations/runtime.js +2 -0
- package/dist/integrations/runtime.js.map +1 -0
- package/dist/integrations/slack-manifest.d.ts +1 -1
- package/dist/integrations/slack-oauth.d.ts +1 -1
- package/dist/integrations/slack-oauth.d.ts.map +1 -1
- package/dist/integrations/slack-oauth.js +1 -0
- package/dist/integrations/slack-oauth.js.map +1 -1
- package/dist/integrations/types.d.ts +3 -1
- package/dist/integrations/types.d.ts.map +1 -1
- package/dist/integrations/types.js.map +1 -1
- package/dist/integrations/webhook-delivery.d.ts +23 -0
- package/dist/integrations/webhook-delivery.d.ts.map +1 -0
- package/dist/integrations/webhook-delivery.js +32 -0
- package/dist/integrations/webhook-delivery.js.map +1 -0
- package/dist/notifications/channels.d.ts.map +1 -1
- package/dist/notifications/channels.js +4 -9
- package/dist/notifications/channels.js.map +1 -1
- package/dist/notifications/routes.d.ts +3 -3
- package/dist/package-lifecycle/eject-manifest.d.ts +43 -0
- package/dist/package-lifecycle/eject-manifest.d.ts.map +1 -0
- package/dist/package-lifecycle/eject-manifest.js +219 -0
- package/dist/package-lifecycle/eject-manifest.js.map +1 -0
- package/dist/package-lifecycle/index.d.ts +1 -0
- package/dist/package-lifecycle/index.d.ts.map +1 -1
- package/dist/package-lifecycle/index.js +1 -0
- package/dist/package-lifecycle/index.js.map +1 -1
- package/dist/progress/routes.d.ts +1 -1
- package/dist/provider-api/actions/custom-provider-registration.d.ts +136 -0
- package/dist/provider-api/actions/custom-provider-registration.d.ts.map +1 -0
- package/dist/provider-api/actions/custom-provider-registration.js +154 -0
- package/dist/provider-api/actions/custom-provider-registration.js.map +1 -0
- package/dist/provider-api/actions/delete-staged-dataset.d.ts +1 -1
- package/dist/provider-api/actions/delete-staged-dataset.d.ts.map +1 -1
- package/dist/provider-api/actions/delete-staged-dataset.js +3 -34
- package/dist/provider-api/actions/delete-staged-dataset.js.map +1 -1
- package/dist/provider-api/actions/list-staged-datasets.d.ts +2 -3
- package/dist/provider-api/actions/list-staged-datasets.d.ts.map +1 -1
- package/dist/provider-api/actions/list-staged-datasets.js +3 -40
- package/dist/provider-api/actions/list-staged-datasets.js.map +1 -1
- package/dist/provider-api/actions/provider-api-audit.d.ts +7 -0
- package/dist/provider-api/actions/provider-api-audit.d.ts.map +1 -0
- package/dist/provider-api/actions/provider-api-audit.js +74 -0
- package/dist/provider-api/actions/provider-api-audit.js.map +1 -0
- package/dist/provider-api/actions/provider-api.d.ts +370 -0
- package/dist/provider-api/actions/provider-api.d.ts.map +1 -0
- package/dist/provider-api/actions/provider-api.js +280 -0
- package/dist/provider-api/actions/provider-api.js.map +1 -0
- package/dist/provider-api/actions/query-staged-dataset.d.ts +1 -1
- package/dist/provider-api/actions/query-staged-dataset.d.ts.map +1 -1
- package/dist/provider-api/actions/query-staged-dataset.js +3 -116
- package/dist/provider-api/actions/query-staged-dataset.js.map +1 -1
- package/dist/provider-api/actions/staged-datasets.d.ts +190 -0
- package/dist/provider-api/actions/staged-datasets.d.ts.map +1 -0
- package/dist/provider-api/actions/staged-datasets.js +210 -0
- package/dist/provider-api/actions/staged-datasets.js.map +1 -0
- package/dist/provider-api/corpus-jobs.d.ts +2 -2
- package/dist/provider-api/gong.d.ts +44 -0
- package/dist/provider-api/gong.d.ts.map +1 -0
- package/dist/provider-api/gong.js +56 -0
- package/dist/provider-api/gong.js.map +1 -0
- package/dist/provider-api/index.d.ts +6 -2
- package/dist/provider-api/index.d.ts.map +1 -1
- package/dist/provider-api/index.js +25 -12
- package/dist/provider-api/index.js.map +1 -1
- package/dist/provider-api/runtime.d.ts +2 -0
- package/dist/provider-api/runtime.d.ts.map +1 -0
- package/dist/provider-api/runtime.js +2 -0
- package/dist/provider-api/runtime.js.map +1 -0
- package/dist/scripts/docs/source-search.d.ts +2 -1
- package/dist/scripts/docs/source-search.d.ts.map +1 -1
- package/dist/scripts/docs/source-search.js +2 -1
- package/dist/scripts/docs/source-search.js.map +1 -1
- package/dist/secrets/routes.d.ts +9 -9
- package/dist/server/google-oauth-credentials.d.ts +35 -0
- package/dist/server/google-oauth-credentials.d.ts.map +1 -1
- package/dist/server/google-oauth-credentials.js +48 -2
- package/dist/server/google-oauth-credentials.js.map +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +1 -1
- package/dist/server/index.js.map +1 -1
- package/dist/server/transcribe-voice.d.ts +1 -1
- package/dist/setup-connections/index.d.ts +1 -1
- package/dist/setup-connections/index.d.ts.map +1 -1
- package/dist/setup-connections/index.js +1 -1
- package/dist/setup-connections/index.js.map +1 -1
- package/dist/shared/merge-by-id.d.ts +5 -0
- package/dist/shared/merge-by-id.d.ts.map +1 -0
- package/dist/shared/merge-by-id.js +7 -0
- package/dist/shared/merge-by-id.js.map +1 -0
- package/dist/styles/chat-history-list.css +1 -313
- package/dist/templates/chat/.agents/skills/actions/SKILL.md +32 -12
- package/dist/templates/chat/.agents/skills/agent-native-docs/SKILL.md +21 -9
- package/dist/templates/chat/.agents/skills/customizing-agent-native/SKILL.md +145 -0
- package/dist/templates/chat/.agents/skills/self-modifying-code/SKILL.md +14 -2
- package/dist/templates/chat/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/dist/templates/chat/AGENTS.md +6 -2
- package/dist/templates/chat/app/components/layout/Sidebar.tsx +51 -157
- package/dist/templates/default/.agents/skills/actions/SKILL.md +32 -12
- package/dist/templates/default/.agents/skills/agent-native-docs/SKILL.md +21 -9
- package/dist/templates/default/.agents/skills/customizing-agent-native/SKILL.md +145 -0
- package/dist/templates/default/.agents/skills/integration-webhooks/SKILL.md +323 -0
- package/dist/templates/default/.agents/skills/onboarding/SKILL.md +56 -0
- package/dist/templates/default/.agents/skills/secrets/SKILL.md +273 -0
- package/dist/templates/default/.agents/skills/self-modifying-code/SKILL.md +14 -2
- package/dist/templates/default/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/dist/templates/default/AGENTS.md +26 -18
- package/dist/templates/headless/.agents/skills/actions/SKILL.md +512 -0
- package/dist/templates/headless/.agents/skills/agent-native-docs/SKILL.md +21 -9
- package/dist/templates/headless/.agents/skills/customizing-agent-native/SKILL.md +145 -0
- package/dist/templates/headless/.agents/skills/integration-webhooks/SKILL.md +323 -0
- package/dist/templates/headless/.agents/skills/secrets/SKILL.md +273 -0
- package/dist/templates/headless/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/dist/templates/headless/AGENTS.md +8 -0
- package/dist/templates/workspace-core/.agents/skills/actions/SKILL.md +32 -12
- package/dist/templates/workspace-core/.agents/skills/agent-native-docs/SKILL.md +21 -9
- package/dist/templates/workspace-core/.agents/skills/agent-native-toolkit/SKILL.md +7 -0
- package/dist/templates/workspace-core/.agents/skills/customizing-agent-native/SKILL.md +145 -0
- package/dist/templates/workspace-core/.agents/skills/self-modifying-code/SKILL.md +14 -2
- package/dist/templates/workspace-core/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/dist/templates/workspace-core/AGENTS.md +4 -0
- package/dist/templates/workspace-root/AGENTS.md +4 -0
- package/dist/vite/client.d.ts.map +1 -1
- package/dist/vite/client.js +22 -2
- package/dist/vite/client.js.map +1 -1
- package/docs/AGENTS.md +7 -0
- package/docs/content/agent-native-toolkit.mdx +38 -0
- package/docs/content/integrations.mdx +63 -2
- package/docs/content/package-lifecycle.mdx +54 -4
- package/docs/design/provider-integration-authority.md +117 -0
- package/package.json +20 -2
- package/src/a2a/agent-card.ts +83 -0
- package/src/a2a/artifact-response.ts +1648 -0
- package/src/a2a/auth-policy.ts +66 -0
- package/src/a2a/caller-auth.ts +102 -0
- package/src/a2a/client.ts +876 -0
- package/src/a2a/correlation.ts +50 -0
- package/src/a2a/handlers.ts +1285 -0
- package/src/a2a/index.ts +50 -0
- package/src/a2a/invoke.ts +348 -0
- package/src/a2a/response-text.ts +53 -0
- package/src/a2a/server.ts +586 -0
- package/src/a2a/task-store.ts +917 -0
- package/src/a2a/types.ts +221 -0
- package/src/a2a-claims.ts +52 -0
- package/src/action-change-marker.ts +74 -0
- package/src/action-ui.ts +38 -0
- package/src/action.ts +1406 -0
- package/src/adapters/cli/index.ts +6 -0
- package/src/adapters/cli/registry.ts +73 -0
- package/src/adapters/cli/shell-adapter.ts +92 -0
- package/src/adapters/cli/types.ts +27 -0
- package/src/agent/action-continuation-guidance.ts +38 -0
- package/src/agent/app-model-defaults.ts +201 -0
- package/src/agent/context-xray/actions/context-evict.ts +56 -0
- package/src/agent/context-xray/actions/context-manifest-get.ts +75 -0
- package/src/agent/context-xray/actions/context-pin.ts +56 -0
- package/src/agent/context-xray/actions/context-preview-get.ts +134 -0
- package/src/agent/context-xray/actions/context-report.ts +75 -0
- package/src/agent/context-xray/actions/context-restore.ts +51 -0
- package/src/agent/context-xray/actions/errors.ts +40 -0
- package/src/agent/context-xray/apply-directives.ts +137 -0
- package/src/agent/context-xray/directives-store.ts +178 -0
- package/src/agent/context-xray/identity.ts +37 -0
- package/src/agent/context-xray/manifest.ts +284 -0
- package/src/agent/context-xray/migrations.ts +32 -0
- package/src/agent/context-xray/plugin.ts +23 -0
- package/src/agent/context-xray/schema.ts +17 -0
- package/src/agent/context-xray/segments.ts +194 -0
- package/src/agent/context-xray/tokenize.ts +93 -0
- package/src/agent/default-model.ts +5 -0
- package/src/agent/durable-background.ts +547 -0
- package/src/agent/engine/ai-sdk-engine.ts +565 -0
- package/src/agent/engine/anthropic-engine.ts +320 -0
- package/src/agent/engine/builder-engine.ts +1110 -0
- package/src/agent/engine/builder-gateway-headers.ts +44 -0
- package/src/agent/engine/builtin.ts +122 -0
- package/src/agent/engine/context-directives-transform.ts +73 -0
- package/src/agent/engine/continuation-dispatch-retry.ts +168 -0
- package/src/agent/engine/credential-errors.ts +69 -0
- package/src/agent/engine/index.ts +54 -0
- package/src/agent/engine/openai-compatible-endpoint.ts +25 -0
- package/src/agent/engine/output-tokens.ts +181 -0
- package/src/agent/engine/provider-env-vars.ts +69 -0
- package/src/agent/engine/registry.ts +853 -0
- package/src/agent/engine/tool-call-journal-seed.ts +85 -0
- package/src/agent/engine/translate-ai-sdk.ts +407 -0
- package/src/agent/engine/translate-anthropic.ts +611 -0
- package/src/agent/engine/types.ts +310 -0
- package/src/agent/harness/acp-adapter.ts +893 -0
- package/src/agent/harness/acp-builtin.ts +70 -0
- package/src/agent/harness/ai-sdk-adapter.ts +509 -0
- package/src/agent/harness/background.ts +365 -0
- package/src/agent/harness/builtin.ts +50 -0
- package/src/agent/harness/index.ts +86 -0
- package/src/agent/harness/lifecycle.ts +498 -0
- package/src/agent/harness/registry.ts +97 -0
- package/src/agent/harness/runner.ts +182 -0
- package/src/agent/harness/store.ts +466 -0
- package/src/agent/harness/translate.ts +130 -0
- package/src/agent/harness/types.ts +129 -0
- package/src/agent/index.ts +32 -0
- package/src/agent/loop-settings.ts +186 -0
- package/src/agent/model-config.ts +363 -0
- package/src/agent/observational-memory/compactor.ts +78 -0
- package/src/agent/observational-memory/config.ts +78 -0
- package/src/agent/observational-memory/index.ts +79 -0
- package/src/agent/observational-memory/internal-run.ts +89 -0
- package/src/agent/observational-memory/message-text.ts +49 -0
- package/src/agent/observational-memory/migrations.ts +44 -0
- package/src/agent/observational-memory/observer.ts +128 -0
- package/src/agent/observational-memory/plugin.ts +35 -0
- package/src/agent/observational-memory/prompts.ts +53 -0
- package/src/agent/observational-memory/read.ts +131 -0
- package/src/agent/observational-memory/reflector.ts +119 -0
- package/src/agent/observational-memory/schema.ts +48 -0
- package/src/agent/observational-memory/store.ts +275 -0
- package/src/agent/observational-memory/types.ts +65 -0
- package/src/agent/processors.ts +209 -0
- package/src/agent/production-agent.ts +8254 -0
- package/src/agent/run-loop-with-resume.ts +394 -0
- package/src/agent/run-manager.ts +1825 -0
- package/src/agent/run-ownership.ts +75 -0
- package/src/agent/run-store.ts +2601 -0
- package/src/agent/runtime-context.ts +169 -0
- package/src/agent/thread-data-builder.ts +1584 -0
- package/src/agent/tool-call-journal.ts +368 -0
- package/src/agent/tool-error-redaction.ts +52 -0
- package/src/agent/tool-result-images.ts +178 -0
- package/src/agent/tool-search.ts +376 -0
- package/src/agent/types.ts +372 -0
- package/src/agent-native/index.ts +198 -0
- package/src/agent-web/config.ts +253 -0
- package/src/agent-web/generator.ts +382 -0
- package/src/agent-web/index.ts +36 -0
- package/src/appearance/actions/change-appearance.ts +35 -0
- package/src/application-state/emitter.ts +81 -0
- package/src/application-state/handlers.ts +121 -0
- package/src/application-state/index.ts +44 -0
- package/src/application-state/script-helpers.ts +155 -0
- package/src/application-state/store.ts +274 -0
- package/src/assets/branding/agent-native.icon/Assets/background.svg +3 -0
- package/src/assets/branding/agent-native.icon/Assets/foreground.svg +12 -0
- package/src/assets/branding/agent-native.icon/icon.json +49 -0
- package/src/assets/branding/favicon.png +0 -0
- package/src/assets/branding/favicon.svg +1 -0
- package/src/assets/branding/icon-on-dark.svg +10 -0
- package/src/assets/branding/icon-on-light.svg +10 -0
- package/src/assets/branding/mac-app-icon.svg +1 -0
- package/src/assets/branding/slack-bot/agent-native-1024.png +0 -0
- package/src/assets/branding/slack-bot/agent-native-512.png +0 -0
- package/src/assets/branding/tray-icon.svg +6 -0
- package/src/assets/branding/wordmark-on-dark.svg +21 -0
- package/src/assets/branding/wordmark-on-light.svg +21 -0
- package/src/assets/fonts/LICENSE_LIBERATION +96 -0
- package/src/assets/fonts/LICENSE_NOTO_NASKH_ARABIC +93 -0
- package/src/assets/fonts/LiberationSans-Bold.ttf +0 -0
- package/src/assets/fonts/LiberationSans-Regular.ttf +0 -0
- package/src/assets/fonts/NotoNaskhArabic-Variable.ttf +0 -0
- package/src/audit/actions/export-audit-events.ts +162 -0
- package/src/audit/actions/get-audit-event.ts +24 -0
- package/src/audit/actions/list-audit-events.ts +66 -0
- package/src/audit/cleanup-job.ts +100 -0
- package/src/audit/config.ts +90 -0
- package/src/audit/index.ts +43 -0
- package/src/audit/record.ts +180 -0
- package/src/audit/redact.ts +109 -0
- package/src/audit/store.ts +346 -0
- package/src/audit/types.ts +141 -0
- package/src/automation/index.ts +802 -0
- package/src/brand-kit/brand-signals.ts +124 -0
- package/src/brand-kit/fig/index.ts +64 -0
- package/src/brand-kit/index.ts +72 -0
- package/src/brand-kit/types.ts +113 -0
- package/src/browser-sessions/actions.ts +302 -0
- package/src/browser-sessions/routes.ts +234 -0
- package/src/browser-sessions/store.ts +679 -0
- package/src/browser-sessions/types.ts +84 -0
- package/src/changelog/parse.ts +328 -0
- package/src/chat-threads/emitter.ts +22 -0
- package/src/chat-threads/schema.ts +43 -0
- package/src/chat-threads/store.ts +1311 -0
- package/src/checkpoints/index.ts +15 -0
- package/src/checkpoints/service.ts +142 -0
- package/src/checkpoints/store.ts +153 -0
- package/src/cli/add.ts +425 -0
- package/src/cli/agent.ts +424 -0
- package/src/cli/agents.ts +122 -0
- package/src/cli/app-skill.ts +1455 -0
- package/src/cli/atomic-json-file.ts +324 -0
- package/src/cli/audit-agent-web.ts +324 -0
- package/src/cli/changelog.ts +199 -0
- package/src/cli/claude-code-participant.ts +515 -0
- package/src/cli/code-agent-commands.ts +270 -0
- package/src/cli/code-agent-connector.ts +1109 -0
- package/src/cli/code-agent-executor.ts +1970 -0
- package/src/cli/code-agent-output-smoother.ts +140 -0
- package/src/cli/code-agent-runs.concurrent-worker.ts +33 -0
- package/src/cli/code-agent-runs.ts +548 -0
- package/src/cli/code.ts +1805 -0
- package/src/cli/codex-cli-participant.ts +496 -0
- package/src/cli/connect.ts +2714 -0
- package/src/cli/content-local.ts +442 -0
- package/src/cli/context-xray-local.ts +2193 -0
- package/src/cli/create-workspace.ts +30 -0
- package/src/cli/create.ts +2247 -0
- package/src/cli/deploy-build.ts +50 -0
- package/src/cli/design-connect.ts +3187 -0
- package/src/cli/doctor.ts +472 -0
- package/src/cli/eject.ts +1594 -0
- package/src/cli/eval.ts +134 -0
- package/src/cli/gateway-helpers.ts +70 -0
- package/src/cli/index.ts +1217 -0
- package/src/cli/info.ts +105 -0
- package/src/cli/invoke.ts +288 -0
- package/src/cli/mcp-config-writers.ts +857 -0
- package/src/cli/mcp.ts +594 -0
- package/src/cli/migrate.ts +1813 -0
- package/src/cli/migration-codemod.ts +646 -0
- package/src/cli/multi-frontier-runs.ts +1952 -0
- package/src/cli/package-lifecycle.ts +823 -0
- package/src/cli/plan-blocks.ts +143 -0
- package/src/cli/plan-local.ts +3189 -0
- package/src/cli/plan-publish-store.ts +138 -0
- package/src/cli/pr-visual-recap-workflow.ts +2 -0
- package/src/cli/recap.ts +5 -0
- package/src/cli/setup-agents.ts +120 -0
- package/src/cli/skills-content/assets-skill.ts +83 -0
- package/src/cli/skills-content/canvas.ts +153 -0
- package/src/cli/skills-content/connection.ts +52 -0
- package/src/cli/skills-content/content-skill.ts +120 -0
- package/src/cli/skills-content/design-exploration-skill.ts +118 -0
- package/src/cli/skills-content/design-visual-edit-skill.ts +228 -0
- package/src/cli/skills-content/document-quality.ts +196 -0
- package/src/cli/skills-content/exemplar.ts +69 -0
- package/src/cli/skills-content/help.ts +77 -0
- package/src/cli/skills-content/index.ts +22 -0
- package/src/cli/skills-content/local-files.ts +100 -0
- package/src/cli/skills-content/plan-setup-auth.ts +80 -0
- package/src/cli/skills-content/visual-plan-skill.ts +493 -0
- package/src/cli/skills-content/visual-recap-skill.ts +553 -0
- package/src/cli/skills-content/visualize-repo-skill.ts +93 -0
- package/src/cli/skills-content/wireframe.ts +349 -0
- package/src/cli/skills.ts +4340 -0
- package/src/cli/sync-builder-starter-manifest.ts +631 -0
- package/src/cli/telemetry.ts +136 -0
- package/src/cli/templates-meta.ts +269 -0
- package/src/cli/upgrade.ts +956 -0
- package/src/cli/visualize-repo.ts +715 -0
- package/src/cli/workspace-dev.ts +1486 -0
- package/src/cli/workspacify.ts +258 -0
- package/src/client/AgentAskPopover.tsx +89 -0
- package/src/client/AgentChatHome.tsx +66 -0
- package/src/client/AgentNative.tsx +161 -0
- package/src/client/AgentNativeEmbedded.tsx +288 -0
- package/src/client/AgentNativeFrame.tsx +151 -0
- package/src/client/AgentPanel.tsx +3437 -0
- package/src/client/AgentTaskCard.tsx +273 -0
- package/src/client/AppearancePicker.tsx +79 -0
- package/src/client/AssistantChat.tsx +5793 -0
- package/src/client/ClientOnly.tsx +22 -0
- package/src/client/CommandMenu.tsx +726 -0
- package/src/client/ConnectBuilderCard.tsx +390 -0
- package/src/client/DefaultSpinner.tsx +47 -0
- package/src/client/ErrorBoundary.tsx +359 -0
- package/src/client/ErrorReportActions.tsx +69 -0
- package/src/client/FeedbackButton.tsx +553 -0
- package/src/client/HighlightedCodeBlock.tsx +173 -0
- package/src/client/IframeEmbed.tsx +151 -0
- package/src/client/KeepTabOpenNotice.tsx +181 -0
- package/src/client/MultiTabAssistantChat.tsx +2576 -0
- package/src/client/NewWorkspaceAppFlow.tsx +525 -0
- package/src/client/PoweredByBadge.tsx +284 -0
- package/src/client/RunStuckBanner.tsx +431 -0
- package/src/client/StarfieldBackground.tsx +466 -0
- package/src/client/Turnstile.tsx +125 -0
- package/src/client/active-run-state.ts +139 -0
- package/src/client/agent-chat/index.ts +279 -0
- package/src/client/agent-chat-adapter.ts +3692 -0
- package/src/client/agent-chat.ts +1233 -0
- package/src/client/agent-engine-key.ts +122 -0
- package/src/client/agent-page/AgentContextTab.tsx +487 -0
- package/src/client/agent-page/AgentEmptyState.tsx +44 -0
- package/src/client/agent-page/AgentJobsTab.tsx +441 -0
- package/src/client/agent-page/AgentTabFrame.tsx +39 -0
- package/src/client/agent-page/AgentTabsPage.tsx +1096 -0
- package/src/client/agent-page/types.ts +18 -0
- package/src/client/agent-page/use-jobs.ts +150 -0
- package/src/client/agent-sidebar-state.ts +166 -0
- package/src/client/analytics/index.ts +40 -0
- package/src/client/analytics-session.ts +70 -0
- package/src/client/analytics.ts +1757 -0
- package/src/client/api-path.ts +124 -0
- package/src/client/app-providers.tsx +230 -0
- package/src/client/appearance.ts +130 -0
- package/src/client/application-state.ts +154 -0
- package/src/client/assistant-ui-recovery.tsx +205 -0
- package/src/client/automation/index.ts +4 -0
- package/src/client/automation.ts +22 -0
- package/src/client/blocks/AiEditableField.tsx +30 -0
- package/src/client/blocks/BlockView.tsx +145 -0
- package/src/client/blocks/RegistryBlockDataProvider.tsx +121 -0
- package/src/client/blocks/SchemaBlockEditor.tsx +457 -0
- package/src/client/blocks/agent.ts +95 -0
- package/src/client/blocks/code-block-direction.ts +21 -0
- package/src/client/blocks/index.ts +308 -0
- package/src/client/blocks/library/AnnotatedCodeBlock.tsx +710 -0
- package/src/client/blocks/library/ApiEndpointBlock.tsx +1120 -0
- package/src/client/blocks/library/DataModelBlock.tsx +775 -0
- package/src/client/blocks/library/DiffBlock.tsx +1854 -0
- package/src/client/blocks/library/FileTreeBlock.tsx +868 -0
- package/src/client/blocks/library/HighlightedCode.tsx +260 -0
- package/src/client/blocks/library/JsonExplorerBlock.tsx +608 -0
- package/src/client/blocks/library/MermaidBlock.tsx +362 -0
- package/src/client/blocks/library/OpenApiSpecBlock.tsx +998 -0
- package/src/client/blocks/library/annotated-code.config.ts +101 -0
- package/src/client/blocks/library/annotation-rail.tsx +1020 -0
- package/src/client/blocks/library/api-endpoint.config.ts +207 -0
- package/src/client/blocks/library/block-copy.ts +399 -0
- package/src/client/blocks/library/callout.config.ts +57 -0
- package/src/client/blocks/library/callout.tsx +149 -0
- package/src/client/blocks/library/checklist.config.ts +56 -0
- package/src/client/blocks/library/checklist.tsx +208 -0
- package/src/client/blocks/library/code-filename-label.tsx +59 -0
- package/src/client/blocks/library/code-highlight.tsx +178 -0
- package/src/client/blocks/library/code-tabs.config.ts +70 -0
- package/src/client/blocks/library/code-tabs.tsx +606 -0
- package/src/client/blocks/library/code.config.ts +69 -0
- package/src/client/blocks/library/code.tsx +440 -0
- package/src/client/blocks/library/columns.config.ts +85 -0
- package/src/client/blocks/library/columns.tsx +334 -0
- package/src/client/blocks/library/data-model.config.ts +152 -0
- package/src/client/blocks/library/dev-doc-ui.tsx +191 -0
- package/src/client/blocks/library/diagram.config.ts +222 -0
- package/src/client/blocks/library/diagram.tsx +958 -0
- package/src/client/blocks/library/diff.config.ts +115 -0
- package/src/client/blocks/library/file-tree.config.ts +92 -0
- package/src/client/blocks/library/html.config.ts +79 -0
- package/src/client/blocks/library/html.tsx +258 -0
- package/src/client/blocks/library/json-explorer.config.ts +74 -0
- package/src/client/blocks/library/mermaid.config.ts +49 -0
- package/src/client/blocks/library/narrow-container.tsx +37 -0
- package/src/client/blocks/library/openapi-spec.config.ts +66 -0
- package/src/client/blocks/library/question-form.config.ts +127 -0
- package/src/client/blocks/library/question-form.tsx +944 -0
- package/src/client/blocks/library/sanitize-html.ts +343 -0
- package/src/client/blocks/library/server-specs.ts +338 -0
- package/src/client/blocks/library/specs.tsx +308 -0
- package/src/client/blocks/library/table.config.ts +61 -0
- package/src/client/blocks/library/table.tsx +449 -0
- package/src/client/blocks/library/tabs.config.ts +96 -0
- package/src/client/blocks/library/tabs.tsx +665 -0
- package/src/client/blocks/library/wireframe-icons.ts +210 -0
- package/src/client/blocks/library/wireframe-kit.tsx +1850 -0
- package/src/client/blocks/library/wireframe.config.ts +539 -0
- package/src/client/blocks/library/wireframe.tsx +535 -0
- package/src/client/blocks/mdx.ts +364 -0
- package/src/client/blocks/provider.tsx +51 -0
- package/src/client/blocks/registry.ts +83 -0
- package/src/client/blocks/schema-form/introspect.ts +201 -0
- package/src/client/blocks/server.ts +170 -0
- package/src/client/blocks/types.ts +415 -0
- package/src/client/browser-session-bridge.ts +548 -0
- package/src/client/browser-tab-id.ts +36 -0
- package/src/client/builder-frame.ts +194 -0
- package/src/client/builder-mark.tsx +21 -0
- package/src/client/changelog/Changelog.tsx +333 -0
- package/src/client/changelog/index.ts +1 -0
- package/src/client/chat/ChatHistoryList.tsx +7 -0
- package/src/client/chat/attachment-adapters.ts +426 -0
- package/src/client/chat/connectors.ts +1579 -0
- package/src/client/chat/index.ts +160 -0
- package/src/client/chat/markdown-renderer.tsx +693 -0
- package/src/client/chat/message-components.tsx +1326 -0
- package/src/client/chat/repo-helpers.ts +281 -0
- package/src/client/chat/run-recovery.tsx +994 -0
- package/src/client/chat/runtime.ts +1810 -0
- package/src/client/chat/tool-call-display.tsx +1270 -0
- package/src/client/chat/tool-render-registry.tsx +144 -0
- package/src/client/chat/use-agent-chat-lifecycle-tracking.ts +74 -0
- package/src/client/chat/use-reconnect-reader-owner.ts +28 -0
- package/src/client/chat/widgets/DataChartRenderer.tsx +242 -0
- package/src/client/chat/widgets/DataChartWidget.tsx +51 -0
- package/src/client/chat/widgets/DataInsightsWidget.tsx +59 -0
- package/src/client/chat/widgets/DataTableWidget.tsx +240 -0
- package/src/client/chat/widgets/InlineExtensionWidget.tsx +60 -0
- package/src/client/chat/widgets/builtin-tool-renderers.tsx +213 -0
- package/src/client/chat/widgets/data-widget-types.ts +1 -0
- package/src/client/chat/widgets/inline-extension-result.ts +86 -0
- package/src/client/chat-model-groups.ts +171 -0
- package/src/client/chat-thread-url.ts +11 -0
- package/src/client/chat-view-transition.ts +213 -0
- package/src/client/client-action.ts +21 -0
- package/src/client/client-bootstrap.ts +7 -0
- package/src/client/client-surface.ts +41 -0
- package/src/client/clipboard.ts +89 -0
- package/src/client/code-agent-chat-adapter.ts +537 -0
- package/src/client/collab/index.ts +60 -0
- package/src/client/command-navigation/index.ts +15 -0
- package/src/client/comments-review/index.ts +1 -0
- package/src/client/components/AgentPresenceChip.tsx +4 -0
- package/src/client/components/ApiKeySettings.tsx +309 -0
- package/src/client/components/CodeAgentIndicator.tsx +59 -0
- package/src/client/components/CodeRequiredDialog.tsx +470 -0
- package/src/client/components/LiveCursorOverlay.tsx +5 -0
- package/src/client/components/MissingKeyCard.tsx +61 -0
- package/src/client/components/PresenceBar.tsx +4 -0
- package/src/client/components/RecentEditHighlights.tsx +4 -0
- package/src/client/components/RemoteSelectionRings.tsx +5 -0
- package/src/client/components/icons/AgentNativeIcon.tsx +46 -0
- package/src/client/components/ui/dialog.tsx +1 -0
- package/src/client/components/ui/dropdown-menu.tsx +1 -0
- package/src/client/components/ui/hover-card.tsx +1 -0
- package/src/client/components/ui/message-scroller.tsx +131 -0
- package/src/client/components/ui/popover.tsx +1 -0
- package/src/client/components/ui/sheet.tsx +1 -0
- package/src/client/components/ui/tooltip.tsx +1 -0
- package/src/client/composer/index.ts +11 -0
- package/src/client/composer/runtime-adapters.tsx +123 -0
- package/src/client/composer/use-mention-search.ts +7 -0
- package/src/client/composer/wired-components.tsx +53 -0
- package/src/client/context-xray/ContextMeter.tsx +124 -0
- package/src/client/context-xray/ContextSegmentRow.tsx +27 -0
- package/src/client/context-xray/ContextTreemap.tsx +24 -0
- package/src/client/context-xray/ContextXRayPanel.tsx +59 -0
- package/src/client/context-xray/SegmentProvenancePopover.tsx +18 -0
- package/src/client/context-xray/format.ts +27 -0
- package/src/client/conversation/AgentConversation.tsx +555 -0
- package/src/client/conversation/code-agent-transcript.ts +283 -0
- package/src/client/conversation/index.ts +22 -0
- package/src/client/conversation/types.ts +85 -0
- package/src/client/conversation/use-near-bottom-autoscroll.ts +278 -0
- package/src/client/create-query-client.ts +86 -0
- package/src/client/db-admin/DataGrid.tsx +551 -0
- package/src/client/db-admin/DbAdminPage.tsx +218 -0
- package/src/client/db-admin/DevDatabaseLink.tsx +16 -0
- package/src/client/db-admin/EditableCell.tsx +451 -0
- package/src/client/db-admin/FilterBar.tsx +203 -0
- package/src/client/db-admin/ResultsGrid.tsx +114 -0
- package/src/client/db-admin/RowSidePanel.tsx +337 -0
- package/src/client/db-admin/SqlEditor.tsx +840 -0
- package/src/client/db-admin/TableBrowser.tsx +212 -0
- package/src/client/db-admin/TableEditor.tsx +760 -0
- package/src/client/db-admin/cell-format.ts +246 -0
- package/src/client/db-admin/changeset.ts +296 -0
- package/src/client/db-admin/export-utils.ts +78 -0
- package/src/client/db-admin/index.ts +33 -0
- package/src/client/db-admin/sql-storage.ts +134 -0
- package/src/client/db-admin/storage.ts +68 -0
- package/src/client/db-admin/useAgentSync.ts +226 -0
- package/src/client/db-admin/useDbAdmin.ts +294 -0
- package/src/client/dev-overlay/DevOverlay.tsx +576 -0
- package/src/client/dev-overlay/builtins.ts +40 -0
- package/src/client/dev-overlay/index.ts +23 -0
- package/src/client/dev-overlay/registry.ts +67 -0
- package/src/client/dev-overlay/types.ts +64 -0
- package/src/client/dev-overlay/use-dev-option.ts +78 -0
- package/src/client/dev-overlay/use-dev-overlay-shortcut.ts +31 -0
- package/src/client/dynamic-suggestions.ts +455 -0
- package/src/client/embed-auth.ts +544 -0
- package/src/client/embed.ts +54 -0
- package/src/client/error-capture.ts +690 -0
- package/src/client/error-format.ts +211 -0
- package/src/client/error-reporting.ts +100 -0
- package/src/client/extensions/AgentNativeExtensionFrame.e2e-host.tsx +136 -0
- package/src/client/extensions/AgentNativeExtensionFrame.tsx +708 -0
- package/src/client/extensions/EmbeddedExtension.tsx +604 -0
- package/src/client/extensions/ExtensionEditor.tsx +450 -0
- package/src/client/extensions/ExtensionQueryErrorState.tsx +47 -0
- package/src/client/extensions/ExtensionSlot.tsx +345 -0
- package/src/client/extensions/ExtensionViewer.tsx +1502 -0
- package/src/client/extensions/ExtensionViewerPage.tsx +32 -0
- package/src/client/extensions/ExtensionsListPage.tsx +432 -0
- package/src/client/extensions/ExtensionsSidebarSection.tsx +1259 -0
- package/src/client/extensions/InlineExtensionFrame.tsx +660 -0
- package/src/client/extensions/agent-native-extension-runtime.ts +495 -0
- package/src/client/extensions/delete-extension.ts +76 -0
- package/src/client/extensions/extension-load-error.ts +26 -0
- package/src/client/extensions/extension-order.ts +49 -0
- package/src/client/extensions/extension-popularity.ts +61 -0
- package/src/client/extensions/iframe-bridge.ts +377 -0
- package/src/client/extensions/index.ts +84 -0
- package/src/client/extensions/portable-extension.ts +712 -0
- package/src/client/feature-flags/FeatureFlagsPanel.tsx +519 -0
- package/src/client/feature-flags/helpers.ts +77 -0
- package/src/client/feature-flags/index.ts +13 -0
- package/src/client/feature-flags/types.ts +29 -0
- package/src/client/feature-flags/use-feature-flag.ts +26 -0
- package/src/client/feedback-context.ts +90 -0
- package/src/client/frame-protocol.ts +168 -0
- package/src/client/frame.ts +329 -0
- package/src/client/guided-questions.tsx +1152 -0
- package/src/client/history/VersionHistoryPanel.tsx +175 -0
- package/src/client/history/index.ts +21 -0
- package/src/client/history/use-history.ts +114 -0
- package/src/client/hooks/index.ts +46 -0
- package/src/client/host/index.ts +170 -0
- package/src/client/host-bridge.ts +1272 -0
- package/src/client/host-tools.ts +190 -0
- package/src/client/i18n.tsx +798 -0
- package/src/client/index.ts +370 -0
- package/src/client/integrations/IntegrationCard.tsx +186 -0
- package/src/client/integrations/IntegrationsPanel.tsx +633 -0
- package/src/client/integrations/api.ts +295 -0
- package/src/client/integrations/index.ts +29 -0
- package/src/client/integrations/useIntegrationStatus.ts +52 -0
- package/src/client/mcp-app-host.ts +720 -0
- package/src/client/mcp-apps/McpAppRenderer.tsx +760 -0
- package/src/client/navigation/index.ts +54 -0
- package/src/client/notifications/NotificationsBell.tsx +383 -0
- package/src/client/notifications/index.ts +1 -0
- package/src/client/observability/ObservabilityDashboard.tsx +890 -0
- package/src/client/observability/ThumbsFeedback.tsx +160 -0
- package/src/client/observability/index.ts +20 -0
- package/src/client/observability/useObservability.ts +266 -0
- package/src/client/onboarding/OnboardingBanner.tsx +73 -0
- package/src/client/onboarding/OnboardingPanel.tsx +1036 -0
- package/src/client/onboarding/SetupButton.tsx +64 -0
- package/src/client/onboarding/index.ts +25 -0
- package/src/client/onboarding/use-onboarding.ts +164 -0
- package/src/client/onboarding/use-preview-mode.ts +40 -0
- package/src/client/org/InvitationBanner.tsx +148 -0
- package/src/client/org/OrgSwitcher.tsx +754 -0
- package/src/client/org/RequireActiveOrg.tsx +337 -0
- package/src/client/org/TeamPage.tsx +1432 -0
- package/src/client/org/hooks.ts +359 -0
- package/src/client/org/index.ts +70 -0
- package/src/client/org/workspace-app-links.ts +367 -0
- package/src/client/org-team/index.ts +1 -0
- package/src/client/progress/RunsTray.tsx +680 -0
- package/src/client/progress/index.ts +1 -0
- package/src/client/require-session.tsx +142 -0
- package/src/client/resources/BuiltinCapabilityDetail.tsx +258 -0
- package/src/client/resources/McpConnectionSuggestion.tsx +276 -0
- package/src/client/resources/McpIntegrationDialog.tsx +808 -0
- package/src/client/resources/McpServerDetail.tsx +230 -0
- package/src/client/resources/ResourceEditor.tsx +872 -0
- package/src/client/resources/ResourceTree.tsx +860 -0
- package/src/client/resources/ResourcesPanel.tsx +1960 -0
- package/src/client/resources/index.ts +25 -0
- package/src/client/resources/mcp-integration-catalog.ts +771 -0
- package/src/client/resources/mcp-integration-logos.ts +108 -0
- package/src/client/resources/runtime.ts +1 -0
- package/src/client/resources/use-builtin-capabilities.ts +113 -0
- package/src/client/resources/use-mcp-servers.ts +217 -0
- package/src/client/resources/use-resources.ts +402 -0
- package/src/client/review/ReviewCommentComposer.tsx +123 -0
- package/src/client/review/ReviewStatusBadge.tsx +39 -0
- package/src/client/review/ReviewThreadPanel.tsx +625 -0
- package/src/client/review/index.ts +38 -0
- package/src/client/review/use-review.ts +186 -0
- package/src/client/route-chunk-recovery/index.ts +1 -0
- package/src/client/route-chunk-recovery.ts +331 -0
- package/src/client/route-state.ts +455 -0
- package/src/client/route-warmup.tsx +543 -0
- package/src/client/session-replay-iframe.e2e-host.tsx +100 -0
- package/src/client/session-replay.ts +3417 -0
- package/src/client/settings/AgentsSection.tsx +441 -0
- package/src/client/settings/AutomationsSection.tsx +516 -0
- package/src/client/settings/BackgroundAgentSection.tsx +189 -0
- package/src/client/settings/BrowserSection.tsx +110 -0
- package/src/client/settings/DemoModeSection.tsx +48 -0
- package/src/client/settings/SecretsSection.tsx +875 -0
- package/src/client/settings/SettingsPanel.tsx +3162 -0
- package/src/client/settings/SettingsSection.tsx +283 -0
- package/src/client/settings/SettingsTabsPage.tsx +592 -0
- package/src/client/settings/UsageSection.tsx +401 -0
- package/src/client/settings/VoiceTranscriptionSection.tsx +960 -0
- package/src/client/settings/agent-settings-search.ts +220 -0
- package/src/client/settings/index.ts +27 -0
- package/src/client/settings/useBuilderStatus.ts +1055 -0
- package/src/client/setup-connections/BuilderConnectCard.tsx +89 -0
- package/src/client/setup-connections/ProviderReadinessBadge.tsx +73 -0
- package/src/client/setup-connections/SetupConnectionsPage.tsx +94 -0
- package/src/client/setup-connections/catalog.ts +6 -0
- package/src/client/setup-connections/index.ts +47 -0
- package/src/client/setup-connections/runtime.ts +1 -0
- package/src/client/sharing/ShareButton.tsx +1748 -0
- package/src/client/sharing/ShareDialog.tsx +846 -0
- package/src/client/sharing/VisibilityBadge.tsx +4 -0
- package/src/client/sharing/index.ts +2 -0
- package/src/client/sse-event-processor.ts +2002 -0
- package/src/client/terminal/AgentTerminal.tsx +488 -0
- package/src/client/terminal/index.ts +7 -0
- package/src/client/theme.ts +27 -0
- package/src/client/tombstone/agent-presence-chip.ts +17 -0
- package/src/client/tombstone/editor.ts +265 -0
- package/src/client/tombstone/live-cursor-overlay.ts +21 -0
- package/src/client/tombstone/presence-bar.ts +17 -0
- package/src/client/tombstone/recent-edit-highlights.ts +17 -0
- package/src/client/tombstone/remote-selection-rings.ts +21 -0
- package/src/client/tombstone/rich-markdown-editor.ts +265 -0
- package/src/client/tombstone/ui-dialog.ts +49 -0
- package/src/client/tombstone/ui-dropdown-menu.ts +69 -0
- package/src/client/tombstone/ui-hover-card.ts +21 -0
- package/src/client/tombstone/ui-popover.ts +25 -0
- package/src/client/tombstone/ui-sheet.ts +49 -0
- package/src/client/tombstone/ui-tooltip.ts +29 -0
- package/src/client/tombstone/visual-style-controls.ts +61 -0
- package/src/client/tool-cells/BashCell.tsx +164 -0
- package/src/client/tool-cells/EditCell.tsx +303 -0
- package/src/client/tool-cells/FilesChangedSummary.tsx +208 -0
- package/src/client/tool-cells/WriteCell.tsx +145 -0
- package/src/client/tool-cells/index.ts +7 -0
- package/src/client/tool-display.ts +41 -0
- package/src/client/track.ts +57 -0
- package/src/client/transcription/BuilderTranscriptionCta.tsx +120 -0
- package/src/client/transcription/use-live-transcription.ts +292 -0
- package/src/client/ui/index.ts +55 -0
- package/src/client/uploads/index.ts +6 -0
- package/src/client/uploads/upload-editor-image.ts +79 -0
- package/src/client/uploads/use-upload-resource.ts +24 -0
- package/src/client/url-scrub.ts +51 -0
- package/src/client/use-action.ts +766 -0
- package/src/client/use-agent-chat-context.ts +63 -0
- package/src/client/use-agent-chat-home-handoff.ts +207 -0
- package/src/client/use-agent-chat.ts +53 -0
- package/src/client/use-agent-engine-configured.ts +211 -0
- package/src/client/use-avatar.ts +127 -0
- package/src/client/use-change-version.ts +150 -0
- package/src/client/use-chat-models.ts +252 -0
- package/src/client/use-chat-threads.ts +1262 -0
- package/src/client/use-db-sync.ts +1112 -0
- package/src/client/use-demo-mode-status.ts +30 -0
- package/src/client/use-dev-mode.ts +177 -0
- package/src/client/use-external-value.ts +40 -0
- package/src/client/use-pausing-interval.ts +65 -0
- package/src/client/use-pinch-zoom.ts +202 -0
- package/src/client/use-run-stuck-detection.ts +427 -0
- package/src/client/use-send-to-agent-chat.ts +85 -0
- package/src/client/use-session.ts +114 -0
- package/src/client/utils.ts +7 -0
- package/src/client/visual-style-controls.tsx +1 -0
- package/src/client/vite-dev-recovery-script.ts +226 -0
- package/src/client/voice-provider-status.ts +44 -0
- package/src/client/widgets/index.ts +41 -0
- package/src/code-agents/background-controller.ts +398 -0
- package/src/code-agents/background-run.ts +156 -0
- package/src/code-agents/index.ts +95 -0
- package/src/code-agents/prompt-attachments.ts +39 -0
- package/src/code-agents/transcript-normalizer.ts +750 -0
- package/src/code-agents/transcript-order.ts +73 -0
- package/src/coding-tools/index.ts +742 -0
- package/src/coding-tools/run-code.ts +1662 -0
- package/src/coding-tools/sandbox/adapter.ts +82 -0
- package/src/coding-tools/sandbox/background.ts +406 -0
- package/src/coding-tools/sandbox/executions-store.ts +517 -0
- package/src/coding-tools/sandbox/index.ts +132 -0
- package/src/coding-tools/sandbox/local-child-process-adapter.ts +217 -0
- package/src/collab/agent-identity.ts +5 -0
- package/src/collab/agent-presence.ts +341 -0
- package/src/collab/awareness-store.ts +196 -0
- package/src/collab/awareness.ts +317 -0
- package/src/collab/client-struct.ts +366 -0
- package/src/collab/client.ts +1205 -0
- package/src/collab/emitter.ts +31 -0
- package/src/collab/follow-mode.ts +107 -0
- package/src/collab/index.ts +151 -0
- package/src/collab/json-to-yjs.ts +504 -0
- package/src/collab/presence.ts +207 -0
- package/src/collab/recent-edits.ts +215 -0
- package/src/collab/routes.ts +191 -0
- package/src/collab/storage.ts +228 -0
- package/src/collab/struct-routes.ts +133 -0
- package/src/collab/text-to-yjs.ts +79 -0
- package/src/collab/undo.ts +432 -0
- package/src/collab/xml-ops.ts +68 -0
- package/src/collab/ydoc-manager.ts +544 -0
- package/src/command-navigation/actions.ts +100 -0
- package/src/command-navigation/index.ts +12 -0
- package/src/comments-review/index.ts +1 -0
- package/src/connections/catalog.ts +451 -0
- package/src/connections/index.ts +48 -0
- package/src/connections/reader.ts +911 -0
- package/src/connections/runtime.ts +1 -0
- package/src/credentials/index.ts +187 -0
- package/src/data-programs/actions.ts +335 -0
- package/src/data-programs/contract.ts +284 -0
- package/src/data-programs/execute.ts +693 -0
- package/src/data-programs/index.ts +72 -0
- package/src/data-programs/schema.ts +148 -0
- package/src/data-programs/store.ts +755 -0
- package/src/data-widgets/index.ts +376 -0
- package/src/db/client.ts +1627 -0
- package/src/db/create-get-db.ts +579 -0
- package/src/db/ddl-guard.ts +302 -0
- package/src/db/drizzle-config.ts +190 -0
- package/src/db/ensure-additive-columns.ts +430 -0
- package/src/db/index.ts +57 -0
- package/src/db/migrations.ts +691 -0
- package/src/db/request-telemetry.ts +154 -0
- package/src/db/runtime-diagnostics.ts +331 -0
- package/src/db/schema.ts +121 -0
- package/src/db/widen-columns.ts +75 -0
- package/src/db-admin/agent-tools.ts +202 -0
- package/src/db-admin/index.ts +26 -0
- package/src/db-admin/operations.ts +803 -0
- package/src/db-admin/routes.ts +174 -0
- package/src/db-admin/types.ts +110 -0
- package/src/demo/browser-state.ts +47 -0
- package/src/demo/fetch-interceptor.ts +175 -0
- package/src/demo/redact.ts +575 -0
- package/src/deploy/build.ts +3935 -0
- package/src/deploy/immutable-assets.ts +65 -0
- package/src/deploy/route-discovery.ts +458 -0
- package/src/deploy/workspace-core.ts +282 -0
- package/src/deploy/workspace-deploy.ts +1488 -0
- package/src/eject/provider-api-definitions.ts +193 -0
- package/src/eject/remote-mcp-presets.ts +137 -0
- package/src/eject/setup-readiness-ui.tsx +29 -0
- package/src/eject/workspace-connections.ts +92 -0
- package/src/embedding/agent.ts +159 -0
- package/src/embedding/bridge.ts +297 -0
- package/src/embedding/index.ts +43 -0
- package/src/embedding/protocol.ts +185 -0
- package/src/embedding/react.tsx +319 -0
- package/src/embeddings/index.ts +233 -0
- package/src/eval/agent-runner.ts +210 -0
- package/src/eval/define-eval.ts +55 -0
- package/src/eval/index.ts +49 -0
- package/src/eval/report.ts +75 -0
- package/src/eval/runner.ts +369 -0
- package/src/eval/scorer.ts +244 -0
- package/src/eval/types.ts +188 -0
- package/src/event-bus/bus.ts +140 -0
- package/src/event-bus/index.ts +3 -0
- package/src/event-bus/registry.ts +79 -0
- package/src/event-bus/types.ts +29 -0
- package/src/extensions/actions.ts +1636 -0
- package/src/extensions/change-marker.ts +54 -0
- package/src/extensions/content-patch.ts +468 -0
- package/src/extensions/fetch-tool.ts +461 -0
- package/src/extensions/html-shell.ts +803 -0
- package/src/extensions/local.ts +462 -0
- package/src/extensions/path.ts +40 -0
- package/src/extensions/proxy-security.ts +171 -0
- package/src/extensions/routes.ts +1080 -0
- package/src/extensions/schema.ts +269 -0
- package/src/extensions/session-replay-iframe.ts +131 -0
- package/src/extensions/slots/routes.ts +126 -0
- package/src/extensions/slots/schema.ts +87 -0
- package/src/extensions/slots/store.ts +450 -0
- package/src/extensions/store.ts +1347 -0
- package/src/extensions/theme.ts +114 -0
- package/src/extensions/url-safety.ts +316 -0
- package/src/extensions/web-content.ts +663 -0
- package/src/extensions/web-search-tool.ts +437 -0
- package/src/feature-flags/a2a-action-route.ts +56 -0
- package/src/feature-flags/actions/get-feature-flags.ts +24 -0
- package/src/feature-flags/actions/list-feature-flags.ts +69 -0
- package/src/feature-flags/actions/set-feature-flag.ts +89 -0
- package/src/feature-flags/index.ts +21 -0
- package/src/feature-flags/permissions.ts +53 -0
- package/src/feature-flags/plugin.ts +44 -0
- package/src/feature-flags/registry.ts +96 -0
- package/src/feature-flags/store.ts +176 -0
- package/src/file-upload/actions/upload-image.ts +213 -0
- package/src/file-upload/builder.ts +431 -0
- package/src/file-upload/index.ts +24 -0
- package/src/file-upload/pre-upload-attachments.ts +305 -0
- package/src/file-upload/registry.ts +125 -0
- package/src/file-upload/types.ts +89 -0
- package/src/guards/db-tool-scoping.ts +129 -0
- package/src/guards/index.ts +23 -0
- package/src/guards/no-drizzle-push.ts +116 -0
- package/src/guards/no-env-credentials.ts +229 -0
- package/src/guards/no-env-mutation.ts +114 -0
- package/src/guards/no-localhost-fallback.ts +124 -0
- package/src/guards/no-unscoped-credentials.ts +227 -0
- package/src/guards/no-unscoped-queries.ts +834 -0
- package/src/guards/scan-utils.ts +105 -0
- package/src/guards/types.ts +30 -0
- package/src/history/actions/create-resource-version.ts +92 -0
- package/src/history/actions/get-resource-version.ts +60 -0
- package/src/history/actions/list-resource-history.ts +53 -0
- package/src/history/actions/list-resource-versions.ts +43 -0
- package/src/history/actions/restore-resource-version.ts +96 -0
- package/src/history/index.ts +26 -0
- package/src/history/registry.ts +111 -0
- package/src/history/store.ts +379 -0
- package/src/history/types.ts +69 -0
- package/src/index.browser.ts +155 -0
- package/src/index.ts +408 -0
- package/src/ingestion/docx.ts +158 -0
- package/src/ingestion/figma-node-to-html.ts +1860 -0
- package/src/ingestion/figma.ts +548 -0
- package/src/ingestion/index.ts +107 -0
- package/src/ingestion/media.ts +264 -0
- package/src/ingestion/notion.ts +121 -0
- package/src/ingestion/office.ts +213 -0
- package/src/ingestion/orchestration.ts +160 -0
- package/src/ingestion/pptx.ts +331 -0
- package/src/ingestion/selection.ts +81 -0
- package/src/ingestion/website.ts +151 -0
- package/src/integrations/a2a-continuation-marker.ts +2 -0
- package/src/integrations/a2a-continuation-processor.ts +888 -0
- package/src/integrations/a2a-continuations-store.ts +643 -0
- package/src/integrations/adapter-overrides.ts +12 -0
- package/src/integrations/adapters/discord.ts +364 -0
- package/src/integrations/adapters/email.ts +1164 -0
- package/src/integrations/adapters/google-docs.ts +371 -0
- package/src/integrations/adapters/index.ts +29 -0
- package/src/integrations/adapters/microsoft-teams.ts +413 -0
- package/src/integrations/adapters/slack.ts +1914 -0
- package/src/integrations/adapters/telegram.ts +386 -0
- package/src/integrations/adapters/whatsapp.ts +358 -0
- package/src/integrations/awaiting-input-store.ts +130 -0
- package/src/integrations/catalog.ts +571 -0
- package/src/integrations/computer-supervision-store.ts +423 -0
- package/src/integrations/computer-supervision.ts +213 -0
- package/src/integrations/config-store.ts +131 -0
- package/src/integrations/controls-store.ts +187 -0
- package/src/integrations/eject/messaging-adapters.ts +85 -0
- package/src/integrations/google-docs-poller.ts +671 -0
- package/src/integrations/identity-links-store.ts +210 -0
- package/src/integrations/identity.ts +196 -0
- package/src/integrations/index.ts +220 -0
- package/src/integrations/installations-store.ts +677 -0
- package/src/integrations/integration-memory.ts +187 -0
- package/src/integrations/internal-token.ts +106 -0
- package/src/integrations/pending-tasks-retry-job.ts +286 -0
- package/src/integrations/pending-tasks-store.ts +468 -0
- package/src/integrations/plugin.ts +3048 -0
- package/src/integrations/remote-commands-store.ts +690 -0
- package/src/integrations/remote-devices-store.ts +492 -0
- package/src/integrations/remote-json-safety.ts +127 -0
- package/src/integrations/remote-push-delivery-job.ts +48 -0
- package/src/integrations/remote-push-delivery.ts +370 -0
- package/src/integrations/remote-push-store.ts +664 -0
- package/src/integrations/remote-retry-job.ts +55 -0
- package/src/integrations/remote-run-events-store.ts +222 -0
- package/src/integrations/remote-types.ts +186 -0
- package/src/integrations/runtime.ts +1 -0
- package/src/integrations/scope-store.ts +498 -0
- package/src/integrations/slack-manifest.ts +78 -0
- package/src/integrations/slack-oauth.ts +344 -0
- package/src/integrations/task-queue-stats.ts +144 -0
- package/src/integrations/thread-mapping-store.ts +134 -0
- package/src/integrations/types.ts +485 -0
- package/src/integrations/usage-budget-store.ts +906 -0
- package/src/integrations/webhook-delivery.ts +55 -0
- package/src/integrations/webhook-handler.ts +1939 -0
- package/src/jobs/actions/list-recurring-jobs.ts +105 -0
- package/src/jobs/actions/manage-recurring-job.ts +85 -0
- package/src/jobs/cron.ts +126 -0
- package/src/jobs/index.ts +9 -0
- package/src/jobs/scheduler.ts +703 -0
- package/src/jobs/tools.ts +367 -0
- package/src/local-artifacts/index.ts +1372 -0
- package/src/localization/actions/get-localization-preference.ts +24 -0
- package/src/localization/actions/set-localization-preference.ts +32 -0
- package/src/localization/default-messages.ts +1009 -0
- package/src/localization/index.ts +2 -0
- package/src/localization/server.ts +131 -0
- package/src/localization/shared.ts +208 -0
- package/src/mcp/actions/call-mcp-tool.ts +19 -0
- package/src/mcp/actions/create-org-service-token.ts +87 -0
- package/src/mcp/actions/list-mcp-tools.ts +18 -0
- package/src/mcp/actions/list-org-service-tokens.ts +44 -0
- package/src/mcp/actions/revoke-org-service-token.ts +30 -0
- package/src/mcp/actions/service-token-access.ts +121 -0
- package/src/mcp/ask-app-inline-tasks.ts +125 -0
- package/src/mcp/build-server.ts +2356 -0
- package/src/mcp/builtin-tools.ts +1506 -0
- package/src/mcp/connect-route.ts +1460 -0
- package/src/mcp/connect-store.ts +680 -0
- package/src/mcp/embed-app.ts +2051 -0
- package/src/mcp/embed-route.ts +84 -0
- package/src/mcp/external-agent-policy.ts +18 -0
- package/src/mcp/index.ts +47 -0
- package/src/mcp/oauth-route.ts +1016 -0
- package/src/mcp/oauth-store.ts +581 -0
- package/src/mcp/oauth-token.ts +227 -0
- package/src/mcp/org-directory.ts +343 -0
- package/src/mcp/route-paths.ts +34 -0
- package/src/mcp/screen-memory-stdio.ts +290 -0
- package/src/mcp/server.ts +507 -0
- package/src/mcp/stdio.ts +328 -0
- package/src/mcp/workspace-resolve.ts +261 -0
- package/src/mcp-client/app-api.ts +136 -0
- package/src/mcp-client/app-result.ts +64 -0
- package/src/mcp-client/builtin-capabilities.ts +146 -0
- package/src/mcp-client/builtin-store.ts +93 -0
- package/src/mcp-client/config.ts +281 -0
- package/src/mcp-client/errors.ts +54 -0
- package/src/mcp-client/hub-client.ts +172 -0
- package/src/mcp-client/hub-routes.ts +198 -0
- package/src/mcp-client/index.ts +504 -0
- package/src/mcp-client/manager.ts +968 -0
- package/src/mcp-client/oauth-client.ts +462 -0
- package/src/mcp-client/oauth-routes.ts +307 -0
- package/src/mcp-client/remote-store.ts +674 -0
- package/src/mcp-client/remote-url.ts +97 -0
- package/src/mcp-client/routes.ts +1093 -0
- package/src/mcp-client/screen-memory-local.ts +461 -0
- package/src/mcp-client/tool-policy.ts +182 -0
- package/src/mcp-client/visibility.ts +56 -0
- package/src/mcp-client/workspace-servers.ts +379 -0
- package/src/navigation/index.ts +170 -0
- package/src/notifications/actions.ts +151 -0
- package/src/notifications/channels.ts +410 -0
- package/src/notifications/index.ts +22 -0
- package/src/notifications/registry.ts +216 -0
- package/src/notifications/routes.ts +106 -0
- package/src/notifications/store.ts +236 -0
- package/src/notifications/types.ts +52 -0
- package/src/oauth-tokens/google-refresh.ts +175 -0
- package/src/oauth-tokens/index.ts +15 -0
- package/src/oauth-tokens/store.ts +384 -0
- package/src/observability/cleanup-job.ts +124 -0
- package/src/observability/evals.ts +507 -0
- package/src/observability/experiments.ts +359 -0
- package/src/observability/feedback.ts +332 -0
- package/src/observability/hosted-model-experiment.ts +118 -0
- package/src/observability/index.ts +62 -0
- package/src/observability/plugin.ts +31 -0
- package/src/observability/routes.ts +431 -0
- package/src/observability/sentiment.ts +261 -0
- package/src/observability/store.ts +1347 -0
- package/src/observability/traces.ts +789 -0
- package/src/observability/tracing.ts +157 -0
- package/src/observability/tracking-identity.ts +55 -0
- package/src/observability/types.ts +211 -0
- package/src/onboarding/default-steps.ts +428 -0
- package/src/onboarding/index.ts +22 -0
- package/src/onboarding/plugin.ts +262 -0
- package/src/onboarding/registry.ts +47 -0
- package/src/onboarding/types.ts +96 -0
- package/src/org/accept-pending.ts +98 -0
- package/src/org/auto-join-domain.ts +113 -0
- package/src/org/context.ts +614 -0
- package/src/org/free-email-providers.ts +124 -0
- package/src/org/handlers.ts +1153 -0
- package/src/org/index.ts +63 -0
- package/src/org/migrations.ts +105 -0
- package/src/org/permissions.ts +30 -0
- package/src/org/plugin.ts +255 -0
- package/src/org/schema.ts +28 -0
- package/src/org/types.ts +57 -0
- package/src/org-team/index.ts +1 -0
- package/src/package-lifecycle/deprecated-imports.ts +179 -0
- package/src/package-lifecycle/eject-manifest.ts +345 -0
- package/src/package-lifecycle/index.ts +7 -0
- package/src/package-lifecycle/manifest.ts +120 -0
- package/src/package-lifecycle/migration-manifest.ts +159 -0
- package/src/package-lifecycle/migration-message.ts +6 -0
- package/src/package-lifecycle/tombstone.ts +58 -0
- package/src/package-lifecycle/upgrade-error.ts +37 -0
- package/src/private-blob/index.ts +18 -0
- package/src/private-blob/registry.ts +242 -0
- package/src/private-blob/types.ts +55 -0
- package/src/progress/actions.ts +179 -0
- package/src/progress/index.ts +16 -0
- package/src/progress/registry.ts +127 -0
- package/src/progress/routes.ts +89 -0
- package/src/progress/store.ts +353 -0
- package/src/progress/types.ts +59 -0
- package/src/provider-api/actions/custom-provider-registration.ts +197 -0
- package/src/provider-api/actions/delete-staged-dataset.ts +5 -0
- package/src/provider-api/actions/github-repo-files.ts +266 -0
- package/src/provider-api/actions/list-staged-datasets.ts +5 -0
- package/src/provider-api/actions/provider-api-audit.ts +88 -0
- package/src/provider-api/actions/provider-api.ts +460 -0
- package/src/provider-api/actions/query-staged-dataset.ts +5 -0
- package/src/provider-api/actions/staged-datasets.ts +359 -0
- package/src/provider-api/corpus-jobs-store.ts +522 -0
- package/src/provider-api/corpus-jobs.ts +1817 -0
- package/src/provider-api/custom-registry.ts +456 -0
- package/src/provider-api/github-repo.ts +675 -0
- package/src/provider-api/gong.ts +108 -0
- package/src/provider-api/index.ts +5444 -0
- package/src/provider-api/quota-governor.ts +562 -0
- package/src/provider-api/runtime.ts +1 -0
- package/src/provider-api/staged-datasets-aggregate.ts +304 -0
- package/src/provider-api/staged-datasets-store.ts +441 -0
- package/src/provider-api/staging.ts +483 -0
- package/src/resources/agents.ts +65 -0
- package/src/resources/emitter.ts +54 -0
- package/src/resources/handlers.ts +728 -0
- package/src/resources/index.ts +4 -0
- package/src/resources/metadata.ts +252 -0
- package/src/resources/script-helpers.ts +160 -0
- package/src/resources/store.ts +1618 -0
- package/src/review/actions/consume-review-feedback.ts +48 -0
- package/src/review/actions/create-review-comment.ts +108 -0
- package/src/review/actions/delete-review-comment.ts +67 -0
- package/src/review/actions/get-review-feedback.ts +49 -0
- package/src/review/actions/list-review-comments.ts +87 -0
- package/src/review/actions/reply-review-comment.ts +118 -0
- package/src/review/actions/resolve-review-thread.ts +94 -0
- package/src/review/actions/send-review-thread-to-agent.ts +62 -0
- package/src/review/actions/set-review-status.ts +58 -0
- package/src/review/identity.ts +101 -0
- package/src/review/index.ts +45 -0
- package/src/review/mentions.ts +44 -0
- package/src/review/registry.ts +111 -0
- package/src/review/store.ts +997 -0
- package/src/review/types.ts +101 -0
- package/src/router/index.ts +24 -0
- package/src/scripts/agent-engines/list-agent-engines.ts +130 -0
- package/src/scripts/agent-engines/manage-agent-engine.ts +197 -0
- package/src/scripts/agent-engines/set-agent-engine.ts +84 -0
- package/src/scripts/agent-engines/test-agent-engine.ts +174 -0
- package/src/scripts/call-agent.ts +792 -0
- package/src/scripts/chat/index.ts +8 -0
- package/src/scripts/chat/open-chat.ts +56 -0
- package/src/scripts/chat/search-chats.ts +121 -0
- package/src/scripts/core-scripts.ts +22 -0
- package/src/scripts/db/check-scoping.ts +212 -0
- package/src/scripts/db/exec.ts +791 -0
- package/src/scripts/db/index.ts +19 -0
- package/src/scripts/db/migrate-encrypt-credentials.ts +223 -0
- package/src/scripts/db/migrate-encrypt-oauth-tokens.ts +213 -0
- package/src/scripts/db/migrate-user-api-keys.ts +257 -0
- package/src/scripts/db/patch.ts +820 -0
- package/src/scripts/db/query.ts +299 -0
- package/src/scripts/db/reset-dev-owner.ts +285 -0
- package/src/scripts/db/safety.ts +286 -0
- package/src/scripts/db/schema.ts +364 -0
- package/src/scripts/db/scoping.ts +341 -0
- package/src/scripts/db/sqlite-client.ts +78 -0
- package/src/scripts/db/tool-mode.ts +23 -0
- package/src/scripts/db/tool-schemas.ts +31 -0
- package/src/scripts/db/wipe-leaked-builder-keys.ts +201 -0
- package/src/scripts/dev/index.ts +296 -0
- package/src/scripts/dev/list-files.ts +119 -0
- package/src/scripts/dev/read-file.ts +77 -0
- package/src/scripts/dev/search-files.ts +151 -0
- package/src/scripts/dev/shell.ts +111 -0
- package/src/scripts/dev/write-file.ts +56 -0
- package/src/scripts/dev-session.ts +96 -0
- package/src/scripts/docs/index.ts +8 -0
- package/src/scripts/docs/search.ts +274 -0
- package/src/scripts/docs/source-search.ts +363 -0
- package/src/scripts/index.ts +15 -0
- package/src/scripts/manage-agent-loop-settings.ts +84 -0
- package/src/scripts/parse-args.ts +46 -0
- package/src/scripts/resources/delete-memory.ts +67 -0
- package/src/scripts/resources/delete.ts +69 -0
- package/src/scripts/resources/effective.ts +71 -0
- package/src/scripts/resources/index.ts +18 -0
- package/src/scripts/resources/list.ts +103 -0
- package/src/scripts/resources/migrate-learnings.ts +40 -0
- package/src/scripts/resources/read.ts +107 -0
- package/src/scripts/resources/save-memory.ts +99 -0
- package/src/scripts/resources/write.ts +158 -0
- package/src/scripts/runner.ts +339 -0
- package/src/scripts/utils.ts +130 -0
- package/src/search/index.ts +413 -0
- package/src/search-utils/index.ts +112 -0
- package/src/secrets/crypto.ts +228 -0
- package/src/secrets/index.ts +65 -0
- package/src/secrets/onboarding.ts +101 -0
- package/src/secrets/register-framework-secrets.ts +228 -0
- package/src/secrets/register.ts +129 -0
- package/src/secrets/routes.ts +697 -0
- package/src/secrets/schema.ts +52 -0
- package/src/secrets/storage.ts +561 -0
- package/src/secrets/substitution.ts +305 -0
- package/src/server/__snapshots__/agent-chat-plugin.surface.spec.ts.snap +150 -0
- package/src/server/action-change.ts +66 -0
- package/src/server/action-discovery.ts +774 -0
- package/src/server/action-routes.ts +608 -0
- package/src/server/agent-access.ts +72 -0
- package/src/server/agent-chat/action-filters-a2a.ts +339 -0
- package/src/server/agent-chat/browser-team-tools.ts +510 -0
- package/src/server/agent-chat/context-tools.ts +599 -0
- package/src/server/agent-chat/framework-prompts.ts +467 -0
- package/src/server/agent-chat/lazy-fs.ts +11 -0
- package/src/server/agent-chat/mcp-glue.ts +91 -0
- package/src/server/agent-chat/plugin-options.ts +379 -0
- package/src/server/agent-chat/process-run-failure.ts +62 -0
- package/src/server/agent-chat/prompt-resources.ts +1004 -0
- package/src/server/agent-chat/recurring-jobs-runtime.ts +80 -0
- package/src/server/agent-chat/request-surface.ts +71 -0
- package/src/server/agent-chat/run-code-tools.ts +67 -0
- package/src/server/agent-chat/script-entries.ts +796 -0
- package/src/server/agent-chat/shared-thread.ts +301 -0
- package/src/server/agent-chat/skill-frontmatter.ts +41 -0
- package/src/server/agent-chat-plugin.ts +5930 -0
- package/src/server/agent-discovery.ts +706 -0
- package/src/server/agent-engine-api-key-route.ts +236 -0
- package/src/server/agent-run-context.ts +204 -0
- package/src/server/agent-teams-run-queue.ts +344 -0
- package/src/server/agent-teams.ts +2257 -0
- package/src/server/agents-bundle.ts +464 -0
- package/src/server/analytics.ts +105 -0
- package/src/server/app-base-path.ts +79 -0
- package/src/server/app-name.ts +53 -0
- package/src/server/app-url.ts +184 -0
- package/src/server/attachment-actions.ts +276 -0
- package/src/server/attribution.ts +214 -0
- package/src/server/auth-marketing.ts +260 -0
- package/src/server/auth-plugin.ts +27 -0
- package/src/server/auth.ts +3803 -0
- package/src/server/better-auth-instance.ts +1197 -0
- package/src/server/builder-browser.ts +1701 -0
- package/src/server/builder-design-systems.ts +668 -0
- package/src/server/builder-space.ts +176 -0
- package/src/server/captcha.ts +63 -0
- package/src/server/capture-error.ts +64 -0
- package/src/server/cli-capture.ts +141 -0
- package/src/server/collab-plugin.ts +391 -0
- package/src/server/complete-text.ts +231 -0
- package/src/server/cookie-namespace.ts +159 -0
- package/src/server/core-routes-plugin.ts +4122 -0
- package/src/server/cors-origins.ts +60 -0
- package/src/server/create-server.ts +268 -0
- package/src/server/credential-provider.ts +1202 -0
- package/src/server/csrf.ts +229 -0
- package/src/server/date-utils.ts +42 -0
- package/src/server/deep-link.ts +119 -0
- package/src/server/derived-secret.ts +32 -0
- package/src/server/design-token-utils.ts +1032 -0
- package/src/server/desktop-sso.ts +83 -0
- package/src/server/edge.ts +69 -0
- package/src/server/email-actions.ts +218 -0
- package/src/server/email-template.ts +192 -0
- package/src/server/email-templates.ts +148 -0
- package/src/server/email.ts +219 -0
- package/src/server/embed-route.ts +283 -0
- package/src/server/embed-session.ts +805 -0
- package/src/server/embedded.ts +252 -0
- package/src/server/entry-server.tsx +154 -0
- package/src/server/framework-request-handler.ts +848 -0
- package/src/server/fusion-app.ts +447 -0
- package/src/server/google-auth-mode.ts +34 -0
- package/src/server/google-auth-plugin.ts +496 -0
- package/src/server/google-oauth-credentials.ts +128 -0
- package/src/server/google-oauth.ts +972 -0
- package/src/server/google-realtime-session.ts +182 -0
- package/src/server/h3-helpers.ts +174 -0
- package/src/server/http-response-telemetry.ts +396 -0
- package/src/server/identity-sso-store.ts +304 -0
- package/src/server/identity-sso.ts +514 -0
- package/src/server/index.ts +593 -0
- package/src/server/missing-key.ts +36 -0
- package/src/server/oauth-helpers.ts +44 -0
- package/src/server/oauth-public-origin.ts +44 -0
- package/src/server/oauth-return-url.ts +120 -0
- package/src/server/og-fonts-data.ts +15 -0
- package/src/server/og-fonts.ts +75 -0
- package/src/server/onboarding-html.ts +4040 -0
- package/src/server/open-route.ts +311 -0
- package/src/server/org-admin.ts +28 -0
- package/src/server/poll-events.ts +88 -0
- package/src/server/poll.ts +1224 -0
- package/src/server/prompts/framework-core-compact.ts +107 -0
- package/src/server/prompts/framework-core.ts +143 -0
- package/src/server/prompts/index.ts +16 -0
- package/src/server/prompts/model-overlays.ts +54 -0
- package/src/server/prompts/shared-rules.ts +104 -0
- package/src/server/realtime-voice.ts +967 -0
- package/src/server/recap-image-route.ts +242 -0
- package/src/server/recap-image-store.ts +185 -0
- package/src/server/request-context.ts +416 -0
- package/src/server/request-origin.ts +67 -0
- package/src/server/resources-plugin.ts +119 -0
- package/src/server/schema-prompt.ts +429 -0
- package/src/server/scoped-key-storage.ts +223 -0
- package/src/server/security-headers.ts +170 -0
- package/src/server/self-dispatch.ts +224 -0
- package/src/server/sentry-config.ts +73 -0
- package/src/server/sentry-plugin.ts +138 -0
- package/src/server/sentry.ts +444 -0
- package/src/server/short-lived-token.ts +170 -0
- package/src/server/social-og-image.ts +454 -0
- package/src/server/sse.ts +102 -0
- package/src/server/ssr-handler.ts +466 -0
- package/src/server/transcribe-voice.ts +1076 -0
- package/src/server/voice-providers-status.ts +118 -0
- package/src/server/workspace-oauth.ts +31 -0
- package/src/server/workspace-provider-oauth.ts +970 -0
- package/src/session-replay-iframe-protocol.ts +58 -0
- package/src/settings/handlers.ts +44 -0
- package/src/settings/index.ts +34 -0
- package/src/settings/org-settings.ts +83 -0
- package/src/settings/script-helpers.ts +24 -0
- package/src/settings/store.ts +247 -0
- package/src/settings/user-settings.ts +47 -0
- package/src/setup-connections/index.ts +90 -0
- package/src/setup-connections/onboarding.ts +47 -0
- package/src/shared/agent-access.ts +112 -0
- package/src/shared/agent-chat.ts +124 -0
- package/src/shared/agent-env.ts +46 -0
- package/src/shared/agent-readable-resource.ts +111 -0
- package/src/shared/agent-sidebar-url.ts +39 -0
- package/src/shared/cache-control.ts +25 -0
- package/src/shared/cloudflare-globals.d.ts +34 -0
- package/src/shared/context-xray.ts +172 -0
- package/src/shared/embed-auth.ts +6 -0
- package/src/shared/index.ts +83 -0
- package/src/shared/llm-connection.ts +42 -0
- package/src/shared/markdown-block-split.ts +129 -0
- package/src/shared/mcp-connect-content.ts +130 -0
- package/src/shared/mcp-embed-headers.ts +175 -0
- package/src/shared/mcp-integration-config.ts +101 -0
- package/src/shared/merge-by-id.ts +14 -0
- package/src/shared/oauth-state.ts +39 -0
- package/src/shared/reasoning-effort.ts +228 -0
- package/src/shared/route-warmup-config.ts +128 -0
- package/src/shared/runtime.ts +31 -0
- package/src/shared/social-meta.ts +82 -0
- package/src/shared/streaming-text-smoothing.ts +184 -0
- package/src/shared/truncate.ts +13 -0
- package/src/shared/workspace-app-audience.ts +177 -0
- package/src/shared/workspace-app-id.ts +54 -0
- package/src/sharing/access.ts +585 -0
- package/src/sharing/actions/create-agent-resource-link.ts +91 -0
- package/src/sharing/actions/extension-change.ts +22 -0
- package/src/sharing/actions/list-resource-shares.ts +93 -0
- package/src/sharing/actions/set-resource-visibility.ts +91 -0
- package/src/sharing/actions/share-resource.ts +322 -0
- package/src/sharing/actions/unshare-resource.ts +72 -0
- package/src/sharing/index.ts +35 -0
- package/src/sharing/registry.ts +201 -0
- package/src/sharing/schema.ts +99 -0
- package/src/styles/agent-conversation.css +766 -0
- package/src/styles/agent-native.css +938 -0
- package/src/styles/blocks.css +1717 -0
- package/src/styles/chat-history-list.css +1 -0
- package/src/styles/rich-markdown-editor.css +1 -0
- package/src/tailwind.preset.ts +140 -0
- package/src/templates/chat/.agents/skills/actions/SKILL.md +32 -12
- package/src/templates/chat/.agents/skills/agent-native-docs/SKILL.md +21 -9
- package/src/templates/chat/.agents/skills/customizing-agent-native/SKILL.md +145 -0
- package/src/templates/chat/.agents/skills/self-modifying-code/SKILL.md +14 -2
- package/src/templates/chat/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/src/templates/chat/AGENTS.md +6 -2
- package/src/templates/chat/app/components/layout/Sidebar.tsx +51 -157
- package/src/templates/default/.agents/skills/actions/SKILL.md +32 -12
- package/src/templates/default/.agents/skills/agent-native-docs/SKILL.md +21 -9
- package/src/templates/default/.agents/skills/customizing-agent-native/SKILL.md +145 -0
- package/src/templates/default/.agents/skills/integration-webhooks/SKILL.md +323 -0
- package/src/templates/default/.agents/skills/onboarding/SKILL.md +56 -0
- package/src/templates/default/.agents/skills/secrets/SKILL.md +273 -0
- package/src/templates/default/.agents/skills/self-modifying-code/SKILL.md +14 -2
- package/src/templates/default/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/src/templates/default/AGENTS.md +26 -18
- package/src/templates/headless/.agents/skills/actions/SKILL.md +512 -0
- package/src/templates/headless/.agents/skills/agent-native-docs/SKILL.md +21 -9
- package/src/templates/headless/.agents/skills/customizing-agent-native/SKILL.md +145 -0
- package/src/templates/headless/.agents/skills/integration-webhooks/SKILL.md +323 -0
- package/src/templates/headless/.agents/skills/secrets/SKILL.md +273 -0
- package/src/templates/headless/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/src/templates/headless/AGENTS.md +8 -0
- package/src/templates/workspace-core/.agents/skills/actions/SKILL.md +32 -12
- package/src/templates/workspace-core/.agents/skills/agent-native-docs/SKILL.md +21 -9
- package/src/templates/workspace-core/.agents/skills/agent-native-toolkit/SKILL.md +7 -0
- package/src/templates/workspace-core/.agents/skills/customizing-agent-native/SKILL.md +145 -0
- package/src/templates/workspace-core/.agents/skills/self-modifying-code/SKILL.md +14 -2
- package/src/templates/workspace-core/.agents/skills/upgrade-agent-native/SKILL.md +6 -0
- package/src/templates/workspace-core/AGENTS.md +4 -0
- package/src/templates/workspace-root/AGENTS.md +4 -0
- package/src/terminal/cli-registry.ts +57 -0
- package/src/terminal/index.ts +22 -0
- package/src/terminal/pty-server.ts +389 -0
- package/src/terminal/terminal-plugin.ts +265 -0
- package/src/testing.ts +23 -0
- package/src/tracking/index.ts +10 -0
- package/src/tracking/providers.ts +422 -0
- package/src/tracking/registry.ts +102 -0
- package/src/tracking/route.ts +108 -0
- package/src/tracking/types.ts +16 -0
- package/src/transcription/builder-transcription.ts +118 -0
- package/src/triggers/actions/list-automations.ts +99 -0
- package/src/triggers/actions/manage-automation.ts +78 -0
- package/src/triggers/actions.ts +333 -0
- package/src/triggers/condition-evaluator.ts +163 -0
- package/src/triggers/dispatcher.ts +536 -0
- package/src/triggers/index.ts +13 -0
- package/src/triggers/routes.ts +322 -0
- package/src/triggers/types.ts +42 -0
- package/src/types/pglite.d.ts +26 -0
- package/src/usage/store.ts +698 -0
- package/src/vite/action-types-plugin.ts +481 -0
- package/src/vite/agent-web-plugin.ts +78 -0
- package/src/vite/agents-bundle-plugin.ts +185 -0
- package/src/vite/client.ts +3039 -0
- package/src/vite/index.ts +21 -0
- package/src/voice/index.ts +18 -0
- package/src/voice/voice-cleanup-prompt.ts +38 -0
- package/src/voice/voice-context.ts +217 -0
- package/src/voice/voice-replacements.ts +75 -0
- package/src/workspace-connections/credentials.ts +603 -0
- package/src/workspace-connections/index.ts +72 -0
- package/src/workspace-connections/lifecycle.ts +43 -0
- package/src/workspace-connections/store.ts +1943 -0
- package/src/workspace-files/index.ts +18 -0
- package/src/workspace-files/store.ts +339 -0
- package/src/workspace-files/tool.ts +266 -0
|
@@ -0,0 +1,1460 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `/mcp/connect` — frictionless external-agent connection. The legacy
|
|
3
|
+
* `/_agent-native/mcp/connect` alias is mounted by the core route plugin.
|
|
4
|
+
*
|
|
5
|
+
* A logged-in user on a deployed agent-native app (e.g. mail.agent-native.com)
|
|
6
|
+
* mints a per-user, scoped, revocable MCP bearer token WITHOUT ever copying a
|
|
7
|
+
* shared deployment secret. Two surfaces:
|
|
8
|
+
*
|
|
9
|
+
* 1. Browser — `GET /mcp/connect` renders a minimal in-app page (same inline
|
|
10
|
+
* HTML approach as the auth pages). The Authorize button POSTs to
|
|
11
|
+
* `/connect/token`, then shows the ready-to-paste `.mcp.json` entry, the
|
|
12
|
+
* `agent-native connect <origin>` one-liner, and the user's existing
|
|
13
|
+
* tokens with Revoke buttons.
|
|
14
|
+
* 2. CLI — an OAuth-2.0-device-authorization-style flow:
|
|
15
|
+
* POST /mcp/connect/device/start (unauth) → device_code + user_code
|
|
16
|
+
* GET /mcp/connect?user_code=… (browser) → user signs in & approves
|
|
17
|
+
* POST /mcp/connect/device/authorize (session) → binds user to the code
|
|
18
|
+
* POST /mcp/connect/device/poll (unauth) → mints + returns the token
|
|
19
|
+
*
|
|
20
|
+
* When A2A_SECRET exists, the minted token reuses the existing A2A signer
|
|
21
|
+
* (`signA2AToken`) and adds a random `jti` + `scope: "mcp-connect"` claim so
|
|
22
|
+
* it can be revoked. Deployments without A2A_SECRET mint the same standard MCP
|
|
23
|
+
* OAuth access-token format used by remote MCP OAuth, signed with the auth
|
|
24
|
+
* secret fallback and bound to the exact MCP resource URL.
|
|
25
|
+
*
|
|
26
|
+
* Node-only (crypto + the A2A signer), bundled alongside the other framework
|
|
27
|
+
* routes. Dialect-agnostic SQL lives in `connect-store.ts`.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
import { randomUUID } from "node:crypto";
|
|
31
|
+
|
|
32
|
+
import type { H3Event } from "h3";
|
|
33
|
+
import { getMethod, getHeader } from "h3";
|
|
34
|
+
|
|
35
|
+
import { signA2AToken } from "../a2a/client.js";
|
|
36
|
+
import { getOrgDomain } from "../org/context.js";
|
|
37
|
+
import {
|
|
38
|
+
getSession,
|
|
39
|
+
getConfiguredLoginHtml,
|
|
40
|
+
isLoopbackRequest,
|
|
41
|
+
} from "../server/auth.js";
|
|
42
|
+
import { readBody } from "../server/h3-helpers.js";
|
|
43
|
+
import {
|
|
44
|
+
MCP_CONNECT_GUIDES,
|
|
45
|
+
MCP_CONNECT_MCP_URL_TEMPLATE,
|
|
46
|
+
MCP_STATIC_TOKEN_FALLBACK,
|
|
47
|
+
interpolateMcpConnectTemplate,
|
|
48
|
+
} from "../shared/mcp-connect-content.js";
|
|
49
|
+
import {
|
|
50
|
+
recordMintedToken,
|
|
51
|
+
listTokens,
|
|
52
|
+
revokeToken,
|
|
53
|
+
normalizeServiceName,
|
|
54
|
+
serviceIdentityEmail,
|
|
55
|
+
createDeviceCode,
|
|
56
|
+
getDeviceCode,
|
|
57
|
+
approveDeviceCode,
|
|
58
|
+
consumeDeviceCode,
|
|
59
|
+
claimDeviceCodeForMint,
|
|
60
|
+
finishDeviceCodeMint,
|
|
61
|
+
releaseDeviceCodeMint,
|
|
62
|
+
expireDeviceCode,
|
|
63
|
+
MCP_CONNECT_OAUTH_CLIENT_ID,
|
|
64
|
+
MCP_CONNECT_SCOPE,
|
|
65
|
+
DEFAULT_TOKEN_TTL_DAYS,
|
|
66
|
+
MIN_TOKEN_TTL_DAYS,
|
|
67
|
+
MAX_TOKEN_TTL_DAYS,
|
|
68
|
+
DEVICE_CODE_TTL_MS,
|
|
69
|
+
} from "./connect-store.js";
|
|
70
|
+
import {
|
|
71
|
+
MCP_OAUTH_DEFAULT_SCOPE,
|
|
72
|
+
signMcpOAuthAccessToken,
|
|
73
|
+
} from "./oauth-token.js";
|
|
74
|
+
import { MCP_PUBLIC_ROUTE_PREFIX } from "./route-paths.js";
|
|
75
|
+
|
|
76
|
+
/** Device-flow poll interval hint (seconds). */
|
|
77
|
+
const DEVICE_POLL_INTERVAL_S = 3;
|
|
78
|
+
|
|
79
|
+
// Human-typable user code: 8 base32 chars, dashed XXXX-XXXX.
|
|
80
|
+
const USER_CODE_RE = /^[A-Z2-7]{4}-[A-Z2-7]{4}$/;
|
|
81
|
+
|
|
82
|
+
export interface McpConnectRouteOptions {
|
|
83
|
+
/** App id (directory under apps/, e.g. `mail`). Used for the server name. */
|
|
84
|
+
appId?: string;
|
|
85
|
+
/** Human app name shown on the connect page. */
|
|
86
|
+
appName?: string;
|
|
87
|
+
/** Explicit MCP server id to return in copyable config/device-flow grants. */
|
|
88
|
+
serverName?: string;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function json(body: unknown, status = 200): Response {
|
|
92
|
+
return new Response(JSON.stringify(body), {
|
|
93
|
+
status,
|
|
94
|
+
headers: { "Content-Type": "application/json" },
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function html(body: string, status = 200): Response {
|
|
99
|
+
return new Response(body, {
|
|
100
|
+
status,
|
|
101
|
+
headers: { "Content-Type": "text/html; charset=utf-8" },
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** Derive the running app's origin from request headers (same logic mountMCP
|
|
106
|
+
* uses) — `https` in prod / for non-loopback hosts, `http` for localhost. */
|
|
107
|
+
function deriveOrigin(event: H3Event): string {
|
|
108
|
+
const forwardedProto = getHeader(event, "x-forwarded-proto");
|
|
109
|
+
const host = getHeader(event, "x-forwarded-host") || getHeader(event, "host");
|
|
110
|
+
const proto =
|
|
111
|
+
forwardedProto?.split(",")[0]?.trim() ||
|
|
112
|
+
(host && /^(localhost|127\.0\.0\.1)(:|$)/.test(host) ? "http" : "https");
|
|
113
|
+
return host ? `${proto}://${host}` : "";
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function isLoopbackOrigin(origin: string): boolean {
|
|
117
|
+
try {
|
|
118
|
+
const hostname = new URL(origin).hostname;
|
|
119
|
+
return (
|
|
120
|
+
hostname === "localhost" ||
|
|
121
|
+
hostname === "127.0.0.1" ||
|
|
122
|
+
hostname === "::1" ||
|
|
123
|
+
hostname === "[::1]" ||
|
|
124
|
+
hostname.startsWith("127.")
|
|
125
|
+
);
|
|
126
|
+
} catch {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function normalizeBasePath(raw: string | undefined): string {
|
|
132
|
+
const trimmed = (raw ?? "").trim();
|
|
133
|
+
if (!trimmed || trimmed === "/") return "";
|
|
134
|
+
const withSlash = trimmed.startsWith("/") ? trimmed : `/${trimmed}`;
|
|
135
|
+
return withSlash.replace(/\/+$/, "");
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function configuredBasePath(): string {
|
|
139
|
+
return normalizeBasePath(
|
|
140
|
+
process.env.APP_BASE_PATH || process.env.VITE_APP_BASE_PATH,
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function joinAppPath(basePath: string, path: string): string {
|
|
145
|
+
if (!basePath) return path;
|
|
146
|
+
if (path === "/") return basePath;
|
|
147
|
+
return `${basePath}${path.startsWith("/") ? path : `/${path}`}`;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function appLabel(origin: string, options: McpConnectRouteOptions): string {
|
|
151
|
+
if (options.appId) return options.appId;
|
|
152
|
+
try {
|
|
153
|
+
const h = new URL(origin).hostname;
|
|
154
|
+
return h.split(".")[0] || h;
|
|
155
|
+
} catch {
|
|
156
|
+
return options.appName || "app";
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function serverName(origin: string, options: McpConnectRouteOptions): string {
|
|
161
|
+
const explicit = options.serverName?.trim();
|
|
162
|
+
if (explicit) return explicit;
|
|
163
|
+
return `agent-native-${appLabel(origin, options)}`;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function canUseDevOpenConnect(event: H3Event): boolean {
|
|
167
|
+
// Loopback determined from the real socket peer (isLoopbackRequest →
|
|
168
|
+
// getRequestIP without xForwardedFor), NOT a parsed `Host` header — the
|
|
169
|
+
// header is client-controlled, and it also handles IPv6 `::1`. A
|
|
170
|
+
// misconfigured public deploy with no secret thus can't unlock dev-open
|
|
171
|
+
// by spoofing `Host: localhost`.
|
|
172
|
+
return (
|
|
173
|
+
isLoopbackRequest(event) &&
|
|
174
|
+
isLoopbackOrigin(deriveOrigin(event)) &&
|
|
175
|
+
!process.env.A2A_SECRET?.trim() &&
|
|
176
|
+
!process.env.ACCESS_TOKEN?.trim() &&
|
|
177
|
+
!process.env.ACCESS_TOKENS?.trim()
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function escapeHtml(s: string): string {
|
|
182
|
+
return s
|
|
183
|
+
.replace(/&/g, "&")
|
|
184
|
+
.replace(/</g, "<")
|
|
185
|
+
.replace(/>/g, ">")
|
|
186
|
+
.replace(/"/g, """);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Resolve the org domain for a session. Used as the JWT `org_domain` claim so
|
|
191
|
+
* the receiving MCP endpoint can map it back to an org id (same as A2A). Best
|
|
192
|
+
* effort — a missing org just yields a user-scoped (no-org) token.
|
|
193
|
+
*/
|
|
194
|
+
async function resolveOrgDomain(
|
|
195
|
+
orgId: string | undefined,
|
|
196
|
+
): Promise<string | undefined> {
|
|
197
|
+
if (!orgId) return undefined;
|
|
198
|
+
try {
|
|
199
|
+
return (await getOrgDomain(orgId)) ?? undefined;
|
|
200
|
+
} catch {
|
|
201
|
+
return undefined;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function clampTtlDays(input: unknown): number {
|
|
206
|
+
const n = Number(input);
|
|
207
|
+
if (!Number.isFinite(n)) return DEFAULT_TOKEN_TTL_DAYS;
|
|
208
|
+
return Math.min(
|
|
209
|
+
MAX_TOKEN_TTL_DAYS,
|
|
210
|
+
Math.max(MIN_TOKEN_TTL_DAYS, Math.floor(n)),
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Mint a connect-scoped JWT and record it. The token value is returned to the
|
|
216
|
+
* caller exactly once and never persisted; only the random `jti` is stored for
|
|
217
|
+
* revocation.
|
|
218
|
+
*/
|
|
219
|
+
async function mintConnectToken(params: {
|
|
220
|
+
email: string;
|
|
221
|
+
orgId: string | undefined;
|
|
222
|
+
label: string | null;
|
|
223
|
+
ttlDays: number;
|
|
224
|
+
appUrl: string;
|
|
225
|
+
/** When `"full"`, embed `catalog_scope: "full"` in the JWT so this token
|
|
226
|
+
* bypasses the compact/connector-catalog tier (active by default whenever a
|
|
227
|
+
* `connectorCatalog` is declared) and gets the complete action surface. */
|
|
228
|
+
catalogScope?: "full";
|
|
229
|
+
}): Promise<{ token: string; jti: string }> {
|
|
230
|
+
const orgDomain = await resolveOrgDomain(params.orgId);
|
|
231
|
+
const jti = randomUUID();
|
|
232
|
+
const token = await signConnectToken({
|
|
233
|
+
ownerEmail: params.email,
|
|
234
|
+
orgId: params.orgId,
|
|
235
|
+
orgDomain,
|
|
236
|
+
appUrl: params.appUrl,
|
|
237
|
+
expiresIn: `${params.ttlDays}d`,
|
|
238
|
+
jti,
|
|
239
|
+
...(params.catalogScope === "full" ? { catalogScope: "full" } : {}),
|
|
240
|
+
});
|
|
241
|
+
await recordMintedToken({
|
|
242
|
+
jti,
|
|
243
|
+
ownerEmail: params.email,
|
|
244
|
+
orgId: params.orgId ?? null,
|
|
245
|
+
label: params.label,
|
|
246
|
+
});
|
|
247
|
+
return { token, jti };
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
async function signConnectToken(params: {
|
|
251
|
+
ownerEmail: string;
|
|
252
|
+
orgId: string | null | undefined;
|
|
253
|
+
orgDomain: string | undefined;
|
|
254
|
+
appUrl: string;
|
|
255
|
+
expiresIn: string;
|
|
256
|
+
jti: string;
|
|
257
|
+
/**
|
|
258
|
+
* When true, embed the org id directly as an `org_id` claim on the
|
|
259
|
+
* A2A-signed path (the OAuth-signed path already carries `params.orgId`).
|
|
260
|
+
* Used for org SERVICE tokens, whose synthetic identity must resolve to the
|
|
261
|
+
* org even when the org has no domain mapping. Personal tokens keep the
|
|
262
|
+
* original domain-based resolution — behavior unchanged.
|
|
263
|
+
*/
|
|
264
|
+
includeOrgIdClaim?: boolean;
|
|
265
|
+
/**
|
|
266
|
+
* When `"full"`, embed a `catalog_scope: "full"` claim so this token
|
|
267
|
+
* bypasses the compact/connector-catalog tier filter (active by default
|
|
268
|
+
* whenever a `connectorCatalog` is declared) and gets the complete action
|
|
269
|
+
* surface. Minted when the user connects with `agent-native connect --full-catalog`.
|
|
270
|
+
*/
|
|
271
|
+
catalogScope?: "full";
|
|
272
|
+
}): Promise<string> {
|
|
273
|
+
if (process.env.A2A_SECRET?.trim()) {
|
|
274
|
+
return signA2AToken(params.ownerEmail, params.orgDomain, undefined, {
|
|
275
|
+
preferGlobalSecret: true,
|
|
276
|
+
expiresIn: params.expiresIn,
|
|
277
|
+
extraClaims: {
|
|
278
|
+
jti: params.jti,
|
|
279
|
+
scope: MCP_CONNECT_SCOPE,
|
|
280
|
+
...(params.includeOrgIdClaim && params.orgId
|
|
281
|
+
? { org_id: params.orgId }
|
|
282
|
+
: {}),
|
|
283
|
+
...(params.catalogScope === "full" ? { catalog_scope: "full" } : {}),
|
|
284
|
+
},
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
return signMcpOAuthAccessToken({
|
|
289
|
+
ownerEmail: params.ownerEmail,
|
|
290
|
+
orgId: params.orgId ?? null,
|
|
291
|
+
orgDomain: params.orgDomain ?? null,
|
|
292
|
+
clientId: MCP_CONNECT_OAUTH_CLIENT_ID,
|
|
293
|
+
scope: MCP_OAUTH_DEFAULT_SCOPE,
|
|
294
|
+
resource: mcpResourceUrl(params.appUrl),
|
|
295
|
+
issuer: params.appUrl,
|
|
296
|
+
jti: params.jti,
|
|
297
|
+
expiresIn: params.expiresIn,
|
|
298
|
+
...(params.catalogScope === "full" ? { catalogScope: "full" } : {}),
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Mint an ORG SERVICE token: a connect-scoped, revocable bearer whose subject
|
|
304
|
+
* is the synthetic service identity `svc-<name>@service.<orgId>` instead of a
|
|
305
|
+
* person. Built for CI (e.g. the `PLAN_RECAP_TOKEN` GitHub secret) so the
|
|
306
|
+
* credential survives any individual leaving or revoking their personal
|
|
307
|
+
* tokens, and so rows created by CI are org-scoped (visible to org members)
|
|
308
|
+
* rather than owned by one person.
|
|
309
|
+
*
|
|
310
|
+
* The token value is returned exactly once and never persisted — only the
|
|
311
|
+
* random `jti` is stored, so the standard revocation path
|
|
312
|
+
* (`isJtiRevoked` in `verifyAuth`) applies to service tokens identically.
|
|
313
|
+
*
|
|
314
|
+
* Authorization is the CALLER'S responsibility: this function does not check
|
|
315
|
+
* org membership/role. The `create-org-service-token` action gates on org
|
|
316
|
+
* owner/admin before calling it.
|
|
317
|
+
*/
|
|
318
|
+
export async function mintOrgServiceToken(params: {
|
|
319
|
+
/** Human-readable service principal name, e.g. "ci" or "pr-recap". */
|
|
320
|
+
serviceName: string;
|
|
321
|
+
/** Org the service token acts for; becomes the resolved session orgId. */
|
|
322
|
+
orgId: string;
|
|
323
|
+
/** The human minting the token — stored for audit, never used as identity. */
|
|
324
|
+
createdBy: string;
|
|
325
|
+
/** 1–365 days; clamped. Defaults to DEFAULT_TOKEN_TTL_DAYS. */
|
|
326
|
+
ttlDays?: number;
|
|
327
|
+
/** App origin used for OAuth-signed tokens (resource/issuer binding). */
|
|
328
|
+
appUrl: string;
|
|
329
|
+
}): Promise<{
|
|
330
|
+
token: string;
|
|
331
|
+
jti: string;
|
|
332
|
+
id: string;
|
|
333
|
+
serviceName: string;
|
|
334
|
+
serviceEmail: string;
|
|
335
|
+
ttlDays: number;
|
|
336
|
+
}> {
|
|
337
|
+
const serviceName = normalizeServiceName(params.serviceName);
|
|
338
|
+
const serviceEmail = serviceIdentityEmail(serviceName, params.orgId);
|
|
339
|
+
const orgDomain = await resolveOrgDomain(params.orgId);
|
|
340
|
+
const ttlDays = clampTtlDays(params.ttlDays ?? DEFAULT_TOKEN_TTL_DAYS);
|
|
341
|
+
const jti = randomUUID();
|
|
342
|
+
const token = await signConnectToken({
|
|
343
|
+
ownerEmail: serviceEmail,
|
|
344
|
+
orgId: params.orgId,
|
|
345
|
+
orgDomain,
|
|
346
|
+
appUrl: params.appUrl,
|
|
347
|
+
expiresIn: `${ttlDays}d`,
|
|
348
|
+
jti,
|
|
349
|
+
includeOrgIdClaim: true,
|
|
350
|
+
});
|
|
351
|
+
const id = await recordMintedToken({
|
|
352
|
+
jti,
|
|
353
|
+
ownerEmail: serviceEmail,
|
|
354
|
+
orgId: params.orgId,
|
|
355
|
+
label: `Service token: ${serviceName}`,
|
|
356
|
+
kind: "service",
|
|
357
|
+
serviceName,
|
|
358
|
+
createdBy: params.createdBy,
|
|
359
|
+
});
|
|
360
|
+
return { token, jti, id, serviceName, serviceEmail, ttlDays };
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
function mcpResultPayload(
|
|
364
|
+
appUrl: string,
|
|
365
|
+
options: McpConnectRouteOptions,
|
|
366
|
+
auth: { token?: string; ownerEmail?: string },
|
|
367
|
+
) {
|
|
368
|
+
const mcpUrl = mcpResourceUrl(appUrl);
|
|
369
|
+
const name = serverName(appUrl, options);
|
|
370
|
+
const headers: Record<string, string> = {};
|
|
371
|
+
if (auth.token) headers.Authorization = `Bearer ${auth.token}`;
|
|
372
|
+
if (!auth.token && auth.ownerEmail) {
|
|
373
|
+
headers["X-Agent-Native-Owner-Email"] = auth.ownerEmail;
|
|
374
|
+
}
|
|
375
|
+
// Intentionally do NOT inject the full-catalog header here. Every connector
|
|
376
|
+
// used to receive it, which silently forced the ~105-tool full catalog on
|
|
377
|
+
// every client. Full-catalog intent now lives durably in the token itself
|
|
378
|
+
// (`catalog_scope: "full"`, minted only by `connect --full-catalog`), so a
|
|
379
|
+
// normal connection defaults to the compact/connector catalog + tool-search.
|
|
380
|
+
return {
|
|
381
|
+
token: auth.token ?? "",
|
|
382
|
+
mcpUrl,
|
|
383
|
+
serverName: name,
|
|
384
|
+
mcpServerEntry: {
|
|
385
|
+
type: "http" as const,
|
|
386
|
+
url: mcpUrl,
|
|
387
|
+
...(Object.keys(headers).length ? { headers } : {}),
|
|
388
|
+
},
|
|
389
|
+
cli: `npx @agent-native/core@latest connect ${appUrl}`,
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
function mcpResourceUrl(appUrl: string): string {
|
|
394
|
+
return `${appUrl}${MCP_PUBLIC_ROUTE_PREFIX}`;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
// ---------------------------------------------------------------------------
|
|
398
|
+
// Connect page (server-rendered HTML string)
|
|
399
|
+
// ---------------------------------------------------------------------------
|
|
400
|
+
|
|
401
|
+
function agentNativeMarkSvg(className: string, gradientId: string): string {
|
|
402
|
+
return `<svg class="${className}" width="114" height="66" viewBox="0 0 114 66" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false">
|
|
403
|
+
<path d="M24.5537 65.7695H0L15.0859 39.4619L37.708 0L60.4912 39.4619H39.6396L24.5537 65.7695Z" fill="white"/>
|
|
404
|
+
<path d="M89.446 0H114L76.2921 65.7704H51.7383L89.446 0Z" fill="url(#${gradientId})"/>
|
|
405
|
+
<defs>
|
|
406
|
+
<linearGradient id="${gradientId}" x1="101.702" y1="67.4791" x2="113.672" y2="-37.4275" gradientUnits="userSpaceOnUse">
|
|
407
|
+
<stop stop-color="#00B5FF"/>
|
|
408
|
+
<stop offset="1" stop-color="#48FFE4"/>
|
|
409
|
+
</linearGradient>
|
|
410
|
+
</defs>
|
|
411
|
+
</svg>`;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
function renderConnectGuide(
|
|
415
|
+
guide: (typeof MCP_CONNECT_GUIDES)[number],
|
|
416
|
+
values: Parameters<typeof interpolateMcpConnectTemplate>[1],
|
|
417
|
+
): string {
|
|
418
|
+
const guideId = escapeHtml(guide.id);
|
|
419
|
+
const content = [
|
|
420
|
+
guide.steps?.length
|
|
421
|
+
? `<ol>${guide.steps
|
|
422
|
+
.map(
|
|
423
|
+
(step) =>
|
|
424
|
+
`<li>${escapeHtml(interpolateMcpConnectTemplate(step, values))}</li>`,
|
|
425
|
+
)
|
|
426
|
+
.join("")}</ol>`
|
|
427
|
+
: "",
|
|
428
|
+
guide.intro
|
|
429
|
+
? `<p>${escapeHtml(interpolateMcpConnectTemplate(guide.intro, values))}</p>`
|
|
430
|
+
: "",
|
|
431
|
+
guide.commandTemplate
|
|
432
|
+
? `<pre id="${guideId}Command">${escapeHtml(interpolateMcpConnectTemplate(guide.commandTemplate, values))}</pre>
|
|
433
|
+
<button type="button" class="primary-link compact" data-copy="${guideId}Command">${escapeHtml(guide.action?.label ?? "Copy")}</button>`
|
|
434
|
+
: "",
|
|
435
|
+
guide.configTemplate
|
|
436
|
+
? `<pre id="${guideId}Config">${escapeHtml(interpolateMcpConnectTemplate(guide.configTemplate, values))}</pre>
|
|
437
|
+
<button type="button" class="primary-link compact" data-copy="${guideId}Config">${escapeHtml(guide.action?.label ?? "Copy")}</button>`
|
|
438
|
+
: "",
|
|
439
|
+
guide.action?.kind === "link" && guide.action.href
|
|
440
|
+
? `<a class="primary-link" href="${escapeHtml(guide.action.href)}" target="_blank" rel="noopener noreferrer">${escapeHtml(guide.action.label)}</a>`
|
|
441
|
+
: "",
|
|
442
|
+
guide.note
|
|
443
|
+
? `<p class="hint">${escapeHtml(interpolateMcpConnectTemplate(guide.note, values))}</p>`
|
|
444
|
+
: "",
|
|
445
|
+
].join("\n");
|
|
446
|
+
|
|
447
|
+
return `<div class="tab-panel${guide.id === MCP_CONNECT_GUIDES[0]?.id ? " is-active" : ""}" role="tabpanel" data-panel="${guideId}">${content}</div>`;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
function renderConnectPage(params: {
|
|
451
|
+
connectBasePath: string;
|
|
452
|
+
email: string;
|
|
453
|
+
appName: string;
|
|
454
|
+
appUrl: string;
|
|
455
|
+
serverId: string;
|
|
456
|
+
userCode: string | null;
|
|
457
|
+
}): string {
|
|
458
|
+
const { connectBasePath, email, appName, appUrl, serverId, userCode } =
|
|
459
|
+
params;
|
|
460
|
+
const safeEmail = escapeHtml(email);
|
|
461
|
+
const safeApp = escapeHtml(appName);
|
|
462
|
+
const mcpUrl = interpolateMcpConnectTemplate(MCP_CONNECT_MCP_URL_TEMPLATE, {
|
|
463
|
+
appName,
|
|
464
|
+
appUrl,
|
|
465
|
+
mcpUrl: "",
|
|
466
|
+
serverId,
|
|
467
|
+
});
|
|
468
|
+
const safeMcpUrl = escapeHtml(mcpUrl);
|
|
469
|
+
const connectTemplateValues = { appName, appUrl, mcpUrl, serverId };
|
|
470
|
+
const brandMarkSvg = agentNativeMarkSvg(
|
|
471
|
+
"brand-mark",
|
|
472
|
+
"agent-native-connect-brand-gradient",
|
|
473
|
+
);
|
|
474
|
+
const flowMarkSvg = agentNativeMarkSvg(
|
|
475
|
+
"flow-mark",
|
|
476
|
+
"agent-native-connect-flow-gradient",
|
|
477
|
+
);
|
|
478
|
+
const safeUserCode =
|
|
479
|
+
userCode && USER_CODE_RE.test(userCode) ? escapeHtml(userCode) : "";
|
|
480
|
+
const guideTabsHtml = MCP_CONNECT_GUIDES.map(
|
|
481
|
+
(guide) =>
|
|
482
|
+
`<button type="button" class="tab${guide.id === MCP_CONNECT_GUIDES[0]?.id ? " is-active" : ""}" role="tab" data-tab="${escapeHtml(guide.id)}" aria-selected="${guide.id === MCP_CONNECT_GUIDES[0]?.id ? "true" : "false"}">${escapeHtml(guide.label)}</button>`,
|
|
483
|
+
).join("\n");
|
|
484
|
+
const guidePanelsHtml = MCP_CONNECT_GUIDES.map((guide) =>
|
|
485
|
+
renderConnectGuide(guide, connectTemplateValues),
|
|
486
|
+
).join("\n");
|
|
487
|
+
const setupHtml = safeUserCode
|
|
488
|
+
? ""
|
|
489
|
+
: `
|
|
490
|
+
<div class="mcp-url-block">
|
|
491
|
+
<div class="section-label">Your MCP URL</div>
|
|
492
|
+
<div class="url-row">
|
|
493
|
+
<code id="mcpUrlValue">${safeMcpUrl}</code>
|
|
494
|
+
<button type="button" class="ghost" data-copy="mcpUrlValue" aria-label="Copy MCP URL">Copy</button>
|
|
495
|
+
</div>
|
|
496
|
+
</div>
|
|
497
|
+
|
|
498
|
+
<details id="assistantSetup" class="hosts">
|
|
499
|
+
<summary>
|
|
500
|
+
<span class="connections-title">Assistant setup</span>
|
|
501
|
+
<span class="connections-state">MCP URL guides</span>
|
|
502
|
+
<span class="chev" aria-hidden="true"></span>
|
|
503
|
+
</summary>
|
|
504
|
+
<div class="hosts-body">
|
|
505
|
+
<div class="section-label">Pick your AI assistant</div>
|
|
506
|
+
<div class="tabs" role="tablist" aria-label="Choose your AI assistant">
|
|
507
|
+
${guideTabsHtml}
|
|
508
|
+
</div>
|
|
509
|
+
${guidePanelsHtml}
|
|
510
|
+
</div>
|
|
511
|
+
</details>`;
|
|
512
|
+
const tokenAdvancedOptionsHtml = safeUserCode
|
|
513
|
+
? ""
|
|
514
|
+
: `
|
|
515
|
+
<details class="advanced">
|
|
516
|
+
<summary>
|
|
517
|
+
Advanced options
|
|
518
|
+
<span class="chev" aria-hidden="true"></span>
|
|
519
|
+
</summary>
|
|
520
|
+
<div class="advanced-body">
|
|
521
|
+
<div class="field">
|
|
522
|
+
<label for="label">Label (optional)</label>
|
|
523
|
+
<input id="label" type="text" placeholder="e.g. Claude Code on my laptop" maxlength="120" />
|
|
524
|
+
</div>
|
|
525
|
+
<div class="field">
|
|
526
|
+
<label for="ttl">Expires in (days, 1–365)</label>
|
|
527
|
+
<input id="ttl" type="number" min="1" max="365" value="${DEFAULT_TOKEN_TTL_DAYS}" />
|
|
528
|
+
</div>
|
|
529
|
+
</div>
|
|
530
|
+
</details>`;
|
|
531
|
+
return `<!DOCTYPE html>
|
|
532
|
+
<html lang="en">
|
|
533
|
+
<head>
|
|
534
|
+
<meta charset="UTF-8">
|
|
535
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
536
|
+
<title>Connect ${safeApp}</title>
|
|
537
|
+
<style>
|
|
538
|
+
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
|
539
|
+
:root {
|
|
540
|
+
color-scheme: dark;
|
|
541
|
+
--bg: #09090b; --panel: #121214; --panel-2: #0c0c0e;
|
|
542
|
+
--panel-soft: rgba(255,255,255,0.025);
|
|
543
|
+
--border: rgba(255,255,255,0.075); --border-strong: rgba(255,255,255,0.14);
|
|
544
|
+
--text: #f7f7f8; --muted: #a1a1aa; --subtle: #74747d;
|
|
545
|
+
--accent: #f4f4f5; --accent-fg: #09090b;
|
|
546
|
+
--ring: rgba(250,250,250,0.55);
|
|
547
|
+
--error: #fca5a5; --error-bg: rgba(127,29,29,0.18);
|
|
548
|
+
--ok: #86efac; --ok-bg: rgba(20,83,45,0.12); --ok-border: rgba(134,239,172,0.18);
|
|
549
|
+
}
|
|
550
|
+
html, body { -webkit-font-smoothing: antialiased; }
|
|
551
|
+
body {
|
|
552
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
553
|
+
background: linear-gradient(180deg, #101013 0%, var(--bg) 58%);
|
|
554
|
+
color: var(--text); display: flex; align-items: center;
|
|
555
|
+
justify-content: center; min-height: 100vh; padding: 1.5rem 1rem;
|
|
556
|
+
}
|
|
557
|
+
.card {
|
|
558
|
+
width: 100%; max-width: 440px;
|
|
559
|
+
background: var(--panel); border: 1px solid var(--border);
|
|
560
|
+
border-radius: 8px; box-shadow: 0 1px 0 rgba(255,255,255,0.04) inset,
|
|
561
|
+
0 30px 90px rgba(0,0,0,0.5);
|
|
562
|
+
padding: 1.25rem;
|
|
563
|
+
}
|
|
564
|
+
.topbar {
|
|
565
|
+
display: flex; align-items: center; justify-content: space-between;
|
|
566
|
+
gap: 0.75rem; margin-bottom: 1.75rem;
|
|
567
|
+
}
|
|
568
|
+
.brand-lockup {
|
|
569
|
+
display: flex; align-items: center; gap: 0.55rem;
|
|
570
|
+
color: var(--muted); font-size: 0.78rem; font-weight: 600;
|
|
571
|
+
}
|
|
572
|
+
.brand-mark { width: 18px; height: auto; display: block; }
|
|
573
|
+
.app-pill {
|
|
574
|
+
max-width: 50%; border: 1px solid var(--border);
|
|
575
|
+
border-radius: 999px; padding: 0.28rem 0.55rem;
|
|
576
|
+
color: var(--subtle); font-size: 0.72rem; line-height: 1;
|
|
577
|
+
overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
|
|
578
|
+
}
|
|
579
|
+
.hero { padding: 0 0.75rem; text-align: center; }
|
|
580
|
+
.flow {
|
|
581
|
+
display: flex; align-items: center; justify-content: center;
|
|
582
|
+
gap: 0; margin: 0 auto 1.1rem; width: fit-content;
|
|
583
|
+
}
|
|
584
|
+
.flow .tile {
|
|
585
|
+
width: 42px; height: 42px; border-radius: 8px;
|
|
586
|
+
display: flex; align-items: center; justify-content: center;
|
|
587
|
+
background: var(--panel-2); border: 1px solid var(--border-strong);
|
|
588
|
+
color: var(--text); flex-shrink: 0;
|
|
589
|
+
}
|
|
590
|
+
.flow-mark { width: 26px; height: auto; display: block; }
|
|
591
|
+
.flow .agent-symbol {
|
|
592
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
593
|
+
font-size: 0.95rem; font-weight: 700; letter-spacing: -0.04em;
|
|
594
|
+
}
|
|
595
|
+
.flow .conn {
|
|
596
|
+
width: 30px; height: 1px; flex-shrink: 0;
|
|
597
|
+
background: linear-gradient(90deg, transparent, var(--border-strong), transparent);
|
|
598
|
+
background-position: center;
|
|
599
|
+
}
|
|
600
|
+
.eyebrow {
|
|
601
|
+
text-align: center; font-size: 0.72rem; font-weight: 600;
|
|
602
|
+
letter-spacing: 0.08em; text-transform: uppercase;
|
|
603
|
+
color: var(--subtle); margin-bottom: 0.55rem;
|
|
604
|
+
}
|
|
605
|
+
h1 {
|
|
606
|
+
text-align: center; font-size: 1.45rem; font-weight: 680;
|
|
607
|
+
line-height: 1.25; margin-bottom: 0.7rem;
|
|
608
|
+
letter-spacing: -0.01em;
|
|
609
|
+
}
|
|
610
|
+
.identity {
|
|
611
|
+
display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
|
|
612
|
+
gap: 0.25rem 0.45rem; color: var(--subtle); font-size: 0.78rem;
|
|
613
|
+
line-height: 1.35; margin: 0 auto 1.5rem; max-width: 34ch;
|
|
614
|
+
}
|
|
615
|
+
.identity strong { color: var(--muted); font-weight: 600; }
|
|
616
|
+
.device-strip {
|
|
617
|
+
display: flex; align-items: center; justify-content: space-between;
|
|
618
|
+
gap: 0.75rem; border: 1px solid var(--border);
|
|
619
|
+
border-radius: 8px; padding: 0.5rem 0.65rem; margin: 0 0 0.9rem;
|
|
620
|
+
background: var(--panel-soft); color: var(--muted);
|
|
621
|
+
}
|
|
622
|
+
.device-strip .label {
|
|
623
|
+
font-size: 0.76rem; font-weight: 560; color: var(--subtle);
|
|
624
|
+
}
|
|
625
|
+
.device-strip .value {
|
|
626
|
+
font-size: 0.78rem; font-weight: 650;
|
|
627
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
628
|
+
letter-spacing: 0.08em; color: var(--muted);
|
|
629
|
+
}
|
|
630
|
+
button {
|
|
631
|
+
cursor: pointer; font: inherit; font-weight: 600; border: none;
|
|
632
|
+
border-radius: 8px; padding: 0.78rem 1rem;
|
|
633
|
+
}
|
|
634
|
+
button:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
|
|
635
|
+
.primary {
|
|
636
|
+
background: var(--accent); color: var(--accent-fg); width: 100%;
|
|
637
|
+
font-size: 0.95rem;
|
|
638
|
+
}
|
|
639
|
+
.primary:hover:not(:disabled) { background: #e4e4e7; }
|
|
640
|
+
.primary:disabled { opacity: 0.55; cursor: default; }
|
|
641
|
+
.primary.is-loading {
|
|
642
|
+
display: inline-flex; align-items: center; justify-content: center;
|
|
643
|
+
gap: 0.55rem; opacity: 1;
|
|
644
|
+
}
|
|
645
|
+
.primary.is-loading::before {
|
|
646
|
+
content: ""; width: 1rem; height: 1rem; flex: 0 0 auto;
|
|
647
|
+
border-radius: 999px; border: 2px solid rgba(0,0,0,0.22);
|
|
648
|
+
border-top-color: var(--accent-fg);
|
|
649
|
+
animation: spin 0.75s linear infinite;
|
|
650
|
+
}
|
|
651
|
+
@keyframes spin { to { transform: rotate(360deg); } }
|
|
652
|
+
@media (prefers-reduced-motion: reduce) {
|
|
653
|
+
.primary.is-loading::before { animation: none; }
|
|
654
|
+
}
|
|
655
|
+
.ghost {
|
|
656
|
+
background: transparent; color: var(--muted);
|
|
657
|
+
border: 1px solid var(--border-strong); padding: 0.35rem 0.7rem;
|
|
658
|
+
font-size: 0.78rem; font-weight: 500; border-radius: 8px;
|
|
659
|
+
}
|
|
660
|
+
.ghost:hover:not(:disabled) { color: var(--text); border-color: var(--subtle); }
|
|
661
|
+
pre {
|
|
662
|
+
background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px;
|
|
663
|
+
padding: 0.9rem; font-size: 0.78rem; line-height: 1.5; overflow-x: auto;
|
|
664
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
665
|
+
color: #d4d4d8; margin: 0.5rem 0 1rem;
|
|
666
|
+
}
|
|
667
|
+
/* Advanced disclosure */
|
|
668
|
+
.advanced { margin: 0 0 1rem; }
|
|
669
|
+
.advanced > summary {
|
|
670
|
+
list-style: none; cursor: pointer; user-select: none;
|
|
671
|
+
display: flex; align-items: center; justify-content: center; gap: 0.35rem;
|
|
672
|
+
color: var(--subtle); font-size: 0.8rem; font-weight: 500;
|
|
673
|
+
padding: 0.5rem 0; text-align: center;
|
|
674
|
+
}
|
|
675
|
+
.advanced > summary::-webkit-details-marker { display: none; }
|
|
676
|
+
.advanced > summary:hover { color: var(--muted); }
|
|
677
|
+
.advanced > summary:focus-visible { outline: 2px solid var(--ring);
|
|
678
|
+
outline-offset: 2px; border-radius: 6px; }
|
|
679
|
+
.advanced > summary .chev {
|
|
680
|
+
width: 7px; height: 7px; border-right: 1.5px solid currentColor;
|
|
681
|
+
border-bottom: 1.5px solid currentColor; transform: rotate(45deg);
|
|
682
|
+
transition: transform 0.15s ease; margin-top: -3px;
|
|
683
|
+
}
|
|
684
|
+
.advanced[open] > summary .chev { transform: rotate(225deg); margin-top: 2px; }
|
|
685
|
+
.advanced-body {
|
|
686
|
+
padding: 0.85rem 0.1rem 0.25rem;
|
|
687
|
+
}
|
|
688
|
+
.field { margin-bottom: 0.9rem; }
|
|
689
|
+
.field:last-child { margin-bottom: 0; }
|
|
690
|
+
.field label { display: block; font-size: 0.78rem; color: var(--muted);
|
|
691
|
+
margin-bottom: 0.35rem; }
|
|
692
|
+
.field input {
|
|
693
|
+
width: 100%; padding: 0.6rem 0.7rem; font: inherit; color: var(--text);
|
|
694
|
+
background: var(--panel-2); border: 1px solid var(--border-strong);
|
|
695
|
+
border-radius: 8px;
|
|
696
|
+
}
|
|
697
|
+
.field input:focus-visible {
|
|
698
|
+
outline: none; border-color: var(--ring);
|
|
699
|
+
box-shadow: 0 0 0 3px rgba(250,250,250,0.12);
|
|
700
|
+
}
|
|
701
|
+
.connections {
|
|
702
|
+
margin-top: 1.1rem; border-top: 1px solid var(--border);
|
|
703
|
+
padding-top: 0.35rem;
|
|
704
|
+
}
|
|
705
|
+
.connections > summary {
|
|
706
|
+
list-style: none; cursor: pointer; user-select: none;
|
|
707
|
+
display: flex; align-items: center; gap: 0.55rem;
|
|
708
|
+
min-height: 2.2rem; color: var(--muted); font-size: 0.82rem;
|
|
709
|
+
}
|
|
710
|
+
.connections > summary::-webkit-details-marker { display: none; }
|
|
711
|
+
.connections > summary:focus-visible {
|
|
712
|
+
outline: 2px solid var(--ring); outline-offset: 2px; border-radius: 6px;
|
|
713
|
+
}
|
|
714
|
+
.connections-title { font-weight: 600; color: var(--muted); }
|
|
715
|
+
.connections-state {
|
|
716
|
+
margin-left: auto; color: var(--subtle); font-size: 0.73rem;
|
|
717
|
+
border: 1px solid var(--border); border-radius: 999px;
|
|
718
|
+
padding: 0.18rem 0.45rem; line-height: 1;
|
|
719
|
+
}
|
|
720
|
+
.connections .chev {
|
|
721
|
+
width: 7px; height: 7px; border-right: 1.5px solid currentColor;
|
|
722
|
+
border-bottom: 1.5px solid currentColor; transform: rotate(45deg);
|
|
723
|
+
transition: transform 0.15s ease; margin: -3px 0 0 0.15rem;
|
|
724
|
+
}
|
|
725
|
+
.connections[open] .chev { transform: rotate(225deg); margin-top: 2px; }
|
|
726
|
+
.token-list { padding-top: 0.4rem; }
|
|
727
|
+
.tok { display: flex; align-items: center; justify-content: space-between;
|
|
728
|
+
gap: 0.75rem; padding: 0.6rem 0; border-bottom: 1px solid var(--border);
|
|
729
|
+
font-size: 0.83rem; }
|
|
730
|
+
.tok:last-child { border-bottom: none; }
|
|
731
|
+
.tok .meta { color: var(--subtle); font-size: 0.74rem; margin-top: 0.1rem; }
|
|
732
|
+
.tok.revoked { opacity: 0.45; }
|
|
733
|
+
.empty-state {
|
|
734
|
+
color: var(--subtle); font-size: 0.78rem; line-height: 1.45;
|
|
735
|
+
padding: 0.3rem 0 0.45rem;
|
|
736
|
+
}
|
|
737
|
+
.msg { font-size: 0.83rem; padding: 0.7rem 0.8rem; border-radius: 8px;
|
|
738
|
+
margin-bottom: 0.9rem; display: none; line-height: 1.4; }
|
|
739
|
+
.msg.err { display: block; color: var(--error); background: var(--error-bg);
|
|
740
|
+
border: 1px solid rgba(252,165,165,0.16); }
|
|
741
|
+
.msg.ok { display: block; color: var(--ok); background: var(--ok-bg);
|
|
742
|
+
border: 1px solid var(--ok-border); }
|
|
743
|
+
.result-panel { padding-top: 0.15rem; }
|
|
744
|
+
.result-title {
|
|
745
|
+
color: var(--text); font-size: 0.95rem; font-weight: 650;
|
|
746
|
+
text-align: center; margin-bottom: 0.35rem;
|
|
747
|
+
}
|
|
748
|
+
.result-copy {
|
|
749
|
+
color: var(--muted); font-size: 0.83rem; line-height: 1.45;
|
|
750
|
+
text-align: center; margin: 0 auto 0.85rem; max-width: 34ch;
|
|
751
|
+
}
|
|
752
|
+
.section-label {
|
|
753
|
+
color: var(--subtle); font-size: 0.7rem; font-weight: 650;
|
|
754
|
+
letter-spacing: 0.08em; text-transform: uppercase; margin-top: 0.85rem;
|
|
755
|
+
}
|
|
756
|
+
@media (max-width: 480px) {
|
|
757
|
+
body { align-items: flex-start; padding: 0.75rem; }
|
|
758
|
+
.card { padding: 1rem; }
|
|
759
|
+
.hero { padding: 0; }
|
|
760
|
+
.topbar { margin-bottom: 1.35rem; }
|
|
761
|
+
h1 { font-size: 1.3rem; }
|
|
762
|
+
.app-pill { max-width: 46%; }
|
|
763
|
+
pre { font-size: 0.72rem; }
|
|
764
|
+
}
|
|
765
|
+
/* MCP URL display + per-host tabs (the non-dev path). */
|
|
766
|
+
.mcp-url-block { margin: 0 0 1rem; }
|
|
767
|
+
.url-row {
|
|
768
|
+
display: flex; align-items: center; gap: 0.5rem;
|
|
769
|
+
background: var(--panel-2); border: 1px solid var(--border-strong);
|
|
770
|
+
border-radius: 8px; padding: 0.45rem 0.5rem 0.45rem 0.75rem;
|
|
771
|
+
}
|
|
772
|
+
.url-row code {
|
|
773
|
+
flex: 1 1 auto; min-width: 0; overflow-x: auto; white-space: nowrap;
|
|
774
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
775
|
+
font-size: 0.78rem; color: var(--text);
|
|
776
|
+
}
|
|
777
|
+
.url-row .ghost { flex: 0 0 auto; }
|
|
778
|
+
.hosts {
|
|
779
|
+
margin: 0 0 1rem; border-top: 1px solid var(--border);
|
|
780
|
+
border-bottom: 1px solid var(--border); padding: 0.35rem 0;
|
|
781
|
+
}
|
|
782
|
+
.hosts > summary {
|
|
783
|
+
list-style: none; cursor: pointer; user-select: none;
|
|
784
|
+
display: flex; align-items: center; gap: 0.55rem;
|
|
785
|
+
min-height: 2.2rem; color: var(--muted); font-size: 0.82rem;
|
|
786
|
+
}
|
|
787
|
+
.hosts > summary::-webkit-details-marker { display: none; }
|
|
788
|
+
.hosts > summary:focus-visible {
|
|
789
|
+
outline: 2px solid var(--ring); outline-offset: 2px; border-radius: 6px;
|
|
790
|
+
}
|
|
791
|
+
.hosts > summary .chev {
|
|
792
|
+
width: 7px; height: 7px; border-right: 1.5px solid currentColor;
|
|
793
|
+
border-bottom: 1.5px solid currentColor; transform: rotate(45deg);
|
|
794
|
+
transition: transform 0.15s ease; margin: -3px 0 0 0.15rem;
|
|
795
|
+
}
|
|
796
|
+
.hosts[open] > summary .chev { transform: rotate(225deg); margin-top: 2px; }
|
|
797
|
+
.hosts-body { padding: 0.15rem 0 0.25rem; }
|
|
798
|
+
.tabs {
|
|
799
|
+
display: flex; flex-wrap: wrap; gap: 0.25rem;
|
|
800
|
+
border-bottom: 1px solid var(--border); margin-bottom: 0.75rem;
|
|
801
|
+
padding-bottom: 0.4rem;
|
|
802
|
+
}
|
|
803
|
+
.tab {
|
|
804
|
+
background: transparent; color: var(--subtle);
|
|
805
|
+
border: 1px solid transparent;
|
|
806
|
+
padding: 0.35rem 0.65rem; font-size: 0.8rem; font-weight: 600;
|
|
807
|
+
border-radius: 6px;
|
|
808
|
+
}
|
|
809
|
+
.tab:hover { color: var(--muted); background: var(--panel-soft); }
|
|
810
|
+
.tab.is-active {
|
|
811
|
+
color: var(--text); background: var(--panel-2);
|
|
812
|
+
border-color: var(--border-strong);
|
|
813
|
+
}
|
|
814
|
+
.tab-panel { display: none; }
|
|
815
|
+
.tab-panel.is-active { display: block; }
|
|
816
|
+
.tab-panel ol { margin: 0 0 0.6rem 1.1rem; padding: 0; }
|
|
817
|
+
.tab-panel li {
|
|
818
|
+
margin-bottom: 0.3rem; font-size: 0.86rem; line-height: 1.5;
|
|
819
|
+
color: var(--muted);
|
|
820
|
+
}
|
|
821
|
+
.tab-panel li strong { color: var(--text); font-weight: 650; }
|
|
822
|
+
.tab-panel a {
|
|
823
|
+
color: var(--text); text-decoration: underline;
|
|
824
|
+
text-underline-offset: 2px;
|
|
825
|
+
}
|
|
826
|
+
.tab-panel p {
|
|
827
|
+
font-size: 0.84rem; color: var(--muted); margin: 0.4rem 0;
|
|
828
|
+
line-height: 1.5;
|
|
829
|
+
}
|
|
830
|
+
.tab-panel .hint {
|
|
831
|
+
font-size: 0.78rem; color: var(--subtle); margin-top: 0.5rem;
|
|
832
|
+
}
|
|
833
|
+
.tab-panel code {
|
|
834
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
835
|
+
font-size: 0.78rem; color: var(--text);
|
|
836
|
+
background: var(--panel-2); padding: 0.05rem 0.3rem;
|
|
837
|
+
border-radius: 4px;
|
|
838
|
+
}
|
|
839
|
+
.tab-panel pre { margin: 0.4rem 0 0.5rem; }
|
|
840
|
+
/* Per-tab primary CTA — visually distinct from the static-token mint
|
|
841
|
+
* button below. Either a link (Open Claude →) or a copy command button.
|
|
842
|
+
*/
|
|
843
|
+
.primary-link {
|
|
844
|
+
display: inline-flex; align-items: center; justify-content: center;
|
|
845
|
+
gap: 0.35rem; min-height: 36px; padding: 0.45rem 0.85rem;
|
|
846
|
+
background: var(--panel-2); color: var(--text);
|
|
847
|
+
border: 1px solid var(--border-strong); border-radius: 8px;
|
|
848
|
+
font-size: 0.86rem; font-weight: 650; text-decoration: none;
|
|
849
|
+
cursor: pointer; width: auto; max-width: 100%; text-align: center;
|
|
850
|
+
margin: 0.5rem 0 0.2rem;
|
|
851
|
+
}
|
|
852
|
+
.tab-panel a.primary-link {
|
|
853
|
+
color: var(--text); text-decoration: none;
|
|
854
|
+
}
|
|
855
|
+
.primary-link:hover {
|
|
856
|
+
background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.2);
|
|
857
|
+
}
|
|
858
|
+
.primary-link.compact { min-width: 0; }
|
|
859
|
+
.copy-flash {
|
|
860
|
+
color: var(--ok) !important;
|
|
861
|
+
border-color: var(--ok-border) !important;
|
|
862
|
+
}
|
|
863
|
+
.static-token-mint .static-token-body { padding-top: 0.5rem; }
|
|
864
|
+
.static-token-mint > summary .connections-state {
|
|
865
|
+
font-style: normal;
|
|
866
|
+
}
|
|
867
|
+
@media (min-width: 560px) {
|
|
868
|
+
.card { max-width: 580px; }
|
|
869
|
+
}
|
|
870
|
+
.hidden { display: none !important; }
|
|
871
|
+
</style>
|
|
872
|
+
</head>
|
|
873
|
+
<body>
|
|
874
|
+
<div class="card">
|
|
875
|
+
<div class="topbar">
|
|
876
|
+
<div class="brand-lockup">
|
|
877
|
+
${brandMarkSvg}
|
|
878
|
+
<span>Agent Native</span>
|
|
879
|
+
</div>
|
|
880
|
+
<div class="app-pill" title="${safeApp}">${safeApp}</div>
|
|
881
|
+
</div>
|
|
882
|
+
|
|
883
|
+
<div class="hero">
|
|
884
|
+
<!-- "Connect an external agent" is kept as the accessible consent label. -->
|
|
885
|
+
<div class="flow" role="img" aria-label="Connect an external agent to ${safeApp}">
|
|
886
|
+
<span class="tile" aria-hidden="true">
|
|
887
|
+
${flowMarkSvg}
|
|
888
|
+
</span>
|
|
889
|
+
<span class="conn" aria-hidden="true"></span>
|
|
890
|
+
<span class="tile" aria-hidden="true">
|
|
891
|
+
<span class="agent-symbol"></></span>
|
|
892
|
+
</span>
|
|
893
|
+
</div>
|
|
894
|
+
|
|
895
|
+
<div class="eyebrow">Connect an external agent</div>
|
|
896
|
+
<h1>${safeUserCode ? `Authorize ${safeApp} from your terminal?` : `Use ${safeApp} from your AI assistant`}</h1>
|
|
897
|
+
<p class="identity">
|
|
898
|
+
<span>Signed in as <strong>${safeEmail}</strong></span>
|
|
899
|
+
</p>
|
|
900
|
+
</div>
|
|
901
|
+
|
|
902
|
+
<div id="codeCallout" class="device-strip ${safeUserCode ? "" : "hidden"}">
|
|
903
|
+
<span class="label">Device code</span>
|
|
904
|
+
<span class="value" id="userCodeValue">${safeUserCode}</span>
|
|
905
|
+
</div>
|
|
906
|
+
|
|
907
|
+
${setupHtml}
|
|
908
|
+
|
|
909
|
+
<details id="staticTokenMint" class="connections static-token-mint"${safeUserCode ? " open" : ""}>
|
|
910
|
+
<summary>
|
|
911
|
+
<span class="connections-title">${safeUserCode ? "Authorize this device" : MCP_STATIC_TOKEN_FALLBACK.title}</span>
|
|
912
|
+
<span class="connections-state">${safeUserCode ? "From your terminal" : MCP_STATIC_TOKEN_FALLBACK.state}</span>
|
|
913
|
+
<span class="chev" aria-hidden="true"></span>
|
|
914
|
+
</summary>
|
|
915
|
+
<div class="static-token-body">
|
|
916
|
+
<div id="msg" class="msg" role="status" aria-live="polite"></div>
|
|
917
|
+
<div id="mintForm">
|
|
918
|
+
<button id="authorizeBtn" class="primary">${safeUserCode ? "Authorize device" : "Create connection token"}</button>
|
|
919
|
+
${tokenAdvancedOptionsHtml}
|
|
920
|
+
</div>
|
|
921
|
+
<div id="result" class="result-panel hidden">
|
|
922
|
+
<div class="result-title">${MCP_STATIC_TOKEN_FALLBACK.resultTitle}</div>
|
|
923
|
+
<p class="result-copy" id="resultMsg">${MCP_STATIC_TOKEN_FALLBACK.resultCopy}</p>
|
|
924
|
+
<div class="section-label">MCP config</div>
|
|
925
|
+
<pre id="mcpJson"></pre>
|
|
926
|
+
<details class="advanced">
|
|
927
|
+
<summary>
|
|
928
|
+
Terminal alternative
|
|
929
|
+
<span class="chev" aria-hidden="true"></span>
|
|
930
|
+
</summary>
|
|
931
|
+
<div class="advanced-body">
|
|
932
|
+
<pre id="cliLine"></pre>
|
|
933
|
+
</div>
|
|
934
|
+
</details>
|
|
935
|
+
</div>
|
|
936
|
+
</div>
|
|
937
|
+
</details>
|
|
938
|
+
|
|
939
|
+
<details id="connections" class="connections">
|
|
940
|
+
<summary>
|
|
941
|
+
<span class="connections-title">Existing connections</span>
|
|
942
|
+
<span id="connectionsState" class="connections-state">Checking</span>
|
|
943
|
+
<span class="chev" aria-hidden="true"></span>
|
|
944
|
+
</summary>
|
|
945
|
+
<div id="tokenList" class="token-list"><div class="empty-state">Checking connections...</div></div>
|
|
946
|
+
</details>
|
|
947
|
+
</div>
|
|
948
|
+
<script>
|
|
949
|
+
(function () {
|
|
950
|
+
var BASE = ${JSON.stringify(joinAppPath(connectBasePath, MCP_PUBLIC_ROUTE_PREFIX + "/connect"))};
|
|
951
|
+
var USER_CODE = ${JSON.stringify(safeUserCode || null)};
|
|
952
|
+
var msgEl = document.getElementById("msg");
|
|
953
|
+
var connectionsEl = document.getElementById("connections");
|
|
954
|
+
var connectionsStateEl = document.getElementById("connectionsState");
|
|
955
|
+
|
|
956
|
+
// Tab switching for the per-host instructions block.
|
|
957
|
+
var tabBtns = document.querySelectorAll(".tabs .tab");
|
|
958
|
+
var tabPanels = document.querySelectorAll(".tab-panel");
|
|
959
|
+
for (var i = 0; i < tabBtns.length; i++) {
|
|
960
|
+
tabBtns[i].addEventListener("click", function (ev) {
|
|
961
|
+
var btn = ev.currentTarget;
|
|
962
|
+
var name = btn.getAttribute("data-tab");
|
|
963
|
+
for (var j = 0; j < tabBtns.length; j++) {
|
|
964
|
+
var active = tabBtns[j] === btn;
|
|
965
|
+
tabBtns[j].classList.toggle("is-active", active);
|
|
966
|
+
tabBtns[j].setAttribute("aria-selected", active ? "true" : "false");
|
|
967
|
+
}
|
|
968
|
+
for (var k = 0; k < tabPanels.length; k++) {
|
|
969
|
+
tabPanels[k].classList.toggle(
|
|
970
|
+
"is-active",
|
|
971
|
+
tabPanels[k].getAttribute("data-panel") === name,
|
|
972
|
+
);
|
|
973
|
+
}
|
|
974
|
+
});
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
// Copy buttons — any element with data-copy="<id>" copies that node's text.
|
|
978
|
+
document.addEventListener("click", function (ev) {
|
|
979
|
+
var btn = ev.target && ev.target.closest && ev.target.closest("[data-copy]");
|
|
980
|
+
if (!btn) return;
|
|
981
|
+
var node = document.getElementById(btn.getAttribute("data-copy"));
|
|
982
|
+
if (!node || !navigator.clipboard) return;
|
|
983
|
+
navigator.clipboard.writeText(node.textContent || "").then(function () {
|
|
984
|
+
var prev = btn.textContent;
|
|
985
|
+
btn.textContent = "Copied";
|
|
986
|
+
btn.classList.add("copy-flash");
|
|
987
|
+
setTimeout(function () {
|
|
988
|
+
btn.textContent = prev;
|
|
989
|
+
btn.classList.remove("copy-flash");
|
|
990
|
+
}, 1400);
|
|
991
|
+
});
|
|
992
|
+
});
|
|
993
|
+
function showMsg(text, kind) {
|
|
994
|
+
msgEl.textContent = text;
|
|
995
|
+
msgEl.className = "msg " + (kind || "err");
|
|
996
|
+
}
|
|
997
|
+
function clearMsg() { msgEl.className = "msg"; msgEl.textContent = ""; }
|
|
998
|
+
|
|
999
|
+
function setButtonLoading(btn, text) {
|
|
1000
|
+
if (!btn.dataset.idleText) btn.dataset.idleText = btn.textContent || "";
|
|
1001
|
+
btn.textContent = text;
|
|
1002
|
+
btn.classList.add("is-loading");
|
|
1003
|
+
btn.setAttribute("aria-busy", "true");
|
|
1004
|
+
btn.disabled = true;
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
function resetButtonLoading(btn) {
|
|
1008
|
+
btn.disabled = false;
|
|
1009
|
+
btn.classList.remove("is-loading");
|
|
1010
|
+
btn.removeAttribute("aria-busy");
|
|
1011
|
+
if (btn.dataset.idleText) btn.textContent = btn.dataset.idleText;
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
function renderResult(data) {
|
|
1015
|
+
document.getElementById("mintForm").classList.add("hidden");
|
|
1016
|
+
var entry = {};
|
|
1017
|
+
entry[data.serverName] = data.mcpServerEntry;
|
|
1018
|
+
document.getElementById("mcpJson").textContent =
|
|
1019
|
+
JSON.stringify({ mcpServers: entry }, null, 2);
|
|
1020
|
+
document.getElementById("cliLine").textContent = data.cli;
|
|
1021
|
+
document.getElementById("result").classList.remove("hidden");
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
async function postJson(path, body) {
|
|
1025
|
+
var res = await fetch(BASE + path, {
|
|
1026
|
+
method: "POST",
|
|
1027
|
+
headers: { "Content-Type": "application/json" },
|
|
1028
|
+
credentials: "same-origin",
|
|
1029
|
+
body: JSON.stringify(body || {})
|
|
1030
|
+
});
|
|
1031
|
+
var data = null;
|
|
1032
|
+
try { data = await res.json(); } catch (e) {}
|
|
1033
|
+
return { ok: res.ok, status: res.status, data: data };
|
|
1034
|
+
}
|
|
1035
|
+
|
|
1036
|
+
async function loadTokens() {
|
|
1037
|
+
var listEl = document.getElementById("tokenList");
|
|
1038
|
+
try {
|
|
1039
|
+
var res = await fetch(BASE + "/tokens", { credentials: "same-origin" });
|
|
1040
|
+
if (!res.ok) {
|
|
1041
|
+
connectionsStateEl.textContent = "Unavailable";
|
|
1042
|
+
listEl.innerHTML = '<div class="empty-state">Could not load connections.</div>';
|
|
1043
|
+
return;
|
|
1044
|
+
}
|
|
1045
|
+
var data = await res.json();
|
|
1046
|
+
var tokens = (data && data.tokens) || [];
|
|
1047
|
+
if (!tokens.length) {
|
|
1048
|
+
connectionsStateEl.textContent = "None";
|
|
1049
|
+
connectionsEl.open = false;
|
|
1050
|
+
listEl.innerHTML = '<div class="empty-state">Created connections will appear here for revoking later.</div>';
|
|
1051
|
+
return;
|
|
1052
|
+
}
|
|
1053
|
+
var activeCount = tokens.filter(function (t) { return !t.revokedAt; }).length;
|
|
1054
|
+
connectionsStateEl.textContent = activeCount === 1 ? "1 active" : activeCount + " active";
|
|
1055
|
+
listEl.innerHTML = "";
|
|
1056
|
+
tokens.forEach(function (t) {
|
|
1057
|
+
var div = document.createElement("div");
|
|
1058
|
+
div.className = "tok" + (t.revokedAt ? " revoked" : "");
|
|
1059
|
+
var when = t.createdAt ? new Date(t.createdAt).toLocaleString() : "";
|
|
1060
|
+
var used = t.lastUsedAt ? " · last used " + new Date(t.lastUsedAt).toLocaleString() : "";
|
|
1061
|
+
var left = document.createElement("div");
|
|
1062
|
+
var label = document.createElement("div");
|
|
1063
|
+
label.textContent = t.label || "(unlabeled)";
|
|
1064
|
+
var meta = document.createElement("div");
|
|
1065
|
+
meta.className = "meta";
|
|
1066
|
+
meta.textContent = (t.revokedAt ? "Revoked · " : "Created ") + when + used;
|
|
1067
|
+
left.appendChild(label); left.appendChild(meta);
|
|
1068
|
+
div.appendChild(left);
|
|
1069
|
+
if (!t.revokedAt) {
|
|
1070
|
+
var btn = document.createElement("button");
|
|
1071
|
+
btn.className = "ghost";
|
|
1072
|
+
btn.textContent = "Revoke";
|
|
1073
|
+
btn.onclick = async function () {
|
|
1074
|
+
btn.disabled = true;
|
|
1075
|
+
var r = await postJson("/tokens/revoke", { id: t.id });
|
|
1076
|
+
if (r.ok) { loadTokens(); }
|
|
1077
|
+
else { btn.disabled = false; showMsg("Could not revoke token."); }
|
|
1078
|
+
};
|
|
1079
|
+
div.appendChild(btn);
|
|
1080
|
+
}
|
|
1081
|
+
listEl.appendChild(div);
|
|
1082
|
+
});
|
|
1083
|
+
} catch (e) {
|
|
1084
|
+
connectionsStateEl.textContent = "Unavailable";
|
|
1085
|
+
listEl.innerHTML = '<div class="empty-state">Could not load connections.</div>';
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
|
|
1089
|
+
document.getElementById("authorizeBtn").onclick = async function () {
|
|
1090
|
+
var btn = this;
|
|
1091
|
+
setButtonLoading(btn, USER_CODE ? "Authorizing device..." : "Creating token...");
|
|
1092
|
+
clearMsg();
|
|
1093
|
+
try {
|
|
1094
|
+
if (USER_CODE) {
|
|
1095
|
+
var a = await postJson("/device/authorize", { user_code: USER_CODE });
|
|
1096
|
+
if (!a.ok) {
|
|
1097
|
+
resetButtonLoading(btn);
|
|
1098
|
+
showMsg((a.data && a.data.error) || "Could not authorize this device code.");
|
|
1099
|
+
return;
|
|
1100
|
+
}
|
|
1101
|
+
showMsg("Device authorized — finishing connection… you can return to your terminal.", "ok");
|
|
1102
|
+
btn.classList.add("hidden");
|
|
1103
|
+
document.getElementById("mintForm").classList.add("hidden");
|
|
1104
|
+
var cc = document.getElementById("codeCallout");
|
|
1105
|
+
if (cc) cc.classList.add("hidden");
|
|
1106
|
+
// The token is minted a few seconds later, when the CLI next polls
|
|
1107
|
+
// /device/poll — so a single loadTokens() here runs BEFORE the row
|
|
1108
|
+
// exists and the list would wrongly read "No connections yet" until
|
|
1109
|
+
// a manual reload. Snapshot the EXISTING non-revoked token ids first
|
|
1110
|
+
// so we announce "Connected" only when THIS device's freshly-minted
|
|
1111
|
+
// token appears — a user who already has tokens must not get a false
|
|
1112
|
+
// success the instant they authorize.
|
|
1113
|
+
var priorIds = {};
|
|
1114
|
+
try {
|
|
1115
|
+
var pr = await fetch(BASE + "/tokens", { credentials: "same-origin" });
|
|
1116
|
+
if (pr.ok) {
|
|
1117
|
+
var pd = await pr.json();
|
|
1118
|
+
((pd && pd.tokens) || []).forEach(function (t) {
|
|
1119
|
+
if (!t.revokedAt) priorIds[t.id] = true;
|
|
1120
|
+
});
|
|
1121
|
+
}
|
|
1122
|
+
} catch (e) {}
|
|
1123
|
+
loadTokens();
|
|
1124
|
+
var tries = 0;
|
|
1125
|
+
var iv = setInterval(async function () {
|
|
1126
|
+
tries++;
|
|
1127
|
+
try {
|
|
1128
|
+
var res = await fetch(BASE + "/tokens", { credentials: "same-origin" });
|
|
1129
|
+
if (res.ok) {
|
|
1130
|
+
var data = await res.json();
|
|
1131
|
+
var fresh = ((data && data.tokens) || []).filter(function (t) {
|
|
1132
|
+
return !t.revokedAt && !priorIds[t.id];
|
|
1133
|
+
});
|
|
1134
|
+
if (fresh.length > 0) {
|
|
1135
|
+
clearInterval(iv);
|
|
1136
|
+
showMsg("Connected. This device can now act as you — manage or revoke it below.", "ok");
|
|
1137
|
+
loadTokens();
|
|
1138
|
+
return;
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
} catch (e) {}
|
|
1142
|
+
if (tries >= 30) {
|
|
1143
|
+
// No new token appeared in the window — e.g. the loopback
|
|
1144
|
+
// dev-open path writes a header-only config and never mints.
|
|
1145
|
+
// Don't claim "Connected" (we couldn't confirm a device token);
|
|
1146
|
+
// keep the "authorized" message and just refresh the list.
|
|
1147
|
+
clearInterval(iv);
|
|
1148
|
+
loadTokens();
|
|
1149
|
+
}
|
|
1150
|
+
}, 2000);
|
|
1151
|
+
return;
|
|
1152
|
+
} else {
|
|
1153
|
+
var labelEl = document.getElementById("label");
|
|
1154
|
+
var ttlEl = document.getElementById("ttl");
|
|
1155
|
+
var label = labelEl ? labelEl.value || undefined : undefined;
|
|
1156
|
+
var ttlDays = ttlEl ? parseInt(ttlEl.value, 10) || undefined : undefined;
|
|
1157
|
+
var m = await postJson("/token", { label: label, ttlDays: ttlDays });
|
|
1158
|
+
if (!m.ok) {
|
|
1159
|
+
resetButtonLoading(btn);
|
|
1160
|
+
showMsg((m.data && m.data.error) || "Could not create token.");
|
|
1161
|
+
return;
|
|
1162
|
+
}
|
|
1163
|
+
renderResult(m.data);
|
|
1164
|
+
}
|
|
1165
|
+
loadTokens();
|
|
1166
|
+
} catch (e) {
|
|
1167
|
+
resetButtonLoading(btn);
|
|
1168
|
+
showMsg("Network error. Please try again.");
|
|
1169
|
+
}
|
|
1170
|
+
};
|
|
1171
|
+
|
|
1172
|
+
loadTokens();
|
|
1173
|
+
})();
|
|
1174
|
+
</script>
|
|
1175
|
+
</body>
|
|
1176
|
+
</html>`;
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
// ---------------------------------------------------------------------------
|
|
1180
|
+
// Handler — single entry point; core-routes-plugin dispatches the subpath.
|
|
1181
|
+
// ---------------------------------------------------------------------------
|
|
1182
|
+
|
|
1183
|
+
/**
|
|
1184
|
+
* Handle a `/mcp/connect[...]` request. The legacy
|
|
1185
|
+
* `/_agent-native/mcp/connect` alias is mounted too. `subpath` is the part
|
|
1186
|
+
* after `/connect` (empty string = the page itself, otherwise e.g. `/token`,
|
|
1187
|
+
* `/device/start`). The core-routes-plugin computes it from the stripped event
|
|
1188
|
+
* path so this module stays mount-agnostic.
|
|
1189
|
+
*/
|
|
1190
|
+
export async function handleMcpConnect(
|
|
1191
|
+
event: H3Event,
|
|
1192
|
+
subpath: string,
|
|
1193
|
+
options: McpConnectRouteOptions = {},
|
|
1194
|
+
): Promise<Response> {
|
|
1195
|
+
const method = getMethod(event);
|
|
1196
|
+
const origin = deriveOrigin(event);
|
|
1197
|
+
const basePath = configuredBasePath();
|
|
1198
|
+
const appUrl = `${origin}${basePath}`;
|
|
1199
|
+
const sub = ("/" + subpath.replace(/^\/+/, "").replace(/\/+$/, "")).replace(
|
|
1200
|
+
/^\/$/,
|
|
1201
|
+
"",
|
|
1202
|
+
);
|
|
1203
|
+
|
|
1204
|
+
// ---- The connect page (GET) ------------------------------------------
|
|
1205
|
+
if (sub === "") {
|
|
1206
|
+
if (method !== "GET" && method !== "HEAD") {
|
|
1207
|
+
return json({ error: "Method not allowed" }, 405);
|
|
1208
|
+
}
|
|
1209
|
+
const session = await getSession(event);
|
|
1210
|
+
if (!session?.email) {
|
|
1211
|
+
// Serve the SAME login form the guard would, at this same URL — the
|
|
1212
|
+
// login form reloads window.location so we re-enter here authed.
|
|
1213
|
+
const loginHtml = getConfiguredLoginHtml(event);
|
|
1214
|
+
if (loginHtml) return html(loginHtml, 200);
|
|
1215
|
+
// Fully-open app (no auth guard): nothing to scope a mint to.
|
|
1216
|
+
return html(
|
|
1217
|
+
renderConnectPage({
|
|
1218
|
+
connectBasePath: basePath,
|
|
1219
|
+
email: "(no auth configured)",
|
|
1220
|
+
appName: options.appName || appLabel(appUrl, options),
|
|
1221
|
+
appUrl,
|
|
1222
|
+
serverId: serverName(appUrl, options),
|
|
1223
|
+
userCode: null,
|
|
1224
|
+
}),
|
|
1225
|
+
);
|
|
1226
|
+
}
|
|
1227
|
+
let userCode: string | null = null;
|
|
1228
|
+
try {
|
|
1229
|
+
const u = new URL(
|
|
1230
|
+
event.node?.req?.url ?? event.path ?? "/",
|
|
1231
|
+
"http://an.invalid",
|
|
1232
|
+
);
|
|
1233
|
+
const raw = u.searchParams.get("user_code");
|
|
1234
|
+
if (raw && USER_CODE_RE.test(raw)) userCode = raw;
|
|
1235
|
+
} catch {
|
|
1236
|
+
userCode = null;
|
|
1237
|
+
}
|
|
1238
|
+
return html(
|
|
1239
|
+
renderConnectPage({
|
|
1240
|
+
connectBasePath: basePath,
|
|
1241
|
+
email: session.email,
|
|
1242
|
+
appName: options.appName || appLabel(appUrl, options),
|
|
1243
|
+
appUrl,
|
|
1244
|
+
serverId: serverName(appUrl, options),
|
|
1245
|
+
userCode,
|
|
1246
|
+
}),
|
|
1247
|
+
);
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
// ---- POST /token (session-required) ---------------------------------
|
|
1251
|
+
if (sub === "/token") {
|
|
1252
|
+
if (method !== "POST") return json({ error: "Method not allowed" }, 405);
|
|
1253
|
+
const session = await getSession(event);
|
|
1254
|
+
if (!session?.email) return json({ error: "Unauthorized" }, 401);
|
|
1255
|
+
if (!process.env.A2A_SECRET?.trim() && canUseDevOpenConnect(event)) {
|
|
1256
|
+
return json(
|
|
1257
|
+
mcpResultPayload(appUrl, options, { ownerEmail: session.email }),
|
|
1258
|
+
);
|
|
1259
|
+
}
|
|
1260
|
+
const body = ((await readBody(event).catch(() => ({}))) ?? {}) as {
|
|
1261
|
+
label?: unknown;
|
|
1262
|
+
ttlDays?: unknown;
|
|
1263
|
+
fullCatalog?: unknown;
|
|
1264
|
+
};
|
|
1265
|
+
const label =
|
|
1266
|
+
typeof body.label === "string" && body.label.trim()
|
|
1267
|
+
? body.label.trim().slice(0, 120)
|
|
1268
|
+
: null;
|
|
1269
|
+
const ttlDays = clampTtlDays(body.ttlDays);
|
|
1270
|
+
const catalogScope: "full" | undefined =
|
|
1271
|
+
body.fullCatalog === true || body.fullCatalog === "true"
|
|
1272
|
+
? "full"
|
|
1273
|
+
: undefined;
|
|
1274
|
+
try {
|
|
1275
|
+
const { token } = await mintConnectToken({
|
|
1276
|
+
email: session.email,
|
|
1277
|
+
orgId: session.orgId,
|
|
1278
|
+
label,
|
|
1279
|
+
ttlDays,
|
|
1280
|
+
appUrl,
|
|
1281
|
+
...(catalogScope ? { catalogScope } : {}),
|
|
1282
|
+
});
|
|
1283
|
+
return json(mcpResultPayload(appUrl, options, { token }));
|
|
1284
|
+
} catch {
|
|
1285
|
+
return json({ error: "Failed to mint token." }, 500);
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
// ---- POST /device/start (UNAUTH) ------------------------------------
|
|
1290
|
+
if (sub === "/device/start") {
|
|
1291
|
+
if (method !== "POST") return json({ error: "Method not allowed" }, 405);
|
|
1292
|
+
try {
|
|
1293
|
+
const row = await createDeviceCode();
|
|
1294
|
+
const verificationUri = `${appUrl}${MCP_PUBLIC_ROUTE_PREFIX}/connect`;
|
|
1295
|
+
return json({
|
|
1296
|
+
device_code: row.deviceCode,
|
|
1297
|
+
user_code: row.userCode,
|
|
1298
|
+
verification_uri: verificationUri,
|
|
1299
|
+
verification_uri_complete: `${verificationUri}?user_code=${row.userCode}`,
|
|
1300
|
+
interval: DEVICE_POLL_INTERVAL_S,
|
|
1301
|
+
expires_in: Math.floor(DEVICE_CODE_TTL_MS / 1000),
|
|
1302
|
+
});
|
|
1303
|
+
} catch (err: any) {
|
|
1304
|
+
if (err?.message === "RATE_LIMITED") {
|
|
1305
|
+
return json({ error: "Rate limited. Try again shortly." }, 429);
|
|
1306
|
+
}
|
|
1307
|
+
return json({ error: "Could not start device flow." }, 500);
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
// ---- POST /device/authorize (session-required) ----------------------
|
|
1312
|
+
if (sub === "/device/authorize") {
|
|
1313
|
+
if (method !== "POST") return json({ error: "Method not allowed" }, 405);
|
|
1314
|
+
const session = await getSession(event);
|
|
1315
|
+
if (!session?.email) return json({ error: "Unauthorized" }, 401);
|
|
1316
|
+
const body = ((await readBody(event).catch(() => ({}))) ?? {}) as {
|
|
1317
|
+
user_code?: unknown;
|
|
1318
|
+
};
|
|
1319
|
+
const userCode =
|
|
1320
|
+
typeof body.user_code === "string" ? body.user_code.trim() : "";
|
|
1321
|
+
if (!USER_CODE_RE.test(userCode)) {
|
|
1322
|
+
return json({ error: "Invalid user code." }, 400);
|
|
1323
|
+
}
|
|
1324
|
+
const orgId =
|
|
1325
|
+
typeof session.orgId === "string" && session.orgId.trim()
|
|
1326
|
+
? session.orgId.trim()
|
|
1327
|
+
: null;
|
|
1328
|
+
const result = await approveDeviceCode(userCode, session.email, orgId);
|
|
1329
|
+
if (result === "not_found") {
|
|
1330
|
+
return json({ error: "Unknown device code." }, 404);
|
|
1331
|
+
}
|
|
1332
|
+
if (result === "expired") {
|
|
1333
|
+
return json({ error: "This device code has expired." }, 410);
|
|
1334
|
+
}
|
|
1335
|
+
if (result === "already") {
|
|
1336
|
+
return json({ error: "This device code was already used." }, 409);
|
|
1337
|
+
}
|
|
1338
|
+
return json({ status: "approved" });
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
// ---- POST /device/poll (UNAUTH) -------------------------------------
|
|
1342
|
+
if (sub === "/device/poll") {
|
|
1343
|
+
if (method !== "POST") return json({ error: "Method not allowed" }, 405);
|
|
1344
|
+
const body = ((await readBody(event).catch(() => ({}))) ?? {}) as {
|
|
1345
|
+
device_code?: unknown;
|
|
1346
|
+
};
|
|
1347
|
+
const deviceCode =
|
|
1348
|
+
typeof body.device_code === "string" ? body.device_code : "";
|
|
1349
|
+
if (!deviceCode) return json({ error: "device_code required" }, 400);
|
|
1350
|
+
const row = await getDeviceCode(deviceCode);
|
|
1351
|
+
if (!row) return json({ status: "not_found" }, 404);
|
|
1352
|
+
if (row.status === "consumed") return json({ status: "consumed" });
|
|
1353
|
+
if (
|
|
1354
|
+
row.status === "expired" ||
|
|
1355
|
+
(row.expiresAt != null && row.expiresAt < Date.now())
|
|
1356
|
+
) {
|
|
1357
|
+
if (row.status !== "expired") void expireDeviceCode(deviceCode);
|
|
1358
|
+
return json({ status: "expired" });
|
|
1359
|
+
}
|
|
1360
|
+
if (
|
|
1361
|
+
row.status === "pending" ||
|
|
1362
|
+
row.status === "minting" ||
|
|
1363
|
+
!row.ownerEmail
|
|
1364
|
+
) {
|
|
1365
|
+
return json({ status: "pending" });
|
|
1366
|
+
}
|
|
1367
|
+
// status === "approved" && ownerEmail bound → mint exactly once.
|
|
1368
|
+
if (!process.env.A2A_SECRET?.trim() && canUseDevOpenConnect(event)) {
|
|
1369
|
+
const consumed = await consumeDeviceCode(
|
|
1370
|
+
deviceCode,
|
|
1371
|
+
`dev-open-${randomUUID()}`,
|
|
1372
|
+
);
|
|
1373
|
+
if (!consumed) {
|
|
1374
|
+
const fresh = await getDeviceCode(deviceCode);
|
|
1375
|
+
if (fresh?.status === "consumed") return json({ status: "consumed" });
|
|
1376
|
+
return json({ status: "pending" });
|
|
1377
|
+
}
|
|
1378
|
+
return json({
|
|
1379
|
+
status: "approved",
|
|
1380
|
+
...mcpResultPayload(appUrl, options, {
|
|
1381
|
+
ownerEmail: row.ownerEmail,
|
|
1382
|
+
}),
|
|
1383
|
+
});
|
|
1384
|
+
}
|
|
1385
|
+
try {
|
|
1386
|
+
const jti = randomUUID();
|
|
1387
|
+
// Claim a retryable minting state first. If signing or recording fails,
|
|
1388
|
+
// release the row back to approved so the CLI can poll again.
|
|
1389
|
+
const claimed = await claimDeviceCodeForMint(deviceCode, jti);
|
|
1390
|
+
if (!claimed) {
|
|
1391
|
+
const fresh = await getDeviceCode(deviceCode);
|
|
1392
|
+
if (fresh?.status === "consumed") return json({ status: "consumed" });
|
|
1393
|
+
return json({ status: "pending" });
|
|
1394
|
+
}
|
|
1395
|
+
let token: string;
|
|
1396
|
+
try {
|
|
1397
|
+
const orgDomain = await resolveOrgDomain(claimed.orgId ?? undefined);
|
|
1398
|
+
token = await signConnectToken({
|
|
1399
|
+
ownerEmail: claimed.ownerEmail!,
|
|
1400
|
+
orgId: claimed.orgId,
|
|
1401
|
+
orgDomain,
|
|
1402
|
+
appUrl,
|
|
1403
|
+
expiresIn: `${DEFAULT_TOKEN_TTL_DAYS}d`,
|
|
1404
|
+
jti,
|
|
1405
|
+
});
|
|
1406
|
+
await recordMintedToken({
|
|
1407
|
+
jti,
|
|
1408
|
+
ownerEmail: claimed.ownerEmail!,
|
|
1409
|
+
orgId: claimed.orgId,
|
|
1410
|
+
label: "Device connection",
|
|
1411
|
+
});
|
|
1412
|
+
if (!(await finishDeviceCodeMint(deviceCode, jti))) {
|
|
1413
|
+
return json({ status: "pending" });
|
|
1414
|
+
}
|
|
1415
|
+
} catch (err) {
|
|
1416
|
+
await releaseDeviceCodeMint(deviceCode, jti);
|
|
1417
|
+
throw err;
|
|
1418
|
+
}
|
|
1419
|
+
return json({
|
|
1420
|
+
status: "approved",
|
|
1421
|
+
...mcpResultPayload(appUrl, options, { token }),
|
|
1422
|
+
});
|
|
1423
|
+
} catch {
|
|
1424
|
+
return json({ status: "error", error: "Failed to mint token." }, 500);
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
|
|
1428
|
+
// ---- GET /tokens (session-required) ---------------------------------
|
|
1429
|
+
if (sub === "/tokens") {
|
|
1430
|
+
if (method !== "GET") return json({ error: "Method not allowed" }, 405);
|
|
1431
|
+
const session = await getSession(event);
|
|
1432
|
+
if (!session?.email) return json({ error: "Unauthorized" }, 401);
|
|
1433
|
+
const rows = await listTokens(session.email);
|
|
1434
|
+
return json({
|
|
1435
|
+
tokens: rows.map((r) => ({
|
|
1436
|
+
id: r.id,
|
|
1437
|
+
label: r.label,
|
|
1438
|
+
createdAt: r.createdAt,
|
|
1439
|
+
lastUsedAt: r.lastUsedAt,
|
|
1440
|
+
revokedAt: r.revokedAt,
|
|
1441
|
+
})),
|
|
1442
|
+
});
|
|
1443
|
+
}
|
|
1444
|
+
|
|
1445
|
+
// ---- POST /tokens/revoke (session-required) -------------------------
|
|
1446
|
+
if (sub === "/tokens/revoke") {
|
|
1447
|
+
if (method !== "POST") return json({ error: "Method not allowed" }, 405);
|
|
1448
|
+
const session = await getSession(event);
|
|
1449
|
+
if (!session?.email) return json({ error: "Unauthorized" }, 401);
|
|
1450
|
+
const body = ((await readBody(event).catch(() => ({}))) ?? {}) as {
|
|
1451
|
+
id?: unknown;
|
|
1452
|
+
};
|
|
1453
|
+
const id = typeof body.id === "string" ? body.id : "";
|
|
1454
|
+
if (!id) return json({ error: "id required" }, 400);
|
|
1455
|
+
const revoked = await revokeToken(session.email, id);
|
|
1456
|
+
return json({ ok: revoked });
|
|
1457
|
+
}
|
|
1458
|
+
|
|
1459
|
+
return json({ error: "Not found" }, 404);
|
|
1460
|
+
}
|