skedyul 1.5.13 → 1.6.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
@@ -377,9 +377,9 @@ function isJsonImport(importPath) {
377
377
  }
378
378
  async function transpileConfigMetadata(configPath) {
379
379
  const esbuild = await import("esbuild");
380
- const absolutePath = path12.resolve(configPath);
381
- const configDir = path12.dirname(absolutePath);
382
- const configBasename = path12.basename(absolutePath);
380
+ const absolutePath = path13.resolve(configPath);
381
+ const configDir = path13.dirname(absolutePath);
382
+ const configBasename = path13.basename(absolutePath);
383
383
  const result = await esbuild.build({
384
384
  absWorkingDir: configDir,
385
385
  entryPoints: [absolutePath],
@@ -394,7 +394,7 @@ async function transpileConfigMetadata(configPath) {
394
394
  name: "prepare-config-entry",
395
395
  setup(build) {
396
396
  build.onLoad({ filter: new RegExp(`/${configBasename.replace(".", "\\.")}$`) }, () => ({
397
- contents: prepareConfigSource(fs12.readFileSync(absolutePath, "utf-8")),
397
+ contents: prepareConfigSource(fs13.readFileSync(absolutePath, "utf-8")),
398
398
  loader: "ts"
399
399
  }));
400
400
  }
@@ -443,12 +443,12 @@ async function transpileConfigMetadata(configPath) {
443
443
  }
444
444
  return result.outputFiles[0].text;
445
445
  }
446
- var fs12, path12, SKEDYUL_SHIM_NAMESPACE, METADATA_STUB_NAMESPACE;
446
+ var fs13, path13, SKEDYUL_SHIM_NAMESPACE, METADATA_STUB_NAMESPACE;
447
447
  var init_transpileConfigMetadata = __esm({
448
448
  "src/config/transpileConfigMetadata.ts"() {
449
449
  "use strict";
450
- fs12 = __toESM(require("fs"));
451
- path12 = __toESM(require("path"));
450
+ fs13 = __toESM(require("fs"));
451
+ path13 = __toESM(require("path"));
452
452
  SKEDYUL_SHIM_NAMESPACE = "skedyul-shim";
453
453
  METADATA_STUB_NAMESPACE = "metadata-stub";
454
454
  }
@@ -1478,10 +1478,11 @@ var instance = {
1478
1478
  * const record = await instance.get('phone_number', 'ins_abc123')
1479
1479
  * ```
1480
1480
  */
1481
- async get(modelHandle, id) {
1481
+ async get(modelHandle, id, options) {
1482
1482
  const { data } = await callCore("instance.get", {
1483
1483
  modelHandle,
1484
- id
1484
+ id,
1485
+ ...options?.includeEnv ? { includeEnv: true } : {}
1485
1486
  });
1486
1487
  return data;
1487
1488
  },
@@ -1498,10 +1499,11 @@ var instance = {
1498
1499
  * })
1499
1500
  * ```
1500
1501
  */
1501
- async create(modelHandle, data) {
1502
+ async create(modelHandle, data, options) {
1502
1503
  const { data: instance2 } = await callCore("instance.create", {
1503
1504
  modelHandle,
1504
- data
1505
+ data,
1506
+ ...options?.env ? { env: options.env } : {}
1505
1507
  });
1506
1508
  return instance2;
1507
1509
  },
@@ -1518,11 +1520,12 @@ var instance = {
1518
1520
  * })
1519
1521
  * ```
1520
1522
  */
1521
- async update(modelHandle, id, data) {
1523
+ async update(modelHandle, id, data, options) {
1522
1524
  const { data: instance2 } = await callCore("instance.update", {
1523
1525
  modelHandle,
1524
1526
  id,
1525
- data
1527
+ data,
1528
+ ...options?.env ? { env: options.env } : {}
1526
1529
  });
1527
1530
  return instance2;
1528
1531
  },
@@ -2734,8 +2737,8 @@ async function toolsCommand(args2) {
2734
2737
  }
2735
2738
 
2736
2739
  // src/cli/commands/serve.ts
2737
- var fs9 = __toESM(require("fs"));
2738
- var path9 = __toESM(require("path"));
2740
+ var fs10 = __toESM(require("fs"));
2741
+ var path10 = __toESM(require("path"));
2739
2742
  init_utils();
2740
2743
 
2741
2744
  // src/server/index.ts
@@ -2796,6 +2799,16 @@ function registerQueueConfig(config) {
2796
2799
  cachedRuntimeQueues = config.queues ?? null;
2797
2800
  }
2798
2801
 
2802
+ // src/sequencer/config-loader.ts
2803
+ var fs8 = __toESM(require("fs"));
2804
+ var path8 = __toESM(require("path"));
2805
+ var cachedRuntimeSequencers = null;
2806
+ var registeredServerConfig2 = null;
2807
+ function registerSequencerConfig(config) {
2808
+ registeredServerConfig2 = config;
2809
+ cachedRuntimeSequencers = config.sequencers ?? null;
2810
+ }
2811
+
2799
2812
  // src/server/utils/schema.ts
2800
2813
  var z4 = __toESM(require("zod"));
2801
2814
  function normalizeBilling(billing) {
@@ -3400,7 +3413,7 @@ function printStartupLog(config, tools, port) {
3400
3413
 
3401
3414
  // src/server/route-handlers/adapters.ts
3402
3415
  function fromLambdaEvent(event2) {
3403
- const path25 = event2.path || event2.rawPath || "/";
3416
+ const path26 = event2.path || event2.rawPath || "/";
3404
3417
  const method = event2.httpMethod || event2.requestContext?.http?.method || "POST";
3405
3418
  const forwardedProto = event2.headers?.["x-forwarded-proto"] ?? event2.headers?.["X-Forwarded-Proto"];
3406
3419
  const protocol = forwardedProto ?? "https";
@@ -3408,9 +3421,9 @@ function fromLambdaEvent(event2) {
3408
3421
  const queryString = event2.queryStringParameters ? "?" + new URLSearchParams(
3409
3422
  event2.queryStringParameters
3410
3423
  ).toString() : "";
3411
- const url = `${protocol}://${host}${path25}${queryString}`;
3424
+ const url = `${protocol}://${host}${path26}${queryString}`;
3412
3425
  return {
3413
- path: path25,
3426
+ path: path26,
3414
3427
  method,
3415
3428
  headers: event2.headers,
3416
3429
  query: event2.queryStringParameters ?? {},
@@ -3492,8 +3505,8 @@ function parseBodyByContentType(req) {
3492
3505
  }
3493
3506
 
3494
3507
  // src/server/route-handlers/handlers.ts
3495
- var fs8 = __toESM(require("fs"));
3496
- var path8 = __toESM(require("path"));
3508
+ var fs9 = __toESM(require("fs"));
3509
+ var path9 = __toESM(require("path"));
3497
3510
 
3498
3511
  // src/server/core-api-handler.ts
3499
3512
  async function handleCoreMethod(method, params) {
@@ -3960,8 +3973,13 @@ async function handleOAuthCallback(parsedBody, hooks) {
3960
3973
  }
3961
3974
  }
3962
3975
 
3976
+ // src/types/webhook.ts
3977
+ function isRuntimeWebhookContext(ctx) {
3978
+ return "appInstallationId" in ctx && ctx.appInstallationId !== void 0;
3979
+ }
3980
+
3963
3981
  // src/server/handlers/webhook-handler.ts
3964
- function parseWebhookRequest(parsedBody, method, url, path25, headers, query, rawBody, appIdHeader, appVersionIdHeader) {
3982
+ function parseWebhookRequest(parsedBody, method, url, path26, headers, query, rawBody, appIdHeader, appVersionIdHeader) {
3965
3983
  const isEnvelope = typeof parsedBody === "object" && parsedBody !== null && "env" in parsedBody && "request" in parsedBody && "context" in parsedBody;
3966
3984
  if (isEnvelope) {
3967
3985
  const envelope = parsedBody;
@@ -4015,7 +4033,7 @@ function parseWebhookRequest(parsedBody, method, url, path25, headers, query, ra
4015
4033
  const webhookRequest = {
4016
4034
  method,
4017
4035
  url,
4018
- path: path25,
4036
+ path: path26,
4019
4037
  headers,
4020
4038
  query,
4021
4039
  body: parsedBody,
@@ -4044,9 +4062,17 @@ async function executeWebhookHandler(handle, webhookRegistry, data) {
4044
4062
  };
4045
4063
  let webhookResponse;
4046
4064
  try {
4065
+ const rateLimitContext = {
4066
+ app: data.webhookContext.app,
4067
+ appInstallationId: isRuntimeWebhookContext(data.webhookContext) ? data.webhookContext.appInstallationId : void 0,
4068
+ invocation: data.invocation,
4069
+ isProvisionContext: !isRuntimeWebhookContext(data.webhookContext)
4070
+ };
4047
4071
  webhookResponse = await runWithLogContext({ invocation: data.invocation }, async () => {
4048
4072
  return await runWithConfig(requestConfig, async () => {
4049
- return await webhookDef.handler(data.webhookRequest, data.webhookContext);
4073
+ return await runWithRateLimitExecutionContext(rateLimitContext, async () => {
4074
+ return await webhookDef.handler(data.webhookRequest, data.webhookContext);
4075
+ });
4050
4076
  });
4051
4077
  });
4052
4078
  } catch (err) {
@@ -4073,7 +4099,7 @@ function isMethodAllowed(webhookRegistry, handle, method) {
4073
4099
 
4074
4100
  // src/server/route-handlers/handlers.ts
4075
4101
  function getConfigFilePath() {
4076
- return process.env.LAMBDA_TASK_ROOT ? path8.join(process.env.LAMBDA_TASK_ROOT, ".skedyul", "config.json") : ".skedyul/config.json";
4102
+ return process.env.LAMBDA_TASK_ROOT ? path9.join(process.env.LAMBDA_TASK_ROOT, ".skedyul", "config.json") : ".skedyul/config.json";
4077
4103
  }
4078
4104
  function findToolInRegistry(registry, toolName) {
4079
4105
  for (const [key, t] of Object.entries(registry)) {
@@ -4112,8 +4138,8 @@ function handleHealthRoute(ctx) {
4112
4138
  function handleConfigRoute(ctx) {
4113
4139
  const configFilePath = getConfigFilePath();
4114
4140
  try {
4115
- if (fs8.existsSync(configFilePath)) {
4116
- const fileConfig = JSON.parse(fs8.readFileSync(configFilePath, "utf-8"));
4141
+ if (fs9.existsSync(configFilePath)) {
4142
+ const fileConfig = JSON.parse(fs9.readFileSync(configFilePath, "utf-8"));
4117
4143
  return { status: 200, body: fileConfig };
4118
4144
  }
4119
4145
  } catch (err) {
@@ -4801,6 +4827,7 @@ installContextLogger();
4801
4827
  function createSkedyulServer(config) {
4802
4828
  mergeRuntimeEnv();
4803
4829
  registerQueueConfig(config);
4830
+ registerSequencerConfig(config);
4804
4831
  const registry = config.tools;
4805
4832
  const webhookRegistry = config.webhooks;
4806
4833
  if (config.coreApi?.service) {
@@ -5290,16 +5317,16 @@ function writeServeState(port, workplace) {
5290
5317
  workplace,
5291
5318
  startedAt: (/* @__PURE__ */ new Date()).toISOString()
5292
5319
  };
5293
- const statePath = path9.join(process.cwd(), SERVE_STATE_FILE);
5294
- fs9.writeFileSync(statePath, JSON.stringify(state, null, 2));
5320
+ const statePath = path10.join(process.cwd(), SERVE_STATE_FILE);
5321
+ fs10.writeFileSync(statePath, JSON.stringify(state, null, 2));
5295
5322
  } catch {
5296
5323
  }
5297
5324
  }
5298
5325
  function removeServeState() {
5299
5326
  try {
5300
- const statePath = path9.join(process.cwd(), SERVE_STATE_FILE);
5301
- if (fs9.existsSync(statePath)) {
5302
- fs9.unlinkSync(statePath);
5327
+ const statePath = path10.join(process.cwd(), SERVE_STATE_FILE);
5328
+ if (fs10.existsSync(statePath)) {
5329
+ fs10.unlinkSync(statePath);
5303
5330
  }
5304
5331
  } catch {
5305
5332
  }
@@ -5967,13 +5994,13 @@ Press Ctrl+C to stop`);
5967
5994
  }
5968
5995
 
5969
5996
  // src/cli/commands/validate.ts
5970
- var fs14 = __toESM(require("fs"));
5971
- var path14 = __toESM(require("path"));
5997
+ var fs15 = __toESM(require("fs"));
5998
+ var path15 = __toESM(require("path"));
5972
5999
  init_utils();
5973
6000
 
5974
6001
  // src/config/schema-loader.ts
5975
- var fs10 = __toESM(require("fs"));
5976
- var path10 = __toESM(require("path"));
6002
+ var fs11 = __toESM(require("fs"));
6003
+ var path11 = __toESM(require("path"));
5977
6004
  var os2 = __toESM(require("os"));
5978
6005
 
5979
6006
  // src/schemas/crm-schema.ts
@@ -6076,6 +6103,8 @@ var CRMPageSchemaZ = import_v42.z.object({
6076
6103
  icon: import_v42.z.string().optional(),
6077
6104
  modelHandle: import_v42.z.string(),
6078
6105
  parentPath: import_v42.z.string().optional(),
6106
+ isDefault: import_v42.z.boolean().optional(),
6107
+ visibility: import_v42.z.enum(["team", "private"]).optional(),
6079
6108
  baseQuery: import_v42.z.unknown().optional(),
6080
6109
  blocks: import_v42.z.array(CRMBlockSchemaZ).optional()
6081
6110
  });
@@ -6126,39 +6155,39 @@ function validateCRMSchema(data) {
6126
6155
 
6127
6156
  // src/config/schema-loader.ts
6128
6157
  async function transpileSchemaTypeScript(filePath) {
6129
- const content = fs10.readFileSync(filePath, "utf-8");
6158
+ const content = fs11.readFileSync(filePath, "utf-8");
6130
6159
  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*$/, "}");
6131
6160
  return transpiled;
6132
6161
  }
6133
6162
  async function loadSchema(schemaPath, options = {}) {
6134
6163
  const { validate = true } = options;
6135
- const absolutePath = path10.resolve(schemaPath);
6136
- if (!fs10.existsSync(absolutePath)) {
6164
+ const absolutePath = path11.resolve(schemaPath);
6165
+ if (!fs11.existsSync(absolutePath)) {
6137
6166
  throw new Error(`Schema file not found: ${absolutePath}`);
6138
6167
  }
6139
6168
  const isTypeScript = absolutePath.endsWith(".ts");
6140
6169
  const isJson = absolutePath.endsWith(".json");
6141
6170
  if (!isTypeScript && !isJson) {
6142
6171
  throw new Error(
6143
- `Unsupported schema file format: ${path10.extname(absolutePath)}. Use .schema.ts or .schema.json`
6172
+ `Unsupported schema file format: ${path11.extname(absolutePath)}. Use .schema.ts or .schema.json`
6144
6173
  );
6145
6174
  }
6146
6175
  let rawSchema;
6147
6176
  try {
6148
6177
  if (isJson) {
6149
- const content = fs10.readFileSync(absolutePath, "utf-8");
6178
+ const content = fs11.readFileSync(absolutePath, "utf-8");
6150
6179
  rawSchema = JSON.parse(content);
6151
6180
  } else {
6152
6181
  const transpiled = await transpileSchemaTypeScript(absolutePath);
6153
6182
  const tempDir = os2.tmpdir();
6154
- const tempFile = path10.join(tempDir, `skedyul-schema-${Date.now()}.cjs`);
6155
- fs10.writeFileSync(tempFile, transpiled);
6183
+ const tempFile = path11.join(tempDir, `skedyul-schema-${Date.now()}.cjs`);
6184
+ fs11.writeFileSync(tempFile, transpiled);
6156
6185
  try {
6157
6186
  const module2 = require(tempFile);
6158
6187
  rawSchema = module2.default || module2;
6159
6188
  } finally {
6160
6189
  try {
6161
- fs10.unlinkSync(tempFile);
6190
+ fs11.unlinkSync(tempFile);
6162
6191
  } catch {
6163
6192
  }
6164
6193
  }
@@ -6203,10 +6232,10 @@ export default defineSchema(${jsonContent})
6203
6232
  `;
6204
6233
  }
6205
6234
  async function saveSchema(schema, outputPath, options = {}) {
6206
- const absolutePath = path10.resolve(outputPath);
6235
+ const absolutePath = path11.resolve(outputPath);
6207
6236
  const isTypeScript = absolutePath.endsWith(".ts");
6208
6237
  const content = isTypeScript ? serializeSchemaToTypeScript(schema) : serializeSchemaToJson(schema, options);
6209
- fs10.writeFileSync(absolutePath, content, "utf-8");
6238
+ fs11.writeFileSync(absolutePath, content, "utf-8");
6210
6239
  }
6211
6240
  var FIELD_TYPE_MAP = {
6212
6241
  string: "STRING",
@@ -6353,8 +6382,8 @@ function transformToBackendSchema(schema) {
6353
6382
  }
6354
6383
 
6355
6384
  // src/config/resolver.ts
6356
- var fs11 = __toESM(require("fs"));
6357
- var path11 = __toESM(require("path"));
6385
+ var fs12 = __toESM(require("fs"));
6386
+ var path12 = __toESM(require("path"));
6358
6387
  async function loadConfigModule(absolutePath) {
6359
6388
  if (absolutePath.endsWith(".ts")) {
6360
6389
  const altPaths = [
@@ -6363,7 +6392,7 @@ async function loadConfigModule(absolutePath) {
6363
6392
  absolutePath.replace(".ts", ".js")
6364
6393
  ];
6365
6394
  for (const altPath of altPaths) {
6366
- if (fs11.existsSync(altPath)) {
6395
+ if (fs12.existsSync(altPath)) {
6367
6396
  return await import(altPath);
6368
6397
  }
6369
6398
  }
@@ -6380,7 +6409,7 @@ async function loadConfigModule(absolutePath) {
6380
6409
  return await import(absolutePath);
6381
6410
  }
6382
6411
  async function loadAndResolveConfig(configPath) {
6383
- const absolutePath = path11.resolve(configPath);
6412
+ const absolutePath = path12.resolve(configPath);
6384
6413
  const module2 = await loadConfigModule(absolutePath);
6385
6414
  const config = module2.default;
6386
6415
  if (!config || typeof config !== "object") {
@@ -6447,7 +6476,8 @@ function serializeResolvedConfig(config) {
6447
6476
  provision: config.provision,
6448
6477
  agents: config.agents,
6449
6478
  events: config.events,
6450
- queues: config.queues
6479
+ queues: config.queues,
6480
+ sequencers: config.sequencers
6451
6481
  };
6452
6482
  }
6453
6483
 
@@ -6462,8 +6492,8 @@ function getAllEnvKeys(config) {
6462
6492
  }
6463
6493
 
6464
6494
  // src/config/loader.ts
6465
- var fs13 = __toESM(require("fs"));
6466
- var path13 = __toESM(require("path"));
6495
+ var fs14 = __toESM(require("fs"));
6496
+ var path14 = __toESM(require("path"));
6467
6497
  var os3 = __toESM(require("os"));
6468
6498
  var CONFIG_FILE_NAMES = [
6469
6499
  "skedyul.config.ts",
@@ -6472,8 +6502,8 @@ var CONFIG_FILE_NAMES = [
6472
6502
  "skedyul.config.cjs"
6473
6503
  ];
6474
6504
  async function loadConfig(configPath) {
6475
- const absolutePath = path13.resolve(configPath);
6476
- if (!fs13.existsSync(absolutePath)) {
6505
+ const absolutePath = path14.resolve(configPath);
6506
+ if (!fs14.existsSync(absolutePath)) {
6477
6507
  throw new Error(`Config file not found: ${absolutePath}`);
6478
6508
  }
6479
6509
  const isTypeScript = absolutePath.endsWith(".ts");
@@ -6482,8 +6512,8 @@ async function loadConfig(configPath) {
6482
6512
  try {
6483
6513
  const { transpileConfigMetadata: transpileConfigMetadata2 } = await Promise.resolve().then(() => (init_transpileConfigMetadata(), transpileConfigMetadata_exports));
6484
6514
  const transpiled = await transpileConfigMetadata2(absolutePath);
6485
- const tempFile = path13.join(os3.tmpdir(), `skedyul-config-${Date.now()}.cjs`);
6486
- fs13.writeFileSync(tempFile, transpiled);
6515
+ const tempFile = path14.join(os3.tmpdir(), `skedyul-config-${Date.now()}.cjs`);
6516
+ fs14.writeFileSync(tempFile, transpiled);
6487
6517
  try {
6488
6518
  const module3 = require(tempFile);
6489
6519
  const config2 = module3.default || module3;
@@ -6496,7 +6526,7 @@ async function loadConfig(configPath) {
6496
6526
  return config2;
6497
6527
  } finally {
6498
6528
  try {
6499
- fs13.unlinkSync(tempFile);
6529
+ fs14.unlinkSync(tempFile);
6500
6530
  } catch {
6501
6531
  }
6502
6532
  }
@@ -6562,8 +6592,8 @@ Examples:
6562
6592
  }
6563
6593
  function findConfigFile2(startDir) {
6564
6594
  for (const fileName of CONFIG_FILE_NAMES) {
6565
- const filePath = path14.join(startDir, fileName);
6566
- if (fs14.existsSync(filePath)) {
6595
+ const filePath = path15.join(startDir, fileName);
6596
+ if (fs15.existsSync(filePath)) {
6567
6597
  return filePath;
6568
6598
  }
6569
6599
  }
@@ -6597,9 +6627,9 @@ async function validateCommand(args2) {
6597
6627
  }
6598
6628
  configPath = foundConfig;
6599
6629
  } else {
6600
- configPath = path14.resolve(process.cwd(), configPath);
6630
+ configPath = path15.resolve(process.cwd(), configPath);
6601
6631
  }
6602
- if (!fs14.existsSync(configPath)) {
6632
+ if (!fs15.existsSync(configPath)) {
6603
6633
  const result2 = {
6604
6634
  valid: false,
6605
6635
  configPath,
@@ -6644,8 +6674,8 @@ async function validateCommand(args2) {
6644
6674
  if (provision?.workflows) {
6645
6675
  for (const workflow of provision.workflows) {
6646
6676
  if (workflow.path) {
6647
- const absoluteWorkflowPath = path14.resolve(path14.dirname(configPath), workflow.path);
6648
- if (!fs14.existsSync(absoluteWorkflowPath)) {
6677
+ const absoluteWorkflowPath = path15.resolve(path15.dirname(configPath), workflow.path);
6678
+ if (!fs15.existsSync(absoluteWorkflowPath)) {
6649
6679
  warnings.push(`Workflow file not found: ${workflow.path}`);
6650
6680
  }
6651
6681
  }
@@ -6740,8 +6770,8 @@ async function validateCommand(args2) {
6740
6770
  }
6741
6771
 
6742
6772
  // src/cli/commands/diff.ts
6743
- var fs15 = __toESM(require("fs"));
6744
- var path15 = __toESM(require("path"));
6773
+ var fs16 = __toESM(require("fs"));
6774
+ var path16 = __toESM(require("path"));
6745
6775
  init_utils();
6746
6776
  function printHelp6() {
6747
6777
  console.log(`
@@ -6774,8 +6804,8 @@ Examples:
6774
6804
  }
6775
6805
  function findConfigFile3(startDir) {
6776
6806
  for (const fileName of CONFIG_FILE_NAMES) {
6777
- const filePath = path15.join(startDir, fileName);
6778
- if (fs15.existsSync(filePath)) {
6807
+ const filePath = path16.join(startDir, fileName);
6808
+ if (fs16.existsSync(filePath)) {
6779
6809
  return filePath;
6780
6810
  }
6781
6811
  }
@@ -6831,9 +6861,9 @@ async function diffCommand(args2) {
6831
6861
  }
6832
6862
  configPath = foundConfig;
6833
6863
  } else {
6834
- configPath = path15.resolve(process.cwd(), configPath);
6864
+ configPath = path16.resolve(process.cwd(), configPath);
6835
6865
  }
6836
- if (!fs15.existsSync(configPath)) {
6866
+ if (!fs16.existsSync(configPath)) {
6837
6867
  if (jsonOutput) {
6838
6868
  console.log(JSON.stringify({ error: `Config file not found: ${configPath}` }));
6839
6869
  } else {
@@ -6875,7 +6905,7 @@ async function diffCommand(args2) {
6875
6905
  const registryPath = flags.registry || flags.r;
6876
6906
  if (registryPath) {
6877
6907
  try {
6878
- const registry = await loadRegistry(path15.resolve(process.cwd(), registryPath));
6908
+ const registry = await loadRegistry(path16.resolve(process.cwd(), registryPath));
6879
6909
  const toolNames = Object.values(registry).map((t) => t.name);
6880
6910
  toolsDiff = {
6881
6911
  added: toolNames,
@@ -6948,8 +6978,8 @@ async function diffCommand(args2) {
6948
6978
  }
6949
6979
 
6950
6980
  // src/cli/commands/deploy.ts
6951
- var fs16 = __toESM(require("fs"));
6952
- var path16 = __toESM(require("path"));
6981
+ var fs17 = __toESM(require("fs"));
6982
+ var path17 = __toESM(require("path"));
6953
6983
  var readline3 = __toESM(require("readline"));
6954
6984
  init_utils();
6955
6985
  function printHelp7() {
@@ -6985,8 +7015,8 @@ Examples:
6985
7015
  }
6986
7016
  function findConfigFile4(startDir) {
6987
7017
  for (const fileName of CONFIG_FILE_NAMES) {
6988
- const filePath = path16.join(startDir, fileName);
6989
- if (fs16.existsSync(filePath)) {
7018
+ const filePath = path17.join(startDir, fileName);
7019
+ if (fs17.existsSync(filePath)) {
6990
7020
  return filePath;
6991
7021
  }
6992
7022
  }
@@ -7100,9 +7130,9 @@ async function deployCommand(args2) {
7100
7130
  }
7101
7131
  configPath = foundConfig;
7102
7132
  } else {
7103
- configPath = path16.resolve(process.cwd(), configPath);
7133
+ configPath = path17.resolve(process.cwd(), configPath);
7104
7134
  }
7105
- if (!fs16.existsSync(configPath)) {
7135
+ if (!fs17.existsSync(configPath)) {
7106
7136
  if (jsonOutput) {
7107
7137
  console.log(JSON.stringify({ error: `Config file not found: ${configPath}` }));
7108
7138
  } else {
@@ -7419,8 +7449,8 @@ async function logoutCommand(args2) {
7419
7449
  }
7420
7450
 
7421
7451
  // src/cli/commands/auth/status.ts
7422
- var fs17 = __toESM(require("fs"));
7423
- var path17 = __toESM(require("path"));
7452
+ var fs18 = __toESM(require("fs"));
7453
+ var path18 = __toESM(require("path"));
7424
7454
  init_utils();
7425
7455
  function printHelp10() {
7426
7456
  console.log(`
@@ -7494,17 +7524,17 @@ async function statusCommand(args2) {
7494
7524
  console.log("");
7495
7525
  console.log(" * = active profile");
7496
7526
  }
7497
- const linksDir = path17.join(process.cwd(), ".skedyul", "links");
7527
+ const linksDir = path18.join(process.cwd(), ".skedyul", "links");
7498
7528
  console.log("");
7499
7529
  console.log("LINKED WORKPLACES (this project)");
7500
7530
  console.log("\u2500".repeat(60));
7501
- if (fs17.existsSync(linksDir)) {
7502
- const linkFiles = fs17.readdirSync(linksDir).filter((f) => f.endsWith(".json"));
7531
+ if (fs18.existsSync(linksDir)) {
7532
+ const linkFiles = fs18.readdirSync(linksDir).filter((f) => f.endsWith(".json"));
7503
7533
  if (linkFiles.length > 0) {
7504
7534
  for (const file2 of linkFiles) {
7505
7535
  const subdomain = file2.replace(".json", "");
7506
7536
  try {
7507
- const content = fs17.readFileSync(path17.join(linksDir, file2), "utf-8");
7537
+ const content = fs18.readFileSync(path18.join(linksDir, file2), "utf-8");
7508
7538
  const link = JSON.parse(content);
7509
7539
  console.log(` - ${subdomain} (${link.appHandle})`);
7510
7540
  } catch {
@@ -7861,8 +7891,8 @@ EXAMPLES
7861
7891
  }
7862
7892
 
7863
7893
  // src/cli/commands/config-export.ts
7864
- var fs18 = __toESM(require("fs"));
7865
- var path18 = __toESM(require("path"));
7894
+ var fs19 = __toESM(require("fs"));
7895
+ var path19 = __toESM(require("path"));
7866
7896
  function printHelp13() {
7867
7897
  console.log(`
7868
7898
  SKEDYUL CONFIG:EXPORT - Export resolved config to JSON
@@ -7908,8 +7938,8 @@ async function configExportCommand(args2) {
7908
7938
  const cwd = process.cwd();
7909
7939
  let configPath = null;
7910
7940
  for (const name of CONFIG_FILE_NAMES) {
7911
- const testPath = path18.join(cwd, name);
7912
- if (fs18.existsSync(testPath)) {
7941
+ const testPath = path19.join(cwd, name);
7942
+ if (fs19.existsSync(testPath)) {
7913
7943
  configPath = testPath;
7914
7944
  break;
7915
7945
  }
@@ -7919,16 +7949,16 @@ async function configExportCommand(args2) {
7919
7949
  console.error("Make sure you are in the root of your integration project.");
7920
7950
  process.exit(1);
7921
7951
  }
7922
- console.log(`Loading config from ${path18.basename(configPath)}...`);
7952
+ console.log(`Loading config from ${path19.basename(configPath)}...`);
7923
7953
  try {
7924
7954
  const resolvedConfig = await loadAndResolveConfig(configPath);
7925
7955
  const serialized = serializeResolvedConfig(resolvedConfig);
7926
- const outputDir = path18.dirname(path18.resolve(cwd, outputPath));
7927
- if (!fs18.existsSync(outputDir)) {
7928
- fs18.mkdirSync(outputDir, { recursive: true });
7956
+ const outputDir = path19.dirname(path19.resolve(cwd, outputPath));
7957
+ if (!fs19.existsSync(outputDir)) {
7958
+ fs19.mkdirSync(outputDir, { recursive: true });
7929
7959
  }
7930
- const fullOutputPath = path18.resolve(cwd, outputPath);
7931
- fs18.writeFileSync(fullOutputPath, JSON.stringify(serialized, null, 2), "utf-8");
7960
+ const fullOutputPath = path19.resolve(cwd, outputPath);
7961
+ fs19.writeFileSync(fullOutputPath, JSON.stringify(serialized, null, 2), "utf-8");
7932
7962
  console.log(``);
7933
7963
  console.log(`Config exported successfully!`);
7934
7964
  console.log(` Output: ${outputPath}`);
@@ -8570,8 +8600,8 @@ async function handleCreateMany(modelHandle, flags) {
8570
8600
  console.error("Usage: skedyul instances create-many <model> --file data.json --workplace <subdomain>");
8571
8601
  process.exit(1);
8572
8602
  }
8573
- const fs25 = await import("fs");
8574
- const fileContent = fs25.readFileSync(filePath, "utf-8");
8603
+ const fs26 = await import("fs");
8604
+ const fileContent = fs26.readFileSync(filePath, "utf-8");
8575
8605
  const items = JSON.parse(fileContent);
8576
8606
  if (!Array.isArray(items)) {
8577
8607
  console.error("Error: File must contain a JSON array of items");
@@ -8598,8 +8628,8 @@ async function handleUpsertMany(modelHandle, flags) {
8598
8628
  console.error("Usage: skedyul instances upsert-many <model> --file data.json --match-field <field> --workplace <subdomain>");
8599
8629
  process.exit(1);
8600
8630
  }
8601
- const fs25 = await import("fs");
8602
- const fileContent = fs25.readFileSync(filePath, "utf-8");
8631
+ const fs26 = await import("fs");
8632
+ const fileContent = fs26.readFileSync(filePath, "utf-8");
8603
8633
  const items = JSON.parse(fileContent);
8604
8634
  if (!Array.isArray(items)) {
8605
8635
  console.error("Error: File must contain a JSON array of items");
@@ -8611,8 +8641,8 @@ async function handleUpsertMany(modelHandle, flags) {
8611
8641
 
8612
8642
  // src/cli/commands/build.ts
8613
8643
  var import_child_process = require("child_process");
8614
- var fs19 = __toESM(require("fs"));
8615
- var path19 = __toESM(require("path"));
8644
+ var fs20 = __toESM(require("fs"));
8645
+ var path20 = __toESM(require("path"));
8616
8646
  function printBuildHelp() {
8617
8647
  console.log(`
8618
8648
  SKEDYUL BUILD - Build your integration
@@ -8681,8 +8711,8 @@ async function buildCommand(args2) {
8681
8711
  const cwd = process.cwd();
8682
8712
  let configPath = null;
8683
8713
  for (const name of CONFIG_FILE_NAMES) {
8684
- const testPath = path19.join(cwd, name);
8685
- if (fs19.existsSync(testPath)) {
8714
+ const testPath = path20.join(cwd, name);
8715
+ if (fs20.existsSync(testPath)) {
8686
8716
  configPath = testPath;
8687
8717
  break;
8688
8718
  }
@@ -8692,8 +8722,8 @@ async function buildCommand(args2) {
8692
8722
  console.error("Make sure you are in the root of your integration project.");
8693
8723
  process.exit(1);
8694
8724
  }
8695
- console.log(`Loading config from ${path19.basename(configPath)}...`);
8696
- const tempConfigPath = path19.join(cwd, ".skedyul-tsup.config.mjs");
8725
+ console.log(`Loading config from ${path20.basename(configPath)}...`);
8726
+ const tempConfigPath = path20.join(cwd, ".skedyul-tsup.config.mjs");
8697
8727
  let createdTempConfig = false;
8698
8728
  try {
8699
8729
  const config = await loadConfig(configPath);
@@ -8702,8 +8732,8 @@ async function buildCommand(args2) {
8702
8732
  const baseExternals = ["skedyul", `skedyul/${computeLayer}`, "zod"];
8703
8733
  const userExternals = config.build && "external" in config.build ? config.build.external ?? [] : [];
8704
8734
  const allExternals = [...baseExternals, ...userExternals];
8705
- const userTsupConfig = path19.join(cwd, "tsup.config.ts");
8706
- const hasUserConfig = fs19.existsSync(userTsupConfig);
8735
+ const userTsupConfig = path20.join(cwd, "tsup.config.ts");
8736
+ const hasUserConfig = fs20.existsSync(userTsupConfig);
8707
8737
  console.log(``);
8708
8738
  console.log(`Building ${config.name ?? "integration"}...`);
8709
8739
  console.log(` Compute layer: ${computeLayer}`);
@@ -8723,7 +8753,7 @@ async function buildCommand(args2) {
8723
8753
  }
8724
8754
  } else {
8725
8755
  const tsupConfigContent = generateTsupConfig(format, allExternals);
8726
- fs19.writeFileSync(tempConfigPath, tsupConfigContent, "utf-8");
8756
+ fs20.writeFileSync(tempConfigPath, tsupConfigContent, "utf-8");
8727
8757
  createdTempConfig = true;
8728
8758
  tsupArgs = [
8729
8759
  "tsup",
@@ -8741,14 +8771,14 @@ async function buildCommand(args2) {
8741
8771
  });
8742
8772
  tsup.on("error", (error) => {
8743
8773
  console.error("Failed to start tsup:", error.message);
8744
- if (createdTempConfig && fs19.existsSync(tempConfigPath)) {
8745
- fs19.unlinkSync(tempConfigPath);
8774
+ if (createdTempConfig && fs20.existsSync(tempConfigPath)) {
8775
+ fs20.unlinkSync(tempConfigPath);
8746
8776
  }
8747
8777
  process.exit(1);
8748
8778
  });
8749
8779
  tsup.on("close", (code) => {
8750
- if (createdTempConfig && fs19.existsSync(tempConfigPath)) {
8751
- fs19.unlinkSync(tempConfigPath);
8780
+ if (createdTempConfig && fs20.existsSync(tempConfigPath)) {
8781
+ fs20.unlinkSync(tempConfigPath);
8752
8782
  }
8753
8783
  if (code === 0) {
8754
8784
  console.log(``);
@@ -8757,8 +8787,8 @@ async function buildCommand(args2) {
8757
8787
  process.exit(code ?? 0);
8758
8788
  });
8759
8789
  } catch (error) {
8760
- if (createdTempConfig && fs19.existsSync(tempConfigPath)) {
8761
- fs19.unlinkSync(tempConfigPath);
8790
+ if (createdTempConfig && fs20.existsSync(tempConfigPath)) {
8791
+ fs20.unlinkSync(tempConfigPath);
8762
8792
  }
8763
8793
  console.error(
8764
8794
  "Error loading config:",
@@ -8771,8 +8801,8 @@ async function buildCommand(args2) {
8771
8801
  // src/cli/commands/smoke-test.ts
8772
8802
  var import_child_process2 = require("child_process");
8773
8803
  var http3 = __toESM(require("http"));
8774
- var fs20 = __toESM(require("fs"));
8775
- var path20 = __toESM(require("path"));
8804
+ var fs21 = __toESM(require("fs"));
8805
+ var path21 = __toESM(require("path"));
8776
8806
  var SMOKE_TEST_PORT = 3456;
8777
8807
  var HEALTH_CHECK_INTERVAL_MS = 500;
8778
8808
  var HEALTH_CHECK_MAX_RETRIES = 30;
@@ -8803,13 +8833,13 @@ WHAT IT DOES
8803
8833
  6. Exits with code 0 (success) or 1 (failure)
8804
8834
  `);
8805
8835
  }
8806
- function makeRequest(port, path25, method, body) {
8836
+ function makeRequest(port, path26, method, body) {
8807
8837
  return new Promise((resolve16, reject) => {
8808
8838
  const postData = body ? JSON.stringify(body) : void 0;
8809
8839
  const options = {
8810
8840
  hostname: "localhost",
8811
8841
  port,
8812
- path: path25,
8842
+ path: path26,
8813
8843
  method,
8814
8844
  headers: {
8815
8845
  "Content-Type": "application/json",
@@ -8897,8 +8927,8 @@ async function smokeTestCommand(args2) {
8897
8927
  const cwd = process.cwd();
8898
8928
  let configPath = null;
8899
8929
  for (const name of CONFIG_FILE_NAMES) {
8900
- const testPath = path20.join(cwd, name);
8901
- if (fs20.existsSync(testPath)) {
8930
+ const testPath = path21.join(cwd, name);
8931
+ if (fs21.existsSync(testPath)) {
8902
8932
  configPath = testPath;
8903
8933
  break;
8904
8934
  }
@@ -8914,10 +8944,10 @@ async function smokeTestCommand(args2) {
8914
8944
  }
8915
8945
  const serverExt = computeLayer === "serverless" ? "mjs" : "js";
8916
8946
  let serverPath = `dist/server/mcp_server.${serverExt}`;
8917
- if (!fs20.existsSync(serverPath)) {
8947
+ if (!fs21.existsSync(serverPath)) {
8918
8948
  const fallbackExt = serverExt === "mjs" ? "js" : "mjs";
8919
8949
  const fallbackPath = `dist/server/mcp_server.${fallbackExt}`;
8920
- if (fs20.existsSync(fallbackPath)) {
8950
+ if (fs21.existsSync(fallbackPath)) {
8921
8951
  console.warn(`[SmokeTest] Warning: Expected ${serverPath} but found ${fallbackPath}`);
8922
8952
  console.warn(`[SmokeTest] Using ${fallbackPath} instead`);
8923
8953
  serverPath = fallbackPath;
@@ -9435,8 +9465,8 @@ async function crmCommand(args2) {
9435
9465
  }
9436
9466
 
9437
9467
  // src/cli/commands/agents.ts
9438
- var fs21 = __toESM(require("fs"));
9439
- var path21 = __toESM(require("path"));
9468
+ var fs22 = __toESM(require("fs"));
9469
+ var path22 = __toESM(require("path"));
9440
9470
  var import_yaml = require("yaml");
9441
9471
  init_utils();
9442
9472
 
@@ -10497,11 +10527,11 @@ function isAgentV3(agent) {
10497
10527
  return "handle" in obj && !("stages" in obj) && !("agents" in obj);
10498
10528
  }
10499
10529
  async function loadAgentFile(filePath) {
10500
- const absolutePath = path21.resolve(filePath);
10501
- if (!fs21.existsSync(absolutePath)) {
10530
+ const absolutePath = path22.resolve(filePath);
10531
+ if (!fs22.existsSync(absolutePath)) {
10502
10532
  throw new Error(`Agent file not found: ${absolutePath}`);
10503
10533
  }
10504
- const content = fs21.readFileSync(absolutePath, "utf-8");
10534
+ const content = fs22.readFileSync(absolutePath, "utf-8");
10505
10535
  const isJson = absolutePath.endsWith(".json");
10506
10536
  const isYaml = absolutePath.endsWith(".yml") || absolutePath.endsWith(".yaml");
10507
10537
  let rawAgent;
@@ -10511,7 +10541,7 @@ async function loadAgentFile(filePath) {
10511
10541
  rawAgent = (0, import_yaml.parse)(content);
10512
10542
  } else {
10513
10543
  throw new Error(
10514
- `Unsupported agent file format: ${path21.extname(absolutePath)}. Use .agent.yml or .agent.json`
10544
+ `Unsupported agent file format: ${path22.extname(absolutePath)}. Use .agent.yml or .agent.json`
10515
10545
  );
10516
10546
  }
10517
10547
  const detectedV3 = isAgentV3(rawAgent);
@@ -10521,8 +10551,8 @@ async function loadAgentFile(filePath) {
10521
10551
  return { agent: v3Result.data, content, isV3: true };
10522
10552
  }
10523
10553
  const errorMessages = v3Result.error.issues.map((e) => {
10524
- const path25 = e.path.length > 0 ? e.path.join(".") : "(root)";
10525
- return ` - ${path25}: ${e.message}`;
10554
+ const path26 = e.path.length > 0 ? e.path.join(".") : "(root)";
10555
+ return ` - ${path26}: ${e.message}`;
10526
10556
  }).join("\n");
10527
10557
  throw new Error(`Agent v3 validation failed:
10528
10558
  ${errorMessages}`);
@@ -10534,8 +10564,8 @@ ${errorMessages}`);
10534
10564
  const v3Result = validateAgentYAMLV3(rawAgent);
10535
10565
  if (!v3Result.success) {
10536
10566
  const errorMessages2 = v3Result.error.issues.map((e) => {
10537
- const path25 = e.path.length > 0 ? e.path.join(".") : "(root)";
10538
- return ` - ${path25}: ${e.message}`;
10567
+ const path26 = e.path.length > 0 ? e.path.join(".") : "(root)";
10568
+ return ` - ${path26}: ${e.message}`;
10539
10569
  }).join("\n");
10540
10570
  throw new Error(`Agent v3 validation failed:
10541
10571
  ${errorMessages2}`);
@@ -11231,14 +11261,14 @@ async function* parseSSEStream(response, debug2 = false) {
11231
11261
  }
11232
11262
 
11233
11263
  // src/cli/utils/mock-context.ts
11234
- var fs22 = __toESM(require("fs"));
11235
- var path22 = __toESM(require("path"));
11264
+ var fs23 = __toESM(require("fs"));
11265
+ var path23 = __toESM(require("path"));
11236
11266
  function loadContext(filePath) {
11237
- const absolutePath = path22.resolve(filePath);
11238
- if (!fs22.existsSync(absolutePath)) {
11267
+ const absolutePath = path23.resolve(filePath);
11268
+ if (!fs23.existsSync(absolutePath)) {
11239
11269
  throw new Error(`Context file not found: ${absolutePath}`);
11240
11270
  }
11241
- const content = fs22.readFileSync(absolutePath, "utf-8");
11271
+ const content = fs23.readFileSync(absolutePath, "utf-8");
11242
11272
  let rawContext;
11243
11273
  try {
11244
11274
  rawContext = JSON.parse(content);
@@ -12324,8 +12354,8 @@ Error: ${input.name} is required`);
12324
12354
  }
12325
12355
 
12326
12356
  // src/cli/commands/skills.ts
12327
- var fs23 = __toESM(require("fs"));
12328
- var path23 = __toESM(require("path"));
12357
+ var fs24 = __toESM(require("fs"));
12358
+ var path24 = __toESM(require("path"));
12329
12359
  var import_yaml2 = require("yaml");
12330
12360
  init_utils();
12331
12361
  function printHelp21() {
@@ -12397,12 +12427,12 @@ async function getWorkplaceToken6(workplaceSubdomain, serverUrl, cliToken) {
12397
12427
  );
12398
12428
  }
12399
12429
  async function loadSkillFile(filePath) {
12400
- const absolutePath = path23.resolve(filePath);
12401
- if (!fs23.existsSync(absolutePath)) {
12430
+ const absolutePath = path24.resolve(filePath);
12431
+ if (!fs24.existsSync(absolutePath)) {
12402
12432
  throw new Error(`File not found: ${absolutePath}`);
12403
12433
  }
12404
- const content = fs23.readFileSync(absolutePath, "utf-8");
12405
- const ext = path23.extname(absolutePath).toLowerCase();
12434
+ const content = fs24.readFileSync(absolutePath, "utf-8");
12435
+ const ext = path24.extname(absolutePath).toLowerCase();
12406
12436
  if (ext !== ".yml" && ext !== ".yaml") {
12407
12437
  throw new Error("Skill file must be a .skill.yml or .skill.yaml file");
12408
12438
  }
@@ -12847,8 +12877,8 @@ async function skillsCommand(args2) {
12847
12877
  }
12848
12878
 
12849
12879
  // src/cli/commands/workflows.ts
12850
- var fs24 = __toESM(require("fs"));
12851
- var path24 = __toESM(require("path"));
12880
+ var fs25 = __toESM(require("fs"));
12881
+ var path25 = __toESM(require("path"));
12852
12882
  var readline7 = __toESM(require("readline"));
12853
12883
  var import_yaml3 = require("yaml");
12854
12884
  init_utils();
@@ -13113,12 +13143,12 @@ async function getWorkplaceToken7(workplaceSubdomain, serverUrl, cliToken) {
13113
13143
  );
13114
13144
  }
13115
13145
  async function loadWorkflowFile(filePath) {
13116
- const absolutePath = path24.resolve(filePath);
13117
- if (!fs24.existsSync(absolutePath)) {
13146
+ const absolutePath = path25.resolve(filePath);
13147
+ if (!fs25.existsSync(absolutePath)) {
13118
13148
  throw new Error(`File not found: ${absolutePath}`);
13119
13149
  }
13120
- const content = fs24.readFileSync(absolutePath, "utf-8");
13121
- const ext = path24.extname(absolutePath).toLowerCase();
13150
+ const content = fs25.readFileSync(absolutePath, "utf-8");
13151
+ const ext = path25.extname(absolutePath).toLowerCase();
13122
13152
  if (ext !== ".yml" && ext !== ".yaml") {
13123
13153
  throw new Error("Workflow file must be a .yml or .yaml file");
13124
13154
  }
@@ -13477,8 +13507,8 @@ async function handlePull2(args2) {
13477
13507
  console.log(JSON.stringify(result, null, 2));
13478
13508
  return;
13479
13509
  }
13480
- const outputPath = path24.resolve(output || `./${handle}.workflow.yml`);
13481
- fs24.writeFileSync(outputPath, result.yaml, "utf-8");
13510
+ const outputPath = path25.resolve(output || `./${handle}.workflow.yml`);
13511
+ fs25.writeFileSync(outputPath, result.yaml, "utf-8");
13482
13512
  console.log(`Saved v${result.version} to ${outputPath}`);
13483
13513
  }
13484
13514
  async function handlePublish3(args2) {