@doist/automations-mcp 1.10.0 → 1.11.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.
@@ -7018,6 +7018,9 @@ var USAGE_BILLING_DENIAL_CODES = [
7018
7018
  ];
7019
7019
  var USAGE_BILLING_TEMPORARILY_UNAVAILABLE_CODE = "usage_billing_temporarily_unavailable";
7020
7020
  var USAGE_BILLING_UNAVAILABLE_CODE = "usage_billing_unavailable";
7021
+ function isUsageBillingDenialCode(code) {
7022
+ return typeof code === "string" && USAGE_BILLING_DENIAL_CODES.includes(code);
7023
+ }
7021
7024
 
7022
7025
  // ../../packages/core/dist/esm/constants/webhook-event-subscription.constants.js
7023
7026
  var WEBHOOK_EVENT_TYPES = [
@@ -9828,6 +9831,29 @@ var chatStreamRequestErrorResponseSchema = z17.object({
9828
9831
  /** Present only when the server establishes whether work started. */
9829
9832
  execution_started: z17.boolean().optional()
9830
9833
  });
9834
+ function getChatBillingRefusal(error) {
9835
+ if (!(error instanceof Error) || !error.message.trim().startsWith("{"))
9836
+ return null;
9837
+ let body;
9838
+ try {
9839
+ body = JSON.parse(error.message);
9840
+ } catch {
9841
+ return null;
9842
+ }
9843
+ const parsed = chatStreamRequestErrorResponseSchema.safeParse(body);
9844
+ if (!parsed.success)
9845
+ return null;
9846
+ if (isUsageBillingDenialCode(parsed.data.code)) {
9847
+ return { message: parsed.data.message, code: parsed.data.code };
9848
+ }
9849
+ if (parsed.data.statusCode === 402 && isBodyWithoutCodeOrReason(body)) {
9850
+ return { message: parsed.data.message, code: void 0 };
9851
+ }
9852
+ return null;
9853
+ }
9854
+ function isBodyWithoutCodeOrReason(body) {
9855
+ return typeof body === "object" && body !== null && !("code" in body) && !("reason" in body);
9856
+ }
9831
9857
  var CHAT_CONVERSATION_STATUSES = ["active", "archived", "all"];
9832
9858
  var chatConversationStatusSchema = z17.enum(CHAT_CONVERSATION_STATUSES);
9833
9859
  var getChatConversationsQuerySchema = z17.object({
@@ -12597,13 +12623,27 @@ var UsageBillingAccountNotFoundResponseSchema = z56.object({
12597
12623
  http_code: z56.literal(404),
12598
12624
  error_extra: z56.record(z56.string(), z56.unknown())
12599
12625
  });
12626
+ var USAGE_BILLING_TOP_UP_REFUSAL_TAGS = {
12627
+ topUpUnavailable: "USAGE_BILLING_TOP_UP_UNAVAILABLE",
12628
+ planRequired: "USAGE_BILLING_PLAN_REQUIRED",
12629
+ currencyMismatch: "USAGE_BILLING_CURRENCY_MISMATCH",
12630
+ topUpBelowMinimum: "USAGE_BILLING_TOP_UP_BELOW_MINIMUM"
12631
+ };
12632
+ var UsageBillingTopUpRefusalTagSchema = z56.enum(USAGE_BILLING_TOP_UP_REFUSAL_TAGS);
12600
12633
  var UsageBillingTopUpUnavailableResponseSchema = z56.object({
12601
- error_tag: z56.literal("USAGE_BILLING_TOP_UP_UNAVAILABLE"),
12634
+ error_tag: z56.literal(USAGE_BILLING_TOP_UP_REFUSAL_TAGS.topUpUnavailable),
12602
12635
  error_code: z56.literal(605),
12603
12636
  error: z56.string(),
12604
12637
  http_code: z56.literal(400),
12605
12638
  error_extra: z56.record(z56.string(), z56.unknown())
12606
12639
  });
12640
+ var UsageBillingTopUpPlanRequiredResponseSchema = z56.object({
12641
+ error_tag: z56.literal(USAGE_BILLING_TOP_UP_REFUSAL_TAGS.planRequired),
12642
+ error_code: z56.literal(615),
12643
+ error: z56.string(),
12644
+ http_code: z56.literal(400),
12645
+ error_extra: z56.record(z56.string(), z56.unknown())
12646
+ });
12607
12647
  var UsageBillingTopUpRefusalSchema = z56.object({
12608
12648
  error_tag: z56.string().min(1),
12609
12649
  error_extra: z56.object({ event_id: z56.string().optional() }).optional()
@@ -13978,7 +14018,7 @@ import { McpServer } from "@modelcontextprotocol/server";
13978
14018
  // package.json
13979
14019
  var package_default = {
13980
14020
  name: "@doist/automations-mcp",
13981
- version: "1.10.0",
14021
+ version: "1.11.0",
13982
14022
  description: "MCP server and importable AI tools for Todoist Automations",
13983
14023
  type: "module",
13984
14024
  main: "./dist/index.js",
@@ -15163,6 +15203,10 @@ function describeTurnError(error, signal) {
15163
15203
  return error.message;
15164
15204
  }
15165
15205
  }
15206
+ const refusal = getChatBillingRefusal(error)?.message;
15207
+ if (refusal !== void 0) {
15208
+ return `the turn was refused. ${refusal.endsWith(".") ? refusal : `${refusal}.`} Retrying won't help until the user acts.`;
15209
+ }
15166
15210
  return `the turn failed. ${formatToolError(error)} The conversation is intact; continue-conversation resumes it.`;
15167
15211
  }
15168
15212
  function describeTurnResult(result) {
@@ -15563,7 +15607,7 @@ var parameters13 = {
15563
15607
  automationId: z77.string().describe("The id of the automation, as returned by find-automations."),
15564
15608
  workspaceId: workspaceIdParameter,
15565
15609
  status: z77.enum(AUTOMATION_RUN_STATUSES).optional().describe(
15566
- "Only runs with this outcome. A run refused for an empty balance is `skipped`, not `failed`."
15610
+ "Only runs with this outcome. A run refused for billing reasons will be marked as `skipped`, not `failed`. See details in the response's `failureCategory`."
15567
15611
  ),
15568
15612
  since: isoDateTimeOrDateQueryParamSchema.optional().describe(
15569
15613
  "Only runs started at or after this ISO 8601 timestamp or YYYY-MM-DD date. A date means the start of that UTC day."
@@ -16589,4 +16633,4 @@ export {
16589
16633
  DEFAULT_BASE_URL,
16590
16634
  getMcpServer
16591
16635
  };
16592
- //# sourceMappingURL=chunk-4DEVWVZG.js.map
16636
+ //# sourceMappingURL=chunk-66AC5E4I.js.map