@mastra/connect 1.1.0-alpha.1 → 1.1.0-alpha.3
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/index.cjs +295 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +295 -19
- package/dist/index.js.map +1 -1
- package/dist/providers/fireflies/tools/get-transcript.d.ts +4 -4
- package/dist/providers/fireflies/tools/get-transcript.d.ts.map +1 -1
- package/dist/providers/google-drive/tools/create-folder.d.ts.map +1 -1
- package/dist/providers/google-drive/tools/export-file.d.ts +32 -0
- package/dist/providers/google-drive/tools/export-file.d.ts.map +1 -0
- package/dist/providers/google-drive/tools/list-revisions.d.ts +44 -0
- package/dist/providers/google-drive/tools/list-revisions.d.ts.map +1 -0
- package/dist/providers/google-drive/tools/move-file.d.ts.map +1 -1
- package/dist/providers/google-drive/tools/upload-document.d.ts.map +1 -1
- package/dist/providers/google-drive/tools.d.ts.map +1 -1
- package/dist/runtime/platform-proxy.d.ts +1 -1
- package/dist/runtime/platform-proxy.d.ts.map +1 -1
- package/dist/tools.d.ts +16 -1
- package/dist/tools.d.ts.map +1 -1
- package/package.json +8 -8
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { tools } from './tools.js';
|
|
2
|
-
export type { ToolsOptions, ToolsProviderOptions, ToolsResolver, ToolsResolverContext, ToolsWithInput, } from './tools.js';
|
|
2
|
+
export type { ToolsOptions, ToolsOptionsInput, ToolsProviderOptions, ToolsResolver, ToolsResolverContext, ToolsWithInput, } from './tools.js';
|
|
3
3
|
export { channels } from './channels.js';
|
|
4
4
|
export type { ChannelsOptions, ChannelsProviderOptions, ChannelsResolver, ChannelsResolverContext, ResolvedChannels, } from './channels.js';
|
|
5
5
|
export type { ChannelProviderRegistration, ChannelInstance, ChannelRuntime } from './providers/channel-provider.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,YAAY,EACV,YAAY,EACZ,oBAAoB,EACpB,aAAa,EACb,oBAAoB,EACpB,cAAc,GACf,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,YAAY,EACV,eAAe,EACf,uBAAuB,EACvB,gBAAgB,EAChB,uBAAuB,EACvB,gBAAgB,GACjB,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,2BAA2B,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACpH,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,YAAY,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAC1D,YAAY,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACjG,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACpD,YAAY,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,YAAY,EACV,YAAY,EACZ,iBAAiB,EACjB,oBAAoB,EACpB,aAAa,EACb,oBAAoB,EACpB,cAAc,GACf,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,YAAY,EACV,eAAe,EACf,uBAAuB,EACvB,gBAAgB,EAChB,uBAAuB,EACvB,gBAAgB,GACjB,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,2BAA2B,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACpH,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,YAAY,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAC1D,YAAY,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACjG,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACpD,YAAY,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -7887,10 +7887,15 @@ const SentenceSchema = z.object({
|
|
|
7887
7887
|
speaker_name: z.string().nullish(),
|
|
7888
7888
|
speaker_id: z.string().nullish(),
|
|
7889
7889
|
raw_text: z.string().nullish(),
|
|
7890
|
-
start_time: z.
|
|
7891
|
-
end_time: z.
|
|
7890
|
+
start_time: z.number().nullish(),
|
|
7891
|
+
end_time: z.number().nullish(),
|
|
7892
7892
|
text: z.string().nullish()
|
|
7893
7893
|
});
|
|
7894
|
+
const ProviderSentenceSchema = SentenceSchema.extend({
|
|
7895
|
+
speaker_id: z.union([z.string(), z.number()]).nullish(),
|
|
7896
|
+
start_time: z.union([z.number(), z.string()]).nullish(),
|
|
7897
|
+
end_time: z.union([z.number(), z.string()]).nullish()
|
|
7898
|
+
});
|
|
7894
7899
|
const SummarySectionSchema = z.object({
|
|
7895
7900
|
title: z.string().nullish(),
|
|
7896
7901
|
content: z.string().nullish()
|
|
@@ -7957,7 +7962,7 @@ const AnalyticsSchema = z.object({
|
|
|
7957
7962
|
const TranscriptSchema = z.object({
|
|
7958
7963
|
id: z.string().nullish(),
|
|
7959
7964
|
title: z.string().nullish(),
|
|
7960
|
-
sentences: z.array(
|
|
7965
|
+
sentences: z.array(ProviderSentenceSchema).nullish(),
|
|
7961
7966
|
summary: ProviderSummarySchema$1.nullable().optional(),
|
|
7962
7967
|
speakers: z.array(SpeakerSchema).nullish(),
|
|
7963
7968
|
meeting_info: MeetingInfoSchema.nullable().optional(),
|
|
@@ -7985,6 +7990,22 @@ const getTranscriptOutputSchema = z.object({
|
|
|
7985
7990
|
function normalizeActionItems$1(actionItems) {
|
|
7986
7991
|
return Array.isArray(actionItems) ? actionItems.join("\n") : actionItems;
|
|
7987
7992
|
}
|
|
7993
|
+
function toFiniteNumber(value) {
|
|
7994
|
+
if (value == null) return void 0;
|
|
7995
|
+
if (typeof value === "number") return Number.isFinite(value) ? value : void 0;
|
|
7996
|
+
const trimmed = value.trim();
|
|
7997
|
+
if (trimmed === "") return void 0;
|
|
7998
|
+
const parsed = Number(trimmed);
|
|
7999
|
+
return Number.isFinite(parsed) ? parsed : void 0;
|
|
8000
|
+
}
|
|
8001
|
+
function normalizeSentence(sentence) {
|
|
8002
|
+
return {
|
|
8003
|
+
...sentence,
|
|
8004
|
+
speaker_id: sentence.speaker_id != null ? String(sentence.speaker_id) : sentence.speaker_id,
|
|
8005
|
+
start_time: toFiniteNumber(sentence.start_time),
|
|
8006
|
+
end_time: toFiniteNumber(sentence.end_time)
|
|
8007
|
+
};
|
|
8008
|
+
}
|
|
7988
8009
|
function getTranscriptTool(proxy) {
|
|
7989
8010
|
return createTool({
|
|
7990
8011
|
id: "fireflies_get_transcript",
|
|
@@ -8090,7 +8111,7 @@ function getTranscriptTool(proxy) {
|
|
|
8090
8111
|
return {
|
|
8091
8112
|
id: transcript.id ?? void 0,
|
|
8092
8113
|
title: transcript.title ?? void 0,
|
|
8093
|
-
sentences: transcript.sentences
|
|
8114
|
+
sentences: transcript.sentences ? transcript.sentences.map(normalizeSentence) : void 0,
|
|
8094
8115
|
summary: transcript.summary ? {
|
|
8095
8116
|
...transcript.summary,
|
|
8096
8117
|
action_items: transcript.summary.action_items != null ? normalizeActionItems$1(transcript.summary.action_items) : transcript.summary.action_items
|
|
@@ -19819,11 +19840,11 @@ function insertTextTool(proxy) {
|
|
|
19819
19840
|
}
|
|
19820
19841
|
//#endregion
|
|
19821
19842
|
//#region src/providers/google-docs/tools/list-revisions.ts
|
|
19822
|
-
const listRevisionsInputSchema = z.object({
|
|
19843
|
+
const listRevisionsInputSchema$1 = z.object({
|
|
19823
19844
|
documentId: z.string().describe("Google Docs document ID. Example: \"1Kj3d86Z-Sfd56YP4dImQ-ggMRyP2QZ_BRO33zOO224c\""),
|
|
19824
19845
|
pageToken: z.string().optional().describe("Pagination token from the previous response. Omit for the first page.")
|
|
19825
19846
|
});
|
|
19826
|
-
const LastModifyingUserSchema = z.object({
|
|
19847
|
+
const LastModifyingUserSchema$1 = z.object({
|
|
19827
19848
|
kind: z.string().optional(),
|
|
19828
19849
|
displayName: z.string().optional(),
|
|
19829
19850
|
photoLink: z.string().optional(),
|
|
@@ -19831,27 +19852,27 @@ const LastModifyingUserSchema = z.object({
|
|
|
19831
19852
|
permissionId: z.string().optional(),
|
|
19832
19853
|
emailAddress: z.string().optional()
|
|
19833
19854
|
});
|
|
19834
|
-
const RevisionSchema = z.object({
|
|
19855
|
+
const RevisionSchema$1 = z.object({
|
|
19835
19856
|
id: z.string(),
|
|
19836
19857
|
modifiedTime: z.string().optional(),
|
|
19837
|
-
lastModifyingUser: LastModifyingUserSchema.optional(),
|
|
19858
|
+
lastModifyingUser: LastModifyingUserSchema$1.optional(),
|
|
19838
19859
|
keepForever: z.boolean().optional(),
|
|
19839
19860
|
published: z.boolean().optional()
|
|
19840
19861
|
});
|
|
19841
|
-
const listRevisionsOutputSchema = z.object({
|
|
19842
|
-
revisions: z.array(RevisionSchema),
|
|
19862
|
+
const listRevisionsOutputSchema$1 = z.object({
|
|
19863
|
+
revisions: z.array(RevisionSchema$1),
|
|
19843
19864
|
nextPageToken: z.string().optional()
|
|
19844
19865
|
});
|
|
19845
|
-
const DriveRevisionsResponseSchema = z.object({
|
|
19866
|
+
const DriveRevisionsResponseSchema$1 = z.object({
|
|
19846
19867
|
nextPageToken: z.string().optional(),
|
|
19847
19868
|
revisions: z.array(z.unknown()).optional()
|
|
19848
19869
|
});
|
|
19849
|
-
function listRevisionsTool(proxy) {
|
|
19870
|
+
function listRevisionsTool$1(proxy) {
|
|
19850
19871
|
return createTool({
|
|
19851
19872
|
id: "google_docs_list_revisions",
|
|
19852
19873
|
description: "List the revision history for a Google Doc.",
|
|
19853
|
-
inputSchema: listRevisionsInputSchema,
|
|
19854
|
-
outputSchema: listRevisionsOutputSchema,
|
|
19874
|
+
inputSchema: listRevisionsInputSchema$1,
|
|
19875
|
+
outputSchema: listRevisionsOutputSchema$1,
|
|
19855
19876
|
execute: async (input, { requestContext }) => {
|
|
19856
19877
|
const platformProxy = proxy.withRequestContext(requestContext);
|
|
19857
19878
|
const response = await platformProxy.get({
|
|
@@ -19864,7 +19885,7 @@ function listRevisionsTool(proxy) {
|
|
|
19864
19885
|
baseUrlOverride: "https://www.googleapis.com",
|
|
19865
19886
|
retries: 3
|
|
19866
19887
|
});
|
|
19867
|
-
const parsedResponse = DriveRevisionsResponseSchema.safeParse(response.data);
|
|
19888
|
+
const parsedResponse = DriveRevisionsResponseSchema$1.safeParse(response.data);
|
|
19868
19889
|
if (!parsedResponse.success) throw new platformProxy.ActionError({
|
|
19869
19890
|
type: "invalid_response",
|
|
19870
19891
|
message: "Invalid response from Google Drive API"
|
|
@@ -19872,7 +19893,7 @@ function listRevisionsTool(proxy) {
|
|
|
19872
19893
|
const rawRevisions = parsedResponse.data.revisions ?? [];
|
|
19873
19894
|
const revisions = [];
|
|
19874
19895
|
for (const rawRevision of rawRevisions) {
|
|
19875
|
-
const parsedRevision = RevisionSchema.safeParse(rawRevision);
|
|
19896
|
+
const parsedRevision = RevisionSchema$1.safeParse(rawRevision);
|
|
19876
19897
|
if (parsedRevision.success) revisions.push(parsedRevision.data);
|
|
19877
19898
|
}
|
|
19878
19899
|
return {
|
|
@@ -20768,7 +20789,7 @@ function createGoogleDocsTools(options) {
|
|
|
20768
20789
|
google_docs_insert_table_row: insertTableRowTool$1(platformProxy),
|
|
20769
20790
|
google_docs_insert_table: insertTableTool(platformProxy),
|
|
20770
20791
|
google_docs_insert_text: insertTextTool(platformProxy),
|
|
20771
|
-
google_docs_list_revisions: listRevisionsTool(platformProxy),
|
|
20792
|
+
google_docs_list_revisions: listRevisionsTool$1(platformProxy),
|
|
20772
20793
|
google_docs_merge_table_cells: mergeTableCellsTool(platformProxy),
|
|
20773
20794
|
google_docs_pin_table_header_rows: pinTableHeaderRowsTool(platformProxy),
|
|
20774
20795
|
google_docs_replace_all_text: replaceAllTextTool(platformProxy),
|
|
@@ -20922,7 +20943,10 @@ function createFolderTool(proxy) {
|
|
|
20922
20943
|
if (input.parentId) requestBody["parents"] = [input.parentId];
|
|
20923
20944
|
const response = await platformProxy.post({
|
|
20924
20945
|
endpoint: "/drive/v3/files",
|
|
20925
|
-
params: {
|
|
20946
|
+
params: {
|
|
20947
|
+
supportsAllDrives: "true",
|
|
20948
|
+
fields: "id,name,mimeType,createdTime,parents"
|
|
20949
|
+
},
|
|
20926
20950
|
data: requestBody,
|
|
20927
20951
|
retries: 3
|
|
20928
20952
|
});
|
|
@@ -21121,6 +21145,56 @@ function emptyTrashTool(proxy) {
|
|
|
21121
21145
|
});
|
|
21122
21146
|
}
|
|
21123
21147
|
//#endregion
|
|
21148
|
+
//#region src/providers/google-drive/tools/export-file.ts
|
|
21149
|
+
const exportFileInputSchema = z.object({
|
|
21150
|
+
fileId: z.string().describe("The ID of the Google Workspace file to export (Doc, Sheet, Slide, etc.). Example: \"1Kj3d86Z-Sfd56YP4dImQ-ggMRyP2QZ_BRO33zOO224c\""),
|
|
21151
|
+
mimeType: z.enum([
|
|
21152
|
+
"application/pdf",
|
|
21153
|
+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
21154
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
21155
|
+
"application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
21156
|
+
"text/html",
|
|
21157
|
+
"text/plain",
|
|
21158
|
+
"text/csv",
|
|
21159
|
+
"application/rtf",
|
|
21160
|
+
"application/epub+zip"
|
|
21161
|
+
]).describe("The target MIME type for the export.")
|
|
21162
|
+
});
|
|
21163
|
+
const exportFileOutputSchema = z.object({
|
|
21164
|
+
fileId: z.string(),
|
|
21165
|
+
mimeType: z.string(),
|
|
21166
|
+
data: z.string().describe("The exported file encoded as a base64 string."),
|
|
21167
|
+
size: z.number().describe("The size of the exported data in bytes.")
|
|
21168
|
+
});
|
|
21169
|
+
function exportFileTool(proxy) {
|
|
21170
|
+
return createTool({
|
|
21171
|
+
id: "google_drive_export_file",
|
|
21172
|
+
description: "Export a Google Workspace file (Doc, Sheet, Slide, etc.) to the specified MIME type.",
|
|
21173
|
+
inputSchema: exportFileInputSchema,
|
|
21174
|
+
outputSchema: exportFileOutputSchema,
|
|
21175
|
+
execute: async (input, { requestContext }) => {
|
|
21176
|
+
const platformProxy = proxy.withRequestContext(requestContext);
|
|
21177
|
+
const rawData = (await platformProxy.get({
|
|
21178
|
+
endpoint: `/drive/v3/files/${encodeURIComponent(input.fileId)}/export`,
|
|
21179
|
+
params: { mimeType: input.mimeType },
|
|
21180
|
+
responseType: "arraybuffer",
|
|
21181
|
+
retries: 3
|
|
21182
|
+
})).data;
|
|
21183
|
+
if (typeof rawData !== "object" || rawData === null) throw new platformProxy.ActionError({
|
|
21184
|
+
type: "invalid_response",
|
|
21185
|
+
message: "Expected binary response from export API."
|
|
21186
|
+
});
|
|
21187
|
+
const buffer = Buffer.isBuffer(rawData) ? rawData : Buffer.from(rawData);
|
|
21188
|
+
return {
|
|
21189
|
+
fileId: input.fileId,
|
|
21190
|
+
mimeType: input.mimeType,
|
|
21191
|
+
data: buffer.toString("base64"),
|
|
21192
|
+
size: buffer.length
|
|
21193
|
+
};
|
|
21194
|
+
}
|
|
21195
|
+
});
|
|
21196
|
+
}
|
|
21197
|
+
//#endregion
|
|
21124
21198
|
//#region src/providers/google-drive/tools/find-file.ts
|
|
21125
21199
|
const findFileInputSchema = z.object({
|
|
21126
21200
|
query: z.string().optional().describe("Search query string. Uses Google Drive search query syntax. Example: \"name contains 'report'\" or \"mimeType = 'application/pdf'\". If not provided, returns all files."),
|
|
@@ -21946,6 +22020,70 @@ function listPermissionsTool(proxy) {
|
|
|
21946
22020
|
});
|
|
21947
22021
|
}
|
|
21948
22022
|
//#endregion
|
|
22023
|
+
//#region src/providers/google-drive/tools/list-revisions.ts
|
|
22024
|
+
const listRevisionsInputSchema = z.object({
|
|
22025
|
+
fileId: z.string().describe("The Drive file ID. Example: \"1Kj3d86Z-Sfd56YP4dImQ-ggMRyP2QZ_BRO33zOO224c\""),
|
|
22026
|
+
pageToken: z.string().optional().describe("Pagination token from the previous response. Omit for the first page.")
|
|
22027
|
+
});
|
|
22028
|
+
const LastModifyingUserSchema = z.object({
|
|
22029
|
+
kind: z.string().optional(),
|
|
22030
|
+
displayName: z.string().optional(),
|
|
22031
|
+
photoLink: z.string().optional(),
|
|
22032
|
+
me: z.boolean().optional(),
|
|
22033
|
+
permissionId: z.string().optional(),
|
|
22034
|
+
emailAddress: z.string().optional()
|
|
22035
|
+
});
|
|
22036
|
+
const RevisionSchema = z.object({
|
|
22037
|
+
id: z.string(),
|
|
22038
|
+
modifiedTime: z.string().optional(),
|
|
22039
|
+
lastModifyingUser: LastModifyingUserSchema.optional(),
|
|
22040
|
+
keepForever: z.boolean().optional(),
|
|
22041
|
+
published: z.boolean().optional()
|
|
22042
|
+
});
|
|
22043
|
+
const listRevisionsOutputSchema = z.object({
|
|
22044
|
+
revisions: z.array(RevisionSchema),
|
|
22045
|
+
nextPageToken: z.string().optional()
|
|
22046
|
+
});
|
|
22047
|
+
const DriveRevisionsResponseSchema = z.object({
|
|
22048
|
+
nextPageToken: z.string().optional(),
|
|
22049
|
+
revisions: z.array(z.unknown()).optional()
|
|
22050
|
+
});
|
|
22051
|
+
function listRevisionsTool(proxy) {
|
|
22052
|
+
return createTool({
|
|
22053
|
+
id: "google_drive_list_revisions",
|
|
22054
|
+
description: "List the revision history for a Drive file.",
|
|
22055
|
+
inputSchema: listRevisionsInputSchema,
|
|
22056
|
+
outputSchema: listRevisionsOutputSchema,
|
|
22057
|
+
execute: async (input, { requestContext }) => {
|
|
22058
|
+
const platformProxy = proxy.withRequestContext(requestContext);
|
|
22059
|
+
const response = await platformProxy.get({
|
|
22060
|
+
endpoint: `/drive/v3/files/${encodeURIComponent(input.fileId)}/revisions`,
|
|
22061
|
+
params: {
|
|
22062
|
+
fields: "nextPageToken,revisions(id,modifiedTime,lastModifyingUser,keepForever,published)",
|
|
22063
|
+
pageSize: "100",
|
|
22064
|
+
...input.pageToken !== void 0 && { pageToken: input.pageToken }
|
|
22065
|
+
},
|
|
22066
|
+
retries: 3
|
|
22067
|
+
});
|
|
22068
|
+
const parsedResponse = DriveRevisionsResponseSchema.safeParse(response.data);
|
|
22069
|
+
if (!parsedResponse.success) throw new platformProxy.ActionError({
|
|
22070
|
+
type: "invalid_response",
|
|
22071
|
+
message: "Invalid response from Google Drive API"
|
|
22072
|
+
});
|
|
22073
|
+
const rawRevisions = parsedResponse.data.revisions ?? [];
|
|
22074
|
+
const revisions = [];
|
|
22075
|
+
for (const rawRevision of rawRevisions) {
|
|
22076
|
+
const parsedRevision = RevisionSchema.safeParse(rawRevision);
|
|
22077
|
+
if (parsedRevision.success) revisions.push(parsedRevision.data);
|
|
22078
|
+
}
|
|
22079
|
+
return {
|
|
22080
|
+
revisions,
|
|
22081
|
+
...parsedResponse.data.nextPageToken !== void 0 && { nextPageToken: parsedResponse.data.nextPageToken }
|
|
22082
|
+
};
|
|
22083
|
+
}
|
|
22084
|
+
});
|
|
22085
|
+
}
|
|
22086
|
+
//#endregion
|
|
21949
22087
|
//#region src/providers/google-drive/tools/move-file.ts
|
|
21950
22088
|
const moveFileInputSchema = z.object({
|
|
21951
22089
|
fileId: z.string().describe("The ID of the file to move. Example: \"1mD3ukEAmRqo8u0RF_Cr6IJl9f_uWTYH03vesDhB5Svw\""),
|
|
@@ -21971,6 +22109,7 @@ function moveFileTool(proxy) {
|
|
|
21971
22109
|
params: {
|
|
21972
22110
|
addParents: input.toFolderId,
|
|
21973
22111
|
removeParents: input.fromFolderId,
|
|
22112
|
+
supportsAllDrives: "true",
|
|
21974
22113
|
fields: "id,name,mimeType,parents"
|
|
21975
22114
|
},
|
|
21976
22115
|
retries: 3
|
|
@@ -22320,7 +22459,10 @@ function uploadDocumentTool(proxy) {
|
|
|
22320
22459
|
if (input.folderId) metadataBody["parents"] = [input.folderId];
|
|
22321
22460
|
const createResponse = await platformProxy.post({
|
|
22322
22461
|
endpoint: "/drive/v3/files",
|
|
22323
|
-
params: {
|
|
22462
|
+
params: {
|
|
22463
|
+
supportsAllDrives: "true",
|
|
22464
|
+
fields: "id,name,mimeType,webViewLink,webContentLink"
|
|
22465
|
+
},
|
|
22324
22466
|
data: metadataBody,
|
|
22325
22467
|
retries: 3
|
|
22326
22468
|
});
|
|
@@ -22335,6 +22477,7 @@ function uploadDocumentTool(proxy) {
|
|
|
22335
22477
|
endpoint: `/upload/drive/v3/files/${fileId}`,
|
|
22336
22478
|
params: {
|
|
22337
22479
|
uploadType: "media",
|
|
22480
|
+
supportsAllDrives: "true",
|
|
22338
22481
|
fields: "id,name,mimeType,webViewLink,webContentLink"
|
|
22339
22482
|
},
|
|
22340
22483
|
headers: { "Content-Type": input.mimeType },
|
|
@@ -22345,6 +22488,7 @@ function uploadDocumentTool(proxy) {
|
|
|
22345
22488
|
const status = error?.response?.status;
|
|
22346
22489
|
if (typeof status === "number" && status >= 400 && status < 500) await platformProxy.delete({
|
|
22347
22490
|
endpoint: `/drive/v3/files/${fileId}`,
|
|
22491
|
+
params: { supportsAllDrives: "true" },
|
|
22348
22492
|
retries: 3
|
|
22349
22493
|
}).catch(() => void 0);
|
|
22350
22494
|
throw error;
|
|
@@ -22381,6 +22525,7 @@ function createGoogleDriveTools(options) {
|
|
|
22381
22525
|
google_drive_delete_permission: deletePermissionTool(platformProxy),
|
|
22382
22526
|
google_drive_delete_shared_drive: deleteSharedDriveTool(platformProxy),
|
|
22383
22527
|
google_drive_empty_trash: emptyTrashTool(platformProxy),
|
|
22528
|
+
google_drive_export_file: exportFileTool(platformProxy),
|
|
22384
22529
|
google_drive_find_file: findFileTool(platformProxy),
|
|
22385
22530
|
google_drive_find_folder: findFolderTool(platformProxy),
|
|
22386
22531
|
google_drive_get_about: getAboutTool(platformProxy),
|
|
@@ -22395,6 +22540,7 @@ function createGoogleDriveTools(options) {
|
|
|
22395
22540
|
google_drive_list_drives: listDrivesTool(platformProxy),
|
|
22396
22541
|
google_drive_list_files_non_unified: listFilesNonUnifiedTool(platformProxy),
|
|
22397
22542
|
google_drive_list_permissions: listPermissionsTool(platformProxy),
|
|
22543
|
+
google_drive_list_revisions: listRevisionsTool(platformProxy),
|
|
22398
22544
|
google_drive_move_file: moveFileTool(platformProxy),
|
|
22399
22545
|
google_drive_unhide_shared_drive: unhideSharedDriveTool(platformProxy),
|
|
22400
22546
|
google_drive_update_comment: updateCommentTool$2(platformProxy),
|
|
@@ -75102,8 +75248,14 @@ let nextResolverId = 0;
|
|
|
75102
75248
|
* Expected provider absence is silently skipped. Actionable per-integration
|
|
75103
75249
|
* problems during resolution (needs re-auth or ambiguity) are downgraded to
|
|
75104
75250
|
* warn-and-skip so one bad integration never takes down the whole toolset.
|
|
75251
|
+
*
|
|
75252
|
+
* Pass a callback instead of an options object to vary options per request
|
|
75253
|
+
* (see {@link ToolsOptionsInput}). With the callback form, configuration
|
|
75254
|
+
* validation runs at the first resolution that produces a given options
|
|
75255
|
+
* value — still failing loudly — instead of at call time.
|
|
75105
75256
|
*/
|
|
75106
75257
|
function tools(options = {}) {
|
|
75258
|
+
if (typeof options === "function") return dynamicTools(options);
|
|
75107
75259
|
const projectId = options.projectId?.trim() || process.env.MASTRA_PROJECT_ID?.trim();
|
|
75108
75260
|
if (!projectId) throw new MastraConnectError("missing_project_id", "Missing project id: set MASTRA_PROJECT_ID or pass projectId.");
|
|
75109
75261
|
if (options.ttlMs !== void 0 && (!Number.isFinite(options.ttlMs) || options.ttlMs < 0)) throw new MastraConnectError("invalid_options", `Invalid ttlMs (${options.ttlMs}): expected a finite number of milliseconds >= 0.`);
|
|
@@ -75211,6 +75363,130 @@ function tools(options = {}) {
|
|
|
75211
75363
|
return resolver;
|
|
75212
75364
|
}
|
|
75213
75365
|
/**
|
|
75366
|
+
* Most distinct options values a callback-form resolver keeps live caches
|
|
75367
|
+
* (and MCP clients) for at once. Callbacks are expected to produce a small,
|
|
75368
|
+
* closed set of option shapes (one per role, say); the cap exists so a
|
|
75369
|
+
* callback that accidentally derives options from unbounded per-request data
|
|
75370
|
+
* cannot leak an MCP client per request. Eviction is least-recently-used and
|
|
75371
|
+
* disconnects the evicted variant's transports.
|
|
75372
|
+
*/
|
|
75373
|
+
const MAX_OPTION_VARIANTS = 32;
|
|
75374
|
+
/**
|
|
75375
|
+
* Builds the callback-form resolver: each resolution invokes `getOptions`
|
|
75376
|
+
* with the request context, then delegates to a memoized static resolver for
|
|
75377
|
+
* that options value, so every distinct options value gets its own snapshot
|
|
75378
|
+
* cache with the normal TTL / stale-while-revalidate semantics. Options
|
|
75379
|
+
* validation happens when a value is first seen (inside `tools()`), so
|
|
75380
|
+
* configuration errors fail that resolution loudly instead of being
|
|
75381
|
+
* swallowed.
|
|
75382
|
+
*/
|
|
75383
|
+
function dynamicTools(getOptions) {
|
|
75384
|
+
const variants = /* @__PURE__ */ new Map();
|
|
75385
|
+
let closing;
|
|
75386
|
+
const disconnectEvicted = (entry) => {
|
|
75387
|
+
entry.resolver.disconnect().catch((error) => {
|
|
75388
|
+
console.warn(`[@mastra/connect] Failed to disconnect evicted tools variant: ${error instanceof Error ? error.message : String(error)}`);
|
|
75389
|
+
});
|
|
75390
|
+
};
|
|
75391
|
+
const releaseVariant = (entry) => {
|
|
75392
|
+
entry.inUse -= 1;
|
|
75393
|
+
if (entry.evicted && entry.inUse === 0) disconnectEvicted(entry);
|
|
75394
|
+
};
|
|
75395
|
+
const acquireVariant = async (ctx) => {
|
|
75396
|
+
if (closing) await closing;
|
|
75397
|
+
const options = await getOptions(ctx);
|
|
75398
|
+
if (closing) await closing;
|
|
75399
|
+
if (typeof options !== "object" || options === null || Array.isArray(options)) throw new MastraConnectError("invalid_options", `The tools() options callback must return a ToolsOptions object, got ${options === null ? "null" : Array.isArray(options) ? "an array" : typeof options}.`);
|
|
75400
|
+
const key = hashOptions(options);
|
|
75401
|
+
const existing = variants.get(key);
|
|
75402
|
+
if (existing) {
|
|
75403
|
+
variants.delete(key);
|
|
75404
|
+
variants.set(key, existing);
|
|
75405
|
+
existing.inUse += 1;
|
|
75406
|
+
return existing;
|
|
75407
|
+
}
|
|
75408
|
+
const entry = {
|
|
75409
|
+
resolver: tools(options),
|
|
75410
|
+
inUse: 1,
|
|
75411
|
+
evicted: false
|
|
75412
|
+
};
|
|
75413
|
+
variants.set(key, entry);
|
|
75414
|
+
if (variants.size > MAX_OPTION_VARIANTS) {
|
|
75415
|
+
const [oldestKey, oldest] = variants.entries().next().value;
|
|
75416
|
+
variants.delete(oldestKey);
|
|
75417
|
+
console.warn(`[@mastra/connect] tools() options callback produced more than ${MAX_OPTION_VARIANTS} distinct options values; evicting the least recently used variant. Derive options from a small, closed set of inputs (e.g. roles), not per-request data.`);
|
|
75418
|
+
oldest.evicted = true;
|
|
75419
|
+
if (oldest.inUse === 0) disconnectEvicted(oldest);
|
|
75420
|
+
}
|
|
75421
|
+
return entry;
|
|
75422
|
+
};
|
|
75423
|
+
const resolve = async (ctx) => {
|
|
75424
|
+
const entry = await acquireVariant(ctx);
|
|
75425
|
+
try {
|
|
75426
|
+
return await entry.resolver(ctx);
|
|
75427
|
+
} finally {
|
|
75428
|
+
releaseVariant(entry);
|
|
75429
|
+
}
|
|
75430
|
+
};
|
|
75431
|
+
const resolver = Object.assign(resolve, {
|
|
75432
|
+
refresh: async () => {
|
|
75433
|
+
const entry = await acquireVariant(void 0);
|
|
75434
|
+
try {
|
|
75435
|
+
return await entry.resolver.refresh();
|
|
75436
|
+
} finally {
|
|
75437
|
+
releaseVariant(entry);
|
|
75438
|
+
}
|
|
75439
|
+
},
|
|
75440
|
+
disconnect: () => {
|
|
75441
|
+
closing ??= (async () => {
|
|
75442
|
+
try {
|
|
75443
|
+
const all = Array.from(variants.values());
|
|
75444
|
+
variants.clear();
|
|
75445
|
+
await Promise.allSettled(all.map((entry) => entry.resolver.disconnect()));
|
|
75446
|
+
} finally {
|
|
75447
|
+
closing = void 0;
|
|
75448
|
+
}
|
|
75449
|
+
})();
|
|
75450
|
+
return closing;
|
|
75451
|
+
},
|
|
75452
|
+
with: (extra) => withExtraTools(resolver, extra)
|
|
75453
|
+
});
|
|
75454
|
+
return resolver;
|
|
75455
|
+
}
|
|
75456
|
+
/** Identity registry for non-serializable option values (e.g. a custom `client.fetch`). */
|
|
75457
|
+
const functionIdentity = /* @__PURE__ */ new WeakMap();
|
|
75458
|
+
let nextFunctionIdentity = 0;
|
|
75459
|
+
/**
|
|
75460
|
+
* Stable key for an options value: JSON with sorted object keys, so two
|
|
75461
|
+
* callbacks returning structurally equal options share one cached variant.
|
|
75462
|
+
* Functions (and other non-plain values) hash by identity — the same
|
|
75463
|
+
* instance maps to the same key, two different instances to different keys —
|
|
75464
|
+
* which is the safe direction: at worst a duplicate cache entry, never a
|
|
75465
|
+
* false merge of different configurations.
|
|
75466
|
+
*/
|
|
75467
|
+
function hashOptions(options) {
|
|
75468
|
+
const byIdentity = (value) => {
|
|
75469
|
+
let id = functionIdentity.get(value);
|
|
75470
|
+
if (id === void 0) {
|
|
75471
|
+
id = ++nextFunctionIdentity;
|
|
75472
|
+
functionIdentity.set(value, id);
|
|
75473
|
+
}
|
|
75474
|
+
return `__identity_${id}__`;
|
|
75475
|
+
};
|
|
75476
|
+
const encode = (value) => {
|
|
75477
|
+
if (value === void 0) return "__undefined__";
|
|
75478
|
+
if (typeof value === "function") return byIdentity(value);
|
|
75479
|
+
if (Array.isArray(value)) return value.map(encode);
|
|
75480
|
+
if (typeof value === "object" && value !== null) {
|
|
75481
|
+
const proto = Object.getPrototypeOf(value);
|
|
75482
|
+
if (proto !== Object.prototype && proto !== null) return byIdentity(value);
|
|
75483
|
+
return Object.fromEntries(Object.entries(value).filter(([, entryValue]) => entryValue !== void 0).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([entryKey, entryValue]) => [entryKey, encode(entryValue)]));
|
|
75484
|
+
}
|
|
75485
|
+
return value;
|
|
75486
|
+
};
|
|
75487
|
+
return JSON.stringify(encode(options));
|
|
75488
|
+
}
|
|
75489
|
+
/**
|
|
75214
75490
|
* Builds the resolver `.with()` returns: resolutions merge the base
|
|
75215
75491
|
* resolver's tools with `extra` (extra wins on key collision), cache handles
|
|
75216
75492
|
* delegate to the base, and further `.with()` calls chain.
|