skedyul 1.5.0 → 1.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -43,7 +43,6 @@ __export(index_exports, {
43
43
  AuthenticationError: () => AuthenticationError,
44
44
  BaseEventPayloadSchema: () => BaseEventPayloadSchema,
45
45
  BreadcrumbItemSchema: () => BreadcrumbItemSchema,
46
- CONFIG_FILE_NAMES: () => CONFIG_FILE_NAMES,
47
46
  CRMCardinalitySchema: () => CRMCardinalitySchema,
48
47
  CRMContextSchema: () => CRMContextSchema2,
49
48
  CRMDataSchema: () => CRMDataSchema,
@@ -309,7 +308,6 @@ __export(index_exports, {
309
308
  isTimeInPolicy: () => isTimeInPolicy,
310
309
  isTimeInWindowSlot: () => isTimeInWindowSlot2,
311
310
  isWorkflowDependency: () => isWorkflowDependency,
312
- loadConfig: () => loadConfig,
313
311
  matchesTrigger: () => matchesTrigger,
314
312
  parseCRMSchema: () => parseCRMSchema,
315
313
  queuedFetch: () => queuedFetch,
@@ -327,7 +325,6 @@ __export(index_exports, {
327
325
  server: () => server,
328
326
  token: () => token,
329
327
  validateCRMSchema: () => validateCRMSchema,
330
- validateConfig: () => validateConfig,
331
328
  validateSkillYAML: () => validateSkillYAML,
332
329
  validateWorkflowYAML: () => validateWorkflowYAML,
333
330
  webhook: () => webhook,
@@ -2353,13 +2350,13 @@ function mergeRuntimeEnv() {
2353
2350
 
2354
2351
  // src/server/utils/http.ts
2355
2352
  function readRawRequestBody(req) {
2356
- return new Promise((resolve5, reject) => {
2353
+ return new Promise((resolve3, reject) => {
2357
2354
  let body = "";
2358
2355
  req.on("data", (chunk) => {
2359
2356
  body += chunk.toString();
2360
2357
  });
2361
2358
  req.on("end", () => {
2362
- resolve5(body);
2359
+ resolve3(body);
2363
2360
  });
2364
2361
  req.on("error", reject);
2365
2362
  });
@@ -4172,7 +4169,7 @@ function printStartupLog(config, tools, port) {
4172
4169
 
4173
4170
  // src/server/route-handlers/adapters.ts
4174
4171
  function fromLambdaEvent(event2) {
4175
- const path7 = event2.path || event2.rawPath || "/";
4172
+ const path5 = event2.path || event2.rawPath || "/";
4176
4173
  const method = event2.httpMethod || event2.requestContext?.http?.method || "POST";
4177
4174
  const forwardedProto = event2.headers?.["x-forwarded-proto"] ?? event2.headers?.["X-Forwarded-Proto"];
4178
4175
  const protocol = forwardedProto ?? "https";
@@ -4180,9 +4177,9 @@ function fromLambdaEvent(event2) {
4180
4177
  const queryString = event2.queryStringParameters ? "?" + new URLSearchParams(
4181
4178
  event2.queryStringParameters
4182
4179
  ).toString() : "";
4183
- const url = `${protocol}://${host}${path7}${queryString}`;
4180
+ const url = `${protocol}://${host}${path5}${queryString}`;
4184
4181
  return {
4185
- path: path7,
4182
+ path: path5,
4186
4183
  method,
4187
4184
  headers: event2.headers,
4188
4185
  query: event2.queryStringParameters ?? {},
@@ -4732,7 +4729,7 @@ async function handleOAuthCallback(parsedBody, hooks) {
4732
4729
  }
4733
4730
 
4734
4731
  // src/server/handlers/webhook-handler.ts
4735
- function parseWebhookRequest(parsedBody, method, url, path7, headers, query, rawBody, appIdHeader, appVersionIdHeader) {
4732
+ function parseWebhookRequest(parsedBody, method, url, path5, headers, query, rawBody, appIdHeader, appVersionIdHeader) {
4736
4733
  const isEnvelope = typeof parsedBody === "object" && parsedBody !== null && "env" in parsedBody && "request" in parsedBody && "context" in parsedBody;
4737
4734
  if (isEnvelope) {
4738
4735
  const envelope = parsedBody;
@@ -4786,7 +4783,7 @@ function parseWebhookRequest(parsedBody, method, url, path7, headers, query, raw
4786
4783
  const webhookRequest = {
4787
4784
  method,
4788
4785
  url,
4789
- path: path7,
4786
+ path: path5,
4790
4787
  headers,
4791
4788
  query,
4792
4789
  body: parsedBody,
@@ -5235,9 +5232,9 @@ async function handleMcpBatchRoute(req, ctx) {
5235
5232
  }
5236
5233
  const perCallTimeoutMs = deadline ? Math.min(deadline, 25e3) : 25e3;
5237
5234
  const executeWithTimeout = async (call2, timeoutMs) => {
5238
- return new Promise(async (resolve5) => {
5235
+ return new Promise(async (resolve3) => {
5239
5236
  const timeoutHandle = setTimeout(() => {
5240
- resolve5({
5237
+ resolve3({
5241
5238
  id: call2.id,
5242
5239
  success: false,
5243
5240
  error: "Timeout",
@@ -5250,7 +5247,7 @@ async function handleMcpBatchRoute(req, ctx) {
5250
5247
  const found = findToolInRegistry(ctx.registry, toolName);
5251
5248
  if (!found) {
5252
5249
  clearTimeout(timeoutHandle);
5253
- resolve5({
5250
+ resolve3({
5254
5251
  id: call2.id,
5255
5252
  success: false,
5256
5253
  error: `Tool "${toolName}" not found`
@@ -5268,13 +5265,13 @@ async function handleMcpBatchRoute(req, ctx) {
5268
5265
  clearTimeout(timeoutHandle);
5269
5266
  const isFailure2 = "success" in toolResult && toolResult.success === false || "error" in toolResult && toolResult.error != null;
5270
5267
  if (isFailure2) {
5271
- resolve5({
5268
+ resolve3({
5272
5269
  id: call2.id,
5273
5270
  success: false,
5274
5271
  error: "error" in toolResult && toolResult.error ? typeof toolResult.error === "string" ? toolResult.error : JSON.stringify(toolResult.error) : "Tool execution failed"
5275
5272
  });
5276
5273
  } else {
5277
- resolve5({
5274
+ resolve3({
5278
5275
  id: call2.id,
5279
5276
  success: true,
5280
5277
  result: "output" in toolResult ? toolResult.output : toolResult
@@ -5282,7 +5279,7 @@ async function handleMcpBatchRoute(req, ctx) {
5282
5279
  }
5283
5280
  } catch (err) {
5284
5281
  clearTimeout(timeoutHandle);
5285
- resolve5({
5282
+ resolve3({
5286
5283
  id: call2.id,
5287
5284
  success: false,
5288
5285
  error: err instanceof Error ? err.message : String(err)
@@ -5468,21 +5465,21 @@ function createDedicatedServerInstance(config, tools, callTool, state, mcpServer
5468
5465
  return {
5469
5466
  async listen(listenPort) {
5470
5467
  const finalPort = listenPort ?? port;
5471
- return new Promise((resolve5, reject) => {
5468
+ return new Promise((resolve3, reject) => {
5472
5469
  httpServer.listen(finalPort, () => {
5473
5470
  printStartupLog(config, tools, finalPort);
5474
- resolve5();
5471
+ resolve3();
5475
5472
  });
5476
5473
  httpServer.once("error", reject);
5477
5474
  });
5478
5475
  },
5479
5476
  async close() {
5480
- return new Promise((resolve5, reject) => {
5477
+ return new Promise((resolve3, reject) => {
5481
5478
  const closable = httpServer;
5482
5479
  closable.closeAllConnections?.();
5483
5480
  httpServer.close((err) => {
5484
5481
  if (err) reject(err);
5485
- else resolve5();
5482
+ else resolve3();
5486
5483
  });
5487
5484
  });
5488
5485
  },
@@ -5837,169 +5834,14 @@ function defineNavigation(navigation) {
5837
5834
  return navigation;
5838
5835
  }
5839
5836
 
5840
- // src/config/loader.ts
5841
- var fs4 = __toESM(require("fs"));
5842
- var path4 = __toESM(require("path"));
5843
- var os = __toESM(require("os"));
5844
-
5845
- // src/config/transpileConfigMetadata.ts
5846
- var esbuild = __toESM(require("esbuild"));
5837
+ // src/config/schema-loader.ts
5847
5838
  var fs3 = __toESM(require("fs"));
5848
5839
  var path3 = __toESM(require("path"));
5849
- var SKEDYUL_SHIM_NAMESPACE = "skedyul-shim";
5850
- var METADATA_STUB_NAMESPACE = "metadata-stub";
5851
- function prepareConfigSource(content) {
5852
- return content.replace(/import\s*\(\s*(['"])([^'"]+)\1\s*\)/g, "Promise.resolve(null)");
5853
- }
5854
- function isJsonImport(importPath) {
5855
- return importPath.endsWith(".json");
5856
- }
5857
- async function transpileConfigMetadata(configPath) {
5858
- const absolutePath = path3.resolve(configPath);
5859
- const configDir = path3.dirname(absolutePath);
5860
- const configBasename = path3.basename(absolutePath);
5861
- const result = await esbuild.build({
5862
- absWorkingDir: configDir,
5863
- entryPoints: [absolutePath],
5864
- bundle: true,
5865
- format: "cjs",
5866
- platform: "node",
5867
- target: "node22",
5868
- write: false,
5869
- logLevel: "silent",
5870
- plugins: [
5871
- {
5872
- name: "prepare-config-entry",
5873
- setup(build2) {
5874
- build2.onLoad({ filter: new RegExp(`/${configBasename.replace(".", "\\.")}$`) }, () => ({
5875
- contents: prepareConfigSource(fs3.readFileSync(absolutePath, "utf-8")),
5876
- loader: "ts"
5877
- }));
5878
- }
5879
- },
5880
- {
5881
- name: "skedyul-shim",
5882
- setup(build2) {
5883
- build2.onResolve({ filter: /^skedyul$/ }, () => ({
5884
- path: "skedyul-shim",
5885
- namespace: SKEDYUL_SHIM_NAMESPACE
5886
- }));
5887
- build2.onLoad({ filter: /.*/, namespace: SKEDYUL_SHIM_NAMESPACE }, () => ({
5888
- contents: [
5889
- "function defineConfig(config) { return config; }",
5890
- "module.exports = { defineConfig };"
5891
- ].join("\n"),
5892
- loader: "js"
5893
- }));
5894
- }
5895
- },
5896
- {
5897
- name: "metadata-stub-imports",
5898
- setup(build2) {
5899
- build2.onResolve({ filter: /^\.{1,2}\// }, (args) => {
5900
- if (isJsonImport(args.path)) {
5901
- return void 0;
5902
- }
5903
- return {
5904
- path: args.path,
5905
- namespace: METADATA_STUB_NAMESPACE
5906
- };
5907
- });
5908
- build2.onLoad({ filter: /.*/, namespace: METADATA_STUB_NAMESPACE }, () => ({
5909
- contents: "module.exports = {};\n",
5910
- loader: "js"
5911
- }));
5912
- }
5913
- }
5914
- ]
5915
- });
5916
- if (result.errors.length > 0) {
5917
- throw new Error(result.errors.map((error) => error.text).join("\n"));
5918
- }
5919
- if (result.outputFiles.length === 0) {
5920
- throw new Error("Config transpile produced no output");
5921
- }
5922
- return result.outputFiles[0].text;
5923
- }
5924
-
5925
- // src/config/loader.ts
5926
- var CONFIG_FILE_NAMES = [
5927
- "skedyul.config.ts",
5928
- "skedyul.config.js",
5929
- "skedyul.config.mjs",
5930
- "skedyul.config.cjs"
5931
- ];
5932
- async function loadConfig(configPath) {
5933
- const absolutePath = path4.resolve(configPath);
5934
- if (!fs4.existsSync(absolutePath)) {
5935
- throw new Error(`Config file not found: ${absolutePath}`);
5936
- }
5937
- const isTypeScript = absolutePath.endsWith(".ts");
5938
- try {
5939
- if (isTypeScript) {
5940
- try {
5941
- const transpiled = await transpileConfigMetadata(absolutePath);
5942
- const tempFile = path4.join(os.tmpdir(), `skedyul-config-${Date.now()}.cjs`);
5943
- fs4.writeFileSync(tempFile, transpiled);
5944
- try {
5945
- const module3 = require(tempFile);
5946
- const config2 = module3.default || module3;
5947
- if (!config2 || typeof config2 !== "object") {
5948
- throw new Error("Config file must export a configuration object");
5949
- }
5950
- if (!config2.name || typeof config2.name !== "string") {
5951
- throw new Error('Config must have a "name" property');
5952
- }
5953
- return config2;
5954
- } finally {
5955
- try {
5956
- fs4.unlinkSync(tempFile);
5957
- } catch {
5958
- }
5959
- }
5960
- } catch (transpileError) {
5961
- throw new Error(
5962
- `Cannot load TypeScript config metadata from ${absolutePath}: ${transpileError instanceof Error ? transpileError.message : String(transpileError)}`
5963
- );
5964
- }
5965
- }
5966
- const module2 = await import(
5967
- /* webpackIgnore: true */
5968
- absolutePath
5969
- );
5970
- const config = module2.default || module2;
5971
- if (!config || typeof config !== "object") {
5972
- throw new Error("Config file must export a configuration object");
5973
- }
5974
- if (!config.name || typeof config.name !== "string") {
5975
- throw new Error('Config must have a "name" property');
5976
- }
5977
- return config;
5978
- } catch (error) {
5979
- throw new Error(
5980
- `Failed to load config from ${configPath}: ${error instanceof Error ? error.message : String(error)}`
5981
- );
5982
- }
5983
- }
5984
- function validateConfig(config) {
5985
- const errors = [];
5986
- if (!config.name) {
5987
- errors.push("Missing required field: name");
5988
- }
5989
- if (config.computeLayer && !["serverless", "dedicated"].includes(config.computeLayer)) {
5990
- errors.push(`Invalid computeLayer: ${config.computeLayer}. Must be 'serverless' or 'dedicated'`);
5991
- }
5992
- return { valid: errors.length === 0, errors };
5993
- }
5994
-
5995
- // src/config/schema-loader.ts
5996
- var fs5 = __toESM(require("fs"));
5997
- var path5 = __toESM(require("path"));
5998
- var os2 = __toESM(require("os"));
5840
+ var os = __toESM(require("os"));
5999
5841
 
6000
5842
  // src/config/resolver.ts
6001
- var fs6 = __toESM(require("fs"));
6002
- var path6 = __toESM(require("path"));
5843
+ var fs4 = __toESM(require("fs"));
5844
+ var path4 = __toESM(require("path"));
6003
5845
 
6004
5846
  // src/config/utils.ts
6005
5847
  function getAllEnvKeys(config) {
@@ -6102,7 +5944,7 @@ function getApiToken() {
6102
5944
  const config = getConfig();
6103
5945
  return config.apiToken || process.env.SKEDYUL_API_TOKEN || "";
6104
5946
  }
6105
- async function callRateLimitApi(path7, body) {
5947
+ async function callRateLimitApi(path5, body) {
6106
5948
  const baseUrl = getApiBaseUrl();
6107
5949
  const token2 = getApiToken();
6108
5950
  if (!baseUrl || !token2) {
@@ -6110,7 +5952,7 @@ async function callRateLimitApi(path7, body) {
6110
5952
  "SKEDYUL_API_URL and SKEDYUL_API_TOKEN are required for platform queue coordination"
6111
5953
  );
6112
5954
  }
6113
- const response = await fetch(`${baseUrl}/api/internal/ratelimit/${path7}`, {
5955
+ const response = await fetch(`${baseUrl}/api/internal/ratelimit/${path5}`, {
6114
5956
  method: "POST",
6115
5957
  headers: {
6116
5958
  Authorization: `Bearer ${token2}`,
@@ -6120,11 +5962,11 @@ async function callRateLimitApi(path7, body) {
6120
5962
  });
6121
5963
  const payload = await response.json().catch(() => null);
6122
5964
  if (!response.ok || payload?.success === false) {
6123
- const message = payload?.errors?.[0]?.message ?? `Queue coordination API ${path7} failed with status ${response.status}`;
5965
+ const message = payload?.errors?.[0]?.message ?? `Queue coordination API ${path5} failed with status ${response.status}`;
6124
5966
  throw new RateLimitBackendError(message, response.status);
6125
5967
  }
6126
5968
  if (!payload?.data) {
6127
- throw new RateLimitBackendError(`Queue coordination API ${path7} returned empty data`);
5969
+ throw new RateLimitBackendError(`Queue coordination API ${path5} returned empty data`);
6128
5970
  }
6129
5971
  return payload.data;
6130
5972
  }
@@ -6251,9 +6093,9 @@ var MemoryRateLimitBackend = class {
6251
6093
  if (canAcquire(state, limits)) {
6252
6094
  return this.grant(state, queueKey, limits);
6253
6095
  }
6254
- return new Promise((resolve5, reject) => {
6096
+ return new Promise((resolve3, reject) => {
6255
6097
  const waiter = {
6256
- resolve: resolve5,
6098
+ resolve: resolve3,
6257
6099
  reject,
6258
6100
  timer: null,
6259
6101
  limits
@@ -6282,7 +6124,7 @@ var MemoryRateLimitBackend = class {
6282
6124
  if (waiter.timer) {
6283
6125
  clearTimeout(waiter.timer);
6284
6126
  }
6285
- resolve5(this.grant(state, queueKey, limits));
6127
+ resolve3(this.grant(state, queueKey, limits));
6286
6128
  return;
6287
6129
  }
6288
6130
  setTimeout(retry, Math.max(getMinTime(limits), 10));
@@ -6403,7 +6245,7 @@ function defaultShouldRetry(error, _attempt) {
6403
6245
  return false;
6404
6246
  }
6405
6247
  function sleep(ms) {
6406
- return new Promise((resolve5) => setTimeout(resolve5, ms));
6248
+ return new Promise((resolve3) => setTimeout(resolve3, ms));
6407
6249
  }
6408
6250
 
6409
6251
  // src/ratelimit/queued-fetch.ts
@@ -6683,16 +6525,16 @@ function evaluateTemplate(template, context) {
6683
6525
  const templateRegex = /\{\{\s*([^}]+)\s*\}\}/g;
6684
6526
  const singleMatch = template.match(/^\{\{\s*([^}]+)\s*\}\}$/);
6685
6527
  if (singleMatch) {
6686
- const path7 = singleMatch[1].trim();
6687
- return resolvePath(context, path7);
6528
+ const path5 = singleMatch[1].trim();
6529
+ return resolvePath(context, path5);
6688
6530
  }
6689
- return template.replace(templateRegex, (_, path7) => {
6690
- const value = resolvePath(context, path7.trim());
6531
+ return template.replace(templateRegex, (_, path5) => {
6532
+ const value = resolvePath(context, path5.trim());
6691
6533
  return value === void 0 || value === null ? "" : String(value);
6692
6534
  });
6693
6535
  }
6694
- function resolvePath(obj, path7) {
6695
- const parts = path7.split(".");
6536
+ function resolvePath(obj, path5) {
6537
+ const parts = path5.split(".");
6696
6538
  let current = obj;
6697
6539
  for (const part of parts) {
6698
6540
  if (current === null || current === void 0) {
@@ -6713,14 +6555,14 @@ function evaluateCondition(condition, context) {
6713
6555
  const expression = match[1].trim();
6714
6556
  const eqMatch = expression.match(/^(.+?)\s*==\s*['"](.+)['"]$/);
6715
6557
  if (eqMatch) {
6716
- const [, path7, expectedValue] = eqMatch;
6717
- const actualValue = resolvePath(context, path7.trim());
6558
+ const [, path5, expectedValue] = eqMatch;
6559
+ const actualValue = resolvePath(context, path5.trim());
6718
6560
  return actualValue === expectedValue;
6719
6561
  }
6720
6562
  const neqMatch = expression.match(/^(.+?)\s*!=\s*['"](.+)['"]$/);
6721
6563
  if (neqMatch) {
6722
- const [, path7, expectedValue] = neqMatch;
6723
- const actualValue = resolvePath(context, path7.trim());
6564
+ const [, path5, expectedValue] = neqMatch;
6565
+ const actualValue = resolvePath(context, path5.trim());
6724
6566
  return actualValue !== expectedValue;
6725
6567
  }
6726
6568
  const value = resolvePath(context, expression);
@@ -7963,7 +7805,6 @@ var index_default = { z: import_v413.z };
7963
7805
  AuthenticationError,
7964
7806
  BaseEventPayloadSchema,
7965
7807
  BreadcrumbItemSchema,
7966
- CONFIG_FILE_NAMES,
7967
7808
  CRMCardinalitySchema,
7968
7809
  CRMContextSchema,
7969
7810
  CRMDataSchema,
@@ -8228,7 +8069,6 @@ var index_default = { z: import_v413.z };
8228
8069
  isTimeInPolicy,
8229
8070
  isTimeInWindowSlot,
8230
8071
  isWorkflowDependency,
8231
- loadConfig,
8232
8072
  matchesTrigger,
8233
8073
  parseCRMSchema,
8234
8074
  queuedFetch,
@@ -8246,7 +8086,6 @@ var index_default = { z: import_v413.z };
8246
8086
  server,
8247
8087
  token,
8248
8088
  validateCRMSchema,
8249
- validateConfig,
8250
8089
  validateSkillYAML,
8251
8090
  validateWorkflowYAML,
8252
8091
  webhook,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skedyul",
3
- "version": "1.5.0",
3
+ "version": "1.5.2",
4
4
  "description": "The Skedyul SDK for Node.js",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -32,6 +32,12 @@
32
32
  "require": "./dist/cli/utils/auth.js",
33
33
  "default": "./dist/cli/utils/auth.js"
34
34
  },
35
+ "./config/loader": {
36
+ "types": "./dist/config/loader.d.ts",
37
+ "import": "./dist/config/loader.mjs",
38
+ "require": "./dist/config/loader.js",
39
+ "default": "./dist/config/loader.js"
40
+ },
35
41
  "./schemas/agent-schema": {
36
42
  "types": "./dist/schemas/agent-schema.d.ts",
37
43
  "import": "./dist/schemas/agent-schema.mjs",