@scarn/sdk 0.0.0-stage → 0.8.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 (152) hide show
  1. package/dist/chunk-0y2fy5en.js +166 -0
  2. package/dist/chunk-3ctaaseb.js +1456 -0
  3. package/dist/chunk-4ggr8af6.js +30 -0
  4. package/dist/chunk-5zsavw98.js +91 -0
  5. package/dist/chunk-63f90zky.js +39 -0
  6. package/dist/chunk-700xe701.js +100 -0
  7. package/dist/chunk-ar6hcj1r.js +35 -0
  8. package/dist/chunk-cdanncng.js +74 -0
  9. package/dist/chunk-dp86pa6m.js +68 -0
  10. package/dist/chunk-e1h021kq.js +86 -0
  11. package/dist/chunk-gds7w7zh.js +330 -0
  12. package/dist/chunk-k4y5qt4y.js +14 -0
  13. package/dist/chunk-mz53r914.js +300 -0
  14. package/dist/chunk-ngy1fdcx.js +57 -0
  15. package/dist/chunk-p7yrcmqm.js +322 -0
  16. package/dist/chunk-rt9tq4j6.js +116 -0
  17. package/dist/chunk-skzxcba3.js +14282 -0
  18. package/dist/chunk-vfeytkqx.js +1687 -0
  19. package/dist/chunk-y2pv8d6a.js +162 -0
  20. package/dist/chunk-y64skrwp.js +17 -0
  21. package/dist/chunk-yjtaq94c.js +1094 -0
  22. package/dist/chunk-zm72ksz0.js +256 -0
  23. package/dist/client.d.ts +4 -0
  24. package/dist/client.js +58 -0
  25. package/dist/contracts/artifact-markers.d.ts +42 -0
  26. package/dist/contracts/artifact-markers.js +16 -0
  27. package/dist/contracts/artifacts.d.ts +67 -0
  28. package/dist/contracts/artifacts.js +27 -0
  29. package/dist/contracts/pipeline-document/built-ins.d.ts +23 -0
  30. package/dist/contracts/pipeline-document/conditions/operators.d.ts +8 -0
  31. package/dist/contracts/pipeline-document/index.d.ts +11 -0
  32. package/dist/contracts/pipeline-document/index.js +99 -0
  33. package/dist/contracts/pipeline-document/json.d.ts +35 -0
  34. package/dist/contracts/pipeline-document/routes.d.ts +16 -0
  35. package/dist/contracts/pipeline-document/schema.d.ts +780 -0
  36. package/dist/contracts/pipeline-document/step-contract.d.ts +11 -0
  37. package/dist/contracts/step-artifact-submissions.d.ts +71 -0
  38. package/dist/contracts/step-artifact-submissions.js +171 -0
  39. package/dist/defaults/atomic-json-file.d.ts +10 -0
  40. package/dist/defaults/auth-file.d.ts +14 -0
  41. package/dist/defaults/base-url.d.ts +1 -0
  42. package/dist/defaults/config-file.d.ts +46 -0
  43. package/dist/defaults/home-dir.d.ts +3 -0
  44. package/dist/defaults/index.d.ts +12 -0
  45. package/dist/defaults/index.js +1240 -0
  46. package/dist/defaults/legacy-config-migration.d.ts +27 -0
  47. package/dist/defaults/load-push-defaults.d.ts +25 -0
  48. package/dist/defaults/project-config.d.ts +32 -0
  49. package/dist/defaults/project-ref.d.ts +34 -0
  50. package/dist/definitions/artifacts/artifact.d.ts +62 -0
  51. package/dist/definitions/artifacts/index.d.ts +1 -0
  52. package/dist/definitions/pipelines/define-default-pipeline-assignment.d.ts +263 -0
  53. package/dist/definitions/pipelines/index.d.ts +3 -0
  54. package/dist/definitions/pipelines/index.js +26 -0
  55. package/dist/definitions/pipelines/pipeline-definitions-client.d.ts +208 -0
  56. package/dist/definitions/pipelines/work-item-fields.d.ts +93 -0
  57. package/dist/definitions/steps/compile-mcps.d.ts +34 -0
  58. package/dist/definitions/steps/define-code-step.d.ts +84 -0
  59. package/dist/definitions/steps/define-mcp.d.ts +79 -0
  60. package/dist/definitions/steps/define-step.d.ts +137 -0
  61. package/dist/definitions/steps/env.d.ts +136 -0
  62. package/dist/definitions/steps/index.d.ts +14 -0
  63. package/dist/definitions/steps/index.js +76 -0
  64. package/dist/definitions/steps/mcp-server-config.d.ts +102 -0
  65. package/dist/definitions/steps/prompt-template.d.ts +24 -0
  66. package/dist/definitions/steps/repo.d.ts +67 -0
  67. package/dist/definitions/steps/runtime.d.ts +115 -0
  68. package/dist/definitions/steps/step-definitions-client.d.ts +400 -0
  69. package/dist/definitions/steps/step-features.d.ts +109 -0
  70. package/dist/definitions/steps/step-handle.d.ts +25 -0
  71. package/dist/definitions/steps/step-ref.d.ts +19 -0
  72. package/dist/definitions/validation/index.d.ts +2 -0
  73. package/dist/definitions/validation/index.js +19 -0
  74. package/dist/definitions/validation/validate-artifact-markers.d.ts +3 -0
  75. package/dist/definitions/validation/validate-artifacts.d.ts +7 -0
  76. package/dist/definitions/validation/validate-definition-specs.d.ts +16 -0
  77. package/dist/definitions/validation/validate-env.d.ts +15 -0
  78. package/dist/definitions/validation/validate-repo.d.ts +13 -0
  79. package/dist/definitions/validation/validate-runtime.d.ts +12 -0
  80. package/dist/definitions/validation/validation-issue.d.ts +11 -0
  81. package/dist/devcontainer-config-path.d.ts +21 -0
  82. package/dist/devcontainer-config-path.js +15 -0
  83. package/dist/env-vars.d.ts +136 -0
  84. package/dist/env-vars.js +37 -0
  85. package/dist/eslint.d.ts +42 -0
  86. package/dist/eslint.js +127 -0
  87. package/dist/generated/client/client.gen.d.ts +2 -0
  88. package/dist/generated/client/index.d.ts +8 -0
  89. package/dist/generated/client/types.gen.d.ts +117 -0
  90. package/dist/generated/client/utils.gen.d.ts +33 -0
  91. package/dist/generated/client.gen.d.ts +12 -0
  92. package/dist/generated/core/auth.gen.d.ts +18 -0
  93. package/dist/generated/core/bodySerializer.gen.d.ts +25 -0
  94. package/dist/generated/core/params.gen.d.ts +43 -0
  95. package/dist/generated/core/pathSerializer.gen.d.ts +33 -0
  96. package/dist/generated/core/queryKeySerializer.gen.d.ts +18 -0
  97. package/dist/generated/core/serverSentEvents.gen.d.ts +71 -0
  98. package/dist/generated/core/types.gen.d.ts +78 -0
  99. package/dist/generated/core/utils.gen.d.ts +19 -0
  100. package/dist/generated/index.d.ts +2 -0
  101. package/dist/generated/sdk.gen.d.ts +302 -0
  102. package/dist/generated/types.gen.d.ts +18375 -0
  103. package/dist/git-url/git-remote.d.ts +30 -0
  104. package/dist/git-url/git-repo-identity.d.ts +44 -0
  105. package/dist/git-url/git-repo-identity.js +161 -0
  106. package/dist/git-url/parse-git-host.d.ts +23 -0
  107. package/dist/health-checks.d.ts +169 -0
  108. package/dist/health-checks.js +21 -0
  109. package/dist/index.d.ts +11 -0
  110. package/dist/index.js +296 -0
  111. package/dist/jsonc.d.ts +3 -0
  112. package/dist/jsonc.js +12 -0
  113. package/dist/managed-runtimes.d.ts +20 -0
  114. package/dist/managed-runtimes.js +15 -0
  115. package/dist/opencode-mcp.d.ts +313 -0
  116. package/dist/opencode-mcp.js +31 -0
  117. package/dist/pipelines/chain.d.ts +7 -0
  118. package/dist/pipelines/compile-args.d.ts +12 -0
  119. package/dist/pipelines/compile-chain.d.ts +9 -0
  120. package/dist/pipelines/compile-checks.d.ts +16 -0
  121. package/dist/pipelines/compile-state.d.ts +30 -0
  122. package/dist/pipelines/condition-data.d.ts +78 -0
  123. package/dist/pipelines/conditions.d.ts +47 -0
  124. package/dist/pipelines/context.d.ts +16 -0
  125. package/dist/pipelines/define-pipeline.d.ts +32 -0
  126. package/dist/pipelines/each.d.ts +5 -0
  127. package/dist/pipelines/errors.d.ts +26 -0
  128. package/dist/pipelines/handles.d.ts +29 -0
  129. package/dist/pipelines/index.d.ts +18 -0
  130. package/dist/pipelines/index.js +83 -0
  131. package/dist/pipelines/model.d.ts +103 -0
  132. package/dist/pipelines/nodes.d.ts +54 -0
  133. package/dist/pipelines/ref-types.d.ts +54 -0
  134. package/dist/pipelines/refs.d.ts +80 -0
  135. package/dist/pipelines/registry.d.ts +12 -0
  136. package/dist/pipelines/source.d.ts +17 -0
  137. package/dist/pipelines/types.d.ts +160 -0
  138. package/dist/push/code-step-lookup.d.ts +32 -0
  139. package/dist/push/code-step-lookup.js +12 -0
  140. package/dist/push/collect-definitions.d.ts +70 -0
  141. package/dist/push/collect-pipeline-documents.d.ts +14 -0
  142. package/dist/push/index.d.ts +6 -0
  143. package/dist/push/index.js +327 -0
  144. package/dist/push/push-from-directory.d.ts +37 -0
  145. package/dist/repo-config.d.ts +80 -0
  146. package/dist/repo-config.js +25 -0
  147. package/dist/scarn-config-parser.d.ts +29 -0
  148. package/dist/scarn-config-parser.js +10 -0
  149. package/dist/task-plane-client.d.ts +489 -0
  150. package/dist/z.d.ts +7 -0
  151. package/package.json +132 -4
  152. package/README.md +0 -3
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Compiles args: each ref becomes its reference string, and each plain JSON
3
+ * value becomes `{ "value": ... }`. An array with a ref among its elements
4
+ * becomes `{ "list": [...] }`, one reference or literal per element. A ref
5
+ * nested deeper in a literal is an error.
6
+ */
7
+ import type { ArgValue } from "../contracts/pipeline-document";
8
+ import type { RawArgs } from "./model";
9
+ /** One compiled arg. Throws `AuthoringError`. */
10
+ export declare function compileArg(name: string, value: RawArgs[string]): ArgValue;
11
+ /** The args in order, without undefined values; Proxy spreads expand here. */
12
+ export declare function argEntries(args: RawArgs): [string, RawArgs[string]][];
@@ -0,0 +1,9 @@
1
+ import { type CompileState, type Segment } from "./compile-state";
2
+ import type { TargetSpec } from "./model";
3
+ import type { SourceSite } from "./source";
4
+ type Json = Record<string, unknown>;
5
+ /** Compiles one transition (start, `next` entry or `catch` target); undefined on error. */
6
+ export declare function compileTransition(state: CompileState, spec: TargetSpec, context: object | null, pointer: readonly Segment[], site: SourceSite | null, kind: "start" | "next" | "catch"): Json | undefined;
7
+ /** Wires a finished chain from `flow`. */
8
+ export declare function wireChain(state: CompileState, value: object, site: SourceSite | null): void;
9
+ export {};
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Whole-graph checks run after every chain is wired: unreachable nodes,
3
+ * decisions without actions, reach-backs to missing nodes, unused reads,
4
+ * work-item field labels, and chains left out of `flow`. Split checks (scopes, merges, reach-backs into
5
+ * merged lanes) run in shared-core's validator.
6
+ */
7
+ import { type CompileState } from "./compile-state";
8
+ import type { BuildIssue } from "./errors";
9
+ export declare function checkReachable(state: CompileState, start: string | undefined): void;
10
+ export declare function checkDecisionActions(state: CompileState): void;
11
+ export declare function checkReaches(state: CompileState): void;
12
+ export declare function checkUnusedReads(state: CompileState): void;
13
+ /** The `workItemFields` map, from the fields used, in order of first use. */
14
+ export declare function workItemFields(state: CompileState): Record<string, string> | undefined;
15
+ /** Finished chains for this pipeline's nodes that were never put in a flow. */
16
+ export declare function unusedChainWarnings(state: CompileState): BuildIssue[];
@@ -0,0 +1,30 @@
1
+ import { type BuildIssue } from "./errors";
2
+ import type { ChainData, NodeDef } from "./model";
3
+ import { type ReadTracker } from "./refs";
4
+ import type { SourceSite } from "./source";
5
+ export type Segment = string | number;
6
+ export interface PlacedNode {
7
+ def: NodeDef;
8
+ chain: ChainData | undefined;
9
+ /** The compiled JSON node. */
10
+ json: Record<string, unknown>;
11
+ }
12
+ export interface CompileState {
13
+ readonly nodes: Map<string, PlacedNode>;
14
+ readonly issues: BuildIssue[];
15
+ readonly sourceMap: Record<string, SourceSite>;
16
+ readonly tracker: ReadTracker;
17
+ /** Every chain in `flow`. */
18
+ readonly usedChains: Set<ChainData>;
19
+ }
20
+ export declare function newState(): CompileState;
21
+ export declare function issue(state: CompileState, site: SourceSite | null, pointer: readonly Segment[], message: string): void;
22
+ export declare function mapSource(state: CompileState, pointer: readonly Segment[], site: SourceSite | null): void;
23
+ /**
24
+ * Runs authoring code (a callback, an args object) for the JSON at
25
+ * `pointer`. Errors it throws become build issues there; returns undefined
26
+ * when it threw.
27
+ */
28
+ export declare function attempt<T>(state: CompileState, pointer: readonly Segment[], site: SourceSite | null, run: () => T): T | undefined;
29
+ /** Places `def`, or reports a clash with an earlier node of the same id. */
30
+ export declare function place(state: CompileState, def: NodeDef, site: SourceSite | null, pointer: readonly Segment[]): PlacedNode | undefined;
@@ -0,0 +1,78 @@
1
+ /**
2
+ * Conditions at run time: data built by the condition helpers and compiled to
3
+ * JSON `when` objects once the pipeline is assembled. Compiling checks that
4
+ * paths inside `some` / `every` / `none` / `count` are relative to the
5
+ * element and paths outside them aren't, and marks every ref it uses.
6
+ */
7
+ import type { ComputedFunction, Condition as JsonCondition, ConditionOperator, JsonValue } from "../contracts/pipeline-document";
8
+ import { type RefData } from "./refs";
9
+ import { type SourceSite } from "./source";
10
+ export declare const conditionBrand: unique symbol;
11
+ export declare const computedBrand: unique symbol;
12
+ /** A condition, built with the helpers. Plain JS booleans aren't conditions. */
13
+ export interface Condition {
14
+ readonly [conditionBrand]: true;
15
+ }
16
+ /** A number computed by `sum`, `avg`, `min`, `max` or `count`. */
17
+ export interface ComputedValue {
18
+ readonly [computedBrand]: true;
19
+ }
20
+ export type Scope = "document" | "element";
21
+ /** A ref or computed value on the left of a comparison. */
22
+ export type LeftNode = {
23
+ kind: "ref";
24
+ ref: RefData;
25
+ } | {
26
+ kind: "computed";
27
+ computed: ComputedNode;
28
+ };
29
+ export type RightNode = {
30
+ kind: "none";
31
+ } | {
32
+ kind: "ref";
33
+ ref: RefData;
34
+ } | {
35
+ kind: "value";
36
+ value: JsonValue;
37
+ };
38
+ export type ConditionNode = {
39
+ kind: "all" | "any";
40
+ items: ConditionData[];
41
+ } | {
42
+ kind: "not";
43
+ item: ConditionData;
44
+ } | {
45
+ kind: "compare";
46
+ left: LeftNode;
47
+ op: ConditionOperator;
48
+ right: RightNode;
49
+ } | {
50
+ kind: "list";
51
+ list: RefData;
52
+ op: ConditionOperator;
53
+ where: ConditionData;
54
+ };
55
+ export type ComputedNode = {
56
+ fn: ComputedFunction;
57
+ refs: RefData[];
58
+ weights?: number[];
59
+ } | {
60
+ fn: ComputedFunction;
61
+ list: RefData;
62
+ field?: RefData;
63
+ where?: ConditionData;
64
+ };
65
+ export declare class ConditionData {
66
+ readonly node: ConditionNode;
67
+ readonly site: SourceSite | null;
68
+ constructor(node: ConditionNode, site?: SourceSite | null);
69
+ }
70
+ export declare class ComputedData {
71
+ readonly node: ComputedNode;
72
+ readonly site: SourceSite | null;
73
+ constructor(node: ComputedNode, site?: SourceSite | null);
74
+ }
75
+ export declare function conditionData(value: unknown): ConditionData;
76
+ export declare function requireRef(value: unknown, what: string): RefData;
77
+ /** Compiles a condition to its JSON `when`. Throws `AuthoringError`. */
78
+ export declare function compileCondition(data: ConditionData, scope?: Scope): JsonCondition;
@@ -0,0 +1,47 @@
1
+ import { type ComputedValue, type Condition } from "./condition-data";
2
+ import type { JsonLiteral, Literal, Placeholder, Ref } from "./ref-types";
3
+ export type { Condition, ComputedValue } from "./condition-data";
4
+ /** What may be compared with a `T`: a reference of that type or a literal. */
5
+ export type Right<T> = [T] extends [never] ? Ref<unknown> | JsonLiteral : Ref<T> | Literal<T>;
6
+ type NumberLeft = Ref<number | null> | ComputedValue;
7
+ type StringLeft = Ref<string | null>;
8
+ export declare function equal<T>(left: Ref<T>, value: NoInfer<Right<T>>): Condition;
9
+ export declare function equal(left: ComputedValue, value: number | Ref<number>): Condition;
10
+ export declare function notEqual<T>(left: Ref<T>, value: NoInfer<Right<T>>): Condition;
11
+ export declare function notEqual(left: ComputedValue, value: number | Ref<number>): Condition;
12
+ export declare function lessThan(left: NumberLeft, value: number | Ref<number>): Condition;
13
+ export declare function lessThanInclusive(left: NumberLeft, value: number | Ref<number>): Condition;
14
+ export declare function greaterThan(left: NumberLeft, value: number | Ref<number>): Condition;
15
+ export declare function greaterThanInclusive(left: NumberLeft, value: number | Ref<number>): Condition;
16
+ export declare function exists(left: Ref<unknown>): Condition;
17
+ export declare function isEmpty(left: Ref<string | readonly unknown[] | object | null>): Condition;
18
+ export declare function contains(left: StringLeft, value: string | Ref<string>): Condition;
19
+ export declare function contains<E>(left: Ref<readonly E[] | null>, value: NoInfer<Right<E>>): Condition;
20
+ export declare function startsWith(left: StringLeft, value: string | Ref<string>): Condition;
21
+ export declare function endsWith(left: StringLeft, value: string | Ref<string>): Condition;
22
+ /** `pattern` is a regular expression source, matched with the `u` flag. */
23
+ export declare function matches(left: StringLeft, pattern: string): Condition;
24
+ /** Date strings (ISO 8601). */
25
+ export declare function before(left: StringLeft, date: string | Ref<string>): Condition;
26
+ export declare function after(left: StringLeft, date: string | Ref<string>): Condition;
27
+ export declare function all(...conditions: [Condition, ...Condition[]]): Condition;
28
+ export declare function any(...conditions: [Condition, ...Condition[]]): Condition;
29
+ export declare function not(condition: Condition): Condition;
30
+ type ElementCallback<E, R> = (element: Placeholder<E>) => R;
31
+ export declare function some<E>(over: Ref<readonly E[] | null>, where: ElementCallback<E, Condition>): Condition;
32
+ export declare function every<E>(over: Ref<readonly E[] | null>, where: ElementCallback<E, Condition>): Condition;
33
+ export declare function none<E>(over: Ref<readonly E[] | null>, where: ElementCallback<E, Condition>): Condition;
34
+ type NumberRefs = readonly [Ref<number | null>, ...Ref<number | null>[]];
35
+ export declare function sum(values: NumberRefs): ComputedValue;
36
+ export declare function sum<E>(over: Ref<readonly E[] | null>, field: ElementCallback<E, Ref<number | null>>): ComputedValue;
37
+ export declare function avg(values: NumberRefs, options?: {
38
+ weights?: number[];
39
+ }): ComputedValue;
40
+ export declare function avg<E>(over: Ref<readonly E[] | null>, field: ElementCallback<E, Ref<number | null>>): ComputedValue;
41
+ export declare function min(values: NumberRefs): ComputedValue;
42
+ export declare function min<E>(over: Ref<readonly E[] | null>, field: ElementCallback<E, Ref<number | null>>): ComputedValue;
43
+ export declare function max(values: NumberRefs): ComputedValue;
44
+ export declare function max<E>(over: Ref<readonly E[] | null>, field: ElementCallback<E, Ref<number | null>>): ComputedValue;
45
+ /** Counts the refs that exist and aren't null, or the list's elements (matching `where`). */
46
+ export declare function count(values: readonly [Ref<unknown>, ...Ref<unknown>[]]): ComputedValue;
47
+ export declare function count<E>(over: Ref<readonly E[] | null>, where?: ElementCallback<E, Condition>): ComputedValue;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * The `r` objects passed to chain callbacks. Each property read creates a
3
+ * fresh root placeholder, so reads are tracked from the root, and each `r`
4
+ * owns its placeholders: using `r.result` from another node's callback is an
5
+ * error, because it would compile to the wrong node's `result`.
6
+ */
7
+ import type { JsonSchema } from "../contracts/pipeline-document";
8
+ import type { NodeDef } from "./model";
9
+ export type ContextKind = "next" | "catch";
10
+ /** The `r` for a callback on `node`'s chain. */
11
+ export declare function makeContext(node: NodeDef, kind: ContextKind): object;
12
+ /** The `item` parameter of an `each` start callback, and its owner token. */
13
+ export declare function makeItem(itemsSchema: JsonSchema | undefined): {
14
+ item: object;
15
+ owner: object;
16
+ };
@@ -0,0 +1,32 @@
1
+ /**
2
+ * `definePipeline`: runs the authoring callbacks once, with placeholders, and
3
+ * compiles the result to a pipeline JSON document. It doesn't validate the
4
+ * document (that's `validatePipeline` in `@scarn/shared-core/pipelines`);
5
+ * it reports what only the TS source can show, and throws
6
+ * `PipelineBuildError` when anything is wrong.
7
+ */
8
+ import type { PipelineDocument, StepCatalog } from "../contracts/pipeline-document";
9
+ import { type BuildIssue } from "./errors";
10
+ import { type SourceSite } from "./source";
11
+ import type { FlowChain, Target } from "./types";
12
+ export interface PipelineConfig {
13
+ key: string;
14
+ title?: string;
15
+ /** The first node. Only `workItem.*` refs and literals are available here. */
16
+ start: Target;
17
+ flow: readonly FlowChain[];
18
+ }
19
+ /** What `definePipeline` returns: the compiled document and what the build needs. */
20
+ export interface PipelineDefinition {
21
+ readonly _tag: "pipeline_document";
22
+ readonly key: string;
23
+ readonly document: PipelineDocument;
24
+ /** TS source sites by JSON pointer (`/nodes/fix/next/routes/0`), for error messages. */
25
+ readonly sourceMap: Readonly<Record<string, SourceSite>>;
26
+ /** The local steps' contracts, by step key. `stepRef` steps aren't in it. */
27
+ readonly steps: StepCatalog;
28
+ /** Problems that don't stop the build, such as chains left out of `flow`. */
29
+ readonly warnings: readonly BuildIssue[];
30
+ }
31
+ /** Compiles a pipeline to its JSON document. Throws `PipelineBuildError`. */
32
+ export declare function definePipeline(config: PipelineConfig): PipelineDefinition;
@@ -0,0 +1,5 @@
1
+ import type { Placeholder, Ref } from "./ref-types";
2
+ import type { EachOptions, EachTarget, Target } from "./types";
3
+ /** Starts one lane per element of `over`, each at the target `start` returns for its item. */
4
+ export declare function each<E>(over: Ref<readonly E[]>, options: EachOptions, start: (item: Placeholder<E>) => Target): EachTarget;
5
+ export declare function each<E>(over: Ref<readonly E[]>, start: (item: Placeholder<E>) => Target): EachTarget;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Build errors: problems `definePipeline` finds while compiling. Each one
3
+ * carries the TS source site and the JSON pointer it applies to, and prints as
4
+ * `file.ts:42 (/nodes/x/next/routes/0/args/plan): message`.
5
+ */
6
+ import { type SourceSite } from "./source";
7
+ export interface BuildIssue {
8
+ site: SourceSite | null;
9
+ /** JSON pointer into the compiled document; "" for the whole document. */
10
+ pointer: string;
11
+ message: string;
12
+ }
13
+ export declare function formatIssue(issue: BuildIssue): string;
14
+ /** Thrown by `definePipeline` when the pipeline can't be compiled. */
15
+ export declare class PipelineBuildError extends Error {
16
+ readonly issues: readonly BuildIssue[];
17
+ constructor(key: string, issues: readonly BuildIssue[]);
18
+ }
19
+ /**
20
+ * Thrown while authoring code runs (a coerced placeholder, a bad spread);
21
+ * the compiler turns it into a `BuildIssue` at the pointer being compiled.
22
+ */
23
+ export declare class AuthoringError extends Error {
24
+ readonly site: SourceSite | null;
25
+ constructor(message: string, site?: SourceSite | null);
26
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Handles at run time: callable functions that record a target when called,
3
+ * with the chain-starting methods attached. Step handles from `defineStep` /
4
+ * `codeStep` and `stepRef` are built here, and so are wait handles.
5
+ */
6
+ import type { JsonSchema } from "../contracts/pipeline-document";
7
+ import type { NodeDef, RawArgs } from "./model";
8
+ /** What `toPipelineStep` needs from a step definition. */
9
+ export interface StepSource {
10
+ key: string;
11
+ inputSchemaJson: JsonSchema | Record<string, unknown> | null;
12
+ resultSchemaJson: JsonSchema | Record<string, unknown> | null;
13
+ errors?: readonly string[];
14
+ /** A code step always has a result schema, so only an agent step without one is a conversation step. */
15
+ kind?: "built_in" | "user_defined" | "code";
16
+ }
17
+ /** Makes `handle` a pipeline handle for `node`: chain methods, `.partial`, and `.as` for steps. */
18
+ export declare function makeHandle<T extends object>(handle: T, node: NodeDef): T;
19
+ /**
20
+ * The call behind a step handle: records a target for `source`'s node. Used
21
+ * by `toStepHandle` so `defineStep` / `codeStep` handles are pipeline steps.
22
+ */
23
+ export declare function stepNode(source: StepSource, local?: boolean): NodeDef;
24
+ /** A callable step handle for `node`, without the handle's own spec fields. */
25
+ export declare function stepCall(node: NodeDef): (args?: RawArgs) => object;
26
+ /** A callable wait or terminal-free handle, with chain methods. */
27
+ export declare function waitHandle(node: NodeDef): object;
28
+ /** A fresh step handle for a step known only by key. */
29
+ export declare function bareStepHandle(source: StepSource, local: boolean): object;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * The pipeline authoring SDK: write a pipeline in TypeScript and compile it
3
+ * to a pipeline JSON document with `definePipeline`.
4
+ */
5
+ export { definePipeline } from "./define-pipeline";
6
+ export type { PipelineConfig, PipelineDefinition } from "./define-pipeline";
7
+ export { decision, reply, succeed, fail, stepRef, workItem, workItemField, } from "./nodes";
8
+ export type { DecisionActionOptions } from "./nodes";
9
+ export { each } from "./each";
10
+ export { equal, notEqual, lessThan, lessThanInclusive, greaterThan, greaterThanInclusive, exists, isEmpty, contains, startsWith, endsWith, matches, before, after, all, any, not, some, every, none, sum, avg, min, max, count, } from "./conditions";
11
+ export type { Condition, ComputedValue, Right } from "./conditions";
12
+ export { PipelineBuildError, formatIssue } from "./errors";
13
+ export type { BuildIssue } from "./errors";
14
+ export type { SourceSite } from "./source";
15
+ export type { Arg, Args, ErrorValue, JsonLiteral, Literal, Placeholder, Ref, UntypedPlaceholder, } from "./ref-types";
16
+ export type { BuiltInError, CatchContext, ConversationResult, DecisionResult, EachOptions, EachTarget, FlowChain, Mergeable, NextContext, NextOptions, NextRoute, NodeHandle, PartialTarget, PipelineStep, ReplyInput, ReplyResult, StepSettings, Target, Terminal, WaitError, WaitHandle, WaitSettings, } from "./types";
17
+ export type { StepRef } from "../definitions/steps/step-ref";
18
+ export type { Catch, Condition as ConditionJson, DecisionAction, DecisionBody, ListArg, JsonSchema, JsonValue, PipelineDocument, PipelineNode, StepCatalog, Next, Otherwise, Route, StepContract, ToleratedFailures, } from "../contracts/pipeline-document";
@@ -0,0 +1,83 @@
1
+ // @bun
2
+ import {
3
+ after,
4
+ all,
5
+ any,
6
+ avg,
7
+ before,
8
+ contains,
9
+ count,
10
+ decision,
11
+ definePipeline,
12
+ each,
13
+ endsWith,
14
+ equal,
15
+ every,
16
+ exists,
17
+ fail,
18
+ greaterThan,
19
+ greaterThanInclusive,
20
+ isEmpty,
21
+ lessThan,
22
+ lessThanInclusive,
23
+ matches,
24
+ max,
25
+ min,
26
+ none,
27
+ not,
28
+ notEqual,
29
+ reply,
30
+ some,
31
+ startsWith,
32
+ stepRef,
33
+ succeed,
34
+ sum,
35
+ workItem,
36
+ workItemField
37
+ } from "../chunk-yjtaq94c.js";
38
+ import"../chunk-p7yrcmqm.js";
39
+ import {
40
+ PipelineBuildError,
41
+ formatIssue
42
+ } from "../chunk-mz53r914.js";
43
+ import"../chunk-dp86pa6m.js";
44
+ import"../chunk-skzxcba3.js";
45
+ import"../chunk-y64skrwp.js";
46
+ export {
47
+ PipelineBuildError,
48
+ after,
49
+ all,
50
+ any,
51
+ avg,
52
+ before,
53
+ contains,
54
+ count,
55
+ decision,
56
+ definePipeline,
57
+ each,
58
+ endsWith,
59
+ equal,
60
+ every,
61
+ exists,
62
+ fail,
63
+ formatIssue,
64
+ greaterThan,
65
+ greaterThanInclusive,
66
+ isEmpty,
67
+ lessThan,
68
+ lessThanInclusive,
69
+ matches,
70
+ max,
71
+ min,
72
+ none,
73
+ not,
74
+ notEqual,
75
+ reply,
76
+ some,
77
+ startsWith,
78
+ stepRef,
79
+ succeed,
80
+ sum,
81
+ workItem,
82
+ workItemField
83
+ };
@@ -0,0 +1,103 @@
1
+ /**
2
+ * The run-time data behind handles, targets and chains. Every value is
3
+ * immutable once created; chain methods return new chains.
4
+ */
5
+ import type { DecisionAction, JsonSchema, ToleratedFailures } from "../contracts/pipeline-document";
6
+ import type { RefData } from "./refs";
7
+ import { type SourceSite } from "./source";
8
+ /** One node of the document, as described by its handle. */
9
+ export type NodeDef = {
10
+ readonly kind: "step";
11
+ readonly id: string;
12
+ readonly step: string;
13
+ /** False for `stepRef` steps, which only the server catalog knows. */
14
+ readonly local: boolean;
15
+ readonly inputSchema: JsonSchema | null;
16
+ readonly resultSchema: JsonSchema | null;
17
+ /** A local agent step with no result schema: its result is `CONVERSATION_RESULT_SCHEMA`. */
18
+ readonly conversation: boolean;
19
+ readonly errors: readonly string[];
20
+ readonly site: SourceSite | null;
21
+ } | {
22
+ readonly kind: "wait";
23
+ readonly id: string;
24
+ readonly for: "decision" | "reply";
25
+ /** A decision wait's actions, in button order; null on other waits. */
26
+ readonly actions: readonly DecisionAction[] | null;
27
+ readonly inputSchema: JsonSchema | null;
28
+ readonly resultSchema: JsonSchema;
29
+ readonly site: SourceSite | null;
30
+ } | {
31
+ readonly kind: "succeed";
32
+ readonly id: string;
33
+ /** Creation order; terminals are emitted after other nodes, in this order. */
34
+ readonly seq: number;
35
+ readonly title?: string;
36
+ readonly site: SourceSite | null;
37
+ } | {
38
+ readonly kind: "fail";
39
+ readonly id: string;
40
+ readonly seq: number;
41
+ readonly title?: string;
42
+ readonly error?: string;
43
+ readonly cause?: string;
44
+ readonly site: SourceSite | null;
45
+ };
46
+ /** Author-written args, before compiling: refs and literals by name. */
47
+ export type RawArgs = Readonly<Record<string, object | string | number | boolean | null | undefined>>;
48
+ export interface EachData {
49
+ readonly over: RefData;
50
+ readonly maxConcurrency: number | undefined;
51
+ readonly toleratedFailures: ToleratedFailures | undefined;
52
+ /** The lane's first target, from the item. */
53
+ readonly start: (item: object) => object;
54
+ readonly site: SourceSite | null;
55
+ }
56
+ /**
57
+ * "Go to this node with these args", from calling a handle; `partial` when
58
+ * it's from `handle.partial(args)` and ends a lane at a merge.
59
+ */
60
+ export interface TargetData {
61
+ readonly node: NodeDef;
62
+ readonly args: RawArgs | undefined;
63
+ readonly site: SourceSite | null;
64
+ readonly partial?: true;
65
+ }
66
+ export interface NodeSettings {
67
+ title?: string;
68
+ timeoutSeconds?: number;
69
+ heartbeatSeconds?: number;
70
+ maxRuns?: number;
71
+ maxTurns?: number;
72
+ }
73
+ /** A target as written: a target value, a bare handle, an `each`, or a callback returning one. */
74
+ export type TargetSpec = object;
75
+ export interface CatchData {
76
+ readonly on: readonly string[];
77
+ readonly target: TargetSpec;
78
+ readonly site: SourceSite | null;
79
+ }
80
+ export interface RouteData {
81
+ readonly when: ((r: object) => object) | undefined;
82
+ readonly target: TargetSpec;
83
+ }
84
+ /** The `.next(...)` call: its routes, `otherwise`, and match mode. */
85
+ export interface NextData {
86
+ readonly match: "first" | "all" | undefined;
87
+ readonly routes: readonly RouteData[];
88
+ readonly otherwise: TargetSpec | undefined;
89
+ readonly site: SourceSite | null;
90
+ }
91
+ export interface ChainData {
92
+ readonly node: NodeDef;
93
+ readonly settings: NodeSettings;
94
+ readonly retry: readonly {
95
+ on: readonly string[];
96
+ maxAttempts: number;
97
+ }[];
98
+ readonly catch: readonly CatchData[];
99
+ /** Set once `.next(...)` ends the chain. */
100
+ readonly next: NextData | undefined;
101
+ readonly site: SourceSite | null;
102
+ }
103
+ export declare function emptyChain(node: NodeDef): ChainData;
@@ -0,0 +1,54 @@
1
+ import { type DecisionBody } from "../contracts/pipeline-document";
2
+ import type { Placeholder, UntypedPlaceholder } from "./ref-types";
3
+ import type { DecisionResult, PipelineStep, ReplyInput, ReplyResult, Terminal, WaitHandle } from "./types";
4
+ /** A zod schema, typed by its output. */
5
+ interface Schema<T> {
6
+ readonly _output: T;
7
+ }
8
+ /** One action of a `decision` wait: its button label, and whether it needs a body. */
9
+ export interface DecisionActionOptions {
10
+ label: string;
11
+ /** Defaults to `"optional"`. */
12
+ body?: DecisionBody;
13
+ }
14
+ /**
15
+ * A wait for a decision: the person picks one of `actions` (buttons in key
16
+ * order) and can write a body. The result is `{ action, body }`, with
17
+ * `action` one of the keys of `actions`. `input` is what's being decided
18
+ * about; it types the args and `r.input`.
19
+ */
20
+ export declare function decision<I = Record<string, unknown>, const A extends Record<string, DecisionActionOptions> = Record<string, DecisionActionOptions>>(id: string, options: {
21
+ input?: Schema<I>;
22
+ actions: A;
23
+ }): WaitHandle<I, DecisionResult<Extract<keyof A, string>>>;
24
+ /**
25
+ * A wait for a reply to questions posted on the work item. Every transition
26
+ * into it passes `questions: string[]`; `{ questions: [] }` asks the default
27
+ * question.
28
+ */
29
+ export declare function reply(id: string): WaitHandle<ReplyInput, ReplyResult>;
30
+ /** Ends the run (or, inside a lane, that lane) successfully. */
31
+ export declare function succeed(id: string, options?: {
32
+ title?: string;
33
+ }): Terminal;
34
+ /** Ends the run (or, inside a lane, that lane) as failed. */
35
+ export declare function fail(id: string, options?: {
36
+ error?: string;
37
+ cause?: string;
38
+ title?: string;
39
+ }): Terminal;
40
+ /**
41
+ * A step that exists only on the server. Untyped unless you pass type
42
+ * arguments; the build validates it against the server catalog.
43
+ */
44
+ export declare function stepRef<TInput = unknown, TResult = unknown, TErrors extends string = string>(key: string): PipelineStep<TInput, TResult, TErrors>;
45
+ /** Work-item data, readable anywhere. */
46
+ export declare const workItem: {
47
+ readonly title: Placeholder<string>;
48
+ };
49
+ /**
50
+ * A work-item form field, as `workItem.fields.<alias>`. `label` is the form
51
+ * label it's read from; the pipeline's `workItemFields` collects them.
52
+ */
53
+ export declare function workItemField(alias: string, label: string): UntypedPlaceholder;
54
+ export {};
@@ -0,0 +1,54 @@
1
+ /**
2
+ * The types of references. A `Placeholder<T>` stands for a value of type `T`
3
+ * that exists only when the pipeline runs: reading `.x` on it gives the
4
+ * placeholder for `T["x"]`, and passing it as an arg or to a condition helper
5
+ * records its reference string. The brands below exist only in the types.
6
+ */
7
+ export declare const refType: unique symbol;
8
+ export declare const untypedBrand: unique symbol;
9
+ /** A reference to a run-time value of type `T`. */
10
+ export interface Ref<out T> {
11
+ readonly [refType]: T;
12
+ }
13
+ /**
14
+ * A reference whose type isn't known (a `stepRef` without type arguments, a
15
+ * work-item field, a wait without an input schema). Any field can be read,
16
+ * and it fits any arg; the build checks it against the catalog.
17
+ */
18
+ export interface UntypedPlaceholder extends Ref<never> {
19
+ readonly [untypedBrand]: true;
20
+ readonly [key: string]: UntypedPlaceholder;
21
+ }
22
+ /** A JSON value written in TypeScript, which may not contain references. */
23
+ export type JsonLiteral = string | number | boolean | null | readonly JsonLiteral[] | {
24
+ readonly [key: string]: JsonLiteral;
25
+ readonly [untypedBrand]?: never;
26
+ };
27
+ /** A plain JSON value of type `T`; references inside it are a type error. */
28
+ export type Literal<T> = unknown extends T ? JsonLiteral : T extends string | number | boolean | null | undefined ? T : T extends readonly (infer E)[] ? readonly Literal<E>[] : {
29
+ readonly [K in keyof T]: Literal<T[K]>;
30
+ };
31
+ type Fields<T> = [NonNullable<T>] extends [string] ? {
32
+ readonly length: Placeholder<number>;
33
+ } : [NonNullable<T>] extends [readonly unknown[]] ? {
34
+ readonly length: Placeholder<number>;
35
+ } : [NonNullable<T>] extends [object] ? {
36
+ readonly [K in keyof NonNullable<T>]-?: Placeholder<Exclude<NonNullable<T>[K], undefined>>;
37
+ } : unknown;
38
+ /** A reference to a `T`, plus a placeholder for each of its fields. */
39
+ export type Placeholder<T> = [T] extends [never] ? UntypedPlaceholder : unknown extends T ? UntypedPlaceholder : Ref<T> & Fields<T>;
40
+ /** An array arg built element by element: each a reference or a JSON literal. */
41
+ export type ListOf<T> = T extends readonly (infer E)[] ? readonly (Ref<E> | Literal<E>)[] : never;
42
+ /** One arg: a reference of a compatible type, a JSON literal, or a list of either. */
43
+ export type Arg<T> = Ref<T> | Literal<T> | ListOf<T>;
44
+ /** The args a step with input `I` is called with. */
45
+ export type Args<I> = {
46
+ [K in keyof I]: Arg<Exclude<I[K], undefined>>;
47
+ };
48
+ /** The error a `catch` handles. */
49
+ export interface ErrorValue {
50
+ name: string;
51
+ message: string;
52
+ cause?: unknown;
53
+ }
54
+ export {};