alchemylab-opencode 1.0.7 → 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 (358) hide show
  1. package/package.json +2 -15
  2. package/build.mjs +0 -192
  3. package/packages/opencode/package.json +0 -138
  4. package/packages/opencode/src/account/account.sql.ts +0 -39
  5. package/packages/opencode/src/account/index.ts +0 -463
  6. package/packages/opencode/src/account/repo.ts +0 -163
  7. package/packages/opencode/src/account/schema.ts +0 -91
  8. package/packages/opencode/src/acp/README.md +0 -174
  9. package/packages/opencode/src/acp/agent.ts +0 -1847
  10. package/packages/opencode/src/acp/session.ts +0 -116
  11. package/packages/opencode/src/acp/types.ts +0 -24
  12. package/packages/opencode/src/agent/agent.ts +0 -420
  13. package/packages/opencode/src/agent/generate.txt +0 -75
  14. package/packages/opencode/src/agent/prompt/compaction.txt +0 -15
  15. package/packages/opencode/src/agent/prompt/explore.txt +0 -18
  16. package/packages/opencode/src/agent/prompt/summary.txt +0 -11
  17. package/packages/opencode/src/agent/prompt/title.txt +0 -44
  18. package/packages/opencode/src/auth/index.ts +0 -110
  19. package/packages/opencode/src/bus/bus-event.ts +0 -40
  20. package/packages/opencode/src/bus/global.ts +0 -10
  21. package/packages/opencode/src/bus/index.ts +0 -185
  22. package/packages/opencode/src/cli/bootstrap.ts +0 -17
  23. package/packages/opencode/src/cli/cmd/cmd.ts +0 -7
  24. package/packages/opencode/src/cli/cmd/run.ts +0 -689
  25. package/packages/opencode/src/cli/cmd/serve.ts +0 -24
  26. package/packages/opencode/src/cli/cmd/tui/event.ts +0 -49
  27. package/packages/opencode/src/cli/effect/prompt.ts +0 -25
  28. package/packages/opencode/src/cli/error.ts +0 -46
  29. package/packages/opencode/src/cli/heap.ts +0 -59
  30. package/packages/opencode/src/cli/logo.ts +0 -6
  31. package/packages/opencode/src/cli/network.ts +0 -60
  32. package/packages/opencode/src/cli/ui.ts +0 -133
  33. package/packages/opencode/src/cli/upgrade.ts +0 -31
  34. package/packages/opencode/src/command/index.ts +0 -195
  35. package/packages/opencode/src/command/template/initialize.txt +0 -66
  36. package/packages/opencode/src/command/template/review.txt +0 -101
  37. package/packages/opencode/src/config/config.ts +0 -1599
  38. package/packages/opencode/src/config/console-state.ts +0 -15
  39. package/packages/opencode/src/config/markdown.ts +0 -99
  40. package/packages/opencode/src/config/paths.ts +0 -167
  41. package/packages/opencode/src/config/tui-migrate.ts +0 -155
  42. package/packages/opencode/src/config/tui-schema.ts +0 -37
  43. package/packages/opencode/src/config/tui.ts +0 -179
  44. package/packages/opencode/src/control-plane/adaptors/index.ts +0 -20
  45. package/packages/opencode/src/control-plane/adaptors/worktree.ts +0 -42
  46. package/packages/opencode/src/control-plane/schema.ts +0 -17
  47. package/packages/opencode/src/control-plane/sse.ts +0 -66
  48. package/packages/opencode/src/control-plane/types.ts +0 -32
  49. package/packages/opencode/src/control-plane/workspace.sql.ts +0 -17
  50. package/packages/opencode/src/control-plane/workspace.ts +0 -168
  51. package/packages/opencode/src/effect/cross-spawn-spawner.ts +0 -502
  52. package/packages/opencode/src/effect/instance-ref.ts +0 -6
  53. package/packages/opencode/src/effect/instance-registry.ts +0 -12
  54. package/packages/opencode/src/effect/instance-state.ts +0 -82
  55. package/packages/opencode/src/effect/run-service.ts +0 -33
  56. package/packages/opencode/src/effect/runner.ts +0 -216
  57. package/packages/opencode/src/env/index.ts +0 -28
  58. package/packages/opencode/src/file/ignore.ts +0 -82
  59. package/packages/opencode/src/file/index.ts +0 -686
  60. package/packages/opencode/src/file/protected.ts +0 -59
  61. package/packages/opencode/src/file/ripgrep.ts +0 -376
  62. package/packages/opencode/src/file/time.ts +0 -133
  63. package/packages/opencode/src/file/watcher.ts +0 -173
  64. package/packages/opencode/src/filesystem/index.ts +0 -236
  65. package/packages/opencode/src/flag/flag.ts +0 -156
  66. package/packages/opencode/src/format/formatter.ts +0 -413
  67. package/packages/opencode/src/format/index.ts +0 -203
  68. package/packages/opencode/src/git/index.ts +0 -303
  69. package/packages/opencode/src/global/index.ts +0 -56
  70. package/packages/opencode/src/id/id.ts +0 -85
  71. package/packages/opencode/src/ide/index.ts +0 -74
  72. package/packages/opencode/src/installation/index.ts +0 -355
  73. package/packages/opencode/src/installation/meta.ts +0 -7
  74. package/packages/opencode/src/lsp/client.ts +0 -252
  75. package/packages/opencode/src/lsp/index.ts +0 -558
  76. package/packages/opencode/src/lsp/language.ts +0 -120
  77. package/packages/opencode/src/lsp/launch.ts +0 -21
  78. package/packages/opencode/src/lsp/server.ts +0 -1968
  79. package/packages/opencode/src/mcp/auth.ts +0 -173
  80. package/packages/opencode/src/mcp/index.ts +0 -931
  81. package/packages/opencode/src/mcp/oauth-callback.ts +0 -216
  82. package/packages/opencode/src/mcp/oauth-provider.ts +0 -185
  83. package/packages/opencode/src/node-loader.mjs +0 -104
  84. package/packages/opencode/src/node-preload.mjs +0 -39
  85. package/packages/opencode/src/node.ts +0 -1
  86. package/packages/opencode/src/npm/index.ts +0 -188
  87. package/packages/opencode/src/patch/index.ts +0 -680
  88. package/packages/opencode/src/permission/arity.ts +0 -163
  89. package/packages/opencode/src/permission/evaluate.ts +0 -15
  90. package/packages/opencode/src/permission/index.ts +0 -325
  91. package/packages/opencode/src/permission/schema.ts +0 -17
  92. package/packages/opencode/src/plugin/cloudflare.ts +0 -67
  93. package/packages/opencode/src/plugin/codex.ts +0 -608
  94. package/packages/opencode/src/plugin/github-copilot/copilot.ts +0 -361
  95. package/packages/opencode/src/plugin/github-copilot/models.ts +0 -144
  96. package/packages/opencode/src/plugin/index.ts +0 -299
  97. package/packages/opencode/src/plugin/install.ts +0 -439
  98. package/packages/opencode/src/plugin/loader.ts +0 -174
  99. package/packages/opencode/src/plugin/meta.ts +0 -188
  100. package/packages/opencode/src/plugin/shared.ts +0 -323
  101. package/packages/opencode/src/project/bootstrap.ts +0 -31
  102. package/packages/opencode/src/project/instance.ts +0 -175
  103. package/packages/opencode/src/project/project.sql.ts +0 -16
  104. package/packages/opencode/src/project/project.ts +0 -519
  105. package/packages/opencode/src/project/schema.ts +0 -16
  106. package/packages/opencode/src/project/state.ts +0 -70
  107. package/packages/opencode/src/project/vcs.ts +0 -240
  108. package/packages/opencode/src/provider/auth.ts +0 -253
  109. package/packages/opencode/src/provider/error.ts +0 -197
  110. package/packages/opencode/src/provider/models.ts +0 -162
  111. package/packages/opencode/src/provider/provider.ts +0 -1709
  112. package/packages/opencode/src/provider/schema.ts +0 -38
  113. package/packages/opencode/src/provider/sdk/copilot/README.md +0 -5
  114. package/packages/opencode/src/provider/sdk/copilot/chat/convert-to-openai-compatible-chat-messages.ts +0 -170
  115. package/packages/opencode/src/provider/sdk/copilot/chat/get-response-metadata.ts +0 -15
  116. package/packages/opencode/src/provider/sdk/copilot/chat/map-openai-compatible-finish-reason.ts +0 -19
  117. package/packages/opencode/src/provider/sdk/copilot/chat/openai-compatible-api-types.ts +0 -64
  118. package/packages/opencode/src/provider/sdk/copilot/chat/openai-compatible-chat-language-model.ts +0 -815
  119. package/packages/opencode/src/provider/sdk/copilot/chat/openai-compatible-chat-options.ts +0 -28
  120. package/packages/opencode/src/provider/sdk/copilot/chat/openai-compatible-metadata-extractor.ts +0 -44
  121. package/packages/opencode/src/provider/sdk/copilot/chat/openai-compatible-prepare-tools.ts +0 -83
  122. package/packages/opencode/src/provider/sdk/copilot/copilot-provider.ts +0 -100
  123. package/packages/opencode/src/provider/sdk/copilot/index.ts +0 -2
  124. package/packages/opencode/src/provider/sdk/copilot/openai-compatible-error.ts +0 -27
  125. package/packages/opencode/src/provider/sdk/copilot/responses/convert-to-openai-responses-input.ts +0 -335
  126. package/packages/opencode/src/provider/sdk/copilot/responses/map-openai-responses-finish-reason.ts +0 -22
  127. package/packages/opencode/src/provider/sdk/copilot/responses/openai-config.ts +0 -18
  128. package/packages/opencode/src/provider/sdk/copilot/responses/openai-error.ts +0 -22
  129. package/packages/opencode/src/provider/sdk/copilot/responses/openai-responses-api-types.ts +0 -214
  130. package/packages/opencode/src/provider/sdk/copilot/responses/openai-responses-language-model.ts +0 -1769
  131. package/packages/opencode/src/provider/sdk/copilot/responses/openai-responses-prepare-tools.ts +0 -173
  132. package/packages/opencode/src/provider/sdk/copilot/responses/openai-responses-settings.ts +0 -1
  133. package/packages/opencode/src/provider/sdk/copilot/responses/tool/code-interpreter.ts +0 -87
  134. package/packages/opencode/src/provider/sdk/copilot/responses/tool/file-search.ts +0 -127
  135. package/packages/opencode/src/provider/sdk/copilot/responses/tool/image-generation.ts +0 -114
  136. package/packages/opencode/src/provider/sdk/copilot/responses/tool/local-shell.ts +0 -64
  137. package/packages/opencode/src/provider/sdk/copilot/responses/tool/web-search-preview.ts +0 -103
  138. package/packages/opencode/src/provider/sdk/copilot/responses/tool/web-search.ts +0 -102
  139. package/packages/opencode/src/provider/transform.ts +0 -1050
  140. package/packages/opencode/src/pty/index.ts +0 -397
  141. package/packages/opencode/src/pty/pty.node.ts +0 -27
  142. package/packages/opencode/src/pty/pty.ts +0 -25
  143. package/packages/opencode/src/pty/schema.ts +0 -17
  144. package/packages/opencode/src/question/index.ts +0 -224
  145. package/packages/opencode/src/question/schema.ts +0 -17
  146. package/packages/opencode/src/run.ts +0 -28
  147. package/packages/opencode/src/serve.ts +0 -45
  148. package/packages/opencode/src/server/error.ts +0 -36
  149. package/packages/opencode/src/server/event.ts +0 -7
  150. package/packages/opencode/src/server/instance.ts +0 -324
  151. package/packages/opencode/src/server/mdns.ts +0 -60
  152. package/packages/opencode/src/server/middleware.ts +0 -33
  153. package/packages/opencode/src/server/projectors.ts +0 -28
  154. package/packages/opencode/src/server/proxy.ts +0 -131
  155. package/packages/opencode/src/server/router.ts +0 -105
  156. package/packages/opencode/src/server/routes/config.ts +0 -92
  157. package/packages/opencode/src/server/routes/event.ts +0 -83
  158. package/packages/opencode/src/server/routes/experimental.ts +0 -374
  159. package/packages/opencode/src/server/routes/file.ts +0 -197
  160. package/packages/opencode/src/server/routes/global.ts +0 -312
  161. package/packages/opencode/src/server/routes/mcp.ts +0 -225
  162. package/packages/opencode/src/server/routes/permission.ts +0 -69
  163. package/packages/opencode/src/server/routes/project.ts +0 -118
  164. package/packages/opencode/src/server/routes/provider.ts +0 -171
  165. package/packages/opencode/src/server/routes/pty.ts +0 -210
  166. package/packages/opencode/src/server/routes/question.ts +0 -99
  167. package/packages/opencode/src/server/routes/session.ts +0 -1030
  168. package/packages/opencode/src/server/routes/tui.ts +0 -379
  169. package/packages/opencode/src/server/routes/workspace.ts +0 -94
  170. package/packages/opencode/src/server/server.ts +0 -353
  171. package/packages/opencode/src/session/compaction.ts +0 -428
  172. package/packages/opencode/src/session/index.ts +0 -887
  173. package/packages/opencode/src/session/instruction.ts +0 -258
  174. package/packages/opencode/src/session/llm.ts +0 -354
  175. package/packages/opencode/src/session/message-v2.ts +0 -1031
  176. package/packages/opencode/src/session/message.ts +0 -191
  177. package/packages/opencode/src/session/overflow.ts +0 -22
  178. package/packages/opencode/src/session/processor.ts +0 -523
  179. package/packages/opencode/src/session/projectors.ts +0 -135
  180. package/packages/opencode/src/session/prompt/anthropic.txt +0 -105
  181. package/packages/opencode/src/session/prompt/beast.txt +0 -147
  182. package/packages/opencode/src/session/prompt/build-switch.txt +0 -5
  183. package/packages/opencode/src/session/prompt/codex.txt +0 -79
  184. package/packages/opencode/src/session/prompt/copilot-gpt-5.txt +0 -143
  185. package/packages/opencode/src/session/prompt/default.txt +0 -105
  186. package/packages/opencode/src/session/prompt/gemini.txt +0 -155
  187. package/packages/opencode/src/session/prompt/gpt.txt +0 -107
  188. package/packages/opencode/src/session/prompt/kimi.txt +0 -95
  189. package/packages/opencode/src/session/prompt/max-steps.txt +0 -16
  190. package/packages/opencode/src/session/prompt/plan-reminder-anthropic.txt +0 -67
  191. package/packages/opencode/src/session/prompt/plan.txt +0 -26
  192. package/packages/opencode/src/session/prompt/trinity.txt +0 -97
  193. package/packages/opencode/src/session/prompt.ts +0 -1911
  194. package/packages/opencode/src/session/retry.ts +0 -106
  195. package/packages/opencode/src/session/revert.ts +0 -176
  196. package/packages/opencode/src/session/schema.ts +0 -38
  197. package/packages/opencode/src/session/session.sql.ts +0 -103
  198. package/packages/opencode/src/session/status.ts +0 -102
  199. package/packages/opencode/src/session/summary.ts +0 -177
  200. package/packages/opencode/src/session/system.ts +0 -76
  201. package/packages/opencode/src/session/todo.ts +0 -95
  202. package/packages/opencode/src/share/share-next.ts +0 -369
  203. package/packages/opencode/src/share/share.sql.ts +0 -13
  204. package/packages/opencode/src/shell/shell.ts +0 -110
  205. package/packages/opencode/src/skill/discovery.ts +0 -116
  206. package/packages/opencode/src/skill/index.ts +0 -277
  207. package/packages/opencode/src/snapshot/index.ts +0 -726
  208. package/packages/opencode/src/sql.d.ts +0 -4
  209. package/packages/opencode/src/storage/db.node.ts +0 -8
  210. package/packages/opencode/src/storage/db.ts +0 -177
  211. package/packages/opencode/src/storage/json-migration.ts +0 -425
  212. package/packages/opencode/src/storage/schema.sql.ts +0 -10
  213. package/packages/opencode/src/storage/schema.ts +0 -5
  214. package/packages/opencode/src/storage/storage.ts +0 -353
  215. package/packages/opencode/src/sync/README.md +0 -179
  216. package/packages/opencode/src/sync/event.sql.ts +0 -16
  217. package/packages/opencode/src/sync/index.ts +0 -263
  218. package/packages/opencode/src/sync/schema.ts +0 -14
  219. package/packages/opencode/src/tool/apply_patch.ts +0 -281
  220. package/packages/opencode/src/tool/apply_patch.txt +0 -33
  221. package/packages/opencode/src/tool/bash.ts +0 -496
  222. package/packages/opencode/src/tool/bash.txt +0 -117
  223. package/packages/opencode/src/tool/batch.ts +0 -183
  224. package/packages/opencode/src/tool/batch.txt +0 -24
  225. package/packages/opencode/src/tool/codesearch.ts +0 -132
  226. package/packages/opencode/src/tool/codesearch.txt +0 -12
  227. package/packages/opencode/src/tool/edit.ts +0 -667
  228. package/packages/opencode/src/tool/edit.txt +0 -10
  229. package/packages/opencode/src/tool/external-directory.ts +0 -46
  230. package/packages/opencode/src/tool/glob.ts +0 -78
  231. package/packages/opencode/src/tool/glob.txt +0 -6
  232. package/packages/opencode/src/tool/grep.ts +0 -156
  233. package/packages/opencode/src/tool/grep.txt +0 -8
  234. package/packages/opencode/src/tool/invalid.ts +0 -17
  235. package/packages/opencode/src/tool/ls.ts +0 -121
  236. package/packages/opencode/src/tool/ls.txt +0 -1
  237. package/packages/opencode/src/tool/lsp.ts +0 -97
  238. package/packages/opencode/src/tool/lsp.txt +0 -19
  239. package/packages/opencode/src/tool/multiedit.ts +0 -46
  240. package/packages/opencode/src/tool/multiedit.txt +0 -41
  241. package/packages/opencode/src/tool/plan-enter.txt +0 -14
  242. package/packages/opencode/src/tool/plan-exit.txt +0 -13
  243. package/packages/opencode/src/tool/plan.ts +0 -131
  244. package/packages/opencode/src/tool/question.ts +0 -46
  245. package/packages/opencode/src/tool/question.txt +0 -10
  246. package/packages/opencode/src/tool/read.ts +0 -332
  247. package/packages/opencode/src/tool/read.txt +0 -14
  248. package/packages/opencode/src/tool/registry.ts +0 -265
  249. package/packages/opencode/src/tool/schema.ts +0 -17
  250. package/packages/opencode/src/tool/skill.ts +0 -105
  251. package/packages/opencode/src/tool/task.ts +0 -166
  252. package/packages/opencode/src/tool/task.txt +0 -60
  253. package/packages/opencode/src/tool/todo.ts +0 -48
  254. package/packages/opencode/src/tool/todowrite.txt +0 -167
  255. package/packages/opencode/src/tool/tool.ts +0 -112
  256. package/packages/opencode/src/tool/truncate.ts +0 -144
  257. package/packages/opencode/src/tool/truncation-dir.ts +0 -4
  258. package/packages/opencode/src/tool/webfetch.ts +0 -206
  259. package/packages/opencode/src/tool/webfetch.txt +0 -13
  260. package/packages/opencode/src/tool/websearch.ts +0 -150
  261. package/packages/opencode/src/tool/websearch.txt +0 -14
  262. package/packages/opencode/src/tool/write.ts +0 -84
  263. package/packages/opencode/src/tool/write.txt +0 -8
  264. package/packages/opencode/src/util/abort.ts +0 -35
  265. package/packages/opencode/src/util/archive.ts +0 -17
  266. package/packages/opencode/src/util/color.ts +0 -19
  267. package/packages/opencode/src/util/context.ts +0 -25
  268. package/packages/opencode/src/util/data-url.ts +0 -9
  269. package/packages/opencode/src/util/defer.ts +0 -12
  270. package/packages/opencode/src/util/effect-http-client.ts +0 -11
  271. package/packages/opencode/src/util/effect-zod.ts +0 -98
  272. package/packages/opencode/src/util/error.ts +0 -77
  273. package/packages/opencode/src/util/filesystem.ts +0 -245
  274. package/packages/opencode/src/util/flock.ts +0 -333
  275. package/packages/opencode/src/util/fn.ts +0 -21
  276. package/packages/opencode/src/util/format.ts +0 -20
  277. package/packages/opencode/src/util/glob.ts +0 -34
  278. package/packages/opencode/src/util/hash.ts +0 -7
  279. package/packages/opencode/src/util/iife.ts +0 -3
  280. package/packages/opencode/src/util/keybind.ts +0 -103
  281. package/packages/opencode/src/util/lazy.ts +0 -23
  282. package/packages/opencode/src/util/locale.ts +0 -81
  283. package/packages/opencode/src/util/lock.ts +0 -98
  284. package/packages/opencode/src/util/log.ts +0 -182
  285. package/packages/opencode/src/util/network.ts +0 -9
  286. package/packages/opencode/src/util/process.ts +0 -176
  287. package/packages/opencode/src/util/queue.ts +0 -32
  288. package/packages/opencode/src/util/record.ts +0 -3
  289. package/packages/opencode/src/util/rpc.ts +0 -66
  290. package/packages/opencode/src/util/schema.ts +0 -53
  291. package/packages/opencode/src/util/scrap.ts +0 -10
  292. package/packages/opencode/src/util/signal.ts +0 -12
  293. package/packages/opencode/src/util/timeout.ts +0 -14
  294. package/packages/opencode/src/util/token.ts +0 -7
  295. package/packages/opencode/src/util/update-schema.ts +0 -13
  296. package/packages/opencode/src/util/which.ts +0 -14
  297. package/packages/opencode/src/util/wildcard.ts +0 -59
  298. package/packages/opencode/src/worktree/index.ts +0 -612
  299. package/packages/plugin/package.json +0 -38
  300. package/packages/plugin/src/example.ts +0 -18
  301. package/packages/plugin/src/index.ts +0 -282
  302. package/packages/plugin/src/shell.ts +0 -136
  303. package/packages/plugin/src/tool.ts +0 -38
  304. package/packages/plugin/src/tui.ts +0 -508
  305. package/packages/script/package.json +0 -16
  306. package/packages/script/src/index.ts +0 -77
  307. package/packages/sdk/package.json +0 -33
  308. package/packages/sdk/src/client.ts +0 -55
  309. package/packages/sdk/src/gen/client/client.gen.ts +0 -212
  310. package/packages/sdk/src/gen/client/index.ts +0 -25
  311. package/packages/sdk/src/gen/client/types.gen.ts +0 -222
  312. package/packages/sdk/src/gen/client/utils.gen.ts +0 -287
  313. package/packages/sdk/src/gen/client.gen.ts +0 -22
  314. package/packages/sdk/src/gen/core/auth.gen.ts +0 -41
  315. package/packages/sdk/src/gen/core/bodySerializer.gen.ts +0 -74
  316. package/packages/sdk/src/gen/core/params.gen.ts +0 -144
  317. package/packages/sdk/src/gen/core/pathSerializer.gen.ts +0 -167
  318. package/packages/sdk/src/gen/core/queryKeySerializer.gen.ts +0 -111
  319. package/packages/sdk/src/gen/core/serverSentEvents.gen.ts +0 -210
  320. package/packages/sdk/src/gen/core/types.gen.ts +0 -91
  321. package/packages/sdk/src/gen/core/utils.gen.ts +0 -109
  322. package/packages/sdk/src/gen/sdk.gen.ts +0 -1197
  323. package/packages/sdk/src/gen/types.gen.ts +0 -3904
  324. package/packages/sdk/src/index.ts +0 -21
  325. package/packages/sdk/src/process.ts +0 -31
  326. package/packages/sdk/src/server.ts +0 -134
  327. package/packages/sdk/src/v2/client.ts +0 -81
  328. package/packages/sdk/src/v2/gen/client/client.gen.ts +0 -285
  329. package/packages/sdk/src/v2/gen/client/index.ts +0 -25
  330. package/packages/sdk/src/v2/gen/client/types.gen.ts +0 -202
  331. package/packages/sdk/src/v2/gen/client/utils.gen.ts +0 -289
  332. package/packages/sdk/src/v2/gen/client.gen.ts +0 -18
  333. package/packages/sdk/src/v2/gen/core/auth.gen.ts +0 -41
  334. package/packages/sdk/src/v2/gen/core/bodySerializer.gen.ts +0 -82
  335. package/packages/sdk/src/v2/gen/core/params.gen.ts +0 -169
  336. package/packages/sdk/src/v2/gen/core/pathSerializer.gen.ts +0 -167
  337. package/packages/sdk/src/v2/gen/core/queryKeySerializer.gen.ts +0 -111
  338. package/packages/sdk/src/v2/gen/core/serverSentEvents.gen.ts +0 -239
  339. package/packages/sdk/src/v2/gen/core/types.gen.ts +0 -86
  340. package/packages/sdk/src/v2/gen/core/utils.gen.ts +0 -137
  341. package/packages/sdk/src/v2/gen/sdk.gen.ts +0 -4223
  342. package/packages/sdk/src/v2/gen/types.gen.ts +0 -5265
  343. package/packages/sdk/src/v2/index.ts +0 -21
  344. package/packages/sdk/src/v2/server.ts +0 -134
  345. package/packages/util/package.json +0 -20
  346. package/packages/util/src/array.ts +0 -10
  347. package/packages/util/src/binary.ts +0 -41
  348. package/packages/util/src/encode.ts +0 -51
  349. package/packages/util/src/error.ts +0 -54
  350. package/packages/util/src/fn.ts +0 -11
  351. package/packages/util/src/identifier.ts +0 -48
  352. package/packages/util/src/iife.ts +0 -3
  353. package/packages/util/src/lazy.ts +0 -11
  354. package/packages/util/src/module.ts +0 -10
  355. package/packages/util/src/path.ts +0 -37
  356. package/packages/util/src/retry.ts +0 -41
  357. package/packages/util/src/slug.ts +0 -74
  358. package/postinstall.cjs +0 -55
@@ -1,353 +0,0 @@
1
- import { Log } from "../util/log"
2
- import path from "path"
3
- import { Global } from "../global"
4
- import { NamedError } from "@opencode-ai/util/error"
5
- import z from "zod"
6
- import { AppFileSystem } from "@/filesystem"
7
- import { makeRuntime } from "@/effect/run-service"
8
- import { Effect, Exit, Layer, Option, RcMap, Schema, ServiceMap, TxReentrantLock } from "effect"
9
- import { Git } from "@/git"
10
-
11
- export namespace Storage {
12
- const log = Log.create({ service: "storage" })
13
-
14
- type Migration = (dir: string, fs: AppFileSystem.Interface) => Effect.Effect<void, AppFileSystem.Error>
15
-
16
- export const NotFoundError = NamedError.create(
17
- "NotFoundError",
18
- z.object({
19
- message: z.string(),
20
- }),
21
- )
22
-
23
- export type Error = AppFileSystem.Error | InstanceType<typeof NotFoundError>
24
-
25
- const RootFile = Schema.Struct({
26
- path: Schema.optional(
27
- Schema.Struct({
28
- root: Schema.optional(Schema.String),
29
- }),
30
- ),
31
- })
32
-
33
- const SessionFile = Schema.Struct({
34
- id: Schema.String,
35
- })
36
-
37
- const MessageFile = Schema.Struct({
38
- id: Schema.String,
39
- })
40
-
41
- const DiffFile = Schema.Struct({
42
- additions: Schema.Number,
43
- deletions: Schema.Number,
44
- })
45
-
46
- const SummaryFile = Schema.Struct({
47
- id: Schema.String,
48
- projectID: Schema.String,
49
- summary: Schema.Struct({ diffs: Schema.Array(DiffFile) }),
50
- })
51
-
52
- const decodeRoot = Schema.decodeUnknownOption(RootFile)
53
- const decodeSession = Schema.decodeUnknownOption(SessionFile)
54
- const decodeMessage = Schema.decodeUnknownOption(MessageFile)
55
- const decodeSummary = Schema.decodeUnknownOption(SummaryFile)
56
-
57
- export interface Interface {
58
- readonly remove: (key: string[]) => Effect.Effect<void, AppFileSystem.Error>
59
- readonly read: <T>(key: string[]) => Effect.Effect<T, Error>
60
- readonly update: <T>(key: string[], fn: (draft: T) => void) => Effect.Effect<T, Error>
61
- readonly write: <T>(key: string[], content: T) => Effect.Effect<void, AppFileSystem.Error>
62
- readonly list: (prefix: string[]) => Effect.Effect<string[][], AppFileSystem.Error>
63
- }
64
-
65
- export class Service extends ServiceMap.Service<Service, Interface>()("@opencode/Storage") {}
66
-
67
- function file(dir: string, key: string[]) {
68
- return path.join(dir, ...key) + ".json"
69
- }
70
-
71
- function missing(err: unknown) {
72
- if (!err || typeof err !== "object") return false
73
- if ("code" in err && err.code === "ENOENT") return true
74
- if ("reason" in err && err.reason && typeof err.reason === "object" && "_tag" in err.reason) {
75
- return err.reason._tag === "NotFound"
76
- }
77
- return false
78
- }
79
-
80
- function parseMigration(text: string) {
81
- const value = Number.parseInt(text, 10)
82
- return Number.isNaN(value) ? 0 : value
83
- }
84
-
85
- const MIGRATIONS: Migration[] = [
86
- Effect.fn("Storage.migration.1")(function* (dir: string, fs: AppFileSystem.Interface) {
87
- const project = path.resolve(dir, "../project")
88
- if (!(yield* fs.isDir(project))) return
89
- const projectDirs = yield* fs.glob("*", {
90
- cwd: project,
91
- include: "all",
92
- })
93
- for (const projectDir of projectDirs) {
94
- const full = path.join(project, projectDir)
95
- if (!(yield* fs.isDir(full))) continue
96
- log.info(`migrating project ${projectDir}`)
97
- let projectID = projectDir
98
- let worktree = "/"
99
-
100
- if (projectID !== "global") {
101
- for (const msgFile of yield* fs.glob("storage/session/message/*/*.json", {
102
- cwd: full,
103
- absolute: true,
104
- })) {
105
- const json = decodeRoot(yield* fs.readJson(msgFile), { onExcessProperty: "preserve" })
106
- const root = Option.isSome(json) ? json.value.path?.root : undefined
107
- if (!root) continue
108
- worktree = root
109
- break
110
- }
111
- if (!worktree) continue
112
- if (!(yield* fs.isDir(worktree))) continue
113
- const result = yield* Effect.promise(() =>
114
- Git.run(["rev-list", "--max-parents=0", "--all"], {
115
- cwd: worktree,
116
- }),
117
- )
118
- const [id] = result
119
- .text()
120
- .split("\n")
121
- .filter(Boolean)
122
- .map((x) => x.trim())
123
- .toSorted()
124
- if (!id) continue
125
- projectID = id
126
-
127
- yield* fs.writeWithDirs(
128
- path.join(dir, "project", projectID + ".json"),
129
- JSON.stringify(
130
- {
131
- id,
132
- vcs: "git",
133
- worktree,
134
- time: {
135
- created: Date.now(),
136
- initialized: Date.now(),
137
- },
138
- },
139
- null,
140
- 2,
141
- ),
142
- )
143
-
144
- log.info(`migrating sessions for project ${projectID}`)
145
- for (const sessionFile of yield* fs.glob("storage/session/info/*.json", {
146
- cwd: full,
147
- absolute: true,
148
- })) {
149
- const dest = path.join(dir, "session", projectID, path.basename(sessionFile))
150
- log.info("copying", { sessionFile, dest })
151
- const session = yield* fs.readJson(sessionFile)
152
- const info = decodeSession(session, { onExcessProperty: "preserve" })
153
- yield* fs.writeWithDirs(dest, JSON.stringify(session, null, 2))
154
- if (Option.isNone(info)) continue
155
- log.info(`migrating messages for session ${info.value.id}`)
156
- for (const msgFile of yield* fs.glob(`storage/session/message/${info.value.id}/*.json`, {
157
- cwd: full,
158
- absolute: true,
159
- })) {
160
- const next = path.join(dir, "message", info.value.id, path.basename(msgFile))
161
- log.info("copying", {
162
- msgFile,
163
- dest: next,
164
- })
165
- const message = yield* fs.readJson(msgFile)
166
- const item = decodeMessage(message, { onExcessProperty: "preserve" })
167
- yield* fs.writeWithDirs(next, JSON.stringify(message, null, 2))
168
- if (Option.isNone(item)) continue
169
-
170
- log.info(`migrating parts for message ${item.value.id}`)
171
- for (const partFile of yield* fs.glob(`storage/session/part/${info.value.id}/${item.value.id}/*.json`, {
172
- cwd: full,
173
- absolute: true,
174
- })) {
175
- const out = path.join(dir, "part", item.value.id, path.basename(partFile))
176
- const part = yield* fs.readJson(partFile)
177
- log.info("copying", {
178
- partFile,
179
- dest: out,
180
- })
181
- yield* fs.writeWithDirs(out, JSON.stringify(part, null, 2))
182
- }
183
- }
184
- }
185
- }
186
- }
187
- }),
188
- Effect.fn("Storage.migration.2")(function* (dir: string, fs: AppFileSystem.Interface) {
189
- for (const item of yield* fs.glob("session/*/*.json", {
190
- cwd: dir,
191
- absolute: true,
192
- })) {
193
- const raw = yield* fs.readJson(item)
194
- const session = decodeSummary(raw, { onExcessProperty: "preserve" })
195
- if (Option.isNone(session)) continue
196
- const diffs = session.value.summary.diffs
197
- yield* fs.writeWithDirs(
198
- path.join(dir, "session_diff", session.value.id + ".json"),
199
- JSON.stringify(diffs, null, 2),
200
- )
201
- yield* fs.writeWithDirs(
202
- path.join(dir, "session", session.value.projectID, session.value.id + ".json"),
203
- JSON.stringify(
204
- {
205
- ...(raw as Record<string, unknown>),
206
- summary: {
207
- additions: diffs.reduce((sum, x) => sum + x.additions, 0),
208
- deletions: diffs.reduce((sum, x) => sum + x.deletions, 0),
209
- },
210
- },
211
- null,
212
- 2,
213
- ),
214
- )
215
- }
216
- }),
217
- ]
218
-
219
- export const layer = Layer.effect(
220
- Service,
221
- Effect.gen(function* () {
222
- const fs = yield* AppFileSystem.Service
223
- const locks = yield* RcMap.make({
224
- lookup: () => TxReentrantLock.make(),
225
- idleTimeToLive: 0,
226
- })
227
- const state = yield* Effect.cached(
228
- Effect.gen(function* () {
229
- const dir = path.join(Global.Path.data, "storage")
230
- const marker = path.join(dir, "migration")
231
- const migration = yield* fs.readFileString(marker).pipe(
232
- Effect.map(parseMigration),
233
- Effect.catchIf(missing, () => Effect.succeed(0)),
234
- Effect.orElseSucceed(() => 0),
235
- )
236
- for (let i = migration; i < MIGRATIONS.length; i++) {
237
- log.info("running migration", { index: i })
238
- const step = MIGRATIONS[i]!
239
- const exit = yield* Effect.exit(step(dir, fs))
240
- if (Exit.isFailure(exit)) {
241
- log.error("failed to run migration", { index: i, cause: exit.cause })
242
- break
243
- }
244
- yield* fs.writeWithDirs(marker, String(i + 1))
245
- }
246
- return { dir }
247
- }),
248
- )
249
-
250
- const fail = (target: string): Effect.Effect<never, InstanceType<typeof NotFoundError>> =>
251
- Effect.fail(new NotFoundError({ message: `Resource not found: ${target}` }))
252
-
253
- const wrap = <A>(target: string, body: Effect.Effect<A, AppFileSystem.Error>) =>
254
- body.pipe(Effect.catchIf(missing, () => fail(target)))
255
-
256
- const writeJson = Effect.fnUntraced(function* (target: string, content: unknown) {
257
- yield* fs.writeWithDirs(target, JSON.stringify(content, null, 2))
258
- })
259
-
260
- const withResolved = <A, E>(
261
- key: string[],
262
- fn: (target: string, rw: TxReentrantLock.TxReentrantLock) => Effect.Effect<A, E>,
263
- ): Effect.Effect<A, E | AppFileSystem.Error> =>
264
- Effect.scoped(
265
- Effect.gen(function* () {
266
- const target = file((yield* state).dir, key)
267
- return yield* fn(target, yield* RcMap.get(locks, target))
268
- }),
269
- )
270
-
271
- const remove: Interface["remove"] = Effect.fn("Storage.remove")(function* (key: string[]) {
272
- yield* withResolved(key, (target, rw) =>
273
- TxReentrantLock.withWriteLock(rw, fs.remove(target).pipe(Effect.catchIf(missing, () => Effect.void))),
274
- )
275
- })
276
-
277
- const read: Interface["read"] = <T>(key: string[]) =>
278
- Effect.gen(function* () {
279
- const value = yield* withResolved(key, (target, rw) =>
280
- TxReentrantLock.withReadLock(rw, wrap(target, fs.readJson(target))),
281
- )
282
- return value as T
283
- })
284
-
285
- const update: Interface["update"] = <T>(key: string[], fn: (draft: T) => void) =>
286
- Effect.gen(function* () {
287
- const value = yield* withResolved(key, (target, rw) =>
288
- TxReentrantLock.withWriteLock(
289
- rw,
290
- Effect.gen(function* () {
291
- const content = yield* wrap(target, fs.readJson(target))
292
- fn(content as T)
293
- yield* writeJson(target, content)
294
- return content
295
- }),
296
- ),
297
- )
298
- return value as T
299
- })
300
-
301
- const write: Interface["write"] = (key: string[], content: unknown) =>
302
- Effect.gen(function* () {
303
- yield* withResolved(key, (target, rw) => TxReentrantLock.withWriteLock(rw, writeJson(target, content)))
304
- })
305
-
306
- const list: Interface["list"] = Effect.fn("Storage.list")(function* (prefix: string[]) {
307
- const dir = (yield* state).dir
308
- const cwd = path.join(dir, ...prefix)
309
- const result = yield* fs
310
- .glob("**/*", {
311
- cwd,
312
- include: "file",
313
- })
314
- .pipe(Effect.catch(() => Effect.succeed<string[]>([])))
315
- return result
316
- .map((x) => [...prefix, ...x.slice(0, -5).split(path.sep)])
317
- .toSorted((a, b) => a.join("/").localeCompare(b.join("/")))
318
- })
319
-
320
- return Service.of({
321
- remove,
322
- read,
323
- update,
324
- write,
325
- list,
326
- })
327
- }),
328
- )
329
-
330
- export const defaultLayer = layer.pipe(Layer.provide(AppFileSystem.defaultLayer))
331
-
332
- const { runPromise } = makeRuntime(Service, defaultLayer)
333
-
334
- export async function remove(key: string[]) {
335
- return runPromise((svc) => svc.remove(key))
336
- }
337
-
338
- export async function read<T>(key: string[]) {
339
- return runPromise((svc) => svc.read<T>(key))
340
- }
341
-
342
- export async function update<T>(key: string[], fn: (draft: T) => void) {
343
- return runPromise((svc) => svc.update<T>(key, fn))
344
- }
345
-
346
- export async function write<T>(key: string[], content: T) {
347
- return runPromise((svc) => svc.write(key, content))
348
- }
349
-
350
- export async function list(prefix: string[]) {
351
- return runPromise((svc) => svc.list(prefix))
352
- }
353
- }
@@ -1,179 +0,0 @@
1
- tl;dr All of these APIs work, are properly type-checked, and are sync events are backwards compatible with `Bus`:
2
-
3
- ```ts
4
- // The schema from `Updated` typechecks the object correctly
5
- SyncEvent.run(Updated, { sessionID: id, info: { title: "foo" } })
6
-
7
- // `subscribeAll` passes a generic sync event
8
- SyncEvent.subscribeAll((event) => {
9
- // These will be type-checked correctly
10
- event.id
11
- event.seq
12
- // This will be unknown because we are listening for all events,
13
- // and this API is only used to record them
14
- event.data
15
- })
16
-
17
- // This works, but you shouldn't publish sync event like this (should fail in the future)
18
- Bus.publish(Updated, { sessionID: id, info: { title: "foo" } })
19
-
20
- // Update event is fully type-checked
21
- Bus.subscribe(Updated, (event) => event.properties.info.title)
22
-
23
- // Update event is fully type-checked
24
- client.subscribe("session.updated", (evt) => evt.properties.info.title)
25
- ```
26
-
27
- # Goal
28
-
29
- ## Syncing with only one writer
30
-
31
- This system defines a basic event sourcing system for session replayability. The goal is to allow for one device to control and modify the session, and allow multiple other devices to "sync" session data. The sync works by getting a log of events to replay and replaying them locally.
32
-
33
- Because only one device is allowed to write, we don't need any kind of sophisticated distributed system clocks or causal ordering. We implement total ordering with a simple sequence id (a number) and increment it by one every time we generate an event.
34
-
35
- ## Bus event integration and backwards compatibility
36
-
37
- This initial implementation aims to be fully backwards compatible. We should be able to land this without any visible changes to the user.
38
-
39
- An existing `Bus` abstraction to send events already exists. We already send events like `session.created` through the system. We should not duplicate this.
40
-
41
- The difference in event sourcing is events are sent _before_ the mutation happens, and "projectors" handle the effects and perform the mutations. This difference is subtle, and a necessary change for syncing to work.
42
-
43
- So the goal is:
44
-
45
- - Introduce a new syncing abstraction to handle event sourcing and projectors
46
- - Seamlessly integrate these new events into the same existing `Bus` abstraction
47
- - Maintain full backwards compatibility to reduce risk
48
-
49
- ## My approach
50
-
51
- This directory introduces a new abstraction: `SyncEvent`. This handles all of the event sourcing.
52
-
53
- There are now "sync events" which are different than "bus events". Bus events are defined like this:
54
-
55
- ```ts
56
- const Diff = BusEvent.define(
57
- "session.diff",
58
- z.object({
59
- sessionID: SessionID.zod,
60
- diff: Snapshot.FileDiff.array(),
61
- }),
62
- )
63
- ```
64
-
65
- You can do `Bus.publish(Diff, { ... })` to push these events, and `Bus.subscribe(Diff, handler)` to listen to them.
66
-
67
- Sync events are a lower-level abstraction which are similar, but also handle the requirements for recording and replaying. Defining them looks like this:
68
-
69
- ```ts
70
- const Created = SyncEvent.define({
71
- type: "session.created",
72
- version: 1,
73
- aggregate: "sessionID",
74
- schema: z.object({
75
- sessionID: SessionID.zod,
76
- info: Info,
77
- }),
78
- })
79
- ```
80
-
81
- Not too different, except they track a version and an "aggregate" field (will explain that later).
82
-
83
- You do this to run an event, which is kind of like `Bus.publish` except that it runs through the event sourcing system:
84
-
85
- ```
86
- SyncEvent.run(Created, { ... })
87
- ```
88
-
89
- The data passed as the second argument is properly type-checked based on the schema defined in `Created`.
90
-
91
- Importantly, **sync events automatically re-publish as bus events**. This makes them backwards compatible, and allows the `Bus` to still be the single abstraction that the system uses to listen for individual events.
92
-
93
- **We have upgraded many of the session events to be sync events** (all of the ones that mutate the db). Sync and bus events are largely compatible. Here are the differences:
94
-
95
- ### Event shape
96
-
97
- - The shape of the events are slightly different. A sync event has the `type`, `id`, `seq`, `aggregateID`, and `data` fields. A bus event has the `type` and `properties` fields. `data` and `properties` are largely the same thing. This conversion is automatically handled when the sync system re-published the event throught the bus.
98
-
99
- The reason for this is because sync events need to track more information. I chose not to copy the `properties` naming to more clearly disambiguate the event types.
100
-
101
- ### Event flow
102
-
103
- There is no way to subscribe to individual sync events in `SyncEvent`. You can use `subscribeAll` to receive _all_ of the events, which is needed for clients that want to record them.
104
-
105
- To listen for individual events, use `Bus.subscribe`. You can pass in a sync event definition to it: `Bus.subscribe(Created, handler)`. This is fully supported.
106
-
107
- You should never "publish" a sync event however: `Bus.publish(Created, ...)`. I would like to force this to be a type error in the future. You should never be touching the db directly, and should not be manually handling these events.
108
-
109
- ### Backwards compatibility
110
-
111
- The system install projectors in `server/projectors.js`. It calls `SyncEvent.init` to do this. It also installs a hook for dynamically converting an event at runtime (`convertEvent`).
112
-
113
- This allows you to "reshape" an event from the sync system before it's published to the bus. This should be avoided, but might be necessary for temporary backwards compat.
114
-
115
- The only time we use this is the `session.updated` event. Previously this event contained the entire session object. The sync even only contains the fields updated. We convert the event to contain to full object for backwards compatibility (but ideally we'd remove this).
116
-
117
- It's very important that types are correct when working with events. Event definitions have a `schema` which carries the defintiion of the event shape (provided by a zod schema, inferred into a TypeScript type). Examples:
118
-
119
- ```ts
120
- // The schema from `Updated` typechecks the object correctly
121
- SyncEvent.run(Updated, { sessionID: id, info: { title: "foo" } })
122
-
123
- // `subscribeAll` passes a generic sync event
124
- SyncEvent.subscribeAll((event) => {
125
- // These will be type-checked correctly
126
- event.id
127
- event.seq
128
- // This will be unknown because we are listening for all events,
129
- // and this API is only used to record them
130
- event.data
131
- })
132
-
133
- // This works, but you shouldn't publish sync event like this (should fail in the future)
134
- Bus.publish(Updated, { sessionID: id, info: { title: "foo" } })
135
-
136
- // Update event is fully type-checked
137
- Bus.subscribe(Updated, (event) => event.properties.info.title)
138
-
139
- // Update event is fully type-checked
140
- client.subscribe("session.updated", (evt) => evt.properties.info.title)
141
- ```
142
-
143
- The last two examples look similar to `SyncEvent.run`, but they were the cause of a lot of grief. Those are existing APIs that we can't break, but we are passing in the new sync event definitions to these APIs, which sometimes have a different event shape.
144
-
145
- I previously mentioned the runtime conversion of events, but we still need to the types to work! To do that, the `define` API supports an optional `busSchema` prop to give it the schema for backwards compatibility. For example this is the full definition of `Session.Update`:
146
-
147
- ```ts
148
- const Update = SyncEvent.define({
149
- type: "session.updated",
150
- version: 1,
151
- aggregate: "sessionID",
152
- schema: z.object({
153
- sessionID: SessionID.zod,
154
- info: partialSchema(Info),
155
- }),
156
- busSchema: z.object({
157
- sessionID: SessionID.zod,
158
- info: Info,
159
- }),
160
- })
161
- ```
162
-
163
- _Important_: the conversion done in `convertEvent` is not automatically type-checked with `busSchema`. It's very important they match, but because we need this at type-checking time this needs to live here.
164
-
165
- Internally, the way this works is `busSchema` is stored on a `properties` field which is what the bus system expects. Doing this made everything with `Bus` "just work". This is why you can pass a sync event to the bus APIs.
166
-
167
- _Alternatives_
168
-
169
- These are some other paths I explored:
170
-
171
- - Providing a way to subscribe to individual sync events, and change all the instances of `Bus.subscribe` in our code to it. Then you are directly only working with sync events always.
172
- - Two big problems. First, `Bus` is instance-scoped, and we'd need to make the sync event system instance-scoped too for backwards compat. If we didn't, those listeners would get calls for events they weren't expecting.
173
- - Second, we can't change consumers of our SDK. So they still have to use the old events, and we might as well stick with them for consistency
174
- - Directly add sync event support to bus system
175
- - I explored adding sync events to the bus, but due to backwards compat, it only made it more complicated (still need to support both shapes)
176
- - I explored a `convertSchema` function to convert the event schema at runtime so we didn't need `busSchema`
177
- - Fatal flaw: we need type-checking done earlier. We can't do this at run-time. This worked for consumers of our SDK (because it gets generated TS types from the converted schema) but breaks for our internal usage of `Bus.subscribe` calls
178
-
179
- I explored many other permutations of the above solutions. What we have today I think is the best balance of backwards compatibility while opening a path forward for the new events.
@@ -1,16 +0,0 @@
1
- import { sqliteTable, text, integer } from "drizzle-orm/sqlite-core"
2
-
3
- export const EventSequenceTable = sqliteTable("event_sequence", {
4
- aggregate_id: text().notNull().primaryKey(),
5
- seq: integer().notNull(),
6
- })
7
-
8
- export const EventTable = sqliteTable("event", {
9
- id: text().primaryKey(),
10
- aggregate_id: text()
11
- .notNull()
12
- .references(() => EventSequenceTable.aggregate_id, { onDelete: "cascade" }),
13
- seq: integer().notNull(),
14
- type: text().notNull(),
15
- data: text({ mode: "json" }).$type<Record<string, unknown>>().notNull(),
16
- })