@scarn/sdk 0.8.20 → 0.8.22
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/auth/api-token-cache.d.ts +24 -0
- package/dist/auth/api-token-source.d.ts +39 -0
- package/dist/auth/authenticated-fetch.d.ts +10 -0
- package/dist/auth/index.d.ts +3 -0
- package/dist/auth/index.js +19 -0
- package/dist/automations/index.js +14 -17
- package/dist/{chunk-habmdf89.js → chunk-0bwsjn0b.js} +29 -29
- package/dist/{chunk-mzj1j0p5.js → chunk-0w13kxkr.js} +34 -31
- package/dist/{chunk-qgkx89eg.js → chunk-3j5wf2t5.js} +44 -43
- package/dist/{chunk-0y2fy5en.js → chunk-4361gxk0.js} +7 -7
- package/dist/{chunk-n3ywwx7n.js → chunk-52520csz.js} +15 -14
- package/dist/chunk-5dnfgyx8.js +159 -0
- package/dist/{chunk-tr3v83cn.js → chunk-5fa4arn1.js} +18 -11
- package/dist/{chunk-ngy1fdcx.js → chunk-631ffb6r.js} +10 -10
- package/dist/{chunk-01nfqm18.js → chunk-7anj08zc.js} +11 -9
- package/dist/{chunk-yq0sf8sb.js → chunk-7dr4kybf.js} +483 -451
- package/dist/chunk-7mhr5aex.js +171 -0
- package/dist/chunk-7rywbqzz.js +27 -0
- package/dist/{chunk-yf15kdte.js → chunk-9ct3xypr.js} +2636 -3864
- package/dist/chunk-9geh4c3v.js +1034 -0
- package/dist/{chunk-19brnwkp.js → chunk-9qf0eg7m.js} +19 -19
- package/dist/{chunk-y11p1q7r.js → chunk-aqqywy8g.js} +4 -4
- package/dist/chunk-bcvx11fn.js +174 -0
- package/dist/{chunk-z4smq8qd.js → chunk-cyfeaz43.js} +86 -86
- package/dist/chunk-czq37rrt.js +286 -0
- package/dist/chunk-ec5z8bbq.js +126 -0
- package/dist/{chunk-rt9tq4j6.js → chunk-h9yxx0hd.js} +7 -7
- package/dist/{chunk-t1dq2c2s.js → chunk-hma87efq.js} +40 -40
- package/dist/{chunk-5dny5jg1.js → chunk-hpv234hf.js} +11 -11
- package/dist/{chunk-rq5k7m33.js → chunk-k7xnsmp5.js} +182 -97
- package/dist/{chunk-91f5gm5z.js → chunk-kbpkpxcn.js} +22 -21
- package/dist/{chunk-6tra3gw8.js → chunk-kjn1knb9.js} +7 -7
- package/dist/{chunk-g4j5cfpc.js → chunk-p3s7cjfc.js} +17 -16
- package/dist/chunk-pq6hrtnb.js +49 -0
- package/dist/{chunk-mp2rqtcj.js → chunk-ptpy7nnm.js} +8 -8
- package/dist/{chunk-xqfj56m9.js → chunk-vn1rfxma.js} +8 -8
- package/dist/chunk-vyv8kvkv.js +113 -0
- package/dist/{chunk-0c60x3v8.js → chunk-xe2zgyz7.js} +35 -35
- package/dist/chunk-y4dwmhn2.js +14 -0
- package/dist/{chunk-098740f7.js → chunk-yypj3zn0.js} +8 -8
- package/dist/chunk-yzj1mfpr.js +1515 -0
- package/dist/client.d.ts +5 -1
- package/dist/client.js +62 -61
- package/dist/connectors/index.js +36 -37
- package/dist/contracts/artifact-markers.js +11 -12
- package/dist/contracts/artifacts.js +21 -23
- package/dist/contracts/automation-document/index.js +28 -30
- package/dist/contracts/pipeline-document/built-ins.d.ts +1 -1
- package/dist/contracts/pipeline-document/index.js +95 -97
- package/dist/contracts/step-artifact-submissions.js +20 -17
- package/dist/contracts/work-item-changes.js +8 -6
- package/dist/create-api-client.d.ts +11 -0
- package/dist/defaults/index.js +44 -884
- package/dist/defaults/load-push-defaults.d.ts +11 -4
- package/dist/defaults/project-ref.d.ts +2 -4
- package/dist/definitions/automations/automations-client.d.ts +2 -1
- package/dist/definitions/automations/index.js +6 -8
- package/dist/definitions/environments/environments-client.d.ts +2 -1
- package/dist/definitions/environments/index.js +37 -38
- package/dist/definitions/pipelines/index.js +12 -14
- package/dist/definitions/pipelines/pipeline-definitions-client.d.ts +2 -1
- package/dist/definitions/steps/define-mcp.d.ts +2 -2
- package/dist/definitions/steps/index.js +93 -95
- package/dist/definitions/steps/mcp-server-config.d.ts +13 -3
- package/dist/definitions/steps/step-definitions-client.d.ts +20 -1
- package/dist/definitions/validation/index.js +17 -18
- package/dist/devcontainer-config-path.js +9 -11
- package/dist/env-vars.js +37 -39
- package/dist/environment.js +41 -42
- package/dist/eslint.js +0 -2
- package/dist/generated/index.d.ts +2 -2
- package/dist/generated/sdk.gen.d.ts +41 -1
- package/dist/generated/types.gen.d.ts +1801 -0
- package/dist/git-url/git-repo-identity.js +0 -2
- package/dist/health-checks.js +15 -17
- package/dist/index.js +364 -358
- package/dist/jsonc.js +7 -8
- package/dist/managed-connections.d.ts +16 -0
- package/dist/managed-connections.js +9 -0
- package/dist/managed-runtimes.js +9 -11
- package/dist/opencode-mcp.d.ts +55 -1
- package/dist/opencode-mcp.js +33 -28
- package/dist/pipelines/index.js +78 -81
- package/dist/push/code-step-lookup.js +9 -10
- package/dist/push/index.d.ts +1 -0
- package/dist/push/index.js +109 -79
- package/dist/push/push-from-directory.d.ts +9 -1
- package/dist/push/pushed-mcp-servers.d.ts +28 -0
- package/dist/repo-config.js +41 -43
- package/dist/resolve-environment.js +14 -15
- package/dist/scarn-config-parser.js +5 -6
- package/dist/task-plane-client.d.ts +143 -1
- package/package.json +11 -3
- package/dist/chunk-46wmsgv7.js +0 -14
- package/dist/chunk-a56zc4s5.js +0 -119
- package/dist/chunk-aemxz9r7.js +0 -107
- package/dist/chunk-b9ja6ss5.js +0 -275
- package/dist/chunk-e0pt5x0e.js +0 -167
- package/dist/chunk-pqtd0hr7.js +0 -96
- package/dist/chunk-rphfy0fj.js +0 -167
- package/dist/chunk-y34zsgsw.js +0 -39
- package/dist/chunk-y64skrwp.js +0 -17
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
toJSONSchema,
|
|
4
|
+
string,
|
|
5
|
+
number,
|
|
6
|
+
int,
|
|
7
|
+
array,
|
|
8
|
+
strictObject,
|
|
9
|
+
union,
|
|
10
|
+
discriminatedUnion,
|
|
11
|
+
record,
|
|
12
|
+
_enum,
|
|
13
|
+
literal,
|
|
14
|
+
json
|
|
15
|
+
} from "./chunk-9ct3xypr.js";
|
|
16
|
+
|
|
17
|
+
// src/contracts/pipeline-document/conditions/operators.ts
|
|
18
|
+
var COMPARISON_OPERATORS2 = [
|
|
19
|
+
"equal",
|
|
20
|
+
"notEqual",
|
|
21
|
+
"lessThan",
|
|
22
|
+
"lessThanInclusive",
|
|
23
|
+
"greaterThan",
|
|
24
|
+
"greaterThanInclusive"
|
|
25
|
+
];
|
|
26
|
+
var CONDITION_OPERATORS2 = [
|
|
27
|
+
...COMPARISON_OPERATORS2,
|
|
28
|
+
"exists",
|
|
29
|
+
"isEmpty",
|
|
30
|
+
"contains",
|
|
31
|
+
"startsWith",
|
|
32
|
+
"endsWith",
|
|
33
|
+
"matches",
|
|
34
|
+
"before",
|
|
35
|
+
"after",
|
|
36
|
+
"some",
|
|
37
|
+
"every",
|
|
38
|
+
"none"
|
|
39
|
+
];
|
|
40
|
+
var COMPUTED_FUNCTIONS2 = [
|
|
41
|
+
"sum",
|
|
42
|
+
"avg",
|
|
43
|
+
"min",
|
|
44
|
+
"max",
|
|
45
|
+
"count"
|
|
46
|
+
];
|
|
47
|
+
var ORDERING_OPERATORS2 = new Set([
|
|
48
|
+
"lessThan",
|
|
49
|
+
"lessThanInclusive",
|
|
50
|
+
"greaterThan",
|
|
51
|
+
"greaterThanInclusive"
|
|
52
|
+
]);
|
|
53
|
+
var STRING_OPERATORS2 = new Set([
|
|
54
|
+
"startsWith",
|
|
55
|
+
"endsWith",
|
|
56
|
+
"matches"
|
|
57
|
+
]);
|
|
58
|
+
var DATE_OPERATORS2 = new Set(["before", "after"]);
|
|
59
|
+
var LIST_OPERATORS2 = new Set(["some", "every", "none"]);
|
|
60
|
+
|
|
61
|
+
// src/contracts/pipeline-document/schema.ts
|
|
62
|
+
var NODE_ID_PATTERN2 = /^[A-Za-z0-9][A-Za-z0-9_-]*$/;
|
|
63
|
+
var ALIAS_PATTERN2 = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
64
|
+
var nodeIdSchema = string().regex(NODE_ID_PATTERN2, "Node ids may only contain letters, digits, '_' and '-'");
|
|
65
|
+
var jsonValueSchema = json();
|
|
66
|
+
var literalSchema2 = strictObject({ value: jsonValueSchema });
|
|
67
|
+
var scalarArgSchema = union([string().min(1), literalSchema2]);
|
|
68
|
+
var listSchema2 = strictObject({ list: array(scalarArgSchema) });
|
|
69
|
+
var argValueSchema2 = union([
|
|
70
|
+
string().min(1),
|
|
71
|
+
literalSchema2,
|
|
72
|
+
listSchema2
|
|
73
|
+
]);
|
|
74
|
+
var computedSourceSchema2 = union([
|
|
75
|
+
array(string().min(1)).min(1),
|
|
76
|
+
strictObject({
|
|
77
|
+
path: string().min(1),
|
|
78
|
+
field: string().min(1).optional(),
|
|
79
|
+
get where() {
|
|
80
|
+
return conditionSchema2.optional();
|
|
81
|
+
}
|
|
82
|
+
})
|
|
83
|
+
]);
|
|
84
|
+
var LIST_OPS = new Set(["some", "every", "none"]);
|
|
85
|
+
var UNARY_OPS = new Set(["exists", "isEmpty"]);
|
|
86
|
+
var conditionSchema2 = strictObject({
|
|
87
|
+
get all() {
|
|
88
|
+
return array(conditionSchema2).min(1).optional();
|
|
89
|
+
},
|
|
90
|
+
get any() {
|
|
91
|
+
return array(conditionSchema2).min(1).optional();
|
|
92
|
+
},
|
|
93
|
+
get not() {
|
|
94
|
+
return conditionSchema2.optional();
|
|
95
|
+
},
|
|
96
|
+
path: string().min(1).optional(),
|
|
97
|
+
sum: computedSourceSchema2.optional(),
|
|
98
|
+
avg: computedSourceSchema2.optional(),
|
|
99
|
+
min: computedSourceSchema2.optional(),
|
|
100
|
+
max: computedSourceSchema2.optional(),
|
|
101
|
+
count: computedSourceSchema2.optional(),
|
|
102
|
+
weights: array(number()).min(1).optional(),
|
|
103
|
+
op: _enum(CONDITION_OPERATORS2).optional(),
|
|
104
|
+
value: jsonValueSchema.optional(),
|
|
105
|
+
ref: string().min(1).optional(),
|
|
106
|
+
get where() {
|
|
107
|
+
return conditionSchema2.optional();
|
|
108
|
+
}
|
|
109
|
+
}).superRefine((condition, ctx) => {
|
|
110
|
+
const combinators = ["all", "any", "not"].filter((key) => condition[key] !== undefined);
|
|
111
|
+
const lefts = ["path", ...COMPUTED_FUNCTIONS2].filter((key) => condition[key] !== undefined);
|
|
112
|
+
if (combinators.length > 0) {
|
|
113
|
+
const extras = Object.keys(condition).filter((key) => key !== combinators[0]);
|
|
114
|
+
if (combinators.length > 1 || extras.length > 0) {
|
|
115
|
+
ctx.addIssue({
|
|
116
|
+
code: "custom",
|
|
117
|
+
message: `A condition with "${String(combinators[0])}" can't have other keys (found ${[...combinators.slice(1), ...extras].map((key) => `"${key}"`).join(", ")})`
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
if (lefts.length !== 1) {
|
|
123
|
+
ctx.addIssue({
|
|
124
|
+
code: "custom",
|
|
125
|
+
message: lefts.length === 0 ? 'A condition needs exactly one of "path", "sum", "avg", "min", "max", "count", or a combinator "all", "any", "not"' : `A condition can have only one of ${lefts.map((key) => `"${key}"`).join(", ")}`
|
|
126
|
+
});
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
if (condition.op === undefined) {
|
|
130
|
+
ctx.addIssue({
|
|
131
|
+
code: "custom",
|
|
132
|
+
message: 'A condition needs "op"',
|
|
133
|
+
path: ["op"]
|
|
134
|
+
});
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
const isList = LIST_OPS.has(condition.op);
|
|
138
|
+
const isUnary = UNARY_OPS.has(condition.op);
|
|
139
|
+
if (isList && condition.where === undefined) {
|
|
140
|
+
ctx.addIssue({
|
|
141
|
+
code: "custom",
|
|
142
|
+
message: `"${condition.op}" needs a "where" condition`,
|
|
143
|
+
path: ["where"]
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
if (!isList && condition.where !== undefined) {
|
|
147
|
+
ctx.addIssue({
|
|
148
|
+
code: "custom",
|
|
149
|
+
message: `"where" is only allowed with "some", "every" or "none", not "${condition.op}"`,
|
|
150
|
+
path: ["where"]
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
const hasValue = condition.value !== undefined;
|
|
154
|
+
const hasRef = condition.ref !== undefined;
|
|
155
|
+
if ((isList || isUnary) && (hasValue || hasRef)) {
|
|
156
|
+
ctx.addIssue({
|
|
157
|
+
code: "custom",
|
|
158
|
+
message: `"${condition.op}" takes no "value" or "ref"`,
|
|
159
|
+
path: [hasValue ? "value" : "ref"]
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
if (!isList && !isUnary && hasValue === hasRef) {
|
|
163
|
+
ctx.addIssue({
|
|
164
|
+
code: "custom",
|
|
165
|
+
message: `"${condition.op}" needs exactly one of "value" or "ref"`
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
if (condition.weights !== undefined && condition.avg === undefined) {
|
|
169
|
+
ctx.addIssue({
|
|
170
|
+
code: "custom",
|
|
171
|
+
message: '"weights" is only allowed with "avg"',
|
|
172
|
+
path: ["weights"]
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
var toleratedFailuresSchema2 = union([
|
|
177
|
+
strictObject({ count: int().nonnegative() }),
|
|
178
|
+
strictObject({ percent: number().min(0).max(100) })
|
|
179
|
+
]);
|
|
180
|
+
var eachSchema2 = strictObject({
|
|
181
|
+
over: string().min(1),
|
|
182
|
+
maxConcurrency: int().positive().optional(),
|
|
183
|
+
toleratedFailures: toleratedFailuresSchema2.optional()
|
|
184
|
+
});
|
|
185
|
+
var routeShape = {
|
|
186
|
+
when: conditionSchema2.optional(),
|
|
187
|
+
to: nodeIdSchema,
|
|
188
|
+
pipeline: string().min(1).optional(),
|
|
189
|
+
args: record(string().min(1), argValueSchema2).optional(),
|
|
190
|
+
each: eachSchema2.optional(),
|
|
191
|
+
partial: literal(true).optional(),
|
|
192
|
+
label: string().min(1).max(80).optional(),
|
|
193
|
+
overridable: literal(true).optional()
|
|
194
|
+
};
|
|
195
|
+
function noPartialWithEach(route, ctx) {
|
|
196
|
+
if (route.each !== undefined && route.partial !== undefined) {
|
|
197
|
+
ctx.addIssue({
|
|
198
|
+
code: "custom",
|
|
199
|
+
message: `A route can't have both "each" and "partial"`,
|
|
200
|
+
path: ["partial"]
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
var routeSchema2 = strictObject(routeShape).superRefine(noPartialWithEach);
|
|
205
|
+
var otherwiseSchema2 = strictObject(routeShape).omit({ when: true }).superRefine(noPartialWithEach);
|
|
206
|
+
var startSchema2 = strictObject(routeShape).omit({ partial: true, label: true, overridable: true });
|
|
207
|
+
var MATCH_MODES2 = ["first", "all"];
|
|
208
|
+
var nextSchema2 = strictObject({
|
|
209
|
+
match: _enum(MATCH_MODES2).optional(),
|
|
210
|
+
routes: array(routeSchema2).min(1),
|
|
211
|
+
otherwise: otherwiseSchema2.optional(),
|
|
212
|
+
overridable: literal(true).optional()
|
|
213
|
+
});
|
|
214
|
+
var retrySchema2 = strictObject({
|
|
215
|
+
on: array(string().min(1)).min(1),
|
|
216
|
+
maxAttempts: int().positive(),
|
|
217
|
+
intervalSeconds: number().nonnegative().optional(),
|
|
218
|
+
backoffRate: number().positive().optional(),
|
|
219
|
+
maxDelaySeconds: number().nonnegative().optional()
|
|
220
|
+
});
|
|
221
|
+
var catchSchema2 = strictObject({
|
|
222
|
+
on: array(string().min(1)).min(1),
|
|
223
|
+
to: nodeIdSchema,
|
|
224
|
+
pipeline: string().min(1).optional(),
|
|
225
|
+
args: record(string().min(1), argValueSchema2).optional()
|
|
226
|
+
});
|
|
227
|
+
var stepNodeSchema2 = strictObject({
|
|
228
|
+
kind: literal("step"),
|
|
229
|
+
title: string().optional(),
|
|
230
|
+
step: string().min(1),
|
|
231
|
+
next: nextSchema2.optional(),
|
|
232
|
+
retry: array(retrySchema2).optional(),
|
|
233
|
+
catch: array(catchSchema2).optional(),
|
|
234
|
+
timeoutSeconds: int().positive().optional(),
|
|
235
|
+
heartbeatSeconds: int().positive().optional(),
|
|
236
|
+
maxRuns: int().positive().optional(),
|
|
237
|
+
maxTurns: int().nonnegative().optional()
|
|
238
|
+
});
|
|
239
|
+
var DEFAULT_MAX_TURNS2 = 2;
|
|
240
|
+
var DECISION_BODY_MODES2 = ["optional", "required"];
|
|
241
|
+
var decisionActionSchema2 = strictObject({
|
|
242
|
+
key: string().min(1),
|
|
243
|
+
label: string().min(1),
|
|
244
|
+
body: _enum(DECISION_BODY_MODES2).optional()
|
|
245
|
+
});
|
|
246
|
+
var waitNodeSchema2 = strictObject({
|
|
247
|
+
kind: literal("wait"),
|
|
248
|
+
title: string().optional(),
|
|
249
|
+
for: _enum(["decision", "reply", "event", "timer"]),
|
|
250
|
+
actions: array(decisionActionSchema2).optional(),
|
|
251
|
+
next: nextSchema2.optional(),
|
|
252
|
+
catch: array(catchSchema2).optional(),
|
|
253
|
+
timeoutSeconds: int().positive().optional(),
|
|
254
|
+
maxRuns: int().positive().optional()
|
|
255
|
+
});
|
|
256
|
+
var succeedNodeSchema2 = strictObject({
|
|
257
|
+
kind: literal("succeed"),
|
|
258
|
+
title: string().optional()
|
|
259
|
+
});
|
|
260
|
+
var failNodeSchema2 = strictObject({
|
|
261
|
+
kind: literal("fail"),
|
|
262
|
+
title: string().optional(),
|
|
263
|
+
error: string().min(1).optional(),
|
|
264
|
+
cause: string().optional()
|
|
265
|
+
});
|
|
266
|
+
var nodeSchema2 = discriminatedUnion("kind", [
|
|
267
|
+
stepNodeSchema2,
|
|
268
|
+
waitNodeSchema2,
|
|
269
|
+
succeedNodeSchema2,
|
|
270
|
+
failNodeSchema2
|
|
271
|
+
]);
|
|
272
|
+
var pipelineDocumentSchema2 = strictObject({
|
|
273
|
+
$schema: string().optional(),
|
|
274
|
+
schemaVersion: literal(1),
|
|
275
|
+
key: string().min(1),
|
|
276
|
+
title: string().optional(),
|
|
277
|
+
timeoutSeconds: int().positive().optional(),
|
|
278
|
+
workItemFields: record(string().regex(ALIAS_PATTERN2, "Aliases must be identifiers (letters, digits, '_')"), string().min(1)).optional(),
|
|
279
|
+
start: startSchema2,
|
|
280
|
+
nodes: record(nodeIdSchema, nodeSchema2)
|
|
281
|
+
});
|
|
282
|
+
function pipelineDocumentJsonSchema2() {
|
|
283
|
+
return toJSONSchema(pipelineDocumentSchema2, { io: "input" });
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
export { COMPARISON_OPERATORS2, CONDITION_OPERATORS2, COMPUTED_FUNCTIONS2, ORDERING_OPERATORS2, STRING_OPERATORS2, DATE_OPERATORS2, LIST_OPERATORS2, NODE_ID_PATTERN2, ALIAS_PATTERN2, literalSchema2, listSchema2, argValueSchema2, computedSourceSchema2, conditionSchema2, toleratedFailuresSchema2, eachSchema2, routeSchema2, otherwiseSchema2, startSchema2, MATCH_MODES2, nextSchema2, retrySchema2, catchSchema2, stepNodeSchema2, DEFAULT_MAX_TURNS2, DECISION_BODY_MODES2, decisionActionSchema2, waitNodeSchema2, succeedNodeSchema2, failNodeSchema2, nodeSchema2, pipelineDocumentSchema2, pipelineDocumentJsonSchema2 };
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
argValueSchema2,
|
|
4
|
+
conditionSchema2,
|
|
5
|
+
MATCH_MODES2
|
|
6
|
+
} from "./chunk-czq37rrt.js";
|
|
7
|
+
import {
|
|
8
|
+
toJSONSchema,
|
|
9
|
+
string,
|
|
10
|
+
array,
|
|
11
|
+
strictObject,
|
|
12
|
+
discriminatedUnion,
|
|
13
|
+
record,
|
|
14
|
+
_enum,
|
|
15
|
+
literal
|
|
16
|
+
} from "./chunk-9ct3xypr.js";
|
|
17
|
+
|
|
18
|
+
// src/contracts/automation-document/schema.ts
|
|
19
|
+
var AUTOMATION_SCOPES2 = ["workItem", "project"];
|
|
20
|
+
var WORK_ITEM_AUTOMATION_EVENTS2 = [
|
|
21
|
+
"self.attached",
|
|
22
|
+
"child.created",
|
|
23
|
+
"child.ready",
|
|
24
|
+
"child.closed"
|
|
25
|
+
];
|
|
26
|
+
var PROJECT_AUTOMATION_EVENTS2 = [
|
|
27
|
+
"workItem.created",
|
|
28
|
+
"workItem.ready",
|
|
29
|
+
"workItem.label.added"
|
|
30
|
+
];
|
|
31
|
+
var AUTOMATION_EVENTS2 = [
|
|
32
|
+
...WORK_ITEM_AUTOMATION_EVENTS2,
|
|
33
|
+
...PROJECT_AUTOMATION_EVENTS2
|
|
34
|
+
];
|
|
35
|
+
var AUTOMATION_SUBJECTS2 = ["workItem", "child"];
|
|
36
|
+
function scopeOfEvent2(event) {
|
|
37
|
+
return WORK_ITEM_AUTOMATION_EVENTS2.includes(event) ? "workItem" : "project";
|
|
38
|
+
}
|
|
39
|
+
function eventHasChild2(event) {
|
|
40
|
+
return event.startsWith("child.");
|
|
41
|
+
}
|
|
42
|
+
var keySchema = string().min(1);
|
|
43
|
+
var subjectSchema = _enum(AUTOMATION_SUBJECTS2);
|
|
44
|
+
var stepTargetShape = {
|
|
45
|
+
kind: literal("step"),
|
|
46
|
+
to: keySchema,
|
|
47
|
+
args: record(string().min(1), argValueSchema2).optional(),
|
|
48
|
+
on: subjectSchema
|
|
49
|
+
};
|
|
50
|
+
var pipelineTargetShape = {
|
|
51
|
+
kind: literal("pipeline"),
|
|
52
|
+
to: keySchema,
|
|
53
|
+
on: subjectSchema
|
|
54
|
+
};
|
|
55
|
+
var attachTargetShape = {
|
|
56
|
+
kind: literal("attach"),
|
|
57
|
+
automation: keySchema
|
|
58
|
+
};
|
|
59
|
+
var skipTargetShape = { kind: literal("skip") };
|
|
60
|
+
var automationTargetSchema2 = discriminatedUnion("kind", [
|
|
61
|
+
strictObject(stepTargetShape),
|
|
62
|
+
strictObject(pipelineTargetShape),
|
|
63
|
+
strictObject(attachTargetShape),
|
|
64
|
+
strictObject(skipTargetShape)
|
|
65
|
+
]);
|
|
66
|
+
var when = { when: conditionSchema2.optional() };
|
|
67
|
+
var automationRouteSchema2 = discriminatedUnion("kind", [
|
|
68
|
+
strictObject({ ...when, ...stepTargetShape }),
|
|
69
|
+
strictObject({ ...when, ...pipelineTargetShape }),
|
|
70
|
+
strictObject({ ...when, ...attachTargetShape }),
|
|
71
|
+
strictObject({ ...when, ...skipTargetShape })
|
|
72
|
+
]);
|
|
73
|
+
var automationNextSchema2 = strictObject({
|
|
74
|
+
match: _enum(MATCH_MODES2).optional(),
|
|
75
|
+
routes: array(automationRouteSchema2).min(1),
|
|
76
|
+
otherwise: automationTargetSchema2.optional()
|
|
77
|
+
});
|
|
78
|
+
var automationRuleSchema2 = strictObject({
|
|
79
|
+
event: _enum(AUTOMATION_EVENTS2),
|
|
80
|
+
next: automationNextSchema2
|
|
81
|
+
});
|
|
82
|
+
function targetsOf(rule) {
|
|
83
|
+
return [
|
|
84
|
+
...rule.next.routes,
|
|
85
|
+
...rule.next.otherwise === undefined ? [] : [rule.next.otherwise]
|
|
86
|
+
];
|
|
87
|
+
}
|
|
88
|
+
var automationDocumentSchema2 = strictObject({
|
|
89
|
+
$schema: string().optional(),
|
|
90
|
+
kind: literal("automation"),
|
|
91
|
+
schemaVersion: literal(1),
|
|
92
|
+
key: keySchema,
|
|
93
|
+
title: string().optional(),
|
|
94
|
+
scope: _enum(AUTOMATION_SCOPES2),
|
|
95
|
+
rules: array(automationRuleSchema2)
|
|
96
|
+
}).superRefine((document, ctx) => {
|
|
97
|
+
document.rules.forEach((rule, index) => {
|
|
98
|
+
if (scopeOfEvent2(rule.event) !== document.scope) {
|
|
99
|
+
ctx.addIssue({
|
|
100
|
+
code: "custom",
|
|
101
|
+
message: `"${rule.event}" isn't an event of a ${document.scope === "workItem" ? "work-item" : "project"} automation`,
|
|
102
|
+
path: ["rules", index, "event"]
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
for (const target of targetsOf(rule)) {
|
|
106
|
+
if (target.kind === "attach" && document.scope !== "project") {
|
|
107
|
+
ctx.addIssue({
|
|
108
|
+
code: "custom",
|
|
109
|
+
message: "Only a project automation can attach automations",
|
|
110
|
+
path: ["rules", index, "next"]
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
if ((target.kind === "step" || target.kind === "pipeline") && target.on === "child" && !eventHasChild2(rule.event)) {
|
|
114
|
+
ctx.addIssue({
|
|
115
|
+
code: "custom",
|
|
116
|
+
message: `"${rule.event}" has no child work item, so a target can't be "on": "child"`,
|
|
117
|
+
path: ["rules", index, "next"]
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
function automationDocumentJsonSchema2() {
|
|
124
|
+
return toJSONSchema(automationDocumentSchema2, { io: "input" });
|
|
125
|
+
}
|
|
126
|
+
export { AUTOMATION_SCOPES2, WORK_ITEM_AUTOMATION_EVENTS2, PROJECT_AUTOMATION_EVENTS2, AUTOMATION_EVENTS2, AUTOMATION_SUBJECTS2, scopeOfEvent2, eventHasChild2, automationTargetSchema2, automationRouteSchema2, automationNextSchema2, automationRuleSchema2, automationDocumentSchema2, automationDocumentJsonSchema2 };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
// src/jsonc.ts
|
|
3
|
-
var
|
|
3
|
+
var stripJsoncComments2 = (content) => {
|
|
4
4
|
let result = "";
|
|
5
5
|
let inString = false;
|
|
6
6
|
let escapeNextCharacter = false;
|
|
@@ -58,7 +58,7 @@ var stripJsoncComments = (content) => {
|
|
|
58
58
|
}
|
|
59
59
|
return result;
|
|
60
60
|
};
|
|
61
|
-
var
|
|
61
|
+
var stripTrailingCommas2 = (content) => {
|
|
62
62
|
let result = "";
|
|
63
63
|
let inString = false;
|
|
64
64
|
let escapeNextCharacter = false;
|
|
@@ -87,12 +87,12 @@ var stripTrailingCommas = (content) => {
|
|
|
87
87
|
if (character === ",") {
|
|
88
88
|
let lookaheadIndex = index + 1;
|
|
89
89
|
while (lookaheadIndex < content.length) {
|
|
90
|
-
const
|
|
91
|
-
if (/\s/u.test(
|
|
90
|
+
const lookaheadCharacter = content.charAt(lookaheadIndex);
|
|
91
|
+
if (/\s/u.test(lookaheadCharacter)) {
|
|
92
92
|
lookaheadIndex += 1;
|
|
93
93
|
continue;
|
|
94
94
|
}
|
|
95
|
-
if (
|
|
95
|
+
if (lookaheadCharacter === "}" || lookaheadCharacter === "]") {
|
|
96
96
|
break;
|
|
97
97
|
}
|
|
98
98
|
result += character;
|
|
@@ -111,6 +111,6 @@ var stripTrailingCommas = (content) => {
|
|
|
111
111
|
}
|
|
112
112
|
return result;
|
|
113
113
|
};
|
|
114
|
-
var
|
|
114
|
+
var parseJsonc2 = (content) => JSON.parse(stripTrailingCommas2(stripJsoncComments2(content)));
|
|
115
115
|
|
|
116
|
-
export {
|
|
116
|
+
export { stripJsoncComments2, stripTrailingCommas2, parseJsonc2 };
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
} from "./chunk-
|
|
3
|
+
devcontainerConfigPathSchema2
|
|
4
|
+
} from "./chunk-yypj3zn0.js";
|
|
5
5
|
import {
|
|
6
|
-
|
|
7
|
-
} from "./chunk-
|
|
6
|
+
containsInputToken2
|
|
7
|
+
} from "./chunk-vyv8kvkv.js";
|
|
8
8
|
import {
|
|
9
|
-
|
|
10
|
-
} from "./chunk-
|
|
9
|
+
MANAGED_RUNTIME_IDS2
|
|
10
|
+
} from "./chunk-y4dwmhn2.js";
|
|
11
11
|
import {
|
|
12
|
-
|
|
13
|
-
} from "./chunk-
|
|
12
|
+
connectorIdsSchema2
|
|
13
|
+
} from "./chunk-3j5wf2t5.js";
|
|
14
14
|
import {
|
|
15
|
-
|
|
16
|
-
} from "./chunk-
|
|
15
|
+
environmentNameSchema2
|
|
16
|
+
} from "./chunk-bcvx11fn.js";
|
|
17
17
|
import {
|
|
18
|
-
|
|
19
|
-
} from "./chunk-
|
|
18
|
+
isEnvironmentHandle2
|
|
19
|
+
} from "./chunk-kjn1knb9.js";
|
|
20
20
|
|
|
21
21
|
// src/definitions/steps/prompt-template.ts
|
|
22
|
-
function
|
|
22
|
+
function createPromptInputProxy2(path = []) {
|
|
23
23
|
const token = () => path.length ? `{{${path.join(".")}}}` : "";
|
|
24
24
|
return new Proxy(Object.freeze({}), {
|
|
25
25
|
get(_, key) {
|
|
@@ -31,23 +31,23 @@ function createPromptInputProxy(path = []) {
|
|
|
31
31
|
}
|
|
32
32
|
if (typeof key !== "string")
|
|
33
33
|
return;
|
|
34
|
-
return
|
|
34
|
+
return createPromptInputProxy2([...path, key]);
|
|
35
35
|
}
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function createPromptTemplateContext2() {
|
|
39
39
|
return {
|
|
40
|
-
input:
|
|
41
|
-
env:
|
|
40
|
+
input: createPromptInputProxy2(["input"]),
|
|
41
|
+
env: createPromptInputProxy2(["env"]),
|
|
42
42
|
scarn: {
|
|
43
|
-
artifactsDir:
|
|
43
|
+
artifactsDir: createPromptInputProxy2([
|
|
44
44
|
"scarn",
|
|
45
45
|
"artifactsDir"
|
|
46
46
|
])
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
|
-
function
|
|
50
|
+
function renderPromptTemplate2(template, contextJson) {
|
|
51
51
|
return template.replace(/\{\{([^}]+)\}\}/g, (_, path) => {
|
|
52
52
|
const value = path.split(".").reduce((curr, key) => curr != null ? curr[key] : undefined, contextJson);
|
|
53
53
|
return value != null ? String(value) : "";
|
|
@@ -56,7 +56,7 @@ function renderPromptTemplate(template, contextJson) {
|
|
|
56
56
|
|
|
57
57
|
// src/definitions/steps/env.ts
|
|
58
58
|
var SECRET_LOOKING_NAME = /SECRET|TOKEN|PASSWORD|PASSWD|API_?KEY|PRIVATE/i;
|
|
59
|
-
function
|
|
59
|
+
function isSecretLookingEnvName2(name) {
|
|
60
60
|
return SECRET_LOOKING_NAME.test(name);
|
|
61
61
|
}
|
|
62
62
|
var helperEntries = new WeakSet;
|
|
@@ -64,7 +64,7 @@ function brand(entry) {
|
|
|
64
64
|
helperEntries.add(entry);
|
|
65
65
|
return entry;
|
|
66
66
|
}
|
|
67
|
-
var
|
|
67
|
+
var Env2 = {
|
|
68
68
|
value(opts) {
|
|
69
69
|
return brand({
|
|
70
70
|
kind: "value",
|
|
@@ -96,12 +96,12 @@ function isHelperEntry(entry) {
|
|
|
96
96
|
return typeof entry === "object" && helperEntries.has(entry);
|
|
97
97
|
}
|
|
98
98
|
function assertNotStaticSecret(name, value, flags) {
|
|
99
|
-
if (
|
|
99
|
+
if (containsInputToken2(value))
|
|
100
100
|
return;
|
|
101
101
|
if (flags.secret) {
|
|
102
102
|
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.`);
|
|
103
103
|
}
|
|
104
|
-
if (
|
|
104
|
+
if (isSecretLookingEnvName2(name) && !flags.unsafeAllowStatic) {
|
|
105
105
|
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.`);
|
|
106
106
|
}
|
|
107
107
|
}
|
|
@@ -145,22 +145,22 @@ function toEnvVarSpec(name, entry) {
|
|
|
145
145
|
...appliesField(entry.applies)
|
|
146
146
|
};
|
|
147
147
|
}
|
|
148
|
-
function
|
|
148
|
+
function normalizeEnv2(fn) {
|
|
149
149
|
if (!fn)
|
|
150
150
|
return null;
|
|
151
|
-
const record = typeof fn === "function" ? fn({ input:
|
|
151
|
+
const record = typeof fn === "function" ? fn({ input: createPromptInputProxy2(["input"]) }) : fn;
|
|
152
152
|
const specs = Object.entries(record).map(([name, entry]) => toEnvVarSpec(name, entry));
|
|
153
153
|
return specs.length > 0 ? specs : null;
|
|
154
154
|
}
|
|
155
155
|
|
|
156
156
|
// src/definitions/steps/runtime.ts
|
|
157
|
-
var managedRuntimeFactories = Object.fromEntries(
|
|
158
|
-
var
|
|
157
|
+
var managedRuntimeFactories = Object.fromEntries(MANAGED_RUNTIME_IDS2.map((id) => [id, () => ({ kind: "managed", id })]));
|
|
158
|
+
var Runtime2 = {
|
|
159
159
|
managed: managedRuntimeFactories,
|
|
160
160
|
devcontainer(opts) {
|
|
161
161
|
if (opts?.config === undefined)
|
|
162
162
|
return { kind: "devcontainer" };
|
|
163
|
-
const parsed =
|
|
163
|
+
const parsed = devcontainerConfigPathSchema2.safeParse(opts.config);
|
|
164
164
|
if (!parsed.success) {
|
|
165
165
|
throw new Error(`Runtime.devcontainer config "${opts.config}": ${parsed.error.issues.map((issue) => issue.message).join("; ")}`);
|
|
166
166
|
}
|
|
@@ -170,7 +170,7 @@ var Runtime = {
|
|
|
170
170
|
return { kind: "host" };
|
|
171
171
|
}
|
|
172
172
|
};
|
|
173
|
-
function
|
|
173
|
+
function assertNoSetupVarsOnHost2(envJson, runtime, owner) {
|
|
174
174
|
if (runtime?.kind !== "host")
|
|
175
175
|
return;
|
|
176
176
|
const setupVar = (envJson ?? []).find((entry) => (entry.applies ?? "agent") !== "agent");
|
|
@@ -178,10 +178,10 @@ function assertNoSetupVarsOnHost(envJson, runtime, owner) {
|
|
|
178
178
|
return;
|
|
179
179
|
throw new Error(`${owner ? `${owner} ` : ""}env "${setupVar.name}": applies "${String(setupVar.applies)}" needs a container to set up, but Runtime.host() has none. Use applies "agent" or Runtime.devcontainer().`);
|
|
180
180
|
}
|
|
181
|
-
function
|
|
181
|
+
function compileConnectors2(connectors, owner) {
|
|
182
182
|
if (connectors === undefined || connectors.length === 0)
|
|
183
183
|
return;
|
|
184
|
-
const parsed =
|
|
184
|
+
const parsed = connectorIdsSchema2.safeParse([...connectors]);
|
|
185
185
|
if (!parsed.success) {
|
|
186
186
|
throw new Error(`${owner ? `${owner} ` : ""}environment connectors: ${parsed.error.issues.map((issue) => issue.message).join("; ")}`);
|
|
187
187
|
}
|
|
@@ -190,18 +190,18 @@ function compileConnectors(connectors, owner) {
|
|
|
190
190
|
function stepOwner(stepKey) {
|
|
191
191
|
return stepKey === undefined ? undefined : `Step "${stepKey}"`;
|
|
192
192
|
}
|
|
193
|
-
function
|
|
194
|
-
if (
|
|
193
|
+
function knownEnvironmentVars2(environment, compiled) {
|
|
194
|
+
if (isEnvironmentHandle2(environment))
|
|
195
195
|
return environment.content.vars ?? [];
|
|
196
196
|
if (compiled?.kind === "named")
|
|
197
197
|
return;
|
|
198
198
|
return compiled?.envJson ?? [];
|
|
199
199
|
}
|
|
200
|
-
function
|
|
200
|
+
function compileEnvironment2(environment, ctx = {}) {
|
|
201
201
|
if (typeof environment === "string") {
|
|
202
|
-
return { kind: "named", name:
|
|
202
|
+
return { kind: "named", name: environmentNameSchema2.parse(environment) };
|
|
203
203
|
}
|
|
204
|
-
if (
|
|
204
|
+
if (isEnvironmentHandle2(environment)) {
|
|
205
205
|
return { kind: "named", name: environment.name };
|
|
206
206
|
}
|
|
207
207
|
if (environment === undefined && ctx.defaultRuntime === undefined)
|
|
@@ -210,9 +210,9 @@ function compileEnvironment(environment, ctx = {}) {
|
|
|
210
210
|
throw new Error(`${stepOwner(ctx.stepKey) ?? "Inline environment"}: environments have no branch; use the step's repo baseBranch.`);
|
|
211
211
|
}
|
|
212
212
|
const runtime = environment?.runtime ?? ctx.defaultRuntime;
|
|
213
|
-
const envJson =
|
|
214
|
-
|
|
215
|
-
const connectors =
|
|
213
|
+
const envJson = normalizeEnv2(environment?.vars);
|
|
214
|
+
assertNoSetupVarsOnHost2(envJson, runtime, stepOwner(ctx.stepKey));
|
|
215
|
+
const connectors = compileConnectors2(environment !== undefined && "connectors" in environment ? environment.connectors : undefined, stepOwner(ctx.stepKey));
|
|
216
216
|
return {
|
|
217
217
|
kind: "inline",
|
|
218
218
|
...runtime === undefined ? {} : { runtime },
|
|
@@ -221,4 +221,4 @@ function compileEnvironment(environment, ctx = {}) {
|
|
|
221
221
|
};
|
|
222
222
|
}
|
|
223
223
|
|
|
224
|
-
export {
|
|
224
|
+
export { createPromptInputProxy2, createPromptTemplateContext2, renderPromptTemplate2, isSecretLookingEnvName2, Env2, normalizeEnv2, Runtime2, assertNoSetupVarsOnHost2, compileConnectors2, knownEnvironmentVars2, compileEnvironment2 };
|