chat-js 1.0.0-alpha.1 → 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 +5 -5
- package/dist/index.js +2625 -2666
- package/package.json +9 -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/CHANGELOG.md +0 -6
- package/templates/electron/icon.png +0 -0
- package/templates/electron/package.json +3 -2
- 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,24 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
|
|
3
|
-
const retrievedInput = z.object({
|
|
4
|
-
url: z.string().describe("The URL to retrieve the information from."),
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
const retrievedContent = z
|
|
8
|
-
.object({
|
|
9
|
-
content: z.string(),
|
|
10
|
-
description: z.string(),
|
|
11
|
-
language: z.string().optional(),
|
|
12
|
-
title: z.string(),
|
|
13
|
-
url: z.string(),
|
|
14
|
-
})
|
|
15
|
-
.transform((item) => ({ ...item, language: item.language }));
|
|
16
|
-
const retrievalFailure = z
|
|
17
|
-
.strictObject({ error: z.string().optional() })
|
|
18
|
-
.transform((item) => ({ error: item.error }));
|
|
19
|
-
const retrievedResult = z.union([
|
|
20
|
-
z.object({ error: z.string() }),
|
|
21
|
-
z.object({ results: z.array(retrievedContent) }),
|
|
22
|
-
z.object({ results: z.array(retrievalFailure) }),
|
|
23
|
-
]);
|
|
24
|
-
export { retrievedInput, retrievedResult };
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import { afterEach, beforeEach, expect, test, vi } from "vitest";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
import { testToolContext } from "@/tests/helpers/eve-tool-context";
|
|
4
|
-
import { toolResultSchema } from "@/lib/eve/tool-result";
|
|
5
|
-
|
|
6
|
-
const mocks = vi.hoisted(() => ({
|
|
7
|
-
extract: vi.fn(),
|
|
8
|
-
scrape: vi.fn(),
|
|
9
|
-
}));
|
|
10
|
-
vi.mock("@mendable/firecrawl-js", () => ({
|
|
11
|
-
default: class {
|
|
12
|
-
public scrapeUrl = mocks.scrape;
|
|
13
|
-
public extract = mocks.extract;
|
|
14
|
-
},
|
|
15
|
-
}));
|
|
16
|
-
vi.mock(
|
|
17
|
-
"@/lib/logger",
|
|
18
|
-
(): { createModuleLogger: () => { error: () => void } } => ({
|
|
19
|
-
createModuleLogger: (): { error: () => void } => ({
|
|
20
|
-
error: vi.fn<() => void>(),
|
|
21
|
-
}),
|
|
22
|
-
})
|
|
23
|
-
);
|
|
24
|
-
beforeEach(() => {
|
|
25
|
-
vi.resetModules();
|
|
26
|
-
vi.resetAllMocks();
|
|
27
|
-
vi.stubEnv("FIRECRAWL_API_KEY", "test-key");
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
afterEach(() => vi.unstubAllEnvs());
|
|
31
|
-
|
|
32
|
-
test("invalid successful scrape rejects instead of becoming a retrieval failure", async () => {
|
|
33
|
-
mocks.scrape.mockResolvedValue({
|
|
34
|
-
markdown: "Content",
|
|
35
|
-
metadata: { description: "Description", language: 42, title: "Page" },
|
|
36
|
-
success: true,
|
|
37
|
-
});
|
|
38
|
-
const { retrieveUrl } = await import("./tool");
|
|
39
|
-
await expect(
|
|
40
|
-
retrieveUrl.execute({ url: "https://example.com" }, testToolContext())
|
|
41
|
-
).rejects.toBeInstanceOf(z.ZodError);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
test.each([
|
|
45
|
-
["missing configuration", "https://example.com"],
|
|
46
|
-
["invalid URL", "file:///private"],
|
|
47
|
-
])(
|
|
48
|
-
"%s produces a zero-cost receipt without calling Firecrawl",
|
|
49
|
-
async (reason, url) => {
|
|
50
|
-
const noChargeUsd = 0;
|
|
51
|
-
if (reason === "missing configuration") {
|
|
52
|
-
vi.stubEnv("FIRECRAWL_API_KEY", "");
|
|
53
|
-
}
|
|
54
|
-
const { retrieveUrl } = await import("./tool");
|
|
55
|
-
const result = await retrieveUrl.execute(
|
|
56
|
-
{
|
|
57
|
-
url,
|
|
58
|
-
},
|
|
59
|
-
testToolContext()
|
|
60
|
-
);
|
|
61
|
-
expect(toolResultSchema.parse(result).usage.costUsd).toBe(noChargeUsd);
|
|
62
|
-
expect(mocks.scrape).not.toHaveBeenCalled();
|
|
63
|
-
}
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
test.each([false, true])(
|
|
67
|
-
"provider completion keeps unknown cost explicit (failure=%s)",
|
|
68
|
-
async (fails) => {
|
|
69
|
-
if (fails) {
|
|
70
|
-
mocks.scrape.mockRejectedValue(new Error("remote failure"));
|
|
71
|
-
} else {
|
|
72
|
-
mocks.scrape.mockResolvedValue({
|
|
73
|
-
markdown: "Content",
|
|
74
|
-
metadata: { description: "Description", title: "Page" },
|
|
75
|
-
success: true,
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
const { retrieveUrl } = await import("./tool");
|
|
79
|
-
const result = await retrieveUrl.execute(
|
|
80
|
-
{ url: "https://example.com" },
|
|
81
|
-
testToolContext()
|
|
82
|
-
);
|
|
83
|
-
expect(toolResultSchema.parse(result).usage.costUsd).toBeUndefined();
|
|
84
|
-
expect(mocks.scrape).toHaveBeenCalledOnce();
|
|
85
|
-
}
|
|
86
|
-
);
|
|
87
|
-
|
|
88
|
-
test.each([
|
|
89
|
-
{
|
|
90
|
-
data: {
|
|
91
|
-
content: "Extracted content",
|
|
92
|
-
description: "Extracted description",
|
|
93
|
-
title: "Extracted title",
|
|
94
|
-
},
|
|
95
|
-
expected: {
|
|
96
|
-
content: "Extracted content",
|
|
97
|
-
description: "Extracted description",
|
|
98
|
-
title: "Scraped title",
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
data: {
|
|
103
|
-
content: "Valid extracted content",
|
|
104
|
-
description: "Valid extracted description",
|
|
105
|
-
title: { malformed: true },
|
|
106
|
-
},
|
|
107
|
-
expected: {
|
|
108
|
-
content: "Valid extracted content",
|
|
109
|
-
description: "Valid extracted description",
|
|
110
|
-
title: "Scraped title",
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
data: { description: "Partial description" },
|
|
115
|
-
expected: {
|
|
116
|
-
content: "",
|
|
117
|
-
description: "Partial description",
|
|
118
|
-
title: "Scraped title",
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
data: { content: 42, description: false, title: {} },
|
|
123
|
-
expected: { content: "", description: "", title: "Scraped title" },
|
|
124
|
-
},
|
|
125
|
-
])(
|
|
126
|
-
"validates extracted fallback fields without replacing scraped values ($data)",
|
|
127
|
-
async ({ data, expected }) => {
|
|
128
|
-
mocks.scrape.mockResolvedValue({
|
|
129
|
-
markdown: "",
|
|
130
|
-
metadata: { description: "", title: "Scraped title" },
|
|
131
|
-
success: true,
|
|
132
|
-
});
|
|
133
|
-
mocks.extract.mockResolvedValue({ success: true, data });
|
|
134
|
-
const { retrieveUrl } = await import("./tool");
|
|
135
|
-
const result = await retrieveUrl.execute(
|
|
136
|
-
{ url: "https://example.com/page?token=private" },
|
|
137
|
-
testToolContext()
|
|
138
|
-
);
|
|
139
|
-
expect(toolResultSchema.parse(result).output).toEqual({
|
|
140
|
-
results: [{ ...expected, url: "https://example.com/page" }],
|
|
141
|
-
});
|
|
142
|
-
expect(mocks.extract).toHaveBeenCalledOnce();
|
|
143
|
-
}
|
|
144
|
-
);
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
import { validateToolOutput } from "@/chatjs/core/tools/validate-output";
|
|
2
|
-
import FirecrawlApp from "@mendable/firecrawl-js";
|
|
3
|
-
import { defineTool } from "eve/tools";
|
|
4
|
-
import { readToolEnvironment } from "./retrieve-url-env";
|
|
5
|
-
import { createModuleLogger } from "@/lib/logger";
|
|
6
|
-
import { executeWithToolUsage } from "@/lib/eve/tool-usage";
|
|
7
|
-
import { retrievedInput, retrievedResult } from "./schemas";
|
|
8
|
-
import { toolResultToModelOutput } from "@/lib/eve/tool-model-output";
|
|
9
|
-
import { z } from "zod";
|
|
10
|
-
|
|
11
|
-
type RetrieveUrlInput = Readonly<z.infer<typeof retrievedInput>>;
|
|
12
|
-
type RetrieveUrlContext = Readonly<{
|
|
13
|
-
abortSignal: Readonly<AbortSignal>;
|
|
14
|
-
}>;
|
|
15
|
-
type RetrieveUrlUsage = Readonly<{
|
|
16
|
-
addCostUsd: (cost: number) => void;
|
|
17
|
-
markUnknown: () => void;
|
|
18
|
-
}>;
|
|
19
|
-
|
|
20
|
-
const hasNonEmptyValue = (value: string | null | undefined): value is string =>
|
|
21
|
-
typeof value === "string" && value !== "";
|
|
22
|
-
|
|
23
|
-
const UNBILLED_TOOL_COST_USD = 0;
|
|
24
|
-
const log = createModuleLogger("tools/retrieve-url");
|
|
25
|
-
const extractedPage = z.object({
|
|
26
|
-
content: z.string(),
|
|
27
|
-
description: z.string(),
|
|
28
|
-
title: z.string(),
|
|
29
|
-
});
|
|
30
|
-
const extractedText = z.preprocess(
|
|
31
|
-
(value) => (typeof value === "string" ? value : ""),
|
|
32
|
-
z.string()
|
|
33
|
-
);
|
|
34
|
-
const extractedPageFallback = z.object({
|
|
35
|
-
content: extractedText,
|
|
36
|
-
description: extractedText,
|
|
37
|
-
title: extractedText,
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
const createClient = (): FirecrawlApp | null => {
|
|
41
|
-
const env = readToolEnvironment();
|
|
42
|
-
return hasNonEmptyValue(env.FIRECRAWL_API_KEY)
|
|
43
|
-
? new FirecrawlApp({ apiKey: env.FIRECRAWL_API_KEY })
|
|
44
|
-
: null;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const parseUrl = (url: string): URL | null => {
|
|
48
|
-
try {
|
|
49
|
-
const parsed = new URL(url);
|
|
50
|
-
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
return parsed;
|
|
54
|
-
} catch {
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
const redactUrl = (url: Readonly<Pick<URL, "origin" | "pathname">>): string =>
|
|
60
|
-
`${url.origin}${url.pathname}`;
|
|
61
|
-
|
|
62
|
-
const retrieveContent = async (url: string, usage: RetrieveUrlUsage) => {
|
|
63
|
-
usage.addCostUsd(UNBILLED_TOOL_COST_USD);
|
|
64
|
-
try {
|
|
65
|
-
const app = createClient();
|
|
66
|
-
if (!app) {
|
|
67
|
-
return {
|
|
68
|
-
error:
|
|
69
|
-
"Firecrawl is not configured. Set FIRECRAWL_API_KEY to enable retrieval.",
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
const parsedUrl = parseUrl(url);
|
|
73
|
-
if (!parsedUrl) {
|
|
74
|
-
return {
|
|
75
|
-
error: "Please provide a valid http:// or https:// URL.",
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
const redactedUrl = redactUrl(parsedUrl);
|
|
80
|
-
const normalizedUrl = parsedUrl.toString();
|
|
81
|
-
// Firecrawl does not return a monetary receipt for scrape/extract.
|
|
82
|
-
usage.markUnknown();
|
|
83
|
-
const content = await app.scrapeUrl(normalizedUrl);
|
|
84
|
-
if (!(content.success && content.metadata)) {
|
|
85
|
-
return {
|
|
86
|
-
results: [
|
|
87
|
-
{
|
|
88
|
-
error: content.error,
|
|
89
|
-
},
|
|
90
|
-
],
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const { metadata } = content;
|
|
95
|
-
let { description, title } = metadata;
|
|
96
|
-
let extractedContent = content.markdown;
|
|
97
|
-
|
|
98
|
-
if (
|
|
99
|
-
!(
|
|
100
|
-
hasNonEmptyValue(title) &&
|
|
101
|
-
hasNonEmptyValue(description) &&
|
|
102
|
-
hasNonEmptyValue(extractedContent)
|
|
103
|
-
)
|
|
104
|
-
) {
|
|
105
|
-
const extractResult = await app.extract([normalizedUrl], {
|
|
106
|
-
prompt:
|
|
107
|
-
"Extract the page title, main content, and a brief description.",
|
|
108
|
-
schema: extractedPage,
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
if (
|
|
112
|
-
extractResult.success &&
|
|
113
|
-
extractResult.data !== undefined &&
|
|
114
|
-
extractResult.data !== null
|
|
115
|
-
) {
|
|
116
|
-
const extracted = extractedPageFallback.safeParse(extractResult.data);
|
|
117
|
-
if (extracted.success) {
|
|
118
|
-
title = hasNonEmptyValue(title) ? title : extracted.data.title;
|
|
119
|
-
description = hasNonEmptyValue(description)
|
|
120
|
-
? description
|
|
121
|
-
: extracted.data.description;
|
|
122
|
-
extractedContent = hasNonEmptyValue(extractedContent)
|
|
123
|
-
? extractedContent
|
|
124
|
-
: extracted.data.content;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
return {
|
|
130
|
-
results: [
|
|
131
|
-
{
|
|
132
|
-
content: extractedContent ?? "",
|
|
133
|
-
description: description ?? "",
|
|
134
|
-
language: metadata.language,
|
|
135
|
-
title: hasNonEmptyValue(title) ? title : "Untitled",
|
|
136
|
-
url: redactedUrl,
|
|
137
|
-
},
|
|
138
|
-
],
|
|
139
|
-
};
|
|
140
|
-
} catch (error) {
|
|
141
|
-
const parsedUrl = parseUrl(url);
|
|
142
|
-
log.error(
|
|
143
|
-
{
|
|
144
|
-
err: error,
|
|
145
|
-
url: parsedUrl ? redactUrl(parsedUrl) : "<invalid-url>",
|
|
146
|
-
},
|
|
147
|
-
"Firecrawl API error in retrieveUrl tool"
|
|
148
|
-
);
|
|
149
|
-
return {
|
|
150
|
-
error: "Failed to retrieve content",
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
export const retrieveUrl = defineTool({
|
|
156
|
-
description: `Fetch structured information from a single URL via Firecrawl.
|
|
157
|
-
|
|
158
|
-
Use for:
|
|
159
|
-
- Extract content from a specific URL supplied by the user
|
|
160
|
-
|
|
161
|
-
Avoid:
|
|
162
|
-
- General-purpose web searches`,
|
|
163
|
-
execute: async ({ url }: RetrieveUrlInput, context: RetrieveUrlContext) =>
|
|
164
|
-
await executeWithToolUsage(context, async (usage: RetrieveUrlUsage) =>
|
|
165
|
-
validateToolOutput(retrievedResult, await retrieveContent(url, usage))
|
|
166
|
-
),
|
|
167
|
-
inputSchema: retrievedInput,
|
|
168
|
-
toModelOutput: toolResultToModelOutput,
|
|
169
|
-
});
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"documentRunExport": "EveDocumentRun",
|
|
3
|
-
"envRequirements": [],
|
|
4
|
-
"id": "saved-code-execution",
|
|
5
|
-
"kind": "tool",
|
|
6
|
-
"requiresTools": ["createCodeDocument", "readDocument", "codeExecution"],
|
|
7
|
-
"tools": [
|
|
8
|
-
{ "rendererExport": "SavedCodeRenderer", "toolExport": "runCodeDocument" }
|
|
9
|
-
],
|
|
10
|
-
"contractVersion": 2,
|
|
11
|
-
"uiBase": "base"
|
|
12
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { EveToolPart, EveMessage } from "eve/client";
|
|
2
|
-
|
|
3
|
-
import { documentExecutionInput } from "./schemas";
|
|
4
|
-
|
|
5
|
-
/** Project the latest execution of this revision from the native transcript.
|
|
6
|
-
* @param {readonly Pick<EveMessage, "id" | "parts">[]} messages Transcript identifiers and parts read newest-first without changing the matched part reference.
|
|
7
|
-
* @param {string} documentId Document identity accepted by the execution tool.
|
|
8
|
-
* @param {string} revisionId Revision identity required to match that run.
|
|
9
|
-
* @returns {{ messageId: string; part: EveToolPart } | undefined} The newest matching tool part by original reference, or no result when that revision has not run.
|
|
10
|
-
*/
|
|
11
|
-
export const latestDocumentRun = (
|
|
12
|
-
messages: readonly Pick<EveMessage, "id" | "parts">[],
|
|
13
|
-
documentId: string,
|
|
14
|
-
revisionId: string
|
|
15
|
-
): { messageId: string; part: EveToolPart } | undefined => {
|
|
16
|
-
for (const message of messages.toReversed()) {
|
|
17
|
-
for (const part of message.parts.toReversed()) {
|
|
18
|
-
if (part.type === "tool" && part.name === "runCodeDocument") {
|
|
19
|
-
const input = documentExecutionInput.safeParse(part.input);
|
|
20
|
-
if (
|
|
21
|
-
input.success &&
|
|
22
|
-
input.data.documentId === documentId &&
|
|
23
|
-
input.data.revisionId === revisionId
|
|
24
|
-
) {
|
|
25
|
-
return { messageId: message.id, part };
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return undefined;
|
|
31
|
-
};
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { Hint } from "@/components/hint";
|
|
3
|
-
import {
|
|
4
|
-
installedDocumentKinds,
|
|
5
|
-
installedToolNames,
|
|
6
|
-
} from "@/integrations/tools/catalog";
|
|
7
|
-
import { Button } from "@/components/ui/button";
|
|
8
|
-
import type { DocumentRunProps } from "@/chatjs/core/documents/ui";
|
|
9
|
-
import { EveDocumentRunResult } from "./result";
|
|
10
|
-
import { Play } from "lucide-react";
|
|
11
|
-
import React from "react";
|
|
12
|
-
import { config } from "@/lib/config";
|
|
13
|
-
import { documentExecutionLanguage } from "./schemas";
|
|
14
|
-
import { latestDocumentRun } from "./document-runs";
|
|
15
|
-
|
|
16
|
-
export const EveDocumentRun = ({
|
|
17
|
-
documentId,
|
|
18
|
-
revisionId,
|
|
19
|
-
title,
|
|
20
|
-
kind,
|
|
21
|
-
messages,
|
|
22
|
-
disabled,
|
|
23
|
-
onAction,
|
|
24
|
-
buttonOnly = false,
|
|
25
|
-
resultOnly = false,
|
|
26
|
-
}: DocumentRunProps): React.JSX.Element | null => {
|
|
27
|
-
const [, startEventAction] = React.useTransition();
|
|
28
|
-
const run = latestDocumentRun(messages, documentId, revisionId);
|
|
29
|
-
const canRun =
|
|
30
|
-
onAction !== undefined &&
|
|
31
|
-
installedDocumentKinds.has("code") &&
|
|
32
|
-
installedToolNames.has("runCodeDocument") &&
|
|
33
|
-
documentExecutionLanguage(title) !== undefined;
|
|
34
|
-
if (
|
|
35
|
-
kind !== "code" ||
|
|
36
|
-
!(canRun || run) ||
|
|
37
|
-
(resultOnly && !run) ||
|
|
38
|
-
(buttonOnly && !canRun)
|
|
39
|
-
) {
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
return (
|
|
43
|
-
<div
|
|
44
|
-
className={buttonOnly ? "shrink-0" : "shrink-0 space-y-2 border-t p-2"}
|
|
45
|
-
>
|
|
46
|
-
{canRun && !resultOnly && (
|
|
47
|
-
<Hint
|
|
48
|
-
trigger={
|
|
49
|
-
<Button
|
|
50
|
-
className="hover:bg-accent h-fit px-2 py-1.5 [&_svg]:size-[18px]"
|
|
51
|
-
disabled={disabled}
|
|
52
|
-
|
|
53
|
-
onClick={() => {
|
|
54
|
-
startEventAction(async () => {
|
|
55
|
-
await onAction({
|
|
56
|
-
message: `Run the saved code using runCodeDocument with documentId "${documentId}" and revisionId "${revisionId}". Execute exactly this revision once. Do not edit the document or substitute codeExecution. Report the result briefly.`,
|
|
57
|
-
modelId: config.ai.tools.code.edits,
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
}}
|
|
61
|
-
size="sm"
|
|
62
|
-
variant="outline"
|
|
63
|
-
>
|
|
64
|
-
<Play size={18} /> Run
|
|
65
|
-
</Button>
|
|
66
|
-
}
|
|
67
|
-
>
|
|
68
|
-
Execute code
|
|
69
|
-
</Hint>
|
|
70
|
-
)}
|
|
71
|
-
{run && !buttonOnly && (
|
|
72
|
-
<details key={run.part.callId} open>
|
|
73
|
-
<summary className="cursor-pointer text-sm">Execution result</summary>
|
|
74
|
-
<div
|
|
75
|
-
className="max-h-64 overflow-auto pt-2"
|
|
76
|
-
data-testid="document-run-result"
|
|
77
|
-
>
|
|
78
|
-
<EveDocumentRunResult part={run.part} />
|
|
79
|
-
</div>
|
|
80
|
-
</details>
|
|
81
|
-
)}
|
|
82
|
-
</div>
|
|
83
|
-
);
|
|
84
|
-
};
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { validateToolOutput } from "@/chatjs/core/tools/validate-output";
|
|
2
|
-
import type { z } from "zod";
|
|
3
|
-
import {
|
|
4
|
-
documentExecutionInput,
|
|
5
|
-
documentExecutionResult,
|
|
6
|
-
documentExecutionLanguage,
|
|
7
|
-
eveCodeExecutionResult,
|
|
8
|
-
} from "./schemas";
|
|
9
|
-
import {
|
|
10
|
-
installedDocumentKinds,
|
|
11
|
-
installedToolNames,
|
|
12
|
-
} from "@/integrations/tools/catalog";
|
|
13
|
-
import type { ToolContext } from "eve/tools";
|
|
14
|
-
import { getEveDocumentRevision } from "@/lib/db/eve-documents";
|
|
15
|
-
import { resolveEveConversationScope } from "@/lib/eve/conversation-scope";
|
|
16
|
-
import { eveTurnAccount } from "@/lib/eve/turn-tools";
|
|
17
|
-
import { codeExecutor } from "@/integrations/tools/code-executor";
|
|
18
|
-
|
|
19
|
-
type ReadonlyCodeExecutionContext = Readonly<
|
|
20
|
-
Pick<ToolContext, "callId" | "session"> & {
|
|
21
|
-
abortSignal: Readonly<AbortSignal>;
|
|
22
|
-
}
|
|
23
|
-
>;
|
|
24
|
-
type CodeResult = Awaited<ReturnType<NonNullable<typeof codeExecutor>>>;
|
|
25
|
-
type SuccessfulCodeResult = Extract<CodeResult, { status: "success" }>;
|
|
26
|
-
type DocumentExecutionSource = Readonly<{
|
|
27
|
-
code: string;
|
|
28
|
-
language: "python" | "javascript";
|
|
29
|
-
title: string;
|
|
30
|
-
}>;
|
|
31
|
-
type DocumentExecutionResult = {
|
|
32
|
-
-readonly [
|
|
33
|
-
Key in keyof Omit<SuccessfulCodeResult, "output">
|
|
34
|
-
]: SuccessfulCodeResult[Key];
|
|
35
|
-
} & {
|
|
36
|
-
output: z.output<typeof documentExecutionResult> & DocumentExecutionSource;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
type DocumentExecutionStream = AsyncGenerator<
|
|
40
|
-
Extract<CodeResult, { status: "error" }> | DocumentExecutionResult,
|
|
41
|
-
void,
|
|
42
|
-
unknown
|
|
43
|
-
>;
|
|
44
|
-
|
|
45
|
-
const documentResult = (
|
|
46
|
-
result: Readonly<
|
|
47
|
-
Omit<SuccessfulCodeResult, "output"> & {
|
|
48
|
-
output: Readonly<SuccessfulCodeResult["output"]>;
|
|
49
|
-
}
|
|
50
|
-
>,
|
|
51
|
-
source: DocumentExecutionSource,
|
|
52
|
-
revision: Readonly<{ documentId: string; id: string }>
|
|
53
|
-
): DocumentExecutionResult => {
|
|
54
|
-
const output = eveCodeExecutionResult.safeParse(result.output);
|
|
55
|
-
return {
|
|
56
|
-
...result,
|
|
57
|
-
output: {
|
|
58
|
-
...validateToolOutput(documentExecutionResult, {
|
|
59
|
-
...(output.success
|
|
60
|
-
? output.data
|
|
61
|
-
: {
|
|
62
|
-
chart: "",
|
|
63
|
-
message:
|
|
64
|
-
"Execution finished, but its output has an unsupported format.",
|
|
65
|
-
}),
|
|
66
|
-
documentId: revision.documentId,
|
|
67
|
-
revisionId: revision.id,
|
|
68
|
-
}),
|
|
69
|
-
...source,
|
|
70
|
-
},
|
|
71
|
-
};
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Execute saved source, never model-supplied replacement code.
|
|
76
|
-
* @param {unknown} value Untrusted tool input validated against the shared execution schema.
|
|
77
|
-
* @param {ToolContext} context Native tool context supplying session scope, call metadata, and cancellation.
|
|
78
|
-
* @yields {unknown} Native EVE platform result snapshots with document identity.
|
|
79
|
-
*/
|
|
80
|
-
export const executeEveCodeDocument = async function* executeEveCodeDocument(
|
|
81
|
-
value: unknown,
|
|
82
|
-
context: ReadonlyCodeExecutionContext
|
|
83
|
-
): DocumentExecutionStream {
|
|
84
|
-
if (
|
|
85
|
-
!(
|
|
86
|
-
installedDocumentKinds.has("code") &&
|
|
87
|
-
installedToolNames.has("runCodeDocument")
|
|
88
|
-
)
|
|
89
|
-
) {
|
|
90
|
-
throw new Error("Document execution is disabled.");
|
|
91
|
-
}
|
|
92
|
-
const input = documentExecutionInput.parse(value);
|
|
93
|
-
const scope = await resolveEveConversationScope(
|
|
94
|
-
(context.session.auth.initiator ?? {}).principalId,
|
|
95
|
-
context.session.id,
|
|
96
|
-
context.abortSignal
|
|
97
|
-
);
|
|
98
|
-
const revision = await getEveDocumentRevision(
|
|
99
|
-
scope.ownerId,
|
|
100
|
-
scope.conversationId,
|
|
101
|
-
input.documentId,
|
|
102
|
-
input.revisionId
|
|
103
|
-
);
|
|
104
|
-
if (!revision || revision.kind !== "code") {
|
|
105
|
-
throw new Error("Code document not found.");
|
|
106
|
-
}
|
|
107
|
-
const language = documentExecutionLanguage(revision.title);
|
|
108
|
-
if (!language) {
|
|
109
|
-
throw new Error("Only Python and JavaScript documents can be run.");
|
|
110
|
-
}
|
|
111
|
-
context.abortSignal.throwIfAborted();
|
|
112
|
-
const source = { code: revision.content, language, title: revision.title };
|
|
113
|
-
if (!codeExecutor || !eveTurnAccount.get()) {
|
|
114
|
-
throw new Error("Installed code executor is unavailable.");
|
|
115
|
-
}
|
|
116
|
-
const result = await codeExecutor(source, {
|
|
117
|
-
abortSignal: context.abortSignal,
|
|
118
|
-
callId: context.callId,
|
|
119
|
-
session: context.session,
|
|
120
|
-
});
|
|
121
|
-
if (result.status === "error") {
|
|
122
|
-
yield result;
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
yield documentResult(result, source, revision);
|
|
126
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { documentExecutionInput, documentExecutionResult } from "./schemas";
|
|
3
|
-
import { CodeExecutionChart } from "@/chatjs/tools/_shared/code-execution/code-execution-chart";
|
|
4
|
-
import React from "react";
|
|
5
|
-
import type { ReadonlyNativeSurface } from "@/lib/readonly-native-surface";
|
|
6
|
-
import type { ToolRendererProps } from "@/chatjs/core/tools/define-renderer";
|
|
7
|
-
import { defineToolRenderer } from "@/chatjs/core/tools/define-renderer";
|
|
8
|
-
|
|
9
|
-
type SavedCodeRenderProps = ReadonlyNativeSurface<
|
|
10
|
-
ToolRendererProps<
|
|
11
|
-
typeof documentExecutionInput,
|
|
12
|
-
typeof documentExecutionResult
|
|
13
|
-
>
|
|
14
|
-
>;
|
|
15
|
-
|
|
16
|
-
export const SavedCodeRenderer = defineToolRenderer({
|
|
17
|
-
inputSchema: documentExecutionInput,
|
|
18
|
-
outputSchema: documentExecutionResult,
|
|
19
|
-
render: ({ tool }: SavedCodeRenderProps) => {
|
|
20
|
-
if (tool.state === "output-available") {
|
|
21
|
-
return (
|
|
22
|
-
<div className="space-y-3">
|
|
23
|
-
<p>{tool.output.message}</p>
|
|
24
|
-
<CodeExecutionChart value={tool.output.chart} />
|
|
25
|
-
</div>
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
return <output>Running saved code…</output>;
|
|
29
|
-
},
|
|
30
|
-
});
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import type { EveMessagePart } from "eve/client";
|
|
3
|
-
import React from "react";
|
|
4
|
-
import { eveCodeExecutionResult } from "./schemas";
|
|
5
|
-
import { toolOutputSchema } from "@/lib/eve/tool-result";
|
|
6
|
-
import { CodeExecutionChart } from "@/chatjs/tools/_shared/code-execution/code-execution-chart";
|
|
7
|
-
|
|
8
|
-
export const EveDocumentRunResult = ({
|
|
9
|
-
part,
|
|
10
|
-
}: Readonly<{
|
|
11
|
-
part: Extract<EveMessagePart, { type: "tool" }>;
|
|
12
|
-
}>): React.JSX.Element => {
|
|
13
|
-
if (part.state === "failed") {
|
|
14
|
-
return <p role="alert">{part.error?.message ?? "Tool failed"}</p>;
|
|
15
|
-
}
|
|
16
|
-
if (part.state === "cancelled") {
|
|
17
|
-
return <p>Document execution stopped.</p>;
|
|
18
|
-
}
|
|
19
|
-
if (part.state === "rejected") {
|
|
20
|
-
return <p>Document execution declined.</p>;
|
|
21
|
-
}
|
|
22
|
-
if (part.state !== "completed") {
|
|
23
|
-
return <output>Running saved code…</output>;
|
|
24
|
-
}
|
|
25
|
-
const result = toolOutputSchema.safeParse(part.output);
|
|
26
|
-
if (!result.success) {
|
|
27
|
-
return <p role="alert">This tool result could not be displayed.</p>;
|
|
28
|
-
}
|
|
29
|
-
if (result.data.status === "error") {
|
|
30
|
-
return <p role="alert">{result.data.error}</p>;
|
|
31
|
-
}
|
|
32
|
-
const output = eveCodeExecutionResult.safeParse(result.data.output);
|
|
33
|
-
if (output.success) {
|
|
34
|
-
return (
|
|
35
|
-
<div className="space-y-3">
|
|
36
|
-
<p>{output.data.message}</p>
|
|
37
|
-
<CodeExecutionChart value={output.data.chart} />
|
|
38
|
-
</div>
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
return <p role="alert">This saved-code result could not be displayed.</p>;
|
|
42
|
-
};
|