chat-js 1.0.0-alpha.2 → 1.0.0-alpha.4
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 +6 -4
- package/dist/index.js +2627 -2667
- package/package.json +10 -4
- package/templates/chat-app/.env.example +2 -8
- package/templates/chat-app/agent/agent.ts +8 -38
- package/templates/chat-app/agent/channels/eve.ts +37 -17
- package/templates/chat-app/agent/hooks/activity.ts +2 -1
- package/templates/chat-app/agent/hooks/billing.ts +11 -8
- package/templates/chat-app/agent/hooks/conversation.ts +2 -2
- package/templates/chat-app/agent/hooks/tool-selection.ts +7 -1
- package/templates/chat-app/agent/instructions/chat.ts +14 -10
- package/templates/chat-app/agent/sandbox.ts +2 -4
- package/templates/chat-app/agent/tools/installed.ts +19 -1
- package/templates/chat-app/app/(chat)/layout.tsx +10 -8
- package/templates/chat-app/app/api/agent-conversations/[id]/route.test.ts +1 -1
- package/templates/chat-app/app/api/agent-conversations/[id]/route.ts +1 -5
- package/templates/chat-app/app/api/agent-conversations/route.test.ts +31 -2
- package/templates/chat-app/app/api/agent-conversations/route.ts +10 -1
- package/templates/chat-app/app/api/agent-workspaces/[id]/route.test.ts +5 -31
- package/templates/chat-app/app/api/agent-workspaces/[id]/route.ts +2 -10
- package/templates/chat-app/app/api/eve/[...path]/route.test.ts +2 -2
- package/templates/chat-app/app/apple-icon.png +0 -0
- package/templates/chat-app/app/favicon.ico +0 -0
- package/templates/chat-app/app/icon.svg +1 -3
- package/templates/chat-app/app/opengraph-image.alt.txt +1 -0
- package/templates/chat-app/app/opengraph-image.png +0 -0
- package/templates/chat-app/chat.config.ts +0 -18
- package/templates/chat-app/chatjs/core/chat/compose.ts +35 -11
- package/templates/chat-app/chatjs/core/chat/contracts.ts +6 -0
- package/templates/chat-app/chatjs/core/installation/contracts.ts +1 -4
- package/templates/chat-app/chatjs/core/session/contracts.ts +19 -4
- package/templates/chat-app/chatjs/generated/composer-tools.ts +5 -12
- package/templates/chat-app/chatjs/generated/installed-chat-ui.ts +11 -5
- package/templates/chat-app/chatjs/generated/installed-config.ts +5 -13
- package/templates/chat-app/chatjs/generated/installed-instrumentation.ts +1 -2
- package/templates/chat-app/chatjs/generated/installed-layout.ts +1 -7
- package/templates/chat-app/chatjs/generated/installed-tools.ts +3 -3
- package/templates/chat-app/chatjs/generated/installed.ts +3 -3
- package/templates/chat-app/chatjs/generated/providers.ts +5 -11
- package/templates/chat-app/chatjs/generated/tool-availability.ts +3 -7
- package/templates/chat-app/chatjs/generated/tool-definitions.ts +3 -4
- package/templates/chat-app/chatjs/generated/tool-requirements.ts +40 -0
- package/templates/chat-app/chatjs/generated/tools.ts +7 -28
- package/templates/chat-app/chatjs/generated/ui.ts +3 -13
- package/templates/chat-app/chatjs/plugins/ai-titles/generate-title.ts +0 -2
- package/templates/chat-app/chatjs/plugins/attachment-uploads/chatjs.json +0 -1
- package/templates/chat-app/chatjs/plugins/guest-chat/session-profile.ts +2 -0
- package/templates/chat-app/chatjs/plugins/guest-chat/signed-out.tsx +70 -34
- package/templates/chat-app/chatjs/plugins/image-viewer/chatjs.json +17 -0
- package/templates/chat-app/chatjs/plugins/image-viewer/client-plugin.ts +9 -0
- package/templates/chat-app/{components → chatjs/plugins/image-viewer}/image-modal.tsx +3 -87
- package/templates/chat-app/chatjs/plugins/image-viewer/viewer-action.tsx +47 -0
- package/templates/chat-app/chatjs/plugins/mcp/composer.tsx +1 -6
- package/templates/chat-app/chatjs/plugins/projects/ui/chat-contributions.tsx +22 -2
- package/templates/chat-app/chatjs/plugins/projects/ui/sidebar-project-item.tsx +48 -33
- package/templates/chat-app/chatjs/plugins/projects/ui/sidebar-projects.tsx +41 -22
- package/templates/chat-app/chatjs/plugins/search/chat.ts +4 -0
- package/templates/chat-app/chatjs/plugins/search/search-chats.tsx +9 -3
- package/templates/chat-app/chatjs/plugins/search/search-hook.ts +5 -6
- package/templates/chat-app/chatjs/plugins/search/search-results-view.tsx +1 -1
- package/templates/chat-app/chatjs/plugins/search/search-text.ts +21 -15
- package/templates/chat-app/chatjs/plugins/search/sidebar-item.tsx +7 -1
- package/templates/chat-app/chatjs/plugins/sharing/ui/share-button.tsx +13 -3
- package/templates/chat-app/chatjs/plugins/sharing/ui/shared-page.tsx +23 -39
- package/templates/chat-app/chatjs/plugins/sharing/ui/transcript-messages.tsx +2 -2
- package/templates/chat-app/chatjs/plugins/spreadsheet-viewer/chatjs.json +18 -0
- package/templates/chat-app/chatjs/plugins/spreadsheet-viewer/client-plugin.ts +9 -0
- package/templates/chat-app/chatjs/plugins/spreadsheet-viewer/load.ts +120 -0
- package/templates/chat-app/chatjs/plugins/spreadsheet-viewer/preview.tsx +72 -0
- package/templates/chat-app/chatjs/plugins/spreadsheet-viewer/viewer-action.tsx +97 -0
- package/templates/chat-app/chatjs/plugins/video-viewer/chatjs.json +16 -0
- package/templates/chat-app/chatjs/plugins/video-viewer/client-plugin.ts +9 -0
- package/templates/chat-app/chatjs/plugins/video-viewer/viewer-action.tsx +64 -0
- package/templates/chat-app/chatjs/tools/_shared/lib/define-tool-renderer.test.ts +16 -22
- package/templates/chat-app/chatjs/tools/attach-workspace-file/attach-conversation-file.ts +34 -0
- package/templates/chat-app/chatjs/tools/attach-workspace-file/attach.ts +106 -0
- package/templates/chat-app/chatjs/tools/attach-workspace-file/chatjs.json +19 -0
- package/templates/chat-app/chatjs/tools/attach-workspace-file/import.ts +71 -0
- package/templates/chat-app/chatjs/tools/attach-workspace-file/renderer.tsx +19 -0
- package/templates/chat-app/chatjs/tools/attach-workspace-file/schemas.ts +51 -0
- package/templates/chat-app/chatjs/tools/attach-workspace-file/tool.ts +62 -0
- package/templates/chat-app/chatjs/tools/deep-research/chatjs.json +18 -4
- package/templates/chat-app/chatjs/tools/deep-research/progress-panel.tsx +2 -31
- package/templates/chat-app/chatjs/tools/deep-research/renderer.tsx +7 -19
- package/templates/chat-app/chatjs/tools/deep-research/schemas.ts +1 -46
- package/templates/chat-app/chatjs/tools/deep-research/task.tsx +0 -41
- package/templates/chat-app/chatjs/tools/deep-research/tasks.tsx +2 -7
- package/templates/chat-app/chatjs/tools/generate-image/chatjs.json +4 -1
- package/templates/chat-app/chatjs/tools/generate-image/image-generation.ts +0 -1
- package/templates/chat-app/chatjs/tools/generate-image/renderer.tsx +39 -51
- package/templates/chat-app/chatjs/tools/generate-video/chatjs.json +4 -1
- package/templates/chat-app/chatjs/tools/generate-video/renderer.tsx +22 -11
- package/templates/chat-app/components/ai-elements/response.tsx +1 -1
- package/templates/chat-app/components/app-sidebar.tsx +26 -86
- package/templates/chat-app/components/artifact-actions.tsx +19 -0
- package/templates/chat-app/components/artifact-download-action.tsx +59 -0
- package/templates/chat-app/components/attachment-card.tsx +15 -9
- package/templates/chat-app/components/chat/chat-account.tsx +189 -0
- package/templates/chat-app/components/{controlled-chat-composer.tsx → chat/chat-composer.tsx} +6 -6
- package/templates/chat-app/components/chat/chat-conversation-screen.tsx +75 -0
- package/templates/chat-app/components/chat/chat-conversation.tsx +35 -0
- package/templates/chat-app/components/chat/chat-header.tsx +52 -0
- package/templates/chat-app/components/chat/chat-message-editor.tsx +24 -0
- package/templates/chat-app/components/chat/chat-navigation.tsx +11 -0
- package/templates/chat-app/components/chat/chat-sidebar.tsx +134 -0
- package/templates/chat-app/components/{eve/eve-messages.tsx → chat/chat-transcript.tsx} +7 -28
- package/templates/chat-app/components/chat/chat-workspace.tsx +19 -0
- package/templates/chat-app/components/chat/connected-chat-sidebar.tsx +8 -0
- package/templates/chat-app/components/chat-header-view.tsx +14 -13
- package/templates/chat-app/components/chat-slots.tsx +13 -3
- package/templates/chat-app/components/composer/active-tool.tsx +3 -1
- package/templates/chat-app/components/composer/composer-menu.tsx +4 -2
- package/templates/chat-app/components/composer/control.ts +4 -1
- package/templates/chat-app/components/composer/prompt-form.tsx +1 -1
- package/templates/chat-app/components/composer/tool-availability.tsx +8 -0
- package/templates/chat-app/components/composer/tool-controls.tsx +17 -50
- package/templates/chat-app/components/composer/tool-display.ts +3 -2
- package/templates/chat-app/components/eve/bash-output.tsx +33 -0
- package/templates/chat-app/components/eve/eve-chat-page.tsx +5 -26
- package/templates/chat-app/components/eve/eve-composer.tsx +11 -8
- package/templates/chat-app/components/eve/eve-conversation.tsx +237 -309
- package/templates/chat-app/components/eve/eve-deletion-provider.tsx +1 -1
- package/templates/chat-app/components/eve/eve-history-list.tsx +7 -3
- package/templates/chat-app/components/eve/eve-message-part.tsx +28 -22
- package/templates/chat-app/components/eve/eve-pending-input.tsx +54 -1
- package/templates/chat-app/components/eve/eve-runtime-provider.tsx +0 -5
- package/templates/chat-app/components/eve/new-conversation-view.tsx +7 -3
- package/templates/chat-app/components/file-artifact-card.tsx +37 -0
- package/templates/chat-app/components/header-actions.tsx +9 -2
- package/templates/chat-app/components/image-actions.tsx +93 -0
- package/templates/chat-app/components/internal-link.tsx +15 -2
- package/templates/chat-app/components/keyboard-shortcuts.tsx +8 -2
- package/templates/chat-app/components/part/tool-activity.tsx +1 -1
- package/templates/chat-app/components/part/tool-data.tsx +1 -1
- package/templates/chat-app/components/sidebar-user-nav.tsx +35 -198
- package/templates/chat-app/components/video-player.tsx +43 -0
- package/templates/chat-app/composer-controls.ts +0 -4
- package/templates/chat-app/docs/guest-sessions.md +1 -1
- package/templates/chat-app/instrumentation.ts +2 -6
- package/templates/chat-app/integrations/chat/models.ts +10 -0
- package/templates/chat-app/integrations/tools/catalog.ts +0 -3
- package/templates/chat-app/lib/ai/app-models.test.ts +13 -1
- package/templates/chat-app/lib/ai/app-models.ts +13 -3
- package/templates/chat-app/lib/ai/tool-context.ts +1 -14
- package/templates/chat-app/lib/ai/tool-renderer-registry.ts +10 -5
- package/templates/chat-app/lib/db/eve-current-copy.ts +13 -95
- package/templates/chat-app/lib/db/eve-deletion.ts +2 -61
- package/templates/chat-app/lib/db/eve-dispatch.ts +64 -18
- package/templates/chat-app/lib/db/eve-file-purge.ts +11 -145
- package/templates/chat-app/lib/db/eve-files.ts +11 -9
- package/templates/chat-app/lib/db/eve-orphaned-files.ts +3 -22
- package/templates/chat-app/lib/db/eve-queries.ts +32 -16
- package/templates/chat-app/lib/db/eve-workspace-deletion.ts +149 -0
- package/templates/chat-app/lib/db/migrate.ts +30 -0
- package/templates/chat-app/lib/db/migrations/0024_abandoned_toxin.sql +67 -0
- package/templates/chat-app/lib/db/migrations/0025_cloudy_thunderbolt.sql +1 -0
- package/templates/chat-app/lib/db/migrations/0026_loving_mesmero.sql +3 -0
- package/templates/chat-app/lib/db/migrations/0027_misty_stephen_strange.sql +1 -0
- package/templates/chat-app/lib/db/migrations/0028_faithful_hannibal_king.sql +12 -0
- package/templates/chat-app/lib/db/migrations/meta/0024_snapshot.json +4119 -0
- package/templates/chat-app/lib/db/migrations/meta/0025_snapshot.json +3988 -0
- package/templates/chat-app/lib/db/migrations/meta/0026_snapshot.json +3686 -0
- package/templates/chat-app/lib/db/migrations/meta/0027_snapshot.json +3596 -0
- package/templates/chat-app/lib/db/migrations/meta/0028_snapshot.json +2554 -0
- package/templates/chat-app/lib/db/migrations/meta/_journal.json +35 -0
- package/templates/chat-app/lib/db/schema.ts +1 -360
- package/templates/chat-app/lib/env-schema.ts +0 -7
- package/templates/chat-app/lib/eve/application-model.ts +56 -0
- package/templates/chat-app/lib/eve/bash-result.ts +22 -0
- package/templates/chat-app/lib/eve/branch-history.test.ts +59 -0
- package/templates/chat-app/lib/eve/branch-history.ts +19 -0
- package/templates/chat-app/lib/eve/channel-files.test.ts +14 -11
- package/templates/chat-app/lib/eve/channel-files.ts +2 -12
- package/templates/chat-app/lib/eve/completed-copy-source.test.ts +81 -17
- package/templates/chat-app/lib/eve/completed-copy-source.ts +2 -6
- package/templates/chat-app/lib/eve/connection-options.ts +7 -7
- package/templates/chat-app/lib/eve/contracts.test.ts +1 -1
- package/templates/chat-app/lib/eve/copy-seed.test.ts +17 -28
- package/templates/chat-app/lib/eve/copy-seed.ts +8 -34
- package/templates/chat-app/lib/eve/copy-transcript.test.ts +143 -47
- package/templates/chat-app/lib/eve/copy-transcript.ts +20 -101
- package/templates/chat-app/lib/eve/create-conversation-operation.test.ts +11 -31
- package/templates/chat-app/lib/eve/create-conversation-operation.ts +0 -10
- package/templates/chat-app/lib/eve/delete-local-conversation.test.ts +12 -20
- package/templates/chat-app/lib/eve/delete-local-conversation.ts +2 -8
- package/templates/chat-app/lib/eve/environment.test.ts +7 -0
- package/templates/chat-app/lib/eve/environment.ts +11 -0
- package/templates/chat-app/lib/eve/execute-conversation-creation.ts +3 -55
- package/templates/chat-app/lib/eve/gateway-auth.test.ts +2 -21
- package/templates/chat-app/lib/eve/gateway-auth.ts +7 -13
- 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/installed-tools.test.ts +16 -9
- package/templates/chat-app/lib/eve/lifecycle/postgres/compatibility.ts +8 -5
- package/templates/chat-app/lib/eve/lifecycle/postgres/eve-payload-purge.ts +6 -2
- package/templates/chat-app/lib/eve/lifecycle/postgres/eve-queue-fence.ts +2 -2
- package/templates/chat-app/lib/eve/lifecycle/postgres/eve-queue-inventory.ts +2 -2
- package/templates/chat-app/lib/eve/lifecycle/postgres/eve-queue-purge.ts +3 -2
- package/templates/chat-app/lib/eve/lifecycle/postgres/eve-resource-fence.ts +2 -8
- package/templates/chat-app/lib/eve/lifecycle/postgres/eve-run-inventory.ts +1 -1
- package/templates/chat-app/lib/eve/lifecycle/postgres/eve-stream-positions.ts +9 -4
- package/templates/chat-app/lib/eve/logical-chat.test.ts +4 -3
- package/templates/chat-app/lib/eve/logical-chat.ts +8 -8
- package/templates/chat-app/lib/eve/message-delivery.test.ts +1 -1
- package/templates/chat-app/lib/eve/message-display.test.ts +5 -5
- package/templates/chat-app/lib/eve/message-display.ts +31 -1
- package/templates/chat-app/lib/eve/message-tool-selection.test.ts +2 -2
- package/templates/chat-app/lib/eve/model-accounting.test.ts +28 -45
- package/templates/chat-app/lib/eve/model-accounting.ts +8 -54
- package/templates/chat-app/lib/eve/purge-files.ts +0 -13
- package/templates/chat-app/lib/eve/purge-local-resources.ts +4 -47
- package/templates/chat-app/lib/eve/readonly-message-types.ts +8 -3
- package/templates/chat-app/lib/eve/reconcile-workspace-turn.ts +2 -37
- package/templates/chat-app/lib/eve/response-group-lineage.test.ts +3 -3
- package/templates/chat-app/lib/eve/retire-session.test.ts +25 -8
- package/templates/chat-app/lib/eve/retire-session.ts +10 -4
- package/templates/chat-app/lib/eve/selected-tools.ts +7 -18
- package/templates/chat-app/lib/eve/server.test.ts +29 -3
- package/templates/chat-app/lib/eve/session-profile.test.ts +12 -9
- package/templates/chat-app/lib/eve/session-profile.ts +7 -4
- package/templates/chat-app/lib/eve/shared-messages.test.ts +3 -4
- package/templates/chat-app/lib/eve/shared-messages.ts +5 -2
- package/templates/chat-app/lib/eve/tool-accounting.test.ts +131 -0
- package/templates/chat-app/lib/eve/tool-accounting.ts +96 -0
- package/templates/chat-app/lib/eve/tool-availability.ts +4 -1
- package/templates/chat-app/lib/eve/tool-configuration.ts +29 -0
- package/templates/chat-app/lib/eve/tool-result.ts +1 -1
- package/templates/chat-app/lib/eve/turn-tools.ts +3 -12
- package/templates/chat-app/lib/eve/usage.test.ts +54 -39
- package/templates/chat-app/lib/eve/usage.ts +9 -1
- package/templates/chat-app/lib/eve/workspace-turn-evidence.test.ts +8 -6
- package/templates/chat-app/lib/eve/workspace-turn-evidence.ts +0 -5
- package/templates/chat-app/lib/required-credentials.test.ts +2 -2
- package/templates/chat-app/lib/tool-readiness.test.ts +69 -0
- package/templates/chat-app/lib/tool-readiness.ts +43 -0
- package/templates/chat-app/logo.svg +1 -1
- package/templates/chat-app/next.config.ts +1 -5
- package/templates/chat-app/oxlint.config.ts +3 -6
- package/templates/chat-app/package.json +4 -16
- package/templates/chat-app/providers/chat-models-provider.tsx +3 -3
- package/templates/chat-app/providers/default-model-provider.tsx +4 -4
- package/templates/chat-app/providers/session-context.ts +24 -0
- package/templates/chat-app/providers/session-provider.tsx +4 -21
- package/templates/chat-app/scripts/agent-status.ts +124 -0
- package/templates/chat-app/scripts/check-env.ts +0 -10
- package/templates/chat-app/scripts/dev-supervisor.mts +3 -30
- package/templates/chat-app/scripts/eve-setup.ts +3 -0
- package/templates/chat-app/tests/helpers/eve-dynamic-context.ts +2 -0
- package/templates/chat-app/tools/platform/research-updates-schema.ts +1 -20
- package/templates/chat-app/trpc/context.tsx +8 -0
- package/templates/chat-app/trpc/react.tsx +3 -4
- package/templates/chat-app/trpc/routers/eve.router.ts +2 -74
- package/templates/chat-app/vendor/workflow-world-postgres-5.1.1.tgz +0 -0
- package/templates/electron/icon.png +0 -0
- package/templates/electron/package.json +2 -1
- package/templates/electron/src/application.test.ts +347 -0
- package/templates/electron/src/application.ts +849 -0
- package/templates/electron/src/lib/auth-cookies.ts +1 -1
- package/templates/electron/src/main.test.ts +175 -0
- package/templates/electron/src/main.ts +5 -745
- package/templates/electron/src/squirrel-startup.ts +61 -0
- package/templates/chat-app/agent/hooks/persistent-sandbox.ts +0 -14
- package/templates/chat-app/app/api/agent-conversation-copies/route.test.ts +0 -190
- package/templates/chat-app/app/api/agent-conversation-copies/route.ts +0 -105
- package/templates/chat-app/chatjs/core/documents/compose-views.ts +0 -12
- package/templates/chat-app/chatjs/core/documents/contracts.ts +0 -91
- package/templates/chat-app/chatjs/core/documents/document-definition.test.ts +0 -60
- package/templates/chat-app/chatjs/core/documents/document-definition.ts +0 -55
- package/templates/chat-app/chatjs/core/documents/ui.ts +0 -67
- package/templates/chat-app/chatjs/generated/code-executor.ts +0 -6
- package/templates/chat-app/chatjs/generated/document-run.ts +0 -12
- package/templates/chat-app/chatjs/generated/document-ui.ts +0 -7
- package/templates/chat-app/chatjs/generated/documents.ts +0 -6
- package/templates/chat-app/chatjs/plugins/langfuse/chatjs.json +0 -14
- package/templates/chat-app/chatjs/plugins/langfuse/credentials.ts +0 -22
- package/templates/chat-app/chatjs/plugins/langfuse/instrumentation.ts +0 -22
- package/templates/chat-app/chatjs/plugins/langfuse/server-plugin.ts +0 -5
- package/templates/chat-app/chatjs/plugins/vercel-analytics/chatjs.json +0 -15
- package/templates/chat-app/chatjs/plugins/vercel-analytics/client-plugin.ts +0 -9
- package/templates/chat-app/chatjs/plugins/vercel-analytics/component.tsx +0 -5
- package/templates/chat-app/chatjs/plugins/vercel-speed-insights/chatjs.json +0 -15
- package/templates/chat-app/chatjs/plugins/vercel-speed-insights/client-plugin.ts +0 -9
- package/templates/chat-app/chatjs/plugins/vercel-speed-insights/component.tsx +0 -4
- package/templates/chat-app/chatjs/providers/sandbox/adapter.ts +0 -232
- package/templates/chat-app/chatjs/providers/sandbox/options.ts +0 -13
- package/templates/chat-app/chatjs/providers/sandbox/persistent.ts +0 -258
- package/templates/chat-app/chatjs/providers/sandbox/provider.ts +0 -27
- package/templates/chat-app/chatjs/providers/sandbox/vercel-sandbox-env.ts +0 -22
- package/templates/chat-app/chatjs/tools/_shared/code-execution/code-execution-chart.tsx +0 -83
- package/templates/chat-app/chatjs/tools/_shared/code-execution/interactive-chart-impl.tsx +0 -290
- package/templates/chat-app/chatjs/tools/_shared/code-execution/interactive-charts.tsx +0 -24
- package/templates/chat-app/chatjs/tools/_shared/code-execution/javascript.ts +0 -222
- package/templates/chat-app/chatjs/tools/_shared/code-execution/python.ts +0 -381
- package/templates/chat-app/chatjs/tools/_shared/code-execution/types.ts +0 -27
- package/templates/chat-app/chatjs/tools/code-documents/assistant-actions.ts +0 -16
- package/templates/chat-app/chatjs/tools/code-documents/chatjs.json +0 -20
- package/templates/chat-app/chatjs/tools/code-documents/configuration-schema.ts +0 -7
- package/templates/chat-app/chatjs/tools/code-documents/definition.ts +0 -9
- package/templates/chat-app/chatjs/tools/code-documents/document.tsx +0 -33
- package/templates/chat-app/chatjs/tools/code-documents/editor.tsx +0 -144
- package/templates/chat-app/chatjs/tools/code-documents/guidelines.ts +0 -15
- package/templates/chat-app/chatjs/tools/code-documents/tool.ts +0 -54
- package/templates/chat-app/chatjs/tools/code-execution/chatjs.json +0 -21
- package/templates/chat-app/chatjs/tools/code-execution/python.test.ts +0 -207
- package/templates/chat-app/chatjs/tools/code-execution/renderer.test.tsx +0 -142
- package/templates/chat-app/chatjs/tools/code-execution/renderer.tsx +0 -68
- package/templates/chat-app/chatjs/tools/code-execution/schemas.ts +0 -23
- package/templates/chat-app/chatjs/tools/code-execution/tool.ts +0 -93
- package/templates/chat-app/chatjs/tools/deep-research/agent.ts +0 -18
- package/templates/chat-app/chatjs/tools/deep-research/availability.ts +0 -23
- package/templates/chat-app/chatjs/tools/deep-research/configuration-schema.ts +0 -36
- package/templates/chat-app/chatjs/tools/deep-research/configuration.ts +0 -22
- package/templates/chat-app/chatjs/tools/deep-research/prompts.ts +0 -280
- package/templates/chat-app/chatjs/tools/deep-research/search-updates.ts +0 -76
- package/templates/chat-app/chatjs/tools/deep-research/steps.ts +0 -92
- package/templates/chat-app/chatjs/tools/delete-document/availability.ts +0 -13
- package/templates/chat-app/chatjs/tools/delete-document/chatjs.json +0 -9
- package/templates/chat-app/chatjs/tools/delete-document/execute.ts +0 -78
- package/templates/chat-app/chatjs/tools/delete-document/schemas.ts +0 -18
- package/templates/chat-app/chatjs/tools/delete-document/tool.ts +0 -49
- package/templates/chat-app/chatjs/tools/get-weather/chatjs.json +0 -14
- package/templates/chat-app/chatjs/tools/get-weather/definition.ts +0 -10
- package/templates/chat-app/chatjs/tools/get-weather/renderer.test.tsx +0 -57
- package/templates/chat-app/chatjs/tools/get-weather/renderer.tsx +0 -290
- package/templates/chat-app/chatjs/tools/get-weather/schemas.ts +0 -51
- package/templates/chat-app/chatjs/tools/get-weather/tool.ts +0 -34
- package/templates/chat-app/chatjs/tools/read-document/chatjs.json +0 -8
- package/templates/chat-app/chatjs/tools/read-document/tool.ts +0 -27
- package/templates/chat-app/chatjs/tools/retrieve-url/chatjs.json +0 -11
- package/templates/chat-app/chatjs/tools/retrieve-url/renderer.tsx +0 -200
- package/templates/chat-app/chatjs/tools/retrieve-url/retrieve-url-env.ts +0 -11
- package/templates/chat-app/chatjs/tools/retrieve-url/schemas.ts +0 -24
- package/templates/chat-app/chatjs/tools/retrieve-url/tool.test.ts +0 -144
- package/templates/chat-app/chatjs/tools/retrieve-url/tool.ts +0 -169
- package/templates/chat-app/chatjs/tools/saved-code-execution/chatjs.json +0 -12
- package/templates/chat-app/chatjs/tools/saved-code-execution/document-runs.ts +0 -31
- package/templates/chat-app/chatjs/tools/saved-code-execution/document.tsx +0 -84
- package/templates/chat-app/chatjs/tools/saved-code-execution/execute.ts +0 -126
- package/templates/chat-app/chatjs/tools/saved-code-execution/renderer.tsx +0 -30
- package/templates/chat-app/chatjs/tools/saved-code-execution/result.tsx +0 -42
- package/templates/chat-app/chatjs/tools/saved-code-execution/schemas.ts +0 -82
- package/templates/chat-app/chatjs/tools/saved-code-execution/tool.ts +0 -12
- package/templates/chat-app/chatjs/tools/sheet-documents/assistant-actions.ts +0 -22
- package/templates/chat-app/chatjs/tools/sheet-documents/chatjs.json +0 -20
- package/templates/chat-app/chatjs/tools/sheet-documents/configuration-schema.ts +0 -10
- package/templates/chat-app/chatjs/tools/sheet-documents/definition.ts +0 -9
- package/templates/chat-app/chatjs/tools/sheet-documents/document.tsx +0 -41
- package/templates/chat-app/chatjs/tools/sheet-documents/editor.tsx +0 -180
- package/templates/chat-app/chatjs/tools/sheet-documents/guidelines.ts +0 -5
- package/templates/chat-app/chatjs/tools/sheet-documents/tool.ts +0 -54
- package/templates/chat-app/chatjs/tools/tavily-search/chatjs.json +0 -19
- package/templates/chat-app/chatjs/tools/tavily-search/renderer.tsx +0 -25
- package/templates/chat-app/chatjs/tools/tavily-search/schemas.ts +0 -39
- package/templates/chat-app/chatjs/tools/tavily-search/tavily-search-env.ts +0 -11
- package/templates/chat-app/chatjs/tools/tavily-search/tool.test.ts +0 -114
- package/templates/chat-app/chatjs/tools/tavily-search/tool.ts +0 -143
- package/templates/chat-app/chatjs/tools/text-documents/assistant-actions.ts +0 -12
- package/templates/chat-app/chatjs/tools/text-documents/chatjs.json +0 -20
- package/templates/chat-app/chatjs/tools/text-documents/comparison.tsx +0 -72
- package/templates/chat-app/chatjs/tools/text-documents/configuration-schema.ts +0 -7
- package/templates/chat-app/chatjs/tools/text-documents/definition.ts +0 -9
- package/templates/chat-app/chatjs/tools/text-documents/diffview.tsx +0 -214
- package/templates/chat-app/chatjs/tools/text-documents/document.tsx +0 -46
- package/templates/chat-app/chatjs/tools/text-documents/editor-config.ts +0 -53
- package/templates/chat-app/chatjs/tools/text-documents/editor.tsx +0 -139
- package/templates/chat-app/chatjs/tools/text-documents/guidelines.ts +0 -7
- package/templates/chat-app/chatjs/tools/text-documents/tool.ts +0 -54
- package/templates/chat-app/chatjs/tools/word-count/chatjs.json +0 -14
- package/templates/chat-app/chatjs/tools/word-count/definition.ts +0 -10
- package/templates/chat-app/chatjs/tools/word-count/renderer.tsx +0 -64
- package/templates/chat-app/chatjs/tools/word-count/schemas.ts +0 -13
- package/templates/chat-app/chatjs/tools/word-count/tool.ts +0 -45
- package/templates/chat-app/components/chat/chat-layout.tsx +0 -129
- package/templates/chat-app/components/chat-sidebar-view.tsx +0 -53
- package/templates/chat-app/components/document-skeleton.tsx +0 -33
- package/templates/chat-app/components/eve/eve-artifact-layout.tsx +0 -722
- package/templates/chat-app/components/eve/eve-copy-button.tsx +0 -165
- package/templates/chat-app/components/eve/eve-document-actions.tsx +0 -124
- package/templates/chat-app/components/eve/eve-document-assistant-actions.tsx +0 -157
- package/templates/chat-app/components/eve/eve-document-body.tsx +0 -29
- package/templates/chat-app/components/eve/eve-document-context.tsx +0 -12
- package/templates/chat-app/components/eve/eve-document-preview.tsx +0 -128
- package/templates/chat-app/components/eve/eve-document-tool.tsx +0 -190
- package/templates/chat-app/components/eve/eve-history.tsx +0 -25
- package/templates/chat-app/components/eve/use-document-draft.ts +0 -281
- package/templates/chat-app/components/favicon-group.tsx +0 -50
- package/templates/chat-app/components/part/document-common.tsx +0 -152
- package/templates/chat-app/components/part/web-search.tsx +0 -75
- package/templates/chat-app/components/sandbox.tsx +0 -43
- package/templates/chat-app/components/source-badge.tsx +0 -50
- package/templates/chat-app/components/sources.tsx +0 -140
- package/templates/chat-app/hooks/use-artifact.tsx +0 -180
- package/templates/chat-app/integrations/documents/definitions.ts +0 -4
- package/templates/chat-app/integrations/documents/run.ts +0 -1
- package/templates/chat-app/integrations/documents/ui.ts +0 -4
- package/templates/chat-app/integrations/providers/sandbox.ts +0 -10
- package/templates/chat-app/integrations/tools/code-executor.ts +0 -1
- package/templates/chat-app/lib/ai/telemetry.ts +0 -4
- package/templates/chat-app/lib/artifacts/artifact-kind.ts +0 -8
- package/templates/chat-app/lib/artifacts/types.ts +0 -19
- package/templates/chat-app/lib/db/eve-code-sandboxes.ts +0 -197
- package/templates/chat-app/lib/db/eve-document-retention.ts +0 -36
- package/templates/chat-app/lib/db/eve-documents.ts +0 -700
- package/templates/chat-app/lib/eve/code-executor.ts +0 -32
- package/templates/chat-app/lib/eve/code-sandbox-name.test.ts +0 -60
- package/templates/chat-app/lib/eve/code-sandbox-name.ts +0 -56
- package/templates/chat-app/lib/eve/code-sandbox-ownership.ts +0 -88
- package/templates/chat-app/lib/eve/copy-input.ts +0 -11
- package/templates/chat-app/lib/eve/create-native-copy.ts +0 -38
- package/templates/chat-app/lib/eve/document-assistant-actions.test.ts +0 -48
- package/templates/chat-app/lib/eve/document-assistant-actions.ts +0 -22
- package/templates/chat-app/lib/eve/document-kind-lifecycle.test.ts +0 -148
- package/templates/chat-app/lib/eve/document-tools.ts +0 -164
- package/templates/chat-app/lib/eve/lifecycle/postgres/eve-sandbox-coverage-proof.ts +0 -140
- package/templates/chat-app/lib/eve/persistent-sandbox-store.ts +0 -621
- package/templates/chat-app/lib/eve/persistent-sandbox.test.ts +0 -209
- package/templates/chat-app/lib/eve/persistent-sandbox.ts +0 -328
- package/templates/chat-app/lib/eve/purge-code-sandboxes.test.ts +0 -125
- package/templates/chat-app/lib/eve/purge-code-sandboxes.ts +0 -83
- package/templates/chat-app/lib/eve/request-copy.test.ts +0 -95
- package/templates/chat-app/lib/eve/request-copy.ts +0 -129
- package/templates/chat-app/lib/eve/research-progress.test.ts +0 -95
- package/templates/chat-app/lib/eve/research-progress.ts +0 -42
- package/templates/chat-app/lib/eve/sandbox-environment.test.ts +0 -49
- package/templates/chat-app/lib/eve/sandbox-environment.ts +0 -29
- package/templates/chat-app/lib/eve/save-copy-operation.ts +0 -33
- package/templates/chat-app/lib/eve/save-document.ts +0 -87
- package/templates/chat-app/lib/eve/verify-local-coverage.ts +0 -84
- package/templates/chat-app/lib/eve/workspace-attachments.ts +0 -173
- package/templates/chat-app/lib/sandbox/runtime.ts +0 -12
- package/templates/chat-app/scripts/persistent-sandbox-cleanup.ts +0 -128
- package/templates/chat-app/scripts/stop-persistent-sandboxes.ts +0 -24
- package/templates/chat-app/tests/artifacts.e2e.ts +0 -7
- package/templates/chat-app/tools/platform/documents/types.ts +0 -11
- package/templates/chat-app/tools/platform/search-presentation.ts +0 -138
- package/templates/chat-app/tools/platform/steps/multi-query-web-search.test.ts +0 -45
- package/templates/chat-app/tools/platform/steps/multi-query-web-search.ts +0 -142
- package/templates/chat-app/tools/platform/steps/search-utils.ts +0 -26
- package/templates/chat-app/vendor/workflow-world-postgres-5.0.0-beta.40.tgz +0 -0
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { chat } from "@/integrations/chat/server";
|
|
2
|
-
import { checkDeletedWorkspaceMemberships } from "@/lib/eve
|
|
2
|
+
import { checkDeletedWorkspaceMemberships } from "@/lib/db/eve-workspace-deletion";
|
|
3
3
|
import { eveDeletionScope } from "./eve-deletion-scope";
|
|
4
|
-
import { unretainedEveDocumentRevisionIds } from "./eve-document-retention";
|
|
5
4
|
import { and, eq, exists, inArray, or, sql } from "drizzle-orm";
|
|
6
5
|
import type { QueryPromise } from "drizzle-orm/query-promise";
|
|
7
6
|
|
|
@@ -9,17 +8,8 @@ import { db } from "./client";
|
|
|
9
8
|
import { tombstoneEveResponseGroups } from "./eve-response-groups";
|
|
10
9
|
import {
|
|
11
10
|
eveChat,
|
|
12
|
-
eveCodeSandbox,
|
|
13
11
|
eveConversation,
|
|
14
|
-
eveDocumentCheckpoint,
|
|
15
|
-
eveDocumentCheckpointEntry,
|
|
16
|
-
eveDocumentHead,
|
|
17
|
-
eveDocumentRevision,
|
|
18
12
|
eveFileReference,
|
|
19
|
-
eveImportedDocumentCheckpoint,
|
|
20
|
-
eveImportedDocumentCheckpointEntry,
|
|
21
|
-
eveNamedDocumentCheckpoint,
|
|
22
|
-
eveNamedDocumentCheckpointEntry,
|
|
23
13
|
eveSubagentSession,
|
|
24
14
|
} from "./schema";
|
|
25
15
|
|
|
@@ -75,31 +65,6 @@ const assertEveFamilyPendingDeletion = (
|
|
|
75
65
|
}
|
|
76
66
|
};
|
|
77
67
|
|
|
78
|
-
/** Read the first unresolved native sandbox without changing query construction or execution.
|
|
79
|
-
* @param {Readonly<Pick<typeof db, "select">>} query - Existing transaction select capability; its receiver is forwarded unchanged.
|
|
80
|
-
* @param {readonly string[]} ids - Family conversation IDs already read after response-group tombstoning.
|
|
81
|
-
* @returns {QueryPromise<readonly (Readonly<Pick<typeof eveCodeSandbox.$inferSelect, "name">> | undefined)[]>} The original native query object; an empty result has no first row.
|
|
82
|
-
*/
|
|
83
|
-
const findUnresolvedEveFamilySandbox = (
|
|
84
|
-
query: Readonly<Pick<typeof db, "select">>,
|
|
85
|
-
ids: readonly string[]
|
|
86
|
-
): QueryPromise<
|
|
87
|
-
readonly (
|
|
88
|
-
| Readonly<Pick<typeof eveCodeSandbox.$inferSelect, "name">>
|
|
89
|
-
| undefined
|
|
90
|
-
)[]
|
|
91
|
-
> =>
|
|
92
|
-
query
|
|
93
|
-
.select({ name: eveCodeSandbox.name })
|
|
94
|
-
.from(eveCodeSandbox)
|
|
95
|
-
.where(
|
|
96
|
-
and(
|
|
97
|
-
inArray(eveCodeSandbox.conversationId, ids),
|
|
98
|
-
eq(eveCodeSandbox.state, "unresolved")
|
|
99
|
-
)
|
|
100
|
-
)
|
|
101
|
-
.limit(SINGLE_MATCH_LIMIT);
|
|
102
|
-
|
|
103
68
|
/** Read the owner-filtered root/member identity before family finalization.
|
|
104
69
|
* @param {Readonly<Pick<typeof db, "select">>} query - Existing transaction select capability, used with its original receiver.
|
|
105
70
|
* @param {string} ownerId - Owner required by the joined identity predicate.
|
|
@@ -220,22 +185,9 @@ const completeEveConversationDeletion = async (
|
|
|
220
185
|
const ids = family.map(
|
|
221
186
|
(row: Readonly<Pick<typeof eveConversation.$inferSelect, "id">>) => row.id
|
|
222
187
|
);
|
|
223
|
-
const [sandbox] = await findUnresolvedEveFamilySandbox(tx, ids);
|
|
224
|
-
if (sandbox) {
|
|
225
|
-
throw new Error("Code sandbox cleanup is incomplete.");
|
|
226
|
-
}
|
|
227
188
|
await checkDeletedWorkspaceMemberships(ownerId, ids, tx);
|
|
228
189
|
|
|
229
|
-
const contentTables = [
|
|
230
|
-
eveFileReference,
|
|
231
|
-
eveImportedDocumentCheckpointEntry,
|
|
232
|
-
eveImportedDocumentCheckpoint,
|
|
233
|
-
eveNamedDocumentCheckpointEntry,
|
|
234
|
-
eveNamedDocumentCheckpoint,
|
|
235
|
-
eveDocumentCheckpointEntry,
|
|
236
|
-
eveDocumentCheckpoint,
|
|
237
|
-
eveDocumentHead,
|
|
238
|
-
];
|
|
190
|
+
const contentTables = [eveFileReference];
|
|
239
191
|
// Only existence matters: check the fenced family's content in one snapshot.
|
|
240
192
|
const remaining = await tx
|
|
241
193
|
.select({ id: eveConversation.id })
|
|
@@ -244,17 +196,6 @@ const completeEveConversationDeletion = async (
|
|
|
244
196
|
and(
|
|
245
197
|
inArray(eveConversation.id, ids),
|
|
246
198
|
or(
|
|
247
|
-
exists(
|
|
248
|
-
tx
|
|
249
|
-
.select({ id: eveDocumentRevision.id })
|
|
250
|
-
.from(eveDocumentRevision)
|
|
251
|
-
.where(
|
|
252
|
-
inArray(
|
|
253
|
-
eveDocumentRevision.id,
|
|
254
|
-
unretainedEveDocumentRevisionIds(ownerId, ids)
|
|
255
|
-
)
|
|
256
|
-
)
|
|
257
|
-
),
|
|
258
199
|
...contentTables.map((table) =>
|
|
259
200
|
exists(
|
|
260
201
|
tx
|
|
@@ -7,6 +7,8 @@ import { EveWorkspaceBusyError, lockEveWorkspace } from "./eve-workspace-turns";
|
|
|
7
7
|
import { reconcileEveWorkspaceTurn } from "../eve/reconcile-workspace-turn";
|
|
8
8
|
import { z } from "zod";
|
|
9
9
|
import { frontendToolsSchema } from "@/lib/ai/types";
|
|
10
|
+
import { parseEveCopySeed } from "@/lib/eve/copy-seed";
|
|
11
|
+
import { eveMessageTool } from "@/lib/eve/message-tool-selection";
|
|
10
12
|
import type { EveMessageDisplayReceipt } from "@/lib/eve/message-display";
|
|
11
13
|
|
|
12
14
|
const hasRow: (row: unknown) => boolean = Boolean;
|
|
@@ -19,9 +21,9 @@ export const getEveMessageDisplayReceipts = async (
|
|
|
19
21
|
): Promise<EveMessageDisplayReceipt[]> => {
|
|
20
22
|
const rows = await database
|
|
21
23
|
.select({
|
|
22
|
-
kind: eveDispatch.kind,
|
|
23
24
|
deliveryId: eveDispatch.deliveryId,
|
|
24
25
|
intent: eveDispatch.intent,
|
|
26
|
+
history: sql<unknown>`case when ${eveDispatch.kind} = 'create' then ${eveConversation.initialSeed} end`,
|
|
25
27
|
})
|
|
26
28
|
.from(eveDispatch)
|
|
27
29
|
.innerJoin(
|
|
@@ -49,7 +51,29 @@ export const getEveMessageDisplayReceipts = async (
|
|
|
49
51
|
}
|
|
50
52
|
const selectedTool = intent.data.selectedTool ?? null;
|
|
51
53
|
return isNonEmptyString(row.deliveryId)
|
|
52
|
-
? [
|
|
54
|
+
? [
|
|
55
|
+
{
|
|
56
|
+
kind: "send",
|
|
57
|
+
deliveryId: row.deliveryId,
|
|
58
|
+
selectedTool,
|
|
59
|
+
...(row.history !== null && row.history !== undefined
|
|
60
|
+
? {
|
|
61
|
+
history: parseEveCopySeed(row.history).messages.map(
|
|
62
|
+
(message) => ({
|
|
63
|
+
role: message.role,
|
|
64
|
+
...(message.role === "assistant"
|
|
65
|
+
? { modelId: message.modelId }
|
|
66
|
+
: {
|
|
67
|
+
selectedTool: eveMessageTool({
|
|
68
|
+
metadata: { custom: message.metadata },
|
|
69
|
+
}),
|
|
70
|
+
}),
|
|
71
|
+
})
|
|
72
|
+
),
|
|
73
|
+
}
|
|
74
|
+
: {}),
|
|
75
|
+
},
|
|
76
|
+
]
|
|
53
77
|
: [];
|
|
54
78
|
});
|
|
55
79
|
};
|
|
@@ -103,6 +127,11 @@ const readEveDispatch = async (input: {
|
|
|
103
127
|
};
|
|
104
128
|
};
|
|
105
129
|
|
|
130
|
+
interface DispatchBinding {
|
|
131
|
+
sessionId: string;
|
|
132
|
+
deliveryId?: string;
|
|
133
|
+
}
|
|
134
|
+
|
|
106
135
|
/** Commits intent before the one allowed dispatch; worker failure leaves it unknown. */
|
|
107
136
|
export const dispatchEveOnce = async (
|
|
108
137
|
input: {
|
|
@@ -112,8 +141,13 @@ export const dispatchEveOnce = async (
|
|
|
112
141
|
readonly kind: "create" | "copy" | "send";
|
|
113
142
|
readonly intent: unknown;
|
|
114
143
|
},
|
|
115
|
-
dispatch: (
|
|
116
|
-
|
|
144
|
+
dispatch: (
|
|
145
|
+
saveReceipt: (
|
|
146
|
+
transaction: Pick<typeof db, "update">,
|
|
147
|
+
binding: DispatchBinding
|
|
148
|
+
) => Promise<void>
|
|
149
|
+
) => Promise<DispatchBinding>
|
|
150
|
+
): Promise<DispatchBinding> => {
|
|
117
151
|
const replay = await readEveDispatch(input);
|
|
118
152
|
if (replay) {
|
|
119
153
|
return replay;
|
|
@@ -204,20 +238,32 @@ export const dispatchEveOnce = async (
|
|
|
204
238
|
}
|
|
205
239
|
throw new EveDispatchUnknownError();
|
|
206
240
|
}
|
|
207
|
-
const
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
241
|
+
const persist = async (
|
|
242
|
+
database: Pick<typeof db, "update">,
|
|
243
|
+
binding: DispatchBinding
|
|
244
|
+
): Promise<void> => {
|
|
245
|
+
if (
|
|
246
|
+
!isNonEmptyString(binding.sessionId) ||
|
|
247
|
+
(input.kind === "send" && !isNonEmptyString(binding.deliveryId))
|
|
248
|
+
) {
|
|
249
|
+
throw new EveDispatchUnknownError();
|
|
250
|
+
}
|
|
251
|
+
const [saved] = await database
|
|
252
|
+
.update(eveDispatch)
|
|
253
|
+
.set(binding)
|
|
254
|
+
.where(and(identity, isNull(eveDispatch.sessionId)))
|
|
255
|
+
.returning();
|
|
256
|
+
if (!hasRow(saved)) {
|
|
257
|
+
throw new EveDispatchUnknownError();
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
let savedInDispatch = false;
|
|
261
|
+
const binding = await dispatch(async (transaction, receipt) => {
|
|
262
|
+
await persist(transaction, receipt);
|
|
263
|
+
savedInDispatch = true;
|
|
264
|
+
});
|
|
265
|
+
if (!savedInDispatch) {
|
|
266
|
+
await persist(db, binding);
|
|
221
267
|
}
|
|
222
268
|
return binding;
|
|
223
269
|
};
|
|
@@ -1,21 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
eveWorkspace,
|
|
3
|
-
eveWorkspaceAttachment,
|
|
4
|
-
eveConversation,
|
|
5
|
-
eveFileReference,
|
|
6
|
-
eveStoredFile,
|
|
7
|
-
} from "./schema";
|
|
1
|
+
import { eveConversation, eveFileReference, eveStoredFile } from "./schema";
|
|
8
2
|
import { eveDeletionScope } from "./eve-deletion-scope";
|
|
9
|
-
import {
|
|
10
|
-
and,
|
|
11
|
-
eq,
|
|
12
|
-
inArray,
|
|
13
|
-
ne,
|
|
14
|
-
notExists,
|
|
15
|
-
notInArray,
|
|
16
|
-
or,
|
|
17
|
-
sql,
|
|
18
|
-
} from "drizzle-orm";
|
|
3
|
+
import { and, eq, inArray, ne, notExists, notInArray, sql } from "drizzle-orm";
|
|
19
4
|
|
|
20
5
|
import { db } from "./client";
|
|
21
6
|
|
|
@@ -57,41 +42,13 @@ const deletingFamilyIds = async (
|
|
|
57
42
|
return family.map((row: Readonly<{ id: string }>) => row.id);
|
|
58
43
|
};
|
|
59
44
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
eveStoredFile.key,
|
|
68
|
-
tx
|
|
69
|
-
.select({ key: eveFileReference.key })
|
|
70
|
-
.from(eveFileReference)
|
|
71
|
-
.where(inArray(eveFileReference.conversationId, ids))
|
|
72
|
-
),
|
|
73
|
-
inArray(
|
|
74
|
-
eveStoredFile.key,
|
|
75
|
-
tx
|
|
76
|
-
.select({ key: eveWorkspaceAttachment.fileKey })
|
|
77
|
-
.from(eveWorkspaceAttachment)
|
|
78
|
-
.innerJoin(
|
|
79
|
-
eveWorkspace,
|
|
80
|
-
eq(eveWorkspace.id, eveWorkspaceAttachment.workspaceId)
|
|
81
|
-
)
|
|
82
|
-
.where(
|
|
83
|
-
and(
|
|
84
|
-
eq(eveWorkspace.state, "deleted"),
|
|
85
|
-
inArray(
|
|
86
|
-
eveWorkspace.id,
|
|
87
|
-
tx
|
|
88
|
-
.select({ id: eveConversation.workspaceId })
|
|
89
|
-
.from(eveConversation)
|
|
90
|
-
.where(inArray(eveConversation.id, ids))
|
|
91
|
-
)
|
|
92
|
-
)
|
|
93
|
-
)
|
|
94
|
-
)
|
|
45
|
+
const purgeCandidate = (tx: FilePurgeReadTransaction, ids: readonly string[]) =>
|
|
46
|
+
inArray(
|
|
47
|
+
eveStoredFile.key,
|
|
48
|
+
tx
|
|
49
|
+
.select({ key: eveFileReference.key })
|
|
50
|
+
.from(eveFileReference)
|
|
51
|
+
.where(inArray(eveFileReference.conversationId, ids))
|
|
95
52
|
);
|
|
96
53
|
|
|
97
54
|
/**
|
|
@@ -118,19 +75,6 @@ const prepareEveFamilyFilePurge = async (
|
|
|
118
75
|
notInArray(eveFileReference.conversationId, ids)
|
|
119
76
|
)
|
|
120
77
|
);
|
|
121
|
-
const workspaceReference = tx
|
|
122
|
-
.select({ key: eveWorkspaceAttachment.fileKey })
|
|
123
|
-
.from(eveWorkspaceAttachment)
|
|
124
|
-
.innerJoin(
|
|
125
|
-
eveWorkspace,
|
|
126
|
-
eq(eveWorkspace.id, eveWorkspaceAttachment.workspaceId)
|
|
127
|
-
)
|
|
128
|
-
.where(
|
|
129
|
-
and(
|
|
130
|
-
eq(eveWorkspaceAttachment.fileKey, eveStoredFile.key),
|
|
131
|
-
ne(eveWorkspace.state, "deleted")
|
|
132
|
-
)
|
|
133
|
-
);
|
|
134
78
|
const files = await tx
|
|
135
79
|
.update(eveStoredFile)
|
|
136
80
|
.set({ state: "deleting" })
|
|
@@ -139,76 +83,13 @@ const prepareEveFamilyFilePurge = async (
|
|
|
139
83
|
eq(eveStoredFile.ownerId, ownerId),
|
|
140
84
|
ne(eveStoredFile.state, "deleted"),
|
|
141
85
|
purgeCandidate(tx, ids),
|
|
142
|
-
notExists(survivingReference)
|
|
143
|
-
notExists(workspaceReference)
|
|
86
|
+
notExists(survivingReference)
|
|
144
87
|
)
|
|
145
88
|
)
|
|
146
89
|
.returning({ key: eveStoredFile.key });
|
|
147
90
|
return files.map((file: Readonly<{ key: string }>) => file.key).toSorted();
|
|
148
91
|
});
|
|
149
92
|
|
|
150
|
-
/** Fence otherwise unreferenced originals after explicit workspace deletion. */
|
|
151
|
-
const prepareEveWorkspaceFilePurge = async (
|
|
152
|
-
ownerId: string,
|
|
153
|
-
workspaceId: string
|
|
154
|
-
): Promise<string[]> =>
|
|
155
|
-
await db.transaction(async (tx) => {
|
|
156
|
-
await tx.execute(
|
|
157
|
-
sql`select pg_advisory_xact_lock(hashtextextended(${`eve-family:${ownerId}`}, 0))`
|
|
158
|
-
);
|
|
159
|
-
const [workspace] = await tx
|
|
160
|
-
.select({ state: eveWorkspace.state })
|
|
161
|
-
.from(eveWorkspace)
|
|
162
|
-
.where(
|
|
163
|
-
and(eq(eveWorkspace.id, workspaceId), eq(eveWorkspace.ownerId, ownerId))
|
|
164
|
-
);
|
|
165
|
-
if (workspace?.state !== "deleted") {
|
|
166
|
-
throw new Error(
|
|
167
|
-
"Workspace resources must be deleted before file cleanup."
|
|
168
|
-
);
|
|
169
|
-
}
|
|
170
|
-
const historyReference = tx
|
|
171
|
-
.select({ key: eveFileReference.key })
|
|
172
|
-
.from(eveFileReference)
|
|
173
|
-
.where(eq(eveFileReference.key, eveStoredFile.key));
|
|
174
|
-
const liveWorkspaceReference = tx
|
|
175
|
-
.select({ key: eveWorkspaceAttachment.fileKey })
|
|
176
|
-
.from(eveWorkspaceAttachment)
|
|
177
|
-
.innerJoin(
|
|
178
|
-
eveWorkspace,
|
|
179
|
-
eq(eveWorkspace.id, eveWorkspaceAttachment.workspaceId)
|
|
180
|
-
)
|
|
181
|
-
.where(
|
|
182
|
-
and(
|
|
183
|
-
eq(eveWorkspaceAttachment.fileKey, eveStoredFile.key),
|
|
184
|
-
ne(eveWorkspace.state, "deleted")
|
|
185
|
-
)
|
|
186
|
-
);
|
|
187
|
-
const catalogKeys = tx
|
|
188
|
-
.select({ key: eveWorkspaceAttachment.fileKey })
|
|
189
|
-
.from(eveWorkspaceAttachment)
|
|
190
|
-
.where(
|
|
191
|
-
and(
|
|
192
|
-
eq(eveWorkspaceAttachment.workspaceId, workspaceId),
|
|
193
|
-
eq(eveWorkspaceAttachment.ownerId, ownerId)
|
|
194
|
-
)
|
|
195
|
-
);
|
|
196
|
-
const files = await tx
|
|
197
|
-
.update(eveStoredFile)
|
|
198
|
-
.set({ state: "deleting" })
|
|
199
|
-
.where(
|
|
200
|
-
and(
|
|
201
|
-
eq(eveStoredFile.ownerId, ownerId),
|
|
202
|
-
ne(eveStoredFile.state, "deleted"),
|
|
203
|
-
inArray(eveStoredFile.key, catalogKeys),
|
|
204
|
-
notExists(historyReference),
|
|
205
|
-
notExists(liveWorkspaceReference)
|
|
206
|
-
)
|
|
207
|
-
)
|
|
208
|
-
.returning({ key: eveStoredFile.key });
|
|
209
|
-
return files.map((file) => file.key).toSorted();
|
|
210
|
-
});
|
|
211
|
-
|
|
212
93
|
/**
|
|
213
94
|
* Call only after the provider confirms removal; no file identity is recycled.
|
|
214
95
|
* @param {string} ownerId Owner used to scope the stored-file state update and family lock.
|
|
@@ -261,19 +142,6 @@ const releaseEveFamilyFileReferences = async (
|
|
|
261
142
|
notInArray(eveFileReference.conversationId, ids)
|
|
262
143
|
)
|
|
263
144
|
);
|
|
264
|
-
const workspaceReference = tx
|
|
265
|
-
.select({ key: eveWorkspaceAttachment.fileKey })
|
|
266
|
-
.from(eveWorkspaceAttachment)
|
|
267
|
-
.innerJoin(
|
|
268
|
-
eveWorkspace,
|
|
269
|
-
eq(eveWorkspace.id, eveWorkspaceAttachment.workspaceId)
|
|
270
|
-
)
|
|
271
|
-
.where(
|
|
272
|
-
and(
|
|
273
|
-
eq(eveWorkspaceAttachment.fileKey, eveStoredFile.key),
|
|
274
|
-
ne(eveWorkspace.state, "deleted")
|
|
275
|
-
)
|
|
276
|
-
);
|
|
277
145
|
const unremovedRows = await tx
|
|
278
146
|
.select({ key: eveStoredFile.key })
|
|
279
147
|
.from(eveStoredFile)
|
|
@@ -282,8 +150,7 @@ const releaseEveFamilyFileReferences = async (
|
|
|
282
150
|
eq(eveStoredFile.ownerId, ownerId),
|
|
283
151
|
ne(eveStoredFile.state, "deleted"),
|
|
284
152
|
purgeCandidate(tx, ids),
|
|
285
|
-
notExists(outsideReference)
|
|
286
|
-
notExists(workspaceReference)
|
|
153
|
+
notExists(outsideReference)
|
|
287
154
|
)
|
|
288
155
|
)
|
|
289
156
|
.limit(EXISTENCE_QUERY_LIMIT);
|
|
@@ -305,7 +172,6 @@ const releaseEveFamilyFileReferences = async (
|
|
|
305
172
|
};
|
|
306
173
|
export {
|
|
307
174
|
completeEveFilePurge,
|
|
308
|
-
prepareEveWorkspaceFilePurge,
|
|
309
175
|
prepareEveFamilyFilePurge,
|
|
310
176
|
releaseEveFamilyFileReferences,
|
|
311
177
|
};
|
|
@@ -281,18 +281,18 @@ const reserveEveGeneratedFile = async (
|
|
|
281
281
|
};
|
|
282
282
|
|
|
283
283
|
/**
|
|
284
|
-
*
|
|
285
|
-
* @param {string} ownerId - Owner whose family lock protects
|
|
284
|
+
* Serialize file access with conversation deletion after validating the active conversation reference.
|
|
285
|
+
* @param {string} ownerId - Owner whose family lock protects file access.
|
|
286
286
|
* @param {string} conversationId - Bound conversation whose file reference is rechecked.
|
|
287
|
-
* @param {string} key - Active
|
|
288
|
-
* @param {() => Promise<Result>}
|
|
287
|
+
* @param {string} key - Active conversation file reference to validate.
|
|
288
|
+
* @param {() => Promise<Result>} access - Storage operation admitted while the deletion fence is locked.
|
|
289
289
|
* @returns {Promise<Result>} The storage operation result after the transaction completes.
|
|
290
290
|
*/
|
|
291
|
-
const
|
|
291
|
+
const withEveConversationFile = async <Result>(
|
|
292
292
|
ownerId: string,
|
|
293
293
|
conversationId: string,
|
|
294
294
|
key: string,
|
|
295
|
-
|
|
295
|
+
access: () => Promise<Result>
|
|
296
296
|
): Promise<Result> =>
|
|
297
297
|
await db.transaction(async (tx: FileLockTransaction) => {
|
|
298
298
|
await tx.execute(
|
|
@@ -312,14 +312,16 @@ const writeEveGeneratedFile = async <Result>(
|
|
|
312
312
|
eq(eveStoredFile.state, "active"),
|
|
313
313
|
eq(eveFileReference.conversationId, conversationId),
|
|
314
314
|
eq(eveFileReference.ownerId, ownerId),
|
|
315
|
+
eq(eveStoredFile.ownerId, ownerId),
|
|
316
|
+
eq(eveConversation.ownerId, ownerId),
|
|
315
317
|
eq(eveConversation.state, "bound")
|
|
316
318
|
)
|
|
317
319
|
);
|
|
318
320
|
const reference = referenceRows.at(FIRST_ROW_INDEX);
|
|
319
321
|
if (!reference) {
|
|
320
|
-
throw new Error("
|
|
322
|
+
throw new Error("File is unavailable in this conversation.");
|
|
321
323
|
}
|
|
322
|
-
return await
|
|
324
|
+
return await access();
|
|
323
325
|
});
|
|
324
326
|
|
|
325
327
|
export {
|
|
@@ -330,6 +332,6 @@ export {
|
|
|
330
332
|
registerEveStoredFile,
|
|
331
333
|
reserveEveGeneratedFile,
|
|
332
334
|
reserveEveUpload,
|
|
333
|
-
|
|
335
|
+
withEveConversationFile,
|
|
334
336
|
writeEveUpload,
|
|
335
337
|
};
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
eveWorkspaceAttachment,
|
|
4
|
-
eveFileReference,
|
|
5
|
-
eveStoredFile,
|
|
6
|
-
} from "./schema";
|
|
7
|
-
import { and, eq, inArray, lt, notExists, ne } from "drizzle-orm";
|
|
1
|
+
import { eveFileReference, eveStoredFile } from "./schema";
|
|
2
|
+
import { and, eq, inArray, lt, notExists } from "drizzle-orm";
|
|
8
3
|
|
|
9
4
|
import { db } from "./client";
|
|
10
5
|
import { lockEveFamilies } from "./eve-family-lock";
|
|
@@ -49,19 +44,6 @@ export const prepareEveOrphanedFilePurge = async (
|
|
|
49
44
|
.select({ key: eveFileReference.key })
|
|
50
45
|
.from(eveFileReference)
|
|
51
46
|
.where(eq(eveFileReference.key, eveStoredFile.key));
|
|
52
|
-
const workspaceReferences = tx
|
|
53
|
-
.select({ key: eveWorkspaceAttachment.fileKey })
|
|
54
|
-
.from(eveWorkspaceAttachment)
|
|
55
|
-
.innerJoin(
|
|
56
|
-
eveWorkspace,
|
|
57
|
-
eq(eveWorkspace.id, eveWorkspaceAttachment.workspaceId)
|
|
58
|
-
)
|
|
59
|
-
.where(
|
|
60
|
-
and(
|
|
61
|
-
eq(eveWorkspaceAttachment.fileKey, eveStoredFile.key),
|
|
62
|
-
ne(eveWorkspace.state, "deleted")
|
|
63
|
-
)
|
|
64
|
-
);
|
|
65
47
|
// Include tombstones: a provider can finish an uncertain write after an
|
|
66
48
|
// earlier deletion. A later inventory pass must remove that object again.
|
|
67
49
|
return await tx
|
|
@@ -72,8 +54,7 @@ export const prepareEveOrphanedFilePurge = async (
|
|
|
72
54
|
inArray(eveStoredFile.ownerId, owners),
|
|
73
55
|
inArray(eveStoredFile.key, keys),
|
|
74
56
|
lt(eveStoredFile.createdAt, cutoff),
|
|
75
|
-
notExists(references)
|
|
76
|
-
notExists(workspaceReferences)
|
|
57
|
+
notExists(references)
|
|
77
58
|
)
|
|
78
59
|
)
|
|
79
60
|
.returning({
|
|
@@ -7,7 +7,7 @@ import { chat } from "@/integrations/chat/server";
|
|
|
7
7
|
import { reserveConversationWorkspace } from "./eve-workspaces";
|
|
8
8
|
import { eveDeletionScope } from "./eve-deletion-scope";
|
|
9
9
|
import { markEveCreationFailure } from "./eve-creation-failure";
|
|
10
|
-
import { dispatchEveOnce } from "./eve-dispatch";
|
|
10
|
+
import { dispatchEveOnce, EveDispatchUnknownError } from "./eve-dispatch";
|
|
11
11
|
import {
|
|
12
12
|
and,
|
|
13
13
|
desc,
|
|
@@ -750,7 +750,7 @@ const bindConversationSession = async (
|
|
|
750
750
|
}
|
|
751
751
|
const [bound] = await tx
|
|
752
752
|
.update(eveConversation)
|
|
753
|
-
.set({ initialRequest: null,
|
|
753
|
+
.set({ initialRequest: null, sessionId, state: "bound" })
|
|
754
754
|
.where(
|
|
755
755
|
and(
|
|
756
756
|
eq(eveConversation.id, reservationId),
|
|
@@ -800,12 +800,11 @@ const assertMatchingMessageCreation = (
|
|
|
800
800
|
initialModelId: string | undefined,
|
|
801
801
|
initialContentHash: string | undefined,
|
|
802
802
|
fork: ReadonlyNativeSurface<EveForkInput> | undefined,
|
|
803
|
-
forkKind: typeof eveConversation.$inferInsert.forkKind
|
|
804
|
-
seedOnly: boolean
|
|
803
|
+
forkKind: typeof eveConversation.$inferInsert.forkKind
|
|
805
804
|
): ConversationRow => {
|
|
806
805
|
if (
|
|
807
806
|
existing === undefined ||
|
|
808
|
-
existing.creationKind !==
|
|
807
|
+
existing.creationKind !== "message" ||
|
|
809
808
|
existing.firstMessage !== message ||
|
|
810
809
|
existing.initialModelId !== (initialModelId ?? null) ||
|
|
811
810
|
existing.initialContentHash !== (initialContentHash ?? null) ||
|
|
@@ -847,7 +846,6 @@ const createEveConversation = async (
|
|
|
847
846
|
fork,
|
|
848
847
|
forkKind,
|
|
849
848
|
fileKeys = [],
|
|
850
|
-
seedOnly = false,
|
|
851
849
|
}: ReadonlyNativeSurface<{
|
|
852
850
|
initialRequest?: unknown;
|
|
853
851
|
initialModelId?: string;
|
|
@@ -856,10 +854,9 @@ const createEveConversation = async (
|
|
|
856
854
|
fork?: EveForkInput;
|
|
857
855
|
forkKind?: typeof eveConversation.$inferInsert.forkKind;
|
|
858
856
|
fileKeys?: string[];
|
|
859
|
-
seedOnly?: boolean;
|
|
860
857
|
}> = {}
|
|
861
858
|
): Promise<BoundConversation> => {
|
|
862
|
-
if (
|
|
859
|
+
if (forkKind && !fork) {
|
|
863
860
|
throw new CreationConflictError(
|
|
864
861
|
"Fork intent requires a source conversation."
|
|
865
862
|
);
|
|
@@ -867,7 +864,7 @@ const createEveConversation = async (
|
|
|
867
864
|
let [reservation] = await reserveEveConversation(
|
|
868
865
|
{
|
|
869
866
|
firstMessage: message,
|
|
870
|
-
creationKind:
|
|
867
|
+
creationKind: "message",
|
|
871
868
|
forkKind,
|
|
872
869
|
initialContentHash,
|
|
873
870
|
initialModelId,
|
|
@@ -897,11 +894,25 @@ const createEveConversation = async (
|
|
|
897
894
|
initialModelId,
|
|
898
895
|
initialContentHash,
|
|
899
896
|
fork,
|
|
900
|
-
forkKind
|
|
901
|
-
seedOnly
|
|
897
|
+
forkKind
|
|
902
898
|
);
|
|
903
899
|
const binding = boundConversation(matching);
|
|
904
900
|
if (binding) {
|
|
901
|
+
const [receipt] = await db
|
|
902
|
+
.select({ sessionId: eveDispatch.sessionId })
|
|
903
|
+
.from(eveDispatch)
|
|
904
|
+
.where(
|
|
905
|
+
and(
|
|
906
|
+
eq(eveDispatch.ownerId, ownerId),
|
|
907
|
+
eq(eveDispatch.operationId, matching.id),
|
|
908
|
+
eq(eveDispatch.conversationId, matching.id),
|
|
909
|
+
eq(eveDispatch.sessionId, binding.sessionId),
|
|
910
|
+
eq(eveDispatch.kind, "create")
|
|
911
|
+
)
|
|
912
|
+
);
|
|
913
|
+
if (!hasQueryRow(receipt)) {
|
|
914
|
+
throw new EveDispatchUnknownError();
|
|
915
|
+
}
|
|
905
916
|
return binding;
|
|
906
917
|
}
|
|
907
918
|
reservation = matching;
|
|
@@ -918,7 +929,7 @@ const createEveConversation = async (
|
|
|
918
929
|
ownerId,
|
|
919
930
|
operationId: reservation.id,
|
|
920
931
|
conversationId: reservation.id,
|
|
921
|
-
kind:
|
|
932
|
+
kind: "create",
|
|
922
933
|
intent: reservation.initialRequest ?? {
|
|
923
934
|
message,
|
|
924
935
|
initialModelId,
|
|
@@ -927,7 +938,7 @@ const createEveConversation = async (
|
|
|
927
938
|
forkKind,
|
|
928
939
|
},
|
|
929
940
|
},
|
|
930
|
-
async () =>
|
|
941
|
+
async (saveReceipt) =>
|
|
931
942
|
await db.transaction(async (tx: CreationTransactionView) => {
|
|
932
943
|
// The reservation is already committed so native hooks can find it.
|
|
933
944
|
// Transaction locks release on worker death; creating rows need no manual repair.
|
|
@@ -949,12 +960,12 @@ const createEveConversation = async (
|
|
|
949
960
|
.where(eq(eveConversation.id, reservation.id));
|
|
950
961
|
const binding = boundConversation(current);
|
|
951
962
|
if (binding) {
|
|
952
|
-
|
|
963
|
+
throw new EveDispatchUnknownError();
|
|
953
964
|
}
|
|
954
965
|
if (
|
|
955
966
|
!(
|
|
956
967
|
hasQueryRow(current) &&
|
|
957
|
-
current.creationKind ===
|
|
968
|
+
current.creationKind === "message" &&
|
|
958
969
|
(current.state === "creating" || current.state === "uncertain")
|
|
959
970
|
)
|
|
960
971
|
) {
|
|
@@ -969,7 +980,12 @@ const createEveConversation = async (
|
|
|
969
980
|
reservation.id,
|
|
970
981
|
accepted.sessionId
|
|
971
982
|
);
|
|
972
|
-
|
|
983
|
+
const receipt = {
|
|
984
|
+
sessionId: bound.sessionId,
|
|
985
|
+
deliveryId: accepted.deliveryId,
|
|
986
|
+
};
|
|
987
|
+
await saveReceipt(tx, receipt);
|
|
988
|
+
return receipt;
|
|
973
989
|
})
|
|
974
990
|
);
|
|
975
991
|
return { id: reservation.id, sessionId: dispatched.sessionId };
|