@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.
- package/dist/chunk-0y2fy5en.js +166 -0
- package/dist/chunk-3ctaaseb.js +1456 -0
- package/dist/chunk-4ggr8af6.js +30 -0
- package/dist/chunk-5zsavw98.js +91 -0
- package/dist/chunk-63f90zky.js +39 -0
- package/dist/chunk-700xe701.js +100 -0
- package/dist/chunk-ar6hcj1r.js +35 -0
- package/dist/chunk-cdanncng.js +74 -0
- package/dist/chunk-dp86pa6m.js +68 -0
- package/dist/chunk-e1h021kq.js +86 -0
- package/dist/chunk-gds7w7zh.js +330 -0
- package/dist/chunk-k4y5qt4y.js +14 -0
- package/dist/chunk-mz53r914.js +300 -0
- package/dist/chunk-ngy1fdcx.js +57 -0
- package/dist/chunk-p7yrcmqm.js +322 -0
- package/dist/chunk-rt9tq4j6.js +116 -0
- package/dist/chunk-skzxcba3.js +14282 -0
- package/dist/chunk-vfeytkqx.js +1687 -0
- package/dist/chunk-y2pv8d6a.js +162 -0
- package/dist/chunk-y64skrwp.js +17 -0
- package/dist/chunk-yjtaq94c.js +1094 -0
- package/dist/chunk-zm72ksz0.js +256 -0
- package/dist/client.d.ts +4 -0
- package/dist/client.js +58 -0
- package/dist/contracts/artifact-markers.d.ts +42 -0
- package/dist/contracts/artifact-markers.js +16 -0
- package/dist/contracts/artifacts.d.ts +67 -0
- package/dist/contracts/artifacts.js +27 -0
- package/dist/contracts/pipeline-document/built-ins.d.ts +23 -0
- package/dist/contracts/pipeline-document/conditions/operators.d.ts +8 -0
- package/dist/contracts/pipeline-document/index.d.ts +11 -0
- package/dist/contracts/pipeline-document/index.js +99 -0
- package/dist/contracts/pipeline-document/json.d.ts +35 -0
- package/dist/contracts/pipeline-document/routes.d.ts +16 -0
- package/dist/contracts/pipeline-document/schema.d.ts +780 -0
- package/dist/contracts/pipeline-document/step-contract.d.ts +11 -0
- package/dist/contracts/step-artifact-submissions.d.ts +71 -0
- package/dist/contracts/step-artifact-submissions.js +171 -0
- package/dist/defaults/atomic-json-file.d.ts +10 -0
- package/dist/defaults/auth-file.d.ts +14 -0
- package/dist/defaults/base-url.d.ts +1 -0
- package/dist/defaults/config-file.d.ts +46 -0
- package/dist/defaults/home-dir.d.ts +3 -0
- package/dist/defaults/index.d.ts +12 -0
- package/dist/defaults/index.js +1240 -0
- package/dist/defaults/legacy-config-migration.d.ts +27 -0
- package/dist/defaults/load-push-defaults.d.ts +25 -0
- package/dist/defaults/project-config.d.ts +32 -0
- package/dist/defaults/project-ref.d.ts +34 -0
- package/dist/definitions/artifacts/artifact.d.ts +62 -0
- package/dist/definitions/artifacts/index.d.ts +1 -0
- package/dist/definitions/pipelines/define-default-pipeline-assignment.d.ts +263 -0
- package/dist/definitions/pipelines/index.d.ts +3 -0
- package/dist/definitions/pipelines/index.js +26 -0
- package/dist/definitions/pipelines/pipeline-definitions-client.d.ts +208 -0
- package/dist/definitions/pipelines/work-item-fields.d.ts +93 -0
- package/dist/definitions/steps/compile-mcps.d.ts +34 -0
- package/dist/definitions/steps/define-code-step.d.ts +84 -0
- package/dist/definitions/steps/define-mcp.d.ts +79 -0
- package/dist/definitions/steps/define-step.d.ts +137 -0
- package/dist/definitions/steps/env.d.ts +136 -0
- package/dist/definitions/steps/index.d.ts +14 -0
- package/dist/definitions/steps/index.js +76 -0
- package/dist/definitions/steps/mcp-server-config.d.ts +102 -0
- package/dist/definitions/steps/prompt-template.d.ts +24 -0
- package/dist/definitions/steps/repo.d.ts +67 -0
- package/dist/definitions/steps/runtime.d.ts +115 -0
- package/dist/definitions/steps/step-definitions-client.d.ts +400 -0
- package/dist/definitions/steps/step-features.d.ts +109 -0
- package/dist/definitions/steps/step-handle.d.ts +25 -0
- package/dist/definitions/steps/step-ref.d.ts +19 -0
- package/dist/definitions/validation/index.d.ts +2 -0
- package/dist/definitions/validation/index.js +19 -0
- package/dist/definitions/validation/validate-artifact-markers.d.ts +3 -0
- package/dist/definitions/validation/validate-artifacts.d.ts +7 -0
- package/dist/definitions/validation/validate-definition-specs.d.ts +16 -0
- package/dist/definitions/validation/validate-env.d.ts +15 -0
- package/dist/definitions/validation/validate-repo.d.ts +13 -0
- package/dist/definitions/validation/validate-runtime.d.ts +12 -0
- package/dist/definitions/validation/validation-issue.d.ts +11 -0
- package/dist/devcontainer-config-path.d.ts +21 -0
- package/dist/devcontainer-config-path.js +15 -0
- package/dist/env-vars.d.ts +136 -0
- package/dist/env-vars.js +37 -0
- package/dist/eslint.d.ts +42 -0
- package/dist/eslint.js +127 -0
- package/dist/generated/client/client.gen.d.ts +2 -0
- package/dist/generated/client/index.d.ts +8 -0
- package/dist/generated/client/types.gen.d.ts +117 -0
- package/dist/generated/client/utils.gen.d.ts +33 -0
- package/dist/generated/client.gen.d.ts +12 -0
- package/dist/generated/core/auth.gen.d.ts +18 -0
- package/dist/generated/core/bodySerializer.gen.d.ts +25 -0
- package/dist/generated/core/params.gen.d.ts +43 -0
- package/dist/generated/core/pathSerializer.gen.d.ts +33 -0
- package/dist/generated/core/queryKeySerializer.gen.d.ts +18 -0
- package/dist/generated/core/serverSentEvents.gen.d.ts +71 -0
- package/dist/generated/core/types.gen.d.ts +78 -0
- package/dist/generated/core/utils.gen.d.ts +19 -0
- package/dist/generated/index.d.ts +2 -0
- package/dist/generated/sdk.gen.d.ts +302 -0
- package/dist/generated/types.gen.d.ts +18375 -0
- package/dist/git-url/git-remote.d.ts +30 -0
- package/dist/git-url/git-repo-identity.d.ts +44 -0
- package/dist/git-url/git-repo-identity.js +161 -0
- package/dist/git-url/parse-git-host.d.ts +23 -0
- package/dist/health-checks.d.ts +169 -0
- package/dist/health-checks.js +21 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +296 -0
- package/dist/jsonc.d.ts +3 -0
- package/dist/jsonc.js +12 -0
- package/dist/managed-runtimes.d.ts +20 -0
- package/dist/managed-runtimes.js +15 -0
- package/dist/opencode-mcp.d.ts +313 -0
- package/dist/opencode-mcp.js +31 -0
- package/dist/pipelines/chain.d.ts +7 -0
- package/dist/pipelines/compile-args.d.ts +12 -0
- package/dist/pipelines/compile-chain.d.ts +9 -0
- package/dist/pipelines/compile-checks.d.ts +16 -0
- package/dist/pipelines/compile-state.d.ts +30 -0
- package/dist/pipelines/condition-data.d.ts +78 -0
- package/dist/pipelines/conditions.d.ts +47 -0
- package/dist/pipelines/context.d.ts +16 -0
- package/dist/pipelines/define-pipeline.d.ts +32 -0
- package/dist/pipelines/each.d.ts +5 -0
- package/dist/pipelines/errors.d.ts +26 -0
- package/dist/pipelines/handles.d.ts +29 -0
- package/dist/pipelines/index.d.ts +18 -0
- package/dist/pipelines/index.js +83 -0
- package/dist/pipelines/model.d.ts +103 -0
- package/dist/pipelines/nodes.d.ts +54 -0
- package/dist/pipelines/ref-types.d.ts +54 -0
- package/dist/pipelines/refs.d.ts +80 -0
- package/dist/pipelines/registry.d.ts +12 -0
- package/dist/pipelines/source.d.ts +17 -0
- package/dist/pipelines/types.d.ts +160 -0
- package/dist/push/code-step-lookup.d.ts +32 -0
- package/dist/push/code-step-lookup.js +12 -0
- package/dist/push/collect-definitions.d.ts +70 -0
- package/dist/push/collect-pipeline-documents.d.ts +14 -0
- package/dist/push/index.d.ts +6 -0
- package/dist/push/index.js +327 -0
- package/dist/push/push-from-directory.d.ts +37 -0
- package/dist/repo-config.d.ts +80 -0
- package/dist/repo-config.js +25 -0
- package/dist/scarn-config-parser.d.ts +29 -0
- package/dist/scarn-config-parser.js +10 -0
- package/dist/task-plane-client.d.ts +489 -0
- package/dist/z.d.ts +7 -0
- package/package.json +132 -4
- package/README.md +0 -3
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Placeholders at run time: Proxies that record the reference path they stand
|
|
3
|
+
* for. Reading a field gives a child placeholder. Coercing one (comparison,
|
|
4
|
+
* arithmetic, template string) throws, and every read is recorded so reads
|
|
5
|
+
* that never reach an arg, `over` or a condition can be reported.
|
|
6
|
+
*/
|
|
7
|
+
import type { JsonSchema } from "../contracts/pipeline-document";
|
|
8
|
+
import { type SourceSite } from "./source";
|
|
9
|
+
/** A work-item field a reference reads, collected into `workItemFields`. */
|
|
10
|
+
export interface WorkItemFieldUse {
|
|
11
|
+
alias: string;
|
|
12
|
+
label: string;
|
|
13
|
+
}
|
|
14
|
+
/** A read of a placeholder field during compilation. */
|
|
15
|
+
export interface ReadRecord {
|
|
16
|
+
readonly path: string;
|
|
17
|
+
readonly site: SourceSite | null;
|
|
18
|
+
readonly pointer: string;
|
|
19
|
+
readonly parent: ReadRecord | null;
|
|
20
|
+
used: boolean;
|
|
21
|
+
hasChildren: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface RefData {
|
|
24
|
+
/** The reference string, or a path relative to a list element. */
|
|
25
|
+
readonly path: string;
|
|
26
|
+
/** "element" refs live inside `some` / `every` / `none` / `count` / field selectors. */
|
|
27
|
+
readonly scope: "document" | "element";
|
|
28
|
+
/** The JSON Schema of the value, when known. */
|
|
29
|
+
readonly schema: JsonSchema | undefined;
|
|
30
|
+
readonly field: WorkItemFieldUse | undefined;
|
|
31
|
+
readonly record: ReadRecord | null;
|
|
32
|
+
/** The callback context that created it; null for refs valid anywhere. */
|
|
33
|
+
readonly owner: object | null;
|
|
34
|
+
/** The node a `nodes.<id>...` reach-back reads. */
|
|
35
|
+
readonly reach: string | undefined;
|
|
36
|
+
}
|
|
37
|
+
/** A reach-back used at `pointer`, checked once every node is placed. */
|
|
38
|
+
export interface ReachUse {
|
|
39
|
+
node: string;
|
|
40
|
+
pointer: string;
|
|
41
|
+
site: SourceSite | null;
|
|
42
|
+
}
|
|
43
|
+
/** Collects reads while `definePipeline` runs the authoring callbacks. */
|
|
44
|
+
export interface ReadTracker {
|
|
45
|
+
readonly records: ReadRecord[];
|
|
46
|
+
/** Work-item fields used, in order of first use. */
|
|
47
|
+
readonly fields: WorkItemFieldUse[];
|
|
48
|
+
readonly reaches: ReachUse[];
|
|
49
|
+
pointer: string;
|
|
50
|
+
}
|
|
51
|
+
/** Runs `run` with `owners` as the callback contexts whose refs may be used. */
|
|
52
|
+
export declare function withOwners<T>(owners: readonly object[], run: () => T): T;
|
|
53
|
+
export declare function withTracker<T>(tracker: ReadTracker, run: () => T): T;
|
|
54
|
+
/** The current pointer of the active tracker, or "" outside compilation. */
|
|
55
|
+
export declare function setTrackerPointer(pointer: string): void;
|
|
56
|
+
export declare function makePlaceholder(data: RefData): object;
|
|
57
|
+
/**
|
|
58
|
+
* A root placeholder for a reference such as `result` or `nodes.x.input`.
|
|
59
|
+
* Context objects create one per property read, so reading `r.result` alone
|
|
60
|
+
* is recorded too.
|
|
61
|
+
*/
|
|
62
|
+
export declare function rootPlaceholder(path: string, schema: JsonSchema | undefined, options?: {
|
|
63
|
+
scope?: "document" | "element";
|
|
64
|
+
field?: WorkItemFieldUse;
|
|
65
|
+
owner?: object | null;
|
|
66
|
+
reach?: string;
|
|
67
|
+
}): object;
|
|
68
|
+
/** The data behind a placeholder, or undefined for any other value. */
|
|
69
|
+
export declare function refData(value: unknown): RefData | undefined;
|
|
70
|
+
/** Marks a placeholder as used, so its read isn't reported. */
|
|
71
|
+
export declare function markUsed(data: RefData): void;
|
|
72
|
+
/**
|
|
73
|
+
* Uses a ref in an arg, `over` or a condition: marks it used and checks it
|
|
74
|
+
* belongs to the callback being compiled. `result` means a different value
|
|
75
|
+
* in every node's callback, so a ref from another callback would compile to
|
|
76
|
+
* the wrong reference.
|
|
77
|
+
*/
|
|
78
|
+
export declare function useRef(data: RefData): string;
|
|
79
|
+
/** Reads of leaf paths that never reached an arg, `over` or a condition. */
|
|
80
|
+
export declare function unusedReads(tracker: ReadTracker): ReadRecord[];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ChainData, EachData, NodeDef, TargetData } from "./model";
|
|
2
|
+
/** Chains finished since the last `definePipeline`, to warn about ones left out of `flow`. */
|
|
3
|
+
export declare const pendingChains: Set<ChainData>;
|
|
4
|
+
export declare function registerNode<T extends object>(value: T, node: NodeDef): T;
|
|
5
|
+
export declare function registerTarget<T extends object>(value: T, target: TargetData): T;
|
|
6
|
+
export declare function registerEach<T extends object>(value: T, each: EachData): T;
|
|
7
|
+
export declare function registerChain<T extends object>(value: T, chain: ChainData): T;
|
|
8
|
+
export declare function nodeOf(value: unknown): NodeDef | undefined;
|
|
9
|
+
export declare function targetOf(value: unknown): TargetData | undefined;
|
|
10
|
+
export declare function eachOf(value: unknown): EachData | undefined;
|
|
11
|
+
export declare function chainOf(value: unknown): ChainData | undefined;
|
|
12
|
+
export declare function requireNode(value: unknown, what: string): NodeDef;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creation sites: where in the author's TypeScript a chain, target or ref was
|
|
3
|
+
* written, read from `new Error().stack`. Frames inside the SDK itself are
|
|
4
|
+
* skipped, so the site is the first frame in user code.
|
|
5
|
+
*/
|
|
6
|
+
/** A position in a source file. `file` is an absolute path or URL. */
|
|
7
|
+
export interface SourceSite {
|
|
8
|
+
file: string;
|
|
9
|
+
line: number;
|
|
10
|
+
column: number;
|
|
11
|
+
}
|
|
12
|
+
/** Parses one stack frame line into a site, or null for native frames. */
|
|
13
|
+
export declare function parseFrame(frame: string): SourceSite | null;
|
|
14
|
+
/** The first frame of the current stack that is outside the SDK, if any. */
|
|
15
|
+
export declare function captureSite(stack?: string | undefined): SourceSite | null;
|
|
16
|
+
/** `file.ts:42`, with the file relative to the working directory when it's inside it. */
|
|
17
|
+
export declare function formatSite(site: SourceSite | null): string;
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The public types of handles, targets and chains. Each chain method returns
|
|
3
|
+
* a type that only has the methods allowed next (see the chain grammar in
|
|
4
|
+
* `docs/plans/pipeline-ts-sdk.md`), so an unfinished or misordered chain is
|
|
5
|
+
* a type error rather than a build error.
|
|
6
|
+
*/
|
|
7
|
+
import type { BUILT_IN_ERRORS, ToleratedFailures, WAIT_ERRORS } from "../contracts/pipeline-document";
|
|
8
|
+
import type { StepRef } from "../definitions/steps/step-ref";
|
|
9
|
+
import type { Condition } from "./condition-data";
|
|
10
|
+
import type { Args, ErrorValue, JsonLiteral, Placeholder, Ref } from "./ref-types";
|
|
11
|
+
export declare const targetBrand: unique symbol;
|
|
12
|
+
export declare const eachBrand: unique symbol;
|
|
13
|
+
export declare const partialBrand: unique symbol;
|
|
14
|
+
export declare const chainBrand: unique symbol;
|
|
15
|
+
export declare const terminalBrand: unique symbol;
|
|
16
|
+
export type BuiltInError = (typeof BUILT_IN_ERRORS)[number];
|
|
17
|
+
export type WaitError = (typeof WAIT_ERRORS)[number];
|
|
18
|
+
/** "Go to this node with these args". */
|
|
19
|
+
export interface Target {
|
|
20
|
+
readonly [targetBrand]: true;
|
|
21
|
+
}
|
|
22
|
+
/** An `each`: start one lane per item. Only valid as a `next` target. */
|
|
23
|
+
export interface EachTarget {
|
|
24
|
+
readonly [eachBrand]: true;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* "End this lane by contributing these args to the merge node": from
|
|
28
|
+
* `handle.partial(args)`. Only valid as a `next` target inside a lane.
|
|
29
|
+
*/
|
|
30
|
+
export interface PartialTarget {
|
|
31
|
+
readonly [partialBrand]: true;
|
|
32
|
+
}
|
|
33
|
+
/** A finished chain, for a pipeline's `flow`. */
|
|
34
|
+
export interface FlowChain {
|
|
35
|
+
readonly [chainBrand]: "flow";
|
|
36
|
+
}
|
|
37
|
+
type NoKeys = Record<never, never>;
|
|
38
|
+
/** The args a node is called with; anything goes when its input is untyped. */
|
|
39
|
+
export type CallArgs<I> = unknown extends I ? Readonly<Record<string, Ref<unknown> | JsonLiteral>> : Args<I>;
|
|
40
|
+
/** Calling a handle: args are optional only when the input has no required keys. */
|
|
41
|
+
export type Call<I> = NoKeys extends I ? (args?: CallArgs<I>) => Target : (args: CallArgs<I>) => Target;
|
|
42
|
+
/** A bare handle is a target only when its input has no required keys. */
|
|
43
|
+
export interface Bare<I> {
|
|
44
|
+
readonly [targetBrand]: NoKeys extends I ? true : false;
|
|
45
|
+
}
|
|
46
|
+
/** Anything `r.node(...)` can reach back to: a step or wait handle. */
|
|
47
|
+
export interface NodeHandle<I, R> {
|
|
48
|
+
readonly __input: I;
|
|
49
|
+
readonly __result: R;
|
|
50
|
+
}
|
|
51
|
+
export interface NodeValues<I, R> {
|
|
52
|
+
readonly result: Placeholder<R>;
|
|
53
|
+
readonly input: Placeholder<I>;
|
|
54
|
+
}
|
|
55
|
+
export interface Reach {
|
|
56
|
+
/** An earlier node's values, as `nodes.<id>.result` / `nodes.<id>.input`. */
|
|
57
|
+
node<I, R>(handle: NodeHandle<I, R>): NodeValues<I, R>;
|
|
58
|
+
}
|
|
59
|
+
/** `r` in the callbacks of `.next(...)`. */
|
|
60
|
+
export interface NextContext<I, R> extends Reach, NodeValues<I, R> {
|
|
61
|
+
}
|
|
62
|
+
/** `r` in `.catch`: the error and the input, but no result. */
|
|
63
|
+
export interface CatchContext<I> extends Reach {
|
|
64
|
+
readonly error: Placeholder<ErrorValue>;
|
|
65
|
+
readonly input: Placeholder<I>;
|
|
66
|
+
}
|
|
67
|
+
export type NextTarget = Target | EachTarget | PartialTarget;
|
|
68
|
+
/** A target, or a callback receiving `r` that returns one. */
|
|
69
|
+
export type TargetArg<C, T> = T | ((r: C) => T);
|
|
70
|
+
/** One route of `.next({ routes })`: taken when `when` matches (or always, with no `when`). */
|
|
71
|
+
export interface NextRoute<C> {
|
|
72
|
+
when?: (r: C) => Condition;
|
|
73
|
+
to: TargetArg<C, NextTarget>;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The routes of `.next(...)`. In `"first"` mode (the default) the first
|
|
77
|
+
* matching route is taken; in `"all"` mode every matching route is taken,
|
|
78
|
+
* each as a lane.
|
|
79
|
+
*/
|
|
80
|
+
export interface NextOptions<C> {
|
|
81
|
+
match?: "first" | "all";
|
|
82
|
+
routes: readonly [NextRoute<C>, ...NextRoute<C>[]];
|
|
83
|
+
/** Taken when no route with a `when` matched. With nothing taken, the path ends there. */
|
|
84
|
+
otherwise?: TargetArg<C, NextTarget>;
|
|
85
|
+
}
|
|
86
|
+
export interface Routable<C, Out> {
|
|
87
|
+
/** Where to go next: one target, or routes with conditions. Ends the chain. */
|
|
88
|
+
next(target: TargetArg<C, NextTarget> | NextOptions<C>): Out;
|
|
89
|
+
}
|
|
90
|
+
/** `.partial(args)` on a step or wait handle: a merge target taking some of the node's args. */
|
|
91
|
+
export interface Mergeable<I> {
|
|
92
|
+
partial(args: Partial<CallArgs<I>>): PartialTarget;
|
|
93
|
+
}
|
|
94
|
+
/** The options of `each`. */
|
|
95
|
+
export interface EachOptions {
|
|
96
|
+
maxConcurrency?: number;
|
|
97
|
+
/** How many lanes may fail before the run (or enclosing lane) fails. Defaults to `{ count: 0 }`. */
|
|
98
|
+
toleratedFailures?: ToleratedFailures;
|
|
99
|
+
}
|
|
100
|
+
type ErrorList<E extends string> = readonly [E, ...E[]];
|
|
101
|
+
export interface StepSettings {
|
|
102
|
+
title?: string;
|
|
103
|
+
timeoutSeconds?: number;
|
|
104
|
+
heartbeatSeconds?: number;
|
|
105
|
+
maxRuns?: number;
|
|
106
|
+
maxTurns?: number;
|
|
107
|
+
}
|
|
108
|
+
export interface WaitSettings {
|
|
109
|
+
title?: string;
|
|
110
|
+
maxRuns?: number;
|
|
111
|
+
}
|
|
112
|
+
export interface RetryOptions<E extends string> {
|
|
113
|
+
on: ErrorList<BuiltInError | E>;
|
|
114
|
+
maxAttempts: number;
|
|
115
|
+
}
|
|
116
|
+
export interface StepAfterCatch<I, R, E extends string> extends Routable<NextContext<I, R>, FlowChain> {
|
|
117
|
+
catch(on: ErrorList<BuiltInError | E>, target: TargetArg<CatchContext<I>, Target>): StepAfterCatch<I, R, E>;
|
|
118
|
+
}
|
|
119
|
+
export interface StepAfterRetry<I, R, E extends string> extends StepAfterCatch<I, R, E> {
|
|
120
|
+
retry(options: RetryOptions<E>): StepAfterRetry<I, R, E>;
|
|
121
|
+
}
|
|
122
|
+
export interface StepChain<I, R, E extends string> extends StepAfterRetry<I, R, E> {
|
|
123
|
+
settings(settings: StepSettings): StepAfterRetry<I, R, E>;
|
|
124
|
+
}
|
|
125
|
+
/** A step in a pipeline: callable as a target, and the start of its chain. */
|
|
126
|
+
export type PipelineStep<I, R, E extends string = string> = Call<I> & Bare<I> & StepRef<I, R, E> & StepChain<I, R, E> & Mergeable<I> & {
|
|
127
|
+
/** The same step as a second node, with id `id`. */
|
|
128
|
+
as(id: string): PipelineStep<I, R, E>;
|
|
129
|
+
};
|
|
130
|
+
export interface WaitAfterCatch<I, R> extends Routable<NextContext<I, R>, FlowChain> {
|
|
131
|
+
catch(on: ErrorList<WaitError>, target: TargetArg<CatchContext<I>, Target>): WaitAfterCatch<I, R>;
|
|
132
|
+
}
|
|
133
|
+
export interface WaitChain<I, R> extends WaitAfterCatch<I, R> {
|
|
134
|
+
settings(settings: WaitSettings): WaitAfterCatch<I, R>;
|
|
135
|
+
}
|
|
136
|
+
/** A `decision` or `reply` wait node. */
|
|
137
|
+
export type WaitHandle<I, R> = Call<I> & Bare<I> & NodeHandle<I, R> & WaitChain<I, R> & Mergeable<I>;
|
|
138
|
+
/** A `succeed` or `fail` node: a target with no chain. */
|
|
139
|
+
export interface Terminal extends Target {
|
|
140
|
+
readonly [terminalBrand]: true;
|
|
141
|
+
}
|
|
142
|
+
/** The result of a `decision` wait: the chosen action's key, and the person's text or null. */
|
|
143
|
+
export interface DecisionResult<K extends string = string> {
|
|
144
|
+
action: K;
|
|
145
|
+
body: string | null;
|
|
146
|
+
}
|
|
147
|
+
export interface ReplyInput {
|
|
148
|
+
questions: string[];
|
|
149
|
+
}
|
|
150
|
+
export interface ReplyResult {
|
|
151
|
+
replied: boolean;
|
|
152
|
+
body: string | null;
|
|
153
|
+
commentId: string | null;
|
|
154
|
+
}
|
|
155
|
+
/** The result of a conversation step: a step with no result schema. */
|
|
156
|
+
export interface ConversationResult {
|
|
157
|
+
conversationId: string;
|
|
158
|
+
summary: string;
|
|
159
|
+
}
|
|
160
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared step discovery: which steps a loaded module defines, and which
|
|
3
|
+
* function implements a given code step.
|
|
4
|
+
*
|
|
5
|
+
* Used by `collect-definitions.ts` to decide what to push and by the worker's
|
|
6
|
+
* code-step runner to decide what to run, so a step is runnable exactly when
|
|
7
|
+
* the collector could find it. Discovery works from the shape of a module's
|
|
8
|
+
* exports, never from shared module instances.
|
|
9
|
+
*
|
|
10
|
+
* Takes type-only imports so it carries no runtime dependency on the rest of
|
|
11
|
+
* the SDK and can be imported on its own (`@scarn/sdk/code-step-lookup`).
|
|
12
|
+
*/
|
|
13
|
+
import type { StepDefinitionSpec } from "../definitions/steps";
|
|
14
|
+
type CodeStepFn = NonNullable<StepDefinitionSpec["entrypoint"]>["fn"];
|
|
15
|
+
/**
|
|
16
|
+
* A step spec, or a step handle: `defineStep` and `codeStep` return a function
|
|
17
|
+
* carrying the spec's fields.
|
|
18
|
+
*/
|
|
19
|
+
export declare function isStepDefinitionSpec(value: unknown): value is StepDefinitionSpec;
|
|
20
|
+
/**
|
|
21
|
+
* Every step spec a module defines: its named exports that are step specs.
|
|
22
|
+
* Deduped by reference, so a step exported under two names appears once.
|
|
23
|
+
*/
|
|
24
|
+
export declare function stepsInModule(mod: Readonly<Record<string, unknown>>): StepDefinitionSpec[];
|
|
25
|
+
/**
|
|
26
|
+
* The function implementing the code step `key` in `mod`, or `undefined` when
|
|
27
|
+
* the module defines no such step. Throws when more than one distinct function
|
|
28
|
+
* is registered under `key`; the same function reachable twice is not
|
|
29
|
+
* ambiguous.
|
|
30
|
+
*/
|
|
31
|
+
export declare function findCodeStepInModule(mod: Readonly<Record<string, unknown>>, key: string): CodeStepFn | undefined;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { type DefaultPipelineAssignmentSpec } from "../definitions/pipelines/define-default-pipeline-assignment";
|
|
2
|
+
import type { StepDefinitionSpec } from "../definitions/steps";
|
|
3
|
+
/**
|
|
4
|
+
* The fixed, repo-root-relative directory `scarn pipelines init` scaffolds
|
|
5
|
+
* and `scarn pipelines push`/`studio` always run from. `resolveCodeStepEntrypoint`
|
|
6
|
+
* uses this to record a `kind: "code"` step's `sourceFile` relative to the repo
|
|
7
|
+
* root (what the worker's `execute-code-step.ts` expects when it joins
|
|
8
|
+
* `sourceFile` onto the checked-out workspace root), regardless of what the
|
|
9
|
+
* collecting process's own `cwd` happens to be.
|
|
10
|
+
*
|
|
11
|
+
* Duplicated nowhere else — `@scarn/worker`'s own `PIPELINE_BUILDER_DIR`
|
|
12
|
+
* imports this one, so there's a single source of truth.
|
|
13
|
+
*/
|
|
14
|
+
export declare const PIPELINE_BUILDER_DIR = ".scarn/pipeline-builder";
|
|
15
|
+
export type CollectedDefinitions = {
|
|
16
|
+
/** Deduped by `key@vN`. */
|
|
17
|
+
readonly steps: readonly StepDefinitionSpec[];
|
|
18
|
+
/** Present only when `default-pipeline-assignment.ts` exists in the directory. */
|
|
19
|
+
readonly defaultPipelineAssignment: DefaultPipelineAssignmentSpec | null;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* One source file that failed to import —
|
|
23
|
+
* `collectDefinitionsFromDirectoryTolerant`'s per-file counterpart to a
|
|
24
|
+
* `collectDefinitionsFromDirectory` throw. `key` is the file's own basename
|
|
25
|
+
* (no extension).
|
|
26
|
+
*/
|
|
27
|
+
export type BrokenPipeline = {
|
|
28
|
+
readonly key: string;
|
|
29
|
+
readonly message: string;
|
|
30
|
+
};
|
|
31
|
+
export type TolerantCollectedDefinitions = CollectedDefinitions & {
|
|
32
|
+
readonly brokenPipelines: readonly BrokenPipeline[];
|
|
33
|
+
};
|
|
34
|
+
/** `.ts`/`.js` files in `dir` that declare definitions — excludes internal scripts and `default-pipeline-assignment.ts`. */
|
|
35
|
+
export declare function listSourceFiles(absDir: string): string[];
|
|
36
|
+
/**
|
|
37
|
+
* Imports every `.ts`/`.js` file in `dir` (except the push script itself and
|
|
38
|
+
* `default-pipeline-assignment.ts`) and collects the step definitions they
|
|
39
|
+
* export. The assignment file, when present, is imported and
|
|
40
|
+
* validated too but returned separately — syncing it needs the server.
|
|
41
|
+
*
|
|
42
|
+
* Designed to run on the user's native runtime (bun, node-with-tsx, deno), NOT
|
|
43
|
+
* inside a `bun --compile`'d binary — that runtime can't resolve scoped package
|
|
44
|
+
* `exports` field remappings from external user files. `scarn pipelines
|
|
45
|
+
* studio` works around this for its own compiled binary by never calling this
|
|
46
|
+
* function in-process: `collectDefinitionsViaSubprocess` (in
|
|
47
|
+
* `packages/worker/src/pipelines/pipeline-studio/infra/collect-definitions-via-subprocess.ts`)
|
|
48
|
+
* spawns a real bun/tsx/deno subprocess that calls this exact function from
|
|
49
|
+
* outside the compiled binary. Calling it directly, in-process, from inside a
|
|
50
|
+
* compiled binary is still unsupported.
|
|
51
|
+
*
|
|
52
|
+
* Throws on the first bad file — a syntax error, a step-definition error, a
|
|
53
|
+
* conflicting `codeStep` key — aborting the
|
|
54
|
+
* whole collection. That's the right behavior for `scarn pipelines push`
|
|
55
|
+
* (this function's only real caller besides its own tests): pushing a
|
|
56
|
+
* partially-collected directory would be worse than refusing to push at all.
|
|
57
|
+
* `scarn pipelines studio` wants the opposite trade-off — see
|
|
58
|
+
* `collectDefinitionsFromDirectoryTolerant` below.
|
|
59
|
+
*/
|
|
60
|
+
export declare function collectDefinitionsFromDirectory(dir: string): Promise<CollectedDefinitions>;
|
|
61
|
+
/**
|
|
62
|
+
* `collectDefinitionsFromDirectory`'s tolerant sibling, built for `scarn
|
|
63
|
+
* pipelines studio`: one file failing to import (a syntax error, a
|
|
64
|
+
* step-definition error, a conflicting `codeStep` key, ...) is recorded as a
|
|
65
|
+
* `BrokenPipeline` entry instead of aborting collection — every *other*
|
|
66
|
+
* file's steps still come back usable, so one bad edit in the builder
|
|
67
|
+
* directory doesn't blank the whole designer (see
|
|
68
|
+
* `compute-studio-snapshot.ts`).
|
|
69
|
+
*/
|
|
70
|
+
export declare function collectDefinitionsFromDirectoryTolerant(dir: string): Promise<TolerantCollectedDefinitions>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type PipelineDocumentFile = {
|
|
2
|
+
/** The file name, relative to the builder directory. */
|
|
3
|
+
readonly file: string;
|
|
4
|
+
readonly key: string;
|
|
5
|
+
readonly title: string | undefined;
|
|
6
|
+
/** The parsed document, sent to the server as-is. */
|
|
7
|
+
readonly document: Record<string, unknown>;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Every `.json` file in `dir` that holds a pipeline document (an object with
|
|
11
|
+
* `nodes`), sorted by file name. Other JSON is skipped. Throws on a file that
|
|
12
|
+
* isn't valid JSON, a document without a `key`, or two files with one `key`.
|
|
13
|
+
*/
|
|
14
|
+
export declare function collectPipelineDocuments(dir: string): PipelineDocumentFile[];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { PIPELINE_BUILDER_DIR, collectDefinitionsFromDirectory, collectDefinitionsFromDirectoryTolerant, } from "./collect-definitions";
|
|
2
|
+
export type { BrokenPipeline, CollectedDefinitions, TolerantCollectedDefinitions, } from "./collect-definitions";
|
|
3
|
+
export { collectPipelineDocuments } from "./collect-pipeline-documents";
|
|
4
|
+
export type { PipelineDocumentFile } from "./collect-pipeline-documents";
|
|
5
|
+
export { pushFromDirectory } from "./push-from-directory";
|
|
6
|
+
export type { PushFromDirectoryOptions, PushFromDirectoryResult, } from "./push-from-directory";
|