skedyul 1.5.13 → 1.7.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.
@@ -58,6 +58,16 @@ function registerQueueConfig(config) {
58
58
  cachedRuntimeQueues = config.queues ?? null;
59
59
  }
60
60
 
61
+ // src/sequencer/config-loader.ts
62
+ import * as fs2 from "fs";
63
+ import * as path2 from "path";
64
+ var cachedRuntimeSequencers = null;
65
+ var registeredServerConfig2 = null;
66
+ function registerSequencerConfig(config) {
67
+ registeredServerConfig2 = config;
68
+ cachedRuntimeSequencers = config.sequencers ?? null;
69
+ }
70
+
61
71
  // src/server/utils/schema.ts
62
72
  import * as z from "zod";
63
73
  function normalizeBilling(billing) {
@@ -694,7 +704,7 @@ function printStartupLog(config, tools, port) {
694
704
 
695
705
  // src/server/route-handlers/adapters.ts
696
706
  function fromLambdaEvent(event) {
697
- const path3 = event.path || event.rawPath || "/";
707
+ const path4 = event.path || event.rawPath || "/";
698
708
  const method = event.httpMethod || event.requestContext?.http?.method || "POST";
699
709
  const forwardedProto = event.headers?.["x-forwarded-proto"] ?? event.headers?.["X-Forwarded-Proto"];
700
710
  const protocol = forwardedProto ?? "https";
@@ -702,9 +712,9 @@ function fromLambdaEvent(event) {
702
712
  const queryString = event.queryStringParameters ? "?" + new URLSearchParams(
703
713
  event.queryStringParameters
704
714
  ).toString() : "";
705
- const url = `${protocol}://${host}${path3}${queryString}`;
715
+ const url = `${protocol}://${host}${path4}${queryString}`;
706
716
  return {
707
- path: path3,
717
+ path: path4,
708
718
  method,
709
719
  headers: event.headers,
710
720
  query: event.queryStringParameters ?? {},
@@ -786,8 +796,8 @@ function parseBodyByContentType(req) {
786
796
  }
787
797
 
788
798
  // src/server/route-handlers/handlers.ts
789
- import * as fs2 from "fs";
790
- import * as path2 from "path";
799
+ import * as fs3 from "fs";
800
+ import * as path3 from "path";
791
801
 
792
802
  // src/server/core-api-handler.ts
793
803
  async function handleCoreMethod(method, params) {
@@ -1254,8 +1264,13 @@ async function handleOAuthCallback(parsedBody, hooks) {
1254
1264
  }
1255
1265
  }
1256
1266
 
1267
+ // src/types/webhook.ts
1268
+ function isRuntimeWebhookContext(ctx) {
1269
+ return "appInstallationId" in ctx && ctx.appInstallationId !== void 0;
1270
+ }
1271
+
1257
1272
  // src/server/handlers/webhook-handler.ts
1258
- function parseWebhookRequest(parsedBody, method, url, path3, headers, query, rawBody, appIdHeader, appVersionIdHeader) {
1273
+ function parseWebhookRequest(parsedBody, method, url, path4, headers, query, rawBody, appIdHeader, appVersionIdHeader) {
1259
1274
  const isEnvelope = typeof parsedBody === "object" && parsedBody !== null && "env" in parsedBody && "request" in parsedBody && "context" in parsedBody;
1260
1275
  if (isEnvelope) {
1261
1276
  const envelope = parsedBody;
@@ -1309,7 +1324,7 @@ function parseWebhookRequest(parsedBody, method, url, path3, headers, query, raw
1309
1324
  const webhookRequest = {
1310
1325
  method,
1311
1326
  url,
1312
- path: path3,
1327
+ path: path4,
1313
1328
  headers,
1314
1329
  query,
1315
1330
  body: parsedBody,
@@ -1338,9 +1353,17 @@ async function executeWebhookHandler(handle, webhookRegistry, data) {
1338
1353
  };
1339
1354
  let webhookResponse;
1340
1355
  try {
1356
+ const rateLimitContext = {
1357
+ app: data.webhookContext.app,
1358
+ appInstallationId: isRuntimeWebhookContext(data.webhookContext) ? data.webhookContext.appInstallationId : void 0,
1359
+ invocation: data.invocation,
1360
+ isProvisionContext: !isRuntimeWebhookContext(data.webhookContext)
1361
+ };
1341
1362
  webhookResponse = await runWithLogContext({ invocation: data.invocation }, async () => {
1342
1363
  return await runWithConfig(requestConfig, async () => {
1343
- return await webhookDef.handler(data.webhookRequest, data.webhookContext);
1364
+ return await runWithRateLimitExecutionContext(rateLimitContext, async () => {
1365
+ return await webhookDef.handler(data.webhookRequest, data.webhookContext);
1366
+ });
1344
1367
  });
1345
1368
  });
1346
1369
  } catch (err) {
@@ -1367,7 +1390,7 @@ function isMethodAllowed(webhookRegistry, handle, method) {
1367
1390
 
1368
1391
  // src/server/route-handlers/handlers.ts
1369
1392
  function getConfigFilePath() {
1370
- return process.env.LAMBDA_TASK_ROOT ? path2.join(process.env.LAMBDA_TASK_ROOT, ".skedyul", "config.json") : ".skedyul/config.json";
1393
+ return process.env.LAMBDA_TASK_ROOT ? path3.join(process.env.LAMBDA_TASK_ROOT, ".skedyul", "config.json") : ".skedyul/config.json";
1371
1394
  }
1372
1395
  function findToolInRegistry(registry, toolName) {
1373
1396
  for (const [key, t] of Object.entries(registry)) {
@@ -1406,8 +1429,8 @@ function handleHealthRoute(ctx) {
1406
1429
  function handleConfigRoute(ctx) {
1407
1430
  const configFilePath = getConfigFilePath();
1408
1431
  try {
1409
- if (fs2.existsSync(configFilePath)) {
1410
- const fileConfig = JSON.parse(fs2.readFileSync(configFilePath, "utf-8"));
1432
+ if (fs3.existsSync(configFilePath)) {
1433
+ const fileConfig = JSON.parse(fs3.readFileSync(configFilePath, "utf-8"));
1411
1434
  return { status: 200, body: fileConfig };
1412
1435
  }
1413
1436
  } catch (err) {
@@ -2095,6 +2118,7 @@ installContextLogger();
2095
2118
  function createSkedyulServer(config) {
2096
2119
  mergeRuntimeEnv();
2097
2120
  registerQueueConfig(config);
2121
+ registerSequencerConfig(config);
2098
2122
  const registry = config.tools;
2099
2123
  const webhookRegistry = config.webhooks;
2100
2124
  if (config.coreApi?.service) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skedyul",
3
- "version": "1.5.13",
3
+ "version": "1.7.0",
4
4
  "description": "The Skedyul SDK for Node.js",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -76,7 +76,7 @@
76
76
  "build": "rm -rf dist tsconfig.tsbuildinfo && tsc --emitDeclarationOnly && pnpm exec tsup-node",
77
77
  "db:generate": "echo 'No database generation needed for this package'",
78
78
  "dev": "npx nodemon --watch src --ext js,ts --exec \"pnpm run build\"",
79
- "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 dist-tests/tests/gsm7.test.js"
79
+ "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/sequencer.test.js dist-tests/tests/config-loader.test.js dist-tests/tests/gsm7.test.js"
80
80
  },
81
81
  "keywords": [
82
82
  "mcp",