skedyul 1.5.2 → 1.5.12

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.
@@ -4,7 +4,9 @@ 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
- /** True when petbooqz_calendar_booking holds a lease in an outer queuedFetch. */
8
- export declare function isInsidePetbooqzCalendarBookingMutex(): boolean;
7
+ /** Active mutex queue names holding a lease in an outer queuedFetch. */
8
+ export declare function getActiveMutexQueueNames(): string[];
9
+ /** True when an active mutex queue suppresses acquire for the target queue name. */
10
+ export declare function shouldSkipNestedAcquire(queueName: string): boolean;
9
11
  export declare function setActiveQueuedOperationLease(lease: ActiveQueuedOperation<unknown>['lease']): void;
10
12
  export declare function updateActiveQueuedOperationAttempt(attempt: number): void;
package/dist/schemas.d.ts CHANGED
@@ -369,12 +369,21 @@ export declare const ChannelCapabilityTypeSchema: z.ZodEnum<{
369
369
  messaging: "messaging";
370
370
  video: "video";
371
371
  }>;
372
+ /** Batch send + status poll capability (preferred over bare send_batch string) */
373
+ export declare const ChannelBatchCapabilitySchema: z.ZodObject<{
374
+ send: z.ZodString;
375
+ get_status: z.ZodString;
376
+ }, z.core.$strip>;
372
377
  /** Capability definition with display info and handler references */
373
378
  export declare const ChannelCapabilitySchema: z.ZodObject<{
374
379
  label: z.ZodString;
375
380
  icon: z.ZodOptional<z.ZodString>;
376
381
  receive: z.ZodOptional<z.ZodString>;
377
382
  send: z.ZodOptional<z.ZodString>;
383
+ send_batch: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
384
+ send: z.ZodString;
385
+ get_status: z.ZodString;
386
+ }, z.core.$strip>]>>;
378
387
  }, z.core.$strip>;
379
388
  /**
380
389
  * Field definition for channel field mappings.
@@ -455,18 +464,30 @@ export declare const ChannelDefinitionSchema: z.ZodObject<{
455
464
  icon: z.ZodOptional<z.ZodString>;
456
465
  receive: z.ZodOptional<z.ZodString>;
457
466
  send: z.ZodOptional<z.ZodString>;
467
+ send_batch: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
468
+ send: z.ZodString;
469
+ get_status: z.ZodString;
470
+ }, z.core.$strip>]>>;
458
471
  }, z.core.$strip>>;
459
472
  voice: z.ZodOptional<z.ZodObject<{
460
473
  label: z.ZodString;
461
474
  icon: z.ZodOptional<z.ZodString>;
462
475
  receive: z.ZodOptional<z.ZodString>;
463
476
  send: z.ZodOptional<z.ZodString>;
477
+ send_batch: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
478
+ send: z.ZodString;
479
+ get_status: z.ZodString;
480
+ }, z.core.$strip>]>>;
464
481
  }, z.core.$strip>>;
465
482
  video: z.ZodOptional<z.ZodObject<{
466
483
  label: z.ZodString;
467
484
  icon: z.ZodOptional<z.ZodString>;
468
485
  receive: z.ZodOptional<z.ZodString>;
469
486
  send: z.ZodOptional<z.ZodString>;
487
+ send_batch: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
488
+ send: z.ZodString;
489
+ get_status: z.ZodString;
490
+ }, z.core.$strip>]>>;
470
491
  }, z.core.$strip>>;
471
492
  }, z.core.$strip>;
472
493
  }, z.core.$strip>;
@@ -3384,18 +3405,30 @@ export declare const ProvisionConfigSchema: z.ZodObject<{
3384
3405
  icon: z.ZodOptional<z.ZodString>;
3385
3406
  receive: z.ZodOptional<z.ZodString>;
3386
3407
  send: z.ZodOptional<z.ZodString>;
3408
+ send_batch: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
3409
+ send: z.ZodString;
3410
+ get_status: z.ZodString;
3411
+ }, z.core.$strip>]>>;
3387
3412
  }, z.core.$strip>>;
3388
3413
  voice: z.ZodOptional<z.ZodObject<{
3389
3414
  label: z.ZodString;
3390
3415
  icon: z.ZodOptional<z.ZodString>;
3391
3416
  receive: z.ZodOptional<z.ZodString>;
3392
3417
  send: z.ZodOptional<z.ZodString>;
3418
+ send_batch: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
3419
+ send: z.ZodString;
3420
+ get_status: z.ZodString;
3421
+ }, z.core.$strip>]>>;
3393
3422
  }, z.core.$strip>>;
3394
3423
  video: z.ZodOptional<z.ZodObject<{
3395
3424
  label: z.ZodString;
3396
3425
  icon: z.ZodOptional<z.ZodString>;
3397
3426
  receive: z.ZodOptional<z.ZodString>;
3398
3427
  send: z.ZodOptional<z.ZodString>;
3428
+ send_batch: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
3429
+ send: z.ZodString;
3430
+ get_status: z.ZodString;
3431
+ }, z.core.$strip>]>>;
3399
3432
  }, z.core.$strip>>;
3400
3433
  }, z.core.$strip>;
3401
3434
  }, z.core.$strip>>>;
@@ -4107,18 +4140,30 @@ export declare const SkedyulConfigSchema: z.ZodObject<{
4107
4140
  icon: z.ZodOptional<z.ZodString>;
4108
4141
  receive: z.ZodOptional<z.ZodString>;
4109
4142
  send: z.ZodOptional<z.ZodString>;
4143
+ send_batch: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
4144
+ send: z.ZodString;
4145
+ get_status: z.ZodString;
4146
+ }, z.core.$strip>]>>;
4110
4147
  }, z.core.$strip>>;
4111
4148
  voice: z.ZodOptional<z.ZodObject<{
4112
4149
  label: z.ZodString;
4113
4150
  icon: z.ZodOptional<z.ZodString>;
4114
4151
  receive: z.ZodOptional<z.ZodString>;
4115
4152
  send: z.ZodOptional<z.ZodString>;
4153
+ send_batch: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
4154
+ send: z.ZodString;
4155
+ get_status: z.ZodString;
4156
+ }, z.core.$strip>]>>;
4116
4157
  }, z.core.$strip>>;
4117
4158
  video: z.ZodOptional<z.ZodObject<{
4118
4159
  label: z.ZodString;
4119
4160
  icon: z.ZodOptional<z.ZodString>;
4120
4161
  receive: z.ZodOptional<z.ZodString>;
4121
4162
  send: z.ZodOptional<z.ZodString>;
4163
+ send_batch: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
4164
+ send: z.ZodString;
4165
+ get_status: z.ZodString;
4166
+ }, z.core.$strip>]>>;
4122
4167
  }, z.core.$strip>>;
4123
4168
  }, z.core.$strip>;
4124
4169
  }, z.core.$strip>>>;
@@ -4812,6 +4857,104 @@ export type MessageSendAttachment = z.infer<typeof MessageSendAttachmentSchema>;
4812
4857
  export type MessageSendMessage = z.infer<typeof MessageSendMessageSchema>;
4813
4858
  export type MessageSendInput = z.infer<typeof MessageSendInputSchema>;
4814
4859
  export type MessageSendOutput = z.infer<typeof MessageSendOutputSchema>;
4860
+ export declare const MessageBulkRecipientSchema: z.ZodObject<{
4861
+ address: z.ZodString;
4862
+ renderedBody: z.ZodString;
4863
+ instanceId: z.ZodOptional<z.ZodString>;
4864
+ threadId: z.ZodOptional<z.ZodString>;
4865
+ messageId: z.ZodOptional<z.ZodString>;
4866
+ contactId: z.ZodOptional<z.ZodString>;
4867
+ }, z.core.$strip>;
4868
+ export declare const MessageBulkSendInputSchema: z.ZodObject<{
4869
+ channel: z.ZodObject<{
4870
+ id: z.ZodString;
4871
+ handle: z.ZodString;
4872
+ identifierValue: z.ZodString;
4873
+ }, z.core.$strip>;
4874
+ recipients: z.ZodArray<z.ZodObject<{
4875
+ address: z.ZodString;
4876
+ renderedBody: z.ZodString;
4877
+ instanceId: z.ZodOptional<z.ZodString>;
4878
+ threadId: z.ZodOptional<z.ZodString>;
4879
+ messageId: z.ZodOptional<z.ZodString>;
4880
+ contactId: z.ZodOptional<z.ZodString>;
4881
+ }, z.core.$strip>>;
4882
+ schedule: z.ZodOptional<z.ZodObject<{
4883
+ at: z.ZodString;
4884
+ }, z.core.$strip>>;
4885
+ }, z.core.$strip>;
4886
+ export declare const MessageBulkSendOutputSchema: z.ZodObject<{
4887
+ status: z.ZodEnum<{
4888
+ failed: "failed";
4889
+ accepted: "accepted";
4890
+ }>;
4891
+ operationId: z.ZodOptional<z.ZodString>;
4892
+ acceptedCount: z.ZodNumber;
4893
+ rejectedCount: z.ZodOptional<z.ZodNumber>;
4894
+ }, z.core.$strip>;
4895
+ export type MessageBulkRecipient = z.infer<typeof MessageBulkRecipientSchema>;
4896
+ export type MessageBulkSendInput = z.infer<typeof MessageBulkSendInputSchema>;
4897
+ export type MessageBulkSendOutput = z.infer<typeof MessageBulkSendOutputSchema>;
4898
+ export declare const MessageBulkStatusMessageSchema: z.ZodObject<{
4899
+ address: z.ZodString;
4900
+ status: z.ZodString;
4901
+ messageId: z.ZodOptional<z.ZodString>;
4902
+ errorCode: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
4903
+ errorMessage: z.ZodOptional<z.ZodString>;
4904
+ }, z.core.$strip>;
4905
+ export declare const MessageBulkStatusStatsSchema: z.ZodObject<{
4906
+ total: z.ZodOptional<z.ZodNumber>;
4907
+ recipients: z.ZodOptional<z.ZodNumber>;
4908
+ attempts: z.ZodOptional<z.ZodNumber>;
4909
+ unaddressable: z.ZodOptional<z.ZodNumber>;
4910
+ queued: z.ZodOptional<z.ZodNumber>;
4911
+ sent: z.ZodOptional<z.ZodNumber>;
4912
+ scheduled: z.ZodOptional<z.ZodNumber>;
4913
+ delivered: z.ZodOptional<z.ZodNumber>;
4914
+ read: z.ZodOptional<z.ZodNumber>;
4915
+ undelivered: z.ZodOptional<z.ZodNumber>;
4916
+ failed: z.ZodOptional<z.ZodNumber>;
4917
+ canceled: z.ZodOptional<z.ZodNumber>;
4918
+ }, z.core.$strip>;
4919
+ export declare const MessageBulkStatusInputSchema: z.ZodObject<{
4920
+ channel: z.ZodObject<{
4921
+ id: z.ZodString;
4922
+ handle: z.ZodString;
4923
+ identifierValue: z.ZodString;
4924
+ }, z.core.$strip>;
4925
+ operationId: z.ZodString;
4926
+ }, z.core.$strip>;
4927
+ export declare const MessageBulkStatusOutputSchema: z.ZodObject<{
4928
+ operationId: z.ZodString;
4929
+ status: z.ZodString;
4930
+ complete: z.ZodBoolean;
4931
+ mock: z.ZodOptional<z.ZodBoolean>;
4932
+ stats: z.ZodOptional<z.ZodObject<{
4933
+ total: z.ZodOptional<z.ZodNumber>;
4934
+ recipients: z.ZodOptional<z.ZodNumber>;
4935
+ attempts: z.ZodOptional<z.ZodNumber>;
4936
+ unaddressable: z.ZodOptional<z.ZodNumber>;
4937
+ queued: z.ZodOptional<z.ZodNumber>;
4938
+ sent: z.ZodOptional<z.ZodNumber>;
4939
+ scheduled: z.ZodOptional<z.ZodNumber>;
4940
+ delivered: z.ZodOptional<z.ZodNumber>;
4941
+ read: z.ZodOptional<z.ZodNumber>;
4942
+ undelivered: z.ZodOptional<z.ZodNumber>;
4943
+ failed: z.ZodOptional<z.ZodNumber>;
4944
+ canceled: z.ZodOptional<z.ZodNumber>;
4945
+ }, z.core.$strip>>;
4946
+ messages: z.ZodArray<z.ZodObject<{
4947
+ address: z.ZodString;
4948
+ status: z.ZodString;
4949
+ messageId: z.ZodOptional<z.ZodString>;
4950
+ errorCode: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
4951
+ errorMessage: z.ZodOptional<z.ZodString>;
4952
+ }, z.core.$strip>>;
4953
+ }, z.core.$strip>;
4954
+ export type MessageBulkStatusMessage = z.infer<typeof MessageBulkStatusMessageSchema>;
4955
+ export type MessageBulkStatusStats = z.infer<typeof MessageBulkStatusStatsSchema>;
4956
+ export type MessageBulkStatusInput = z.infer<typeof MessageBulkStatusInputSchema>;
4957
+ export type MessageBulkStatusOutput = z.infer<typeof MessageBulkStatusOutputSchema>;
4815
4958
  export declare function isModelDependency(dep: ResourceDependency): dep is ModelDependency;
4816
4959
  export declare function isChannelDependency(dep: ResourceDependency): dep is ChannelDependency;
4817
4960
  export declare function isWorkflowDependency(dep: ResourceDependency): dep is WorkflowDependency;
@@ -1,9 +1,9 @@
1
1
  import * as z from 'zod';
2
- import type { BillingInfo, ToolSchema, ToolSchemaWithJson } from '../../types';
2
+ import type { BillingInfo, ToolBilling, ToolSchema, ToolSchemaWithJson } from '../../types';
3
3
  /**
4
- * Normalizes billing info to ensure credits field exists
4
+ * Normalizes billing info to ensure credits field exists while preserving estimate data.
5
5
  */
6
- export declare function normalizeBilling(billing?: BillingInfo): BillingInfo;
6
+ export declare function normalizeBilling(billing?: BillingInfo | ToolBilling): ToolBilling;
7
7
  /**
8
8
  * Converts a Zod schema to JSON Schema format
9
9
  */
package/dist/server.js CHANGED
@@ -100,9 +100,12 @@ function registerQueueConfig(config) {
100
100
  // src/server/utils/schema.ts
101
101
  var z = __toESM(require("zod"));
102
102
  function normalizeBilling(billing) {
103
- if (!billing || typeof billing.credits !== "number") {
103
+ if (!billing || typeof billing !== "object") {
104
104
  return { credits: 0 };
105
105
  }
106
+ if (typeof billing.credits !== "number") {
107
+ return { ...billing, credits: 0 };
108
+ }
106
109
  return billing;
107
110
  }
108
111
  function toJsonSchema(schema) {
@@ -436,6 +439,7 @@ function buildToolMetadata(registry) {
436
439
  const timeout = typeof rawTimeout === "number" && rawTimeout > 0 ? rawTimeout : 1e4;
437
440
  const retries = typeof rawRetries === "number" && rawRetries >= 1 ? rawRetries : 1;
438
441
  const queueTouchPoints = tool.queueTouchPoints ?? toolConfig.queueTouchPoints;
442
+ const rateLimitHandoff = tool.rateLimitHandoff ?? toolConfig.rateLimitHandoff;
439
443
  return {
440
444
  name: tool.name,
441
445
  displayName: tool.label || tool.name,
@@ -446,11 +450,13 @@ function buildToolMetadata(registry) {
446
450
  timeout,
447
451
  retries,
448
452
  queueTouchPoints,
453
+ rateLimitHandoff,
449
454
  config: {
450
455
  timeout,
451
456
  retries,
452
457
  completionHints: toolConfig.completionHints,
453
- queueTouchPoints
458
+ queueTouchPoints,
459
+ rateLimitHandoff
454
460
  }
455
461
  };
456
462
  });
@@ -492,7 +498,8 @@ function createCallToolHandler(registry, state, onMaxRequests) {
492
498
  }
493
499
  const fn = tool.handler;
494
500
  const args = toolArgsInput ?? {};
495
- const estimateMode = args.estimate === true;
501
+ const rawContextForMode = args.context ?? {};
502
+ const estimateMode = args.estimate === true || rawContextForMode.mode === "estimate";
496
503
  if (!estimateMode) {
497
504
  state.incrementRequestCount();
498
505
  if (state.shouldShutdown()) {
@@ -979,7 +986,8 @@ function serializeConfig(config) {
979
986
  // Read timeout/retries from top-level first, then fallback to config
980
987
  timeout: tool.timeout ?? tool.config?.timeout,
981
988
  retries: tool.retries ?? tool.config?.retries,
982
- queueTouchPoints: tool.queueTouchPoints ?? tool.config?.queueTouchPoints
989
+ queueTouchPoints: tool.queueTouchPoints ?? tool.config?.queueTouchPoints,
990
+ rateLimitHandoff: tool.rateLimitHandoff ?? tool.config?.rateLimitHandoff
983
991
  })) : [],
984
992
  webhooks: webhookRegistry ? Object.values(webhookRegistry).map((w) => ({
985
993
  name: w.name,
@@ -1674,11 +1682,12 @@ async function handleMcpRoute(req, ctx) {
1674
1682
  async function handleMcpToolsCall(params, id, ctx) {
1675
1683
  const toolName = params?.name;
1676
1684
  const rawArgs = params?.arguments ?? {};
1677
- const hasSkedyulFormat = "inputs" in rawArgs || "env" in rawArgs || "context" in rawArgs || "invocation" in rawArgs;
1685
+ const hasSkedyulFormat = "inputs" in rawArgs || "env" in rawArgs || "context" in rawArgs || "invocation" in rawArgs || "estimate" in rawArgs;
1678
1686
  const toolInputs = hasSkedyulFormat ? rawArgs.inputs ?? {} : rawArgs;
1679
1687
  const toolContext = hasSkedyulFormat ? rawArgs.context : void 0;
1680
1688
  const toolEnv = hasSkedyulFormat ? rawArgs.env : void 0;
1681
1689
  const toolInvocation = hasSkedyulFormat ? rawArgs.invocation : void 0;
1690
+ const estimate = hasSkedyulFormat && rawArgs.estimate === true;
1682
1691
  const found = findToolInRegistry(ctx.registry, toolName);
1683
1692
  if (!found) {
1684
1693
  return {
@@ -1703,7 +1712,8 @@ async function handleMcpToolsCall(params, id, ctx) {
1703
1712
  inputs: validatedInputs,
1704
1713
  context: toolContext,
1705
1714
  env: toolEnv,
1706
- invocation: toolInvocation
1715
+ invocation: toolInvocation,
1716
+ estimate
1707
1717
  });
1708
1718
  let result;
1709
1719
  const isFailure = isToolCallFailure(toolResult);
@@ -61,9 +61,12 @@ function registerQueueConfig(config) {
61
61
  // src/server/utils/schema.ts
62
62
  import * as z from "zod";
63
63
  function normalizeBilling(billing) {
64
- if (!billing || typeof billing.credits !== "number") {
64
+ if (!billing || typeof billing !== "object") {
65
65
  return { credits: 0 };
66
66
  }
67
+ if (typeof billing.credits !== "number") {
68
+ return { ...billing, credits: 0 };
69
+ }
67
70
  return billing;
68
71
  }
69
72
  function toJsonSchema(schema) {
@@ -397,6 +400,7 @@ function buildToolMetadata(registry) {
397
400
  const timeout = typeof rawTimeout === "number" && rawTimeout > 0 ? rawTimeout : 1e4;
398
401
  const retries = typeof rawRetries === "number" && rawRetries >= 1 ? rawRetries : 1;
399
402
  const queueTouchPoints = tool.queueTouchPoints ?? toolConfig.queueTouchPoints;
403
+ const rateLimitHandoff = tool.rateLimitHandoff ?? toolConfig.rateLimitHandoff;
400
404
  return {
401
405
  name: tool.name,
402
406
  displayName: tool.label || tool.name,
@@ -407,11 +411,13 @@ function buildToolMetadata(registry) {
407
411
  timeout,
408
412
  retries,
409
413
  queueTouchPoints,
414
+ rateLimitHandoff,
410
415
  config: {
411
416
  timeout,
412
417
  retries,
413
418
  completionHints: toolConfig.completionHints,
414
- queueTouchPoints
419
+ queueTouchPoints,
420
+ rateLimitHandoff
415
421
  }
416
422
  };
417
423
  });
@@ -453,7 +459,8 @@ function createCallToolHandler(registry, state, onMaxRequests) {
453
459
  }
454
460
  const fn = tool.handler;
455
461
  const args = toolArgsInput ?? {};
456
- const estimateMode = args.estimate === true;
462
+ const rawContextForMode = args.context ?? {};
463
+ const estimateMode = args.estimate === true || rawContextForMode.mode === "estimate";
457
464
  if (!estimateMode) {
458
465
  state.incrementRequestCount();
459
466
  if (state.shouldShutdown()) {
@@ -940,7 +947,8 @@ function serializeConfig(config) {
940
947
  // Read timeout/retries from top-level first, then fallback to config
941
948
  timeout: tool.timeout ?? tool.config?.timeout,
942
949
  retries: tool.retries ?? tool.config?.retries,
943
- queueTouchPoints: tool.queueTouchPoints ?? tool.config?.queueTouchPoints
950
+ queueTouchPoints: tool.queueTouchPoints ?? tool.config?.queueTouchPoints,
951
+ rateLimitHandoff: tool.rateLimitHandoff ?? tool.config?.rateLimitHandoff
944
952
  })) : [],
945
953
  webhooks: webhookRegistry ? Object.values(webhookRegistry).map((w) => ({
946
954
  name: w.name,
@@ -1635,11 +1643,12 @@ async function handleMcpRoute(req, ctx) {
1635
1643
  async function handleMcpToolsCall(params, id, ctx) {
1636
1644
  const toolName = params?.name;
1637
1645
  const rawArgs = params?.arguments ?? {};
1638
- const hasSkedyulFormat = "inputs" in rawArgs || "env" in rawArgs || "context" in rawArgs || "invocation" in rawArgs;
1646
+ const hasSkedyulFormat = "inputs" in rawArgs || "env" in rawArgs || "context" in rawArgs || "invocation" in rawArgs || "estimate" in rawArgs;
1639
1647
  const toolInputs = hasSkedyulFormat ? rawArgs.inputs ?? {} : rawArgs;
1640
1648
  const toolContext = hasSkedyulFormat ? rawArgs.context : void 0;
1641
1649
  const toolEnv = hasSkedyulFormat ? rawArgs.env : void 0;
1642
1650
  const toolInvocation = hasSkedyulFormat ? rawArgs.invocation : void 0;
1651
+ const estimate = hasSkedyulFormat && rawArgs.estimate === true;
1643
1652
  const found = findToolInRegistry(ctx.registry, toolName);
1644
1653
  if (!found) {
1645
1654
  return {
@@ -1664,7 +1673,8 @@ async function handleMcpToolsCall(params, id, ctx) {
1664
1673
  inputs: validatedInputs,
1665
1674
  context: toolContext,
1666
1675
  env: toolEnv,
1667
- invocation: toolInvocation
1676
+ invocation: toolInvocation,
1677
+ estimate
1668
1678
  });
1669
1679
  let result;
1670
1680
  const isFailure = isToolCallFailure(toolResult);
@@ -0,0 +1,11 @@
1
+ export type SmsEncoding = 'GSM-7' | 'UCS-2';
2
+ export type SmsSegmentEstimate = {
3
+ encoding: SmsEncoding;
4
+ characters: number;
5
+ septets?: number;
6
+ segments: number;
7
+ };
8
+ /** Strip characters that are not encodable in GSM-7. */
9
+ export declare function toGsm7(value: unknown): string;
10
+ /** Estimate SMS segment count for a message body. */
11
+ export declare function estimateSmsSegments(text: string): SmsSegmentEstimate;
@@ -0,0 +1,95 @@
1
+ import { z } from 'zod/v4';
2
+ import type { ToolBilling } from './tool';
3
+ /**
4
+ * Money expressed in a currency's minor unit (e.g. cents, pence).
5
+ * Use ISO 4217 codes so amounts format correctly across locales.
6
+ */
7
+ export interface MoneyMinorUnits {
8
+ /** ISO 4217 currency code (USD, AUD, EUR, …) */
9
+ currency: string;
10
+ /** Amount in the currency's smallest unit */
11
+ minorUnits: number;
12
+ }
13
+ /** Inclusive range of estimated charges in minor currency units. */
14
+ export interface MoneyMinorRange {
15
+ currency: string;
16
+ minorUnitsLow: number;
17
+ minorUnitsHigh: number;
18
+ /** Optional skewed expected charge for single-value display (~$X.XX). */
19
+ minorUnitsExpected?: number;
20
+ }
21
+ /** Why a cohort member was excluded from a bulk send estimate. */
22
+ export interface EstimationSkippedBreakdown {
23
+ missingAddress: number;
24
+ optOut: number;
25
+ emptyMessage: number;
26
+ unavailable: number;
27
+ }
28
+ /**
29
+ * Standard estimate payload for tool estimate mode and platform estimate APIs.
30
+ * Channel-agnostic — integrations populate `cost` when pricing is known.
31
+ */
32
+ export interface Estimation {
33
+ deliverableCount: number;
34
+ skippedCount?: number;
35
+ skippedBreakdown?: EstimationSkippedBreakdown;
36
+ cost?: MoneyMinorRange;
37
+ }
38
+ export declare const MoneyMinorRangeSchema: z.ZodObject<{
39
+ currency: z.ZodString;
40
+ minorUnitsLow: z.ZodNumber;
41
+ minorUnitsHigh: z.ZodNumber;
42
+ minorUnitsExpected: z.ZodOptional<z.ZodNumber>;
43
+ }, z.core.$strip>;
44
+ export declare const EstimationSkippedBreakdownSchema: z.ZodObject<{
45
+ missingAddress: z.ZodNumber;
46
+ optOut: z.ZodNumber;
47
+ emptyMessage: z.ZodNumber;
48
+ unavailable: z.ZodNumber;
49
+ }, z.core.$strip>;
50
+ export declare const EstimationSchema: z.ZodObject<{
51
+ deliverableCount: z.ZodNumber;
52
+ skippedCount: z.ZodOptional<z.ZodNumber>;
53
+ skippedBreakdown: z.ZodOptional<z.ZodObject<{
54
+ missingAddress: z.ZodNumber;
55
+ optOut: z.ZodNumber;
56
+ emptyMessage: z.ZodNumber;
57
+ unavailable: z.ZodNumber;
58
+ }, z.core.$strip>>;
59
+ cost: z.ZodOptional<z.ZodObject<{
60
+ currency: z.ZodString;
61
+ minorUnitsLow: z.ZodNumber;
62
+ minorUnitsHigh: z.ZodNumber;
63
+ minorUnitsExpected: z.ZodOptional<z.ZodNumber>;
64
+ }, z.core.$strip>>;
65
+ }, z.core.$strip>;
66
+ export declare function createMoneyMinorRange(params: {
67
+ currency: string;
68
+ minorUnitsLow: number;
69
+ minorUnitsHigh: number;
70
+ minorUnitsExpected?: number;
71
+ }): MoneyMinorRange;
72
+ export declare function createEstimation(params: {
73
+ deliverableCount: number;
74
+ skippedCount?: number;
75
+ skippedBreakdown?: EstimationSkippedBreakdown;
76
+ cost?: MoneyMinorRange;
77
+ }): Estimation;
78
+ /** Skew expected cost toward the typical case when only a range is known. */
79
+ export declare function computeSkewedExpectedMinorUnits(range: MoneyMinorRange): number;
80
+ export type FormatMoneyMinorEstimateOptions = {
81
+ locale?: string;
82
+ /** When set, overrides computed skew for display. */
83
+ expectedMinorUnits?: number;
84
+ /** Show a range instead of ~estimate when high/low ratio exceeds this (default 4). */
85
+ maxSpreadRatio?: number;
86
+ };
87
+ /** Format a minor-unit cost range for display (single amount when low === high). */
88
+ export declare function formatMoneyMinorRange(range: MoneyMinorRange, locale?: string): string;
89
+ /**
90
+ * Format an estimated charge for UI: prefer a single ~$X.XX educated guess.
91
+ * Falls back to a low–high range when the spread is still too wide.
92
+ */
93
+ export declare function formatMoneyMinorEstimate(range: MoneyMinorRange, options?: FormatMoneyMinorEstimateOptions): string;
94
+ /** Read standardized estimation from tool billing (supports legacy flat cost fields). */
95
+ export declare function parseEstimationFromBilling(billing?: ToolBilling | Record<string, unknown>): Estimation | undefined;
@@ -10,6 +10,9 @@ export { createToolCallContext, createServerHookContext, createWebhookContext, c
10
10
  export type { ToolTrigger, ProvisionToolContext, DeveloperPageActionToolContext, DeveloperFormSubmitToolContext, FieldChangeToolContext, PageActionToolContext, FormSubmitToolContext, AgentToolContext, WorkflowToolContext, CronToolContext, CronContext, ToolExecutionContext, } from './tool-context';
11
11
  export { isProvisionContext, isRuntimeContext, isCronContext, isDeveloperContext } from './tool-context';
12
12
  export type { ToolResult, ToolSuccess, ToolFailure, ErrorCode, ErrorCategory, ToolWarning, ToolPagination, ToolBilling, ToolRetry, ToolTiming, ToolCompletionHints, ToolConfig, QueueTouchPoint, BillingInfo, ToolResponseMeta, ToolEffect, ToolError, ToolExecutionResult, ToolSchemaWithJson, ToolSchema, ToolHandler, ToolDefinition, ToolRegistryEntry, ToolRegistry, ToolName, ToolMetadata, ToolCallResponse, ExecutionScope, } from './tool';
13
+ export type { MoneyMinorUnits, MoneyMinorRange, Estimation, EstimationSkippedBreakdown } from './estimation';
14
+ export { MoneyMinorRangeSchema, EstimationSchema, EstimationSkippedBreakdownSchema, createMoneyMinorRange, createEstimation, parseEstimationFromBilling, formatMoneyMinorRange, formatMoneyMinorEstimate, computeSkewedExpectedMinorUnits, } from './estimation';
15
+ export type { FormatMoneyMinorEstimateOptions } from './estimation';
13
16
  export { ToolResponseMetaSchema } from './tool';
14
17
  export { createSuccessResponse, createListResponse, createErrorResponse, createValidationError, createNotFoundError, createAuthError, createRateLimitError, createExternalError, createTimeoutError, createPermissionError, createConflictError, isSuccess, isFailure, isRetryable, getRetryDelay, } from './tool-response';
15
18
  export type { HealthStatus, ComputeLayer, DedicatedServerInstance, ServerlessServerInstance, SkedyulServerInstance, } from './server';
@@ -60,9 +60,23 @@ export interface ToolPagination {
60
60
  * Billing/usage information.
61
61
  */
62
62
  export interface ToolBilling {
63
- credits: number;
63
+ credits?: number;
64
64
  tokens?: number;
65
65
  cost?: number;
66
+ /** Standard estimate payload (preferred for estimate-mode tool calls). */
67
+ estimation?: import('./estimation').Estimation;
68
+ /**
69
+ * @deprecated Use `estimation.cost` — legacy flat minor-unit bounds.
70
+ */
71
+ costCentsLow?: number;
72
+ /**
73
+ * @deprecated Use `estimation.cost` — legacy flat minor-unit bounds.
74
+ */
75
+ costCentsHigh?: number;
76
+ /**
77
+ * @deprecated Use `estimation.cost.currency` — legacy ISO 4217 code.
78
+ */
79
+ currency?: string;
66
80
  }
67
81
  /**
68
82
  * Client-side effects to execute after tool completion.
@@ -104,6 +118,11 @@ export interface QueueTouchPoint {
104
118
  /** True for correctness mutexes — excluded from rate-limit probe admission */
105
119
  mutexOnly?: boolean;
106
120
  }
121
+ /** Workflow mutex handoff role for multi-step tool.call sequences. */
122
+ export interface RateLimitHandoff {
123
+ role: 'mutex_reserve' | 'mutex_confirm' | 'mutex_book';
124
+ group?: string;
125
+ }
107
126
  export interface ToolConfig {
108
127
  /** Timeout in milliseconds. Defaults to 10000 (10 seconds) if not specified. */
109
128
  timeout?: number;
@@ -113,6 +132,8 @@ export interface ToolConfig {
113
132
  completionHints?: ToolCompletionHints;
114
133
  /** Rate-limit queue touch points for orchestration admission probes */
115
134
  queueTouchPoints?: QueueTouchPoint[];
135
+ /** Mutex lease handoff between workflow tool.call steps */
136
+ rateLimitHandoff?: RateLimitHandoff;
116
137
  }
117
138
  /**
118
139
  * Successful tool execution result.
@@ -186,7 +207,7 @@ export interface ToolExecutionResult<Output = unknown> {
186
207
  /** Discriminator for new ToolResult shape (true=success, false=failure) */
187
208
  success?: boolean;
188
209
  output: Output | null;
189
- billing: BillingInfo;
210
+ billing: ToolBilling;
190
211
  meta?: ToolResponseMeta;
191
212
  effect?: ToolEffect;
192
213
  error?: ToolError | null;
@@ -230,6 +251,8 @@ export interface ToolDefinition<Input = unknown, Output = unknown, InputSchema e
230
251
  config?: ToolConfig;
231
252
  /** Rate-limit queue touch points (also accepted at top level for ergonomics) */
232
253
  queueTouchPoints?: QueueTouchPoint[];
254
+ /** Mutex lease handoff between workflow tool.call steps */
255
+ rateLimitHandoff?: RateLimitHandoff;
233
256
  /**
234
257
  * Execution scope for this tool.
235
258
  * - `installation` (default): Requires appInstallationId, receives sk_wkp_ token.
@@ -270,6 +293,8 @@ export interface ToolMetadata {
270
293
  config?: ToolConfig;
271
294
  /** Rate-limit queue touch points for orchestration admission probes */
272
295
  queueTouchPoints?: QueueTouchPoint[];
296
+ /** Mutex lease handoff between workflow tool.call steps */
297
+ rateLimitHandoff?: RateLimitHandoff;
273
298
  /** Execution scope for this tool */
274
299
  executionScope?: ExecutionScope;
275
300
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skedyul",
3
- "version": "1.5.2",
3
+ "version": "1.5.12",
4
4
  "description": "The Skedyul SDK for Node.js",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -61,16 +61,22 @@
61
61
  "import": "./dist/scheduling/index.mjs",
62
62
  "require": "./dist/scheduling/index.js",
63
63
  "default": "./dist/scheduling/index.js"
64
+ },
65
+ "./estimation": {
66
+ "types": "./dist/types/estimation.d.ts",
67
+ "import": "./dist/estimation/index.mjs",
68
+ "require": "./dist/estimation/index.js",
69
+ "default": "./dist/estimation/index.js"
64
70
  }
65
71
  },
66
72
  "files": [
67
73
  "dist"
68
74
  ],
69
75
  "scripts": {
70
- "build": "rm -rf dist tsconfig.tsbuildinfo && tsc --emitDeclarationOnly && tsup",
76
+ "build": "rm -rf dist tsconfig.tsbuildinfo && tsc --emitDeclarationOnly && pnpm exec tsup-node",
71
77
  "db:generate": "echo 'No database generation needed for this package'",
72
78
  "dev": "npx nodemon --watch src --ext js,ts --exec \"pnpm run build\"",
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"
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"
74
80
  },
75
81
  "keywords": [
76
82
  "mcp",