@contractspec/lib.contracts 1.56.1 → 1.57.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.
- package/dist/_virtual/{rolldown_runtime.js → _rolldown/runtime.js} +3 -3
- package/dist/app-config/app-config.contracts.d.ts +50 -50
- package/dist/app-config/events.d.ts +27 -27
- package/dist/app-config/lifecycle-contracts.d.ts +54 -54
- package/dist/app-config/runtime.js +3 -3
- package/dist/app-config/validation.js +3 -3
- package/dist/capabilities/capabilities.js +20 -20
- package/dist/capabilities/context.d.ts +0 -1
- package/dist/capabilities/context.js +1 -1
- package/dist/capabilities/guards.d.ts +0 -1
- package/dist/capabilities/index.d.ts +2 -1
- package/dist/capabilities/index.js +2 -1
- package/dist/capabilities/meeting-recorder.d.ts +10 -0
- package/dist/capabilities/meeting-recorder.js +82 -0
- package/dist/capabilities/validation.d.ts +0 -1
- package/dist/client/react/drivers/rn-reusables.d.ts +0 -1
- package/dist/client/react/drivers/shadcn.d.ts +0 -1
- package/dist/client/react/form-render.js +3 -3
- package/dist/contract-registry/schemas.d.ts +2 -2
- package/dist/data-views/registry.d.ts +0 -1
- package/dist/data-views/spec.d.ts +0 -1
- package/dist/docs/commands/docsPublish.command.d.ts +13 -13
- package/dist/docs/contracts.d.ts +103 -103
- package/dist/docs/events/docsGenerated.event.d.ts +13 -13
- package/dist/docs/events/docsPublished.event.d.ts +15 -15
- package/dist/docs/forms/docsSearch.form.d.ts +4 -4
- package/dist/docs/queries/contractReference.query.d.ts +47 -47
- package/dist/docs/queries/docsIndex.query.d.ts +57 -57
- package/dist/docs/tech/llm/llm-integration.docblock.d.ts +0 -1
- package/dist/docs/tech/mcp-endpoints.docblock.js +5 -0
- package/dist/events.d.ts +0 -1
- package/dist/examples/index.d.ts +0 -1
- package/dist/examples/registry.d.ts +0 -1
- package/dist/examples/schema.d.ts +17 -17
- package/dist/experiments/spec.d.ts +2 -4
- package/dist/features/index.d.ts +0 -1
- package/dist/features/types.d.ts +2 -5
- package/dist/forms/forms.d.ts +1 -2
- package/dist/forms/forms.js +1 -2
- package/dist/index.d.ts +42 -1
- package/dist/index.js +36 -1
- package/dist/install.d.ts +2 -5
- package/dist/integrations/docs/integrations.docblock.js +19 -1
- package/dist/integrations/index.d.ts +26 -1
- package/dist/integrations/index.js +20 -1
- package/dist/integrations/meeting-recorder/contracts/index.d.ts +10 -0
- package/dist/integrations/meeting-recorder/contracts/index.js +12 -0
- package/dist/integrations/meeting-recorder/contracts/meetings.d.ts +458 -0
- package/dist/integrations/meeting-recorder/contracts/meetings.js +149 -0
- package/dist/integrations/meeting-recorder/contracts/transcripts.d.ts +173 -0
- package/dist/integrations/meeting-recorder/contracts/transcripts.js +156 -0
- package/dist/integrations/meeting-recorder/contracts/webhooks.d.ts +92 -0
- package/dist/integrations/meeting-recorder/contracts/webhooks.js +82 -0
- package/dist/integrations/meeting-recorder/meeting-recorder.capability.d.ts +7 -0
- package/dist/integrations/meeting-recorder/meeting-recorder.capability.js +21 -0
- package/dist/integrations/meeting-recorder/meeting-recorder.feature.d.ts +11 -0
- package/dist/integrations/meeting-recorder/meeting-recorder.feature.js +67 -0
- package/dist/integrations/meeting-recorder/models.d.ts +407 -0
- package/dist/integrations/meeting-recorder/models.js +295 -0
- package/dist/integrations/meeting-recorder/telemetry.d.ts +16 -0
- package/dist/integrations/meeting-recorder/telemetry.js +42 -0
- package/dist/integrations/openbanking/contracts/accounts.d.ts +66 -66
- package/dist/integrations/openbanking/contracts/balances.d.ts +34 -34
- package/dist/integrations/openbanking/contracts/transactions.d.ts +48 -48
- package/dist/integrations/openbanking/models.d.ts +55 -55
- package/dist/integrations/operations.d.ts +102 -102
- package/dist/integrations/providers/analytics-reader.d.ts +107 -0
- package/dist/integrations/providers/analytics-reader.js +0 -0
- package/dist/integrations/providers/analytics-writer.d.ts +10 -0
- package/dist/integrations/providers/analytics-writer.js +0 -0
- package/dist/integrations/providers/analytics.d.ts +49 -0
- package/dist/integrations/providers/analytics.js +0 -0
- package/dist/integrations/providers/database.d.ts +15 -0
- package/dist/integrations/providers/database.js +0 -0
- package/dist/integrations/providers/fal.d.ts +8 -0
- package/dist/integrations/providers/fal.js +94 -0
- package/dist/integrations/providers/fathom.d.ts +8 -0
- package/dist/integrations/providers/fathom.js +114 -0
- package/dist/integrations/providers/fireflies.d.ts +8 -0
- package/dist/integrations/providers/fireflies.js +98 -0
- package/dist/integrations/providers/gradium.d.ts +8 -0
- package/dist/integrations/providers/gradium.js +92 -0
- package/dist/integrations/providers/granola.d.ts +8 -0
- package/dist/integrations/providers/granola.js +71 -0
- package/dist/integrations/providers/index.d.ts +19 -1
- package/dist/integrations/providers/index.js +13 -1
- package/dist/integrations/providers/jira.d.ts +8 -0
- package/dist/integrations/providers/jira.js +90 -0
- package/dist/integrations/providers/linear.d.ts +8 -0
- package/dist/integrations/providers/linear.js +85 -0
- package/dist/integrations/providers/meeting-recorder.d.ts +132 -0
- package/dist/integrations/providers/meeting-recorder.js +0 -0
- package/dist/integrations/providers/notion.d.ts +8 -0
- package/dist/integrations/providers/notion.js +91 -0
- package/dist/integrations/providers/posthog.d.ts +8 -0
- package/dist/integrations/providers/posthog.js +107 -0
- package/dist/integrations/providers/project-management.d.ts +35 -0
- package/dist/integrations/providers/project-management.js +0 -0
- package/dist/integrations/providers/registry.d.ts +0 -1
- package/dist/integrations/providers/registry.js +24 -0
- package/dist/integrations/providers/supabase-postgres.d.ts +8 -0
- package/dist/integrations/providers/supabase-postgres.js +73 -0
- package/dist/integrations/providers/supabase-vector.d.ts +8 -0
- package/dist/integrations/providers/supabase-vector.js +93 -0
- package/dist/integrations/providers/tldv.d.ts +8 -0
- package/dist/integrations/providers/tldv.js +98 -0
- package/dist/integrations/runtime.js +0 -1
- package/dist/integrations/spec.d.ts +1 -1
- package/dist/jobs/queue.d.ts +0 -1
- package/dist/knowledge/binding.d.ts +1 -3
- package/dist/knowledge/operations.d.ts +66 -66
- package/dist/llm/exporters.d.ts +0 -1
- package/dist/llm/exporters.js +0 -1
- package/dist/llm/prompts.d.ts +0 -1
- package/dist/llm/types.d.ts +0 -1
- package/dist/onboarding-base.d.ts +29 -29
- package/dist/openapi.d.ts +0 -1
- package/dist/operations/operation.d.ts +19 -43
- package/dist/operations/registry.d.ts +0 -1
- package/dist/operations/registry.js +2 -2
- package/dist/operations/report/getContractVerificationStatus.d.ts +10 -10
- package/dist/ownership.d.ts +41 -88
- package/dist/policy/guards.d.ts +0 -1
- package/dist/policy/guards.js +3 -3
- package/dist/policy/index.d.ts +0 -1
- package/dist/policy/validation.d.ts +0 -1
- package/dist/product-intent/contract-patch-intent.d.ts +103 -0
- package/dist/product-intent/contract-patch-intent.js +33 -0
- package/dist/product-intent/contract-spec-patch.d.ts +89 -0
- package/dist/product-intent/contract-spec-patch.js +27 -0
- package/dist/product-intent/evidence.d.ts +17 -0
- package/dist/product-intent/evidence.js +13 -0
- package/dist/product-intent/findings.d.ts +60 -0
- package/dist/product-intent/findings.js +17 -0
- package/dist/product-intent/impact-report.d.ts +60 -0
- package/dist/product-intent/impact-report.js +27 -0
- package/dist/product-intent/index.d.ts +16 -0
- package/dist/product-intent/index.js +17 -0
- package/dist/product-intent/insights.d.ts +65 -0
- package/dist/product-intent/insights.js +23 -0
- package/dist/product-intent/opportunity-brief.d.ts +195 -0
- package/dist/product-intent/opportunity-brief.js +42 -0
- package/dist/product-intent/problems.d.ts +62 -0
- package/dist/product-intent/problems.js +22 -0
- package/dist/product-intent/registry.d.ts +32 -0
- package/dist/product-intent/registry.js +49 -0
- package/dist/product-intent/runtime.d.ts +103 -0
- package/dist/product-intent/runtime.js +101 -0
- package/dist/product-intent/spec.d.ts +676 -0
- package/dist/product-intent/spec.js +53 -0
- package/dist/product-intent/task-pack.d.ts +101 -0
- package/dist/product-intent/task-pack.js +34 -0
- package/dist/product-intent/tickets.d.ts +70 -0
- package/dist/product-intent/tickets.js +24 -0
- package/dist/product-intent/types.d.ts +12 -0
- package/dist/product-intent/types.js +13 -0
- package/dist/product-intent/ui-wireframe.d.ts +103 -0
- package/dist/product-intent/ui-wireframe.js +33 -0
- package/dist/registry-utils.d.ts +0 -1
- package/dist/registry-utils.js +3 -3
- package/dist/resources.js +1 -1
- package/dist/schema-to-markdown.d.ts +0 -1
- package/dist/server/contracts-adapter-input.js +2 -2
- package/dist/server/graphql-pothos.d.ts +0 -1
- package/dist/server/mcp/createMcpServer.d.ts +0 -1
- package/dist/server/rest-express.d.ts +0 -1
- package/dist/server/rest-generic.js +3 -3
- package/dist/server/rest-next-app.d.ts +0 -1
- package/dist/tests/spec.d.ts +0 -1
- package/dist/translations/registry.d.ts +0 -1
- package/dist/translations/spec.d.ts +0 -1
- package/dist/translations/validation.d.ts +0 -1
- package/dist/types.d.ts +5 -12
- package/dist/versioning/types.d.ts +0 -1
- package/dist/versioning/utils.d.ts +0 -1
- package/dist/workflow/adapters/memory-store.d.ts +0 -1
- package/dist/workflow/context.d.ts +0 -1
- package/dist/workflow/context.js +2 -2
- package/dist/workflow/runner.d.ts +1 -2
- package/dist/workspace-config/contractsrc-schema.d.ts +0 -1
- package/dist/workspace-config/contractsrc-types.d.ts +1 -3
- package/package.json +110 -32
- package/dist/integrations/providers/impls/elevenlabs-voice.d.ts +0 -20
- package/dist/integrations/providers/impls/elevenlabs-voice.js +0 -95
- package/dist/integrations/providers/impls/gcs-storage.d.ts +0 -24
- package/dist/integrations/providers/impls/gcs-storage.js +0 -88
- package/dist/integrations/providers/impls/gmail-inbound.d.ts +0 -26
- package/dist/integrations/providers/impls/gmail-inbound.js +0 -200
- package/dist/integrations/providers/impls/gmail-outbound.d.ts +0 -18
- package/dist/integrations/providers/impls/gmail-outbound.js +0 -105
- package/dist/integrations/providers/impls/google-calendar.d.ts +0 -23
- package/dist/integrations/providers/impls/google-calendar.js +0 -154
- package/dist/integrations/providers/impls/index.d.ts +0 -15
- package/dist/integrations/providers/impls/index.js +0 -16
- package/dist/integrations/providers/impls/mistral-embedding.d.ts +0 -23
- package/dist/integrations/providers/impls/mistral-embedding.js +0 -41
- package/dist/integrations/providers/impls/mistral-llm.d.ts +0 -31
- package/dist/integrations/providers/impls/mistral-llm.js +0 -247
- package/dist/integrations/providers/impls/postmark-email.d.ts +0 -19
- package/dist/integrations/providers/impls/postmark-email.js +0 -55
- package/dist/integrations/providers/impls/powens-client.d.ts +0 -124
- package/dist/integrations/providers/impls/powens-client.js +0 -171
- package/dist/integrations/providers/impls/powens-openbanking.d.ts +0 -27
- package/dist/integrations/providers/impls/powens-openbanking.js +0 -218
- package/dist/integrations/providers/impls/provider-factory.d.ts +0 -26
- package/dist/integrations/providers/impls/provider-factory.js +0 -146
- package/dist/integrations/providers/impls/qdrant-vector.d.ts +0 -24
- package/dist/integrations/providers/impls/qdrant-vector.js +0 -69
- package/dist/integrations/providers/impls/stripe-payments.d.ts +0 -28
- package/dist/integrations/providers/impls/stripe-payments.js +0 -202
- package/dist/integrations/providers/impls/twilio-sms.d.ts +0 -20
- package/dist/integrations/providers/impls/twilio-sms.js +0 -58
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
import { google } from "googleapis";
|
|
2
|
-
|
|
3
|
-
//#region src/integrations/providers/impls/gmail-inbound.ts
|
|
4
|
-
var GmailInboundProvider = class {
|
|
5
|
-
gmail;
|
|
6
|
-
userId;
|
|
7
|
-
includeSpamTrash;
|
|
8
|
-
auth;
|
|
9
|
-
constructor(options) {
|
|
10
|
-
this.auth = options.auth;
|
|
11
|
-
this.gmail = options.gmail ?? google.gmail({
|
|
12
|
-
version: "v1",
|
|
13
|
-
auth: options.auth
|
|
14
|
-
});
|
|
15
|
-
this.userId = options.userId ?? "me";
|
|
16
|
-
this.includeSpamTrash = options.includeSpamTrash ?? false;
|
|
17
|
-
}
|
|
18
|
-
async listThreads(query) {
|
|
19
|
-
const response = await this.gmail.users.threads.list({
|
|
20
|
-
userId: this.userId,
|
|
21
|
-
maxResults: query?.pageSize,
|
|
22
|
-
pageToken: query?.pageToken,
|
|
23
|
-
q: query?.query,
|
|
24
|
-
labelIds: query?.label ? [query.label] : void 0,
|
|
25
|
-
includeSpamTrash: this.includeSpamTrash,
|
|
26
|
-
auth: this.auth
|
|
27
|
-
});
|
|
28
|
-
return (await Promise.all((response.data.threads ?? []).map(async (thread) => {
|
|
29
|
-
if (!thread.id) return null;
|
|
30
|
-
return this.getThread(thread.id);
|
|
31
|
-
}))).filter((thread) => thread !== null);
|
|
32
|
-
}
|
|
33
|
-
async getThread(threadId) {
|
|
34
|
-
const thread = (await this.gmail.users.threads.get({
|
|
35
|
-
id: threadId,
|
|
36
|
-
userId: this.userId,
|
|
37
|
-
format: "full",
|
|
38
|
-
auth: this.auth
|
|
39
|
-
})).data;
|
|
40
|
-
if (!thread) return null;
|
|
41
|
-
const messages = thread.messages?.map((message) => this.transformMessage(message)) ?? [];
|
|
42
|
-
const participants = dedupeAddresses(messages.flatMap((message) => [
|
|
43
|
-
message.from,
|
|
44
|
-
...message.to,
|
|
45
|
-
...message.cc ?? []
|
|
46
|
-
]));
|
|
47
|
-
const firstMessage = messages[0];
|
|
48
|
-
const lastMessage = messages[messages.length - 1];
|
|
49
|
-
const updatedAt = lastMessage?.receivedAt ?? lastMessage?.sentAt ?? firstMessage?.receivedAt ?? firstMessage?.sentAt ?? /* @__PURE__ */ new Date();
|
|
50
|
-
const labels = Array.from(new Set(messages.flatMap((message) => {
|
|
51
|
-
const labelField = message.metadata?.labelIds;
|
|
52
|
-
if (!labelField) return [];
|
|
53
|
-
return labelField.split(",").map((label) => label.trim());
|
|
54
|
-
}).filter((label) => Boolean(label))));
|
|
55
|
-
return {
|
|
56
|
-
id: thread.id ?? threadId,
|
|
57
|
-
subject: messages[0]?.subject,
|
|
58
|
-
snippet: thread.snippet ?? "",
|
|
59
|
-
participants,
|
|
60
|
-
messages,
|
|
61
|
-
updatedAt,
|
|
62
|
-
labels,
|
|
63
|
-
metadata: thread.historyId ? { historyId: thread.historyId } : void 0
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
async listMessagesSince(query) {
|
|
67
|
-
const after = query.since ? Math.floor(query.since.getTime() / 1e3) : void 0;
|
|
68
|
-
const q = [];
|
|
69
|
-
if (after) q.push(`after:${after}`);
|
|
70
|
-
const response = await this.gmail.users.messages.list({
|
|
71
|
-
userId: this.userId,
|
|
72
|
-
maxResults: query.pageSize,
|
|
73
|
-
pageToken: query.pageToken,
|
|
74
|
-
labelIds: query.label ? [query.label] : void 0,
|
|
75
|
-
q: q.join(" "),
|
|
76
|
-
includeSpamTrash: this.includeSpamTrash,
|
|
77
|
-
auth: this.auth
|
|
78
|
-
});
|
|
79
|
-
return {
|
|
80
|
-
messages: (await Promise.all((response.data.messages ?? []).map(async (item) => {
|
|
81
|
-
if (!item.id) return null;
|
|
82
|
-
const full = await this.gmail.users.messages.get({
|
|
83
|
-
userId: this.userId,
|
|
84
|
-
id: item.id,
|
|
85
|
-
format: "full",
|
|
86
|
-
auth: this.auth
|
|
87
|
-
});
|
|
88
|
-
if (!full.data) return null;
|
|
89
|
-
return this.transformMessage(full.data);
|
|
90
|
-
}))).filter((message) => message !== null),
|
|
91
|
-
nextPageToken: response.data.nextPageToken ?? void 0
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
transformMessage(message) {
|
|
95
|
-
const headers = message.payload?.headers ?? [];
|
|
96
|
-
const subject = headerValue(headers, "Subject") ?? "";
|
|
97
|
-
const from = parseAddress(headerValue(headers, "From")) ?? inferFallbackAddress("from", message.id);
|
|
98
|
-
const to = parseAddressList(headerValue(headers, "To"));
|
|
99
|
-
const cc = parseAddressList(headerValue(headers, "Cc"));
|
|
100
|
-
const bcc = parseAddressList(headerValue(headers, "Bcc"));
|
|
101
|
-
const replyTo = parseAddress(headerValue(headers, "Reply-To"));
|
|
102
|
-
const { text, html, attachments } = extractContent(message.payload);
|
|
103
|
-
const timestamp = message.internalDate ? new Date(Number(message.internalDate)) : /* @__PURE__ */ new Date();
|
|
104
|
-
const metadata = {
|
|
105
|
-
...message.labelIds?.length ? { labelIds: message.labelIds.join(",") } : {},
|
|
106
|
-
...message.historyId ? { historyId: message.historyId } : {}
|
|
107
|
-
};
|
|
108
|
-
return {
|
|
109
|
-
id: message.id ?? "",
|
|
110
|
-
threadId: message.threadId ?? "",
|
|
111
|
-
subject,
|
|
112
|
-
from,
|
|
113
|
-
to,
|
|
114
|
-
cc,
|
|
115
|
-
bcc,
|
|
116
|
-
replyTo: replyTo ?? void 0,
|
|
117
|
-
sentAt: timestamp,
|
|
118
|
-
receivedAt: timestamp,
|
|
119
|
-
textBody: text ?? void 0,
|
|
120
|
-
htmlBody: html ?? void 0,
|
|
121
|
-
attachments,
|
|
122
|
-
headers: Object.fromEntries(headers.map((header) => [header.name ?? "", header.value ?? ""])),
|
|
123
|
-
metadata: Object.keys(metadata).length > 0 ? metadata : void 0
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
function headerValue(headers, name) {
|
|
128
|
-
const value = headers.find((candidate) => candidate.name?.toLowerCase() === name.toLowerCase())?.value;
|
|
129
|
-
return typeof value === "string" ? value : void 0;
|
|
130
|
-
}
|
|
131
|
-
function parseAddress(header) {
|
|
132
|
-
const addresses = parseAddressList(header);
|
|
133
|
-
if (addresses.length === 0) return null;
|
|
134
|
-
return addresses[0] ?? null;
|
|
135
|
-
}
|
|
136
|
-
function inferFallbackAddress(field, messageId) {
|
|
137
|
-
return { email: `${field}-${messageId ? messageId.replace(/[^\w]/g, "").slice(-8) || "unknown" : "unknown"}@mail.local` };
|
|
138
|
-
}
|
|
139
|
-
function parseAddressList(header) {
|
|
140
|
-
if (!header) return [];
|
|
141
|
-
return header.split(",").map((part) => part.trim()).filter(Boolean).map((value) => {
|
|
142
|
-
const match = value.match(/^(?:"?([^"]*)"?\s)?<?([^<>]+)>?$/);
|
|
143
|
-
if (!match) return { email: value };
|
|
144
|
-
const name = match[1]?.trim();
|
|
145
|
-
const email = match[2]?.trim();
|
|
146
|
-
if (!email) return { email: value };
|
|
147
|
-
return name ? {
|
|
148
|
-
email,
|
|
149
|
-
name
|
|
150
|
-
} : { email };
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
function dedupeAddresses(addresses) {
|
|
154
|
-
const map = /* @__PURE__ */ new Map();
|
|
155
|
-
for (const address of addresses) {
|
|
156
|
-
if (!address) continue;
|
|
157
|
-
map.set(address.email.toLowerCase(), address);
|
|
158
|
-
}
|
|
159
|
-
return Array.from(map.values());
|
|
160
|
-
}
|
|
161
|
-
function extractContent(payload) {
|
|
162
|
-
if (!payload) return { attachments: [] };
|
|
163
|
-
const attachments = [];
|
|
164
|
-
const visit = (part) => {
|
|
165
|
-
if (!part) return {};
|
|
166
|
-
if (part.filename && part.body?.attachmentId) attachments.push({
|
|
167
|
-
id: part.body.attachmentId,
|
|
168
|
-
filename: part.filename,
|
|
169
|
-
contentType: part.mimeType ?? "application/octet-stream",
|
|
170
|
-
sizeBytes: part.body.size ?? void 0
|
|
171
|
-
});
|
|
172
|
-
const mimeType = part.mimeType ?? "";
|
|
173
|
-
const data = part.body?.data;
|
|
174
|
-
if (mimeType === "text/plain" && data) return { text: decodeBase64Url(data) };
|
|
175
|
-
if (mimeType === "text/html" && data) return { html: decodeBase64Url(data) };
|
|
176
|
-
if (part.parts?.length) return part.parts.reduce((acc, nested) => {
|
|
177
|
-
const value = visit(nested);
|
|
178
|
-
return {
|
|
179
|
-
text: value.text ?? acc.text,
|
|
180
|
-
html: value.html ?? acc.html
|
|
181
|
-
};
|
|
182
|
-
}, {});
|
|
183
|
-
return {};
|
|
184
|
-
};
|
|
185
|
-
const { text, html } = visit(payload);
|
|
186
|
-
return {
|
|
187
|
-
text,
|
|
188
|
-
html,
|
|
189
|
-
attachments
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
function decodeBase64Url(data) {
|
|
193
|
-
const normalized = data.replace(/-/g, "+").replace(/_/g, "/");
|
|
194
|
-
const padding = normalized.length % 4;
|
|
195
|
-
const padded = padding === 0 ? normalized : normalized + "=".repeat(4 - padding);
|
|
196
|
-
return Buffer.from(padded, "base64").toString("utf-8");
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
//#endregion
|
|
200
|
-
export { GmailInboundProvider };
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { EmailOutboundMessage, EmailOutboundProvider, EmailOutboundResult } from "../email.js";
|
|
2
|
-
import { gmail_v1 } from "googleapis";
|
|
3
|
-
|
|
4
|
-
//#region src/integrations/providers/impls/gmail-outbound.d.ts
|
|
5
|
-
interface GmailOutboundProviderOptions {
|
|
6
|
-
auth: gmail_v1.Options['auth'];
|
|
7
|
-
userId?: string;
|
|
8
|
-
gmail?: gmail_v1.Gmail;
|
|
9
|
-
}
|
|
10
|
-
declare class GmailOutboundProvider implements EmailOutboundProvider {
|
|
11
|
-
private readonly gmail;
|
|
12
|
-
private readonly userId;
|
|
13
|
-
private readonly auth;
|
|
14
|
-
constructor(options: GmailOutboundProviderOptions);
|
|
15
|
-
sendEmail(message: EmailOutboundMessage): Promise<EmailOutboundResult>;
|
|
16
|
-
}
|
|
17
|
-
//#endregion
|
|
18
|
-
export { GmailOutboundProvider, GmailOutboundProviderOptions };
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { google } from "googleapis";
|
|
2
|
-
|
|
3
|
-
//#region src/integrations/providers/impls/gmail-outbound.ts
|
|
4
|
-
var GmailOutboundProvider = class {
|
|
5
|
-
gmail;
|
|
6
|
-
userId;
|
|
7
|
-
auth;
|
|
8
|
-
constructor(options) {
|
|
9
|
-
this.auth = options.auth;
|
|
10
|
-
this.gmail = options.gmail ?? google.gmail({
|
|
11
|
-
version: "v1",
|
|
12
|
-
auth: options.auth
|
|
13
|
-
});
|
|
14
|
-
this.userId = options.userId ?? "me";
|
|
15
|
-
}
|
|
16
|
-
async sendEmail(message) {
|
|
17
|
-
const raw = encodeMessage(message);
|
|
18
|
-
const response = await this.gmail.users.messages.send({
|
|
19
|
-
userId: this.userId,
|
|
20
|
-
requestBody: { raw },
|
|
21
|
-
auth: this.auth
|
|
22
|
-
});
|
|
23
|
-
return {
|
|
24
|
-
id: response.data.id ?? "",
|
|
25
|
-
providerMessageId: response.data.id ?? void 0,
|
|
26
|
-
queuedAt: /* @__PURE__ */ new Date()
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
function encodeMessage(message) {
|
|
31
|
-
const headers = [
|
|
32
|
-
`From: ${formatAddress(message.from)}`,
|
|
33
|
-
`To: ${message.to.map(formatAddress).join(", ")}`,
|
|
34
|
-
`Subject: ${message.subject}`,
|
|
35
|
-
"MIME-Version: 1.0"
|
|
36
|
-
];
|
|
37
|
-
if (message.cc?.length) headers.push(`Cc: ${message.cc.map(formatAddress).join(", ")}`);
|
|
38
|
-
if (message.replyTo) headers.push(`Reply-To: ${formatAddress(message.replyTo)}`);
|
|
39
|
-
Object.entries(message.headers ?? {}).forEach(([key, value]) => {
|
|
40
|
-
headers.push(`${key}: ${value}`);
|
|
41
|
-
});
|
|
42
|
-
const attachments = message.attachments ?? [];
|
|
43
|
-
const hasHtml = Boolean(message.htmlBody);
|
|
44
|
-
const hasText = Boolean(message.textBody);
|
|
45
|
-
const boundaryMain = `mixed_${Date.now()}`;
|
|
46
|
-
const boundaryAlt = `alt_${Date.now()}`;
|
|
47
|
-
let body = "";
|
|
48
|
-
if (attachments.length > 0) {
|
|
49
|
-
headers.push(`Content-Type: multipart/mixed; boundary="${boundaryMain}"`);
|
|
50
|
-
body += `\r\n--${boundaryMain}\r\n`;
|
|
51
|
-
body += buildAlternativePart(hasText, hasHtml, boundaryAlt, message);
|
|
52
|
-
attachments.forEach((attachment) => {
|
|
53
|
-
body += buildAttachmentPart(boundaryMain, attachment);
|
|
54
|
-
});
|
|
55
|
-
body += `\r\n--${boundaryMain}--`;
|
|
56
|
-
} else if (hasText && hasHtml) {
|
|
57
|
-
headers.push(`Content-Type: multipart/alternative; boundary="${boundaryAlt}"`);
|
|
58
|
-
body += `\r\n--${boundaryAlt}\r\n`;
|
|
59
|
-
body += buildTextPart("text/plain; charset=\"utf-8\"", message.textBody ?? "");
|
|
60
|
-
body += `\r\n--${boundaryAlt}\r\n`;
|
|
61
|
-
body += buildTextPart("text/html; charset=\"utf-8\"", message.htmlBody ?? "");
|
|
62
|
-
body += `\r\n--${boundaryAlt}--`;
|
|
63
|
-
} else if (hasHtml) {
|
|
64
|
-
headers.push("Content-Type: text/html; charset=\"utf-8\"");
|
|
65
|
-
body += `\r\n\r\n${message.htmlBody}`;
|
|
66
|
-
} else {
|
|
67
|
-
headers.push("Content-Type: text/plain; charset=\"utf-8\"");
|
|
68
|
-
body += `\r\n\r\n${message.textBody ?? ""}`;
|
|
69
|
-
}
|
|
70
|
-
const mime = `${headers.join("\r\n")}${body}`;
|
|
71
|
-
return Buffer.from(mime).toString("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
72
|
-
}
|
|
73
|
-
function buildAlternativePart(hasText, hasHtml, boundary, message) {
|
|
74
|
-
let content = "";
|
|
75
|
-
content += `Content-Type: multipart/alternative; boundary="${boundary}"\r\n`;
|
|
76
|
-
content += "\r\n";
|
|
77
|
-
if (hasText) {
|
|
78
|
-
content += `--${boundary}\r\n`;
|
|
79
|
-
content += buildTextPart("text/plain; charset=\"utf-8\"", message.textBody ?? "");
|
|
80
|
-
}
|
|
81
|
-
if (hasHtml) {
|
|
82
|
-
content += `\r\n--${boundary}\r\n`;
|
|
83
|
-
content += buildTextPart("text/html; charset=\"utf-8\"", message.htmlBody ?? "");
|
|
84
|
-
}
|
|
85
|
-
content += `\r\n--${boundary}--`;
|
|
86
|
-
return content;
|
|
87
|
-
}
|
|
88
|
-
function buildTextPart(contentType, content) {
|
|
89
|
-
return `Content-Type: ${contentType}\r\nContent-Transfer-Encoding: 7bit\r
|
|
90
|
-
\r
|
|
91
|
-
` + content;
|
|
92
|
-
}
|
|
93
|
-
function buildAttachmentPart(boundary, attachment) {
|
|
94
|
-
const data = attachment.data ?? new Uint8Array();
|
|
95
|
-
const encoded = data.byteLength > 0 ? Buffer.from(data).toString("base64") : "";
|
|
96
|
-
return `\r\n--${boundary}\r\nContent-Type: ${attachment.contentType}; name="${attachment.filename}"\r\nContent-Transfer-Encoding: base64\r
|
|
97
|
-
Content-Disposition: attachment; filename="${attachment.filename}"\r\n\r\n` + encoded;
|
|
98
|
-
}
|
|
99
|
-
function formatAddress(address) {
|
|
100
|
-
if (address.name) return `"${address.name}" <${address.email}>`;
|
|
101
|
-
return address.email;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
//#endregion
|
|
105
|
-
export { GmailOutboundProvider };
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { CalendarEvent, CalendarEventInput, CalendarEventUpdateInput, CalendarListEventsQuery, CalendarListEventsResult, CalendarProvider } from "../calendar.js";
|
|
2
|
-
import { calendar_v3 } from "googleapis";
|
|
3
|
-
|
|
4
|
-
//#region src/integrations/providers/impls/google-calendar.d.ts
|
|
5
|
-
interface GoogleCalendarProviderOptions {
|
|
6
|
-
auth: calendar_v3.Options['auth'];
|
|
7
|
-
calendar?: calendar_v3.Calendar;
|
|
8
|
-
calendarId?: string;
|
|
9
|
-
}
|
|
10
|
-
declare class GoogleCalendarProvider implements CalendarProvider {
|
|
11
|
-
private readonly calendar;
|
|
12
|
-
private readonly defaultCalendarId;
|
|
13
|
-
private readonly auth;
|
|
14
|
-
constructor(options: GoogleCalendarProviderOptions);
|
|
15
|
-
listEvents(query: CalendarListEventsQuery): Promise<CalendarListEventsResult>;
|
|
16
|
-
createEvent(input: CalendarEventInput): Promise<CalendarEvent>;
|
|
17
|
-
updateEvent(calendarId: string, eventId: string, input: CalendarEventUpdateInput): Promise<CalendarEvent>;
|
|
18
|
-
deleteEvent(calendarId: string, eventId: string): Promise<void>;
|
|
19
|
-
private fromGoogleEvent;
|
|
20
|
-
private toGoogleEvent;
|
|
21
|
-
}
|
|
22
|
-
//#endregion
|
|
23
|
-
export { GoogleCalendarProvider, GoogleCalendarProviderOptions };
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import { google } from "googleapis";
|
|
2
|
-
|
|
3
|
-
//#region src/integrations/providers/impls/google-calendar.ts
|
|
4
|
-
var GoogleCalendarProvider = class {
|
|
5
|
-
calendar;
|
|
6
|
-
defaultCalendarId;
|
|
7
|
-
auth;
|
|
8
|
-
constructor(options) {
|
|
9
|
-
this.auth = options.auth;
|
|
10
|
-
this.calendar = options.calendar ?? google.calendar({
|
|
11
|
-
version: "v3",
|
|
12
|
-
auth: options.auth
|
|
13
|
-
});
|
|
14
|
-
this.defaultCalendarId = options.calendarId ?? "primary";
|
|
15
|
-
}
|
|
16
|
-
async listEvents(query) {
|
|
17
|
-
const response = await this.calendar.events.list({
|
|
18
|
-
calendarId: query.calendarId ?? this.defaultCalendarId,
|
|
19
|
-
timeMin: query.timeMin?.toISOString(),
|
|
20
|
-
timeMax: query.timeMax?.toISOString(),
|
|
21
|
-
maxResults: query.maxResults,
|
|
22
|
-
pageToken: query.pageToken,
|
|
23
|
-
singleEvents: true,
|
|
24
|
-
orderBy: "startTime",
|
|
25
|
-
auth: this.auth
|
|
26
|
-
});
|
|
27
|
-
return {
|
|
28
|
-
events: response.data.items?.map((item) => this.fromGoogleEvent(query.calendarId ?? this.defaultCalendarId, item)) ?? [],
|
|
29
|
-
nextPageToken: response.data.nextPageToken ?? void 0
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
async createEvent(input) {
|
|
33
|
-
const calendarId = input.calendarId ?? this.defaultCalendarId;
|
|
34
|
-
const response = await this.calendar.events.insert({
|
|
35
|
-
calendarId,
|
|
36
|
-
requestBody: this.toGoogleEvent(input),
|
|
37
|
-
conferenceDataVersion: input.conference?.create ? 1 : void 0,
|
|
38
|
-
auth: this.auth
|
|
39
|
-
});
|
|
40
|
-
return this.fromGoogleEvent(calendarId, response.data);
|
|
41
|
-
}
|
|
42
|
-
async updateEvent(calendarId, eventId, input) {
|
|
43
|
-
const response = await this.calendar.events.patch({
|
|
44
|
-
calendarId: calendarId ?? this.defaultCalendarId,
|
|
45
|
-
eventId,
|
|
46
|
-
requestBody: this.toGoogleEvent(input),
|
|
47
|
-
conferenceDataVersion: input.conference?.create ? 1 : void 0,
|
|
48
|
-
auth: this.auth
|
|
49
|
-
});
|
|
50
|
-
return this.fromGoogleEvent(calendarId, response.data);
|
|
51
|
-
}
|
|
52
|
-
async deleteEvent(calendarId, eventId) {
|
|
53
|
-
await this.calendar.events.delete({
|
|
54
|
-
calendarId: calendarId ?? this.defaultCalendarId,
|
|
55
|
-
eventId,
|
|
56
|
-
auth: this.auth
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
fromGoogleEvent(calendarId, event) {
|
|
60
|
-
const start = parseDateTime(event.start);
|
|
61
|
-
const end = parseDateTime(event.end);
|
|
62
|
-
const attendees = event.attendees?.map((attendee) => ({
|
|
63
|
-
email: attendee.email ?? "",
|
|
64
|
-
name: attendee.displayName ?? void 0,
|
|
65
|
-
optional: attendee.optional ?? void 0,
|
|
66
|
-
responseStatus: normalizeResponseStatus(attendee.responseStatus)
|
|
67
|
-
})) ?? [];
|
|
68
|
-
const reminders = event.reminders?.overrides?.map((reminder) => ({
|
|
69
|
-
method: reminder.method ?? "popup",
|
|
70
|
-
minutesBeforeStart: reminder.minutes ?? 0
|
|
71
|
-
})) ?? [];
|
|
72
|
-
const metadata = buildMetadata(event);
|
|
73
|
-
return {
|
|
74
|
-
id: event.id ?? "",
|
|
75
|
-
calendarId,
|
|
76
|
-
title: event.summary ?? "",
|
|
77
|
-
description: event.description ?? void 0,
|
|
78
|
-
location: event.location ?? void 0,
|
|
79
|
-
start,
|
|
80
|
-
end,
|
|
81
|
-
allDay: event.start?.date ? true : void 0,
|
|
82
|
-
attendees,
|
|
83
|
-
reminders,
|
|
84
|
-
conferenceLink: event.hangoutLink ?? event.conferenceData?.entryPoints?.find((entry) => entry.uri)?.uri ?? void 0,
|
|
85
|
-
metadata,
|
|
86
|
-
createdAt: event.created ? new Date(event.created) : void 0,
|
|
87
|
-
updatedAt: event.updated ? new Date(event.updated) : void 0
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
toGoogleEvent(input) {
|
|
91
|
-
const event = {};
|
|
92
|
-
if ("title" in input && input.title) event.summary = input.title;
|
|
93
|
-
if (input.description !== void 0) event.description = input.description;
|
|
94
|
-
if (input.location !== void 0) event.location = input.location;
|
|
95
|
-
if (input.start) event.start = formatDateTime(input.start, input.allDay);
|
|
96
|
-
if (input.end) event.end = formatDateTime(input.end, input.allDay);
|
|
97
|
-
if (input.attendees) event.attendees = input.attendees.map((attendee) => ({
|
|
98
|
-
email: attendee.email,
|
|
99
|
-
displayName: attendee.name,
|
|
100
|
-
optional: attendee.optional,
|
|
101
|
-
responseStatus: attendee.responseStatus
|
|
102
|
-
}));
|
|
103
|
-
if (input.reminders) event.reminders = {
|
|
104
|
-
useDefault: false,
|
|
105
|
-
overrides: input.reminders.map((reminder) => ({
|
|
106
|
-
method: reminder.method,
|
|
107
|
-
minutes: reminder.minutesBeforeStart
|
|
108
|
-
}))
|
|
109
|
-
};
|
|
110
|
-
if (input.conference?.create) event.conferenceData = { createRequest: { requestId: `conf-${Date.now()}` } };
|
|
111
|
-
if (input.metadata) event.extendedProperties = {
|
|
112
|
-
...event.extendedProperties ?? {},
|
|
113
|
-
private: {
|
|
114
|
-
...event.extendedProperties?.private ?? {},
|
|
115
|
-
...input.metadata
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
return event;
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
function parseDateTime(time) {
|
|
122
|
-
if (!time) return /* @__PURE__ */ new Date();
|
|
123
|
-
if (time.dateTime) return new Date(time.dateTime);
|
|
124
|
-
if (time.date) return /* @__PURE__ */ new Date(`${time.date}T00:00:00`);
|
|
125
|
-
return /* @__PURE__ */ new Date();
|
|
126
|
-
}
|
|
127
|
-
function formatDateTime(date, allDay) {
|
|
128
|
-
if (allDay) return { date: date.toISOString().slice(0, 10) };
|
|
129
|
-
return { dateTime: date.toISOString() };
|
|
130
|
-
}
|
|
131
|
-
function normalizeResponseStatus(status) {
|
|
132
|
-
if (!status) return void 0;
|
|
133
|
-
return [
|
|
134
|
-
"needsAction",
|
|
135
|
-
"declined",
|
|
136
|
-
"tentative",
|
|
137
|
-
"accepted"
|
|
138
|
-
].includes(status) ? status : void 0;
|
|
139
|
-
}
|
|
140
|
-
function buildMetadata(event) {
|
|
141
|
-
const metadata = {};
|
|
142
|
-
if (event.status) metadata.status = event.status;
|
|
143
|
-
if (event.htmlLink) metadata.htmlLink = event.htmlLink;
|
|
144
|
-
if (event.iCalUID) metadata.iCalUID = event.iCalUID;
|
|
145
|
-
if (event.etag) metadata.etag = event.etag;
|
|
146
|
-
if (event.conferenceData?.conferenceSolution?.name) metadata.conferenceSolution = event.conferenceData.conferenceSolution.name;
|
|
147
|
-
if (event.extendedProperties?.private) Object.entries(event.extendedProperties.private).forEach(([key, value]) => {
|
|
148
|
-
if (typeof value === "string") metadata[`extended.${key}`] = value;
|
|
149
|
-
});
|
|
150
|
-
return Object.keys(metadata).length > 0 ? metadata : void 0;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
//#endregion
|
|
154
|
-
export { GoogleCalendarProvider };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { ElevenLabsVoiceProvider, ElevenLabsVoiceProviderOptions } from "./elevenlabs-voice.js";
|
|
2
|
-
import { GoogleCloudStorageProvider, GoogleCloudStorageProviderOptions } from "./gcs-storage.js";
|
|
3
|
-
import { GmailInboundProvider, GmailInboundProviderOptions } from "./gmail-inbound.js";
|
|
4
|
-
import { GmailOutboundProvider, GmailOutboundProviderOptions } from "./gmail-outbound.js";
|
|
5
|
-
import { GoogleCalendarProvider, GoogleCalendarProviderOptions } from "./google-calendar.js";
|
|
6
|
-
import { MistralLLMProvider, MistralLLMProviderOptions } from "./mistral-llm.js";
|
|
7
|
-
import { MistralEmbeddingProvider, MistralEmbeddingProviderOptions } from "./mistral-embedding.js";
|
|
8
|
-
import { QdrantVectorProvider, QdrantVectorProviderOptions } from "./qdrant-vector.js";
|
|
9
|
-
import { StripePaymentsProvider, StripePaymentsProviderOptions } from "./stripe-payments.js";
|
|
10
|
-
import { PostmarkEmailProvider, PostmarkEmailProviderOptions } from "./postmark-email.js";
|
|
11
|
-
import { TwilioSmsProvider, TwilioSmsProviderOptions } from "./twilio-sms.js";
|
|
12
|
-
import { PowensAccount, PowensAccountListResponse, PowensBalance, PowensClient, PowensClientError, PowensClientOptions, PowensConnectionStatusResponse, PowensEnvironment, PowensTransaction, PowensTransactionListResponse } from "./powens-client.js";
|
|
13
|
-
import { PowensOpenBankingProvider, PowensOpenBankingProviderOptions } from "./powens-openbanking.js";
|
|
14
|
-
import { IntegrationProviderFactory } from "./provider-factory.js";
|
|
15
|
-
export { ElevenLabsVoiceProvider, ElevenLabsVoiceProviderOptions, GmailInboundProvider, GmailInboundProviderOptions, GmailOutboundProvider, GmailOutboundProviderOptions, GoogleCalendarProvider, GoogleCalendarProviderOptions, GoogleCloudStorageProvider, GoogleCloudStorageProviderOptions, IntegrationProviderFactory, MistralEmbeddingProvider, MistralEmbeddingProviderOptions, MistralLLMProvider, MistralLLMProviderOptions, PostmarkEmailProvider, PostmarkEmailProviderOptions, PowensAccount, PowensAccountListResponse, PowensBalance, PowensClient, PowensClientError, PowensClientOptions, PowensConnectionStatusResponse, PowensEnvironment, PowensOpenBankingProvider, PowensOpenBankingProviderOptions, PowensTransaction, PowensTransactionListResponse, QdrantVectorProvider, QdrantVectorProviderOptions, StripePaymentsProvider, StripePaymentsProviderOptions, TwilioSmsProvider, TwilioSmsProviderOptions };
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { ElevenLabsVoiceProvider } from "./elevenlabs-voice.js";
|
|
2
|
-
import { GoogleCloudStorageProvider } from "./gcs-storage.js";
|
|
3
|
-
import { GmailInboundProvider } from "./gmail-inbound.js";
|
|
4
|
-
import { GmailOutboundProvider } from "./gmail-outbound.js";
|
|
5
|
-
import { GoogleCalendarProvider } from "./google-calendar.js";
|
|
6
|
-
import { MistralLLMProvider } from "./mistral-llm.js";
|
|
7
|
-
import { MistralEmbeddingProvider } from "./mistral-embedding.js";
|
|
8
|
-
import { QdrantVectorProvider } from "./qdrant-vector.js";
|
|
9
|
-
import { StripePaymentsProvider } from "./stripe-payments.js";
|
|
10
|
-
import { PostmarkEmailProvider } from "./postmark-email.js";
|
|
11
|
-
import { TwilioSmsProvider } from "./twilio-sms.js";
|
|
12
|
-
import { PowensClient, PowensClientError } from "./powens-client.js";
|
|
13
|
-
import { PowensOpenBankingProvider } from "./powens-openbanking.js";
|
|
14
|
-
import { IntegrationProviderFactory } from "./provider-factory.js";
|
|
15
|
-
|
|
16
|
-
export { ElevenLabsVoiceProvider, GmailInboundProvider, GmailOutboundProvider, GoogleCalendarProvider, GoogleCloudStorageProvider, IntegrationProviderFactory, MistralEmbeddingProvider, MistralLLMProvider, PostmarkEmailProvider, PowensClient, PowensClientError, PowensOpenBankingProvider, QdrantVectorProvider, StripePaymentsProvider, TwilioSmsProvider };
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { EmbeddingDocument, EmbeddingProvider, EmbeddingResult } from "../embedding.js";
|
|
2
|
-
import { Mistral } from "@mistralai/mistralai";
|
|
3
|
-
|
|
4
|
-
//#region src/integrations/providers/impls/mistral-embedding.d.ts
|
|
5
|
-
interface MistralEmbeddingProviderOptions {
|
|
6
|
-
apiKey: string;
|
|
7
|
-
defaultModel?: string;
|
|
8
|
-
serverURL?: string;
|
|
9
|
-
client?: Mistral;
|
|
10
|
-
}
|
|
11
|
-
declare class MistralEmbeddingProvider implements EmbeddingProvider {
|
|
12
|
-
private readonly client;
|
|
13
|
-
private readonly defaultModel;
|
|
14
|
-
constructor(options: MistralEmbeddingProviderOptions);
|
|
15
|
-
embedDocuments(documents: EmbeddingDocument[], options?: {
|
|
16
|
-
model?: string;
|
|
17
|
-
}): Promise<EmbeddingResult[]>;
|
|
18
|
-
embedQuery(query: string, options?: {
|
|
19
|
-
model?: string;
|
|
20
|
-
}): Promise<EmbeddingResult>;
|
|
21
|
-
}
|
|
22
|
-
//#endregion
|
|
23
|
-
export { MistralEmbeddingProvider, MistralEmbeddingProviderOptions };
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { Mistral } from "@mistralai/mistralai";
|
|
2
|
-
|
|
3
|
-
//#region src/integrations/providers/impls/mistral-embedding.ts
|
|
4
|
-
var MistralEmbeddingProvider = class {
|
|
5
|
-
client;
|
|
6
|
-
defaultModel;
|
|
7
|
-
constructor(options) {
|
|
8
|
-
if (!options.apiKey) throw new Error("MistralEmbeddingProvider requires an apiKey");
|
|
9
|
-
this.client = options.client ?? new Mistral({
|
|
10
|
-
apiKey: options.apiKey,
|
|
11
|
-
serverURL: options.serverURL
|
|
12
|
-
});
|
|
13
|
-
this.defaultModel = options.defaultModel ?? "mistral-embed";
|
|
14
|
-
}
|
|
15
|
-
async embedDocuments(documents, options) {
|
|
16
|
-
if (documents.length === 0) return [];
|
|
17
|
-
const model = options?.model ?? this.defaultModel;
|
|
18
|
-
const response = await this.client.embeddings.create({
|
|
19
|
-
model,
|
|
20
|
-
inputs: documents.map((doc) => doc.text)
|
|
21
|
-
});
|
|
22
|
-
return response.data.map((item, index) => ({
|
|
23
|
-
id: documents[index]?.id ?? (item.index != null ? `embedding-${item.index}` : `embedding-${index}`),
|
|
24
|
-
vector: item.embedding ?? [],
|
|
25
|
-
dimensions: item.embedding?.length ?? 0,
|
|
26
|
-
model: response.model,
|
|
27
|
-
metadata: documents[index]?.metadata ? Object.fromEntries(Object.entries(documents[index]?.metadata ?? {}).map(([key, value]) => [key, String(value)])) : void 0
|
|
28
|
-
}));
|
|
29
|
-
}
|
|
30
|
-
async embedQuery(query, options) {
|
|
31
|
-
const [result] = await this.embedDocuments([{
|
|
32
|
-
id: "query",
|
|
33
|
-
text: query
|
|
34
|
-
}], options);
|
|
35
|
-
if (!result) throw new Error("Failed to compute embedding for query");
|
|
36
|
-
return result;
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
//#endregion
|
|
41
|
-
export { MistralEmbeddingProvider };
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { LLMChatOptions, LLMMessage, LLMProvider, LLMResponse, LLMStreamChunk } from "../llm.js";
|
|
2
|
-
import { Mistral } from "@mistralai/mistralai";
|
|
3
|
-
|
|
4
|
-
//#region src/integrations/providers/impls/mistral-llm.d.ts
|
|
5
|
-
interface MistralLLMProviderOptions {
|
|
6
|
-
apiKey: string;
|
|
7
|
-
defaultModel?: string;
|
|
8
|
-
serverURL?: string;
|
|
9
|
-
client?: Mistral;
|
|
10
|
-
userAgentSuffix?: string;
|
|
11
|
-
}
|
|
12
|
-
declare class MistralLLMProvider implements LLMProvider {
|
|
13
|
-
private readonly client;
|
|
14
|
-
private readonly defaultModel;
|
|
15
|
-
constructor(options: MistralLLMProviderOptions);
|
|
16
|
-
chat(messages: LLMMessage[], options?: LLMChatOptions): Promise<LLMResponse>;
|
|
17
|
-
stream(messages: LLMMessage[], options?: LLMChatOptions): AsyncIterable<LLMStreamChunk>;
|
|
18
|
-
countTokens(_messages: LLMMessage[]): Promise<{
|
|
19
|
-
promptTokens: number;
|
|
20
|
-
}>;
|
|
21
|
-
private buildChatRequest;
|
|
22
|
-
private buildLLMResponse;
|
|
23
|
-
private fromUsage;
|
|
24
|
-
private fromAssistantMessage;
|
|
25
|
-
private fromMistralToolCall;
|
|
26
|
-
private toMistralMessage;
|
|
27
|
-
private extractText;
|
|
28
|
-
private extractToolCalls;
|
|
29
|
-
}
|
|
30
|
-
//#endregion
|
|
31
|
-
export { MistralLLMProvider, MistralLLMProviderOptions };
|