alchemylab-opencode 1.0.6 → 1.0.8

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 (413) hide show
  1. package/dist/arktype-aI7TBD0R-HX4BR3RX.js +21 -0
  2. package/dist/arktype-aI7TBD0R-HX4BR3RX.js.map +7 -0
  3. package/dist/{chunk-UWZSRZHA.js → chunk-23UYOGZG.js} +817 -315
  4. package/dist/chunk-23UYOGZG.js.map +7 -0
  5. package/dist/chunk-3AF5MXLF.js +49 -0
  6. package/dist/chunk-3AF5MXLF.js.map +7 -0
  7. package/dist/chunk-FMP3YLWX.js +30 -0
  8. package/dist/chunk-FMP3YLWX.js.map +7 -0
  9. package/dist/{chunk-ANDTK76Q.js → chunk-GSE2T5UY.js} +3 -3
  10. package/dist/{chunk-CYXMV3J3.js → chunk-LU5XVQUD.js} +4 -4
  11. package/dist/chunk-O5VWOPCL.js +106 -0
  12. package/dist/chunk-O5VWOPCL.js.map +7 -0
  13. package/dist/chunk-PWFRMDDF.js +12 -0
  14. package/dist/{chunk-DSPC5QIG.js → chunk-SM6WZDN6.js} +9 -9
  15. package/dist/{chunk-MCWTARFP.js → chunk-TASPMBUL.js} +4 -4
  16. package/dist/chunk-VL3RSEZ2.js +160 -0
  17. package/dist/chunk-VL3RSEZ2.js.map +7 -0
  18. package/dist/default-u_dwuiYb-WOFHQQ3K.js +22 -0
  19. package/dist/effect-QlVUlMFu-UERLUUQW.js +29 -0
  20. package/dist/effect-QlVUlMFu-UERLUUQW.js.map +7 -0
  21. package/dist/{mcp-VAU4RMWH.js → mcp-XFGN3FWW.js} +2 -2
  22. package/dist/{registry-PYMN6L3G.js → registry-W4MBVBYD.js} +3 -3
  23. package/dist/{run-YFVCQJQM.js → run-73HUV4H3.js} +9 -6
  24. package/dist/{run-YFVCQJQM.js.map → run-73HUV4H3.js.map} +1 -1
  25. package/dist/run.js +1 -1
  26. package/dist/serve.js +1 -1
  27. package/dist/{server-K3UGWASP.js → server-2CPOG3LS.js} +9 -6
  28. package/dist/{session-HJFWTM7C.js → session-M6HOZ56B.js} +3 -3
  29. package/dist/session-M6HOZ56B.js.map +7 -0
  30. package/dist/{share-next-55VCIMUH.js → share-next-QRBVSD37.js} +4 -4
  31. package/dist/share-next-QRBVSD37.js.map +7 -0
  32. package/dist/sury-CWZTCd75-XC3NCMTP.js +29 -0
  33. package/dist/sury-CWZTCd75-XC3NCMTP.js.map +7 -0
  34. package/dist/typebox-Dei93FPO-QOBKW4L7.js +21 -0
  35. package/dist/typebox-Dei93FPO-QOBKW4L7.js.map +7 -0
  36. package/dist/valibot--1zFm7rT-LHHLSLYY.js +29 -0
  37. package/dist/valibot--1zFm7rT-LHHLSLYY.js.map +7 -0
  38. package/dist/valibot-D_HTw1Gn-UR62BIDY.js +60 -0
  39. package/dist/valibot-D_HTw1Gn-UR62BIDY.js.map +7 -0
  40. package/dist/{worktree-6GGDLADY.js → worktree-3GUHT2P7.js} +5 -5
  41. package/dist/zod-Bwrt9trS-J2GOMA2R.js +43 -0
  42. package/dist/zod-Bwrt9trS-J2GOMA2R.js.map +7 -0
  43. package/dist/zod-DSgpEGAE-VTXQW6SB.js +56 -0
  44. package/dist/zod-DSgpEGAE-VTXQW6SB.js.map +7 -0
  45. package/package.json +2 -15
  46. package/build.mjs +0 -182
  47. package/dist/chunk-UWZSRZHA.js.map +0 -7
  48. package/packages/opencode/package.json +0 -138
  49. package/packages/opencode/src/account/account.sql.ts +0 -39
  50. package/packages/opencode/src/account/index.ts +0 -463
  51. package/packages/opencode/src/account/repo.ts +0 -163
  52. package/packages/opencode/src/account/schema.ts +0 -91
  53. package/packages/opencode/src/acp/README.md +0 -174
  54. package/packages/opencode/src/acp/agent.ts +0 -1847
  55. package/packages/opencode/src/acp/session.ts +0 -116
  56. package/packages/opencode/src/acp/types.ts +0 -24
  57. package/packages/opencode/src/agent/agent.ts +0 -420
  58. package/packages/opencode/src/agent/generate.txt +0 -75
  59. package/packages/opencode/src/agent/prompt/compaction.txt +0 -15
  60. package/packages/opencode/src/agent/prompt/explore.txt +0 -18
  61. package/packages/opencode/src/agent/prompt/summary.txt +0 -11
  62. package/packages/opencode/src/agent/prompt/title.txt +0 -44
  63. package/packages/opencode/src/auth/index.ts +0 -110
  64. package/packages/opencode/src/bus/bus-event.ts +0 -40
  65. package/packages/opencode/src/bus/global.ts +0 -10
  66. package/packages/opencode/src/bus/index.ts +0 -185
  67. package/packages/opencode/src/cli/bootstrap.ts +0 -17
  68. package/packages/opencode/src/cli/cmd/cmd.ts +0 -7
  69. package/packages/opencode/src/cli/cmd/run.ts +0 -689
  70. package/packages/opencode/src/cli/cmd/serve.ts +0 -24
  71. package/packages/opencode/src/cli/cmd/tui/event.ts +0 -49
  72. package/packages/opencode/src/cli/effect/prompt.ts +0 -25
  73. package/packages/opencode/src/cli/error.ts +0 -46
  74. package/packages/opencode/src/cli/heap.ts +0 -59
  75. package/packages/opencode/src/cli/logo.ts +0 -6
  76. package/packages/opencode/src/cli/network.ts +0 -60
  77. package/packages/opencode/src/cli/ui.ts +0 -133
  78. package/packages/opencode/src/cli/upgrade.ts +0 -31
  79. package/packages/opencode/src/command/index.ts +0 -195
  80. package/packages/opencode/src/command/template/initialize.txt +0 -66
  81. package/packages/opencode/src/command/template/review.txt +0 -101
  82. package/packages/opencode/src/config/config.ts +0 -1599
  83. package/packages/opencode/src/config/console-state.ts +0 -15
  84. package/packages/opencode/src/config/markdown.ts +0 -99
  85. package/packages/opencode/src/config/paths.ts +0 -167
  86. package/packages/opencode/src/config/tui-migrate.ts +0 -155
  87. package/packages/opencode/src/config/tui-schema.ts +0 -37
  88. package/packages/opencode/src/config/tui.ts +0 -179
  89. package/packages/opencode/src/control-plane/adaptors/index.ts +0 -20
  90. package/packages/opencode/src/control-plane/adaptors/worktree.ts +0 -42
  91. package/packages/opencode/src/control-plane/schema.ts +0 -17
  92. package/packages/opencode/src/control-plane/sse.ts +0 -66
  93. package/packages/opencode/src/control-plane/types.ts +0 -32
  94. package/packages/opencode/src/control-plane/workspace.sql.ts +0 -17
  95. package/packages/opencode/src/control-plane/workspace.ts +0 -168
  96. package/packages/opencode/src/effect/cross-spawn-spawner.ts +0 -502
  97. package/packages/opencode/src/effect/instance-ref.ts +0 -6
  98. package/packages/opencode/src/effect/instance-registry.ts +0 -12
  99. package/packages/opencode/src/effect/instance-state.ts +0 -82
  100. package/packages/opencode/src/effect/run-service.ts +0 -33
  101. package/packages/opencode/src/effect/runner.ts +0 -216
  102. package/packages/opencode/src/env/index.ts +0 -28
  103. package/packages/opencode/src/file/ignore.ts +0 -82
  104. package/packages/opencode/src/file/index.ts +0 -686
  105. package/packages/opencode/src/file/protected.ts +0 -59
  106. package/packages/opencode/src/file/ripgrep.ts +0 -376
  107. package/packages/opencode/src/file/time.ts +0 -133
  108. package/packages/opencode/src/file/watcher.ts +0 -173
  109. package/packages/opencode/src/filesystem/index.ts +0 -236
  110. package/packages/opencode/src/flag/flag.ts +0 -156
  111. package/packages/opencode/src/format/formatter.ts +0 -413
  112. package/packages/opencode/src/format/index.ts +0 -203
  113. package/packages/opencode/src/git/index.ts +0 -303
  114. package/packages/opencode/src/global/index.ts +0 -56
  115. package/packages/opencode/src/id/id.ts +0 -85
  116. package/packages/opencode/src/ide/index.ts +0 -74
  117. package/packages/opencode/src/installation/index.ts +0 -355
  118. package/packages/opencode/src/installation/meta.ts +0 -7
  119. package/packages/opencode/src/lsp/client.ts +0 -252
  120. package/packages/opencode/src/lsp/index.ts +0 -558
  121. package/packages/opencode/src/lsp/language.ts +0 -120
  122. package/packages/opencode/src/lsp/launch.ts +0 -21
  123. package/packages/opencode/src/lsp/server.ts +0 -1968
  124. package/packages/opencode/src/mcp/auth.ts +0 -173
  125. package/packages/opencode/src/mcp/index.ts +0 -931
  126. package/packages/opencode/src/mcp/oauth-callback.ts +0 -216
  127. package/packages/opencode/src/mcp/oauth-provider.ts +0 -185
  128. package/packages/opencode/src/node-loader.mjs +0 -104
  129. package/packages/opencode/src/node-preload.mjs +0 -39
  130. package/packages/opencode/src/node.ts +0 -1
  131. package/packages/opencode/src/npm/index.ts +0 -188
  132. package/packages/opencode/src/patch/index.ts +0 -680
  133. package/packages/opencode/src/permission/arity.ts +0 -163
  134. package/packages/opencode/src/permission/evaluate.ts +0 -15
  135. package/packages/opencode/src/permission/index.ts +0 -325
  136. package/packages/opencode/src/permission/schema.ts +0 -17
  137. package/packages/opencode/src/plugin/cloudflare.ts +0 -67
  138. package/packages/opencode/src/plugin/codex.ts +0 -608
  139. package/packages/opencode/src/plugin/github-copilot/copilot.ts +0 -361
  140. package/packages/opencode/src/plugin/github-copilot/models.ts +0 -144
  141. package/packages/opencode/src/plugin/index.ts +0 -299
  142. package/packages/opencode/src/plugin/install.ts +0 -439
  143. package/packages/opencode/src/plugin/loader.ts +0 -174
  144. package/packages/opencode/src/plugin/meta.ts +0 -188
  145. package/packages/opencode/src/plugin/shared.ts +0 -323
  146. package/packages/opencode/src/project/bootstrap.ts +0 -31
  147. package/packages/opencode/src/project/instance.ts +0 -175
  148. package/packages/opencode/src/project/project.sql.ts +0 -16
  149. package/packages/opencode/src/project/project.ts +0 -519
  150. package/packages/opencode/src/project/schema.ts +0 -16
  151. package/packages/opencode/src/project/state.ts +0 -70
  152. package/packages/opencode/src/project/vcs.ts +0 -240
  153. package/packages/opencode/src/provider/auth.ts +0 -253
  154. package/packages/opencode/src/provider/error.ts +0 -197
  155. package/packages/opencode/src/provider/models.ts +0 -162
  156. package/packages/opencode/src/provider/provider.ts +0 -1709
  157. package/packages/opencode/src/provider/schema.ts +0 -38
  158. package/packages/opencode/src/provider/sdk/copilot/README.md +0 -5
  159. package/packages/opencode/src/provider/sdk/copilot/chat/convert-to-openai-compatible-chat-messages.ts +0 -170
  160. package/packages/opencode/src/provider/sdk/copilot/chat/get-response-metadata.ts +0 -15
  161. package/packages/opencode/src/provider/sdk/copilot/chat/map-openai-compatible-finish-reason.ts +0 -19
  162. package/packages/opencode/src/provider/sdk/copilot/chat/openai-compatible-api-types.ts +0 -64
  163. package/packages/opencode/src/provider/sdk/copilot/chat/openai-compatible-chat-language-model.ts +0 -815
  164. package/packages/opencode/src/provider/sdk/copilot/chat/openai-compatible-chat-options.ts +0 -28
  165. package/packages/opencode/src/provider/sdk/copilot/chat/openai-compatible-metadata-extractor.ts +0 -44
  166. package/packages/opencode/src/provider/sdk/copilot/chat/openai-compatible-prepare-tools.ts +0 -83
  167. package/packages/opencode/src/provider/sdk/copilot/copilot-provider.ts +0 -100
  168. package/packages/opencode/src/provider/sdk/copilot/index.ts +0 -2
  169. package/packages/opencode/src/provider/sdk/copilot/openai-compatible-error.ts +0 -27
  170. package/packages/opencode/src/provider/sdk/copilot/responses/convert-to-openai-responses-input.ts +0 -335
  171. package/packages/opencode/src/provider/sdk/copilot/responses/map-openai-responses-finish-reason.ts +0 -22
  172. package/packages/opencode/src/provider/sdk/copilot/responses/openai-config.ts +0 -18
  173. package/packages/opencode/src/provider/sdk/copilot/responses/openai-error.ts +0 -22
  174. package/packages/opencode/src/provider/sdk/copilot/responses/openai-responses-api-types.ts +0 -214
  175. package/packages/opencode/src/provider/sdk/copilot/responses/openai-responses-language-model.ts +0 -1769
  176. package/packages/opencode/src/provider/sdk/copilot/responses/openai-responses-prepare-tools.ts +0 -173
  177. package/packages/opencode/src/provider/sdk/copilot/responses/openai-responses-settings.ts +0 -1
  178. package/packages/opencode/src/provider/sdk/copilot/responses/tool/code-interpreter.ts +0 -87
  179. package/packages/opencode/src/provider/sdk/copilot/responses/tool/file-search.ts +0 -127
  180. package/packages/opencode/src/provider/sdk/copilot/responses/tool/image-generation.ts +0 -114
  181. package/packages/opencode/src/provider/sdk/copilot/responses/tool/local-shell.ts +0 -64
  182. package/packages/opencode/src/provider/sdk/copilot/responses/tool/web-search-preview.ts +0 -103
  183. package/packages/opencode/src/provider/sdk/copilot/responses/tool/web-search.ts +0 -102
  184. package/packages/opencode/src/provider/transform.ts +0 -1050
  185. package/packages/opencode/src/pty/index.ts +0 -397
  186. package/packages/opencode/src/pty/pty.node.ts +0 -27
  187. package/packages/opencode/src/pty/pty.ts +0 -25
  188. package/packages/opencode/src/pty/schema.ts +0 -17
  189. package/packages/opencode/src/question/index.ts +0 -224
  190. package/packages/opencode/src/question/schema.ts +0 -17
  191. package/packages/opencode/src/run.ts +0 -28
  192. package/packages/opencode/src/serve.ts +0 -45
  193. package/packages/opencode/src/server/error.ts +0 -36
  194. package/packages/opencode/src/server/event.ts +0 -7
  195. package/packages/opencode/src/server/instance.ts +0 -324
  196. package/packages/opencode/src/server/mdns.ts +0 -60
  197. package/packages/opencode/src/server/middleware.ts +0 -33
  198. package/packages/opencode/src/server/projectors.ts +0 -28
  199. package/packages/opencode/src/server/proxy.ts +0 -131
  200. package/packages/opencode/src/server/router.ts +0 -105
  201. package/packages/opencode/src/server/routes/config.ts +0 -92
  202. package/packages/opencode/src/server/routes/event.ts +0 -83
  203. package/packages/opencode/src/server/routes/experimental.ts +0 -374
  204. package/packages/opencode/src/server/routes/file.ts +0 -197
  205. package/packages/opencode/src/server/routes/global.ts +0 -312
  206. package/packages/opencode/src/server/routes/mcp.ts +0 -225
  207. package/packages/opencode/src/server/routes/permission.ts +0 -69
  208. package/packages/opencode/src/server/routes/project.ts +0 -118
  209. package/packages/opencode/src/server/routes/provider.ts +0 -171
  210. package/packages/opencode/src/server/routes/pty.ts +0 -210
  211. package/packages/opencode/src/server/routes/question.ts +0 -99
  212. package/packages/opencode/src/server/routes/session.ts +0 -1030
  213. package/packages/opencode/src/server/routes/tui.ts +0 -379
  214. package/packages/opencode/src/server/routes/workspace.ts +0 -94
  215. package/packages/opencode/src/server/server.ts +0 -353
  216. package/packages/opencode/src/session/compaction.ts +0 -428
  217. package/packages/opencode/src/session/index.ts +0 -887
  218. package/packages/opencode/src/session/instruction.ts +0 -258
  219. package/packages/opencode/src/session/llm.ts +0 -354
  220. package/packages/opencode/src/session/message-v2.ts +0 -1031
  221. package/packages/opencode/src/session/message.ts +0 -191
  222. package/packages/opencode/src/session/overflow.ts +0 -22
  223. package/packages/opencode/src/session/processor.ts +0 -523
  224. package/packages/opencode/src/session/projectors.ts +0 -135
  225. package/packages/opencode/src/session/prompt/anthropic.txt +0 -105
  226. package/packages/opencode/src/session/prompt/beast.txt +0 -147
  227. package/packages/opencode/src/session/prompt/build-switch.txt +0 -5
  228. package/packages/opencode/src/session/prompt/codex.txt +0 -79
  229. package/packages/opencode/src/session/prompt/copilot-gpt-5.txt +0 -143
  230. package/packages/opencode/src/session/prompt/default.txt +0 -105
  231. package/packages/opencode/src/session/prompt/gemini.txt +0 -155
  232. package/packages/opencode/src/session/prompt/gpt.txt +0 -107
  233. package/packages/opencode/src/session/prompt/kimi.txt +0 -95
  234. package/packages/opencode/src/session/prompt/max-steps.txt +0 -16
  235. package/packages/opencode/src/session/prompt/plan-reminder-anthropic.txt +0 -67
  236. package/packages/opencode/src/session/prompt/plan.txt +0 -26
  237. package/packages/opencode/src/session/prompt/trinity.txt +0 -97
  238. package/packages/opencode/src/session/prompt.ts +0 -1911
  239. package/packages/opencode/src/session/retry.ts +0 -106
  240. package/packages/opencode/src/session/revert.ts +0 -176
  241. package/packages/opencode/src/session/schema.ts +0 -38
  242. package/packages/opencode/src/session/session.sql.ts +0 -103
  243. package/packages/opencode/src/session/status.ts +0 -102
  244. package/packages/opencode/src/session/summary.ts +0 -177
  245. package/packages/opencode/src/session/system.ts +0 -76
  246. package/packages/opencode/src/session/todo.ts +0 -95
  247. package/packages/opencode/src/share/share-next.ts +0 -369
  248. package/packages/opencode/src/share/share.sql.ts +0 -13
  249. package/packages/opencode/src/shell/shell.ts +0 -110
  250. package/packages/opencode/src/skill/discovery.ts +0 -116
  251. package/packages/opencode/src/skill/index.ts +0 -277
  252. package/packages/opencode/src/snapshot/index.ts +0 -726
  253. package/packages/opencode/src/sql.d.ts +0 -4
  254. package/packages/opencode/src/storage/db.node.ts +0 -8
  255. package/packages/opencode/src/storage/db.ts +0 -177
  256. package/packages/opencode/src/storage/json-migration.ts +0 -425
  257. package/packages/opencode/src/storage/schema.sql.ts +0 -10
  258. package/packages/opencode/src/storage/schema.ts +0 -5
  259. package/packages/opencode/src/storage/storage.ts +0 -353
  260. package/packages/opencode/src/sync/README.md +0 -179
  261. package/packages/opencode/src/sync/event.sql.ts +0 -16
  262. package/packages/opencode/src/sync/index.ts +0 -263
  263. package/packages/opencode/src/sync/schema.ts +0 -14
  264. package/packages/opencode/src/tool/apply_patch.ts +0 -281
  265. package/packages/opencode/src/tool/apply_patch.txt +0 -33
  266. package/packages/opencode/src/tool/bash.ts +0 -496
  267. package/packages/opencode/src/tool/bash.txt +0 -117
  268. package/packages/opencode/src/tool/batch.ts +0 -183
  269. package/packages/opencode/src/tool/batch.txt +0 -24
  270. package/packages/opencode/src/tool/codesearch.ts +0 -132
  271. package/packages/opencode/src/tool/codesearch.txt +0 -12
  272. package/packages/opencode/src/tool/edit.ts +0 -667
  273. package/packages/opencode/src/tool/edit.txt +0 -10
  274. package/packages/opencode/src/tool/external-directory.ts +0 -46
  275. package/packages/opencode/src/tool/glob.ts +0 -78
  276. package/packages/opencode/src/tool/glob.txt +0 -6
  277. package/packages/opencode/src/tool/grep.ts +0 -156
  278. package/packages/opencode/src/tool/grep.txt +0 -8
  279. package/packages/opencode/src/tool/invalid.ts +0 -17
  280. package/packages/opencode/src/tool/ls.ts +0 -121
  281. package/packages/opencode/src/tool/ls.txt +0 -1
  282. package/packages/opencode/src/tool/lsp.ts +0 -97
  283. package/packages/opencode/src/tool/lsp.txt +0 -19
  284. package/packages/opencode/src/tool/multiedit.ts +0 -46
  285. package/packages/opencode/src/tool/multiedit.txt +0 -41
  286. package/packages/opencode/src/tool/plan-enter.txt +0 -14
  287. package/packages/opencode/src/tool/plan-exit.txt +0 -13
  288. package/packages/opencode/src/tool/plan.ts +0 -131
  289. package/packages/opencode/src/tool/question.ts +0 -46
  290. package/packages/opencode/src/tool/question.txt +0 -10
  291. package/packages/opencode/src/tool/read.ts +0 -332
  292. package/packages/opencode/src/tool/read.txt +0 -14
  293. package/packages/opencode/src/tool/registry.ts +0 -265
  294. package/packages/opencode/src/tool/schema.ts +0 -17
  295. package/packages/opencode/src/tool/skill.ts +0 -105
  296. package/packages/opencode/src/tool/task.ts +0 -166
  297. package/packages/opencode/src/tool/task.txt +0 -60
  298. package/packages/opencode/src/tool/todo.ts +0 -48
  299. package/packages/opencode/src/tool/todowrite.txt +0 -167
  300. package/packages/opencode/src/tool/tool.ts +0 -112
  301. package/packages/opencode/src/tool/truncate.ts +0 -144
  302. package/packages/opencode/src/tool/truncation-dir.ts +0 -4
  303. package/packages/opencode/src/tool/webfetch.ts +0 -206
  304. package/packages/opencode/src/tool/webfetch.txt +0 -13
  305. package/packages/opencode/src/tool/websearch.ts +0 -150
  306. package/packages/opencode/src/tool/websearch.txt +0 -14
  307. package/packages/opencode/src/tool/write.ts +0 -84
  308. package/packages/opencode/src/tool/write.txt +0 -8
  309. package/packages/opencode/src/util/abort.ts +0 -35
  310. package/packages/opencode/src/util/archive.ts +0 -17
  311. package/packages/opencode/src/util/color.ts +0 -19
  312. package/packages/opencode/src/util/context.ts +0 -25
  313. package/packages/opencode/src/util/data-url.ts +0 -9
  314. package/packages/opencode/src/util/defer.ts +0 -12
  315. package/packages/opencode/src/util/effect-http-client.ts +0 -11
  316. package/packages/opencode/src/util/effect-zod.ts +0 -98
  317. package/packages/opencode/src/util/error.ts +0 -77
  318. package/packages/opencode/src/util/filesystem.ts +0 -245
  319. package/packages/opencode/src/util/flock.ts +0 -333
  320. package/packages/opencode/src/util/fn.ts +0 -21
  321. package/packages/opencode/src/util/format.ts +0 -20
  322. package/packages/opencode/src/util/glob.ts +0 -34
  323. package/packages/opencode/src/util/hash.ts +0 -7
  324. package/packages/opencode/src/util/iife.ts +0 -3
  325. package/packages/opencode/src/util/keybind.ts +0 -103
  326. package/packages/opencode/src/util/lazy.ts +0 -23
  327. package/packages/opencode/src/util/locale.ts +0 -81
  328. package/packages/opencode/src/util/lock.ts +0 -98
  329. package/packages/opencode/src/util/log.ts +0 -182
  330. package/packages/opencode/src/util/network.ts +0 -9
  331. package/packages/opencode/src/util/process.ts +0 -176
  332. package/packages/opencode/src/util/queue.ts +0 -32
  333. package/packages/opencode/src/util/record.ts +0 -3
  334. package/packages/opencode/src/util/rpc.ts +0 -66
  335. package/packages/opencode/src/util/schema.ts +0 -53
  336. package/packages/opencode/src/util/scrap.ts +0 -10
  337. package/packages/opencode/src/util/signal.ts +0 -12
  338. package/packages/opencode/src/util/timeout.ts +0 -14
  339. package/packages/opencode/src/util/token.ts +0 -7
  340. package/packages/opencode/src/util/update-schema.ts +0 -13
  341. package/packages/opencode/src/util/which.ts +0 -14
  342. package/packages/opencode/src/util/wildcard.ts +0 -59
  343. package/packages/opencode/src/worktree/index.ts +0 -612
  344. package/packages/plugin/package.json +0 -38
  345. package/packages/plugin/src/example.ts +0 -18
  346. package/packages/plugin/src/index.ts +0 -282
  347. package/packages/plugin/src/shell.ts +0 -136
  348. package/packages/plugin/src/tool.ts +0 -38
  349. package/packages/plugin/src/tui.ts +0 -508
  350. package/packages/script/package.json +0 -16
  351. package/packages/script/src/index.ts +0 -77
  352. package/packages/sdk/package.json +0 -33
  353. package/packages/sdk/src/client.ts +0 -55
  354. package/packages/sdk/src/gen/client/client.gen.ts +0 -212
  355. package/packages/sdk/src/gen/client/index.ts +0 -25
  356. package/packages/sdk/src/gen/client/types.gen.ts +0 -222
  357. package/packages/sdk/src/gen/client/utils.gen.ts +0 -287
  358. package/packages/sdk/src/gen/client.gen.ts +0 -22
  359. package/packages/sdk/src/gen/core/auth.gen.ts +0 -41
  360. package/packages/sdk/src/gen/core/bodySerializer.gen.ts +0 -74
  361. package/packages/sdk/src/gen/core/params.gen.ts +0 -144
  362. package/packages/sdk/src/gen/core/pathSerializer.gen.ts +0 -167
  363. package/packages/sdk/src/gen/core/queryKeySerializer.gen.ts +0 -111
  364. package/packages/sdk/src/gen/core/serverSentEvents.gen.ts +0 -210
  365. package/packages/sdk/src/gen/core/types.gen.ts +0 -91
  366. package/packages/sdk/src/gen/core/utils.gen.ts +0 -109
  367. package/packages/sdk/src/gen/sdk.gen.ts +0 -1197
  368. package/packages/sdk/src/gen/types.gen.ts +0 -3904
  369. package/packages/sdk/src/index.ts +0 -21
  370. package/packages/sdk/src/process.ts +0 -31
  371. package/packages/sdk/src/server.ts +0 -134
  372. package/packages/sdk/src/v2/client.ts +0 -81
  373. package/packages/sdk/src/v2/gen/client/client.gen.ts +0 -285
  374. package/packages/sdk/src/v2/gen/client/index.ts +0 -25
  375. package/packages/sdk/src/v2/gen/client/types.gen.ts +0 -202
  376. package/packages/sdk/src/v2/gen/client/utils.gen.ts +0 -289
  377. package/packages/sdk/src/v2/gen/client.gen.ts +0 -18
  378. package/packages/sdk/src/v2/gen/core/auth.gen.ts +0 -41
  379. package/packages/sdk/src/v2/gen/core/bodySerializer.gen.ts +0 -82
  380. package/packages/sdk/src/v2/gen/core/params.gen.ts +0 -169
  381. package/packages/sdk/src/v2/gen/core/pathSerializer.gen.ts +0 -167
  382. package/packages/sdk/src/v2/gen/core/queryKeySerializer.gen.ts +0 -111
  383. package/packages/sdk/src/v2/gen/core/serverSentEvents.gen.ts +0 -239
  384. package/packages/sdk/src/v2/gen/core/types.gen.ts +0 -86
  385. package/packages/sdk/src/v2/gen/core/utils.gen.ts +0 -137
  386. package/packages/sdk/src/v2/gen/sdk.gen.ts +0 -4223
  387. package/packages/sdk/src/v2/gen/types.gen.ts +0 -5265
  388. package/packages/sdk/src/v2/index.ts +0 -21
  389. package/packages/sdk/src/v2/server.ts +0 -134
  390. package/packages/util/package.json +0 -20
  391. package/packages/util/src/array.ts +0 -10
  392. package/packages/util/src/binary.ts +0 -41
  393. package/packages/util/src/encode.ts +0 -51
  394. package/packages/util/src/error.ts +0 -54
  395. package/packages/util/src/fn.ts +0 -11
  396. package/packages/util/src/identifier.ts +0 -48
  397. package/packages/util/src/iife.ts +0 -3
  398. package/packages/util/src/lazy.ts +0 -11
  399. package/packages/util/src/module.ts +0 -10
  400. package/packages/util/src/path.ts +0 -37
  401. package/packages/util/src/retry.ts +0 -41
  402. package/packages/util/src/slug.ts +0 -74
  403. package/postinstall.cjs +0 -55
  404. /package/dist/{chunk-ANDTK76Q.js.map → chunk-GSE2T5UY.js.map} +0 -0
  405. /package/dist/{chunk-CYXMV3J3.js.map → chunk-LU5XVQUD.js.map} +0 -0
  406. /package/dist/{mcp-VAU4RMWH.js.map → chunk-PWFRMDDF.js.map} +0 -0
  407. /package/dist/{chunk-DSPC5QIG.js.map → chunk-SM6WZDN6.js.map} +0 -0
  408. /package/dist/{chunk-MCWTARFP.js.map → chunk-TASPMBUL.js.map} +0 -0
  409. /package/dist/{registry-PYMN6L3G.js.map → default-u_dwuiYb-WOFHQQ3K.js.map} +0 -0
  410. /package/dist/{server-K3UGWASP.js.map → mcp-XFGN3FWW.js.map} +0 -0
  411. /package/dist/{session-HJFWTM7C.js.map → registry-W4MBVBYD.js.map} +0 -0
  412. /package/dist/{share-next-55VCIMUH.js.map → server-2CPOG3LS.js.map} +0 -0
  413. /package/dist/{worktree-6GGDLADY.js.map → worktree-3GUHT2P7.js.map} +0 -0
@@ -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 multistep 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
-
@@ -1,112 +0,0 @@
1
- import z from "zod"
2
- import { Effect } from "effect"
3
- import type { MessageV2 } from "../session/message-v2"
4
- import type { Agent } from "../agent/agent"
5
- import type { Permission } from "../permission"
6
- import type { SessionID, MessageID } from "../session/schema"
7
- import { Truncate } from "./truncate"
8
-
9
- export namespace Tool {
10
- interface Metadata {
11
- [key: string]: any
12
- }
13
-
14
- export interface InitContext {
15
- agent?: Agent.Info
16
- }
17
-
18
- export type Context<M extends Metadata = Metadata> = {
19
- sessionID: SessionID
20
- messageID: MessageID
21
- agent: string
22
- abort: AbortSignal
23
- callID?: string
24
- extra?: { [key: string]: any }
25
- messages: MessageV2.WithParts[]
26
- metadata(input: { title?: string; metadata?: M }): void
27
- ask(input: Omit<Permission.Request, "id" | "sessionID" | "tool">): Promise<void>
28
- }
29
- export interface Def<Parameters extends z.ZodType = z.ZodType, M extends Metadata = Metadata> {
30
- description: string
31
- parameters: Parameters
32
- execute(
33
- args: z.infer<Parameters>,
34
- ctx: Context,
35
- ): Promise<{
36
- title: string
37
- metadata: M
38
- output: string
39
- attachments?: Omit<MessageV2.FilePart, "id" | "sessionID" | "messageID">[]
40
- }>
41
- formatValidationError?(error: z.ZodError): string
42
- }
43
-
44
- export interface Info<Parameters extends z.ZodType = z.ZodType, M extends Metadata = Metadata> {
45
- id: string
46
- init: (ctx?: InitContext) => Promise<Def<Parameters, M>>
47
- }
48
-
49
- export type InferParameters<T> =
50
- T extends Info<infer P, any>
51
- ? z.infer<P>
52
- : T extends Effect.Effect<Info<infer P, any>, any, any>
53
- ? z.infer<P>
54
- : never
55
- export type InferMetadata<T> =
56
- T extends Info<any, infer M> ? M : T extends Effect.Effect<Info<any, infer M>, any, any> ? M : never
57
-
58
- function wrap<Parameters extends z.ZodType, Result extends Metadata>(
59
- id: string,
60
- init: ((ctx?: InitContext) => Promise<Def<Parameters, Result>>) | Def<Parameters, Result>,
61
- ) {
62
- return async (initCtx?: InitContext) => {
63
- const toolInfo = init instanceof Function ? await init(initCtx) : { ...init }
64
- const execute = toolInfo.execute
65
- toolInfo.execute = async (args, ctx) => {
66
- try {
67
- toolInfo.parameters.parse(args)
68
- } catch (error) {
69
- if (error instanceof z.ZodError && toolInfo.formatValidationError) {
70
- throw new Error(toolInfo.formatValidationError(error), { cause: error })
71
- }
72
- throw new Error(
73
- `The ${id} tool was called with invalid arguments: ${error}.\nPlease rewrite the input so it satisfies the expected schema.`,
74
- { cause: error },
75
- )
76
- }
77
- const result = await execute(args, ctx)
78
- if (result.metadata.truncated !== undefined) {
79
- return result
80
- }
81
- const truncated = await Truncate.output(result.output, {}, initCtx?.agent)
82
- return {
83
- ...result,
84
- output: truncated.content,
85
- metadata: {
86
- ...result.metadata,
87
- truncated: truncated.truncated,
88
- ...(truncated.truncated && { outputPath: truncated.outputPath }),
89
- },
90
- }
91
- }
92
- return toolInfo
93
- }
94
- }
95
-
96
- export function define<Parameters extends z.ZodType, Result extends Metadata>(
97
- id: string,
98
- init: ((ctx?: InitContext) => Promise<Def<Parameters, Result>>) | Def<Parameters, Result>,
99
- ): Info<Parameters, Result> {
100
- return {
101
- id,
102
- init: wrap(id, init),
103
- }
104
- }
105
-
106
- export function defineEffect<Parameters extends z.ZodType, Result extends Metadata, R>(
107
- id: string,
108
- init: Effect.Effect<((ctx?: InitContext) => Promise<Def<Parameters, Result>>) | Def<Parameters, Result>, never, R>,
109
- ): Effect.Effect<Info<Parameters, Result>, never, R> {
110
- return Effect.map(init, (next) => ({ id, init: wrap(id, next) }))
111
- }
112
- }
@@ -1,144 +0,0 @@
1
- import { NodePath } from "@effect/platform-node"
2
- import { Cause, Duration, Effect, Layer, Schedule, ServiceMap } from "effect"
3
- import path from "path"
4
- import type { Agent } from "../agent/agent"
5
- import { makeRuntime } from "@/effect/run-service"
6
- import { AppFileSystem } from "@/filesystem"
7
- import { evaluate } from "@/permission/evaluate"
8
- import { Identifier } from "../id/id"
9
- import { Log } from "../util/log"
10
- import { ToolID } from "./schema"
11
- import { TRUNCATION_DIR } from "./truncation-dir"
12
-
13
- export namespace Truncate {
14
- const log = Log.create({ service: "truncation" })
15
- const RETENTION = Duration.days(7)
16
-
17
- export const MAX_LINES = 2000
18
- export const MAX_BYTES = 50 * 1024
19
- export const DIR = TRUNCATION_DIR
20
- export const GLOB = path.join(TRUNCATION_DIR, "*")
21
-
22
- export type Result = { content: string; truncated: false } | { content: string; truncated: true; outputPath: string }
23
-
24
- export interface Options {
25
- maxLines?: number
26
- maxBytes?: number
27
- direction?: "head" | "tail"
28
- }
29
-
30
- function hasTaskTool(agent?: Agent.Info) {
31
- if (!agent?.permission) return false
32
- return evaluate("task", "*", agent.permission).action !== "deny"
33
- }
34
-
35
- export interface Interface {
36
- readonly cleanup: () => Effect.Effect<void>
37
- /**
38
- * Returns output unchanged when it fits within the limits, otherwise writes the full text
39
- * to the truncation directory and returns a preview plus a hint to inspect the saved file.
40
- */
41
- readonly output: (text: string, options?: Options, agent?: Agent.Info) => Effect.Effect<Result>
42
- }
43
-
44
- export class Service extends ServiceMap.Service<Service, Interface>()("@opencode/Truncate") {}
45
-
46
- export const layer = Layer.effect(
47
- Service,
48
- Effect.gen(function* () {
49
- const fs = yield* AppFileSystem.Service
50
-
51
- const cleanup = Effect.fn("Truncate.cleanup")(function* () {
52
- const cutoff = Identifier.timestamp(Identifier.create("tool", false, Date.now() - Duration.toMillis(RETENTION)))
53
- const entries = yield* fs.readDirectory(TRUNCATION_DIR).pipe(
54
- Effect.map((all) => all.filter((name) => name.startsWith("tool_"))),
55
- Effect.catch(() => Effect.succeed([])),
56
- )
57
- for (const entry of entries) {
58
- if (Identifier.timestamp(entry) >= cutoff) continue
59
- yield* fs.remove(path.join(TRUNCATION_DIR, entry)).pipe(Effect.catch(() => Effect.void))
60
- }
61
- })
62
-
63
- const output = Effect.fn("Truncate.output")(function* (text: string, options: Options = {}, agent?: Agent.Info) {
64
- const maxLines = options.maxLines ?? MAX_LINES
65
- const maxBytes = options.maxBytes ?? MAX_BYTES
66
- const direction = options.direction ?? "head"
67
- const lines = text.split("\n")
68
- const totalBytes = Buffer.byteLength(text, "utf-8")
69
-
70
- if (lines.length <= maxLines && totalBytes <= maxBytes) {
71
- return { content: text, truncated: false } as const
72
- }
73
-
74
- const out: string[] = []
75
- let i = 0
76
- let bytes = 0
77
- let hitBytes = false
78
-
79
- if (direction === "head") {
80
- for (i = 0; i < lines.length && i < maxLines; i++) {
81
- const size = Buffer.byteLength(lines[i], "utf-8") + (i > 0 ? 1 : 0)
82
- if (bytes + size > maxBytes) {
83
- hitBytes = true
84
- break
85
- }
86
- out.push(lines[i])
87
- bytes += size
88
- }
89
- } else {
90
- for (i = lines.length - 1; i >= 0 && out.length < maxLines; i--) {
91
- const size = Buffer.byteLength(lines[i], "utf-8") + (out.length > 0 ? 1 : 0)
92
- if (bytes + size > maxBytes) {
93
- hitBytes = true
94
- break
95
- }
96
- out.unshift(lines[i])
97
- bytes += size
98
- }
99
- }
100
-
101
- const removed = hitBytes ? totalBytes - bytes : lines.length - out.length
102
- const unit = hitBytes ? "bytes" : "lines"
103
- const preview = out.join("\n")
104
- const file = path.join(TRUNCATION_DIR, ToolID.ascending())
105
-
106
- yield* fs.ensureDir(TRUNCATION_DIR).pipe(Effect.orDie)
107
- yield* fs.writeFileString(file, text).pipe(Effect.orDie)
108
-
109
- const hint = hasTaskTool(agent)
110
- ? `The tool call succeeded but the output was truncated. Full output saved to: ${file}\nUse the Task tool to have explore agent process this file with Grep and Read (with offset/limit). Do NOT read the full file yourself - delegate to save context.`
111
- : `The tool call succeeded but the output was truncated. Full output saved to: ${file}\nUse Grep to search the full content or Read with offset/limit to view specific sections.`
112
-
113
- return {
114
- content:
115
- direction === "head"
116
- ? `${preview}\n\n...${removed} ${unit} truncated...\n\n${hint}`
117
- : `...${removed} ${unit} truncated...\n\n${hint}\n\n${preview}`,
118
- truncated: true,
119
- outputPath: file,
120
- } as const
121
- })
122
-
123
- yield* cleanup().pipe(
124
- Effect.catchCause((cause) => {
125
- log.error("truncation cleanup failed", { cause: Cause.pretty(cause) })
126
- return Effect.void
127
- }),
128
- Effect.repeat(Schedule.spaced(Duration.hours(1))),
129
- Effect.delay(Duration.minutes(1)),
130
- Effect.forkScoped,
131
- )
132
-
133
- return Service.of({ cleanup, output })
134
- }),
135
- )
136
-
137
- export const defaultLayer = layer.pipe(Layer.provide(AppFileSystem.defaultLayer), Layer.provide(NodePath.layer))
138
-
139
- const { runPromise } = makeRuntime(Service, defaultLayer)
140
-
141
- export async function output(text: string, options: Options = {}, agent?: Agent.Info): Promise<Result> {
142
- return runPromise((s) => s.output(text, options, agent))
143
- }
144
- }
@@ -1,4 +0,0 @@
1
- import path from "path"
2
- import { Global } from "../global"
3
-
4
- export const TRUNCATION_DIR = path.join(Global.Path.data, "tool-output")
@@ -1,206 +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 { abortAfterAny } from "../util/abort"
6
-
7
- const MAX_RESPONSE_SIZE = 5 * 1024 * 1024 // 5MB
8
- const DEFAULT_TIMEOUT = 30 * 1000 // 30 seconds
9
- const MAX_TIMEOUT = 120 * 1000 // 2 minutes
10
-
11
- export const WebFetchTool = Tool.define("webfetch", {
12
- description: DESCRIPTION,
13
- parameters: z.object({
14
- url: z.string().describe("The URL to fetch content from"),
15
- format: z
16
- .enum(["text", "markdown", "html"])
17
- .default("markdown")
18
- .describe("The format to return the content in (text, markdown, or html). Defaults to markdown."),
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
- await ctx.ask({
28
- permission: "webfetch",
29
- patterns: [params.url],
30
- always: ["*"],
31
- metadata: {
32
- url: params.url,
33
- format: params.format,
34
- timeout: params.timeout,
35
- },
36
- })
37
-
38
- const timeout = Math.min((params.timeout ?? DEFAULT_TIMEOUT / 1000) * 1000, MAX_TIMEOUT)
39
-
40
- const { signal, clearTimeout } = abortAfterAny(timeout, ctx.abort)
41
-
42
- // Build Accept header based on requested format with q parameters for fallbacks
43
- let acceptHeader = "*/*"
44
- switch (params.format) {
45
- case "markdown":
46
- 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"
47
- break
48
- case "text":
49
- acceptHeader = "text/plain;q=1.0, text/markdown;q=0.9, text/html;q=0.8, */*;q=0.1"
50
- break
51
- case "html":
52
- 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"
53
- break
54
- default:
55
- acceptHeader =
56
- "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8"
57
- }
58
- const headers = {
59
- "User-Agent":
60
- "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36",
61
- Accept: acceptHeader,
62
- "Accept-Language": "en-US,en;q=0.9",
63
- }
64
-
65
- const initial = await fetch(params.url, { signal, headers })
66
-
67
- // Retry with honest UA if blocked by Cloudflare bot detection (TLS fingerprint mismatch)
68
- const response =
69
- initial.status === 403 && initial.headers.get("cf-mitigated") === "challenge"
70
- ? await fetch(params.url, { signal, headers: { ...headers, "User-Agent": "opencode" } })
71
- : initial
72
-
73
- clearTimeout()
74
-
75
- if (!response.ok) {
76
- throw new Error(`Request failed with status code: ${response.status}`)
77
- }
78
-
79
- // Check content length
80
- const contentLength = response.headers.get("content-length")
81
- if (contentLength && parseInt(contentLength) > MAX_RESPONSE_SIZE) {
82
- throw new Error("Response too large (exceeds 5MB limit)")
83
- }
84
-
85
- const arrayBuffer = await response.arrayBuffer()
86
- if (arrayBuffer.byteLength > MAX_RESPONSE_SIZE) {
87
- throw new Error("Response too large (exceeds 5MB limit)")
88
- }
89
-
90
- const contentType = response.headers.get("content-type") || ""
91
- const mime = contentType.split(";")[0]?.trim().toLowerCase() || ""
92
- const title = `${params.url} (${contentType})`
93
-
94
- // Check if response is an image
95
- const isImage = mime.startsWith("image/") && mime !== "image/svg+xml" && mime !== "image/vnd.fastbidsheet"
96
-
97
- if (isImage) {
98
- const base64Content = Buffer.from(arrayBuffer).toString("base64")
99
- return {
100
- title,
101
- output: "Image fetched successfully",
102
- metadata: {},
103
- attachments: [
104
- {
105
- type: "file",
106
- mime,
107
- url: `data:${mime};base64,${base64Content}`,
108
- },
109
- ],
110
- }
111
- }
112
-
113
- const content = new TextDecoder().decode(arrayBuffer)
114
-
115
- // Handle content based on requested format and actual content type
116
- switch (params.format) {
117
- case "markdown":
118
- if (contentType.includes("text/html")) {
119
- const markdown = convertHTMLToMarkdown(content)
120
- return {
121
- output: markdown,
122
- title,
123
- metadata: {},
124
- }
125
- }
126
- return {
127
- output: content,
128
- title,
129
- metadata: {},
130
- }
131
-
132
- case "text":
133
- if (contentType.includes("text/html")) {
134
- const text = await extractTextFromHTML(content)
135
- return {
136
- output: text,
137
- title,
138
- metadata: {},
139
- }
140
- }
141
- return {
142
- output: content,
143
- title,
144
- metadata: {},
145
- }
146
-
147
- case "html":
148
- return {
149
- output: content,
150
- title,
151
- metadata: {},
152
- }
153
-
154
- default:
155
- return {
156
- output: content,
157
- title,
158
- metadata: {},
159
- }
160
- }
161
- },
162
- })
163
-
164
- async function extractTextFromHTML(html: string) {
165
- let text = ""
166
- let skipContent = false
167
-
168
- const rewriter = new HTMLRewriter()
169
- .on("script, style, noscript, iframe, object, embed", {
170
- element() {
171
- skipContent = true
172
- },
173
- text() {
174
- // Skip text content inside these elements
175
- },
176
- })
177
- .on("*", {
178
- element(element) {
179
- // Reset skip flag when entering other elements
180
- if (!["script", "style", "noscript", "iframe", "object", "embed"].includes(element.tagName)) {
181
- skipContent = false
182
- }
183
- },
184
- text(input) {
185
- if (!skipContent) {
186
- text += input.text
187
- }
188
- },
189
- })
190
- .transform(new Response(html))
191
-
192
- await rewriter.text()
193
- return text.trim()
194
- }
195
-
196
- function convertHTMLToMarkdown(html: string): string {
197
- const turndownService = new TurndownService({
198
- headingStyle: "atx",
199
- hr: "---",
200
- bulletListMarker: "-",
201
- codeBlockStyle: "fenced",
202
- emDelimiter: "*",
203
- })
204
- turndownService.remove(["script", "style", "meta", "link"])
205
- return turndownService.turndown(html)
206
- }
@@ -1,13 +0,0 @@
1
- - Fetches content from a specified URL
2
- - Takes a URL and optional format as input
3
- - Fetches the URL content, converts to requested format (markdown by default)
4
- - Returns the content in the specified format
5
- - Use this tool when you need to retrieve and analyze web content
6
-
7
- Usage notes:
8
- - IMPORTANT: if another tool is present that offers better web fetching capabilities, is more targeted to the task, or has fewer restrictions, prefer using that tool instead of this one.
9
- - The URL must be a fully-formed valid URL
10
- - HTTP URLs will be automatically upgraded to HTTPS
11
- - Format options: "markdown" (default), "text", or "html"
12
- - This tool is read-only and does not modify any files
13
- - Results may be summarized if the content is very large