@scarn/sdk 0.0.0-stage → 0.0.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-4361gxk0.js +166 -0
- package/dist/chunk-4vehh3dq.js +333 -0
- package/dist/chunk-56e4kp0a.js +162 -0
- package/dist/chunk-5mmj03ah.js +1074 -0
- package/dist/chunk-631ffb6r.js +57 -0
- package/dist/chunk-91p9vzcs.js +1453 -0
- package/dist/chunk-9s07v9r1.js +30 -0
- package/dist/chunk-b21233rt.js +78 -0
- package/dist/chunk-dnn39qt4.js +13539 -0
- package/dist/chunk-eg1hcvhb.js +300 -0
- package/dist/chunk-g0rdnn0r.js +95 -0
- package/dist/chunk-h9yxx0hd.js +116 -0
- package/dist/chunk-njd6npf0.js +35 -0
- package/dist/chunk-ny07ncb9.js +330 -0
- package/dist/chunk-p6kc9wq8.js +97 -0
- package/dist/chunk-qpw5wt1p.js +257 -0
- package/dist/chunk-rq3q8vg7.js +1094 -0
- package/dist/chunk-s0gap8r8.js +14 -0
- package/dist/chunk-tfm5hjzm.js +100 -0
- package/dist/chunk-ynk2bjae.js +1686 -0
- package/dist/chunk-zpqyjgb4.js +49 -0
- package/dist/client.d.ts +4 -0
- package/dist/client.js +57 -0
- package/dist/contracts/artifact-markers.d.ts +42 -0
- package/dist/contracts/artifact-markers.js +15 -0
- package/dist/contracts/artifacts.d.ts +67 -0
- package/dist/contracts/artifacts.js +25 -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 +97 -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 +174 -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 +1239 -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 +24 -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 +73 -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 +17 -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 +13 -0
- package/dist/env-vars.d.ts +136 -0
- package/dist/env-vars.js +35 -0
- package/dist/eslint.d.ts +42 -0
- package/dist/eslint.js +125 -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 +18368 -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 +159 -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 +19 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +293 -0
- package/dist/jsonc.d.ts +3 -0
- package/dist/jsonc.js +11 -0
- package/dist/managed-runtimes.d.ts +20 -0
- package/dist/managed-runtimes.js +13 -0
- package/dist/opencode-mcp.d.ts +313 -0
- package/dist/opencode-mcp.js +29 -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 +80 -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 +11 -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 +328 -0
- package/dist/push/push-from-directory.d.ts +37 -0
- package/dist/repo-config.d.ts +80 -0
- package/dist/repo-config.js +23 -0
- package/dist/scarn-config-parser.d.ts +29 -0
- package/dist/scarn-config-parser.js +9 -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,136 @@
|
|
|
1
|
+
import { type EnvVarApplies, type EnvVarsInput } from "../../env-vars";
|
|
2
|
+
import { type PromptInputProxy } from "./prompt-template";
|
|
3
|
+
/**
|
|
4
|
+
* True for names that look like they hold a credential. A static (input-free)
|
|
5
|
+
* literal on such a name is rejected at definition time unless the author opts
|
|
6
|
+
* in with `unsafeAllowStatic`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function isSecretLookingEnvName(name: string): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Which process a variable reaches. `agent` (the default) is the agent or code
|
|
11
|
+
* step process. `setup` is only the `devcontainer up` process, where
|
|
12
|
+
* `initializeCommand` runs; it overrides the worker's own variable of the same
|
|
13
|
+
* name and is not added to the container, so forward it with
|
|
14
|
+
* `${localEnv:NAME:default}` in `devcontainer.json` if the container needs it.
|
|
15
|
+
* `both` is both. `setup` and `both` are rejected on `Runtime.host()`, which
|
|
16
|
+
* has no container to set up.
|
|
17
|
+
*/
|
|
18
|
+
export type EnvAppliesOpt = {
|
|
19
|
+
readonly applies?: EnvVarApplies;
|
|
20
|
+
};
|
|
21
|
+
export type ValueOpts = EnvAppliesOpt & {
|
|
22
|
+
readonly value: string;
|
|
23
|
+
readonly secret?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Allows a static (input-free) value on a secret-looking name such as
|
|
26
|
+
* `API_TOKEN`. Never serialized. A static value is still stored in
|
|
27
|
+
* plaintext, so only use this for values that are not actually secret.
|
|
28
|
+
*/
|
|
29
|
+
readonly unsafeAllowStatic?: boolean;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* `secret: true` and `default` are mutually exclusive: a default is stored in
|
|
33
|
+
* the definition in plaintext.
|
|
34
|
+
*/
|
|
35
|
+
export type InheritOpts = EnvAppliesOpt & ({
|
|
36
|
+
readonly from?: string;
|
|
37
|
+
readonly secret: true;
|
|
38
|
+
readonly optional?: boolean;
|
|
39
|
+
readonly default?: never;
|
|
40
|
+
} | {
|
|
41
|
+
readonly from?: string;
|
|
42
|
+
readonly secret?: false;
|
|
43
|
+
readonly optional?: boolean;
|
|
44
|
+
readonly default?: string;
|
|
45
|
+
});
|
|
46
|
+
export type EnvValue<TSecret extends boolean = boolean> = {
|
|
47
|
+
readonly kind: "value";
|
|
48
|
+
readonly value: string;
|
|
49
|
+
readonly secret: TSecret;
|
|
50
|
+
readonly unsafeAllowStatic: boolean;
|
|
51
|
+
readonly applies: EnvVarApplies;
|
|
52
|
+
};
|
|
53
|
+
export type EnvInherit<TSecret extends boolean = boolean, TOptional extends boolean = boolean, TDefault extends string | undefined = string | undefined> = {
|
|
54
|
+
readonly kind: "inherit";
|
|
55
|
+
readonly from: string | undefined;
|
|
56
|
+
readonly secret: TSecret;
|
|
57
|
+
readonly optional: TOptional;
|
|
58
|
+
readonly default: TDefault;
|
|
59
|
+
readonly applies: EnvVarApplies;
|
|
60
|
+
};
|
|
61
|
+
export type EnvEntry = string | EnvValue | EnvInherit;
|
|
62
|
+
export type EnvRecord = Record<string, EnvEntry>;
|
|
63
|
+
/** Runs once at definition time, against the same input proxy `agentPrompt` uses. */
|
|
64
|
+
export type EnvFn<TInput, TEnv extends EnvRecord = EnvRecord> = (context: {
|
|
65
|
+
input: PromptInputProxy<TInput>;
|
|
66
|
+
}) => TEnv;
|
|
67
|
+
type SecretOf<O> = O extends {
|
|
68
|
+
secret: infer S;
|
|
69
|
+
} ? S extends false ? false : true : false;
|
|
70
|
+
type OptionalOf<O> = O extends {
|
|
71
|
+
optional: infer P;
|
|
72
|
+
} ? P extends false ? false : true : false;
|
|
73
|
+
type DefaultOf<O> = O extends {
|
|
74
|
+
default: infer D extends string;
|
|
75
|
+
} ? D : undefined;
|
|
76
|
+
type PromptEntryValue<E> = E extends {
|
|
77
|
+
kind: "inherit";
|
|
78
|
+
} ? E extends {
|
|
79
|
+
default: string;
|
|
80
|
+
} ? string : E extends {
|
|
81
|
+
optional: false;
|
|
82
|
+
} ? string : string | undefined : string;
|
|
83
|
+
/**
|
|
84
|
+
* The `env` object an `agentPrompt` callback receives when the step declares
|
|
85
|
+
* `environment.vars`: only declared, non-secret keys. An entry whose secrecy is
|
|
86
|
+
* not provably `false` is dropped.
|
|
87
|
+
*/
|
|
88
|
+
export type PromptEnv<TEnv extends EnvRecord> = {
|
|
89
|
+
[K in keyof TEnv as TEnv[K] extends string ? K : TEnv[K] extends {
|
|
90
|
+
secret: false;
|
|
91
|
+
} ? K : never]: PromptEntryValue<TEnv[K]>;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* The prompt `env` type for a step: strict (`PromptEnv`) once
|
|
95
|
+
* `environment.vars` is declared, today's loose record otherwise. Undeclared
|
|
96
|
+
* `vars` leaves `TEnv` at its `EnvRecord` default, whose index signature is the
|
|
97
|
+
* marker.
|
|
98
|
+
*/
|
|
99
|
+
export type PromptEnvContext<TEnv extends EnvRecord> = string extends keyof TEnv ? PromptInputProxy<Record<string, string | undefined>> : PromptEnv<TEnv>;
|
|
100
|
+
export declare const Env: {
|
|
101
|
+
/**
|
|
102
|
+
* A literal or `{{input.…}}` template value. Same as writing a bare string,
|
|
103
|
+
* with an explicit `secret` flag.
|
|
104
|
+
*
|
|
105
|
+
* - Source: the step definition itself, rendered against the run's input.
|
|
106
|
+
* - Stored: yes, as the template, in plaintext. Visible in the API and UI.
|
|
107
|
+
* - Masked: in logs, when `secret` is true. A secret must contain an
|
|
108
|
+
* `{{input.…}}` token, because a static secret would be stored in
|
|
109
|
+
* plaintext.
|
|
110
|
+
*/
|
|
111
|
+
readonly value: <const O extends ValueOpts>(opts: O) => EnvValue<SecretOf<O>>;
|
|
112
|
+
/**
|
|
113
|
+
* Reads the variable from the **worker** host (`.scarn/.env`, then
|
|
114
|
+
* `process.env`), not from the devcontainer's `containerEnv`. The name
|
|
115
|
+
* defaults to the key; `from` renames it.
|
|
116
|
+
*
|
|
117
|
+
* - Source: the worker environment at run time.
|
|
118
|
+
* - Stored: only the variable name (plus `default`, which is plaintext).
|
|
119
|
+
* - Masked: in logs, when `secret` is true. A secret cannot carry a
|
|
120
|
+
* `default`.
|
|
121
|
+
*
|
|
122
|
+
* A required variable that is missing from the worker fails the step before
|
|
123
|
+
* it starts; `optional` omits it, and `default` fills it.
|
|
124
|
+
*
|
|
125
|
+
* `applies: "setup"` hands it to `devcontainer up` instead of the agent, for
|
|
126
|
+
* example to steer the repo's `initializeCommand`.
|
|
127
|
+
*/
|
|
128
|
+
readonly inherit: <const O extends InheritOpts = Record<never, never>>(opts?: O) => EnvInherit<SecretOf<O>, OptionalOf<O>, DefaultOf<O>>;
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* Runs the authored `environment.vars` function once and returns the wire
|
|
132
|
+
* shape, or `null` when the step declares no `vars` (or an empty record).
|
|
133
|
+
* Throws on a static secret, or a static literal on a secret-looking name.
|
|
134
|
+
*/
|
|
135
|
+
export declare function normalizeEnv<TInput>(fn: EnvFn<TInput> | undefined): EnvVarsInput | null;
|
|
136
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * as z from "../../z";
|
|
2
|
+
export * from "../artifacts";
|
|
3
|
+
export * from "./define-step";
|
|
4
|
+
export * from "./define-code-step";
|
|
5
|
+
export * from "./step-handle";
|
|
6
|
+
export * from "./step-ref";
|
|
7
|
+
export * from "./define-mcp";
|
|
8
|
+
export { compileMcps, type CompiledMcps } from "./compile-mcps";
|
|
9
|
+
export * from "./env";
|
|
10
|
+
export * from "./prompt-template";
|
|
11
|
+
export * from "./repo";
|
|
12
|
+
export * from "./runtime";
|
|
13
|
+
export * from "./step-definitions-client";
|
|
14
|
+
export * from "./step-features";
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
ARTIFACT_BRAND2,
|
|
4
|
+
ArtifactTypes2,
|
|
5
|
+
normalizeArtifactAccept2,
|
|
6
|
+
artifact2,
|
|
7
|
+
Artifact2,
|
|
8
|
+
exports_z,
|
|
9
|
+
createPromptInputProxy2,
|
|
10
|
+
createPromptTemplateContext2,
|
|
11
|
+
renderPromptTemplate2,
|
|
12
|
+
isSecretLookingEnvName2,
|
|
13
|
+
Env2,
|
|
14
|
+
normalizeEnv2,
|
|
15
|
+
Repo2,
|
|
16
|
+
compileRepo2,
|
|
17
|
+
Runtime2,
|
|
18
|
+
compileEnvironment2,
|
|
19
|
+
isMcpHandle2,
|
|
20
|
+
defineMcp2,
|
|
21
|
+
resolveMcpChecks2,
|
|
22
|
+
compileMcps2,
|
|
23
|
+
compileStepErrors2,
|
|
24
|
+
compileStepRetry2,
|
|
25
|
+
toStepHandle2,
|
|
26
|
+
toStepSpec2,
|
|
27
|
+
defineStep2,
|
|
28
|
+
codeStep2,
|
|
29
|
+
createStepDefinitionsClient2,
|
|
30
|
+
Features2,
|
|
31
|
+
Notify2
|
|
32
|
+
} from "../../chunk-91p9vzcs.js";
|
|
33
|
+
import"../../chunk-eg1hcvhb.js";
|
|
34
|
+
import"../../chunk-p6kc9wq8.js";
|
|
35
|
+
import"../../chunk-9s07v9r1.js";
|
|
36
|
+
import"../../chunk-s0gap8r8.js";
|
|
37
|
+
import"../../chunk-b21233rt.js";
|
|
38
|
+
import"../../chunk-g0rdnn0r.js";
|
|
39
|
+
import"../../chunk-zpqyjgb4.js";
|
|
40
|
+
import"../../chunk-631ffb6r.js";
|
|
41
|
+
import"../../chunk-56e4kp0a.js";
|
|
42
|
+
import"../../chunk-ynk2bjae.js";
|
|
43
|
+
export {
|
|
44
|
+
ARTIFACT_BRAND2 as ARTIFACT_BRAND,
|
|
45
|
+
Artifact2 as Artifact,
|
|
46
|
+
ArtifactTypes2 as ArtifactTypes,
|
|
47
|
+
Env2 as Env,
|
|
48
|
+
Features2 as Features,
|
|
49
|
+
Notify2 as Notify,
|
|
50
|
+
Repo2 as Repo,
|
|
51
|
+
Runtime2 as Runtime,
|
|
52
|
+
artifact2 as artifact,
|
|
53
|
+
codeStep2 as codeStep,
|
|
54
|
+
compileEnvironment2 as compileEnvironment,
|
|
55
|
+
compileMcps2 as compileMcps,
|
|
56
|
+
compileRepo2 as compileRepo,
|
|
57
|
+
compileStepErrors2 as compileStepErrors,
|
|
58
|
+
compileStepRetry2 as compileStepRetry,
|
|
59
|
+
createPromptInputProxy2 as createPromptInputProxy,
|
|
60
|
+
createPromptTemplateContext2 as createPromptTemplateContext,
|
|
61
|
+
createStepDefinitionsClient2 as createStepDefinitionsClient,
|
|
62
|
+
defineMcp2 as defineMcp,
|
|
63
|
+
defineStep2 as defineStep,
|
|
64
|
+
isMcpHandle2 as isMcpHandle,
|
|
65
|
+
isSecretLookingEnvName2 as isSecretLookingEnvName,
|
|
66
|
+
normalizeArtifactAccept2 as normalizeArtifactAccept,
|
|
67
|
+
normalizeEnv2 as normalizeEnv,
|
|
68
|
+
renderPromptTemplate2 as renderPromptTemplate,
|
|
69
|
+
resolveMcpChecks2 as resolveMcpChecks,
|
|
70
|
+
toStepHandle2 as toStepHandle,
|
|
71
|
+
toStepSpec2 as toStepSpec,
|
|
72
|
+
exports_z as z
|
|
73
|
+
};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
declare const refFieldsSchema: z.ZodObject<{
|
|
3
|
+
timeout: z.ZodOptional<z.ZodObject<{
|
|
4
|
+
startup: z.ZodOptional<z.ZodInt>;
|
|
5
|
+
catalog: z.ZodOptional<z.ZodInt>;
|
|
6
|
+
execution: z.ZodOptional<z.ZodInt>;
|
|
7
|
+
}, z.core.$strict>>;
|
|
8
|
+
protocol: z.ZodOptional<z.ZodEnum<{
|
|
9
|
+
auto: "auto";
|
|
10
|
+
legacy: "legacy";
|
|
11
|
+
"2026-07-28": "2026-07-28";
|
|
12
|
+
}>>;
|
|
13
|
+
codemode: z.ZodOptional<z.ZodBoolean>;
|
|
14
|
+
}, z.core.$strict>;
|
|
15
|
+
declare const localFieldsSchema: z.ZodObject<{
|
|
16
|
+
timeout: z.ZodOptional<z.ZodObject<{
|
|
17
|
+
startup: z.ZodOptional<z.ZodInt>;
|
|
18
|
+
catalog: z.ZodOptional<z.ZodInt>;
|
|
19
|
+
execution: z.ZodOptional<z.ZodInt>;
|
|
20
|
+
}, z.core.$strict>>;
|
|
21
|
+
command: z.ZodArray<z.ZodString>;
|
|
22
|
+
protocol: z.ZodOptional<z.ZodEnum<{
|
|
23
|
+
auto: "auto";
|
|
24
|
+
legacy: "legacy";
|
|
25
|
+
"2026-07-28": "2026-07-28";
|
|
26
|
+
}>>;
|
|
27
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
28
|
+
environment: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
29
|
+
codemode: z.ZodOptional<z.ZodBoolean>;
|
|
30
|
+
}, z.core.$strict>;
|
|
31
|
+
declare const remoteFieldsSchema: z.ZodObject<{
|
|
32
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
33
|
+
url: z.ZodString;
|
|
34
|
+
timeout: z.ZodOptional<z.ZodObject<{
|
|
35
|
+
startup: z.ZodOptional<z.ZodInt>;
|
|
36
|
+
catalog: z.ZodOptional<z.ZodInt>;
|
|
37
|
+
execution: z.ZodOptional<z.ZodInt>;
|
|
38
|
+
}, z.core.$strict>>;
|
|
39
|
+
protocol: z.ZodOptional<z.ZodEnum<{
|
|
40
|
+
auto: "auto";
|
|
41
|
+
legacy: "legacy";
|
|
42
|
+
"2026-07-28": "2026-07-28";
|
|
43
|
+
}>>;
|
|
44
|
+
oauth: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
45
|
+
client_id: z.ZodOptional<z.ZodString>;
|
|
46
|
+
client_secret: z.ZodOptional<z.ZodString>;
|
|
47
|
+
scope: z.ZodOptional<z.ZodString>;
|
|
48
|
+
callback_port: z.ZodOptional<z.ZodInt>;
|
|
49
|
+
redirect_uri: z.ZodOptional<z.ZodString>;
|
|
50
|
+
auth_server_metadata_url: z.ZodOptional<z.ZodString>;
|
|
51
|
+
}, z.core.$strict>, z.ZodLiteral<false>]>>;
|
|
52
|
+
codemode: z.ZodOptional<z.ZodBoolean>;
|
|
53
|
+
}, z.core.$strict>;
|
|
54
|
+
/** The shared OpenCode fields a `ref` applies on top of the repo's definition. */
|
|
55
|
+
export type McpRefServerFields = z.output<typeof refFieldsSchema>;
|
|
56
|
+
/** A `local` server: `command`, `cwd?`, `environment?` and the shared fields. */
|
|
57
|
+
export type McpLocalServerFields = z.output<typeof localFieldsSchema>;
|
|
58
|
+
/** A `remote` server: `url`, `headers?`, `oauth?` and the shared fields. */
|
|
59
|
+
export type McpRemoteServerFields = z.output<typeof remoteFieldsSchema>;
|
|
60
|
+
export type McpServerType = "ref" | "local" | "remote";
|
|
61
|
+
/**
|
|
62
|
+
* A `defineMcp` server. For `ref`, `name` is the server's name in the repo's
|
|
63
|
+
* MCP config. For `local`/`remote`, `name` only labels the server in errors;
|
|
64
|
+
* the step's `mcps` key names it at runtime.
|
|
65
|
+
*/
|
|
66
|
+
export type McpServerDefinition = {
|
|
67
|
+
readonly type: "ref";
|
|
68
|
+
readonly name: string;
|
|
69
|
+
readonly server: Readonly<McpRefServerFields>;
|
|
70
|
+
} | {
|
|
71
|
+
readonly type: "local";
|
|
72
|
+
readonly name: string;
|
|
73
|
+
readonly server: Readonly<McpLocalServerFields>;
|
|
74
|
+
} | {
|
|
75
|
+
readonly type: "remote";
|
|
76
|
+
readonly name: string;
|
|
77
|
+
readonly server: Readonly<McpRemoteServerFields>;
|
|
78
|
+
};
|
|
79
|
+
export type McpServerConfig = ({
|
|
80
|
+
type: "ref";
|
|
81
|
+
name: string;
|
|
82
|
+
} & z.input<typeof refFieldsSchema>) | ({
|
|
83
|
+
type: "local";
|
|
84
|
+
name: string;
|
|
85
|
+
} & z.input<typeof localFieldsSchema>) | ({
|
|
86
|
+
type: "remote";
|
|
87
|
+
name: string;
|
|
88
|
+
} & z.input<typeof remoteFieldsSchema>);
|
|
89
|
+
/**
|
|
90
|
+
* The `{env:VAR}` names an inline server reads, which compile into required
|
|
91
|
+
* env entries tagged with the server's key. Empty for a `ref`: the worker
|
|
92
|
+
* infers those from the repo's definition.
|
|
93
|
+
*/
|
|
94
|
+
export declare function inferredMcpEnv(definition: McpServerDefinition): string[];
|
|
95
|
+
/**
|
|
96
|
+
* Validates a `defineMcp` config's server half and returns it with its
|
|
97
|
+
* OpenCode fields parsed. Throws on an unknown `type`, an invalid field, a
|
|
98
|
+
* literal (non-`{env:VAR}`) `environment` or `headers` value, or a
|
|
99
|
+
* placeholder naming an invalid or reserved variable.
|
|
100
|
+
*/
|
|
101
|
+
export declare function parseMcpServer(config: McpServerConfig): McpServerDefinition;
|
|
102
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type that maps T to a string-embeddable proxy shape.
|
|
3
|
+
* `-?` strips optionality so `input.user?.email` and `input.user.email` both work —
|
|
4
|
+
* the proxy is never nullish, so optional chaining is a no-op at definition time.
|
|
5
|
+
* `& string` lets each node embed in template literals (`${input.title}`).
|
|
6
|
+
*/
|
|
7
|
+
export type PromptInputProxy<T> = {
|
|
8
|
+
[K in keyof T]-?: PromptInputProxy<NonNullable<T[K]>>;
|
|
9
|
+
} & string;
|
|
10
|
+
export type PromptTemplateContext<TInput, TPromptEnv = PromptInputProxy<Record<string, string | undefined>>> = {
|
|
11
|
+
input: PromptInputProxy<TInput>;
|
|
12
|
+
env: TPromptEnv;
|
|
13
|
+
scarn: {
|
|
14
|
+
artifactsDir: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export declare function createPromptInputProxy<T>(path?: string[]): PromptInputProxy<T>;
|
|
18
|
+
export declare function createPromptTemplateContext<TInput, TPromptEnv = PromptInputProxy<Record<string, string | undefined>>>(): PromptTemplateContext<TInput, TPromptEnv>;
|
|
19
|
+
/**
|
|
20
|
+
* Renders a prompt template string by replacing `{{dot.path}}` tokens with
|
|
21
|
+
* values resolved from the provided context object. Missing or null values
|
|
22
|
+
* are replaced with an empty string.
|
|
23
|
+
*/
|
|
24
|
+
export declare function renderPromptTemplate(template: string, contextJson: unknown): string;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { type RepoConfigInput } from "../../repo-config";
|
|
2
|
+
import { type PromptInputProxy } from "./prompt-template";
|
|
3
|
+
import type { RuntimeSpec } from "./runtime";
|
|
4
|
+
/**
|
|
5
|
+
* Authoring helpers for a step's `environment.repo` option, and the
|
|
6
|
+
* definition-time compilation that turns it into the `repo` wire field
|
|
7
|
+
* (`../../repo-config.ts`).
|
|
8
|
+
*/
|
|
9
|
+
/** The step gets no repository: no clone, branch, commit or push. */
|
|
10
|
+
export type NoneRepoSpec = {
|
|
11
|
+
readonly mode: "none";
|
|
12
|
+
};
|
|
13
|
+
/** Clones and checks out the base branch; creates no branch, commits and pushes nothing. */
|
|
14
|
+
export type ReadOnlyRepoSpec = {
|
|
15
|
+
readonly mode: "readOnly";
|
|
16
|
+
};
|
|
17
|
+
export type ReadWriteRepoSpec = {
|
|
18
|
+
readonly mode: "readWrite";
|
|
19
|
+
/**
|
|
20
|
+
* Commit message template; `{{input.…}}` and `{{result.…}}` tokens only, one
|
|
21
|
+
* line, at most 500 characters. Defaults to `scarn: task <taskId>`.
|
|
22
|
+
*/
|
|
23
|
+
readonly message?: string;
|
|
24
|
+
/** Defaults to `"fail"`: a failed push fails the step. */
|
|
25
|
+
readonly onPushFailure?: "fail" | "warn";
|
|
26
|
+
};
|
|
27
|
+
export type RepoSpec = NoneRepoSpec | ReadOnlyRepoSpec | ReadWriteRepoSpec;
|
|
28
|
+
/** What `Runtime.devcontainer()` accepts. */
|
|
29
|
+
export type DevcontainerRepoSpec = ReadOnlyRepoSpec | ReadWriteRepoSpec;
|
|
30
|
+
/** What `Runtime.host()` accepts. */
|
|
31
|
+
export type HostRepoSpec = NoneRepoSpec;
|
|
32
|
+
/** Runs once at definition time, against the same proxies `agentPrompt` and `vars` use. */
|
|
33
|
+
export type RepoFn<TInput, TResult, TSpec extends RepoSpec> = (context: {
|
|
34
|
+
input: PromptInputProxy<TInput>;
|
|
35
|
+
result: PromptInputProxy<TResult>;
|
|
36
|
+
}) => TSpec;
|
|
37
|
+
export type RepoField<TInput, TResult, TSpec extends RepoSpec> = TSpec | RepoFn<TInput, TResult, TSpec>;
|
|
38
|
+
export type ReadWriteRepoOpts = Omit<ReadWriteRepoSpec, "mode">;
|
|
39
|
+
export declare const Repo: {
|
|
40
|
+
/**
|
|
41
|
+
* The step gets no repository. What `Runtime.host()` already implies, stated
|
|
42
|
+
* as a value. Only valid with `Runtime.host()`.
|
|
43
|
+
*/
|
|
44
|
+
readonly none: () => NoneRepoSpec;
|
|
45
|
+
/**
|
|
46
|
+
* Clones and checks out the base branch, but creates no work branch, commits
|
|
47
|
+
* nothing, pushes nothing and reports no `workBranch`. A policy, not a
|
|
48
|
+
* sandbox: edits the agent makes stay in the workspace and are discarded.
|
|
49
|
+
*/
|
|
50
|
+
readonly readOnly: () => ReadOnlyRepoSpec;
|
|
51
|
+
/**
|
|
52
|
+
* Creates a work branch, then commits and pushes it when the step succeeds.
|
|
53
|
+
* This is the default for a devcontainer step.
|
|
54
|
+
*/
|
|
55
|
+
readonly readWrite: (opts?: ReadWriteRepoOpts) => ReadWriteRepoSpec;
|
|
56
|
+
};
|
|
57
|
+
export type CompileRepoContext = {
|
|
58
|
+
/** Named in error messages. */
|
|
59
|
+
readonly stepKey?: string;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Runs the authored `environment.repo` once (the function form against `input`
|
|
63
|
+
* and `result` proxies) and returns the wire shape, or `undefined` when the step
|
|
64
|
+
* declares no `repo`. Throws when the mode does not fit the runtime or breaks
|
|
65
|
+
* the `repoConfigInputSchema` rules.
|
|
66
|
+
*/
|
|
67
|
+
export declare function compileRepo<TInput, TResult>(repo: RepoField<TInput, TResult, RepoSpec> | undefined, runtime: RuntimeSpec | undefined, ctx?: CompileRepoContext): RepoConfigInput | undefined;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import type { EnvVarsInput } from "../../env-vars";
|
|
2
|
+
import { type ManagedRuntimeId } from "../../managed-runtimes";
|
|
3
|
+
import type { RepoConfigInput } from "../../repo-config";
|
|
4
|
+
import { type EnvFn, type EnvRecord } from "./env";
|
|
5
|
+
import { type CompileRepoContext, type DevcontainerRepoSpec, type HostRepoSpec, type RepoField } from "./repo";
|
|
6
|
+
/**
|
|
7
|
+
* Authoring helpers for a step's `environment` option, and the definition-time
|
|
8
|
+
* compilation that turns it into the wire fields `executionMode`,
|
|
9
|
+
* `managedRuntime`, `devcontainerConfigPath`, `envJson` and `repo`.
|
|
10
|
+
*/
|
|
11
|
+
/** Where a step runs. Build one with `Runtime.devcontainer()`, `Runtime.host()` or `Runtime.managed.<id>()`. */
|
|
12
|
+
export type DevcontainerRuntimeSpec = {
|
|
13
|
+
readonly kind: "devcontainer";
|
|
14
|
+
readonly config?: string;
|
|
15
|
+
};
|
|
16
|
+
export type HostRuntimeSpec = {
|
|
17
|
+
readonly kind: "host";
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* A worker-supplied container (image, config and dependency install owned by
|
|
21
|
+
* the worker). Build one with `Runtime.managed.<id>()`. `codeStep` only.
|
|
22
|
+
*/
|
|
23
|
+
export type ManagedRuntimeSpec<TId extends ManagedRuntimeId = ManagedRuntimeId> = {
|
|
24
|
+
readonly kind: "managed";
|
|
25
|
+
readonly id: TId;
|
|
26
|
+
};
|
|
27
|
+
export type RuntimeSpec = DevcontainerRuntimeSpec | HostRuntimeSpec | ManagedRuntimeSpec;
|
|
28
|
+
/**
|
|
29
|
+
* How a step runs: its `runtime`, its environment `vars` and its `repo` access.
|
|
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 takes
|
|
32
|
+
* `Repo.readOnly()` or `Repo.readWrite()`.
|
|
33
|
+
*
|
|
34
|
+
* Declare `vars` before `agentPrompt` so `TEnv` is inferred into the prompt's
|
|
35
|
+
* `env`, which is then strict: only declared, non-secret keys.
|
|
36
|
+
*/
|
|
37
|
+
export type StepEnvironment<TInput, TEnv extends EnvRecord = EnvRecord, TResult = unknown> = {
|
|
38
|
+
/** Defaults to `Runtime.devcontainer()`. */
|
|
39
|
+
runtime?: DevcontainerRuntimeSpec;
|
|
40
|
+
vars?: EnvFn<TInput, TEnv>;
|
|
41
|
+
/** Defaults to `Repo.readWrite()`. */
|
|
42
|
+
repo?: RepoField<TInput, TResult, DevcontainerRepoSpec>;
|
|
43
|
+
} | {
|
|
44
|
+
runtime: HostRuntimeSpec;
|
|
45
|
+
vars?: EnvFn<TInput, TEnv>;
|
|
46
|
+
/** Defaults to `Repo.none()`. */
|
|
47
|
+
repo?: RepoField<TInput, TResult, HostRepoSpec>;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* `codeStep`'s environment: `StepEnvironment`'s devcontainer variant plus
|
|
51
|
+
* managed runtimes. A code step runs repo code, which needs a clone, and the
|
|
52
|
+
* host runtime has none.
|
|
53
|
+
*/
|
|
54
|
+
export type CodeStepEnvironment<TInput, TResult = unknown> = {
|
|
55
|
+
/**
|
|
56
|
+
* Defaults to `Runtime.managed.bun1()`. `Runtime.devcontainer()` opts into the
|
|
57
|
+
* project's own container. `Runtime.host()` is not supported.
|
|
58
|
+
*/
|
|
59
|
+
runtime?: DevcontainerRuntimeSpec | ManagedRuntimeSpec;
|
|
60
|
+
vars?: EnvFn<TInput>;
|
|
61
|
+
/** Defaults to `Repo.readWrite()`. */
|
|
62
|
+
repo?: RepoField<TInput, TResult, DevcontainerRepoSpec>;
|
|
63
|
+
};
|
|
64
|
+
export type DevcontainerRuntimeOpts = {
|
|
65
|
+
/**
|
|
66
|
+
* Full repo-relative path to the devcontainer config, e.g.
|
|
67
|
+
* `.devcontainer/frontend/devcontainer.json`. The basename must be
|
|
68
|
+
* `devcontainer.json` or `.devcontainer.json`. There is no fallback: if the
|
|
69
|
+
* file is missing on the step's base branch, the step fails.
|
|
70
|
+
*/
|
|
71
|
+
readonly config?: string;
|
|
72
|
+
};
|
|
73
|
+
export type ManagedRuntimeFactories = {
|
|
74
|
+
readonly [K in ManagedRuntimeId]: () => ManagedRuntimeSpec<K>;
|
|
75
|
+
};
|
|
76
|
+
export declare const Runtime: {
|
|
77
|
+
/**
|
|
78
|
+
* Worker-supplied containers for `codeStep`, one factory per identifier, for
|
|
79
|
+
* example `Runtime.managed.bun1()`. The worker owns the image and installs the
|
|
80
|
+
* pipeline-builder dependencies; the repo holds nothing. An unknown identifier
|
|
81
|
+
* is a type error. Not supported for `defineStep`.
|
|
82
|
+
*/
|
|
83
|
+
readonly managed: ManagedRuntimeFactories;
|
|
84
|
+
/**
|
|
85
|
+
* Runs the step in the repository's devcontainer. Without `config` the worker
|
|
86
|
+
* searches for `.devcontainer/devcontainer.json`, then `devcontainer.json`.
|
|
87
|
+
* Throws when `config` breaks the path rules.
|
|
88
|
+
*/
|
|
89
|
+
readonly devcontainer: (opts?: DevcontainerRuntimeOpts) => DevcontainerRuntimeSpec;
|
|
90
|
+
/**
|
|
91
|
+
* Runs the step on the worker host, with no clone and no container. Takes no
|
|
92
|
+
* options, so a config path cannot be combined with it. Not supported for
|
|
93
|
+
* `codeStep`, which needs a workspace.
|
|
94
|
+
*/
|
|
95
|
+
readonly host: () => HostRuntimeSpec;
|
|
96
|
+
};
|
|
97
|
+
export type CompiledEnvironment = {
|
|
98
|
+
executionMode: "workspace" | "no_workspace";
|
|
99
|
+
devcontainerConfigPath: string | null;
|
|
100
|
+
managedRuntime: ManagedRuntimeId | null;
|
|
101
|
+
envJson: EnvVarsInput | null;
|
|
102
|
+
/** `undefined` when the author wrote no `repo`; the server resolves the default. */
|
|
103
|
+
repo: RepoConfigInput | undefined;
|
|
104
|
+
};
|
|
105
|
+
export type CompileEnvironmentContext = CompileRepoContext & {
|
|
106
|
+
/** Used when the environment declares no `runtime`. `codeStep` passes the default managed runtime. */
|
|
107
|
+
readonly defaultRuntime?: ManagedRuntimeSpec;
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Turns the authored `environment` into its wire fields. Runs `vars` and `repo`
|
|
111
|
+
* once. Throws on a static secret, or a static literal on a secret-looking name,
|
|
112
|
+
* on a setup variable on the host runtime, and on a `repo` the runtime cannot
|
|
113
|
+
* honor or that breaks the commit message rules.
|
|
114
|
+
*/
|
|
115
|
+
export declare function compileEnvironment<TInput, TEnv extends EnvRecord, TResult>(environment: StepEnvironment<TInput, TEnv, TResult> | CodeStepEnvironment<TInput, TResult> | undefined, ctx?: CompileEnvironmentContext): CompiledEnvironment;
|