@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.
- package/dist/chunk-0y2fy5en.js +166 -0
- package/dist/chunk-3ctaaseb.js +1456 -0
- package/dist/chunk-4ggr8af6.js +30 -0
- package/dist/chunk-5zsavw98.js +91 -0
- package/dist/chunk-63f90zky.js +39 -0
- package/dist/chunk-700xe701.js +100 -0
- package/dist/chunk-ar6hcj1r.js +35 -0
- package/dist/chunk-cdanncng.js +74 -0
- package/dist/chunk-dp86pa6m.js +68 -0
- package/dist/chunk-e1h021kq.js +86 -0
- package/dist/chunk-gds7w7zh.js +330 -0
- package/dist/chunk-k4y5qt4y.js +14 -0
- package/dist/chunk-mz53r914.js +300 -0
- package/dist/chunk-ngy1fdcx.js +57 -0
- package/dist/chunk-p7yrcmqm.js +322 -0
- package/dist/chunk-rt9tq4j6.js +116 -0
- package/dist/chunk-skzxcba3.js +14282 -0
- package/dist/chunk-vfeytkqx.js +1687 -0
- package/dist/chunk-y2pv8d6a.js +162 -0
- package/dist/chunk-y64skrwp.js +17 -0
- package/dist/chunk-yjtaq94c.js +1094 -0
- package/dist/chunk-zm72ksz0.js +256 -0
- package/dist/client.d.ts +4 -0
- package/dist/client.js +58 -0
- package/dist/contracts/artifact-markers.d.ts +42 -0
- package/dist/contracts/artifact-markers.js +16 -0
- package/dist/contracts/artifacts.d.ts +67 -0
- package/dist/contracts/artifacts.js +27 -0
- package/dist/contracts/pipeline-document/built-ins.d.ts +23 -0
- package/dist/contracts/pipeline-document/conditions/operators.d.ts +8 -0
- package/dist/contracts/pipeline-document/index.d.ts +11 -0
- package/dist/contracts/pipeline-document/index.js +99 -0
- package/dist/contracts/pipeline-document/json.d.ts +35 -0
- package/dist/contracts/pipeline-document/routes.d.ts +16 -0
- package/dist/contracts/pipeline-document/schema.d.ts +780 -0
- package/dist/contracts/pipeline-document/step-contract.d.ts +11 -0
- package/dist/contracts/step-artifact-submissions.d.ts +71 -0
- package/dist/contracts/step-artifact-submissions.js +171 -0
- package/dist/defaults/atomic-json-file.d.ts +10 -0
- package/dist/defaults/auth-file.d.ts +14 -0
- package/dist/defaults/base-url.d.ts +1 -0
- package/dist/defaults/config-file.d.ts +46 -0
- package/dist/defaults/home-dir.d.ts +3 -0
- package/dist/defaults/index.d.ts +12 -0
- package/dist/defaults/index.js +1240 -0
- package/dist/defaults/legacy-config-migration.d.ts +27 -0
- package/dist/defaults/load-push-defaults.d.ts +25 -0
- package/dist/defaults/project-config.d.ts +32 -0
- package/dist/defaults/project-ref.d.ts +34 -0
- package/dist/definitions/artifacts/artifact.d.ts +62 -0
- package/dist/definitions/artifacts/index.d.ts +1 -0
- package/dist/definitions/pipelines/define-default-pipeline-assignment.d.ts +263 -0
- package/dist/definitions/pipelines/index.d.ts +3 -0
- package/dist/definitions/pipelines/index.js +26 -0
- package/dist/definitions/pipelines/pipeline-definitions-client.d.ts +208 -0
- package/dist/definitions/pipelines/work-item-fields.d.ts +93 -0
- package/dist/definitions/steps/compile-mcps.d.ts +34 -0
- package/dist/definitions/steps/define-code-step.d.ts +84 -0
- package/dist/definitions/steps/define-mcp.d.ts +79 -0
- package/dist/definitions/steps/define-step.d.ts +137 -0
- package/dist/definitions/steps/env.d.ts +136 -0
- package/dist/definitions/steps/index.d.ts +14 -0
- package/dist/definitions/steps/index.js +76 -0
- package/dist/definitions/steps/mcp-server-config.d.ts +102 -0
- package/dist/definitions/steps/prompt-template.d.ts +24 -0
- package/dist/definitions/steps/repo.d.ts +67 -0
- package/dist/definitions/steps/runtime.d.ts +115 -0
- package/dist/definitions/steps/step-definitions-client.d.ts +400 -0
- package/dist/definitions/steps/step-features.d.ts +109 -0
- package/dist/definitions/steps/step-handle.d.ts +25 -0
- package/dist/definitions/steps/step-ref.d.ts +19 -0
- package/dist/definitions/validation/index.d.ts +2 -0
- package/dist/definitions/validation/index.js +19 -0
- package/dist/definitions/validation/validate-artifact-markers.d.ts +3 -0
- package/dist/definitions/validation/validate-artifacts.d.ts +7 -0
- package/dist/definitions/validation/validate-definition-specs.d.ts +16 -0
- package/dist/definitions/validation/validate-env.d.ts +15 -0
- package/dist/definitions/validation/validate-repo.d.ts +13 -0
- package/dist/definitions/validation/validate-runtime.d.ts +12 -0
- package/dist/definitions/validation/validation-issue.d.ts +11 -0
- package/dist/devcontainer-config-path.d.ts +21 -0
- package/dist/devcontainer-config-path.js +15 -0
- package/dist/env-vars.d.ts +136 -0
- package/dist/env-vars.js +37 -0
- package/dist/eslint.d.ts +42 -0
- package/dist/eslint.js +127 -0
- package/dist/generated/client/client.gen.d.ts +2 -0
- package/dist/generated/client/index.d.ts +8 -0
- package/dist/generated/client/types.gen.d.ts +117 -0
- package/dist/generated/client/utils.gen.d.ts +33 -0
- package/dist/generated/client.gen.d.ts +12 -0
- package/dist/generated/core/auth.gen.d.ts +18 -0
- package/dist/generated/core/bodySerializer.gen.d.ts +25 -0
- package/dist/generated/core/params.gen.d.ts +43 -0
- package/dist/generated/core/pathSerializer.gen.d.ts +33 -0
- package/dist/generated/core/queryKeySerializer.gen.d.ts +18 -0
- package/dist/generated/core/serverSentEvents.gen.d.ts +71 -0
- package/dist/generated/core/types.gen.d.ts +78 -0
- package/dist/generated/core/utils.gen.d.ts +19 -0
- package/dist/generated/index.d.ts +2 -0
- package/dist/generated/sdk.gen.d.ts +302 -0
- package/dist/generated/types.gen.d.ts +18375 -0
- package/dist/git-url/git-remote.d.ts +30 -0
- package/dist/git-url/git-repo-identity.d.ts +44 -0
- package/dist/git-url/git-repo-identity.js +161 -0
- package/dist/git-url/parse-git-host.d.ts +23 -0
- package/dist/health-checks.d.ts +169 -0
- package/dist/health-checks.js +21 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +296 -0
- package/dist/jsonc.d.ts +3 -0
- package/dist/jsonc.js +12 -0
- package/dist/managed-runtimes.d.ts +20 -0
- package/dist/managed-runtimes.js +15 -0
- package/dist/opencode-mcp.d.ts +313 -0
- package/dist/opencode-mcp.js +31 -0
- package/dist/pipelines/chain.d.ts +7 -0
- package/dist/pipelines/compile-args.d.ts +12 -0
- package/dist/pipelines/compile-chain.d.ts +9 -0
- package/dist/pipelines/compile-checks.d.ts +16 -0
- package/dist/pipelines/compile-state.d.ts +30 -0
- package/dist/pipelines/condition-data.d.ts +78 -0
- package/dist/pipelines/conditions.d.ts +47 -0
- package/dist/pipelines/context.d.ts +16 -0
- package/dist/pipelines/define-pipeline.d.ts +32 -0
- package/dist/pipelines/each.d.ts +5 -0
- package/dist/pipelines/errors.d.ts +26 -0
- package/dist/pipelines/handles.d.ts +29 -0
- package/dist/pipelines/index.d.ts +18 -0
- package/dist/pipelines/index.js +83 -0
- package/dist/pipelines/model.d.ts +103 -0
- package/dist/pipelines/nodes.d.ts +54 -0
- package/dist/pipelines/ref-types.d.ts +54 -0
- package/dist/pipelines/refs.d.ts +80 -0
- package/dist/pipelines/registry.d.ts +12 -0
- package/dist/pipelines/source.d.ts +17 -0
- package/dist/pipelines/types.d.ts +160 -0
- package/dist/push/code-step-lookup.d.ts +32 -0
- package/dist/push/code-step-lookup.js +12 -0
- package/dist/push/collect-definitions.d.ts +70 -0
- package/dist/push/collect-pipeline-documents.d.ts +14 -0
- package/dist/push/index.d.ts +6 -0
- package/dist/push/index.js +327 -0
- package/dist/push/push-from-directory.d.ts +37 -0
- package/dist/repo-config.d.ts +80 -0
- package/dist/repo-config.js +25 -0
- package/dist/scarn-config-parser.d.ts +29 -0
- package/dist/scarn-config-parser.js +10 -0
- package/dist/task-plane-client.d.ts +489 -0
- package/dist/z.d.ts +7 -0
- package/package.json +132 -4
- package/README.md +0 -3
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** What a pipeline document needs to know about the steps it uses. */
|
|
2
|
+
import type { JsonSchema } from "./json";
|
|
3
|
+
/** What the validator needs to know about a step definition. */
|
|
4
|
+
export interface StepContract {
|
|
5
|
+
inputSchema: JsonSchema;
|
|
6
|
+
/** null: a conversation step, whose result is `CONVERSATION_RESULT_SCHEMA`. */
|
|
7
|
+
resultSchema: JsonSchema | null;
|
|
8
|
+
/** Error names the step declares, which `retry.on` and `catch.on` may use. */
|
|
9
|
+
errors: readonly string[];
|
|
10
|
+
}
|
|
11
|
+
export type StepCatalog = Readonly<Record<string, StepContract>>;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { type ArtifactField, type ArtifactJsonSchemaNode } from "./artifacts";
|
|
2
|
+
export declare const STEP_ARTIFACTS_RELATIVE_DIR = ".scarn/step-artifacts";
|
|
3
|
+
export declare const STEP_ARTIFACT_SUBMISSIONS_RELATIVE_PATH = ".scarn/current-execution/artifacts.json";
|
|
4
|
+
export type SubmittedArtifact = {
|
|
5
|
+
/** Path relative to the step-artifacts folder. */
|
|
6
|
+
readonly stored: string;
|
|
7
|
+
/** The path the agent submitted, as given. */
|
|
8
|
+
readonly sourcePath: string;
|
|
9
|
+
readonly sizeBytes: number;
|
|
10
|
+
};
|
|
11
|
+
export type StepArtifactSubmissions = {
|
|
12
|
+
readonly fields: Readonly<Record<string, SubmittedArtifact>>;
|
|
13
|
+
readonly extra: readonly SubmittedArtifact[];
|
|
14
|
+
};
|
|
15
|
+
export declare const EMPTY_STEP_ARTIFACT_SUBMISSIONS: StepArtifactSubmissions;
|
|
16
|
+
/** Declared artifact fields that can be filled in; v1 skips fields inside arrays. */
|
|
17
|
+
export declare function findSubmittableArtifactFields(schema: ArtifactJsonSchemaNode | null | undefined): ArtifactField[];
|
|
18
|
+
export declare function buildStepArtifactsDir(workspacePath: string): string;
|
|
19
|
+
export declare function buildStepArtifactSubmissionsPath(workspacePath: string): string;
|
|
20
|
+
/** Reads `artifacts.json`; a missing file means nothing was submitted. */
|
|
21
|
+
export declare function readStepArtifactSubmissions(workspacePath: string): Promise<StepArtifactSubmissions>;
|
|
22
|
+
export declare function writeStepArtifactSubmissions(workspacePath: string, submissions: StepArtifactSubmissions): Promise<void>;
|
|
23
|
+
/** A step's findings as parsed JSON. */
|
|
24
|
+
export type StepFindingsJson = string | number | boolean | null | StepFindingsJson[] | {
|
|
25
|
+
[key: string]: StepFindingsJson;
|
|
26
|
+
};
|
|
27
|
+
export type ApplyArtifactSubmissionsMode =
|
|
28
|
+
/**
|
|
29
|
+
* The plugin: a value the agent wrote in an artifact field is rejected, and
|
|
30
|
+
* every field is filled in from the submissions.
|
|
31
|
+
*/
|
|
32
|
+
"fill"
|
|
33
|
+
/**
|
|
34
|
+
* The worker: the findings were already filled in, so each artifact field
|
|
35
|
+
* must equal what the submissions record.
|
|
36
|
+
*/
|
|
37
|
+
| "verify";
|
|
38
|
+
export type ApplyArtifactSubmissionsResult = {
|
|
39
|
+
/** The findings with every artifact field filled in (a copy). */
|
|
40
|
+
readonly findings: StepFindingsJson;
|
|
41
|
+
readonly problems: readonly string[];
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Fills each declared artifact field from `submissions`: the stored name when
|
|
45
|
+
* the field was submitted, `null` when it wasn't and the field is nullable,
|
|
46
|
+
* and a problem when it wasn't and the field is required. Collects every
|
|
47
|
+
* problem rather than stopping at the first.
|
|
48
|
+
*/
|
|
49
|
+
export declare function applyArtifactSubmissions(input: {
|
|
50
|
+
readonly findings: StepFindingsJson;
|
|
51
|
+
readonly fields: readonly ArtifactField[];
|
|
52
|
+
readonly submissions: StepArtifactSubmissions;
|
|
53
|
+
readonly mode: ApplyArtifactSubmissionsMode;
|
|
54
|
+
}): ApplyArtifactSubmissionsResult;
|
|
55
|
+
/** Checks every submitted field's stored file is still a non-empty file. */
|
|
56
|
+
export declare function checkSubmittedArtifactFiles(input: {
|
|
57
|
+
readonly workspacePath: string;
|
|
58
|
+
readonly fields: readonly ArtifactField[];
|
|
59
|
+
readonly submissions: StepArtifactSubmissions;
|
|
60
|
+
}): Promise<string[]>;
|
|
61
|
+
/**
|
|
62
|
+
* Checks the artifact fields a code step returned (`Artifact.path(...)`
|
|
63
|
+
* values): each must be a path inside the step-artifacts folder naming a
|
|
64
|
+
* non-empty file with an accepted extension. `null` and absent values are
|
|
65
|
+
* left to the schema check.
|
|
66
|
+
*/
|
|
67
|
+
export declare function checkReturnedArtifactPaths(input: {
|
|
68
|
+
readonly workspacePath: string;
|
|
69
|
+
readonly fields: readonly ArtifactField[];
|
|
70
|
+
readonly findings: StepFindingsJson;
|
|
71
|
+
}): Promise<string[]>;
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
artifactAcceptsFile,
|
|
4
|
+
artifactFileExtension,
|
|
5
|
+
findArtifactFields
|
|
6
|
+
} from "../chunk-y2pv8d6a.js";
|
|
7
|
+
import {
|
|
8
|
+
exports_external
|
|
9
|
+
} from "../chunk-skzxcba3.js";
|
|
10
|
+
import"../chunk-y64skrwp.js";
|
|
11
|
+
|
|
12
|
+
// src/contracts/step-artifact-submissions.ts
|
|
13
|
+
import { mkdir, readFile, stat, writeFile } from "fs/promises";
|
|
14
|
+
import path from "path";
|
|
15
|
+
var STEP_ARTIFACTS_RELATIVE_DIR = ".scarn/step-artifacts";
|
|
16
|
+
var STEP_ARTIFACT_SUBMISSIONS_RELATIVE_PATH = ".scarn/current-execution/artifacts.json";
|
|
17
|
+
var EMPTY_STEP_ARTIFACT_SUBMISSIONS = {
|
|
18
|
+
fields: {},
|
|
19
|
+
extra: []
|
|
20
|
+
};
|
|
21
|
+
function findSubmittableArtifactFields(schema) {
|
|
22
|
+
return findArtifactFields(schema).filter((field) => !field.inArray);
|
|
23
|
+
}
|
|
24
|
+
var submittedArtifactSchema = exports_external.object({
|
|
25
|
+
stored: exports_external.string().min(1),
|
|
26
|
+
sourcePath: exports_external.string(),
|
|
27
|
+
sizeBytes: exports_external.number()
|
|
28
|
+
});
|
|
29
|
+
var stepArtifactSubmissionsSchema = exports_external.object({
|
|
30
|
+
fields: exports_external.record(exports_external.string(), submittedArtifactSchema),
|
|
31
|
+
extra: exports_external.array(submittedArtifactSchema)
|
|
32
|
+
});
|
|
33
|
+
function buildStepArtifactsDir(workspacePath) {
|
|
34
|
+
return path.join(workspacePath, STEP_ARTIFACTS_RELATIVE_DIR);
|
|
35
|
+
}
|
|
36
|
+
function buildStepArtifactSubmissionsPath(workspacePath) {
|
|
37
|
+
return path.join(workspacePath, STEP_ARTIFACT_SUBMISSIONS_RELATIVE_PATH);
|
|
38
|
+
}
|
|
39
|
+
async function readStepArtifactSubmissions(workspacePath) {
|
|
40
|
+
let raw;
|
|
41
|
+
try {
|
|
42
|
+
raw = await readFile(buildStepArtifactSubmissionsPath(workspacePath), "utf8");
|
|
43
|
+
} catch (error) {
|
|
44
|
+
if (error.code === "ENOENT") {
|
|
45
|
+
return EMPTY_STEP_ARTIFACT_SUBMISSIONS;
|
|
46
|
+
}
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
49
|
+
const parsed = stepArtifactSubmissionsSchema.safeParse(JSON.parse(raw));
|
|
50
|
+
if (!parsed.success) {
|
|
51
|
+
throw new Error(`${STEP_ARTIFACT_SUBMISSIONS_RELATIVE_PATH} is malformed: ${parsed.error.message}`);
|
|
52
|
+
}
|
|
53
|
+
return parsed.data;
|
|
54
|
+
}
|
|
55
|
+
async function writeStepArtifactSubmissions(workspacePath, submissions) {
|
|
56
|
+
const filePath = buildStepArtifactSubmissionsPath(workspacePath);
|
|
57
|
+
await mkdir(path.dirname(filePath), { recursive: true });
|
|
58
|
+
await writeFile(filePath, `${JSON.stringify(submissions, null, 2)}
|
|
59
|
+
`, "utf8");
|
|
60
|
+
}
|
|
61
|
+
function isJsonObject(value) {
|
|
62
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
63
|
+
}
|
|
64
|
+
function readPath(root, segments) {
|
|
65
|
+
let current = root;
|
|
66
|
+
for (const segment of segments) {
|
|
67
|
+
if (!isJsonObject(current))
|
|
68
|
+
return;
|
|
69
|
+
current = current[segment];
|
|
70
|
+
}
|
|
71
|
+
return current;
|
|
72
|
+
}
|
|
73
|
+
function writePath(root, segments, value) {
|
|
74
|
+
let current = root;
|
|
75
|
+
for (const segment of segments.slice(0, -1)) {
|
|
76
|
+
const next = current[segment];
|
|
77
|
+
if (isJsonObject(next)) {
|
|
78
|
+
current = next;
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
if (value === null || next !== undefined)
|
|
82
|
+
return;
|
|
83
|
+
const created = {};
|
|
84
|
+
current[segment] = created;
|
|
85
|
+
current = created;
|
|
86
|
+
}
|
|
87
|
+
const last = segments.at(-1);
|
|
88
|
+
if (last !== undefined)
|
|
89
|
+
current[last] = value;
|
|
90
|
+
}
|
|
91
|
+
function submitHint(field) {
|
|
92
|
+
return `call \`scarn-submit-artifact\` with \`field: "${field}"\``;
|
|
93
|
+
}
|
|
94
|
+
function applyArtifactSubmissions(input) {
|
|
95
|
+
const findings = structuredClone(input.findings);
|
|
96
|
+
const problems = [];
|
|
97
|
+
if (!isJsonObject(findings))
|
|
98
|
+
return { findings, problems };
|
|
99
|
+
for (const field of input.fields) {
|
|
100
|
+
const segments = field.path.split(".");
|
|
101
|
+
const current = readPath(findings, segments);
|
|
102
|
+
const submitted = input.submissions.fields[field.path];
|
|
103
|
+
const expected = submitted?.stored ?? null;
|
|
104
|
+
if (input.mode === "fill" && current !== undefined && current !== null) {
|
|
105
|
+
problems.push(`\`${field.path}\` is filled in from submitted artifacts. Remove it and ${submitHint(field.path)}.`);
|
|
106
|
+
}
|
|
107
|
+
if (input.mode === "verify" && (current ?? null) !== expected && (submitted || field.nullable)) {
|
|
108
|
+
problems.push(`\`${field.path}\` is ${JSON.stringify(current ?? null)} in the findings, but the submitted artifacts record ${JSON.stringify(expected)}.`);
|
|
109
|
+
}
|
|
110
|
+
if (!submitted && !field.nullable) {
|
|
111
|
+
problems.push(`\`${field.path}\` is required. Save the file and ${submitHint(field.path)} first.`);
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
writePath(findings, segments, expected);
|
|
115
|
+
}
|
|
116
|
+
return { findings, problems };
|
|
117
|
+
}
|
|
118
|
+
async function checkSubmittedArtifactFiles(input) {
|
|
119
|
+
const artifactsDir = buildStepArtifactsDir(input.workspacePath);
|
|
120
|
+
const problems = [];
|
|
121
|
+
for (const field of input.fields) {
|
|
122
|
+
const submitted = input.submissions.fields[field.path];
|
|
123
|
+
if (!submitted)
|
|
124
|
+
continue;
|
|
125
|
+
const relativePath = path.posix.join(STEP_ARTIFACTS_RELATIVE_DIR, submitted.stored);
|
|
126
|
+
const stats = await stat(path.join(artifactsDir, submitted.stored)).catch(() => null);
|
|
127
|
+
if (!stats?.isFile() || stats.size === 0) {
|
|
128
|
+
problems.push(`\`${field.path}\` was submitted as ${submitted.stored}, but ${relativePath} is missing or empty. Save the file again and ${submitHint(field.path)}.`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return problems;
|
|
132
|
+
}
|
|
133
|
+
function isInsideArtifactsDir(value) {
|
|
134
|
+
const normalized = path.posix.normalize(value);
|
|
135
|
+
return normalized === value && !value.includes("\\") && !path.posix.isAbsolute(value) && value !== "." && value !== ".." && !value.startsWith("../") && !value.endsWith("/");
|
|
136
|
+
}
|
|
137
|
+
async function checkReturnedArtifactPaths(input) {
|
|
138
|
+
const artifactsDir = buildStepArtifactsDir(input.workspacePath);
|
|
139
|
+
const problems = [];
|
|
140
|
+
for (const field of input.fields) {
|
|
141
|
+
const value = readPath(input.findings, field.path.split("."));
|
|
142
|
+
if (value === undefined || value === null)
|
|
143
|
+
continue;
|
|
144
|
+
if (typeof value !== "string" || !isInsideArtifactsDir(value)) {
|
|
145
|
+
problems.push(`\`${field.path}\` must be a path relative to ${STEP_ARTIFACTS_RELATIVE_DIR} (use \`Artifact.path("<name>")\`), got ${JSON.stringify(value)}.`);
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
const stats = await stat(path.join(artifactsDir, value)).catch(() => null);
|
|
149
|
+
if (!stats?.isFile() || stats.size === 0) {
|
|
150
|
+
problems.push(`\`${field.path}\` is ${value}, but ${path.posix.join(STEP_ARTIFACTS_RELATIVE_DIR, value)} is missing or empty.`);
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
if (!artifactAcceptsFile(field.accept, value)) {
|
|
154
|
+
problems.push(`\`${field.path}\` accepts ${field.accept.join(", ")}, but ${value} has ${artifactFileExtension(value) || "no extension"}.`);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return problems;
|
|
158
|
+
}
|
|
159
|
+
export {
|
|
160
|
+
EMPTY_STEP_ARTIFACT_SUBMISSIONS,
|
|
161
|
+
STEP_ARTIFACTS_RELATIVE_DIR,
|
|
162
|
+
STEP_ARTIFACT_SUBMISSIONS_RELATIVE_PATH,
|
|
163
|
+
applyArtifactSubmissions,
|
|
164
|
+
buildStepArtifactSubmissionsPath,
|
|
165
|
+
buildStepArtifactsDir,
|
|
166
|
+
checkReturnedArtifactPaths,
|
|
167
|
+
checkSubmittedArtifactFiles,
|
|
168
|
+
findSubmittableArtifactFields,
|
|
169
|
+
readStepArtifactSubmissions,
|
|
170
|
+
writeStepArtifactSubmissions
|
|
171
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Writes `data` as pretty-printed JSON to `filePath` atomically: serialize to
|
|
3
|
+
* a pid+timestamp-suffixed temp file in the same directory, then rename it
|
|
4
|
+
* over the target so a concurrent reader never observes a partially-written
|
|
5
|
+
* file. Creates the parent directory if it doesn't exist yet, and
|
|
6
|
+
* best-effort restricts both the temp file and the final path to
|
|
7
|
+
* owner-read/write (0o600). Shared by `auth-file.ts`'s `writeAuthFile` and
|
|
8
|
+
* `config-file.ts`'s `writeConfigFile` — the dance is identical for both.
|
|
9
|
+
*/
|
|
10
|
+
export declare function writeJsonFileAtomically(filePath: string, data: unknown): void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface AuthProfile {
|
|
2
|
+
accessToken: string;
|
|
3
|
+
userId?: string;
|
|
4
|
+
email?: string;
|
|
5
|
+
name?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface AuthFile {
|
|
8
|
+
profiles: Record<string, AuthProfile>;
|
|
9
|
+
}
|
|
10
|
+
export declare const getAuthFilePath: () => string;
|
|
11
|
+
export declare const loadAuthFile: () => AuthFile;
|
|
12
|
+
export declare const loadAuthProfile: (baseUrl: string) => AuthProfile | null;
|
|
13
|
+
export declare const saveAuthProfile: (baseUrl: string, profile: AuthProfile) => void;
|
|
14
|
+
export declare const deleteAuthProfile: (baseUrl: string) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const resolveScarnBaseUrl: (value?: string | null) => string;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export declare const DEFAULT_ARTIFACT_LOCAL_MAX_BYTES: number;
|
|
2
|
+
export declare const DEFAULT_ARTIFACT_LOCAL_MAX_AGE_DAYS = 14;
|
|
3
|
+
export interface ArtifactRetentionSettings {
|
|
4
|
+
localMaxBytes: number;
|
|
5
|
+
localMaxAgeDays: number;
|
|
6
|
+
}
|
|
7
|
+
export interface ConfigFile {
|
|
8
|
+
/**
|
|
9
|
+
* A random id generated on first read and persisted here — it identifies
|
|
10
|
+
* this machine/install before any account exists, so pre-auth CLI
|
|
11
|
+
* telemetry (init started, requirements verified) has a stable distinct
|
|
12
|
+
* id to key events to. See `getOrCreateAnonymousId`.
|
|
13
|
+
*/
|
|
14
|
+
anonymousId?: string;
|
|
15
|
+
/**
|
|
16
|
+
* User-level telemetry opt-out, set via `scarn telemetry disable` (or
|
|
17
|
+
* the `SCARN_TELEMETRY_DISABLED` env var, checked separately at the
|
|
18
|
+
* call site). Global — unlike auth profiles, it is not scoped to a
|
|
19
|
+
* `baseUrl`.
|
|
20
|
+
*/
|
|
21
|
+
telemetryDisabled?: boolean;
|
|
22
|
+
artifacts: ArtifactRetentionSettings;
|
|
23
|
+
}
|
|
24
|
+
export declare const getConfigFilePath: () => string;
|
|
25
|
+
/**
|
|
26
|
+
* See the matching comment in `auth-file.ts`: both modules must trigger
|
|
27
|
+
* `migrateLegacyConfigIfNeeded` from their own `loadX`, but neither may
|
|
28
|
+
* import the other, so `auth.jsonc`'s path is mirrored here rather than
|
|
29
|
+
* imported from `auth-file.ts`. `auth-file.ts` is the source of truth for
|
|
30
|
+
* that path string; if it ever changes, update both call sites.
|
|
31
|
+
*/
|
|
32
|
+
export declare const loadConfigFile: () => ConfigFile;
|
|
33
|
+
/**
|
|
34
|
+
* The persisted pre-auth distinct id for this machine/install, creating and
|
|
35
|
+
* persisting one the first time it is read. Stable across every command
|
|
36
|
+
* invocation until `~/.scarn/config.jsonc` is deleted or edited by hand —
|
|
37
|
+
* unlike `auth.jsonc`, nothing in this package deletes `config.jsonc`
|
|
38
|
+
* automatically (telemetry settings survive `scarn auth logout`, matching
|
|
39
|
+
* today's behavior).
|
|
40
|
+
*/
|
|
41
|
+
export declare const getOrCreateAnonymousId: () => string;
|
|
42
|
+
/** The persisted telemetry opt-out flag. Defaults to `false` (enabled). */
|
|
43
|
+
export declare const isTelemetryDisabled: () => boolean;
|
|
44
|
+
/** Persist the telemetry opt-out flag, leaving everything else intact. */
|
|
45
|
+
export declare const setTelemetryDisabled: (disabled: boolean) => void;
|
|
46
|
+
export declare const getArtifactRetentionSettings: () => ArtifactRetentionSettings;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { deleteAuthProfile, getAuthFilePath, loadAuthFile, loadAuthProfile, saveAuthProfile, } from "./auth-file";
|
|
2
|
+
export type { AuthFile, AuthProfile } from "./auth-file";
|
|
3
|
+
export { getArtifactRetentionSettings, getConfigFilePath, getOrCreateAnonymousId, isTelemetryDisabled, loadConfigFile, setTelemetryDisabled, } from "./config-file";
|
|
4
|
+
export type { ArtifactRetentionSettings, ConfigFile } from "./config-file";
|
|
5
|
+
export { setHomeDirForTests } from "./home-dir";
|
|
6
|
+
export { resolveScarnBaseUrl } from "./base-url";
|
|
7
|
+
export { formatProjectRef, isProjectRef, loadProjectConfig, parseProjectRef, PROJECT_CONFIG_RELATIVE_PATH, } from "./project-config";
|
|
8
|
+
export type { ProjectConfig, ProjectRef } from "./project-config";
|
|
9
|
+
export { PROJECT_REF_FORMAT_HINT, ProjectRefError, resolveProjectRef, } from "./project-ref";
|
|
10
|
+
export type { ProjectRefErrorKind, ResolvedProjectRef, ResolveProjectRefOptions, } from "./project-ref";
|
|
11
|
+
export { loadPushDefaults } from "./load-push-defaults";
|
|
12
|
+
export type { LoadPushDefaultsOptions, PushDefaults, } from "./load-push-defaults";
|