@scarn/sdk 0.8.19 → 0.8.21

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 (76) 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 +20 -0
  6. package/dist/automations/index.js +6 -6
  7. package/dist/{chunk-pqtd0hr7.js → chunk-08gcnrzh.js} +2 -2
  8. package/dist/{chunk-2tmrw253.js → chunk-0he2dx5n.js} +5 -5
  9. package/dist/{chunk-aknfw08j.js → chunk-59arcerk.js} +16 -13
  10. package/dist/{chunk-61jf8b6s.js → chunk-5dny5jg1.js} +11 -1
  11. package/dist/{chunk-46wmsgv7.js → chunk-5say64w8.js} +1 -1
  12. package/dist/{chunk-9we3vqsv.js → chunk-6p340dd4.js} +2 -2
  13. package/dist/{chunk-19brnwkp.js → chunk-8hsk6f6b.js} +1 -1
  14. package/dist/{chunk-098740f7.js → chunk-8kzaxz52.js} +1 -1
  15. package/dist/{chunk-mmy80pec.js → chunk-8tmsvkmj.js} +5 -5
  16. package/dist/{chunk-e0pt5x0e.js → chunk-aph2js2v.js} +5 -5
  17. package/dist/chunk-azss2d1n.js +1036 -0
  18. package/dist/{chunk-t1dq2c2s.js → chunk-gasw078g.js} +5 -5
  19. package/dist/{chunk-0c60x3v8.js → chunk-h1v6w1fh.js} +5 -5
  20. package/dist/{chunk-tvjcfh6s.js → chunk-k57h6qke.js} +8 -5
  21. package/dist/{chunk-x0hjhqrf.js → chunk-mp2rqtcj.js} +1 -1
  22. package/dist/{chunk-aemxz9r7.js → chunk-mrzn5tq4.js} +1 -1
  23. package/dist/{chunk-qgkx89eg.js → chunk-nkm31g10.js} +3 -3
  24. package/dist/{chunk-833ef6dg.js → chunk-p74r4y6j.js} +14 -14
  25. package/dist/{chunk-p1fs73bd.js → chunk-pwyj6qf3.js} +2 -2
  26. package/dist/{chunk-evb3hw48.js → chunk-qt81x1pm.js} +7 -4
  27. package/dist/{chunk-mzj1j0p5.js → chunk-r3sbp2wn.js} +3 -3
  28. package/dist/{chunk-rphfy0fj.js → chunk-vsp708vw.js} +1 -1
  29. package/dist/{chunk-yf15kdte.js → chunk-xhpp6qz8.js} +96 -96
  30. package/dist/{chunk-jj9pezwb.js → chunk-xqfj56m9.js} +43 -3
  31. package/dist/{chunk-y34zsgsw.js → chunk-y7ac1t9c.js} +1 -1
  32. package/dist/{chunk-3zp2qtf8.js → chunk-y81cr6tp.js} +38 -14
  33. package/dist/{chunk-ymywp5ht.js → chunk-zxzvketc.js} +5 -5
  34. package/dist/client.d.ts +5 -1
  35. package/dist/client.js +2 -2
  36. package/dist/connectors/index.js +4 -4
  37. package/dist/contracts/artifacts.js +2 -2
  38. package/dist/contracts/automation-document/index.js +3 -3
  39. package/dist/contracts/pipeline-document/index.js +5 -3
  40. package/dist/contracts/pipeline-document/routes.d.ts +9 -0
  41. package/dist/contracts/pipeline-document/schema.d.ts +40 -1
  42. package/dist/contracts/step-artifact-submissions.js +2 -2
  43. package/dist/contracts/work-item-changes.js +1 -1
  44. package/dist/create-api-client.d.ts +11 -0
  45. package/dist/defaults/index.js +32 -871
  46. package/dist/defaults/load-push-defaults.d.ts +11 -4
  47. package/dist/defaults/project-ref.d.ts +2 -4
  48. package/dist/definitions/automations/automations-client.d.ts +2 -1
  49. package/dist/definitions/automations/index.js +3 -3
  50. package/dist/definitions/environments/environments-client.d.ts +2 -1
  51. package/dist/definitions/environments/index.js +10 -10
  52. package/dist/definitions/pipelines/index.js +3 -3
  53. package/dist/definitions/pipelines/pipeline-definitions-client.d.ts +2 -1
  54. package/dist/definitions/steps/index.js +14 -14
  55. package/dist/definitions/steps/step-definitions-client.d.ts +2 -1
  56. package/dist/definitions/validation/index.js +10 -10
  57. package/dist/devcontainer-config-path.js +2 -2
  58. package/dist/env-vars.js +2 -2
  59. package/dist/environment.js +7 -7
  60. package/dist/generated/index.d.ts +1 -1
  61. package/dist/generated/sdk.gen.d.ts +5 -1
  62. package/dist/generated/types.gen.d.ts +298 -0
  63. package/dist/health-checks.js +2 -2
  64. package/dist/index.js +23 -23
  65. package/dist/managed-runtimes.js +2 -2
  66. package/dist/opencode-mcp.js +3 -3
  67. package/dist/pipelines/index.d.ts +1 -1
  68. package/dist/pipelines/index.js +6 -6
  69. package/dist/pipelines/model.d.ts +10 -4
  70. package/dist/pipelines/types.d.ts +13 -1
  71. package/dist/push/index.js +43 -42
  72. package/dist/push/push-from-directory.d.ts +6 -1
  73. package/dist/repo-config.js +2 -2
  74. package/dist/resolve-environment.js +8 -8
  75. package/dist/task-plane-client.d.ts +6 -0
  76. package/package.json +6 -2
@@ -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,20 @@
1
+ // @bun
2
+ import {
3
+ ApiTokenAuthError,
4
+ createApiTokenSource,
5
+ createAuthenticatedFetch,
6
+ deleteApiTokenCacheEntry,
7
+ getApiTokenCacheFilePath,
8
+ loadApiTokenCacheEntry,
9
+ saveApiTokenCacheEntry
10
+ } from "../chunk-azss2d1n.js";
11
+ import"../chunk-y64skrwp.js";
12
+ export {
13
+ ApiTokenAuthError,
14
+ createApiTokenSource,
15
+ createAuthenticatedFetch,
16
+ deleteApiTokenCacheEntry,
17
+ getApiTokenCacheFilePath,
18
+ loadApiTokenCacheEntry,
19
+ saveApiTokenCacheEntry
20
+ };
@@ -4,14 +4,14 @@ import {
4
4
  defineAutomation,
5
5
  onEvent,
6
6
  skip
7
- } from "../chunk-9we3vqsv.js";
8
- import"../chunk-x0hjhqrf.js";
9
- import"../chunk-p1fs73bd.js";
10
- import"../chunk-61jf8b6s.js";
11
- import"../chunk-evb3hw48.js";
7
+ } from "../chunk-6p340dd4.js";
8
+ import"../chunk-mp2rqtcj.js";
9
+ import"../chunk-pwyj6qf3.js";
10
+ import"../chunk-5dny5jg1.js";
11
+ import"../chunk-qt81x1pm.js";
12
12
  import"../chunk-y11p1q7r.js";
13
13
  import"../chunk-01nfqm18.js";
14
- import"../chunk-yf15kdte.js";
14
+ import"../chunk-xhpp6qz8.js";
15
15
  import"../chunk-y64skrwp.js";
16
16
  export {
17
17
  attach,
@@ -2,10 +2,10 @@
2
2
  import {
3
3
  MAX_ENV_VARS,
4
4
  inheritEnvVarSchema
5
- } from "./chunk-aemxz9r7.js";
5
+ } from "./chunk-mrzn5tq4.js";
6
6
  import {
7
7
  exports_external
8
- } from "./chunk-yf15kdte.js";
8
+ } from "./chunk-xhpp6qz8.js";
9
9
 
10
10
  // src/opencode-mcp.ts
11
11
  var workerVarsSchema = exports_external.array(inheritEnvVarSchema.safeExtend({ applies: exports_external.literal("agent") })).max(MAX_ENV_VARS).refine((entries) => new Set(entries.map((entry) => entry.name)).size === entries.length, { message: "MCP worker variable names must be unique" });
@@ -1,11 +1,11 @@
1
1
  // @bun
2
2
  import {
3
3
  Automations,
4
- createClient
5
- } from "./chunk-3zp2qtf8.js";
4
+ createApiClient
5
+ } from "./chunk-y81cr6tp.js";
6
6
  import {
7
7
  exports_external
8
- } from "./chunk-yf15kdte.js";
8
+ } from "./chunk-xhpp6qz8.js";
9
9
 
10
10
  // src/definitions/automations/automations-client.ts
11
11
  var automationDocumentIssueSchema = exports_external.object({
@@ -35,8 +35,8 @@ function unwrap(result) {
35
35
  }
36
36
  return result.data;
37
37
  }
38
- function createAutomationsClient(baseUrl) {
39
- const client = createClient({ baseUrl });
38
+ function createAutomationsClient(baseUrl, options) {
39
+ const client = createApiClient(baseUrl, { fetch: options?.fetch });
40
40
  return buildAutomationsClient(new Automations({ client }));
41
41
  }
42
42
  var buildAutomationsClient = (automations) => ({
@@ -18,11 +18,11 @@ import {
18
18
  useRef,
19
19
  withOwners,
20
20
  withTracker
21
- } from "./chunk-x0hjhqrf.js";
21
+ } from "./chunk-mp2rqtcj.js";
22
22
  import {
23
23
  bareStepHandle,
24
24
  waitHandle
25
- } from "./chunk-jj9pezwb.js";
25
+ } from "./chunk-xqfj56m9.js";
26
26
  import {
27
27
  AuthoringError,
28
28
  PipelineBuildError,
@@ -47,7 +47,7 @@ import {
47
47
  } from "./chunk-01nfqm18.js";
48
48
  import {
49
49
  toJSONSchema
50
- } from "./chunk-yf15kdte.js";
50
+ } from "./chunk-xhpp6qz8.js";
51
51
 
52
52
  // src/pipelines/context.ts
53
53
  function schemaOf(node, source) {
@@ -237,9 +237,10 @@ function wireBody(state, chain, json) {
237
237
  return;
238
238
  }
239
239
  const context = makeContext(chain.node, "next");
240
- const compileRoute = (when, target, pointer) => {
240
+ const compileRoute = (route, pointer) => {
241
241
  mapSource(state, pointer, next.site);
242
242
  const entry = {};
243
+ const { when, target, label, overridable } = route;
243
244
  if (when !== undefined) {
244
245
  const compiled2 = attempt(state, [...pointer, "when"], next.site, () => withOwners([context], () => compileCondition(conditionData(when(context)))));
245
246
  if (compiled2 !== undefined) {
@@ -247,7 +248,12 @@ function wireBody(state, chain, json) {
247
248
  }
248
249
  }
249
250
  const compiled = compileTransition(state, target, context, pointer, next.site, "next");
250
- return { ...entry, ...compiled };
251
+ return {
252
+ ...entry,
253
+ ...compiled,
254
+ ...label === undefined ? {} : { label },
255
+ ...overridable === undefined ? {} : { overridable }
256
+ };
251
257
  };
252
258
  const out = {};
253
259
  if (next.match === "all") {
@@ -259,21 +265,18 @@ function wireBody(state, chain, json) {
259
265
  }
260
266
  });
261
267
  }
262
- out["routes"] = next.routes.map((route, index) => compileRoute(route.when, route.target, [
263
- "nodes",
264
- id,
265
- "next",
266
- "routes",
267
- index
268
- ]));
268
+ out["routes"] = next.routes.map((route, index) => compileRoute(route, ["nodes", id, "next", "routes", index]));
269
269
  if (next.otherwise !== undefined) {
270
- out["otherwise"] = compileRoute(undefined, next.otherwise, [
270
+ out["otherwise"] = compileRoute(next.otherwise, [
271
271
  "nodes",
272
272
  id,
273
273
  "next",
274
274
  "otherwise"
275
275
  ]);
276
276
  }
277
+ if (next.overridable !== undefined) {
278
+ out["overridable"] = next.overridable;
279
+ }
277
280
  json["next"] = out;
278
281
  }
279
282
 
@@ -50,4 +50,14 @@ function routeAt(next, kind, index) {
50
50
  }
51
51
  return kind === "otherwise" ? next.otherwise : next.routes[index];
52
52
  }
53
- export { isJsonObject, jsonPointer, deepEqual, routeEntries, routeAt };
53
+ function isRouteOverridable(next, transition) {
54
+ const route = routeAt(next, transition.kind, transition.index);
55
+ if (next === undefined || route === undefined) {
56
+ return false;
57
+ }
58
+ if (transition.kind === "route" && next.match === "all" && next.routes[transition.index]?.when === undefined) {
59
+ return false;
60
+ }
61
+ return route.overridable ?? next.overridable ?? false;
62
+ }
63
+ export { isJsonObject, jsonPointer, deepEqual, routeEntries, routeAt, isRouteOverridable };
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  exports_external
4
- } from "./chunk-yf15kdte.js";
4
+ } from "./chunk-xhpp6qz8.js";
5
5
 
6
6
  // src/managed-runtimes.ts
7
7
  var MANAGED_RUNTIME_IDS = ["bun1", "node24"];
@@ -11,11 +11,11 @@ import {
11
11
  rootPlaceholder,
12
12
  withOwners,
13
13
  withTracker
14
- } from "./chunk-x0hjhqrf.js";
14
+ } from "./chunk-mp2rqtcj.js";
15
15
  import {
16
16
  eventHasChild,
17
17
  scopeOfEvent
18
- } from "./chunk-p1fs73bd.js";
18
+ } from "./chunk-pwyj6qf3.js";
19
19
  import {
20
20
  AuthoringError,
21
21
  PipelineBuildError,
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  exports_external
4
- } from "./chunk-yf15kdte.js";
4
+ } from "./chunk-xhpp6qz8.js";
5
5
 
6
6
  // src/contracts/artifacts.ts
7
7
  var artifactKindSchema = exports_external.enum([
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  exports_external
4
- } from "./chunk-yf15kdte.js";
4
+ } from "./chunk-xhpp6qz8.js";
5
5
 
6
6
  // src/devcontainer-config-path.ts
7
7
  var MAX_DEVCONTAINER_CONFIG_PATH_LENGTH = 255;
@@ -1,11 +1,11 @@
1
1
  // @bun
2
2
  import {
3
3
  Environments,
4
- createClient
5
- } from "./chunk-3zp2qtf8.js";
4
+ createApiClient
5
+ } from "./chunk-y81cr6tp.js";
6
6
  import {
7
7
  exports_external
8
- } from "./chunk-yf15kdte.js";
8
+ } from "./chunk-xhpp6qz8.js";
9
9
 
10
10
  // src/definitions/environments/environments-client.ts
11
11
  var environmentContentIssueSchema = exports_external.object({
@@ -34,8 +34,8 @@ function unwrap(result) {
34
34
  }
35
35
  return result.data;
36
36
  }
37
- function createEnvironmentsClient(baseUrl) {
38
- const client = createClient({ baseUrl });
37
+ function createEnvironmentsClient(baseUrl, options) {
38
+ const client = createApiClient(baseUrl, { fetch: options?.fetch });
39
39
  return buildEnvironmentsClient(new Environments({ client }));
40
40
  }
41
41
  var buildEnvironmentsClient = (environments) => ({
@@ -1,21 +1,21 @@
1
1
  // @bun
2
2
  import {
3
3
  devcontainerConfigPathSchema
4
- } from "./chunk-098740f7.js";
4
+ } from "./chunk-8kzaxz52.js";
5
5
  import {
6
6
  managedRuntimeIdSchema
7
- } from "./chunk-46wmsgv7.js";
7
+ } from "./chunk-5say64w8.js";
8
8
  import {
9
9
  connectorIdsSchema,
10
10
  findMissingConnectorVars
11
- } from "./chunk-qgkx89eg.js";
11
+ } from "./chunk-nkm31g10.js";
12
12
  import {
13
13
  envVarsSchema,
14
14
  storedEnvVarsSchema
15
- } from "./chunk-aemxz9r7.js";
15
+ } from "./chunk-mrzn5tq4.js";
16
16
  import {
17
17
  exports_external
18
- } from "./chunk-yf15kdte.js";
18
+ } from "./chunk-xhpp6qz8.js";
19
19
 
20
20
  // src/environment.ts
21
21
  var environmentNameSchema = exports_external.string().regex(/^[a-z0-9][a-z0-9-]*$/, "must match /^[a-z0-9][a-z0-9-]*$/");