spell-runtime 1.0.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/LICENSE +21 -0
- package/README.md +136 -0
- package/README.txt +126 -0
- package/dist/bundle/install.d.ts +7 -0
- package/dist/bundle/install.js +99 -0
- package/dist/bundle/install.js.map +1 -0
- package/dist/bundle/manifest.d.ts +5 -0
- package/dist/bundle/manifest.js +267 -0
- package/dist/bundle/manifest.js.map +1 -0
- package/dist/bundle/store.d.ts +16 -0
- package/dist/bundle/store.js +129 -0
- package/dist/bundle/store.js.map +1 -0
- package/dist/checks/evaluate.d.ts +2 -0
- package/dist/checks/evaluate.js +107 -0
- package/dist/checks/evaluate.js.map +1 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +144 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/logging/executionLog.d.ts +3 -0
- package/dist/logging/executionLog.js +31 -0
- package/dist/logging/executionLog.js.map +1 -0
- package/dist/runner/cast.d.ts +7 -0
- package/dist/runner/cast.js +117 -0
- package/dist/runner/cast.js.map +1 -0
- package/dist/runner/hostRunner.d.ts +5 -0
- package/dist/runner/hostRunner.js +41 -0
- package/dist/runner/hostRunner.js.map +1 -0
- package/dist/runner/input.d.ts +2 -0
- package/dist/runner/input.js +42 -0
- package/dist/runner/input.js.map +1 -0
- package/dist/runner/summary.d.ts +2 -0
- package/dist/runner/summary.js +31 -0
- package/dist/runner/summary.js.map +1 -0
- package/dist/steps/httpStep.d.ts +7 -0
- package/dist/steps/httpStep.js +100 -0
- package/dist/steps/httpStep.js.map +1 -0
- package/dist/steps/shellStep.d.ts +7 -0
- package/dist/steps/shellStep.js +48 -0
- package/dist/steps/shellStep.js.map +1 -0
- package/dist/types.d.ts +105 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/util/errors.d.ts +3 -0
- package/dist/util/errors.js +11 -0
- package/dist/util/errors.js.map +1 -0
- package/dist/util/http.d.ts +6 -0
- package/dist/util/http.js +11 -0
- package/dist/util/http.js.map +1 -0
- package/dist/util/idKey.d.ts +2 -0
- package/dist/util/idKey.js +11 -0
- package/dist/util/idKey.js.map +1 -0
- package/dist/util/object.d.ts +7 -0
- package/dist/util/object.js +62 -0
- package/dist/util/object.js.map +1 -0
- package/dist/util/outputs.d.ts +1 -0
- package/dist/util/outputs.js +28 -0
- package/dist/util/outputs.js.map +1 -0
- package/dist/util/paths.d.ts +4 -0
- package/dist/util/paths.js +26 -0
- package/dist/util/paths.js.map +1 -0
- package/dist/util/platform.d.ts +1 -0
- package/dist/util/platform.js +7 -0
- package/dist/util/platform.js.map +1 -0
- package/dist/util/template.d.ts +1 -0
- package/dist/util/template.js +61 -0
- package/dist/util/template.js.map +1 -0
- package/dist/util/version.d.ts +2 -0
- package/dist/util/version.js +35 -0
- package/dist/util/version.js.map +1 -0
- package/package.json +42 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.runHost = runHost;
|
|
7
|
+
const promises_1 = require("node:fs/promises");
|
|
8
|
+
const node_os_1 = require("node:os");
|
|
9
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
10
|
+
const errors_1 = require("../util/errors");
|
|
11
|
+
const httpStep_1 = require("../steps/httpStep");
|
|
12
|
+
const shellStep_1 = require("../steps/shellStep");
|
|
13
|
+
async function runHost(manifest, bundlePath, input) {
|
|
14
|
+
const tempDir = await (0, promises_1.mkdtemp)(node_path_1.default.join((0, node_os_1.tmpdir)(), "spell-input-"));
|
|
15
|
+
const inputPath = node_path_1.default.join(tempDir, "input.json");
|
|
16
|
+
await (0, promises_1.writeFile)(inputPath, JSON.stringify(input), "utf8");
|
|
17
|
+
const env = {
|
|
18
|
+
...process.env,
|
|
19
|
+
INPUT_JSON: inputPath
|
|
20
|
+
};
|
|
21
|
+
const outputs = {};
|
|
22
|
+
const stepResults = [];
|
|
23
|
+
for (const step of manifest.steps) {
|
|
24
|
+
const runPath = node_path_1.default.resolve(bundlePath, step.run);
|
|
25
|
+
if (step.uses === "shell") {
|
|
26
|
+
const result = await (0, shellStep_1.runShellStep)(step, runPath, bundlePath, env);
|
|
27
|
+
stepResults.push(result.stepResult);
|
|
28
|
+
outputs[`step.${step.name}.stdout`] = result.stdout;
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
if (step.uses === "http") {
|
|
32
|
+
const result = await (0, httpStep_1.runHttpStep)(step, runPath, input, env);
|
|
33
|
+
stepResults.push(result.stepResult);
|
|
34
|
+
outputs[`step.${step.name}.json`] = result.responseBody;
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
throw new errors_1.SpellError(`unsupported step type: ${step.uses}`);
|
|
38
|
+
}
|
|
39
|
+
return { outputs, stepResults };
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=hostRunner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hostRunner.js","sourceRoot":"","sources":["../../src/runner/hostRunner.ts"],"names":[],"mappings":";;;;;AAQA,0BAsCC;AA9CD,+CAAsD;AACtD,qCAAiC;AACjC,0DAA6B;AAE7B,2CAA4C;AAC5C,gDAAgD;AAChD,kDAAkD;AAE3C,KAAK,UAAU,OAAO,CAC3B,QAA6B,EAC7B,UAAkB,EAClB,KAA8B;IAE9B,MAAM,OAAO,GAAG,MAAM,IAAA,kBAAO,EAAC,mBAAI,CAAC,IAAI,CAAC,IAAA,gBAAM,GAAE,EAAE,cAAc,CAAC,CAAC,CAAC;IACnE,MAAM,SAAS,GAAG,mBAAI,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IACnD,MAAM,IAAA,oBAAS,EAAC,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK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|| function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.buildInput = buildInput;
|
|
7
|
+
exports.validateInputAgainstSchema = validateInputAgainstSchema;
|
|
8
|
+
const promises_1 = require("node:fs/promises");
|
|
9
|
+
const _2020_1 = __importDefault(require("ajv/dist/2020"));
|
|
10
|
+
const errors_1 = require("../util/errors");
|
|
11
|
+
const object_1 = require("../util/object");
|
|
12
|
+
const ajv = new _2020_1.default({ allErrors: true, strict: false });
|
|
13
|
+
async function buildInput(inputFile, paramPairs) {
|
|
14
|
+
let baseInput = {};
|
|
15
|
+
if (inputFile) {
|
|
16
|
+
const raw = await (0, promises_1.readFile)(inputFile, "utf8");
|
|
17
|
+
const parsed = JSON.parse(raw);
|
|
18
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
19
|
+
throw new errors_1.SpellError("--input must be a JSON object");
|
|
20
|
+
}
|
|
21
|
+
baseInput = { ...parsed };
|
|
22
|
+
}
|
|
23
|
+
for (const pair of paramPairs) {
|
|
24
|
+
const { key, value } = (0, object_1.parseKeyValuePair)(pair);
|
|
25
|
+
(0, object_1.setByDotPath)(baseInput, key, value);
|
|
26
|
+
}
|
|
27
|
+
return baseInput;
|
|
28
|
+
}
|
|
29
|
+
function validateInputAgainstSchema(schema, input) {
|
|
30
|
+
if (!schema || typeof schema !== "object" || Array.isArray(schema)) {
|
|
31
|
+
throw new errors_1.SpellError("schema.json must be a JSON object");
|
|
32
|
+
}
|
|
33
|
+
const validate = ajv.compile(schema);
|
|
34
|
+
const valid = validate(input);
|
|
35
|
+
if (!valid) {
|
|
36
|
+
const messages = (validate.errors ?? [])
|
|
37
|
+
.map((e) => `${e.instancePath || "/"} ${e.message}`.trim())
|
|
38
|
+
.join("; ");
|
|
39
|
+
throw new errors_1.SpellError(`input does not match schema: ${messages}`);
|
|
40
|
+
}
|
|
41
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,EAAE,CAAC;QACnE,MAAM,IAAI,mBAAU,CAAC,mCAAmC,CAAC,CAAC;IAC5D,CAAC;IAED,MAAM,QAAQ,GAAG,GAAG,CAAC,OAAO,CAAC,MAAmB,CAAC,CAAC;IAClD,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC9B,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,QAAQ,GAAG,CAAC,QAAQ,CAAC,MAAM,IAAI,EAAE,CAAC;aACrC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,YAAY,IAAI,GAAG,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC;aAC1D,IAAI,CAAC,IAAI,CAAC,CAAC;QACd,MAAM,IAAI,mBAAU,CAAC,gCAAgC,QAAQ,EAAE,CAAC,CAAC;IACnE,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.renderExecutionSummary = renderExecutionSummary;
|
|
4
|
+
function renderExecutionSummary(manifest) {
|
|
5
|
+
const lines = [];
|
|
6
|
+
lines.push("=== Execution Summary ===");
|
|
7
|
+
lines.push(`id@version: ${manifest.id}@${manifest.version}`);
|
|
8
|
+
lines.push(`risk: ${manifest.risk}`);
|
|
9
|
+
lines.push("effects:");
|
|
10
|
+
if (manifest.effects.length === 0) {
|
|
11
|
+
lines.push(" - none");
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
for (const effect of manifest.effects) {
|
|
15
|
+
lines.push(` - type=${effect.type}, target=${effect.target}, mutates=${effect.mutates}`);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
lines.push("permissions:");
|
|
19
|
+
if (manifest.permissions.length === 0) {
|
|
20
|
+
lines.push(" - none");
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
for (const permission of manifest.permissions) {
|
|
24
|
+
lines.push(` - connector=${permission.connector}, scopes=${permission.scopes.join(",")}`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
lines.push(`billing: enabled=${manifest.billing.enabled}, mode=${manifest.billing.mode}, max_amount=${manifest.billing.max_amount}, currency=${manifest.billing.currency}`);
|
|
28
|
+
lines.push(`runtime: execution=${manifest.runtime.execution}, docker_image=${manifest.runtime.docker_image ?? "-"}`);
|
|
29
|
+
return lines.join("\n");
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=summary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"summary.js","sourceRoot":"","sources":["../../src/runner/summary.ts"],"names":[],"mappings":";;AAEA,wDAgCC;AAhCD,SAAgB,sBAAsB,CAAC,QAA6B;IAClE,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;IACxC,KAAK,CAAC,IAAI,CAAC,eAAe,QAAQ,CAAC,EAAE,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;IAC7D,KAAK,CAAC,IAAI,CAAC,SAAS,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IAErC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACvB,IAAI,QAAQ,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAClC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACzB,CAAC;SAAM,CAAC;QACN,KAAK,MAAM,MAAM,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC;YACtC,KAAK,CAAC,IAAI,CAAC,YAAY,MAAM,CAAC,IAAI,YAAY,MAAM,CAAC,MAAM,aAAa,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;QAC5F,CAAC;IACH,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAC3B,IAAI,QAAQ,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtC,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACzB,CAAC;SAAM,CAAC;QACN,KAAK,MAAM,UAAU,IAAI,QAAQ,CAAC,WAAW,EAAE,CAAC;YAC9C,KAAK,CAAC,IAAI,CAAC,iBAAiB,UAAU,CAAC,SAAS,YAAY,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC7F,CAAC;IACH,CAAC;IAED,KAAK,CAAC,IAAI,CACR,oBAAoB,QAAQ,CAAC,OAAO,CAAC,OAAO,UAAU,QAAQ,CAAC,OAAO,CAAC,IAAI,gBAAgB,QAAQ,CAAC,OAAO,CAAC,UAAU,cAAc,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,CAChK,CAAC;IACF,KAAK,CAAC,IAAI,CACR,sBAAsB,QAAQ,CAAC,OAAO,CAAC,SAAS,kBAAkB,QAAQ,CAAC,OAAO,CAAC,YAAY,IAAI,GAAG,EAAE,CACzG,CAAC;IAEF,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SpellStep, StepResult } from "../types";
|
|
2
|
+
export interface HttpStepExecution {
|
|
3
|
+
stepResult: StepResult;
|
|
4
|
+
responseBody: unknown;
|
|
5
|
+
status: number;
|
|
6
|
+
}
|
|
7
|
+
export declare function runHttpStep(step: SpellStep, runPath: string, input: Record<string, unknown>, env: NodeJS.ProcessEnv): Promise<HttpStepExecution>;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runHttpStep = runHttpStep;
|
|
4
|
+
const promises_1 = require("node:fs/promises");
|
|
5
|
+
const errors_1 = require("../util/errors");
|
|
6
|
+
const http_1 = require("../util/http");
|
|
7
|
+
const template_1 = require("../util/template");
|
|
8
|
+
async function runHttpStep(step, runPath, input, env) {
|
|
9
|
+
const started = new Date().toISOString();
|
|
10
|
+
const raw = await (0, promises_1.readFile)(runPath, "utf8");
|
|
11
|
+
let parsed;
|
|
12
|
+
try {
|
|
13
|
+
parsed = JSON.parse(raw);
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
throw new errors_1.SpellError(`failed to parse http step '${step.name}' JSON: ${error.message}`);
|
|
17
|
+
}
|
|
18
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
19
|
+
throw new errors_1.SpellError(`http step '${step.name}' definition must be an object`);
|
|
20
|
+
}
|
|
21
|
+
const def = parsed;
|
|
22
|
+
const method = readRequiredString(def, "method");
|
|
23
|
+
const urlValue = readRequiredString(def, "url");
|
|
24
|
+
const headersValue = def.headers;
|
|
25
|
+
const bodyValue = def.body;
|
|
26
|
+
const resolvedMethod = String((0, template_1.applyTemplate)(method, input, env)).toUpperCase();
|
|
27
|
+
const resolvedUrl = (0, template_1.applyTemplate)(urlValue, input, env);
|
|
28
|
+
if (typeof resolvedUrl !== "string") {
|
|
29
|
+
throw new errors_1.SpellError(`http step '${step.name}' url must resolve to string`);
|
|
30
|
+
}
|
|
31
|
+
const resolvedHeaders = (0, template_1.applyTemplate)(headersValue, input, env);
|
|
32
|
+
const headers = normalizeHeaders(resolvedHeaders);
|
|
33
|
+
const resolvedBody = (0, template_1.applyTemplate)(bodyValue, input, env);
|
|
34
|
+
let body;
|
|
35
|
+
if (resolvedBody !== undefined) {
|
|
36
|
+
if (typeof resolvedBody === "string") {
|
|
37
|
+
body = resolvedBody;
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
body = JSON.stringify(resolvedBody);
|
|
41
|
+
if (!hasHeader(headers, "content-type")) {
|
|
42
|
+
headers["content-type"] = "application/json";
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const response = await (0, http_1.fetchHttp)(resolvedUrl, {
|
|
47
|
+
method: resolvedMethod,
|
|
48
|
+
headers,
|
|
49
|
+
body
|
|
50
|
+
});
|
|
51
|
+
const responseText = await response.text();
|
|
52
|
+
let responseBody;
|
|
53
|
+
try {
|
|
54
|
+
responseBody = JSON.parse(responseText);
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
responseBody = responseText;
|
|
58
|
+
}
|
|
59
|
+
const finished = new Date().toISOString();
|
|
60
|
+
const stepResult = {
|
|
61
|
+
stepName: step.name,
|
|
62
|
+
uses: step.uses,
|
|
63
|
+
started_at: started,
|
|
64
|
+
finished_at: finished,
|
|
65
|
+
success: true,
|
|
66
|
+
message: `http ${resolvedMethod} ${resolvedUrl} -> ${response.status}`
|
|
67
|
+
};
|
|
68
|
+
return {
|
|
69
|
+
stepResult,
|
|
70
|
+
responseBody,
|
|
71
|
+
status: response.status
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
function readRequiredString(obj, key) {
|
|
75
|
+
const value = obj[key];
|
|
76
|
+
if (typeof value !== "string" || !value.trim()) {
|
|
77
|
+
throw new errors_1.SpellError(`http step definition missing '${key}' string`);
|
|
78
|
+
}
|
|
79
|
+
return value;
|
|
80
|
+
}
|
|
81
|
+
function normalizeHeaders(value) {
|
|
82
|
+
if (value === undefined) {
|
|
83
|
+
return {};
|
|
84
|
+
}
|
|
85
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
86
|
+
throw new errors_1.SpellError("http step headers must resolve to an object");
|
|
87
|
+
}
|
|
88
|
+
const out = {};
|
|
89
|
+
for (const [k, v] of Object.entries(value)) {
|
|
90
|
+
if (typeof v !== "string") {
|
|
91
|
+
throw new errors_1.SpellError(`http step header '${k}' must be string`);
|
|
92
|
+
}
|
|
93
|
+
out[k.toLowerCase()] = v;
|
|
94
|
+
}
|
|
95
|
+
return out;
|
|
96
|
+
}
|
|
97
|
+
function hasHeader(headers, key) {
|
|
98
|
+
return Object.prototype.hasOwnProperty.call(headers, key.toLowerCase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AC1B,MAAM,IAAI,mBAAU,CAAC,qBAAqB,CAAC,kBAAkB,CAAC,CAAC;QACjE,CAAC;QACD,GAAG,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,SAAS,CAAC,OAA+B,EAAE,GAAW;IAC7D,OAAO,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC;AAC1E,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SpellStep, StepResult } from "../types";
|
|
2
|
+
export interface ShellStepExecution {
|
|
3
|
+
stepResult: StepResult;
|
|
4
|
+
stdout: string;
|
|
5
|
+
stderr: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function runShellStep(step: SpellStep, runPath: string, cwd: string, env: NodeJS.ProcessEnv): Promise<ShellStepExecution>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runShellStep = runShellStep;
|
|
4
|
+
const node_child_process_1 = require("node:child_process");
|
|
5
|
+
const errors_1 = require("../util/errors");
|
|
6
|
+
async function runShellStep(step, runPath, cwd, env) {
|
|
7
|
+
const started = new Date().toISOString();
|
|
8
|
+
const child = (0, node_child_process_1.spawn)(runPath, [], {
|
|
9
|
+
shell: false,
|
|
10
|
+
cwd,
|
|
11
|
+
env
|
|
12
|
+
});
|
|
13
|
+
let stdout = "";
|
|
14
|
+
let stderr = "";
|
|
15
|
+
child.stdout.on("data", (chunk) => {
|
|
16
|
+
stdout += chunk.toString();
|
|
17
|
+
});
|
|
18
|
+
child.stderr.on("data", (chunk) => {
|
|
19
|
+
stderr += chunk.toString();
|
|
20
|
+
});
|
|
21
|
+
const exitCode = await new Promise((resolve, reject) => {
|
|
22
|
+
child.on("error", reject);
|
|
23
|
+
child.on("close", resolve);
|
|
24
|
+
}).catch((error) => {
|
|
25
|
+
throw new errors_1.SpellError(`failed to execute shell step '${step.name}': ${error.message}`);
|
|
26
|
+
});
|
|
27
|
+
const finished = new Date().toISOString();
|
|
28
|
+
const stepResult = {
|
|
29
|
+
stepName: step.name,
|
|
30
|
+
uses: step.uses,
|
|
31
|
+
started_at: started,
|
|
32
|
+
finished_at: finished,
|
|
33
|
+
success: exitCode === 0,
|
|
34
|
+
exitCode,
|
|
35
|
+
stdout_head: stdout.slice(0, 200),
|
|
36
|
+
stderr_head: stderr.slice(0, 200),
|
|
37
|
+
message: exitCode === 0 ? "ok" : `non-zero exit code: ${exitCode}`
|
|
38
|
+
};
|
|
39
|
+
if (exitCode !== 0) {
|
|
40
|
+
throw new errors_1.SpellError(`step failed: ${step.name} (exit code ${exitCode})`);
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
stepResult,
|
|
44
|
+
stdout,
|
|
45
|
+
stderr
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=shellStep.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shellStep.js","sourceRoot":"","sources":["../../src/steps/shellStep.ts"],"names":[],"mappings":";;AAUA,oCAuDC;AAjED,2DAA2C;AAE3C,2CAA4C;AAQrC,KAAK,UAAU,YAAY,CAChC,IAAe,EACf,OAAe,EACf,GAAW,EACX,GAAsB;IAEtB,MAAM,OAAO,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAEzC,MAAM,KAAK,GAAG,IAAA,0BAAK,EAAC,OAAO,EAAE,EAAE,EAAE;QAC/B,KAAK,EAAE,KAAK;QACZ,GAAG;QACH,GAAG;KACJ,CAAC,CAAC;IAEH,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,IAAI,MAAM,GAAG,EAAE,CAAC;IAEhB,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,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IAAI,CAAC,IAAI,eAAe,QAAQ,GAAG,CAAC,CAAC;IAC5E,CAAC;IAED,OAAO;QACL,UAAU;QACV,MAAM;QACN,MAAM;KACP,CAAC;AACJ,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
export type SpellRisk = "low" | "medium" | "high" | "critical";
|
|
2
|
+
export type RuntimeExecution = "host" | "docker";
|
|
3
|
+
export type StepUses = "shell" | "http";
|
|
4
|
+
export type CheckType = "exit_code" | "file_exists" | "http_status" | "jsonpath_equals";
|
|
5
|
+
export interface SpellPermission {
|
|
6
|
+
connector: string;
|
|
7
|
+
scopes: string[];
|
|
8
|
+
}
|
|
9
|
+
export interface SpellEffect {
|
|
10
|
+
type: string;
|
|
11
|
+
target: string;
|
|
12
|
+
mutates: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface SpellBilling {
|
|
15
|
+
enabled: boolean;
|
|
16
|
+
mode: "none" | "upfront" | "on_success" | "subscription";
|
|
17
|
+
currency: string;
|
|
18
|
+
max_amount: number;
|
|
19
|
+
}
|
|
20
|
+
export interface SpellRuntime {
|
|
21
|
+
execution: RuntimeExecution;
|
|
22
|
+
platforms: string[];
|
|
23
|
+
docker_image?: string;
|
|
24
|
+
}
|
|
25
|
+
export interface SpellStep {
|
|
26
|
+
uses: StepUses;
|
|
27
|
+
name: string;
|
|
28
|
+
run: string;
|
|
29
|
+
}
|
|
30
|
+
export interface SpellCheck {
|
|
31
|
+
type: CheckType;
|
|
32
|
+
params: Record<string, unknown>;
|
|
33
|
+
}
|
|
34
|
+
export interface SpellBundleManifest {
|
|
35
|
+
id: string;
|
|
36
|
+
version: string;
|
|
37
|
+
name: string;
|
|
38
|
+
summary: string;
|
|
39
|
+
inputs_schema: string;
|
|
40
|
+
risk: SpellRisk;
|
|
41
|
+
permissions: SpellPermission[];
|
|
42
|
+
effects: SpellEffect[];
|
|
43
|
+
billing: SpellBilling;
|
|
44
|
+
runtime: SpellRuntime;
|
|
45
|
+
steps: SpellStep[];
|
|
46
|
+
checks: SpellCheck[];
|
|
47
|
+
}
|
|
48
|
+
export interface LoadedBundle {
|
|
49
|
+
manifest: SpellBundleManifest;
|
|
50
|
+
bundlePath: string;
|
|
51
|
+
schemaPath: string;
|
|
52
|
+
idKey: string;
|
|
53
|
+
}
|
|
54
|
+
export interface StepResult {
|
|
55
|
+
stepName: string;
|
|
56
|
+
uses: StepUses;
|
|
57
|
+
started_at: string;
|
|
58
|
+
finished_at: string;
|
|
59
|
+
success: boolean;
|
|
60
|
+
exitCode?: number | null;
|
|
61
|
+
stdout_head?: string;
|
|
62
|
+
stderr_head?: string;
|
|
63
|
+
message?: string;
|
|
64
|
+
}
|
|
65
|
+
export interface CheckResult {
|
|
66
|
+
type: CheckType;
|
|
67
|
+
success: boolean;
|
|
68
|
+
message: string;
|
|
69
|
+
}
|
|
70
|
+
export interface CastContext {
|
|
71
|
+
input: Record<string, unknown>;
|
|
72
|
+
outputs: Record<string, unknown>;
|
|
73
|
+
bundlePath: string;
|
|
74
|
+
manifest: SpellBundleManifest;
|
|
75
|
+
stepResults: StepResult[];
|
|
76
|
+
}
|
|
77
|
+
export interface ExecutionLog {
|
|
78
|
+
execution_id: string;
|
|
79
|
+
started_at: string;
|
|
80
|
+
finished_at: string;
|
|
81
|
+
id: string;
|
|
82
|
+
version: string;
|
|
83
|
+
input: Record<string, unknown>;
|
|
84
|
+
summary: {
|
|
85
|
+
risk: SpellRisk;
|
|
86
|
+
billing: SpellBilling;
|
|
87
|
+
runtime: SpellRuntime;
|
|
88
|
+
};
|
|
89
|
+
steps: StepResult[];
|
|
90
|
+
outputs: Record<string, unknown>;
|
|
91
|
+
checks: CheckResult[];
|
|
92
|
+
success: boolean;
|
|
93
|
+
error?: string;
|
|
94
|
+
}
|
|
95
|
+
export interface CastOptions {
|
|
96
|
+
id: string;
|
|
97
|
+
version?: string;
|
|
98
|
+
inputFile?: string;
|
|
99
|
+
paramPairs: string[];
|
|
100
|
+
dryRun: boolean;
|
|
101
|
+
yes: boolean;
|
|
102
|
+
allowBilling: boolean;
|
|
103
|
+
verbose: boolean;
|
|
104
|
+
profile?: string;
|
|
105
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SpellError = void 0;
|
|
4
|
+
class SpellError extends Error {
|
|
5
|
+
constructor(message) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = "SpellError";
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.SpellError = SpellError;
|
|
11
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/util/errors.ts"],"names":[],"mappings":";;;AAAA,MAAa,UAAW,SAAQ,KAAK;IACnC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;IAC3B,CAAC;CACF;AALD,gCAKC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { fetch as undiciFetch } from "undici";
|
|
2
|
+
type FetchInput = Parameters<typeof undiciFetch>[0];
|
|
3
|
+
type FetchInit = Parameters<typeof undiciFetch>[1];
|
|
4
|
+
type FetchResponse = Awaited<ReturnType<typeof undiciFetch>>;
|
|
5
|
+
export declare function fetchHttp(input: FetchInput, init?: FetchInit): Promise<FetchResponse>;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fetchHttp = fetchHttp;
|
|
4
|
+
const undici_1 = require("undici");
|
|
5
|
+
async function fetchHttp(input, init) {
|
|
6
|
+
if (typeof globalThis.fetch === "function") {
|
|
7
|
+
return globalThis.fetch(input, init);
|
|
8
|
+
}
|
|
9
|
+
return (0, undici_1.fetch)(input, init);
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=http.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/util/http.ts"],"names":[],"mappings":";;AAMA,8BAMC;AAZD,mCAA8C;AAMvC,KAAK,UAAU,SAAS,CAAC,KAAiB,EAAE,IAAgB;IACjE,IAAI,OAAO,UAAU,CAAC,KAAK,KAAK,UAAU,EAAE,CAAC;QAC3C,OAAO,UAAU,CAAC,KAAK,CAAC,KAAc,EAAE,IAAa,CAA6B,CAAC;IACrF,CAAC;IAED,OAAO,IAAA,cAAW,EAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toIdKey = toIdKey;
|
|
4
|
+
exports.sanitizeIdForFilename = sanitizeIdForFilename;
|
|
5
|
+
function toIdKey(id) {
|
|
6
|
+
return Buffer.from(id, "utf8").toString("base64url");
|
|
7
|
+
}
|
|
8
|
+
function sanitizeIdForFilename(id) {
|
|
9
|
+
return id.replace(/[^a-zA-Z0-9._-]/g, "_");
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=idKey.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"idKey.js","sourceRoot":"","sources":["../../src/util/idKey.ts"],"names":[],"mappings":";;AAAA,0BAEC;AAED,sDAEC;AAND,SAAgB,OAAO,CAAC,EAAU;IAChC,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;AACvD,CAAC;AAED,SAAgB,qBAAqB,CAAC,EAAU;IAC9C,OAAO,EAAE,CAAC,OAAO,CAAC,kBAAkB,EAAE,GAAG,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function getByDotPath(input: unknown, dotPath: string): unknown;
|
|
2
|
+
export declare function setByDotPath(target: Record<string, unknown>, dotPath: string, value: unknown): void;
|
|
3
|
+
export declare function parseKeyValuePair(pair: string): {
|
|
4
|
+
key: string;
|
|
5
|
+
value: unknown;
|
|
6
|
+
};
|
|
7
|
+
export declare function parseMaybeJson(raw: string): unknown;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getByDotPath = getByDotPath;
|
|
4
|
+
exports.setByDotPath = setByDotPath;
|
|
5
|
+
exports.parseKeyValuePair = parseKeyValuePair;
|
|
6
|
+
exports.parseMaybeJson = parseMaybeJson;
|
|
7
|
+
const errors_1 = require("./errors");
|
|
8
|
+
function getByDotPath(input, dotPath) {
|
|
9
|
+
if (dotPath.trim() === "") {
|
|
10
|
+
return input;
|
|
11
|
+
}
|
|
12
|
+
const parts = dotPath.split(".");
|
|
13
|
+
let cursor = input;
|
|
14
|
+
for (const part of parts) {
|
|
15
|
+
if (cursor === null || typeof cursor !== "object" || !(part in cursor)) {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
cursor = cursor[part];
|
|
19
|
+
}
|
|
20
|
+
return cursor;
|
|
21
|
+
}
|
|
22
|
+
function setByDotPath(target, dotPath, value) {
|
|
23
|
+
const parts = dotPath.split(".").filter(Boolean);
|
|
24
|
+
if (parts.length === 0) {
|
|
25
|
+
throw new errors_1.SpellError("invalid -p key: empty key");
|
|
26
|
+
}
|
|
27
|
+
let cursor = target;
|
|
28
|
+
for (let i = 0; i < parts.length - 1; i += 1) {
|
|
29
|
+
const part = parts[i];
|
|
30
|
+
const next = cursor[part];
|
|
31
|
+
if (typeof next !== "object" || next === null || Array.isArray(next)) {
|
|
32
|
+
cursor[part] = {};
|
|
33
|
+
}
|
|
34
|
+
cursor = cursor[part];
|
|
35
|
+
}
|
|
36
|
+
cursor[parts[parts.length - 1]] = value;
|
|
37
|
+
}
|
|
38
|
+
function parseKeyValuePair(pair) {
|
|
39
|
+
const idx = pair.indexOf("=");
|
|
40
|
+
if (idx <= 0) {
|
|
41
|
+
throw new errors_1.SpellError(`invalid -p argument: ${pair}`);
|
|
42
|
+
}
|
|
43
|
+
const key = pair.slice(0, idx).trim();
|
|
44
|
+
const raw = pair.slice(idx + 1);
|
|
45
|
+
if (!key) {
|
|
46
|
+
throw new errors_1.SpellError(`invalid -p argument: ${pair}`);
|
|
47
|
+
}
|
|
48
|
+
return { key, value: parseMaybeJson(raw) };
|
|
49
|
+
}
|
|
50
|
+
function parseMaybeJson(raw) {
|
|
51
|
+
const trimmed = raw.trim();
|
|
52
|
+
if (!trimmed) {
|
|
53
|
+
return "";
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
return JSON.parse(trimmed);
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return raw;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=object.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"object.js","sourceRoot":"","sources":["../../src/util/object.ts"],"names":[],"mappings":";;AAEA,oCAgBC;AAED,oCAiBC;AAED,8CAcC;AAED,wCAWC;AAlED,qCAAsC;AAEtC,SAAgB,YAAY,CAAC,KAAc,EAAE,OAAe;IAC1D,IAAI,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QAC1B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACjC,IAAI,MAAM,GAAY,KAAK,CAAC;IAE5B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,MAAM,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AAC,EAAE,CAAC;QACb,MAAM,IAAI,mBAAU,CAAC,wBAAwB,IAAI,EAAE,CAAC,CAAC;IACvD,CAAC;IAED,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IACtC,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;IAEhC,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,mBAAU,CAAC,wBAAwB,IAAI,EAAE,CAAC,CAAC;IACvD,CAAC;IAED,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC;AAC7C,CAAC;AAED,SAAgB,cAAc,CAAC,GAAW;IACxC,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;IAC3B,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC7B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,GAAG,CAAC;IACb,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function resolveOutputReference(outputs: Record<string, unknown>, ref: string): unknown;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveOutputReference = resolveOutputReference;
|
|
4
|
+
const errors_1 = require("./errors");
|
|
5
|
+
const object_1 = require("./object");
|
|
6
|
+
function resolveOutputReference(outputs, ref) {
|
|
7
|
+
const match = /^step\.([^.]+)\.(stdout|json)(?:\.(.+))?$/.exec(ref);
|
|
8
|
+
if (!match) {
|
|
9
|
+
throw new errors_1.SpellError(`invalid output reference: ${ref}`);
|
|
10
|
+
}
|
|
11
|
+
const [, stepName, kind, path] = match;
|
|
12
|
+
const key = `step.${stepName}.${kind}`;
|
|
13
|
+
if (!(key in outputs)) {
|
|
14
|
+
throw new errors_1.SpellError(`output reference not found: ${ref}`);
|
|
15
|
+
}
|
|
16
|
+
const baseValue = outputs[key];
|
|
17
|
+
if (kind === "stdout") {
|
|
18
|
+
if (path) {
|
|
19
|
+
throw new errors_1.SpellError(`stdout reference does not support nested path: ${ref}`);
|
|
20
|
+
}
|
|
21
|
+
return baseValue;
|
|
22
|
+
}
|
|
23
|
+
if (!path) {
|
|
24
|
+
return baseValue;
|
|
25
|
+
}
|
|
26
|
+
return (0, object_1.getByDotPath)(baseValue, path);
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=outputs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outputs.js","sourceRoot":"","sources":["../../src/util/outputs.ts"],"names":[],"mappings":";;AAGA,wDA0BC;AA7BD,qCAAsC;AACtC,qCAAwC;AAExC,SAAgB,sBAAsB,CAAC,OAAgC,EAAE,GAAW;IAClF,MAAM,KAAK,GAAG,2CAA2C,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpE,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,mBAAU,CAAC,6BAA6B,GAAG,EAAE,CAAC,CAAC;IAC3D,CAAC;IAED,MAAM,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,KAAK,CAAC;IACvC,MAAM,GAAG,GAAG,QAAQ,QAAQ,IAAI,IAAI,EAAE,CAAC;IACvC,IAAI,CAAC,CAAC,GAAG,IAAI,OAAO,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,mBAAU,CAAC,+BAA+B,GAAG,EAAE,CAAC,CAAC;IAC7D,CAAC;IAED,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAE/B,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;QACtB,IAAI,IAAI,EAAE,CAAC;YACT,MAAM,IAAI,mBAAU,CAAC,kDAAkD,GAAG,EAAE,CAAC,CAAC;QAChF,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,IAAA,qBAAY,EAAC,SAAS,EAAE,IAAI,CAAC,CAAC;AACvC,CAAC"}
|