smithers-orchestrator 0.15.1 → 0.16.0

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 (495) hide show
  1. package/package.json +47 -113
  2. package/src/CreateSmithersApi.ts +62 -0
  3. package/src/CreateSmithersOptions.ts +9 -0
  4. package/src/create.js +384 -0
  5. package/src/dom/renderer.js +1 -0
  6. package/src/examples-entry.js +29 -0
  7. package/src/external/ExternalSmithersConfig.ts +12 -0
  8. package/src/external/HostNodeJson.ts +12 -0
  9. package/src/external/SerializedCtx.ts +9 -0
  10. package/src/external/create-external-smithers.js +148 -0
  11. package/src/external/index.js +10 -0
  12. package/src/gateway.js +1 -0
  13. package/src/ide/SmithersIdeAskUserResult.ts +7 -0
  14. package/src/ide/SmithersIdeAvailability.ts +17 -0
  15. package/src/ide/SmithersIdeCommandBaseResult.ts +7 -0
  16. package/src/ide/SmithersIdeOpenDiffResult.ts +5 -0
  17. package/src/ide/SmithersIdeOpenFileResult.ts +8 -0
  18. package/src/ide/SmithersIdeOpenWebviewResult.ts +7 -0
  19. package/src/ide/SmithersIdeOverlayOptions.ts +7 -0
  20. package/src/ide/SmithersIdeOverlayResult.ts +8 -0
  21. package/src/ide/SmithersIdeOverlayType.ts +1 -0
  22. package/src/ide/SmithersIdeResolvedConfig.ts +8 -0
  23. package/src/ide/SmithersIdeRunTerminalResult.ts +8 -0
  24. package/src/ide/SmithersIdeService.js +432 -0
  25. package/src/ide/SmithersIdeServiceApi.ts +35 -0
  26. package/src/ide/SmithersIdeServiceConfig.ts +8 -0
  27. package/src/ide/index.js +44 -0
  28. package/src/ide/tools.js +94 -0
  29. package/src/index.d.ts +408 -0
  30. package/src/index.js +218 -0
  31. package/src/jsx-runtime.js +3 -0
  32. package/src/mdx-plugin.js +5 -0
  33. package/src/memory.js +1 -0
  34. package/src/observability.js +1 -0
  35. package/src/openapi.js +1 -0
  36. package/src/pi-extension.js +1 -0
  37. package/src/pi-plugin/SmithersPiRunContext.ts +7 -0
  38. package/src/pi-plugin/extension.js +1970 -0
  39. package/src/pi-plugin/index.js +164 -0
  40. package/src/pi-plugin.js +1 -0
  41. package/src/scorers.js +1 -0
  42. package/src/serve.js +1 -0
  43. package/src/server.js +1 -0
  44. package/src/tools/bash.js +180 -0
  45. package/src/tools/context.js +29 -0
  46. package/src/tools/defineTool.js +69 -0
  47. package/src/tools/edit.js +41 -0
  48. package/src/tools/grep.js +33 -0
  49. package/src/tools/index.js +29 -0
  50. package/src/tools/read.js +24 -0
  51. package/src/tools/utils.js +181 -0
  52. package/src/tools/write.js +35 -0
  53. package/src/tools.d.ts +122 -0
  54. package/src/tools.js +1 -0
  55. package/README.md +0 -305
  56. package/docs/.mintignore +0 -1
  57. package/docs/api/effect.mdx +0 -933
  58. package/docs/cli/overview.mdx +0 -1444
  59. package/docs/cli/quickstart.mdx +0 -125
  60. package/docs/components/approval-gate.mdx +0 -105
  61. package/docs/components/approval.mdx +0 -219
  62. package/docs/components/aspects.mdx +0 -143
  63. package/docs/components/branch.mdx +0 -122
  64. package/docs/components/check-suite.mdx +0 -153
  65. package/docs/components/classify-and-route.mdx +0 -142
  66. package/docs/components/content-pipeline.mdx +0 -141
  67. package/docs/components/continue-as-new.mdx +0 -163
  68. package/docs/components/debate.mdx +0 -111
  69. package/docs/components/decision-table.mdx +0 -169
  70. package/docs/components/drift-detector.mdx +0 -136
  71. package/docs/components/escalation-chain.mdx +0 -134
  72. package/docs/components/gather-and-synthesize.mdx +0 -146
  73. package/docs/components/human-task.mdx +0 -159
  74. package/docs/components/kanban.mdx +0 -156
  75. package/docs/components/loop.mdx +0 -257
  76. package/docs/components/merge-queue.mdx +0 -66
  77. package/docs/components/optimizer.mdx +0 -137
  78. package/docs/components/panel.mdx +0 -146
  79. package/docs/components/parallel.mdx +0 -95
  80. package/docs/components/poller.mdx +0 -119
  81. package/docs/components/review-loop.mdx +0 -129
  82. package/docs/components/runbook.mdx +0 -169
  83. package/docs/components/saga.mdx +0 -161
  84. package/docs/components/sandbox.mdx +0 -325
  85. package/docs/components/scan-fix-verify.mdx +0 -137
  86. package/docs/components/sequence.mdx +0 -88
  87. package/docs/components/signal.mdx +0 -65
  88. package/docs/components/subflow.mdx +0 -108
  89. package/docs/components/super-smithers.mdx +0 -123
  90. package/docs/components/supervisor.mdx +0 -164
  91. package/docs/components/task.mdx +0 -338
  92. package/docs/components/timer.mdx +0 -135
  93. package/docs/components/try-catch-finally.mdx +0 -170
  94. package/docs/components/voice.mdx +0 -66
  95. package/docs/components/wait-for-event.mdx +0 -154
  96. package/docs/components/workflow.mdx +0 -93
  97. package/docs/components/worktree.mdx +0 -87
  98. package/docs/concepts/agents-and-tools.mdx +0 -293
  99. package/docs/concepts/approvals.mdx +0 -292
  100. package/docs/concepts/caching.mdx +0 -242
  101. package/docs/concepts/control-flow.mdx +0 -306
  102. package/docs/concepts/data-model.mdx +0 -365
  103. package/docs/concepts/evals.mdx +0 -303
  104. package/docs/concepts/execution-model.mdx +0 -234
  105. package/docs/concepts/human-in-the-loop.mdx +0 -350
  106. package/docs/concepts/memory.mdx +0 -230
  107. package/docs/concepts/openapi-tools.mdx +0 -227
  108. package/docs/concepts/planner-internals.mdx +0 -187
  109. package/docs/concepts/rag.mdx +0 -236
  110. package/docs/concepts/reactivity.mdx +0 -380
  111. package/docs/concepts/suspend-and-resume.mdx +0 -211
  112. package/docs/concepts/time-travel.mdx +0 -271
  113. package/docs/concepts/unidirectional-dataflow.mdx +0 -160
  114. package/docs/concepts/voice.mdx +0 -295
  115. package/docs/concepts/workflow-state.mdx +0 -258
  116. package/docs/concepts/workflows-overview.mdx +0 -238
  117. package/docs/design-prompts/devtools-prd.md +0 -206
  118. package/docs/design-prompts/hmr-design.md +0 -304
  119. package/docs/design-prompts/smithers-init-command-design.md +0 -835
  120. package/docs/design-prompts/tui-chat-design.md +0 -524
  121. package/docs/design-prompts/tui-chat-engineering.md +0 -629
  122. package/docs/design-prompts/tui-chat-prd.md +0 -138
  123. package/docs/design-prompts/tui-chat-tickets.md +0 -350
  124. package/docs/docs.json +0 -366
  125. package/docs/examples/agents-md.mdx +0 -54
  126. package/docs/examples/approval-gate.mdx +0 -153
  127. package/docs/examples/ci-workflow.mdx +0 -43
  128. package/docs/examples/claude-plugin-orchestrator.mdx +0 -77
  129. package/docs/examples/claude-plugin-skill.mdx +0 -71
  130. package/docs/examples/dynamic-plan.mdx +0 -114
  131. package/docs/examples/generate-llms-txt.mdx +0 -45
  132. package/docs/examples/hello-world.mdx +0 -49
  133. package/docs/examples/loop.mdx +0 -130
  134. package/docs/examples/multi-agent-review.mdx +0 -115
  135. package/docs/examples/tools-agent.mdx +0 -124
  136. package/docs/examples/workflow-approval.mdx +0 -81
  137. package/docs/examples/workflow-hello.mdx +0 -55
  138. package/docs/examples/workflow-quickstart.mdx +0 -90
  139. package/docs/examples/worktree-feature-prompts.mdx +0 -185
  140. package/docs/examples/worktree-feature-run-sh.mdx +0 -89
  141. package/docs/examples/worktree-feature-schemas.mdx +0 -169
  142. package/docs/examples/worktree-feature-workflow.mdx +0 -286
  143. package/docs/favicon.svg +0 -4
  144. package/docs/favicons/favicon-16x16.png +0 -0
  145. package/docs/favicons/favicon-32x32.png +0 -0
  146. package/docs/favicons/favicon.ico +0 -0
  147. package/docs/guides/alerting.mdx +0 -110
  148. package/docs/guides/best-practices.mdx +0 -380
  149. package/docs/guides/debugging.mdx +0 -201
  150. package/docs/guides/dynamic-tickets.mdx +0 -205
  151. package/docs/guides/error-handling.mdx +0 -318
  152. package/docs/guides/evals-quickstart.mdx +0 -168
  153. package/docs/guides/hot-reload.mdx +0 -171
  154. package/docs/guides/mdx-prompts.mdx +0 -195
  155. package/docs/guides/memory-quickstart.mdx +0 -179
  156. package/docs/guides/model-selection.mdx +0 -241
  157. package/docs/guides/monitoring-logs.mdx +0 -185
  158. package/docs/guides/openapi-tools-quickstart.mdx +0 -133
  159. package/docs/guides/patterns.mdx +0 -336
  160. package/docs/guides/project-structure.mdx +0 -299
  161. package/docs/guides/rag-quickstart.mdx +0 -145
  162. package/docs/guides/resumability.mdx +0 -181
  163. package/docs/guides/review-loop.mdx +0 -267
  164. package/docs/guides/structured-output.mdx +0 -169
  165. package/docs/guides/third-party-hooks.mdx +0 -302
  166. package/docs/guides/time-travel-quickstart.mdx +0 -141
  167. package/docs/guides/troubleshooting.mdx +0 -41
  168. package/docs/guides/tui.mdx +0 -364
  169. package/docs/guides/tutorial-workflow.mdx +0 -260
  170. package/docs/guides/vcs.mdx +0 -170
  171. package/docs/guides/voice-quickstart.mdx +0 -138
  172. package/docs/images/state-machine.jpg +0 -0
  173. package/docs/images/tui/agent-console.jpg +0 -0
  174. package/docs/images/tui/data-grid.jpg +0 -0
  175. package/docs/images/tui/inspector-chat.jpg +0 -0
  176. package/docs/images/tui/inspector-frames.jpg +0 -0
  177. package/docs/images/tui/inspector-input.jpg +0 -0
  178. package/docs/images/tui/inspector-logs.jpg +0 -0
  179. package/docs/images/tui/inspector-output.jpg +0 -0
  180. package/docs/images/tui/launch-workflow.jpg +0 -0
  181. package/docs/images/tui/runs-view.jpg +0 -0
  182. package/docs/images/tui/task-list.jpg +0 -0
  183. package/docs/images/tui/telemetry-view.jpg +0 -0
  184. package/docs/images/tui/triggers-view.jpg +0 -0
  185. package/docs/images/unidirectional-dataflow.jpg +0 -0
  186. package/docs/index.mdx +0 -62
  187. package/docs/installation.mdx +0 -59
  188. package/docs/integrations/cli-agents.mdx +0 -957
  189. package/docs/integrations/common-tools.mdx +0 -244
  190. package/docs/integrations/ecosystem.mdx +0 -63
  191. package/docs/integrations/external-workflows.mdx +0 -381
  192. package/docs/integrations/gateway.mdx +0 -824
  193. package/docs/integrations/github-bot.mdx +0 -445
  194. package/docs/integrations/ide.mdx +0 -519
  195. package/docs/integrations/integrations.mdx +0 -268
  196. package/docs/integrations/mcp-server.mdx +0 -709
  197. package/docs/integrations/pi-extension.mdx +0 -248
  198. package/docs/integrations/pi-integration.mdx +0 -86
  199. package/docs/integrations/pi-plugin.mdx +0 -310
  200. package/docs/integrations/sdk-agents.mdx +0 -109
  201. package/docs/integrations/serve.mdx +0 -219
  202. package/docs/integrations/server.mdx +0 -432
  203. package/docs/integrations/tools.mdx +0 -355
  204. package/docs/introduction.mdx +0 -70
  205. package/docs/jsx/installation.mdx +0 -113
  206. package/docs/jsx/overview.mdx +0 -96
  207. package/docs/jsx/quickstart.mdx +0 -111
  208. package/docs/llms-full.txt +0 -30666
  209. package/docs/llms.txt +0 -98
  210. package/docs/quickstart.mdx +0 -61
  211. package/docs/reference/errors.mdx +0 -218
  212. package/docs/reference/package-configuration.mdx +0 -158
  213. package/docs/reference/types.mdx +0 -941
  214. package/docs/reference/vcs-helpers.mdx +0 -175
  215. package/docs/runtime/events.mdx +0 -1226
  216. package/docs/runtime/render-frame.mdx +0 -222
  217. package/docs/runtime/revert.mdx +0 -140
  218. package/docs/runtime/run-workflow.mdx +0 -224
  219. package/observability/dashboards/smithers.json +0 -223
  220. package/observability/docker-compose.otel.yml +0 -47
  221. package/observability/grafana/dashboards/smithers-dashboard.json +0 -453
  222. package/observability/grafana/provisioning/dashboards/dashboards.yml +0 -12
  223. package/observability/grafana/provisioning/datasources/datasources.yml +0 -29
  224. package/observability/otel-collector-config.yml +0 -32
  225. package/observability/prometheus/prometheus.yml +0 -8
  226. package/observability/tempo/tempo.yml +0 -17
  227. package/src/AgentLike.ts +0 -28
  228. package/src/CachePolicy.ts +0 -4
  229. package/src/GraphSnapshot.ts +0 -9
  230. package/src/OutputAccessor.ts +0 -25
  231. package/src/OutputKey.ts +0 -1
  232. package/src/RetryPolicy.ts +0 -6
  233. package/src/RunAuthContext.ts +0 -6
  234. package/src/RunOptions.ts +0 -42
  235. package/src/RunResult.ts +0 -13
  236. package/src/RunStatus.ts +0 -9
  237. package/src/SchemaRegistryEntry.ts +0 -4
  238. package/src/SmithersCtx.ts +0 -89
  239. package/src/SmithersError.ts +0 -10
  240. package/src/SmithersEvent.ts +0 -564
  241. package/src/SmithersWorkflow.ts +0 -13
  242. package/src/SmithersWorkflowOptions.ts +0 -45
  243. package/src/TaskDescriptor.ts +0 -67
  244. package/src/XmlNode.ts +0 -13
  245. package/src/agents/AmpAgent.ts +0 -284
  246. package/src/agents/AnthropicAgent.ts +0 -70
  247. package/src/agents/BaseCliAgent.ts +0 -1848
  248. package/src/agents/ClaudeCodeAgent.ts +0 -593
  249. package/src/agents/CodexAgent.ts +0 -715
  250. package/src/agents/ForgeAgent.ts +0 -135
  251. package/src/agents/GeminiAgent.ts +0 -313
  252. package/src/agents/KimiAgent.ts +0 -313
  253. package/src/agents/OpenAIAgent.ts +0 -70
  254. package/src/agents/PiAgent.ts +0 -629
  255. package/src/agents/capability-registry.ts +0 -138
  256. package/src/agents/cli-capabilities.ts +0 -203
  257. package/src/agents/diagnostics.ts +0 -704
  258. package/src/agents/index.ts +0 -29
  259. package/src/agents/schema.ts +0 -71
  260. package/src/agents/sdk-shared.ts +0 -117
  261. package/src/aspects/AspectContext.ts +0 -87
  262. package/src/aspects/index.ts +0 -12
  263. package/src/cli/agent-contract.ts +0 -421
  264. package/src/cli/agent-detection.ts +0 -282
  265. package/src/cli/ask.ts +0 -503
  266. package/src/cli/chat.ts +0 -146
  267. package/src/cli/event-categories.ts +0 -176
  268. package/src/cli/find-db.ts +0 -90
  269. package/src/cli/format.ts +0 -274
  270. package/src/cli/hijack-session.ts +0 -232
  271. package/src/cli/hijack.ts +0 -249
  272. package/src/cli/index.ts +0 -4977
  273. package/src/cli/node-detail.ts +0 -921
  274. package/src/cli/resume-detached.ts +0 -43
  275. package/src/cli/scheduler.ts +0 -174
  276. package/src/cli/supervisor.ts +0 -607
  277. package/src/cli/tui/app.tsx +0 -195
  278. package/src/cli/tui/components/AskModal.tsx +0 -119
  279. package/src/cli/tui/components/ChatPane.tsx +0 -71
  280. package/src/cli/tui/components/CronList.tsx +0 -101
  281. package/src/cli/tui/components/DetailsPane.tsx +0 -116
  282. package/src/cli/tui/components/FramesPane.tsx +0 -166
  283. package/src/cli/tui/components/LogsPane.tsx +0 -58
  284. package/src/cli/tui/components/MetricsPane.tsx +0 -121
  285. package/src/cli/tui/components/NodeDetailView.tsx +0 -301
  286. package/src/cli/tui/components/NodeInspector.tsx +0 -67
  287. package/src/cli/tui/components/RunDetailView.tsx +0 -216
  288. package/src/cli/tui/components/RunsList.tsx +0 -220
  289. package/src/cli/tui/components/SqliteBrowser.tsx +0 -155
  290. package/src/cli/tui/components/WorkflowLauncher.tsx +0 -73
  291. package/src/cli/watch.ts +0 -129
  292. package/src/cli/why-diagnosis.ts +0 -1175
  293. package/src/cli/workflow-pack.ts +0 -2158
  294. package/src/cli/workflows.ts +0 -149
  295. package/src/components/Approval.ts +0 -254
  296. package/src/components/ApprovalGate.ts +0 -66
  297. package/src/components/Aspects.ts +0 -64
  298. package/src/components/Branch.ts +0 -14
  299. package/src/components/CheckSuite.ts +0 -108
  300. package/src/components/ClassifyAndRoute.ts +0 -127
  301. package/src/components/ContentPipeline.ts +0 -65
  302. package/src/components/ContinueAsNew.ts +0 -27
  303. package/src/components/Debate.ts +0 -115
  304. package/src/components/DecisionTable.ts +0 -68
  305. package/src/components/DriftDetector.ts +0 -90
  306. package/src/components/EscalationChain.ts +0 -138
  307. package/src/components/GatherAndSynthesize.ts +0 -122
  308. package/src/components/HumanTask.ts +0 -146
  309. package/src/components/Kanban.ts +0 -130
  310. package/src/components/MergeQueue.ts +0 -22
  311. package/src/components/Optimizer.ts +0 -94
  312. package/src/components/Panel.ts +0 -105
  313. package/src/components/Parallel.ts +0 -18
  314. package/src/components/Poller.ts +0 -103
  315. package/src/components/Ralph.ts +0 -22
  316. package/src/components/ReviewLoop.ts +0 -91
  317. package/src/components/Runbook.ts +0 -138
  318. package/src/components/Saga.ts +0 -112
  319. package/src/components/Sandbox.ts +0 -98
  320. package/src/components/ScanFixVerify.ts +0 -109
  321. package/src/components/Sequence.ts +0 -11
  322. package/src/components/Signal.ts +0 -70
  323. package/src/components/Subflow.ts +0 -62
  324. package/src/components/SuperSmithers.ts +0 -164
  325. package/src/components/Supervisor.ts +0 -146
  326. package/src/components/Task.ts +0 -374
  327. package/src/components/Timer.ts +0 -70
  328. package/src/components/TryCatchFinally.ts +0 -51
  329. package/src/components/Voice.ts +0 -27
  330. package/src/components/WaitForEvent.ts +0 -63
  331. package/src/components/Workflow.ts +0 -11
  332. package/src/components/Worktree.ts +0 -22
  333. package/src/components/control-flow-utils.ts +0 -40
  334. package/src/components/index.ts +0 -138
  335. package/src/constants.ts +0 -7
  336. package/src/context.ts +0 -266
  337. package/src/create.ts +0 -444
  338. package/src/db/adapter.ts +0 -2897
  339. package/src/db/ensure.ts +0 -17
  340. package/src/db/frame-codec.ts +0 -390
  341. package/src/db/input.ts +0 -19
  342. package/src/db/internal-schema.ts +0 -271
  343. package/src/db/output.ts +0 -285
  344. package/src/db/schema-signature.ts +0 -19
  345. package/src/db/snapshot.ts +0 -142
  346. package/src/db/write-retry.ts +0 -190
  347. package/src/devtools/SmithersDevTools.ts +0 -671
  348. package/src/devtools/index.ts +0 -9
  349. package/src/devtools/preload.ts +0 -12
  350. package/src/dom/extract.ts +0 -949
  351. package/src/dom/renderer.ts +0 -239
  352. package/src/effect/activity-bridge.ts +0 -158
  353. package/src/effect/bridge-utils.ts +0 -40
  354. package/src/effect/builder.ts +0 -1003
  355. package/src/effect/child-process.ts +0 -262
  356. package/src/effect/compute-task-bridge.ts +0 -897
  357. package/src/effect/deferred-bridge.ts +0 -72
  358. package/src/effect/deferred-state-bridge.ts +0 -1604
  359. package/src/effect/diff-bundle.ts +0 -309
  360. package/src/effect/durable-deferred-bridge.ts +0 -358
  361. package/src/effect/entity-worker.ts +0 -172
  362. package/src/effect/http-runner.ts +0 -114
  363. package/src/effect/interop.ts +0 -56
  364. package/src/effect/logging.ts +0 -69
  365. package/src/effect/metrics.ts +0 -1542
  366. package/src/effect/rpc-schema.ts +0 -130
  367. package/src/effect/runtime.ts +0 -78
  368. package/src/effect/sandbox-entity.ts +0 -215
  369. package/src/effect/single-runner.ts +0 -206
  370. package/src/effect/socket-runner.ts +0 -82
  371. package/src/effect/sql-message-storage.ts +0 -813
  372. package/src/effect/static-task-bridge.ts +0 -394
  373. package/src/effect/task-runtime.ts +0 -37
  374. package/src/effect/versioning.ts +0 -128
  375. package/src/effect/workflow-bridge.ts +0 -399
  376. package/src/effect/workflow-make-bridge.ts +0 -301
  377. package/src/engine/approvals.ts +0 -294
  378. package/src/engine/child-workflow.ts +0 -179
  379. package/src/engine/index.ts +0 -6298
  380. package/src/engine/scheduler.ts +0 -709
  381. package/src/engine/signals.ts +0 -106
  382. package/src/errors/tagged.ts +0 -290
  383. package/src/events.ts +0 -217
  384. package/src/examples-entry.ts +0 -35
  385. package/src/external/create-external-smithers.ts +0 -162
  386. package/src/external/index.ts +0 -6
  387. package/src/external/json-schema-to-zod.ts +0 -199
  388. package/src/external/python-subprocess.ts +0 -148
  389. package/src/external/python.ts +0 -66
  390. package/src/gateway/index.ts +0 -3134
  391. package/src/hot/HotWorkflowController.ts +0 -258
  392. package/src/hot/index.ts +0 -6
  393. package/src/hot/overlay.ts +0 -193
  394. package/src/hot/watch.ts +0 -175
  395. package/src/human-requests.ts +0 -120
  396. package/src/ide/SmithersIdeService.ts +0 -591
  397. package/src/ide/index.ts +0 -60
  398. package/src/ide/tools.ts +0 -101
  399. package/src/index.ts +0 -406
  400. package/src/jsx-runtime.ts +0 -3
  401. package/src/markdownComponents.ts +0 -78
  402. package/src/mcp/semantic-server.ts +0 -52
  403. package/src/mcp/semantic-tools.ts +0 -1410
  404. package/src/mdx-plugin.ts +0 -6
  405. package/src/memory/index.ts +0 -50
  406. package/src/memory/metrics.ts +0 -25
  407. package/src/memory/processors/index.ts +0 -91
  408. package/src/memory/schema.ts +0 -53
  409. package/src/memory/semantic.ts +0 -116
  410. package/src/memory/service.ts +0 -159
  411. package/src/memory/store.ts +0 -405
  412. package/src/memory/types.ts +0 -116
  413. package/src/observability/correlation.ts +0 -130
  414. package/src/observability/index.ts +0 -740
  415. package/src/openapi/index.ts +0 -27
  416. package/src/openapi/metrics.ts +0 -24
  417. package/src/openapi/ref-resolver.ts +0 -47
  418. package/src/openapi/schema-converter.ts +0 -235
  419. package/src/openapi/spec-parser.ts +0 -186
  420. package/src/openapi/tool-factory.ts +0 -332
  421. package/src/openapi/types.ts +0 -113
  422. package/src/pi-plugin/extension.ts +0 -1921
  423. package/src/pi-plugin/index.ts +0 -208
  424. package/src/rag/chunker.ts +0 -295
  425. package/src/rag/document.ts +0 -74
  426. package/src/rag/effect.ts +0 -45
  427. package/src/rag/embedder.ts +0 -84
  428. package/src/rag/index.ts +0 -63
  429. package/src/rag/metrics.ts +0 -28
  430. package/src/rag/pipeline.ts +0 -74
  431. package/src/rag/tool.ts +0 -61
  432. package/src/rag/types.ts +0 -103
  433. package/src/rag/vector-store.ts +0 -228
  434. package/src/renderMdx.ts +0 -26
  435. package/src/retry-task.ts +0 -263
  436. package/src/revert.ts +0 -90
  437. package/src/runtime-owner.ts +0 -30
  438. package/src/sandbox/bundle.ts +0 -326
  439. package/src/sandbox/execute.ts +0 -435
  440. package/src/sandbox/transport.ts +0 -90
  441. package/src/scorers/aggregate.ts +0 -107
  442. package/src/scorers/builtins.ts +0 -187
  443. package/src/scorers/create-scorer.ts +0 -120
  444. package/src/scorers/index.ts +0 -44
  445. package/src/scorers/metrics.ts +0 -24
  446. package/src/scorers/run-scorers.ts +0 -228
  447. package/src/scorers/schema.ts +0 -29
  448. package/src/scorers/types.ts +0 -117
  449. package/src/server/index.ts +0 -1355
  450. package/src/server/serve.ts +0 -381
  451. package/src/time-travel/diff.ts +0 -217
  452. package/src/time-travel/fork.ts +0 -284
  453. package/src/time-travel/index.ts +0 -89
  454. package/src/time-travel/metrics.ts +0 -24
  455. package/src/time-travel/replay.ts +0 -102
  456. package/src/time-travel/schema.ts +0 -62
  457. package/src/time-travel/snapshot.ts +0 -248
  458. package/src/time-travel/timeline.ts +0 -171
  459. package/src/time-travel/types.ts +0 -143
  460. package/src/time-travel/vcs-version.ts +0 -239
  461. package/src/timetravel.ts +0 -297
  462. package/src/tools/bash.ts +0 -218
  463. package/src/tools/context.ts +0 -46
  464. package/src/tools/defineTool.ts +0 -138
  465. package/src/tools/edit.ts +0 -75
  466. package/src/tools/grep.ts +0 -80
  467. package/src/tools/index.ts +0 -14
  468. package/src/tools/logToolCall.ts +0 -195
  469. package/src/tools/read.ts +0 -69
  470. package/src/tools/tools.ts +0 -8
  471. package/src/tools/utils.ts +0 -65
  472. package/src/tools/write.ts +0 -65
  473. package/src/types/react-dom-server.d.ts +0 -1
  474. package/src/unwrapZodType.ts +0 -20
  475. package/src/utils/camelToSnake.ts +0 -6
  476. package/src/utils/errors.ts +0 -632
  477. package/src/utils/hash.ts +0 -7
  478. package/src/utils/ids.ts +0 -6
  479. package/src/utils/input-bounds.ts +0 -333
  480. package/src/utils/parse.ts +0 -9
  481. package/src/utils/retry.ts +0 -63
  482. package/src/utils/time.ts +0 -3
  483. package/src/utils/tree-ids.ts +0 -15
  484. package/src/utils/xml.ts +0 -30
  485. package/src/vcs/find-root.ts +0 -19
  486. package/src/vcs/jj.ts +0 -309
  487. package/src/voice/ai-sdk-voice.ts +0 -122
  488. package/src/voice/composite.ts +0 -164
  489. package/src/voice/effect.ts +0 -159
  490. package/src/voice/index.ts +0 -28
  491. package/src/voice/realtime.ts +0 -798
  492. package/src/voice/types.ts +0 -157
  493. package/src/zod-to-example.ts +0 -61
  494. package/src/zodToCreateTableSQL.ts +0 -51
  495. package/src/zodToTable.ts +0 -71
package/package.json CHANGED
@@ -1,128 +1,62 @@
1
1
  {
2
2
  "name": "smithers-orchestrator",
3
- "version": "0.15.1",
4
- "description": "AI workflow orchestration with JSX",
5
- "author": "William Cory",
6
- "license": "MIT",
7
- "module": "src/index.ts",
3
+ "version": "0.16.0",
4
+ "description": "Public Smithers facade and workflow authoring convenience package",
8
5
  "type": "module",
9
- "bin": {
10
- "smithers": "src/cli/index.ts"
11
- },
6
+ "sideEffects": false,
12
7
  "exports": {
13
- ".": "./src/index.ts",
14
- "./gateway": "./src/gateway/index.ts",
15
- "./jsx-runtime": "./src/jsx-runtime.ts",
16
- "./jsx-dev-runtime": "./src/jsx-runtime.ts",
17
- "./tools": "./src/tools/index.ts",
18
- "./server": "./src/server/index.ts",
19
- "./observability": "./src/observability/index.ts",
20
- "./pi-plugin": "./src/pi-plugin/index.ts",
21
- "./pi-extension": "./src/pi-plugin/extension.ts",
22
- "./mdx-plugin": "./src/mdx-plugin.ts",
23
- "./dom/renderer": "./src/dom/renderer.ts",
24
- "./serve": "./src/server/serve.ts",
25
- "./scorers": "./src/scorers/index.ts",
26
- "./voice": "./src/voice/index.ts",
27
- "./rag": "./src/rag/index.ts",
28
- "./memory": "./src/memory/index.ts",
29
- "./openapi": "./src/openapi/index.ts"
8
+ ".": {
9
+ "types": "./src/index.d.ts",
10
+ "import": "./src/index.js",
11
+ "default": "./src/index.js"
12
+ },
13
+ "./tools": {
14
+ "types": "./src/tools.d.ts",
15
+ "import": "./src/tools.js",
16
+ "default": "./src/tools.js"
17
+ },
18
+ "./*": {
19
+ "types": "./src/index.d.ts",
20
+ "import": "./src/*.js",
21
+ "default": "./src/*.js"
22
+ },
23
+ "./jsx-dev-runtime": {
24
+ "types": "./src/index.d.ts",
25
+ "import": "./src/jsx-runtime.js",
26
+ "default": "./src/jsx-runtime.js"
27
+ }
30
28
  },
31
29
  "files": [
32
- "src/",
33
- "docs/",
34
- "observability/",
35
- "README.md",
36
- "LICENSE"
37
- ],
38
- "engines": {
39
- "bun": ">=1.3.0"
40
- },
41
- "repository": {
42
- "type": "git",
43
- "url": "git+https://github.com/evmts/smithers.git"
44
- },
45
- "homepage": "https://github.com/evmts/smithers#readme",
46
- "bugs": {
47
- "url": "https://github.com/evmts/smithers/issues"
48
- },
49
- "keywords": [
50
- "ai",
51
- "agent",
52
- "react",
53
- "jsx",
54
- "llm",
55
- "claude",
56
- "orchestration",
57
- "workflow",
58
- "bun"
30
+ "src/"
59
31
  ],
60
- "scripts": {
61
- "typecheck": "tsc --noEmit",
62
- "typecheck:examples": "tsc -p tsconfig.examples.json --noEmit",
63
- "lint": "oxlint --react-plugin --node-plugin --import-plugin --ignore-path .gitignore src tests apps/cli/src",
64
- "lint:fix": "oxlint --react-plugin --node-plugin --import-plugin --ignore-path .gitignore --fix src tests apps/cli/src",
65
- "cli": "bun run src/cli/index.ts",
66
- "test": "bash ./scripts/run-all-tests.sh",
67
- "e2e": "playwright test",
68
- "docs": "cd docs && bunx mintlify dev"
69
- },
70
32
  "dependencies": {
71
- "@ai-sdk/anthropic": "^3.0.36",
72
- "@ai-sdk/openai": "^3.0.41",
73
- "@effect/cluster": "^0.58.0",
74
- "@effect/opentelemetry": "^0.61.0",
75
- "@effect/platform": "^0.96.0",
76
- "@effect/platform-bun": "^0.89.0",
77
- "@effect/rpc": "^0.75.0",
78
- "@effect/sql": "^0.51.0",
79
- "@effect/sql-sqlite-bun": "^0.52.0",
80
- "@effect/workflow": "^0.18.0",
81
- "@mariozechner/pi-coding-agent": "0.63.1",
82
- "@mariozechner/pi-tui": "0.63.1",
83
- "@mdx-js/esbuild": "^3.1.1",
84
- "@modelcontextprotocol/sdk": "^1.27.0",
85
- "@opentelemetry/api": "^1.9.0",
86
- "@opentelemetry/exporter-metrics-otlp-http": "^0.213.0",
87
- "@opentelemetry/exporter-trace-otlp-http": "^0.213.0",
88
- "@opentelemetry/resources": "^2.6.0",
89
- "@opentelemetry/sdk-logs": "^0.213.0",
90
- "@opentelemetry/sdk-metrics": "^2.6.0",
91
- "@opentelemetry/sdk-trace-base": "^2.6.0",
92
- "@opentelemetry/sdk-trace-node": "^2.6.0",
93
- "@opentelemetry/semantic-conventions": "^1.40.0",
94
- "@opentui/core": "^0.1.92",
95
- "@opentui/react": "^0.1.92",
96
- "@sinclair/typebox": "0.34.49",
97
- "@types/react-dom": "^19.2.3",
98
- "@types/react-reconciler": "^0.28.9",
99
33
  "ai": "^6.0.69",
100
- "bippy": "^0.5.32",
101
- "cron-parser": "^5.5.0",
102
34
  "diff": "^5.2.0",
103
- "drizzle-orm": "^0.45.1",
104
- "drizzle-zod": "^0.8.3",
105
- "effect": "^3.21.0",
106
- "hono": "^4.12.8",
107
- "incur": "^0.3.3",
108
- "react": "^19.2.4",
109
- "react-dom": "^19.2.4",
110
- "react-reconciler": "^0.31.0",
111
- "picocolors": "^1.1.1",
112
- "ws": "^8.18.0",
113
- "zod": "^4.3.6"
114
- },
115
- "peerDependencies": {
116
- "typescript": "~5.9.3"
35
+ "zod": "^4.3.6",
36
+ "@smithers-orchestrator/agents": "0.16.0",
37
+ "@smithers-orchestrator/driver": "0.16.0",
38
+ "@smithers-orchestrator/engine": "0.16.0",
39
+ "@smithers-orchestrator/errors": "0.16.0",
40
+ "@smithers-orchestrator/db": "0.16.0",
41
+ "@smithers-orchestrator/memory": "0.16.0",
42
+ "@smithers-orchestrator/graph": "0.16.0",
43
+ "@smithers-orchestrator/observability": "0.16.0",
44
+ "@smithers-orchestrator/openapi": "0.16.0",
45
+ "@smithers-orchestrator/components": "0.16.0",
46
+ "@smithers-orchestrator/react-reconciler": "0.16.0",
47
+ "@smithers-orchestrator/sandbox": "0.16.0",
48
+ "@smithers-orchestrator/scheduler": "0.16.0",
49
+ "@smithers-orchestrator/scorers": "0.16.0",
50
+ "@smithers-orchestrator/server": "0.16.0",
51
+ "@smithers-orchestrator/vcs": "0.16.0",
52
+ "@smithers-orchestrator/time-travel": "0.16.0"
117
53
  },
118
54
  "devDependencies": {
119
- "@playwright/test": "^1.52.0",
120
- "@tanstack/react-query": "^5.96.2",
121
55
  "@types/bun": "latest",
122
- "@types/diff": "^5.2.0",
123
- "@types/react": "^19.2.10",
124
- "@types/ws": "^8.5.12",
125
- "oxlint": "^1.59.0",
126
56
  "typescript": "~5.9.3"
57
+ },
58
+ "scripts": {
59
+ "typecheck": "tsc -p tsconfig.json --noEmit",
60
+ "build": "tsup --dts-only"
127
61
  }
128
- }
62
+ }
@@ -0,0 +1,62 @@
1
+ import type React from "react";
2
+ import type { BunSQLiteDatabase } from "drizzle-orm/bun-sqlite";
3
+ import type {
4
+ Sequence as BaseSequence,
5
+ Parallel as BaseParallel,
6
+ MergeQueue as BaseMergeQueue,
7
+ Branch as BaseBranch,
8
+ Loop as BaseLoop,
9
+ Ralph as BaseRalph,
10
+ ContinueAsNew as BaseContinueAsNew,
11
+ continueAsNew as baseContinueAsNew,
12
+ Worktree as BaseWorktree,
13
+ Timer as BaseTimer,
14
+ } from "@smithers-orchestrator/components";
15
+ import type { ApprovalProps } from "@smithers-orchestrator/components/components/ApprovalProps";
16
+ import type { DepsSpec } from "@smithers-orchestrator/components/components/DepsSpec";
17
+ import type { SandboxProps } from "@smithers-orchestrator/components/components/SandboxProps";
18
+ import type { SignalProps } from "@smithers-orchestrator/components/components/SignalProps";
19
+ import type { TaskProps } from "@smithers-orchestrator/components/components/TaskProps";
20
+ import type { WorkflowProps } from "@smithers-orchestrator/components/components/WorkflowProps";
21
+ import type { SmithersWorkflow } from "@smithers-orchestrator/components/SmithersWorkflow";
22
+ import type { SmithersWorkflowOptions } from "@smithers-orchestrator/scheduler/SmithersWorkflowOptions";
23
+ import type { SmithersCtx } from "@smithers-orchestrator/driver/SmithersCtx";
24
+ import type { z } from "zod";
25
+
26
+ /** Union of all Zod schema values registered in the schema, constrained to ZodObject. */
27
+ type SchemaOutput<Schema> = Extract<Schema[keyof Schema], z.ZodObject<z.ZodRawShape>>;
28
+ type RuntimeSchema<Schema> = Schema extends { input: infer Input }
29
+ ? Omit<Schema, "input"> & {
30
+ input: Input extends z.ZodTypeAny ? z.infer<Input> : Input;
31
+ }
32
+ : Schema;
33
+
34
+ export type CreateSmithersApi<Schema = unknown> = {
35
+ Workflow: (props: WorkflowProps) => React.ReactElement;
36
+ Approval: <Row>(props: ApprovalProps<Row, SchemaOutput<Schema>>) => React.ReactElement;
37
+ Task: <Row, D extends DepsSpec = {}>(
38
+ props: TaskProps<Row, SchemaOutput<Schema>, D>,
39
+ ) => React.ReactElement;
40
+ Sequence: typeof BaseSequence;
41
+ Parallel: typeof BaseParallel;
42
+ MergeQueue: typeof BaseMergeQueue;
43
+ Branch: typeof BaseBranch;
44
+ Loop: typeof BaseLoop;
45
+ Ralph: typeof BaseRalph;
46
+ ContinueAsNew: typeof BaseContinueAsNew;
47
+ continueAsNew: typeof baseContinueAsNew;
48
+ Worktree: typeof BaseWorktree;
49
+ Sandbox: (props: SandboxProps) => React.ReactElement;
50
+ Signal: <SignalSchema extends z.ZodObject<z.ZodRawShape>>(
51
+ props: SignalProps<SignalSchema>,
52
+ ) => React.ReactElement;
53
+ Timer: typeof BaseTimer;
54
+ useCtx: () => SmithersCtx<RuntimeSchema<Schema>>;
55
+ smithers: (
56
+ build: (ctx: SmithersCtx<RuntimeSchema<Schema>>) => React.ReactElement,
57
+ opts?: SmithersWorkflowOptions,
58
+ ) => SmithersWorkflow<RuntimeSchema<Schema>>;
59
+ db: BunSQLiteDatabase<Record<string, unknown>>;
60
+ tables: { [K in keyof Schema]: unknown };
61
+ outputs: { [K in keyof Schema]: Schema[K] };
62
+ };
@@ -0,0 +1,9 @@
1
+ import type { SmithersAlertPolicy } from "@smithers-orchestrator/scheduler/SmithersWorkflowOptions";
2
+
3
+ export type CreateSmithersOptions = {
4
+ readableName?: string;
5
+ description?: string;
6
+ alertPolicy?: SmithersAlertPolicy;
7
+ dbPath?: string;
8
+ journalMode?: string;
9
+ };
package/src/create.js ADDED
@@ -0,0 +1,384 @@
1
+ // @smithers-type-exports-begin
2
+ /**
3
+ * @template Schema
4
+ * @typedef {import("./CreateSmithersApi.ts").CreateSmithersApi<Schema>} CreateSmithersApi
5
+ */
6
+ // @smithers-type-exports-end
7
+
8
+ import { Database } from "bun:sqlite";
9
+ import { drizzle } from "drizzle-orm/bun-sqlite";
10
+ import { sqliteTable, text } from "drizzle-orm/sqlite-core";
11
+ import React from "react";
12
+ import { createSmithersContext, SmithersContext as GlobalSmithersContext } from "@smithers-orchestrator/react-reconciler/context";
13
+ import { Approval as BaseApproval, Workflow as BaseWorkflow, Task as BaseTask, Sequence as BaseSequence, Parallel as BaseParallel, MergeQueue as BaseMergeQueue, Branch as BaseBranch, Loop as BaseLoop, Ralph as BaseRalph, ContinueAsNew as BaseContinueAsNew, continueAsNew as baseContinueAsNew, Worktree as BaseWorktree, Sandbox as BaseSandbox, Signal as BaseSignal, Timer as BaseTimer, } from "@smithers-orchestrator/components";
14
+ import { zodToTable } from "@smithers-orchestrator/db/zodToTable";
15
+ import { zodToCreateTableSQL } from "@smithers-orchestrator/db/zodToCreateTableSQL";
16
+ import { camelToSnake } from "@smithers-orchestrator/db/utils/camelToSnake";
17
+ import { resolve } from "node:path";
18
+ import { SmithersError } from "@smithers-orchestrator/errors/SmithersError";
19
+ /** @typedef {import("@smithers-orchestrator/components").ApprovalProps<any, any>} ApprovalProps */
20
+ /** @typedef {import("@smithers-orchestrator/components").SandboxProps} SandboxProps */
21
+ /** @typedef {import("@smithers-orchestrator/components").SignalProps<any>} SignalProps */
22
+ /** @typedef {import("@smithers-orchestrator/scheduler/SmithersWorkflowOptions").SmithersAlertPolicy} SmithersAlertPolicy */
23
+ /** @typedef {import("@smithers-orchestrator/scheduler/SmithersWorkflowOptions").SmithersAlertPolicyDefaults} SmithersAlertPolicyDefaults */
24
+ /** @typedef {import("@smithers-orchestrator/scheduler/SmithersWorkflowOptions").SmithersAlertPolicyRule} SmithersAlertPolicyRule */
25
+ /**
26
+ * @template Schema
27
+ * @typedef {import("@smithers-orchestrator/driver/SmithersCtx").SmithersCtx<Schema>} SmithersCtx
28
+ */
29
+ /**
30
+ * @template Schema
31
+ * @typedef {import("@smithers-orchestrator/components/SmithersWorkflow").SmithersWorkflow<Schema>} SmithersWorkflow
32
+ */
33
+ /** @typedef {import("@smithers-orchestrator/scheduler/SmithersWorkflowOptions").SmithersWorkflowOptions} SmithersWorkflowOptions */
34
+ /** @typedef {import("@smithers-orchestrator/components").WorkflowProps} WorkflowProps */
35
+ /** @typedef {import("./CreateSmithersOptions.ts").CreateSmithersOptions} CreateSmithersOptions */
36
+
37
+ const hotCache = new Map();
38
+ /**
39
+ * @param {Record<string, any>} schemas
40
+ * @param {string} dbPath
41
+ * @returns {string}
42
+ */
43
+ function computeSchemaSig(schemas, dbPath) {
44
+ const parts = [dbPath];
45
+ for (const name of Object.keys(schemas).sort()) {
46
+ const tableName = camelToSnake(name);
47
+ const ddl = zodToCreateTableSQL(tableName, schemas[name]);
48
+ parts.push(`${name}:${ddl}`);
49
+ }
50
+ return parts.join("\n");
51
+ }
52
+ /**
53
+ * @param {Record<string, string>} [base]
54
+ * @param {Record<string, string>} [override]
55
+ * @returns {Record<string, string> | undefined}
56
+ */
57
+ function mergeAlertLabels(base, override) {
58
+ if (!base && !override)
59
+ return undefined;
60
+ return {
61
+ ...base,
62
+ ...override,
63
+ };
64
+ }
65
+ /**
66
+ * @param {SmithersAlertPolicyDefaults} [base]
67
+ * @param {SmithersAlertPolicyDefaults} [override]
68
+ * @returns {SmithersAlertPolicyDefaults | undefined}
69
+ */
70
+ function mergeAlertDefaults(base, override) {
71
+ if (!base && !override)
72
+ return undefined;
73
+ const merged = {
74
+ ...base,
75
+ ...override,
76
+ };
77
+ const labels = mergeAlertLabels(base?.labels, override?.labels);
78
+ if (labels)
79
+ merged.labels = labels;
80
+ return merged;
81
+ }
82
+ /**
83
+ * @param {SmithersAlertPolicyRule} [base]
84
+ * @param {SmithersAlertPolicyRule} [override]
85
+ * @returns {SmithersAlertPolicyRule | undefined}
86
+ */
87
+ function mergeAlertRule(base, override) {
88
+ if (!base && !override)
89
+ return undefined;
90
+ const merged = {
91
+ ...base,
92
+ ...override,
93
+ };
94
+ const labels = mergeAlertLabels(base?.labels, override?.labels);
95
+ if (labels)
96
+ merged.labels = labels;
97
+ return merged;
98
+ }
99
+ /**
100
+ * @param {Record<string, SmithersAlertPolicyRule>} [base]
101
+ * @param {Record<string, SmithersAlertPolicyRule>} [override]
102
+ * @returns {Record<string, SmithersAlertPolicyRule> | undefined}
103
+ */
104
+ function mergeAlertRules(base, override) {
105
+ if (!base && !override)
106
+ return undefined;
107
+ const merged = {
108
+ ...base,
109
+ };
110
+ for (const [name, rule] of Object.entries(override ?? {})) {
111
+ merged[name] = mergeAlertRule(base?.[name], rule) ?? rule;
112
+ }
113
+ return merged;
114
+ }
115
+ /**
116
+ * @param {SmithersAlertPolicy} [base]
117
+ * @param {SmithersAlertPolicy} [override]
118
+ * @returns {SmithersAlertPolicy | undefined}
119
+ */
120
+ function mergeAlertPolicies(base, override) {
121
+ if (!base && !override)
122
+ return undefined;
123
+ const merged = {};
124
+ const defaults = mergeAlertDefaults(base?.defaults, override?.defaults);
125
+ const rules = mergeAlertRules(base?.rules, override?.rules);
126
+ const reactions = base?.reactions || override?.reactions
127
+ ? {
128
+ ...base?.reactions,
129
+ ...override?.reactions,
130
+ }
131
+ : undefined;
132
+ if (defaults)
133
+ merged.defaults = defaults;
134
+ if (rules)
135
+ merged.rules = rules;
136
+ if (reactions)
137
+ merged.reactions = reactions;
138
+ return merged;
139
+ }
140
+ /**
141
+ * Schema-driven API — users define only Zod schemas, the framework owns the entire storage layer.
142
+ *
143
+ * @template {Record<string, import("zod").ZodObject<any>>} Schemas
144
+ * @param {Schemas} schemas
145
+ * @param {CreateSmithersOptions} [opts]
146
+ * @returns {import("./CreateSmithersApi.ts").CreateSmithersApi<Schemas>}
147
+ *
148
+ * @example
149
+ * ```ts
150
+ * const { Workflow, Task, smithers, outputs } = createSmithers({
151
+ * discover: discoverOutputSchema,
152
+ * research: researchOutputSchema,
153
+ * });
154
+ *
155
+ * export default smithers((ctx) => (
156
+ * <Workflow name="my-workflow">
157
+ * <Task id="discover" output={outputs.discover} agent={myAgent}>...</Task>
158
+ * </Workflow>
159
+ * ));
160
+ * ```
161
+ */
162
+ export function createSmithers(schemas, opts) {
163
+ const dbPath = opts?.dbPath ?? "./smithers.db";
164
+ const absDbPath = resolve(process.cwd(), dbPath);
165
+ if (process.env.SMITHERS_HOT === "1") {
166
+ const sig = computeSchemaSig(schemas, absDbPath);
167
+ const cached = hotCache.get(absDbPath);
168
+ if (cached) {
169
+ if (cached.schemaSig !== sig) {
170
+ throw new SmithersError("SCHEMA_CHANGE_HOT", "[smithers hot] Schema change detected; restart required to apply schema changes.");
171
+ }
172
+ cached.setModuleAlertPolicy(opts?.alertPolicy);
173
+ return cached.api;
174
+ }
175
+ // Will cache after creating the API below
176
+ }
177
+ // 1. Generate Drizzle tables from Zod schemas
178
+ const tables = {};
179
+ const inputTable = schemas.input
180
+ ? zodToTable("input", schemas.input, { isInput: true })
181
+ : sqliteTable("input", {
182
+ runId: text("run_id").primaryKey(),
183
+ payload: text("payload", { mode: "json" }).$type(),
184
+ });
185
+ for (const [name, zodSchema] of Object.entries(schemas)) {
186
+ if (name === "input")
187
+ continue;
188
+ const tableName = camelToSnake(name);
189
+ tables[name] = zodToTable(tableName, zodSchema);
190
+ }
191
+ // 2. Create SQLite db
192
+ const sqlite = new Database(dbPath);
193
+ sqlite.run(`PRAGMA journal_mode = ${opts?.journalMode ?? "WAL"}`);
194
+ // 30s timeout: concurrent worktrees each spawn agent processes that all write
195
+ // to smithers.db simultaneously. 5s is too short and causes SQLITE_IOERR_VNODE
196
+ // on macOS when the VFS can't acquire the WAL shared-memory lock in time.
197
+ sqlite.run("PRAGMA busy_timeout = 30000");
198
+ // NORMAL is safe in WAL mode (no data loss on crash) and reduces fsync
199
+ // stalls that contribute to WAL checkpoint contention across processes.
200
+ sqlite.run("PRAGMA synchronous = NORMAL");
201
+ // Ensure no exclusive lock is held, allowing multiple readers/writers.
202
+ sqlite.run("PRAGMA locking_mode = NORMAL");
203
+ sqlite.run("PRAGMA foreign_keys = ON");
204
+ // Register a process-exit hook to explicitly close the Database.
205
+ // bun:sqlite's GC finalizer calls sqlite3_close() which fatally aborts if
206
+ // Drizzle's cached prepared statements haven't been finalized first.
207
+ // Calling close() ourselves lets sqlite3 finalize everything gracefully.
208
+ let dbClosed = false;
209
+ const closeDb = () => {
210
+ if (dbClosed)
211
+ return;
212
+ dbClosed = true;
213
+ try {
214
+ sqlite.close();
215
+ }
216
+ catch { }
217
+ };
218
+ process.on("exit", closeDb);
219
+ // 3. Auto-create tables using CREATE TABLE IF NOT EXISTS
220
+ if (schemas.input) {
221
+ const inputDdl = zodToCreateTableSQL("input", schemas.input, { isInput: true });
222
+ sqlite.run(inputDdl);
223
+ }
224
+ else {
225
+ sqlite.exec(`CREATE TABLE IF NOT EXISTS "input" (run_id TEXT PRIMARY KEY, payload TEXT)`);
226
+ try {
227
+ const cols = sqlite.query(`PRAGMA table_info("input")`).all();
228
+ const hasPayload = cols.some((col) => col?.name === "payload");
229
+ if (!hasPayload) {
230
+ sqlite.run(`ALTER TABLE "input" ADD COLUMN payload TEXT`);
231
+ }
232
+ }
233
+ catch {
234
+ // ignore - older SQLite or permission issues; input payload remains best-effort
235
+ }
236
+ }
237
+ for (const [name, zodSchema] of Object.entries(schemas)) {
238
+ if (name === "input")
239
+ continue;
240
+ const tableName = camelToSnake(name);
241
+ const ddl = zodToCreateTableSQL(tableName, zodSchema);
242
+ sqlite.run(ddl);
243
+ }
244
+ // 4. Create Drizzle instance with all tables in the schema
245
+ const drizzleSchema = { input: inputTable };
246
+ for (const [key, table] of Object.entries(tables)) {
247
+ drizzleSchema[key] = table;
248
+ }
249
+ const db = drizzle(sqlite, { schema: drizzleSchema });
250
+ // 5. Build schema registry for engine resolution of string output keys
251
+ const schemaRegistry = new Map();
252
+ for (const [name, zodSchema] of Object.entries(schemas)) {
253
+ if (name === "input")
254
+ continue;
255
+ schemaRegistry.set(name, { table: tables[name], zodSchema });
256
+ }
257
+ // 6. Build reverse lookup: ZodObject reference → schema key name
258
+ const zodToKeyName = new Map();
259
+ for (const [name, zodSchema] of Object.entries(schemas)) {
260
+ if (name === "input")
261
+ continue;
262
+ zodToKeyName.set(zodSchema, name);
263
+ }
264
+ // 7. Context + hooks
265
+ const { SmithersContext: RuntimeSmithersContext, useCtx, } = createSmithersContext();
266
+ const ctxRef = { current: null };
267
+ let moduleAlertPolicy = opts?.alertPolicy;
268
+ /**
269
+ * @param {WorkflowProps} props
270
+ */
271
+ function Workflow(props) {
272
+ return React.createElement(BaseWorkflow, props, props.children);
273
+ }
274
+ /**
275
+ * @template Row
276
+ * @param {ApprovalProps<Row>} props
277
+ */
278
+ function Approval(props) {
279
+ return React.createElement(BaseApproval, {
280
+ ...props,
281
+ smithersContext: RuntimeSmithersContext,
282
+ });
283
+ }
284
+ /**
285
+ * Task wrapper that resolves ZodObject output references against the
286
+ * schema registry by reference equality, injecting the outputSchema.
287
+ */
288
+ function Task(props) {
289
+ return React.createElement(BaseTask, {
290
+ ...props,
291
+ smithersContext: RuntimeSmithersContext,
292
+ });
293
+ }
294
+ /**
295
+ * @param {SandboxProps} props
296
+ */
297
+ function Sandbox(props) {
298
+ const workflow = props.workflow ??
299
+ {
300
+ db,
301
+ build: () => React.createElement(BaseWorkflow, { name: `sandbox:${props.id}` }, props.children),
302
+ opts: {},
303
+ schemaRegistry,
304
+ zodToKeyName,
305
+ };
306
+ return React.createElement(BaseSandbox, {
307
+ ...props,
308
+ workflow,
309
+ smithersContext: RuntimeSmithersContext,
310
+ });
311
+ }
312
+ /**
313
+ * @template SignalSchema
314
+ * @param {SignalProps<SignalSchema>} props
315
+ */
316
+ function Signal(props) {
317
+ return React.createElement(BaseSignal, {
318
+ ...props,
319
+ smithersContext: RuntimeSmithersContext,
320
+ });
321
+ }
322
+ /**
323
+ * @param {(ctx: SmithersCtx<Schemas>) => React.ReactElement} build
324
+ * @param {SmithersWorkflowOptions} [smithersOpts]
325
+ * @returns {SmithersWorkflow<Schemas>}
326
+ */
327
+ function boundSmithers(build, smithersOpts) {
328
+ const workflowOpts = {
329
+ ...smithersOpts,
330
+ };
331
+ const alertPolicy = mergeAlertPolicies(moduleAlertPolicy, smithersOpts?.alertPolicy);
332
+ if (alertPolicy)
333
+ workflowOpts.alertPolicy = alertPolicy;
334
+ return {
335
+ readableName: opts?.readableName,
336
+ description: opts?.description,
337
+ db,
338
+ build: (ctx) => {
339
+ ctxRef.current = ctx;
340
+ return React.createElement(RuntimeSmithersContext.Provider, { value: ctxRef.current }, React.createElement(GlobalSmithersContext.Provider, { value: ctxRef.current }, build(ctx)));
341
+ },
342
+ opts: workflowOpts,
343
+ schemaRegistry,
344
+ zodToKeyName,
345
+ };
346
+ }
347
+ /**
348
+ * @param {SmithersAlertPolicy} [alertPolicy]
349
+ */
350
+ const setModuleAlertPolicy = (alertPolicy) => {
351
+ moduleAlertPolicy = alertPolicy;
352
+ };
353
+ const api = {
354
+ Workflow,
355
+ Approval,
356
+ Task,
357
+ Sequence: BaseSequence,
358
+ Parallel: BaseParallel,
359
+ MergeQueue: BaseMergeQueue,
360
+ Branch: BaseBranch,
361
+ Loop: BaseLoop,
362
+ Ralph: BaseRalph,
363
+ ContinueAsNew: BaseContinueAsNew,
364
+ continueAsNew: baseContinueAsNew,
365
+ Worktree: BaseWorktree,
366
+ Sandbox,
367
+ Signal,
368
+ Timer: BaseTimer,
369
+ useCtx,
370
+ smithers: boundSmithers,
371
+ db,
372
+ tables: tables,
373
+ outputs: schemas,
374
+ };
375
+ if (process.env.SMITHERS_HOT === "1") {
376
+ const sig = computeSchemaSig(schemas, absDbPath);
377
+ hotCache.set(absDbPath, {
378
+ api: api,
379
+ schemaSig: sig,
380
+ setModuleAlertPolicy,
381
+ });
382
+ }
383
+ return api;
384
+ }
@@ -0,0 +1 @@
1
+ export * from "@smithers-orchestrator/react-reconciler/dom/renderer";
@@ -0,0 +1,29 @@
1
+ // @smithers-type-exports-begin
2
+ /** @typedef {import("@smithers-orchestrator/agents/AgentLike").AgentLike} AgentLike */
3
+ /** @typedef {import("@smithers-orchestrator/components").ApprovalDecision} ApprovalDecision */
4
+ /** @typedef {import("@smithers-orchestrator/components").ApprovalProps} ApprovalProps */
5
+ /** @typedef {import("@smithers-orchestrator/components").ApprovalRequest} ApprovalRequest */
6
+ /**
7
+ * @template Schema
8
+ * @typedef {import("./CreateSmithersApi.ts").CreateSmithersApi<Schema>} CreateSmithersApi
9
+ */
10
+ /** @typedef {import("@smithers-orchestrator/components").DepsSpec} DepsSpec */
11
+ /** @typedef {import("@smithers-orchestrator/components").InferDeps} InferDeps */
12
+ /** @typedef {import("@smithers-orchestrator/components").OutputTarget} OutputTarget */
13
+ /** @typedef {import("@smithers-orchestrator/driver/SmithersCtx").SmithersCtx} SmithersCtx */
14
+ /** @typedef {import("@smithers-orchestrator/errors/SmithersError").SmithersError} SmithersError */
15
+ /**
16
+ * @template Schema
17
+ * @typedef {import("@smithers-orchestrator/components/SmithersWorkflow").SmithersWorkflow<Schema>} SmithersWorkflow
18
+ */
19
+ /** @typedef {import("@smithers-orchestrator/components").TaskProps} TaskProps */
20
+ /** @typedef {import("@smithers-orchestrator/components").WaitForEventProps} WaitForEventProps */
21
+ // @smithers-type-exports-end
22
+
23
+ export { Approval, approvalDecisionSchema, Workflow, Task, Sequence, Parallel, MergeQueue, Branch, Loop, Ralph, Worktree, } from "@smithers-orchestrator/components";
24
+ export { Timer } from "@smithers-orchestrator/components";
25
+ export { ClaudeCodeAgent } from "@smithers-orchestrator/agents/ClaudeCodeAgent";
26
+ export { KimiAgent } from "@smithers-orchestrator/agents/KimiAgent";
27
+ export { PiAgent } from "@smithers-orchestrator/agents/PiAgent";
28
+ export { createSmithers } from "./create.js";
29
+ export { runWorkflow, renderFrame } from "@smithers-orchestrator/engine";