@chat-js/registry 0.2.0-beta.1 → 0.2.0-beta.10

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.
Files changed (280) hide show
  1. package/README.md +16 -12
  2. package/dist/r/ai-titles.json +14 -17
  3. package/dist/r/akamai-storage.json +13 -1
  4. package/dist/r/alibaba-storage.json +13 -1
  5. package/dist/r/appwrite-storage.json +8 -1
  6. package/dist/r/archil-storage.json +8 -1
  7. package/dist/r/attach-workspace-file.json +82 -0
  8. package/dist/r/attachment-uploads.json +24 -35
  9. package/dist/r/azure-storage.json +8 -1
  10. package/dist/r/backblaze-b2-storage.json +13 -1
  11. package/dist/r/base/ai-titles.json +14 -17
  12. package/dist/r/base/akamai-storage.json +13 -1
  13. package/dist/r/base/alibaba-storage.json +13 -1
  14. package/dist/r/base/appwrite-storage.json +8 -1
  15. package/dist/r/base/archil-storage.json +8 -1
  16. package/dist/r/base/attach-workspace-file.json +82 -0
  17. package/dist/r/base/attachment-uploads.json +24 -35
  18. package/dist/r/base/azure-storage.json +8 -1
  19. package/dist/r/base/backblaze-b2-storage.json +13 -1
  20. package/dist/r/base/bunny-storage-storage.json +2 -1
  21. package/dist/r/base/cloudinary-storage.json +2 -1
  22. package/dist/r/base/credits.json +24 -46
  23. package/dist/r/base/deep-research.json +55 -141
  24. package/dist/r/base/default-sandbox.json +35 -0
  25. package/dist/r/base/desktop.json +129 -0
  26. package/dist/r/base/digitalocean-spaces-storage.json +13 -1
  27. package/dist/r/base/docker-sandbox.json +35 -0
  28. package/dist/r/base/dropbox-storage.json +2 -1
  29. package/dist/r/base/exoscale-storage.json +13 -1
  30. package/dist/r/base/feedback.json +31 -53
  31. package/dist/r/base/filebase-storage.json +8 -1
  32. package/dist/r/base/firebase-storage-storage.json +2 -1
  33. package/dist/r/base/followup-suggestions.json +44 -66
  34. package/dist/r/base/ftp-storage.json +18 -1
  35. package/dist/r/base/gcs-storage.json +8 -1
  36. package/dist/r/base/generate-image.json +22 -16
  37. package/dist/r/base/generate-video.json +16 -10
  38. package/dist/r/base/google-drive-storage.json +2 -1
  39. package/dist/r/base/guest-chat.json +166 -0
  40. package/dist/r/base/hetzner-storage.json +13 -1
  41. package/dist/r/base/ibm-cos-storage.json +13 -1
  42. package/dist/r/base/idrive-e2-storage.json +13 -1
  43. package/dist/r/base/image-viewer.json +49 -0
  44. package/dist/r/base/just-bash-sandbox.json +32 -0
  45. package/dist/r/base/litellm-gateway.json +5 -8
  46. package/dist/r/base/mcp.json +128 -121
  47. package/dist/r/base/memory-storage.json +5 -3
  48. package/dist/r/base/minio-storage.json +13 -1
  49. package/dist/r/base/model-preferences.json +41 -55
  50. package/dist/r/base/neon-storage.json +8 -1
  51. package/dist/r/base/netlify-blobs-storage.json +10 -2
  52. package/dist/r/base/onedrive-storage.json +2 -1
  53. package/dist/r/base/openai-compatible-gateway.json +5 -8
  54. package/dist/r/base/openai-gateway.json +5 -8
  55. package/dist/r/base/openrouter-gateway.json +4 -8
  56. package/dist/r/base/oracle-cloud-storage.json +18 -1
  57. package/dist/r/base/ovhcloud-storage.json +13 -1
  58. package/dist/r/base/pocketbase-storage.json +2 -1
  59. package/dist/r/base/projects.json +107 -108
  60. package/dist/r/base/r2-storage.json +9 -1
  61. package/dist/r/base/registry.json +2340 -2555
  62. package/dist/r/base/s3-storage.json +15 -1
  63. package/dist/r/base/scaleway-storage.json +13 -1
  64. package/dist/r/base/search.json +74 -66
  65. package/dist/r/base/sftp-storage.json +18 -1
  66. package/dist/r/base/sharepoint-storage.json +2 -1
  67. package/dist/r/base/sharing.json +58 -64
  68. package/dist/r/base/spreadsheet-grid.json +20 -0
  69. package/dist/r/base/spreadsheet-viewer.json +62 -0
  70. package/dist/r/base/storj-storage.json +8 -1
  71. package/dist/r/base/streamdown-math.json +35 -0
  72. package/dist/r/base/streamdown-mermaid.json +34 -0
  73. package/dist/r/base/supabase-storage.json +8 -1
  74. package/dist/r/base/tencent-storage.json +13 -1
  75. package/dist/r/base/tigris-storage.json +8 -1
  76. package/dist/r/base/uploadthing-storage.json +2 -1
  77. package/dist/r/base/vercel-blob-storage.json +3 -1
  78. package/dist/r/base/vercel-gateway.json +7 -9
  79. package/dist/r/base/vercel-sandbox.json +8 -26
  80. package/dist/r/base/video-viewer.json +42 -0
  81. package/dist/r/base/vultr-storage.json +13 -1
  82. package/dist/r/base/wasabi-storage.json +13 -1
  83. package/dist/r/base/webdav-storage.json +13 -1
  84. package/dist/r/base/yandex-storage.json +8 -1
  85. package/dist/r/bunny-storage-storage.json +2 -1
  86. package/dist/r/cloudinary-storage.json +2 -1
  87. package/dist/r/credits.json +24 -46
  88. package/dist/r/deep-research.json +55 -141
  89. package/dist/r/default-sandbox.json +35 -0
  90. package/dist/r/desktop.json +129 -0
  91. package/dist/r/digitalocean-spaces-storage.json +13 -1
  92. package/dist/r/docker-sandbox.json +35 -0
  93. package/dist/r/dropbox-storage.json +2 -1
  94. package/dist/r/eve/deep-research.json +47 -0
  95. package/dist/r/eve/registry.json +53 -0
  96. package/dist/r/exoscale-storage.json +13 -1
  97. package/dist/r/feedback.json +31 -53
  98. package/dist/r/filebase-storage.json +8 -1
  99. package/dist/r/firebase-storage-storage.json +2 -1
  100. package/dist/r/followup-suggestions.json +44 -66
  101. package/dist/r/ftp-storage.json +18 -1
  102. package/dist/r/gcs-storage.json +8 -1
  103. package/dist/r/generate-image.json +22 -16
  104. package/dist/r/generate-video.json +16 -10
  105. package/dist/r/google-drive-storage.json +2 -1
  106. package/dist/r/guest-chat.json +166 -0
  107. package/dist/r/hetzner-storage.json +13 -1
  108. package/dist/r/ibm-cos-storage.json +13 -1
  109. package/dist/r/idrive-e2-storage.json +13 -1
  110. package/dist/r/image-viewer.json +49 -0
  111. package/dist/r/just-bash-sandbox.json +32 -0
  112. package/dist/r/litellm-gateway.json +5 -8
  113. package/dist/r/mcp.json +128 -121
  114. package/dist/r/memory-storage.json +5 -3
  115. package/dist/r/minio-storage.json +13 -1
  116. package/dist/r/model-preferences.json +41 -55
  117. package/dist/r/neon-storage.json +8 -1
  118. package/dist/r/netlify-blobs-storage.json +10 -2
  119. package/dist/r/onedrive-storage.json +2 -1
  120. package/dist/r/openai-compatible-gateway.json +5 -8
  121. package/dist/r/openai-gateway.json +5 -8
  122. package/dist/r/openrouter-gateway.json +4 -8
  123. package/dist/r/oracle-cloud-storage.json +18 -1
  124. package/dist/r/ovhcloud-storage.json +13 -1
  125. package/dist/r/pocketbase-storage.json +2 -1
  126. package/dist/r/projects.json +107 -108
  127. package/dist/r/r2-storage.json +9 -1
  128. package/dist/r/radix/ai-titles.json +14 -17
  129. package/dist/r/radix/akamai-storage.json +13 -1
  130. package/dist/r/radix/alibaba-storage.json +13 -1
  131. package/dist/r/radix/appwrite-storage.json +8 -1
  132. package/dist/r/radix/archil-storage.json +8 -1
  133. package/dist/r/radix/attach-workspace-file.json +82 -0
  134. package/dist/r/radix/attachment-uploads.json +24 -35
  135. package/dist/r/radix/azure-storage.json +8 -1
  136. package/dist/r/radix/backblaze-b2-storage.json +13 -1
  137. package/dist/r/radix/bunny-storage-storage.json +2 -1
  138. package/dist/r/radix/cloudinary-storage.json +2 -1
  139. package/dist/r/radix/credits.json +24 -46
  140. package/dist/r/radix/deep-research.json +55 -141
  141. package/dist/r/radix/default-sandbox.json +35 -0
  142. package/dist/r/radix/desktop.json +129 -0
  143. package/dist/r/radix/digitalocean-spaces-storage.json +13 -1
  144. package/dist/r/radix/docker-sandbox.json +35 -0
  145. package/dist/r/radix/dropbox-storage.json +2 -1
  146. package/dist/r/radix/exoscale-storage.json +13 -1
  147. package/dist/r/radix/feedback.json +31 -53
  148. package/dist/r/radix/filebase-storage.json +8 -1
  149. package/dist/r/radix/firebase-storage-storage.json +2 -1
  150. package/dist/r/radix/followup-suggestions.json +44 -66
  151. package/dist/r/radix/ftp-storage.json +18 -1
  152. package/dist/r/radix/gcs-storage.json +8 -1
  153. package/dist/r/radix/generate-image.json +22 -16
  154. package/dist/r/radix/generate-video.json +16 -10
  155. package/dist/r/radix/google-drive-storage.json +2 -1
  156. package/dist/r/radix/guest-chat.json +166 -0
  157. package/dist/r/radix/hetzner-storage.json +13 -1
  158. package/dist/r/radix/ibm-cos-storage.json +13 -1
  159. package/dist/r/radix/idrive-e2-storage.json +13 -1
  160. package/dist/r/radix/image-viewer.json +49 -0
  161. package/dist/r/radix/just-bash-sandbox.json +32 -0
  162. package/dist/r/radix/litellm-gateway.json +5 -8
  163. package/dist/r/radix/mcp.json +128 -121
  164. package/dist/r/radix/memory-storage.json +5 -3
  165. package/dist/r/radix/minio-storage.json +13 -1
  166. package/dist/r/radix/model-preferences.json +41 -55
  167. package/dist/r/radix/neon-storage.json +8 -1
  168. package/dist/r/radix/netlify-blobs-storage.json +10 -2
  169. package/dist/r/radix/onedrive-storage.json +2 -1
  170. package/dist/r/radix/openai-compatible-gateway.json +5 -8
  171. package/dist/r/radix/openai-gateway.json +5 -8
  172. package/dist/r/radix/openrouter-gateway.json +4 -8
  173. package/dist/r/radix/oracle-cloud-storage.json +18 -1
  174. package/dist/r/radix/ovhcloud-storage.json +13 -1
  175. package/dist/r/radix/pocketbase-storage.json +2 -1
  176. package/dist/r/radix/projects.json +107 -108
  177. package/dist/r/radix/r2-storage.json +9 -1
  178. package/dist/r/radix/registry.json +2339 -2554
  179. package/dist/r/radix/s3-storage.json +15 -1
  180. package/dist/r/radix/scaleway-storage.json +13 -1
  181. package/dist/r/radix/search.json +74 -66
  182. package/dist/r/radix/sftp-storage.json +18 -1
  183. package/dist/r/radix/sharepoint-storage.json +2 -1
  184. package/dist/r/radix/sharing.json +58 -64
  185. package/dist/r/radix/spreadsheet-grid.json +20 -0
  186. package/dist/r/radix/spreadsheet-viewer.json +62 -0
  187. package/dist/r/radix/storj-storage.json +8 -1
  188. package/dist/r/radix/streamdown-math.json +35 -0
  189. package/dist/r/radix/streamdown-mermaid.json +34 -0
  190. package/dist/r/radix/supabase-storage.json +8 -1
  191. package/dist/r/radix/tencent-storage.json +13 -1
  192. package/dist/r/radix/tigris-storage.json +8 -1
  193. package/dist/r/radix/uploadthing-storage.json +2 -1
  194. package/dist/r/radix/vercel-blob-storage.json +3 -1
  195. package/dist/r/radix/vercel-gateway.json +7 -9
  196. package/dist/r/radix/vercel-sandbox.json +8 -26
  197. package/dist/r/radix/video-viewer.json +42 -0
  198. package/dist/r/radix/vultr-storage.json +13 -1
  199. package/dist/r/radix/wasabi-storage.json +13 -1
  200. package/dist/r/radix/webdav-storage.json +13 -1
  201. package/dist/r/radix/yandex-storage.json +8 -1
  202. package/dist/r/registry.json +2340 -2555
  203. package/dist/r/s3-storage.json +15 -1
  204. package/dist/r/scaleway-storage.json +13 -1
  205. package/dist/r/search.json +74 -66
  206. package/dist/r/sftp-storage.json +18 -1
  207. package/dist/r/sharepoint-storage.json +2 -1
  208. package/dist/r/sharing.json +58 -64
  209. package/dist/r/spreadsheet-grid.json +20 -0
  210. package/dist/r/spreadsheet-viewer.json +62 -0
  211. package/dist/r/storj-storage.json +8 -1
  212. package/dist/r/streamdown-math.json +35 -0
  213. package/dist/r/streamdown-mermaid.json +34 -0
  214. package/dist/r/supabase-storage.json +8 -1
  215. package/dist/r/tencent-storage.json +13 -1
  216. package/dist/r/tigris-storage.json +8 -1
  217. package/dist/r/uploadthing-storage.json +2 -1
  218. package/dist/r/vercel-blob-storage.json +3 -1
  219. package/dist/r/vercel-gateway.json +7 -9
  220. package/dist/r/vercel-sandbox.json +8 -26
  221. package/dist/r/video-viewer.json +42 -0
  222. package/dist/r/vultr-storage.json +13 -1
  223. package/dist/r/wasabi-storage.json +13 -1
  224. package/dist/r/webdav-storage.json +13 -1
  225. package/dist/r/yandex-storage.json +8 -1
  226. package/package.json +19 -40
  227. package/dist/r/base/code-documents.json +0 -96
  228. package/dist/r/base/code-execution-runtime.json +0 -25
  229. package/dist/r/base/code-execution-ui.json +0 -32
  230. package/dist/r/base/code-execution.json +0 -69
  231. package/dist/r/base/daytona-sandbox.json +0 -55
  232. package/dist/r/base/delete-document.json +0 -58
  233. package/dist/r/base/firecrawl-search.json +0 -72
  234. package/dist/r/base/get-weather.json +0 -52
  235. package/dist/r/base/langfuse.json +0 -63
  236. package/dist/r/base/read-document.json +0 -34
  237. package/dist/r/base/retrieve-url.json +0 -69
  238. package/dist/r/base/saved-code-execution.json +0 -84
  239. package/dist/r/base/sheet-documents.json +0 -94
  240. package/dist/r/base/tavily-search.json +0 -72
  241. package/dist/r/base/text-documents.json +0 -117
  242. package/dist/r/base/vercel-analytics.json +0 -46
  243. package/dist/r/base/vercel-speed-insights.json +0 -46
  244. package/dist/r/base/word-count.json +0 -51
  245. package/dist/r/code-documents.json +0 -96
  246. package/dist/r/code-execution-runtime.json +0 -25
  247. package/dist/r/code-execution-ui.json +0 -32
  248. package/dist/r/code-execution.json +0 -69
  249. package/dist/r/daytona-sandbox.json +0 -55
  250. package/dist/r/delete-document.json +0 -58
  251. package/dist/r/firecrawl-search.json +0 -72
  252. package/dist/r/get-weather.json +0 -52
  253. package/dist/r/langfuse.json +0 -63
  254. package/dist/r/radix/code-documents.json +0 -96
  255. package/dist/r/radix/code-execution-runtime.json +0 -25
  256. package/dist/r/radix/code-execution-ui.json +0 -32
  257. package/dist/r/radix/code-execution.json +0 -69
  258. package/dist/r/radix/daytona-sandbox.json +0 -55
  259. package/dist/r/radix/delete-document.json +0 -58
  260. package/dist/r/radix/firecrawl-search.json +0 -72
  261. package/dist/r/radix/get-weather.json +0 -52
  262. package/dist/r/radix/langfuse.json +0 -63
  263. package/dist/r/radix/read-document.json +0 -34
  264. package/dist/r/radix/retrieve-url.json +0 -69
  265. package/dist/r/radix/saved-code-execution.json +0 -84
  266. package/dist/r/radix/sheet-documents.json +0 -94
  267. package/dist/r/radix/tavily-search.json +0 -72
  268. package/dist/r/radix/text-documents.json +0 -117
  269. package/dist/r/radix/vercel-analytics.json +0 -46
  270. package/dist/r/radix/vercel-speed-insights.json +0 -46
  271. package/dist/r/radix/word-count.json +0 -51
  272. package/dist/r/read-document.json +0 -34
  273. package/dist/r/retrieve-url.json +0 -69
  274. package/dist/r/saved-code-execution.json +0 -84
  275. package/dist/r/sheet-documents.json +0 -94
  276. package/dist/r/tavily-search.json +0 -72
  277. package/dist/r/text-documents.json +0 -117
  278. package/dist/r/vercel-analytics.json +0 -46
  279. package/dist/r/vercel-speed-insights.json +0 -46
  280. package/dist/r/word-count.json +0 -51
@@ -1,212 +1,122 @@
1
1
  {
2
2
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
3
  "name": "deep-research",
4
- "description": "Native EVE research workflow, subagents, prompts, and progress UI",
4
+ "description": "Research with installed EVE capabilities; produces a sandbox report. ChatJS adds optional progress UI.",
5
5
  "dependencies": [
6
- "lucide-react@0.553.0",
7
- "motion@^12.23.24"
8
- ],
9
- "registryDependencies": [
10
- "@chatjs/text-documents"
6
+ "lucide-react@0.553.0"
11
7
  ],
12
8
  "files": [
13
9
  {
14
10
  "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 \"@/lib/ai/define-tool-renderer\";\nimport { defineToolRenderer } from \"@/lib/ai/define-tool-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: \"output-available\",\n toolCallId: tool.toolCallId,\n toolName: \"createTextDocument\",\n type: \"dynamic-tool\",\n }}\n />\n );\n }\n return <div className=\"space-y-3\">{content}</div>;\n },\n renderProgress: ReasonSearchResearchProgress,\n updateSchema: ResearchUpdateSchema,\n});\n",
16
- "type": "registry:file",
17
- "target": "~/tools/chatjs/deep-research/renderer.tsx"
18
- },
19
- {
20
- "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 Omit<WorkflowToolContext, \"abortSignal\"> & {\n abortSignal: Readonly<AbortSignal>;\n }\n>;\n\ntype Snapshot = Awaited<\n ReturnType<ReturnType<Client[\"sessions\"][\"attach\"]>[\"snapshot\"]>\n>;\ntype StreamEvent = Snapshot[\"events\"][number];\ntype InvocationData = Extract<StreamEvent, { type: \"agent.started\" }>[\"data\"];\ntype InvocationEventView =\n | Readonly<{\n type: \"agent.started\";\n data: Readonly<\n Pick<InvocationData, \"callId\" | \"sessionId\" | \"name\" | \"turnId\"> & {\n remote?: Readonly<NonNullable<InvocationData[\"remote\"]>>;\n }\n >;\n }>\n | Readonly<{ type: Exclude<StreamEvent[\"type\"], \"agent.started\"> }>;\ntype ActionResult = Extract<\n StreamEvent,\n { type: \"action.result\" }\n>[\"data\"][\"result\"];\ntype ActionEventView =\n | Readonly<{\n type: \"action.result\";\n data: Readonly<{\n result:\n | Readonly<{ kind: \"tool-result\"; output: unknown }>\n | Readonly<{ kind: Exclude<ActionResult[\"kind\"], \"tool-result\"> }>;\n }>;\n }>\n | Readonly<{ type: Exclude<StreamEvent[\"type\"], \"action.result\"> }>;\ntype SnapshotView = Readonly<{ events: readonly ActionEventView[] }>;\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: InvocationEventView) => {\n if (\n event.type === \"agent.started\" &&\n !event.data.remote &&\n event.data.name === \"researcher\" &&\n event.data.turnId === context.session.turn.id &&\n // Native agent.started carries the exact owning workflow tool call ID.\n event.data.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: SnapshotView) =>\n snapshot.events.flatMap((event) => {\n if (\n event.type !== \"action.result\" ||\n event.data.result.kind !== \"tool-result\"\n ) {\n return [];\n }\n const receipt = toolOutputSchema.safeParse(event.data.result.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",
11
+ "content": "\"use client\";\nimport { researchInput, researchOutput } from \"./schemas\";\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 }: 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 && result.format !== \"progress\") {\n content =\n result.format === \"clarifying_questions\" ? (\n <p>{result.answer}</p>\n ) : (\n <div className=\"space-y-1\">\n <p className=\"font-medium\">{result.title}</p>\n <p className=\"text-muted-foreground text-sm\">\n Research complete. Report saved in the agent workspace.\n </p>\n </div>\n );\n }\n return <div className=\"space-y-3\">{content}</div>;\n },\n renderProgress: ReasonSearchResearchProgress,\n updateSchema: ResearchUpdateSchema,\n});\n",
22
12
  "type": "registry:file",
23
- "target": "~/tools/chatjs/deep-research/search-updates.ts"
13
+ "target": "~/chatjs/tools/deep-research/renderer.tsx"
24
14
  },
25
15
  {
26
16
  "path": "src/tools/deep-research/progress-panel.tsx",
27
- "content": "import { Maximize2, Minimize2 } from \"lucide-react\";\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\";\nimport { UpdateTitle } from \"./update-title\";\nimport { cn } from \"@/lib/utils\";\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 <div className=\"w-full rounded-lg border p-1\">\n <button\n className={cn(\n \"flex w-full cursor-pointer items-center justify-between rounded-lg px-3 py-2\",\n \"hover:bg-accent hover:text-accent-foreground transition-colors\"\n )}\n onClick={(): void => {\n setIsExpanded(!isExpanded);\n }}\n type=\"button\"\n >\n <div className=\"flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-4\">\n <div className=\"flex flex-col gap-2 sm:flex-row sm:items-center\">\n {isComplete ? (\n <span className=\"text-muted-foreground text-xs\">{`Researched for ${timeSpent} seconds, ${searchCount} searches, ${sourceCount} sources`}</span>\n ) : (\n <UpdateTitle isRunning={!isComplete} title={lastUpdateTitle} />\n )}\n </div>\n </div>\n <div className=\"flex items-center gap-2\">\n {isExpanded ? (\n <Minimize2\n aria-hidden=\"true\"\n className=\"text-muted-foreground size-4 shrink-0\"\n />\n ) : (\n <Maximize2\n aria-hidden=\"true\"\n className=\"text-muted-foreground size-4 shrink-0\"\n />\n )}\n </div>\n </button>\n\n {isExpanded ? (\n <div className=\"px-1 pt-2 pb-1\">\n <ResearchTasks updates={updates} />\n </div>\n ) : (\n lastUpdate &&\n !isComplete && (\n <div className=\"px-4 pt-1 pb-3\">\n {/* We only show the running step in this component */}\n <ResearchTask isRunning minimal update={lastUpdate} />\n </div>\n )\n )}\n </div>\n );\n};\n",
17
+ "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 { ResearchUpdate } 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 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 // 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`\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
18
  "type": "registry:file",
29
- "target": "~/tools/chatjs/deep-research/progress-panel.tsx"
19
+ "target": "~/chatjs/tools/deep-research/progress-panel.tsx"
30
20
  },
31
21
  {
32
22
  "path": "src/tools/deep-research/tool.ts",
33
23
  "content": "export { default as deepResearch } from \"@/agent/tools/deepResearch\";\n",
34
24
  "type": "registry:file",
35
- "target": "~/tools/chatjs/deep-research/tool.ts"
36
- },
37
- {
38
- "path": "src/tools/deep-research/availability.ts",
39
- "content": "import { eveToolAllowed, eveTurnTool } from \"@/lib/eve/turn-tools\";\nimport {\n installedDocumentKinds,\n installedToolNames,\n} from \"@/composition/generated/installed-tools\";\nimport type { ToolContext } from \"eve/tools\";\nimport { providers } from \"@/composition/generated/providers\";\n\nexport const researchAvailable = (\n session: Pick<ToolContext[\"session\"], \"auth\" | \"parent\">\n): boolean => {\n const owner = session.auth.initiator;\n const selected = eveTurnTool.get();\n return Boolean(\n owner &&\n !session.parent &&\n owner.attributes.chatjsGuest !== \"true\" &&\n eveToolAllowed(\"deepResearch\") &&\n (!selected || selected === \"deepResearch\") &&\n installedToolNames.has(\"deepResearch\") &&\n installedDocumentKinds.has(\"text\") &&\n Object.hasOwn(providers, \"webSearch\")\n );\n};\n",
40
- "type": "registry:file",
41
- "target": "~/tools/chatjs/deep-research/availability.ts"
25
+ "target": "~/chatjs/tools/deep-research/tool.ts"
42
26
  },
43
27
  {
44
28
  "path": "src/tools/deep-research/progress.tsx",
45
29
  "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
30
  "type": "registry:file",
47
- "target": "~/tools/chatjs/deep-research/progress.tsx"
31
+ "target": "~/chatjs/tools/deep-research/progress.tsx"
48
32
  },
49
33
  {
50
34
  "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 { UpdateTitle } from \"./update-title\";\nimport { WebSourceBadge } from \"@/components/source-badge\";\nimport { motion } from \"motion/react\";\n\nexport const ResearchTask = ({\n update,\n minimal,\n isRunning,\n}: Readonly<{\n update: ReadonlyNativeSurface<ResearchUpdate>;\n minimal: boolean;\n isRunning: boolean;\n}>): React.JSX.Element => (\n <div className=\"group\">\n {!minimal && (\n <div className=\"flex items-center gap-2\">\n <UpdateTitle isRunning={isRunning} title={update.title} />\n </div>\n )}\n <motion.div\n animate={{\n height: \"auto\",\n opacity: 1,\n transition: {\n height: { duration: 0.2, ease: \"easeOut\" },\n opacity: { delay: 0.05, duration: 0.15 },\n },\n }}\n exit={{\n height: 0,\n opacity: 0,\n transition: {\n height: { duration: 0.2, ease: \"easeIn\" },\n opacity: { duration: 0.1 },\n },\n }}\n initial={{ height: 0, opacity: 0 }}\n >\n <div className=\"space-y-2 py-2 pr-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-xsize-neutral-500\">Searching the web...</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\">\n {update.message}\n </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 </motion.div>\n </div>\n);\n",
35
+ "content": "import React from \"react\";\nimport type { ReadonlyNativeSurface } from \"@/lib/readonly-native-surface\";\nimport type { ResearchUpdate } from \"@/tools/platform/research-updates-schema\";\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 === \"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
36
  "type": "registry:file",
53
- "target": "~/tools/chatjs/deep-research/task.tsx"
54
- },
55
- {
56
- "path": "src/tools/deep-research/agent.ts",
57
- "content": "import { defineAgent, defineDynamic } from \"eve\";\nimport type { DefinedAgent, DynamicResolveContext } from \"eve\";\n\nimport { resolveAccountedEveModel } from \"@/lib/eve/model-accounting\";\n\nimport { getDeepResearchConfig } from \"./configuration\";\n\ntype Phase = \"research\" | \"compression\" | \"final_report\";\nexport const defineResearchAgent = (\n phase: Phase\n): DefinedAgent<{\n defaultTools: false;\n description: string;\n model: ReturnType<\n typeof defineDynamic<{\n \"step.started\": (\n event: unknown,\n context: DynamicResolveContext\n ) => ReturnType<typeof resolveAccountedEveModel>;\n }>\n >;\n tool: false;\n}> =>\n defineAgent({\n defaultTools: false,\n description: `Deep research ${phase} phase. Called by the research workflow.`,\n model: defineDynamic({\n events: {\n \"step.started\": async (event, context) =>\n await resolveAccountedEveModel(\n getDeepResearchConfig()[`${phase}_model`],\n event,\n context\n ),\n },\n }),\n tool: false,\n });\n",
58
- "type": "registry:file",
59
- "target": "~/tools/chatjs/deep-research/agent.ts"
37
+ "target": "~/chatjs/tools/deep-research/task.tsx"
60
38
  },
61
39
  {
62
40
  "path": "src/tools/deep-research/schemas.ts",
63
- "content": "import { eveDocumentWriteResult } from \"@/lib/eve/document-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",
41
+ "content": "export { researchInput, researchOutput } from \"@/agent/lib/research/schemas\";\n",
64
42
  "type": "registry:file",
65
- "target": "~/tools/chatjs/deep-research/schemas.ts"
43
+ "target": "~/chatjs/tools/deep-research/schemas.ts"
66
44
  },
67
45
  {
68
46
  "path": "src/tools/deep-research/tasks.tsx",
69
- "content": "import { CircleCheck, Dot, FileText, Pencil, Sparkles } from \"lucide-react\";\nimport type React from \"react\";\nimport type { ReactNode } from \"react\";\nimport type { ReadonlyNativeSurface } from \"@/lib/readonly-native-surface\";\nimport { ResearchTask } from \"./task\";\nimport type { ResearchUpdate } from \"@/tools/platform/research-updates-schema\";\nimport { cn } from \"@/lib/utils\";\nimport { motion } from \"motion/react\";\n\nconst icons: Record<ResearchUpdate[\"type\"], React.ElementType> = {\n completed: CircleCheck,\n started: Dot,\n thoughts: Sparkles,\n web: FileText,\n writing: Pencil,\n} as const;\n\nconst StepTypeIcon = ({\n update,\n}: Readonly<{\n update: Readonly<Pick<ResearchUpdate, \"type\">>;\n}>): React.JSX.Element => {\n const Icon = icons[update.type];\n return <Icon className=\"text-muted-foreground h-4 w-4\" />;\n};\n\nconst StepWrapper = ({\n update,\n children,\n isLast,\n}: StepWrapperProps): React.JSX.Element => (\n <div className=\"flex w-full flex-row items-stretch justify-start gap-2\">\n <div className=\"flex min-h-full shrink-0 flex-col items-center justify-start px-2\">\n <div className=\"bg-border/50 h-1 shrink-0\" />\n <div className=\"bg-background z-10 py-0.5\">\n <StepTypeIcon update={update} />\n </div>\n <motion.div\n animate={{ height: \"100%\" }}\n className={cn(\n \"border-border min-h-full w-px flex-1 border-l border-dashed\",\n isLast && \"hidden\"\n )}\n initial={{ height: 0 }}\n transition={{ duration: 0.5 }}\n />\n </div>\n <motion.div\n animate={{ opacity: 1, y: 0 }}\n className=\"flex w-full flex-1 flex-col gap-4 overflow-hidden pt-1 pr-2 pb-2\"\n initial={{ opacity: 0, y: 5 }}\n transition={{ duration: 0.3 }}\n >\n {children}\n </motion.div>\n </div>\n);\n\nconst ResearchTasks = ({\n updates,\n}: ReadonlyNativeSurface<{ updates: ResearchUpdate[] }>): React.JSX.Element => {\n const occurrences = new Map<string, number>();\n return (\n <div className=\"relative\">\n {updates.map((update: ReadonlyNativeSurface<ResearchUpdate>, index) => {\n const identity = `${update.type}:${update.toolCallId}`;\n const occurrence = occurrences.get(identity) ?? 0;\n occurrences.set(identity, occurrence + 1);\n return (\n <StepWrapper\n isLast={index === updates.length - 1}\n key={`${identity}:${occurrence}`}\n update={update}\n >\n <ResearchTask\n isRunning={\n (update.type === \"web\" && update.status === \"running\") ||\n (index === updates.length - 1 && update.type !== \"completed\")\n }\n minimal={false}\n update={update}\n />\n </StepWrapper>\n );\n })}\n </div>\n );\n};\n\ninterface StepWrapperProps {\n readonly children: ReadonlyNativeSurface<ReactNode>;\n readonly isLast: boolean;\n readonly update: ReadonlyNativeSurface<ResearchUpdate>;\n}\nexport { ResearchTasks };\n",
70
- "type": "registry:file",
71
- "target": "~/tools/chatjs/deep-research/tasks.tsx"
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"
78
- },
79
- {
80
- "path": "src/tools/deep-research/prompts.ts",
81
- "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
- "type": "registry:file",
83
- "target": "~/tools/chatjs/deep-research/prompts.ts"
84
- },
85
- {
86
- "path": "src/tools/deep-research/steps.ts",
87
- "content": "import { Client } from \"eve/client\";\nimport type { WorkflowToolContext } from \"eve/tools\";\nimport { eveDocumentWriteResult } from \"@/lib/eve/document-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 Omit<WorkflowToolContext, \"abortSignal\"> & {\n abortSignal: Readonly<AbortSignal>;\n }\n>;\n\ntype MessageView = Readonly<{\n parts: readonly Readonly<{ type: string; toolCallId?: 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 !== \"dynamic-tool\" || part.toolCallId !== 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
- "type": "registry:file",
89
- "target": "~/tools/chatjs/deep-research/steps.ts"
90
- },
91
- {
92
- "path": "src/tools/deep-research/configuration.ts",
93
- "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
- "type": "registry:file",
95
- "target": "~/tools/chatjs/deep-research/configuration.ts"
96
- },
97
- {
98
- "path": "src/tools/deep-research/configuration-schema.ts",
99
- "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",
47
+ "content": "import React from \"react\";\nimport { CircleCheck, Dot, 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 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 = !complete && 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",
100
48
  "type": "registry:file",
101
- "target": "~/tools/chatjs/deep-research/configuration-schema.ts"
49
+ "target": "~/chatjs/tools/deep-research/tasks.tsx"
102
50
  },
103
51
  {
104
52
  "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",
53
+ "content": "// ChatJS source: deep-research. Ownership: chatjs/tools/deep-research/chatjs.json.\nimport { defineWorkflowTool, toolOutput } from \"eve/tools\";\nimport {\n clarifyWithUserInstructions,\n compressResearchSimpleHumanMessage,\n compressResearchSystemPrompt,\n finalReportGenerationPrompt,\n leadResearcherPrompt,\n researchSystemPrompt,\n transformMessagesIntoResearchTopicPrompt,\n} from \"../lib/research/prompts\";\nimport { prepareResearch, researchCompletedAt } from \"../lib/research/steps\";\nimport {\n researchBrief,\n researchInput,\n researchClarification,\n researchDecision,\n researchFindings,\n researchReport,\n researchResult,\n} from \"../lib/research/schemas\";\nimport type { ResearchUpdate } from \"../lib/research/schemas\";\nimport type { AgentSession, WorkflowToolContext } from \"eve/tools\";\nimport { z } from \"zod\";\n\nimport {\n readResearchFiles,\n writeResearchFile,\n} from \"../lib/research/workspace\";\n\ntype ResearchResult = ReturnType<typeof researchResult>;\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 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 installed EVE capabilities and sandbox files. Supply the full task and relevant conversation context in request. Use only for explicit deep research requests, once per turn. Returns a Markdown report path in the shared sandbox. After completion, deliver the file using attach_workspace_file when installed or your channel's native file delivery. If no delivery mechanism exists, explain where the file is and do not invent a download URL. If clarification is needed, ask the returned questions. If research fails, report the error instead of starting duplicate research.\",\n async *execute(\n input: Readonly<z.infer<typeof researchInput>>,\n context: ResearchWorkflowContext\n ): AsyncGenerator<ResearchResult, void> {\n \"use workflow\";\n const { config, date, messages, timestamp } = await prepareResearch(\n input.request\n );\n const updates: ResearchUpdate[] = [];\n const progress = (): ResearchResult =>\n researchResult({ format: \"progress\" }, updates);\n if (config.allow_clarification) {\n const clarification = researchClarification.parse(\n await researchReply(context.agent(\"agent\"), {\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 researchResult({\n answer: clarification.question,\n format: \"clarifying_questions\",\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(\"agent\"), {\n signal: context.abortSignal,\n message: structuredMessage(\n transformMessagesIntoResearchTopicPrompt({ date, messages })\n ),\n outputSchema: outputSchema(researchBrief),\n })\n );\n await writeResearchFile(context, \"brief.md\", brief.research_brief);\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 noteFiles: 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 // oxlint-disable-next-line no-await-in-loop -- Each decision reads the notes completed by preceding research rounds.\n const findings = await readResearchFiles(context, [\n \"brief.md\",\n ...noteFiles,\n ]);\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(\"agent\"), {\n signal: context.abortSignal,\n message: structuredMessage(\n `${leadResearcherPrompt({ date, max_concurrent_research_units: config.max_concurrent_research_units })}\\n\\nResearch brief: ${findings[0]}\\n\\nFindings so far:\\n${findings.slice(1).join(\"\\n\\n\")}\\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 const raw = researchFindings.parse(\n // oxlint-disable-next-line no-await-in-loop -- Complete the topic before moving to the next research stage.\n await researchReply(context.agent(\"agent\"), {\n signal: context.abortSignal,\n message: structuredMessage(\n `${researchSystemPrompt({ date, max_search_queries: config.search_api_max_queries, mcp_prompt: \"Use eve__search to discover installed search/retrieval connections and eve__tool to call them. Use native read_file or bash for relevant sandbox files. Do not call deepResearch recursively. If current external evidence is needed but no search capability is installed, say so explicitly; never fabricate sources.\" })}\\n\\nResearch brief:\\n${findings[0]}\\n\\nTopic:\\n${topic}\\n\\nReturn comprehensive raw findings with source URLs, citations, uncertainties, and conflicting evidence.`\n ),\n outputSchema: outputSchema(researchFindings),\n })\n );\n const topicNumber = noteFiles.length + 1;\n const sourceFile = `topic-${topicNumber}-sources.md`;\n // oxlint-disable-next-line no-await-in-loop -- Preserve cited source findings before compression.\n await writeResearchFile(\n context,\n sourceFile,\n `# ${topic}\\n\\n${raw.findings}`\n );\n // oxlint-disable-next-line no-await-in-loop -- Compression consumes the saved source file.\n const [sources] = await readResearchFiles(context, [sourceFile]);\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(\"agent\"), {\n signal: context.abortSignal,\n message: structuredMessage(\n `${compressResearchSystemPrompt({ date })}\\n\\n${sources}\\n\\n${compressResearchSimpleHumanMessage}`\n ),\n outputSchema: outputSchema(researchFindings),\n })\n );\n const noteFile = `topic-${topicNumber}-notes.md`;\n // oxlint-disable-next-line no-await-in-loop -- Commit notes before advancing the supervisor.\n await writeResearchFile(\n context,\n noteFile,\n `# ${topic}\\n\\n${compressed.findings}`\n );\n noteFiles.push(noteFile);\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 [savedBrief, ...savedNotes] = await readResearchFiles(context, [\n \"brief.md\",\n ...noteFiles,\n ]);\n const report = researchReport.parse(\n await researchReply(context.agent(\"agent\"), {\n signal: context.abortSignal,\n message: structuredMessage(\n `${finalReportGenerationPrompt({ date, findings: savedNotes.join(\"\\n\"), research_brief: savedBrief })}\\n\\nWrite the complete Markdown report with title ${JSON.stringify(brief.title)}. Return title and content; the workflow will publish the report as a Markdown file.`\n ),\n outputSchema: outputSchema(researchReport),\n })\n );\n context.abortSignal.throwIfAborted();\n const reportPath = await writeResearchFile(\n context,\n \"report.md\",\n report.content\n );\n const completedAt = await researchCompletedAt();\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 researchResult(\n { path: reportPath, title: report.title, format: \"report\" },\n updates\n );\n },\n inputSchema: researchInput,\n toModelOutput: (result) => toolOutput.json(result.output),\n});\n",
106
54
  "type": "registry:file",
107
55
  "target": "~/agent/tools/deepResearch.ts"
108
56
  },
109
57
  {
110
- "path": "src/tools/deep-research/agent/subagents/researchPlanner/agent.ts",
111
- "content": "import { defineResearchAgent } from \"@/tools/chatjs/deep-research/agent\";\n\nexport default defineResearchAgent(\"research\");\n",
58
+ "path": "src/tools/deep-research/agent/lib/research/configuration.ts",
59
+ "content": "/** Workflow-specific bounds. Model, reasoning, approvals, connections, and sandbox belong to agent/agent.ts and native EVE files. */\nexport const researchOptions = {\n allow_clarification: true,\n max_concurrent_research_units: 2,\n max_researcher_iterations: 1,\n search_api_max_queries: 2,\n};\n",
112
60
  "type": "registry:file",
113
- "target": "~/agent/subagents/researchPlanner/agent.ts"
61
+ "target": "~/agent/lib/research/configuration.ts"
114
62
  },
115
63
  {
116
- "path": "src/tools/deep-research/agent/subagents/researchPlanner/sandbox.ts",
117
- "content": "import { defineParentSandbox } from \"eve/sandbox\";\n\nexport default defineParentSandbox();\n",
118
- "type": "registry:file",
119
- "target": "~/agent/subagents/researchPlanner/sandbox.ts"
120
- },
121
- {
122
- "path": "src/tools/deep-research/agent/subagents/researchPlanner/hooks/billing.ts",
123
- "content": "export { default } from \"@/agent/hooks/billing\";\n",
124
- "type": "registry:file",
125
- "target": "~/agent/subagents/researchPlanner/hooks/billing.ts"
126
- },
127
- {
128
- "path": "src/tools/deep-research/agent/subagents/researchWriter/agent.ts",
129
- "content": "import { defineResearchAgent } from \"@/tools/chatjs/deep-research/agent\";\n\nexport default defineResearchAgent(\"final_report\");\n",
130
- "type": "registry:file",
131
- "target": "~/agent/subagents/researchWriter/agent.ts"
132
- },
133
- {
134
- "path": "src/tools/deep-research/agent/subagents/researchWriter/sandbox.ts",
135
- "content": "import { defineParentSandbox } from \"eve/sandbox\";\n\nexport default defineParentSandbox();\n",
136
- "type": "registry:file",
137
- "target": "~/agent/subagents/researchWriter/sandbox.ts"
138
- },
139
- {
140
- "path": "src/tools/deep-research/agent/subagents/researchWriter/hooks/billing.ts",
141
- "content": "export { default } from \"@/agent/hooks/billing\";\n",
142
- "type": "registry:file",
143
- "target": "~/agent/subagents/researchWriter/hooks/billing.ts"
144
- },
145
- {
146
- "path": "src/tools/deep-research/agent/subagents/researchCompressor/agent.ts",
147
- "content": "import { defineResearchAgent } from \"@/tools/chatjs/deep-research/agent\";\n\nexport default defineResearchAgent(\"compression\");\n",
148
- "type": "registry:file",
149
- "target": "~/agent/subagents/researchCompressor/agent.ts"
150
- },
151
- {
152
- "path": "src/tools/deep-research/agent/subagents/researchCompressor/sandbox.ts",
153
- "content": "import { defineParentSandbox } from \"eve/sandbox\";\n\nexport default defineParentSandbox();\n",
154
- "type": "registry:file",
155
- "target": "~/agent/subagents/researchCompressor/sandbox.ts"
156
- },
157
- {
158
- "path": "src/tools/deep-research/agent/subagents/researchCompressor/hooks/billing.ts",
159
- "content": "export { default } from \"@/agent/hooks/billing\";\n",
160
- "type": "registry:file",
161
- "target": "~/agent/subagents/researchCompressor/hooks/billing.ts"
162
- },
163
- {
164
- "path": "src/tools/deep-research/agent/subagents/researcher/agent.ts",
165
- "content": "import { defineResearchAgent } from \"@/tools/chatjs/deep-research/agent\";\n\nexport default defineResearchAgent(\"research\");\n",
64
+ "path": "src/tools/deep-research/agent/lib/research/prompts.ts",
65
+ "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",
166
66
  "type": "registry:file",
167
- "target": "~/agent/subagents/researcher/agent.ts"
67
+ "target": "~/agent/lib/research/prompts.ts"
168
68
  },
169
69
  {
170
- "path": "src/tools/deep-research/agent/subagents/researcher/sandbox.ts",
171
- "content": "import { defineParentSandbox } from \"eve/sandbox\";\n\nexport default defineParentSandbox();\n",
70
+ "path": "src/tools/deep-research/agent/lib/research/schemas.ts",
71
+ "content": "import { z } from \"zod\";\n\nconst MINIMUM_RESEARCH_TEXT_LENGTH = 1;\n\nconst researchOutput = z.union([\n z.object({ format: z.literal(\"progress\") }),\n z.object({ answer: z.string(), format: z.literal(\"clarifying_questions\") }),\n z.object({\n format: z.literal(\"report\"),\n path: z.string(),\n title: z.string(),\n }),\n]);\n\nconst researchInput = z.object({\n request: z\n .string()\n .min(1)\n .describe(\n \"The full research task, relevant conversation context, scope, and any input sandbox file paths.\"\n ),\n});\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\nexport interface ResearchUpdate {\n type: \"started\" | \"writing\" | \"thoughts\" | \"completed\";\n title: string;\n toolCallId: string;\n timestamp?: number;\n message?: string;\n status?: \"running\" | \"completed\";\n}\n\n// Optional presentation metadata; plain JSON that any EVE channel can consume.\nexport const researchResult = (\n output: z.input<typeof researchOutput>,\n updates: readonly ResearchUpdate[] = []\n) => ({\n kind: \"chatjs.tool-result\" as const,\n version: 1 as const,\n status: \"success\" as const,\n output: researchOutput.parse(output),\n updates: updates.map((update) => ({ ...update })),\n usage: { costUsd: 0 },\n});\n",
172
72
  "type": "registry:file",
173
- "target": "~/agent/subagents/researcher/sandbox.ts"
73
+ "target": "~/agent/lib/research/schemas.ts"
174
74
  },
175
75
  {
176
- "path": "src/tools/deep-research/agent/subagents/researcher/tools/web-search.ts",
177
- "content": "import { defineState } from \"eve/context\";\nimport { defineDynamic } from \"eve/tools\";\n\nimport { providers } from \"@/composition/generated/providers\";\n\nconst MAX_RESEARCH_SEARCH_ROUNDS = 19;\nconst INITIAL_SEARCH_ROUND = 0;\nconst SEARCH_ROUND_INCREMENT = 1;\n\ntype ResearchSearchContext = Readonly<{\n session: Readonly<{\n auth: Readonly<{\n initiator: Readonly<{\n attributes: Readonly<Record<string, string | readonly string[]>>;\n }> | null;\n }>;\n }>;\n}>;\n\nconst researchSteps = defineState<number>(\n \"chatjs.research-steps\",\n () => INITIAL_SEARCH_ROUND\n);\n\nconst requireResearchSearch =\n (): (typeof providers)[keyof typeof providers] => {\n const providerEntry = Object.entries(providers).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({\n events: {\n \"step.started\": (_event, context: ResearchSearchContext) => {\n const owner = context.session.auth.initiator;\n if (owner && owner.attributes.chatjsGuest === \"true\") {\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 = researchSteps.get();\n researchSteps.update((count) => count + SEARCH_ROUND_INCREMENT);\n\n if (searchRounds >= MAX_RESEARCH_SEARCH_ROUNDS) {\n return null;\n }\n return search;\n },\n },\n});\n",
76
+ "path": "src/tools/deep-research/agent/lib/research/steps.ts",
77
+ "content": "import { researchOptions } from \"./configuration\";\n\n// oxlint-disable-next-line eslint/func-style, eslint/require-await -- EVE requires async step declarations. Record the clock and authored options once for workflow replay.\nexport async function prepareResearch(request: string) {\n \"use step\";\n return {\n config: researchOptions,\n date: new Date().toLocaleDateString(\"en-US\", {\n day: \"numeric\",\n month: \"short\",\n weekday: \"short\",\n year: \"numeric\",\n }),\n messages: request,\n timestamp: Date.now(),\n };\n}\n\n// oxlint-disable-next-line eslint/func-style, eslint/require-await -- EVE requires async step declarations. Completion time is a durable workflow step.\nexport async function researchCompletedAt() {\n \"use step\";\n return Date.now();\n}\n",
178
78
  "type": "registry:file",
179
- "target": "~/agent/subagents/researcher/tools/webSearch.ts"
79
+ "target": "~/agent/lib/research/steps.ts"
180
80
  },
181
81
  {
182
- "path": "src/tools/deep-research/agent/subagents/researcher/hooks/billing.ts",
183
- "content": "export { default } from \"@/agent/hooks/billing\";\n",
82
+ "path": "src/tools/deep-research/agent/lib/research/workspace.ts",
83
+ "content": "import type { WorkflowStepToolContext } from \"eve/tools\";\nimport type { SandboxSession } from \"eve/sandbox\";\n\ntype Context = Readonly<\n Pick<WorkflowStepToolContext, \"callId\" | \"abortSignal\"> & {\n getSandbox: () => PromiseLike<\n Pick<SandboxSession, \"resolvePath\" | \"readTextFile\" | \"writeTextFile\">\n >;\n }\n>;\n\n// Per-call paths keep follow-up research from overwriting an earlier report.\nconst researchPath = (callId: string, name: string): string => {\n if (!/^[a-z0-9-]+\\.md$/u.test(name)) {\n throw new Error(\"Invalid research workspace filename.\");\n }\n return `research/run-${encodeURIComponent(callId)}/${name}`;\n};\n\n// oxlint-disable-next-line eslint/func-style -- EVE durable steps require function declarations. Whole-file writes are safe to retry.\nexport async function writeResearchFile(\n context: Context,\n name: string,\n content: string\n): Promise<string> {\n \"use step\";\n context.abortSignal.throwIfAborted();\n const sandbox = await context.getSandbox();\n const path = sandbox.resolvePath(researchPath(context.callId, name));\n await sandbox.writeTextFile({ path, content, signal: context.abortSignal });\n return path;\n}\n\n// oxlint-disable-next-line eslint/func-style -- Read the current workspace in a durable step, not during workflow replay.\nexport async function readResearchFiles(\n context: Context,\n names: readonly string[]\n): Promise<string[]> {\n \"use step\";\n context.abortSignal.throwIfAborted();\n const sandbox = await context.getSandbox();\n return await Promise.all(\n names.map(async (name) => {\n const path = sandbox.resolvePath(researchPath(context.callId, name));\n const content = await sandbox.readTextFile({\n path,\n signal: context.abortSignal,\n });\n if (content === null) {\n throw new Error(\n `Research workspace file is no longer available: ${path}`\n );\n }\n return content;\n })\n );\n}\n",
184
84
  "type": "registry:file",
185
- "target": "~/agent/subagents/researcher/hooks/billing.ts"
85
+ "target": "~/agent/lib/research/workspace.ts"
186
86
  },
187
87
  {
188
88
  "path": "dist/source/deep-research.json",
189
- "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",
89
+ "content": "{\n \"agentCategory\": \"extension\",\n \"requiresChatJS\": false,\n \"native\": {\n \"layout\": \"agent\",\n \"files\": [\n \"tools/deepResearch.ts\",\n \"lib/research/configuration.ts\",\n \"lib/research/prompts.ts\",\n \"lib/research/schemas.ts\",\n \"lib/research/steps.ts\",\n \"lib/research/workspace.ts\"\n ],\n \"dependencies\": [\"eve\", \"zod\"]\n },\n \"envRequirements\": [],\n \"id\": \"deep-research\",\n \"kind\": \"tool\",\n \"requiresTools\": [],\n \"tools\": [\n {\n \"accounting\": \"none\",\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 \"channelSupport\": { \"web\": \"supported\", \"slack\": \"unverified\" }\n}\n",
190
90
  "type": "registry:file",
191
- "target": "~/tools/chatjs/deep-research/chatjs.json"
91
+ "target": "~/chatjs/tools/deep-research/chatjs.json"
192
92
  }
193
93
  ],
194
94
  "meta": {
195
95
  "chatjs": {
196
- "config": {
197
- "key": "deepResearch"
96
+ "agentCategory": "extension",
97
+ "requiresChatJS": false,
98
+ "native": {
99
+ "layout": "agent",
100
+ "files": [
101
+ "tools/deepResearch.ts",
102
+ "lib/research/configuration.ts",
103
+ "lib/research/prompts.ts",
104
+ "lib/research/schemas.ts",
105
+ "lib/research/steps.ts",
106
+ "lib/research/workspace.ts"
107
+ ],
108
+ "dependencies": [
109
+ "eve",
110
+ "zod"
111
+ ]
198
112
  },
199
- "availabilityExport": "researchAvailable",
200
113
  "envRequirements": [],
201
114
  "id": "deep-research",
202
115
  "kind": "tool",
203
- "requiresTools": [
204
- "createTextDocument",
205
- "readDocument",
206
- "webSearch"
207
- ],
116
+ "requiresTools": [],
208
117
  "tools": [
209
118
  {
119
+ "accounting": "none",
210
120
  "composer": {
211
121
  "icon": "Telescope",
212
122
  "name": "Deep Research",
@@ -217,7 +127,11 @@
217
127
  "workflow": true
218
128
  }
219
129
  ],
220
- "contractVersion": 1
130
+ "contractVersion": 1,
131
+ "channelSupport": {
132
+ "web": "supported",
133
+ "slack": "unverified"
134
+ }
221
135
  }
222
136
  },
223
137
  "type": "registry:item"
@@ -0,0 +1,35 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
+ "name": "default-sandbox",
4
+ "title": "Automatic",
5
+ "description": "EVE selects Vercel on Vercel, Docker when available, or a simulated shell in development.",
6
+ "dependencies": [
7
+ "eve@npm:@chat-js/eve@1.1.1-chatjs.0"
8
+ ],
9
+ "files": [
10
+ {
11
+ "path": "src/sandboxes/default/sandbox.ts",
12
+ "content": "import { DefaultSandbox, defineSandbox } from \"eve/sandbox\";\n\nexport const environment = DefaultSandbox.environment();\nexport default defineSandbox(async () => await environment.open());\n",
13
+ "type": "registry:file",
14
+ "target": "~/agent/sandbox.ts"
15
+ }
16
+ ],
17
+ "meta": {
18
+ "chatjs": {
19
+ "contractVersion": 1,
20
+ "kind": "sandbox",
21
+ "id": "default",
22
+ "capabilities": {
23
+ "persistent": true,
24
+ "runtimes": [
25
+ "python",
26
+ "javascript"
27
+ ],
28
+ "cleanup": "eve-session",
29
+ "cancellation": "eve"
30
+ },
31
+ "envRequirements": []
32
+ }
33
+ },
34
+ "type": "registry:item"
35
+ }