@bastani/atomic 0.5.2 → 0.5.3-1

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 (57) hide show
  1. package/dist/chunk-1gb5qxz9.js +1 -0
  2. package/dist/chunk-fdk7tact.js +417 -0
  3. package/dist/chunk-mn870nrv.js +982 -0
  4. package/dist/sdk/components/color-utils.d.ts +3 -0
  5. package/dist/sdk/components/connectors.d.ts +14 -0
  6. package/dist/sdk/components/connectors.test.d.ts +1 -0
  7. package/dist/sdk/components/edge.d.ts +3 -0
  8. package/dist/sdk/components/error-boundary.d.ts +22 -0
  9. package/dist/sdk/components/graph-theme.d.ts +16 -0
  10. package/dist/sdk/components/header.d.ts +2 -0
  11. package/dist/sdk/components/layout.d.ts +26 -0
  12. package/dist/sdk/components/layout.test.d.ts +1 -0
  13. package/dist/sdk/components/node-card.d.ts +8 -0
  14. package/dist/sdk/components/orchestrator-panel-contexts.d.ts +15 -0
  15. package/dist/sdk/components/orchestrator-panel-store.d.ts +35 -0
  16. package/dist/sdk/components/orchestrator-panel-store.test.d.ts +1 -0
  17. package/dist/sdk/components/orchestrator-panel-types.d.ts +16 -0
  18. package/dist/sdk/components/orchestrator-panel.d.ts +51 -0
  19. package/dist/sdk/components/session-graph-panel.d.ts +6 -0
  20. package/dist/sdk/components/status-helpers.d.ts +5 -0
  21. package/dist/sdk/components/statusline.d.ts +6 -0
  22. package/dist/sdk/define-workflow.d.ts +77 -0
  23. package/dist/sdk/define-workflow.test.d.ts +1 -0
  24. package/dist/sdk/errors.d.ts +21 -0
  25. package/dist/sdk/index.d.ts +12 -0
  26. package/dist/sdk/index.js +52 -0
  27. package/dist/sdk/providers/claude.d.ts +159 -0
  28. package/dist/sdk/providers/copilot.d.ts +14 -0
  29. package/dist/sdk/providers/opencode.d.ts +14 -0
  30. package/dist/sdk/runtime/discovery.d.ts +31 -0
  31. package/dist/sdk/runtime/executor-entry.d.ts +10 -0
  32. package/dist/sdk/runtime/executor.d.ts +61 -0
  33. package/dist/sdk/runtime/executor.test.d.ts +1 -0
  34. package/dist/sdk/runtime/graph-inference.d.ts +34 -0
  35. package/dist/sdk/runtime/loader.d.ts +72 -0
  36. package/dist/sdk/runtime/panel.d.ts +8 -0
  37. package/dist/sdk/runtime/theme.d.ts +27 -0
  38. package/dist/sdk/runtime/tmux.d.ts +191 -0
  39. package/dist/sdk/types.d.ts +214 -0
  40. package/dist/sdk/workflows/builtin/ralph/claude/index.d.ts +13 -0
  41. package/dist/sdk/workflows/builtin/ralph/claude/index.js +95 -0
  42. package/dist/sdk/workflows/builtin/ralph/copilot/index.d.ts +13 -0
  43. package/dist/sdk/workflows/builtin/ralph/copilot/index.js +118 -0
  44. package/dist/sdk/workflows/builtin/ralph/helpers/git.d.ts +16 -0
  45. package/dist/sdk/workflows/builtin/ralph/helpers/prompts.d.ts +118 -0
  46. package/dist/sdk/workflows/builtin/ralph/helpers/review.d.ts +19 -0
  47. package/dist/sdk/workflows/builtin/ralph/opencode/index.d.ts +13 -0
  48. package/dist/sdk/workflows/builtin/ralph/opencode/index.js +147 -0
  49. package/dist/sdk/workflows/index.d.ts +24 -0
  50. package/dist/sdk/workflows/index.js +94 -0
  51. package/package.json +33 -6
  52. package/src/commands/cli/init/index.ts +1 -101
  53. package/src/commands/cli/workflow.ts +4 -14
  54. package/src/sdk/runtime/executor.ts +2 -2
  55. package/src/services/system/auto-sync.ts +45 -30
  56. package/src/services/system/install-ui.ts +115 -45
  57. package/src/theme/logo.ts +112 -0
@@ -0,0 +1,3 @@
1
+ export declare function hexToRgb(hex: string): [number, number, number];
2
+ export declare function rgbToHex(r: number, g: number, b: number): string;
3
+ export declare function lerpColor(a: string, b: string, t: number): string;
@@ -0,0 +1,14 @@
1
+ import type { GraphTheme } from "./graph-theme.js";
2
+ import { type LayoutNode } from "./layout.js";
3
+ export interface ConnectorResult {
4
+ text: string;
5
+ col: number;
6
+ row: number;
7
+ width: number;
8
+ height: number;
9
+ color: string;
10
+ }
11
+ /** Fan-out connector: one parent branching down to one or more tree children. */
12
+ export declare function buildConnector(parent: LayoutNode, rowH: Record<number, number>, theme: GraphTheme): ConnectorResult | null;
13
+ /** Fan-in connector: multiple parents converging down to a single merge child. */
14
+ export declare function buildMergeConnector(child: LayoutNode, rowH: Record<number, number>, allNodes: Record<string, LayoutNode>, theme: GraphTheme): ConnectorResult | null;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ /** @jsxImportSource @opentui/react */
2
+ import type { ConnectorResult } from "./connectors.js";
3
+ export declare function Edge({ text, col, row, width, height, color: edgeColor }: ConnectorResult): import("react").ReactNode;
@@ -0,0 +1,22 @@
1
+ /** @jsxImportSource @opentui/react */
2
+ /**
3
+ * React Error Boundary for the orchestrator panel.
4
+ *
5
+ * Catches render-time errors in the component tree and displays a
6
+ * static fallback so the rest of the TUI doesn't crash.
7
+ */
8
+ import { Component, type ReactNode, type ErrorInfo } from "react";
9
+ interface ErrorBoundaryProps {
10
+ fallback: (error: Error) => ReactNode;
11
+ children: ReactNode;
12
+ }
13
+ interface ErrorBoundaryState {
14
+ error: Error | null;
15
+ }
16
+ export declare class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
17
+ state: ErrorBoundaryState;
18
+ static getDerivedStateFromError(error: Error): ErrorBoundaryState;
19
+ componentDidCatch(error: Error, info: ErrorInfo): void;
20
+ render(): ReactNode;
21
+ }
22
+ export {};
@@ -0,0 +1,16 @@
1
+ import type { TerminalTheme } from "../runtime/theme.js";
2
+ export interface GraphTheme {
3
+ background: string;
4
+ backgroundElement: string;
5
+ text: string;
6
+ textMuted: string;
7
+ textDim: string;
8
+ primary: string;
9
+ success: string;
10
+ error: string;
11
+ warning: string;
12
+ info: string;
13
+ border: string;
14
+ borderActive: string;
15
+ }
16
+ export declare function deriveGraphTheme(t: TerminalTheme): GraphTheme;
@@ -0,0 +1,2 @@
1
+ /** @jsxImportSource @opentui/react */
2
+ export declare function Header(): import("react").ReactNode;
@@ -0,0 +1,26 @@
1
+ import type { SessionData, SessionStatus } from "./orchestrator-panel-types.js";
2
+ export declare const NODE_W = 36;
3
+ export declare const NODE_H = 4;
4
+ export declare const H_GAP = 6;
5
+ export declare const V_GAP = 3;
6
+ export declare const PAD = 3;
7
+ export interface LayoutNode {
8
+ name: string;
9
+ status: SessionStatus;
10
+ parents: string[];
11
+ error?: string;
12
+ startedAt: number | null;
13
+ endedAt: number | null;
14
+ children: LayoutNode[];
15
+ depth: number;
16
+ x: number;
17
+ y: number;
18
+ }
19
+ export interface LayoutResult {
20
+ roots: LayoutNode[];
21
+ map: Record<string, LayoutNode>;
22
+ rowH: Record<number, number>;
23
+ width: number;
24
+ height: number;
25
+ }
26
+ export declare function computeLayout(sessions: SessionData[]): LayoutResult;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ /** @jsxImportSource @opentui/react */
2
+ import { type LayoutNode } from "./layout.js";
3
+ export declare function NodeCard({ node, focused, pulsePhase, displayH, }: {
4
+ node: LayoutNode;
5
+ focused: boolean;
6
+ pulsePhase: number;
7
+ displayH: number;
8
+ }): import("react").ReactNode;
@@ -0,0 +1,15 @@
1
+ import type { PanelStore } from "./orchestrator-panel-store.js";
2
+ import type { GraphTheme } from "./graph-theme.js";
3
+ export declare const StoreContext: import("react").Context<PanelStore | null>;
4
+ export declare const ThemeContext: import("react").Context<GraphTheme | null>;
5
+ export declare const TmuxSessionContext: import("react").Context<string>;
6
+ export declare function useStore(): PanelStore;
7
+ export declare function useGraphTheme(): GraphTheme;
8
+ /**
9
+ * Subscribe to the store and return its current version.
10
+ *
11
+ * Uses `useSyncExternalStore` so the subscription is active from the
12
+ * very first render — no `useEffect` timing gap that could cause a
13
+ * missed `addSession` update.
14
+ */
15
+ export declare function useStoreVersion(store: PanelStore): number;
@@ -0,0 +1,35 @@
1
+ import type { SessionData, PanelSession } from "./orchestrator-panel-types.js";
2
+ type Listener = () => void;
3
+ export declare class PanelStore {
4
+ version: number;
5
+ workflowName: string;
6
+ agent: string;
7
+ prompt: string;
8
+ sessions: SessionData[];
9
+ completionInfo: {
10
+ workflowName: string;
11
+ transcriptsPath: string;
12
+ } | null;
13
+ fatalError: string | null;
14
+ completionReached: boolean;
15
+ exitResolve: (() => void) | null;
16
+ abortResolve: (() => void) | null;
17
+ private listeners;
18
+ subscribe: (fn: Listener) => (() => void);
19
+ private emit;
20
+ setWorkflowInfo(name: string, agent: string, sessions: PanelSession[], prompt: string): void;
21
+ startSession(name: string): void;
22
+ completeSession(name: string): void;
23
+ failSession(name: string, error: string): void;
24
+ addSession(session: SessionData): void;
25
+ setCompletion(workflowName: string, transcriptsPath: string): void;
26
+ setFatalError(message: string): void;
27
+ /** Safely invoke exitResolve at most once, guarding against rapid repeated calls. */
28
+ resolveExit(): void;
29
+ /** Safely invoke abortResolve at most once to signal mid-execution quit. */
30
+ resolveAbort(): void;
31
+ /** Quit the workflow — routes to the correct handler based on current phase. */
32
+ requestQuit(): void;
33
+ markCompletionReached(): void;
34
+ }
35
+ export {};
@@ -0,0 +1,16 @@
1
+ export type SessionStatus = "pending" | "running" | "complete" | "error";
2
+ export interface PanelSession {
3
+ name: string;
4
+ parents: string[];
5
+ }
6
+ export interface PanelOptions {
7
+ tmuxSession: string;
8
+ }
9
+ export interface SessionData {
10
+ name: string;
11
+ status: SessionStatus;
12
+ parents: string[];
13
+ error?: string;
14
+ startedAt: number | null;
15
+ endedAt: number | null;
16
+ }
@@ -0,0 +1,51 @@
1
+ /** @jsxImportSource @opentui/react */
2
+ /**
3
+ * OrchestratorPanel — public API class that bridges the imperative
4
+ * executor interface with the React-based session graph TUI.
5
+ */
6
+ import { type CliRenderer } from "@opentui/core";
7
+ import type { PanelSession, PanelOptions } from "./orchestrator-panel-types.js";
8
+ export declare class OrchestratorPanel {
9
+ private store;
10
+ private renderer;
11
+ private destroyed;
12
+ private constructor();
13
+ /**
14
+ * Create a new OrchestratorPanel with the default CLI renderer.
15
+ *
16
+ * This is the primary entry point — it initialises the terminal renderer
17
+ * and mounts the React-based session graph TUI.
18
+ */
19
+ static create(options: PanelOptions): Promise<OrchestratorPanel>;
20
+ /** Create with an externally-provided renderer (e.g. a test renderer). */
21
+ static createWithRenderer(renderer: CliRenderer, options: PanelOptions): OrchestratorPanel;
22
+ /**
23
+ * Display the workflow overview in the TUI — name, agent, session graph,
24
+ * and the user prompt. Call once after construction before sessions start.
25
+ */
26
+ showWorkflowInfo(name: string, agent: string, sessions: PanelSession[], prompt: string): void;
27
+ /** Mark a session as running in the graph UI. */
28
+ sessionStart(name: string): void;
29
+ /** Mark a session as successfully completed in the graph UI. */
30
+ sessionSuccess(name: string): void;
31
+ /** Mark a session as failed in the graph UI and display the error message. */
32
+ sessionError(name: string, message: string): void;
33
+ /** Dynamically add a new session node to the graph UI. */
34
+ addSession(name: string, parents: string[]): void;
35
+ /** Show the workflow-complete banner with a link to saved transcripts. */
36
+ showCompletion(workflowName: string, transcriptsPath: string): void;
37
+ /** Display a fatal error banner in the TUI. */
38
+ showFatalError(message: string): void;
39
+ /**
40
+ * Block until the user presses `q` or `Ctrl+C` in the TUI.
41
+ * Call after {@link showCompletion} or {@link showFatalError}.
42
+ */
43
+ waitForExit(): Promise<void>;
44
+ /**
45
+ * Returns a promise that resolves when the user requests a mid-execution quit
46
+ * (via `q` or `Ctrl+C`). Race this against the workflow run.
47
+ */
48
+ waitForAbort(): Promise<void>;
49
+ /** Tear down the terminal renderer and release resources. Idempotent. */
50
+ destroy(): void;
51
+ }
@@ -0,0 +1,6 @@
1
+ /** @jsxImportSource @opentui/react */
2
+ /**
3
+ * Main graph component — renders the navigable session tree with
4
+ * keyboard navigation, scroll management, and live animations.
5
+ */
6
+ export declare function SessionGraphPanel(): import("react").ReactNode;
@@ -0,0 +1,5 @@
1
+ import type { GraphTheme } from "./graph-theme.js";
2
+ export declare function statusColor(status: string, theme: GraphTheme): string;
3
+ export declare function statusLabel(status: string): string;
4
+ export declare function statusIcon(status: string): string;
5
+ export declare function fmtDuration(ms: number): string;
@@ -0,0 +1,6 @@
1
+ /** @jsxImportSource @opentui/react */
2
+ import type { LayoutNode } from "./layout.js";
3
+ export declare function Statusline({ focusedNode, attachMsg, }: {
4
+ focusedNode: LayoutNode | undefined;
5
+ attachMsg: string;
6
+ }): import("react").ReactNode;
@@ -0,0 +1,77 @@
1
+ /**
2
+ * Workflow Builder — defines a workflow with a single `.run()` entry point.
3
+ *
4
+ * Usage:
5
+ * defineWorkflow<"copilot">({ name: "my-workflow", description: "..." })
6
+ * .run(async (ctx) => {
7
+ * await ctx.stage({ name: "research" }, {}, {}, async (s) => { ... });
8
+ * await ctx.stage({ name: "plan" }, {}, {}, async (s) => { ... });
9
+ * })
10
+ * .compile()
11
+ */
12
+ import type { AgentType, WorkflowOptions, WorkflowContext, WorkflowDefinition } from "./types.js";
13
+ /**
14
+ * Chainable workflow builder. Records the run callback,
15
+ * then .compile() seals it into a WorkflowDefinition.
16
+ */
17
+ export declare class WorkflowBuilder<A extends AgentType = AgentType> {
18
+ /** @internal Brand for detection across package boundaries */
19
+ readonly __brand: "WorkflowBuilder";
20
+ private readonly options;
21
+ private runFn;
22
+ constructor(options: WorkflowOptions);
23
+ /**
24
+ * Set the workflow's entry point.
25
+ *
26
+ * The callback receives a {@link WorkflowContext} with `stage()` for
27
+ * spawning agent sessions, and `transcript()` / `getMessages()` for
28
+ * reading completed session outputs. Use native TypeScript control flow
29
+ * (loops, conditionals, `Promise.all()`) for orchestration.
30
+ */
31
+ run(fn: (ctx: WorkflowContext<A>) => Promise<void>): this;
32
+ /**
33
+ * Compile the workflow into a sealed WorkflowDefinition.
34
+ *
35
+ * After calling compile(), the returned object is consumed by the
36
+ * Atomic CLI runtime.
37
+ */
38
+ compile(): WorkflowDefinition<A>;
39
+ }
40
+ /**
41
+ * Entry point for defining a workflow.
42
+ *
43
+ * Pass a type parameter to narrow all context types to a specific agent:
44
+ *
45
+ * @example
46
+ * ```typescript
47
+ * import { defineWorkflow } from "@bastani/atomic/workflows";
48
+ *
49
+ * export default defineWorkflow<"copilot">({
50
+ * name: "hello",
51
+ * description: "Two-session demo",
52
+ * })
53
+ * .run(async (ctx) => {
54
+ * const describe = await ctx.stage(
55
+ * { name: "describe" },
56
+ * {},
57
+ * {},
58
+ * async (s) => {
59
+ * // s.client: CopilotClient, s.session: CopilotSession
60
+ * await s.session.sendAndWait({ prompt: s.userPrompt });
61
+ * s.save(await s.session.getMessages());
62
+ * },
63
+ * );
64
+ * await ctx.stage(
65
+ * { name: "summarize" },
66
+ * {},
67
+ * {},
68
+ * async (s) => {
69
+ * const research = await s.transcript(describe);
70
+ * // ...
71
+ * },
72
+ * );
73
+ * })
74
+ * .compile();
75
+ * ```
76
+ */
77
+ export declare function defineWorkflow<A extends AgentType = AgentType>(options: WorkflowOptions): WorkflowBuilder<A>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Typed error classes for the SDK.
3
+ *
4
+ * The SDK throws these instead of calling process.exit() or console.error().
5
+ * The CLI layer catches them and maps to user-visible output.
6
+ */
7
+ /** Thrown when a required system dependency is not found on PATH. */
8
+ export declare class MissingDependencyError extends Error {
9
+ readonly dependency: "tmux" | "psmux" | "bun";
10
+ constructor(dependency: "tmux" | "psmux" | "bun");
11
+ }
12
+ /** Thrown when a workflow file is defined but missing .compile(). */
13
+ export declare class WorkflowNotCompiledError extends Error {
14
+ readonly path: string;
15
+ constructor(path: string);
16
+ }
17
+ /** Thrown when a workflow file does not export a valid WorkflowDefinition. */
18
+ export declare class InvalidWorkflowError extends Error {
19
+ readonly path: string;
20
+ constructor(path: string);
21
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * atomic SDK
3
+ *
4
+ * Public API barrel — re-exports the SDK surface.
5
+ * CLI-only concerns (colors, prompts, process management) are not exported here.
6
+ */
7
+ export { MissingDependencyError, WorkflowNotCompiledError, InvalidWorkflowError, } from "./errors.js";
8
+ export type { AgentType, Transcript, SavedMessage, SaveTranscript, SessionContext, SessionRef, SessionHandle, SessionRunOptions, WorkflowContext, WorkflowOptions, WorkflowDefinition, StageClientOptions, StageSessionOptions, ProviderClient, ProviderSession, } from "./types.js";
9
+ export { defineWorkflow } from "./define-workflow.js";
10
+ export { discoverWorkflows, findWorkflow, } from "./runtime/discovery.js";
11
+ export { WorkflowLoader } from "./runtime/loader.js";
12
+ export { executeWorkflow } from "./runtime/executor.js";
@@ -0,0 +1,52 @@
1
+ // @bun
2
+ import {
3
+ WorkflowLoader,
4
+ defineWorkflow,
5
+ discoverWorkflows,
6
+ executeWorkflow,
7
+ findWorkflow
8
+ } from "../chunk-mn870nrv.js";
9
+
10
+ // src/sdk/errors.ts
11
+ class MissingDependencyError extends Error {
12
+ dependency;
13
+ constructor(dependency) {
14
+ super(`Required dependency not found: ${dependency}`);
15
+ this.dependency = dependency;
16
+ this.name = "MissingDependencyError";
17
+ }
18
+ }
19
+
20
+ class WorkflowNotCompiledError extends Error {
21
+ path;
22
+ constructor(path) {
23
+ super(`Workflow at ${path} was defined but not compiled.
24
+ ` + ` Add .compile() at the end of your defineWorkflow() chain:
25
+
26
+ ` + ` export default defineWorkflow({ ... })
27
+ ` + ` .run(async (ctx) => { ... })
28
+ ` + ` .compile();`);
29
+ this.path = path;
30
+ this.name = "WorkflowNotCompiledError";
31
+ }
32
+ }
33
+
34
+ class InvalidWorkflowError extends Error {
35
+ path;
36
+ constructor(path) {
37
+ super(`${path} does not export a valid WorkflowDefinition.
38
+ ` + ` Make sure it exports defineWorkflow(...).compile() as the default export.`);
39
+ this.path = path;
40
+ this.name = "InvalidWorkflowError";
41
+ }
42
+ }
43
+ export {
44
+ findWorkflow,
45
+ executeWorkflow,
46
+ discoverWorkflows,
47
+ defineWorkflow,
48
+ WorkflowNotCompiledError,
49
+ WorkflowLoader,
50
+ MissingDependencyError,
51
+ InvalidWorkflowError
52
+ };
@@ -0,0 +1,159 @@
1
+ /**
2
+ * Claude Code query abstraction.
3
+ *
4
+ * Sends a prompt to an interactive Claude Code session running in a tmux pane
5
+ * using `tmux send-keys -l --` (literal text) + `C-m` (raw carriage return).
6
+ * Verifies delivery by polling `capture-pane` and retries if needed.
7
+ *
8
+ * This is NOT headless — Claude runs as a full interactive TUI in the pane.
9
+ * We're automating keyboard input and reading pane output.
10
+ *
11
+ * Reliability hardened from oh-my-codex's sendToWorker implementation:
12
+ * - Pre-send readiness wait with exponential backoff
13
+ * - CLI-specific submit plan (Claude: 1 C-m per round)
14
+ * - Per-round capture verification (6 rounds)
15
+ * - Adaptive retry with C-u clear + retype
16
+ * - Post-submit active-task detection
17
+ * - Whitespace-collapsing normalization
18
+ */
19
+ /**
20
+ * Remove a pane from the initialized set, freeing memory.
21
+ * Call when a Claude session is killed or no longer needed.
22
+ */
23
+ export declare function clearClaudeSession(paneId: string): void;
24
+ export interface ClaudeSessionOptions {
25
+ /** tmux pane ID where Claude should be started */
26
+ paneId: string;
27
+ /** CLI flags to pass to the `claude` command (default: ["--allow-dangerously-skip-permissions", "--dangerously-skip-permissions"]) */
28
+ chatFlags?: string[];
29
+ /** Timeout in ms waiting for Claude TUI to be ready (default: 30s) */
30
+ readyTimeoutMs?: number;
31
+ }
32
+ /**
33
+ * Start Claude Code in a tmux pane with configurable CLI flags.
34
+ *
35
+ * Must be called before any `claudeQuery()` calls targeting the same pane.
36
+ * The pane should be a bare shell — `createClaudeSession` sends the `claude`
37
+ * command with the given flags and waits for the TUI to become ready.
38
+ *
39
+ * @example
40
+ * ```typescript
41
+ * import { createClaudeSession, claudeQuery } from "@bastani/atomic/workflows";
42
+ *
43
+ * await createClaudeSession({ paneId: ctx.paneId });
44
+ * await claudeQuery({ paneId: ctx.paneId, prompt: "Describe this project" });
45
+ * ```
46
+ *
47
+ * @example
48
+ * ```typescript
49
+ * // With custom flags
50
+ * await createClaudeSession({
51
+ * paneId: ctx.paneId,
52
+ * chatFlags: ["--model", "opus", "--dangerously-skip-permissions"],
53
+ * });
54
+ * ```
55
+ */
56
+ export declare function createClaudeSession(options: ClaudeSessionOptions): Promise<void>;
57
+ export interface ClaudeQueryOptions {
58
+ /** tmux pane ID where Claude is running */
59
+ paneId: string;
60
+ /** The prompt to send */
61
+ prompt: string;
62
+ /** Timeout in ms waiting for Claude to finish responding (default: 300s) */
63
+ timeoutMs?: number;
64
+ /** Polling interval in ms (default: 2000) */
65
+ pollIntervalMs?: number;
66
+ /** Number of C-m presses per submit round (default: 1 for Claude) */
67
+ submitPresses?: number;
68
+ /** Max submit rounds if text isn't consumed (default: 6) */
69
+ maxSubmitRounds?: number;
70
+ /** Timeout in ms waiting for pane to be ready before sending (default: 30s) */
71
+ readyTimeoutMs?: number;
72
+ }
73
+ export interface ClaudeQueryResult {
74
+ /** The full pane content after the response completed */
75
+ output: string;
76
+ /** Whether delivery was confirmed (text disappeared from input) */
77
+ delivered: boolean;
78
+ }
79
+ /**
80
+ * Send a prompt to a Claude Code interactive session running in a tmux pane.
81
+ *
82
+ * Flow (hardened from OMX's sendToWorker):
83
+ * 1. Wait for pane readiness with exponential backoff
84
+ * 2. Capture pane content before sending
85
+ * 3. Send literal text via `send-keys -l --`
86
+ * 4. Submit with C-m rounds and per-round capture verification
87
+ * 5. Adaptive retry: clear line (C-u), re-type, re-submit
88
+ * 6. Post-submit verification via active-task detection
89
+ * 7. Wait for response by polling for output stabilization + prompt return
90
+ *
91
+ * @example
92
+ * ```typescript
93
+ * import { claudeQuery } from "@bastani/atomic/workflows";
94
+ *
95
+ * const result = await claudeQuery({
96
+ * paneId: ctx.paneId,
97
+ * prompt: "Describe this project",
98
+ * });
99
+ * ctx.log(result.output);
100
+ * ```
101
+ */
102
+ export declare function claudeQuery(options: ClaudeQueryOptions): Promise<ClaudeQueryResult>;
103
+ /**
104
+ * Default query options the user can set per-stage via the `sessionOpts` arg.
105
+ * These become defaults for every `s.session.query()` call within that stage.
106
+ */
107
+ export interface ClaudeQueryDefaults {
108
+ /** Timeout in ms waiting for Claude to finish responding (default: 300s) */
109
+ timeoutMs?: number;
110
+ /** Polling interval in ms (default: 2000) */
111
+ pollIntervalMs?: number;
112
+ /** Number of C-m presses per submit round (default: 1) */
113
+ submitPresses?: number;
114
+ /** Max submit rounds if text isn't consumed (default: 6) */
115
+ maxSubmitRounds?: number;
116
+ /** Timeout in ms waiting for pane to be ready before sending (default: 30s) */
117
+ readyTimeoutMs?: number;
118
+ }
119
+ /**
120
+ * Synthetic client wrapper for Claude stages.
121
+ * Auto-starts the Claude CLI in the tmux pane during `start()`.
122
+ */
123
+ export declare class ClaudeClientWrapper {
124
+ readonly paneId: string;
125
+ private readonly opts;
126
+ constructor(paneId: string, opts?: {
127
+ chatFlags?: string[];
128
+ readyTimeoutMs?: number;
129
+ });
130
+ /** Start the Claude CLI in the tmux pane. Called by the runtime during init. */
131
+ start(): Promise<void>;
132
+ /** Noop — cleanup is handled by the runtime via `clearClaudeSession`. */
133
+ stop(): Promise<void>;
134
+ }
135
+ /**
136
+ * Synthetic session wrapper for Claude stages.
137
+ * Wraps `claudeQuery()` so users call `s.session.query(prompt)`.
138
+ */
139
+ export declare class ClaudeSessionWrapper {
140
+ readonly paneId: string;
141
+ readonly sessionId: string;
142
+ private readonly defaults;
143
+ constructor(paneId: string, sessionId: string, defaults?: ClaudeQueryDefaults);
144
+ /** Send a prompt to Claude and wait for the response. */
145
+ query(prompt: string, opts?: Partial<ClaudeQueryDefaults>): Promise<ClaudeQueryResult>;
146
+ /** Noop — for API symmetry with CopilotSession.disconnect(). */
147
+ disconnect(): Promise<void>;
148
+ }
149
+ export interface ClaudeValidationWarning {
150
+ rule: string;
151
+ message: string;
152
+ }
153
+ /**
154
+ * Validate a Claude workflow source file for common mistakes.
155
+ *
156
+ * Warns on direct usage of createClaudeSession/claudeQuery — the runtime
157
+ * now handles init/cleanup automatically via s.client and s.session.
158
+ */
159
+ export declare function validateClaudeWorkflow(source: string): ClaudeValidationWarning[];
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Copilot workflow source validation.
3
+ *
4
+ * Checks that Copilot workflow source files use the runtime-managed
5
+ * `s.client` and `s.session` instead of manual SDK client creation.
6
+ */
7
+ export interface CopilotValidationWarning {
8
+ rule: string;
9
+ message: string;
10
+ }
11
+ /**
12
+ * Validate a Copilot workflow source file for common mistakes.
13
+ */
14
+ export declare function validateCopilotWorkflow(source: string): CopilotValidationWarning[];
@@ -0,0 +1,14 @@
1
+ /**
2
+ * OpenCode workflow source validation.
3
+ *
4
+ * Checks that OpenCode workflow source files use the runtime-managed
5
+ * `s.client` and `s.session` instead of manual SDK client creation.
6
+ */
7
+ export interface OpenCodeValidationWarning {
8
+ rule: string;
9
+ message: string;
10
+ }
11
+ /**
12
+ * Validate an OpenCode workflow source file for common mistakes.
13
+ */
14
+ export declare function validateOpenCodeWorkflow(source: string): OpenCodeValidationWarning[];
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Workflow discovery — finds workflow definitions from disk.
3
+ *
4
+ * Workflows are discovered from:
5
+ * 1. .atomic/workflows/<name>/<agent>/index.ts (project-local)
6
+ * 2. ~/.atomic/workflows/<name>/<agent>/index.ts (global)
7
+ *
8
+ * Project-local workflows take precedence over global ones with the same name.
9
+ */
10
+ import type { AgentType } from "../types.js";
11
+ export interface DiscoveredWorkflow {
12
+ name: string;
13
+ agent: AgentType;
14
+ path: string;
15
+ source: "local" | "global" | "builtin";
16
+ }
17
+ export declare const AGENTS: AgentType[];
18
+ /**
19
+ * Default `.gitignore` content for a workflows directory.
20
+ * Auto-generated during install; regenerated by discovery if missing.
21
+ */
22
+ export declare const WORKFLOWS_GITIGNORE: string;
23
+ /**
24
+ * Discover all available workflows from built-in, global, and local sources.
25
+ * Optionally filter by agent. Precedence: local > global > builtin.
26
+ */
27
+ export declare function discoverWorkflows(projectRoot?: string, agentFilter?: AgentType): Promise<DiscoveredWorkflow[]>;
28
+ /**
29
+ * Find a specific workflow by name and agent.
30
+ */
31
+ export declare function findWorkflow(name: string, agent: AgentType, projectRoot?: string): Promise<DiscoveredWorkflow | null>;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Orchestrator entry point — invoked inside a tmux pane by the launcher script.
3
+ *
4
+ * Separated from executor.ts to avoid the dual-module-identity problem:
5
+ * Bun evaluates a file twice when it is both the entry point (`bun run`)
6
+ * and reached through package.json `exports` self-referencing. Keeping
7
+ * the side-effectful `--run` guard here ensures executor.ts stays a pure
8
+ * library module that can be safely re-exported from the SDK barrel.
9
+ */
10
+ export {};