@agent-native/core 0.97.0 → 0.98.1
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 +56 -0
- package/corpus/core/docs/content/authentication.mdx +3 -3
- package/corpus/core/docs/content/doctor.mdx +170 -0
- package/corpus/core/docs/content/external-agents.mdx +8 -7
- package/corpus/core/docs/content/locales/ar-SA/authentication.mdx +2 -2
- package/corpus/core/docs/content/locales/ar-SA/external-agents.mdx +8 -7
- package/corpus/core/docs/content/locales/ar-SA/mcp-protocol.mdx +1 -1
- package/corpus/core/docs/content/locales/ar-SA/security.mdx +2 -0
- package/corpus/core/docs/content/locales/de-DE/authentication.mdx +1 -1
- package/corpus/core/docs/content/locales/de-DE/external-agents.mdx +8 -7
- package/corpus/core/docs/content/locales/de-DE/mcp-protocol.mdx +1 -1
- package/corpus/core/docs/content/locales/de-DE/security.mdx +2 -0
- package/corpus/core/docs/content/locales/es-ES/authentication.mdx +2 -2
- package/corpus/core/docs/content/locales/es-ES/external-agents.mdx +8 -7
- package/corpus/core/docs/content/locales/es-ES/mcp-protocol.mdx +1 -1
- package/corpus/core/docs/content/locales/es-ES/security.mdx +2 -0
- package/corpus/core/docs/content/locales/fr-FR/authentication.mdx +1 -1
- package/corpus/core/docs/content/locales/fr-FR/external-agents.mdx +8 -7
- package/corpus/core/docs/content/locales/fr-FR/mcp-protocol.mdx +1 -1
- package/corpus/core/docs/content/locales/fr-FR/security.mdx +2 -0
- package/corpus/core/docs/content/locales/hi-IN/authentication.mdx +2 -2
- package/corpus/core/docs/content/locales/hi-IN/external-agents.mdx +8 -7
- package/corpus/core/docs/content/locales/hi-IN/mcp-protocol.mdx +1 -1
- package/corpus/core/docs/content/locales/hi-IN/security.mdx +2 -0
- package/corpus/core/docs/content/locales/ja-JP/authentication.mdx +2 -2
- package/corpus/core/docs/content/locales/ja-JP/external-agents.mdx +8 -7
- package/corpus/core/docs/content/locales/ja-JP/mcp-protocol.mdx +1 -1
- package/corpus/core/docs/content/locales/ja-JP/security.mdx +2 -0
- package/corpus/core/docs/content/locales/ko-KR/authentication.mdx +2 -2
- package/corpus/core/docs/content/locales/ko-KR/external-agents.mdx +8 -7
- package/corpus/core/docs/content/locales/ko-KR/mcp-protocol.mdx +1 -1
- package/corpus/core/docs/content/locales/ko-KR/security.mdx +2 -0
- package/corpus/core/docs/content/locales/pt-BR/authentication.mdx +2 -2
- package/corpus/core/docs/content/locales/pt-BR/external-agents.mdx +8 -7
- package/corpus/core/docs/content/locales/pt-BR/mcp-protocol.mdx +1 -1
- package/corpus/core/docs/content/locales/pt-BR/security.mdx +2 -0
- package/corpus/core/docs/content/locales/zh-CN/authentication.mdx +2 -2
- package/corpus/core/docs/content/locales/zh-CN/external-agents.mdx +8 -7
- package/corpus/core/docs/content/locales/zh-CN/mcp-protocol.mdx +1 -1
- package/corpus/core/docs/content/locales/zh-CN/security.mdx +2 -0
- package/corpus/core/docs/content/locales/zh-TW/authentication.mdx +2 -2
- package/corpus/core/docs/content/locales/zh-TW/external-agents.mdx +8 -7
- package/corpus/core/docs/content/locales/zh-TW/mcp-protocol.mdx +1 -1
- package/corpus/core/docs/content/locales/zh-TW/security.mdx +2 -0
- package/corpus/core/docs/content/mcp-protocol.mdx +1 -1
- package/corpus/core/docs/content/security.mdx +2 -0
- package/corpus/core/package.json +6 -2
- package/corpus/core/scripts/finalize-build.mjs +63 -3
- package/corpus/core/scripts/materialize-source-corpus.mjs +101 -15
- package/corpus/core/src/action-change-marker.ts +8 -1
- package/corpus/core/src/action.ts +42 -0
- package/corpus/core/src/agent/engine/builder-engine.ts +3 -0
- package/corpus/core/src/agent/engine/context-directives-transform.ts +69 -0
- package/corpus/core/src/agent/engine/continuation-dispatch-retry.ts +168 -0
- package/corpus/core/src/agent/engine/tool-call-journal-seed.ts +85 -0
- package/corpus/core/src/agent/production-agent.ts +129 -244
- package/corpus/core/src/changelog/parse.ts +8 -3
- package/corpus/core/src/cli/doctor.ts +9 -3
- package/corpus/core/src/cli/plan-local.ts +10 -2
- package/corpus/core/src/cli/skills-content/assets-skill.ts +83 -0
- package/corpus/core/src/cli/skills-content/canvas.ts +153 -0
- package/corpus/core/src/cli/skills-content/connection.ts +52 -0
- package/corpus/core/src/cli/skills-content/content-skill.ts +109 -0
- package/corpus/core/src/cli/skills-content/design-exploration-skill.ts +118 -0
- package/corpus/core/src/cli/skills-content/design-visual-edit-skill.ts +228 -0
- package/corpus/core/src/cli/skills-content/document-quality.ts +196 -0
- package/corpus/core/src/cli/skills-content/exemplar.ts +69 -0
- package/corpus/core/src/cli/skills-content/help.ts +77 -0
- package/corpus/core/src/cli/skills-content/index.ts +22 -0
- package/corpus/core/src/cli/skills-content/local-files.ts +95 -0
- package/corpus/core/src/cli/skills-content/plan-setup-auth.ts +80 -0
- package/corpus/core/src/cli/skills-content/visual-plan-skill.ts +470 -0
- package/corpus/core/src/cli/skills-content/visual-recap-skill.ts +547 -0
- package/corpus/core/src/cli/skills-content/visualize-repo-skill.ts +93 -0
- package/corpus/core/src/cli/skills-content/wireframe.ts +349 -0
- package/corpus/core/src/cli/skills.ts +27 -2733
- package/corpus/core/src/client/AgentPanel.tsx +8 -8
- package/corpus/core/src/client/AssistantChat.tsx +83 -39
- package/corpus/core/src/client/CommandMenu.tsx +16 -5
- package/corpus/core/src/client/FeedbackButton.tsx +2 -2
- package/corpus/core/src/client/analytics.ts +29 -0
- package/corpus/core/src/client/app-providers.tsx +18 -5
- package/corpus/core/src/client/blocks/library/wireframe-kit.tsx +16 -2
- package/corpus/core/src/client/chat/tool-call-display.tsx +3 -3
- package/corpus/core/src/client/chat-model-groups.ts +28 -0
- package/corpus/core/src/client/composer/PastedTextChip.tsx +1 -1
- package/corpus/core/src/client/composer/RealtimeVoiceMode.tsx +523 -68
- package/corpus/core/src/client/composer/TiptapComposer.tsx +47 -30
- package/corpus/core/src/client/composer/VoiceButton.tsx +22 -5
- package/corpus/core/src/client/composer/index.ts +5 -0
- package/corpus/core/src/client/composer/useRealtimeVoiceMode.tsx +1271 -35
- package/corpus/core/src/client/context-xray/ContextXRayPanel.tsx +5 -2
- package/corpus/core/src/client/extensions/ExtensionEditor.tsx +37 -4
- package/corpus/core/src/client/extensions/ExtensionQueryErrorState.tsx +47 -0
- package/corpus/core/src/client/extensions/ExtensionSlot.tsx +39 -10
- package/corpus/core/src/client/extensions/ExtensionViewer.tsx +44 -6
- package/corpus/core/src/client/extensions/ExtensionsListPage.tsx +12 -3
- package/corpus/core/src/client/extensions/ExtensionsSidebarSection.tsx +49 -11
- package/corpus/core/src/client/index.ts +5 -13
- package/corpus/core/src/client/progress/RunsTray.tsx +23 -4
- 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/settings/SettingsTabsPage.tsx +7 -0
- package/corpus/core/src/client/settings/useBuilderStatus.ts +6 -0
- package/corpus/core/src/client/tool-cells/EditCell.tsx +19 -16
- package/corpus/core/src/client/tool-cells/FilesChangedSummary.tsx +26 -23
- package/corpus/core/src/client/tool-cells/WriteCell.tsx +19 -16
- 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-pausing-interval.ts +14 -4
- package/corpus/core/src/client/visual-style-controls.tsx +1 -1
- package/corpus/core/src/deploy/build.ts +36 -14
- package/corpus/core/src/integrations/google-docs-poller.ts +23 -2
- package/corpus/core/src/integrations/plugin.ts +10 -0
- 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/integrations/webhook-handler.ts +27 -2
- package/corpus/core/src/jobs/scheduler.ts +28 -2
- package/corpus/core/src/localization/default-messages.ts +51 -1
- package/corpus/core/src/mcp/oauth-token.ts +6 -1
- package/corpus/core/src/mcp-client/workspace-servers.ts +4 -4
- package/corpus/core/src/observability/routes.ts +36 -0
- package/corpus/core/src/observability/sentiment.ts +261 -0
- package/corpus/core/src/observability/store.ts +23 -0
- package/corpus/core/src/observability/traces.ts +49 -63
- package/corpus/core/src/observability/tracking-identity.ts +55 -0
- package/corpus/core/src/observability/types.ts +13 -0
- package/corpus/core/src/secrets/crypto.ts +28 -8
- package/corpus/core/src/secrets/storage.ts +67 -3
- 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/agent-chat/action-filters-a2a.ts +199 -0
- package/corpus/core/src/server/agent-chat/browser-team-tools.ts +510 -0
- package/corpus/core/src/server/agent-chat/context-tools.ts +595 -0
- package/corpus/core/src/server/agent-chat/framework-prompts.ts +470 -0
- package/corpus/core/src/server/agent-chat/lazy-fs.ts +11 -0
- package/corpus/core/src/server/agent-chat/mcp-glue.ts +91 -0
- package/corpus/core/src/server/agent-chat/plugin-options.ts +350 -0
- package/corpus/core/src/server/agent-chat/process-run-failure.ts +62 -0
- package/corpus/core/src/server/agent-chat/prompt-resources.ts +688 -0
- package/corpus/core/src/server/agent-chat/recurring-jobs-runtime.ts +80 -0
- package/corpus/core/src/server/agent-chat/request-surface.ts +71 -0
- package/corpus/core/src/server/agent-chat/run-code-tools.ts +67 -0
- package/corpus/core/src/server/agent-chat/script-entries.ts +779 -0
- package/corpus/core/src/server/agent-chat/shared-thread.ts +301 -0
- package/corpus/core/src/server/agent-chat/skill-frontmatter.ts +41 -0
- package/corpus/core/src/server/agent-chat-plugin.ts +364 -4182
- package/corpus/core/src/server/agent-teams.ts +26 -3
- package/corpus/core/src/server/auth.ts +55 -57
- package/corpus/core/src/server/credential-provider.ts +22 -25
- package/corpus/core/src/server/edge.ts +1 -0
- package/corpus/core/src/server/onboarding-html.ts +1 -16
- package/corpus/core/src/server/poll.ts +1 -0
- package/corpus/core/src/server/realtime-voice.ts +335 -14
- package/corpus/core/src/server/request-origin.ts +6 -2
- package/corpus/core/src/server/ssr-handler.ts +55 -2
- package/corpus/core/src/sharing/access.ts +155 -11
- package/corpus/core/src/sharing/registry.ts +7 -0
- package/corpus/core/src/styles/agent-native.css +17 -16
- package/corpus/core/src/templates/default/.agents/skills/frontend-design/SKILL.md +1 -1
- package/corpus/core/src/templates/default/.agents/skills/real-time-sync/SKILL.md +2 -2
- package/corpus/core/src/templates/default/app/i18n/ar-SA.ts +6 -0
- package/corpus/core/src/templates/default/app/i18n/de-DE.ts +6 -0
- package/corpus/core/src/templates/default/app/i18n/en-US.ts +6 -0
- package/corpus/core/src/templates/default/app/i18n/es-ES.ts +6 -0
- package/corpus/core/src/templates/default/app/i18n/fr-FR.ts +6 -0
- package/corpus/core/src/templates/default/app/i18n/hi-IN.ts +6 -0
- package/corpus/core/src/templates/default/app/i18n/ja-JP.ts +6 -0
- package/corpus/core/src/templates/default/app/i18n/ko-KR.ts +6 -0
- package/corpus/core/src/templates/default/app/i18n/pt-BR.ts +6 -0
- package/corpus/core/src/templates/default/app/i18n/zh-CN.ts +6 -0
- package/corpus/core/src/templates/default/app/i18n/zh-TW.ts +6 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/authentication/SKILL.md +27 -29
- package/corpus/core/src/templates/workspace-core/.agents/skills/external-agents/SKILL.md +2 -1
- package/corpus/core/src/templates/workspace-core/.agents/skills/frontend-design/SKILL.md +1 -1
- package/corpus/core/src/templates/workspace-core/.agents/skills/observability/SKILL.md +32 -0
- 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/templates/workspace-core/.agents/skills/writing-agent-instructions/SKILL.md +25 -0
- package/corpus/core/src/templates/workspace-core/src/server/index.ts +4 -2
- package/corpus/core/src/testing.ts +26 -0
- package/corpus/core/src/triggers/dispatcher.ts +23 -2
- package/corpus/core/src/vite/client.ts +135 -3
- package/corpus/core/tsconfig.cli.json +1 -1
- package/corpus/core/tsconfig.json +5 -1
- package/corpus/templates/analytics/.agents/skills/bigquery/SKILL.md +2 -2
- package/corpus/templates/analytics/.agents/skills/frontend-design/SKILL.md +1 -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 +15 -6
- package/corpus/templates/analytics/actions/install-dashboard-template.ts +79 -43
- package/corpus/templates/analytics/actions/list-explorer-dashboards.ts +3 -3
- package/corpus/templates/analytics/actions/list-sql-dashboards.ts +8 -3
- package/corpus/templates/analytics/actions/navigate.ts +59 -5
- package/corpus/templates/analytics/actions/rename-analysis.ts +8 -2
- package/corpus/templates/analytics/actions/rename-dashboard.ts +8 -7
- package/corpus/templates/analytics/actions/view-screen.ts +7 -29
- package/corpus/templates/analytics/app/components/ProviderCorpusJobNotifier.tsx +20 -3
- package/corpus/templates/analytics/app/components/ResourceLoadError.tsx +42 -0
- package/corpus/templates/analytics/app/components/dashboard/SqlChart.tsx +2 -1
- package/corpus/templates/analytics/app/components/layout/CommandPalette.tsx +85 -70
- package/corpus/templates/analytics/app/components/layout/Header.tsx +1 -1
- package/corpus/templates/analytics/app/components/layout/Sidebar.tsx +128 -95
- package/corpus/templates/analytics/app/components/layout/SidebarLoadError.tsx +24 -0
- package/corpus/templates/analytics/app/global.css +19 -20
- package/corpus/templates/analytics/app/hooks/use-dashboard-views.ts +15 -5
- package/corpus/templates/analytics/app/i18n/zh-TW.ts +4 -0
- package/corpus/templates/analytics/app/i18n-data.ts +40 -0
- package/corpus/templates/analytics/app/lib/provider-corpus-job-sync.ts +26 -0
- package/corpus/templates/analytics/app/pages/Settings.tsx +41 -343
- package/corpus/templates/analytics/app/pages/adhoc/explorer/components/SqlPreview.tsx +36 -20
- package/corpus/templates/analytics/app/pages/adhoc/explorer/index.tsx +34 -20
- package/corpus/templates/analytics/app/pages/adhoc/explorer/use-explorer-config.ts +42 -41
- package/corpus/templates/analytics/app/pages/adhoc/explorer-dashboard/index.tsx +43 -36
- package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/ViewsMenu.tsx +11 -2
- 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 +40 -8
- package/corpus/templates/analytics/app/routes/_index.tsx +14 -2
- 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-03-agent-llm-observability-dashboard.md +1 -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-agent-feedback-sentiment-dashboard.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-11-analytics-chats-now-start-faster-by-loading-metric-definitio.md +6 -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-command-and-sql-previews-now-respond-without-lag.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-11-command-search-now-reports-loading-failures-and-lets-you-ret.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-11-dashboard-navigation-now-loads-faster-and-reports-request-fa.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-11-inferred-message-sentiment-dashboard.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-11-microphone-settings-from-realtime-voice-mode-now-open-the-vo.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-11-more-dashboard-edit-paths-are-now-safe-against-simultaneous-.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-renaming-a-dashboard-is-now-safe-against-simultaneous-agent-.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-11-renaming-an-analysis-is-now-safe-against-simultaneous-edits.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-11-workspace-mounted-analytics-now-opens-ask-reliably-and-route.md +6 -0
- package/corpus/templates/analytics/docs/schemas/first-party-analytics.md +37 -3
- package/corpus/templates/analytics/package.json +1 -1
- package/corpus/templates/analytics/seeds/dashboards/agent-native-templates-first-party.json +37 -1
- package/corpus/templates/analytics/server/handlers/session-replay.ts +57 -0
- package/corpus/templates/analytics/server/lib/dashboard-catalog.ts +1 -24
- package/corpus/templates/analytics/server/lib/dashboard-seeds.ts +0 -5
- package/corpus/templates/analytics/server/lib/dashboards-store.ts +289 -20
- package/corpus/templates/analytics/server/lib/data-dictionary-context.ts +106 -34
- package/corpus/templates/analytics/server/lib/demo-dashboards.ts +20 -4
- 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/agent-chat.ts +11 -39
- 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/frontend-design/SKILL.md +1 -1
- package/corpus/templates/assets/.agents/skills/real-time-sync/SKILL.md +2 -2
- package/corpus/templates/assets/app/components/create/RecentDraftsSection.tsx +30 -4
- 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 +49 -6
- package/corpus/templates/assets/changelog/2026-07-11-library-load-failures-now-show-a-retry-action.md +6 -0
- package/corpus/templates/brain/.agents/skills/frontend-design/SKILL.md +1 -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/frontend-design/SKILL.md +1 -1
- package/corpus/templates/calendar/.agents/skills/real-time-sync/SKILL.md +2 -2
- package/corpus/templates/calendar/.env.example +5 -0
- package/corpus/templates/calendar/app/components/calendar/EventCard.tsx +2 -2
- package/corpus/templates/calendar/app/i18n/zh-TW.ts +2 -0
- package/corpus/templates/calendar/app/i18n-data.ts +20 -0
- package/corpus/templates/calendar/app/pages/BookingLinksPage.tsx +37 -1
- package/corpus/templates/calendar/app/pages/BookingsList.tsx +20 -3
- package/corpus/templates/calendar/app/root.tsx +1 -0
- package/corpus/templates/calendar/changelog/2026-07-11-booking-load-failures-now-show-a-retry-action.md +6 -0
- package/corpus/templates/calendar/changelog/2026-07-11-event-cards-give-subtle-press-feedback-and-smoother-hover.md +6 -0
- package/corpus/templates/chat/.agents/skills/frontend-design/SKILL.md +1 -1
- package/corpus/templates/chat/.agents/skills/real-time-sync/SKILL.md +2 -2
- package/corpus/templates/clips/.agents/skills/frontend-design/SKILL.md +1 -1
- package/corpus/templates/clips/actions/decline-invite.ts +8 -0
- package/corpus/templates/clips/app/components/library/folder-tree.tsx +209 -187
- package/corpus/templates/clips/app/components/meetings/meeting-card.tsx +2 -2
- package/corpus/templates/clips/app/components/player/reactions-tray.tsx +17 -5
- package/corpus/templates/clips/app/components/player/scrubber.tsx +5 -3
- package/corpus/templates/clips/app/components/recorder/pre-record-panel.tsx +2 -2
- package/corpus/templates/clips/app/components/workspace/insights-hub.tsx +119 -95
- package/corpus/templates/clips/app/global.css +45 -0
- 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/root.tsx +4 -0
- package/corpus/templates/clips/app/routes/_app.notifications.tsx +23 -2
- package/corpus/templates/clips/app/routes/_app.settings._index.tsx +20 -22
- package/corpus/templates/clips/app/routes/_app.trash.tsx +24 -2
- package/corpus/templates/clips/changelog/2026-07-11-controls-and-folders-now-move-more-smoothly.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-11-declining-an-invitation-now-requires-being-its-recipient.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-recording-overlays-are-lighter-weight-and-no-longer-cause-pa.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/clips/changelog/2026-07-11-workspace-load-failures-now-show-a-retry-action.md +6 -0
- package/corpus/templates/clips/chrome-extension/src/overlay.css +34 -5
- package/corpus/templates/clips/chrome-extension/src/styles.css +2 -2
- package/corpus/templates/clips/desktop/src/styles.css +71 -26
- package/corpus/templates/content/.agents/skills/frontend-design/SKILL.md +1 -1
- package/corpus/templates/content/.agents/skills/real-time-sync/SKILL.md +2 -2
- package/corpus/templates/content/actions/move-document.ts +34 -18
- package/corpus/templates/content/app/components/QueryErrorState.tsx +39 -0
- package/corpus/templates/content/app/components/editor/LinkHoverPreview.tsx +1 -1
- package/corpus/templates/content/app/components/editor/database/DatabaseView.tsx +225 -1435
- package/corpus/templates/content/app/components/editor/database/GalleryView.tsx +368 -0
- package/corpus/templates/content/app/components/editor/database/ListView.tsx +353 -0
- package/corpus/templates/content/app/components/editor/database/TimelineView.tsx +580 -0
- package/corpus/templates/content/app/components/sidebar/DocumentSidebar.tsx +11 -2
- package/corpus/templates/content/app/global.css +19 -19
- package/corpus/templates/content/app/hooks/use-comments.ts +0 -1
- package/corpus/templates/content/app/root.tsx +2 -2
- package/corpus/templates/content/app/routes/_app._index.tsx +11 -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-11-document-load-failures-now-show-a-retry-action.md +6 -0
- package/corpus/templates/content/changelog/2026-07-11-editor-toggle-feedback-now-feels-more-responsive.md +6 -0
- package/corpus/templates/content/changelog/2026-07-11-moving-documents-at-the-same-time-no-longer-scrambles-their-.md +6 -0
- package/corpus/templates/content/changelog/2026-07-11-public-document-chats-now-start-faster-while-keeping-full-do.md +6 -0
- package/corpus/templates/content/changelog/2026-07-11-reopening-a-comment-now-uses-consistent-permissions-everywhe.md +6 -0
- package/corpus/templates/content/changelog/2026-07-11-sidebar-resizing-now-tracks-your-cursor-instantly-instead-of.md +6 -0
- package/corpus/templates/content/server/lib/public-documents.ts +47 -10
- package/corpus/templates/content/server/routes/api/comments/[id].patch.ts +24 -24
- package/corpus/templates/design/.agents/skills/frontend-design/SKILL.md +1 -1
- package/corpus/templates/design/app/components/QueryErrorState.tsx +24 -0
- package/corpus/templates/design/app/components/design/CanvasContextMenu.tsx +1 -1
- package/corpus/templates/design/app/components/design/DesignImportPanel.tsx +5 -2
- package/corpus/templates/design/app/components/design/EditPanel.tsx +326 -319
- package/corpus/templates/design/app/components/design/LayersPanel.tsx +198 -193
- package/corpus/templates/design/app/components/design/edit-panel/panel-primitives.tsx +11 -4
- package/corpus/templates/design/app/components/design/inspector/DesignColorPicker.tsx +1 -1
- package/corpus/templates/design/app/components/layout/Header.tsx +1 -1
- package/corpus/templates/design/app/components/layout/Layout.tsx +1 -1
- package/corpus/templates/design/app/pages/DesignSystems.tsx +7 -1
- package/corpus/templates/design/app/pages/Index.tsx +14 -2
- package/corpus/templates/design/app/pages/Present.tsx +16 -3
- package/corpus/templates/design/app/pages/Templates.tsx +10 -4
- package/corpus/templates/design/app/pages/design-editor/canvas-primitive-insert.ts +484 -0
- package/corpus/templates/design/app/pages/design-editor/clone-and-pen-edit.ts +378 -0
- package/corpus/templates/design/app/pages/design-editor/design-data-geometry-utils.ts +138 -0
- package/corpus/templates/design/app/pages/design-editor/dom-utils.ts +15 -0
- package/corpus/templates/design/app/pages/design-editor/generation-prompt-directives.ts +180 -0
- package/corpus/templates/design/app/pages/design-editor/html-layer-positioning.ts +226 -0
- package/corpus/templates/design/app/pages/design-editor/png-export-render.ts +348 -0
- package/corpus/templates/design/app/pages/design-editor/screen-command-utils.ts +160 -0
- package/corpus/templates/design/app/pages/design-editor/text-edit-utils.ts +238 -0
- package/corpus/templates/design/app/pages/design-editor/tool-state.ts +23 -1
- package/corpus/templates/design/app/pages/design-editor/types.ts +25 -0
- package/corpus/templates/design/app/root.tsx +10 -1
- package/corpus/templates/design/changelog/2026-07-11-canvas-context-menus-now-open-without-motion-jitter.md +6 -0
- package/corpus/templates/design/changelog/2026-07-11-design-load-failures-now-show-a-retry-action.md +6 -0
- package/corpus/templates/design/changelog/2026-07-11-inspector-tooltips-appear-instantly-as-you-sweep-across-icon.md +6 -0
- package/corpus/templates/dispatch/.agents/skills/frontend-design/SKILL.md +1 -1
- package/corpus/templates/dispatch/app/i18n/zh-TW.ts +10 -0
- package/corpus/templates/dispatch/app/i18n-data.ts +123 -0
- package/corpus/templates/dispatch/app/routes/integrations.tsx +163 -144
- package/corpus/templates/dispatch/changelog/2026-07-11-dispatch-mcp-connections-now-start-with-safer-app-access-and.md +6 -0
- package/corpus/templates/dispatch/changelog/2026-07-11-overview-and-chat-now-share-a-cleaner-more-stable-flow.md +6 -0
- package/corpus/templates/dispatch/changelog/2026-07-11-query-errors-now-show-a-retry-option.md +6 -0
- package/corpus/templates/forms/.agents/skills/frontend-design/SKILL.md +1 -1
- package/corpus/templates/forms/.agents/skills/real-time-sync/SKILL.md +2 -2
- package/corpus/templates/forms/app/components/layout/Sidebar.tsx +3 -3
- package/corpus/templates/forms/app/root.tsx +34 -8
- package/corpus/templates/macros/.agents/skills/frontend-design/SKILL.md +1 -1
- package/corpus/templates/macros/app/components/DailyProgress.tsx +25 -5
- package/corpus/templates/macros/app/components/QueryErrorState.tsx +31 -0
- package/corpus/templates/macros/app/components/WeightTracker.tsx +5 -1
- package/corpus/templates/macros/app/components/layout/AppLayout.tsx +1 -2
- package/corpus/templates/macros/app/components/ui/button.tsx +1 -1
- package/corpus/templates/macros/app/components/ui/progress.tsx +1 -1
- package/corpus/templates/macros/app/components/ui/tabs.tsx +1 -1
- package/corpus/templates/macros/app/i18n/ar-SA.ts +2 -0
- package/corpus/templates/macros/app/i18n/de-DE.ts +2 -0
- package/corpus/templates/macros/app/i18n/en-US.ts +2 -0
- package/corpus/templates/macros/app/i18n/es-ES.ts +2 -0
- package/corpus/templates/macros/app/i18n/fr-FR.ts +2 -0
- package/corpus/templates/macros/app/i18n/hi-IN.ts +2 -0
- package/corpus/templates/macros/app/i18n/ja-JP.ts +2 -0
- package/corpus/templates/macros/app/i18n/ko-KR.ts +2 -0
- package/corpus/templates/macros/app/i18n/pt-BR.ts +2 -0
- package/corpus/templates/macros/app/i18n/zh-CN.ts +2 -0
- package/corpus/templates/macros/app/i18n/zh-TW.ts +2 -0
- package/corpus/templates/macros/app/root.tsx +0 -3
- package/corpus/templates/macros/app/routes/_index.tsx +22 -12
- package/corpus/templates/macros/app/routes/analytics.tsx +31 -10
- package/corpus/templates/macros/changelog/2026-07-11-daily-tracking-now-loads-and-updates-more-quickly.md +6 -0
- package/corpus/templates/macros/changelog/2026-07-11-data-load-failures-now-show-a-clear-error-with-a-retry-actio.md +6 -0
- package/corpus/templates/mail/.agents/skills/frontend-design/SKILL.md +1 -1
- package/corpus/templates/mail/.agents/skills/real-time-sync/SKILL.md +2 -2
- package/corpus/templates/mail/.env.example +16 -11
- package/corpus/templates/mail/actions/list-emails.ts +39 -35
- package/corpus/templates/mail/app/components/email/ComposeModal.tsx +58 -6
- package/corpus/templates/mail/app/components/email/EmailListItem.tsx +35 -2
- package/corpus/templates/mail/app/components/layout/AppLayout.tsx +113 -104
- package/corpus/templates/mail/app/hooks/use-compose-state.ts +1 -0
- package/corpus/templates/mail/app/root.tsx +9 -22
- package/corpus/templates/mail/changelog/2026-07-11-compose-and-navigation-motion-now-feel-faster-and-smoother.md +6 -0
- package/corpus/templates/mail/changelog/2026-07-11-swipe-to-archive-or-snooze-now-responds-to-quick-flicks-not-.md +6 -0
- package/corpus/templates/mail/changelog/2026-07-11-the-assistant-now-sees-the-same-inbox-you-do-snoozed-mail-st.md +6 -0
- package/corpus/templates/mail/server/handlers/emails.ts +25 -69
- package/corpus/templates/mail/server/lib/list-inbox-emails.ts +169 -0
- package/corpus/templates/plan/.agents/skills/frontend-design/SKILL.md +1 -1
- package/corpus/templates/plan/.agents/skills/real-time-sync/SKILL.md +2 -2
- package/corpus/templates/plan/.env.example +4 -0
- package/corpus/templates/plan/actions/create-plan-design.ts +89 -81
- package/corpus/templates/plan/actions/create-prototype-plan.ts +72 -59
- package/corpus/templates/plan/actions/create-ui-plan.ts +70 -55
- package/corpus/templates/plan/actions/create-visual-plan.ts +65 -51
- package/corpus/templates/plan/actions/update-local-plan-folder.ts +43 -30
- package/corpus/templates/plan/actions/update-visual-plan.ts +81 -64
- package/corpus/templates/plan/app/components/layout/Sidebar.tsx +17 -0
- package/corpus/templates/plan/app/components/ui/tabs.tsx +1 -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/i18n/ar-SA.ts +10 -0
- package/corpus/templates/plan/app/i18n/de-DE.ts +10 -0
- package/corpus/templates/plan/app/i18n/en-US.ts +10 -0
- package/corpus/templates/plan/app/i18n/es-ES.ts +10 -0
- package/corpus/templates/plan/app/i18n/fr-FR.ts +10 -0
- package/corpus/templates/plan/app/i18n/hi-IN.ts +10 -0
- package/corpus/templates/plan/app/i18n/ja-JP.ts +10 -0
- package/corpus/templates/plan/app/i18n/ko-KR.ts +10 -0
- package/corpus/templates/plan/app/i18n/pt-BR.ts +10 -0
- package/corpus/templates/plan/app/i18n/zh-CN.ts +10 -0
- package/corpus/templates/plan/app/i18n/zh-TW.ts +10 -0
- package/corpus/templates/plan/app/lib/plan-local-bridge.ts +80 -1
- package/corpus/templates/plan/app/pages/PlansPage.tsx +157 -31
- package/corpus/templates/plan/app/root.tsx +11 -0
- package/corpus/templates/plan/changelog/2026-07-11-local-plans-now-explain-and-recover-from-browser-permission-.md +6 -0
- package/corpus/templates/plan/changelog/2026-07-11-plan-edits-now-save-atomically-and-can-no-longer-partially-a.md +6 -0
- package/corpus/templates/plan/changelog/2026-07-11-plan-lists-now-show-a-clear-error-with-a-retry-action-when-t.md +6 -0
- package/corpus/templates/plan/changelog/2026-07-11-plan-refreshes-only-when-content-changes.md +6 -0
- package/corpus/templates/plan/shared/plan-content.ts +546 -260
- package/corpus/templates/slides/.agents/skills/frontend-design/SKILL.md +1 -1
- package/corpus/templates/slides/actions/delete-slide-comment.ts +49 -0
- package/corpus/templates/slides/actions/update-slide-comment.ts +93 -0
- package/corpus/templates/slides/actions/view-screen.ts +14 -6
- package/corpus/templates/slides/app/components/comments/SlideCommentsPanel.tsx +37 -11
- package/corpus/templates/slides/app/components/editor/EditorSidebar.tsx +1 -1
- package/corpus/templates/slides/app/components/editor/EditorToolbar.tsx +2 -2
- package/corpus/templates/slides/app/components/editor/GenerateSlidesDialog.tsx +2 -2
- package/corpus/templates/slides/app/components/layout/Header.tsx +1 -1
- package/corpus/templates/slides/app/components/presentation/PresentationView.tsx +4 -2
- package/corpus/templates/slides/app/components/visual-editor/CanvasCommentPins.tsx +4 -3
- package/corpus/templates/slides/app/context/DeckContext.tsx +10 -0
- package/corpus/templates/slides/app/hooks/use-slide-comments.ts +7 -31
- package/corpus/templates/slides/app/i18n/ar-SA.ts +6 -0
- package/corpus/templates/slides/app/i18n/de-DE.ts +6 -0
- package/corpus/templates/slides/app/i18n/en-US.ts +6 -0
- package/corpus/templates/slides/app/i18n/es-ES.ts +6 -0
- package/corpus/templates/slides/app/i18n/fr-FR.ts +6 -0
- package/corpus/templates/slides/app/i18n/hi-IN.ts +6 -0
- package/corpus/templates/slides/app/i18n/ja-JP.ts +6 -0
- package/corpus/templates/slides/app/i18n/ko-KR.ts +6 -0
- package/corpus/templates/slides/app/i18n/pt-BR.ts +6 -0
- package/corpus/templates/slides/app/i18n/zh-CN.ts +5 -0
- package/corpus/templates/slides/app/i18n/zh-TW.ts +5 -0
- package/corpus/templates/slides/app/pages/DesignSystems.tsx +23 -2
- package/corpus/templates/slides/app/pages/Index.tsx +29 -1
- package/corpus/templates/slides/changelog/2026-07-11-comment-load-failures-now-show-a-retry-action-instead-of-say.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-11-comment-pins-now-clear-with-a-faster-smoother-confirmation.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-11-comments-now-update-from-live-collaboration-events-without-c.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-11-deck-and-design-system-load-failures-now-show-a-retry-action.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-11-editor-toggles-and-toolbar-menus-now-animate-smoothly.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-11-the-assistant-can-now-resolve-reopen-and-delete-slide-commen.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-11-viewing-slides-no-longer-loads-every-deck-s-full-contents-in.md +6 -0
- package/corpus/templates/slides/server/routes/api/comments/[id].delete.ts +29 -48
- package/corpus/templates/slides/server/routes/api/comments/[id].patch.ts +29 -65
- 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/action.d.ts +23 -0
- package/dist/action.d.ts.map +1 -1
- package/dist/action.js +13 -0
- package/dist/action.js.map +1 -1
- package/dist/agent/engine/builder-engine.d.ts.map +1 -1
- package/dist/agent/engine/builder-engine.js +3 -0
- package/dist/agent/engine/builder-engine.js.map +1 -1
- package/dist/agent/engine/context-directives-transform.d.ts +25 -0
- package/dist/agent/engine/context-directives-transform.d.ts.map +1 -0
- package/dist/agent/engine/context-directives-transform.js +53 -0
- package/dist/agent/engine/context-directives-transform.js.map +1 -0
- package/dist/agent/engine/continuation-dispatch-retry.d.ts +40 -0
- package/dist/agent/engine/continuation-dispatch-retry.d.ts.map +1 -0
- package/dist/agent/engine/continuation-dispatch-retry.js +109 -0
- package/dist/agent/engine/continuation-dispatch-retry.js.map +1 -0
- package/dist/agent/engine/tool-call-journal-seed.d.ts +46 -0
- package/dist/agent/engine/tool-call-journal-seed.d.ts.map +1 -0
- package/dist/agent/engine/tool-call-journal-seed.js +60 -0
- package/dist/agent/engine/tool-call-journal-seed.js.map +1 -0
- package/dist/agent/production-agent.d.ts +7 -0
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +102 -222
- package/dist/agent/production-agent.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/doctor.d.ts.map +1 -1
- package/dist/cli/doctor.js +7 -3
- package/dist/cli/doctor.js.map +1 -1
- package/dist/cli/plan-local.d.ts.map +1 -1
- package/dist/cli/plan-local.js +8 -2
- package/dist/cli/plan-local.js.map +1 -1
- package/dist/cli/skills-content/assets-skill.d.ts +2 -0
- package/dist/cli/skills-content/assets-skill.d.ts.map +1 -0
- package/dist/cli/skills-content/assets-skill.js +84 -0
- package/dist/cli/skills-content/assets-skill.js.map +1 -0
- package/dist/cli/skills-content/canvas.d.ts +4 -0
- package/dist/cli/skills-content/canvas.d.ts.map +1 -0
- package/dist/cli/skills-content/canvas.js +152 -0
- package/dist/cli/skills-content/canvas.js.map +1 -0
- package/dist/cli/skills-content/connection.d.ts +2 -0
- package/dist/cli/skills-content/connection.d.ts.map +1 -0
- package/dist/cli/skills-content/connection.js +53 -0
- package/dist/cli/skills-content/connection.js.map +1 -0
- package/dist/cli/skills-content/content-skill.d.ts +2 -0
- package/dist/cli/skills-content/content-skill.d.ts.map +1 -0
- package/dist/cli/skills-content/content-skill.js +110 -0
- package/dist/cli/skills-content/content-skill.js.map +1 -0
- package/dist/cli/skills-content/design-exploration-skill.d.ts +2 -0
- package/dist/cli/skills-content/design-exploration-skill.d.ts.map +1 -0
- package/dist/cli/skills-content/design-exploration-skill.js +119 -0
- package/dist/cli/skills-content/design-exploration-skill.js.map +1 -0
- package/dist/cli/skills-content/design-visual-edit-skill.d.ts +2 -0
- package/dist/cli/skills-content/design-visual-edit-skill.d.ts.map +1 -0
- package/dist/cli/skills-content/design-visual-edit-skill.js +229 -0
- package/dist/cli/skills-content/design-visual-edit-skill.js.map +1 -0
- package/dist/cli/skills-content/document-quality.d.ts +4 -0
- package/dist/cli/skills-content/document-quality.d.ts.map +1 -0
- package/dist/cli/skills-content/document-quality.js +195 -0
- package/dist/cli/skills-content/document-quality.js.map +1 -0
- package/dist/cli/skills-content/exemplar.d.ts +4 -0
- package/dist/cli/skills-content/exemplar.d.ts.map +1 -0
- package/dist/cli/skills-content/exemplar.js +68 -0
- package/dist/cli/skills-content/exemplar.js.map +1 -0
- package/dist/cli/skills-content/help.d.ts +2 -0
- package/dist/cli/skills-content/help.d.ts.map +1 -0
- package/dist/cli/skills-content/help.js +78 -0
- package/dist/cli/skills-content/help.js.map +1 -0
- package/dist/cli/skills-content/index.d.ts +23 -0
- package/dist/cli/skills-content/index.d.ts.map +1 -0
- package/dist/cli/skills-content/index.js +23 -0
- package/dist/cli/skills-content/index.js.map +1 -0
- package/dist/cli/skills-content/local-files.d.ts +2 -0
- package/dist/cli/skills-content/local-files.d.ts.map +1 -0
- package/dist/cli/skills-content/local-files.js +96 -0
- package/dist/cli/skills-content/local-files.js.map +1 -0
- package/dist/cli/skills-content/plan-setup-auth.d.ts +9 -0
- package/dist/cli/skills-content/plan-setup-auth.d.ts.map +1 -0
- package/dist/cli/skills-content/plan-setup-auth.js +81 -0
- package/dist/cli/skills-content/plan-setup-auth.js.map +1 -0
- package/dist/cli/skills-content/visual-plan-skill.d.ts +2 -0
- package/dist/cli/skills-content/visual-plan-skill.d.ts.map +1 -0
- package/dist/cli/skills-content/visual-plan-skill.js +471 -0
- package/dist/cli/skills-content/visual-plan-skill.js.map +1 -0
- package/dist/cli/skills-content/visual-recap-skill.d.ts +2 -0
- package/dist/cli/skills-content/visual-recap-skill.d.ts.map +1 -0
- package/dist/cli/skills-content/visual-recap-skill.js +548 -0
- package/dist/cli/skills-content/visual-recap-skill.js.map +1 -0
- package/dist/cli/skills-content/visualize-repo-skill.d.ts +2 -0
- package/dist/cli/skills-content/visualize-repo-skill.d.ts.map +1 -0
- package/dist/cli/skills-content/visualize-repo-skill.js +94 -0
- package/dist/cli/skills-content/visualize-repo-skill.js.map +1 -0
- package/dist/cli/skills-content/wireframe.d.ts +4 -0
- package/dist/cli/skills-content/wireframe.d.ts.map +1 -0
- package/dist/cli/skills-content/wireframe.js +347 -0
- package/dist/cli/skills-content/wireframe.js.map +1 -0
- package/dist/cli/skills.d.ts +2 -10
- package/dist/cli/skills.d.ts.map +1 -1
- package/dist/cli/skills.js +2 -2710
- package/dist/cli/skills.js.map +1 -1
- package/dist/client/AgentPanel.d.ts.map +1 -1
- package/dist/client/AgentPanel.js +6 -5
- 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/CommandMenu.d.ts.map +1 -1
- package/dist/client/CommandMenu.js +15 -3
- package/dist/client/CommandMenu.js.map +1 -1
- package/dist/client/FeedbackButton.js +2 -2
- package/dist/client/FeedbackButton.js.map +1 -1
- package/dist/client/analytics.d.ts.map +1 -1
- package/dist/client/analytics.js +26 -0
- package/dist/client/analytics.js.map +1 -1
- package/dist/client/app-providers.d.ts +13 -5
- package/dist/client/app-providers.d.ts.map +1 -1
- package/dist/client/app-providers.js +9 -6
- package/dist/client/app-providers.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/tool-call-display.d.ts +4 -0
- package/dist/client/chat/tool-call-display.d.ts.map +1 -1
- package/dist/client/chat/tool-call-display.js +3 -3
- package/dist/client/chat/tool-call-display.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/PastedTextChip.js +1 -1
- package/dist/client/composer/PastedTextChip.js.map +1 -1
- package/dist/client/composer/RealtimeVoiceMode.d.ts +40 -2
- package/dist/client/composer/RealtimeVoiceMode.d.ts.map +1 -1
- package/dist/client/composer/RealtimeVoiceMode.js +186 -35
- 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 +48 -30
- package/dist/client/composer/TiptapComposer.js.map +1 -1
- package/dist/client/composer/VoiceButton.d.ts +2 -0
- package/dist/client/composer/VoiceButton.d.ts.map +1 -1
- package/dist/client/composer/VoiceButton.js +9 -3
- 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 +104 -2
- package/dist/client/composer/useRealtimeVoiceMode.d.ts.map +1 -1
- package/dist/client/composer/useRealtimeVoiceMode.js +1015 -35
- package/dist/client/composer/useRealtimeVoiceMode.js.map +1 -1
- package/dist/client/context-xray/ContextXRayPanel.d.ts.map +1 -1
- package/dist/client/context-xray/ContextXRayPanel.js +4 -1
- package/dist/client/context-xray/ContextXRayPanel.js.map +1 -1
- package/dist/client/extensions/ExtensionEditor.d.ts.map +1 -1
- package/dist/client/extensions/ExtensionEditor.js +15 -5
- package/dist/client/extensions/ExtensionEditor.js.map +1 -1
- package/dist/client/extensions/ExtensionQueryErrorState.d.ts +8 -0
- package/dist/client/extensions/ExtensionQueryErrorState.d.ts.map +1 -0
- package/dist/client/extensions/ExtensionQueryErrorState.js +11 -0
- package/dist/client/extensions/ExtensionQueryErrorState.js.map +1 -0
- package/dist/client/extensions/ExtensionSlot.d.ts.map +1 -1
- package/dist/client/extensions/ExtensionSlot.js +17 -7
- package/dist/client/extensions/ExtensionSlot.js.map +1 -1
- package/dist/client/extensions/ExtensionViewer.d.ts.map +1 -1
- package/dist/client/extensions/ExtensionViewer.js +17 -7
- package/dist/client/extensions/ExtensionViewer.js.map +1 -1
- package/dist/client/extensions/ExtensionsListPage.d.ts.map +1 -1
- package/dist/client/extensions/ExtensionsListPage.js +5 -3
- package/dist/client/extensions/ExtensionsListPage.js.map +1 -1
- package/dist/client/extensions/ExtensionsSidebarSection.d.ts.map +1 -1
- package/dist/client/extensions/ExtensionsSidebarSection.js +21 -8
- package/dist/client/extensions/ExtensionsSidebarSection.js.map +1 -1
- package/dist/client/index.d.ts +1 -3
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +1 -6
- package/dist/client/index.js.map +1 -1
- package/dist/client/progress/RunsTray.d.ts.map +1 -1
- package/dist/client/progress/RunsTray.js +17 -4
- package/dist/client/progress/RunsTray.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/settings/SettingsTabsPage.d.ts.map +1 -1
- package/dist/client/settings/SettingsTabsPage.js +4 -0
- package/dist/client/settings/SettingsTabsPage.js.map +1 -1
- package/dist/client/settings/useBuilderStatus.d.ts +2 -0
- package/dist/client/settings/useBuilderStatus.d.ts.map +1 -1
- package/dist/client/settings/useBuilderStatus.js +4 -0
- package/dist/client/settings/useBuilderStatus.js.map +1 -1
- package/dist/client/tool-cells/EditCell.d.ts.map +1 -1
- package/dist/client/tool-cells/EditCell.js +2 -1
- package/dist/client/tool-cells/EditCell.js.map +1 -1
- package/dist/client/tool-cells/FilesChangedSummary.d.ts.map +1 -1
- package/dist/client/tool-cells/FilesChangedSummary.js +2 -1
- package/dist/client/tool-cells/FilesChangedSummary.js.map +1 -1
- package/dist/client/tool-cells/WriteCell.d.ts.map +1 -1
- package/dist/client/tool-cells/WriteCell.js +2 -1
- package/dist/client/tool-cells/WriteCell.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-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/client/visual-style-controls.js +1 -1
- package/dist/client/visual-style-controls.js.map +1 -1
- package/dist/collab/routes.d.ts +1 -1
- package/dist/deploy/build.d.ts.map +1 -1
- package/dist/deploy/build.js +36 -14
- package/dist/deploy/build.js.map +1 -1
- package/dist/integrations/google-docs-poller.d.ts +7 -0
- package/dist/integrations/google-docs-poller.d.ts.map +1 -1
- package/dist/integrations/google-docs-poller.js +13 -3
- package/dist/integrations/google-docs-poller.js.map +1 -1
- package/dist/integrations/plugin.d.ts.map +1 -1
- package/dist/integrations/plugin.js +10 -0
- package/dist/integrations/plugin.js.map +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/integrations/webhook-handler.d.ts +11 -0
- package/dist/integrations/webhook-handler.d.ts.map +1 -1
- package/dist/integrations/webhook-handler.js +16 -4
- package/dist/integrations/webhook-handler.js.map +1 -1
- package/dist/jobs/scheduler.d.ts +12 -0
- package/dist/jobs/scheduler.d.ts.map +1 -1
- package/dist/jobs/scheduler.js +13 -3
- package/dist/jobs/scheduler.js.map +1 -1
- package/dist/localization/default-messages.d.ts +47 -0
- package/dist/localization/default-messages.d.ts.map +1 -1
- package/dist/localization/default-messages.js +48 -1
- package/dist/localization/default-messages.js.map +1 -1
- package/dist/mcp/oauth-token.d.ts +1 -1
- package/dist/mcp/oauth-token.d.ts.map +1 -1
- package/dist/mcp/oauth-token.js +6 -1
- package/dist/mcp/oauth-token.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 +2 -2
- package/dist/observability/routes.d.ts +5 -5
- package/dist/observability/routes.d.ts.map +1 -1
- package/dist/observability/routes.js +32 -0
- package/dist/observability/routes.js.map +1 -1
- package/dist/observability/sentiment.d.ts +42 -0
- package/dist/observability/sentiment.d.ts.map +1 -0
- package/dist/observability/sentiment.js +196 -0
- package/dist/observability/sentiment.js.map +1 -0
- package/dist/observability/store.d.ts +5 -0
- package/dist/observability/store.d.ts.map +1 -1
- package/dist/observability/store.js +17 -0
- package/dist/observability/store.js.map +1 -1
- package/dist/observability/traces.d.ts +2 -0
- package/dist/observability/traces.d.ts.map +1 -1
- package/dist/observability/traces.js +42 -57
- package/dist/observability/traces.js.map +1 -1
- package/dist/observability/tracking-identity.d.ts +3 -0
- package/dist/observability/tracking-identity.d.ts.map +1 -0
- package/dist/observability/tracking-identity.js +51 -0
- package/dist/observability/tracking-identity.js.map +1 -0
- package/dist/observability/types.d.ts +10 -0
- package/dist/observability/types.d.ts.map +1 -1
- package/dist/observability/types.js +3 -0
- package/dist/observability/types.js.map +1 -1
- package/dist/progress/routes.d.ts +1 -1
- package/dist/resources/handlers.d.ts +1 -1
- 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/secrets/routes.d.ts +9 -9
- package/dist/secrets/storage.d.ts +6 -0
- package/dist/secrets/storage.d.ts.map +1 -1
- package/dist/secrets/storage.js +61 -3
- package/dist/secrets/storage.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-chat/action-filters-a2a.d.ts +50 -0
- package/dist/server/agent-chat/action-filters-a2a.d.ts.map +1 -0
- package/dist/server/agent-chat/action-filters-a2a.js +127 -0
- package/dist/server/agent-chat/action-filters-a2a.js.map +1 -0
- package/dist/server/agent-chat/browser-team-tools.d.ts +21 -0
- package/dist/server/agent-chat/browser-team-tools.d.ts.map +1 -0
- package/dist/server/agent-chat/browser-team-tools.js +417 -0
- package/dist/server/agent-chat/browser-team-tools.js.map +1 -0
- package/dist/server/agent-chat/context-tools.d.ts +33 -0
- package/dist/server/agent-chat/context-tools.d.ts.map +1 -0
- package/dist/server/agent-chat/context-tools.js +520 -0
- package/dist/server/agent-chat/context-tools.js.map +1 -0
- package/dist/server/agent-chat/framework-prompts.d.ts +65 -0
- package/dist/server/agent-chat/framework-prompts.d.ts.map +1 -0
- package/dist/server/agent-chat/framework-prompts.js +403 -0
- package/dist/server/agent-chat/framework-prompts.js.map +1 -0
- package/dist/server/agent-chat/lazy-fs.d.ts +2 -0
- package/dist/server/agent-chat/lazy-fs.d.ts.map +1 -0
- package/dist/server/agent-chat/lazy-fs.js +11 -0
- package/dist/server/agent-chat/lazy-fs.js.map +1 -0
- package/dist/server/agent-chat/mcp-glue.d.ts +9 -0
- package/dist/server/agent-chat/mcp-glue.d.ts.map +1 -0
- package/dist/server/agent-chat/mcp-glue.js +63 -0
- package/dist/server/agent-chat/mcp-glue.js.map +1 -0
- package/dist/server/agent-chat/plugin-options.d.ts +322 -0
- package/dist/server/agent-chat/plugin-options.d.ts.map +1 -0
- package/dist/server/agent-chat/plugin-options.js +2 -0
- package/dist/server/agent-chat/plugin-options.js.map +1 -0
- package/dist/server/agent-chat/process-run-failure.d.ts +12 -0
- package/dist/server/agent-chat/process-run-failure.d.ts.map +1 -0
- package/dist/server/agent-chat/process-run-failure.js +24 -0
- package/dist/server/agent-chat/process-run-failure.js.map +1 -0
- package/dist/server/agent-chat/prompt-resources.d.ts +28 -0
- package/dist/server/agent-chat/prompt-resources.d.ts.map +1 -0
- package/dist/server/agent-chat/prompt-resources.js +514 -0
- package/dist/server/agent-chat/prompt-resources.js.map +1 -0
- package/dist/server/agent-chat/recurring-jobs-runtime.d.ts +5 -0
- package/dist/server/agent-chat/recurring-jobs-runtime.d.ts.map +1 -0
- package/dist/server/agent-chat/recurring-jobs-runtime.js +53 -0
- package/dist/server/agent-chat/recurring-jobs-runtime.js.map +1 -0
- package/dist/server/agent-chat/request-surface.d.ts +8 -0
- package/dist/server/agent-chat/request-surface.d.ts.map +1 -0
- package/dist/server/agent-chat/request-surface.js +56 -0
- package/dist/server/agent-chat/request-surface.js.map +1 -0
- package/dist/server/agent-chat/run-code-tools.d.ts +17 -0
- package/dist/server/agent-chat/run-code-tools.d.ts.map +1 -0
- package/dist/server/agent-chat/run-code-tools.js +55 -0
- package/dist/server/agent-chat/run-code-tools.js.map +1 -0
- package/dist/server/agent-chat/script-entries.d.ts +47 -0
- package/dist/server/agent-chat/script-entries.d.ts.map +1 -0
- package/dist/server/agent-chat/script-entries.js +633 -0
- package/dist/server/agent-chat/script-entries.js.map +1 -0
- package/dist/server/agent-chat/shared-thread.d.ts +33 -0
- package/dist/server/agent-chat/shared-thread.d.ts.map +1 -0
- package/dist/server/agent-chat/shared-thread.js +242 -0
- package/dist/server/agent-chat/shared-thread.js.map +1 -0
- package/dist/server/agent-chat/skill-frontmatter.d.ts +7 -0
- package/dist/server/agent-chat/skill-frontmatter.d.ts.map +1 -0
- package/dist/server/agent-chat/skill-frontmatter.js +26 -0
- package/dist/server/agent-chat/skill-frontmatter.js.map +1 -0
- package/dist/server/agent-chat-plugin.d.ts +45 -486
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +173 -3005
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/server/agent-teams.d.ts +10 -0
- package/dist/server/agent-teams.d.ts.map +1 -1
- package/dist/server/agent-teams.js +13 -3
- package/dist/server/agent-teams.js.map +1 -1
- package/dist/server/auth.d.ts.map +1 -1
- package/dist/server/auth.js +50 -52
- package/dist/server/auth.js.map +1 -1
- package/dist/server/credential-provider.d.ts.map +1 -1
- package/dist/server/credential-provider.js +22 -21
- package/dist/server/credential-provider.js.map +1 -1
- package/dist/server/edge.d.ts +1 -0
- package/dist/server/edge.d.ts.map +1 -1
- package/dist/server/edge.js +1 -0
- package/dist/server/edge.js.map +1 -1
- package/dist/server/onboarding-html.d.ts.map +1 -1
- package/dist/server/onboarding-html.js +1 -16
- package/dist/server/onboarding-html.js.map +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 +10 -0
- package/dist/server/realtime-voice.d.ts.map +1 -1
- package/dist/server/realtime-voice.js +249 -15
- package/dist/server/realtime-voice.js.map +1 -1
- package/dist/server/request-origin.d.ts.map +1 -1
- package/dist/server/request-origin.js +6 -3
- package/dist/server/request-origin.js.map +1 -1
- package/dist/server/ssr-handler.d.ts.map +1 -1
- package/dist/server/ssr-handler.js +47 -2
- package/dist/server/ssr-handler.js.map +1 -1
- package/dist/sharing/access.d.ts +63 -3
- package/dist/sharing/access.d.ts.map +1 -1
- package/dist/sharing/access.js +53 -15
- package/dist/sharing/access.js.map +1 -1
- package/dist/sharing/registry.d.ts +7 -0
- package/dist/sharing/registry.d.ts.map +1 -1
- package/dist/sharing/registry.js.map +1 -1
- package/dist/styles/agent-native.css +17 -16
- package/dist/templates/default/.agents/skills/frontend-design/SKILL.md +1 -1
- package/dist/templates/default/.agents/skills/real-time-sync/SKILL.md +2 -2
- package/dist/templates/default/app/i18n/ar-SA.ts +6 -0
- package/dist/templates/default/app/i18n/de-DE.ts +6 -0
- package/dist/templates/default/app/i18n/en-US.ts +6 -0
- package/dist/templates/default/app/i18n/es-ES.ts +6 -0
- package/dist/templates/default/app/i18n/fr-FR.ts +6 -0
- package/dist/templates/default/app/i18n/hi-IN.ts +6 -0
- package/dist/templates/default/app/i18n/ja-JP.ts +6 -0
- package/dist/templates/default/app/i18n/ko-KR.ts +6 -0
- package/dist/templates/default/app/i18n/pt-BR.ts +6 -0
- package/dist/templates/default/app/i18n/zh-CN.ts +6 -0
- package/dist/templates/default/app/i18n/zh-TW.ts +6 -0
- package/dist/templates/workspace-core/.agents/skills/authentication/SKILL.md +27 -29
- package/dist/templates/workspace-core/.agents/skills/external-agents/SKILL.md +2 -1
- package/dist/templates/workspace-core/.agents/skills/frontend-design/SKILL.md +1 -1
- package/dist/templates/workspace-core/.agents/skills/observability/SKILL.md +32 -0
- 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/templates/workspace-core/.agents/skills/writing-agent-instructions/SKILL.md +25 -0
- package/dist/templates/workspace-core/src/server/index.ts +4 -2
- package/dist/testing.d.ts +16 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +16 -0
- package/dist/testing.js.map +1 -0
- package/dist/triggers/dispatcher.d.ts +7 -0
- package/dist/triggers/dispatcher.d.ts.map +1 -1
- package/dist/triggers/dispatcher.js +13 -3
- package/dist/triggers/dispatcher.js.map +1 -1
- package/dist/vite/client.d.ts +16 -1
- package/dist/vite/client.d.ts.map +1 -1
- package/dist/vite/client.js +111 -3
- package/dist/vite/client.js.map +1 -1
- package/docs/content/authentication.mdx +3 -3
- package/docs/content/doctor.mdx +170 -0
- package/docs/content/external-agents.mdx +8 -7
- package/docs/content/locales/ar-SA/authentication.mdx +2 -2
- package/docs/content/locales/ar-SA/external-agents.mdx +8 -7
- package/docs/content/locales/ar-SA/mcp-protocol.mdx +1 -1
- package/docs/content/locales/ar-SA/security.mdx +2 -0
- package/docs/content/locales/de-DE/authentication.mdx +1 -1
- package/docs/content/locales/de-DE/external-agents.mdx +8 -7
- package/docs/content/locales/de-DE/mcp-protocol.mdx +1 -1
- package/docs/content/locales/de-DE/security.mdx +2 -0
- package/docs/content/locales/es-ES/authentication.mdx +2 -2
- package/docs/content/locales/es-ES/external-agents.mdx +8 -7
- package/docs/content/locales/es-ES/mcp-protocol.mdx +1 -1
- package/docs/content/locales/es-ES/security.mdx +2 -0
- package/docs/content/locales/fr-FR/authentication.mdx +1 -1
- package/docs/content/locales/fr-FR/external-agents.mdx +8 -7
- package/docs/content/locales/fr-FR/mcp-protocol.mdx +1 -1
- package/docs/content/locales/fr-FR/security.mdx +2 -0
- package/docs/content/locales/hi-IN/authentication.mdx +2 -2
- package/docs/content/locales/hi-IN/external-agents.mdx +8 -7
- package/docs/content/locales/hi-IN/mcp-protocol.mdx +1 -1
- package/docs/content/locales/hi-IN/security.mdx +2 -0
- package/docs/content/locales/ja-JP/authentication.mdx +2 -2
- package/docs/content/locales/ja-JP/external-agents.mdx +8 -7
- package/docs/content/locales/ja-JP/mcp-protocol.mdx +1 -1
- package/docs/content/locales/ja-JP/security.mdx +2 -0
- package/docs/content/locales/ko-KR/authentication.mdx +2 -2
- package/docs/content/locales/ko-KR/external-agents.mdx +8 -7
- package/docs/content/locales/ko-KR/mcp-protocol.mdx +1 -1
- package/docs/content/locales/ko-KR/security.mdx +2 -0
- package/docs/content/locales/pt-BR/authentication.mdx +2 -2
- package/docs/content/locales/pt-BR/external-agents.mdx +8 -7
- package/docs/content/locales/pt-BR/mcp-protocol.mdx +1 -1
- package/docs/content/locales/pt-BR/security.mdx +2 -0
- package/docs/content/locales/zh-CN/authentication.mdx +2 -2
- package/docs/content/locales/zh-CN/external-agents.mdx +8 -7
- package/docs/content/locales/zh-CN/mcp-protocol.mdx +1 -1
- package/docs/content/locales/zh-CN/security.mdx +2 -0
- package/docs/content/locales/zh-TW/authentication.mdx +2 -2
- package/docs/content/locales/zh-TW/external-agents.mdx +8 -7
- package/docs/content/locales/zh-TW/mcp-protocol.mdx +1 -1
- package/docs/content/locales/zh-TW/security.mdx +2 -0
- package/docs/content/mcp-protocol.mdx +1 -1
- package/docs/content/security.mdx +2 -0
- package/package.json +7 -3
- package/src/templates/default/.agents/skills/frontend-design/SKILL.md +1 -1
- package/src/templates/default/.agents/skills/real-time-sync/SKILL.md +2 -2
- package/src/templates/default/app/i18n/ar-SA.ts +6 -0
- package/src/templates/default/app/i18n/de-DE.ts +6 -0
- package/src/templates/default/app/i18n/en-US.ts +6 -0
- package/src/templates/default/app/i18n/es-ES.ts +6 -0
- package/src/templates/default/app/i18n/fr-FR.ts +6 -0
- package/src/templates/default/app/i18n/hi-IN.ts +6 -0
- package/src/templates/default/app/i18n/ja-JP.ts +6 -0
- package/src/templates/default/app/i18n/ko-KR.ts +6 -0
- package/src/templates/default/app/i18n/pt-BR.ts +6 -0
- package/src/templates/default/app/i18n/zh-CN.ts +6 -0
- package/src/templates/default/app/i18n/zh-TW.ts +6 -0
- package/src/templates/workspace-core/.agents/skills/authentication/SKILL.md +27 -29
- package/src/templates/workspace-core/.agents/skills/external-agents/SKILL.md +2 -1
- package/src/templates/workspace-core/.agents/skills/frontend-design/SKILL.md +1 -1
- package/src/templates/workspace-core/.agents/skills/observability/SKILL.md +32 -0
- 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
- package/src/templates/workspace-core/.agents/skills/writing-agent-instructions/SKILL.md +25 -0
- package/src/templates/workspace-core/src/server/index.ts +4 -2
- package/corpus/core/src/client/ProductionAgentPanel.tsx +0 -9
- package/corpus/core/src/client/auth-redirect-url.ts +0 -23
- package/corpus/core/src/client/useProductionAgent.ts +0 -253
- package/corpus/core/src/shared/auth-redirect-url.ts +0 -1
- package/corpus/templates/analytics/app/pages/Index.tsx +0 -16
- package/corpus/templates/analytics/seeds/dashboards/agent-observability-llm.json +0 -173
- package/dist/client/ProductionAgentPanel.d.ts +0 -6
- package/dist/client/ProductionAgentPanel.d.ts.map +0 -1
- package/dist/client/ProductionAgentPanel.js +0 -6
- package/dist/client/ProductionAgentPanel.js.map +0 -1
- package/dist/client/auth-redirect-url.d.ts +0 -2
- package/dist/client/auth-redirect-url.d.ts.map +0 -1
- package/dist/client/auth-redirect-url.js +0 -19
- package/dist/client/auth-redirect-url.js.map +0 -1
- package/dist/client/useProductionAgent.d.ts +0 -24
- package/dist/client/useProductionAgent.d.ts.map +0 -1
- package/dist/client/useProductionAgent.js +0 -179
- package/dist/client/useProductionAgent.js.map +0 -1
- package/dist/shared/auth-redirect-url.d.ts +0 -2
- package/dist/shared/auth-redirect-url.d.ts.map +0 -1
- package/dist/shared/auth-redirect-url.js +0 -2
- package/dist/shared/auth-redirect-url.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditCell.js","sourceRoot":"","sources":["../../../src/client/tool-cells/EditCell.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;AAEH,OAAO,EACL,eAAe,EACf,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IACV,CACR,EACA,IAAI,CAAC,SAAS,IAAI,CACjB,eAAM,SAAS,EAAC,mCAAmC,0BAE5C,CACR,IACI,CACR,EAEA,OAAO,IAAI,CACV,KAAC,eAAe,IACd,SAAS,EAAE,EAAE,CACX,kCAAkC,EAClC,QAAQ,IAAI,YAAY,CACzB,GACD,CACH,IACM,EAGR,QAAQ,IAAI,OAAO,IAAI,CACtB,eAAK,SAAS,EAAC,yCAAyC,aACtD,KAAC,QAAQ,IAAC,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,GAAI,EAChD,WAAW,GAAG,CAAC,IAAI,CAClB,cAAK,SAAS,EAAC,uEAAuE,YACpF,kBACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,gDAAgD,EAC1D,OAAO,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,sBAEzB,WAAW,mBACV,GACL,CACP,IACG,CACP,IACG,CACP,CAAC;AACJ,CAAC","sourcesContent":["/**\n * EditCell — renders an edit tool call as a syntax-highlighted unified diff.\n *\n * The diff is computed client-side from oldText / newText stored in the\n * structured metadata. The HighlightedCodeBlock from AssistantChat is not\n * accessible here, so we do a lightweight line-diff + per-line class approach\n * instead (no dep on shiki required for the diff view itself).\n *\n * Collapsed by default beyond MAX_COLLAPSED_LINES; expand button shows all.\n */\n\nimport {\n IconChevronDown,\n IconFile,\n IconFileDiff,\n IconLoader2,\n} from \"@tabler/icons-react\";\nimport { memo, useMemo, useState } from \"react\";\n\nimport { cn } from \"../utils.js\";\n\nexport interface EditCellMeta {\n toolKind: \"edit\";\n filePath: string;\n oldText?: string;\n newText?: string;\n truncated?: boolean;\n}\n\ninterface EditCellProps {\n meta: EditCellMeta;\n isRunning: boolean;\n}\n\n/** Lines shown collapsed before \"expand\" is offered. */\nconst MAX_COLLAPSED_LINES = 40;\n\n// ─── Diff computation ────────────────────────────────────────────────────────\n\ninterface DiffLine {\n kind: \"context\" | \"added\" | \"removed\";\n text: string;\n oldLineNo?: number;\n newLineNo?: number;\n}\n\nfunction computeLineDiff(oldText: string, newText: string): DiffLine[] {\n const oldLines = oldText.split(\"\\n\");\n const newLines = newText.split(\"\\n\");\n\n // Simple Myers-style LCS via DP for line-level diffs.\n // For very large files we cap input to keep it snappy.\n const MAX_LINES = 2000;\n const a = oldLines.slice(0, MAX_LINES);\n const b = newLines.slice(0, MAX_LINES);\n\n const m = a.length;\n const n = b.length;\n\n // Build LCS table\n const dp: number[][] = Array.from({ length: m + 1 }, () =>\n new Array(n + 1).fill(0),\n );\n for (let i = m - 1; i >= 0; i--) {\n for (let j = n - 1; j >= 0; j--) {\n if (a[i] === b[j]) {\n dp[i][j] = dp[i + 1][j + 1] + 1;\n } else {\n dp[i][j] = Math.max(dp[i + 1][j], dp[i][j + 1]);\n }\n }\n }\n\n const result: DiffLine[] = [];\n let i = 0;\n let j = 0;\n let oldLineNo = 1;\n let newLineNo = 1;\n\n while (i < m || j < n) {\n if (i < m && j < n && a[i] === b[j]) {\n result.push({\n kind: \"context\",\n text: a[i],\n oldLineNo: oldLineNo++,\n newLineNo: newLineNo++,\n });\n i++;\n j++;\n } else if (j < n && (i >= m || dp[i + 1][j] >= dp[i][j + 1])) {\n result.push({ kind: \"added\", text: b[j], newLineNo: newLineNo++ });\n j++;\n } else {\n result.push({ kind: \"removed\", text: a[i], oldLineNo: oldLineNo++ });\n i++;\n }\n }\n\n // Append any overflow lines as context\n if (oldLines.length > MAX_LINES) {\n for (let k = MAX_LINES; k < oldLines.length; k++) {\n result.push({\n kind: \"removed\",\n text: oldLines[k],\n oldLineNo: oldLineNo++,\n });\n }\n }\n if (newLines.length > MAX_LINES) {\n for (let k = MAX_LINES; k < newLines.length; k++) {\n result.push({\n kind: \"added\",\n text: newLines[k],\n newLineNo: newLineNo++,\n });\n }\n }\n\n return result;\n}\n\n/** Compute +N -N line counts from a diff. */\nfunction diffStats(lines: DiffLine[]): { added: number; removed: number } {\n let added = 0;\n let removed = 0;\n for (const line of lines) {\n if (line.kind === \"added\") added++;\n else if (line.kind === \"removed\") removed++;\n }\n return { added, removed };\n}\n\n// ─── Component ───────────────────────────────────────────────────────────────\n\nconst DiffView = memo(function DiffView({\n lines,\n maxLines,\n}: {\n lines: DiffLine[];\n maxLines: number | null;\n}) {\n const visible = maxLines === null ? lines : lines.slice(0, maxLines);\n\n return (\n <div className=\"overflow-x-auto\">\n <table className=\"w-full min-w-full border-collapse font-mono text-[11px] leading-relaxed\">\n <tbody>\n {visible.map((line, idx) => (\n <tr\n key={idx}\n className={cn(\n line.kind === \"added\" &&\n \"bg-emerald-500/8 dark:bg-emerald-400/8\",\n line.kind === \"removed\" && \"bg-destructive/8\",\n )}\n >\n {/* Old line number */}\n <td className=\"w-8 select-none border-r border-border/30 px-1.5 text-right text-[10px] text-muted-foreground/60\">\n {line.oldLineNo ?? \"\"}\n </td>\n {/* New line number */}\n <td className=\"w-8 select-none border-r border-border/30 px-1.5 text-right text-[10px] text-muted-foreground/60\">\n {line.newLineNo ?? \"\"}\n </td>\n {/* Sigil */}\n <td\n className={cn(\n \"w-4 select-none text-center text-[10px] font-bold\",\n line.kind === \"added\" &&\n \"text-emerald-600 dark:text-emerald-400\",\n line.kind === \"removed\" && \"text-destructive\",\n line.kind === \"context\" && \"text-muted-foreground/40\",\n )}\n >\n {line.kind === \"added\"\n ? \"+\"\n : line.kind === \"removed\"\n ? \"-\"\n : \" \"}\n </td>\n {/* Content */}\n <td\n className={cn(\n \"px-2 text-foreground\",\n line.kind === \"added\" &&\n \"text-emerald-800 dark:text-emerald-200\",\n line.kind === \"removed\" && \"text-red-800 dark:text-red-200\",\n )}\n >\n <span\n style={{ whiteSpace: \"pre-wrap\", wordBreak: \"break-all\" }}\n >\n {line.text}\n </span>\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n );\n});\n\nexport function EditCell({ meta, isRunning }: EditCellProps) {\n const [expanded, setExpanded] = useState(false);\n const [showAll, setShowAll] = useState(false);\n\n const diff = useMemo(() => {\n if (!meta.oldText && !meta.newText) return null;\n return computeLineDiff(meta.oldText ?? \"\", meta.newText ?? \"\");\n }, [meta.oldText, meta.newText]);\n\n const stats = useMemo(() => (diff ? diffStats(diff) : null), [diff]);\n const hasDiff = diff !== null && diff.length > 0;\n\n const totalLines = diff?.length ?? 0;\n const maxCollapsed =\n showAll || totalLines <= MAX_COLLAPSED_LINES ? null : MAX_COLLAPSED_LINES;\n const hiddenLines =\n maxCollapsed !== null ? totalLines - MAX_COLLAPSED_LINES : 0;\n\n return (\n <div className=\"my-1 overflow-hidden rounded-md border border-border/60\">\n {/* Header */}\n <button\n type=\"button\"\n onClick={() => hasDiff && setExpanded((e) => !e)}\n className={cn(\n \"flex w-full items-center gap-2 px-2.5 py-1.5 text-left text-xs font-mono\",\n isRunning\n ? \"bg-muted text-muted-foreground\"\n : \"bg-muted text-muted-foreground hover:bg-accent\",\n hasDiff && \"cursor-pointer\",\n !hasDiff && \"cursor-default\",\n )}\n aria-expanded={hasDiff ? expanded : undefined}\n >\n <span className=\"shrink-0\">\n {isRunning ? (\n <IconLoader2 className=\"h-3 w-3 animate-spin\" />\n ) : (\n <IconFileDiff className=\"h-3 w-3 text-amber-500\" />\n )}\n </span>\n\n <IconFile className=\"h-3 w-3 shrink-0 text-muted-foreground/70\" />\n <span className=\"min-w-0 flex-1 truncate font-medium text-foreground\">\n {meta.filePath}\n </span>\n\n {stats && !isRunning && (\n <span className=\"ml-auto flex shrink-0 items-center gap-1.5\">\n {stats.added > 0 && (\n <span className=\"text-[10px] font-semibold text-emerald-600 dark:text-emerald-400\">\n +{stats.added}\n </span>\n )}\n {stats.removed > 0 && (\n <span className=\"text-[10px] font-semibold text-destructive\">\n -{stats.removed}\n </span>\n )}\n {meta.truncated && (\n <span className=\"text-[10px] text-muted-foreground\">\n (partial)\n </span>\n )}\n </span>\n )}\n\n {hasDiff && (\n <IconChevronDown\n className={cn(\n \"ml-1 h-3 w-3 shrink-0 opacity-40\",\n expanded && \"rotate-180\",\n )}\n />\n )}\n </button>\n\n {/* Diff body */}\n {expanded && hasDiff && (\n <div className=\"border-t border-border/40 bg-background\">\n <DiffView lines={diff} maxLines={maxCollapsed} />\n {hiddenLines > 0 && (\n <div className=\"border-t border-border/40 px-3 py-1 text-[11px] text-muted-foreground\">\n <button\n type=\"button\"\n className=\"cursor-pointer underline hover:text-foreground\"\n onClick={() => setShowAll(true)}\n >\n Show {hiddenLines} more lines\n </button>\n </div>\n )}\n </div>\n )}\n </div>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"EditCell.js","sourceRoot":"","sources":["../../../src/client/tool-cells/EditCell.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;AAEH,OAAO,EACL,eAAe,EACf,QAAQ,EACR,YAAY,EACZ,WAAW,GACZ,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAejC,wDAAwD;AACxD,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAW/B,SAAS,eAAe,CAAC,OAAe,EAAE,OAAe;IACvD,MAAM,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACrC,MAAM,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAErC,sDAAsD;IACtD,uDAAuD;IACvD,MAAM,SAAS,GAAG,IAAI,CAAC;IACvB,MAAM,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;IACvC,MAAM,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;IAEvC,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;IACnB,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;IAEnB,kBAA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,GAAG,CACjD,CAAC,CAAC,CAAC,CACF,KAAC,YAAY,IAAC,SAAS,EAAC,wBAAwB,GAAG,CACpD,GACI,EAEP,KAAC,QAAQ,IAAC,SAAS,EAAC,2CAA2C,GAAG,EAClE,eAAM,SAAS,EAAC,qDAAqD,YAClE,IAAI,CAAC,QAAQ,GACT,EAEN,KAAK,IAAI,CAAC,SAAS,IAAI,CACtB,gBAAM,SAAS,EAAC,4CAA4C,aACzD,KAAK,CAAC,KAAK,GAAG,CAAC,IAAI,CAClB,gBAAM,SAAS,EAAC,kEAAkE,kBAC9E,KAAK,CAAC,KAAK,IACR,CACR,EACA,KAAK,CAAC,OAAO,GAAG,CAAC,IAAI,CACpB,gBAAM,SAAS,EAAC,4CAA4C,kBACxD,KAAK,CAAC,OAAO,IACV,CACR,EACA,IAAI,CAAC,SAAS,IAAI,CACjB,eAAM,SAAS,EAAC,mCAAmC,0BAE5C,CACR,IACI,CACR,EAEA,OAAO,IAAI,CACV,KAAC,eAAe,IACd,SAAS,EAAE,EAAE,CACX,kCAAkC,EAClC,QAAQ,IAAI,YAAY,CACzB,GACD,CACH,IACM,EAGT,KAAC,gBAAgB,IAAC,IAAI,EAAE,QAAQ,IAAI,OAAO,YACxC,OAAO,IAAI,CACV,eAAK,SAAS,EAAC,yCAAyC,aACtD,KAAC,QAAQ,IAAC,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,GAAI,EAChD,WAAW,GAAG,CAAC,IAAI,CAClB,cAAK,SAAS,EAAC,uEAAuE,YACpF,kBACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,gDAAgD,EAC1D,OAAO,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,sBAEzB,WAAW,mBACV,GACL,CACP,IACG,CACP,GACgB,IACf,CACP,CAAC;AACJ,CAAC","sourcesContent":["/**\n * EditCell — renders an edit tool call as a syntax-highlighted unified diff.\n *\n * The diff is computed client-side from oldText / newText stored in the\n * structured metadata. The HighlightedCodeBlock from AssistantChat is not\n * accessible here, so we do a lightweight line-diff + per-line class approach\n * instead (no dep on shiki required for the diff view itself).\n *\n * Collapsed by default beyond MAX_COLLAPSED_LINES; expand button shows all.\n */\n\nimport {\n IconChevronDown,\n IconFile,\n IconFileDiff,\n IconLoader2,\n} from \"@tabler/icons-react\";\nimport { memo, useMemo, useState } from \"react\";\n\nimport { AnimatedCollapse } from \"../chat/tool-call-display.js\";\nimport { cn } from \"../utils.js\";\n\nexport interface EditCellMeta {\n toolKind: \"edit\";\n filePath: string;\n oldText?: string;\n newText?: string;\n truncated?: boolean;\n}\n\ninterface EditCellProps {\n meta: EditCellMeta;\n isRunning: boolean;\n}\n\n/** Lines shown collapsed before \"expand\" is offered. */\nconst MAX_COLLAPSED_LINES = 40;\n\n// ─── Diff computation ────────────────────────────────────────────────────────\n\ninterface DiffLine {\n kind: \"context\" | \"added\" | \"removed\";\n text: string;\n oldLineNo?: number;\n newLineNo?: number;\n}\n\nfunction computeLineDiff(oldText: string, newText: string): DiffLine[] {\n const oldLines = oldText.split(\"\\n\");\n const newLines = newText.split(\"\\n\");\n\n // Simple Myers-style LCS via DP for line-level diffs.\n // For very large files we cap input to keep it snappy.\n const MAX_LINES = 2000;\n const a = oldLines.slice(0, MAX_LINES);\n const b = newLines.slice(0, MAX_LINES);\n\n const m = a.length;\n const n = b.length;\n\n // Build LCS table\n const dp: number[][] = Array.from({ length: m + 1 }, () =>\n new Array(n + 1).fill(0),\n );\n for (let i = m - 1; i >= 0; i--) {\n for (let j = n - 1; j >= 0; j--) {\n if (a[i] === b[j]) {\n dp[i][j] = dp[i + 1][j + 1] + 1;\n } else {\n dp[i][j] = Math.max(dp[i + 1][j], dp[i][j + 1]);\n }\n }\n }\n\n const result: DiffLine[] = [];\n let i = 0;\n let j = 0;\n let oldLineNo = 1;\n let newLineNo = 1;\n\n while (i < m || j < n) {\n if (i < m && j < n && a[i] === b[j]) {\n result.push({\n kind: \"context\",\n text: a[i],\n oldLineNo: oldLineNo++,\n newLineNo: newLineNo++,\n });\n i++;\n j++;\n } else if (j < n && (i >= m || dp[i + 1][j] >= dp[i][j + 1])) {\n result.push({ kind: \"added\", text: b[j], newLineNo: newLineNo++ });\n j++;\n } else {\n result.push({ kind: \"removed\", text: a[i], oldLineNo: oldLineNo++ });\n i++;\n }\n }\n\n // Append any overflow lines as context\n if (oldLines.length > MAX_LINES) {\n for (let k = MAX_LINES; k < oldLines.length; k++) {\n result.push({\n kind: \"removed\",\n text: oldLines[k],\n oldLineNo: oldLineNo++,\n });\n }\n }\n if (newLines.length > MAX_LINES) {\n for (let k = MAX_LINES; k < newLines.length; k++) {\n result.push({\n kind: \"added\",\n text: newLines[k],\n newLineNo: newLineNo++,\n });\n }\n }\n\n return result;\n}\n\n/** Compute +N -N line counts from a diff. */\nfunction diffStats(lines: DiffLine[]): { added: number; removed: number } {\n let added = 0;\n let removed = 0;\n for (const line of lines) {\n if (line.kind === \"added\") added++;\n else if (line.kind === \"removed\") removed++;\n }\n return { added, removed };\n}\n\n// ─── Component ───────────────────────────────────────────────────────────────\n\nconst DiffView = memo(function DiffView({\n lines,\n maxLines,\n}: {\n lines: DiffLine[];\n maxLines: number | null;\n}) {\n const visible = maxLines === null ? lines : lines.slice(0, maxLines);\n\n return (\n <div className=\"overflow-x-auto\">\n <table className=\"w-full min-w-full border-collapse font-mono text-[11px] leading-relaxed\">\n <tbody>\n {visible.map((line, idx) => (\n <tr\n key={idx}\n className={cn(\n line.kind === \"added\" &&\n \"bg-emerald-500/8 dark:bg-emerald-400/8\",\n line.kind === \"removed\" && \"bg-destructive/8\",\n )}\n >\n {/* Old line number */}\n <td className=\"w-8 select-none border-r border-border/30 px-1.5 text-right text-[10px] text-muted-foreground/60\">\n {line.oldLineNo ?? \"\"}\n </td>\n {/* New line number */}\n <td className=\"w-8 select-none border-r border-border/30 px-1.5 text-right text-[10px] text-muted-foreground/60\">\n {line.newLineNo ?? \"\"}\n </td>\n {/* Sigil */}\n <td\n className={cn(\n \"w-4 select-none text-center text-[10px] font-bold\",\n line.kind === \"added\" &&\n \"text-emerald-600 dark:text-emerald-400\",\n line.kind === \"removed\" && \"text-destructive\",\n line.kind === \"context\" && \"text-muted-foreground/40\",\n )}\n >\n {line.kind === \"added\"\n ? \"+\"\n : line.kind === \"removed\"\n ? \"-\"\n : \" \"}\n </td>\n {/* Content */}\n <td\n className={cn(\n \"px-2 text-foreground\",\n line.kind === \"added\" &&\n \"text-emerald-800 dark:text-emerald-200\",\n line.kind === \"removed\" && \"text-red-800 dark:text-red-200\",\n )}\n >\n <span\n style={{ whiteSpace: \"pre-wrap\", wordBreak: \"break-all\" }}\n >\n {line.text}\n </span>\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n );\n});\n\nexport function EditCell({ meta, isRunning }: EditCellProps) {\n const [expanded, setExpanded] = useState(false);\n const [showAll, setShowAll] = useState(false);\n\n const diff = useMemo(() => {\n if (!meta.oldText && !meta.newText) return null;\n return computeLineDiff(meta.oldText ?? \"\", meta.newText ?? \"\");\n }, [meta.oldText, meta.newText]);\n\n const stats = useMemo(() => (diff ? diffStats(diff) : null), [diff]);\n const hasDiff = diff !== null && diff.length > 0;\n\n const totalLines = diff?.length ?? 0;\n const maxCollapsed =\n showAll || totalLines <= MAX_COLLAPSED_LINES ? null : MAX_COLLAPSED_LINES;\n const hiddenLines =\n maxCollapsed !== null ? totalLines - MAX_COLLAPSED_LINES : 0;\n\n return (\n <div className=\"my-1 overflow-hidden rounded-md border border-border/60\">\n {/* Header */}\n <button\n type=\"button\"\n onClick={() => hasDiff && setExpanded((e) => !e)}\n className={cn(\n \"flex w-full items-center gap-2 px-2.5 py-1.5 text-left text-xs font-mono\",\n isRunning\n ? \"bg-muted text-muted-foreground\"\n : \"bg-muted text-muted-foreground hover:bg-accent\",\n hasDiff && \"cursor-pointer\",\n !hasDiff && \"cursor-default\",\n )}\n aria-expanded={hasDiff ? expanded : undefined}\n >\n <span className=\"shrink-0\">\n {isRunning ? (\n <IconLoader2 className=\"h-3 w-3 animate-spin\" />\n ) : (\n <IconFileDiff className=\"h-3 w-3 text-amber-500\" />\n )}\n </span>\n\n <IconFile className=\"h-3 w-3 shrink-0 text-muted-foreground/70\" />\n <span className=\"min-w-0 flex-1 truncate font-medium text-foreground\">\n {meta.filePath}\n </span>\n\n {stats && !isRunning && (\n <span className=\"ml-auto flex shrink-0 items-center gap-1.5\">\n {stats.added > 0 && (\n <span className=\"text-[10px] font-semibold text-emerald-600 dark:text-emerald-400\">\n +{stats.added}\n </span>\n )}\n {stats.removed > 0 && (\n <span className=\"text-[10px] font-semibold text-destructive\">\n -{stats.removed}\n </span>\n )}\n {meta.truncated && (\n <span className=\"text-[10px] text-muted-foreground\">\n (partial)\n </span>\n )}\n </span>\n )}\n\n {hasDiff && (\n <IconChevronDown\n className={cn(\n \"ml-1 h-3 w-3 shrink-0 opacity-40\",\n expanded && \"rotate-180\",\n )}\n />\n )}\n </button>\n\n {/* Diff body */}\n <AnimatedCollapse open={expanded && hasDiff}>\n {hasDiff && (\n <div className=\"border-t border-border/40 bg-background\">\n <DiffView lines={diff} maxLines={maxCollapsed} />\n {hiddenLines > 0 && (\n <div className=\"border-t border-border/40 px-3 py-1 text-[11px] text-muted-foreground\">\n <button\n type=\"button\"\n className=\"cursor-pointer underline hover:text-foreground\"\n onClick={() => setShowAll(true)}\n >\n Show {hiddenLines} more lines\n </button>\n </div>\n )}\n </div>\n )}\n </AnimatedCollapse>\n </div>\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilesChangedSummary.d.ts","sourceRoot":"","sources":["../../../src/client/tool-cells/FilesChangedSummary.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"FilesChangedSummary.d.ts","sourceRoot":"","sources":["../../../src/client/tool-cells/FilesChangedSummary.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAK7D,UAAU,wBAAwB;IAChC,uDAAuD;IACvD,KAAK,EAAE,WAAW,EAAE,CAAC;CACtB;AAiFD,eAAO,MAAM,mBAAmB,mDAE7B,wBAAwB,wCA0GzB,CAAC"}
|
|
@@ -6,6 +6,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
6
6
|
*/
|
|
7
7
|
import { IconFiles } from "@tabler/icons-react";
|
|
8
8
|
import { memo, useMemo, useState } from "react";
|
|
9
|
+
import { AnimatedCollapse } from "../chat/tool-call-display.js";
|
|
9
10
|
import { cn } from "../utils.js";
|
|
10
11
|
import { EditCell } from "./EditCell.js";
|
|
11
12
|
import { WriteCell } from "./WriteCell.js";
|
|
@@ -92,7 +93,7 @@ export const FilesChangedSummary = memo(function FilesChangedSummary({ parts, })
|
|
|
92
93
|
const key = `${entry.kind}:${entry.filePath}`;
|
|
93
94
|
const isExpanded = expanded.has(key);
|
|
94
95
|
const part = parts[entry.partIndex];
|
|
95
|
-
return (_jsxs("div", { className: "border-b border-border/30 last:border-b-0", children: [_jsxs("button", { type: "button", onClick: () => toggle(key), className: "flex w-full cursor-pointer items-center gap-2 px-2.5 py-1 text-left text-[11px] hover:bg-accent", children: [_jsx("span", { className: cn("inline-block h-1.5 w-1.5 shrink-0 rounded-full", entry.kind === "write" ? "bg-emerald-500" : "bg-amber-500") }), _jsx("span", { className: "min-w-0 flex-1 truncate font-mono text-foreground", children: entry.filePath }), _jsxs("span", { className: "ml-auto flex shrink-0 items-center gap-1", children: [entry.added > 0 && (_jsxs("span", { className: "text-[10px] font-semibold text-emerald-600 dark:text-emerald-400", children: ["+", entry.added] })), entry.removed > 0 && (_jsxs("span", { className: "text-[10px] font-semibold text-destructive", children: ["-", entry.removed] }))] })] }), isExpanded
|
|
96
|
+
return (_jsxs("div", { className: "border-b border-border/30 last:border-b-0", children: [_jsxs("button", { type: "button", onClick: () => toggle(key), className: "flex w-full cursor-pointer items-center gap-2 px-2.5 py-1 text-left text-[11px] hover:bg-accent", children: [_jsx("span", { className: cn("inline-block h-1.5 w-1.5 shrink-0 rounded-full", entry.kind === "write" ? "bg-emerald-500" : "bg-amber-500") }), _jsx("span", { className: "min-w-0 flex-1 truncate font-mono text-foreground", children: entry.filePath }), _jsxs("span", { className: "ml-auto flex shrink-0 items-center gap-1", children: [entry.added > 0 && (_jsxs("span", { className: "text-[10px] font-semibold text-emerald-600 dark:text-emerald-400", children: ["+", entry.added] })), entry.removed > 0 && (_jsxs("span", { className: "text-[10px] font-semibold text-destructive", children: ["-", entry.removed] }))] })] }), _jsx(AnimatedCollapse, { open: isExpanded, children: part.type === "tool-call" && part.structuredMeta && (_jsx("div", { className: "pl-4", children: entry.kind === "edit" ? (_jsx(EditCell, { meta: part.structuredMeta, isRunning: false })) : (_jsx(WriteCell, { meta: part.structuredMeta, isRunning: false })) })) })] }, key));
|
|
96
97
|
})] }));
|
|
97
98
|
});
|
|
98
99
|
//# sourceMappingURL=FilesChangedSummary.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilesChangedSummary.js","sourceRoot":"","sources":["../../../src/client/tool-cells/FilesChangedSummary.tsx"],"names":[],"mappings":";AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGhD,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAe3C,SAAS,UAAU,CAAC,IAAY;IAC9B,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5C,CAAC;AAED,SAAS,aAAa,CACpB,OAA2B,EAC3B,OAA2B;IAE3B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AAI,KAAK,MAAM,CAAC,CAAC,CAAC,CACvB,KAAC,QAAQ,IACP,IAAI,EACF,IAAI,CAAC,cAEO,EAEd,SAAS,EAAE,KAAK,GAChB,CACH,CAAC,CAAC,CAAC,CACF,KAAC,SAAS,IACR,IAAI,EACF,IAAI,CAAC,cAEO,EAEd,SAAS,EAAE,KAAK,GAChB,CACH,GACG,CACP,KAnDO,GAAG,CAoDP,CACP,CAAC;YACJ,CAAC,CAAC,IACE,CACP,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["/**\n * FilesChangedSummary — aggregates all edit/write tool calls in a turn and\n * renders a compact \"+N -M path\" summary row per file. Click a row to expand\n * to that file's diff. Derived purely from ContentPart structuredMeta.\n */\n\nimport { IconFiles } from \"@tabler/icons-react\";\nimport { memo, useMemo, useState } from \"react\";\n\nimport type { ContentPart } from \"../sse-event-processor.js\";\nimport { cn } from \"../utils.js\";\nimport { EditCell } from \"./EditCell.js\";\nimport { WriteCell } from \"./WriteCell.js\";\n\ninterface FilesChangedSummaryProps {\n /** All content parts in the current assistant turn. */\n parts: ContentPart[];\n}\n\ninterface FileEntry {\n filePath: string;\n kind: \"edit\" | \"write\";\n added: number;\n removed: number;\n partIndex: number;\n}\n\nfunction countLines(text: string): number {\n return text ? text.split(\"\\n\").length : 0;\n}\n\nfunction editLineDelta(\n oldText: string | undefined,\n newText: string | undefined,\n): { added: number; removed: number } {\n const oldLines = oldText ? oldText.split(\"\\n\") : [];\n const newLines = newText ? newText.split(\"\\n\") : [];\n\n // Simple count: compare total lines per side. For a real diff the\n // edit cell already shows the full diff, so this approximation is fine\n // for the summary bar.\n const base = Math.min(oldLines.length, newLines.length);\n const added = newLines.length - base;\n const removed = oldLines.length - base;\n return { added, removed };\n}\n\nfunction extractFileEntries(parts: ContentPart[]): FileEntry[] {\n const entries: FileEntry[] = [];\n for (let i = 0; i < parts.length; i++) {\n const part = parts[i];\n if (part.type !== \"tool-call\" || !part.structuredMeta) continue;\n const meta = part.structuredMeta as Record<string, unknown>;\n const kind = meta.toolKind as string | undefined;\n if (kind === \"edit\") {\n const { added, removed } = editLineDelta(\n meta.oldText as string | undefined,\n meta.newText as string | undefined,\n );\n entries.push({\n filePath: (meta.filePath as string) ?? \"\",\n kind: \"edit\",\n added,\n removed,\n partIndex: i,\n });\n } else if (kind === \"write\") {\n const lineCount =\n typeof meta.lineCount === \"number\"\n ? meta.lineCount\n : countLines((meta.content as string | undefined) ?? \"\");\n entries.push({\n filePath: (meta.filePath as string) ?? \"\",\n kind: \"write\",\n added: lineCount,\n removed: 0,\n partIndex: i,\n });\n }\n }\n\n // Deduplicate: last edit/write per file path wins for the summary row,\n // but keep the expanded view as-is.\n const seen = new Map<string, number>();\n const deduped: FileEntry[] = [];\n for (const entry of entries) {\n const key = `${entry.kind}:${entry.filePath}`;\n if (seen.has(key)) {\n const existing = seen.get(key)!;\n deduped[existing] = entry;\n } else {\n seen.set(key, deduped.length);\n deduped.push(entry);\n }\n }\n return deduped;\n}\n\nexport const FilesChangedSummary = memo(function FilesChangedSummary({\n parts,\n}: FilesChangedSummaryProps) {\n const entries = useMemo(() => extractFileEntries(parts), [parts]);\n const [expanded, setExpanded] = useState<Set<string>>(new Set());\n\n if (entries.length === 0) return null;\n\n const toggle = (key: string) => {\n setExpanded((prev) => {\n const next = new Set(prev);\n if (next.has(key)) next.delete(key);\n else next.add(key);\n return next;\n });\n };\n\n const totalAdded = entries.reduce((s, e) => s + e.added, 0);\n const totalRemoved = entries.reduce((s, e) => s + e.removed, 0);\n\n return (\n <div className=\"my-2 overflow-hidden rounded-md border border-border/60\">\n {/* Summary header */}\n <div className=\"flex items-center gap-2 border-b border-border/40 bg-muted px-2.5 py-1.5 text-xs text-muted-foreground\">\n <IconFiles className=\"h-3.5 w-3.5 shrink-0\" />\n <span className=\"font-medium text-foreground\">\n {entries.length} file{entries.length === 1 ? \"\" : \"s\"} changed\n </span>\n <span className=\"ml-auto flex items-center gap-1.5\">\n {totalAdded > 0 && (\n <span className=\"text-[10px] font-semibold text-emerald-600 dark:text-emerald-400\">\n +{totalAdded}\n </span>\n )}\n {totalRemoved > 0 && (\n <span className=\"text-[10px] font-semibold text-destructive\">\n -{totalRemoved}\n </span>\n )}\n </span>\n </div>\n\n {/* Per-file rows */}\n {entries.map((entry) => {\n const key = `${entry.kind}:${entry.filePath}`;\n const isExpanded = expanded.has(key);\n const part = parts[entry.partIndex];\n\n return (\n <div key={key} className=\"border-b border-border/30 last:border-b-0\">\n <button\n type=\"button\"\n onClick={() => toggle(key)}\n className=\"flex w-full cursor-pointer items-center gap-2 px-2.5 py-1 text-left text-[11px] hover:bg-accent\"\n >\n <span\n className={cn(\n \"inline-block h-1.5 w-1.5 shrink-0 rounded-full\",\n entry.kind === \"write\" ? \"bg-emerald-500\" : \"bg-amber-500\",\n )}\n />\n <span className=\"min-w-0 flex-1 truncate font-mono text-foreground\">\n {entry.filePath}\n </span>\n <span className=\"ml-auto flex shrink-0 items-center gap-1\">\n {entry.added > 0 && (\n <span className=\"text-[10px] font-semibold text-emerald-600 dark:text-emerald-400\">\n +{entry.added}\n </span>\n )}\n {entry.removed > 0 && (\n <span className=\"text-[10px] font-semibold text-destructive\">\n -{entry.removed}\n </span>\n )}\n </span>\n </button>\n\n {isExpanded && part.type === \"tool-call\" && part.structuredMeta && (\n <div className=\"pl-4\">\n {entry.kind === \"edit\" ? (\n <EditCell\n meta={\n part.structuredMeta as unknown as Parameters<\n typeof EditCell\n >[0][\"meta\"]\n }\n isRunning={false}\n />\n ) : (\n <WriteCell\n meta={\n part.structuredMeta as unknown as Parameters<\n typeof WriteCell\n >[0][\"meta\"]\n }\n isRunning={false}\n />\n )}\n </div>\n )}\n </div>\n );\n })}\n </div>\n );\n});\n"]}
|
|
1
|
+
{"version":3,"file":"FilesChangedSummary.js","sourceRoot":"","sources":["../../../src/client/tool-cells/FilesChangedSummary.tsx"],"names":[],"mappings":";AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CA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gB,CAAC,CAAC,CAAC,cAAc,CAC3D,GACD,EACF,eAAM,SAAS,EAAC,mDAAmD,YAChE,KAAK,CAAC,QAAQ,GACV,EACP,gBAAM,SAAS,EAAC,0CAA0C,aACvD,KAAK,CAAC,KAAK,GAAG,CAAC,IAAI,CAClB,gBAAM,SAAS,EAAC,kEAAkE,kBAC9E,KAAK,CAAC,KAAK,IACR,CACR,EACA,KAAK,CAAC,OAAO,GAAG,CAAC,IAAI,CACpB,gBAAM,SAAS,EAAC,4CAA4C,kBACxD,KAAK,CAAC,OAAO,IACV,CACR,IACI,IACA,EAET,KAAC,gBAAgB,IAAC,IAAI,EAAE,UAAU,YAC/B,IAAI,CAAC,IAAI,KAAK,WAAW,IAAI,IAAI,CAAC,cAAc,IAAI,CACnD,cAAK,SAAS,EAAC,MAAM,YAClB,KAAK,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,CACvB,KAAC,QAAQ,IACP,IAAI,EACF,IAAI,CAAC,cAEO,EAEd,SAAS,EAAE,KAAK,GAChB,CACH,CAAC,CAAC,CAAC,CACF,KAAC,SAAS,IACR,IAAI,EACF,IAAI,CAAC,cAEO,EAEd,SAAS,EAAE,KAAK,GAChB,CACH,GACG,CACP,GACgB,KArDX,GAAG,CAsDP,CACP,CAAC;YACJ,CAAC,CAAC,IACE,CACP,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["/**\n * FilesChangedSummary — aggregates all edit/write tool calls in a turn and\n * renders a compact \"+N -M path\" summary row per file. Click a row to expand\n * to that file's diff. Derived purely from ContentPart structuredMeta.\n */\n\nimport { IconFiles } from \"@tabler/icons-react\";\nimport { memo, useMemo, useState } from \"react\";\n\nimport { AnimatedCollapse } from \"../chat/tool-call-display.js\";\nimport type { ContentPart } from \"../sse-event-processor.js\";\nimport { cn } from \"../utils.js\";\nimport { EditCell } from \"./EditCell.js\";\nimport { WriteCell } from \"./WriteCell.js\";\n\ninterface FilesChangedSummaryProps {\n /** All content parts in the current assistant turn. */\n parts: ContentPart[];\n}\n\ninterface FileEntry {\n filePath: string;\n kind: \"edit\" | \"write\";\n added: number;\n removed: number;\n partIndex: number;\n}\n\nfunction countLines(text: string): number {\n return text ? text.split(\"\\n\").length : 0;\n}\n\nfunction editLineDelta(\n oldText: string | undefined,\n newText: string | undefined,\n): { added: number; removed: number } {\n const oldLines = oldText ? oldText.split(\"\\n\") : [];\n const newLines = newText ? newText.split(\"\\n\") : [];\n\n // Simple count: compare total lines per side. For a real diff the\n // edit cell already shows the full diff, so this approximation is fine\n // for the summary bar.\n const base = Math.min(oldLines.length, newLines.length);\n const added = newLines.length - base;\n const removed = oldLines.length - base;\n return { added, removed };\n}\n\nfunction extractFileEntries(parts: ContentPart[]): FileEntry[] {\n const entries: FileEntry[] = [];\n for (let i = 0; i < parts.length; i++) {\n const part = parts[i];\n if (part.type !== \"tool-call\" || !part.structuredMeta) continue;\n const meta = part.structuredMeta as Record<string, unknown>;\n const kind = meta.toolKind as string | undefined;\n if (kind === \"edit\") {\n const { added, removed } = editLineDelta(\n meta.oldText as string | undefined,\n meta.newText as string | undefined,\n );\n entries.push({\n filePath: (meta.filePath as string) ?? \"\",\n kind: \"edit\",\n added,\n removed,\n partIndex: i,\n });\n } else if (kind === \"write\") {\n const lineCount =\n typeof meta.lineCount === \"number\"\n ? meta.lineCount\n : countLines((meta.content as string | undefined) ?? \"\");\n entries.push({\n filePath: (meta.filePath as string) ?? \"\",\n kind: \"write\",\n added: lineCount,\n removed: 0,\n partIndex: i,\n });\n }\n }\n\n // Deduplicate: last edit/write per file path wins for the summary row,\n // but keep the expanded view as-is.\n const seen = new Map<string, number>();\n const deduped: FileEntry[] = [];\n for (const entry of entries) {\n const key = `${entry.kind}:${entry.filePath}`;\n if (seen.has(key)) {\n const existing = seen.get(key)!;\n deduped[existing] = entry;\n } else {\n seen.set(key, deduped.length);\n deduped.push(entry);\n }\n }\n return deduped;\n}\n\nexport const FilesChangedSummary = memo(function FilesChangedSummary({\n parts,\n}: FilesChangedSummaryProps) {\n const entries = useMemo(() => extractFileEntries(parts), [parts]);\n const [expanded, setExpanded] = useState<Set<string>>(new Set());\n\n if (entries.length === 0) return null;\n\n const toggle = (key: string) => {\n setExpanded((prev) => {\n const next = new Set(prev);\n if (next.has(key)) next.delete(key);\n else next.add(key);\n return next;\n });\n };\n\n const totalAdded = entries.reduce((s, e) => s + e.added, 0);\n const totalRemoved = entries.reduce((s, e) => s + e.removed, 0);\n\n return (\n <div className=\"my-2 overflow-hidden rounded-md border border-border/60\">\n {/* Summary header */}\n <div className=\"flex items-center gap-2 border-b border-border/40 bg-muted px-2.5 py-1.5 text-xs text-muted-foreground\">\n <IconFiles className=\"h-3.5 w-3.5 shrink-0\" />\n <span className=\"font-medium text-foreground\">\n {entries.length} file{entries.length === 1 ? \"\" : \"s\"} changed\n </span>\n <span className=\"ml-auto flex items-center gap-1.5\">\n {totalAdded > 0 && (\n <span className=\"text-[10px] font-semibold text-emerald-600 dark:text-emerald-400\">\n +{totalAdded}\n </span>\n )}\n {totalRemoved > 0 && (\n <span className=\"text-[10px] font-semibold text-destructive\">\n -{totalRemoved}\n </span>\n )}\n </span>\n </div>\n\n {/* Per-file rows */}\n {entries.map((entry) => {\n const key = `${entry.kind}:${entry.filePath}`;\n const isExpanded = expanded.has(key);\n const part = parts[entry.partIndex];\n\n return (\n <div key={key} className=\"border-b border-border/30 last:border-b-0\">\n <button\n type=\"button\"\n onClick={() => toggle(key)}\n className=\"flex w-full cursor-pointer items-center gap-2 px-2.5 py-1 text-left text-[11px] hover:bg-accent\"\n >\n <span\n className={cn(\n \"inline-block h-1.5 w-1.5 shrink-0 rounded-full\",\n entry.kind === \"write\" ? \"bg-emerald-500\" : \"bg-amber-500\",\n )}\n />\n <span className=\"min-w-0 flex-1 truncate font-mono text-foreground\">\n {entry.filePath}\n </span>\n <span className=\"ml-auto flex shrink-0 items-center gap-1\">\n {entry.added > 0 && (\n <span className=\"text-[10px] font-semibold text-emerald-600 dark:text-emerald-400\">\n +{entry.added}\n </span>\n )}\n {entry.removed > 0 && (\n <span className=\"text-[10px] font-semibold text-destructive\">\n -{entry.removed}\n </span>\n )}\n </span>\n </button>\n\n <AnimatedCollapse open={isExpanded}>\n {part.type === \"tool-call\" && part.structuredMeta && (\n <div className=\"pl-4\">\n {entry.kind === \"edit\" ? (\n <EditCell\n meta={\n part.structuredMeta as unknown as Parameters<\n typeof EditCell\n >[0][\"meta\"]\n }\n isRunning={false}\n />\n ) : (\n <WriteCell\n meta={\n part.structuredMeta as unknown as Parameters<\n typeof WriteCell\n >[0][\"meta\"]\n }\n isRunning={false}\n />\n )}\n </div>\n )}\n </AnimatedCollapse>\n </div>\n );\n })}\n </div>\n );\n});\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WriteCell.d.ts","sourceRoot":"","sources":["../../../src/client/tool-cells/WriteCell.tsx"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"WriteCell.d.ts","sourceRoot":"","sources":["../../../src/client/tool-cells/WriteCell.tsx"],"names":[],"mappings":"AAAA;;GAEG;AAYH,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,UAAU,cAAc;IACtB,IAAI,EAAE,aAAa,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;CACpB;AAyCD,wBAAgB,SAAS,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,cAAc,+BA8E5D"}
|
|
@@ -4,6 +4,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
4
4
|
*/
|
|
5
5
|
import { IconChevronDown, IconFilePlus, IconLoader2, } from "@tabler/icons-react";
|
|
6
6
|
import { memo, useState } from "react";
|
|
7
|
+
import { AnimatedCollapse } from "../chat/tool-call-display.js";
|
|
7
8
|
import { cn } from "../utils.js";
|
|
8
9
|
const MAX_COLLAPSED_LINES = 40;
|
|
9
10
|
const FileContentView = memo(function FileContentView({ content, maxLines, }) {
|
|
@@ -21,6 +22,6 @@ export function WriteCell({ meta, isRunning }) {
|
|
|
21
22
|
const hiddenLines = maxCollapsed !== null ? totalLines - MAX_COLLAPSED_LINES : 0;
|
|
22
23
|
return (_jsxs("div", { className: "my-1 overflow-hidden rounded-md border border-border/60", children: [_jsxs("button", { type: "button", onClick: () => hasContent && setExpanded((e) => !e), className: cn("flex w-full items-center gap-2 px-2.5 py-1.5 text-left text-xs font-mono", isRunning
|
|
23
24
|
? "bg-muted text-muted-foreground"
|
|
24
|
-
: "bg-muted text-muted-foreground hover:bg-accent", hasContent && "cursor-pointer", !hasContent && "cursor-default"), "aria-expanded": hasContent ? expanded : undefined, children: [_jsx("span", { className: "shrink-0", children: isRunning ? (_jsx(IconLoader2, { className: "h-3 w-3 animate-spin" })) : (_jsx(IconFilePlus, { className: "h-3 w-3 text-emerald-500" })) }), _jsx("span", { className: "min-w-0 flex-1 truncate font-medium text-foreground", children: meta.filePath }), _jsxs("span", { className: "ml-auto flex shrink-0 items-center gap-1.5", children: [meta.lineCount !== undefined && !isRunning && (_jsxs("span", { className: "text-[10px] font-semibold text-emerald-600 dark:text-emerald-400", children: ["+", meta.lineCount] })), meta.truncated && (_jsx("span", { className: "text-[10px] text-muted-foreground", children: "(partial)" })), hasContent && (_jsx(IconChevronDown, { className: cn("h-3 w-3 opacity-40", expanded && "rotate-180") }))] })] }), expanded && hasContent
|
|
25
|
+
: "bg-muted text-muted-foreground hover:bg-accent", hasContent && "cursor-pointer", !hasContent && "cursor-default"), "aria-expanded": hasContent ? expanded : undefined, children: [_jsx("span", { className: "shrink-0", children: isRunning ? (_jsx(IconLoader2, { className: "h-3 w-3 animate-spin" })) : (_jsx(IconFilePlus, { className: "h-3 w-3 text-emerald-500" })) }), _jsx("span", { className: "min-w-0 flex-1 truncate font-medium text-foreground", children: meta.filePath }), _jsxs("span", { className: "ml-auto flex shrink-0 items-center gap-1.5", children: [meta.lineCount !== undefined && !isRunning && (_jsxs("span", { className: "text-[10px] font-semibold text-emerald-600 dark:text-emerald-400", children: ["+", meta.lineCount] })), meta.truncated && (_jsx("span", { className: "text-[10px] text-muted-foreground", children: "(partial)" })), hasContent && (_jsx(IconChevronDown, { className: cn("h-3 w-3 opacity-40", expanded && "rotate-180") }))] })] }), _jsx(AnimatedCollapse, { open: expanded && hasContent, children: meta.content && (_jsxs("div", { className: "border-t border-border/40 bg-background", children: [_jsx(FileContentView, { content: meta.content, maxLines: maxCollapsed }), hiddenLines > 0 && (_jsx("div", { className: "border-t border-border/40 px-3 py-1 text-[11px] text-muted-foreground", children: _jsxs("button", { type: "button", className: "cursor-pointer underline hover:text-foreground", onClick: () => setShowAll(true), children: ["Show ", hiddenLines, " more lines"] }) }))] })) })] }));
|
|
25
26
|
}
|
|
26
27
|
//# sourceMappingURL=WriteCell.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WriteCell.js","sourceRoot":"","sources":["../../../src/client/tool-cells/WriteCell.tsx"],"names":[],"mappings":";AAAA;;GAEG;AAEH,OAAO,EACL,eAAe,EACf,YAAY,EACZ,WAAW,GACZ,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAejC,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAE/B,MAAM,eAAe,GAAG,IAAI,CAAC,SAAS,eAAe,CAAC,EACpD,OAAO,EACP,QAAQ,GAIT;IACC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAClC,MAAM,OAAO,GAAG,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,E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AS,IAAI,CAC7C,gBAAM,SAAS,EAAC,kEAAkE,kBAC9E,IAAI,CAAC,SAAS,IACX,CACR,EACA,IAAI,CAAC,SAAS,IAAI,CACjB,eAAM,SAAS,EAAC,mCAAmC,0BAAiB,CACrE,EACA,UAAU,IAAI,CACb,KAAC,eAAe,IACd,SAAS,EAAE,EAAE,CAAC,oBAAoB,EAAE,QAAQ,IAAI,YAAY,CAAC,GAC7D,CACH,IACI,IACA,EAGT,KAAC,gBAAgB,IAAC,IAAI,EAAE,QAAQ,IAAI,UAAU,YAC3C,IAAI,CAAC,OAAO,IAAI,CACf,eAAK,SAAS,EAAC,yCAAyC,aACtD,KAAC,eAAe,IAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,QAAQ,EAAE,YAAY,GAAI,EACjE,WAAW,GAAG,CAAC,IAAI,CAClB,cAAK,SAAS,EAAC,uEAAuE,YACpF,kBACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,gDAAgD,EAC1D,OAAO,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,sBAEzB,WAAW,mBACV,GACL,CACP,IACG,CACP,GACgB,IACf,CACP,CAAC;AACJ,CAAC","sourcesContent":["/**\n * WriteCell — renders a write tool call as a new-file view with added-line styling.\n */\n\nimport {\n IconChevronDown,\n IconFilePlus,\n IconLoader2,\n} from \"@tabler/icons-react\";\nimport { memo, useState } from \"react\";\n\nimport { AnimatedCollapse } from \"../chat/tool-call-display.js\";\nimport { cn } from \"../utils.js\";\n\nexport interface WriteCellMeta {\n toolKind: \"write\";\n filePath: string;\n content?: string;\n truncated?: boolean;\n lineCount?: number;\n}\n\ninterface WriteCellProps {\n meta: WriteCellMeta;\n isRunning: boolean;\n}\n\nconst MAX_COLLAPSED_LINES = 40;\n\nconst FileContentView = memo(function FileContentView({\n content,\n maxLines,\n}: {\n content: string;\n maxLines: number | null;\n}) {\n const lines = content.split(\"\\n\");\n const visible = maxLines !== null ? lines.slice(0, maxLines) : lines;\n\n return (\n <div className=\"overflow-x-auto\">\n <table className=\"w-full min-w-full border-collapse font-mono text-[11px] leading-relaxed\">\n <tbody>\n {visible.map((line, idx) => (\n <tr key={idx} className=\"bg-emerald-500/8 dark:bg-emerald-400/8\">\n <td className=\"w-8 select-none border-r border-border/30 px-1.5 text-right text-[10px] text-muted-foreground/60\">\n {idx + 1}\n </td>\n <td className=\"w-4 select-none text-center text-[10px] font-bold text-emerald-600 dark:text-emerald-400\">\n +\n </td>\n <td className=\"px-2 text-emerald-800 dark:text-emerald-200\">\n <span\n style={{ whiteSpace: \"pre-wrap\", wordBreak: \"break-all\" }}\n >\n {line}\n </span>\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n );\n});\n\nexport function WriteCell({ meta, isRunning }: WriteCellProps) {\n const [expanded, setExpanded] = useState(false);\n const [showAll, setShowAll] = useState(false);\n\n const hasContent = Boolean(meta.content);\n const lines = meta.content ? meta.content.split(\"\\n\") : [];\n const totalLines = lines.length;\n const maxCollapsed =\n showAll || totalLines <= MAX_COLLAPSED_LINES ? null : MAX_COLLAPSED_LINES;\n const hiddenLines =\n maxCollapsed !== null ? totalLines - MAX_COLLAPSED_LINES : 0;\n\n return (\n <div className=\"my-1 overflow-hidden rounded-md border border-border/60\">\n {/* Header */}\n <button\n type=\"button\"\n onClick={() => hasContent && setExpanded((e) => !e)}\n className={cn(\n \"flex w-full items-center gap-2 px-2.5 py-1.5 text-left text-xs font-mono\",\n isRunning\n ? \"bg-muted text-muted-foreground\"\n : \"bg-muted text-muted-foreground hover:bg-accent\",\n hasContent && \"cursor-pointer\",\n !hasContent && \"cursor-default\",\n )}\n aria-expanded={hasContent ? expanded : undefined}\n >\n <span className=\"shrink-0\">\n {isRunning ? (\n <IconLoader2 className=\"h-3 w-3 animate-spin\" />\n ) : (\n <IconFilePlus className=\"h-3 w-3 text-emerald-500\" />\n )}\n </span>\n\n <span className=\"min-w-0 flex-1 truncate font-medium text-foreground\">\n {meta.filePath}\n </span>\n\n <span className=\"ml-auto flex shrink-0 items-center gap-1.5\">\n {meta.lineCount !== undefined && !isRunning && (\n <span className=\"text-[10px] font-semibold text-emerald-600 dark:text-emerald-400\">\n +{meta.lineCount}\n </span>\n )}\n {meta.truncated && (\n <span className=\"text-[10px] text-muted-foreground\">(partial)</span>\n )}\n {hasContent && (\n <IconChevronDown\n className={cn(\"h-3 w-3 opacity-40\", expanded && \"rotate-180\")}\n />\n )}\n </span>\n </button>\n\n {/* Content body */}\n <AnimatedCollapse open={expanded && hasContent}>\n {meta.content && (\n <div className=\"border-t border-border/40 bg-background\">\n <FileContentView content={meta.content} maxLines={maxCollapsed} />\n {hiddenLines > 0 && (\n <div className=\"border-t border-border/40 px-3 py-1 text-[11px] text-muted-foreground\">\n <button\n type=\"button\"\n className=\"cursor-pointer underline hover:text-foreground\"\n onClick={() => setShowAll(true)}\n >\n Show {hiddenLines} more lines\n </button>\n </div>\n )}\n </div>\n )}\n </AnimatedCollapse>\n </div>\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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E,KAAK,EACjB,MAAM,CAAC,EAAE,YAAY,CAAC,KAAK,CAAC,EAC5B,OAAO,GAAE,IAAI,CAAC,uBAAuB,EAAE,QAAQ,CAAM,GACpD,yBAAyB,CAC1B,OAAO,SAAS,SAAS,GAAG,YAAY,CAAC,KAAK,CAAC,GAAG,OAAO,CAC1D,CAwCA;AAMD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAC5B,OAAO,GAAG,SAAS,EACnB,KAAK,SAAS,UAAU,GAAG,UAAU,EAErC,UAAU,EAAE,KAAK,EACjB,MAAM,CAAC,EAAE,YAAY,CAAC,KAAK,CAAC,EAC5B,OAAO,CAAC,EAAE,IAAI,CACZ,eAAe,CAAC,OAAO,SAAS,SAAS,GAAG,YAAY,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,EAC1E,UAAU,GAAG,SAAS,CACvB,6HAcF;AAMD;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,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;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AyE;QACzE,0EAA0E;QAC1E,qEAAqE;QACrE,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CACtB,WAAW,CAAI,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC;QACvD,KAAK,EAAE,uBAAuB;QAC9B,UAAU,EAAE,4BAA4B;QACxC,GAAG,OAAO;KACX,CAAC,CAAC;AACL,CAAC;AAED,8EAA8E;AAC9E,gBAAgB;AAChB,8EAA8E;AAE9E;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,iBAAiB,CAK/B,UAAiB,EACjB,OAUC;IAED,MAAM,WAAW,GAAG,cAAc,EAAE,CAAC;IACrC,MAAM,EACJ,MAAM,EAAE,SAAS,EACjB,SAAS,EACT,2BAA2B,GAAG,KAAK,EACnC,GAAG,WAAW,EACf,GAAG,OAAO,IAAK,EAAU,CAAC;IAC3B,MAAM,MAAM,GAAG,SAAS,IAAI,MAAM,CAAC;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,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,2BA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AM,UAAU,iBAAiB,CAK/B,UAAiB,EACjB,OAUC;IAED,MAAM,WAAW,GAAG,cAAc,EAAE,CAAC;IACrC,MAAM,EACJ,MAAM,EAAE,SAAS,EACjB,SAAS,EACT,2BAA2B,GAAG,KAAK,EACnC,GAAG,WAAW,EACf,GAAG,OAAO,IAAK,EAAU,CAAC;IAC3B,MAAM,MAAM,GAAG,SAAS,IAAI,MAAM,CAAC;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 { 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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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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AAC,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"}
|