@contractspec/integration.providers-impls 3.8.9 → 3.8.11

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 (147) hide show
  1. package/dist/analytics.js +1 -2
  2. package/dist/calendar.js +1 -2
  3. package/dist/database.js +1 -2
  4. package/dist/email.js +1 -2
  5. package/dist/embedding.js +1 -2
  6. package/dist/health.js +1 -2
  7. package/dist/impls/async-event-queue.js +1 -48
  8. package/dist/impls/composio-fallback-resolver.js +1 -579
  9. package/dist/impls/composio-mcp.js +1 -163
  10. package/dist/impls/composio-proxies.js +1 -310
  11. package/dist/impls/composio-sdk.js +1 -77
  12. package/dist/impls/composio-types.js +1 -53
  13. package/dist/impls/elevenlabs-voice.js +1 -104
  14. package/dist/impls/fal-voice.js +1 -117
  15. package/dist/impls/fathom-meeting-recorder.js +2 -289
  16. package/dist/impls/fathom-meeting-recorder.mapper.js +1 -107
  17. package/dist/impls/fathom-meeting-recorder.utils.js +1 -74
  18. package/dist/impls/fathom-meeting-recorder.webhooks.js +1 -31
  19. package/dist/impls/fireflies-meeting-recorder.js +5 -203
  20. package/dist/impls/fireflies-meeting-recorder.queries.js +4 -14
  21. package/dist/impls/fireflies-meeting-recorder.utils.js +1 -44
  22. package/dist/impls/gcs-storage.js +1 -99
  23. package/dist/impls/gmail-inbound.js +1 -229
  24. package/dist/impls/gmail-outbound.js +25 -137
  25. package/dist/impls/google-calendar.js +1 -193
  26. package/dist/impls/gradium-voice.js +1 -95
  27. package/dist/impls/granola-meeting-recorder.js +3 -514
  28. package/dist/impls/granola-meeting-recorder.mcp.js +1 -280
  29. package/dist/impls/health/base-health-provider.js +1 -617
  30. package/dist/impls/health/hybrid-health-providers.js +1 -1089
  31. package/dist/impls/health/official-health-providers.js +1 -969
  32. package/dist/impls/health/provider-normalizers.js +1 -288
  33. package/dist/impls/health/providers.js +1 -1095
  34. package/dist/impls/health-provider-factory.js +1 -1309
  35. package/dist/impls/index.js +42 -7448
  36. package/dist/impls/jira.js +1 -126
  37. package/dist/impls/linear.js +1 -85
  38. package/dist/impls/messaging-github.js +1 -111
  39. package/dist/impls/messaging-slack.js +1 -81
  40. package/dist/impls/messaging-telegram.js +1 -48
  41. package/dist/impls/messaging-whatsapp-meta.js +1 -53
  42. package/dist/impls/messaging-whatsapp-twilio.js +1 -83
  43. package/dist/impls/mistral-conversational.js +2 -477
  44. package/dist/impls/mistral-conversational.session.js +2 -207
  45. package/dist/impls/mistral-embedding.js +1 -45
  46. package/dist/impls/mistral-llm.js +1 -271
  47. package/dist/impls/mistral-stt.js +1 -168
  48. package/dist/impls/notion.js +1 -162
  49. package/dist/impls/posthog-reader.js +1 -161
  50. package/dist/impls/posthog-utils.js +1 -40
  51. package/dist/impls/posthog.js +1 -324
  52. package/dist/impls/postmark-email.js +1 -62
  53. package/dist/impls/powens-client.js +1 -197
  54. package/dist/impls/powens-openbanking.js +1 -428
  55. package/dist/impls/provider-factory.js +18 -6268
  56. package/dist/impls/qdrant-vector.js +1 -80
  57. package/dist/impls/stripe-payments.js +1 -230
  58. package/dist/impls/supabase-psql.js +1 -152
  59. package/dist/impls/supabase-vector.js +9 -298
  60. package/dist/impls/tldv-meeting-recorder.js +2 -147
  61. package/dist/impls/twilio-sms.js +1 -67
  62. package/dist/index.js +42 -7495
  63. package/dist/llm.js +1 -2
  64. package/dist/meeting-recorder.js +1 -2
  65. package/dist/messaging.js +1 -2
  66. package/dist/node/analytics.js +1 -2
  67. package/dist/node/calendar.js +1 -2
  68. package/dist/node/database.js +1 -2
  69. package/dist/node/email.js +1 -2
  70. package/dist/node/embedding.js +1 -2
  71. package/dist/node/health.js +1 -2
  72. package/dist/node/impls/async-event-queue.js +1 -49
  73. package/dist/node/impls/composio-fallback-resolver.js +1 -580
  74. package/dist/node/impls/composio-mcp.js +1 -164
  75. package/dist/node/impls/composio-proxies.js +1 -311
  76. package/dist/node/impls/composio-sdk.js +1 -78
  77. package/dist/node/impls/composio-types.js +1 -54
  78. package/dist/node/impls/elevenlabs-voice.js +1 -105
  79. package/dist/node/impls/fal-voice.js +1 -118
  80. package/dist/node/impls/fathom-meeting-recorder.js +2 -290
  81. package/dist/node/impls/fathom-meeting-recorder.mapper.js +1 -108
  82. package/dist/node/impls/fathom-meeting-recorder.utils.js +1 -75
  83. package/dist/node/impls/fathom-meeting-recorder.webhooks.js +1 -32
  84. package/dist/node/impls/fireflies-meeting-recorder.js +5 -204
  85. package/dist/node/impls/fireflies-meeting-recorder.queries.js +4 -15
  86. package/dist/node/impls/fireflies-meeting-recorder.utils.js +1 -45
  87. package/dist/node/impls/gcs-storage.js +1 -100
  88. package/dist/node/impls/gmail-inbound.js +1 -230
  89. package/dist/node/impls/gmail-outbound.js +25 -138
  90. package/dist/node/impls/google-calendar.js +1 -194
  91. package/dist/node/impls/gradium-voice.js +1 -96
  92. package/dist/node/impls/granola-meeting-recorder.js +3 -515
  93. package/dist/node/impls/granola-meeting-recorder.mcp.js +1 -281
  94. package/dist/node/impls/health/base-health-provider.js +1 -618
  95. package/dist/node/impls/health/hybrid-health-providers.js +1 -1090
  96. package/dist/node/impls/health/official-health-providers.js +1 -970
  97. package/dist/node/impls/health/provider-normalizers.js +1 -289
  98. package/dist/node/impls/health/providers.js +1 -1096
  99. package/dist/node/impls/health-provider-factory.js +1 -1310
  100. package/dist/node/impls/index.js +42 -7449
  101. package/dist/node/impls/jira.js +1 -127
  102. package/dist/node/impls/linear.js +1 -86
  103. package/dist/node/impls/messaging-github.js +1 -112
  104. package/dist/node/impls/messaging-slack.js +1 -82
  105. package/dist/node/impls/messaging-telegram.js +1 -49
  106. package/dist/node/impls/messaging-whatsapp-meta.js +1 -54
  107. package/dist/node/impls/messaging-whatsapp-twilio.js +1 -84
  108. package/dist/node/impls/mistral-conversational.js +2 -478
  109. package/dist/node/impls/mistral-conversational.session.js +2 -208
  110. package/dist/node/impls/mistral-embedding.js +1 -46
  111. package/dist/node/impls/mistral-llm.js +1 -272
  112. package/dist/node/impls/mistral-stt.js +1 -169
  113. package/dist/node/impls/notion.js +1 -163
  114. package/dist/node/impls/posthog-reader.js +1 -162
  115. package/dist/node/impls/posthog-utils.js +1 -41
  116. package/dist/node/impls/posthog.js +1 -325
  117. package/dist/node/impls/postmark-email.js +1 -63
  118. package/dist/node/impls/powens-client.js +1 -198
  119. package/dist/node/impls/powens-openbanking.js +1 -429
  120. package/dist/node/impls/provider-factory.js +18 -6269
  121. package/dist/node/impls/qdrant-vector.js +1 -81
  122. package/dist/node/impls/stripe-payments.js +1 -231
  123. package/dist/node/impls/supabase-psql.js +1 -153
  124. package/dist/node/impls/supabase-vector.js +9 -299
  125. package/dist/node/impls/tldv-meeting-recorder.js +2 -148
  126. package/dist/node/impls/twilio-sms.js +1 -68
  127. package/dist/node/index.js +42 -7496
  128. package/dist/node/llm.js +1 -2
  129. package/dist/node/meeting-recorder.js +1 -2
  130. package/dist/node/messaging.js +1 -2
  131. package/dist/node/openbanking.js +1 -2
  132. package/dist/node/payments.js +1 -2
  133. package/dist/node/project-management.js +1 -2
  134. package/dist/node/secrets/provider.js +1 -14
  135. package/dist/node/sms.js +1 -2
  136. package/dist/node/storage.js +1 -2
  137. package/dist/node/vector-store.js +1 -2
  138. package/dist/node/voice.js +1 -2
  139. package/dist/openbanking.js +1 -2
  140. package/dist/payments.js +1 -2
  141. package/dist/project-management.js +1 -2
  142. package/dist/secrets/provider.js +1 -13
  143. package/dist/sms.js +1 -2
  144. package/dist/storage.js +1 -2
  145. package/dist/vector-store.js +1 -2
  146. package/dist/voice.js +1 -2
  147. package/package.json +16 -16
@@ -1,127 +1 @@
1
- import { createRequire } from "node:module";
2
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
3
-
4
- // src/impls/jira.ts
5
- import { Buffer } from "node:buffer";
6
-
7
- class JiraProjectManagementProvider {
8
- siteUrl;
9
- authHeader;
10
- defaults;
11
- fetchFn;
12
- constructor(options) {
13
- this.siteUrl = normalizeSiteUrl(options.siteUrl);
14
- this.authHeader = buildAuthHeader(options.email, options.apiToken);
15
- this.defaults = {
16
- projectKey: options.projectKey,
17
- issueType: options.issueType,
18
- defaultLabels: options.defaultLabels,
19
- issueTypeMap: options.issueTypeMap
20
- };
21
- this.fetchFn = options.fetch ?? fetch;
22
- }
23
- async createWorkItem(input) {
24
- const projectKey = input.projectId ?? this.defaults.projectKey;
25
- if (!projectKey) {
26
- throw new Error("Jira projectKey is required to create work items.");
27
- }
28
- const issueType = resolveIssueType(input.type, this.defaults);
29
- const description = buildJiraDescription(input.description);
30
- const labels = mergeLabels(this.defaults.defaultLabels, input.tags);
31
- const priority = mapPriority(input.priority);
32
- const payload = {
33
- fields: {
34
- project: { key: projectKey },
35
- summary: input.title,
36
- description,
37
- issuetype: { name: issueType },
38
- labels,
39
- priority: priority ? { name: priority } : undefined,
40
- assignee: input.assigneeId ? { accountId: input.assigneeId } : undefined,
41
- duedate: input.dueDate ? input.dueDate.toISOString().slice(0, 10) : undefined
42
- }
43
- };
44
- const response = await this.fetchFn(`${this.siteUrl}/rest/api/3/issue`, {
45
- method: "POST",
46
- headers: {
47
- Authorization: this.authHeader,
48
- "Content-Type": "application/json",
49
- Accept: "application/json"
50
- },
51
- body: JSON.stringify(payload)
52
- });
53
- if (!response.ok) {
54
- const body = await response.text();
55
- throw new Error(`Jira API error (${response.status}): ${body || response.statusText}`);
56
- }
57
- const data = await response.json();
58
- return {
59
- id: data.id ?? data.key ?? "",
60
- title: input.title,
61
- url: data.key ? `${this.siteUrl}/browse/${data.key}` : undefined,
62
- status: input.status,
63
- priority: input.priority,
64
- tags: input.tags,
65
- projectId: projectKey,
66
- externalId: input.externalId,
67
- metadata: input.metadata
68
- };
69
- }
70
- async createWorkItems(items) {
71
- const created = [];
72
- for (const item of items) {
73
- created.push(await this.createWorkItem(item));
74
- }
75
- return created;
76
- }
77
- }
78
- function normalizeSiteUrl(siteUrl) {
79
- return siteUrl.replace(/\/$/, "");
80
- }
81
- function buildAuthHeader(email, apiToken) {
82
- const token = Buffer.from(`${email}:${apiToken}`).toString("base64");
83
- return `Basic ${token}`;
84
- }
85
- function resolveIssueType(type, defaults) {
86
- if (type && defaults.issueTypeMap?.[type]) {
87
- return defaults.issueTypeMap[type] ?? defaults.issueType ?? "Task";
88
- }
89
- return defaults.issueType ?? "Task";
90
- }
91
- function mapPriority(priority) {
92
- switch (priority) {
93
- case "urgent":
94
- return "Highest";
95
- case "high":
96
- return "High";
97
- case "medium":
98
- return "Medium";
99
- case "low":
100
- return "Low";
101
- case "none":
102
- default:
103
- return;
104
- }
105
- }
106
- function mergeLabels(defaults, tags) {
107
- const merged = new Set;
108
- (defaults ?? []).forEach((label) => merged.add(label));
109
- (tags ?? []).forEach((tag) => merged.add(tag));
110
- const result = [...merged];
111
- return result.length > 0 ? result : undefined;
112
- }
113
- function buildJiraDescription(description) {
114
- if (!description)
115
- return;
116
- const lines = description.split(/\r?\n/).filter((line) => line.trim());
117
- const content = lines.map((line) => ({
118
- type: "paragraph",
119
- content: [{ type: "text", text: line }]
120
- }));
121
- if (content.length === 0)
122
- return;
123
- return { type: "doc", version: 1, content };
124
- }
125
- export {
126
- JiraProjectManagementProvider
127
- };
1
+ import{createRequire as u}from"node:module";var k=u(import.meta.url);import{Buffer as m}from"node:buffer";class g{siteUrl;authHeader;defaults;fetchFn;constructor(e){this.siteUrl=p(e.siteUrl),this.authHeader=f(e.email,e.apiToken),this.defaults={projectKey:e.projectKey,issueType:e.issueType,defaultLabels:e.defaultLabels,issueTypeMap:e.issueTypeMap},this.fetchFn=e.fetch??fetch}async createWorkItem(e){let t=e.projectId??this.defaults.projectKey;if(!t)throw Error("Jira projectKey is required to create work items.");let r=l(e.type,this.defaults),n=P(e.description),a=h(this.defaults.defaultLabels,e.tags),o=y(e.priority),c={fields:{project:{key:t},summary:e.title,description:n,issuetype:{name:r},labels:a,priority:o?{name:o}:void 0,assignee:e.assigneeId?{accountId:e.assigneeId}:void 0,duedate:e.dueDate?e.dueDate.toISOString().slice(0,10):void 0}},i=await this.fetchFn(`${this.siteUrl}/rest/api/3/issue`,{method:"POST",headers:{Authorization:this.authHeader,"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(c)});if(!i.ok){let d=await i.text();throw Error(`Jira API error (${i.status}): ${d||i.statusText}`)}let s=await i.json();return{id:s.id??s.key??"",title:e.title,url:s.key?`${this.siteUrl}/browse/${s.key}`:void 0,status:e.status,priority:e.priority,tags:e.tags,projectId:t,externalId:e.externalId,metadata:e.metadata}}async createWorkItems(e){let t=[];for(let r of e)t.push(await this.createWorkItem(r));return t}}function p(e){return e.replace(/\/$/,"")}function f(e,t){return`Basic ${m.from(`${e}:${t}`).toString("base64")}`}function l(e,t){if(e&&t.issueTypeMap?.[e])return t.issueTypeMap[e]??t.issueType??"Task";return t.issueType??"Task"}function y(e){switch(e){case"urgent":return"Highest";case"high":return"High";case"medium":return"Medium";case"low":return"Low";case"none":default:return}}function h(e,t){let r=new Set;(e??[]).forEach((a)=>r.add(a)),(t??[]).forEach((a)=>r.add(a));let n=[...r];return n.length>0?n:void 0}function P(e){if(!e)return;let r=e.split(/\r?\n/).filter((n)=>n.trim()).map((n)=>({type:"paragraph",content:[{type:"text",text:n}]}));if(r.length===0)return;return{type:"doc",version:1,content:r}}export{g as JiraProjectManagementProvider};
@@ -1,86 +1 @@
1
- import { createRequire } from "node:module";
2
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
3
-
4
- // src/impls/linear.ts
5
- import { LinearClient } from "@linear/sdk";
6
- var PRIORITY_MAP = {
7
- urgent: 1,
8
- high: 2,
9
- medium: 3,
10
- low: 4,
11
- none: 0
12
- };
13
-
14
- class LinearProjectManagementProvider {
15
- client;
16
- defaults;
17
- constructor(options) {
18
- this.client = options.client ?? new LinearClient({ apiKey: options.apiKey });
19
- this.defaults = {
20
- teamId: options.teamId,
21
- projectId: options.projectId,
22
- assigneeId: options.assigneeId,
23
- stateId: options.stateId,
24
- labelIds: options.labelIds,
25
- tagLabelMap: options.tagLabelMap
26
- };
27
- }
28
- async createWorkItem(input) {
29
- const teamId = this.defaults.teamId;
30
- if (!teamId) {
31
- throw new Error("Linear teamId is required to create work items.");
32
- }
33
- const payload = await this.client.createIssue({
34
- teamId,
35
- title: input.title,
36
- description: input.description,
37
- priority: mapPriority(input.priority),
38
- estimate: input.estimate,
39
- assigneeId: input.assigneeId ?? this.defaults.assigneeId,
40
- projectId: input.projectId ?? this.defaults.projectId,
41
- stateId: this.defaults.stateId,
42
- labelIds: resolveLabelIds(this.defaults, input.tags)
43
- });
44
- const issue = await payload.issue;
45
- const state = issue ? await issue.state : undefined;
46
- return {
47
- id: issue?.id ?? "",
48
- title: issue?.title ?? input.title,
49
- url: issue?.url ?? undefined,
50
- status: state?.name ?? undefined,
51
- priority: input.priority,
52
- tags: input.tags,
53
- projectId: input.projectId ?? this.defaults.projectId,
54
- externalId: input.externalId,
55
- metadata: input.metadata
56
- };
57
- }
58
- async createWorkItems(items) {
59
- const created = [];
60
- for (const item of items) {
61
- created.push(await this.createWorkItem(item));
62
- }
63
- return created;
64
- }
65
- }
66
- function mapPriority(priority) {
67
- if (!priority)
68
- return;
69
- return PRIORITY_MAP[priority] ?? undefined;
70
- }
71
- function resolveLabelIds(defaults, tags) {
72
- const labelIds = new Set;
73
- (defaults.labelIds ?? []).forEach((id) => labelIds.add(id));
74
- if (tags && defaults.tagLabelMap) {
75
- tags.forEach((tag) => {
76
- const mapped = defaults.tagLabelMap?.[tag];
77
- if (mapped)
78
- labelIds.add(mapped);
79
- });
80
- }
81
- const merged = [...labelIds];
82
- return merged.length > 0 ? merged : undefined;
83
- }
84
- export {
85
- LinearProjectManagementProvider
86
- };
1
+ import{createRequire as s}from"node:module";var g=s(import.meta.url);import{LinearClient as d}from"@linear/sdk";var o={urgent:1,high:2,medium:3,low:4,none:0};class c{client;defaults;constructor(e){this.client=e.client??new d({apiKey:e.apiKey}),this.defaults={teamId:e.teamId,projectId:e.projectId,assigneeId:e.assigneeId,stateId:e.stateId,labelIds:e.labelIds,tagLabelMap:e.tagLabelMap}}async createWorkItem(e){let t=this.defaults.teamId;if(!t)throw Error("Linear teamId is required to create work items.");let a=await(await this.client.createIssue({teamId:t,title:e.title,description:e.description,priority:m(e.priority),estimate:e.estimate,assigneeId:e.assigneeId??this.defaults.assigneeId,projectId:e.projectId??this.defaults.projectId,stateId:this.defaults.stateId,labelIds:I(this.defaults,e.tags)})).issue,n=a?await a.state:void 0;return{id:a?.id??"",title:a?.title??e.title,url:a?.url??void 0,status:n?.name??void 0,priority:e.priority,tags:e.tags,projectId:e.projectId??this.defaults.projectId,externalId:e.externalId,metadata:e.metadata}}async createWorkItems(e){let t=[];for(let r of e)t.push(await this.createWorkItem(r));return t}}function m(e){if(!e)return;return o[e]??void 0}function I(e,t){let r=new Set;if((e.labelIds??[]).forEach((n)=>r.add(n)),t&&e.tagLabelMap)t.forEach((n)=>{let i=e.tagLabelMap?.[n];if(i)r.add(i)});let a=[...r];return a.length>0?a:void 0}export{c as LinearProjectManagementProvider};
@@ -1,112 +1 @@
1
- import { createRequire } from "node:module";
2
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
3
-
4
- // src/impls/messaging-github.ts
5
- class GithubMessagingProvider {
6
- token;
7
- defaultOwner;
8
- defaultRepo;
9
- apiBaseUrl;
10
- constructor(options) {
11
- this.token = options.token;
12
- this.defaultOwner = options.defaultOwner;
13
- this.defaultRepo = options.defaultRepo;
14
- this.apiBaseUrl = options.apiBaseUrl ?? "https://api.github.com";
15
- }
16
- async sendMessage(input) {
17
- const target = this.resolveTarget(input);
18
- const response = await fetch(`${this.apiBaseUrl}/repos/${target.owner}/${target.repo}/issues/${target.issueNumber}/comments`, {
19
- method: "POST",
20
- headers: {
21
- authorization: `Bearer ${this.token}`,
22
- accept: "application/vnd.github+json",
23
- "content-type": "application/json"
24
- },
25
- body: JSON.stringify({ body: input.text })
26
- });
27
- const body = await response.json();
28
- if (!response.ok || !body.id) {
29
- throw new Error(`GitHub sendMessage failed: ${body.message ?? `HTTP_${response.status}`}`);
30
- }
31
- return {
32
- id: String(body.id),
33
- providerMessageId: body.node_id,
34
- status: "sent",
35
- sentAt: new Date,
36
- metadata: {
37
- url: body.html_url ?? "",
38
- owner: target.owner,
39
- repo: target.repo,
40
- issueNumber: String(target.issueNumber)
41
- }
42
- };
43
- }
44
- async updateMessage(messageId, input) {
45
- const owner = input.metadata?.owner ?? this.defaultOwner;
46
- const repo = input.metadata?.repo ?? this.defaultRepo;
47
- if (!owner || !repo) {
48
- throw new Error("GitHub updateMessage requires owner and repo metadata.");
49
- }
50
- const response = await fetch(`${this.apiBaseUrl}/repos/${owner}/${repo}/issues/comments/${messageId}`, {
51
- method: "PATCH",
52
- headers: {
53
- authorization: `Bearer ${this.token}`,
54
- accept: "application/vnd.github+json",
55
- "content-type": "application/json"
56
- },
57
- body: JSON.stringify({ body: input.text })
58
- });
59
- const body = await response.json();
60
- if (!response.ok || !body.id) {
61
- throw new Error(`GitHub updateMessage failed: ${body.message ?? `HTTP_${response.status}`}`);
62
- }
63
- return {
64
- id: String(body.id),
65
- providerMessageId: body.node_id,
66
- status: "sent",
67
- sentAt: new Date,
68
- metadata: {
69
- url: body.html_url ?? "",
70
- owner,
71
- repo
72
- }
73
- };
74
- }
75
- resolveTarget(input) {
76
- const parsedRecipient = parseRecipient(input.recipientId);
77
- const owner = parsedRecipient?.owner ?? this.defaultOwner;
78
- const repo = parsedRecipient?.repo ?? this.defaultRepo;
79
- const issueNumber = parsedRecipient?.issueNumber ?? parseIssueNumber(input.threadId);
80
- if (!owner || !repo || issueNumber == null) {
81
- throw new Error("GitHub sendMessage requires owner/repo and issueNumber (use recipientId like owner/repo#123 or provide defaults + threadId).");
82
- }
83
- return {
84
- owner,
85
- repo,
86
- issueNumber
87
- };
88
- }
89
- }
90
- function parseRecipient(value) {
91
- if (!value)
92
- return null;
93
- const match = value.trim().match(/^([^/]+)\/([^#]+)#(\d+)$/);
94
- if (!match)
95
- return null;
96
- const owner = match[1];
97
- const repo = match[2];
98
- const issueNumber = Number(match[3]);
99
- if (!owner || !repo || !Number.isInteger(issueNumber)) {
100
- return null;
101
- }
102
- return { owner, repo, issueNumber };
103
- }
104
- function parseIssueNumber(value) {
105
- if (!value)
106
- return null;
107
- const numeric = Number(value);
108
- return Number.isInteger(numeric) ? numeric : null;
109
- }
110
- export {
111
- GithubMessagingProvider
112
- };
1
+ import{createRequire as a}from"node:module";var p=a(import.meta.url);class o{token;defaultOwner;defaultRepo;apiBaseUrl;constructor(t){this.token=t.token,this.defaultOwner=t.defaultOwner,this.defaultRepo=t.defaultRepo,this.apiBaseUrl=t.apiBaseUrl??"https://api.github.com"}async sendMessage(t){let e=this.resolveTarget(t),r=await fetch(`${this.apiBaseUrl}/repos/${e.owner}/${e.repo}/issues/${e.issueNumber}/comments`,{method:"POST",headers:{authorization:`Bearer ${this.token}`,accept:"application/vnd.github+json","content-type":"application/json"},body:JSON.stringify({body:t.text})}),s=await r.json();if(!r.ok||!s.id)throw Error(`GitHub sendMessage failed: ${s.message??`HTTP_${r.status}`}`);return{id:String(s.id),providerMessageId:s.node_id,status:"sent",sentAt:new Date,metadata:{url:s.html_url??"",owner:e.owner,repo:e.repo,issueNumber:String(e.issueNumber)}}}async updateMessage(t,e){let r=e.metadata?.owner??this.defaultOwner,s=e.metadata?.repo??this.defaultRepo;if(!r||!s)throw Error("GitHub updateMessage requires owner and repo metadata.");let n=await fetch(`${this.apiBaseUrl}/repos/${r}/${s}/issues/comments/${t}`,{method:"PATCH",headers:{authorization:`Bearer ${this.token}`,accept:"application/vnd.github+json","content-type":"application/json"},body:JSON.stringify({body:e.text})}),i=await n.json();if(!n.ok||!i.id)throw Error(`GitHub updateMessage failed: ${i.message??`HTTP_${n.status}`}`);return{id:String(i.id),providerMessageId:i.node_id,status:"sent",sentAt:new Date,metadata:{url:i.html_url??"",owner:r,repo:s}}}resolveTarget(t){let e=u(t.recipientId),r=e?.owner??this.defaultOwner,s=e?.repo??this.defaultRepo,n=e?.issueNumber??d(t.threadId);if(!r||!s||n==null)throw Error("GitHub sendMessage requires owner/repo and issueNumber (use recipientId like owner/repo#123 or provide defaults + threadId).");return{owner:r,repo:s,issueNumber:n}}}function u(t){if(!t)return null;let e=t.trim().match(/^([^/]+)\/([^#]+)#(\d+)$/);if(!e)return null;let r=e[1],s=e[2],n=Number(e[3]);if(!r||!s||!Number.isInteger(n))return null;return{owner:r,repo:s,issueNumber:n}}function d(t){if(!t)return null;let e=Number(t);return Number.isInteger(e)?e:null}export{o as GithubMessagingProvider};
@@ -1,82 +1 @@
1
- import { createRequire } from "node:module";
2
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
3
-
4
- // src/impls/messaging-slack.ts
5
- class SlackMessagingProvider {
6
- botToken;
7
- defaultChannelId;
8
- apiBaseUrl;
9
- constructor(options) {
10
- this.botToken = options.botToken;
11
- this.defaultChannelId = options.defaultChannelId;
12
- this.apiBaseUrl = options.apiBaseUrl ?? "https://slack.com/api";
13
- }
14
- async sendMessage(input) {
15
- const channel = input.channelId ?? input.recipientId ?? this.defaultChannelId;
16
- if (!channel) {
17
- throw new Error("Slack sendMessage requires channelId, recipientId, or defaultChannelId.");
18
- }
19
- const payload = {
20
- channel,
21
- text: input.text,
22
- mrkdwn: input.markdown ?? true,
23
- thread_ts: input.threadId
24
- };
25
- const response = await fetch(`${this.apiBaseUrl}/chat.postMessage`, {
26
- method: "POST",
27
- headers: {
28
- authorization: `Bearer ${this.botToken}`,
29
- "content-type": "application/json"
30
- },
31
- body: JSON.stringify(payload)
32
- });
33
- const body = await response.json();
34
- if (!response.ok || !body.ok || !body.ts) {
35
- throw new Error(`Slack sendMessage failed: ${body.error ?? `HTTP_${response.status}`}`);
36
- }
37
- return {
38
- id: `slack:${body.channel ?? channel}:${body.ts}`,
39
- providerMessageId: body.ts,
40
- status: "sent",
41
- sentAt: new Date,
42
- metadata: {
43
- channelId: body.channel ?? channel
44
- }
45
- };
46
- }
47
- async updateMessage(messageId, input) {
48
- const channel = input.channelId ?? this.defaultChannelId;
49
- if (!channel) {
50
- throw new Error("Slack updateMessage requires channelId or defaultChannelId.");
51
- }
52
- const response = await fetch(`${this.apiBaseUrl}/chat.update`, {
53
- method: "POST",
54
- headers: {
55
- authorization: `Bearer ${this.botToken}`,
56
- "content-type": "application/json"
57
- },
58
- body: JSON.stringify({
59
- channel,
60
- ts: messageId,
61
- text: input.text,
62
- mrkdwn: input.markdown ?? true
63
- })
64
- });
65
- const body = await response.json();
66
- if (!response.ok || !body.ok || !body.ts) {
67
- throw new Error(`Slack updateMessage failed: ${body.error ?? `HTTP_${response.status}`}`);
68
- }
69
- return {
70
- id: `slack:${body.channel ?? channel}:${body.ts}`,
71
- providerMessageId: body.ts,
72
- status: "sent",
73
- sentAt: new Date,
74
- metadata: {
75
- channelId: body.channel ?? channel
76
- }
77
- };
78
- }
79
- }
80
- export {
81
- SlackMessagingProvider
82
- };
1
+ import{createRequire as r}from"node:module";var d=r(import.meta.url);class o{botToken;defaultChannelId;apiBaseUrl;constructor(s){this.botToken=s.botToken,this.defaultChannelId=s.defaultChannelId,this.apiBaseUrl=s.apiBaseUrl??"https://slack.com/api"}async sendMessage(s){let a=s.channelId??s.recipientId??this.defaultChannelId;if(!a)throw Error("Slack sendMessage requires channelId, recipientId, or defaultChannelId.");let n={channel:a,text:s.text,mrkdwn:s.markdown??!0,thread_ts:s.threadId},t=await fetch(`${this.apiBaseUrl}/chat.postMessage`,{method:"POST",headers:{authorization:`Bearer ${this.botToken}`,"content-type":"application/json"},body:JSON.stringify(n)}),e=await t.json();if(!t.ok||!e.ok||!e.ts)throw Error(`Slack sendMessage failed: ${e.error??`HTTP_${t.status}`}`);return{id:`slack:${e.channel??a}:${e.ts}`,providerMessageId:e.ts,status:"sent",sentAt:new Date,metadata:{channelId:e.channel??a}}}async updateMessage(s,a){let n=a.channelId??this.defaultChannelId;if(!n)throw Error("Slack updateMessage requires channelId or defaultChannelId.");let t=await fetch(`${this.apiBaseUrl}/chat.update`,{method:"POST",headers:{authorization:`Bearer ${this.botToken}`,"content-type":"application/json"},body:JSON.stringify({channel:n,ts:s,text:a.text,mrkdwn:a.markdown??!0})}),e=await t.json();if(!t.ok||!e.ok||!e.ts)throw Error(`Slack updateMessage failed: ${e.error??`HTTP_${t.status}`}`);return{id:`slack:${e.channel??n}:${e.ts}`,providerMessageId:e.ts,status:"sent",sentAt:new Date,metadata:{channelId:e.channel??n}}}}export{o as SlackMessagingProvider};
@@ -1,49 +1 @@
1
- import { createRequire } from "node:module";
2
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
3
-
4
- // src/impls/messaging-telegram.ts
5
- class TelegramMessagingProvider {
6
- botToken;
7
- defaultChatId;
8
- apiBaseUrl;
9
- constructor(options) {
10
- this.botToken = options.botToken;
11
- this.defaultChatId = options.defaultChatId;
12
- this.apiBaseUrl = options.apiBaseUrl ?? "https://api.telegram.org";
13
- }
14
- async sendMessage(input) {
15
- const chatId = input.channelId ?? input.recipientId ?? this.defaultChatId ?? undefined;
16
- if (!chatId) {
17
- throw new Error("Telegram sendMessage requires channelId, recipientId, or defaultChatId.");
18
- }
19
- const messageThreadId = input.threadId && input.threadId !== chatId ? Number.parseInt(input.threadId, 10) : undefined;
20
- const response = await fetch(`${this.apiBaseUrl}/bot${this.botToken}/sendMessage`, {
21
- method: "POST",
22
- headers: {
23
- "content-type": "application/json"
24
- },
25
- body: JSON.stringify({
26
- chat_id: chatId,
27
- text: input.text,
28
- message_thread_id: Number.isFinite(messageThreadId) ? messageThreadId : undefined
29
- })
30
- });
31
- const body = await response.json();
32
- const providerMessageId = body.result?.message_id;
33
- if (!response.ok || !body.ok || providerMessageId == null) {
34
- throw new Error(`Telegram sendMessage failed: ${body.description ?? `HTTP_${response.status}`}`);
35
- }
36
- return {
37
- id: `telegram:${chatId}:${providerMessageId}`,
38
- providerMessageId: String(providerMessageId),
39
- status: "sent",
40
- sentAt: new Date,
41
- metadata: {
42
- chatId: String(body.result?.chat?.id ?? chatId)
43
- }
44
- };
45
- }
46
- }
47
- export {
48
- TelegramMessagingProvider
49
- };
1
+ import{createRequire as i}from"node:module";var g=i(import.meta.url);class d{botToken;defaultChatId;apiBaseUrl;constructor(e){this.botToken=e.botToken,this.defaultChatId=e.defaultChatId,this.apiBaseUrl=e.apiBaseUrl??"https://api.telegram.org"}async sendMessage(e){let s=e.channelId??e.recipientId??this.defaultChatId??void 0;if(!s)throw Error("Telegram sendMessage requires channelId, recipientId, or defaultChatId.");let n=e.threadId&&e.threadId!==s?Number.parseInt(e.threadId,10):void 0,a=await fetch(`${this.apiBaseUrl}/bot${this.botToken}/sendMessage`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({chat_id:s,text:e.text,message_thread_id:Number.isFinite(n)?n:void 0})}),t=await a.json(),r=t.result?.message_id;if(!a.ok||!t.ok||r==null)throw Error(`Telegram sendMessage failed: ${t.description??`HTTP_${a.status}`}`);return{id:`telegram:${s}:${r}`,providerMessageId:String(r),status:"sent",sentAt:new Date,metadata:{chatId:String(t.result?.chat?.id??s)}}}}export{d as TelegramMessagingProvider};
@@ -1,54 +1 @@
1
- import { createRequire } from "node:module";
2
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
3
-
4
- // src/impls/messaging-whatsapp-meta.ts
5
- class MetaWhatsappMessagingProvider {
6
- accessToken;
7
- phoneNumberId;
8
- apiVersion;
9
- constructor(options) {
10
- this.accessToken = options.accessToken;
11
- this.phoneNumberId = options.phoneNumberId;
12
- this.apiVersion = options.apiVersion ?? "v22.0";
13
- }
14
- async sendMessage(input) {
15
- const to = input.recipientId;
16
- if (!to) {
17
- throw new Error("Meta WhatsApp sendMessage requires recipientId.");
18
- }
19
- const response = await fetch(`https://graph.facebook.com/${this.apiVersion}/${this.phoneNumberId}/messages`, {
20
- method: "POST",
21
- headers: {
22
- authorization: `Bearer ${this.accessToken}`,
23
- "content-type": "application/json"
24
- },
25
- body: JSON.stringify({
26
- messaging_product: "whatsapp",
27
- to,
28
- type: "text",
29
- text: {
30
- body: input.text,
31
- preview_url: false
32
- }
33
- })
34
- });
35
- const body = await response.json();
36
- const messageId = body.messages?.[0]?.id;
37
- if (!response.ok || !messageId) {
38
- const errorCode = body.error?.code != null ? String(body.error.code) : "";
39
- throw new Error(`Meta WhatsApp sendMessage failed: ${body.error?.message ?? `HTTP_${response.status}`}${errorCode ? ` (${errorCode})` : ""}`);
40
- }
41
- return {
42
- id: messageId,
43
- providerMessageId: messageId,
44
- status: "sent",
45
- sentAt: new Date,
46
- metadata: {
47
- phoneNumberId: this.phoneNumberId
48
- }
49
- };
50
- }
51
- }
52
- export {
53
- MetaWhatsappMessagingProvider
54
- };
1
+ import{createRequire as i}from"node:module";var d=i(import.meta.url);class o{accessToken;phoneNumberId;apiVersion;constructor(e){this.accessToken=e.accessToken,this.phoneNumberId=e.phoneNumberId,this.apiVersion=e.apiVersion??"v22.0"}async sendMessage(e){let a=e.recipientId;if(!a)throw Error("Meta WhatsApp sendMessage requires recipientId.");let r=await fetch(`https://graph.facebook.com/${this.apiVersion}/${this.phoneNumberId}/messages`,{method:"POST",headers:{authorization:`Bearer ${this.accessToken}`,"content-type":"application/json"},body:JSON.stringify({messaging_product:"whatsapp",to:a,type:"text",text:{body:e.text,preview_url:!1}})}),s=await r.json(),t=s.messages?.[0]?.id;if(!r.ok||!t){let n=s.error?.code!=null?String(s.error.code):"";throw Error(`Meta WhatsApp sendMessage failed: ${s.error?.message??`HTTP_${r.status}`}${n?` (${n})`:""}`)}return{id:t,providerMessageId:t,status:"sent",sentAt:new Date,metadata:{phoneNumberId:this.phoneNumberId}}}}export{o as MetaWhatsappMessagingProvider};
@@ -1,84 +1 @@
1
- import { createRequire } from "node:module";
2
- var __require = /* @__PURE__ */ createRequire(import.meta.url);
3
-
4
- // src/impls/messaging-whatsapp-twilio.ts
5
- import { Buffer } from "node:buffer";
6
-
7
- class TwilioWhatsappMessagingProvider {
8
- accountSid;
9
- authToken;
10
- fromNumber;
11
- constructor(options) {
12
- this.accountSid = options.accountSid;
13
- this.authToken = options.authToken;
14
- this.fromNumber = options.fromNumber;
15
- }
16
- async sendMessage(input) {
17
- const to = normalizeWhatsappAddress(input.recipientId);
18
- const from = normalizeWhatsappAddress(input.channelId ?? this.fromNumber);
19
- if (!to) {
20
- throw new Error("Twilio WhatsApp sendMessage requires recipientId.");
21
- }
22
- if (!from) {
23
- throw new Error("Twilio WhatsApp sendMessage requires channelId or configured fromNumber.");
24
- }
25
- const params = new URLSearchParams;
26
- params.set("To", to);
27
- params.set("From", from);
28
- params.set("Body", input.text);
29
- const auth = Buffer.from(`${this.accountSid}:${this.authToken}`).toString("base64");
30
- const response = await fetch(`https://api.twilio.com/2010-04-01/Accounts/${this.accountSid}/Messages.json`, {
31
- method: "POST",
32
- headers: {
33
- authorization: `Basic ${auth}`,
34
- "content-type": "application/x-www-form-urlencoded"
35
- },
36
- body: params.toString()
37
- });
38
- const body = await response.json();
39
- if (!response.ok || !body.sid) {
40
- throw new Error(`Twilio WhatsApp sendMessage failed: ${body.error_message ?? `HTTP_${response.status}`}`);
41
- }
42
- return {
43
- id: body.sid,
44
- providerMessageId: body.sid,
45
- status: mapTwilioStatus(body.status),
46
- sentAt: new Date,
47
- errorCode: body.error_code != null ? String(body.error_code) : undefined,
48
- errorMessage: body.error_message ?? undefined,
49
- metadata: {
50
- from,
51
- to
52
- }
53
- };
54
- }
55
- }
56
- function normalizeWhatsappAddress(value) {
57
- if (!value)
58
- return null;
59
- if (value.startsWith("whatsapp:"))
60
- return value;
61
- return `whatsapp:${value}`;
62
- }
63
- function mapTwilioStatus(status) {
64
- switch (status) {
65
- case "queued":
66
- case "accepted":
67
- case "scheduled":
68
- return "queued";
69
- case "sending":
70
- return "sending";
71
- case "delivered":
72
- return "delivered";
73
- case "failed":
74
- case "undelivered":
75
- case "canceled":
76
- return "failed";
77
- case "sent":
78
- default:
79
- return "sent";
80
- }
81
- }
82
- export {
83
- TwilioWhatsappMessagingProvider
84
- };
1
+ import{createRequire as d}from"node:module";var l=d(import.meta.url);import{Buffer as c}from"node:buffer";class u{accountSid;authToken;fromNumber;constructor(e){this.accountSid=e.accountSid,this.authToken=e.authToken,this.fromNumber=e.fromNumber}async sendMessage(e){let t=a(e.recipientId),n=a(e.channelId??this.fromNumber);if(!t)throw Error("Twilio WhatsApp sendMessage requires recipientId.");if(!n)throw Error("Twilio WhatsApp sendMessage requires channelId or configured fromNumber.");let r=new URLSearchParams;r.set("To",t),r.set("From",n),r.set("Body",e.text);let o=c.from(`${this.accountSid}:${this.authToken}`).toString("base64"),i=await fetch(`https://api.twilio.com/2010-04-01/Accounts/${this.accountSid}/Messages.json`,{method:"POST",headers:{authorization:`Basic ${o}`,"content-type":"application/x-www-form-urlencoded"},body:r.toString()}),s=await i.json();if(!i.ok||!s.sid)throw Error(`Twilio WhatsApp sendMessage failed: ${s.error_message??`HTTP_${i.status}`}`);return{id:s.sid,providerMessageId:s.sid,status:g(s.status),sentAt:new Date,errorCode:s.error_code!=null?String(s.error_code):void 0,errorMessage:s.error_message??void 0,metadata:{from:n,to:t}}}}function a(e){if(!e)return null;if(e.startsWith("whatsapp:"))return e;return`whatsapp:${e}`}function g(e){switch(e){case"queued":case"accepted":case"scheduled":return"queued";case"sending":return"sending";case"delivered":return"delivered";case"failed":case"undelivered":case"canceled":return"failed";case"sent":default:return"sent"}}export{u as TwilioWhatsappMessagingProvider};