skedyul 1.4.11 → 1.5.2
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 +157 -240
- package/dist/cli/index.js +324 -255
- package/dist/config/index.d.ts +0 -1
- package/dist/config/loader.js +208 -0
- package/dist/config/loader.mjs +184 -0
- package/dist/config/transpileConfigMetadata.d.ts +1 -0
- package/dist/esm/index.mjs +37 -141
- package/dist/index.d.ts +1 -1
- package/dist/index.js +37 -138
- package/package.json +9 -2
package/dist/cli/index.js
CHANGED
|
@@ -364,6 +364,96 @@ var init_link = __esm({
|
|
|
364
364
|
}
|
|
365
365
|
});
|
|
366
366
|
|
|
367
|
+
// src/config/transpileConfigMetadata.ts
|
|
368
|
+
var transpileConfigMetadata_exports = {};
|
|
369
|
+
__export(transpileConfigMetadata_exports, {
|
|
370
|
+
transpileConfigMetadata: () => transpileConfigMetadata
|
|
371
|
+
});
|
|
372
|
+
function prepareConfigSource(content) {
|
|
373
|
+
return content.replace(/import\s*\(\s*(['"])([^'"]+)\1\s*\)/g, "Promise.resolve(null)");
|
|
374
|
+
}
|
|
375
|
+
function isJsonImport(importPath) {
|
|
376
|
+
return importPath.endsWith(".json");
|
|
377
|
+
}
|
|
378
|
+
async function transpileConfigMetadata(configPath) {
|
|
379
|
+
const esbuild = await import("esbuild");
|
|
380
|
+
const absolutePath = path12.resolve(configPath);
|
|
381
|
+
const configDir = path12.dirname(absolutePath);
|
|
382
|
+
const configBasename = path12.basename(absolutePath);
|
|
383
|
+
const result = await esbuild.build({
|
|
384
|
+
absWorkingDir: configDir,
|
|
385
|
+
entryPoints: [absolutePath],
|
|
386
|
+
bundle: true,
|
|
387
|
+
format: "cjs",
|
|
388
|
+
platform: "node",
|
|
389
|
+
target: "node22",
|
|
390
|
+
write: false,
|
|
391
|
+
logLevel: "silent",
|
|
392
|
+
plugins: [
|
|
393
|
+
{
|
|
394
|
+
name: "prepare-config-entry",
|
|
395
|
+
setup(build) {
|
|
396
|
+
build.onLoad({ filter: new RegExp(`/${configBasename.replace(".", "\\.")}$`) }, () => ({
|
|
397
|
+
contents: prepareConfigSource(fs12.readFileSync(absolutePath, "utf-8")),
|
|
398
|
+
loader: "ts"
|
|
399
|
+
}));
|
|
400
|
+
}
|
|
401
|
+
},
|
|
402
|
+
{
|
|
403
|
+
name: "skedyul-shim",
|
|
404
|
+
setup(build) {
|
|
405
|
+
build.onResolve({ filter: /^skedyul$/ }, () => ({
|
|
406
|
+
path: "skedyul-shim",
|
|
407
|
+
namespace: SKEDYUL_SHIM_NAMESPACE
|
|
408
|
+
}));
|
|
409
|
+
build.onLoad({ filter: /.*/, namespace: SKEDYUL_SHIM_NAMESPACE }, () => ({
|
|
410
|
+
contents: [
|
|
411
|
+
"function defineConfig(config) { return config; }",
|
|
412
|
+
"module.exports = { defineConfig };"
|
|
413
|
+
].join("\n"),
|
|
414
|
+
loader: "js"
|
|
415
|
+
}));
|
|
416
|
+
}
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
name: "metadata-stub-imports",
|
|
420
|
+
setup(build) {
|
|
421
|
+
build.onResolve({ filter: /^\.{1,2}\// }, (args2) => {
|
|
422
|
+
if (isJsonImport(args2.path)) {
|
|
423
|
+
return void 0;
|
|
424
|
+
}
|
|
425
|
+
return {
|
|
426
|
+
path: args2.path,
|
|
427
|
+
namespace: METADATA_STUB_NAMESPACE
|
|
428
|
+
};
|
|
429
|
+
});
|
|
430
|
+
build.onLoad({ filter: /.*/, namespace: METADATA_STUB_NAMESPACE }, () => ({
|
|
431
|
+
contents: "module.exports = {};\n",
|
|
432
|
+
loader: "js"
|
|
433
|
+
}));
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
]
|
|
437
|
+
});
|
|
438
|
+
if (result.errors.length > 0) {
|
|
439
|
+
throw new Error(result.errors.map((error) => error.text).join("\n"));
|
|
440
|
+
}
|
|
441
|
+
if (result.outputFiles.length === 0) {
|
|
442
|
+
throw new Error("Config transpile produced no output");
|
|
443
|
+
}
|
|
444
|
+
return result.outputFiles[0].text;
|
|
445
|
+
}
|
|
446
|
+
var fs12, path12, SKEDYUL_SHIM_NAMESPACE, METADATA_STUB_NAMESPACE;
|
|
447
|
+
var init_transpileConfigMetadata = __esm({
|
|
448
|
+
"src/config/transpileConfigMetadata.ts"() {
|
|
449
|
+
"use strict";
|
|
450
|
+
fs12 = __toESM(require("fs"));
|
|
451
|
+
path12 = __toESM(require("path"));
|
|
452
|
+
SKEDYUL_SHIM_NAMESPACE = "skedyul-shim";
|
|
453
|
+
METADATA_STUB_NAMESPACE = "metadata-stub";
|
|
454
|
+
}
|
|
455
|
+
});
|
|
456
|
+
|
|
367
457
|
// src/cli/commands/invoke.ts
|
|
368
458
|
var z2 = __toESM(require("zod"));
|
|
369
459
|
var fs5 = __toESM(require("fs"));
|
|
@@ -649,7 +739,7 @@ function setNgrokAuthtoken(authtoken) {
|
|
|
649
739
|
saveConfig(config);
|
|
650
740
|
}
|
|
651
741
|
async function startOAuthCallback(serverUrl) {
|
|
652
|
-
return new Promise((
|
|
742
|
+
return new Promise((resolve16, reject) => {
|
|
653
743
|
let timeoutId = null;
|
|
654
744
|
const cleanup = () => {
|
|
655
745
|
if (timeoutId) {
|
|
@@ -711,7 +801,7 @@ async function startOAuthCallback(serverUrl) {
|
|
|
711
801
|
`);
|
|
712
802
|
cleanup();
|
|
713
803
|
server2.close();
|
|
714
|
-
|
|
804
|
+
resolve16({
|
|
715
805
|
token,
|
|
716
806
|
userId,
|
|
717
807
|
username,
|
|
@@ -765,10 +855,10 @@ async function openBrowser(url) {
|
|
|
765
855
|
} else {
|
|
766
856
|
command = `xdg-open "${url}"`;
|
|
767
857
|
}
|
|
768
|
-
return new Promise((
|
|
858
|
+
return new Promise((resolve16, reject) => {
|
|
769
859
|
exec(command, (error) => {
|
|
770
860
|
if (error) reject(error);
|
|
771
|
-
else
|
|
861
|
+
else resolve16();
|
|
772
862
|
});
|
|
773
863
|
});
|
|
774
864
|
}
|
|
@@ -2797,13 +2887,13 @@ function mergeRuntimeEnv() {
|
|
|
2797
2887
|
|
|
2798
2888
|
// src/server/utils/http.ts
|
|
2799
2889
|
function readRawRequestBody(req) {
|
|
2800
|
-
return new Promise((
|
|
2890
|
+
return new Promise((resolve16, reject) => {
|
|
2801
2891
|
let body = "";
|
|
2802
2892
|
req.on("data", (chunk) => {
|
|
2803
2893
|
body += chunk.toString();
|
|
2804
2894
|
});
|
|
2805
2895
|
req.on("end", () => {
|
|
2806
|
-
|
|
2896
|
+
resolve16(body);
|
|
2807
2897
|
});
|
|
2808
2898
|
req.on("error", reject);
|
|
2809
2899
|
});
|
|
@@ -3303,7 +3393,7 @@ function printStartupLog(config, tools, port) {
|
|
|
3303
3393
|
|
|
3304
3394
|
// src/server/route-handlers/adapters.ts
|
|
3305
3395
|
function fromLambdaEvent(event2) {
|
|
3306
|
-
const
|
|
3396
|
+
const path25 = event2.path || event2.rawPath || "/";
|
|
3307
3397
|
const method = event2.httpMethod || event2.requestContext?.http?.method || "POST";
|
|
3308
3398
|
const forwardedProto = event2.headers?.["x-forwarded-proto"] ?? event2.headers?.["X-Forwarded-Proto"];
|
|
3309
3399
|
const protocol = forwardedProto ?? "https";
|
|
@@ -3311,9 +3401,9 @@ function fromLambdaEvent(event2) {
|
|
|
3311
3401
|
const queryString = event2.queryStringParameters ? "?" + new URLSearchParams(
|
|
3312
3402
|
event2.queryStringParameters
|
|
3313
3403
|
).toString() : "";
|
|
3314
|
-
const url = `${protocol}://${host}${
|
|
3404
|
+
const url = `${protocol}://${host}${path25}${queryString}`;
|
|
3315
3405
|
return {
|
|
3316
|
-
path:
|
|
3406
|
+
path: path25,
|
|
3317
3407
|
method,
|
|
3318
3408
|
headers: event2.headers,
|
|
3319
3409
|
query: event2.queryStringParameters ?? {},
|
|
@@ -3863,7 +3953,7 @@ async function handleOAuthCallback(parsedBody, hooks) {
|
|
|
3863
3953
|
}
|
|
3864
3954
|
|
|
3865
3955
|
// src/server/handlers/webhook-handler.ts
|
|
3866
|
-
function parseWebhookRequest(parsedBody, method, url,
|
|
3956
|
+
function parseWebhookRequest(parsedBody, method, url, path25, headers, query, rawBody, appIdHeader, appVersionIdHeader) {
|
|
3867
3957
|
const isEnvelope = typeof parsedBody === "object" && parsedBody !== null && "env" in parsedBody && "request" in parsedBody && "context" in parsedBody;
|
|
3868
3958
|
if (isEnvelope) {
|
|
3869
3959
|
const envelope = parsedBody;
|
|
@@ -3917,7 +4007,7 @@ function parseWebhookRequest(parsedBody, method, url, path24, headers, query, ra
|
|
|
3917
4007
|
const webhookRequest = {
|
|
3918
4008
|
method,
|
|
3919
4009
|
url,
|
|
3920
|
-
path:
|
|
4010
|
+
path: path25,
|
|
3921
4011
|
headers,
|
|
3922
4012
|
query,
|
|
3923
4013
|
body: parsedBody,
|
|
@@ -4366,9 +4456,9 @@ async function handleMcpBatchRoute(req, ctx) {
|
|
|
4366
4456
|
}
|
|
4367
4457
|
const perCallTimeoutMs = deadline ? Math.min(deadline, 25e3) : 25e3;
|
|
4368
4458
|
const executeWithTimeout = async (call, timeoutMs) => {
|
|
4369
|
-
return new Promise(async (
|
|
4459
|
+
return new Promise(async (resolve16) => {
|
|
4370
4460
|
const timeoutHandle = setTimeout(() => {
|
|
4371
|
-
|
|
4461
|
+
resolve16({
|
|
4372
4462
|
id: call.id,
|
|
4373
4463
|
success: false,
|
|
4374
4464
|
error: "Timeout",
|
|
@@ -4381,7 +4471,7 @@ async function handleMcpBatchRoute(req, ctx) {
|
|
|
4381
4471
|
const found = findToolInRegistry(ctx.registry, toolName);
|
|
4382
4472
|
if (!found) {
|
|
4383
4473
|
clearTimeout(timeoutHandle);
|
|
4384
|
-
|
|
4474
|
+
resolve16({
|
|
4385
4475
|
id: call.id,
|
|
4386
4476
|
success: false,
|
|
4387
4477
|
error: `Tool "${toolName}" not found`
|
|
@@ -4399,13 +4489,13 @@ async function handleMcpBatchRoute(req, ctx) {
|
|
|
4399
4489
|
clearTimeout(timeoutHandle);
|
|
4400
4490
|
const isFailure = "success" in toolResult && toolResult.success === false || "error" in toolResult && toolResult.error != null;
|
|
4401
4491
|
if (isFailure) {
|
|
4402
|
-
|
|
4492
|
+
resolve16({
|
|
4403
4493
|
id: call.id,
|
|
4404
4494
|
success: false,
|
|
4405
4495
|
error: "error" in toolResult && toolResult.error ? typeof toolResult.error === "string" ? toolResult.error : JSON.stringify(toolResult.error) : "Tool execution failed"
|
|
4406
4496
|
});
|
|
4407
4497
|
} else {
|
|
4408
|
-
|
|
4498
|
+
resolve16({
|
|
4409
4499
|
id: call.id,
|
|
4410
4500
|
success: true,
|
|
4411
4501
|
result: "output" in toolResult ? toolResult.output : toolResult
|
|
@@ -4413,7 +4503,7 @@ async function handleMcpBatchRoute(req, ctx) {
|
|
|
4413
4503
|
}
|
|
4414
4504
|
} catch (err) {
|
|
4415
4505
|
clearTimeout(timeoutHandle);
|
|
4416
|
-
|
|
4506
|
+
resolve16({
|
|
4417
4507
|
id: call.id,
|
|
4418
4508
|
success: false,
|
|
4419
4509
|
error: err instanceof Error ? err.message : String(err)
|
|
@@ -4599,21 +4689,21 @@ function createDedicatedServerInstance(config, tools, callTool, state, mcpServer
|
|
|
4599
4689
|
return {
|
|
4600
4690
|
async listen(listenPort) {
|
|
4601
4691
|
const finalPort = listenPort ?? port;
|
|
4602
|
-
return new Promise((
|
|
4692
|
+
return new Promise((resolve16, reject) => {
|
|
4603
4693
|
httpServer.listen(finalPort, () => {
|
|
4604
4694
|
printStartupLog(config, tools, finalPort);
|
|
4605
|
-
|
|
4695
|
+
resolve16();
|
|
4606
4696
|
});
|
|
4607
4697
|
httpServer.once("error", reject);
|
|
4608
4698
|
});
|
|
4609
4699
|
},
|
|
4610
4700
|
async close() {
|
|
4611
|
-
return new Promise((
|
|
4701
|
+
return new Promise((resolve16, reject) => {
|
|
4612
4702
|
const closable = httpServer;
|
|
4613
4703
|
closable.closeAllConnections?.();
|
|
4614
4704
|
httpServer.close((err) => {
|
|
4615
4705
|
if (err) reject(err);
|
|
4616
|
-
else
|
|
4706
|
+
else resolve16();
|
|
4617
4707
|
});
|
|
4618
4708
|
});
|
|
4619
4709
|
},
|
|
@@ -5010,11 +5100,11 @@ async function promptForMigrationApproval(impacts) {
|
|
|
5010
5100
|
console.log("");
|
|
5011
5101
|
console.log("These changes cannot be undone. Data will be permanently deleted.");
|
|
5012
5102
|
console.log("");
|
|
5013
|
-
return new Promise((
|
|
5103
|
+
return new Promise((resolve16) => {
|
|
5014
5104
|
rl.question("Do you want to proceed? (yes/no): ", (answer) => {
|
|
5015
5105
|
rl.close();
|
|
5016
5106
|
const normalized = answer.toLowerCase().trim();
|
|
5017
|
-
|
|
5107
|
+
resolve16(normalized === "yes" || normalized === "y");
|
|
5018
5108
|
});
|
|
5019
5109
|
});
|
|
5020
5110
|
}
|
|
@@ -5067,7 +5157,7 @@ async function waitForMigrationCompletion(serverUrl, token, migrationId, timeout
|
|
|
5067
5157
|
);
|
|
5068
5158
|
} catch {
|
|
5069
5159
|
}
|
|
5070
|
-
await new Promise((
|
|
5160
|
+
await new Promise((resolve16) => setTimeout(resolve16, pollInterval));
|
|
5071
5161
|
}
|
|
5072
5162
|
process.stdout.write("\n");
|
|
5073
5163
|
return { completed: false, timedOut: true, denied: false };
|
|
@@ -5221,7 +5311,7 @@ async function promptInput(question, hidden = false) {
|
|
|
5221
5311
|
input: process.stdin,
|
|
5222
5312
|
output: process.stdout
|
|
5223
5313
|
});
|
|
5224
|
-
return new Promise((
|
|
5314
|
+
return new Promise((resolve16) => {
|
|
5225
5315
|
if (hidden) {
|
|
5226
5316
|
process.stdout.write(question);
|
|
5227
5317
|
let input = "";
|
|
@@ -5236,7 +5326,7 @@ async function promptInput(question, hidden = false) {
|
|
|
5236
5326
|
if (stdin.setRawMode) stdin.setRawMode(wasRaw ?? false);
|
|
5237
5327
|
process.stdout.write("\n");
|
|
5238
5328
|
rl.close();
|
|
5239
|
-
|
|
5329
|
+
resolve16(input);
|
|
5240
5330
|
} else if (char === "") {
|
|
5241
5331
|
process.exit(0);
|
|
5242
5332
|
} else if (char === "\x7F" || char === "\b") {
|
|
@@ -5251,7 +5341,7 @@ async function promptInput(question, hidden = false) {
|
|
|
5251
5341
|
} else {
|
|
5252
5342
|
rl.question(question, (answer) => {
|
|
5253
5343
|
rl.close();
|
|
5254
|
-
|
|
5344
|
+
resolve16(answer.trim());
|
|
5255
5345
|
});
|
|
5256
5346
|
}
|
|
5257
5347
|
});
|
|
@@ -5412,12 +5502,12 @@ var HEARTBEAT_INTERVAL_MS = 30 * 1e3;
|
|
|
5412
5502
|
var DEFAULT_PORT = 6e4;
|
|
5413
5503
|
var MAX_PORT_ATTEMPTS = 100;
|
|
5414
5504
|
async function isPortAvailable(port) {
|
|
5415
|
-
return new Promise((
|
|
5505
|
+
return new Promise((resolve16) => {
|
|
5416
5506
|
const server2 = net.createServer();
|
|
5417
|
-
server2.once("error", () =>
|
|
5507
|
+
server2.once("error", () => resolve16(false));
|
|
5418
5508
|
server2.once("listening", () => {
|
|
5419
5509
|
server2.close();
|
|
5420
|
-
|
|
5510
|
+
resolve16(true);
|
|
5421
5511
|
});
|
|
5422
5512
|
server2.listen(port, "127.0.0.1");
|
|
5423
5513
|
});
|
|
@@ -5867,109 +5957,14 @@ Press Ctrl+C to stop`);
|
|
|
5867
5957
|
}
|
|
5868
5958
|
|
|
5869
5959
|
// src/cli/commands/validate.ts
|
|
5870
|
-
var
|
|
5871
|
-
var
|
|
5960
|
+
var fs14 = __toESM(require("fs"));
|
|
5961
|
+
var path14 = __toESM(require("path"));
|
|
5872
5962
|
init_utils();
|
|
5873
5963
|
|
|
5874
|
-
// src/config/loader.ts
|
|
5964
|
+
// src/config/schema-loader.ts
|
|
5875
5965
|
var fs10 = __toESM(require("fs"));
|
|
5876
5966
|
var path10 = __toESM(require("path"));
|
|
5877
5967
|
var os2 = __toESM(require("os"));
|
|
5878
|
-
var CONFIG_FILE_NAMES = [
|
|
5879
|
-
"skedyul.config.ts",
|
|
5880
|
-
"skedyul.config.js",
|
|
5881
|
-
"skedyul.config.mjs",
|
|
5882
|
-
"skedyul.config.cjs"
|
|
5883
|
-
];
|
|
5884
|
-
async function transpileTypeScript(filePath) {
|
|
5885
|
-
const content = fs10.readFileSync(filePath, "utf-8");
|
|
5886
|
-
const configDir = path10.dirname(path10.resolve(filePath));
|
|
5887
|
-
let transpiled = content.replace(/import\s+type\s+\{[^}]+\}\s+from\s+['"][^'"]+['"]\s*;?\n?/g, "").replace(/import\s+\{\s*defineConfig\s*\}\s+from\s+['"]skedyul['"]\s*;?\n?/g, "").replace(/:\s*SkedyulConfig/g, "").replace(/export\s+default\s+/, "module.exports = ").replace(/defineConfig\s*\(\s*\{/, "{").replace(/\}\s*\)\s*;?\s*$/, "}");
|
|
5888
|
-
transpiled = transpiled.replace(
|
|
5889
|
-
/import\s+(\w+)\s+from\s+['"](\.[^'"]+)['"]\s*(?:with\s*\{[^}]*\})?/g,
|
|
5890
|
-
(_match, varName, relativePath) => {
|
|
5891
|
-
const absolutePath = path10.resolve(configDir, relativePath);
|
|
5892
|
-
return `const ${varName} = require('${absolutePath.replace(/\\/g, "/")}')`;
|
|
5893
|
-
}
|
|
5894
|
-
);
|
|
5895
|
-
transpiled = transpiled.replace(
|
|
5896
|
-
/import\s+\{\s*([^}]+)\s*\}\s+from\s+['"](\.[^'"]+)['"]\s*;?\n?/g,
|
|
5897
|
-
(_match, namedImports, relativePath) => {
|
|
5898
|
-
const absolutePath = path10.resolve(configDir, relativePath);
|
|
5899
|
-
return `const { ${namedImports.trim()} } = require('${absolutePath.replace(/\\/g, "/")}')
|
|
5900
|
-
`;
|
|
5901
|
-
}
|
|
5902
|
-
);
|
|
5903
|
-
transpiled = transpiled.replace(/import\s*\(\s*['"][^'"]+['"]\s*\)/g, "null");
|
|
5904
|
-
return transpiled;
|
|
5905
|
-
}
|
|
5906
|
-
async function loadConfig(configPath) {
|
|
5907
|
-
const absolutePath = path10.resolve(configPath);
|
|
5908
|
-
if (!fs10.existsSync(absolutePath)) {
|
|
5909
|
-
throw new Error(`Config file not found: ${absolutePath}`);
|
|
5910
|
-
}
|
|
5911
|
-
const isTypeScript = absolutePath.endsWith(".ts");
|
|
5912
|
-
try {
|
|
5913
|
-
if (isTypeScript) {
|
|
5914
|
-
try {
|
|
5915
|
-
const transpiled = await transpileTypeScript(absolutePath);
|
|
5916
|
-
const tempFile = path10.join(os2.tmpdir(), `skedyul-config-${Date.now()}.cjs`);
|
|
5917
|
-
fs10.writeFileSync(tempFile, transpiled);
|
|
5918
|
-
try {
|
|
5919
|
-
const module3 = require(tempFile);
|
|
5920
|
-
const config2 = module3.default || module3;
|
|
5921
|
-
if (!config2 || typeof config2 !== "object") {
|
|
5922
|
-
throw new Error("Config file must export a configuration object");
|
|
5923
|
-
}
|
|
5924
|
-
if (!config2.name || typeof config2.name !== "string") {
|
|
5925
|
-
throw new Error('Config must have a "name" property');
|
|
5926
|
-
}
|
|
5927
|
-
return config2;
|
|
5928
|
-
} finally {
|
|
5929
|
-
try {
|
|
5930
|
-
fs10.unlinkSync(tempFile);
|
|
5931
|
-
} catch {
|
|
5932
|
-
}
|
|
5933
|
-
}
|
|
5934
|
-
} catch (transpileError) {
|
|
5935
|
-
throw new Error(
|
|
5936
|
-
`Cannot load TypeScript config metadata from ${absolutePath}: ${transpileError instanceof Error ? transpileError.message : String(transpileError)}`
|
|
5937
|
-
);
|
|
5938
|
-
}
|
|
5939
|
-
}
|
|
5940
|
-
const module2 = await import(
|
|
5941
|
-
/* webpackIgnore: true */
|
|
5942
|
-
absolutePath
|
|
5943
|
-
);
|
|
5944
|
-
const config = module2.default || module2;
|
|
5945
|
-
if (!config || typeof config !== "object") {
|
|
5946
|
-
throw new Error("Config file must export a configuration object");
|
|
5947
|
-
}
|
|
5948
|
-
if (!config.name || typeof config.name !== "string") {
|
|
5949
|
-
throw new Error('Config must have a "name" property');
|
|
5950
|
-
}
|
|
5951
|
-
return config;
|
|
5952
|
-
} catch (error) {
|
|
5953
|
-
throw new Error(
|
|
5954
|
-
`Failed to load config from ${configPath}: ${error instanceof Error ? error.message : String(error)}`
|
|
5955
|
-
);
|
|
5956
|
-
}
|
|
5957
|
-
}
|
|
5958
|
-
function validateConfig(config) {
|
|
5959
|
-
const errors = [];
|
|
5960
|
-
if (!config.name) {
|
|
5961
|
-
errors.push("Missing required field: name");
|
|
5962
|
-
}
|
|
5963
|
-
if (config.computeLayer && !["serverless", "dedicated"].includes(config.computeLayer)) {
|
|
5964
|
-
errors.push(`Invalid computeLayer: ${config.computeLayer}. Must be 'serverless' or 'dedicated'`);
|
|
5965
|
-
}
|
|
5966
|
-
return { valid: errors.length === 0, errors };
|
|
5967
|
-
}
|
|
5968
|
-
|
|
5969
|
-
// src/config/schema-loader.ts
|
|
5970
|
-
var fs11 = __toESM(require("fs"));
|
|
5971
|
-
var path11 = __toESM(require("path"));
|
|
5972
|
-
var os3 = __toESM(require("os"));
|
|
5973
5968
|
|
|
5974
5969
|
// src/schemas/crm-schema.ts
|
|
5975
5970
|
var import_v42 = require("zod/v4");
|
|
@@ -6121,39 +6116,39 @@ function validateCRMSchema(data) {
|
|
|
6121
6116
|
|
|
6122
6117
|
// src/config/schema-loader.ts
|
|
6123
6118
|
async function transpileSchemaTypeScript(filePath) {
|
|
6124
|
-
const content =
|
|
6119
|
+
const content = fs10.readFileSync(filePath, "utf-8");
|
|
6125
6120
|
let transpiled = content.replace(/import\s+type\s+\{[^}]+\}\s+from\s+['"][^'"]+['"]\s*;?\n?/g, "").replace(/import\s+\{\s*defineSchema\s*\}\s+from\s+['"]skedyul['"]\s*;?\n?/g, "").replace(/:\s*CRMSchema/g, "").replace(/export\s+default\s+/, "module.exports = ").replace(/defineSchema\s*\(\s*\{/, "{").replace(/\}\s*\)\s*;?\s*$/, "}");
|
|
6126
6121
|
return transpiled;
|
|
6127
6122
|
}
|
|
6128
6123
|
async function loadSchema(schemaPath, options = {}) {
|
|
6129
6124
|
const { validate = true } = options;
|
|
6130
|
-
const absolutePath =
|
|
6131
|
-
if (!
|
|
6125
|
+
const absolutePath = path10.resolve(schemaPath);
|
|
6126
|
+
if (!fs10.existsSync(absolutePath)) {
|
|
6132
6127
|
throw new Error(`Schema file not found: ${absolutePath}`);
|
|
6133
6128
|
}
|
|
6134
6129
|
const isTypeScript = absolutePath.endsWith(".ts");
|
|
6135
6130
|
const isJson = absolutePath.endsWith(".json");
|
|
6136
6131
|
if (!isTypeScript && !isJson) {
|
|
6137
6132
|
throw new Error(
|
|
6138
|
-
`Unsupported schema file format: ${
|
|
6133
|
+
`Unsupported schema file format: ${path10.extname(absolutePath)}. Use .schema.ts or .schema.json`
|
|
6139
6134
|
);
|
|
6140
6135
|
}
|
|
6141
6136
|
let rawSchema;
|
|
6142
6137
|
try {
|
|
6143
6138
|
if (isJson) {
|
|
6144
|
-
const content =
|
|
6139
|
+
const content = fs10.readFileSync(absolutePath, "utf-8");
|
|
6145
6140
|
rawSchema = JSON.parse(content);
|
|
6146
6141
|
} else {
|
|
6147
6142
|
const transpiled = await transpileSchemaTypeScript(absolutePath);
|
|
6148
|
-
const tempDir =
|
|
6149
|
-
const tempFile =
|
|
6150
|
-
|
|
6143
|
+
const tempDir = os2.tmpdir();
|
|
6144
|
+
const tempFile = path10.join(tempDir, `skedyul-schema-${Date.now()}.cjs`);
|
|
6145
|
+
fs10.writeFileSync(tempFile, transpiled);
|
|
6151
6146
|
try {
|
|
6152
6147
|
const module2 = require(tempFile);
|
|
6153
6148
|
rawSchema = module2.default || module2;
|
|
6154
6149
|
} finally {
|
|
6155
6150
|
try {
|
|
6156
|
-
|
|
6151
|
+
fs10.unlinkSync(tempFile);
|
|
6157
6152
|
} catch {
|
|
6158
6153
|
}
|
|
6159
6154
|
}
|
|
@@ -6198,10 +6193,10 @@ export default defineSchema(${jsonContent})
|
|
|
6198
6193
|
`;
|
|
6199
6194
|
}
|
|
6200
6195
|
async function saveSchema(schema, outputPath, options = {}) {
|
|
6201
|
-
const absolutePath =
|
|
6196
|
+
const absolutePath = path10.resolve(outputPath);
|
|
6202
6197
|
const isTypeScript = absolutePath.endsWith(".ts");
|
|
6203
6198
|
const content = isTypeScript ? serializeSchemaToTypeScript(schema) : serializeSchemaToJson(schema, options);
|
|
6204
|
-
|
|
6199
|
+
fs10.writeFileSync(absolutePath, content, "utf-8");
|
|
6205
6200
|
}
|
|
6206
6201
|
var FIELD_TYPE_MAP = {
|
|
6207
6202
|
string: "STRING",
|
|
@@ -6348,8 +6343,8 @@ function transformToBackendSchema(schema) {
|
|
|
6348
6343
|
}
|
|
6349
6344
|
|
|
6350
6345
|
// src/config/resolver.ts
|
|
6351
|
-
var
|
|
6352
|
-
var
|
|
6346
|
+
var fs11 = __toESM(require("fs"));
|
|
6347
|
+
var path11 = __toESM(require("path"));
|
|
6353
6348
|
async function loadConfigModule(absolutePath) {
|
|
6354
6349
|
if (absolutePath.endsWith(".ts")) {
|
|
6355
6350
|
const altPaths = [
|
|
@@ -6358,7 +6353,7 @@ async function loadConfigModule(absolutePath) {
|
|
|
6358
6353
|
absolutePath.replace(".ts", ".js")
|
|
6359
6354
|
];
|
|
6360
6355
|
for (const altPath of altPaths) {
|
|
6361
|
-
if (
|
|
6356
|
+
if (fs11.existsSync(altPath)) {
|
|
6362
6357
|
return await import(altPath);
|
|
6363
6358
|
}
|
|
6364
6359
|
}
|
|
@@ -6375,7 +6370,7 @@ async function loadConfigModule(absolutePath) {
|
|
|
6375
6370
|
return await import(absolutePath);
|
|
6376
6371
|
}
|
|
6377
6372
|
async function loadAndResolveConfig(configPath) {
|
|
6378
|
-
const absolutePath =
|
|
6373
|
+
const absolutePath = path11.resolve(configPath);
|
|
6379
6374
|
const module2 = await loadConfigModule(absolutePath);
|
|
6380
6375
|
const config = module2.default;
|
|
6381
6376
|
if (!config || typeof config !== "object") {
|
|
@@ -6455,6 +6450,80 @@ function getAllEnvKeys(config) {
|
|
|
6455
6450
|
};
|
|
6456
6451
|
}
|
|
6457
6452
|
|
|
6453
|
+
// src/config/loader.ts
|
|
6454
|
+
var fs13 = __toESM(require("fs"));
|
|
6455
|
+
var path13 = __toESM(require("path"));
|
|
6456
|
+
var os3 = __toESM(require("os"));
|
|
6457
|
+
var CONFIG_FILE_NAMES = [
|
|
6458
|
+
"skedyul.config.ts",
|
|
6459
|
+
"skedyul.config.js",
|
|
6460
|
+
"skedyul.config.mjs",
|
|
6461
|
+
"skedyul.config.cjs"
|
|
6462
|
+
];
|
|
6463
|
+
async function loadConfig(configPath) {
|
|
6464
|
+
const absolutePath = path13.resolve(configPath);
|
|
6465
|
+
if (!fs13.existsSync(absolutePath)) {
|
|
6466
|
+
throw new Error(`Config file not found: ${absolutePath}`);
|
|
6467
|
+
}
|
|
6468
|
+
const isTypeScript = absolutePath.endsWith(".ts");
|
|
6469
|
+
try {
|
|
6470
|
+
if (isTypeScript) {
|
|
6471
|
+
try {
|
|
6472
|
+
const { transpileConfigMetadata: transpileConfigMetadata2 } = await Promise.resolve().then(() => (init_transpileConfigMetadata(), transpileConfigMetadata_exports));
|
|
6473
|
+
const transpiled = await transpileConfigMetadata2(absolutePath);
|
|
6474
|
+
const tempFile = path13.join(os3.tmpdir(), `skedyul-config-${Date.now()}.cjs`);
|
|
6475
|
+
fs13.writeFileSync(tempFile, transpiled);
|
|
6476
|
+
try {
|
|
6477
|
+
const module3 = require(tempFile);
|
|
6478
|
+
const config2 = module3.default || module3;
|
|
6479
|
+
if (!config2 || typeof config2 !== "object") {
|
|
6480
|
+
throw new Error("Config file must export a configuration object");
|
|
6481
|
+
}
|
|
6482
|
+
if (!config2.name || typeof config2.name !== "string") {
|
|
6483
|
+
throw new Error('Config must have a "name" property');
|
|
6484
|
+
}
|
|
6485
|
+
return config2;
|
|
6486
|
+
} finally {
|
|
6487
|
+
try {
|
|
6488
|
+
fs13.unlinkSync(tempFile);
|
|
6489
|
+
} catch {
|
|
6490
|
+
}
|
|
6491
|
+
}
|
|
6492
|
+
} catch (transpileError) {
|
|
6493
|
+
throw new Error(
|
|
6494
|
+
`Cannot load TypeScript config metadata from ${absolutePath}: ${transpileError instanceof Error ? transpileError.message : String(transpileError)}`
|
|
6495
|
+
);
|
|
6496
|
+
}
|
|
6497
|
+
}
|
|
6498
|
+
const module2 = await import(
|
|
6499
|
+
/* webpackIgnore: true */
|
|
6500
|
+
absolutePath
|
|
6501
|
+
);
|
|
6502
|
+
const config = module2.default || module2;
|
|
6503
|
+
if (!config || typeof config !== "object") {
|
|
6504
|
+
throw new Error("Config file must export a configuration object");
|
|
6505
|
+
}
|
|
6506
|
+
if (!config.name || typeof config.name !== "string") {
|
|
6507
|
+
throw new Error('Config must have a "name" property');
|
|
6508
|
+
}
|
|
6509
|
+
return config;
|
|
6510
|
+
} catch (error) {
|
|
6511
|
+
throw new Error(
|
|
6512
|
+
`Failed to load config from ${configPath}: ${error instanceof Error ? error.message : String(error)}`
|
|
6513
|
+
);
|
|
6514
|
+
}
|
|
6515
|
+
}
|
|
6516
|
+
function validateConfig(config) {
|
|
6517
|
+
const errors = [];
|
|
6518
|
+
if (!config.name) {
|
|
6519
|
+
errors.push("Missing required field: name");
|
|
6520
|
+
}
|
|
6521
|
+
if (config.computeLayer && !["serverless", "dedicated"].includes(config.computeLayer)) {
|
|
6522
|
+
errors.push(`Invalid computeLayer: ${config.computeLayer}. Must be 'serverless' or 'dedicated'`);
|
|
6523
|
+
}
|
|
6524
|
+
return { valid: errors.length === 0, errors };
|
|
6525
|
+
}
|
|
6526
|
+
|
|
6458
6527
|
// src/cli/commands/validate.ts
|
|
6459
6528
|
function printHelp5() {
|
|
6460
6529
|
console.log(`
|
|
@@ -6482,8 +6551,8 @@ Examples:
|
|
|
6482
6551
|
}
|
|
6483
6552
|
function findConfigFile2(startDir) {
|
|
6484
6553
|
for (const fileName of CONFIG_FILE_NAMES) {
|
|
6485
|
-
const filePath =
|
|
6486
|
-
if (
|
|
6554
|
+
const filePath = path14.join(startDir, fileName);
|
|
6555
|
+
if (fs14.existsSync(filePath)) {
|
|
6487
6556
|
return filePath;
|
|
6488
6557
|
}
|
|
6489
6558
|
}
|
|
@@ -6517,9 +6586,9 @@ async function validateCommand(args2) {
|
|
|
6517
6586
|
}
|
|
6518
6587
|
configPath = foundConfig;
|
|
6519
6588
|
} else {
|
|
6520
|
-
configPath =
|
|
6589
|
+
configPath = path14.resolve(process.cwd(), configPath);
|
|
6521
6590
|
}
|
|
6522
|
-
if (!
|
|
6591
|
+
if (!fs14.existsSync(configPath)) {
|
|
6523
6592
|
const result2 = {
|
|
6524
6593
|
valid: false,
|
|
6525
6594
|
configPath,
|
|
@@ -6564,8 +6633,8 @@ async function validateCommand(args2) {
|
|
|
6564
6633
|
if (provision?.workflows) {
|
|
6565
6634
|
for (const workflow of provision.workflows) {
|
|
6566
6635
|
if (workflow.path) {
|
|
6567
|
-
const absoluteWorkflowPath =
|
|
6568
|
-
if (!
|
|
6636
|
+
const absoluteWorkflowPath = path14.resolve(path14.dirname(configPath), workflow.path);
|
|
6637
|
+
if (!fs14.existsSync(absoluteWorkflowPath)) {
|
|
6569
6638
|
warnings.push(`Workflow file not found: ${workflow.path}`);
|
|
6570
6639
|
}
|
|
6571
6640
|
}
|
|
@@ -6660,8 +6729,8 @@ async function validateCommand(args2) {
|
|
|
6660
6729
|
}
|
|
6661
6730
|
|
|
6662
6731
|
// src/cli/commands/diff.ts
|
|
6663
|
-
var
|
|
6664
|
-
var
|
|
6732
|
+
var fs15 = __toESM(require("fs"));
|
|
6733
|
+
var path15 = __toESM(require("path"));
|
|
6665
6734
|
init_utils();
|
|
6666
6735
|
function printHelp6() {
|
|
6667
6736
|
console.log(`
|
|
@@ -6694,8 +6763,8 @@ Examples:
|
|
|
6694
6763
|
}
|
|
6695
6764
|
function findConfigFile3(startDir) {
|
|
6696
6765
|
for (const fileName of CONFIG_FILE_NAMES) {
|
|
6697
|
-
const filePath =
|
|
6698
|
-
if (
|
|
6766
|
+
const filePath = path15.join(startDir, fileName);
|
|
6767
|
+
if (fs15.existsSync(filePath)) {
|
|
6699
6768
|
return filePath;
|
|
6700
6769
|
}
|
|
6701
6770
|
}
|
|
@@ -6751,9 +6820,9 @@ async function diffCommand(args2) {
|
|
|
6751
6820
|
}
|
|
6752
6821
|
configPath = foundConfig;
|
|
6753
6822
|
} else {
|
|
6754
|
-
configPath =
|
|
6823
|
+
configPath = path15.resolve(process.cwd(), configPath);
|
|
6755
6824
|
}
|
|
6756
|
-
if (!
|
|
6825
|
+
if (!fs15.existsSync(configPath)) {
|
|
6757
6826
|
if (jsonOutput) {
|
|
6758
6827
|
console.log(JSON.stringify({ error: `Config file not found: ${configPath}` }));
|
|
6759
6828
|
} else {
|
|
@@ -6795,7 +6864,7 @@ async function diffCommand(args2) {
|
|
|
6795
6864
|
const registryPath = flags.registry || flags.r;
|
|
6796
6865
|
if (registryPath) {
|
|
6797
6866
|
try {
|
|
6798
|
-
const registry = await loadRegistry(
|
|
6867
|
+
const registry = await loadRegistry(path15.resolve(process.cwd(), registryPath));
|
|
6799
6868
|
const toolNames = Object.values(registry).map((t) => t.name);
|
|
6800
6869
|
toolsDiff = {
|
|
6801
6870
|
added: toolNames,
|
|
@@ -6868,8 +6937,8 @@ async function diffCommand(args2) {
|
|
|
6868
6937
|
}
|
|
6869
6938
|
|
|
6870
6939
|
// src/cli/commands/deploy.ts
|
|
6871
|
-
var
|
|
6872
|
-
var
|
|
6940
|
+
var fs16 = __toESM(require("fs"));
|
|
6941
|
+
var path16 = __toESM(require("path"));
|
|
6873
6942
|
var readline3 = __toESM(require("readline"));
|
|
6874
6943
|
init_utils();
|
|
6875
6944
|
function printHelp7() {
|
|
@@ -6905,8 +6974,8 @@ Examples:
|
|
|
6905
6974
|
}
|
|
6906
6975
|
function findConfigFile4(startDir) {
|
|
6907
6976
|
for (const fileName of CONFIG_FILE_NAMES) {
|
|
6908
|
-
const filePath =
|
|
6909
|
-
if (
|
|
6977
|
+
const filePath = path16.join(startDir, fileName);
|
|
6978
|
+
if (fs16.existsSync(filePath)) {
|
|
6910
6979
|
return filePath;
|
|
6911
6980
|
}
|
|
6912
6981
|
}
|
|
@@ -6931,11 +7000,11 @@ async function promptForApproval(impacts) {
|
|
|
6931
7000
|
console.log("");
|
|
6932
7001
|
console.log("These changes cannot be undone. Data will be permanently deleted.");
|
|
6933
7002
|
console.log("");
|
|
6934
|
-
return new Promise((
|
|
7003
|
+
return new Promise((resolve16) => {
|
|
6935
7004
|
rl.question("Do you want to proceed? (yes/no): ", (answer) => {
|
|
6936
7005
|
rl.close();
|
|
6937
7006
|
const normalized = answer.toLowerCase().trim();
|
|
6938
|
-
|
|
7007
|
+
resolve16(normalized === "yes" || normalized === "y");
|
|
6939
7008
|
});
|
|
6940
7009
|
});
|
|
6941
7010
|
}
|
|
@@ -6971,7 +7040,7 @@ async function waitForMigrationApproval(serverUrl, token, migrationId, timeoutMs
|
|
|
6971
7040
|
process.stdout.write(`\r Status: ${data.status} | Time remaining: ${remaining} minutes `);
|
|
6972
7041
|
} catch {
|
|
6973
7042
|
}
|
|
6974
|
-
await new Promise((
|
|
7043
|
+
await new Promise((resolve16) => setTimeout(resolve16, pollInterval));
|
|
6975
7044
|
}
|
|
6976
7045
|
return { approved: false, timedOut: true };
|
|
6977
7046
|
}
|
|
@@ -7020,9 +7089,9 @@ async function deployCommand(args2) {
|
|
|
7020
7089
|
}
|
|
7021
7090
|
configPath = foundConfig;
|
|
7022
7091
|
} else {
|
|
7023
|
-
configPath =
|
|
7092
|
+
configPath = path16.resolve(process.cwd(), configPath);
|
|
7024
7093
|
}
|
|
7025
|
-
if (!
|
|
7094
|
+
if (!fs16.existsSync(configPath)) {
|
|
7026
7095
|
if (jsonOutput) {
|
|
7027
7096
|
console.log(JSON.stringify({ error: `Config file not found: ${configPath}` }));
|
|
7028
7097
|
} else {
|
|
@@ -7339,8 +7408,8 @@ async function logoutCommand(args2) {
|
|
|
7339
7408
|
}
|
|
7340
7409
|
|
|
7341
7410
|
// src/cli/commands/auth/status.ts
|
|
7342
|
-
var
|
|
7343
|
-
var
|
|
7411
|
+
var fs17 = __toESM(require("fs"));
|
|
7412
|
+
var path17 = __toESM(require("path"));
|
|
7344
7413
|
init_utils();
|
|
7345
7414
|
function printHelp10() {
|
|
7346
7415
|
console.log(`
|
|
@@ -7414,17 +7483,17 @@ async function statusCommand(args2) {
|
|
|
7414
7483
|
console.log("");
|
|
7415
7484
|
console.log(" * = active profile");
|
|
7416
7485
|
}
|
|
7417
|
-
const linksDir =
|
|
7486
|
+
const linksDir = path17.join(process.cwd(), ".skedyul", "links");
|
|
7418
7487
|
console.log("");
|
|
7419
7488
|
console.log("LINKED WORKPLACES (this project)");
|
|
7420
7489
|
console.log("\u2500".repeat(60));
|
|
7421
|
-
if (
|
|
7422
|
-
const linkFiles =
|
|
7490
|
+
if (fs17.existsSync(linksDir)) {
|
|
7491
|
+
const linkFiles = fs17.readdirSync(linksDir).filter((f) => f.endsWith(".json"));
|
|
7423
7492
|
if (linkFiles.length > 0) {
|
|
7424
7493
|
for (const file2 of linkFiles) {
|
|
7425
7494
|
const subdomain = file2.replace(".json", "");
|
|
7426
7495
|
try {
|
|
7427
|
-
const content =
|
|
7496
|
+
const content = fs17.readFileSync(path17.join(linksDir, file2), "utf-8");
|
|
7428
7497
|
const link = JSON.parse(content);
|
|
7429
7498
|
console.log(` - ${subdomain} (${link.appHandle})`);
|
|
7430
7499
|
} catch {
|
|
@@ -7781,8 +7850,8 @@ EXAMPLES
|
|
|
7781
7850
|
}
|
|
7782
7851
|
|
|
7783
7852
|
// src/cli/commands/config-export.ts
|
|
7784
|
-
var
|
|
7785
|
-
var
|
|
7853
|
+
var fs18 = __toESM(require("fs"));
|
|
7854
|
+
var path18 = __toESM(require("path"));
|
|
7786
7855
|
function printHelp13() {
|
|
7787
7856
|
console.log(`
|
|
7788
7857
|
SKEDYUL CONFIG:EXPORT - Export resolved config to JSON
|
|
@@ -7828,8 +7897,8 @@ async function configExportCommand(args2) {
|
|
|
7828
7897
|
const cwd = process.cwd();
|
|
7829
7898
|
let configPath = null;
|
|
7830
7899
|
for (const name of CONFIG_FILE_NAMES) {
|
|
7831
|
-
const testPath =
|
|
7832
|
-
if (
|
|
7900
|
+
const testPath = path18.join(cwd, name);
|
|
7901
|
+
if (fs18.existsSync(testPath)) {
|
|
7833
7902
|
configPath = testPath;
|
|
7834
7903
|
break;
|
|
7835
7904
|
}
|
|
@@ -7839,16 +7908,16 @@ async function configExportCommand(args2) {
|
|
|
7839
7908
|
console.error("Make sure you are in the root of your integration project.");
|
|
7840
7909
|
process.exit(1);
|
|
7841
7910
|
}
|
|
7842
|
-
console.log(`Loading config from ${
|
|
7911
|
+
console.log(`Loading config from ${path18.basename(configPath)}...`);
|
|
7843
7912
|
try {
|
|
7844
7913
|
const resolvedConfig = await loadAndResolveConfig(configPath);
|
|
7845
7914
|
const serialized = serializeResolvedConfig(resolvedConfig);
|
|
7846
|
-
const outputDir =
|
|
7847
|
-
if (!
|
|
7848
|
-
|
|
7915
|
+
const outputDir = path18.dirname(path18.resolve(cwd, outputPath));
|
|
7916
|
+
if (!fs18.existsSync(outputDir)) {
|
|
7917
|
+
fs18.mkdirSync(outputDir, { recursive: true });
|
|
7849
7918
|
}
|
|
7850
|
-
const fullOutputPath =
|
|
7851
|
-
|
|
7919
|
+
const fullOutputPath = path18.resolve(cwd, outputPath);
|
|
7920
|
+
fs18.writeFileSync(fullOutputPath, JSON.stringify(serialized, null, 2), "utf-8");
|
|
7852
7921
|
console.log(``);
|
|
7853
7922
|
console.log(`Config exported successfully!`);
|
|
7854
7923
|
console.log(` Output: ${outputPath}`);
|
|
@@ -8049,7 +8118,7 @@ async function promptHidden(question) {
|
|
|
8049
8118
|
input: process.stdin,
|
|
8050
8119
|
output: process.stdout
|
|
8051
8120
|
});
|
|
8052
|
-
return new Promise((
|
|
8121
|
+
return new Promise((resolve16) => {
|
|
8053
8122
|
process.stdout.write(question);
|
|
8054
8123
|
let input = "";
|
|
8055
8124
|
const stdin = process.stdin;
|
|
@@ -8063,7 +8132,7 @@ async function promptHidden(question) {
|
|
|
8063
8132
|
if (stdin.setRawMode) stdin.setRawMode(wasRaw ?? false);
|
|
8064
8133
|
process.stdout.write("\n");
|
|
8065
8134
|
rl.close();
|
|
8066
|
-
|
|
8135
|
+
resolve16(input.trim());
|
|
8067
8136
|
} else if (char === "") {
|
|
8068
8137
|
process.exit(0);
|
|
8069
8138
|
} else if (char === "\x7F" || char === "\b") {
|
|
@@ -8093,17 +8162,17 @@ async function prompt(options) {
|
|
|
8093
8162
|
input: process.stdin,
|
|
8094
8163
|
output: process.stdout
|
|
8095
8164
|
});
|
|
8096
|
-
return new Promise((
|
|
8165
|
+
return new Promise((resolve16) => {
|
|
8097
8166
|
const displayMessage = defaultValue ? `${message} [${defaultValue}]: ` : `${message}: `;
|
|
8098
8167
|
rl.question(displayMessage, (answer) => {
|
|
8099
8168
|
rl.close();
|
|
8100
8169
|
const value = answer.trim() || defaultValue || "";
|
|
8101
8170
|
if (required && !value) {
|
|
8102
8171
|
console.error("Value is required.");
|
|
8103
|
-
|
|
8172
|
+
resolve16(prompt(options));
|
|
8104
8173
|
return;
|
|
8105
8174
|
}
|
|
8106
|
-
|
|
8175
|
+
resolve16(value);
|
|
8107
8176
|
});
|
|
8108
8177
|
});
|
|
8109
8178
|
}
|
|
@@ -8490,8 +8559,8 @@ async function handleCreateMany(modelHandle, flags) {
|
|
|
8490
8559
|
console.error("Usage: skedyul instances create-many <model> --file data.json --workplace <subdomain>");
|
|
8491
8560
|
process.exit(1);
|
|
8492
8561
|
}
|
|
8493
|
-
const
|
|
8494
|
-
const fileContent =
|
|
8562
|
+
const fs25 = await import("fs");
|
|
8563
|
+
const fileContent = fs25.readFileSync(filePath, "utf-8");
|
|
8495
8564
|
const items = JSON.parse(fileContent);
|
|
8496
8565
|
if (!Array.isArray(items)) {
|
|
8497
8566
|
console.error("Error: File must contain a JSON array of items");
|
|
@@ -8518,8 +8587,8 @@ async function handleUpsertMany(modelHandle, flags) {
|
|
|
8518
8587
|
console.error("Usage: skedyul instances upsert-many <model> --file data.json --match-field <field> --workplace <subdomain>");
|
|
8519
8588
|
process.exit(1);
|
|
8520
8589
|
}
|
|
8521
|
-
const
|
|
8522
|
-
const fileContent =
|
|
8590
|
+
const fs25 = await import("fs");
|
|
8591
|
+
const fileContent = fs25.readFileSync(filePath, "utf-8");
|
|
8523
8592
|
const items = JSON.parse(fileContent);
|
|
8524
8593
|
if (!Array.isArray(items)) {
|
|
8525
8594
|
console.error("Error: File must contain a JSON array of items");
|
|
@@ -8531,8 +8600,8 @@ async function handleUpsertMany(modelHandle, flags) {
|
|
|
8531
8600
|
|
|
8532
8601
|
// src/cli/commands/build.ts
|
|
8533
8602
|
var import_child_process = require("child_process");
|
|
8534
|
-
var
|
|
8535
|
-
var
|
|
8603
|
+
var fs19 = __toESM(require("fs"));
|
|
8604
|
+
var path19 = __toESM(require("path"));
|
|
8536
8605
|
function printBuildHelp() {
|
|
8537
8606
|
console.log(`
|
|
8538
8607
|
SKEDYUL BUILD - Build your integration
|
|
@@ -8601,8 +8670,8 @@ async function buildCommand(args2) {
|
|
|
8601
8670
|
const cwd = process.cwd();
|
|
8602
8671
|
let configPath = null;
|
|
8603
8672
|
for (const name of CONFIG_FILE_NAMES) {
|
|
8604
|
-
const testPath =
|
|
8605
|
-
if (
|
|
8673
|
+
const testPath = path19.join(cwd, name);
|
|
8674
|
+
if (fs19.existsSync(testPath)) {
|
|
8606
8675
|
configPath = testPath;
|
|
8607
8676
|
break;
|
|
8608
8677
|
}
|
|
@@ -8612,8 +8681,8 @@ async function buildCommand(args2) {
|
|
|
8612
8681
|
console.error("Make sure you are in the root of your integration project.");
|
|
8613
8682
|
process.exit(1);
|
|
8614
8683
|
}
|
|
8615
|
-
console.log(`Loading config from ${
|
|
8616
|
-
const tempConfigPath =
|
|
8684
|
+
console.log(`Loading config from ${path19.basename(configPath)}...`);
|
|
8685
|
+
const tempConfigPath = path19.join(cwd, ".skedyul-tsup.config.mjs");
|
|
8617
8686
|
let createdTempConfig = false;
|
|
8618
8687
|
try {
|
|
8619
8688
|
const config = await loadConfig(configPath);
|
|
@@ -8622,8 +8691,8 @@ async function buildCommand(args2) {
|
|
|
8622
8691
|
const baseExternals = ["skedyul", `skedyul/${computeLayer}`, "zod"];
|
|
8623
8692
|
const userExternals = config.build && "external" in config.build ? config.build.external ?? [] : [];
|
|
8624
8693
|
const allExternals = [...baseExternals, ...userExternals];
|
|
8625
|
-
const userTsupConfig =
|
|
8626
|
-
const hasUserConfig =
|
|
8694
|
+
const userTsupConfig = path19.join(cwd, "tsup.config.ts");
|
|
8695
|
+
const hasUserConfig = fs19.existsSync(userTsupConfig);
|
|
8627
8696
|
console.log(``);
|
|
8628
8697
|
console.log(`Building ${config.name ?? "integration"}...`);
|
|
8629
8698
|
console.log(` Compute layer: ${computeLayer}`);
|
|
@@ -8643,7 +8712,7 @@ async function buildCommand(args2) {
|
|
|
8643
8712
|
}
|
|
8644
8713
|
} else {
|
|
8645
8714
|
const tsupConfigContent = generateTsupConfig(format, allExternals);
|
|
8646
|
-
|
|
8715
|
+
fs19.writeFileSync(tempConfigPath, tsupConfigContent, "utf-8");
|
|
8647
8716
|
createdTempConfig = true;
|
|
8648
8717
|
tsupArgs = [
|
|
8649
8718
|
"tsup",
|
|
@@ -8661,14 +8730,14 @@ async function buildCommand(args2) {
|
|
|
8661
8730
|
});
|
|
8662
8731
|
tsup.on("error", (error) => {
|
|
8663
8732
|
console.error("Failed to start tsup:", error.message);
|
|
8664
|
-
if (createdTempConfig &&
|
|
8665
|
-
|
|
8733
|
+
if (createdTempConfig && fs19.existsSync(tempConfigPath)) {
|
|
8734
|
+
fs19.unlinkSync(tempConfigPath);
|
|
8666
8735
|
}
|
|
8667
8736
|
process.exit(1);
|
|
8668
8737
|
});
|
|
8669
8738
|
tsup.on("close", (code) => {
|
|
8670
|
-
if (createdTempConfig &&
|
|
8671
|
-
|
|
8739
|
+
if (createdTempConfig && fs19.existsSync(tempConfigPath)) {
|
|
8740
|
+
fs19.unlinkSync(tempConfigPath);
|
|
8672
8741
|
}
|
|
8673
8742
|
if (code === 0) {
|
|
8674
8743
|
console.log(``);
|
|
@@ -8677,8 +8746,8 @@ async function buildCommand(args2) {
|
|
|
8677
8746
|
process.exit(code ?? 0);
|
|
8678
8747
|
});
|
|
8679
8748
|
} catch (error) {
|
|
8680
|
-
if (createdTempConfig &&
|
|
8681
|
-
|
|
8749
|
+
if (createdTempConfig && fs19.existsSync(tempConfigPath)) {
|
|
8750
|
+
fs19.unlinkSync(tempConfigPath);
|
|
8682
8751
|
}
|
|
8683
8752
|
console.error(
|
|
8684
8753
|
"Error loading config:",
|
|
@@ -8691,8 +8760,8 @@ async function buildCommand(args2) {
|
|
|
8691
8760
|
// src/cli/commands/smoke-test.ts
|
|
8692
8761
|
var import_child_process2 = require("child_process");
|
|
8693
8762
|
var http3 = __toESM(require("http"));
|
|
8694
|
-
var
|
|
8695
|
-
var
|
|
8763
|
+
var fs20 = __toESM(require("fs"));
|
|
8764
|
+
var path20 = __toESM(require("path"));
|
|
8696
8765
|
var SMOKE_TEST_PORT = 3456;
|
|
8697
8766
|
var HEALTH_CHECK_INTERVAL_MS = 500;
|
|
8698
8767
|
var HEALTH_CHECK_MAX_RETRIES = 30;
|
|
@@ -8723,13 +8792,13 @@ WHAT IT DOES
|
|
|
8723
8792
|
6. Exits with code 0 (success) or 1 (failure)
|
|
8724
8793
|
`);
|
|
8725
8794
|
}
|
|
8726
|
-
function makeRequest(port,
|
|
8727
|
-
return new Promise((
|
|
8795
|
+
function makeRequest(port, path25, method, body) {
|
|
8796
|
+
return new Promise((resolve16, reject) => {
|
|
8728
8797
|
const postData = body ? JSON.stringify(body) : void 0;
|
|
8729
8798
|
const options = {
|
|
8730
8799
|
hostname: "localhost",
|
|
8731
8800
|
port,
|
|
8732
|
-
path:
|
|
8801
|
+
path: path25,
|
|
8733
8802
|
method,
|
|
8734
8803
|
headers: {
|
|
8735
8804
|
"Content-Type": "application/json",
|
|
@@ -8745,9 +8814,9 @@ function makeRequest(port, path24, method, body) {
|
|
|
8745
8814
|
res.on("end", () => {
|
|
8746
8815
|
try {
|
|
8747
8816
|
const parsed = data ? JSON.parse(data) : {};
|
|
8748
|
-
|
|
8817
|
+
resolve16({ status: res.statusCode ?? 0, body: parsed });
|
|
8749
8818
|
} catch {
|
|
8750
|
-
|
|
8819
|
+
resolve16({ status: res.statusCode ?? 0, body: data });
|
|
8751
8820
|
}
|
|
8752
8821
|
});
|
|
8753
8822
|
});
|
|
@@ -8767,7 +8836,7 @@ async function waitForHealth(port) {
|
|
|
8767
8836
|
}
|
|
8768
8837
|
} catch {
|
|
8769
8838
|
}
|
|
8770
|
-
await new Promise((
|
|
8839
|
+
await new Promise((resolve16) => setTimeout(resolve16, HEALTH_CHECK_INTERVAL_MS));
|
|
8771
8840
|
}
|
|
8772
8841
|
return false;
|
|
8773
8842
|
}
|
|
@@ -8817,8 +8886,8 @@ async function smokeTestCommand(args2) {
|
|
|
8817
8886
|
const cwd = process.cwd();
|
|
8818
8887
|
let configPath = null;
|
|
8819
8888
|
for (const name of CONFIG_FILE_NAMES) {
|
|
8820
|
-
const testPath =
|
|
8821
|
-
if (
|
|
8889
|
+
const testPath = path20.join(cwd, name);
|
|
8890
|
+
if (fs20.existsSync(testPath)) {
|
|
8822
8891
|
configPath = testPath;
|
|
8823
8892
|
break;
|
|
8824
8893
|
}
|
|
@@ -8834,10 +8903,10 @@ async function smokeTestCommand(args2) {
|
|
|
8834
8903
|
}
|
|
8835
8904
|
const serverExt = computeLayer === "serverless" ? "mjs" : "js";
|
|
8836
8905
|
let serverPath = `dist/server/mcp_server.${serverExt}`;
|
|
8837
|
-
if (!
|
|
8906
|
+
if (!fs20.existsSync(serverPath)) {
|
|
8838
8907
|
const fallbackExt = serverExt === "mjs" ? "js" : "mjs";
|
|
8839
8908
|
const fallbackPath = `dist/server/mcp_server.${fallbackExt}`;
|
|
8840
|
-
if (
|
|
8909
|
+
if (fs20.existsSync(fallbackPath)) {
|
|
8841
8910
|
console.warn(`[SmokeTest] Warning: Expected ${serverPath} but found ${fallbackPath}`);
|
|
8842
8911
|
console.warn(`[SmokeTest] Using ${fallbackPath} instead`);
|
|
8843
8912
|
serverPath = fallbackPath;
|
|
@@ -8898,7 +8967,7 @@ async function smokeTestCommand(args2) {
|
|
|
8898
8967
|
server2.on("error", (err) => {
|
|
8899
8968
|
console.error(`[SmokeTest] Failed to spawn server: ${err.message}`);
|
|
8900
8969
|
});
|
|
8901
|
-
await new Promise((
|
|
8970
|
+
await new Promise((resolve16) => setTimeout(resolve16, 1e3));
|
|
8902
8971
|
if (serverExited) {
|
|
8903
8972
|
console.error("[SmokeTest] FAILED: Server crashed during startup");
|
|
8904
8973
|
console.error(`[SmokeTest] Exit code: ${serverExitCode}`);
|
|
@@ -9047,11 +9116,11 @@ async function promptForApproval2(impacts) {
|
|
|
9047
9116
|
console.log("");
|
|
9048
9117
|
console.log("These changes cannot be undone. Data will be permanently deleted.");
|
|
9049
9118
|
console.log("");
|
|
9050
|
-
return new Promise((
|
|
9119
|
+
return new Promise((resolve16) => {
|
|
9051
9120
|
rl.question("Do you want to proceed? (yes/no): ", (answer) => {
|
|
9052
9121
|
rl.close();
|
|
9053
9122
|
const normalized = answer.toLowerCase().trim();
|
|
9054
|
-
|
|
9123
|
+
resolve16(normalized === "yes" || normalized === "y");
|
|
9055
9124
|
});
|
|
9056
9125
|
});
|
|
9057
9126
|
}
|
|
@@ -9355,8 +9424,8 @@ async function crmCommand(args2) {
|
|
|
9355
9424
|
}
|
|
9356
9425
|
|
|
9357
9426
|
// src/cli/commands/agents.ts
|
|
9358
|
-
var
|
|
9359
|
-
var
|
|
9427
|
+
var fs21 = __toESM(require("fs"));
|
|
9428
|
+
var path21 = __toESM(require("path"));
|
|
9360
9429
|
var import_yaml = require("yaml");
|
|
9361
9430
|
init_utils();
|
|
9362
9431
|
|
|
@@ -10417,11 +10486,11 @@ function isAgentV3(agent) {
|
|
|
10417
10486
|
return "handle" in obj && !("stages" in obj) && !("agents" in obj);
|
|
10418
10487
|
}
|
|
10419
10488
|
async function loadAgentFile(filePath) {
|
|
10420
|
-
const absolutePath =
|
|
10421
|
-
if (!
|
|
10489
|
+
const absolutePath = path21.resolve(filePath);
|
|
10490
|
+
if (!fs21.existsSync(absolutePath)) {
|
|
10422
10491
|
throw new Error(`Agent file not found: ${absolutePath}`);
|
|
10423
10492
|
}
|
|
10424
|
-
const content =
|
|
10493
|
+
const content = fs21.readFileSync(absolutePath, "utf-8");
|
|
10425
10494
|
const isJson = absolutePath.endsWith(".json");
|
|
10426
10495
|
const isYaml = absolutePath.endsWith(".yml") || absolutePath.endsWith(".yaml");
|
|
10427
10496
|
let rawAgent;
|
|
@@ -10431,7 +10500,7 @@ async function loadAgentFile(filePath) {
|
|
|
10431
10500
|
rawAgent = (0, import_yaml.parse)(content);
|
|
10432
10501
|
} else {
|
|
10433
10502
|
throw new Error(
|
|
10434
|
-
`Unsupported agent file format: ${
|
|
10503
|
+
`Unsupported agent file format: ${path21.extname(absolutePath)}. Use .agent.yml or .agent.json`
|
|
10435
10504
|
);
|
|
10436
10505
|
}
|
|
10437
10506
|
const detectedV3 = isAgentV3(rawAgent);
|
|
@@ -10441,8 +10510,8 @@ async function loadAgentFile(filePath) {
|
|
|
10441
10510
|
return { agent: v3Result.data, content, isV3: true };
|
|
10442
10511
|
}
|
|
10443
10512
|
const errorMessages = v3Result.error.issues.map((e) => {
|
|
10444
|
-
const
|
|
10445
|
-
return ` - ${
|
|
10513
|
+
const path25 = e.path.length > 0 ? e.path.join(".") : "(root)";
|
|
10514
|
+
return ` - ${path25}: ${e.message}`;
|
|
10446
10515
|
}).join("\n");
|
|
10447
10516
|
throw new Error(`Agent v3 validation failed:
|
|
10448
10517
|
${errorMessages}`);
|
|
@@ -10454,8 +10523,8 @@ ${errorMessages}`);
|
|
|
10454
10523
|
const v3Result = validateAgentYAMLV3(rawAgent);
|
|
10455
10524
|
if (!v3Result.success) {
|
|
10456
10525
|
const errorMessages2 = v3Result.error.issues.map((e) => {
|
|
10457
|
-
const
|
|
10458
|
-
return ` - ${
|
|
10526
|
+
const path25 = e.path.length > 0 ? e.path.join(".") : "(root)";
|
|
10527
|
+
return ` - ${path25}: ${e.message}`;
|
|
10459
10528
|
}).join("\n");
|
|
10460
10529
|
throw new Error(`Agent v3 validation failed:
|
|
10461
10530
|
${errorMessages2}`);
|
|
@@ -11151,14 +11220,14 @@ async function* parseSSEStream(response, debug2 = false) {
|
|
|
11151
11220
|
}
|
|
11152
11221
|
|
|
11153
11222
|
// src/cli/utils/mock-context.ts
|
|
11154
|
-
var
|
|
11155
|
-
var
|
|
11223
|
+
var fs22 = __toESM(require("fs"));
|
|
11224
|
+
var path22 = __toESM(require("path"));
|
|
11156
11225
|
function loadContext(filePath) {
|
|
11157
|
-
const absolutePath =
|
|
11158
|
-
if (!
|
|
11226
|
+
const absolutePath = path22.resolve(filePath);
|
|
11227
|
+
if (!fs22.existsSync(absolutePath)) {
|
|
11159
11228
|
throw new Error(`Context file not found: ${absolutePath}`);
|
|
11160
11229
|
}
|
|
11161
|
-
const content =
|
|
11230
|
+
const content = fs22.readFileSync(absolutePath, "utf-8");
|
|
11162
11231
|
let rawContext;
|
|
11163
11232
|
try {
|
|
11164
11233
|
rawContext = JSON.parse(content);
|
|
@@ -11695,9 +11764,9 @@ async function chatCommand(args2) {
|
|
|
11695
11764
|
output: process.stdout
|
|
11696
11765
|
});
|
|
11697
11766
|
const askQuestion = (prompt2) => {
|
|
11698
|
-
return new Promise((
|
|
11767
|
+
return new Promise((resolve16) => {
|
|
11699
11768
|
rl.question(prompt2, (answer) => {
|
|
11700
|
-
|
|
11769
|
+
resolve16(answer);
|
|
11701
11770
|
});
|
|
11702
11771
|
});
|
|
11703
11772
|
};
|
|
@@ -12244,8 +12313,8 @@ Error: ${input.name} is required`);
|
|
|
12244
12313
|
}
|
|
12245
12314
|
|
|
12246
12315
|
// src/cli/commands/skills.ts
|
|
12247
|
-
var
|
|
12248
|
-
var
|
|
12316
|
+
var fs23 = __toESM(require("fs"));
|
|
12317
|
+
var path23 = __toESM(require("path"));
|
|
12249
12318
|
var import_yaml2 = require("yaml");
|
|
12250
12319
|
init_utils();
|
|
12251
12320
|
function printHelp21() {
|
|
@@ -12317,12 +12386,12 @@ async function getWorkplaceToken6(workplaceSubdomain, serverUrl, cliToken) {
|
|
|
12317
12386
|
);
|
|
12318
12387
|
}
|
|
12319
12388
|
async function loadSkillFile(filePath) {
|
|
12320
|
-
const absolutePath =
|
|
12321
|
-
if (!
|
|
12389
|
+
const absolutePath = path23.resolve(filePath);
|
|
12390
|
+
if (!fs23.existsSync(absolutePath)) {
|
|
12322
12391
|
throw new Error(`File not found: ${absolutePath}`);
|
|
12323
12392
|
}
|
|
12324
|
-
const content =
|
|
12325
|
-
const ext =
|
|
12393
|
+
const content = fs23.readFileSync(absolutePath, "utf-8");
|
|
12394
|
+
const ext = path23.extname(absolutePath).toLowerCase();
|
|
12326
12395
|
if (ext !== ".yml" && ext !== ".yaml") {
|
|
12327
12396
|
throw new Error("Skill file must be a .skill.yml or .skill.yaml file");
|
|
12328
12397
|
}
|
|
@@ -12767,8 +12836,8 @@ async function skillsCommand(args2) {
|
|
|
12767
12836
|
}
|
|
12768
12837
|
|
|
12769
12838
|
// src/cli/commands/workflows.ts
|
|
12770
|
-
var
|
|
12771
|
-
var
|
|
12839
|
+
var fs24 = __toESM(require("fs"));
|
|
12840
|
+
var path24 = __toESM(require("path"));
|
|
12772
12841
|
var readline7 = __toESM(require("readline"));
|
|
12773
12842
|
var import_yaml3 = require("yaml");
|
|
12774
12843
|
init_utils();
|
|
@@ -13033,12 +13102,12 @@ async function getWorkplaceToken7(workplaceSubdomain, serverUrl, cliToken) {
|
|
|
13033
13102
|
);
|
|
13034
13103
|
}
|
|
13035
13104
|
async function loadWorkflowFile(filePath) {
|
|
13036
|
-
const absolutePath =
|
|
13037
|
-
if (!
|
|
13105
|
+
const absolutePath = path24.resolve(filePath);
|
|
13106
|
+
if (!fs24.existsSync(absolutePath)) {
|
|
13038
13107
|
throw new Error(`File not found: ${absolutePath}`);
|
|
13039
13108
|
}
|
|
13040
|
-
const content =
|
|
13041
|
-
const ext =
|
|
13109
|
+
const content = fs24.readFileSync(absolutePath, "utf-8");
|
|
13110
|
+
const ext = path24.extname(absolutePath).toLowerCase();
|
|
13042
13111
|
if (ext !== ".yml" && ext !== ".yaml") {
|
|
13043
13112
|
throw new Error("Workflow file must be a .yml or .yaml file");
|
|
13044
13113
|
}
|
|
@@ -13078,8 +13147,8 @@ function isTerminalRunStatus(status) {
|
|
|
13078
13147
|
return status === "completed" || status === "failed" || status === "cancelled";
|
|
13079
13148
|
}
|
|
13080
13149
|
function sleep(ms) {
|
|
13081
|
-
return new Promise((
|
|
13082
|
-
setTimeout(
|
|
13150
|
+
return new Promise((resolve16) => {
|
|
13151
|
+
setTimeout(resolve16, ms);
|
|
13083
13152
|
});
|
|
13084
13153
|
}
|
|
13085
13154
|
async function handleList5(args2) {
|
|
@@ -13397,8 +13466,8 @@ async function handlePull2(args2) {
|
|
|
13397
13466
|
console.log(JSON.stringify(result, null, 2));
|
|
13398
13467
|
return;
|
|
13399
13468
|
}
|
|
13400
|
-
const outputPath =
|
|
13401
|
-
|
|
13469
|
+
const outputPath = path24.resolve(output || `./${handle}.workflow.yml`);
|
|
13470
|
+
fs24.writeFileSync(outputPath, result.yaml, "utf-8");
|
|
13402
13471
|
console.log(`Saved v${result.version} to ${outputPath}`);
|
|
13403
13472
|
}
|
|
13404
13473
|
async function handlePublish3(args2) {
|
|
@@ -13445,9 +13514,9 @@ async function promptForMissingInputs(schema, inputs) {
|
|
|
13445
13514
|
input: process.stdin,
|
|
13446
13515
|
output: process.stdout
|
|
13447
13516
|
});
|
|
13448
|
-
const askQuestion = (prompt2) => new Promise((
|
|
13517
|
+
const askQuestion = (prompt2) => new Promise((resolve16) => {
|
|
13449
13518
|
rl.question(prompt2, (answer) => {
|
|
13450
|
-
|
|
13519
|
+
resolve16(answer);
|
|
13451
13520
|
});
|
|
13452
13521
|
});
|
|
13453
13522
|
const resolved = { ...inputs };
|