skedyul 1.2.38 → 1.2.41

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/cli/index.js CHANGED
@@ -3754,28 +3754,69 @@ async function handleMcpToolsCall(params, id, ctx) {
3754
3754
  invocation: toolInvocation
3755
3755
  });
3756
3756
  let result;
3757
- if (toolResult.error) {
3758
- const errorOutput = { error: toolResult.error };
3757
+ const isNewShapeFailure = "success" in toolResult && toolResult.success === false;
3758
+ const isLegacyErrorFailure = "error" in toolResult && toolResult.error != null;
3759
+ const isLegacyMetaFailure = "meta" in toolResult && toolResult.meta != null && typeof toolResult.meta === "object" && "success" in toolResult.meta && toolResult.meta.success === false;
3760
+ const isFailure = isNewShapeFailure || isLegacyErrorFailure || isLegacyMetaFailure;
3761
+ if (isFailure) {
3762
+ let errorOutput;
3763
+ if (isNewShapeFailure && "error" in toolResult) {
3764
+ errorOutput = {
3765
+ error: toolResult.error,
3766
+ retry: "retry" in toolResult ? toolResult.retry : void 0
3767
+ };
3768
+ } else if (isLegacyErrorFailure && "error" in toolResult) {
3769
+ errorOutput = { error: toolResult.error };
3770
+ } else if (isLegacyMetaFailure && "meta" in toolResult && toolResult.meta) {
3771
+ const meta = toolResult.meta;
3772
+ errorOutput = {
3773
+ error: {
3774
+ code: "TOOL_FAILED",
3775
+ message: meta.message ?? "Tool execution failed",
3776
+ category: "internal"
3777
+ }
3778
+ };
3779
+ } else {
3780
+ errorOutput = {
3781
+ error: {
3782
+ code: "TOOL_FAILED",
3783
+ message: "Tool execution failed",
3784
+ category: "internal"
3785
+ }
3786
+ };
3787
+ }
3759
3788
  result = {
3760
3789
  content: [{ type: "text", text: JSON.stringify(errorOutput) }],
3761
3790
  structuredContent: hasOutputSchema ? void 0 : errorOutput,
3762
3791
  isError: true,
3763
- billing: toolResult.billing
3792
+ billing: "billing" in toolResult ? toolResult.billing : void 0
3764
3793
  };
3765
3794
  } else {
3766
- const outputData = toolResult.output;
3795
+ const outputData = "output" in toolResult ? toolResult.output : null;
3796
+ const effect = "effect" in toolResult ? toolResult.effect : void 0;
3797
+ const warnings = "warnings" in toolResult ? toolResult.warnings : void 0;
3798
+ const pagination = "pagination" in toolResult ? toolResult.pagination : void 0;
3767
3799
  let structuredContent;
3768
3800
  if (outputData) {
3769
- structuredContent = { ...outputData, __effect: toolResult.effect };
3770
- } else if (toolResult.effect) {
3771
- structuredContent = { __effect: toolResult.effect };
3801
+ structuredContent = {
3802
+ ...outputData,
3803
+ __effect: effect,
3804
+ __warnings: warnings,
3805
+ __pagination: pagination
3806
+ };
3807
+ } else if (effect || warnings || pagination) {
3808
+ structuredContent = {
3809
+ __effect: effect,
3810
+ __warnings: warnings,
3811
+ __pagination: pagination
3812
+ };
3772
3813
  } else if (hasOutputSchema) {
3773
3814
  structuredContent = {};
3774
3815
  }
3775
3816
  result = {
3776
- content: [{ type: "text", text: JSON.stringify(toolResult.output) }],
3817
+ content: [{ type: "text", text: JSON.stringify(outputData) }],
3777
3818
  structuredContent,
3778
- billing: toolResult.billing
3819
+ billing: "billing" in toolResult ? toolResult.billing : void 0
3779
3820
  };
3780
3821
  }
3781
3822
  return {
@@ -1546,28 +1546,69 @@ async function handleMcpToolsCall(params, id, ctx) {
1546
1546
  invocation: toolInvocation
1547
1547
  });
1548
1548
  let result;
1549
- if (toolResult.error) {
1550
- const errorOutput = { error: toolResult.error };
1549
+ const isNewShapeFailure = "success" in toolResult && toolResult.success === false;
1550
+ const isLegacyErrorFailure = "error" in toolResult && toolResult.error != null;
1551
+ const isLegacyMetaFailure = "meta" in toolResult && toolResult.meta != null && typeof toolResult.meta === "object" && "success" in toolResult.meta && toolResult.meta.success === false;
1552
+ const isFailure = isNewShapeFailure || isLegacyErrorFailure || isLegacyMetaFailure;
1553
+ if (isFailure) {
1554
+ let errorOutput;
1555
+ if (isNewShapeFailure && "error" in toolResult) {
1556
+ errorOutput = {
1557
+ error: toolResult.error,
1558
+ retry: "retry" in toolResult ? toolResult.retry : void 0
1559
+ };
1560
+ } else if (isLegacyErrorFailure && "error" in toolResult) {
1561
+ errorOutput = { error: toolResult.error };
1562
+ } else if (isLegacyMetaFailure && "meta" in toolResult && toolResult.meta) {
1563
+ const meta = toolResult.meta;
1564
+ errorOutput = {
1565
+ error: {
1566
+ code: "TOOL_FAILED",
1567
+ message: meta.message ?? "Tool execution failed",
1568
+ category: "internal"
1569
+ }
1570
+ };
1571
+ } else {
1572
+ errorOutput = {
1573
+ error: {
1574
+ code: "TOOL_FAILED",
1575
+ message: "Tool execution failed",
1576
+ category: "internal"
1577
+ }
1578
+ };
1579
+ }
1551
1580
  result = {
1552
1581
  content: [{ type: "text", text: JSON.stringify(errorOutput) }],
1553
1582
  structuredContent: hasOutputSchema ? void 0 : errorOutput,
1554
1583
  isError: true,
1555
- billing: toolResult.billing
1584
+ billing: "billing" in toolResult ? toolResult.billing : void 0
1556
1585
  };
1557
1586
  } else {
1558
- const outputData = toolResult.output;
1587
+ const outputData = "output" in toolResult ? toolResult.output : null;
1588
+ const effect = "effect" in toolResult ? toolResult.effect : void 0;
1589
+ const warnings = "warnings" in toolResult ? toolResult.warnings : void 0;
1590
+ const pagination = "pagination" in toolResult ? toolResult.pagination : void 0;
1559
1591
  let structuredContent;
1560
1592
  if (outputData) {
1561
- structuredContent = { ...outputData, __effect: toolResult.effect };
1562
- } else if (toolResult.effect) {
1563
- structuredContent = { __effect: toolResult.effect };
1593
+ structuredContent = {
1594
+ ...outputData,
1595
+ __effect: effect,
1596
+ __warnings: warnings,
1597
+ __pagination: pagination
1598
+ };
1599
+ } else if (effect || warnings || pagination) {
1600
+ structuredContent = {
1601
+ __effect: effect,
1602
+ __warnings: warnings,
1603
+ __pagination: pagination
1604
+ };
1564
1605
  } else if (hasOutputSchema) {
1565
1606
  structuredContent = {};
1566
1607
  }
1567
1608
  result = {
1568
- content: [{ type: "text", text: JSON.stringify(toolResult.output) }],
1609
+ content: [{ type: "text", text: JSON.stringify(outputData) }],
1569
1610
  structuredContent,
1570
- billing: toolResult.billing
1611
+ billing: "billing" in toolResult ? toolResult.billing : void 0
1571
1612
  };
1572
1613
  }
1573
1614
  return {
@@ -59,14 +59,143 @@ function isRuntimeContext(ctx) {
59
59
  // src/types/tool.ts
60
60
  import { z } from "zod/v4";
61
61
  var ToolResponseMetaSchema = z.object({
62
- /** Whether the tool execution succeeded */
63
62
  success: z.boolean(),
64
- /** Human-readable message describing the result or error */
65
63
  message: z.string(),
66
- /** Name of the tool that was executed */
67
64
  toolName: z.string()
68
65
  });
69
66
 
67
+ // src/types/tool-response.ts
68
+ function createSuccessResponse(output, options) {
69
+ return {
70
+ success: true,
71
+ output,
72
+ ...options
73
+ };
74
+ }
75
+ function createListResponse(items, pagination, options) {
76
+ return {
77
+ success: true,
78
+ output: items,
79
+ pagination,
80
+ ...options
81
+ };
82
+ }
83
+ function inferCategory(code) {
84
+ switch (code) {
85
+ case "VALIDATION_ERROR":
86
+ case "CONFLICT":
87
+ return "validation";
88
+ case "AUTH_INVALID":
89
+ case "AUTH_EXPIRED":
90
+ case "PERMISSION_DENIED":
91
+ return "auth";
92
+ case "TIMEOUT":
93
+ return "timeout";
94
+ case "RATE_LIMITED":
95
+ case "EXTERNAL_SERVICE_ERROR":
96
+ case "NOT_FOUND":
97
+ case "QUOTA_EXCEEDED":
98
+ return "external";
99
+ default:
100
+ return "internal";
101
+ }
102
+ }
103
+ function createErrorResponse(code, message, options) {
104
+ const category = options?.category ?? inferCategory(code);
105
+ return {
106
+ success: false,
107
+ error: {
108
+ code,
109
+ message,
110
+ category,
111
+ field: options?.field,
112
+ details: options?.details
113
+ },
114
+ retry: options?.retry,
115
+ partialOutput: options?.partialOutput,
116
+ billing: options?.billing,
117
+ effect: options?.effect
118
+ };
119
+ }
120
+ function createValidationError(message, field, details) {
121
+ return createErrorResponse("VALIDATION_ERROR", message, {
122
+ category: "validation",
123
+ field,
124
+ details
125
+ });
126
+ }
127
+ function createNotFoundError(resource2, identifier) {
128
+ const message = identifier ? `${resource2} '${identifier}' not found` : `${resource2} not found`;
129
+ return createErrorResponse("NOT_FOUND", message, { category: "external" });
130
+ }
131
+ function createAuthError(message, options) {
132
+ return createErrorResponse(
133
+ options?.expired ? "AUTH_EXPIRED" : "AUTH_INVALID",
134
+ message,
135
+ { category: "auth", retry: options?.retry }
136
+ );
137
+ }
138
+ function createRateLimitError(retryAfterMs) {
139
+ return createErrorResponse(
140
+ "RATE_LIMITED",
141
+ "Rate limit exceeded. Please try again later.",
142
+ {
143
+ category: "external",
144
+ retry: {
145
+ allowed: true,
146
+ afterMs: retryAfterMs
147
+ }
148
+ }
149
+ );
150
+ }
151
+ function createExternalError(service, message, options) {
152
+ return createErrorResponse(
153
+ "EXTERNAL_SERVICE_ERROR",
154
+ `${service}: ${message}`,
155
+ {
156
+ category: "external",
157
+ retry: options?.retry ?? { allowed: true },
158
+ details: options?.details
159
+ }
160
+ );
161
+ }
162
+ function createTimeoutError(message = "Operation timed out", options) {
163
+ return createErrorResponse("TIMEOUT", message, {
164
+ category: "timeout",
165
+ retry: options?.retry ?? { allowed: true }
166
+ });
167
+ }
168
+ function createPermissionError(message = "Permission denied") {
169
+ return createErrorResponse("PERMISSION_DENIED", message, {
170
+ category: "auth"
171
+ });
172
+ }
173
+ function createConflictError(message, field) {
174
+ return createErrorResponse("CONFLICT", message, {
175
+ category: "validation",
176
+ field
177
+ });
178
+ }
179
+ function isSuccess(result) {
180
+ return result.success === true;
181
+ }
182
+ function isFailure(result) {
183
+ return result.success === false;
184
+ }
185
+ function isRetryable(result) {
186
+ if (result.retry?.allowed === false) return false;
187
+ if (result.retry?.allowed === true) return true;
188
+ const retryableCategories = [
189
+ "network",
190
+ "timeout",
191
+ "external"
192
+ ];
193
+ return result.error.category ? retryableCategories.includes(result.error.category) : false;
194
+ }
195
+ function getRetryDelay(result) {
196
+ return result.retry?.afterMs;
197
+ }
198
+
70
199
  // src/types/webhook.ts
71
200
  function isRuntimeWebhookContext(ctx) {
72
201
  return "appInstallationId" in ctx && ctx.appInstallationId !== void 0;
@@ -106,10 +235,24 @@ var FilterOperatorSchema = z2.enum([
106
235
  "isEmpty",
107
236
  "isNotEmpty"
108
237
  ]);
109
- var FilterConditionSchema = z2.record(
110
- FilterOperatorSchema,
111
- PrimitiveOrArraySchema
112
- );
238
+ var FilterConditionSchema = z2.object({
239
+ eq: PrimitiveOrArraySchema,
240
+ neq: PrimitiveOrArraySchema,
241
+ gt: PrimitiveOrArraySchema,
242
+ gte: PrimitiveOrArraySchema,
243
+ lt: PrimitiveOrArraySchema,
244
+ lte: PrimitiveOrArraySchema,
245
+ in: PrimitiveOrArraySchema,
246
+ contains: PrimitiveOrArraySchema,
247
+ notContains: PrimitiveOrArraySchema,
248
+ not_contains: PrimitiveOrArraySchema,
249
+ startsWith: PrimitiveOrArraySchema,
250
+ starts_with: PrimitiveOrArraySchema,
251
+ endsWith: PrimitiveOrArraySchema,
252
+ ends_with: PrimitiveOrArraySchema,
253
+ isEmpty: PrimitiveOrArraySchema,
254
+ isNotEmpty: PrimitiveOrArraySchema
255
+ }).partial();
113
256
  var StructuredFilterSchema = z2.record(
114
257
  z2.string(),
115
258
  FilterConditionSchema
@@ -3258,28 +3401,69 @@ async function handleMcpToolsCall(params, id, ctx) {
3258
3401
  invocation: toolInvocation
3259
3402
  });
3260
3403
  let result;
3261
- if (toolResult.error) {
3262
- const errorOutput = { error: toolResult.error };
3404
+ const isNewShapeFailure = "success" in toolResult && toolResult.success === false;
3405
+ const isLegacyErrorFailure = "error" in toolResult && toolResult.error != null;
3406
+ const isLegacyMetaFailure = "meta" in toolResult && toolResult.meta != null && typeof toolResult.meta === "object" && "success" in toolResult.meta && toolResult.meta.success === false;
3407
+ const isFailure2 = isNewShapeFailure || isLegacyErrorFailure || isLegacyMetaFailure;
3408
+ if (isFailure2) {
3409
+ let errorOutput;
3410
+ if (isNewShapeFailure && "error" in toolResult) {
3411
+ errorOutput = {
3412
+ error: toolResult.error,
3413
+ retry: "retry" in toolResult ? toolResult.retry : void 0
3414
+ };
3415
+ } else if (isLegacyErrorFailure && "error" in toolResult) {
3416
+ errorOutput = { error: toolResult.error };
3417
+ } else if (isLegacyMetaFailure && "meta" in toolResult && toolResult.meta) {
3418
+ const meta = toolResult.meta;
3419
+ errorOutput = {
3420
+ error: {
3421
+ code: "TOOL_FAILED",
3422
+ message: meta.message ?? "Tool execution failed",
3423
+ category: "internal"
3424
+ }
3425
+ };
3426
+ } else {
3427
+ errorOutput = {
3428
+ error: {
3429
+ code: "TOOL_FAILED",
3430
+ message: "Tool execution failed",
3431
+ category: "internal"
3432
+ }
3433
+ };
3434
+ }
3263
3435
  result = {
3264
3436
  content: [{ type: "text", text: JSON.stringify(errorOutput) }],
3265
3437
  structuredContent: hasOutputSchema ? void 0 : errorOutput,
3266
3438
  isError: true,
3267
- billing: toolResult.billing
3439
+ billing: "billing" in toolResult ? toolResult.billing : void 0
3268
3440
  };
3269
3441
  } else {
3270
- const outputData = toolResult.output;
3442
+ const outputData = "output" in toolResult ? toolResult.output : null;
3443
+ const effect = "effect" in toolResult ? toolResult.effect : void 0;
3444
+ const warnings = "warnings" in toolResult ? toolResult.warnings : void 0;
3445
+ const pagination = "pagination" in toolResult ? toolResult.pagination : void 0;
3271
3446
  let structuredContent;
3272
3447
  if (outputData) {
3273
- structuredContent = { ...outputData, __effect: toolResult.effect };
3274
- } else if (toolResult.effect) {
3275
- structuredContent = { __effect: toolResult.effect };
3448
+ structuredContent = {
3449
+ ...outputData,
3450
+ __effect: effect,
3451
+ __warnings: warnings,
3452
+ __pagination: pagination
3453
+ };
3454
+ } else if (effect || warnings || pagination) {
3455
+ structuredContent = {
3456
+ __effect: effect,
3457
+ __warnings: warnings,
3458
+ __pagination: pagination
3459
+ };
3276
3460
  } else if (hasOutputSchema) {
3277
3461
  structuredContent = {};
3278
3462
  }
3279
3463
  result = {
3280
- content: [{ type: "text", text: JSON.stringify(toolResult.output) }],
3464
+ content: [{ type: "text", text: JSON.stringify(outputData) }],
3281
3465
  structuredContent,
3282
- billing: toolResult.billing
3466
+ billing: "billing" in toolResult ? toolResult.billing : void 0
3283
3467
  };
3284
3468
  }
3285
3469
  return {
@@ -3323,7 +3507,7 @@ function createOptionsResponse() {
3323
3507
  body: { message: "OK" }
3324
3508
  };
3325
3509
  }
3326
- function createErrorResponse(err) {
3510
+ function createErrorResponse2(err) {
3327
3511
  return {
3328
3512
  status: 500,
3329
3513
  body: {
@@ -3379,7 +3563,7 @@ async function routeRequest(req, ctx) {
3379
3563
  }
3380
3564
  return createNotFoundResponse();
3381
3565
  } catch (err) {
3382
- return createErrorResponse(err);
3566
+ return createErrorResponse2(err);
3383
3567
  }
3384
3568
  }
3385
3569
 
@@ -4062,9 +4246,20 @@ export {
4062
4246
  ai,
4063
4247
  communicationChannel,
4064
4248
  configure,
4249
+ createAuthError,
4250
+ createConflictError,
4065
4251
  createContextLogger,
4252
+ createErrorResponse,
4253
+ createExternalError,
4254
+ createListResponse,
4255
+ createNotFoundError,
4256
+ createPermissionError,
4257
+ createRateLimitError,
4066
4258
  createServerHookContext,
4259
+ createSuccessResponse,
4260
+ createTimeoutError,
4067
4261
  createToolCallContext,
4262
+ createValidationError,
4068
4263
  createWebhookContext,
4069
4264
  createWorkflowStepContext,
4070
4265
  src_default as default,
@@ -4080,12 +4275,16 @@ export {
4080
4275
  getAllEnvKeys,
4081
4276
  getConfig,
4082
4277
  getRequiredInstallEnvKeys,
4278
+ getRetryDelay,
4083
4279
  instance,
4084
4280
  isChannelDependency,
4281
+ isFailure,
4085
4282
  isModelDependency,
4086
4283
  isProvisionContext,
4284
+ isRetryable,
4087
4285
  isRuntimeContext,
4088
4286
  isRuntimeWebhookContext,
4287
+ isSuccess,
4089
4288
  isWorkflowDependency,
4090
4289
  loadConfig,
4091
4290
  report,