skedyul 1.2.50 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli/index.js CHANGED
@@ -2644,8 +2644,8 @@ async function toolsCommand(args2) {
2644
2644
  }
2645
2645
 
2646
2646
  // src/cli/commands/serve.ts
2647
- var fs8 = __toESM(require("fs"));
2648
- var path8 = __toESM(require("path"));
2647
+ var fs9 = __toESM(require("fs"));
2648
+ var path9 = __toESM(require("path"));
2649
2649
  init_utils();
2650
2650
 
2651
2651
  // src/server/index.ts
@@ -2696,6 +2696,16 @@ var CoreApiService = class {
2696
2696
  };
2697
2697
  var coreApiService = new CoreApiService();
2698
2698
 
2699
+ // src/ratelimit/config-loader.ts
2700
+ var fs7 = __toESM(require("fs"));
2701
+ var path7 = __toESM(require("path"));
2702
+ var cachedRuntimeQueues = null;
2703
+ var registeredServerConfig = null;
2704
+ function registerQueueConfig(config) {
2705
+ registeredServerConfig = config;
2706
+ cachedRuntimeQueues = config.queues ?? null;
2707
+ }
2708
+
2699
2709
  // src/server/utils/schema.ts
2700
2710
  var z4 = __toESM(require("zod"));
2701
2711
  function normalizeBilling(billing) {
@@ -2862,6 +2872,14 @@ function buildToolCallErrorOutput(result) {
2862
2872
  };
2863
2873
  }
2864
2874
 
2875
+ // src/ratelimit/context.ts
2876
+ var import_async_hooks2 = require("async_hooks");
2877
+ var executionContextStorage = new import_async_hooks2.AsyncLocalStorage();
2878
+ var activeOperationStorage = new import_async_hooks2.AsyncLocalStorage();
2879
+ function runWithRateLimitExecutionContext(ctx, fn) {
2880
+ return executionContextStorage.run(ctx, fn);
2881
+ }
2882
+
2865
2883
  // src/errors.ts
2866
2884
  var InstallError = class extends Error {
2867
2885
  // Optional: which field caused the error
@@ -2881,8 +2899,8 @@ var AppAuthInvalidError = class extends Error {
2881
2899
  };
2882
2900
 
2883
2901
  // src/server/context-logger.ts
2884
- var import_async_hooks2 = require("async_hooks");
2885
- var logContextStorage = new import_async_hooks2.AsyncLocalStorage();
2902
+ var import_async_hooks3 = require("async_hooks");
2903
+ var logContextStorage = new import_async_hooks3.AsyncLocalStorage();
2886
2904
  function runWithLogContext(context, fn) {
2887
2905
  return logContextStorage.run(context, fn);
2888
2906
  }
@@ -3075,9 +3093,17 @@ function createCallToolHandler(registry, state, onMaxRequests) {
3075
3093
  baseUrl: toolEnv.SKEDYUL_API_URL ?? "",
3076
3094
  apiToken: toolEnv.SKEDYUL_API_TOKEN ?? ""
3077
3095
  };
3096
+ const rateLimitContext = {
3097
+ app,
3098
+ appInstallationId: trigger === "provision" ? void 0 : rawContext.appInstallationId,
3099
+ invocation,
3100
+ isProvisionContext: trigger === "provision"
3101
+ };
3078
3102
  const functionResult = await runWithConfig(requestConfig, async () => {
3079
- return await runWithLogContext({ invocation }, async () => {
3080
- return await fn(inputs, executionContext);
3103
+ return await runWithRateLimitExecutionContext(rateLimitContext, async () => {
3104
+ return await runWithLogContext({ invocation }, async () => {
3105
+ return await fn(inputs, executionContext);
3106
+ });
3081
3107
  });
3082
3108
  });
3083
3109
  const billing = normalizeBilling(functionResult.billing);
@@ -3214,7 +3240,7 @@ function printStartupLog(config, tools, port) {
3214
3240
 
3215
3241
  // src/server/route-handlers/adapters.ts
3216
3242
  function fromLambdaEvent(event2) {
3217
- const path23 = event2.path || event2.rawPath || "/";
3243
+ const path24 = event2.path || event2.rawPath || "/";
3218
3244
  const method = event2.httpMethod || event2.requestContext?.http?.method || "POST";
3219
3245
  const forwardedProto = event2.headers?.["x-forwarded-proto"] ?? event2.headers?.["X-Forwarded-Proto"];
3220
3246
  const protocol = forwardedProto ?? "https";
@@ -3222,9 +3248,9 @@ function fromLambdaEvent(event2) {
3222
3248
  const queryString = event2.queryStringParameters ? "?" + new URLSearchParams(
3223
3249
  event2.queryStringParameters
3224
3250
  ).toString() : "";
3225
- const url = `${protocol}://${host}${path23}${queryString}`;
3251
+ const url = `${protocol}://${host}${path24}${queryString}`;
3226
3252
  return {
3227
- path: path23,
3253
+ path: path24,
3228
3254
  method,
3229
3255
  headers: event2.headers,
3230
3256
  query: event2.queryStringParameters ?? {},
@@ -3306,8 +3332,8 @@ function parseBodyByContentType(req) {
3306
3332
  }
3307
3333
 
3308
3334
  // src/server/route-handlers/handlers.ts
3309
- var fs7 = __toESM(require("fs"));
3310
- var path7 = __toESM(require("path"));
3335
+ var fs8 = __toESM(require("fs"));
3336
+ var path8 = __toESM(require("path"));
3311
3337
 
3312
3338
  // src/server/core-api-handler.ts
3313
3339
  async function handleCoreMethod(method, params) {
@@ -3475,7 +3501,8 @@ function serializeConfig(config) {
3475
3501
  type: w.type ?? "WEBHOOK"
3476
3502
  })) : [],
3477
3503
  provision: isProvisionConfig(config.provision) ? config.provision : void 0,
3478
- agents: config.agents
3504
+ agents: config.agents,
3505
+ queues: config.queues
3479
3506
  };
3480
3507
  }
3481
3508
  function isProvisionConfig(value) {
@@ -3771,7 +3798,7 @@ async function handleOAuthCallback(parsedBody, hooks) {
3771
3798
  }
3772
3799
 
3773
3800
  // src/server/handlers/webhook-handler.ts
3774
- function parseWebhookRequest(parsedBody, method, url, path23, headers, query, rawBody, appIdHeader, appVersionIdHeader) {
3801
+ function parseWebhookRequest(parsedBody, method, url, path24, headers, query, rawBody, appIdHeader, appVersionIdHeader) {
3775
3802
  const isEnvelope = typeof parsedBody === "object" && parsedBody !== null && "env" in parsedBody && "request" in parsedBody && "context" in parsedBody;
3776
3803
  if (isEnvelope) {
3777
3804
  const envelope = parsedBody;
@@ -3825,7 +3852,7 @@ function parseWebhookRequest(parsedBody, method, url, path23, headers, query, ra
3825
3852
  const webhookRequest = {
3826
3853
  method,
3827
3854
  url,
3828
- path: path23,
3855
+ path: path24,
3829
3856
  headers,
3830
3857
  query,
3831
3858
  body: parsedBody,
@@ -3883,7 +3910,7 @@ function isMethodAllowed(webhookRegistry, handle, method) {
3883
3910
 
3884
3911
  // src/server/route-handlers/handlers.ts
3885
3912
  function getConfigFilePath() {
3886
- return process.env.LAMBDA_TASK_ROOT ? path7.join(process.env.LAMBDA_TASK_ROOT, ".skedyul", "config.json") : ".skedyul/config.json";
3913
+ return process.env.LAMBDA_TASK_ROOT ? path8.join(process.env.LAMBDA_TASK_ROOT, ".skedyul", "config.json") : ".skedyul/config.json";
3887
3914
  }
3888
3915
  function findToolInRegistry(registry, toolName) {
3889
3916
  for (const [key, t] of Object.entries(registry)) {
@@ -3922,8 +3949,8 @@ function handleHealthRoute(ctx) {
3922
3949
  function handleConfigRoute(ctx) {
3923
3950
  const configFilePath = getConfigFilePath();
3924
3951
  try {
3925
- if (fs7.existsSync(configFilePath)) {
3926
- const fileConfig = JSON.parse(fs7.readFileSync(configFilePath, "utf-8"));
3952
+ if (fs8.existsSync(configFilePath)) {
3953
+ const fileConfig = JSON.parse(fs8.readFileSync(configFilePath, "utf-8"));
3927
3954
  return { status: 200, body: fileConfig };
3928
3955
  }
3929
3956
  } catch (err) {
@@ -4608,6 +4635,7 @@ function createServerlessInstance(config, tools, callTool, state, mcpServer) {
4608
4635
  installContextLogger();
4609
4636
  function createSkedyulServer(config) {
4610
4637
  mergeRuntimeEnv();
4638
+ registerQueueConfig(config);
4611
4639
  const registry = config.tools;
4612
4640
  const webhookRegistry = config.webhooks;
4613
4641
  if (config.coreApi?.service) {
@@ -5097,16 +5125,16 @@ function writeServeState(port, workplace) {
5097
5125
  workplace,
5098
5126
  startedAt: (/* @__PURE__ */ new Date()).toISOString()
5099
5127
  };
5100
- const statePath = path8.join(process.cwd(), SERVE_STATE_FILE);
5101
- fs8.writeFileSync(statePath, JSON.stringify(state, null, 2));
5128
+ const statePath = path9.join(process.cwd(), SERVE_STATE_FILE);
5129
+ fs9.writeFileSync(statePath, JSON.stringify(state, null, 2));
5102
5130
  } catch {
5103
5131
  }
5104
5132
  }
5105
5133
  function removeServeState() {
5106
5134
  try {
5107
- const statePath = path8.join(process.cwd(), SERVE_STATE_FILE);
5108
- if (fs8.existsSync(statePath)) {
5109
- fs8.unlinkSync(statePath);
5135
+ const statePath = path9.join(process.cwd(), SERVE_STATE_FILE);
5136
+ if (fs9.existsSync(statePath)) {
5137
+ fs9.unlinkSync(statePath);
5110
5138
  }
5111
5139
  } catch {
5112
5140
  }
@@ -5774,13 +5802,13 @@ Press Ctrl+C to stop`);
5774
5802
  }
5775
5803
 
5776
5804
  // src/cli/commands/validate.ts
5777
- var fs12 = __toESM(require("fs"));
5778
- var path12 = __toESM(require("path"));
5805
+ var fs13 = __toESM(require("fs"));
5806
+ var path13 = __toESM(require("path"));
5779
5807
  init_utils();
5780
5808
 
5781
5809
  // src/config/loader.ts
5782
- var fs9 = __toESM(require("fs"));
5783
- var path9 = __toESM(require("path"));
5810
+ var fs10 = __toESM(require("fs"));
5811
+ var path10 = __toESM(require("path"));
5784
5812
  var os2 = __toESM(require("os"));
5785
5813
  var CONFIG_FILE_NAMES = [
5786
5814
  "skedyul.config.ts",
@@ -5789,13 +5817,13 @@ var CONFIG_FILE_NAMES = [
5789
5817
  "skedyul.config.cjs"
5790
5818
  ];
5791
5819
  async function transpileTypeScript(filePath) {
5792
- const content = fs9.readFileSync(filePath, "utf-8");
5793
- const configDir = path9.dirname(path9.resolve(filePath));
5820
+ const content = fs10.readFileSync(filePath, "utf-8");
5821
+ const configDir = path10.dirname(path10.resolve(filePath));
5794
5822
  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*$/, "}");
5795
5823
  transpiled = transpiled.replace(
5796
5824
  /import\s+(\w+)\s+from\s+['"](\.[^'"]+)['"]\s*(?:with\s*\{[^}]*\})?/g,
5797
5825
  (match, varName, relativePath) => {
5798
- const absolutePath = path9.resolve(configDir, relativePath);
5826
+ const absolutePath = path10.resolve(configDir, relativePath);
5799
5827
  return `const ${varName} = require('${absolutePath.replace(/\\/g, "/")}')`;
5800
5828
  }
5801
5829
  );
@@ -5803,8 +5831,8 @@ async function transpileTypeScript(filePath) {
5803
5831
  return transpiled;
5804
5832
  }
5805
5833
  async function loadConfig(configPath) {
5806
- const absolutePath = path9.resolve(configPath);
5807
- if (!fs9.existsSync(absolutePath)) {
5834
+ const absolutePath = path10.resolve(configPath);
5835
+ if (!fs10.existsSync(absolutePath)) {
5808
5836
  throw new Error(`Config file not found: ${absolutePath}`);
5809
5837
  }
5810
5838
  const isTypeScript = absolutePath.endsWith(".ts");
@@ -5813,8 +5841,8 @@ async function loadConfig(configPath) {
5813
5841
  if (isTypeScript) {
5814
5842
  const transpiled = await transpileTypeScript(absolutePath);
5815
5843
  const tempDir = os2.tmpdir();
5816
- const tempFile = path9.join(tempDir, `skedyul-config-${Date.now()}.cjs`);
5817
- fs9.writeFileSync(tempFile, transpiled);
5844
+ const tempFile = path10.join(tempDir, `skedyul-config-${Date.now()}.cjs`);
5845
+ fs10.writeFileSync(tempFile, transpiled);
5818
5846
  moduleToLoad = tempFile;
5819
5847
  try {
5820
5848
  const module3 = require(moduleToLoad);
@@ -5828,7 +5856,7 @@ async function loadConfig(configPath) {
5828
5856
  return config2;
5829
5857
  } finally {
5830
5858
  try {
5831
- fs9.unlinkSync(tempFile);
5859
+ fs10.unlinkSync(tempFile);
5832
5860
  } catch {
5833
5861
  }
5834
5862
  }
@@ -5863,8 +5891,8 @@ function validateConfig(config) {
5863
5891
  }
5864
5892
 
5865
5893
  // src/config/schema-loader.ts
5866
- var fs10 = __toESM(require("fs"));
5867
- var path10 = __toESM(require("path"));
5894
+ var fs11 = __toESM(require("fs"));
5895
+ var path11 = __toESM(require("path"));
5868
5896
  var os3 = __toESM(require("os"));
5869
5897
 
5870
5898
  // src/schemas/crm-schema.ts
@@ -6017,39 +6045,39 @@ function validateCRMSchema(data) {
6017
6045
 
6018
6046
  // src/config/schema-loader.ts
6019
6047
  async function transpileSchemaTypeScript(filePath) {
6020
- const content = fs10.readFileSync(filePath, "utf-8");
6048
+ const content = fs11.readFileSync(filePath, "utf-8");
6021
6049
  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*$/, "}");
6022
6050
  return transpiled;
6023
6051
  }
6024
6052
  async function loadSchema(schemaPath, options = {}) {
6025
6053
  const { validate = true } = options;
6026
- const absolutePath = path10.resolve(schemaPath);
6027
- if (!fs10.existsSync(absolutePath)) {
6054
+ const absolutePath = path11.resolve(schemaPath);
6055
+ if (!fs11.existsSync(absolutePath)) {
6028
6056
  throw new Error(`Schema file not found: ${absolutePath}`);
6029
6057
  }
6030
6058
  const isTypeScript = absolutePath.endsWith(".ts");
6031
6059
  const isJson = absolutePath.endsWith(".json");
6032
6060
  if (!isTypeScript && !isJson) {
6033
6061
  throw new Error(
6034
- `Unsupported schema file format: ${path10.extname(absolutePath)}. Use .schema.ts or .schema.json`
6062
+ `Unsupported schema file format: ${path11.extname(absolutePath)}. Use .schema.ts or .schema.json`
6035
6063
  );
6036
6064
  }
6037
6065
  let rawSchema;
6038
6066
  try {
6039
6067
  if (isJson) {
6040
- const content = fs10.readFileSync(absolutePath, "utf-8");
6068
+ const content = fs11.readFileSync(absolutePath, "utf-8");
6041
6069
  rawSchema = JSON.parse(content);
6042
6070
  } else {
6043
6071
  const transpiled = await transpileSchemaTypeScript(absolutePath);
6044
6072
  const tempDir = os3.tmpdir();
6045
- const tempFile = path10.join(tempDir, `skedyul-schema-${Date.now()}.cjs`);
6046
- fs10.writeFileSync(tempFile, transpiled);
6073
+ const tempFile = path11.join(tempDir, `skedyul-schema-${Date.now()}.cjs`);
6074
+ fs11.writeFileSync(tempFile, transpiled);
6047
6075
  try {
6048
6076
  const module2 = require(tempFile);
6049
6077
  rawSchema = module2.default || module2;
6050
6078
  } finally {
6051
6079
  try {
6052
- fs10.unlinkSync(tempFile);
6080
+ fs11.unlinkSync(tempFile);
6053
6081
  } catch {
6054
6082
  }
6055
6083
  }
@@ -6094,10 +6122,10 @@ export default defineSchema(${jsonContent})
6094
6122
  `;
6095
6123
  }
6096
6124
  async function saveSchema(schema, outputPath, options = {}) {
6097
- const absolutePath = path10.resolve(outputPath);
6125
+ const absolutePath = path11.resolve(outputPath);
6098
6126
  const isTypeScript = absolutePath.endsWith(".ts");
6099
6127
  const content = isTypeScript ? serializeSchemaToTypeScript(schema) : serializeSchemaToJson(schema, options);
6100
- fs10.writeFileSync(absolutePath, content, "utf-8");
6128
+ fs11.writeFileSync(absolutePath, content, "utf-8");
6101
6129
  }
6102
6130
  var FIELD_TYPE_MAP = {
6103
6131
  string: "STRING",
@@ -6244,8 +6272,8 @@ function transformToBackendSchema(schema) {
6244
6272
  }
6245
6273
 
6246
6274
  // src/config/resolver.ts
6247
- var fs11 = __toESM(require("fs"));
6248
- var path11 = __toESM(require("path"));
6275
+ var fs12 = __toESM(require("fs"));
6276
+ var path12 = __toESM(require("path"));
6249
6277
  async function loadConfigModule(absolutePath) {
6250
6278
  if (absolutePath.endsWith(".ts")) {
6251
6279
  const altPaths = [
@@ -6254,7 +6282,7 @@ async function loadConfigModule(absolutePath) {
6254
6282
  absolutePath.replace(".ts", ".js")
6255
6283
  ];
6256
6284
  for (const altPath of altPaths) {
6257
- if (fs11.existsSync(altPath)) {
6285
+ if (fs12.existsSync(altPath)) {
6258
6286
  return await import(altPath);
6259
6287
  }
6260
6288
  }
@@ -6271,7 +6299,7 @@ async function loadConfigModule(absolutePath) {
6271
6299
  return await import(absolutePath);
6272
6300
  }
6273
6301
  async function loadAndResolveConfig(configPath) {
6274
- const absolutePath = path11.resolve(configPath);
6302
+ const absolutePath = path12.resolve(configPath);
6275
6303
  const module2 = await loadConfigModule(absolutePath);
6276
6304
  const config = module2.default;
6277
6305
  if (!config || typeof config !== "object") {
@@ -6334,7 +6362,8 @@ function serializeResolvedConfig(config) {
6334
6362
  type: w.type ?? "WEBHOOK"
6335
6363
  })) : [],
6336
6364
  provision: config.provision,
6337
- agents: config.agents
6365
+ agents: config.agents,
6366
+ queues: config.queues
6338
6367
  };
6339
6368
  }
6340
6369
 
@@ -6375,8 +6404,8 @@ Examples:
6375
6404
  }
6376
6405
  function findConfigFile2(startDir) {
6377
6406
  for (const fileName of CONFIG_FILE_NAMES) {
6378
- const filePath = path12.join(startDir, fileName);
6379
- if (fs12.existsSync(filePath)) {
6407
+ const filePath = path13.join(startDir, fileName);
6408
+ if (fs13.existsSync(filePath)) {
6380
6409
  return filePath;
6381
6410
  }
6382
6411
  }
@@ -6410,9 +6439,9 @@ async function validateCommand(args2) {
6410
6439
  }
6411
6440
  configPath = foundConfig;
6412
6441
  } else {
6413
- configPath = path12.resolve(process.cwd(), configPath);
6442
+ configPath = path13.resolve(process.cwd(), configPath);
6414
6443
  }
6415
- if (!fs12.existsSync(configPath)) {
6444
+ if (!fs13.existsSync(configPath)) {
6416
6445
  const result2 = {
6417
6446
  valid: false,
6418
6447
  configPath,
@@ -6457,8 +6486,8 @@ async function validateCommand(args2) {
6457
6486
  if (provision?.workflows) {
6458
6487
  for (const workflow of provision.workflows) {
6459
6488
  if (workflow.path) {
6460
- const absoluteWorkflowPath = path12.resolve(path12.dirname(configPath), workflow.path);
6461
- if (!fs12.existsSync(absoluteWorkflowPath)) {
6489
+ const absoluteWorkflowPath = path13.resolve(path13.dirname(configPath), workflow.path);
6490
+ if (!fs13.existsSync(absoluteWorkflowPath)) {
6462
6491
  warnings.push(`Workflow file not found: ${workflow.path}`);
6463
6492
  }
6464
6493
  }
@@ -6553,8 +6582,8 @@ async function validateCommand(args2) {
6553
6582
  }
6554
6583
 
6555
6584
  // src/cli/commands/diff.ts
6556
- var fs13 = __toESM(require("fs"));
6557
- var path13 = __toESM(require("path"));
6585
+ var fs14 = __toESM(require("fs"));
6586
+ var path14 = __toESM(require("path"));
6558
6587
  init_utils();
6559
6588
  function printHelp6() {
6560
6589
  console.log(`
@@ -6587,8 +6616,8 @@ Examples:
6587
6616
  }
6588
6617
  function findConfigFile3(startDir) {
6589
6618
  for (const fileName of CONFIG_FILE_NAMES) {
6590
- const filePath = path13.join(startDir, fileName);
6591
- if (fs13.existsSync(filePath)) {
6619
+ const filePath = path14.join(startDir, fileName);
6620
+ if (fs14.existsSync(filePath)) {
6592
6621
  return filePath;
6593
6622
  }
6594
6623
  }
@@ -6644,9 +6673,9 @@ async function diffCommand(args2) {
6644
6673
  }
6645
6674
  configPath = foundConfig;
6646
6675
  } else {
6647
- configPath = path13.resolve(process.cwd(), configPath);
6676
+ configPath = path14.resolve(process.cwd(), configPath);
6648
6677
  }
6649
- if (!fs13.existsSync(configPath)) {
6678
+ if (!fs14.existsSync(configPath)) {
6650
6679
  if (jsonOutput) {
6651
6680
  console.log(JSON.stringify({ error: `Config file not found: ${configPath}` }));
6652
6681
  } else {
@@ -6688,7 +6717,7 @@ async function diffCommand(args2) {
6688
6717
  const registryPath = flags.registry || flags.r;
6689
6718
  if (registryPath) {
6690
6719
  try {
6691
- const registry = await loadRegistry(path13.resolve(process.cwd(), registryPath));
6720
+ const registry = await loadRegistry(path14.resolve(process.cwd(), registryPath));
6692
6721
  const toolNames = Object.values(registry).map((t) => t.name);
6693
6722
  toolsDiff = {
6694
6723
  added: toolNames,
@@ -6761,8 +6790,8 @@ async function diffCommand(args2) {
6761
6790
  }
6762
6791
 
6763
6792
  // src/cli/commands/deploy.ts
6764
- var fs14 = __toESM(require("fs"));
6765
- var path14 = __toESM(require("path"));
6793
+ var fs15 = __toESM(require("fs"));
6794
+ var path15 = __toESM(require("path"));
6766
6795
  var readline3 = __toESM(require("readline"));
6767
6796
  init_utils();
6768
6797
  function printHelp7() {
@@ -6798,8 +6827,8 @@ Examples:
6798
6827
  }
6799
6828
  function findConfigFile4(startDir) {
6800
6829
  for (const fileName of CONFIG_FILE_NAMES) {
6801
- const filePath = path14.join(startDir, fileName);
6802
- if (fs14.existsSync(filePath)) {
6830
+ const filePath = path15.join(startDir, fileName);
6831
+ if (fs15.existsSync(filePath)) {
6803
6832
  return filePath;
6804
6833
  }
6805
6834
  }
@@ -6913,9 +6942,9 @@ async function deployCommand(args2) {
6913
6942
  }
6914
6943
  configPath = foundConfig;
6915
6944
  } else {
6916
- configPath = path14.resolve(process.cwd(), configPath);
6945
+ configPath = path15.resolve(process.cwd(), configPath);
6917
6946
  }
6918
- if (!fs14.existsSync(configPath)) {
6947
+ if (!fs15.existsSync(configPath)) {
6919
6948
  if (jsonOutput) {
6920
6949
  console.log(JSON.stringify({ error: `Config file not found: ${configPath}` }));
6921
6950
  } else {
@@ -7232,8 +7261,8 @@ async function logoutCommand(args2) {
7232
7261
  }
7233
7262
 
7234
7263
  // src/cli/commands/auth/status.ts
7235
- var fs15 = __toESM(require("fs"));
7236
- var path15 = __toESM(require("path"));
7264
+ var fs16 = __toESM(require("fs"));
7265
+ var path16 = __toESM(require("path"));
7237
7266
  init_utils();
7238
7267
  function printHelp10() {
7239
7268
  console.log(`
@@ -7307,17 +7336,17 @@ async function statusCommand(args2) {
7307
7336
  console.log("");
7308
7337
  console.log(" * = active profile");
7309
7338
  }
7310
- const linksDir = path15.join(process.cwd(), ".skedyul", "links");
7339
+ const linksDir = path16.join(process.cwd(), ".skedyul", "links");
7311
7340
  console.log("");
7312
7341
  console.log("LINKED WORKPLACES (this project)");
7313
7342
  console.log("\u2500".repeat(60));
7314
- if (fs15.existsSync(linksDir)) {
7315
- const linkFiles = fs15.readdirSync(linksDir).filter((f) => f.endsWith(".json"));
7343
+ if (fs16.existsSync(linksDir)) {
7344
+ const linkFiles = fs16.readdirSync(linksDir).filter((f) => f.endsWith(".json"));
7316
7345
  if (linkFiles.length > 0) {
7317
7346
  for (const file2 of linkFiles) {
7318
7347
  const subdomain = file2.replace(".json", "");
7319
7348
  try {
7320
- const content = fs15.readFileSync(path15.join(linksDir, file2), "utf-8");
7349
+ const content = fs16.readFileSync(path16.join(linksDir, file2), "utf-8");
7321
7350
  const link = JSON.parse(content);
7322
7351
  console.log(` - ${subdomain} (${link.appHandle})`);
7323
7352
  } catch {
@@ -7674,8 +7703,8 @@ EXAMPLES
7674
7703
  }
7675
7704
 
7676
7705
  // src/cli/commands/config-export.ts
7677
- var fs16 = __toESM(require("fs"));
7678
- var path16 = __toESM(require("path"));
7706
+ var fs17 = __toESM(require("fs"));
7707
+ var path17 = __toESM(require("path"));
7679
7708
  function printHelp13() {
7680
7709
  console.log(`
7681
7710
  SKEDYUL CONFIG:EXPORT - Export resolved config to JSON
@@ -7721,8 +7750,8 @@ async function configExportCommand(args2) {
7721
7750
  const cwd = process.cwd();
7722
7751
  let configPath = null;
7723
7752
  for (const name of CONFIG_FILE_NAMES) {
7724
- const testPath = path16.join(cwd, name);
7725
- if (fs16.existsSync(testPath)) {
7753
+ const testPath = path17.join(cwd, name);
7754
+ if (fs17.existsSync(testPath)) {
7726
7755
  configPath = testPath;
7727
7756
  break;
7728
7757
  }
@@ -7732,16 +7761,16 @@ async function configExportCommand(args2) {
7732
7761
  console.error("Make sure you are in the root of your integration project.");
7733
7762
  process.exit(1);
7734
7763
  }
7735
- console.log(`Loading config from ${path16.basename(configPath)}...`);
7764
+ console.log(`Loading config from ${path17.basename(configPath)}...`);
7736
7765
  try {
7737
7766
  const resolvedConfig = await loadAndResolveConfig(configPath);
7738
7767
  const serialized = serializeResolvedConfig(resolvedConfig);
7739
- const outputDir = path16.dirname(path16.resolve(cwd, outputPath));
7740
- if (!fs16.existsSync(outputDir)) {
7741
- fs16.mkdirSync(outputDir, { recursive: true });
7768
+ const outputDir = path17.dirname(path17.resolve(cwd, outputPath));
7769
+ if (!fs17.existsSync(outputDir)) {
7770
+ fs17.mkdirSync(outputDir, { recursive: true });
7742
7771
  }
7743
- const fullOutputPath = path16.resolve(cwd, outputPath);
7744
- fs16.writeFileSync(fullOutputPath, JSON.stringify(serialized, null, 2), "utf-8");
7772
+ const fullOutputPath = path17.resolve(cwd, outputPath);
7773
+ fs17.writeFileSync(fullOutputPath, JSON.stringify(serialized, null, 2), "utf-8");
7745
7774
  console.log(``);
7746
7775
  console.log(`Config exported successfully!`);
7747
7776
  console.log(` Output: ${outputPath}`);
@@ -8383,8 +8412,8 @@ async function handleCreateMany(modelHandle, flags) {
8383
8412
  console.error("Usage: skedyul instances create-many <model> --file data.json --workplace <subdomain>");
8384
8413
  process.exit(1);
8385
8414
  }
8386
- const fs23 = await import("fs");
8387
- const fileContent = fs23.readFileSync(filePath, "utf-8");
8415
+ const fs24 = await import("fs");
8416
+ const fileContent = fs24.readFileSync(filePath, "utf-8");
8388
8417
  const items = JSON.parse(fileContent);
8389
8418
  if (!Array.isArray(items)) {
8390
8419
  console.error("Error: File must contain a JSON array of items");
@@ -8411,8 +8440,8 @@ async function handleUpsertMany(modelHandle, flags) {
8411
8440
  console.error("Usage: skedyul instances upsert-many <model> --file data.json --match-field <field> --workplace <subdomain>");
8412
8441
  process.exit(1);
8413
8442
  }
8414
- const fs23 = await import("fs");
8415
- const fileContent = fs23.readFileSync(filePath, "utf-8");
8443
+ const fs24 = await import("fs");
8444
+ const fileContent = fs24.readFileSync(filePath, "utf-8");
8416
8445
  const items = JSON.parse(fileContent);
8417
8446
  if (!Array.isArray(items)) {
8418
8447
  console.error("Error: File must contain a JSON array of items");
@@ -8424,8 +8453,8 @@ async function handleUpsertMany(modelHandle, flags) {
8424
8453
 
8425
8454
  // src/cli/commands/build.ts
8426
8455
  var import_child_process = require("child_process");
8427
- var fs17 = __toESM(require("fs"));
8428
- var path17 = __toESM(require("path"));
8456
+ var fs18 = __toESM(require("fs"));
8457
+ var path18 = __toESM(require("path"));
8429
8458
  function printBuildHelp() {
8430
8459
  console.log(`
8431
8460
  SKEDYUL BUILD - Build your integration
@@ -8494,8 +8523,8 @@ async function buildCommand(args2) {
8494
8523
  const cwd = process.cwd();
8495
8524
  let configPath = null;
8496
8525
  for (const name of CONFIG_FILE_NAMES) {
8497
- const testPath = path17.join(cwd, name);
8498
- if (fs17.existsSync(testPath)) {
8526
+ const testPath = path18.join(cwd, name);
8527
+ if (fs18.existsSync(testPath)) {
8499
8528
  configPath = testPath;
8500
8529
  break;
8501
8530
  }
@@ -8505,8 +8534,8 @@ async function buildCommand(args2) {
8505
8534
  console.error("Make sure you are in the root of your integration project.");
8506
8535
  process.exit(1);
8507
8536
  }
8508
- console.log(`Loading config from ${path17.basename(configPath)}...`);
8509
- const tempConfigPath = path17.join(cwd, ".skedyul-tsup.config.mjs");
8537
+ console.log(`Loading config from ${path18.basename(configPath)}...`);
8538
+ const tempConfigPath = path18.join(cwd, ".skedyul-tsup.config.mjs");
8510
8539
  let createdTempConfig = false;
8511
8540
  try {
8512
8541
  const config = await loadConfig(configPath);
@@ -8515,8 +8544,8 @@ async function buildCommand(args2) {
8515
8544
  const baseExternals = ["skedyul", `skedyul/${computeLayer}`, "zod"];
8516
8545
  const userExternals = config.build && "external" in config.build ? config.build.external ?? [] : [];
8517
8546
  const allExternals = [...baseExternals, ...userExternals];
8518
- const userTsupConfig = path17.join(cwd, "tsup.config.ts");
8519
- const hasUserConfig = fs17.existsSync(userTsupConfig);
8547
+ const userTsupConfig = path18.join(cwd, "tsup.config.ts");
8548
+ const hasUserConfig = fs18.existsSync(userTsupConfig);
8520
8549
  console.log(``);
8521
8550
  console.log(`Building ${config.name ?? "integration"}...`);
8522
8551
  console.log(` Compute layer: ${computeLayer}`);
@@ -8536,7 +8565,7 @@ async function buildCommand(args2) {
8536
8565
  }
8537
8566
  } else {
8538
8567
  const tsupConfigContent = generateTsupConfig(format, allExternals);
8539
- fs17.writeFileSync(tempConfigPath, tsupConfigContent, "utf-8");
8568
+ fs18.writeFileSync(tempConfigPath, tsupConfigContent, "utf-8");
8540
8569
  createdTempConfig = true;
8541
8570
  tsupArgs = [
8542
8571
  "tsup",
@@ -8554,14 +8583,14 @@ async function buildCommand(args2) {
8554
8583
  });
8555
8584
  tsup.on("error", (error) => {
8556
8585
  console.error("Failed to start tsup:", error.message);
8557
- if (createdTempConfig && fs17.existsSync(tempConfigPath)) {
8558
- fs17.unlinkSync(tempConfigPath);
8586
+ if (createdTempConfig && fs18.existsSync(tempConfigPath)) {
8587
+ fs18.unlinkSync(tempConfigPath);
8559
8588
  }
8560
8589
  process.exit(1);
8561
8590
  });
8562
8591
  tsup.on("close", (code) => {
8563
- if (createdTempConfig && fs17.existsSync(tempConfigPath)) {
8564
- fs17.unlinkSync(tempConfigPath);
8592
+ if (createdTempConfig && fs18.existsSync(tempConfigPath)) {
8593
+ fs18.unlinkSync(tempConfigPath);
8565
8594
  }
8566
8595
  if (code === 0) {
8567
8596
  console.log(``);
@@ -8570,8 +8599,8 @@ async function buildCommand(args2) {
8570
8599
  process.exit(code ?? 0);
8571
8600
  });
8572
8601
  } catch (error) {
8573
- if (createdTempConfig && fs17.existsSync(tempConfigPath)) {
8574
- fs17.unlinkSync(tempConfigPath);
8602
+ if (createdTempConfig && fs18.existsSync(tempConfigPath)) {
8603
+ fs18.unlinkSync(tempConfigPath);
8575
8604
  }
8576
8605
  console.error(
8577
8606
  "Error loading config:",
@@ -8584,8 +8613,8 @@ async function buildCommand(args2) {
8584
8613
  // src/cli/commands/smoke-test.ts
8585
8614
  var import_child_process2 = require("child_process");
8586
8615
  var http3 = __toESM(require("http"));
8587
- var fs18 = __toESM(require("fs"));
8588
- var path18 = __toESM(require("path"));
8616
+ var fs19 = __toESM(require("fs"));
8617
+ var path19 = __toESM(require("path"));
8589
8618
  var SMOKE_TEST_PORT = 3456;
8590
8619
  var HEALTH_CHECK_INTERVAL_MS = 500;
8591
8620
  var HEALTH_CHECK_MAX_RETRIES = 30;
@@ -8616,13 +8645,13 @@ WHAT IT DOES
8616
8645
  6. Exits with code 0 (success) or 1 (failure)
8617
8646
  `);
8618
8647
  }
8619
- function makeRequest(port, path23, method, body) {
8648
+ function makeRequest(port, path24, method, body) {
8620
8649
  return new Promise((resolve15, reject) => {
8621
8650
  const postData = body ? JSON.stringify(body) : void 0;
8622
8651
  const options = {
8623
8652
  hostname: "localhost",
8624
8653
  port,
8625
- path: path23,
8654
+ path: path24,
8626
8655
  method,
8627
8656
  headers: {
8628
8657
  "Content-Type": "application/json",
@@ -8710,8 +8739,8 @@ async function smokeTestCommand(args2) {
8710
8739
  const cwd = process.cwd();
8711
8740
  let configPath = null;
8712
8741
  for (const name of CONFIG_FILE_NAMES) {
8713
- const testPath = path18.join(cwd, name);
8714
- if (fs18.existsSync(testPath)) {
8742
+ const testPath = path19.join(cwd, name);
8743
+ if (fs19.existsSync(testPath)) {
8715
8744
  configPath = testPath;
8716
8745
  break;
8717
8746
  }
@@ -8727,10 +8756,10 @@ async function smokeTestCommand(args2) {
8727
8756
  }
8728
8757
  const serverExt = computeLayer === "serverless" ? "mjs" : "js";
8729
8758
  let serverPath = `dist/server/mcp_server.${serverExt}`;
8730
- if (!fs18.existsSync(serverPath)) {
8759
+ if (!fs19.existsSync(serverPath)) {
8731
8760
  const fallbackExt = serverExt === "mjs" ? "js" : "mjs";
8732
8761
  const fallbackPath = `dist/server/mcp_server.${fallbackExt}`;
8733
- if (fs18.existsSync(fallbackPath)) {
8762
+ if (fs19.existsSync(fallbackPath)) {
8734
8763
  console.warn(`[SmokeTest] Warning: Expected ${serverPath} but found ${fallbackPath}`);
8735
8764
  console.warn(`[SmokeTest] Using ${fallbackPath} instead`);
8736
8765
  serverPath = fallbackPath;
@@ -9248,8 +9277,8 @@ async function crmCommand(args2) {
9248
9277
  }
9249
9278
 
9250
9279
  // src/cli/commands/agents.ts
9251
- var fs19 = __toESM(require("fs"));
9252
- var path19 = __toESM(require("path"));
9280
+ var fs20 = __toESM(require("fs"));
9281
+ var path20 = __toESM(require("path"));
9253
9282
  var import_yaml = require("yaml");
9254
9283
  init_utils();
9255
9284
 
@@ -10308,11 +10337,11 @@ function isAgentV3(agent) {
10308
10337
  return "handle" in obj && !("stages" in obj) && !("agents" in obj);
10309
10338
  }
10310
10339
  async function loadAgentFile(filePath) {
10311
- const absolutePath = path19.resolve(filePath);
10312
- if (!fs19.existsSync(absolutePath)) {
10340
+ const absolutePath = path20.resolve(filePath);
10341
+ if (!fs20.existsSync(absolutePath)) {
10313
10342
  throw new Error(`Agent file not found: ${absolutePath}`);
10314
10343
  }
10315
- const content = fs19.readFileSync(absolutePath, "utf-8");
10344
+ const content = fs20.readFileSync(absolutePath, "utf-8");
10316
10345
  const isJson = absolutePath.endsWith(".json");
10317
10346
  const isYaml = absolutePath.endsWith(".yml") || absolutePath.endsWith(".yaml");
10318
10347
  let rawAgent;
@@ -10322,7 +10351,7 @@ async function loadAgentFile(filePath) {
10322
10351
  rawAgent = (0, import_yaml.parse)(content);
10323
10352
  } else {
10324
10353
  throw new Error(
10325
- `Unsupported agent file format: ${path19.extname(absolutePath)}. Use .agent.yml or .agent.json`
10354
+ `Unsupported agent file format: ${path20.extname(absolutePath)}. Use .agent.yml or .agent.json`
10326
10355
  );
10327
10356
  }
10328
10357
  const detectedV3 = isAgentV3(rawAgent);
@@ -10332,8 +10361,8 @@ async function loadAgentFile(filePath) {
10332
10361
  return { agent: v3Result.data, content, isV3: true };
10333
10362
  }
10334
10363
  const errorMessages = v3Result.error.issues.map((e) => {
10335
- const path23 = e.path.length > 0 ? e.path.join(".") : "(root)";
10336
- return ` - ${path23}: ${e.message}`;
10364
+ const path24 = e.path.length > 0 ? e.path.join(".") : "(root)";
10365
+ return ` - ${path24}: ${e.message}`;
10337
10366
  }).join("\n");
10338
10367
  throw new Error(`Agent v3 validation failed:
10339
10368
  ${errorMessages}`);
@@ -10345,8 +10374,8 @@ ${errorMessages}`);
10345
10374
  const v3Result = validateAgentYAMLV3(rawAgent);
10346
10375
  if (!v3Result.success) {
10347
10376
  const errorMessages2 = v3Result.error.issues.map((e) => {
10348
- const path23 = e.path.length > 0 ? e.path.join(".") : "(root)";
10349
- return ` - ${path23}: ${e.message}`;
10377
+ const path24 = e.path.length > 0 ? e.path.join(".") : "(root)";
10378
+ return ` - ${path24}: ${e.message}`;
10350
10379
  }).join("\n");
10351
10380
  throw new Error(`Agent v3 validation failed:
10352
10381
  ${errorMessages2}`);
@@ -11042,14 +11071,14 @@ async function* parseSSEStream(response, debug2 = false) {
11042
11071
  }
11043
11072
 
11044
11073
  // src/cli/utils/mock-context.ts
11045
- var fs20 = __toESM(require("fs"));
11046
- var path20 = __toESM(require("path"));
11074
+ var fs21 = __toESM(require("fs"));
11075
+ var path21 = __toESM(require("path"));
11047
11076
  function loadContext(filePath) {
11048
- const absolutePath = path20.resolve(filePath);
11049
- if (!fs20.existsSync(absolutePath)) {
11077
+ const absolutePath = path21.resolve(filePath);
11078
+ if (!fs21.existsSync(absolutePath)) {
11050
11079
  throw new Error(`Context file not found: ${absolutePath}`);
11051
11080
  }
11052
- const content = fs20.readFileSync(absolutePath, "utf-8");
11081
+ const content = fs21.readFileSync(absolutePath, "utf-8");
11053
11082
  let rawContext;
11054
11083
  try {
11055
11084
  rawContext = JSON.parse(content);
@@ -12135,8 +12164,8 @@ Error: ${input.name} is required`);
12135
12164
  }
12136
12165
 
12137
12166
  // src/cli/commands/skills.ts
12138
- var fs21 = __toESM(require("fs"));
12139
- var path21 = __toESM(require("path"));
12167
+ var fs22 = __toESM(require("fs"));
12168
+ var path22 = __toESM(require("path"));
12140
12169
  var import_yaml2 = require("yaml");
12141
12170
  init_utils();
12142
12171
  function printHelp21() {
@@ -12208,12 +12237,12 @@ async function getWorkplaceToken6(workplaceSubdomain, serverUrl, cliToken) {
12208
12237
  );
12209
12238
  }
12210
12239
  async function loadSkillFile(filePath) {
12211
- const absolutePath = path21.resolve(filePath);
12212
- if (!fs21.existsSync(absolutePath)) {
12240
+ const absolutePath = path22.resolve(filePath);
12241
+ if (!fs22.existsSync(absolutePath)) {
12213
12242
  throw new Error(`File not found: ${absolutePath}`);
12214
12243
  }
12215
- const content = fs21.readFileSync(absolutePath, "utf-8");
12216
- const ext = path21.extname(absolutePath).toLowerCase();
12244
+ const content = fs22.readFileSync(absolutePath, "utf-8");
12245
+ const ext = path22.extname(absolutePath).toLowerCase();
12217
12246
  if (ext !== ".yml" && ext !== ".yaml") {
12218
12247
  throw new Error("Skill file must be a .skill.yml or .skill.yaml file");
12219
12248
  }
@@ -12658,8 +12687,8 @@ async function skillsCommand(args2) {
12658
12687
  }
12659
12688
 
12660
12689
  // src/cli/commands/workflows.ts
12661
- var fs22 = __toESM(require("fs"));
12662
- var path22 = __toESM(require("path"));
12690
+ var fs23 = __toESM(require("fs"));
12691
+ var path23 = __toESM(require("path"));
12663
12692
  var readline7 = __toESM(require("readline"));
12664
12693
  var import_yaml3 = require("yaml");
12665
12694
  init_utils();
@@ -12924,12 +12953,12 @@ async function getWorkplaceToken7(workplaceSubdomain, serverUrl, cliToken) {
12924
12953
  );
12925
12954
  }
12926
12955
  async function loadWorkflowFile(filePath) {
12927
- const absolutePath = path22.resolve(filePath);
12928
- if (!fs22.existsSync(absolutePath)) {
12956
+ const absolutePath = path23.resolve(filePath);
12957
+ if (!fs23.existsSync(absolutePath)) {
12929
12958
  throw new Error(`File not found: ${absolutePath}`);
12930
12959
  }
12931
- const content = fs22.readFileSync(absolutePath, "utf-8");
12932
- const ext = path22.extname(absolutePath).toLowerCase();
12960
+ const content = fs23.readFileSync(absolutePath, "utf-8");
12961
+ const ext = path23.extname(absolutePath).toLowerCase();
12933
12962
  if (ext !== ".yml" && ext !== ".yaml") {
12934
12963
  throw new Error("Workflow file must be a .yml or .yaml file");
12935
12964
  }
@@ -13288,8 +13317,8 @@ async function handlePull2(args2) {
13288
13317
  console.log(JSON.stringify(result, null, 2));
13289
13318
  return;
13290
13319
  }
13291
- const outputPath = path22.resolve(output || `./${handle}.workflow.yml`);
13292
- fs22.writeFileSync(outputPath, result.yaml, "utf-8");
13320
+ const outputPath = path23.resolve(output || `./${handle}.workflow.yml`);
13321
+ fs23.writeFileSync(outputPath, result.yaml, "utf-8");
13293
13322
  console.log(`Saved v${result.version} to ${outputPath}`);
13294
13323
  }
13295
13324
  async function handlePublish3(args2) {