@scarn/sdk 0.8.20 → 0.8.22

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 (102) hide show
  1. package/dist/auth/api-token-cache.d.ts +24 -0
  2. package/dist/auth/api-token-source.d.ts +39 -0
  3. package/dist/auth/authenticated-fetch.d.ts +10 -0
  4. package/dist/auth/index.d.ts +3 -0
  5. package/dist/auth/index.js +19 -0
  6. package/dist/automations/index.js +14 -17
  7. package/dist/{chunk-habmdf89.js → chunk-0bwsjn0b.js} +29 -29
  8. package/dist/{chunk-mzj1j0p5.js → chunk-0w13kxkr.js} +34 -31
  9. package/dist/{chunk-qgkx89eg.js → chunk-3j5wf2t5.js} +44 -43
  10. package/dist/{chunk-0y2fy5en.js → chunk-4361gxk0.js} +7 -7
  11. package/dist/{chunk-n3ywwx7n.js → chunk-52520csz.js} +15 -14
  12. package/dist/chunk-5dnfgyx8.js +159 -0
  13. package/dist/{chunk-tr3v83cn.js → chunk-5fa4arn1.js} +18 -11
  14. package/dist/{chunk-ngy1fdcx.js → chunk-631ffb6r.js} +10 -10
  15. package/dist/{chunk-01nfqm18.js → chunk-7anj08zc.js} +11 -9
  16. package/dist/{chunk-yq0sf8sb.js → chunk-7dr4kybf.js} +483 -451
  17. package/dist/chunk-7mhr5aex.js +171 -0
  18. package/dist/chunk-7rywbqzz.js +27 -0
  19. package/dist/{chunk-yf15kdte.js → chunk-9ct3xypr.js} +2636 -3864
  20. package/dist/chunk-9geh4c3v.js +1034 -0
  21. package/dist/{chunk-19brnwkp.js → chunk-9qf0eg7m.js} +19 -19
  22. package/dist/{chunk-y11p1q7r.js → chunk-aqqywy8g.js} +4 -4
  23. package/dist/chunk-bcvx11fn.js +174 -0
  24. package/dist/{chunk-z4smq8qd.js → chunk-cyfeaz43.js} +86 -86
  25. package/dist/chunk-czq37rrt.js +286 -0
  26. package/dist/chunk-ec5z8bbq.js +126 -0
  27. package/dist/{chunk-rt9tq4j6.js → chunk-h9yxx0hd.js} +7 -7
  28. package/dist/{chunk-t1dq2c2s.js → chunk-hma87efq.js} +40 -40
  29. package/dist/{chunk-5dny5jg1.js → chunk-hpv234hf.js} +11 -11
  30. package/dist/{chunk-rq5k7m33.js → chunk-k7xnsmp5.js} +182 -97
  31. package/dist/{chunk-91f5gm5z.js → chunk-kbpkpxcn.js} +22 -21
  32. package/dist/{chunk-6tra3gw8.js → chunk-kjn1knb9.js} +7 -7
  33. package/dist/{chunk-g4j5cfpc.js → chunk-p3s7cjfc.js} +17 -16
  34. package/dist/chunk-pq6hrtnb.js +49 -0
  35. package/dist/{chunk-mp2rqtcj.js → chunk-ptpy7nnm.js} +8 -8
  36. package/dist/{chunk-xqfj56m9.js → chunk-vn1rfxma.js} +8 -8
  37. package/dist/chunk-vyv8kvkv.js +113 -0
  38. package/dist/{chunk-0c60x3v8.js → chunk-xe2zgyz7.js} +35 -35
  39. package/dist/chunk-y4dwmhn2.js +14 -0
  40. package/dist/{chunk-098740f7.js → chunk-yypj3zn0.js} +8 -8
  41. package/dist/chunk-yzj1mfpr.js +1515 -0
  42. package/dist/client.d.ts +5 -1
  43. package/dist/client.js +62 -61
  44. package/dist/connectors/index.js +36 -37
  45. package/dist/contracts/artifact-markers.js +11 -12
  46. package/dist/contracts/artifacts.js +21 -23
  47. package/dist/contracts/automation-document/index.js +28 -30
  48. package/dist/contracts/pipeline-document/built-ins.d.ts +1 -1
  49. package/dist/contracts/pipeline-document/index.js +95 -97
  50. package/dist/contracts/step-artifact-submissions.js +20 -17
  51. package/dist/contracts/work-item-changes.js +8 -6
  52. package/dist/create-api-client.d.ts +11 -0
  53. package/dist/defaults/index.js +44 -884
  54. package/dist/defaults/load-push-defaults.d.ts +11 -4
  55. package/dist/defaults/project-ref.d.ts +2 -4
  56. package/dist/definitions/automations/automations-client.d.ts +2 -1
  57. package/dist/definitions/automations/index.js +6 -8
  58. package/dist/definitions/environments/environments-client.d.ts +2 -1
  59. package/dist/definitions/environments/index.js +37 -38
  60. package/dist/definitions/pipelines/index.js +12 -14
  61. package/dist/definitions/pipelines/pipeline-definitions-client.d.ts +2 -1
  62. package/dist/definitions/steps/define-mcp.d.ts +2 -2
  63. package/dist/definitions/steps/index.js +93 -95
  64. package/dist/definitions/steps/mcp-server-config.d.ts +13 -3
  65. package/dist/definitions/steps/step-definitions-client.d.ts +20 -1
  66. package/dist/definitions/validation/index.js +17 -18
  67. package/dist/devcontainer-config-path.js +9 -11
  68. package/dist/env-vars.js +37 -39
  69. package/dist/environment.js +41 -42
  70. package/dist/eslint.js +0 -2
  71. package/dist/generated/index.d.ts +2 -2
  72. package/dist/generated/sdk.gen.d.ts +41 -1
  73. package/dist/generated/types.gen.d.ts +1801 -0
  74. package/dist/git-url/git-repo-identity.js +0 -2
  75. package/dist/health-checks.js +15 -17
  76. package/dist/index.js +364 -358
  77. package/dist/jsonc.js +7 -8
  78. package/dist/managed-connections.d.ts +16 -0
  79. package/dist/managed-connections.js +9 -0
  80. package/dist/managed-runtimes.js +9 -11
  81. package/dist/opencode-mcp.d.ts +55 -1
  82. package/dist/opencode-mcp.js +33 -28
  83. package/dist/pipelines/index.js +78 -81
  84. package/dist/push/code-step-lookup.js +9 -10
  85. package/dist/push/index.d.ts +1 -0
  86. package/dist/push/index.js +109 -79
  87. package/dist/push/push-from-directory.d.ts +9 -1
  88. package/dist/push/pushed-mcp-servers.d.ts +28 -0
  89. package/dist/repo-config.js +41 -43
  90. package/dist/resolve-environment.js +14 -15
  91. package/dist/scarn-config-parser.js +5 -6
  92. package/dist/task-plane-client.d.ts +143 -1
  93. package/package.json +11 -3
  94. package/dist/chunk-46wmsgv7.js +0 -14
  95. package/dist/chunk-a56zc4s5.js +0 -119
  96. package/dist/chunk-aemxz9r7.js +0 -107
  97. package/dist/chunk-b9ja6ss5.js +0 -275
  98. package/dist/chunk-e0pt5x0e.js +0 -167
  99. package/dist/chunk-pqtd0hr7.js +0 -96
  100. package/dist/chunk-rphfy0fj.js +0 -167
  101. package/dist/chunk-y34zsgsw.js +0 -39
  102. package/dist/chunk-y64skrwp.js +0 -17
@@ -0,0 +1,24 @@
1
+ /**
2
+ * On-disk cache of short-lived API tokens (`~/.scarn/api-tokens.jsonc`),
3
+ * keyed by base URL exactly as `auth.jsonc` keys its profiles. Each entry
4
+ * remembers a hash of the session token it was minted from, so a re-login
5
+ * makes it stale. Kept apart from `auth.jsonc` because the worker watches that
6
+ * file for re-logins and token refreshes must not trigger it.
7
+ */
8
+ export interface ApiTokenCacheEntry {
9
+ sessionHash: string;
10
+ token: string;
11
+ /** Epoch milliseconds. */
12
+ expiresAt: number;
13
+ }
14
+ export declare const getApiTokenCacheFilePath: () => string;
15
+ export declare const loadApiTokenCacheEntry: (baseUrl: string) => ApiTokenCacheEntry | null;
16
+ export declare const saveApiTokenCacheEntry: (baseUrl: string, entry: ApiTokenCacheEntry) => void;
17
+ /**
18
+ * Removes the cached token for `baseUrl`. With `onlyToken`, the entry is
19
+ * removed only if it still holds that token, so a token another process has
20
+ * just refreshed is left alone.
21
+ */
22
+ export declare const deleteApiTokenCacheEntry: (baseUrl: string, options?: {
23
+ onlyToken?: string;
24
+ }) => void;
@@ -0,0 +1,39 @@
1
+ export type FetchLike = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
2
+ /**
3
+ * The session token is missing or the server rejected it while minting an API
4
+ * token: the user has to log in again.
5
+ */
6
+ export declare class ApiTokenAuthError extends Error {
7
+ readonly baseUrl: string;
8
+ readonly status: number | undefined;
9
+ constructor(message: string, baseUrl: string, status?: number);
10
+ }
11
+ export type ApiCredential = {
12
+ /** Full `Authorization` header value. */
13
+ authorization: string;
14
+ /** `session` once the server has no token endpoint (404) and the session bearer is sent instead. */
15
+ kind: "jwt" | "session";
16
+ };
17
+ export type ApiTokenSourceOptions = {
18
+ baseUrl: string;
19
+ getSessionToken: () => string | null | undefined | Promise<string | null | undefined>;
20
+ fetch?: FetchLike | undefined;
21
+ };
22
+ export type ApiTokenSource = {
23
+ getAuthorization(): Promise<string>;
24
+ getCredential(): Promise<ApiCredential>;
25
+ /**
26
+ * Drops the cached token (memory and disk). With `failedAuthorization`,
27
+ * drops it only if it is still the token that failed, so a token refreshed
28
+ * meanwhile survives.
29
+ */
30
+ invalidate(failedAuthorization?: string): void;
31
+ };
32
+ /**
33
+ * Supplies the `Authorization` header for API calls: a short-lived JWT minted
34
+ * from the session token at `GET /api/auth/token`, cached in memory and in
35
+ * `~/.scarn/api-tokens.jsonc` and reused while it has more than a minute left.
36
+ * Servers without the token endpoint (404) get the session bearer for the
37
+ * rest of the process.
38
+ */
39
+ export declare function createApiTokenSource(options: ApiTokenSourceOptions): ApiTokenSource;
@@ -0,0 +1,10 @@
1
+ import type { ApiTokenSource, FetchLike } from "./api-token-source";
2
+ /**
3
+ * Wraps `fetch` so every request carries the token source's `Authorization`.
4
+ * A 401 on a request sent with a JWT invalidates that token and retries once
5
+ * with a fresh one; the retry's response is returned as is. The retry uses a
6
+ * clone taken before the first send, so request bodies can be resent.
7
+ */
8
+ export declare function createAuthenticatedFetch(source: ApiTokenSource, options?: {
9
+ fetch?: FetchLike | undefined;
10
+ }): FetchLike;
@@ -0,0 +1,3 @@
1
+ export { deleteApiTokenCacheEntry, getApiTokenCacheFilePath, loadApiTokenCacheEntry, saveApiTokenCacheEntry, type ApiTokenCacheEntry, } from "./api-token-cache";
2
+ export { ApiTokenAuthError, createApiTokenSource, type ApiCredential, type ApiTokenSource, type ApiTokenSourceOptions, type FetchLike, } from "./api-token-source";
3
+ export { createAuthenticatedFetch } from "./authenticated-fetch";
@@ -0,0 +1,19 @@
1
+ // @bun
2
+ import {
3
+ getApiTokenCacheFilePath2,
4
+ loadApiTokenCacheEntry2,
5
+ saveApiTokenCacheEntry2,
6
+ deleteApiTokenCacheEntry2,
7
+ ApiTokenAuthError2,
8
+ createApiTokenSource2,
9
+ createAuthenticatedFetch2
10
+ } from "../chunk-9geh4c3v.js";
11
+ export {
12
+ ApiTokenAuthError2 as ApiTokenAuthError,
13
+ createApiTokenSource2 as createApiTokenSource,
14
+ createAuthenticatedFetch2 as createAuthenticatedFetch,
15
+ deleteApiTokenCacheEntry2 as deleteApiTokenCacheEntry,
16
+ getApiTokenCacheFilePath2 as getApiTokenCacheFilePath,
17
+ loadApiTokenCacheEntry2 as loadApiTokenCacheEntry,
18
+ saveApiTokenCacheEntry2 as saveApiTokenCacheEntry
19
+ };
@@ -1,21 +1,18 @@
1
1
  // @bun
2
2
  import {
3
- attach,
4
- defineAutomation,
5
- onEvent,
6
- skip
7
- } from "../chunk-habmdf89.js";
8
- import"../chunk-mp2rqtcj.js";
9
- import"../chunk-a56zc4s5.js";
10
- import"../chunk-5dny5jg1.js";
11
- import"../chunk-b9ja6ss5.js";
12
- import"../chunk-y11p1q7r.js";
13
- import"../chunk-01nfqm18.js";
14
- import"../chunk-yf15kdte.js";
15
- import"../chunk-y64skrwp.js";
3
+ skip2,
4
+ attach2,
5
+ onEvent2,
6
+ defineAutomation2
7
+ } from "../chunk-0bwsjn0b.js";
8
+ import"../chunk-ptpy7nnm.js";
9
+ import"../chunk-ec5z8bbq.js";
10
+ import"../chunk-hpv234hf.js";
11
+ import"../chunk-czq37rrt.js";
12
+ import"../chunk-aqqywy8g.js";
16
13
  export {
17
- attach,
18
- defineAutomation,
19
- onEvent,
20
- skip
14
+ attach2 as attach,
15
+ defineAutomation2 as defineAutomation,
16
+ onEvent2 as onEvent,
17
+ skip2 as skip
21
18
  };
@@ -1,31 +1,31 @@
1
1
  // @bun
2
2
  import {
3
- argEntries,
4
- attempt,
5
- compileArg,
6
- compileCondition,
7
- conditionData,
8
- issue,
9
- mapSource,
10
- newState,
11
- rootPlaceholder,
12
- withOwners,
13
- withTracker
14
- } from "./chunk-mp2rqtcj.js";
15
- import {
16
- eventHasChild,
17
- scopeOfEvent
18
- } from "./chunk-a56zc4s5.js";
3
+ scopeOfEvent2,
4
+ eventHasChild2
5
+ } from "./chunk-ec5z8bbq.js";
19
6
  import {
7
+ captureSite,
8
+ PipelineBuildError2,
20
9
  AuthoringError,
21
- PipelineBuildError,
10
+ registerAutomationTarget,
22
11
  automationTargetOf,
23
- captureSite,
24
12
  markSubject,
25
13
  nodeOf,
26
- registerAutomationTarget,
27
14
  targetOf
28
- } from "./chunk-y11p1q7r.js";
15
+ } from "./chunk-aqqywy8g.js";
16
+ import {
17
+ withOwners,
18
+ withTracker,
19
+ rootPlaceholder,
20
+ conditionData,
21
+ compileCondition,
22
+ compileArg,
23
+ argEntries,
24
+ newState,
25
+ issue,
26
+ mapSource,
27
+ attempt
28
+ } from "./chunk-ptpy7nnm.js";
29
29
 
30
30
  // src/automations/define-automation.ts
31
31
  var rules = new WeakMap;
@@ -49,7 +49,7 @@ function eventWorkItem(subject, owner) {
49
49
  function eventContext(event) {
50
50
  const context = {};
51
51
  context["workItem"] = eventWorkItem("workItem", context);
52
- if (eventHasChild(event)) {
52
+ if (eventHasChild2(event)) {
53
53
  context["child"] = eventWorkItem("child", context);
54
54
  }
55
55
  if (event === "workItem.label.added") {
@@ -60,8 +60,8 @@ function eventContext(event) {
60
60
  }
61
61
  return context;
62
62
  }
63
- var skip = registerAutomationTarget({ kind: "skip", site: null });
64
- function attach(automation) {
63
+ var skip2 = registerAutomationTarget({ kind: "skip", site: null });
64
+ function attach2(automation) {
65
65
  if (automation?._tag !== "automation_document") {
66
66
  throw new AuthoringError("attach(...) takes an automation: the value defineAutomation returns");
67
67
  }
@@ -71,7 +71,7 @@ function attach(automation) {
71
71
  site: captureSite()
72
72
  });
73
73
  }
74
- function onEvent(options) {
74
+ function onEvent2(options) {
75
75
  const site = captureSite();
76
76
  const rule = options.routes === undefined ? {
77
77
  event: options.event,
@@ -147,7 +147,7 @@ function compileTarget(state, scope, rule, spec, context, pointer) {
147
147
  const report = (message) => {
148
148
  issue(state, target.site ?? rule.site, pointer, message);
149
149
  };
150
- if ((target.kind === "step" || target.kind === "pipeline") && target.on === "child" && !eventHasChild(rule.event)) {
150
+ if ((target.kind === "step" || target.kind === "pipeline") && target.on === "child" && !eventHasChild2(rule.event)) {
151
151
  report(`"${rule.event}" has no child work item; .on(r.child) only works on child.* events`);
152
152
  return;
153
153
  }
@@ -177,7 +177,7 @@ function compileTarget(state, scope, rule, spec, context, pointer) {
177
177
  function compileRule(state, scope, rule, index) {
178
178
  const base = ["rules", index];
179
179
  mapSource(state, base, rule.site);
180
- if (scopeOfEvent(rule.event) !== scope) {
180
+ if (scopeOfEvent2(rule.event) !== scope) {
181
181
  issue(state, rule.site, [...base, "event"], `"${rule.event}" isn't an event of a ${scope === "workItem" ? "work-item" : "project"} automation`);
182
182
  }
183
183
  const context = eventContext(rule.event);
@@ -214,7 +214,7 @@ function compileRule(state, scope, rule, index) {
214
214
  }
215
215
  return { event: rule.event, next };
216
216
  }
217
- function defineAutomation(config) {
217
+ function defineAutomation2(config) {
218
218
  const site = captureSite();
219
219
  const state = newState();
220
220
  const compiled = withTracker(state.tracker, () => config.rules.map((value, index) => {
@@ -226,7 +226,7 @@ function defineAutomation(config) {
226
226
  return compileRule(state, config.scope, rule, index);
227
227
  }));
228
228
  if (state.issues.length > 0) {
229
- throw new PipelineBuildError(config.key, state.issues);
229
+ throw new PipelineBuildError2(config.key, state.issues);
230
230
  }
231
231
  const document = {
232
232
  kind: "automation",
@@ -247,4 +247,4 @@ function defineAutomation(config) {
247
247
  }
248
248
  };
249
249
  }
250
- export { skip, attach, onEvent, defineAutomation };
250
+ export { skip2, attach2, onEvent2, defineAutomation2 };
@@ -1,18 +1,21 @@
1
1
  // @bun
2
2
  import {
3
- BrokenDevcontainerReference,
4
- EnvironmentInvalid,
5
- EnvironmentNotFound,
6
- environmentNameSchema,
7
- inlineEnvironmentReadSchema
8
- } from "./chunk-e0pt5x0e.js";
3
+ ConnectorVarsMissing2,
4
+ findMissingConnectorVars2
5
+ } from "./chunk-3j5wf2t5.js";
9
6
  import {
10
- ConnectorVarsMissing,
11
- findMissingConnectorVars
12
- } from "./chunk-qgkx89eg.js";
7
+ environmentNameSchema2,
8
+ inlineEnvironmentReadSchema2,
9
+ EnvironmentNotFound2,
10
+ EnvironmentInvalid2,
11
+ BrokenDevcontainerReference2
12
+ } from "./chunk-bcvx11fn.js";
13
13
  import {
14
- exports_external
15
- } from "./chunk-yf15kdte.js";
14
+ number,
15
+ object,
16
+ union,
17
+ literal
18
+ } from "./chunk-9ct3xypr.js";
16
19
 
17
20
  // src/resolve-environment.ts
18
21
  var DEVCONTAINER_DISCOVERY_PATHS = [
@@ -29,32 +32,32 @@ var namedContentAsInline = ({
29
32
  ...vars === undefined ? {} : { envJson: vars },
30
33
  ...connectors === undefined ? {} : { connectors }
31
34
  });
32
- var namedEnvironmentEnvelopeSchema = exports_external.union([
33
- exports_external.object({
34
- name: environmentNameSchema,
35
- version: exports_external.number().int().positive(),
36
- content: exports_external.object({})
35
+ var namedEnvironmentEnvelopeSchema = union([
36
+ object({
37
+ name: environmentNameSchema2,
38
+ version: number().int().positive(),
39
+ content: object({})
37
40
  }),
38
- exports_external.object({ name: environmentNameSchema, notFound: exports_external.literal(true) })
41
+ object({ name: environmentNameSchema2, notFound: literal(true) })
39
42
  ]);
40
- function readEnvironmentDefinition(ref) {
43
+ function readEnvironmentDefinition2(ref) {
41
44
  let named;
42
45
  if (ref?.kind === "named") {
43
46
  const envelope = namedEnvironmentEnvelopeSchema.safeParse(ref);
44
47
  if (!envelope.success) {
45
- return new EnvironmentInvalid(undefined, envelope.error.issues);
48
+ return new EnvironmentInvalid2(undefined, envelope.error.issues);
46
49
  }
47
50
  if ("notFound" in envelope.data) {
48
- return new EnvironmentNotFound(envelope.data.name);
51
+ return new EnvironmentNotFound2(envelope.data.name);
49
52
  }
50
53
  named = {
51
54
  name: envelope.data.name,
52
55
  label: `environment ${envelope.data.name} v${String(envelope.data.version)}`
53
56
  };
54
57
  }
55
- const parsedRef = inlineEnvironmentReadSchema.safeParse(ref?.kind === "named" && "content" in ref ? namedContentAsInline(ref.content) : ref);
58
+ const parsedRef = inlineEnvironmentReadSchema2.safeParse(ref?.kind === "named" && "content" in ref ? namedContentAsInline(ref.content) : ref);
56
59
  if (!parsedRef.success) {
57
- return new EnvironmentInvalid(named?.label, named === undefined ? parsedRef.error.issues : parsedRef.error.issues.map((issue) => ({
60
+ return new EnvironmentInvalid2(named?.label, named === undefined ? parsedRef.error.issues : parsedRef.error.issues.map((issue) => ({
58
61
  ...issue,
59
62
  path: issue.path.map((key) => key === "envJson" ? "vars" : key)
60
63
  })));
@@ -63,9 +66,9 @@ function readEnvironmentDefinition(ref) {
63
66
  const runtime = reference?.runtime;
64
67
  const envVars = reference?.envJson ?? [];
65
68
  const connectors = reference?.connectors ?? [];
66
- const missing = findMissingConnectorVars(connectors, envVars);
69
+ const missing = findMissingConnectorVars2(connectors, envVars);
67
70
  if (missing.length > 0) {
68
- return new ConnectorVarsMissing(named?.label, missing);
71
+ return new ConnectorVarsMissing2(named?.label, missing);
69
72
  }
70
73
  return {
71
74
  source: named ? "named" : reference?.kind ?? "repo-default",
@@ -75,18 +78,18 @@ function readEnvironmentDefinition(ref) {
75
78
  connectors
76
79
  };
77
80
  }
78
- async function resolveEnvironment(deps, ref) {
79
- const definition = readEnvironmentDefinition(ref);
81
+ async function resolveEnvironment2(deps, ref) {
82
+ const definition = readEnvironmentDefinition2(ref);
80
83
  if (definition instanceof Error)
81
84
  return definition;
82
- return resolveEnvironmentDefinition(deps, definition);
85
+ return resolveEnvironmentDefinition2(deps, definition);
83
86
  }
84
- async function resolveEnvironmentDefinition(deps, definition) {
87
+ async function resolveEnvironmentDefinition2(deps, definition) {
85
88
  const { runtime } = definition;
86
89
  let resolvedRuntime;
87
90
  if (runtime?.kind === "devcontainer" && runtime.config !== undefined) {
88
91
  if (!await deps.devcontainerExists(runtime.config)) {
89
- return new BrokenDevcontainerReference(runtime.config);
92
+ return new BrokenDevcontainerReference2(runtime.config);
90
93
  }
91
94
  resolvedRuntime = { kind: "devcontainer", config: runtime.config };
92
95
  } else if (runtime === undefined || runtime.kind === "devcontainer") {
@@ -100,7 +103,7 @@ async function resolveEnvironmentDefinition(deps, definition) {
100
103
  if (discoveredConfig !== undefined) {
101
104
  resolvedRuntime = { kind: "devcontainer", config: discoveredConfig };
102
105
  } else if (runtime?.kind === "devcontainer") {
103
- return new BrokenDevcontainerReference(DEVCONTAINER_DISCOVERY_PATHS[0], DEVCONTAINER_DISCOVERY_PATHS);
106
+ return new BrokenDevcontainerReference2(DEVCONTAINER_DISCOVERY_PATHS[0], DEVCONTAINER_DISCOVERY_PATHS);
104
107
  } else {
105
108
  resolvedRuntime = { kind: "managed", id: "bun1" };
106
109
  }
@@ -113,4 +116,4 @@ async function resolveEnvironmentDefinition(deps, definition) {
113
116
  };
114
117
  }
115
118
 
116
- export { readEnvironmentDefinition, resolveEnvironment, resolveEnvironmentDefinition };
119
+ export { readEnvironmentDefinition2, resolveEnvironment2, resolveEnvironmentDefinition2 };
@@ -1,18 +1,19 @@
1
1
  // @bun
2
2
  import {
3
- collectEnvPlaceholderNames,
4
- isEnvPlaceholderValue,
5
- openCodeResolvedMcpServerConfigSchema
6
- } from "./chunk-pqtd0hr7.js";
3
+ ENV_VAR_NAME_PATTERN2
4
+ } from "./chunk-vyv8kvkv.js";
7
5
  import {
8
- ENV_VAR_NAME_PATTERN
9
- } from "./chunk-aemxz9r7.js";
6
+ openCodeResolvedMcpServerConfigSchema2,
7
+ isEnvPlaceholderValue2,
8
+ collectEnvPlaceholderNames2
9
+ } from "./chunk-5dnfgyx8.js";
10
10
  import {
11
- exports_external
12
- } from "./chunk-yf15kdte.js";
11
+ string,
12
+ array
13
+ } from "./chunk-9ct3xypr.js";
13
14
 
14
15
  // src/connectors/catalog.ts
15
- var connectorAuthValues = ["none", "apiKey"];
16
+ var connectorAuthValues2 = ["none", "apiKey"];
16
17
  var CONNECTOR_ID_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/u;
17
18
  var CONNECTOR_DEFINITIONS = [
18
19
  {
@@ -49,8 +50,8 @@ var CONNECTOR_DEFINITIONS = [
49
50
  }
50
51
  }
51
52
  ];
52
- var E2E_FAKE_CONNECTOR_FLAG = "SCARN_E2E_FAKE_CONNECTOR";
53
- var E2E_FAKE_CONNECTOR = {
53
+ var E2E_FAKE_CONNECTOR_FLAG2 = "SCARN_E2E_FAKE_CONNECTOR";
54
+ var E2E_FAKE_CONNECTOR2 = {
54
55
  id: "e2e-fake",
55
56
  name: "E2E fake",
56
57
  description: "Test-only fake MCP server for the end-to-end tests.",
@@ -67,10 +68,10 @@ var E2E_FAKE_CONNECTOR = {
67
68
  environment: { FAKE_API_KEY: "{env:FAKE_API_KEY}" }
68
69
  }
69
70
  };
70
- function connectorDefinitions(env) {
71
- return env[E2E_FAKE_CONNECTOR_FLAG] === "true" ? [...CONNECTOR_DEFINITIONS, E2E_FAKE_CONNECTOR] : CONNECTOR_DEFINITIONS;
71
+ function connectorDefinitions2(env) {
72
+ return env[E2E_FAKE_CONNECTOR_FLAG2] === "true" ? [...CONNECTOR_DEFINITIONS, E2E_FAKE_CONNECTOR2] : CONNECTOR_DEFINITIONS;
72
73
  }
73
- function validateConnectorCatalog(entries) {
74
+ function validateConnectorCatalog2(entries) {
74
75
  const problems = [];
75
76
  const seen = new Set;
76
77
  for (const entry of entries) {
@@ -81,11 +82,11 @@ function validateConnectorCatalog(entries) {
81
82
  if (seen.has(entry.id))
82
83
  problems.push(`${label}: duplicate id`);
83
84
  seen.add(entry.id);
84
- if (!openCodeResolvedMcpServerConfigSchema.safeParse(entry.mcp).success) {
85
+ if (!openCodeResolvedMcpServerConfigSchema2.safeParse(entry.mcp).success) {
85
86
  problems.push(`${label}: mcp is not a valid OpenCode MCP config`);
86
87
  }
87
88
  const credentialValues = Object.values(entry.mcp.type === "local" ? entry.mcp.environment ?? {} : entry.mcp.headers ?? {});
88
- if (!credentialValues.every(isEnvPlaceholderValue)) {
89
+ if (!credentialValues.every(isEnvPlaceholderValue2)) {
89
90
  problems.push(`${label}: ${entry.mcp.type === "local" ? "environment" : "headers"} values must be {env:NAME} placeholders`);
90
91
  }
91
92
  const declared = entry.requiredVars.map((variable) => variable.name);
@@ -93,15 +94,15 @@ function validateConnectorCatalog(entries) {
93
94
  problems.push(`${label}: requiredVars names must be unique`);
94
95
  }
95
96
  for (const name of declared) {
96
- if (!ENV_VAR_NAME_PATTERN.test(name)) {
97
+ if (!ENV_VAR_NAME_PATTERN2.test(name)) {
97
98
  problems.push(`${label}: requiredVars "${name}" is not a valid name`);
98
99
  }
99
100
  }
100
- const read = collectEnvPlaceholderNames(entry.mcp);
101
- for (const name of read.filter((name2) => !declared.includes(name2))) {
101
+ const read = collectEnvPlaceholderNames2(entry.mcp);
102
+ for (const name of read.filter((name) => !declared.includes(name))) {
102
103
  problems.push(`${label}: mcp reads {env:${name}} but requiredVars omits it`);
103
104
  }
104
- for (const name of declared.filter((name2) => !read.includes(name2))) {
105
+ for (const name of declared.filter((name) => !read.includes(name))) {
105
106
  problems.push(`${label}: requiredVars lists ${name} but mcp never reads it`);
106
107
  }
107
108
  if (entry.auth === "none" !== (declared.length === 0)) {
@@ -111,22 +112,22 @@ function validateConnectorCatalog(entries) {
111
112
  return problems;
112
113
  }
113
114
  function buildCatalog(entries) {
114
- const problems = validateConnectorCatalog(entries);
115
+ const problems = validateConnectorCatalog2(entries);
115
116
  if (problems.length > 0) {
116
117
  throw new Error(`Invalid connector catalog: ${problems.join("; ")}`);
117
118
  }
118
119
  return Object.freeze(Object.fromEntries(entries.map((entry) => [entry.id, entry])));
119
120
  }
120
121
  var runtimeEnv = globalThis.process?.env ?? {};
121
- var CONNECTOR_CATALOG = buildCatalog(connectorDefinitions(runtimeEnv));
122
- function isConnectorId(id) {
123
- return Object.hasOwn(CONNECTOR_CATALOG, id);
122
+ var CONNECTOR_CATALOG2 = buildCatalog(connectorDefinitions2(runtimeEnv));
123
+ function isConnectorId2(id) {
124
+ return Object.hasOwn(CONNECTOR_CATALOG2, id);
124
125
  }
125
- function getConnector(id) {
126
- return isConnectorId(id) ? CONNECTOR_CATALOG[id] : undefined;
126
+ function getConnector2(id) {
127
+ return isConnectorId2(id) ? CONNECTOR_CATALOG2[id] : undefined;
127
128
  }
128
- function listConnectorSummaries() {
129
- return Object.values(CONNECTOR_CATALOG).map(({ id, name, description, auth, requiredVars }) => ({
129
+ function listConnectorSummaries2() {
130
+ return Object.values(CONNECTOR_CATALOG2).map(({ id, name, description, auth, requiredVars }) => ({
130
131
  id,
131
132
  name,
132
133
  description,
@@ -136,14 +137,14 @@ function listConnectorSummaries() {
136
137
  }
137
138
 
138
139
  // src/connectors/index.ts
139
- var connectorIdsSchema = exports_external.array(exports_external.string()).superRefine((ids, ctx) => {
140
+ var connectorIdsSchema2 = array(string()).superRefine((ids, ctx) => {
140
141
  const seen = new Set;
141
142
  ids.forEach((id, index) => {
142
- if (!isConnectorId(id)) {
143
+ if (!isConnectorId2(id)) {
143
144
  ctx.addIssue({
144
145
  code: "custom",
145
146
  path: [index],
146
- message: `unknown connector "${id}"; known connectors: ${Object.keys(CONNECTOR_CATALOG).join(", ")}`
147
+ message: `unknown connector "${id}"; known connectors: ${Object.keys(CONNECTOR_CATALOG2).join(", ")}`
147
148
  });
148
149
  } else if (seen.has(id)) {
149
150
  ctx.addIssue({
@@ -156,7 +157,7 @@ var connectorIdsSchema = exports_external.array(exports_external.string()).super
156
157
  });
157
158
  });
158
159
 
159
- class ConnectorVarsMissing extends Error {
160
+ class ConnectorVarsMissing2 extends Error {
160
161
  environment;
161
162
  missing;
162
163
  kind = "ConnectorVarsMissing";
@@ -167,39 +168,39 @@ class ConnectorVarsMissing extends Error {
167
168
  this.missing = missing;
168
169
  }
169
170
  }
170
- function findMissingConnectorVars(connectors, envVars) {
171
+ function findMissingConnectorVars2(connectors, envVars) {
171
172
  const provided = new Set(envVars.filter((entry) => entry.applies !== "setup").map((entry) => entry.name));
172
173
  return connectors.flatMap((connector) => {
173
- const vars = (CONNECTOR_CATALOG[connector]?.requiredVars ?? []).map((variable) => variable.name).filter((name) => !provided.has(name));
174
+ const vars = (CONNECTOR_CATALOG2[connector]?.requiredVars ?? []).map((variable) => variable.name).filter((name) => !provided.has(name));
174
175
  return vars.length > 0 ? [{ connector, vars }] : [];
175
176
  });
176
177
  }
177
- function findConnectorMcpCollisions(connectors, stepMcpKeys) {
178
+ function findConnectorMcpCollisions2(connectors, stepMcpKeys) {
178
179
  const ids = new Set(connectors);
179
180
  return [...stepMcpKeys].filter((key) => ids.has(key)).sort();
180
181
  }
181
- function connectorMcpCollisionMessage(collisions) {
182
+ function connectorMcpCollisionMessage2(collisions) {
182
183
  return `step mcps ${collisions.map((key) => `"${key}"`).join(", ")} collide with the environment's connectors; rename the step's MCP server or drop the connector`;
183
184
  }
184
185
 
185
- class ConnectorMcpCollision extends Error {
186
+ class ConnectorMcpCollision2 extends Error {
186
187
  collisions;
187
188
  kind = "ConnectorMcpCollision";
188
189
  code = "SCARN_ENVIRONMENT_INVALID";
189
190
  constructor(collisions) {
190
- super(connectorMcpCollisionMessage(collisions));
191
+ super(connectorMcpCollisionMessage2(collisions));
191
192
  this.collisions = collisions;
192
193
  }
193
194
  }
194
- function mergeConnectorMcpServers(connectors, servers, stepMcpKeys = Object.keys(servers ?? {})) {
195
+ function mergeConnectorMcpServers2(connectors, servers, stepMcpKeys = Object.keys(servers ?? {})) {
195
196
  if (connectors.length === 0)
196
197
  return servers;
197
- const collisions = findConnectorMcpCollisions(connectors, stepMcpKeys);
198
+ const collisions = findConnectorMcpCollisions2(connectors, stepMcpKeys);
198
199
  if (collisions.length > 0)
199
- throw new ConnectorMcpCollision(collisions);
200
+ throw new ConnectorMcpCollision2(collisions);
200
201
  const merged = { ...servers };
201
202
  for (const id of connectors) {
202
- const connector = CONNECTOR_CATALOG[id];
203
+ const connector = CONNECTOR_CATALOG2[id];
203
204
  if (connector === undefined)
204
205
  throw new Error(`Unknown connector "${id}"`);
205
206
  merged[id] = structuredClone(connector.mcp);
@@ -207,4 +208,4 @@ function mergeConnectorMcpServers(connectors, servers, stepMcpKeys = Object.keys
207
208
  return merged;
208
209
  }
209
210
 
210
- export { connectorAuthValues, E2E_FAKE_CONNECTOR_FLAG, E2E_FAKE_CONNECTOR, connectorDefinitions, validateConnectorCatalog, CONNECTOR_CATALOG, isConnectorId, getConnector, listConnectorSummaries, connectorIdsSchema, ConnectorVarsMissing, findMissingConnectorVars, findConnectorMcpCollisions, connectorMcpCollisionMessage, ConnectorMcpCollision, mergeConnectorMcpServers };
211
+ export { connectorAuthValues2, E2E_FAKE_CONNECTOR_FLAG2, E2E_FAKE_CONNECTOR2, connectorDefinitions2, validateConnectorCatalog2, CONNECTOR_CATALOG2, isConnectorId2, getConnector2, listConnectorSummaries2, connectorIdsSchema2, ConnectorVarsMissing2, findMissingConnectorVars2, findConnectorMcpCollisions2, connectorMcpCollisionMessage2, ConnectorMcpCollision2, mergeConnectorMcpServers2 };
@@ -2,7 +2,7 @@
2
2
  // src/scarn-config-parser.ts
3
3
  import { access, readFile } from "fs/promises";
4
4
  import path from "path";
5
- var SCARN_CONFIG_RELATIVE_PATH = ".scarn/scarn.jsonc";
5
+ var SCARN_CONFIG_RELATIVE_PATH2 = ".scarn/scarn.jsonc";
6
6
  var stripJsoncComments = (content) => {
7
7
  let result = "";
8
8
  let inString = false;
@@ -90,12 +90,12 @@ var stripTrailingCommas = (content) => {
90
90
  if (character === ",") {
91
91
  let lookaheadIndex = index + 1;
92
92
  while (lookaheadIndex < content.length) {
93
- const lookaheadCharacter2 = content.charAt(lookaheadIndex);
94
- if (/\s/u.test(lookaheadCharacter2)) {
93
+ const lookaheadCharacter = content.charAt(lookaheadIndex);
94
+ if (/\s/u.test(lookaheadCharacter)) {
95
95
  lookaheadIndex += 1;
96
96
  continue;
97
97
  }
98
- if (lookaheadCharacter2 === "}" || lookaheadCharacter2 === "]") {
98
+ if (lookaheadCharacter === "}" || lookaheadCharacter === "]") {
99
99
  break;
100
100
  }
101
101
  result += character;
@@ -146,8 +146,8 @@ var parseServices = (raw) => {
146
146
  };
147
147
  });
148
148
  };
149
- async function parseScarnConfig(workspacePath) {
150
- const filePath = path.join(workspacePath, SCARN_CONFIG_RELATIVE_PATH);
149
+ async function parseScarnConfig2(workspacePath) {
150
+ const filePath = path.join(workspacePath, SCARN_CONFIG_RELATIVE_PATH2);
151
151
  const exists = await access(filePath).then(() => true).catch(() => false);
152
152
  if (!exists) {
153
153
  return { found: false };
@@ -163,4 +163,4 @@ async function parseScarnConfig(workspacePath) {
163
163
  };
164
164
  }
165
165
 
166
- export { SCARN_CONFIG_RELATIVE_PATH, parseScarnConfig };
166
+ export { SCARN_CONFIG_RELATIVE_PATH2, parseScarnConfig2 };