@agent-native/core 0.97.0 → 0.98.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/corpus/README.md +2 -2
- package/corpus/core/CHANGELOG.md +32 -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 +5 -1
- package/corpus/core/scripts/finalize-build.mjs +63 -3
- package/corpus/core/scripts/materialize-source-corpus.mjs +101 -15
- 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/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 +6 -5
- package/corpus/core/src/client/CommandMenu.tsx +16 -5
- package/corpus/core/src/client/FeedbackButton.tsx +2 -2
- package/corpus/core/src/client/app-providers.tsx +18 -5
- package/corpus/core/src/client/chat/tool-call-display.tsx +3 -3
- package/corpus/core/src/client/composer/PastedTextChip.tsx +1 -1
- package/corpus/core/src/client/composer/RealtimeVoiceMode.tsx +143 -45
- package/corpus/core/src/client/composer/TiptapComposer.tsx +1 -1
- package/corpus/core/src/client/composer/VoiceButton.tsx +21 -5
- package/corpus/core/src/client/composer/useRealtimeVoiceMode.tsx +107 -10
- 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 +0 -13
- package/corpus/core/src/client/progress/RunsTray.tsx +10 -3
- 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/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/webhook-handler.ts +27 -2
- package/corpus/core/src/jobs/scheduler.ts +28 -2
- package/corpus/core/src/localization/default-messages.ts +8 -1
- package/corpus/core/src/mcp/oauth-token.ts +6 -1
- 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/storage.ts +67 -3
- 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/realtime-voice.ts +40 -5
- 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 +15 -14
- package/corpus/core/src/templates/default/.agents/skills/frontend-design/SKILL.md +1 -1
- 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/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 +126 -2
- 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.md +19 -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/rename-analysis.ts +8 -2
- package/corpus/templates/analytics/actions/rename-dashboard.ts +8 -7
- package/corpus/templates/analytics/actions/view-screen.ts +4 -23
- package/corpus/templates/analytics/app/components/ResourceLoadError.tsx +42 -0
- package/corpus/templates/analytics/app/components/layout/CommandPalette.tsx +85 -70
- package/corpus/templates/analytics/app/components/layout/Sidebar.tsx +107 -89
- package/corpus/templates/analytics/app/components/layout/SidebarLoadError.tsx +24 -0
- 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/pages/Settings.tsx +6 -2
- 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/root.tsx +13 -1
- package/corpus/templates/analytics/app/routes/_index.tsx +14 -2
- package/corpus/templates/analytics/changelog/2026-07-03-agent-llm-observability-dashboard.md +1 -1
- 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-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-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-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/seeds/dashboards/agent-native-templates-first-party.json +339 -1
- 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 +4 -1
- package/corpus/templates/analytics/server/plugins/agent-chat.ts +11 -39
- package/corpus/templates/assets/.agents/skills/frontend-design/SKILL.md +1 -1
- package/corpus/templates/assets/app/components/create/RecentDraftsSection.tsx +30 -4
- package/corpus/templates/assets/app/routes/library.tsx +49 -5
- 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/calendar/.agents/skills/frontend-design/SKILL.md +1 -1
- 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/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/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/root.tsx +4 -0
- package/corpus/templates/clips/app/routes/_app.notifications.tsx +23 -2
- 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-recording-overlays-are-lighter-weight-and-no-longer-cause-pa.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/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/root.tsx +2 -2
- package/corpus/templates/content/app/routes/_app._index.tsx +11 -1
- 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/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/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/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/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/.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/root.tsx +8 -10
- 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/.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/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 +152 -4
- 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/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 +33 -10
- package/corpus/templates/slides/app/components/editor/EditorSidebar.tsx +1 -1
- package/corpus/templates/slides/app/components/editor/EditorToolbar.tsx +1 -1
- package/corpus/templates/slides/app/components/editor/GenerateSlidesDialog.tsx +2 -2
- 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 +9 -0
- 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-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.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/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 +4 -2
- package/dist/client/AgentPanel.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/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/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/composer/PastedTextChip.js +1 -1
- package/dist/client/composer/PastedTextChip.js.map +1 -1
- package/dist/client/composer/RealtimeVoiceMode.d.ts +3 -1
- package/dist/client/composer/RealtimeVoiceMode.d.ts.map +1 -1
- package/dist/client/composer/RealtimeVoiceMode.js +35 -14
- package/dist/client/composer/RealtimeVoiceMode.js.map +1 -1
- package/dist/client/composer/TiptapComposer.js +1 -1
- 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/useRealtimeVoiceMode.d.ts +5 -0
- package/dist/client/composer/useRealtimeVoiceMode.d.ts.map +1 -1
- package/dist/client/composer/useRealtimeVoiceMode.js +91 -12
- 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 +0 -2
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +0 -5
- package/dist/client/index.js.map +1 -1
- package/dist/client/progress/RunsTray.d.ts.map +1 -1
- package/dist/client/progress/RunsTray.js +7 -3
- package/dist/client/progress/RunsTray.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/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/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 +7 -0
- package/dist/localization/default-messages.d.ts.map +1 -1
- package/dist/localization/default-messages.js +8 -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/notifications/routes.d.ts +2 -2
- 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/provider-api/corpus-jobs.d.ts +2 -2
- package/dist/resources/handlers.d.ts +1 -1
- 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/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-engine-api-key-route.d.ts +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/realtime-voice.d.ts +3 -0
- package/dist/server/realtime-voice.d.ts.map +1 -1
- package/dist/server/realtime-voice.js +29 -5
- 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 +15 -14
- package/dist/templates/default/.agents/skills/frontend-design/SKILL.md +1 -1
- package/dist/templates/default/app/i18n/ar-SA.ts +6 -0
- package/dist/templates/default/app/i18n/de-DE.ts +6 -0
- package/dist/templates/default/app/i18n/en-US.ts +6 -0
- package/dist/templates/default/app/i18n/es-ES.ts +6 -0
- package/dist/templates/default/app/i18n/fr-FR.ts +6 -0
- package/dist/templates/default/app/i18n/hi-IN.ts +6 -0
- package/dist/templates/default/app/i18n/ja-JP.ts +6 -0
- package/dist/templates/default/app/i18n/ko-KR.ts +6 -0
- package/dist/templates/default/app/i18n/pt-BR.ts +6 -0
- package/dist/templates/default/app/i18n/zh-CN.ts +6 -0
- package/dist/templates/default/app/i18n/zh-TW.ts +6 -0
- package/dist/templates/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/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 +105 -2
- 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 +6 -2
- package/src/templates/default/.agents/skills/frontend-design/SKILL.md +1 -1
- package/src/templates/default/app/i18n/ar-SA.ts +6 -0
- package/src/templates/default/app/i18n/de-DE.ts +6 -0
- package/src/templates/default/app/i18n/en-US.ts +6 -0
- package/src/templates/default/app/i18n/es-ES.ts +6 -0
- package/src/templates/default/app/i18n/fr-FR.ts +6 -0
- package/src/templates/default/app/i18n/hi-IN.ts +6 -0
- package/src/templates/default/app/i18n/ja-JP.ts +6 -0
- package/src/templates/default/app/i18n/ko-KR.ts +6 -0
- package/src/templates/default/app/i18n/pt-BR.ts +6 -0
- package/src/templates/default/app/i18n/zh-CN.ts +6 -0
- package/src/templates/default/app/i18n/zh-TW.ts +6 -0
- package/src/templates/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/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":"useRealtimeVoiceMode.js","sourceRoot":"","sources":["../../../src/client/composer/useRealtimeVoiceMode.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,aAAa,EACb,WAAW,EACX,UAAU,EACV,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,GAET,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EACL,0BAA0B,GAE3B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAClC,OAAO,EACL,kCAAkC,EAClC,yBAAyB,EACzB,wBAAwB,GAEzB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,+BAA+B,EAAE,MAAM,gCAAgC,CAAC;AACjF,OAAO,EACL,qBAAqB,GAGtB,MAAM,wBAAwB,CAAC;AAEhC,MAAM,wBAAwB,GAAG,wBAAwB,CAAC;AAC1D,MAAM,6BAA6B,GAAG,gBAAgB,CAAC;AACvD,MAAM,2BAA2B,GAAG,uCAAuC,CAAC;AAC5E,MAAM,wBAAwB,GAAG,oCAAoC,CAAC;AA4BtE;;;;GAIG;AACH,MAAM,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,CAAC;AACJ,CAAC;AAED,gFAAgF;AAChF,SAAS,gCAAgC,CAAC,EACxC,QAAQ,GACyC;IACjD,MAAM,KAAK,GAAG,4BAA4B,EAAE,CAAC;IAC7C,IAAI,KAAK,EAAE,MAAM,IAAI,CAAC,KAAK,CAAC,WAAW;QAAE,OAAO,IAAI,CAAC;IACrD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,oBAAoB;IAClC,MAAM,KAAK,GAAG,UAAU,CAAC,wBAAwB,CAAC,CAAC;IACnD,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CACb,qEAAqE,CACtE,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,4BAA4B;IAC1C,OAAO,UAAU,CAAC,wBAAwB,CAAC,CAAC;AAC9C,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,wBAAwB;IAI5C,MAAM,CAAC,UAAU,EAAE,GAAG,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QAC1C,kBAAkB,CAAC,YAAY,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC;QAClD,kBAAkB,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC;KAChD,CAAC,CAAC;IACH,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC;AAC7B,CAAC","sourcesContent":["import {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n type ReactNode,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\n\nimport { requestAgentChatThreadOpen } from \"../agent-chat.js\";\nimport {\n SIDEBAR_STATE_CHANGE_EVENT,\n type AgentSidebarStateChangeDetail,\n} from \"../agent-sidebar-state.js\";\nimport { agentNativePath } from \"../api-path.js\";\nimport { readClientAppState, setClientAppState } from \"../application-state.js\";\nimport { getBrowserTabId } from \"../browser-tab-id.js\";\nimport { useT } from \"../i18n.js\";\nimport {\n createRealtimeVoiceAudioLevelStore,\n normalizeRealtimeVoiceRms,\n smoothRealtimeVoiceLevel,\n type RealtimeVoiceAudioLevelStore,\n} from \"./realtime-voice-audio-level.js\";\nimport { realtimeVoiceTranscriptRegistry } from \"./realtime-voice-transcript.js\";\nimport {\n RealtimeVoiceModeDock,\n type RealtimeVoiceModeCopy,\n type RealtimeVoiceModeState,\n} from \"./RealtimeVoiceMode.js\";\n\nconst REALTIME_VOICE_STATE_KEY = \"realtime-voice-session\";\nconst REALTIME_VOICE_REQUEST_SOURCE = \"realtime-voice\";\nconst REALTIME_VOICE_SESSION_PATH = \"/_agent-native/realtime-voice/session\";\nconst REALTIME_VOICE_TOOL_PATH = \"/_agent-native/realtime-voice/tool\";\n\ntype RealtimeServerEvent = Record<string, unknown> & { type?: string };\n\nexport interface RealtimeVoiceToolResult {\n callId: string;\n status: \"completed\" | \"failed\" | \"approval_required\";\n output: string;\n approvalKey?: string;\n}\n\nexport interface RealtimeVoiceModeApi {\n state: \"idle\" | RealtimeVoiceModeState;\n active: boolean;\n errorMessage: string | null;\n chatVisible: boolean;\n audioLevels: RealtimeVoiceAudioLevelStore;\n start: () => Promise<void>;\n end: () => void;\n toggleChat: () => void;\n}\n\nexport interface CompletedRealtimeVoiceTranscript {\n role: \"user\" | \"assistant\";\n text: string;\n providerId?: string;\n}\n\n/**\n * Voice mode owns the chat only temporarily. Restore the captured transcript\n * when it is still the user's active thread (or the chat has no active thread)\n * but never pull them back after they deliberately selected another thread.\n */\nexport function shouldRestoreRealtimeVoiceTranscriptThread(\n transcriptThreadId: string | undefined,\n activeThreadId: string | undefined,\n): transcriptThreadId is string {\n return Boolean(\n transcriptThreadId &&\n (!activeThreadId || activeThreadId === transcriptThreadId),\n );\n}\n\nexport function extractCompletedRealtimeVoiceTranscript(\n event: RealtimeServerEvent,\n): CompletedRealtimeVoiceTranscript | null {\n const userCompleted =\n event.type === \"conversation.item.input_audio_transcription.completed\";\n const assistantCompleted =\n event.type === \"response.output_audio_transcript.done\";\n if (!userCompleted && !assistantCompleted) return null;\n const text =\n typeof event.transcript === \"string\" ? event.transcript.trim() : \"\";\n if (!text) return null;\n const providerId = [event.item_id, event.response_id, event.event_id].find(\n (value): value is string => typeof value === \"string\" && value.length > 0,\n );\n return {\n role: userCompleted ? \"user\" : \"assistant\",\n text,\n ...(providerId ? { providerId } : {}),\n };\n}\n\nexport interface RealtimeVoiceModeProviderProps {\n children: ReactNode;\n browserTabId?: string;\n}\n\nfunction errorMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\nasync function readErrorResponse(response: Response): Promise<string> {\n const raw = await response.text().catch(() => \"\");\n if (!raw) return response.statusText || `HTTP ${response.status}`;\n try {\n const parsed = JSON.parse(raw) as { error?: unknown; message?: unknown };\n return String(parsed.error ?? parsed.message ?? raw);\n } catch {\n return raw.slice(0, 500);\n }\n}\n\nexport async function createRealtimeVoiceSession(\n offerSdp: string,\n options: { browserTabId?: string; signal?: AbortSignal } = {},\n): Promise<string> {\n const response = await fetch(agentNativePath(REALTIME_VOICE_SESSION_PATH), {\n method: \"POST\",\n credentials: \"same-origin\",\n headers: {\n \"Content-Type\": \"application/sdp\",\n ...(options.browserTabId\n ? { \"X-Agent-Native-Browser-Tab\": options.browserTabId }\n : {}),\n },\n body: offerSdp,\n signal: options.signal,\n });\n if (!response.ok) {\n const message = await readErrorResponse(response);\n const error = new Error(message);\n (error as { status?: number }).status = response.status;\n throw error;\n }\n return response.text();\n}\n\nexport async function executeRealtimeVoiceTool(input: {\n name: string;\n args: Record<string, unknown>;\n callId: string;\n sessionId?: string;\n browserTabId?: string;\n signal?: AbortSignal;\n}): Promise<RealtimeVoiceToolResult> {\n const response = await fetch(agentNativePath(REALTIME_VOICE_TOOL_PATH), {\n method: \"POST\",\n credentials: \"same-origin\",\n headers: {\n \"Content-Type\": \"application/json\",\n ...(input.browserTabId\n ? { \"X-Agent-Native-Browser-Tab\": input.browserTabId }\n : {}),\n },\n body: JSON.stringify({\n name: input.name,\n args: input.args,\n callId: input.callId,\n sessionId: input.sessionId,\n browserTabId: input.browserTabId,\n }),\n signal: input.signal,\n });\n if (!response.ok) {\n throw new Error(await readErrorResponse(response));\n }\n return (await response.json()) as RealtimeVoiceToolResult;\n}\n\nexport function extractRealtimeVoiceFunctionCalls(\n event: RealtimeServerEvent,\n): Array<{ name: string; callId: string; argumentsText: string }> {\n if (event.type === \"response.function_call_arguments.done\") {\n const name = typeof event.name === \"string\" ? event.name : \"\";\n const callId = typeof event.call_id === \"string\" ? event.call_id : \"\";\n if (!name || !callId) return [];\n return [\n {\n name,\n callId,\n argumentsText:\n typeof event.arguments === \"string\" ? event.arguments : \"{}\",\n },\n ];\n }\n if (event.type !== \"response.done\") return [];\n const response = event.response;\n if (!response || typeof response !== \"object\") return [];\n const output = (response as { output?: unknown }).output;\n if (!Array.isArray(output)) return [];\n return output.flatMap((item) => {\n if (!item || typeof item !== \"object\") return [];\n const record = item as Record<string, unknown>;\n if (record.type !== \"function_call\") return [];\n const name = typeof record.name === \"string\" ? record.name : \"\";\n const callId = typeof record.call_id === \"string\" ? record.call_id : \"\";\n if (!name || !callId) return [];\n return [\n {\n name,\n callId,\n argumentsText:\n typeof record.arguments === \"string\" ? record.arguments : \"{}\",\n },\n ];\n });\n}\n\nfunction parseFunctionArguments(text: string): Record<string, unknown> {\n const parsed = JSON.parse(text || \"{}\");\n if (!parsed || typeof parsed !== \"object\" || Array.isArray(parsed)) {\n throw new Error(\"The voice model returned invalid tool arguments.\");\n }\n return parsed as Record<string, unknown>;\n}\n\nfunction sendDataChannelEvent(\n channel: RTCDataChannel | null,\n event: Record<string, unknown>,\n): void {\n if (!channel || channel.readyState !== \"open\") return;\n channel.send(JSON.stringify(event));\n}\n\nfunction openOpenAiKeySettings(): void {\n if (typeof window === \"undefined\") return;\n window.location.hash = \"#secrets:OPENAI_API_KEY\";\n window.dispatchEvent(new Event(\"agent-panel:open\"));\n window.dispatchEvent(\n new CustomEvent(\"agent-panel:open-settings\", {\n detail: { section: \"secrets\" },\n }),\n );\n}\n\nfunction voiceCopy(t: ReturnType<typeof useT>): RealtimeVoiceModeCopy {\n return {\n entryButtonLabel: t(\"agentPanel.voiceMode.entryButtonLabel\"),\n promptTitle: t(\"agentPanel.voiceMode.promptTitle\"),\n promptDescription: t(\"agentPanel.voiceMode.promptDescription\"),\n setupTitle: t(\"agentPanel.voiceMode.setupTitle\"),\n setupDescription: t(\"agentPanel.voiceMode.setupDescription\"),\n connectBuilder: t(\"agentPanel.voiceMode.connectBuilder\"),\n useOpenAiKey: t(\"agentPanel.voiceMode.useOpenAiKey\"),\n startWithOpenAiKey: t(\"agentPanel.voiceMode.startWithOpenAiKey\"),\n startVoiceMode: t(\"agentPanel.voiceMode.start\"),\n keepDictating: t(\"agentPanel.voiceMode.keepDictating\"),\n showChat: t(\"agentPanel.voiceMode.showChat\"),\n hideChat: t(\"agentPanel.voiceMode.hideChat\"),\n endVoiceMode: t(\"agentPanel.voiceMode.end\"),\n status: {\n connecting: t(\"agentPanel.voiceMode.status.connecting\"),\n listening: t(\"agentPanel.voiceMode.status.listening\"),\n speaking: t(\"agentPanel.voiceMode.status.speaking\"),\n working: t(\"agentPanel.voiceMode.status.working\"),\n error: t(\"agentPanel.voiceMode.status.error\"),\n ending: t(\"agentPanel.voiceMode.status.ending\"),\n },\n errors: {\n unsupported: t(\"agentPanel.voiceMode.errors.unsupported\"),\n responseFailed: t(\"agentPanel.voiceMode.errors.responseFailed\"),\n sessionFailed: t(\"agentPanel.voiceMode.errors.sessionFailed\"),\n channelDisconnected: t(\"agentPanel.voiceMode.errors.channelDisconnected\"),\n connectionFailed: t(\"agentPanel.voiceMode.errors.connectionFailed\"),\n offerFailed: t(\"agentPanel.voiceMode.errors.offerFailed\"),\n },\n };\n}\n\nexport function useRealtimeVoiceModeCopy(): RealtimeVoiceModeCopy {\n const t = useT();\n return useMemo(() => voiceCopy(t), [t]);\n}\n\nfunction useRealtimeVoiceModeController(\n browserTabId?: string,\n copy?: RealtimeVoiceModeCopy,\n): RealtimeVoiceModeApi {\n const [state, setState] = useState<\"idle\" | RealtimeVoiceModeState>(\"idle\");\n const [error, setError] = useState<string | null>(null);\n const [chatVisible, setChatVisible] = useState(false);\n const [audioLevels] = useState(createRealtimeVoiceAudioLevelStore);\n const stateRef = useRef(state);\n const peerRef = useRef<RTCPeerConnection | null>(null);\n const channelRef = useRef<RTCDataChannel | null>(null);\n const streamRef = useRef<MediaStream | null>(null);\n const audioRef = useRef<HTMLAudioElement | null>(null);\n const audioContextRef = useRef<AudioContext | null>(null);\n const inputAnalyserRef = useRef<AnalyserNode | null>(null);\n const outputAnalyserRef = useRef<AnalyserNode | null>(null);\n const inputMeterBufferRef = useRef<Uint8Array<ArrayBuffer> | null>(null);\n const outputMeterBufferRef = useRef<Uint8Array<ArrayBuffer> | null>(null);\n const inputSourceRef = useRef<MediaStreamAudioSourceNode | null>(null);\n const outputSourceRef = useRef<MediaStreamAudioSourceNode | null>(null);\n const meterFrameRef = useRef<number | null>(null);\n const lastMeterSampleRef = useRef(0);\n const abortRef = useRef<AbortController | null>(null);\n const handledCallsRef = useRef(new Set<string>());\n const sessionIdRef = useRef<string | undefined>(undefined);\n const startedAtRef = useRef<string | undefined>(undefined);\n const lastUserTextRef = useRef(\"\");\n const lastAssistantTextRef = useRef(\"\");\n const transcriptThreadIdRef = useRef<string | undefined>(undefined);\n const transcriptSequenceRef = useRef(0);\n\n useEffect(() => {\n stateRef.current = state;\n }, [state]);\n\n const syncAppState = useCallback(\n (nextState: \"idle\" | RealtimeVoiceModeState) => {\n const value =\n nextState === \"idle\"\n ? null\n : {\n active: true,\n status: nextState,\n model: \"gpt-realtime-2.1\",\n startedAt: startedAtRef.current,\n sessionId: sessionIdRef.current,\n browserTabId,\n lastUserText: lastUserTextRef.current || undefined,\n lastAssistantText: lastAssistantTextRef.current || undefined,\n };\n void setClientAppState(REALTIME_VOICE_STATE_KEY, value, {\n requestSource: REALTIME_VOICE_REQUEST_SOURCE,\n }).catch(() => undefined);\n },\n [browserTabId],\n );\n\n const transition = useCallback(\n (nextState: \"idle\" | RealtimeVoiceModeState) => {\n stateRef.current = nextState;\n setState(nextState);\n syncAppState(nextState);\n },\n [syncAppState],\n );\n\n const startMeterLoop = useCallback(() => {\n if (meterFrameRef.current !== null) return;\n const sample = (timestamp: number) => {\n meterFrameRef.current = requestAnimationFrame(sample);\n if (timestamp - lastMeterSampleRef.current < 50) return;\n lastMeterSampleRef.current = timestamp;\n\n const current = audioLevels.getSnapshot();\n let input = current.input;\n let output = current.output;\n const inputAnalyser = inputAnalyserRef.current;\n const inputBuffer = inputMeterBufferRef.current;\n if (inputAnalyser && inputBuffer) {\n inputAnalyser.getByteTimeDomainData(inputBuffer);\n input = smoothRealtimeVoiceLevel(\n input,\n normalizeRealtimeVoiceRms(inputBuffer),\n );\n }\n const outputAnalyser = outputAnalyserRef.current;\n const outputBuffer = outputMeterBufferRef.current;\n if (outputAnalyser && outputBuffer) {\n outputAnalyser.getByteTimeDomainData(outputBuffer);\n output = smoothRealtimeVoiceLevel(\n output,\n normalizeRealtimeVoiceRms(outputBuffer),\n );\n }\n audioLevels.set({ input, output });\n };\n meterFrameRef.current = requestAnimationFrame(sample);\n }, [audioLevels]);\n\n const attachAudioMeter = useCallback(\n (stream: MediaStream, channel: \"input\" | \"output\") => {\n try {\n const AudioCtor =\n window.AudioContext ??\n (\n window as typeof window & {\n webkitAudioContext?: typeof AudioContext;\n }\n ).webkitAudioContext;\n if (!AudioCtor) return;\n const context = audioContextRef.current ?? new AudioCtor();\n audioContextRef.current = context;\n void context.resume().catch(() => undefined);\n const analyser = context.createAnalyser();\n analyser.fftSize = 512;\n const source = context.createMediaStreamSource(stream);\n source.connect(analyser);\n const buffer = new Uint8Array(analyser.frequencyBinCount);\n if (channel === \"input\") {\n inputSourceRef.current?.disconnect();\n inputSourceRef.current = source;\n inputAnalyserRef.current = analyser;\n inputMeterBufferRef.current = buffer;\n } else {\n outputSourceRef.current?.disconnect();\n outputSourceRef.current = source;\n outputAnalyserRef.current = analyser;\n outputMeterBufferRef.current = buffer;\n }\n startMeterLoop();\n } catch {\n // Audio metering is visual-only; keep the realtime call healthy.\n }\n },\n [startMeterLoop],\n );\n\n const cleanupTransport = useCallback(() => {\n abortRef.current?.abort();\n abortRef.current = null;\n channelRef.current?.close();\n channelRef.current = null;\n peerRef.current?.close();\n peerRef.current = null;\n for (const track of streamRef.current?.getTracks() ?? []) track.stop();\n streamRef.current = null;\n if (audioRef.current) {\n audioRef.current.pause();\n audioRef.current.srcObject = null;\n }\n audioRef.current = null;\n if (meterFrameRef.current !== null) {\n cancelAnimationFrame(meterFrameRef.current);\n meterFrameRef.current = null;\n }\n inputSourceRef.current?.disconnect();\n outputSourceRef.current?.disconnect();\n inputSourceRef.current = null;\n outputSourceRef.current = null;\n inputAnalyserRef.current = null;\n outputAnalyserRef.current = null;\n inputMeterBufferRef.current = null;\n outputMeterBufferRef.current = null;\n lastMeterSampleRef.current = 0;\n const audioContext = audioContextRef.current;\n audioContextRef.current = null;\n if (audioContext) void audioContext.close().catch(() => undefined);\n audioLevels.reset();\n handledCallsRef.current.clear();\n }, [audioLevels]);\n\n const fail = useCallback(\n (message: string, options?: { openKeySettings?: boolean }) => {\n cleanupTransport();\n setError(message);\n transition(\"error\");\n if (options?.openKeySettings) openOpenAiKeySettings();\n },\n [cleanupTransport, transition],\n );\n\n const handleFunctionCall = useCallback(\n async (call: { name: string; callId: string; argumentsText: string }) => {\n if (handledCallsRef.current.has(call.callId)) return;\n handledCallsRef.current.add(call.callId);\n transition(\"working\");\n let result: RealtimeVoiceToolResult;\n try {\n const args = parseFunctionArguments(call.argumentsText);\n result = await executeRealtimeVoiceTool({\n name: call.name,\n args,\n callId: call.callId,\n sessionId: sessionIdRef.current,\n browserTabId,\n signal: abortRef.current?.signal,\n });\n } catch (toolError) {\n result = {\n callId: call.callId,\n status: \"failed\",\n output: errorMessage(toolError),\n };\n }\n sendDataChannelEvent(channelRef.current, {\n type: \"conversation.item.create\",\n item: {\n type: \"function_call_output\",\n call_id: call.callId,\n output: JSON.stringify(result),\n },\n });\n sendDataChannelEvent(channelRef.current, { type: \"response.create\" });\n },\n [browserTabId, transition],\n );\n\n const persistCompletedTranscript = useCallback(\n (event: RealtimeServerEvent) => {\n const transcript = extractCompletedRealtimeVoiceTranscript(event);\n const threadId = transcriptThreadIdRef.current;\n if (!transcript || !threadId) return;\n const sessionIdentity =\n sessionIdRef.current ?? startedAtRef.current ?? \"pending\";\n const providerIdentity =\n transcript.providerId ?? `sequence-${++transcriptSequenceRef.current}`;\n realtimeVoiceTranscriptRegistry.publish({\n id: `realtime-voice:${sessionIdentity}:${transcript.role}:${providerIdentity}`,\n threadId,\n role: transcript.role,\n text: transcript.text,\n createdAt: new Date().toISOString(),\n });\n },\n [],\n );\n\n const handleServerEvent = useCallback(\n (event: RealtimeServerEvent) => {\n if (event.type === \"session.created\") {\n const session = event.session;\n if (session && typeof session === \"object\") {\n const id = (session as { id?: unknown }).id;\n if (typeof id === \"string\") sessionIdRef.current = id;\n }\n transition(\"listening\");\n } else if (event.type === \"input_audio_buffer.speech_started\") {\n transition(\"listening\");\n } else if (event.type === \"input_audio_buffer.speech_stopped\") {\n transition(\"working\");\n } else if (event.type === \"response.created\") {\n lastAssistantTextRef.current = \"\";\n transition(\"working\");\n } else if (event.type === \"response.output_audio_transcript.delta\") {\n if (typeof event.delta === \"string\") {\n lastAssistantTextRef.current += event.delta;\n }\n transition(\"speaking\");\n } else if (event.type === \"response.output_audio_transcript.done\") {\n if (typeof event.transcript === \"string\") {\n lastAssistantTextRef.current = event.transcript;\n }\n persistCompletedTranscript(event);\n syncAppState(\"speaking\");\n } else if (\n event.type === \"conversation.item.input_audio_transcription.completed\"\n ) {\n if (typeof event.transcript === \"string\") {\n lastUserTextRef.current = event.transcript;\n }\n persistCompletedTranscript(event);\n syncAppState(\"working\");\n } else if (event.type === \"response.done\") {\n const response = event.response;\n const status =\n response && typeof response === \"object\"\n ? (response as { status?: unknown }).status\n : undefined;\n if (status === \"failed\") {\n fail(\n copy?.errors.responseFailed ??\n \"OpenAI could not complete the voice response.\",\n );\n return;\n }\n } else if (event.type === \"error\") {\n const detail = event.error;\n const message =\n detail && typeof detail === \"object\"\n ? String((detail as { message?: unknown }).message ?? \"\")\n : typeof detail === \"string\"\n ? detail\n : \"\";\n fail(\n message ||\n copy?.errors.sessionFailed ||\n \"The realtime voice session encountered an error.\",\n );\n return;\n }\n\n const calls = extractRealtimeVoiceFunctionCalls(event);\n for (const call of calls) void handleFunctionCall(call);\n if (event.type === \"response.done\" && calls.length === 0) {\n transition(\"listening\");\n }\n },\n [\n copy,\n fail,\n handleFunctionCall,\n persistCompletedTranscript,\n syncAppState,\n transition,\n ],\n );\n\n const start = useCallback(async () => {\n if (stateRef.current !== \"idle\") return;\n if (\n typeof RTCPeerConnection === \"undefined\" ||\n !navigator.mediaDevices?.getUserMedia\n ) {\n fail(\n copy?.errors.unsupported ??\n \"This browser does not support realtime voice conversations.\",\n );\n return;\n }\n setError(null);\n startedAtRef.current = new Date().toISOString();\n lastUserTextRef.current = \"\";\n lastAssistantTextRef.current = \"\";\n sessionIdRef.current = undefined;\n transcriptThreadIdRef.current =\n realtimeVoiceTranscriptRegistry.activeThreadId();\n transcriptSequenceRef.current = 0;\n transition(\"connecting\");\n setChatVisible(false);\n window.dispatchEvent(new Event(\"agent-panel:close\"));\n\n const abortController = new AbortController();\n abortRef.current = abortController;\n try {\n const stream = await navigator.mediaDevices.getUserMedia({\n audio: {\n echoCancellation: true,\n noiseSuppression: true,\n autoGainControl: true,\n },\n });\n streamRef.current = stream;\n attachAudioMeter(stream, \"input\");\n\n const peer = new RTCPeerConnection();\n peerRef.current = peer;\n for (const track of stream.getAudioTracks()) peer.addTrack(track, stream);\n\n const audio = document.createElement(\"audio\");\n audio.autoplay = true;\n audio.setAttribute(\"playsinline\", \"\");\n audioRef.current = audio;\n peer.ontrack = (trackEvent) => {\n const remoteStream = trackEvent.streams[0] ?? null;\n audio.srcObject = remoteStream;\n if (remoteStream) attachAudioMeter(remoteStream, \"output\");\n void audio.play().catch(() => undefined);\n };\n\n const channel = peer.createDataChannel(\"oai-events\");\n channelRef.current = channel;\n channel.onopen = () => transition(\"listening\");\n channel.onmessage = (messageEvent) => {\n try {\n handleServerEvent(JSON.parse(String(messageEvent.data)));\n } catch {\n // Ignore malformed provider events without ending a healthy call.\n }\n };\n channel.onerror = () =>\n fail(\n copy?.errors.channelDisconnected ??\n \"The realtime voice control channel disconnected.\",\n );\n peer.onconnectionstatechange = () => {\n if (peer.connectionState === \"connected\") transition(\"listening\");\n if (peer.connectionState === \"failed\") {\n fail(\n copy?.errors.connectionFailed ??\n \"The realtime voice connection failed.\",\n );\n }\n };\n\n const offer = await peer.createOffer();\n await peer.setLocalDescription(offer);\n if (!offer.sdp) {\n throw new Error(\n copy?.errors.offerFailed ??\n \"The browser did not create an audio offer.\",\n );\n }\n const answerSdp = await createRealtimeVoiceSession(offer.sdp, {\n browserTabId,\n signal: abortController.signal,\n });\n await peer.setRemoteDescription({ type: \"answer\", sdp: answerSdp });\n } catch (startError) {\n const status = (startError as { status?: unknown })?.status;\n fail(errorMessage(startError), { openKeySettings: status === 400 });\n }\n }, [\n attachAudioMeter,\n browserTabId,\n copy,\n fail,\n handleServerEvent,\n transition,\n ]);\n\n const end = useCallback(() => {\n if (stateRef.current === \"idle\" || stateRef.current === \"ending\") return;\n const transcriptThreadId = transcriptThreadIdRef.current;\n const activeThreadId = realtimeVoiceTranscriptRegistry.activeThreadId();\n transition(\"ending\");\n cleanupTransport();\n setError(null);\n sessionIdRef.current = undefined;\n startedAtRef.current = undefined;\n transcriptThreadIdRef.current = undefined;\n setChatVisible(true);\n if (\n shouldRestoreRealtimeVoiceTranscriptThread(\n transcriptThreadId,\n activeThreadId,\n )\n ) {\n requestAgentChatThreadOpen({\n threadId: transcriptThreadId,\n // The request is delivered asynchronously. Re-checking this at the\n // receiver prevents a navigation that happened during that gap from\n // being overwritten.\n onlyIfActiveThreadId: transcriptThreadId,\n });\n } else {\n window.dispatchEvent(new Event(\"agent-panel:open\"));\n }\n transition(\"idle\");\n }, [cleanupTransport, transition]);\n\n const toggleChat = useCallback(() => {\n setChatVisible((current) => !current);\n window.dispatchEvent(new Event(\"agent-panel:toggle\"));\n }, []);\n\n useEffect(() => {\n const onSidebarState = (event: Event) => {\n const detail = (event as CustomEvent<AgentSidebarStateChangeDetail>)\n .detail;\n if (detail && typeof detail.open === \"boolean\") {\n setChatVisible(detail.open);\n }\n };\n window.addEventListener(SIDEBAR_STATE_CHANGE_EVENT, onSidebarState);\n return () =>\n window.removeEventListener(SIDEBAR_STATE_CHANGE_EVENT, onSidebarState);\n }, []);\n\n useEffect(() => cleanupTransport, [cleanupTransport]);\n\n return {\n state,\n active: state !== \"idle\",\n errorMessage: error,\n chatVisible,\n audioLevels,\n start,\n end,\n toggleChat,\n };\n}\n\nconst RealtimeVoiceModeContext = createContext<RealtimeVoiceModeApi | null>(\n null,\n);\n\nexport function RealtimeVoiceModeProvider({\n children,\n browserTabId,\n}: RealtimeVoiceModeProviderProps) {\n const resolvedBrowserTabId = useMemo(\n () => browserTabId ?? getBrowserTabId(),\n [browserTabId],\n );\n const copy = useRealtimeVoiceModeCopy();\n const voice = useRealtimeVoiceModeController(resolvedBrowserTabId, copy);\n\n return (\n <RealtimeVoiceModeContext.Provider value={voice}>\n {children}\n {voice.active && typeof document !== \"undefined\"\n ? createPortal(\n <RealtimeVoiceModeDock\n state={voice.state === \"idle\" ? \"ending\" : voice.state}\n copy={copy}\n chatVisible={voice.chatVisible}\n audioLevels={voice.audioLevels}\n onToggleChat={voice.toggleChat}\n onEndVoiceMode={voice.end}\n errorMessage={voice.errorMessage}\n />,\n document.body,\n )\n : null}\n </RealtimeVoiceModeContext.Provider>\n );\n}\n\n/**\n * Ensure standalone/full-page composers get realtime voice without nesting a\n * second session owner inside the persistent AgentSidebar provider.\n */\nexport function RealtimeVoiceModeBoundary({\n children,\n browserTabId,\n}: RealtimeVoiceModeProviderProps) {\n const existing = useRealtimeVoiceModeOptional();\n if (existing) {\n return (\n <RealtimeVoiceModeComposerSurface>\n {children}\n </RealtimeVoiceModeComposerSurface>\n );\n }\n return (\n <RealtimeVoiceModeProvider browserTabId={browserTabId}>\n <RealtimeVoiceModeComposerSurface>\n {children}\n </RealtimeVoiceModeComposerSurface>\n </RealtimeVoiceModeProvider>\n );\n}\n\n/** Hide a composer while voice owns input; the dock can reveal it on demand. */\nfunction RealtimeVoiceModeComposerSurface({\n children,\n}: Pick<RealtimeVoiceModeProviderProps, \"children\">) {\n const voice = useRealtimeVoiceModeOptional();\n if (voice?.active && !voice.chatVisible) return null;\n return children;\n}\n\nexport function useRealtimeVoiceMode(): RealtimeVoiceModeApi {\n const value = useContext(RealtimeVoiceModeContext);\n if (!value) {\n throw new Error(\n \"useRealtimeVoiceMode must be used inside RealtimeVoiceModeProvider.\",\n );\n }\n return value;\n}\n\nexport function useRealtimeVoiceModeOptional(): RealtimeVoiceModeApi | null {\n return useContext(RealtimeVoiceModeContext);\n}\n\nexport async function readRealtimeVoiceContext(): Promise<{\n navigation: unknown;\n url: unknown;\n}> {\n const [navigation, url] = await Promise.all([\n readClientAppState(\"navigation\").catch(() => null),\n readClientAppState(\"__url__\").catch(() => null),\n ]);\n return { navigation, url };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"useRealtimeVoiceMode.js","sourceRoot":"","sources":["../../../src/client/composer/useRealtimeVoiceMode.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,aAAa,EACb,WAAW,EACX,UAAU,EACV,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,GAET,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EACL,0BAA0B,GAE3B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,eAA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C;IACJ,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,4BAA4B;IAC1C,OAAO,UAAU,CAAC,wBAAwB,CAAC,CAAC;AAC9C,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,wBAAwB;IAI5C,MAAM,CAAC,UAAU,EAAE,GAAG,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QAC1C,kBAAkB,CAAC,YAAY,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC;QAClD,kBAAkB,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC;KAChD,CAAC,CAAC;IACH,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC;AAC7B,CAAC","sourcesContent":["import {\n createContext,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useRef,\n useState,\n type ReactNode,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\n\nimport { requestAgentChatThreadOpen } from \"../agent-chat.js\";\nimport {\n SIDEBAR_STATE_CHANGE_EVENT,\n type AgentSidebarStateChangeDetail,\n} from \"../agent-sidebar-state.js\";\nimport { agentNativePath, appPath } from \"../api-path.js\";\nimport { readClientAppState, setClientAppState } from \"../application-state.js\";\nimport { getBrowserTabId } from \"../browser-tab-id.js\";\nimport { useT } from \"../i18n.js\";\nimport {\n createRealtimeVoiceAudioLevelStore,\n normalizeRealtimeVoiceRms,\n smoothRealtimeVoiceLevel,\n type RealtimeVoiceAudioLevelStore,\n} from \"./realtime-voice-audio-level.js\";\nimport { realtimeVoiceTranscriptRegistry } from \"./realtime-voice-transcript.js\";\nimport {\n RealtimeVoiceModeDock,\n type RealtimeVoiceModeCopy,\n type RealtimeVoiceModeState,\n} from \"./RealtimeVoiceMode.js\";\n\nconst REALTIME_VOICE_STATE_KEY = \"realtime-voice-session\";\nconst REALTIME_VOICE_REQUEST_SOURCE = \"realtime-voice\";\nconst REALTIME_VOICE_SESSION_PATH = \"/_agent-native/realtime-voice/session\";\nconst REALTIME_VOICE_TOOL_PATH = \"/_agent-native/realtime-voice/tool\";\nconst REALTIME_VOICE_CONNECTION_TIMEOUT_MS = 15_000;\n\nexport const REALTIME_VOICE_AUDIO_CONSTRAINTS: MediaTrackConstraints = {\n // Prefer the browser/OS-selected input instead of whichever physical device\n // happens to be enumerated first. `ideal` keeps browsers without the\n // synthetic `default` device from failing with OverconstrainedError.\n deviceId: { ideal: \"default\" },\n echoCancellation: true,\n noiseSuppression: true,\n autoGainControl: true,\n};\n\ntype RealtimeServerEvent = Record<string, unknown> & { type?: string };\n\nexport interface RealtimeVoiceToolResult {\n callId: string;\n status: \"completed\" | \"failed\" | \"approval_required\";\n output: string;\n approvalKey?: string;\n}\n\nexport interface RealtimeVoiceModeApi {\n state: \"idle\" | RealtimeVoiceModeState;\n active: boolean;\n errorMessage: string | null;\n chatVisible: boolean;\n audioLevels: RealtimeVoiceAudioLevelStore;\n start: () => Promise<void>;\n end: () => void;\n toggleChat: () => void;\n}\n\nexport interface CompletedRealtimeVoiceTranscript {\n role: \"user\" | \"assistant\";\n text: string;\n providerId?: string;\n}\n\n/**\n * Voice mode owns the chat only temporarily. Restore the captured transcript\n * when it is still the user's active thread (or the chat has no active thread)\n * but never pull them back after they deliberately selected another thread.\n */\nexport function shouldRestoreRealtimeVoiceTranscriptThread(\n transcriptThreadId: string | undefined,\n activeThreadId: string | undefined,\n): transcriptThreadId is string {\n return Boolean(\n transcriptThreadId &&\n (!activeThreadId || activeThreadId === transcriptThreadId),\n );\n}\n\nexport function extractCompletedRealtimeVoiceTranscript(\n event: RealtimeServerEvent,\n): CompletedRealtimeVoiceTranscript | null {\n const userCompleted =\n event.type === \"conversation.item.input_audio_transcription.completed\";\n const assistantCompleted =\n event.type === \"response.output_audio_transcript.done\";\n if (!userCompleted && !assistantCompleted) return null;\n const text =\n typeof event.transcript === \"string\" ? event.transcript.trim() : \"\";\n if (!text) return null;\n const providerId = [event.item_id, event.response_id, event.event_id].find(\n (value): value is string => typeof value === \"string\" && value.length > 0,\n );\n return {\n role: userCompleted ? \"user\" : \"assistant\",\n text,\n ...(providerId ? { providerId } : {}),\n };\n}\n\nexport interface RealtimeVoiceModeProviderProps {\n children: ReactNode;\n browserTabId?: string;\n}\n\nfunction errorMessage(error: unknown): string {\n return error instanceof Error ? error.message : String(error);\n}\n\nexport function isRealtimeVoiceAbortError(error: unknown): boolean {\n return Boolean(\n error &&\n typeof error === \"object\" &&\n (error as { name?: unknown }).name === \"AbortError\",\n );\n}\n\nexport function createRealtimeVoiceConnectionTimeout(\n onTimeout: () => void,\n timeoutMs = REALTIME_VOICE_CONNECTION_TIMEOUT_MS,\n): () => void {\n const timeout = window.setTimeout(onTimeout, timeoutMs);\n return () => window.clearTimeout(timeout);\n}\n\nasync function readErrorResponse(response: Response): Promise<string> {\n const raw = await response.text().catch(() => \"\");\n if (!raw) return response.statusText || `HTTP ${response.status}`;\n try {\n const parsed = JSON.parse(raw) as { error?: unknown; message?: unknown };\n return String(parsed.error ?? parsed.message ?? raw);\n } catch {\n return raw.slice(0, 500);\n }\n}\n\nexport async function createRealtimeVoiceSession(\n offerSdp: string,\n options: { browserTabId?: string; signal?: AbortSignal } = {},\n): Promise<string> {\n const response = await fetch(agentNativePath(REALTIME_VOICE_SESSION_PATH), {\n method: \"POST\",\n credentials: \"same-origin\",\n headers: {\n \"Content-Type\": \"application/sdp\",\n ...(options.browserTabId\n ? { \"X-Agent-Native-Browser-Tab\": options.browserTabId }\n : {}),\n },\n body: offerSdp,\n signal: options.signal,\n });\n if (!response.ok) {\n const message = await readErrorResponse(response);\n const error = new Error(message);\n (error as { status?: number }).status = response.status;\n throw error;\n }\n return response.text();\n}\n\nexport async function executeRealtimeVoiceTool(input: {\n name: string;\n args: Record<string, unknown>;\n callId: string;\n sessionId?: string;\n browserTabId?: string;\n signal?: AbortSignal;\n}): Promise<RealtimeVoiceToolResult> {\n const response = await fetch(agentNativePath(REALTIME_VOICE_TOOL_PATH), {\n method: \"POST\",\n credentials: \"same-origin\",\n headers: {\n \"Content-Type\": \"application/json\",\n ...(input.browserTabId\n ? { \"X-Agent-Native-Browser-Tab\": input.browserTabId }\n : {}),\n },\n body: JSON.stringify({\n name: input.name,\n args: input.args,\n callId: input.callId,\n sessionId: input.sessionId,\n browserTabId: input.browserTabId,\n }),\n signal: input.signal,\n });\n if (!response.ok) {\n throw new Error(await readErrorResponse(response));\n }\n return (await response.json()) as RealtimeVoiceToolResult;\n}\n\nexport function extractRealtimeVoiceFunctionCalls(\n event: RealtimeServerEvent,\n): Array<{ name: string; callId: string; argumentsText: string }> {\n if (event.type === \"response.function_call_arguments.done\") {\n const name = typeof event.name === \"string\" ? event.name : \"\";\n const callId = typeof event.call_id === \"string\" ? event.call_id : \"\";\n if (!name || !callId) return [];\n return [\n {\n name,\n callId,\n argumentsText:\n typeof event.arguments === \"string\" ? event.arguments : \"{}\",\n },\n ];\n }\n if (event.type !== \"response.done\") return [];\n const response = event.response;\n if (!response || typeof response !== \"object\") return [];\n const output = (response as { output?: unknown }).output;\n if (!Array.isArray(output)) return [];\n return output.flatMap((item) => {\n if (!item || typeof item !== \"object\") return [];\n const record = item as Record<string, unknown>;\n if (record.type !== \"function_call\") return [];\n const name = typeof record.name === \"string\" ? record.name : \"\";\n const callId = typeof record.call_id === \"string\" ? record.call_id : \"\";\n if (!name || !callId) return [];\n return [\n {\n name,\n callId,\n argumentsText:\n typeof record.arguments === \"string\" ? record.arguments : \"{}\",\n },\n ];\n });\n}\n\nfunction parseFunctionArguments(text: string): Record<string, unknown> {\n const parsed = JSON.parse(text || \"{}\");\n if (!parsed || typeof parsed !== \"object\" || Array.isArray(parsed)) {\n throw new Error(\"The voice model returned invalid tool arguments.\");\n }\n return parsed as Record<string, unknown>;\n}\n\nfunction sendDataChannelEvent(\n channel: RTCDataChannel | null,\n event: Record<string, unknown>,\n): void {\n if (!channel || channel.readyState !== \"open\") return;\n channel.send(JSON.stringify(event));\n}\n\nfunction openOpenAiKeySettings(): void {\n if (typeof window === \"undefined\") return;\n window.location.hash = \"#secrets:OPENAI_API_KEY\";\n window.dispatchEvent(new Event(\"agent-panel:open\"));\n window.dispatchEvent(\n new CustomEvent(\"agent-panel:open-settings\", {\n detail: { section: \"secrets\" },\n }),\n );\n}\n\nfunction openMicrophoneSettings(): void {\n if (typeof window === \"undefined\") return;\n window.location.assign(`${appPath(\"/settings\")}#voice`);\n}\n\nexport function endRealtimeVoiceBeforeNavigation(\n end: () => void,\n navigate: () => void,\n): void {\n end();\n window.setTimeout(navigate, 0);\n}\n\nexport function listenForRealtimeVoicePageHide(\n cleanup: () => void,\n): () => void {\n window.addEventListener(\"pagehide\", cleanup);\n return () => window.removeEventListener(\"pagehide\", cleanup);\n}\n\nfunction voiceCopy(t: ReturnType<typeof useT>): RealtimeVoiceModeCopy {\n return {\n entryButtonLabel: t(\"agentPanel.voiceMode.entryButtonLabel\"),\n promptTitle: t(\"agentPanel.voiceMode.promptTitle\"),\n promptDescription: t(\"agentPanel.voiceMode.promptDescription\"),\n setupTitle: t(\"agentPanel.voiceMode.setupTitle\"),\n setupDescription: t(\"agentPanel.voiceMode.setupDescription\"),\n connectBuilder: t(\"agentPanel.voiceMode.connectBuilder\"),\n useOpenAiKey: t(\"agentPanel.voiceMode.useOpenAiKey\"),\n startWithOpenAiKey: t(\"agentPanel.voiceMode.startWithOpenAiKey\"),\n startVoiceMode: t(\"agentPanel.voiceMode.start\"),\n keepDictating: t(\"agentPanel.voiceMode.keepDictating\"),\n showChat: t(\"agentPanel.voiceMode.showChat\"),\n hideChat: t(\"agentPanel.voiceMode.hideChat\"),\n endVoiceMode: t(\"agentPanel.voiceMode.end\"),\n microphoneSettings: t(\"agentPanel.voiceMode.microphoneSettings\"),\n status: {\n connecting: t(\"agentPanel.voiceMode.status.connecting\"),\n listening: t(\"agentPanel.voiceMode.status.listening\"),\n speaking: t(\"agentPanel.voiceMode.status.speaking\"),\n working: t(\"agentPanel.voiceMode.status.working\"),\n error: t(\"agentPanel.voiceMode.status.error\"),\n ending: t(\"agentPanel.voiceMode.status.ending\"),\n },\n errors: {\n unsupported: t(\"agentPanel.voiceMode.errors.unsupported\"),\n responseFailed: t(\"agentPanel.voiceMode.errors.responseFailed\"),\n sessionFailed: t(\"agentPanel.voiceMode.errors.sessionFailed\"),\n channelDisconnected: t(\"agentPanel.voiceMode.errors.channelDisconnected\"),\n connectionFailed: t(\"agentPanel.voiceMode.errors.connectionFailed\"),\n offerFailed: t(\"agentPanel.voiceMode.errors.offerFailed\"),\n },\n };\n}\n\nexport function useRealtimeVoiceModeCopy(): RealtimeVoiceModeCopy {\n const t = useT();\n return useMemo(() => voiceCopy(t), [t]);\n}\n\nfunction useRealtimeVoiceModeController(\n browserTabId?: string,\n copy?: RealtimeVoiceModeCopy,\n): RealtimeVoiceModeApi {\n const [state, setState] = useState<\"idle\" | RealtimeVoiceModeState>(\"idle\");\n const [error, setError] = useState<string | null>(null);\n const [chatVisible, setChatVisible] = useState(false);\n const [audioLevels] = useState(createRealtimeVoiceAudioLevelStore);\n const stateRef = useRef(state);\n const peerRef = useRef<RTCPeerConnection | null>(null);\n const channelRef = useRef<RTCDataChannel | null>(null);\n const streamRef = useRef<MediaStream | null>(null);\n const audioRef = useRef<HTMLAudioElement | null>(null);\n const audioContextRef = useRef<AudioContext | null>(null);\n const inputAnalyserRef = useRef<AnalyserNode | null>(null);\n const outputAnalyserRef = useRef<AnalyserNode | null>(null);\n const inputMeterBufferRef = useRef<Uint8Array<ArrayBuffer> | null>(null);\n const outputMeterBufferRef = useRef<Uint8Array<ArrayBuffer> | null>(null);\n const inputSourceRef = useRef<MediaStreamAudioSourceNode | null>(null);\n const outputSourceRef = useRef<MediaStreamAudioSourceNode | null>(null);\n const meterFrameRef = useRef<number | null>(null);\n const lastMeterSampleRef = useRef(0);\n const abortRef = useRef<AbortController | null>(null);\n const cancelConnectionTimeoutRef = useRef<(() => void) | null>(null);\n const handledCallsRef = useRef(new Set<string>());\n const sessionIdRef = useRef<string | undefined>(undefined);\n const startedAtRef = useRef<string | undefined>(undefined);\n const lastUserTextRef = useRef(\"\");\n const lastAssistantTextRef = useRef(\"\");\n const transcriptThreadIdRef = useRef<string | undefined>(undefined);\n const transcriptSequenceRef = useRef(0);\n\n useEffect(() => {\n stateRef.current = state;\n }, [state]);\n\n const syncAppState = useCallback(\n (nextState: \"idle\" | RealtimeVoiceModeState) => {\n const value =\n nextState === \"idle\"\n ? null\n : {\n active: true,\n status: nextState,\n model: \"gpt-realtime-2.1\",\n startedAt: startedAtRef.current,\n sessionId: sessionIdRef.current,\n browserTabId,\n lastUserText: lastUserTextRef.current || undefined,\n lastAssistantText: lastAssistantTextRef.current || undefined,\n };\n void setClientAppState(REALTIME_VOICE_STATE_KEY, value, {\n requestSource: REALTIME_VOICE_REQUEST_SOURCE,\n }).catch(() => undefined);\n },\n [browserTabId],\n );\n\n const transition = useCallback(\n (nextState: \"idle\" | RealtimeVoiceModeState) => {\n stateRef.current = nextState;\n setState(nextState);\n syncAppState(nextState);\n },\n [syncAppState],\n );\n\n const startMeterLoop = useCallback(() => {\n if (meterFrameRef.current !== null) return;\n const sample = (timestamp: number) => {\n meterFrameRef.current = requestAnimationFrame(sample);\n if (timestamp - lastMeterSampleRef.current < 50) return;\n lastMeterSampleRef.current = timestamp;\n\n const current = audioLevels.getSnapshot();\n let input = current.input;\n let output = current.output;\n const inputAnalyser = inputAnalyserRef.current;\n const inputBuffer = inputMeterBufferRef.current;\n if (inputAnalyser && inputBuffer) {\n inputAnalyser.getByteTimeDomainData(inputBuffer);\n input = smoothRealtimeVoiceLevel(\n input,\n normalizeRealtimeVoiceRms(inputBuffer),\n );\n }\n const outputAnalyser = outputAnalyserRef.current;\n const outputBuffer = outputMeterBufferRef.current;\n if (outputAnalyser && outputBuffer) {\n outputAnalyser.getByteTimeDomainData(outputBuffer);\n output = smoothRealtimeVoiceLevel(\n output,\n normalizeRealtimeVoiceRms(outputBuffer),\n );\n }\n audioLevels.set({ input, output });\n };\n meterFrameRef.current = requestAnimationFrame(sample);\n }, [audioLevels]);\n\n const attachAudioMeter = useCallback(\n (stream: MediaStream, channel: \"input\" | \"output\") => {\n try {\n const AudioCtor =\n window.AudioContext ??\n (\n window as typeof window & {\n webkitAudioContext?: typeof AudioContext;\n }\n ).webkitAudioContext;\n if (!AudioCtor) return;\n const context = audioContextRef.current ?? new AudioCtor();\n audioContextRef.current = context;\n void context.resume().catch(() => undefined);\n const analyser = context.createAnalyser();\n analyser.fftSize = 512;\n const source = context.createMediaStreamSource(stream);\n source.connect(analyser);\n const buffer = new Uint8Array(analyser.frequencyBinCount);\n if (channel === \"input\") {\n inputSourceRef.current?.disconnect();\n inputSourceRef.current = source;\n inputAnalyserRef.current = analyser;\n inputMeterBufferRef.current = buffer;\n } else {\n outputSourceRef.current?.disconnect();\n outputSourceRef.current = source;\n outputAnalyserRef.current = analyser;\n outputMeterBufferRef.current = buffer;\n }\n startMeterLoop();\n } catch {\n // Audio metering is visual-only; keep the realtime call healthy.\n }\n },\n [startMeterLoop],\n );\n\n const cleanupTransport = useCallback(() => {\n cancelConnectionTimeoutRef.current?.();\n cancelConnectionTimeoutRef.current = null;\n abortRef.current?.abort();\n abortRef.current = null;\n channelRef.current?.close();\n channelRef.current = null;\n peerRef.current?.close();\n peerRef.current = null;\n for (const track of streamRef.current?.getTracks() ?? []) track.stop();\n streamRef.current = null;\n if (audioRef.current) {\n audioRef.current.pause();\n audioRef.current.srcObject = null;\n }\n audioRef.current = null;\n if (meterFrameRef.current !== null) {\n cancelAnimationFrame(meterFrameRef.current);\n meterFrameRef.current = null;\n }\n inputSourceRef.current?.disconnect();\n outputSourceRef.current?.disconnect();\n inputSourceRef.current = null;\n outputSourceRef.current = null;\n inputAnalyserRef.current = null;\n outputAnalyserRef.current = null;\n inputMeterBufferRef.current = null;\n outputMeterBufferRef.current = null;\n lastMeterSampleRef.current = 0;\n const audioContext = audioContextRef.current;\n audioContextRef.current = null;\n if (audioContext) void audioContext.close().catch(() => undefined);\n audioLevels.reset();\n handledCallsRef.current.clear();\n }, [audioLevels]);\n\n const fail = useCallback(\n (message: string, options?: { openKeySettings?: boolean }) => {\n cleanupTransport();\n setError(message);\n transition(\"error\");\n if (options?.openKeySettings) openOpenAiKeySettings();\n },\n [cleanupTransport, transition],\n );\n\n const handleFunctionCall = useCallback(\n async (call: { name: string; callId: string; argumentsText: string }) => {\n if (handledCallsRef.current.has(call.callId)) return;\n handledCallsRef.current.add(call.callId);\n transition(\"working\");\n let result: RealtimeVoiceToolResult;\n try {\n const args = parseFunctionArguments(call.argumentsText);\n result = await executeRealtimeVoiceTool({\n name: call.name,\n args,\n callId: call.callId,\n sessionId: sessionIdRef.current,\n browserTabId,\n signal: abortRef.current?.signal,\n });\n } catch (toolError) {\n result = {\n callId: call.callId,\n status: \"failed\",\n output: errorMessage(toolError),\n };\n }\n sendDataChannelEvent(channelRef.current, {\n type: \"conversation.item.create\",\n item: {\n type: \"function_call_output\",\n call_id: call.callId,\n output: JSON.stringify(result),\n },\n });\n sendDataChannelEvent(channelRef.current, { type: \"response.create\" });\n },\n [browserTabId, transition],\n );\n\n const persistCompletedTranscript = useCallback(\n (event: RealtimeServerEvent) => {\n const transcript = extractCompletedRealtimeVoiceTranscript(event);\n const threadId = transcriptThreadIdRef.current;\n if (!transcript || !threadId) return;\n const sessionIdentity =\n sessionIdRef.current ?? startedAtRef.current ?? \"pending\";\n const providerIdentity =\n transcript.providerId ?? `sequence-${++transcriptSequenceRef.current}`;\n realtimeVoiceTranscriptRegistry.publish({\n id: `realtime-voice:${sessionIdentity}:${transcript.role}:${providerIdentity}`,\n threadId,\n role: transcript.role,\n text: transcript.text,\n createdAt: new Date().toISOString(),\n });\n },\n [],\n );\n\n const handleServerEvent = useCallback(\n (event: RealtimeServerEvent) => {\n if (event.type === \"session.created\") {\n const session = event.session;\n if (session && typeof session === \"object\") {\n const id = (session as { id?: unknown }).id;\n if (typeof id === \"string\") sessionIdRef.current = id;\n }\n transition(\"listening\");\n } else if (event.type === \"input_audio_buffer.speech_started\") {\n transition(\"listening\");\n } else if (event.type === \"input_audio_buffer.speech_stopped\") {\n transition(\"working\");\n } else if (event.type === \"response.created\") {\n lastAssistantTextRef.current = \"\";\n transition(\"working\");\n } else if (event.type === \"response.output_audio_transcript.delta\") {\n if (typeof event.delta === \"string\") {\n lastAssistantTextRef.current += event.delta;\n }\n transition(\"speaking\");\n } else if (event.type === \"response.output_audio_transcript.done\") {\n if (typeof event.transcript === \"string\") {\n lastAssistantTextRef.current = event.transcript;\n }\n persistCompletedTranscript(event);\n syncAppState(\"speaking\");\n } else if (\n event.type === \"conversation.item.input_audio_transcription.completed\"\n ) {\n if (typeof event.transcript === \"string\") {\n lastUserTextRef.current = event.transcript;\n }\n persistCompletedTranscript(event);\n syncAppState(\"working\");\n } else if (event.type === \"response.done\") {\n const response = event.response;\n const status =\n response && typeof response === \"object\"\n ? (response as { status?: unknown }).status\n : undefined;\n if (status === \"failed\") {\n fail(\n copy?.errors.responseFailed ??\n \"OpenAI could not complete the voice response.\",\n );\n return;\n }\n } else if (event.type === \"error\") {\n const detail = event.error;\n const message =\n detail && typeof detail === \"object\"\n ? String((detail as { message?: unknown }).message ?? \"\")\n : typeof detail === \"string\"\n ? detail\n : \"\";\n fail(\n message ||\n copy?.errors.sessionFailed ||\n \"The realtime voice session encountered an error.\",\n );\n return;\n }\n\n const calls = extractRealtimeVoiceFunctionCalls(event);\n for (const call of calls) void handleFunctionCall(call);\n if (event.type === \"response.done\" && calls.length === 0) {\n transition(\"listening\");\n }\n },\n [\n copy,\n fail,\n handleFunctionCall,\n persistCompletedTranscript,\n syncAppState,\n transition,\n ],\n );\n\n const start = useCallback(async () => {\n if (stateRef.current !== \"idle\") return;\n if (\n typeof RTCPeerConnection === \"undefined\" ||\n !navigator.mediaDevices?.getUserMedia\n ) {\n fail(\n copy?.errors.unsupported ??\n \"This browser does not support realtime voice conversations.\",\n );\n return;\n }\n setError(null);\n startedAtRef.current = new Date().toISOString();\n lastUserTextRef.current = \"\";\n lastAssistantTextRef.current = \"\";\n sessionIdRef.current = undefined;\n transcriptThreadIdRef.current =\n realtimeVoiceTranscriptRegistry.activeThreadId();\n transcriptSequenceRef.current = 0;\n transition(\"connecting\");\n setChatVisible(false);\n window.dispatchEvent(new Event(\"agent-panel:close\"));\n\n const abortController = new AbortController();\n abortRef.current = abortController;\n const isCurrentAttempt = () =>\n abortRef.current === abortController && !abortController.signal.aborted;\n const markConnected = () => {\n if (!isCurrentAttempt()) return;\n cancelConnectionTimeoutRef.current?.();\n cancelConnectionTimeoutRef.current = null;\n transition(\"listening\");\n };\n cancelConnectionTimeoutRef.current = createRealtimeVoiceConnectionTimeout(\n () => {\n if (!isCurrentAttempt()) return;\n fail(\n copy?.errors.connectionFailed ??\n \"The realtime voice connection timed out.\",\n );\n },\n );\n try {\n const stream = await navigator.mediaDevices.getUserMedia({\n audio: REALTIME_VOICE_AUDIO_CONSTRAINTS,\n });\n if (!isCurrentAttempt()) {\n for (const track of stream.getTracks()) track.stop();\n return;\n }\n streamRef.current = stream;\n attachAudioMeter(stream, \"input\");\n\n const peer = new RTCPeerConnection();\n peerRef.current = peer;\n for (const track of stream.getAudioTracks()) peer.addTrack(track, stream);\n\n const audio = document.createElement(\"audio\");\n audio.autoplay = true;\n audio.setAttribute(\"playsinline\", \"\");\n audioRef.current = audio;\n peer.ontrack = (trackEvent) => {\n const remoteStream = trackEvent.streams[0] ?? null;\n audio.srcObject = remoteStream;\n if (remoteStream) attachAudioMeter(remoteStream, \"output\");\n void audio.play().catch(() => undefined);\n };\n\n const channel = peer.createDataChannel(\"oai-events\");\n channelRef.current = channel;\n channel.onopen = markConnected;\n channel.onmessage = (messageEvent) => {\n if (!isCurrentAttempt()) return;\n try {\n handleServerEvent(JSON.parse(String(messageEvent.data)));\n } catch {\n // Ignore malformed provider events without ending a healthy call.\n }\n };\n channel.onerror = () => {\n if (!isCurrentAttempt()) return;\n fail(\n copy?.errors.channelDisconnected ??\n \"The realtime voice control channel disconnected.\",\n );\n };\n peer.onconnectionstatechange = () => {\n if (!isCurrentAttempt()) return;\n if (peer.connectionState === \"connected\") markConnected();\n if (peer.connectionState === \"failed\") {\n fail(\n copy?.errors.connectionFailed ??\n \"The realtime voice connection failed.\",\n );\n }\n };\n\n const offer = await peer.createOffer();\n if (!isCurrentAttempt()) return;\n await peer.setLocalDescription(offer);\n if (!isCurrentAttempt()) return;\n if (!offer.sdp) {\n throw new Error(\n copy?.errors.offerFailed ??\n \"The browser did not create an audio offer.\",\n );\n }\n const answerSdp = await createRealtimeVoiceSession(offer.sdp, {\n browserTabId,\n signal: abortController.signal,\n });\n if (!isCurrentAttempt()) return;\n await peer.setRemoteDescription({ type: \"answer\", sdp: answerSdp });\n } catch (startError) {\n // Ending a connection aborts the SDP request by design. A superseded\n // attempt must never resurrect the dock or surface that cancellation as\n // an error after cleanup.\n if (\n isRealtimeVoiceAbortError(startError) ||\n abortController.signal.aborted ||\n abortRef.current !== abortController\n ) {\n return;\n }\n const status = (startError as { status?: unknown })?.status;\n fail(errorMessage(startError), { openKeySettings: status === 400 });\n }\n }, [\n attachAudioMeter,\n browserTabId,\n copy,\n fail,\n handleServerEvent,\n transition,\n ]);\n\n const end = useCallback(() => {\n if (stateRef.current === \"idle\" || stateRef.current === \"ending\") return;\n const transcriptThreadId = transcriptThreadIdRef.current;\n const activeThreadId = realtimeVoiceTranscriptRegistry.activeThreadId();\n transition(\"ending\");\n cleanupTransport();\n setError(null);\n sessionIdRef.current = undefined;\n startedAtRef.current = undefined;\n transcriptThreadIdRef.current = undefined;\n setChatVisible(true);\n if (\n shouldRestoreRealtimeVoiceTranscriptThread(\n transcriptThreadId,\n activeThreadId,\n )\n ) {\n requestAgentChatThreadOpen({\n threadId: transcriptThreadId,\n // The request is delivered asynchronously. Re-checking this at the\n // receiver prevents a navigation that happened during that gap from\n // being overwritten.\n onlyIfActiveThreadId: transcriptThreadId,\n });\n } else {\n window.dispatchEvent(new Event(\"agent-panel:open\"));\n }\n transition(\"idle\");\n }, [cleanupTransport, transition]);\n\n const toggleChat = useCallback(() => {\n setChatVisible((current) => !current);\n window.dispatchEvent(new Event(\"agent-panel:toggle\"));\n }, []);\n\n useEffect(() => {\n const onSidebarState = (event: Event) => {\n const detail = (event as CustomEvent<AgentSidebarStateChangeDetail>)\n .detail;\n if (detail && typeof detail.open === \"boolean\") {\n setChatVisible(detail.open);\n }\n };\n window.addEventListener(SIDEBAR_STATE_CHANGE_EVENT, onSidebarState);\n return () =>\n window.removeEventListener(SIDEBAR_STATE_CHANGE_EVENT, onSidebarState);\n }, []);\n\n useEffect(() => {\n const stopListening = listenForRealtimeVoicePageHide(cleanupTransport);\n return () => {\n stopListening();\n cleanupTransport();\n };\n }, [cleanupTransport]);\n\n return {\n state,\n active: state !== \"idle\",\n errorMessage: error,\n chatVisible,\n audioLevels,\n start,\n end,\n toggleChat,\n };\n}\n\nconst RealtimeVoiceModeContext = createContext<RealtimeVoiceModeApi | null>(\n null,\n);\n\nexport function RealtimeVoiceModeProvider({\n children,\n browserTabId,\n}: RealtimeVoiceModeProviderProps) {\n const resolvedBrowserTabId = useMemo(\n () => browserTabId ?? getBrowserTabId(),\n [browserTabId],\n );\n const copy = useRealtimeVoiceModeCopy();\n const voice = useRealtimeVoiceModeController(resolvedBrowserTabId, copy);\n\n return (\n <RealtimeVoiceModeContext.Provider value={voice}>\n {children}\n {voice.active && typeof document !== \"undefined\"\n ? createPortal(\n <RealtimeVoiceModeDock\n state={voice.state === \"idle\" ? \"ending\" : voice.state}\n copy={copy}\n chatVisible={voice.chatVisible}\n audioLevels={voice.audioLevels}\n onToggleChat={voice.toggleChat}\n onEndVoiceMode={voice.end}\n onOpenMicrophoneSettings={() =>\n endRealtimeVoiceBeforeNavigation(\n voice.end,\n openMicrophoneSettings,\n )\n }\n errorMessage={voice.errorMessage}\n />,\n document.body,\n )\n : null}\n </RealtimeVoiceModeContext.Provider>\n );\n}\n\n/**\n * Ensure standalone/full-page composers get realtime voice without nesting a\n * second session owner inside the persistent AgentSidebar provider.\n */\nexport function RealtimeVoiceModeBoundary({\n children,\n browserTabId,\n}: RealtimeVoiceModeProviderProps) {\n const existing = useRealtimeVoiceModeOptional();\n if (existing) {\n return (\n <RealtimeVoiceModeComposerSurface>\n {children}\n </RealtimeVoiceModeComposerSurface>\n );\n }\n return (\n <RealtimeVoiceModeProvider browserTabId={browserTabId}>\n <RealtimeVoiceModeComposerSurface>\n {children}\n </RealtimeVoiceModeComposerSurface>\n </RealtimeVoiceModeProvider>\n );\n}\n\n/** Hide a composer while voice owns input; the dock can reveal it on demand. */\nfunction RealtimeVoiceModeComposerSurface({\n children,\n}: Pick<RealtimeVoiceModeProviderProps, \"children\">) {\n const voice = useRealtimeVoiceModeOptional();\n if (voice?.active && !voice.chatVisible) return null;\n return children;\n}\n\nexport function useRealtimeVoiceMode(): RealtimeVoiceModeApi {\n const value = useContext(RealtimeVoiceModeContext);\n if (!value) {\n throw new Error(\n \"useRealtimeVoiceMode must be used inside RealtimeVoiceModeProvider.\",\n );\n }\n return value;\n}\n\nexport function useRealtimeVoiceModeOptional(): RealtimeVoiceModeApi | null {\n return useContext(RealtimeVoiceModeContext);\n}\n\nexport async function readRealtimeVoiceContext(): Promise<{\n navigation: unknown;\n url: unknown;\n}> {\n const [navigation, url] = await Promise.all([\n readClientAppState(\"navigation\").catch(() => null),\n readClientAppState(\"__url__\").catch(() => null),\n ]);\n return { navigation, url };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextXRayPanel.d.ts","sourceRoot":"","sources":["../../../src/client/context-xray/ContextXRayPanel.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,eAAe,EAEf,oBAAoB,EACrB,MAAM,8BAA8B,CAAC;AA8DtC,wBAAgB,gBAAgB,CAAC,EAC/B,QAAQ,EACR,UAAU,EACV,KAAK,EACL,OAAO,EACP,SAAS,GACV,EAAE;IACD,QAAQ,EAAE,eAAe,CAAC;IAC1B,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;IAC9C,KAAK,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,OAAO,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,SAAS,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC,+
|
|
1
|
+
{"version":3,"file":"ContextXRayPanel.d.ts","sourceRoot":"","sources":["../../../src/client/context-xray/ContextXRayPanel.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,eAAe,EAEf,oBAAoB,EACrB,MAAM,8BAA8B,CAAC;AA8DtC,wBAAgB,gBAAgB,CAAC,EAC/B,QAAQ,EACR,UAAU,EACV,KAAK,EACL,OAAO,EACP,SAAS,GACV,EAAE;IACD,QAAQ,EAAE,eAAe,CAAC;IAC1B,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;IAC9C,KAAK,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,OAAO,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,SAAS,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC,+BAuKA"}
|
|
@@ -64,7 +64,10 @@ export function ContextXRayPanel({ manifest, optimistic, onPin, onEvict, onResto
|
|
|
64
64
|
manifest.tokenCountMethod === "estimate" ? "estimated" : null,
|
|
65
65
|
!manifest.enforceable ? "advisory" : null,
|
|
66
66
|
].filter((item) => Boolean(item));
|
|
67
|
-
return (_jsxs("div", { className: "flex max-h-[min(72vh,520px)] flex-col", children: [_jsxs("div", { className: "border-b border-border/60 px-3 py-2.5", children: [_jsxs("div", { className: "flex items-center justify-between gap-3", children: [_jsx("h2", { className: "min-w-0 truncate text-sm font-medium text-foreground", children: "Context X-Ray" }), _jsxs("div", { className: "shrink-0 text-xs tabular-nums text-muted-foreground", children: [formatTokens(manifest.totalTokens), " \u00B7 ", pct, "%"] })] }), _jsx("div", { className: "mt-2 h-1 overflow-hidden rounded-full bg-muted/70", children: _jsx("div", { className: "h-full rounded-full bg-foreground transition-
|
|
67
|
+
return (_jsxs("div", { className: "flex max-h-[min(72vh,520px)] flex-col", children: [_jsxs("div", { className: "border-b border-border/60 px-3 py-2.5", children: [_jsxs("div", { className: "flex items-center justify-between gap-3", children: [_jsx("h2", { className: "min-w-0 truncate text-sm font-medium text-foreground", children: "Context X-Ray" }), _jsxs("div", { className: "shrink-0 text-xs tabular-nums text-muted-foreground", children: [formatTokens(manifest.totalTokens), " \u00B7 ", pct, "%"] })] }), _jsx("div", { className: "mt-2 h-1 overflow-hidden rounded-full bg-muted/70", children: _jsx("div", { className: "h-full rounded-full bg-foreground origin-left transition-transform duration-200", style: {
|
|
68
|
+
transform: `scaleX(${Math.min(1, pct / 100)})`,
|
|
69
|
+
width: "100%",
|
|
70
|
+
} }) }), _jsxs("div", { className: "mt-1.5 flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px] text-muted-foreground", children: [details.map((detail) => (_jsx("span", { children: detail }, detail))), manifest.reclaimedTokens > 0 && (_jsxs("span", { className: "font-medium text-emerald-600 dark:text-emerald-400", children: ["-", formatTokens(manifest.reclaimedTokens)] }))] })] }), _jsxs("div", { className: "overflow-y-auto px-2 py-2", children: [_jsx("div", { className: "mb-1 flex items-center justify-end", children: _jsxs("div", { className: "inline-flex rounded-md bg-muted/40 p-0.5", children: [_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx("button", { type: "button", onClick: () => setMode("list"), "aria-label": "Show context list", className: cn("flex size-7 items-center justify-center rounded text-muted-foreground", mode === "list"
|
|
68
71
|
? "bg-background text-foreground shadow-sm"
|
|
69
72
|
: "hover:text-foreground"), children: _jsx(IconListDetails, { className: "h-3.5 w-3.5" }) }) }), _jsx(TooltipContent, { children: "List" })] }), _jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx("button", { type: "button", onClick: () => setMode("map"), "aria-label": "Show context map", className: cn("flex size-7 items-center justify-center rounded text-muted-foreground", mode === "map"
|
|
70
73
|
? "bg-background text-foreground shadow-sm"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextXRayPanel.js","sourceRoot":"","sources":["../../../src/client/context-xray/ContextXRayPanel.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,eAAe,GAChB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAO1C,OAAO,EACL,OAAO,EACP,cAAc,EACd,cAAc,GACf,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAQ7E,SAAS,qBAAqB,CAC5B,QAAkC,EAClC,UAA6C;IAE7C,IAAI,UAAU,CAAC,IAAI,KAAK,CAAC;QAAE,OAAO,QAAQ,CAAC;IAC3C,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;QAC9B,MAAM,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QACjD,OAAO,MAAM,CAAC,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;IACnD,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,eAAe,CAAC,QAAkC;IACzD,MAAM,GAAG,GAAG,IAAI,GAAG,EAAiB,CAAC;IACrC,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,MA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K,CAAC,OAAO,CAAC,SAAS,CAAC,EACrC,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,EACzC,SAAS,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC,IALxC,OAAO,CAAC,SAAS,CAMtB,CACH,CAAC,GACA,CACP,KA/CO,KAAK,CAAC,IAAI,CAgDd,CACP,CAAC;wBACJ,CAAC,CAAC,GACE,CACP,IACG,IACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["import {\n IconChartTreemap,\n IconChevronDown,\n IconChevronRight,\n IconListDetails,\n} from \"@tabler/icons-react\";\nimport { useMemo, useState } from \"react\";\n\nimport type {\n ContextManifest,\n ContextManifestSegment,\n ContextSegmentStatus,\n} from \"../../shared/context-xray.js\";\nimport {\n Tooltip,\n TooltipContent,\n TooltipTrigger,\n} from \"../components/ui/tooltip.js\";\nimport { cn } from \"../utils.js\";\nimport { ContextSegmentRow } from \"./ContextSegmentRow.js\";\nimport { ContextTreemap } from \"./ContextTreemap.js\";\nimport { formatTokens, groupColor, resolveContextWindow } from \"./format.js\";\n\ninterface Group {\n name: string;\n tokens: number;\n segments: ContextManifestSegment[];\n}\n\nfunction applyOptimisticStatus(\n segments: ContextManifestSegment[],\n optimistic: Map<string, ContextSegmentStatus>,\n): ContextManifestSegment[] {\n if (optimistic.size === 0) return segments;\n return segments.map((segment) => {\n const status = optimistic.get(segment.segmentId);\n return status ? { ...segment, status } : segment;\n });\n}\n\nfunction groupedSegments(segments: ContextManifestSegment[]): Group[] {\n const map = new Map<string, Group>();\n for (const segment of segments) {\n const groupName =\n segment.status === \"pinned\"\n ? \"Pinned\"\n : segment.status === \"evicted\"\n ? \"Evicted\"\n : segment.group;\n const group = map.get(groupName) ?? {\n name: groupName,\n tokens: 0,\n segments: [],\n };\n group.tokens += segment.tokenCount;\n group.segments.push(segment);\n map.set(groupName, group);\n }\n const order = [\n \"Pinned\",\n \"Tool results\",\n \"Files read\",\n \"Conversation\",\n \"Thinking\",\n \"Evicted\",\n ];\n return [...map.values()].sort((a, b) => {\n const ai = order.indexOf(a.name);\n const bi = order.indexOf(b.name);\n if (ai >= 0 || bi >= 0) return (ai < 0 ? 99 : ai) - (bi < 0 ? 99 : bi);\n return b.tokens - a.tokens;\n });\n}\n\nexport function ContextXRayPanel({\n manifest,\n optimistic,\n onPin,\n onEvict,\n onRestore,\n}: {\n manifest: ContextManifest;\n optimistic: Map<string, ContextSegmentStatus>;\n onPin: (segmentId: string) => void;\n onEvict: (segmentId: string) => void;\n onRestore: (segmentId: string) => void;\n}) {\n const [mode, setMode] = useState<\"list\" | \"map\">(\"list\");\n const [collapsed, setCollapsed] = useState<Set<string>>(new Set());\n const segments = useMemo(\n () => applyOptimisticStatus(manifest.segments, optimistic),\n [manifest.segments, optimistic],\n );\n const groups = useMemo(() => groupedSegments(segments), [segments]);\n const contextWindow = resolveContextWindow(manifest.model);\n const pct = Math.min(\n 100,\n Math.round((manifest.totalTokens / contextWindow) * 100),\n );\n const headroom = Math.max(0, contextWindow - manifest.totalTokens);\n const pinned = segments.filter((s) => s.status === \"pinned\").length;\n const evicted = segments.filter((s) => s.status === \"evicted\").length;\n const details = [\n `${formatTokens(headroom)} free`,\n pinned > 0 ? `${pinned} pinned` : null,\n evicted > 0 ? `${evicted} evicted` : null,\n manifest.tokenCountMethod === \"estimate\" ? \"estimated\" : null,\n !manifest.enforceable ? \"advisory\" : null,\n ].filter((item): item is string => Boolean(item));\n\n return (\n <div className=\"flex max-h-[min(72vh,520px)] flex-col\">\n <div className=\"border-b border-border/60 px-3 py-2.5\">\n <div className=\"flex items-center justify-between gap-3\">\n <h2 className=\"min-w-0 truncate text-sm font-medium text-foreground\">\n Context X-Ray\n </h2>\n <div className=\"shrink-0 text-xs tabular-nums text-muted-foreground\">\n {formatTokens(manifest.totalTokens)} · {pct}%\n </div>\n </div>\n <div className=\"mt-2 h-1 overflow-hidden rounded-full bg-muted/70\">\n <div\n className=\"h-full rounded-full bg-foreground transition-[width] duration-200\"\n style={{ width: `${pct}%` }}\n />\n </div>\n <div className=\"mt-1.5 flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px] text-muted-foreground\">\n {details.map((detail) => (\n <span key={detail}>{detail}</span>\n ))}\n {manifest.reclaimedTokens > 0 && (\n <span className=\"font-medium text-emerald-600 dark:text-emerald-400\">\n -{formatTokens(manifest.reclaimedTokens)}\n </span>\n )}\n </div>\n </div>\n\n <div className=\"overflow-y-auto px-2 py-2\">\n <div className=\"mb-1 flex items-center justify-end\">\n <div className=\"inline-flex rounded-md bg-muted/40 p-0.5\">\n <Tooltip>\n <TooltipTrigger asChild>\n <button\n type=\"button\"\n onClick={() => setMode(\"list\")}\n aria-label=\"Show context list\"\n className={cn(\n \"flex size-7 items-center justify-center rounded text-muted-foreground\",\n mode === \"list\"\n ? \"bg-background text-foreground shadow-sm\"\n : \"hover:text-foreground\",\n )}\n >\n <IconListDetails className=\"h-3.5 w-3.5\" />\n </button>\n </TooltipTrigger>\n <TooltipContent>List</TooltipContent>\n </Tooltip>\n <Tooltip>\n <TooltipTrigger asChild>\n <button\n type=\"button\"\n onClick={() => setMode(\"map\")}\n aria-label=\"Show context map\"\n className={cn(\n \"flex size-7 items-center justify-center rounded text-muted-foreground\",\n mode === \"map\"\n ? \"bg-background text-foreground shadow-sm\"\n : \"hover:text-foreground\",\n )}\n >\n <IconChartTreemap className=\"h-3.5 w-3.5\" />\n </button>\n </TooltipTrigger>\n <TooltipContent>Map</TooltipContent>\n </Tooltip>\n </div>\n </div>\n\n {mode === \"map\" ? (\n <ContextTreemap\n segments={segments}\n onSelect={(segmentId) => {\n const segment = segments.find((s) => s.segmentId === segmentId);\n if (segment) setCollapsed(new Set());\n }}\n />\n ) : (\n <div className=\"divide-y divide-border/60\">\n {groups.map((group) => {\n const isCollapsed = collapsed.has(group.name);\n return (\n <div key={group.name}>\n <button\n type=\"button\"\n onClick={() => {\n setCollapsed((prev) => {\n const next = new Set(prev);\n if (next.has(group.name)) next.delete(group.name);\n else next.add(group.name);\n return next;\n });\n }}\n className=\"flex w-full items-center gap-2 rounded-sm px-1.5 py-2 text-left hover:bg-accent/35\"\n >\n {isCollapsed ? (\n <IconChevronRight className=\"h-3.5 w-3.5 text-muted-foreground\" />\n ) : (\n <IconChevronDown className=\"h-3.5 w-3.5 text-muted-foreground\" />\n )}\n <span\n className={cn(\n \"h-2 w-2 rounded-full\",\n groupColor(group.name),\n )}\n />\n <span className=\"min-w-0 flex-1 truncate text-xs font-medium\">\n {group.name}\n </span>\n <span className=\"text-[11px] text-muted-foreground\">\n {formatTokens(group.tokens)}\n </span>\n </button>\n {!isCollapsed && (\n <div className=\"pb-1\">\n {group.segments\n .slice()\n .sort((a, b) => b.tokenCount - a.tokenCount)\n .map((segment) => (\n <ContextSegmentRow\n key={segment.segmentId}\n segment={segment}\n advisory={!manifest.enforceable}\n onPin={() => onPin(segment.segmentId)}\n onEvict={() => onEvict(segment.segmentId)}\n onRestore={() => onRestore(segment.segmentId)}\n />\n ))}\n </div>\n )}\n </div>\n );\n })}\n </div>\n )}\n </div>\n </div>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ContextXRayPanel.js","sourceRoot":"","sources":["../../../src/client/context-xray/ContextXRayPanel.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,eAAe,GAChB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAO1C,OAAO,EACL,OAAO,EACP,cAAc,EACd,cAAc,GACf,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,oBA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AAmC,GAAG,CAClE,EACD,eACE,SAAS,EAAE,EAAE,CACX,sBAAsB,EACtB,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CACvB,GACD,EACF,eAAM,SAAS,EAAC,6CAA6C,YAC1D,KAAK,CAAC,IAAI,GACN,EACP,eAAM,SAAS,EAAC,mCAAmC,YAChD,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC,GACtB,IACA,EACR,CAAC,WAAW,IAAI,CACf,cAAK,SAAS,EAAC,MAAM,YAClB,KAAK,CAAC,QAAQ;6CACZ,KAAK,EAAE;6CACP,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,UAAU,CAAC;6CAC3C,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAChB,KAAC,iBAAiB,IAEhB,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,CAAC,QAAQ,CAAC,WAAW,EAC/B,KAAK,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,EACrC,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,EACzC,SAAS,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC,IALxC,OAAO,CAAC,SAAS,CAMtB,CACH,CAAC,GACA,CACP,KA/CO,KAAK,CAAC,IAAI,CAgDd,CACP,CAAC;wBACJ,CAAC,CAAC,GACE,CACP,IACG,IACF,CACP,CAAC;AACJ,CAAC","sourcesContent":["import {\n IconChartTreemap,\n IconChevronDown,\n IconChevronRight,\n IconListDetails,\n} from \"@tabler/icons-react\";\nimport { useMemo, useState } from \"react\";\n\nimport type {\n ContextManifest,\n ContextManifestSegment,\n ContextSegmentStatus,\n} from \"../../shared/context-xray.js\";\nimport {\n Tooltip,\n TooltipContent,\n TooltipTrigger,\n} from \"../components/ui/tooltip.js\";\nimport { cn } from \"../utils.js\";\nimport { ContextSegmentRow } from \"./ContextSegmentRow.js\";\nimport { ContextTreemap } from \"./ContextTreemap.js\";\nimport { formatTokens, groupColor, resolveContextWindow } from \"./format.js\";\n\ninterface Group {\n name: string;\n tokens: number;\n segments: ContextManifestSegment[];\n}\n\nfunction applyOptimisticStatus(\n segments: ContextManifestSegment[],\n optimistic: Map<string, ContextSegmentStatus>,\n): ContextManifestSegment[] {\n if (optimistic.size === 0) return segments;\n return segments.map((segment) => {\n const status = optimistic.get(segment.segmentId);\n return status ? { ...segment, status } : segment;\n });\n}\n\nfunction groupedSegments(segments: ContextManifestSegment[]): Group[] {\n const map = new Map<string, Group>();\n for (const segment of segments) {\n const groupName =\n segment.status === \"pinned\"\n ? \"Pinned\"\n : segment.status === \"evicted\"\n ? \"Evicted\"\n : segment.group;\n const group = map.get(groupName) ?? {\n name: groupName,\n tokens: 0,\n segments: [],\n };\n group.tokens += segment.tokenCount;\n group.segments.push(segment);\n map.set(groupName, group);\n }\n const order = [\n \"Pinned\",\n \"Tool results\",\n \"Files read\",\n \"Conversation\",\n \"Thinking\",\n \"Evicted\",\n ];\n return [...map.values()].sort((a, b) => {\n const ai = order.indexOf(a.name);\n const bi = order.indexOf(b.name);\n if (ai >= 0 || bi >= 0) return (ai < 0 ? 99 : ai) - (bi < 0 ? 99 : bi);\n return b.tokens - a.tokens;\n });\n}\n\nexport function ContextXRayPanel({\n manifest,\n optimistic,\n onPin,\n onEvict,\n onRestore,\n}: {\n manifest: ContextManifest;\n optimistic: Map<string, ContextSegmentStatus>;\n onPin: (segmentId: string) => void;\n onEvict: (segmentId: string) => void;\n onRestore: (segmentId: string) => void;\n}) {\n const [mode, setMode] = useState<\"list\" | \"map\">(\"list\");\n const [collapsed, setCollapsed] = useState<Set<string>>(new Set());\n const segments = useMemo(\n () => applyOptimisticStatus(manifest.segments, optimistic),\n [manifest.segments, optimistic],\n );\n const groups = useMemo(() => groupedSegments(segments), [segments]);\n const contextWindow = resolveContextWindow(manifest.model);\n const pct = Math.min(\n 100,\n Math.round((manifest.totalTokens / contextWindow) * 100),\n );\n const headroom = Math.max(0, contextWindow - manifest.totalTokens);\n const pinned = segments.filter((s) => s.status === \"pinned\").length;\n const evicted = segments.filter((s) => s.status === \"evicted\").length;\n const details = [\n `${formatTokens(headroom)} free`,\n pinned > 0 ? `${pinned} pinned` : null,\n evicted > 0 ? `${evicted} evicted` : null,\n manifest.tokenCountMethod === \"estimate\" ? \"estimated\" : null,\n !manifest.enforceable ? \"advisory\" : null,\n ].filter((item): item is string => Boolean(item));\n\n return (\n <div className=\"flex max-h-[min(72vh,520px)] flex-col\">\n <div className=\"border-b border-border/60 px-3 py-2.5\">\n <div className=\"flex items-center justify-between gap-3\">\n <h2 className=\"min-w-0 truncate text-sm font-medium text-foreground\">\n Context X-Ray\n </h2>\n <div className=\"shrink-0 text-xs tabular-nums text-muted-foreground\">\n {formatTokens(manifest.totalTokens)} · {pct}%\n </div>\n </div>\n <div className=\"mt-2 h-1 overflow-hidden rounded-full bg-muted/70\">\n <div\n className=\"h-full rounded-full bg-foreground origin-left transition-transform duration-200\"\n style={{\n transform: `scaleX(${Math.min(1, pct / 100)})`,\n width: \"100%\",\n }}\n />\n </div>\n <div className=\"mt-1.5 flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px] text-muted-foreground\">\n {details.map((detail) => (\n <span key={detail}>{detail}</span>\n ))}\n {manifest.reclaimedTokens > 0 && (\n <span className=\"font-medium text-emerald-600 dark:text-emerald-400\">\n -{formatTokens(manifest.reclaimedTokens)}\n </span>\n )}\n </div>\n </div>\n\n <div className=\"overflow-y-auto px-2 py-2\">\n <div className=\"mb-1 flex items-center justify-end\">\n <div className=\"inline-flex rounded-md bg-muted/40 p-0.5\">\n <Tooltip>\n <TooltipTrigger asChild>\n <button\n type=\"button\"\n onClick={() => setMode(\"list\")}\n aria-label=\"Show context list\"\n className={cn(\n \"flex size-7 items-center justify-center rounded text-muted-foreground\",\n mode === \"list\"\n ? \"bg-background text-foreground shadow-sm\"\n : \"hover:text-foreground\",\n )}\n >\n <IconListDetails className=\"h-3.5 w-3.5\" />\n </button>\n </TooltipTrigger>\n <TooltipContent>List</TooltipContent>\n </Tooltip>\n <Tooltip>\n <TooltipTrigger asChild>\n <button\n type=\"button\"\n onClick={() => setMode(\"map\")}\n aria-label=\"Show context map\"\n className={cn(\n \"flex size-7 items-center justify-center rounded text-muted-foreground\",\n mode === \"map\"\n ? \"bg-background text-foreground shadow-sm\"\n : \"hover:text-foreground\",\n )}\n >\n <IconChartTreemap className=\"h-3.5 w-3.5\" />\n </button>\n </TooltipTrigger>\n <TooltipContent>Map</TooltipContent>\n </Tooltip>\n </div>\n </div>\n\n {mode === \"map\" ? (\n <ContextTreemap\n segments={segments}\n onSelect={(segmentId) => {\n const segment = segments.find((s) => s.segmentId === segmentId);\n if (segment) setCollapsed(new Set());\n }}\n />\n ) : (\n <div className=\"divide-y divide-border/60\">\n {groups.map((group) => {\n const isCollapsed = collapsed.has(group.name);\n return (\n <div key={group.name}>\n <button\n type=\"button\"\n onClick={() => {\n setCollapsed((prev) => {\n const next = new Set(prev);\n if (next.has(group.name)) next.delete(group.name);\n else next.add(group.name);\n return next;\n });\n }}\n className=\"flex w-full items-center gap-2 rounded-sm px-1.5 py-2 text-left hover:bg-accent/35\"\n >\n {isCollapsed ? (\n <IconChevronRight className=\"h-3.5 w-3.5 text-muted-foreground\" />\n ) : (\n <IconChevronDown className=\"h-3.5 w-3.5 text-muted-foreground\" />\n )}\n <span\n className={cn(\n \"h-2 w-2 rounded-full\",\n groupColor(group.name),\n )}\n />\n <span className=\"min-w-0 flex-1 truncate text-xs font-medium\">\n {group.name}\n </span>\n <span className=\"text-[11px] text-muted-foreground\">\n {formatTokens(group.tokens)}\n </span>\n </button>\n {!isCollapsed && (\n <div className=\"pb-1\">\n {group.segments\n .slice()\n .sort((a, b) => b.tokenCount - a.tokenCount)\n .map((segment) => (\n <ContextSegmentRow\n key={segment.segmentId}\n segment={segment}\n advisory={!manifest.enforceable}\n onPin={() => onPin(segment.segmentId)}\n onEvict={() => onEvict(segment.segmentId)}\n onRestore={() => onRestore(segment.segmentId)}\n />\n ))}\n </div>\n )}\n </div>\n );\n })}\n </div>\n )}\n </div>\n </div>\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExtensionEditor.d.ts","sourceRoot":"","sources":["../../../src/client/extensions/ExtensionEditor.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ExtensionEditor.d.ts","sourceRoot":"","sources":["../../../src/client/extensions/ExtensionEditor.tsx"],"names":[],"mappings":"AA8CA,MAAM,WAAW,oBAAoB;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,eAAe,CAAC,EAAE,WAAW,EAAE,EAAE,oBAAoB,+BAwYpE"}
|
|
@@ -10,6 +10,7 @@ import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, } from "../co
|
|
|
10
10
|
import { useT } from "../i18n.js";
|
|
11
11
|
import { cn } from "../utils.js";
|
|
12
12
|
import { deleteOrHideExtension, invalidateExtensionRemoval, } from "./delete-extension.js";
|
|
13
|
+
import { ExtensionQueryErrorState } from "./ExtensionQueryErrorState.js";
|
|
13
14
|
export function ExtensionEditor({ extensionId }) {
|
|
14
15
|
const t = useT();
|
|
15
16
|
const navigate = useNavigate();
|
|
@@ -22,17 +23,19 @@ export function ExtensionEditor({ extensionId }) {
|
|
|
22
23
|
const [deleting, setDeleting] = useState(false);
|
|
23
24
|
const [menuOpen, setMenuOpen] = useState(false);
|
|
24
25
|
const [confirmingDelete, setConfirmingDelete] = useState(false);
|
|
25
|
-
const
|
|
26
|
+
const slotsQuery = useQuery({
|
|
26
27
|
queryKey: ["extension-slots", extensionId],
|
|
27
28
|
queryFn: async () => {
|
|
28
29
|
const res = await fetch(agentNativePath(`/_agent-native/slots/extension/${extensionId}`));
|
|
29
|
-
if (!res.ok)
|
|
30
|
-
|
|
30
|
+
if (!res.ok) {
|
|
31
|
+
throw new Error(`Failed to load extension slots (${res.status})`);
|
|
32
|
+
}
|
|
31
33
|
return res.json();
|
|
32
34
|
},
|
|
33
35
|
enabled: isEdit && menuOpen,
|
|
34
36
|
});
|
|
35
|
-
const
|
|
37
|
+
const slots = slotsQuery.data ?? [];
|
|
38
|
+
const existingToolQuery = useQuery({
|
|
36
39
|
queryKey: ["extension", extensionId],
|
|
37
40
|
queryFn: async () => {
|
|
38
41
|
const res = await fetch(agentNativePath(`/_agent-native/extensions/${extensionId}`));
|
|
@@ -42,6 +45,7 @@ export function ExtensionEditor({ extensionId }) {
|
|
|
42
45
|
},
|
|
43
46
|
enabled: isEdit,
|
|
44
47
|
});
|
|
48
|
+
const existingTool = existingToolQuery.data;
|
|
45
49
|
useEffect(() => {
|
|
46
50
|
if (existingTool) {
|
|
47
51
|
setName(existingTool.name ?? "");
|
|
@@ -125,6 +129,12 @@ export function ExtensionEditor({ extensionId }) {
|
|
|
125
129
|
queryClient.invalidateQueries({ queryKey: ["slot-installs", slotId] });
|
|
126
130
|
}
|
|
127
131
|
};
|
|
132
|
+
if (isEdit && existingToolQuery.isLoading) {
|
|
133
|
+
return (_jsxs("div", { className: "flex h-full flex-col", children: [_jsx("div", { className: "h-12 shrink-0 border-b" }), _jsx("div", { className: "flex-1 bg-muted/20 animate-pulse" })] }));
|
|
134
|
+
}
|
|
135
|
+
if (isEdit && existingToolQuery.isError) {
|
|
136
|
+
return (_jsx(ExtensionQueryErrorState, { className: "h-full min-h-[20rem]", message: t("extensions.loadError"), onRetry: () => void existingToolQuery.refetch(), retrying: existingToolQuery.isFetching }));
|
|
137
|
+
}
|
|
128
138
|
return (_jsx(TooltipProvider, { delayDuration: 200, children: _jsxs("div", { className: "flex h-full flex-col", children: [_jsxs("header", { className: "flex items-center justify-between border-b px-4 py-3", children: [_jsxs("div", { className: "flex items-center gap-3", children: [_jsx(Link, { to: extensionId
|
|
129
139
|
? extensionPath(extensionId, existingTool?.name ?? name)
|
|
130
140
|
: "/extensions", className: "inline-flex cursor-pointer items-center justify-center rounded-md p-1 text-muted-foreground hover:bg-accent hover:text-accent-foreground", "aria-label": t("extensions.back"), children: _jsx(IconArrowLeft, { className: "h-4 w-4" }) }), _jsx("h1", { className: "text-sm font-semibold", children: isEdit
|
|
@@ -137,7 +147,7 @@ export function ExtensionEditor({ extensionId }) {
|
|
|
137
147
|
setMenuOpen(o);
|
|
138
148
|
if (!o)
|
|
139
149
|
setConfirmingDelete(false);
|
|
140
|
-
}, children: [_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx(PopoverTrigger, { asChild: true, children: _jsx("button", { type: "button", className: "inline-flex h-8 w-8 cursor-pointer items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-accent-foreground", "aria-label": t("extensions.moreOptions"), children: _jsx(IconDots, { className: "h-4 w-4" }) }) }) }), _jsx(TooltipContent, { children: t("extensions.moreOptions") })] }), _jsx(PopoverContent, { align: "end", sideOffset: 4, className: "w-72 p-0", children: !confirmingDelete ? (_jsxs(_Fragment, { children: [_jsxs("div", { className: "px-3 py-2 border-b border-border/40", children: [_jsx("p", { className: "text-[12px] font-medium", children: t("extensions.appearsIn") }), slots.length === 0 ? (_jsx("p", { className: "text-[11px] text-muted-foreground/70 mt-0.5", children: t("extensions.noWidgetAreas") })) : (_jsx("p", { className: "text-[11px] text-muted-foreground/70 mt-0.5", children: t("extensions.widgetAreaCount", {
|
|
150
|
+
}, children: [_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx(PopoverTrigger, { asChild: true, children: _jsx("button", { type: "button", className: "inline-flex h-8 w-8 cursor-pointer items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-accent-foreground", "aria-label": t("extensions.moreOptions"), children: _jsx(IconDots, { className: "h-4 w-4" }) }) }) }), _jsx(TooltipContent, { children: t("extensions.moreOptions") })] }), _jsx(PopoverContent, { align: "end", sideOffset: 4, className: "w-72 p-0", children: !confirmingDelete ? (_jsxs(_Fragment, { children: [_jsxs("div", { className: "px-3 py-2 border-b border-border/40", children: [_jsx("p", { className: "text-[12px] font-medium", children: t("extensions.appearsIn") }), slotsQuery.isError ? (_jsx(ExtensionQueryErrorState, { compact: true, className: "px-0", message: t("extensions.widgetAreasLoadError"), onRetry: () => void slotsQuery.refetch(), retrying: slotsQuery.isFetching })) : slots.length === 0 ? (_jsx("p", { className: "text-[11px] text-muted-foreground/70 mt-0.5", children: t("extensions.noWidgetAreas") })) : (_jsx("p", { className: "text-[11px] text-muted-foreground/70 mt-0.5", children: t("extensions.widgetAreaCount", {
|
|
141
151
|
count: slots.length,
|
|
142
152
|
}) }))] }), slots.length > 0 && (_jsx("div", { className: "max-h-48 overflow-y-auto py-1", children: slots.map((s) => (_jsxs("div", { className: "flex items-center gap-2 px-3 py-1.5 text-[12px]", children: [_jsx("span", { className: "flex-1 truncate font-mono text-[11px] text-muted-foreground", children: s.slotId }), _jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx("button", { type: "button", onClick: () => handleRemoveFromSlot(s.slotId), className: "rounded p-1 text-muted-foreground/60 hover:bg-accent hover:text-foreground cursor-pointer", "aria-label": t("extensions.removeFromWidgetArea"), children: _jsx(IconX, { className: "h-3.5 w-3.5" }) }) }), _jsx(TooltipContent, { children: t("extensions.removeFromWidgetAreaForMe") })] })] }, s.id))) })), _jsx("div", { className: "border-t border-border/40 p-1", children: _jsxs("button", { type: "button", onClick: () => setConfirmingDelete(true), className: "flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-[12px] text-destructive hover:bg-destructive/10 cursor-pointer text-left", children: [_jsx(IconTrash, { className: "h-3.5 w-3.5" }), _jsx("span", { children: existingTool?.canDelete === false
|
|
143
153
|
? t("extensions.removeFromMyListEllipsis")
|