@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.
Files changed (152) hide show
  1. package/dist/chunk-0y2fy5en.js +166 -0
  2. package/dist/chunk-3ctaaseb.js +1456 -0
  3. package/dist/chunk-4ggr8af6.js +30 -0
  4. package/dist/chunk-5zsavw98.js +91 -0
  5. package/dist/chunk-63f90zky.js +39 -0
  6. package/dist/chunk-700xe701.js +100 -0
  7. package/dist/chunk-ar6hcj1r.js +35 -0
  8. package/dist/chunk-cdanncng.js +74 -0
  9. package/dist/chunk-dp86pa6m.js +68 -0
  10. package/dist/chunk-e1h021kq.js +86 -0
  11. package/dist/chunk-gds7w7zh.js +330 -0
  12. package/dist/chunk-k4y5qt4y.js +14 -0
  13. package/dist/chunk-mz53r914.js +300 -0
  14. package/dist/chunk-ngy1fdcx.js +57 -0
  15. package/dist/chunk-p7yrcmqm.js +322 -0
  16. package/dist/chunk-rt9tq4j6.js +116 -0
  17. package/dist/chunk-skzxcba3.js +14282 -0
  18. package/dist/chunk-vfeytkqx.js +1687 -0
  19. package/dist/chunk-y2pv8d6a.js +162 -0
  20. package/dist/chunk-y64skrwp.js +17 -0
  21. package/dist/chunk-yjtaq94c.js +1094 -0
  22. package/dist/chunk-zm72ksz0.js +256 -0
  23. package/dist/client.d.ts +4 -0
  24. package/dist/client.js +58 -0
  25. package/dist/contracts/artifact-markers.d.ts +42 -0
  26. package/dist/contracts/artifact-markers.js +16 -0
  27. package/dist/contracts/artifacts.d.ts +67 -0
  28. package/dist/contracts/artifacts.js +27 -0
  29. package/dist/contracts/pipeline-document/built-ins.d.ts +23 -0
  30. package/dist/contracts/pipeline-document/conditions/operators.d.ts +8 -0
  31. package/dist/contracts/pipeline-document/index.d.ts +11 -0
  32. package/dist/contracts/pipeline-document/index.js +99 -0
  33. package/dist/contracts/pipeline-document/json.d.ts +35 -0
  34. package/dist/contracts/pipeline-document/routes.d.ts +16 -0
  35. package/dist/contracts/pipeline-document/schema.d.ts +780 -0
  36. package/dist/contracts/pipeline-document/step-contract.d.ts +11 -0
  37. package/dist/contracts/step-artifact-submissions.d.ts +71 -0
  38. package/dist/contracts/step-artifact-submissions.js +171 -0
  39. package/dist/defaults/atomic-json-file.d.ts +10 -0
  40. package/dist/defaults/auth-file.d.ts +14 -0
  41. package/dist/defaults/base-url.d.ts +1 -0
  42. package/dist/defaults/config-file.d.ts +46 -0
  43. package/dist/defaults/home-dir.d.ts +3 -0
  44. package/dist/defaults/index.d.ts +12 -0
  45. package/dist/defaults/index.js +1240 -0
  46. package/dist/defaults/legacy-config-migration.d.ts +27 -0
  47. package/dist/defaults/load-push-defaults.d.ts +25 -0
  48. package/dist/defaults/project-config.d.ts +32 -0
  49. package/dist/defaults/project-ref.d.ts +34 -0
  50. package/dist/definitions/artifacts/artifact.d.ts +62 -0
  51. package/dist/definitions/artifacts/index.d.ts +1 -0
  52. package/dist/definitions/pipelines/define-default-pipeline-assignment.d.ts +263 -0
  53. package/dist/definitions/pipelines/index.d.ts +3 -0
  54. package/dist/definitions/pipelines/index.js +26 -0
  55. package/dist/definitions/pipelines/pipeline-definitions-client.d.ts +208 -0
  56. package/dist/definitions/pipelines/work-item-fields.d.ts +93 -0
  57. package/dist/definitions/steps/compile-mcps.d.ts +34 -0
  58. package/dist/definitions/steps/define-code-step.d.ts +84 -0
  59. package/dist/definitions/steps/define-mcp.d.ts +79 -0
  60. package/dist/definitions/steps/define-step.d.ts +137 -0
  61. package/dist/definitions/steps/env.d.ts +136 -0
  62. package/dist/definitions/steps/index.d.ts +14 -0
  63. package/dist/definitions/steps/index.js +76 -0
  64. package/dist/definitions/steps/mcp-server-config.d.ts +102 -0
  65. package/dist/definitions/steps/prompt-template.d.ts +24 -0
  66. package/dist/definitions/steps/repo.d.ts +67 -0
  67. package/dist/definitions/steps/runtime.d.ts +115 -0
  68. package/dist/definitions/steps/step-definitions-client.d.ts +400 -0
  69. package/dist/definitions/steps/step-features.d.ts +109 -0
  70. package/dist/definitions/steps/step-handle.d.ts +25 -0
  71. package/dist/definitions/steps/step-ref.d.ts +19 -0
  72. package/dist/definitions/validation/index.d.ts +2 -0
  73. package/dist/definitions/validation/index.js +19 -0
  74. package/dist/definitions/validation/validate-artifact-markers.d.ts +3 -0
  75. package/dist/definitions/validation/validate-artifacts.d.ts +7 -0
  76. package/dist/definitions/validation/validate-definition-specs.d.ts +16 -0
  77. package/dist/definitions/validation/validate-env.d.ts +15 -0
  78. package/dist/definitions/validation/validate-repo.d.ts +13 -0
  79. package/dist/definitions/validation/validate-runtime.d.ts +12 -0
  80. package/dist/definitions/validation/validation-issue.d.ts +11 -0
  81. package/dist/devcontainer-config-path.d.ts +21 -0
  82. package/dist/devcontainer-config-path.js +15 -0
  83. package/dist/env-vars.d.ts +136 -0
  84. package/dist/env-vars.js +37 -0
  85. package/dist/eslint.d.ts +42 -0
  86. package/dist/eslint.js +127 -0
  87. package/dist/generated/client/client.gen.d.ts +2 -0
  88. package/dist/generated/client/index.d.ts +8 -0
  89. package/dist/generated/client/types.gen.d.ts +117 -0
  90. package/dist/generated/client/utils.gen.d.ts +33 -0
  91. package/dist/generated/client.gen.d.ts +12 -0
  92. package/dist/generated/core/auth.gen.d.ts +18 -0
  93. package/dist/generated/core/bodySerializer.gen.d.ts +25 -0
  94. package/dist/generated/core/params.gen.d.ts +43 -0
  95. package/dist/generated/core/pathSerializer.gen.d.ts +33 -0
  96. package/dist/generated/core/queryKeySerializer.gen.d.ts +18 -0
  97. package/dist/generated/core/serverSentEvents.gen.d.ts +71 -0
  98. package/dist/generated/core/types.gen.d.ts +78 -0
  99. package/dist/generated/core/utils.gen.d.ts +19 -0
  100. package/dist/generated/index.d.ts +2 -0
  101. package/dist/generated/sdk.gen.d.ts +302 -0
  102. package/dist/generated/types.gen.d.ts +18375 -0
  103. package/dist/git-url/git-remote.d.ts +30 -0
  104. package/dist/git-url/git-repo-identity.d.ts +44 -0
  105. package/dist/git-url/git-repo-identity.js +161 -0
  106. package/dist/git-url/parse-git-host.d.ts +23 -0
  107. package/dist/health-checks.d.ts +169 -0
  108. package/dist/health-checks.js +21 -0
  109. package/dist/index.d.ts +11 -0
  110. package/dist/index.js +296 -0
  111. package/dist/jsonc.d.ts +3 -0
  112. package/dist/jsonc.js +12 -0
  113. package/dist/managed-runtimes.d.ts +20 -0
  114. package/dist/managed-runtimes.js +15 -0
  115. package/dist/opencode-mcp.d.ts +313 -0
  116. package/dist/opencode-mcp.js +31 -0
  117. package/dist/pipelines/chain.d.ts +7 -0
  118. package/dist/pipelines/compile-args.d.ts +12 -0
  119. package/dist/pipelines/compile-chain.d.ts +9 -0
  120. package/dist/pipelines/compile-checks.d.ts +16 -0
  121. package/dist/pipelines/compile-state.d.ts +30 -0
  122. package/dist/pipelines/condition-data.d.ts +78 -0
  123. package/dist/pipelines/conditions.d.ts +47 -0
  124. package/dist/pipelines/context.d.ts +16 -0
  125. package/dist/pipelines/define-pipeline.d.ts +32 -0
  126. package/dist/pipelines/each.d.ts +5 -0
  127. package/dist/pipelines/errors.d.ts +26 -0
  128. package/dist/pipelines/handles.d.ts +29 -0
  129. package/dist/pipelines/index.d.ts +18 -0
  130. package/dist/pipelines/index.js +83 -0
  131. package/dist/pipelines/model.d.ts +103 -0
  132. package/dist/pipelines/nodes.d.ts +54 -0
  133. package/dist/pipelines/ref-types.d.ts +54 -0
  134. package/dist/pipelines/refs.d.ts +80 -0
  135. package/dist/pipelines/registry.d.ts +12 -0
  136. package/dist/pipelines/source.d.ts +17 -0
  137. package/dist/pipelines/types.d.ts +160 -0
  138. package/dist/push/code-step-lookup.d.ts +32 -0
  139. package/dist/push/code-step-lookup.js +12 -0
  140. package/dist/push/collect-definitions.d.ts +70 -0
  141. package/dist/push/collect-pipeline-documents.d.ts +14 -0
  142. package/dist/push/index.d.ts +6 -0
  143. package/dist/push/index.js +327 -0
  144. package/dist/push/push-from-directory.d.ts +37 -0
  145. package/dist/repo-config.d.ts +80 -0
  146. package/dist/repo-config.js +25 -0
  147. package/dist/scarn-config-parser.d.ts +29 -0
  148. package/dist/scarn-config-parser.js +10 -0
  149. package/dist/task-plane-client.d.ts +489 -0
  150. package/dist/z.d.ts +7 -0
  151. package/package.json +132 -4
  152. package/README.md +0 -3
@@ -0,0 +1,256 @@
1
+ // @bun
2
+ import {
3
+ PipelineDefinitions,
4
+ createClient
5
+ } from "./chunk-vfeytkqx.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
+
110
+ // src/definitions/pipelines/define-default-pipeline-assignment.ts
111
+ var DEFAULT_PIPELINE_ASSIGNMENT_FILENAME = "default-pipeline-assignment.ts";
112
+ function makeLeaf(fact, path, operator, value) {
113
+ const condition = {
114
+ _tag: "leaf",
115
+ fact,
116
+ ...path ? { path } : {},
117
+ operator,
118
+ value
119
+ };
120
+ return {
121
+ _condition: condition,
122
+ then(outcome) {
123
+ return {
124
+ _tag: "assignment_rule",
125
+ conditions: [condition],
126
+ mode: "all",
127
+ outcome
128
+ };
129
+ }
130
+ };
131
+ }
132
+ function makeFieldRef(fact, path) {
133
+ const untyped = {
134
+ eq: (v) => makeLeaf(fact, path, "equal", v),
135
+ ne: (v) => makeLeaf(fact, path, "notEqual", v),
136
+ gt: (v) => makeLeaf(fact, path, "greaterThan", v),
137
+ gte: (v) => makeLeaf(fact, path, "greaterThanInclusive", v),
138
+ lt: (v) => makeLeaf(fact, path, "lessThan", v),
139
+ lte: (v) => makeLeaf(fact, path, "lessThanInclusive", v),
140
+ in: (vs) => makeLeaf(fact, path, "in", vs),
141
+ notIn: (vs) => makeLeaf(fact, path, "notIn", vs),
142
+ contains: (v) => makeLeaf(fact, path, "contains", v),
143
+ doesNotContain: (v) => makeLeaf(fact, path, "doesNotContain", v)
144
+ };
145
+ return untyped;
146
+ }
147
+ function buildWorkItemAccessor() {
148
+ const accessor = {
149
+ field: (name) => makeFieldRef("workItem", `$.${WORK_ITEM_FIELDS_PATH_PREFIX}${name}`)
150
+ };
151
+ for (const key of WORK_ITEM_TOP_LEVEL_FIELDS) {
152
+ accessor[key] = makeFieldRef("workItem", `$.${key}`);
153
+ }
154
+ return accessor;
155
+ }
156
+ function makeAssign(pipeline) {
157
+ const key = typeof pipeline === "string" ? pipeline : pipeline.key;
158
+ if (typeof key !== "string" || key.length === 0) {
159
+ throw new Error("assign() requires a pipeline key or the value definePipeline() returns.");
160
+ }
161
+ return { _tag: "assign", pipelineKey: key };
162
+ }
163
+ function extractCondition(ref) {
164
+ return ref._condition;
165
+ }
166
+ function makeGroup(mode, refs) {
167
+ const conditions = refs.map(extractCondition);
168
+ const condition = { _tag: "group", mode, conditions };
169
+ return {
170
+ _condition: condition,
171
+ then(outcome) {
172
+ return { _tag: "assignment_rule", conditions, mode, outcome };
173
+ }
174
+ };
175
+ }
176
+ function buildCtx() {
177
+ return {
178
+ workItem: buildWorkItemAccessor(),
179
+ context: {
180
+ isNew: makeFieldRef("context", "$.isNew")
181
+ },
182
+ assign: makeAssign,
183
+ skip: () => ({ _tag: "skip" }),
184
+ all: (...refs) => makeGroup("all", refs),
185
+ any: (...refs) => makeGroup("any", refs)
186
+ };
187
+ }
188
+ function defaultPipelineAssignment(callback) {
189
+ const input = callback(buildCtx());
190
+ return {
191
+ _tag: "default_pipeline_assignment",
192
+ default: input.default,
193
+ rules: input.rules
194
+ };
195
+ }
196
+ function serializeConditionNode(condition) {
197
+ if (condition._tag === "leaf") {
198
+ return {
199
+ fact: condition.fact,
200
+ ...condition.path ? { path: condition.path } : {},
201
+ operator: condition.operator,
202
+ value: condition.value
203
+ };
204
+ }
205
+ if (condition.mode === "all") {
206
+ return { all: condition.conditions.map(serializeConditionNode) };
207
+ }
208
+ return { any: condition.conditions.map(serializeConditionNode) };
209
+ }
210
+ function serializeOutcome(outcome) {
211
+ if (outcome._tag === "skip")
212
+ return { type: "skip", params: null };
213
+ return { type: "assign", params: { pipelineKey: outcome.pipelineKey } };
214
+ }
215
+ function serializeAssignmentRule(rule) {
216
+ const { type, params } = serializeOutcome(rule.outcome);
217
+ return {
218
+ conditions: { [rule.mode]: rule.conditions.map(serializeConditionNode) },
219
+ event: { type, ...params ? { params } : {} }
220
+ };
221
+ }
222
+ function serializeDefaultPipelineAssignment(spec) {
223
+ let primaryKey = null;
224
+ if (spec.default._tag === "assign") {
225
+ primaryKey = spec.default.pipelineKey;
226
+ } else {
227
+ for (const rule of spec.rules) {
228
+ if (rule.outcome._tag === "assign") {
229
+ primaryKey = rule.outcome.pipelineKey;
230
+ break;
231
+ }
232
+ }
233
+ }
234
+ if (primaryKey === null) {
235
+ throw new Error("defaultPipelineAssignment must contain at least one assign() outcome " + "(in `default` or in `rules`). A policy that only skips is not useful.");
236
+ }
237
+ const { type: defaultType, params: defaultParams } = serializeOutcome(spec.default);
238
+ const outcomeSet = new Set([defaultType]);
239
+ const serializedRules = spec.rules.map((rule) => {
240
+ outcomeSet.add(serializeOutcome(rule.outcome).type);
241
+ return serializeAssignmentRule(rule);
242
+ });
243
+ return {
244
+ pipelineDefinitionKey: primaryKey,
245
+ rulesJson: { rules: serializedRules },
246
+ defaultEventType: defaultType,
247
+ defaultEventParamsJson: defaultParams,
248
+ allowedEventTypes: [...outcomeSet]
249
+ };
250
+ }
251
+ function isDefaultPipelineAssignmentSpec(value) {
252
+ if (typeof value !== "object" || value === null)
253
+ return false;
254
+ return value["_tag"] === "default_pipeline_assignment";
255
+ }
256
+ export { PipelineDefinitionsApiError, createPipelineDefinitionsClient, WORK_ITEM_TOP_LEVEL_FIELDS, WORK_ITEM_FIELDS_PATH_PREFIX, resolveWorkItemFieldPath, DEFAULT_PIPELINE_ASSIGNMENT_FILENAME, defaultPipelineAssignment, serializeDefaultPipelineAssignment, isDefaultPipelineAssignmentSpec };
@@ -0,0 +1,4 @@
1
+ import { ScarnClient } from "./generated";
2
+ export * from "./task-plane-client";
3
+ export * from "./generated/";
4
+ export declare function createScarnClient(baseUrl: string): ScarnClient;
package/dist/client.js ADDED
@@ -0,0 +1,58 @@
1
+ // @bun
2
+ import {
3
+ createScarnClient,
4
+ createTaskPlaneClient
5
+ } from "./chunk-700xe701.js";
6
+ import {
7
+ Api,
8
+ Billing,
9
+ Conversations,
10
+ GitHubIntegrations,
11
+ NotificationRules,
12
+ PipelineDefinitions,
13
+ PipelineExecutions,
14
+ ProjectArtifacts,
15
+ ProjectIntegrations,
16
+ ProjectInvites,
17
+ Projects,
18
+ ScarnClient,
19
+ Secrets,
20
+ StepDefinitionTemplates,
21
+ StepDefinitions,
22
+ TaskRuns,
23
+ Tasks,
24
+ UserNotifications,
25
+ Username,
26
+ WorkItemBlocks,
27
+ WorkItemCommentDrafts,
28
+ WorkItemComments,
29
+ WorkItems
30
+ } from "./chunk-vfeytkqx.js";
31
+ import"./chunk-y64skrwp.js";
32
+ export {
33
+ Api,
34
+ Billing,
35
+ Conversations,
36
+ GitHubIntegrations,
37
+ NotificationRules,
38
+ PipelineDefinitions,
39
+ PipelineExecutions,
40
+ ProjectArtifacts,
41
+ ProjectIntegrations,
42
+ ProjectInvites,
43
+ Projects,
44
+ ScarnClient,
45
+ Secrets,
46
+ StepDefinitionTemplates,
47
+ StepDefinitions,
48
+ TaskRuns,
49
+ Tasks,
50
+ UserNotifications,
51
+ Username,
52
+ WorkItemBlocks,
53
+ WorkItemCommentDrafts,
54
+ WorkItemComments,
55
+ WorkItems,
56
+ createScarnClient,
57
+ createTaskPlaneClient
58
+ };
@@ -0,0 +1,42 @@
1
+ /**
2
+ * The artifact marker wire format, shared by the SDK (`Artifact.embed` /
3
+ * `Artifact.link` and definition validation) and core (draft resolution and
4
+ * rendering):
5
+ *
6
+ * - `![caption](artifact:signal/<stepKey>/<signalKey>)` / `[label](...)`
7
+ * point at a declared artifact signal and are required.
8
+ * - `![caption](artifact:<name-or-glob>)` / `[label](...)` point at any file
9
+ * under `artifactsDir` and are optional.
10
+ *
11
+ * Text inside `[...]` escapes `\`, `[` and `]` with a backslash. A ref with
12
+ * whitespace or `<`/`>` is wrapped in `<...>`; otherwise `\`, `(` and `)` are
13
+ * backslash-escaped.
14
+ */
15
+ export declare const ARTIFACT_MARKER_SCHEME = "artifact:";
16
+ export type ArtifactMarkerKind = "embed" | "link";
17
+ export type ArtifactMarkerRef = {
18
+ readonly type: "signal";
19
+ readonly stepKey: string;
20
+ readonly signalKey: string;
21
+ } | {
22
+ readonly type: "path";
23
+ readonly pattern: string;
24
+ };
25
+ /** A marker found in a piece of text. `start`/`end` are string offsets. */
26
+ export type ArtifactMarkerMatch = {
27
+ readonly kind: ArtifactMarkerKind;
28
+ /** The caption (embed) or label (link), unescaped. */
29
+ readonly text: string;
30
+ /** Everything after `artifact:`, unescaped. */
31
+ readonly rawRef: string;
32
+ readonly ref: ArtifactMarkerRef;
33
+ readonly start: number;
34
+ readonly end: number;
35
+ };
36
+ /** Splits the part after `artifact:` into a signal or path ref. */
37
+ export declare function parseArtifactMarkerRef(rawRef: string): ArtifactMarkerRef;
38
+ export declare function formatArtifactMarkerRef(ref: ArtifactMarkerRef): string;
39
+ /** Builds a marker string. `text` is the caption (embed) or label (link). */
40
+ export declare function buildArtifactMarker(kind: ArtifactMarkerKind, ref: ArtifactMarkerRef, text: string): string;
41
+ /** Every artifact marker in `text`, in order. Other links are ignored. */
42
+ export declare function findArtifactMarkers(text: string): ArtifactMarkerMatch[];
@@ -0,0 +1,16 @@
1
+ // @bun
2
+ import {
3
+ ARTIFACT_MARKER_SCHEME,
4
+ buildArtifactMarker,
5
+ findArtifactMarkers,
6
+ formatArtifactMarkerRef,
7
+ parseArtifactMarkerRef
8
+ } from "../chunk-ngy1fdcx.js";
9
+ import"../chunk-y64skrwp.js";
10
+ export {
11
+ ARTIFACT_MARKER_SCHEME,
12
+ buildArtifactMarker,
13
+ findArtifactMarkers,
14
+ formatArtifactMarkerRef,
15
+ parseArtifactMarkerRef
16
+ };
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Artifact contract shared by the SDK, the opencode plugin, the worker and
3
+ * core. Everything here works on JSON Schema only (the `x-scarn-artifact`
4
+ * keyword), never on Zod schemas, so the server can use it without knowing
5
+ * how a step was authored.
6
+ */
7
+ import { z } from "zod";
8
+ export declare const artifactKindSchema: z.ZodEnum<{
9
+ generic: "generic";
10
+ "playwright-trace": "playwright-trace";
11
+ video: "video";
12
+ image: "image";
13
+ }>;
14
+ export type ArtifactKind = z.infer<typeof artifactKindSchema>;
15
+ export declare const ARTIFACT_SCHEMA_KEYWORD = "x-scarn-artifact";
16
+ export type ArtifactSchemaKeyword = {
17
+ readonly accept: readonly string[];
18
+ };
19
+ /** A JSON Schema node. `true` / `false` are the boolean schema forms. */
20
+ export type ArtifactJsonSchemaNode = boolean | {
21
+ readonly [key: string]: unknown;
22
+ };
23
+ /** A declared artifact field in a step's result schema. */
24
+ export type ArtifactField = {
25
+ /**
26
+ * Dot path of the field. Array items appear as `[]`, e.g. `shots[]` or
27
+ * `runs[].video`.
28
+ */
29
+ readonly path: string;
30
+ /** Lower-case extensions with a leading dot. Empty accepts any file. */
31
+ readonly accept: readonly string[];
32
+ readonly nullable: boolean;
33
+ readonly description: string | null;
34
+ /** True when the field sits inside an array, which v1 does not support. */
35
+ readonly inArray: boolean;
36
+ };
37
+ export declare const artifactPlatforms: readonly ["github", "jira", "bitbucket"];
38
+ export type ArtifactPlatform = (typeof artifactPlatforms)[number];
39
+ /**
40
+ * Extensions each platform can show inline in a comment. Anything else is
41
+ * linked to its Scarn artifact page. GitHub and Bitbucket link everything
42
+ * in v1.
43
+ */
44
+ export declare const EMBEDDABLE_ARTIFACT_EXTENSIONS: Readonly<Record<ArtifactPlatform, readonly string[]>>;
45
+ export declare function isEmbeddableArtifactExtension(platform: ArtifactPlatform, extension: string): boolean;
46
+ /** The lower-cased extension of a file name, with its dot; `""` when none. */
47
+ export declare function artifactFileExtension(fileName: string): string;
48
+ /** Whether a file name matches an `accept` list. An empty list accepts any file. */
49
+ export declare function artifactAcceptsFile(accept: readonly string[], fileName: string): boolean;
50
+ /** Reads the `x-scarn-artifact` keyword on this exact node. */
51
+ export declare function readArtifactKeyword(node: ArtifactJsonSchemaNode): ArtifactSchemaKeyword | null;
52
+ export type ArtifactNodeMatch = ArtifactSchemaKeyword & {
53
+ readonly nullable: boolean;
54
+ readonly description: string | null;
55
+ };
56
+ /**
57
+ * Matches a node that is an artifact field, either directly or as
58
+ * `anyOf: [<artifact>, { type: "null" }]` (Zod's `.nullable()`).
59
+ */
60
+ export declare function matchArtifactNode(node: ArtifactJsonSchemaNode): ArtifactNodeMatch | null;
61
+ /**
62
+ * Every artifact field declared in a result schema: walks object
63
+ * properties, `anyOf` / `oneOf` / `allOf` branches, local `$ref`s and array
64
+ * items. Fields inside arrays are returned with `inArray: true`; v1 rejects
65
+ * them at definition time.
66
+ */
67
+ export declare function findArtifactFields(schema: ArtifactJsonSchemaNode | null | undefined): ArtifactField[];
@@ -0,0 +1,27 @@
1
+ // @bun
2
+ import {
3
+ ARTIFACT_SCHEMA_KEYWORD,
4
+ EMBEDDABLE_ARTIFACT_EXTENSIONS,
5
+ artifactAcceptsFile,
6
+ artifactFileExtension,
7
+ artifactKindSchema,
8
+ artifactPlatforms,
9
+ findArtifactFields,
10
+ isEmbeddableArtifactExtension,
11
+ matchArtifactNode,
12
+ readArtifactKeyword
13
+ } from "../chunk-y2pv8d6a.js";
14
+ import"../chunk-skzxcba3.js";
15
+ import"../chunk-y64skrwp.js";
16
+ export {
17
+ ARTIFACT_SCHEMA_KEYWORD,
18
+ EMBEDDABLE_ARTIFACT_EXTENSIONS,
19
+ artifactAcceptsFile,
20
+ artifactFileExtension,
21
+ artifactKindSchema,
22
+ artifactPlatforms,
23
+ findArtifactFields,
24
+ isEmbeddableArtifactExtension,
25
+ matchArtifactNode,
26
+ readArtifactKeyword
27
+ };
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Built-in error names and the schemas of built-in values: wait results,
3
+ * the input a `reply` wait takes, and caught errors.
4
+ */
5
+ import type { JsonSchema } from "./json";
6
+ export declare const BUILT_IN_ERRORS: readonly ["Scarn.All", "Scarn.StepFailed", "Scarn.HealthCheckFailed", "Scarn.Timeout", "Scarn.HeartbeatTimeout", "Scarn.MaxRunsExceeded", "Scarn.MaxTurnsExceeded", "Scarn.ConditionError", "Scarn.ArgsError"];
7
+ /** The errors a wait node can raise, so the only names its `catch` may use. */
8
+ export declare const WAIT_ERRORS: readonly ["Scarn.All", "Scarn.MaxRunsExceeded", "Scarn.ArgsError"];
9
+ /**
10
+ * The result of a `wait` node with `for: decision`: the chosen action's key
11
+ * and the person's text. With no actions (an invalid node) `action` is any
12
+ * string, so only the missing actions are reported.
13
+ */
14
+ export declare function decisionResultSchema(actions: readonly {
15
+ key: string;
16
+ }[]): JsonSchema;
17
+ /** The result of a `wait` node with `for: reply`; `replied: false` is "continue without reply". */
18
+ export declare const REPLY_RESULT_SCHEMA: JsonSchema;
19
+ /** The result of a conversation step (a step with no result schema): the conversation and the agent's last message. */
20
+ export declare const CONVERSATION_RESULT_SCHEMA: JsonSchema;
21
+ /** What every transition into a `reply` wait must pass. */
22
+ export declare const REPLY_INPUT_SCHEMA: JsonSchema;
23
+ export declare const ERROR_SCHEMA: JsonSchema;
@@ -0,0 +1,8 @@
1
+ /** Condition operator and computed-function names, shared by schema, evaluator and validator. */
2
+ export declare const COMPARISON_OPERATORS: readonly ["equal", "notEqual", "lessThan", "lessThanInclusive", "greaterThan", "greaterThanInclusive"];
3
+ export declare const CONDITION_OPERATORS: readonly ["equal", "notEqual", "lessThan", "lessThanInclusive", "greaterThan", "greaterThanInclusive", "exists", "isEmpty", "contains", "startsWith", "endsWith", "matches", "before", "after", "some", "every", "none"];
4
+ export declare const COMPUTED_FUNCTIONS: readonly ["sum", "avg", "min", "max", "count"];
5
+ export declare const ORDERING_OPERATORS: Set<string>;
6
+ export declare const STRING_OPERATORS: Set<string>;
7
+ export declare const DATE_OPERATORS: Set<string>;
8
+ export declare const LIST_OPERATORS: Set<string>;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * The pipeline document contract: what a pipeline JSON document is. Logic
3
+ * that works on documents (validation, evaluation) lives in
4
+ * `@scarn/shared-core/pipelines`.
5
+ */
6
+ export * from "./json";
7
+ export * from "./schema";
8
+ export * from "./routes";
9
+ export * from "./conditions/operators";
10
+ export * from "./step-contract";
11
+ export * from "./built-ins";
@@ -0,0 +1,99 @@
1
+ // @bun
2
+ import {
3
+ ALIAS_PATTERN,
4
+ COMPARISON_OPERATORS,
5
+ COMPUTED_FUNCTIONS,
6
+ CONDITION_OPERATORS,
7
+ DATE_OPERATORS,
8
+ DECISION_BODY_MODES,
9
+ DEFAULT_MAX_TURNS,
10
+ LIST_OPERATORS,
11
+ MATCH_MODES,
12
+ NODE_ID_PATTERN,
13
+ ORDERING_OPERATORS,
14
+ STRING_OPERATORS,
15
+ argValueSchema,
16
+ catchSchema,
17
+ computedSourceSchema,
18
+ conditionSchema,
19
+ decisionActionSchema,
20
+ deepEqual,
21
+ eachSchema,
22
+ failNodeSchema,
23
+ isJsonObject,
24
+ jsonPointer,
25
+ listSchema,
26
+ literalSchema,
27
+ nextSchema,
28
+ nodeSchema,
29
+ otherwiseSchema,
30
+ pipelineDocumentJsonSchema,
31
+ pipelineDocumentSchema,
32
+ retrySchema,
33
+ routeAt,
34
+ routeEntries,
35
+ routeSchema,
36
+ startSchema,
37
+ stepNodeSchema,
38
+ succeedNodeSchema,
39
+ toleratedFailuresSchema,
40
+ waitNodeSchema
41
+ } from "../../chunk-p7yrcmqm.js";
42
+ import {
43
+ BUILT_IN_ERRORS,
44
+ CONVERSATION_RESULT_SCHEMA,
45
+ ERROR_SCHEMA,
46
+ REPLY_INPUT_SCHEMA,
47
+ REPLY_RESULT_SCHEMA,
48
+ WAIT_ERRORS,
49
+ decisionResultSchema
50
+ } from "../../chunk-dp86pa6m.js";
51
+ import"../../chunk-skzxcba3.js";
52
+ import"../../chunk-y64skrwp.js";
53
+ export {
54
+ ALIAS_PATTERN,
55
+ BUILT_IN_ERRORS,
56
+ COMPARISON_OPERATORS,
57
+ COMPUTED_FUNCTIONS,
58
+ CONDITION_OPERATORS,
59
+ CONVERSATION_RESULT_SCHEMA,
60
+ DATE_OPERATORS,
61
+ DECISION_BODY_MODES,
62
+ DEFAULT_MAX_TURNS,
63
+ ERROR_SCHEMA,
64
+ LIST_OPERATORS,
65
+ MATCH_MODES,
66
+ NODE_ID_PATTERN,
67
+ ORDERING_OPERATORS,
68
+ REPLY_INPUT_SCHEMA,
69
+ REPLY_RESULT_SCHEMA,
70
+ STRING_OPERATORS,
71
+ WAIT_ERRORS,
72
+ argValueSchema,
73
+ catchSchema,
74
+ computedSourceSchema,
75
+ conditionSchema,
76
+ decisionActionSchema,
77
+ decisionResultSchema,
78
+ deepEqual,
79
+ eachSchema,
80
+ failNodeSchema,
81
+ isJsonObject,
82
+ jsonPointer,
83
+ listSchema,
84
+ literalSchema,
85
+ nextSchema,
86
+ nodeSchema,
87
+ otherwiseSchema,
88
+ pipelineDocumentJsonSchema,
89
+ pipelineDocumentSchema,
90
+ retrySchema,
91
+ routeAt,
92
+ routeEntries,
93
+ routeSchema,
94
+ startSchema,
95
+ stepNodeSchema,
96
+ succeedNodeSchema,
97
+ toleratedFailuresSchema,
98
+ waitNodeSchema
99
+ };
@@ -0,0 +1,35 @@
1
+ /**
2
+ * JSON value and JSON Schema types shared across the package, plus small
3
+ * helpers for JSON pointers and structural equality.
4
+ */
5
+ export type JsonValue = null | boolean | number | string | JsonValue[] | {
6
+ [key: string]: JsonValue;
7
+ };
8
+ export type JsonObject = {
9
+ [key: string]: JsonValue;
10
+ };
11
+ export interface JsonSchemaObject {
12
+ type?: string | string[];
13
+ properties?: Record<string, JsonSchema>;
14
+ required?: string[];
15
+ additionalProperties?: JsonSchema;
16
+ items?: JsonSchema;
17
+ prefixItems?: JsonSchema[];
18
+ anyOf?: JsonSchema[];
19
+ oneOf?: JsonSchema[];
20
+ allOf?: JsonSchema[];
21
+ enum?: JsonValue[];
22
+ const?: JsonValue;
23
+ $ref?: string;
24
+ $defs?: Record<string, JsonSchema>;
25
+ definitions?: Record<string, JsonSchema>;
26
+ title?: string;
27
+ description?: string;
28
+ format?: string;
29
+ [key: string]: unknown;
30
+ }
31
+ export type JsonSchema = boolean | JsonSchemaObject;
32
+ export declare function isJsonObject(value: JsonValue | undefined): value is JsonObject;
33
+ /** Builds an RFC 6901 JSON pointer such as `/nodes/fix/next/routes/1/args/plan`. */
34
+ export declare function jsonPointer(segments: readonly (string | number)[]): string;
35
+ export declare function deepEqual(left: JsonValue | undefined, right: JsonValue | undefined): boolean;
@@ -0,0 +1,16 @@
1
+ /** Reading the routes of a node's `next` object. */
2
+ import type { Next, Otherwise, Route } from "./schema";
3
+ export type RouteKind = "route" | "otherwise";
4
+ /** One entry of a `next` object: a route, or the `otherwise` route. */
5
+ export interface RouteEntry {
6
+ kind: RouteKind;
7
+ /** The route's index in `routes`, or 0 for `otherwise`. */
8
+ index: number;
9
+ route: Route | Otherwise;
10
+ /** Where the entry sits inside the `next` object. */
11
+ pointer: ["routes", number] | ["otherwise"];
12
+ }
13
+ /** Every route of `next` in order, with `otherwise` last. */
14
+ export declare function routeEntries(next: Next | undefined): RouteEntry[];
15
+ /** The route a `kind` and `index` name, if `next` has it. */
16
+ export declare function routeAt(next: Next | undefined, kind: RouteKind, index: number): Route | Otherwise | undefined;