@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,1506 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic cross-app MCP tools — a stable verb set every external agent gets
|
|
3
|
+
* regardless of which template it is talking to.
|
|
4
|
+
*
|
|
5
|
+
* These are merged into the MCP action registry by
|
|
6
|
+
* `createMCPServerForRequest` (see `build-server.ts`). **Precedence: template
|
|
7
|
+
* actions win.** If a template defines an action named `list_apps` /
|
|
8
|
+
* `open_app` / `ask_app` / `create_workspace_app` / `list_templates`, the
|
|
9
|
+
* template's `ActionEntry` overwrites the builtin of the same name. This is
|
|
10
|
+
* the same template-over-framework precedence `autoDiscoverActions` uses.
|
|
11
|
+
*
|
|
12
|
+
* | Tool | Side effects | Returns |
|
|
13
|
+
* | --------------------- | ------------ | ---------------------------------------- |
|
|
14
|
+
* | `list_apps` | none | `{ apps: [{ id, url, running }] }` |
|
|
15
|
+
* | `open_app` | none | `{ url }` (+ deep-link `link`) |
|
|
16
|
+
* | `create_embed_session`| ticket mint | `{ startUrl }` for MCP App iframes |
|
|
17
|
+
* | `ask_app` | agent loop | `{ app, routedVia, response }` or task |
|
|
18
|
+
* | `ask_app_status` | none | poll a durable `ask_app` task |
|
|
19
|
+
* | `create_workspace_app`| scaffolds | `{ name, url, port, deepLink }` (+ link) |
|
|
20
|
+
*
|
|
21
|
+
* `open_app` / `create_workspace_app` return an **absolute** URL on the
|
|
22
|
+
* *target* app's origin when it differs from this app (so a workspace link
|
|
23
|
+
* lands in the right app), and a relative path for the same app / standalone.
|
|
24
|
+
* `ask_app` routes to a *different* workspace app over A2A when possible and
|
|
25
|
+
* reports `routedVia: "a2a"`; otherwise it answers locally
|
|
26
|
+
* (`routedVia: "local"`) and never falsely claims cross-app delegation.
|
|
27
|
+
* | `list_templates` | none | `{ templates: [...] }` (allow-list only) |
|
|
28
|
+
*
|
|
29
|
+
* Node-only at call time (workspace resolution + scaffolding use `fs`), but
|
|
30
|
+
* the module has no top-level Node imports so it bundles fine alongside
|
|
31
|
+
* `mountMCP` — the Node bits are dynamically imported inside `run()`.
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
import type { A2AApprovedAction, Task } from "../a2a/types.js";
|
|
35
|
+
import type { ActionEntry } from "../agent/production-agent.js";
|
|
36
|
+
import type { ActionTool } from "../agent/types.js";
|
|
37
|
+
import { getConfiguredAppBasePath } from "../server/app-base-path.js";
|
|
38
|
+
import { buildDeepLink } from "../server/deep-link.js";
|
|
39
|
+
import { MCP_APP_CHAT_BRIDGE_QUERY_PARAM } from "../shared/embed-auth.js";
|
|
40
|
+
import type { MCPConfig } from "./build-server.js";
|
|
41
|
+
import { embedApp } from "./embed-app.js";
|
|
42
|
+
import { fetchOrgApps, type OrgApp } from "./org-directory.js";
|
|
43
|
+
|
|
44
|
+
/** Flat map of param name → JSON-schema property. */
|
|
45
|
+
type Params = Record<
|
|
46
|
+
string,
|
|
47
|
+
{ type: string; description?: string; enum?: string[] }
|
|
48
|
+
>;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Build an `ActionTool`. `parameters` is wrapped in the
|
|
52
|
+
* `{ type:"object", properties, required }` shape `createMCPServerForRequest`
|
|
53
|
+
* forwards verbatim as the MCP tool `inputSchema`.
|
|
54
|
+
*/
|
|
55
|
+
function tool(
|
|
56
|
+
description: string,
|
|
57
|
+
parameters?: Params,
|
|
58
|
+
required?: string[],
|
|
59
|
+
): ActionTool {
|
|
60
|
+
if (!parameters) return { description };
|
|
61
|
+
return {
|
|
62
|
+
description,
|
|
63
|
+
parameters: {
|
|
64
|
+
type: "object",
|
|
65
|
+
properties: parameters,
|
|
66
|
+
...(required && required.length ? { required } : {}),
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* The canonical app id this MCP server is mounted for. `MCPConfig.appId` is
|
|
73
|
+
* authoritative; fall back to lowercasing `name` (which is the capitalized
|
|
74
|
+
* app id at every call site) for back-compat with configs that predate the
|
|
75
|
+
* `appId` field.
|
|
76
|
+
*/
|
|
77
|
+
function currentAppId(config: MCPConfig): string {
|
|
78
|
+
return (config.appId || config.name || "app").toLowerCase();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const CONTROL_CHARS = new RegExp("[\\u0000-\\u001f\\u007f]");
|
|
82
|
+
const ASK_APP_DEFAULT_INLINE_WAIT_MS = 20_000;
|
|
83
|
+
const ASK_APP_MAX_INLINE_WAIT_MS = 25_000;
|
|
84
|
+
const ASK_APP_POLL_INTERVAL_MS = 1_500;
|
|
85
|
+
const ASK_APP_A2A_REQUEST_TIMEOUT_MS = 10_000;
|
|
86
|
+
const ASK_APP_STATUS_RETRY_DELAYS_MS = [250, 750, 1_500] as const;
|
|
87
|
+
const ASK_APP_TERMINAL_STATES = new Set<string>([
|
|
88
|
+
"completed",
|
|
89
|
+
"failed",
|
|
90
|
+
"canceled",
|
|
91
|
+
"input-required",
|
|
92
|
+
]);
|
|
93
|
+
|
|
94
|
+
class AskAppInlineDeadlineError extends Error {
|
|
95
|
+
constructor() {
|
|
96
|
+
super("ask_app inline wait deadline reached");
|
|
97
|
+
this.name = "AskAppInlineDeadlineError";
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
type AskAppRequestMeta = { origin?: string; basePath?: string };
|
|
102
|
+
|
|
103
|
+
interface AskAppRoute {
|
|
104
|
+
app: string;
|
|
105
|
+
origin: string;
|
|
106
|
+
routedVia: "local" | "a2a";
|
|
107
|
+
requestOrigin?: string;
|
|
108
|
+
note?: string;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
interface AskAppTaskResult {
|
|
112
|
+
app: string;
|
|
113
|
+
routedVia: "local" | "a2a";
|
|
114
|
+
taskId: string;
|
|
115
|
+
status: string;
|
|
116
|
+
response?: string;
|
|
117
|
+
error?: string;
|
|
118
|
+
inputRequired?: string;
|
|
119
|
+
note?: string;
|
|
120
|
+
pollAfterMs?: number;
|
|
121
|
+
poll?: {
|
|
122
|
+
tool: "ask_app_status";
|
|
123
|
+
arguments: { app: string; taskId: string };
|
|
124
|
+
};
|
|
125
|
+
message?: string;
|
|
126
|
+
statusRead?: "unavailable";
|
|
127
|
+
retryable?: true;
|
|
128
|
+
errorCategory?: AskAppStatusErrorCategory;
|
|
129
|
+
attempts?: number;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
type AskAppStatusErrorCategory =
|
|
133
|
+
| "transport"
|
|
134
|
+
| "timeout"
|
|
135
|
+
| "upstream_5xx"
|
|
136
|
+
| "rate_limited";
|
|
137
|
+
|
|
138
|
+
function safeAppPath(raw: unknown): string | null {
|
|
139
|
+
if (typeof raw !== "string" || !raw.trim()) return null;
|
|
140
|
+
const value = raw.trim();
|
|
141
|
+
if (CONTROL_CHARS.test(value)) return null;
|
|
142
|
+
if (!value.startsWith("/")) return null;
|
|
143
|
+
if (value.startsWith("//") || value.startsWith("/\\")) return null;
|
|
144
|
+
if (/^\/[a-z][a-z0-9+.-]*:/i.test(value)) return null;
|
|
145
|
+
return value;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function appendParamsToPath(
|
|
149
|
+
path: string,
|
|
150
|
+
params: Record<string, string | number | boolean> | undefined,
|
|
151
|
+
): string {
|
|
152
|
+
if (!params || Object.keys(params).length === 0) return path;
|
|
153
|
+
const url = new URL(path, "http://agent-native.invalid");
|
|
154
|
+
for (const [key, value] of Object.entries(params)) {
|
|
155
|
+
url.searchParams.set(key, String(value));
|
|
156
|
+
}
|
|
157
|
+
return `${url.pathname}${url.search}${url.hash}`;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function viewToAppPath(view: string): string | null {
|
|
161
|
+
const value = view.trim();
|
|
162
|
+
if (!value) return null;
|
|
163
|
+
return safeAppPath(value.startsWith("/") ? value : `/${value}`);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
function withConfiguredBasePath(path: string): string {
|
|
167
|
+
const base = getConfiguredAppBasePath();
|
|
168
|
+
if (!base || path === base || path.startsWith(`${base}/`)) return path;
|
|
169
|
+
return `${base}${path}`;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function withMcpChatBridgeParam(path: string): string {
|
|
173
|
+
try {
|
|
174
|
+
const url = new URL(path, "http://agent-native.invalid");
|
|
175
|
+
url.searchParams.set(MCP_APP_CHAT_BRIDGE_QUERY_PARAM, "1");
|
|
176
|
+
return `${url.pathname}${url.search}${url.hash}`;
|
|
177
|
+
} catch {
|
|
178
|
+
return path;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function agentNativeA2AEndpoint(urlOrOrigin: string): string {
|
|
183
|
+
const value = urlOrOrigin.replace(/\/+$/, "");
|
|
184
|
+
try {
|
|
185
|
+
const parsed = new URL(value);
|
|
186
|
+
const pathname = parsed.pathname.replace(/\/+$/, "");
|
|
187
|
+
if (pathname.endsWith("/_agent-native/a2a") || pathname.endsWith("/a2a")) {
|
|
188
|
+
return value;
|
|
189
|
+
}
|
|
190
|
+
} catch {
|
|
191
|
+
// Fall through and append the conventional Agent Native endpoint.
|
|
192
|
+
}
|
|
193
|
+
return `${value}/_agent-native/a2a`;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function selfA2AEndpointUrl(requestMeta?: AskAppRequestMeta): string | null {
|
|
197
|
+
const origin = requestMeta?.origin?.replace(/\/+$/, "");
|
|
198
|
+
if (!origin) return null;
|
|
199
|
+
const basePath = requestMeta?.basePath || getConfiguredAppBasePath();
|
|
200
|
+
return agentNativeA2AEndpoint(`${origin}${basePath}`);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function boundedAskAppWaitMs(raw: unknown): number {
|
|
204
|
+
if (raw == null || raw === "") return ASK_APP_DEFAULT_INLINE_WAIT_MS;
|
|
205
|
+
const parsed = Number(raw);
|
|
206
|
+
if (!Number.isFinite(parsed)) return ASK_APP_DEFAULT_INLINE_WAIT_MS;
|
|
207
|
+
return Math.max(0, Math.min(ASK_APP_MAX_INLINE_WAIT_MS, Math.trunc(parsed)));
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function isExplicitAsyncAsk(raw: unknown): boolean {
|
|
211
|
+
return raw === true || raw === "true" || raw === 1 || raw === "1";
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function taskState(task: Task): string {
|
|
215
|
+
return String(task.status?.state ?? "unknown");
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function isTerminalTask(task: Task): boolean {
|
|
219
|
+
return ASK_APP_TERMINAL_STATES.has(taskState(task));
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function taskText(task: Task): string {
|
|
223
|
+
return (
|
|
224
|
+
task.status.message?.parts
|
|
225
|
+
?.filter(
|
|
226
|
+
(part): part is { type: "text"; text: string } => part.type === "text",
|
|
227
|
+
)
|
|
228
|
+
.map((part) => part.text)
|
|
229
|
+
.join("\n")
|
|
230
|
+
.trim() ?? ""
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
function askAppTaskResult(route: AskAppRoute, task: Task): AskAppTaskResult {
|
|
235
|
+
const status = taskState(task);
|
|
236
|
+
const response = taskText(task);
|
|
237
|
+
const base = {
|
|
238
|
+
app: route.app,
|
|
239
|
+
routedVia: route.routedVia,
|
|
240
|
+
taskId: task.id,
|
|
241
|
+
status,
|
|
242
|
+
...(route.note ? { note: route.note } : {}),
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
if (status === "completed") {
|
|
246
|
+
return {
|
|
247
|
+
...base,
|
|
248
|
+
response: response || "(no response)",
|
|
249
|
+
};
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
if (status === "failed" || status === "canceled") {
|
|
253
|
+
return {
|
|
254
|
+
...base,
|
|
255
|
+
...(response ? { response } : {}),
|
|
256
|
+
error: response || `ask_app task ${status}.`,
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
if (status === "input-required") {
|
|
261
|
+
const inputRequired =
|
|
262
|
+
response || "The agent needs additional input before it can continue.";
|
|
263
|
+
return {
|
|
264
|
+
...base,
|
|
265
|
+
response: inputRequired,
|
|
266
|
+
inputRequired,
|
|
267
|
+
message: inputRequired,
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
return {
|
|
272
|
+
...base,
|
|
273
|
+
pollAfterMs: ASK_APP_POLL_INTERVAL_MS,
|
|
274
|
+
poll: {
|
|
275
|
+
tool: "ask_app_status",
|
|
276
|
+
arguments: { app: route.app, taskId: task.id },
|
|
277
|
+
},
|
|
278
|
+
message:
|
|
279
|
+
`ask_app is still ${status}. Call ask_app_status with ` +
|
|
280
|
+
`taskId "${task.id}" to retrieve the final response.`,
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Same shape as `askAppTaskResult`, but built from an in-process
|
|
286
|
+
* `ask-app-inline-tasks.ts` snapshot instead of an A2A `Task` — used by the
|
|
287
|
+
* no-origin fallback (no A2A task exists to describe). Kept field-for-field
|
|
288
|
+
* identical so `ask_app` / `ask_app_status` callers can't tell which backing
|
|
289
|
+
* store answered.
|
|
290
|
+
*/
|
|
291
|
+
function askAppInlineTaskResult(
|
|
292
|
+
selfId: string,
|
|
293
|
+
taskId: string,
|
|
294
|
+
inline: {
|
|
295
|
+
status: "working" | "completed" | "failed";
|
|
296
|
+
response?: string;
|
|
297
|
+
error?: string;
|
|
298
|
+
},
|
|
299
|
+
note?: string,
|
|
300
|
+
): AskAppTaskResult {
|
|
301
|
+
const base = {
|
|
302
|
+
app: selfId,
|
|
303
|
+
routedVia: "local" as const,
|
|
304
|
+
taskId,
|
|
305
|
+
status: inline.status,
|
|
306
|
+
...(note ? { note } : {}),
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
if (inline.status === "completed") {
|
|
310
|
+
return { ...base, response: inline.response || "(no response)" };
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
if (inline.status === "failed") {
|
|
314
|
+
return { ...base, error: inline.error || "ask_app task failed." };
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
return {
|
|
318
|
+
...base,
|
|
319
|
+
pollAfterMs: ASK_APP_POLL_INTERVAL_MS,
|
|
320
|
+
poll: {
|
|
321
|
+
tool: "ask_app_status",
|
|
322
|
+
arguments: { app: selfId, taskId },
|
|
323
|
+
},
|
|
324
|
+
message:
|
|
325
|
+
`ask_app is still ${inline.status}. Call ask_app_status with ` +
|
|
326
|
+
`taskId "${taskId}" to retrieve the final response.`,
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
async function createA2AClientForAskApp(
|
|
331
|
+
origin: string,
|
|
332
|
+
requestOrigin?: string,
|
|
333
|
+
deadline?: number,
|
|
334
|
+
): Promise<{
|
|
335
|
+
client: import("../a2a/client.js").A2AClient;
|
|
336
|
+
metadata: Record<string, unknown>;
|
|
337
|
+
}> {
|
|
338
|
+
const { A2AClient } = await import("../a2a/client.js");
|
|
339
|
+
const { resolveA2ACallerAuth } = await import("../a2a/caller-auth.js");
|
|
340
|
+
const auth = await resolveA2ACallerAuth();
|
|
341
|
+
const metadata: Record<string, unknown> = {};
|
|
342
|
+
if (auth.userEmail) metadata.userEmail = auth.userEmail;
|
|
343
|
+
if (auth.orgDomain) metadata.orgDomain = auth.orgDomain;
|
|
344
|
+
if (requestOrigin) metadata.requestOrigin = requestOrigin;
|
|
345
|
+
const remainingMs = deadline == null ? null : deadline - Date.now();
|
|
346
|
+
return {
|
|
347
|
+
client: new A2AClient(origin, auth.apiKey, {
|
|
348
|
+
requestTimeoutMs:
|
|
349
|
+
remainingMs == null
|
|
350
|
+
? ASK_APP_A2A_REQUEST_TIMEOUT_MS
|
|
351
|
+
: Math.max(1, Math.min(ASK_APP_A2A_REQUEST_TIMEOUT_MS, remainingMs)),
|
|
352
|
+
...(auth.apiKeyFallbacks
|
|
353
|
+
? { fallbackApiKeys: auth.apiKeyFallbacks }
|
|
354
|
+
: {}),
|
|
355
|
+
}),
|
|
356
|
+
metadata,
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
async function runBeforeAskAppDeadline<T>(
|
|
361
|
+
operation: () => Promise<T>,
|
|
362
|
+
deadline: number,
|
|
363
|
+
): Promise<T> {
|
|
364
|
+
const remainingMs = deadline - Date.now();
|
|
365
|
+
if (remainingMs <= 0) throw new AskAppInlineDeadlineError();
|
|
366
|
+
|
|
367
|
+
let timeout: ReturnType<typeof setTimeout> | undefined;
|
|
368
|
+
try {
|
|
369
|
+
return await Promise.race([
|
|
370
|
+
operation(),
|
|
371
|
+
new Promise<T>((_resolve, reject) => {
|
|
372
|
+
timeout = setTimeout(
|
|
373
|
+
() => reject(new AskAppInlineDeadlineError()),
|
|
374
|
+
remainingMs,
|
|
375
|
+
);
|
|
376
|
+
}),
|
|
377
|
+
]);
|
|
378
|
+
} finally {
|
|
379
|
+
if (timeout) clearTimeout(timeout);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
async function waitForA2ATask(
|
|
384
|
+
client: import("../a2a/client.js").A2AClient,
|
|
385
|
+
initialTask: Task,
|
|
386
|
+
deadline: number | undefined,
|
|
387
|
+
): Promise<Task> {
|
|
388
|
+
if (deadline == null || isTerminalTask(initialTask)) return initialTask;
|
|
389
|
+
let current = initialTask;
|
|
390
|
+
|
|
391
|
+
while (!isTerminalTask(current)) {
|
|
392
|
+
const remaining = deadline - Date.now();
|
|
393
|
+
if (remaining <= 0) return current;
|
|
394
|
+
await new Promise((resolve) =>
|
|
395
|
+
setTimeout(resolve, Math.min(ASK_APP_POLL_INTERVAL_MS, remaining)),
|
|
396
|
+
);
|
|
397
|
+
if (Date.now() >= deadline) return current;
|
|
398
|
+
try {
|
|
399
|
+
current = await runBeforeAskAppDeadline(
|
|
400
|
+
() => client.getTask(initialTask.id),
|
|
401
|
+
deadline,
|
|
402
|
+
);
|
|
403
|
+
} catch (err) {
|
|
404
|
+
if (err instanceof AskAppInlineDeadlineError) return current;
|
|
405
|
+
if (!isTransientAskAppStatusError(err)) throw err;
|
|
406
|
+
if (Date.now() >= deadline) return current;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
return current;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
async function submitAskAppA2ATask(
|
|
414
|
+
route: AskAppRoute,
|
|
415
|
+
message: string,
|
|
416
|
+
maxWaitMs: number,
|
|
417
|
+
approvedActions?: A2AApprovedAction[],
|
|
418
|
+
): Promise<AskAppTaskResult> {
|
|
419
|
+
const deadline = maxWaitMs > 0 ? Date.now() + maxWaitMs : undefined;
|
|
420
|
+
const { client, metadata } = await createA2AClientForAskApp(
|
|
421
|
+
route.origin,
|
|
422
|
+
route.requestOrigin,
|
|
423
|
+
deadline,
|
|
424
|
+
);
|
|
425
|
+
const task = await client.send(
|
|
426
|
+
{
|
|
427
|
+
role: "user",
|
|
428
|
+
parts: [{ type: "text", text: message }],
|
|
429
|
+
},
|
|
430
|
+
{
|
|
431
|
+
async: true,
|
|
432
|
+
metadata,
|
|
433
|
+
...(approvedActions?.length ? { approvedActions } : {}),
|
|
434
|
+
},
|
|
435
|
+
);
|
|
436
|
+
const finalOrRunning = await waitForA2ATask(client, task, deadline);
|
|
437
|
+
return askAppTaskResult(route, finalOrRunning);
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
async function fetchAskAppA2ATask(
|
|
441
|
+
route: AskAppRoute,
|
|
442
|
+
taskId: string,
|
|
443
|
+
): Promise<AskAppTaskResult> {
|
|
444
|
+
const { client } = await createA2AClientForAskApp(route.origin);
|
|
445
|
+
const maxAttempts = ASK_APP_STATUS_RETRY_DELAYS_MS.length + 1;
|
|
446
|
+
for (
|
|
447
|
+
let attempt = 0;
|
|
448
|
+
attempt <= ASK_APP_STATUS_RETRY_DELAYS_MS.length;
|
|
449
|
+
attempt++
|
|
450
|
+
) {
|
|
451
|
+
const startedAt = Date.now();
|
|
452
|
+
try {
|
|
453
|
+
const task = await client.getTask(taskId);
|
|
454
|
+
return askAppTaskResult(route, task);
|
|
455
|
+
} catch (err) {
|
|
456
|
+
const delayMs = ASK_APP_STATUS_RETRY_DELAYS_MS[attempt];
|
|
457
|
+
const errorCategory = askAppStatusErrorCategory(err);
|
|
458
|
+
const retryable = errorCategory != null;
|
|
459
|
+
const willRetry = retryable && delayMs != null;
|
|
460
|
+
if (retryable) {
|
|
461
|
+
console.warn("[ask_app_status] tasks/get attempt failed", {
|
|
462
|
+
app: route.app,
|
|
463
|
+
routedVia: route.routedVia,
|
|
464
|
+
taskId,
|
|
465
|
+
originHost: askAppStatusOriginHost(route.origin),
|
|
466
|
+
attempt: attempt + 1,
|
|
467
|
+
maxAttempts,
|
|
468
|
+
elapsedMs: Date.now() - startedAt,
|
|
469
|
+
errorCategory,
|
|
470
|
+
errorName: err instanceof Error ? err.name : typeof err,
|
|
471
|
+
causeCode: askAppStatusErrorCauseCode(err),
|
|
472
|
+
willRetry,
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
if (!retryable) {
|
|
477
|
+
throw err;
|
|
478
|
+
}
|
|
479
|
+
if (delayMs == null) {
|
|
480
|
+
return askAppStatusReadUnavailableResult(
|
|
481
|
+
route,
|
|
482
|
+
taskId,
|
|
483
|
+
errorCategory,
|
|
484
|
+
maxAttempts,
|
|
485
|
+
);
|
|
486
|
+
}
|
|
487
|
+
await new Promise((resolve) => setTimeout(resolve, delayMs));
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
throw new Error("ask_app_status retry loop exited unexpectedly.");
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
function isTransientAskAppStatusError(err: unknown): boolean {
|
|
494
|
+
return askAppStatusErrorCategory(err) != null;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
function askAppStatusErrorCategory(
|
|
498
|
+
err: unknown,
|
|
499
|
+
): AskAppStatusErrorCategory | null {
|
|
500
|
+
const message = err instanceof Error ? err.message : String(err ?? "");
|
|
501
|
+
const causeCode = askAppStatusErrorCauseCode(err) ?? "";
|
|
502
|
+
const diagnostic = `${message} ${causeCode}`;
|
|
503
|
+
if (/A2A request failed \(429\)/i.test(message)) return "rate_limited";
|
|
504
|
+
if (/A2A request failed \((?:500|502|503|504)\)/i.test(message)) {
|
|
505
|
+
return "upstream_5xx";
|
|
506
|
+
}
|
|
507
|
+
if (/etimedout|timeout|aborted|aborterror/i.test(diagnostic)) {
|
|
508
|
+
return "timeout";
|
|
509
|
+
}
|
|
510
|
+
if (
|
|
511
|
+
/\bfetch failed\b|failed to fetch|networkerror|socket hang up|econnreset/i.test(
|
|
512
|
+
diagnostic,
|
|
513
|
+
)
|
|
514
|
+
) {
|
|
515
|
+
return "transport";
|
|
516
|
+
}
|
|
517
|
+
return null;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
function askAppStatusErrorCauseCode(err: unknown): string | undefined {
|
|
521
|
+
if (!(err instanceof Error)) return undefined;
|
|
522
|
+
const directCode = (err as Error & { code?: unknown }).code;
|
|
523
|
+
if (typeof directCode === "string" && directCode.trim()) {
|
|
524
|
+
return directCode.trim();
|
|
525
|
+
}
|
|
526
|
+
if (!err.cause || typeof err.cause !== "object") return undefined;
|
|
527
|
+
const code = (err.cause as { code?: unknown }).code;
|
|
528
|
+
return typeof code === "string" && code.trim() ? code.trim() : undefined;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
function askAppStatusOriginHost(origin: string): string {
|
|
532
|
+
try {
|
|
533
|
+
return new URL(origin).host;
|
|
534
|
+
} catch {
|
|
535
|
+
return "unknown";
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
function askAppStatusReadUnavailableResult(
|
|
540
|
+
route: AskAppRoute,
|
|
541
|
+
taskId: string,
|
|
542
|
+
errorCategory: AskAppStatusErrorCategory,
|
|
543
|
+
attempts: number,
|
|
544
|
+
): AskAppTaskResult {
|
|
545
|
+
return {
|
|
546
|
+
app: route.app,
|
|
547
|
+
routedVia: route.routedVia,
|
|
548
|
+
taskId,
|
|
549
|
+
status: "unknown",
|
|
550
|
+
statusRead: "unavailable",
|
|
551
|
+
retryable: true,
|
|
552
|
+
errorCategory,
|
|
553
|
+
attempts,
|
|
554
|
+
pollAfterMs: ASK_APP_POLL_INTERVAL_MS,
|
|
555
|
+
poll: {
|
|
556
|
+
tool: "ask_app_status",
|
|
557
|
+
arguments: { app: route.app, taskId },
|
|
558
|
+
},
|
|
559
|
+
message:
|
|
560
|
+
"The durable ask_app task status could not be read after bounded retries. " +
|
|
561
|
+
"The task may still be running or completed. Retry ask_app_status " +
|
|
562
|
+
"with the same app and taskId; do not resubmit ask_app.",
|
|
563
|
+
};
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
/**
|
|
567
|
+
* Resolve the absolute origin of a *target* workspace app (e.g.
|
|
568
|
+
* `http://127.0.0.1:8101`) so cross-app deep links / A2A calls point at the
|
|
569
|
+
* right app instead of the current request's origin. Reuses the same
|
|
570
|
+
* workspace resolution `list_apps` / the stdio proxy use.
|
|
571
|
+
*
|
|
572
|
+
* Returns `null` when:
|
|
573
|
+
* - the target is the current app (caller should keep relative behavior),
|
|
574
|
+
* - there is no workspace info (standalone / single app), or
|
|
575
|
+
* - the target app is unknown.
|
|
576
|
+
*/
|
|
577
|
+
async function resolveTargetAppOrigin(
|
|
578
|
+
config: MCPConfig,
|
|
579
|
+
targetAppId: string,
|
|
580
|
+
): Promise<{ origin: string; id: string } | null> {
|
|
581
|
+
const target = targetAppId.trim().toLowerCase();
|
|
582
|
+
if (!target || target === currentAppId(config)) return null;
|
|
583
|
+
try {
|
|
584
|
+
const { resolveWorkspace } = await import("./workspace-resolve.js");
|
|
585
|
+
const ws = await resolveWorkspace();
|
|
586
|
+
if (!ws.isWorkspace) return null;
|
|
587
|
+
const match = ws.apps.find((a) => a.id.toLowerCase() === target);
|
|
588
|
+
if (!match) return null;
|
|
589
|
+
return { origin: match.url, id: match.id };
|
|
590
|
+
} catch {
|
|
591
|
+
return null;
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
// ---------------------------------------------------------------------------
|
|
596
|
+
// list_apps
|
|
597
|
+
// ---------------------------------------------------------------------------
|
|
598
|
+
|
|
599
|
+
function listAppsTool(
|
|
600
|
+
config: MCPConfig,
|
|
601
|
+
requestMeta?: { origin?: string },
|
|
602
|
+
): ActionEntry {
|
|
603
|
+
return {
|
|
604
|
+
tool: tool(
|
|
605
|
+
"List the workspace apps and their URLs. Use this to discover which " +
|
|
606
|
+
"apps exist before opening or asking one. In a single-app project " +
|
|
607
|
+
"this returns just that app. When an org directory is configured " +
|
|
608
|
+
"this also includes the org's deployed sibling apps.",
|
|
609
|
+
),
|
|
610
|
+
readOnly: true,
|
|
611
|
+
parallelSafe: true,
|
|
612
|
+
run: async () => {
|
|
613
|
+
const { resolveWorkspace } = await import("./workspace-resolve.js");
|
|
614
|
+
const ws = await resolveWorkspace();
|
|
615
|
+
|
|
616
|
+
// The MCP request is served BY the current app, so it is provably
|
|
617
|
+
// reachable at the inbound request origin — that beats a guessed
|
|
618
|
+
// `PORT || 5173` probe (which reports the wrong URL + `running:false`
|
|
619
|
+
// whenever the dev server picked a non-default port, e.g. `agent-
|
|
620
|
+
// native dev` on :8080). For the entry that IS this app (the sole
|
|
621
|
+
// entry when single-app, or the id matching `config.appId` in a
|
|
622
|
+
// workspace) prefer the live origin; other workspace apps keep their
|
|
623
|
+
// probed values.
|
|
624
|
+
const liveOrigin = requestMeta?.origin?.replace(/\/+$/, "") || "";
|
|
625
|
+
let livePort = 0;
|
|
626
|
+
if (liveOrigin) {
|
|
627
|
+
try {
|
|
628
|
+
const u = new URL(liveOrigin);
|
|
629
|
+
livePort = Number(u.port) || (u.protocol === "https:" ? 443 : 80);
|
|
630
|
+
} catch {
|
|
631
|
+
livePort = 0;
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
const selfId = (config.appId ?? "").toLowerCase();
|
|
635
|
+
const isSelf = (id: string) =>
|
|
636
|
+
!!liveOrigin &&
|
|
637
|
+
(!ws.isWorkspace || (!!selfId && id.toLowerCase() === selfId));
|
|
638
|
+
|
|
639
|
+
interface AppEntry {
|
|
640
|
+
id: string;
|
|
641
|
+
url: string;
|
|
642
|
+
port: number | undefined;
|
|
643
|
+
running: boolean;
|
|
644
|
+
source: "workspace" | "org-directory";
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
const apps: AppEntry[] = ws.apps.map((a) =>
|
|
648
|
+
isSelf(a.id)
|
|
649
|
+
? {
|
|
650
|
+
id: a.id,
|
|
651
|
+
url: liveOrigin,
|
|
652
|
+
port: (livePort || a.port) as number | undefined,
|
|
653
|
+
running: true,
|
|
654
|
+
source: "workspace" as const,
|
|
655
|
+
}
|
|
656
|
+
: {
|
|
657
|
+
id: a.id,
|
|
658
|
+
url: a.url,
|
|
659
|
+
port: a.port as number | undefined,
|
|
660
|
+
running: a.running,
|
|
661
|
+
source: "workspace" as const,
|
|
662
|
+
},
|
|
663
|
+
);
|
|
664
|
+
const seenIds = new Set(apps.map((a) => a.id.toLowerCase()));
|
|
665
|
+
const seenOrigins = new Set(apps.map((a) => a.url.replace(/\/+$/, "")));
|
|
666
|
+
|
|
667
|
+
// Merge the org directory's deployed sibling apps. Inactive (no env)
|
|
668
|
+
// or any failure ⇒ fetchOrgApps() returns [] and this is a no-op, so
|
|
669
|
+
// the existing local/workspace behavior is preserved exactly.
|
|
670
|
+
const orgApps = await fetchOrgApps({
|
|
671
|
+
selfId: currentAppId(config),
|
|
672
|
+
}).catch(() => [] as OrgApp[]);
|
|
673
|
+
for (const oa of orgApps) {
|
|
674
|
+
const idKey = oa.id.toLowerCase();
|
|
675
|
+
const originKey = oa.url.replace(/\/+$/, "");
|
|
676
|
+
// Dedupe by id OR origin — a workspace app already listed wins.
|
|
677
|
+
if (seenIds.has(idKey) || seenOrigins.has(originKey)) continue;
|
|
678
|
+
seenIds.add(idKey);
|
|
679
|
+
seenOrigins.add(originKey);
|
|
680
|
+
apps.push({
|
|
681
|
+
id: oa.id,
|
|
682
|
+
url: oa.url,
|
|
683
|
+
port: undefined,
|
|
684
|
+
running: true,
|
|
685
|
+
source: "org-directory",
|
|
686
|
+
});
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
return {
|
|
690
|
+
workspace: ws.isWorkspace,
|
|
691
|
+
gatewayUrl: ws.gatewayUrl,
|
|
692
|
+
apps,
|
|
693
|
+
};
|
|
694
|
+
},
|
|
695
|
+
};
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
// ---------------------------------------------------------------------------
|
|
699
|
+
// open_app
|
|
700
|
+
// ---------------------------------------------------------------------------
|
|
701
|
+
|
|
702
|
+
function openAppTool(
|
|
703
|
+
config: MCPConfig,
|
|
704
|
+
requestMeta?: { origin?: string },
|
|
705
|
+
): ActionEntry {
|
|
706
|
+
return {
|
|
707
|
+
tool: tool(
|
|
708
|
+
"Build a deep link that opens an app at a specific view/record or " +
|
|
709
|
+
"focused route/component. No side " +
|
|
710
|
+
"effects — returns a URL the user can click to land in the running UI. " +
|
|
711
|
+
"Set embed:true when a UI-capable MCP host should render the live app " +
|
|
712
|
+
"or focused route/component inline. Omit view and path to land on the " +
|
|
713
|
+
"app's home page.",
|
|
714
|
+
{
|
|
715
|
+
app: { type: "string", description: "App id, e.g. 'mail'" },
|
|
716
|
+
view: {
|
|
717
|
+
type: "string",
|
|
718
|
+
description:
|
|
719
|
+
"Target view, e.g. 'inbox' (maps to navigate command). Optional — omit (along with path) to open the app's home page.",
|
|
720
|
+
},
|
|
721
|
+
path: {
|
|
722
|
+
type: "string",
|
|
723
|
+
description:
|
|
724
|
+
"Optional app route to open directly, e.g. '/extensions/abc', '/adhoc/q2', or '/chart?panel=...'. Must be same-origin relative. Omit (along with view) to open the app's home page.",
|
|
725
|
+
},
|
|
726
|
+
params: {
|
|
727
|
+
type: "object",
|
|
728
|
+
description:
|
|
729
|
+
"Optional record-focus / filter params, e.g. { threadId: 'abc' }",
|
|
730
|
+
},
|
|
731
|
+
embed: {
|
|
732
|
+
type: "boolean",
|
|
733
|
+
description:
|
|
734
|
+
"Render the full app or focused route/component inline in MCP Apps when the host supports it.",
|
|
735
|
+
},
|
|
736
|
+
chrome: {
|
|
737
|
+
type: "string",
|
|
738
|
+
enum: ["full", "minimal"],
|
|
739
|
+
description:
|
|
740
|
+
"Embed chrome preference for compatible app routes. Defaults to full.",
|
|
741
|
+
},
|
|
742
|
+
},
|
|
743
|
+
["app"],
|
|
744
|
+
),
|
|
745
|
+
readOnly: true,
|
|
746
|
+
parallelSafe: true,
|
|
747
|
+
run: async (args: Record<string, any>) => {
|
|
748
|
+
const app = String(args.app ?? "").trim();
|
|
749
|
+
const view = String(args.view ?? "").trim();
|
|
750
|
+
// `safeAppPath` rejects anything that isn't a leading-slash same-origin
|
|
751
|
+
// path. When the caller passes nothing, fall back to the app's root so a
|
|
752
|
+
// bare `open_app({app:"dispatch"})` lands on the home page instead of
|
|
753
|
+
// throwing. The model self-corrects on the retry today, but the extra
|
|
754
|
+
// round-trip wastes a turn and looks broken to the user.
|
|
755
|
+
const path = safeAppPath(args.path) || (view ? null : "/");
|
|
756
|
+
if (!app) {
|
|
757
|
+
throw new Error("open_app requires 'app'.");
|
|
758
|
+
}
|
|
759
|
+
let params: Record<string, string | number | boolean> | undefined;
|
|
760
|
+
const raw = args.params;
|
|
761
|
+
if (raw && typeof raw === "object") {
|
|
762
|
+
params = raw as Record<string, string | number | boolean>;
|
|
763
|
+
} else if (typeof raw === "string" && raw.trim()) {
|
|
764
|
+
try {
|
|
765
|
+
params = JSON.parse(raw);
|
|
766
|
+
} catch {
|
|
767
|
+
params = undefined;
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
const embeddedParam = params?.embed;
|
|
771
|
+
const chromeParam = params?.chrome;
|
|
772
|
+
let embed = args.embed === true || args.embed === "true";
|
|
773
|
+
if (
|
|
774
|
+
args.embed == null &&
|
|
775
|
+
(embeddedParam === true || embeddedParam === "true")
|
|
776
|
+
) {
|
|
777
|
+
embed = true;
|
|
778
|
+
} else if (
|
|
779
|
+
args.embed == null &&
|
|
780
|
+
(embeddedParam === false || embeddedParam === "false")
|
|
781
|
+
) {
|
|
782
|
+
embed = false;
|
|
783
|
+
}
|
|
784
|
+
if (
|
|
785
|
+
embeddedParam === true ||
|
|
786
|
+
embeddedParam === false ||
|
|
787
|
+
embeddedParam === "true" ||
|
|
788
|
+
embeddedParam === "false"
|
|
789
|
+
) {
|
|
790
|
+
delete params?.embed;
|
|
791
|
+
}
|
|
792
|
+
|
|
793
|
+
const chrome =
|
|
794
|
+
typeof args.chrome === "string"
|
|
795
|
+
? args.chrome
|
|
796
|
+
: chromeParam === "full" || chromeParam === "minimal"
|
|
797
|
+
? chromeParam
|
|
798
|
+
: undefined;
|
|
799
|
+
if (chromeParam === "full" || chromeParam === "minimal") {
|
|
800
|
+
delete params?.chrome;
|
|
801
|
+
}
|
|
802
|
+
if (params && Object.keys(params).length === 0) params = undefined;
|
|
803
|
+
|
|
804
|
+
const directViewPath = embed && view ? viewToAppPath(view) : null;
|
|
805
|
+
const relUrl = path
|
|
806
|
+
? appendParamsToPath(path, params)
|
|
807
|
+
: directViewPath
|
|
808
|
+
? appendParamsToPath(directViewPath, params)
|
|
809
|
+
: buildDeepLink({ app, view, params });
|
|
810
|
+
const sameAppUrl =
|
|
811
|
+
path || directViewPath ? withConfiguredBasePath(relUrl) : relUrl;
|
|
812
|
+
|
|
813
|
+
// Cross-app target in a workspace: resolve the TARGET app's origin and
|
|
814
|
+
// return an absolute URL. Otherwise the MCP layer would prefix the
|
|
815
|
+
// relative path with the CURRENT request origin, landing the user in
|
|
816
|
+
// the wrong app (e.g. open_app({app:"calendar"}) served from Mail).
|
|
817
|
+
// Same-app / standalone keeps the relative path (current behavior).
|
|
818
|
+
const targetApp = await resolveTargetAppOrigin(config, app);
|
|
819
|
+
const appUrl = targetApp
|
|
820
|
+
? `${targetApp.origin.replace(/\/+$/, "")}${relUrl}`
|
|
821
|
+
: sameAppUrl;
|
|
822
|
+
const url = appUrl;
|
|
823
|
+
let embedStartUrl: string | undefined;
|
|
824
|
+
let embedTargetPath: string | undefined;
|
|
825
|
+
let embedExpiresAt: number | undefined;
|
|
826
|
+
|
|
827
|
+
if (embed && !targetApp) {
|
|
828
|
+
const { getRequestContext } =
|
|
829
|
+
await import("../server/request-context.js");
|
|
830
|
+
const ctx = getRequestContext();
|
|
831
|
+
const ownerEmail = ctx?.userEmail?.trim();
|
|
832
|
+
if (ownerEmail) {
|
|
833
|
+
const { normalizeEmbedTargetPath, createEmbedSessionTicket } =
|
|
834
|
+
await import("../server/embed-session.js");
|
|
835
|
+
const { buildEmbedStartPath } =
|
|
836
|
+
await import("../server/embed-route.js");
|
|
837
|
+
const targetPath = normalizeEmbedTargetPath(
|
|
838
|
+
withMcpChatBridgeParam(url),
|
|
839
|
+
requestMeta?.origin,
|
|
840
|
+
);
|
|
841
|
+
if (targetPath) {
|
|
842
|
+
const ticket = await createEmbedSessionTicket({
|
|
843
|
+
ownerEmail,
|
|
844
|
+
orgId: ctx?.orgId,
|
|
845
|
+
targetPath,
|
|
846
|
+
scope: chrome ?? null,
|
|
847
|
+
});
|
|
848
|
+
const startPath = buildEmbedStartPath(ticket.ticket);
|
|
849
|
+
embedStartUrl = requestMeta?.origin
|
|
850
|
+
? new URL(startPath, requestMeta.origin).toString()
|
|
851
|
+
: startPath;
|
|
852
|
+
embedTargetPath = targetPath;
|
|
853
|
+
embedExpiresAt = ticket.expiresAt;
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
return {
|
|
859
|
+
app,
|
|
860
|
+
...(view ? { view } : {}),
|
|
861
|
+
...(path ? { path } : {}),
|
|
862
|
+
url,
|
|
863
|
+
...(embedStartUrl ? { embedStartUrl } : {}),
|
|
864
|
+
...(embedTargetPath ? { embedTargetPath } : {}),
|
|
865
|
+
...(embedExpiresAt ? { embedExpiresAt } : {}),
|
|
866
|
+
embed,
|
|
867
|
+
};
|
|
868
|
+
},
|
|
869
|
+
link: ({ result }) => {
|
|
870
|
+
if (!result || typeof result !== "object") return null;
|
|
871
|
+
const r = result as {
|
|
872
|
+
url?: string;
|
|
873
|
+
app?: string;
|
|
874
|
+
view?: string;
|
|
875
|
+
embed?: boolean;
|
|
876
|
+
};
|
|
877
|
+
if (r.embed) return null;
|
|
878
|
+
if (!r.url) return null;
|
|
879
|
+
return {
|
|
880
|
+
url: r.url,
|
|
881
|
+
label: `Open ${r.app ?? "app"}`,
|
|
882
|
+
view: r.view,
|
|
883
|
+
};
|
|
884
|
+
},
|
|
885
|
+
mcpApp: {
|
|
886
|
+
resource: embedApp({
|
|
887
|
+
title: "Open app",
|
|
888
|
+
description: "Render the requested app route inline.",
|
|
889
|
+
iframeTitle: "Agent Native app",
|
|
890
|
+
openLabel: "Open app",
|
|
891
|
+
}),
|
|
892
|
+
},
|
|
893
|
+
};
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
// ---------------------------------------------------------------------------
|
|
897
|
+
// create_embed_session
|
|
898
|
+
// ---------------------------------------------------------------------------
|
|
899
|
+
|
|
900
|
+
function createEmbedSessionTool(requestMeta?: {
|
|
901
|
+
origin?: string;
|
|
902
|
+
}): ActionEntry {
|
|
903
|
+
return {
|
|
904
|
+
tool: {
|
|
905
|
+
...tool(
|
|
906
|
+
"MCP Apps helper: create a one-time browser embed session for a same-origin app URL. Usually called by an MCP App iframe, not directly by the model.",
|
|
907
|
+
{
|
|
908
|
+
url: {
|
|
909
|
+
type: "string",
|
|
910
|
+
description:
|
|
911
|
+
"Same-origin absolute URL or app-relative path to embed.",
|
|
912
|
+
},
|
|
913
|
+
path: {
|
|
914
|
+
type: "string",
|
|
915
|
+
description: "Same-origin app-relative path to embed.",
|
|
916
|
+
},
|
|
917
|
+
chrome: {
|
|
918
|
+
type: "string",
|
|
919
|
+
enum: ["full", "minimal"],
|
|
920
|
+
description: "Embed chrome preference. Defaults to full.",
|
|
921
|
+
},
|
|
922
|
+
},
|
|
923
|
+
),
|
|
924
|
+
_meta: { ui: { visibility: ["app"] } },
|
|
925
|
+
} as ActionTool,
|
|
926
|
+
// App-only bootstrap helper: the ticket becomes a normal browser session,
|
|
927
|
+
// so keep it write-scoped until embed sessions can enforce MCP scopes.
|
|
928
|
+
readOnly: false,
|
|
929
|
+
parallelSafe: true,
|
|
930
|
+
run: async (args: Record<string, any>) => {
|
|
931
|
+
const { getRequestContext } =
|
|
932
|
+
await import("../server/request-context.js");
|
|
933
|
+
const ctx = getRequestContext();
|
|
934
|
+
const ownerEmail = ctx?.userEmail?.trim();
|
|
935
|
+
if (!ownerEmail) {
|
|
936
|
+
throw new Error(
|
|
937
|
+
"create_embed_session requires an authenticated MCP caller.",
|
|
938
|
+
);
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
const { normalizeEmbedTargetPath, createEmbedSessionTicket } =
|
|
942
|
+
await import("../server/embed-session.js");
|
|
943
|
+
const { buildEmbedStartPath } = await import("../server/embed-route.js");
|
|
944
|
+
const rawTarget =
|
|
945
|
+
typeof args.url === "string" && args.url.trim()
|
|
946
|
+
? args.url
|
|
947
|
+
: typeof args.path === "string"
|
|
948
|
+
? args.path
|
|
949
|
+
: "";
|
|
950
|
+
const targetPath = normalizeEmbedTargetPath(
|
|
951
|
+
rawTarget,
|
|
952
|
+
requestMeta?.origin,
|
|
953
|
+
);
|
|
954
|
+
if (!targetPath) {
|
|
955
|
+
throw new Error(
|
|
956
|
+
"create_embed_session can only embed same-origin app-relative URLs.",
|
|
957
|
+
);
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
const ticket = await createEmbedSessionTicket({
|
|
961
|
+
ownerEmail,
|
|
962
|
+
orgId: ctx?.orgId,
|
|
963
|
+
targetPath,
|
|
964
|
+
scope: typeof args.chrome === "string" ? args.chrome : null,
|
|
965
|
+
});
|
|
966
|
+
const startPath = buildEmbedStartPath(ticket.ticket);
|
|
967
|
+
const startUrl = requestMeta?.origin
|
|
968
|
+
? new URL(startPath, requestMeta.origin).toString()
|
|
969
|
+
: startPath;
|
|
970
|
+
return {
|
|
971
|
+
startUrl,
|
|
972
|
+
targetPath,
|
|
973
|
+
expiresAt: ticket.expiresAt,
|
|
974
|
+
};
|
|
975
|
+
},
|
|
976
|
+
};
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
/**
|
|
980
|
+
* Route an `ask_app` message to a *different* app's agent over A2A. Shared by
|
|
981
|
+
* the workspace-resolved path and the org-directory-resolved path so the A2A
|
|
982
|
+
* call logic is not duplicated. `origin` is the target app's A2A base
|
|
983
|
+
* (workspace dev origin or the directory's `a2aUrl`); `id` is reported back.
|
|
984
|
+
*
|
|
985
|
+
* Throws on failure so the caller can be honest — it never falls back to this
|
|
986
|
+
* app's agent and pretends it was the target.
|
|
987
|
+
*/
|
|
988
|
+
async function routeAskOverA2A(
|
|
989
|
+
origin: string,
|
|
990
|
+
id: string,
|
|
991
|
+
message: string,
|
|
992
|
+
options?: {
|
|
993
|
+
durable?: boolean;
|
|
994
|
+
maxWaitMs?: number;
|
|
995
|
+
requestOrigin?: string;
|
|
996
|
+
approvedActions?: A2AApprovedAction[];
|
|
997
|
+
},
|
|
998
|
+
): Promise<
|
|
999
|
+
{ app: string; routedVia: "a2a"; response: string } | AskAppTaskResult
|
|
1000
|
+
> {
|
|
1001
|
+
if (options?.durable) {
|
|
1002
|
+
return submitAskAppA2ATask(
|
|
1003
|
+
{
|
|
1004
|
+
app: id,
|
|
1005
|
+
origin: agentNativeA2AEndpoint(origin),
|
|
1006
|
+
routedVia: "a2a",
|
|
1007
|
+
requestOrigin: options.requestOrigin ?? origin,
|
|
1008
|
+
},
|
|
1009
|
+
message,
|
|
1010
|
+
options.maxWaitMs ?? ASK_APP_DEFAULT_INLINE_WAIT_MS,
|
|
1011
|
+
options.approvedActions,
|
|
1012
|
+
);
|
|
1013
|
+
}
|
|
1014
|
+
const { callAgent } = await import("../a2a/client.js");
|
|
1015
|
+
const { resolveA2ACallerAuth } = await import("../a2a/caller-auth.js");
|
|
1016
|
+
// The MCP handler runs inside `runWithRequestContext`, so this is the
|
|
1017
|
+
// verified caller identity and org scope. Reuse the same auth resolver as
|
|
1018
|
+
// org-directory discovery so the directory lookup and actual A2A call are
|
|
1019
|
+
// scoped the same way.
|
|
1020
|
+
const auth = await resolveA2ACallerAuth();
|
|
1021
|
+
const response = await callAgent(origin, message, {
|
|
1022
|
+
apiKey: auth.apiKey,
|
|
1023
|
+
userEmail: auth.userEmail,
|
|
1024
|
+
orgDomain: auth.orgDomain,
|
|
1025
|
+
orgSecret: auth.orgSecret,
|
|
1026
|
+
requestOrigin: options?.requestOrigin,
|
|
1027
|
+
approvedActions: options?.approvedActions,
|
|
1028
|
+
// Bound the wait — cross-app A2A polls async by default.
|
|
1029
|
+
timeoutMs: 5 * 60_000,
|
|
1030
|
+
});
|
|
1031
|
+
return { app: id, routedVia: "a2a", response };
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
async function resolveAskAppStatusRoute(
|
|
1035
|
+
config: MCPConfig,
|
|
1036
|
+
requestedApp: string,
|
|
1037
|
+
requestMeta?: AskAppRequestMeta,
|
|
1038
|
+
): Promise<AskAppRoute> {
|
|
1039
|
+
const selfId = currentAppId(config);
|
|
1040
|
+
const normalized = requestedApp.trim().toLowerCase();
|
|
1041
|
+
const selfEndpointUrl = selfA2AEndpointUrl(requestMeta);
|
|
1042
|
+
|
|
1043
|
+
if (!normalized || normalized === selfId) {
|
|
1044
|
+
if (!selfEndpointUrl) {
|
|
1045
|
+
throw new Error(
|
|
1046
|
+
"ask_app_status requires a running app origin for local tasks.",
|
|
1047
|
+
);
|
|
1048
|
+
}
|
|
1049
|
+
return {
|
|
1050
|
+
app: selfId,
|
|
1051
|
+
origin: selfEndpointUrl,
|
|
1052
|
+
routedVia: "local",
|
|
1053
|
+
requestOrigin: requestMeta?.origin,
|
|
1054
|
+
};
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
const targetApp = await resolveTargetAppOrigin(config, requestedApp);
|
|
1058
|
+
if (targetApp) {
|
|
1059
|
+
return {
|
|
1060
|
+
app: targetApp.id,
|
|
1061
|
+
origin: agentNativeA2AEndpoint(targetApp.origin),
|
|
1062
|
+
routedVia: "a2a",
|
|
1063
|
+
requestOrigin: targetApp.origin,
|
|
1064
|
+
};
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
const orgApps = await fetchOrgApps({ selfId }).catch(() => [] as OrgApp[]);
|
|
1068
|
+
const dirMatch = orgApps.find((a) => a.id === normalized);
|
|
1069
|
+
if (dirMatch) {
|
|
1070
|
+
return {
|
|
1071
|
+
app: dirMatch.id,
|
|
1072
|
+
origin: agentNativeA2AEndpoint(dirMatch.a2aUrl),
|
|
1073
|
+
routedVia: "a2a",
|
|
1074
|
+
requestOrigin: dirMatch.url,
|
|
1075
|
+
};
|
|
1076
|
+
}
|
|
1077
|
+
|
|
1078
|
+
throw new Error(`No reachable ask_app task route for app "${requestedApp}".`);
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
// ---------------------------------------------------------------------------
|
|
1082
|
+
// ask_app
|
|
1083
|
+
// ---------------------------------------------------------------------------
|
|
1084
|
+
|
|
1085
|
+
function askAppTool(
|
|
1086
|
+
config: MCPConfig,
|
|
1087
|
+
requestMeta?: AskAppRequestMeta,
|
|
1088
|
+
): ActionEntry {
|
|
1089
|
+
return {
|
|
1090
|
+
tool: tool(
|
|
1091
|
+
"Send a natural-language message to an app's AI agent and get its " +
|
|
1092
|
+
"response. Use this first for natural-language investigation, " +
|
|
1093
|
+
"diagnosis, multi-step work, and changes; it runs with the app's " +
|
|
1094
|
+
"full skills, instructions, tools, and context. Use direct action " +
|
|
1095
|
+
"tools only for a known, bounded read or simple UI handoff. In a " +
|
|
1096
|
+
"single-app project the 'app' " +
|
|
1097
|
+
"param is optional (defaults to this app). When 'app' names a " +
|
|
1098
|
+
"different workspace app it is routed there over A2A; the result's " +
|
|
1099
|
+
"'routedVia' field reports whether it ran cross-app or locally. " +
|
|
1100
|
+
"On hosted MCP, long tasks may return a durable taskId instead of a " +
|
|
1101
|
+
"final response; call ask_app_status with that taskId until completed.",
|
|
1102
|
+
{
|
|
1103
|
+
app: {
|
|
1104
|
+
type: "string",
|
|
1105
|
+
description: "App id to route to (optional in a single-app project)",
|
|
1106
|
+
},
|
|
1107
|
+
message: {
|
|
1108
|
+
type: "string",
|
|
1109
|
+
description: "The message to send to the app's agent",
|
|
1110
|
+
},
|
|
1111
|
+
async: {
|
|
1112
|
+
type: "boolean",
|
|
1113
|
+
description:
|
|
1114
|
+
"When true, start a durable task and return immediately with a taskId.",
|
|
1115
|
+
},
|
|
1116
|
+
maxWaitMs: {
|
|
1117
|
+
type: "number",
|
|
1118
|
+
description:
|
|
1119
|
+
"Maximum time to wait inline before returning a taskId. Hosted MCP clamps this to 25000ms.",
|
|
1120
|
+
},
|
|
1121
|
+
approvedActions: {
|
|
1122
|
+
type: "array",
|
|
1123
|
+
description:
|
|
1124
|
+
"Exact downstream tool calls the user explicitly authorized in this chat. Never infer authorization or include a different action.",
|
|
1125
|
+
items: {
|
|
1126
|
+
type: "object",
|
|
1127
|
+
properties: {
|
|
1128
|
+
tool: { type: "string" },
|
|
1129
|
+
input: { type: "object", additionalProperties: true },
|
|
1130
|
+
},
|
|
1131
|
+
required: ["tool", "input"],
|
|
1132
|
+
},
|
|
1133
|
+
} as any,
|
|
1134
|
+
},
|
|
1135
|
+
["message"],
|
|
1136
|
+
),
|
|
1137
|
+
run: async (args: Record<string, any>) => {
|
|
1138
|
+
const message = String(args.message ?? "").trim();
|
|
1139
|
+
if (!message) throw new Error("ask_app requires a 'message'.");
|
|
1140
|
+
const requestedApp = String(args.app ?? "").trim();
|
|
1141
|
+
const selfId = currentAppId(config);
|
|
1142
|
+
const useDurableA2A = Boolean(requestMeta?.origin);
|
|
1143
|
+
const maxWaitMs = isExplicitAsyncAsk(args.async)
|
|
1144
|
+
? 0
|
|
1145
|
+
: boundedAskAppWaitMs(args.maxWaitMs);
|
|
1146
|
+
const approvedActions = Array.isArray(args.approvedActions)
|
|
1147
|
+
? (args.approvedActions as A2AApprovedAction[])
|
|
1148
|
+
: undefined;
|
|
1149
|
+
|
|
1150
|
+
// Cross-app: the caller named a *different* workspace app. Route the
|
|
1151
|
+
// message to THAT app's agent over A2A (its `/_agent-native/a2a`
|
|
1152
|
+
// endpoint runs the real agent loop with JWT identity) rather than
|
|
1153
|
+
// silently answering from this app's agent and claiming delegation.
|
|
1154
|
+
const targetApp = await resolveTargetAppOrigin(config, requestedApp);
|
|
1155
|
+
if (targetApp) {
|
|
1156
|
+
try {
|
|
1157
|
+
return await routeAskOverA2A(
|
|
1158
|
+
targetApp.origin,
|
|
1159
|
+
targetApp.id,
|
|
1160
|
+
message,
|
|
1161
|
+
{
|
|
1162
|
+
durable: useDurableA2A,
|
|
1163
|
+
maxWaitMs,
|
|
1164
|
+
requestOrigin: targetApp.origin,
|
|
1165
|
+
approvedActions,
|
|
1166
|
+
},
|
|
1167
|
+
);
|
|
1168
|
+
} catch (err: any) {
|
|
1169
|
+
// Be honest: routing was attempted and failed — do NOT fall back to
|
|
1170
|
+
// this app's agent and pretend it was the target.
|
|
1171
|
+
throw new Error(
|
|
1172
|
+
`Failed to route ask_app to "${targetApp.id}" via A2A: ` +
|
|
1173
|
+
`${err?.message ?? err}`,
|
|
1174
|
+
);
|
|
1175
|
+
}
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
// Not a known local/workspace app — try the org directory. When a
|
|
1179
|
+
// directory is configured and the requested app is one of the org's
|
|
1180
|
+
// deployed sibling apps, route to it over A2A (same path as above,
|
|
1181
|
+
// against its `a2aUrl`). Inactive directory / any failure ⇒ orgApps is
|
|
1182
|
+
// [] and this is skipped, preserving the exact local-only behavior.
|
|
1183
|
+
if (requestedApp && requestedApp.toLowerCase() !== selfId) {
|
|
1184
|
+
const orgApps = await fetchOrgApps({ selfId }).catch(
|
|
1185
|
+
() => [] as OrgApp[],
|
|
1186
|
+
);
|
|
1187
|
+
const dirMatch = orgApps.find(
|
|
1188
|
+
(a) => a.id === requestedApp.toLowerCase(),
|
|
1189
|
+
);
|
|
1190
|
+
if (dirMatch) {
|
|
1191
|
+
try {
|
|
1192
|
+
return await routeAskOverA2A(
|
|
1193
|
+
dirMatch.a2aUrl,
|
|
1194
|
+
dirMatch.id,
|
|
1195
|
+
message,
|
|
1196
|
+
{
|
|
1197
|
+
durable: useDurableA2A,
|
|
1198
|
+
maxWaitMs,
|
|
1199
|
+
requestOrigin: dirMatch.url,
|
|
1200
|
+
approvedActions,
|
|
1201
|
+
},
|
|
1202
|
+
);
|
|
1203
|
+
} catch (err: any) {
|
|
1204
|
+
throw new Error(
|
|
1205
|
+
`Failed to route ask_app to "${dirMatch.id}" via A2A ` +
|
|
1206
|
+
`(org directory): ${err?.message ?? err}`,
|
|
1207
|
+
);
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
// Same app (or no workspace / unknown target): answer locally with this
|
|
1213
|
+
// app's own ask-agent handler — the same entry point the HTTP MCP mount
|
|
1214
|
+
// + A2A use, so there is no second agent runner.
|
|
1215
|
+
if (!config.askAgent) {
|
|
1216
|
+
throw new Error(
|
|
1217
|
+
"This app does not expose an agent (no ask-agent handler).",
|
|
1218
|
+
);
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
// If the caller named an app we couldn't route to (unknown id, or no
|
|
1222
|
+
// workspace), say so honestly instead of claiming we reached it.
|
|
1223
|
+
const unresolved =
|
|
1224
|
+
!!requestedApp && requestedApp.toLowerCase() !== selfId;
|
|
1225
|
+
const note = unresolved
|
|
1226
|
+
? `Requested app "${requestedApp}" is not a reachable workspace ` +
|
|
1227
|
+
`app; answered with this app ("${selfId}") instead.`
|
|
1228
|
+
: undefined;
|
|
1229
|
+
|
|
1230
|
+
// Hosted MCP cannot safely keep a JSON request/response open for a full
|
|
1231
|
+
// agent loop: serverless gateways can return an inactivity 504 before
|
|
1232
|
+
// the result body exists. When we know the running app origin, submit the
|
|
1233
|
+
// local ask through the app's durable A2A task path and only wait a
|
|
1234
|
+
// short bounded window for fast completions.
|
|
1235
|
+
const localA2AEndpointUrl = selfA2AEndpointUrl(requestMeta);
|
|
1236
|
+
if (localA2AEndpointUrl) {
|
|
1237
|
+
return submitAskAppA2ATask(
|
|
1238
|
+
{
|
|
1239
|
+
app: selfId,
|
|
1240
|
+
origin: localA2AEndpointUrl,
|
|
1241
|
+
routedVia: "local",
|
|
1242
|
+
requestOrigin: requestMeta?.origin,
|
|
1243
|
+
...(note ? { note } : {}),
|
|
1244
|
+
},
|
|
1245
|
+
message,
|
|
1246
|
+
maxWaitMs,
|
|
1247
|
+
approvedActions,
|
|
1248
|
+
);
|
|
1249
|
+
}
|
|
1250
|
+
|
|
1251
|
+
// No derivable app origin at all (e.g. stdio / no request context) —
|
|
1252
|
+
// there is no `/_agent-native/a2a` endpoint to submit a durable task
|
|
1253
|
+
// to either. Bound the wait against a process-local task map instead
|
|
1254
|
+
// of awaiting config.askAgent() unbounded, so a slow agent run can't
|
|
1255
|
+
// hold this MCP call open indefinitely. Settling in time keeps the
|
|
1256
|
+
// original response shape; timing out returns the same still-working
|
|
1257
|
+
// poll payload the A2A path would, using the same taskId contract
|
|
1258
|
+
// (see ask-app-inline-tasks.ts).
|
|
1259
|
+
const { startAskAppInlineTask } =
|
|
1260
|
+
await import("./ask-app-inline-tasks.js");
|
|
1261
|
+
const inline = await startAskAppInlineTask(
|
|
1262
|
+
config.askAgent,
|
|
1263
|
+
message,
|
|
1264
|
+
maxWaitMs,
|
|
1265
|
+
);
|
|
1266
|
+
if (inline.status === "completed") {
|
|
1267
|
+
return {
|
|
1268
|
+
app: selfId,
|
|
1269
|
+
routedVia: "local",
|
|
1270
|
+
...(note ? { note } : {}),
|
|
1271
|
+
response: inline.response || "(no response)",
|
|
1272
|
+
};
|
|
1273
|
+
}
|
|
1274
|
+
if (inline.status === "failed") {
|
|
1275
|
+
// Settled with an error inside the bounded wait — surface it the
|
|
1276
|
+
// same way the old unbounded `await config.askAgent(message)` did.
|
|
1277
|
+
throw new Error(inline.error || "ask_app task failed.");
|
|
1278
|
+
}
|
|
1279
|
+
return askAppInlineTaskResult(selfId, inline.taskId, inline, note);
|
|
1280
|
+
},
|
|
1281
|
+
};
|
|
1282
|
+
}
|
|
1283
|
+
|
|
1284
|
+
function askAppStatusTool(
|
|
1285
|
+
config: MCPConfig,
|
|
1286
|
+
requestMeta?: AskAppRequestMeta,
|
|
1287
|
+
): ActionEntry {
|
|
1288
|
+
return {
|
|
1289
|
+
tool: tool(
|
|
1290
|
+
"Poll a durable ask_app task and return its current status or final response. " +
|
|
1291
|
+
"If a transient status read stays unavailable after bounded retries, the " +
|
|
1292
|
+
"result preserves the app and taskId with statusRead 'unavailable' and a " +
|
|
1293
|
+
"poll instruction. Retry ask_app_status for that same task; never resubmit " +
|
|
1294
|
+
"ask_app as status-read recovery because that can duplicate work.",
|
|
1295
|
+
{
|
|
1296
|
+
app: {
|
|
1297
|
+
type: "string",
|
|
1298
|
+
description:
|
|
1299
|
+
"App id returned by ask_app. Optional for same-app local tasks.",
|
|
1300
|
+
},
|
|
1301
|
+
taskId: {
|
|
1302
|
+
type: "string",
|
|
1303
|
+
description: "The durable task id returned by ask_app.",
|
|
1304
|
+
},
|
|
1305
|
+
},
|
|
1306
|
+
["taskId"],
|
|
1307
|
+
),
|
|
1308
|
+
readOnly: true,
|
|
1309
|
+
parallelSafe: true,
|
|
1310
|
+
run: async (args: Record<string, any>) => {
|
|
1311
|
+
const taskId = String(args.taskId ?? "").trim();
|
|
1312
|
+
if (!taskId) throw new Error("ask_app_status requires 'taskId'.");
|
|
1313
|
+
|
|
1314
|
+
// The no-derivable-origin ask_app fallback tracks its tasks in a
|
|
1315
|
+
// process-local map, not the durable A2A store. Check it FIRST —
|
|
1316
|
+
// before any origin requirement — so a taskId minted by that fallback
|
|
1317
|
+
// never has to satisfy `resolveAskAppStatusRoute`'s "running app
|
|
1318
|
+
// origin" check. Falls through to the normal A2A route when the id
|
|
1319
|
+
// isn't one of these (never started here, evicted, or an ordinary A2A
|
|
1320
|
+
// task id).
|
|
1321
|
+
const { getAskAppInlineTask } = await import("./ask-app-inline-tasks.js");
|
|
1322
|
+
const inline = getAskAppInlineTask(taskId);
|
|
1323
|
+
if (inline) {
|
|
1324
|
+
return askAppInlineTaskResult(currentAppId(config), taskId, inline);
|
|
1325
|
+
}
|
|
1326
|
+
|
|
1327
|
+
const requestedApp = String(args.app ?? "").trim();
|
|
1328
|
+
const route = await resolveAskAppStatusRoute(
|
|
1329
|
+
config,
|
|
1330
|
+
requestedApp,
|
|
1331
|
+
requestMeta,
|
|
1332
|
+
);
|
|
1333
|
+
return fetchAskAppA2ATask(route, taskId);
|
|
1334
|
+
},
|
|
1335
|
+
};
|
|
1336
|
+
}
|
|
1337
|
+
|
|
1338
|
+
// ---------------------------------------------------------------------------
|
|
1339
|
+
// list_templates
|
|
1340
|
+
// ---------------------------------------------------------------------------
|
|
1341
|
+
|
|
1342
|
+
function listTemplatesTool(): ActionEntry {
|
|
1343
|
+
return {
|
|
1344
|
+
tool: tool(
|
|
1345
|
+
"List the first-party templates that can be scaffolded into a workspace " +
|
|
1346
|
+
"(allow-listed templates only).",
|
|
1347
|
+
),
|
|
1348
|
+
readOnly: true,
|
|
1349
|
+
parallelSafe: true,
|
|
1350
|
+
run: async () => {
|
|
1351
|
+
const { visibleTemplates } = await import("../cli/templates-meta.js");
|
|
1352
|
+
return {
|
|
1353
|
+
templates: visibleTemplates().map((t) => ({
|
|
1354
|
+
name: t.name,
|
|
1355
|
+
label: t.label,
|
|
1356
|
+
hint: t.hint,
|
|
1357
|
+
})),
|
|
1358
|
+
};
|
|
1359
|
+
},
|
|
1360
|
+
};
|
|
1361
|
+
}
|
|
1362
|
+
|
|
1363
|
+
// ---------------------------------------------------------------------------
|
|
1364
|
+
// create_workspace_app
|
|
1365
|
+
// ---------------------------------------------------------------------------
|
|
1366
|
+
|
|
1367
|
+
function createWorkspaceAppTool(): ActionEntry {
|
|
1368
|
+
return {
|
|
1369
|
+
tool: tool(
|
|
1370
|
+
"Scaffold a new app into the current workspace from an allow-listed " +
|
|
1371
|
+
"template, then return a deep link to open it. Idempotent: if an app " +
|
|
1372
|
+
"with that name already exists it is reused.",
|
|
1373
|
+
{
|
|
1374
|
+
name: {
|
|
1375
|
+
type: "string",
|
|
1376
|
+
description: "New app id (directory under apps/), e.g. 'mymail'",
|
|
1377
|
+
},
|
|
1378
|
+
template: {
|
|
1379
|
+
type: "string",
|
|
1380
|
+
description:
|
|
1381
|
+
"Template to scaffold from — must be allow-listed (see list_templates)",
|
|
1382
|
+
},
|
|
1383
|
+
},
|
|
1384
|
+
["name", "template"],
|
|
1385
|
+
),
|
|
1386
|
+
run: async (args: Record<string, any>) => {
|
|
1387
|
+
const name = String(args.name ?? "").trim();
|
|
1388
|
+
const template = String(args.template ?? "").trim();
|
|
1389
|
+
if (!name || !template) {
|
|
1390
|
+
throw new Error(
|
|
1391
|
+
"create_workspace_app requires both 'name' and 'template'.",
|
|
1392
|
+
);
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1395
|
+
// Enforce the strict public template allow-list. The authoritative,
|
|
1396
|
+
// dependency-free source inside @agent-native/core is cli/templates-meta
|
|
1397
|
+
// (kept in sync with packages/shared-app-config/templates.ts; CI guard).
|
|
1398
|
+
const { visibleTemplates } = await import("../cli/templates-meta.js");
|
|
1399
|
+
const allowed = new Set(visibleTemplates().map((t) => t.name));
|
|
1400
|
+
if (!allowed.has(template)) {
|
|
1401
|
+
throw new Error(
|
|
1402
|
+
`Template "${template}" is not allow-listed. Allowed: ${[...allowed]
|
|
1403
|
+
.sort()
|
|
1404
|
+
.join(", ")}`,
|
|
1405
|
+
);
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
const { findWorkspaceRoot, resolveWorkspace } =
|
|
1409
|
+
await import("./workspace-resolve.js");
|
|
1410
|
+
const fs = await import("node:fs");
|
|
1411
|
+
const path = await import("node:path");
|
|
1412
|
+
|
|
1413
|
+
const root = findWorkspaceRoot(process.cwd());
|
|
1414
|
+
if (!root) {
|
|
1415
|
+
throw new Error(
|
|
1416
|
+
"Not inside a workspace. create_workspace_app only works in a " +
|
|
1417
|
+
"multi-app workspace (run from the workspace root).",
|
|
1418
|
+
);
|
|
1419
|
+
}
|
|
1420
|
+
|
|
1421
|
+
const appDir = path.join(root, "apps", name);
|
|
1422
|
+
const alreadyExisted = fs.existsSync(appDir);
|
|
1423
|
+
|
|
1424
|
+
if (!alreadyExisted) {
|
|
1425
|
+
// Reuse the CLI scaffolder directly (no second `agent-native`
|
|
1426
|
+
// subprocess). `addAppToWorkspace(name, { template })` takes the
|
|
1427
|
+
// non-interactive single-template path when name + one template are
|
|
1428
|
+
// given. Run it from the workspace root so detectWorkspace resolves.
|
|
1429
|
+
const prevCwd = process.cwd();
|
|
1430
|
+
try {
|
|
1431
|
+
process.chdir(root);
|
|
1432
|
+
const { addAppToWorkspace } = await import("../cli/create.js");
|
|
1433
|
+
await addAppToWorkspace(name, { template, noInstall: true });
|
|
1434
|
+
} finally {
|
|
1435
|
+
try {
|
|
1436
|
+
process.chdir(prevCwd);
|
|
1437
|
+
} catch {
|
|
1438
|
+
// best-effort cwd restore
|
|
1439
|
+
}
|
|
1440
|
+
}
|
|
1441
|
+
}
|
|
1442
|
+
|
|
1443
|
+
// The workspace gateway auto-detects new apps/* dirs (fs.watch +
|
|
1444
|
+
// 2s sync) and lazily boots the dev server on first request, so we
|
|
1445
|
+
// don't spawn vite ourselves — opening the deep link warms it. Resolve
|
|
1446
|
+
// the port the gateway will use so we can report it.
|
|
1447
|
+
const ws = await resolveWorkspace(root);
|
|
1448
|
+
const appInfo = ws.apps.find((a) => a.id === name);
|
|
1449
|
+
const port = appInfo?.port;
|
|
1450
|
+
// The scaffolded app is always a *different* app from the host MCP
|
|
1451
|
+
// server, so anchor the deep link to the new app's own origin. A
|
|
1452
|
+
// relative path would otherwise be prefixed with the current request
|
|
1453
|
+
// origin and land on the wrong app. Fall back to the relative path
|
|
1454
|
+
// only if the gateway hasn't reported the new app's URL yet.
|
|
1455
|
+
const relDeepLink = buildDeepLink({ app: name, view: "home" });
|
|
1456
|
+
const deepLink = appInfo?.url
|
|
1457
|
+
? `${appInfo.url.replace(/\/+$/, "")}${relDeepLink}`
|
|
1458
|
+
: relDeepLink;
|
|
1459
|
+
|
|
1460
|
+
return {
|
|
1461
|
+
name,
|
|
1462
|
+
template,
|
|
1463
|
+
created: !alreadyExisted,
|
|
1464
|
+
reused: alreadyExisted,
|
|
1465
|
+
port,
|
|
1466
|
+
url: appInfo?.url,
|
|
1467
|
+
gatewayUrl: ws.gatewayUrl,
|
|
1468
|
+
deepLink,
|
|
1469
|
+
};
|
|
1470
|
+
},
|
|
1471
|
+
link: ({ result }) => {
|
|
1472
|
+
if (!result || typeof result !== "object") return null;
|
|
1473
|
+
const r = result as { deepLink?: string; name?: string };
|
|
1474
|
+
if (!r.deepLink) return null;
|
|
1475
|
+
return {
|
|
1476
|
+
url: r.deepLink,
|
|
1477
|
+
label: `Open ${r.name ?? "app"}`,
|
|
1478
|
+
view: "home",
|
|
1479
|
+
};
|
|
1480
|
+
},
|
|
1481
|
+
};
|
|
1482
|
+
}
|
|
1483
|
+
|
|
1484
|
+
// ---------------------------------------------------------------------------
|
|
1485
|
+
// Registry
|
|
1486
|
+
// ---------------------------------------------------------------------------
|
|
1487
|
+
|
|
1488
|
+
/**
|
|
1489
|
+
* Build the generic cross-app builtin tool registry. Called by
|
|
1490
|
+
* `createMCPServerForRequest`; the result is merged UNDER the config's
|
|
1491
|
+
* actions so template actions of the same name win.
|
|
1492
|
+
*/
|
|
1493
|
+
export function getBuiltinCrossAppTools(
|
|
1494
|
+
config: MCPConfig,
|
|
1495
|
+
requestMeta?: AskAppRequestMeta,
|
|
1496
|
+
): Record<string, ActionEntry> {
|
|
1497
|
+
return {
|
|
1498
|
+
list_apps: listAppsTool(config, requestMeta),
|
|
1499
|
+
open_app: openAppTool(config, requestMeta),
|
|
1500
|
+
create_embed_session: createEmbedSessionTool(requestMeta),
|
|
1501
|
+
ask_app: askAppTool(config, requestMeta),
|
|
1502
|
+
ask_app_status: askAppStatusTool(config, requestMeta),
|
|
1503
|
+
create_workspace_app: createWorkspaceAppTool(),
|
|
1504
|
+
list_templates: listTemplatesTool(),
|
|
1505
|
+
};
|
|
1506
|
+
}
|