@agent-native/core 0.145.5 → 0.145.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/corpus/README.md +1 -1
- package/corpus/templates/analytics/.agents/skills/actions/SKILL.md +18 -0
- package/corpus/templates/analytics/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
- package/corpus/templates/analytics/.agents/skills/dashboard-management/SKILL.md +17 -1
- package/corpus/templates/analytics/.agents/skills/delegate-to-agent/SKILL.md +45 -47
- package/corpus/templates/analytics/.agents/skills/frontend-design/SKILL.md +1 -0
- package/corpus/templates/analytics/.agents/skills/gong/SKILL.md +22 -3
- package/corpus/templates/analytics/.agents/skills/turn-into-app/SKILL.md +76 -23
- package/corpus/templates/analytics/.agents/skills/turn-into-app/agents/openai.yaml +2 -2
- package/corpus/templates/analytics/.agents/skills/turn-into-app/references/fresh-project.md +64 -0
- package/corpus/templates/analytics/AGENTS.md +2 -1
- package/corpus/templates/analytics/actions/account-deep-dive.ts +83 -47
- package/corpus/templates/analytics/actions/create-dashboard-folder.ts +27 -0
- package/corpus/templates/analytics/actions/gong-calls.ts +3 -3
- package/corpus/templates/analytics/actions/list-dashboard-folders.ts +26 -0
- package/corpus/templates/analytics/actions/list-sql-dashboards.ts +1 -0
- package/corpus/templates/analytics/actions/set-dashboard-folder.ts +26 -0
- package/corpus/templates/analytics/app/components/ProviderCorpusJobNotifier.tsx +18 -3
- package/corpus/templates/analytics/app/components/layout/CommandPalette.tsx +6 -4
- package/corpus/templates/analytics/app/components/layout/Header.tsx +1 -0
- package/corpus/templates/analytics/app/components/layout/NewDashboardDialog.tsx +12 -2
- package/corpus/templates/analytics/app/components/layout/Sidebar.tsx +35 -20
- package/corpus/templates/analytics/app/global.css +17 -0
- package/corpus/templates/analytics/app/hooks/use-dashboard-revisions.ts +29 -15
- package/corpus/templates/analytics/app/hooks/use-dashboard-views.ts +15 -3
- package/corpus/templates/analytics/app/i18n-data.ts +296 -0
- package/corpus/templates/analytics/app/lib/prefetch-keys.ts +23 -2
- package/corpus/templates/analytics/app/pages/DashboardOverview.tsx +642 -0
- package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/index.tsx +66 -31
- package/corpus/templates/analytics/app/root.tsx +4 -0
- package/corpus/templates/analytics/app/routes/dashboards._index.tsx +5 -1
- package/corpus/templates/analytics/changelog/2026-08-07-added-a-dashboards-overview-with-personal-and-shared-folders.md +6 -0
- package/corpus/templates/analytics/changelog/2026-08-07-analytics-no-longer-stalls-under-bursts-of-event-ingest-key-.md +6 -0
- package/corpus/templates/analytics/changelog/2026-08-07-analytics-tracking-and-chat-startup-no-longer-emit-avoidable.md +6 -0
- package/corpus/templates/analytics/changelog/2026-08-07-dashboard-panels-now-load-custom-api-data-programs-reliably.md +6 -0
- package/corpus/templates/analytics/changelog/2026-08-07-gong-searches-conserve-api-quota-and-report-incomplete-coverage.md +6 -0
- package/corpus/templates/analytics/changelog/2026-08-07-searchable-dashboards-make-personal-and-shared-folders-easie.md +6 -0
- package/corpus/templates/analytics/netlify.toml +3 -0
- package/corpus/templates/analytics/scripts/emit-netlify-dashboard-report-cron.ts +112 -0
- package/corpus/templates/analytics/server/db/index.ts +12 -0
- package/corpus/templates/analytics/server/db/schema.ts +14 -0
- package/corpus/templates/analytics/server/jobs/analytics-rollup-backfill.ts +4 -0
- package/corpus/templates/analytics/server/lib/agent-chat-plan-mode.ts +1 -0
- package/corpus/templates/analytics/server/lib/analytics-query-catalog.ts +85 -15
- package/corpus/templates/analytics/server/lib/dashboard-folders-store.ts +168 -0
- package/corpus/templates/analytics/server/lib/dashboard-panel-query.ts +9 -4
- package/corpus/templates/analytics/server/lib/dashboards-store.ts +116 -1
- package/corpus/templates/analytics/server/lib/first-party-analytics-rollups.ts +4 -8
- package/corpus/templates/analytics/server/lib/first-party-analytics.ts +65 -10
- package/corpus/templates/analytics/server/lib/gong.ts +139 -78
- package/corpus/templates/analytics/server/lib/session-replay.ts +5 -5
- package/corpus/templates/analytics/server/plugins/db.ts +55 -15
- package/corpus/templates/analytics/server/plugins/session-replay-retention-jobs.ts +6 -2
- package/corpus/templates/analytics/server/routes/api/session-replay/retention.post.ts +65 -0
- package/corpus/templates/assets/.agents/skills/actions/SKILL.md +18 -0
- package/corpus/templates/assets/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
- package/corpus/templates/assets/.agents/skills/delegate-to-agent/SKILL.md +45 -47
- package/corpus/templates/assets/.agents/skills/frontend-design/SKILL.md +1 -0
- package/corpus/templates/assets/.agents/skills/turn-into-app/SKILL.md +76 -23
- package/corpus/templates/assets/.agents/skills/turn-into-app/agents/openai.yaml +2 -2
- package/corpus/templates/assets/.agents/skills/turn-into-app/references/fresh-project.md +64 -0
- package/corpus/templates/brain/.agents/skills/actions/SKILL.md +18 -0
- package/corpus/templates/brain/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
- package/corpus/templates/brain/.agents/skills/delegate-to-agent/SKILL.md +45 -47
- package/corpus/templates/brain/.agents/skills/frontend-design/SKILL.md +1 -0
- package/corpus/templates/brain/.agents/skills/turn-into-app/SKILL.md +76 -23
- package/corpus/templates/brain/.agents/skills/turn-into-app/agents/openai.yaml +2 -2
- package/corpus/templates/brain/.agents/skills/turn-into-app/references/fresh-project.md +64 -0
- package/corpus/templates/calendar/.agents/skills/actions/SKILL.md +18 -0
- package/corpus/templates/calendar/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
- package/corpus/templates/calendar/.agents/skills/delegate-to-agent/SKILL.md +45 -47
- package/corpus/templates/calendar/.agents/skills/frontend-design/SKILL.md +1 -0
- package/corpus/templates/calendar/.agents/skills/turn-into-app/SKILL.md +76 -23
- package/corpus/templates/calendar/.agents/skills/turn-into-app/agents/openai.yaml +2 -2
- package/corpus/templates/calendar/.agents/skills/turn-into-app/references/fresh-project.md +64 -0
- package/corpus/templates/chat/.agents/skills/actions/SKILL.md +18 -0
- package/corpus/templates/chat/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
- package/corpus/templates/chat/.agents/skills/delegate-to-agent/SKILL.md +45 -47
- package/corpus/templates/chat/.agents/skills/frontend-design/SKILL.md +1 -0
- package/corpus/templates/chat/.agents/skills/turn-into-app/SKILL.md +76 -23
- package/corpus/templates/chat/.agents/skills/turn-into-app/agents/openai.yaml +2 -2
- package/corpus/templates/chat/.agents/skills/turn-into-app/references/fresh-project.md +64 -0
- package/corpus/templates/chat/.env.example +3 -0
- package/corpus/templates/chat/AGENTS.md +4 -0
- package/corpus/templates/clips/.agents/skills/actions/SKILL.md +18 -0
- package/corpus/templates/clips/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
- package/corpus/templates/clips/.agents/skills/delegate-to-agent/SKILL.md +45 -47
- package/corpus/templates/clips/.agents/skills/frontend-design/SKILL.md +1 -0
- package/corpus/templates/clips/.agents/skills/turn-into-app/SKILL.md +76 -23
- package/corpus/templates/clips/.agents/skills/turn-into-app/agents/openai.yaml +2 -2
- package/corpus/templates/clips/.agents/skills/turn-into-app/references/fresh-project.md +64 -0
- package/corpus/templates/clips/actions/lib/audio-only-transcription.ts +4 -0
- package/corpus/templates/clips/actions/request-transcript.ts +52 -3
- package/corpus/templates/clips/app/components/recorder/recorder-engine.ts +3 -10
- package/corpus/templates/clips/app/routes/r.$recordingId.tsx +1 -0
- package/corpus/templates/clips/changelog/2026-08-07-screen-recordings-now-capture-tab-and-system-audio-even-when.md +6 -0
- package/corpus/templates/clips/changelog/2026-08-07-transcription-now-retries-transient-cloud-failures-automatic.md +6 -0
- package/corpus/templates/clips/server/db/schema.ts +7 -0
- package/corpus/templates/clips/server/plugins/db.ts +8 -0
- package/corpus/templates/clips/shared/recording-capture.ts +38 -0
- package/corpus/templates/clips/shared/transcript-failure.ts +89 -0
- package/corpus/templates/content/.agents/skills/actions/SKILL.md +18 -0
- package/corpus/templates/content/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
- package/corpus/templates/content/.agents/skills/delegate-to-agent/SKILL.md +45 -47
- package/corpus/templates/content/.agents/skills/frontend-design/SKILL.md +1 -0
- package/corpus/templates/content/.agents/skills/turn-into-app/SKILL.md +76 -23
- package/corpus/templates/content/.agents/skills/turn-into-app/agents/openai.yaml +2 -2
- package/corpus/templates/content/.agents/skills/turn-into-app/references/fresh-project.md +64 -0
- package/corpus/templates/content/.env.example +9 -3
- package/corpus/templates/content/app/components/sidebar/DocumentSidebar.tsx +1 -0
- package/corpus/templates/content/changelog/2026-08-07-collapsed-sidebar-utility-buttons-stay-anchored-at-the-botto.md +6 -0
- package/corpus/templates/crm/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
- package/corpus/templates/crm/.agents/skills/turn-into-app/SKILL.md +76 -23
- package/corpus/templates/crm/.agents/skills/turn-into-app/agents/openai.yaml +2 -2
- package/corpus/templates/crm/.agents/skills/turn-into-app/references/fresh-project.md +64 -0
- package/corpus/templates/design/.agents/skills/actions/SKILL.md +18 -0
- package/corpus/templates/design/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
- package/corpus/templates/design/.agents/skills/delegate-to-agent/SKILL.md +45 -47
- package/corpus/templates/design/.agents/skills/frontend-design/SKILL.md +1 -0
- package/corpus/templates/design/.agents/skills/turn-into-app/SKILL.md +76 -23
- package/corpus/templates/design/.agents/skills/turn-into-app/agents/openai.yaml +2 -2
- package/corpus/templates/design/.agents/skills/turn-into-app/references/fresh-project.md +64 -0
- package/corpus/templates/dispatch/.agents/skills/actions/SKILL.md +18 -0
- package/corpus/templates/dispatch/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
- package/corpus/templates/dispatch/.agents/skills/delegate-to-agent/SKILL.md +45 -47
- package/corpus/templates/dispatch/.agents/skills/frontend-design/SKILL.md +1 -0
- package/corpus/templates/dispatch/.agents/skills/turn-into-app/SKILL.md +76 -23
- package/corpus/templates/dispatch/.agents/skills/turn-into-app/agents/openai.yaml +2 -2
- package/corpus/templates/dispatch/.agents/skills/turn-into-app/references/fresh-project.md +64 -0
- package/corpus/templates/factory/.agents/skills/actions/SKILL.md +18 -0
- package/corpus/templates/factory/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
- package/corpus/templates/factory/.agents/skills/delegate-to-agent/SKILL.md +45 -47
- package/corpus/templates/factory/.agents/skills/frontend-design/SKILL.md +1 -0
- package/corpus/templates/factory/.agents/skills/turn-into-app/SKILL.md +76 -23
- package/corpus/templates/factory/.agents/skills/turn-into-app/agents/openai.yaml +2 -2
- package/corpus/templates/factory/.agents/skills/turn-into-app/references/fresh-project.md +64 -0
- package/corpus/templates/factory/actions/babysit-agent-native-pull-request.ts +279 -0
- package/corpus/templates/factory/actions/get-factory-automation-health.ts +23 -4
- package/corpus/templates/factory/app/components/factory/FactoryCanvas.tsx +1 -1
- package/corpus/templates/factory/app/routes/factory.tsx +21 -3
- package/corpus/templates/factory/changelog/2026-08-07-factory-can-keep-builder-bot-pull-requests-moving-by-request.md +6 -0
- package/corpus/templates/factory/server/lib/require-factory-automation.ts +1 -0
- package/corpus/templates/factory/server/plugins/agent-chat.ts +4 -1
- package/corpus/templates/factory/server/plugins/factory-scheduler-job.ts +81 -12
- package/corpus/templates/factory/server/triage/github-client.ts +31 -0
- package/corpus/templates/factory/server/triage/pr-babysit.ts +75 -1
- package/corpus/templates/forms/.agents/skills/actions/SKILL.md +18 -0
- package/corpus/templates/forms/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
- package/corpus/templates/forms/.agents/skills/delegate-to-agent/SKILL.md +45 -47
- package/corpus/templates/forms/.agents/skills/frontend-design/SKILL.md +1 -0
- package/corpus/templates/forms/.agents/skills/turn-into-app/SKILL.md +76 -23
- package/corpus/templates/forms/.agents/skills/turn-into-app/agents/openai.yaml +2 -2
- package/corpus/templates/forms/.agents/skills/turn-into-app/references/fresh-project.md +64 -0
- package/corpus/templates/macros/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
- package/corpus/templates/macros/.agents/skills/frontend-design/SKILL.md +1 -0
- package/corpus/templates/macros/.agents/skills/turn-into-app/SKILL.md +76 -23
- package/corpus/templates/macros/.agents/skills/turn-into-app/agents/openai.yaml +2 -2
- package/corpus/templates/macros/.agents/skills/turn-into-app/references/fresh-project.md +64 -0
- package/corpus/templates/mail/.agents/skills/actions/SKILL.md +18 -0
- package/corpus/templates/mail/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
- package/corpus/templates/mail/.agents/skills/delegate-to-agent/SKILL.md +45 -47
- package/corpus/templates/mail/.agents/skills/frontend-design/SKILL.md +1 -0
- package/corpus/templates/mail/.agents/skills/turn-into-app/SKILL.md +76 -23
- package/corpus/templates/mail/.agents/skills/turn-into-app/agents/openai.yaml +2 -2
- package/corpus/templates/mail/.agents/skills/turn-into-app/references/fresh-project.md +64 -0
- package/corpus/templates/plan/.agents/skills/actions/SKILL.md +18 -0
- package/corpus/templates/plan/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
- package/corpus/templates/plan/.agents/skills/delegate-to-agent/SKILL.md +45 -47
- package/corpus/templates/plan/.agents/skills/frontend-design/SKILL.md +1 -0
- package/corpus/templates/plan/.agents/skills/turn-into-app/SKILL.md +76 -23
- package/corpus/templates/plan/.agents/skills/turn-into-app/agents/openai.yaml +2 -2
- package/corpus/templates/plan/.agents/skills/turn-into-app/references/fresh-project.md +64 -0
- package/corpus/templates/plan/app/pages/PlansPage.tsx +2 -1
- package/corpus/templates/plan/changelog/2026-08-07-inline-help-icons-now-stay-visually-balanced-with-nearby-tex.md +6 -0
- package/corpus/templates/slides/.agents/skills/actions/SKILL.md +18 -0
- package/corpus/templates/slides/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
- package/corpus/templates/slides/.agents/skills/delegate-to-agent/SKILL.md +45 -47
- package/corpus/templates/slides/.agents/skills/frontend-design/SKILL.md +1 -0
- package/corpus/templates/slides/.agents/skills/turn-into-app/SKILL.md +76 -23
- package/corpus/templates/slides/.agents/skills/turn-into-app/agents/openai.yaml +2 -2
- package/corpus/templates/slides/.agents/skills/turn-into-app/references/fresh-project.md +64 -0
- package/corpus/templates/slides/.env.example +5 -0
- package/corpus/templates/slides/changelog/2026-08-07-fixed-generated-slides-briefly-disappearing-while-they-are-b.md +6 -0
- package/corpus/templates/slides/server/plugins/collab.ts +20 -8
- package/corpus/templates/tasks/.agents/skills/actions/SKILL.md +18 -0
- package/corpus/templates/tasks/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
- package/corpus/templates/tasks/.agents/skills/delegate-to-agent/SKILL.md +45 -47
- package/corpus/templates/tasks/.agents/skills/frontend-design/SKILL.md +1 -0
- package/corpus/templates/tasks/.agents/skills/turn-into-app/SKILL.md +76 -23
- package/corpus/templates/tasks/.agents/skills/turn-into-app/agents/openai.yaml +2 -2
- package/corpus/templates/tasks/.agents/skills/turn-into-app/references/fresh-project.md +64 -0
- package/corpus/templates/tasks/.env.example +3 -0
- package/dist/agent/production-agent.js +24 -3
- package/dist/client/AgentPanel.d.ts +6 -0
- package/dist/client/AgentPanel.js +176 -30
- package/dist/client/AssistantChat.d.ts +2 -0
- package/dist/client/AssistantChat.js +4 -1
- package/dist/client/ConnectBuilderCard.js +6 -11
- package/dist/client/MultiTabAssistantChat.js +1 -1
- package/dist/client/RuntimeConfigNotice.d.ts +1 -0
- package/dist/client/RuntimeConfigNotice.js +94 -0
- package/dist/client/agent-chat/index.d.ts +1 -1
- package/dist/client/agent-chat/index.js +1 -1
- package/dist/client/agent-chat-adapter.js +85 -4
- package/dist/client/agent-page/AgentTabsPage.js +1 -1
- package/dist/client/agent-sidebar-state.d.ts +6 -0
- package/dist/client/agent-sidebar-state.js +25 -0
- package/dist/client/app-providers.js +2 -1
- package/dist/client/assistant-ui-recovery.js +1 -1
- package/dist/client/chat/index.d.ts +1 -1
- package/dist/client/chat/index.js +1 -1
- package/dist/client/chat/markdown-renderer.d.ts +2 -1
- package/dist/client/chat/markdown-renderer.js +48 -2
- package/dist/client/chat/message-components.d.ts +6 -0
- package/dist/client/chat/message-components.js +182 -53
- package/dist/client/chat/tool-call-display.d.ts +16 -4
- package/dist/client/chat/tool-call-display.js +225 -18
- package/dist/client/extensions/ExtensionsSidebarSection.js +1 -1
- package/dist/client/frame-protocol.d.ts +4 -0
- package/dist/client/i18n.js +9 -0
- package/dist/client/integrations/IntegrationsPanel.js +2 -5
- package/dist/client/onboarding/FirstRunOnboarding.js +2 -3
- package/dist/client/org/TeamPage.js +49 -6
- package/dist/client/org/hooks.d.ts +7 -2
- package/dist/client/org/hooks.js +11 -4
- package/dist/client/resources/McpConnectionSuggestion.js +2 -3
- package/dist/client/resources/McpIntegrationDialog.js +2 -16
- package/dist/client/resources/McpIntegrationLogo.d.ts +11 -0
- package/dist/client/resources/McpIntegrationLogo.js +14 -0
- package/dist/client/resources/ResourceTree.js +1 -1
- package/dist/client/resources/mcp-integration-logos.d.ts +1 -0
- package/dist/client/resources/mcp-integration-logos.js +47 -18
- package/dist/client/settings/useBuilderStatus.js +6 -0
- package/dist/client/ui/index.d.ts +1 -0
- package/dist/client/ui/index.js +1 -0
- package/dist/client/use-db-sync.js +4 -0
- package/dist/collab/struct-routes.d.ts +1 -1
- package/dist/config.d.ts +26 -3
- package/dist/config.js +106 -14
- package/dist/db/ddl-guard.d.ts +15 -2
- package/dist/db/ddl-guard.js +53 -5
- package/dist/file-upload/actions/upload-image.d.ts +1 -1
- package/dist/jobs/scheduler.js +7 -0
- package/dist/localization/default-messages.d.ts +17 -0
- package/dist/localization/default-messages.js +17 -0
- package/dist/mcp/oauth-client-metadata.js +5 -1
- package/dist/mcp/oauth-route.d.ts +5 -4
- package/dist/mcp/oauth-route.js +25 -9
- package/dist/mcp/screen-memory-stdio.d.ts +7 -7
- package/dist/mcp/server.d.ts +1 -1
- package/dist/mcp/server.js +9 -10
- package/dist/notifications/routes.d.ts +2 -2
- package/dist/observability/routes.d.ts +3 -3
- package/dist/org/handlers.d.ts +1 -0
- package/dist/org/handlers.js +17 -2
- package/dist/provider-api/actions/custom-provider-registration.d.ts +5 -5
- package/dist/provider-api/actions/provider-api.d.ts +7 -7
- package/dist/provider-api/corpus-jobs.d.ts +12 -2
- package/dist/provider-api/corpus-jobs.js +31 -1
- package/dist/provider-api/index.d.ts +2 -0
- package/dist/provider-api/index.js +7 -1
- package/dist/secrets/routes.d.ts +3 -3
- package/dist/server/agent-chat/recurring-jobs-runtime.d.ts +1 -1
- package/dist/server/agent-chat/recurring-jobs-runtime.js +14 -2
- package/dist/server/agent-chat/script-entries.js +12 -1
- package/dist/server/agent-chat-plugin.js +2 -2
- package/dist/server/agent-engine-api-key-route.d.ts +1 -1
- package/dist/server/auth.d.ts +1 -0
- package/dist/server/auth.js +85 -1
- package/dist/server/better-auth-instance.d.ts +9 -0
- package/dist/server/better-auth-instance.js +25 -11
- package/dist/server/core-routes-plugin.d.ts +7 -0
- package/dist/server/core-routes-plugin.js +51 -5
- package/dist/server/create-server.js +23 -2
- package/dist/server/db-pressure.d.ts +38 -0
- package/dist/server/db-pressure.js +147 -0
- package/dist/server/index.d.ts +1 -0
- package/dist/server/index.js +1 -0
- package/dist/server/legacy-auth-migration.d.ts +10 -0
- package/dist/server/legacy-auth-migration.js +37 -0
- package/dist/server/onboarding-html.js +206 -2
- package/dist/server/poll.d.ts +26 -0
- package/dist/server/poll.js +108 -13
- package/dist/server/ssr-handler.js +4 -1
- package/dist/server/transcribe-voice.d.ts +1 -1
- package/dist/shared/index.d.ts +1 -0
- package/dist/shared/index.js +1 -0
- package/dist/shared/runtime-config.d.ts +44 -0
- package/dist/shared/runtime-config.js +284 -0
- package/dist/styles/agent-native.css +48 -1
- package/dist/templates/chat/.agents/skills/actions/SKILL.md +18 -0
- package/dist/templates/chat/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
- package/dist/templates/chat/.agents/skills/delegate-to-agent/SKILL.md +45 -47
- package/dist/templates/chat/.agents/skills/frontend-design/SKILL.md +1 -0
- package/dist/templates/chat/.agents/skills/turn-into-app/SKILL.md +76 -23
- package/dist/templates/chat/.agents/skills/turn-into-app/agents/openai.yaml +2 -2
- package/dist/templates/chat/.agents/skills/turn-into-app/references/fresh-project.md +64 -0
- package/dist/templates/chat/.env.example +3 -0
- package/dist/templates/chat/AGENTS.md +4 -0
- package/dist/templates/default/.agents/skills/actions/SKILL.md +18 -0
- package/dist/templates/default/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
- package/dist/templates/default/.agents/skills/delegate-to-agent/SKILL.md +45 -47
- package/dist/templates/default/.agents/skills/frontend-design/SKILL.md +1 -0
- package/dist/templates/default/.agents/skills/turn-into-app/SKILL.md +76 -23
- package/dist/templates/default/.agents/skills/turn-into-app/agents/openai.yaml +2 -2
- package/dist/templates/default/.agents/skills/turn-into-app/references/fresh-project.md +64 -0
- package/dist/templates/default/AGENTS.md +6 -1
- package/dist/templates/default/app/i18n/ar-SA.ts +6 -0
- package/dist/templates/default/app/i18n/de-DE.ts +6 -0
- package/dist/templates/default/app/i18n/en-US.ts +6 -0
- package/dist/templates/default/app/i18n/es-ES.ts +6 -0
- package/dist/templates/default/app/i18n/fr-FR.ts +6 -0
- package/dist/templates/default/app/i18n/hi-IN.ts +6 -0
- package/dist/templates/default/app/i18n/ja-JP.ts +6 -0
- package/dist/templates/default/app/i18n/ko-KR.ts +6 -0
- package/dist/templates/default/app/i18n/pt-BR.ts +6 -0
- package/dist/templates/default/app/i18n/zh-CN.ts +6 -0
- package/dist/templates/default/app/i18n/zh-TW.ts +6 -0
- package/dist/templates/headless/.agents/skills/actions/SKILL.md +18 -0
- package/dist/templates/headless/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
- package/dist/templates/headless/.agents/skills/turn-into-app/SKILL.md +76 -23
- package/dist/templates/headless/.agents/skills/turn-into-app/agents/openai.yaml +2 -2
- package/dist/templates/headless/.agents/skills/turn-into-app/references/fresh-project.md +64 -0
- package/dist/templates/workspace-core/.agents/skills/actions/SKILL.md +18 -0
- package/dist/templates/workspace-core/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
- package/dist/templates/workspace-core/.agents/skills/delegate-to-agent/SKILL.md +45 -47
- package/dist/templates/workspace-core/.agents/skills/frontend-design/SKILL.md +1 -0
- package/dist/templates/workspace-core/.agents/skills/turn-into-app/SKILL.md +76 -23
- package/dist/templates/workspace-core/.agents/skills/turn-into-app/agents/openai.yaml +2 -2
- package/dist/templates/workspace-core/.agents/skills/turn-into-app/references/fresh-project.md +64 -0
- package/dist/templates/workspace-core/.agents/skills/workspace-conventions/SKILL.md +4 -0
- package/dist/templates/workspace-core/.agents/skills/writing-agent-instructions/SKILL.md +8 -0
- package/dist/templates/workspace-core/AGENTS.md +7 -2
- package/dist/templates/workspace-root/AGENTS.md +5 -0
- package/dist/vite/client.d.ts +3 -3
- package/dist/vite/client.js +47 -1
- package/dist/vite/index.d.ts +1 -1
- package/docs/content/agent-native-config.mdx +240 -139
- package/docs/content/authentication.mdx +17 -0
- package/docs/content/deployment.mdx +19 -14
- package/docs/content/drop-in-agent.mdx +19 -2
- package/docs/content/environment-variables.mdx +63 -38
- package/docs/content/getting-started-actions.mdx +15 -6
- package/docs/content/getting-started-database.mdx +14 -10
- package/docs/content/getting-started-pages.mdx +32 -35
- package/docs/content/getting-started.mdx +7 -6
- package/package.json +1 -1
- package/src/templates/chat/.agents/skills/actions/SKILL.md +18 -0
- package/src/templates/chat/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
- package/src/templates/chat/.agents/skills/delegate-to-agent/SKILL.md +45 -47
- package/src/templates/chat/.agents/skills/frontend-design/SKILL.md +1 -0
- package/src/templates/chat/.agents/skills/turn-into-app/SKILL.md +76 -23
- package/src/templates/chat/.agents/skills/turn-into-app/agents/openai.yaml +2 -2
- package/src/templates/chat/.agents/skills/turn-into-app/references/fresh-project.md +64 -0
- package/src/templates/chat/.env.example +3 -0
- package/src/templates/chat/AGENTS.md +4 -0
- package/src/templates/default/.agents/skills/actions/SKILL.md +18 -0
- package/src/templates/default/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
- package/src/templates/default/.agents/skills/delegate-to-agent/SKILL.md +45 -47
- package/src/templates/default/.agents/skills/frontend-design/SKILL.md +1 -0
- package/src/templates/default/.agents/skills/turn-into-app/SKILL.md +76 -23
- package/src/templates/default/.agents/skills/turn-into-app/agents/openai.yaml +2 -2
- package/src/templates/default/.agents/skills/turn-into-app/references/fresh-project.md +64 -0
- package/src/templates/default/AGENTS.md +6 -1
- package/src/templates/default/app/i18n/ar-SA.ts +6 -0
- package/src/templates/default/app/i18n/de-DE.ts +6 -0
- package/src/templates/default/app/i18n/en-US.ts +6 -0
- package/src/templates/default/app/i18n/es-ES.ts +6 -0
- package/src/templates/default/app/i18n/fr-FR.ts +6 -0
- package/src/templates/default/app/i18n/hi-IN.ts +6 -0
- package/src/templates/default/app/i18n/ja-JP.ts +6 -0
- package/src/templates/default/app/i18n/ko-KR.ts +6 -0
- package/src/templates/default/app/i18n/pt-BR.ts +6 -0
- package/src/templates/default/app/i18n/zh-CN.ts +6 -0
- package/src/templates/default/app/i18n/zh-TW.ts +6 -0
- package/src/templates/headless/.agents/skills/actions/SKILL.md +18 -0
- package/src/templates/headless/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
- package/src/templates/headless/.agents/skills/turn-into-app/SKILL.md +76 -23
- package/src/templates/headless/.agents/skills/turn-into-app/agents/openai.yaml +2 -2
- package/src/templates/headless/.agents/skills/turn-into-app/references/fresh-project.md +64 -0
- package/src/templates/workspace-core/.agents/skills/actions/SKILL.md +18 -0
- package/src/templates/workspace-core/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
- package/src/templates/workspace-core/.agents/skills/delegate-to-agent/SKILL.md +45 -47
- package/src/templates/workspace-core/.agents/skills/frontend-design/SKILL.md +1 -0
- package/src/templates/workspace-core/.agents/skills/turn-into-app/SKILL.md +76 -23
- package/src/templates/workspace-core/.agents/skills/turn-into-app/agents/openai.yaml +2 -2
- package/src/templates/workspace-core/.agents/skills/turn-into-app/references/fresh-project.md +64 -0
- package/src/templates/workspace-core/.agents/skills/workspace-conventions/SKILL.md +4 -0
- package/src/templates/workspace-core/.agents/skills/writing-agent-instructions/SKILL.md +8 -0
- package/src/templates/workspace-core/AGENTS.md +7 -2
- package/src/templates/workspace-root/AGENTS.md +5 -0
- package/corpus/templates/dispatch/app/routes/admin.apps.$appId.tsx +0 -1
- package/corpus/templates/dispatch/app/routes/admin.apps.tsx +0 -1
|
@@ -27,6 +27,7 @@ import { EMPTY_SPECULATION_RULES, resolveSsrCacheHeaders, } from "../shared/cach
|
|
|
27
27
|
import { EMBED_TARGET_HEADER } from "../shared/embed-auth.js";
|
|
28
28
|
import { llmConnectionTrackingProperties } from "../shared/llm-connection.js";
|
|
29
29
|
import { EMBED_TRANSPLANT_HEADER, isMcpEmbedCorsOrigin, MCP_EMBED_CORS_ALLOW_HEADERS, shouldAllowMcpEmbedCredentials, } from "../shared/mcp-embed-headers.js";
|
|
30
|
+
import { getRuntimeConfigReport } from "../shared/runtime-config.js";
|
|
30
31
|
import { captureException } from "../tracking/error-capture.js";
|
|
31
32
|
import { track } from "../tracking/index.js";
|
|
32
33
|
import { registerBuiltinProviders } from "../tracking/providers.js";
|
|
@@ -41,6 +42,7 @@ import { BUILDER_CONNECT_PARAM, BUILDER_CONNECT_OWNER_COOKIE, BUILDER_ENV_KEYS,
|
|
|
41
42
|
import { captureError, registerErrorCaptureProvider } from "./capture-error.js";
|
|
42
43
|
import { getAllowedCorsOrigin, readCorsAllowedOrigins, } from "./cors-origins.js";
|
|
43
44
|
import { canUseDeployCredentialFallbackForRequest, prefetchSecrets, readDeployCredentialEnv, resolveSecret, } from "./credential-provider.js";
|
|
45
|
+
import { probeDbPressure } from "./db-pressure.js";
|
|
44
46
|
import { resolveDeployEnvironment, resolveServerRelease, } from "./deploy-environment.js";
|
|
45
47
|
import { createEmbedStartRouteHandler } from "./embed-route.js";
|
|
46
48
|
import { shouldReportError } from "./error-noise-filter.js";
|
|
@@ -264,6 +266,7 @@ const DB_HEALTH_PROBE_DEADLINE_MS = 5_000;
|
|
|
264
266
|
export async function runDbHealthProbe(exec = getDbExec, options = {}) {
|
|
265
267
|
const startedAt = Date.now();
|
|
266
268
|
let db = false;
|
|
269
|
+
let trivialQueryMs;
|
|
267
270
|
let schema;
|
|
268
271
|
const dbExec = exec();
|
|
269
272
|
let dbTimedOut = false;
|
|
@@ -278,8 +281,10 @@ export async function runDbHealthProbe(exec = getDbExec, options = {}) {
|
|
|
278
281
|
timer = setTimeout(() => reject(new Error("db probe deadline")), DB_HEALTH_PROBE_DEADLINE_MS);
|
|
279
282
|
});
|
|
280
283
|
try {
|
|
284
|
+
const trivialQueryStartedAt = Date.now();
|
|
281
285
|
await Promise.race([dbExec.execute("SELECT 1"), deadline]);
|
|
282
286
|
db = true;
|
|
287
|
+
trivialQueryMs = Date.now() - trivialQueryStartedAt;
|
|
283
288
|
}
|
|
284
289
|
finally {
|
|
285
290
|
if (timer)
|
|
@@ -296,6 +301,14 @@ export async function runDbHealthProbe(exec = getDbExec, options = {}) {
|
|
|
296
301
|
});
|
|
297
302
|
}
|
|
298
303
|
const database = getDatabaseRuntimeFingerprint();
|
|
304
|
+
// Measured on the connection `SELECT 1` just warmed, so the number reflects
|
|
305
|
+
// the database's own load rather than a serverless cold start.
|
|
306
|
+
let pressure;
|
|
307
|
+
if (options.pressure) {
|
|
308
|
+
pressure = db
|
|
309
|
+
? await probeDbPressure(dbExec, database.dialect, { trivialQueryMs })
|
|
310
|
+
: { measured: false, reason: "database unreachable" };
|
|
311
|
+
}
|
|
299
312
|
return {
|
|
300
313
|
ok: true,
|
|
301
314
|
ready: db && (!schema || schema.ok),
|
|
@@ -312,6 +325,7 @@ export async function runDbHealthProbe(exec = getDbExec, options = {}) {
|
|
|
312
325
|
netlifyDatabaseUrlConfigured: database.netlifyDatabaseUrlConfigured,
|
|
313
326
|
},
|
|
314
327
|
...(schema ? { schema } : {}),
|
|
328
|
+
...(pressure ? { pressure } : {}),
|
|
315
329
|
};
|
|
316
330
|
}
|
|
317
331
|
const DEFAULT_BUILDER_WAITLIST_FORM_ID = "DYTHuM0jlV";
|
|
@@ -809,7 +823,7 @@ export async function readLegacyCoreRouteInitSettings(readSetting = getSetting)
|
|
|
809
823
|
* Routes:
|
|
810
824
|
* GET /_agent-native/poll — polling endpoint for change detection
|
|
811
825
|
* GET /_agent-native/events (or custom) — SSE endpoint for real-time sync
|
|
812
|
-
* GET /_agent-native/ping — health check
|
|
826
|
+
* GET /_agent-native/ping — health check; add ?configuration=1 for redacted deploy diagnostics
|
|
813
827
|
* GET /_agent-native/health — DB liveness probe + scale-to-zero warmup
|
|
814
828
|
* GET /_agent-native/env-status — env key configuration status (when envKeys provided)
|
|
815
829
|
* POST /_agent-native/env-vars — compatibility route that saves keys to scoped DB secrets
|
|
@@ -1197,9 +1211,30 @@ export function createCoreRoutesPlugin(options = {}) {
|
|
|
1197
1211
|
}
|
|
1198
1212
|
// Ping
|
|
1199
1213
|
if (!options.disablePing) {
|
|
1200
|
-
getH3App(nitroApp).use(`${P}/ping`, defineEventHandler(() =>
|
|
1201
|
-
message
|
|
1202
|
-
|
|
1214
|
+
getH3App(nitroApp).use(`${P}/ping`, defineEventHandler((event) => {
|
|
1215
|
+
const message = process.env.PING_MESSAGE ?? "pong";
|
|
1216
|
+
const configuration = event.url?.searchParams.get("configuration") === "1" ||
|
|
1217
|
+
event.url?.searchParams.get("configuration") === "true";
|
|
1218
|
+
if (!configuration)
|
|
1219
|
+
return { message };
|
|
1220
|
+
// Custom required keys must come from server-side app configuration;
|
|
1221
|
+
// never let an anonymous caller turn this into an env-name oracle.
|
|
1222
|
+
const requirements = {
|
|
1223
|
+
...(event.url?.searchParams.get("auth") === "0"
|
|
1224
|
+
? { authEnabled: false }
|
|
1225
|
+
: {}),
|
|
1226
|
+
...(event.url?.searchParams.get("database") === "0"
|
|
1227
|
+
? { databaseRequired: false }
|
|
1228
|
+
: {}),
|
|
1229
|
+
};
|
|
1230
|
+
return {
|
|
1231
|
+
message,
|
|
1232
|
+
configuration: getRuntimeConfigReport(process.env, requirements, {
|
|
1233
|
+
phase: "runtime",
|
|
1234
|
+
appName: process.env.APP_NAME,
|
|
1235
|
+
}),
|
|
1236
|
+
};
|
|
1237
|
+
}));
|
|
1203
1238
|
}
|
|
1204
1239
|
// ─── Durable sandbox execution processor ─────────────────────────
|
|
1205
1240
|
// Self-fired by run-code's background queue (see
|
|
@@ -1294,7 +1329,18 @@ export function createCoreRoutesPlugin(options = {}) {
|
|
|
1294
1329
|
const strict = event.url?.searchParams.get("strict") === "1" ||
|
|
1295
1330
|
event.url?.searchParams.get("strict") === "true" ||
|
|
1296
1331
|
process.env.AGENT_NATIVE_HEALTH_STRICT_SCHEMA === "true";
|
|
1297
|
-
|
|
1332
|
+
// Off by default: the one-minute warm cron does not need it, and
|
|
1333
|
+
// an extra `pg_stat_activity` read every minute per app is waste.
|
|
1334
|
+
// Pressure deliberately does NOT change `ready` or the status
|
|
1335
|
+
// code — a pressured database is still serving, and an uptime
|
|
1336
|
+
// monitor that pages on it would learn to ignore this route. The
|
|
1337
|
+
// fleet audit reads the counters and decides.
|
|
1338
|
+
const pressure = event.url?.searchParams.get("pressure") === "1" ||
|
|
1339
|
+
event.url?.searchParams.get("pressure") === "true";
|
|
1340
|
+
const result = await runDbHealthProbe(getDbExec, {
|
|
1341
|
+
schema,
|
|
1342
|
+
pressure,
|
|
1343
|
+
});
|
|
1298
1344
|
if (strict && !result.ready)
|
|
1299
1345
|
setResponseStatus(event, 503);
|
|
1300
1346
|
return result;
|
|
@@ -3,6 +3,7 @@ import { getOrgContext } from "../org/context.js";
|
|
|
3
3
|
import { readBody } from "../server/h3-helpers.js";
|
|
4
4
|
import { EMBED_TARGET_HEADER } from "../shared/embed-auth.js";
|
|
5
5
|
import { EMBED_TRANSPLANT_HEADER, isMcpEmbedCorsOrigin, MCP_EMBED_CORS_ALLOW_HEADERS, shouldAllowMcpEmbedCredentials, } from "../shared/mcp-embed-headers.js";
|
|
6
|
+
import { getRuntimeConfigReport } from "../shared/runtime-config.js";
|
|
6
7
|
import { getSession } from "./auth.js";
|
|
7
8
|
import { getAllowedCorsOrigin, readCorsAllowedOrigins, } from "./cors-origins.js";
|
|
8
9
|
import { resolveSecret } from "./credential-provider.js";
|
|
@@ -107,9 +108,29 @@ export function createServer(options = {}) {
|
|
|
107
108
|
const router = createRouter();
|
|
108
109
|
// Health check
|
|
109
110
|
if (!options.disablePing) {
|
|
110
|
-
router.get("/_agent-native/ping", defineEventHandler(() => {
|
|
111
|
+
router.get("/_agent-native/ping", defineEventHandler((event) => {
|
|
111
112
|
const message = options.pingMessage ?? process.env.PING_MESSAGE ?? "pong";
|
|
112
|
-
|
|
113
|
+
const configuration = event.url?.searchParams.get("configuration") === "1" ||
|
|
114
|
+
event.url?.searchParams.get("configuration") === "true";
|
|
115
|
+
if (!configuration)
|
|
116
|
+
return { message };
|
|
117
|
+
// Custom required keys must come from server-side app configuration;
|
|
118
|
+
// never let an anonymous caller turn this into an env-name oracle.
|
|
119
|
+
const requirements = {
|
|
120
|
+
...(event.url?.searchParams.get("auth") === "0"
|
|
121
|
+
? { authEnabled: false }
|
|
122
|
+
: {}),
|
|
123
|
+
...(event.url?.searchParams.get("database") === "0"
|
|
124
|
+
? { databaseRequired: false }
|
|
125
|
+
: {}),
|
|
126
|
+
};
|
|
127
|
+
return {
|
|
128
|
+
message,
|
|
129
|
+
configuration: getRuntimeConfigReport(process.env, requirements, {
|
|
130
|
+
phase: "runtime",
|
|
131
|
+
appName: process.env.APP_NAME,
|
|
132
|
+
}),
|
|
133
|
+
};
|
|
113
134
|
}));
|
|
114
135
|
}
|
|
115
136
|
// Env key management routes
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/** Counters taken in one shot from `pg_stat_activity`. */
|
|
2
|
+
export interface DbPressureCounters {
|
|
3
|
+
connections: number;
|
|
4
|
+
idleInTxn: number;
|
|
5
|
+
oldestIdleTxnS: number;
|
|
6
|
+
maxSameQuery: number;
|
|
7
|
+
/** Round-trip of this statement on an already-open connection. */
|
|
8
|
+
trivialQueryMs: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Measured counters, or an explicit reason they could not be taken.
|
|
12
|
+
*
|
|
13
|
+
* A monitor must never read "not measured" as "healthy", so the two are
|
|
14
|
+
* different shapes rather than an empty warning list.
|
|
15
|
+
*/
|
|
16
|
+
export type DbPressure = ({
|
|
17
|
+
measured: true;
|
|
18
|
+
warnings: string[];
|
|
19
|
+
} & DbPressureCounters) | {
|
|
20
|
+
measured: false;
|
|
21
|
+
reason: string;
|
|
22
|
+
};
|
|
23
|
+
export declare const MAX_IDLE_TXN_AGE_S = 60;
|
|
24
|
+
export declare const MAX_TRIVIAL_QUERY_MS = 1000;
|
|
25
|
+
export declare const MAX_SAME_QUERY_CONCURRENCY = 10;
|
|
26
|
+
export declare const DB_PRESSURE_SQL = "\nSELECT\n count(*)::int AS connections,\n count(*) FILTER (WHERE state = 'idle in transaction')::int AS idle_in_txn,\n coalesce(round(max(extract(epoch from (now() - state_change)))\n FILTER (WHERE state = 'idle in transaction'))::int, 0) AS oldest_idle_txn_s,\n coalesce((\n SELECT max(c) FROM (\n SELECT count(*)::int AS c FROM pg_stat_activity\n WHERE pid <> pg_backend_pid()\n AND state = 'active'\n AND query <> ''\n GROUP BY left(query, 60)\n ) q\n ), 0)::int AS max_same_query\nFROM pg_stat_activity\nWHERE pid <> pg_backend_pid()";
|
|
27
|
+
/** Reasons this database looks pressured, or [] when it looks fine. */
|
|
28
|
+
export declare function dbPressureWarnings(p: DbPressureCounters): string[];
|
|
29
|
+
/**
|
|
30
|
+
* Read the pressure counters. Postgres-only: `pg_stat_activity` does not exist
|
|
31
|
+
* on SQLite/libSQL/D1, and a dialect that cannot answer reports `measured:
|
|
32
|
+
* false` rather than a clean-looking zero.
|
|
33
|
+
*/
|
|
34
|
+
export declare function probeDbPressure(exec: {
|
|
35
|
+
execute: (sql: string) => Promise<unknown>;
|
|
36
|
+
}, dialect: string, options?: {
|
|
37
|
+
trivialQueryMs?: number;
|
|
38
|
+
}): Promise<DbPressure>;
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
// Database pressure — the three signals that precede an outage, measured from
|
|
2
|
+
// inside the app that owns the database.
|
|
3
|
+
//
|
|
4
|
+
// The analytics app degraded for hours on 2026-08-06 before it fell over, and
|
|
5
|
+
// every check we had said UP until the moment it said DOWN. What was actually
|
|
6
|
+
// true, and visible in `pg_stat_activity` the whole time:
|
|
7
|
+
//
|
|
8
|
+
// - 11-20 connections stuck `idle in transaction` up to 283s, left behind by
|
|
9
|
+
// serverless workers killed mid-transaction. They hold locks; nothing
|
|
10
|
+
// reaped them.
|
|
11
|
+
// - `SELECT 1` drifting from ~0.2s to 6s as those locks accumulated.
|
|
12
|
+
// - 47-56 concurrent copies of one unprojected query, each dragging a JSON
|
|
13
|
+
// blob per row.
|
|
14
|
+
//
|
|
15
|
+
// None of that is "down". All of it is the hour before down. A monitor that
|
|
16
|
+
// only distinguishes 200 from 500 cannot see any of it.
|
|
17
|
+
//
|
|
18
|
+
// This lives in core rather than in a workstation script because the numbers
|
|
19
|
+
// require a database credential, and the app already has its own. Reading them
|
|
20
|
+
// here means the scheduled fleet audit needs no production credentials at all.
|
|
21
|
+
// `scripts/chat-health.mjs` measures the same three signals locally against
|
|
22
|
+
// every app at once; `db-pressure.spec.ts` pins the two threshold sets equal.
|
|
23
|
+
// Thresholds set from that outage, not intuition. Healthy analytics reads
|
|
24
|
+
// 0 / 128ms / 1; at the point it went down it read 20 / 6000ms / 56.
|
|
25
|
+
export const MAX_IDLE_TXN_AGE_S = 60;
|
|
26
|
+
export const MAX_TRIVIAL_QUERY_MS = 1_000;
|
|
27
|
+
export const MAX_SAME_QUERY_CONCURRENCY = 10;
|
|
28
|
+
/**
|
|
29
|
+
* A hung probe must not hang the health route — that is the defect that took
|
|
30
|
+
* the docs site permanently cold. Short because this runs on a connection the
|
|
31
|
+
* liveness probe just proved is answering.
|
|
32
|
+
*/
|
|
33
|
+
const PRESSURE_PROBE_DEADLINE_MS = 3_000;
|
|
34
|
+
export const DB_PRESSURE_SQL = `
|
|
35
|
+
SELECT
|
|
36
|
+
count(*)::int AS connections,
|
|
37
|
+
count(*) FILTER (WHERE state = 'idle in transaction')::int AS idle_in_txn,
|
|
38
|
+
coalesce(round(max(extract(epoch from (now() - state_change)))
|
|
39
|
+
FILTER (WHERE state = 'idle in transaction'))::int, 0) AS oldest_idle_txn_s,
|
|
40
|
+
coalesce((
|
|
41
|
+
SELECT max(c) FROM (
|
|
42
|
+
SELECT count(*)::int AS c FROM pg_stat_activity
|
|
43
|
+
WHERE pid <> pg_backend_pid()
|
|
44
|
+
AND state = 'active'
|
|
45
|
+
AND query <> ''
|
|
46
|
+
GROUP BY left(query, 60)
|
|
47
|
+
) q
|
|
48
|
+
), 0)::int AS max_same_query
|
|
49
|
+
FROM pg_stat_activity
|
|
50
|
+
WHERE pid <> pg_backend_pid()`;
|
|
51
|
+
/** Reasons this database looks pressured, or [] when it looks fine. */
|
|
52
|
+
export function dbPressureWarnings(p) {
|
|
53
|
+
const out = [];
|
|
54
|
+
if (p.idleInTxn > 0 && p.oldestIdleTxnS > MAX_IDLE_TXN_AGE_S) {
|
|
55
|
+
out.push(`${p.idleInTxn} idle-in-transaction (oldest ${p.oldestIdleTxnS}s) — workers killed mid-transaction still holding locks`);
|
|
56
|
+
}
|
|
57
|
+
if (p.trivialQueryMs > MAX_TRIVIAL_QUERY_MS) {
|
|
58
|
+
out.push(`trivial query took ${p.trivialQueryMs}ms — the database itself is slow, not the app`);
|
|
59
|
+
}
|
|
60
|
+
if (p.maxSameQuery >= MAX_SAME_QUERY_CONCURRENCY) {
|
|
61
|
+
out.push(`${p.maxSameQuery} concurrent copies of one query — a hot path is stampeding`);
|
|
62
|
+
}
|
|
63
|
+
return out;
|
|
64
|
+
}
|
|
65
|
+
function readCount(row, key) {
|
|
66
|
+
const value = row[key];
|
|
67
|
+
if (typeof value === "number" && Number.isFinite(value))
|
|
68
|
+
return value;
|
|
69
|
+
// Some drivers hand back bigint-ish columns as strings.
|
|
70
|
+
if (typeof value === "string" && value.trim() !== "") {
|
|
71
|
+
const parsed = Number(value);
|
|
72
|
+
if (Number.isFinite(parsed))
|
|
73
|
+
return parsed;
|
|
74
|
+
}
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Read the pressure counters. Postgres-only: `pg_stat_activity` does not exist
|
|
79
|
+
* on SQLite/libSQL/D1, and a dialect that cannot answer reports `measured:
|
|
80
|
+
* false` rather than a clean-looking zero.
|
|
81
|
+
*/
|
|
82
|
+
export async function probeDbPressure(exec, dialect, options = {}) {
|
|
83
|
+
if (dialect !== "postgres") {
|
|
84
|
+
return {
|
|
85
|
+
measured: false,
|
|
86
|
+
reason: `dialect ${dialect} has no pg_stat_activity`,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
let timer;
|
|
90
|
+
try {
|
|
91
|
+
const trivialQueryMs = options.trivialQueryMs ?? (await measureTrivialQuery(exec));
|
|
92
|
+
const deadline = new Promise((_, reject) => {
|
|
93
|
+
timer = setTimeout(() => reject(new Error("pressure probe deadline")), PRESSURE_PROBE_DEADLINE_MS);
|
|
94
|
+
});
|
|
95
|
+
const result = (await Promise.race([
|
|
96
|
+
exec.execute(DB_PRESSURE_SQL),
|
|
97
|
+
deadline,
|
|
98
|
+
]));
|
|
99
|
+
const row = result?.rows?.[0];
|
|
100
|
+
if (!row) {
|
|
101
|
+
return { measured: false, reason: "pressure query returned no rows" };
|
|
102
|
+
}
|
|
103
|
+
const counters = {
|
|
104
|
+
connections: readCount(row, "connections") ?? -1,
|
|
105
|
+
idleInTxn: readCount(row, "idle_in_txn") ?? -1,
|
|
106
|
+
oldestIdleTxnS: readCount(row, "oldest_idle_txn_s") ?? -1,
|
|
107
|
+
maxSameQuery: readCount(row, "max_same_query") ?? -1,
|
|
108
|
+
trivialQueryMs,
|
|
109
|
+
};
|
|
110
|
+
if (Object.values(counters).some((n) => n < 0)) {
|
|
111
|
+
return {
|
|
112
|
+
measured: false,
|
|
113
|
+
reason: "pressure query returned unreadable counters",
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
measured: true,
|
|
118
|
+
...counters,
|
|
119
|
+
warnings: dbPressureWarnings(counters),
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
catch (err) {
|
|
123
|
+
return {
|
|
124
|
+
measured: false,
|
|
125
|
+
reason: err instanceof Error ? err.message : String(err),
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
finally {
|
|
129
|
+
if (timer)
|
|
130
|
+
clearTimeout(timer);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
async function measureTrivialQuery(exec) {
|
|
134
|
+
let timer;
|
|
135
|
+
const startedAt = Date.now();
|
|
136
|
+
try {
|
|
137
|
+
const deadline = new Promise((_, reject) => {
|
|
138
|
+
timer = setTimeout(() => reject(new Error("trivial query deadline")), PRESSURE_PROBE_DEADLINE_MS);
|
|
139
|
+
});
|
|
140
|
+
await Promise.race([exec.execute("SELECT 1"), deadline]);
|
|
141
|
+
return Date.now() - startedAt;
|
|
142
|
+
}
|
|
143
|
+
finally {
|
|
144
|
+
if (timer)
|
|
145
|
+
clearTimeout(timer);
|
|
146
|
+
}
|
|
147
|
+
}
|
package/dist/server/index.d.ts
CHANGED
|
@@ -37,6 +37,7 @@ export { configureAgentNativeEmbeddedEnvironment, createAgentNativeEmbeddedAuthO
|
|
|
37
37
|
export { createThread, getThread, listThreads, updateThreadData, deleteThread, setThreadArchived, setThreadPinned, setThreadScope, type ChatThread, type ChatThreadScope, type ChatThreadSummary, type ListThreadsOptions, } from "../chat-threads/store.js";
|
|
38
38
|
export { createResourcesPlugin, defaultResourcesPlugin, } from "./resources-plugin.js";
|
|
39
39
|
export { createCoreRoutesPlugin, defaultCoreRoutesPlugin, FRAMEWORK_ROUTE_PREFIX, type CoreRoutesPluginOptions, } from "./core-routes-plugin.js";
|
|
40
|
+
export { buildRuntimeConfigPrompt, formatRuntimeConfigReport, getRuntimeConfigReport, parseRuntimeConfigReport, runtimeConfigRequirementsFromSearchParams, type RuntimeConfigEnvironment, type RuntimeConfigIssue, type RuntimeConfigIssueCode, type RuntimeConfigIssueSeverity, type RuntimeConfigPhase, type RuntimeConfigReport, type RuntimeConfigRequirements, } from "../shared/runtime-config.js";
|
|
40
41
|
export { AGENT_NATIVE_OG_IMAGE_CACHE_CONTROL, AGENT_NATIVE_OG_IMAGE_HEIGHT, AGENT_NATIVE_OG_IMAGE_NETLIFY_CACHE_CONTROL, AGENT_NATIVE_OG_IMAGE_WIDTH, agentNativeOgImageResponseHeaders, createAgentNativeOgImageHandler, renderAgentNativeOgImagePng, renderAgentNativeOgImageSvg, type AgentNativeOgImageInput, } from "./social-og-image.js";
|
|
41
42
|
export { OG_FONT_FAMILY, resolveOgFontFiles } from "./og-fonts.js";
|
|
42
43
|
export { createBrowserSessionActionEntries, type CreateBrowserSessionActionEntriesOptions, } from "../browser-sessions/actions.js";
|
package/dist/server/index.js
CHANGED
|
@@ -38,6 +38,7 @@ export { configureAgentNativeEmbeddedEnvironment, createAgentNativeEmbeddedAuthO
|
|
|
38
38
|
export { createThread, getThread, listThreads, updateThreadData, deleteThread, setThreadArchived, setThreadPinned, setThreadScope, } from "../chat-threads/store.js";
|
|
39
39
|
export { createResourcesPlugin, defaultResourcesPlugin, } from "./resources-plugin.js";
|
|
40
40
|
export { createCoreRoutesPlugin, defaultCoreRoutesPlugin, FRAMEWORK_ROUTE_PREFIX, } from "./core-routes-plugin.js";
|
|
41
|
+
export { buildRuntimeConfigPrompt, formatRuntimeConfigReport, getRuntimeConfigReport, parseRuntimeConfigReport, runtimeConfigRequirementsFromSearchParams, } from "../shared/runtime-config.js";
|
|
41
42
|
export { AGENT_NATIVE_OG_IMAGE_CACHE_CONTROL, AGENT_NATIVE_OG_IMAGE_HEIGHT, AGENT_NATIVE_OG_IMAGE_NETLIFY_CACHE_CONTROL, AGENT_NATIVE_OG_IMAGE_WIDTH, agentNativeOgImageResponseHeaders, createAgentNativeOgImageHandler, renderAgentNativeOgImagePng, renderAgentNativeOgImageSvg, } from "./social-og-image.js";
|
|
42
43
|
export { OG_FONT_FAMILY, resolveOgFontFiles } from "./og-fonts.js";
|
|
43
44
|
export { createBrowserSessionActionEntries, } from "../browser-sessions/actions.js";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Backfill the canonical Better Auth user for a verified legacy session.
|
|
3
|
+
*
|
|
4
|
+
* Older OAuth sessions were keyed by email in the framework `sessions` table
|
|
5
|
+
* before every deployment required a Better Auth `user` row. Keep the legacy
|
|
6
|
+
* session as the authentication proof, and use Better Auth's adapter only to
|
|
7
|
+
* create the missing canonical user. Do not invent a provider account: the
|
|
8
|
+
* next provider sign-in owns that link.
|
|
9
|
+
*/
|
|
10
|
+
export declare function ensureCanonicalUserForLegacySession(email: string): Promise<boolean>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { getBetterAuthInternalAdapter } from "./better-auth-instance.js";
|
|
2
|
+
/**
|
|
3
|
+
* Backfill the canonical Better Auth user for a verified legacy session.
|
|
4
|
+
*
|
|
5
|
+
* Older OAuth sessions were keyed by email in the framework `sessions` table
|
|
6
|
+
* before every deployment required a Better Auth `user` row. Keep the legacy
|
|
7
|
+
* session as the authentication proof, and use Better Auth's adapter only to
|
|
8
|
+
* create the missing canonical user. Do not invent a provider account: the
|
|
9
|
+
* next provider sign-in owns that link.
|
|
10
|
+
*/
|
|
11
|
+
export async function ensureCanonicalUserForLegacySession(email) {
|
|
12
|
+
const normalizedEmail = email.trim().toLowerCase();
|
|
13
|
+
if (!normalizedEmail || !normalizedEmail.includes("@"))
|
|
14
|
+
return false;
|
|
15
|
+
const adapter = await getBetterAuthInternalAdapter();
|
|
16
|
+
if (!adapter) {
|
|
17
|
+
throw new Error("Better Auth internal adapter is unavailable");
|
|
18
|
+
}
|
|
19
|
+
const findExisting = () => adapter.findUserByEmail(normalizedEmail, { includeAccounts: false });
|
|
20
|
+
if (await findExisting())
|
|
21
|
+
return false;
|
|
22
|
+
try {
|
|
23
|
+
await adapter.createUser({
|
|
24
|
+
email: normalizedEmail,
|
|
25
|
+
name: normalizedEmail.split("@")[0] || "User",
|
|
26
|
+
emailVerified: true,
|
|
27
|
+
});
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
// A concurrent request may have created the same canonical user. Treat
|
|
32
|
+
// that race as success only after the adapter can read the winner.
|
|
33
|
+
if (await findExisting())
|
|
34
|
+
return false;
|
|
35
|
+
throw error;
|
|
36
|
+
}
|
|
37
|
+
}
|