@scarn/sdk 0.0.0-stage → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-0y2fy5en.js +166 -0
- package/dist/chunk-3ctaaseb.js +1456 -0
- package/dist/chunk-4ggr8af6.js +30 -0
- package/dist/chunk-5zsavw98.js +91 -0
- package/dist/chunk-63f90zky.js +39 -0
- package/dist/chunk-700xe701.js +100 -0
- package/dist/chunk-ar6hcj1r.js +35 -0
- package/dist/chunk-cdanncng.js +74 -0
- package/dist/chunk-dp86pa6m.js +68 -0
- package/dist/chunk-e1h021kq.js +86 -0
- package/dist/chunk-gds7w7zh.js +330 -0
- package/dist/chunk-k4y5qt4y.js +14 -0
- package/dist/chunk-mz53r914.js +300 -0
- package/dist/chunk-ngy1fdcx.js +57 -0
- package/dist/chunk-p7yrcmqm.js +322 -0
- package/dist/chunk-rt9tq4j6.js +116 -0
- package/dist/chunk-skzxcba3.js +14282 -0
- package/dist/chunk-vfeytkqx.js +1687 -0
- package/dist/chunk-y2pv8d6a.js +162 -0
- package/dist/chunk-y64skrwp.js +17 -0
- package/dist/chunk-yjtaq94c.js +1094 -0
- package/dist/chunk-zm72ksz0.js +256 -0
- package/dist/client.d.ts +4 -0
- package/dist/client.js +58 -0
- package/dist/contracts/artifact-markers.d.ts +42 -0
- package/dist/contracts/artifact-markers.js +16 -0
- package/dist/contracts/artifacts.d.ts +67 -0
- package/dist/contracts/artifacts.js +27 -0
- package/dist/contracts/pipeline-document/built-ins.d.ts +23 -0
- package/dist/contracts/pipeline-document/conditions/operators.d.ts +8 -0
- package/dist/contracts/pipeline-document/index.d.ts +11 -0
- package/dist/contracts/pipeline-document/index.js +99 -0
- package/dist/contracts/pipeline-document/json.d.ts +35 -0
- package/dist/contracts/pipeline-document/routes.d.ts +16 -0
- package/dist/contracts/pipeline-document/schema.d.ts +780 -0
- package/dist/contracts/pipeline-document/step-contract.d.ts +11 -0
- package/dist/contracts/step-artifact-submissions.d.ts +71 -0
- package/dist/contracts/step-artifact-submissions.js +171 -0
- package/dist/defaults/atomic-json-file.d.ts +10 -0
- package/dist/defaults/auth-file.d.ts +14 -0
- package/dist/defaults/base-url.d.ts +1 -0
- package/dist/defaults/config-file.d.ts +46 -0
- package/dist/defaults/home-dir.d.ts +3 -0
- package/dist/defaults/index.d.ts +12 -0
- package/dist/defaults/index.js +1240 -0
- package/dist/defaults/legacy-config-migration.d.ts +27 -0
- package/dist/defaults/load-push-defaults.d.ts +25 -0
- package/dist/defaults/project-config.d.ts +32 -0
- package/dist/defaults/project-ref.d.ts +34 -0
- package/dist/definitions/artifacts/artifact.d.ts +62 -0
- package/dist/definitions/artifacts/index.d.ts +1 -0
- package/dist/definitions/pipelines/define-default-pipeline-assignment.d.ts +263 -0
- package/dist/definitions/pipelines/index.d.ts +3 -0
- package/dist/definitions/pipelines/index.js +26 -0
- package/dist/definitions/pipelines/pipeline-definitions-client.d.ts +208 -0
- package/dist/definitions/pipelines/work-item-fields.d.ts +93 -0
- package/dist/definitions/steps/compile-mcps.d.ts +34 -0
- package/dist/definitions/steps/define-code-step.d.ts +84 -0
- package/dist/definitions/steps/define-mcp.d.ts +79 -0
- package/dist/definitions/steps/define-step.d.ts +137 -0
- package/dist/definitions/steps/env.d.ts +136 -0
- package/dist/definitions/steps/index.d.ts +14 -0
- package/dist/definitions/steps/index.js +76 -0
- package/dist/definitions/steps/mcp-server-config.d.ts +102 -0
- package/dist/definitions/steps/prompt-template.d.ts +24 -0
- package/dist/definitions/steps/repo.d.ts +67 -0
- package/dist/definitions/steps/runtime.d.ts +115 -0
- package/dist/definitions/steps/step-definitions-client.d.ts +400 -0
- package/dist/definitions/steps/step-features.d.ts +109 -0
- package/dist/definitions/steps/step-handle.d.ts +25 -0
- package/dist/definitions/steps/step-ref.d.ts +19 -0
- package/dist/definitions/validation/index.d.ts +2 -0
- package/dist/definitions/validation/index.js +19 -0
- package/dist/definitions/validation/validate-artifact-markers.d.ts +3 -0
- package/dist/definitions/validation/validate-artifacts.d.ts +7 -0
- package/dist/definitions/validation/validate-definition-specs.d.ts +16 -0
- package/dist/definitions/validation/validate-env.d.ts +15 -0
- package/dist/definitions/validation/validate-repo.d.ts +13 -0
- package/dist/definitions/validation/validate-runtime.d.ts +12 -0
- package/dist/definitions/validation/validation-issue.d.ts +11 -0
- package/dist/devcontainer-config-path.d.ts +21 -0
- package/dist/devcontainer-config-path.js +15 -0
- package/dist/env-vars.d.ts +136 -0
- package/dist/env-vars.js +37 -0
- package/dist/eslint.d.ts +42 -0
- package/dist/eslint.js +127 -0
- package/dist/generated/client/client.gen.d.ts +2 -0
- package/dist/generated/client/index.d.ts +8 -0
- package/dist/generated/client/types.gen.d.ts +117 -0
- package/dist/generated/client/utils.gen.d.ts +33 -0
- package/dist/generated/client.gen.d.ts +12 -0
- package/dist/generated/core/auth.gen.d.ts +18 -0
- package/dist/generated/core/bodySerializer.gen.d.ts +25 -0
- package/dist/generated/core/params.gen.d.ts +43 -0
- package/dist/generated/core/pathSerializer.gen.d.ts +33 -0
- package/dist/generated/core/queryKeySerializer.gen.d.ts +18 -0
- package/dist/generated/core/serverSentEvents.gen.d.ts +71 -0
- package/dist/generated/core/types.gen.d.ts +78 -0
- package/dist/generated/core/utils.gen.d.ts +19 -0
- package/dist/generated/index.d.ts +2 -0
- package/dist/generated/sdk.gen.d.ts +302 -0
- package/dist/generated/types.gen.d.ts +18375 -0
- package/dist/git-url/git-remote.d.ts +30 -0
- package/dist/git-url/git-repo-identity.d.ts +44 -0
- package/dist/git-url/git-repo-identity.js +161 -0
- package/dist/git-url/parse-git-host.d.ts +23 -0
- package/dist/health-checks.d.ts +169 -0
- package/dist/health-checks.js +21 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +296 -0
- package/dist/jsonc.d.ts +3 -0
- package/dist/jsonc.js +12 -0
- package/dist/managed-runtimes.d.ts +20 -0
- package/dist/managed-runtimes.js +15 -0
- package/dist/opencode-mcp.d.ts +313 -0
- package/dist/opencode-mcp.js +31 -0
- package/dist/pipelines/chain.d.ts +7 -0
- package/dist/pipelines/compile-args.d.ts +12 -0
- package/dist/pipelines/compile-chain.d.ts +9 -0
- package/dist/pipelines/compile-checks.d.ts +16 -0
- package/dist/pipelines/compile-state.d.ts +30 -0
- package/dist/pipelines/condition-data.d.ts +78 -0
- package/dist/pipelines/conditions.d.ts +47 -0
- package/dist/pipelines/context.d.ts +16 -0
- package/dist/pipelines/define-pipeline.d.ts +32 -0
- package/dist/pipelines/each.d.ts +5 -0
- package/dist/pipelines/errors.d.ts +26 -0
- package/dist/pipelines/handles.d.ts +29 -0
- package/dist/pipelines/index.d.ts +18 -0
- package/dist/pipelines/index.js +83 -0
- package/dist/pipelines/model.d.ts +103 -0
- package/dist/pipelines/nodes.d.ts +54 -0
- package/dist/pipelines/ref-types.d.ts +54 -0
- package/dist/pipelines/refs.d.ts +80 -0
- package/dist/pipelines/registry.d.ts +12 -0
- package/dist/pipelines/source.d.ts +17 -0
- package/dist/pipelines/types.d.ts +160 -0
- package/dist/push/code-step-lookup.d.ts +32 -0
- package/dist/push/code-step-lookup.js +12 -0
- package/dist/push/collect-definitions.d.ts +70 -0
- package/dist/push/collect-pipeline-documents.d.ts +14 -0
- package/dist/push/index.d.ts +6 -0
- package/dist/push/index.js +327 -0
- package/dist/push/push-from-directory.d.ts +37 -0
- package/dist/repo-config.d.ts +80 -0
- package/dist/repo-config.js +25 -0
- package/dist/scarn-config-parser.d.ts +29 -0
- package/dist/scarn-config-parser.js +10 -0
- package/dist/task-plane-client.d.ts +489 -0
- package/dist/z.d.ts +7 -0
- package/package.json +132 -4
- package/README.md +0 -3
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
exports_external
|
|
4
|
+
} from "./chunk-skzxcba3.js";
|
|
5
|
+
|
|
6
|
+
// src/devcontainer-config-path.ts
|
|
7
|
+
var MAX_DEVCONTAINER_CONFIG_PATH_LENGTH = 255;
|
|
8
|
+
var DEVCONTAINER_CONFIG_BASENAMES = [
|
|
9
|
+
"devcontainer.json",
|
|
10
|
+
".devcontainer.json"
|
|
11
|
+
];
|
|
12
|
+
var LEADING_CURRENT_DIR = /^(?:\.\/)+/;
|
|
13
|
+
var DRIVE_LETTER = /^[A-Za-z]:/;
|
|
14
|
+
function normalizeDevcontainerConfigPath(path) {
|
|
15
|
+
return path.replace(LEADING_CURRENT_DIR, "");
|
|
16
|
+
}
|
|
17
|
+
function basenameOf(path) {
|
|
18
|
+
return path.slice(Math.max(path.lastIndexOf("/"), path.lastIndexOf("\\")) + 1);
|
|
19
|
+
}
|
|
20
|
+
var devcontainerConfigPathSchema = exports_external.string().max(MAX_DEVCONTAINER_CONFIG_PATH_LENGTH).overwrite(normalizeDevcontainerConfigPath).refine((path) => !path.includes("\\"), {
|
|
21
|
+
message: "must use forward slashes, not backslashes"
|
|
22
|
+
}).refine((path) => !path.startsWith("/") && !DRIVE_LETTER.test(path), {
|
|
23
|
+
message: "must be relative to the repository root, not absolute"
|
|
24
|
+
}).refine((path) => !path.split("/").includes(".."), {
|
|
25
|
+
message: 'must not contain a ".." segment'
|
|
26
|
+
}).refine((path) => DEVCONTAINER_CONFIG_BASENAMES.includes(basenameOf(path)), {
|
|
27
|
+
message: 'must end in "devcontainer.json" or ".devcontainer.json"'
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
export { MAX_DEVCONTAINER_CONFIG_PATH_LENGTH, DEVCONTAINER_CONFIG_BASENAMES, normalizeDevcontainerConfigPath, devcontainerConfigPathSchema };
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
exports_external
|
|
4
|
+
} from "./chunk-skzxcba3.js";
|
|
5
|
+
|
|
6
|
+
// src/env-vars.ts
|
|
7
|
+
var ENV_VAR_NAME_PATTERN = /^[A-Z_][A-Z0-9_]*$/;
|
|
8
|
+
var RESERVED_ENV_VAR_NAMES = [
|
|
9
|
+
"HOME",
|
|
10
|
+
"XDG_CONFIG_HOME",
|
|
11
|
+
"XDG_DATA_HOME",
|
|
12
|
+
"OPENCODE_CONFIG_CONTENT",
|
|
13
|
+
"npm_config_cache"
|
|
14
|
+
];
|
|
15
|
+
var RESERVED_ENV_VAR_PREFIX = "SCARN_";
|
|
16
|
+
var MAX_ENV_VARS = 64;
|
|
17
|
+
var MAX_ENV_VAR_NAME_LENGTH = 128;
|
|
18
|
+
var MAX_ENV_VAR_VALUE_LENGTH = 4096;
|
|
19
|
+
var INPUT_TOKEN_PATTERN = /\{\{input\.[^}]+\}\}/;
|
|
20
|
+
function containsInputToken(value) {
|
|
21
|
+
return INPUT_TOKEN_PATTERN.test(value);
|
|
22
|
+
}
|
|
23
|
+
function isReservedEnvVarName(name) {
|
|
24
|
+
return name.startsWith(RESERVED_ENV_VAR_PREFIX) || RESERVED_ENV_VAR_NAMES.includes(name);
|
|
25
|
+
}
|
|
26
|
+
var envVarNameSchema = exports_external.string().max(MAX_ENV_VAR_NAME_LENGTH).regex(ENV_VAR_NAME_PATTERN, "must match /^[A-Z_][A-Z0-9_]*$/").refine((name) => !isReservedEnvVarName(name), {
|
|
27
|
+
message: `is reserved (SCARN_*, ${RESERVED_ENV_VAR_NAMES.join(", ")})`
|
|
28
|
+
});
|
|
29
|
+
var envVarValueSchema = exports_external.string().max(MAX_ENV_VAR_VALUE_LENGTH);
|
|
30
|
+
var envVarAppliesValues = ["agent", "setup", "both"];
|
|
31
|
+
var envVarAppliesSchema = exports_external.enum(envVarAppliesValues).default("agent");
|
|
32
|
+
function appliesToAgent(applies) {
|
|
33
|
+
return applies !== "setup";
|
|
34
|
+
}
|
|
35
|
+
function appliesToSetup(applies) {
|
|
36
|
+
return applies === "setup" || applies === "both";
|
|
37
|
+
}
|
|
38
|
+
function isUninheritableWorkerEnvVarName(name) {
|
|
39
|
+
return name.toUpperCase().startsWith(RESERVED_ENV_VAR_PREFIX);
|
|
40
|
+
}
|
|
41
|
+
var valueEnvVarSchema = exports_external.object({
|
|
42
|
+
name: envVarNameSchema,
|
|
43
|
+
source: exports_external.literal("value"),
|
|
44
|
+
value: envVarValueSchema,
|
|
45
|
+
secret: exports_external.boolean(),
|
|
46
|
+
applies: envVarAppliesSchema
|
|
47
|
+
}).strict().refine((entry) => !entry.secret || containsInputToken(entry.value), {
|
|
48
|
+
path: ["value"],
|
|
49
|
+
message: "a secret value must contain an {{input.\u2026}} token; a static secret would be stored in plaintext. Use Env.inherit({ secret: true }) instead"
|
|
50
|
+
});
|
|
51
|
+
var inheritEnvVarSchema = exports_external.object({
|
|
52
|
+
name: envVarNameSchema,
|
|
53
|
+
source: exports_external.literal("inherit"),
|
|
54
|
+
from: exports_external.string().max(MAX_ENV_VAR_NAME_LENGTH).regex(/^[A-Za-z_][A-Za-z0-9_]*$/, "must be a valid environment variable name").refine((from) => !isUninheritableWorkerEnvVarName(from), {
|
|
55
|
+
message: `cannot read worker variables starting with ${RESERVED_ENV_VAR_PREFIX}`
|
|
56
|
+
}),
|
|
57
|
+
secret: exports_external.boolean(),
|
|
58
|
+
optional: exports_external.boolean(),
|
|
59
|
+
default: envVarValueSchema.optional(),
|
|
60
|
+
mcp: exports_external.string().min(1).optional(),
|
|
61
|
+
applies: envVarAppliesSchema
|
|
62
|
+
}).strict().refine((entry) => !(entry.secret && entry.default !== undefined), {
|
|
63
|
+
path: ["default"],
|
|
64
|
+
message: "a secret cannot carry a default; it would be stored in plaintext"
|
|
65
|
+
});
|
|
66
|
+
var envVarSpecSchema = exports_external.discriminatedUnion("source", [
|
|
67
|
+
valueEnvVarSchema,
|
|
68
|
+
inheritEnvVarSchema
|
|
69
|
+
]);
|
|
70
|
+
var envVarsSchema = exports_external.array(envVarSpecSchema).max(MAX_ENV_VARS).refine((entries) => new Set(entries.map((entry) => entry.name)).size === entries.length, { message: "environment variable names must be unique" });
|
|
71
|
+
var storedEnvVarsSchema = exports_external.array(exports_external.discriminatedUnion("source", [
|
|
72
|
+
exports_external.object({
|
|
73
|
+
name: exports_external.string(),
|
|
74
|
+
source: exports_external.literal("value"),
|
|
75
|
+
value: exports_external.string(),
|
|
76
|
+
secret: exports_external.boolean(),
|
|
77
|
+
applies: exports_external.enum(envVarAppliesValues).default("agent")
|
|
78
|
+
}),
|
|
79
|
+
exports_external.object({
|
|
80
|
+
name: exports_external.string(),
|
|
81
|
+
source: exports_external.literal("inherit"),
|
|
82
|
+
from: exports_external.string(),
|
|
83
|
+
secret: exports_external.boolean(),
|
|
84
|
+
optional: exports_external.boolean(),
|
|
85
|
+
default: exports_external.string().optional(),
|
|
86
|
+
mcp: exports_external.string().optional(),
|
|
87
|
+
applies: exports_external.enum(envVarAppliesValues).default("agent")
|
|
88
|
+
})
|
|
89
|
+
]));
|
|
90
|
+
|
|
91
|
+
export { ENV_VAR_NAME_PATTERN, RESERVED_ENV_VAR_NAMES, RESERVED_ENV_VAR_PREFIX, MAX_ENV_VARS, MAX_ENV_VAR_NAME_LENGTH, MAX_ENV_VAR_VALUE_LENGTH, containsInputToken, isReservedEnvVarName, envVarAppliesValues, appliesToAgent, appliesToSetup, isUninheritableWorkerEnvVarName, envVarSpecSchema, envVarsSchema, storedEnvVarsSchema };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
exports_external
|
|
4
|
+
} from "./chunk-skzxcba3.js";
|
|
5
|
+
|
|
6
|
+
// src/health-checks.ts
|
|
7
|
+
var healthCheckSeverityValues = ["required", "warn"];
|
|
8
|
+
var healthCheckBaseSchema = exports_external.object({
|
|
9
|
+
name: exports_external.string().trim().min(1).optional(),
|
|
10
|
+
severity: exports_external.enum(healthCheckSeverityValues).default("required"),
|
|
11
|
+
timeoutSeconds: exports_external.number().gt(0).max(3600).default(15),
|
|
12
|
+
serialGroup: exports_external.string().trim().min(1).optional()
|
|
13
|
+
});
|
|
14
|
+
var toolHealthCheckSchema = healthCheckBaseSchema.extend({
|
|
15
|
+
kind: exports_external.literal("tool").default("tool"),
|
|
16
|
+
tool: exports_external.string().trim().min(1),
|
|
17
|
+
mcp: exports_external.string().trim().min(1).optional(),
|
|
18
|
+
args: exports_external.record(exports_external.string(), exports_external.unknown()).optional()
|
|
19
|
+
}).strict();
|
|
20
|
+
var cliHealthCheckSchema = healthCheckBaseSchema.extend({
|
|
21
|
+
kind: exports_external.literal("cli"),
|
|
22
|
+
command: exports_external.array(exports_external.string().min(1)).min(1),
|
|
23
|
+
expectExitCode: exports_external.int().default(0)
|
|
24
|
+
}).strict();
|
|
25
|
+
function injectDefaultKind(value) {
|
|
26
|
+
if (typeof value === "object" && value !== null && !("kind" in value)) {
|
|
27
|
+
return { ...value, kind: "tool" };
|
|
28
|
+
}
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
31
|
+
var healthCheckSchema = exports_external.preprocess(injectDefaultKind, exports_external.discriminatedUnion("kind", [toolHealthCheckSchema, cliHealthCheckSchema]));
|
|
32
|
+
var healthChecksSchema = exports_external.array(healthCheckSchema);
|
|
33
|
+
var stepToolHealthCheckSchema = toolHealthCheckSchema.omit({ mcp: true }).strict();
|
|
34
|
+
var stepHealthChecksInputSchema = exports_external.array(exports_external.preprocess(injectDefaultKind, exports_external.discriminatedUnion("kind", [
|
|
35
|
+
stepToolHealthCheckSchema,
|
|
36
|
+
cliHealthCheckSchema
|
|
37
|
+
])));
|
|
38
|
+
|
|
39
|
+
export { healthCheckSeverityValues, toolHealthCheckSchema, cliHealthCheckSchema, healthCheckSchema, healthChecksSchema, stepToolHealthCheckSchema, stepHealthChecksInputSchema };
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
ScarnClient,
|
|
4
|
+
TaskRuns,
|
|
5
|
+
createClient
|
|
6
|
+
} from "./chunk-vfeytkqx.js";
|
|
7
|
+
// src/task-plane-client.ts
|
|
8
|
+
function unwrap(result) {
|
|
9
|
+
if (result.error)
|
|
10
|
+
throw new Error(JSON.stringify(result.error));
|
|
11
|
+
return result.data;
|
|
12
|
+
}
|
|
13
|
+
function createTaskPlaneClient(baseUrl, options) {
|
|
14
|
+
const client = createClient({ baseUrl, headers: options?.headers });
|
|
15
|
+
return buildTaskPlaneClient(new TaskRuns({ client }));
|
|
16
|
+
}
|
|
17
|
+
var buildTaskPlaneClient = (taskRuns) => {
|
|
18
|
+
return {
|
|
19
|
+
claimTaskRuns: async (input) => unwrap(await taskRuns.claimTaskRuns({ body: input })),
|
|
20
|
+
heartbeatTaskRun: async ({
|
|
21
|
+
taskRunId,
|
|
22
|
+
...body
|
|
23
|
+
}) => {
|
|
24
|
+
unwrap(await taskRuns.heartbeatTaskRun({ path: { taskRunId }, body }));
|
|
25
|
+
},
|
|
26
|
+
getTaskRun: async ({ taskRunId }) => unwrap(await taskRuns.getTaskRun({ path: { taskRunId } })),
|
|
27
|
+
getTaskLogArchive: ({ taskRunId }) => taskRuns.getTaskLogArchive({ path: { taskRunId } }),
|
|
28
|
+
readTaskLogs: ({
|
|
29
|
+
taskRunId,
|
|
30
|
+
...query
|
|
31
|
+
}) => taskRuns.readTaskLogs({ path: { taskRunId }, query }),
|
|
32
|
+
getTaskRunWorkerContext: async ({
|
|
33
|
+
taskRunId,
|
|
34
|
+
...body
|
|
35
|
+
}) => unwrap(await taskRuns.getTaskRunWorkerContext({ path: { taskRunId }, body })),
|
|
36
|
+
completeTaskRun: async ({
|
|
37
|
+
taskRunId,
|
|
38
|
+
...body
|
|
39
|
+
}) => {
|
|
40
|
+
unwrap(await taskRuns.completeTaskRun({
|
|
41
|
+
path: { taskRunId },
|
|
42
|
+
body: { ...body, status: "succeeded" }
|
|
43
|
+
}));
|
|
44
|
+
},
|
|
45
|
+
failTaskRun: async ({
|
|
46
|
+
taskRunId,
|
|
47
|
+
...body
|
|
48
|
+
}) => {
|
|
49
|
+
unwrap(await taskRuns.completeTaskRun({
|
|
50
|
+
path: { taskRunId },
|
|
51
|
+
body: { ...body, status: "failed" }
|
|
52
|
+
}));
|
|
53
|
+
},
|
|
54
|
+
yieldTaskRun: async ({
|
|
55
|
+
taskRunId,
|
|
56
|
+
...body
|
|
57
|
+
}) => {
|
|
58
|
+
unwrap(await taskRuns.yieldTaskRun({ path: { taskRunId }, body }));
|
|
59
|
+
},
|
|
60
|
+
appendTaskLogs: async ({
|
|
61
|
+
taskRunId,
|
|
62
|
+
...body
|
|
63
|
+
}) => unwrap(await taskRuns.appendTaskLogs({ path: { taskRunId }, body })),
|
|
64
|
+
createArtifactUploadUrl: async ({
|
|
65
|
+
taskRunId,
|
|
66
|
+
...body
|
|
67
|
+
}) => unwrap(await taskRuns.createArtifactUploadUrl({ path: { taskRunId }, body })),
|
|
68
|
+
createSessionUploadUrl: async ({
|
|
69
|
+
taskRunId,
|
|
70
|
+
...body
|
|
71
|
+
}) => unwrap(await taskRuns.createSessionUploadUrl({ path: { taskRunId }, body })),
|
|
72
|
+
recordArtifact: async ({
|
|
73
|
+
taskRunId,
|
|
74
|
+
...body
|
|
75
|
+
}) => {
|
|
76
|
+
unwrap(await taskRuns.recordTaskArtifact({ path: { taskRunId }, body }));
|
|
77
|
+
},
|
|
78
|
+
recordArtifactFailure: async ({
|
|
79
|
+
taskRunId,
|
|
80
|
+
...body
|
|
81
|
+
}) => {
|
|
82
|
+
unwrap(await taskRuns.recordTaskArtifactFailure({ path: { taskRunId }, body }));
|
|
83
|
+
},
|
|
84
|
+
listTaskArtifacts: async ({ taskRunId }) => unwrap(await taskRuns.listTaskArtifacts({ path: { taskRunId } })),
|
|
85
|
+
getArtifactDownloadUrl: async ({
|
|
86
|
+
taskRunId,
|
|
87
|
+
artifactId
|
|
88
|
+
}) => unwrap(await taskRuns.getArtifactDownloadUrl({
|
|
89
|
+
path: { taskRunId, artifactId }
|
|
90
|
+
}))
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
// src/client.ts
|
|
95
|
+
function createScarnClient(baseUrl) {
|
|
96
|
+
const client = createClient({ baseUrl });
|
|
97
|
+
return new ScarnClient({ client });
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export { createTaskPlaneClient, createScarnClient };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/push/code-step-lookup.ts
|
|
3
|
+
function isStepDefinitionSpec(value) {
|
|
4
|
+
if (typeof value !== "object" && typeof value !== "function")
|
|
5
|
+
return false;
|
|
6
|
+
if (value === null)
|
|
7
|
+
return false;
|
|
8
|
+
const obj = value;
|
|
9
|
+
return typeof obj["key"] === "string" && typeof obj["name"] === "string" && typeof obj["version"] === "number" && (obj["kind"] === "user_defined" || obj["kind"] === "code");
|
|
10
|
+
}
|
|
11
|
+
function stepsInModule(mod) {
|
|
12
|
+
const found = new Set;
|
|
13
|
+
for (const [exportName, value] of Object.entries(mod)) {
|
|
14
|
+
if (exportName !== "default" && isStepDefinitionSpec(value)) {
|
|
15
|
+
found.add(value);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return [...found];
|
|
19
|
+
}
|
|
20
|
+
function findCodeStepInModule(mod, key) {
|
|
21
|
+
const fns = new Set;
|
|
22
|
+
for (const spec of stepsInModule(mod)) {
|
|
23
|
+
if (spec.kind !== "code" || spec.key !== key)
|
|
24
|
+
continue;
|
|
25
|
+
const fn = spec.entrypoint?.fn;
|
|
26
|
+
if (typeof fn === "function")
|
|
27
|
+
fns.add(fn);
|
|
28
|
+
}
|
|
29
|
+
if (fns.size > 1) {
|
|
30
|
+
throw new Error(`Code step "${key}" is ambiguous: ${String(fns.size)} distinct functions are registered under that key in the same module.`);
|
|
31
|
+
}
|
|
32
|
+
return fns.values().next().value;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export { isStepDefinitionSpec, stepsInModule, findCodeStepInModule };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
exports_external
|
|
4
|
+
} from "./chunk-skzxcba3.js";
|
|
5
|
+
|
|
6
|
+
// src/repo-config.ts
|
|
7
|
+
var MAX_REPO_COMMIT_MESSAGE_LENGTH = 500;
|
|
8
|
+
var REPO_COMMIT_MESSAGE_TOKEN_ROOTS = [
|
|
9
|
+
"input",
|
|
10
|
+
"result"
|
|
11
|
+
];
|
|
12
|
+
var TOKEN_PATTERN = /\{\{([^}]+)\}\}/g;
|
|
13
|
+
function findDisallowedCommitMessageTokenRoots(message) {
|
|
14
|
+
const disallowed = [];
|
|
15
|
+
for (const match of message.matchAll(TOKEN_PATTERN)) {
|
|
16
|
+
const root = (match[1] ?? "").split(".")[0] ?? "";
|
|
17
|
+
if (!REPO_COMMIT_MESSAGE_TOKEN_ROOTS.includes(root))
|
|
18
|
+
disallowed.push(root);
|
|
19
|
+
}
|
|
20
|
+
return disallowed;
|
|
21
|
+
}
|
|
22
|
+
var repoCommitMessageSchema = exports_external.string().max(MAX_REPO_COMMIT_MESSAGE_LENGTH).refine((message) => !/[\r\n]/.test(message), {
|
|
23
|
+
message: "must be a single line"
|
|
24
|
+
}).refine((message) => findDisallowedCommitMessageTokenRoots(message).length === 0, {
|
|
25
|
+
message: `may only use {{${REPO_COMMIT_MESSAGE_TOKEN_ROOTS.join(".\u2026}}, {{")}.\u2026}} tokens`
|
|
26
|
+
});
|
|
27
|
+
var onPushFailureSchema = exports_external.enum(["fail", "warn"]);
|
|
28
|
+
var repoConfigInputSchema = exports_external.discriminatedUnion("mode", [
|
|
29
|
+
exports_external.object({ mode: exports_external.literal("none") }).strict(),
|
|
30
|
+
exports_external.object({ mode: exports_external.literal("readOnly") }).strict(),
|
|
31
|
+
exports_external.object({
|
|
32
|
+
mode: exports_external.literal("readWrite"),
|
|
33
|
+
message: repoCommitMessageSchema.nullish(),
|
|
34
|
+
onPushFailure: onPushFailureSchema.optional()
|
|
35
|
+
}).strict()
|
|
36
|
+
]);
|
|
37
|
+
var repoConfigSchema = exports_external.discriminatedUnion("mode", [
|
|
38
|
+
exports_external.object({ mode: exports_external.literal("none") }).strict(),
|
|
39
|
+
exports_external.object({ mode: exports_external.literal("readOnly") }).strict(),
|
|
40
|
+
exports_external.object({
|
|
41
|
+
mode: exports_external.literal("readWrite"),
|
|
42
|
+
message: repoCommitMessageSchema.nullable(),
|
|
43
|
+
onPushFailure: onPushFailureSchema
|
|
44
|
+
}).strict()
|
|
45
|
+
]);
|
|
46
|
+
var REPO_RUNTIME_SUPPORT = {
|
|
47
|
+
workspace: {
|
|
48
|
+
modes: ["readOnly", "readWrite"],
|
|
49
|
+
default: "readWrite",
|
|
50
|
+
unsupportedBecause: "a devcontainer step reads its config from the clone"
|
|
51
|
+
},
|
|
52
|
+
no_workspace: {
|
|
53
|
+
modes: ["none"],
|
|
54
|
+
default: "none",
|
|
55
|
+
unsupportedBecause: "a host step has no clone"
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
function repoRuntimeMismatch(executionMode, mode) {
|
|
59
|
+
const support = REPO_RUNTIME_SUPPORT[executionMode];
|
|
60
|
+
return support.modes.includes(mode) ? null : support.unsupportedBecause;
|
|
61
|
+
}
|
|
62
|
+
function resolveRepoConfig(executionMode, input) {
|
|
63
|
+
const mode = input?.mode ?? REPO_RUNTIME_SUPPORT[executionMode].default;
|
|
64
|
+
if (mode !== "readWrite")
|
|
65
|
+
return { mode };
|
|
66
|
+
const readWrite = input?.mode === "readWrite" ? input : undefined;
|
|
67
|
+
return {
|
|
68
|
+
mode,
|
|
69
|
+
message: readWrite?.message ?? null,
|
|
70
|
+
onPushFailure: readWrite?.onPushFailure ?? "fail"
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export { MAX_REPO_COMMIT_MESSAGE_LENGTH, REPO_COMMIT_MESSAGE_TOKEN_ROOTS, findDisallowedCommitMessageTokenRoots, repoCommitMessageSchema, repoConfigInputSchema, repoConfigSchema, REPO_RUNTIME_SUPPORT, repoRuntimeMismatch, resolveRepoConfig };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/contracts/pipeline-document/built-ins.ts
|
|
3
|
+
var BUILT_IN_ERRORS = [
|
|
4
|
+
"Scarn.All",
|
|
5
|
+
"Scarn.StepFailed",
|
|
6
|
+
"Scarn.HealthCheckFailed",
|
|
7
|
+
"Scarn.Timeout",
|
|
8
|
+
"Scarn.HeartbeatTimeout",
|
|
9
|
+
"Scarn.MaxRunsExceeded",
|
|
10
|
+
"Scarn.MaxTurnsExceeded",
|
|
11
|
+
"Scarn.ConditionError",
|
|
12
|
+
"Scarn.ArgsError"
|
|
13
|
+
];
|
|
14
|
+
var WAIT_ERRORS = [
|
|
15
|
+
"Scarn.All",
|
|
16
|
+
"Scarn.MaxRunsExceeded",
|
|
17
|
+
"Scarn.ArgsError"
|
|
18
|
+
];
|
|
19
|
+
function decisionResultSchema(actions) {
|
|
20
|
+
const keys = [...new Set(actions.map((action) => action.key))];
|
|
21
|
+
return {
|
|
22
|
+
title: "DecisionResult",
|
|
23
|
+
type: "object",
|
|
24
|
+
properties: {
|
|
25
|
+
action: keys.length === 0 ? { type: "string" } : { type: "string", enum: keys },
|
|
26
|
+
body: { type: ["string", "null"] }
|
|
27
|
+
},
|
|
28
|
+
required: ["action", "body"],
|
|
29
|
+
additionalProperties: false
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
var REPLY_RESULT_SCHEMA = {
|
|
33
|
+
title: "ReplyResult",
|
|
34
|
+
type: "object",
|
|
35
|
+
properties: {
|
|
36
|
+
replied: { type: "boolean" },
|
|
37
|
+
body: { type: ["string", "null"] },
|
|
38
|
+
commentId: { type: ["string", "null"] }
|
|
39
|
+
},
|
|
40
|
+
required: ["replied", "body", "commentId"],
|
|
41
|
+
additionalProperties: false
|
|
42
|
+
};
|
|
43
|
+
var CONVERSATION_RESULT_SCHEMA = {
|
|
44
|
+
title: "ConversationResult",
|
|
45
|
+
type: "object",
|
|
46
|
+
properties: {
|
|
47
|
+
conversationId: { type: "string" },
|
|
48
|
+
summary: { type: "string" }
|
|
49
|
+
},
|
|
50
|
+
required: ["conversationId", "summary"],
|
|
51
|
+
additionalProperties: false
|
|
52
|
+
};
|
|
53
|
+
var REPLY_INPUT_SCHEMA = {
|
|
54
|
+
type: "array",
|
|
55
|
+
items: { type: "string" }
|
|
56
|
+
};
|
|
57
|
+
var ERROR_SCHEMA = {
|
|
58
|
+
title: "Error",
|
|
59
|
+
type: "object",
|
|
60
|
+
properties: {
|
|
61
|
+
name: { type: "string" },
|
|
62
|
+
message: { type: "string" },
|
|
63
|
+
cause: {}
|
|
64
|
+
},
|
|
65
|
+
required: ["name", "message"]
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export { BUILT_IN_ERRORS, WAIT_ERRORS, decisionResultSchema, REPLY_RESULT_SCHEMA, CONVERSATION_RESULT_SCHEMA, REPLY_INPUT_SCHEMA, ERROR_SCHEMA };
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
exports_external
|
|
4
|
+
} from "./chunk-skzxcba3.js";
|
|
5
|
+
|
|
6
|
+
// src/opencode-mcp.ts
|
|
7
|
+
var nonEmptyStringSchema = exports_external.string().trim().min(1);
|
|
8
|
+
var mcpStringMapSchema = exports_external.record(exports_external.string(), exports_external.string());
|
|
9
|
+
var positiveIntSchema = exports_external.int().gt(0).max(Number.MAX_SAFE_INTEGER);
|
|
10
|
+
var openCodeMcpTimeoutSchema = exports_external.object({
|
|
11
|
+
startup: positiveIntSchema.optional(),
|
|
12
|
+
catalog: positiveIntSchema.optional(),
|
|
13
|
+
execution: positiveIntSchema.optional()
|
|
14
|
+
}).strict();
|
|
15
|
+
var openCodeMcpProtocolSchema = exports_external.enum([
|
|
16
|
+
"legacy",
|
|
17
|
+
"auto",
|
|
18
|
+
"2026-07-28"
|
|
19
|
+
]);
|
|
20
|
+
var sharedServerFields = {
|
|
21
|
+
disabled: exports_external.boolean().optional(),
|
|
22
|
+
codemode: exports_external.boolean().optional(),
|
|
23
|
+
timeout: openCodeMcpTimeoutSchema.optional(),
|
|
24
|
+
protocol: openCodeMcpProtocolSchema.optional()
|
|
25
|
+
};
|
|
26
|
+
var openCodeMcpLocalConfigSchema = exports_external.object({
|
|
27
|
+
type: exports_external.literal("local"),
|
|
28
|
+
command: exports_external.array(nonEmptyStringSchema).min(1),
|
|
29
|
+
cwd: exports_external.string().optional(),
|
|
30
|
+
environment: mcpStringMapSchema.optional(),
|
|
31
|
+
...sharedServerFields
|
|
32
|
+
}).strict();
|
|
33
|
+
var openCodeMcpOAuthConfigSchema = exports_external.object({
|
|
34
|
+
client_id: exports_external.string().optional(),
|
|
35
|
+
client_secret: exports_external.string().optional(),
|
|
36
|
+
scope: exports_external.string().optional(),
|
|
37
|
+
callback_port: positiveIntSchema.optional(),
|
|
38
|
+
redirect_uri: exports_external.string().optional(),
|
|
39
|
+
auth_server_metadata_url: exports_external.string().optional()
|
|
40
|
+
}).strict();
|
|
41
|
+
var openCodeMcpRemoteConfigSchema = exports_external.object({
|
|
42
|
+
type: exports_external.literal("remote"),
|
|
43
|
+
url: exports_external.string(),
|
|
44
|
+
headers: mcpStringMapSchema.optional(),
|
|
45
|
+
oauth: exports_external.union([openCodeMcpOAuthConfigSchema, exports_external.literal(false)]).optional(),
|
|
46
|
+
...sharedServerFields
|
|
47
|
+
}).strict();
|
|
48
|
+
var openCodeMcpRefConfigSchema = exports_external.object({
|
|
49
|
+
type: exports_external.literal("ref"),
|
|
50
|
+
name: nonEmptyStringSchema.optional(),
|
|
51
|
+
...sharedServerFields
|
|
52
|
+
}).strict();
|
|
53
|
+
var openCodeResolvedMcpServerConfigSchema = exports_external.discriminatedUnion("type", [openCodeMcpLocalConfigSchema, openCodeMcpRemoteConfigSchema]);
|
|
54
|
+
var openCodeResolvedMcpServersSchema = exports_external.record(exports_external.string(), openCodeResolvedMcpServerConfigSchema);
|
|
55
|
+
var openCodeMcpServerConfigSchema = exports_external.discriminatedUnion("type", [
|
|
56
|
+
openCodeMcpLocalConfigSchema,
|
|
57
|
+
openCodeMcpRemoteConfigSchema,
|
|
58
|
+
openCodeMcpRefConfigSchema
|
|
59
|
+
]);
|
|
60
|
+
var openCodeMcpServersSchema = exports_external.record(exports_external.string(), openCodeMcpServerConfigSchema);
|
|
61
|
+
var ENV_PLACEHOLDER_PATTERN = /\{env:[A-Za-z_][A-Za-z0-9_]*\}/gu;
|
|
62
|
+
var ENV_PLACEHOLDER_NAME_PATTERN = /\{env:([^}]+)\}/gu;
|
|
63
|
+
var AUTH_SCHEME_PATTERN = /^(?:bearer|basic|token)\s+/iu;
|
|
64
|
+
function isEnvPlaceholderValue(value) {
|
|
65
|
+
if (value.match(ENV_PLACEHOLDER_PATTERN) === null)
|
|
66
|
+
return false;
|
|
67
|
+
return value.trim().replace(AUTH_SCHEME_PATTERN, "").replace(ENV_PLACEHOLDER_PATTERN, "").trim() === "";
|
|
68
|
+
}
|
|
69
|
+
function collectEnvPlaceholderNames(value) {
|
|
70
|
+
const names = new Set;
|
|
71
|
+
const visit = (item) => {
|
|
72
|
+
if (typeof item === "string") {
|
|
73
|
+
for (const match of item.matchAll(ENV_PLACEHOLDER_NAME_PATTERN)) {
|
|
74
|
+
if (match[1] !== undefined)
|
|
75
|
+
names.add(match[1]);
|
|
76
|
+
}
|
|
77
|
+
} else if (typeof item === "object" && item !== null) {
|
|
78
|
+
for (const child of Object.values(item))
|
|
79
|
+
visit(child);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
visit(value);
|
|
83
|
+
return [...names].sort();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export { openCodeMcpTimeoutSchema, openCodeMcpProtocolSchema, openCodeMcpLocalConfigSchema, openCodeMcpOAuthConfigSchema, openCodeMcpRemoteConfigSchema, openCodeMcpRefConfigSchema, openCodeResolvedMcpServerConfigSchema, openCodeResolvedMcpServersSchema, openCodeMcpServerConfigSchema, openCodeMcpServersSchema, isEnvPlaceholderValue, collectEnvPlaceholderNames };
|