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