@scarn/sdk 0.8.20 → 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.
- package/dist/auth/api-token-cache.d.ts +24 -0
- package/dist/auth/api-token-source.d.ts +39 -0
- package/dist/auth/authenticated-fetch.d.ts +10 -0
- package/dist/auth/index.d.ts +3 -0
- package/dist/auth/index.js +20 -0
- package/dist/automations/index.js +4 -4
- package/dist/{chunk-pqtd0hr7.js → chunk-08gcnrzh.js} +2 -2
- package/dist/{chunk-g4j5cfpc.js → chunk-0he2dx5n.js} +5 -5
- package/dist/{chunk-z4smq8qd.js → chunk-59arcerk.js} +1 -1
- package/dist/{chunk-46wmsgv7.js → chunk-5say64w8.js} +1 -1
- package/dist/{chunk-habmdf89.js → chunk-6p340dd4.js} +1 -1
- package/dist/{chunk-19brnwkp.js → chunk-8hsk6f6b.js} +1 -1
- package/dist/{chunk-098740f7.js → chunk-8kzaxz52.js} +1 -1
- package/dist/{chunk-n3ywwx7n.js → chunk-8tmsvkmj.js} +5 -5
- package/dist/{chunk-e0pt5x0e.js → chunk-aph2js2v.js} +5 -5
- package/dist/chunk-azss2d1n.js +1036 -0
- package/dist/{chunk-t1dq2c2s.js → chunk-gasw078g.js} +5 -5
- package/dist/{chunk-0c60x3v8.js → chunk-h1v6w1fh.js} +5 -5
- package/dist/{chunk-tr3v83cn.js → chunk-k57h6qke.js} +8 -5
- package/dist/{chunk-aemxz9r7.js → chunk-mrzn5tq4.js} +1 -1
- package/dist/{chunk-qgkx89eg.js → chunk-nkm31g10.js} +3 -3
- package/dist/{chunk-yq0sf8sb.js → chunk-p74r4y6j.js} +13 -13
- package/dist/{chunk-a56zc4s5.js → chunk-pwyj6qf3.js} +2 -2
- package/dist/{chunk-b9ja6ss5.js → chunk-qt81x1pm.js} +1 -1
- package/dist/{chunk-mzj1j0p5.js → chunk-r3sbp2wn.js} +3 -3
- package/dist/{chunk-rphfy0fj.js → chunk-vsp708vw.js} +1 -1
- package/dist/{chunk-yf15kdte.js → chunk-xhpp6qz8.js} +96 -96
- package/dist/{chunk-y34zsgsw.js → chunk-y7ac1t9c.js} +1 -1
- package/dist/{chunk-rq5k7m33.js → chunk-y81cr6tp.js} +28 -14
- package/dist/{chunk-91f5gm5z.js → chunk-zxzvketc.js} +5 -5
- package/dist/client.d.ts +5 -1
- package/dist/client.js +2 -2
- package/dist/connectors/index.js +4 -4
- package/dist/contracts/artifacts.js +2 -2
- package/dist/contracts/automation-document/index.js +3 -3
- package/dist/contracts/pipeline-document/index.js +2 -2
- package/dist/contracts/step-artifact-submissions.js +2 -2
- package/dist/contracts/work-item-changes.js +1 -1
- package/dist/create-api-client.d.ts +11 -0
- package/dist/defaults/index.js +32 -871
- package/dist/defaults/load-push-defaults.d.ts +11 -4
- package/dist/defaults/project-ref.d.ts +2 -4
- package/dist/definitions/automations/automations-client.d.ts +2 -1
- package/dist/definitions/automations/index.js +3 -3
- package/dist/definitions/environments/environments-client.d.ts +2 -1
- package/dist/definitions/environments/index.js +10 -10
- package/dist/definitions/pipelines/index.js +3 -3
- package/dist/definitions/pipelines/pipeline-definitions-client.d.ts +2 -1
- package/dist/definitions/steps/index.js +13 -13
- package/dist/definitions/steps/step-definitions-client.d.ts +2 -1
- package/dist/definitions/validation/index.js +10 -10
- package/dist/devcontainer-config-path.js +2 -2
- package/dist/env-vars.js +2 -2
- package/dist/environment.js +7 -7
- package/dist/health-checks.js +2 -2
- package/dist/index.js +20 -20
- package/dist/managed-runtimes.js +2 -2
- package/dist/opencode-mcp.js +3 -3
- package/dist/pipelines/index.js +3 -3
- package/dist/push/index.js +42 -41
- package/dist/push/push-from-directory.d.ts +6 -1
- package/dist/repo-config.js +2 -2
- package/dist/resolve-environment.js +8 -8
- package/dist/task-plane-client.d.ts +6 -0
- 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-
|
|
7
|
+
} from "../chunk-6p340dd4.js";
|
|
8
8
|
import"../chunk-mp2rqtcj.js";
|
|
9
|
-
import"../chunk-
|
|
9
|
+
import"../chunk-pwyj6qf3.js";
|
|
10
10
|
import"../chunk-5dny5jg1.js";
|
|
11
|
-
import"../chunk-
|
|
11
|
+
import"../chunk-qt81x1pm.js";
|
|
12
12
|
import"../chunk-y11p1q7r.js";
|
|
13
13
|
import"../chunk-01nfqm18.js";
|
|
14
|
-
import"../chunk-
|
|
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-
|
|
5
|
+
} from "./chunk-mrzn5tq4.js";
|
|
6
6
|
import {
|
|
7
7
|
exports_external
|
|
8
|
-
} from "./chunk-
|
|
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
|
-
|
|
5
|
-
} from "./chunk-
|
|
4
|
+
createApiClient
|
|
5
|
+
} from "./chunk-y81cr6tp.js";
|
|
6
6
|
import {
|
|
7
7
|
exports_external
|
|
8
|
-
} from "./chunk-
|
|
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 =
|
|
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) => ({
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
Environments,
|
|
4
|
-
|
|
5
|
-
} from "./chunk-
|
|
4
|
+
createApiClient
|
|
5
|
+
} from "./chunk-y81cr6tp.js";
|
|
6
6
|
import {
|
|
7
7
|
exports_external
|
|
8
|
-
} from "./chunk-
|
|
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 =
|
|
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-
|
|
4
|
+
} from "./chunk-8kzaxz52.js";
|
|
5
5
|
import {
|
|
6
6
|
managedRuntimeIdSchema
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-5say64w8.js";
|
|
8
8
|
import {
|
|
9
9
|
connectorIdsSchema,
|
|
10
10
|
findMissingConnectorVars
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-nkm31g10.js";
|
|
12
12
|
import {
|
|
13
13
|
envVarsSchema,
|
|
14
14
|
storedEnvVarsSchema
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-mrzn5tq4.js";
|
|
16
16
|
import {
|
|
17
17
|
exports_external
|
|
18
|
-
} from "./chunk-
|
|
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-]*$/");
|