@diagonal-hq/cli 0.38.1 → 0.38.3
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/README.md +1 -1
- package/dist/check-data.json +1 -0
- package/dist/cli-assets-cli-VQBXYEIZ.mjs +386 -0
- package/dist/cli-check-data-GHZW7MSI.mjs +17893 -0
- package/dist/cli-chunk-A7Q2M4ZU.mjs +1052 -0
- package/dist/cli-chunk-F2J44UIS.mjs +39865 -0
- package/dist/cli-chunk-HWHRAOWD.mjs +24035 -0
- package/dist/cli-chunk-IJTP2OMH.mjs +212 -0
- package/dist/cli-chunk-LRS5IEI3.mjs +48 -0
- package/dist/cli-chunk-T6442V5V.mjs +7463 -0
- package/dist/cli-chunk-WPC3DBHX.mjs +52 -0
- package/dist/cli-chunk-XMVYLKEB.mjs +359 -0
- package/dist/cli-chunk-YIPLFIKL.mjs +63 -0
- package/dist/cli-files.generated-WAU3U62D.mjs +61 -0
- package/dist/cli-sdk-files.generated-HAH7DJPZ.mjs +1429 -0
- package/dist/cli-skill-file-TEJUXCJB.mjs +262 -0
- package/dist/cli-workflows-E2QBBI3W.mjs +462 -0
- package/dist/cli.mjs +400 -100589
- package/dist/script-sdk.json +1 -0
- package/package.json +7 -4
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { createRequire as __diagonalCreateRequire } from 'node:module';
|
|
2
|
+
const require = __diagonalCreateRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
stringFacts
|
|
5
|
+
} from "./cli-chunk-WPC3DBHX.mjs";
|
|
6
|
+
|
|
7
|
+
// scripts/lib/workflow-script/compile.mjs
|
|
8
|
+
import { spawn, spawnSync } from "node:child_process";
|
|
9
|
+
import { createRequire as createRequire2 } from "node:module";
|
|
10
|
+
|
|
11
|
+
// scripts/lib/native-platform-suffix.mjs
|
|
12
|
+
function nativePlatformSuffix({
|
|
13
|
+
platform = process.platform,
|
|
14
|
+
arch = process.arch,
|
|
15
|
+
glibcVersionRuntime = (globalThis[/* @__PURE__ */ Symbol.for("diagonal.nativePlatformSuffix.glibcVersionRuntime")] ??= {
|
|
16
|
+
value: process.report.getReport().header.glibcVersionRuntime
|
|
17
|
+
}).value
|
|
18
|
+
} = {}) {
|
|
19
|
+
const parts = [platform, arch];
|
|
20
|
+
if (platform === "linux") {
|
|
21
|
+
if (glibcVersionRuntime) {
|
|
22
|
+
parts.push(arch === "arm" ? "gnueabihf" : "gnu");
|
|
23
|
+
} else {
|
|
24
|
+
parts.push("musl");
|
|
25
|
+
}
|
|
26
|
+
} else if (platform === "win32") {
|
|
27
|
+
parts.push("msvc");
|
|
28
|
+
}
|
|
29
|
+
return parts.join("-");
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// scripts/lib/runtime-build/bundled-binaries.mjs
|
|
33
|
+
import { accessSync, chmodSync, constants, existsSync } from "node:fs";
|
|
34
|
+
var BUN_PACKAGES = {
|
|
35
|
+
"darwin-arm64": "@oven/bun-darwin-aarch64",
|
|
36
|
+
"darwin-x64": "@oven/bun-darwin-x64",
|
|
37
|
+
"linux-arm64-gnu": "@oven/bun-linux-aarch64",
|
|
38
|
+
"linux-arm64-musl": "@oven/bun-linux-aarch64-musl",
|
|
39
|
+
"linux-x64-gnu": "@oven/bun-linux-x64",
|
|
40
|
+
"linux-x64-musl": "@oven/bun-linux-x64-musl"
|
|
41
|
+
};
|
|
42
|
+
function bunPackage(nativePlatform) {
|
|
43
|
+
const name = BUN_PACKAGES[nativePlatform];
|
|
44
|
+
if (name === void 0) {
|
|
45
|
+
throw new Error(`bun has no package for the platform ${nativePlatform}.`);
|
|
46
|
+
}
|
|
47
|
+
return name;
|
|
48
|
+
}
|
|
49
|
+
function ensureExecutable(binary) {
|
|
50
|
+
try {
|
|
51
|
+
accessSync(binary, constants.X_OK);
|
|
52
|
+
} catch (error) {
|
|
53
|
+
if (error.code !== "EACCES") {
|
|
54
|
+
throw error;
|
|
55
|
+
}
|
|
56
|
+
chmodSync(binary, 493);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// scripts/lib/workflow-script/compiler-packages.mjs
|
|
61
|
+
import { existsSync as existsSync2, readFileSync } from "node:fs";
|
|
62
|
+
import { createRequire } from "node:module";
|
|
63
|
+
import { fileURLToPath } from "node:url";
|
|
64
|
+
var COMPILER_BINARY = "workflow-script-compiler";
|
|
65
|
+
var checkout = new URL("../../../", import.meta.url);
|
|
66
|
+
var crate = new URL("services/workflow-script-compiler/", checkout);
|
|
67
|
+
function compilerPackage(platform) {
|
|
68
|
+
return `@diagonal-hq/workflow-script-compiler-${platform}`;
|
|
69
|
+
}
|
|
70
|
+
function compilerSourcesHash() {
|
|
71
|
+
const stamp = fileURLToPath(new URL("sources.stamp", crate));
|
|
72
|
+
return existsSync2(stamp) ? readFileSync(stamp, "utf8").trim() : null;
|
|
73
|
+
}
|
|
74
|
+
function hostCompilerPlatform() {
|
|
75
|
+
return `${process.platform}-${process.arch}`;
|
|
76
|
+
}
|
|
77
|
+
function localCompilerBinary(platform) {
|
|
78
|
+
const directory = new URL(`dist/${platform}/`, crate);
|
|
79
|
+
const binary = fileURLToPath(new URL(COMPILER_BINARY, directory));
|
|
80
|
+
const stamp = fileURLToPath(new URL("sources.stamp", directory));
|
|
81
|
+
const hash = compilerSourcesHash();
|
|
82
|
+
return hash !== null && existsSync2(binary) && existsSync2(stamp) && readFileSync(stamp, "utf8").trim() === hash ? binary : null;
|
|
83
|
+
}
|
|
84
|
+
function bundledCompilerBinary(platform) {
|
|
85
|
+
const directory = new URL(`scripts/dist/workflow-script-compiler/${platform}/`, checkout);
|
|
86
|
+
const binary = fileURLToPath(new URL(COMPILER_BINARY, directory));
|
|
87
|
+
const stamp = fileURLToPath(new URL("sources.stamp", directory));
|
|
88
|
+
const hash = compilerSourcesHash();
|
|
89
|
+
return hash !== null && existsSync2(binary) && existsSync2(stamp) && readFileSync(stamp, "utf8").trim() === hash ? binary : null;
|
|
90
|
+
}
|
|
91
|
+
function installedCompilerBinary(platform, from = import.meta.url) {
|
|
92
|
+
try {
|
|
93
|
+
return createRequire(from).resolve(`${compilerPackage(platform)}/bin/${COMPILER_BINARY}`);
|
|
94
|
+
} catch {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// scripts/lib/workflow-script/compile.mjs
|
|
100
|
+
function compilerBinary() {
|
|
101
|
+
if (process.env.WORKFLOW_SCRIPT_COMPILER_BINARY) {
|
|
102
|
+
return process.env.WORKFLOW_SCRIPT_COMPILER_BINARY;
|
|
103
|
+
}
|
|
104
|
+
const platform = hostCompilerPlatform();
|
|
105
|
+
const binary = localCompilerBinary(platform) ?? bundledCompilerBinary(platform) ?? installedCompilerBinary(platform);
|
|
106
|
+
if (binary === null) {
|
|
107
|
+
throw new Error(
|
|
108
|
+
`No workflow script compiler for ${platform} matches services/workflow-script-compiler/sources.stamp. Run npm run build:runtime-workspace-build, or services/workflow-script-compiler/build.sh ${platform}.`
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
ensureExecutable(binary);
|
|
112
|
+
return binary;
|
|
113
|
+
}
|
|
114
|
+
var packagedBun = null;
|
|
115
|
+
function bunBinary() {
|
|
116
|
+
if (process.env.RUNTIME_BUN_BINARY) {
|
|
117
|
+
return process.env.RUNTIME_BUN_BINARY;
|
|
118
|
+
}
|
|
119
|
+
packagedBun ??= packagedBunBinary();
|
|
120
|
+
return packagedBun;
|
|
121
|
+
}
|
|
122
|
+
function packagedBunBinary() {
|
|
123
|
+
const require2 = createRequire2(import.meta.url);
|
|
124
|
+
try {
|
|
125
|
+
return require2.resolve(`${bunPackage(nativePlatformSuffix())}/bin/bun`);
|
|
126
|
+
} catch {
|
|
127
|
+
return require2.resolve("bun/bin/bun.exe");
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
function stripTypes(files) {
|
|
131
|
+
if (files.length === 0) {
|
|
132
|
+
return [];
|
|
133
|
+
}
|
|
134
|
+
return runCompiler({ strips: files }).stripResults;
|
|
135
|
+
}
|
|
136
|
+
function runWorkspaceBuild(root, request, sources = {}, needs = workspaceBuildNeeds(root, request, sources)) {
|
|
137
|
+
return workspaceBuildAnswer(runCompiler(workspaceBuildInput(root, request, sources, needs), buildArguments(sources)));
|
|
138
|
+
}
|
|
139
|
+
async function runWorkspaceBuildAsync(root, request, sources, needs) {
|
|
140
|
+
return workspaceBuildAnswer(await runCompilerAsync(workspaceBuildInput(root, request, sources, needs), buildArguments(sources)));
|
|
141
|
+
}
|
|
142
|
+
function workspaceBuildInput(root, request, { data = null, sdk = null, skillFrontMatter = null }, needs) {
|
|
143
|
+
if (needs.skills.length > 0 && skillFrontMatter === null) {
|
|
144
|
+
throw new Error("The build needs the reader of the skill files.");
|
|
145
|
+
}
|
|
146
|
+
const build = data === null ? { root, ...request } : { root, ...request, data };
|
|
147
|
+
const answers = { stringFacts: stringFacts(needs.stringFacts), skillFrontMatter: needs.skills.length > 0 ? skillFrontMatter(root, needs.skills) : {} };
|
|
148
|
+
return { build: { ...build, ...answers }, ...sdk === null ? {} : { sdk } };
|
|
149
|
+
}
|
|
150
|
+
function workspaceBuildAnswer(answer) {
|
|
151
|
+
if (answer.failure !== void 0) {
|
|
152
|
+
throw answer.failure.name === "TypeError" ? new TypeError(answer.failure.message) : new Error(answer.failure.message);
|
|
153
|
+
}
|
|
154
|
+
return answer;
|
|
155
|
+
}
|
|
156
|
+
function workspaceBuildNeeds(root, request, sources = {}) {
|
|
157
|
+
const { data = null } = sources;
|
|
158
|
+
const first = runCompiler({ build: data === null ? { root, ...request } : { root, ...request, data } }, buildArguments(sources), { bun: false });
|
|
159
|
+
if (first.needs === void 0) {
|
|
160
|
+
throw new Error("The workflow script compiler did not name the needs of the build.");
|
|
161
|
+
}
|
|
162
|
+
return first.needs;
|
|
163
|
+
}
|
|
164
|
+
function buildArguments({ dataFile = null, sdkFile = null }) {
|
|
165
|
+
return [...dataFile === null ? [] : ["--data", dataFile], ...sdkFile === null ? [] : ["--sdk", sdkFile]];
|
|
166
|
+
}
|
|
167
|
+
function runCompiler(input, args = [], { timeout, bun = true } = {}) {
|
|
168
|
+
const run = spawnSync(compilerBinary(), args, {
|
|
169
|
+
input: JSON.stringify(input),
|
|
170
|
+
encoding: "utf8",
|
|
171
|
+
maxBuffer: 256 * 1024 * 1024,
|
|
172
|
+
timeout,
|
|
173
|
+
killSignal: "SIGKILL",
|
|
174
|
+
env: bun ? { ...process.env, RUNTIME_BUN_BINARY: bunBinary() } : process.env
|
|
175
|
+
});
|
|
176
|
+
if (run.error !== void 0) {
|
|
177
|
+
throw run.error;
|
|
178
|
+
}
|
|
179
|
+
if (run.status !== 0) {
|
|
180
|
+
throw new Error(`The workflow script compiler failed: ${run.stderr.slice(0, 2e3)}`);
|
|
181
|
+
}
|
|
182
|
+
return JSON.parse(run.stdout);
|
|
183
|
+
}
|
|
184
|
+
function runCompilerAsync(input, args) {
|
|
185
|
+
return new Promise((resolve, reject) => {
|
|
186
|
+
const child = spawn(compilerBinary(), args, { env: { ...process.env, RUNTIME_BUN_BINARY: bunBinary() } });
|
|
187
|
+
const stdout = [];
|
|
188
|
+
const stderr = [];
|
|
189
|
+
child.stdout.on("data", (chunk) => stdout.push(chunk));
|
|
190
|
+
child.stderr.on("data", (chunk) => stderr.push(chunk));
|
|
191
|
+
child.on("error", reject);
|
|
192
|
+
child.on("close", (status) => {
|
|
193
|
+
if (status !== 0) {
|
|
194
|
+
reject(new Error(`The workflow script compiler failed: ${Buffer.concat(stderr).toString("utf8").slice(0, 2e3)}`));
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
try {
|
|
198
|
+
resolve(JSON.parse(Buffer.concat(stdout).toString("utf8")));
|
|
199
|
+
} catch (error) {
|
|
200
|
+
reject(error);
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
child.stdin.end(JSON.stringify(input));
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export {
|
|
208
|
+
stripTypes,
|
|
209
|
+
runWorkspaceBuild,
|
|
210
|
+
runWorkspaceBuildAsync,
|
|
211
|
+
workspaceBuildNeeds
|
|
212
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { createRequire as __diagonalCreateRequire } from 'node:module';
|
|
2
|
+
const require = __diagonalCreateRequire(import.meta.url);
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
10
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
11
|
+
}) : x)(function(x) {
|
|
12
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
13
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
14
|
+
});
|
|
15
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
16
|
+
try {
|
|
17
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
18
|
+
} catch (e) {
|
|
19
|
+
throw mod = 0, e;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
var __export = (target, all) => {
|
|
23
|
+
for (var name in all)
|
|
24
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
25
|
+
};
|
|
26
|
+
var __copyProps = (to, from, except, desc) => {
|
|
27
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
28
|
+
for (let key of __getOwnPropNames(from))
|
|
29
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
30
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
31
|
+
}
|
|
32
|
+
return to;
|
|
33
|
+
};
|
|
34
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
35
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
36
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
37
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
38
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
39
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
40
|
+
mod
|
|
41
|
+
));
|
|
42
|
+
|
|
43
|
+
export {
|
|
44
|
+
__require,
|
|
45
|
+
__commonJS,
|
|
46
|
+
__export,
|
|
47
|
+
__toESM
|
|
48
|
+
};
|