@scarn/sdk 0.8.1 → 0.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/automations/define-automation.d.ts +20 -0
- package/dist/automations/index.d.ts +8 -0
- package/dist/automations/index.js +21 -0
- package/dist/automations/targets.d.ts +36 -0
- package/dist/automations/types.d.ts +116 -0
- package/dist/{chunk-dp86pa6m.js → chunk-01nfqm18.js} +5 -1
- package/dist/chunk-0vzq22dj.js +73 -0
- package/dist/chunk-11hbmexe.js +250 -0
- package/dist/{chunk-700xe701.js → chunk-3gy0cb5f.js} +5 -1
- package/dist/{chunk-102vfpw4.js → chunk-43y7tfn4.js} +33 -414
- package/dist/chunk-61jf8b6s.js +53 -0
- package/dist/chunk-76d1bwwz.js +119 -0
- package/dist/chunk-8z1wa3kd.js +109 -0
- package/dist/{chunk-p7yrcmqm.js → chunk-cnxaagfj.js} +2 -52
- package/dist/{chunk-cdanncng.js → chunk-ejzfdm1z.js} +21 -5
- package/dist/{chunk-gds7w7zh.js → chunk-fgfhvsee.js} +1 -4
- package/dist/{chunk-3ctaaseb.js → chunk-fyfvp6jx.js} +48 -21
- package/dist/{chunk-mz53r914.js → chunk-jj9pezwb.js} +22 -119
- package/dist/{chunk-vfeytkqx.js → chunk-wnfj3wyx.js} +106 -33
- package/dist/chunk-x0hjhqrf.js +416 -0
- package/dist/chunk-y11p1q7r.js +159 -0
- package/dist/client.js +6 -4
- package/dist/contracts/automation-document/index.d.ts +5 -0
- package/dist/contracts/automation-document/index.js +34 -0
- package/dist/contracts/automation-document/schema.d.ts +363 -0
- package/dist/contracts/pipeline-document/built-ins.d.ts +1 -1
- package/dist/contracts/pipeline-document/index.js +9 -7
- package/dist/contracts/pipeline-document/schema.d.ts +3 -3
- package/dist/contracts/work-item-changes.d.ts +51 -0
- package/dist/contracts/work-item-changes.js +68 -0
- package/dist/defaults/index.js +2 -2
- package/dist/definitions/automations/automations-client.d.ts +178 -0
- package/dist/definitions/automations/index.d.ts +1 -0
- package/dist/definitions/automations/index.js +12 -0
- package/dist/definitions/pipelines/index.d.ts +0 -1
- package/dist/definitions/pipelines/index.js +4 -12
- package/dist/definitions/pipelines/work-item-fields.d.ts +11 -22
- package/dist/definitions/steps/define-code-step.d.ts +3 -1
- package/dist/definitions/steps/define-step.d.ts +29 -1
- package/dist/definitions/steps/index.js +12 -7
- package/dist/definitions/steps/repo.d.ts +11 -3
- package/dist/definitions/steps/runtime.d.ts +11 -12
- package/dist/definitions/steps/step-definitions-client.d.ts +18 -0
- package/dist/definitions/steps/step-features.d.ts +2 -2
- package/dist/definitions/steps/step-handle.d.ts +8 -1
- package/dist/definitions/validation/index.js +2 -2
- package/dist/generated/index.d.ts +2 -2
- package/dist/generated/sdk.gen.d.ts +66 -11
- package/dist/generated/types.gen.d.ts +5513 -3488
- package/dist/index.d.ts +1 -0
- package/dist/index.js +61 -49
- package/dist/pipelines/define-pipeline.d.ts +7 -7
- package/dist/pipelines/handles.d.ts +0 -5
- package/dist/pipelines/index.js +7 -4
- package/dist/pipelines/types.d.ts +13 -1
- package/dist/push/collect-definitions.d.ts +3 -8
- package/dist/push/collect-pipeline-documents.d.ts +13 -3
- package/dist/push/index.d.ts +2 -2
- package/dist/push/index.js +90 -127
- package/dist/push/push-from-directory.d.ts +10 -6
- package/dist/repo-config.d.ts +14 -4
- package/dist/repo-config.js +5 -1
- package/dist/task-plane-client.d.ts +42 -0
- package/package.json +17 -1
- package/dist/chunk-zm72ksz0.js +0 -256
- package/dist/definitions/pipelines/define-default-pipeline-assignment.d.ts +0 -263
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
PipelineDefinitions,
|
|
4
|
+
createClient
|
|
5
|
+
} from "./chunk-wnfj3wyx.js";
|
|
6
|
+
import {
|
|
7
|
+
exports_external
|
|
8
|
+
} from "./chunk-skzxcba3.js";
|
|
9
|
+
|
|
10
|
+
// src/definitions/pipelines/pipeline-definitions-client.ts
|
|
11
|
+
var pipelineDocumentIssueSchema = exports_external.object({
|
|
12
|
+
code: exports_external.string(),
|
|
13
|
+
path: exports_external.string(),
|
|
14
|
+
message: exports_external.string(),
|
|
15
|
+
hint: exports_external.string().optional()
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
class PipelineDefinitionsApiError extends Error {
|
|
19
|
+
code;
|
|
20
|
+
issues;
|
|
21
|
+
constructor(error) {
|
|
22
|
+
super(error.detail ?? error.title ?? JSON.stringify(error));
|
|
23
|
+
this.name = "PipelineDefinitionsApiError";
|
|
24
|
+
this.code = error.code;
|
|
25
|
+
this.issues = documentIssuesOf(error.meta);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function documentIssuesOf(meta) {
|
|
29
|
+
const errors = meta?.["errors"];
|
|
30
|
+
if (!Array.isArray(errors))
|
|
31
|
+
return [];
|
|
32
|
+
return errors.flatMap((error) => {
|
|
33
|
+
const parsed = pipelineDocumentIssueSchema.safeParse(error);
|
|
34
|
+
return parsed.success ? [parsed.data] : [];
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function unwrap(result) {
|
|
38
|
+
if (result.error !== undefined) {
|
|
39
|
+
throw new PipelineDefinitionsApiError(result.error);
|
|
40
|
+
}
|
|
41
|
+
return result.data;
|
|
42
|
+
}
|
|
43
|
+
function createPipelineDefinitionsClient(baseUrl) {
|
|
44
|
+
const client = createClient({ baseUrl });
|
|
45
|
+
return buildPipelineDefinitionsClient(new PipelineDefinitions({ client }));
|
|
46
|
+
}
|
|
47
|
+
var buildPipelineDefinitionsClient = (pipelineDefinitions) => ({
|
|
48
|
+
listByProjectId: async (projectId, options) => unwrap(await pipelineDefinitions.listPipelineDefinitions({
|
|
49
|
+
path: { projectId },
|
|
50
|
+
headers: options?.headers
|
|
51
|
+
})),
|
|
52
|
+
get: async (pipelineDefinitionId, options) => unwrap(await pipelineDefinitions.getPipelineDefinition({
|
|
53
|
+
path: { pipelineDefinitionId },
|
|
54
|
+
headers: options?.headers
|
|
55
|
+
})),
|
|
56
|
+
create: async (input, options) => unwrap(await pipelineDefinitions.createPipelineDefinition({
|
|
57
|
+
body: input,
|
|
58
|
+
headers: options?.headers
|
|
59
|
+
})),
|
|
60
|
+
publishVersion: async (pipelineDefinitionId, document, options) => unwrap(await pipelineDefinitions.publishPipelineDefinitionVersion({
|
|
61
|
+
path: { pipelineDefinitionId },
|
|
62
|
+
body: { document },
|
|
63
|
+
headers: options?.headers
|
|
64
|
+
})),
|
|
65
|
+
activateVersion: async (pipelineDefinitionId, version, options) => unwrap(await pipelineDefinitions.activatePipelineDefinitionVersion({
|
|
66
|
+
path: { pipelineDefinitionId, version },
|
|
67
|
+
headers: options?.headers
|
|
68
|
+
})),
|
|
69
|
+
listVersions: async (pipelineDefinitionId, options) => unwrap(await pipelineDefinitions.listPipelineDefinitionVersions({
|
|
70
|
+
path: { pipelineDefinitionId },
|
|
71
|
+
headers: options?.headers
|
|
72
|
+
})),
|
|
73
|
+
getVersion: async (pipelineDefinitionId, version, options) => unwrap(await pipelineDefinitions.getPipelineDefinitionVersion({
|
|
74
|
+
path: { pipelineDefinitionId, version },
|
|
75
|
+
headers: options?.headers
|
|
76
|
+
}))
|
|
77
|
+
});
|
|
78
|
+
// src/definitions/pipelines/work-item-fields.ts
|
|
79
|
+
var WORK_ITEM_TOP_LEVEL_FIELDS = [
|
|
80
|
+
"id",
|
|
81
|
+
"projectId",
|
|
82
|
+
"platform",
|
|
83
|
+
"platformId",
|
|
84
|
+
"platformKey",
|
|
85
|
+
"url",
|
|
86
|
+
"title",
|
|
87
|
+
"description",
|
|
88
|
+
"sourceCreatedAt",
|
|
89
|
+
"sourceUpdatedAt",
|
|
90
|
+
"createdByUserId",
|
|
91
|
+
"parentWorkItemId",
|
|
92
|
+
"createdAt",
|
|
93
|
+
"updatedAt"
|
|
94
|
+
];
|
|
95
|
+
var WORK_ITEM_FIELDS_PATH_PREFIX = "fields.";
|
|
96
|
+
function resolveWorkItemFieldPath(record, path) {
|
|
97
|
+
if (typeof record !== "object" || record === null)
|
|
98
|
+
return;
|
|
99
|
+
const asRecord = record;
|
|
100
|
+
if (path.startsWith(WORK_ITEM_FIELDS_PATH_PREFIX)) {
|
|
101
|
+
const fieldName = path.slice(WORK_ITEM_FIELDS_PATH_PREFIX.length);
|
|
102
|
+
const fields = asRecord["fields"];
|
|
103
|
+
if (typeof fields !== "object" || fields === null)
|
|
104
|
+
return;
|
|
105
|
+
return fields[fieldName];
|
|
106
|
+
}
|
|
107
|
+
return asRecord[path];
|
|
108
|
+
}
|
|
109
|
+
export { PipelineDefinitionsApiError, createPipelineDefinitionsClient, WORK_ITEM_TOP_LEVEL_FIELDS, WORK_ITEM_FIELDS_PATH_PREFIX, resolveWorkItemFieldPath };
|
|
@@ -3,30 +3,6 @@ import {
|
|
|
3
3
|
exports_external
|
|
4
4
|
} from "./chunk-skzxcba3.js";
|
|
5
5
|
|
|
6
|
-
// src/contracts/pipeline-document/json.ts
|
|
7
|
-
function isJsonObject(value) {
|
|
8
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9
|
-
}
|
|
10
|
-
function escapePointerSegment(segment) {
|
|
11
|
-
return String(segment).replaceAll("~", "~0").replaceAll("/", "~1");
|
|
12
|
-
}
|
|
13
|
-
function jsonPointer(segments) {
|
|
14
|
-
return segments.map((segment) => `/${escapePointerSegment(segment)}`).join("");
|
|
15
|
-
}
|
|
16
|
-
function deepEqual(left, right) {
|
|
17
|
-
if (left === right) {
|
|
18
|
-
return true;
|
|
19
|
-
}
|
|
20
|
-
if (Array.isArray(left)) {
|
|
21
|
-
return Array.isArray(right) && left.length === right.length && left.every((item, index) => deepEqual(item, right[index]));
|
|
22
|
-
}
|
|
23
|
-
if (isJsonObject(left) && isJsonObject(right)) {
|
|
24
|
-
const leftKeys = Object.keys(left);
|
|
25
|
-
const rightKeys = Object.keys(right);
|
|
26
|
-
return leftKeys.length === rightKeys.length && leftKeys.every((key) => Object.hasOwn(right, key) && deepEqual(left[key], right[key]));
|
|
27
|
-
}
|
|
28
|
-
return false;
|
|
29
|
-
}
|
|
30
6
|
// src/contracts/pipeline-document/conditions/operators.ts
|
|
31
7
|
var COMPARISON_OPERATORS = [
|
|
32
8
|
"equal",
|
|
@@ -292,31 +268,5 @@ var pipelineDocumentSchema = exports_external.strictObject({
|
|
|
292
268
|
function pipelineDocumentJsonSchema() {
|
|
293
269
|
return exports_external.toJSONSchema(pipelineDocumentSchema, { io: "input" });
|
|
294
270
|
}
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
if (next === undefined) {
|
|
298
|
-
return [];
|
|
299
|
-
}
|
|
300
|
-
const entries = next.routes.map((route, index) => ({
|
|
301
|
-
kind: "route",
|
|
302
|
-
index,
|
|
303
|
-
route,
|
|
304
|
-
pointer: ["routes", index]
|
|
305
|
-
}));
|
|
306
|
-
if (next.otherwise !== undefined) {
|
|
307
|
-
entries.push({
|
|
308
|
-
kind: "otherwise",
|
|
309
|
-
index: 0,
|
|
310
|
-
route: next.otherwise,
|
|
311
|
-
pointer: ["otherwise"]
|
|
312
|
-
});
|
|
313
|
-
}
|
|
314
|
-
return entries;
|
|
315
|
-
}
|
|
316
|
-
function routeAt(next, kind, index) {
|
|
317
|
-
if (next === undefined) {
|
|
318
|
-
return;
|
|
319
|
-
}
|
|
320
|
-
return kind === "otherwise" ? next.otherwise : next.routes[index];
|
|
321
|
-
}
|
|
322
|
-
export { isJsonObject, jsonPointer, deepEqual, COMPARISON_OPERATORS, CONDITION_OPERATORS, COMPUTED_FUNCTIONS, ORDERING_OPERATORS, STRING_OPERATORS, DATE_OPERATORS, LIST_OPERATORS, NODE_ID_PATTERN, ALIAS_PATTERN, literalSchema, listSchema, argValueSchema, computedSourceSchema, conditionSchema, toleratedFailuresSchema, eachSchema, routeSchema, otherwiseSchema, startSchema, MATCH_MODES, nextSchema, retrySchema, catchSchema, stepNodeSchema, DEFAULT_MAX_TURNS, DECISION_BODY_MODES, decisionActionSchema, waitNodeSchema, succeedNodeSchema, failNodeSchema, nodeSchema, pipelineDocumentSchema, pipelineDocumentJsonSchema, routeEntries, routeAt };
|
|
271
|
+
|
|
272
|
+
export { COMPARISON_OPERATORS, CONDITION_OPERATORS, COMPUTED_FUNCTIONS, ORDERING_OPERATORS, STRING_OPERATORS, DATE_OPERATORS, LIST_OPERATORS, NODE_ID_PATTERN, ALIAS_PATTERN, literalSchema, listSchema, argValueSchema, computedSourceSchema, conditionSchema, toleratedFailuresSchema, eachSchema, routeSchema, otherwiseSchema, startSchema, MATCH_MODES, nextSchema, retrySchema, catchSchema, stepNodeSchema, DEFAULT_MAX_TURNS, DECISION_BODY_MODES, decisionActionSchema, waitNodeSchema, succeedNodeSchema, failNodeSchema, nodeSchema, pipelineDocumentSchema, pipelineDocumentJsonSchema };
|
|
@@ -7,22 +7,38 @@ import {
|
|
|
7
7
|
var MAX_REPO_COMMIT_MESSAGE_LENGTH = 500;
|
|
8
8
|
var REPO_COMMIT_MESSAGE_TOKEN_ROOTS = [
|
|
9
9
|
"input",
|
|
10
|
-
"result"
|
|
10
|
+
"result",
|
|
11
|
+
"workItem"
|
|
11
12
|
];
|
|
13
|
+
var REPO_COMMIT_MESSAGE_WORK_ITEM_KEYS = [
|
|
14
|
+
"title",
|
|
15
|
+
"platformKey"
|
|
16
|
+
];
|
|
17
|
+
function commitMessageUsesWorkItem(message) {
|
|
18
|
+
for (const match of message.matchAll(TOKEN_PATTERN)) {
|
|
19
|
+
if ((match[1] ?? "").split(".")[0] === "workItem")
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
12
24
|
var TOKEN_PATTERN = /\{\{([^}]+)\}\}/g;
|
|
13
25
|
function findDisallowedCommitMessageTokenRoots(message) {
|
|
14
26
|
const disallowed = [];
|
|
15
27
|
for (const match of message.matchAll(TOKEN_PATTERN)) {
|
|
16
|
-
const
|
|
17
|
-
|
|
28
|
+
const path = match[1] ?? "";
|
|
29
|
+
const [root = "", ...rest] = path.split(".");
|
|
30
|
+
if (!REPO_COMMIT_MESSAGE_TOKEN_ROOTS.includes(root)) {
|
|
18
31
|
disallowed.push(root);
|
|
32
|
+
} else if (root === "workItem" && (rest.length !== 1 || !REPO_COMMIT_MESSAGE_WORK_ITEM_KEYS.includes(rest[0] ?? ""))) {
|
|
33
|
+
disallowed.push(path);
|
|
34
|
+
}
|
|
19
35
|
}
|
|
20
36
|
return disallowed;
|
|
21
37
|
}
|
|
22
38
|
var repoCommitMessageSchema = exports_external.string().max(MAX_REPO_COMMIT_MESSAGE_LENGTH).refine((message) => !/[\r\n]/.test(message), {
|
|
23
39
|
message: "must be a single line"
|
|
24
40
|
}).refine((message) => findDisallowedCommitMessageTokenRoots(message).length === 0, {
|
|
25
|
-
message: `may only use {{${
|
|
41
|
+
message: `may only use {{input.\u2026}}, {{result.\u2026}}, {{${REPO_COMMIT_MESSAGE_WORK_ITEM_KEYS.map((key) => `workItem.${key}`).join("}} and {{")}}} tokens`
|
|
26
42
|
});
|
|
27
43
|
var onPushFailureSchema = exports_external.enum(["fail", "warn"]);
|
|
28
44
|
var repoConfigInputSchema = exports_external.discriminatedUnion("mode", [
|
|
@@ -71,4 +87,4 @@ function resolveRepoConfig(executionMode, input) {
|
|
|
71
87
|
};
|
|
72
88
|
}
|
|
73
89
|
|
|
74
|
-
export { MAX_REPO_COMMIT_MESSAGE_LENGTH, REPO_COMMIT_MESSAGE_TOKEN_ROOTS, findDisallowedCommitMessageTokenRoots, repoCommitMessageSchema, repoConfigInputSchema, repoConfigSchema, REPO_RUNTIME_SUPPORT, repoRuntimeMismatch, resolveRepoConfig };
|
|
90
|
+
export { MAX_REPO_COMMIT_MESSAGE_LENGTH, REPO_COMMIT_MESSAGE_TOKEN_ROOTS, REPO_COMMIT_MESSAGE_WORK_ITEM_KEYS, commitMessageUsesWorkItem, findDisallowedCommitMessageTokenRoots, repoCommitMessageSchema, repoConfigInputSchema, repoConfigSchema, REPO_RUNTIME_SUPPORT, repoRuntimeMismatch, resolveRepoConfig };
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
import {
|
|
13
13
|
repoConfigInputSchema,
|
|
14
14
|
repoRuntimeMismatch
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-ejzfdm1z.js";
|
|
16
16
|
import {
|
|
17
17
|
findArtifactMarkers
|
|
18
18
|
} from "./chunk-ngy1fdcx.js";
|
|
@@ -250,9 +250,6 @@ function checkManagedRuntime(step) {
|
|
|
250
250
|
if (!isManagedRuntimeId(step.managedRuntime)) {
|
|
251
251
|
problems.push(`unknown managed runtime; expected one of ${MANAGED_RUNTIME_IDS.join(", ")}`);
|
|
252
252
|
}
|
|
253
|
-
if (step.kind !== "code") {
|
|
254
|
-
problems.push("managed runtimes are only supported for code steps. Use Runtime.devcontainer() or Runtime.host() for defineStep");
|
|
255
|
-
}
|
|
256
253
|
if (step.executionMode === "no_workspace") {
|
|
257
254
|
problems.push('a managed runtime needs a workspace, but the step runs on the host (executionMode "no_workspace")');
|
|
258
255
|
}
|
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
// @bun
|
|
2
|
+
import {
|
|
3
|
+
collectEnvPlaceholderNames,
|
|
4
|
+
isEnvPlaceholderValue,
|
|
5
|
+
openCodeMcpLocalConfigSchema,
|
|
6
|
+
openCodeMcpRefConfigSchema,
|
|
7
|
+
openCodeMcpRemoteConfigSchema
|
|
8
|
+
} from "./chunk-e1h021kq.js";
|
|
9
|
+
import {
|
|
10
|
+
stepHealthChecksInputSchema,
|
|
11
|
+
toolHealthCheckSchema
|
|
12
|
+
} from "./chunk-63f90zky.js";
|
|
2
13
|
import {
|
|
3
14
|
makeHandle,
|
|
4
15
|
stepCall,
|
|
5
16
|
stepNode
|
|
6
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-jj9pezwb.js";
|
|
7
18
|
import {
|
|
8
19
|
ENV_VAR_NAME_PATTERN,
|
|
9
20
|
containsInputToken,
|
|
@@ -19,18 +30,11 @@ import {
|
|
|
19
30
|
import {
|
|
20
31
|
repoConfigInputSchema,
|
|
21
32
|
repoRuntimeMismatch
|
|
22
|
-
} from "./chunk-
|
|
23
|
-
import {
|
|
24
|
-
collectEnvPlaceholderNames,
|
|
25
|
-
isEnvPlaceholderValue,
|
|
26
|
-
openCodeMcpLocalConfigSchema,
|
|
27
|
-
openCodeMcpRefConfigSchema,
|
|
28
|
-
openCodeMcpRemoteConfigSchema
|
|
29
|
-
} from "./chunk-e1h021kq.js";
|
|
33
|
+
} from "./chunk-ejzfdm1z.js";
|
|
30
34
|
import {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
} from "./chunk-
|
|
35
|
+
StepDefinitions,
|
|
36
|
+
createClient
|
|
37
|
+
} from "./chunk-wnfj3wyx.js";
|
|
34
38
|
import {
|
|
35
39
|
buildArtifactMarker
|
|
36
40
|
} from "./chunk-ngy1fdcx.js";
|
|
@@ -39,11 +43,7 @@ import {
|
|
|
39
43
|
} from "./chunk-y2pv8d6a.js";
|
|
40
44
|
import {
|
|
41
45
|
BUILT_IN_ERRORS
|
|
42
|
-
} from "./chunk-
|
|
43
|
-
import {
|
|
44
|
-
StepDefinitions,
|
|
45
|
-
createClient
|
|
46
|
-
} from "./chunk-vfeytkqx.js";
|
|
46
|
+
} from "./chunk-01nfqm18.js";
|
|
47
47
|
import {
|
|
48
48
|
$brand,
|
|
49
49
|
$input,
|
|
@@ -736,7 +736,8 @@ function compileRepo(repo, runtime, ctx = {}) {
|
|
|
736
736
|
return;
|
|
737
737
|
const spec = typeof repo === "function" ? repo({
|
|
738
738
|
input: createPromptInputProxy(["input"]),
|
|
739
|
-
result: createPromptInputProxy(["result"])
|
|
739
|
+
result: createPromptInputProxy(["result"]),
|
|
740
|
+
workItem: createPromptInputProxy(["workItem"])
|
|
740
741
|
}) : repo;
|
|
741
742
|
const where = ctx.stepKey ? `Step "${ctx.stepKey}" repo` : "repo";
|
|
742
743
|
const executionMode = executionModeOf(runtime);
|
|
@@ -1174,6 +1175,21 @@ function compileStepRetry(stepKey, retry, errors) {
|
|
|
1174
1175
|
return { on: [...entry.on], maxAttempts: entry.maxAttempts };
|
|
1175
1176
|
});
|
|
1176
1177
|
}
|
|
1178
|
+
function compileStepMaxTurns(stepKey, maxTurns) {
|
|
1179
|
+
if (!Number.isInteger(maxTurns) || maxTurns <= 0) {
|
|
1180
|
+
throw new Error(`Step "${stepKey}": maxTurns must be a positive integer.`);
|
|
1181
|
+
}
|
|
1182
|
+
return maxTurns;
|
|
1183
|
+
}
|
|
1184
|
+
function compileStepConcurrency(stepKey, concurrency) {
|
|
1185
|
+
if (!Number.isInteger(concurrency.max) || concurrency.max < 1) {
|
|
1186
|
+
throw new Error(`Step "${stepKey}": concurrency max must be an integer of at least 1.`);
|
|
1187
|
+
}
|
|
1188
|
+
if (!Number.isInteger(concurrency.waiting) || concurrency.waiting < 0) {
|
|
1189
|
+
throw new Error(`Step "${stepKey}": concurrency waiting must be a non-negative integer.`);
|
|
1190
|
+
}
|
|
1191
|
+
return { max: concurrency.max, waiting: concurrency.waiting };
|
|
1192
|
+
}
|
|
1177
1193
|
function toStepHandle(spec) {
|
|
1178
1194
|
const node = stepNode(spec);
|
|
1179
1195
|
const call = stepCall(node);
|
|
@@ -1242,14 +1258,19 @@ ${feature._promptAddition}` : feature._promptAddition;
|
|
|
1242
1258
|
devcontainerConfigPath,
|
|
1243
1259
|
...managedRuntime !== null ? { managedRuntime } : {},
|
|
1244
1260
|
prompt: effectivePrompt,
|
|
1245
|
-
inputSchemaJson: config2.
|
|
1261
|
+
inputSchemaJson: config2.input ? toJSONSchema(config2.input) : null,
|
|
1246
1262
|
resultSchemaJson,
|
|
1247
1263
|
opencodeMcpJson: mcpFields.opencodeMcpJson,
|
|
1248
1264
|
healthChecksJson: mcpFields.healthChecksJson,
|
|
1249
1265
|
envJson: mcpFields.envJson,
|
|
1250
1266
|
...repo !== undefined ? { repo } : {},
|
|
1251
1267
|
errors: compileStepErrors(config2.key, config2.errors),
|
|
1252
|
-
retryJson: compileStepRetry(config2.key, config2.retry, config2.errors ?? [])
|
|
1268
|
+
retryJson: compileStepRetry(config2.key, config2.retry, config2.errors ?? []),
|
|
1269
|
+
...config2.maxTurns !== undefined ? { maxTurns: compileStepMaxTurns(config2.key, config2.maxTurns) } : {},
|
|
1270
|
+
...config2.concurrency !== undefined ? {
|
|
1271
|
+
concurrency: compileStepConcurrency(config2.key, config2.concurrency)
|
|
1272
|
+
} : {},
|
|
1273
|
+
...config2.workItemPermissions !== undefined ? { workItemPermissions: [...config2.workItemPermissions] } : {}
|
|
1253
1274
|
};
|
|
1254
1275
|
return toStepHandle(spec);
|
|
1255
1276
|
}
|
|
@@ -1289,6 +1310,9 @@ function codeStep(config2) {
|
|
|
1289
1310
|
...repo !== undefined ? { repo } : {},
|
|
1290
1311
|
errors: compileStepErrors(config2.key, config2.errors),
|
|
1291
1312
|
retryJson: compileStepRetry(config2.key, config2.retry, config2.errors ?? []),
|
|
1313
|
+
...config2.concurrency !== undefined ? {
|
|
1314
|
+
concurrency: compileStepConcurrency(config2.key, config2.concurrency)
|
|
1315
|
+
} : {},
|
|
1292
1316
|
entrypoint: { fn: config2.fn }
|
|
1293
1317
|
};
|
|
1294
1318
|
return toStepHandle(spec);
|
|
@@ -1343,6 +1367,9 @@ var buildStepDefinitionsClient = (stepDefinitions) => {
|
|
|
1343
1367
|
on: [...entry.on],
|
|
1344
1368
|
maxAttempts: entry.maxAttempts
|
|
1345
1369
|
})),
|
|
1370
|
+
maxTurns: spec.maxTurns ?? null,
|
|
1371
|
+
concurrency: spec.concurrency ?? null,
|
|
1372
|
+
workItemPermissions: [...spec.workItemPermissions ?? []],
|
|
1346
1373
|
status: spec.status,
|
|
1347
1374
|
projectId
|
|
1348
1375
|
};
|
|
@@ -1453,4 +1480,4 @@ var Notify = {
|
|
|
1453
1480
|
[NOTIFICATION_RESULT_KEY]: fragments.flatMap((fragment) => fragment[NOTIFICATION_RESULT_KEY])
|
|
1454
1481
|
})
|
|
1455
1482
|
};
|
|
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 };
|
|
1483
|
+
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, compileStepMaxTurns, compileStepConcurrency, toStepHandle, toStepSpec, defineStep, codeStep, createStepDefinitionsClient, Features, Notify };
|
|
@@ -1,121 +1,16 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const match = FRAME.exec(frame.trim());
|
|
15
|
-
if (match === null) {
|
|
16
|
-
return null;
|
|
17
|
-
}
|
|
18
|
-
const [, file, line, column] = match;
|
|
19
|
-
if (file === undefined || line === undefined || column === undefined) {
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
return { file: toPath(file), line: Number(line), column: Number(column) };
|
|
23
|
-
}
|
|
24
|
-
function captureSite(stack = new Error().stack) {
|
|
25
|
-
for (const frame of (stack ?? "").split(`
|
|
26
|
-
`).slice(1)) {
|
|
27
|
-
const site = parseFrame(frame);
|
|
28
|
-
if (site !== null && !site.file.startsWith(SDK_ROOT) && !site.file.startsWith("node:") && site.file.includes("/")) {
|
|
29
|
-
return site;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return null;
|
|
33
|
-
}
|
|
34
|
-
function cwd() {
|
|
35
|
-
const proc = globalThis.process;
|
|
36
|
-
return typeof proc?.cwd === "function" ? proc.cwd() : null;
|
|
37
|
-
}
|
|
38
|
-
function formatSite(site) {
|
|
39
|
-
if (site === null) {
|
|
40
|
-
return "<unknown>";
|
|
41
|
-
}
|
|
42
|
-
const base = cwd();
|
|
43
|
-
const file = base !== null && site.file.startsWith(`${base}/`) ? site.file.slice(base.length + 1) : site.file;
|
|
44
|
-
return `${file}:${String(site.line)}`;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// src/pipelines/errors.ts
|
|
48
|
-
function formatIssue(issue) {
|
|
49
|
-
return `${formatSite(issue.site)} (${issue.pointer === "" ? "/" : issue.pointer}): ${issue.message}`;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
class PipelineBuildError extends Error {
|
|
53
|
-
issues;
|
|
54
|
-
constructor(key, issues) {
|
|
55
|
-
super(`Pipeline "${key}" has ${String(issues.length)} build error${issues.length === 1 ? "" : "s"}:
|
|
56
|
-
${issues.map((issue) => ` ${formatIssue(issue)}`).join(`
|
|
57
|
-
`)}`);
|
|
58
|
-
this.name = "PipelineBuildError";
|
|
59
|
-
this.issues = issues;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
class AuthoringError extends Error {
|
|
64
|
-
site;
|
|
65
|
-
constructor(message, site = captureSite()) {
|
|
66
|
-
super(message);
|
|
67
|
-
this.name = "AuthoringError";
|
|
68
|
-
this.site = site;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// src/pipelines/registry.ts
|
|
73
|
-
var nodes = new WeakMap;
|
|
74
|
-
var targets = new WeakMap;
|
|
75
|
-
var eaches = new WeakMap;
|
|
76
|
-
var chains = new WeakMap;
|
|
77
|
-
var pendingChains = new Set;
|
|
78
|
-
function registerNode(value, node) {
|
|
79
|
-
nodes.set(value, node);
|
|
80
|
-
return value;
|
|
81
|
-
}
|
|
82
|
-
function registerTarget(value, target) {
|
|
83
|
-
targets.set(value, target);
|
|
84
|
-
return value;
|
|
85
|
-
}
|
|
86
|
-
function registerEach(value, each) {
|
|
87
|
-
eaches.set(value, each);
|
|
88
|
-
return value;
|
|
89
|
-
}
|
|
90
|
-
function registerChain(value, chain) {
|
|
91
|
-
chains.set(value, chain);
|
|
92
|
-
if (chain.next !== undefined) {
|
|
93
|
-
pendingChains.add(chain);
|
|
94
|
-
}
|
|
95
|
-
return value;
|
|
96
|
-
}
|
|
97
|
-
function isObject(value) {
|
|
98
|
-
return (typeof value === "object" || typeof value === "function") && value !== null;
|
|
99
|
-
}
|
|
100
|
-
function nodeOf(value) {
|
|
101
|
-
return isObject(value) ? nodes.get(value) : undefined;
|
|
102
|
-
}
|
|
103
|
-
function targetOf(value) {
|
|
104
|
-
return isObject(value) ? targets.get(value) : undefined;
|
|
105
|
-
}
|
|
106
|
-
function eachOf(value) {
|
|
107
|
-
return isObject(value) ? eaches.get(value) : undefined;
|
|
108
|
-
}
|
|
109
|
-
function chainOf(value) {
|
|
110
|
-
return isObject(value) ? chains.get(value) : undefined;
|
|
111
|
-
}
|
|
112
|
-
function requireNode(value, what) {
|
|
113
|
-
const node = nodeOf(value);
|
|
114
|
-
if (node === undefined) {
|
|
115
|
-
throw new AuthoringError(`${what} must be a step, decision or reply handle`);
|
|
116
|
-
}
|
|
117
|
-
return node;
|
|
118
|
-
}
|
|
2
|
+
import {
|
|
3
|
+
AuthoringError,
|
|
4
|
+
captureSite,
|
|
5
|
+
chainOf,
|
|
6
|
+
eachOf,
|
|
7
|
+
nodeOf,
|
|
8
|
+
registerChain,
|
|
9
|
+
registerNode,
|
|
10
|
+
registerTarget,
|
|
11
|
+
stepOn,
|
|
12
|
+
targetOf
|
|
13
|
+
} from "./chunk-y11p1q7r.js";
|
|
119
14
|
|
|
120
15
|
// src/pipelines/model.ts
|
|
121
16
|
function emptyChain(node) {
|
|
@@ -236,7 +131,15 @@ function checkArgs(node, args) {
|
|
|
236
131
|
function targetFn(node) {
|
|
237
132
|
return (args) => {
|
|
238
133
|
checkArgs(node, args);
|
|
239
|
-
|
|
134
|
+
const data = { node, args, site: captureSite() };
|
|
135
|
+
const value = { _tag: "pipeline_target", to: node.id };
|
|
136
|
+
if (node.kind === "step") {
|
|
137
|
+
Object.defineProperty(value, "on", {
|
|
138
|
+
value: stepOn(data),
|
|
139
|
+
enumerable: false
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
return registerTarget(Object.freeze(value), data);
|
|
240
143
|
};
|
|
241
144
|
}
|
|
242
145
|
function partialFn(node) {
|
|
@@ -297,4 +200,4 @@ function bareStepHandle(source, local) {
|
|
|
297
200
|
return stepHandleFor(stepNode(source, local));
|
|
298
201
|
}
|
|
299
202
|
|
|
300
|
-
export {
|
|
203
|
+
export { makeHandle, stepNode, stepCall, waitHandle, bareStepHandle };
|