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.
- package/package.json +47 -113
- package/src/CreateSmithersApi.ts +62 -0
- package/src/CreateSmithersOptions.ts +9 -0
- package/src/create.js +384 -0
- package/src/dom/renderer.js +1 -0
- package/src/examples-entry.js +29 -0
- package/src/external/ExternalSmithersConfig.ts +12 -0
- package/src/external/HostNodeJson.ts +12 -0
- package/src/external/SerializedCtx.ts +9 -0
- package/src/external/create-external-smithers.js +148 -0
- package/src/external/index.js +10 -0
- package/src/gateway.js +1 -0
- package/src/ide/SmithersIdeAskUserResult.ts +7 -0
- package/src/ide/SmithersIdeAvailability.ts +17 -0
- package/src/ide/SmithersIdeCommandBaseResult.ts +7 -0
- package/src/ide/SmithersIdeOpenDiffResult.ts +5 -0
- package/src/ide/SmithersIdeOpenFileResult.ts +8 -0
- package/src/ide/SmithersIdeOpenWebviewResult.ts +7 -0
- package/src/ide/SmithersIdeOverlayOptions.ts +7 -0
- package/src/ide/SmithersIdeOverlayResult.ts +8 -0
- package/src/ide/SmithersIdeOverlayType.ts +1 -0
- package/src/ide/SmithersIdeResolvedConfig.ts +8 -0
- package/src/ide/SmithersIdeRunTerminalResult.ts +8 -0
- package/src/ide/SmithersIdeService.js +432 -0
- package/src/ide/SmithersIdeServiceApi.ts +35 -0
- package/src/ide/SmithersIdeServiceConfig.ts +8 -0
- package/src/ide/index.js +44 -0
- package/src/ide/tools.js +94 -0
- package/src/index.d.ts +408 -0
- package/src/index.js +218 -0
- package/src/jsx-runtime.js +3 -0
- package/src/mdx-plugin.js +5 -0
- package/src/memory.js +1 -0
- package/src/observability.js +1 -0
- package/src/openapi.js +1 -0
- package/src/pi-extension.js +1 -0
- package/src/pi-plugin/SmithersPiRunContext.ts +7 -0
- package/src/pi-plugin/extension.js +1970 -0
- package/src/pi-plugin/index.js +164 -0
- package/src/pi-plugin.js +1 -0
- package/src/scorers.js +1 -0
- package/src/serve.js +1 -0
- package/src/server.js +1 -0
- package/src/tools/bash.js +180 -0
- package/src/tools/context.js +29 -0
- package/src/tools/defineTool.js +69 -0
- package/src/tools/edit.js +41 -0
- package/src/tools/grep.js +33 -0
- package/src/tools/index.js +29 -0
- package/src/tools/read.js +24 -0
- package/src/tools/utils.js +181 -0
- package/src/tools/write.js +35 -0
- package/src/tools.d.ts +122 -0
- package/src/tools.js +1 -0
- package/README.md +0 -305
- package/docs/.mintignore +0 -1
- package/docs/api/effect.mdx +0 -933
- package/docs/cli/overview.mdx +0 -1444
- package/docs/cli/quickstart.mdx +0 -125
- package/docs/components/approval-gate.mdx +0 -105
- package/docs/components/approval.mdx +0 -219
- package/docs/components/aspects.mdx +0 -143
- package/docs/components/branch.mdx +0 -122
- package/docs/components/check-suite.mdx +0 -153
- package/docs/components/classify-and-route.mdx +0 -142
- package/docs/components/content-pipeline.mdx +0 -141
- package/docs/components/continue-as-new.mdx +0 -163
- package/docs/components/debate.mdx +0 -111
- package/docs/components/decision-table.mdx +0 -169
- package/docs/components/drift-detector.mdx +0 -136
- package/docs/components/escalation-chain.mdx +0 -134
- package/docs/components/gather-and-synthesize.mdx +0 -146
- package/docs/components/human-task.mdx +0 -159
- package/docs/components/kanban.mdx +0 -156
- package/docs/components/loop.mdx +0 -257
- package/docs/components/merge-queue.mdx +0 -66
- package/docs/components/optimizer.mdx +0 -137
- package/docs/components/panel.mdx +0 -146
- package/docs/components/parallel.mdx +0 -95
- package/docs/components/poller.mdx +0 -119
- package/docs/components/review-loop.mdx +0 -129
- package/docs/components/runbook.mdx +0 -169
- package/docs/components/saga.mdx +0 -161
- package/docs/components/sandbox.mdx +0 -325
- package/docs/components/scan-fix-verify.mdx +0 -137
- package/docs/components/sequence.mdx +0 -88
- package/docs/components/signal.mdx +0 -65
- package/docs/components/subflow.mdx +0 -108
- package/docs/components/super-smithers.mdx +0 -123
- package/docs/components/supervisor.mdx +0 -164
- package/docs/components/task.mdx +0 -338
- package/docs/components/timer.mdx +0 -135
- package/docs/components/try-catch-finally.mdx +0 -170
- package/docs/components/voice.mdx +0 -66
- package/docs/components/wait-for-event.mdx +0 -154
- package/docs/components/workflow.mdx +0 -93
- package/docs/components/worktree.mdx +0 -87
- package/docs/concepts/agents-and-tools.mdx +0 -293
- package/docs/concepts/approvals.mdx +0 -292
- package/docs/concepts/caching.mdx +0 -242
- package/docs/concepts/control-flow.mdx +0 -306
- package/docs/concepts/data-model.mdx +0 -365
- package/docs/concepts/evals.mdx +0 -303
- package/docs/concepts/execution-model.mdx +0 -234
- package/docs/concepts/human-in-the-loop.mdx +0 -350
- package/docs/concepts/memory.mdx +0 -230
- package/docs/concepts/openapi-tools.mdx +0 -227
- package/docs/concepts/planner-internals.mdx +0 -187
- package/docs/concepts/rag.mdx +0 -236
- package/docs/concepts/reactivity.mdx +0 -380
- package/docs/concepts/suspend-and-resume.mdx +0 -211
- package/docs/concepts/time-travel.mdx +0 -271
- package/docs/concepts/unidirectional-dataflow.mdx +0 -160
- package/docs/concepts/voice.mdx +0 -295
- package/docs/concepts/workflow-state.mdx +0 -258
- package/docs/concepts/workflows-overview.mdx +0 -238
- package/docs/design-prompts/devtools-prd.md +0 -206
- package/docs/design-prompts/hmr-design.md +0 -304
- package/docs/design-prompts/smithers-init-command-design.md +0 -835
- package/docs/design-prompts/tui-chat-design.md +0 -524
- package/docs/design-prompts/tui-chat-engineering.md +0 -629
- package/docs/design-prompts/tui-chat-prd.md +0 -138
- package/docs/design-prompts/tui-chat-tickets.md +0 -350
- package/docs/docs.json +0 -366
- package/docs/examples/agents-md.mdx +0 -54
- package/docs/examples/approval-gate.mdx +0 -153
- package/docs/examples/ci-workflow.mdx +0 -43
- package/docs/examples/claude-plugin-orchestrator.mdx +0 -77
- package/docs/examples/claude-plugin-skill.mdx +0 -71
- package/docs/examples/dynamic-plan.mdx +0 -114
- package/docs/examples/generate-llms-txt.mdx +0 -45
- package/docs/examples/hello-world.mdx +0 -49
- package/docs/examples/loop.mdx +0 -130
- package/docs/examples/multi-agent-review.mdx +0 -115
- package/docs/examples/tools-agent.mdx +0 -124
- package/docs/examples/workflow-approval.mdx +0 -81
- package/docs/examples/workflow-hello.mdx +0 -55
- package/docs/examples/workflow-quickstart.mdx +0 -90
- package/docs/examples/worktree-feature-prompts.mdx +0 -185
- package/docs/examples/worktree-feature-run-sh.mdx +0 -89
- package/docs/examples/worktree-feature-schemas.mdx +0 -169
- package/docs/examples/worktree-feature-workflow.mdx +0 -286
- package/docs/favicon.svg +0 -4
- package/docs/favicons/favicon-16x16.png +0 -0
- package/docs/favicons/favicon-32x32.png +0 -0
- package/docs/favicons/favicon.ico +0 -0
- package/docs/guides/alerting.mdx +0 -110
- package/docs/guides/best-practices.mdx +0 -380
- package/docs/guides/debugging.mdx +0 -201
- package/docs/guides/dynamic-tickets.mdx +0 -205
- package/docs/guides/error-handling.mdx +0 -318
- package/docs/guides/evals-quickstart.mdx +0 -168
- package/docs/guides/hot-reload.mdx +0 -171
- package/docs/guides/mdx-prompts.mdx +0 -195
- package/docs/guides/memory-quickstart.mdx +0 -179
- package/docs/guides/model-selection.mdx +0 -241
- package/docs/guides/monitoring-logs.mdx +0 -185
- package/docs/guides/openapi-tools-quickstart.mdx +0 -133
- package/docs/guides/patterns.mdx +0 -336
- package/docs/guides/project-structure.mdx +0 -299
- package/docs/guides/rag-quickstart.mdx +0 -145
- package/docs/guides/resumability.mdx +0 -181
- package/docs/guides/review-loop.mdx +0 -267
- package/docs/guides/structured-output.mdx +0 -169
- package/docs/guides/third-party-hooks.mdx +0 -302
- package/docs/guides/time-travel-quickstart.mdx +0 -141
- package/docs/guides/troubleshooting.mdx +0 -41
- package/docs/guides/tui.mdx +0 -364
- package/docs/guides/tutorial-workflow.mdx +0 -260
- package/docs/guides/vcs.mdx +0 -170
- package/docs/guides/voice-quickstart.mdx +0 -138
- package/docs/images/state-machine.jpg +0 -0
- package/docs/images/tui/agent-console.jpg +0 -0
- package/docs/images/tui/data-grid.jpg +0 -0
- package/docs/images/tui/inspector-chat.jpg +0 -0
- package/docs/images/tui/inspector-frames.jpg +0 -0
- package/docs/images/tui/inspector-input.jpg +0 -0
- package/docs/images/tui/inspector-logs.jpg +0 -0
- package/docs/images/tui/inspector-output.jpg +0 -0
- package/docs/images/tui/launch-workflow.jpg +0 -0
- package/docs/images/tui/runs-view.jpg +0 -0
- package/docs/images/tui/task-list.jpg +0 -0
- package/docs/images/tui/telemetry-view.jpg +0 -0
- package/docs/images/tui/triggers-view.jpg +0 -0
- package/docs/images/unidirectional-dataflow.jpg +0 -0
- package/docs/index.mdx +0 -62
- package/docs/installation.mdx +0 -59
- package/docs/integrations/cli-agents.mdx +0 -957
- package/docs/integrations/common-tools.mdx +0 -244
- package/docs/integrations/ecosystem.mdx +0 -63
- package/docs/integrations/external-workflows.mdx +0 -381
- package/docs/integrations/gateway.mdx +0 -824
- package/docs/integrations/github-bot.mdx +0 -445
- package/docs/integrations/ide.mdx +0 -519
- package/docs/integrations/integrations.mdx +0 -268
- package/docs/integrations/mcp-server.mdx +0 -709
- package/docs/integrations/pi-extension.mdx +0 -248
- package/docs/integrations/pi-integration.mdx +0 -86
- package/docs/integrations/pi-plugin.mdx +0 -310
- package/docs/integrations/sdk-agents.mdx +0 -109
- package/docs/integrations/serve.mdx +0 -219
- package/docs/integrations/server.mdx +0 -432
- package/docs/integrations/tools.mdx +0 -355
- package/docs/introduction.mdx +0 -70
- package/docs/jsx/installation.mdx +0 -113
- package/docs/jsx/overview.mdx +0 -96
- package/docs/jsx/quickstart.mdx +0 -111
- package/docs/llms-full.txt +0 -30666
- package/docs/llms.txt +0 -98
- package/docs/quickstart.mdx +0 -61
- package/docs/reference/errors.mdx +0 -218
- package/docs/reference/package-configuration.mdx +0 -158
- package/docs/reference/types.mdx +0 -941
- package/docs/reference/vcs-helpers.mdx +0 -175
- package/docs/runtime/events.mdx +0 -1226
- package/docs/runtime/render-frame.mdx +0 -222
- package/docs/runtime/revert.mdx +0 -140
- package/docs/runtime/run-workflow.mdx +0 -224
- package/observability/dashboards/smithers.json +0 -223
- package/observability/docker-compose.otel.yml +0 -47
- package/observability/grafana/dashboards/smithers-dashboard.json +0 -453
- package/observability/grafana/provisioning/dashboards/dashboards.yml +0 -12
- package/observability/grafana/provisioning/datasources/datasources.yml +0 -29
- package/observability/otel-collector-config.yml +0 -32
- package/observability/prometheus/prometheus.yml +0 -8
- package/observability/tempo/tempo.yml +0 -17
- package/src/AgentLike.ts +0 -28
- package/src/CachePolicy.ts +0 -4
- package/src/GraphSnapshot.ts +0 -9
- package/src/OutputAccessor.ts +0 -25
- package/src/OutputKey.ts +0 -1
- package/src/RetryPolicy.ts +0 -6
- package/src/RunAuthContext.ts +0 -6
- package/src/RunOptions.ts +0 -42
- package/src/RunResult.ts +0 -13
- package/src/RunStatus.ts +0 -9
- package/src/SchemaRegistryEntry.ts +0 -4
- package/src/SmithersCtx.ts +0 -89
- package/src/SmithersError.ts +0 -10
- package/src/SmithersEvent.ts +0 -564
- package/src/SmithersWorkflow.ts +0 -13
- package/src/SmithersWorkflowOptions.ts +0 -45
- package/src/TaskDescriptor.ts +0 -67
- package/src/XmlNode.ts +0 -13
- package/src/agents/AmpAgent.ts +0 -284
- package/src/agents/AnthropicAgent.ts +0 -70
- package/src/agents/BaseCliAgent.ts +0 -1848
- package/src/agents/ClaudeCodeAgent.ts +0 -593
- package/src/agents/CodexAgent.ts +0 -715
- package/src/agents/ForgeAgent.ts +0 -135
- package/src/agents/GeminiAgent.ts +0 -313
- package/src/agents/KimiAgent.ts +0 -313
- package/src/agents/OpenAIAgent.ts +0 -70
- package/src/agents/PiAgent.ts +0 -629
- package/src/agents/capability-registry.ts +0 -138
- package/src/agents/cli-capabilities.ts +0 -203
- package/src/agents/diagnostics.ts +0 -704
- package/src/agents/index.ts +0 -29
- package/src/agents/schema.ts +0 -71
- package/src/agents/sdk-shared.ts +0 -117
- package/src/aspects/AspectContext.ts +0 -87
- package/src/aspects/index.ts +0 -12
- package/src/cli/agent-contract.ts +0 -421
- package/src/cli/agent-detection.ts +0 -282
- package/src/cli/ask.ts +0 -503
- package/src/cli/chat.ts +0 -146
- package/src/cli/event-categories.ts +0 -176
- package/src/cli/find-db.ts +0 -90
- package/src/cli/format.ts +0 -274
- package/src/cli/hijack-session.ts +0 -232
- package/src/cli/hijack.ts +0 -249
- package/src/cli/index.ts +0 -4977
- package/src/cli/node-detail.ts +0 -921
- package/src/cli/resume-detached.ts +0 -43
- package/src/cli/scheduler.ts +0 -174
- package/src/cli/supervisor.ts +0 -607
- package/src/cli/tui/app.tsx +0 -195
- package/src/cli/tui/components/AskModal.tsx +0 -119
- package/src/cli/tui/components/ChatPane.tsx +0 -71
- package/src/cli/tui/components/CronList.tsx +0 -101
- package/src/cli/tui/components/DetailsPane.tsx +0 -116
- package/src/cli/tui/components/FramesPane.tsx +0 -166
- package/src/cli/tui/components/LogsPane.tsx +0 -58
- package/src/cli/tui/components/MetricsPane.tsx +0 -121
- package/src/cli/tui/components/NodeDetailView.tsx +0 -301
- package/src/cli/tui/components/NodeInspector.tsx +0 -67
- package/src/cli/tui/components/RunDetailView.tsx +0 -216
- package/src/cli/tui/components/RunsList.tsx +0 -220
- package/src/cli/tui/components/SqliteBrowser.tsx +0 -155
- package/src/cli/tui/components/WorkflowLauncher.tsx +0 -73
- package/src/cli/watch.ts +0 -129
- package/src/cli/why-diagnosis.ts +0 -1175
- package/src/cli/workflow-pack.ts +0 -2158
- package/src/cli/workflows.ts +0 -149
- package/src/components/Approval.ts +0 -254
- package/src/components/ApprovalGate.ts +0 -66
- package/src/components/Aspects.ts +0 -64
- package/src/components/Branch.ts +0 -14
- package/src/components/CheckSuite.ts +0 -108
- package/src/components/ClassifyAndRoute.ts +0 -127
- package/src/components/ContentPipeline.ts +0 -65
- package/src/components/ContinueAsNew.ts +0 -27
- package/src/components/Debate.ts +0 -115
- package/src/components/DecisionTable.ts +0 -68
- package/src/components/DriftDetector.ts +0 -90
- package/src/components/EscalationChain.ts +0 -138
- package/src/components/GatherAndSynthesize.ts +0 -122
- package/src/components/HumanTask.ts +0 -146
- package/src/components/Kanban.ts +0 -130
- package/src/components/MergeQueue.ts +0 -22
- package/src/components/Optimizer.ts +0 -94
- package/src/components/Panel.ts +0 -105
- package/src/components/Parallel.ts +0 -18
- package/src/components/Poller.ts +0 -103
- package/src/components/Ralph.ts +0 -22
- package/src/components/ReviewLoop.ts +0 -91
- package/src/components/Runbook.ts +0 -138
- package/src/components/Saga.ts +0 -112
- package/src/components/Sandbox.ts +0 -98
- package/src/components/ScanFixVerify.ts +0 -109
- package/src/components/Sequence.ts +0 -11
- package/src/components/Signal.ts +0 -70
- package/src/components/Subflow.ts +0 -62
- package/src/components/SuperSmithers.ts +0 -164
- package/src/components/Supervisor.ts +0 -146
- package/src/components/Task.ts +0 -374
- package/src/components/Timer.ts +0 -70
- package/src/components/TryCatchFinally.ts +0 -51
- package/src/components/Voice.ts +0 -27
- package/src/components/WaitForEvent.ts +0 -63
- package/src/components/Workflow.ts +0 -11
- package/src/components/Worktree.ts +0 -22
- package/src/components/control-flow-utils.ts +0 -40
- package/src/components/index.ts +0 -138
- package/src/constants.ts +0 -7
- package/src/context.ts +0 -266
- package/src/create.ts +0 -444
- package/src/db/adapter.ts +0 -2897
- package/src/db/ensure.ts +0 -17
- package/src/db/frame-codec.ts +0 -390
- package/src/db/input.ts +0 -19
- package/src/db/internal-schema.ts +0 -271
- package/src/db/output.ts +0 -285
- package/src/db/schema-signature.ts +0 -19
- package/src/db/snapshot.ts +0 -142
- package/src/db/write-retry.ts +0 -190
- package/src/devtools/SmithersDevTools.ts +0 -671
- package/src/devtools/index.ts +0 -9
- package/src/devtools/preload.ts +0 -12
- package/src/dom/extract.ts +0 -949
- package/src/dom/renderer.ts +0 -239
- package/src/effect/activity-bridge.ts +0 -158
- package/src/effect/bridge-utils.ts +0 -40
- package/src/effect/builder.ts +0 -1003
- package/src/effect/child-process.ts +0 -262
- package/src/effect/compute-task-bridge.ts +0 -897
- package/src/effect/deferred-bridge.ts +0 -72
- package/src/effect/deferred-state-bridge.ts +0 -1604
- package/src/effect/diff-bundle.ts +0 -309
- package/src/effect/durable-deferred-bridge.ts +0 -358
- package/src/effect/entity-worker.ts +0 -172
- package/src/effect/http-runner.ts +0 -114
- package/src/effect/interop.ts +0 -56
- package/src/effect/logging.ts +0 -69
- package/src/effect/metrics.ts +0 -1542
- package/src/effect/rpc-schema.ts +0 -130
- package/src/effect/runtime.ts +0 -78
- package/src/effect/sandbox-entity.ts +0 -215
- package/src/effect/single-runner.ts +0 -206
- package/src/effect/socket-runner.ts +0 -82
- package/src/effect/sql-message-storage.ts +0 -813
- package/src/effect/static-task-bridge.ts +0 -394
- package/src/effect/task-runtime.ts +0 -37
- package/src/effect/versioning.ts +0 -128
- package/src/effect/workflow-bridge.ts +0 -399
- package/src/effect/workflow-make-bridge.ts +0 -301
- package/src/engine/approvals.ts +0 -294
- package/src/engine/child-workflow.ts +0 -179
- package/src/engine/index.ts +0 -6298
- package/src/engine/scheduler.ts +0 -709
- package/src/engine/signals.ts +0 -106
- package/src/errors/tagged.ts +0 -290
- package/src/events.ts +0 -217
- package/src/examples-entry.ts +0 -35
- package/src/external/create-external-smithers.ts +0 -162
- package/src/external/index.ts +0 -6
- package/src/external/json-schema-to-zod.ts +0 -199
- package/src/external/python-subprocess.ts +0 -148
- package/src/external/python.ts +0 -66
- package/src/gateway/index.ts +0 -3134
- package/src/hot/HotWorkflowController.ts +0 -258
- package/src/hot/index.ts +0 -6
- package/src/hot/overlay.ts +0 -193
- package/src/hot/watch.ts +0 -175
- package/src/human-requests.ts +0 -120
- package/src/ide/SmithersIdeService.ts +0 -591
- package/src/ide/index.ts +0 -60
- package/src/ide/tools.ts +0 -101
- package/src/index.ts +0 -406
- package/src/jsx-runtime.ts +0 -3
- package/src/markdownComponents.ts +0 -78
- package/src/mcp/semantic-server.ts +0 -52
- package/src/mcp/semantic-tools.ts +0 -1410
- package/src/mdx-plugin.ts +0 -6
- package/src/memory/index.ts +0 -50
- package/src/memory/metrics.ts +0 -25
- package/src/memory/processors/index.ts +0 -91
- package/src/memory/schema.ts +0 -53
- package/src/memory/semantic.ts +0 -116
- package/src/memory/service.ts +0 -159
- package/src/memory/store.ts +0 -405
- package/src/memory/types.ts +0 -116
- package/src/observability/correlation.ts +0 -130
- package/src/observability/index.ts +0 -740
- package/src/openapi/index.ts +0 -27
- package/src/openapi/metrics.ts +0 -24
- package/src/openapi/ref-resolver.ts +0 -47
- package/src/openapi/schema-converter.ts +0 -235
- package/src/openapi/spec-parser.ts +0 -186
- package/src/openapi/tool-factory.ts +0 -332
- package/src/openapi/types.ts +0 -113
- package/src/pi-plugin/extension.ts +0 -1921
- package/src/pi-plugin/index.ts +0 -208
- package/src/rag/chunker.ts +0 -295
- package/src/rag/document.ts +0 -74
- package/src/rag/effect.ts +0 -45
- package/src/rag/embedder.ts +0 -84
- package/src/rag/index.ts +0 -63
- package/src/rag/metrics.ts +0 -28
- package/src/rag/pipeline.ts +0 -74
- package/src/rag/tool.ts +0 -61
- package/src/rag/types.ts +0 -103
- package/src/rag/vector-store.ts +0 -228
- package/src/renderMdx.ts +0 -26
- package/src/retry-task.ts +0 -263
- package/src/revert.ts +0 -90
- package/src/runtime-owner.ts +0 -30
- package/src/sandbox/bundle.ts +0 -326
- package/src/sandbox/execute.ts +0 -435
- package/src/sandbox/transport.ts +0 -90
- package/src/scorers/aggregate.ts +0 -107
- package/src/scorers/builtins.ts +0 -187
- package/src/scorers/create-scorer.ts +0 -120
- package/src/scorers/index.ts +0 -44
- package/src/scorers/metrics.ts +0 -24
- package/src/scorers/run-scorers.ts +0 -228
- package/src/scorers/schema.ts +0 -29
- package/src/scorers/types.ts +0 -117
- package/src/server/index.ts +0 -1355
- package/src/server/serve.ts +0 -381
- package/src/time-travel/diff.ts +0 -217
- package/src/time-travel/fork.ts +0 -284
- package/src/time-travel/index.ts +0 -89
- package/src/time-travel/metrics.ts +0 -24
- package/src/time-travel/replay.ts +0 -102
- package/src/time-travel/schema.ts +0 -62
- package/src/time-travel/snapshot.ts +0 -248
- package/src/time-travel/timeline.ts +0 -171
- package/src/time-travel/types.ts +0 -143
- package/src/time-travel/vcs-version.ts +0 -239
- package/src/timetravel.ts +0 -297
- package/src/tools/bash.ts +0 -218
- package/src/tools/context.ts +0 -46
- package/src/tools/defineTool.ts +0 -138
- package/src/tools/edit.ts +0 -75
- package/src/tools/grep.ts +0 -80
- package/src/tools/index.ts +0 -14
- package/src/tools/logToolCall.ts +0 -195
- package/src/tools/read.ts +0 -69
- package/src/tools/tools.ts +0 -8
- package/src/tools/utils.ts +0 -65
- package/src/tools/write.ts +0 -65
- package/src/types/react-dom-server.d.ts +0 -1
- package/src/unwrapZodType.ts +0 -20
- package/src/utils/camelToSnake.ts +0 -6
- package/src/utils/errors.ts +0 -632
- package/src/utils/hash.ts +0 -7
- package/src/utils/ids.ts +0 -6
- package/src/utils/input-bounds.ts +0 -333
- package/src/utils/parse.ts +0 -9
- package/src/utils/retry.ts +0 -63
- package/src/utils/time.ts +0 -3
- package/src/utils/tree-ids.ts +0 -15
- package/src/utils/xml.ts +0 -30
- package/src/vcs/find-root.ts +0 -19
- package/src/vcs/jj.ts +0 -309
- package/src/voice/ai-sdk-voice.ts +0 -122
- package/src/voice/composite.ts +0 -164
- package/src/voice/effect.ts +0 -159
- package/src/voice/index.ts +0 -28
- package/src/voice/realtime.ts +0 -798
- package/src/voice/types.ts +0 -157
- package/src/zod-to-example.ts +0 -61
- package/src/zodToCreateTableSQL.ts +0 -51
- package/src/zodToTable.ts +0 -71
package/package.json
CHANGED
|
@@ -1,128 +1,62 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "smithers-orchestrator",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
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
|
-
"
|
|
10
|
-
"smithers": "src/cli/index.ts"
|
|
11
|
-
},
|
|
6
|
+
"sideEffects": false,
|
|
12
7
|
"exports": {
|
|
13
|
-
".":
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"./
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"./
|
|
29
|
-
|
|
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
|
-
"
|
|
104
|
-
"
|
|
105
|
-
"
|
|
106
|
-
"
|
|
107
|
-
"
|
|
108
|
-
"
|
|
109
|
-
"
|
|
110
|
-
"
|
|
111
|
-
"
|
|
112
|
-
"
|
|
113
|
-
"
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
"
|
|
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";
|