chat-js 1.0.0-alpha.7 → 1.0.0-beta.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/README.md +8 -6
- package/dist/index.js +7487 -6859
- package/package.json +2 -2
- package/templates/chat-app/AGENTS.md +1 -1
- package/templates/chat-app/agent/agent.ts +0 -2
- package/templates/chat-app/agent/hooks/followup-suggestions.ts +1 -1
- package/templates/chat-app/agent/hooks/projects.ts +1 -1
- package/templates/chat-app/agent/hooks/search.ts +1 -1
- package/templates/chat-app/agent/instructions/projects.ts +1 -1
- package/templates/chat-app/agent/tools/mcp.ts +1 -1
- package/templates/chat-app/app/(auth)/device-login/page.tsx +1 -1
- package/templates/chat-app/app/(chat)/api/files/upload/route.ts +1 -1
- package/templates/chat-app/app/(chat)/chat/{[id] → [chatId]}/page.tsx +4 -4
- package/templates/chat-app/app/(chat)/project/[projectId]/chat/[chatId]/page.tsx +1 -1
- package/templates/chat-app/app/(chat)/project/[projectId]/page.tsx +1 -1
- package/templates/chat-app/app/(chat)/settings/connectors/[connectorId]/page.tsx +1 -1
- package/templates/chat-app/app/(chat)/settings/connectors/page.tsx +1 -1
- package/templates/chat-app/app/(chat)/settings/models/page.tsx +1 -1
- package/templates/chat-app/app/(chat)/share/[id]/page.tsx +1 -1
- package/templates/chat-app/app/api/agent-conversations/route.test.ts +5 -5
- package/templates/chat-app/app/api/agent-conversations/route.ts +2 -2
- package/templates/chat-app/app/api/agent-response-groups/route.test.ts +5 -5
- package/templates/chat-app/app/api/agent-response-groups/route.ts +1 -1
- package/templates/chat-app/app/api/eve/[...path]/route.test.ts +133 -4
- package/templates/chat-app/app/api/eve/[...path]/route.ts +175 -49
- package/templates/chat-app/app/api/eve-guest/route.ts +1 -1
- package/templates/chat-app/app/api/mcp/oauth/callback/route.ts +1 -1
- package/templates/chat-app/app/editor.css +0 -6
- package/templates/chat-app/app/layout.tsx +11 -18
- package/templates/chat-app/app/opengraph-image.png +0 -0
- package/templates/chat-app/chat.config.ts +0 -44
- package/templates/chat-app/chatjs/core/chat/compose.ts +4 -4
- package/templates/chat-app/chatjs/core/chat/contracts.ts +6 -6
- package/templates/chat-app/chatjs/core/gateway/runtime.ts +0 -7
- package/templates/chat-app/chatjs/core/installation/contracts.ts +0 -7
- package/templates/chat-app/chatjs/core/ui/slots.tsx +15 -5
- package/templates/chat-app/chatjs/generated/installed-auth-ui.ts +2 -2
- package/templates/chat-app/chatjs/generated/installed-auth.ts +4 -2
- package/templates/chat-app/chatjs/generated/installed-billing.ts +2 -2
- package/templates/chat-app/chatjs/generated/installed-chat-ui.ts +28 -24
- package/templates/chat-app/chatjs/generated/installed-chat.ts +12 -12
- package/templates/chat-app/chatjs/generated/installed-cleanup.ts +4 -4
- package/templates/chat-app/chatjs/generated/installed-instrumentation.ts +8 -2
- package/templates/chat-app/chatjs/generated/installed-layout.ts +2 -2
- package/templates/chat-app/chatjs/generated/installed-model-visibility.ts +2 -2
- package/templates/chat-app/chatjs/generated/installed-navigation.ts +2 -2
- package/templates/chat-app/chatjs/generated/installed-routers.ts +18 -19
- package/templates/chat-app/chatjs/generated/installed-session-profiles.ts +5 -3
- package/templates/chat-app/chatjs/generated/installed-sign-out.ts +2 -2
- package/templates/chat-app/chatjs/generated/installed-signed-out.ts +2 -2
- package/templates/chat-app/chatjs/generated/installed-uploads.ts +2 -2
- package/templates/chat-app/chatjs/generated/installed.ts +2 -0
- package/templates/chat-app/chatjs/plugins/ai-titles/{chat.ts → chat-server.ts} +3 -1
- package/templates/chat-app/chatjs/plugins/ai-titles/generate-title.ts +7 -9
- package/templates/chat-app/chatjs/plugins/ai-titles/{chatjs.json → plugin.json} +3 -4
- package/templates/chat-app/chatjs/plugins/ai-titles/title-queries.ts +4 -4
- package/templates/chat-app/chatjs/plugins/attachment-uploads/{client-plugin.ts → chat-ui.ts} +1 -3
- package/templates/chat-app/chatjs/plugins/attachment-uploads/plugin.json +16 -0
- package/templates/chat-app/chatjs/plugins/credits/billing.ts +3 -1
- package/templates/chat-app/chatjs/plugins/credits/{client-plugin.ts → chat-ui.ts} +1 -1
- package/templates/chat-app/chatjs/plugins/credits/{chatjs.json → plugin.json} +4 -13
- package/templates/chat-app/chatjs/plugins/credits/router.ts +4 -2
- package/templates/chat-app/chatjs/plugins/desktop/auth-form.tsx +3 -1
- package/templates/chat-app/chatjs/plugins/desktop/auth-server.ts +3 -1
- package/templates/chat-app/chatjs/plugins/desktop/{client-plugin.ts → layout-ui.ts} +1 -1
- package/templates/chat-app/chatjs/plugins/desktop/navigation.ts +3 -1
- package/templates/chat-app/chatjs/plugins/desktop/{chatjs.json → plugin.json} +4 -16
- package/templates/chat-app/chatjs/plugins/desktop/sign-out.ts +3 -1
- package/templates/chat-app/chatjs/plugins/feedback/chat-server.ts +13 -0
- package/templates/chat-app/chatjs/plugins/feedback/{client-plugin.ts → chat-ui.ts} +1 -1
- package/templates/chat-app/chatjs/plugins/feedback/feedback-actions.tsx +4 -4
- package/templates/chat-app/chatjs/plugins/feedback/feedback-queries.ts +11 -11
- package/templates/chat-app/chatjs/plugins/feedback/feedback-schema.ts +2 -2
- package/templates/chat-app/chatjs/plugins/feedback/{chatjs.json → plugin.json} +5 -14
- package/templates/chat-app/chatjs/plugins/feedback/router.ts +9 -7
- package/templates/chat-app/chatjs/plugins/feedback/vote-message.ts +3 -6
- package/templates/chat-app/chatjs/plugins/followup-suggestions/{chat.ts → chat-server.ts} +3 -1
- package/templates/chat-app/chatjs/plugins/followup-suggestions/{client-plugin.ts → chat-ui.ts} +1 -1
- package/templates/chat-app/chatjs/plugins/followup-suggestions/followup-queries.ts +2 -2
- package/templates/chat-app/chatjs/plugins/followup-suggestions/{chatjs.json → plugin.json} +5 -17
- package/templates/chat-app/chatjs/plugins/followup-suggestions/router.ts +8 -9
- package/templates/chat-app/chatjs/plugins/followup-suggestions/suggestions.tsx +2 -7
- package/templates/chat-app/chatjs/plugins/followup-suggestions/use-followups.ts +2 -2
- package/templates/chat-app/chatjs/plugins/guest-chat/cleanup.ts +1 -7
- package/templates/chat-app/chatjs/plugins/guest-chat/guest-auth.ts +1 -0
- package/templates/chat-app/chatjs/plugins/guest-chat/instrumentation.ts +6 -0
- package/templates/chat-app/chatjs/plugins/guest-chat/{chatjs.json → plugin.json} +6 -12
- package/templates/chat-app/chatjs/plugins/guest-chat/session-profile.ts +3 -1
- package/templates/chat-app/chatjs/plugins/guest-chat/signed-out.tsx +53 -24
- package/templates/chat-app/chatjs/plugins/image-viewer/{client-plugin.ts → chat-ui.ts} +1 -1
- package/templates/chat-app/chatjs/plugins/image-viewer/plugin.json +11 -0
- package/templates/chat-app/chatjs/plugins/mcp/{client-plugin.ts → chat-ui.ts} +1 -1
- package/templates/chat-app/chatjs/plugins/mcp/db/encrypted-text.ts +1 -1
- package/templates/chat-app/chatjs/plugins/mcp/{chatjs.json → plugin.json} +5 -13
- package/templates/chat-app/chatjs/plugins/mcp/router.ts +4 -2
- package/templates/chat-app/chatjs/plugins/mcp/routes/connectors-page.tsx +4 -1
- package/templates/chat-app/chatjs/plugins/mcp/setup.ts +2 -2
- package/templates/chat-app/chatjs/plugins/mcp/ui/connectors-settings.tsx +1 -1
- package/templates/chat-app/chatjs/plugins/mcp/ui/mcp-connect-dialog.tsx +1 -1
- package/templates/chat-app/chatjs/plugins/mcp/ui/mcp-create-dialog.tsx +1 -1
- package/templates/chat-app/chatjs/plugins/mcp/{mcp-env.ts → validate-env.ts} +2 -1
- package/templates/chat-app/chatjs/plugins/model-preferences/{client-plugin.ts → chat-ui.ts} +1 -3
- package/templates/chat-app/chatjs/plugins/model-preferences/model-row.tsx +3 -0
- package/templates/chat-app/chatjs/plugins/model-preferences/{use-model-preferences.ts → model-visibility.ts} +1 -1
- package/templates/chat-app/chatjs/plugins/model-preferences/models-settings.tsx +1 -0
- package/templates/chat-app/chatjs/plugins/model-preferences/{chatjs.json → plugin.json} +5 -13
- package/templates/chat-app/chatjs/plugins/model-preferences/router.ts +5 -1
- package/templates/chat-app/chatjs/plugins/projects/{chat.ts → chat-server.ts} +3 -1
- package/templates/chat-app/chatjs/plugins/projects/{client-plugin.ts → chat-ui.ts} +1 -1
- package/templates/chat-app/chatjs/plugins/projects/conversation-hook.ts +1 -1
- package/templates/chat-app/chatjs/plugins/projects/db/project-queries.ts +2 -2
- package/templates/chat-app/chatjs/plugins/projects/{chatjs.json → plugin.json} +5 -14
- package/templates/chat-app/chatjs/plugins/projects/router.ts +7 -7
- package/templates/chat-app/chatjs/plugins/projects/routes/project-page.tsx +10 -1
- package/templates/chat-app/chatjs/plugins/projects/ui/chat-contributions.tsx +3 -3
- package/templates/chat-app/chatjs/plugins/projects/ui/delete-project-dialog.tsx +0 -3
- package/templates/chat-app/chatjs/plugins/projects/ui/eve-move-project-dialog.tsx +1 -1
- package/templates/chat-app/chatjs/plugins/projects/ui/project-icon-picker.tsx +1 -0
- package/templates/chat-app/chatjs/plugins/projects/ui/sidebar-projects.tsx +12 -11
- package/templates/chat-app/chatjs/plugins/search/{chat.ts → chat-server.ts} +8 -6
- package/templates/chat-app/chatjs/plugins/search/{client-plugin.ts → chat-ui.ts} +1 -1
- package/templates/chat-app/chatjs/plugins/search/{chatjs.json → plugin.json} +5 -14
- package/templates/chat-app/chatjs/plugins/search/router.ts +4 -2
- package/templates/chat-app/chatjs/plugins/search/search-backfill.ts +4 -4
- package/templates/chat-app/chatjs/plugins/search/search-chats.tsx +1 -1
- package/templates/chat-app/chatjs/plugins/search/search-hook.ts +2 -2
- package/templates/chat-app/chatjs/plugins/search/search-queries.ts +13 -13
- package/templates/chat-app/chatjs/plugins/search/search-results-view.tsx +2 -2
- package/templates/chat-app/chatjs/plugins/search/search-schema.ts +3 -3
- package/templates/chat-app/chatjs/plugins/sharing/{chat.ts → chat-server.ts} +3 -1
- package/templates/chat-app/chatjs/plugins/sharing/{client-plugin.ts → chat-ui.ts} +1 -1
- package/templates/chat-app/chatjs/plugins/sharing/{chatjs.json → plugin.json} +5 -14
- package/templates/chat-app/chatjs/plugins/sharing/router.ts +4 -2
- package/templates/chat-app/chatjs/plugins/sharing/ui/chat-contributions.tsx +9 -11
- package/templates/chat-app/chatjs/plugins/sharing/ui/share-button.tsx +6 -6
- package/templates/chat-app/chatjs/plugins/sharing/ui/share-dialog.tsx +9 -9
- package/templates/chat-app/chatjs/plugins/spreadsheet-viewer/{client-plugin.ts → chat-ui.ts} +1 -1
- package/templates/chat-app/chatjs/plugins/spreadsheet-viewer/plugin.json +12 -0
- package/templates/chat-app/chatjs/plugins/streamdown-math/chat-ui.ts +11 -0
- package/templates/chat-app/chatjs/plugins/streamdown-math/plugin.json +6 -0
- package/templates/chat-app/chatjs/plugins/streamdown-mermaid/chat-ui.ts +10 -0
- package/templates/chat-app/chatjs/plugins/streamdown-mermaid/plugin.json +6 -0
- package/templates/chat-app/chatjs/plugins/video-viewer/{client-plugin.ts → chat-ui.ts} +1 -1
- package/templates/chat-app/chatjs/plugins/video-viewer/plugin.json +10 -0
- package/templates/chat-app/chatjs/providers/gateway.ts +49 -55
- package/templates/chat-app/chatjs/tools/attach-workspace-file/tool.ts +2 -2
- package/templates/chat-app/chatjs/tools/generate-image/tool.test.ts +3 -14
- package/templates/chat-app/components/ai-elements/response.tsx +16 -15
- package/templates/chat-app/components/auth-form-view.tsx +35 -43
- package/templates/chat-app/components/chat/chat-composer.tsx +90 -27
- package/templates/chat-app/components/chat/chat-conversation-screen.tsx +3 -3
- package/templates/chat-app/components/chat/chat-navigation.tsx +11 -1
- package/templates/chat-app/components/chat/chat-sidebar.tsx +8 -9
- package/templates/chat-app/components/chat/chat-transcript.tsx +52 -23
- package/templates/chat-app/components/chat-slots.tsx +1 -1
- package/templates/chat-app/components/composer/composer-menu.tsx +5 -4
- package/templates/chat-app/components/composer/prompt-form.tsx +7 -1
- package/templates/chat-app/components/eve/eve-chat-error.tsx +12 -2
- package/templates/chat-app/components/eve/eve-chat-header.tsx +5 -7
- package/templates/chat-app/components/eve/eve-chat-page.tsx +9 -9
- package/templates/chat-app/components/eve/eve-composer.tsx +16 -5
- package/templates/chat-app/components/eve/eve-conversation.tsx +342 -209
- package/templates/chat-app/components/eve/eve-creation-recovery.tsx +53 -3
- package/templates/chat-app/components/eve/eve-deletion-provider.tsx +10 -12
- package/templates/chat-app/components/eve/eve-history-list.tsx +4 -9
- package/templates/chat-app/components/eve/eve-logical-context.tsx +1 -0
- package/templates/chat-app/components/eve/eve-logical-navigation.tsx +3 -3
- package/templates/chat-app/components/eve/eve-message-content.tsx +252 -0
- package/templates/chat-app/components/eve/eve-message-part.tsx +13 -58
- package/templates/chat-app/components/eve/eve-pending-input.tsx +82 -5
- package/templates/chat-app/components/eve/eve-runtime-provider.tsx +74 -15
- package/templates/chat-app/components/eve/use-eve-composer-draft.ts +64 -26
- package/templates/chat-app/components/eve/use-eve-fork.ts +14 -16
- package/templates/chat-app/components/eve/use-logical-commands.ts +3 -3
- package/templates/chat-app/components/eve/use-new-eve-conversation.tsx +42 -7
- package/templates/chat-app/components/model-selection-indicator.tsx +12 -10
- package/templates/chat-app/components/model-selector-view.tsx +211 -186
- package/templates/chat-app/components/new-chat-button.tsx +1 -1
- package/templates/chat-app/components/parallel-responses/model-picker.tsx +5 -1
- package/templates/chat-app/components/parallel-responses/responses.tsx +2 -2
- package/templates/chat-app/components/settings/settings-nav.tsx +1 -1
- package/templates/chat-app/components/settings/settings-navigation-link.tsx +1 -0
- package/templates/chat-app/components/sidebar-top-row.tsx +1 -1
- package/templates/chat-app/components/ui/sidebar.tsx +1 -1
- package/templates/chat-app/components/ui/trace.tsx +1 -1
- package/templates/chat-app/hooks/use-auto-focus.ts +12 -13
- package/templates/chat-app/integrations/routers.ts +1 -1
- package/templates/chat-app/lib/ai/active-gateway.ts +0 -9
- package/templates/chat-app/lib/ai/app-models.test.ts +0 -4
- package/templates/chat-app/lib/ai/app-models.ts +11 -6
- package/templates/chat-app/lib/ai/gateways/registry.ts +4 -31
- package/templates/chat-app/lib/ai/model-catalog.ts +50 -0
- package/templates/chat-app/lib/ai/models.ts +4 -39
- package/templates/chat-app/lib/ai/providers.ts +2 -16
- package/templates/chat-app/lib/chat-after-create.test.ts +1 -1
- package/templates/chat-app/lib/chat-after-create.ts +1 -1
- package/templates/chat-app/lib/config-schema.ts +0 -96
- package/templates/chat-app/lib/db/eve-creation-failure.ts +3 -3
- package/templates/chat-app/lib/db/eve-current-copy.ts +11 -11
- package/templates/chat-app/lib/db/eve-deletion.ts +19 -19
- package/templates/chat-app/lib/db/eve-dispatch.ts +115 -18
- package/templates/chat-app/lib/db/eve-file-purge.ts +4 -4
- package/templates/chat-app/lib/db/eve-files.ts +13 -13
- package/templates/chat-app/lib/db/eve-queries.ts +28 -43
- package/templates/chat-app/lib/db/eve-response-groups.ts +30 -112
- package/templates/chat-app/lib/db/eve-subagents.ts +8 -8
- package/templates/chat-app/lib/db/eve-title.ts +2 -2
- package/templates/chat-app/lib/db/eve-workspace-deletion.ts +3 -3
- package/templates/chat-app/lib/db/eve-workspace-turns.ts +37 -5
- package/templates/chat-app/lib/db/eve-workspaces.ts +3 -3
- package/templates/chat-app/lib/db/migrations/0029_branch_identifiers.sql +23 -0
- package/templates/chat-app/lib/db/migrations/meta/0029_snapshot.json +2547 -0
- package/templates/chat-app/lib/db/migrations/meta/_journal.json +7 -0
- package/templates/chat-app/lib/db/schema.ts +19 -25
- package/templates/chat-app/lib/devtools-disabled.ts +1 -0
- package/templates/chat-app/lib/eve/completed-copy-source.test.ts +12 -2
- package/templates/chat-app/lib/eve/completed-copy-source.ts +5 -2
- package/templates/chat-app/lib/eve/contracts.test.ts +5 -5
- package/templates/chat-app/lib/eve/contracts.ts +1 -1
- package/templates/chat-app/lib/eve/conversation-scope.test.ts +2 -2
- package/templates/chat-app/lib/eve/conversation-scope.ts +4 -4
- package/templates/chat-app/lib/eve/create-conversation-operation.test.ts +1 -1
- package/templates/chat-app/lib/eve/create-response-group.test.ts +3 -3
- package/templates/chat-app/lib/eve/delete-local-conversation.ts +3 -3
- package/templates/chat-app/lib/eve/generated-files.test.ts +1 -1
- package/templates/chat-app/lib/eve/generated-files.ts +2 -2
- package/templates/chat-app/lib/eve/logical-chat.test.ts +17 -17
- package/templates/chat-app/lib/eve/logical-chat.ts +27 -31
- package/templates/chat-app/lib/eve/logical-response-slots.ts +4 -7
- package/templates/chat-app/lib/eve/message-delivery.ts +1 -0
- package/templates/chat-app/lib/eve/model-selection.test.ts +47 -50
- package/templates/chat-app/lib/eve/model-selection.ts +5 -37
- package/templates/chat-app/lib/eve/pending-create.test.ts +46 -7
- package/templates/chat-app/lib/eve/pending-create.ts +36 -4
- package/templates/chat-app/lib/eve/persisted-wire-order.test.ts +2 -2
- package/templates/chat-app/lib/eve/prepare-deletion.ts +3 -3
- package/templates/chat-app/lib/eve/purge-local-resources.ts +3 -3
- package/templates/chat-app/lib/eve/reconcile-workspace-turn.ts +2 -2
- package/templates/chat-app/lib/eve/request-policy.ts +1 -0
- package/templates/chat-app/lib/eve/resolve-creation-request.ts +1 -1
- package/templates/chat-app/lib/eve/response-group-contracts.ts +1 -1
- package/templates/chat-app/lib/eve/response-group-lineage.test.ts +12 -12
- package/templates/chat-app/lib/eve/response-group-lineage.ts +21 -24
- package/templates/chat-app/lib/eve/response-group.test.ts +2 -2
- package/templates/chat-app/lib/eve/response-group.ts +1 -1
- package/templates/chat-app/lib/eve/response-model.ts +11 -1
- package/templates/chat-app/lib/eve/restore-message-attachments.test.ts +1 -1
- package/templates/chat-app/lib/eve/restore-message-attachments.ts +3 -3
- package/templates/chat-app/lib/eve/retire-session.ts +3 -3
- package/templates/chat-app/lib/eve/steer-rejected.ts +7 -0
- package/templates/chat-app/lib/eve/tool-cost.test.ts +18 -6
- package/templates/chat-app/lib/eve/tool-cost.ts +10 -18
- package/templates/chat-app/lib/eve/workspace-turn-evidence.test.ts +27 -0
- package/templates/chat-app/lib/eve/workspace-turn-evidence.ts +20 -13
- package/templates/chat-app/oxfmt.config.ts +0 -2
- package/templates/chat-app/package.json +7 -9
- package/templates/chat-app/playwright.config.ts +5 -1
- package/templates/chat-app/proxy.ts +2 -4
- package/templates/chat-app/scripts/agent-status.ts +6 -19
- package/templates/chat-app/scripts/build-eve.test.ts +56 -0
- package/templates/chat-app/scripts/build-eve.ts +12 -5
- package/templates/chat-app/scripts/check-env.ts +77 -73
- package/templates/chat-app/scripts/environment-validation-report.ts +1 -20
- package/templates/chat-app/scripts/installed-environment-validation.ts +14 -15
- package/templates/chat-app/trpc/init.ts +2 -0
- package/templates/chat-app/trpc/react.tsx +2 -2
- package/templates/chat-app/trpc/routers/_app.test.ts +56 -0
- package/templates/chat-app/trpc/routers/_app.ts +12 -11
- package/templates/chat-app/trpc/routers/eve.router.ts +2 -2
- package/templates/electron/forge.config.ts +1 -19
- package/templates/electron/scripts/write-branding.ts +1 -5
- package/templates/chat-app/app/privacy/page.tsx +0 -153
- package/templates/chat-app/app/terms/page.tsx +0 -270
- package/templates/chat-app/chatjs/core/installation/plugin.ts +0 -13
- package/templates/chat-app/chatjs/plugins/attachment-uploads/chatjs.json +0 -22
- package/templates/chat-app/chatjs/plugins/credits/server-plugin.ts +0 -5
- package/templates/chat-app/chatjs/plugins/feedback/chat.ts +0 -13
- package/templates/chat-app/chatjs/plugins/feedback/server-plugin.ts +0 -8
- package/templates/chat-app/chatjs/plugins/followup-suggestions/server-plugin.ts +0 -8
- package/templates/chat-app/chatjs/plugins/guest-chat/server-plugin.ts +0 -12
- package/templates/chat-app/chatjs/plugins/image-viewer/chatjs.json +0 -17
- package/templates/chat-app/chatjs/plugins/mcp/server-plugin.ts +0 -5
- package/templates/chat-app/chatjs/plugins/model-preferences/server-plugin.ts +0 -8
- package/templates/chat-app/chatjs/plugins/projects/server-plugin.ts +0 -8
- package/templates/chat-app/chatjs/plugins/search/server-plugin.ts +0 -5
- package/templates/chat-app/chatjs/plugins/sharing/server-plugin.ts +0 -5
- package/templates/chat-app/chatjs/plugins/spreadsheet-viewer/chatjs.json +0 -18
- package/templates/chat-app/chatjs/plugins/video-viewer/chatjs.json +0 -16
- package/templates/chat-app/components/ai-elements/context-hover.radix.tsx +0 -15
- package/templates/chat-app/components/ai-elements/context-hover.tsx +0 -17
- package/templates/chat-app/components/ai-elements/context.tsx +0 -405
- package/templates/chat-app/components/composer/editor.css +0 -96
- package/templates/chat-app/components/lexical-chat-input.tsx +0 -276
- package/templates/chat-app/components/model-selection-indicator.radix.tsx +0 -17
- package/templates/chat-app/components/ui/resizable.tsx +0 -49
- package/templates/chat-app/lib/ai/gateways/fallback-models.ts +0 -29
- package/templates/chat-app/lib/ai/models.generated.ts +0 -4242
- package/templates/chat-app/lib/ai/usage-token-details.test.ts +0 -76
- package/templates/chat-app/lib/ai/usage-token-details.ts +0 -33
- package/templates/chat-app/lib/chat-route.ts +0 -18
- package/templates/chat-app/providers/parse-chat-id-from-pathname.test.ts +0 -126
- package/templates/chat-app/providers/parse-chat-id-from-pathname.ts +0 -51
- package/templates/chat-app/scripts/fetch-models.ts +0 -30
- package/templates/chat-app/scripts/gateway-snapshot-warning.test.ts +0 -9
- /package/templates/chat-app/chatjs/plugins/attachment-uploads/{integration.tsx → uploads.ts} +0 -0
|
@@ -12,13 +12,13 @@ const SEARCH_INDEX_BATCH_SIZE = 100;
|
|
|
12
12
|
/**
|
|
13
13
|
* Recover from durable events, including text omitted from the bounded live retry buffer.
|
|
14
14
|
* @param {string} ownerId Owner whose EVE credentials and search index receive the recovered text.
|
|
15
|
-
* @param {string}
|
|
15
|
+
* @param {string} branchId Conversation receiving idempotent event and seed search entries.
|
|
16
16
|
* @param {string} sessionId Durable EVE session whose snapshot supplies the history.
|
|
17
17
|
* @returns {Promise<void>} Resolves after every batch is indexed; snapshot and index failures reject for a later retry.
|
|
18
18
|
*/
|
|
19
19
|
export const backfillEveSearchConversation = async (
|
|
20
20
|
ownerId: string,
|
|
21
|
-
|
|
21
|
+
branchId: string,
|
|
22
22
|
sessionId: string
|
|
23
23
|
): Promise<void> => {
|
|
24
24
|
const client = new Client(getEveConnectionOptions(ownerId));
|
|
@@ -31,10 +31,10 @@ export const backfillEveSearchConversation = async (
|
|
|
31
31
|
batch.push(entry);
|
|
32
32
|
if (batch.length === SEARCH_INDEX_BATCH_SIZE) {
|
|
33
33
|
// oxlint-disable-next-line eslint/no-await-in-loop -- Flush SEARCH_INDEX_BATCH_SIZE text entries before continuing the snapshot so a failed batch stops later writes and buffered indexing work stays bounded.
|
|
34
|
-
await indexEveSearchText(ownerId,
|
|
34
|
+
await indexEveSearchText(ownerId, branchId, batch);
|
|
35
35
|
batch = [];
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
await indexEveSearchText(ownerId,
|
|
39
|
+
await indexEveSearchText(ownerId, branchId, batch);
|
|
40
40
|
};
|
|
@@ -89,14 +89,14 @@ export default defineHook({
|
|
|
89
89
|
// message as well as any restored history omitted from the retry buffer.
|
|
90
90
|
await backfillEveSearchConversation(
|
|
91
91
|
scope.ownerId,
|
|
92
|
-
scope.
|
|
92
|
+
scope.branchId,
|
|
93
93
|
context.session.id
|
|
94
94
|
);
|
|
95
95
|
needsRecovery.update(() => false);
|
|
96
96
|
} else {
|
|
97
97
|
await indexEveSearchText(
|
|
98
98
|
scope.ownerId,
|
|
99
|
-
scope.
|
|
99
|
+
scope.branchId,
|
|
100
100
|
pending.get()
|
|
101
101
|
);
|
|
102
102
|
}
|
|
@@ -48,13 +48,13 @@ const splitSearchChunks = (
|
|
|
48
48
|
* updated when their indexed text changes.
|
|
49
49
|
* @param {SearchTransaction} tx Transaction shared with the caller’s conversation update.
|
|
50
50
|
* @param {string} ownerId Owner whose active conversation is being indexed.
|
|
51
|
-
* @param {string}
|
|
51
|
+
* @param {string} branchId Bound conversation that owns the chunks.
|
|
52
52
|
* @param {readonly EveSearchText[]} entries Search keys and text chunks to persist.
|
|
53
53
|
*/
|
|
54
54
|
const writeEveSearchText = async (
|
|
55
55
|
tx: SearchTransaction,
|
|
56
56
|
ownerId: string,
|
|
57
|
-
|
|
57
|
+
branchId: string,
|
|
58
58
|
entries: readonly EveSearchText[]
|
|
59
59
|
): Promise<void> => {
|
|
60
60
|
const [conversation] = await tx
|
|
@@ -62,7 +62,7 @@ const writeEveSearchText = async (
|
|
|
62
62
|
.from(eveConversation)
|
|
63
63
|
.where(
|
|
64
64
|
and(
|
|
65
|
-
eq(eveConversation.id,
|
|
65
|
+
eq(eveConversation.id, branchId),
|
|
66
66
|
eq(eveConversation.ownerId, ownerId),
|
|
67
67
|
eq(eveConversation.state, "bound")
|
|
68
68
|
)
|
|
@@ -87,33 +87,33 @@ const writeEveSearchText = async (
|
|
|
87
87
|
.slice(index, index + SEARCH_WRITE_BATCH_SIZE)
|
|
88
88
|
.map((entry: EveSearchText) => ({
|
|
89
89
|
...entry,
|
|
90
|
-
|
|
90
|
+
branchId,
|
|
91
91
|
ownerId,
|
|
92
92
|
}))
|
|
93
93
|
)
|
|
94
94
|
.onConflictDoUpdate({
|
|
95
95
|
set: { text: sql`excluded.text` },
|
|
96
96
|
setWhere: sql`${eveSearchText.text} is distinct from excluded.text`,
|
|
97
|
-
target: [eveSearchText.
|
|
97
|
+
target: [eveSearchText.branchId, eveSearchText.key],
|
|
98
98
|
});
|
|
99
99
|
}
|
|
100
100
|
};
|
|
101
101
|
|
|
102
102
|
const indexEveSearchText = async (
|
|
103
103
|
ownerId: string,
|
|
104
|
-
|
|
104
|
+
branchId: string,
|
|
105
105
|
entries: readonly EveSearchText[]
|
|
106
106
|
): Promise<void> => {
|
|
107
107
|
if (entries.length > EMPTY_RESULT_COUNT) {
|
|
108
108
|
await db.transaction(async (tx: SearchTransaction) => {
|
|
109
|
-
await writeEveSearchText(tx, ownerId,
|
|
109
|
+
await writeEveSearchText(tx, ownerId, branchId, entries);
|
|
110
110
|
});
|
|
111
111
|
}
|
|
112
112
|
};
|
|
113
113
|
|
|
114
114
|
const eveSearchResult = z.object({
|
|
115
115
|
id: z.string(),
|
|
116
|
-
|
|
116
|
+
branchId: z.string(),
|
|
117
117
|
title: z.string(),
|
|
118
118
|
excerpt: z.string(),
|
|
119
119
|
updatedAt: z.string(),
|
|
@@ -220,14 +220,14 @@ const searchEveConversations = async (
|
|
|
220
220
|
from parsed
|
|
221
221
|
),
|
|
222
222
|
matches as (
|
|
223
|
-
select chat.id, branch.id as "
|
|
223
|
+
select chat.id, branch.id as "branchId", chat.title, chat."updatedAt",
|
|
224
224
|
2 + ts_rank_cd(to_tsvector('simple', chat.title), query.terms) as rank,
|
|
225
225
|
''::text as body
|
|
226
226
|
from "EveChat" chat cross join query
|
|
227
227
|
join lateral (
|
|
228
228
|
select id from "EveConversation"
|
|
229
229
|
where "chatId" = chat.id and "ownerId" = ${ownerId} and state = 'bound'
|
|
230
|
-
order by (id = chat."
|
|
230
|
+
order by (id = chat."activeBranchId") desc, "createdAt", id limit 1
|
|
231
231
|
) branch on true
|
|
232
232
|
where chat."ownerId" = ${ownerId} and to_tsvector('simple', chat.title) @@ query.terms
|
|
233
233
|
union all
|
|
@@ -235,15 +235,15 @@ const searchEveConversations = async (
|
|
|
235
235
|
ts_rank_cd(to_tsvector('simple', content.text), query.terms) as rank,
|
|
236
236
|
content.text as body
|
|
237
237
|
from "EveSearchText" content cross join query
|
|
238
|
-
join "EveConversation" branch on branch.id = content."
|
|
238
|
+
join "EveConversation" branch on branch.id = content."branchId" and branch."ownerId" = ${ownerId} and branch.state = 'bound'
|
|
239
239
|
join "EveChat" chat on chat.id = branch."chatId" and chat."ownerId" = ${ownerId}
|
|
240
240
|
where content."ownerId" = ${ownerId} and to_tsvector('simple', content.text) @@ query.terms
|
|
241
241
|
), best as (
|
|
242
242
|
select distinct on (id) *, max(rank) over (partition by id) as "chatRank"
|
|
243
243
|
from matches
|
|
244
|
-
order by id, (body <> '') desc, rank desc, "
|
|
244
|
+
order by id, (body <> '') desc, rank desc, "branchId", body
|
|
245
245
|
), headlines as (
|
|
246
|
-
select id, "
|
|
246
|
+
select id, "branchId", title, query.terms::text as "highlightQuery",
|
|
247
247
|
to_char("updatedAt", 'YYYY-MM-DD"T"HH24:MI:SS.US"Z"') as "updatedAt",
|
|
248
248
|
"chatRank"::double precision as rank,
|
|
249
249
|
case when body = '' then '' else ts_headline('simple', body, query.terms,
|
|
@@ -68,7 +68,7 @@ export const EveSearchResultsView = ({
|
|
|
68
68
|
readonly error: boolean;
|
|
69
69
|
readonly items: readonly {
|
|
70
70
|
readonly id: string;
|
|
71
|
-
readonly
|
|
71
|
+
readonly branchId: string;
|
|
72
72
|
readonly title: string;
|
|
73
73
|
readonly excerpt: string;
|
|
74
74
|
}[];
|
|
@@ -184,7 +184,7 @@ export const EveSearchResultsView = ({
|
|
|
184
184
|
key={item.id}
|
|
185
185
|
value={item.id}
|
|
186
186
|
onSelect={() => {
|
|
187
|
-
onSelect(item.
|
|
187
|
+
onSelect(item.branchId);
|
|
188
188
|
}}
|
|
189
189
|
>
|
|
190
190
|
<MessageSquare className="text-muted-foreground mt-0.5 size-4 shrink-0" />
|
|
@@ -13,15 +13,15 @@ import { eveConversation } from "@/lib/db/schema";
|
|
|
13
13
|
export const eveSearchText = pgTable(
|
|
14
14
|
"EveSearchText",
|
|
15
15
|
{
|
|
16
|
-
|
|
16
|
+
branchId: uuid("branchId").notNull(),
|
|
17
17
|
key: text("key").notNull(),
|
|
18
18
|
ownerId: text("ownerId").notNull(),
|
|
19
19
|
text: text("text").notNull(),
|
|
20
20
|
},
|
|
21
21
|
(table) => [
|
|
22
|
-
primaryKey({ columns: [table.
|
|
22
|
+
primaryKey({ columns: [table.branchId, table.key] }),
|
|
23
23
|
foreignKey({
|
|
24
|
-
columns: [table.
|
|
24
|
+
columns: [table.branchId, table.ownerId],
|
|
25
25
|
foreignColumns: [eveConversation.id, eveConversation.ownerId],
|
|
26
26
|
}).onDelete("cascade"),
|
|
27
27
|
index("EveSearchText_owner").on(table.ownerId),
|
|
@@ -2,6 +2,8 @@ import { eq } from "drizzle-orm";
|
|
|
2
2
|
import type { ChatServerIntegration } from "@/chatjs/core/chat/contracts";
|
|
3
3
|
import { eveConversation } from "@/lib/db/schema";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
const sharingChat = {
|
|
6
6
|
publicReadFilter: () => eq(eveConversation.visibility, "public"),
|
|
7
7
|
} satisfies ChatServerIntegration;
|
|
8
|
+
|
|
9
|
+
export default sharingChat;
|
|
@@ -3,7 +3,7 @@ import { definePlugin, slot } from "@/chatjs/core/ui/slots";
|
|
|
3
3
|
import { ChatActions, ChatHeaderActions } from "@/components/chat-slots";
|
|
4
4
|
import { SharingActions, SharingHeaderActions } from "./ui/chat-contributions";
|
|
5
5
|
|
|
6
|
-
export const
|
|
6
|
+
export const chatUi = definePlugin({
|
|
7
7
|
id: "sharing",
|
|
8
8
|
slots: [
|
|
9
9
|
slot(ChatActions, SharingActions),
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
|
+
"contractVersion": 3,
|
|
3
|
+
"uiBase": "base",
|
|
2
4
|
"id": "sharing",
|
|
3
5
|
"kind": "plugin",
|
|
4
6
|
"files": [
|
|
5
|
-
"chatjs/plugins/sharing/chat.ts",
|
|
6
|
-
"chatjs/plugins/sharing/
|
|
7
|
+
"chatjs/plugins/sharing/chat-server.ts",
|
|
8
|
+
"chatjs/plugins/sharing/chat-ui.ts",
|
|
7
9
|
"chatjs/plugins/sharing/public-conversation.ts",
|
|
8
10
|
"chatjs/plugins/sharing/queries.ts",
|
|
9
11
|
"chatjs/plugins/sharing/router.ts",
|
|
10
|
-
"chatjs/plugins/sharing/server-plugin.ts",
|
|
11
12
|
"chatjs/plugins/sharing/ui/chat-contributions.tsx",
|
|
12
13
|
"chatjs/plugins/sharing/ui/share-button.tsx",
|
|
13
14
|
"chatjs/plugins/sharing/ui/share-dialog.tsx",
|
|
@@ -17,15 +18,5 @@
|
|
|
17
18
|
"chatjs/plugins/sharing/ui/transcript-messages.tsx",
|
|
18
19
|
"chatjs/plugins/sharing/ui/shared-page.tsx",
|
|
19
20
|
"app/(chat)/share/[id]/page.tsx"
|
|
20
|
-
]
|
|
21
|
-
"chat": { "export": "sharingChat" },
|
|
22
|
-
"server": { "export": "sharing", "routers": ["sharing"] },
|
|
23
|
-
"client": {
|
|
24
|
-
"export": "sharingClient",
|
|
25
|
-
"composerControls": [],
|
|
26
|
-
"settingsItems": [],
|
|
27
|
-
"chat": true
|
|
28
|
-
},
|
|
29
|
-
"contractVersion": 2,
|
|
30
|
-
"uiBase": "base"
|
|
21
|
+
]
|
|
31
22
|
}
|
|
@@ -3,7 +3,7 @@ import { z } from "zod";
|
|
|
3
3
|
import { createTRPCRouter, protectedProcedure } from "@/trpc/init";
|
|
4
4
|
import { getSharing, setSharing } from "./queries";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
const sharingProcedures = {
|
|
7
7
|
get: protectedProcedure
|
|
8
8
|
.input(z.object({ id: z.uuid() }))
|
|
9
9
|
.query(async ({ ctx, input }) => {
|
|
@@ -24,4 +24,6 @@ export const sharingRouter = createTRPCRouter({
|
|
|
24
24
|
}
|
|
25
25
|
return row;
|
|
26
26
|
}),
|
|
27
|
-
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const router = createTRPCRouter({ sharing: sharingProcedures });
|
|
@@ -9,11 +9,11 @@ export const SharingActions = ({
|
|
|
9
9
|
chat,
|
|
10
10
|
}: ChatActionProps): React.JSX.Element | null => {
|
|
11
11
|
const [open, setOpen] = useState(false);
|
|
12
|
-
const {
|
|
12
|
+
const { branchId } = chat;
|
|
13
13
|
if (
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
branchId === undefined ||
|
|
15
|
+
branchId === null ||
|
|
16
|
+
branchId === "" ||
|
|
17
17
|
chat.state !== "bound"
|
|
18
18
|
) {
|
|
19
19
|
return null;
|
|
@@ -30,7 +30,7 @@ export const SharingActions = ({
|
|
|
30
30
|
open={open}
|
|
31
31
|
onOpenChange={setOpen}
|
|
32
32
|
renderContent={(onClose) => (
|
|
33
|
-
<EveShareDialogContent
|
|
33
|
+
<EveShareDialogContent branchId={branchId} onClose={onClose} />
|
|
34
34
|
)}
|
|
35
35
|
/>
|
|
36
36
|
)}
|
|
@@ -41,14 +41,12 @@ export const SharingHeaderActions = ({
|
|
|
41
41
|
chat,
|
|
42
42
|
}: ChatActionProps): React.JSX.Element | null => {
|
|
43
43
|
if (
|
|
44
|
-
chat.
|
|
45
|
-
chat.
|
|
46
|
-
chat.
|
|
44
|
+
chat.branchId === undefined ||
|
|
45
|
+
chat.branchId === null ||
|
|
46
|
+
chat.branchId === "" ||
|
|
47
47
|
chat.state !== "bound"
|
|
48
48
|
) {
|
|
49
49
|
return null;
|
|
50
50
|
}
|
|
51
|
-
return
|
|
52
|
-
<EveShareButton chatId={chat.conversationId} className="hidden md:flex" />
|
|
53
|
-
);
|
|
51
|
+
return <EveShareButton branchId={chat.branchId} className="hidden md:flex" />;
|
|
54
52
|
};
|
|
@@ -25,18 +25,18 @@ type ShareStep = "info" | "shared";
|
|
|
25
25
|
|
|
26
26
|
/** Runtime-owned link destination; the dialog and visibility controller stay shared. */
|
|
27
27
|
export const SharingEnvironmentContext = createContext<{
|
|
28
|
-
readonly getUrl: (
|
|
28
|
+
readonly getUrl: (branchId: string) => string;
|
|
29
29
|
readonly notice?: string;
|
|
30
|
-
}>({ getUrl: (
|
|
30
|
+
}>({ getUrl: (branchId) => `${globalThis.location.origin}/share/${branchId}` });
|
|
31
31
|
|
|
32
32
|
const ShareDialogView = ({
|
|
33
|
-
|
|
33
|
+
branchId,
|
|
34
34
|
isPublic,
|
|
35
35
|
isPending,
|
|
36
36
|
onClose,
|
|
37
37
|
setVisibility,
|
|
38
38
|
}: {
|
|
39
|
-
readonly
|
|
39
|
+
readonly branchId: string;
|
|
40
40
|
readonly isPublic: boolean;
|
|
41
41
|
readonly isPending: boolean;
|
|
42
42
|
readonly onClose: () => void;
|
|
@@ -67,7 +67,7 @@ const ShareDialogView = ({
|
|
|
67
67
|
}
|
|
68
68
|
};
|
|
69
69
|
const handleCopyLink = async (): Promise<void> => {
|
|
70
|
-
const shareUrl = environment.getUrl(
|
|
70
|
+
const shareUrl = environment.getUrl(branchId);
|
|
71
71
|
try {
|
|
72
72
|
await navigator.clipboard.writeText(shareUrl);
|
|
73
73
|
toast.success("Share link copied to clipboard");
|
|
@@ -192,7 +192,7 @@ const ShareDialogView = ({
|
|
|
192
192
|
</label>
|
|
193
193
|
<input
|
|
194
194
|
className="border-input bg-background ring-offset-background placeholder:text-muted-foreground focus-visible:ring-ring flex h-10 w-full rounded-md border px-3 py-2 text-sm file:border-0 file:bg-transparent file:text-sm file:font-medium focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden disabled:cursor-not-allowed disabled:opacity-50"
|
|
195
|
-
value={environment.getUrl(
|
|
195
|
+
value={environment.getUrl(branchId)}
|
|
196
196
|
id="link"
|
|
197
197
|
readOnly
|
|
198
198
|
/>
|
|
@@ -11,27 +11,27 @@ import {
|
|
|
11
11
|
import { useTRPC } from "@/trpc/react";
|
|
12
12
|
|
|
13
13
|
const EveShareDialogContent = ({
|
|
14
|
-
|
|
14
|
+
branchId,
|
|
15
15
|
onClose,
|
|
16
16
|
}: {
|
|
17
|
-
readonly
|
|
17
|
+
readonly branchId: string;
|
|
18
18
|
readonly onClose: () => void;
|
|
19
19
|
}): ReactJSX.Element => {
|
|
20
20
|
const trpc = useTRPC();
|
|
21
21
|
const cache = useQueryClient();
|
|
22
|
-
const query = useQuery(trpc.sharing.get.queryOptions({ id:
|
|
22
|
+
const query = useQuery(trpc.sharing.get.queryOptions({ id: branchId }));
|
|
23
23
|
const mutation = useMutation(trpc.sharing.setVisibility.mutationOptions());
|
|
24
24
|
return (
|
|
25
25
|
<>
|
|
26
26
|
<ShareDialogView
|
|
27
|
-
|
|
27
|
+
branchId={branchId}
|
|
28
28
|
isPending={query.isPending || mutation.isPending || query.isError}
|
|
29
29
|
isPublic={query.data?.visibility === "public"}
|
|
30
30
|
onClose={onClose}
|
|
31
31
|
setVisibility={async (visibility) => {
|
|
32
|
-
await mutation.mutateAsync({ id:
|
|
32
|
+
await mutation.mutateAsync({ id: branchId, visibility });
|
|
33
33
|
await cache.invalidateQueries({
|
|
34
|
-
queryKey: trpc.sharing.get.queryKey({ id:
|
|
34
|
+
queryKey: trpc.sharing.get.queryKey({ id: branchId }),
|
|
35
35
|
});
|
|
36
36
|
}}
|
|
37
37
|
/>
|
|
@@ -41,16 +41,16 @@ const EveShareDialogContent = ({
|
|
|
41
41
|
};
|
|
42
42
|
|
|
43
43
|
const EveShareButton = ({
|
|
44
|
-
|
|
44
|
+
branchId,
|
|
45
45
|
className,
|
|
46
46
|
}: {
|
|
47
|
-
readonly
|
|
47
|
+
readonly branchId: string;
|
|
48
48
|
readonly className?: string;
|
|
49
49
|
}): React.JSX.Element => (
|
|
50
50
|
<ShareButton
|
|
51
51
|
className={className}
|
|
52
52
|
renderContent={(onClose): React.JSX.Element => (
|
|
53
|
-
<EveShareDialogContent
|
|
53
|
+
<EveShareDialogContent branchId={branchId} onClose={onClose} />
|
|
54
54
|
)}
|
|
55
55
|
/>
|
|
56
56
|
);
|
package/templates/chat-app/chatjs/plugins/spreadsheet-viewer/{client-plugin.ts → chat-ui.ts}
RENAMED
|
@@ -3,7 +3,7 @@ import { definePlugin, slot } from "@/chatjs/core/ui/slots";
|
|
|
3
3
|
import { ArtifactViewerActions } from "@/components/artifact-actions";
|
|
4
4
|
import { SpreadsheetViewerAction } from "./viewer-action";
|
|
5
5
|
|
|
6
|
-
export const
|
|
6
|
+
export const chatUi = definePlugin({
|
|
7
7
|
id: "spreadsheet-viewer",
|
|
8
8
|
slots: [slot(ArtifactViewerActions, SpreadsheetViewerAction)],
|
|
9
9
|
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"contractVersion": 3,
|
|
3
|
+
"uiBase": "base",
|
|
4
|
+
"id": "spreadsheet-viewer",
|
|
5
|
+
"kind": "plugin",
|
|
6
|
+
"files": [
|
|
7
|
+
"chatjs/plugins/spreadsheet-viewer/chat-ui.ts",
|
|
8
|
+
"chatjs/plugins/spreadsheet-viewer/viewer-action.tsx",
|
|
9
|
+
"chatjs/plugins/spreadsheet-viewer/load.ts",
|
|
10
|
+
"chatjs/plugins/spreadsheet-viewer/preview.tsx"
|
|
11
|
+
]
|
|
12
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import "katex/dist/katex.min.css";
|
|
4
|
+
import { math } from "@streamdown/math";
|
|
5
|
+
import { definePlugin } from "@/chatjs/core/ui/slots";
|
|
6
|
+
|
|
7
|
+
export const chatUi = definePlugin({
|
|
8
|
+
id: "streamdown-math",
|
|
9
|
+
slots: [],
|
|
10
|
+
streamdown: { math },
|
|
11
|
+
});
|
|
@@ -3,7 +3,7 @@ import { definePlugin, slot } from "@/chatjs/core/ui/slots";
|
|
|
3
3
|
import { ArtifactViewerActions } from "@/components/artifact-actions";
|
|
4
4
|
import { VideoViewerAction } from "./viewer-action";
|
|
5
5
|
|
|
6
|
-
export const
|
|
6
|
+
export const chatUi = definePlugin({
|
|
7
7
|
id: "video-viewer",
|
|
8
8
|
slots: [slot(ArtifactViewerActions, VideoViewerAction)],
|
|
9
9
|
});
|
|
@@ -16,6 +16,7 @@ import type { gateway } from "@ai-sdk/gateway";
|
|
|
16
16
|
import { getVercelOidcToken } from "@vercel/oidc";
|
|
17
17
|
import { z } from "zod";
|
|
18
18
|
|
|
19
|
+
const MODEL_DISCOVERY_TIMEOUT_MS = 10_000;
|
|
19
20
|
const MODEL_ID_PARAMETER_INDEX = 0;
|
|
20
21
|
type VercelImageModelId = Parameters<
|
|
21
22
|
(typeof gateway)["imageModel"]
|
|
@@ -90,68 +91,61 @@ class VercelGateway
|
|
|
90
91
|
apiKey === null ? catalogUrl : `${catalogUrl}?include_availability`;
|
|
91
92
|
this.log.debug({ url }, "Fetching models from Vercel AI Gateway");
|
|
92
93
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
: { headers: { Authorization: `Bearer ${apiKey}` } }
|
|
99
|
-
);
|
|
94
|
+
const response = await this.fetch(url, {
|
|
95
|
+
headers:
|
|
96
|
+
apiKey === null ? undefined : { Authorization: `Bearer ${apiKey}` },
|
|
97
|
+
signal: AbortSignal.timeout(MODEL_DISCOVERY_TIMEOUT_MS),
|
|
98
|
+
});
|
|
100
99
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
100
|
+
if (!response.ok) {
|
|
101
|
+
this.log.error(
|
|
102
|
+
{ status: response.status, statusText: response.statusText, url },
|
|
103
|
+
"Vercel AI Gateway returned non-OK response"
|
|
104
|
+
);
|
|
105
|
+
throw new Error(
|
|
106
|
+
`Failed to fetch models: ${response.status} ${response.statusText}`
|
|
107
|
+
);
|
|
108
|
+
}
|
|
108
109
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
models.push(aiGatewayModelSchema.parse(candidate));
|
|
127
|
-
} else {
|
|
128
|
-
unsupportedTypes.add(type);
|
|
110
|
+
const bodyRaw: unknown = await response.json();
|
|
111
|
+
const body = modelsEnvelopeSchema.parse(bodyRaw);
|
|
112
|
+
const unsupportedTypes = new Set<string>();
|
|
113
|
+
const models: AiGatewayModel[] = [];
|
|
114
|
+
|
|
115
|
+
for (const candidate of body.data) {
|
|
116
|
+
const { type } = modelDiscriminatorSchema.parse(candidate);
|
|
117
|
+
if (isAiGatewayModelType(type)) {
|
|
118
|
+
const availability = modelAvailability.safeParse(candidate);
|
|
119
|
+
const eligibility = availability.data?.model_eligibility;
|
|
120
|
+
if (
|
|
121
|
+
eligibility?.status === "ineligible" &&
|
|
122
|
+
(eligibility.category === "policy" ||
|
|
123
|
+
eligibility.category === "configuration")
|
|
124
|
+
) {
|
|
125
|
+
continue;
|
|
129
126
|
}
|
|
127
|
+
models.push(aiGatewayModelSchema.parse(candidate));
|
|
128
|
+
} else {
|
|
129
|
+
unsupportedTypes.add(type);
|
|
130
130
|
}
|
|
131
|
+
}
|
|
131
132
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
this.log.info(
|
|
144
|
-
{ modelCount: models.length },
|
|
145
|
-
"Successfully fetched models from Vercel AI Gateway"
|
|
133
|
+
if (unsupportedTypes.size > EMPTY_MODEL_TYPE_COUNT) {
|
|
134
|
+
this.log.warn(
|
|
135
|
+
{
|
|
136
|
+
modelCount: body.data.length,
|
|
137
|
+
skippedModelCount: body.data.length - models.length,
|
|
138
|
+
unsupportedTypes: [...unsupportedTypes],
|
|
139
|
+
},
|
|
140
|
+
"Skipping models with unsupported types from Vercel AI Gateway"
|
|
146
141
|
);
|
|
147
|
-
return models;
|
|
148
|
-
} catch (error) {
|
|
149
|
-
this.log.error(
|
|
150
|
-
{ err: error, url },
|
|
151
|
-
"Error fetching models from Vercel AI Gateway, falling back to generated models"
|
|
152
|
-
);
|
|
153
|
-
return [...this.getFallbackModels(this.type)];
|
|
154
142
|
}
|
|
143
|
+
|
|
144
|
+
this.log.info(
|
|
145
|
+
{ modelCount: models.length },
|
|
146
|
+
"Successfully fetched models from Vercel AI Gateway"
|
|
147
|
+
);
|
|
148
|
+
return models;
|
|
155
149
|
}
|
|
156
150
|
}
|
|
157
151
|
export { VercelGateway as Gateway, VercelGateway };
|
|
@@ -40,14 +40,14 @@ export const import_file = defineTool({
|
|
|
40
40
|
"File import requires the current ChatJS conversation owner's authority."
|
|
41
41
|
);
|
|
42
42
|
}
|
|
43
|
-
const { ownerId,
|
|
43
|
+
const { ownerId, branchId } = await resolveEveConversationScope(
|
|
44
44
|
current.principalId,
|
|
45
45
|
context.session.id,
|
|
46
46
|
context.abortSignal
|
|
47
47
|
);
|
|
48
48
|
return await withEveConversationFile(
|
|
49
49
|
ownerId,
|
|
50
|
-
|
|
50
|
+
branchId,
|
|
51
51
|
input.fileId,
|
|
52
52
|
async () =>
|
|
53
53
|
await importStoredFile(input, {
|