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
|
@@ -11,7 +11,7 @@ interface EveBranchReference {
|
|
|
11
11
|
forkMessageId?: string | null;
|
|
12
12
|
forkTurnId: string | null;
|
|
13
13
|
id: string;
|
|
14
|
-
|
|
14
|
+
parentBranchId: string | null;
|
|
15
15
|
responseGroupId?: string | null;
|
|
16
16
|
responseGroupIndex?: number | null;
|
|
17
17
|
}
|
|
@@ -38,13 +38,13 @@ type LogicalBranch = EveBranchReference & {
|
|
|
38
38
|
interface LogicalNode {
|
|
39
39
|
id: string;
|
|
40
40
|
parentId: string | null;
|
|
41
|
-
|
|
41
|
+
branchId: string;
|
|
42
42
|
message: EveMessage;
|
|
43
43
|
}
|
|
44
44
|
interface LogicalChatSnapshot {
|
|
45
45
|
readyBranches: ReadonlySet<string>;
|
|
46
46
|
chatId: string;
|
|
47
|
-
|
|
47
|
+
branchId: string;
|
|
48
48
|
cursorId: string | null;
|
|
49
49
|
nodes: ReadonlyMap<string, LogicalNode>;
|
|
50
50
|
paths: ReadonlyMap<string, readonly string[]>;
|
|
@@ -94,14 +94,14 @@ const branchPrefix = (
|
|
|
94
94
|
aliases: ReadonlyMap<string, string>
|
|
95
95
|
): { prefix: readonly string[]; replaced?: string } => {
|
|
96
96
|
if (
|
|
97
|
-
!isNonEmptyString(branch.
|
|
97
|
+
!isNonEmptyString(branch.parentBranchId) ||
|
|
98
98
|
!isNonEmptyString(branch.forkMessageId)
|
|
99
99
|
) {
|
|
100
100
|
return { prefix: [] };
|
|
101
101
|
}
|
|
102
|
-
const source = paths.get(branch.
|
|
102
|
+
const source = paths.get(branch.parentBranchId) ?? [];
|
|
103
103
|
const boundary = aliases.get(
|
|
104
|
-
aliasKey(branch.
|
|
104
|
+
aliasKey(branch.parentBranchId, branch.forkMessageId)
|
|
105
105
|
);
|
|
106
106
|
const index = boundary === undefined ? -1 : source.indexOf(boundary);
|
|
107
107
|
if (index < 0) {
|
|
@@ -160,7 +160,7 @@ const projectBranch = (
|
|
|
160
160
|
: logicalNativeId(branch.sessionId ?? branch.id, message));
|
|
161
161
|
if (!nodes.has(id)) {
|
|
162
162
|
nodes.set(id, {
|
|
163
|
-
|
|
163
|
+
branchId: branch.id,
|
|
164
164
|
id,
|
|
165
165
|
message,
|
|
166
166
|
parentId: path.at(-1) ?? null,
|
|
@@ -206,19 +206,19 @@ class LogicalChat {
|
|
|
206
206
|
public readonly chatId: string;
|
|
207
207
|
public constructor(
|
|
208
208
|
chatId: string,
|
|
209
|
-
|
|
209
|
+
initialBranchId: string,
|
|
210
210
|
hydrateLatest = false
|
|
211
211
|
) {
|
|
212
212
|
this.hydrateLatest = hydrateLatest;
|
|
213
213
|
this.chatId = chatId;
|
|
214
|
-
this.selected =
|
|
214
|
+
this.selected = initialBranchId;
|
|
215
215
|
this.snapshot = {
|
|
216
216
|
agents: new Map(),
|
|
217
217
|
aliases: new Map(),
|
|
218
218
|
branches: [],
|
|
219
219
|
chatId,
|
|
220
220
|
children: new Map(),
|
|
221
|
-
|
|
221
|
+
branchId: initialBranchId,
|
|
222
222
|
cursorId: null,
|
|
223
223
|
nodes: new Map(),
|
|
224
224
|
paths: new Map(),
|
|
@@ -246,8 +246,8 @@ class LogicalChat {
|
|
|
246
246
|
this.publish();
|
|
247
247
|
}
|
|
248
248
|
|
|
249
|
-
public observe(
|
|
250
|
-
const previous = this.agents.get(
|
|
249
|
+
public observe(branchId: string, agent: NativeChatAgent): void {
|
|
250
|
+
const previous = this.agents.get(branchId);
|
|
251
251
|
if (
|
|
252
252
|
previous?.messages === agent.messages &&
|
|
253
253
|
previous.events === agent.events &&
|
|
@@ -256,7 +256,7 @@ class LogicalChat {
|
|
|
256
256
|
) {
|
|
257
257
|
return;
|
|
258
258
|
}
|
|
259
|
-
this.agents.set(
|
|
259
|
+
this.agents.set(branchId, agent);
|
|
260
260
|
this.publish();
|
|
261
261
|
}
|
|
262
262
|
|
|
@@ -273,20 +273,20 @@ class LogicalChat {
|
|
|
273
273
|
this.pendingSelection = undefined;
|
|
274
274
|
}
|
|
275
275
|
|
|
276
|
-
public selectBranch(
|
|
276
|
+
public selectBranch(branchId: string): void {
|
|
277
277
|
this.hydrateLatest = false;
|
|
278
278
|
this.follow = true;
|
|
279
|
-
const path = this.snapshot.paths.get(
|
|
279
|
+
const path = this.snapshot.paths.get(branchId);
|
|
280
280
|
if (
|
|
281
281
|
path !== undefined &&
|
|
282
282
|
path.length > 0 &&
|
|
283
|
-
this.snapshot.readyBranches.has(
|
|
283
|
+
this.snapshot.readyBranches.has(branchId)
|
|
284
284
|
) {
|
|
285
285
|
this.pendingSelection = undefined;
|
|
286
|
-
this.selected =
|
|
286
|
+
this.selected = branchId;
|
|
287
287
|
this.cursor = path.at(-1) ?? null;
|
|
288
288
|
} else {
|
|
289
|
-
this.pendingSelection =
|
|
289
|
+
this.pendingSelection = branchId;
|
|
290
290
|
}
|
|
291
291
|
this.publish();
|
|
292
292
|
}
|
|
@@ -303,26 +303,22 @@ class LogicalChat {
|
|
|
303
303
|
last = (this.snapshot.children.get(node.id) ?? []).at(-1);
|
|
304
304
|
}
|
|
305
305
|
this.pendingSelection = undefined;
|
|
306
|
-
this.selected = node.
|
|
306
|
+
this.selected = node.branchId;
|
|
307
307
|
this.cursor = node.id;
|
|
308
308
|
this.follow =
|
|
309
|
-
node.message.role === "user" &&
|
|
310
|
-
busy(this.agents.get(node.conversationId));
|
|
309
|
+
node.message.role === "user" && busy(this.agents.get(node.branchId));
|
|
311
310
|
this.publish();
|
|
312
311
|
}
|
|
313
312
|
|
|
314
|
-
public logicalId(
|
|
315
|
-
|
|
316
|
-
nativeId: string
|
|
317
|
-
): string | undefined {
|
|
318
|
-
return this.snapshot.aliases.get(aliasKey(conversationId, nativeId));
|
|
313
|
+
public logicalId(branchId: string, nativeId: string): string | undefined {
|
|
314
|
+
return this.snapshot.aliases.get(aliasKey(branchId, nativeId));
|
|
319
315
|
}
|
|
320
316
|
|
|
321
317
|
public siblings(
|
|
322
|
-
|
|
318
|
+
branchId: string,
|
|
323
319
|
nativeId: string
|
|
324
320
|
): { ids: readonly string[]; index: number } {
|
|
325
|
-
const id = this.logicalId(
|
|
321
|
+
const id = this.logicalId(branchId, nativeId);
|
|
326
322
|
if (!isNonEmptyString(id)) {
|
|
327
323
|
return { ids: [], index: -1 };
|
|
328
324
|
}
|
|
@@ -400,8 +396,8 @@ class LogicalChat {
|
|
|
400
396
|
let progressed = false;
|
|
401
397
|
for (const [id, branch] of waiting) {
|
|
402
398
|
if (
|
|
403
|
-
isNonEmptyString(branch.
|
|
404
|
-
!paths.has(branch.
|
|
399
|
+
isNonEmptyString(branch.parentBranchId) &&
|
|
400
|
+
!paths.has(branch.parentBranchId)
|
|
405
401
|
) {
|
|
406
402
|
continue;
|
|
407
403
|
}
|
|
@@ -457,7 +453,7 @@ class LogicalChat {
|
|
|
457
453
|
branches: this.branches,
|
|
458
454
|
chatId: this.chatId,
|
|
459
455
|
children,
|
|
460
|
-
|
|
456
|
+
branchId: this.selected,
|
|
461
457
|
cursorId: this.cursor,
|
|
462
458
|
error,
|
|
463
459
|
nodes,
|
|
@@ -43,7 +43,7 @@ const belongsToSlot = (
|
|
|
43
43
|
return false;
|
|
44
44
|
}
|
|
45
45
|
seen.add(current.id);
|
|
46
|
-
const parentId: string | null = current.
|
|
46
|
+
const parentId: string | null = current.parentBranchId;
|
|
47
47
|
current = branches.find((value) => value.id === parentId);
|
|
48
48
|
}
|
|
49
49
|
return false;
|
|
@@ -61,7 +61,7 @@ const slotReadAccess = (
|
|
|
61
61
|
answerMatches: (nodeId, branchId, userId) => {
|
|
62
62
|
const value = node(nodeId);
|
|
63
63
|
return (
|
|
64
|
-
value?.
|
|
64
|
+
value?.branchId === branchId &&
|
|
65
65
|
value.parentId === userId &&
|
|
66
66
|
value.message.role === "assistant"
|
|
67
67
|
);
|
|
@@ -118,10 +118,7 @@ const selectedSlotAttempt = (
|
|
|
118
118
|
export const logicalResponseSlots = (
|
|
119
119
|
snapshot: ReadonlyNativeSurface<
|
|
120
120
|
Readonly<
|
|
121
|
-
Pick<
|
|
122
|
-
LogicalChatSnapshot,
|
|
123
|
-
"branches" | "paths" | "conversationId" | "nodes"
|
|
124
|
-
>
|
|
121
|
+
Pick<LogicalChatSnapshot, "branches" | "paths" | "branchId" | "nodes">
|
|
125
122
|
>
|
|
126
123
|
>,
|
|
127
124
|
userId: string
|
|
@@ -153,7 +150,7 @@ export const logicalResponseSlots = (
|
|
|
153
150
|
rejection: undefined,
|
|
154
151
|
})
|
|
155
152
|
);
|
|
156
|
-
const selectedPath = snapshot.paths.get(snapshot.
|
|
153
|
+
const selectedPath = snapshot.paths.get(snapshot.branchId) ?? [];
|
|
157
154
|
const read = slotReadAccess(
|
|
158
155
|
() => snapshot.branches,
|
|
159
156
|
(branchId) => snapshot.paths.get(branchId),
|
|
@@ -20,6 +20,7 @@ const pendingMessage = z.object({
|
|
|
20
20
|
message: z.string(),
|
|
21
21
|
modelId: z.string().optional(),
|
|
22
22
|
operationId: z.uuid().optional(),
|
|
23
|
+
turnPolicy: z.literal("steer").optional(),
|
|
23
24
|
rejection: z.string().optional(),
|
|
24
25
|
retryable: z.boolean().optional(),
|
|
25
26
|
selectedTool: toolNameSchema.optional(),
|
|
@@ -1,44 +1,10 @@
|
|
|
1
1
|
import { MockLanguageModelV3 } from "ai/test";
|
|
2
2
|
import { expect, test, vi } from "vitest";
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
getEveModelDefinition,
|
|
6
|
-
loadEveModelDefinition,
|
|
7
|
-
resolveEveModel,
|
|
8
|
-
} from "./model-selection";
|
|
4
|
+
import { loadEveModelDefinition, resolveEveModel } from "./model-selection";
|
|
9
5
|
|
|
10
|
-
vi.
|
|
11
|
-
|
|
12
|
-
createLanguageModel: (id: string) =>
|
|
13
|
-
new MockLanguageModelV3({
|
|
14
|
-
doGenerate: vi
|
|
15
|
-
.fn()
|
|
16
|
-
.mockRejectedValue(new Error(`provider model: ${id}`)),
|
|
17
|
-
modelId: id,
|
|
18
|
-
provider: "test",
|
|
19
|
-
}),
|
|
20
|
-
fetchModels: async () => {
|
|
21
|
-
const { getFallbackModels } =
|
|
22
|
-
await import("../ai/gateways/fallback-models");
|
|
23
|
-
return [
|
|
24
|
-
...getFallbackModels("test"),
|
|
25
|
-
{ id: "live-only", pricing: {}, tags: [], type: "language" },
|
|
26
|
-
];
|
|
27
|
-
},
|
|
28
|
-
}),
|
|
29
|
-
}));
|
|
30
|
-
vi.mock("../config", () => ({
|
|
31
|
-
config: {
|
|
32
|
-
ai: {
|
|
33
|
-
disabledModels: ["disabled"],
|
|
34
|
-
providerOrder: [],
|
|
35
|
-
gateway: "test",
|
|
36
|
-
workflows: { chat: "plain" },
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
}));
|
|
40
|
-
vi.mock("../ai/gateways/fallback-models", () => ({
|
|
41
|
-
getFallbackModels: () => [
|
|
6
|
+
const { discoverModels } = vi.hoisted(() => ({
|
|
7
|
+
discoverModels: vi.fn().mockResolvedValue([
|
|
42
8
|
{
|
|
43
9
|
context_window: 1000,
|
|
44
10
|
id: "plain",
|
|
@@ -73,16 +39,42 @@ vi.mock("../ai/gateways/fallback-models", () => ({
|
|
|
73
39
|
},
|
|
74
40
|
{ id: "disabled", pricing: {}, tags: [], type: "language" },
|
|
75
41
|
{ id: "image", pricing: {}, tags: [], type: "image" },
|
|
76
|
-
],
|
|
42
|
+
]),
|
|
43
|
+
}));
|
|
44
|
+
|
|
45
|
+
vi.mock("../ai/active-gateway", () => ({
|
|
46
|
+
getActiveGateway: () => ({
|
|
47
|
+
createLanguageModel: (id: string) =>
|
|
48
|
+
new MockLanguageModelV3({
|
|
49
|
+
doGenerate: vi
|
|
50
|
+
.fn()
|
|
51
|
+
.mockRejectedValue(new Error(`provider model: ${id}`)),
|
|
52
|
+
modelId: id,
|
|
53
|
+
provider: "test",
|
|
54
|
+
}),
|
|
55
|
+
fetchModels: discoverModels,
|
|
56
|
+
}),
|
|
57
|
+
}));
|
|
58
|
+
vi.mock("../config", () => ({
|
|
59
|
+
config: {
|
|
60
|
+
ai: {
|
|
61
|
+
disabledModels: ["disabled"],
|
|
62
|
+
providerOrder: [],
|
|
63
|
+
gateway: "test",
|
|
64
|
+
workflows: { chat: "plain" },
|
|
65
|
+
},
|
|
66
|
+
},
|
|
77
67
|
}));
|
|
78
68
|
|
|
79
69
|
test("keeps the provider model and reasoning variant distinct", async () => {
|
|
80
|
-
expect(
|
|
70
|
+
expect(await loadEveModelDefinition()).toMatchObject({
|
|
81
71
|
id: "plain",
|
|
82
72
|
reasoning: false,
|
|
83
73
|
});
|
|
84
|
-
expect(
|
|
85
|
-
|
|
74
|
+
expect(await loadEveModelDefinition("thinking")).toMatchObject({
|
|
75
|
+
reasoning: false,
|
|
76
|
+
});
|
|
77
|
+
expect(await loadEveModelDefinition("thinking-reasoning")).toMatchObject({
|
|
86
78
|
apiModelId: "thinking",
|
|
87
79
|
reasoning: true,
|
|
88
80
|
});
|
|
@@ -127,19 +119,24 @@ test("the logical reasoning identity still dispatches to the original provider m
|
|
|
127
119
|
});
|
|
128
120
|
test.each(["unknown", "disabled", "image", "plain-reasoning"])(
|
|
129
121
|
"rejects unavailable selection %s",
|
|
130
|
-
(id) => {
|
|
131
|
-
expect((
|
|
122
|
+
async (id) => {
|
|
123
|
+
await expect(loadEveModelDefinition(id)).rejects.toThrow("not available");
|
|
132
124
|
}
|
|
133
125
|
);
|
|
134
126
|
|
|
135
|
-
test("accepts live catalog models absent from the snapshot", async () => {
|
|
136
|
-
expect(() => getEveModelDefinition("live-only")).toThrow();
|
|
137
|
-
expect(await loadEveModelDefinition("live-only")).toMatchObject({
|
|
138
|
-
id: "live-only",
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
|
|
142
127
|
test("chooses a discovered chat model when the gateway's preferred ID is missing", async () => {
|
|
143
128
|
const { loadDefaultEveWebModelId } = await import("./model-selection");
|
|
144
129
|
expect(await loadDefaultEveWebModelId("missing-default")).toBe("plain");
|
|
145
130
|
});
|
|
131
|
+
|
|
132
|
+
test("retries discovery after a gateway error and reuses the successful catalog", async () => {
|
|
133
|
+
vi.resetModules();
|
|
134
|
+
const { loadEveModelDefinition: load } = await import("./model-selection");
|
|
135
|
+
discoverModels
|
|
136
|
+
.mockClear()
|
|
137
|
+
.mockRejectedValueOnce(new Error("gateway unavailable"));
|
|
138
|
+
await expect(load("plain")).rejects.toThrow("gateway unavailable");
|
|
139
|
+
expect(await load("plain")).toMatchObject({ id: "plain" });
|
|
140
|
+
await load("thinking");
|
|
141
|
+
expect(discoverModels).toHaveBeenCalledTimes(2);
|
|
142
|
+
});
|
|
@@ -4,10 +4,8 @@ import { wrapLanguageModel } from "ai";
|
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
|
|
6
6
|
import { getActiveGateway } from "@/lib/ai/active-gateway";
|
|
7
|
-
import { getFallbackModels } from "@/lib/ai/gateways/fallback-models";
|
|
8
7
|
import type { ModelData } from "@/lib/ai/model-data";
|
|
9
|
-
import
|
|
10
|
-
import { toModelData } from "@/lib/ai/to-model-data";
|
|
8
|
+
import { loadModelCatalog } from "@/lib/ai/model-catalog";
|
|
11
9
|
import {
|
|
12
10
|
buildWebChatModels,
|
|
13
11
|
getDefaultWebChatModelId,
|
|
@@ -15,7 +13,6 @@ import {
|
|
|
15
13
|
import { config } from "@/lib/config";
|
|
16
14
|
|
|
17
15
|
const serializedOptions = z.record(z.string(), z.record(z.string(), z.json()));
|
|
18
|
-
const MODEL_CATALOG_TTL_MS = 3_600_000;
|
|
19
16
|
type EveModelDefinition = ModelData & {
|
|
20
17
|
apiModelId: string;
|
|
21
18
|
selectedModelId: string;
|
|
@@ -29,12 +26,9 @@ class EveModelUnavailableError extends Error {
|
|
|
29
26
|
}
|
|
30
27
|
|
|
31
28
|
const getEveModelDefinition = (
|
|
32
|
-
|
|
33
|
-
models: readonly ModelData[]
|
|
34
|
-
(model: Readonly<ReadonlyAiGatewayModel>) => toModelData(model)
|
|
35
|
-
)
|
|
29
|
+
id: string,
|
|
30
|
+
models: readonly ModelData[]
|
|
36
31
|
): EveModelDefinition => {
|
|
37
|
-
const id = requestedId ?? config.ai.workflows.chat;
|
|
38
32
|
const model = models.find(
|
|
39
33
|
(item: Readonly<ModelData>) =>
|
|
40
34
|
item.id === id || (item.reasoning && `${item.id}-reasoning` === id)
|
|
@@ -56,31 +50,6 @@ const getEveModelDefinition = (
|
|
|
56
50
|
};
|
|
57
51
|
};
|
|
58
52
|
|
|
59
|
-
let catalog: { expires: number; models: ModelData[] } | undefined;
|
|
60
|
-
let loading: Promise<ModelData[]> | undefined;
|
|
61
|
-
|
|
62
|
-
const loadEveModelCatalog = async (): Promise<readonly ModelData[]> => {
|
|
63
|
-
if (!catalog || catalog.expires < Date.now()) {
|
|
64
|
-
loading ??= (async (): Promise<ModelData[]> => {
|
|
65
|
-
try {
|
|
66
|
-
const models = await getActiveGateway().fetchModels();
|
|
67
|
-
const converted = models.map(
|
|
68
|
-
(model: Readonly<ReadonlyAiGatewayModel>) => toModelData(model)
|
|
69
|
-
);
|
|
70
|
-
catalog = {
|
|
71
|
-
expires: Date.now() + MODEL_CATALOG_TTL_MS,
|
|
72
|
-
models: converted,
|
|
73
|
-
};
|
|
74
|
-
return converted;
|
|
75
|
-
} finally {
|
|
76
|
-
loading = undefined;
|
|
77
|
-
}
|
|
78
|
-
})();
|
|
79
|
-
return await loading;
|
|
80
|
-
}
|
|
81
|
-
return catalog.models;
|
|
82
|
-
};
|
|
83
|
-
|
|
84
53
|
const defaultEveWebModelId = (
|
|
85
54
|
models: readonly ModelData[],
|
|
86
55
|
preferredModelId?: string
|
|
@@ -98,12 +67,12 @@ const defaultEveWebModelId = (
|
|
|
98
67
|
const loadDefaultEveWebModelId = async (
|
|
99
68
|
preferredModelId: string
|
|
100
69
|
): Promise<string> =>
|
|
101
|
-
defaultEveWebModelId(await
|
|
70
|
+
defaultEveWebModelId(await loadModelCatalog(), preferredModelId);
|
|
102
71
|
|
|
103
72
|
const loadEveModelDefinition = async (
|
|
104
73
|
requestedId?: string
|
|
105
74
|
): Promise<EveModelDefinition> => {
|
|
106
|
-
const models = await
|
|
75
|
+
const models = await loadModelCatalog();
|
|
107
76
|
return getEveModelDefinition(
|
|
108
77
|
requestedId ?? defaultEveWebModelId(models),
|
|
109
78
|
models
|
|
@@ -126,7 +95,6 @@ const resolveEveModel = async (requestedId?: string): Promise<SessionModel> => {
|
|
|
126
95
|
};
|
|
127
96
|
export {
|
|
128
97
|
EveModelUnavailableError,
|
|
129
|
-
getEveModelDefinition,
|
|
130
98
|
loadDefaultEveWebModelId,
|
|
131
99
|
loadEveModelDefinition,
|
|
132
100
|
resolveEveModel,
|
|
@@ -4,6 +4,8 @@ import {
|
|
|
4
4
|
moveRejectedContextCreation,
|
|
5
5
|
prepareCreation,
|
|
6
6
|
readCreation,
|
|
7
|
+
readCreationFollowUp,
|
|
8
|
+
saveCreationFollowUp,
|
|
7
9
|
} from "./pending-create";
|
|
8
10
|
|
|
9
11
|
const storageFixture = (): Pick<
|
|
@@ -47,6 +49,7 @@ describe("rejected project draft recovery", () => {
|
|
|
47
49
|
undefined,
|
|
48
50
|
{ projectId }
|
|
49
51
|
);
|
|
52
|
+
saveCreationFollowUp(storage, "owner", "And next month too", { context });
|
|
50
53
|
const next = moveRejectedContextCreation(
|
|
51
54
|
storage,
|
|
52
55
|
"owner",
|
|
@@ -61,6 +64,8 @@ describe("rejected project draft recovery", () => {
|
|
|
61
64
|
expect(next.projectId).toBeUndefined();
|
|
62
65
|
expect(readCreation(storage, "owner")).toEqual(next);
|
|
63
66
|
expect(readCreation(storage, "owner", { context })).toBeUndefined();
|
|
67
|
+
expect(readCreationFollowUp(storage, "owner")).toBe("And next month too");
|
|
68
|
+
expect(readCreationFollowUp(storage, "owner", { context })).toBe("");
|
|
64
69
|
});
|
|
65
70
|
it("preserves both requests if another root draft exists", () => {
|
|
66
71
|
const storage = storageFixture();
|
|
@@ -98,15 +103,49 @@ describe("rejected project draft recovery", () => {
|
|
|
98
103
|
)
|
|
99
104
|
).toThrow("saved request changed");
|
|
100
105
|
});
|
|
106
|
+
|
|
107
|
+
it("preserves the project request when New Chat has a standalone draft", () => {
|
|
108
|
+
const storage = storageFixture();
|
|
109
|
+
const projectId = crypto.randomUUID();
|
|
110
|
+
const context = { key: `project:${projectId}`, label: "project" };
|
|
111
|
+
const scope = { context };
|
|
112
|
+
const original = prepareCreation(
|
|
113
|
+
storage,
|
|
114
|
+
"owner",
|
|
115
|
+
"Project message",
|
|
116
|
+
undefined,
|
|
117
|
+
scope,
|
|
118
|
+
undefined,
|
|
119
|
+
{ projectId }
|
|
120
|
+
);
|
|
121
|
+
saveCreationFollowUp(storage, "owner", "Project follow-up", scope);
|
|
122
|
+
saveCreationFollowUp(storage, "owner", "Unrelated New Chat draft");
|
|
123
|
+
expect(() =>
|
|
124
|
+
moveRejectedContextCreation(
|
|
125
|
+
storage,
|
|
126
|
+
"owner",
|
|
127
|
+
context,
|
|
128
|
+
original.operationId
|
|
129
|
+
)
|
|
130
|
+
).toThrow("Send or clear the draft");
|
|
131
|
+
expect(readCreationFollowUp(storage, "owner")).toBe(
|
|
132
|
+
"Unrelated New Chat draft"
|
|
133
|
+
);
|
|
134
|
+
expect(readCreationFollowUp(storage, "owner", scope)).toBe(
|
|
135
|
+
"Project follow-up"
|
|
136
|
+
);
|
|
137
|
+
expect(readCreation(storage, "owner", scope)).toEqual(original);
|
|
138
|
+
expect(readCreation(storage, "owner")).toBeUndefined();
|
|
139
|
+
});
|
|
101
140
|
});
|
|
102
141
|
|
|
103
142
|
it("keeps owner-scoped unresolved forks discoverable, including damaged drafts", () => {
|
|
104
143
|
const storage = storageFixture();
|
|
105
|
-
const
|
|
106
|
-
expect(hasPendingCreation(storage, "owner", {
|
|
107
|
-
prepareCreation(storage, "owner", "edit", undefined, {
|
|
108
|
-
expect(hasPendingCreation(storage, "owner", {
|
|
109
|
-
expect(hasPendingCreation(storage, "other", {
|
|
110
|
-
storage.setItem(`chatjs.eve.pending:owner:fork:${
|
|
111
|
-
expect(hasPendingCreation(storage, "owner", {
|
|
144
|
+
const branchId = crypto.randomUUID();
|
|
145
|
+
expect(hasPendingCreation(storage, "owner", { branchId })).toBe(false);
|
|
146
|
+
prepareCreation(storage, "owner", "edit", undefined, { branchId });
|
|
147
|
+
expect(hasPendingCreation(storage, "owner", { branchId })).toBe(true);
|
|
148
|
+
expect(hasPendingCreation(storage, "other", { branchId })).toBe(false);
|
|
149
|
+
storage.setItem(`chatjs.eve.pending:owner:fork:${branchId}`, "damaged");
|
|
150
|
+
expect(hasPendingCreation(storage, "owner", { branchId })).toBe(true);
|
|
112
151
|
});
|
|
@@ -20,20 +20,40 @@ const creationRequest = z.union([
|
|
|
20
20
|
type StorageAccess = Pick<Storage, "getItem" | "setItem" | "removeItem">;
|
|
21
21
|
|
|
22
22
|
type CreationScope =
|
|
23
|
-
| {
|
|
24
|
-
| { context: ChatCreationScope;
|
|
23
|
+
| { branchId: string; context?: never }
|
|
24
|
+
| { context: ChatCreationScope; branchId?: never };
|
|
25
25
|
|
|
26
26
|
const keyFor = (ownerId: string, scope?: Readonly<CreationScope>): string => {
|
|
27
27
|
let suffix = "";
|
|
28
28
|
|
|
29
|
-
if (scope && isNonEmptyString(scope.
|
|
30
|
-
suffix = `:fork:${scope.
|
|
29
|
+
if (scope && isNonEmptyString(scope.branchId)) {
|
|
30
|
+
suffix = `:fork:${scope.branchId}`;
|
|
31
31
|
} else if (scope?.context) {
|
|
32
32
|
suffix = `:${scope.context.key}`;
|
|
33
33
|
}
|
|
34
34
|
return `chatjs.eve.pending:${ownerId}${suffix}`;
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
+
const readCreationFollowUp = (
|
|
38
|
+
storage: StorageAccess,
|
|
39
|
+
ownerId: string,
|
|
40
|
+
scope?: Readonly<CreationScope>
|
|
41
|
+
): string => storage.getItem(`${keyFor(ownerId, scope)}:follow-up`) ?? "";
|
|
42
|
+
|
|
43
|
+
const saveCreationFollowUp = (
|
|
44
|
+
storage: StorageAccess,
|
|
45
|
+
ownerId: string,
|
|
46
|
+
text: string,
|
|
47
|
+
scope?: Readonly<CreationScope>
|
|
48
|
+
): void => {
|
|
49
|
+
const key = `${keyFor(ownerId, scope)}:follow-up`;
|
|
50
|
+
if (text) {
|
|
51
|
+
storage.setItem(key, text);
|
|
52
|
+
} else {
|
|
53
|
+
storage.removeItem(key);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
37
57
|
const hasPendingCreation = (
|
|
38
58
|
storage: StorageAccess,
|
|
39
59
|
ownerId: string,
|
|
@@ -212,6 +232,11 @@ const moveRejectedContextCreation = (
|
|
|
212
232
|
"Finish the saved request in New Chat before recovering this draft."
|
|
213
233
|
);
|
|
214
234
|
}
|
|
235
|
+
if (readCreationFollowUp(storage, ownerId)) {
|
|
236
|
+
throw new Error(
|
|
237
|
+
"Send or clear the draft in New Chat before recovering this project draft."
|
|
238
|
+
);
|
|
239
|
+
}
|
|
215
240
|
const next =
|
|
216
241
|
"modelIds" in pending
|
|
217
242
|
? prepareResponseGroupCreation(
|
|
@@ -230,6 +255,11 @@ const moveRejectedContextCreation = (
|
|
|
230
255
|
undefined,
|
|
231
256
|
pending.selectedTool
|
|
232
257
|
);
|
|
258
|
+
const followUp = readCreationFollowUp(storage, ownerId, scope);
|
|
259
|
+
if (followUp) {
|
|
260
|
+
saveCreationFollowUp(storage, ownerId, followUp);
|
|
261
|
+
saveCreationFollowUp(storage, ownerId, "", scope);
|
|
262
|
+
}
|
|
233
263
|
finishCreation(storage, ownerId, scope);
|
|
234
264
|
return next;
|
|
235
265
|
};
|
|
@@ -242,5 +272,7 @@ export {
|
|
|
242
272
|
prepareSelectedCreation,
|
|
243
273
|
readCreation,
|
|
244
274
|
readCreationRequest,
|
|
275
|
+
readCreationFollowUp,
|
|
276
|
+
saveCreationFollowUp,
|
|
245
277
|
};
|
|
246
278
|
export type { CreationScope };
|
|
@@ -6,9 +6,9 @@ import { eveResponseGroupInput } from "./response-group-input";
|
|
|
6
6
|
|
|
7
7
|
// Reordering accepted command fields changes persisted admission hashes.
|
|
8
8
|
const creationWire =
|
|
9
|
-
'{"operationId":"11111111-1111-4111-8111-111111111111","modelId":"test/model","message":[{"type":"text","text":"hello"},{"type":"file","data":"/api/files/abcdefghijklmnopqrstuvwx.png","mediaType":"image/png","filename":"image.png"}],"fork":{"
|
|
9
|
+
'{"operationId":"11111111-1111-4111-8111-111111111111","modelId":"test/model","message":[{"type":"text","text":"hello"},{"type":"file","data":"/api/files/abcdefghijklmnopqrstuvwx.png","mediaType":"image/png","filename":"image.png"}],"fork":{"branchId":"22222222-2222-4222-8222-222222222222"}}';
|
|
10
10
|
const groupWire =
|
|
11
|
-
'{"operationId":"11111111-1111-4111-8111-111111111111","modelIds":["test/one","test/two"],"message":"hello","fork":{"
|
|
11
|
+
'{"operationId":"11111111-1111-4111-8111-111111111111","modelIds":["test/one","test/two"],"message":"hello","fork":{"branchId":"22222222-2222-4222-8222-222222222222"}}';
|
|
12
12
|
|
|
13
13
|
const digest = (value: string): string =>
|
|
14
14
|
createHash("sha256").update(value).digest("hex");
|
|
@@ -6,12 +6,12 @@ import {
|
|
|
6
6
|
|
|
7
7
|
/** Authorize and retire the whole family before fencing work for external-resource inventory.
|
|
8
8
|
* @param {string} ownerId Owner whose conversation family is authorized and retired.
|
|
9
|
-
* @param {string}
|
|
9
|
+
* @param {string} branchId Conversation used to resolve the deletion family.
|
|
10
10
|
* @returns {ReturnType<typeof prepareEveFamilyDeletion>} The retired family with each native session inventory and sorted distinct run/stream identities, or no result for an absent family. Missing session bindings and lifecycle preparation failures reject before external-resource cleanup.
|
|
11
11
|
*/
|
|
12
12
|
export const prepareEveFamilyDeletion = async (
|
|
13
13
|
ownerId: string,
|
|
14
|
-
|
|
14
|
+
branchId: string
|
|
15
15
|
): Promise<
|
|
16
16
|
| (NonNullable<Awaited<ReturnType<typeof retireEveFamilyForDeletion>>> & {
|
|
17
17
|
nativeInventories: {
|
|
@@ -25,7 +25,7 @@ export const prepareEveFamilyDeletion = async (
|
|
|
25
25
|
| undefined
|
|
26
26
|
> => {
|
|
27
27
|
const lifecycle = requireEveDeletionLifecycle();
|
|
28
|
-
const family = await retireEveFamilyForDeletion(ownerId,
|
|
28
|
+
const family = await retireEveFamilyForDeletion(ownerId, branchId);
|
|
29
29
|
if (!family) {
|
|
30
30
|
return undefined;
|
|
31
31
|
}
|
|
@@ -13,14 +13,14 @@ const purgeExternalEveFamilyResources = async (
|
|
|
13
13
|
* Internal local-provider coordinator. Native history and deleting bindings remain
|
|
14
14
|
* until external tool resources are accounted for and final erasure can proceed.
|
|
15
15
|
* @param {string} ownerId Owner authorizing the local family resource purge.
|
|
16
|
-
* @param {string}
|
|
16
|
+
* @param {string} branchId Conversation resolving the retired deletion family.
|
|
17
17
|
* @returns {ReturnType<typeof prepareEveFamilyDeletion>} The prepared family after external sandbox/file stages, or the unchanged absent/empty family result. Unattributed resource evidence or failed cleanup rejects before final native/application erasure.
|
|
18
18
|
*/
|
|
19
19
|
export const purgeLocalEveFamilyResources = async (
|
|
20
20
|
ownerId: string,
|
|
21
|
-
|
|
21
|
+
branchId: string
|
|
22
22
|
): ReturnType<typeof prepareEveFamilyDeletion> => {
|
|
23
|
-
const family = await prepareEveFamilyDeletion(ownerId,
|
|
23
|
+
const family = await prepareEveFamilyDeletion(ownerId, branchId);
|
|
24
24
|
if (!family) {
|
|
25
25
|
return family;
|
|
26
26
|
}
|
|
@@ -44,9 +44,9 @@ const hasSettledDescendants = async (
|
|
|
44
44
|
/** Reconcile known receipts only. Failure/absence leaves the durable workspace reservation intact. */
|
|
45
45
|
export const reconcileEveWorkspaceTurn = async (
|
|
46
46
|
ownerId: string,
|
|
47
|
-
|
|
47
|
+
branchId: string
|
|
48
48
|
): Promise<void> => {
|
|
49
|
-
const active = await readActiveEveWorkspaceOperation(ownerId,
|
|
49
|
+
const active = await readActiveEveWorkspaceOperation(ownerId, branchId);
|
|
50
50
|
const sessionId = active?.operation.sessionId;
|
|
51
51
|
if (
|
|
52
52
|
active === undefined ||
|