@pilot-status/mcp-server 0.1.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.
Files changed (75) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +230 -0
  3. package/dist/index.d.ts +3 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +45 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/lib/api-client.d.ts +100 -0
  8. package/dist/lib/api-client.d.ts.map +1 -0
  9. package/dist/lib/api-client.js +204 -0
  10. package/dist/lib/api-client.js.map +1 -0
  11. package/dist/lib/config.d.ts +54 -0
  12. package/dist/lib/config.d.ts.map +1 -0
  13. package/dist/lib/config.js +79 -0
  14. package/dist/lib/config.js.map +1 -0
  15. package/dist/lib/http-transport.d.ts +42 -0
  16. package/dist/lib/http-transport.d.ts.map +1 -0
  17. package/dist/lib/http-transport.js +228 -0
  18. package/dist/lib/http-transport.js.map +1 -0
  19. package/dist/lib/register.d.ts +28 -0
  20. package/dist/lib/register.d.ts.map +1 -0
  21. package/dist/lib/register.js +69 -0
  22. package/dist/lib/register.js.map +1 -0
  23. package/dist/lib/server.d.ts +16 -0
  24. package/dist/lib/server.d.ts.map +1 -0
  25. package/dist/lib/server.js +23 -0
  26. package/dist/lib/server.js.map +1 -0
  27. package/dist/tools/analytics.d.ts +3 -0
  28. package/dist/tools/analytics.d.ts.map +1 -0
  29. package/dist/tools/analytics.js +22 -0
  30. package/dist/tools/analytics.js.map +1 -0
  31. package/dist/tools/api-keys.d.ts +3 -0
  32. package/dist/tools/api-keys.d.ts.map +1 -0
  33. package/dist/tools/api-keys.js +35 -0
  34. package/dist/tools/api-keys.js.map +1 -0
  35. package/dist/tools/branding.d.ts +3 -0
  36. package/dist/tools/branding.d.ts.map +1 -0
  37. package/dist/tools/branding.js +35 -0
  38. package/dist/tools/branding.js.map +1 -0
  39. package/dist/tools/conversations.d.ts +3 -0
  40. package/dist/tools/conversations.d.ts.map +1 -0
  41. package/dist/tools/conversations.js +18 -0
  42. package/dist/tools/conversations.js.map +1 -0
  43. package/dist/tools/groups.d.ts +3 -0
  44. package/dist/tools/groups.d.ts.map +1 -0
  45. package/dist/tools/groups.js +17 -0
  46. package/dist/tools/groups.js.map +1 -0
  47. package/dist/tools/index.d.ts +9 -0
  48. package/dist/tools/index.d.ts.map +1 -0
  49. package/dist/tools/index.js +26 -0
  50. package/dist/tools/index.js.map +1 -0
  51. package/dist/tools/messages.d.ts +3 -0
  52. package/dist/tools/messages.d.ts.map +1 -0
  53. package/dist/tools/messages.js +134 -0
  54. package/dist/tools/messages.js.map +1 -0
  55. package/dist/tools/numbers.d.ts +3 -0
  56. package/dist/tools/numbers.d.ts.map +1 -0
  57. package/dist/tools/numbers.js +52 -0
  58. package/dist/tools/numbers.js.map +1 -0
  59. package/dist/tools/shared.d.ts +19 -0
  60. package/dist/tools/shared.d.ts.map +1 -0
  61. package/dist/tools/shared.js +27 -0
  62. package/dist/tools/shared.js.map +1 -0
  63. package/dist/tools/subscription.d.ts +3 -0
  64. package/dist/tools/subscription.d.ts.map +1 -0
  65. package/dist/tools/subscription.js +39 -0
  66. package/dist/tools/subscription.js.map +1 -0
  67. package/dist/tools/templates.d.ts +3 -0
  68. package/dist/tools/templates.d.ts.map +1 -0
  69. package/dist/tools/templates.js +68 -0
  70. package/dist/tools/templates.js.map +1 -0
  71. package/dist/tools/types.d.ts +23 -0
  72. package/dist/tools/types.d.ts.map +1 -0
  73. package/dist/tools/types.js +20 -0
  74. package/dist/tools/types.js.map +1 -0
  75. package/package.json +64 -0
@@ -0,0 +1,35 @@
1
+ import { z } from "zod";
2
+ import { defineTool } from "./types.js";
3
+ const apiKeysList = defineTool({
4
+ name: "api_keys_list",
5
+ description: "List API keys for the tenant (scoped to the key's WhatsApp number) via GET /v1/api-keys. " +
6
+ "Number-scoped API key required.",
7
+ inputSchema: {},
8
+ handler: (client) => client.get("/v1/api-keys"),
9
+ });
10
+ const apiKeysCreate = defineTool({
11
+ name: "api_keys_create",
12
+ description: "Create a new API key via POST /v1/api-keys. The raw key is returned only once. " +
13
+ "Number-scoped API key required.",
14
+ inputSchema: {
15
+ name: z.string().min(1).max(100).describe("Human-readable key name"),
16
+ webhookId: z
17
+ .string()
18
+ .min(1)
19
+ .nullable()
20
+ .optional()
21
+ .describe("Webhook to attach (null to detach)"),
22
+ whatsappInstanceId: z.string().min(1).nullable().optional(),
23
+ whatsappNumberId: z.string().min(1).nullable().optional(),
24
+ retentionDays: z
25
+ .number()
26
+ .int()
27
+ .min(0)
28
+ .max(3650)
29
+ .optional()
30
+ .describe("Message log retention in days"),
31
+ },
32
+ handler: (client, args) => client.post("/v1/api-keys", { body: args }),
33
+ });
34
+ export const apiKeyTools = [apiKeysList, apiKeysCreate];
35
+ //# sourceMappingURL=api-keys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-keys.js","sourceRoot":"","sources":["../../src/tools/api-keys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAgB,MAAM,YAAY,CAAC;AAEtD,MAAM,WAAW,GAAG,UAAU,CAAC;IAC3B,IAAI,EAAE,eAAe;IACrB,WAAW,EACP,2FAA2F;QAC3F,iCAAiC;IACrC,WAAW,EAAE,EAAE;IACf,OAAO,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,cAAc,CAAC;CAClD,CAAC,CAAC;AAEH,MAAM,aAAa,GAAG,UAAU,CAAC;IAC7B,IAAI,EAAE,iBAAiB;IACvB,WAAW,EACP,iFAAiF;QACjF,iCAAiC;IACrC,WAAW,EAAE;QACT,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,yBAAyB,CAAC;QACpE,SAAS,EAAE,CAAC;aACP,MAAM,EAAE;aACR,GAAG,CAAC,CAAC,CAAC;aACN,QAAQ,EAAE;aACV,QAAQ,EAAE;aACV,QAAQ,CAAC,oCAAoC,CAAC;QACnD,kBAAkB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;QAC3D,gBAAgB,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE;QACzD,aAAa,EAAE,CAAC;aACX,MAAM,EAAE;aACR,GAAG,EAAE;aACL,GAAG,CAAC,CAAC,CAAC;aACN,GAAG,CAAC,IAAI,CAAC;aACT,QAAQ,EAAE;aACV,QAAQ,CAAC,+BAA+B,CAAC;KACjD;IACD,OAAO,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;CACzE,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,WAAW,GAAc,CAAC,WAAW,EAAE,aAAa,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { type ToolDef } from "./types.js";
2
+ export declare const brandingTools: ToolDef[];
3
+ //# sourceMappingURL=branding.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"branding.d.ts","sourceRoot":"","sources":["../../src/tools/branding.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAsCtD,eAAO,MAAM,aAAa,EAAE,OAAO,EAAkC,CAAC"}
@@ -0,0 +1,35 @@
1
+ import { z } from "zod";
2
+ import { defineTool } from "./types.js";
3
+ const hexColor = z
4
+ .string()
5
+ .regex(/^#[0-9a-fA-F]{6}$/, "must be a #RRGGBB hex color");
6
+ const httpsUrl = z
7
+ .string()
8
+ .url()
9
+ .max(2048)
10
+ .refine((u) => u.startsWith("https://"), "must be an https URL");
11
+ const brandingGet = defineTool({
12
+ name: "branding_get",
13
+ description: "Get the tenant's white-label branding (connect/remote-pairing pages) via GET /v1/branding. " +
14
+ "Tenant-scoped API key required.",
15
+ inputSchema: {},
16
+ handler: (client) => client.get("/v1/branding"),
17
+ });
18
+ const brandingUpsert = defineTool({
19
+ name: "branding_upsert",
20
+ description: "Create or update tenant white-label branding via PUT /v1/branding. Send null to clear a " +
21
+ "field, omit a field to leave it unchanged. Tenant-scoped API key required.",
22
+ inputSchema: {
23
+ logoUrl: httpsUrl.nullish(),
24
+ primaryColor: hexColor.nullish(),
25
+ backgroundColor: hexColor.nullish(),
26
+ companyName: z.string().max(60).nullish(),
27
+ subtitle: z.string().max(120).nullish(),
28
+ supportUrl: httpsUrl.nullish(),
29
+ defaultRedirectUrl: httpsUrl.nullish(),
30
+ hidePilotStatusBranding: z.boolean().optional(),
31
+ },
32
+ handler: (client, args) => client.put("/v1/branding", { body: args }),
33
+ });
34
+ export const brandingTools = [brandingGet, brandingUpsert];
35
+ //# sourceMappingURL=branding.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"branding.js","sourceRoot":"","sources":["../../src/tools/branding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAgB,MAAM,YAAY,CAAC;AAEtD,MAAM,QAAQ,GAAG,CAAC;KACb,MAAM,EAAE;KACR,KAAK,CAAC,mBAAmB,EAAE,6BAA6B,CAAC,CAAC;AAC/D,MAAM,QAAQ,GAAG,CAAC;KACb,MAAM,EAAE;KACR,GAAG,EAAE;KACL,GAAG,CAAC,IAAI,CAAC;KACT,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,sBAAsB,CAAC,CAAC;AAErE,MAAM,WAAW,GAAG,UAAU,CAAC;IAC3B,IAAI,EAAE,cAAc;IACpB,WAAW,EACP,6FAA6F;QAC7F,iCAAiC;IACrC,WAAW,EAAE,EAAE;IACf,OAAO,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,cAAc,CAAC;CAClD,CAAC,CAAC;AAEH,MAAM,cAAc,GAAG,UAAU,CAAC;IAC9B,IAAI,EAAE,iBAAiB;IACvB,WAAW,EACP,0FAA0F;QAC1F,4EAA4E;IAChF,WAAW,EAAE;QACT,OAAO,EAAE,QAAQ,CAAC,OAAO,EAAE;QAC3B,YAAY,EAAE,QAAQ,CAAC,OAAO,EAAE;QAChC,eAAe,EAAE,QAAQ,CAAC,OAAO,EAAE;QACnC,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE;QACzC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE;QACvC,UAAU,EAAE,QAAQ,CAAC,OAAO,EAAE;QAC9B,kBAAkB,EAAE,QAAQ,CAAC,OAAO,EAAE;QACtC,uBAAuB,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;KAClD;IACD,OAAO,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,cAAc,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;CACxE,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,aAAa,GAAc,CAAC,WAAW,EAAE,cAAc,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { type ToolDef } from "./types.js";
2
+ export declare const conversationTools: ToolDef[];
3
+ //# sourceMappingURL=conversations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversations.d.ts","sourceRoot":"","sources":["../../src/tools/conversations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAoBjE,eAAO,MAAM,iBAAiB,EAAE,OAAO,EAAwB,CAAC"}
@@ -0,0 +1,18 @@
1
+ import { defineTool, pickQuery } from "./types.js";
2
+ import { dateRangeShape, paginationShape } from "./shared.js";
3
+ const conversationsList = defineTool({
4
+ name: "conversations_list",
5
+ description: "List conversations for the key's WhatsApp number via GET /v1/conversations, ordered by " +
6
+ "last message. Supports startDate/endDate (ISO-8601, filter by last-message time) and " +
7
+ "page/pageSize. Returns empty when the number's privacy mode is RELAY_ONLY; respects the " +
8
+ "STORE_X_DAYS retention window. Number-scoped API key required.",
9
+ inputSchema: {
10
+ ...dateRangeShape,
11
+ ...paginationShape,
12
+ },
13
+ handler: (client, args) => client.get("/v1/conversations", {
14
+ query: pickQuery(args, ["startDate", "endDate", "page", "pageSize"]),
15
+ }),
16
+ });
17
+ export const conversationTools = [conversationsList];
18
+ //# sourceMappingURL=conversations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversations.js","sourceRoot":"","sources":["../../src/tools/conversations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAgB,MAAM,YAAY,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9D,MAAM,iBAAiB,GAAG,UAAU,CAAC;IACjC,IAAI,EAAE,oBAAoB;IAC1B,WAAW,EACP,yFAAyF;QACzF,uFAAuF;QACvF,0FAA0F;QAC1F,gEAAgE;IACpE,WAAW,EAAE;QACT,GAAG,cAAc;QACjB,GAAG,eAAe;KACrB;IACD,OAAO,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,CACtB,MAAM,CAAC,GAAG,CAAC,mBAAmB,EAAE;QAC5B,KAAK,EAAE,SAAS,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;KACvE,CAAC;CACT,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,iBAAiB,GAAc,CAAC,iBAAiB,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { type ToolDef } from "./types.js";
2
+ export declare const groupTools: ToolDef[];
3
+ //# sourceMappingURL=groups.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"groups.d.ts","sourceRoot":"","sources":["../../src/tools/groups.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAoBtD,eAAO,MAAM,UAAU,EAAE,OAAO,EAAkC,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { defineTool } from "./types.js";
2
+ const groupsList = defineTool({
3
+ name: "groups_list",
4
+ description: "List WhatsApp groups for the key's connected instance via GET /v1/groups. " +
5
+ "Number-scoped API key required. Not supported for Meta Cloud API numbers.",
6
+ inputSchema: {},
7
+ handler: (client) => client.get("/v1/groups"),
8
+ });
9
+ const newslettersList = defineTool({
10
+ name: "newsletters_list",
11
+ description: "List WhatsApp newsletter channels for the key's connected instance via " +
12
+ "GET /v1/newsletters. Number-scoped API key required. Not supported for Meta numbers.",
13
+ inputSchema: {},
14
+ handler: (client) => client.get("/v1/newsletters"),
15
+ });
16
+ export const groupTools = [groupsList, newslettersList];
17
+ //# sourceMappingURL=groups.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"groups.js","sourceRoot":"","sources":["../../src/tools/groups.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAgB,MAAM,YAAY,CAAC;AAEtD,MAAM,UAAU,GAAG,UAAU,CAAC;IAC1B,IAAI,EAAE,aAAa;IACnB,WAAW,EACP,4EAA4E;QAC5E,2EAA2E;IAC/E,WAAW,EAAE,EAAE;IACf,OAAO,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,YAAY,CAAC;CAChD,CAAC,CAAC;AAEH,MAAM,eAAe,GAAG,UAAU,CAAC;IAC/B,IAAI,EAAE,kBAAkB;IACxB,WAAW,EACP,yEAAyE;QACzE,sFAAsF;IAC1F,WAAW,EAAE,EAAE;IACf,OAAO,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,iBAAiB,CAAC;CACrD,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,UAAU,GAAc,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { ToolDef } from "./types.js";
2
+ /**
3
+ * All MCP tools, one per public `/v1` endpoint (token-based connect/pairing
4
+ * routes are intentionally excluded — those are interactive browser flows).
5
+ */
6
+ export declare const tools: ToolDef[];
7
+ export { defineTool } from "./types.js";
8
+ export type { ToolDef } from "./types.js";
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAW1C;;;GAGG;AACH,eAAO,MAAM,KAAK,EAAE,OAAO,EAU1B,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,YAAY,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { messageTools } from "./messages.js";
2
+ import { conversationTools } from "./conversations.js";
3
+ import { groupTools } from "./groups.js";
4
+ import { numberTools } from "./numbers.js";
5
+ import { templateTools } from "./templates.js";
6
+ import { brandingTools } from "./branding.js";
7
+ import { analyticsTools } from "./analytics.js";
8
+ import { apiKeyTools } from "./api-keys.js";
9
+ import { subscriptionTools } from "./subscription.js";
10
+ /**
11
+ * All MCP tools, one per public `/v1` endpoint (token-based connect/pairing
12
+ * routes are intentionally excluded — those are interactive browser flows).
13
+ */
14
+ export const tools = [
15
+ ...messageTools,
16
+ ...conversationTools,
17
+ ...groupTools,
18
+ ...numberTools,
19
+ ...templateTools,
20
+ ...brandingTools,
21
+ ...analyticsTools,
22
+ ...apiKeyTools,
23
+ ...subscriptionTools,
24
+ ];
25
+ export { defineTool } from "./types.js";
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD;;;GAGG;AACH,MAAM,CAAC,MAAM,KAAK,GAAc;IAC5B,GAAG,YAAY;IACf,GAAG,iBAAiB;IACpB,GAAG,UAAU;IACb,GAAG,WAAW;IACd,GAAG,aAAa;IAChB,GAAG,aAAa;IAChB,GAAG,cAAc;IACjB,GAAG,WAAW;IACd,GAAG,iBAAiB;CACvB,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { type ToolDef } from "./types.js";
2
+ export declare const messageTools: ToolDef[];
3
+ //# sourceMappingURL=messages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/tools/messages.ts"],"names":[],"mappings":"AACA,OAAO,EAAyB,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AA8IjE,eAAO,MAAM,YAAY,EAAE,OAAO,EAMjC,CAAC"}
@@ -0,0 +1,134 @@
1
+ import { z } from "zod";
2
+ import { defineTool, pickQuery } from "./types.js";
3
+ import { dateRangeShape, paginationShape } from "./shared.js";
4
+ const buttonSchema = z
5
+ .object({
6
+ type: z
7
+ .enum([
8
+ "QUICK_REPLY",
9
+ "URL",
10
+ "PHONE_NUMBER",
11
+ "COPY_CODE",
12
+ "reply",
13
+ "url",
14
+ "call",
15
+ "copy",
16
+ ])
17
+ .describe("button type"),
18
+ text: z.string().optional(),
19
+ url: z.string().url().optional(),
20
+ phone_number: z.string().optional(),
21
+ copyCode: z.string().optional(),
22
+ id: z.string().optional(),
23
+ })
24
+ .passthrough();
25
+ const messagesSend = defineTool({
26
+ name: "messages_send",
27
+ description: "Send a WhatsApp message via POST /v1/messages/send. Provide exactly one destination " +
28
+ "(destinationNumber, groupId, or newsletterId) and exactly one of templateId (approved " +
29
+ "template) or text (free-form). Number-scoped API key required.",
30
+ inputSchema: {
31
+ templateId: z
32
+ .string()
33
+ .optional()
34
+ .describe("Template id or name (mutually exclusive with text)"),
35
+ text: z
36
+ .string()
37
+ .optional()
38
+ .describe("Free-form message text (mutually exclusive with templateId)"),
39
+ destinationNumber: z
40
+ .string()
41
+ .optional()
42
+ .describe("Recipient phone in E.164 digits"),
43
+ groupId: z.string().optional().describe("WhatsApp group JID (…@g.us)"),
44
+ newsletterId: z
45
+ .string()
46
+ .optional()
47
+ .describe("WhatsApp newsletter channel id (…@newsletter)"),
48
+ variables: z
49
+ .record(z.string())
50
+ .optional()
51
+ .describe("Template variable substitutions"),
52
+ media: z.string().url().optional().describe("Media URL (template messages)"),
53
+ mediaType: z.enum(["image", "video", "document"]).optional(),
54
+ buttons: z.array(buttonSchema).min(1).max(3).optional(),
55
+ header: z
56
+ .object({
57
+ type: z.enum(["text", "image", "video", "document"]),
58
+ content: z.string(),
59
+ })
60
+ .optional()
61
+ .describe("Free-form header (requires buttons)"),
62
+ footer: z.string().max(60).optional(),
63
+ deliverAt: z
64
+ .string()
65
+ .optional()
66
+ .describe("Schedule send time (ISO-8601)"),
67
+ deliverUntil: z
68
+ .string()
69
+ .optional()
70
+ .describe("Drop the message if not sent by this time (ISO-8601)"),
71
+ labels: z.array(z.string()).max(50).optional(),
72
+ marketingOptions: z
73
+ .object({ aiRewriteEnabled: z.boolean().optional() })
74
+ .optional(),
75
+ },
76
+ handler: (client, args) => client.post("/v1/messages/send", { body: args }),
77
+ });
78
+ const messageGet = defineTool({
79
+ name: "message_get",
80
+ description: "Fetch a single message's status and metadata via GET /v1/messages/{id}. " +
81
+ "Accepts the message id or correlationId. Number-scoped API key required.",
82
+ inputSchema: {
83
+ id: z.string().min(1).describe("Message id or correlationId"),
84
+ },
85
+ handler: (client, args) => client.get(`/v1/messages/${encodeURIComponent(String(args.id))}`),
86
+ });
87
+ const messagesCancel = defineTool({
88
+ name: "messages_cancel",
89
+ description: "Cancel one or more scheduled (not-yet-sent) messages via DELETE /v1/messages/cancel. " +
90
+ "Number-scoped API key required.",
91
+ inputSchema: {
92
+ messageIds: z
93
+ .array(z.string().min(1))
94
+ .min(1)
95
+ .max(100)
96
+ .describe("Message ids to cancel (1–100)"),
97
+ },
98
+ handler: (client, args) => client.delete("/v1/messages/cancel", {
99
+ body: { messageIds: args.messageIds },
100
+ }),
101
+ });
102
+ const messagesGroup = defineTool({
103
+ name: "messages_group",
104
+ description: "List stored group messages via GET /v1/messages/group, ordered newest first. " +
105
+ "Supports startDate/endDate (ISO-8601) and page/pageSize. Returns empty when the " +
106
+ "number's privacy mode is RELAY_ONLY. Not supported for Meta Cloud API numbers.",
107
+ inputSchema: {
108
+ ...dateRangeShape,
109
+ ...paginationShape,
110
+ },
111
+ handler: (client, args) => client.get("/v1/messages/group", {
112
+ query: pickQuery(args, ["startDate", "endDate", "page", "pageSize"]),
113
+ }),
114
+ });
115
+ const messagesUnread = defineTool({
116
+ name: "messages_unread",
117
+ description: "List inbound messages that have not been read (readAt is null) via " +
118
+ "GET /v1/messages/unread. Supports page/pageSize. Returns empty when the number's " +
119
+ "privacy mode is RELAY_ONLY.",
120
+ inputSchema: {
121
+ ...paginationShape,
122
+ },
123
+ handler: (client, args) => client.get("/v1/messages/unread", {
124
+ query: pickQuery(args, ["page", "pageSize"]),
125
+ }),
126
+ });
127
+ export const messageTools = [
128
+ messagesSend,
129
+ messageGet,
130
+ messagesCancel,
131
+ messagesGroup,
132
+ messagesUnread,
133
+ ];
134
+ //# sourceMappingURL=messages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messages.js","sourceRoot":"","sources":["../../src/tools/messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,SAAS,EAAgB,MAAM,YAAY,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9D,MAAM,YAAY,GAAG,CAAC;KACjB,MAAM,CAAC;IACJ,IAAI,EAAE,CAAC;SACF,IAAI,CAAC;QACF,aAAa;QACb,KAAK;QACL,cAAc;QACd,WAAW;QACX,OAAO;QACP,KAAK;QACL,MAAM;QACN,MAAM;KACT,CAAC;SACD,QAAQ,CAAC,aAAa,CAAC;IAC5B,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IAChC,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACnC,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC/B,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC5B,CAAC;KACD,WAAW,EAAE,CAAC;AAEnB,MAAM,YAAY,GAAG,UAAU,CAAC;IAC5B,IAAI,EAAE,eAAe;IACrB,WAAW,EACP,sFAAsF;QACtF,wFAAwF;QACxF,gEAAgE;IACpE,WAAW,EAAE;QACT,UAAU,EAAE,CAAC;aACR,MAAM,EAAE;aACR,QAAQ,EAAE;aACV,QAAQ,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MappingURL=numbers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"numbers.d.ts","sourceRoot":"","sources":["../../src/tools/numbers.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAyDtD,eAAO,MAAM,WAAW,EAAE,OAAO,EAKhC,CAAC"}
@@ -0,0 +1,52 @@
1
+ import { z } from "zod";
2
+ import { defineTool } from "./types.js";
3
+ const numbersList = defineTool({
4
+ name: "numbers_list",
5
+ description: "List all WhatsApp numbers for the tenant via GET /v1/numbers, including per-connection " +
6
+ "state and aggregate connection status. Works with tenant- or number-scoped keys.",
7
+ inputSchema: {},
8
+ handler: (client) => client.get("/v1/numbers"),
9
+ });
10
+ const numbersCreate = defineTool({
11
+ name: "numbers_create",
12
+ description: "Create a new WhatsApp number (unofficial QR pairing) via POST /v1/numbers and return the " +
13
+ "QR code / pairing code to connect it. The phone must be unique for the tenant.",
14
+ inputSchema: {
15
+ name: z.string().min(1).max(60).describe("Display name for the number"),
16
+ number: z
17
+ .string()
18
+ .min(10)
19
+ .regex(/^\+?\d+$/, "number must be a valid phone number")
20
+ .describe("Phone in E.164 digits"),
21
+ linkToApiKey: z
22
+ .boolean()
23
+ .optional()
24
+ .describe("Link the new number to the calling number-scoped key (default true for number keys)"),
25
+ },
26
+ handler: (client, args) => client.post("/v1/numbers", { body: args }),
27
+ });
28
+ const numbersDelete = defineTool({
29
+ name: "numbers_delete",
30
+ description: "Delete a WhatsApp number / instance via DELETE /v1/numbers/{id}, cleaning up the upstream " +
31
+ "provider connection.",
32
+ inputSchema: {
33
+ id: z.string().min(1).describe("WhatsApp number / instance id"),
34
+ },
35
+ handler: (client, args) => client.delete(`/v1/numbers/${encodeURIComponent(String(args.id))}`),
36
+ });
37
+ const numbersStatus = defineTool({
38
+ name: "numbers_status",
39
+ description: "Get the live connection state of a WhatsApp number via GET /v1/numbers/{id}/status " +
40
+ "(e.g. OPEN, CONNECTING, CLOSE).",
41
+ inputSchema: {
42
+ id: z.string().min(1).describe("WhatsApp number / instance id"),
43
+ },
44
+ handler: (client, args) => client.get(`/v1/numbers/${encodeURIComponent(String(args.id))}/status`),
45
+ });
46
+ export const numberTools = [
47
+ numbersList,
48
+ numbersCreate,
49
+ numbersDelete,
50
+ numbersStatus,
51
+ ];
52
+ //# sourceMappingURL=numbers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"numbers.js","sourceRoot":"","sources":["../../src/tools/numbers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAgB,MAAM,YAAY,CAAC;AAEtD,MAAM,WAAW,GAAG,UAAU,CAAC;IAC3B,IAAI,EAAE,cAAc;IACpB,WAAW,EACP,yFAAyF;QACzF,kFAAkF;IACtF,WAAW,EAAE,EAAE;IACf,OAAO,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC;CACjD,CAAC,CAAC;AAEH,MAAM,aAAa,GAAG,UAAU,CAAC;IAC7B,IAAI,EAAE,gBAAgB;IACtB,WAAW,EACP,2FAA2F;QAC3F,gFAAgF;IACpF,WAAW,EAAE;QACT,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,6BAA6B,CAAC;QACvE,MAAM,EAAE,CAAC;aACJ,MAAM,EAAE;aACR,GAAG,CAAC,EAAE,CAAC;aACP,KAAK,CAAC,UAAU,EAAE,qCAAqC,CAAC;aACxD,QAAQ,CAAC,uBAAuB,CAAC;QACtC,YAAY,EAAE,CAAC;aACV,OAAO,EAAE;aACT,QAAQ,EAAE;aACV,QAAQ,CACL,qFAAqF,CACxF;KACR;IACD,OAAO,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;CACxE,CAAC,CAAC;AAEH,MAAM,aAAa,GAAG,UAAU,CAAC;IAC7B,IAAI,EAAE,gBAAgB;IACtB,WAAW,EACP,4FAA4F;QAC5F,sBAAsB;IAC1B,WAAW,EAAE;QACT,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,+BAA+B,CAAC;KAClE;IACD,OAAO,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,CACtB,MAAM,CAAC,MAAM,CAAC,eAAe,kBAAkB,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;CAC1E,CAAC,CAAC;AAEH,MAAM,aAAa,GAAG,UAAU,CAAC;IAC7B,IAAI,EAAE,gBAAgB;IACtB,WAAW,EACP,qFAAqF;QACrF,iCAAiC;IACrC,WAAW,EAAE;QACT,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,+BAA+B,CAAC;KAClE;IACD,OAAO,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,CACtB,MAAM,CAAC,GAAG,CAAC,eAAe,kBAAkB,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC;CAC9E,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,WAAW,GAAc;IAClC,WAAW;IACX,aAAa;IACb,aAAa;IACb,aAAa;CAChB,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Reusable Zod raw-shape fragments shared across tools. Kept loose on purpose —
4
+ * the public API is the source of truth and validates every field server-side;
5
+ * over-tight client schemas would only cause confusing local rejections.
6
+ */
7
+ /** ISO-8601 date-time string (with offset or Z), e.g. 2026-06-27T00:00:00Z. */
8
+ export declare const isoDateTime: z.ZodString;
9
+ /** page / pageSize pagination fragment. */
10
+ export declare const paginationShape: {
11
+ readonly page: z.ZodOptional<z.ZodNumber>;
12
+ readonly pageSize: z.ZodOptional<z.ZodNumber>;
13
+ };
14
+ /** startDate / endDate date-range fragment (filters by message/conversation time). */
15
+ export declare const dateRangeShape: {
16
+ readonly startDate: z.ZodOptional<z.ZodString>;
17
+ readonly endDate: z.ZodOptional<z.ZodString>;
18
+ };
19
+ //# sourceMappingURL=shared.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/tools/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;GAIG;AAEH,+EAA+E;AAC/E,eAAO,MAAM,WAAW,aAEsC,CAAC;AAE/D,2CAA2C;AAC3C,eAAO,MAAM,eAAe;;;CASlB,CAAC;AAEX,sFAAsF;AACtF,eAAO,MAAM,cAAc;;;CAGjB,CAAC"}
@@ -0,0 +1,27 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Reusable Zod raw-shape fragments shared across tools. Kept loose on purpose —
4
+ * the public API is the source of truth and validates every field server-side;
5
+ * over-tight client schemas would only cause confusing local rejections.
6
+ */
7
+ /** ISO-8601 date-time string (with offset or Z), e.g. 2026-06-27T00:00:00Z. */
8
+ export const isoDateTime = z
9
+ .string()
10
+ .describe("ISO-8601 date-time, e.g. 2026-06-27T00:00:00Z");
11
+ /** page / pageSize pagination fragment. */
12
+ export const paginationShape = {
13
+ page: z.number().int().min(1).optional().describe("1-based page number"),
14
+ pageSize: z
15
+ .number()
16
+ .int()
17
+ .min(1)
18
+ .max(200)
19
+ .optional()
20
+ .describe("items per page (max 200)"),
21
+ };
22
+ /** startDate / endDate date-range fragment (filters by message/conversation time). */
23
+ export const dateRangeShape = {
24
+ startDate: isoDateTime.optional().describe("inclusive lower bound (ISO-8601)"),
25
+ endDate: isoDateTime.optional().describe("inclusive upper bound (ISO-8601)"),
26
+ };
27
+ //# sourceMappingURL=shared.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/tools/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;GAIG;AAEH,+EAA+E;AAC/E,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC;KACvB,MAAM,EAAE;KACR,QAAQ,CAAC,+CAA+C,CAAC,CAAC;AAE/D,2CAA2C;AAC3C,MAAM,CAAC,MAAM,eAAe,GAAG;IAC3B,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,qBAAqB,CAAC;IACxE,QAAQ,EAAE,CAAC;SACN,MAAM,EAAE;SACR,GAAG,EAAE;SACL,GAAG,CAAC,CAAC,CAAC;SACN,GAAG,CAAC,GAAG,CAAC;SACR,QAAQ,EAAE;SACV,QAAQ,CAAC,0BAA0B,CAAC;CACnC,CAAC;AAEX,sFAAsF;AACtF,MAAM,CAAC,MAAM,cAAc,GAAG;IAC1B,SAAS,EAAE,WAAW,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,kCAAkC,CAAC;IAC9E,OAAO,EAAE,WAAW,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,kCAAkC,CAAC;CACtE,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { type ToolDef } from "./types.js";
2
+ export declare const subscriptionTools: ToolDef[];
3
+ //# sourceMappingURL=subscription.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscription.d.ts","sourceRoot":"","sources":["../../src/tools/subscription.ts"],"names":[],"mappings":"AACA,OAAO,EAAyB,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AA2CjE,eAAO,MAAM,iBAAiB,EAAE,OAAO,EAAuC,CAAC"}
@@ -0,0 +1,39 @@
1
+ import { z } from "zod";
2
+ import { defineTool, pickQuery } from "./types.js";
3
+ const extraNumbersGet = defineTool({
4
+ name: "subscription_extra_numbers_get",
5
+ description: "Preview the cost of buying N extra WhatsApp number(s) via GET /v1/subscription/extra-numbers. " +
6
+ "Tenant-scoped API key required.",
7
+ inputSchema: {
8
+ quantity: z
9
+ .number()
10
+ .int()
11
+ .min(1)
12
+ .optional()
13
+ .describe("How many extra numbers to preview (default 1)"),
14
+ },
15
+ handler: (client, args) => client.get("/v1/subscription/extra-numbers", {
16
+ query: pickQuery(args, ["quantity"]),
17
+ }),
18
+ });
19
+ const extraNumbersAdd = defineTool({
20
+ name: "subscription_extra_numbers_add",
21
+ description: "Purchase N extra WhatsApp number(s) via POST /v1/subscription/extra-numbers. FREE plans " +
22
+ "convert to On Demand and require confirm:true. Returns a checkout URL if no saved card. " +
23
+ "Tenant-scoped API key required.",
24
+ inputSchema: {
25
+ quantity: z
26
+ .number()
27
+ .int()
28
+ .min(1)
29
+ .optional()
30
+ .describe("How many extra numbers to buy (default 1)"),
31
+ confirm: z
32
+ .boolean()
33
+ .optional()
34
+ .describe("Required (true) when the purchase converts a FREE plan to On Demand"),
35
+ },
36
+ handler: (client, args) => client.post("/v1/subscription/extra-numbers", { body: args }),
37
+ });
38
+ export const subscriptionTools = [extraNumbersGet, extraNumbersAdd];
39
+ //# sourceMappingURL=subscription.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscription.js","sourceRoot":"","sources":["../../src/tools/subscription.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,SAAS,EAAgB,MAAM,YAAY,CAAC;AAEjE,MAAM,eAAe,GAAG,UAAU,CAAC;IAC/B,IAAI,EAAE,gCAAgC;IACtC,WAAW,EACP,gGAAgG;QAChG,iCAAiC;IACrC,WAAW,EAAE;QACT,QAAQ,EAAE,CAAC;aACN,MAAM,EAAE;aACR,GAAG,EAAE;aACL,GAAG,CAAC,CAAC,CAAC;aACN,QAAQ,EAAE;aACV,QAAQ,CAAC,+CAA+C,CAAC;KACjE;IACD,OAAO,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,CACtB,MAAM,CAAC,GAAG,CAAC,gCAAgC,EAAE;QACzC,KAAK,EAAE,SAAS,CAAC,IAAI,EAAE,CAAC,UAAU,CAAC,CAAC;KACvC,CAAC;CACT,CAAC,CAAC;AAEH,MAAM,eAAe,GAAG,UAAU,CAAC;IAC/B,IAAI,EAAE,gCAAgC;IACtC,WAAW,EACP,0FAA0F;QAC1F,0FAA0F;QAC1F,iCAAiC;IACrC,WAAW,EAAE;QACT,QAAQ,EAAE,CAAC;aACN,MAAM,EAAE;aACR,GAAG,EAAE;aACL,GAAG,CAAC,CAAC,CAAC;aACN,QAAQ,EAAE;aACV,QAAQ,CAAC,2CAA2C,CAAC;QAC1D,OAAO,EAAE,CAAC;aACL,OAAO,EAAE;aACT,QAAQ,EAAE;aACV,QAAQ,CAAC,qEAAqE,CAAC;KACvF;IACD,OAAO,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,CACtB,MAAM,CAAC,IAAI,CAAC,gCAAgC,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;CACpE,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,iBAAiB,GAAc,CAAC,eAAe,EAAE,eAAe,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { type ToolDef } from "./types.js";
2
+ export declare const templateTools: ToolDef[];
3
+ //# sourceMappingURL=templates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/tools/templates.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAyEtD,eAAO,MAAM,aAAa,EAAE,OAAO,EAKlC,CAAC"}
@@ -0,0 +1,68 @@
1
+ import { z } from "zod";
2
+ import { defineTool } from "./types.js";
3
+ const templatesList = defineTool({
4
+ name: "templates_list",
5
+ description: "List message templates for the key's WhatsApp number via GET /v1/templates. " +
6
+ "Number-scoped API key required.",
7
+ inputSchema: {},
8
+ handler: (client) => client.get("/v1/templates"),
9
+ });
10
+ const templatesCreate = defineTool({
11
+ name: "templates_create",
12
+ description: "Create a message template via POST /v1/templates. The template is scoped to the key's " +
13
+ "WhatsApp number (and submitted to Meta for Meta numbers). Number-scoped API key required.",
14
+ inputSchema: {
15
+ name: z
16
+ .string()
17
+ .min(1)
18
+ .max(100)
19
+ .describe("Template name (letters/numbers; separators become _)"),
20
+ category: z
21
+ .enum(["OTP", "UTILITY", "MARKETING"])
22
+ .optional()
23
+ .describe("Template category (default UTILITY)"),
24
+ body: z
25
+ .string()
26
+ .min(1)
27
+ .describe("Template body — plain text or the full template JSON (header/body/footer/buttons)"),
28
+ variables: z
29
+ .array(z.string())
30
+ .optional()
31
+ .describe("Variable names (auto-derived from body if omitted)"),
32
+ language: z
33
+ .string()
34
+ .optional()
35
+ .describe("Meta language code, e.g. pt_BR (default pt_BR)"),
36
+ },
37
+ handler: (client, args) => client.post("/v1/templates", { body: args }),
38
+ });
39
+ const templatesGet = defineTool({
40
+ name: "templates_get",
41
+ description: "Fetch a single template by id via GET /v1/templates/{id}. Number-scoped API key required.",
42
+ inputSchema: {
43
+ id: z.string().min(1).describe("Template id"),
44
+ },
45
+ handler: (client, args) => client.get(`/v1/templates/${encodeURIComponent(String(args.id))}`),
46
+ });
47
+ const templatesUpdate = defineTool({
48
+ name: "templates_update",
49
+ description: "Update a template's body via PUT /v1/templates/{id} (re-submits to Meta for Meta numbers). " +
50
+ "Number-scoped API key required.",
51
+ inputSchema: {
52
+ id: z.string().min(1).describe("Template id"),
53
+ body: z
54
+ .string()
55
+ .min(1)
56
+ .describe("New template body (text or full template JSON)"),
57
+ },
58
+ handler: (client, args) => client.put(`/v1/templates/${encodeURIComponent(String(args.id))}`, {
59
+ body: { body: args.body },
60
+ }),
61
+ });
62
+ export const templateTools = [
63
+ templatesList,
64
+ templatesCreate,
65
+ templatesGet,
66
+ templatesUpdate,
67
+ ];
68
+ //# sourceMappingURL=templates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"templates.js","sourceRoot":"","sources":["../../src/tools/templates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAgB,MAAM,YAAY,CAAC;AAEtD,MAAM,aAAa,GAAG,UAAU,CAAC;IAC7B,IAAI,EAAE,gBAAgB;IACtB,WAAW,EACP,8EAA8E;QAC9E,iCAAiC;IACrC,WAAW,EAAE,EAAE;IACf,OAAO,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC;CACnD,CAAC,CAAC;AAEH,MAAM,eAAe,GAAG,UAAU,CAAC;IAC/B,IAAI,EAAE,kBAAkB;IACxB,WAAW,EACP,wFAAwF;QACxF,2FAA2F;IAC/F,WAAW,EAAE;QACT,IAAI,EAAE,CAAC;aACF,MAAM,EAAE;aACR,GAAG,CAAC,CAAC,CAAC;aACN,GAAG,CAAC,GAAG,CAAC;aACR,QAAQ,CAAC,sDAAsD,CAAC;QACrE,QAAQ,EAAE,CAAC;aACN,IAAI,CAAC,CAAC,KAAK,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;aACrC,QAAQ,EAAE;aACV,QAAQ,CAAC,qCAAqC,CAAC;QACpD,IAAI,EAAE,CAAC;aACF,MAAM,EAAE;aACR,GAAG,CAAC,CAAC,CAAC;aACN,QAAQ,CACL,mFAAmF,CACtF;QACL,SAAS,EAAE,CAAC;aACP,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;aACjB,QAAQ,EAAE;aACV,QAAQ,CAAC,oDAAoD,CAAC;QACnE,QAAQ,EAAE,CAAC;aACN,MAAM,EAAE;aACR,QAAQ,EAAE;aACV,QAAQ,CAAC,gDAAgD,CAAC;KAClE;IACD,OAAO,EAAE,CAAC,MAA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