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
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { ExpandIcon } from "lucide-react";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
import type { ArtifactReference } from "@/components/artifact-actions";
|
|
6
|
+
import { ArtifactDownloadAction } from "@/components/artifact-download-action";
|
|
7
|
+
import { VideoPlayer } from "@/components/video-player";
|
|
8
|
+
import { Button } from "@/components/ui/button";
|
|
9
|
+
import {
|
|
10
|
+
Dialog,
|
|
11
|
+
DialogContent,
|
|
12
|
+
DialogDescription,
|
|
13
|
+
DialogTitle,
|
|
14
|
+
} from "@/components/ui/dialog";
|
|
15
|
+
|
|
16
|
+
export const VideoViewerAction = ({
|
|
17
|
+
artifact,
|
|
18
|
+
onOpen,
|
|
19
|
+
}: {
|
|
20
|
+
readonly artifact: ArtifactReference;
|
|
21
|
+
readonly onOpen?: () => void;
|
|
22
|
+
}) => {
|
|
23
|
+
const [open, setOpen] = useState(false);
|
|
24
|
+
if (!artifact.mediaType.startsWith("video/")) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
return (
|
|
28
|
+
<>
|
|
29
|
+
<Button
|
|
30
|
+
aria-label="Open video"
|
|
31
|
+
title="Open video"
|
|
32
|
+
size="icon-sm"
|
|
33
|
+
variant="ghost"
|
|
34
|
+
onClick={() => {
|
|
35
|
+
onOpen?.();
|
|
36
|
+
setOpen(true);
|
|
37
|
+
}}
|
|
38
|
+
>
|
|
39
|
+
<ExpandIcon size={16} />
|
|
40
|
+
</Button>
|
|
41
|
+
{open && (
|
|
42
|
+
<Dialog open onOpenChange={setOpen}>
|
|
43
|
+
<DialogContent className="w-[calc(100%-2rem)] max-w-5xl sm:max-w-5xl">
|
|
44
|
+
<DialogTitle className="pe-8">Video preview</DialogTitle>
|
|
45
|
+
<DialogDescription className="line-clamp-2">
|
|
46
|
+
{artifact.name}
|
|
47
|
+
</DialogDescription>
|
|
48
|
+
<VideoPlayer
|
|
49
|
+
src={artifact.url}
|
|
50
|
+
name={artifact.name}
|
|
51
|
+
className="rounded-md"
|
|
52
|
+
/>
|
|
53
|
+
<div className="flex justify-end">
|
|
54
|
+
<ArtifactDownloadAction
|
|
55
|
+
artifact={artifact}
|
|
56
|
+
label="Download video"
|
|
57
|
+
/>
|
|
58
|
+
</div>
|
|
59
|
+
</DialogContent>
|
|
60
|
+
</Dialog>
|
|
61
|
+
)}
|
|
62
|
+
</>
|
|
63
|
+
);
|
|
64
|
+
};
|
|
@@ -8,13 +8,6 @@ import type { ui as chatjsUi } from "@/integrations/tools/ui";
|
|
|
8
8
|
import { createElement } from "react";
|
|
9
9
|
import { renderToStaticMarkup } from "react-dom/server";
|
|
10
10
|
|
|
11
|
-
vi.mock(
|
|
12
|
-
"@/components/eve/eve-document-tool",
|
|
13
|
-
(): { EveDocumentTool: () => null } => ({
|
|
14
|
-
EveDocumentTool: (): null => null,
|
|
15
|
-
})
|
|
16
|
-
);
|
|
17
|
-
|
|
18
11
|
vi.mock("@/integrations/tools/ui", async (importOriginal) => {
|
|
19
12
|
const { z: zod } = await import("zod");
|
|
20
13
|
const { createElement: reactCreateElement } = await import("react");
|
|
@@ -120,24 +113,25 @@ test("validates custom input and output before invoking its typed renderer", ()
|
|
|
120
113
|
}
|
|
121
114
|
});
|
|
122
115
|
|
|
123
|
-
test("uses the installed
|
|
116
|
+
test("uses the installed workspace attachment renderer and rejects malformed persisted results", () => {
|
|
124
117
|
expect(
|
|
125
118
|
renderResult({
|
|
126
|
-
input: {
|
|
119
|
+
input: { path: "/workspace/sample-notes.md" },
|
|
127
120
|
output: {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
121
|
+
fileId: "abcdefghijklmnopqrstuvwx.md",
|
|
122
|
+
name: "sample-notes.md",
|
|
123
|
+
mediaType: "text/plain",
|
|
124
|
+
size: 7,
|
|
125
|
+
url: "/api/files/abcdefghijklmnopqrstuvwx.md",
|
|
132
126
|
},
|
|
133
|
-
toolName: "
|
|
127
|
+
toolName: "attach_workspace_file",
|
|
134
128
|
})
|
|
135
|
-
).toContain("
|
|
129
|
+
).toContain("sample-notes.md");
|
|
136
130
|
expect(
|
|
137
131
|
renderResult({
|
|
138
|
-
input: {
|
|
139
|
-
output: {
|
|
140
|
-
toolName: "
|
|
132
|
+
input: { path: "/workspace/sample-notes.md" },
|
|
133
|
+
output: { size: {} },
|
|
134
|
+
toolName: "attach_workspace_file",
|
|
141
135
|
})
|
|
142
136
|
).toContain("This tool result could not be displayed.");
|
|
143
137
|
});
|
|
@@ -150,13 +144,13 @@ test("shows a failed tool instead of its loading skeleton", () => {
|
|
|
150
144
|
part: {
|
|
151
145
|
error: {
|
|
152
146
|
code: "fixture_error",
|
|
153
|
-
message: "
|
|
147
|
+
message: "File storage unavailable",
|
|
154
148
|
},
|
|
155
149
|
input: {},
|
|
156
150
|
state: "failed",
|
|
157
151
|
callId: "call-fixture",
|
|
158
|
-
name: "
|
|
159
|
-
label: "
|
|
152
|
+
name: "attach_workspace_file",
|
|
153
|
+
label: "attach_workspace_file",
|
|
160
154
|
type: "tool",
|
|
161
155
|
kind: "tool",
|
|
162
156
|
stepIndex: 0,
|
|
@@ -164,7 +158,7 @@ test("shows a failed tool instead of its loading skeleton", () => {
|
|
|
164
158
|
})
|
|
165
159
|
);
|
|
166
160
|
expect(html).toContain('role="alert"');
|
|
167
|
-
expect(html).toContain("
|
|
161
|
+
expect(html).toContain("File storage unavailable");
|
|
168
162
|
expect(html).not.toContain("skeleton");
|
|
169
163
|
});
|
|
170
164
|
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { WorkflowStepToolContext } from "eve/tools";
|
|
2
|
+
import type { z } from "zod";
|
|
3
|
+
import { eveGeneratedFileUploader } from "@/lib/eve/generated-files";
|
|
4
|
+
import { resolveEveConversationScope } from "@/lib/eve/conversation-scope";
|
|
5
|
+
import { attachSandboxFile } from "./attach";
|
|
6
|
+
import type { attachWorkspaceFileInput } from "./schemas";
|
|
7
|
+
|
|
8
|
+
/** Application boundary shared by tools and durable workflows publishing sandbox files. */
|
|
9
|
+
export const attachConversationFile = async (
|
|
10
|
+
input: z.infer<typeof attachWorkspaceFileInput>,
|
|
11
|
+
context: Readonly<WorkflowStepToolContext>
|
|
12
|
+
) => {
|
|
13
|
+
const { current, initiator } = context.session.auth;
|
|
14
|
+
if (
|
|
15
|
+
context.session.parent ||
|
|
16
|
+
current?.authenticator !== "chatjs-gateway" ||
|
|
17
|
+
current.principalId !== initiator?.principalId
|
|
18
|
+
) {
|
|
19
|
+
throw new Error(
|
|
20
|
+
"Publication requires the current ChatJS conversation owner's authority."
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
// Authorize the application resource before reading sandbox bytes.
|
|
24
|
+
await resolveEveConversationScope(
|
|
25
|
+
current.principalId,
|
|
26
|
+
context.session.id,
|
|
27
|
+
context.abortSignal
|
|
28
|
+
);
|
|
29
|
+
return await attachSandboxFile(input, {
|
|
30
|
+
sandbox: await context.getSandbox(),
|
|
31
|
+
upload: eveGeneratedFileUploader(context),
|
|
32
|
+
signal: context.abortSignal,
|
|
33
|
+
});
|
|
34
|
+
};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import nodePath from "node:path";
|
|
2
|
+
import type { SandboxSession } from "eve/sandbox";
|
|
3
|
+
import type { FileUploader } from "@/lib/file-storage";
|
|
4
|
+
import type { z } from "zod";
|
|
5
|
+
import type { attachWorkspaceFileInput } from "./schemas";
|
|
6
|
+
import {
|
|
7
|
+
maximumWorkspaceFileBytes,
|
|
8
|
+
attachWorkspaceFileResult,
|
|
9
|
+
} from "./schemas";
|
|
10
|
+
|
|
11
|
+
// Active browser formats such as HTML and SVG are delivered as downloads.
|
|
12
|
+
const mediaTypes: Readonly<Record<string, string>> = {
|
|
13
|
+
".txt": "text/plain",
|
|
14
|
+
".md": "text/plain",
|
|
15
|
+
".csv": "text/csv",
|
|
16
|
+
".json": "application/json",
|
|
17
|
+
".pdf": "application/pdf",
|
|
18
|
+
".xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
19
|
+
".docx":
|
|
20
|
+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
21
|
+
".pptx":
|
|
22
|
+
"application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
23
|
+
".png": "image/png",
|
|
24
|
+
".jpg": "image/jpeg",
|
|
25
|
+
".jpeg": "image/jpeg",
|
|
26
|
+
".webp": "image/webp",
|
|
27
|
+
".gif": "image/gif",
|
|
28
|
+
".mp4": "video/mp4",
|
|
29
|
+
".webm": "video/webm",
|
|
30
|
+
".mp3": "audio/mpeg",
|
|
31
|
+
".wav": "audio/wav",
|
|
32
|
+
".zip": "application/zip",
|
|
33
|
+
};
|
|
34
|
+
const shellQuote = (value: string): string =>
|
|
35
|
+
`'${value.replaceAll("'", "'\\''")}'`;
|
|
36
|
+
const inWorkspace = (path: string, root: string): boolean =>
|
|
37
|
+
path.startsWith(`${root}/`);
|
|
38
|
+
|
|
39
|
+
export const attachSandboxFile = async (
|
|
40
|
+
input: z.infer<typeof attachWorkspaceFileInput>,
|
|
41
|
+
{
|
|
42
|
+
sandbox,
|
|
43
|
+
upload,
|
|
44
|
+
signal,
|
|
45
|
+
}: {
|
|
46
|
+
readonly sandbox: Pick<SandboxSession, "resolvePath" | "run" | "readFile">;
|
|
47
|
+
readonly upload: FileUploader;
|
|
48
|
+
readonly signal: AbortSignal;
|
|
49
|
+
}
|
|
50
|
+
): Promise<z.infer<typeof attachWorkspaceFileResult>> => {
|
|
51
|
+
signal.throwIfAborted();
|
|
52
|
+
const root = nodePath.posix.normalize(sandbox.resolvePath("."));
|
|
53
|
+
const path = nodePath.posix.normalize(sandbox.resolvePath(input.path));
|
|
54
|
+
if (!inWorkspace(path, root)) {
|
|
55
|
+
throw new Error("Attach a file inside the sandbox workspace.");
|
|
56
|
+
}
|
|
57
|
+
const quoted = shellQuote(path);
|
|
58
|
+
const resolved = await sandbox.run({
|
|
59
|
+
command: `if [ -f ${quoted} ]; then readlink -f -- ${quoted}; fi`,
|
|
60
|
+
signal,
|
|
61
|
+
});
|
|
62
|
+
const realPath = resolved.stdout.replace(/\n$/u, "");
|
|
63
|
+
if (resolved.exitCode !== 0 || !inWorkspace(realPath, root)) {
|
|
64
|
+
throw new Error(
|
|
65
|
+
"The file is missing, is not a regular file, or resolves outside the workspace."
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
const stream = await sandbox.readFile({ path: realPath, signal });
|
|
69
|
+
if (!stream) {
|
|
70
|
+
throw new Error("The sandbox file is no longer available.");
|
|
71
|
+
}
|
|
72
|
+
const reader = stream.getReader();
|
|
73
|
+
const chunks: Uint8Array[] = [];
|
|
74
|
+
let size = 0;
|
|
75
|
+
try {
|
|
76
|
+
for (;;) {
|
|
77
|
+
signal.throwIfAborted();
|
|
78
|
+
// oxlint-disable-next-line eslint/no-await-in-loop -- Read ordered chunks and enforce a limit before storing bytes.
|
|
79
|
+
const { done, value } = await reader.read();
|
|
80
|
+
if (done) {
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
size += value.byteLength;
|
|
84
|
+
if (size > maximumWorkspaceFileBytes) {
|
|
85
|
+
throw new Error("Files must be 32 MiB or smaller.");
|
|
86
|
+
}
|
|
87
|
+
chunks.push(value);
|
|
88
|
+
}
|
|
89
|
+
} finally {
|
|
90
|
+
await reader.cancel();
|
|
91
|
+
reader.releaseLock();
|
|
92
|
+
}
|
|
93
|
+
signal.throwIfAborted();
|
|
94
|
+
const name = input.name ?? nodePath.posix.basename(path);
|
|
95
|
+
const mediaType =
|
|
96
|
+
mediaTypes[nodePath.posix.extname(name).toLowerCase()] ??
|
|
97
|
+
"application/octet-stream";
|
|
98
|
+
const stored = await upload(name, Buffer.concat(chunks, size), mediaType);
|
|
99
|
+
return attachWorkspaceFileResult.parse({
|
|
100
|
+
fileId: stored.fileId,
|
|
101
|
+
url: stored.url,
|
|
102
|
+
name: stored.pathname,
|
|
103
|
+
mediaType,
|
|
104
|
+
size,
|
|
105
|
+
});
|
|
106
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"agentCategory": "tool",
|
|
3
|
+
"requiresChatJS": true,
|
|
4
|
+
"channelSupport": { "web": "supported", "slack": "unsupported" },
|
|
5
|
+
"envRequirements": [],
|
|
6
|
+
"id": "attach-workspace-file",
|
|
7
|
+
"kind": "tool",
|
|
8
|
+
"requiresStorage": true,
|
|
9
|
+
"requiresTools": [],
|
|
10
|
+
"tools": [
|
|
11
|
+
{ "accounting": "none", "toolExport": "import_file" },
|
|
12
|
+
{
|
|
13
|
+
"accounting": "none",
|
|
14
|
+
"rendererExport": "AttachWorkspaceFileRenderer",
|
|
15
|
+
"toolExport": "attach_workspace_file"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"contractVersion": 1
|
|
19
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import type { SandboxSession } from "eve/sandbox";
|
|
3
|
+
import type { z } from "zod";
|
|
4
|
+
import { maximumWorkspaceFileBytes } from "./schemas";
|
|
5
|
+
import type { importFileInput } from "./schemas";
|
|
6
|
+
|
|
7
|
+
/** Copy authorized stored bytes into a fresh native workspace path. */
|
|
8
|
+
export const importStoredFile = async (
|
|
9
|
+
input: z.infer<typeof importFileInput>,
|
|
10
|
+
{
|
|
11
|
+
stat,
|
|
12
|
+
read,
|
|
13
|
+
getSandbox,
|
|
14
|
+
signal,
|
|
15
|
+
}: {
|
|
16
|
+
readonly stat: () => Promise<{ readonly size: number }>;
|
|
17
|
+
readonly read: () => Promise<{
|
|
18
|
+
readonly type: string;
|
|
19
|
+
readonly stream: () => ReadableStream<Uint8Array>;
|
|
20
|
+
}>;
|
|
21
|
+
readonly getSandbox: () => PromiseLike<
|
|
22
|
+
Pick<SandboxSession, "resolvePath" | "writeBinaryFile">
|
|
23
|
+
>;
|
|
24
|
+
readonly signal: AbortSignal;
|
|
25
|
+
}
|
|
26
|
+
) => {
|
|
27
|
+
signal.throwIfAborted();
|
|
28
|
+
const metadata = await stat();
|
|
29
|
+
if (metadata.size > maximumWorkspaceFileBytes) {
|
|
30
|
+
throw new Error("Files must be 32 MiB or smaller.");
|
|
31
|
+
}
|
|
32
|
+
signal.throwIfAborted();
|
|
33
|
+
const file = await read();
|
|
34
|
+
const reader = file.stream().getReader();
|
|
35
|
+
const chunks: Uint8Array[] = [];
|
|
36
|
+
let size = 0;
|
|
37
|
+
try {
|
|
38
|
+
for (;;) {
|
|
39
|
+
signal.throwIfAborted();
|
|
40
|
+
// oxlint-disable-next-line eslint/no-await-in-loop -- Bound storage reads before acquiring a sandbox or writing any bytes.
|
|
41
|
+
const { done, value } = await reader.read();
|
|
42
|
+
if (done) {
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
size += value.byteLength;
|
|
46
|
+
if (size > maximumWorkspaceFileBytes) {
|
|
47
|
+
throw new Error("Files must be 32 MiB or smaller.");
|
|
48
|
+
}
|
|
49
|
+
chunks.push(value);
|
|
50
|
+
}
|
|
51
|
+
} finally {
|
|
52
|
+
await reader.cancel();
|
|
53
|
+
reader.releaseLock();
|
|
54
|
+
}
|
|
55
|
+
signal.throwIfAborted();
|
|
56
|
+
const sandbox = await getSandbox();
|
|
57
|
+
// Fresh flat filenames cannot follow user-selected directories or overwrite an earlier import.
|
|
58
|
+
const path = sandbox.resolvePath(`import-${randomUUID()}-${input.name}`);
|
|
59
|
+
await sandbox.writeBinaryFile({
|
|
60
|
+
path,
|
|
61
|
+
content: Buffer.concat(chunks, size),
|
|
62
|
+
signal,
|
|
63
|
+
});
|
|
64
|
+
return {
|
|
65
|
+
fileId: input.fileId,
|
|
66
|
+
path,
|
|
67
|
+
name: input.name,
|
|
68
|
+
mediaType: file.type,
|
|
69
|
+
size,
|
|
70
|
+
};
|
|
71
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { FileArtifactCard } from "@/components/file-artifact-card";
|
|
4
|
+
import { defineToolRenderer } from "@/chatjs/core/tools/define-renderer";
|
|
5
|
+
import { attachWorkspaceFileInput, attachWorkspaceFileResult } from "./schemas";
|
|
6
|
+
|
|
7
|
+
export const AttachWorkspaceFileRenderer = defineToolRenderer({
|
|
8
|
+
inputSchema: attachWorkspaceFileInput,
|
|
9
|
+
outputSchema: attachWorkspaceFileResult,
|
|
10
|
+
render: ({ tool }) =>
|
|
11
|
+
tool.state === "output-available" ? (
|
|
12
|
+
<FileArtifactCard artifact={tool.output} />
|
|
13
|
+
) : (
|
|
14
|
+
<output className="text-muted-foreground block rounded-lg border p-4 text-sm">
|
|
15
|
+
Preparing download
|
|
16
|
+
{tool.input?.name === undefined ? "…" : `: ${tool.input.name}`}
|
|
17
|
+
</output>
|
|
18
|
+
),
|
|
19
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { isFileStorageKey } from "@/lib/file-url";
|
|
3
|
+
|
|
4
|
+
export const maximumWorkspaceFileBytes = 32 * 1024 * 1024;
|
|
5
|
+
|
|
6
|
+
export const attachWorkspaceFileInput = z.object({
|
|
7
|
+
path: z
|
|
8
|
+
.string()
|
|
9
|
+
.min(1)
|
|
10
|
+
.max(4096)
|
|
11
|
+
.regex(/^[^\p{Cc}]+$/u)
|
|
12
|
+
.describe(
|
|
13
|
+
"File in the current EVE sandbox workspace, e.g. /workspace/report.xlsx."
|
|
14
|
+
),
|
|
15
|
+
name: z
|
|
16
|
+
.string()
|
|
17
|
+
.trim()
|
|
18
|
+
.min(1)
|
|
19
|
+
.max(180)
|
|
20
|
+
.regex(/^[^/\\\p{Cc}]+$/u)
|
|
21
|
+
.optional()
|
|
22
|
+
.describe("Optional download filename, including its extension."),
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export const attachWorkspaceFileResult = z.object({
|
|
26
|
+
fileId: z.string().min(1),
|
|
27
|
+
name: z.string().min(1),
|
|
28
|
+
mediaType: z.string().min(1),
|
|
29
|
+
size: z.number().int().nonnegative().max(maximumWorkspaceFileBytes),
|
|
30
|
+
url: z.string().min(1),
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
export const importFileInput = z.object({
|
|
34
|
+
fileId: z
|
|
35
|
+
.string()
|
|
36
|
+
.refine(isFileStorageKey, "Use a fileId from this conversation.")
|
|
37
|
+
.describe(
|
|
38
|
+
"Exact fileId returned by attach_workspace_file, or the storage key in a file attachment URL in this conversation. Never guess a file ID."
|
|
39
|
+
),
|
|
40
|
+
name: attachWorkspaceFileInput.shape.name
|
|
41
|
+
.unwrap()
|
|
42
|
+
.describe(
|
|
43
|
+
"Filename from the referenced artifact, including its extension."
|
|
44
|
+
),
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
export const importFileResult = attachWorkspaceFileResult
|
|
48
|
+
.omit({ url: true })
|
|
49
|
+
.extend({
|
|
50
|
+
path: z.string().min(1),
|
|
51
|
+
});
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { defineTool, toolOutput } from "eve/tools";
|
|
2
|
+
import { resolveEveConversationScope } from "@/lib/eve/conversation-scope";
|
|
3
|
+
import { attachConversationFile } from "./attach-conversation-file";
|
|
4
|
+
import {
|
|
5
|
+
attachWorkspaceFileInput,
|
|
6
|
+
attachWorkspaceFileResult,
|
|
7
|
+
importFileInput,
|
|
8
|
+
importFileResult,
|
|
9
|
+
} from "./schemas";
|
|
10
|
+
import { importStoredFile } from "./import";
|
|
11
|
+
import { withEveConversationFile } from "@/lib/db/eve-files";
|
|
12
|
+
import { downloadFile, getFileMetadata } from "@/lib/file-storage";
|
|
13
|
+
|
|
14
|
+
export const attach_workspace_file = defineTool({
|
|
15
|
+
description:
|
|
16
|
+
"Attach a finished workspace file to the current ChatJS conversation as a downloadable artifact. Creates a new durable snapshot; later sandbox edits do not change it. Use for user-requested deliverables, not intermediate files. To revise an earlier artifact, import_file using its exact fileId, edit the workspace copy with native tools, then attach_workspace_file again. Earlier downloads remain unchanged. Maximum 32 MiB. Delegated agents return the file path to the parent so it can attach the file.",
|
|
17
|
+
inputSchema: attachWorkspaceFileInput,
|
|
18
|
+
outputSchema: attachWorkspaceFileResult,
|
|
19
|
+
availableInSubagents: false,
|
|
20
|
+
async execute(input, context) {
|
|
21
|
+
return await attachConversationFile(input, context);
|
|
22
|
+
},
|
|
23
|
+
toModelOutput: (output) => toolOutput.json(output),
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export const import_file = defineTool({
|
|
27
|
+
description:
|
|
28
|
+
"Import a published artifact or uploaded file referenced in the current ChatJS conversation into the current EVE workspace. Use before revising an earlier file, including after its original sandbox is gone. Supply its exact fileId and filename from conversation history; ask the user to identify or upload the file if ambiguous. Returns a fresh local copy. Edit it with native tools and attach_workspace_file to deliver a new snapshot. The original is never changed. Maximum 32 MiB.",
|
|
29
|
+
inputSchema: importFileInput,
|
|
30
|
+
outputSchema: importFileResult,
|
|
31
|
+
availableInSubagents: false,
|
|
32
|
+
async execute(input, context) {
|
|
33
|
+
const { current, initiator } = context.session.auth;
|
|
34
|
+
if (
|
|
35
|
+
context.session.parent ||
|
|
36
|
+
current?.authenticator !== "chatjs-gateway" ||
|
|
37
|
+
current.principalId !== initiator?.principalId
|
|
38
|
+
) {
|
|
39
|
+
throw new Error(
|
|
40
|
+
"File import requires the current ChatJS conversation owner's authority."
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
const { ownerId, conversationId } = await resolveEveConversationScope(
|
|
44
|
+
current.principalId,
|
|
45
|
+
context.session.id,
|
|
46
|
+
context.abortSignal
|
|
47
|
+
);
|
|
48
|
+
return await withEveConversationFile(
|
|
49
|
+
ownerId,
|
|
50
|
+
conversationId,
|
|
51
|
+
input.fileId,
|
|
52
|
+
async () =>
|
|
53
|
+
await importStoredFile(input, {
|
|
54
|
+
stat: async () => await getFileMetadata(input.fileId),
|
|
55
|
+
read: async () => await downloadFile(input.fileId),
|
|
56
|
+
getSandbox: async () => await context.getSandbox(),
|
|
57
|
+
signal: context.abortSignal,
|
|
58
|
+
})
|
|
59
|
+
);
|
|
60
|
+
},
|
|
61
|
+
toModelOutput: (output) => toolOutput.json(output),
|
|
62
|
+
});
|
|
@@ -1,12 +1,25 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
"
|
|
2
|
+
"agentCategory": "extension",
|
|
3
|
+
"requiresChatJS": false,
|
|
4
|
+
"native": {
|
|
5
|
+
"layout": "agent",
|
|
6
|
+
"files": [
|
|
7
|
+
"tools/deepResearch.ts",
|
|
8
|
+
"lib/research/configuration.ts",
|
|
9
|
+
"lib/research/prompts.ts",
|
|
10
|
+
"lib/research/schemas.ts",
|
|
11
|
+
"lib/research/steps.ts",
|
|
12
|
+
"lib/research/workspace.ts"
|
|
13
|
+
],
|
|
14
|
+
"dependencies": ["eve", "zod"]
|
|
15
|
+
},
|
|
4
16
|
"envRequirements": [],
|
|
5
17
|
"id": "deep-research",
|
|
6
18
|
"kind": "tool",
|
|
7
|
-
"requiresTools": [
|
|
19
|
+
"requiresTools": [],
|
|
8
20
|
"tools": [
|
|
9
21
|
{
|
|
22
|
+
"accounting": "none",
|
|
10
23
|
"composer": {
|
|
11
24
|
"icon": "Telescope",
|
|
12
25
|
"name": "Deep Research",
|
|
@@ -17,5 +30,6 @@
|
|
|
17
30
|
"workflow": true
|
|
18
31
|
}
|
|
19
32
|
],
|
|
20
|
-
"contractVersion": 1
|
|
33
|
+
"contractVersion": 1,
|
|
34
|
+
"channelSupport": { "web": "supported", "slack": "unverified" }
|
|
21
35
|
}
|
|
@@ -7,10 +7,7 @@ import {
|
|
|
7
7
|
TraceTitle,
|
|
8
8
|
} from "@/components/ui/trace";
|
|
9
9
|
// Type-only imports
|
|
10
|
-
import type {
|
|
11
|
-
ResearchUpdate,
|
|
12
|
-
WebSearchUpdate,
|
|
13
|
-
} from "@/tools/platform/research-updates-schema";
|
|
10
|
+
import type { ResearchUpdate } from "@/tools/platform/research-updates-schema";
|
|
14
11
|
import React from "react";
|
|
15
12
|
import type { ReadonlyNativeSurface } from "@/lib/readonly-native-surface";
|
|
16
13
|
import { ResearchTask } from "./task";
|
|
@@ -21,7 +18,6 @@ const updateName = {
|
|
|
21
18
|
completed: "Completed",
|
|
22
19
|
started: "Started",
|
|
23
20
|
thoughts: "Thoughts",
|
|
24
|
-
web: "Web Search",
|
|
25
21
|
writing: "Writing",
|
|
26
22
|
} as const;
|
|
27
23
|
|
|
@@ -36,31 +32,6 @@ export const ResearchProgress = ({
|
|
|
36
32
|
|
|
37
33
|
const lastUpdate = updates.length > 0 ? updates.at(-1) : null;
|
|
38
34
|
|
|
39
|
-
const searchCount = React.useMemo(
|
|
40
|
-
(): number =>
|
|
41
|
-
updates.filter(
|
|
42
|
-
(update: ReadonlyNativeSurface<ResearchUpdate>) => update.type === "web"
|
|
43
|
-
).length,
|
|
44
|
-
[updates]
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
const sourceCount = React.useMemo(
|
|
48
|
-
(): number =>
|
|
49
|
-
updates
|
|
50
|
-
.filter(
|
|
51
|
-
(update: ReadonlyNativeSurface<ResearchUpdate>) =>
|
|
52
|
-
update.type === "web"
|
|
53
|
-
)
|
|
54
|
-
.reduce(
|
|
55
|
-
(
|
|
56
|
-
acc: number,
|
|
57
|
-
update: ReadonlyNativeSurface<WebSearchUpdate>
|
|
58
|
-
): number => acc + (update.results?.length ?? 0),
|
|
59
|
-
0
|
|
60
|
-
),
|
|
61
|
-
[updates]
|
|
62
|
-
);
|
|
63
|
-
|
|
64
35
|
// Keep the fallback title while no update has been received.
|
|
65
36
|
const lastUpdateTitle = ((): string => {
|
|
66
37
|
if (!lastUpdate) {
|
|
@@ -104,7 +75,7 @@ export const ResearchProgress = ({
|
|
|
104
75
|
<TraceLine status={isComplete ? undefined : "running"}>
|
|
105
76
|
<TraceTitle>
|
|
106
77
|
{isComplete
|
|
107
|
-
? `Researched for ${timeSpent} seconds
|
|
78
|
+
? `Researched for ${timeSpent} seconds`
|
|
108
79
|
: lastUpdateTitle}
|
|
109
80
|
</TraceTitle>
|
|
110
81
|
</TraceLine>
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { researchInput, researchOutput } from "./schemas";
|
|
3
|
-
import { EveDocumentTool } from "@/components/eve/eve-document-tool";
|
|
4
3
|
import React from "react";
|
|
5
4
|
import type { ReadonlyNativeSurface } from "@/lib/readonly-native-surface";
|
|
6
5
|
import { ReasonSearchResearchProgress } from "./progress";
|
|
@@ -13,33 +12,22 @@ export const DeepResearchRenderer = defineToolRenderer({
|
|
|
13
12
|
outputSchema: researchOutput,
|
|
14
13
|
render: ({
|
|
15
14
|
tool,
|
|
16
|
-
messageId,
|
|
17
|
-
isReadonly,
|
|
18
15
|
}: ReadonlyNativeSurface<
|
|
19
16
|
ToolRendererProps<typeof researchInput, typeof researchOutput>
|
|
20
17
|
>) => {
|
|
21
18
|
const result = tool.state === "output-available" ? tool.output : undefined;
|
|
22
19
|
let content = <output>Researching…</output>;
|
|
23
|
-
if (result &&
|
|
20
|
+
if (result && result.format !== "progress") {
|
|
24
21
|
content =
|
|
25
22
|
result.format === "clarifying_questions" ? (
|
|
26
23
|
<p>{result.answer}</p>
|
|
27
24
|
) : (
|
|
28
|
-
<
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
state: "completed",
|
|
35
|
-
callId: tool.toolCallId,
|
|
36
|
-
kind: "tool",
|
|
37
|
-
label: "Create document",
|
|
38
|
-
stepIndex: 0,
|
|
39
|
-
name: "createTextDocument",
|
|
40
|
-
type: "tool",
|
|
41
|
-
}}
|
|
42
|
-
/>
|
|
25
|
+
<div className="space-y-1">
|
|
26
|
+
<p className="font-medium">{result.title}</p>
|
|
27
|
+
<p className="text-muted-foreground text-sm">
|
|
28
|
+
Research complete. Report saved in the agent workspace.
|
|
29
|
+
</p>
|
|
30
|
+
</div>
|
|
43
31
|
);
|
|
44
32
|
}
|
|
45
33
|
return <div className="space-y-3">{content}</div>;
|