@scarn/sdk 0.8.1 → 0.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/dist/automations/define-automation.d.ts +20 -0
  2. package/dist/automations/index.d.ts +8 -0
  3. package/dist/automations/index.js +21 -0
  4. package/dist/automations/targets.d.ts +36 -0
  5. package/dist/automations/types.d.ts +116 -0
  6. package/dist/{chunk-dp86pa6m.js → chunk-01nfqm18.js} +5 -1
  7. package/dist/chunk-0vzq22dj.js +73 -0
  8. package/dist/chunk-11hbmexe.js +250 -0
  9. package/dist/{chunk-700xe701.js → chunk-3gy0cb5f.js} +5 -1
  10. package/dist/{chunk-102vfpw4.js → chunk-43y7tfn4.js} +33 -414
  11. package/dist/chunk-61jf8b6s.js +53 -0
  12. package/dist/chunk-76d1bwwz.js +119 -0
  13. package/dist/chunk-8z1wa3kd.js +109 -0
  14. package/dist/{chunk-p7yrcmqm.js → chunk-cnxaagfj.js} +2 -52
  15. package/dist/{chunk-cdanncng.js → chunk-ejzfdm1z.js} +21 -5
  16. package/dist/{chunk-gds7w7zh.js → chunk-fgfhvsee.js} +1 -4
  17. package/dist/{chunk-3ctaaseb.js → chunk-fyfvp6jx.js} +48 -21
  18. package/dist/{chunk-mz53r914.js → chunk-jj9pezwb.js} +22 -119
  19. package/dist/{chunk-vfeytkqx.js → chunk-wnfj3wyx.js} +106 -33
  20. package/dist/chunk-x0hjhqrf.js +416 -0
  21. package/dist/chunk-y11p1q7r.js +159 -0
  22. package/dist/client.js +6 -4
  23. package/dist/contracts/automation-document/index.d.ts +5 -0
  24. package/dist/contracts/automation-document/index.js +34 -0
  25. package/dist/contracts/automation-document/schema.d.ts +363 -0
  26. package/dist/contracts/pipeline-document/built-ins.d.ts +1 -1
  27. package/dist/contracts/pipeline-document/index.js +9 -7
  28. package/dist/contracts/pipeline-document/schema.d.ts +3 -3
  29. package/dist/contracts/work-item-changes.d.ts +51 -0
  30. package/dist/contracts/work-item-changes.js +68 -0
  31. package/dist/defaults/index.js +2 -2
  32. package/dist/definitions/automations/automations-client.d.ts +178 -0
  33. package/dist/definitions/automations/index.d.ts +1 -0
  34. package/dist/definitions/automations/index.js +12 -0
  35. package/dist/definitions/pipelines/index.d.ts +0 -1
  36. package/dist/definitions/pipelines/index.js +4 -12
  37. package/dist/definitions/pipelines/work-item-fields.d.ts +11 -22
  38. package/dist/definitions/steps/define-code-step.d.ts +3 -1
  39. package/dist/definitions/steps/define-step.d.ts +29 -1
  40. package/dist/definitions/steps/index.js +12 -7
  41. package/dist/definitions/steps/repo.d.ts +11 -3
  42. package/dist/definitions/steps/runtime.d.ts +11 -12
  43. package/dist/definitions/steps/step-definitions-client.d.ts +18 -0
  44. package/dist/definitions/steps/step-features.d.ts +2 -2
  45. package/dist/definitions/steps/step-handle.d.ts +8 -1
  46. package/dist/definitions/validation/index.js +2 -2
  47. package/dist/generated/index.d.ts +2 -2
  48. package/dist/generated/sdk.gen.d.ts +66 -11
  49. package/dist/generated/types.gen.d.ts +5513 -3488
  50. package/dist/index.d.ts +1 -0
  51. package/dist/index.js +61 -49
  52. package/dist/pipelines/define-pipeline.d.ts +7 -7
  53. package/dist/pipelines/handles.d.ts +0 -5
  54. package/dist/pipelines/index.js +7 -4
  55. package/dist/pipelines/types.d.ts +13 -1
  56. package/dist/push/collect-definitions.d.ts +3 -8
  57. package/dist/push/collect-pipeline-documents.d.ts +13 -3
  58. package/dist/push/index.d.ts +2 -2
  59. package/dist/push/index.js +90 -127
  60. package/dist/push/push-from-directory.d.ts +10 -6
  61. package/dist/repo-config.d.ts +14 -4
  62. package/dist/repo-config.js +5 -1
  63. package/dist/task-plane-client.d.ts +42 -0
  64. package/package.json +17 -1
  65. package/dist/chunk-zm72ksz0.js +0 -256
  66. package/dist/definitions/pipelines/define-default-pipeline-assignment.d.ts +0 -263
package/dist/index.d.ts CHANGED
@@ -5,6 +5,7 @@ export * from "./contracts/artifact-markers";
5
5
  export * from "./definitions/steps";
6
6
  export * from "./definitions/pipelines";
7
7
  export * from "./pipelines";
8
+ export * from "./automations";
8
9
  export type { PipelineDefinition } from "./pipelines";
9
10
  export * from "./opencode-mcp";
10
11
  export * from "./jsonc";
package/dist/index.js CHANGED
@@ -3,6 +3,13 @@ import {
3
3
  SCARN_CONFIG_RELATIVE_PATH,
4
4
  parseScarnConfig
5
5
  } from "./chunk-0y2fy5en.js";
6
+ import {
7
+ PipelineDefinitionsApiError,
8
+ WORK_ITEM_FIELDS_PATH_PREFIX,
9
+ WORK_ITEM_TOP_LEVEL_FIELDS,
10
+ createPipelineDefinitionsClient,
11
+ resolveWorkItemFieldPath
12
+ } from "./chunk-8z1wa3kd.js";
6
13
  import {
7
14
  after,
8
15
  all,
@@ -38,7 +45,15 @@ import {
38
45
  sum,
39
46
  workItem,
40
47
  workItemField
41
- } from "./chunk-102vfpw4.js";
48
+ } from "./chunk-43y7tfn4.js";
49
+ import {
50
+ attach,
51
+ defineAutomation,
52
+ onEvent,
53
+ skip
54
+ } from "./chunk-11hbmexe.js";
55
+ import"./chunk-x0hjhqrf.js";
56
+ import"./chunk-76d1bwwz.js";
42
57
  import {
43
58
  parseJsonc,
44
59
  stripJsoncComments,
@@ -47,8 +62,9 @@ import {
47
62
  import {
48
63
  createScarnClient,
49
64
  createTaskPlaneClient
50
- } from "./chunk-700xe701.js";
51
- import"./chunk-p7yrcmqm.js";
65
+ } from "./chunk-3gy0cb5f.js";
66
+ import"./chunk-61jf8b6s.js";
67
+ import"./chunk-cnxaagfj.js";
52
68
  import {
53
69
  ARTIFACT_BRAND,
54
70
  Artifact,
@@ -63,7 +79,9 @@ import {
63
79
  compileEnvironment,
64
80
  compileMcps,
65
81
  compileRepo,
82
+ compileStepConcurrency,
66
83
  compileStepErrors,
84
+ compileStepMaxTurns,
67
85
  compileStepRetry,
68
86
  createPromptInputProxy,
69
87
  createPromptTemplateContext,
@@ -79,15 +97,7 @@ import {
79
97
  resolveMcpChecks,
80
98
  toStepHandle,
81
99
  toStepSpec
82
- } from "./chunk-3ctaaseb.js";
83
- import {
84
- PipelineBuildError,
85
- formatIssue
86
- } from "./chunk-mz53r914.js";
87
- import"./chunk-5zsavw98.js";
88
- import"./chunk-4ggr8af6.js";
89
- import"./chunk-k4y5qt4y.js";
90
- import"./chunk-cdanncng.js";
100
+ } from "./chunk-fyfvp6jx.js";
91
101
  import {
92
102
  collectEnvPlaceholderNames,
93
103
  isEnvPlaceholderValue,
@@ -103,42 +113,22 @@ import {
103
113
  openCodeResolvedMcpServersSchema
104
114
  } from "./chunk-e1h021kq.js";
105
115
  import"./chunk-63f90zky.js";
116
+ import"./chunk-jj9pezwb.js";
106
117
  import {
107
- ARTIFACT_MARKER_SCHEME,
108
- buildArtifactMarker,
109
- findArtifactMarkers,
110
- formatArtifactMarkerRef,
111
- parseArtifactMarkerRef
112
- } from "./chunk-ngy1fdcx.js";
113
- import {
114
- ARTIFACT_SCHEMA_KEYWORD,
115
- EMBEDDABLE_ARTIFACT_EXTENSIONS,
116
- artifactAcceptsFile,
117
- artifactFileExtension,
118
- artifactKindSchema,
119
- artifactPlatforms,
120
- findArtifactFields,
121
- isEmbeddableArtifactExtension,
122
- matchArtifactNode,
123
- readArtifactKeyword
124
- } from "./chunk-y2pv8d6a.js";
125
- import"./chunk-dp86pa6m.js";
126
- import {
127
- DEFAULT_PIPELINE_ASSIGNMENT_FILENAME,
128
- PipelineDefinitionsApiError,
129
- WORK_ITEM_FIELDS_PATH_PREFIX,
130
- WORK_ITEM_TOP_LEVEL_FIELDS,
131
- createPipelineDefinitionsClient,
132
- defaultPipelineAssignment,
133
- isDefaultPipelineAssignmentSpec,
134
- resolveWorkItemFieldPath,
135
- serializeDefaultPipelineAssignment
136
- } from "./chunk-zm72ksz0.js";
118
+ PipelineBuildError,
119
+ formatIssue
120
+ } from "./chunk-y11p1q7r.js";
121
+ import"./chunk-5zsavw98.js";
122
+ import"./chunk-4ggr8af6.js";
123
+ import"./chunk-k4y5qt4y.js";
124
+ import"./chunk-ejzfdm1z.js";
137
125
  import {
138
126
  Api,
127
+ Automations,
139
128
  Billing,
140
129
  Conversations,
141
130
  GitHubIntegrations,
131
+ Inbox,
142
132
  NotificationRules,
143
133
  PipelineDefinitions,
144
134
  PipelineExecutions,
@@ -148,7 +138,6 @@ import {
148
138
  Projects,
149
139
  ScarnClient,
150
140
  Secrets,
151
- StepDefinitionTemplates,
152
141
  StepDefinitions,
153
142
  TaskRuns,
154
143
  Tasks,
@@ -158,7 +147,27 @@ import {
158
147
  WorkItemCommentDrafts,
159
148
  WorkItemComments,
160
149
  WorkItems
161
- } from "./chunk-vfeytkqx.js";
150
+ } from "./chunk-wnfj3wyx.js";
151
+ import {
152
+ ARTIFACT_MARKER_SCHEME,
153
+ buildArtifactMarker,
154
+ findArtifactMarkers,
155
+ formatArtifactMarkerRef,
156
+ parseArtifactMarkerRef
157
+ } from "./chunk-ngy1fdcx.js";
158
+ import {
159
+ ARTIFACT_SCHEMA_KEYWORD,
160
+ EMBEDDABLE_ARTIFACT_EXTENSIONS,
161
+ artifactAcceptsFile,
162
+ artifactFileExtension,
163
+ artifactKindSchema,
164
+ artifactPlatforms,
165
+ findArtifactFields,
166
+ isEmbeddableArtifactExtension,
167
+ matchArtifactNode,
168
+ readArtifactKeyword
169
+ } from "./chunk-y2pv8d6a.js";
170
+ import"./chunk-01nfqm18.js";
162
171
  import"./chunk-skzxcba3.js";
163
172
  import"./chunk-y64skrwp.js";
164
173
  export {
@@ -168,13 +177,14 @@ export {
168
177
  Api,
169
178
  Artifact,
170
179
  ArtifactTypes,
180
+ Automations,
171
181
  Billing,
172
182
  Conversations,
173
- DEFAULT_PIPELINE_ASSIGNMENT_FILENAME,
174
183
  EMBEDDABLE_ARTIFACT_EXTENSIONS,
175
184
  Env,
176
185
  Features,
177
186
  GitHubIntegrations,
187
+ Inbox,
178
188
  NotificationRules,
179
189
  Notify,
180
190
  PipelineBuildError,
@@ -190,7 +200,6 @@ export {
190
200
  SCARN_CONFIG_RELATIVE_PATH,
191
201
  ScarnClient,
192
202
  Secrets,
193
- StepDefinitionTemplates,
194
203
  StepDefinitions,
195
204
  TaskRuns,
196
205
  Tasks,
@@ -210,6 +219,7 @@ export {
210
219
  artifactFileExtension,
211
220
  artifactKindSchema,
212
221
  artifactPlatforms,
222
+ attach,
213
223
  avg,
214
224
  before,
215
225
  buildArtifactMarker,
@@ -218,7 +228,9 @@ export {
218
228
  compileEnvironment,
219
229
  compileMcps,
220
230
  compileRepo,
231
+ compileStepConcurrency,
221
232
  compileStepErrors,
233
+ compileStepMaxTurns,
222
234
  compileStepRetry,
223
235
  contains,
224
236
  count,
@@ -229,7 +241,7 @@ export {
229
241
  createStepDefinitionsClient,
230
242
  createTaskPlaneClient,
231
243
  decision,
232
- defaultPipelineAssignment,
244
+ defineAutomation,
233
245
  defineMcp,
234
246
  definePipeline,
235
247
  defineStep,
@@ -245,7 +257,6 @@ export {
245
257
  formatIssue,
246
258
  greaterThan,
247
259
  greaterThanInclusive,
248
- isDefaultPipelineAssignmentSpec,
249
260
  isEmbeddableArtifactExtension,
250
261
  isEmpty,
251
262
  isEnvPlaceholderValue,
@@ -262,6 +273,7 @@ export {
262
273
  normalizeEnv,
263
274
  not,
264
275
  notEqual,
276
+ onEvent,
265
277
  openCodeMcpLocalConfigSchema,
266
278
  openCodeMcpOAuthConfigSchema,
267
279
  openCodeMcpProtocolSchema,
@@ -280,7 +292,7 @@ export {
280
292
  reply,
281
293
  resolveMcpChecks,
282
294
  resolveWorkItemFieldPath,
283
- serializeDefaultPipelineAssignment,
295
+ skip,
284
296
  some,
285
297
  startsWith,
286
298
  stepRef,
@@ -1,10 +1,5 @@
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
- */
1
+ import type { AutomationTarget, EventWorkItem } from "../automations/types";
2
+ import type { AutomationScope, AutomationSubject } from "../contracts/automation-document";
8
3
  import type { PipelineDocument, StepCatalog } from "../contracts/pipeline-document";
9
4
  import { type BuildIssue } from "./errors";
10
5
  import { type SourceSite } from "./source";
@@ -27,6 +22,11 @@ export interface PipelineDefinition {
27
22
  readonly steps: StepCatalog;
28
23
  /** Problems that don't stop the build, such as chains left out of `flow`. */
29
24
  readonly warnings: readonly BuildIssue[];
25
+ /**
26
+ * In an automation rule: a run of this pipeline for `workItem`
27
+ * (`r.workItem` or `r.child`). The bare pipeline runs for `r.workItem`.
28
+ */
29
+ on(workItem: EventWorkItem<AutomationSubject>): AutomationTarget<AutomationScope>;
30
30
  }
31
31
  /** Compiles a pipeline to its JSON document. Throws `PipelineBuildError`. */
32
32
  export declare function definePipeline(config: PipelineConfig): PipelineDefinition;
@@ -1,8 +1,3 @@
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
1
  import type { JsonSchema } from "../contracts/pipeline-document";
7
2
  import type { NodeDef, RawArgs } from "./model";
8
3
  /** What `toPipelineStep` needs from a step definition. */
@@ -34,13 +34,16 @@ import {
34
34
  sum,
35
35
  workItem,
36
36
  workItemField
37
- } from "../chunk-102vfpw4.js";
38
- import"../chunk-p7yrcmqm.js";
37
+ } from "../chunk-43y7tfn4.js";
38
+ import"../chunk-x0hjhqrf.js";
39
+ import"../chunk-61jf8b6s.js";
40
+ import"../chunk-cnxaagfj.js";
41
+ import"../chunk-jj9pezwb.js";
39
42
  import {
40
43
  PipelineBuildError,
41
44
  formatIssue
42
- } from "../chunk-mz53r914.js";
43
- import"../chunk-dp86pa6m.js";
45
+ } from "../chunk-y11p1q7r.js";
46
+ import"../chunk-01nfqm18.js";
44
47
  import"../chunk-skzxcba3.js";
45
48
  import"../chunk-y64skrwp.js";
46
49
  export {
@@ -4,6 +4,8 @@
4
4
  * `docs/plans/pipeline-ts-sdk.md`), so an unfinished or misordered chain is
5
5
  * a type error rather than a build error.
6
6
  */
7
+ import type { AutomationTarget, EventWorkItem } from "../automations/types";
8
+ import type { AutomationScope, AutomationSubject } from "../contracts/automation-document";
7
9
  import type { BUILT_IN_ERRORS, ToleratedFailures, WAIT_ERRORS } from "../contracts/pipeline-document";
8
10
  import type { StepRef } from "../definitions/steps/step-ref";
9
11
  import type { Condition } from "./condition-data";
@@ -39,6 +41,16 @@ type NoKeys = Record<never, never>;
39
41
  export type CallArgs<I> = unknown extends I ? Readonly<Record<string, Ref<unknown> | JsonLiteral>> : Args<I>;
40
42
  /** Calling a handle: args are optional only when the input has no required keys. */
41
43
  export type Call<I> = NoKeys extends I ? (args?: CallArgs<I>) => Target : (args: CallArgs<I>) => Target;
44
+ /**
45
+ * A step called with its args. In a pipeline it's a target; in an
46
+ * automation rule, `.on(r.workItem | r.child)` picks the work item its Task
47
+ * is for.
48
+ */
49
+ export interface StepTarget extends Target {
50
+ on(workItem: EventWorkItem<AutomationSubject>): AutomationTarget<AutomationScope>;
51
+ }
52
+ /** Calling a step handle: like `Call`, but the target also has `.on(...)`. */
53
+ export type StepCall<I> = NoKeys extends I ? (args?: CallArgs<I>) => StepTarget : (args: CallArgs<I>) => StepTarget;
42
54
  /** A bare handle is a target only when its input has no required keys. */
43
55
  export interface Bare<I> {
44
56
  readonly [targetBrand]: NoKeys extends I ? true : false;
@@ -123,7 +135,7 @@ export interface StepChain<I, R, E extends string> extends StepAfterRetry<I, R,
123
135
  settings(settings: StepSettings): StepAfterRetry<I, R, E>;
124
136
  }
125
137
  /** 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> & {
138
+ export type PipelineStep<I, R, E extends string = string> = StepCall<I> & Bare<I> & StepRef<I, R, E> & StepChain<I, R, E> & Mergeable<I> & {
127
139
  /** The same step as a second node, with id `id`. */
128
140
  as(id: string): PipelineStep<I, R, E>;
129
141
  };
@@ -1,4 +1,3 @@
1
- import { type DefaultPipelineAssignmentSpec } from "../definitions/pipelines/define-default-pipeline-assignment";
2
1
  import type { StepDefinitionSpec } from "../definitions/steps";
3
2
  /**
4
3
  * The fixed, repo-root-relative directory `scarn pipelines init` scaffolds
@@ -15,8 +14,6 @@ export declare const PIPELINE_BUILDER_DIR = ".scarn/pipeline-builder";
15
14
  export type CollectedDefinitions = {
16
15
  /** Deduped by `key@vN`. */
17
16
  readonly steps: readonly StepDefinitionSpec[];
18
- /** Present only when `default-pipeline-assignment.ts` exists in the directory. */
19
- readonly defaultPipelineAssignment: DefaultPipelineAssignmentSpec | null;
20
17
  };
21
18
  /**
22
19
  * One source file that failed to import —
@@ -31,13 +28,11 @@ export type BrokenPipeline = {
31
28
  export type TolerantCollectedDefinitions = CollectedDefinitions & {
32
29
  readonly brokenPipelines: readonly BrokenPipeline[];
33
30
  };
34
- /** `.ts`/`.js` files in `dir` that declare definitions — excludes internal scripts and `default-pipeline-assignment.ts`. */
31
+ /** `.ts`/`.js` files in `dir` that declare definitions — excludes internal scripts. */
35
32
  export declare function listSourceFiles(absDir: string): string[];
36
33
  /**
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.
34
+ * Imports every `.ts`/`.js` file in `dir` (except the push script itself) and
35
+ * collects the step definitions they export.
41
36
  *
42
37
  * Designed to run on the user's native runtime (bun, node-with-tsx, deno), NOT
43
38
  * inside a `bun --compile`'d binary — that runtime can't resolve scoped package
@@ -1,3 +1,4 @@
1
+ export type BuiltDocumentKind = "pipeline" | "automation";
1
2
  export type PipelineDocumentFile = {
2
3
  /** The file name, relative to the builder directory. */
3
4
  readonly file: string;
@@ -6,9 +7,18 @@ export type PipelineDocumentFile = {
6
7
  /** The parsed document, sent to the server as-is. */
7
8
  readonly document: Record<string, unknown>;
8
9
  };
10
+ export type BuiltDocumentFile = PipelineDocumentFile & {
11
+ readonly kind: BuiltDocumentKind;
12
+ };
9
13
  /**
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`.
14
+ * Every `.json` file in `dir` that holds a pipeline or automation document,
15
+ * sorted by file name. Other JSON is skipped. Throws on a file that isn't
16
+ * valid JSON, a document without a `key`, or two files with one `key`:
17
+ * pipelines and automations share one key space, like their `<key>.json`
18
+ * file names.
13
19
  */
20
+ export declare function collectBuiltDocuments(dir: string): BuiltDocumentFile[];
21
+ /** The pipeline documents in `dir` (see `collectBuiltDocuments`). */
14
22
  export declare function collectPipelineDocuments(dir: string): PipelineDocumentFile[];
23
+ /** The automation documents in `dir` (see `collectBuiltDocuments`). */
24
+ export declare function collectAutomationDocuments(dir: string): PipelineDocumentFile[];
@@ -1,6 +1,6 @@
1
1
  export { PIPELINE_BUILDER_DIR, collectDefinitionsFromDirectory, collectDefinitionsFromDirectoryTolerant, } from "./collect-definitions";
2
2
  export type { BrokenPipeline, CollectedDefinitions, TolerantCollectedDefinitions, } from "./collect-definitions";
3
- export { collectPipelineDocuments } from "./collect-pipeline-documents";
4
- export type { PipelineDocumentFile } from "./collect-pipeline-documents";
3
+ export { collectAutomationDocuments, collectBuiltDocuments, collectPipelineDocuments, } from "./collect-pipeline-documents";
4
+ export type { BuiltDocumentFile, BuiltDocumentKind, PipelineDocumentFile, } from "./collect-pipeline-documents";
5
5
  export { pushFromDirectory } from "./push-from-directory";
6
6
  export type { PushFromDirectoryOptions, PushFromDirectoryResult, } from "./push-from-directory";