@agent-native/core 0.98.0 → 0.98.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/corpus/README.md +2 -2
- package/corpus/core/CHANGELOG.md +32 -0
- package/corpus/core/docs/content/locales/ar-SA/pr-visual-recap.mdx +25 -1
- package/corpus/core/docs/content/locales/ar-SA/template-plan.mdx +1 -1
- package/corpus/core/docs/content/locales/de-DE/pr-visual-recap.mdx +25 -1
- package/corpus/core/docs/content/locales/de-DE/template-plan.mdx +1 -1
- package/corpus/core/docs/content/locales/es-ES/pr-visual-recap.mdx +25 -1
- package/corpus/core/docs/content/locales/es-ES/template-plan.mdx +1 -1
- package/corpus/core/docs/content/locales/fr-FR/pr-visual-recap.mdx +25 -1
- package/corpus/core/docs/content/locales/fr-FR/template-plan.mdx +1 -1
- package/corpus/core/docs/content/locales/hi-IN/pr-visual-recap.mdx +25 -1
- package/corpus/core/docs/content/locales/hi-IN/template-plan.mdx +1 -1
- package/corpus/core/docs/content/locales/ja-JP/pr-visual-recap.mdx +25 -1
- package/corpus/core/docs/content/locales/ja-JP/template-plan.mdx +1 -1
- package/corpus/core/docs/content/locales/ko-KR/pr-visual-recap.mdx +25 -1
- package/corpus/core/docs/content/locales/ko-KR/template-plan.mdx +1 -1
- package/corpus/core/docs/content/locales/pt-BR/pr-visual-recap.mdx +25 -1
- package/corpus/core/docs/content/locales/pt-BR/template-plan.mdx +1 -1
- package/corpus/core/docs/content/locales/zh-CN/pr-visual-recap.mdx +25 -1
- package/corpus/core/docs/content/locales/zh-CN/template-plan.mdx +1 -1
- package/corpus/core/docs/content/locales/zh-TW/pr-visual-recap.mdx +25 -1
- package/corpus/core/docs/content/locales/zh-TW/template-plan.mdx +1 -1
- package/corpus/core/docs/content/pr-visual-recap.mdx +50 -1
- package/corpus/core/docs/content/template-plan.mdx +1 -1
- package/corpus/core/package.json +2 -2
- package/corpus/core/src/action-change-marker.ts +8 -1
- package/corpus/core/src/changelog/parse.ts +8 -3
- package/corpus/core/src/cli/plan-local.ts +43 -11
- package/corpus/core/src/cli/pr-visual-recap-workflow.ts +2 -9
- package/corpus/core/src/cli/recap.ts +356 -4
- package/corpus/core/src/cli/skills-content/local-files.ts +17 -12
- package/corpus/core/src/client/AgentPanel.tsx +2 -3
- package/corpus/core/src/client/AssistantChat.tsx +83 -39
- package/corpus/core/src/client/analytics.ts +125 -14
- package/corpus/core/src/client/blocks/library/wireframe-kit.tsx +16 -2
- package/corpus/core/src/client/chat-model-groups.ts +28 -0
- package/corpus/core/src/client/composer/RealtimeVoiceMode.tsx +442 -85
- package/corpus/core/src/client/composer/TiptapComposer.tsx +46 -29
- package/corpus/core/src/client/composer/VoiceButton.tsx +2 -1
- package/corpus/core/src/client/composer/index.ts +5 -0
- package/corpus/core/src/client/composer/useRealtimeVoiceMode.tsx +1206 -67
- package/corpus/core/src/client/index.ts +10 -0
- package/corpus/core/src/client/progress/RunsTray.tsx +13 -1
- package/corpus/core/src/client/session-replay.ts +10 -0
- package/corpus/core/src/client/settings/DemoModeSection.tsx +4 -28
- package/corpus/core/src/client/settings/SecretsSection.tsx +387 -266
- package/corpus/core/src/client/settings/SettingsPanel.tsx +117 -38
- package/corpus/core/src/client/url-scrub.ts +13 -0
- package/corpus/core/src/client/use-action.ts +12 -0
- package/corpus/core/src/client/use-agent-chat-home-handoff.ts +8 -1
- package/corpus/core/src/client/use-agent-engine-configured.ts +17 -3
- package/corpus/core/src/client/use-db-sync.ts +84 -34
- package/corpus/core/src/client/use-demo-mode-status.ts +44 -0
- package/corpus/core/src/client/use-pausing-interval.ts +14 -4
- package/corpus/core/src/integrations/scope-store.ts +1 -1
- package/corpus/core/src/integrations/usage-budget-store.ts +1 -1
- package/corpus/core/src/localization/default-messages.ts +44 -1
- package/corpus/core/src/mcp-client/workspace-servers.ts +4 -4
- package/corpus/core/src/secrets/crypto.ts +28 -8
- package/corpus/core/src/server/action-change.ts +5 -1
- package/corpus/core/src/server/action-routes.ts +8 -0
- package/corpus/core/src/server/poll.ts +1 -0
- package/corpus/core/src/server/realtime-voice.ts +299 -13
- package/corpus/core/src/styles/agent-native.css +2 -2
- package/corpus/core/src/templates/default/.agents/skills/real-time-sync/SKILL.md +2 -2
- package/corpus/core/src/templates/workspace-core/.agents/skills/real-time-sync/SKILL.md +2 -2
- package/corpus/core/src/templates/workspace-core/.agents/skills/secrets/SKILL.md +7 -3
- package/corpus/core/src/templates/workspace-core/.agents/skills/voice-transcription/SKILL.md +39 -9
- package/corpus/core/src/vite/client.ts +9 -1
- package/corpus/templates/analytics/.agents/skills/real-time-sync/SKILL.md +2 -2
- package/corpus/templates/analytics/.agents/skills/session-replay/SKILL.md +10 -5
- package/corpus/templates/analytics/AGENTS.md +17 -13
- package/corpus/templates/analytics/actions/navigate.ts +59 -5
- package/corpus/templates/analytics/actions/view-screen.ts +3 -6
- package/corpus/templates/analytics/app/components/ProviderCorpusJobNotifier.tsx +20 -3
- package/corpus/templates/analytics/app/components/dashboard/SqlChart.tsx +20 -5
- package/corpus/templates/analytics/app/components/layout/Header.tsx +1 -1
- package/corpus/templates/analytics/app/components/layout/Sidebar.tsx +21 -6
- package/corpus/templates/analytics/app/global.css +19 -20
- package/corpus/templates/analytics/app/lib/demo-chart-trend.ts +156 -0
- package/corpus/templates/analytics/app/lib/provider-corpus-job-sync.ts +26 -0
- package/corpus/templates/analytics/app/pages/Settings.tsx +35 -341
- package/corpus/templates/analytics/app/pages/monitoring/ErrorsPanel.tsx +38 -7
- package/corpus/templates/analytics/app/pages/monitoring/MonitoringPage.tsx +1 -1
- package/corpus/templates/analytics/app/pages/monitoring/errors/i18n.ts +3 -0
- package/corpus/templates/analytics/app/pages/sessions/SessionDetailPage.tsx +333 -272
- package/corpus/templates/analytics/app/pages/sessions/SessionDevToolsPanel.tsx +72 -17
- package/corpus/templates/analytics/app/pages/sessions/SessionsPage.tsx +297 -108
- package/corpus/templates/analytics/app/root.tsx +28 -8
- package/corpus/templates/analytics/changelog/2026-06-24-first-party-signup-and-pageview-panels-now-honor-dashboard-filters.md +2 -1
- package/corpus/templates/analytics/changelog/2026-06-25-referrer-dashboard-panels-show-external-domains.md +2 -1
- package/corpus/templates/analytics/changelog/2026-07-06-mobile-chat-header-is-more-compact-and-the-menu-button-opens-navigation.md +1 -0
- package/corpus/templates/analytics/changelog/2026-07-08-dashboard-history-and-chat-context.md +1 -0
- package/corpus/templates/analytics/changelog/2026-07-08-settings-are-cleaner-searchable-and-alerts-have-their-own-tab.md +1 -0
- package/corpus/templates/analytics/changelog/2026-07-08-sidebar-sections-stay-collapsed-until-opened.md +1 -0
- package/corpus/templates/analytics/changelog/2026-07-11-analytics-no-longer-repeatedly-restarts-background-requests-.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-11-analytics-only-asks-for-replay-storage-when-you-enable-sessi.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-11-charts-now-show-their-loading-skeleton-while-refreshing.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-11-realtime-voice-now-shows-a-clear-connection-indicator-comple.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-11-replay-event-counts-stay-hidden-until-recordings-finish-load.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-11-replay-storage-key-mismatches-show-actionable-setup-guidance.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-11-replay-timelines-group-continuous-scrolling-and-dev-tools-co.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-11-session-filters-now-stay-compact-in-a-settings-menu-at-mediu.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-11-session-replay-console-errors-now-link-to-matching-issues-or.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-11-session-replays-load-large-recordings-faster-and-surface-fai.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-11-session-replays-preserve-recorded-styles-and-viewport-layout.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-11-session-replays-stay-centered-instead-of-clipping-wide-recor.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-12-daily-dashboard-emails-reliably-include-the-complete-dashboa.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-12-demo-mode-charts-trend-upward.md +6 -0
- package/corpus/templates/analytics/package.json +1 -1
- package/corpus/templates/analytics/seeds/dashboards/agent-native-templates-first-party.json +1 -303
- package/corpus/templates/analytics/server/handlers/session-replay.ts +57 -0
- package/corpus/templates/analytics/server/jobs/dashboard-report.ts +2 -0
- package/corpus/templates/analytics/server/lib/dashboard-catalog.ts +1 -1
- package/corpus/templates/analytics/server/lib/dashboard-report.ts +17 -33
- package/corpus/templates/analytics/server/lib/demo-dashboards.ts +16 -3
- package/corpus/templates/analytics/server/lib/session-replay-agent-context.ts +12 -0
- package/corpus/templates/analytics/server/lib/session-replay.ts +208 -2
- package/corpus/templates/analytics/server/plugins/onboarding.ts +7 -79
- package/corpus/templates/analytics/server/routes/api/session-replay/recordings/[recordingId]/chunks.get.ts +1 -0
- package/corpus/templates/assets/.agents/skills/real-time-sync/SKILL.md +2 -2
- package/corpus/templates/assets/app/global.css +4 -4
- package/corpus/templates/assets/app/routes/brand-kits.$id.tsx +0 -1
- package/corpus/templates/assets/app/routes/library.tsx +0 -1
- package/corpus/templates/brain/.agents/skills/real-time-sync/SKILL.md +2 -2
- package/corpus/templates/brain/app/global.css +5 -5
- package/corpus/templates/brain/app/root.tsx +0 -3
- package/corpus/templates/calendar/.agents/skills/real-time-sync/SKILL.md +2 -2
- package/corpus/templates/calendar/app/root.tsx +1 -0
- package/corpus/templates/chat/.agents/skills/real-time-sync/SKILL.md +2 -2
- package/corpus/templates/clips/app/components/player/video-player.tsx +5 -1
- package/corpus/templates/clips/app/hooks/use-auto-title.ts +74 -8
- package/corpus/templates/clips/app/hooks/use-library.ts +12 -25
- package/corpus/templates/clips/app/routes/_app.settings._index.tsx +20 -22
- package/corpus/templates/clips/changelog/2026-07-11-clips-no-longer-stay-stuck-on-preparing-clip-when-they-are-r.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-11-generated-titles-no-longer-cause-continuous-background-refreshes.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-11-s3-storage-setup-stays-collapsed-until-you-choose-it-as-the-.md +6 -0
- package/corpus/templates/content/.agents/skills/real-time-sync/SKILL.md +2 -2
- package/corpus/templates/content/app/components/sidebar/DocumentSidebar.tsx +2 -2
- package/corpus/templates/content/app/hooks/use-comments.ts +0 -1
- package/corpus/templates/content/changelog/2026-07-11-comments-now-update-from-live-collaboration-events-without-c.md +6 -0
- package/corpus/templates/content/changelog/2026-07-12-the-left-sidebar-stays-fixed-horizontally-while-scrolling-on.md +6 -0
- package/corpus/templates/design/app/components/layout/Header.tsx +1 -1
- package/corpus/templates/forms/.agents/skills/real-time-sync/SKILL.md +2 -2
- package/corpus/templates/macros/app/components/layout/AppLayout.tsx +1 -2
- package/corpus/templates/macros/app/root.tsx +0 -3
- package/corpus/templates/mail/.agents/skills/real-time-sync/SKILL.md +2 -2
- package/corpus/templates/mail/app/hooks/use-compose-state.ts +1 -0
- package/corpus/templates/mail/app/root.tsx +1 -12
- package/corpus/templates/plan/.agents/skills/real-time-sync/SKILL.md +2 -2
- package/corpus/templates/plan/.agents/skills/visual-plan/references/local-files.md +17 -12
- package/corpus/templates/plan/.agents/skills/visual-recap/references/local-files.md +17 -12
- package/corpus/templates/plan/actions/validate-local-plan-source.ts +4 -4
- package/corpus/templates/plan/app/components/layout/Sidebar.tsx +2 -1
- package/corpus/templates/plan/app/hooks/use-navigation-state.ts +5 -2
- package/corpus/templates/plan/app/hooks/use-plans.ts +6 -13
- package/corpus/templates/plan/app/lib/plan-local-bridge.ts +41 -0
- package/corpus/templates/plan/app/lib/plan-tracking.ts +3 -0
- package/corpus/templates/plan/app/pages/PlansPage.tsx +14 -36
- package/corpus/templates/plan/app/root.tsx +13 -3
- package/corpus/templates/plan/changelog/2026-07-11-plan-refreshes-only-when-content-changes.md +6 -0
- package/corpus/templates/plan/changelog/2026-07-12-local-plan-source-now-stays-on-device.md +6 -0
- package/corpus/templates/slides/app/components/comments/SlideCommentsPanel.tsx +4 -1
- package/corpus/templates/slides/app/components/editor/EditorToolbar.tsx +1 -1
- package/corpus/templates/slides/app/components/layout/Header.tsx +1 -1
- package/corpus/templates/slides/app/context/DeckContext.tsx +1 -0
- package/corpus/templates/slides/app/hooks/use-slide-comments.ts +7 -31
- package/corpus/templates/slides/changelog/2026-07-11-comments-now-update-from-live-collaboration-events-without-c.md +6 -0
- package/dist/action-change-marker.d.ts +1 -0
- package/dist/action-change-marker.d.ts.map +1 -1
- package/dist/action-change-marker.js +7 -1
- package/dist/action-change-marker.js.map +1 -1
- package/dist/changelog/parse.d.ts +4 -2
- package/dist/changelog/parse.d.ts.map +1 -1
- package/dist/changelog/parse.js +5 -3
- package/dist/changelog/parse.js.map +1 -1
- package/dist/cli/plan-local.d.ts +6 -6
- package/dist/cli/plan-local.d.ts.map +1 -1
- package/dist/cli/plan-local.js +36 -7
- package/dist/cli/plan-local.js.map +1 -1
- package/dist/cli/pr-visual-recap-workflow.d.ts +2 -8
- package/dist/cli/pr-visual-recap-workflow.d.ts.map +1 -1
- package/dist/cli/pr-visual-recap-workflow.js +2 -8
- package/dist/cli/pr-visual-recap-workflow.js.map +1 -1
- package/dist/cli/recap.d.ts +22 -1
- package/dist/cli/recap.d.ts.map +1 -1
- package/dist/cli/recap.js +286 -2
- package/dist/cli/recap.js.map +1 -1
- package/dist/cli/skills-content/local-files.d.ts +1 -1
- package/dist/cli/skills-content/local-files.d.ts.map +1 -1
- package/dist/cli/skills-content/local-files.js +17 -12
- package/dist/cli/skills-content/local-files.js.map +1 -1
- package/dist/client/AgentPanel.d.ts.map +1 -1
- package/dist/client/AgentPanel.js +2 -3
- package/dist/client/AgentPanel.js.map +1 -1
- package/dist/client/AssistantChat.d.ts +7 -0
- package/dist/client/AssistantChat.d.ts.map +1 -1
- package/dist/client/AssistantChat.js +62 -40
- package/dist/client/AssistantChat.js.map +1 -1
- package/dist/client/analytics.d.ts +8 -0
- package/dist/client/analytics.d.ts.map +1 -1
- package/dist/client/analytics.js +103 -13
- package/dist/client/analytics.js.map +1 -1
- package/dist/client/blocks/library/wireframe-kit.d.ts +2 -0
- package/dist/client/blocks/library/wireframe-kit.d.ts.map +1 -1
- package/dist/client/blocks/library/wireframe-kit.js +9 -2
- package/dist/client/blocks/library/wireframe-kit.js.map +1 -1
- package/dist/client/chat-model-groups.d.ts.map +1 -1
- package/dist/client/chat-model-groups.js +24 -0
- package/dist/client/chat-model-groups.js.map +1 -1
- package/dist/client/composer/RealtimeVoiceMode.d.ts +40 -4
- package/dist/client/composer/RealtimeVoiceMode.d.ts.map +1 -1
- package/dist/client/composer/RealtimeVoiceMode.js +172 -42
- package/dist/client/composer/RealtimeVoiceMode.js.map +1 -1
- package/dist/client/composer/TiptapComposer.d.ts +4 -0
- package/dist/client/composer/TiptapComposer.d.ts.map +1 -1
- package/dist/client/composer/TiptapComposer.js +47 -29
- package/dist/client/composer/TiptapComposer.js.map +1 -1
- package/dist/client/composer/VoiceButton.d.ts.map +1 -1
- package/dist/client/composer/VoiceButton.js +2 -2
- package/dist/client/composer/VoiceButton.js.map +1 -1
- package/dist/client/composer/index.d.ts +2 -2
- package/dist/client/composer/index.d.ts.map +1 -1
- package/dist/client/composer/index.js +1 -1
- package/dist/client/composer/index.js.map +1 -1
- package/dist/client/composer/useRealtimeVoiceMode.d.ts +100 -3
- package/dist/client/composer/useRealtimeVoiceMode.d.ts.map +1 -1
- package/dist/client/composer/useRealtimeVoiceMode.js +952 -51
- package/dist/client/composer/useRealtimeVoiceMode.js.map +1 -1
- package/dist/client/index.d.ts +3 -2
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +3 -2
- package/dist/client/index.js.map +1 -1
- package/dist/client/progress/RunsTray.d.ts.map +1 -1
- package/dist/client/progress/RunsTray.js +10 -1
- package/dist/client/progress/RunsTray.js.map +1 -1
- package/dist/client/session-replay.d.ts +2 -0
- package/dist/client/session-replay.d.ts.map +1 -1
- package/dist/client/session-replay.js +7 -0
- package/dist/client/session-replay.js.map +1 -1
- package/dist/client/settings/DemoModeSection.d.ts.map +1 -1
- package/dist/client/settings/DemoModeSection.js +4 -23
- package/dist/client/settings/DemoModeSection.js.map +1 -1
- package/dist/client/settings/SecretsSection.d.ts +2 -3
- package/dist/client/settings/SecretsSection.d.ts.map +1 -1
- package/dist/client/settings/SecretsSection.js +46 -22
- package/dist/client/settings/SecretsSection.js.map +1 -1
- package/dist/client/settings/SettingsPanel.d.ts +9 -0
- package/dist/client/settings/SettingsPanel.d.ts.map +1 -1
- package/dist/client/settings/SettingsPanel.js +46 -12
- package/dist/client/settings/SettingsPanel.js.map +1 -1
- package/dist/client/url-scrub.d.ts.map +1 -1
- package/dist/client/url-scrub.js +14 -0
- package/dist/client/url-scrub.js.map +1 -1
- package/dist/client/use-action.d.ts +2 -0
- package/dist/client/use-action.d.ts.map +1 -1
- package/dist/client/use-action.js +10 -0
- package/dist/client/use-action.js.map +1 -1
- package/dist/client/use-agent-chat-home-handoff.d.ts +2 -0
- package/dist/client/use-agent-chat-home-handoff.d.ts.map +1 -1
- package/dist/client/use-agent-chat-home-handoff.js +7 -1
- package/dist/client/use-agent-chat-home-handoff.js.map +1 -1
- package/dist/client/use-agent-engine-configured.d.ts.map +1 -1
- package/dist/client/use-agent-engine-configured.js +17 -3
- package/dist/client/use-agent-engine-configured.js.map +1 -1
- package/dist/client/use-db-sync.d.ts +8 -2
- package/dist/client/use-db-sync.d.ts.map +1 -1
- package/dist/client/use-db-sync.js +57 -32
- package/dist/client/use-db-sync.js.map +1 -1
- package/dist/client/use-demo-mode-status.d.ts +12 -0
- package/dist/client/use-demo-mode-status.d.ts.map +1 -0
- package/dist/client/use-demo-mode-status.js +30 -0
- package/dist/client/use-demo-mode-status.js.map +1 -0
- package/dist/client/use-pausing-interval.d.ts.map +1 -1
- package/dist/client/use-pausing-interval.js +16 -4
- package/dist/client/use-pausing-interval.js.map +1 -1
- package/dist/collab/struct-routes.d.ts +1 -1
- package/dist/integrations/scope-store.js +1 -1
- package/dist/integrations/scope-store.js.map +1 -1
- package/dist/integrations/usage-budget-store.js +1 -1
- package/dist/integrations/usage-budget-store.js.map +1 -1
- package/dist/localization/default-messages.d.ts +41 -1
- package/dist/localization/default-messages.d.ts.map +1 -1
- package/dist/localization/default-messages.js +41 -1
- package/dist/localization/default-messages.js.map +1 -1
- package/dist/mcp-client/workspace-servers.js +4 -4
- package/dist/mcp-client/workspace-servers.js.map +1 -1
- package/dist/notifications/routes.d.ts +3 -3
- package/dist/progress/routes.d.ts +1 -1
- package/dist/provider-api/corpus-jobs.d.ts +2 -2
- package/dist/resources/handlers.d.ts +3 -3
- package/dist/secrets/crypto.d.ts +7 -6
- package/dist/secrets/crypto.d.ts.map +1 -1
- package/dist/secrets/crypto.js +30 -11
- package/dist/secrets/crypto.js.map +1 -1
- package/dist/server/action-change.d.ts +1 -0
- package/dist/server/action-change.d.ts.map +1 -1
- package/dist/server/action-change.js +4 -1
- package/dist/server/action-change.js.map +1 -1
- package/dist/server/action-routes.d.ts.map +1 -1
- package/dist/server/action-routes.js +5 -0
- package/dist/server/action-routes.js.map +1 -1
- package/dist/server/agent-engine-api-key-route.d.ts +1 -1
- package/dist/server/poll.d.ts.map +1 -1
- package/dist/server/poll.js +1 -0
- package/dist/server/poll.js.map +1 -1
- package/dist/server/realtime-voice.d.ts +7 -0
- package/dist/server/realtime-voice.d.ts.map +1 -1
- package/dist/server/realtime-voice.js +222 -12
- package/dist/server/realtime-voice.js.map +1 -1
- package/dist/styles/agent-native.css +2 -2
- package/dist/templates/default/.agents/skills/real-time-sync/SKILL.md +2 -2
- package/dist/templates/workspace-core/.agents/skills/real-time-sync/SKILL.md +2 -2
- package/dist/templates/workspace-core/.agents/skills/secrets/SKILL.md +7 -3
- package/dist/templates/workspace-core/.agents/skills/voice-transcription/SKILL.md +39 -9
- package/dist/vite/client.d.ts.map +1 -1
- package/dist/vite/client.js +6 -1
- package/dist/vite/client.js.map +1 -1
- package/docs/content/locales/ar-SA/pr-visual-recap.mdx +25 -1
- package/docs/content/locales/ar-SA/template-plan.mdx +1 -1
- package/docs/content/locales/de-DE/pr-visual-recap.mdx +25 -1
- package/docs/content/locales/de-DE/template-plan.mdx +1 -1
- package/docs/content/locales/es-ES/pr-visual-recap.mdx +25 -1
- package/docs/content/locales/es-ES/template-plan.mdx +1 -1
- package/docs/content/locales/fr-FR/pr-visual-recap.mdx +25 -1
- package/docs/content/locales/fr-FR/template-plan.mdx +1 -1
- package/docs/content/locales/hi-IN/pr-visual-recap.mdx +25 -1
- package/docs/content/locales/hi-IN/template-plan.mdx +1 -1
- package/docs/content/locales/ja-JP/pr-visual-recap.mdx +25 -1
- package/docs/content/locales/ja-JP/template-plan.mdx +1 -1
- package/docs/content/locales/ko-KR/pr-visual-recap.mdx +25 -1
- package/docs/content/locales/ko-KR/template-plan.mdx +1 -1
- package/docs/content/locales/pt-BR/pr-visual-recap.mdx +25 -1
- package/docs/content/locales/pt-BR/template-plan.mdx +1 -1
- package/docs/content/locales/zh-CN/pr-visual-recap.mdx +25 -1
- package/docs/content/locales/zh-CN/template-plan.mdx +1 -1
- package/docs/content/locales/zh-TW/pr-visual-recap.mdx +25 -1
- package/docs/content/locales/zh-TW/template-plan.mdx +1 -1
- package/docs/content/pr-visual-recap.mdx +50 -1
- package/docs/content/template-plan.mdx +1 -1
- package/package.json +2 -2
- package/src/templates/default/.agents/skills/real-time-sync/SKILL.md +2 -2
- package/src/templates/workspace-core/.agents/skills/real-time-sync/SKILL.md +2 -2
- package/src/templates/workspace-core/.agents/skills/secrets/SKILL.md +7 -3
- package/src/templates/workspace-core/.agents/skills/voice-transcription/SKILL.md +39 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url-scrub.d.ts","sourceRoot":"","sources":["../../src/client/url-scrub.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"url-scrub.d.ts","sourceRoot":"","sources":["../../src/client/url-scrub.ts"],"names":[],"mappings":"AAiBA,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAiCpE"}
|
package/dist/client/url-scrub.js
CHANGED
|
@@ -12,6 +12,7 @@ const SENSITIVE_QUERY_PARAMS = new Set([
|
|
|
12
12
|
"code",
|
|
13
13
|
"share",
|
|
14
14
|
"share_token",
|
|
15
|
+
"bridge",
|
|
15
16
|
]);
|
|
16
17
|
export function scrubUrl(url) {
|
|
17
18
|
if (!url || typeof url !== "string")
|
|
@@ -26,6 +27,19 @@ export function scrubUrl(url) {
|
|
|
26
27
|
mutated = true;
|
|
27
28
|
}
|
|
28
29
|
}
|
|
30
|
+
if (u.hash.includes("=")) {
|
|
31
|
+
const hashParams = new URLSearchParams(u.hash.slice(1));
|
|
32
|
+
let hashMutated = false;
|
|
33
|
+
for (const key of Array.from(hashParams.keys())) {
|
|
34
|
+
if (SENSITIVE_QUERY_PARAMS.has(key.toLowerCase())) {
|
|
35
|
+
hashParams.set(key, "<redacted>");
|
|
36
|
+
mutated = true;
|
|
37
|
+
hashMutated = true;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (hashMutated)
|
|
41
|
+
u.hash = hashParams.toString();
|
|
42
|
+
}
|
|
29
43
|
if (!mutated)
|
|
30
44
|
return url;
|
|
31
45
|
// If the original URL was relative, return only the path/query/fragment.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url-scrub.js","sourceRoot":"","sources":["../../src/client/url-scrub.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAC;IACrC,UAAU;IACV,GAAG;IACH,OAAO;IACP,OAAO;IACP,MAAM;IACN,OAAO;IACP,aAAa;
|
|
1
|
+
{"version":3,"file":"url-scrub.js","sourceRoot":"","sources":["../../src/client/url-scrub.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAC;IACrC,UAAU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CAAC,CAAC,IAAI,GAAG,UAAU,CAAC,QAAQ,EAAE,CAAC;QAClD,CAAC;QACD,IAAI,CAAC,OAAO;YAAE,OAAO,GAAG,CAAC;QACzB,yEAAyE;QACzE,IAAI,CAAC,CAAC,MAAM,KAAK,0BAA0B,EAAE,CAAC;YAC5C,OAAO,GAAG,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;QAC7C,CAAC;QACD,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC;IACtB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,GAAG,CAAC;IACb,CAAC;AACH,CAAC","sourcesContent":["/**\n * Query parameters that may carry sensitive values in the URL bar. Browser\n * telemetry and feedback integrations must not copy OAuth codes, share tokens,\n * password params, email-confirm tokens, or similar secrets into downstream\n * systems.\n */\nconst SENSITIVE_QUERY_PARAMS = new Set([\n \"password\",\n \"p\",\n \"token\",\n \"state\",\n \"code\",\n \"share\",\n \"share_token\",\n \"bridge\",\n]);\n\nexport function scrubUrl(url: string | undefined): string | undefined {\n if (!url || typeof url !== \"string\") return url;\n try {\n // Parse using a base origin so relative URLs still work.\n const u = new URL(url, \"http://placeholder.local\");\n let mutated = false;\n for (const key of Array.from(u.searchParams.keys())) {\n if (SENSITIVE_QUERY_PARAMS.has(key.toLowerCase())) {\n u.searchParams.set(key, \"<redacted>\");\n mutated = true;\n }\n }\n if (u.hash.includes(\"=\")) {\n const hashParams = new URLSearchParams(u.hash.slice(1));\n let hashMutated = false;\n for (const key of Array.from(hashParams.keys())) {\n if (SENSITIVE_QUERY_PARAMS.has(key.toLowerCase())) {\n hashParams.set(key, \"<redacted>\");\n mutated = true;\n hashMutated = true;\n }\n }\n if (hashMutated) u.hash = hashParams.toString();\n }\n if (!mutated) return url;\n // If the original URL was relative, return only the path/query/fragment.\n if (u.origin === \"http://placeholder.local\") {\n return `${u.pathname}${u.search}${u.hash}`;\n }\n return u.toString();\n } catch {\n return url;\n }\n}\n"]}
|
|
@@ -55,6 +55,8 @@ export interface ActionFetchOptions {
|
|
|
55
55
|
keepalive?: boolean;
|
|
56
56
|
/** Pre-serialized mutation body used by the keepalive budget coordinator. */
|
|
57
57
|
serializedBody?: string;
|
|
58
|
+
/** Omit the tab echo-suppression tag for imperative callers. */
|
|
59
|
+
includeRequestSource?: boolean;
|
|
58
60
|
}
|
|
59
61
|
/**
|
|
60
62
|
* Conservative per-document keepalive body budget. Browsers commonly enforce
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-action.d.ts","sourceRoot":"","sources":["../../src/client/use-action.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EACV,eAAe,EACf,kBAAkB,EACnB,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"use-action.d.ts","sourceRoot":"","sources":["../../src/client/use-action.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EACV,eAAe,EACf,kBAAkB,EACnB,MAAM,uBAAuB,CAAC;AAmC/B,mCAAmC;AACnC,wBAAgB,uBAAuB,CACrC,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,OAAO,GACb,OAAO,CAaT;AAED,+CAA+C;AAC/C,eAAO,MAAM,8BAA8B,gCAA0B,CAAC;AAwBtE;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAEzE;AAMD;;;;;GAKG;AACH,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,yBAAyB;KAAG;CACvC;AAED,MAAM,WAAW,cAAe,SAAQ,yBAAyB;CAAG;AAEpE,2FAA2F;AAC3F,KAAK,UAAU,GAAG,MAAM,cAAc,SAAS,KAAK,GAChD,MAAM,GACN,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAEpD,8EAA8E;AAC9E,KAAK,YAAY,CAAC,CAAC,SAAS,MAAM,IAAI,CAAC,SAAS,MAA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AK,GAAG,SAAS,EACjB,UAAU,GAAG,SAAS,EACtB,KAAK,SAAS,UAAU,GAAG,UAAU,EAErC,UAAU,EAAE,KAAK,EACjB,OAAO,CAAC,EAAE,IAAI,CACZ,kBAAkB,CAChB,KAAK,SAAS,SAAS,GAAG,YAAY,CAAC,KAAK,CAAC,GAAG,KAAK,EACrD,KAAK,EACL,UAAU,SAAS,SAAS,GAAG,YAAY,CAAC,KAAK,CAAC,GAAG,UAAU,CAChE,EACD,YAAY,CACb,GAAG;IACF,MAAM,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,QAAQ,CAAC;IACnC,2BAA2B,CAAC,EAAE,OAAO,CAAC;CACvC,6LA2BF"}
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
*/
|
|
24
24
|
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
|
|
25
25
|
import { agentNativePath } from "./api-path.js";
|
|
26
|
+
import { getBrowserTabId } from "./browser-tab-id.js";
|
|
26
27
|
import { ensureEmbedAuthFetchInterceptor } from "./embed-auth.js";
|
|
27
28
|
const ACTION_PREFIX = agentNativePath("/_agent-native/actions");
|
|
28
29
|
/**
|
|
@@ -166,6 +167,14 @@ async function actionFetch(name, method, params, options) {
|
|
|
166
167
|
// safe to expose: CORS allows it (see action-routes.ts) and it carries
|
|
167
168
|
// no auth weight — it only narrows the caller tag.
|
|
168
169
|
"X-Agent-Native-Frontend": "1",
|
|
170
|
+
...(options?.includeRequestSource !== false
|
|
171
|
+
? {
|
|
172
|
+
// The server copies this onto the emitted action sync event.
|
|
173
|
+
// useDbSync can then ignore the echo in this tab while other tabs
|
|
174
|
+
// still refresh.
|
|
175
|
+
"X-Request-Source": getBrowserTabId(),
|
|
176
|
+
}
|
|
177
|
+
: {}),
|
|
169
178
|
};
|
|
170
179
|
const tz = resolveUserTimezone();
|
|
171
180
|
if (tz)
|
|
@@ -316,6 +325,7 @@ export function callAction(actionName, params, options = {}) {
|
|
|
316
325
|
return actionFetch(actionName, options.method ?? "POST", params, {
|
|
317
326
|
signal: options.signal,
|
|
318
327
|
timeoutMs: options.timeoutMs,
|
|
328
|
+
includeRequestSource: false,
|
|
319
329
|
});
|
|
320
330
|
}
|
|
321
331
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-action.js","sourceRoot":"","sources":["../../src/client/use-action.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAM9E,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,+BAA+B,EAAE,MAAM,iBAAiB,CAAC;AAElE,MAAM,aAAa,GAAG,eAAe,CAAC,wBAAwB,CAAC,CAAC;AAEhE;;;;;;GAMG;AACH,MAAM,yBAAyB,GAAG,MAAM,CAAC;AAEzC,SAAS,aAAa,CAAC,KAAc;IACnC,OAAO,CACL,CAAC,CAAC,KAAK;QACP,OAAO,KAAK,KAAK,QAAQ;QACzB,QAAQ,IAAI,KAAK;QACjB,CAAE,KAA8B,CAAC,MAAM,KAAK,GAAG;YAC5C,KAA8B,CAAC,MAAM,KAAK,GAAG,CAAC,CAClD,CAAC;AACJ,CAAC;AAED,SAAS,eAAe,CAAC,KAAc;IACrC,OAAO,CACL,CAAC,CAAC,KAAK;QACP,OAAO,KAAK,KAAK,QAAQ;QACxB,KAAgC,CAAC,QAAQ,KAAK,IAAI,CACpD,CAAC;AACJ,CAAC;AAED,mCAAmC;AACnC,MAAM,UAAU,uBAAuB,CACrC,YAAoB,EACpB,KAAc;IAEd,IAAI,aAAa,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACvC,qEAAqE;IACrE,kEAAkE;IAClE,IAAI,eAAe,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACzC,IAAI,2BAA2B,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;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AC;IAKnC,OAAO,WAAW,CAAc;QAC9B,GAAG,WAAW;QACd,UAAU,EAAE,CAAC,MAAM,EAAE,EAAE,CACrB,WAAW,CAAI,UAAU,EAAE,MAAM,EAAE,MAA6B,CAAC;QACnE,SAAS,EAAE,CAAC,GAAG,IAAqB,EAAE,EAAE;YACtC,iEAAiE;YACjE,wEAAwE;YACxE,IAAI,CAAC,2BAA2B,EAAE,CAAC;gBACjC,WAAW,CAAC,iBAAiB,CAAC,EAAE,QAAQ,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;YAC1D,CAAC;YACA,SAAsB,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;QACrC,CAAC;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * Client helpers for calling actions through the framework transport.\n *\n * Components should prefer `useActionQuery` / `useActionMutation`; use\n * `callAction` for imperative cases such as debounced search, prefetching, or\n * event handlers that do not fit a hook.\n *\n * ## End-to-end type safety\n *\n * When the action type registry is generated (via the Vite plugin or CLI),\n * `useActionQuery` and `useActionMutation` automatically infer the correct\n * return type and parameter types from the action definitions — no manual\n * type annotations needed.\n *\n * ```ts\n * // Fully typed — return type and params inferred from the action's defineAction()\n * const { data } = useActionQuery(\"list-forms\", { status: \"published\" });\n * // ^? Form[] (inferred from the action's run() return type)\n * ```\n *\n * Without the registry, the hooks fall back to `any` types for backward\n * compatibility.\n */\nimport { useQuery, useMutation, useQueryClient } from \"@tanstack/react-query\";\nimport type {\n UseQueryOptions,\n UseMutationOptions,\n} from \"@tanstack/react-query\";\n\nimport { agentNativePath } from \"./api-path.js\";\nimport { ensureEmbedAuthFetchInterceptor } from \"./embed-auth.js\";\n\nconst ACTION_PREFIX = agentNativePath(\"/_agent-native/actions\");\n\n/**\n * Upper bound on how long a single action fetch may stay in flight (headers\n * AND body). Converts a hung server/proxy/connection into a visible, typed\n * failure instead of a UI that spins forever. Generous on purpose: it sits\n * above every server-side budget (serverless function limits, hosted run\n * wall-clock), so it only fires when something is genuinely stuck.\n */\nconst DEFAULT_ACTION_TIMEOUT_MS = 60_000;\n\nfunction isAuthFailure(error: unknown): boolean {\n return (\n !!error &&\n typeof error === \"object\" &&\n \"status\" in error &&\n ((error as { status?: unknown }).status === 401 ||\n (error as { status?: unknown }).status === 403)\n );\n}\n\nfunction isActionTimeout(error: unknown): boolean {\n return (\n !!error &&\n typeof error === \"object\" &&\n (error as { timedOut?: unknown }).timedOut === true\n );\n}\n\n/** @internal exported for tests */\nexport function defaultActionQueryRetry(\n failureCount: number,\n error: unknown,\n): boolean {\n if (isAuthFailure(error)) return false;\n // A timeout already made the user wait the full timeout window once;\n // silently retrying would multiply that wait. Surface it instead.\n if (isActionTimeout(error)) return false;\n if (isBrowserResourceExhaustion(error)) return false;\n // Network-level failures never carry an HTTP `status` (actionFetch only\n // sets it after a response arrives). Chrome reports connection-pool\n // exhaustion (net::ERR_INSUFFICIENT_RESOURCES) as a generic \"Failed to\n // fetch\", indistinguishable from a transient blip — allow one retry, not\n // three, so an exhausted tab cannot sustain its own fetch storm.\n if (isNetworkLevelFailure(error)) return failureCount < 1;\n return failureCount < 3;\n}\n\n/** @internal alias kept for existing specs. */\nexport const shouldRetryActionQueryForError = defaultActionQueryRetry;\n\nfunction isBrowserResourceExhaustion(error: unknown): boolean {\n const message =\n error instanceof Error\n ? error.message\n : typeof error === \"string\"\n ? error\n : \"\";\n return /ERR_INSUFFICIENT_RESOURCES|insufficient resources/i.test(message);\n}\n\nfunction isNetworkLevelFailure(error: unknown): boolean {\n // Match the exact shape actionFetch produces for fetch-level failures (its\n // catch wraps the cause as \"Action <name> failed: <cause>\" and never sets a\n // status). Other status-less errors (test doubles, transport internals)\n // keep the standard three-retry policy.\n return (\n error instanceof Error &&\n (error as { status?: unknown }).status === undefined &&\n /^Action .+ failed: /.test(error.message)\n );\n}\n\n/**\n * Default retry backoff for action queries. React Query's stock retryDelay\n * (1s → 2s → 4s) makes a failing query sit on a spinner for ~7s before the\n * error surfaces; interactive data fetches want failures visible fast.\n *\n * @internal exported for tests\n */\nexport function defaultActionQueryRetryDelay(failureCount: number): number {\n return Math.min(500 * 2 ** failureCount, 2_000);\n}\n\n// ---------------------------------------------------------------------------\n// Action type registry — augmented by generated code\n// ---------------------------------------------------------------------------\n\n/**\n * Action type registry. This interface is empty by default and gets augmented\n * by the auto-generated `.generated/action-types.d.ts` file. When augmented,\n * it maps action names to their parameter and return types, enabling\n * end-to-end type safety for `useActionQuery` and `useActionMutation`.\n */\ndeclare global {\n interface AgentNativeActionRegistry {}\n}\n\nexport interface ActionRegistry extends AgentNativeActionRegistry {}\n\n/** Resolves to the union of registered action names, or `string` if no registry exists. */\ntype ActionName = keyof ActionRegistry extends never\n ? string\n : (keyof ActionRegistry & string) | (string & {});\n\n/** Resolves the return type of an action, or `any` if not in the registry. */\ntype ActionResult<T extends string> = T extends keyof ActionRegistry\n ? ActionRegistry[T] extends { result: infer R }\n ? R\n : any\n : any;\n\n/** Resolves the parameter type of an action, or `Record<string, any>` if not in the registry. */\ntype ActionParams<T extends string> = T extends keyof ActionRegistry\n ? ActionRegistry[T] extends { params: infer P }\n ? P\n : Record<string, any>\n : Record<string, any>;\n\nexport type ClientActionMethod = \"GET\" | \"POST\" | \"PUT\" | \"DELETE\";\n\nexport interface ClientActionCallOptions {\n method?: ClientActionMethod;\n /** Abort signal for the underlying fetch. */\n signal?: AbortSignal;\n /** Override the default 60s fetch timeout for long-running actions. */\n timeoutMs?: number;\n}\n\n// ---------------------------------------------------------------------------\n// Fetch helper\n// ---------------------------------------------------------------------------\n\n/**\n * Resolve the browser's IANA timezone (e.g. \"America/Los_Angeles\"). This is\n * sent on every action request as `x-user-timezone` so server-side defaults\n * like \"today\" honor the user's local day rather than the server's UTC clock.\n */\nfunction resolveUserTimezone(): string | undefined {\n try {\n return Intl.DateTimeFormat().resolvedOptions().timeZone || undefined;\n } catch {\n return undefined;\n }\n}\n\nexport function serializeActionQueryParams(\n params: Record<string, any>,\n): string {\n const qs = new URLSearchParams();\n for (const [key, value] of Object.entries(params)) {\n appendActionQueryParam(qs, key, value);\n }\n return qs.toString();\n}\n\nfunction appendActionQueryParam(\n qs: URLSearchParams,\n key: string,\n value: unknown,\n) {\n if (value === null || value === undefined) return;\n if (Array.isArray(value)) {\n // Use bracket keys so a one-item array still arrives as an array after the\n // server parses URLSearchParams. Repeated bare keys lose that distinction.\n for (const item of value) {\n appendActionQueryParam(qs, `${key}[]`, item);\n }\n return;\n }\n qs.append(key, String(value));\n}\n\nexport interface ActionFetchOptions {\n /**\n * Abort signal from the caller (React Query passes one per queryFn\n * invocation so superseded requests — key change, unmount, refetch — cancel\n * the underlying network request instead of hogging a connection slot).\n */\n signal?: AbortSignal;\n /** Per-call override for the fetch timeout. */\n timeoutMs?: number;\n /** Keep the request alive while the document is being unloaded. */\n keepalive?: boolean;\n /** Pre-serialized mutation body used by the keepalive budget coordinator. */\n serializedBody?: string;\n}\n\n/**\n * Conservative per-document keepalive body budget. Browsers commonly enforce\n * an approximately 64 KiB aggregate limit across every in-flight keepalive\n * request; leaving headroom for other framework traffic prevents a request\n * that passed our guard from being rejected by the browser at send time.\n */\nexport const ACTION_KEEPALIVE_BODY_BUDGET_BYTES = 48_000;\n\nlet reservedKeepaliveBodyBytes = 0;\n\nfunction utf8ByteLength(value: string): number {\n if (typeof TextEncoder !== \"undefined\") {\n return new TextEncoder().encode(value).byteLength;\n }\n\n let bytes = 0;\n for (const character of value) {\n const codePoint = character.codePointAt(0) ?? 0;\n bytes +=\n codePoint <= 0x7f\n ? 1\n : codePoint <= 0x7ff\n ? 2\n : codePoint <= 0xffff\n ? 3\n : 4;\n }\n return bytes;\n}\n\nasync function actionFetch<T>(\n name: string,\n method: string,\n params?: Record<string, any>,\n options?: ActionFetchOptions,\n): Promise<T> {\n ensureEmbedAuthFetchInterceptor();\n let url = `${ACTION_PREFIX}/${name}`;\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n // Tag browser-originated action calls so the server can set\n // `ctx.caller = \"frontend\"` (vs a bare programmatic `\"http\"` POST).\n // Mirrors the X-Agent-Native-Tool-Bridge: 1 convention. The header is\n // safe to expose: CORS allows it (see action-routes.ts) and it carries\n // no auth weight — it only narrows the caller tag.\n \"X-Agent-Native-Frontend\": \"1\",\n };\n const tz = resolveUserTimezone();\n if (tz) headers[\"x-user-timezone\"] = tz;\n const init: RequestInit = {\n method,\n headers,\n cache: \"no-store\",\n keepalive: options?.keepalive,\n };\n\n if (method === \"GET\" && params && Object.keys(params).length > 0) {\n // Skip null/undefined so optional filters don't turn into literal \"null\"\n // strings in the query string (e.g. `?folderId=null`).\n const qs = serializeActionQueryParams(params);\n if (qs) url += `?${qs}`;\n } else if (method !== \"GET\" && params) {\n init.body = options?.serializedBody ?? JSON.stringify(params);\n }\n\n // One controller drives both cancellation sources: the caller's signal\n // (superseded query, unmount) and the timeout. The timer stays armed until\n // the BODY is fully read — headers arriving quickly while the body stalls\n // is exactly the hang this bounds.\n const outerSignal = options?.signal;\n const timeoutMs = options?.timeoutMs ?? DEFAULT_ACTION_TIMEOUT_MS;\n const controller =\n typeof AbortController === \"undefined\" ? null : new AbortController();\n const onOuterAbort = () => controller?.abort();\n if (outerSignal && controller) {\n if (outerSignal.aborted) controller.abort();\n else outerSignal.addEventListener(\"abort\", onOuterAbort, { once: true });\n }\n let timedOut = false;\n const timer = controller\n ? setTimeout(() => {\n timedOut = true;\n controller.abort();\n }, timeoutMs)\n : null;\n if (controller) init.signal = controller.signal;\n\n const throwTimeout = (): never => {\n const error = new Error(\n `Action ${name} timed out after ${Math.round(timeoutMs / 1000)}s`,\n );\n (error as any).timedOut = true;\n (error as any).status = 408;\n throw error;\n };\n\n let res: Response;\n let raw = \"\";\n let readFailed = false;\n let readError: unknown;\n try {\n try {\n res = await fetch(url, init);\n } catch (err) {\n if (timedOut) throwTimeout();\n // Caller-initiated cancellation — rethrow untouched so React Query\n // recognizes it as a cancellation rather than a query failure.\n if (outerSignal?.aborted) throw err;\n // Network failures, CORS, server unreachable, etc. — give the caller a\n // useful message instead of the opaque \"Failed to fetch\".\n const cause = err instanceof Error ? err.message : String(err);\n throw new Error(`Action ${name} failed: ${cause}`);\n }\n\n // 204 No Content — nothing to parse.\n if (res.status === 204) return null as T;\n\n // Read the body as text first so we can:\n // - tolerate empty bodies (avoids \"Unexpected end of JSON input\")\n // - surface non-JSON error responses (HTML 401/404 pages, plain text, etc.)\n // - preserve the original HTTP status in the thrown error\n // Track read failures separately from \"no body\" — a stream interruption /\n // decode failure on a 2xx response should error rather than silently\n // succeed with `null`.\n try {\n raw = await res.text();\n } catch (err) {\n if (timedOut) throwTimeout();\n if (outerSignal?.aborted) throw err;\n readFailed = true;\n readError = err;\n }\n } finally {\n if (timer) clearTimeout(timer);\n if (outerSignal) outerSignal.removeEventListener(\"abort\", onOuterAbort);\n }\n\n let data: any = undefined;\n let parseFailed = false;\n if (raw.length > 0) {\n try {\n data = JSON.parse(raw);\n } catch {\n // Body wasn't JSON — keep `data` undefined and use the raw text below.\n parseFailed = true;\n }\n }\n\n if (!res.ok) {\n const message =\n (data && (data.error || data.message)) ||\n // Truncate non-JSON bodies so we don't dump entire HTML pages into the\n // console, but still give the developer a hint as to what came back.\n (raw && raw.slice(0, 200)) ||\n res.statusText ||\n `HTTP ${res.status}`;\n const error = new Error(`Action ${name} failed: ${message}`);\n (error as any).status = res.status;\n throw error;\n }\n\n // 2xx but the body couldn't even be read (mid-stream abort, decode failure,\n // etc.). Don't silently treat that as a `null` success.\n if (readFailed) {\n const cause =\n readError instanceof Error ? readError.message : String(readError);\n const error = new Error(\n `Action ${name} returned ${res.status} but the body could not be read: ${cause}`,\n );\n (error as any).status = res.status;\n throw error;\n }\n\n // 2xx with a non-empty, non-JSON body. Action callers expect typed data, so\n // returning `null` here would silently mask a real server bug (e.g. a proxy\n // returning HTML 200 instead of JSON). Throw instead — empty bodies (handled\n // above by the `raw.length > 0` guard and the 204 short-circuit) still\n // correctly resolve to `null`.\n if (parseFailed) {\n const error = new Error(\n `Action ${name} returned a non-JSON ${res.status} response: ${raw.slice(0, 200)}`,\n );\n (error as any).status = res.status;\n throw error;\n }\n\n return (data ?? (null as unknown)) as T;\n}\n\n/**\n * Imperatively call an action from browser/client code.\n *\n * Prefer `useActionQuery` / `useActionMutation` in React render flows. Use this\n * helper when a hook is not ergonomic; do not hand-write fetch calls to\n * `/_agent-native/actions/*` in components.\n */\nexport function callAction<\n TResult = undefined,\n TName extends ActionName = ActionName,\n>(\n actionName: TName,\n params?: ActionParams<TName>,\n options: ClientActionCallOptions = {},\n): Promise<TResult extends undefined ? ActionResult<TName> : TResult> {\n type R = TResult extends undefined ? ActionResult<TName> : TResult;\n return actionFetch<R>(actionName, options.method ?? \"POST\", params, {\n signal: options.signal,\n timeoutMs: options.timeoutMs,\n });\n}\n\nexport type KeepaliveActionCallRejectionReason =\n | \"body-too-large\"\n | \"budget-exhausted\";\n\nexport type KeepaliveActionCallResult<TResult> =\n | {\n accepted: true;\n bodyBytes: number;\n completion: Promise<TResult>;\n }\n | {\n accepted: false;\n bodyBytes: number;\n reason: KeepaliveActionCallRejectionReason;\n completion: null;\n };\n\n/**\n * Attempts an unload-safe action call without exceeding the browser's shared\n * keepalive request budget. The reservation remains held until the response\n * body has completed, because browsers count every in-flight keepalive body\n * against the same per-document quota.\n *\n * A rejected attempt is deliberately synchronous so callers can fall back to\n * a durable outbox before returning from `pagehide`.\n */\nexport function tryCallActionKeepalive<\n TResult = undefined,\n TName extends ActionName = ActionName,\n>(\n actionName: TName,\n params?: ActionParams<TName>,\n options: Omit<ClientActionCallOptions, \"method\"> = {},\n): KeepaliveActionCallResult<\n TResult extends undefined ? ActionResult<TName> : TResult\n> {\n type R = TResult extends undefined ? ActionResult<TName> : TResult;\n const serializedBody = JSON.stringify(params ?? {});\n const bodyBytes = utf8ByteLength(serializedBody);\n\n if (bodyBytes > ACTION_KEEPALIVE_BODY_BUDGET_BYTES) {\n return {\n accepted: false,\n bodyBytes,\n reason: \"body-too-large\",\n completion: null,\n };\n }\n\n if (\n reservedKeepaliveBodyBytes + bodyBytes >\n ACTION_KEEPALIVE_BODY_BUDGET_BYTES\n ) {\n return {\n accepted: false,\n bodyBytes,\n reason: \"budget-exhausted\",\n completion: null,\n };\n }\n\n reservedKeepaliveBodyBytes += bodyBytes;\n const completion = actionFetch<R>(actionName, \"POST\", params, {\n signal: options.signal,\n timeoutMs: options.timeoutMs,\n keepalive: true,\n serializedBody,\n }).finally(() => {\n reservedKeepaliveBodyBytes = Math.max(\n 0,\n reservedKeepaliveBodyBytes - bodyBytes,\n );\n });\n\n return { accepted: true, bodyBytes, completion };\n}\n\n// ---------------------------------------------------------------------------\n// Query hook\n// ---------------------------------------------------------------------------\n\n/**\n * Query an action exposed as GET.\n *\n * When the action type registry is generated, the return type and parameter\n * types are inferred automatically from the action's `defineAction()` call.\n *\n * ```ts\n * // Type-safe — no manual generic needed\n * const { data } = useActionQuery(\"list-meals\", { date: \"2025-01-01\" });\n *\n * // Manual override still works when needed\n * const { data } = useActionQuery<CustomType>(\"list-meals\");\n * ```\n */\nexport function useActionQuery<\n TResult = undefined,\n TName extends ActionName = ActionName,\n>(\n actionName: TName,\n params?: ActionParams<TName>,\n options?: Omit<\n UseQueryOptions<TResult extends undefined ? ActionResult<TName> : TResult>,\n \"queryKey\" | \"queryFn\"\n >,\n) {\n type R = TResult extends undefined ? ActionResult<TName> : TResult;\n return useQuery<R>({\n queryKey: [\"action\", actionName, params],\n // Thread React Query's per-fetch AbortSignal into the network request so\n // superseded fetches (key change, unmount, rapid refetch) actually cancel\n // instead of holding a per-origin connection slot until they finish.\n queryFn: ({ signal }) =>\n actionFetch<R>(actionName, \"GET\", params, { signal }),\n retry: defaultActionQueryRetry,\n retryDelay: defaultActionQueryRetryDelay,\n ...options,\n });\n}\n\n// ---------------------------------------------------------------------------\n// Mutation hook\n// ---------------------------------------------------------------------------\n\n/**\n * Mutate via an action exposed as POST (default), PUT, or DELETE.\n *\n * When the action type registry is generated, the return type and parameter\n * types are inferred automatically.\n *\n * ```ts\n * // Type-safe\n * const { mutate } = useActionMutation(\"log-meal\");\n * mutate({ name: \"Salad\", calories: 350 });\n * ```\n */\nexport function useActionMutation<\n TData = undefined,\n TVariables = undefined,\n TName extends ActionName = ActionName,\n>(\n actionName: TName,\n options?: Omit<\n UseMutationOptions<\n TData extends undefined ? ActionResult<TName> : TData,\n Error,\n TVariables extends undefined ? ActionParams<TName> : TVariables\n >,\n \"mutationFn\"\n > & {\n method?: \"POST\" | \"PUT\" | \"DELETE\";\n skipActionQueryInvalidation?: boolean;\n },\n) {\n const queryClient = useQueryClient();\n const {\n method: methodOpt,\n onSuccess,\n skipActionQueryInvalidation = false,\n ...restOptions\n } = options ?? ({} as any);\n const method = methodOpt ?? \"POST\";\n\n type D = TData extends undefined ? ActionResult<TName> : TData;\n type V = TVariables extends undefined ? ActionParams<TName> : TVariables;\n\n return useMutation<D, Error, V>({\n ...restOptions,\n mutationFn: (params) =>\n actionFetch<D>(actionName, method, params as Record<string, any>),\n onSuccess: (...args: [any, any, any]) => {\n // Most mutations change app data broadly. High-volume background\n // mutations can opt out and perform narrower invalidation in onSuccess.\n if (!skipActionQueryInvalidation) {\n queryClient.invalidateQueries({ queryKey: [\"action\"] });\n }\n (onSuccess as Function)?.(...args);\n },\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"use-action.js","sourceRoot":"","sources":["../../src/client/use-action.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAM9E,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,+BAA+B,EAAE,MAAM,iBAAiB,CAAC;AAElE,MAAM,aAAa,GAAG,eAAe,CAAC,wBAAwB,CAAC,CAAC;AAEhE;;;;;;GAMG;AACH,MAAM,yBAAyB,GAAG,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C,CAAC;YAC1D,CAAC;YACA,SAAsB,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;QACrC,CAAC;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * Client helpers for calling actions through the framework transport.\n *\n * Components should prefer `useActionQuery` / `useActionMutation`; use\n * `callAction` for imperative cases such as debounced search, prefetching, or\n * event handlers that do not fit a hook.\n *\n * ## End-to-end type safety\n *\n * When the action type registry is generated (via the Vite plugin or CLI),\n * `useActionQuery` and `useActionMutation` automatically infer the correct\n * return type and parameter types from the action definitions — no manual\n * type annotations needed.\n *\n * ```ts\n * // Fully typed — return type and params inferred from the action's defineAction()\n * const { data } = useActionQuery(\"list-forms\", { status: \"published\" });\n * // ^? Form[] (inferred from the action's run() return type)\n * ```\n *\n * Without the registry, the hooks fall back to `any` types for backward\n * compatibility.\n */\nimport { useQuery, useMutation, useQueryClient } from \"@tanstack/react-query\";\nimport type {\n UseQueryOptions,\n UseMutationOptions,\n} from \"@tanstack/react-query\";\n\nimport { agentNativePath } from \"./api-path.js\";\nimport { getBrowserTabId } from \"./browser-tab-id.js\";\nimport { ensureEmbedAuthFetchInterceptor } from \"./embed-auth.js\";\n\nconst ACTION_PREFIX = agentNativePath(\"/_agent-native/actions\");\n\n/**\n * Upper bound on how long a single action fetch may stay in flight (headers\n * AND body). Converts a hung server/proxy/connection into a visible, typed\n * failure instead of a UI that spins forever. Generous on purpose: it sits\n * above every server-side budget (serverless function limits, hosted run\n * wall-clock), so it only fires when something is genuinely stuck.\n */\nconst DEFAULT_ACTION_TIMEOUT_MS = 60_000;\n\nfunction isAuthFailure(error: unknown): boolean {\n return (\n !!error &&\n typeof error === \"object\" &&\n \"status\" in error &&\n ((error as { status?: unknown }).status === 401 ||\n (error as { status?: unknown }).status === 403)\n );\n}\n\nfunction isActionTimeout(error: unknown): boolean {\n return (\n !!error &&\n typeof error === \"object\" &&\n (error as { timedOut?: unknown }).timedOut === true\n );\n}\n\n/** @internal exported for tests */\nexport function defaultActionQueryRetry(\n failureCount: number,\n error: unknown,\n): boolean {\n if (isAuthFailure(error)) return false;\n // A timeout already made the user wait the full timeout window once;\n // silently retrying would multiply that wait. Surface it instead.\n if (isActionTimeout(error)) return false;\n if (isBrowserResourceExhaustion(error)) return false;\n // Network-level failures never carry an HTTP `status` (actionFetch only\n // sets it after a response arrives). Chrome reports connection-pool\n // exhaustion (net::ERR_INSUFFICIENT_RESOURCES) as a generic \"Failed to\n // fetch\", indistinguishable from a transient blip — allow one retry, not\n // three, so an exhausted tab cannot sustain its own fetch storm.\n if (isNetworkLevelFailure(error)) return failureCount < 1;\n return failureCount < 3;\n}\n\n/** @internal alias kept for existing specs. */\nexport const shouldRetryActionQueryForError = defaultActionQueryRetry;\n\nfunction isBrowserResourceExhaustion(error: unknown): boolean {\n const message =\n error instanceof Error\n ? error.message\n : typeof error === \"string\"\n ? error\n : \"\";\n return /ERR_INSUFFICIENT_RESOURCES|insufficient resources/i.test(message);\n}\n\nfunction isNetworkLevelFailure(error: unknown): boolean {\n // Match the exact shape actionFetch produces for fetch-level failures (its\n // catch wraps the cause as \"Action <name> failed: <cause>\" and never sets a\n // status). Other status-less errors (test doubles, transport internals)\n // keep the standard three-retry policy.\n return (\n error instanceof Error &&\n (error as { status?: unknown }).status === undefined &&\n /^Action .+ failed: /.test(error.message)\n );\n}\n\n/**\n * Default retry backoff for action queries. React Query's stock retryDelay\n * (1s → 2s → 4s) makes a failing query sit on a spinner for ~7s before the\n * error surfaces; interactive data fetches want failures visible fast.\n *\n * @internal exported for tests\n */\nexport function defaultActionQueryRetryDelay(failureCount: number): number {\n return Math.min(500 * 2 ** failureCount, 2_000);\n}\n\n// ---------------------------------------------------------------------------\n// Action type registry — augmented by generated code\n// ---------------------------------------------------------------------------\n\n/**\n * Action type registry. This interface is empty by default and gets augmented\n * by the auto-generated `.generated/action-types.d.ts` file. When augmented,\n * it maps action names to their parameter and return types, enabling\n * end-to-end type safety for `useActionQuery` and `useActionMutation`.\n */\ndeclare global {\n interface AgentNativeActionRegistry {}\n}\n\nexport interface ActionRegistry extends AgentNativeActionRegistry {}\n\n/** Resolves to the union of registered action names, or `string` if no registry exists. */\ntype ActionName = keyof ActionRegistry extends never\n ? string\n : (keyof ActionRegistry & string) | (string & {});\n\n/** Resolves the return type of an action, or `any` if not in the registry. */\ntype ActionResult<T extends string> = T extends keyof ActionRegistry\n ? ActionRegistry[T] extends { result: infer R }\n ? R\n : any\n : any;\n\n/** Resolves the parameter type of an action, or `Record<string, any>` if not in the registry. */\ntype ActionParams<T extends string> = T extends keyof ActionRegistry\n ? ActionRegistry[T] extends { params: infer P }\n ? P\n : Record<string, any>\n : Record<string, any>;\n\nexport type ClientActionMethod = \"GET\" | \"POST\" | \"PUT\" | \"DELETE\";\n\nexport interface ClientActionCallOptions {\n method?: ClientActionMethod;\n /** Abort signal for the underlying fetch. */\n signal?: AbortSignal;\n /** Override the default 60s fetch timeout for long-running actions. */\n timeoutMs?: number;\n}\n\n// ---------------------------------------------------------------------------\n// Fetch helper\n// ---------------------------------------------------------------------------\n\n/**\n * Resolve the browser's IANA timezone (e.g. \"America/Los_Angeles\"). This is\n * sent on every action request as `x-user-timezone` so server-side defaults\n * like \"today\" honor the user's local day rather than the server's UTC clock.\n */\nfunction resolveUserTimezone(): string | undefined {\n try {\n return Intl.DateTimeFormat().resolvedOptions().timeZone || undefined;\n } catch {\n return undefined;\n }\n}\n\nexport function serializeActionQueryParams(\n params: Record<string, any>,\n): string {\n const qs = new URLSearchParams();\n for (const [key, value] of Object.entries(params)) {\n appendActionQueryParam(qs, key, value);\n }\n return qs.toString();\n}\n\nfunction appendActionQueryParam(\n qs: URLSearchParams,\n key: string,\n value: unknown,\n) {\n if (value === null || value === undefined) return;\n if (Array.isArray(value)) {\n // Use bracket keys so a one-item array still arrives as an array after the\n // server parses URLSearchParams. Repeated bare keys lose that distinction.\n for (const item of value) {\n appendActionQueryParam(qs, `${key}[]`, item);\n }\n return;\n }\n qs.append(key, String(value));\n}\n\nexport interface ActionFetchOptions {\n /**\n * Abort signal from the caller (React Query passes one per queryFn\n * invocation so superseded requests — key change, unmount, refetch — cancel\n * the underlying network request instead of hogging a connection slot).\n */\n signal?: AbortSignal;\n /** Per-call override for the fetch timeout. */\n timeoutMs?: number;\n /** Keep the request alive while the document is being unloaded. */\n keepalive?: boolean;\n /** Pre-serialized mutation body used by the keepalive budget coordinator. */\n serializedBody?: string;\n /** Omit the tab echo-suppression tag for imperative callers. */\n includeRequestSource?: boolean;\n}\n\n/**\n * Conservative per-document keepalive body budget. Browsers commonly enforce\n * an approximately 64 KiB aggregate limit across every in-flight keepalive\n * request; leaving headroom for other framework traffic prevents a request\n * that passed our guard from being rejected by the browser at send time.\n */\nexport const ACTION_KEEPALIVE_BODY_BUDGET_BYTES = 48_000;\n\nlet reservedKeepaliveBodyBytes = 0;\n\nfunction utf8ByteLength(value: string): number {\n if (typeof TextEncoder !== \"undefined\") {\n return new TextEncoder().encode(value).byteLength;\n }\n\n let bytes = 0;\n for (const character of value) {\n const codePoint = character.codePointAt(0) ?? 0;\n bytes +=\n codePoint <= 0x7f\n ? 1\n : codePoint <= 0x7ff\n ? 2\n : codePoint <= 0xffff\n ? 3\n : 4;\n }\n return bytes;\n}\n\nasync function actionFetch<T>(\n name: string,\n method: string,\n params?: Record<string, any>,\n options?: ActionFetchOptions,\n): Promise<T> {\n ensureEmbedAuthFetchInterceptor();\n let url = `${ACTION_PREFIX}/${name}`;\n const headers: Record<string, string> = {\n \"Content-Type\": \"application/json\",\n // Tag browser-originated action calls so the server can set\n // `ctx.caller = \"frontend\"` (vs a bare programmatic `\"http\"` POST).\n // Mirrors the X-Agent-Native-Tool-Bridge: 1 convention. The header is\n // safe to expose: CORS allows it (see action-routes.ts) and it carries\n // no auth weight — it only narrows the caller tag.\n \"X-Agent-Native-Frontend\": \"1\",\n ...(options?.includeRequestSource !== false\n ? {\n // The server copies this onto the emitted action sync event.\n // useDbSync can then ignore the echo in this tab while other tabs\n // still refresh.\n \"X-Request-Source\": getBrowserTabId(),\n }\n : {}),\n };\n const tz = resolveUserTimezone();\n if (tz) headers[\"x-user-timezone\"] = tz;\n const init: RequestInit = {\n method,\n headers,\n cache: \"no-store\",\n keepalive: options?.keepalive,\n };\n\n if (method === \"GET\" && params && Object.keys(params).length > 0) {\n // Skip null/undefined so optional filters don't turn into literal \"null\"\n // strings in the query string (e.g. `?folderId=null`).\n const qs = serializeActionQueryParams(params);\n if (qs) url += `?${qs}`;\n } else if (method !== \"GET\" && params) {\n init.body = options?.serializedBody ?? JSON.stringify(params);\n }\n\n // One controller drives both cancellation sources: the caller's signal\n // (superseded query, unmount) and the timeout. The timer stays armed until\n // the BODY is fully read — headers arriving quickly while the body stalls\n // is exactly the hang this bounds.\n const outerSignal = options?.signal;\n const timeoutMs = options?.timeoutMs ?? DEFAULT_ACTION_TIMEOUT_MS;\n const controller =\n typeof AbortController === \"undefined\" ? null : new AbortController();\n const onOuterAbort = () => controller?.abort();\n if (outerSignal && controller) {\n if (outerSignal.aborted) controller.abort();\n else outerSignal.addEventListener(\"abort\", onOuterAbort, { once: true });\n }\n let timedOut = false;\n const timer = controller\n ? setTimeout(() => {\n timedOut = true;\n controller.abort();\n }, timeoutMs)\n : null;\n if (controller) init.signal = controller.signal;\n\n const throwTimeout = (): never => {\n const error = new Error(\n `Action ${name} timed out after ${Math.round(timeoutMs / 1000)}s`,\n );\n (error as any).timedOut = true;\n (error as any).status = 408;\n throw error;\n };\n\n let res: Response;\n let raw = \"\";\n let readFailed = false;\n let readError: unknown;\n try {\n try {\n res = await fetch(url, init);\n } catch (err) {\n if (timedOut) throwTimeout();\n // Caller-initiated cancellation — rethrow untouched so React Query\n // recognizes it as a cancellation rather than a query failure.\n if (outerSignal?.aborted) throw err;\n // Network failures, CORS, server unreachable, etc. — give the caller a\n // useful message instead of the opaque \"Failed to fetch\".\n const cause = err instanceof Error ? err.message : String(err);\n throw new Error(`Action ${name} failed: ${cause}`);\n }\n\n // 204 No Content — nothing to parse.\n if (res.status === 204) return null as T;\n\n // Read the body as text first so we can:\n // - tolerate empty bodies (avoids \"Unexpected end of JSON input\")\n // - surface non-JSON error responses (HTML 401/404 pages, plain text, etc.)\n // - preserve the original HTTP status in the thrown error\n // Track read failures separately from \"no body\" — a stream interruption /\n // decode failure on a 2xx response should error rather than silently\n // succeed with `null`.\n try {\n raw = await res.text();\n } catch (err) {\n if (timedOut) throwTimeout();\n if (outerSignal?.aborted) throw err;\n readFailed = true;\n readError = err;\n }\n } finally {\n if (timer) clearTimeout(timer);\n if (outerSignal) outerSignal.removeEventListener(\"abort\", onOuterAbort);\n }\n\n let data: any = undefined;\n let parseFailed = false;\n if (raw.length > 0) {\n try {\n data = JSON.parse(raw);\n } catch {\n // Body wasn't JSON — keep `data` undefined and use the raw text below.\n parseFailed = true;\n }\n }\n\n if (!res.ok) {\n const message =\n (data && (data.error || data.message)) ||\n // Truncate non-JSON bodies so we don't dump entire HTML pages into the\n // console, but still give the developer a hint as to what came back.\n (raw && raw.slice(0, 200)) ||\n res.statusText ||\n `HTTP ${res.status}`;\n const error = new Error(`Action ${name} failed: ${message}`);\n (error as any).status = res.status;\n throw error;\n }\n\n // 2xx but the body couldn't even be read (mid-stream abort, decode failure,\n // etc.). Don't silently treat that as a `null` success.\n if (readFailed) {\n const cause =\n readError instanceof Error ? readError.message : String(readError);\n const error = new Error(\n `Action ${name} returned ${res.status} but the body could not be read: ${cause}`,\n );\n (error as any).status = res.status;\n throw error;\n }\n\n // 2xx with a non-empty, non-JSON body. Action callers expect typed data, so\n // returning `null` here would silently mask a real server bug (e.g. a proxy\n // returning HTML 200 instead of JSON). Throw instead — empty bodies (handled\n // above by the `raw.length > 0` guard and the 204 short-circuit) still\n // correctly resolve to `null`.\n if (parseFailed) {\n const error = new Error(\n `Action ${name} returned a non-JSON ${res.status} response: ${raw.slice(0, 200)}`,\n );\n (error as any).status = res.status;\n throw error;\n }\n\n return (data ?? (null as unknown)) as T;\n}\n\n/**\n * Imperatively call an action from browser/client code.\n *\n * Prefer `useActionQuery` / `useActionMutation` in React render flows. Use this\n * helper when a hook is not ergonomic; do not hand-write fetch calls to\n * `/_agent-native/actions/*` in components.\n */\nexport function callAction<\n TResult = undefined,\n TName extends ActionName = ActionName,\n>(\n actionName: TName,\n params?: ActionParams<TName>,\n options: ClientActionCallOptions = {},\n): Promise<TResult extends undefined ? ActionResult<TName> : TResult> {\n type R = TResult extends undefined ? ActionResult<TName> : TResult;\n return actionFetch<R>(actionName, options.method ?? \"POST\", params, {\n signal: options.signal,\n timeoutMs: options.timeoutMs,\n includeRequestSource: false,\n });\n}\n\nexport type KeepaliveActionCallRejectionReason =\n | \"body-too-large\"\n | \"budget-exhausted\";\n\nexport type KeepaliveActionCallResult<TResult> =\n | {\n accepted: true;\n bodyBytes: number;\n completion: Promise<TResult>;\n }\n | {\n accepted: false;\n bodyBytes: number;\n reason: KeepaliveActionCallRejectionReason;\n completion: null;\n };\n\n/**\n * Attempts an unload-safe action call without exceeding the browser's shared\n * keepalive request budget. The reservation remains held until the response\n * body has completed, because browsers count every in-flight keepalive body\n * against the same per-document quota.\n *\n * A rejected attempt is deliberately synchronous so callers can fall back to\n * a durable outbox before returning from `pagehide`.\n */\nexport function tryCallActionKeepalive<\n TResult = undefined,\n TName extends ActionName = ActionName,\n>(\n actionName: TName,\n params?: ActionParams<TName>,\n options: Omit<ClientActionCallOptions, \"method\"> = {},\n): KeepaliveActionCallResult<\n TResult extends undefined ? ActionResult<TName> : TResult\n> {\n type R = TResult extends undefined ? ActionResult<TName> : TResult;\n const serializedBody = JSON.stringify(params ?? {});\n const bodyBytes = utf8ByteLength(serializedBody);\n\n if (bodyBytes > ACTION_KEEPALIVE_BODY_BUDGET_BYTES) {\n return {\n accepted: false,\n bodyBytes,\n reason: \"body-too-large\",\n completion: null,\n };\n }\n\n if (\n reservedKeepaliveBodyBytes + bodyBytes >\n ACTION_KEEPALIVE_BODY_BUDGET_BYTES\n ) {\n return {\n accepted: false,\n bodyBytes,\n reason: \"budget-exhausted\",\n completion: null,\n };\n }\n\n reservedKeepaliveBodyBytes += bodyBytes;\n const completion = actionFetch<R>(actionName, \"POST\", params, {\n signal: options.signal,\n timeoutMs: options.timeoutMs,\n keepalive: true,\n serializedBody,\n }).finally(() => {\n reservedKeepaliveBodyBytes = Math.max(\n 0,\n reservedKeepaliveBodyBytes - bodyBytes,\n );\n });\n\n return { accepted: true, bodyBytes, completion };\n}\n\n// ---------------------------------------------------------------------------\n// Query hook\n// ---------------------------------------------------------------------------\n\n/**\n * Query an action exposed as GET.\n *\n * When the action type registry is generated, the return type and parameter\n * types are inferred automatically from the action's `defineAction()` call.\n *\n * ```ts\n * // Type-safe — no manual generic needed\n * const { data } = useActionQuery(\"list-meals\", { date: \"2025-01-01\" });\n *\n * // Manual override still works when needed\n * const { data } = useActionQuery<CustomType>(\"list-meals\");\n * ```\n */\nexport function useActionQuery<\n TResult = undefined,\n TName extends ActionName = ActionName,\n>(\n actionName: TName,\n params?: ActionParams<TName>,\n options?: Omit<\n UseQueryOptions<TResult extends undefined ? ActionResult<TName> : TResult>,\n \"queryKey\" | \"queryFn\"\n >,\n) {\n type R = TResult extends undefined ? ActionResult<TName> : TResult;\n return useQuery<R>({\n queryKey: [\"action\", actionName, params],\n // Thread React Query's per-fetch AbortSignal into the network request so\n // superseded fetches (key change, unmount, rapid refetch) actually cancel\n // instead of holding a per-origin connection slot until they finish.\n queryFn: ({ signal }) =>\n actionFetch<R>(actionName, \"GET\", params, { signal }),\n retry: defaultActionQueryRetry,\n retryDelay: defaultActionQueryRetryDelay,\n ...options,\n });\n}\n\n// ---------------------------------------------------------------------------\n// Mutation hook\n// ---------------------------------------------------------------------------\n\n/**\n * Mutate via an action exposed as POST (default), PUT, or DELETE.\n *\n * When the action type registry is generated, the return type and parameter\n * types are inferred automatically.\n *\n * ```ts\n * // Type-safe\n * const { mutate } = useActionMutation(\"log-meal\");\n * mutate({ name: \"Salad\", calories: 350 });\n * ```\n */\nexport function useActionMutation<\n TData = undefined,\n TVariables = undefined,\n TName extends ActionName = ActionName,\n>(\n actionName: TName,\n options?: Omit<\n UseMutationOptions<\n TData extends undefined ? ActionResult<TName> : TData,\n Error,\n TVariables extends undefined ? ActionParams<TName> : TVariables\n >,\n \"mutationFn\"\n > & {\n method?: \"POST\" | \"PUT\" | \"DELETE\";\n skipActionQueryInvalidation?: boolean;\n },\n) {\n const queryClient = useQueryClient();\n const {\n method: methodOpt,\n onSuccess,\n skipActionQueryInvalidation = false,\n ...restOptions\n } = options ?? ({} as any);\n const method = methodOpt ?? \"POST\";\n\n type D = TData extends undefined ? ActionResult<TName> : TData;\n type V = TVariables extends undefined ? ActionParams<TName> : TVariables;\n\n return useMutation<D, Error, V>({\n ...restOptions,\n mutationFn: (params) =>\n actionFetch<D>(actionName, method, params as Record<string, any>),\n onSuccess: (...args: [any, any, any]) => {\n // Most mutations change app data broadly. High-volume background\n // mutations can opt out and perform narrower invalidation in onSuccess.\n if (!skipActionQueryInvalidation) {\n queryClient.invalidateQueries({ queryKey: [\"action\"] });\n }\n (onSuccess as Function)?.(...args);\n },\n });\n}\n"]}
|
|
@@ -34,6 +34,8 @@ export declare function useAgentChatHomeHandoff({ storageKey, activePath, ttlMs,
|
|
|
34
34
|
/**
|
|
35
35
|
* Intercepts ordinary in-app links clicked from a full-page chat route so the
|
|
36
36
|
* page chat can morph into the destination AgentSidebar and keep its thread.
|
|
37
|
+
* Settings is intentionally excluded: a user opening it keeps chat full-page.
|
|
38
|
+
* Agent-driven navigation can still opt into the handoff by marking it first.
|
|
37
39
|
*/
|
|
38
40
|
export declare function useAgentChatHomeHandoffLinks({ storageKey, chatPath, isChatPath, enabled, ttlMs, requireActiveHandoff, }: UseAgentChatHomeHandoffLinksOptions): void;
|
|
39
41
|
//# sourceMappingURL=use-agent-chat-home-handoff.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-agent-chat-home-handoff.d.ts","sourceRoot":"","sources":["../../src/client/use-agent-chat-home-handoff.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,8BAA8B;IAC7C,wEAAwE;IACxE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,sEAAsE;IACtE,UAAU,EAAE,MAAM,CAAC;IACnB,sEAAsE;IACtE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4DAA4D;IAC5D,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,mCAAmC;IAClD,wEAAwE;IACxE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,uEAAuE;IACvE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC;IAC3C,kEAAkE;IAClE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,sEAAsE;IACtE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sEAAsE;IACtE,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;
|
|
1
|
+
{"version":3,"file":"use-agent-chat-home-handoff.d.ts","sourceRoot":"","sources":["../../src/client/use-agent-chat-home-handoff.ts"],"names":[],"mappings":"AAWA,MAAM,WAAW,8BAA8B;IAC7C,wEAAwE;IACxE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,sEAAsE;IACtE,UAAU,EAAE,MAAM,CAAC;IACnB,sEAAsE;IACtE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4DAA4D;IAC5D,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,mCAAmC;IAClD,wEAAwE;IACxE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,uEAAuE;IACvE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC;IAC3C,kEAAkE;IAClE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,sEAAsE;IACtE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,sEAAsE;IACtE,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AA0ED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,EACtC,UAAU,EACV,UAAU,EACV,KAAK,EACL,OAAc,GACf,EAAE,8BAA8B,GAAG,OAAO,CAc1C;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAAC,EAC3C,UAAU,EACV,QAAc,EACd,UAAU,EACV,OAAc,EACd,KAAK,EACL,oBAA4B,GAC7B,EAAE,mCAAmC,GAAG,IAAI,CAuD5C"}
|
|
@@ -36,6 +36,9 @@ function isStaticAssetPath(pathname) {
|
|
|
36
36
|
const lastSegment = pathname.split("/").pop() ?? "";
|
|
37
37
|
return /\.[A-Za-z0-9]{1,12}$/.test(lastSegment);
|
|
38
38
|
}
|
|
39
|
+
function isSettingsPath(pathname) {
|
|
40
|
+
return pathname === "/settings" || pathname.startsWith("/settings/");
|
|
41
|
+
}
|
|
39
42
|
function localPathFromAnchor(anchor) {
|
|
40
43
|
if (!anchor.href)
|
|
41
44
|
return null;
|
|
@@ -84,6 +87,8 @@ export function useAgentChatHomeHandoff({ storageKey, activePath, ttlMs, enabled
|
|
|
84
87
|
/**
|
|
85
88
|
* Intercepts ordinary in-app links clicked from a full-page chat route so the
|
|
86
89
|
* page chat can morph into the destination AgentSidebar and keep its thread.
|
|
90
|
+
* Settings is intentionally excluded: a user opening it keeps chat full-page.
|
|
91
|
+
* Agent-driven navigation can still opt into the handoff by marking it first.
|
|
87
92
|
*/
|
|
88
93
|
export function useAgentChatHomeHandoffLinks({ storageKey, chatPath = "/", isChatPath, enabled = true, ttlMs, requireActiveHandoff = false, }) {
|
|
89
94
|
const location = useLocation();
|
|
@@ -113,7 +118,8 @@ export function useAgentChatHomeHandoffLinks({ storageKey, chatPath = "/", isCha
|
|
|
113
118
|
if (!path ||
|
|
114
119
|
matchesChatPath(pathname) ||
|
|
115
120
|
isFrameworkOrApiPath(pathname) ||
|
|
116
|
-
isStaticAssetPath(pathname)
|
|
121
|
+
isStaticAssetPath(pathname) ||
|
|
122
|
+
isSettingsPath(pathname)) {
|
|
117
123
|
return;
|
|
118
124
|
}
|
|
119
125
|
if (requireActiveHandoff &&
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-agent-chat-home-handoff.js","sourceRoot":"","sources":["../../src/client/use-agent-chat-home-handoff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAExD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EACL,2BAA2B,EAC3B,4BAA4B,EAC5B,wBAAwB,EACxB,mCAAmC,GACpC,MAAM,2BAA2B,CAAC;AAgCnC,SAAS,aAAa,CAAC,IAAY;IACjC,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;IAC/B,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC3B,IAAI,MAAM,GAAG,IAAI,CAAC;IAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9B,IAAI,MAAM,KAAK,QAAQ;YAAE,OAAO,GAAG,CAAC;QACpC,IAAI,MAAM,CAAC,UAAU,CAAC,GAAG,QAAQ,GAAG,CAAC,EAAE,CAAC;YACtC,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC;YAC9C,SAAS;QACX,CAAC;QACD,IACE,MAAM,CAAC,UAAU,CAAC,GAAG,QAAQ,GAAG,CAAC;YACjC,MAAM,CAAC,UAAU,CAAC,GAAG,QAAQ,GAAG,CAAC,EACjC,CAAC;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YACzD,IACE,CAAC,IAAI;gBACL,eAAe,CAAC,QAAQ,CAAC;gBACzB,oBAAoB,CAAC,QAAQ,CAAC;gBAC9B,iBAAiB,CAAC,QAAQ,CAAC,EAC3B,CAAC;gBACD,OAAO;YACT,CAAC;YAED,IACE,oBAAoB;gBACpB,CAAC,4BAA4B,CAAC,UAAU,EAAE,iBAAiB,CAAC,KAAK,CAAC,CAAC,EACnE,CAAC;gBACD,OAAO;YACT,CAAC;YAED,KAAK,CAAC,cAAc,EAAE,CAAC;YACvB,wBAAwB,CAAC,UAAU,CAAC,CAAC;YACrC,mCAAmC,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QACtD,CAAC;QAED,QAAQ,CAAC,gBAAgB,CAAC,OAAO,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC;QACtD,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,mBAAmB,CAAC,OAAO,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC;IACxE,CAAC,EAAE;QACD,OAAO;QACP,QAAQ,CAAC,QAAQ;QACjB,QAAQ;QACR,oBAAoB;QACpB,UAAU;QACV,KAAK;KACN,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { useEffect, useRef, useState } from \"react\";\nimport { useLocation, useNavigate } from \"react-router\";\n\nimport { appBasePath } from \"./api-path.js\";\nimport {\n consumeAgentChatHomeHandoff,\n isAgentChatHomeHandoffActive,\n markAgentChatHomeHandoff,\n navigateWithAgentChatViewTransition,\n} from \"./chat-view-transition.js\";\n\nexport interface UseAgentChatHomeHandoffOptions {\n /** Namespace shared by the full-page chat and AgentSidebar surfaces. */\n storageKey?: string | null;\n /** The current destination path that receives the sidebar handoff. */\n activePath: string;\n /** How long the handoff marker remains valid. Defaults to 6 hours. */\n ttlMs?: number;\n /** Disable consumption without changing hook call order. */\n enabled?: boolean;\n}\n\nexport interface UseAgentChatHomeHandoffLinksOptions {\n /** Namespace shared by the full-page chat and AgentSidebar surfaces. */\n storageKey?: string | null;\n /** Router-local path for the full-page chat route. Defaults to \"/\". */\n chatPath?: string;\n /**\n * Matches every router-local pathname owned by the full-page chat surface.\n * Defaults to an exact match against `chatPath`. Pass this to cover deep\n * links such as `/chat/:threadId`.\n */\n isChatPath?: (pathname: string) => boolean;\n /** Disable link interception without changing hook call order. */\n enabled?: boolean;\n /** How long the handoff marker remains valid. Defaults to 6 hours. */\n ttlMs?: number;\n /** Only intercept links if a recent handoff marker already exists. */\n requireActiveHandoff?: boolean;\n}\n\nfunction stripBasePath(path: string): string {\n const basePath = appBasePath();\n if (!basePath) return path;\n let result = path;\n for (let i = 0; i < 4; i += 1) {\n if (result === basePath) return \"/\";\n if (result.startsWith(`${basePath}/`)) {\n result = result.slice(basePath.length) || \"/\";\n continue;\n }\n if (\n result.startsWith(`${basePath}?`) ||\n result.startsWith(`${basePath}#`)\n ) {\n result = `/${result.slice(basePath.length)}`;\n continue;\n }\n break;\n }\n return result;\n}\n\nfunction pathnameFromLocalPath(path: string): string {\n return path.split(/[?#]/, 1)[0] || \"/\";\n}\n\nfunction isFrameworkOrApiPath(pathname: string): boolean {\n return (\n pathname === \"/_agent-native\" ||\n pathname.startsWith(\"/_agent-native/\") ||\n pathname === \"/api\" ||\n pathname.startsWith(\"/api/\")\n );\n}\n\nfunction isStaticAssetPath(pathname: string): boolean {\n const lastSegment = pathname.split(\"/\").pop() ?? \"\";\n return /\\.[A-Za-z0-9]{1,12}$/.test(lastSegment);\n}\n\nfunction localPathFromAnchor(anchor: HTMLAnchorElement): string | null {\n if (!anchor.href) return null;\n try {\n const url = new URL(anchor.href);\n if (url.origin !== window.location.origin) return null;\n return stripBasePath(`${url.pathname}${url.search}${url.hash}`);\n } catch {\n return null;\n }\n}\n\nfunction shouldHandleAnchorClick(\n event: MouseEvent,\n anchor: HTMLAnchorElement,\n): boolean {\n if (event.defaultPrevented || event.button !== 0) return false;\n if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) {\n return false;\n }\n if (anchor.target && anchor.target !== \"_self\") return false;\n if (anchor.hasAttribute(\"download\")) return false;\n return true;\n}\n\nfunction handoffTtlOptions(ttlMs: number | undefined) {\n return ttlMs === undefined ? undefined : { ttlMs };\n}\n\n/**\n * Returns true for the route that has just received a full-page-chat handoff.\n * Pass the result to `AgentSidebar openOnChatRunning`.\n */\nexport function useAgentChatHomeHandoff({\n storageKey,\n activePath,\n ttlMs,\n enabled = true,\n}: UseAgentChatHomeHandoffOptions): boolean {\n const [handoffPath, setHandoffPath] = useState<string | null>(null);\n\n useEffect(() => {\n if (!enabled) {\n setHandoffPath(null);\n return;\n }\n if (consumeAgentChatHomeHandoff(storageKey, handoffTtlOptions(ttlMs))) {\n setHandoffPath(activePath);\n }\n }, [activePath, enabled, storageKey, ttlMs]);\n\n return enabled && handoffPath === activePath;\n}\n\n/**\n * Intercepts ordinary in-app links clicked from a full-page chat route so the\n * page chat can morph into the destination AgentSidebar and keep its thread.\n */\nexport function useAgentChatHomeHandoffLinks({\n storageKey,\n chatPath = \"/\",\n isChatPath,\n enabled = true,\n ttlMs,\n requireActiveHandoff = false,\n}: UseAgentChatHomeHandoffLinksOptions): void {\n const location = useLocation();\n const navigate = useNavigate();\n const matchesChatPathRef = useRef<(pathname: string) => boolean>(() => false);\n matchesChatPathRef.current =\n isChatPath ?? ((pathname: string) => pathname === chatPath);\n\n useEffect(() => {\n const matchesChatPath = (pathname: string) =>\n matchesChatPathRef.current(pathname);\n if (!enabled || !matchesChatPath(stripBasePath(location.pathname))) return;\n if (typeof document === \"undefined\") return;\n\n function handleClick(event: MouseEvent) {\n const target = event.target;\n if (!(target instanceof Element)) return;\n const anchor = target.closest(\"a[href]\");\n if (!(anchor instanceof HTMLAnchorElement)) return;\n if (!shouldHandleAnchorClick(event, anchor)) return;\n if (anchor.closest(\".agent-panel-root\")) return;\n\n const path = localPathFromAnchor(anchor);\n const pathname = path ? pathnameFromLocalPath(path) : \"\";\n if (\n !path ||\n matchesChatPath(pathname) ||\n isFrameworkOrApiPath(pathname) ||\n isStaticAssetPath(pathname)\n ) {\n return;\n }\n\n if (\n requireActiveHandoff &&\n !isAgentChatHomeHandoffActive(storageKey, handoffTtlOptions(ttlMs))\n ) {\n return;\n }\n\n event.preventDefault();\n markAgentChatHomeHandoff(storageKey);\n navigateWithAgentChatViewTransition(navigate, path);\n }\n\n document.addEventListener(\"click\", handleClick, true);\n return () => document.removeEventListener(\"click\", handleClick, true);\n }, [\n enabled,\n location.pathname,\n navigate,\n requireActiveHandoff,\n storageKey,\n ttlMs,\n ]);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"use-agent-chat-home-handoff.js","sourceRoot":"","sources":["../../src/client/use-agent-chat-home-handoff.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAExD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EACL,2BAA2B,EAC3B,4BAA4B,EAC5B,wBAAwB,EACxB,mCAAmC,GACpC,MAAM,2BAA2B,CAAC;AAgCnC,SAAS,aAAa,CAAC,IAAY;IACjC,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;IAC/B,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC3B,IAAI,MAAM,GAAG,IAAI,CAAC;IAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QAC9B,IAAI,MAAM,KAAK,QAAQ;YAAE,OAAO,GAAG,CAAC;QACpC,IAAI,MAAM,CAAC,UAAU,CAAC,GAAG,QAAQ,GAAG,CAAC,EAAE,CAAC;YACtC,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC;YAC9C,SAAS;QACX,CAAC;QACD,IACE,MAAM,CAAC,UAAU,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D,IAAI,MAAM,CAAC,OAAO,CAAC,mBAAmB,CAAC;gBAAE,OAAO;YAEhD,MAAM,IAAI,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC;YACzC,MAAM,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACzD,IACE,CAAC,IAAI;gBACL,eAAe,CAAC,QAAQ,CAAC;gBACzB,oBAAoB,CAAC,QAAQ,CAAC;gBAC9B,iBAAiB,CAAC,QAAQ,CAAC;gBAC3B,cAAc,CAAC,QAAQ,CAAC,EACxB,CAAC;gBACD,OAAO;YACT,CAAC;YAED,IACE,oBAAoB;gBACpB,CAAC,4BAA4B,CAAC,UAAU,EAAE,iBAAiB,CAAC,KAAK,CAAC,CAAC,EACnE,CAAC;gBACD,OAAO;YACT,CAAC;YAED,KAAK,CAAC,cAAc,EAAE,CAAC;YACvB,wBAAwB,CAAC,UAAU,CAAC,CAAC;YACrC,mCAAmC,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QACtD,CAAC;QAED,QAAQ,CAAC,gBAAgB,CAAC,OAAO,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC;QACtD,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,mBAAmB,CAAC,OAAO,EAAE,WAAW,EAAE,IAAI,CAAC,CAAC;IACxE,CAAC,EAAE;QACD,OAAO;QACP,QAAQ,CAAC,QAAQ;QACjB,QAAQ;QACR,oBAAoB;QACpB,UAAU;QACV,KAAK;KACN,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { useEffect, useRef, useState } from \"react\";\nimport { useLocation, useNavigate } from \"react-router\";\n\nimport { appBasePath } from \"./api-path.js\";\nimport {\n consumeAgentChatHomeHandoff,\n isAgentChatHomeHandoffActive,\n markAgentChatHomeHandoff,\n navigateWithAgentChatViewTransition,\n} from \"./chat-view-transition.js\";\n\nexport interface UseAgentChatHomeHandoffOptions {\n /** Namespace shared by the full-page chat and AgentSidebar surfaces. */\n storageKey?: string | null;\n /** The current destination path that receives the sidebar handoff. */\n activePath: string;\n /** How long the handoff marker remains valid. Defaults to 6 hours. */\n ttlMs?: number;\n /** Disable consumption without changing hook call order. */\n enabled?: boolean;\n}\n\nexport interface UseAgentChatHomeHandoffLinksOptions {\n /** Namespace shared by the full-page chat and AgentSidebar surfaces. */\n storageKey?: string | null;\n /** Router-local path for the full-page chat route. Defaults to \"/\". */\n chatPath?: string;\n /**\n * Matches every router-local pathname owned by the full-page chat surface.\n * Defaults to an exact match against `chatPath`. Pass this to cover deep\n * links such as `/chat/:threadId`.\n */\n isChatPath?: (pathname: string) => boolean;\n /** Disable link interception without changing hook call order. */\n enabled?: boolean;\n /** How long the handoff marker remains valid. Defaults to 6 hours. */\n ttlMs?: number;\n /** Only intercept links if a recent handoff marker already exists. */\n requireActiveHandoff?: boolean;\n}\n\nfunction stripBasePath(path: string): string {\n const basePath = appBasePath();\n if (!basePath) return path;\n let result = path;\n for (let i = 0; i < 4; i += 1) {\n if (result === basePath) return \"/\";\n if (result.startsWith(`${basePath}/`)) {\n result = result.slice(basePath.length) || \"/\";\n continue;\n }\n if (\n result.startsWith(`${basePath}?`) ||\n result.startsWith(`${basePath}#`)\n ) {\n result = `/${result.slice(basePath.length)}`;\n continue;\n }\n break;\n }\n return result;\n}\n\nfunction pathnameFromLocalPath(path: string): string {\n return path.split(/[?#]/, 1)[0] || \"/\";\n}\n\nfunction isFrameworkOrApiPath(pathname: string): boolean {\n return (\n pathname === \"/_agent-native\" ||\n pathname.startsWith(\"/_agent-native/\") ||\n pathname === \"/api\" ||\n pathname.startsWith(\"/api/\")\n );\n}\n\nfunction isStaticAssetPath(pathname: string): boolean {\n const lastSegment = pathname.split(\"/\").pop() ?? \"\";\n return /\\.[A-Za-z0-9]{1,12}$/.test(lastSegment);\n}\n\nfunction isSettingsPath(pathname: string): boolean {\n return pathname === \"/settings\" || pathname.startsWith(\"/settings/\");\n}\n\nfunction localPathFromAnchor(anchor: HTMLAnchorElement): string | null {\n if (!anchor.href) return null;\n try {\n const url = new URL(anchor.href);\n if (url.origin !== window.location.origin) return null;\n return stripBasePath(`${url.pathname}${url.search}${url.hash}`);\n } catch {\n return null;\n }\n}\n\nfunction shouldHandleAnchorClick(\n event: MouseEvent,\n anchor: HTMLAnchorElement,\n): boolean {\n if (event.defaultPrevented || event.button !== 0) return false;\n if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) {\n return false;\n }\n if (anchor.target && anchor.target !== \"_self\") return false;\n if (anchor.hasAttribute(\"download\")) return false;\n return true;\n}\n\nfunction handoffTtlOptions(ttlMs: number | undefined) {\n return ttlMs === undefined ? undefined : { ttlMs };\n}\n\n/**\n * Returns true for the route that has just received a full-page-chat handoff.\n * Pass the result to `AgentSidebar openOnChatRunning`.\n */\nexport function useAgentChatHomeHandoff({\n storageKey,\n activePath,\n ttlMs,\n enabled = true,\n}: UseAgentChatHomeHandoffOptions): boolean {\n const [handoffPath, setHandoffPath] = useState<string | null>(null);\n\n useEffect(() => {\n if (!enabled) {\n setHandoffPath(null);\n return;\n }\n if (consumeAgentChatHomeHandoff(storageKey, handoffTtlOptions(ttlMs))) {\n setHandoffPath(activePath);\n }\n }, [activePath, enabled, storageKey, ttlMs]);\n\n return enabled && handoffPath === activePath;\n}\n\n/**\n * Intercepts ordinary in-app links clicked from a full-page chat route so the\n * page chat can morph into the destination AgentSidebar and keep its thread.\n * Settings is intentionally excluded: a user opening it keeps chat full-page.\n * Agent-driven navigation can still opt into the handoff by marking it first.\n */\nexport function useAgentChatHomeHandoffLinks({\n storageKey,\n chatPath = \"/\",\n isChatPath,\n enabled = true,\n ttlMs,\n requireActiveHandoff = false,\n}: UseAgentChatHomeHandoffLinksOptions): void {\n const location = useLocation();\n const navigate = useNavigate();\n const matchesChatPathRef = useRef<(pathname: string) => boolean>(() => false);\n matchesChatPathRef.current =\n isChatPath ?? ((pathname: string) => pathname === chatPath);\n\n useEffect(() => {\n const matchesChatPath = (pathname: string) =>\n matchesChatPathRef.current(pathname);\n if (!enabled || !matchesChatPath(stripBasePath(location.pathname))) return;\n if (typeof document === \"undefined\") return;\n\n function handleClick(event: MouseEvent) {\n const target = event.target;\n if (!(target instanceof Element)) return;\n const anchor = target.closest(\"a[href]\");\n if (!(anchor instanceof HTMLAnchorElement)) return;\n if (!shouldHandleAnchorClick(event, anchor)) return;\n if (anchor.closest(\".agent-panel-root\")) return;\n\n const path = localPathFromAnchor(anchor);\n const pathname = path ? pathnameFromLocalPath(path) : \"\";\n if (\n !path ||\n matchesChatPath(pathname) ||\n isFrameworkOrApiPath(pathname) ||\n isStaticAssetPath(pathname) ||\n isSettingsPath(pathname)\n ) {\n return;\n }\n\n if (\n requireActiveHandoff &&\n !isAgentChatHomeHandoffActive(storageKey, handoffTtlOptions(ttlMs))\n ) {\n return;\n }\n\n event.preventDefault();\n markAgentChatHomeHandoff(storageKey);\n navigateWithAgentChatViewTransition(navigate, path);\n }\n\n document.addEventListener(\"click\", handleClick, true);\n return () => document.removeEventListener(\"click\", handleClick, true);\n }, [\n enabled,\n location.pathname,\n navigate,\n requireActiveHandoff,\n storageKey,\n ttlMs,\n ]);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-agent-engine-configured.d.ts","sourceRoot":"","sources":["../../src/client/use-agent-engine-configured.ts"],"names":[],"mappings":"AAOA,iFAAiF;AACjF,MAAM,MAAM,0BAA0B,GAAG,SAAS,GAAG,YAAY,GAAG,SAAS,CAAC;AAE9E,MAAM,WAAW,8BAA8B;IAC7C,6EAA6E;IAC7E,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,0BAA0B,CAAC;CACnC;AAED,MAAM,WAAW,sCAAsC;IACrD;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,+BAA+B;IAC9C,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;
|
|
1
|
+
{"version":3,"file":"use-agent-engine-configured.d.ts","sourceRoot":"","sources":["../../src/client/use-agent-engine-configured.ts"],"names":[],"mappings":"AAOA,iFAAiF;AACjF,MAAM,MAAM,0BAA0B,GAAG,SAAS,GAAG,YAAY,GAAG,SAAS,CAAC;AAE9E,MAAM,WAAW,8BAA8B;IAC7C,6EAA6E;IAC7E,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,0BAA0B,CAAC;CACnC;AAED,MAAM,WAAW,sCAAsC;IACrD;;;;OAIG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,+BAA+B;IAC9C,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAiED,wBAAsB,+BAA+B,CACnD,OAAO,UAAO,EACd,OAAO,CAAC,EAAE,sCAAsC,GAC/C,OAAO,CAAC,0BAA0B,CAAC,CA4CrC;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,UAAO,EACd,OAAO,CAAC,EAAE,+BAA+B,GACxC,8BAA8B,CAyDhC"}
|
|
@@ -3,6 +3,7 @@ import { PROVIDER_ENV_VARS } from "../agent/engine/provider-env-vars.js";
|
|
|
3
3
|
import { agentNativePath } from "./api-path.js";
|
|
4
4
|
const PROVIDER_ENV_VAR_SET = new Set(PROVIDER_ENV_VARS);
|
|
5
5
|
const DEFAULT_STATUS_CHECK_TIMEOUT_MS = 2500;
|
|
6
|
+
const UNKNOWN_STATUS_RETRY_MS = 2000;
|
|
6
7
|
async function fetchStatusJson(path, timeoutMs) {
|
|
7
8
|
const controller = typeof AbortController !== "undefined" ? new AbortController() : null;
|
|
8
9
|
let timeoutId;
|
|
@@ -75,9 +76,14 @@ export async function fetchAgentEngineConfiguredState(enabled = true, options) {
|
|
|
75
76
|
(engineStatusKnown && engineStatus.configured);
|
|
76
77
|
if (anyConfigured)
|
|
77
78
|
return "configured";
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
// The engine status route is the canonical readiness check: it resolves
|
|
80
|
+
// Builder, scoped BYOK secrets, deployment credentials, and custom engines.
|
|
81
|
+
// Once it has answered `configured: false`, a slow legacy env/Builder status
|
|
82
|
+
// request must not leave the composer permissively stuck in `unknown`.
|
|
83
|
+
if (engineStatusKnown)
|
|
84
|
+
return "missing";
|
|
85
|
+
// Compatibility fallback for older hosts without the canonical route.
|
|
86
|
+
return envKeysKnown && builderStatusKnown ? "missing" : "unknown";
|
|
81
87
|
}
|
|
82
88
|
/**
|
|
83
89
|
* Shared "can the agent run?" gate — the single source of truth for the sidebar
|
|
@@ -90,17 +96,23 @@ export function useAgentEngineConfigured(enabled = true, options) {
|
|
|
90
96
|
const [state, setState] = useState("unknown");
|
|
91
97
|
useEffect(() => {
|
|
92
98
|
let cancelled = false;
|
|
99
|
+
let retryId;
|
|
93
100
|
// Monotonic call counter: overlapping checks (mount + a
|
|
94
101
|
// `agent-engine:configured-changed` fired right after a key is saved) can
|
|
95
102
|
// resolve out of order; only the latest call may write state, or a slow
|
|
96
103
|
// stale "missing" response would overwrite the fresh "configured" one.
|
|
97
104
|
let requestSeq = 0;
|
|
98
105
|
const check = async (options) => {
|
|
106
|
+
if (retryId !== undefined) {
|
|
107
|
+
clearTimeout(retryId);
|
|
108
|
+
retryId = undefined;
|
|
109
|
+
}
|
|
99
110
|
const seq = ++requestSeq;
|
|
100
111
|
const nextState = await fetchAgentEngineConfiguredState(enabled, options);
|
|
101
112
|
if (cancelled || seq !== requestSeq)
|
|
102
113
|
return;
|
|
103
114
|
if (nextState === "unknown") {
|
|
115
|
+
retryId = setTimeout(() => void check(), UNKNOWN_STATUS_RETRY_MS);
|
|
104
116
|
return;
|
|
105
117
|
}
|
|
106
118
|
setState(nextState);
|
|
@@ -124,6 +136,8 @@ export function useAgentEngineConfigured(enabled = true, options) {
|
|
|
124
136
|
window.addEventListener("agent-chat:missing-api-key", onMissing);
|
|
125
137
|
return () => {
|
|
126
138
|
cancelled = true;
|
|
139
|
+
if (retryId !== undefined)
|
|
140
|
+
clearTimeout(retryId);
|
|
127
141
|
window.removeEventListener("agent-engine:configured-changed", onConfiguredChanged);
|
|
128
142
|
window.removeEventListener("agent-chat:missing-api-key", onMissing);
|
|
129
143
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-agent-engine-configured.js","sourceRoot":"","sources":["../../src/client/use-agent-engine-configured.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC,iBAAiB,CAAC,CAAC;AA0BxD,MAAM,+BAA+B,GAAG,IAAI,CAAC;AAE7C,KAAK,UAAU,eAAe,CAC5B,IAAY,EACZ,SAAiB;IAEjB,MAAM,UAAU,GACd,OAAO,eAAe,KAAK,WAAW,CAAC,CAAC,CAAC,IAAI,eAAe,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IACxE,IAAI,SAAoD,CAAC;IACzD,MAAM,OAAO,GAAG,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;QAC5C,SAAS,GAAG,UAAU,CAAC,GAAG,EAAE;YAC1B,UAAU,EAAE,KAAK,EAAE,CAAC;YACpB,OAAO,CAAC,IAAI,CAAC,CAAC;QAChB,CAAC,EAAE,SAAS,CAAC,CAAC;IAChB,CAAC,CAAC,CAAC;IAEH,2EAA2E;IAC3E,4EAA4E;IAC5E,yEAAyE;IACzE,MAAM,OAAO,GAAG,KAAK,CAAC,eAAe,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QACF,MAAM,mBAAmB,GAAG,GAAG,EAAE;YAC/B,KAAK,KAAK,EAAE,CAAC;QACf,CAAC,CAAC;QACF,MAAM,SAAS,GAAG,CAAC,KAAY,EAAE,EAAE;YACjC,IAAI,CAAC,2BAA2B,CAAC,KAAK,EAAE,OAAO,CAAC;gBAAE,OAAO;YACzD,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,QAAQ,CAAC,YAAY,CAAC,CAAC;gBACvB,OAAO;YACT,CAAC;YACD,KAAK,KAAK,CAAC,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC,CAAC;QACxC,CAAC,CAAC;QAEF,KAAK,KAAK,EAAE,CAAC;QACb,MAAM,CAAC,gBAAgB,CACrB,iCAAiC,EACjC,mBAAmB,CACpB,CAAC;QACF,4EAA4E;QAC5E,uDAAuD;QACvD,MAAM,CAAC,gBAAgB,CAAC,4BAA4B,EAAE,SAAS,CAAC,CAAC;QACjE,OAAO,GAAG,EAAE;YACV,SAAS,GAAG,IAAI,CAAC;YACjB,MAAM,CAAC,mBAAmB,CACxB,iCAAiC,EACjC,mBAAmB,CACpB,CAAC;YACF,MAAM,CAAC,mBAAmB,CAAC,4BAA4B,EAAE,SAAS,CAAC,CAAC;QACtE,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC;IAEjD,OAAO,EAAE,OAAO,EAAE,KAAK,KAAK,SAAS,EAAE,KAAK,EAAE,CAAC;AACjD,CAAC","sourcesContent":["import { useEffect, useState } from \"react\";\n\nimport { PROVIDER_ENV_VARS } from \"../agent/engine/provider-env-vars.js\";\nimport { agentNativePath } from \"./api-path.js\";\n\nconst PROVIDER_ENV_VAR_SET = new Set(PROVIDER_ENV_VARS);\n\n/** `unknown` until the first check resolves, so callers don't flash the gate. */\nexport type AgentEngineConfiguredState = \"unknown\" | \"configured\" | \"missing\";\n\nexport interface UseAgentEngineConfiguredResult {\n /** True once we know nothing can run the agent (no key / Builder / BYOK). */\n missing: boolean;\n state: AgentEngineConfiguredState;\n}\n\nexport interface FetchAgentEngineConfiguredStateOptions {\n /**\n * Legacy hint from explicit missing-key stream events. Kept for API\n * compatibility, but missing state still requires authoritative status\n * responses so transient endpoint failures do not clobber connected state.\n */\n missingFallback?: boolean;\n timeoutMs?: number;\n}\n\nexport interface UseAgentEngineConfiguredOptions {\n tabId?: string | null;\n threadId?: string | null;\n}\n\nconst DEFAULT_STATUS_CHECK_TIMEOUT_MS = 2500;\n\nasync function fetchStatusJson(\n path: string,\n timeoutMs: number,\n): Promise<unknown | null> {\n const controller =\n typeof AbortController !== \"undefined\" ? new AbortController() : null;\n let timeoutId: ReturnType<typeof setTimeout> | undefined;\n const timeout = new Promise<null>((resolve) => {\n timeoutId = setTimeout(() => {\n controller?.abort();\n resolve(null);\n }, timeoutMs);\n });\n\n // Never serve a stale status from the HTTP cache: this is re-fetched right\n // after a provider connects, and a cached \"missing\" would keep the composer\n // gate and error banner pinned even though a provider is now configured.\n const request = fetch(agentNativePath(path), {\n cache: \"no-store\",\n ...(controller ? { signal: controller.signal } : {}),\n })\n .then((r) => (r.ok ? r.json() : null))\n .catch(() => null)\n .finally(() => {\n if (timeoutId !== undefined) clearTimeout(timeoutId);\n });\n\n return Promise.race([request, timeout]);\n}\n\nfunction hasConfiguredFlag(value: unknown): value is { configured: boolean } {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"configured\" in value &&\n typeof (value as { configured?: unknown }).configured === \"boolean\"\n );\n}\n\nfunction missingKeyEventMatchesScope(\n event: Event,\n options: UseAgentEngineConfiguredOptions | undefined,\n): boolean {\n const detail = (event as CustomEvent).detail as\n | { tabId?: unknown; threadId?: unknown }\n | undefined;\n const eventTabId = typeof detail?.tabId === \"string\" ? detail.tabId : null;\n const eventThreadId =\n typeof detail?.threadId === \"string\" ? detail.threadId : null;\n if (!eventTabId && !eventThreadId) return true;\n\n const tabId = options?.tabId ?? null;\n const threadId = options?.threadId ?? null;\n if (!tabId && !threadId) return true;\n return (\n (eventTabId != null && eventTabId === tabId) ||\n (eventThreadId != null && eventThreadId === threadId)\n );\n}\n\nexport async function fetchAgentEngineConfiguredState(\n enabled = true,\n options?: FetchAgentEngineConfiguredStateOptions,\n): Promise<AgentEngineConfiguredState> {\n if (!enabled) return \"configured\";\n\n const timeoutMs =\n typeof options?.timeoutMs === \"number\" && options.timeoutMs > 0\n ? options.timeoutMs\n : DEFAULT_STATUS_CHECK_TIMEOUT_MS;\n const [envKeys, builderStatus, engineStatus] = await Promise.all([\n fetchStatusJson(\"/_agent-native/env-status\", timeoutMs),\n fetchStatusJson(\"/_agent-native/builder/status\", timeoutMs),\n fetchStatusJson(\"/_agent-native/agent-engine/status\", timeoutMs),\n ]);\n\n // All three failed — likely a flaky network; keep the caller in unknown.\n // Even an explicit missing-key stream event should not pin the composer into\n // setup without a fresh authoritative status response.\n if (envKeys == null && builderStatus == null && engineStatus == null) {\n return \"unknown\";\n }\n\n const envKeysKnown = Array.isArray(envKeys);\n const builderStatusKnown = hasConfiguredFlag(builderStatus);\n const engineStatusKnown = hasConfiguredFlag(engineStatus);\n const keys = envKeysKnown\n ? (envKeys as Array<{\n key: string;\n configured: boolean;\n }>)\n : [];\n const llmKeys = keys.filter((k) => PROVIDER_ENV_VAR_SET.has(k.key));\n const anyConfigured =\n llmKeys.some((k) => k.configured) ||\n (builderStatusKnown && builderStatus.configured) ||\n (engineStatusKnown && engineStatus.configured);\n if (anyConfigured) return \"configured\";\n return envKeysKnown && builderStatusKnown && engineStatusKnown\n ? \"missing\"\n : \"unknown\";\n}\n\n/**\n * Shared \"can the agent run?\" gate — the single source of truth for the sidebar\n * composer and app prompt boxes. Checks the env-key / Builder / BYOK status\n * endpoints on mount, re-checks on `agent-engine:configured-changed`, and folds\n * in the adapter's `agent-chat:missing-api-key` signal. Pass `enabled = false`\n * to short-circuit to configured; flaky requests stay `unknown`.\n */\nexport function useAgentEngineConfigured(\n enabled = true,\n options?: UseAgentEngineConfiguredOptions,\n): UseAgentEngineConfiguredResult {\n const [state, setState] = useState<AgentEngineConfiguredState>(\"unknown\");\n\n useEffect(() => {\n let cancelled = false;\n // Monotonic call counter: overlapping checks (mount + a\n // `agent-engine:configured-changed` fired right after a key is saved) can\n // resolve out of order; only the latest call may write state, or a slow\n // stale \"missing\" response would overwrite the fresh \"configured\" one.\n let requestSeq = 0;\n const check = async (options?: { missingFallback?: boolean }) => {\n const seq = ++requestSeq;\n const nextState = await fetchAgentEngineConfiguredState(enabled, options);\n if (cancelled || seq !== requestSeq) return;\n if (nextState === \"unknown\") {\n return;\n }\n setState(nextState);\n };\n const onConfiguredChanged = () => {\n void check();\n };\n const onMissing = (event: Event) => {\n if (!missingKeyEventMatchesScope(event, options)) return;\n if (!enabled) {\n setState(\"configured\");\n return;\n }\n void check({ missingFallback: true });\n };\n\n void check();\n window.addEventListener(\n \"agent-engine:configured-changed\",\n onConfiguredChanged,\n );\n // A stale failed stream can arrive after a reconnect succeeds. Re-check the\n // current status before pinning the composer in setup.\n window.addEventListener(\"agent-chat:missing-api-key\", onMissing);\n return () => {\n cancelled = true;\n window.removeEventListener(\n \"agent-engine:configured-changed\",\n onConfiguredChanged,\n );\n window.removeEventListener(\"agent-chat:missing-api-key\", onMissing);\n };\n }, [enabled, options?.tabId, options?.threadId]);\n\n return { missing: state === \"missing\", state };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"use-agent-engine-configured.js","sourceRoot":"","sources":["../../src/client/use-agent-engine-configured.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC,iBAAiB,CAAC,CAAC;AA0BxD,MAAM,+BAA+B,GAAG,IAAI,CAAC;AAC7C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AAe,EAAE,IAAI,EAAE,CAAC,CAAC;QACxC,CAAC,CAAC;QAEF,KAAK,KAAK,EAAE,CAAC;QACb,MAAM,CAAC,gBAAgB,CACrB,iCAAiC,EACjC,mBAAmB,CACpB,CAAC;QACF,4EAA4E;QAC5E,uDAAuD;QACvD,MAAM,CAAC,gBAAgB,CAAC,4BAA4B,EAAE,SAAS,CAAC,CAAC;QACjE,OAAO,GAAG,EAAE;YACV,SAAS,GAAG,IAAI,CAAC;YACjB,IAAI,OAAO,KAAK,SAAS;gBAAE,YAAY,CAAC,OAAO,CAAC,CAAC;YACjD,MAAM,CAAC,mBAAmB,CACxB,iCAAiC,EACjC,mBAAmB,CACpB,CAAC;YACF,MAAM,CAAC,mBAAmB,CAAC,4BAA4B,EAAE,SAAS,CAAC,CAAC;QACtE,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC;IAEjD,OAAO,EAAE,OAAO,EAAE,KAAK,KAAK,SAAS,EAAE,KAAK,EAAE,CAAC;AACjD,CAAC","sourcesContent":["import { useEffect, useState } from \"react\";\n\nimport { PROVIDER_ENV_VARS } from \"../agent/engine/provider-env-vars.js\";\nimport { agentNativePath } from \"./api-path.js\";\n\nconst PROVIDER_ENV_VAR_SET = new Set(PROVIDER_ENV_VARS);\n\n/** `unknown` until the first check resolves, so callers don't flash the gate. */\nexport type AgentEngineConfiguredState = \"unknown\" | \"configured\" | \"missing\";\n\nexport interface UseAgentEngineConfiguredResult {\n /** True once we know nothing can run the agent (no key / Builder / BYOK). */\n missing: boolean;\n state: AgentEngineConfiguredState;\n}\n\nexport interface FetchAgentEngineConfiguredStateOptions {\n /**\n * Legacy hint from explicit missing-key stream events. Kept for API\n * compatibility, but missing state still requires authoritative status\n * responses so transient endpoint failures do not clobber connected state.\n */\n missingFallback?: boolean;\n timeoutMs?: number;\n}\n\nexport interface UseAgentEngineConfiguredOptions {\n tabId?: string | null;\n threadId?: string | null;\n}\n\nconst DEFAULT_STATUS_CHECK_TIMEOUT_MS = 2500;\nconst UNKNOWN_STATUS_RETRY_MS = 2000;\n\nasync function fetchStatusJson(\n path: string,\n timeoutMs: number,\n): Promise<unknown | null> {\n const controller =\n typeof AbortController !== \"undefined\" ? new AbortController() : null;\n let timeoutId: ReturnType<typeof setTimeout> | undefined;\n const timeout = new Promise<null>((resolve) => {\n timeoutId = setTimeout(() => {\n controller?.abort();\n resolve(null);\n }, timeoutMs);\n });\n\n // Never serve a stale status from the HTTP cache: this is re-fetched right\n // after a provider connects, and a cached \"missing\" would keep the composer\n // gate and error banner pinned even though a provider is now configured.\n const request = fetch(agentNativePath(path), {\n cache: \"no-store\",\n ...(controller ? { signal: controller.signal } : {}),\n })\n .then((r) => (r.ok ? r.json() : null))\n .catch(() => null)\n .finally(() => {\n if (timeoutId !== undefined) clearTimeout(timeoutId);\n });\n\n return Promise.race([request, timeout]);\n}\n\nfunction hasConfiguredFlag(value: unknown): value is { configured: boolean } {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"configured\" in value &&\n typeof (value as { configured?: unknown }).configured === \"boolean\"\n );\n}\n\nfunction missingKeyEventMatchesScope(\n event: Event,\n options: UseAgentEngineConfiguredOptions | undefined,\n): boolean {\n const detail = (event as CustomEvent).detail as\n | { tabId?: unknown; threadId?: unknown }\n | undefined;\n const eventTabId = typeof detail?.tabId === \"string\" ? detail.tabId : null;\n const eventThreadId =\n typeof detail?.threadId === \"string\" ? detail.threadId : null;\n if (!eventTabId && !eventThreadId) return true;\n\n const tabId = options?.tabId ?? null;\n const threadId = options?.threadId ?? null;\n if (!tabId && !threadId) return true;\n return (\n (eventTabId != null && eventTabId === tabId) ||\n (eventThreadId != null && eventThreadId === threadId)\n );\n}\n\nexport async function fetchAgentEngineConfiguredState(\n enabled = true,\n options?: FetchAgentEngineConfiguredStateOptions,\n): Promise<AgentEngineConfiguredState> {\n if (!enabled) return \"configured\";\n\n const timeoutMs =\n typeof options?.timeoutMs === \"number\" && options.timeoutMs > 0\n ? options.timeoutMs\n : DEFAULT_STATUS_CHECK_TIMEOUT_MS;\n const [envKeys, builderStatus, engineStatus] = await Promise.all([\n fetchStatusJson(\"/_agent-native/env-status\", timeoutMs),\n fetchStatusJson(\"/_agent-native/builder/status\", timeoutMs),\n fetchStatusJson(\"/_agent-native/agent-engine/status\", timeoutMs),\n ]);\n\n // All three failed — likely a flaky network; keep the caller in unknown.\n // Even an explicit missing-key stream event should not pin the composer into\n // setup without a fresh authoritative status response.\n if (envKeys == null && builderStatus == null && engineStatus == null) {\n return \"unknown\";\n }\n\n const envKeysKnown = Array.isArray(envKeys);\n const builderStatusKnown = hasConfiguredFlag(builderStatus);\n const engineStatusKnown = hasConfiguredFlag(engineStatus);\n const keys = envKeysKnown\n ? (envKeys as Array<{\n key: string;\n configured: boolean;\n }>)\n : [];\n const llmKeys = keys.filter((k) => PROVIDER_ENV_VAR_SET.has(k.key));\n const anyConfigured =\n llmKeys.some((k) => k.configured) ||\n (builderStatusKnown && builderStatus.configured) ||\n (engineStatusKnown && engineStatus.configured);\n if (anyConfigured) return \"configured\";\n\n // The engine status route is the canonical readiness check: it resolves\n // Builder, scoped BYOK secrets, deployment credentials, and custom engines.\n // Once it has answered `configured: false`, a slow legacy env/Builder status\n // request must not leave the composer permissively stuck in `unknown`.\n if (engineStatusKnown) return \"missing\";\n\n // Compatibility fallback for older hosts without the canonical route.\n return envKeysKnown && builderStatusKnown ? \"missing\" : \"unknown\";\n}\n\n/**\n * Shared \"can the agent run?\" gate — the single source of truth for the sidebar\n * composer and app prompt boxes. Checks the env-key / Builder / BYOK status\n * endpoints on mount, re-checks on `agent-engine:configured-changed`, and folds\n * in the adapter's `agent-chat:missing-api-key` signal. Pass `enabled = false`\n * to short-circuit to configured; flaky requests stay `unknown`.\n */\nexport function useAgentEngineConfigured(\n enabled = true,\n options?: UseAgentEngineConfiguredOptions,\n): UseAgentEngineConfiguredResult {\n const [state, setState] = useState<AgentEngineConfiguredState>(\"unknown\");\n\n useEffect(() => {\n let cancelled = false;\n let retryId: ReturnType<typeof setTimeout> | undefined;\n // Monotonic call counter: overlapping checks (mount + a\n // `agent-engine:configured-changed` fired right after a key is saved) can\n // resolve out of order; only the latest call may write state, or a slow\n // stale \"missing\" response would overwrite the fresh \"configured\" one.\n let requestSeq = 0;\n const check = async (options?: { missingFallback?: boolean }) => {\n if (retryId !== undefined) {\n clearTimeout(retryId);\n retryId = undefined;\n }\n const seq = ++requestSeq;\n const nextState = await fetchAgentEngineConfiguredState(enabled, options);\n if (cancelled || seq !== requestSeq) return;\n if (nextState === \"unknown\") {\n retryId = setTimeout(() => void check(), UNKNOWN_STATUS_RETRY_MS);\n return;\n }\n setState(nextState);\n };\n const onConfiguredChanged = () => {\n void check();\n };\n const onMissing = (event: Event) => {\n if (!missingKeyEventMatchesScope(event, options)) return;\n if (!enabled) {\n setState(\"configured\");\n return;\n }\n void check({ missingFallback: true });\n };\n\n void check();\n window.addEventListener(\n \"agent-engine:configured-changed\",\n onConfiguredChanged,\n );\n // A stale failed stream can arrive after a reconnect succeeds. Re-check the\n // current status before pinning the composer in setup.\n window.addEventListener(\"agent-chat:missing-api-key\", onMissing);\n return () => {\n cancelled = true;\n if (retryId !== undefined) clearTimeout(retryId);\n window.removeEventListener(\n \"agent-engine:configured-changed\",\n onConfiguredChanged,\n );\n window.removeEventListener(\"agent-chat:missing-api-key\", onMissing);\n };\n }, [enabled, options?.tabId, options?.threadId]);\n\n return { missing: state === \"missing\", state };\n}\n"]}
|
|
@@ -5,7 +5,13 @@ interface QueryClient {
|
|
|
5
5
|
invalidateQueries(opts?: {
|
|
6
6
|
queryKey?: string[];
|
|
7
7
|
predicate?: (query: Query) => boolean;
|
|
8
|
-
}
|
|
8
|
+
}, options?: {
|
|
9
|
+
cancelRefetch?: boolean;
|
|
10
|
+
}): unknown;
|
|
11
|
+
isFetching?(filters?: {
|
|
12
|
+
queryKey?: string[];
|
|
13
|
+
predicate?: (query: Query) => boolean;
|
|
14
|
+
}): number;
|
|
9
15
|
}
|
|
10
16
|
export type SyncEvent = {
|
|
11
17
|
version?: number;
|
|
@@ -83,7 +89,7 @@ export declare function subscribeSyncEvents(options: SubscribeSyncEventsOptions)
|
|
|
83
89
|
* @param options.onEvent - Optional callback for each change event
|
|
84
90
|
* @param options.interval - Poll interval in ms. Default: 2000
|
|
85
91
|
* @param options.fallbackInterval - Poll interval while SSE is connected.
|
|
86
|
-
* Default:
|
|
92
|
+
* Default: 60000
|
|
87
93
|
* @param options.pauseWhenHidden - Pause polling while the tab is hidden.
|
|
88
94
|
* Default: true
|
|
89
95
|
* @param options.ignoreSource - Skip events whose `requestSource` matches this
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-db-sync.d.ts","sourceRoot":"","sources":["../../src/client/use-db-sync.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-db-sync.d.ts","sourceRoot":"","sources":["../../src/client/use-db-sync.ts"],"names":[],"mappings":"AAcA,UAAU,KAAK;IACb,QAAQ,EAAE,SAAS,OAAO,EAAE,CAAC;CAC9B;AAED,UAAU,WAAW;IACnB,iBAAiB,CACf,IAAI,CAAC,EAAE;QACL,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;QACpB,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC;KACvC,EACD,OAAO,CAAC,EAAE;QAAE,aAAa,CAAC,EAAE,OAAO,CAAA;KAAE,GACpC,OAAO,CAAC;IACX,UAAU,CAAC,CAAC,OAAO,CAAC,EAAE;QACpB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;QACpB,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC;KACvC,GAAG,MAAM,CAAC;CACZ;AA0BD,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAA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