integrate-sdk 0.9.55 → 0.9.58
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/adapters/index.js +2440 -31
- package/dist/adapters/solid-start.js +2440 -31
- package/dist/adapters/svelte-kit.js +2440 -31
- package/dist/ai/anthropic.d.ts.map +1 -1
- package/dist/ai/anthropic.js +11 -2
- package/dist/ai/google.d.ts.map +1 -1
- package/dist/ai/google.js +11 -2
- package/dist/ai/index.js +16 -7
- package/dist/ai/openai.d.ts.map +1 -1
- package/dist/ai/openai.js +11 -2
- package/dist/ai/utils.d.ts +21 -0
- package/dist/ai/utils.d.ts.map +1 -1
- package/dist/ai/utils.js +10 -0
- package/dist/ai/vercel-ai.d.ts.map +1 -1
- package/dist/ai/vercel-ai.js +10 -1
- package/dist/database/adapters/drizzle.d.ts +23 -0
- package/dist/database/adapters/drizzle.d.ts.map +1 -0
- package/dist/database/adapters/drizzle.js +646 -0
- package/dist/database/adapters/mongodb.d.ts +17 -0
- package/dist/database/adapters/mongodb.d.ts.map +1 -0
- package/dist/database/adapters/mongodb.js +643 -0
- package/dist/database/adapters/prisma.d.ts +18 -0
- package/dist/database/adapters/prisma.d.ts.map +1 -0
- package/dist/database/adapters/prisma.js +679 -0
- package/dist/database/index.d.ts +9 -0
- package/dist/database/index.d.ts.map +1 -0
- package/dist/database/index.js +1167 -0
- package/dist/index.js +77 -31
- package/dist/integrations.js +77 -31
- package/dist/server.js +3633 -42
- package/dist/src/ai/anthropic.d.ts.map +1 -1
- package/dist/src/ai/google.d.ts.map +1 -1
- package/dist/src/ai/openai.d.ts.map +1 -1
- package/dist/src/ai/utils.d.ts +21 -0
- package/dist/src/ai/utils.d.ts.map +1 -1
- package/dist/src/ai/vercel-ai.d.ts.map +1 -1
- package/dist/src/client.d.ts +4 -2
- package/dist/src/client.d.ts.map +1 -1
- package/dist/src/config/types.d.ts +44 -1
- package/dist/src/config/types.d.ts.map +1 -1
- package/dist/src/database/adapters/drizzle.d.ts +23 -0
- package/dist/src/database/adapters/drizzle.d.ts.map +1 -0
- package/dist/src/database/adapters/mongodb.d.ts +17 -0
- package/dist/src/database/adapters/mongodb.d.ts.map +1 -0
- package/dist/src/database/adapters/prisma.d.ts +18 -0
- package/dist/src/database/adapters/prisma.d.ts.map +1 -0
- package/dist/src/database/factory.d.ts +9 -0
- package/dist/src/database/factory.d.ts.map +1 -0
- package/dist/src/database/index.d.ts +9 -0
- package/dist/src/database/index.d.ts.map +1 -0
- package/dist/src/database/schemas/drizzle.d.ts +508 -0
- package/dist/src/database/schemas/drizzle.d.ts.map +1 -0
- package/dist/src/database/token-store.d.ts +28 -0
- package/dist/src/database/token-store.d.ts.map +1 -0
- package/dist/src/database/trigger-store.d.ts +23 -0
- package/dist/src/database/trigger-store.d.ts.map +1 -0
- package/dist/src/database/types.d.ts +132 -0
- package/dist/src/database/types.d.ts.map +1 -0
- package/dist/src/integrations/integration-docs-metadata.d.ts +40 -0
- package/dist/src/integrations/integration-docs-metadata.d.ts.map +1 -0
- package/dist/src/server.d.ts +4 -3
- package/dist/src/server.d.ts.map +1 -1
- package/package.json +32 -5
package/dist/index.js
CHANGED
|
@@ -1675,6 +1675,25 @@ function toConfiguredIntegrationWithToolMetadata(integration, toolMetadata) {
|
|
|
1675
1675
|
};
|
|
1676
1676
|
}
|
|
1677
1677
|
|
|
1678
|
+
// src/database/token-store.ts
|
|
1679
|
+
var USABLE_ACCESS_TOKEN_BUFFER_MS = 30 * 1000;
|
|
1680
|
+
var MIN_MEANINGFUL_EXPIRY_MS = Date.UTC(2000, 0, 1);
|
|
1681
|
+
async function listConnectedProviders(configuredIntegrationIds, getProviderToken, context) {
|
|
1682
|
+
if (!context.userId || configuredIntegrationIds.length === 0) {
|
|
1683
|
+
return [];
|
|
1684
|
+
}
|
|
1685
|
+
const connected = [];
|
|
1686
|
+
await Promise.all(configuredIntegrationIds.map(async (provider) => {
|
|
1687
|
+
try {
|
|
1688
|
+
const token = await getProviderToken(provider, undefined, context);
|
|
1689
|
+
if (token?.accessToken || typeof token?.refreshToken === "string" && token.refreshToken.length > 0) {
|
|
1690
|
+
connected.push(provider);
|
|
1691
|
+
}
|
|
1692
|
+
} catch {}
|
|
1693
|
+
}));
|
|
1694
|
+
return connected.sort();
|
|
1695
|
+
}
|
|
1696
|
+
|
|
1678
1697
|
// src/client.ts
|
|
1679
1698
|
init_errors();
|
|
1680
1699
|
|
|
@@ -3824,20 +3843,32 @@ class MCPClientBase {
|
|
|
3824
3843
|
getEnabledTools() {
|
|
3825
3844
|
return Array.from(this.availableTools.values()).filter((tool) => this.enabledToolNames.has(tool.name));
|
|
3826
3845
|
}
|
|
3827
|
-
async getEnabledToolsAsync() {
|
|
3828
|
-
|
|
3829
|
-
|
|
3846
|
+
async getEnabledToolsAsync(options) {
|
|
3847
|
+
const targetIntegrationIds = await this.resolveTargetIntegrationIds(options);
|
|
3848
|
+
if (targetIntegrationIds.size === 0) {
|
|
3849
|
+
return [];
|
|
3830
3850
|
}
|
|
3831
|
-
|
|
3832
|
-
|
|
3851
|
+
const filterToTargets = (tools2) => this.filterToolsToIntegrations(tools2, targetIntegrationIds);
|
|
3852
|
+
const hasCompleteCache = () => {
|
|
3853
|
+
for (const integration of this.integrations) {
|
|
3854
|
+
if (!targetIntegrationIds.has(integration.id))
|
|
3855
|
+
continue;
|
|
3856
|
+
for (const toolName of integration.tools) {
|
|
3857
|
+
if (!this.enabledToolNames.has(toolName))
|
|
3858
|
+
continue;
|
|
3859
|
+
if (!this.availableTools.has(toolName))
|
|
3860
|
+
return false;
|
|
3861
|
+
}
|
|
3862
|
+
}
|
|
3863
|
+
return this.availableTools.size > 0;
|
|
3864
|
+
};
|
|
3865
|
+
if (this.availableTools.size > 0 && hasCompleteCache()) {
|
|
3866
|
+
return filterToTargets(this.getEnabledTools());
|
|
3833
3867
|
}
|
|
3834
3868
|
const tools = [];
|
|
3835
|
-
const integrationIds = new Set;
|
|
3836
|
-
for (const integration of this.integrations) {
|
|
3837
|
-
integrationIds.add(integration.id);
|
|
3838
|
-
}
|
|
3839
3869
|
const { parallelWithLimit: parallelWithLimit2 } = await Promise.resolve().then(() => exports_concurrency);
|
|
3840
|
-
const
|
|
3870
|
+
const concurrency = options?.fetchConcurrency ?? 8;
|
|
3871
|
+
const integrationToolsResults = await parallelWithLimit2(Array.from(targetIntegrationIds), async (integrationId) => {
|
|
3841
3872
|
try {
|
|
3842
3873
|
const response = await this.callServerToolInternal("list_tools_by_integration", {
|
|
3843
3874
|
integration: integrationId
|
|
@@ -3848,25 +3879,14 @@ class MCPClientBase {
|
|
|
3848
3879
|
if (item.type === "text" && item.text) {
|
|
3849
3880
|
try {
|
|
3850
3881
|
const parsed = JSON.parse(item.text);
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
}
|
|
3860
|
-
}
|
|
3861
|
-
} else if (parsed.tools && Array.isArray(parsed.tools)) {
|
|
3862
|
-
for (const tool of parsed.tools) {
|
|
3863
|
-
if (tool.name && tool.inputSchema) {
|
|
3864
|
-
integrationTools.push({
|
|
3865
|
-
name: tool.name,
|
|
3866
|
-
description: tool.description,
|
|
3867
|
-
inputSchema: tool.inputSchema
|
|
3868
|
-
});
|
|
3869
|
-
}
|
|
3882
|
+
const parsedTools = Array.isArray(parsed) ? parsed : parsed.tools && Array.isArray(parsed.tools) ? parsed.tools : [];
|
|
3883
|
+
for (const tool of parsedTools) {
|
|
3884
|
+
if (tool.name && tool.inputSchema) {
|
|
3885
|
+
integrationTools.push({
|
|
3886
|
+
name: tool.name,
|
|
3887
|
+
description: tool.description,
|
|
3888
|
+
inputSchema: tool.inputSchema
|
|
3889
|
+
});
|
|
3870
3890
|
}
|
|
3871
3891
|
}
|
|
3872
3892
|
} catch {}
|
|
@@ -3878,14 +3898,40 @@ class MCPClientBase {
|
|
|
3878
3898
|
logger5.error(`Failed to fetch tools for integration ${integrationId}:`, error);
|
|
3879
3899
|
return [];
|
|
3880
3900
|
}
|
|
3881
|
-
},
|
|
3901
|
+
}, concurrency);
|
|
3882
3902
|
for (const integrationTools of integrationToolsResults) {
|
|
3883
3903
|
tools.push(...integrationTools);
|
|
3884
3904
|
}
|
|
3885
3905
|
for (const tool of tools) {
|
|
3886
3906
|
this.availableTools.set(tool.name, tool);
|
|
3887
3907
|
}
|
|
3888
|
-
return tools.filter((tool) => this.enabledToolNames.has(tool.name));
|
|
3908
|
+
return filterToTargets(tools.filter((tool) => this.enabledToolNames.has(tool.name)));
|
|
3909
|
+
}
|
|
3910
|
+
async resolveTargetIntegrationIds(options) {
|
|
3911
|
+
const configuredIds = this.integrations.map((integration) => integration.id);
|
|
3912
|
+
const configuredSet = new Set(configuredIds);
|
|
3913
|
+
if (options?.integrationIds && options.integrationIds.length > 0) {
|
|
3914
|
+
return new Set(options.integrationIds.filter((id) => configuredSet.has(id)));
|
|
3915
|
+
}
|
|
3916
|
+
if (options?.connectedOnly && options.context?.userId) {
|
|
3917
|
+
const connected = await listConnectedProviders(configuredIds, (provider, email, context) => this.oauthManager.getProviderToken(provider, email, context), options.context);
|
|
3918
|
+
return new Set(connected);
|
|
3919
|
+
}
|
|
3920
|
+
return configuredSet;
|
|
3921
|
+
}
|
|
3922
|
+
filterToolsToIntegrations(tools, integrationIds) {
|
|
3923
|
+
if (integrationIds.size === 0) {
|
|
3924
|
+
return [];
|
|
3925
|
+
}
|
|
3926
|
+
const allowedNames = new Set;
|
|
3927
|
+
for (const integration of this.integrations) {
|
|
3928
|
+
if (!integrationIds.has(integration.id))
|
|
3929
|
+
continue;
|
|
3930
|
+
for (const toolName of integration.tools) {
|
|
3931
|
+
allowedNames.add(toolName);
|
|
3932
|
+
}
|
|
3933
|
+
}
|
|
3934
|
+
return tools.filter((tool) => this.enabledToolNames.has(tool.name) && allowedNames.has(tool.name));
|
|
3889
3935
|
}
|
|
3890
3936
|
getOAuthConfig(integrationId) {
|
|
3891
3937
|
const integration = this.integrations.find((p) => p.id === integrationId);
|
package/dist/integrations.js
CHANGED
|
@@ -1675,6 +1675,25 @@ function toConfiguredIntegrationWithToolMetadata(integration, toolMetadata) {
|
|
|
1675
1675
|
};
|
|
1676
1676
|
}
|
|
1677
1677
|
|
|
1678
|
+
// src/database/token-store.ts
|
|
1679
|
+
var USABLE_ACCESS_TOKEN_BUFFER_MS = 30 * 1000;
|
|
1680
|
+
var MIN_MEANINGFUL_EXPIRY_MS = Date.UTC(2000, 0, 1);
|
|
1681
|
+
async function listConnectedProviders(configuredIntegrationIds, getProviderToken, context) {
|
|
1682
|
+
if (!context.userId || configuredIntegrationIds.length === 0) {
|
|
1683
|
+
return [];
|
|
1684
|
+
}
|
|
1685
|
+
const connected = [];
|
|
1686
|
+
await Promise.all(configuredIntegrationIds.map(async (provider) => {
|
|
1687
|
+
try {
|
|
1688
|
+
const token = await getProviderToken(provider, undefined, context);
|
|
1689
|
+
if (token?.accessToken || typeof token?.refreshToken === "string" && token.refreshToken.length > 0) {
|
|
1690
|
+
connected.push(provider);
|
|
1691
|
+
}
|
|
1692
|
+
} catch {}
|
|
1693
|
+
}));
|
|
1694
|
+
return connected.sort();
|
|
1695
|
+
}
|
|
1696
|
+
|
|
1678
1697
|
// src/client.ts
|
|
1679
1698
|
init_errors();
|
|
1680
1699
|
|
|
@@ -3824,20 +3843,32 @@ class MCPClientBase {
|
|
|
3824
3843
|
getEnabledTools() {
|
|
3825
3844
|
return Array.from(this.availableTools.values()).filter((tool) => this.enabledToolNames.has(tool.name));
|
|
3826
3845
|
}
|
|
3827
|
-
async getEnabledToolsAsync() {
|
|
3828
|
-
|
|
3829
|
-
|
|
3846
|
+
async getEnabledToolsAsync(options) {
|
|
3847
|
+
const targetIntegrationIds = await this.resolveTargetIntegrationIds(options);
|
|
3848
|
+
if (targetIntegrationIds.size === 0) {
|
|
3849
|
+
return [];
|
|
3830
3850
|
}
|
|
3831
|
-
|
|
3832
|
-
|
|
3851
|
+
const filterToTargets = (tools2) => this.filterToolsToIntegrations(tools2, targetIntegrationIds);
|
|
3852
|
+
const hasCompleteCache = () => {
|
|
3853
|
+
for (const integration of this.integrations) {
|
|
3854
|
+
if (!targetIntegrationIds.has(integration.id))
|
|
3855
|
+
continue;
|
|
3856
|
+
for (const toolName of integration.tools) {
|
|
3857
|
+
if (!this.enabledToolNames.has(toolName))
|
|
3858
|
+
continue;
|
|
3859
|
+
if (!this.availableTools.has(toolName))
|
|
3860
|
+
return false;
|
|
3861
|
+
}
|
|
3862
|
+
}
|
|
3863
|
+
return this.availableTools.size > 0;
|
|
3864
|
+
};
|
|
3865
|
+
if (this.availableTools.size > 0 && hasCompleteCache()) {
|
|
3866
|
+
return filterToTargets(this.getEnabledTools());
|
|
3833
3867
|
}
|
|
3834
3868
|
const tools = [];
|
|
3835
|
-
const integrationIds = new Set;
|
|
3836
|
-
for (const integration of this.integrations) {
|
|
3837
|
-
integrationIds.add(integration.id);
|
|
3838
|
-
}
|
|
3839
3869
|
const { parallelWithLimit: parallelWithLimit2 } = await Promise.resolve().then(() => exports_concurrency);
|
|
3840
|
-
const
|
|
3870
|
+
const concurrency = options?.fetchConcurrency ?? 8;
|
|
3871
|
+
const integrationToolsResults = await parallelWithLimit2(Array.from(targetIntegrationIds), async (integrationId) => {
|
|
3841
3872
|
try {
|
|
3842
3873
|
const response = await this.callServerToolInternal("list_tools_by_integration", {
|
|
3843
3874
|
integration: integrationId
|
|
@@ -3848,25 +3879,14 @@ class MCPClientBase {
|
|
|
3848
3879
|
if (item.type === "text" && item.text) {
|
|
3849
3880
|
try {
|
|
3850
3881
|
const parsed = JSON.parse(item.text);
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
}
|
|
3860
|
-
}
|
|
3861
|
-
} else if (parsed.tools && Array.isArray(parsed.tools)) {
|
|
3862
|
-
for (const tool of parsed.tools) {
|
|
3863
|
-
if (tool.name && tool.inputSchema) {
|
|
3864
|
-
integrationTools.push({
|
|
3865
|
-
name: tool.name,
|
|
3866
|
-
description: tool.description,
|
|
3867
|
-
inputSchema: tool.inputSchema
|
|
3868
|
-
});
|
|
3869
|
-
}
|
|
3882
|
+
const parsedTools = Array.isArray(parsed) ? parsed : parsed.tools && Array.isArray(parsed.tools) ? parsed.tools : [];
|
|
3883
|
+
for (const tool of parsedTools) {
|
|
3884
|
+
if (tool.name && tool.inputSchema) {
|
|
3885
|
+
integrationTools.push({
|
|
3886
|
+
name: tool.name,
|
|
3887
|
+
description: tool.description,
|
|
3888
|
+
inputSchema: tool.inputSchema
|
|
3889
|
+
});
|
|
3870
3890
|
}
|
|
3871
3891
|
}
|
|
3872
3892
|
} catch {}
|
|
@@ -3878,14 +3898,40 @@ class MCPClientBase {
|
|
|
3878
3898
|
logger5.error(`Failed to fetch tools for integration ${integrationId}:`, error);
|
|
3879
3899
|
return [];
|
|
3880
3900
|
}
|
|
3881
|
-
},
|
|
3901
|
+
}, concurrency);
|
|
3882
3902
|
for (const integrationTools of integrationToolsResults) {
|
|
3883
3903
|
tools.push(...integrationTools);
|
|
3884
3904
|
}
|
|
3885
3905
|
for (const tool of tools) {
|
|
3886
3906
|
this.availableTools.set(tool.name, tool);
|
|
3887
3907
|
}
|
|
3888
|
-
return tools.filter((tool) => this.enabledToolNames.has(tool.name));
|
|
3908
|
+
return filterToTargets(tools.filter((tool) => this.enabledToolNames.has(tool.name)));
|
|
3909
|
+
}
|
|
3910
|
+
async resolveTargetIntegrationIds(options) {
|
|
3911
|
+
const configuredIds = this.integrations.map((integration) => integration.id);
|
|
3912
|
+
const configuredSet = new Set(configuredIds);
|
|
3913
|
+
if (options?.integrationIds && options.integrationIds.length > 0) {
|
|
3914
|
+
return new Set(options.integrationIds.filter((id) => configuredSet.has(id)));
|
|
3915
|
+
}
|
|
3916
|
+
if (options?.connectedOnly && options.context?.userId) {
|
|
3917
|
+
const connected = await listConnectedProviders(configuredIds, (provider, email, context) => this.oauthManager.getProviderToken(provider, email, context), options.context);
|
|
3918
|
+
return new Set(connected);
|
|
3919
|
+
}
|
|
3920
|
+
return configuredSet;
|
|
3921
|
+
}
|
|
3922
|
+
filterToolsToIntegrations(tools, integrationIds) {
|
|
3923
|
+
if (integrationIds.size === 0) {
|
|
3924
|
+
return [];
|
|
3925
|
+
}
|
|
3926
|
+
const allowedNames = new Set;
|
|
3927
|
+
for (const integration of this.integrations) {
|
|
3928
|
+
if (!integrationIds.has(integration.id))
|
|
3929
|
+
continue;
|
|
3930
|
+
for (const toolName of integration.tools) {
|
|
3931
|
+
allowedNames.add(toolName);
|
|
3932
|
+
}
|
|
3933
|
+
}
|
|
3934
|
+
return tools.filter((tool) => this.enabledToolNames.has(tool.name) && allowedNames.has(tool.name));
|
|
3889
3935
|
}
|
|
3890
3936
|
getOAuthConfig(integrationId) {
|
|
3891
3937
|
const integration = this.integrations.find((p) => p.id === integrationId);
|