@boboddy/sdk 0.4.3 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/client.js +0 -23
  2. package/dist/definitions/advancement-policies/define-advancement-policy.d.ts +30 -5
  3. package/dist/definitions/advancement-policies/index.js +11 -1
  4. package/dist/definitions/pipelines/bindings.d.ts +62 -0
  5. package/dist/definitions/pipelines/builder-helpers.d.ts +19 -106
  6. package/dist/definitions/pipelines/chain-graph.d.ts +15 -14
  7. package/dist/definitions/pipelines/compile-node-definitions.d.ts +27 -0
  8. package/dist/definitions/pipelines/define-pipeline.d.ts +101 -154
  9. package/dist/definitions/pipelines/index.d.ts +0 -2
  10. package/dist/definitions/pipelines/index.js +470 -615
  11. package/dist/definitions/pipelines/node-input-ctx.d.ts +31 -0
  12. package/dist/definitions/pipelines/pipeline-definitions-client.d.ts +18 -4
  13. package/dist/definitions/pipelines/pipeline-states.d.ts +104 -0
  14. package/dist/definitions/steps/define-code-step.d.ts +50 -0
  15. package/dist/definitions/steps/define-step.d.ts +22 -1
  16. package/dist/definitions/steps/index.d.ts +1 -0
  17. package/dist/definitions/steps/index.js +41 -24
  18. package/dist/definitions/steps/step-definitions-client.d.ts +29 -5
  19. package/dist/definitions/validation/index.js +15148 -94
  20. package/dist/definitions/validation/validate-definition-specs.d.ts +19 -1
  21. package/dist/generated/index.d.ts +1 -1
  22. package/dist/generated/sdk.gen.d.ts +1 -4
  23. package/dist/generated/types.gen.d.ts +296 -878
  24. package/dist/index.js +510 -615
  25. package/dist/push/collect-definitions.d.ts +40 -1
  26. package/dist/push/index.d.ts +2 -2
  27. package/dist/push/index.js +788 -738
  28. package/dist/step-execution-plane-client.d.ts +9 -4
  29. package/package.json +2 -2
  30. package/dist/definitions/pipelines/builder.d.ts +0 -80
  31. package/dist/definitions/pipelines/fan-out-builder.d.ts +0 -66
  32. package/dist/definitions/pipelines/input-accessor.d.ts +0 -25
@@ -1,165 +1,114 @@
1
- import { type ZodType } from "zod";
2
- import type { StepDefinitionSpec, TypedStepDefinitionSpec } from "../steps/define-step";
3
- import { type AdvancementPolicy, type SerializedAdvancementPolicy, type SerializedComputedSignalDefinition } from "../advancement-policies/define-advancement-policy";
4
- import { type CohortAdvancementPolicy, type SerializedCohortAdvancementPolicy, type SerializedStepSignalsListDefinition } from "../advancement-policies/cohort-advancement-policy";
1
+ import { z, type ZodType } from "zod";
2
+ import type { StepDefinitionSpec } from "../steps/define-step";
3
+ import type { SerializedAdvancementPolicy, SerializedComputedSignalDefinition, SerializedCondition } from "../advancement-policies/define-advancement-policy";
4
+ import type { SerializedCohortAdvancementPolicy, SerializedStepSignalsListDefinition } from "../advancement-policies/cohort-advancement-policy";
5
+ import type { SerializedBinding } from "./bindings";
6
+ import type { DefinePipelineInput } from "./pipeline-states";
5
7
  export type { AdvancementPolicy, PipelineStepComputedSignalType, } from "../advancement-policies/define-advancement-policy";
6
8
  export { Computed, Rule, } from "../advancement-policies/define-advancement-policy";
7
- type AnyTypedStep = TypedStepDefinitionSpec<any, any, any, any>;
8
- export type PipelineInputBinding = {
9
- source: "pipeline_input";
10
- path: string;
9
+ export * from "./pipeline-states";
10
+ export * from "./node-input-ctx";
11
+ export * from "./bindings";
12
+ export type NodeDefinitionKind = "step" | "fanOut" | "cohortGate" | "choice" | "parallel" | "loop" | "succeed" | "fail";
13
+ export type ChoiceCaseSpec = {
14
+ conditionJson: SerializedCondition;
15
+ targetNodeKey: string;
11
16
  };
12
- export type WorkItemBinding = {
13
- source: "work_item";
14
- field: string;
15
- };
16
- export type StepSignalBinding = {
17
- source: "step_signal";
18
- step: AnyTypedStep;
19
- signalKey: string;
20
- };
21
- export type StepOutputBinding = {
22
- source: "step_output";
23
- step: AnyTypedStep;
24
- };
25
- export type LiteralBinding = {
26
- source: "literal";
27
- value: unknown;
28
- };
29
- /**
30
- * `ctx.signalsList(fanOutStep)`'s binding (issue #167): reaches a fan-out's
31
- * whole cohort — every terminal branch's own signals + output — from a
32
- * later, non-adjacent step's input mapper. Resolved server-side against
33
- * `ResolvedNodeInputContext.cohorts[stepKey]` (an array of
34
- * `{ branchIndex, signals, outputJson }`, sorted by `branchIndex`).
35
- */
36
- export type SignalsListBinding = {
37
- source: "signals_list";
38
- fanOutStep: AnyTypedStep;
17
+ export type ParallelBranchSpec = {
18
+ stepKey: string;
19
+ stepName: string;
20
+ stepDescription: string | null;
21
+ inputBindingsJson: Record<string, SerializedBinding>;
39
22
  };
40
23
  /**
41
- * `.fanOutStep(step, config)`'s own `input` ctx's `item` binding (issue
42
- * #167): resolves server-side, per branch, to that branch's own item value
43
- * the element of the array `config.over` names, when `over` resolves to
44
- * an array (count-only mode has no `item` to bind, both at the type level
45
- * — see `FanOutItemType` — and at the wire level, since no `fanOut` node
46
- * config would carry an `item` binding for it). Carries no extra fields:
47
- * the branch index alone (implicit in which branch is executing) is enough
48
- * to resolve the right element server-side.
24
+ * Fields shared by every node kind that does its own work by running a step
25
+ * template (`step`/`fanOut`/`loop`) the step's own key/name/description,
26
+ * its resolved input bindings, and its timeout. Intersected into each of
27
+ * those three kinds' own type below rather than duplicated field-for-field.
49
28
  */
50
- export type FanOutItemBinding = {
51
- source: "fan_out_item";
29
+ type StepTemplateFields = {
30
+ stepKey: string;
31
+ stepName: string;
32
+ stepDescription: string | null;
33
+ inputBindingsJson: Record<string, SerializedBinding>;
34
+ timeoutSeconds: number | null;
52
35
  };
53
- export type AnyBinding = PipelineInputBinding | WorkItemBinding | StepSignalBinding | StepOutputBinding | LiteralBinding | SignalsListBinding | FanOutItemBinding;
54
- export type PipelineStepConfig<TStep extends AnyTypedStep = AnyTypedStep> = {
55
- step: TStep;
56
- /** Maps each step input field to an input source. Extra keys are ignored at runtime. */
57
- input?: Partial<{
58
- [K in keyof NonNullable<TStep["__inputType"]> & string]: AnyBinding;
59
- }>;
60
- timeout?: number | null;
61
- /**
62
- * Controls when and how this step advances in the pipeline.
63
- * Signal keys in `Rule.signal()` / `Rule.when()` calls are type-checked
64
- * against the step's declared signals. Inline `Computed.X(...)` tokens can
65
- * also appear in the signal position; they're hoisted into the step's
66
- * `computedSignalDefinitions` at serialization time.
67
- * Defaults to `{ defaultOutcome: "continue" }` when omitted.
68
- */
69
- advancement?: AdvancementPolicy<TStep["__signalKeys"]>;
36
+ export type StepNodeDefinitionSpec = StepTemplateFields & {
37
+ nodeKey: string;
38
+ kind: "step";
39
+ advancementPolicyDefinition: SerializedAdvancementPolicy;
40
+ computedSignalDefinitions: SerializedComputedSignalDefinition[];
70
41
  };
71
- /**
72
- * `.fanOutStep(step, config)`'s node config (issue #167): a `fanOut` node
73
- * whose `stepDefinitionId`/`stepDefinitionVersion` template is `fanOutStep`
74
- * the template every branch executes and whose `advanceEach` policy
75
- * each branch's own result is evaluated against. Pushes exactly one
76
- * `fanOut` node onto the pipeline's node sequence (paired with exactly one
77
- * `PipelineCohortGateNodeConfig` immediately after it — see `.advanceAll()`
78
- * — never more than the fan-out+gate pair itself).
79
- *
80
- * Named `*StepConfig` (rather than a bare `PipelineFanOutConfig`) to reserve
81
- * room for a future sibling `PipelineFanOutSubPipelineConfig` — a fan-out
82
- * whose template is a whole sub-pipeline rather than a single step. That
83
- * sibling is out of scope for issue #167 and is not implemented here.
84
- */
85
- export type PipelineFanOutStepConfig<TStep extends AnyTypedStep = AnyTypedStep> = {
86
- nodeType: "fanOut";
87
- fanOutStep: TStep;
42
+ export type FanOutNodeDefinitionSpec = StepTemplateFields & {
43
+ nodeKey: string;
44
+ kind: "fanOut";
45
+ /** The signal its branch cardinality is resolved from. */
88
46
  overSignalKey: string;
89
- input?: Partial<{
90
- [K in keyof NonNullable<TStep["__inputType"]> & string]: AnyBinding;
91
- }>;
92
- timeout?: number | null;
93
- advanceEach?: CohortAdvancementPolicy;
47
+ /** Each branch's own continue/block decision. */
48
+ advanceEachPolicyDefinition: SerializedCohortAdvancementPolicy;
49
+ /** Caps how many branches release to the claim pool up front. */
50
+ maxConcurrency: number | null;
94
51
  };
95
- /**
96
- * `.advanceAll(callback)`'s node config (issue #167): the pure decision
97
- * gate that aggregates a fan-out's cohort back together — no work of its
98
- * own, so no `step`/`input`/`timeout`. `nodeKey` is derived by the builder
99
- * (`${fanOutStep.key}__cohortGate`), not user-supplied.
100
- */
101
- export type PipelineCohortGateNodeConfig = {
102
- nodeType: "cohortGate";
52
+ export type CohortGateNodeDefinitionSpec = {
103
53
  nodeKey: string;
104
- advanceAll?: CohortAdvancementPolicy;
105
- stepSignalsListDefinitions?: SerializedStepSignalsListDefinition[];
54
+ kind: "cohortGate";
55
+ /** The whole cohort's continue/block decision. */
56
+ advanceAllPolicyDefinition: SerializedCohortAdvancementPolicy;
57
+ /** Every `ctx.stepSignalsList`-derived value `advanceAll`'s rules may reference. */
58
+ stepSignalsListDefinitions: SerializedStepSignalsListDefinition[];
106
59
  };
107
- /**
108
- * A single entry in a pipeline's declaration-order node sequence: an
109
- * ordinary step, or one half of a fan-out+cohort-gate pair. Discriminated
110
- * by the presence/value of `nodeType` (absent means a plain step) rather
111
- * than a `kind` field, so `PipelineStepConfig` itself needs no change.
112
- */
113
- export type PipelineNodeConfig = PipelineStepConfig | PipelineFanOutStepConfig | PipelineCohortGateNodeConfig;
114
- export type SerializedBinding = {
115
- source: "pipeline_input";
116
- path: string;
117
- } | {
118
- source: "work_item";
119
- field: string;
120
- } | {
121
- source: "step_signal";
122
- stepKey: string;
123
- signalKey: string;
124
- } | {
125
- source: "step_output";
126
- stepKey: string;
127
- } | {
128
- source: "literal";
129
- value: unknown;
130
- } | {
131
- source: "signals_list";
132
- stepKey: string;
133
- } | {
134
- source: "fan_out_item";
60
+ export type ChoiceNodeDefinitionSpec = {
61
+ nodeKey: string;
62
+ kind: "choice";
63
+ /** The routing table may be empty when `default` alone covers every case. */
64
+ choices: ChoiceCaseSpec[];
65
+ /** The fallback target when no `choices[]` entry matches. */
66
+ default: string | null;
135
67
  };
136
- export type NodeDefinitionKind = "step" | "fanOut" | "cohortGate";
137
- export type NodeDefinitionSpec = {
138
- /** Unique within the pipeline; equals `stepKey` for a step/fanOut node, or the builder-derived gate key for a cohortGate node. */
68
+ export type ParallelNodeDefinitionSpec = {
139
69
  nodeKey: string;
140
- kind: NodeDefinitionKind;
141
- /** `step`/`fanOut` only — the step template's key/version. Absent on a `cohortGate` node (it produces no work of its own). */
142
- stepKey?: string;
143
- stepName?: string;
144
- stepDescription?: string | null;
145
- inputBindingsJson?: Record<string, SerializedBinding>;
146
- timeoutSeconds?: number | null;
147
- /** `step` only. */
148
- advancementPolicyDefinition?: SerializedAdvancementPolicy;
149
- /** `step` only. */
150
- computedSignalDefinitions?: SerializedComputedSignalDefinition[];
151
- /** `fanOut` only — the signal its branch cardinality is resolved from. */
152
- overSignalKey?: string;
153
- /** `fanOut` only — each branch's own continue/block decision. */
154
- advanceEachPolicyDefinition?: SerializedCohortAdvancementPolicy;
155
- /** `cohortGate` only — the whole cohort's continue/block decision. */
70
+ kind: "parallel";
71
+ /** Its named, single-step branches. */
72
+ branches: Record<string, ParallelBranchSpec>;
73
+ /** The whole cohort's continue/block decision — absent means "continue iff every branch continued." */
156
74
  advanceAllPolicyDefinition?: SerializedCohortAdvancementPolicy;
157
- /** `cohortGate` only — every `ctx.stepSignalsList`-derived value `advanceAll`'s rules may reference. */
158
- stepSignalsListDefinitions?: SerializedStepSignalsListDefinition[];
159
75
  };
76
+ export type LoopNodeDefinitionSpec = StepTemplateFields & {
77
+ nodeKey: string;
78
+ kind: "loop";
79
+ maxIterations: number;
80
+ /** The condition tested after each iteration. */
81
+ untilConditionJson: SerializedCondition;
82
+ };
83
+ /** `succeed`/`fail` carry no fields of their own besides `nodeKey`/`kind`. */
84
+ export type TerminalNodeDefinitionSpec = {
85
+ nodeKey: string;
86
+ kind: "succeed" | "fail";
87
+ };
88
+ /**
89
+ * One compiled node in the pipeline's graph, discriminated by `kind` — each
90
+ * kind's own fields (see its type above) are the only ones legal on it; a
91
+ * `choice` node has no `stepKey`, a `step` node has no `choices`, etc. The
92
+ * ones that need real ids (a `step`/`fanOut`/`loop`'s `stepKey`, a
93
+ * `parallel` branch's own `stepKey`) are resolved to `stepDefinitionId`s by
94
+ * `pipeline-definitions-client.ts` at push time, not here — this spec only
95
+ * ever carries author-declared keys.
96
+ */
97
+ export type NodeDefinitionSpec = StepNodeDefinitionSpec | FanOutNodeDefinitionSpec | CohortGateNodeDefinitionSpec | ChoiceNodeDefinitionSpec | ParallelNodeDefinitionSpec | LoopNodeDefinitionSpec | TerminalNodeDefinitionSpec;
98
+ /** The kinds that run a step template and therefore carry `StepTemplateFields`. */
99
+ export type WorkingNodeDefinitionSpec = StepNodeDefinitionSpec | FanOutNodeDefinitionSpec | LoopNodeDefinitionSpec;
100
+ /** Narrows a `NodeDefinitionSpec` to the kinds that run a step template. */
101
+ export declare function isWorkingNodeDefinition(node: NodeDefinitionSpec): node is WorkingNodeDefinitionSpec;
160
102
  export type DependencyEdgeSpec = {
161
103
  fromNodeKey: string;
162
104
  toNodeKey: string;
105
+ /**
106
+ * A `loop` node's `next`/`onExhausted` disambiguation
107
+ * (`{loopExit: "next" | "onExhausted"}` — the routing source of truth
108
+ * for `loop`) or a `choice` edge's designer-only display summary (never
109
+ * the routing source of truth for `choice` — see §4).
110
+ */
111
+ discriminantJson?: Record<string, unknown> | null;
163
112
  };
164
113
  export type PipelineDefinitionSpec = {
165
114
  key: string;
@@ -173,14 +122,12 @@ export type PipelineDefinitionSpec = {
173
122
  /** Step specs referenced by this pipeline. Used by the push command to auto-push steps that aren't explicitly exported. */
174
123
  _stepDefinitions?: StepDefinitionSpec[];
175
124
  };
176
- export type DefinePipelineInput = {
177
- key: string;
178
- name: string;
179
- description?: string | null;
180
- version?: number;
181
- status?: "draft" | "active";
182
- input?: ZodType | null;
183
- nodes: ReadonlyArray<PipelineNodeConfig>;
184
- pipelineInputBindings?: Record<string, AnyBinding>;
185
- };
186
- export declare function buildPipelineSpec(config: DefinePipelineInput): PipelineDefinitionSpec;
125
+ /**
126
+ * Compiles a flat, ASL-flavored pipeline definition (see
127
+ * docs/research/flat-pipeline-sdk-and-visual-designer.md §4) into the wire
128
+ * `PipelineDefinitionSpec` shape. `states` is a map keyed by node key —
129
+ * there is no `dependsOn`; every node's incoming edge(s) are derived here
130
+ * by walking each state's own forward pointer(s) (`next`/`choices[].next`/
131
+ * `default`/`onExhausted`/branch-completion target).
132
+ */
133
+ export declare function definePipeline<TInput extends ZodType = z.ZodUnknown>(config: DefinePipelineInput<TInput>): PipelineDefinitionSpec;
@@ -1,6 +1,4 @@
1
1
  export * from "./define-pipeline";
2
- export * from "./builder";
3
- export * from "./input-accessor";
4
2
  export * from "./pipeline-definitions-client";
5
3
  export * from "./define-default-pipeline-assignment";
6
4
  export * from "./work-item-fields";