skedyul 1.4.11 → 1.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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((resolve4, 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
- resolve4(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 path6 = 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}${path6}${queryString}`;
4180
+ const url = `${protocol}://${host}${path5}${queryString}`;
4184
4181
  return {
4185
- path: path6,
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, path6, 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, path6, headers, query, raw
4786
4783
  const webhookRequest = {
4787
4784
  method,
4788
4785
  url,
4789
- path: path6,
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 (resolve4) => {
5235
+ return new Promise(async (resolve3) => {
5239
5236
  const timeoutHandle = setTimeout(() => {
5240
- resolve4({
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
- resolve4({
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
- resolve4({
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
- resolve4({
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
- resolve4({
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((resolve4, reject) => {
5468
+ return new Promise((resolve3, reject) => {
5472
5469
  httpServer.listen(finalPort, () => {
5473
5470
  printStartupLog(config, tools, finalPort);
5474
- resolve4();
5471
+ resolve3();
5475
5472
  });
5476
5473
  httpServer.once("error", reject);
5477
5474
  });
5478
5475
  },
5479
5476
  async close() {
5480
- return new Promise((resolve4, 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 resolve4();
5482
+ else resolve3();
5486
5483
  });
5487
5484
  });
5488
5485
  },
@@ -5837,109 +5834,14 @@ function defineNavigation(navigation) {
5837
5834
  return navigation;
5838
5835
  }
5839
5836
 
5840
- // src/config/loader.ts
5837
+ // src/config/schema-loader.ts
5841
5838
  var fs3 = __toESM(require("fs"));
5842
5839
  var path3 = __toESM(require("path"));
5843
5840
  var os = __toESM(require("os"));
5844
- var CONFIG_FILE_NAMES = [
5845
- "skedyul.config.ts",
5846
- "skedyul.config.js",
5847
- "skedyul.config.mjs",
5848
- "skedyul.config.cjs"
5849
- ];
5850
- async function transpileTypeScript(filePath) {
5851
- const content = fs3.readFileSync(filePath, "utf-8");
5852
- const configDir = path3.dirname(path3.resolve(filePath));
5853
- 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*$/, "}");
5854
- transpiled = transpiled.replace(
5855
- /import\s+(\w+)\s+from\s+['"](\.[^'"]+)['"]\s*(?:with\s*\{[^}]*\})?/g,
5856
- (_match, varName, relativePath) => {
5857
- const absolutePath = path3.resolve(configDir, relativePath);
5858
- return `const ${varName} = require('${absolutePath.replace(/\\/g, "/")}')`;
5859
- }
5860
- );
5861
- transpiled = transpiled.replace(
5862
- /import\s+\{\s*([^}]+)\s*\}\s+from\s+['"](\.[^'"]+)['"]\s*;?\n?/g,
5863
- (_match, namedImports, relativePath) => {
5864
- const absolutePath = path3.resolve(configDir, relativePath);
5865
- return `const { ${namedImports.trim()} } = require('${absolutePath.replace(/\\/g, "/")}')
5866
- `;
5867
- }
5868
- );
5869
- transpiled = transpiled.replace(/import\s*\(\s*['"][^'"]+['"]\s*\)/g, "null");
5870
- return transpiled;
5871
- }
5872
- async function loadConfig(configPath) {
5873
- const absolutePath = path3.resolve(configPath);
5874
- if (!fs3.existsSync(absolutePath)) {
5875
- throw new Error(`Config file not found: ${absolutePath}`);
5876
- }
5877
- const isTypeScript = absolutePath.endsWith(".ts");
5878
- try {
5879
- if (isTypeScript) {
5880
- try {
5881
- const transpiled = await transpileTypeScript(absolutePath);
5882
- const tempFile = path3.join(os.tmpdir(), `skedyul-config-${Date.now()}.cjs`);
5883
- fs3.writeFileSync(tempFile, transpiled);
5884
- try {
5885
- const module3 = require(tempFile);
5886
- const config2 = module3.default || module3;
5887
- if (!config2 || typeof config2 !== "object") {
5888
- throw new Error("Config file must export a configuration object");
5889
- }
5890
- if (!config2.name || typeof config2.name !== "string") {
5891
- throw new Error('Config must have a "name" property');
5892
- }
5893
- return config2;
5894
- } finally {
5895
- try {
5896
- fs3.unlinkSync(tempFile);
5897
- } catch {
5898
- }
5899
- }
5900
- } catch (transpileError) {
5901
- throw new Error(
5902
- `Cannot load TypeScript config metadata from ${absolutePath}: ${transpileError instanceof Error ? transpileError.message : String(transpileError)}`
5903
- );
5904
- }
5905
- }
5906
- const module2 = await import(
5907
- /* webpackIgnore: true */
5908
- absolutePath
5909
- );
5910
- const config = module2.default || module2;
5911
- if (!config || typeof config !== "object") {
5912
- throw new Error("Config file must export a configuration object");
5913
- }
5914
- if (!config.name || typeof config.name !== "string") {
5915
- throw new Error('Config must have a "name" property');
5916
- }
5917
- return config;
5918
- } catch (error) {
5919
- throw new Error(
5920
- `Failed to load config from ${configPath}: ${error instanceof Error ? error.message : String(error)}`
5921
- );
5922
- }
5923
- }
5924
- function validateConfig(config) {
5925
- const errors = [];
5926
- if (!config.name) {
5927
- errors.push("Missing required field: name");
5928
- }
5929
- if (config.computeLayer && !["serverless", "dedicated"].includes(config.computeLayer)) {
5930
- errors.push(`Invalid computeLayer: ${config.computeLayer}. Must be 'serverless' or 'dedicated'`);
5931
- }
5932
- return { valid: errors.length === 0, errors };
5933
- }
5934
5841
 
5935
- // src/config/schema-loader.ts
5842
+ // src/config/resolver.ts
5936
5843
  var fs4 = __toESM(require("fs"));
5937
5844
  var path4 = __toESM(require("path"));
5938
- var os2 = __toESM(require("os"));
5939
-
5940
- // src/config/resolver.ts
5941
- var fs5 = __toESM(require("fs"));
5942
- var path5 = __toESM(require("path"));
5943
5845
 
5944
5846
  // src/config/utils.ts
5945
5847
  function getAllEnvKeys(config) {
@@ -6042,7 +5944,7 @@ function getApiToken() {
6042
5944
  const config = getConfig();
6043
5945
  return config.apiToken || process.env.SKEDYUL_API_TOKEN || "";
6044
5946
  }
6045
- async function callRateLimitApi(path6, body) {
5947
+ async function callRateLimitApi(path5, body) {
6046
5948
  const baseUrl = getApiBaseUrl();
6047
5949
  const token2 = getApiToken();
6048
5950
  if (!baseUrl || !token2) {
@@ -6050,7 +5952,7 @@ async function callRateLimitApi(path6, body) {
6050
5952
  "SKEDYUL_API_URL and SKEDYUL_API_TOKEN are required for platform queue coordination"
6051
5953
  );
6052
5954
  }
6053
- const response = await fetch(`${baseUrl}/api/internal/ratelimit/${path6}`, {
5955
+ const response = await fetch(`${baseUrl}/api/internal/ratelimit/${path5}`, {
6054
5956
  method: "POST",
6055
5957
  headers: {
6056
5958
  Authorization: `Bearer ${token2}`,
@@ -6060,11 +5962,11 @@ async function callRateLimitApi(path6, body) {
6060
5962
  });
6061
5963
  const payload = await response.json().catch(() => null);
6062
5964
  if (!response.ok || payload?.success === false) {
6063
- const message = payload?.errors?.[0]?.message ?? `Queue coordination API ${path6} failed with status ${response.status}`;
5965
+ const message = payload?.errors?.[0]?.message ?? `Queue coordination API ${path5} failed with status ${response.status}`;
6064
5966
  throw new RateLimitBackendError(message, response.status);
6065
5967
  }
6066
5968
  if (!payload?.data) {
6067
- throw new RateLimitBackendError(`Queue coordination API ${path6} returned empty data`);
5969
+ throw new RateLimitBackendError(`Queue coordination API ${path5} returned empty data`);
6068
5970
  }
6069
5971
  return payload.data;
6070
5972
  }
@@ -6191,9 +6093,9 @@ var MemoryRateLimitBackend = class {
6191
6093
  if (canAcquire(state, limits)) {
6192
6094
  return this.grant(state, queueKey, limits);
6193
6095
  }
6194
- return new Promise((resolve4, reject) => {
6096
+ return new Promise((resolve3, reject) => {
6195
6097
  const waiter = {
6196
- resolve: resolve4,
6098
+ resolve: resolve3,
6197
6099
  reject,
6198
6100
  timer: null,
6199
6101
  limits
@@ -6222,7 +6124,7 @@ var MemoryRateLimitBackend = class {
6222
6124
  if (waiter.timer) {
6223
6125
  clearTimeout(waiter.timer);
6224
6126
  }
6225
- resolve4(this.grant(state, queueKey, limits));
6127
+ resolve3(this.grant(state, queueKey, limits));
6226
6128
  return;
6227
6129
  }
6228
6130
  setTimeout(retry, Math.max(getMinTime(limits), 10));
@@ -6343,7 +6245,7 @@ function defaultShouldRetry(error, _attempt) {
6343
6245
  return false;
6344
6246
  }
6345
6247
  function sleep(ms) {
6346
- return new Promise((resolve4) => setTimeout(resolve4, ms));
6248
+ return new Promise((resolve3) => setTimeout(resolve3, ms));
6347
6249
  }
6348
6250
 
6349
6251
  // src/ratelimit/queued-fetch.ts
@@ -6623,16 +6525,16 @@ function evaluateTemplate(template, context) {
6623
6525
  const templateRegex = /\{\{\s*([^}]+)\s*\}\}/g;
6624
6526
  const singleMatch = template.match(/^\{\{\s*([^}]+)\s*\}\}$/);
6625
6527
  if (singleMatch) {
6626
- const path6 = singleMatch[1].trim();
6627
- return resolvePath(context, path6);
6528
+ const path5 = singleMatch[1].trim();
6529
+ return resolvePath(context, path5);
6628
6530
  }
6629
- return template.replace(templateRegex, (_, path6) => {
6630
- const value = resolvePath(context, path6.trim());
6531
+ return template.replace(templateRegex, (_, path5) => {
6532
+ const value = resolvePath(context, path5.trim());
6631
6533
  return value === void 0 || value === null ? "" : String(value);
6632
6534
  });
6633
6535
  }
6634
- function resolvePath(obj, path6) {
6635
- const parts = path6.split(".");
6536
+ function resolvePath(obj, path5) {
6537
+ const parts = path5.split(".");
6636
6538
  let current = obj;
6637
6539
  for (const part of parts) {
6638
6540
  if (current === null || current === void 0) {
@@ -6653,14 +6555,14 @@ function evaluateCondition(condition, context) {
6653
6555
  const expression = match[1].trim();
6654
6556
  const eqMatch = expression.match(/^(.+?)\s*==\s*['"](.+)['"]$/);
6655
6557
  if (eqMatch) {
6656
- const [, path6, expectedValue] = eqMatch;
6657
- const actualValue = resolvePath(context, path6.trim());
6558
+ const [, path5, expectedValue] = eqMatch;
6559
+ const actualValue = resolvePath(context, path5.trim());
6658
6560
  return actualValue === expectedValue;
6659
6561
  }
6660
6562
  const neqMatch = expression.match(/^(.+?)\s*!=\s*['"](.+)['"]$/);
6661
6563
  if (neqMatch) {
6662
- const [, path6, expectedValue] = neqMatch;
6663
- const actualValue = resolvePath(context, path6.trim());
6564
+ const [, path5, expectedValue] = neqMatch;
6565
+ const actualValue = resolvePath(context, path5.trim());
6664
6566
  return actualValue !== expectedValue;
6665
6567
  }
6666
6568
  const value = resolvePath(context, expression);
@@ -7903,7 +7805,6 @@ var index_default = { z: import_v413.z };
7903
7805
  AuthenticationError,
7904
7806
  BaseEventPayloadSchema,
7905
7807
  BreadcrumbItemSchema,
7906
- CONFIG_FILE_NAMES,
7907
7808
  CRMCardinalitySchema,
7908
7809
  CRMContextSchema,
7909
7810
  CRMDataSchema,
@@ -8168,7 +8069,6 @@ var index_default = { z: import_v413.z };
8168
8069
  isTimeInPolicy,
8169
8070
  isTimeInWindowSlot,
8170
8071
  isWorkflowDependency,
8171
- loadConfig,
8172
8072
  matchesTrigger,
8173
8073
  parseCRMSchema,
8174
8074
  queuedFetch,
@@ -8186,7 +8086,6 @@ var index_default = { z: import_v413.z };
8186
8086
  server,
8187
8087
  token,
8188
8088
  validateCRMSchema,
8189
- validateConfig,
8190
8089
  validateSkillYAML,
8191
8090
  validateWorkflowYAML,
8192
8091
  webhook,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skedyul",
3
- "version": "1.4.11",
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",
@@ -64,7 +70,7 @@
64
70
  "build": "rm -rf dist tsconfig.tsbuildinfo && tsc --emitDeclarationOnly && tsup",
65
71
  "db:generate": "echo 'No database generation needed for this package'",
66
72
  "dev": "npx nodemon --watch src --ext js,ts --exec \"pnpm run build\"",
67
- "test": "tsc --project tsconfig.tests.json && node --test dist-tests/tests/server.test.js dist-tests/tests/cli.test.js dist-tests/tests/agent-schema-v3.test.js dist-tests/tests/ratelimit.test.js"
73
+ "test": "tsc --project tsconfig.tests.json && node --test dist-tests/tests/server.test.js dist-tests/tests/cli.test.js dist-tests/tests/agent-schema-v3.test.js dist-tests/tests/ratelimit.test.js dist-tests/tests/config-loader.test.js"
68
74
  },
69
75
  "keywords": [
70
76
  "mcp",
@@ -81,6 +87,7 @@
81
87
  "license": "MIT",
82
88
  "dependencies": {
83
89
  "@modelcontextprotocol/sdk": "^1.23.0",
90
+ "esbuild": "^0.27.7",
84
91
  "tsx": "^4.19.0",
85
92
  "yaml": "^2.3.1",
86
93
  "zod": "^4.0.0"