skedyul 1.7.3 → 1.7.5

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/.build-stamp CHANGED
@@ -1 +1 @@
1
- 1785796289915
1
+ 1785810690937
package/dist/cli/index.js CHANGED
@@ -3111,6 +3111,26 @@ function parsePreAcquiredLeases(raw) {
3111
3111
  return void 0;
3112
3112
  }
3113
3113
  }
3114
+ function parseHeldMutexQueueKeys(raw) {
3115
+ if (!raw) {
3116
+ return void 0;
3117
+ }
3118
+ try {
3119
+ const parsed = JSON.parse(raw);
3120
+ if (!Array.isArray(parsed)) {
3121
+ return void 0;
3122
+ }
3123
+ const keys = parsed.filter(
3124
+ (item) => item != null && typeof item === "object" && typeof item.queueKey === "string" && typeof item.queueName === "string"
3125
+ ).map((item) => ({
3126
+ queueKey: item.queueKey,
3127
+ queueName: item.queueName
3128
+ }));
3129
+ return keys.length > 0 ? keys : void 0;
3130
+ } catch {
3131
+ return void 0;
3132
+ }
3133
+ }
3114
3134
  function buildToolMetadata(registry) {
3115
3135
  return Object.values(registry).map((tool) => {
3116
3136
  const toolConfig = tool.config ?? {};
@@ -3248,7 +3268,10 @@ function createCallToolHandler(registry, state, onMaxRequests) {
3248
3268
  appInstallationId: trigger === "provision" ? void 0 : rawContext.appInstallationId,
3249
3269
  invocation,
3250
3270
  isProvisionContext: trigger === "provision",
3251
- preAcquiredLeases: parsePreAcquiredLeases(toolEnv.SKEDYUL_RATE_LIMIT_LEASES)
3271
+ preAcquiredLeases: parsePreAcquiredLeases(toolEnv.SKEDYUL_RATE_LIMIT_LEASES),
3272
+ heldMutexQueueKeys: parseHeldMutexQueueKeys(
3273
+ toolEnv.SKEDYUL_HELD_MUTEX_QUEUE_KEYS
3274
+ )
3252
3275
  };
3253
3276
  const functionResult = await runWithConfig(requestConfig, async () => {
3254
3277
  return await runWithRateLimitExecutionContext(rateLimitContext, async () => {
@@ -441,6 +441,26 @@ function parsePreAcquiredLeases(raw) {
441
441
  return void 0;
442
442
  }
443
443
  }
444
+ function parseHeldMutexQueueKeys(raw) {
445
+ if (!raw) {
446
+ return void 0;
447
+ }
448
+ try {
449
+ const parsed = JSON.parse(raw);
450
+ if (!Array.isArray(parsed)) {
451
+ return void 0;
452
+ }
453
+ const keys = parsed.filter(
454
+ (item) => item != null && typeof item === "object" && typeof item.queueKey === "string" && typeof item.queueName === "string"
455
+ ).map((item) => ({
456
+ queueKey: item.queueKey,
457
+ queueName: item.queueName
458
+ }));
459
+ return keys.length > 0 ? keys : void 0;
460
+ } catch {
461
+ return void 0;
462
+ }
463
+ }
444
464
  function buildToolMetadata(registry) {
445
465
  return Object.values(registry).map((tool) => {
446
466
  const toolConfig = tool.config ?? {};
@@ -578,7 +598,10 @@ function createCallToolHandler(registry, state, onMaxRequests) {
578
598
  appInstallationId: trigger === "provision" ? void 0 : rawContext.appInstallationId,
579
599
  invocation,
580
600
  isProvisionContext: trigger === "provision",
581
- preAcquiredLeases: parsePreAcquiredLeases(toolEnv.SKEDYUL_RATE_LIMIT_LEASES)
601
+ preAcquiredLeases: parsePreAcquiredLeases(toolEnv.SKEDYUL_RATE_LIMIT_LEASES),
602
+ heldMutexQueueKeys: parseHeldMutexQueueKeys(
603
+ toolEnv.SKEDYUL_HELD_MUTEX_QUEUE_KEYS
604
+ )
582
605
  };
583
606
  const functionResult = await runWithConfig(requestConfig, async () => {
584
607
  return await runWithRateLimitExecutionContext(rateLimitContext, async () => {
@@ -3649,6 +3649,14 @@ function getActiveMutexQueueNames() {
3649
3649
  names.add(operation.resolved.name);
3650
3650
  }
3651
3651
  }
3652
+ const held = getRateLimitExecutionContext()?.heldMutexQueueKeys;
3653
+ if (held?.length) {
3654
+ for (const entry of held) {
3655
+ if (entry.queueName) {
3656
+ names.add(entry.queueName);
3657
+ }
3658
+ }
3659
+ }
3652
3660
  return [...names];
3653
3661
  }
3654
3662
  function shouldSkipNestedAcquire(queueName) {
@@ -3887,6 +3895,26 @@ function parsePreAcquiredLeases(raw) {
3887
3895
  return void 0;
3888
3896
  }
3889
3897
  }
3898
+ function parseHeldMutexQueueKeys(raw) {
3899
+ if (!raw) {
3900
+ return void 0;
3901
+ }
3902
+ try {
3903
+ const parsed = JSON.parse(raw);
3904
+ if (!Array.isArray(parsed)) {
3905
+ return void 0;
3906
+ }
3907
+ const keys = parsed.filter(
3908
+ (item) => item != null && typeof item === "object" && typeof item.queueKey === "string" && typeof item.queueName === "string"
3909
+ ).map((item) => ({
3910
+ queueKey: item.queueKey,
3911
+ queueName: item.queueName
3912
+ }));
3913
+ return keys.length > 0 ? keys : void 0;
3914
+ } catch {
3915
+ return void 0;
3916
+ }
3917
+ }
3890
3918
  function buildToolMetadata(registry) {
3891
3919
  return Object.values(registry).map((tool) => {
3892
3920
  const toolConfig = tool.config ?? {};
@@ -4024,7 +4052,10 @@ function createCallToolHandler(registry, state, onMaxRequests) {
4024
4052
  appInstallationId: trigger === "provision" ? void 0 : rawContext.appInstallationId,
4025
4053
  invocation,
4026
4054
  isProvisionContext: trigger === "provision",
4027
- preAcquiredLeases: parsePreAcquiredLeases(toolEnv.SKEDYUL_RATE_LIMIT_LEASES)
4055
+ preAcquiredLeases: parsePreAcquiredLeases(toolEnv.SKEDYUL_RATE_LIMIT_LEASES),
4056
+ heldMutexQueueKeys: parseHeldMutexQueueKeys(
4057
+ toolEnv.SKEDYUL_HELD_MUTEX_QUEUE_KEYS
4058
+ )
4028
4059
  };
4029
4060
  const functionResult = await runWithConfig(requestConfig, async () => {
4030
4061
  return await runWithRateLimitExecutionContext(rateLimitContext, async () => {
@@ -6416,6 +6447,11 @@ async function queuedFetch(queueInput, fnOrPromise) {
6416
6447
  function findPreAcquiredLease(queueKey, ctx) {
6417
6448
  return ctx?.preAcquiredLeases?.find((lease) => lease.queueKey === queueKey);
6418
6449
  }
6450
+ function isHeldMutexQueueKey(queueKey, ctx) {
6451
+ return Boolean(
6452
+ ctx?.heldMutexQueueKeys?.some((entry) => entry.queueKey === queueKey)
6453
+ );
6454
+ }
6419
6455
  function shouldRethrowRateLimitCause(maxRetries, error, attempt, shouldRetryFn) {
6420
6456
  if (maxRetries !== 0 || !shouldRetryFn(error, attempt)) {
6421
6457
  return false;
@@ -6433,10 +6469,14 @@ async function executeWithRetries(operation, maxRetries) {
6433
6469
  operation.resolved.queueKey,
6434
6470
  rateLimitCtx
6435
6471
  );
6472
+ const heldByPlatform = isHeldMutexQueueKey(
6473
+ operation.resolved.queueKey,
6474
+ rateLimitCtx
6475
+ );
6436
6476
  if (shouldSkipNestedAcquire(operation.resolved.name)) {
6437
6477
  return operation.fn();
6438
6478
  }
6439
- if (preAcquired) {
6479
+ if (preAcquired || heldByPlatform) {
6440
6480
  try {
6441
6481
  return await operation.fn();
6442
6482
  } catch (error) {
package/dist/index.js CHANGED
@@ -4023,6 +4023,14 @@ function getActiveMutexQueueNames() {
4023
4023
  names.add(operation.resolved.name);
4024
4024
  }
4025
4025
  }
4026
+ const held = getRateLimitExecutionContext()?.heldMutexQueueKeys;
4027
+ if (held?.length) {
4028
+ for (const entry of held) {
4029
+ if (entry.queueName) {
4030
+ names.add(entry.queueName);
4031
+ }
4032
+ }
4033
+ }
4026
4034
  return [...names];
4027
4035
  }
4028
4036
  function shouldSkipNestedAcquire(queueName) {
@@ -4261,6 +4269,26 @@ function parsePreAcquiredLeases(raw) {
4261
4269
  return void 0;
4262
4270
  }
4263
4271
  }
4272
+ function parseHeldMutexQueueKeys(raw) {
4273
+ if (!raw) {
4274
+ return void 0;
4275
+ }
4276
+ try {
4277
+ const parsed = JSON.parse(raw);
4278
+ if (!Array.isArray(parsed)) {
4279
+ return void 0;
4280
+ }
4281
+ const keys = parsed.filter(
4282
+ (item) => item != null && typeof item === "object" && typeof item.queueKey === "string" && typeof item.queueName === "string"
4283
+ ).map((item) => ({
4284
+ queueKey: item.queueKey,
4285
+ queueName: item.queueName
4286
+ }));
4287
+ return keys.length > 0 ? keys : void 0;
4288
+ } catch {
4289
+ return void 0;
4290
+ }
4291
+ }
4264
4292
  function buildToolMetadata(registry) {
4265
4293
  return Object.values(registry).map((tool) => {
4266
4294
  const toolConfig = tool.config ?? {};
@@ -4398,7 +4426,10 @@ function createCallToolHandler(registry, state, onMaxRequests) {
4398
4426
  appInstallationId: trigger === "provision" ? void 0 : rawContext.appInstallationId,
4399
4427
  invocation,
4400
4428
  isProvisionContext: trigger === "provision",
4401
- preAcquiredLeases: parsePreAcquiredLeases(toolEnv.SKEDYUL_RATE_LIMIT_LEASES)
4429
+ preAcquiredLeases: parsePreAcquiredLeases(toolEnv.SKEDYUL_RATE_LIMIT_LEASES),
4430
+ heldMutexQueueKeys: parseHeldMutexQueueKeys(
4431
+ toolEnv.SKEDYUL_HELD_MUTEX_QUEUE_KEYS
4432
+ )
4402
4433
  };
4403
4434
  const functionResult = await runWithConfig(requestConfig, async () => {
4404
4435
  return await runWithRateLimitExecutionContext(rateLimitContext, async () => {
@@ -6790,6 +6821,11 @@ async function queuedFetch(queueInput, fnOrPromise) {
6790
6821
  function findPreAcquiredLease(queueKey, ctx) {
6791
6822
  return ctx?.preAcquiredLeases?.find((lease) => lease.queueKey === queueKey);
6792
6823
  }
6824
+ function isHeldMutexQueueKey(queueKey, ctx) {
6825
+ return Boolean(
6826
+ ctx?.heldMutexQueueKeys?.some((entry) => entry.queueKey === queueKey)
6827
+ );
6828
+ }
6793
6829
  function shouldRethrowRateLimitCause(maxRetries, error, attempt, shouldRetryFn) {
6794
6830
  if (maxRetries !== 0 || !shouldRetryFn(error, attempt)) {
6795
6831
  return false;
@@ -6807,10 +6843,14 @@ async function executeWithRetries(operation, maxRetries) {
6807
6843
  operation.resolved.queueKey,
6808
6844
  rateLimitCtx
6809
6845
  );
6846
+ const heldByPlatform = isHeldMutexQueueKey(
6847
+ operation.resolved.queueKey,
6848
+ rateLimitCtx
6849
+ );
6810
6850
  if (shouldSkipNestedAcquire(operation.resolved.name)) {
6811
6851
  return operation.fn();
6812
6852
  }
6813
- if (preAcquired) {
6853
+ if (preAcquired || heldByPlatform) {
6814
6854
  try {
6815
6855
  return await operation.fn();
6816
6856
  } catch (error) {
@@ -4,7 +4,7 @@ export declare function getRateLimitExecutionContext(): RateLimitExecutionContex
4
4
  export declare function runWithActiveQueuedOperation<T>(operation: ActiveQueuedOperation<T>, fn: () => Promise<T>): Promise<T>;
5
5
  export declare function getActiveQueuedOperation<T>(): ActiveQueuedOperation<T> | undefined;
6
6
  export declare function getActiveQueuedOperationStack(): ActiveQueuedOperation<unknown>[];
7
- /** Active mutex queue names holding a lease in an outer queuedFetch. */
7
+ /** Active mutex queue names holding a lease in an outer queuedFetch or platform-held. */
8
8
  export declare function getActiveMutexQueueNames(): string[];
9
9
  /** True when an active mutex queue suppresses acquire for the target queue name. */
10
10
  export declare function shouldSkipNestedAcquire(queueName: string): boolean;
@@ -1,6 +1,10 @@
1
1
  import type { SerializableQueueConfig } from '../config/queue-config';
2
2
  import type { AppInfo } from '../types/shared';
3
3
  import type { InvocationContext } from '../types/invocation';
4
+ export interface HeldMutexQueueKey {
5
+ queueKey: string;
6
+ queueName: string;
7
+ }
4
8
  export interface RateLimitExecutionContext {
5
9
  app: AppInfo;
6
10
  appInstallationId?: string;
@@ -11,6 +15,12 @@ export interface RateLimitExecutionContext {
11
15
  queueKey: string;
12
16
  leaseId: string;
13
17
  }>;
18
+ /**
19
+ * Mutex queue keys held by platform Temporal orchestration for this tool call.
20
+ * queuedFetch skips acquire/release for matching keys; queue names count as active mutexes
21
+ * for suppressesQueues.
22
+ */
23
+ heldMutexQueueKeys?: HeldMutexQueueKey[];
14
24
  }
15
25
  export interface QueueSelector {
16
26
  queue: string;
@@ -4,6 +4,10 @@ export declare function parsePreAcquiredLeases(raw: string | undefined): Array<{
4
4
  queueKey: string;
5
5
  leaseId: string;
6
6
  }> | undefined;
7
+ export declare function parseHeldMutexQueueKeys(raw: string | undefined): Array<{
8
+ queueKey: string;
9
+ queueName: string;
10
+ }> | undefined;
7
11
  /**
8
12
  * Builds tool metadata array from a tool registry
9
13
  */
package/dist/server.js CHANGED
@@ -441,6 +441,26 @@ function parsePreAcquiredLeases(raw) {
441
441
  return void 0;
442
442
  }
443
443
  }
444
+ function parseHeldMutexQueueKeys(raw) {
445
+ if (!raw) {
446
+ return void 0;
447
+ }
448
+ try {
449
+ const parsed = JSON.parse(raw);
450
+ if (!Array.isArray(parsed)) {
451
+ return void 0;
452
+ }
453
+ const keys = parsed.filter(
454
+ (item) => item != null && typeof item === "object" && typeof item.queueKey === "string" && typeof item.queueName === "string"
455
+ ).map((item) => ({
456
+ queueKey: item.queueKey,
457
+ queueName: item.queueName
458
+ }));
459
+ return keys.length > 0 ? keys : void 0;
460
+ } catch {
461
+ return void 0;
462
+ }
463
+ }
444
464
  function buildToolMetadata(registry) {
445
465
  return Object.values(registry).map((tool) => {
446
466
  const toolConfig = tool.config ?? {};
@@ -578,7 +598,10 @@ function createCallToolHandler(registry, state, onMaxRequests) {
578
598
  appInstallationId: trigger === "provision" ? void 0 : rawContext.appInstallationId,
579
599
  invocation,
580
600
  isProvisionContext: trigger === "provision",
581
- preAcquiredLeases: parsePreAcquiredLeases(toolEnv.SKEDYUL_RATE_LIMIT_LEASES)
601
+ preAcquiredLeases: parsePreAcquiredLeases(toolEnv.SKEDYUL_RATE_LIMIT_LEASES),
602
+ heldMutexQueueKeys: parseHeldMutexQueueKeys(
603
+ toolEnv.SKEDYUL_HELD_MUTEX_QUEUE_KEYS
604
+ )
582
605
  };
583
606
  const functionResult = await runWithConfig(requestConfig, async () => {
584
607
  return await runWithRateLimitExecutionContext(rateLimitContext, async () => {
@@ -402,6 +402,26 @@ function parsePreAcquiredLeases(raw) {
402
402
  return void 0;
403
403
  }
404
404
  }
405
+ function parseHeldMutexQueueKeys(raw) {
406
+ if (!raw) {
407
+ return void 0;
408
+ }
409
+ try {
410
+ const parsed = JSON.parse(raw);
411
+ if (!Array.isArray(parsed)) {
412
+ return void 0;
413
+ }
414
+ const keys = parsed.filter(
415
+ (item) => item != null && typeof item === "object" && typeof item.queueKey === "string" && typeof item.queueName === "string"
416
+ ).map((item) => ({
417
+ queueKey: item.queueKey,
418
+ queueName: item.queueName
419
+ }));
420
+ return keys.length > 0 ? keys : void 0;
421
+ } catch {
422
+ return void 0;
423
+ }
424
+ }
405
425
  function buildToolMetadata(registry) {
406
426
  return Object.values(registry).map((tool) => {
407
427
  const toolConfig = tool.config ?? {};
@@ -539,7 +559,10 @@ function createCallToolHandler(registry, state, onMaxRequests) {
539
559
  appInstallationId: trigger === "provision" ? void 0 : rawContext.appInstallationId,
540
560
  invocation,
541
561
  isProvisionContext: trigger === "provision",
542
- preAcquiredLeases: parsePreAcquiredLeases(toolEnv.SKEDYUL_RATE_LIMIT_LEASES)
562
+ preAcquiredLeases: parsePreAcquiredLeases(toolEnv.SKEDYUL_RATE_LIMIT_LEASES),
563
+ heldMutexQueueKeys: parseHeldMutexQueueKeys(
564
+ toolEnv.SKEDYUL_HELD_MUTEX_QUEUE_KEYS
565
+ )
543
566
  };
544
567
  const functionResult = await runWithConfig(requestConfig, async () => {
545
568
  return await runWithRateLimitExecutionContext(rateLimitContext, async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skedyul",
3
- "version": "1.7.3",
3
+ "version": "1.7.5",
4
4
  "description": "The Skedyul SDK for Node.js",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",