@boboddy/sdk 0.1.14-alpha → 0.1.16-alpha
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/dist/boboddy-config-parser.js +4 -325
- package/dist/client.js +2 -1
- package/dist/defaults/auth-file.d.ts +14 -0
- package/dist/defaults/base-url.d.ts +1 -0
- package/dist/defaults/index.d.ts +7 -0
- package/dist/defaults/index.js +312 -0
- package/dist/defaults/load-push-defaults.d.ts +21 -0
- package/dist/defaults/project-config.d.ts +5 -0
- package/dist/definitions/advancement-policies/define-advancement-policy.d.ts +4 -0
- package/dist/definitions/advancement-policies/fluent-rules.d.ts +82 -0
- package/dist/definitions/advancement-policies/index.d.ts +1 -0
- package/dist/definitions/advancement-policies/index.js +87 -0
- package/dist/definitions/pipelines/builder.d.ts +111 -0
- package/dist/definitions/pipelines/define-pipeline.d.ts +24 -52
- package/dist/definitions/pipelines/index.d.ts +2 -0
- package/dist/definitions/pipelines/index.js +14672 -75
- package/dist/definitions/pipelines/input-accessor.d.ts +25 -0
- package/dist/definitions/pipelines/pipeline-definitions-client.d.ts +17 -21
- package/dist/definitions/steps/define-step.d.ts +17 -4
- package/dist/definitions/steps/index.d.ts +1 -0
- package/dist/definitions/steps/index.js +1605 -1578
- package/dist/definitions/steps/prompt-template.d.ts +16 -0
- package/dist/definitions/steps/step-features.d.ts +1 -1
- package/dist/generated/types.gen.d.ts +90 -108
- package/dist/index.js +1981 -1956
- package/dist/jsonc.js +1 -0
- package/dist/opencode-mcp.js +1573 -1572
- package/dist/push/index.d.ts +2 -0
- package/dist/push/index.js +16480 -0
- package/dist/push/push-from-directory.d.ts +21 -0
- package/package.json +9 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface PushDefaults {
|
|
2
|
+
baseUrl: string;
|
|
3
|
+
projectId: string | undefined;
|
|
4
|
+
accessToken: string | undefined;
|
|
5
|
+
}
|
|
6
|
+
export interface LoadPushDefaultsOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Directory the script is running from. The project config (`.boboddy/boboddy.jsonc`)
|
|
9
|
+
* is searched for in this directory and each ancestor directory.
|
|
10
|
+
*/
|
|
11
|
+
dir: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Reads the conventional defaults for a `boboddy pipelines push` run:
|
|
15
|
+
* - `baseUrl`: from `BOBODDY_BASE_URL` env var or the built-in default.
|
|
16
|
+
* - `projectId`: from `BOBODDY_PROJECT_ID` env var or the nearest ancestor
|
|
17
|
+
* `.boboddy/boboddy.jsonc` of `opts.dir`.
|
|
18
|
+
* - `accessToken`: from `BOBODDY_ACCESS_TOKEN` env var or the saved auth
|
|
19
|
+
* profile for the resolved `baseUrl`.
|
|
20
|
+
*/
|
|
21
|
+
export declare function loadPushDefaults(opts: LoadPushDefaultsOptions): Promise<PushDefaults>;
|
|
@@ -34,6 +34,10 @@ type ComputedOptions = {
|
|
|
34
34
|
* @example
|
|
35
35
|
* Rule.when(Computed.sum(["success"]), "greaterThan", 1, "continue")
|
|
36
36
|
* Rule.signal(Computed.average(["score"]), "greaterThanInclusive", 80)
|
|
37
|
+
*
|
|
38
|
+
* For new code, prefer the equivalent factories on the `.advance()` callback
|
|
39
|
+
* context of the `pipeline()` builder (`avg`, `sum`, `min`, `max`, …) — they
|
|
40
|
+
* return chainable `SignalRef`s and infer signal keys from the current step.
|
|
37
41
|
*/
|
|
38
42
|
export declare const Computed: {
|
|
39
43
|
readonly average: <const TInputs extends readonly [string, string, ...string[]]>(inputSignalKeys: TInputs, options?: ComputedOptions) => InlineComputedSignal<`average_${Join<TInputs, "_">}`, TInputs[number]>;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { type AdvancementOutcome, type Rule, type RuleCondition, type RouteOutcome, type SignalCondition } from "./define-advancement-policy";
|
|
2
|
+
declare const LEAF_BRAND: unique symbol;
|
|
3
|
+
declare const GROUP_BRAND: unique symbol;
|
|
4
|
+
declare const SIGNAL_KEY: unique symbol;
|
|
5
|
+
/**
|
|
6
|
+
* A leaf condition + outcome attacher. Built by `signal(key).<op>(value)` or
|
|
7
|
+
* any computed factory chained with a comparator. Nestable inside `all()` /
|
|
8
|
+
* `any()`, or terminable with `.then(outcome)`.
|
|
9
|
+
*/
|
|
10
|
+
export interface RuleLeaf<TSignalKeys extends string = string> {
|
|
11
|
+
readonly [LEAF_BRAND]: SignalCondition<TSignalKeys>;
|
|
12
|
+
then(outcome: AdvancementOutcome): Rule<TSignalKeys>;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A grouped condition + outcome attacher. Built by `all(...)` or `any(...)`.
|
|
16
|
+
* Nestable inside another group, or terminable with `.then(outcome)`.
|
|
17
|
+
*/
|
|
18
|
+
export interface RuleGroup<TSignalKeys extends string = string> {
|
|
19
|
+
readonly [GROUP_BRAND]: {
|
|
20
|
+
mode: "all" | "any";
|
|
21
|
+
conditions: RuleCondition<TSignalKeys>[];
|
|
22
|
+
};
|
|
23
|
+
then(outcome: AdvancementOutcome): Rule<TSignalKeys>;
|
|
24
|
+
}
|
|
25
|
+
type Nestable<K extends string> = RuleLeaf<K> | RuleGroup<K>;
|
|
26
|
+
/**
|
|
27
|
+
* A comparator-bound signal reference. Returned by `signal(key)` and by every
|
|
28
|
+
* computed factory (`avg`, `sum`, etc.). Calling any comparator (`gte`, `eq`,
|
|
29
|
+
* …) produces a `RuleLeaf`.
|
|
30
|
+
*
|
|
31
|
+
* `TValue` is the TypeScript type of the signal's value, enabling type-safe
|
|
32
|
+
* comparisons (e.g. `eq(true)` errors when the signal is a string).
|
|
33
|
+
*/
|
|
34
|
+
export interface SignalRef<TSignalKeys extends string = string, TValue = unknown> {
|
|
35
|
+
eq(value: TValue): RuleLeaf<TSignalKeys>;
|
|
36
|
+
ne(value: TValue): RuleLeaf<TSignalKeys>;
|
|
37
|
+
gt(value: number): RuleLeaf<TSignalKeys>;
|
|
38
|
+
gte(value: number): RuleLeaf<TSignalKeys>;
|
|
39
|
+
lt(value: number): RuleLeaf<TSignalKeys>;
|
|
40
|
+
lte(value: number): RuleLeaf<TSignalKeys>;
|
|
41
|
+
in(values: ReadonlyArray<TValue>): RuleLeaf<TSignalKeys>;
|
|
42
|
+
notIn(values: ReadonlyArray<TValue>): RuleLeaf<TSignalKeys>;
|
|
43
|
+
contains(value: unknown): RuleLeaf<TSignalKeys>;
|
|
44
|
+
doesNotContain(value: unknown): RuleLeaf<TSignalKeys>;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* A `SignalRef` backed by a plain signal key (not a computed token). The
|
|
48
|
+
* embedded `SIGNAL_KEY` brand lets computed factories extract the key at
|
|
49
|
+
* runtime so callers can pass `stepSignals.foo` instead of the string `"foo"`.
|
|
50
|
+
*/
|
|
51
|
+
export interface KeyedSignalRef<TSignalKeys extends string = string, TValue = unknown> extends SignalRef<TSignalKeys, TValue> {
|
|
52
|
+
readonly [SIGNAL_KEY]: TSignalKeys;
|
|
53
|
+
}
|
|
54
|
+
type ComputedTuple<K extends string, TValue = unknown> = [
|
|
55
|
+
KeyedSignalRef<K, TValue>,
|
|
56
|
+
KeyedSignalRef<K, TValue>,
|
|
57
|
+
...KeyedSignalRef<K, TValue>[]
|
|
58
|
+
];
|
|
59
|
+
type SignalValue<TSignalKeys extends string, TSignalTypeMap extends Partial<Record<string, unknown>>, K extends TSignalKeys> = K extends keyof TSignalTypeMap ? TSignalTypeMap[K] : unknown;
|
|
60
|
+
export interface AdvanceCtx<TSignalKeys extends string = string, TSignalTypeMap extends Partial<Record<string, unknown>> = Record<string, unknown>> {
|
|
61
|
+
signal<K extends TSignalKeys>(key: K): KeyedSignalRef<TSignalKeys, SignalValue<TSignalKeys, TSignalTypeMap, K>>;
|
|
62
|
+
stepSignals: {
|
|
63
|
+
[K in TSignalKeys]: KeyedSignalRef<TSignalKeys, SignalValue<TSignalKeys, TSignalTypeMap, K>>;
|
|
64
|
+
};
|
|
65
|
+
avg(...args: ComputedTuple<TSignalKeys, number>): SignalRef<TSignalKeys>;
|
|
66
|
+
weightedAvg(...args: ComputedTuple<TSignalKeys, number>): SignalRef<TSignalKeys>;
|
|
67
|
+
sum(...args: ComputedTuple<TSignalKeys, number>): SignalRef<TSignalKeys>;
|
|
68
|
+
min(...args: ComputedTuple<TSignalKeys, number>): SignalRef<TSignalKeys>;
|
|
69
|
+
max(...args: ComputedTuple<TSignalKeys, number>): SignalRef<TSignalKeys>;
|
|
70
|
+
count(...args: ComputedTuple<TSignalKeys>): SignalRef<TSignalKeys>;
|
|
71
|
+
booleanAny(...args: ComputedTuple<TSignalKeys, boolean>): SignalRef<TSignalKeys>;
|
|
72
|
+
booleanAll(...args: ComputedTuple<TSignalKeys, boolean>): SignalRef<TSignalKeys>;
|
|
73
|
+
all(...refs: Nestable<TSignalKeys>[]): RuleGroup<TSignalKeys>;
|
|
74
|
+
any(...refs: Nestable<TSignalKeys>[]): RuleGroup<TSignalKeys>;
|
|
75
|
+
route(pipelineKey: string, inputJson?: Record<string, unknown>): RouteOutcome;
|
|
76
|
+
}
|
|
77
|
+
export interface AdvanceResult<TSignalKeys extends string = string> {
|
|
78
|
+
default: AdvancementOutcome;
|
|
79
|
+
rules?: Rule<TSignalKeys>[];
|
|
80
|
+
}
|
|
81
|
+
export declare function makeAdvanceCtx<TSignalKeys extends string, TSignalTypeMap extends Partial<Record<string, unknown>> = Record<string, unknown>>(): AdvanceCtx<TSignalKeys, TSignalTypeMap>;
|
|
82
|
+
export {};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// @bun
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
2
3
|
var __returnValue = (v) => v;
|
|
3
4
|
function __exportSetter(name, newValue) {
|
|
@@ -156,8 +157,94 @@ function extractInlineComputedSignals(policy) {
|
|
|
156
157
|
}
|
|
157
158
|
return [...byKey.values()];
|
|
158
159
|
}
|
|
160
|
+
// src/definitions/advancement-policies/fluent-rules.ts
|
|
161
|
+
var LEAF_BRAND = Symbol.for("boboddy.fluentRule.leaf");
|
|
162
|
+
var GROUP_BRAND = Symbol.for("boboddy.fluentRule.group");
|
|
163
|
+
var SIGNAL_KEY = Symbol.for("boboddy.fluentRule.signalKey");
|
|
164
|
+
function createSignalRef(signal2) {
|
|
165
|
+
const leaf = (operator, value) => {
|
|
166
|
+
const condition = {
|
|
167
|
+
_tag: "signal",
|
|
168
|
+
signal: signal2,
|
|
169
|
+
operator,
|
|
170
|
+
value
|
|
171
|
+
};
|
|
172
|
+
return {
|
|
173
|
+
[LEAF_BRAND]: condition,
|
|
174
|
+
then(outcome) {
|
|
175
|
+
return {
|
|
176
|
+
_tag: "rule",
|
|
177
|
+
mode: "all",
|
|
178
|
+
conditions: [condition],
|
|
179
|
+
outcome
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
return {
|
|
185
|
+
eq: (v) => leaf("equal", v),
|
|
186
|
+
ne: (v) => leaf("notEqual", v),
|
|
187
|
+
gt: (v) => leaf("greaterThan", v),
|
|
188
|
+
gte: (v) => leaf("greaterThanInclusive", v),
|
|
189
|
+
lt: (v) => leaf("lessThan", v),
|
|
190
|
+
lte: (v) => leaf("lessThanInclusive", v),
|
|
191
|
+
in: (vs) => leaf("in", vs),
|
|
192
|
+
notIn: (vs) => leaf("notIn", vs),
|
|
193
|
+
contains: (v) => leaf("contains", v),
|
|
194
|
+
doesNotContain: (v) => leaf("doesNotContain", v)
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
function extractCondition(ref) {
|
|
198
|
+
if (LEAF_BRAND in ref)
|
|
199
|
+
return ref[LEAF_BRAND];
|
|
200
|
+
const group = ref[GROUP_BRAND];
|
|
201
|
+
return group.mode === "all" ? { _tag: "all", conditions: group.conditions } : { _tag: "any", conditions: group.conditions };
|
|
202
|
+
}
|
|
203
|
+
function createGroup(mode, refs) {
|
|
204
|
+
const conditions = refs.map(extractCondition);
|
|
205
|
+
return {
|
|
206
|
+
[GROUP_BRAND]: { mode, conditions },
|
|
207
|
+
then(outcome) {
|
|
208
|
+
return { _tag: "rule", mode, conditions, outcome };
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
function resolveComputedArg(arg) {
|
|
213
|
+
return arg[SIGNAL_KEY];
|
|
214
|
+
}
|
|
215
|
+
function makeKeyedSignalRef(key) {
|
|
216
|
+
const ref = createSignalRef(key);
|
|
217
|
+
return Object.assign(ref, {
|
|
218
|
+
[SIGNAL_KEY]: key
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
function makeAdvanceCtx() {
|
|
222
|
+
const wrapComputed = (token) => createSignalRef(token);
|
|
223
|
+
return {
|
|
224
|
+
signal: (key) => makeKeyedSignalRef(key),
|
|
225
|
+
stepSignals: new Proxy({}, {
|
|
226
|
+
get(_, key) {
|
|
227
|
+
if (typeof key === "string")
|
|
228
|
+
return makeKeyedSignalRef(key);
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
}),
|
|
232
|
+
avg: (...args) => wrapComputed(Computed.average(args.map(resolveComputedArg))),
|
|
233
|
+
weightedAvg: (...args) => wrapComputed(Computed.weightedAverage(args.map(resolveComputedArg))),
|
|
234
|
+
sum: (...args) => wrapComputed(Computed.sum(args.map(resolveComputedArg))),
|
|
235
|
+
min: (...args) => wrapComputed(Computed.min(args.map(resolveComputedArg))),
|
|
236
|
+
max: (...args) => wrapComputed(Computed.max(args.map(resolveComputedArg))),
|
|
237
|
+
count: (...args) => wrapComputed(Computed.count(args.map(resolveComputedArg))),
|
|
238
|
+
booleanAny: (...args) => wrapComputed(Computed.booleanAny(args.map(resolveComputedArg))),
|
|
239
|
+
booleanAll: (...args) => wrapComputed(Computed.booleanAll(args.map(resolveComputedArg))),
|
|
240
|
+
all: (...refs) => createGroup("all", refs),
|
|
241
|
+
any: (...refs) => createGroup("any", refs),
|
|
242
|
+
route: (pipelineKey, inputJson) => inputJson !== undefined ? { outcome: "route", pipelineKey, inputJson } : { outcome: "route", pipelineKey }
|
|
243
|
+
};
|
|
244
|
+
}
|
|
159
245
|
export {
|
|
160
246
|
serializeAdvancementPolicy,
|
|
247
|
+
makeAdvanceCtx,
|
|
161
248
|
extractInlineComputedSignals,
|
|
162
249
|
Rule,
|
|
163
250
|
Computed
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { z, type ZodType } from "zod";
|
|
2
|
+
import type { TypedStepDefinitionSpec } from "../steps/define-step";
|
|
3
|
+
import { type AdvanceCtx, type AdvanceResult } from "../advancement-policies/fluent-rules";
|
|
4
|
+
import { type AnyBinding, type LiteralBinding, type PipelineDefinitionSpec, type PipelineStepConfig, type StepOutputBinding, type StepSignalBinding, type WorkItemBinding } from "./define-pipeline";
|
|
5
|
+
import { type InputAccessor } from "./input-accessor";
|
|
6
|
+
type AnyTypedStep = TypedStepDefinitionSpec<any, any, any, any>;
|
|
7
|
+
export type StepConfig = {
|
|
8
|
+
timeout?: number | null;
|
|
9
|
+
};
|
|
10
|
+
type ElementOf<T extends ReadonlyArray<unknown>> = T extends ReadonlyArray<infer U> ? U : never;
|
|
11
|
+
type LastStep<T extends ReadonlyArray<AnyTypedStep>> = T extends readonly [
|
|
12
|
+
...AnyTypedStep[],
|
|
13
|
+
infer L
|
|
14
|
+
] ? L extends AnyTypedStep ? L : never : never;
|
|
15
|
+
type LastSignalKeys<T extends ReadonlyArray<AnyTypedStep>> = LastStep<T> extends AnyTypedStep ? LastStep<T>["__signalKeys"] : never;
|
|
16
|
+
type LastSignalTypeMap<T extends ReadonlyArray<AnyTypedStep>> = LastStep<T> extends AnyTypedStep ? LastStep<T>["__signalTypeMap"] : Record<string, unknown>;
|
|
17
|
+
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
18
|
+
type Prettify<T> = {
|
|
19
|
+
[K in keyof T]: T[K];
|
|
20
|
+
} & {};
|
|
21
|
+
type RequiredInputKeys<T extends object> = {
|
|
22
|
+
[K in keyof T & string]-?: undefined extends T[K] ? never : K;
|
|
23
|
+
}[keyof T & string];
|
|
24
|
+
type OptionalInputKeys<T extends object> = {
|
|
25
|
+
[K in keyof T & string]-?: undefined extends T[K] ? K : never;
|
|
26
|
+
}[keyof T & string];
|
|
27
|
+
type StepInputMapping<S extends AnyTypedStep> = IsAny<S["__inputType"]> extends true ? Partial<Record<string, AnyBinding>> : S["__inputType"] extends object ? {
|
|
28
|
+
[K in RequiredInputKeys<S["__inputType"]>]: AnyBinding;
|
|
29
|
+
} & {
|
|
30
|
+
[K in OptionalInputKeys<S["__inputType"]>]?: AnyBinding;
|
|
31
|
+
} : Partial<Record<string, AnyBinding>>;
|
|
32
|
+
export type WorkItemAccessor = {
|
|
33
|
+
readonly title: WorkItemBinding;
|
|
34
|
+
readonly description: WorkItemBinding;
|
|
35
|
+
readonly field: (fieldName: string) => WorkItemBinding;
|
|
36
|
+
};
|
|
37
|
+
type WithWorkItemFields<T> = {
|
|
38
|
+
workItemTitle: string;
|
|
39
|
+
workItemDescription: string | null;
|
|
40
|
+
} & T;
|
|
41
|
+
export type StepInputCtx<TInput extends ZodType, TSteps extends ReadonlyArray<AnyTypedStep>> = {
|
|
42
|
+
input: InputAccessor<Prettify<WithWorkItemFields<TInput["_output"]>>>;
|
|
43
|
+
signal: <S extends ElementOf<TSteps>>(step: S, key: S["__signalKeys"]) => StepSignalBinding;
|
|
44
|
+
output: <S extends ElementOf<TSteps>>(step: S) => StepOutputBinding;
|
|
45
|
+
literal: (value: unknown) => LiteralBinding;
|
|
46
|
+
};
|
|
47
|
+
type ReservedPipelineInputKeys = "workItemTitle" | "workItemDescription";
|
|
48
|
+
type NoReservedKeys<T extends ZodType> = T extends {
|
|
49
|
+
shape: infer Shape;
|
|
50
|
+
} ? [string & keyof Shape & ReservedPipelineInputKeys] extends [never] ? T : never : T;
|
|
51
|
+
export type PipelineMeta<TInput extends ZodType = z.ZodUnknown> = {
|
|
52
|
+
key: string;
|
|
53
|
+
name: string;
|
|
54
|
+
description?: string;
|
|
55
|
+
version?: number;
|
|
56
|
+
status?: "draft" | "active";
|
|
57
|
+
additionalPipelineInput?: {
|
|
58
|
+
schema: NoReservedKeys<TInput>;
|
|
59
|
+
bindings: (ctx: {
|
|
60
|
+
workItem: WorkItemAccessor;
|
|
61
|
+
literal: (value: unknown) => LiteralBinding;
|
|
62
|
+
}) => TInput["_output"] extends object ? {
|
|
63
|
+
[K in RequiredInputKeys<TInput["_output"]>]: AnyBinding;
|
|
64
|
+
} & {
|
|
65
|
+
[K in OptionalInputKeys<TInput["_output"]>]?: AnyBinding;
|
|
66
|
+
} : Partial<Record<string, AnyBinding>>;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Returned by `.step()`. Requires `.advance()` before the pipeline can
|
|
71
|
+
* continue. Also accepts `.timeout()` before `.advance()`.
|
|
72
|
+
*/
|
|
73
|
+
export declare class PipelineStepAdvancementBuilder<TInput extends ZodType, TSteps extends ReadonlyArray<AnyTypedStep>> {
|
|
74
|
+
protected readonly inputSchema: TInput;
|
|
75
|
+
protected readonly meta: Omit<PipelineMeta<TInput>, "additionalPipelineInput">;
|
|
76
|
+
protected readonly steps: PipelineStepConfig[];
|
|
77
|
+
protected readonly pipelineInputBindings: Record<string, AnyBinding>;
|
|
78
|
+
readonly __steps: TSteps;
|
|
79
|
+
constructor(inputSchema: TInput, meta: Omit<PipelineMeta<TInput>, "additionalPipelineInput">, steps: PipelineStepConfig[], pipelineInputBindings?: Record<string, AnyBinding>);
|
|
80
|
+
advance(callback: (ctx: AdvanceCtx<LastSignalKeys<TSteps>, LastSignalTypeMap<TSteps>>) => AdvanceResult<LastSignalKeys<TSteps>>): PipelineStepBuilder<TInput, TSteps>;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Returned by `.advance()`. Provides `.step()` to chain additional steps,
|
|
84
|
+
* `.timeout()` to set timeout after advancing, and `.build()` to finalize.
|
|
85
|
+
*/
|
|
86
|
+
export declare class PipelineStepBuilder<TInput extends ZodType, TSteps extends ReadonlyArray<AnyTypedStep>> {
|
|
87
|
+
protected readonly inputSchema: TInput;
|
|
88
|
+
protected readonly meta: Omit<PipelineMeta<TInput>, "additionalPipelineInput">;
|
|
89
|
+
protected readonly steps: PipelineStepConfig[];
|
|
90
|
+
protected readonly pipelineInputBindings: Record<string, AnyBinding>;
|
|
91
|
+
readonly __steps: TSteps;
|
|
92
|
+
constructor(inputSchema: TInput, meta: Omit<PipelineMeta<TInput>, "additionalPipelineInput">, steps: PipelineStepConfig[], pipelineInputBindings?: Record<string, AnyBinding>);
|
|
93
|
+
step<S extends AnyTypedStep>(step: S, mapper: (ctx: StepInputCtx<TInput, TSteps>) => StepInputMapping<S>, configFn?: (config: StepConfig) => void): PipelineStepAdvancementBuilder<TInput, [...TSteps, S]>;
|
|
94
|
+
build(): PipelineDefinitionSpec;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Entry-point builder returned by `pipeline()`. Only exposes `.step()` —
|
|
98
|
+
* call that to receive a `PipelineStepAdvancementBuilder` which requires
|
|
99
|
+
* `.advance()` before the pipeline can proceed.
|
|
100
|
+
*/
|
|
101
|
+
export declare class PipelineBuilder<TInput extends ZodType> {
|
|
102
|
+
private readonly inputSchema;
|
|
103
|
+
private readonly meta;
|
|
104
|
+
private readonly steps;
|
|
105
|
+
private readonly pipelineInputBindings;
|
|
106
|
+
constructor(meta: PipelineMeta<TInput>);
|
|
107
|
+
step<S extends AnyTypedStep>(step: S, mapper: (ctx: StepInputCtx<TInput, []>) => StepInputMapping<S>, configFn?: (config: StepConfig) => void): PipelineStepAdvancementBuilder<TInput, [S]>;
|
|
108
|
+
}
|
|
109
|
+
export declare function literal(value: unknown): LiteralBinding;
|
|
110
|
+
export declare function pipeline<TInput extends ZodType = z.ZodUnknown>(meta: PipelineMeta<TInput>): PipelineBuilder<TInput>;
|
|
111
|
+
export {};
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type {
|
|
1
|
+
import { type ZodType } from "zod";
|
|
2
|
+
import type { StepDefinitionSpec, TypedStepDefinitionSpec } from "../steps/define-step";
|
|
3
3
|
import { type AdvancementPolicy, type SerializedAdvancementPolicy, type SerializedComputedSignalDefinition } from "../advancement-policies/define-advancement-policy";
|
|
4
4
|
export type { AdvancementPolicy, PipelineStepComputedSignalType, } from "../advancement-policies/define-advancement-policy";
|
|
5
5
|
export { Computed, Rule, } from "../advancement-policies/define-advancement-policy";
|
|
6
|
-
type AnyTypedStep = TypedStepDefinitionSpec<any, any, any>;
|
|
6
|
+
type AnyTypedStep = TypedStepDefinitionSpec<any, any, any, any>;
|
|
7
7
|
export type PipelineInputBinding = {
|
|
8
8
|
source: "pipeline_input";
|
|
9
9
|
path: string;
|
|
10
10
|
};
|
|
11
|
+
export type WorkItemBinding = {
|
|
12
|
+
source: "work_item";
|
|
13
|
+
field: string;
|
|
14
|
+
};
|
|
11
15
|
export type StepSignalBinding = {
|
|
12
16
|
source: "step_signal";
|
|
13
17
|
step: AnyTypedStep;
|
|
@@ -17,23 +21,11 @@ export type StepOutputBinding = {
|
|
|
17
21
|
source: "step_output";
|
|
18
22
|
step: AnyTypedStep;
|
|
19
23
|
};
|
|
20
|
-
export type
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
export declare function fromPipelineInput<T extends ZodType>(_schema: T, path: DotPaths<T["_output"]>): PipelineInputBinding;
|
|
26
|
-
/**
|
|
27
|
-
* Binds a step input field to a named signal from a prior step.
|
|
28
|
-
* `signalKey` is validated against the prior step's declared signal keys.
|
|
29
|
-
*/
|
|
30
|
-
export declare function fromSignal<TStep extends AnyTypedStep>(step: TStep, signalKey: TStep["__signalKeys"]): StepSignalBinding;
|
|
31
|
-
/**
|
|
32
|
-
* Binds a step input field to the entire agent output of a prior step.
|
|
33
|
-
* Use this when your consumer handles the full output object directly.
|
|
34
|
-
* For a stable contract, prefer fromSignal() instead.
|
|
35
|
-
*/
|
|
36
|
-
export declare function stepOutput(step: AnyTypedStep): StepOutputBinding;
|
|
24
|
+
export type LiteralBinding = {
|
|
25
|
+
source: "literal";
|
|
26
|
+
value: unknown;
|
|
27
|
+
};
|
|
28
|
+
export type AnyBinding = PipelineInputBinding | WorkItemBinding | StepSignalBinding | StepOutputBinding | LiteralBinding;
|
|
37
29
|
export type PipelineStepConfig<TStep extends AnyTypedStep = AnyTypedStep> = {
|
|
38
30
|
step: TStep;
|
|
39
31
|
/** Maps each step input field to an input source. Extra keys are ignored at runtime. */
|
|
@@ -54,6 +46,9 @@ export type PipelineStepConfig<TStep extends AnyTypedStep = AnyTypedStep> = {
|
|
|
54
46
|
type SerializedBinding = {
|
|
55
47
|
source: "pipeline_input";
|
|
56
48
|
path: string;
|
|
49
|
+
} | {
|
|
50
|
+
source: "work_item";
|
|
51
|
+
field: string;
|
|
57
52
|
} | {
|
|
58
53
|
source: "step_signal";
|
|
59
54
|
stepKey: string;
|
|
@@ -61,6 +56,9 @@ type SerializedBinding = {
|
|
|
61
56
|
} | {
|
|
62
57
|
source: "step_output";
|
|
63
58
|
stepKey: string;
|
|
59
|
+
} | {
|
|
60
|
+
source: "literal";
|
|
61
|
+
value: unknown;
|
|
64
62
|
};
|
|
65
63
|
export type PipelineDefinitionSpec = {
|
|
66
64
|
key: string;
|
|
@@ -68,6 +66,7 @@ export type PipelineDefinitionSpec = {
|
|
|
68
66
|
description: string | null;
|
|
69
67
|
version: number;
|
|
70
68
|
status: "draft" | "active" | "archived";
|
|
69
|
+
inputSchemaJson?: Record<string, unknown> | null;
|
|
71
70
|
steps: Array<{
|
|
72
71
|
stepKey: string;
|
|
73
72
|
stepName: string;
|
|
@@ -78,44 +77,17 @@ export type PipelineDefinitionSpec = {
|
|
|
78
77
|
advancementPolicyDefinition: SerializedAdvancementPolicy;
|
|
79
78
|
computedSignalDefinitions: SerializedComputedSignalDefinition[];
|
|
80
79
|
}>;
|
|
81
|
-
/** Step specs referenced by this pipeline.
|
|
80
|
+
/** Step specs referenced by this pipeline. Used by the push command to auto-push steps that aren't explicitly exported. */
|
|
82
81
|
_stepDefinitions?: StepDefinitionSpec[];
|
|
83
82
|
};
|
|
84
|
-
/**
|
|
85
|
-
* Untyped input shape used for documentation and as the internal implementation
|
|
86
|
-
* target. Call sites use the generic overload below which provides per-step
|
|
87
|
-
* signal key validation.
|
|
88
|
-
*/
|
|
89
83
|
export type DefinePipelineInput = {
|
|
90
84
|
key: string;
|
|
91
85
|
name: string;
|
|
92
86
|
description?: string | null;
|
|
93
87
|
version?: number;
|
|
94
88
|
status?: "draft" | "active";
|
|
95
|
-
|
|
89
|
+
input?: ZodType | null;
|
|
90
|
+
steps: ReadonlyArray<PipelineStepConfig>;
|
|
91
|
+
pipelineInputBindings?: Record<string, AnyBinding>;
|
|
96
92
|
};
|
|
97
|
-
|
|
98
|
-
* Defines a pipeline from an ordered list of step configs.
|
|
99
|
-
*
|
|
100
|
-
* Each step's `advancement` policy is typed against that step's declared signal
|
|
101
|
-
* keys — passing an unknown signal key to `Rule.signal()` / `Rule.when()` is a
|
|
102
|
-
* compile-time error. Inline `Computed.X(...)` tokens can also be used in the
|
|
103
|
-
* signal position; they're walked out of the rules tree at serialization time
|
|
104
|
-
* and emitted as the step's `computedSignalDefinitions`.
|
|
105
|
-
*
|
|
106
|
-
* TypeScript achieves per-element signal key checking by constraining `TSteps`
|
|
107
|
-
* to a tuple of step instances (`AnyTypedStep[]`), not step configs. Each element
|
|
108
|
-
* of `steps` is then typed as `PipelineStepConfig<TSteps[K]>`, giving TypeScript
|
|
109
|
-
* a direct inference site: `step: TSteps[K]` matches the concrete step instance,
|
|
110
|
-
* which carries the signal key union via `__signalKeys`.
|
|
111
|
-
*/
|
|
112
|
-
export declare function definePipeline<const TSteps extends ReadonlyArray<AnyTypedStep>>(config: {
|
|
113
|
-
key: string;
|
|
114
|
-
name: string;
|
|
115
|
-
description?: string | null;
|
|
116
|
-
version?: number;
|
|
117
|
-
status?: "draft" | "active";
|
|
118
|
-
steps: {
|
|
119
|
-
[K in keyof TSteps]: PipelineStepConfig<TSteps[K]>;
|
|
120
|
-
};
|
|
121
|
-
}): PipelineDefinitionSpec;
|
|
93
|
+
export declare function buildPipelineSpec(config: DefinePipelineInput): PipelineDefinitionSpec;
|