@bastani/atomic 0.9.0-alpha.1 → 0.9.0-alpha.2
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/CHANGELOG.md +23 -0
- package/dist/builtin/cursor/CHANGELOG.md +6 -0
- package/dist/builtin/cursor/package.json +2 -2
- package/dist/builtin/intercom/CHANGELOG.md +6 -0
- package/dist/builtin/intercom/package.json +2 -2
- package/dist/builtin/mcp/CHANGELOG.md +6 -0
- package/dist/builtin/mcp/package.json +3 -3
- package/dist/builtin/subagents/CHANGELOG.md +6 -0
- package/dist/builtin/subagents/package.json +4 -4
- package/dist/builtin/web-access/CHANGELOG.md +6 -0
- package/dist/builtin/web-access/package.json +2 -2
- package/dist/builtin/workflows/CHANGELOG.md +12 -0
- package/dist/builtin/workflows/README.md +189 -122
- package/dist/builtin/workflows/builtin/deep-research-codebase.ts +30 -27
- package/dist/builtin/workflows/builtin/goal-runner.ts +10 -17
- package/dist/builtin/workflows/builtin/goal.ts +39 -44
- package/dist/builtin/workflows/builtin/index.d.ts +1 -0
- package/dist/builtin/workflows/builtin/open-claude-design-runner.ts +16 -17
- package/dist/builtin/workflows/builtin/open-claude-design.d.ts +1 -0
- package/dist/builtin/workflows/builtin/open-claude-design.ts +42 -50
- package/dist/builtin/workflows/builtin/ralph.ts +44 -41
- package/dist/builtin/workflows/package.json +2 -2
- package/dist/builtin/workflows/src/authoring/typebox-defaults.d.ts +41 -0
- package/dist/builtin/workflows/src/authoring/typebox-defaults.ts +217 -0
- package/dist/builtin/workflows/src/authoring/workflow.ts +184 -0
- package/dist/builtin/workflows/src/authoring.d.ts +14 -66
- package/dist/builtin/workflows/src/engine/graph-inference.ts +100 -0
- package/dist/builtin/workflows/src/engine/options.ts +40 -0
- package/dist/builtin/workflows/src/engine/primitives/chain.ts +29 -0
- package/dist/builtin/workflows/src/engine/primitives/exit.ts +2 -0
- package/dist/builtin/workflows/src/engine/primitives/parallel.ts +47 -0
- package/dist/builtin/workflows/src/engine/primitives/task.ts +108 -0
- package/dist/builtin/workflows/src/engine/primitives/ui.ts +41 -0
- package/dist/builtin/workflows/src/engine/primitives/workflow.ts +159 -0
- package/dist/builtin/workflows/src/engine/replay.ts +8 -0
- package/dist/builtin/workflows/src/engine/run.ts +356 -0
- package/dist/builtin/workflows/src/engine/runtime.ts +160 -0
- package/dist/builtin/workflows/src/extension/workflow-module-loader.ts +9 -3
- package/dist/builtin/workflows/src/extension/workflow-schema.ts +0 -18
- package/dist/builtin/workflows/src/index.ts +0 -2
- package/dist/builtin/workflows/src/runs/background/runner.ts +6 -3
- package/dist/builtin/workflows/src/runs/foreground/executor-child-boundary.ts +3 -3
- package/dist/builtin/workflows/src/runs/foreground/executor-child-helpers.ts +4 -4
- package/dist/builtin/workflows/src/runs/foreground/executor-child-workflow.ts +1 -158
- package/dist/builtin/workflows/src/runs/foreground/executor-direct-helpers.ts +1 -1
- package/dist/builtin/workflows/src/runs/foreground/executor-outputs.ts +2 -2
- package/dist/builtin/workflows/src/runs/foreground/executor-prompt-nodes.ts +1 -1
- package/dist/builtin/workflows/src/runs/foreground/executor-run.ts +1 -359
- package/dist/builtin/workflows/src/runs/foreground/executor-scheduler.ts +1 -1
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-call.ts +2 -5
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-factory.ts +12 -4
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-replay.ts +4 -3
- package/dist/builtin/workflows/src/runs/foreground/executor-stage-types.ts +9 -2
- package/dist/builtin/workflows/src/runs/foreground/executor-task-context.ts +2 -132
- package/dist/builtin/workflows/src/runs/foreground/executor-types.ts +2 -2
- package/dist/builtin/workflows/src/runs/shared/graph-inference.ts +2 -100
- package/dist/builtin/workflows/src/sdk-surface.ts +6 -9
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +9 -3
- package/dist/builtin/workflows/src/shared/authoring-contract-stage.ts +17 -3
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +3 -33
- package/dist/builtin/workflows/src/shared/authoring-contract-ui.ts +9 -81
- package/dist/builtin/workflows/src/shared/types.ts +25 -8
- package/dist/builtin/workflows/src/shared/workflow-authoring-types.d.ts +49 -0
- package/dist/builtin/workflows/src/shared/workflow-authoring-types.ts +84 -0
- package/dist/builtin/workflows/src/workflows/registry.ts +7 -3
- package/dist/core/agent-session-auto-compaction.d.ts.map +1 -1
- package/dist/core/agent-session-auto-compaction.js +6 -1
- package/dist/core/agent-session-auto-compaction.js.map +1 -1
- package/dist/core/agent-session-bash.d.ts.map +1 -1
- package/dist/core/agent-session-bash.js +0 -5
- package/dist/core/agent-session-bash.js.map +1 -1
- package/dist/core/agent-session-methods.d.ts +0 -2
- package/dist/core/agent-session-methods.d.ts.map +1 -1
- package/dist/core/agent-session-methods.js.map +1 -1
- package/dist/core/agent-session-services.d.ts +0 -1
- package/dist/core/agent-session-services.d.ts.map +1 -1
- package/dist/core/agent-session-services.js +0 -1
- package/dist/core/agent-session-services.js.map +1 -1
- package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
- package/dist/core/agent-session-tool-registry.js +0 -2
- package/dist/core/agent-session-tool-registry.js.map +1 -1
- package/dist/core/agent-session-types.d.ts +0 -2
- package/dist/core/agent-session-types.d.ts.map +1 -1
- package/dist/core/agent-session-types.js.map +1 -1
- package/dist/core/agent-session.d.ts +0 -2
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +0 -1
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/atomic-guide-command.d.ts.map +1 -1
- package/dist/core/atomic-guide-command.js +1 -1
- package/dist/core/atomic-guide-command.js.map +1 -1
- package/dist/core/extensions/loader-core.d.ts +1 -3
- package/dist/core/extensions/loader-core.d.ts.map +1 -1
- package/dist/core/extensions/loader-core.js +13 -6
- package/dist/core/extensions/loader-core.js.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.d.ts +7 -1
- package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.js +34 -2
- package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
- package/dist/core/extensions/loader.d.ts +2 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +2 -1
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/index.d.ts +0 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +0 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/model-registry-builtins.d.ts.map +1 -1
- package/dist/core/model-registry-builtins.js +6 -0
- package/dist/core/model-registry-builtins.js.map +1 -1
- package/dist/core/model-registry-schemas.d.ts +65 -13
- package/dist/core/model-registry-schemas.d.ts.map +1 -1
- package/dist/core/model-registry-schemas.js +10 -0
- package/dist/core/model-registry-schemas.js.map +1 -1
- package/dist/core/resource-loader-core.d.ts +1 -0
- package/dist/core/resource-loader-core.d.ts.map +1 -1
- package/dist/core/resource-loader-core.js +2 -0
- package/dist/core/resource-loader-core.js.map +1 -1
- package/dist/core/resource-loader-extensions.d.ts.map +1 -1
- package/dist/core/resource-loader-extensions.js +3 -3
- package/dist/core/resource-loader-extensions.js.map +1 -1
- package/dist/core/resource-loader-internals.d.ts +1 -0
- package/dist/core/resource-loader-internals.d.ts.map +1 -1
- package/dist/core/resource-loader-internals.js.map +1 -1
- package/dist/core/resource-loader-reload.d.ts.map +1 -1
- package/dist/core/resource-loader-reload.js +6 -2
- package/dist/core/resource-loader-reload.js.map +1 -1
- package/dist/core/sdk-exports.d.ts +1 -1
- package/dist/core/sdk-exports.d.ts.map +1 -1
- package/dist/core/sdk-exports.js.map +1 -1
- package/dist/core/sdk-types.d.ts +0 -3
- package/dist/core/sdk-types.d.ts.map +1 -1
- package/dist/core/sdk-types.js.map +1 -1
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +0 -1
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager-history.d.ts.map +1 -1
- package/dist/core/session-manager-history.js +2 -1
- package/dist/core/session-manager-history.js.map +1 -1
- package/dist/core/tools/bash.d.ts +0 -5
- package/dist/core/tools/bash.d.ts.map +1 -1
- package/dist/core/tools/bash.js +10 -11
- package/dist/core/tools/bash.js.map +1 -1
- package/dist/core/tools/edit-diff-preserve.d.ts +18 -0
- package/dist/core/tools/edit-diff-preserve.d.ts.map +1 -0
- package/dist/core/tools/edit-diff-preserve.js +85 -0
- package/dist/core/tools/edit-diff-preserve.js.map +1 -0
- package/dist/core/tools/edit-diff.d.ts +3 -2
- package/dist/core/tools/edit-diff.d.ts.map +1 -1
- package/dist/core/tools/edit-diff.js +15 -18
- package/dist/core/tools/edit-diff.js.map +1 -1
- package/dist/core/tools/index.d.ts +0 -1
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +0 -1
- package/dist/core/tools/index.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +2 -2
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/model-search.d.ts +5 -0
- package/dist/modes/interactive/model-search.d.ts.map +1 -1
- package/dist/modes/interactive/model-search.js +9 -0
- package/dist/modes/interactive/model-search.js.map +1 -1
- package/dist/utils/shell.d.ts +1 -0
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +12 -5
- package/dist/utils/shell.js.map +1 -1
- package/docs/custom-provider.md +4 -3
- package/docs/models.md +3 -2
- package/docs/packages.md +2 -2
- package/docs/quickstart.md +1 -1
- package/docs/sdk.md +2 -40
- package/docs/security.md +1 -1
- package/docs/workflows.md +238 -173
- package/package.json +5 -5
- package/dist/builtin/workflows/src/workflows/define-workflow.ts +0 -277
- package/dist/core/tools/bash-policy-compile.d.ts +0 -5
- package/dist/core/tools/bash-policy-compile.d.ts.map +0 -1
- package/dist/core/tools/bash-policy-compile.js +0 -241
- package/dist/core/tools/bash-policy-compile.js.map +0 -1
- package/dist/core/tools/bash-policy-evaluate.d.ts +0 -3
- package/dist/core/tools/bash-policy-evaluate.d.ts.map +0 -1
- package/dist/core/tools/bash-policy-evaluate.js +0 -92
- package/dist/core/tools/bash-policy-evaluate.js.map +0 -1
- package/dist/core/tools/bash-policy-format.d.ts +0 -5
- package/dist/core/tools/bash-policy-format.d.ts.map +0 -1
- package/dist/core/tools/bash-policy-format.js +0 -49
- package/dist/core/tools/bash-policy-format.js.map +0 -1
- package/dist/core/tools/bash-policy-parser.d.ts +0 -4
- package/dist/core/tools/bash-policy-parser.d.ts.map +0 -1
- package/dist/core/tools/bash-policy-parser.js +0 -155
- package/dist/core/tools/bash-policy-parser.js.map +0 -1
- package/dist/core/tools/bash-policy-segment.d.ts +0 -3
- package/dist/core/tools/bash-policy-segment.d.ts.map +0 -1
- package/dist/core/tools/bash-policy-segment.js +0 -275
- package/dist/core/tools/bash-policy-segment.js.map +0 -1
- package/dist/core/tools/bash-policy-shell.d.ts +0 -11
- package/dist/core/tools/bash-policy-shell.d.ts.map +0 -1
- package/dist/core/tools/bash-policy-shell.js +0 -267
- package/dist/core/tools/bash-policy-shell.js.map +0 -1
- package/dist/core/tools/bash-policy-types.d.ts +0 -146
- package/dist/core/tools/bash-policy-types.d.ts.map +0 -1
- package/dist/core/tools/bash-policy-types.js +0 -2
- package/dist/core/tools/bash-policy-types.js.map +0 -1
- package/dist/core/tools/bash-policy.d.ts +0 -6
- package/dist/core/tools/bash-policy.d.ts.map +0 -1
- package/dist/core/tools/bash-policy.js +0 -5
- package/dist/core/tools/bash-policy.js.map +0 -1
|
@@ -3,10 +3,16 @@ import type { Store } from "../../shared/store.js";
|
|
|
3
3
|
import type { StageContext } from "../../shared/types.js";
|
|
4
4
|
import type { InternalStageContext } from "./stage-runner.js";
|
|
5
5
|
import type { StageControlRegistry } from "./stage-control-registry.js";
|
|
6
|
-
import type {
|
|
6
|
+
import type { ParallelFailFastScope } from "./executor-types.js";
|
|
7
7
|
import type { StageScheduler } from "./executor-scheduler.js";
|
|
8
8
|
import type { WorkflowExitManager } from "./executor-exit-manager.js";
|
|
9
9
|
import type { WorkflowFailure } from "../../shared/workflow-failures.js";
|
|
10
|
+
import type { EngineStageRuntimeOptions } from "../../engine/options.js";
|
|
11
|
+
|
|
12
|
+
export interface StageMcpScope {
|
|
13
|
+
apply(): void;
|
|
14
|
+
clear(): void;
|
|
15
|
+
}
|
|
10
16
|
|
|
11
17
|
export interface LiveStageMutableState {
|
|
12
18
|
activeAskUserQuestionAnonymousCalls: number;
|
|
@@ -27,12 +33,13 @@ export interface LiveStageRuntime {
|
|
|
27
33
|
readonly stageSnapshot: StageSnapshot;
|
|
28
34
|
readonly innerCtx: InternalStageContext;
|
|
29
35
|
readonly activeStore: Store;
|
|
30
|
-
readonly opts:
|
|
36
|
+
readonly opts: EngineStageRuntimeOptions;
|
|
31
37
|
readonly stageRegistry: StageControlRegistry;
|
|
32
38
|
readonly scheduler: StageScheduler;
|
|
33
39
|
readonly signal: AbortSignal;
|
|
34
40
|
readonly exit: WorkflowExitManager;
|
|
35
41
|
readonly classifyExecutorFailure: (error: unknown) => WorkflowFailure;
|
|
42
|
+
readonly mcpScope: StageMcpScope;
|
|
36
43
|
readonly stageFailFastScope?: ParallelFailFastScope;
|
|
37
44
|
readonly state: LiveStageMutableState;
|
|
38
45
|
unregisterStageHandle: () => void;
|
|
@@ -1,132 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import type { WorkflowExitManager } from "./executor-exit-manager.js";
|
|
4
|
-
import type { ParallelFailFastScope, ParallelFailFastStage } from "./executor-types.js";
|
|
5
|
-
import { findWorkflowExitSignal } from "./executor-abort.js";
|
|
6
|
-
import {
|
|
7
|
-
applyTaskContext,
|
|
8
|
-
chainStepPrompt,
|
|
9
|
-
parallelFallbackTask,
|
|
10
|
-
replaceTaskPlaceholder,
|
|
11
|
-
structuredTaskOutputText,
|
|
12
|
-
taskOptionsFromStep,
|
|
13
|
-
taskPrevious,
|
|
14
|
-
taskPrompt,
|
|
15
|
-
taskPromptOptions,
|
|
16
|
-
taskReadInstruction,
|
|
17
|
-
taskStageOptions,
|
|
18
|
-
taskWithSharedDefaults,
|
|
19
|
-
truncateTaskOutput,
|
|
20
|
-
} from "./executor-task-prompts.js";
|
|
21
|
-
import { cleanupPreparedWorktrees, collectWorktreeDiffs, mapParallelSteps, prepareDirectWorktrees, stageOptionsWithGitWorktree, stageOptionsWithInputDefaults } from "./executor-direct-helpers.js";
|
|
22
|
-
import type { InternalStageContext } from "./stage-runner.js";
|
|
23
|
-
|
|
24
|
-
export interface WorkflowTaskRunners {
|
|
25
|
-
task(name: string, options: WorkflowTaskOptions, stageFailFastScope?: ParallelFailFastScope): Promise<WorkflowTaskResult>;
|
|
26
|
-
chain(steps: readonly WorkflowTaskStep[], options?: WorkflowChainOptions): Promise<WorkflowTaskResult[]>;
|
|
27
|
-
parallel(steps: readonly WorkflowTaskStep[], options?: WorkflowParallelOptions): Promise<WorkflowTaskResult[]>;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export function createWorkflowTaskRunners(input: {
|
|
31
|
-
readonly runId: string;
|
|
32
|
-
readonly exit: WorkflowExitManager;
|
|
33
|
-
readonly tracker: GraphFrontierTracker;
|
|
34
|
-
readonly inputRuntimeDefaults: Partial<StageOptions>;
|
|
35
|
-
readonly workflowInvocationCwd: string;
|
|
36
|
-
readonly stage: (name: string, options?: StageOptions, scope?: ParallelFailFastScope) => StageContext;
|
|
37
|
-
}): WorkflowTaskRunners {
|
|
38
|
-
const task = async (name: string, options: WorkflowTaskOptions, stageFailFastScope?: ParallelFailFastScope): Promise<WorkflowTaskResult> => {
|
|
39
|
-
input.exit.throwIfWorkflowExitSelected();
|
|
40
|
-
const runTaskOnce = async (taskOptions: WorkflowTaskOptions): Promise<WorkflowTaskResult> => {
|
|
41
|
-
input.exit.throwIfWorkflowExitSelected();
|
|
42
|
-
const resolvedTaskOptions = stageOptionsWithGitWorktree(stageOptionsWithInputDefaults(taskOptions, input.inputRuntimeDefaults), input.workflowInvocationCwd) ?? taskOptions;
|
|
43
|
-
const stage = input.stage(name, taskStageOptions(resolvedTaskOptions), stageFailFastScope);
|
|
44
|
-
const rawOutput = await stage.prompt(
|
|
45
|
-
applyTaskContext(`${taskReadInstruction(resolvedTaskOptions)}${taskPrompt(resolvedTaskOptions)}`, taskPrevious(resolvedTaskOptions)),
|
|
46
|
-
taskPromptOptions(resolvedTaskOptions),
|
|
47
|
-
);
|
|
48
|
-
const structured = typeof rawOutput === "string" ? undefined : rawOutput;
|
|
49
|
-
const text = truncateTaskOutput(structuredTaskOutputText(rawOutput), resolvedTaskOptions.maxOutput);
|
|
50
|
-
const sessionId = (() => {
|
|
51
|
-
try {
|
|
52
|
-
return stage.sessionId;
|
|
53
|
-
} catch {
|
|
54
|
-
return undefined;
|
|
55
|
-
}
|
|
56
|
-
})();
|
|
57
|
-
const stageMeta = (stage as InternalStageContext).__modelFallbackMeta?.() ?? {};
|
|
58
|
-
return {
|
|
59
|
-
name,
|
|
60
|
-
stageName: name,
|
|
61
|
-
text,
|
|
62
|
-
...(structured !== undefined ? { structured } : {}),
|
|
63
|
-
...(sessionId !== undefined ? { sessionId } : {}),
|
|
64
|
-
...(stage.sessionFile !== undefined ? { sessionFile: stage.sessionFile } : {}),
|
|
65
|
-
...(stageMeta.model !== undefined ? { model: stageMeta.model } : {}),
|
|
66
|
-
...(stageMeta.fastMode === true ? { fastMode: stageMeta.fastMode } : {}),
|
|
67
|
-
...(stageMeta.attemptedModels !== undefined ? { attemptedModels: stageMeta.attemptedModels } : {}),
|
|
68
|
-
...(stageMeta.modelAttempts !== undefined ? { modelAttempts: stageMeta.modelAttempts } : {}),
|
|
69
|
-
...(stageMeta.warnings !== undefined ? { warnings: stageMeta.warnings } : {}),
|
|
70
|
-
};
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
if (options.worktree !== true) return runTaskOnce(options);
|
|
74
|
-
const prepared = prepareDirectWorktrees(
|
|
75
|
-
[{ ...options, name }],
|
|
76
|
-
{ ...options, worktree: true },
|
|
77
|
-
`${input.runId}-${name}-${crypto.randomUUID()}`,
|
|
78
|
-
name,
|
|
79
|
-
);
|
|
80
|
-
const preparedTask = prepared.tasks[0]!;
|
|
81
|
-
try {
|
|
82
|
-
const result = await runTaskOnce(preparedTask);
|
|
83
|
-
const worktreeDiffs = collectWorktreeDiffs(prepared, options.artifacts !== false);
|
|
84
|
-
return worktreeDiffs.artifacts.length === 0
|
|
85
|
-
? result
|
|
86
|
-
: { ...result, artifacts: [...(result.artifacts ?? []), ...worktreeDiffs.artifacts] };
|
|
87
|
-
} finally {
|
|
88
|
-
cleanupPreparedWorktrees(prepared);
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
const chain = async (steps: readonly WorkflowTaskStep[], options: WorkflowChainOptions = {}): Promise<WorkflowTaskResult[]> => {
|
|
93
|
-
input.exit.throwIfWorkflowExitSelected();
|
|
94
|
-
const results: WorkflowTaskResult[] = [];
|
|
95
|
-
for (let index = 0; index < steps.length; index += 1) {
|
|
96
|
-
input.exit.throwIfWorkflowExitSelected();
|
|
97
|
-
const step = steps[index]!;
|
|
98
|
-
const explicitPrevious = taskPrevious(step);
|
|
99
|
-
const previous = explicitPrevious ?? (index > 0 ? results[index - 1] : undefined);
|
|
100
|
-
const prompt = replaceTaskPlaceholder(chainStepPrompt(step, index), options.task ?? "");
|
|
101
|
-
results.push(await task(step.name, taskWithSharedDefaults(taskOptionsFromStep(step, prompt, previous), options)));
|
|
102
|
-
}
|
|
103
|
-
return results;
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
const parallel = async (steps: readonly WorkflowTaskStep[], options: WorkflowParallelOptions = {}): Promise<WorkflowTaskResult[]> => {
|
|
107
|
-
input.exit.throwIfWorkflowExitSelected();
|
|
108
|
-
const fallback = parallelFallbackTask(steps, options);
|
|
109
|
-
const failFastEnabled = options.failFast !== false;
|
|
110
|
-
const parallelScope: ParallelFailFastScope = {
|
|
111
|
-
failed: false,
|
|
112
|
-
activeStages: new Map<string, ParallelFailFastStage>(),
|
|
113
|
-
parentIds: Object.freeze(input.tracker.currentParents()),
|
|
114
|
-
};
|
|
115
|
-
return mapParallelSteps(steps, options.concurrency, options.failFast, async (step) => {
|
|
116
|
-
input.exit.throwIfWorkflowExitSelected();
|
|
117
|
-
const prompt = replaceTaskPlaceholder(step.prompt ?? step.task ?? fallback, options.task ?? fallback);
|
|
118
|
-
return await task(step.name, taskWithSharedDefaults(taskOptionsFromStep(step, prompt, taskPrevious(step)), options), parallelScope);
|
|
119
|
-
}, (error) => {
|
|
120
|
-
if (!failFastEnabled) return;
|
|
121
|
-
parallelScope.failed = true;
|
|
122
|
-
parallelScope.firstFailure = error;
|
|
123
|
-
for (const stage of parallelScope.activeStages.values()) stage.skip();
|
|
124
|
-
}, {
|
|
125
|
-
beforeDequeue: input.exit.throwIfWorkflowExitSelected,
|
|
126
|
-
beforeMap: input.exit.throwIfWorkflowExitSelected,
|
|
127
|
-
isControlSignal: (error) => findWorkflowExitSignal(error, input.exit.exitScope) !== undefined,
|
|
128
|
-
});
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
return { task, chain, parallel };
|
|
132
|
-
}
|
|
1
|
+
export { createWorkflowTaskRunners } from "../../engine/primitives/task.js";
|
|
2
|
+
export type { WorkflowTaskRunners } from "../../engine/primitives/task.js";
|
|
@@ -82,10 +82,10 @@ export interface RunOpts extends Omit<AuthoringContract.RunOpts, "adapters" | "s
|
|
|
82
82
|
onRunEnd?: (runId: string, status: RunStatus, result?: WorkflowOutputValues, error?: string, exitReason?: string) => void;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
export interface RunResult {
|
|
85
|
+
export interface RunResult<TOutputs extends WorkflowOutputValues = WorkflowOutputValues> {
|
|
86
86
|
readonly runId: string;
|
|
87
87
|
readonly status: RunStatus;
|
|
88
|
-
readonly result?:
|
|
88
|
+
readonly result?: Partial<TOutputs>;
|
|
89
89
|
readonly error?: string;
|
|
90
90
|
/** True when the run reached its terminal status through ctx.exit(). */
|
|
91
91
|
readonly exited?: boolean;
|
|
@@ -1,100 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* Algorithm:
|
|
5
|
-
* - Maintain `frontier: Set<string>` — settled stage IDs not yet consumed as parents
|
|
6
|
-
* - At onSpawn(stageId): snapshot current frontier as parents, store in stageParents
|
|
7
|
-
* - At onSettle(stageId): remove stage's parents from frontier, add stageId to frontier
|
|
8
|
-
* - getParents(stageId): return recorded parents
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
export interface StageNode {
|
|
12
|
-
readonly id: string;
|
|
13
|
-
readonly name: string;
|
|
14
|
-
readonly parentIds: readonly string[];
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export class GraphFrontierTracker {
|
|
18
|
-
private frontier: Set<string> = new Set();
|
|
19
|
-
private stageParents: Map<string, string[]> = new Map();
|
|
20
|
-
private nodes: Map<string, StageNode> = new Map();
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Call when ctx.stage(name) is invoked.
|
|
24
|
-
* Returns the inferred parent IDs (snapshot of current frontier).
|
|
25
|
-
*/
|
|
26
|
-
onSpawn(stageId: string, stageName: string): string[] {
|
|
27
|
-
const parents = Array.from(this.frontier);
|
|
28
|
-
this.stageParents.set(stageId, parents);
|
|
29
|
-
|
|
30
|
-
this.nodes.set(stageId, {
|
|
31
|
-
id: stageId,
|
|
32
|
-
name: stageName,
|
|
33
|
-
parentIds: Object.freeze(parents),
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
return parents;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Snapshot the current frontier without registering or mutating a stage.
|
|
41
|
-
*
|
|
42
|
-
* Use this when an already-spawned stage needs its parents refreshed before
|
|
43
|
-
* it starts; `onSpawn` must only be called for the initial `ctx.stage()`
|
|
44
|
-
* invocation that creates the graph node.
|
|
45
|
-
*/
|
|
46
|
-
currentParents(): string[] {
|
|
47
|
-
return Array.from(this.frontier);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Replace the recorded parents for a stage before it settles.
|
|
52
|
-
*
|
|
53
|
-
* Continuation replay uses source-run topology as authoritative: a replayed
|
|
54
|
-
* stage may spawn with provisional parents inferred from the continuation's
|
|
55
|
-
* current frontier, then install the translated source parents before the
|
|
56
|
-
* stage is recorded or settled.
|
|
57
|
-
*/
|
|
58
|
-
replaceParents(stageId: string, parentIds: readonly string[]): void {
|
|
59
|
-
const parents = Array.from(parentIds);
|
|
60
|
-
this.stageParents.set(stageId, parents);
|
|
61
|
-
const node = this.nodes.get(stageId);
|
|
62
|
-
if (node !== undefined) {
|
|
63
|
-
this.nodes.set(stageId, {
|
|
64
|
-
...node,
|
|
65
|
-
parentIds: Object.freeze(parents),
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Call when the stage's Promise settles.
|
|
72
|
-
* Removes the stage's parents from the frontier and adds stageId to frontier.
|
|
73
|
-
*/
|
|
74
|
-
onSettle(stageId: string): void {
|
|
75
|
-
const parents = this.stageParents.get(stageId) ?? [];
|
|
76
|
-
// Remove parents from frontier (they are now consumed)
|
|
77
|
-
for (const parentId of parents) {
|
|
78
|
-
this.frontier.delete(parentId);
|
|
79
|
-
}
|
|
80
|
-
// Add this stage to the frontier
|
|
81
|
-
this.frontier.add(stageId);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/** Get all recorded nodes as an array. */
|
|
85
|
-
getNodes(): StageNode[] {
|
|
86
|
-
return Array.from(this.nodes.values());
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/** Get parent IDs for a stage. */
|
|
90
|
-
getParents(stageId: string): string[] {
|
|
91
|
-
return this.stageParents.get(stageId) ?? [];
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/** Reset to initial state. */
|
|
95
|
-
reset(): void {
|
|
96
|
-
this.frontier.clear();
|
|
97
|
-
this.stageParents.clear();
|
|
98
|
-
this.nodes.clear();
|
|
99
|
-
}
|
|
100
|
-
}
|
|
1
|
+
export { GraphFrontierTracker } from "../../engine/graph-inference.js";
|
|
2
|
+
export type { StageNode } from "../../engine/graph-inference.js";
|
|
@@ -5,10 +5,11 @@
|
|
|
5
5
|
* discovery. The package root re-exports this module directly.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
export {
|
|
8
|
+
export { workflow } from "./authoring/workflow.js";
|
|
9
|
+
export type { Static, TSchema } from "typebox";
|
|
9
10
|
|
|
10
11
|
const REMOVED_RUN_WORKFLOW_MESSAGE =
|
|
11
|
-
"@bastani/workflows no longer exports runWorkflow; author workflows with
|
|
12
|
+
"@bastani/workflows no longer exports runWorkflow; author workflows with workflow({...})";
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* @deprecated Removed imperative workflow API. Kept as a runtime migration
|
|
@@ -18,22 +19,18 @@ export const runWorkflow: never = (() => {
|
|
|
18
19
|
throw new Error(REMOVED_RUN_WORKFLOW_MESSAGE);
|
|
19
20
|
}) as never;
|
|
20
21
|
|
|
21
|
-
// TypeBox authoring surface so jiti-loaded workflows can `import { Type } from
|
|
22
|
-
// "@bastani/workflows"` (the virtual module is built from this file).
|
|
23
|
-
export { Type } from "typebox";
|
|
24
|
-
export type { Static, TSchema } from "typebox";
|
|
25
22
|
export { createRegistry } from "./workflows/registry.js";
|
|
26
23
|
export { normalizeWorkflowName, workflowNamesEqual } from "./workflows/identity.js";
|
|
27
24
|
export type * from "./shared/types.js";
|
|
28
25
|
export { INTERACTIVE_WORKFLOW_POLICY, NON_INTERACTIVE_WORKFLOW_POLICY } from "./shared/types.js";
|
|
29
|
-
export type {
|
|
26
|
+
export type { AuthoredWorkflowDefinition, AuthoredWorkflowSpec, WorkflowInputsFromSchemas, WorkflowOutputsFromSchemas, WorkflowProvidedInputsFromSchemas } from "./authoring/workflow.js";
|
|
30
27
|
export type { WorkflowRegistry } from "./workflows/registry.js";
|
|
31
28
|
|
|
32
29
|
export { run, runTask, runParallel, runChain, resolveInputs } from "./runs/foreground/executor.js";
|
|
33
30
|
export type { RunOpts, RunResult, ResolvedInputs } from "./runs/foreground/executor.js";
|
|
34
31
|
export type { AgentSessionAdapter, StageAdapters } from "./runs/foreground/stage-runner.js";
|
|
35
|
-
export { GraphFrontierTracker } from "./
|
|
36
|
-
export type { StageNode } from "./
|
|
32
|
+
export { GraphFrontierTracker } from "./engine/graph-inference.js";
|
|
33
|
+
export type { StageNode } from "./engine/graph-inference.js";
|
|
37
34
|
export { setupGitWorktree } from "./runs/shared/worktree.js";
|
|
38
35
|
export type { GitWorktreeSetupOptions, GitWorktreeSetupResult } from "./runs/shared/worktree.js";
|
|
39
36
|
export { createStore, store } from "./shared/store.js";
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/** Workflow authoring primitives, stage/session contracts, and task option types. */
|
|
2
|
-
import type { BashCommandPolicy } from "@bastani/atomic";
|
|
3
2
|
import type { Static, TSchema } from "typebox";
|
|
4
3
|
export type { Static, TSchema };
|
|
5
4
|
export type WorkflowSerializablePrimitive = string | number | boolean | null;
|
|
@@ -28,10 +27,11 @@ export type RunStatus = "pending" | "running" | "paused" | WorkflowExitStatus |
|
|
|
28
27
|
export type WorkflowDetailsMode = "named" | "single" | "parallel" | "chain" | "inspection" | "control";
|
|
29
28
|
export type WorkflowDetailsStatus = "accepted" | "running" | WorkflowExitStatus | "failed" | "killed" | "noop";
|
|
30
29
|
export type WorkflowAction = "list" | "get" | "inputs" | "run" | "status" | "interrupt" | "resume";
|
|
30
|
+
type WorkflowExitOutputValues<TOutputs extends WorkflowOutputValues = WorkflowOutputValues> = [keyof TOutputs] extends [never] ? Readonly<Record<string, never>> : Partial<TOutputs>;
|
|
31
31
|
export interface WorkflowExitOptions<TOutputs extends WorkflowOutputValues = WorkflowOutputValues> {
|
|
32
32
|
readonly status?: WorkflowExitStatus;
|
|
33
33
|
readonly reason?: string;
|
|
34
|
-
readonly outputs?:
|
|
34
|
+
readonly outputs?: WorkflowExitOutputValues<TOutputs>;
|
|
35
35
|
}
|
|
36
36
|
export interface WorkflowModelFallbackFields {
|
|
37
37
|
/** Ordered model IDs to try after `model` fails; entries may use `:off|minimal|low|medium|high|xhigh` reasoning suffixes. */
|
|
@@ -124,7 +124,6 @@ export interface StageOptions<TSchemaDef extends TSchema | undefined = TSchema |
|
|
|
124
124
|
readonly noTools?: "all" | "builtin";
|
|
125
125
|
readonly excludedTools?: readonly string[];
|
|
126
126
|
readonly customTools?: readonly WorkflowCustomToolDefinition[];
|
|
127
|
-
readonly bashPolicy?: BashCommandPolicy;
|
|
128
127
|
readonly cwd?: string;
|
|
129
128
|
readonly agentDir?: string;
|
|
130
129
|
readonly scopedModels?: readonly WorkflowScopedModel[];
|
|
@@ -347,6 +346,13 @@ export interface WorkflowRunChildOptions<TInputs extends WorkflowInputValues = W
|
|
|
347
346
|
readonly inputs?: TInputs;
|
|
348
347
|
readonly stageName?: string;
|
|
349
348
|
}
|
|
349
|
+
type WorkflowRequiredKeys<T extends object> = {
|
|
350
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? never : K;
|
|
351
|
+
}[keyof T];
|
|
352
|
+
export type WorkflowRunChildOptionsArgument<TInputs extends WorkflowInputValues = WorkflowInputValues> = [WorkflowRequiredKeys<TInputs>] extends [never] ? WorkflowRunChildOptions<TInputs> : WorkflowRunChildOptions<TInputs> & {
|
|
353
|
+
readonly inputs: TInputs;
|
|
354
|
+
};
|
|
355
|
+
export type WorkflowRunChildArgs<TInputs extends WorkflowInputValues = WorkflowInputValues> = [WorkflowRequiredKeys<TInputs>] extends [never] ? readonly [options?: WorkflowRunChildOptionsArgument<NoInfer<TInputs>>] : readonly [options: WorkflowRunChildOptionsArgument<NoInfer<TInputs>>];
|
|
350
356
|
export interface WorkflowCompletedChildResult<TOutputs extends WorkflowOutputValues = WorkflowOutputValues> extends WorkflowSerializableObject {
|
|
351
357
|
readonly workflow: string;
|
|
352
358
|
readonly runId: string;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/** Workflow authoring primitives, stage/session contracts, and task option types. */
|
|
2
2
|
|
|
3
|
-
import type { BashCommandPolicy } from "@bastani/atomic";
|
|
4
3
|
import type { Static, TSchema } from "typebox";
|
|
5
4
|
|
|
6
5
|
export type { Static, TSchema };
|
|
@@ -38,10 +37,14 @@ export type WorkflowDetailsMode = "named" | "single" | "parallel" | "chain" | "i
|
|
|
38
37
|
export type WorkflowDetailsStatus = "accepted" | "running" | WorkflowExitStatus | "failed" | "killed" | "noop";
|
|
39
38
|
export type WorkflowAction = "list" | "get" | "inputs" | "run" | "status" | "interrupt" | "resume";
|
|
40
39
|
|
|
40
|
+
type WorkflowExitOutputValues<TOutputs extends WorkflowOutputValues = WorkflowOutputValues> = [keyof TOutputs] extends [never]
|
|
41
|
+
? Readonly<Record<string, never>>
|
|
42
|
+
: Partial<TOutputs>;
|
|
43
|
+
|
|
41
44
|
export interface WorkflowExitOptions<TOutputs extends WorkflowOutputValues = WorkflowOutputValues> {
|
|
42
45
|
readonly status?: WorkflowExitStatus;
|
|
43
46
|
readonly reason?: string;
|
|
44
|
-
readonly outputs?:
|
|
47
|
+
readonly outputs?: WorkflowExitOutputValues<TOutputs>;
|
|
45
48
|
}
|
|
46
49
|
|
|
47
50
|
export interface WorkflowModelFallbackFields {
|
|
@@ -156,7 +159,6 @@ export interface StageOptions<TSchemaDef extends TSchema | undefined = TSchema |
|
|
|
156
159
|
readonly noTools?: "all" | "builtin";
|
|
157
160
|
readonly excludedTools?: readonly string[];
|
|
158
161
|
readonly customTools?: readonly WorkflowCustomToolDefinition[];
|
|
159
|
-
readonly bashPolicy?: BashCommandPolicy;
|
|
160
162
|
readonly cwd?: string;
|
|
161
163
|
readonly agentDir?: string;
|
|
162
164
|
readonly scopedModels?: readonly WorkflowScopedModel[];
|
|
@@ -402,6 +404,18 @@ export interface WorkflowRunChildOptions<TInputs extends WorkflowInputValues = W
|
|
|
402
404
|
readonly stageName?: string;
|
|
403
405
|
}
|
|
404
406
|
|
|
407
|
+
type WorkflowRequiredKeys<T extends object> = {
|
|
408
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? never : K;
|
|
409
|
+
}[keyof T];
|
|
410
|
+
|
|
411
|
+
export type WorkflowRunChildOptionsArgument<TInputs extends WorkflowInputValues = WorkflowInputValues> = [WorkflowRequiredKeys<TInputs>] extends [never]
|
|
412
|
+
? WorkflowRunChildOptions<TInputs>
|
|
413
|
+
: WorkflowRunChildOptions<TInputs> & { readonly inputs: TInputs };
|
|
414
|
+
|
|
415
|
+
export type WorkflowRunChildArgs<TInputs extends WorkflowInputValues = WorkflowInputValues> = [WorkflowRequiredKeys<TInputs>] extends [never]
|
|
416
|
+
? readonly [options?: WorkflowRunChildOptionsArgument<NoInfer<TInputs>>]
|
|
417
|
+
: readonly [options: WorkflowRunChildOptionsArgument<NoInfer<TInputs>>];
|
|
418
|
+
|
|
405
419
|
export interface WorkflowCompletedChildResult<TOutputs extends WorkflowOutputValues = WorkflowOutputValues> extends WorkflowSerializableObject {
|
|
406
420
|
readonly workflow: string;
|
|
407
421
|
readonly runId: string;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/** Workflow authoring UI, builder, run, and result contract types. */
|
|
2
2
|
import type { KeybindingsManager, Theme } from "@bastani/atomic";
|
|
3
3
|
import type { Component, OverlayHandle, OverlayOptions, TUI } from "@earendil-works/pi-tui";
|
|
4
|
-
import type {
|
|
5
|
-
import type { RunStatus, StageAdapters, StageContext, StageOptions, WorkflowAction, WorkflowArtifact, WorkflowChainOptions, WorkflowContextMode, WorkflowDetailsMode, WorkflowChildResult, WorkflowDetailsStatus, WorkflowExecutionMode, WorkflowExitOptions, WorkflowInputSchemaMap, WorkflowInputValues, WorkflowMcpPort, WorkflowModelCatalogPort, WorkflowOutputSchemaMap, WorkflowOutputValues, WorkflowParallelOptions, WorkflowPersistencePort,
|
|
4
|
+
import type { TSchema } from "typebox";
|
|
5
|
+
import type { RunStatus, StageAdapters, StageContext, StageOptions, WorkflowAction, WorkflowArtifact, WorkflowChainOptions, WorkflowContextMode, WorkflowDetailsMode, WorkflowChildResult, WorkflowDetailsStatus, WorkflowExecutionMode, WorkflowExitOptions, WorkflowInputSchemaMap, WorkflowInputValues, WorkflowMcpPort, WorkflowModelCatalogPort, WorkflowOutputSchemaMap, WorkflowOutputValues, WorkflowParallelOptions, WorkflowPersistencePort, WorkflowRunChildArgs, WorkflowSerializableObject, WorkflowSerializableValue, WorkflowTaskOptions, WorkflowTaskResult, WorkflowTaskStep } from "./authoring-contract-stage.js";
|
|
6
6
|
export type WorkflowCustomUiComponent = Component & {
|
|
7
7
|
dispose?(): void;
|
|
8
8
|
};
|
|
@@ -55,7 +55,7 @@ export interface WorkflowRunContext<TInputs extends WorkflowInputValues = Workfl
|
|
|
55
55
|
task(name: string, options: WorkflowTaskOptions): Promise<WorkflowTaskResult>;
|
|
56
56
|
chain(steps: readonly WorkflowTaskStep[], options?: WorkflowChainOptions): Promise<WorkflowTaskResult[]>;
|
|
57
57
|
parallel(steps: readonly WorkflowTaskStep[], options?: WorkflowParallelOptions): Promise<WorkflowTaskResult[]>;
|
|
58
|
-
workflow<TChildInputs extends WorkflowInputValues, TChildOutputs extends WorkflowOutputValues>(definition: WorkflowDefinition<TChildInputs, TChildOutputs> & TDefinitionBrand,
|
|
58
|
+
workflow<TChildInputs extends WorkflowInputValues, TChildOutputs extends WorkflowOutputValues, TChildRunInputs extends WorkflowInputValues = TChildInputs>(definition: WorkflowDefinition<TChildInputs, TChildOutputs, TChildRunInputs> & TDefinitionBrand, ...args: WorkflowRunChildArgs<TChildRunInputs>): Promise<WorkflowChildResult<TChildOutputs>>;
|
|
59
59
|
readonly ui: WorkflowUIContext;
|
|
60
60
|
}
|
|
61
61
|
export type WorkflowRunFn<TInputs extends WorkflowInputValues = WorkflowInputValues, TOutputs extends WorkflowOutputValues = WorkflowOutputValues, TDefinitionBrand extends object = {}> = (ctx: WorkflowRunContext<TInputs, TDefinitionBrand, TOutputs>) => Promise<TOutputs> | TOutputs;
|
|
@@ -85,36 +85,7 @@ export interface WorkflowDefinition<TInputs extends WorkflowInputValues = Workfl
|
|
|
85
85
|
readonly inputBindings?: WorkflowInputBindings;
|
|
86
86
|
run(ctx: WorkflowRunContext<TInputs, TDefinitionBrand, TOutputs>): Promise<TOutputs> | TOutputs;
|
|
87
87
|
}
|
|
88
|
-
type DeclaredResolvedEntry<K extends string, S extends TSchema> = S extends TOptional<TSchema> ? {
|
|
89
|
-
readonly [P in K]?: Static<S>;
|
|
90
|
-
} : {
|
|
91
|
-
readonly [P in K]: Static<S>;
|
|
92
|
-
};
|
|
93
|
-
type DeclaredProvidedEntry<K extends string, S extends TSchema> = S extends TOptional<TSchema> | {
|
|
94
|
-
readonly default: WorkflowSerializableValue;
|
|
95
|
-
} ? {
|
|
96
|
-
readonly [P in K]?: Static<S>;
|
|
97
|
-
} : {
|
|
98
|
-
readonly [P in K]: Static<S>;
|
|
99
|
-
};
|
|
100
|
-
type Simplify<T> = {
|
|
101
|
-
[K in keyof T]: T[K];
|
|
102
|
-
} & {};
|
|
103
88
|
export type NoExtraOutputs<TDeclared extends WorkflowOutputValues, TActual extends TDeclared> = TActual & Record<Exclude<keyof TActual, keyof TDeclared>, never>;
|
|
104
|
-
export interface WorkflowBuilder<TInputs extends WorkflowInputValues = {}, TOutputs extends WorkflowOutputValues = {}, TRunInputs extends WorkflowInputValues = TInputs, TDefinitionBrand extends object = {}, TCompiledDefinition extends WorkflowDefinition<TInputs, TOutputs, TRunInputs, TDefinitionBrand> = WorkflowDefinition<TInputs, TOutputs, TRunInputs, TDefinitionBrand>> {
|
|
105
|
-
description(text: string): WorkflowBuilder<TInputs, TOutputs, TRunInputs, TDefinitionBrand, TCompiledDefinition>;
|
|
106
|
-
input<K extends string, S extends TSchema>(key: K, schema: S): WorkflowBuilder<Simplify<TInputs & DeclaredResolvedEntry<K, S>>, TOutputs, Simplify<TRunInputs & DeclaredProvidedEntry<K, S>>, TDefinitionBrand, WorkflowDefinition<Simplify<TInputs & DeclaredResolvedEntry<K, S>>, TOutputs, Simplify<TRunInputs & DeclaredProvidedEntry<K, S>>, TDefinitionBrand> & TDefinitionBrand>;
|
|
107
|
-
output<K extends string, S extends TSchema>(key: K, schema: S): WorkflowBuilder<TInputs, Simplify<TOutputs & (DeclaredResolvedEntry<K, S> & WorkflowOutputValues)>, TRunInputs, TDefinitionBrand, WorkflowDefinition<TInputs, Simplify<TOutputs & (DeclaredResolvedEntry<K, S> & WorkflowOutputValues)>, TRunInputs, TDefinitionBrand> & TDefinitionBrand>;
|
|
108
|
-
worktreeFromInputs(binding: WorkflowWorktreeInputBinding): WorkflowBuilder<TInputs, TOutputs, TRunInputs, TDefinitionBrand, TCompiledDefinition>;
|
|
109
|
-
run<TActualOutputs extends TOutputs>(fn: (ctx: WorkflowRunContext<TInputs, TDefinitionBrand, TOutputs>) => Promise<NoExtraOutputs<TOutputs, TActualOutputs>> | NoExtraOutputs<TOutputs, TActualOutputs>): CompletedWorkflowBuilder<TInputs, TOutputs, TRunInputs, TDefinitionBrand, TCompiledDefinition>;
|
|
110
|
-
}
|
|
111
|
-
export interface CompletedWorkflowBuilder<TInputs extends WorkflowInputValues = {}, TOutputs extends WorkflowOutputValues = {}, TRunInputs extends WorkflowInputValues = TInputs, TDefinitionBrand extends object = {}, TCompiledDefinition extends WorkflowDefinition<TInputs, TOutputs, TRunInputs, TDefinitionBrand> = WorkflowDefinition<TInputs, TOutputs, TRunInputs, TDefinitionBrand>> extends WorkflowBuilder<TInputs, TOutputs, TRunInputs, TDefinitionBrand, TCompiledDefinition> {
|
|
112
|
-
description(text: string): CompletedWorkflowBuilder<TInputs, TOutputs, TRunInputs, TDefinitionBrand, TCompiledDefinition>;
|
|
113
|
-
input<K extends string, S extends TSchema>(key: K, schema: S): CompletedWorkflowBuilder<Simplify<TInputs & DeclaredResolvedEntry<K, S>>, TOutputs, Simplify<TRunInputs & DeclaredProvidedEntry<K, S>>, TDefinitionBrand, WorkflowDefinition<Simplify<TInputs & DeclaredResolvedEntry<K, S>>, TOutputs, Simplify<TRunInputs & DeclaredProvidedEntry<K, S>>, TDefinitionBrand> & TDefinitionBrand>;
|
|
114
|
-
output<K extends string, S extends TSchema>(key: K, schema: S): CompletedWorkflowBuilder<TInputs, Simplify<TOutputs & (DeclaredResolvedEntry<K, S> & WorkflowOutputValues)>, TRunInputs, TDefinitionBrand, WorkflowDefinition<TInputs, Simplify<TOutputs & (DeclaredResolvedEntry<K, S> & WorkflowOutputValues)>, TRunInputs, TDefinitionBrand> & TDefinitionBrand>;
|
|
115
|
-
worktreeFromInputs(binding: WorkflowWorktreeInputBinding): CompletedWorkflowBuilder<TInputs, TOutputs, TRunInputs, TDefinitionBrand, TCompiledDefinition>;
|
|
116
|
-
compile(): TCompiledDefinition;
|
|
117
|
-
}
|
|
118
89
|
export interface WorkflowOverlayAdapter extends WorkflowSerializableObject {
|
|
119
90
|
}
|
|
120
91
|
export interface RunSnapshot extends WorkflowSerializableObject {
|
|
@@ -233,4 +204,3 @@ export interface GitWorktreeSetupResult extends WorkflowSerializableObject {
|
|
|
233
204
|
readonly repositoryRoot: string;
|
|
234
205
|
readonly created: boolean;
|
|
235
206
|
}
|
|
236
|
-
export {};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import type { KeybindingsManager, Theme } from "@bastani/atomic";
|
|
4
4
|
import type { Component, OverlayHandle, OverlayOptions, TUI } from "@earendil-works/pi-tui";
|
|
5
|
-
import type {
|
|
5
|
+
import type { TSchema } from "typebox";
|
|
6
6
|
import type {
|
|
7
7
|
RunStatus,
|
|
8
8
|
StageAdapters,
|
|
@@ -25,7 +25,7 @@ import type {
|
|
|
25
25
|
WorkflowOutputValues,
|
|
26
26
|
WorkflowParallelOptions,
|
|
27
27
|
WorkflowPersistencePort,
|
|
28
|
-
|
|
28
|
+
WorkflowRunChildArgs,
|
|
29
29
|
WorkflowSerializableObject,
|
|
30
30
|
WorkflowSerializableValue,
|
|
31
31
|
WorkflowTaskOptions,
|
|
@@ -95,9 +95,13 @@ export interface WorkflowRunContext<
|
|
|
95
95
|
task(name: string, options: WorkflowTaskOptions): Promise<WorkflowTaskResult>;
|
|
96
96
|
chain(steps: readonly WorkflowTaskStep[], options?: WorkflowChainOptions): Promise<WorkflowTaskResult[]>;
|
|
97
97
|
parallel(steps: readonly WorkflowTaskStep[], options?: WorkflowParallelOptions): Promise<WorkflowTaskResult[]>;
|
|
98
|
-
workflow<
|
|
99
|
-
|
|
100
|
-
|
|
98
|
+
workflow<
|
|
99
|
+
TChildInputs extends WorkflowInputValues,
|
|
100
|
+
TChildOutputs extends WorkflowOutputValues,
|
|
101
|
+
TChildRunInputs extends WorkflowInputValues = TChildInputs,
|
|
102
|
+
>(
|
|
103
|
+
definition: WorkflowDefinition<TChildInputs, TChildOutputs, TChildRunInputs> & TDefinitionBrand,
|
|
104
|
+
...args: WorkflowRunChildArgs<TChildRunInputs>
|
|
101
105
|
): Promise<WorkflowChildResult<TChildOutputs>>;
|
|
102
106
|
readonly ui: WorkflowUIContext;
|
|
103
107
|
}
|
|
@@ -143,85 +147,9 @@ export interface WorkflowDefinition<
|
|
|
143
147
|
run(ctx: WorkflowRunContext<TInputs, TDefinitionBrand, TOutputs>): Promise<TOutputs> | TOutputs;
|
|
144
148
|
}
|
|
145
149
|
|
|
146
|
-
type DeclaredResolvedEntry<K extends string, S extends TSchema> = S extends TOptional<TSchema>
|
|
147
|
-
? { readonly [P in K]?: Static<S> }
|
|
148
|
-
: { readonly [P in K]: Static<S> };
|
|
149
|
-
|
|
150
|
-
type DeclaredProvidedEntry<K extends string, S extends TSchema> =
|
|
151
|
-
S extends TOptional<TSchema> | { readonly default: WorkflowSerializableValue }
|
|
152
|
-
? { readonly [P in K]?: Static<S> }
|
|
153
|
-
: { readonly [P in K]: Static<S> };
|
|
154
|
-
|
|
155
|
-
type Simplify<T> = { [K in keyof T]: T[K] } & {};
|
|
156
150
|
export type NoExtraOutputs<TDeclared extends WorkflowOutputValues, TActual extends TDeclared> = TActual &
|
|
157
151
|
Record<Exclude<keyof TActual, keyof TDeclared>, never>;
|
|
158
152
|
|
|
159
|
-
export interface WorkflowBuilder<
|
|
160
|
-
TInputs extends WorkflowInputValues = {},
|
|
161
|
-
TOutputs extends WorkflowOutputValues = {},
|
|
162
|
-
TRunInputs extends WorkflowInputValues = TInputs,
|
|
163
|
-
TDefinitionBrand extends object = {},
|
|
164
|
-
TCompiledDefinition extends WorkflowDefinition<TInputs, TOutputs, TRunInputs, TDefinitionBrand> = WorkflowDefinition<TInputs, TOutputs, TRunInputs, TDefinitionBrand>,
|
|
165
|
-
> {
|
|
166
|
-
description(text: string): WorkflowBuilder<TInputs, TOutputs, TRunInputs, TDefinitionBrand, TCompiledDefinition>;
|
|
167
|
-
input<K extends string, S extends TSchema>(
|
|
168
|
-
key: K,
|
|
169
|
-
schema: S,
|
|
170
|
-
): WorkflowBuilder<
|
|
171
|
-
Simplify<TInputs & DeclaredResolvedEntry<K, S>>,
|
|
172
|
-
TOutputs,
|
|
173
|
-
Simplify<TRunInputs & DeclaredProvidedEntry<K, S>>,
|
|
174
|
-
TDefinitionBrand,
|
|
175
|
-
WorkflowDefinition<Simplify<TInputs & DeclaredResolvedEntry<K, S>>, TOutputs, Simplify<TRunInputs & DeclaredProvidedEntry<K, S>>, TDefinitionBrand> & TDefinitionBrand
|
|
176
|
-
>;
|
|
177
|
-
output<K extends string, S extends TSchema>(
|
|
178
|
-
key: K,
|
|
179
|
-
schema: S,
|
|
180
|
-
): WorkflowBuilder<
|
|
181
|
-
TInputs,
|
|
182
|
-
Simplify<TOutputs & (DeclaredResolvedEntry<K, S> & WorkflowOutputValues)>,
|
|
183
|
-
TRunInputs,
|
|
184
|
-
TDefinitionBrand,
|
|
185
|
-
WorkflowDefinition<TInputs, Simplify<TOutputs & (DeclaredResolvedEntry<K, S> & WorkflowOutputValues)>, TRunInputs, TDefinitionBrand> & TDefinitionBrand
|
|
186
|
-
>;
|
|
187
|
-
worktreeFromInputs(binding: WorkflowWorktreeInputBinding): WorkflowBuilder<TInputs, TOutputs, TRunInputs, TDefinitionBrand, TCompiledDefinition>;
|
|
188
|
-
run<TActualOutputs extends TOutputs>(
|
|
189
|
-
fn: (ctx: WorkflowRunContext<TInputs, TDefinitionBrand, TOutputs>) => Promise<NoExtraOutputs<TOutputs, TActualOutputs>> | NoExtraOutputs<TOutputs, TActualOutputs>,
|
|
190
|
-
): CompletedWorkflowBuilder<TInputs, TOutputs, TRunInputs, TDefinitionBrand, TCompiledDefinition>;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
export interface CompletedWorkflowBuilder<
|
|
194
|
-
TInputs extends WorkflowInputValues = {},
|
|
195
|
-
TOutputs extends WorkflowOutputValues = {},
|
|
196
|
-
TRunInputs extends WorkflowInputValues = TInputs,
|
|
197
|
-
TDefinitionBrand extends object = {},
|
|
198
|
-
TCompiledDefinition extends WorkflowDefinition<TInputs, TOutputs, TRunInputs, TDefinitionBrand> = WorkflowDefinition<TInputs, TOutputs, TRunInputs, TDefinitionBrand>,
|
|
199
|
-
> extends WorkflowBuilder<TInputs, TOutputs, TRunInputs, TDefinitionBrand, TCompiledDefinition> {
|
|
200
|
-
description(text: string): CompletedWorkflowBuilder<TInputs, TOutputs, TRunInputs, TDefinitionBrand, TCompiledDefinition>;
|
|
201
|
-
input<K extends string, S extends TSchema>(
|
|
202
|
-
key: K,
|
|
203
|
-
schema: S,
|
|
204
|
-
): CompletedWorkflowBuilder<
|
|
205
|
-
Simplify<TInputs & DeclaredResolvedEntry<K, S>>,
|
|
206
|
-
TOutputs,
|
|
207
|
-
Simplify<TRunInputs & DeclaredProvidedEntry<K, S>>,
|
|
208
|
-
TDefinitionBrand,
|
|
209
|
-
WorkflowDefinition<Simplify<TInputs & DeclaredResolvedEntry<K, S>>, TOutputs, Simplify<TRunInputs & DeclaredProvidedEntry<K, S>>, TDefinitionBrand> & TDefinitionBrand
|
|
210
|
-
>;
|
|
211
|
-
output<K extends string, S extends TSchema>(
|
|
212
|
-
key: K,
|
|
213
|
-
schema: S,
|
|
214
|
-
): CompletedWorkflowBuilder<
|
|
215
|
-
TInputs,
|
|
216
|
-
Simplify<TOutputs & (DeclaredResolvedEntry<K, S> & WorkflowOutputValues)>,
|
|
217
|
-
TRunInputs,
|
|
218
|
-
TDefinitionBrand,
|
|
219
|
-
WorkflowDefinition<TInputs, Simplify<TOutputs & (DeclaredResolvedEntry<K, S> & WorkflowOutputValues)>, TRunInputs, TDefinitionBrand> & TDefinitionBrand
|
|
220
|
-
>;
|
|
221
|
-
worktreeFromInputs(binding: WorkflowWorktreeInputBinding): CompletedWorkflowBuilder<TInputs, TOutputs, TRunInputs, TDefinitionBrand, TCompiledDefinition>;
|
|
222
|
-
compile(): TCompiledDefinition;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
153
|
export interface WorkflowOverlayAdapter extends WorkflowSerializableObject {}
|
|
226
154
|
export interface RunSnapshot extends WorkflowSerializableObject {}
|
|
227
155
|
export interface ActiveRunEntry {
|