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,190 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { documentDefinitions } from "@/integrations/documents/definitions";
|
|
4
|
-
|
|
5
|
-
import { hasText } from "@/components/text-value";
|
|
6
|
-
|
|
7
|
-
import type { JSX as ReactJSX } from "react";
|
|
8
|
-
import React, { useEffect, useRef } from "react";
|
|
9
|
-
import { useIsClient } from "usehooks-ts";
|
|
10
|
-
import { z } from "zod";
|
|
11
|
-
|
|
12
|
-
import { DocumentToolResult } from "@/components/part/document-common";
|
|
13
|
-
import { useArtifact } from "@/hooks/use-artifact";
|
|
14
|
-
import { eveDocumentResult } from "@/chatjs/core/documents/contracts";
|
|
15
|
-
import type { ReadonlyEveMessagePart } from "@/lib/eve/readonly-message-types";
|
|
16
|
-
|
|
17
|
-
import {
|
|
18
|
-
useDocumentConversation,
|
|
19
|
-
useDocumentReplaying,
|
|
20
|
-
} from "./eve-document-context";
|
|
21
|
-
import { EveDocumentPreview } from "./eve-document-preview";
|
|
22
|
-
|
|
23
|
-
const partialDocument = z.object({
|
|
24
|
-
content: z.string().optional(),
|
|
25
|
-
documentId: z.string().optional(),
|
|
26
|
-
title: z.string().optional(),
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
export const EveDocumentTool = ({
|
|
30
|
-
part,
|
|
31
|
-
messageId,
|
|
32
|
-
isReadonly,
|
|
33
|
-
preview = false,
|
|
34
|
-
}: {
|
|
35
|
-
readonly part: Extract<ReadonlyEveMessagePart, { readonly type: "tool" }>;
|
|
36
|
-
readonly messageId: string;
|
|
37
|
-
readonly isReadonly: boolean;
|
|
38
|
-
readonly preview?: boolean;
|
|
39
|
-
}): ReactJSX.Element => {
|
|
40
|
-
const isClient = useIsClient();
|
|
41
|
-
const replaying = useDocumentReplaying();
|
|
42
|
-
const conversationId = useDocumentConversation();
|
|
43
|
-
const { setArtifact } = useArtifact();
|
|
44
|
-
// oxlint-disable-next-line unicorn/no-useless-undefined -- React requires an initial ref value; undefined represents the uninitialized state.
|
|
45
|
-
const pendingCall = useRef<string | undefined>(undefined);
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
if (replaying) {
|
|
48
|
-
pendingCall.current = undefined;
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
const operation = documentDefinitions.operations.get(part.name);
|
|
52
|
-
if (
|
|
53
|
-
part.state === "streaming" ||
|
|
54
|
-
part.state === "running" ||
|
|
55
|
-
part.state === "requested"
|
|
56
|
-
) {
|
|
57
|
-
pendingCall.current = part.callId;
|
|
58
|
-
const input = partialDocument.safeParse(part.input);
|
|
59
|
-
if (isReadonly || !operation || !input.success) {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
const { data } = input;
|
|
63
|
-
setArtifact((current) => {
|
|
64
|
-
// A user-selected historical revision or another open document is never stolen by a stream.
|
|
65
|
-
if (
|
|
66
|
-
current.isVisible &&
|
|
67
|
-
(current.followLive === false ||
|
|
68
|
-
(current.documentId !== "init" &&
|
|
69
|
-
current.documentId !== data.documentId))
|
|
70
|
-
) {
|
|
71
|
-
return current;
|
|
72
|
-
}
|
|
73
|
-
return {
|
|
74
|
-
...current,
|
|
75
|
-
content: data.content ?? "",
|
|
76
|
-
conversationId,
|
|
77
|
-
documentId: data.documentId ?? "init",
|
|
78
|
-
followLive: true,
|
|
79
|
-
isVisible:
|
|
80
|
-
current.previewCallId === part.callId ? current.isVisible : true,
|
|
81
|
-
kind: operation.kind,
|
|
82
|
-
messageId,
|
|
83
|
-
previewCallId: part.callId,
|
|
84
|
-
status: "streaming",
|
|
85
|
-
title: data.title ?? current.title,
|
|
86
|
-
};
|
|
87
|
-
});
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
if (
|
|
91
|
-
part.state !== "completed" &&
|
|
92
|
-
part.state !== "failed" &&
|
|
93
|
-
part.state !== "rejected" &&
|
|
94
|
-
part.state !== "cancelled"
|
|
95
|
-
) {
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
const wasPending = pendingCall.current === part.callId;
|
|
99
|
-
pendingCall.current = undefined;
|
|
100
|
-
if (!wasPending || isReadonly || !operation) {
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
const completed =
|
|
104
|
-
part.state === "completed"
|
|
105
|
-
? eveDocumentResult.safeParse(part.output)
|
|
106
|
-
: undefined;
|
|
107
|
-
setArtifact((current) => {
|
|
108
|
-
if (!(completed?.success === true)) {
|
|
109
|
-
if (current.previewCallId === part.callId) {
|
|
110
|
-
return {
|
|
111
|
-
...current,
|
|
112
|
-
isVisible: current.documentId !== "init",
|
|
113
|
-
previewCallId: undefined,
|
|
114
|
-
status: "idle",
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
return current;
|
|
118
|
-
}
|
|
119
|
-
if (
|
|
120
|
-
current.isVisible &&
|
|
121
|
-
(current.followLive === false ||
|
|
122
|
-
(current.documentId !== "init" &&
|
|
123
|
-
current.documentId !== completed.data.documentId))
|
|
124
|
-
) {
|
|
125
|
-
return current;
|
|
126
|
-
}
|
|
127
|
-
return {
|
|
128
|
-
content: "",
|
|
129
|
-
conversationId,
|
|
130
|
-
date: completed.data.date,
|
|
131
|
-
documentId: completed.data.documentId,
|
|
132
|
-
followLive: true,
|
|
133
|
-
isVisible:
|
|
134
|
-
current.previewCallId === part.callId ? current.isVisible : true,
|
|
135
|
-
kind: completed.data.kind,
|
|
136
|
-
messageId,
|
|
137
|
-
status: "idle",
|
|
138
|
-
title: completed.data.title,
|
|
139
|
-
};
|
|
140
|
-
});
|
|
141
|
-
}, [part, isReadonly, messageId, setArtifact, conversationId, replaying]);
|
|
142
|
-
if (part.state === "failed") {
|
|
143
|
-
return <p role="alert">{part.error?.message ?? "Tool failed"}</p>;
|
|
144
|
-
}
|
|
145
|
-
if (part.state === "cancelled") {
|
|
146
|
-
return <p>Document operation stopped.</p>;
|
|
147
|
-
}
|
|
148
|
-
if (part.state === "rejected") {
|
|
149
|
-
return <p>Document operation declined.</p>;
|
|
150
|
-
}
|
|
151
|
-
if (part.state !== "completed") {
|
|
152
|
-
return (
|
|
153
|
-
<output>
|
|
154
|
-
{part.name === "readDocument"
|
|
155
|
-
? "Reading document…"
|
|
156
|
-
: "Writing document…"}
|
|
157
|
-
</output>
|
|
158
|
-
);
|
|
159
|
-
}
|
|
160
|
-
const result = eveDocumentResult.safeParse(part.output);
|
|
161
|
-
if (!result.success) {
|
|
162
|
-
return <p role="alert">This document result could not be displayed.</p>;
|
|
163
|
-
}
|
|
164
|
-
const completedOperation = documentDefinitions.operations.get(part.name);
|
|
165
|
-
const writeAction =
|
|
166
|
-
completedOperation?.edit === false ||
|
|
167
|
-
(!completedOperation && part.name.startsWith("create"))
|
|
168
|
-
? "create"
|
|
169
|
-
: "update";
|
|
170
|
-
if (preview && hasText(conversationId)) {
|
|
171
|
-
return (
|
|
172
|
-
<EveDocumentPreview
|
|
173
|
-
isReadonly={isReadonly}
|
|
174
|
-
action={part.name === "readDocument" ? "read" : writeAction}
|
|
175
|
-
conversationId={conversationId}
|
|
176
|
-
result={result.data}
|
|
177
|
-
messageId={messageId}
|
|
178
|
-
/>
|
|
179
|
-
);
|
|
180
|
-
}
|
|
181
|
-
return (
|
|
182
|
-
<DocumentToolResult
|
|
183
|
-
disabled={!isClient}
|
|
184
|
-
isReadonly={isReadonly}
|
|
185
|
-
messageId={messageId}
|
|
186
|
-
result={{ ...result.data, id: result.data.documentId }}
|
|
187
|
-
type={part.name === "readDocument" ? "read" : writeAction}
|
|
188
|
-
/>
|
|
189
|
-
);
|
|
190
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { headers } from "next/headers";
|
|
2
|
-
import React from "react";
|
|
3
|
-
|
|
4
|
-
import { listEveConversations } from "@/lib/db/eve-queries";
|
|
5
|
-
import { resolveEvePrincipal } from "@/lib/eve/principal";
|
|
6
|
-
|
|
7
|
-
import { EveHistoryList } from "./eve-history-list";
|
|
8
|
-
|
|
9
|
-
export const EveHistory = async () => {
|
|
10
|
-
const principal = await resolveEvePrincipal(await headers());
|
|
11
|
-
if (!principal) {
|
|
12
|
-
return null;
|
|
13
|
-
}
|
|
14
|
-
const current = await listEveConversations(principal.ownerId, {
|
|
15
|
-
surface: "sidebar",
|
|
16
|
-
search: "",
|
|
17
|
-
});
|
|
18
|
-
return (
|
|
19
|
-
<EveHistoryList
|
|
20
|
-
initialPage={current}
|
|
21
|
-
key={principal.ownerId}
|
|
22
|
-
ownerId={principal.ownerId}
|
|
23
|
-
/>
|
|
24
|
-
);
|
|
25
|
-
};
|
|
@@ -1,281 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { withTaskCleanup } from "@/components/task-cleanup";
|
|
4
|
-
|
|
5
|
-
import { hasText } from "@/components/text-value";
|
|
6
|
-
|
|
7
|
-
import { useMutation } from "@tanstack/react-query";
|
|
8
|
-
import {
|
|
9
|
-
useCallback,
|
|
10
|
-
useEffect,
|
|
11
|
-
useMemo,
|
|
12
|
-
useRef,
|
|
13
|
-
useState,
|
|
14
|
-
useSyncExternalStore,
|
|
15
|
-
} from "react";
|
|
16
|
-
import { z } from "zod";
|
|
17
|
-
|
|
18
|
-
import { useTRPC } from "@/trpc/react";
|
|
19
|
-
|
|
20
|
-
const draftSchema = z.object({
|
|
21
|
-
baseRevisionId: z.uuid(),
|
|
22
|
-
content: z.string(),
|
|
23
|
-
operationId: z.uuid(),
|
|
24
|
-
submittedContent: z.string().optional(),
|
|
25
|
-
title: z.string(),
|
|
26
|
-
});
|
|
27
|
-
type Draft = z.infer<typeof draftSchema>;
|
|
28
|
-
interface Revision {
|
|
29
|
-
id: string;
|
|
30
|
-
title: string;
|
|
31
|
-
content: string;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const createDocumentDraftStore = (storageKey: string) => {
|
|
35
|
-
const initial: {
|
|
36
|
-
draft: Draft | undefined;
|
|
37
|
-
ready: boolean;
|
|
38
|
-
storageError: boolean;
|
|
39
|
-
} = {
|
|
40
|
-
draft: undefined,
|
|
41
|
-
ready: false,
|
|
42
|
-
storageError: false,
|
|
43
|
-
};
|
|
44
|
-
let snapshot = initial;
|
|
45
|
-
const latest: { current: Draft | undefined } = { current: undefined };
|
|
46
|
-
const listeners = new Set<() => void>();
|
|
47
|
-
const publish = (next: typeof initial): void => {
|
|
48
|
-
snapshot = next;
|
|
49
|
-
latest.current = next.draft;
|
|
50
|
-
for (const listener of listeners) {
|
|
51
|
-
listener();
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
return {
|
|
55
|
-
latest,
|
|
56
|
-
getSnapshot: () => snapshot,
|
|
57
|
-
getServerSnapshot: () => initial,
|
|
58
|
-
subscribe: (listener: () => void) => {
|
|
59
|
-
listeners.add(listener);
|
|
60
|
-
return () => {
|
|
61
|
-
listeners.delete(listener);
|
|
62
|
-
};
|
|
63
|
-
},
|
|
64
|
-
restore: (onRestore: (revisionId: string) => void): void => {
|
|
65
|
-
if (snapshot.ready) {
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
let draft: Draft | undefined;
|
|
69
|
-
let storageError = false;
|
|
70
|
-
try {
|
|
71
|
-
const stored = sessionStorage.getItem(storageKey);
|
|
72
|
-
if (typeof stored === "string" && stored !== "") {
|
|
73
|
-
draft = draftSchema.parse(JSON.parse(stored));
|
|
74
|
-
latest.current = draft;
|
|
75
|
-
onRestore(draft.baseRevisionId);
|
|
76
|
-
}
|
|
77
|
-
} catch {
|
|
78
|
-
storageError = true;
|
|
79
|
-
}
|
|
80
|
-
publish({ draft, ready: true, storageError });
|
|
81
|
-
},
|
|
82
|
-
update: (draft?: Draft): void => {
|
|
83
|
-
latest.current = draft;
|
|
84
|
-
let storageError = false;
|
|
85
|
-
// Publish only after durable persistence, while retaining edits if storage fails.
|
|
86
|
-
try {
|
|
87
|
-
if (draft) {
|
|
88
|
-
sessionStorage.setItem(storageKey, JSON.stringify(draft));
|
|
89
|
-
} else {
|
|
90
|
-
sessionStorage.removeItem(storageKey);
|
|
91
|
-
}
|
|
92
|
-
} catch {
|
|
93
|
-
storageError = true;
|
|
94
|
-
}
|
|
95
|
-
publish({ ...snapshot, draft, storageError });
|
|
96
|
-
},
|
|
97
|
-
};
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
/** One immutable request at a time; newer edits remain queued behind it. */
|
|
101
|
-
export const useDocumentDraft = ({
|
|
102
|
-
conversationId,
|
|
103
|
-
documentId,
|
|
104
|
-
enabled,
|
|
105
|
-
revision,
|
|
106
|
-
onSaved,
|
|
107
|
-
onRestore,
|
|
108
|
-
}: {
|
|
109
|
-
readonly conversationId: string;
|
|
110
|
-
readonly documentId: string;
|
|
111
|
-
readonly enabled: boolean;
|
|
112
|
-
readonly revision: Readonly<Revision> | undefined;
|
|
113
|
-
readonly onSaved: (revisionId: string) => Promise<void>;
|
|
114
|
-
readonly onRestore: (revisionId: string) => void;
|
|
115
|
-
}) => {
|
|
116
|
-
const trpc = useTRPC();
|
|
117
|
-
const { mutateAsync, isPending } = useMutation(
|
|
118
|
-
trpc.eve.saveDocument.mutationOptions()
|
|
119
|
-
);
|
|
120
|
-
const storageKey = `eve-document-draft:${conversationId}:${documentId}`;
|
|
121
|
-
const store = useMemo(
|
|
122
|
-
() => createDocumentDraftStore(storageKey),
|
|
123
|
-
[storageKey]
|
|
124
|
-
);
|
|
125
|
-
const subscribe = useCallback(
|
|
126
|
-
(listener: () => void) => {
|
|
127
|
-
const unsubscribe = store.subscribe(listener);
|
|
128
|
-
if (enabled) {
|
|
129
|
-
store.restore(onRestore);
|
|
130
|
-
}
|
|
131
|
-
return unsubscribe;
|
|
132
|
-
},
|
|
133
|
-
[store, enabled, onRestore]
|
|
134
|
-
);
|
|
135
|
-
const { draft, ready, storageError } = useSyncExternalStore(
|
|
136
|
-
subscribe,
|
|
137
|
-
store.getSnapshot,
|
|
138
|
-
store.getServerSnapshot
|
|
139
|
-
);
|
|
140
|
-
const { latest, update } = store;
|
|
141
|
-
const [failure, setFailure] = useState<string>();
|
|
142
|
-
const busy = useRef(false);
|
|
143
|
-
const active = useRef(true);
|
|
144
|
-
useEffect(() => {
|
|
145
|
-
active.current = true;
|
|
146
|
-
return (): void => {
|
|
147
|
-
active.current = false;
|
|
148
|
-
};
|
|
149
|
-
}, []);
|
|
150
|
-
|
|
151
|
-
const edit = useCallback(
|
|
152
|
-
(content: string) => {
|
|
153
|
-
if (!(enabled && ready && revision)) {
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
const { current } = latest;
|
|
157
|
-
if (current?.content === content) {
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
if (!current && content === revision.content) {
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
update(
|
|
164
|
-
current
|
|
165
|
-
? { ...current, content }
|
|
166
|
-
: {
|
|
167
|
-
baseRevisionId: revision.id,
|
|
168
|
-
content,
|
|
169
|
-
operationId: crypto.randomUUID(),
|
|
170
|
-
title: revision.title,
|
|
171
|
-
}
|
|
172
|
-
);
|
|
173
|
-
},
|
|
174
|
-
[enabled, ready, revision, update, latest]
|
|
175
|
-
);
|
|
176
|
-
|
|
177
|
-
const save = useCallback(async () => {
|
|
178
|
-
const { current } = latest;
|
|
179
|
-
if (!(enabled && ready && current) || busy.current) {
|
|
180
|
-
return;
|
|
181
|
-
}
|
|
182
|
-
busy.current = true;
|
|
183
|
-
setFailure(undefined);
|
|
184
|
-
const submitted = {
|
|
185
|
-
...current,
|
|
186
|
-
submittedContent: current.submittedContent ?? current.content,
|
|
187
|
-
};
|
|
188
|
-
update(submitted);
|
|
189
|
-
|
|
190
|
-
await withTaskCleanup(
|
|
191
|
-
async () => {
|
|
192
|
-
try {
|
|
193
|
-
const saved = await mutateAsync({
|
|
194
|
-
content: submitted.submittedContent,
|
|
195
|
-
conversationId,
|
|
196
|
-
documentId,
|
|
197
|
-
expectedRevisionId: submitted.baseRevisionId,
|
|
198
|
-
operationId: submitted.operationId,
|
|
199
|
-
title: submitted.title,
|
|
200
|
-
});
|
|
201
|
-
if (!active.current) {
|
|
202
|
-
return;
|
|
203
|
-
}
|
|
204
|
-
await onSaved(saved.id);
|
|
205
|
-
if (!active.current) {
|
|
206
|
-
return;
|
|
207
|
-
}
|
|
208
|
-
const newest = latest.current;
|
|
209
|
-
update(
|
|
210
|
-
newest && newest.content !== submitted.submittedContent
|
|
211
|
-
? {
|
|
212
|
-
baseRevisionId: saved.id,
|
|
213
|
-
content: newest.content,
|
|
214
|
-
operationId: crypto.randomUUID(),
|
|
215
|
-
title: saved.title,
|
|
216
|
-
}
|
|
217
|
-
: undefined
|
|
218
|
-
);
|
|
219
|
-
} catch (error) {
|
|
220
|
-
setFailure(
|
|
221
|
-
error instanceof Error
|
|
222
|
-
? error.message
|
|
223
|
-
: "Document could not be saved."
|
|
224
|
-
);
|
|
225
|
-
}
|
|
226
|
-
},
|
|
227
|
-
() => {
|
|
228
|
-
busy.current = false;
|
|
229
|
-
}
|
|
230
|
-
);
|
|
231
|
-
}, [
|
|
232
|
-
enabled,
|
|
233
|
-
ready,
|
|
234
|
-
conversationId,
|
|
235
|
-
documentId,
|
|
236
|
-
mutateAsync,
|
|
237
|
-
update,
|
|
238
|
-
onSaved,
|
|
239
|
-
latest,
|
|
240
|
-
]);
|
|
241
|
-
useEffect((): (() => void) | undefined => {
|
|
242
|
-
if (!(enabled && ready && draft) || hasText(failure) || isPending) {
|
|
243
|
-
return undefined;
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
const timer = setTimeout(() => {
|
|
247
|
-
void save();
|
|
248
|
-
}, 2000);
|
|
249
|
-
|
|
250
|
-
return (): void => {
|
|
251
|
-
clearTimeout(timer);
|
|
252
|
-
};
|
|
253
|
-
}, [enabled, ready, draft, failure, isPending, save]);
|
|
254
|
-
|
|
255
|
-
return {
|
|
256
|
-
discard: () => {
|
|
257
|
-
if (!busy.current) {
|
|
258
|
-
update();
|
|
259
|
-
setFailure(undefined);
|
|
260
|
-
}
|
|
261
|
-
},
|
|
262
|
-
draft,
|
|
263
|
-
edit,
|
|
264
|
-
error: failure,
|
|
265
|
-
ready,
|
|
266
|
-
restore: (content: string, title: string, baseRevisionId: string) => {
|
|
267
|
-
if (!(enabled && ready) || busy.current || latest.current) {
|
|
268
|
-
return;
|
|
269
|
-
}
|
|
270
|
-
update({
|
|
271
|
-
baseRevisionId,
|
|
272
|
-
content,
|
|
273
|
-
operationId: crypto.randomUUID(),
|
|
274
|
-
title,
|
|
275
|
-
});
|
|
276
|
-
},
|
|
277
|
-
retry: save,
|
|
278
|
-
saving: isPending,
|
|
279
|
-
storageError,
|
|
280
|
-
};
|
|
281
|
-
};
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { Favicon } from "./favicon";
|
|
2
|
-
|
|
3
|
-
import type React from "react";
|
|
4
|
-
|
|
5
|
-
import { cn } from "@/lib/utils";
|
|
6
|
-
|
|
7
|
-
const DEFAULT_MAX_VISIBLE_FAVICONS = 4;
|
|
8
|
-
|
|
9
|
-
// Define a simpler interface for the sources needed by this component
|
|
10
|
-
interface FaviconSource {
|
|
11
|
-
// Title is optional, mainly for alt text
|
|
12
|
-
readonly title?: string;
|
|
13
|
-
readonly url: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
interface FaviconGroupProps {
|
|
17
|
-
readonly className?: string;
|
|
18
|
-
readonly maxVisible?: number;
|
|
19
|
-
// Use the simpler interface
|
|
20
|
-
readonly sources: readonly FaviconSource[];
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export const FaviconGroup: React.FC<FaviconGroupProps> = ({
|
|
24
|
-
sources,
|
|
25
|
-
maxVisible = DEFAULT_MAX_VISIBLE_FAVICONS,
|
|
26
|
-
className,
|
|
27
|
-
}): React.JSX.Element => {
|
|
28
|
-
const visibleSources = sources.slice(0, maxVisible);
|
|
29
|
-
|
|
30
|
-
return (
|
|
31
|
-
<div className={cn("flex items-center", className)}>
|
|
32
|
-
{visibleSources.map((source, index): React.JSX.Element => (
|
|
33
|
-
<Favicon
|
|
34
|
-
alt={`Favicon for ${
|
|
35
|
-
typeof source.title === "string" && source.title !== ""
|
|
36
|
-
? source.title
|
|
37
|
-
: new URL(source.url).hostname
|
|
38
|
-
}`}
|
|
39
|
-
className={cn(
|
|
40
|
-
"border-background h-5 w-5 rounded-full border-2",
|
|
41
|
-
index > 0 ? "-ml-2" : ""
|
|
42
|
-
)}
|
|
43
|
-
key={source.url === "" ? index : source.url}
|
|
44
|
-
style={{ zIndex: maxVisible - index }}
|
|
45
|
-
url={`https://www.google.com/s2/favicons?domain=${new URL(source.url).hostname}&sz=32`}
|
|
46
|
-
/>
|
|
47
|
-
))}
|
|
48
|
-
</div>
|
|
49
|
-
);
|
|
50
|
-
};
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import { hasText } from "@/components/text-value";
|
|
2
|
-
import { File, Pencil } from "lucide-react";
|
|
3
|
-
import React, { memo } from "react";
|
|
4
|
-
import { Trace, TraceLine, TraceIcon, TraceTitle } from "@/components/ui/trace";
|
|
5
|
-
import type { ArtifactKind } from "@/lib/artifacts/artifact-kind";
|
|
6
|
-
|
|
7
|
-
import type { JSX as ReactJSX } from "react";
|
|
8
|
-
|
|
9
|
-
import { useArtifact } from "@/hooks/use-artifact";
|
|
10
|
-
|
|
11
|
-
import { useDocumentConversation } from "@/components/eve/eve-document-context";
|
|
12
|
-
|
|
13
|
-
const hasProp = <Key extends string>(
|
|
14
|
-
obj: unknown,
|
|
15
|
-
prop: Key
|
|
16
|
-
): obj is Record<Key, unknown> =>
|
|
17
|
-
typeof obj === "object" && obj !== null && prop in obj;
|
|
18
|
-
|
|
19
|
-
const isArtifactToolResult = (
|
|
20
|
-
value: unknown
|
|
21
|
-
): value is { id: string; title: string; kind: ArtifactKind } =>
|
|
22
|
-
hasProp(value, "id") &&
|
|
23
|
-
typeof value.id === "string" &&
|
|
24
|
-
hasProp(value, "title") &&
|
|
25
|
-
typeof value.title === "string" &&
|
|
26
|
-
hasProp(value, "kind") &&
|
|
27
|
-
typeof value.kind === "string";
|
|
28
|
-
|
|
29
|
-
type DocumentActionText =
|
|
30
|
-
| "Reading"
|
|
31
|
-
| "Read"
|
|
32
|
-
| "Creating"
|
|
33
|
-
| "Created"
|
|
34
|
-
| "Updating"
|
|
35
|
-
| "Updated";
|
|
36
|
-
|
|
37
|
-
const actionTextByType: ReadonlyMap<
|
|
38
|
-
"create" | "update" | "read",
|
|
39
|
-
{ readonly past: DocumentActionText; readonly present: DocumentActionText }
|
|
40
|
-
> = new Map([
|
|
41
|
-
["read", { past: "Read", present: "Reading" }],
|
|
42
|
-
["create", { past: "Created", present: "Creating" }],
|
|
43
|
-
["update", { past: "Updated", present: "Updating" }],
|
|
44
|
-
]);
|
|
45
|
-
const getActionText = (
|
|
46
|
-
type: "create" | "update" | "read",
|
|
47
|
-
tense: "present" | "past"
|
|
48
|
-
): DocumentActionText | null => {
|
|
49
|
-
const labels = actionTextByType.get(type);
|
|
50
|
-
if (!labels) {
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
if (tense === "present") {
|
|
54
|
-
return labels.present;
|
|
55
|
-
}
|
|
56
|
-
return labels.past;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
interface DocumentToolResultProps {
|
|
60
|
-
readonly followLive?: boolean;
|
|
61
|
-
readonly disabled?: boolean;
|
|
62
|
-
readonly isReadonly: boolean;
|
|
63
|
-
readonly messageId: string;
|
|
64
|
-
readonly result: {
|
|
65
|
-
readonly id: string;
|
|
66
|
-
readonly title: string;
|
|
67
|
-
readonly kind: ArtifactKind;
|
|
68
|
-
readonly revisionId?: string;
|
|
69
|
-
};
|
|
70
|
-
readonly type: "create" | "update" | "read";
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const PureDocumentToolResult = ({
|
|
74
|
-
disabled = false,
|
|
75
|
-
followLive = false,
|
|
76
|
-
type,
|
|
77
|
-
result,
|
|
78
|
-
isReadonly: _isReadonly,
|
|
79
|
-
messageId,
|
|
80
|
-
}: DocumentToolResultProps): ReactJSX.Element => {
|
|
81
|
-
const { setArtifact } = useArtifact();
|
|
82
|
-
const conversationId = useDocumentConversation();
|
|
83
|
-
|
|
84
|
-
return (
|
|
85
|
-
<Trace>
|
|
86
|
-
<button
|
|
87
|
-
className="disabled:pointer-events-none disabled:opacity-50"
|
|
88
|
-
aria-label={`${getActionText(type, "past")} "${result.title}"`}
|
|
89
|
-
disabled={disabled}
|
|
90
|
-
onClick={() => {
|
|
91
|
-
setArtifact({
|
|
92
|
-
content: "",
|
|
93
|
-
conversationId,
|
|
94
|
-
documentId: result.id,
|
|
95
|
-
followLive,
|
|
96
|
-
isVisible: true,
|
|
97
|
-
kind: result.kind,
|
|
98
|
-
messageId,
|
|
99
|
-
revisionId: followLive ? undefined : result.revisionId,
|
|
100
|
-
status: "idle",
|
|
101
|
-
title: result.title,
|
|
102
|
-
});
|
|
103
|
-
}}
|
|
104
|
-
type="button"
|
|
105
|
-
>
|
|
106
|
-
<TraceLine>
|
|
107
|
-
<TraceIcon>{type === "update" ? <Pencil /> : <File />}</TraceIcon>
|
|
108
|
-
<TraceTitle>{`${getActionText(type, "past")} "${result.title}"`}</TraceTitle>
|
|
109
|
-
</TraceLine>
|
|
110
|
-
</button>
|
|
111
|
-
</Trace>
|
|
112
|
-
);
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
const DocumentToolResult = memo(PureDocumentToolResult);
|
|
116
|
-
|
|
117
|
-
interface DocumentToolCallProps {
|
|
118
|
-
readonly args: { readonly title?: string };
|
|
119
|
-
readonly isReadonly: boolean;
|
|
120
|
-
readonly type: "create" | "update" | "read";
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
const PureDocumentToolCall = ({
|
|
124
|
-
type,
|
|
125
|
-
args,
|
|
126
|
-
isReadonly: _isReadonly,
|
|
127
|
-
}: DocumentToolCallProps): ReactJSX.Element => {
|
|
128
|
-
const { setArtifact } = useArtifact();
|
|
129
|
-
|
|
130
|
-
return (
|
|
131
|
-
<Trace>
|
|
132
|
-
<button
|
|
133
|
-
aria-label={`${getActionText(type, "present")} ${args.title ?? "document"}`}
|
|
134
|
-
onClick={() => {
|
|
135
|
-
setArtifact((currentArtifact) => ({
|
|
136
|
-
...currentArtifact,
|
|
137
|
-
isVisible: true,
|
|
138
|
-
}));
|
|
139
|
-
}}
|
|
140
|
-
type="button"
|
|
141
|
-
>
|
|
142
|
-
<TraceLine status="running">
|
|
143
|
-
<TraceIcon>{type === "update" ? <Pencil /> : <File />}</TraceIcon>
|
|
144
|
-
<TraceTitle>{`${getActionText(type, "present")} ${hasText(args.title) ? `"${args.title}"` : ""}`}</TraceTitle>
|
|
145
|
-
</TraceLine>
|
|
146
|
-
</button>
|
|
147
|
-
</Trace>
|
|
148
|
-
);
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
const DocumentToolCall = memo(PureDocumentToolCall);
|
|
152
|
-
export { DocumentToolCall, DocumentToolResult, hasProp, isArtifactToolResult };
|