chat-js 1.0.0-alpha.2 → 1.0.0-alpha.3
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 +4 -4
- package/dist/index.js +2625 -2666
- package/package.json +8 -3
- 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,143 +0,0 @@
|
|
|
1
|
-
import type { ToolProgressWriter } from "@/lib/ai/tool-context";
|
|
2
|
-
import { tavily } from "@tavily/core";
|
|
3
|
-
import { defineTool } from "eve/tools";
|
|
4
|
-
import { readToolEnvironment } from "./tavily-search-env";
|
|
5
|
-
import { createModuleLogger } from "@/lib/logger";
|
|
6
|
-
import { executeWithResearchProgress } from "@/lib/eve/research-progress";
|
|
7
|
-
import {
|
|
8
|
-
DEFAULT_MAX_RESULTS,
|
|
9
|
-
executeMultiQuerySearch,
|
|
10
|
-
} from "@/tools/platform/search-presentation";
|
|
11
|
-
import { toolResultToModelOutput } from "@/lib/eve/tool-model-output";
|
|
12
|
-
import { webSearchInput, webSearchResult } from "./schemas";
|
|
13
|
-
import type { z } from "zod";
|
|
14
|
-
|
|
15
|
-
const TAVILY_COST_CENTS = 5;
|
|
16
|
-
const CENTS_PER_USD = 100;
|
|
17
|
-
type SearchInput = z.infer<typeof webSearchInput>;
|
|
18
|
-
type ReadonlySearchInput = Readonly<{
|
|
19
|
-
search_queries: readonly Readonly<SearchInput["search_queries"][number]>[];
|
|
20
|
-
exclude_domains: Readonly<SearchInput["exclude_domains"]>;
|
|
21
|
-
searchDepth: SearchInput["searchDepth"];
|
|
22
|
-
topics: Readonly<SearchInput["topics"]>;
|
|
23
|
-
}>;
|
|
24
|
-
type ExecutionContext = Readonly<{
|
|
25
|
-
abortSignal: Readonly<AbortSignal>;
|
|
26
|
-
callId: string;
|
|
27
|
-
}>;
|
|
28
|
-
type ResearchExecution = Readonly<{
|
|
29
|
-
abortSignal: Readonly<AbortSignal>;
|
|
30
|
-
dataStream: Readonly<ToolProgressWriter>;
|
|
31
|
-
usage: Readonly<{ addCostUsd: (cost: number) => void }>;
|
|
32
|
-
}>;
|
|
33
|
-
|
|
34
|
-
const FIRST_TOPIC_INDEX = 0;
|
|
35
|
-
const NEWS_LOOKBACK_DAYS = 7;
|
|
36
|
-
const createTavilySearch =
|
|
37
|
-
(
|
|
38
|
-
options: Readonly<{
|
|
39
|
-
topics: Readonly<NonNullable<SearchInput["topics"]>>;
|
|
40
|
-
excludeDomains: readonly string[];
|
|
41
|
-
searchDepth: NonNullable<SearchInput["searchDepth"]>;
|
|
42
|
-
}>
|
|
43
|
-
): ((
|
|
44
|
-
query: Readonly<{ query: string; maxResults: number }>,
|
|
45
|
-
index: number
|
|
46
|
-
) => Promise<{ content: string; title: string; url: string }[]>) =>
|
|
47
|
-
async ({ query, maxResults }, index) => {
|
|
48
|
-
const env = readToolEnvironment();
|
|
49
|
-
if (
|
|
50
|
-
!(typeof env.TAVILY_API_KEY === "string" && env.TAVILY_API_KEY !== "")
|
|
51
|
-
) {
|
|
52
|
-
throw new Error("Set TAVILY_API_KEY to enable Tavily search.");
|
|
53
|
-
}
|
|
54
|
-
const topic =
|
|
55
|
-
options.topics[index] ?? options.topics[FIRST_TOPIC_INDEX] ?? "general";
|
|
56
|
-
const response = await tavily({ apiKey: env.TAVILY_API_KEY }).search(
|
|
57
|
-
query,
|
|
58
|
-
{
|
|
59
|
-
days: topic === "news" ? NEWS_LOOKBACK_DAYS : undefined,
|
|
60
|
-
excludeDomains: [...options.excludeDomains],
|
|
61
|
-
includeAnswer: true,
|
|
62
|
-
maxResults,
|
|
63
|
-
searchDepth: options.searchDepth,
|
|
64
|
-
topic,
|
|
65
|
-
}
|
|
66
|
-
);
|
|
67
|
-
return response.results.map(
|
|
68
|
-
({
|
|
69
|
-
title,
|
|
70
|
-
url,
|
|
71
|
-
content,
|
|
72
|
-
}: Readonly<{ title: string; url: string; content: string }>) => ({
|
|
73
|
-
content,
|
|
74
|
-
title,
|
|
75
|
-
url,
|
|
76
|
-
})
|
|
77
|
-
);
|
|
78
|
-
};
|
|
79
|
-
export const webSearch = defineTool({
|
|
80
|
-
description: `Multi-query web search (supports depth, topic & result limits). Always cite sources inline.
|
|
81
|
-
|
|
82
|
-
Use for:
|
|
83
|
-
- General information gathering via web search
|
|
84
|
-
|
|
85
|
-
Avoid:
|
|
86
|
-
- Pulling content from a single known URL (use retrieveUrl instead)`,
|
|
87
|
-
execute: (
|
|
88
|
-
{
|
|
89
|
-
search_queries,
|
|
90
|
-
topics,
|
|
91
|
-
searchDepth,
|
|
92
|
-
exclude_domains,
|
|
93
|
-
}: ReadonlySearchInput,
|
|
94
|
-
context: ExecutionContext
|
|
95
|
-
) =>
|
|
96
|
-
executeWithResearchProgress(
|
|
97
|
-
context,
|
|
98
|
-
async ({ dataStream, usage, abortSignal }: ResearchExecution) => {
|
|
99
|
-
const toolCallId = context.callId;
|
|
100
|
-
abortSignal.throwIfAborted();
|
|
101
|
-
const log = createModuleLogger("tools/web-search");
|
|
102
|
-
log.debug(
|
|
103
|
-
{
|
|
104
|
-
exclude_domains,
|
|
105
|
-
queriesCount: search_queries.length,
|
|
106
|
-
searchDepth,
|
|
107
|
-
topics,
|
|
108
|
-
},
|
|
109
|
-
"webSearch.execute"
|
|
110
|
-
);
|
|
111
|
-
// Handle nullable arrays with defaults
|
|
112
|
-
const safeTopics: Readonly<NonNullable<SearchInput["topics"]>> =
|
|
113
|
-
topics ?? ["general"];
|
|
114
|
-
const safeSearchDepth = searchDepth ?? "basic";
|
|
115
|
-
const safeExcludeDomains = exclude_domains ?? [];
|
|
116
|
-
const result = await executeMultiQuerySearch({
|
|
117
|
-
completeTitle: "Search complete",
|
|
118
|
-
dataStream,
|
|
119
|
-
search: createTavilySearch({
|
|
120
|
-
excludeDomains: safeExcludeDomains,
|
|
121
|
-
searchDepth: safeSearchDepth,
|
|
122
|
-
topics: safeTopics,
|
|
123
|
-
}),
|
|
124
|
-
search_queries: search_queries.map((query) => ({
|
|
125
|
-
maxResults: query.maxResults ?? DEFAULT_MAX_RESULTS,
|
|
126
|
-
query: query.query,
|
|
127
|
-
})),
|
|
128
|
-
title: "Searching",
|
|
129
|
-
toolCallId,
|
|
130
|
-
writeTopLevelUpdates: true,
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
// Report API cost
|
|
134
|
-
usage.addCostUsd(TAVILY_COST_CENTS / CENTS_PER_USD);
|
|
135
|
-
|
|
136
|
-
return result;
|
|
137
|
-
},
|
|
138
|
-
webSearchResult
|
|
139
|
-
),
|
|
140
|
-
// Keep defaultable fields required and nullable for strict tool calling.
|
|
141
|
-
inputSchema: webSearchInput,
|
|
142
|
-
toModelOutput: toolResultToModelOutput,
|
|
143
|
-
});
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { DocumentAssistantAction } from "@/chatjs/core/documents/contracts";
|
|
2
|
-
import { config } from "@/lib/config";
|
|
3
|
-
|
|
4
|
-
const documentAssistantActions = (): DocumentAssistantAction[] => [
|
|
5
|
-
{
|
|
6
|
-
instruction:
|
|
7
|
-
"Add final polish, check grammar, add section titles for structure, and ensure the document reads smoothly.",
|
|
8
|
-
label: "Add final polish",
|
|
9
|
-
modelId: config.ai.tools.text.polish,
|
|
10
|
-
},
|
|
11
|
-
];
|
|
12
|
-
export { documentAssistantActions };
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"config": { "key": "text" },
|
|
3
|
-
"documentKind": "text",
|
|
4
|
-
"envRequirements": [],
|
|
5
|
-
"id": "text-documents",
|
|
6
|
-
"kind": "tool",
|
|
7
|
-
"requiresTools": ["readDocument"],
|
|
8
|
-
"tools": [
|
|
9
|
-
{
|
|
10
|
-
"composer": { "icon": "Edit3", "name": "Canvas", "shortName": "Canvas" },
|
|
11
|
-
"toolExport": "createTextDocument"
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
"composer": { "icon": "Edit3", "name": "Canvas", "shortName": "Canvas" },
|
|
15
|
-
"toolExport": "editTextDocument"
|
|
16
|
-
}
|
|
17
|
-
],
|
|
18
|
-
"contractVersion": 2,
|
|
19
|
-
"uiBase": "base"
|
|
20
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { Button } from "@/components/ui/button";
|
|
3
|
-
import { DocumentSkeleton } from "@/components/document-skeleton";
|
|
4
|
-
import React from "react";
|
|
5
|
-
import dynamic from "next/dynamic";
|
|
6
|
-
import { useQuery } from "@tanstack/react-query";
|
|
7
|
-
import { useTRPC } from "@/trpc/react";
|
|
8
|
-
|
|
9
|
-
const DiffView = dynamic(
|
|
10
|
-
async () => {
|
|
11
|
-
const { DiffView: Comparison } = await import("./diffview");
|
|
12
|
-
return Comparison;
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
loading: () => <DocumentSkeleton artifactKind="text" />,
|
|
16
|
-
ssr: false,
|
|
17
|
-
}
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
export const EveDocumentComparison = ({
|
|
21
|
-
conversationId,
|
|
22
|
-
documentId,
|
|
23
|
-
previousRevisionId,
|
|
24
|
-
content,
|
|
25
|
-
version,
|
|
26
|
-
}: {
|
|
27
|
-
readonly conversationId: string;
|
|
28
|
-
readonly documentId: string;
|
|
29
|
-
readonly previousRevisionId: string;
|
|
30
|
-
readonly content: string;
|
|
31
|
-
readonly version: number;
|
|
32
|
-
}): React.JSX.Element => {
|
|
33
|
-
const trpc = useTRPC();
|
|
34
|
-
const previous = useQuery(
|
|
35
|
-
trpc.eve.document.queryOptions({
|
|
36
|
-
conversationId,
|
|
37
|
-
documentId,
|
|
38
|
-
revisionId: previousRevisionId,
|
|
39
|
-
})
|
|
40
|
-
);
|
|
41
|
-
return (
|
|
42
|
-
<section
|
|
43
|
-
aria-label="Document changes"
|
|
44
|
-
className="mx-auto max-w-3xl space-y-4 px-4 py-8"
|
|
45
|
-
>
|
|
46
|
-
<p className="text-muted-foreground text-sm">
|
|
47
|
-
Changes from version {version - 1} to {version}
|
|
48
|
-
</p>
|
|
49
|
-
{previous.isPending && <DocumentSkeleton artifactKind="text" />}
|
|
50
|
-
{previous.isError && (
|
|
51
|
-
<div className="space-y-2" role="alert">
|
|
52
|
-
<p>The previous version could not be loaded.</p>
|
|
53
|
-
{}
|
|
54
|
-
<Button
|
|
55
|
-
onClick={(): void => {
|
|
56
|
-
void previous.refetch();
|
|
57
|
-
}}
|
|
58
|
-
variant="outline"
|
|
59
|
-
>
|
|
60
|
-
Retry comparison
|
|
61
|
-
</Button>
|
|
62
|
-
</div>
|
|
63
|
-
)}
|
|
64
|
-
{previous.data && !previous.isError && (
|
|
65
|
-
<DiffView
|
|
66
|
-
newContent={content}
|
|
67
|
-
oldContent={previous.data.revision.content}
|
|
68
|
-
/>
|
|
69
|
-
)}
|
|
70
|
-
</section>
|
|
71
|
-
);
|
|
72
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import type { DocumentDefinition } from "@/chatjs/core/documents/document-definition";
|
|
3
|
-
|
|
4
|
-
export const documentDefinition = {
|
|
5
|
-
kind: "text",
|
|
6
|
-
contentSchema: z.string().max(2_000_000),
|
|
7
|
-
createTool: "createTextDocument",
|
|
8
|
-
editTool: "editTextDocument",
|
|
9
|
-
} as const satisfies DocumentDefinition;
|
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
import { $createParagraphNode, $getRoot, TextNode } from "lexical";
|
|
2
|
-
import type { EditorConfig, LexicalEditor, SerializedTextNode } from "lexical";
|
|
3
|
-
import React, { useEffect } from "react";
|
|
4
|
-
import type { ChangeObject } from "diff";
|
|
5
|
-
import { ContentEditable } from "@lexical/react/LexicalContentEditable";
|
|
6
|
-
import { LexicalComposer } from "@lexical/react/LexicalComposer";
|
|
7
|
-
import { LexicalErrorBoundary } from "@lexical/react/LexicalErrorBoundary";
|
|
8
|
-
import type { ReadonlyNativeSurface } from "@/lib/readonly-native-surface";
|
|
9
|
-
import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin";
|
|
10
|
-
import { createEditorConfig } from "./editor-config";
|
|
11
|
-
import { diffWords } from "diff";
|
|
12
|
-
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
13
|
-
|
|
14
|
-
const DiffType = {
|
|
15
|
-
Deleted: -1,
|
|
16
|
-
Inserted: 1,
|
|
17
|
-
Unchanged: 0,
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
// Define diff types
|
|
21
|
-
type DiffTypeValue = (typeof DiffType)[keyof typeof DiffType];
|
|
22
|
-
type SerializedDiffTextNode = SerializedTextNode & {
|
|
23
|
-
diffType?: DiffTypeValue;
|
|
24
|
-
type: "diff-text";
|
|
25
|
-
version: 1;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
// Custom diff text node that supports styling
|
|
29
|
-
class DiffTextNode extends TextNode {
|
|
30
|
-
public __diffType?: DiffTypeValue;
|
|
31
|
-
|
|
32
|
-
public static getType(): string {
|
|
33
|
-
return "diff-text";
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
public static clone(
|
|
37
|
-
node: Readonly<Pick<DiffTextNode, "__text" | "__key" | "__diffType">>
|
|
38
|
-
): DiffTextNode {
|
|
39
|
-
const newNode = new DiffTextNode(node.__text, node.__key);
|
|
40
|
-
newNode.__diffType = node.__diffType;
|
|
41
|
-
return newNode;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
public static importJSON(
|
|
45
|
-
serializedNode: ReadonlyNativeSurface<SerializedDiffTextNode>
|
|
46
|
-
): DiffTextNode {
|
|
47
|
-
const { text, diffType } = serializedNode;
|
|
48
|
-
const node = new DiffTextNode(text);
|
|
49
|
-
if (diffType !== undefined) {
|
|
50
|
-
node.setDiffType(diffType);
|
|
51
|
-
}
|
|
52
|
-
return node;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
public exportJSON(): SerializedDiffTextNode {
|
|
56
|
-
return {
|
|
57
|
-
...super.exportJSON(),
|
|
58
|
-
diffType: this.__diffType,
|
|
59
|
-
type: "diff-text",
|
|
60
|
-
version: 1,
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
public setDiffType(diffType: DiffTypeValue): void {
|
|
65
|
-
const writable = this.getWritable();
|
|
66
|
-
writable.__diffType = diffType;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
public getDiffType(): DiffTypeValue | undefined {
|
|
70
|
-
return this.__diffType;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
public createDOM(config: EditorConfig, editor?: LexicalEditor): HTMLElement {
|
|
74
|
-
const element = super.createDOM(config, editor);
|
|
75
|
-
const diffType = this.getDiffType();
|
|
76
|
-
|
|
77
|
-
if (
|
|
78
|
-
diffType !== null &&
|
|
79
|
-
diffType !== undefined &&
|
|
80
|
-
diffType !== 0 &&
|
|
81
|
-
!Number.isNaN(diffType)
|
|
82
|
-
) {
|
|
83
|
-
let className = "";
|
|
84
|
-
switch (diffType) {
|
|
85
|
-
case DiffType.Inserted: {
|
|
86
|
-
className =
|
|
87
|
-
"bg-green-100 text-green-700 dark:bg-green-500/70 dark:text-green-300";
|
|
88
|
-
break;
|
|
89
|
-
}
|
|
90
|
-
case DiffType.Deleted: {
|
|
91
|
-
className =
|
|
92
|
-
"bg-red-100 line-through text-red-600 dark:bg-red-500/70 dark:text-red-300";
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
|
-
default: {
|
|
96
|
-
className = "";
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
element.className = className;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return element;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
public updateDOM(
|
|
106
|
-
prevNode: this,
|
|
107
|
-
dom: HTMLElement,
|
|
108
|
-
config: EditorConfig
|
|
109
|
-
): boolean {
|
|
110
|
-
const prevDiffType = prevNode.getDiffType();
|
|
111
|
-
const currentDiffType = this.getDiffType();
|
|
112
|
-
|
|
113
|
-
if (prevDiffType !== currentDiffType) {
|
|
114
|
-
// Update classes if diff type changed
|
|
115
|
-
// Recreate the span when its diff styling changes.
|
|
116
|
-
return true;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return super.updateDOM(prevNode, dom, config);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// Proper diff computation using the diff library
|
|
124
|
-
const computeProperDiff = (
|
|
125
|
-
oldText: string,
|
|
126
|
-
newText: string
|
|
127
|
-
): { text: string; type: number }[] => {
|
|
128
|
-
const changes = diffWords(oldText, newText);
|
|
129
|
-
|
|
130
|
-
return changes.map((change: Readonly<ChangeObject<string>>) => {
|
|
131
|
-
let type: DiffTypeValue;
|
|
132
|
-
if (change.added) {
|
|
133
|
-
type = DiffType.Inserted;
|
|
134
|
-
} else if (change.removed) {
|
|
135
|
-
type = DiffType.Deleted;
|
|
136
|
-
} else {
|
|
137
|
-
type = DiffType.Unchanged;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
return {
|
|
141
|
-
text: change.value,
|
|
142
|
-
type,
|
|
143
|
-
};
|
|
144
|
-
});
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
const DiffContentPlugin = ({
|
|
148
|
-
oldContent,
|
|
149
|
-
newContent,
|
|
150
|
-
}: ReadonlyNativeSurface<{
|
|
151
|
-
oldContent: string;
|
|
152
|
-
newContent: string;
|
|
153
|
-
}>): null => {
|
|
154
|
-
const [editor] = useLexicalComposerContext();
|
|
155
|
-
|
|
156
|
-
useEffect((): void => {
|
|
157
|
-
editor.update((): void => {
|
|
158
|
-
const root = $getRoot();
|
|
159
|
-
|
|
160
|
-
// Clear existing content
|
|
161
|
-
const children = root.getChildren();
|
|
162
|
-
for (const child of children) {
|
|
163
|
-
child.remove();
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
// Compute proper diff using LCS algorithm
|
|
167
|
-
const diffResult = computeProperDiff(oldContent, newContent);
|
|
168
|
-
|
|
169
|
-
// Create a single paragraph with all diff nodes
|
|
170
|
-
const paragraphNode = $createParagraphNode();
|
|
171
|
-
|
|
172
|
-
for (const { text, type } of diffResult) {
|
|
173
|
-
const textNode = new DiffTextNode(text);
|
|
174
|
-
textNode.setDiffType(type);
|
|
175
|
-
paragraphNode.append(textNode);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
root.append(paragraphNode);
|
|
179
|
-
});
|
|
180
|
-
}, [oldContent, newContent, editor]);
|
|
181
|
-
|
|
182
|
-
return null;
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
interface DiffEditorProps {
|
|
186
|
-
newContent: string;
|
|
187
|
-
oldContent: string;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
export const DiffView = ({
|
|
191
|
-
oldContent,
|
|
192
|
-
newContent,
|
|
193
|
-
}: ReadonlyNativeSurface<DiffEditorProps>): React.JSX.Element => {
|
|
194
|
-
const initialConfig = {
|
|
195
|
-
...createEditorConfig(),
|
|
196
|
-
editable: false,
|
|
197
|
-
nodes: [DiffTextNode],
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
return (
|
|
201
|
-
<div className="prose dark:prose-invert relative w-full text-left">
|
|
202
|
-
<LexicalComposer initialConfig={initialConfig}>
|
|
203
|
-
<RichTextPlugin
|
|
204
|
-
contentEditable={
|
|
205
|
-
<ContentEditable className="lexical-editor text-left outline-hidden" />
|
|
206
|
-
}
|
|
207
|
-
ErrorBoundary={LexicalErrorBoundary}
|
|
208
|
-
placeholder={null}
|
|
209
|
-
/>
|
|
210
|
-
<DiffContentPlugin newContent={newContent} oldContent={oldContent} />
|
|
211
|
-
</LexicalComposer>
|
|
212
|
-
</div>
|
|
213
|
-
);
|
|
214
|
-
};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import type { DocumentBodyProps, DocumentUi } from "@/chatjs/core/documents/ui";
|
|
3
|
-
import { documentDefinition } from "./definition";
|
|
4
|
-
import { documentAssistantActions } from "./assistant-actions";
|
|
5
|
-
import React from "react";
|
|
6
|
-
import type { ReadonlyNativeSurface } from "@/lib/readonly-native-surface";
|
|
7
|
-
import { ScrollArea } from "@/components/ui/scroll-area";
|
|
8
|
-
import { EveDocumentComparison } from "./comparison";
|
|
9
|
-
import dynamic from "next/dynamic";
|
|
10
|
-
|
|
11
|
-
const Editor = dynamic(
|
|
12
|
-
async () => {
|
|
13
|
-
const { Editor: TextEditor } = await import("./editor");
|
|
14
|
-
return TextEditor;
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
ssr: false,
|
|
18
|
-
}
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
export const documentUi: DocumentUi = {
|
|
22
|
-
supportsComparison: true,
|
|
23
|
-
definition: documentDefinition,
|
|
24
|
-
assistantActions: documentAssistantActions,
|
|
25
|
-
Body: ({
|
|
26
|
-
inline,
|
|
27
|
-
editorProps,
|
|
28
|
-
comparison,
|
|
29
|
-
}: ReadonlyNativeSurface<DocumentBodyProps>) => (
|
|
30
|
-
<ScrollArea className="min-h-0 flex-1">
|
|
31
|
-
{comparison ? (
|
|
32
|
-
<EveDocumentComparison {...comparison} />
|
|
33
|
-
) : (
|
|
34
|
-
<div
|
|
35
|
-
className={
|
|
36
|
-
inline === true
|
|
37
|
-
? "p-4 sm:px-14 sm:py-16"
|
|
38
|
-
: "mx-auto max-w-3xl px-4 py-8"
|
|
39
|
-
}
|
|
40
|
-
>
|
|
41
|
-
<Editor {...editorProps} />
|
|
42
|
-
</div>
|
|
43
|
-
)}
|
|
44
|
-
</ScrollArea>
|
|
45
|
-
),
|
|
46
|
-
};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { $convertToMarkdownString, TRANSFORMERS } from "@lexical/markdown";
|
|
2
|
-
import { CodeHighlightNode, CodeNode } from "@lexical/code";
|
|
3
|
-
import type { EditorState, LexicalEditor } from "lexical";
|
|
4
|
-
import { HeadingNode, QuoteNode } from "@lexical/rich-text";
|
|
5
|
-
import { ListItemNode, ListNode } from "@lexical/list";
|
|
6
|
-
import { LinkNode } from "@lexical/link";
|
|
7
|
-
|
|
8
|
-
const DOCUMENT_NODE_CLASSES = [
|
|
9
|
-
HeadingNode,
|
|
10
|
-
ListNode,
|
|
11
|
-
ListItemNode,
|
|
12
|
-
QuoteNode,
|
|
13
|
-
CodeNode,
|
|
14
|
-
CodeHighlightNode,
|
|
15
|
-
LinkNode,
|
|
16
|
-
];
|
|
17
|
-
interface DocumentEditorConfig {
|
|
18
|
-
namespace: string;
|
|
19
|
-
nodes: typeof DOCUMENT_NODE_CLASSES;
|
|
20
|
-
onError: (error: Readonly<Error>) => void;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// Create initial editor configuration with a fresh node collection for each editor.
|
|
24
|
-
const createEditorConfig = (): DocumentEditorConfig => ({
|
|
25
|
-
namespace: "DocumentEditor",
|
|
26
|
-
nodes: [...DOCUMENT_NODE_CLASSES],
|
|
27
|
-
onError: (error: Readonly<Error>): void => {
|
|
28
|
-
console.error("Lexical error:", error);
|
|
29
|
-
},
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
const handleEditorChange = ({
|
|
33
|
-
editorState: _editorState,
|
|
34
|
-
editor,
|
|
35
|
-
onSaveContent,
|
|
36
|
-
}: Readonly<{
|
|
37
|
-
editorState: Readonly<Pick<EditorState, "read">>;
|
|
38
|
-
editor: Readonly<Pick<LexicalEditor, "getEditorState">>;
|
|
39
|
-
onSaveContent: (updatedContent: string, debounce: boolean) => void;
|
|
40
|
-
}>): void => {
|
|
41
|
-
let updatedContent = "";
|
|
42
|
-
|
|
43
|
-
editor.getEditorState().read((): void => {
|
|
44
|
-
updatedContent = $convertToMarkdownString(TRANSFORMERS);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
// Check if this should be debounced (similar to ProseMirror's no-debounce meta)
|
|
48
|
-
// Default to debounced saving
|
|
49
|
-
const shouldDebounce = true;
|
|
50
|
-
|
|
51
|
-
onSaveContent(updatedContent, shouldDebounce);
|
|
52
|
-
};
|
|
53
|
-
export { createEditorConfig, handleEditorChange };
|