cerebras-cli 1.0.1 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (314) hide show
  1. package/README.md +3 -5
  2. package/cerebras-cli-1.0.0.tgz +0 -0
  3. package/package.json +7 -88
  4. package/AGENTS.md +0 -27
  5. package/Dockerfile +0 -10
  6. package/bunfig.toml +0 -4
  7. package/parsers-config.ts +0 -239
  8. package/script/build.ts +0 -151
  9. package/script/postinstall.mjs +0 -122
  10. package/script/publish.ts +0 -256
  11. package/script/schema.ts +0 -47
  12. package/src/acp/README.md +0 -164
  13. package/src/acp/agent.ts +0 -812
  14. package/src/acp/session.ts +0 -70
  15. package/src/acp/types.ts +0 -22
  16. package/src/agent/agent.ts +0 -310
  17. package/src/agent/generate.txt +0 -75
  18. package/src/auth/index.ts +0 -70
  19. package/src/bun/index.ts +0 -152
  20. package/src/bus/global.ts +0 -10
  21. package/src/bus/index.ts +0 -142
  22. package/src/cli/bootstrap.ts +0 -17
  23. package/src/cli/cmd/acp.ts +0 -88
  24. package/src/cli/cmd/agent.ts +0 -165
  25. package/src/cli/cmd/auth.ts +0 -369
  26. package/src/cli/cmd/cmd.ts +0 -7
  27. package/src/cli/cmd/debug/config.ts +0 -15
  28. package/src/cli/cmd/debug/file.ts +0 -91
  29. package/src/cli/cmd/debug/index.ts +0 -41
  30. package/src/cli/cmd/debug/lsp.ts +0 -47
  31. package/src/cli/cmd/debug/ripgrep.ts +0 -83
  32. package/src/cli/cmd/debug/scrap.ts +0 -15
  33. package/src/cli/cmd/debug/snapshot.ts +0 -48
  34. package/src/cli/cmd/export.ts +0 -88
  35. package/src/cli/cmd/generate.ts +0 -38
  36. package/src/cli/cmd/github.ts +0 -1200
  37. package/src/cli/cmd/import.ts +0 -98
  38. package/src/cli/cmd/mcp.ts +0 -400
  39. package/src/cli/cmd/models.ts +0 -77
  40. package/src/cli/cmd/pr.ts +0 -112
  41. package/src/cli/cmd/run.ts +0 -342
  42. package/src/cli/cmd/serve.ts +0 -31
  43. package/src/cli/cmd/session.ts +0 -106
  44. package/src/cli/cmd/stats.ts +0 -298
  45. package/src/cli/cmd/tui/app.tsx +0 -732
  46. package/src/cli/cmd/tui/attach.ts +0 -25
  47. package/src/cli/cmd/tui/component/border.tsx +0 -21
  48. package/src/cli/cmd/tui/component/dialog-agent.tsx +0 -31
  49. package/src/cli/cmd/tui/component/dialog-command.tsx +0 -124
  50. package/src/cli/cmd/tui/component/dialog-feedback.tsx +0 -160
  51. package/src/cli/cmd/tui/component/dialog-mcp.tsx +0 -86
  52. package/src/cli/cmd/tui/component/dialog-model.tsx +0 -223
  53. package/src/cli/cmd/tui/component/dialog-notification.tsx +0 -78
  54. package/src/cli/cmd/tui/component/dialog-provider.tsx +0 -222
  55. package/src/cli/cmd/tui/component/dialog-session-list.tsx +0 -97
  56. package/src/cli/cmd/tui/component/dialog-session-rename.tsx +0 -31
  57. package/src/cli/cmd/tui/component/dialog-status.tsx +0 -114
  58. package/src/cli/cmd/tui/component/dialog-tag.tsx +0 -44
  59. package/src/cli/cmd/tui/component/dialog-theme-list.tsx +0 -50
  60. package/src/cli/cmd/tui/component/logo.tsx +0 -37
  61. package/src/cli/cmd/tui/component/notification-banner.tsx +0 -58
  62. package/src/cli/cmd/tui/component/prompt/autocomplete.tsx +0 -530
  63. package/src/cli/cmd/tui/component/prompt/history.tsx +0 -107
  64. package/src/cli/cmd/tui/component/prompt/index.tsx +0 -931
  65. package/src/cli/cmd/tui/context/args.tsx +0 -14
  66. package/src/cli/cmd/tui/context/directory.ts +0 -12
  67. package/src/cli/cmd/tui/context/exit.tsx +0 -23
  68. package/src/cli/cmd/tui/context/helper.tsx +0 -25
  69. package/src/cli/cmd/tui/context/keybind.tsx +0 -111
  70. package/src/cli/cmd/tui/context/kv.tsx +0 -49
  71. package/src/cli/cmd/tui/context/local.tsx +0 -339
  72. package/src/cli/cmd/tui/context/prompt.tsx +0 -18
  73. package/src/cli/cmd/tui/context/route.tsx +0 -45
  74. package/src/cli/cmd/tui/context/sdk.tsx +0 -75
  75. package/src/cli/cmd/tui/context/sync.tsx +0 -374
  76. package/src/cli/cmd/tui/context/theme/aura.json +0 -69
  77. package/src/cli/cmd/tui/context/theme/ayu.json +0 -80
  78. package/src/cli/cmd/tui/context/theme/catppuccin-macchiato.json +0 -233
  79. package/src/cli/cmd/tui/context/theme/catppuccin.json +0 -112
  80. package/src/cli/cmd/tui/context/theme/cobalt2.json +0 -228
  81. package/src/cli/cmd/tui/context/theme/dracula.json +0 -219
  82. package/src/cli/cmd/tui/context/theme/everforest.json +0 -241
  83. package/src/cli/cmd/tui/context/theme/flexoki.json +0 -237
  84. package/src/cli/cmd/tui/context/theme/github.json +0 -233
  85. package/src/cli/cmd/tui/context/theme/gruvbox.json +0 -95
  86. package/src/cli/cmd/tui/context/theme/kanagawa.json +0 -77
  87. package/src/cli/cmd/tui/context/theme/material.json +0 -235
  88. package/src/cli/cmd/tui/context/theme/matrix.json +0 -77
  89. package/src/cli/cmd/tui/context/theme/mercury.json +0 -252
  90. package/src/cli/cmd/tui/context/theme/monokai.json +0 -221
  91. package/src/cli/cmd/tui/context/theme/nightowl.json +0 -221
  92. package/src/cli/cmd/tui/context/theme/nord.json +0 -223
  93. package/src/cli/cmd/tui/context/theme/one-dark.json +0 -84
  94. package/src/cli/cmd/tui/context/theme/orng.json +0 -245
  95. package/src/cli/cmd/tui/context/theme/palenight.json +0 -222
  96. package/src/cli/cmd/tui/context/theme/rosepine.json +0 -234
  97. package/src/cli/cmd/tui/context/theme/solarized.json +0 -223
  98. package/src/cli/cmd/tui/context/theme/synthwave84.json +0 -226
  99. package/src/cli/cmd/tui/context/theme/tokyonight.json +0 -243
  100. package/src/cli/cmd/tui/context/theme/vercel.json +0 -245
  101. package/src/cli/cmd/tui/context/theme/vesper.json +0 -218
  102. package/src/cli/cmd/tui/context/theme/zenburn.json +0 -223
  103. package/src/cli/cmd/tui/context/theme.tsx +0 -1077
  104. package/src/cli/cmd/tui/event.ts +0 -39
  105. package/src/cli/cmd/tui/routes/home.tsx +0 -104
  106. package/src/cli/cmd/tui/routes/session/dialog-message.tsx +0 -93
  107. package/src/cli/cmd/tui/routes/session/dialog-timeline.tsx +0 -37
  108. package/src/cli/cmd/tui/routes/session/footer.tsx +0 -76
  109. package/src/cli/cmd/tui/routes/session/header.tsx +0 -183
  110. package/src/cli/cmd/tui/routes/session/index.tsx +0 -1703
  111. package/src/cli/cmd/tui/routes/session/sidebar.tsx +0 -586
  112. package/src/cli/cmd/tui/spawn.ts +0 -60
  113. package/src/cli/cmd/tui/thread.ts +0 -120
  114. package/src/cli/cmd/tui/ui/dialog-alert.tsx +0 -55
  115. package/src/cli/cmd/tui/ui/dialog-confirm.tsx +0 -81
  116. package/src/cli/cmd/tui/ui/dialog-help.tsx +0 -36
  117. package/src/cli/cmd/tui/ui/dialog-prompt.tsx +0 -75
  118. package/src/cli/cmd/tui/ui/dialog-select.tsx +0 -317
  119. package/src/cli/cmd/tui/ui/dialog.tsx +0 -170
  120. package/src/cli/cmd/tui/ui/spinner.ts +0 -368
  121. package/src/cli/cmd/tui/ui/toast.tsx +0 -100
  122. package/src/cli/cmd/tui/util/clipboard.ts +0 -127
  123. package/src/cli/cmd/tui/util/editor.ts +0 -32
  124. package/src/cli/cmd/tui/util/terminal.ts +0 -114
  125. package/src/cli/cmd/tui/worker.ts +0 -63
  126. package/src/cli/cmd/uninstall.ts +0 -344
  127. package/src/cli/cmd/upgrade.ts +0 -67
  128. package/src/cli/cmd/web.ts +0 -84
  129. package/src/cli/error.ts +0 -55
  130. package/src/cli/ui.ts +0 -84
  131. package/src/cli/upgrade.ts +0 -25
  132. package/src/command/index.ts +0 -79
  133. package/src/command/template/initialize.txt +0 -10
  134. package/src/command/template/review.txt +0 -73
  135. package/src/config/config.ts +0 -886
  136. package/src/config/markdown.ts +0 -41
  137. package/src/env/index.ts +0 -26
  138. package/src/file/fzf.ts +0 -124
  139. package/src/file/ignore.ts +0 -83
  140. package/src/file/index.ts +0 -326
  141. package/src/file/ripgrep.ts +0 -391
  142. package/src/file/time.ts +0 -38
  143. package/src/file/watcher.ts +0 -89
  144. package/src/flag/flag.ts +0 -28
  145. package/src/format/formatter.ts +0 -277
  146. package/src/format/index.ts +0 -137
  147. package/src/global/index.ts +0 -52
  148. package/src/id/id.ts +0 -73
  149. package/src/ide/index.ts +0 -75
  150. package/src/index.ts +0 -158
  151. package/src/installation/index.ts +0 -194
  152. package/src/lsp/client.ts +0 -215
  153. package/src/lsp/index.ts +0 -370
  154. package/src/lsp/language.ts +0 -111
  155. package/src/lsp/server.ts +0 -1327
  156. package/src/mcp/auth.ts +0 -82
  157. package/src/mcp/index.ts +0 -576
  158. package/src/mcp/oauth-callback.ts +0 -203
  159. package/src/mcp/oauth-provider.ts +0 -132
  160. package/src/notification/index.ts +0 -101
  161. package/src/patch/index.ts +0 -622
  162. package/src/permission/index.ts +0 -198
  163. package/src/plugin/index.ts +0 -95
  164. package/src/project/bootstrap.ts +0 -31
  165. package/src/project/instance.ts +0 -68
  166. package/src/project/project.ts +0 -133
  167. package/src/project/state.ts +0 -65
  168. package/src/project/vcs.ts +0 -77
  169. package/src/provider/auth.ts +0 -143
  170. package/src/provider/models-macro.ts +0 -11
  171. package/src/provider/models.ts +0 -93
  172. package/src/provider/provider.ts +0 -996
  173. package/src/provider/sdk/openai-compatible/src/README.md +0 -5
  174. package/src/provider/sdk/openai-compatible/src/index.ts +0 -2
  175. package/src/provider/sdk/openai-compatible/src/openai-compatible-provider.ts +0 -100
  176. package/src/provider/sdk/openai-compatible/src/responses/convert-to-openai-responses-input.ts +0 -303
  177. package/src/provider/sdk/openai-compatible/src/responses/map-openai-responses-finish-reason.ts +0 -27
  178. package/src/provider/sdk/openai-compatible/src/responses/openai-config.ts +0 -18
  179. package/src/provider/sdk/openai-compatible/src/responses/openai-error.ts +0 -22
  180. package/src/provider/sdk/openai-compatible/src/responses/openai-responses-api-types.ts +0 -207
  181. package/src/provider/sdk/openai-compatible/src/responses/openai-responses-language-model.ts +0 -1713
  182. package/src/provider/sdk/openai-compatible/src/responses/openai-responses-prepare-tools.ts +0 -177
  183. package/src/provider/sdk/openai-compatible/src/responses/openai-responses-settings.ts +0 -1
  184. package/src/provider/sdk/openai-compatible/src/responses/tool/code-interpreter.ts +0 -88
  185. package/src/provider/sdk/openai-compatible/src/responses/tool/file-search.ts +0 -128
  186. package/src/provider/sdk/openai-compatible/src/responses/tool/image-generation.ts +0 -115
  187. package/src/provider/sdk/openai-compatible/src/responses/tool/local-shell.ts +0 -65
  188. package/src/provider/sdk/openai-compatible/src/responses/tool/web-search-preview.ts +0 -104
  189. package/src/provider/sdk/openai-compatible/src/responses/tool/web-search.ts +0 -103
  190. package/src/provider/transform.ts +0 -406
  191. package/src/pty/index.ts +0 -226
  192. package/src/ratelimit/index.ts +0 -185
  193. package/src/server/error.ts +0 -36
  194. package/src/server/project.ts +0 -50
  195. package/src/server/server.ts +0 -2463
  196. package/src/server/tui.ts +0 -71
  197. package/src/session/compaction.ts +0 -257
  198. package/src/session/index.ts +0 -470
  199. package/src/session/message-v2.ts +0 -641
  200. package/src/session/message.ts +0 -189
  201. package/src/session/processor.ts +0 -443
  202. package/src/session/prompt/anthropic-20250930.txt +0 -166
  203. package/src/session/prompt/anthropic.txt +0 -105
  204. package/src/session/prompt/anthropic_spoof.txt +0 -1
  205. package/src/session/prompt/beast.txt +0 -147
  206. package/src/session/prompt/build-switch.txt +0 -5
  207. package/src/session/prompt/codex.txt +0 -318
  208. package/src/session/prompt/compaction.txt +0 -12
  209. package/src/session/prompt/copilot-gpt-5.txt +0 -143
  210. package/src/session/prompt/gemini.txt +0 -155
  211. package/src/session/prompt/max-steps.txt +0 -16
  212. package/src/session/prompt/plan-reminder-anthropic.txt +0 -67
  213. package/src/session/prompt/plan.txt +0 -26
  214. package/src/session/prompt/polaris.txt +0 -107
  215. package/src/session/prompt/qwen.txt +0 -109
  216. package/src/session/prompt/summarize.txt +0 -4
  217. package/src/session/prompt/title.txt +0 -36
  218. package/src/session/prompt.ts +0 -1541
  219. package/src/session/retry.ts +0 -82
  220. package/src/session/revert.ts +0 -108
  221. package/src/session/status.ts +0 -75
  222. package/src/session/summary.ts +0 -203
  223. package/src/session/system.ts +0 -148
  224. package/src/session/todo.ts +0 -36
  225. package/src/share/share-next.ts +0 -195
  226. package/src/share/share.ts +0 -87
  227. package/src/snapshot/index.ts +0 -197
  228. package/src/storage/storage.ts +0 -226
  229. package/src/telemetry/index.ts +0 -232
  230. package/src/tool/bash.ts +0 -365
  231. package/src/tool/bash.txt +0 -128
  232. package/src/tool/batch.ts +0 -173
  233. package/src/tool/batch.txt +0 -28
  234. package/src/tool/codesearch.ts +0 -138
  235. package/src/tool/codesearch.txt +0 -12
  236. package/src/tool/edit.ts +0 -674
  237. package/src/tool/edit.txt +0 -10
  238. package/src/tool/glob.ts +0 -65
  239. package/src/tool/glob.txt +0 -6
  240. package/src/tool/grep.ts +0 -120
  241. package/src/tool/grep.txt +0 -8
  242. package/src/tool/invalid.ts +0 -17
  243. package/src/tool/ls.ts +0 -110
  244. package/src/tool/ls.txt +0 -1
  245. package/src/tool/lsp-diagnostics.ts +0 -26
  246. package/src/tool/lsp-diagnostics.txt +0 -1
  247. package/src/tool/lsp-hover.ts +0 -31
  248. package/src/tool/lsp-hover.txt +0 -1
  249. package/src/tool/multiedit.ts +0 -46
  250. package/src/tool/multiedit.txt +0 -41
  251. package/src/tool/patch.ts +0 -233
  252. package/src/tool/patch.txt +0 -1
  253. package/src/tool/read.ts +0 -217
  254. package/src/tool/read.txt +0 -12
  255. package/src/tool/registry.ts +0 -148
  256. package/src/tool/task.ts +0 -135
  257. package/src/tool/task.txt +0 -60
  258. package/src/tool/todo.ts +0 -39
  259. package/src/tool/todoread.txt +0 -14
  260. package/src/tool/todowrite.txt +0 -167
  261. package/src/tool/tool.ts +0 -66
  262. package/src/tool/webfetch.ts +0 -187
  263. package/src/tool/webfetch.txt +0 -14
  264. package/src/tool/websearch.ts +0 -150
  265. package/src/tool/websearch.txt +0 -11
  266. package/src/tool/write.ts +0 -99
  267. package/src/tool/write.txt +0 -8
  268. package/src/types/shims.d.ts +0 -3
  269. package/src/util/color.ts +0 -19
  270. package/src/util/context.ts +0 -25
  271. package/src/util/defer.ts +0 -12
  272. package/src/util/eventloop.ts +0 -20
  273. package/src/util/filesystem.ts +0 -69
  274. package/src/util/fn.ts +0 -11
  275. package/src/util/iife.ts +0 -3
  276. package/src/util/keybind.ts +0 -79
  277. package/src/util/lazy.ts +0 -11
  278. package/src/util/locale.ts +0 -81
  279. package/src/util/lock.ts +0 -98
  280. package/src/util/log.ts +0 -177
  281. package/src/util/queue.ts +0 -32
  282. package/src/util/rpc.ts +0 -42
  283. package/src/util/scrap.ts +0 -10
  284. package/src/util/signal.ts +0 -12
  285. package/src/util/timeout.ts +0 -14
  286. package/src/util/token.ts +0 -7
  287. package/src/util/wildcard.ts +0 -54
  288. package/sst-env.d.ts +0 -9
  289. package/test/bun.test.ts +0 -53
  290. package/test/config/agent-color.test.ts +0 -66
  291. package/test/config/config.test.ts +0 -503
  292. package/test/config/markdown.test.ts +0 -89
  293. package/test/file/ignore.test.ts +0 -10
  294. package/test/fixture/fixture.ts +0 -28
  295. package/test/fixture/lsp/fake-lsp-server.js +0 -77
  296. package/test/ide/ide.test.ts +0 -82
  297. package/test/keybind.test.ts +0 -317
  298. package/test/lsp/client.test.ts +0 -95
  299. package/test/patch/patch.test.ts +0 -348
  300. package/test/preload.ts +0 -38
  301. package/test/project/project.test.ts +0 -42
  302. package/test/provider/provider.test.ts +0 -1809
  303. package/test/provider/transform.test.ts +0 -305
  304. package/test/session/retry.test.ts +0 -61
  305. package/test/session/session.test.ts +0 -71
  306. package/test/snapshot/snapshot.test.ts +0 -939
  307. package/test/tool/__snapshots__/tool.test.ts.snap +0 -9
  308. package/test/tool/bash.test.ts +0 -55
  309. package/test/tool/patch.test.ts +0 -259
  310. package/test/util/iife.test.ts +0 -36
  311. package/test/util/lazy.test.ts +0 -50
  312. package/test/util/timeout.test.ts +0 -21
  313. package/test/util/wildcard.test.ts +0 -55
  314. package/tsconfig.json +0 -17
package/src/tool/task.ts DELETED
@@ -1,135 +0,0 @@
1
- import { Tool } from "./tool"
2
- import DESCRIPTION from "./task.txt"
3
- import z from "zod"
4
- import { Session } from "../session"
5
- import { Bus } from "../bus"
6
- import { MessageV2 } from "../session/message-v2"
7
- import { Identifier } from "../id/id"
8
- import { Agent } from "../agent/agent"
9
- import { SessionPrompt } from "../session/prompt"
10
- import { iife } from "@/util/iife"
11
- import { defer } from "@/util/defer"
12
- import { Config } from "../config/config"
13
-
14
- export const TaskTool = Tool.define("task", async () => {
15
- const agents = await Agent.list().then((x) => x.filter((a) => a.mode !== "primary"))
16
- const description = DESCRIPTION.replace(
17
- "{agents}",
18
- agents
19
- .map((a) => `- ${a.name}: ${a.description ?? "This subagent should only be called manually by the user."}`)
20
- .join("\n"),
21
- )
22
- return {
23
- description,
24
- parameters: z.object({
25
- description: z.string().describe("A short (3-5 words) description of the task"),
26
- prompt: z.string().describe("The task for the agent to perform"),
27
- subagent_type: z.string().describe("The type of specialized agent to use for this task"),
28
- session_id: z.string().describe("Existing Task session to continue").optional(),
29
- }),
30
- async execute(params, ctx) {
31
- const agent = await Agent.get(params.subagent_type)
32
- if (!agent) throw new Error(`Unknown agent type: ${params.subagent_type} is not a valid agent type`)
33
- const session = await iife(async () => {
34
- if (params.session_id) {
35
- const found = await Session.get(params.session_id).catch(() => {})
36
- if (found) return found
37
- }
38
-
39
- return await Session.create({
40
- parentID: ctx.sessionID,
41
- title: params.description + ` (@${agent.name} subagent)`,
42
- })
43
- })
44
- const msg = await MessageV2.get({ sessionID: ctx.sessionID, messageID: ctx.messageID })
45
- if (msg.info.role !== "assistant") throw new Error("Not an assistant message")
46
-
47
- ctx.metadata({
48
- title: params.description,
49
- metadata: {
50
- sessionId: session.id,
51
- },
52
- })
53
-
54
- const messageID = Identifier.ascending("message")
55
- const parts: Record<string, { id: string; tool: string; state: { status: string; title?: string } }> = {}
56
- const unsub = Bus.subscribe(MessageV2.Event.PartUpdated, async (evt) => {
57
- if (evt.properties.part.sessionID !== session.id) return
58
- if (evt.properties.part.messageID === messageID) return
59
- if (evt.properties.part.type !== "tool") return
60
- const part = evt.properties.part
61
- parts[part.id] = {
62
- id: part.id,
63
- tool: part.tool,
64
- state: {
65
- status: part.state.status,
66
- title: part.state.status === "completed" ? part.state.title : undefined,
67
- },
68
- }
69
- ctx.metadata({
70
- title: params.description,
71
- metadata: {
72
- summary: Object.values(parts).sort((a, b) => a.id.localeCompare(b.id)),
73
- sessionId: session.id,
74
- },
75
- })
76
- })
77
-
78
- const model = agent.model ?? {
79
- modelID: msg.info.modelID,
80
- providerID: msg.info.providerID,
81
- }
82
-
83
- function cancel() {
84
- SessionPrompt.cancel(session.id)
85
- }
86
- ctx.abort.addEventListener("abort", cancel)
87
- using _ = defer(() => ctx.abort.removeEventListener("abort", cancel))
88
- const promptParts = await SessionPrompt.resolvePromptParts(params.prompt)
89
-
90
- const config = await Config.get()
91
- const result = await SessionPrompt.prompt({
92
- messageID,
93
- sessionID: session.id,
94
- model: {
95
- modelID: model.modelID,
96
- providerID: model.providerID,
97
- },
98
- agent: agent.name,
99
- tools: {
100
- todowrite: false,
101
- todoread: false,
102
- task: false,
103
- ...Object.fromEntries((config.experimental?.primary_tools ?? []).map((t) => [t, false])),
104
- ...agent.tools,
105
- },
106
- parts: promptParts,
107
- })
108
- unsub()
109
- const messages = await Session.messages({ sessionID: session.id })
110
- const summary = messages
111
- .filter((x) => x.info.role === "assistant")
112
- .flatMap((msg) => msg.parts.filter((x: any) => x.type === "tool") as MessageV2.ToolPart[])
113
- .map((part) => ({
114
- id: part.id,
115
- tool: part.tool,
116
- state: {
117
- status: part.state.status,
118
- title: part.state.status === "completed" ? part.state.title : undefined,
119
- },
120
- }))
121
- const text = result.parts.findLast((x) => x.type === "text")?.text ?? ""
122
-
123
- const output = text + "\n\n" + ["<task_metadata>", `session_id: ${session.id}`, "</task_metadata>"].join("\n")
124
-
125
- return {
126
- title: params.description,
127
- metadata: {
128
- summary,
129
- sessionId: session.id,
130
- },
131
- output,
132
- }
133
- },
134
- }
135
- })
package/src/tool/task.txt DELETED
@@ -1,60 +0,0 @@
1
- Launch a new agent to handle complex, multi-step tasks autonomously.
2
-
3
- Available agent types and the tools they have access to:
4
- {agents}
5
-
6
- When using the Task tool, you must specify a subagent_type parameter to select which agent type to use.
7
-
8
- When to use the Task tool:
9
- - When you are instructed to execute custom slash commands. Use the Task tool with the slash command invocation as the entire prompt. The slash command can take arguments. For example: Task(description="Check the file", prompt="/check-file path/to/file.py")
10
-
11
- When NOT to use the Task tool:
12
- - If you want to read a specific file path, use the Read or Glob tool instead of the Task tool, to find the match more quickly
13
- - If you are searching for a specific class definition like "class Foo", use the Glob tool instead, to find the match more quickly
14
- - If you are searching for code within a specific file or set of 2-3 files, use the Read tool instead of the Task tool, to find the match more quickly
15
- - Other tasks that are not related to the agent descriptions above
16
-
17
-
18
- Usage notes:
19
- 1. Launch multiple agents concurrently whenever possible, to maximize performance; to do that, use a single message with multiple tool uses
20
- 2. When the agent is done, it will return a single message back to you. The result returned by the agent is not visible to the user. To show the user the result, you should send a text message back to the user with a concise summary of the result.
21
- 3. Each agent invocation is stateless unless you provide a session_id. Your prompt should contain a highly detailed task description for the agent to perform autonomously and you should specify exactly what information the agent should return back to you in its final and only message to you.
22
- 4. The agent's outputs should generally be trusted
23
- 5. Clearly tell the agent whether you expect it to write code or just to do research (search, file reads, web fetches, etc.), since it is not aware of the user's intent
24
- 6. If the agent description mentions that it should be used proactively, then you should try your best to use it without the user having to ask for it first. Use your judgement.
25
-
26
- Example usage (NOTE: The agents below are fictional examples for illustration only - use the actual agents listed above):
27
-
28
- <example_agent_descriptions>
29
- "code-reviewer": use this agent after you are done writing a significant piece of code
30
- "greeting-responder": use this agent when to respond to user greetings with a friendly joke
31
- </example_agent_description>
32
-
33
- <example>
34
- user: "Please write a function that checks if a number is prime"
35
- assistant: Sure let me write a function that checks if a number is prime
36
- assistant: First let me use the Write tool to write a function that checks if a number is prime
37
- assistant: I'm going to use the Write tool to write the following code:
38
- <code>
39
- function isPrime(n) {
40
- if (n <= 1) return false
41
- for (let i = 2; i * i <= n; i++) {
42
- if (n % i === 0) return false
43
- }
44
- return true
45
- }
46
- </code>
47
- <commentary>
48
- Since a significant piece of code was written and the task was completed, now use the code-reviewer agent to review the code
49
- </commentary>
50
- assistant: Now let me use the code-reviewer agent to review the code
51
- assistant: Uses the Task tool to launch the code-reviewer agent
52
- </example>
53
-
54
- <example>
55
- user: "Hello"
56
- <commentary>
57
- Since the user is greeting, use the greeting-responder agent to respond with a friendly joke
58
- </commentary>
59
- assistant: "I'm going to use the Task tool to launch the with the greeting-responder agent"
60
- </example>
package/src/tool/todo.ts DELETED
@@ -1,39 +0,0 @@
1
- import z from "zod"
2
- import { Tool } from "./tool"
3
- import DESCRIPTION_WRITE from "./todowrite.txt"
4
- import { Todo } from "../session/todo"
5
-
6
- export const TodoWriteTool = Tool.define("todowrite", {
7
- description: DESCRIPTION_WRITE,
8
- parameters: z.object({
9
- todos: z.array(z.object(Todo.Info.shape)).describe("The updated todo list"),
10
- }),
11
- async execute(params, opts) {
12
- await Todo.update({
13
- sessionID: opts.sessionID,
14
- todos: params.todos,
15
- })
16
- return {
17
- title: `${params.todos.filter((x) => x.status !== "completed").length} todos`,
18
- output: JSON.stringify(params.todos, null, 2),
19
- metadata: {
20
- todos: params.todos,
21
- },
22
- }
23
- },
24
- })
25
-
26
- export const TodoReadTool = Tool.define("todoread", {
27
- description: "Use this tool to read your todo list",
28
- parameters: z.object({}),
29
- async execute(_params, opts) {
30
- const todos = await Todo.get(opts.sessionID)
31
- return {
32
- title: `${todos.filter((x) => x.status !== "completed").length} todos`,
33
- metadata: {
34
- todos,
35
- },
36
- output: JSON.stringify(todos, null, 2),
37
- }
38
- },
39
- })
@@ -1,14 +0,0 @@
1
- Use this tool to read the current to-do list for the session. This tool should be used proactively and frequently to ensure that you are aware of
2
- the status of the current task list. You should make use of this tool as often as possible, especially in the following situations:
3
- - At the beginning of conversations to see what's pending
4
- - Before starting new tasks to prioritize work
5
- - When the user asks about previous tasks or plans
6
- - Whenever you're uncertain about what to do next
7
- - After completing tasks to update your understanding of remaining work
8
- - After every few messages to ensure you're on track
9
-
10
- Usage:
11
- - This tool takes in no parameters. So leave the input blank or empty. DO NOT include a dummy object, placeholder string or a key like "input" or "empty". LEAVE IT BLANK.
12
- - Returns a list of todo items with their status, priority, and content
13
- - Use this information to track progress and plan next steps
14
- - If no todos exist yet, an empty list will be returned
@@ -1,167 +0,0 @@
1
- Use this tool to create and manage a structured task list for your current coding session. This helps you track progress, organize complex tasks, and demonstrate thoroughness to the user.
2
- It also helps the user understand the progress of the task and overall progress of their requests.
3
-
4
- ## When to Use This Tool
5
- Use this tool proactively in these scenarios:
6
-
7
- 1. Complex multi-step tasks - When a task requires 3 or more distinct steps or actions
8
- 2. Non-trivial and complex tasks - Tasks that require careful planning or multiple operations
9
- 3. User explicitly requests todo list - When the user directly asks you to use the todo list
10
- 4. User provides multiple tasks - When users provide a list of things to be done (numbered or comma-separated)
11
- 5. After receiving new instructions - Immediately capture user requirements as todos. Feel free to edit the todo list based on new information.
12
- 6. After completing a task - Mark it complete and add any new follow-up tasks
13
- 7. When you start working on a new task, mark the todo as in_progress. Ideally you should only have one todo as in_progress at a time. Complete existing tasks before starting new ones.
14
-
15
- ## When NOT to Use This Tool
16
-
17
- Skip using this tool when:
18
- 1. There is only a single, straightforward task
19
- 2. The task is trivial and tracking it provides no organizational benefit
20
- 3. The task can be completed in less than 3 trivial steps
21
- 4. The task is purely conversational or informational
22
-
23
- NOTE that you should not use this tool if there is only one trivial task to do. In this case you are better off just doing the task directly.
24
-
25
- ## Examples of When to Use the Todo List
26
-
27
- <example>
28
- User: I want to add a dark mode toggle to the application settings. Make sure you run the tests and build when you're done!
29
- Assistant: I'll help add a dark mode toggle to your application settings. Let me create a todo list to track this implementation.
30
- *Creates todo list with the following items:*
31
- 1. Create dark mode toggle component in Settings page
32
- 2. Add dark mode state management (context/store)
33
- 3. Implement CSS-in-JS styles for dark theme
34
- 4. Update existing components to support theme switching
35
- 5. Run tests and build process, addressing any failures or errors that occur
36
- *Begins working on the first task*
37
-
38
- <reasoning>
39
- The assistant used the todo list because:
40
- 1. Adding dark mode is a multi-step feature requiring UI, state management, and styling changes
41
- 2. The user explicitly requested tests and build be run afterward
42
- 3. The assistant inferred that tests and build need to pass by adding "Ensure tests and build succeed" as the final task
43
- </reasoning>
44
- </example>
45
-
46
- <example>
47
- User: Help me rename the function getCwd to getCurrentWorkingDirectory across my project
48
- Assistant: Let me first search through your codebase to find all occurrences of 'getCwd'.
49
- *Uses grep or search tools to locate all instances of getCwd in the codebase*
50
- Assistant: I've found 15 instances of 'getCwd' across 8 different files. Let me create a todo list to track these changes.
51
- *Creates todo list with specific items for each file that needs updating*
52
-
53
- <reasoning>
54
- The assistant used the todo list because:
55
- 1. First, the assistant searched to understand the scope of the task
56
- 2. Upon finding multiple occurrences across different files, it determined this was a complex task with multiple steps
57
- 3. The todo list helps ensure every instance is tracked and updated systematically
58
- 4. This approach prevents missing any occurrences and maintains code consistency
59
- </reasoning>
60
- </example>
61
-
62
-
63
- <example>
64
- User: I need to implement these features for my e-commerce site: user registration, product catalog, shopping cart, and checkout flow.
65
- Assistant: I'll help implement these features. First, let's add all the features to the todo list.
66
- *Creates a todo list breaking down each feature into specific tasks based on the project architecture*
67
- Assistant: Let's start with user registration. This will involve creating database models, API endpoints, and frontend forms that integrate with your existing authentication system.
68
-
69
- <reasoning>
70
- The assistant used the todo list because:
71
- 1. The user provided multiple complex features to implement in a comma separated list
72
- 2. The todo list helps organize these large features into manageable tasks
73
- 3. This approach allows for tracking progress across the entire implementation
74
- </reasoning>
75
- </example>
76
-
77
- <example>
78
- User: Can you help optimize my React application? It's rendering slowly and has performance issues.</user>
79
- Assistant: I'll help optimize your React application. First, let me examine your codebase to identify potential performance bottlenecks.
80
- *Reviews component structure, render patterns, state management, and data fetching*
81
- Assistant: After analyzing your codebase, I've identified several performance issues. Let me create a todo list to track our optimization efforts.
82
- *Creates todo list with items like: 1) Implement memoization for expensive calculations in ProductList, 2) Add virtualization for long lists in Dashboard, 3) Optimize image loading in Gallery component, 4) Fix state update loops in ShoppingCart, 5) Review bundle size and implement code splitting*
83
- Let's start by implementing memoization for the expensive calculations in your ProductList component.</assistant>
84
-
85
- <reasoning>
86
- The assistant used the todo list because:
87
- 1. First, the assistant examined the codebase to identify specific performance issues
88
- 2. Based on this analysis, it identified multiple optimization opportunities
89
- 3. Performance optimization is a non-trivial task requiring multiple steps
90
- 4. The todo list helps methodically track improvements across different components
91
- 5. This systematic approach ensures all performance bottlenecks are addressed
92
- </reasoning>
93
- </example>
94
-
95
- ## Examples of When NOT to Use the Todo List
96
-
97
- <example>
98
- User: How do I print 'Hello World' in Python?
99
- Assistant: In Python, you can print "Hello World" with this simple code:
100
-
101
- python
102
- print("Hello World")
103
-
104
- This will output the text "Hello World" to the console when executed.</assistant>
105
-
106
- <reasoning>
107
- The assistant did not use the todo list because this is a single, trivial task that can be completed in one step. There's no need to track multiple tasks or steps for such a straightforward request.
108
- </reasoning>
109
- </example>
110
-
111
- <example>
112
- User: What does the git status command do?
113
- Assistant: The git status command shows the current state of your working directory and staging area. It displays which changes have been staged, which haven't, and which files aren't being tracked by Git. This is a fundamental command for understanding the current state of your repository before making commits.
114
-
115
- <reasoning>
116
- The assistant did not use the todo list because this is an informational request with no actual coding task to complete. The user is simply asking for an explanation, not for the assistant to perform multiple steps or tasks.
117
- </reasoning>
118
- </example>
119
-
120
- <example>
121
- User: Can you add a comment to the calculateTotal function to explain what it does?
122
- Assistant: Sure, let me add a comment to the calculateTotal function to explain what it does.
123
- * Uses the Edit tool to add a comment to the calculateTotal function *
124
-
125
- <reasoning>
126
- The assistant did not use the todo list because this is a single, straightforward task confined to one location in the code. Adding a comment doesn't require tracking multiple steps or systematic organization.
127
- </reasoning>
128
- </example>
129
-
130
- <example>
131
- User: Run npm install for me and tell me what happens.
132
- Assistant: I'll run the npm install command for you.
133
-
134
- *Executes: npm install*
135
-
136
- The command completed successfully. Here's the output:
137
- [Output of npm install command]
138
-
139
- All dependencies have been installed according to your package.json file.
140
-
141
- <reasoning>
142
- The assistant did not use the todo list because this is a single command execution with immediate results. There are no multiple steps to track or organize, making the todo list unnecessary for this straightforward task.
143
- </reasoning>
144
- </example>
145
-
146
- ## Task States and Management
147
-
148
- 1. **Task States**: Use these states to track progress:
149
- - pending: Task not yet started
150
- - in_progress: Currently working on (limit to ONE task at a time)
151
- - completed: Task finished successfully
152
- - cancelled: Task no longer needed
153
-
154
- 2. **Task Management**:
155
- - Update task status in real-time as you work
156
- - Mark tasks complete IMMEDIATELY after finishing (don't batch completions)
157
- - Only have ONE task in_progress at any time
158
- - Complete current tasks before starting new ones
159
- - Cancel tasks that become irrelevant
160
-
161
- 3. **Task Breakdown**:
162
- - Create specific, actionable items
163
- - Break complex tasks into smaller, manageable steps
164
- - Use clear, descriptive task names
165
-
166
- When in doubt, use this tool. Being proactive with task management demonstrates attentiveness and ensures you complete all requirements successfully.
167
-
package/src/tool/tool.ts DELETED
@@ -1,66 +0,0 @@
1
- import z from "zod"
2
- import type { MessageV2 } from "../session/message-v2"
3
-
4
- export namespace Tool {
5
- interface Metadata {
6
- [key: string]: any
7
- }
8
-
9
- export type Context<M extends Metadata = Metadata> = {
10
- sessionID: string
11
- messageID: string
12
- agent: string
13
- abort: AbortSignal
14
- callID?: string
15
- extra?: { [key: string]: any }
16
- metadata(input: { title?: string; metadata?: M }): void
17
- }
18
- export interface Info<Parameters extends z.ZodType = z.ZodType, M extends Metadata = Metadata> {
19
- id: string
20
- init: () => Promise<{
21
- description: string
22
- parameters: Parameters
23
- execute(
24
- args: z.infer<Parameters>,
25
- ctx: Context,
26
- ): Promise<{
27
- title: string
28
- metadata: M
29
- output: string
30
- attachments?: MessageV2.FilePart[]
31
- }>
32
- formatValidationError?(error: z.ZodError): string
33
- }>
34
- }
35
-
36
- export type InferParameters<T extends Info> = T extends Info<infer P> ? z.infer<P> : never
37
- export type InferMetadata<T extends Info> = T extends Info<any, infer M> ? M : never
38
-
39
- export function define<Parameters extends z.ZodType, Result extends Metadata>(
40
- id: string,
41
- init: Info<Parameters, Result>["init"] | Awaited<ReturnType<Info<Parameters, Result>["init"]>>,
42
- ): Info<Parameters, Result> {
43
- return {
44
- id,
45
- init: async () => {
46
- const toolInfo = init instanceof Function ? await init() : init
47
- const execute = toolInfo.execute
48
- toolInfo.execute = (args, ctx) => {
49
- try {
50
- toolInfo.parameters.parse(args)
51
- } catch (error) {
52
- if (error instanceof z.ZodError && toolInfo.formatValidationError) {
53
- throw new Error(toolInfo.formatValidationError(error), { cause: error })
54
- }
55
- throw new Error(
56
- `The ${id} tool was called with invalid arguments: ${error}.\nPlease rewrite the input so it satisfies the expected schema.`,
57
- { cause: error },
58
- )
59
- }
60
- return execute(args, ctx)
61
- }
62
- return toolInfo
63
- },
64
- }
65
- }
66
- }
@@ -1,187 +0,0 @@
1
- import z from "zod"
2
- import { Tool } from "./tool"
3
- import TurndownService from "turndown"
4
- import DESCRIPTION from "./webfetch.txt"
5
- import { Config } from "../config/config"
6
- import { Permission } from "../permission"
7
-
8
- const MAX_RESPONSE_SIZE = 5 * 1024 * 1024 // 5MB
9
- const DEFAULT_TIMEOUT = 30 * 1000 // 30 seconds
10
- const MAX_TIMEOUT = 120 * 1000 // 2 minutes
11
-
12
- export const WebFetchTool = Tool.define("webfetch", {
13
- description: DESCRIPTION,
14
- parameters: z.object({
15
- url: z.string().describe("The URL to fetch content from"),
16
- format: z
17
- .enum(["text", "markdown", "html"])
18
- .describe("The format to return the content in (text, markdown, or html)"),
19
- timeout: z.number().describe("Optional timeout in seconds (max 120)").optional(),
20
- }),
21
- async execute(params, ctx) {
22
- // Validate URL
23
- if (!params.url.startsWith("http://") && !params.url.startsWith("https://")) {
24
- throw new Error("URL must start with http:// or https://")
25
- }
26
-
27
- const cfg = await Config.get()
28
- if (cfg.permission?.webfetch === "ask")
29
- await Permission.ask({
30
- type: "webfetch",
31
- sessionID: ctx.sessionID,
32
- messageID: ctx.messageID,
33
- callID: ctx.callID,
34
- title: "Fetch content from: " + params.url,
35
- metadata: {
36
- url: params.url,
37
- format: params.format,
38
- timeout: params.timeout,
39
- },
40
- })
41
-
42
- const timeout = Math.min((params.timeout ?? DEFAULT_TIMEOUT / 1000) * 1000, MAX_TIMEOUT)
43
-
44
- const controller = new AbortController()
45
- const timeoutId = setTimeout(() => controller.abort(), timeout)
46
-
47
- // Build Accept header based on requested format with q parameters for fallbacks
48
- let acceptHeader = "*/*"
49
- switch (params.format) {
50
- case "markdown":
51
- acceptHeader = "text/markdown;q=1.0, text/x-markdown;q=0.9, text/plain;q=0.8, text/html;q=0.7, */*;q=0.1"
52
- break
53
- case "text":
54
- acceptHeader = "text/plain;q=1.0, text/markdown;q=0.9, text/html;q=0.8, */*;q=0.1"
55
- break
56
- case "html":
57
- acceptHeader = "text/html;q=1.0, application/xhtml+xml;q=0.9, text/plain;q=0.8, text/markdown;q=0.7, */*;q=0.1"
58
- break
59
- default:
60
- acceptHeader =
61
- "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8"
62
- }
63
-
64
- const response = await fetch(params.url, {
65
- signal: AbortSignal.any([controller.signal, ctx.abort]),
66
- headers: {
67
- "User-Agent":
68
- "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
69
- Accept: acceptHeader,
70
- "Accept-Language": "en-US,en;q=0.9",
71
- },
72
- })
73
-
74
- clearTimeout(timeoutId)
75
-
76
- if (!response.ok) {
77
- throw new Error(`Request failed with status code: ${response.status}`)
78
- }
79
-
80
- // Check content length
81
- const contentLength = response.headers.get("content-length")
82
- if (contentLength && parseInt(contentLength) > MAX_RESPONSE_SIZE) {
83
- throw new Error("Response too large (exceeds 5MB limit)")
84
- }
85
-
86
- const arrayBuffer = await response.arrayBuffer()
87
- if (arrayBuffer.byteLength > MAX_RESPONSE_SIZE) {
88
- throw new Error("Response too large (exceeds 5MB limit)")
89
- }
90
-
91
- const content = new TextDecoder().decode(arrayBuffer)
92
- const contentType = response.headers.get("content-type") || ""
93
-
94
- const title = `${params.url} (${contentType})`
95
-
96
- // Handle content based on requested format and actual content type
97
- switch (params.format) {
98
- case "markdown":
99
- if (contentType.includes("text/html")) {
100
- const markdown = convertHTMLToMarkdown(content)
101
- return {
102
- output: markdown,
103
- title,
104
- metadata: {},
105
- }
106
- }
107
- return {
108
- output: content,
109
- title,
110
- metadata: {},
111
- }
112
-
113
- case "text":
114
- if (contentType.includes("text/html")) {
115
- const text = await extractTextFromHTML(content)
116
- return {
117
- output: text,
118
- title,
119
- metadata: {},
120
- }
121
- }
122
- return {
123
- output: content,
124
- title,
125
- metadata: {},
126
- }
127
-
128
- case "html":
129
- return {
130
- output: content,
131
- title,
132
- metadata: {},
133
- }
134
-
135
- default:
136
- return {
137
- output: content,
138
- title,
139
- metadata: {},
140
- }
141
- }
142
- },
143
- })
144
-
145
- async function extractTextFromHTML(html: string) {
146
- let text = ""
147
- let skipContent = false
148
-
149
- const rewriter = new HTMLRewriter()
150
- .on("script, style, noscript, iframe, object, embed", {
151
- element() {
152
- skipContent = true
153
- },
154
- text() {
155
- // Skip text content inside these elements
156
- },
157
- })
158
- .on("*", {
159
- element(element) {
160
- // Reset skip flag when entering other elements
161
- if (!["script", "style", "noscript", "iframe", "object", "embed"].includes(element.tagName)) {
162
- skipContent = false
163
- }
164
- },
165
- text(input) {
166
- if (!skipContent) {
167
- text += input.text
168
- }
169
- },
170
- })
171
- .transform(new Response(html))
172
-
173
- await rewriter.text()
174
- return text.trim()
175
- }
176
-
177
- function convertHTMLToMarkdown(html: string): string {
178
- const turndownService = new TurndownService({
179
- headingStyle: "atx",
180
- hr: "---",
181
- bulletListMarker: "-",
182
- codeBlockStyle: "fenced",
183
- emDelimiter: "*",
184
- })
185
- turndownService.remove(["script", "style", "meta", "link"])
186
- return turndownService.turndown(html)
187
- }