import type React from "react"; import type { BunSQLiteDatabase } from "drizzle-orm/bun-sqlite"; import type { 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, Timer as BaseTimer, UI as BaseUI, TUI as BaseTUI, } from "@smthrs/components"; import type { ApprovalProps } from "@smthrs/components/components/ApprovalProps"; import type { DepsSpec } from "@smthrs/components/components/DepsSpec"; import type { SandboxProps } from "@smthrs/components/components/SandboxProps"; import type { SignalProps } from "@smthrs/components/components/SignalProps"; import type { TaskProps } from "@smthrs/components/components/TaskProps"; import type { WorkflowProps } from "@smthrs/components/components/WorkflowProps"; import type { SmithersWorkflow } from "@smthrs/components/SmithersWorkflow"; import type { SmithersWorkflowOptions } from "@smthrs/scheduler/SmithersWorkflowOptions"; import type { SmithersCtx } from "@smthrs/driver/SmithersCtx"; import type { z } from "zod"; /** Union of all Zod schema values registered in the schema, constrained to ZodObject. */ type SchemaOutput = Extract>; type RuntimeSchema = Schema extends { input: infer Input } ? Omit & { input: Input extends z.ZodTypeAny ? z.infer : Input; } : Schema; export type CreateSmithersApi = { Workflow: (props: WorkflowProps) => React.ReactElement; Approval: (props: ApprovalProps>) => React.ReactElement; Task: (props: TaskProps, D>) => React.ReactElement; Sequence: typeof BaseSequence; Parallel: typeof BaseParallel; MergeQueue: typeof BaseMergeQueue; Branch: typeof BaseBranch; Loop: typeof BaseLoop; Ralph: typeof BaseRalph; ContinueAsNew: typeof BaseContinueAsNew; continueAsNew: typeof baseContinueAsNew; Worktree: typeof BaseWorktree; Sandbox: (props: SandboxProps) => React.ReactElement; Signal: >(props: SignalProps) => React.ReactElement; Timer: typeof BaseTimer; UI: typeof BaseUI; TUI: typeof BaseTUI; useCtx: () => SmithersCtx>; smithers: ( build: (ctx: SmithersCtx>) => React.ReactElement, opts?: SmithersWorkflowOptions, ) => SmithersWorkflow>; db: BunSQLiteDatabase>; tables: { [K in keyof Schema]: unknown }; outputs: { [K in keyof Schema]: Schema[K] }; /** * Release the underlying database handle. Idempotent, and a no-op for * backends that own no closable handle. Callers that open many short-lived * databases (test fixtures above all) should call this in teardown instead * of letting handles accumulate until the process exits. * * On the sqlite backend this hands off to `sqlite3_close_v2`, which unwinds * the connection only once every prepared statement on it is finalized. * Drizzle's bun-sqlite driver leaves one unreachable statement behind per * database, so the three fds, the `-shm` mapping and the sqlite3 locking * state survive this call and are handed back on the next full garbage * collection. A caller that needs them back at a definite point — a test * suite closing fixtures in teardown — must force a collection after * closing. */ close: () => void; };