@scarn/sdk 0.0.0-stage → 0.0.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 (151) hide show
  1. package/dist/chunk-4361gxk0.js +166 -0
  2. package/dist/chunk-4vehh3dq.js +333 -0
  3. package/dist/chunk-56e4kp0a.js +162 -0
  4. package/dist/chunk-5mmj03ah.js +1074 -0
  5. package/dist/chunk-631ffb6r.js +57 -0
  6. package/dist/chunk-91p9vzcs.js +1453 -0
  7. package/dist/chunk-9s07v9r1.js +30 -0
  8. package/dist/chunk-b21233rt.js +78 -0
  9. package/dist/chunk-dnn39qt4.js +13539 -0
  10. package/dist/chunk-eg1hcvhb.js +300 -0
  11. package/dist/chunk-g0rdnn0r.js +95 -0
  12. package/dist/chunk-h9yxx0hd.js +116 -0
  13. package/dist/chunk-njd6npf0.js +35 -0
  14. package/dist/chunk-ny07ncb9.js +330 -0
  15. package/dist/chunk-p6kc9wq8.js +97 -0
  16. package/dist/chunk-qpw5wt1p.js +257 -0
  17. package/dist/chunk-rq3q8vg7.js +1094 -0
  18. package/dist/chunk-s0gap8r8.js +14 -0
  19. package/dist/chunk-tfm5hjzm.js +100 -0
  20. package/dist/chunk-ynk2bjae.js +1686 -0
  21. package/dist/chunk-zpqyjgb4.js +49 -0
  22. package/dist/client.d.ts +4 -0
  23. package/dist/client.js +57 -0
  24. package/dist/contracts/artifact-markers.d.ts +42 -0
  25. package/dist/contracts/artifact-markers.js +15 -0
  26. package/dist/contracts/artifacts.d.ts +67 -0
  27. package/dist/contracts/artifacts.js +25 -0
  28. package/dist/contracts/pipeline-document/built-ins.d.ts +23 -0
  29. package/dist/contracts/pipeline-document/conditions/operators.d.ts +8 -0
  30. package/dist/contracts/pipeline-document/index.d.ts +11 -0
  31. package/dist/contracts/pipeline-document/index.js +97 -0
  32. package/dist/contracts/pipeline-document/json.d.ts +35 -0
  33. package/dist/contracts/pipeline-document/routes.d.ts +16 -0
  34. package/dist/contracts/pipeline-document/schema.d.ts +780 -0
  35. package/dist/contracts/pipeline-document/step-contract.d.ts +11 -0
  36. package/dist/contracts/step-artifact-submissions.d.ts +71 -0
  37. package/dist/contracts/step-artifact-submissions.js +174 -0
  38. package/dist/defaults/atomic-json-file.d.ts +10 -0
  39. package/dist/defaults/auth-file.d.ts +14 -0
  40. package/dist/defaults/base-url.d.ts +1 -0
  41. package/dist/defaults/config-file.d.ts +46 -0
  42. package/dist/defaults/home-dir.d.ts +3 -0
  43. package/dist/defaults/index.d.ts +12 -0
  44. package/dist/defaults/index.js +1239 -0
  45. package/dist/defaults/legacy-config-migration.d.ts +27 -0
  46. package/dist/defaults/load-push-defaults.d.ts +25 -0
  47. package/dist/defaults/project-config.d.ts +32 -0
  48. package/dist/defaults/project-ref.d.ts +34 -0
  49. package/dist/definitions/artifacts/artifact.d.ts +62 -0
  50. package/dist/definitions/artifacts/index.d.ts +1 -0
  51. package/dist/definitions/pipelines/define-default-pipeline-assignment.d.ts +263 -0
  52. package/dist/definitions/pipelines/index.d.ts +3 -0
  53. package/dist/definitions/pipelines/index.js +24 -0
  54. package/dist/definitions/pipelines/pipeline-definitions-client.d.ts +208 -0
  55. package/dist/definitions/pipelines/work-item-fields.d.ts +93 -0
  56. package/dist/definitions/steps/compile-mcps.d.ts +34 -0
  57. package/dist/definitions/steps/define-code-step.d.ts +84 -0
  58. package/dist/definitions/steps/define-mcp.d.ts +79 -0
  59. package/dist/definitions/steps/define-step.d.ts +137 -0
  60. package/dist/definitions/steps/env.d.ts +136 -0
  61. package/dist/definitions/steps/index.d.ts +14 -0
  62. package/dist/definitions/steps/index.js +73 -0
  63. package/dist/definitions/steps/mcp-server-config.d.ts +102 -0
  64. package/dist/definitions/steps/prompt-template.d.ts +24 -0
  65. package/dist/definitions/steps/repo.d.ts +67 -0
  66. package/dist/definitions/steps/runtime.d.ts +115 -0
  67. package/dist/definitions/steps/step-definitions-client.d.ts +400 -0
  68. package/dist/definitions/steps/step-features.d.ts +109 -0
  69. package/dist/definitions/steps/step-handle.d.ts +25 -0
  70. package/dist/definitions/steps/step-ref.d.ts +19 -0
  71. package/dist/definitions/validation/index.d.ts +2 -0
  72. package/dist/definitions/validation/index.js +17 -0
  73. package/dist/definitions/validation/validate-artifact-markers.d.ts +3 -0
  74. package/dist/definitions/validation/validate-artifacts.d.ts +7 -0
  75. package/dist/definitions/validation/validate-definition-specs.d.ts +16 -0
  76. package/dist/definitions/validation/validate-env.d.ts +15 -0
  77. package/dist/definitions/validation/validate-repo.d.ts +13 -0
  78. package/dist/definitions/validation/validate-runtime.d.ts +12 -0
  79. package/dist/definitions/validation/validation-issue.d.ts +11 -0
  80. package/dist/devcontainer-config-path.d.ts +21 -0
  81. package/dist/devcontainer-config-path.js +13 -0
  82. package/dist/env-vars.d.ts +136 -0
  83. package/dist/env-vars.js +35 -0
  84. package/dist/eslint.d.ts +42 -0
  85. package/dist/eslint.js +125 -0
  86. package/dist/generated/client/client.gen.d.ts +2 -0
  87. package/dist/generated/client/index.d.ts +8 -0
  88. package/dist/generated/client/types.gen.d.ts +117 -0
  89. package/dist/generated/client/utils.gen.d.ts +33 -0
  90. package/dist/generated/client.gen.d.ts +12 -0
  91. package/dist/generated/core/auth.gen.d.ts +18 -0
  92. package/dist/generated/core/bodySerializer.gen.d.ts +25 -0
  93. package/dist/generated/core/params.gen.d.ts +43 -0
  94. package/dist/generated/core/pathSerializer.gen.d.ts +33 -0
  95. package/dist/generated/core/queryKeySerializer.gen.d.ts +18 -0
  96. package/dist/generated/core/serverSentEvents.gen.d.ts +71 -0
  97. package/dist/generated/core/types.gen.d.ts +78 -0
  98. package/dist/generated/core/utils.gen.d.ts +19 -0
  99. package/dist/generated/index.d.ts +2 -0
  100. package/dist/generated/sdk.gen.d.ts +302 -0
  101. package/dist/generated/types.gen.d.ts +18368 -0
  102. package/dist/git-url/git-remote.d.ts +30 -0
  103. package/dist/git-url/git-repo-identity.d.ts +44 -0
  104. package/dist/git-url/git-repo-identity.js +159 -0
  105. package/dist/git-url/parse-git-host.d.ts +23 -0
  106. package/dist/health-checks.d.ts +169 -0
  107. package/dist/health-checks.js +19 -0
  108. package/dist/index.d.ts +11 -0
  109. package/dist/index.js +293 -0
  110. package/dist/jsonc.d.ts +3 -0
  111. package/dist/jsonc.js +11 -0
  112. package/dist/managed-runtimes.d.ts +20 -0
  113. package/dist/managed-runtimes.js +13 -0
  114. package/dist/opencode-mcp.d.ts +313 -0
  115. package/dist/opencode-mcp.js +29 -0
  116. package/dist/pipelines/chain.d.ts +7 -0
  117. package/dist/pipelines/compile-args.d.ts +12 -0
  118. package/dist/pipelines/compile-chain.d.ts +9 -0
  119. package/dist/pipelines/compile-checks.d.ts +16 -0
  120. package/dist/pipelines/compile-state.d.ts +30 -0
  121. package/dist/pipelines/condition-data.d.ts +78 -0
  122. package/dist/pipelines/conditions.d.ts +47 -0
  123. package/dist/pipelines/context.d.ts +16 -0
  124. package/dist/pipelines/define-pipeline.d.ts +32 -0
  125. package/dist/pipelines/each.d.ts +5 -0
  126. package/dist/pipelines/errors.d.ts +26 -0
  127. package/dist/pipelines/handles.d.ts +29 -0
  128. package/dist/pipelines/index.d.ts +18 -0
  129. package/dist/pipelines/index.js +80 -0
  130. package/dist/pipelines/model.d.ts +103 -0
  131. package/dist/pipelines/nodes.d.ts +54 -0
  132. package/dist/pipelines/ref-types.d.ts +54 -0
  133. package/dist/pipelines/refs.d.ts +80 -0
  134. package/dist/pipelines/registry.d.ts +12 -0
  135. package/dist/pipelines/source.d.ts +17 -0
  136. package/dist/pipelines/types.d.ts +160 -0
  137. package/dist/push/code-step-lookup.d.ts +32 -0
  138. package/dist/push/code-step-lookup.js +11 -0
  139. package/dist/push/collect-definitions.d.ts +70 -0
  140. package/dist/push/collect-pipeline-documents.d.ts +14 -0
  141. package/dist/push/index.d.ts +6 -0
  142. package/dist/push/index.js +328 -0
  143. package/dist/push/push-from-directory.d.ts +37 -0
  144. package/dist/repo-config.d.ts +80 -0
  145. package/dist/repo-config.js +23 -0
  146. package/dist/scarn-config-parser.d.ts +29 -0
  147. package/dist/scarn-config-parser.js +9 -0
  148. package/dist/task-plane-client.d.ts +489 -0
  149. package/dist/z.d.ts +7 -0
  150. package/package.json +132 -4
  151. package/README.md +0 -3
@@ -0,0 +1,1453 @@
1
+ // @bun
2
+ import {
3
+ ARTIFACT_SCHEMA_KEYWORD2
4
+ } from "./chunk-56e4kp0a.js";
5
+ import {
6
+ buildArtifactMarker2
7
+ } from "./chunk-631ffb6r.js";
8
+ import {
9
+ toolHealthCheckSchema2,
10
+ stepHealthChecksInputSchema2
11
+ } from "./chunk-zpqyjgb4.js";
12
+ import {
13
+ devcontainerConfigPathSchema2
14
+ } from "./chunk-9s07v9r1.js";
15
+ import {
16
+ MANAGED_RUNTIME_IDS2,
17
+ DEFAULT_CODE_STEP_RUNTIME_ID2
18
+ } from "./chunk-s0gap8r8.js";
19
+ import {
20
+ ENV_VAR_NAME_PATTERN2,
21
+ containsInputToken2,
22
+ isReservedEnvVarName2
23
+ } from "./chunk-p6kc9wq8.js";
24
+ import {
25
+ repoConfigInputSchema2,
26
+ repoRuntimeMismatch2
27
+ } from "./chunk-b21233rt.js";
28
+ import {
29
+ openCodeMcpLocalConfigSchema2,
30
+ openCodeMcpRemoteConfigSchema2,
31
+ openCodeMcpRefConfigSchema2,
32
+ isEnvPlaceholderValue2,
33
+ collectEnvPlaceholderNames2
34
+ } from "./chunk-g0rdnn0r.js";
35
+ import {
36
+ makeHandle,
37
+ stepNode,
38
+ stepCall
39
+ } from "./chunk-eg1hcvhb.js";
40
+ import {
41
+ createClient,
42
+ StepDefinitions2
43
+ } from "./chunk-ynk2bjae.js";
44
+ import {
45
+ ZodIssueCode,
46
+ setErrorMap,
47
+ getErrorMap,
48
+ ZodFirstPartyTypeKind,
49
+ fromJSONSchema,
50
+ exports_coerce,
51
+ exports_external,
52
+ BUILT_IN_ERRORS2
53
+ } from "./chunk-5mmj03ah.js";
54
+ import {
55
+ __export,
56
+ NEVER,
57
+ $brand,
58
+ config,
59
+ clone,
60
+ exports_util,
61
+ flattenError,
62
+ formatError,
63
+ treeifyError,
64
+ prettifyError,
65
+ exports_regexes,
66
+ exports_locales,
67
+ $output,
68
+ $input,
69
+ registry,
70
+ globalRegistry,
71
+ TimePrecision,
72
+ _lt,
73
+ _lte,
74
+ _gt,
75
+ _gte,
76
+ _positive,
77
+ _negative,
78
+ _nonpositive,
79
+ _nonnegative,
80
+ _multipleOf,
81
+ _maxSize,
82
+ _minSize,
83
+ _size,
84
+ _maxLength,
85
+ _minLength,
86
+ _length,
87
+ _regex,
88
+ _lowercase,
89
+ _uppercase,
90
+ _includes,
91
+ _startsWith,
92
+ _endsWith,
93
+ _property,
94
+ _mime,
95
+ _overwrite,
96
+ _normalize,
97
+ _trim,
98
+ _toLowerCase,
99
+ _toUpperCase,
100
+ _slugify,
101
+ toJSONSchema,
102
+ exports_core,
103
+ ZodISODateTime,
104
+ ZodISODate,
105
+ ZodISOTime,
106
+ ZodISODuration,
107
+ exports_iso,
108
+ ZodError,
109
+ ZodRealError,
110
+ parse,
111
+ parseAsync,
112
+ safeParse,
113
+ safeParseAsync,
114
+ encode,
115
+ decode,
116
+ encodeAsync,
117
+ decodeAsync,
118
+ safeEncode,
119
+ safeDecode,
120
+ safeEncodeAsync,
121
+ safeDecodeAsync,
122
+ ZodType,
123
+ _ZodString,
124
+ ZodString,
125
+ string,
126
+ ZodStringFormat,
127
+ ZodEmail,
128
+ email,
129
+ ZodGUID,
130
+ guid,
131
+ ZodUUID,
132
+ uuid,
133
+ uuidv4,
134
+ uuidv6,
135
+ uuidv7,
136
+ ZodURL,
137
+ url,
138
+ httpUrl,
139
+ ZodEmoji,
140
+ emoji,
141
+ ZodNanoID,
142
+ nanoid,
143
+ ZodCUID,
144
+ cuid,
145
+ ZodCUID2,
146
+ cuid2,
147
+ ZodULID,
148
+ ulid,
149
+ ZodXID,
150
+ xid,
151
+ ZodKSUID,
152
+ ksuid,
153
+ ZodIPv4,
154
+ ipv4,
155
+ ZodMAC,
156
+ mac,
157
+ ZodIPv6,
158
+ ipv6,
159
+ ZodCIDRv4,
160
+ cidrv4,
161
+ ZodCIDRv6,
162
+ cidrv6,
163
+ ZodBase64,
164
+ base64,
165
+ ZodBase64URL,
166
+ base64url,
167
+ ZodE164,
168
+ e164,
169
+ ZodJWT,
170
+ jwt,
171
+ ZodCustomStringFormat,
172
+ stringFormat,
173
+ hostname,
174
+ hex,
175
+ hash,
176
+ ZodNumber,
177
+ number,
178
+ ZodNumberFormat,
179
+ int,
180
+ float32,
181
+ float64,
182
+ int32,
183
+ uint32,
184
+ ZodBoolean,
185
+ boolean,
186
+ ZodBigInt,
187
+ bigint,
188
+ ZodBigIntFormat,
189
+ int64,
190
+ uint64,
191
+ ZodSymbol,
192
+ symbol,
193
+ ZodUndefined,
194
+ _undefined,
195
+ ZodNull,
196
+ _null,
197
+ ZodAny,
198
+ any3,
199
+ ZodUnknown,
200
+ unknown,
201
+ ZodNever,
202
+ never,
203
+ ZodVoid,
204
+ _void,
205
+ ZodDate,
206
+ date,
207
+ ZodArray,
208
+ array,
209
+ keyof,
210
+ ZodObject,
211
+ object,
212
+ strictObject,
213
+ looseObject,
214
+ ZodUnion,
215
+ union,
216
+ ZodXor,
217
+ xor,
218
+ ZodDiscriminatedUnion,
219
+ discriminatedUnion,
220
+ ZodIntersection,
221
+ intersection,
222
+ ZodTuple,
223
+ tuple,
224
+ ZodRecord,
225
+ record,
226
+ partialRecord,
227
+ looseRecord,
228
+ ZodMap,
229
+ map,
230
+ ZodSet,
231
+ set,
232
+ ZodEnum,
233
+ _enum,
234
+ nativeEnum,
235
+ ZodLiteral,
236
+ literal,
237
+ ZodFile,
238
+ file,
239
+ ZodTransform,
240
+ transform,
241
+ ZodOptional,
242
+ optional,
243
+ ZodExactOptional,
244
+ exactOptional,
245
+ ZodNullable,
246
+ nullable,
247
+ nullish,
248
+ ZodDefault,
249
+ _default,
250
+ ZodPrefault,
251
+ prefault,
252
+ ZodNonOptional,
253
+ nonoptional,
254
+ ZodSuccess,
255
+ success,
256
+ ZodCatch,
257
+ _catch,
258
+ ZodNaN,
259
+ nan,
260
+ ZodPipe,
261
+ pipe,
262
+ ZodCodec,
263
+ codec,
264
+ invertCodec,
265
+ ZodPreprocess,
266
+ ZodReadonly,
267
+ readonly,
268
+ ZodTemplateLiteral,
269
+ templateLiteral,
270
+ ZodLazy,
271
+ lazy,
272
+ ZodPromise,
273
+ promise,
274
+ ZodFunction,
275
+ _function,
276
+ ZodCustom,
277
+ check,
278
+ custom,
279
+ refine,
280
+ superRefine,
281
+ describe,
282
+ meta,
283
+ _instanceof,
284
+ stringbool,
285
+ json,
286
+ preprocess
287
+ } from "./chunk-dnn39qt4.js";
288
+
289
+ // src/z.ts
290
+ var exports_z = {};
291
+ __export(exports_z, {
292
+ $brand: () => $brand,
293
+ $input: () => $input,
294
+ $output: () => $output,
295
+ NEVER: () => NEVER,
296
+ TimePrecision: () => TimePrecision,
297
+ ZodAny: () => ZodAny,
298
+ ZodArray: () => ZodArray,
299
+ ZodBase64: () => ZodBase64,
300
+ ZodBase64URL: () => ZodBase64URL,
301
+ ZodBigInt: () => ZodBigInt,
302
+ ZodBigIntFormat: () => ZodBigIntFormat,
303
+ ZodBoolean: () => ZodBoolean,
304
+ ZodCIDRv4: () => ZodCIDRv4,
305
+ ZodCIDRv6: () => ZodCIDRv6,
306
+ ZodCUID: () => ZodCUID,
307
+ ZodCUID2: () => ZodCUID2,
308
+ ZodCatch: () => ZodCatch,
309
+ ZodCodec: () => ZodCodec,
310
+ ZodCustom: () => ZodCustom,
311
+ ZodCustomStringFormat: () => ZodCustomStringFormat,
312
+ ZodDate: () => ZodDate,
313
+ ZodDefault: () => ZodDefault,
314
+ ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
315
+ ZodE164: () => ZodE164,
316
+ ZodEmail: () => ZodEmail,
317
+ ZodEmoji: () => ZodEmoji,
318
+ ZodEnum: () => ZodEnum,
319
+ ZodError: () => ZodError,
320
+ ZodExactOptional: () => ZodExactOptional,
321
+ ZodFile: () => ZodFile,
322
+ ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind,
323
+ ZodFunction: () => ZodFunction,
324
+ ZodGUID: () => ZodGUID,
325
+ ZodIPv4: () => ZodIPv4,
326
+ ZodIPv6: () => ZodIPv6,
327
+ ZodISODate: () => ZodISODate,
328
+ ZodISODateTime: () => ZodISODateTime,
329
+ ZodISODuration: () => ZodISODuration,
330
+ ZodISOTime: () => ZodISOTime,
331
+ ZodIntersection: () => ZodIntersection,
332
+ ZodIssueCode: () => ZodIssueCode,
333
+ ZodJWT: () => ZodJWT,
334
+ ZodKSUID: () => ZodKSUID,
335
+ ZodLazy: () => ZodLazy,
336
+ ZodLiteral: () => ZodLiteral,
337
+ ZodMAC: () => ZodMAC,
338
+ ZodMap: () => ZodMap,
339
+ ZodNaN: () => ZodNaN,
340
+ ZodNanoID: () => ZodNanoID,
341
+ ZodNever: () => ZodNever,
342
+ ZodNonOptional: () => ZodNonOptional,
343
+ ZodNull: () => ZodNull,
344
+ ZodNullable: () => ZodNullable,
345
+ ZodNumber: () => ZodNumber,
346
+ ZodNumberFormat: () => ZodNumberFormat,
347
+ ZodObject: () => ZodObject,
348
+ ZodOptional: () => ZodOptional,
349
+ ZodPipe: () => ZodPipe,
350
+ ZodPrefault: () => ZodPrefault,
351
+ ZodPreprocess: () => ZodPreprocess,
352
+ ZodPromise: () => ZodPromise,
353
+ ZodReadonly: () => ZodReadonly,
354
+ ZodRealError: () => ZodRealError,
355
+ ZodRecord: () => ZodRecord,
356
+ ZodSet: () => ZodSet,
357
+ ZodString: () => ZodString,
358
+ ZodStringFormat: () => ZodStringFormat,
359
+ ZodSuccess: () => ZodSuccess,
360
+ ZodSymbol: () => ZodSymbol,
361
+ ZodTemplateLiteral: () => ZodTemplateLiteral,
362
+ ZodTransform: () => ZodTransform,
363
+ ZodTuple: () => ZodTuple,
364
+ ZodType: () => ZodType,
365
+ ZodULID: () => ZodULID,
366
+ ZodURL: () => ZodURL,
367
+ ZodUUID: () => ZodUUID,
368
+ ZodUndefined: () => ZodUndefined,
369
+ ZodUnion: () => ZodUnion,
370
+ ZodUnknown: () => ZodUnknown,
371
+ ZodVoid: () => ZodVoid,
372
+ ZodXID: () => ZodXID,
373
+ ZodXor: () => ZodXor,
374
+ _ZodString: () => _ZodString,
375
+ _default: () => _default,
376
+ _function: () => _function,
377
+ any: () => any3,
378
+ array: () => array,
379
+ artifact: () => artifact2,
380
+ base64: () => base64,
381
+ base64url: () => base64url,
382
+ bigint: () => bigint,
383
+ boolean: () => boolean,
384
+ catch: () => _catch,
385
+ check: () => check,
386
+ cidrv4: () => cidrv4,
387
+ cidrv6: () => cidrv6,
388
+ clone: () => clone,
389
+ codec: () => codec,
390
+ coerce: () => exports_coerce,
391
+ config: () => config,
392
+ core: () => exports_core,
393
+ cuid: () => cuid,
394
+ cuid2: () => cuid2,
395
+ custom: () => custom,
396
+ date: () => date,
397
+ decode: () => decode,
398
+ decodeAsync: () => decodeAsync,
399
+ describe: () => describe,
400
+ discriminatedUnion: () => discriminatedUnion,
401
+ e164: () => e164,
402
+ email: () => email,
403
+ emoji: () => emoji,
404
+ encode: () => encode,
405
+ encodeAsync: () => encodeAsync,
406
+ endsWith: () => _endsWith,
407
+ enum: () => _enum,
408
+ exactOptional: () => exactOptional,
409
+ file: () => file,
410
+ flattenError: () => flattenError,
411
+ float32: () => float32,
412
+ float64: () => float64,
413
+ formatError: () => formatError,
414
+ fromJSONSchema: () => fromJSONSchema,
415
+ function: () => _function,
416
+ getErrorMap: () => getErrorMap,
417
+ globalRegistry: () => globalRegistry,
418
+ gt: () => _gt,
419
+ gte: () => _gte,
420
+ guid: () => guid,
421
+ hash: () => hash,
422
+ hex: () => hex,
423
+ hostname: () => hostname,
424
+ httpUrl: () => httpUrl,
425
+ includes: () => _includes,
426
+ instanceof: () => _instanceof,
427
+ int: () => int,
428
+ int32: () => int32,
429
+ int64: () => int64,
430
+ intersection: () => intersection,
431
+ invertCodec: () => invertCodec,
432
+ ipv4: () => ipv4,
433
+ ipv6: () => ipv6,
434
+ iso: () => exports_iso,
435
+ json: () => json,
436
+ jwt: () => jwt,
437
+ keyof: () => keyof,
438
+ ksuid: () => ksuid,
439
+ lazy: () => lazy,
440
+ length: () => _length,
441
+ literal: () => literal,
442
+ locales: () => exports_locales,
443
+ looseObject: () => looseObject,
444
+ looseRecord: () => looseRecord,
445
+ lowercase: () => _lowercase,
446
+ lt: () => _lt,
447
+ lte: () => _lte,
448
+ mac: () => mac,
449
+ map: () => map,
450
+ maxLength: () => _maxLength,
451
+ maxSize: () => _maxSize,
452
+ meta: () => meta,
453
+ mime: () => _mime,
454
+ minLength: () => _minLength,
455
+ minSize: () => _minSize,
456
+ multipleOf: () => _multipleOf,
457
+ nan: () => nan,
458
+ nanoid: () => nanoid,
459
+ nativeEnum: () => nativeEnum,
460
+ negative: () => _negative,
461
+ never: () => never,
462
+ nonnegative: () => _nonnegative,
463
+ nonoptional: () => nonoptional,
464
+ nonpositive: () => _nonpositive,
465
+ normalize: () => _normalize,
466
+ null: () => _null,
467
+ nullable: () => nullable,
468
+ nullish: () => nullish,
469
+ number: () => number,
470
+ object: () => object,
471
+ optional: () => optional,
472
+ overwrite: () => _overwrite,
473
+ parse: () => parse,
474
+ parseAsync: () => parseAsync,
475
+ partialRecord: () => partialRecord,
476
+ pipe: () => pipe,
477
+ positive: () => _positive,
478
+ prefault: () => prefault,
479
+ preprocess: () => preprocess,
480
+ prettifyError: () => prettifyError,
481
+ promise: () => promise,
482
+ property: () => _property,
483
+ readonly: () => readonly,
484
+ record: () => record,
485
+ refine: () => refine,
486
+ regex: () => _regex,
487
+ regexes: () => exports_regexes,
488
+ registry: () => registry,
489
+ safeDecode: () => safeDecode,
490
+ safeDecodeAsync: () => safeDecodeAsync,
491
+ safeEncode: () => safeEncode,
492
+ safeEncodeAsync: () => safeEncodeAsync,
493
+ safeParse: () => safeParse,
494
+ safeParseAsync: () => safeParseAsync,
495
+ set: () => set,
496
+ setErrorMap: () => setErrorMap,
497
+ size: () => _size,
498
+ slugify: () => _slugify,
499
+ startsWith: () => _startsWith,
500
+ strictObject: () => strictObject,
501
+ string: () => string,
502
+ stringFormat: () => stringFormat,
503
+ stringbool: () => stringbool,
504
+ success: () => success,
505
+ superRefine: () => superRefine,
506
+ symbol: () => symbol,
507
+ templateLiteral: () => templateLiteral,
508
+ toJSONSchema: () => toJSONSchema,
509
+ toLowerCase: () => _toLowerCase,
510
+ toUpperCase: () => _toUpperCase,
511
+ transform: () => transform,
512
+ treeifyError: () => treeifyError,
513
+ trim: () => _trim,
514
+ tuple: () => tuple,
515
+ uint32: () => uint32,
516
+ uint64: () => uint64,
517
+ ulid: () => ulid,
518
+ undefined: () => _undefined,
519
+ union: () => union,
520
+ unknown: () => unknown,
521
+ uppercase: () => _uppercase,
522
+ url: () => url,
523
+ util: () => exports_util,
524
+ uuid: () => uuid,
525
+ uuidv4: () => uuidv4,
526
+ uuidv6: () => uuidv6,
527
+ uuidv7: () => uuidv7,
528
+ void: () => _void,
529
+ xid: () => xid,
530
+ xor: () => xor,
531
+ z: () => exports_external
532
+ });
533
+ // src/definitions/artifacts/artifact.ts
534
+ var ARTIFACT_BRAND2 = "ScarnArtifact";
535
+ var ArtifactTypes2 = {
536
+ video: [".mp4", ".webm", ".mov"],
537
+ image: [".png", ".jpg", ".jpeg", ".gif", ".svg"]
538
+ };
539
+ var EXTENSION_PATTERN = /^\.[a-z0-9][a-z0-9_-]*(\.[a-z0-9][a-z0-9_-]*)*$/;
540
+ function describeEntry(entry) {
541
+ const cleaned = entry.trim().toLowerCase().replace(/^\*?\.?/, "");
542
+ return cleaned && EXTENSION_PATTERN.test(`.${cleaned}`) ? ` Did you mean \`.${cleaned}\`?` : "";
543
+ }
544
+ function normalizeArtifactAccept2(accept) {
545
+ if (accept === undefined)
546
+ return [];
547
+ const problems = [];
548
+ const out = [];
549
+ for (const entry of accept) {
550
+ if (typeof entry !== "string") {
551
+ problems.push(`${JSON.stringify(entry)} is not a string.`);
552
+ continue;
553
+ }
554
+ if (!entry.startsWith(".")) {
555
+ problems.push(`"${entry}" must be a file extension starting with a dot.${describeEntry(entry)}`);
556
+ continue;
557
+ }
558
+ if (entry !== entry.toLowerCase()) {
559
+ problems.push(`"${entry}" must be lower-case.${describeEntry(entry)}`);
560
+ continue;
561
+ }
562
+ if (!EXTENSION_PATTERN.test(entry)) {
563
+ problems.push(`"${entry}" is not a valid file extension.`);
564
+ continue;
565
+ }
566
+ if (!out.includes(entry))
567
+ out.push(entry);
568
+ }
569
+ if (problems.length > 0) {
570
+ throw new Error(`artifact({ accept }): ${problems.join(" ")}`);
571
+ }
572
+ return out;
573
+ }
574
+ function artifact2(options = {}) {
575
+ const keyword = {
576
+ accept: normalizeArtifactAccept2(options.accept)
577
+ };
578
+ return string().brand().meta({ [ARTIFACT_SCHEMA_KEYWORD2]: keyword });
579
+ }
580
+ var toMarkerRef = (target) => typeof target === "string" ? { type: "path", pattern: target } : {
581
+ type: "signal",
582
+ stepKey: target.step.key,
583
+ signalKey: target.path
584
+ };
585
+ var Artifact2 = {
586
+ path(relativePath) {
587
+ return relativePath;
588
+ },
589
+ embed(target, options) {
590
+ return buildArtifactMarker2("embed", toMarkerRef(target), options.caption);
591
+ },
592
+ link(target, options) {
593
+ return buildArtifactMarker2("link", toMarkerRef(target), options.label);
594
+ }
595
+ };
596
+ // src/definitions/steps/prompt-template.ts
597
+ function createPromptInputProxy2(path = []) {
598
+ const token = () => path.length ? `{{${path.join(".")}}}` : "";
599
+ return new Proxy(Object.freeze({}), {
600
+ get(_, key) {
601
+ if (key === Symbol.toPrimitive || key === "valueOf") {
602
+ return (_hint) => token();
603
+ }
604
+ if (key === "toString") {
605
+ return () => token();
606
+ }
607
+ if (typeof key !== "string")
608
+ return;
609
+ return createPromptInputProxy2([...path, key]);
610
+ }
611
+ });
612
+ }
613
+ function createPromptTemplateContext2() {
614
+ return {
615
+ input: createPromptInputProxy2(["input"]),
616
+ env: createPromptInputProxy2(["env"]),
617
+ scarn: {
618
+ artifactsDir: createPromptInputProxy2([
619
+ "scarn",
620
+ "artifactsDir"
621
+ ])
622
+ }
623
+ };
624
+ }
625
+ function renderPromptTemplate2(template, contextJson) {
626
+ return template.replace(/\{\{([^}]+)\}\}/g, (_, path) => {
627
+ const value = path.split(".").reduce((curr, key) => curr != null ? curr[key] : undefined, contextJson);
628
+ return value != null ? String(value) : "";
629
+ });
630
+ }
631
+
632
+ // src/definitions/steps/env.ts
633
+ var SECRET_LOOKING_NAME = /SECRET|TOKEN|PASSWORD|PASSWD|API_?KEY|PRIVATE/i;
634
+ function isSecretLookingEnvName2(name) {
635
+ return SECRET_LOOKING_NAME.test(name);
636
+ }
637
+ var helperEntries = new WeakSet;
638
+ function brand(entry) {
639
+ helperEntries.add(entry);
640
+ return entry;
641
+ }
642
+ var Env2 = {
643
+ value(opts) {
644
+ return brand({
645
+ kind: "value",
646
+ value: opts.value,
647
+ secret: opts.secret ?? false,
648
+ unsafeAllowStatic: opts.unsafeAllowStatic ?? false,
649
+ applies: opts.applies ?? "agent"
650
+ });
651
+ },
652
+ inherit(opts) {
653
+ return brand({
654
+ kind: "inherit",
655
+ from: opts?.from,
656
+ secret: opts?.secret ?? false,
657
+ optional: opts?.optional ?? false,
658
+ default: opts?.default,
659
+ applies: opts?.applies ?? "agent"
660
+ });
661
+ }
662
+ };
663
+ function isHelperEntry(entry) {
664
+ return typeof entry === "object" && helperEntries.has(entry);
665
+ }
666
+ function assertNotStaticSecret(name, value, flags) {
667
+ if (containsInputToken2(value))
668
+ return;
669
+ if (flags.secret) {
670
+ throw new Error(`Env "${name}": a secret must interpolate an input token; a static secret would be stored in plaintext. Use Env.inherit({ secret: true }) to read it from the worker.`);
671
+ }
672
+ if (isSecretLookingEnvName2(name) && !flags.unsafeAllowStatic) {
673
+ throw new Error(`Env "${name}": a static value on a secret-looking name would be stored in plaintext. Use Env.inherit({ secret: true }) to read it from the worker, or Env.value({ value, unsafeAllowStatic: true }) if it is not actually secret.`);
674
+ }
675
+ }
676
+ function appliesField(applies) {
677
+ return applies === "agent" ? {} : { applies };
678
+ }
679
+ function toEnvVarSpec(name, entry) {
680
+ if (!isHelperEntry(entry)) {
681
+ const value = `${entry}`;
682
+ assertNotStaticSecret(name, value, {
683
+ secret: false,
684
+ unsafeAllowStatic: false
685
+ });
686
+ return { name, source: "value", value, secret: false };
687
+ }
688
+ if (entry.kind === "value") {
689
+ assertNotStaticSecret(name, entry.value, entry);
690
+ return {
691
+ name,
692
+ source: "value",
693
+ value: entry.value,
694
+ secret: entry.secret,
695
+ ...appliesField(entry.applies)
696
+ };
697
+ }
698
+ return {
699
+ name,
700
+ source: "inherit",
701
+ from: entry.from ?? name,
702
+ secret: entry.secret,
703
+ optional: entry.optional,
704
+ ...entry.default !== undefined ? { default: entry.default } : {},
705
+ ...appliesField(entry.applies)
706
+ };
707
+ }
708
+ function normalizeEnv2(fn) {
709
+ if (!fn)
710
+ return null;
711
+ const record = fn({ input: createPromptInputProxy2(["input"]) });
712
+ const specs = Object.entries(record).map(([name, entry]) => toEnvVarSpec(name, entry));
713
+ return specs.length > 0 ? specs : null;
714
+ }
715
+
716
+ // src/definitions/steps/repo.ts
717
+ var Repo2 = {
718
+ none() {
719
+ return { mode: "none" };
720
+ },
721
+ readOnly() {
722
+ return { mode: "readOnly" };
723
+ },
724
+ readWrite(opts) {
725
+ return { mode: "readWrite", ...opts };
726
+ }
727
+ };
728
+ function executionModeOf(runtime) {
729
+ return runtime?.kind === "host" ? "no_workspace" : "workspace";
730
+ }
731
+ function compileRepo2(repo, runtime, ctx = {}) {
732
+ if (repo === undefined)
733
+ return;
734
+ const spec = typeof repo === "function" ? repo({
735
+ input: createPromptInputProxy2(["input"]),
736
+ result: createPromptInputProxy2(["result"])
737
+ }) : repo;
738
+ const where = ctx.stepKey ? `Step "${ctx.stepKey}" repo` : "repo";
739
+ const executionMode = executionModeOf(runtime);
740
+ const mismatch = repoRuntimeMismatch2(executionMode, spec.mode);
741
+ if (mismatch !== null) {
742
+ throw new Error(`${where} "${spec.mode}" cannot be used with executionMode "${executionMode}": ${mismatch}.`);
743
+ }
744
+ const config = spec.mode === "readWrite" ? toReadWriteConfig(spec) : { mode: spec.mode };
745
+ const parsed = repoConfigInputSchema2.safeParse(config);
746
+ if (!parsed.success) {
747
+ throw new Error(`${where}: ${parsed.error.issues.map((issue) => `${issue.path.join(".") || "mode"} ${issue.message}`).join("; ")}`);
748
+ }
749
+ return config;
750
+ }
751
+ function toReadWriteConfig(spec) {
752
+ return {
753
+ mode: "readWrite",
754
+ ...spec.message !== undefined ? {
755
+ message: `${spec.message}`
756
+ } : {},
757
+ ...spec.onPushFailure !== undefined ? { onPushFailure: spec.onPushFailure } : {}
758
+ };
759
+ }
760
+
761
+ // src/definitions/steps/runtime.ts
762
+ var managedRuntimeFactories = Object.fromEntries(MANAGED_RUNTIME_IDS2.map((id) => [id, () => ({ kind: "managed", id })]));
763
+ var Runtime2 = {
764
+ managed: managedRuntimeFactories,
765
+ devcontainer(opts) {
766
+ if (opts?.config === undefined)
767
+ return { kind: "devcontainer" };
768
+ const parsed = devcontainerConfigPathSchema2.safeParse(opts.config);
769
+ if (!parsed.success) {
770
+ throw new Error(`Runtime.devcontainer config "${opts.config}": ${parsed.error.issues.map((issue) => issue.message).join("; ")}`);
771
+ }
772
+ return { kind: "devcontainer", config: parsed.data };
773
+ },
774
+ host() {
775
+ return { kind: "host" };
776
+ }
777
+ };
778
+ function assertNoSetupVarsOnHost(envJson, runtime, stepKey) {
779
+ if (runtime?.kind !== "host")
780
+ return;
781
+ const setupVar = (envJson ?? []).find((entry) => (entry.applies ?? "agent") !== "agent");
782
+ if (!setupVar)
783
+ return;
784
+ throw new Error(`${stepKey ? `Step "${stepKey}" ` : ""}env "${setupVar.name}": applies "${String(setupVar.applies)}" needs a container to set up, but Runtime.host() has none. Use applies "agent" or Runtime.devcontainer().`);
785
+ }
786
+ function compileEnvironment2(environment, ctx = {}) {
787
+ const runtime = environment?.runtime ?? ctx.defaultRuntime;
788
+ const envJson = normalizeEnv2(environment?.vars);
789
+ assertNoSetupVarsOnHost(envJson, runtime, ctx.stepKey);
790
+ return {
791
+ executionMode: runtime?.kind === "host" ? "no_workspace" : "workspace",
792
+ devcontainerConfigPath: runtime?.kind === "devcontainer" ? runtime.config ?? null : null,
793
+ managedRuntime: runtime?.kind === "managed" ? runtime.id : null,
794
+ envJson,
795
+ repo: compileRepo2(environment?.repo, runtime, ctx)
796
+ };
797
+ }
798
+
799
+ // src/definitions/steps/mcp-server-config.ts
800
+ var ownedFields = { type: true, disabled: true };
801
+ var refFieldsSchema = openCodeMcpRefConfigSchema2.omit({
802
+ ...ownedFields,
803
+ name: true
804
+ });
805
+ var localFieldsSchema = openCodeMcpLocalConfigSchema2.omit(ownedFields);
806
+ var remoteFieldsSchema = openCodeMcpRemoteConfigSchema2.omit(ownedFields);
807
+ var commonConfigKeys = new Set([
808
+ "type",
809
+ "name",
810
+ "env",
811
+ "optionalEnv",
812
+ "healthChecks"
813
+ ]);
814
+ function formatIssues(error) {
815
+ return error.issues.map((issue) => issue.path.length > 0 ? `${issue.path.map(String).join(".")}: ${issue.message}` : issue.message).join("; ");
816
+ }
817
+ function parseFields(name, schema, config) {
818
+ const fields = Object.fromEntries(Object.entries(config).filter(([key]) => !commonConfigKeys.has(key)));
819
+ const parsed = schema.safeParse(fields);
820
+ if (!parsed.success) {
821
+ throw new Error(`defineMcp "${name}": ${formatIssues(parsed.error)}`);
822
+ }
823
+ return parsed.data;
824
+ }
825
+ function assertPlaceholders(name, field, values) {
826
+ for (const [key, value] of Object.entries(values ?? {})) {
827
+ if (isEnvPlaceholderValue2(value))
828
+ continue;
829
+ throw new Error(`defineMcp "${name}": ${field}.${key} must be written as {env:VAR}; a literal ${field} value would be stored in plaintext.`);
830
+ }
831
+ }
832
+ function inferredMcpEnv(definition) {
833
+ return definition.type === "ref" ? [] : collectEnvPlaceholderNames2(definition.server);
834
+ }
835
+ function assertInferredEnv(definition) {
836
+ for (const variable of inferredMcpEnv(definition)) {
837
+ if (!ENV_VAR_NAME_PATTERN2.test(variable)) {
838
+ throw new Error(`defineMcp "${definition.name}": {env:${variable}} must name a variable matching ${String(ENV_VAR_NAME_PATTERN2)}.`);
839
+ }
840
+ if (isReservedEnvVarName2(variable)) {
841
+ throw new Error(`defineMcp "${definition.name}": {env:${variable}} reads a variable reserved for Scarn.`);
842
+ }
843
+ }
844
+ }
845
+ function parseMcpServer(config) {
846
+ if (typeof config.name !== "string" || config.name.trim().length === 0) {
847
+ throw new Error("defineMcp: name must be a non-empty string.");
848
+ }
849
+ const { name } = config;
850
+ let definition;
851
+ switch (config.type) {
852
+ case "ref":
853
+ definition = {
854
+ type: "ref",
855
+ name,
856
+ server: parseFields(name, refFieldsSchema, config)
857
+ };
858
+ break;
859
+ case "local": {
860
+ const server = parseFields(name, localFieldsSchema, config);
861
+ assertPlaceholders(name, "environment", server.environment);
862
+ definition = { type: "local", name, server };
863
+ break;
864
+ }
865
+ case "remote": {
866
+ const server = parseFields(name, remoteFieldsSchema, config);
867
+ assertPlaceholders(name, "headers", server.headers);
868
+ definition = { type: "remote", name, server };
869
+ break;
870
+ }
871
+ default:
872
+ throw new Error(`defineMcp "${name}": type must be "ref", "local" or "remote".`);
873
+ }
874
+ assertInferredEnv(definition);
875
+ return definition;
876
+ }
877
+
878
+ // src/definitions/steps/define-mcp.ts
879
+ var mcpCheckInputSchema = toolHealthCheckSchema2.omit({ kind: true, mcp: true, name: true }).extend({ enabled: boolean().optional() }).strict();
880
+ var mcpCheckPatchSchema = toolHealthCheckSchema2.pick({
881
+ tool: true,
882
+ args: true,
883
+ timeoutSeconds: true,
884
+ severity: true,
885
+ serialGroup: true
886
+ }).partial().strict();
887
+ var handles = new WeakSet;
888
+ function isMcpHandle2(value) {
889
+ return typeof value === "object" && value !== null && handles.has(value);
890
+ }
891
+ function deepFreeze(value) {
892
+ if (typeof value === "object" && value !== null && !Object.isFrozen(value)) {
893
+ Object.freeze(value);
894
+ for (const child of Object.values(value))
895
+ deepFreeze(child);
896
+ }
897
+ return value;
898
+ }
899
+ function frozenCopy(value) {
900
+ return deepFreeze(structuredClone(value));
901
+ }
902
+ function formatIssues2(error) {
903
+ return error.issues.map((issue) => issue.path.length > 0 ? `${issue.path.map(String).join(".")}: ${issue.message}` : issue.message).join("; ");
904
+ }
905
+ function assertCheckName(label, name) {
906
+ if (name.trim().length === 0 || name.includes(".")) {
907
+ throw new Error(`defineMcp "${label}": health check name "${name}" must be non-empty and contain no ".".`);
908
+ }
909
+ }
910
+ function assertCheckInput(label, name, check) {
911
+ assertCheckName(label, name);
912
+ const parsed = mcpCheckInputSchema.safeParse(check);
913
+ if (!parsed.success) {
914
+ throw new Error(`defineMcp "${label}" health check "${name}": ${formatIssues2(parsed.error)}`);
915
+ }
916
+ }
917
+ function assertEnvNames(label, env, optionalEnv) {
918
+ const seen = new Set;
919
+ for (const name of [...env, ...optionalEnv]) {
920
+ if (!ENV_VAR_NAME_PATTERN2.test(name)) {
921
+ throw new Error(`defineMcp "${label}": env var "${name}" must match ${String(ENV_VAR_NAME_PATTERN2)}.`);
922
+ }
923
+ if (isReservedEnvVarName2(name)) {
924
+ throw new Error(`defineMcp "${label}": env var "${name}" is reserved for Scarn.`);
925
+ }
926
+ if (seen.has(name)) {
927
+ throw new Error(`defineMcp "${label}": env var "${name}" is declared more than once.`);
928
+ }
929
+ seen.add(name);
930
+ }
931
+ }
932
+ function knownCheckNames(state) {
933
+ const names = new Set(Object.keys(state.checks));
934
+ for (const op of state.overrides) {
935
+ if (op.op === "add")
936
+ names.add(op.name);
937
+ }
938
+ return names;
939
+ }
940
+ function assertKnownCheck(state, method, name) {
941
+ const known = knownCheckNames(state);
942
+ if (known.has(name))
943
+ return;
944
+ throw new Error(`defineMcp "${state.name}".${method}: unknown health check "${name}". Known checks: ${known.size > 0 ? [...known].join(", ") : "(none)"}.`);
945
+ }
946
+ function withOp(state, op) {
947
+ return createHandle({
948
+ ...state,
949
+ overrides: Object.freeze([...state.overrides, deepFreeze(op)])
950
+ });
951
+ }
952
+ function createHandle(state) {
953
+ const handle = {
954
+ ...state,
955
+ overrideCheck: (name, patch) => {
956
+ assertKnownCheck(state, "overrideCheck", name);
957
+ const parsed = mcpCheckPatchSchema.safeParse(patch);
958
+ if (!parsed.success) {
959
+ throw new Error(`defineMcp "${state.name}".overrideCheck("${name}"): ${formatIssues2(parsed.error)}`);
960
+ }
961
+ return withOp(state, {
962
+ op: "override",
963
+ name,
964
+ patch: structuredClone(patch)
965
+ });
966
+ },
967
+ disableCheck: (name) => {
968
+ assertKnownCheck(state, "disableCheck", name);
969
+ return withOp(state, { op: "disable", name });
970
+ },
971
+ enableCheck: (name) => {
972
+ assertKnownCheck(state, "enableCheck", name);
973
+ return withOp(state, { op: "enable", name });
974
+ },
975
+ addCheck: (name, check) => {
976
+ assertCheckInput(state.name, name, check);
977
+ if (knownCheckNames(state).has(name)) {
978
+ throw new Error(`defineMcp "${state.name}".addCheck: health check "${name}" already exists; use overrideCheck to change it.`);
979
+ }
980
+ return withOp(state, { op: "add", name, check: structuredClone(check) });
981
+ },
982
+ disableAllChecks: () => withOp(state, { op: "disableAll" })
983
+ };
984
+ handles.add(handle);
985
+ return Object.freeze(handle);
986
+ }
987
+ function defineMcp2(config) {
988
+ const definition = parseMcpServer(config);
989
+ const env = config.env ?? [];
990
+ const optionalEnv = config.optionalEnv ?? [];
991
+ assertEnvNames(definition.name, env, optionalEnv);
992
+ const checks = config.healthChecks ?? {};
993
+ for (const [name, check] of Object.entries(checks)) {
994
+ assertCheckInput(definition.name, name, check);
995
+ }
996
+ return createHandle({
997
+ ...frozenCopy(definition),
998
+ env: frozenCopy([...env]),
999
+ optionalEnv: frozenCopy([...optionalEnv]),
1000
+ checks: frozenCopy({ ...checks }),
1001
+ overrides: Object.freeze([])
1002
+ });
1003
+ }
1004
+ function resolveMcpChecks2(handle) {
1005
+ const resolved = new Map;
1006
+ for (const [name, check] of Object.entries(handle.checks)) {
1007
+ resolved.set(name, { check: { ...check }, enabled: check.enabled ?? true });
1008
+ }
1009
+ for (const op of handle.overrides) {
1010
+ if (op.op === "add") {
1011
+ resolved.set(op.name, {
1012
+ check: { ...op.check },
1013
+ enabled: op.check.enabled ?? true
1014
+ });
1015
+ } else if (op.op === "disableAll") {
1016
+ for (const entry of resolved.values())
1017
+ entry.enabled = false;
1018
+ } else {
1019
+ const entry = resolved.get(op.name);
1020
+ if (!entry)
1021
+ continue;
1022
+ if (op.op === "override")
1023
+ entry.check = { ...entry.check, ...op.patch };
1024
+ else
1025
+ entry.enabled = op.op === "enable";
1026
+ }
1027
+ }
1028
+ return [...resolved].map(([name, { check, enabled }]) => ({
1029
+ name,
1030
+ check,
1031
+ enabled
1032
+ }));
1033
+ }
1034
+
1035
+ // src/definitions/steps/compile-mcps.ts
1036
+ function compileServer(key, handle) {
1037
+ switch (handle.type) {
1038
+ case "ref":
1039
+ return {
1040
+ type: "ref",
1041
+ ...handle.name !== key ? { name: handle.name } : {},
1042
+ ...structuredClone(handle.server)
1043
+ };
1044
+ case "local":
1045
+ return { type: "local", ...structuredClone(handle.server) };
1046
+ case "remote":
1047
+ return { type: "remote", ...structuredClone(handle.server) };
1048
+ }
1049
+ }
1050
+ function compileChecks(key, handle) {
1051
+ return resolveMcpChecks2(handle).filter((resolved) => resolved.enabled).map(({ name, check }) => ({
1052
+ kind: "tool",
1053
+ mcp: key,
1054
+ name: `${key}.${name}`,
1055
+ tool: check.tool,
1056
+ ...check.args !== undefined ? { args: check.args } : {},
1057
+ ...check.timeoutSeconds !== undefined ? { timeoutSeconds: check.timeoutSeconds } : {},
1058
+ serialGroup: check.serialGroup ?? key,
1059
+ severity: check.severity ?? "required"
1060
+ }));
1061
+ }
1062
+ function compileEnv(key, handle) {
1063
+ const entry = (name, optional) => ({
1064
+ source: "inherit",
1065
+ name,
1066
+ from: name,
1067
+ secret: true,
1068
+ optional,
1069
+ mcp: key,
1070
+ applies: "agent"
1071
+ });
1072
+ const listed = new Set([...handle.env, ...handle.optionalEnv]);
1073
+ const inferred = inferredMcpEnv(handle).filter((name) => !listed.has(name));
1074
+ return [
1075
+ ...handle.env.map((name) => entry(name, false)),
1076
+ ...inferred.map((name) => entry(name, false)),
1077
+ ...handle.optionalEnv.map((name) => entry(name, true))
1078
+ ];
1079
+ }
1080
+ function dedupeEnv(entries) {
1081
+ const byName = new Map;
1082
+ for (const entry of entries) {
1083
+ const existing = byName.get(entry.name);
1084
+ if (!existing) {
1085
+ byName.set(entry.name, entry);
1086
+ continue;
1087
+ }
1088
+ byName.set(entry.name, {
1089
+ source: "inherit",
1090
+ name: entry.name,
1091
+ from: entry.from,
1092
+ secret: true,
1093
+ optional: existing.optional && entry.optional,
1094
+ applies: "agent"
1095
+ });
1096
+ }
1097
+ return [...byName.values()];
1098
+ }
1099
+ function compileMcps2(mcps, stepKey) {
1100
+ const compiled = {
1101
+ opencodeMcpJson: {},
1102
+ healthChecks: [],
1103
+ envEntries: []
1104
+ };
1105
+ for (const [key, handle] of Object.entries(mcps)) {
1106
+ if (!isMcpHandle2(handle)) {
1107
+ throw new Error(`Step "${stepKey}" mcps.${key}: expected a handle from defineMcp().`);
1108
+ }
1109
+ compiled.opencodeMcpJson[key] = compileServer(key, handle);
1110
+ compiled.healthChecks.push(...compileChecks(key, handle));
1111
+ compiled.envEntries.push(...compileEnv(key, handle));
1112
+ }
1113
+ compiled.envEntries = dedupeEnv(compiled.envEntries);
1114
+ return compiled;
1115
+ }
1116
+ function nonEmpty(items) {
1117
+ return items.length > 0 ? items : null;
1118
+ }
1119
+ function mergeStepMcps(stepKey, input) {
1120
+ if (!input.mcps || Object.keys(input.mcps).length === 0) {
1121
+ return {
1122
+ opencodeMcpJson: null,
1123
+ healthChecksJson: input.healthChecks ?? null,
1124
+ envJson: input.envJson
1125
+ };
1126
+ }
1127
+ const compiled = compileMcps2(input.mcps, stepKey);
1128
+ const stepVars = input.envJson ?? [];
1129
+ const stepVarNames = new Set(stepVars.map((entry) => entry.name));
1130
+ return {
1131
+ opencodeMcpJson: compiled.opencodeMcpJson,
1132
+ healthChecksJson: nonEmpty([
1133
+ ...compiled.healthChecks,
1134
+ ...input.healthChecks ?? []
1135
+ ]),
1136
+ envJson: nonEmpty([
1137
+ ...compiled.envEntries.filter((entry) => !stepVarNames.has(entry.name)),
1138
+ ...stepVars
1139
+ ])
1140
+ };
1141
+ }
1142
+
1143
+ // src/definitions/steps/step-handle.ts
1144
+ function compileStepErrors2(stepKey, errors) {
1145
+ const names = [...errors ?? []];
1146
+ const seen = new Set;
1147
+ for (const name of names) {
1148
+ if (name.trim() === "") {
1149
+ throw new Error(`Step "${stepKey}": error names must not be empty.`);
1150
+ }
1151
+ if (seen.has(name)) {
1152
+ throw new Error(`Step "${stepKey}": error "${name}" is declared more than once.`);
1153
+ }
1154
+ seen.add(name);
1155
+ }
1156
+ return names;
1157
+ }
1158
+ function compileStepRetry2(stepKey, retry, errors) {
1159
+ const known = new Set([...BUILT_IN_ERRORS2, ...errors]);
1160
+ return (retry ?? []).map((entry) => {
1161
+ if (entry.on.length === 0) {
1162
+ throw new Error(`Step "${stepKey}": each retry must name an error.`);
1163
+ }
1164
+ const unknown = entry.on.find((name) => !known.has(name));
1165
+ if (unknown !== undefined) {
1166
+ throw new Error(`Step "${stepKey}": retry names "${unknown}", which is neither a built-in error nor one the step declares.`);
1167
+ }
1168
+ if (!Number.isInteger(entry.maxAttempts) || entry.maxAttempts <= 0) {
1169
+ throw new Error(`Step "${stepKey}": retry maxAttempts must be a positive integer.`);
1170
+ }
1171
+ return { on: [...entry.on], maxAttempts: entry.maxAttempts };
1172
+ });
1173
+ }
1174
+ function toStepHandle2(spec) {
1175
+ const node = stepNode(spec);
1176
+ const call = stepCall(node);
1177
+ const { name, ...rest } = spec;
1178
+ Object.defineProperty(call, "name", {
1179
+ value: name,
1180
+ enumerable: true
1181
+ });
1182
+ Object.assign(call, rest);
1183
+ return makeHandle(call, node);
1184
+ }
1185
+ function toStepSpec2(step) {
1186
+ return { ...step };
1187
+ }
1188
+
1189
+ // src/definitions/steps/define-step.ts
1190
+ function assertStepMcpInput(config) {
1191
+ if ("mcpServers" in config) {
1192
+ throw new Error(`Step "${config.key}": mcpServers is not supported. Declare each MCP server with defineMcp({ type: "ref" | "local" | "remote", ... }) and list it under mcps.`);
1193
+ }
1194
+ if (config.healthChecks == null)
1195
+ return;
1196
+ const parsed = stepHealthChecksInputSchema2.safeParse(config.healthChecks);
1197
+ if (parsed.success)
1198
+ return;
1199
+ const issues = parsed.error.issues.map((issue) => issue.path.length > 0 ? `${issue.path.map(String).join(".")}: ${issue.message}` : issue.message).join("; ");
1200
+ throw new Error(`Step "${config.key}" healthChecks: ${issues}. MCP health checks are declared on the server with defineMcp({ healthChecks }).`);
1201
+ }
1202
+ function defineStep2(config) {
1203
+ const features = config.features ?? [];
1204
+ let effectiveResult = config.result;
1205
+ for (const feature of features) {
1206
+ effectiveResult = effectiveResult ? effectiveResult.extend(feature._resultExtension.shape) : feature._resultExtension;
1207
+ }
1208
+ const basePrompt = typeof config.agentPrompt === "function" ? config.agentPrompt(createPromptTemplateContext2()) : config.agentPrompt;
1209
+ let effectivePrompt = basePrompt;
1210
+ for (const feature of features) {
1211
+ if (feature._promptAddition) {
1212
+ effectivePrompt = effectivePrompt ? `${effectivePrompt}
1213
+
1214
+ ${feature._promptAddition}` : feature._promptAddition;
1215
+ }
1216
+ }
1217
+ const {
1218
+ executionMode,
1219
+ devcontainerConfigPath,
1220
+ managedRuntime,
1221
+ envJson,
1222
+ repo
1223
+ } = compileEnvironment2(config.environment, { stepKey: config.key });
1224
+ assertStepMcpInput(config);
1225
+ const mcpFields = mergeStepMcps(config.key, {
1226
+ mcps: config.mcps,
1227
+ healthChecks: config.healthChecks,
1228
+ envJson
1229
+ });
1230
+ const resultSchemaJson = effectiveResult ? toJSONSchema(effectiveResult) : null;
1231
+ const spec = {
1232
+ key: config.key,
1233
+ name: config.name,
1234
+ description: config.description ?? null,
1235
+ version: config.version ?? 1,
1236
+ kind: "user_defined",
1237
+ status: config.status ?? "active",
1238
+ executionMode,
1239
+ devcontainerConfigPath,
1240
+ ...managedRuntime !== null ? { managedRuntime } : {},
1241
+ prompt: effectivePrompt,
1242
+ inputSchemaJson: config.additionalInput ? toJSONSchema(config.additionalInput) : null,
1243
+ resultSchemaJson,
1244
+ opencodeMcpJson: mcpFields.opencodeMcpJson,
1245
+ healthChecksJson: mcpFields.healthChecksJson,
1246
+ envJson: mcpFields.envJson,
1247
+ ...repo !== undefined ? { repo } : {},
1248
+ errors: compileStepErrors2(config.key, config.errors),
1249
+ retryJson: compileStepRetry2(config.key, config.retry, config.errors ?? [])
1250
+ };
1251
+ return toStepHandle2(spec);
1252
+ }
1253
+ // src/definitions/steps/define-code-step.ts
1254
+ function codeStep2(config) {
1255
+ const features = config.features ?? [];
1256
+ let effectiveResult = config.resultSchema;
1257
+ for (const feature of features) {
1258
+ effectiveResult = effectiveResult ? effectiveResult.extend(feature._resultExtension.shape) : feature._resultExtension;
1259
+ }
1260
+ const {
1261
+ executionMode,
1262
+ devcontainerConfigPath,
1263
+ managedRuntime,
1264
+ envJson,
1265
+ repo
1266
+ } = compileEnvironment2(config.environment, {
1267
+ stepKey: config.key,
1268
+ defaultRuntime: Runtime2.managed[DEFAULT_CODE_STEP_RUNTIME_ID2]()
1269
+ });
1270
+ const spec = {
1271
+ key: config.key,
1272
+ name: config.name,
1273
+ description: config.description ?? null,
1274
+ version: config.version ?? 1,
1275
+ kind: "code",
1276
+ status: config.status ?? "active",
1277
+ executionMode,
1278
+ devcontainerConfigPath,
1279
+ managedRuntime,
1280
+ prompt: null,
1281
+ inputSchemaJson: config.inputSchema ? toJSONSchema(config.inputSchema) : null,
1282
+ resultSchemaJson: effectiveResult ? toJSONSchema(effectiveResult) : null,
1283
+ opencodeMcpJson: null,
1284
+ healthChecksJson: null,
1285
+ envJson,
1286
+ ...repo !== undefined ? { repo } : {},
1287
+ errors: compileStepErrors2(config.key, config.errors),
1288
+ retryJson: compileStepRetry2(config.key, config.retry, config.errors ?? []),
1289
+ entrypoint: { fn: config.fn }
1290
+ };
1291
+ return toStepHandle2(spec);
1292
+ }
1293
+ // src/definitions/steps/step-definitions-client.ts
1294
+ var ANY_OBJECT_SCHEMA = { type: "object" };
1295
+ function createStepDefinitionsClient2(baseUrl) {
1296
+ const client = createClient({ baseUrl });
1297
+ return buildStepDefinitionsClient(new StepDefinitions2({ client }));
1298
+ }
1299
+ var buildStepDefinitionsClient = (stepDefinitions) => {
1300
+ return {
1301
+ listByProjectId: async (projectId, options) => {
1302
+ const result = await stepDefinitions.listStepDefinitions({
1303
+ query: { projectId },
1304
+ headers: options?.headers
1305
+ });
1306
+ if (result.error)
1307
+ throw new Error(JSON.stringify(result.error));
1308
+ return result.data;
1309
+ },
1310
+ create: async (body, options) => {
1311
+ const result = await stepDefinitions.createStepDefinition({
1312
+ body,
1313
+ headers: options?.headers
1314
+ });
1315
+ if (result.error)
1316
+ throw new Error(JSON.stringify(result.error));
1317
+ return result.data;
1318
+ },
1319
+ upsertFromSpec: async (projectId, step, options) => {
1320
+ const spec = toStepSpec2(step);
1321
+ const body = {
1322
+ key: spec.key,
1323
+ name: spec.name,
1324
+ description: spec.description,
1325
+ prompt: spec.prompt ?? null,
1326
+ version: spec.version,
1327
+ kind: spec.kind,
1328
+ entrypointJson: spec.entrypointJson ?? null,
1329
+ executionMode: spec.executionMode,
1330
+ devcontainerConfigPath: spec.devcontainerConfigPath,
1331
+ managedRuntime: spec.managedRuntime,
1332
+ repo: spec.repo,
1333
+ inputSchemaJson: spec.inputSchemaJson ?? ANY_OBJECT_SCHEMA,
1334
+ resultSchemaJson: spec.kind === "code" ? spec.resultSchemaJson ?? ANY_OBJECT_SCHEMA : spec.resultSchemaJson,
1335
+ opencodeMcpJson: spec.opencodeMcpJson,
1336
+ healthChecksJson: spec.healthChecksJson,
1337
+ envJson: spec.envJson,
1338
+ errors: [...spec.errors ?? []],
1339
+ retry: (spec.retryJson ?? []).map((entry) => ({
1340
+ on: [...entry.on],
1341
+ maxAttempts: entry.maxAttempts
1342
+ })),
1343
+ status: spec.status,
1344
+ projectId
1345
+ };
1346
+ const result = await stepDefinitions.upsertStepDefinition({
1347
+ body,
1348
+ headers: options?.headers
1349
+ });
1350
+ if (result.error)
1351
+ throw new Error(JSON.stringify(result.error));
1352
+ return result.data;
1353
+ }
1354
+ };
1355
+ };
1356
+ // src/definitions/steps/step-features.ts
1357
+ var notificationKindSchema = _enum([
1358
+ "feedback_request",
1359
+ "status_update",
1360
+ "blocked",
1361
+ "result_ready",
1362
+ "warning"
1363
+ ]);
1364
+ var notificationPrioritySchema = _enum(["low", "normal", "high", "urgent"]);
1365
+ var notificationChannelSchema = _enum([
1366
+ "in_app",
1367
+ "work_item_platform_comment",
1368
+ "email",
1369
+ "slack"
1370
+ ]);
1371
+ var NOTIFICATION_RESULT_KEY = "$scarn_notifications_v1";
1372
+ var DEFAULT_NOTIFICATION_KIND = "status_update";
1373
+ var notificationItemSchema = object({
1374
+ kind: notificationKindSchema.describe("The kind of user notification."),
1375
+ title: string().optional().describe("Short, human-readable notification title."),
1376
+ body: string().describe("The notification body / details."),
1377
+ priority: notificationPrioritySchema.describe("How important this notification is for the user."),
1378
+ suggestedChannels: array(notificationChannelSchema).optional().describe("Channels the agent thinks are worth using. The platform policy decides the final channels."),
1379
+ payload: record(string(), unknown()).optional().describe('Kind-specific structured data. For "feedback_request": { category, urgency }.')
1380
+ }).describe("A single user notification emitted by the agent.");
1381
+ var notificationsFeature = {
1382
+ _resultExtension: object({
1383
+ [NOTIFICATION_RESULT_KEY]: array(notificationItemSchema).optional()
1384
+ }),
1385
+ _promptAddition: [
1386
+ "## User Notifications",
1387
+ "",
1388
+ `If you need to communicate something to a human, populate the \`${NOTIFICATION_RESULT_KEY}\` array.`,
1389
+ "Each item must include:",
1390
+ "- **kind**: One of `feedback_request`, `status_update`, `blocked`, `result_ready`, `warning`.",
1391
+ "- **title**: A short, human-readable title.",
1392
+ "- **body**: The details of the notification.",
1393
+ "- **priority**: One of `low`, `normal`, `high`, `urgent`.",
1394
+ '- **suggestedChannels** *(optional)*: Channels you think are worth using (e.g. `["in_app", "work_item_platform_comment"]`).',
1395
+ " You only *suggest* channels \u2014 the platform policy decides the final delivery channels.",
1396
+ " Suggesting `work_item_platform_comment` does NOT post anything directly: it always requires a human to review the exact text and explicitly approve it before it's posted to the work item's originating platform issue (e.g. GitHub) \u2014 it becomes a pending draft on that comment thread, not an immediate post.",
1397
+ '- **payload** *(optional)*: Kind-specific data. For `feedback_request`, include `{ "category": string, "urgency": "blocking"|"clarification"|"assumption"|"informational" }`.',
1398
+ "",
1399
+ "### Artifacts in comments",
1400
+ "",
1401
+ "A `work_item_platform_comment` body can show or link files this pipeline run produced, using artifact markers:",
1402
+ "- `![caption](artifact:signal/<stepKey>/<resultPath>)` embeds the artifact field at `<resultPath>` in that step's result where the platform can show it, and links to it otherwise. `[label](artifact:signal/<stepKey>/<resultPath>)` links to it. If that artifact is unavailable, the comment is not drafted.",
1403
+ "- `![caption](artifact:<name-or-glob>)` and `[label](artifact:<name-or-glob>)` do the same for any file under the artifacts folder, e.g. `artifact:screenshots/*.png`. If nothing matches, the marker's paragraph is left out.",
1404
+ "Rules:",
1405
+ "- One marker per paragraph: put each marker on its own line, with a blank line before and after. A marker inside a sentence is only linked.",
1406
+ `- Don't refer to an artifact outside its marker (no "see the video below"). Put any description in the caption or label, so the comment still reads correctly if the marker is left out.`
1407
+ ].join(`
1408
+ `)
1409
+ };
1410
+ var feedbackRequestsFeature = {
1411
+ _resultExtension: object({
1412
+ [NOTIFICATION_RESULT_KEY]: array(notificationItemSchema.extend({ kind: literal("feedback_request") })).optional()
1413
+ }),
1414
+ _promptAddition: [
1415
+ "## Feedback Requests",
1416
+ "",
1417
+ `If you need to ask a human a clarifying question, populate the \`${NOTIFICATION_RESULT_KEY}\` array with items of kind \`"feedback_request"\`.`,
1418
+ "Each item must include:",
1419
+ "- **title**: A short, human-readable summary of the question.",
1420
+ "- **body**: The full question.",
1421
+ "- **priority**: One of `low`, `normal`, `high`, `urgent`.",
1422
+ '- **payload**: `{ "category": string, "urgency": "blocking"|"clarification"|"assumption"|"informational" }`.'
1423
+ ].join(`
1424
+ `)
1425
+ };
1426
+ var Features2 = {
1427
+ notifications: () => notificationsFeature,
1428
+ feedbackRequests: () => feedbackRequestsFeature
1429
+ };
1430
+ var Notify2 = {
1431
+ create: (item) => ({
1432
+ [NOTIFICATION_RESULT_KEY]: [item]
1433
+ }),
1434
+ inApp: (title, body, priority, options) => Notify2.create({
1435
+ kind: options?.kind ?? DEFAULT_NOTIFICATION_KIND,
1436
+ title,
1437
+ body,
1438
+ priority,
1439
+ suggestedChannels: ["in_app"],
1440
+ ...options?.payload ? { payload: options.payload } : {}
1441
+ }),
1442
+ feedbackRequest: (question, category, urgency) => Notify2.create({
1443
+ kind: "feedback_request",
1444
+ title: question,
1445
+ body: question,
1446
+ priority: "normal",
1447
+ payload: { category, urgency }
1448
+ }),
1449
+ merge: (...fragments) => ({
1450
+ [NOTIFICATION_RESULT_KEY]: fragments.flatMap((fragment) => fragment[NOTIFICATION_RESULT_KEY])
1451
+ })
1452
+ };
1453
+ export { ARTIFACT_BRAND2, ArtifactTypes2, normalizeArtifactAccept2, artifact2, Artifact2, exports_z, createPromptInputProxy2, createPromptTemplateContext2, renderPromptTemplate2, isSecretLookingEnvName2, Env2, normalizeEnv2, Repo2, compileRepo2, Runtime2, compileEnvironment2, isMcpHandle2, defineMcp2, resolveMcpChecks2, compileMcps2, compileStepErrors2, compileStepRetry2, toStepHandle2, toStepSpec2, defineStep2, codeStep2, createStepDefinitionsClient2, Features2, Notify2 };