/** * runFlow / resumeFlow — CLI entry helpers for the flow connector. * * Moved from `runner/src/runner.ts` to `factory-assets/connectors/flow/run-flow.ts` * in Phase 3 of the flow-connector extraction (2026-05-08). Behaviour is * byte-identical to the previous runner-side implementation; only the log * source changes from `runner:flow:` to `flow-connector:run:`. * * The runner re-exports these symbols with a deprecation warning for one * release. CLI consumers should switch to * `import { runFlow, resumeFlow } from "@skaile/workspaces/factory-assets/connectors/flow/run-flow"`. * * Internal runner helpers (FlowOrchestrator, bootstrapRunnerLogStore, * createAgentSession, resolveDriverPaths, session helpers) are loaded lazily * via dynamic `await import("@skaile/workspaces/runner")` inside * `loadRunnerModule()` below. The lazy load avoids a static package-level * cycle (runner → connectors → factory-assets → runner) — the cycle exists at * the workspace level but never resolves at module-load time because * factory-assets only ever calls `import` from inside an async function body. * The string-literal specifier preserves `bun --compile` and tsup static * analysis. */ import type { AgentEvent } from "@skaile/workspaces/bridge"; /** Type-only re-export of SessionState so the runner tombstone shim still works. */ export type SessionState = import("@skaile/workspaces/runner").SessionState; /** * Options for {@link runFlow}. * * Wraps `FlowOrchestrator` with autonomous mode turned on by default. First-class * gate nodes remain mandatory human decisions in every mode. * * @docLink packages/factory-assets/flow#run-flow */ export interface RunOptions { /** The working directory for the project being orchestrated. */ projectDir: string; /** Absolute path to the `.flow.yaml` or `.flow.json` definition file. */ flowPath: string; /** * Directory containing `agent.yaml`, `SOUL.md`, `RULES.md`, `knowledge/`. * Resolved from `skaile.yaml` via `resolveAgentDir` when absent. */ agentDir?: string; /** * Agent driver backend. Defaults to `settings.driver` (`"omp"` or `"claude-sdk"`). */ driver?: string; /** * LLM provider override (e.g. `"anthropic"`, `"openrouter"`). * Falls back to `settings.provider` when absent. */ provider?: string; /** * Model name override. Falls back to `settings.model` when absent. */ model?: string; /** * Path to a specific `settings.json` to load instead of the default * layered resolution chain (project → parent → global → built-in defaults). */ settingsFile?: string; /** * When `true`, prints the initial flow state without starting the agent * and returns immediately. */ dryRun?: boolean; /** * Per-session timeout in milliseconds. Defaults to * {@link DEFAULT_SESSION_TIMEOUT_MS} (4 hours). */ sessionTimeoutMs?: number; /** Optional human-readable label shown in the session list. */ sessionLabel?: string; /** Autonomous mode for CLI runs. Defaults to true; first-class gate nodes are never bypassed. */ autonomousMode?: boolean; /** * Called for each {@link AgentEvent} emitted during the run * (e.g. `text`, `tool_call`, `state_changed`). */ onEvent?: (event: AgentEvent) => void; /** * Called for each diagnostic log line. Defaults to `process.stdout`. */ onLog?: (line: string) => void; } /** * Options for resuming an existing CLI session. * * Reconnects the driver's conversation thread (conversation history is * preserved via the stored `driverSessionId`) but restarts flow execution * from scratch — flow state is not persisted in CLI mode. For governed, * resumable flow runs use a host that persists flow state (e.g. the Skaile * platform). * * @docLink packages/factory-assets/flow#resume-flow */ export interface ResumeOptions { /** The working directory for the project being orchestrated. */ projectDir: string; /** * Specific run ID to resume. When absent, the current session pointer * at `/.skaile/current` is used. */ sessionId?: string; /** * Agent definition directory override. Defaults to the directory stored * in the session file. */ agentDir?: string; /** * When `true`, prints the initial flow state without starting the agent * and returns immediately. */ dryRun?: boolean; /** * Per-session timeout in milliseconds. Defaults to * {@link DEFAULT_SESSION_TIMEOUT_MS} (4 hours). */ sessionTimeoutMs?: number; /** * Called for each {@link AgentEvent} emitted during the run. */ onEvent?: RunOptions["onEvent"]; /** * Called for each diagnostic log line. Defaults to `process.stdout`. */ onLog?: RunOptions["onLog"]; } /** * Start a new flow session from the CLI. * * Wraps `FlowOrchestrator` with autonomous mode turned on by default. The * runner remains idle between turns; first-class gates always park for a human * decision, including in autonomous mode. Non-CLI hosts (Skaile platform, * Pichi) use the orchestrator directly via the serve command surface and drive * gates through user actions. * * @docLink packages/factory-assets/flow#run-flow */ export declare function runFlow(opts: RunOptions): Promise; /** * Resume an existing session from the CLI. * * With the Phase 2 turn-based model, flow state is NOT persisted to * local session files — only the driver session ID is kept. The CLI * can resume the agent's conversation thread, but the flow execution * itself starts from scratch because the runner has no durable store * for per-run state. * * For a governed, resumable flow run, use a host that persists flow * state (e.g. the Skaile platform). CLI resume is retained as a * driver-level convenience only: we load the session, restart the * flow, and the SDK will reconnect to the prior conversation thread. * * @docLink packages/factory-assets/flow#resume-flow */ export declare function resumeFlow(opts: ResumeOptions): Promise; /** * Resolve one flow identity through the CLI/serve host's normal lookup order — * the same roots and filenames `skaile run` and `flow list` use, via * {@link flowLookupRoots} / {@link findFlowFileInRoots}. Resolution is by the * **declared** `id`, not by filename. * * @throws {Error} When `flowId` is not a canonical asset name, when no file * declares it, or when a match somehow resolves outside every lookup root. */ export declare function resolveFlowPath(flowId: string, projectDir: string): string; //# sourceMappingURL=run-flow.d.ts.map