@contractspec/integration.providers-impls 2.10.0 → 3.1.1

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 (138) hide show
  1. package/README.md +66 -10
  2. package/dist/impls/async-event-queue.d.ts +8 -0
  3. package/dist/impls/async-event-queue.js +49 -0
  4. package/dist/impls/composio-fallback-resolver.d.ts +34 -0
  5. package/dist/impls/composio-fallback-resolver.js +580 -0
  6. package/dist/impls/composio-mcp.d.ts +22 -0
  7. package/dist/impls/composio-mcp.js +164 -0
  8. package/dist/impls/composio-proxies.d.ts +60 -0
  9. package/dist/impls/composio-proxies.js +311 -0
  10. package/dist/impls/composio-sdk.d.ts +25 -0
  11. package/dist/impls/composio-sdk.js +78 -0
  12. package/dist/impls/composio-types.d.ts +43 -0
  13. package/dist/impls/composio-types.js +54 -0
  14. package/dist/impls/elevenlabs-voice.js +2 -0
  15. package/dist/impls/fal-voice.js +2 -0
  16. package/dist/impls/fathom-meeting-recorder.js +2 -0
  17. package/dist/impls/fathom-meeting-recorder.mapper.js +2 -0
  18. package/dist/impls/fathom-meeting-recorder.utils.js +2 -0
  19. package/dist/impls/fathom-meeting-recorder.webhooks.js +2 -0
  20. package/dist/impls/fireflies-meeting-recorder.js +2 -0
  21. package/dist/impls/fireflies-meeting-recorder.queries.js +2 -0
  22. package/dist/impls/fireflies-meeting-recorder.utils.js +2 -0
  23. package/dist/impls/gcs-storage.js +2 -0
  24. package/dist/impls/gmail-inbound.js +2 -0
  25. package/dist/impls/gmail-outbound.js +2 -0
  26. package/dist/impls/google-calendar.js +2 -0
  27. package/dist/impls/gradium-voice.js +2 -0
  28. package/dist/impls/granola-meeting-recorder.js +2 -0
  29. package/dist/impls/granola-meeting-recorder.mcp.js +2 -0
  30. package/dist/impls/health/base-health-provider.d.ts +64 -13
  31. package/dist/impls/health/base-health-provider.js +508 -156
  32. package/dist/impls/health/hybrid-health-providers.d.ts +34 -0
  33. package/dist/impls/health/hybrid-health-providers.js +1090 -0
  34. package/dist/impls/health/official-health-providers.d.ts +78 -0
  35. package/dist/impls/health/official-health-providers.js +970 -0
  36. package/dist/impls/health/provider-normalizers.d.ts +28 -0
  37. package/dist/impls/health/provider-normalizers.js +289 -0
  38. package/dist/impls/health/providers.d.ts +2 -39
  39. package/dist/impls/health/providers.js +897 -184
  40. package/dist/impls/health-provider-factory.js +1011 -196
  41. package/dist/impls/index.d.ts +11 -0
  42. package/dist/impls/index.js +2588 -259
  43. package/dist/impls/jira.js +2 -0
  44. package/dist/impls/linear.js +2 -0
  45. package/dist/impls/messaging-github.d.ts +17 -0
  46. package/dist/impls/messaging-github.js +112 -0
  47. package/dist/impls/messaging-slack.d.ts +14 -0
  48. package/dist/impls/messaging-slack.js +82 -0
  49. package/dist/impls/messaging-whatsapp-meta.d.ts +13 -0
  50. package/dist/impls/messaging-whatsapp-meta.js +54 -0
  51. package/dist/impls/messaging-whatsapp-twilio.d.ts +13 -0
  52. package/dist/impls/messaging-whatsapp-twilio.js +84 -0
  53. package/dist/impls/mistral-conversational.d.ts +23 -0
  54. package/dist/impls/mistral-conversational.js +478 -0
  55. package/dist/impls/mistral-conversational.session.d.ts +32 -0
  56. package/dist/impls/mistral-conversational.session.js +208 -0
  57. package/dist/impls/mistral-embedding.js +2 -0
  58. package/dist/impls/mistral-llm.js +2 -0
  59. package/dist/impls/mistral-stt.d.ts +17 -0
  60. package/dist/impls/mistral-stt.js +169 -0
  61. package/dist/impls/notion.js +2 -0
  62. package/dist/impls/posthog-reader.js +2 -0
  63. package/dist/impls/posthog-utils.js +2 -0
  64. package/dist/impls/posthog.js +2 -0
  65. package/dist/impls/postmark-email.js +2 -0
  66. package/dist/impls/powens-client.js +2 -0
  67. package/dist/impls/powens-openbanking.js +2 -0
  68. package/dist/impls/provider-factory.d.ts +29 -1
  69. package/dist/impls/provider-factory.js +1985 -249
  70. package/dist/impls/qdrant-vector.js +2 -0
  71. package/dist/impls/stripe-payments.js +3 -1
  72. package/dist/impls/supabase-psql.js +2 -0
  73. package/dist/impls/supabase-vector.js +2 -0
  74. package/dist/impls/tldv-meeting-recorder.js +2 -0
  75. package/dist/impls/twilio-sms.js +2 -0
  76. package/dist/index.d.ts +1 -0
  77. package/dist/index.js +2615 -283
  78. package/dist/messaging.d.ts +1 -0
  79. package/dist/messaging.js +3 -0
  80. package/dist/node/impls/async-event-queue.js +49 -0
  81. package/dist/node/impls/composio-fallback-resolver.js +580 -0
  82. package/dist/node/impls/composio-mcp.js +164 -0
  83. package/dist/node/impls/composio-proxies.js +311 -0
  84. package/dist/node/impls/composio-sdk.js +78 -0
  85. package/dist/node/impls/composio-types.js +54 -0
  86. package/dist/node/impls/elevenlabs-voice.js +3 -0
  87. package/dist/node/impls/fal-voice.js +3 -0
  88. package/dist/node/impls/fathom-meeting-recorder.js +3 -0
  89. package/dist/node/impls/fathom-meeting-recorder.mapper.js +3 -0
  90. package/dist/node/impls/fathom-meeting-recorder.utils.js +3 -0
  91. package/dist/node/impls/fathom-meeting-recorder.webhooks.js +3 -0
  92. package/dist/node/impls/fireflies-meeting-recorder.js +3 -0
  93. package/dist/node/impls/fireflies-meeting-recorder.queries.js +3 -0
  94. package/dist/node/impls/fireflies-meeting-recorder.utils.js +3 -0
  95. package/dist/node/impls/gcs-storage.js +3 -0
  96. package/dist/node/impls/gmail-inbound.js +3 -0
  97. package/dist/node/impls/gmail-outbound.js +3 -0
  98. package/dist/node/impls/google-calendar.js +3 -0
  99. package/dist/node/impls/gradium-voice.js +3 -0
  100. package/dist/node/impls/granola-meeting-recorder.js +3 -0
  101. package/dist/node/impls/granola-meeting-recorder.mcp.js +3 -0
  102. package/dist/node/impls/health/base-health-provider.js +509 -156
  103. package/dist/node/impls/health/hybrid-health-providers.js +1090 -0
  104. package/dist/node/impls/health/official-health-providers.js +970 -0
  105. package/dist/node/impls/health/provider-normalizers.js +289 -0
  106. package/dist/node/impls/health/providers.js +898 -184
  107. package/dist/node/impls/health-provider-factory.js +1012 -196
  108. package/dist/node/impls/index.js +2589 -259
  109. package/dist/node/impls/jira.js +3 -0
  110. package/dist/node/impls/linear.js +3 -0
  111. package/dist/node/impls/messaging-github.js +112 -0
  112. package/dist/node/impls/messaging-slack.js +82 -0
  113. package/dist/node/impls/messaging-whatsapp-meta.js +54 -0
  114. package/dist/node/impls/messaging-whatsapp-twilio.js +84 -0
  115. package/dist/node/impls/mistral-conversational.js +478 -0
  116. package/dist/node/impls/mistral-conversational.session.js +208 -0
  117. package/dist/node/impls/mistral-embedding.js +3 -0
  118. package/dist/node/impls/mistral-llm.js +3 -0
  119. package/dist/node/impls/mistral-stt.js +169 -0
  120. package/dist/node/impls/notion.js +3 -0
  121. package/dist/node/impls/posthog-reader.js +3 -0
  122. package/dist/node/impls/posthog-utils.js +3 -0
  123. package/dist/node/impls/posthog.js +3 -0
  124. package/dist/node/impls/postmark-email.js +3 -0
  125. package/dist/node/impls/powens-client.js +3 -0
  126. package/dist/node/impls/powens-openbanking.js +3 -0
  127. package/dist/node/impls/provider-factory.js +1986 -249
  128. package/dist/node/impls/qdrant-vector.js +3 -0
  129. package/dist/node/impls/stripe-payments.js +4 -1
  130. package/dist/node/impls/supabase-psql.js +3 -0
  131. package/dist/node/impls/supabase-vector.js +3 -0
  132. package/dist/node/impls/tldv-meeting-recorder.js +3 -0
  133. package/dist/node/impls/twilio-sms.js +3 -0
  134. package/dist/node/index.js +2616 -283
  135. package/dist/node/messaging.js +2 -0
  136. package/dist/node/secrets/provider.js +3 -0
  137. package/dist/secrets/provider.js +2 -0
  138. package/package.json +219 -14
@@ -1,4 +1,6 @@
1
1
  // @bun
2
+ var __require = import.meta.require;
3
+
2
4
  // src/impls/mistral-embedding.ts
3
5
  import { Mistral } from "@mistralai/mistralai";
4
6
 
@@ -1,4 +1,6 @@
1
1
  // @bun
2
+ var __require = import.meta.require;
3
+
2
4
  // src/impls/mistral-llm.ts
3
5
  import { Mistral } from "@mistralai/mistralai";
4
6
 
@@ -0,0 +1,17 @@
1
+ import type { STTProvider, STTTranscriptionInput, STTTranscriptionResult } from '../voice';
2
+ export interface MistralSttProviderOptions {
3
+ apiKey: string;
4
+ defaultModel?: string;
5
+ defaultLanguage?: string;
6
+ serverURL?: string;
7
+ fetchImpl?: typeof fetch;
8
+ }
9
+ export declare class MistralSttProvider implements STTProvider {
10
+ private readonly apiKey;
11
+ private readonly defaultModel;
12
+ private readonly defaultLanguage?;
13
+ private readonly baseUrl;
14
+ private readonly fetchImpl;
15
+ constructor(options: MistralSttProviderOptions);
16
+ transcribe(input: STTTranscriptionInput): Promise<STTTranscriptionResult>;
17
+ }
@@ -0,0 +1,169 @@
1
+ // @bun
2
+ var __require = import.meta.require;
3
+
4
+ // src/impls/mistral-stt.ts
5
+ var DEFAULT_BASE_URL = "https://api.mistral.ai/v1";
6
+ var DEFAULT_MODEL = "voxtral-mini-latest";
7
+ var AUDIO_MIME_BY_FORMAT = {
8
+ mp3: "audio/mpeg",
9
+ wav: "audio/wav",
10
+ ogg: "audio/ogg",
11
+ pcm: "audio/pcm",
12
+ opus: "audio/opus"
13
+ };
14
+
15
+ class MistralSttProvider {
16
+ apiKey;
17
+ defaultModel;
18
+ defaultLanguage;
19
+ baseUrl;
20
+ fetchImpl;
21
+ constructor(options) {
22
+ if (!options.apiKey) {
23
+ throw new Error("MistralSttProvider requires an apiKey");
24
+ }
25
+ this.apiKey = options.apiKey;
26
+ this.defaultModel = options.defaultModel ?? DEFAULT_MODEL;
27
+ this.defaultLanguage = options.defaultLanguage;
28
+ this.baseUrl = normalizeBaseUrl(options.serverURL ?? DEFAULT_BASE_URL);
29
+ this.fetchImpl = options.fetchImpl ?? fetch;
30
+ }
31
+ async transcribe(input) {
32
+ const formData = new FormData;
33
+ const model = input.model ?? this.defaultModel;
34
+ const mimeType = AUDIO_MIME_BY_FORMAT[input.audio.format] ?? "audio/wav";
35
+ const fileName = `audio.${input.audio.format}`;
36
+ const audioBytes = new Uint8Array(input.audio.data);
37
+ const blob = new Blob([audioBytes], { type: mimeType });
38
+ formData.append("file", blob, fileName);
39
+ formData.append("model", model);
40
+ formData.append("response_format", "verbose_json");
41
+ const language = input.language ?? this.defaultLanguage;
42
+ if (language) {
43
+ formData.append("language", language);
44
+ }
45
+ const response = await this.fetchImpl(`${this.baseUrl}/audio/transcriptions`, {
46
+ method: "POST",
47
+ headers: {
48
+ Authorization: `Bearer ${this.apiKey}`
49
+ },
50
+ body: formData
51
+ });
52
+ if (!response.ok) {
53
+ const body = await response.text();
54
+ throw new Error(`Mistral transcription request failed (${response.status}): ${body}`);
55
+ }
56
+ const payload = await response.json();
57
+ return toTranscriptionResult(payload, input);
58
+ }
59
+ }
60
+ function toTranscriptionResult(payload, input) {
61
+ const record = asRecord(payload);
62
+ const text = readString(record, "text") ?? "";
63
+ const language = readString(record, "language") ?? input.language ?? "unknown";
64
+ const segments = parseSegments(record);
65
+ if (segments.length === 0 && text.length > 0) {
66
+ segments.push({
67
+ text,
68
+ startMs: 0,
69
+ endMs: input.audio.durationMs ?? 0
70
+ });
71
+ }
72
+ const durationMs = input.audio.durationMs ?? segments.reduce((max, segment) => Math.max(max, segment.endMs), 0);
73
+ const topLevelWords = parseWordTimings(record.words);
74
+ const flattenedWords = segments.flatMap((segment) => segment.wordTimings ?? []);
75
+ const wordTimings = topLevelWords.length > 0 ? topLevelWords : flattenedWords.length > 0 ? flattenedWords : undefined;
76
+ const speakers = dedupeSpeakers(segments);
77
+ return {
78
+ text,
79
+ segments,
80
+ language,
81
+ durationMs,
82
+ speakers: speakers.length > 0 ? speakers : undefined,
83
+ wordTimings
84
+ };
85
+ }
86
+ function parseSegments(record) {
87
+ if (!Array.isArray(record.segments)) {
88
+ return [];
89
+ }
90
+ const parsed = [];
91
+ for (const entry of record.segments) {
92
+ const segmentRecord = asRecord(entry);
93
+ const text = readString(segmentRecord, "text");
94
+ if (!text) {
95
+ continue;
96
+ }
97
+ const startSeconds = readNumber(segmentRecord, "start") ?? 0;
98
+ const endSeconds = readNumber(segmentRecord, "end") ?? startSeconds;
99
+ parsed.push({
100
+ text,
101
+ startMs: secondsToMs(startSeconds),
102
+ endMs: secondsToMs(endSeconds),
103
+ speakerId: readString(segmentRecord, "speaker") ?? undefined,
104
+ confidence: readNumber(segmentRecord, "confidence"),
105
+ wordTimings: parseWordTimings(segmentRecord.words)
106
+ });
107
+ }
108
+ return parsed;
109
+ }
110
+ function parseWordTimings(value) {
111
+ if (!Array.isArray(value)) {
112
+ return [];
113
+ }
114
+ const words = [];
115
+ for (const entry of value) {
116
+ const wordRecord = asRecord(entry);
117
+ const word = readString(wordRecord, "word");
118
+ const startSeconds = readNumber(wordRecord, "start");
119
+ const endSeconds = readNumber(wordRecord, "end");
120
+ if (!word || startSeconds == null || endSeconds == null) {
121
+ continue;
122
+ }
123
+ words.push({
124
+ word,
125
+ startMs: secondsToMs(startSeconds),
126
+ endMs: secondsToMs(endSeconds),
127
+ confidence: readNumber(wordRecord, "confidence")
128
+ });
129
+ }
130
+ return words;
131
+ }
132
+ function dedupeSpeakers(segments) {
133
+ const seen = new Set;
134
+ const speakers = [];
135
+ for (const segment of segments) {
136
+ if (!segment.speakerId || seen.has(segment.speakerId)) {
137
+ continue;
138
+ }
139
+ seen.add(segment.speakerId);
140
+ speakers.push({
141
+ id: segment.speakerId,
142
+ name: segment.speakerName
143
+ });
144
+ }
145
+ return speakers;
146
+ }
147
+ function normalizeBaseUrl(url) {
148
+ return url.endsWith("/") ? url.slice(0, -1) : url;
149
+ }
150
+ function asRecord(value) {
151
+ if (value && typeof value === "object") {
152
+ return value;
153
+ }
154
+ return {};
155
+ }
156
+ function readString(record, key) {
157
+ const value = record[key];
158
+ return typeof value === "string" ? value : undefined;
159
+ }
160
+ function readNumber(record, key) {
161
+ const value = record[key];
162
+ return typeof value === "number" ? value : undefined;
163
+ }
164
+ function secondsToMs(value) {
165
+ return Math.round(value * 1000);
166
+ }
167
+ export {
168
+ MistralSttProvider
169
+ };
@@ -1,4 +1,6 @@
1
1
  // @bun
2
+ var __require = import.meta.require;
3
+
2
4
  // src/impls/notion.ts
3
5
  import { Client } from "@notionhq/client";
4
6
 
@@ -1,4 +1,6 @@
1
1
  // @bun
2
+ var __require = import.meta.require;
3
+
2
4
  // src/impls/posthog-reader.ts
3
5
  class PosthogAnalyticsReader {
4
6
  projectId;
@@ -1,4 +1,6 @@
1
1
  // @bun
2
+ var __require = import.meta.require;
3
+
2
4
  // src/impls/posthog-utils.ts
3
5
  function normalizeHost(host) {
4
6
  return host.replace(/\/$/, "");
@@ -1,4 +1,6 @@
1
1
  // @bun
2
+ var __require = import.meta.require;
3
+
2
4
  // src/impls/posthog-reader.ts
3
5
  class PosthogAnalyticsReader {
4
6
  projectId;
@@ -1,4 +1,6 @@
1
1
  // @bun
2
+ var __require = import.meta.require;
3
+
2
4
  // src/impls/postmark-email.ts
3
5
  import { ServerClient } from "postmark";
4
6
 
@@ -1,4 +1,6 @@
1
1
  // @bun
2
+ var __require = import.meta.require;
3
+
2
4
  // src/impls/powens-client.ts
3
5
  import { URL } from "url";
4
6
  var POWENS_BASE_URL = {
@@ -1,4 +1,6 @@
1
1
  // @bun
2
+ var __require = import.meta.require;
3
+
2
4
  // src/impls/powens-client.ts
3
5
  import { URL } from "url";
4
6
  var POWENS_BASE_URL = {
@@ -1,27 +1,55 @@
1
1
  import type { IntegrationContext } from '@contractspec/integration.runtime/runtime';
2
+ import type { IntegrationTransportType } from '@contractspec/lib.contracts-integrations/integrations/transport';
3
+ import type { IntegrationAuthType } from '@contractspec/lib.contracts-integrations/integrations/auth';
2
4
  import type { PaymentsProvider } from '../payments';
3
5
  import type { EmailOutboundProvider } from '../email';
4
6
  import type { SmsProvider } from '../sms';
7
+ import type { MessagingProvider } from '../messaging';
5
8
  import type { VectorStoreProvider } from '../vector-store';
6
9
  import type { AnalyticsProvider } from '../analytics';
7
10
  import type { DatabaseProvider } from '../database';
8
11
  import type { ObjectStorageProvider } from '../storage';
9
- import type { TTSProvider } from '../voice';
12
+ import type { ConversationalProvider, STTProvider, TTSProvider } from '../voice';
10
13
  import type { LLMProvider } from '../llm';
11
14
  import type { EmbeddingProvider } from '../embedding';
12
15
  import type { OpenBankingProvider } from '../openbanking';
13
16
  import type { ProjectManagementProvider } from '../project-management';
14
17
  import type { MeetingRecorderProvider } from '../meeting-recorder';
15
18
  import type { HealthProvider } from '../health';
19
+ import type { ComposioFallbackResolver } from './composio-fallback-resolver';
20
+ /**
21
+ * Resolved transport, auth, and version context for a provider invocation.
22
+ */
23
+ export interface ResolvedProviderContext {
24
+ transport: IntegrationTransportType;
25
+ authMethod: IntegrationAuthType | undefined;
26
+ apiVersion: string | undefined;
27
+ /** Pre-built auth headers from the resolved auth method and secrets. */
28
+ authHeaders: Record<string, string>;
29
+ secrets: Record<string, unknown>;
30
+ }
16
31
  export declare class IntegrationProviderFactory {
32
+ private readonly composioFallback?;
33
+ constructor(options?: {
34
+ composioFallback?: ComposioFallbackResolver;
35
+ });
36
+ /**
37
+ * Resolve transport, auth method, API version, and build auth headers
38
+ * for a given integration context. Consumers can call this directly
39
+ * for custom wiring or it is used internally by the create* methods.
40
+ */
41
+ resolveProviderContext(context: IntegrationContext): Promise<ResolvedProviderContext>;
17
42
  createPaymentsProvider(context: IntegrationContext): Promise<PaymentsProvider>;
18
43
  createEmailOutboundProvider(context: IntegrationContext): Promise<EmailOutboundProvider>;
19
44
  createSmsProvider(context: IntegrationContext): Promise<SmsProvider>;
45
+ createMessagingProvider(context: IntegrationContext): Promise<MessagingProvider>;
20
46
  createVectorStoreProvider(context: IntegrationContext): Promise<VectorStoreProvider>;
21
47
  createAnalyticsProvider(context: IntegrationContext): Promise<AnalyticsProvider>;
22
48
  createDatabaseProvider(context: IntegrationContext): Promise<DatabaseProvider>;
23
49
  createObjectStorageProvider(context: IntegrationContext): Promise<ObjectStorageProvider>;
24
50
  createVoiceProvider(context: IntegrationContext): Promise<TTSProvider>;
51
+ createSttProvider(context: IntegrationContext): Promise<STTProvider>;
52
+ createConversationalProvider(context: IntegrationContext): Promise<ConversationalProvider>;
25
53
  createProjectManagementProvider(context: IntegrationContext): Promise<ProjectManagementProvider>;
26
54
  createMeetingRecorderProvider(context: IntegrationContext): Promise<MeetingRecorderProvider>;
27
55
  createLlmProvider(context: IntegrationContext): Promise<LLMProvider>;