@scarn/sdk 0.8.2 → 0.8.4
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-nb0nkt71.js → chunk-01nfqm18.js} +1 -0
- package/dist/chunk-0vzq22dj.js +73 -0
- package/dist/chunk-11hbmexe.js +250 -0
- package/dist/{chunk-2fn95pdd.js → chunk-3gy0cb5f.js} +5 -1
- package/dist/{chunk-qrasq5xe.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-x9788y82.js → chunk-hyaez4ee.js} +145 -16
- package/dist/{chunk-mz53r914.js → chunk-jj9pezwb.js} +22 -119
- package/dist/{chunk-8pyhrdgy.js → chunk-wnfj3wyx.js} +55 -11
- package/dist/chunk-x0hjhqrf.js +416 -0
- package/dist/chunk-y11p1q7r.js +159 -0
- package/dist/client.js +4 -2
- 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 +6 -4
- package/dist/contracts/work-item-changes.js +2 -2
- 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 +8 -5
- package/dist/definitions/steps/define-step.d.ts +22 -11
- package/dist/definitions/steps/index.js +13 -6
- 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 +105 -3
- package/dist/definitions/steps/step-features.d.ts +89 -6
- package/dist/definitions/steps/step-handle.d.ts +6 -1
- package/dist/definitions/validation/index.js +2 -2
- package/dist/generated/index.d.ts +2 -2
- package/dist/generated/sdk.gen.d.ts +38 -6
- package/dist/generated/types.gen.d.ts +3026 -1889
- package/dist/index.d.ts +1 -0
- package/dist/index.js +44 -30
- 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 +87 -124
- 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 +71 -1
- package/package.json +13 -1
- package/dist/chunk-ra53p0v8.js +0 -256
- package/dist/definitions/pipelines/define-default-pipeline-assignment.d.ts +0 -263
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { Automations } from "../../generated/sdk.gen";
|
|
3
|
+
import type { PutApiProjectsByProjectIdAutomationsByKeyResponses } from "../../generated/types.gen";
|
|
4
|
+
type RequestOptions = {
|
|
5
|
+
headers?: Record<string, unknown> | undefined;
|
|
6
|
+
};
|
|
7
|
+
export type PublishAutomationResult = PutApiProjectsByProjectIdAutomationsByKeyResponses[200];
|
|
8
|
+
export type Automation = PublishAutomationResult["automation"];
|
|
9
|
+
declare const automationDocumentIssueSchema: z.ZodObject<{
|
|
10
|
+
code: z.ZodString;
|
|
11
|
+
path: z.ZodString;
|
|
12
|
+
message: z.ZodString;
|
|
13
|
+
hint: z.ZodOptional<z.ZodString>;
|
|
14
|
+
}, z.core.$strip>;
|
|
15
|
+
/** One validation error the server reports for a rejected automation document. */
|
|
16
|
+
export type AutomationDocumentIssue = z.infer<typeof automationDocumentIssueSchema>;
|
|
17
|
+
type ApiError = {
|
|
18
|
+
title?: string;
|
|
19
|
+
detail?: string;
|
|
20
|
+
code?: string;
|
|
21
|
+
meta?: {
|
|
22
|
+
[key: string]: unknown;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Thrown when the API rejects a request. `issues` carries the per-path
|
|
27
|
+
* validation errors of an `AUTOMATION_DOCUMENT_INVALID` rejection.
|
|
28
|
+
*/
|
|
29
|
+
export declare class AutomationsApiError extends Error {
|
|
30
|
+
readonly code: string | undefined;
|
|
31
|
+
readonly issues: readonly AutomationDocumentIssue[];
|
|
32
|
+
constructor(error: ApiError);
|
|
33
|
+
}
|
|
34
|
+
export declare function createAutomationsClient(baseUrl: string): ReturnType<typeof buildAutomationsClient>;
|
|
35
|
+
declare const buildAutomationsClient: (automations: Automations) => {
|
|
36
|
+
listByProjectId: (projectId: string, options?: RequestOptions) => Promise<{
|
|
37
|
+
id: string;
|
|
38
|
+
projectId: string;
|
|
39
|
+
key: string;
|
|
40
|
+
title: string | unknown;
|
|
41
|
+
scope: "workItem" | "project";
|
|
42
|
+
enabled: boolean;
|
|
43
|
+
latestVersion: {
|
|
44
|
+
id: string;
|
|
45
|
+
version: number;
|
|
46
|
+
schemaVersion: number;
|
|
47
|
+
contentHash: string;
|
|
48
|
+
document: {
|
|
49
|
+
[key: string]: unknown;
|
|
50
|
+
};
|
|
51
|
+
publishedAt: string;
|
|
52
|
+
} | unknown;
|
|
53
|
+
createdAt: string;
|
|
54
|
+
updatedAt: string;
|
|
55
|
+
}[]>;
|
|
56
|
+
/**
|
|
57
|
+
* Publishes `document` as the automation's next version, creating the
|
|
58
|
+
* automation (disabled) when its key is new. `published` is false when it
|
|
59
|
+
* matched the latest version.
|
|
60
|
+
*/
|
|
61
|
+
publish: (projectId: string, key: string, document: Record<string, unknown>, options?: RequestOptions) => Promise<{
|
|
62
|
+
published: boolean;
|
|
63
|
+
automation: {
|
|
64
|
+
id: string;
|
|
65
|
+
projectId: string;
|
|
66
|
+
key: string;
|
|
67
|
+
title: string | unknown;
|
|
68
|
+
scope: "workItem" | "project";
|
|
69
|
+
enabled: boolean;
|
|
70
|
+
latestVersion: {
|
|
71
|
+
id: string;
|
|
72
|
+
version: number;
|
|
73
|
+
schemaVersion: number;
|
|
74
|
+
contentHash: string;
|
|
75
|
+
document: {
|
|
76
|
+
[key: string]: unknown;
|
|
77
|
+
};
|
|
78
|
+
publishedAt: string;
|
|
79
|
+
} | unknown;
|
|
80
|
+
createdAt: string;
|
|
81
|
+
updatedAt: string;
|
|
82
|
+
};
|
|
83
|
+
}>;
|
|
84
|
+
enable: (projectId: string, key: string, options?: RequestOptions) => Promise<{
|
|
85
|
+
id: string;
|
|
86
|
+
projectId: string;
|
|
87
|
+
key: string;
|
|
88
|
+
title: string | unknown;
|
|
89
|
+
scope: "workItem" | "project";
|
|
90
|
+
enabled: boolean;
|
|
91
|
+
latestVersion: {
|
|
92
|
+
id: string;
|
|
93
|
+
version: number;
|
|
94
|
+
schemaVersion: number;
|
|
95
|
+
contentHash: string;
|
|
96
|
+
document: {
|
|
97
|
+
[key: string]: unknown;
|
|
98
|
+
};
|
|
99
|
+
publishedAt: string;
|
|
100
|
+
} | unknown;
|
|
101
|
+
createdAt: string;
|
|
102
|
+
updatedAt: string;
|
|
103
|
+
}>;
|
|
104
|
+
disable: (projectId: string, key: string, options?: RequestOptions) => Promise<{
|
|
105
|
+
id: string;
|
|
106
|
+
projectId: string;
|
|
107
|
+
key: string;
|
|
108
|
+
title: string | unknown;
|
|
109
|
+
scope: "workItem" | "project";
|
|
110
|
+
enabled: boolean;
|
|
111
|
+
latestVersion: {
|
|
112
|
+
id: string;
|
|
113
|
+
version: number;
|
|
114
|
+
schemaVersion: number;
|
|
115
|
+
contentHash: string;
|
|
116
|
+
document: {
|
|
117
|
+
[key: string]: unknown;
|
|
118
|
+
};
|
|
119
|
+
publishedAt: string;
|
|
120
|
+
} | unknown;
|
|
121
|
+
createdAt: string;
|
|
122
|
+
updatedAt: string;
|
|
123
|
+
}>;
|
|
124
|
+
listForWorkItem: (workItemId: string, options?: RequestOptions) => Promise<{
|
|
125
|
+
workItemId: string;
|
|
126
|
+
automation: {
|
|
127
|
+
id: string;
|
|
128
|
+
projectId: string;
|
|
129
|
+
key: string;
|
|
130
|
+
title: string | unknown;
|
|
131
|
+
scope: "workItem" | "project";
|
|
132
|
+
enabled: boolean;
|
|
133
|
+
latestVersion: {
|
|
134
|
+
id: string;
|
|
135
|
+
version: number;
|
|
136
|
+
schemaVersion: number;
|
|
137
|
+
contentHash: string;
|
|
138
|
+
document: {
|
|
139
|
+
[key: string]: unknown;
|
|
140
|
+
};
|
|
141
|
+
publishedAt: string;
|
|
142
|
+
} | unknown;
|
|
143
|
+
createdAt: string;
|
|
144
|
+
updatedAt: string;
|
|
145
|
+
};
|
|
146
|
+
attachedByUserId: string;
|
|
147
|
+
attachedAt: string;
|
|
148
|
+
}[]>;
|
|
149
|
+
attach: (workItemId: string, key: string, options?: RequestOptions) => Promise<{
|
|
150
|
+
workItemId: string;
|
|
151
|
+
automation: {
|
|
152
|
+
id: string;
|
|
153
|
+
projectId: string;
|
|
154
|
+
key: string;
|
|
155
|
+
title: string | unknown;
|
|
156
|
+
scope: "workItem" | "project";
|
|
157
|
+
enabled: boolean;
|
|
158
|
+
latestVersion: {
|
|
159
|
+
id: string;
|
|
160
|
+
version: number;
|
|
161
|
+
schemaVersion: number;
|
|
162
|
+
contentHash: string;
|
|
163
|
+
document: {
|
|
164
|
+
[key: string]: unknown;
|
|
165
|
+
};
|
|
166
|
+
publishedAt: string;
|
|
167
|
+
} | unknown;
|
|
168
|
+
createdAt: string;
|
|
169
|
+
updatedAt: string;
|
|
170
|
+
};
|
|
171
|
+
attachedByUserId: string;
|
|
172
|
+
attachedAt: string;
|
|
173
|
+
}>;
|
|
174
|
+
detach: (workItemId: string, key: string, options?: RequestOptions) => Promise<{
|
|
175
|
+
detached: boolean;
|
|
176
|
+
}>;
|
|
177
|
+
};
|
|
178
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./automations-client";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
AutomationsApiError,
|
|
4
|
+
createAutomationsClient
|
|
5
|
+
} from "../../chunk-0vzq22dj.js";
|
|
6
|
+
import"../../chunk-wnfj3wyx.js";
|
|
7
|
+
import"../../chunk-skzxcba3.js";
|
|
8
|
+
import"../../chunk-y64skrwp.js";
|
|
9
|
+
export {
|
|
10
|
+
AutomationsApiError,
|
|
11
|
+
createAutomationsClient
|
|
12
|
+
};
|
|
@@ -1,26 +1,18 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
|
-
DEFAULT_PIPELINE_ASSIGNMENT_FILENAME,
|
|
4
3
|
PipelineDefinitionsApiError,
|
|
5
4
|
WORK_ITEM_FIELDS_PATH_PREFIX,
|
|
6
5
|
WORK_ITEM_TOP_LEVEL_FIELDS,
|
|
7
6
|
createPipelineDefinitionsClient,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
serializeDefaultPipelineAssignment
|
|
12
|
-
} from "../../chunk-ra53p0v8.js";
|
|
13
|
-
import"../../chunk-8pyhrdgy.js";
|
|
7
|
+
resolveWorkItemFieldPath
|
|
8
|
+
} from "../../chunk-8z1wa3kd.js";
|
|
9
|
+
import"../../chunk-wnfj3wyx.js";
|
|
14
10
|
import"../../chunk-skzxcba3.js";
|
|
15
11
|
import"../../chunk-y64skrwp.js";
|
|
16
12
|
export {
|
|
17
|
-
DEFAULT_PIPELINE_ASSIGNMENT_FILENAME,
|
|
18
13
|
PipelineDefinitionsApiError,
|
|
19
14
|
WORK_ITEM_FIELDS_PATH_PREFIX,
|
|
20
15
|
WORK_ITEM_TOP_LEVEL_FIELDS,
|
|
21
16
|
createPipelineDefinitionsClient,
|
|
22
|
-
|
|
23
|
-
isDefaultPipelineAssignmentSpec,
|
|
24
|
-
resolveWorkItemFieldPath,
|
|
25
|
-
serializeDefaultPipelineAssignment
|
|
17
|
+
resolveWorkItemFieldPath
|
|
26
18
|
};
|
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
import type { GetApiWorkItemsByWorkItemIdResponses } from "../../generated/types.gen";
|
|
2
2
|
/**
|
|
3
|
-
* Top-level work-item properties
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* (`default-pipeline-assignment-file-generator.ts`). `fields` is deliberately excluded from this
|
|
7
|
-
* list: it's reached via `.field(name)` on every one of those accessors, not
|
|
8
|
-
* as a top-level property.
|
|
3
|
+
* Top-level work-item properties a server-side resolver publishes. `fields`
|
|
4
|
+
* is deliberately excluded from this list: it's reached via
|
|
5
|
+
* `fields.<name>` paths, not as a top-level property.
|
|
9
6
|
*
|
|
10
7
|
* This is the single source of truth for the list — it must stay in sync
|
|
11
|
-
* with the `workItem`
|
|
12
|
-
*
|
|
13
|
-
* `evaluate-default-pipeline-assignment.ts`; `buildResolvedWorkItemContext`
|
|
14
|
-
* in `resolve-node-input.ts`).
|
|
8
|
+
* with the `workItem` context shape the server-side resolver publishes
|
|
9
|
+
* (`buildResolvedWorkItemContext` in `resolve-node-input.ts`).
|
|
15
10
|
*/
|
|
16
11
|
export declare const WORK_ITEM_TOP_LEVEL_FIELDS: readonly ["id", "projectId", "platform", "platformId", "platformKey", "url", "title", "description", "sourceCreatedAt", "sourceUpdatedAt", "createdByUserId", "parentWorkItemId", "createdAt", "updatedAt"];
|
|
17
12
|
export type WorkItemTopLevelField = (typeof WORK_ITEM_TOP_LEVEL_FIELDS)[number];
|
|
@@ -25,9 +20,8 @@ export type WorkItemTopLevelField = (typeof WORK_ITEM_TOP_LEVEL_FIELDS)[number];
|
|
|
25
20
|
type WorkItemPlatformLiteral = GetApiWorkItemsByWorkItemIdResponses[200]["platform"];
|
|
26
21
|
/**
|
|
27
22
|
* Per-field value types for every member of `WORK_ITEM_TOP_LEVEL_FIELDS`,
|
|
28
|
-
* mirroring exactly what the server-side
|
|
29
|
-
*
|
|
30
|
-
* `buildResolvedWorkItemContext` for regular pipeline/step input bindings).
|
|
23
|
+
* mirroring exactly what the server-side resolver publishes at resolution
|
|
24
|
+
* time (`buildResolvedWorkItemContext` for pipeline/step input bindings).
|
|
31
25
|
* Notably, `sourceCreatedAt`/`sourceUpdatedAt`/`createdAt`/`updatedAt` are
|
|
32
26
|
* serialized as ISO date strings (or `null`), never `Date` objects.
|
|
33
27
|
*/
|
|
@@ -50,11 +44,8 @@ export type WorkItemTopLevelFieldTypeMap = {
|
|
|
50
44
|
/**
|
|
51
45
|
* The path prefix marking a reference into a work item's platform-specific
|
|
52
46
|
* `fields` bag (a Jira custom field, a GitHub label, etc.), as opposed to a
|
|
53
|
-
* `WorkItemTopLevelField`. Shared by every
|
|
54
|
-
* (`
|
|
55
|
-
* reads them back (`resolveWorkItemFieldPath` below; the JSONPath-rooted
|
|
56
|
-
* variant in `evaluate-default-pipeline-assignment.ts`, which layers a `$.`
|
|
57
|
-
* prefix on top of this same convention).
|
|
47
|
+
* `WorkItemTopLevelField`. Shared by every resolver that reads these paths
|
|
48
|
+
* (`resolveWorkItemFieldPath` below).
|
|
58
49
|
*/
|
|
59
50
|
export declare const WORK_ITEM_FIELDS_PATH_PREFIX = "fields.";
|
|
60
51
|
/**
|
|
@@ -75,10 +66,8 @@ export declare const WORK_ITEM_FIELDS_PATH_PREFIX = "fields.";
|
|
|
75
66
|
* This resolver sidesteps that hazard entirely: everything after `fields.`
|
|
76
67
|
* is treated as one atomic, unsplit key. Every work-item path resolver in
|
|
77
68
|
* the codebase must use this same convention for a field name to round-trip
|
|
78
|
-
* correctly — see `
|
|
79
|
-
*
|
|
80
|
-
* this function) and `resolve-node-input.ts`'s `work_item` binding
|
|
81
|
-
* resolution (which calls this function directly, replacing what used to be
|
|
69
|
+
* correctly — see `resolve-node-input.ts`'s `work_item` binding resolution
|
|
70
|
+
* (which calls this function directly, replacing what used to be
|
|
82
71
|
* a dot-splitting walker shared with unrelated binding sources and
|
|
83
72
|
* susceptible to the exact hazard described above).
|
|
84
73
|
*
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { ZodType } from "zod";
|
|
2
|
-
import type { EffectiveResult, StepRetryEntry } from "./define-step";
|
|
2
|
+
import type { EffectiveResult, StepConcurrency, StepRetryEntry } from "./define-step";
|
|
3
3
|
import type { BuiltInError } from "../../pipelines/types";
|
|
4
4
|
import { type StepHandle } from "./step-handle";
|
|
5
5
|
import { type CodeStepEnvironment } from "./runtime";
|
|
6
|
-
import type {
|
|
6
|
+
import type { CodeStepFeature } from "./step-features";
|
|
7
7
|
/** What the worker passes a code step besides its input. */
|
|
8
8
|
export type CodeStepContext = {
|
|
9
9
|
/**
|
|
@@ -14,7 +14,7 @@ export type CodeStepContext = {
|
|
|
14
14
|
artifactsDir: string;
|
|
15
15
|
};
|
|
16
16
|
export type CodeStepFn<TInput, TResult> = (input: TInput, context: CodeStepContext) => TResult | Promise<TResult>;
|
|
17
|
-
export type DefineCodeStepInput<TInput extends ZodType = ZodType, TResult extends ZodType = ZodType, TFeatures extends ReadonlyArray<
|
|
17
|
+
export type DefineCodeStepInput<TInput extends ZodType = ZodType, TResult extends ZodType = ZodType, TFeatures extends ReadonlyArray<CodeStepFeature> = never[]> = {
|
|
18
18
|
key: string;
|
|
19
19
|
name: string;
|
|
20
20
|
description?: string | null;
|
|
@@ -38,7 +38,8 @@ export type DefineCodeStepInput<TInput extends ZodType = ZodType, TResult extend
|
|
|
38
38
|
/**
|
|
39
39
|
* Step features to attach — unlike `defineStep()`, only each feature's
|
|
40
40
|
* `_resultExtension` applies here (there is no prompt to append
|
|
41
|
-
* to on a `kind: "code"` step).
|
|
41
|
+
* to on a `kind: "code"` step). `Features.workItems.*` is rejected: a code
|
|
42
|
+
* step has no agent tools to use a grant with.
|
|
42
43
|
*/
|
|
43
44
|
features?: TFeatures;
|
|
44
45
|
/**
|
|
@@ -67,6 +68,8 @@ export type DefineCodeStepInput<TInput extends ZodType = ZodType, TResult extend
|
|
|
67
68
|
errors?: readonly string[];
|
|
68
69
|
/** As `defineStep()`'s `retry`: how a standalone Task of this step retries. */
|
|
69
70
|
retry?: readonly StepRetryEntry[];
|
|
71
|
+
/** As `defineStep()`'s `concurrency`: the per-work-item concurrency limit. */
|
|
72
|
+
concurrency?: StepConcurrency;
|
|
70
73
|
};
|
|
71
74
|
/**
|
|
72
75
|
* Defines a `kind: "code"` step: a plain function instead of an LLM
|
|
@@ -75,7 +78,7 @@ export type DefineCodeStepInput<TInput extends ZodType = ZodType, TResult extend
|
|
|
75
78
|
* `entrypoint.fn` reference attached instead — see `StepDefinitionSpec`'s
|
|
76
79
|
* own doc comment for what happens to it during collection.
|
|
77
80
|
*/
|
|
78
|
-
export declare function codeStep<TInput extends ZodType = ZodType, TResult extends ZodType = ZodType, const TFeatures extends ReadonlyArray<
|
|
81
|
+
export declare function codeStep<TInput extends ZodType = ZodType, TResult extends ZodType = ZodType, const TFeatures extends ReadonlyArray<CodeStepFeature> = never[], const TErrors extends string = never>(config: Omit<DefineCodeStepInput<TInput, TResult, TFeatures>, "errors" | "retry"> & {
|
|
79
82
|
errors?: readonly TErrors[];
|
|
80
83
|
retry?: readonly {
|
|
81
84
|
on: readonly (BuiltInError | TErrors)[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ZodType } from "zod";
|
|
2
|
-
import type { AnyStepFeature, FeatureResultExtensions } from "./step-features";
|
|
2
|
+
import type { AnyStepFeature, FeatureResultExtensions, Grant } from "./step-features";
|
|
3
3
|
import { type PromptTemplateContext } from "./prompt-template";
|
|
4
4
|
import { type HealthChecksInput, type StepHealthChecksInput } from "../../health-checks";
|
|
5
5
|
import type { OpenCodeMcpServers } from "../../opencode-mcp";
|
|
@@ -9,7 +9,6 @@ import type { EnvRecord, PromptEnvContext } from "./env";
|
|
|
9
9
|
import { type StepEnvironment } from "./runtime";
|
|
10
10
|
import type { McpHandle } from "./define-mcp";
|
|
11
11
|
import type { BuiltInError, ConversationResult } from "../../pipelines/types";
|
|
12
|
-
import type { PutApiStepDefinitionsData } from "../../generated/types.gen";
|
|
13
12
|
import { type StepHandle } from "./step-handle";
|
|
14
13
|
type Prettify<T> = {
|
|
15
14
|
[K in keyof T]: T[K];
|
|
@@ -60,11 +59,18 @@ export type DefineStepInput<TInput extends ZodType = ZodType, TResult extends Zo
|
|
|
60
59
|
* `.settings({ maxTurns })` instead.
|
|
61
60
|
*/
|
|
62
61
|
maxTurns?: number;
|
|
63
|
-
/**
|
|
64
|
-
|
|
62
|
+
/**
|
|
63
|
+
* How many live Tasks of this step may run on one work item (`max`), and
|
|
64
|
+
* how many more may wait for a slot (`waiting`). Anything past that is
|
|
65
|
+
* dropped. Omitted means no limit. Pipeline nodes can't override it.
|
|
66
|
+
*/
|
|
67
|
+
concurrency?: StepConcurrency;
|
|
68
|
+
};
|
|
69
|
+
/** A step's per-work-item concurrency limit. */
|
|
70
|
+
export type StepConcurrency = {
|
|
71
|
+
max: number;
|
|
72
|
+
waiting: number;
|
|
65
73
|
};
|
|
66
|
-
/** A work item permission a step's Tasks may be granted. */
|
|
67
|
-
export type WorkItemPermission = NonNullable<PutApiStepDefinitionsData["body"]["workItemPermissions"]>[number];
|
|
68
74
|
/** One `retry` entry: the same shape as a pipeline node's `retry`. */
|
|
69
75
|
export type StepRetryEntry = {
|
|
70
76
|
on: readonly string[];
|
|
@@ -117,8 +123,13 @@ export type StepDefinitionSpec = {
|
|
|
117
123
|
retryJson?: StepRetryEntry[];
|
|
118
124
|
/** How many times a standalone Task of this step may hand over; omitted means the server default. */
|
|
119
125
|
maxTurns?: number;
|
|
120
|
-
/**
|
|
121
|
-
|
|
126
|
+
/** The step's per-work-item concurrency limit; omitted means no limit. */
|
|
127
|
+
concurrency?: StepConcurrency;
|
|
128
|
+
/**
|
|
129
|
+
* What the step's Tasks may do to work items, from its
|
|
130
|
+
* `Features.workItems.*` features. Every Task may also read its own.
|
|
131
|
+
*/
|
|
132
|
+
grants?: readonly Grant[];
|
|
122
133
|
/**
|
|
123
134
|
* `kind === "code"` only: the live function of a spec produced by
|
|
124
135
|
* `codeStep()`. Code-step discovery (`findCodeStepInModule`) reads it to
|
|
@@ -137,10 +148,10 @@ export type StepDefinitionSpec = {
|
|
|
137
148
|
export type EffectiveResult<TResult, TFeatures extends ReadonlyArray<AnyStepFeature>> = Prettify<TResult & FeatureResultExtensions<TFeatures>>;
|
|
138
149
|
/**
|
|
139
150
|
* A `defineStep` handle's result type: `ConversationResult` when the step has
|
|
140
|
-
* no `result` and no
|
|
141
|
-
* result.
|
|
151
|
+
* no `result` and no feature adds result fields (a conversation step), else
|
|
152
|
+
* its effective result.
|
|
142
153
|
*/
|
|
143
|
-
export type DefineStepResult<TResult extends ZodType, TFeatures extends ReadonlyArray<AnyStepFeature>> = ZodType extends TResult ? [TFeatures
|
|
154
|
+
export type DefineStepResult<TResult extends ZodType, TFeatures extends ReadonlyArray<AnyStepFeature>> = ZodType extends TResult ? [keyof FeatureResultExtensions<TFeatures>] extends [never] ? ConversationResult : EffectiveResult<TResult["_output"], TFeatures> : EffectiveResult<TResult["_output"], TFeatures>;
|
|
144
155
|
export declare function defineStep<TInput extends ZodType = ZodType, TResult extends ZodType = ZodType, const TFeatures extends ReadonlyArray<AnyStepFeature> = never[], TEnv extends EnvRecord = EnvRecord, const TErrors extends string = never>(config: Omit<DefineStepInput<TInput, TResult, TEnv>, "features" | "errors" | "retry"> & {
|
|
145
156
|
features?: TFeatures;
|
|
146
157
|
errors?: readonly TErrors[];
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
compileEnvironment,
|
|
14
14
|
compileMcps,
|
|
15
15
|
compileRepo,
|
|
16
|
+
compileStepConcurrency,
|
|
16
17
|
compileStepErrors,
|
|
17
18
|
compileStepMaxTurns,
|
|
18
19
|
compileStepRetry,
|
|
@@ -22,6 +23,8 @@ import {
|
|
|
22
23
|
defineMcp,
|
|
23
24
|
defineStep,
|
|
24
25
|
exports_z,
|
|
26
|
+
grantActionValues,
|
|
27
|
+
grantScopeValues,
|
|
25
28
|
isMcpHandle,
|
|
26
29
|
isSecretLookingEnvName,
|
|
27
30
|
normalizeArtifactAccept,
|
|
@@ -30,18 +33,19 @@ import {
|
|
|
30
33
|
resolveMcpChecks,
|
|
31
34
|
toStepHandle,
|
|
32
35
|
toStepSpec
|
|
33
|
-
} from "../../chunk-
|
|
36
|
+
} from "../../chunk-hyaez4ee.js";
|
|
37
|
+
import"../../chunk-e1h021kq.js";
|
|
34
38
|
import"../../chunk-63f90zky.js";
|
|
35
|
-
import"../../chunk-
|
|
39
|
+
import"../../chunk-jj9pezwb.js";
|
|
40
|
+
import"../../chunk-y11p1q7r.js";
|
|
36
41
|
import"../../chunk-5zsavw98.js";
|
|
37
42
|
import"../../chunk-4ggr8af6.js";
|
|
38
43
|
import"../../chunk-k4y5qt4y.js";
|
|
39
|
-
import"../../chunk-
|
|
40
|
-
import"../../chunk-
|
|
41
|
-
import"../../chunk-8pyhrdgy.js";
|
|
44
|
+
import"../../chunk-ejzfdm1z.js";
|
|
45
|
+
import"../../chunk-wnfj3wyx.js";
|
|
42
46
|
import"../../chunk-ngy1fdcx.js";
|
|
43
47
|
import"../../chunk-y2pv8d6a.js";
|
|
44
|
-
import"../../chunk-
|
|
48
|
+
import"../../chunk-01nfqm18.js";
|
|
45
49
|
import"../../chunk-skzxcba3.js";
|
|
46
50
|
import"../../chunk-y64skrwp.js";
|
|
47
51
|
export {
|
|
@@ -58,6 +62,7 @@ export {
|
|
|
58
62
|
compileEnvironment,
|
|
59
63
|
compileMcps,
|
|
60
64
|
compileRepo,
|
|
65
|
+
compileStepConcurrency,
|
|
61
66
|
compileStepErrors,
|
|
62
67
|
compileStepMaxTurns,
|
|
63
68
|
compileStepRetry,
|
|
@@ -66,6 +71,8 @@ export {
|
|
|
66
71
|
createStepDefinitionsClient,
|
|
67
72
|
defineMcp,
|
|
68
73
|
defineStep,
|
|
74
|
+
grantActionValues,
|
|
75
|
+
grantScopeValues,
|
|
69
76
|
isMcpHandle,
|
|
70
77
|
isSecretLookingEnvName,
|
|
71
78
|
normalizeArtifactAccept,
|
|
@@ -17,22 +17,30 @@ export type ReadOnlyRepoSpec = {
|
|
|
17
17
|
export type ReadWriteRepoSpec = {
|
|
18
18
|
readonly mode: "readWrite";
|
|
19
19
|
/**
|
|
20
|
-
* Commit message template; `{{input.…}}
|
|
21
|
-
*
|
|
20
|
+
* Commit message template; `{{input.…}}`, `{{result.…}}`,
|
|
21
|
+
* `{{workItem.title}}` and `{{workItem.platformKey}}` tokens only, one line,
|
|
22
|
+
* at most 500 characters. Defaults to `scarn: task <taskId>`.
|
|
22
23
|
*/
|
|
23
24
|
readonly message?: string;
|
|
24
25
|
/** Defaults to `"fail"`: a failed push fails the step. */
|
|
25
26
|
readonly onPushFailure?: "fail" | "warn";
|
|
26
27
|
};
|
|
27
28
|
export type RepoSpec = NoneRepoSpec | ReadOnlyRepoSpec | ReadWriteRepoSpec;
|
|
28
|
-
/** What `Runtime.devcontainer()`
|
|
29
|
+
/** What `Runtime.devcontainer()` and `Runtime.managed.<id>()` accept. */
|
|
29
30
|
export type DevcontainerRepoSpec = ReadOnlyRepoSpec | ReadWriteRepoSpec;
|
|
30
31
|
/** What `Runtime.host()` accepts. */
|
|
31
32
|
export type HostRepoSpec = NoneRepoSpec;
|
|
32
33
|
/** Runs once at definition time, against the same proxies `agentPrompt` and `vars` use. */
|
|
34
|
+
/** The work item values a commit message may name, read live at commit time. */
|
|
35
|
+
export type CommitMessageWorkItem = {
|
|
36
|
+
title: string;
|
|
37
|
+
platformKey: string;
|
|
38
|
+
};
|
|
33
39
|
export type RepoFn<TInput, TResult, TSpec extends RepoSpec> = (context: {
|
|
34
40
|
input: PromptInputProxy<TInput>;
|
|
35
41
|
result: PromptInputProxy<TResult>;
|
|
42
|
+
/** The Task's work item: `{{workItem.title}}` and `{{workItem.platformKey}}`. */
|
|
43
|
+
workItem: PromptInputProxy<CommitMessageWorkItem>;
|
|
36
44
|
}) => TSpec;
|
|
37
45
|
export type RepoField<TInput, TResult, TSpec extends RepoSpec> = TSpec | RepoFn<TInput, TResult, TSpec>;
|
|
38
46
|
export type ReadWriteRepoOpts = Omit<ReadWriteRepoSpec, "mode">;
|
|
@@ -17,8 +17,8 @@ export type HostRuntimeSpec = {
|
|
|
17
17
|
readonly kind: "host";
|
|
18
18
|
};
|
|
19
19
|
/**
|
|
20
|
-
* A worker-supplied container (image
|
|
21
|
-
*
|
|
20
|
+
* A worker-supplied container (image and config owned by the worker). Build one
|
|
21
|
+
* with `Runtime.managed.<id>()`. Works with `codeStep` and `defineStep`.
|
|
22
22
|
*/
|
|
23
23
|
export type ManagedRuntimeSpec<TId extends ManagedRuntimeId = ManagedRuntimeId> = {
|
|
24
24
|
readonly kind: "managed";
|
|
@@ -28,15 +28,15 @@ export type RuntimeSpec = DevcontainerRuntimeSpec | HostRuntimeSpec | ManagedRun
|
|
|
28
28
|
/**
|
|
29
29
|
* How a step runs: its `runtime`, its environment `vars` and its `repo` access.
|
|
30
30
|
* A union on the runtime kind, so a `repo` the runtime cannot honor is a type
|
|
31
|
-
* error: a host step takes only `Repo.none()`, a devcontainer step
|
|
32
|
-
* `Repo.readOnly()` or `Repo.readWrite()`.
|
|
31
|
+
* error: a host step takes only `Repo.none()`, a devcontainer or managed step
|
|
32
|
+
* takes `Repo.readOnly()` or `Repo.readWrite()`.
|
|
33
33
|
*
|
|
34
34
|
* Declare `vars` before `agentPrompt` so `TEnv` is inferred into the prompt's
|
|
35
35
|
* `env`, which is then strict: only declared, non-secret keys.
|
|
36
36
|
*/
|
|
37
37
|
export type StepEnvironment<TInput, TEnv extends EnvRecord = EnvRecord, TResult = unknown> = {
|
|
38
38
|
/** Defaults to `Runtime.devcontainer()`. */
|
|
39
|
-
runtime?: DevcontainerRuntimeSpec;
|
|
39
|
+
runtime?: DevcontainerRuntimeSpec | ManagedRuntimeSpec;
|
|
40
40
|
vars?: EnvFn<TInput, TEnv>;
|
|
41
41
|
/** Defaults to `Repo.readWrite()`. */
|
|
42
42
|
repo?: RepoField<TInput, TResult, DevcontainerRepoSpec>;
|
|
@@ -47,9 +47,8 @@ export type StepEnvironment<TInput, TEnv extends EnvRecord = EnvRecord, TResult
|
|
|
47
47
|
repo?: RepoField<TInput, TResult, HostRepoSpec>;
|
|
48
48
|
};
|
|
49
49
|
/**
|
|
50
|
-
* `codeStep`'s environment: `StepEnvironment`'s
|
|
51
|
-
*
|
|
52
|
-
* host runtime has none.
|
|
50
|
+
* `codeStep`'s environment: `StepEnvironment`'s workspace variant. A code step
|
|
51
|
+
* runs repo code, which needs a clone, and the host runtime has none.
|
|
53
52
|
*/
|
|
54
53
|
export type CodeStepEnvironment<TInput, TResult = unknown> = {
|
|
55
54
|
/**
|
|
@@ -75,10 +74,10 @@ export type ManagedRuntimeFactories = {
|
|
|
75
74
|
};
|
|
76
75
|
export declare const Runtime: {
|
|
77
76
|
/**
|
|
78
|
-
* Worker-supplied containers
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
* is a type error.
|
|
77
|
+
* Worker-supplied containers, one factory per identifier, for example
|
|
78
|
+
* `Runtime.managed.bun1()`. The worker owns the image and clones the repo
|
|
79
|
+
* into it; the repo holds nothing. For a `codeStep` it also installs the
|
|
80
|
+
* pipeline-builder dependencies. An unknown identifier is a type error.
|
|
82
81
|
*/
|
|
83
82
|
readonly managed: ManagedRuntimeFactories;
|
|
84
83
|
/**
|