@bastani/atomic 0.5.34-0 → 0.6.0-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 (94) hide show
  1. package/README.md +329 -50
  2. package/dist/commands/cli/session.d.ts +67 -0
  3. package/dist/commands/cli/session.d.ts.map +1 -0
  4. package/dist/commands/cli/workflow-status.d.ts +63 -0
  5. package/dist/commands/cli/workflow-status.d.ts.map +1 -0
  6. package/dist/sdk/commander.d.ts +74 -0
  7. package/dist/sdk/commander.d.ts.map +1 -0
  8. package/dist/sdk/components/workflow-picker-panel.d.ts +14 -17
  9. package/dist/sdk/components/workflow-picker-panel.d.ts.map +1 -1
  10. package/dist/sdk/define-workflow.d.ts +18 -9
  11. package/dist/sdk/define-workflow.d.ts.map +1 -1
  12. package/dist/sdk/index.d.ts +4 -3
  13. package/dist/sdk/index.d.ts.map +1 -1
  14. package/dist/sdk/management-commands.d.ts +42 -0
  15. package/dist/sdk/management-commands.d.ts.map +1 -0
  16. package/dist/sdk/registry.d.ts +27 -0
  17. package/dist/sdk/registry.d.ts.map +1 -0
  18. package/dist/sdk/runtime/attached-footer.d.ts +1 -1
  19. package/dist/sdk/runtime/executor-env.d.ts +20 -0
  20. package/dist/sdk/runtime/executor-env.d.ts.map +1 -0
  21. package/dist/sdk/runtime/executor.d.ts +61 -10
  22. package/dist/sdk/runtime/executor.d.ts.map +1 -1
  23. package/dist/sdk/types.d.ts +147 -4
  24. package/dist/sdk/types.d.ts.map +1 -1
  25. package/dist/sdk/worker-shared.d.ts +42 -0
  26. package/dist/sdk/worker-shared.d.ts.map +1 -0
  27. package/dist/sdk/workflow-cli.d.ts +103 -0
  28. package/dist/sdk/workflow-cli.d.ts.map +1 -0
  29. package/dist/sdk/workflows/builtin-registry.d.ts +113 -0
  30. package/dist/sdk/workflows/builtin-registry.d.ts.map +1 -0
  31. package/dist/sdk/workflows/index.d.ts +5 -5
  32. package/dist/sdk/workflows/index.d.ts.map +1 -1
  33. package/package.json +12 -8
  34. package/src/cli.ts +85 -144
  35. package/src/commands/cli/chat/index.ts +10 -0
  36. package/src/commands/cli/workflow-command.test.ts +279 -938
  37. package/src/commands/cli/workflow-inputs.test.ts +41 -11
  38. package/src/commands/cli/workflow-inputs.ts +47 -12
  39. package/src/commands/cli/workflow-list.test.ts +234 -0
  40. package/src/commands/cli/workflow-list.ts +0 -0
  41. package/src/commands/cli/workflow.ts +11 -798
  42. package/src/scripts/constants.ts +2 -1
  43. package/src/sdk/commander.ts +161 -0
  44. package/src/sdk/components/workflow-picker-panel.tsx +78 -258
  45. package/src/sdk/define-workflow.test.ts +104 -11
  46. package/src/sdk/define-workflow.ts +47 -11
  47. package/src/sdk/errors.test.ts +16 -0
  48. package/src/sdk/index.ts +8 -8
  49. package/src/sdk/management-commands.ts +151 -0
  50. package/src/sdk/registry.ts +132 -0
  51. package/src/sdk/runtime/attached-footer.ts +1 -1
  52. package/src/sdk/runtime/executor-env.ts +45 -0
  53. package/src/sdk/runtime/executor.test.ts +37 -0
  54. package/src/sdk/runtime/executor.ts +147 -68
  55. package/src/sdk/types.ts +169 -4
  56. package/src/sdk/worker-shared.test.ts +163 -0
  57. package/src/sdk/worker-shared.ts +155 -0
  58. package/src/sdk/workflow-cli.ts +409 -0
  59. package/src/sdk/workflows/builtin/deep-research-codebase/claude/index.ts +1 -1
  60. package/src/sdk/workflows/builtin/deep-research-codebase/copilot/index.ts +1 -1
  61. package/src/sdk/workflows/builtin/deep-research-codebase/opencode/index.ts +1 -1
  62. package/src/sdk/workflows/builtin/open-claude-design/claude/index.ts +1 -1
  63. package/src/sdk/workflows/builtin/open-claude-design/copilot/index.ts +1 -1
  64. package/src/sdk/workflows/builtin/open-claude-design/opencode/index.ts +1 -1
  65. package/src/sdk/workflows/builtin/ralph/claude/index.ts +1 -1
  66. package/src/sdk/workflows/builtin/ralph/copilot/index.ts +1 -1
  67. package/src/sdk/workflows/builtin/ralph/opencode/index.ts +1 -1
  68. package/src/sdk/workflows/builtin-registry.ts +23 -0
  69. package/src/sdk/workflows/index.ts +10 -20
  70. package/src/services/system/auth.test.ts +63 -1
  71. package/.agents/skills/workflow-creator/SKILL.md +0 -334
  72. package/.agents/skills/workflow-creator/references/agent-sessions.md +0 -888
  73. package/.agents/skills/workflow-creator/references/computation-and-validation.md +0 -201
  74. package/.agents/skills/workflow-creator/references/control-flow.md +0 -470
  75. package/.agents/skills/workflow-creator/references/discovery-and-verification.md +0 -232
  76. package/.agents/skills/workflow-creator/references/failure-modes.md +0 -903
  77. package/.agents/skills/workflow-creator/references/getting-started.md +0 -275
  78. package/.agents/skills/workflow-creator/references/running-workflows.md +0 -235
  79. package/.agents/skills/workflow-creator/references/session-config.md +0 -384
  80. package/.agents/skills/workflow-creator/references/state-and-data-flow.md +0 -357
  81. package/.agents/skills/workflow-creator/references/user-input.md +0 -234
  82. package/.agents/skills/workflow-creator/references/workflow-inputs.md +0 -272
  83. package/dist/sdk/runtime/discovery.d.ts +0 -132
  84. package/dist/sdk/runtime/discovery.d.ts.map +0 -1
  85. package/dist/sdk/runtime/executor-entry.d.ts +0 -11
  86. package/dist/sdk/runtime/executor-entry.d.ts.map +0 -1
  87. package/dist/sdk/runtime/loader.d.ts +0 -70
  88. package/dist/sdk/runtime/loader.d.ts.map +0 -1
  89. package/dist/version.d.ts +0 -2
  90. package/dist/version.d.ts.map +0 -1
  91. package/src/commands/cli/workflow.test.ts +0 -317
  92. package/src/sdk/runtime/discovery.ts +0 -368
  93. package/src/sdk/runtime/executor-entry.ts +0 -18
  94. package/src/sdk/runtime/loader.ts +0 -267
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Session CLI commands — shared between `atomic chat session` and
3
+ * `atomic workflow session`, and the top-level `atomic session` picker.
4
+ *
5
+ * Wraps tmux -L atomic list-sessions / attach-session so users can
6
+ * inspect and reconnect to running atomic sessions without touching
7
+ * tmux directly.
8
+ */
9
+ import { select, confirm, isCancel } from "@clack/prompts";
10
+ import type { TmuxSession } from "../../sdk/runtime/tmux.ts";
11
+ import type { Subprocess } from "bun";
12
+ /** Scope controls which session types a command shows. */
13
+ export type SessionScope = "chat" | "workflow" | "all";
14
+ /** Injectable tmux dependencies for command functions. */
15
+ export interface SessionDeps {
16
+ isTmuxInstalled: () => boolean;
17
+ sessionExists: (name: string) => boolean;
18
+ listSessions: () => TmuxSession[];
19
+ isInsideAtomicSocket: () => boolean;
20
+ isInsideTmux: () => boolean;
21
+ switchClient: (name: string) => void;
22
+ spawnMuxAttach: (name: string) => Subprocess;
23
+ detachAndAttachAtomic: (name: string) => void;
24
+ killSession: (name: string) => void;
25
+ /** Prompt function for the session picker — defaults to @clack/prompts select. */
26
+ select: typeof select;
27
+ /** Prompt function for yes/no confirmations — defaults to @clack/prompts confirm. */
28
+ confirm: typeof confirm;
29
+ isCancel: typeof isCancel;
30
+ }
31
+ /**
32
+ * Render the session list as a printable string.
33
+ *
34
+ * Layout mirrors the workflow list style — data-first count header,
35
+ * session rows with metadata, dim footer hint.
36
+ */
37
+ export declare function renderSessionList(sessions: TmuxSession[]): string;
38
+ /** Filter sessions by scope (chat-only, workflow-only, or all). */
39
+ export declare function filterByScope(sessions: TmuxSession[], scope: SessionScope): TmuxSession[];
40
+ /** Filter sessions to only those matching at least one of the given agents. */
41
+ export declare function filterByAgent(sessions: TmuxSession[], agents: string[]): TmuxSession[];
42
+ export declare function sessionListCommand(agents?: string[], scope?: SessionScope, deps?: SessionDeps): Promise<number>;
43
+ /**
44
+ * Connect to a named session. Handles the three tmux contexts:
45
+ * already on atomic socket → switch-client, inside other tmux → detach+attach,
46
+ * outside tmux → spawn attach.
47
+ */
48
+ export declare function sessionConnectCommand(sessionName: string, deps?: SessionDeps): Promise<number>;
49
+ /**
50
+ * Show an fzf-style interactive picker for all running atomic sessions.
51
+ * Used by `atomic session connect` (no args).
52
+ */
53
+ export declare function sessionPickerCommand(agents?: string[], scope?: SessionScope, deps?: SessionDeps): Promise<number>;
54
+ /**
55
+ * Kill a named session or all sessions matching the given scope and agents.
56
+ *
57
+ * - If `sessionId` is provided: confirm and kill that one session.
58
+ * - If `sessionId` is omitted: confirm and kill all sessions in scope.
59
+ *
60
+ * Pass `yes: true` (the `-y/--yes` flag on the CLI) to skip the
61
+ * confirmation prompt — useful for orchestrating agents that need to
62
+ * tear down a workflow session non-interactively.
63
+ */
64
+ export declare function sessionKillCommand(sessionId: string | undefined, agents?: string[], scope?: SessionScope, deps?: SessionDeps, options?: {
65
+ yes?: boolean;
66
+ }): Promise<number>;
67
+ //# sourceMappingURL=session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../../src/commands/cli/session.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAU,MAAM,gBAAgB,CAAC;AAcnE,OAAO,KAAK,EAAE,WAAW,EAAe,MAAM,2BAA2B,CAAC;AAC1E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAEtC,0DAA0D;AAC1D,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,UAAU,GAAG,KAAK,CAAC;AAEvD,0DAA0D;AAC1D,MAAM,WAAW,WAAW;IAC1B,eAAe,EAAE,MAAM,OAAO,CAAC;IAC/B,aAAa,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IACzC,YAAY,EAAE,MAAM,WAAW,EAAE,CAAC;IAClC,oBAAoB,EAAE,MAAM,OAAO,CAAC;IACpC,YAAY,EAAE,MAAM,OAAO,CAAC;IAC5B,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,cAAc,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,UAAU,CAAC;IAC7C,qBAAqB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9C,WAAW,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,kFA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decide whether
4
+ * to keep waiting, surface a HIL prompt to the user, or move on.
5
+ *
6
+ * Status sources, in priority order:
7
+ * 1. <sessionDir>/status.json — written by the orchestrator on every
8
+ * panel-store mutation. Provides per-stage detail and the
9
+ * derived overall state (in_progress | error | completed |
10
+ * needs_review).
11
+ * 2. tmux liveness fallback — when status.json is missing or stale
12
+ * we still report whether the tmux session is alive so
13
+ * script-driven workflows aren't blind during the brief window
14
+ * before the orchestrator first writes its snapshot.
15
+ */
16
+ import { readSnapshot, type WorkflowOverallStatus, type WorkflowStatusSnapshot } from "../../sdk/runtime/status-writer.ts";
17
+ import type { TmuxSession } from "../../sdk/runtime/tmux.ts";
18
+ export type StatusFormat = "json" | "text";
19
+ /** A single workflow's resolved status, as returned to the caller. */
20
+ export interface WorkflowStatusReport {
21
+ /** Tmux session name (e.g. `atomic-wf-claude-ralph-a1b2c3d4`). */
22
+ id: string;
23
+ /** Workflow run id (the trailing 8-hex segment of the tmux name). */
24
+ workflowRunId: string;
25
+ /** Workflow name pulled from the snapshot. Empty when no snapshot exists. */
26
+ workflowName: string;
27
+ /** Agent backend (claude / copilot / opencode). */
28
+ agent: string;
29
+ overall: WorkflowOverallStatus;
30
+ /** True when the tmux session is currently alive on the atomic socket. */
31
+ alive: boolean;
32
+ /** ISO timestamp of the last snapshot, or null when none exists. */
33
+ updatedAt: string | null;
34
+ /** Sessions/stages, mirrored from the snapshot. Empty when no snapshot exists. */
35
+ sessions: WorkflowStatusSnapshot["sessions"];
36
+ /** Fatal-error message, if any. */
37
+ fatalError: string | null;
38
+ }
39
+ export interface StatusDeps {
40
+ isTmuxInstalled: () => boolean;
41
+ sessionExists: (name: string) => boolean;
42
+ listSessions: () => TmuxSession[];
43
+ /**
44
+ * Read a snapshot from disk. Defaults to the real reader; tests
45
+ * inject a fake to control the snapshot data without touching the
46
+ * filesystem.
47
+ */
48
+ readSnapshot: typeof readSnapshot;
49
+ /** Base directory for session dirs. Defaults to `~/.atomic/sessions`. */
50
+ sessionsBaseDir: string;
51
+ }
52
+ export interface WorkflowStatusOptions {
53
+ /** Filter to a specific workflow by tmux session name. */
54
+ id?: string;
55
+ format?: StatusFormat;
56
+ }
57
+ /**
58
+ * Top-level command. Prints either a single report (when `id` is
59
+ * provided) or the list of all workflow sessions on the atomic
60
+ * socket. Returns 1 when a requested id can't be found, 0 otherwise.
61
+ */
62
+ export declare function workflowStatusCommand(options: WorkflowStatusOptions, deps?: StatusDeps): Promise<number>;
63
+ //# sourceMappingURL=workflow-status.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workflow-status.d.ts","sourceRoot":"","sources":["../../../src/commands/cli/workflow-status.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAUH,OAAO,EACL,YAAY,EAEZ,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC5B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAE7D,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,MAAM,CAAC;AAE3C,sEAAsE;AACtE,MAAM,WAAW,oBAAoB;IACnC,kEAAkE;IAClE,EAAE,EAAE,MAAM,CAAC;IACX,qEAAqE;IACrE,aAAa,EAAE,MAAM,CAAC;IACtB,6EAA6E;IAC7E,YAAY,EAAE,MAAM,CAAC;IACrB,mDAAmD;IACnD,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,qBAAqB,CAAC;IAC/B,0EAA0E;IAC1E,KAAK,EAAE,OAAO,CAAC;IACf,oEAAoE;IACpE,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,kFAAkF;IAClF,QAAQ,EAAE,sBAAsB,CAAC,UAAU,CAAC,CAAC;IAC7C,mCAAmC;IACnC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,MAAM,WAAW,UAAU;IACzB,eAAe,EAAE,MAAM,OAAO,CAAC;IAC/B,aAAa,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IACzC,YAAY,EAAE,MAAM,WAAW,EAAE,CAAC;IAClC;;;;OAIG;IACH,YAAY,EAAE,OAAO,YAAY,CAAC;IAClC,yEAAyE;IACzE,eAAe,EAAE,MAAM,CAAC;CACzB;AAiED,MAAM,WAAW,qBAAqB;IACpC,0DAA0D;IAC1D,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB;AAED;;;;GAIG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,qBAAqB,EAC9B,IAAI,GAAE,UAAwB,GAC7B,OAAO,CAAC,MAAM,CAAC,CAiDjB"}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Commander adapter for embedding a WorkflowCli under a parent Commander CLI.
3
+ *
4
+ * ```ts
5
+ * import { createWorkflowCli } from "@bastani/atomic/workflows";
6
+ * import { toCommand, runCli } from "@bastani/atomic/workflows/commander";
7
+ *
8
+ * const cli = createWorkflowCli(workflow);
9
+ * const program = new Command("my-app");
10
+ * program.addCommand(toCommand(cli, "workflow"));
11
+ *
12
+ * await runCli(cli, () => program.parseAsync());
13
+ * ```
14
+ *
15
+ * `WorkflowCli` itself is framework-agnostic — this module is the only place
16
+ * that imports Commander on the adapter side of the API. A future
17
+ * yargs/citty adapter would be a sibling module with the same shape.
18
+ *
19
+ * `runCli` handles orchestrator re-entry transparently — parent CLIs never
20
+ * see env vars or guards. PyTorch-distributed style: the framework owns
21
+ * rank-zero dispatch; the developer writes one line.
22
+ */
23
+ import type { Command } from "@commander-js/extra-typings";
24
+ import type { WorkflowCli, WorkflowDefinition } from "./types.ts";
25
+ /**
26
+ * Build a Commander `Command` bound to a WorkflowCli for embedding under
27
+ * a parent CLI. The returned Command declares `-n/--name`, `-a/--agent`,
28
+ * `-d/--detach`, plus the per-input union across the registry. Picker
29
+ * behaviour (agent without name in a TTY) is preserved.
30
+ *
31
+ * @param cli - WorkflowCli returned by `createWorkflowCli()`.
32
+ * @param name - Mount name (default: `"workflow"`).
33
+ */
34
+ export declare function toCommand<T extends Record<string, WorkflowDefinition>>(cli: WorkflowCli<T>, name?: string): Command;
35
+ /**
36
+ * Bootstrap an embedded Commander CLI. Use this in place of
37
+ * `program.parseAsync()` when you've mounted an atomic WorkflowCli under
38
+ * a parent program.
39
+ *
40
+ * Inspired by PyTorch's `init_process_group()`: the framework handles
41
+ * rank-zero dispatch (here: orchestrator vs CLI) transparently, so the
42
+ * developer writes the same code whether this process is a fresh CLI
43
+ * invocation or a tmux-spawned orchestrator re-exec.
44
+ *
45
+ * - On a fresh invocation, invokes `cliFn()` (your `program.parseAsync()`
46
+ * call, plus any bootstrap you want before it).
47
+ * - When the process is a detached orchestrator re-exec
48
+ * (`ATOMIC_ORCHESTRATOR_MODE=1` is set by the runtime), resolves the
49
+ * workflow identified by `ATOMIC_WF_KEY` against the supplied CLI
50
+ * (or the first match across CLIs) and drives it via
51
+ * `runOrchestrator`. `cliFn` is not called.
52
+ *
53
+ * Accepts a single WorkflowCli or an array — use an array when your
54
+ * parent CLI embeds multiple atomic WorkflowClis (rare, but supported).
55
+ *
56
+ * @example
57
+ * ```ts
58
+ * const program = new Command("my-app");
59
+ * program.addCommand(toCommand(cli));
60
+ *
61
+ * await runCli(cli, () => program.parseAsync());
62
+ * ```
63
+ *
64
+ * @example With pre-parse bootstrap:
65
+ * ```ts
66
+ * await runCli(builtinCli, async () => {
67
+ * await ensureGlobalAtomicSettings();
68
+ * await autoSyncIfStale();
69
+ * await program.parseAsync();
70
+ * });
71
+ * ```
72
+ */
73
+ export declare function runCli(target: WorkflowCli | ReadonlyArray<WorkflowCli>, cliFn: () => void | Promise<void>): Promise<void>;
74
+ //# sourceMappingURL=commander.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commander.d.ts","sourceRoot":"","sources":["../../src/sdk/commander.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAEV,WAAW,EACX,kBAAkB,EACnB,MAAM,YAAY,CAAC;AASpB;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,EACpE,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,EACnB,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAyCT;AAID;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAsB,MAAM,CAC1B,MAAM,EAAE,WAAW,GAAG,aAAa,CAAC,WAAW,CAAC,EAChD,KAAK,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAChC,OAAO,CAAC,IAAI,CAAC,CAyBf"}
@@ -16,7 +16,7 @@
16
16
  *
17
17
  * Lifecycle:
18
18
  *
19
- * const panel = await WorkflowPickerPanel.create({ agent, workflows });
19
+ * const panel = await WorkflowPickerPanel.create({ agent, registry });
20
20
  * const result = await panel.waitForSelection();
21
21
  * panel.destroy();
22
22
  * if (result) await executeWorkflow({ ... });
@@ -27,8 +27,7 @@
27
27
  */
28
28
  import { type CliRenderer } from "@opentui/core";
29
29
  import { type TerminalTheme } from "../runtime/theme.ts";
30
- import type { AgentType, WorkflowInput } from "../types.ts";
31
- import type { WorkflowWithMetadata } from "../runtime/discovery.ts";
30
+ import type { AgentType, WorkflowInput, WorkflowDefinition, Registry } from "../types.ts";
32
31
  export interface PickerTheme {
33
32
  background: string;
34
33
  backgroundPanel: string;
@@ -47,11 +46,10 @@ export interface PickerTheme {
47
46
  borderActive: string;
48
47
  }
49
48
  export declare function buildPickerTheme(base: TerminalTheme, isDark: boolean): PickerTheme;
50
- type Source = "local" | "global" | "builtin";
51
49
  /** The payload the picker resolves with on successful submission. */
52
50
  export interface WorkflowPickerResult {
53
51
  /** The workflow the user committed to running. */
54
- workflow: WorkflowWithMetadata;
52
+ workflow: WorkflowDefinition;
55
53
  /** Populated form values, one per declared input (or { prompt } for free-form). */
56
54
  inputs: Record<string, string>;
57
55
  }
@@ -62,36 +60,35 @@ export interface WorkflowPickerResult {
62
60
  */
63
61
  export declare function fuzzyMatch(query: string, target: string): number | null;
64
62
  interface ListEntry {
65
- workflow: WorkflowWithMetadata;
66
- section: Source;
63
+ workflow: WorkflowDefinition;
64
+ /** Agent the workflow belongs to — used for section grouping. */
65
+ section: AgentType;
67
66
  }
68
67
  type ListRow = {
69
68
  kind: "section";
70
- source: Source;
69
+ agent: AgentType;
71
70
  } | {
72
71
  kind: "entry";
73
72
  entry: ListEntry;
74
73
  };
75
- /**
76
- * Deduplicate workflows by name using builtin > local > global precedence.
77
- * When two workflows share a name, only the higher-precedence entry is kept.
78
- */
79
- export declare function deduplicateByName(workflows: WorkflowWithMetadata[]): WorkflowWithMetadata[];
80
- export declare function buildEntries(query: string, workflows: WorkflowWithMetadata[]): ListEntry[];
74
+ export declare function buildEntries(query: string, workflows: WorkflowDefinition[]): ListEntry[];
81
75
  export declare function buildRows(entries: ListEntry[], query: string): ListRow[];
82
76
  export declare function isFieldValid(field: WorkflowInput, value: string): boolean;
83
77
  interface PickerAppProps {
84
78
  theme: PickerTheme;
85
79
  agent: AgentType;
86
- workflows: WorkflowWithMetadata[];
80
+ workflows: WorkflowDefinition[];
87
81
  onSubmit: (result: WorkflowPickerResult) => void;
88
82
  onCancel: () => void;
89
83
  }
90
84
  export declare function WorkflowPicker({ theme, agent, workflows, onSubmit, onCancel, }: PickerAppProps): import("react").ReactNode;
91
85
  export interface WorkflowPickerPanelOptions {
92
86
  agent: AgentType;
93
- /** Pre-loaded workflows to show. Must already be filtered to `agent`. */
94
- workflows: WorkflowWithMetadata[];
87
+ /**
88
+ * Registry of compiled workflow definitions. The panel calls
89
+ * `registry.list()` and filters to the selected `agent`.
90
+ */
91
+ registry: Registry<Record<string, WorkflowDefinition>>;
95
92
  }
96
93
  /**
97
94
  * Imperative shell around the React picker tree — mirrors the
@@ -1 +1 @@
1
- {"version":3,"file":"workflow-picker-panel.d.ts","sourceRoot":"","sources":["../../../src/sdk/components/workflow-picker-panel.tsx"],"names":[],"mappings":"AAAA,sCAAsC;AACtC;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAEL,KAAK,WAAW,EAIjB,MAAM,eAAe,CAAC;AAQvB,OAAO,EAAgB,KAAK,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,KAAK,EACV,oBAAoB,EAErB,MAAM,yBAAyB,CAAC;AASjC,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO,GAAG,WAAW,CAuBlF;AAeD,KAAK,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,CAAC;AAG7C,qEAAqE;AACrE,MAAM,WAAW,oBAAoB;IACnC,kDAAkD;IAClD,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,mFAAmF;IACnF,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChC;AA6BD;;;;GAIG;AAC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AoB,KAAK,IAAI,CAAC;IACjD,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,wBAAgB,cAAc,CAAC,EAC7B,KAAK,EACL,KAAK,EACL,SAAS,EACT,QAAQ,EACR,QAAQ,GACT,EAAE,cAAc,6BA0IhB;AAID,MAAM,WAAW,0BAA0B;IACzC,KAAK,EAAE,SAAS,CAAC;IACjB;;;OAGG;IACH,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC;CACxD;AAED;;;;GAIG;AACH,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,QAAQ,CAAc;IAC9B,OAAO,CAAC,IAAI,CAAO;IACnB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,gBAAgB,CACjB;IACP,OAAO,CAAC,gBAAgB,CAAuC;IAE/D,OAAO;IA6CP;;;;OAIG;WACU,MAAM,CACjB,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC,mBAAmB,CAAC;IAgB/B,0EAA0E;IAC1E,MAAM,CAAC,kBAAkB,CACvB,QAAQ,EAAE,WAAW,EACrB,OAAO,EAAE,0BAA0B,GAClC,mBAAmB;IAItB;;;;OAIG;IACH,gBAAgB,IAAI,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IAIxD,8CAA8C;IAC9C,OAAO,IAAI,IAAI;IAef,OAAO,CAAC,YAAY;IAOpB,OAAO,CAAC,YAAY;CAMrB"}
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Usage:
5
5
  * defineWorkflow({ name: "my-workflow", inputs: [...] })
6
- * .for<"copilot">()
6
+ * .for("copilot")
7
7
  * .run(async (ctx) => {
8
8
  * await ctx.stage({ name: "research" }, {}, {}, async (s) => { ... });
9
9
  * await ctx.stage({ name: "plan" }, {}, {}, async (s) => { ... });
@@ -12,6 +12,15 @@
12
12
  */
13
13
  import type { AgentType, WorkflowOptions, WorkflowContext, WorkflowDefinition, WorkflowInput } from "./types.ts";
14
14
  type AnyInputs = readonly WorkflowInput[];
15
+ /**
16
+ * Flag and subcommand names reserved by the worker CLI that cannot be used as
17
+ * workflow input names. The first block (`name` / `agent` / `detach` / `list`
18
+ * / `help` / `version`) collides with Commander's own flags on the root
19
+ * command; the second block (`session` / `status`) collides with the auto-
20
+ * registered management subcommands added by `createWorkflowCli` when
21
+ * `includeManagementCommands` is left at its default (`true`).
22
+ */
23
+ export declare const RESERVED_INPUT_NAMES: readonly ["name", "agent", "detach", "list", "help", "version", "session", "status"];
15
24
  /**
16
25
  * Chainable workflow builder. Records the run callback,
17
26
  * then .compile() seals it into a WorkflowDefinition.
@@ -21,14 +30,14 @@ export declare class WorkflowBuilder<A extends AgentType = AgentType, I extends
21
30
  readonly __brand: "WorkflowBuilder";
22
31
  private readonly options;
23
32
  private runFn;
33
+ private agentValue;
24
34
  constructor(options: WorkflowOptions<I>);
25
35
  /**
26
36
  * Narrow the agent type for this workflow while preserving typed inputs.
27
37
  *
28
- * Use `.for<"copilot">()` **before** `.run()` instead of passing the
29
- * agent as a type parameter to `defineWorkflow`. This allows TypeScript
30
- * to infer input names from the `inputs` array AND narrow the agent
31
- * type for `stage()` callbacks.
38
+ * Pass the agent as a runtime string argument so the compiled
39
+ * {@link WorkflowDefinition} carries the `agent` field required by
40
+ * the registry.
32
41
  *
33
42
  * @example
34
43
  * ```typescript
@@ -36,7 +45,7 @@ export declare class WorkflowBuilder<A extends AgentType = AgentType, I extends
36
45
  * name: "my-workflow",
37
46
  * inputs: [{ name: "greeting", type: "string" }],
38
47
  * })
39
- * .for<"copilot">()
48
+ * .for("copilot")
40
49
  * .run(async (ctx) => {
41
50
  * ctx.inputs.greeting; // ✓ typed
42
51
  * ctx.inputs.prompt; // ✗ compile error
@@ -44,7 +53,7 @@ export declare class WorkflowBuilder<A extends AgentType = AgentType, I extends
44
53
  * .compile();
45
54
  * ```
46
55
  */
47
- for<B extends AgentType>(): WorkflowBuilder<B, I>;
56
+ for<B extends AgentType>(agent: B): WorkflowBuilder<B, I>;
48
57
  /**
49
58
  * Set the workflow's entry point.
50
59
  *
@@ -66,7 +75,7 @@ export declare class WorkflowBuilder<A extends AgentType = AgentType, I extends
66
75
  * Entry point for defining a workflow.
67
76
  *
68
77
  * Write the `inputs` array inline so TypeScript infers literal field
69
- * names and enforces them on `ctx.inputs`. Use `.for<Agent>()` to
78
+ * names and enforces them on `ctx.inputs`. Use `.for(agent)` to
70
79
  * narrow the agent type while keeping typed inputs:
71
80
  *
72
81
  * @example
@@ -80,7 +89,7 @@ export declare class WorkflowBuilder<A extends AgentType = AgentType, I extends
80
89
  * { name: "greeting", type: "string", required: true },
81
90
  * ],
82
91
  * })
83
- * .for<"copilot">()
92
+ * .for("copilot")
84
93
  * .run(async (ctx) => {
85
94
  * ctx.inputs.greeting; // ✓ string | undefined
86
95
  * ctx.inputs.prompt; // ✗ compile error — not declared
@@ -1 +1 @@
1
- {"version":3,"file":"define-workflow.d.ts","sourceRoot":"","sources":["../../src/sdk/define-workflow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,aAAa,EACd,MAAM,YAAY,CAAC;AAEpB,KAAK,SAAS,GAAG,SAAS,aAAa,EAAE,CAAC;AA0D1C;;;GAGG;AACH,qBAAa,eAAe,CAC1B,CAAC,SAAS,SAAS,GAAG,SAAS,EAC/B,CAAC,SAAS,SAAS,GAAG,SAAS;IAE/B,8DAA8D;IAC9D,QAAQ,CAAC,OAAO,EAAG,iBAAiB,CAAU;IAC9C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqB;IAC7C,OAAO,CAAC,KAAK,CAAgE;gBAEjE,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC;IAIvC;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,GAAG,CAAC,CAAC,SAAS,SAAS,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC;IAIjD;;;;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;;;;OAOG;IACH,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;IAW5D;;;;;OAKG;IACH,OAAO,IAAI,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC;CA4CpC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,cAAc,CAC5B,KAAK,CAAC,CAAC,SAAS,SAAS,aAAa,EAAE,GAAG,SAAS,aAAa,EAAE,EAEnE,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC,GAC1B,eAAe,CAAC,SAAS,EAAE,CAAC,CAAC,CAK/B"}
@@ -7,7 +7,8 @@
7
7
  export { MissingDependencyError, WorkflowNotCompiledError, InvalidWorkflowError, } from "./errors.ts";
8
8
  export type { AgentType, Transcript, SavedMessage, SaveTranscript, SessionContext, SessionRef, SessionHandle, SessionRunOptions, WorkflowContext, WorkflowOptions, WorkflowDefinition, StageClientOptions, StageSessionOptions, ProviderClient, ProviderSession, } from "./types.ts";
9
9
  export { defineWorkflow } from "./define-workflow.ts";
10
- export { discoverWorkflows, findWorkflow, } from "./runtime/discovery.ts";
11
- export { WorkflowLoader } from "./runtime/loader.ts";
12
- export { executeWorkflow } from "./runtime/executor.ts";
10
+ export type { Registry } from "./registry.ts";
11
+ export { createRegistry } from "./registry.ts";
12
+ export { createWorkflowCli } from "./workflow-cli.ts";
13
+ export type { WorkflowCli, CreateWorkflowCliOptions } from "./types.ts";
13
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sdk/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,sBAAsB,EACtB,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,aAAa,CAAC;AAGrB,YAAY,EACV,SAAS,EACT,UAAU,EACV,YAAY,EACZ,cAAc,EACd,cAAc,EACd,UAAU,EACV,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EACd,eAAe,GAChB,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD,OAAO,EACL,iBAAiB,EACjB,YAAY,GACb,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/sdk/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,sBAAsB,EACtB,wBAAwB,EACxB,oBAAoB,GACrB,MAAM,aAAa,CAAC;AAGrB,YAAY,EACV,SAAS,EACT,UAAU,EACV,YAAY,EACZ,cAAc,EACd,cAAc,EACd,UAAU,EACV,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EACd,eAAe,GAChB,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAGtD,YAAY,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAK/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,YAAY,EAAE,WAAW,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Session + status management subcommands for workflow CLIs.
3
+ *
4
+ * Shared by the atomic CLI root (`atomic session *`, `atomic workflow status`)
5
+ * and by SDK-built CLIs (`createWorkflowCli(...)`). Factoring this out means a
6
+ * user running `bun run src/claude-worker.ts session list` gets the identical
7
+ * command surface as `atomic session list`, without the SDK embedding its own
8
+ * diverging implementation. All queries go through the shared atomic tmux
9
+ * socket, so sessions spawned by SDK-built CLIs and by `atomic workflow -n …`
10
+ * show up interchangeably.
11
+ *
12
+ * Commander options are declared with the same names, descriptions, and
13
+ * behaviour as the atomic root CLI — keep them in sync when the root CLI
14
+ * grows a new option.
15
+ */
16
+ import type { Command } from "@commander-js/extra-typings";
17
+ import type { SessionScope } from "../commands/cli/session.ts";
18
+ /**
19
+ * Attach the `session` subcommand group (`list` / `connect` / `kill`) to a
20
+ * parent Commander command. Returns the created `session` group so callers
21
+ * can attach additional children if they need to.
22
+ *
23
+ * @param parent The Commander command to mount `session` under.
24
+ * @param scope Which session set the list/kill commands operate on. SDK CLIs
25
+ * typically pass `"workflow"` to scope the picker to
26
+ * `atomic-wf-*` sessions only; the atomic root uses `"all"`.
27
+ */
28
+ export declare function addSessionSubcommand(parent: Command, scope?: SessionScope): Command;
29
+ /**
30
+ * Attach a top-level `status` subcommand for querying workflow status.
31
+ * Mirrors `atomic workflow status` — same overall-state contract
32
+ * (`in_progress` / `error` / `completed` / `needs_review`) and same JSON
33
+ * shape. Omit the id to list every running workflow on the socket.
34
+ */
35
+ export declare function addStatusSubcommand(parent: Command): void;
36
+ /**
37
+ * Convenience: attach both `session` and `status` subcommands in the order
38
+ * the SDK defaults use. Called by `createWorkflowCli` when
39
+ * `includeManagementCommands` is `true` (the default).
40
+ */
41
+ export declare function addManagementCommands(parent: Command, scope?: SessionScope): void;
42
+ //# sourceMappingURL=management-commands.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"management-commands.d.ts","sourceRoot":"","sources":["../../src/sdk/management-commands.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAO/D;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,OAAO,EACf,KAAK,GAAE,YAAoB,GAC1B,OAAO,CA0ET;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAkBzD;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,OAAO,EACf,KAAK,GAAE,YAAyB,GAC/B,IAAI,CAGN"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Workflow Registry — immutable, chainable registry of WorkflowDefinition objects.
3
+ *
4
+ * Key scheme: `${agent}/${name}` — each (agent, name) pair is unique.
5
+ * Registering the same key twice throws — no silent overwrites.
6
+ * `register()` is immutable: returns a new Registry, original is unchanged.
7
+ */
8
+ import type { Registry } from "./types.ts";
9
+ import { validateCopilotWorkflow } from "./providers/copilot.ts";
10
+ import { validateOpenCodeWorkflow } from "./providers/opencode.ts";
11
+ import { validateClaudeWorkflow } from "./providers/claude.ts";
12
+ export type { Registry };
13
+ /**
14
+ * Create an empty workflow registry.
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * import { createRegistry } from "@bastani/atomic/workflows";
19
+ * import { myWorkflow } from "./workflows/my-workflow.workflow";
20
+ *
21
+ * const registry = createRegistry()
22
+ * .register(myWorkflow);
23
+ * ```
24
+ */
25
+ export declare function createRegistry(): Registry<Record<string, never>>;
26
+ export { validateCopilotWorkflow, validateOpenCodeWorkflow, validateClaudeWorkflow };
27
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/sdk/registry.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAa,QAAQ,EAA2C,MAAM,YAAY,CAAC;AAC/F,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAI/D,YAAY,EAAE,QAAQ,EAAE,CAAC;AAmGzB;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAEhE;AAGD,OAAO,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,CAAC"}
@@ -9,7 +9,7 @@
9
9
  *
10
10
  * Resolves the CLI entrypoint relative to this module (runtime/ lives at
11
11
  * src/sdk/runtime/, so ../../cli.ts is the CLI). `process.argv[1]` points
12
- * at the orchestrator's executor-entry.ts when called from the executor,
12
+ * at the worker entrypoint when called from the orchestrator,
13
13
  * so it can't be used here.
14
14
  */
15
15
  import type { AgentType } from "../types.ts";
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Orchestrator environment variable validation — extracted into its own
3
+ * module so test files can import it directly without touching the
4
+ * executor.ts module (which is mocked in worker.test.ts and
5
+ * workflow-command.test.ts). Importing from here bypasses those mocks.
6
+ */
7
+ import type { AgentType } from "../types.ts";
8
+ /**
9
+ * Read and validate the required orchestrator env vars, throwing on the
10
+ * first missing or invalid value.
11
+ *
12
+ * Required vars: ATOMIC_WF_ID, ATOMIC_WF_TMUX, ATOMIC_WF_AGENT, ATOMIC_WF_CWD.
13
+ */
14
+ export declare function validateOrchestratorEnv(): {
15
+ workflowRunId: string;
16
+ tmuxSessionName: string;
17
+ agent: AgentType;
18
+ cwd: string;
19
+ };
20
+ //# sourceMappingURL=executor-env.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executor-env.d.ts","sourceRoot":"","sources":["../../../src/sdk/runtime/executor-env.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAG7C;;;;;GAKG;AACH,wBAAgB,uBAAuB,IAAI;IACzC,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,SAAS,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;CACb,CAuBA"}
@@ -2,18 +2,18 @@
2
2
  * Workflow runtime executor.
3
3
  *
4
4
  * Architecture:
5
- * 1. `executeWorkflow()` is called by the CLI command
6
- * 2. It creates a tmux session with an orchestrator pane that runs
7
- * `bun run executor-entry.ts` (a thin wrapper that calls `runOrchestrator()`)
5
+ * 1. `executeWorkflow()` is called by the CLI command or worker
6
+ * 2. It creates a tmux session with an orchestrator pane that re-executes
7
+ * the user's entrypoint file with `ATOMIC_ORCHESTRATOR_MODE=1`
8
8
  * 3. The CLI then attaches to the tmux session (user sees it live)
9
9
  * 4. The orchestrator pane calls `definition.run(workflowCtx)` — the
10
10
  * user's callback uses `ctx.stage()` to spawn agent sessions
11
11
  *
12
- * The entry point is in executor-entry.ts (not this file) to avoid Bun's
13
- * dual-module-identity issue: Bun evaluates a file twice when it is both
14
- * the entry point and reached through package.json `exports` self-referencing.
12
+ * In the new model the user's own file (e.g. `src/worker.ts`) is re-executed
13
+ * with env vars (`ATOMIC_ORCHESTRATOR_MODE`, `ATOMIC_WF_KEY`) that signal
14
+ * re-entry. The worker detects those vars and calls `runOrchestrator(definition)`.
15
15
  */
16
- import type { WorkflowDefinition, WorkflowInput, AgentType, SavedMessage } from "../types.ts";
16
+ import type { WorkflowDefinition, WorkflowInput, AgentType, SavedMessage, StageClientOptions } from "../types.ts";
17
17
  export { errorMessage } from "../errors.ts";
18
18
  export interface WorkflowRunOptions {
19
19
  /** The compiled workflow definition */
@@ -27,8 +27,19 @@ export interface WorkflowRunOptions {
27
27
  * whether the workflow declares a schema. Empty record is valid.
28
28
  */
29
29
  inputs?: Record<string, string>;
30
- /** Absolute path to the workflow's index.ts file (from discovery) */
31
- workflowFile: string;
30
+ /**
31
+ * Absolute path to the user's entrypoint file (e.g. `src/worker.ts`).
32
+ * The launcher re-executes this file with `ATOMIC_ORCHESTRATOR_MODE=1`
33
+ * so the worker can detect re-entry and call `runOrchestrator()`.
34
+ * Defaults to `process.argv[1]` at the call site.
35
+ */
36
+ entrypointFile: string;
37
+ /**
38
+ * Registry key identifying this workflow, formatted as `"<agent>/<name>"`.
39
+ * Passed via `ATOMIC_WF_KEY` so the orchestrator can resolve the
40
+ * definition from the registry without a file-system scan.
41
+ */
42
+ workflowKey: string;
32
43
  /** Project root (defaults to cwd) */
33
44
  projectRoot?: string;
34
45
  /**
@@ -234,5 +245,45 @@ export declare function watchCopilotSessionForElicitation(session: CopilotHILSes
234
245
  * entries the caller already supplied. Exported for unit testing.
235
246
  */
236
247
  export declare function mergeExcludedTools(existing: string[] | undefined, extras: string[]): string[];
237
- export declare function runOrchestrator(): Promise<void>;
248
+ type ExternalCopilotClientOptions = Omit<StageClientOptions<"copilot">, "gitHubToken" | "useLoggedInUser">;
249
+ interface ExternalCopilotOptions {
250
+ clientOptions: ExternalCopilotClientOptions;
251
+ sessionGitHubToken?: string;
252
+ }
253
+ /**
254
+ * Copilot SDK 0.3.0 rejects client-level auth options when connecting to an
255
+ * existing `cliUrl`. Visible stages use an already-running TUI server, so move
256
+ * token auth to the session-level option that 0.3.0 introduced for this case.
257
+ */
258
+ export declare function normalizeExternalCopilotOptions(clientOptions: StageClientOptions<"copilot">, sessionGitHubToken?: string): ExternalCopilotOptions;
259
+ /**
260
+ * Run the orchestrator inside a tmux pane.
261
+ *
262
+ * Called by the worker entrypoint when `ATOMIC_ORCHESTRATOR_MODE=1` is set.
263
+ * The `definition` parameter is resolved by the caller (the worker) from the
264
+ * registry using `ATOMIC_WF_KEY` — this function no longer performs any
265
+ * file-path import or workflow discovery.
266
+ *
267
+ * @param definition - Resolved workflow definition from the registry.
268
+ */
269
+ export { validateOrchestratorEnv } from "./executor-env.ts";
270
+ /**
271
+ * Orchestrator re-entry guard.
272
+ *
273
+ * When `executeWorkflow()` spawns a detached pane, it re-invokes the
274
+ * composition root with `ATOMIC_ORCHESTRATOR_MODE=1` +
275
+ * `ATOMIC_WF_KEY="<agent>/<name>"`. This helper detects that re-entry
276
+ * and hands off to `runOrchestrator()` with the resolved definition.
277
+ *
278
+ * Returns `true` when re-entry was handled (caller should stop normal
279
+ * CLI flow). Returns `false` when `ATOMIC_ORCHESTRATOR_MODE` is unset
280
+ * — the caller should proceed with argv parsing.
281
+ *
282
+ * The `resolve` callback lets embedded workers pass a trivial lookup
283
+ * (their single bound definition) while the dispatcher passes its
284
+ * registry. Throws on malformed or unknown keys so authoring mistakes
285
+ * surface loudly instead of silently hanging.
286
+ */
287
+ export declare function handleOrchestratorReEntry(resolve: (name: string, agent: AgentType) => WorkflowDefinition | undefined): Promise<boolean>;
288
+ export declare function runOrchestrator(definition: WorkflowDefinition): Promise<void>;
238
289
  //# sourceMappingURL=executor.d.ts.map