skedyul 1.2.24 → 1.2.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/commands/config-export.d.ts +12 -0
- package/dist/cli/index.js +301 -115
- package/dist/config/index.d.ts +1 -0
- package/dist/config/resolver.d.ts +38 -0
- package/dist/dedicated/server.js +21 -0
- package/dist/dockerfile.d.ts +1 -1
- package/dist/esm/index.mjs +61 -37
- package/dist/index.js +61 -37
- package/dist/server.js +21 -0
- package/dist/serverless/server.mjs +21 -0
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -627,7 +627,7 @@ function setNgrokAuthtoken(authtoken) {
|
|
|
627
627
|
saveConfig(config);
|
|
628
628
|
}
|
|
629
629
|
async function startOAuthCallback(serverUrl) {
|
|
630
|
-
return new Promise((
|
|
630
|
+
return new Promise((resolve10, reject) => {
|
|
631
631
|
let timeoutId = null;
|
|
632
632
|
const cleanup = () => {
|
|
633
633
|
if (timeoutId) {
|
|
@@ -689,7 +689,7 @@ async function startOAuthCallback(serverUrl) {
|
|
|
689
689
|
`);
|
|
690
690
|
cleanup();
|
|
691
691
|
server2.close();
|
|
692
|
-
|
|
692
|
+
resolve10({
|
|
693
693
|
token,
|
|
694
694
|
userId,
|
|
695
695
|
username,
|
|
@@ -743,10 +743,10 @@ async function openBrowser(url) {
|
|
|
743
743
|
} else {
|
|
744
744
|
command = `xdg-open "${url}"`;
|
|
745
745
|
}
|
|
746
|
-
return new Promise((
|
|
746
|
+
return new Promise((resolve10, reject) => {
|
|
747
747
|
exec(command, (error) => {
|
|
748
748
|
if (error) reject(error);
|
|
749
|
-
else
|
|
749
|
+
else resolve10();
|
|
750
750
|
});
|
|
751
751
|
});
|
|
752
752
|
}
|
|
@@ -2398,13 +2398,13 @@ function mergeRuntimeEnv() {
|
|
|
2398
2398
|
|
|
2399
2399
|
// src/server/utils/http.ts
|
|
2400
2400
|
function readRawRequestBody(req) {
|
|
2401
|
-
return new Promise((
|
|
2401
|
+
return new Promise((resolve10, reject) => {
|
|
2402
2402
|
let body = "";
|
|
2403
2403
|
req.on("data", (chunk) => {
|
|
2404
2404
|
body += chunk.toString();
|
|
2405
2405
|
});
|
|
2406
2406
|
req.on("end", () => {
|
|
2407
|
-
|
|
2407
|
+
resolve10(body);
|
|
2408
2408
|
});
|
|
2409
2409
|
req.on("error", reject);
|
|
2410
2410
|
});
|
|
@@ -2693,6 +2693,7 @@ function createCallToolHandler(registry, state, onMaxRequests) {
|
|
|
2693
2693
|
}
|
|
2694
2694
|
|
|
2695
2695
|
// src/server/dedicated.ts
|
|
2696
|
+
var fs7 = __toESM(require("fs"));
|
|
2696
2697
|
var import_http2 = __toESM(require("http"));
|
|
2697
2698
|
var import_streamableHttp = require("@modelcontextprotocol/sdk/server/streamableHttp.js");
|
|
2698
2699
|
|
|
@@ -3225,7 +3226,7 @@ async function handleOAuthCallback(parsedBody, hooks) {
|
|
|
3225
3226
|
}
|
|
3226
3227
|
|
|
3227
3228
|
// src/server/handlers/webhook-handler.ts
|
|
3228
|
-
function parseWebhookRequest(parsedBody, method, url,
|
|
3229
|
+
function parseWebhookRequest(parsedBody, method, url, path16, headers, query, rawBody, appIdHeader, appVersionIdHeader) {
|
|
3229
3230
|
const isEnvelope = typeof parsedBody === "object" && parsedBody !== null && "env" in parsedBody && "request" in parsedBody && "context" in parsedBody;
|
|
3230
3231
|
if (isEnvelope) {
|
|
3231
3232
|
const envelope = parsedBody;
|
|
@@ -3279,7 +3280,7 @@ function parseWebhookRequest(parsedBody, method, url, path14, headers, query, ra
|
|
|
3279
3280
|
const webhookRequest = {
|
|
3280
3281
|
method,
|
|
3281
3282
|
url,
|
|
3282
|
-
path:
|
|
3283
|
+
path: path16,
|
|
3283
3284
|
headers,
|
|
3284
3285
|
query,
|
|
3285
3286
|
body: parsedBody,
|
|
@@ -3336,6 +3337,7 @@ function isMethodAllowed(webhookRegistry, handle, method) {
|
|
|
3336
3337
|
}
|
|
3337
3338
|
|
|
3338
3339
|
// src/server/dedicated.ts
|
|
3340
|
+
var CONFIG_FILE_PATH = ".skedyul/config.json";
|
|
3339
3341
|
function createDedicatedServerInstance(config, tools, callTool, state, mcpServer) {
|
|
3340
3342
|
const port = getListeningPort(config);
|
|
3341
3343
|
const registry = config.tools;
|
|
@@ -3356,6 +3358,15 @@ function createDedicatedServerInstance(config, tools, callTool, state, mcpServer
|
|
|
3356
3358
|
return;
|
|
3357
3359
|
}
|
|
3358
3360
|
if (pathname === "/config" && req.method === "GET") {
|
|
3361
|
+
try {
|
|
3362
|
+
if (fs7.existsSync(CONFIG_FILE_PATH)) {
|
|
3363
|
+
const fileConfig = JSON.parse(fs7.readFileSync(CONFIG_FILE_PATH, "utf-8"));
|
|
3364
|
+
sendJSON(res, 200, fileConfig);
|
|
3365
|
+
return;
|
|
3366
|
+
}
|
|
3367
|
+
} catch (err) {
|
|
3368
|
+
console.warn("[/config] Failed to read config file, falling back to runtime serialization:", err);
|
|
3369
|
+
}
|
|
3359
3370
|
sendJSON(res, 200, serializeConfig(config));
|
|
3360
3371
|
return;
|
|
3361
3372
|
}
|
|
@@ -3655,10 +3666,10 @@ function createDedicatedServerInstance(config, tools, callTool, state, mcpServer
|
|
|
3655
3666
|
return {
|
|
3656
3667
|
async listen(listenPort) {
|
|
3657
3668
|
const finalPort = listenPort ?? port;
|
|
3658
|
-
return new Promise((
|
|
3669
|
+
return new Promise((resolve10, reject) => {
|
|
3659
3670
|
httpServer.listen(finalPort, () => {
|
|
3660
3671
|
printStartupLog(config, tools, finalPort);
|
|
3661
|
-
|
|
3672
|
+
resolve10();
|
|
3662
3673
|
});
|
|
3663
3674
|
httpServer.once("error", reject);
|
|
3664
3675
|
});
|
|
@@ -3668,6 +3679,8 @@ function createDedicatedServerInstance(config, tools, callTool, state, mcpServer
|
|
|
3668
3679
|
}
|
|
3669
3680
|
|
|
3670
3681
|
// src/server/serverless.ts
|
|
3682
|
+
var fs8 = __toESM(require("fs"));
|
|
3683
|
+
var CONFIG_FILE_PATH2 = ".skedyul/config.json";
|
|
3671
3684
|
function createServerlessInstance(config, tools, callTool, state, mcpServer) {
|
|
3672
3685
|
const headers = getDefaultHeaders(config.cors);
|
|
3673
3686
|
const registry = config.tools;
|
|
@@ -3680,13 +3693,13 @@ function createServerlessInstance(config, tools, callTool, state, mcpServer) {
|
|
|
3680
3693
|
hasLoggedStartup = true;
|
|
3681
3694
|
}
|
|
3682
3695
|
try {
|
|
3683
|
-
const
|
|
3696
|
+
const path16 = event.path || event.rawPath || "/";
|
|
3684
3697
|
const method = event.httpMethod || event.requestContext?.http?.method || "POST";
|
|
3685
3698
|
if (method === "OPTIONS") {
|
|
3686
3699
|
return createResponse(200, { message: "OK" }, headers);
|
|
3687
3700
|
}
|
|
3688
|
-
if (
|
|
3689
|
-
const handle =
|
|
3701
|
+
if (path16.startsWith("/webhooks/") && webhookRegistry) {
|
|
3702
|
+
const handle = path16.slice("/webhooks/".length);
|
|
3690
3703
|
if (!webhookRegistry[handle]) {
|
|
3691
3704
|
return createResponse(404, { error: `Webhook handler '${handle}' not found` }, headers);
|
|
3692
3705
|
}
|
|
@@ -3709,12 +3722,12 @@ function createServerlessInstance(config, tools, callTool, state, mcpServer) {
|
|
|
3709
3722
|
const protocol = forwardedProto ?? "https";
|
|
3710
3723
|
const host = event.headers?.host ?? event.headers?.Host ?? "localhost";
|
|
3711
3724
|
const queryString = event.queryStringParameters ? "?" + new URLSearchParams(event.queryStringParameters).toString() : "";
|
|
3712
|
-
const webhookUrl = `${protocol}://${host}${
|
|
3725
|
+
const webhookUrl = `${protocol}://${host}${path16}${queryString}`;
|
|
3713
3726
|
const parseResult = parseWebhookRequest(
|
|
3714
3727
|
parsedBody,
|
|
3715
3728
|
method,
|
|
3716
3729
|
webhookUrl,
|
|
3717
|
-
|
|
3730
|
+
path16,
|
|
3718
3731
|
event.headers,
|
|
3719
3732
|
event.queryStringParameters ?? {},
|
|
3720
3733
|
rawBody,
|
|
@@ -3735,7 +3748,7 @@ function createServerlessInstance(config, tools, callTool, state, mcpServer) {
|
|
|
3735
3748
|
body: result.body !== void 0 ? typeof result.body === "string" ? result.body : JSON.stringify(result.body) : ""
|
|
3736
3749
|
};
|
|
3737
3750
|
}
|
|
3738
|
-
if (
|
|
3751
|
+
if (path16 === "/core" && method === "POST") {
|
|
3739
3752
|
let coreBody;
|
|
3740
3753
|
try {
|
|
3741
3754
|
coreBody = event.body ? JSON.parse(event.body) : {};
|
|
@@ -3767,7 +3780,7 @@ function createServerlessInstance(config, tools, callTool, state, mcpServer) {
|
|
|
3767
3780
|
const result = await handleCoreMethod(coreMethod, coreBody.params);
|
|
3768
3781
|
return createResponse(result.status, result.payload, headers);
|
|
3769
3782
|
}
|
|
3770
|
-
if (
|
|
3783
|
+
if (path16 === "/core/webhook" && method === "POST") {
|
|
3771
3784
|
const rawWebhookBody = event.body ?? "";
|
|
3772
3785
|
let webhookBody;
|
|
3773
3786
|
try {
|
|
@@ -3782,14 +3795,14 @@ function createServerlessInstance(config, tools, callTool, state, mcpServer) {
|
|
|
3782
3795
|
const forwardedProto = event.headers?.["x-forwarded-proto"] ?? event.headers?.["X-Forwarded-Proto"];
|
|
3783
3796
|
const protocol = forwardedProto ?? "https";
|
|
3784
3797
|
const host = event.headers?.host ?? event.headers?.Host ?? "localhost";
|
|
3785
|
-
const webhookUrl = `${protocol}://${host}${
|
|
3798
|
+
const webhookUrl = `${protocol}://${host}${path16}`;
|
|
3786
3799
|
const coreWebhookRequest = {
|
|
3787
3800
|
method,
|
|
3788
3801
|
headers: event.headers ?? {},
|
|
3789
3802
|
body: webhookBody,
|
|
3790
3803
|
query: event.queryStringParameters ?? {},
|
|
3791
3804
|
url: webhookUrl,
|
|
3792
|
-
path:
|
|
3805
|
+
path: path16,
|
|
3793
3806
|
rawBody: rawWebhookBody ? Buffer.from(rawWebhookBody, "utf-8") : void 0
|
|
3794
3807
|
};
|
|
3795
3808
|
const webhookResponse = await coreApiService.dispatchWebhook(
|
|
@@ -3801,7 +3814,7 @@ function createServerlessInstance(config, tools, callTool, state, mcpServer) {
|
|
|
3801
3814
|
headers
|
|
3802
3815
|
);
|
|
3803
3816
|
}
|
|
3804
|
-
if (
|
|
3817
|
+
if (path16 === "/estimate" && method === "POST") {
|
|
3805
3818
|
let estimateBody;
|
|
3806
3819
|
try {
|
|
3807
3820
|
estimateBody = event.body ? JSON.parse(event.body) : {};
|
|
@@ -3867,7 +3880,7 @@ function createServerlessInstance(config, tools, callTool, state, mcpServer) {
|
|
|
3867
3880
|
);
|
|
3868
3881
|
}
|
|
3869
3882
|
}
|
|
3870
|
-
if (
|
|
3883
|
+
if (path16 === "/install" && method === "POST") {
|
|
3871
3884
|
let installBody;
|
|
3872
3885
|
try {
|
|
3873
3886
|
installBody = event.body ? JSON.parse(event.body) : {};
|
|
@@ -3881,7 +3894,7 @@ function createServerlessInstance(config, tools, callTool, state, mcpServer) {
|
|
|
3881
3894
|
const result = await handleInstall(installBody, config.hooks);
|
|
3882
3895
|
return createResponse(result.status, result.body, headers);
|
|
3883
3896
|
}
|
|
3884
|
-
if (
|
|
3897
|
+
if (path16 === "/uninstall" && method === "POST") {
|
|
3885
3898
|
let uninstallBody;
|
|
3886
3899
|
try {
|
|
3887
3900
|
uninstallBody = event.body ? JSON.parse(event.body) : {};
|
|
@@ -3895,7 +3908,7 @@ function createServerlessInstance(config, tools, callTool, state, mcpServer) {
|
|
|
3895
3908
|
const result = await handleUninstall(uninstallBody, config.hooks);
|
|
3896
3909
|
return createResponse(result.status, result.body, headers);
|
|
3897
3910
|
}
|
|
3898
|
-
if (
|
|
3911
|
+
if (path16 === "/provision" && method === "POST") {
|
|
3899
3912
|
let provisionBody;
|
|
3900
3913
|
try {
|
|
3901
3914
|
provisionBody = event.body ? JSON.parse(event.body) : {};
|
|
@@ -3909,7 +3922,7 @@ function createServerlessInstance(config, tools, callTool, state, mcpServer) {
|
|
|
3909
3922
|
const result = await handleProvision(provisionBody, config.hooks);
|
|
3910
3923
|
return createResponse(result.status, result.body, headers);
|
|
3911
3924
|
}
|
|
3912
|
-
if (
|
|
3925
|
+
if (path16 === "/oauth_callback" && method === "POST") {
|
|
3913
3926
|
let parsedBody;
|
|
3914
3927
|
try {
|
|
3915
3928
|
parsedBody = event.body ? JSON.parse(event.body) : {};
|
|
@@ -3924,13 +3937,21 @@ function createServerlessInstance(config, tools, callTool, state, mcpServer) {
|
|
|
3924
3937
|
const result = await handleOAuthCallback(parsedBody, config.hooks);
|
|
3925
3938
|
return createResponse(result.status, result.body, headers);
|
|
3926
3939
|
}
|
|
3927
|
-
if (
|
|
3940
|
+
if (path16 === "/health" && method === "GET") {
|
|
3928
3941
|
return createResponse(200, state.getHealthStatus(), headers);
|
|
3929
3942
|
}
|
|
3930
|
-
if (
|
|
3943
|
+
if (path16 === "/config" && method === "GET") {
|
|
3944
|
+
try {
|
|
3945
|
+
if (fs8.existsSync(CONFIG_FILE_PATH2)) {
|
|
3946
|
+
const fileConfig = JSON.parse(fs8.readFileSync(CONFIG_FILE_PATH2, "utf-8"));
|
|
3947
|
+
return createResponse(200, fileConfig, headers);
|
|
3948
|
+
}
|
|
3949
|
+
} catch (err) {
|
|
3950
|
+
console.warn("[/config] Failed to read config file, falling back to runtime serialization:", err);
|
|
3951
|
+
}
|
|
3931
3952
|
return createResponse(200, serializeConfig(config), headers);
|
|
3932
3953
|
}
|
|
3933
|
-
if (
|
|
3954
|
+
if (path16 === "/mcp" && method === "POST") {
|
|
3934
3955
|
let body;
|
|
3935
3956
|
try {
|
|
3936
3957
|
body = event.body ? JSON.parse(event.body) : {};
|
|
@@ -4378,7 +4399,7 @@ async function promptInput(question, hidden = false) {
|
|
|
4378
4399
|
input: process.stdin,
|
|
4379
4400
|
output: process.stdout
|
|
4380
4401
|
});
|
|
4381
|
-
return new Promise((
|
|
4402
|
+
return new Promise((resolve10) => {
|
|
4382
4403
|
if (hidden) {
|
|
4383
4404
|
process.stdout.write(question);
|
|
4384
4405
|
let input = "";
|
|
@@ -4393,7 +4414,7 @@ async function promptInput(question, hidden = false) {
|
|
|
4393
4414
|
if (stdin.setRawMode) stdin.setRawMode(wasRaw ?? false);
|
|
4394
4415
|
process.stdout.write("\n");
|
|
4395
4416
|
rl.close();
|
|
4396
|
-
|
|
4417
|
+
resolve10(input);
|
|
4397
4418
|
} else if (char === "") {
|
|
4398
4419
|
process.exit(0);
|
|
4399
4420
|
} else if (char === "\x7F" || char === "\b") {
|
|
@@ -4408,7 +4429,7 @@ async function promptInput(question, hidden = false) {
|
|
|
4408
4429
|
} else {
|
|
4409
4430
|
rl.question(question, (answer) => {
|
|
4410
4431
|
rl.close();
|
|
4411
|
-
|
|
4432
|
+
resolve10(answer.trim());
|
|
4412
4433
|
});
|
|
4413
4434
|
}
|
|
4414
4435
|
});
|
|
@@ -4524,12 +4545,12 @@ var HEARTBEAT_INTERVAL_MS = 30 * 1e3;
|
|
|
4524
4545
|
var DEFAULT_PORT = 6e4;
|
|
4525
4546
|
var MAX_PORT_ATTEMPTS = 100;
|
|
4526
4547
|
async function isPortAvailable(port) {
|
|
4527
|
-
return new Promise((
|
|
4548
|
+
return new Promise((resolve10) => {
|
|
4528
4549
|
const server2 = net.createServer();
|
|
4529
|
-
server2.once("error", () =>
|
|
4550
|
+
server2.once("error", () => resolve10(false));
|
|
4530
4551
|
server2.once("listening", () => {
|
|
4531
4552
|
server2.close();
|
|
4532
|
-
|
|
4553
|
+
resolve10(true);
|
|
4533
4554
|
});
|
|
4534
4555
|
server2.listen(port, "127.0.0.1");
|
|
4535
4556
|
});
|
|
@@ -4962,12 +4983,12 @@ Press Ctrl+C to stop`);
|
|
|
4962
4983
|
}
|
|
4963
4984
|
|
|
4964
4985
|
// src/cli/commands/validate.ts
|
|
4965
|
-
var
|
|
4966
|
-
var
|
|
4986
|
+
var fs10 = __toESM(require("fs"));
|
|
4987
|
+
var path9 = __toESM(require("path"));
|
|
4967
4988
|
init_utils();
|
|
4968
4989
|
|
|
4969
4990
|
// src/config/loader.ts
|
|
4970
|
-
var
|
|
4991
|
+
var fs9 = __toESM(require("fs"));
|
|
4971
4992
|
var path7 = __toESM(require("path"));
|
|
4972
4993
|
var os2 = __toESM(require("os"));
|
|
4973
4994
|
var CONFIG_FILE_NAMES = [
|
|
@@ -4977,7 +4998,7 @@ var CONFIG_FILE_NAMES = [
|
|
|
4977
4998
|
"skedyul.config.cjs"
|
|
4978
4999
|
];
|
|
4979
5000
|
async function transpileTypeScript(filePath) {
|
|
4980
|
-
const content =
|
|
5001
|
+
const content = fs9.readFileSync(filePath, "utf-8");
|
|
4981
5002
|
const configDir = path7.dirname(path7.resolve(filePath));
|
|
4982
5003
|
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*$/, "}");
|
|
4983
5004
|
transpiled = transpiled.replace(
|
|
@@ -4992,7 +5013,7 @@ async function transpileTypeScript(filePath) {
|
|
|
4992
5013
|
}
|
|
4993
5014
|
async function loadConfig(configPath) {
|
|
4994
5015
|
const absolutePath = path7.resolve(configPath);
|
|
4995
|
-
if (!
|
|
5016
|
+
if (!fs9.existsSync(absolutePath)) {
|
|
4996
5017
|
throw new Error(`Config file not found: ${absolutePath}`);
|
|
4997
5018
|
}
|
|
4998
5019
|
const isTypeScript = absolutePath.endsWith(".ts");
|
|
@@ -5002,7 +5023,7 @@ async function loadConfig(configPath) {
|
|
|
5002
5023
|
const transpiled = await transpileTypeScript(absolutePath);
|
|
5003
5024
|
const tempDir = os2.tmpdir();
|
|
5004
5025
|
const tempFile = path7.join(tempDir, `skedyul-config-${Date.now()}.js`);
|
|
5005
|
-
|
|
5026
|
+
fs9.writeFileSync(tempFile, transpiled);
|
|
5006
5027
|
moduleToLoad = tempFile;
|
|
5007
5028
|
try {
|
|
5008
5029
|
const module3 = require(moduleToLoad);
|
|
@@ -5016,7 +5037,7 @@ async function loadConfig(configPath) {
|
|
|
5016
5037
|
return config2;
|
|
5017
5038
|
} finally {
|
|
5018
5039
|
try {
|
|
5019
|
-
|
|
5040
|
+
fs9.unlinkSync(tempFile);
|
|
5020
5041
|
} catch {
|
|
5021
5042
|
}
|
|
5022
5043
|
}
|
|
@@ -5047,6 +5068,75 @@ function validateConfig(config) {
|
|
|
5047
5068
|
return { valid: errors.length === 0, errors };
|
|
5048
5069
|
}
|
|
5049
5070
|
|
|
5071
|
+
// src/config/resolver.ts
|
|
5072
|
+
var path8 = __toESM(require("path"));
|
|
5073
|
+
async function loadAndResolveConfig(configPath) {
|
|
5074
|
+
const absolutePath = path8.resolve(configPath);
|
|
5075
|
+
const module2 = await import(absolutePath);
|
|
5076
|
+
const config = module2.default;
|
|
5077
|
+
if (!config || typeof config !== "object") {
|
|
5078
|
+
throw new Error("Config file must export a configuration object");
|
|
5079
|
+
}
|
|
5080
|
+
if (!config.name || typeof config.name !== "string") {
|
|
5081
|
+
throw new Error('Config must have a "name" property');
|
|
5082
|
+
}
|
|
5083
|
+
let tools;
|
|
5084
|
+
if (config.tools) {
|
|
5085
|
+
if (config.tools instanceof Promise) {
|
|
5086
|
+
const resolved = await config.tools;
|
|
5087
|
+
tools = resolved.toolRegistry || resolved.default;
|
|
5088
|
+
} else {
|
|
5089
|
+
tools = config.tools;
|
|
5090
|
+
}
|
|
5091
|
+
}
|
|
5092
|
+
let webhooks;
|
|
5093
|
+
if (config.webhooks) {
|
|
5094
|
+
if (config.webhooks instanceof Promise) {
|
|
5095
|
+
const resolved = await config.webhooks;
|
|
5096
|
+
webhooks = resolved.webhookRegistry || resolved.default;
|
|
5097
|
+
} else {
|
|
5098
|
+
webhooks = config.webhooks;
|
|
5099
|
+
}
|
|
5100
|
+
}
|
|
5101
|
+
let provision;
|
|
5102
|
+
if (config.provision) {
|
|
5103
|
+
if (config.provision instanceof Promise) {
|
|
5104
|
+
const resolved = await config.provision;
|
|
5105
|
+
provision = resolved.default;
|
|
5106
|
+
} else {
|
|
5107
|
+
provision = config.provision;
|
|
5108
|
+
}
|
|
5109
|
+
}
|
|
5110
|
+
return {
|
|
5111
|
+
...config,
|
|
5112
|
+
tools,
|
|
5113
|
+
webhooks,
|
|
5114
|
+
provision
|
|
5115
|
+
};
|
|
5116
|
+
}
|
|
5117
|
+
function serializeResolvedConfig(config) {
|
|
5118
|
+
return {
|
|
5119
|
+
name: config.name,
|
|
5120
|
+
version: config.version,
|
|
5121
|
+
description: config.description,
|
|
5122
|
+
computeLayer: config.computeLayer,
|
|
5123
|
+
tools: config.tools ? Object.entries(config.tools).map(([key, tool]) => ({
|
|
5124
|
+
name: tool.name || key,
|
|
5125
|
+
description: tool.description,
|
|
5126
|
+
timeout: tool.timeout,
|
|
5127
|
+
retries: tool.retries
|
|
5128
|
+
})) : [],
|
|
5129
|
+
webhooks: config.webhooks ? Object.values(config.webhooks).map((w) => ({
|
|
5130
|
+
name: w.name,
|
|
5131
|
+
description: w.description,
|
|
5132
|
+
methods: w.methods ?? ["POST"],
|
|
5133
|
+
type: w.type ?? "WEBHOOK"
|
|
5134
|
+
})) : [],
|
|
5135
|
+
provision: config.provision,
|
|
5136
|
+
agents: config.agents
|
|
5137
|
+
};
|
|
5138
|
+
}
|
|
5139
|
+
|
|
5050
5140
|
// src/config/utils.ts
|
|
5051
5141
|
function getAllEnvKeys(config) {
|
|
5052
5142
|
const provision = config.provision && "env" in config.provision ? config.provision : void 0;
|
|
@@ -5084,8 +5174,8 @@ Examples:
|
|
|
5084
5174
|
}
|
|
5085
5175
|
function findConfigFile2(startDir) {
|
|
5086
5176
|
for (const fileName of CONFIG_FILE_NAMES) {
|
|
5087
|
-
const filePath =
|
|
5088
|
-
if (
|
|
5177
|
+
const filePath = path9.join(startDir, fileName);
|
|
5178
|
+
if (fs10.existsSync(filePath)) {
|
|
5089
5179
|
return filePath;
|
|
5090
5180
|
}
|
|
5091
5181
|
}
|
|
@@ -5119,9 +5209,9 @@ async function validateCommand(args2) {
|
|
|
5119
5209
|
}
|
|
5120
5210
|
configPath = foundConfig;
|
|
5121
5211
|
} else {
|
|
5122
|
-
configPath =
|
|
5212
|
+
configPath = path9.resolve(process.cwd(), configPath);
|
|
5123
5213
|
}
|
|
5124
|
-
if (!
|
|
5214
|
+
if (!fs10.existsSync(configPath)) {
|
|
5125
5215
|
const result2 = {
|
|
5126
5216
|
valid: false,
|
|
5127
5217
|
configPath,
|
|
@@ -5166,8 +5256,8 @@ async function validateCommand(args2) {
|
|
|
5166
5256
|
if (provision?.workflows) {
|
|
5167
5257
|
for (const workflow of provision.workflows) {
|
|
5168
5258
|
if (workflow.path) {
|
|
5169
|
-
const absoluteWorkflowPath =
|
|
5170
|
-
if (!
|
|
5259
|
+
const absoluteWorkflowPath = path9.resolve(path9.dirname(configPath), workflow.path);
|
|
5260
|
+
if (!fs10.existsSync(absoluteWorkflowPath)) {
|
|
5171
5261
|
warnings.push(`Workflow file not found: ${workflow.path}`);
|
|
5172
5262
|
}
|
|
5173
5263
|
}
|
|
@@ -5262,8 +5352,8 @@ async function validateCommand(args2) {
|
|
|
5262
5352
|
}
|
|
5263
5353
|
|
|
5264
5354
|
// src/cli/commands/diff.ts
|
|
5265
|
-
var
|
|
5266
|
-
var
|
|
5355
|
+
var fs11 = __toESM(require("fs"));
|
|
5356
|
+
var path10 = __toESM(require("path"));
|
|
5267
5357
|
init_utils();
|
|
5268
5358
|
function printHelp6() {
|
|
5269
5359
|
console.log(`
|
|
@@ -5296,8 +5386,8 @@ Examples:
|
|
|
5296
5386
|
}
|
|
5297
5387
|
function findConfigFile3(startDir) {
|
|
5298
5388
|
for (const fileName of CONFIG_FILE_NAMES) {
|
|
5299
|
-
const filePath =
|
|
5300
|
-
if (
|
|
5389
|
+
const filePath = path10.join(startDir, fileName);
|
|
5390
|
+
if (fs11.existsSync(filePath)) {
|
|
5301
5391
|
return filePath;
|
|
5302
5392
|
}
|
|
5303
5393
|
}
|
|
@@ -5353,9 +5443,9 @@ async function diffCommand(args2) {
|
|
|
5353
5443
|
}
|
|
5354
5444
|
configPath = foundConfig;
|
|
5355
5445
|
} else {
|
|
5356
|
-
configPath =
|
|
5446
|
+
configPath = path10.resolve(process.cwd(), configPath);
|
|
5357
5447
|
}
|
|
5358
|
-
if (!
|
|
5448
|
+
if (!fs11.existsSync(configPath)) {
|
|
5359
5449
|
if (jsonOutput) {
|
|
5360
5450
|
console.log(JSON.stringify({ error: `Config file not found: ${configPath}` }));
|
|
5361
5451
|
} else {
|
|
@@ -5397,7 +5487,7 @@ async function diffCommand(args2) {
|
|
|
5397
5487
|
const registryPath = flags.registry || flags.r;
|
|
5398
5488
|
if (registryPath) {
|
|
5399
5489
|
try {
|
|
5400
|
-
const registry = await loadRegistry(
|
|
5490
|
+
const registry = await loadRegistry(path10.resolve(process.cwd(), registryPath));
|
|
5401
5491
|
const toolNames = Object.values(registry).map((t) => t.name);
|
|
5402
5492
|
toolsDiff = {
|
|
5403
5493
|
added: toolNames,
|
|
@@ -5470,8 +5560,8 @@ async function diffCommand(args2) {
|
|
|
5470
5560
|
}
|
|
5471
5561
|
|
|
5472
5562
|
// src/cli/commands/deploy.ts
|
|
5473
|
-
var
|
|
5474
|
-
var
|
|
5563
|
+
var fs12 = __toESM(require("fs"));
|
|
5564
|
+
var path11 = __toESM(require("path"));
|
|
5475
5565
|
var readline2 = __toESM(require("readline"));
|
|
5476
5566
|
init_utils();
|
|
5477
5567
|
function printHelp7() {
|
|
@@ -5507,8 +5597,8 @@ Examples:
|
|
|
5507
5597
|
}
|
|
5508
5598
|
function findConfigFile4(startDir) {
|
|
5509
5599
|
for (const fileName of CONFIG_FILE_NAMES) {
|
|
5510
|
-
const filePath =
|
|
5511
|
-
if (
|
|
5600
|
+
const filePath = path11.join(startDir, fileName);
|
|
5601
|
+
if (fs12.existsSync(filePath)) {
|
|
5512
5602
|
return filePath;
|
|
5513
5603
|
}
|
|
5514
5604
|
}
|
|
@@ -5533,11 +5623,11 @@ async function promptForApproval(impacts) {
|
|
|
5533
5623
|
console.log("");
|
|
5534
5624
|
console.log("These changes cannot be undone. Data will be permanently deleted.");
|
|
5535
5625
|
console.log("");
|
|
5536
|
-
return new Promise((
|
|
5626
|
+
return new Promise((resolve10) => {
|
|
5537
5627
|
rl.question("Do you want to proceed? (yes/no): ", (answer) => {
|
|
5538
5628
|
rl.close();
|
|
5539
5629
|
const normalized = answer.toLowerCase().trim();
|
|
5540
|
-
|
|
5630
|
+
resolve10(normalized === "yes" || normalized === "y");
|
|
5541
5631
|
});
|
|
5542
5632
|
});
|
|
5543
5633
|
}
|
|
@@ -5573,7 +5663,7 @@ async function waitForMigrationApproval(serverUrl, token, migrationId, timeoutMs
|
|
|
5573
5663
|
process.stdout.write(`\r Status: ${data.status} | Time remaining: ${remaining} minutes `);
|
|
5574
5664
|
} catch {
|
|
5575
5665
|
}
|
|
5576
|
-
await new Promise((
|
|
5666
|
+
await new Promise((resolve10) => setTimeout(resolve10, pollInterval));
|
|
5577
5667
|
}
|
|
5578
5668
|
return { approved: false, timedOut: true };
|
|
5579
5669
|
}
|
|
@@ -5622,9 +5712,9 @@ async function deployCommand(args2) {
|
|
|
5622
5712
|
}
|
|
5623
5713
|
configPath = foundConfig;
|
|
5624
5714
|
} else {
|
|
5625
|
-
configPath =
|
|
5715
|
+
configPath = path11.resolve(process.cwd(), configPath);
|
|
5626
5716
|
}
|
|
5627
|
-
if (!
|
|
5717
|
+
if (!fs12.existsSync(configPath)) {
|
|
5628
5718
|
if (jsonOutput) {
|
|
5629
5719
|
console.log(JSON.stringify({ error: `Config file not found: ${configPath}` }));
|
|
5630
5720
|
} else {
|
|
@@ -5941,8 +6031,8 @@ async function logoutCommand(args2) {
|
|
|
5941
6031
|
}
|
|
5942
6032
|
|
|
5943
6033
|
// src/cli/commands/auth/status.ts
|
|
5944
|
-
var
|
|
5945
|
-
var
|
|
6034
|
+
var fs13 = __toESM(require("fs"));
|
|
6035
|
+
var path12 = __toESM(require("path"));
|
|
5946
6036
|
init_utils();
|
|
5947
6037
|
function printHelp10() {
|
|
5948
6038
|
console.log(`
|
|
@@ -6016,17 +6106,17 @@ async function statusCommand(args2) {
|
|
|
6016
6106
|
console.log("");
|
|
6017
6107
|
console.log(" * = active profile");
|
|
6018
6108
|
}
|
|
6019
|
-
const linksDir =
|
|
6109
|
+
const linksDir = path12.join(process.cwd(), ".skedyul", "links");
|
|
6020
6110
|
console.log("");
|
|
6021
6111
|
console.log("LINKED WORKPLACES (this project)");
|
|
6022
6112
|
console.log("\u2500".repeat(60));
|
|
6023
|
-
if (
|
|
6024
|
-
const linkFiles =
|
|
6113
|
+
if (fs13.existsSync(linksDir)) {
|
|
6114
|
+
const linkFiles = fs13.readdirSync(linksDir).filter((f) => f.endsWith(".json"));
|
|
6025
6115
|
if (linkFiles.length > 0) {
|
|
6026
6116
|
for (const file2 of linkFiles) {
|
|
6027
6117
|
const subdomain = file2.replace(".json", "");
|
|
6028
6118
|
try {
|
|
6029
|
-
const content =
|
|
6119
|
+
const content = fs13.readFileSync(path12.join(linksDir, file2), "utf-8");
|
|
6030
6120
|
const link = JSON.parse(content);
|
|
6031
6121
|
console.log(` - ${subdomain} (${link.appHandle})`);
|
|
6032
6122
|
} catch {
|
|
@@ -6382,10 +6472,102 @@ EXAMPLES
|
|
|
6382
6472
|
`);
|
|
6383
6473
|
}
|
|
6384
6474
|
|
|
6475
|
+
// src/cli/commands/config-export.ts
|
|
6476
|
+
var fs14 = __toESM(require("fs"));
|
|
6477
|
+
var path13 = __toESM(require("path"));
|
|
6478
|
+
function printHelp13() {
|
|
6479
|
+
console.log(`
|
|
6480
|
+
SKEDYUL CONFIG:EXPORT - Export resolved config to JSON
|
|
6481
|
+
\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501
|
|
6482
|
+
|
|
6483
|
+
Resolves all dynamic imports in skedyul.config.ts and exports the full
|
|
6484
|
+
config to a JSON file. This includes tools, webhooks, and provision config
|
|
6485
|
+
(models, channels, pages, relationships).
|
|
6486
|
+
|
|
6487
|
+
USAGE
|
|
6488
|
+
$ skedyul config:export [options]
|
|
6489
|
+
|
|
6490
|
+
OPTIONS
|
|
6491
|
+
-o, --output <path> Output path (default: .skedyul/config.json)
|
|
6492
|
+
--help, -h Show this help message
|
|
6493
|
+
|
|
6494
|
+
EXAMPLES
|
|
6495
|
+
# Export to default location
|
|
6496
|
+
$ skedyul config:export
|
|
6497
|
+
|
|
6498
|
+
# Export to custom path
|
|
6499
|
+
$ skedyul config:export -o dist/config.json
|
|
6500
|
+
|
|
6501
|
+
OUTPUT
|
|
6502
|
+
The exported JSON contains:
|
|
6503
|
+
- name, version, description, computeLayer
|
|
6504
|
+
- tools: Array of tool metadata (name, description, timeout, retries)
|
|
6505
|
+
- webhooks: Array of webhook metadata (name, description, methods, type)
|
|
6506
|
+
- provision: Full provision config (models, channels, pages, relationships)
|
|
6507
|
+
- agents: Agent definitions
|
|
6508
|
+
`);
|
|
6509
|
+
}
|
|
6510
|
+
async function configExportCommand(args2) {
|
|
6511
|
+
if (args2.includes("--help") || args2.includes("-h")) {
|
|
6512
|
+
printHelp13();
|
|
6513
|
+
process.exit(0);
|
|
6514
|
+
}
|
|
6515
|
+
let outputPath = ".skedyul/config.json";
|
|
6516
|
+
const outputIndex = args2.findIndex((arg) => arg === "-o" || arg === "--output");
|
|
6517
|
+
if (outputIndex !== -1 && args2[outputIndex + 1]) {
|
|
6518
|
+
outputPath = args2[outputIndex + 1];
|
|
6519
|
+
}
|
|
6520
|
+
const cwd = process.cwd();
|
|
6521
|
+
let configPath = null;
|
|
6522
|
+
for (const name of CONFIG_FILE_NAMES) {
|
|
6523
|
+
const testPath = path13.join(cwd, name);
|
|
6524
|
+
if (fs14.existsSync(testPath)) {
|
|
6525
|
+
configPath = testPath;
|
|
6526
|
+
break;
|
|
6527
|
+
}
|
|
6528
|
+
}
|
|
6529
|
+
if (!configPath) {
|
|
6530
|
+
console.error("Error: No skedyul.config.ts found in current directory");
|
|
6531
|
+
console.error("Make sure you are in the root of your integration project.");
|
|
6532
|
+
process.exit(1);
|
|
6533
|
+
}
|
|
6534
|
+
console.log(`Loading config from ${path13.basename(configPath)}...`);
|
|
6535
|
+
try {
|
|
6536
|
+
const resolvedConfig = await loadAndResolveConfig(configPath);
|
|
6537
|
+
const serialized = serializeResolvedConfig(resolvedConfig);
|
|
6538
|
+
const outputDir = path13.dirname(path13.resolve(cwd, outputPath));
|
|
6539
|
+
if (!fs14.existsSync(outputDir)) {
|
|
6540
|
+
fs14.mkdirSync(outputDir, { recursive: true });
|
|
6541
|
+
}
|
|
6542
|
+
const fullOutputPath = path13.resolve(cwd, outputPath);
|
|
6543
|
+
fs14.writeFileSync(fullOutputPath, JSON.stringify(serialized, null, 2), "utf-8");
|
|
6544
|
+
console.log(``);
|
|
6545
|
+
console.log(`Config exported successfully!`);
|
|
6546
|
+
console.log(` Output: ${outputPath}`);
|
|
6547
|
+
console.log(` Name: ${serialized.name}`);
|
|
6548
|
+
console.log(` Tools: ${serialized.tools?.length ?? 0}`);
|
|
6549
|
+
console.log(` Webhooks: ${serialized.webhooks?.length ?? 0}`);
|
|
6550
|
+
console.log(` Provision models: ${serialized.provision?.models?.length ?? 0}`);
|
|
6551
|
+
console.log(` Provision channels: ${serialized.provision?.channels?.length ?? 0}`);
|
|
6552
|
+
console.log(` Provision pages: ${serialized.provision?.pages?.length ?? 0}`);
|
|
6553
|
+
console.log(` Agents: ${serialized.agents?.length ?? 0}`);
|
|
6554
|
+
console.log(``);
|
|
6555
|
+
} catch (error) {
|
|
6556
|
+
console.error(
|
|
6557
|
+
"Error exporting config:",
|
|
6558
|
+
error instanceof Error ? error.message : String(error)
|
|
6559
|
+
);
|
|
6560
|
+
if (error instanceof Error && error.stack) {
|
|
6561
|
+
console.error(error.stack);
|
|
6562
|
+
}
|
|
6563
|
+
process.exit(1);
|
|
6564
|
+
}
|
|
6565
|
+
}
|
|
6566
|
+
|
|
6385
6567
|
// src/cli/commands/link.ts
|
|
6386
6568
|
init_utils();
|
|
6387
6569
|
init_link();
|
|
6388
|
-
function
|
|
6570
|
+
function printHelp14() {
|
|
6389
6571
|
console.log(`
|
|
6390
6572
|
skedyul dev link - Link project to a Skedyul workplace
|
|
6391
6573
|
|
|
@@ -6417,7 +6599,7 @@ Examples:
|
|
|
6417
6599
|
async function linkCommand(args2) {
|
|
6418
6600
|
const { flags } = parseArgs(args2);
|
|
6419
6601
|
if (flags.help || flags.h) {
|
|
6420
|
-
|
|
6602
|
+
printHelp14();
|
|
6421
6603
|
return;
|
|
6422
6604
|
}
|
|
6423
6605
|
const workplaceSubdomain = flags.workplace || flags.w;
|
|
@@ -6502,7 +6684,7 @@ Failed to link: ${error instanceof Error ? error.message : String(error)}`
|
|
|
6502
6684
|
// src/cli/commands/unlink.ts
|
|
6503
6685
|
init_utils();
|
|
6504
6686
|
init_link();
|
|
6505
|
-
function
|
|
6687
|
+
function printHelp15() {
|
|
6506
6688
|
console.log(`
|
|
6507
6689
|
skedyul dev unlink - Remove a workplace link
|
|
6508
6690
|
|
|
@@ -6525,7 +6707,7 @@ Examples:
|
|
|
6525
6707
|
async function unlinkCommand(args2) {
|
|
6526
6708
|
const { flags } = parseArgs(args2);
|
|
6527
6709
|
if (flags.help || flags.h) {
|
|
6528
|
-
|
|
6710
|
+
printHelp15();
|
|
6529
6711
|
return;
|
|
6530
6712
|
}
|
|
6531
6713
|
const workplaceSubdomain = flags.workplace || flags.w;
|
|
@@ -6561,7 +6743,7 @@ async function prompt(options) {
|
|
|
6561
6743
|
output: process.stdout
|
|
6562
6744
|
});
|
|
6563
6745
|
if (hidden) {
|
|
6564
|
-
return new Promise((
|
|
6746
|
+
return new Promise((resolve10) => {
|
|
6565
6747
|
let muted = false;
|
|
6566
6748
|
const originalWrite = process.stdout.write.bind(process.stdout);
|
|
6567
6749
|
process.stdout.write = ((chunk, encoding, cb) => {
|
|
@@ -6582,31 +6764,31 @@ async function prompt(options) {
|
|
|
6582
6764
|
const value = answer.trim() || defaultValue || "";
|
|
6583
6765
|
if (required && !value) {
|
|
6584
6766
|
console.error("Value is required.");
|
|
6585
|
-
|
|
6767
|
+
resolve10(prompt(options));
|
|
6586
6768
|
return;
|
|
6587
6769
|
}
|
|
6588
|
-
|
|
6770
|
+
resolve10(value);
|
|
6589
6771
|
});
|
|
6590
6772
|
muted = true;
|
|
6591
6773
|
});
|
|
6592
6774
|
}
|
|
6593
|
-
return new Promise((
|
|
6775
|
+
return new Promise((resolve10) => {
|
|
6594
6776
|
const displayMessage = defaultValue ? `${message} [${defaultValue}]: ` : `${message}: `;
|
|
6595
6777
|
rl.question(displayMessage, (answer) => {
|
|
6596
6778
|
rl.close();
|
|
6597
6779
|
const value = answer.trim() || defaultValue || "";
|
|
6598
6780
|
if (required && !value) {
|
|
6599
6781
|
console.error("Value is required.");
|
|
6600
|
-
|
|
6782
|
+
resolve10(prompt(options));
|
|
6601
6783
|
return;
|
|
6602
6784
|
}
|
|
6603
|
-
|
|
6785
|
+
resolve10(value);
|
|
6604
6786
|
});
|
|
6605
6787
|
});
|
|
6606
6788
|
}
|
|
6607
6789
|
|
|
6608
6790
|
// src/cli/commands/install.ts
|
|
6609
|
-
function
|
|
6791
|
+
function printHelp16() {
|
|
6610
6792
|
console.log(`
|
|
6611
6793
|
skedyul dev install - Configure installation environment variables
|
|
6612
6794
|
|
|
@@ -6632,7 +6814,7 @@ Examples:
|
|
|
6632
6814
|
async function installCommand(args2) {
|
|
6633
6815
|
const { flags } = parseArgs(args2);
|
|
6634
6816
|
if (flags.help || flags.h) {
|
|
6635
|
-
|
|
6817
|
+
printHelp16();
|
|
6636
6818
|
return;
|
|
6637
6819
|
}
|
|
6638
6820
|
const workplaceSubdomain = flags.workplace || flags.w;
|
|
@@ -6705,7 +6887,7 @@ Next step:`);
|
|
|
6705
6887
|
|
|
6706
6888
|
// src/cli/commands/instances.ts
|
|
6707
6889
|
init_utils();
|
|
6708
|
-
function
|
|
6890
|
+
function printHelp17() {
|
|
6709
6891
|
console.log(`
|
|
6710
6892
|
skedyul instances - Manage CRM instances
|
|
6711
6893
|
|
|
@@ -6773,7 +6955,7 @@ async function getWorkplaceToken(workplaceSubdomain, serverUrl, cliToken) {
|
|
|
6773
6955
|
async function instancesCommand(args2) {
|
|
6774
6956
|
const { positional, flags } = parseArgs(args2);
|
|
6775
6957
|
if (flags.help || flags.h || positional.length === 0) {
|
|
6776
|
-
|
|
6958
|
+
printHelp17();
|
|
6777
6959
|
return;
|
|
6778
6960
|
}
|
|
6779
6961
|
const subcommand = positional[0];
|
|
@@ -6834,7 +7016,7 @@ async function instancesCommand(args2) {
|
|
|
6834
7016
|
break;
|
|
6835
7017
|
default:
|
|
6836
7018
|
console.error(`Error: Unknown subcommand: ${subcommand}`);
|
|
6837
|
-
|
|
7019
|
+
printHelp17();
|
|
6838
7020
|
process.exit(1);
|
|
6839
7021
|
}
|
|
6840
7022
|
} catch (error) {
|
|
@@ -6941,8 +7123,8 @@ async function handleCreateMany(modelHandle, flags) {
|
|
|
6941
7123
|
console.error("Usage: skedyul instances create-many <model> --file data.json --workplace <subdomain>");
|
|
6942
7124
|
process.exit(1);
|
|
6943
7125
|
}
|
|
6944
|
-
const
|
|
6945
|
-
const fileContent =
|
|
7126
|
+
const fs17 = await import("fs");
|
|
7127
|
+
const fileContent = fs17.readFileSync(filePath, "utf-8");
|
|
6946
7128
|
const items = JSON.parse(fileContent);
|
|
6947
7129
|
if (!Array.isArray(items)) {
|
|
6948
7130
|
console.error("Error: File must contain a JSON array of items");
|
|
@@ -6969,8 +7151,8 @@ async function handleUpsertMany(modelHandle, flags) {
|
|
|
6969
7151
|
console.error("Usage: skedyul instances upsert-many <model> --file data.json --match-field <field> --workplace <subdomain>");
|
|
6970
7152
|
process.exit(1);
|
|
6971
7153
|
}
|
|
6972
|
-
const
|
|
6973
|
-
const fileContent =
|
|
7154
|
+
const fs17 = await import("fs");
|
|
7155
|
+
const fileContent = fs17.readFileSync(filePath, "utf-8");
|
|
6974
7156
|
const items = JSON.parse(fileContent);
|
|
6975
7157
|
if (!Array.isArray(items)) {
|
|
6976
7158
|
console.error("Error: File must contain a JSON array of items");
|
|
@@ -6982,8 +7164,8 @@ async function handleUpsertMany(modelHandle, flags) {
|
|
|
6982
7164
|
|
|
6983
7165
|
// src/cli/commands/build.ts
|
|
6984
7166
|
var import_child_process = require("child_process");
|
|
6985
|
-
var
|
|
6986
|
-
var
|
|
7167
|
+
var fs15 = __toESM(require("fs"));
|
|
7168
|
+
var path14 = __toESM(require("path"));
|
|
6987
7169
|
function printBuildHelp() {
|
|
6988
7170
|
console.log(`
|
|
6989
7171
|
SKEDYUL BUILD - Build your integration
|
|
@@ -7052,8 +7234,8 @@ async function buildCommand(args2) {
|
|
|
7052
7234
|
const cwd = process.cwd();
|
|
7053
7235
|
let configPath = null;
|
|
7054
7236
|
for (const name of CONFIG_FILE_NAMES) {
|
|
7055
|
-
const testPath =
|
|
7056
|
-
if (
|
|
7237
|
+
const testPath = path14.join(cwd, name);
|
|
7238
|
+
if (fs15.existsSync(testPath)) {
|
|
7057
7239
|
configPath = testPath;
|
|
7058
7240
|
break;
|
|
7059
7241
|
}
|
|
@@ -7063,8 +7245,8 @@ async function buildCommand(args2) {
|
|
|
7063
7245
|
console.error("Make sure you are in the root of your integration project.");
|
|
7064
7246
|
process.exit(1);
|
|
7065
7247
|
}
|
|
7066
|
-
console.log(`Loading config from ${
|
|
7067
|
-
const tempConfigPath =
|
|
7248
|
+
console.log(`Loading config from ${path14.basename(configPath)}...`);
|
|
7249
|
+
const tempConfigPath = path14.join(cwd, ".skedyul-tsup.config.mjs");
|
|
7068
7250
|
let createdTempConfig = false;
|
|
7069
7251
|
try {
|
|
7070
7252
|
const config = await loadConfig(configPath);
|
|
@@ -7073,8 +7255,8 @@ async function buildCommand(args2) {
|
|
|
7073
7255
|
const baseExternals = ["skedyul", `skedyul/${computeLayer}`, "zod"];
|
|
7074
7256
|
const userExternals = config.build && "external" in config.build ? config.build.external ?? [] : [];
|
|
7075
7257
|
const allExternals = [...baseExternals, ...userExternals];
|
|
7076
|
-
const userTsupConfig =
|
|
7077
|
-
const hasUserConfig =
|
|
7258
|
+
const userTsupConfig = path14.join(cwd, "tsup.config.ts");
|
|
7259
|
+
const hasUserConfig = fs15.existsSync(userTsupConfig);
|
|
7078
7260
|
console.log(``);
|
|
7079
7261
|
console.log(`Building ${config.name ?? "integration"}...`);
|
|
7080
7262
|
console.log(` Compute layer: ${computeLayer}`);
|
|
@@ -7094,7 +7276,7 @@ async function buildCommand(args2) {
|
|
|
7094
7276
|
}
|
|
7095
7277
|
} else {
|
|
7096
7278
|
const tsupConfigContent = generateTsupConfig(format, allExternals);
|
|
7097
|
-
|
|
7279
|
+
fs15.writeFileSync(tempConfigPath, tsupConfigContent, "utf-8");
|
|
7098
7280
|
createdTempConfig = true;
|
|
7099
7281
|
tsupArgs = [
|
|
7100
7282
|
"tsup",
|
|
@@ -7112,14 +7294,14 @@ async function buildCommand(args2) {
|
|
|
7112
7294
|
});
|
|
7113
7295
|
tsup.on("error", (error) => {
|
|
7114
7296
|
console.error("Failed to start tsup:", error.message);
|
|
7115
|
-
if (createdTempConfig &&
|
|
7116
|
-
|
|
7297
|
+
if (createdTempConfig && fs15.existsSync(tempConfigPath)) {
|
|
7298
|
+
fs15.unlinkSync(tempConfigPath);
|
|
7117
7299
|
}
|
|
7118
7300
|
process.exit(1);
|
|
7119
7301
|
});
|
|
7120
7302
|
tsup.on("close", (code) => {
|
|
7121
|
-
if (createdTempConfig &&
|
|
7122
|
-
|
|
7303
|
+
if (createdTempConfig && fs15.existsSync(tempConfigPath)) {
|
|
7304
|
+
fs15.unlinkSync(tempConfigPath);
|
|
7123
7305
|
}
|
|
7124
7306
|
if (code === 0) {
|
|
7125
7307
|
console.log(``);
|
|
@@ -7128,8 +7310,8 @@ async function buildCommand(args2) {
|
|
|
7128
7310
|
process.exit(code ?? 0);
|
|
7129
7311
|
});
|
|
7130
7312
|
} catch (error) {
|
|
7131
|
-
if (createdTempConfig &&
|
|
7132
|
-
|
|
7313
|
+
if (createdTempConfig && fs15.existsSync(tempConfigPath)) {
|
|
7314
|
+
fs15.unlinkSync(tempConfigPath);
|
|
7133
7315
|
}
|
|
7134
7316
|
console.error(
|
|
7135
7317
|
"Error loading config:",
|
|
@@ -7142,8 +7324,8 @@ async function buildCommand(args2) {
|
|
|
7142
7324
|
// src/cli/commands/smoke-test.ts
|
|
7143
7325
|
var import_child_process2 = require("child_process");
|
|
7144
7326
|
var http3 = __toESM(require("http"));
|
|
7145
|
-
var
|
|
7146
|
-
var
|
|
7327
|
+
var fs16 = __toESM(require("fs"));
|
|
7328
|
+
var path15 = __toESM(require("path"));
|
|
7147
7329
|
var SMOKE_TEST_PORT = 3456;
|
|
7148
7330
|
var HEALTH_CHECK_INTERVAL_MS = 500;
|
|
7149
7331
|
var HEALTH_CHECK_MAX_RETRIES = 30;
|
|
@@ -7174,13 +7356,13 @@ WHAT IT DOES
|
|
|
7174
7356
|
6. Exits with code 0 (success) or 1 (failure)
|
|
7175
7357
|
`);
|
|
7176
7358
|
}
|
|
7177
|
-
function makeRequest(port,
|
|
7178
|
-
return new Promise((
|
|
7359
|
+
function makeRequest(port, path16, method, body) {
|
|
7360
|
+
return new Promise((resolve10, reject) => {
|
|
7179
7361
|
const postData = body ? JSON.stringify(body) : void 0;
|
|
7180
7362
|
const options = {
|
|
7181
7363
|
hostname: "localhost",
|
|
7182
7364
|
port,
|
|
7183
|
-
path:
|
|
7365
|
+
path: path16,
|
|
7184
7366
|
method,
|
|
7185
7367
|
headers: {
|
|
7186
7368
|
"Content-Type": "application/json",
|
|
@@ -7196,9 +7378,9 @@ function makeRequest(port, path14, method, body) {
|
|
|
7196
7378
|
res.on("end", () => {
|
|
7197
7379
|
try {
|
|
7198
7380
|
const parsed = data ? JSON.parse(data) : {};
|
|
7199
|
-
|
|
7381
|
+
resolve10({ status: res.statusCode ?? 0, body: parsed });
|
|
7200
7382
|
} catch {
|
|
7201
|
-
|
|
7383
|
+
resolve10({ status: res.statusCode ?? 0, body: data });
|
|
7202
7384
|
}
|
|
7203
7385
|
});
|
|
7204
7386
|
});
|
|
@@ -7218,7 +7400,7 @@ async function waitForHealth(port) {
|
|
|
7218
7400
|
}
|
|
7219
7401
|
} catch {
|
|
7220
7402
|
}
|
|
7221
|
-
await new Promise((
|
|
7403
|
+
await new Promise((resolve10) => setTimeout(resolve10, HEALTH_CHECK_INTERVAL_MS));
|
|
7222
7404
|
}
|
|
7223
7405
|
return false;
|
|
7224
7406
|
}
|
|
@@ -7268,8 +7450,8 @@ async function smokeTestCommand(args2) {
|
|
|
7268
7450
|
const cwd = process.cwd();
|
|
7269
7451
|
let configPath = null;
|
|
7270
7452
|
for (const name of CONFIG_FILE_NAMES) {
|
|
7271
|
-
const testPath =
|
|
7272
|
-
if (
|
|
7453
|
+
const testPath = path15.join(cwd, name);
|
|
7454
|
+
if (fs16.existsSync(testPath)) {
|
|
7273
7455
|
configPath = testPath;
|
|
7274
7456
|
break;
|
|
7275
7457
|
}
|
|
@@ -7285,10 +7467,10 @@ async function smokeTestCommand(args2) {
|
|
|
7285
7467
|
}
|
|
7286
7468
|
const serverExt = computeLayer === "serverless" ? "mjs" : "js";
|
|
7287
7469
|
let serverPath = `dist/server/mcp_server.${serverExt}`;
|
|
7288
|
-
if (!
|
|
7470
|
+
if (!fs16.existsSync(serverPath)) {
|
|
7289
7471
|
const fallbackExt = serverExt === "mjs" ? "js" : "mjs";
|
|
7290
7472
|
const fallbackPath = `dist/server/mcp_server.${fallbackExt}`;
|
|
7291
|
-
if (
|
|
7473
|
+
if (fs16.existsSync(fallbackPath)) {
|
|
7292
7474
|
console.warn(`[SmokeTest] Warning: Expected ${serverPath} but found ${fallbackPath}`);
|
|
7293
7475
|
console.warn(`[SmokeTest] Using ${fallbackPath} instead`);
|
|
7294
7476
|
serverPath = fallbackPath;
|
|
@@ -7349,7 +7531,7 @@ async function smokeTestCommand(args2) {
|
|
|
7349
7531
|
server2.on("error", (err) => {
|
|
7350
7532
|
console.error(`[SmokeTest] Failed to spawn server: ${err.message}`);
|
|
7351
7533
|
});
|
|
7352
|
-
await new Promise((
|
|
7534
|
+
await new Promise((resolve10) => setTimeout(resolve10, 1e3));
|
|
7353
7535
|
if (serverExited) {
|
|
7354
7536
|
console.error("[SmokeTest] FAILED: Server crashed during startup");
|
|
7355
7537
|
console.error(`[SmokeTest] Exit code: ${serverExitCode}`);
|
|
@@ -7592,6 +7774,10 @@ async function main() {
|
|
|
7592
7774
|
await configCommand(args.slice(1));
|
|
7593
7775
|
return;
|
|
7594
7776
|
}
|
|
7777
|
+
if (command === "config:export") {
|
|
7778
|
+
await configExportCommand(args.slice(1));
|
|
7779
|
+
return;
|
|
7780
|
+
}
|
|
7595
7781
|
if (command === "invoke") {
|
|
7596
7782
|
await invokeRemoteCommand(args.slice(1));
|
|
7597
7783
|
return;
|