@contractspec/integration.providers-impls 3.7.5 → 3.7.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +80 -241
- package/dist/impls/composio-fallback-resolver.d.ts +4 -4
- package/dist/impls/composio-fallback-resolver.js +73 -73
- package/dist/impls/composio-mcp.d.ts +1 -1
- package/dist/impls/composio-proxies.d.ts +5 -5
- package/dist/impls/composio-sdk.d.ts +1 -1
- package/dist/impls/elevenlabs-voice.d.ts +1 -1
- package/dist/impls/fal-voice.d.ts +1 -1
- package/dist/impls/gcs-storage.d.ts +1 -1
- package/dist/impls/gmail-inbound.d.ts +1 -1
- package/dist/impls/gradium-voice.d.ts +2 -2
- package/dist/impls/health/base-health-provider.d.ts +1 -1
- package/dist/impls/health/official-health-providers.d.ts +1 -1
- package/dist/impls/health/providers.d.ts +1 -1
- package/dist/impls/health-provider-factory.d.ts +1 -1
- package/dist/impls/index.d.ts +30 -30
- package/dist/impls/index.js +2150 -2150
- package/dist/impls/mistral-conversational.d.ts +1 -1
- package/dist/impls/mistral-conversational.js +159 -159
- package/dist/impls/posthog-reader.d.ts +1 -1
- package/dist/impls/provider-factory.d.ts +11 -11
- package/dist/impls/provider-factory.js +2073 -2073
- package/dist/index.d.ts +12 -12
- package/dist/index.js +2057 -2057
- package/dist/node/impls/composio-fallback-resolver.js +73 -73
- package/dist/node/impls/index.js +2150 -2150
- package/dist/node/impls/mistral-conversational.js +159 -159
- package/dist/node/impls/provider-factory.js +2073 -2073
- package/dist/node/index.js +2057 -2057
- package/dist/node/secrets/provider.js +2 -2
- package/dist/secrets/provider.d.ts +2 -2
- package/dist/secrets/provider.js +2 -2
- package/package.json +13 -13
|
@@ -45,6 +45,165 @@ class AsyncEventQueue {
|
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
// src/impls/mistral-conversational.session.ts
|
|
49
|
+
class MistralConversationSession {
|
|
50
|
+
events;
|
|
51
|
+
queue = new AsyncEventQueue;
|
|
52
|
+
turns = [];
|
|
53
|
+
history = [];
|
|
54
|
+
sessionId = crypto.randomUUID();
|
|
55
|
+
startedAt = Date.now();
|
|
56
|
+
sessionConfig;
|
|
57
|
+
defaultModel;
|
|
58
|
+
complete;
|
|
59
|
+
sttProvider;
|
|
60
|
+
pending = Promise.resolve();
|
|
61
|
+
closed = false;
|
|
62
|
+
closedSummary;
|
|
63
|
+
constructor(options) {
|
|
64
|
+
this.sessionConfig = options.sessionConfig;
|
|
65
|
+
this.defaultModel = options.defaultModel;
|
|
66
|
+
this.complete = options.complete;
|
|
67
|
+
this.sttProvider = options.sttProvider;
|
|
68
|
+
this.events = this.queue;
|
|
69
|
+
this.queue.push({
|
|
70
|
+
type: "session_started",
|
|
71
|
+
sessionId: this.sessionId
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
sendAudio(chunk) {
|
|
75
|
+
if (this.closed) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
this.pending = this.pending.then(async () => {
|
|
79
|
+
const transcription = await this.sttProvider.transcribe({
|
|
80
|
+
audio: {
|
|
81
|
+
data: chunk,
|
|
82
|
+
format: this.sessionConfig.inputFormat ?? "pcm",
|
|
83
|
+
sampleRateHz: 16000
|
|
84
|
+
},
|
|
85
|
+
language: this.sessionConfig.language
|
|
86
|
+
});
|
|
87
|
+
const transcriptText = transcription.text.trim();
|
|
88
|
+
if (transcriptText.length > 0) {
|
|
89
|
+
await this.handleUserText(transcriptText);
|
|
90
|
+
}
|
|
91
|
+
}).catch((error) => {
|
|
92
|
+
this.emitError(error);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
sendText(text) {
|
|
96
|
+
if (this.closed) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
const normalized = text.trim();
|
|
100
|
+
if (normalized.length === 0) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
this.pending = this.pending.then(() => this.handleUserText(normalized)).catch((error) => {
|
|
104
|
+
this.emitError(error);
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
interrupt() {
|
|
108
|
+
if (this.closed) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
this.queue.push({
|
|
112
|
+
type: "error",
|
|
113
|
+
error: new Error("Interrupt is not supported for non-streaming sessions.")
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
async close() {
|
|
117
|
+
if (this.closedSummary) {
|
|
118
|
+
return this.closedSummary;
|
|
119
|
+
}
|
|
120
|
+
this.closed = true;
|
|
121
|
+
await this.pending;
|
|
122
|
+
const durationMs = Date.now() - this.startedAt;
|
|
123
|
+
const summary = {
|
|
124
|
+
sessionId: this.sessionId,
|
|
125
|
+
durationMs,
|
|
126
|
+
turns: this.turns.map((turn) => ({
|
|
127
|
+
role: turn.role === "assistant" ? "agent" : turn.role,
|
|
128
|
+
text: turn.text,
|
|
129
|
+
startMs: turn.startMs,
|
|
130
|
+
endMs: turn.endMs
|
|
131
|
+
})),
|
|
132
|
+
transcript: this.turns.map((turn) => `${turn.role}: ${turn.text}`).join(`
|
|
133
|
+
`)
|
|
134
|
+
};
|
|
135
|
+
this.closedSummary = summary;
|
|
136
|
+
this.queue.push({
|
|
137
|
+
type: "session_ended",
|
|
138
|
+
reason: "closed_by_client",
|
|
139
|
+
durationMs
|
|
140
|
+
});
|
|
141
|
+
this.queue.close();
|
|
142
|
+
return summary;
|
|
143
|
+
}
|
|
144
|
+
async handleUserText(text) {
|
|
145
|
+
if (this.closed) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
const userStart = Date.now();
|
|
149
|
+
this.queue.push({ type: "user_speech_started" });
|
|
150
|
+
this.queue.push({ type: "user_speech_ended", transcript: text });
|
|
151
|
+
this.queue.push({
|
|
152
|
+
type: "transcript",
|
|
153
|
+
role: "user",
|
|
154
|
+
text,
|
|
155
|
+
timestamp: userStart
|
|
156
|
+
});
|
|
157
|
+
this.turns.push({
|
|
158
|
+
role: "user",
|
|
159
|
+
text,
|
|
160
|
+
startMs: userStart,
|
|
161
|
+
endMs: Date.now()
|
|
162
|
+
});
|
|
163
|
+
this.history.push({ role: "user", content: text });
|
|
164
|
+
const assistantStart = Date.now();
|
|
165
|
+
const assistantText = await this.complete(this.history, {
|
|
166
|
+
...this.sessionConfig,
|
|
167
|
+
llmModel: this.sessionConfig.llmModel ?? this.defaultModel
|
|
168
|
+
});
|
|
169
|
+
if (this.closed) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
const normalizedAssistantText = assistantText.trim();
|
|
173
|
+
const finalAssistantText = normalizedAssistantText.length > 0 ? normalizedAssistantText : "I was unable to produce a response.";
|
|
174
|
+
this.queue.push({
|
|
175
|
+
type: "agent_speech_started",
|
|
176
|
+
text: finalAssistantText
|
|
177
|
+
});
|
|
178
|
+
this.queue.push({
|
|
179
|
+
type: "transcript",
|
|
180
|
+
role: "agent",
|
|
181
|
+
text: finalAssistantText,
|
|
182
|
+
timestamp: assistantStart
|
|
183
|
+
});
|
|
184
|
+
this.queue.push({ type: "agent_speech_ended" });
|
|
185
|
+
this.turns.push({
|
|
186
|
+
role: "assistant",
|
|
187
|
+
text: finalAssistantText,
|
|
188
|
+
startMs: assistantStart,
|
|
189
|
+
endMs: Date.now()
|
|
190
|
+
});
|
|
191
|
+
this.history.push({ role: "assistant", content: finalAssistantText });
|
|
192
|
+
}
|
|
193
|
+
emitError(error) {
|
|
194
|
+
if (this.closed) {
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
this.queue.push({ type: "error", error: toError(error) });
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
function toError(error) {
|
|
201
|
+
if (error instanceof Error) {
|
|
202
|
+
return error;
|
|
203
|
+
}
|
|
204
|
+
return new Error(String(error));
|
|
205
|
+
}
|
|
206
|
+
|
|
48
207
|
// src/impls/mistral-stt.ts
|
|
49
208
|
var DEFAULT_BASE_URL = "https://api.mistral.ai/v1";
|
|
50
209
|
var DEFAULT_MODEL = "voxtral-mini-latest";
|
|
@@ -209,165 +368,6 @@ function secondsToMs(value) {
|
|
|
209
368
|
return Math.round(value * 1000);
|
|
210
369
|
}
|
|
211
370
|
|
|
212
|
-
// src/impls/mistral-conversational.session.ts
|
|
213
|
-
class MistralConversationSession {
|
|
214
|
-
events;
|
|
215
|
-
queue = new AsyncEventQueue;
|
|
216
|
-
turns = [];
|
|
217
|
-
history = [];
|
|
218
|
-
sessionId = crypto.randomUUID();
|
|
219
|
-
startedAt = Date.now();
|
|
220
|
-
sessionConfig;
|
|
221
|
-
defaultModel;
|
|
222
|
-
complete;
|
|
223
|
-
sttProvider;
|
|
224
|
-
pending = Promise.resolve();
|
|
225
|
-
closed = false;
|
|
226
|
-
closedSummary;
|
|
227
|
-
constructor(options) {
|
|
228
|
-
this.sessionConfig = options.sessionConfig;
|
|
229
|
-
this.defaultModel = options.defaultModel;
|
|
230
|
-
this.complete = options.complete;
|
|
231
|
-
this.sttProvider = options.sttProvider;
|
|
232
|
-
this.events = this.queue;
|
|
233
|
-
this.queue.push({
|
|
234
|
-
type: "session_started",
|
|
235
|
-
sessionId: this.sessionId
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
sendAudio(chunk) {
|
|
239
|
-
if (this.closed) {
|
|
240
|
-
return;
|
|
241
|
-
}
|
|
242
|
-
this.pending = this.pending.then(async () => {
|
|
243
|
-
const transcription = await this.sttProvider.transcribe({
|
|
244
|
-
audio: {
|
|
245
|
-
data: chunk,
|
|
246
|
-
format: this.sessionConfig.inputFormat ?? "pcm",
|
|
247
|
-
sampleRateHz: 16000
|
|
248
|
-
},
|
|
249
|
-
language: this.sessionConfig.language
|
|
250
|
-
});
|
|
251
|
-
const transcriptText = transcription.text.trim();
|
|
252
|
-
if (transcriptText.length > 0) {
|
|
253
|
-
await this.handleUserText(transcriptText);
|
|
254
|
-
}
|
|
255
|
-
}).catch((error) => {
|
|
256
|
-
this.emitError(error);
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
sendText(text) {
|
|
260
|
-
if (this.closed) {
|
|
261
|
-
return;
|
|
262
|
-
}
|
|
263
|
-
const normalized = text.trim();
|
|
264
|
-
if (normalized.length === 0) {
|
|
265
|
-
return;
|
|
266
|
-
}
|
|
267
|
-
this.pending = this.pending.then(() => this.handleUserText(normalized)).catch((error) => {
|
|
268
|
-
this.emitError(error);
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
interrupt() {
|
|
272
|
-
if (this.closed) {
|
|
273
|
-
return;
|
|
274
|
-
}
|
|
275
|
-
this.queue.push({
|
|
276
|
-
type: "error",
|
|
277
|
-
error: new Error("Interrupt is not supported for non-streaming sessions.")
|
|
278
|
-
});
|
|
279
|
-
}
|
|
280
|
-
async close() {
|
|
281
|
-
if (this.closedSummary) {
|
|
282
|
-
return this.closedSummary;
|
|
283
|
-
}
|
|
284
|
-
this.closed = true;
|
|
285
|
-
await this.pending;
|
|
286
|
-
const durationMs = Date.now() - this.startedAt;
|
|
287
|
-
const summary = {
|
|
288
|
-
sessionId: this.sessionId,
|
|
289
|
-
durationMs,
|
|
290
|
-
turns: this.turns.map((turn) => ({
|
|
291
|
-
role: turn.role === "assistant" ? "agent" : turn.role,
|
|
292
|
-
text: turn.text,
|
|
293
|
-
startMs: turn.startMs,
|
|
294
|
-
endMs: turn.endMs
|
|
295
|
-
})),
|
|
296
|
-
transcript: this.turns.map((turn) => `${turn.role}: ${turn.text}`).join(`
|
|
297
|
-
`)
|
|
298
|
-
};
|
|
299
|
-
this.closedSummary = summary;
|
|
300
|
-
this.queue.push({
|
|
301
|
-
type: "session_ended",
|
|
302
|
-
reason: "closed_by_client",
|
|
303
|
-
durationMs
|
|
304
|
-
});
|
|
305
|
-
this.queue.close();
|
|
306
|
-
return summary;
|
|
307
|
-
}
|
|
308
|
-
async handleUserText(text) {
|
|
309
|
-
if (this.closed) {
|
|
310
|
-
return;
|
|
311
|
-
}
|
|
312
|
-
const userStart = Date.now();
|
|
313
|
-
this.queue.push({ type: "user_speech_started" });
|
|
314
|
-
this.queue.push({ type: "user_speech_ended", transcript: text });
|
|
315
|
-
this.queue.push({
|
|
316
|
-
type: "transcript",
|
|
317
|
-
role: "user",
|
|
318
|
-
text,
|
|
319
|
-
timestamp: userStart
|
|
320
|
-
});
|
|
321
|
-
this.turns.push({
|
|
322
|
-
role: "user",
|
|
323
|
-
text,
|
|
324
|
-
startMs: userStart,
|
|
325
|
-
endMs: Date.now()
|
|
326
|
-
});
|
|
327
|
-
this.history.push({ role: "user", content: text });
|
|
328
|
-
const assistantStart = Date.now();
|
|
329
|
-
const assistantText = await this.complete(this.history, {
|
|
330
|
-
...this.sessionConfig,
|
|
331
|
-
llmModel: this.sessionConfig.llmModel ?? this.defaultModel
|
|
332
|
-
});
|
|
333
|
-
if (this.closed) {
|
|
334
|
-
return;
|
|
335
|
-
}
|
|
336
|
-
const normalizedAssistantText = assistantText.trim();
|
|
337
|
-
const finalAssistantText = normalizedAssistantText.length > 0 ? normalizedAssistantText : "I was unable to produce a response.";
|
|
338
|
-
this.queue.push({
|
|
339
|
-
type: "agent_speech_started",
|
|
340
|
-
text: finalAssistantText
|
|
341
|
-
});
|
|
342
|
-
this.queue.push({
|
|
343
|
-
type: "transcript",
|
|
344
|
-
role: "agent",
|
|
345
|
-
text: finalAssistantText,
|
|
346
|
-
timestamp: assistantStart
|
|
347
|
-
});
|
|
348
|
-
this.queue.push({ type: "agent_speech_ended" });
|
|
349
|
-
this.turns.push({
|
|
350
|
-
role: "assistant",
|
|
351
|
-
text: finalAssistantText,
|
|
352
|
-
startMs: assistantStart,
|
|
353
|
-
endMs: Date.now()
|
|
354
|
-
});
|
|
355
|
-
this.history.push({ role: "assistant", content: finalAssistantText });
|
|
356
|
-
}
|
|
357
|
-
emitError(error) {
|
|
358
|
-
if (this.closed) {
|
|
359
|
-
return;
|
|
360
|
-
}
|
|
361
|
-
this.queue.push({ type: "error", error: toError(error) });
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
function toError(error) {
|
|
365
|
-
if (error instanceof Error) {
|
|
366
|
-
return error;
|
|
367
|
-
}
|
|
368
|
-
return new Error(String(error));
|
|
369
|
-
}
|
|
370
|
-
|
|
371
371
|
// src/impls/mistral-conversational.ts
|
|
372
372
|
var DEFAULT_BASE_URL2 = "https://api.mistral.ai/v1";
|
|
373
373
|
var DEFAULT_MODEL2 = "mistral-small-latest";
|