@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,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,76 @@
1
+ // @bun
2
+ import {
3
+ ARTIFACT_BRAND,
4
+ Artifact,
5
+ ArtifactTypes,
6
+ Env,
7
+ Features,
8
+ Notify,
9
+ Repo,
10
+ Runtime,
11
+ artifact,
12
+ codeStep,
13
+ compileEnvironment,
14
+ compileMcps,
15
+ compileRepo,
16
+ compileStepErrors,
17
+ compileStepRetry,
18
+ createPromptInputProxy,
19
+ createPromptTemplateContext,
20
+ createStepDefinitionsClient,
21
+ defineMcp,
22
+ defineStep,
23
+ exports_z,
24
+ isMcpHandle,
25
+ isSecretLookingEnvName,
26
+ normalizeArtifactAccept,
27
+ normalizeEnv,
28
+ renderPromptTemplate,
29
+ resolveMcpChecks,
30
+ toStepHandle,
31
+ toStepSpec
32
+ } from "../../chunk-3ctaaseb.js";
33
+ import"../../chunk-mz53r914.js";
34
+ import"../../chunk-5zsavw98.js";
35
+ import"../../chunk-4ggr8af6.js";
36
+ import"../../chunk-k4y5qt4y.js";
37
+ import"../../chunk-cdanncng.js";
38
+ import"../../chunk-e1h021kq.js";
39
+ import"../../chunk-63f90zky.js";
40
+ import"../../chunk-ngy1fdcx.js";
41
+ import"../../chunk-y2pv8d6a.js";
42
+ import"../../chunk-dp86pa6m.js";
43
+ import"../../chunk-vfeytkqx.js";
44
+ import"../../chunk-skzxcba3.js";
45
+ import"../../chunk-y64skrwp.js";
46
+ export {
47
+ ARTIFACT_BRAND,
48
+ Artifact,
49
+ ArtifactTypes,
50
+ Env,
51
+ Features,
52
+ Notify,
53
+ Repo,
54
+ Runtime,
55
+ artifact,
56
+ codeStep,
57
+ compileEnvironment,
58
+ compileMcps,
59
+ compileRepo,
60
+ compileStepErrors,
61
+ compileStepRetry,
62
+ createPromptInputProxy,
63
+ createPromptTemplateContext,
64
+ createStepDefinitionsClient,
65
+ defineMcp,
66
+ defineStep,
67
+ isMcpHandle,
68
+ isSecretLookingEnvName,
69
+ normalizeArtifactAccept,
70
+ normalizeEnv,
71
+ renderPromptTemplate,
72
+ resolveMcpChecks,
73
+ toStepHandle,
74
+ toStepSpec,
75
+ exports_z as z
76
+ };
@@ -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;