@bastani/atomic 0.9.0-alpha.1 → 0.9.0-alpha.3
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 +29 -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 +19 -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-ledger.ts +2 -0
- package/dist/builtin/workflows/builtin/goal-reports.ts +5 -0
- package/dist/builtin/workflows/builtin/goal-runner.ts +17 -20
- package/dist/builtin/workflows/builtin/goal-types.ts +2 -0
- package/dist/builtin/workflows/builtin/goal.d.ts +1 -0
- package/dist/builtin/workflows/builtin/goal.ts +40 -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/prompt-refinement.ts +102 -0
- package/dist/builtin/workflows/builtin/ralph-core.ts +6 -4
- package/dist/builtin/workflows/builtin/ralph-runner.ts +22 -24
- package/dist/builtin/workflows/builtin/ralph.d.ts +2 -0
- package/dist/builtin/workflows/builtin/ralph.ts +46 -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-prompts.ts +3 -1
- 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/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +0 -1
- package/dist/core/system-prompt.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 +991 -176
- 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
|
@@ -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 {
|
|
@@ -55,10 +55,10 @@ export type WorkflowExitOptions<TOutputs extends WorkflowOutputValues = Workflow
|
|
|
55
55
|
// ---------------------------------------------------------------------------
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
|
-
* Inputs and outputs are declared
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
* via TypeBox `Value`.
|
|
58
|
+
* Inputs and outputs are declared as TypeBox schema maps on
|
|
59
|
+
* `workflow({ inputs: { ... }, outputs: { ... } })`. Authors import `Type`
|
|
60
|
+
* from typebox, while the workflow authoring types thread the corresponding
|
|
61
|
+
* `Static<>` types and the runtime validates via TypeBox `Value`.
|
|
62
62
|
*/
|
|
63
63
|
export type WorkflowInputSchemaMap = AuthoringContract.WorkflowInputSchemaMap;
|
|
64
64
|
export type WorkflowOutputSchemaMap = AuthoringContract.WorkflowOutputSchemaMap;
|
|
@@ -100,6 +100,18 @@ export interface WorkflowRunChildOptions<TInputs extends WorkflowInputValues = W
|
|
|
100
100
|
readonly stageName?: string;
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
+
type WorkflowRequiredKeys<T extends object> = {
|
|
104
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? never : K;
|
|
105
|
+
}[keyof T];
|
|
106
|
+
|
|
107
|
+
export type WorkflowRunChildOptionsArgument<TInputs extends WorkflowInputValues = WorkflowInputValues> = [WorkflowRequiredKeys<TInputs>] extends [never]
|
|
108
|
+
? WorkflowRunChildOptions<TInputs>
|
|
109
|
+
: WorkflowRunChildOptions<TInputs> & { readonly inputs: TInputs };
|
|
110
|
+
|
|
111
|
+
export type WorkflowRunChildArgs<TInputs extends WorkflowInputValues = WorkflowInputValues> = [WorkflowRequiredKeys<TInputs>] extends [never]
|
|
112
|
+
? readonly [options?: WorkflowRunChildOptionsArgument<NoInfer<TInputs>>]
|
|
113
|
+
: readonly [options: WorkflowRunChildOptionsArgument<NoInfer<TInputs>>];
|
|
114
|
+
|
|
103
115
|
export type WorkflowCompletedChildResult<TOutputs extends WorkflowOutputValues = WorkflowOutputValues> = AuthoringContract.WorkflowCompletedChildResult<TOutputs>;
|
|
104
116
|
export type WorkflowExitedChildResult<TOutputs extends WorkflowOutputValues = WorkflowOutputValues> = AuthoringContract.WorkflowExitedChildResult<TOutputs>;
|
|
105
117
|
export type WorkflowChildResult<TOutputs extends WorkflowOutputValues = WorkflowOutputValues> = AuthoringContract.WorkflowChildResult<TOutputs>;
|
|
@@ -359,9 +371,13 @@ export interface WorkflowRunContext<
|
|
|
359
371
|
/** Run tasks in parallel. Missing step tasks use the first available task as a fallback. */
|
|
360
372
|
parallel(steps: readonly WorkflowTaskStep[], options?: WorkflowParallelOptions): Promise<WorkflowTaskResult[]>;
|
|
361
373
|
/** Execute a reusable child workflow by compiled workflow definition. */
|
|
362
|
-
workflow<
|
|
363
|
-
|
|
364
|
-
|
|
374
|
+
workflow<
|
|
375
|
+
TChildInputs extends WorkflowInputValues,
|
|
376
|
+
TChildOutputs extends WorkflowOutputValues,
|
|
377
|
+
TChildRunInputs extends WorkflowInputValues = TChildInputs,
|
|
378
|
+
>(
|
|
379
|
+
definition: WorkflowDefinition<TChildInputs, TChildOutputs, TChildRunInputs>,
|
|
380
|
+
...args: WorkflowRunChildArgs<TChildRunInputs>
|
|
365
381
|
): Promise<WorkflowChildResult<TChildOutputs>>;
|
|
366
382
|
/** HIL primitives for user interaction during a run. */
|
|
367
383
|
readonly ui: WorkflowUIContext;
|
|
@@ -403,6 +419,7 @@ export type WorkflowDefinitionBrand = { readonly [workflowDefinitionBrand]: true
|
|
|
403
419
|
export interface WorkflowDefinition<
|
|
404
420
|
TInputs extends WorkflowInputValues = WorkflowInputValues,
|
|
405
421
|
TOutputs extends WorkflowOutputValues = WorkflowOutputValues,
|
|
406
|
-
|
|
422
|
+
TRunInputs extends WorkflowInputValues = TInputs,
|
|
423
|
+
> extends Omit<AuthoringContract.WorkflowDefinition<TInputs, TOutputs, TRunInputs, WorkflowDefinitionBrand>, "run">, WorkflowDefinitionBrand {
|
|
407
424
|
readonly run: WorkflowRunFn<TInputs, TOutputs>;
|
|
408
425
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { Static, TOptional, TSchema } from "typebox";
|
|
2
|
+
import type { WorkflowInputSchemaMap, WorkflowInputValues, WorkflowOutputSchemaMap, WorkflowOutputValues, WorkflowSerializableValue, WorkflowWorktreeInputBinding } from "./authoring-contract.js";
|
|
3
|
+
type SchemaKeys<TSchemas> = keyof TSchemas & string;
|
|
4
|
+
type Simplify<T> = {
|
|
5
|
+
[K in keyof T]: T[K];
|
|
6
|
+
} & {};
|
|
7
|
+
type UnionToIntersection<T> = (T extends T ? (value: T) => void : never) extends (value: infer TIntersection) => void ? TIntersection : never;
|
|
8
|
+
type WorkflowInputShape<T> = T extends WorkflowInputValues ? T : never;
|
|
9
|
+
type WorkflowOutputShape<T> = T extends WorkflowOutputValues ? T : never;
|
|
10
|
+
type DeclaredResolvedEntry<K extends string, S extends TSchema> = S extends TOptional<TSchema> ? {
|
|
11
|
+
readonly [P in K]?: Static<S> & WorkflowSerializableValue;
|
|
12
|
+
} : {
|
|
13
|
+
readonly [P in K]: Static<S> & WorkflowSerializableValue;
|
|
14
|
+
};
|
|
15
|
+
type DeclaredProvidedEntry<K extends string, S extends TSchema> = S extends TOptional<TSchema> | {
|
|
16
|
+
readonly default: WorkflowSerializableValue;
|
|
17
|
+
} ? {
|
|
18
|
+
readonly [P in K]?: Static<S> & WorkflowSerializableValue;
|
|
19
|
+
} : {
|
|
20
|
+
readonly [P in K]: Static<S> & WorkflowSerializableValue;
|
|
21
|
+
};
|
|
22
|
+
type DeclaredOutputEntry<K extends string, S extends TSchema> = S extends TOptional<TSchema> ? {
|
|
23
|
+
readonly [P in K]?: Static<S> & WorkflowSerializableValue;
|
|
24
|
+
} : {
|
|
25
|
+
readonly [P in K]: Static<S> & WorkflowSerializableValue;
|
|
26
|
+
};
|
|
27
|
+
type WorkflowResolvedInputShapeFromSchemas<TSchemas extends WorkflowInputSchemaMap> = [SchemaKeys<TSchemas>] extends [never] ? {} : Simplify<UnionToIntersection<{
|
|
28
|
+
readonly [K in SchemaKeys<TSchemas>]: DeclaredResolvedEntry<K, TSchemas[K]>;
|
|
29
|
+
}[SchemaKeys<TSchemas>]>>;
|
|
30
|
+
type WorkflowProvidedInputShapeFromSchemas<TSchemas extends WorkflowInputSchemaMap> = [SchemaKeys<TSchemas>] extends [never] ? {} : Simplify<UnionToIntersection<{
|
|
31
|
+
readonly [K in SchemaKeys<TSchemas>]: DeclaredProvidedEntry<K, TSchemas[K]>;
|
|
32
|
+
}[SchemaKeys<TSchemas>]>>;
|
|
33
|
+
export type WorkflowInputsFromSchemas<TSchemas extends WorkflowInputSchemaMap> = WorkflowInputShape<WorkflowResolvedInputShapeFromSchemas<TSchemas>>;
|
|
34
|
+
export type WorkflowProvidedInputsFromSchemas<TSchemas extends WorkflowInputSchemaMap> = WorkflowInputShape<WorkflowProvidedInputShapeFromSchemas<TSchemas>>;
|
|
35
|
+
type WorkflowDeclaredOutputsFromSchemas<TSchemas extends WorkflowOutputSchemaMap> = [SchemaKeys<TSchemas>] extends [never] ? {} : Simplify<UnionToIntersection<{
|
|
36
|
+
readonly [K in SchemaKeys<TSchemas>]: DeclaredOutputEntry<K, TSchemas[K]>;
|
|
37
|
+
}[SchemaKeys<TSchemas>]>>;
|
|
38
|
+
export type WorkflowOutputsFromSchemas<TSchemas extends WorkflowOutputSchemaMap> = WorkflowOutputShape<WorkflowDeclaredOutputsFromSchemas<TSchemas>>;
|
|
39
|
+
export type NoExtraWorkflowOutputs<TDeclared, TActual extends TDeclared> = TActual & Record<Exclude<keyof TActual, keyof TDeclared>, never>;
|
|
40
|
+
export type WorkflowRunOutputResult<TOutputs extends WorkflowOutputSchemaMap, TActualOutputs extends WorkflowOutputsFromSchemas<TOutputs>> = NoExtraWorkflowOutputs<WorkflowOutputsFromSchemas<TOutputs>, TActualOutputs>;
|
|
41
|
+
export interface AuthoredWorkflowSpec<TInputs extends WorkflowInputSchemaMap = {}, TOutputs extends WorkflowOutputSchemaMap = WorkflowOutputSchemaMap, TActualOutputs extends WorkflowOutputsFromSchemas<TOutputs> = WorkflowOutputsFromSchemas<TOutputs>, TRunContext = unknown> {
|
|
42
|
+
readonly name?: string;
|
|
43
|
+
readonly description: string;
|
|
44
|
+
readonly inputs?: TInputs;
|
|
45
|
+
readonly outputs: TOutputs;
|
|
46
|
+
readonly worktreeFromInputs?: WorkflowWorktreeInputBinding;
|
|
47
|
+
readonly run: (ctx: TRunContext) => Promise<WorkflowRunOutputResult<TOutputs, TActualOutputs>> | WorkflowRunOutputResult<TOutputs, TActualOutputs>;
|
|
48
|
+
}
|
|
49
|
+
export {};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type {} from "../authoring/typebox-defaults.js";
|
|
2
|
+
import type { Static, TOptional, TSchema } from "typebox";
|
|
3
|
+
import type {
|
|
4
|
+
WorkflowInputSchemaMap,
|
|
5
|
+
WorkflowInputValues,
|
|
6
|
+
WorkflowOutputSchemaMap,
|
|
7
|
+
WorkflowOutputValues,
|
|
8
|
+
WorkflowSerializableValue,
|
|
9
|
+
WorkflowWorktreeInputBinding,
|
|
10
|
+
} from "./authoring-contract.js";
|
|
11
|
+
|
|
12
|
+
type SchemaKeys<TSchemas> = keyof TSchemas & string;
|
|
13
|
+
type Simplify<T> = { [K in keyof T]: T[K] } & {};
|
|
14
|
+
type UnionToIntersection<T> = (
|
|
15
|
+
T extends T ? (value: T) => void : never
|
|
16
|
+
) extends (value: infer TIntersection) => void
|
|
17
|
+
? TIntersection
|
|
18
|
+
: never;
|
|
19
|
+
type WorkflowInputShape<T> = T extends WorkflowInputValues ? T : never;
|
|
20
|
+
type WorkflowOutputShape<T> = T extends WorkflowOutputValues ? T : never;
|
|
21
|
+
|
|
22
|
+
type DeclaredResolvedEntry<K extends string, S extends TSchema> = S extends TOptional<TSchema>
|
|
23
|
+
? { readonly [P in K]?: Static<S> & WorkflowSerializableValue }
|
|
24
|
+
: { readonly [P in K]: Static<S> & WorkflowSerializableValue };
|
|
25
|
+
|
|
26
|
+
type DeclaredProvidedEntry<K extends string, S extends TSchema> =
|
|
27
|
+
S extends TOptional<TSchema> | { readonly default: WorkflowSerializableValue }
|
|
28
|
+
? { readonly [P in K]?: Static<S> & WorkflowSerializableValue }
|
|
29
|
+
: { readonly [P in K]: Static<S> & WorkflowSerializableValue };
|
|
30
|
+
|
|
31
|
+
type DeclaredOutputEntry<K extends string, S extends TSchema> = S extends TOptional<TSchema>
|
|
32
|
+
? { readonly [P in K]?: Static<S> & WorkflowSerializableValue }
|
|
33
|
+
: { readonly [P in K]: Static<S> & WorkflowSerializableValue };
|
|
34
|
+
|
|
35
|
+
type WorkflowResolvedInputShapeFromSchemas<TSchemas extends WorkflowInputSchemaMap> = [SchemaKeys<TSchemas>] extends [never]
|
|
36
|
+
? {}
|
|
37
|
+
: Simplify<UnionToIntersection<{
|
|
38
|
+
readonly [K in SchemaKeys<TSchemas>]: DeclaredResolvedEntry<K, TSchemas[K]>;
|
|
39
|
+
}[SchemaKeys<TSchemas>]>>;
|
|
40
|
+
|
|
41
|
+
type WorkflowProvidedInputShapeFromSchemas<TSchemas extends WorkflowInputSchemaMap> = [SchemaKeys<TSchemas>] extends [never]
|
|
42
|
+
? {}
|
|
43
|
+
: Simplify<UnionToIntersection<{
|
|
44
|
+
readonly [K in SchemaKeys<TSchemas>]: DeclaredProvidedEntry<K, TSchemas[K]>;
|
|
45
|
+
}[SchemaKeys<TSchemas>]>>;
|
|
46
|
+
|
|
47
|
+
export type WorkflowInputsFromSchemas<TSchemas extends WorkflowInputSchemaMap> =
|
|
48
|
+
WorkflowInputShape<WorkflowResolvedInputShapeFromSchemas<TSchemas>>;
|
|
49
|
+
|
|
50
|
+
export type WorkflowProvidedInputsFromSchemas<TSchemas extends WorkflowInputSchemaMap> =
|
|
51
|
+
WorkflowInputShape<WorkflowProvidedInputShapeFromSchemas<TSchemas>>;
|
|
52
|
+
|
|
53
|
+
type WorkflowDeclaredOutputsFromSchemas<TSchemas extends WorkflowOutputSchemaMap> = [SchemaKeys<TSchemas>] extends [never]
|
|
54
|
+
? {}
|
|
55
|
+
: Simplify<UnionToIntersection<{
|
|
56
|
+
readonly [K in SchemaKeys<TSchemas>]: DeclaredOutputEntry<K, TSchemas[K]>;
|
|
57
|
+
}[SchemaKeys<TSchemas>]>>;
|
|
58
|
+
|
|
59
|
+
export type WorkflowOutputsFromSchemas<TSchemas extends WorkflowOutputSchemaMap> =
|
|
60
|
+
WorkflowOutputShape<WorkflowDeclaredOutputsFromSchemas<TSchemas>>;
|
|
61
|
+
|
|
62
|
+
export type NoExtraWorkflowOutputs<TDeclared, TActual extends TDeclared> = TActual &
|
|
63
|
+
Record<Exclude<keyof TActual, keyof TDeclared>, never>;
|
|
64
|
+
|
|
65
|
+
export type WorkflowRunOutputResult<
|
|
66
|
+
TOutputs extends WorkflowOutputSchemaMap,
|
|
67
|
+
TActualOutputs extends WorkflowOutputsFromSchemas<TOutputs>,
|
|
68
|
+
> = NoExtraWorkflowOutputs<WorkflowOutputsFromSchemas<TOutputs>, TActualOutputs>;
|
|
69
|
+
|
|
70
|
+
export interface AuthoredWorkflowSpec<
|
|
71
|
+
TInputs extends WorkflowInputSchemaMap = {},
|
|
72
|
+
TOutputs extends WorkflowOutputSchemaMap = WorkflowOutputSchemaMap,
|
|
73
|
+
TActualOutputs extends WorkflowOutputsFromSchemas<TOutputs> = WorkflowOutputsFromSchemas<TOutputs>,
|
|
74
|
+
TRunContext = unknown,
|
|
75
|
+
> {
|
|
76
|
+
readonly name?: string;
|
|
77
|
+
readonly description: string;
|
|
78
|
+
readonly inputs?: TInputs;
|
|
79
|
+
readonly outputs: TOutputs;
|
|
80
|
+
readonly worktreeFromInputs?: WorkflowWorktreeInputBinding;
|
|
81
|
+
readonly run: (
|
|
82
|
+
ctx: TRunContext,
|
|
83
|
+
) => Promise<WorkflowRunOutputResult<TOutputs, TActualOutputs>> | WorkflowRunOutputResult<TOutputs, TActualOutputs>;
|
|
84
|
+
}
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* pi-subagents src/agents/agents.ts (discover/parse)
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import type { WorkflowDefinition } from "../shared/types.js";
|
|
11
|
+
import type { WorkflowDefinition, WorkflowInputValues, WorkflowOutputValues } from "../shared/types.js";
|
|
12
12
|
import { normalizeWorkflowName } from "./identity.js";
|
|
13
13
|
|
|
14
14
|
export interface WorkflowRegistry {
|
|
@@ -17,7 +17,11 @@ export interface WorkflowRegistry {
|
|
|
17
17
|
* Keyed by the definition's normalizedName; replaces any prior entry with
|
|
18
18
|
* the same key. Returns a NEW registry — this one is unchanged.
|
|
19
19
|
*/
|
|
20
|
-
register
|
|
20
|
+
register<
|
|
21
|
+
TInputs extends WorkflowInputValues,
|
|
22
|
+
TOutputs extends WorkflowOutputValues,
|
|
23
|
+
TRunInputs extends WorkflowInputValues = TInputs,
|
|
24
|
+
>(definition: WorkflowDefinition<TInputs, TOutputs, TRunInputs>): WorkflowRegistry;
|
|
21
25
|
/**
|
|
22
26
|
* Return a new registry with all definitions from another registry merged
|
|
23
27
|
* in (other's entries win on collision).
|
|
@@ -52,7 +56,7 @@ function makeRegistry(store: Map<string, WorkflowDefinition>): WorkflowRegistry
|
|
|
52
56
|
return {
|
|
53
57
|
register(definition) {
|
|
54
58
|
const next = new Map(store);
|
|
55
|
-
next.set(definition.normalizedName, definition);
|
|
59
|
+
next.set(definition.normalizedName, definition as never as WorkflowDefinition);
|
|
56
60
|
return makeRegistry(next);
|
|
57
61
|
},
|
|
58
62
|
|