@agent-native/core 0.7.13 → 0.7.15
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/README.md +56 -6
- package/dist/a2a/client.d.ts +44 -1
- package/dist/a2a/client.d.ts.map +1 -1
- package/dist/a2a/client.js +88 -11
- package/dist/a2a/client.js.map +1 -1
- package/dist/a2a/handlers.d.ts +10 -0
- package/dist/a2a/handlers.d.ts.map +1 -1
- package/dist/a2a/handlers.js +417 -67
- package/dist/a2a/handlers.js.map +1 -1
- package/dist/a2a/server.d.ts.map +1 -1
- package/dist/a2a/server.js +212 -19
- package/dist/a2a/server.js.map +1 -1
- package/dist/a2a/task-store.d.ts +20 -1
- package/dist/a2a/task-store.d.ts.map +1 -1
- package/dist/a2a/task-store.js +72 -2
- package/dist/a2a/task-store.js.map +1 -1
- package/dist/agent/default-model.d.ts +21 -0
- package/dist/agent/default-model.d.ts.map +1 -0
- package/dist/agent/default-model.js +21 -0
- package/dist/agent/default-model.js.map +1 -0
- package/dist/agent/engine/ai-sdk-engine.d.ts.map +1 -1
- package/dist/agent/engine/ai-sdk-engine.js +7 -4
- package/dist/agent/engine/ai-sdk-engine.js.map +1 -1
- package/dist/agent/engine/anthropic-engine.d.ts +1 -1
- package/dist/agent/engine/anthropic-engine.d.ts.map +1 -1
- package/dist/agent/engine/anthropic-engine.js +10 -4
- package/dist/agent/engine/anthropic-engine.js.map +1 -1
- package/dist/agent/engine/builder-engine.d.ts +1 -1
- package/dist/agent/engine/builder-engine.d.ts.map +1 -1
- package/dist/agent/engine/builder-engine.js +11 -26
- package/dist/agent/engine/builder-engine.js.map +1 -1
- package/dist/agent/engine/builtin.js +1 -1
- package/dist/agent/engine/builtin.js.map +1 -1
- package/dist/agent/engine/registry.d.ts +27 -7
- package/dist/agent/engine/registry.d.ts.map +1 -1
- package/dist/agent/engine/registry.js +101 -20
- package/dist/agent/engine/registry.js.map +1 -1
- package/dist/agent/index.d.ts +1 -0
- package/dist/agent/index.d.ts.map +1 -1
- package/dist/agent/index.js +1 -0
- package/dist/agent/index.js.map +1 -1
- package/dist/agent/production-agent.d.ts +25 -3
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +227 -36
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/application-state/handlers.d.ts.map +1 -1
- package/dist/application-state/handlers.js +10 -6
- package/dist/application-state/handlers.js.map +1 -1
- package/dist/application-state/script-helpers.d.ts +1 -1
- package/dist/application-state/script-helpers.d.ts.map +1 -1
- package/dist/application-state/script-helpers.js +12 -8
- package/dist/application-state/script-helpers.js.map +1 -1
- package/dist/application-state/store.d.ts.map +1 -1
- package/dist/application-state/store.js +19 -10
- package/dist/application-state/store.js.map +1 -1
- package/dist/chat-threads/store.d.ts +3 -0
- package/dist/chat-threads/store.d.ts.map +1 -1
- package/dist/chat-threads/store.js +36 -1
- package/dist/chat-threads/store.js.map +1 -1
- package/dist/cli/create.d.ts.map +1 -1
- package/dist/cli/create.js +79 -13
- package/dist/cli/create.js.map +1 -1
- package/dist/cli/index.js +97 -39
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/templates-meta.d.ts +4 -0
- package/dist/cli/templates-meta.d.ts.map +1 -1
- package/dist/cli/templates-meta.js +67 -12
- package/dist/cli/templates-meta.js.map +1 -1
- package/dist/cli/workspacify.d.ts +2 -0
- package/dist/cli/workspacify.d.ts.map +1 -1
- package/dist/cli/workspacify.js +5 -4
- package/dist/cli/workspacify.js.map +1 -1
- package/dist/client/AgentPanel.d.ts +7 -2
- package/dist/client/AgentPanel.d.ts.map +1 -1
- package/dist/client/AgentPanel.js +81 -32
- package/dist/client/AgentPanel.js.map +1 -1
- package/dist/client/AgentTaskCard.d.ts.map +1 -1
- package/dist/client/AgentTaskCard.js +5 -2
- package/dist/client/AgentTaskCard.js.map +1 -1
- package/dist/client/AssistantChat.d.ts +2 -0
- package/dist/client/AssistantChat.d.ts.map +1 -1
- package/dist/client/AssistantChat.js +183 -84
- package/dist/client/AssistantChat.js.map +1 -1
- package/dist/client/ConnectBuilderCard.d.ts.map +1 -1
- package/dist/client/ConnectBuilderCard.js +2 -1
- package/dist/client/ConnectBuilderCard.js.map +1 -1
- package/dist/client/DefaultSpinner.d.ts +1 -1
- package/dist/client/DefaultSpinner.d.ts.map +1 -1
- package/dist/client/DefaultSpinner.js +2 -9
- package/dist/client/DefaultSpinner.js.map +1 -1
- package/dist/client/ErrorBoundary.d.ts +1 -3
- package/dist/client/ErrorBoundary.d.ts.map +1 -1
- package/dist/client/ErrorBoundary.js +37 -9
- package/dist/client/ErrorBoundary.js.map +1 -1
- package/dist/client/FeedbackButton.d.ts.map +1 -1
- package/dist/client/FeedbackButton.js +4 -3
- package/dist/client/FeedbackButton.js.map +1 -1
- package/dist/client/MultiTabAssistantChat.d.ts.map +1 -1
- package/dist/client/MultiTabAssistantChat.js +165 -68
- package/dist/client/MultiTabAssistantChat.js.map +1 -1
- package/dist/client/agent-chat-adapter.d.ts.map +1 -1
- package/dist/client/agent-chat-adapter.js +2 -1
- package/dist/client/agent-chat-adapter.js.map +1 -1
- package/dist/client/agent-chat.d.ts +11 -0
- package/dist/client/agent-chat.d.ts.map +1 -1
- package/dist/client/agent-chat.js +4 -2
- package/dist/client/agent-chat.js.map +1 -1
- package/dist/client/analytics.d.ts.map +1 -1
- package/dist/client/analytics.js +70 -1
- package/dist/client/analytics.js.map +1 -1
- package/dist/client/api-path.d.ts +5 -0
- package/dist/client/api-path.d.ts.map +1 -0
- package/dist/client/api-path.js +48 -0
- package/dist/client/api-path.js.map +1 -0
- package/dist/client/components/AgentPresenceChip.d.ts +12 -0
- package/dist/client/components/AgentPresenceChip.d.ts.map +1 -0
- package/dist/client/components/AgentPresenceChip.js +42 -0
- package/dist/client/components/AgentPresenceChip.js.map +1 -0
- package/dist/client/components/ApiKeySettings.d.ts.map +1 -1
- package/dist/client/components/ApiKeySettings.js +3 -2
- package/dist/client/components/ApiKeySettings.js.map +1 -1
- package/dist/client/components/CodeRequiredDialog.d.ts.map +1 -1
- package/dist/client/components/CodeRequiredDialog.js +3 -2
- package/dist/client/components/CodeRequiredDialog.js.map +1 -1
- package/dist/client/components/PresenceBar.d.ts +17 -0
- package/dist/client/components/PresenceBar.d.ts.map +1 -0
- package/dist/client/components/PresenceBar.js +118 -0
- package/dist/client/components/PresenceBar.js.map +1 -0
- package/dist/client/composer/ComposerPlusMenu.d.ts +6 -1
- package/dist/client/composer/ComposerPlusMenu.d.ts.map +1 -1
- package/dist/client/composer/ComposerPlusMenu.js +22 -83
- package/dist/client/composer/ComposerPlusMenu.js.map +1 -1
- package/dist/client/composer/TiptapComposer.d.ts +3 -1
- package/dist/client/composer/TiptapComposer.d.ts.map +1 -1
- package/dist/client/composer/TiptapComposer.js +245 -23
- package/dist/client/composer/TiptapComposer.js.map +1 -1
- package/dist/client/composer/draft-key.d.ts +2 -0
- package/dist/client/composer/draft-key.d.ts.map +1 -0
- package/dist/client/composer/draft-key.js +8 -0
- package/dist/client/composer/draft-key.js.map +1 -0
- package/dist/client/composer/types.d.ts +1 -0
- package/dist/client/composer/types.d.ts.map +1 -1
- package/dist/client/composer/use-file-search.d.ts.map +1 -1
- package/dist/client/composer/use-file-search.js +2 -1
- package/dist/client/composer/use-file-search.js.map +1 -1
- package/dist/client/composer/use-mention-search.d.ts.map +1 -1
- package/dist/client/composer/use-mention-search.js +2 -1
- package/dist/client/composer/use-mention-search.js.map +1 -1
- package/dist/client/composer/use-skills.d.ts.map +1 -1
- package/dist/client/composer/use-skills.js +2 -1
- package/dist/client/composer/use-skills.js.map +1 -1
- package/dist/client/composer/useVoiceDictation.d.ts +3 -1
- package/dist/client/composer/useVoiceDictation.d.ts.map +1 -1
- package/dist/client/composer/useVoiceDictation.js +101 -18
- package/dist/client/composer/useVoiceDictation.js.map +1 -1
- package/dist/client/dev-mode.d.ts +14 -0
- package/dist/client/dev-mode.d.ts.map +1 -0
- package/dist/client/dev-mode.js +14 -0
- package/dist/client/dev-mode.js.map +1 -0
- package/dist/client/dev-overlay/DevOverlay.d.ts +26 -0
- package/dist/client/dev-overlay/DevOverlay.d.ts.map +1 -0
- package/dist/client/dev-overlay/DevOverlay.js +315 -0
- package/dist/client/dev-overlay/DevOverlay.js.map +1 -0
- package/dist/client/dev-overlay/builtins.d.ts +6 -0
- package/dist/client/dev-overlay/builtins.d.ts.map +1 -0
- package/dist/client/dev-overlay/builtins.js +35 -0
- package/dist/client/dev-overlay/builtins.js.map +1 -0
- package/dist/client/dev-overlay/index.d.ts +6 -0
- package/dist/client/dev-overlay/index.d.ts.map +1 -0
- package/dist/client/dev-overlay/index.js +5 -0
- package/dist/client/dev-overlay/index.js.map +1 -0
- package/dist/client/dev-overlay/registry.d.ts +13 -0
- package/dist/client/dev-overlay/registry.d.ts.map +1 -0
- package/dist/client/dev-overlay/registry.js +63 -0
- package/dist/client/dev-overlay/registry.js.map +1 -0
- package/dist/client/dev-overlay/types.d.ts +56 -0
- package/dist/client/dev-overlay/types.d.ts.map +1 -0
- package/dist/client/dev-overlay/types.js +9 -0
- package/dist/client/dev-overlay/types.js.map +1 -0
- package/dist/client/dev-overlay/use-dev-option.d.ts +12 -0
- package/dist/client/dev-overlay/use-dev-option.d.ts.map +1 -0
- package/dist/client/dev-overlay/use-dev-option.js +73 -0
- package/dist/client/dev-overlay/use-dev-option.js.map +1 -0
- package/dist/client/dev-overlay/use-dev-overlay-shortcut.d.ts +6 -0
- package/dist/client/dev-overlay/use-dev-overlay-shortcut.d.ts.map +1 -0
- package/dist/client/dev-overlay/use-dev-overlay-shortcut.js +29 -0
- package/dist/client/dev-overlay/use-dev-overlay-shortcut.js.map +1 -0
- package/dist/client/frame.d.ts +1 -0
- package/dist/client/frame.d.ts.map +1 -1
- package/dist/client/frame.js +32 -11
- package/dist/client/frame.js.map +1 -1
- package/dist/client/index.d.ts +7 -0
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +9 -0
- package/dist/client/index.js.map +1 -1
- package/dist/client/integrations/IntegrationCard.d.ts.map +1 -1
- package/dist/client/integrations/IntegrationCard.js +3 -2
- package/dist/client/integrations/IntegrationCard.js.map +1 -1
- package/dist/client/integrations/IntegrationsPanel.d.ts.map +1 -1
- package/dist/client/integrations/IntegrationsPanel.js +3 -2
- package/dist/client/integrations/IntegrationsPanel.js.map +1 -1
- package/dist/client/integrations/useIntegrationStatus.d.ts.map +1 -1
- package/dist/client/integrations/useIntegrationStatus.js +2 -1
- package/dist/client/integrations/useIntegrationStatus.js.map +1 -1
- package/dist/client/notifications/NotificationsBell.d.ts.map +1 -1
- package/dist/client/notifications/NotificationsBell.js +26 -8
- package/dist/client/notifications/NotificationsBell.js.map +1 -1
- package/dist/client/observability/ThumbsFeedback.d.ts.map +1 -1
- package/dist/client/observability/ThumbsFeedback.js +2 -1
- package/dist/client/observability/ThumbsFeedback.js.map +1 -1
- package/dist/client/observability/useObservability.d.ts.map +1 -1
- package/dist/client/observability/useObservability.js +2 -1
- package/dist/client/observability/useObservability.js.map +1 -1
- package/dist/client/onboarding/OnboardingPanel.d.ts +0 -7
- package/dist/client/onboarding/OnboardingPanel.d.ts.map +1 -1
- package/dist/client/onboarding/OnboardingPanel.js +20 -10
- package/dist/client/onboarding/OnboardingPanel.js.map +1 -1
- package/dist/client/onboarding/index.d.ts +1 -0
- package/dist/client/onboarding/index.d.ts.map +1 -1
- package/dist/client/onboarding/index.js +1 -0
- package/dist/client/onboarding/index.js.map +1 -1
- package/dist/client/onboarding/use-onboarding.d.ts +1 -7
- package/dist/client/onboarding/use-onboarding.d.ts.map +1 -1
- package/dist/client/onboarding/use-onboarding.js +27 -13
- package/dist/client/onboarding/use-onboarding.js.map +1 -1
- package/dist/client/onboarding/use-preview-mode.d.ts +10 -0
- package/dist/client/onboarding/use-preview-mode.d.ts.map +1 -0
- package/dist/client/onboarding/use-preview-mode.js +35 -0
- package/dist/client/onboarding/use-preview-mode.js.map +1 -0
- package/dist/client/org/OrgSwitcher.d.ts.map +1 -1
- package/dist/client/org/OrgSwitcher.js +2 -1
- package/dist/client/org/OrgSwitcher.js.map +1 -1
- package/dist/client/org/RequireActiveOrg.d.ts.map +1 -1
- package/dist/client/org/RequireActiveOrg.js +15 -10
- package/dist/client/org/RequireActiveOrg.js.map +1 -1
- package/dist/client/org/TeamPage.d.ts.map +1 -1
- package/dist/client/org/TeamPage.js +132 -9
- package/dist/client/org/TeamPage.js.map +1 -1
- package/dist/client/org/hooks.d.ts +30 -0
- package/dist/client/org/hooks.d.ts.map +1 -1
- package/dist/client/org/hooks.js +67 -1
- package/dist/client/org/hooks.js.map +1 -1
- package/dist/client/org/index.d.ts +2 -2
- package/dist/client/org/index.d.ts.map +1 -1
- package/dist/client/org/index.js +1 -1
- package/dist/client/org/index.js.map +1 -1
- package/dist/client/progress/RunsTray.d.ts.map +1 -1
- package/dist/client/progress/RunsTray.js +2 -1
- package/dist/client/progress/RunsTray.js.map +1 -1
- package/dist/client/resources/McpServerDetail.d.ts +0 -8
- package/dist/client/resources/McpServerDetail.d.ts.map +1 -1
- package/dist/client/resources/McpServerDetail.js +6 -1
- package/dist/client/resources/McpServerDetail.js.map +1 -1
- package/dist/client/resources/ResourceEditor.d.ts.map +1 -1
- package/dist/client/resources/ResourceEditor.js +2 -1
- package/dist/client/resources/ResourceEditor.js.map +1 -1
- package/dist/client/resources/ResourcesPanel.d.ts.map +1 -1
- package/dist/client/resources/ResourcesPanel.js +7 -2
- package/dist/client/resources/ResourcesPanel.js.map +1 -1
- package/dist/client/resources/use-mcp-servers.d.ts.map +1 -1
- package/dist/client/resources/use-mcp-servers.js +7 -2
- package/dist/client/resources/use-mcp-servers.js.map +1 -1
- package/dist/client/resources/use-resources.d.ts.map +1 -1
- package/dist/client/resources/use-resources.js +9 -7
- package/dist/client/resources/use-resources.js.map +1 -1
- package/dist/client/settings/AgentsSection.d.ts.map +1 -1
- package/dist/client/settings/AgentsSection.js +7 -5
- package/dist/client/settings/AgentsSection.js.map +1 -1
- package/dist/client/settings/AutomationsSection.d.ts.map +1 -1
- package/dist/client/settings/AutomationsSection.js +10 -5
- package/dist/client/settings/AutomationsSection.js.map +1 -1
- package/dist/client/settings/BackgroundAgentSection.d.ts.map +1 -1
- package/dist/client/settings/BackgroundAgentSection.js +2 -1
- package/dist/client/settings/BackgroundAgentSection.js.map +1 -1
- package/dist/client/settings/SecretsSection.d.ts.map +1 -1
- package/dist/client/settings/SecretsSection.js +12 -4
- package/dist/client/settings/SecretsSection.js.map +1 -1
- package/dist/client/settings/SettingsPanel.d.ts.map +1 -1
- package/dist/client/settings/SettingsPanel.js +38 -33
- package/dist/client/settings/SettingsPanel.js.map +1 -1
- package/dist/client/settings/UsageSection.d.ts.map +1 -1
- package/dist/client/settings/UsageSection.js +2 -1
- package/dist/client/settings/UsageSection.js.map +1 -1
- package/dist/client/settings/VoiceTranscriptionSection.d.ts +2 -4
- package/dist/client/settings/VoiceTranscriptionSection.d.ts.map +1 -1
- package/dist/client/settings/VoiceTranscriptionSection.js +66 -23
- package/dist/client/settings/VoiceTranscriptionSection.js.map +1 -1
- package/dist/client/settings/useBuilderStatus.d.ts +9 -0
- package/dist/client/settings/useBuilderStatus.d.ts.map +1 -1
- package/dist/client/settings/useBuilderStatus.js +31 -3
- package/dist/client/settings/useBuilderStatus.js.map +1 -1
- package/dist/client/sharing/ShareButton.d.ts.map +1 -1
- package/dist/client/sharing/ShareButton.js +7 -2
- package/dist/client/sharing/ShareButton.js.map +1 -1
- package/dist/client/sharing/ShareDialog.d.ts.map +1 -1
- package/dist/client/sharing/ShareDialog.js +4 -3
- package/dist/client/sharing/ShareDialog.js.map +1 -1
- package/dist/client/sse-event-processor.d.ts.map +1 -1
- package/dist/client/sse-event-processor.js +10 -0
- package/dist/client/sse-event-processor.js.map +1 -1
- package/dist/client/terminal/AgentTerminal.d.ts +1 -0
- package/dist/client/terminal/AgentTerminal.d.ts.map +1 -1
- package/dist/client/terminal/AgentTerminal.js +12 -8
- package/dist/client/terminal/AgentTerminal.js.map +1 -1
- package/dist/client/tools/EmbeddedTool.d.ts +20 -0
- package/dist/client/tools/EmbeddedTool.d.ts.map +1 -0
- package/dist/client/tools/EmbeddedTool.js +113 -0
- package/dist/client/tools/EmbeddedTool.js.map +1 -0
- package/dist/client/tools/ExtensionSlot.d.ts +27 -0
- package/dist/client/tools/ExtensionSlot.d.ts.map +1 -0
- package/dist/client/tools/ExtensionSlot.js +96 -0
- package/dist/client/tools/ExtensionSlot.js.map +1 -0
- package/dist/client/tools/ToolEditor.d.ts +5 -0
- package/dist/client/tools/ToolEditor.d.ts.map +1 -0
- package/dist/client/tools/ToolEditor.js +99 -0
- package/dist/client/tools/ToolEditor.js.map +1 -0
- package/dist/client/tools/ToolViewer.d.ts +5 -0
- package/dist/client/tools/ToolViewer.d.ts.map +1 -0
- package/dist/client/tools/ToolViewer.js +275 -0
- package/dist/client/tools/ToolViewer.js.map +1 -0
- package/dist/client/tools/ToolViewerPage.d.ts +2 -0
- package/dist/client/tools/ToolViewerPage.d.ts.map +1 -0
- package/dist/client/tools/ToolViewerPage.js +24 -0
- package/dist/client/tools/ToolViewerPage.js.map +1 -0
- package/dist/client/tools/ToolsListPage.d.ts +2 -0
- package/dist/client/tools/ToolsListPage.d.ts.map +1 -0
- package/dist/client/tools/ToolsListPage.js +73 -0
- package/dist/client/tools/ToolsListPage.js.map +1 -0
- package/dist/client/tools/ToolsSidebarSection.d.ts +2 -0
- package/dist/client/tools/ToolsSidebarSection.d.ts.map +1 -0
- package/dist/client/tools/ToolsSidebarSection.js +189 -0
- package/dist/client/tools/ToolsSidebarSection.js.map +1 -0
- package/dist/client/tools/iframe-bridge.d.ts +16 -0
- package/dist/client/tools/iframe-bridge.d.ts.map +1 -0
- package/dist/client/tools/iframe-bridge.js +118 -0
- package/dist/client/tools/iframe-bridge.js.map +1 -0
- package/dist/client/tools/index.d.ts +8 -0
- package/dist/client/tools/index.d.ts.map +1 -0
- package/dist/client/tools/index.js +8 -0
- package/dist/client/tools/index.js.map +1 -0
- package/dist/client/use-action.d.ts.map +1 -1
- package/dist/client/use-action.js +2 -1
- package/dist/client/use-action.js.map +1 -1
- package/dist/client/use-avatar.d.ts.map +1 -1
- package/dist/client/use-avatar.js +3 -2
- package/dist/client/use-avatar.js.map +1 -1
- package/dist/client/use-builder-enabled.d.ts.map +1 -1
- package/dist/client/use-builder-enabled.js +2 -1
- package/dist/client/use-builder-enabled.js.map +1 -1
- package/dist/client/use-chat-threads.d.ts +1 -0
- package/dist/client/use-chat-threads.d.ts.map +1 -1
- package/dist/client/use-chat-threads.js +31 -1
- package/dist/client/use-chat-threads.js.map +1 -1
- package/dist/client/use-db-sync.d.ts.map +1 -1
- package/dist/client/use-db-sync.js +9 -8
- package/dist/client/use-db-sync.js.map +1 -1
- package/dist/client/use-dev-mode.d.ts.map +1 -1
- package/dist/client/use-dev-mode.js +2 -1
- package/dist/client/use-dev-mode.js.map +1 -1
- package/dist/client/use-send-to-agent-chat.d.ts.map +1 -1
- package/dist/client/use-send-to-agent-chat.js +3 -1
- package/dist/client/use-send-to-agent-chat.js.map +1 -1
- package/dist/client/use-session.d.ts.map +1 -1
- package/dist/client/use-session.js +2 -1
- package/dist/client/use-session.js.map +1 -1
- package/dist/client/useProductionAgent.d.ts.map +1 -1
- package/dist/client/useProductionAgent.js +2 -1
- package/dist/client/useProductionAgent.js.map +1 -1
- package/dist/collab/agent-identity.d.ts +15 -0
- package/dist/collab/agent-identity.d.ts.map +1 -0
- package/dist/collab/agent-identity.js +14 -0
- package/dist/collab/agent-identity.js.map +1 -0
- package/dist/collab/agent-presence.d.ts +59 -0
- package/dist/collab/agent-presence.d.ts.map +1 -0
- package/dist/collab/agent-presence.js +165 -0
- package/dist/collab/agent-presence.js.map +1 -0
- package/dist/collab/awareness.d.ts +7 -0
- package/dist/collab/awareness.d.ts.map +1 -1
- package/dist/collab/awareness.js +2 -2
- package/dist/collab/awareness.js.map +1 -1
- package/dist/collab/client-struct.d.ts +43 -0
- package/dist/collab/client-struct.d.ts.map +1 -0
- package/dist/collab/client-struct.js +272 -0
- package/dist/collab/client-struct.js.map +1 -0
- package/dist/collab/client.d.ts +2 -0
- package/dist/collab/client.d.ts.map +1 -1
- package/dist/collab/client.js +18 -3
- package/dist/collab/client.js.map +1 -1
- package/dist/collab/index.d.ts +6 -1
- package/dist/collab/index.d.ts.map +1 -1
- package/dist/collab/index.js +11 -1
- package/dist/collab/index.js.map +1 -1
- package/dist/collab/json-to-yjs.d.ts +72 -0
- package/dist/collab/json-to-yjs.d.ts.map +1 -0
- package/dist/collab/json-to-yjs.js +456 -0
- package/dist/collab/json-to-yjs.js.map +1 -0
- package/dist/collab/struct-routes.d.ts +52 -0
- package/dist/collab/struct-routes.d.ts.map +1 -0
- package/dist/collab/struct-routes.js +74 -0
- package/dist/collab/struct-routes.js.map +1 -0
- package/dist/collab/ydoc-manager.d.ts +19 -0
- package/dist/collab/ydoc-manager.d.ts.map +1 -1
- package/dist/collab/ydoc-manager.js +49 -0
- package/dist/collab/ydoc-manager.js.map +1 -1
- package/dist/credentials/index.d.ts +27 -10
- package/dist/credentials/index.d.ts.map +1 -1
- package/dist/credentials/index.js +61 -19
- package/dist/credentials/index.js.map +1 -1
- package/dist/db/client.d.ts.map +1 -1
- package/dist/db/client.js +10 -1
- package/dist/db/client.js.map +1 -1
- package/dist/db/migrations.d.ts +13 -5
- package/dist/db/migrations.d.ts.map +1 -1
- package/dist/db/migrations.js +9 -2
- package/dist/db/migrations.js.map +1 -1
- package/dist/deploy/build.d.ts +12 -1
- package/dist/deploy/build.d.ts.map +1 -1
- package/dist/deploy/build.js +196 -24
- package/dist/deploy/build.js.map +1 -1
- package/dist/file-upload/builder.d.ts.map +1 -1
- package/dist/file-upload/builder.js +2 -1
- package/dist/file-upload/builder.js.map +1 -1
- package/dist/file-upload/registry.d.ts.map +1 -1
- package/dist/file-upload/registry.js +25 -1
- package/dist/file-upload/registry.js.map +1 -1
- 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/adapters/email.d.ts +17 -0
- package/dist/integrations/adapters/email.d.ts.map +1 -0
- package/dist/integrations/adapters/email.js +740 -0
- package/dist/integrations/adapters/email.js.map +1 -0
- package/dist/integrations/adapters/slack.d.ts.map +1 -1
- package/dist/integrations/adapters/slack.js +190 -32
- package/dist/integrations/adapters/slack.js.map +1 -1
- package/dist/integrations/adapters/telegram.d.ts.map +1 -1
- package/dist/integrations/adapters/telegram.js +56 -5
- package/dist/integrations/adapters/telegram.js.map +1 -1
- package/dist/integrations/adapters/whatsapp.d.ts.map +1 -1
- package/dist/integrations/adapters/whatsapp.js +91 -12
- package/dist/integrations/adapters/whatsapp.js.map +1 -1
- package/dist/integrations/google-docs-poller.d.ts.map +1 -1
- package/dist/integrations/google-docs-poller.js +5 -2
- package/dist/integrations/google-docs-poller.js.map +1 -1
- package/dist/integrations/index.d.ts +1 -0
- package/dist/integrations/index.d.ts.map +1 -1
- package/dist/integrations/index.js +1 -0
- package/dist/integrations/index.js.map +1 -1
- package/dist/integrations/internal-token.d.ts +18 -0
- package/dist/integrations/internal-token.d.ts.map +1 -0
- package/dist/integrations/internal-token.js +102 -0
- package/dist/integrations/internal-token.js.map +1 -0
- package/dist/integrations/pending-tasks-retry-job.d.ts +15 -0
- package/dist/integrations/pending-tasks-retry-job.d.ts.map +1 -0
- package/dist/integrations/pending-tasks-retry-job.js +210 -0
- package/dist/integrations/pending-tasks-retry-job.js.map +1 -0
- package/dist/integrations/pending-tasks-store.d.ts +56 -0
- package/dist/integrations/pending-tasks-store.d.ts.map +1 -0
- package/dist/integrations/pending-tasks-store.js +204 -0
- package/dist/integrations/pending-tasks-store.js.map +1 -0
- package/dist/integrations/plugin.d.ts.map +1 -1
- package/dist/integrations/plugin.js +340 -15
- package/dist/integrations/plugin.js.map +1 -1
- package/dist/integrations/task-queue-stats.d.ts +22 -0
- package/dist/integrations/task-queue-stats.d.ts.map +1 -0
- package/dist/integrations/task-queue-stats.js +117 -0
- package/dist/integrations/task-queue-stats.js.map +1 -0
- package/dist/integrations/types.d.ts +35 -2
- package/dist/integrations/types.d.ts.map +1 -1
- package/dist/integrations/webhook-handler.d.ts +29 -4
- package/dist/integrations/webhook-handler.d.ts.map +1 -1
- package/dist/integrations/webhook-handler.js +323 -85
- package/dist/integrations/webhook-handler.js.map +1 -1
- package/dist/jobs/cron.d.ts.map +1 -1
- package/dist/jobs/cron.js +12 -4
- package/dist/jobs/cron.js.map +1 -1
- package/dist/jobs/scheduler.d.ts.map +1 -1
- package/dist/jobs/scheduler.js +141 -16
- package/dist/jobs/scheduler.js.map +1 -1
- package/dist/jobs/tools.d.ts.map +1 -1
- package/dist/jobs/tools.js +94 -3
- package/dist/jobs/tools.js.map +1 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +128 -62
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp-client/hub-routes.d.ts +14 -0
- package/dist/mcp-client/hub-routes.d.ts.map +1 -1
- package/dist/mcp-client/hub-routes.js +42 -2
- package/dist/mcp-client/hub-routes.js.map +1 -1
- package/dist/mcp-client/index.d.ts +1 -1
- package/dist/mcp-client/index.d.ts.map +1 -1
- package/dist/mcp-client/index.js +1 -1
- package/dist/mcp-client/index.js.map +1 -1
- package/dist/mcp-client/manager.d.ts +3 -0
- package/dist/mcp-client/manager.d.ts.map +1 -1
- package/dist/mcp-client/manager.js +33 -3
- package/dist/mcp-client/manager.js.map +1 -1
- package/dist/mcp-client/remote-store.d.ts +49 -1
- package/dist/mcp-client/remote-store.d.ts.map +1 -1
- package/dist/mcp-client/remote-store.js +253 -6
- package/dist/mcp-client/remote-store.js.map +1 -1
- package/dist/mcp-client/routes.d.ts.map +1 -1
- package/dist/mcp-client/routes.js +11 -9
- package/dist/mcp-client/routes.js.map +1 -1
- package/dist/mcp-client/visibility.d.ts +7 -3
- package/dist/mcp-client/visibility.d.ts.map +1 -1
- package/dist/mcp-client/visibility.js +16 -7
- package/dist/mcp-client/visibility.js.map +1 -1
- package/dist/notifications/actions.d.ts.map +1 -1
- package/dist/notifications/actions.js +7 -1
- package/dist/notifications/actions.js.map +1 -1
- package/dist/notifications/routes.d.ts +1 -1
- package/dist/notifications/routes.d.ts.map +1 -1
- package/dist/notifications/routes.js +20 -3
- package/dist/notifications/routes.js.map +1 -1
- package/dist/notifications/store.d.ts.map +1 -1
- package/dist/notifications/store.js +6 -1
- package/dist/notifications/store.js.map +1 -1
- package/dist/oauth-tokens/google-refresh.d.ts.map +1 -1
- package/dist/oauth-tokens/google-refresh.js +6 -0
- package/dist/oauth-tokens/google-refresh.js.map +1 -1
- package/dist/oauth-tokens/store.d.ts +43 -2
- package/dist/oauth-tokens/store.d.ts.map +1 -1
- package/dist/oauth-tokens/store.js +83 -14
- package/dist/oauth-tokens/store.js.map +1 -1
- package/dist/observability/experiments.js +5 -5
- package/dist/observability/experiments.js.map +1 -1
- package/dist/observability/routes.d.ts.map +1 -1
- package/dist/observability/routes.js +37 -8
- package/dist/observability/routes.js.map +1 -1
- package/dist/observability/store.d.ts.map +1 -1
- package/dist/observability/store.js +19 -3
- package/dist/observability/store.js.map +1 -1
- package/dist/observability/types.d.ts +7 -0
- package/dist/observability/types.d.ts.map +1 -1
- package/dist/observability/types.js.map +1 -1
- package/dist/onboarding/default-steps.d.ts.map +1 -1
- package/dist/onboarding/default-steps.js +10 -4
- package/dist/onboarding/default-steps.js.map +1 -1
- package/dist/onboarding/plugin.d.ts.map +1 -1
- package/dist/onboarding/plugin.js +63 -32
- package/dist/onboarding/plugin.js.map +1 -1
- package/dist/onboarding/types.d.ts +6 -1
- package/dist/onboarding/types.d.ts.map +1 -1
- package/dist/org/accept-pending.d.ts.map +1 -1
- package/dist/org/accept-pending.js +2 -1
- package/dist/org/accept-pending.js.map +1 -1
- package/dist/org/context.d.ts +35 -0
- package/dist/org/context.d.ts.map +1 -1
- package/dist/org/context.js +136 -0
- package/dist/org/context.js.map +1 -1
- package/dist/org/handlers.d.ts +76 -0
- package/dist/org/handlers.d.ts.map +1 -1
- package/dist/org/handlers.js +411 -2
- package/dist/org/handlers.js.map +1 -1
- package/dist/org/index.d.ts +2 -2
- package/dist/org/index.d.ts.map +1 -1
- package/dist/org/index.js +2 -2
- package/dist/org/index.js.map +1 -1
- package/dist/org/migrations.d.ts.map +1 -1
- package/dist/org/migrations.js +8 -0
- package/dist/org/migrations.js.map +1 -1
- package/dist/org/plugin.d.ts +6 -0
- package/dist/org/plugin.d.ts.map +1 -1
- package/dist/org/plugin.js +71 -7
- package/dist/org/plugin.js.map +1 -1
- package/dist/org/schema.d.ts +38 -0
- package/dist/org/schema.d.ts.map +1 -1
- package/dist/org/schema.js +2 -0
- package/dist/org/schema.js.map +1 -1
- package/dist/org/types.d.ts +7 -0
- package/dist/org/types.d.ts.map +1 -1
- package/dist/progress/actions.d.ts.map +1 -1
- package/dist/progress/actions.js +10 -1
- package/dist/progress/actions.js.map +1 -1
- package/dist/progress/routes.d.ts +1 -1
- package/dist/progress/routes.d.ts.map +1 -1
- package/dist/progress/routes.js +20 -3
- package/dist/progress/routes.js.map +1 -1
- package/dist/progress/store.d.ts.map +1 -1
- package/dist/progress/store.js +6 -1
- package/dist/progress/store.js.map +1 -1
- package/dist/resources/handlers.d.ts.map +1 -1
- package/dist/resources/handlers.js +35 -7
- package/dist/resources/handlers.js.map +1 -1
- package/dist/resources/script-helpers.d.ts.map +1 -1
- package/dist/resources/script-helpers.js +15 -3
- package/dist/resources/script-helpers.js.map +1 -1
- package/dist/resources/store.d.ts.map +1 -1
- package/dist/resources/store.js +12 -4
- package/dist/resources/store.js.map +1 -1
- package/dist/scripts/call-agent.d.ts +1 -0
- package/dist/scripts/call-agent.d.ts.map +1 -1
- package/dist/scripts/call-agent.js +146 -36
- package/dist/scripts/call-agent.js.map +1 -1
- package/dist/scripts/chat/search-chats.d.ts.map +1 -1
- package/dist/scripts/chat/search-chats.js +3 -2
- package/dist/scripts/chat/search-chats.js.map +1 -1
- package/dist/scripts/db/exec.d.ts +1 -1
- package/dist/scripts/db/exec.d.ts.map +1 -1
- package/dist/scripts/db/exec.js +22 -3
- package/dist/scripts/db/exec.js.map +1 -1
- package/dist/scripts/db/index.d.ts.map +1 -1
- package/dist/scripts/db/index.js +2 -0
- package/dist/scripts/db/index.js.map +1 -1
- package/dist/scripts/db/migrate-user-api-keys.d.ts +24 -0
- package/dist/scripts/db/migrate-user-api-keys.d.ts.map +1 -0
- package/dist/scripts/db/migrate-user-api-keys.js +234 -0
- package/dist/scripts/db/migrate-user-api-keys.js.map +1 -0
- package/dist/scripts/db/query.d.ts +1 -1
- package/dist/scripts/db/query.d.ts.map +1 -1
- package/dist/scripts/db/query.js +22 -3
- package/dist/scripts/db/query.js.map +1 -1
- package/dist/scripts/db/scoping.d.ts.map +1 -1
- package/dist/scripts/db/scoping.js +15 -9
- package/dist/scripts/db/scoping.js.map +1 -1
- package/dist/scripts/db/wipe-leaked-builder-keys.d.ts +27 -0
- package/dist/scripts/db/wipe-leaked-builder-keys.d.ts.map +1 -0
- package/dist/scripts/db/wipe-leaked-builder-keys.js +163 -0
- package/dist/scripts/db/wipe-leaked-builder-keys.js.map +1 -0
- package/dist/scripts/dev/shell.d.ts.map +1 -1
- package/dist/scripts/dev/shell.js +3 -1
- package/dist/scripts/dev/shell.js.map +1 -1
- package/dist/scripts/resources/delete-memory.d.ts.map +1 -1
- package/dist/scripts/resources/delete-memory.js +2 -1
- package/dist/scripts/resources/delete-memory.js.map +1 -1
- package/dist/scripts/resources/delete.d.ts.map +1 -1
- package/dist/scripts/resources/delete.js +2 -1
- package/dist/scripts/resources/delete.js.map +1 -1
- package/dist/scripts/resources/list.d.ts.map +1 -1
- package/dist/scripts/resources/list.js +2 -1
- package/dist/scripts/resources/list.js.map +1 -1
- package/dist/scripts/resources/migrate-learnings.d.ts.map +1 -1
- package/dist/scripts/resources/migrate-learnings.js +2 -1
- package/dist/scripts/resources/migrate-learnings.js.map +1 -1
- package/dist/scripts/resources/read.d.ts.map +1 -1
- package/dist/scripts/resources/read.js +2 -1
- package/dist/scripts/resources/read.js.map +1 -1
- package/dist/scripts/resources/save-memory.d.ts.map +1 -1
- package/dist/scripts/resources/save-memory.js +2 -1
- package/dist/scripts/resources/save-memory.js.map +1 -1
- package/dist/scripts/resources/write.d.ts.map +1 -1
- package/dist/scripts/resources/write.js +2 -1
- package/dist/scripts/resources/write.js.map +1 -1
- package/dist/secrets/onboarding.d.ts.map +1 -1
- package/dist/secrets/onboarding.js +24 -16
- package/dist/secrets/onboarding.js.map +1 -1
- package/dist/secrets/register-framework-secrets.d.ts +5 -0
- package/dist/secrets/register-framework-secrets.d.ts.map +1 -1
- package/dist/secrets/register-framework-secrets.js +7 -44
- package/dist/secrets/register-framework-secrets.js.map +1 -1
- package/dist/secrets/routes.d.ts.map +1 -1
- package/dist/secrets/routes.js +139 -37
- package/dist/secrets/routes.js.map +1 -1
- package/dist/secrets/storage.d.ts.map +1 -1
- package/dist/secrets/storage.js +23 -12
- package/dist/secrets/storage.js.map +1 -1
- package/dist/secrets/substitution.d.ts +24 -2
- package/dist/secrets/substitution.d.ts.map +1 -1
- package/dist/secrets/substitution.js +58 -8
- package/dist/secrets/substitution.js.map +1 -1
- package/dist/server/action-discovery.d.ts.map +1 -1
- package/dist/server/action-discovery.js +54 -51
- package/dist/server/action-discovery.js.map +1 -1
- package/dist/server/action-routes.d.ts.map +1 -1
- package/dist/server/action-routes.js +42 -15
- package/dist/server/action-routes.js.map +1 -1
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +632 -373
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/server/agent-discovery.d.ts +8 -0
- package/dist/server/agent-discovery.d.ts.map +1 -1
- package/dist/server/agent-discovery.js +39 -12
- package/dist/server/agent-discovery.js.map +1 -1
- package/dist/server/agent-teams.d.ts.map +1 -1
- package/dist/server/agent-teams.js +4 -1
- package/dist/server/agent-teams.js.map +1 -1
- package/dist/server/analytics.d.ts +0 -1
- package/dist/server/analytics.d.ts.map +1 -1
- package/dist/server/analytics.js +0 -1
- package/dist/server/analytics.js.map +1 -1
- package/dist/server/app-base-path.d.ts +4 -0
- package/dist/server/app-base-path.d.ts.map +1 -0
- package/dist/server/app-base-path.js +33 -0
- package/dist/server/app-base-path.js.map +1 -0
- package/dist/server/auth.d.ts +29 -0
- package/dist/server/auth.d.ts.map +1 -1
- package/dist/server/auth.js +629 -82
- package/dist/server/auth.js.map +1 -1
- package/dist/server/better-auth-instance.d.ts +1 -0
- package/dist/server/better-auth-instance.d.ts.map +1 -1
- package/dist/server/better-auth-instance.js +67 -15
- package/dist/server/better-auth-instance.js.map +1 -1
- package/dist/server/builder-browser.d.ts +16 -1
- package/dist/server/builder-browser.d.ts.map +1 -1
- package/dist/server/builder-browser.js +102 -16
- package/dist/server/builder-browser.js.map +1 -1
- package/dist/server/cli-capture.d.ts +31 -0
- package/dist/server/cli-capture.d.ts.map +1 -0
- package/dist/server/cli-capture.js +120 -0
- package/dist/server/cli-capture.js.map +1 -0
- package/dist/server/collab-plugin.d.ts +16 -0
- package/dist/server/collab-plugin.d.ts.map +1 -1
- package/dist/server/collab-plugin.js +87 -19
- package/dist/server/collab-plugin.js.map +1 -1
- package/dist/server/core-routes-plugin.d.ts.map +1 -1
- package/dist/server/core-routes-plugin.js +499 -164
- package/dist/server/core-routes-plugin.js.map +1 -1
- package/dist/server/create-server.d.ts +2 -0
- package/dist/server/create-server.d.ts.map +1 -1
- package/dist/server/create-server.js +82 -11
- package/dist/server/create-server.js.map +1 -1
- package/dist/server/credential-provider.d.ts +54 -2
- package/dist/server/credential-provider.d.ts.map +1 -1
- package/dist/server/credential-provider.js +164 -2
- package/dist/server/credential-provider.js.map +1 -1
- package/dist/server/csrf.d.ts +58 -0
- package/dist/server/csrf.d.ts.map +1 -0
- package/dist/server/csrf.js +165 -0
- package/dist/server/csrf.js.map +1 -0
- package/dist/server/design-token-utils.d.ts +132 -0
- package/dist/server/design-token-utils.d.ts.map +1 -0
- package/dist/server/design-token-utils.js +714 -0
- package/dist/server/design-token-utils.js.map +1 -0
- package/dist/server/email.d.ts +10 -0
- package/dist/server/email.d.ts.map +1 -1
- package/dist/server/email.js +63 -16
- package/dist/server/email.js.map +1 -1
- package/dist/server/framework-request-handler.d.ts +20 -0
- package/dist/server/framework-request-handler.d.ts.map +1 -1
- package/dist/server/framework-request-handler.js +140 -24
- package/dist/server/framework-request-handler.js.map +1 -1
- package/dist/server/google-auth-plugin.d.ts.map +1 -1
- package/dist/server/google-auth-plugin.js +10 -2
- package/dist/server/google-auth-plugin.js.map +1 -1
- package/dist/server/google-oauth.d.ts +102 -3
- package/dist/server/google-oauth.d.ts.map +1 -1
- package/dist/server/google-oauth.js +263 -43
- package/dist/server/google-oauth.js.map +1 -1
- package/dist/server/index.d.ts +5 -5
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +5 -5
- package/dist/server/index.js.map +1 -1
- package/dist/server/oauth-helpers.d.ts +8 -3
- package/dist/server/oauth-helpers.d.ts.map +1 -1
- package/dist/server/oauth-helpers.js +12 -8
- package/dist/server/oauth-helpers.js.map +1 -1
- package/dist/server/onboarding-html.d.ts.map +1 -1
- package/dist/server/onboarding-html.js +50 -9
- package/dist/server/onboarding-html.js.map +1 -1
- package/dist/server/poll.d.ts +33 -0
- package/dist/server/poll.d.ts.map +1 -1
- package/dist/server/poll.js +43 -2
- package/dist/server/poll.js.map +1 -1
- package/dist/server/request-context.d.ts +102 -3
- package/dist/server/request-context.d.ts.map +1 -1
- package/dist/server/request-context.js +100 -7
- package/dist/server/request-context.js.map +1 -1
- package/dist/server/security-headers.d.ts +51 -0
- package/dist/server/security-headers.d.ts.map +1 -0
- package/dist/server/security-headers.js +90 -0
- package/dist/server/security-headers.js.map +1 -0
- package/dist/server/ssr-handler.d.ts.map +1 -1
- package/dist/server/ssr-handler.js +96 -2
- package/dist/server/ssr-handler.js.map +1 -1
- package/dist/server/transcribe-voice.d.ts.map +1 -1
- package/dist/server/transcribe-voice.js +376 -60
- package/dist/server/transcribe-voice.js.map +1 -1
- package/dist/server/voice-providers-status.d.ts +12 -0
- package/dist/server/voice-providers-status.d.ts.map +1 -0
- package/dist/server/voice-providers-status.js +71 -0
- package/dist/server/voice-providers-status.js.map +1 -0
- package/dist/sharing/access.d.ts.map +1 -1
- package/dist/sharing/access.js +16 -13
- package/dist/sharing/access.js.map +1 -1
- package/dist/sharing/actions/share-resource.d.ts +1 -0
- package/dist/sharing/actions/share-resource.d.ts.map +1 -1
- package/dist/sharing/actions/share-resource.js +45 -0
- package/dist/sharing/actions/share-resource.js.map +1 -1
- package/dist/sharing/schema.d.ts +1 -1
- package/dist/styles/agent-native.css +5 -0
- package/dist/templates/default/.agents/skills/delegate-to-agent/SKILL.md +54 -0
- package/dist/templates/default/app/root.tsx +51 -14
- package/dist/templates/default/app/routes/_index.tsx +6 -1
- package/dist/templates/default/public/favicon.svg +13 -0
- package/dist/templates/default/public/icon-180.svg +12 -3
- package/dist/templates/default/public/icon-192.svg +12 -3
- package/dist/templates/default/public/icon-512.svg +12 -3
- package/dist/templates/default/react-router.config.ts +3 -0
- package/dist/templates/workspace-core/package.json +22 -4
- package/dist/templates/workspace-core/src/credentials.ts +32 -5
- package/dist/templates/workspace-core/tsconfig.json +4 -1
- package/dist/terminal/pty-server.d.ts.map +1 -1
- package/dist/terminal/pty-server.js +7 -1
- package/dist/terminal/pty-server.js.map +1 -1
- package/dist/terminal/terminal-plugin.d.ts.map +1 -1
- package/dist/terminal/terminal-plugin.js +26 -6
- package/dist/terminal/terminal-plugin.js.map +1 -1
- package/dist/tools/actions.d.ts +3 -0
- package/dist/tools/actions.d.ts.map +1 -0
- package/dist/tools/actions.js +270 -0
- package/dist/tools/actions.js.map +1 -0
- package/dist/tools/fetch-tool.d.ts +1 -0
- package/dist/tools/fetch-tool.d.ts.map +1 -1
- package/dist/tools/fetch-tool.js +39 -17
- package/dist/tools/fetch-tool.js.map +1 -1
- package/dist/tools/html-shell.d.ts +44 -0
- package/dist/tools/html-shell.d.ts.map +1 -0
- package/dist/tools/html-shell.js +485 -0
- package/dist/tools/html-shell.js.map +1 -0
- package/dist/tools/proxy-security.d.ts +12 -0
- package/dist/tools/proxy-security.d.ts.map +1 -0
- package/dist/tools/proxy-security.js +158 -0
- package/dist/tools/proxy-security.js.map +1 -0
- package/dist/tools/routes.d.ts +2 -0
- package/dist/tools/routes.d.ts.map +1 -0
- package/dist/tools/routes.js +629 -0
- package/dist/tools/routes.js.map +1 -0
- package/dist/tools/schema.d.ts +578 -0
- package/dist/tools/schema.d.ts.map +1 -0
- package/dist/tools/schema.js +115 -0
- package/dist/tools/schema.js.map +1 -0
- package/dist/tools/slots/routes.d.ts +15 -0
- package/dist/tools/slots/routes.d.ts.map +1 -0
- package/dist/tools/slots/routes.js +94 -0
- package/dist/tools/slots/routes.js.map +1 -0
- package/dist/tools/slots/schema.d.ts +303 -0
- package/dist/tools/slots/schema.d.ts.map +1 -0
- package/dist/tools/slots/schema.js +76 -0
- package/dist/tools/slots/schema.js.map +1 -0
- package/dist/tools/slots/store.d.ts +66 -0
- package/dist/tools/slots/store.d.ts.map +1 -0
- package/dist/tools/slots/store.js +227 -0
- package/dist/tools/slots/store.js.map +1 -0
- package/dist/tools/store.d.ts +40 -0
- package/dist/tools/store.d.ts.map +1 -0
- package/dist/tools/store.js +181 -0
- package/dist/tools/store.js.map +1 -0
- package/dist/tools/theme.d.ts +2 -0
- package/dist/tools/theme.d.ts.map +1 -0
- package/dist/tools/theme.js +67 -0
- package/dist/tools/theme.js.map +1 -0
- package/dist/tools/url-safety.d.ts +24 -0
- package/dist/tools/url-safety.d.ts.map +1 -0
- package/dist/tools/url-safety.js +224 -0
- package/dist/tools/url-safety.js.map +1 -0
- package/dist/tracking/providers.d.ts.map +1 -1
- package/dist/tracking/providers.js +28 -11
- package/dist/tracking/providers.js.map +1 -1
- package/dist/tracking/registry.d.ts.map +1 -1
- package/dist/tracking/registry.js +7 -3
- package/dist/tracking/registry.js.map +1 -1
- package/dist/transcription/builder-transcription.d.ts.map +1 -1
- package/dist/transcription/builder-transcription.js +26 -14
- package/dist/transcription/builder-transcription.js.map +1 -1
- package/dist/triggers/actions.d.ts.map +1 -1
- package/dist/triggers/actions.js +11 -6
- package/dist/triggers/actions.js.map +1 -1
- package/dist/triggers/condition-evaluator.d.ts +8 -0
- package/dist/triggers/condition-evaluator.d.ts.map +1 -1
- package/dist/triggers/condition-evaluator.js +39 -4
- package/dist/triggers/condition-evaluator.js.map +1 -1
- package/dist/triggers/dispatcher.d.ts.map +1 -1
- package/dist/triggers/dispatcher.js +67 -4
- package/dist/triggers/dispatcher.js.map +1 -1
- package/dist/vite/action-types-plugin.d.ts.map +1 -1
- package/dist/vite/action-types-plugin.js +18 -7
- package/dist/vite/action-types-plugin.js.map +1 -1
- package/dist/vite/client.d.ts +2 -0
- package/dist/vite/client.d.ts.map +1 -1
- package/dist/vite/client.js +240 -8
- package/dist/vite/client.js.map +1 -1
- package/docs/content/a2a-protocol.md +2 -2
- package/docs/content/authentication.md +78 -12
- package/docs/content/cloneable-saas.md +59 -62
- package/docs/content/drop-in-agent.md +2 -2
- package/docs/content/faq.md +73 -43
- package/docs/content/getting-started.md +37 -61
- package/docs/content/mcp-clients.md +14 -1
- package/docs/content/messaging.md +324 -0
- package/docs/content/onboarding.md +82 -12
- package/docs/content/pure-agent-apps.md +55 -28
- package/docs/content/template-analytics.md +65 -59
- package/docs/content/template-calendar.md +61 -56
- package/docs/content/template-clips.md +25 -23
- package/docs/content/template-content.md +36 -26
- package/docs/content/template-design.md +55 -0
- package/docs/content/template-dispatch.md +15 -1
- package/docs/content/template-forms.md +19 -16
- package/docs/content/template-mail.md +78 -80
- package/docs/content/template-slides.md +43 -31
- package/docs/content/template-video.md +49 -22
- package/docs/content/tools.md +107 -0
- package/docs/content/what-is-agent-native.md +89 -105
- package/package.json +5 -1
- package/src/templates/default/.agents/skills/delegate-to-agent/SKILL.md +54 -0
- package/src/templates/default/app/root.tsx +51 -14
- package/src/templates/default/app/routes/_index.tsx +6 -1
- package/src/templates/default/public/favicon.svg +13 -0
- package/src/templates/default/public/icon-180.svg +12 -3
- package/src/templates/default/public/icon-192.svg +12 -3
- package/src/templates/default/public/icon-512.svg +12 -3
- package/src/templates/default/react-router.config.ts +3 -0
- package/src/templates/workspace-core/package.json +22 -4
- package/src/templates/workspace-core/src/credentials.ts +32 -5
- package/src/templates/workspace-core/tsconfig.json +4 -1
- package/docs/content/integrations.md +0 -198
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
import { runWithRequestContext, getRequestOrgId } from "./request-context.js";
|
|
1
|
+
import { runWithRequestContext, getRequestOrgId, getRequestUserEmail, getRequestRunContext, ensureRequestRunContext, } from "./request-context.js";
|
|
2
2
|
import { getSetting, putSetting } from "../settings/store.js";
|
|
3
3
|
import { getH3App, trackPluginInit } from "./framework-request-handler.js";
|
|
4
4
|
import { createProductionAgentHandler, runAgentLoop, actionsToEngineTools, getActiveRunForThreadAsync, abortRun, subscribeToRun, } from "../agent/production-agent.js";
|
|
5
5
|
import { resolveEngine, createAnthropicEngine } from "../agent/engine/index.js";
|
|
6
|
+
import { DEFAULT_MODEL } from "../agent/default-model.js";
|
|
6
7
|
import { McpClientManager, loadMcpConfig, autoDetectMcpConfig, mcpToolsToActionEntries, syncMcpActionEntries, mountMcpServersRoutes, mountMcpHubRoutes, buildMergedConfig, getHubStatus, isHubServeEnabled, } from "../mcp-client/index.js";
|
|
7
8
|
import { discoverAgents } from "./agent-discovery.js";
|
|
8
9
|
import { loadSchemaPromptBlock } from "./schema-prompt.js";
|
|
9
10
|
import { buildAssistantMessage, extractThreadMeta, } from "../agent/thread-data-builder.js";
|
|
10
11
|
import { defineEventHandler, setResponseStatus, setResponseHeader, getMethod, getQuery, getHeader, } from "h3";
|
|
11
|
-
import { getSession } from "./auth.js";
|
|
12
|
+
import { getSession, DEV_MODE_USER_EMAIL } from "./auth.js";
|
|
12
13
|
import { getOrigin } from "./google-oauth.js";
|
|
13
|
-
import { createThread, getThread, listThreads, searchThreads, updateThreadData, withThreadDataLock, deleteThread, setThreadQueuedMessages, } from "../chat-threads/store.js";
|
|
14
|
+
import { createThread, forkThread, getThread, listThreads, searchThreads, updateThreadData, withThreadDataLock, deleteThread, setThreadQueuedMessages, } from "../chat-threads/store.js";
|
|
14
15
|
import { resourceListAccessible, resourceList, resourceGet, resourceGetByPath, ensurePersonalDefaults, SHARED_OWNER, } from "../resources/store.js";
|
|
15
16
|
import nodePath from "node:path";
|
|
16
17
|
import { readBody } from "./h3-helpers.js";
|
|
17
18
|
import { getBuilderBrowserConnectUrl } from "./builder-browser.js";
|
|
19
|
+
import { captureCliOutput } from "./cli-capture.js";
|
|
18
20
|
// Lazy fs — loaded via dynamic import() on first use.
|
|
19
21
|
// This avoids require() which bundlers convert to createRequire(import.meta.url)
|
|
20
22
|
// that crashes on CF Workers where import.meta.url is undefined.
|
|
@@ -27,7 +29,9 @@ async function lazyFs() {
|
|
|
27
29
|
}
|
|
28
30
|
/**
|
|
29
31
|
* Wraps a core CLI script (that writes to console.log) as a ActionEntry
|
|
30
|
-
* by capturing stdout.
|
|
32
|
+
* by capturing stdout. Uses an AsyncLocalStorage-backed capture so
|
|
33
|
+
* concurrent tool calls do not corrupt the global console/stdout pointers
|
|
34
|
+
* (see `cli-capture.ts`).
|
|
31
35
|
*/
|
|
32
36
|
function wrapCliScript(tool, cliDefault, opts) {
|
|
33
37
|
return {
|
|
@@ -38,39 +42,7 @@ function wrapCliScript(tool, cliDefault, opts) {
|
|
|
38
42
|
for (const [k, v] of Object.entries(args)) {
|
|
39
43
|
cliArgs.push(`--${k}`, v);
|
|
40
44
|
}
|
|
41
|
-
|
|
42
|
-
const origLog = console.log;
|
|
43
|
-
const origError = console.error;
|
|
44
|
-
const origStdoutWrite = process.stdout.write;
|
|
45
|
-
console.log = (...a) => {
|
|
46
|
-
logs.push(a.map(String).join(" "));
|
|
47
|
-
};
|
|
48
|
-
console.error = (...a) => {
|
|
49
|
-
logs.push(a.map(String).join(" "));
|
|
50
|
-
};
|
|
51
|
-
// Intercept process.stdout.write so scripts that write directly
|
|
52
|
-
// (e.g. resource-read) have their output captured
|
|
53
|
-
process.stdout.write = ((chunk, ...rest) => {
|
|
54
|
-
if (typeof chunk === "string") {
|
|
55
|
-
logs.push(chunk);
|
|
56
|
-
}
|
|
57
|
-
else if (Buffer.isBuffer(chunk)) {
|
|
58
|
-
logs.push(chunk.toString());
|
|
59
|
-
}
|
|
60
|
-
return true;
|
|
61
|
-
});
|
|
62
|
-
try {
|
|
63
|
-
await cliDefault(cliArgs);
|
|
64
|
-
}
|
|
65
|
-
catch (err) {
|
|
66
|
-
logs.push(`Error: ${err?.message ?? String(err)}`);
|
|
67
|
-
}
|
|
68
|
-
finally {
|
|
69
|
-
console.log = origLog;
|
|
70
|
-
console.error = origError;
|
|
71
|
-
process.stdout.write = origStdoutWrite;
|
|
72
|
-
}
|
|
73
|
-
return logs.join("\n") || "(no output)";
|
|
45
|
+
return captureCliOutput(() => cliDefault(cliArgs));
|
|
74
46
|
},
|
|
75
47
|
};
|
|
76
48
|
}
|
|
@@ -156,6 +128,12 @@ function createRefreshScreenEntry() {
|
|
|
156
128
|
}
|
|
157
129
|
/** Well-known application-state key used by the refresh-screen tool. */
|
|
158
130
|
const SCREEN_REFRESH_KEY = "__screen_refresh__";
|
|
131
|
+
/**
|
|
132
|
+
* In-memory rate-limit tracker for `/generate-title`. Keyed by user email,
|
|
133
|
+
* value is recent invocation timestamps within the rolling window. Stale
|
|
134
|
+
* entries are pruned on read.
|
|
135
|
+
*/
|
|
136
|
+
const generateTitleRateLimit = new Map();
|
|
159
137
|
/**
|
|
160
138
|
* Creates the `set-search-params` / `set-url-path` tools. Writes a one-shot
|
|
161
139
|
* URL command to application_state; the client's URLSync component applies
|
|
@@ -673,17 +651,94 @@ function createBuilderBrowserTool(deps) {
|
|
|
673
651
|
},
|
|
674
652
|
},
|
|
675
653
|
run: async (args) => {
|
|
676
|
-
const
|
|
654
|
+
const { resolveBuilderCredentials } = await import("./credential-provider.js");
|
|
655
|
+
const creds = await resolveBuilderCredentials();
|
|
656
|
+
const configured = !!(creds.privateKey && creds.publicKey);
|
|
677
657
|
const prompt = typeof args?.prompt === "string" ? args.prompt : "";
|
|
678
658
|
return JSON.stringify({
|
|
679
659
|
kind: "connect-builder-card",
|
|
680
660
|
configured,
|
|
681
661
|
connectUrl: getBuilderBrowserConnectUrl(deps.getOrigin()),
|
|
682
|
-
orgName:
|
|
662
|
+
orgName: creds.orgName || null,
|
|
683
663
|
prompt,
|
|
684
664
|
});
|
|
685
665
|
},
|
|
686
666
|
},
|
|
667
|
+
"activate-browser": {
|
|
668
|
+
tool: {
|
|
669
|
+
description: "Activate browser automation tools. Call this when you need to interact with a real browser — e.g. to extract design tokens from a rendered page, take screenshots, read computed styles from JS-heavy sites, or test a live URL. After activation, chrome-devtools MCP tools (navigate, click, evaluate_script, take_screenshot, etc.) become available on your next action. Requires Builder.io connection.",
|
|
670
|
+
parameters: {
|
|
671
|
+
type: "object",
|
|
672
|
+
properties: {
|
|
673
|
+
sessionId: {
|
|
674
|
+
type: "string",
|
|
675
|
+
description: "Optional session identifier for the browser connection. Auto-generated if omitted.",
|
|
676
|
+
},
|
|
677
|
+
},
|
|
678
|
+
},
|
|
679
|
+
},
|
|
680
|
+
run: async (args) => {
|
|
681
|
+
const { resolveBuilderCredentials } = await import("./credential-provider.js");
|
|
682
|
+
const creds = await resolveBuilderCredentials();
|
|
683
|
+
if (!creds.privateKey || !creds.publicKey) {
|
|
684
|
+
return JSON.stringify({
|
|
685
|
+
error: "builder-not-connected",
|
|
686
|
+
message: "Builder.io is not connected. Call `connect-builder` first to enable browser automation.",
|
|
687
|
+
});
|
|
688
|
+
}
|
|
689
|
+
const { requestBuilderBrowserConnection } = await import("./builder-browser.js");
|
|
690
|
+
const sessionId = (typeof args?.sessionId === "string" && args.sessionId) ||
|
|
691
|
+
`an-browser-${Date.now()}`;
|
|
692
|
+
let connection;
|
|
693
|
+
try {
|
|
694
|
+
connection = await requestBuilderBrowserConnection({ sessionId });
|
|
695
|
+
}
|
|
696
|
+
catch (err) {
|
|
697
|
+
return JSON.stringify({
|
|
698
|
+
error: "browser-connection-failed",
|
|
699
|
+
message: `Failed to get browser connection: ${err?.message ?? err}`,
|
|
700
|
+
});
|
|
701
|
+
}
|
|
702
|
+
const wsUrl = connection.wsUrl;
|
|
703
|
+
if (!wsUrl) {
|
|
704
|
+
return JSON.stringify({
|
|
705
|
+
error: "no-ws-url",
|
|
706
|
+
message: "Browser connection did not return a WebSocket URL.",
|
|
707
|
+
});
|
|
708
|
+
}
|
|
709
|
+
const manager = getGlobalMcpManager();
|
|
710
|
+
if (!manager) {
|
|
711
|
+
return JSON.stringify({
|
|
712
|
+
error: "no-mcp-manager",
|
|
713
|
+
message: "MCP manager is not available.",
|
|
714
|
+
});
|
|
715
|
+
}
|
|
716
|
+
// Add chrome-devtools-mcp server pointing at the provisioned browser
|
|
717
|
+
const currentConfig = manager.getConfig();
|
|
718
|
+
const servers = { ...(currentConfig?.servers ?? {}) };
|
|
719
|
+
servers["chrome-devtools"] = {
|
|
720
|
+
command: "npx",
|
|
721
|
+
args: [
|
|
722
|
+
"-y",
|
|
723
|
+
"chrome-devtools-mcp@latest",
|
|
724
|
+
"--wsEndpoint",
|
|
725
|
+
wsUrl,
|
|
726
|
+
"--categoryEmulation=false",
|
|
727
|
+
],
|
|
728
|
+
type: "stdio",
|
|
729
|
+
};
|
|
730
|
+
await manager.reconfigure({
|
|
731
|
+
servers,
|
|
732
|
+
source: currentConfig?.source ?? "runtime",
|
|
733
|
+
});
|
|
734
|
+
return JSON.stringify({
|
|
735
|
+
success: true,
|
|
736
|
+
message: "Browser activated. Chrome DevTools MCP tools (mcp__chrome-devtools__*) are now available. Use them on your next action to navigate pages, read DOM, take screenshots, evaluate JavaScript, etc.",
|
|
737
|
+
wsUrl,
|
|
738
|
+
sessionId,
|
|
739
|
+
});
|
|
740
|
+
},
|
|
741
|
+
},
|
|
687
742
|
};
|
|
688
743
|
}
|
|
689
744
|
/**
|
|
@@ -875,6 +930,9 @@ const FRAMEWORK_CORE_COMPACT = `
|
|
|
875
930
|
5. **Screen refresh is automatic** — The framework auto-refreshes after mutating tool calls. Only call \`refresh-screen\` when you mutated data via a path the framework can't detect.
|
|
876
931
|
6. **Memory** — Use \`save-memory\` proactively when you learn preferences, corrections, or project context.
|
|
877
932
|
7. **Security** — Always use parameterized queries. Never \`dangerouslySetInnerHTML\`, \`innerHTML\`, or \`eval()\`.
|
|
933
|
+
8. **\`db-*\` tools are internal only** — \`db-query\`, \`db-exec\`, \`db-patch\` ONLY access the app's own SQL database (settings, application_state, template tables). They CANNOT reach BigQuery, HubSpot, GA4, Jira, or any external data source. If the user asks about a table that is NOT in the app schema (e.g. \`dbt_analytics.*\`, \`dbt_mart.*\`, or any fully-qualified \`project.dataset.table\`), use the appropriate template action instead — \`bigquery\` for warehouse tables, \`ga4-report\` for Google Analytics, \`hubspot-deals\` for HubSpot, etc. **Never use \`db-query\` for external data — it will fail.**
|
|
934
|
+
9. **Never fabricate data** — Do NOT invent numbers, metrics, records, or query results. Do NOT present estimated or example data as if it were real. If a data source is unavailable (missing credentials, connection error, tool failure), say so clearly, note the gap, and work with whatever data you do have. If no data can be retrieved at all, say "I can't retrieve this data right now" and explain why. Presenting made-up data as real is a critical failure — it is worse than admitting the limitation.
|
|
935
|
+
10. **Never fabricate success from tool errors** — When any tool call returns an error (marked \`isError: true\`, contains "Command failed", "Error:", or non-zero exit output), the operation FAILED. Do NOT synthesize a success narrative or describe what the action "would have" produced. Report the failure verbatim from the tool output. This applies especially to \`shell(command="pnpm action ...")\` calls: if the action threw, it did NOT succeed.
|
|
878
936
|
|
|
879
937
|
### Resources
|
|
880
938
|
|
|
@@ -887,7 +945,7 @@ When the user says "show me", "go to", "open", etc., ALWAYS use \`navigate\` fir
|
|
|
887
945
|
|
|
888
946
|
### Extended Capabilities
|
|
889
947
|
|
|
890
|
-
You also have tools for: inline embeds, chat history search, agent teams/sub-agents, recurring jobs, A2A cross-app calls, structured memory, and browser
|
|
948
|
+
You also have tools for: inline embeds, chat history search, agent teams/sub-agents, recurring jobs, A2A cross-app calls, structured memory, and browser automation (\`activate-browser\` to provision a real Chrome). Call \`get-framework-context\` to read detailed instructions for any of these when needed.
|
|
891
949
|
`;
|
|
892
950
|
/**
|
|
893
951
|
* Verbose framework sections returned by the `get-framework-context` tool.
|
|
@@ -954,11 +1012,26 @@ Convert natural language to 5-field cron format:
|
|
|
954
1012
|
builder: `### Connecting Builder.io
|
|
955
1013
|
|
|
956
1014
|
When the user asks to connect Builder.io or you hit a "Builder not configured" error, call the \`connect-builder\` tool. It renders a one-click Connect card inline — do NOT write out multi-step setup instructions yourself.`,
|
|
957
|
-
browser: `### Browser
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
-
|
|
1015
|
+
browser: `### Browser Automation
|
|
1016
|
+
|
|
1017
|
+
You can activate a real Chrome browser via Builder.io for tasks that need full page rendering:
|
|
1018
|
+
- Extracting design tokens from JS-heavy or SPA websites (computed styles, rendered colors/fonts)
|
|
1019
|
+
- Taking screenshots of live pages
|
|
1020
|
+
- Testing interactive flows on deployed URLs
|
|
1021
|
+
- Reading content from pages that require JavaScript execution
|
|
1022
|
+
|
|
1023
|
+
**How to use:**
|
|
1024
|
+
1. Call \`activate-browser\` — this provisions a Chrome instance and registers chrome-devtools MCP tools
|
|
1025
|
+
2. On your next action, use \`mcp__chrome-devtools__navigate_page\`, \`mcp__chrome-devtools__evaluate_script\`, \`mcp__chrome-devtools__take_screenshot\`, etc.
|
|
1026
|
+
3. If Builder is not connected, call \`connect-builder\` first
|
|
1027
|
+
|
|
1028
|
+
**When to recommend browser automation:**
|
|
1029
|
+
- User wants to import a design system from a URL (JS-rendered sites give almost no useful data from plain HTML fetch)
|
|
1030
|
+
- User asks you to check how a deployed site looks or behaves
|
|
1031
|
+
- Any task involving reading computed/rendered page state
|
|
1032
|
+
- When \`web-request\` returns minimal/skeleton HTML from a modern SPA
|
|
1033
|
+
|
|
1034
|
+
Prefer \`web-request\` for simple API calls and static pages. Use browser automation when you need the real rendered page.`,
|
|
962
1035
|
"call-agent": `### call-agent — External Apps Only
|
|
963
1036
|
|
|
964
1037
|
The \`call-agent\` tool sends a message to a DIFFERENT, separately-deployed app's agent (A2A protocol). It is **not** for calling actions within the current app.
|
|
@@ -1023,6 +1096,9 @@ const FRAMEWORK_CORE = `
|
|
|
1023
1096
|
5. **Screen refresh is automatic after action calls** — The framework auto-emits a refresh event after any successful mutating tool call (template actions like \`log-meal\`, \`update-form\`, \`edit-document\`, and the \`db-exec\` / \`db-patch\` tools). The UI re-fetches its queries without a full page reload. You do NOT need to call \`refresh-screen\` after an action — it's already handled. Only call \`refresh-screen\` explicitly when (a) you mutated data via a path the framework can't detect (e.g. writing directly to an external system whose results the app mirrors), or (b) you want to pass a \`scope\` hint so the UI narrows which queries to refetch. Do NOT tell the user to reload the page.
|
|
1024
1097
|
6. **Memory** — Use the structured memory system to persist knowledge across sessions. Use \`save-memory\` proactively when you learn preferences, corrections, or project context. Update shared AGENTS.md for instructions that should apply to all users.
|
|
1025
1098
|
7. **Security** — Always use \`defineAction\` with a Zod \`schema:\` for input validation. Never construct SQL with string concatenation — use parameterized queries via db-query/db-exec. Never use \`dangerouslySetInnerHTML\`, \`innerHTML\`, or \`eval()\`. Never expose secrets in responses or source code. Every table with user data must have \`owner_email\`.
|
|
1099
|
+
8. **\`db-*\` tools are internal only** — \`db-query\`, \`db-exec\`, \`db-patch\` ONLY access the app's own SQL database (settings, application_state, template tables). They CANNOT reach BigQuery, HubSpot, GA4, Jira, or any external data source. If the user asks about a table that is NOT in the app schema (e.g. \`dbt_analytics.*\`, \`dbt_mart.*\`, or any fully-qualified \`project.dataset.table\`), use the appropriate template action instead — \`bigquery\` for warehouse tables, \`ga4-report\` for Google Analytics, \`hubspot-deals\` for HubSpot, etc. **Never use \`db-query\` for external data — it will fail.**
|
|
1100
|
+
9. **Never fabricate data** — Do NOT invent numbers, metrics, records, or query results. Do NOT present estimated or example data as if it were real. If a data source is unavailable (missing credentials, connection error, tool failure), say so clearly, note the gap, and work with whatever data you do have. If no data can be retrieved at all, say "I can't retrieve this data right now" and explain why. Presenting made-up data as real is a critical failure — it is worse than admitting the limitation.
|
|
1101
|
+
10. **Never fabricate success from tool errors** — When any tool call returns an error (marked \`isError: true\`, contains "Command failed", "Error:", or non-zero exit output), the operation FAILED. Do NOT synthesize a success narrative, format a result table, or describe what the action "would have" produced. Report the failure verbatim from the tool output. This applies especially to \`shell(command="pnpm action ...")\` calls: if the underlying action threw (visible in the error text), the action did NOT succeed — report the error, do not describe a successful outcome.
|
|
1026
1102
|
|
|
1027
1103
|
### Resources
|
|
1028
1104
|
|
|
@@ -1123,11 +1199,9 @@ Job instructions should be self-contained — include which actions to call, wha
|
|
|
1123
1199
|
|
|
1124
1200
|
When the user asks to connect Builder.io, needs Builder for LLM access / browser automation, or you hit a "Builder not configured" error, call the \`connect-builder\` tool. It renders a one-click Connect card inline in the chat — do NOT write out multi-step setup instructions yourself (no "Option 1 / Option 2", no terminal commands). Just call the tool and let the card handle the rest.
|
|
1125
1201
|
|
|
1126
|
-
### Browser
|
|
1202
|
+
### Browser Automation
|
|
1127
1203
|
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
- If Builder is not configured, the card will guide the user through setup.
|
|
1204
|
+
Call \`activate-browser\` to provision a real Chrome browser. After activation, chrome-devtools MCP tools become available for navigating pages, reading rendered DOM, taking screenshots, and evaluating JavaScript. If Builder is not connected, call \`connect-builder\` first. Use browser automation proactively when tasks benefit from full page rendering (design system extraction from URLs, visual verification, SPA content reading).
|
|
1131
1205
|
|
|
1132
1206
|
### call-agent — External Apps Only
|
|
1133
1207
|
|
|
@@ -1182,8 +1256,16 @@ The agent and the UI are equal partners — everything the UI can do, you can do
|
|
|
1182
1256
|
|
|
1183
1257
|
**In production mode, you operate through registered actions exposed as tools.** These are your capabilities — use them to read data, take actions, and help the user. You cannot edit source code or access the filesystem directly. Your tools are the app's API.
|
|
1184
1258
|
|
|
1259
|
+
### Tools (Mini-Apps) — Use \`create-tool\` for tools / widgets / dashboards
|
|
1260
|
+
|
|
1261
|
+
If the user asks you to create, build, or make a **tool**, **widget**, **dashboard**, **calculator**, **mini-app**, or any small self-contained interactive utility — call \`create-tool\` immediately with a self-contained Alpine.js HTML body. This is **NOT** a code change and does **NOT** go through \`connect-builder\`. Tools are sandboxed mini-apps stored in the database — no source files are touched, no PR is opened, no build is required. The tool appears in the Tools view and can be edited later via \`update-tool\`.
|
|
1262
|
+
|
|
1263
|
+
When in doubt — if the request mentions "tool", "widget", "dashboard", "calculator", or asks for a small interactive utility — choose \`create-tool\`. Do **not** preface the call with planning text like "let me build the dashboard…" — just call \`create-tool\` directly. One tool call, one response.
|
|
1264
|
+
|
|
1185
1265
|
### Code Changes Not Available — Call \`connect-builder\` Immediately
|
|
1186
1266
|
|
|
1267
|
+
If the request matches the Tools section above (tool / widget / dashboard / calculator / mini-app), use \`create-tool\` instead — do NOT route it to \`connect-builder\`.
|
|
1268
|
+
|
|
1187
1269
|
When the user asks you to change the UI, modify code, add a feature, fix a bug in the app itself, change styles, add a hook, create a component, add a route, add an integration, or anything else that requires editing source files — you MUST take exactly these steps, in order:
|
|
1188
1270
|
|
|
1189
1271
|
1. Call the \`connect-builder\` tool, passing the user's full request verbatim as the \`prompt\` argument. This renders an inline card. If Builder is connected, the card hands the prompt off to Builder's cloud agent on one click and returns a branch URL; otherwise it shows a connect / waitlist flow. Either way, Builder writes the code — no local setup, no clone, no install.
|
|
@@ -1231,9 +1313,13 @@ The agent and the UI are equal partners — everything the UI can do, you can do
|
|
|
1231
1313
|
|
|
1232
1314
|
**In production mode, you operate through registered actions exposed as tools.** These are your capabilities — use them to read data, take actions, and help the user. You cannot edit source code or access the filesystem directly. Your tools are the app's API.
|
|
1233
1315
|
|
|
1316
|
+
### Tools (Mini-Apps) — Use \`create-tool\`
|
|
1317
|
+
|
|
1318
|
+
If the user asks for a **tool**, **widget**, **dashboard**, **calculator**, or **mini-app**, call \`create-tool\` immediately with a self-contained Alpine.js HTML body. This is NOT a code change — tools are sandboxed mini-apps stored in the database. Do not preface with "let me build…" — just call \`create-tool\`.
|
|
1319
|
+
|
|
1234
1320
|
### Code Changes — Call \`connect-builder\`
|
|
1235
1321
|
|
|
1236
|
-
When the user asks to change the UI, modify code, add a feature, or fix a bug in the app itself — call \`connect-builder\` immediately, passing the user's request as the \`prompt\`. Do NOT write code, list files, make plans, or spawn sub-agents for code changes. Builder handles it in the cloud. Mention \`npx agent-native create <app-name>\` as an offline fallback.
|
|
1322
|
+
When the user asks to change the UI, modify code, add a feature, or fix a bug in the app itself — call \`connect-builder\` immediately, passing the user's request as the \`prompt\`. (Tool / widget / dashboard requests use \`create-tool\` instead — see above.) Do NOT write code, list files, make plans, or spawn sub-agents for code changes. Builder handles it in the cloud. Mention \`npx agent-native create <app-name>\` as an offline fallback.
|
|
1237
1323
|
${FRAMEWORK_CORE_COMPACT}`;
|
|
1238
1324
|
const DEV_FRAMEWORK_PROMPT_COMPACT = `## Agent-Native Framework — Development Mode
|
|
1239
1325
|
|
|
@@ -1590,7 +1676,7 @@ export function createAgentChatPlugin(options) {
|
|
|
1590
1676
|
if (mcpConfig?.source) {
|
|
1591
1677
|
console.log(`[mcp-client] loaded config from ${mcpConfig.source} (${Object.keys(mcpConfig.servers).length} server(s))`);
|
|
1592
1678
|
}
|
|
1593
|
-
else {
|
|
1679
|
+
else if (process.env.DEBUG) {
|
|
1594
1680
|
console.log("[mcp-client] no configured MCP servers — skipping MCP tools");
|
|
1595
1681
|
}
|
|
1596
1682
|
}
|
|
@@ -1668,9 +1754,8 @@ export function createAgentChatPlugin(options) {
|
|
|
1668
1754
|
...engineScripts,
|
|
1669
1755
|
};
|
|
1670
1756
|
const callAgentScript = await createCallAgentScriptEntry(options?.appId);
|
|
1671
|
-
let _currentRequestOrigin = "http://localhost:3000";
|
|
1672
1757
|
const browserTools = createBuilderBrowserTool({
|
|
1673
|
-
getOrigin: () =>
|
|
1758
|
+
getOrigin: () => getRequestRunContext()?.requestOrigin ?? "http://localhost:3000",
|
|
1674
1759
|
});
|
|
1675
1760
|
// Auto-mount A2A protocol endpoints so every app is discoverable
|
|
1676
1761
|
// and callable by other agents via the standard protocol.
|
|
@@ -1801,27 +1886,57 @@ export function createAgentChatPlugin(options) {
|
|
|
1801
1886
|
}
|
|
1802
1887
|
catch { }
|
|
1803
1888
|
}
|
|
1804
|
-
//
|
|
1805
|
-
//
|
|
1806
|
-
//
|
|
1807
|
-
|
|
1808
|
-
//
|
|
1889
|
+
// Per-request owner is read from the AsyncLocalStorage run context
|
|
1890
|
+
// (populated by prepareRun). Module-scope `let` would race across
|
|
1891
|
+
// concurrent requests on a long-lived Node process — overlapping
|
|
1892
|
+
// tool calls would observe whichever request wrote last. ALS gives
|
|
1893
|
+
// each async call-chain its own view of the owner.
|
|
1894
|
+
//
|
|
1895
|
+
// Falls back to `getRequestUserEmail()` so callers that wrap work
|
|
1896
|
+
// in `runWithRequestContext({ userEmail }, …)` without going through
|
|
1897
|
+
// `prepareRun` (recurring jobs, trigger dispatcher) still see the
|
|
1898
|
+
// correct owner.
|
|
1899
|
+
//
|
|
1900
|
+
// SECURITY: returns `null` when neither the run context nor the
|
|
1901
|
+
// request user-email is populated. Consumers MUST short-circuit
|
|
1902
|
+
// with an explicit error rather than fall back to a sentinel
|
|
1903
|
+
// identity (e.g. DEV_MODE_USER_EMAIL). The previous fallback to
|
|
1904
|
+
// `local@localhost` slipped past `guard-no-localhost-fallback`
|
|
1905
|
+
// because the literal was hidden behind a symbolic alias —
|
|
1906
|
+
// any agent loop that reached this code without a populated
|
|
1907
|
+
// session would resolve `${keys.NAME}` against the dev-shim's
|
|
1908
|
+
// `app_secrets WHERE scope_id='local@localhost'` rows. See
|
|
1909
|
+
// audit 02 (HIGH: getCurrentRunOwner) and the
|
|
1910
|
+
// 2026-04-29 credentials-leak incident for the prior shape.
|
|
1911
|
+
const getCurrentRunOwner = () => getRequestRunContext()?.owner ?? getRequestUserEmail() ?? null;
|
|
1912
|
+
const requireCurrentRunOwner = (operation) => {
|
|
1913
|
+
const owner = getCurrentRunOwner();
|
|
1914
|
+
if (!owner) {
|
|
1915
|
+
throw new Error(`[agent-chat] No authenticated owner in run context — ` +
|
|
1916
|
+
`refusing to ${operation}. Ensure the request goes through ` +
|
|
1917
|
+
`prepareRun() or is wrapped in runWithRequestContext({ userEmail, ... }).`);
|
|
1918
|
+
}
|
|
1919
|
+
return owner;
|
|
1920
|
+
};
|
|
1921
|
+
// Automation tools + fetch tool — depend on owner via callback.
|
|
1922
|
+
// Each callback short-circuits with a clear error when the run context
|
|
1923
|
+
// has no authenticated owner (see SECURITY note on getCurrentRunOwner).
|
|
1809
1924
|
let automationTools = {};
|
|
1810
1925
|
try {
|
|
1811
1926
|
const { createAutomationToolEntries } = await import("../triggers/actions.js");
|
|
1812
|
-
automationTools = createAutomationToolEntries(() =>
|
|
1927
|
+
automationTools = createAutomationToolEntries(() => requireCurrentRunOwner("manage automations"));
|
|
1813
1928
|
}
|
|
1814
1929
|
catch { }
|
|
1815
1930
|
let notificationTools = {};
|
|
1816
1931
|
try {
|
|
1817
1932
|
const { createNotificationToolEntries } = await import("../notifications/actions.js");
|
|
1818
|
-
notificationTools = createNotificationToolEntries(() =>
|
|
1933
|
+
notificationTools = createNotificationToolEntries(() => requireCurrentRunOwner("manage notifications"));
|
|
1819
1934
|
}
|
|
1820
1935
|
catch { }
|
|
1821
1936
|
let progressTools = {};
|
|
1822
1937
|
try {
|
|
1823
1938
|
const { createProgressToolEntries } = await import("../progress/actions.js");
|
|
1824
|
-
progressTools = createProgressToolEntries(() =>
|
|
1939
|
+
progressTools = createProgressToolEntries(() => requireCurrentRunOwner("manage progress"));
|
|
1825
1940
|
}
|
|
1826
1941
|
catch { }
|
|
1827
1942
|
let fetchTool = {};
|
|
@@ -1829,10 +1944,10 @@ export function createAgentChatPlugin(options) {
|
|
|
1829
1944
|
const { createFetchToolEntry } = await import("../tools/fetch-tool.js");
|
|
1830
1945
|
const { resolveKeyReferences, validateUrlAllowlist, getKeyAllowlist } = await import("../secrets/substitution.js");
|
|
1831
1946
|
fetchTool = createFetchToolEntry({
|
|
1832
|
-
resolveKeys: async (text) => resolveKeyReferences(text, "user",
|
|
1947
|
+
resolveKeys: async (text) => resolveKeyReferences(text, "user", requireCurrentRunOwner("resolve key references")),
|
|
1833
1948
|
validateUrl: async (url, usedKeys) => {
|
|
1834
1949
|
for (const keyName of usedKeys) {
|
|
1835
|
-
const allowlist = await getKeyAllowlist(keyName, "user",
|
|
1950
|
+
const allowlist = await getKeyAllowlist(keyName, "user", requireCurrentRunOwner("validate URL allowlist"));
|
|
1836
1951
|
if (allowlist && !validateUrlAllowlist(url, allowlist)) {
|
|
1837
1952
|
return false;
|
|
1838
1953
|
}
|
|
@@ -1842,6 +1957,12 @@ export function createAgentChatPlugin(options) {
|
|
|
1842
1957
|
});
|
|
1843
1958
|
}
|
|
1844
1959
|
catch { }
|
|
1960
|
+
let toolActions = {};
|
|
1961
|
+
try {
|
|
1962
|
+
const { createToolActionEntries } = await import("../tools/actions.js");
|
|
1963
|
+
toolActions = createToolActionEntries();
|
|
1964
|
+
}
|
|
1965
|
+
catch { }
|
|
1845
1966
|
// In dev mode, template actions (templateScripts and discoveredActions) are
|
|
1846
1967
|
// NOT registered as native tools — the agent invokes them via shell instead.
|
|
1847
1968
|
// This avoids degenerate empty-object tool calls that Anthropic models
|
|
@@ -1852,12 +1973,14 @@ export function createAgentChatPlugin(options) {
|
|
|
1852
1973
|
...resourceScripts,
|
|
1853
1974
|
...docsScripts,
|
|
1854
1975
|
...(lazyContext ? frameworkContextTool : {}),
|
|
1976
|
+
...urlTools,
|
|
1855
1977
|
...chatScripts,
|
|
1856
1978
|
...callAgentScript,
|
|
1857
1979
|
...automationTools,
|
|
1858
1980
|
...notificationTools,
|
|
1859
1981
|
...progressTools,
|
|
1860
1982
|
...fetchTool,
|
|
1983
|
+
...toolActions,
|
|
1861
1984
|
...browserTools,
|
|
1862
1985
|
...devScriptsForA2A,
|
|
1863
1986
|
}
|
|
@@ -1876,6 +1999,7 @@ export function createAgentChatPlugin(options) {
|
|
|
1876
1999
|
...notificationTools,
|
|
1877
2000
|
...progressTools,
|
|
1878
2001
|
...fetchTool,
|
|
2002
|
+
...toolActions,
|
|
1879
2003
|
...browserTools,
|
|
1880
2004
|
...devScriptsForA2A,
|
|
1881
2005
|
};
|
|
@@ -1893,11 +2017,80 @@ export function createAgentChatPlugin(options) {
|
|
|
1893
2017
|
streaming: true,
|
|
1894
2018
|
handler: async function* (message, context) {
|
|
1895
2019
|
// Resolve the caller's identity for user-scoped data access.
|
|
2020
|
+
// Priority: A2A-JWT verified email (set by the A2A handler in
|
|
2021
|
+
// request-context) > dev session DB (dev only) > Google OAuth
|
|
2022
|
+
// tokeninfo (prod only). Without the JWT-verified-email path,
|
|
2023
|
+
// cross-app A2A calls landed owned by `local@localhost` (dev) or
|
|
2024
|
+
// `dispatch@shared`, which made resources invisible to the actual
|
|
2025
|
+
// signed-in user.
|
|
2026
|
+
//
|
|
2027
|
+
// SECURITY: we deliberately do NOT trust `context.metadata.userEmail`
|
|
2028
|
+
// as a fallback. The A2A endpoint runs in three modes — JWT-signed
|
|
2029
|
+
// (verified email lands in request context), API-key (caller is
|
|
2030
|
+
// app-authenticated but NOT user-authenticated), and unsigned
|
|
2031
|
+
// (no auth at all). Trusting caller-supplied metadata on the latter
|
|
2032
|
+
// two paths would let any reachable caller forge `metadata.userEmail`
|
|
2033
|
+
// and impersonate an arbitrary user. The JWT path already populates
|
|
2034
|
+
// the request context, so the metadata fallback was only ever used
|
|
2035
|
+
// on the unauthenticated paths — exactly where it's unsafe.
|
|
1896
2036
|
const isDev = process.env.NODE_ENV !== "production";
|
|
1897
2037
|
let userEmail;
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
2038
|
+
// 1. JWT-verified email from A2A receiver (auth boundary already
|
|
2039
|
+
// enforced upstream). Works in dev AND prod.
|
|
2040
|
+
try {
|
|
2041
|
+
const { getRequestUserEmail } = await import("./request-context.js");
|
|
2042
|
+
userEmail = getRequestUserEmail();
|
|
2043
|
+
}
|
|
2044
|
+
catch { }
|
|
2045
|
+
// Dev-mode-only: when no JWT-verified email is present, fall back
|
|
2046
|
+
// to the most recently logged-in session. This is convenient for a
|
|
2047
|
+
// single-developer dev box but is a silent-impersonation hole if
|
|
2048
|
+
// it ever fires in production or on an exposed dev environment
|
|
2049
|
+
// (preview deploys, ngrok tunnels, etc.).
|
|
2050
|
+
//
|
|
2051
|
+
// SECURITY: gate this fallback narrowly:
|
|
2052
|
+
// - NODE_ENV strictly === "development" (not "test", not unset).
|
|
2053
|
+
// - AUTH_MODE === "local" (the dev-only auth shim).
|
|
2054
|
+
// - Request host is localhost / 127.0.0.1 (best-effort: when the
|
|
2055
|
+
// A2A handler doesn't have direct H3 event access, we rely on
|
|
2056
|
+
// env-based shape checks).
|
|
2057
|
+
//
|
|
2058
|
+
// In production this MUST never fire — the runtime assertion
|
|
2059
|
+
// below crashes loud if NODE_ENV === "production" somehow reaches
|
|
2060
|
+
// this block.
|
|
2061
|
+
if (!userEmail && isDev) {
|
|
2062
|
+
if (process.env.NODE_ENV === "production") {
|
|
2063
|
+
throw new Error("[agent-chat] Dev-mode 'latest session' fallback reached in production — refusing.");
|
|
2064
|
+
}
|
|
2065
|
+
const strictlyDev = process.env.NODE_ENV === "development";
|
|
2066
|
+
const localAuthMode = process.env.AUTH_MODE === "local";
|
|
2067
|
+
// Request host check: rely on the request-context request origin
|
|
2068
|
+
// which prepareRun() / mountActionRoutes populate. The A2A
|
|
2069
|
+
// handler doesn't have direct H3 event access, but on a
|
|
2070
|
+
// misconfigured non-localhost dev box we still want to refuse.
|
|
2071
|
+
let isLocalHost = false;
|
|
2072
|
+
try {
|
|
2073
|
+
const origin = getRequestRunContext()?.requestOrigin;
|
|
2074
|
+
if (origin) {
|
|
2075
|
+
const url = new URL(origin);
|
|
2076
|
+
isLocalHost =
|
|
2077
|
+
url.hostname === "localhost" ||
|
|
2078
|
+
url.hostname === "127.0.0.1" ||
|
|
2079
|
+
url.hostname === "::1";
|
|
2080
|
+
}
|
|
2081
|
+
else {
|
|
2082
|
+
// No origin in context — the A2A handler runs without an
|
|
2083
|
+
// explicit request origin. Treat absence as permissive only
|
|
2084
|
+
// when we're confident the process is dev-only (NODE_ENV
|
|
2085
|
+
// strictly "development" + AUTH_MODE=local). Otherwise
|
|
2086
|
+
// refuse.
|
|
2087
|
+
isLocalHost = strictlyDev && localAuthMode;
|
|
2088
|
+
}
|
|
2089
|
+
}
|
|
2090
|
+
catch {
|
|
2091
|
+
isLocalHost = false;
|
|
2092
|
+
}
|
|
2093
|
+
if (strictlyDev && localAuthMode && isLocalHost) {
|
|
1901
2094
|
try {
|
|
1902
2095
|
const { getDbExec } = await import("../db/client.js");
|
|
1903
2096
|
const db = getDbExec();
|
|
@@ -1911,7 +2104,7 @@ export function createAgentChatPlugin(options) {
|
|
|
1911
2104
|
catch { }
|
|
1912
2105
|
}
|
|
1913
2106
|
}
|
|
1914
|
-
|
|
2107
|
+
if (!userEmail && !isDev) {
|
|
1915
2108
|
const googleToken = context.metadata?.googleToken;
|
|
1916
2109
|
if (googleToken) {
|
|
1917
2110
|
try {
|
|
@@ -1926,9 +2119,6 @@ export function createAgentChatPlugin(options) {
|
|
|
1926
2119
|
catch { }
|
|
1927
2120
|
}
|
|
1928
2121
|
}
|
|
1929
|
-
if (userEmail) {
|
|
1930
|
-
process.env.AGENT_USER_EMAIL = userEmail;
|
|
1931
|
-
}
|
|
1932
2122
|
const text = message.parts
|
|
1933
2123
|
.filter((p) => p.type === "text")
|
|
1934
2124
|
.map((p) => p.text)
|
|
@@ -1952,7 +2142,9 @@ export function createAgentChatPlugin(options) {
|
|
|
1952
2142
|
const devActive = isDevMode();
|
|
1953
2143
|
const handler = devActive && devHandler ? devHandler : prodHandler;
|
|
1954
2144
|
// Build the same system prompt the interactive agent uses
|
|
1955
|
-
|
|
2145
|
+
if (!userEmail)
|
|
2146
|
+
throw new Error("no authenticated user");
|
|
2147
|
+
const owner = userEmail;
|
|
1956
2148
|
const resources = await loadResourcesForPrompt(owner, lazyContext);
|
|
1957
2149
|
const schemaBlock = lazyContext
|
|
1958
2150
|
? ""
|
|
@@ -1960,8 +2152,7 @@ export function createAgentChatPlugin(options) {
|
|
|
1960
2152
|
const systemPrompt = devActive
|
|
1961
2153
|
? devPrompt + resources + schemaBlock
|
|
1962
2154
|
: basePrompt + resources + schemaBlock;
|
|
1963
|
-
const model = options?.model ??
|
|
1964
|
-
(canToggle ? "claude-sonnet-4-6" : "claude-haiku-4-5-20251001");
|
|
2155
|
+
const model = options?.model ?? DEFAULT_MODEL;
|
|
1965
2156
|
// Build tools — same as interactive handler but WITHOUT call-agent
|
|
1966
2157
|
// to prevent infinite recursive A2A loops (agent calling itself).
|
|
1967
2158
|
// In dev mode, template actions are invoked via shell (not native tools),
|
|
@@ -1971,7 +2162,9 @@ export function createAgentChatPlugin(options) {
|
|
|
1971
2162
|
...resourceScripts,
|
|
1972
2163
|
...docsScripts,
|
|
1973
2164
|
...(lazyContext ? frameworkContextTool : {}),
|
|
2165
|
+
...urlTools,
|
|
1974
2166
|
...chatScripts,
|
|
2167
|
+
...toolActions,
|
|
1975
2168
|
...browserTools,
|
|
1976
2169
|
...devScriptsForA2A,
|
|
1977
2170
|
}
|
|
@@ -1984,6 +2177,7 @@ export function createAgentChatPlugin(options) {
|
|
|
1984
2177
|
...(lazyContext ? frameworkContextTool : {}),
|
|
1985
2178
|
...urlTools,
|
|
1986
2179
|
...chatScripts,
|
|
2180
|
+
...toolActions,
|
|
1987
2181
|
...browserTools,
|
|
1988
2182
|
};
|
|
1989
2183
|
const a2aTools = actionsToEngineTools(a2aActions);
|
|
@@ -2078,8 +2272,7 @@ export function createAgentChatPlugin(options) {
|
|
|
2078
2272
|
engineOption: options?.engine,
|
|
2079
2273
|
apiKey: options?.apiKey,
|
|
2080
2274
|
});
|
|
2081
|
-
const model = options?.model ??
|
|
2082
|
-
(canToggle ? "claude-sonnet-4-6" : "claude-haiku-4-5-20251001");
|
|
2275
|
+
const model = options?.model ?? DEFAULT_MODEL;
|
|
2083
2276
|
// Same actions as A2A — without call-agent to prevent loops.
|
|
2084
2277
|
// In dev mode, template actions go through shell, not native tools.
|
|
2085
2278
|
const devActiveMcp = isDevMode();
|
|
@@ -2088,7 +2281,9 @@ export function createAgentChatPlugin(options) {
|
|
|
2088
2281
|
...resourceScripts,
|
|
2089
2282
|
...docsScripts,
|
|
2090
2283
|
...(lazyContext ? frameworkContextTool : {}),
|
|
2284
|
+
...urlTools,
|
|
2091
2285
|
...chatScripts,
|
|
2286
|
+
...toolActions,
|
|
2092
2287
|
...devScriptsForA2A,
|
|
2093
2288
|
}
|
|
2094
2289
|
: {
|
|
@@ -2100,12 +2295,13 @@ export function createAgentChatPlugin(options) {
|
|
|
2100
2295
|
...(lazyContext ? frameworkContextTool : {}),
|
|
2101
2296
|
...urlTools,
|
|
2102
2297
|
...chatScripts,
|
|
2298
|
+
...toolActions,
|
|
2103
2299
|
};
|
|
2104
2300
|
const mcpTools = actionsToEngineTools(mcpActions);
|
|
2105
|
-
const resources = await loadResourcesForPrompt(
|
|
2301
|
+
const resources = await loadResourcesForPrompt(DEV_MODE_USER_EMAIL, lazyContext);
|
|
2106
2302
|
const schemaBlock = lazyContext
|
|
2107
2303
|
? ""
|
|
2108
|
-
: await buildSchemaBlock(
|
|
2304
|
+
: await buildSchemaBlock(DEV_MODE_USER_EMAIL, devActiveMcp);
|
|
2109
2305
|
// Build the MCP handler's own prompt — always use the shell-based
|
|
2110
2306
|
// dev prompt in dev mode because mcpActions routes template actions
|
|
2111
2307
|
// through shell (`devScriptsForA2A`), regardless of `nativeActionsInDev`.
|
|
@@ -2143,13 +2339,15 @@ export function createAgentChatPlugin(options) {
|
|
|
2143
2339
|
});
|
|
2144
2340
|
// Resolve owner from the H3 event's session — matches how resources are created
|
|
2145
2341
|
const getOwnerFromEvent = async (event) => {
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2342
|
+
const session = await getSession(event);
|
|
2343
|
+
if (!session?.email) {
|
|
2344
|
+
const { createError } = await import("h3");
|
|
2345
|
+
throw createError({
|
|
2346
|
+
statusCode: 401,
|
|
2347
|
+
statusMessage: "Unauthenticated",
|
|
2348
|
+
});
|
|
2152
2349
|
}
|
|
2350
|
+
return session.email;
|
|
2153
2351
|
};
|
|
2154
2352
|
// Auto-mount template actions as HTTP endpoints under /_agent-native/actions/
|
|
2155
2353
|
// Include engine management script so the UI can call manage-agent-engine.
|
|
@@ -2241,6 +2439,15 @@ export function createAgentChatPlugin(options) {
|
|
|
2241
2439
|
else {
|
|
2242
2440
|
repo.messages.push(assistantMsg);
|
|
2243
2441
|
}
|
|
2442
|
+
// Store debug metadata so we can inspect what the LLM actually
|
|
2443
|
+
// received (system prompt, model, engine) when diagnosing issues.
|
|
2444
|
+
const runCtx = getRequestRunContext();
|
|
2445
|
+
repo._debug = {
|
|
2446
|
+
systemPrompt: runCtx?.systemPrompt,
|
|
2447
|
+
model: runCtx?.model ?? resolvedModel,
|
|
2448
|
+
engine: runCtx?.engine?.name ?? "unknown",
|
|
2449
|
+
timestamp: Date.now(),
|
|
2450
|
+
};
|
|
2244
2451
|
const meta = extractThreadMeta(repo);
|
|
2245
2452
|
await updateThreadData(threadId, JSON.stringify(repo), meta.title || thread.title, meta.preview || thread.preview, repo.messages.length);
|
|
2246
2453
|
}
|
|
@@ -2248,13 +2455,32 @@ export function createAgentChatPlugin(options) {
|
|
|
2248
2455
|
// Best-effort — don't break cleanup
|
|
2249
2456
|
}
|
|
2250
2457
|
});
|
|
2251
|
-
// Emit agent.turn.completed for automation triggers
|
|
2458
|
+
// Emit agent.turn.completed for automation triggers.
|
|
2459
|
+
//
|
|
2460
|
+
// SECURITY: include `owner` so the trigger dispatcher's tenant-scope
|
|
2461
|
+
// check engages (see triggers/dispatcher.ts:212-218). Without an
|
|
2462
|
+
// owner, every user's matching `agent.turn.completed` trigger
|
|
2463
|
+
// would fire when ANY user's chat turn completes — cross-tenant
|
|
2464
|
+
// fan-out (audit 12 #9). Owner comes from the thread row when
|
|
2465
|
+
// available (most reliable; persisted at thread create time),
|
|
2466
|
+
// falling back to the current run context's owner. If neither
|
|
2467
|
+
// resolves we skip emission entirely rather than emit unowned.
|
|
2252
2468
|
try {
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
threadId
|
|
2256
|
-
|
|
2257
|
-
}
|
|
2469
|
+
let ownerEmail;
|
|
2470
|
+
try {
|
|
2471
|
+
const ownerThread = await getThread(threadId);
|
|
2472
|
+
ownerEmail = ownerThread?.ownerEmail;
|
|
2473
|
+
}
|
|
2474
|
+
catch {
|
|
2475
|
+
// ignore — fall through to run-context owner
|
|
2476
|
+
}
|
|
2477
|
+
if (!ownerEmail) {
|
|
2478
|
+
ownerEmail = getRequestRunContext()?.owner;
|
|
2479
|
+
}
|
|
2480
|
+
if (ownerEmail) {
|
|
2481
|
+
const { emit } = await import("../event-bus/index.js");
|
|
2482
|
+
emit("agent.turn.completed", { threadId, model: resolvedModel }, { owner: ownerEmail });
|
|
2483
|
+
}
|
|
2258
2484
|
}
|
|
2259
2485
|
catch {
|
|
2260
2486
|
// Event bus not available — skip
|
|
@@ -2315,20 +2541,10 @@ export function createAgentChatPlugin(options) {
|
|
|
2315
2541
|
// Each run gets its own send function, keyed by threadId so concurrent
|
|
2316
2542
|
// requests for different threads don't clobber each other.
|
|
2317
2543
|
const _runSendByThread = new Map();
|
|
2318
|
-
|
|
2319
|
-
let _currentRunThreadId = "";
|
|
2320
|
-
let _currentRunSystemPrompt = basePrompt;
|
|
2321
|
-
// Populated by onEngineResolved per request so sub-agents inherit
|
|
2322
|
-
// whichever provider + model the user configured (OpenRouter, Groq, …)
|
|
2323
|
-
// instead of silently falling back to Anthropic + Claude.
|
|
2324
|
-
let _currentRunEngine;
|
|
2325
|
-
let _currentRunModel;
|
|
2326
|
-
// Default to Haiku in production mode to manage costs for hosted apps
|
|
2327
|
-
const resolvedModel = options?.model ??
|
|
2328
|
-
(canToggle ? "claude-sonnet-4-6" : "claude-haiku-4-5-20251001");
|
|
2544
|
+
const resolvedModel = options?.model ?? DEFAULT_MODEL;
|
|
2329
2545
|
const teamTools = createTeamTools({
|
|
2330
|
-
getOwner: () =>
|
|
2331
|
-
getSystemPrompt: () =>
|
|
2546
|
+
getOwner: () => requireCurrentRunOwner("spawn or manage sub-agents"),
|
|
2547
|
+
getSystemPrompt: () => getRequestRunContext()?.systemPrompt ?? basePrompt,
|
|
2332
2548
|
getActions: () => isDevMode()
|
|
2333
2549
|
? {
|
|
2334
2550
|
// Sub-agents spawned in dev mode also invoke template actions
|
|
@@ -2349,20 +2565,24 @@ export function createAgentChatPlugin(options) {
|
|
|
2349
2565
|
...urlTools,
|
|
2350
2566
|
...chatScripts,
|
|
2351
2567
|
},
|
|
2352
|
-
getEngine: () =>
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2568
|
+
getEngine: () => {
|
|
2569
|
+
const runCtx = getRequestRunContext();
|
|
2570
|
+
return (runCtx?.engine ??
|
|
2571
|
+
createAnthropicEngine({
|
|
2572
|
+
// Sub-agents must inherit the parent run's resolved key so a
|
|
2573
|
+
// BYO-key user can't bypass the free-tier check on the parent
|
|
2574
|
+
// run and then have agent-teams spawn delegations bill the platform key.
|
|
2575
|
+
apiKey: runCtx?.userApiKey ??
|
|
2576
|
+
options?.apiKey ??
|
|
2577
|
+
process.env.ANTHROPIC_API_KEY,
|
|
2578
|
+
}));
|
|
2579
|
+
},
|
|
2580
|
+
getModel: () => getRequestRunContext()?.model ?? resolvedModel,
|
|
2581
|
+
getParentThreadId: () => getRequestRunContext()?.threadId ?? "",
|
|
2363
2582
|
getSend: () => {
|
|
2364
2583
|
// Return the send for the current run's thread
|
|
2365
|
-
const
|
|
2584
|
+
const threadId = getRequestRunContext()?.threadId ?? "";
|
|
2585
|
+
const send = _runSendByThread.get(threadId);
|
|
2366
2586
|
return send ?? null;
|
|
2367
2587
|
},
|
|
2368
2588
|
});
|
|
@@ -2374,6 +2594,19 @@ export function createAgentChatPlugin(options) {
|
|
|
2374
2594
|
jobTools = createJobTools();
|
|
2375
2595
|
}
|
|
2376
2596
|
catch { }
|
|
2597
|
+
// Lean mode: only template actions + essential framework tools. Drop
|
|
2598
|
+
// web-request, browser tools, teams, jobs, automations, notifications,
|
|
2599
|
+
// progress, call-agent, and MCP entries to keep the tool list tight and
|
|
2600
|
+
// prevent the LLM from reaching for web-request instead of the
|
|
2601
|
+
// template's native actions (e.g. log-meal).
|
|
2602
|
+
const leanActions = {
|
|
2603
|
+
...templateScripts,
|
|
2604
|
+
...resourceScripts,
|
|
2605
|
+
...refreshScreenTool,
|
|
2606
|
+
...urlTools,
|
|
2607
|
+
...chatScripts,
|
|
2608
|
+
...toolActions,
|
|
2609
|
+
};
|
|
2377
2610
|
const prodActions = {
|
|
2378
2611
|
...templateScripts,
|
|
2379
2612
|
...resourceScripts,
|
|
@@ -2390,6 +2623,7 @@ export function createAgentChatPlugin(options) {
|
|
|
2390
2623
|
...notificationTools,
|
|
2391
2624
|
...progressTools,
|
|
2392
2625
|
...fetchTool,
|
|
2626
|
+
...toolActions,
|
|
2393
2627
|
...browserTools,
|
|
2394
2628
|
...mcpActionEntries,
|
|
2395
2629
|
};
|
|
@@ -2420,27 +2654,37 @@ export function createAgentChatPlugin(options) {
|
|
|
2420
2654
|
// and tokens that minimal/voice apps don't need.
|
|
2421
2655
|
const leanBasePrompt = (options?.systemPrompt ?? "") + prodActionsPrompt;
|
|
2422
2656
|
// Per-request preamble shared by both prod and dev handlers. Resolves
|
|
2423
|
-
// owner + user API key
|
|
2424
|
-
//
|
|
2425
|
-
//
|
|
2426
|
-
//
|
|
2427
|
-
//
|
|
2657
|
+
// owner + user API key onto the AsyncLocalStorage run context so
|
|
2658
|
+
// downstream tool closures (automation, fetch, team) read the
|
|
2659
|
+
// current request's identity without racing against concurrent
|
|
2660
|
+
// requests. `extraContext` runs in every prompt variant (lean, lazy,
|
|
2661
|
+
// full) — if a template defined it, they opted in; framework-provided
|
|
2662
|
+
// content is what the token-saving modes strip.
|
|
2428
2663
|
const prepareRun = async (event) => {
|
|
2429
|
-
_currentRequestOrigin = getOrigin(event);
|
|
2430
2664
|
const owner = await getOwnerFromEvent(event);
|
|
2431
|
-
_currentRunOwner = owner;
|
|
2432
2665
|
const { getOwnerActiveApiKey } = await import("../agent/production-agent.js");
|
|
2433
|
-
|
|
2666
|
+
const userApiKey = await getOwnerActiveApiKey(owner);
|
|
2667
|
+
const runCtx = ensureRequestRunContext();
|
|
2668
|
+
if (runCtx) {
|
|
2669
|
+
runCtx.requestOrigin = getOrigin(event);
|
|
2670
|
+
runCtx.owner = owner;
|
|
2671
|
+
runCtx.userApiKey = userApiKey;
|
|
2672
|
+
}
|
|
2434
2673
|
const extra = await resolveExtraContext(event, owner);
|
|
2435
2674
|
return { owner, extra };
|
|
2436
2675
|
};
|
|
2676
|
+
const setSystemPromptOnContext = (prompt) => {
|
|
2677
|
+
const runCtx = ensureRequestRunContext();
|
|
2678
|
+
if (runCtx)
|
|
2679
|
+
runCtx.systemPrompt = prompt;
|
|
2680
|
+
return prompt;
|
|
2681
|
+
};
|
|
2437
2682
|
const prodHandler = createProductionAgentHandler({
|
|
2438
|
-
actions: prodActions,
|
|
2683
|
+
actions: leanPrompt ? leanActions : prodActions,
|
|
2439
2684
|
systemPrompt: async (event) => {
|
|
2440
2685
|
const { owner, extra } = await prepareRun(event);
|
|
2441
2686
|
if (leanPrompt) {
|
|
2442
|
-
|
|
2443
|
-
return _currentRunSystemPrompt;
|
|
2687
|
+
return setSystemPromptOnContext(leanBasePrompt + extra);
|
|
2444
2688
|
}
|
|
2445
2689
|
const resources = await loadResourcesForPrompt(owner, lazyContext);
|
|
2446
2690
|
// In lazy context mode, skip embedding the full schema — the agent
|
|
@@ -2448,21 +2692,23 @@ export function createAgentChatPlugin(options) {
|
|
|
2448
2692
|
const schemaBlock = lazyContext
|
|
2449
2693
|
? ""
|
|
2450
2694
|
: await buildSchemaBlock(owner, false);
|
|
2451
|
-
|
|
2452
|
-
basePrompt + resources + schemaBlock + extra;
|
|
2453
|
-
return _currentRunSystemPrompt;
|
|
2695
|
+
return setSystemPromptOnContext(basePrompt + resources + schemaBlock + extra);
|
|
2454
2696
|
},
|
|
2455
|
-
model: options?.model ??
|
|
2456
|
-
(isHostedProd ? "claude-haiku-4-5-20251001" : undefined),
|
|
2697
|
+
model: options?.model ?? DEFAULT_MODEL,
|
|
2457
2698
|
apiKey: options?.apiKey,
|
|
2458
2699
|
skipFilesContext: leanPrompt,
|
|
2459
2700
|
onEngineResolved: (engine, model) => {
|
|
2460
|
-
|
|
2461
|
-
|
|
2701
|
+
const runCtx = ensureRequestRunContext();
|
|
2702
|
+
if (runCtx) {
|
|
2703
|
+
runCtx.engine = engine;
|
|
2704
|
+
runCtx.model = model;
|
|
2705
|
+
}
|
|
2462
2706
|
},
|
|
2463
2707
|
onRunStart: (send, threadId) => {
|
|
2464
2708
|
_runSendByThread.set(threadId, send);
|
|
2465
|
-
|
|
2709
|
+
const runCtx = ensureRequestRunContext();
|
|
2710
|
+
if (runCtx)
|
|
2711
|
+
runCtx.threadId = threadId;
|
|
2466
2712
|
},
|
|
2467
2713
|
onRunComplete: async (run, threadId) => {
|
|
2468
2714
|
if (threadId)
|
|
@@ -2487,28 +2733,31 @@ export function createAgentChatPlugin(options) {
|
|
|
2487
2733
|
// template's actions as native tools instead of routing through shell.
|
|
2488
2734
|
// Templates with structured-arg actions (objects/arrays) need this to
|
|
2489
2735
|
// avoid round-tripping JSON through the CLI parser.
|
|
2490
|
-
const devActions =
|
|
2491
|
-
?
|
|
2492
|
-
:
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2736
|
+
const devActions = leanPrompt
|
|
2737
|
+
? leanActions
|
|
2738
|
+
: devNative
|
|
2739
|
+
? prodActions
|
|
2740
|
+
: {
|
|
2741
|
+
...resourceScripts,
|
|
2742
|
+
...docsScripts,
|
|
2743
|
+
...(lazyContext ? frameworkContextTool : {}),
|
|
2744
|
+
...chatScripts,
|
|
2745
|
+
...callAgentScript,
|
|
2746
|
+
...teamTools,
|
|
2747
|
+
...jobTools,
|
|
2748
|
+
...automationTools,
|
|
2749
|
+
...notificationTools,
|
|
2750
|
+
...progressTools,
|
|
2751
|
+
...fetchTool,
|
|
2752
|
+
...toolActions,
|
|
2753
|
+
...browserTools,
|
|
2754
|
+
...mcpActionEntries,
|
|
2755
|
+
...(await createDevScriptRegistry()),
|
|
2756
|
+
};
|
|
2508
2757
|
// Keep dev action dict in sync with runtime MCP additions. When
|
|
2509
2758
|
// native-actions mode is on (lean or `nativeActionsInDev`), devActions
|
|
2510
2759
|
// === prodActions so the prod listener already covers it.
|
|
2511
|
-
if (devActions !== prodActions) {
|
|
2760
|
+
if (devActions !== prodActions && devActions !== leanActions) {
|
|
2512
2761
|
mcpManager.onChange(() => {
|
|
2513
2762
|
syncMcpActionEntries(mcpManager, devActions);
|
|
2514
2763
|
});
|
|
@@ -2518,27 +2767,29 @@ export function createAgentChatPlugin(options) {
|
|
|
2518
2767
|
systemPrompt: async (event) => {
|
|
2519
2768
|
const { owner, extra } = await prepareRun(event);
|
|
2520
2769
|
if (leanPrompt) {
|
|
2521
|
-
|
|
2522
|
-
return _currentRunSystemPrompt;
|
|
2770
|
+
return setSystemPromptOnContext(leanBasePrompt + extra);
|
|
2523
2771
|
}
|
|
2524
2772
|
const resources = await loadResourcesForPrompt(owner, lazyContext);
|
|
2525
2773
|
const schemaBlock = lazyContext
|
|
2526
2774
|
? ""
|
|
2527
2775
|
: await buildSchemaBlock(owner, true);
|
|
2528
|
-
|
|
2529
|
-
devPrompt + resources + schemaBlock + extra;
|
|
2530
|
-
return _currentRunSystemPrompt;
|
|
2776
|
+
return setSystemPromptOnContext(devPrompt + resources + schemaBlock + extra);
|
|
2531
2777
|
},
|
|
2532
2778
|
model: options?.model,
|
|
2533
2779
|
apiKey: options?.apiKey,
|
|
2534
2780
|
skipFilesContext: leanPrompt,
|
|
2535
2781
|
onEngineResolved: (engine, model) => {
|
|
2536
|
-
|
|
2537
|
-
|
|
2782
|
+
const runCtx = ensureRequestRunContext();
|
|
2783
|
+
if (runCtx) {
|
|
2784
|
+
runCtx.engine = engine;
|
|
2785
|
+
runCtx.model = model;
|
|
2786
|
+
}
|
|
2538
2787
|
},
|
|
2539
2788
|
onRunStart: (send, threadId) => {
|
|
2540
2789
|
_runSendByThread.set(threadId, send);
|
|
2541
|
-
|
|
2790
|
+
const runCtx = ensureRequestRunContext();
|
|
2791
|
+
if (runCtx)
|
|
2792
|
+
runCtx.threadId = threadId;
|
|
2542
2793
|
},
|
|
2543
2794
|
onRunComplete: async (run, threadId) => {
|
|
2544
2795
|
if (threadId)
|
|
@@ -2586,10 +2837,11 @@ export function createAgentChatPlugin(options) {
|
|
|
2586
2837
|
return { devMode: currentDevMode, canToggle };
|
|
2587
2838
|
}));
|
|
2588
2839
|
// Mount save-key BEFORE the prefix handler so it isn't shadowed.
|
|
2589
|
-
// Persists the user's key
|
|
2590
|
-
//
|
|
2591
|
-
//
|
|
2592
|
-
//
|
|
2840
|
+
// Persists the user's API key in `app_secrets` (encrypted, scope=user,
|
|
2841
|
+
// scopeId=email). Hard rule: never mutates process.env, never writes
|
|
2842
|
+
// .env. User-pasted secrets must not become deploy-level identity —
|
|
2843
|
+
// that's the cross-tenant leak class (KVesta Space, 2026-04).
|
|
2844
|
+
// Consumers read these values per-request via `resolveSecret(key)`.
|
|
2593
2845
|
getH3App(nitroApp).use(`${routePath}/save-key`, defineEventHandler(async (event) => {
|
|
2594
2846
|
if (getMethod(event) !== "POST") {
|
|
2595
2847
|
setResponseStatus(event, 405);
|
|
@@ -2603,75 +2855,35 @@ export function createAgentChatPlugin(options) {
|
|
|
2603
2855
|
return { error: "API key is required" };
|
|
2604
2856
|
}
|
|
2605
2857
|
const trimmedKey = key.trim();
|
|
2606
|
-
// Persist per-owner so the key survives cold starts in serverless
|
|
2607
|
-
// and so the user's key isn't shared across users on multi-tenant
|
|
2608
|
-
// hosted deployments. We require a real authenticated owner here —
|
|
2609
|
-
// `local@localhost` is the unauthenticated fallback and must never
|
|
2610
|
-
// become the shared key bucket on hosted deployments.
|
|
2611
2858
|
const ownerEmail = await getOwnerFromEvent(event);
|
|
2612
|
-
if (
|
|
2613
|
-
(!ownerEmail || ownerEmail === "local@localhost")) {
|
|
2859
|
+
if (!ownerEmail || ownerEmail === DEV_MODE_USER_EMAIL) {
|
|
2614
2860
|
setResponseStatus(event, 401);
|
|
2615
2861
|
return { error: "Authentication required" };
|
|
2616
2862
|
}
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
}
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
};
|
|
2641
|
-
}
|
|
2642
|
-
// Local dev falls through to the env-file path below.
|
|
2643
|
-
}
|
|
2644
|
-
}
|
|
2645
|
-
// In hosted/multi-tenant mode we deliberately do NOT touch
|
|
2646
|
-
// process.env or .env: the per-owner SQL lookup above is the
|
|
2647
|
-
// single source of truth, and overwriting the shared env key
|
|
2648
|
-
// would leak one tenant's credentials into every subsequent
|
|
2649
|
-
// request that hit the same warm instance without its own key.
|
|
2650
|
-
if (!isHostedProd) {
|
|
2651
|
-
const providerToEnv = {
|
|
2652
|
-
anthropic: "ANTHROPIC_API_KEY",
|
|
2653
|
-
openai: "OPENAI_API_KEY",
|
|
2654
|
-
google: "GOOGLE_GENERATIVE_AI_API_KEY",
|
|
2655
|
-
groq: "GROQ_API_KEY",
|
|
2656
|
-
mistral: "MISTRAL_API_KEY",
|
|
2657
|
-
cohere: "COHERE_API_KEY",
|
|
2863
|
+
const providerToEnv = {
|
|
2864
|
+
anthropic: "ANTHROPIC_API_KEY",
|
|
2865
|
+
openai: "OPENAI_API_KEY",
|
|
2866
|
+
google: "GOOGLE_GENERATIVE_AI_API_KEY",
|
|
2867
|
+
groq: "GROQ_API_KEY",
|
|
2868
|
+
mistral: "MISTRAL_API_KEY",
|
|
2869
|
+
cohere: "COHERE_API_KEY",
|
|
2870
|
+
};
|
|
2871
|
+
const secretKey = providerToEnv[provider] ?? `${provider.toUpperCase()}_API_KEY`;
|
|
2872
|
+
try {
|
|
2873
|
+
const { writeAppSecret } = await import("../secrets/storage.js");
|
|
2874
|
+
await writeAppSecret({
|
|
2875
|
+
key: secretKey,
|
|
2876
|
+
value: trimmedKey,
|
|
2877
|
+
scope: "user",
|
|
2878
|
+
scopeId: ownerEmail,
|
|
2879
|
+
});
|
|
2880
|
+
}
|
|
2881
|
+
catch (err) {
|
|
2882
|
+
console.error("[agent-chat] save-key persistence failed:", err instanceof Error ? err.message : err);
|
|
2883
|
+
setResponseStatus(event, 500);
|
|
2884
|
+
return {
|
|
2885
|
+
error: "Failed to persist API key. Please try again or contact support.",
|
|
2658
2886
|
};
|
|
2659
|
-
const envVar = providerToEnv[provider] ?? `${provider.toUpperCase()}_API_KEY`;
|
|
2660
|
-
try {
|
|
2661
|
-
const path = await import("path");
|
|
2662
|
-
const { upsertEnvFile } = await import("./create-server.js");
|
|
2663
|
-
const envPath = path.join(process.cwd(), ".env");
|
|
2664
|
-
await upsertEnvFile(envPath, [
|
|
2665
|
-
{ key: envVar, value: trimmedKey },
|
|
2666
|
-
]);
|
|
2667
|
-
}
|
|
2668
|
-
catch {
|
|
2669
|
-
// Edge runtime — can't write .env, but can still update process.env
|
|
2670
|
-
}
|
|
2671
|
-
// Update process.env so the agent works immediately in the
|
|
2672
|
-
// current local-dev invocation; the SQL persist above covers
|
|
2673
|
-
// future invocations.
|
|
2674
|
-
process.env[envVar] = trimmedKey;
|
|
2675
2887
|
}
|
|
2676
2888
|
return { ok: true };
|
|
2677
2889
|
}));
|
|
@@ -2709,7 +2921,7 @@ export function createAgentChatPlugin(options) {
|
|
|
2709
2921
|
// Query resources
|
|
2710
2922
|
try {
|
|
2711
2923
|
const resources = currentDevMode
|
|
2712
|
-
? await resourceListAccessible(
|
|
2924
|
+
? await resourceListAccessible(DEV_MODE_USER_EMAIL)
|
|
2713
2925
|
: await resourceList(SHARED_OWNER);
|
|
2714
2926
|
for (const r of resources) {
|
|
2715
2927
|
if (!seen.has(r.path)) {
|
|
@@ -2794,7 +3006,7 @@ export function createAgentChatPlugin(options) {
|
|
|
2794
3006
|
// Query resources with skills/ prefix
|
|
2795
3007
|
try {
|
|
2796
3008
|
const resourceSkills = currentDevMode
|
|
2797
|
-
? await resourceListAccessible(
|
|
3009
|
+
? await resourceListAccessible(DEV_MODE_USER_EMAIL, "skills/")
|
|
2798
3010
|
: await resourceList(SHARED_OWNER, "skills/");
|
|
2799
3011
|
for (const r of resourceSkills) {
|
|
2800
3012
|
// Try to get content to parse frontmatter
|
|
@@ -2839,6 +3051,22 @@ export function createAgentChatPlugin(options) {
|
|
|
2839
3051
|
setResponseStatus(event, 405);
|
|
2840
3052
|
return { error: "Method not allowed" };
|
|
2841
3053
|
}
|
|
3054
|
+
// Resolve the caller and run the entire stream inside a request
|
|
3055
|
+
// context so custom mention providers can use `accessFilter` /
|
|
3056
|
+
// `resolveAccess` when querying ownable tables. Without this,
|
|
3057
|
+
// a provider that searches `decks` (or any sharable resource)
|
|
3058
|
+
// would see every row regardless of ownership.
|
|
3059
|
+
const mentionsOwner = await getOwnerFromEvent(event).catch(() => undefined);
|
|
3060
|
+
let mentionsOrgId;
|
|
3061
|
+
if (options?.resolveOrgId) {
|
|
3062
|
+
try {
|
|
3063
|
+
const resolved = await options.resolveOrgId(event);
|
|
3064
|
+
mentionsOrgId = resolved ?? undefined;
|
|
3065
|
+
}
|
|
3066
|
+
catch {
|
|
3067
|
+
mentionsOrgId = undefined;
|
|
3068
|
+
}
|
|
3069
|
+
}
|
|
2842
3070
|
const query = getQuery(event);
|
|
2843
3071
|
const q = typeof query.q === "string" ? query.q.toLowerCase() : "";
|
|
2844
3072
|
const matchesQuery = (item) => !q ||
|
|
@@ -2849,148 +3077,154 @@ export function createAgentChatPlugin(options) {
|
|
|
2849
3077
|
setResponseHeader(event, "Content-Type", "application/x-ndjson");
|
|
2850
3078
|
setResponseHeader(event, "Cache-Control", "no-cache");
|
|
2851
3079
|
const stream = new ReadableStream({
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2876
|
-
|
|
2877
|
-
// 1. Resources from SQL (fast — flush first)
|
|
2878
|
-
sources.push((async () => {
|
|
3080
|
+
start(controller) {
|
|
3081
|
+
return runWithRequestContext({
|
|
3082
|
+
userEmail: mentionsOwner,
|
|
3083
|
+
orgId: mentionsOrgId,
|
|
3084
|
+
}, () => mentionsStreamWork(controller));
|
|
3085
|
+
},
|
|
3086
|
+
cancel() {
|
|
3087
|
+
// Client disconnected — stop enqueuing
|
|
3088
|
+
},
|
|
3089
|
+
});
|
|
3090
|
+
return stream;
|
|
3091
|
+
async function mentionsStreamWork(controller) {
|
|
3092
|
+
const MAX_RESULTS = 50;
|
|
3093
|
+
let totalSent = 0;
|
|
3094
|
+
let cancelled = false;
|
|
3095
|
+
const flush = (batch) => {
|
|
3096
|
+
if (cancelled)
|
|
3097
|
+
return;
|
|
3098
|
+
const filtered = batch.filter(matchesQuery);
|
|
3099
|
+
if (filtered.length === 0)
|
|
3100
|
+
return;
|
|
3101
|
+
const remaining = MAX_RESULTS - totalSent;
|
|
3102
|
+
const toSend = filtered.slice(0, remaining);
|
|
3103
|
+
if (toSend.length > 0) {
|
|
3104
|
+
totalSent += toSend.length;
|
|
2879
3105
|
try {
|
|
2880
|
-
|
|
2881
|
-
? await resourceListAccessible("local@localhost")
|
|
2882
|
-
: await resourceList(SHARED_OWNER);
|
|
2883
|
-
flush(resources.map((r) => {
|
|
2884
|
-
const isShared = r.owner === SHARED_OWNER;
|
|
2885
|
-
return {
|
|
2886
|
-
id: `resource:${r.path}`,
|
|
2887
|
-
label: r.path.split("/").pop() || r.path,
|
|
2888
|
-
description: r.path,
|
|
2889
|
-
icon: "file",
|
|
2890
|
-
source: isShared
|
|
2891
|
-
? "resource:shared"
|
|
2892
|
-
: "resource:private",
|
|
2893
|
-
refType: "file",
|
|
2894
|
-
refPath: r.path,
|
|
2895
|
-
section: "Files",
|
|
2896
|
-
};
|
|
2897
|
-
}));
|
|
3106
|
+
controller.enqueue(enc.encode(JSON.stringify({ items: toSend }) + "\n"));
|
|
2898
3107
|
}
|
|
2899
|
-
catch {
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
3108
|
+
catch {
|
|
3109
|
+
// Stream was closed by client
|
|
3110
|
+
cancelled = true;
|
|
3111
|
+
}
|
|
3112
|
+
}
|
|
3113
|
+
};
|
|
3114
|
+
// All sources run in parallel; each flushes independently.
|
|
3115
|
+
const sources = [];
|
|
3116
|
+
// 1. Resources from SQL (fast — flush first)
|
|
3117
|
+
sources.push((async () => {
|
|
3118
|
+
try {
|
|
3119
|
+
const resources = currentDevMode
|
|
3120
|
+
? await resourceListAccessible(DEV_MODE_USER_EMAIL)
|
|
3121
|
+
: await resourceList(SHARED_OWNER);
|
|
3122
|
+
flush(resources.map((r) => {
|
|
3123
|
+
const isShared = r.owner === SHARED_OWNER;
|
|
3124
|
+
return {
|
|
3125
|
+
id: `resource:${r.path}`,
|
|
3126
|
+
label: r.path.split("/").pop() || r.path,
|
|
3127
|
+
description: r.path,
|
|
3128
|
+
icon: "file",
|
|
3129
|
+
source: isShared
|
|
3130
|
+
? "resource:shared"
|
|
3131
|
+
: "resource:private",
|
|
2915
3132
|
refType: "file",
|
|
2916
|
-
refPath:
|
|
3133
|
+
refPath: r.path,
|
|
2917
3134
|
section: "Files",
|
|
2918
|
-
}
|
|
2919
|
-
})
|
|
3135
|
+
};
|
|
3136
|
+
}));
|
|
2920
3137
|
}
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
const providerItems = await provider.search(q, event);
|
|
2926
|
-
flush(providerItems.map((item) => ({
|
|
2927
|
-
id: item.id,
|
|
2928
|
-
label: item.label,
|
|
2929
|
-
description: item.description,
|
|
2930
|
-
icon: item.icon || provider.icon || "file",
|
|
2931
|
-
source: key,
|
|
2932
|
-
refType: item.refType,
|
|
2933
|
-
refPath: item.refPath,
|
|
2934
|
-
refId: item.refId,
|
|
2935
|
-
section: provider.label,
|
|
2936
|
-
})));
|
|
2937
|
-
}
|
|
2938
|
-
catch (e) {
|
|
2939
|
-
console.error(`[agent-native] Mention provider "${key}" failed:`, e);
|
|
2940
|
-
}
|
|
2941
|
-
})());
|
|
2942
|
-
}
|
|
2943
|
-
// 4. Custom workspace agents
|
|
3138
|
+
catch { }
|
|
3139
|
+
})());
|
|
3140
|
+
// 2. Codebase files (dev mode only — can be slow on large repos)
|
|
3141
|
+
if (currentDevMode) {
|
|
2944
3142
|
sources.push((async () => {
|
|
3143
|
+
const codebaseFiles = [];
|
|
2945
3144
|
try {
|
|
2946
|
-
|
|
2947
|
-
const { listAccessibleCustomAgents } = await import("../resources/agents.js");
|
|
2948
|
-
const agents = await listAccessibleCustomAgents(owner);
|
|
2949
|
-
flush(agents.map((agent) => ({
|
|
2950
|
-
id: `custom-agent:${agent.id}`,
|
|
2951
|
-
label: agent.name,
|
|
2952
|
-
description: agent.description || agent.path,
|
|
2953
|
-
icon: "agent",
|
|
2954
|
-
source: "agent:custom",
|
|
2955
|
-
refType: "custom-agent",
|
|
2956
|
-
refPath: agent.path,
|
|
2957
|
-
refId: agent.id,
|
|
2958
|
-
section: "Agents",
|
|
2959
|
-
})));
|
|
2960
|
-
}
|
|
2961
|
-
catch (e) {
|
|
2962
|
-
console.error("[agent-native] Custom agent discovery failed:", e);
|
|
3145
|
+
await collectFiles(process.cwd(), "", 0, codebaseFiles);
|
|
2963
3146
|
}
|
|
3147
|
+
catch { }
|
|
3148
|
+
flush(codebaseFiles.map((f) => ({
|
|
3149
|
+
id: `codebase:${f.path}`,
|
|
3150
|
+
label: f.name,
|
|
3151
|
+
description: f.path !== f.name ? f.path : undefined,
|
|
3152
|
+
icon: f.type,
|
|
3153
|
+
source: "codebase",
|
|
3154
|
+
refType: "file",
|
|
3155
|
+
refPath: f.path,
|
|
3156
|
+
section: "Files",
|
|
3157
|
+
})));
|
|
2964
3158
|
})());
|
|
2965
|
-
|
|
3159
|
+
}
|
|
3160
|
+
// 3. Custom mention providers (each flushes independently)
|
|
3161
|
+
for (const [key, provider] of Object.entries(mentionProviders)) {
|
|
2966
3162
|
sources.push((async () => {
|
|
2967
3163
|
try {
|
|
2968
|
-
const
|
|
2969
|
-
flush(
|
|
2970
|
-
id:
|
|
2971
|
-
label:
|
|
2972
|
-
description:
|
|
2973
|
-
icon: "
|
|
2974
|
-
source:
|
|
2975
|
-
refType:
|
|
2976
|
-
refPath:
|
|
2977
|
-
refId:
|
|
2978
|
-
section:
|
|
3164
|
+
const providerItems = await provider.search(q, event);
|
|
3165
|
+
flush(providerItems.map((item) => ({
|
|
3166
|
+
id: item.id,
|
|
3167
|
+
label: item.label,
|
|
3168
|
+
description: item.description,
|
|
3169
|
+
icon: item.icon || provider.icon || "file",
|
|
3170
|
+
source: key,
|
|
3171
|
+
refType: item.refType,
|
|
3172
|
+
refPath: item.refPath,
|
|
3173
|
+
refId: item.refId,
|
|
3174
|
+
section: provider.label,
|
|
2979
3175
|
})));
|
|
2980
3176
|
}
|
|
2981
3177
|
catch (e) {
|
|
2982
|
-
console.error(
|
|
3178
|
+
console.error(`[agent-native] Mention provider "${key}" failed:`, e);
|
|
2983
3179
|
}
|
|
2984
3180
|
})());
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
3181
|
+
}
|
|
3182
|
+
// 4. Custom workspace agents
|
|
3183
|
+
sources.push((async () => {
|
|
3184
|
+
try {
|
|
3185
|
+
const owner = await getOwnerFromEvent(event);
|
|
3186
|
+
const { listAccessibleCustomAgents } = await import("../resources/agents.js");
|
|
3187
|
+
const agents = await listAccessibleCustomAgents(owner);
|
|
3188
|
+
flush(agents.map((agent) => ({
|
|
3189
|
+
id: `custom-agent:${agent.id}`,
|
|
3190
|
+
label: agent.name,
|
|
3191
|
+
description: agent.description || agent.path,
|
|
3192
|
+
icon: "agent",
|
|
3193
|
+
source: "agent:custom",
|
|
3194
|
+
refType: "custom-agent",
|
|
3195
|
+
refPath: agent.path,
|
|
3196
|
+
refId: agent.id,
|
|
3197
|
+
section: "Agents",
|
|
3198
|
+
})));
|
|
3199
|
+
}
|
|
3200
|
+
catch (e) {
|
|
3201
|
+
console.error("[agent-native] Custom agent discovery failed:", e);
|
|
3202
|
+
}
|
|
3203
|
+
})());
|
|
3204
|
+
// 5. Peer agent discovery (network call — often slowest)
|
|
3205
|
+
sources.push((async () => {
|
|
3206
|
+
try {
|
|
3207
|
+
const agents = await discoverAgents(options?.appId);
|
|
3208
|
+
flush(agents.map((agent) => ({
|
|
3209
|
+
id: `agent:${agent.id}`,
|
|
3210
|
+
label: agent.name,
|
|
3211
|
+
description: agent.description,
|
|
3212
|
+
icon: "agent",
|
|
3213
|
+
source: "agent",
|
|
3214
|
+
refType: "agent",
|
|
3215
|
+
refPath: agent.url,
|
|
3216
|
+
refId: agent.id,
|
|
3217
|
+
section: "Connected Agents",
|
|
3218
|
+
})));
|
|
3219
|
+
}
|
|
3220
|
+
catch (e) {
|
|
3221
|
+
console.error("[agent-native] Agent discovery failed:", e);
|
|
3222
|
+
}
|
|
3223
|
+
})());
|
|
3224
|
+
await Promise.all(sources);
|
|
3225
|
+
if (!cancelled)
|
|
3226
|
+
controller.close();
|
|
3227
|
+
}
|
|
2994
3228
|
}));
|
|
2995
3229
|
// ─── Generate thread title ──────────────────────────────────────────
|
|
2996
3230
|
getH3App(nitroApp).use(`${routePath}/generate-title`, defineEventHandler(async (event) => {
|
|
@@ -2999,6 +3233,19 @@ export function createAgentChatPlugin(options) {
|
|
|
2999
3233
|
return { error: "Method not allowed" };
|
|
3000
3234
|
}
|
|
3001
3235
|
const ownerEmail = await getOwnerFromEvent(event);
|
|
3236
|
+
// Per-user rate limit: 10 calls / 60s. Prevents an authenticated
|
|
3237
|
+
// user from spamming the endpoint to exhaust shared Anthropic
|
|
3238
|
+
// credits on platform-key deployments.
|
|
3239
|
+
const now = Date.now();
|
|
3240
|
+
const limitWindowMs = 60_000;
|
|
3241
|
+
const limitMax = 10;
|
|
3242
|
+
const recent = (generateTitleRateLimit.get(ownerEmail) ?? []).filter((t) => now - t < limitWindowMs);
|
|
3243
|
+
if (recent.length >= limitMax) {
|
|
3244
|
+
setResponseStatus(event, 429);
|
|
3245
|
+
return { error: "Rate limit exceeded" };
|
|
3246
|
+
}
|
|
3247
|
+
recent.push(now);
|
|
3248
|
+
generateTitleRateLimit.set(ownerEmail, recent);
|
|
3002
3249
|
const body = await readBody(event);
|
|
3003
3250
|
const message = body?.message;
|
|
3004
3251
|
if (!message || typeof message !== "string") {
|
|
@@ -3091,10 +3338,15 @@ export function createAgentChatPlugin(options) {
|
|
|
3091
3338
|
// Check in-memory first, then SQL (cross-isolate on Workers)
|
|
3092
3339
|
const run = await getActiveRunForThreadAsync(threadId);
|
|
3093
3340
|
if (!run) {
|
|
3094
|
-
|
|
3095
|
-
|
|
3341
|
+
return {
|
|
3342
|
+
active: false,
|
|
3343
|
+
threadId,
|
|
3344
|
+
status: "idle",
|
|
3345
|
+
heartbeatAt: null,
|
|
3346
|
+
};
|
|
3096
3347
|
}
|
|
3097
3348
|
return {
|
|
3349
|
+
active: true,
|
|
3098
3350
|
runId: run.runId,
|
|
3099
3351
|
threadId: run.threadId,
|
|
3100
3352
|
status: run.status,
|
|
@@ -3288,6 +3540,19 @@ export function createAgentChatPlugin(options) {
|
|
|
3288
3540
|
await setThreadQueuedMessages(threadId, queued);
|
|
3289
3541
|
return { ok: true };
|
|
3290
3542
|
}
|
|
3543
|
+
// POST /threads/:id/fork — duplicate a thread with all its messages
|
|
3544
|
+
if (method === "POST" &&
|
|
3545
|
+
/\/threads\/[^/?]+\/fork/.test(event.node?.req?.url || event.path || "")) {
|
|
3546
|
+
const body = await readBody(event);
|
|
3547
|
+
const forked = await forkThread(threadId, owner, {
|
|
3548
|
+
id: body?.id,
|
|
3549
|
+
});
|
|
3550
|
+
if (!forked) {
|
|
3551
|
+
setResponseStatus(event, 404);
|
|
3552
|
+
return { error: "Thread not found" };
|
|
3553
|
+
}
|
|
3554
|
+
return forked;
|
|
3555
|
+
}
|
|
3291
3556
|
if (method === "DELETE") {
|
|
3292
3557
|
const thread = await getThread(threadId);
|
|
3293
3558
|
if (!thread || thread.ownerEmail !== owner) {
|
|
@@ -3353,14 +3618,6 @@ export function createAgentChatPlugin(options) {
|
|
|
3353
3618
|
// Session not available
|
|
3354
3619
|
}
|
|
3355
3620
|
}
|
|
3356
|
-
// Also set process.env for backwards compat (CLI scripts, legacy readers)
|
|
3357
|
-
process.env.AGENT_USER_EMAIL = owner;
|
|
3358
|
-
if (resolvedOrgId) {
|
|
3359
|
-
process.env.AGENT_ORG_ID = resolvedOrgId;
|
|
3360
|
-
}
|
|
3361
|
-
else {
|
|
3362
|
-
delete process.env.AGENT_ORG_ID;
|
|
3363
|
-
}
|
|
3364
3621
|
// Propagate the caller's IANA timezone from `x-user-timezone` so that
|
|
3365
3622
|
// tool calls made by the agent (e.g. log-meal with no explicit date)
|
|
3366
3623
|
// resolve "today" in the user's local timezone instead of server UTC.
|
|
@@ -3370,8 +3627,6 @@ export function createAgentChatPlugin(options) {
|
|
|
3370
3627
|
tzRaw.trim().length < 64
|
|
3371
3628
|
? tzRaw.trim()
|
|
3372
3629
|
: undefined;
|
|
3373
|
-
if (timezone)
|
|
3374
|
-
process.env.AGENT_USER_TIMEZONE = timezone;
|
|
3375
3630
|
return runWithRequestContext({ userEmail: owner, orgId: resolvedOrgId, timezone }, () => {
|
|
3376
3631
|
const handler = currentDevMode && devHandler ? devHandler : prodHandler;
|
|
3377
3632
|
return handler(event);
|
|
@@ -3395,6 +3650,7 @@ export function createAgentChatPlugin(options) {
|
|
|
3395
3650
|
...notificationTools,
|
|
3396
3651
|
...progressTools,
|
|
3397
3652
|
...fetchTool,
|
|
3653
|
+
...toolActions,
|
|
3398
3654
|
}),
|
|
3399
3655
|
getSystemPrompt: async (owner) => {
|
|
3400
3656
|
const resources = await loadResourcesForPrompt(owner, lazyContext);
|
|
@@ -3435,6 +3691,7 @@ export function createAgentChatPlugin(options) {
|
|
|
3435
3691
|
...notificationTools,
|
|
3436
3692
|
...progressTools,
|
|
3437
3693
|
...fetchTool,
|
|
3694
|
+
...toolActions,
|
|
3438
3695
|
}),
|
|
3439
3696
|
getSystemPrompt: async (owner) => {
|
|
3440
3697
|
const resources = await loadResourcesForPrompt(owner, lazyContext);
|
|
@@ -3488,9 +3745,10 @@ export function getGlobalMcpManager() {
|
|
|
3488
3745
|
return _globalMcpManager;
|
|
3489
3746
|
}
|
|
3490
3747
|
function mountMcpHubStatusRoute(nitroApp) {
|
|
3491
|
-
|
|
3748
|
+
const mountedApps = (globalThis.__agentNativeMcpHubStatusMountedApps ??= new WeakSet());
|
|
3749
|
+
if (mountedApps.has(nitroApp))
|
|
3492
3750
|
return;
|
|
3493
|
-
|
|
3751
|
+
mountedApps.add(nitroApp);
|
|
3494
3752
|
try {
|
|
3495
3753
|
getH3App(nitroApp).use("/_agent-native/mcp/hub/status", defineEventHandler(async (event) => {
|
|
3496
3754
|
if (getMethod(event) !== "GET") {
|
|
@@ -3506,10 +3764,11 @@ function mountMcpHubStatusRoute(nitroApp) {
|
|
|
3506
3764
|
}
|
|
3507
3765
|
}
|
|
3508
3766
|
function mountMcpStatusRoute(nitroApp, manager) {
|
|
3509
|
-
// Idempotent
|
|
3510
|
-
|
|
3767
|
+
// Idempotent per Nitro app; dev-all may host multiple templates in one process.
|
|
3768
|
+
const mountedApps = (globalThis.__agentNativeMcpStatusMountedApps ??= new WeakSet());
|
|
3769
|
+
if (mountedApps.has(nitroApp))
|
|
3511
3770
|
return;
|
|
3512
|
-
|
|
3771
|
+
mountedApps.add(nitroApp);
|
|
3513
3772
|
try {
|
|
3514
3773
|
getH3App(nitroApp).use("/_agent-native/mcp/status", defineEventHandler(async (event) => {
|
|
3515
3774
|
if (getMethod(event) !== "GET") {
|