@contractspec/integration.providers-impls 3.8.8 → 3.8.10
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/analytics.js +1 -2
- package/dist/calendar.js +1 -2
- package/dist/database.js +1 -2
- package/dist/email.js +1 -2
- package/dist/embedding.js +1 -2
- package/dist/health.js +1 -2
- package/dist/impls/async-event-queue.js +1 -48
- package/dist/impls/composio-fallback-resolver.js +1 -579
- package/dist/impls/composio-mcp.js +1 -163
- package/dist/impls/composio-proxies.js +1 -310
- package/dist/impls/composio-sdk.js +1 -77
- package/dist/impls/composio-types.js +1 -53
- package/dist/impls/elevenlabs-voice.js +1 -104
- package/dist/impls/fal-voice.js +1 -117
- package/dist/impls/fathom-meeting-recorder.js +2 -289
- package/dist/impls/fathom-meeting-recorder.mapper.js +1 -107
- package/dist/impls/fathom-meeting-recorder.utils.js +1 -74
- package/dist/impls/fathom-meeting-recorder.webhooks.js +1 -31
- package/dist/impls/fireflies-meeting-recorder.js +5 -203
- package/dist/impls/fireflies-meeting-recorder.queries.js +4 -14
- package/dist/impls/fireflies-meeting-recorder.utils.js +1 -44
- package/dist/impls/gcs-storage.js +1 -99
- package/dist/impls/gmail-inbound.js +1 -229
- package/dist/impls/gmail-outbound.js +25 -137
- package/dist/impls/google-calendar.js +1 -193
- package/dist/impls/gradium-voice.js +1 -95
- package/dist/impls/granola-meeting-recorder.js +3 -514
- package/dist/impls/granola-meeting-recorder.mcp.js +1 -280
- package/dist/impls/health/base-health-provider.js +1 -617
- package/dist/impls/health/hybrid-health-providers.js +1 -1089
- package/dist/impls/health/official-health-providers.js +1 -969
- package/dist/impls/health/provider-normalizers.js +1 -288
- package/dist/impls/health/providers.js +1 -1095
- package/dist/impls/health-provider-factory.js +1 -1309
- package/dist/impls/index.js +42 -7448
- package/dist/impls/jira.js +1 -126
- package/dist/impls/linear.js +1 -85
- package/dist/impls/messaging-github.js +1 -111
- package/dist/impls/messaging-slack.js +1 -81
- package/dist/impls/messaging-telegram.js +1 -48
- package/dist/impls/messaging-whatsapp-meta.js +1 -53
- package/dist/impls/messaging-whatsapp-twilio.js +1 -83
- package/dist/impls/mistral-conversational.js +2 -477
- package/dist/impls/mistral-conversational.session.js +2 -207
- package/dist/impls/mistral-embedding.js +1 -45
- package/dist/impls/mistral-llm.js +1 -271
- package/dist/impls/mistral-stt.js +1 -168
- package/dist/impls/notion.js +1 -162
- package/dist/impls/posthog-reader.js +1 -161
- package/dist/impls/posthog-utils.js +1 -40
- package/dist/impls/posthog.js +1 -324
- package/dist/impls/postmark-email.js +1 -62
- package/dist/impls/powens-client.js +1 -197
- package/dist/impls/powens-openbanking.js +1 -428
- package/dist/impls/provider-factory.js +18 -6268
- package/dist/impls/qdrant-vector.js +1 -80
- package/dist/impls/stripe-payments.js +1 -230
- package/dist/impls/supabase-psql.js +1 -152
- package/dist/impls/supabase-vector.js +9 -298
- package/dist/impls/tldv-meeting-recorder.js +2 -147
- package/dist/impls/twilio-sms.js +1 -67
- package/dist/index.js +42 -7495
- package/dist/llm.js +1 -2
- package/dist/meeting-recorder.js +1 -2
- package/dist/messaging.js +1 -2
- package/dist/node/analytics.js +1 -2
- package/dist/node/calendar.js +1 -2
- package/dist/node/database.js +1 -2
- package/dist/node/email.js +1 -2
- package/dist/node/embedding.js +1 -2
- package/dist/node/health.js +1 -2
- package/dist/node/impls/async-event-queue.js +1 -49
- package/dist/node/impls/composio-fallback-resolver.js +1 -580
- package/dist/node/impls/composio-mcp.js +1 -164
- package/dist/node/impls/composio-proxies.js +1 -311
- package/dist/node/impls/composio-sdk.js +1 -78
- package/dist/node/impls/composio-types.js +1 -54
- package/dist/node/impls/elevenlabs-voice.js +1 -105
- package/dist/node/impls/fal-voice.js +1 -118
- package/dist/node/impls/fathom-meeting-recorder.js +2 -290
- package/dist/node/impls/fathom-meeting-recorder.mapper.js +1 -108
- package/dist/node/impls/fathom-meeting-recorder.utils.js +1 -75
- package/dist/node/impls/fathom-meeting-recorder.webhooks.js +1 -32
- package/dist/node/impls/fireflies-meeting-recorder.js +5 -204
- package/dist/node/impls/fireflies-meeting-recorder.queries.js +4 -15
- package/dist/node/impls/fireflies-meeting-recorder.utils.js +1 -45
- package/dist/node/impls/gcs-storage.js +1 -100
- package/dist/node/impls/gmail-inbound.js +1 -230
- package/dist/node/impls/gmail-outbound.js +25 -138
- package/dist/node/impls/google-calendar.js +1 -194
- package/dist/node/impls/gradium-voice.js +1 -96
- package/dist/node/impls/granola-meeting-recorder.js +3 -515
- package/dist/node/impls/granola-meeting-recorder.mcp.js +1 -281
- package/dist/node/impls/health/base-health-provider.js +1 -618
- package/dist/node/impls/health/hybrid-health-providers.js +1 -1090
- package/dist/node/impls/health/official-health-providers.js +1 -970
- package/dist/node/impls/health/provider-normalizers.js +1 -289
- package/dist/node/impls/health/providers.js +1 -1096
- package/dist/node/impls/health-provider-factory.js +1 -1310
- package/dist/node/impls/index.js +42 -7449
- package/dist/node/impls/jira.js +1 -127
- package/dist/node/impls/linear.js +1 -86
- package/dist/node/impls/messaging-github.js +1 -112
- package/dist/node/impls/messaging-slack.js +1 -82
- package/dist/node/impls/messaging-telegram.js +1 -49
- package/dist/node/impls/messaging-whatsapp-meta.js +1 -54
- package/dist/node/impls/messaging-whatsapp-twilio.js +1 -84
- package/dist/node/impls/mistral-conversational.js +2 -478
- package/dist/node/impls/mistral-conversational.session.js +2 -208
- package/dist/node/impls/mistral-embedding.js +1 -46
- package/dist/node/impls/mistral-llm.js +1 -272
- package/dist/node/impls/mistral-stt.js +1 -169
- package/dist/node/impls/notion.js +1 -163
- package/dist/node/impls/posthog-reader.js +1 -162
- package/dist/node/impls/posthog-utils.js +1 -41
- package/dist/node/impls/posthog.js +1 -325
- package/dist/node/impls/postmark-email.js +1 -63
- package/dist/node/impls/powens-client.js +1 -198
- package/dist/node/impls/powens-openbanking.js +1 -429
- package/dist/node/impls/provider-factory.js +18 -6269
- package/dist/node/impls/qdrant-vector.js +1 -81
- package/dist/node/impls/stripe-payments.js +1 -231
- package/dist/node/impls/supabase-psql.js +1 -153
- package/dist/node/impls/supabase-vector.js +9 -299
- package/dist/node/impls/tldv-meeting-recorder.js +2 -148
- package/dist/node/impls/twilio-sms.js +1 -68
- package/dist/node/index.js +42 -7496
- package/dist/node/llm.js +1 -2
- package/dist/node/meeting-recorder.js +1 -2
- package/dist/node/messaging.js +1 -2
- package/dist/node/openbanking.js +1 -2
- package/dist/node/payments.js +1 -2
- package/dist/node/project-management.js +1 -2
- package/dist/node/secrets/provider.js +1 -14
- package/dist/node/sms.js +1 -2
- package/dist/node/storage.js +1 -2
- package/dist/node/vector-store.js +1 -2
- package/dist/node/voice.js +1 -2
- package/dist/openbanking.js +1 -2
- package/dist/payments.js +1 -2
- package/dist/project-management.js +1 -2
- package/dist/secrets/provider.js +1 -13
- package/dist/sms.js +1 -2
- package/dist/storage.js +1 -2
- package/dist/vector-store.js +1 -2
- package/dist/voice.js +1 -2
- package/package.json +17 -17
|
@@ -1,281 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
3
|
-
|
|
4
|
-
// src/impls/granola-meeting-recorder.mcp.ts
|
|
5
|
-
var UNKNOWN_EMAIL = "unknown@granola.local";
|
|
6
|
-
var EPOCH = "1970-01-01T00:00:00.000Z";
|
|
7
|
-
|
|
8
|
-
class GranolaMcpClient {
|
|
9
|
-
requestId = 0;
|
|
10
|
-
mcpUrl;
|
|
11
|
-
mcpAccessToken;
|
|
12
|
-
mcpHeaders;
|
|
13
|
-
fetchFn;
|
|
14
|
-
constructor(options) {
|
|
15
|
-
this.mcpUrl = options.mcpUrl;
|
|
16
|
-
this.mcpAccessToken = options.mcpAccessToken;
|
|
17
|
-
this.mcpHeaders = options.mcpHeaders;
|
|
18
|
-
this.fetchFn = options.fetchFn ?? fetch;
|
|
19
|
-
}
|
|
20
|
-
async callTool(name, args) {
|
|
21
|
-
const headers = {
|
|
22
|
-
"Content-Type": "application/json",
|
|
23
|
-
...this.mcpHeaders ?? {}
|
|
24
|
-
};
|
|
25
|
-
if (this.mcpAccessToken) {
|
|
26
|
-
headers.Authorization = `Bearer ${this.mcpAccessToken}`;
|
|
27
|
-
}
|
|
28
|
-
const response = await this.fetchFn(this.mcpUrl, {
|
|
29
|
-
method: "POST",
|
|
30
|
-
headers,
|
|
31
|
-
body: JSON.stringify({
|
|
32
|
-
jsonrpc: "2.0",
|
|
33
|
-
id: ++this.requestId,
|
|
34
|
-
method: "tools/call",
|
|
35
|
-
params: {
|
|
36
|
-
name,
|
|
37
|
-
arguments: args
|
|
38
|
-
}
|
|
39
|
-
})
|
|
40
|
-
});
|
|
41
|
-
if (!response.ok) {
|
|
42
|
-
const message = await safeReadText(response);
|
|
43
|
-
throw new Error(`Granola MCP error (${response.status}): ${message}`);
|
|
44
|
-
}
|
|
45
|
-
const rpc = await response.json();
|
|
46
|
-
if (rpc.error) {
|
|
47
|
-
throw new Error(rpc.error.message ?? "Granola MCP returned an error.");
|
|
48
|
-
}
|
|
49
|
-
return extractRpcResult(rpc);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
function normalizeMcpListResult(payload) {
|
|
53
|
-
const root = asObject(payload);
|
|
54
|
-
const list = asArray(payload) ?? asArray(root?.notes) ?? asArray(root?.meetings) ?? asArray(root?.items) ?? asArray(root?.results) ?? asArray(root?.data) ?? [];
|
|
55
|
-
const notes = list.map((item) => mapSummaryItem(item)).filter((item) => Boolean(item));
|
|
56
|
-
return {
|
|
57
|
-
notes,
|
|
58
|
-
nextCursor: readString(root, ["nextCursor", "next_cursor", "cursor"]),
|
|
59
|
-
hasMore: readBoolean(root, ["hasMore", "has_more"])
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
function normalizeMcpMeeting(payload, targetMeetingId) {
|
|
63
|
-
const root = asObject(payload);
|
|
64
|
-
const candidates = asArray(payload) ?? asArray(root?.meetings) ?? asArray(root?.notes) ?? asArray(root?.items) ?? asArray(root?.results) ?? asArray(root?.data);
|
|
65
|
-
if (candidates?.length) {
|
|
66
|
-
const selected = candidates.find((item) => readId(item) === targetMeetingId) ?? candidates.find((item) => String(readId(item) ?? "").includes(targetMeetingId)) ?? candidates[0];
|
|
67
|
-
return selected ? mapMeetingItem(selected) : undefined;
|
|
68
|
-
}
|
|
69
|
-
const direct = mapMeetingItem(payload);
|
|
70
|
-
if (direct && direct.id === targetMeetingId) {
|
|
71
|
-
return direct;
|
|
72
|
-
}
|
|
73
|
-
return direct;
|
|
74
|
-
}
|
|
75
|
-
function normalizeMcpTranscript(payload) {
|
|
76
|
-
const root = asObject(payload);
|
|
77
|
-
const list = asArray(payload) ?? asArray(root?.transcript) ?? asArray(root?.segments) ?? asArray(root?.items) ?? asArray(root?.data) ?? [];
|
|
78
|
-
if (list.length === 0 && typeof payload === "string") {
|
|
79
|
-
return [
|
|
80
|
-
{
|
|
81
|
-
text: payload,
|
|
82
|
-
start_time: "00:00:00",
|
|
83
|
-
end_time: "00:00:00"
|
|
84
|
-
}
|
|
85
|
-
];
|
|
86
|
-
}
|
|
87
|
-
return list.map((item) => mapTranscriptSegment(item)).filter((item) => Boolean(item));
|
|
88
|
-
}
|
|
89
|
-
function extractRpcResult(rpc) {
|
|
90
|
-
const result = rpc.result;
|
|
91
|
-
if (!result)
|
|
92
|
-
return null;
|
|
93
|
-
if (result.structuredContent !== undefined)
|
|
94
|
-
return result.structuredContent;
|
|
95
|
-
if (result.data !== undefined)
|
|
96
|
-
return result.data;
|
|
97
|
-
const textPayload = result.content?.find((entry) => entry?.type === "text")?.text;
|
|
98
|
-
if (!textPayload)
|
|
99
|
-
return result;
|
|
100
|
-
try {
|
|
101
|
-
return JSON.parse(textPayload);
|
|
102
|
-
} catch {
|
|
103
|
-
return textPayload;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
function mapSummaryItem(value) {
|
|
107
|
-
const object = asObject(value);
|
|
108
|
-
if (!object)
|
|
109
|
-
return;
|
|
110
|
-
const id = readId(object);
|
|
111
|
-
if (!id)
|
|
112
|
-
return;
|
|
113
|
-
const owner = mapOwner(object);
|
|
114
|
-
return {
|
|
115
|
-
id,
|
|
116
|
-
title: readString(object, ["title", "name", "meeting_title"]) ?? null,
|
|
117
|
-
owner,
|
|
118
|
-
created_at: readString(object, ["created_at", "createdAt", "date", "meeting_date"]) ?? EPOCH
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
function mapMeetingItem(value) {
|
|
122
|
-
const summary = mapSummaryItem(value);
|
|
123
|
-
if (!summary)
|
|
124
|
-
return;
|
|
125
|
-
const object = asObject(value) ?? {};
|
|
126
|
-
const attendees = asArray(object.attendees) ?? asArray(object.participants) ?? asArray(object.invitees) ?? [];
|
|
127
|
-
const mappedAttendees = attendees.map((entry) => mapUser(entry)).filter((entry) => Boolean(entry));
|
|
128
|
-
const folders = asArray(object.folder_membership) ?? asArray(object.folders) ?? [];
|
|
129
|
-
const folderMembership = folders.map((entry, index) => mapFolder(entry, index)).filter((entry) => Boolean(entry));
|
|
130
|
-
const calendarEvent = asObject(object.calendar_event) ? {
|
|
131
|
-
event_title: readString(asObject(object.calendar_event), [
|
|
132
|
-
"event_title",
|
|
133
|
-
"title"
|
|
134
|
-
]) ?? null,
|
|
135
|
-
invitees: mappedAttendees.map((attendee) => ({
|
|
136
|
-
email: attendee.email
|
|
137
|
-
})),
|
|
138
|
-
organiser: readString(asObject(object.calendar_event), [
|
|
139
|
-
"organiser",
|
|
140
|
-
"organizer"
|
|
141
|
-
]) ?? summary.owner.email,
|
|
142
|
-
calendar_event_id: readString(asObject(object.calendar_event), [
|
|
143
|
-
"calendar_event_id",
|
|
144
|
-
"id"
|
|
145
|
-
]) ?? null,
|
|
146
|
-
scheduled_start_time: readString(asObject(object.calendar_event), [
|
|
147
|
-
"scheduled_start_time",
|
|
148
|
-
"start_time",
|
|
149
|
-
"start"
|
|
150
|
-
]) ?? null,
|
|
151
|
-
scheduled_end_time: readString(asObject(object.calendar_event), [
|
|
152
|
-
"scheduled_end_time",
|
|
153
|
-
"end_time",
|
|
154
|
-
"end"
|
|
155
|
-
]) ?? null
|
|
156
|
-
} : null;
|
|
157
|
-
const transcript = normalizeMcpTranscript(object.transcript ?? object.segments);
|
|
158
|
-
return {
|
|
159
|
-
...summary,
|
|
160
|
-
calendar_event: calendarEvent,
|
|
161
|
-
attendees: mappedAttendees,
|
|
162
|
-
folder_membership: folderMembership,
|
|
163
|
-
summary_text: readString(object, ["summary_text", "summary", "enhanced_notes"]) ?? "",
|
|
164
|
-
transcript: transcript.length ? transcript : null
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
function mapTranscriptSegment(value) {
|
|
168
|
-
const object = asObject(value);
|
|
169
|
-
if (!object) {
|
|
170
|
-
if (typeof value !== "string")
|
|
171
|
-
return;
|
|
172
|
-
return {
|
|
173
|
-
text: value,
|
|
174
|
-
start_time: "00:00:00",
|
|
175
|
-
end_time: "00:00:00"
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
const text = readString(object, ["text", "content", "utterance"]);
|
|
179
|
-
if (!text)
|
|
180
|
-
return;
|
|
181
|
-
const speakerSource = readString(asObject(object.speaker), ["source", "name"]) ?? readString(object, ["speaker", "speaker_name"]);
|
|
182
|
-
return {
|
|
183
|
-
speaker: speakerSource ? { source: speakerSource } : undefined,
|
|
184
|
-
text,
|
|
185
|
-
start_time: readString(object, ["start_time", "startTime", "timestamp", "time"]) ?? "00:00:00",
|
|
186
|
-
end_time: readString(object, ["end_time", "endTime"]) ?? "00:00:00"
|
|
187
|
-
};
|
|
188
|
-
}
|
|
189
|
-
function mapOwner(object) {
|
|
190
|
-
const ownerObject = asObject(object.owner) ?? asObject(object.organizer) ?? asObject(object.organiser);
|
|
191
|
-
const attendee = asArray(object.attendees)?.[0] ?? asArray(object.participants)?.[0] ?? asArray(object.invitees)?.[0];
|
|
192
|
-
const ownerCandidate = ownerObject ?? asObject(attendee) ?? {};
|
|
193
|
-
return {
|
|
194
|
-
name: readString(ownerCandidate, ["name", "displayName"]) ?? null,
|
|
195
|
-
email: readString(ownerCandidate, ["email"]) ?? UNKNOWN_EMAIL
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
function mapUser(value) {
|
|
199
|
-
if (typeof value === "string") {
|
|
200
|
-
return {
|
|
201
|
-
name: null,
|
|
202
|
-
email: value
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
const object = asObject(value);
|
|
206
|
-
if (!object)
|
|
207
|
-
return;
|
|
208
|
-
const email = readString(object, ["email"]);
|
|
209
|
-
if (!email)
|
|
210
|
-
return;
|
|
211
|
-
return {
|
|
212
|
-
name: readString(object, ["name", "displayName"]) ?? null,
|
|
213
|
-
email
|
|
214
|
-
};
|
|
215
|
-
}
|
|
216
|
-
function mapFolder(value, index) {
|
|
217
|
-
const object = asObject(value);
|
|
218
|
-
if (!object)
|
|
219
|
-
return;
|
|
220
|
-
const id = readString(object, ["id"]) ?? `folder-${index}`;
|
|
221
|
-
const name = readString(object, ["name"]) ?? "Folder";
|
|
222
|
-
return {
|
|
223
|
-
id,
|
|
224
|
-
object: "folder",
|
|
225
|
-
name
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
function readId(value) {
|
|
229
|
-
const object = asObject(value);
|
|
230
|
-
if (!object)
|
|
231
|
-
return;
|
|
232
|
-
return readString(object, [
|
|
233
|
-
"id",
|
|
234
|
-
"meeting_id",
|
|
235
|
-
"meetingId",
|
|
236
|
-
"note_id",
|
|
237
|
-
"noteId"
|
|
238
|
-
]);
|
|
239
|
-
}
|
|
240
|
-
function readString(object, keys) {
|
|
241
|
-
if (!object)
|
|
242
|
-
return;
|
|
243
|
-
for (const key of keys) {
|
|
244
|
-
const value = object[key];
|
|
245
|
-
if (typeof value === "string" && value.trim().length > 0) {
|
|
246
|
-
return value;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
return;
|
|
250
|
-
}
|
|
251
|
-
function readBoolean(object, keys) {
|
|
252
|
-
if (!object)
|
|
253
|
-
return;
|
|
254
|
-
for (const key of keys) {
|
|
255
|
-
const value = object[key];
|
|
256
|
-
if (typeof value === "boolean")
|
|
257
|
-
return value;
|
|
258
|
-
}
|
|
259
|
-
return;
|
|
260
|
-
}
|
|
261
|
-
function asObject(value) {
|
|
262
|
-
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
263
|
-
return;
|
|
264
|
-
return value;
|
|
265
|
-
}
|
|
266
|
-
function asArray(value) {
|
|
267
|
-
return Array.isArray(value) ? value : undefined;
|
|
268
|
-
}
|
|
269
|
-
async function safeReadText(response) {
|
|
270
|
-
try {
|
|
271
|
-
return await response.text();
|
|
272
|
-
} catch {
|
|
273
|
-
return response.statusText;
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
export {
|
|
277
|
-
normalizeMcpTranscript,
|
|
278
|
-
normalizeMcpMeeting,
|
|
279
|
-
normalizeMcpListResult,
|
|
280
|
-
GranolaMcpClient
|
|
281
|
-
};
|
|
1
|
+
import{createRequire as h}from"node:module";var S=h(import.meta.url);class y{requestId=0;mcpUrl;mcpAccessToken;mcpHeaders;fetchFn;constructor(e){this.mcpUrl=e.mcpUrl,this.mcpAccessToken=e.mcpAccessToken,this.mcpHeaders=e.mcpHeaders,this.fetchFn=e.fetchFn??fetch}async callTool(e,n){let t={"Content-Type":"application/json",...this.mcpHeaders??{}};if(this.mcpAccessToken)t.Authorization=`Bearer ${this.mcpAccessToken}`;let r=await this.fetchFn(this.mcpUrl,{method:"POST",headers:t,body:JSON.stringify({jsonrpc:"2.0",id:++this.requestId,method:"tools/call",params:{name:e,arguments:n}})});if(!r.ok){let d=await N(r);throw Error(`Granola MCP error (${r.status}): ${d}`)}let a=await r.json();if(a.error)throw Error(a.error.message??"Granola MCP returned an error.");return w(a)}}function v(e){let n=i(e);return{notes:(o(e)??o(n?.notes)??o(n?.meetings)??o(n?.items)??o(n?.results)??o(n?.data)??[]).map((a)=>p(a)).filter((a)=>Boolean(a)),nextCursor:s(n,["nextCursor","next_cursor","cursor"]),hasMore:M(n,["hasMore","has_more"])}}function O(e,n){let t=i(e),r=o(e)??o(t?.meetings)??o(t?.notes)??o(t?.items)??o(t?.results)??o(t?.data);if(r?.length){let d=r.find((u)=>l(u)===n)??r.find((u)=>String(l(u)??"").includes(n))??r[0];return d?f(d):void 0}let a=f(e);if(a&&a.id===n)return a;return a}function k(e){let n=i(e),t=o(e)??o(n?.transcript)??o(n?.segments)??o(n?.items)??o(n?.data)??[];if(t.length===0&&typeof e==="string")return[{text:e,start_time:"00:00:00",end_time:"00:00:00"}];return t.map((r)=>G(r)).filter((r)=>Boolean(r))}function w(e){let n=e.result;if(!n)return null;if(n.structuredContent!==void 0)return n.structuredContent;if(n.data!==void 0)return n.data;let t=n.content?.find((r)=>r?.type==="text")?.text;if(!t)return n;try{return JSON.parse(t)}catch{return t}}function p(e){let n=i(e);if(!n)return;let t=l(n);if(!t)return;let r=x(n);return{id:t,title:s(n,["title","name","meeting_title"])??null,owner:r,created_at:s(n,["created_at","createdAt","date","meeting_date"])??"1970-01-01T00:00:00.000Z"}}function f(e){let n=p(e);if(!n)return;let t=i(e)??{},a=(o(t.attendees)??o(t.participants)??o(t.invitees)??[]).map((c)=>R(c)).filter((c)=>Boolean(c)),u=(o(t.folder_membership)??o(t.folders)??[]).map((c,_)=>T(c,_)).filter((c)=>Boolean(c)),g=i(t.calendar_event)?{event_title:s(i(t.calendar_event),["event_title","title"])??null,invitees:a.map((c)=>({email:c.email})),organiser:s(i(t.calendar_event),["organiser","organizer"])??n.owner.email,calendar_event_id:s(i(t.calendar_event),["calendar_event_id","id"])??null,scheduled_start_time:s(i(t.calendar_event),["scheduled_start_time","start_time","start"])??null,scheduled_end_time:s(i(t.calendar_event),["scheduled_end_time","end_time","end"])??null}:null,m=k(t.transcript??t.segments);return{...n,calendar_event:g,attendees:a,folder_membership:u,summary_text:s(t,["summary_text","summary","enhanced_notes"])??"",transcript:m.length?m:null}}function G(e){let n=i(e);if(!n){if(typeof e!=="string")return;return{text:e,start_time:"00:00:00",end_time:"00:00:00"}}let t=s(n,["text","content","utterance"]);if(!t)return;let r=s(i(n.speaker),["source","name"])??s(n,["speaker","speaker_name"]);return{speaker:r?{source:r}:void 0,text:t,start_time:s(n,["start_time","startTime","timestamp","time"])??"00:00:00",end_time:s(n,["end_time","endTime"])??"00:00:00"}}function x(e){let n=i(e.owner)??i(e.organizer)??i(e.organiser),t=o(e.attendees)?.[0]??o(e.participants)?.[0]??o(e.invitees)?.[0],r=n??i(t)??{};return{name:s(r,["name","displayName"])??null,email:s(r,["email"])??"unknown@granola.local"}}function R(e){if(typeof e==="string")return{name:null,email:e};let n=i(e);if(!n)return;let t=s(n,["email"]);if(!t)return;return{name:s(n,["name","displayName"])??null,email:t}}function T(e,n){let t=i(e);if(!t)return;let r=s(t,["id"])??`folder-${n}`,a=s(t,["name"])??"Folder";return{id:r,object:"folder",name:a}}function l(e){let n=i(e);if(!n)return;return s(n,["id","meeting_id","meetingId","note_id","noteId"])}function s(e,n){if(!e)return;for(let t of n){let r=e[t];if(typeof r==="string"&&r.trim().length>0)return r}return}function M(e,n){if(!e)return;for(let t of n){let r=e[t];if(typeof r==="boolean")return r}return}function i(e){if(!e||typeof e!=="object"||Array.isArray(e))return;return e}function o(e){return Array.isArray(e)?e:void 0}async function N(e){try{return await e.text()}catch{return e.statusText}}export{k as normalizeMcpTranscript,O as normalizeMcpMeeting,v as normalizeMcpListResult,y as GranolaMcpClient};
|