chat-js 1.0.0-alpha.2 → 1.0.0-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -4
- package/dist/index.js +2627 -2667
- package/package.json +10 -4
- package/templates/chat-app/.env.example +2 -8
- package/templates/chat-app/agent/agent.ts +8 -38
- package/templates/chat-app/agent/channels/eve.ts +37 -17
- package/templates/chat-app/agent/hooks/activity.ts +2 -1
- package/templates/chat-app/agent/hooks/billing.ts +11 -8
- package/templates/chat-app/agent/hooks/conversation.ts +2 -2
- package/templates/chat-app/agent/hooks/tool-selection.ts +7 -1
- package/templates/chat-app/agent/instructions/chat.ts +14 -10
- package/templates/chat-app/agent/sandbox.ts +2 -4
- package/templates/chat-app/agent/tools/installed.ts +19 -1
- package/templates/chat-app/app/(chat)/layout.tsx +10 -8
- package/templates/chat-app/app/api/agent-conversations/[id]/route.test.ts +1 -1
- package/templates/chat-app/app/api/agent-conversations/[id]/route.ts +1 -5
- package/templates/chat-app/app/api/agent-conversations/route.test.ts +31 -2
- package/templates/chat-app/app/api/agent-conversations/route.ts +10 -1
- package/templates/chat-app/app/api/agent-workspaces/[id]/route.test.ts +5 -31
- package/templates/chat-app/app/api/agent-workspaces/[id]/route.ts +2 -10
- package/templates/chat-app/app/api/eve/[...path]/route.test.ts +2 -2
- package/templates/chat-app/app/apple-icon.png +0 -0
- package/templates/chat-app/app/favicon.ico +0 -0
- package/templates/chat-app/app/icon.svg +1 -3
- package/templates/chat-app/app/opengraph-image.alt.txt +1 -0
- package/templates/chat-app/app/opengraph-image.png +0 -0
- package/templates/chat-app/chat.config.ts +0 -18
- package/templates/chat-app/chatjs/core/chat/compose.ts +35 -11
- package/templates/chat-app/chatjs/core/chat/contracts.ts +6 -0
- package/templates/chat-app/chatjs/core/installation/contracts.ts +1 -4
- package/templates/chat-app/chatjs/core/session/contracts.ts +19 -4
- package/templates/chat-app/chatjs/generated/composer-tools.ts +5 -12
- package/templates/chat-app/chatjs/generated/installed-chat-ui.ts +11 -5
- package/templates/chat-app/chatjs/generated/installed-config.ts +5 -13
- package/templates/chat-app/chatjs/generated/installed-instrumentation.ts +1 -2
- package/templates/chat-app/chatjs/generated/installed-layout.ts +1 -7
- package/templates/chat-app/chatjs/generated/installed-tools.ts +3 -3
- package/templates/chat-app/chatjs/generated/installed.ts +3 -3
- package/templates/chat-app/chatjs/generated/providers.ts +5 -11
- package/templates/chat-app/chatjs/generated/tool-availability.ts +3 -7
- package/templates/chat-app/chatjs/generated/tool-definitions.ts +3 -4
- package/templates/chat-app/chatjs/generated/tool-requirements.ts +40 -0
- package/templates/chat-app/chatjs/generated/tools.ts +7 -28
- package/templates/chat-app/chatjs/generated/ui.ts +3 -13
- package/templates/chat-app/chatjs/plugins/ai-titles/generate-title.ts +0 -2
- package/templates/chat-app/chatjs/plugins/attachment-uploads/chatjs.json +0 -1
- package/templates/chat-app/chatjs/plugins/guest-chat/session-profile.ts +2 -0
- package/templates/chat-app/chatjs/plugins/guest-chat/signed-out.tsx +70 -34
- package/templates/chat-app/chatjs/plugins/image-viewer/chatjs.json +17 -0
- package/templates/chat-app/chatjs/plugins/image-viewer/client-plugin.ts +9 -0
- package/templates/chat-app/{components → chatjs/plugins/image-viewer}/image-modal.tsx +3 -87
- package/templates/chat-app/chatjs/plugins/image-viewer/viewer-action.tsx +47 -0
- package/templates/chat-app/chatjs/plugins/mcp/composer.tsx +1 -6
- package/templates/chat-app/chatjs/plugins/projects/ui/chat-contributions.tsx +22 -2
- package/templates/chat-app/chatjs/plugins/projects/ui/sidebar-project-item.tsx +48 -33
- package/templates/chat-app/chatjs/plugins/projects/ui/sidebar-projects.tsx +41 -22
- package/templates/chat-app/chatjs/plugins/search/chat.ts +4 -0
- package/templates/chat-app/chatjs/plugins/search/search-chats.tsx +9 -3
- package/templates/chat-app/chatjs/plugins/search/search-hook.ts +5 -6
- package/templates/chat-app/chatjs/plugins/search/search-results-view.tsx +1 -1
- package/templates/chat-app/chatjs/plugins/search/search-text.ts +21 -15
- package/templates/chat-app/chatjs/plugins/search/sidebar-item.tsx +7 -1
- package/templates/chat-app/chatjs/plugins/sharing/ui/share-button.tsx +13 -3
- package/templates/chat-app/chatjs/plugins/sharing/ui/shared-page.tsx +23 -39
- package/templates/chat-app/chatjs/plugins/sharing/ui/transcript-messages.tsx +2 -2
- package/templates/chat-app/chatjs/plugins/spreadsheet-viewer/chatjs.json +18 -0
- package/templates/chat-app/chatjs/plugins/spreadsheet-viewer/client-plugin.ts +9 -0
- package/templates/chat-app/chatjs/plugins/spreadsheet-viewer/load.ts +120 -0
- package/templates/chat-app/chatjs/plugins/spreadsheet-viewer/preview.tsx +72 -0
- package/templates/chat-app/chatjs/plugins/spreadsheet-viewer/viewer-action.tsx +97 -0
- package/templates/chat-app/chatjs/plugins/video-viewer/chatjs.json +16 -0
- package/templates/chat-app/chatjs/plugins/video-viewer/client-plugin.ts +9 -0
- package/templates/chat-app/chatjs/plugins/video-viewer/viewer-action.tsx +64 -0
- package/templates/chat-app/chatjs/tools/_shared/lib/define-tool-renderer.test.ts +16 -22
- package/templates/chat-app/chatjs/tools/attach-workspace-file/attach-conversation-file.ts +34 -0
- package/templates/chat-app/chatjs/tools/attach-workspace-file/attach.ts +106 -0
- package/templates/chat-app/chatjs/tools/attach-workspace-file/chatjs.json +19 -0
- package/templates/chat-app/chatjs/tools/attach-workspace-file/import.ts +71 -0
- package/templates/chat-app/chatjs/tools/attach-workspace-file/renderer.tsx +19 -0
- package/templates/chat-app/chatjs/tools/attach-workspace-file/schemas.ts +51 -0
- package/templates/chat-app/chatjs/tools/attach-workspace-file/tool.ts +62 -0
- package/templates/chat-app/chatjs/tools/deep-research/chatjs.json +18 -4
- package/templates/chat-app/chatjs/tools/deep-research/progress-panel.tsx +2 -31
- package/templates/chat-app/chatjs/tools/deep-research/renderer.tsx +7 -19
- package/templates/chat-app/chatjs/tools/deep-research/schemas.ts +1 -46
- package/templates/chat-app/chatjs/tools/deep-research/task.tsx +0 -41
- package/templates/chat-app/chatjs/tools/deep-research/tasks.tsx +2 -7
- package/templates/chat-app/chatjs/tools/generate-image/chatjs.json +4 -1
- package/templates/chat-app/chatjs/tools/generate-image/image-generation.ts +0 -1
- package/templates/chat-app/chatjs/tools/generate-image/renderer.tsx +39 -51
- package/templates/chat-app/chatjs/tools/generate-video/chatjs.json +4 -1
- package/templates/chat-app/chatjs/tools/generate-video/renderer.tsx +22 -11
- package/templates/chat-app/components/ai-elements/response.tsx +1 -1
- package/templates/chat-app/components/app-sidebar.tsx +26 -86
- package/templates/chat-app/components/artifact-actions.tsx +19 -0
- package/templates/chat-app/components/artifact-download-action.tsx +59 -0
- package/templates/chat-app/components/attachment-card.tsx +15 -9
- package/templates/chat-app/components/chat/chat-account.tsx +189 -0
- package/templates/chat-app/components/{controlled-chat-composer.tsx → chat/chat-composer.tsx} +6 -6
- package/templates/chat-app/components/chat/chat-conversation-screen.tsx +75 -0
- package/templates/chat-app/components/chat/chat-conversation.tsx +35 -0
- package/templates/chat-app/components/chat/chat-header.tsx +52 -0
- package/templates/chat-app/components/chat/chat-message-editor.tsx +24 -0
- package/templates/chat-app/components/chat/chat-navigation.tsx +11 -0
- package/templates/chat-app/components/chat/chat-sidebar.tsx +134 -0
- package/templates/chat-app/components/{eve/eve-messages.tsx → chat/chat-transcript.tsx} +7 -28
- package/templates/chat-app/components/chat/chat-workspace.tsx +19 -0
- package/templates/chat-app/components/chat/connected-chat-sidebar.tsx +8 -0
- package/templates/chat-app/components/chat-header-view.tsx +14 -13
- package/templates/chat-app/components/chat-slots.tsx +13 -3
- package/templates/chat-app/components/composer/active-tool.tsx +3 -1
- package/templates/chat-app/components/composer/composer-menu.tsx +4 -2
- package/templates/chat-app/components/composer/control.ts +4 -1
- package/templates/chat-app/components/composer/prompt-form.tsx +1 -1
- package/templates/chat-app/components/composer/tool-availability.tsx +8 -0
- package/templates/chat-app/components/composer/tool-controls.tsx +17 -50
- package/templates/chat-app/components/composer/tool-display.ts +3 -2
- package/templates/chat-app/components/eve/bash-output.tsx +33 -0
- package/templates/chat-app/components/eve/eve-chat-page.tsx +5 -26
- package/templates/chat-app/components/eve/eve-composer.tsx +11 -8
- package/templates/chat-app/components/eve/eve-conversation.tsx +237 -309
- package/templates/chat-app/components/eve/eve-deletion-provider.tsx +1 -1
- package/templates/chat-app/components/eve/eve-history-list.tsx +7 -3
- package/templates/chat-app/components/eve/eve-message-part.tsx +28 -22
- package/templates/chat-app/components/eve/eve-pending-input.tsx +54 -1
- package/templates/chat-app/components/eve/eve-runtime-provider.tsx +0 -5
- package/templates/chat-app/components/eve/new-conversation-view.tsx +7 -3
- package/templates/chat-app/components/file-artifact-card.tsx +37 -0
- package/templates/chat-app/components/header-actions.tsx +9 -2
- package/templates/chat-app/components/image-actions.tsx +93 -0
- package/templates/chat-app/components/internal-link.tsx +15 -2
- package/templates/chat-app/components/keyboard-shortcuts.tsx +8 -2
- package/templates/chat-app/components/part/tool-activity.tsx +1 -1
- package/templates/chat-app/components/part/tool-data.tsx +1 -1
- package/templates/chat-app/components/sidebar-user-nav.tsx +35 -198
- package/templates/chat-app/components/video-player.tsx +43 -0
- package/templates/chat-app/composer-controls.ts +0 -4
- package/templates/chat-app/docs/guest-sessions.md +1 -1
- package/templates/chat-app/instrumentation.ts +2 -6
- package/templates/chat-app/integrations/chat/models.ts +10 -0
- package/templates/chat-app/integrations/tools/catalog.ts +0 -3
- package/templates/chat-app/lib/ai/app-models.test.ts +13 -1
- package/templates/chat-app/lib/ai/app-models.ts +13 -3
- package/templates/chat-app/lib/ai/tool-context.ts +1 -14
- package/templates/chat-app/lib/ai/tool-renderer-registry.ts +10 -5
- package/templates/chat-app/lib/db/eve-current-copy.ts +13 -95
- package/templates/chat-app/lib/db/eve-deletion.ts +2 -61
- package/templates/chat-app/lib/db/eve-dispatch.ts +64 -18
- package/templates/chat-app/lib/db/eve-file-purge.ts +11 -145
- package/templates/chat-app/lib/db/eve-files.ts +11 -9
- package/templates/chat-app/lib/db/eve-orphaned-files.ts +3 -22
- package/templates/chat-app/lib/db/eve-queries.ts +32 -16
- package/templates/chat-app/lib/db/eve-workspace-deletion.ts +149 -0
- package/templates/chat-app/lib/db/migrate.ts +30 -0
- package/templates/chat-app/lib/db/migrations/0024_abandoned_toxin.sql +67 -0
- package/templates/chat-app/lib/db/migrations/0025_cloudy_thunderbolt.sql +1 -0
- package/templates/chat-app/lib/db/migrations/0026_loving_mesmero.sql +3 -0
- package/templates/chat-app/lib/db/migrations/0027_misty_stephen_strange.sql +1 -0
- package/templates/chat-app/lib/db/migrations/0028_faithful_hannibal_king.sql +12 -0
- package/templates/chat-app/lib/db/migrations/meta/0024_snapshot.json +4119 -0
- package/templates/chat-app/lib/db/migrations/meta/0025_snapshot.json +3988 -0
- package/templates/chat-app/lib/db/migrations/meta/0026_snapshot.json +3686 -0
- package/templates/chat-app/lib/db/migrations/meta/0027_snapshot.json +3596 -0
- package/templates/chat-app/lib/db/migrations/meta/0028_snapshot.json +2554 -0
- package/templates/chat-app/lib/db/migrations/meta/_journal.json +35 -0
- package/templates/chat-app/lib/db/schema.ts +1 -360
- package/templates/chat-app/lib/env-schema.ts +0 -7
- package/templates/chat-app/lib/eve/application-model.ts +56 -0
- package/templates/chat-app/lib/eve/bash-result.ts +22 -0
- package/templates/chat-app/lib/eve/branch-history.test.ts +59 -0
- package/templates/chat-app/lib/eve/branch-history.ts +19 -0
- package/templates/chat-app/lib/eve/channel-files.test.ts +14 -11
- package/templates/chat-app/lib/eve/channel-files.ts +2 -12
- package/templates/chat-app/lib/eve/completed-copy-source.test.ts +81 -17
- package/templates/chat-app/lib/eve/completed-copy-source.ts +2 -6
- package/templates/chat-app/lib/eve/connection-options.ts +7 -7
- package/templates/chat-app/lib/eve/contracts.test.ts +1 -1
- package/templates/chat-app/lib/eve/copy-seed.test.ts +17 -28
- package/templates/chat-app/lib/eve/copy-seed.ts +8 -34
- package/templates/chat-app/lib/eve/copy-transcript.test.ts +143 -47
- package/templates/chat-app/lib/eve/copy-transcript.ts +20 -101
- package/templates/chat-app/lib/eve/create-conversation-operation.test.ts +11 -31
- package/templates/chat-app/lib/eve/create-conversation-operation.ts +0 -10
- package/templates/chat-app/lib/eve/delete-local-conversation.test.ts +12 -20
- package/templates/chat-app/lib/eve/delete-local-conversation.ts +2 -8
- package/templates/chat-app/lib/eve/environment.test.ts +7 -0
- package/templates/chat-app/lib/eve/environment.ts +11 -0
- package/templates/chat-app/lib/eve/execute-conversation-creation.ts +3 -55
- package/templates/chat-app/lib/eve/gateway-auth.test.ts +2 -21
- package/templates/chat-app/lib/eve/gateway-auth.ts +7 -13
- package/templates/chat-app/lib/eve/generated-files.test.ts +1 -1
- package/templates/chat-app/lib/eve/generated-files.ts +2 -2
- package/templates/chat-app/lib/eve/installed-tools.test.ts +16 -9
- package/templates/chat-app/lib/eve/lifecycle/postgres/compatibility.ts +8 -5
- package/templates/chat-app/lib/eve/lifecycle/postgres/eve-payload-purge.ts +6 -2
- package/templates/chat-app/lib/eve/lifecycle/postgres/eve-queue-fence.ts +2 -2
- package/templates/chat-app/lib/eve/lifecycle/postgres/eve-queue-inventory.ts +2 -2
- package/templates/chat-app/lib/eve/lifecycle/postgres/eve-queue-purge.ts +3 -2
- package/templates/chat-app/lib/eve/lifecycle/postgres/eve-resource-fence.ts +2 -8
- package/templates/chat-app/lib/eve/lifecycle/postgres/eve-run-inventory.ts +1 -1
- package/templates/chat-app/lib/eve/lifecycle/postgres/eve-stream-positions.ts +9 -4
- package/templates/chat-app/lib/eve/logical-chat.test.ts +4 -3
- package/templates/chat-app/lib/eve/logical-chat.ts +8 -8
- package/templates/chat-app/lib/eve/message-delivery.test.ts +1 -1
- package/templates/chat-app/lib/eve/message-display.test.ts +5 -5
- package/templates/chat-app/lib/eve/message-display.ts +31 -1
- package/templates/chat-app/lib/eve/message-tool-selection.test.ts +2 -2
- package/templates/chat-app/lib/eve/model-accounting.test.ts +28 -45
- package/templates/chat-app/lib/eve/model-accounting.ts +8 -54
- package/templates/chat-app/lib/eve/purge-files.ts +0 -13
- package/templates/chat-app/lib/eve/purge-local-resources.ts +4 -47
- package/templates/chat-app/lib/eve/readonly-message-types.ts +8 -3
- package/templates/chat-app/lib/eve/reconcile-workspace-turn.ts +2 -37
- package/templates/chat-app/lib/eve/response-group-lineage.test.ts +3 -3
- package/templates/chat-app/lib/eve/retire-session.test.ts +25 -8
- package/templates/chat-app/lib/eve/retire-session.ts +10 -4
- package/templates/chat-app/lib/eve/selected-tools.ts +7 -18
- package/templates/chat-app/lib/eve/server.test.ts +29 -3
- package/templates/chat-app/lib/eve/session-profile.test.ts +12 -9
- package/templates/chat-app/lib/eve/session-profile.ts +7 -4
- package/templates/chat-app/lib/eve/shared-messages.test.ts +3 -4
- package/templates/chat-app/lib/eve/shared-messages.ts +5 -2
- package/templates/chat-app/lib/eve/tool-accounting.test.ts +131 -0
- package/templates/chat-app/lib/eve/tool-accounting.ts +96 -0
- package/templates/chat-app/lib/eve/tool-availability.ts +4 -1
- package/templates/chat-app/lib/eve/tool-configuration.ts +29 -0
- package/templates/chat-app/lib/eve/tool-result.ts +1 -1
- package/templates/chat-app/lib/eve/turn-tools.ts +3 -12
- package/templates/chat-app/lib/eve/usage.test.ts +54 -39
- package/templates/chat-app/lib/eve/usage.ts +9 -1
- package/templates/chat-app/lib/eve/workspace-turn-evidence.test.ts +8 -6
- package/templates/chat-app/lib/eve/workspace-turn-evidence.ts +0 -5
- package/templates/chat-app/lib/required-credentials.test.ts +2 -2
- package/templates/chat-app/lib/tool-readiness.test.ts +69 -0
- package/templates/chat-app/lib/tool-readiness.ts +43 -0
- package/templates/chat-app/logo.svg +1 -1
- package/templates/chat-app/next.config.ts +1 -5
- package/templates/chat-app/oxlint.config.ts +3 -6
- package/templates/chat-app/package.json +4 -16
- package/templates/chat-app/providers/chat-models-provider.tsx +3 -3
- package/templates/chat-app/providers/default-model-provider.tsx +4 -4
- package/templates/chat-app/providers/session-context.ts +24 -0
- package/templates/chat-app/providers/session-provider.tsx +4 -21
- package/templates/chat-app/scripts/agent-status.ts +124 -0
- package/templates/chat-app/scripts/check-env.ts +0 -10
- package/templates/chat-app/scripts/dev-supervisor.mts +3 -30
- package/templates/chat-app/scripts/eve-setup.ts +3 -0
- package/templates/chat-app/tests/helpers/eve-dynamic-context.ts +2 -0
- package/templates/chat-app/tools/platform/research-updates-schema.ts +1 -20
- package/templates/chat-app/trpc/context.tsx +8 -0
- package/templates/chat-app/trpc/react.tsx +3 -4
- package/templates/chat-app/trpc/routers/eve.router.ts +2 -74
- package/templates/chat-app/vendor/workflow-world-postgres-5.1.1.tgz +0 -0
- package/templates/electron/icon.png +0 -0
- package/templates/electron/package.json +2 -1
- package/templates/electron/src/application.test.ts +347 -0
- package/templates/electron/src/application.ts +849 -0
- package/templates/electron/src/lib/auth-cookies.ts +1 -1
- package/templates/electron/src/main.test.ts +175 -0
- package/templates/electron/src/main.ts +5 -745
- package/templates/electron/src/squirrel-startup.ts +61 -0
- package/templates/chat-app/agent/hooks/persistent-sandbox.ts +0 -14
- package/templates/chat-app/app/api/agent-conversation-copies/route.test.ts +0 -190
- package/templates/chat-app/app/api/agent-conversation-copies/route.ts +0 -105
- package/templates/chat-app/chatjs/core/documents/compose-views.ts +0 -12
- package/templates/chat-app/chatjs/core/documents/contracts.ts +0 -91
- package/templates/chat-app/chatjs/core/documents/document-definition.test.ts +0 -60
- package/templates/chat-app/chatjs/core/documents/document-definition.ts +0 -55
- package/templates/chat-app/chatjs/core/documents/ui.ts +0 -67
- package/templates/chat-app/chatjs/generated/code-executor.ts +0 -6
- package/templates/chat-app/chatjs/generated/document-run.ts +0 -12
- package/templates/chat-app/chatjs/generated/document-ui.ts +0 -7
- package/templates/chat-app/chatjs/generated/documents.ts +0 -6
- package/templates/chat-app/chatjs/plugins/langfuse/chatjs.json +0 -14
- package/templates/chat-app/chatjs/plugins/langfuse/credentials.ts +0 -22
- package/templates/chat-app/chatjs/plugins/langfuse/instrumentation.ts +0 -22
- package/templates/chat-app/chatjs/plugins/langfuse/server-plugin.ts +0 -5
- package/templates/chat-app/chatjs/plugins/vercel-analytics/chatjs.json +0 -15
- package/templates/chat-app/chatjs/plugins/vercel-analytics/client-plugin.ts +0 -9
- package/templates/chat-app/chatjs/plugins/vercel-analytics/component.tsx +0 -5
- package/templates/chat-app/chatjs/plugins/vercel-speed-insights/chatjs.json +0 -15
- package/templates/chat-app/chatjs/plugins/vercel-speed-insights/client-plugin.ts +0 -9
- package/templates/chat-app/chatjs/plugins/vercel-speed-insights/component.tsx +0 -4
- package/templates/chat-app/chatjs/providers/sandbox/adapter.ts +0 -232
- package/templates/chat-app/chatjs/providers/sandbox/options.ts +0 -13
- package/templates/chat-app/chatjs/providers/sandbox/persistent.ts +0 -258
- package/templates/chat-app/chatjs/providers/sandbox/provider.ts +0 -27
- package/templates/chat-app/chatjs/providers/sandbox/vercel-sandbox-env.ts +0 -22
- package/templates/chat-app/chatjs/tools/_shared/code-execution/code-execution-chart.tsx +0 -83
- package/templates/chat-app/chatjs/tools/_shared/code-execution/interactive-chart-impl.tsx +0 -290
- package/templates/chat-app/chatjs/tools/_shared/code-execution/interactive-charts.tsx +0 -24
- package/templates/chat-app/chatjs/tools/_shared/code-execution/javascript.ts +0 -222
- package/templates/chat-app/chatjs/tools/_shared/code-execution/python.ts +0 -381
- package/templates/chat-app/chatjs/tools/_shared/code-execution/types.ts +0 -27
- package/templates/chat-app/chatjs/tools/code-documents/assistant-actions.ts +0 -16
- package/templates/chat-app/chatjs/tools/code-documents/chatjs.json +0 -20
- package/templates/chat-app/chatjs/tools/code-documents/configuration-schema.ts +0 -7
- package/templates/chat-app/chatjs/tools/code-documents/definition.ts +0 -9
- package/templates/chat-app/chatjs/tools/code-documents/document.tsx +0 -33
- package/templates/chat-app/chatjs/tools/code-documents/editor.tsx +0 -144
- package/templates/chat-app/chatjs/tools/code-documents/guidelines.ts +0 -15
- package/templates/chat-app/chatjs/tools/code-documents/tool.ts +0 -54
- package/templates/chat-app/chatjs/tools/code-execution/chatjs.json +0 -21
- package/templates/chat-app/chatjs/tools/code-execution/python.test.ts +0 -207
- package/templates/chat-app/chatjs/tools/code-execution/renderer.test.tsx +0 -142
- package/templates/chat-app/chatjs/tools/code-execution/renderer.tsx +0 -68
- package/templates/chat-app/chatjs/tools/code-execution/schemas.ts +0 -23
- package/templates/chat-app/chatjs/tools/code-execution/tool.ts +0 -93
- package/templates/chat-app/chatjs/tools/deep-research/agent.ts +0 -18
- package/templates/chat-app/chatjs/tools/deep-research/availability.ts +0 -23
- package/templates/chat-app/chatjs/tools/deep-research/configuration-schema.ts +0 -36
- package/templates/chat-app/chatjs/tools/deep-research/configuration.ts +0 -22
- package/templates/chat-app/chatjs/tools/deep-research/prompts.ts +0 -280
- package/templates/chat-app/chatjs/tools/deep-research/search-updates.ts +0 -76
- package/templates/chat-app/chatjs/tools/deep-research/steps.ts +0 -92
- package/templates/chat-app/chatjs/tools/delete-document/availability.ts +0 -13
- package/templates/chat-app/chatjs/tools/delete-document/chatjs.json +0 -9
- package/templates/chat-app/chatjs/tools/delete-document/execute.ts +0 -78
- package/templates/chat-app/chatjs/tools/delete-document/schemas.ts +0 -18
- package/templates/chat-app/chatjs/tools/delete-document/tool.ts +0 -49
- package/templates/chat-app/chatjs/tools/get-weather/chatjs.json +0 -14
- package/templates/chat-app/chatjs/tools/get-weather/definition.ts +0 -10
- package/templates/chat-app/chatjs/tools/get-weather/renderer.test.tsx +0 -57
- package/templates/chat-app/chatjs/tools/get-weather/renderer.tsx +0 -290
- package/templates/chat-app/chatjs/tools/get-weather/schemas.ts +0 -51
- package/templates/chat-app/chatjs/tools/get-weather/tool.ts +0 -34
- package/templates/chat-app/chatjs/tools/read-document/chatjs.json +0 -8
- package/templates/chat-app/chatjs/tools/read-document/tool.ts +0 -27
- package/templates/chat-app/chatjs/tools/retrieve-url/chatjs.json +0 -11
- package/templates/chat-app/chatjs/tools/retrieve-url/renderer.tsx +0 -200
- package/templates/chat-app/chatjs/tools/retrieve-url/retrieve-url-env.ts +0 -11
- package/templates/chat-app/chatjs/tools/retrieve-url/schemas.ts +0 -24
- package/templates/chat-app/chatjs/tools/retrieve-url/tool.test.ts +0 -144
- package/templates/chat-app/chatjs/tools/retrieve-url/tool.ts +0 -169
- package/templates/chat-app/chatjs/tools/saved-code-execution/chatjs.json +0 -12
- package/templates/chat-app/chatjs/tools/saved-code-execution/document-runs.ts +0 -31
- package/templates/chat-app/chatjs/tools/saved-code-execution/document.tsx +0 -84
- package/templates/chat-app/chatjs/tools/saved-code-execution/execute.ts +0 -126
- package/templates/chat-app/chatjs/tools/saved-code-execution/renderer.tsx +0 -30
- package/templates/chat-app/chatjs/tools/saved-code-execution/result.tsx +0 -42
- package/templates/chat-app/chatjs/tools/saved-code-execution/schemas.ts +0 -82
- package/templates/chat-app/chatjs/tools/saved-code-execution/tool.ts +0 -12
- package/templates/chat-app/chatjs/tools/sheet-documents/assistant-actions.ts +0 -22
- package/templates/chat-app/chatjs/tools/sheet-documents/chatjs.json +0 -20
- package/templates/chat-app/chatjs/tools/sheet-documents/configuration-schema.ts +0 -10
- package/templates/chat-app/chatjs/tools/sheet-documents/definition.ts +0 -9
- package/templates/chat-app/chatjs/tools/sheet-documents/document.tsx +0 -41
- package/templates/chat-app/chatjs/tools/sheet-documents/editor.tsx +0 -180
- package/templates/chat-app/chatjs/tools/sheet-documents/guidelines.ts +0 -5
- package/templates/chat-app/chatjs/tools/sheet-documents/tool.ts +0 -54
- package/templates/chat-app/chatjs/tools/tavily-search/chatjs.json +0 -19
- package/templates/chat-app/chatjs/tools/tavily-search/renderer.tsx +0 -25
- package/templates/chat-app/chatjs/tools/tavily-search/schemas.ts +0 -39
- package/templates/chat-app/chatjs/tools/tavily-search/tavily-search-env.ts +0 -11
- package/templates/chat-app/chatjs/tools/tavily-search/tool.test.ts +0 -114
- package/templates/chat-app/chatjs/tools/tavily-search/tool.ts +0 -143
- package/templates/chat-app/chatjs/tools/text-documents/assistant-actions.ts +0 -12
- package/templates/chat-app/chatjs/tools/text-documents/chatjs.json +0 -20
- package/templates/chat-app/chatjs/tools/text-documents/comparison.tsx +0 -72
- package/templates/chat-app/chatjs/tools/text-documents/configuration-schema.ts +0 -7
- package/templates/chat-app/chatjs/tools/text-documents/definition.ts +0 -9
- package/templates/chat-app/chatjs/tools/text-documents/diffview.tsx +0 -214
- package/templates/chat-app/chatjs/tools/text-documents/document.tsx +0 -46
- package/templates/chat-app/chatjs/tools/text-documents/editor-config.ts +0 -53
- package/templates/chat-app/chatjs/tools/text-documents/editor.tsx +0 -139
- package/templates/chat-app/chatjs/tools/text-documents/guidelines.ts +0 -7
- package/templates/chat-app/chatjs/tools/text-documents/tool.ts +0 -54
- package/templates/chat-app/chatjs/tools/word-count/chatjs.json +0 -14
- package/templates/chat-app/chatjs/tools/word-count/definition.ts +0 -10
- package/templates/chat-app/chatjs/tools/word-count/renderer.tsx +0 -64
- package/templates/chat-app/chatjs/tools/word-count/schemas.ts +0 -13
- package/templates/chat-app/chatjs/tools/word-count/tool.ts +0 -45
- package/templates/chat-app/components/chat/chat-layout.tsx +0 -129
- package/templates/chat-app/components/chat-sidebar-view.tsx +0 -53
- package/templates/chat-app/components/document-skeleton.tsx +0 -33
- package/templates/chat-app/components/eve/eve-artifact-layout.tsx +0 -722
- package/templates/chat-app/components/eve/eve-copy-button.tsx +0 -165
- package/templates/chat-app/components/eve/eve-document-actions.tsx +0 -124
- package/templates/chat-app/components/eve/eve-document-assistant-actions.tsx +0 -157
- package/templates/chat-app/components/eve/eve-document-body.tsx +0 -29
- package/templates/chat-app/components/eve/eve-document-context.tsx +0 -12
- package/templates/chat-app/components/eve/eve-document-preview.tsx +0 -128
- package/templates/chat-app/components/eve/eve-document-tool.tsx +0 -190
- package/templates/chat-app/components/eve/eve-history.tsx +0 -25
- package/templates/chat-app/components/eve/use-document-draft.ts +0 -281
- package/templates/chat-app/components/favicon-group.tsx +0 -50
- package/templates/chat-app/components/part/document-common.tsx +0 -152
- package/templates/chat-app/components/part/web-search.tsx +0 -75
- package/templates/chat-app/components/sandbox.tsx +0 -43
- package/templates/chat-app/components/source-badge.tsx +0 -50
- package/templates/chat-app/components/sources.tsx +0 -140
- package/templates/chat-app/hooks/use-artifact.tsx +0 -180
- package/templates/chat-app/integrations/documents/definitions.ts +0 -4
- package/templates/chat-app/integrations/documents/run.ts +0 -1
- package/templates/chat-app/integrations/documents/ui.ts +0 -4
- package/templates/chat-app/integrations/providers/sandbox.ts +0 -10
- package/templates/chat-app/integrations/tools/code-executor.ts +0 -1
- package/templates/chat-app/lib/ai/telemetry.ts +0 -4
- package/templates/chat-app/lib/artifacts/artifact-kind.ts +0 -8
- package/templates/chat-app/lib/artifacts/types.ts +0 -19
- package/templates/chat-app/lib/db/eve-code-sandboxes.ts +0 -197
- package/templates/chat-app/lib/db/eve-document-retention.ts +0 -36
- package/templates/chat-app/lib/db/eve-documents.ts +0 -700
- package/templates/chat-app/lib/eve/code-executor.ts +0 -32
- package/templates/chat-app/lib/eve/code-sandbox-name.test.ts +0 -60
- package/templates/chat-app/lib/eve/code-sandbox-name.ts +0 -56
- package/templates/chat-app/lib/eve/code-sandbox-ownership.ts +0 -88
- package/templates/chat-app/lib/eve/copy-input.ts +0 -11
- package/templates/chat-app/lib/eve/create-native-copy.ts +0 -38
- package/templates/chat-app/lib/eve/document-assistant-actions.test.ts +0 -48
- package/templates/chat-app/lib/eve/document-assistant-actions.ts +0 -22
- package/templates/chat-app/lib/eve/document-kind-lifecycle.test.ts +0 -148
- package/templates/chat-app/lib/eve/document-tools.ts +0 -164
- package/templates/chat-app/lib/eve/lifecycle/postgres/eve-sandbox-coverage-proof.ts +0 -140
- package/templates/chat-app/lib/eve/persistent-sandbox-store.ts +0 -621
- package/templates/chat-app/lib/eve/persistent-sandbox.test.ts +0 -209
- package/templates/chat-app/lib/eve/persistent-sandbox.ts +0 -328
- package/templates/chat-app/lib/eve/purge-code-sandboxes.test.ts +0 -125
- package/templates/chat-app/lib/eve/purge-code-sandboxes.ts +0 -83
- package/templates/chat-app/lib/eve/request-copy.test.ts +0 -95
- package/templates/chat-app/lib/eve/request-copy.ts +0 -129
- package/templates/chat-app/lib/eve/research-progress.test.ts +0 -95
- package/templates/chat-app/lib/eve/research-progress.ts +0 -42
- package/templates/chat-app/lib/eve/sandbox-environment.test.ts +0 -49
- package/templates/chat-app/lib/eve/sandbox-environment.ts +0 -29
- package/templates/chat-app/lib/eve/save-copy-operation.ts +0 -33
- package/templates/chat-app/lib/eve/save-document.ts +0 -87
- package/templates/chat-app/lib/eve/verify-local-coverage.ts +0 -84
- package/templates/chat-app/lib/eve/workspace-attachments.ts +0 -173
- package/templates/chat-app/lib/sandbox/runtime.ts +0 -12
- package/templates/chat-app/scripts/persistent-sandbox-cleanup.ts +0 -128
- package/templates/chat-app/scripts/stop-persistent-sandboxes.ts +0 -24
- package/templates/chat-app/tests/artifacts.e2e.ts +0 -7
- package/templates/chat-app/tools/platform/documents/types.ts +0 -11
- package/templates/chat-app/tools/platform/search-presentation.ts +0 -138
- package/templates/chat-app/tools/platform/steps/multi-query-web-search.test.ts +0 -45
- package/templates/chat-app/tools/platform/steps/multi-query-web-search.ts +0 -142
- package/templates/chat-app/tools/platform/steps/search-utils.ts +0 -26
- package/templates/chat-app/vendor/workflow-world-postgres-5.0.0-beta.40.tgz +0 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { defineTool } from "eve/tools";
|
|
2
|
+
import type { ToolDefinition } from "eve/tools";
|
|
3
|
+
import type { ToolOutput, ToolResult } from "./tool-result";
|
|
4
|
+
import { createToolResult } from "./tool-result";
|
|
5
|
+
import { toolResultToModelOutput } from "./tool-model-output";
|
|
6
|
+
|
|
7
|
+
type AccountingPolicy = "none" | "unknown" | { readonly costUsd: number };
|
|
8
|
+
|
|
9
|
+
const isStream = <Output>(
|
|
10
|
+
output: Output | AsyncIterable<Output>
|
|
11
|
+
): output is AsyncIterable<Output> =>
|
|
12
|
+
typeof output === "object" &&
|
|
13
|
+
output !== null &&
|
|
14
|
+
Symbol.asyncIterator in output;
|
|
15
|
+
|
|
16
|
+
/** Wrap native snapshots once; only successful completion settles a charge.
|
|
17
|
+
* Unknown provider pricing must never be reported as a zero-cost receipt.
|
|
18
|
+
*/
|
|
19
|
+
export const withToolAccounting = <Input, Output extends ToolOutput>(
|
|
20
|
+
definition: ToolDefinition<Input, Output>,
|
|
21
|
+
policy: AccountingPolicy
|
|
22
|
+
): ToolDefinition<Input, ToolResult<Output>> => {
|
|
23
|
+
const costUsd = typeof policy === "object" ? policy.costUsd : undefined;
|
|
24
|
+
const settledCostUsd = policy === "none" ? 0 : costUsd;
|
|
25
|
+
if (costUsd !== undefined && (!Number.isFinite(costUsd) || costUsd < 0)) {
|
|
26
|
+
throw new Error("Tool cost must be finite and nonnegative.");
|
|
27
|
+
}
|
|
28
|
+
const {
|
|
29
|
+
outputSchema: _outputSchema,
|
|
30
|
+
toModelOutput,
|
|
31
|
+
label,
|
|
32
|
+
endsTurn,
|
|
33
|
+
...options
|
|
34
|
+
} = definition;
|
|
35
|
+
return defineTool<Input, ToolResult<Output>>({
|
|
36
|
+
...options,
|
|
37
|
+
async *execute(input, context) {
|
|
38
|
+
context.abortSignal.throwIfAborted();
|
|
39
|
+
const result = await definition.execute(input, context);
|
|
40
|
+
if (isStream(result)) {
|
|
41
|
+
let final: { output: Output } | undefined;
|
|
42
|
+
for await (const output of result) {
|
|
43
|
+
context.abortSignal.throwIfAborted();
|
|
44
|
+
final = { output };
|
|
45
|
+
yield createToolResult(output);
|
|
46
|
+
}
|
|
47
|
+
context.abortSignal.throwIfAborted();
|
|
48
|
+
if (!final) {
|
|
49
|
+
throw new Error("Native tool completed without an output snapshot.");
|
|
50
|
+
}
|
|
51
|
+
yield createToolResult(final.output, settledCostUsd);
|
|
52
|
+
} else {
|
|
53
|
+
context.abortSignal.throwIfAborted();
|
|
54
|
+
yield createToolResult(result, settledCostUsd);
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
toModelOutput: async (result) =>
|
|
58
|
+
result.status === "success" && toModelOutput
|
|
59
|
+
? await toModelOutput(result.output)
|
|
60
|
+
: toolResultToModelOutput(result),
|
|
61
|
+
endsTurn:
|
|
62
|
+
typeof endsTurn === "function"
|
|
63
|
+
? async (result) =>
|
|
64
|
+
result.status === "success" && (await endsTurn(result.output))
|
|
65
|
+
: endsTurn,
|
|
66
|
+
label: label
|
|
67
|
+
? {
|
|
68
|
+
start: (input) => label.start(input),
|
|
69
|
+
...(label.delta
|
|
70
|
+
? {
|
|
71
|
+
delta: (
|
|
72
|
+
input: Readonly<Input>,
|
|
73
|
+
result: Readonly<ToolResult<Output>>
|
|
74
|
+
) =>
|
|
75
|
+
result.status === "success"
|
|
76
|
+
? (label.delta?.(input, result.output) ??
|
|
77
|
+
label.start(input))
|
|
78
|
+
: label.start(input),
|
|
79
|
+
}
|
|
80
|
+
: {}),
|
|
81
|
+
...(label.complete
|
|
82
|
+
? {
|
|
83
|
+
complete: (
|
|
84
|
+
input: Readonly<Input>,
|
|
85
|
+
result: Readonly<ToolResult<Output>>
|
|
86
|
+
) =>
|
|
87
|
+
result.status === "success"
|
|
88
|
+
? (label.complete?.(input, result.output) ??
|
|
89
|
+
label.start(input))
|
|
90
|
+
: label.start(input),
|
|
91
|
+
}
|
|
92
|
+
: {}),
|
|
93
|
+
}
|
|
94
|
+
: undefined,
|
|
95
|
+
});
|
|
96
|
+
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { missingToolConfiguration } from "./tool-configuration";
|
|
1
2
|
import type { LanguageModelMiddleware } from "ai";
|
|
2
3
|
import type { ToolContext } from "eve/tools";
|
|
3
4
|
|
|
@@ -27,7 +28,9 @@ export const installedToolAvailabilityMiddleware = (
|
|
|
27
28
|
Promise.resolve({
|
|
28
29
|
...params,
|
|
29
30
|
tools: params.tools?.filter(
|
|
30
|
-
(tool: { readonly name: string }) =>
|
|
31
|
+
(tool: { readonly name: string }) =>
|
|
32
|
+
!unavailable.has(tool.name) &&
|
|
33
|
+
missingToolConfiguration(tool.name).length === 0
|
|
31
34
|
),
|
|
32
35
|
}),
|
|
33
36
|
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { toolRequirements } from "../../chatjs/generated/tool-requirements";
|
|
2
|
+
import { gatewayEnvRequirements } from "../../chatjs/providers/gateway-defaults";
|
|
3
|
+
import { storageEnvRequirements } from "../../chatjs/providers/storage-options";
|
|
4
|
+
import { inspectToolConfiguration } from "../tool-readiness";
|
|
5
|
+
|
|
6
|
+
export const missingToolConfiguration = (
|
|
7
|
+
name: string,
|
|
8
|
+
environment: Readonly<NodeJS.ProcessEnv> = process.env
|
|
9
|
+
): string[] =>
|
|
10
|
+
Object.hasOwn(toolRequirements, name)
|
|
11
|
+
? inspectToolConfiguration(
|
|
12
|
+
name,
|
|
13
|
+
toolRequirements,
|
|
14
|
+
{
|
|
15
|
+
gateway: gatewayEnvRequirements,
|
|
16
|
+
storage: storageEnvRequirements,
|
|
17
|
+
},
|
|
18
|
+
environment
|
|
19
|
+
)
|
|
20
|
+
: [];
|
|
21
|
+
|
|
22
|
+
export const assertToolConfigured = (name: string): void => {
|
|
23
|
+
const missing = missingToolConfiguration(name);
|
|
24
|
+
if (missing.length > 0) {
|
|
25
|
+
throw new Error(
|
|
26
|
+
`Capability ${name} is unavailable. Configure ${missing.join("; ")} in .env.local, then run chat-js setup.`
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
@@ -60,7 +60,7 @@ const hasEveToolReceipt = (value: unknown): boolean =>
|
|
|
60
60
|
|
|
61
61
|
const createToolResult = <Output extends ToolOutput>(
|
|
62
62
|
output: Output,
|
|
63
|
-
costUsd
|
|
63
|
+
costUsd?: number,
|
|
64
64
|
updates?: readonly ToolOutput[]
|
|
65
65
|
): ToolResult<Output> => {
|
|
66
66
|
jsonOutput.parse(output);
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
+
import { missingToolConfiguration } from "./tool-configuration";
|
|
1
2
|
import { defineState } from "eve/context";
|
|
2
3
|
|
|
3
4
|
import type { UiToolName } from "@/lib/ai/types";
|
|
4
|
-
import {
|
|
5
|
-
installedDocumentKinds,
|
|
6
|
-
installedToolNames,
|
|
7
|
-
} from "@/integrations/tools/catalog";
|
|
8
|
-
|
|
9
|
-
import { documentDefinitions } from "@/integrations/documents/definitions";
|
|
10
5
|
import { selectedEveTools } from "./selected-tools";
|
|
11
6
|
|
|
12
7
|
// Set only by turn.started. Approval/reconnect authentication must not change it.
|
|
@@ -18,12 +13,8 @@ const eveTurnTool = defineState<UiToolName | null>(
|
|
|
18
13
|
const eveTurnAccount = defineState<boolean>("chatjs.turn-account", () => false);
|
|
19
14
|
|
|
20
15
|
const eveInstalledToolEnabled = (name: string): boolean => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return installedDocumentKinds.has(operation.kind);
|
|
24
|
-
}
|
|
25
|
-
if (name === "readDocument") {
|
|
26
|
-
return installedToolNames.has(name);
|
|
16
|
+
if (missingToolConfiguration(name).length > 0) {
|
|
17
|
+
return false;
|
|
27
18
|
}
|
|
28
19
|
return true;
|
|
29
20
|
};
|
|
@@ -5,6 +5,11 @@ import type { recordEveUsage } from "../db/eve-billing";
|
|
|
5
5
|
|
|
6
6
|
import { ingestEveUsage } from "./usage";
|
|
7
7
|
|
|
8
|
+
const billing = vi.hoisted((): { debit?: () => unknown } => ({
|
|
9
|
+
debit: vi.fn(),
|
|
10
|
+
}));
|
|
11
|
+
vi.mock("@/integrations/billing", () => ({ billing }));
|
|
12
|
+
|
|
8
13
|
const record = vi.hoisted(() => vi.fn<typeof recordEveUsage>());
|
|
9
14
|
const register = vi.hoisted(() => vi.fn());
|
|
10
15
|
const logError = vi.hoisted(() => vi.fn());
|
|
@@ -14,8 +19,10 @@ vi.mock("../logger", () => ({
|
|
|
14
19
|
vi.mock("../db/eve-subagents", () => ({ registerEveSubagent: register }));
|
|
15
20
|
vi.mock("../db/eve-billing", () => ({ recordEveUsage: record }));
|
|
16
21
|
beforeEach(() => {
|
|
22
|
+
billing.debit = vi.fn();
|
|
17
23
|
record.mockReset();
|
|
18
24
|
register.mockReset();
|
|
25
|
+
logError.mockReset();
|
|
19
26
|
});
|
|
20
27
|
it.each(["completed", "failed"] as const)(
|
|
21
28
|
"never charges model settlement %s through replay",
|
|
@@ -153,14 +160,16 @@ it.each([{}, { costUsd: -1 }])(
|
|
|
153
160
|
}
|
|
154
161
|
);
|
|
155
162
|
|
|
156
|
-
it(
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
"session",
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
163
|
+
it.each([{}, { answer: "ordinary data", costUsd: 5 }, null])(
|
|
164
|
+
"does not require or infer ChatJS billing from native output %j",
|
|
165
|
+
async (output) => {
|
|
166
|
+
expect(await ingestEveUsage("owner", "session", toolEvent(output))).toBe(
|
|
167
|
+
true
|
|
168
|
+
);
|
|
169
|
+
expect(record).not.toHaveBeenCalled();
|
|
170
|
+
expect(logError).not.toHaveBeenCalled();
|
|
171
|
+
}
|
|
172
|
+
);
|
|
164
173
|
it("attributes independent child tool receipts to the root turn", async () => {
|
|
165
174
|
const attribution = { sessionId: "root", turnId: "turn_7" };
|
|
166
175
|
await ingestEveUsage(
|
|
@@ -184,14 +193,7 @@ it("attributes independent child tool receipts to the root turn", async () => {
|
|
|
184
193
|
);
|
|
185
194
|
});
|
|
186
195
|
|
|
187
|
-
it("permits cursor advancement for events without
|
|
188
|
-
expect(
|
|
189
|
-
await ingestEveUsage(
|
|
190
|
-
"owner",
|
|
191
|
-
"session",
|
|
192
|
-
toolEvent({ answer: "ordinary output" })
|
|
193
|
-
)
|
|
194
|
-
).toBe(true);
|
|
196
|
+
it("permits cursor advancement for lifecycle events without tool executions", async () => {
|
|
195
197
|
expect(
|
|
196
198
|
await ingestEveUsage("owner", "session", {
|
|
197
199
|
type: "session.ended",
|
|
@@ -201,30 +203,43 @@ it("permits cursor advancement for events without a billable tool receipt", asyn
|
|
|
201
203
|
expect(record).not.toHaveBeenCalled();
|
|
202
204
|
});
|
|
203
205
|
|
|
204
|
-
it(
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
"parent",
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
206
|
+
it.each([true, false])(
|
|
207
|
+
"registers native local children regardless of billing (%s) and ignores remote sessions",
|
|
208
|
+
async (enabled) => {
|
|
209
|
+
billing.debit = enabled ? vi.fn() : undefined;
|
|
210
|
+
const event = {
|
|
211
|
+
type: "child.opened",
|
|
212
|
+
scope: { turnId: "turn" },
|
|
213
|
+
data: {
|
|
214
|
+
sessionId: "child",
|
|
215
|
+
owner: { callId: "call" },
|
|
216
|
+
name: "research",
|
|
217
|
+
stream: "/eve/v1/session/child/stream",
|
|
218
|
+
},
|
|
219
|
+
} satisfies Parameters<typeof ingestEveUsage>[2];
|
|
220
|
+
await expect(ingestEveUsage("owner", "parent", event)).resolves.toBe(true);
|
|
221
|
+
expect(register).toHaveBeenCalledExactlyOnceWith(
|
|
222
|
+
"owner",
|
|
223
|
+
"parent",
|
|
224
|
+
"child",
|
|
225
|
+
"turn"
|
|
226
|
+
);
|
|
227
|
+
await expect(
|
|
228
|
+
ingestEveUsage("owner", "parent", {
|
|
229
|
+
...event,
|
|
230
|
+
data: { ...event.data, stream: "https://remote.test/stream" },
|
|
231
|
+
})
|
|
232
|
+
).resolves.toBe(true);
|
|
233
|
+
expect(register).toHaveBeenCalledOnce();
|
|
234
|
+
expect(record).not.toHaveBeenCalled();
|
|
235
|
+
}
|
|
236
|
+
);
|
|
237
|
+
|
|
238
|
+
it("does not require a ChatJS cost receipt or write a ledger when billing is absent", async () => {
|
|
239
|
+
billing.debit = undefined;
|
|
222
240
|
await expect(
|
|
223
|
-
ingestEveUsage("owner", "
|
|
224
|
-
...event,
|
|
225
|
-
data: { ...event.data, stream: "https://remote.test/stream" },
|
|
226
|
-
})
|
|
241
|
+
ingestEveUsage("owner", "session", toolEvent({ title: "Example Domain" }))
|
|
227
242
|
).resolves.toBe(true);
|
|
228
|
-
expect(register).toHaveBeenCalledOnce();
|
|
229
243
|
expect(record).not.toHaveBeenCalled();
|
|
244
|
+
expect(logError).not.toHaveBeenCalled();
|
|
230
245
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { billing } from "@/integrations/billing";
|
|
1
2
|
import type { SessionEvent as UsageEventReader } from "eve/client";
|
|
2
3
|
import { recordEveUsage } from "@/lib/db/eve-billing";
|
|
3
4
|
import { registerEveSubagent } from "@/lib/db/eve-subagents";
|
|
@@ -17,10 +18,12 @@ const ingestToolUsage = async (
|
|
|
17
18
|
event: Extract<UsageEventReader, { type: "call.settled" }>,
|
|
18
19
|
attribution?: Readonly<{ sessionId: string; turnId: string }>
|
|
19
20
|
): Promise<boolean> => {
|
|
20
|
-
|
|
21
|
+
// Native capabilities are unmetered by ChatJS unless they explicitly opt into
|
|
22
|
+
// its receipt protocol. Their service/compute costs are not inferred as zero.
|
|
21
23
|
if (!hasEveToolReceipt(event.data.output)) {
|
|
22
24
|
return true;
|
|
23
25
|
}
|
|
26
|
+
const result = toolResultSchema.safeParse(event.data.output);
|
|
24
27
|
const recordedCost = result.success ? result.data.usage.costUsd : undefined;
|
|
25
28
|
const turnId = attribution?.turnId ?? event.scope?.turnId;
|
|
26
29
|
if (turnId === undefined || turnId === "") {
|
|
@@ -68,6 +71,11 @@ export const ingestEveUsage = async (
|
|
|
68
71
|
await registerEveSubagent(ownerId, sessionId, event.data.sessionId, turnId);
|
|
69
72
|
}
|
|
70
73
|
|
|
74
|
+
// Replay and deletion share this path even when application billing is absent.
|
|
75
|
+
if (billing.debit === undefined) {
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
|
|
71
79
|
if (event.type === "call.settled") {
|
|
72
80
|
return await ingestToolUsage(
|
|
73
81
|
ownerId,
|
|
@@ -47,7 +47,7 @@ const settled: WorkspaceTurnEvent = {
|
|
|
47
47
|
};
|
|
48
48
|
const prefix = [session, admitted, started, consumed];
|
|
49
49
|
const completed = [...prefix, handled, settled];
|
|
50
|
-
const operation = {
|
|
50
|
+
const operation = { deliveryId: "exact" } as const;
|
|
51
51
|
|
|
52
52
|
it("requires the exact consumed delivery and its settled turn", () => {
|
|
53
53
|
expect(hasSettledWorkspaceOperation(operation, completed)).toBe(true);
|
|
@@ -103,11 +103,13 @@ it("accepts settled cancellation/failure but not a cancellation command receipt"
|
|
|
103
103
|
);
|
|
104
104
|
});
|
|
105
105
|
|
|
106
|
-
it("
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
expect(hasSettledWorkspaceOperation(
|
|
106
|
+
it("never releases a branch before its initial delivery is consumed and settled", () => {
|
|
107
|
+
expect(hasSettledWorkspaceOperation({ deliveryId: null }, [session])).toBe(
|
|
108
|
+
false
|
|
109
|
+
);
|
|
110
|
+
expect(hasSettledWorkspaceOperation({ deliveryId: "exact" }, [session])).toBe(
|
|
111
|
+
false
|
|
112
|
+
);
|
|
111
113
|
});
|
|
112
114
|
|
|
113
115
|
it("rejects settlement before consumption or for another turn", () => {
|
|
@@ -20,18 +20,13 @@ export const hasSettledWorkspaceSession = (
|
|
|
20
20
|
|
|
21
21
|
export const hasSettledWorkspaceOperation = (
|
|
22
22
|
operation: {
|
|
23
|
-
readonly kind: "create" | "copy" | "send";
|
|
24
23
|
readonly deliveryId: string | null;
|
|
25
|
-
readonly seeded: boolean;
|
|
26
24
|
},
|
|
27
25
|
events: readonly WorkspaceTurnEvent[]
|
|
28
26
|
): boolean => {
|
|
29
27
|
if (!hasSettledWorkspaceSession(events)) {
|
|
30
28
|
return false;
|
|
31
29
|
}
|
|
32
|
-
if (operation.kind === "copy" || operation.seeded) {
|
|
33
|
-
return true;
|
|
34
|
-
}
|
|
35
30
|
const consumedIndex = events.findIndex(
|
|
36
31
|
(event) =>
|
|
37
32
|
event.type === "delivery.consumed" &&
|
|
@@ -8,7 +8,7 @@ import { assert, expect, test } from "vitest";
|
|
|
8
8
|
test("reports missing groups explicitly without exposing supplied secrets", () => {
|
|
9
9
|
try {
|
|
10
10
|
requireCredentials(
|
|
11
|
-
"
|
|
11
|
+
"custom-service",
|
|
12
12
|
[
|
|
13
13
|
{ options: [["PUBLIC_KEY", "SECRET_KEY"], ["TOKEN"]] },
|
|
14
14
|
{ options: [["HOST"]] },
|
|
@@ -22,7 +22,7 @@ test("reports missing groups explicitly without exposing supplied secrets", () =
|
|
|
22
22
|
throw error;
|
|
23
23
|
}
|
|
24
24
|
expect(error.code).toBe("CHATJS_MISSING_CREDENTIALS");
|
|
25
|
-
expect(error.integration).toBe("
|
|
25
|
+
expect(error.integration).toBe("custom-service");
|
|
26
26
|
expect(error.requirements).toHaveLength(1);
|
|
27
27
|
expect(error.message).toContain("PUBLIC_KEY + SECRET_KEY or TOKEN");
|
|
28
28
|
expect(error.message).not.toContain("private-value");
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { expect, it } from "vitest";
|
|
2
|
+
import { inspectToolConfiguration } from "./tool-readiness";
|
|
3
|
+
import type { ToolRequirements } from "./tool-readiness";
|
|
4
|
+
|
|
5
|
+
const providers = {
|
|
6
|
+
gateway: [{ options: [["MODEL_KEY"]] }],
|
|
7
|
+
storage: [{ options: [["STORAGE_KEY"]] }],
|
|
8
|
+
};
|
|
9
|
+
const tool = (overrides: Partial<ToolRequirements> = {}): ToolRequirements => ({
|
|
10
|
+
id: "test",
|
|
11
|
+
envRequirements: [],
|
|
12
|
+
requiresTools: [],
|
|
13
|
+
requiresGateway: false,
|
|
14
|
+
requiresStorage: false,
|
|
15
|
+
...overrides,
|
|
16
|
+
});
|
|
17
|
+
it("checks alternative credentials and dependencies without exposing their values", () => {
|
|
18
|
+
const tools = {
|
|
19
|
+
search: tool({
|
|
20
|
+
id: "search",
|
|
21
|
+
envRequirements: [{ options: [["SEARCH_KEY"], ["USER", "TOKEN"]] }],
|
|
22
|
+
}),
|
|
23
|
+
research: tool({
|
|
24
|
+
requiresTools: ["search"],
|
|
25
|
+
requiresStorage: true,
|
|
26
|
+
requiresGateway: true,
|
|
27
|
+
}),
|
|
28
|
+
};
|
|
29
|
+
const env: NodeJS.ProcessEnv = {
|
|
30
|
+
NODE_ENV: "test",
|
|
31
|
+
USER: "private-user",
|
|
32
|
+
MODEL_KEY: "secret-model-key",
|
|
33
|
+
STORAGE_KEY: "secret-storage-key",
|
|
34
|
+
};
|
|
35
|
+
expect(inspectToolConfiguration("research", tools, providers, env)).toEqual([
|
|
36
|
+
"search: SEARCH_KEY or USER + TOKEN",
|
|
37
|
+
]);
|
|
38
|
+
expect(
|
|
39
|
+
inspectToolConfiguration("research", tools, providers, {
|
|
40
|
+
...env,
|
|
41
|
+
TOKEN: "secret-token",
|
|
42
|
+
})
|
|
43
|
+
).toEqual([]);
|
|
44
|
+
expect(
|
|
45
|
+
inspectToolConfiguration("research", tools, providers, {
|
|
46
|
+
...env,
|
|
47
|
+
SEARCH_KEY: "secret-search-key",
|
|
48
|
+
})
|
|
49
|
+
).toEqual([]);
|
|
50
|
+
expect(env).not.toHaveProperty("TOKEN");
|
|
51
|
+
});
|
|
52
|
+
it("fails closed for absent dependencies and cycles", () => {
|
|
53
|
+
expect(
|
|
54
|
+
inspectToolConfiguration(
|
|
55
|
+
"runner",
|
|
56
|
+
{ runner: tool({ requiresTools: ["absent"] }) },
|
|
57
|
+
providers,
|
|
58
|
+
{ NODE_ENV: "test" }
|
|
59
|
+
)
|
|
60
|
+
).toEqual(["Required capability absent is not installed."]);
|
|
61
|
+
expect(
|
|
62
|
+
inspectToolConfiguration(
|
|
63
|
+
"cycle",
|
|
64
|
+
{ cycle: tool({ requiresTools: ["cycle"] }) },
|
|
65
|
+
providers,
|
|
66
|
+
{ NODE_ENV: "test" }
|
|
67
|
+
)
|
|
68
|
+
).toEqual(["Capability dependency cycle at cycle."]);
|
|
69
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { getMissingRequirement } from "./config-requirements";
|
|
2
|
+
import type { EnvRequirement } from "./config-requirements";
|
|
3
|
+
|
|
4
|
+
export interface ToolRequirements {
|
|
5
|
+
readonly id: string;
|
|
6
|
+
readonly envRequirements: readonly EnvRequirement[];
|
|
7
|
+
readonly requiresTools: readonly string[];
|
|
8
|
+
readonly requiresGateway: boolean;
|
|
9
|
+
readonly requiresStorage: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** Configuration presence only. No credential values, network requests, or connection claims. */
|
|
13
|
+
export const inspectToolConfiguration = (
|
|
14
|
+
name: string,
|
|
15
|
+
tools: Readonly<Partial<Record<string, ToolRequirements>>>,
|
|
16
|
+
providers: Readonly<Record<"gateway" | "storage", readonly EnvRequirement[]>>,
|
|
17
|
+
environment: Readonly<NodeJS.ProcessEnv>
|
|
18
|
+
): string[] => {
|
|
19
|
+
const visiting = new Set<string>();
|
|
20
|
+
const inspect = (key: string): string[] => {
|
|
21
|
+
const definition = tools[key];
|
|
22
|
+
if (!definition) {
|
|
23
|
+
return [`Required capability ${key} is not installed.`];
|
|
24
|
+
}
|
|
25
|
+
if (visiting.has(key)) {
|
|
26
|
+
return [`Capability dependency cycle at ${key}.`];
|
|
27
|
+
}
|
|
28
|
+
visiting.add(key);
|
|
29
|
+
const requirements = [
|
|
30
|
+
...definition.envRequirements,
|
|
31
|
+
...(definition.requiresGateway ? providers.gateway : []),
|
|
32
|
+
...(definition.requiresStorage ? providers.storage : []),
|
|
33
|
+
];
|
|
34
|
+
const missing = requirements.flatMap((requirement) => {
|
|
35
|
+
const message = getMissingRequirement(requirement, environment);
|
|
36
|
+
return message === null ? [] : [`${definition.id}: ${message}`];
|
|
37
|
+
});
|
|
38
|
+
const dependencies = definition.requiresTools.flatMap(inspect);
|
|
39
|
+
visiting.delete(key);
|
|
40
|
+
return [...missing, ...dependencies];
|
|
41
|
+
};
|
|
42
|
+
return [...new Set(inspect(name))];
|
|
43
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 30 30" fill="#e8e8df"><path d="M1 1h8v8H1zm10 0h8v8h-8zm10 0h8v8h-8zM1 11h8v8H1zm0 10h8v8H1zm10 0h8v8h-8zm10 0h8v8h-8z"/></svg>
|
|
@@ -4,11 +4,7 @@ import { withEve } from "eve/next";
|
|
|
4
4
|
const nextConfig: NextConfig = {
|
|
5
5
|
cacheComponents: true,
|
|
6
6
|
experimental: {
|
|
7
|
-
optimizePackageImports: [
|
|
8
|
-
"react-tweet",
|
|
9
|
-
"echarts-for-react",
|
|
10
|
-
"lucide-react",
|
|
11
|
-
],
|
|
7
|
+
optimizePackageImports: ["react-tweet", "lucide-react"],
|
|
12
8
|
staleTimes: {
|
|
13
9
|
dynamic: 0,
|
|
14
10
|
static: 30,
|
|
@@ -25,13 +25,10 @@ export default defineConfig({
|
|
|
25
25
|
],
|
|
26
26
|
options: { typeAware: true },
|
|
27
27
|
overrides: [
|
|
28
|
-
// EVE uses discovered tool filenames verbatim as IDs for deepResearch
|
|
29
|
-
// Oxlint 1.82 reports filename-case at offset zero and ignores source directives; a native probe reproduced this for
|
|
28
|
+
// EVE uses discovered tool filenames verbatim as IDs for deepResearch; confirm_note is preserved by its explicit map key.
|
|
29
|
+
// Oxlint 1.82 reports filename-case at offset zero and ignores source directives; a native probe reproduced this for the remaining exception.
|
|
30
30
|
{
|
|
31
|
-
files: [
|
|
32
|
-
"agent/tools/deepResearch.ts",
|
|
33
|
-
"agent/subagents/researcher/tools/webSearch.ts",
|
|
34
|
-
],
|
|
31
|
+
files: ["agent/tools/deepResearch.ts"],
|
|
35
32
|
rules: { "unicorn/filename-case": "off" },
|
|
36
33
|
},
|
|
37
34
|
],
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"private": true,
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"prebuild": "bun --filter @chat-js/gateways
|
|
7
|
+
"prebuild": "bun --filter @chat-js/gateways build && bun run check-env",
|
|
8
8
|
"dev": "bun run check-env && EVE_SANDBOX_IMAGE_TAG=${EVE_SANDBOX_IMAGE_TAG:-0.80.1} next dev",
|
|
9
9
|
"dev:inspect": "bun run check-env && EVE_SANDBOX_IMAGE_TAG=${EVE_SANDBOX_IMAGE_TAG:-0.80.1} next dev --inspect",
|
|
10
10
|
"build": "tsx lib/db/migrate.ts --deployment && bun run eve:build && EVE_SANDBOX_IMAGE_TAG=${EVE_SANDBOX_IMAGE_TAG:-0.80.1} next build",
|
|
@@ -48,21 +48,15 @@
|
|
|
48
48
|
"@ai-sdk/devtools": "1.0.40",
|
|
49
49
|
"@ai-sdk/gateway": "4.0.110",
|
|
50
50
|
"@ai-sdk/mcp": "2.0.73",
|
|
51
|
-
"@ai-sdk/otel": "1.0.137",
|
|
52
51
|
"@ai-sdk/provider": "4.0.26",
|
|
53
52
|
"@ai-sdk/provider-utils": "5.0.58",
|
|
54
53
|
"@base-ui/react": "^1.9.0",
|
|
55
54
|
"@better-auth/core": "1.6.2",
|
|
56
55
|
"@better-auth/electron": "1.6.2",
|
|
57
56
|
"@chat-js/gateways": "workspace:*",
|
|
58
|
-
"@chat-js/sandboxes": "0.2.0",
|
|
59
57
|
"@hookform/resolvers": "^5.2.1",
|
|
60
58
|
"@lexical/react": "^0.32.1",
|
|
61
|
-
"@mendable/firecrawl-js": "1.29.1",
|
|
62
59
|
"@modelcontextprotocol/sdk": "^1.24.3",
|
|
63
|
-
"@opentelemetry/api-logs": "^0.200.0",
|
|
64
|
-
"@opentelemetry/instrumentation": "^0.200.0",
|
|
65
|
-
"@opentelemetry/sdk-logs": "^0.200.0",
|
|
66
60
|
"@shadcn/react": "0.3.1",
|
|
67
61
|
"@streamdown/code": "^1.1.1",
|
|
68
62
|
"@streamdown/math": "^1.0.2",
|
|
@@ -71,18 +65,14 @@
|
|
|
71
65
|
"@t3-oss/env-nextjs": "^0.13.8",
|
|
72
66
|
"@tanstack/react-query": "^5.104.1",
|
|
73
67
|
"@tanstack/react-query-devtools": "^5.80.3",
|
|
74
|
-
"@tavily/core": "^0.3.3",
|
|
75
68
|
"@trpc/client": "^11.1.2",
|
|
76
69
|
"@trpc/server": "^11.1.2",
|
|
77
70
|
"@trpc/tanstack-react-query": "^11.1.2",
|
|
78
71
|
"@types/uuid": "^10.0.0",
|
|
79
|
-
"@vercel/analytics": "^1.5.0",
|
|
80
72
|
"@vercel/blob": "2.4.0",
|
|
73
|
+
"@vercel/connect": "2.9.2",
|
|
81
74
|
"@vercel/oidc": "3.2.0",
|
|
82
|
-
"@
|
|
83
|
-
"@vercel/sandbox": "3.3.0",
|
|
84
|
-
"@vercel/speed-insights": "^1.3.1",
|
|
85
|
-
"@workflow/world-postgres": "file:vendor/workflow-world-postgres-5.0.0-beta.40.tgz",
|
|
75
|
+
"@workflow/world-postgres": "file:vendor/workflow-world-postgres-5.1.1.tgz",
|
|
86
76
|
"ai": "7.0.137",
|
|
87
77
|
"ajv": "8.18.0",
|
|
88
78
|
"better-auth": "1.6.2",
|
|
@@ -94,12 +84,10 @@
|
|
|
94
84
|
"date-fns": "^4.1.0",
|
|
95
85
|
"dotenv": "^17.2.3",
|
|
96
86
|
"drizzle-orm": "^0.45.1",
|
|
97
|
-
"eve": "npm:@chat-js/eve@1.0.0-rc.
|
|
87
|
+
"eve": "npm:@chat-js/eve@1.0.0-rc.6-chatjs.1",
|
|
98
88
|
"fast-deep-equal": "^3.1.3",
|
|
99
89
|
"files-sdk": "2.5.0",
|
|
100
90
|
"guarded-fetch": "^0.1.4",
|
|
101
|
-
"langfuse": "^3.37.0",
|
|
102
|
-
"langfuse-vercel": "^3.37.0",
|
|
103
91
|
"lexical": "^0.32.1",
|
|
104
92
|
"lucide-react": "0.553.0",
|
|
105
93
|
"motion": "^12.23.24",
|
|
@@ -15,9 +15,9 @@ interface ChatModelsContextType {
|
|
|
15
15
|
readonly models: readonly ReadonlyNativeSurface<AppModelDefinition>[];
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
const ChatModelsContext = createContext<
|
|
19
|
-
undefined
|
|
20
|
-
);
|
|
18
|
+
export const ChatModelsContext = createContext<
|
|
19
|
+
ChatModelsContextType | undefined
|
|
20
|
+
>(undefined);
|
|
21
21
|
|
|
22
22
|
const ChatModelsProvider = ({
|
|
23
23
|
children,
|