@chat-js/registry 0.2.0-beta.1 → 0.2.0-beta.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 +14 -10
- package/dist/r/ai-titles.json +9 -9
- package/dist/r/akamai-storage.json +1 -1
- package/dist/r/alibaba-storage.json +1 -1
- package/dist/r/appwrite-storage.json +1 -1
- package/dist/r/archil-storage.json +1 -1
- package/dist/r/attachment-uploads.json +19 -20
- package/dist/r/azure-storage.json +1 -1
- package/dist/r/backblaze-b2-storage.json +1 -1
- package/dist/r/base/ai-titles.json +9 -9
- package/dist/r/base/akamai-storage.json +1 -1
- package/dist/r/base/alibaba-storage.json +1 -1
- package/dist/r/base/appwrite-storage.json +1 -1
- package/dist/r/base/archil-storage.json +1 -1
- package/dist/r/base/attachment-uploads.json +19 -20
- package/dist/r/base/azure-storage.json +1 -1
- package/dist/r/base/backblaze-b2-storage.json +1 -1
- package/dist/r/base/bunny-storage-storage.json +1 -1
- package/dist/r/base/cloudinary-storage.json +1 -1
- package/dist/r/base/code-documents.json +17 -12
- package/dist/r/base/code-execution-runtime.json +3 -3
- package/dist/r/base/code-execution-ui.json +3 -3
- package/dist/r/base/code-execution.json +7 -7
- package/dist/r/base/credits.json +22 -22
- package/dist/r/base/daytona-sandbox.json +3 -3
- package/dist/r/base/deep-research.json +42 -47
- package/dist/r/base/delete-document.json +7 -7
- package/dist/r/base/desktop.json +144 -0
- package/dist/r/base/digitalocean-spaces-storage.json +1 -1
- package/dist/r/base/dropbox-storage.json +1 -1
- package/dist/r/base/exoscale-storage.json +1 -1
- package/dist/r/base/feedback.json +25 -25
- package/dist/r/base/filebase-storage.json +1 -1
- package/dist/r/base/firebase-storage-storage.json +1 -1
- package/dist/r/base/firecrawl-search.json +7 -7
- package/dist/r/base/followup-suggestions.json +40 -40
- package/dist/r/base/ftp-storage.json +1 -1
- package/dist/r/base/gcs-storage.json +1 -1
- package/dist/r/base/generate-image.json +12 -12
- package/dist/r/base/generate-video.json +7 -7
- package/dist/r/base/get-weather.json +14 -7
- package/dist/r/base/google-drive-storage.json +1 -1
- package/dist/r/base/guest-chat.json +181 -0
- package/dist/r/base/hetzner-storage.json +1 -1
- package/dist/r/base/ibm-cos-storage.json +1 -1
- package/dist/r/base/idrive-e2-storage.json +1 -1
- package/dist/r/base/langfuse.json +11 -11
- package/dist/r/base/litellm-gateway.json +1 -4
- package/dist/r/base/mcp.json +123 -93
- package/dist/r/base/memory-storage.json +1 -1
- package/dist/r/base/minio-storage.json +1 -1
- package/dist/r/base/model-preferences.json +36 -29
- package/dist/r/base/neon-storage.json +1 -1
- package/dist/r/base/netlify-blobs-storage.json +1 -1
- package/dist/r/base/onedrive-storage.json +1 -1
- package/dist/r/base/openai-compatible-gateway.json +1 -4
- package/dist/r/base/openai-gateway.json +1 -4
- package/dist/r/base/openrouter-gateway.json +1 -5
- package/dist/r/base/oracle-cloud-storage.json +1 -1
- package/dist/r/base/ovhcloud-storage.json +1 -1
- package/dist/r/base/pocketbase-storage.json +1 -1
- package/dist/r/base/projects.json +104 -83
- package/dist/r/base/r2-storage.json +1 -1
- package/dist/r/base/read-document.json +3 -3
- package/dist/r/base/registry.json +885 -496
- package/dist/r/base/retrieve-url.json +11 -8
- package/dist/r/base/s3-storage.json +1 -1
- package/dist/r/base/saved-code-execution.json +14 -14
- package/dist/r/base/scaleway-storage.json +1 -1
- package/dist/r/base/search.json +70 -40
- package/dist/r/base/sftp-storage.json +1 -1
- package/dist/r/base/sharepoint-storage.json +1 -1
- package/dist/r/base/sharing.json +54 -38
- package/dist/r/base/sheet-documents.json +17 -12
- package/dist/r/base/storj-storage.json +1 -1
- package/dist/r/base/supabase-storage.json +1 -1
- package/dist/r/base/tavily-search.json +7 -7
- package/dist/r/base/tencent-storage.json +1 -1
- package/dist/r/base/text-documents.json +20 -15
- package/dist/r/base/tigris-storage.json +1 -1
- package/dist/r/base/uploadthing-storage.json +1 -1
- package/dist/r/base/vercel-analytics.json +8 -8
- package/dist/r/base/vercel-blob-storage.json +1 -1
- package/dist/r/base/vercel-gateway.json +1 -5
- package/dist/r/base/vercel-sandbox.json +4 -4
- package/dist/r/base/vercel-speed-insights.json +8 -8
- package/dist/r/base/vultr-storage.json +1 -1
- package/dist/r/base/wasabi-storage.json +1 -1
- package/dist/r/base/webdav-storage.json +1 -1
- package/dist/r/base/word-count.json +15 -8
- package/dist/r/base/yandex-storage.json +1 -1
- package/dist/r/bunny-storage-storage.json +1 -1
- package/dist/r/cloudinary-storage.json +1 -1
- package/dist/r/code-documents.json +17 -12
- package/dist/r/code-execution-runtime.json +3 -3
- package/dist/r/code-execution-ui.json +3 -3
- package/dist/r/code-execution.json +7 -7
- package/dist/r/credits.json +22 -22
- package/dist/r/daytona-sandbox.json +3 -3
- package/dist/r/deep-research.json +42 -47
- package/dist/r/delete-document.json +7 -7
- package/dist/r/desktop.json +144 -0
- package/dist/r/digitalocean-spaces-storage.json +1 -1
- package/dist/r/dropbox-storage.json +1 -1
- package/dist/r/exoscale-storage.json +1 -1
- package/dist/r/feedback.json +25 -25
- package/dist/r/filebase-storage.json +1 -1
- package/dist/r/firebase-storage-storage.json +1 -1
- package/dist/r/firecrawl-search.json +7 -7
- package/dist/r/followup-suggestions.json +40 -40
- package/dist/r/ftp-storage.json +1 -1
- package/dist/r/gcs-storage.json +1 -1
- package/dist/r/generate-image.json +12 -12
- package/dist/r/generate-video.json +7 -7
- package/dist/r/get-weather.json +14 -7
- package/dist/r/google-drive-storage.json +1 -1
- package/dist/r/guest-chat.json +181 -0
- package/dist/r/hetzner-storage.json +1 -1
- package/dist/r/ibm-cos-storage.json +1 -1
- package/dist/r/idrive-e2-storage.json +1 -1
- package/dist/r/langfuse.json +11 -11
- package/dist/r/litellm-gateway.json +1 -4
- package/dist/r/mcp.json +123 -93
- package/dist/r/memory-storage.json +1 -1
- package/dist/r/minio-storage.json +1 -1
- package/dist/r/model-preferences.json +36 -29
- package/dist/r/neon-storage.json +1 -1
- package/dist/r/netlify-blobs-storage.json +1 -1
- package/dist/r/onedrive-storage.json +1 -1
- package/dist/r/openai-compatible-gateway.json +1 -4
- package/dist/r/openai-gateway.json +1 -4
- package/dist/r/openrouter-gateway.json +1 -5
- package/dist/r/oracle-cloud-storage.json +1 -1
- package/dist/r/ovhcloud-storage.json +1 -1
- package/dist/r/pocketbase-storage.json +1 -1
- package/dist/r/projects.json +104 -83
- package/dist/r/r2-storage.json +1 -1
- package/dist/r/radix/ai-titles.json +9 -9
- package/dist/r/radix/akamai-storage.json +1 -1
- package/dist/r/radix/alibaba-storage.json +1 -1
- package/dist/r/radix/appwrite-storage.json +1 -1
- package/dist/r/radix/archil-storage.json +1 -1
- package/dist/r/radix/attachment-uploads.json +19 -20
- package/dist/r/radix/azure-storage.json +1 -1
- package/dist/r/radix/backblaze-b2-storage.json +1 -1
- package/dist/r/radix/bunny-storage-storage.json +1 -1
- package/dist/r/radix/cloudinary-storage.json +1 -1
- package/dist/r/radix/code-documents.json +17 -12
- package/dist/r/radix/code-execution-runtime.json +3 -3
- package/dist/r/radix/code-execution-ui.json +3 -3
- package/dist/r/radix/code-execution.json +7 -7
- package/dist/r/radix/credits.json +22 -22
- package/dist/r/radix/daytona-sandbox.json +3 -3
- package/dist/r/radix/deep-research.json +42 -47
- package/dist/r/radix/delete-document.json +7 -7
- package/dist/r/radix/desktop.json +144 -0
- package/dist/r/radix/digitalocean-spaces-storage.json +1 -1
- package/dist/r/radix/dropbox-storage.json +1 -1
- package/dist/r/radix/exoscale-storage.json +1 -1
- package/dist/r/radix/feedback.json +25 -25
- package/dist/r/radix/filebase-storage.json +1 -1
- package/dist/r/radix/firebase-storage-storage.json +1 -1
- package/dist/r/radix/firecrawl-search.json +7 -7
- package/dist/r/radix/followup-suggestions.json +40 -40
- package/dist/r/radix/ftp-storage.json +1 -1
- package/dist/r/radix/gcs-storage.json +1 -1
- package/dist/r/radix/generate-image.json +12 -12
- package/dist/r/radix/generate-video.json +7 -7
- package/dist/r/radix/get-weather.json +14 -7
- package/dist/r/radix/google-drive-storage.json +1 -1
- package/dist/r/radix/guest-chat.json +181 -0
- package/dist/r/radix/hetzner-storage.json +1 -1
- package/dist/r/radix/ibm-cos-storage.json +1 -1
- package/dist/r/radix/idrive-e2-storage.json +1 -1
- package/dist/r/radix/langfuse.json +11 -11
- package/dist/r/radix/litellm-gateway.json +1 -4
- package/dist/r/radix/mcp.json +123 -93
- package/dist/r/radix/memory-storage.json +1 -1
- package/dist/r/radix/minio-storage.json +1 -1
- package/dist/r/radix/model-preferences.json +36 -29
- package/dist/r/radix/neon-storage.json +1 -1
- package/dist/r/radix/netlify-blobs-storage.json +1 -1
- package/dist/r/radix/onedrive-storage.json +1 -1
- package/dist/r/radix/openai-compatible-gateway.json +1 -4
- package/dist/r/radix/openai-gateway.json +1 -4
- package/dist/r/radix/openrouter-gateway.json +1 -5
- package/dist/r/radix/oracle-cloud-storage.json +1 -1
- package/dist/r/radix/ovhcloud-storage.json +1 -1
- package/dist/r/radix/pocketbase-storage.json +1 -1
- package/dist/r/radix/projects.json +104 -83
- package/dist/r/radix/r2-storage.json +1 -1
- package/dist/r/radix/read-document.json +3 -3
- package/dist/r/radix/registry.json +885 -496
- package/dist/r/radix/retrieve-url.json +11 -8
- package/dist/r/radix/s3-storage.json +1 -1
- package/dist/r/radix/saved-code-execution.json +14 -14
- package/dist/r/radix/scaleway-storage.json +1 -1
- package/dist/r/radix/search.json +70 -40
- package/dist/r/radix/sftp-storage.json +1 -1
- package/dist/r/radix/sharepoint-storage.json +1 -1
- package/dist/r/radix/sharing.json +54 -38
- package/dist/r/radix/sheet-documents.json +17 -12
- package/dist/r/radix/storj-storage.json +1 -1
- package/dist/r/radix/supabase-storage.json +1 -1
- package/dist/r/radix/tavily-search.json +7 -7
- package/dist/r/radix/tencent-storage.json +1 -1
- package/dist/r/radix/text-documents.json +20 -15
- package/dist/r/radix/tigris-storage.json +1 -1
- package/dist/r/radix/uploadthing-storage.json +1 -1
- package/dist/r/radix/vercel-analytics.json +8 -8
- package/dist/r/radix/vercel-blob-storage.json +1 -1
- package/dist/r/radix/vercel-gateway.json +1 -5
- package/dist/r/radix/vercel-sandbox.json +4 -4
- package/dist/r/radix/vercel-speed-insights.json +8 -8
- package/dist/r/radix/vultr-storage.json +1 -1
- package/dist/r/radix/wasabi-storage.json +1 -1
- package/dist/r/radix/webdav-storage.json +1 -1
- package/dist/r/radix/word-count.json +15 -8
- package/dist/r/radix/yandex-storage.json +1 -1
- package/dist/r/read-document.json +3 -3
- package/dist/r/registry.json +885 -496
- package/dist/r/retrieve-url.json +11 -8
- package/dist/r/s3-storage.json +1 -1
- package/dist/r/saved-code-execution.json +14 -14
- package/dist/r/scaleway-storage.json +1 -1
- package/dist/r/search.json +70 -40
- package/dist/r/sftp-storage.json +1 -1
- package/dist/r/sharepoint-storage.json +1 -1
- package/dist/r/sharing.json +54 -38
- package/dist/r/sheet-documents.json +17 -12
- package/dist/r/storj-storage.json +1 -1
- package/dist/r/supabase-storage.json +1 -1
- package/dist/r/tavily-search.json +7 -7
- package/dist/r/tencent-storage.json +1 -1
- package/dist/r/text-documents.json +20 -15
- package/dist/r/tigris-storage.json +1 -1
- package/dist/r/uploadthing-storage.json +1 -1
- package/dist/r/vercel-analytics.json +8 -8
- package/dist/r/vercel-blob-storage.json +1 -1
- package/dist/r/vercel-gateway.json +1 -5
- package/dist/r/vercel-sandbox.json +4 -4
- package/dist/r/vercel-speed-insights.json +8 -8
- package/dist/r/vultr-storage.json +1 -1
- package/dist/r/wasabi-storage.json +1 -1
- package/dist/r/webdav-storage.json +1 -1
- package/dist/r/word-count.json +15 -8
- package/dist/r/yandex-storage.json +1 -1
- package/package.json +7 -7
|
@@ -3,184 +3,179 @@
|
|
|
3
3
|
"name": "deep-research",
|
|
4
4
|
"description": "Native EVE research workflow, subagents, prompts, and progress UI",
|
|
5
5
|
"dependencies": [
|
|
6
|
-
"lucide-react@0.553.0"
|
|
7
|
-
"motion@^12.23.24"
|
|
6
|
+
"lucide-react@0.553.0"
|
|
8
7
|
],
|
|
9
8
|
"registryDependencies": [
|
|
10
|
-
"@chatjs/text-documents"
|
|
9
|
+
"@chatjs/text-documents",
|
|
10
|
+
"trace",
|
|
11
|
+
"badge"
|
|
11
12
|
],
|
|
12
13
|
"files": [
|
|
13
14
|
{
|
|
14
15
|
"path": "src/tools/deep-research/renderer.tsx",
|
|
15
|
-
"content": "\"use client\";\nimport { researchInput, researchOutput } from \"./schemas\";\nimport { EveDocumentTool } from \"@/components/eve/eve-document-tool\";\nimport React from \"react\";\nimport type { ReadonlyNativeSurface } from \"@/lib/readonly-native-surface\";\nimport { ReasonSearchResearchProgress } from \"./progress\";\nimport { ResearchUpdateSchema } from \"@/tools/platform/research-updates-schema\";\nimport type { ToolRendererProps } from \"@/
|
|
16
|
+
"content": "\"use client\";\nimport { researchInput, researchOutput } from \"./schemas\";\nimport { EveDocumentTool } from \"@/components/eve/eve-document-tool\";\nimport React from \"react\";\nimport type { ReadonlyNativeSurface } from \"@/lib/readonly-native-surface\";\nimport { ReasonSearchResearchProgress } from \"./progress\";\nimport { ResearchUpdateSchema } from \"@/tools/platform/research-updates-schema\";\nimport type { ToolRendererProps } from \"@/chatjs/core/tools/define-renderer\";\nimport { defineToolRenderer } from \"@/chatjs/core/tools/define-renderer\";\n\nexport const DeepResearchRenderer = defineToolRenderer({\n inputSchema: researchInput,\n outputSchema: researchOutput,\n render: ({\n tool,\n messageId,\n isReadonly,\n }: ReadonlyNativeSurface<\n ToolRendererProps<typeof researchInput, typeof researchOutput>\n >) => {\n const result = tool.state === \"output-available\" ? tool.output : undefined;\n let content = <output>Researching…</output>;\n if (result && \"format\" in result) {\n content =\n result.format === \"clarifying_questions\" ? (\n <p>{result.answer}</p>\n ) : (\n <EveDocumentTool\n isReadonly={isReadonly}\n messageId={messageId}\n part={{\n input: {},\n output: result,\n state: \"completed\",\n callId: tool.toolCallId,\n kind: \"tool\",\n label: \"Create document\",\n stepIndex: 0,\n name: \"createTextDocument\",\n type: \"tool\",\n }}\n />\n );\n }\n return <div className=\"space-y-3\">{content}</div>;\n },\n renderProgress: ReasonSearchResearchProgress,\n updateSchema: ResearchUpdateSchema,\n});\n",
|
|
16
17
|
"type": "registry:file",
|
|
17
|
-
"target": "~/tools/
|
|
18
|
+
"target": "~/chatjs/tools/deep-research/renderer.tsx"
|
|
18
19
|
},
|
|
19
20
|
{
|
|
20
21
|
"path": "src/tools/deep-research/search-updates.ts",
|
|
21
|
-
"content": "import { Client } from \"eve/client\";\nimport { ResearchUpdateSchema } from \"@/tools/platform/research-updates-schema\";\nimport type { WebSearchUpdate } from \"@/tools/platform/research-updates-schema\";\nimport type { WorkflowToolContext } from \"eve/tools\";\nimport { getEveConnectionOptions } from \"@/lib/eve/connection-options\";\nimport { toolOutputSchema } from \"@/lib/eve/tool-result\";\n\ntype Context = Readonly<\n
|
|
22
|
+
"content": "import { Client } from \"eve/client\";\nimport { ResearchUpdateSchema } from \"@/tools/platform/research-updates-schema\";\nimport type { WebSearchUpdate } from \"@/tools/platform/research-updates-schema\";\nimport type { WorkflowToolContext } from \"eve/tools\";\nimport { getEveConnectionOptions } from \"@/lib/eve/connection-options\";\nimport { toolOutputSchema } from \"@/lib/eve/tool-result\";\n\ntype Context = Readonly<\n Pick<WorkflowToolContext, \"session\" | \"callId\"> & {\n abortSignal: Readonly<AbortSignal>;\n }\n>;\n\ntype Snapshot = Awaited<\n ReturnType<ReturnType<Client[\"sessions\"][\"attach\"]>[\"snapshot\"]>\n>;\nconst readResearchSnapshots = async (\n client: Readonly<{ sessions: Readonly<Pick<Client[\"sessions\"], \"attach\">> }>,\n sessionIds: readonly string[],\n options: Readonly<{ signal: Readonly<AbortSignal> }>\n): Promise<Snapshot[]> => {\n const requests: Promise<Snapshot>[] = [];\n for (const sessionId of sessionIds) {\n requests.push(client.sessions.attach(sessionId).snapshot(options));\n }\n return await Promise.all(requests);\n};\n// oxlint-disable-next-line eslint/func-style -- EVE 0.61 authored-workflow-directives rejects const-bound steps; record owned child search snapshots so replay never rereads live evidence.\nexport async function researchSearchUpdates(\n context: Context\n): Promise<WebSearchUpdate[]> {\n \"use step\";\n const owner = context.session.auth.initiator;\n if (!owner) {\n throw new Error(\"Research progress requires an authenticated owner.\");\n }\n const client = new Client(getEveConnectionOptions(owner.principalId));\n const options = { signal: context.abortSignal };\n const root = await client.sessions\n .attach(context.session.id)\n .snapshot(options);\n const children = root.events.flatMap((event) => {\n if (\n event.type === \"child.opened\" &&\n event.data.stream ===\n `/eve/v1/session/${encodeURIComponent(event.data.sessionId)}/stream` &&\n event.data.name === \"researcher\" &&\n event.scope?.turnId === context.session.turn.id &&\n \"callId\" in event.data.owner &&\n event.data.owner.callId === context.callId\n ) {\n return [event.data.sessionId];\n }\n return [];\n });\n const snapshots = await readResearchSnapshots(client, children, options);\n return snapshots.flatMap((snapshot) =>\n snapshot.events.flatMap((event) => {\n if (event.type !== \"call.settled\") {\n return [];\n }\n const receipt = toolOutputSchema.safeParse(event.data.output);\n if (!receipt.success) {\n return [];\n }\n return (receipt.data.updates ?? []).flatMap((value: unknown) => {\n const update = ResearchUpdateSchema.safeParse(value);\n\n if (update.success && update.data.type === \"web\") {\n return [update.data];\n }\n return [];\n });\n })\n );\n}\n",
|
|
22
23
|
"type": "registry:file",
|
|
23
|
-
"target": "~/tools/
|
|
24
|
+
"target": "~/chatjs/tools/deep-research/search-updates.ts"
|
|
24
25
|
},
|
|
25
26
|
{
|
|
26
27
|
"path": "src/tools/deep-research/progress-panel.tsx",
|
|
27
|
-
"content": "import {
|
|
28
|
+
"content": "import {\n Trace,\n TraceCollapsible,\n TraceCollapsibleTrigger,\n TraceCollapsibleContent,\n TraceLine,\n TraceTitle,\n} from \"@/components/ui/trace\";\n// Type-only imports\nimport type {\n ResearchUpdate,\n WebSearchUpdate,\n} from \"@/tools/platform/research-updates-schema\";\nimport React from \"react\";\nimport type { ReadonlyNativeSurface } from \"@/lib/readonly-native-surface\";\nimport { ResearchTask } from \"./task\";\nimport { ResearchTasks } from \"./tasks\";\n\n// Add the updateName mapping (consider moving to a shared util later)\nconst updateName = {\n completed: \"Completed\",\n started: \"Started\",\n thoughts: \"Thoughts\",\n web: \"Web Search\",\n writing: \"Writing\",\n} as const;\n\nexport const ResearchProgress = ({\n updates,\n isComplete,\n}: ReadonlyNativeSurface<{\n updates: ResearchUpdate[];\n isComplete: boolean;\n}>): React.JSX.Element => {\n const [isExpanded, setIsExpanded] = React.useState(false);\n\n const lastUpdate = updates.length > 0 ? updates.at(-1) : null;\n\n const searchCount = React.useMemo(\n (): number =>\n updates.filter(\n (update: ReadonlyNativeSurface<ResearchUpdate>) => update.type === \"web\"\n ).length,\n [updates]\n );\n\n const sourceCount = React.useMemo(\n (): number =>\n updates\n .filter(\n (update: ReadonlyNativeSurface<ResearchUpdate>) =>\n update.type === \"web\"\n )\n .reduce(\n (\n acc: number,\n update: ReadonlyNativeSurface<WebSearchUpdate>\n ): number => acc + (update.results?.length ?? 0),\n 0\n ),\n [updates]\n );\n\n // Keep the fallback title while no update has been received.\n const lastUpdateTitle = ((): string => {\n if (!lastUpdate) {\n return \"Researching\";\n }\n if (isComplete) {\n return \"Research Complete\";\n }\n return lastUpdate.title || updateName[lastUpdate.type];\n })();\n\n const timeSpent = React.useMemo((): number => {\n if (isComplete) {\n const progressUpdates = updates.filter(\n (update: ReadonlyNativeSurface<ResearchUpdate>) =>\n update.type === \"started\" || update.type === \"completed\"\n );\n const completedUpdate = progressUpdates.find(\n (update: ReadonlyNativeSurface<ResearchUpdate>) =>\n update.type === \"completed\"\n );\n\n if (\n completedUpdate !== undefined &&\n completedUpdate.timestamp !== 0 &&\n !Number.isNaN(completedUpdate.timestamp)\n ) {\n return Math.floor(\n (completedUpdate.timestamp - progressUpdates[0].timestamp) / 1000\n );\n }\n return 0;\n }\n return 0;\n }, [updates, isComplete]);\n\n return (\n <Trace>\n <TraceCollapsible open={isExpanded} onOpenChange={setIsExpanded}>\n <TraceCollapsibleTrigger>\n <TraceLine status={isComplete ? undefined : \"running\"}>\n <TraceTitle>\n {isComplete\n ? `Researched for ${timeSpent} seconds, ${searchCount} searches, ${sourceCount} sources`\n : lastUpdateTitle}\n </TraceTitle>\n </TraceLine>\n </TraceCollapsibleTrigger>\n <TraceCollapsibleContent>\n <ResearchTasks updates={updates} />\n </TraceCollapsibleContent>\n </TraceCollapsible>\n {!isExpanded && lastUpdate && !isComplete && (\n <ResearchTask update={lastUpdate} />\n )}\n </Trace>\n );\n};\n",
|
|
28
29
|
"type": "registry:file",
|
|
29
|
-
"target": "~/tools/
|
|
30
|
+
"target": "~/chatjs/tools/deep-research/progress-panel.tsx"
|
|
30
31
|
},
|
|
31
32
|
{
|
|
32
33
|
"path": "src/tools/deep-research/tool.ts",
|
|
33
34
|
"content": "export { default as deepResearch } from \"@/agent/tools/deepResearch\";\n",
|
|
34
35
|
"type": "registry:file",
|
|
35
|
-
"target": "~/tools/
|
|
36
|
+
"target": "~/chatjs/tools/deep-research/tool.ts"
|
|
36
37
|
},
|
|
37
38
|
{
|
|
38
39
|
"path": "src/tools/deep-research/availability.ts",
|
|
39
|
-
"content": "import {
|
|
40
|
+
"content": "import { isAccountSession } from \"@/lib/eve/session-identity\";\nimport { eveTurnAccount, eveTurnTool } from \"@/lib/eve/turn-tools\";\nimport {\n installedDocumentKinds,\n installedToolNames,\n} from \"@/integrations/tools/catalog\";\nimport type { ToolContext } from \"eve/tools\";\nimport { toolProviders } from \"@/integrations/tools/providers\";\n\nexport const researchAvailable = (\n session: Pick<ToolContext[\"session\"], \"auth\" | \"parent\">\n): boolean => {\n const selected = eveTurnTool.get();\n return (\n isAccountSession(session) &&\n !session.parent &&\n eveTurnAccount.get() &&\n (selected === null || selected === \"deepResearch\") &&\n installedToolNames.has(\"deepResearch\") &&\n installedDocumentKinds.has(\"text\") &&\n Object.hasOwn(toolProviders, \"webSearch\")\n );\n};\n",
|
|
40
41
|
"type": "registry:file",
|
|
41
|
-
"target": "~/tools/
|
|
42
|
+
"target": "~/chatjs/tools/deep-research/availability.ts"
|
|
42
43
|
},
|
|
43
44
|
{
|
|
44
45
|
"path": "src/tools/deep-research/progress.tsx",
|
|
45
46
|
"content": "import React from \"react\";\nimport type { ReadonlyNativeSurface } from \"@/lib/readonly-native-surface\";\nimport { ResearchProgress } from \"./progress-panel\";\nimport type { ResearchUpdate } from \"@/tools/platform/research-updates-schema\";\n\nexport const ReasonSearchResearchProgress = ({\n updates,\n}: ReadonlyNativeSurface<{\n updates: ResearchUpdate[];\n}>): React.JSX.Element | null => {\n if (updates.length > 0) {\n return (\n <ResearchProgress\n isComplete={updates.some(\n (update: ReadonlyNativeSurface<ResearchUpdate>) =>\n update.type === \"completed\"\n )}\n updates={updates}\n />\n );\n }\n return null;\n};\n",
|
|
46
47
|
"type": "registry:file",
|
|
47
|
-
"target": "~/tools/
|
|
48
|
+
"target": "~/chatjs/tools/deep-research/progress.tsx"
|
|
48
49
|
},
|
|
49
50
|
{
|
|
50
51
|
"path": "src/tools/deep-research/task.tsx",
|
|
51
|
-
"content": "import { Loader2, SearchIcon } from \"lucide-react\";\nimport { Badge } from \"@/components/ui/badge\";\nimport React from \"react\";\nimport type { ReadonlyNativeSurface } from \"@/lib/readonly-native-surface\";\nimport type { ResearchUpdate } from \"@/tools/platform/research-updates-schema\";\nimport {
|
|
52
|
+
"content": "import { Loader2, SearchIcon } from \"lucide-react\";\nimport { Badge } from \"@/components/ui/badge\";\nimport React from \"react\";\nimport type { ReadonlyNativeSurface } from \"@/lib/readonly-native-surface\";\nimport type { ResearchUpdate } from \"@/tools/platform/research-updates-schema\";\nimport { WebSourceBadge } from \"@/components/source-badge\";\n\nexport const ResearchTask = ({\n update,\n}: Readonly<{\n update: ReadonlyNativeSurface<ResearchUpdate>;\n}>): React.JSX.Element => (\n <div className=\"group\">\n <div className=\"flex min-w-0 flex-col gap-2\">\n {update.type === \"web\" && update.queries !== undefined && (\n <div className=\"flex flex-wrap gap-2\">\n {update.queries.map((query) => (\n <Badge\n className=\"bg-muted flex items-center gap-1\"\n key={query}\n variant=\"outline\"\n >\n <SearchIcon className=\"size-3.5\" />\n {/* // TODO: Make this size width responsive or accomodate long text in another manner */}\n <span className=\"max-w-[300px] truncate\">{query}</span>\n </Badge>\n ))}\n </div>\n )}\n {/* Search Results: Show only when completed and results exist */}\n {update.type === \"web\" &&\n update.status === \"completed\" &&\n update.results && (\n <div className=\"flex flex-wrap gap-2\">\n {update.type === \"web\" &&\n update.results.map((result) => (\n <WebSourceBadge key={result.url} result={result} />\n ))}\n </div>\n )}\n {/* Search Loading State */}\n {update.type === \"web\" && update.status === \"running\" && (\n <div className=\"py-2\">\n <div className=\"flex items-center gap-3\">\n <Loader2 className=\"text-muted-foreground size-4 animate-spin\" />\n <p className=\"text-muted-foreground text-sm\">\n Searching the web...\n </p>\n </div>\n </div>\n )}\n {/* {Thoughts} */}\n {update.type === \"thoughts\" && (\n <div className=\"space-y-2\">\n <p className=\"text-foreground text-sm font-light\">{update.message}</p>\n </div>\n )}\n {update.type === \"writing\" &&\n update.message !== undefined &&\n update.message !== \"\" && (\n <div className=\"space-y-2\">\n <p className=\"text-foreground text-sm font-light\">\n {update.message}\n </p>\n </div>\n )}\n </div>\n </div>\n);\n",
|
|
52
53
|
"type": "registry:file",
|
|
53
|
-
"target": "~/tools/
|
|
54
|
+
"target": "~/chatjs/tools/deep-research/task.tsx"
|
|
54
55
|
},
|
|
55
56
|
{
|
|
56
57
|
"path": "src/tools/deep-research/agent.ts",
|
|
57
|
-
"content": "import { defineAgent, defineDynamic } from \"eve\";\nimport
|
|
58
|
+
"content": "import { defineAgent, defineDynamic } from \"eve\";\nimport { resolveAccountedEveModel } from \"@/lib/eve/model-accounting\";\nimport { getDeepResearchConfig } from \"./configuration\";\n\ntype Phase = \"research\" | \"compression\" | \"final_report\";\nexport const defineResearchAgent = (phase: Phase) =>\n defineAgent({\n defaultTools: false,\n description: `Deep research ${phase} phase. Called by the research workflow.`,\n model: defineDynamic(\n async (context) =>\n await resolveAccountedEveModel(\n getDeepResearchConfig()[`${phase}_model`],\n context\n )\n ),\n tool: false,\n });\n",
|
|
58
59
|
"type": "registry:file",
|
|
59
|
-
"target": "~/tools/
|
|
60
|
+
"target": "~/chatjs/tools/deep-research/agent.ts"
|
|
60
61
|
},
|
|
61
62
|
{
|
|
62
63
|
"path": "src/tools/deep-research/schemas.ts",
|
|
63
|
-
"content": "import { eveDocumentWriteResult } from \"@/
|
|
64
|
+
"content": "import { eveDocumentWriteResult } from \"@/chatjs/core/documents/contracts\";\nimport { z } from \"zod\";\n\nconst MINIMUM_RESEARCH_TEXT_LENGTH = 1;\n\nconst researchOutput = z.union([\n z.object({ searches: z.tuple([]) }),\n z.object({ answer: z.string(), format: z.literal(\"clarifying_questions\") }),\n eveDocumentWriteResult.extend({ format: z.literal(\"report\") }),\n]);\n\nconst researchInput = z.object({});\n\nconst researchClarification = z.object({\n need_clarification: z.boolean(),\n question: z.string(),\n verification: z.string(),\n});\n\nconst researchBrief = z.object({\n research_brief: z.string().min(MINIMUM_RESEARCH_TEXT_LENGTH),\n title: z.string().min(MINIMUM_RESEARCH_TEXT_LENGTH),\n});\n\nconst researchDecision = z.object({\n complete: z.boolean(),\n topics: z.array(z.string().min(MINIMUM_RESEARCH_TEXT_LENGTH)),\n});\n\nconst researchFindings = z.object({\n findings: z.string().min(MINIMUM_RESEARCH_TEXT_LENGTH),\n});\n\nconst researchReport = z.object({\n content: z.string().min(MINIMUM_RESEARCH_TEXT_LENGTH),\n title: z.string().min(MINIMUM_RESEARCH_TEXT_LENGTH),\n});\nexport {\n researchBrief,\n researchClarification,\n researchDecision,\n researchFindings,\n researchInput,\n researchOutput,\n researchReport,\n};\n",
|
|
64
65
|
"type": "registry:file",
|
|
65
|
-
"target": "~/tools/
|
|
66
|
+
"target": "~/chatjs/tools/deep-research/schemas.ts"
|
|
66
67
|
},
|
|
67
68
|
{
|
|
68
69
|
"path": "src/tools/deep-research/tasks.tsx",
|
|
69
|
-
"content": "import { CircleCheck, Dot, FileText, Pencil, Sparkles } from \"lucide-react\";\nimport
|
|
70
|
+
"content": "import React from \"react\";\nimport { CircleCheck, Dot, FileText, Pencil, Sparkles } from \"lucide-react\";\nimport { Trace, TraceIcon, TraceLine, TraceTitle } from \"@/components/ui/trace\";\nimport type { ReadonlyNativeSurface } from \"@/lib/readonly-native-surface\";\nimport type { ResearchUpdate } from \"@/tools/platform/research-updates-schema\";\nimport { ResearchTask } from \"./task\";\n\nconst icons = {\n completed: CircleCheck,\n started: Dot,\n thoughts: Sparkles,\n web: FileText,\n writing: Pencil,\n};\n\nexport const ResearchTasks = ({\n updates,\n}: ReadonlyNativeSurface<{ updates: ResearchUpdate[] }>): React.JSX.Element => {\n const occurrences = new Map<string, number>();\n const complete = updates.some((update) => update.type === \"completed\");\n return (\n <Trace>\n {updates.map((update, index) => {\n const identity = `${update.type}:${update.toolCallId}`;\n const occurrence = occurrences.get(identity) ?? 0;\n occurrences.set(identity, occurrence + 1);\n const running =\n !complete &&\n (update.type === \"web\"\n ? update.status === \"running\"\n : index === updates.length - 1);\n const Icon = icons[update.type];\n return (\n <div\n className=\"group flex min-w-0 flex-col gap-2\"\n key={`${identity}:${occurrence}`}\n data-research-step\n >\n <TraceLine status={running ? \"running\" : undefined}>\n <TraceIcon>\n <Icon />\n </TraceIcon>\n <TraceTitle>{update.title}</TraceTitle>\n </TraceLine>\n <div className=\"min-w-0 ps-6\">\n <ResearchTask update={update} />\n </div>\n </div>\n );\n })}\n </Trace>\n );\n};\n",
|
|
70
71
|
"type": "registry:file",
|
|
71
|
-
"target": "~/tools/
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
"path": "src/tools/deep-research/update-title.tsx",
|
|
75
|
-
"content": "import React from \"react\";\nimport { Shimmer } from \"@/components/ai-elements/shimmer\";\nimport { cn } from \"@/lib/utils\";\n\nexport const UpdateTitle = ({\n title,\n isRunning,\n className,\n}: Readonly<{\n title: string;\n isRunning: boolean;\n className?: string;\n}>): React.JSX.Element => {\n if (isRunning) {\n return (\n <Shimmer as=\"h3\" className={cn(\"text-sm font-medium\", className)}>\n {title}\n </Shimmer>\n );\n }\n\n return <h3 className={cn(\"text-sm font-medium\", className)}>{title}</h3>;\n};\n",
|
|
76
|
-
"type": "registry:file",
|
|
77
|
-
"target": "~/tools/chatjs/deep-research/update-title.tsx"
|
|
72
|
+
"target": "~/chatjs/tools/deep-research/tasks.tsx"
|
|
78
73
|
},
|
|
79
74
|
{
|
|
80
75
|
"path": "src/tools/deep-research/prompts.ts",
|
|
81
76
|
"content": "const clarifyWithUserInstructions = ({\n messages,\n date,\n}: Readonly<{\n messages: string;\n date: string;\n}>): string =>\n `These are the messages that have been exchanged so far from the user asking for the report:\n<Messages>\n${messages}\n</Messages>\n\nToday's date is ${date}.\n\nAssess whether you need to ask a clarifying question, or if the user has already provided enough information for you to start research.\nIMPORTANT: If you can see in the messages history that you have already asked a clarifying question, you almost always do not need to ask another one. Only ask another question if ABSOLUTELY NECESSARY.\n\nIf there are acronyms, abbreviations, or unknown terms, ask the user to clarify.\nIf you need to ask a question, follow these guidelines:\n- Be concise while gathering all necessary information\n- Make sure to gather all the information needed to carry out the research task in a concise, well-structured manner.\n- Use bullet points or numbered lists if appropriate for clarity. Make sure that this uses markdown formatting and will be rendered correctly if the string output is passed to a markdown renderer.\n- Don't ask for unnecessary information, or information that the user has already provided. If you can see that the user has already provided the information, do not ask for it again.\n\nRespond in valid JSON format with these exact keys:\n\"need_clarification\": boolean,\n\"question\": \"<question to ask the user to clarify the report scope>\",\n\"verification\": \"<verification message that we will start research>\"\n\nIf you need to ask a clarifying question, return:\n\"need_clarification\": true,\n\"question\": \"<your clarifying question>\",\n\"verification\": \"\"\n\nIf you do not need to ask a clarifying question, return:\n\"need_clarification\": false,\n\"question\": \"\",\n\"verification\": \"<acknowledgement message that you will now start research based on the provided information>\"\n\nFor the verification message when no clarification is needed:\n- Acknowledge that you have sufficient information to proceed\n- Briefly summarize the key aspects of what you understand from their request\n- Confirm that you will now begin the research process\n- Keep the message concise and professional`;\n\nconst transformMessagesIntoResearchTopicPrompt = ({\n messages,\n date,\n}: Readonly<{\n messages: string;\n date: string;\n}>): string =>\n `You will be given a set of messages that have been exchanged so far between yourself and the user.\nYour job is to translate these messages into a more detailed and concrete research question that will be used to guide the research.\n\nThe messages that have been exchanged so far between yourself and the user are:\n<Messages>\n${messages}\n</Messages>\n\nToday's date is ${date}.\n\nYou will return a single research question that will be used to guide the research.\n\nGuidelines:\n1. Maximize Specificity and Detail\n- Include all known user preferences and explicitly list key attributes or dimensions to consider.\n- It is important that all details from the user are included in the instructions.\n\n2. Fill in Unstated But Necessary Dimensions as Open-Ended\n- If certain attributes are essential for a meaningful output but the user has not provided them, explicitly state that they are open-ended or default to no specific constraint.\n\n3. Avoid Unwarranted Assumptions\n- If the user has not provided a particular detail, do not invent one.\n- Instead, state the lack of specification and guide the researcher to treat it as flexible or accept all possible options.\n\n4. Use the First Person\n- Phrase the request from the perspective of the user.\n\n5. Sources\n- If specific sources should be prioritized, specify them in the research question.\n- For product and travel research, prefer linking directly to official or primary websites (e.g., official brand sites, manufacturer pages, or reputable e-commerce platforms like Amazon for user reviews) rather than aggregator sites or SEO-heavy blogs.\n- For academic or scientific queries, prefer linking directly to the original paper or official journal publication rather than survey papers or secondary summaries.\n- For people, try linking directly to their LinkedIn profile, or their personal website if they have one.\n- If the query is in a specific language, prioritize sources published in that language.`;\n\nconst leadResearcherPrompt = ({\n date,\n max_concurrent_research_units,\n}: Readonly<{\n date: string;\n max_concurrent_research_units: number;\n}>): string =>\n `You are a research supervisor. Today's date is ${date}.\nYou receive a research brief and findings from all completed topics. Decide whether the evidence is sufficient for a comprehensive report or identify specific gaps requiring follow-up research.\n\nReturn JSON with complete (boolean) and topics (array of strings).\n- To research, set complete to false and provide up to ${max_concurrent_research_units} detailed, self-contained topics. The workflow will run them sequentially and return their findings before your next decision.\n- To finish, set complete to true and topics to []. A separate writer synthesizes the report.\n- Start by researching the brief. On later rounds, request only net new information that is necessary to answer it. Do not ask researchers to synthesize existing findings.\n- Each topic must include all necessary context, explain acronyms, and state the desired depth of effort. Researchers do not see your other topics or findings.\n- Split independent questions when that improves coverage. Resolve dependencies first. More topics increase cost; prefer fewer comprehensive investigations over redundant subtopics.\n- Judge evidence coverage and reliability, not formatting. Findings may be raw or messy.\n- Match depth to the user's request. Detailed or comprehensive requests warrant more follow-up than broad overviews.\n- As research accumulates, require a stronger reason to request additional work. Finish when the findings adequately answer the brief. Do not repeat topics with minor rephrasing.`;\n\nconst researchSystemPrompt = ({\n date,\n mcp_prompt,\n max_search_queries,\n}: Readonly<{\n date: string;\n mcp_prompt: string;\n max_search_queries: number;\n}>): string =>\n `You are a research assistant conducting deep research on the user's input topic. Use the tools and search methods provided to research the user's input topic. For context, today's date is ${date}.\n\n<Task>\nYour job is to use tools and search methods to find information that can answer the question that a user asks.\nYou can use any of the tools provided to you to find resources that can help answer the research question. You can call these tools in series or in parallel, your research is conducted in a tool-calling loop.\n</Task>\n\n<Tool Calling Guidelines>\n- Make sure you review all of the tools you have available to you, match the tools to the user's request, and select the tool that is most likely to be the best fit.\n- In each iteration, select the BEST tool for the job, this may or may not be general websearch.\n- When selecting the next tool to call, make sure that you are calling tools with arguments that you have not already tried.\n- Tool calling is costly, so be sure to be very intentional about what you look up. Some of the tools may have implicit limitations. As you call tools, feel out what these limitations are, and adjust your tool calls accordingly.\n- You have a maximum of ${max_search_queries} web search queries available, so use them strategically and efficiently.\n- This could mean that you need to call a different tool or stop searching, e.g. it's okay to recognize that a tool has limitations and cannot do what you need it to.\n- Don't mention any tool limitations in your output, but adjust your tool calls accordingly.\n- ${mcp_prompt}\n<Tool Calling Guidelines>\n\n<Criteria for Finishing Research>\n- The user will give you a sense of how much effort you should put into the research. This does not translate ~directly~ to the number of tool calls you should make, but it does give you a sense of the depth of the research you should conduct.\n- Once you have enough evidence, stop searching and call eve__reply with your findings, including source URLs, citations, uncertainties, and conflicting evidence.\n- One case where you should stop is if your previous tool calls have stopped yielding useful information.\n</Criteria for Finishing Research>\n\n<Helpful Tips>\n1. If you haven't conducted any searches yet, start with broad searches to get necessary context and background information. Once you have some background, you can start to narrow down your searches to get more specific information.\n2. Different topics require different levels of research depth. If the question is broad, your research can be more shallow, and you may not need to iterate and call tools as many times.\n3. If the question is detailed, you may need to be more stingy about the depth of your findings, and you may need to iterate and call tools more times to get a fully detailed answer.\n</Helpful Tips>\n\n<Critical Reminders>\n- You MUST conduct research using web search or a different tool before finishing! You cannot finish without conducting research first!\n- The caller needs your findings, not just your search activity. Always finish by calling eve__reply with the collected evidence; a separate agent will compress it and write the user-facing report.\n</Critical Reminders>`;\n\nconst compressResearchSystemPrompt = ({\n date,\n}: Readonly<{ date: string }>): string =>\n `You are a research assistant that has conducted research on a topic by calling several tools and web searches. Your job is now to clean up the findings, but preserve all of the relevant statements and information that the researcher has gathered. For context, today's date is ${date}.\n\n<Task>\nYou need to clean up information gathered from tool calls and web searches in the existing messages.\nAll relevant information should be repeated and rewritten verbatim, but in a cleaner format.\nThe purpose of this step is just to remove any obviously irrelevant or duplicative information.\nFor example, if three sources all say \"X\", you could say \"These three sources all stated X\".\nOnly these fully comprehensive cleaned findings are going to be returned to the user, so it's crucial that you don't lose any information from the raw messages.\n</Task>\n\n<Guidelines>\n1. Your output findings should be fully comprehensive and include ALL of the information and sources that the researcher has gathered from tool calls and web searches. It is expected that you repeat key information verbatim.\n2. This report can be as long as necessary to return ALL of the information that the researcher has gathered.\n3. In your report, you should return inline citations for each source that the researcher found.\n4. You should include a \"Sources\" section at the end of the report that lists all of the sources the researcher found with corresponding citations, cited against statements in the report.\n5. Make sure to include ALL of the sources that the researcher gathered in the report, and how they were used to answer the question!\n6. It's really important not to lose any sources. A later LLM will be used to merge this report with others, so having all of the sources is critical.\n</Guidelines>\n\n<Output Format>\nThe report should be structured like this:\n**List of Queries and Tool Calls Made**\n**Fully Comprehensive Findings**\n**List of All Relevant Sources (with citations in the report)**\n</Output Format>\n\n<Citation Rules>\n- Assign each unique URL a single citation number in your text\n- End with ### Sources that lists each source with corresponding numbers\n- IMPORTANT: Number sources sequentially without gaps (1,2,3,4...) in the final list regardless of which sources you choose\n- Example format:\n [1] Source Title: URL\n [2] Source Title: URL\n</Citation Rules>\n\nCritical Reminder: It is extremely important that any information that is even remotely relevant to the user's research topic is preserved verbatim (e.g. don't rewrite it, don't summarize it, don't paraphrase it).`;\n\nconst compressResearchSimpleHumanMessage = `All above messages are about research conducted by an AI Researcher. Please clean up these findings.\n\nDO NOT summarize the information. I want the raw information returned, just in a cleaner format. Make sure all relevant information is preserved - you can rewrite findings verbatim.`;\n\nconst FINAL_REPORT_INSTRUCTIONS = `\n\nPlease create a detailed answer to the overall research brief that:\n1. Is well-organized with proper headings (# for title, ## for sections, ### for subsections)\n2. Includes specific facts and insights from the research\n3. References relevant sources using [Title](URL) format\n4. Provides a balanced, thorough analysis. Be as comprehensive as possible, and include all information that is relevant to the overall research question. People are using you for deep research and will expect detailed, comprehensive answers.\n5. Includes a \"Sources\" section at the end with all referenced links\n\nYou can structure your report in a number of different ways. Here are some examples:\n\nTo answer a question that asks you to compare two things, you might structure your report like this:\n1/ intro\n2/ overview of topic A\n3/ overview of topic B\n4/ comparison between A and B\n5/ conclusion\n\nTo answer a question that asks you to return a list of things, you might only need a single section which is the entire list.\n1/ list of things or table of things\nOr, you could choose to make each item in the list a separate section in the report. When asked for lists, you don't need an introduction or conclusion.\n1/ item 1\n2/ item 2\n3/ item 3\n\nTo answer a question that asks you to summarize a topic, give a report, or give an overview, you might structure your report like this:\n1/ overview of topic\n2/ concept 1\n3/ concept 2\n4/ concept 3\n5/ conclusion\n\nIf you think you can answer the question with a single section, you can do that too!\n1/ answer\n\nREMEMBER: Section is a VERY fluid and loose concept. You can structure your report however you think is best, including in ways that are not listed above!\nMake sure that your sections are cohesive, and make sense for the reader.\n\nFor each section of the report, do the following:\n- Use simple, clear language\n- Use ## for section title (Markdown format) for each section of the report\n- Do NOT ever refer to yourself as the writer of the report. This should be a professional report without any self-referential language.\n- Do not say what you are doing in the report. Just write the report without any commentary from yourself.\n\nFormat the report in clear markdown with proper structure and include source references where appropriate.\n\n<Citation Rules>\n- Assign each unique URL a single citation number in your text\n- End with ### Sources that lists each source with corresponding numbers\n- IMPORTANT: Number sources sequentially without gaps (1,2,3,4...) in the final list regardless of which sources you choose\n- Each source should be a separate line item in a list, so that in markdown it is rendered as a list.\n- Example format:\n [1] Source Title: URL\n [2] Source Title: URL\n- Citations are extremely important. Make sure to include these, and pay a lot of attention to getting these right. Users will often use these citations to look into more information.\n</Citation Rules>`;\n\nconst finalReportGenerationPrompt = ({\n research_brief,\n date,\n findings,\n}: Readonly<{\n research_brief: string;\n date: string;\n findings: string;\n}>): string =>\n `Based on all the research conducted, create a comprehensive, well-structured answer to the overall research brief:\n<Research Brief>\n${research_brief}\n</Research Brief>\n\nToday's date is ${date}.\n\nHere are the findings from the research that you conducted:\n<Findings>\n${findings}\n</Findings>${FINAL_REPORT_INSTRUCTIONS}`;\nexport {\n clarifyWithUserInstructions,\n compressResearchSimpleHumanMessage,\n compressResearchSystemPrompt,\n finalReportGenerationPrompt,\n leadResearcherPrompt,\n researchSystemPrompt,\n transformMessagesIntoResearchTopicPrompt,\n};\n",
|
|
82
77
|
"type": "registry:file",
|
|
83
|
-
"target": "~/tools/
|
|
78
|
+
"target": "~/chatjs/tools/deep-research/prompts.ts"
|
|
84
79
|
},
|
|
85
80
|
{
|
|
86
81
|
"path": "src/tools/deep-research/steps.ts",
|
|
87
|
-
"content": "import { Client } from \"eve/client\";\nimport type { WorkflowToolContext } from \"eve/tools\";\nimport { eveDocumentWriteResult } from \"@/
|
|
82
|
+
"content": "import { Client } from \"eve/client\";\nimport type { WorkflowToolContext } from \"eve/tools\";\nimport { eveDocumentWriteResult } from \"@/chatjs/core/documents/contracts\";\nimport { executeEveDocumentTool } from \"@/lib/eve/document-tools\";\nimport { getEveConnectionOptions } from \"@/lib/eve/connection-options\";\nimport { researchAvailable } from \"./availability\";\nimport { getDeepResearchConfig } from \"./configuration\";\nimport { researchReport } from \"./schemas\";\nimport { sharedEveMessages } from \"@/lib/eve/shared-messages\";\nimport type { z } from \"zod\";\n\ntype Context = Readonly<\n Pick<WorkflowToolContext, \"session\" | \"callId\"> & {\n abortSignal: Readonly<AbortSignal>;\n }\n>;\n\ntype MessageView = Readonly<{\n parts: readonly Readonly<{ type: string; callId?: string }>[];\n role: string;\n}>;\n\n// oxlint-disable-next-line eslint/func-style -- EVE 0.61 authored-workflow-directives rejects const-bound steps; record the owned transcript, config, and clock once for replay.\nasync function prepareResearch(context: Context): Promise<{\n config: ReturnType<typeof getDeepResearchConfig>;\n date: string;\n messages: string;\n timestamp: number;\n}> {\n \"use step\";\n const owner = context.session.auth.initiator;\n if (!owner || !researchAvailable(context.session)) {\n throw new Error(\n \"Deep research requires an authenticated owner, installed text documents, and installed webSearch.\"\n );\n }\n context.abortSignal.throwIfAborted();\n const client = new Client(getEveConnectionOptions(owner.principalId));\n const snapshot = await client.sessions\n .attach(context.session.id)\n .snapshot({ signal: context.abortSignal });\n const messages = sharedEveMessages(snapshot.events).map(\n (message: MessageView) => ({\n parts: message.parts.filter(\n (part): boolean =>\n part.type !== \"tool\" || part.callId !== context.callId\n ),\n role: message.role,\n })\n );\n return {\n config: getDeepResearchConfig(),\n date: new Date().toLocaleDateString(\"en-US\", {\n day: \"numeric\",\n month: \"short\",\n weekday: \"short\",\n year: \"numeric\",\n }),\n messages: messages\n .map(\n (message: MessageView): string =>\n `${message.role}: ${JSON.stringify(message.parts)}`\n )\n .join(\"\\n\"),\n timestamp: Date.now(),\n };\n}\n// oxlint-disable-next-line eslint/func-style -- EVE 0.61 authored-workflow-directives rejects const-bound steps; persist the document write and its completion clock together for replay.\nasync function saveResearchReport(\n context: Context,\n report: Readonly<z.infer<typeof researchReport>>\n): Promise<{\n document: z.infer<typeof eveDocumentWriteResult>;\n completedAt: number;\n}> {\n \"use step\";\n context.abortSignal.throwIfAborted();\n const content = researchReport.parse(report);\n const document = eveDocumentWriteResult.parse(\n await executeEveDocumentTool(\n \"createTextDocument\",\n {\n ...content,\n fileIds: [],\n },\n context\n )\n );\n // Record completion with the saved document so replay never reads a new clock.\n return { document, completedAt: Date.now() };\n}\nexport { prepareResearch, saveResearchReport };\n",
|
|
88
83
|
"type": "registry:file",
|
|
89
|
-
"target": "~/tools/
|
|
84
|
+
"target": "~/chatjs/tools/deep-research/steps.ts"
|
|
90
85
|
},
|
|
91
86
|
{
|
|
92
87
|
"path": "src/tools/deep-research/configuration.ts",
|
|
93
88
|
"content": "import { config } from \"@/lib/config\";\n\nexport const getDeepResearchConfig = (): {\n allow_clarification: typeof config.ai.tools.deepResearch.allowClarification;\n compression_model: typeof config.ai.tools.deepResearch.defaultModel;\n final_report_model: typeof config.ai.tools.deepResearch.finalReportModel;\n max_concurrent_research_units: typeof config.ai.tools.deepResearch.maxConcurrentResearchUnits;\n max_researcher_iterations: typeof config.ai.tools.deepResearch.maxResearcherIterations;\n research_model: typeof config.ai.tools.deepResearch.defaultModel;\n search_api_max_queries: typeof config.ai.tools.deepResearch.maxSearchQueries;\n} => {\n const options = config.ai.tools.deepResearch;\n return {\n allow_clarification: options.allowClarification,\n compression_model: options.defaultModel,\n final_report_model: options.finalReportModel,\n max_concurrent_research_units: options.maxConcurrentResearchUnits,\n max_researcher_iterations: options.maxResearcherIterations,\n research_model: options.defaultModel,\n search_api_max_queries: options.maxSearchQueries,\n };\n};\n",
|
|
94
89
|
"type": "registry:file",
|
|
95
|
-
"target": "~/tools/
|
|
90
|
+
"target": "~/chatjs/tools/deep-research/configuration.ts"
|
|
96
91
|
},
|
|
97
92
|
{
|
|
98
93
|
"path": "src/tools/deep-research/configuration-schema.ts",
|
|
99
94
|
"content": "import { z } from \"zod\";\nimport { languageModelSchema, modelRoles } from \"@/lib/config-models\";\n\nconst MINIMUM_COUNT = 1;\nconst MAX_CONCURRENT_UNITS = 20;\nconst MAX_ITERATIONS = 10;\nconst MAX_QUERIES = 10;\nconst DEFAULT_CONCURRENT_UNITS = 2;\nconst DEFAULT_ITERATIONS = 1;\nconst DEFAULT_QUERIES = 2;\nconst configSchema = z\n .strictObject({\n allowClarification: z.boolean().default(true),\n defaultModel: languageModelSchema.default(modelRoles.fast),\n finalReportModel: languageModelSchema.default(modelRoles.smart),\n maxConcurrentResearchUnits: z\n .number()\n .int()\n .min(MINIMUM_COUNT)\n .max(MAX_CONCURRENT_UNITS)\n .default(DEFAULT_CONCURRENT_UNITS),\n maxResearcherIterations: z\n .number()\n .int()\n .min(MINIMUM_COUNT)\n .max(MAX_ITERATIONS)\n .default(DEFAULT_ITERATIONS),\n maxSearchQueries: z\n .number()\n .int()\n .min(MINIMUM_COUNT)\n .max(MAX_QUERIES)\n .default(DEFAULT_QUERIES),\n })\n .prefault({});\nexport { configSchema };\n",
|
|
100
95
|
"type": "registry:file",
|
|
101
|
-
"target": "~/tools/
|
|
96
|
+
"target": "~/chatjs/tools/deep-research/configuration-schema.ts"
|
|
102
97
|
},
|
|
103
98
|
{
|
|
104
99
|
"path": "src/tools/deep-research/agent/tools/deep-research.ts",
|
|
105
|
-
"content": "import { requireAccountSession } from \"@/lib/eve/session-identity\";\nimport { defineWorkflowTool } from \"eve/tools\";\nimport { toolResultToModelOutput } from \"@/lib/eve/tool-model-output\";\nimport {\n clarifyWithUserInstructions,\n compressResearchSimpleHumanMessage,\n compressResearchSystemPrompt,\n finalReportGenerationPrompt,\n leadResearcherPrompt,\n researchSystemPrompt,\n transformMessagesIntoResearchTopicPrompt,\n} from \"@/tools/chatjs/deep-research/prompts\";\nimport {\n prepareResearch,\n saveResearchReport,\n} from \"@/tools/chatjs/deep-research/steps\";\nimport {\n researchBrief,\n researchInput,\n researchClarification,\n researchDecision,\n researchFindings,\n researchReport,\n} from \"@/tools/chatjs/deep-research/schemas\";\nimport type { ResearchUpdate } from \"@/tools/platform/research-updates-schema\";\nimport type { ToolResult } from \"@/lib/eve/tool-result\";\nimport type { AgentSession, WorkflowToolContext } from \"eve/tools\";\nimport { createToolResult } from \"@/lib/eve/tool-result\";\nimport type { researchOutput } from \"@/tools/chatjs/deep-research/schemas\";\nimport { researchSearchUpdates } from \"@/tools/chatjs/deep-research/search-updates\";\nimport { z } from \"zod\";\n\ntype ResearchOutput = z.infer<typeof researchOutput>;\n\ntype ResearchWorkflowContext = Readonly<\n Omit<WorkflowToolContext, \"abortSignal\"> & {\n abortSignal: Readonly<AbortSignal>;\n }\n>;\n\nconst structuredMessage = (message: string): string =>\n `${message}\\n\\nDeliver the requested fields through the eve__reply tool. Put any Markdown inside its string fields; do not return prose or JSON text instead of calling the tool.`;\n\nconst outputSchema = (schema: z.ZodType): Record<string, z.JSONType> =>\n z.record(z.string(), z.json()).parse(z.toJSONSchema(schema));\n\nconst researchReply = async (\n agent: Readonly<AgentSession>,\n options: Readonly<{\n message: string;\n outputSchema: Record<string, z.JSONType>;\n signal: AbortSignal;\n }>\n): Promise<unknown> => {\n options.signal.throwIfAborted();\n const response = await agent.send(options.message, {\n outputSchema: options.outputSchema,\n signal: options.signal,\n });\n const result = await response.result();\n options.signal.throwIfAborted();\n if (result.status === \"failed\") {\n throw new Error(result.error?.message ?? \"Research agent failed\");\n }\n if (result.data === undefined) {\n throw new Error(\"Research agent ended without structured output\");\n }\n return result.data;\n};\n\nconst ORCHESTRATION_COST_USD = 0;\nconst INITIAL_RESEARCH_ROUND = 0;\nconst RESEARCH_ROUND_INCREMENT = 1;\nconst BRIEF_UPDATE_INDEX = 1;\nconst EMPTY_TOPIC_COUNT = 0;\n\nexport default defineWorkflowTool({\n availableInSubagents: false,\n description:\n \"Conduct deep research using this conversation and installed search, then save a cited report. Use only for explicit deep research requests, at most once per user turn. If research fails, report the failure and let the user choose whether to retry; do not start duplicate research calls. If clarification is needed, ask the returned questions and call again after the user answers. The report is displayed to the user; do not repeat it in full.\",\n async *execute(\n _input: Readonly<Record<string, never>>,\n context: ResearchWorkflowContext\n ): AsyncGenerator<ToolResult<ResearchOutput>, void> {\n \"use workflow\";\n requireAccountSession(context.session);\n const { config, date, messages, timestamp } =\n await prepareResearch(context);\n const updates: ResearchUpdate[] = [];\n let searchUpdates: ResearchUpdate[] = [];\n // Native child events own model/search costs. This orchestration receipt adds no charge.\n const progress = (): ToolResult<ResearchOutput> =>\n createToolResult<ResearchOutput>(\n { searches: [] },\n ORCHESTRATION_COST_USD,\n [...updates, ...searchUpdates]\n );\n if (config.allow_clarification) {\n const clarification = researchClarification.parse(\n await researchReply(context.agent(\"researchPlanner\"), {\n signal: context.abortSignal,\n message: structuredMessage(\n clarifyWithUserInstructions({ date, messages })\n ),\n outputSchema: outputSchema(researchClarification),\n })\n );\n if (clarification.need_clarification) {\n yield createToolResult(\n { answer: clarification.question, format: \"clarifying_questions\" },\n ORCHESTRATION_COST_USD\n );\n return;\n }\n }\n updates.push(\n {\n timestamp,\n title: \"Starting research\",\n toolCallId: context.callId,\n type: \"started\",\n },\n {\n status: \"running\",\n title: \"Writing research brief\",\n toolCallId: context.callId,\n type: \"writing\",\n }\n );\n yield progress();\n const brief = researchBrief.parse(\n await researchReply(context.agent(\"researchPlanner\"), {\n signal: context.abortSignal,\n message: structuredMessage(\n transformMessagesIntoResearchTopicPrompt({ date, messages })\n ),\n outputSchema: outputSchema(researchBrief),\n })\n );\n updates[BRIEF_UPDATE_INDEX] = {\n message: brief.research_brief,\n status: \"completed\",\n title: \"Writing research brief\",\n toolCallId: context.callId,\n type: \"writing\",\n };\n yield progress();\n\n const notes: { topic: string; findings: string }[] = [];\n const decisionSchema = researchDecision.extend({\n topics: researchDecision.shape.topics.max(\n config.max_concurrent_research_units\n ),\n });\n // Preserve the SDK's max_researcher_iterations + 1 decision steps, including\n // its allowance for research on the final step if the supervisor has not finished.\n for (\n let round = INITIAL_RESEARCH_ROUND;\n round <= config.max_researcher_iterations;\n round += RESEARCH_ROUND_INCREMENT\n ) {\n context.abortSignal.throwIfAborted();\n const decision = decisionSchema.parse(\n // oxlint-disable-next-line no-await-in-loop -- Each decision consumes the findings added by the preceding round.\n await researchReply(context.agent(\"researchPlanner\"), {\n signal: context.abortSignal,\n message: structuredMessage(\n `${leadResearcherPrompt({ date, max_concurrent_research_units: config.max_concurrent_research_units })}\\n\\nResearch brief: ${brief.research_brief}\\n\\nFindings so far:\\n${JSON.stringify(notes)}\\n\\nDecision round ${round + RESEARCH_ROUND_INCREMENT} of ${config.max_researcher_iterations + RESEARCH_ROUND_INCREMENT}. Return your next decision.`\n ),\n outputSchema: outputSchema(decisionSchema),\n })\n );\n if (decision.complete) {\n break;\n }\n if (decision.topics.length === EMPTY_TOPIC_COUNT) {\n throw new Error(\n \"The research supervisor must select topics or finish.\"\n );\n }\n for (const topic of decision.topics) {\n context.abortSignal.throwIfAborted();\n const updateIndex = updates.length;\n updates.push({\n message: topic,\n status: \"running\",\n title: \"Researching topic\",\n toolCallId: context.callId,\n type: \"thoughts\",\n });\n yield progress();\n let raw: z.infer<typeof researchFindings>;\n try {\n raw = researchFindings.parse(\n // oxlint-disable-next-line no-await-in-loop -- Publish each topic's progress and finish its child before advancing; failure must prevent later topics from starting.\n await researchReply(context.agent(\"researcher\"), {\n signal: context.abortSignal,\n message: structuredMessage(\n `${researchSystemPrompt({ date, max_search_queries: config.search_api_max_queries, mcp_prompt: \"\" })}\\n\\nTopic:\\n${topic}\\n\\nReturn comprehensive raw findings, preserving source URLs, citations, relevant quotations, uncertainties, and conflicting evidence for the compression stage.`\n ),\n outputSchema: outputSchema(researchFindings),\n })\n );\n } catch (error) {\n // Keep completed search evidence even if the researcher later fails.\n // Cancellation must stop promptly instead of starting more reads.\n context.abortSignal.throwIfAborted();\n const previousSearchUpdates = searchUpdates;\n // oxlint-disable-next-line no-await-in-loop -- Preserve completed search evidence before publishing the failure and terminating the topic loop.\n searchUpdates = await researchSearchUpdates(context).catch(\n () => previousSearchUpdates\n );\n yield progress();\n throw error;\n }\n // oxlint-disable-next-line no-await-in-loop -- Read the just-completed child's evidence before publishing progress and compressing its findings.\n searchUpdates = await researchSearchUpdates(context);\n yield progress();\n const compressed = researchFindings.parse(\n // oxlint-disable-next-line no-await-in-loop -- Commit this topic's compressed notes before the next topic and supervisor decision.\n await researchReply(context.agent(\"researchCompressor\"), {\n signal: context.abortSignal,\n message: structuredMessage(\n `${compressResearchSystemPrompt({ date })}\\n\\n${raw.findings}\\n\\n${compressResearchSimpleHumanMessage}`\n ),\n outputSchema: outputSchema(researchFindings),\n })\n );\n notes.push({ findings: compressed.findings, topic });\n updates[updateIndex] = {\n message: topic,\n status: \"completed\",\n title: \"Research topic completed\",\n toolCallId: context.callId,\n type: \"thoughts\",\n };\n yield progress();\n }\n }\n const reportUpdateIndex = updates.length;\n updates.push({\n status: \"running\",\n title: \"Writing final report\",\n toolCallId: context.callId,\n type: \"writing\",\n });\n yield progress();\n const report = researchReport.parse(\n await researchReply(context.agent(\"researchWriter\"), {\n signal: context.abortSignal,\n message: structuredMessage(\n `${finalReportGenerationPrompt({ date, findings: notes.map((note: Readonly<(typeof notes)[number]>): string => note.findings).join(\"\\n\"), research_brief: brief.research_brief })}\\n\\nWrite the complete Markdown report with title ${JSON.stringify(brief.title)}. Return title and content; the workflow will save the document.`\n ),\n outputSchema: outputSchema(researchReport),\n })\n );\n context.abortSignal.throwIfAborted();\n const { document, completedAt } = await saveResearchReport(context, report);\n updates[reportUpdateIndex] = {\n status: \"completed\",\n title: \"Writing final report\",\n toolCallId: context.callId,\n type: \"writing\",\n };\n updates.push({\n timestamp: completedAt,\n title: \"Research complete\",\n toolCallId: context.callId,\n type: \"completed\",\n });\n yield createToolResult(\n { ...document, format: \"report\" },\n ORCHESTRATION_COST_USD,\n [...updates, ...searchUpdates]\n );\n },\n inputSchema: researchInput,\n toModelOutput: toolResultToModelOutput,\n});\n",
|
|
100
|
+
"content": "// ChatJS source: deep-research. Ownership: chatjs/tools/deep-research/chatjs.json.\nimport { requireAccountSession } from \"@/lib/eve/session-identity\";\nimport { defineWorkflowTool } from \"eve/tools\";\nimport { toolResultToModelOutput } from \"@/lib/eve/tool-model-output\";\nimport {\n clarifyWithUserInstructions,\n compressResearchSimpleHumanMessage,\n compressResearchSystemPrompt,\n finalReportGenerationPrompt,\n leadResearcherPrompt,\n researchSystemPrompt,\n transformMessagesIntoResearchTopicPrompt,\n} from \"@/chatjs/tools/deep-research/prompts\";\nimport {\n prepareResearch,\n saveResearchReport,\n} from \"@/chatjs/tools/deep-research/steps\";\nimport {\n researchBrief,\n researchInput,\n researchClarification,\n researchDecision,\n researchFindings,\n researchReport,\n researchOutput,\n} from \"@/chatjs/tools/deep-research/schemas\";\nimport type { ResearchUpdate } from \"@/tools/platform/research-updates-schema\";\nimport type { ToolResult } from \"@/lib/eve/tool-result\";\nimport type { AgentSession, WorkflowToolContext } from \"eve/tools\";\nimport { createToolResult } from \"@/lib/eve/tool-result\";\nimport { validateToolOutput } from \"@/chatjs/core/tools/validate-output\";\nimport { researchSearchUpdates } from \"@/chatjs/tools/deep-research/search-updates\";\nimport { z } from \"zod\";\n\ntype ResearchOutput = z.infer<typeof researchOutput>;\n\ntype ResearchWorkflowContext = Readonly<\n Omit<WorkflowToolContext, \"abortSignal\"> & {\n abortSignal: Readonly<AbortSignal>;\n }\n>;\n\nconst structuredMessage = (message: string): string =>\n `${message}\\n\\nDeliver the requested fields through the eve__reply tool. Put any Markdown inside its string fields; do not return prose or JSON text instead of calling the tool.`;\n\nconst outputSchema = (schema: z.ZodType): Record<string, z.JSONType> =>\n z.record(z.string(), z.json()).parse(z.toJSONSchema(schema));\n\nconst researchReply = async (\n agent: Readonly<AgentSession>,\n options: Readonly<{\n message: string;\n outputSchema: Record<string, z.JSONType>;\n signal: AbortSignal;\n }>\n): Promise<unknown> => {\n options.signal.throwIfAborted();\n const response = await agent.send(options.message, {\n outputSchema: options.outputSchema,\n signal: options.signal,\n });\n const result = await response.result();\n options.signal.throwIfAborted();\n if (result.status === \"failed\") {\n throw new Error(result.error?.message ?? \"Research agent failed\");\n }\n if (result.data === undefined) {\n throw new Error(\"Research agent ended without structured output\");\n }\n return result.data;\n};\n\nconst ORCHESTRATION_COST_USD = 0;\nconst INITIAL_RESEARCH_ROUND = 0;\nconst RESEARCH_ROUND_INCREMENT = 1;\nconst BRIEF_UPDATE_INDEX = 1;\nconst EMPTY_TOPIC_COUNT = 0;\n\nexport default defineWorkflowTool({\n availableInSubagents: false,\n description:\n \"Conduct deep research using this conversation and installed search, then save a cited report. Use only for explicit deep research requests, at most once per user turn. If research fails, report the failure and let the user choose whether to retry; do not start duplicate research calls. If clarification is needed, ask the returned questions and call again after the user answers. The report is displayed to the user; do not repeat it in full.\",\n async *execute(\n _input: Readonly<Record<string, never>>,\n context: ResearchWorkflowContext\n ): AsyncGenerator<ToolResult<ResearchOutput>, void> {\n \"use workflow\";\n requireAccountSession(context.session);\n const { config, date, messages, timestamp } =\n await prepareResearch(context);\n const updates: ResearchUpdate[] = [];\n let searchUpdates: ResearchUpdate[] = [];\n // Native child events own model/search costs. This orchestration receipt adds no charge.\n const progress = (): ToolResult<ResearchOutput> =>\n createToolResult<ResearchOutput>(\n validateToolOutput(researchOutput, { searches: [] }),\n ORCHESTRATION_COST_USD,\n [...updates, ...searchUpdates]\n );\n if (config.allow_clarification) {\n const clarification = researchClarification.parse(\n await researchReply(context.agent(\"researchPlanner\"), {\n signal: context.abortSignal,\n message: structuredMessage(\n clarifyWithUserInstructions({ date, messages })\n ),\n outputSchema: outputSchema(researchClarification),\n })\n );\n if (clarification.need_clarification) {\n yield createToolResult(\n validateToolOutput(researchOutput, {\n answer: clarification.question,\n format: \"clarifying_questions\",\n }),\n ORCHESTRATION_COST_USD\n );\n return;\n }\n }\n updates.push(\n {\n timestamp,\n title: \"Starting research\",\n toolCallId: context.callId,\n type: \"started\",\n },\n {\n status: \"running\",\n title: \"Writing research brief\",\n toolCallId: context.callId,\n type: \"writing\",\n }\n );\n yield progress();\n const brief = researchBrief.parse(\n await researchReply(context.agent(\"researchPlanner\"), {\n signal: context.abortSignal,\n message: structuredMessage(\n transformMessagesIntoResearchTopicPrompt({ date, messages })\n ),\n outputSchema: outputSchema(researchBrief),\n })\n );\n updates[BRIEF_UPDATE_INDEX] = {\n message: brief.research_brief,\n status: \"completed\",\n title: \"Writing research brief\",\n toolCallId: context.callId,\n type: \"writing\",\n };\n yield progress();\n\n const notes: { topic: string; findings: string }[] = [];\n const decisionSchema = researchDecision.extend({\n topics: researchDecision.shape.topics.max(\n config.max_concurrent_research_units\n ),\n });\n // Preserve the SDK's max_researcher_iterations + 1 decision steps, including\n // its allowance for research on the final step if the supervisor has not finished.\n for (\n let round = INITIAL_RESEARCH_ROUND;\n round <= config.max_researcher_iterations;\n round += RESEARCH_ROUND_INCREMENT\n ) {\n context.abortSignal.throwIfAborted();\n const decision = decisionSchema.parse(\n // oxlint-disable-next-line no-await-in-loop -- Each decision consumes the findings added by the preceding round.\n await researchReply(context.agent(\"researchPlanner\"), {\n signal: context.abortSignal,\n message: structuredMessage(\n `${leadResearcherPrompt({ date, max_concurrent_research_units: config.max_concurrent_research_units })}\\n\\nResearch brief: ${brief.research_brief}\\n\\nFindings so far:\\n${JSON.stringify(notes)}\\n\\nDecision round ${round + RESEARCH_ROUND_INCREMENT} of ${config.max_researcher_iterations + RESEARCH_ROUND_INCREMENT}. Return your next decision.`\n ),\n outputSchema: outputSchema(decisionSchema),\n })\n );\n if (decision.complete) {\n break;\n }\n if (decision.topics.length === EMPTY_TOPIC_COUNT) {\n throw new Error(\n \"The research supervisor must select topics or finish.\"\n );\n }\n for (const topic of decision.topics) {\n context.abortSignal.throwIfAborted();\n const updateIndex = updates.length;\n updates.push({\n message: topic,\n status: \"running\",\n title: \"Researching topic\",\n toolCallId: context.callId,\n type: \"thoughts\",\n });\n yield progress();\n let raw: z.infer<typeof researchFindings>;\n try {\n raw = researchFindings.parse(\n // oxlint-disable-next-line no-await-in-loop -- Publish each topic's progress and finish its child before advancing; failure must prevent later topics from starting.\n await researchReply(context.agent(\"researcher\"), {\n signal: context.abortSignal,\n message: structuredMessage(\n `${researchSystemPrompt({ date, max_search_queries: config.search_api_max_queries, mcp_prompt: \"\" })}\\n\\nTopic:\\n${topic}\\n\\nReturn comprehensive raw findings, preserving source URLs, citations, relevant quotations, uncertainties, and conflicting evidence for the compression stage.`\n ),\n outputSchema: outputSchema(researchFindings),\n })\n );\n } catch (error) {\n // Keep completed search evidence even if the researcher later fails.\n // Cancellation must stop promptly instead of starting more reads.\n context.abortSignal.throwIfAborted();\n const previousSearchUpdates = searchUpdates;\n // oxlint-disable-next-line no-await-in-loop -- Preserve completed search evidence before publishing the failure and terminating the topic loop.\n searchUpdates = await researchSearchUpdates(context).catch(\n () => previousSearchUpdates\n );\n yield progress();\n throw error;\n }\n // oxlint-disable-next-line no-await-in-loop -- Read the just-completed child's evidence before publishing progress and compressing its findings.\n searchUpdates = await researchSearchUpdates(context);\n yield progress();\n const compressed = researchFindings.parse(\n // oxlint-disable-next-line no-await-in-loop -- Commit this topic's compressed notes before the next topic and supervisor decision.\n await researchReply(context.agent(\"researchCompressor\"), {\n signal: context.abortSignal,\n message: structuredMessage(\n `${compressResearchSystemPrompt({ date })}\\n\\n${raw.findings}\\n\\n${compressResearchSimpleHumanMessage}`\n ),\n outputSchema: outputSchema(researchFindings),\n })\n );\n notes.push({ findings: compressed.findings, topic });\n updates[updateIndex] = {\n message: topic,\n status: \"completed\",\n title: \"Research topic completed\",\n toolCallId: context.callId,\n type: \"thoughts\",\n };\n yield progress();\n }\n }\n const reportUpdateIndex = updates.length;\n updates.push({\n status: \"running\",\n title: \"Writing final report\",\n toolCallId: context.callId,\n type: \"writing\",\n });\n yield progress();\n const report = researchReport.parse(\n await researchReply(context.agent(\"researchWriter\"), {\n signal: context.abortSignal,\n message: structuredMessage(\n `${finalReportGenerationPrompt({ date, findings: notes.map((note: Readonly<(typeof notes)[number]>): string => note.findings).join(\"\\n\"), research_brief: brief.research_brief })}\\n\\nWrite the complete Markdown report with title ${JSON.stringify(brief.title)}. Return title and content; the workflow will save the document.`\n ),\n outputSchema: outputSchema(researchReport),\n })\n );\n context.abortSignal.throwIfAborted();\n const { document, completedAt } = await saveResearchReport(context, report);\n updates[reportUpdateIndex] = {\n status: \"completed\",\n title: \"Writing final report\",\n toolCallId: context.callId,\n type: \"writing\",\n };\n updates.push({\n timestamp: completedAt,\n title: \"Research complete\",\n toolCallId: context.callId,\n type: \"completed\",\n });\n yield createToolResult(\n validateToolOutput(researchOutput, { ...document, format: \"report\" }),\n ORCHESTRATION_COST_USD,\n [...updates, ...searchUpdates]\n );\n },\n inputSchema: researchInput,\n toModelOutput: toolResultToModelOutput,\n});\n",
|
|
106
101
|
"type": "registry:file",
|
|
107
102
|
"target": "~/agent/tools/deepResearch.ts"
|
|
108
103
|
},
|
|
109
104
|
{
|
|
110
105
|
"path": "src/tools/deep-research/agent/subagents/researchPlanner/agent.ts",
|
|
111
|
-
"content": "
|
|
106
|
+
"content": "// ChatJS source: deep-research. Ownership: chatjs/tools/deep-research/chatjs.json.\nimport { defineResearchAgent } from \"@/chatjs/tools/deep-research/agent\";\n\nexport default defineResearchAgent(\"research\");\n",
|
|
112
107
|
"type": "registry:file",
|
|
113
108
|
"target": "~/agent/subagents/researchPlanner/agent.ts"
|
|
114
109
|
},
|
|
115
110
|
{
|
|
116
111
|
"path": "src/tools/deep-research/agent/subagents/researchPlanner/sandbox.ts",
|
|
117
|
-
"content": "
|
|
112
|
+
"content": "// ChatJS source: deep-research. Ownership: chatjs/tools/deep-research/chatjs.json.\nimport { defineParentSandbox } from \"eve/sandbox\";\n\nexport default defineParentSandbox();\n",
|
|
118
113
|
"type": "registry:file",
|
|
119
114
|
"target": "~/agent/subagents/researchPlanner/sandbox.ts"
|
|
120
115
|
},
|
|
121
116
|
{
|
|
122
117
|
"path": "src/tools/deep-research/agent/subagents/researchPlanner/hooks/billing.ts",
|
|
123
|
-
"content": "
|
|
118
|
+
"content": "// ChatJS source: deep-research. Ownership: chatjs/tools/deep-research/chatjs.json.\nexport { default } from \"@/agent/hooks/billing\";\n",
|
|
124
119
|
"type": "registry:file",
|
|
125
120
|
"target": "~/agent/subagents/researchPlanner/hooks/billing.ts"
|
|
126
121
|
},
|
|
127
122
|
{
|
|
128
123
|
"path": "src/tools/deep-research/agent/subagents/researchWriter/agent.ts",
|
|
129
|
-
"content": "
|
|
124
|
+
"content": "// ChatJS source: deep-research. Ownership: chatjs/tools/deep-research/chatjs.json.\nimport { defineResearchAgent } from \"@/chatjs/tools/deep-research/agent\";\n\nexport default defineResearchAgent(\"final_report\");\n",
|
|
130
125
|
"type": "registry:file",
|
|
131
126
|
"target": "~/agent/subagents/researchWriter/agent.ts"
|
|
132
127
|
},
|
|
133
128
|
{
|
|
134
129
|
"path": "src/tools/deep-research/agent/subagents/researchWriter/sandbox.ts",
|
|
135
|
-
"content": "
|
|
130
|
+
"content": "// ChatJS source: deep-research. Ownership: chatjs/tools/deep-research/chatjs.json.\nimport { defineParentSandbox } from \"eve/sandbox\";\n\nexport default defineParentSandbox();\n",
|
|
136
131
|
"type": "registry:file",
|
|
137
132
|
"target": "~/agent/subagents/researchWriter/sandbox.ts"
|
|
138
133
|
},
|
|
139
134
|
{
|
|
140
135
|
"path": "src/tools/deep-research/agent/subagents/researchWriter/hooks/billing.ts",
|
|
141
|
-
"content": "
|
|
136
|
+
"content": "// ChatJS source: deep-research. Ownership: chatjs/tools/deep-research/chatjs.json.\nexport { default } from \"@/agent/hooks/billing\";\n",
|
|
142
137
|
"type": "registry:file",
|
|
143
138
|
"target": "~/agent/subagents/researchWriter/hooks/billing.ts"
|
|
144
139
|
},
|
|
145
140
|
{
|
|
146
141
|
"path": "src/tools/deep-research/agent/subagents/researchCompressor/agent.ts",
|
|
147
|
-
"content": "
|
|
142
|
+
"content": "// ChatJS source: deep-research. Ownership: chatjs/tools/deep-research/chatjs.json.\nimport { defineResearchAgent } from \"@/chatjs/tools/deep-research/agent\";\n\nexport default defineResearchAgent(\"compression\");\n",
|
|
148
143
|
"type": "registry:file",
|
|
149
144
|
"target": "~/agent/subagents/researchCompressor/agent.ts"
|
|
150
145
|
},
|
|
151
146
|
{
|
|
152
147
|
"path": "src/tools/deep-research/agent/subagents/researchCompressor/sandbox.ts",
|
|
153
|
-
"content": "
|
|
148
|
+
"content": "// ChatJS source: deep-research. Ownership: chatjs/tools/deep-research/chatjs.json.\nimport { defineParentSandbox } from \"eve/sandbox\";\n\nexport default defineParentSandbox();\n",
|
|
154
149
|
"type": "registry:file",
|
|
155
150
|
"target": "~/agent/subagents/researchCompressor/sandbox.ts"
|
|
156
151
|
},
|
|
157
152
|
{
|
|
158
153
|
"path": "src/tools/deep-research/agent/subagents/researchCompressor/hooks/billing.ts",
|
|
159
|
-
"content": "
|
|
154
|
+
"content": "// ChatJS source: deep-research. Ownership: chatjs/tools/deep-research/chatjs.json.\nexport { default } from \"@/agent/hooks/billing\";\n",
|
|
160
155
|
"type": "registry:file",
|
|
161
156
|
"target": "~/agent/subagents/researchCompressor/hooks/billing.ts"
|
|
162
157
|
},
|
|
163
158
|
{
|
|
164
159
|
"path": "src/tools/deep-research/agent/subagents/researcher/agent.ts",
|
|
165
|
-
"content": "
|
|
160
|
+
"content": "// ChatJS source: deep-research. Ownership: chatjs/tools/deep-research/chatjs.json.\nimport { defineResearchAgent } from \"@/chatjs/tools/deep-research/agent\";\n\nexport default defineResearchAgent(\"research\");\n",
|
|
166
161
|
"type": "registry:file",
|
|
167
162
|
"target": "~/agent/subagents/researcher/agent.ts"
|
|
168
163
|
},
|
|
169
164
|
{
|
|
170
165
|
"path": "src/tools/deep-research/agent/subagents/researcher/sandbox.ts",
|
|
171
|
-
"content": "
|
|
166
|
+
"content": "// ChatJS source: deep-research. Ownership: chatjs/tools/deep-research/chatjs.json.\nimport { defineParentSandbox } from \"eve/sandbox\";\n\nexport default defineParentSandbox();\n",
|
|
172
167
|
"type": "registry:file",
|
|
173
168
|
"target": "~/agent/subagents/researcher/sandbox.ts"
|
|
174
169
|
},
|
|
175
170
|
{
|
|
176
171
|
"path": "src/tools/deep-research/agent/subagents/researcher/tools/web-search.ts",
|
|
177
|
-
"content": "import {
|
|
172
|
+
"content": "import { runs } from \"eve/events\";\nimport { defineDynamic } from \"eve/tools\";\n\nimport { isAccountSession } from \"@/lib/eve/session-identity\";\nimport { toolProviders } from \"@/integrations/tools/providers\";\n\nconst MAX_RESEARCH_SEARCH_ROUNDS = 19;\n\nconst requireResearchSearch =\n (): (typeof toolProviders)[keyof typeof toolProviders] => {\n const providerEntry = Object.entries(toolProviders).find(\n ([name]: Readonly<[string, unknown]>) => name === \"webSearch\"\n );\n const [, search] = providerEntry ?? [];\n if (!search) {\n throw new Error(\"Deep research requires an installed webSearch tool.\");\n }\n return search;\n };\n\nexport default defineDynamic((context) => {\n if (!isAccountSession(context.session)) {\n throw new Error(\"Research search is unavailable.\");\n }\n const search = requireResearchSearch();\n // The old SDK researcher allowed twenty model steps. Reserve the last\n // response for findings, without enabling another search round.\n const searchRounds = runs(context.view, { turnId: context.turn?.id }).filter(\n (run) => run.status === \"settled\"\n ).length;\n\n if (searchRounds >= MAX_RESEARCH_SEARCH_ROUNDS) {\n return null;\n }\n return search;\n});\n",
|
|
178
173
|
"type": "registry:file",
|
|
179
174
|
"target": "~/agent/subagents/researcher/tools/webSearch.ts"
|
|
180
175
|
},
|
|
181
176
|
{
|
|
182
177
|
"path": "src/tools/deep-research/agent/subagents/researcher/hooks/billing.ts",
|
|
183
|
-
"content": "
|
|
178
|
+
"content": "// ChatJS source: deep-research. Ownership: chatjs/tools/deep-research/chatjs.json.\nexport { default } from \"@/agent/hooks/billing\";\n",
|
|
184
179
|
"type": "registry:file",
|
|
185
180
|
"target": "~/agent/subagents/researcher/hooks/billing.ts"
|
|
186
181
|
},
|
|
@@ -188,7 +183,7 @@
|
|
|
188
183
|
"path": "dist/source/deep-research.json",
|
|
189
184
|
"content": "{\n \"config\": { \"key\": \"deepResearch\" },\n \"availabilityExport\": \"researchAvailable\",\n \"envRequirements\": [],\n \"id\": \"deep-research\",\n \"kind\": \"tool\",\n \"requiresTools\": [\"createTextDocument\", \"readDocument\", \"webSearch\"],\n \"tools\": [\n {\n \"composer\": {\n \"icon\": \"Telescope\",\n \"name\": \"Deep Research\",\n \"shortName\": \"Research\"\n },\n \"rendererExport\": \"DeepResearchRenderer\",\n \"toolExport\": \"deepResearch\",\n \"workflow\": true\n }\n ],\n \"contractVersion\": 1\n}\n",
|
|
190
185
|
"type": "registry:file",
|
|
191
|
-
"target": "~/tools/
|
|
186
|
+
"target": "~/chatjs/tools/deep-research/chatjs.json"
|
|
192
187
|
}
|
|
193
188
|
],
|
|
194
189
|
"meta": {
|
|
@@ -10,31 +10,31 @@
|
|
|
10
10
|
"path": "src/tools/delete-document/tool.ts",
|
|
11
11
|
"content": "import type { ApprovalResponseContext } from \"eve/tools/approval\";\nimport type { ToolContext } from \"eve/tools\";\nimport { defineTool } from \"eve/tools\";\nimport { executeDocumentDeletion, requestDocumentDeletion } from \"./execute\";\nimport { deleteDocumentInput } from \"./schemas\";\nimport type { z } from \"zod\";\n\ntype DeleteDocumentInput = z.infer<typeof deleteDocumentInput>;\ntype DeleteDocumentRequestContext = Readonly<\n Pick<ToolContext, \"callId\" | \"session\"> & {\n abortSignal: Readonly<AbortSignal>;\n toolInput?: Readonly<DeleteDocumentInput>;\n }\n>;\ntype DeleteDocumentPrincipal = Readonly<\n Pick<\n ApprovalResponseContext<DeleteDocumentInput>[\"response\"][\"principal\"],\n \"principalId\"\n >\n>;\ntype DeleteDocumentResponseContext = Readonly<\n Pick<ApprovalResponseContext<DeleteDocumentInput>, \"response\"> & {\n session: Readonly<{\n initiator: DeleteDocumentPrincipal | null;\n }>;\n }\n>;\n\nexport const deleteDocument = defineTool({\n approval: {\n request: async (context: DeleteDocumentRequestContext) =>\n await requestDocumentDeletion(context.toolInput, context),\n response: ({ response, session }: DeleteDocumentResponseContext) => {\n if (\n response.principal.principalId === (session.initiator ?? {}).principalId\n ) {\n return { status: \"allowed\" };\n }\n return {\n reason: \"Only the document owner may approve deletion.\",\n status: \"rejected\",\n };\n },\n },\n description:\n \"Request owner approval to remove a document from this conversation. Read it first and supply its exact title and revision. Call this tool to display the approval controls; do not ask for confirmation in a chat message. Execution waits for approval. Historical snapshots and other branches retain their copies; this does not permanently erase their content.\",\n execute: executeDocumentDeletion,\n inputSchema: deleteDocumentInput,\n});\n",
|
|
12
12
|
"type": "registry:file",
|
|
13
|
-
"target": "~/tools/
|
|
13
|
+
"target": "~/chatjs/tools/delete-document/tool.ts"
|
|
14
14
|
},
|
|
15
15
|
{
|
|
16
16
|
"path": "src/tools/delete-document/execute.ts",
|
|
17
|
-
"content": "import {\n getEveDocumentRevision,\n removeEveDocumentFromConversation,\n} from \"@/lib/db/eve-documents\";\nimport type { ToolContext } from \"eve/tools\";\nimport { deleteDocumentAvailable } from \"./availability\";\nimport { deleteDocumentInput } from \"./schemas\";\nimport { installedDocumentKinds } from \"@/
|
|
17
|
+
"content": "import {\n getEveDocumentRevision,\n removeEveDocumentFromConversation,\n} from \"@/lib/db/eve-documents\";\nimport type { ToolContext } from \"eve/tools\";\nimport { deleteDocumentAvailable } from \"./availability\";\nimport { deleteDocumentInput } from \"./schemas\";\nimport { installedDocumentKinds } from \"@/integrations/tools/catalog\";\nimport { resolveEveConversationScope } from \"@/lib/eve/conversation-scope\";\nimport type { z } from \"zod\";\n\ntype Context = Readonly<\n Pick<ToolContext, \"session\" | \"callId\" | \"approval\"> & {\n abortSignal: Readonly<AbortSignal>;\n }\n>;\n\nconst scopeFor = async (\n context: Context\n): ReturnType<typeof resolveEveConversationScope> => {\n if (!deleteDocumentAvailable(context.session)) {\n throw new Error(\"Document deletion is unavailable.\");\n }\n return await resolveEveConversationScope(\n (context.session.auth.initiator ?? {}).principalId,\n context.session.id,\n context.abortSignal\n );\n};\nconst requestDocumentDeletion = async (\n value: unknown,\n context: Context\n): Promise<\"user-approval\"> => {\n const input = deleteDocumentInput.parse(value);\n const scope = await scopeFor(context);\n const revision = await getEveDocumentRevision(\n scope.ownerId,\n scope.conversationId,\n input.documentId\n );\n if (!revision || !installedDocumentKinds.has(revision.kind)) {\n throw new Error(\"Document not found.\");\n }\n if (\n revision.id !== input.expectedRevisionId ||\n revision.title !== input.title\n ) {\n throw new Error(\n \"Document changed. Read it again before requesting deletion.\"\n );\n }\n context.abortSignal.throwIfAborted();\n return \"user-approval\" as const;\n};\nconst executeDocumentDeletion = async (\n input: Readonly<z.infer<typeof deleteDocumentInput>>,\n context: Context\n): ReturnType<typeof removeEveDocumentFromConversation> => {\n const scope = await scopeFor(context);\n const { approval } = context;\n if (!approval || approval.responder.principalId !== scope.ownerId) {\n throw new Error(\"Document deletion requires the owner's approval.\");\n }\n const revision = await getEveDocumentRevision(\n scope.ownerId,\n scope.conversationId,\n input.documentId\n );\n if (revision && !installedDocumentKinds.has(revision.kind)) {\n throw new Error(\"Document tools are disabled for this kind.\");\n }\n return await removeEveDocumentFromConversation(\n input,\n scope,\n context.abortSignal\n );\n};\nexport { executeDocumentDeletion, requestDocumentDeletion };\n",
|
|
18
18
|
"type": "registry:file",
|
|
19
|
-
"target": "~/tools/
|
|
19
|
+
"target": "~/chatjs/tools/delete-document/execute.ts"
|
|
20
20
|
},
|
|
21
21
|
{
|
|
22
22
|
"path": "src/tools/delete-document/schemas.ts",
|
|
23
23
|
"content": "import { z } from \"zod\";\n\nconst MINIMUM_DOCUMENT_TITLE_LENGTH = 1;\nconst MAXIMUM_DOCUMENT_TITLE_LENGTH = 1000;\n\nexport const deleteDocumentInput = z.object({\n documentId: z.uuid(),\n expectedRevisionId: z\n .uuid()\n .describe(\"Current revision ID returned by readDocument.\"),\n title: z\n .string()\n .min(MINIMUM_DOCUMENT_TITLE_LENGTH)\n .max(MAXIMUM_DOCUMENT_TITLE_LENGTH)\n .describe(\n \"Exact current title returned by readDocument, shown for approval.\"\n ),\n});\n",
|
|
24
24
|
"type": "registry:file",
|
|
25
|
-
"target": "~/tools/
|
|
25
|
+
"target": "~/chatjs/tools/delete-document/schemas.ts"
|
|
26
26
|
},
|
|
27
27
|
{
|
|
28
28
|
"path": "src/tools/delete-document/availability.ts",
|
|
29
|
-
"content": "import type { ToolContext } from \"eve/tools\";\n\nimport { installedDocumentKinds } from \"@/
|
|
29
|
+
"content": "import { isAccountSession } from \"@/lib/eve/session-identity\";\nimport type { ToolContext } from \"eve/tools\";\n\nimport { installedDocumentKinds } from \"@/integrations/tools/catalog\";\n\nconst EMPTY_DOCUMENT_KIND_COUNT = 0;\n\nexport const deleteDocumentAvailable = (\n session: Pick<ToolContext[\"session\"], \"auth\" | \"parent\">\n): boolean =>\n isAccountSession(session) &&\n !session.parent &&\n installedDocumentKinds.size > EMPTY_DOCUMENT_KIND_COUNT;\n",
|
|
30
30
|
"type": "registry:file",
|
|
31
|
-
"target": "~/tools/
|
|
31
|
+
"target": "~/chatjs/tools/delete-document/availability.ts"
|
|
32
32
|
},
|
|
33
33
|
{
|
|
34
34
|
"path": "dist/source/delete-document.json",
|
|
35
35
|
"content": "{\n \"availabilityExport\": \"deleteDocumentAvailable\",\n \"envRequirements\": [],\n \"id\": \"delete-document\",\n \"kind\": \"tool\",\n \"requiresTools\": [\"readDocument\"],\n \"tools\": [{ \"toolExport\": \"deleteDocument\" }],\n \"contractVersion\": 1\n}\n",
|
|
36
36
|
"type": "registry:file",
|
|
37
|
-
"target": "~/tools/
|
|
37
|
+
"target": "~/chatjs/tools/delete-document/chatjs.json"
|
|
38
38
|
}
|
|
39
39
|
],
|
|
40
40
|
"meta": {
|