integrate-sdk 0.9.56 → 0.9.61
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 +80 -35
- package/dist/adapters/solid-start.js +80 -35
- package/dist/adapters/svelte-kit.js +80 -35
- 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 +93 -7
- package/dist/ai/openai.d.ts.map +1 -1
- package/dist/ai/openai.js +11 -2
- package/dist/ai/tool-cache.d.ts +50 -0
- package/dist/ai/tool-cache.d.ts.map +1 -0
- package/dist/ai/utils.d.ts +26 -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 +87 -1
- package/dist/database/index.d.ts +1 -1
- package/dist/database/index.d.ts.map +1 -1
- package/dist/database/index.js +39 -0
- package/dist/index.js +142 -32
- package/dist/integrations.js +142 -32
- package/dist/react.d.ts +2 -2
- package/dist/react.d.ts.map +1 -1
- package/dist/react.js +86 -0
- package/dist/server.js +578 -189
- 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/tool-cache.d.ts +50 -0
- package/dist/src/ai/tool-cache.d.ts.map +1 -0
- package/dist/src/ai/utils.d.ts +26 -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 +5 -5
- package/dist/src/client.d.ts.map +1 -1
- package/dist/src/config/types.d.ts +30 -0
- package/dist/src/config/types.d.ts.map +1 -1
- package/dist/src/database/index.d.ts +1 -1
- package/dist/src/database/index.d.ts.map +1 -1
- package/dist/src/database/token-store.d.ts +10 -0
- package/dist/src/database/token-store.d.ts.map +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/integrations/bundle.d.ts +18 -0
- package/dist/src/integrations/bundle.d.ts.map +1 -0
- package/dist/src/react/hooks.d.ts +16 -0
- package/dist/src/react/hooks.d.ts.map +1 -1
- package/dist/src/server.d.ts +13 -1
- package/dist/src/server.d.ts.map +1 -1
- package/dist/src/utils/normalize-tool-name.d.ts +14 -0
- package/dist/src/utils/normalize-tool-name.d.ts.map +1 -0
- package/dist/src/utils/parse-tool-result.d.ts +23 -0
- package/dist/src/utils/parse-tool-result.d.ts.map +1 -0
- package/package.json +1 -1
- package/react.ts +10 -2
package/dist/adapters/index.js
CHANGED
|
@@ -2729,6 +2729,27 @@ class HttpSessionTransport {
|
|
|
2729
2729
|
// ../client.ts
|
|
2730
2730
|
init_integration_summary();
|
|
2731
2731
|
init_library_metadata();
|
|
2732
|
+
|
|
2733
|
+
// ../database/token-store.ts
|
|
2734
|
+
var USABLE_ACCESS_TOKEN_BUFFER_MS = 30 * 1000;
|
|
2735
|
+
var MIN_MEANINGFUL_EXPIRY_MS = Date.UTC(2000, 0, 1);
|
|
2736
|
+
async function listConnectedProviders(configuredIntegrationIds, getProviderToken, context) {
|
|
2737
|
+
if (!context.userId || configuredIntegrationIds.length === 0) {
|
|
2738
|
+
return [];
|
|
2739
|
+
}
|
|
2740
|
+
const connected = [];
|
|
2741
|
+
await Promise.all(configuredIntegrationIds.map(async (provider) => {
|
|
2742
|
+
try {
|
|
2743
|
+
const token = await getProviderToken(provider, undefined, context);
|
|
2744
|
+
if (token?.accessToken || typeof token?.refreshToken === "string" && token.refreshToken.length > 0) {
|
|
2745
|
+
connected.push(provider);
|
|
2746
|
+
}
|
|
2747
|
+
} catch {}
|
|
2748
|
+
}));
|
|
2749
|
+
return connected.sort();
|
|
2750
|
+
}
|
|
2751
|
+
|
|
2752
|
+
// ../client.ts
|
|
2732
2753
|
init_errors();
|
|
2733
2754
|
init_logger();
|
|
2734
2755
|
|
|
@@ -4415,7 +4436,7 @@ class MCPClientBase {
|
|
|
4415
4436
|
logger7.debug(`Discovered ${totalDiscovered} tools, ${enabledCount} enabled by integrations`);
|
|
4416
4437
|
}
|
|
4417
4438
|
async _callToolByName(name, args, options) {
|
|
4418
|
-
return await this.
|
|
4439
|
+
return await this.callTool(name, args, options);
|
|
4419
4440
|
}
|
|
4420
4441
|
async callTool(name, args, options) {
|
|
4421
4442
|
return await this.callToolWithRetry(name, args, 0, options);
|
|
@@ -4594,20 +4615,32 @@ class MCPClientBase {
|
|
|
4594
4615
|
getEnabledTools() {
|
|
4595
4616
|
return Array.from(this.availableTools.values()).filter((tool) => this.enabledToolNames.has(tool.name));
|
|
4596
4617
|
}
|
|
4597
|
-
async getEnabledToolsAsync() {
|
|
4598
|
-
|
|
4599
|
-
|
|
4618
|
+
async getEnabledToolsAsync(options) {
|
|
4619
|
+
const targetIntegrationIds = await this.resolveTargetIntegrationIds(options);
|
|
4620
|
+
if (targetIntegrationIds.size === 0) {
|
|
4621
|
+
return [];
|
|
4600
4622
|
}
|
|
4601
|
-
|
|
4602
|
-
|
|
4623
|
+
const filterToTargets = (tools2) => this.filterToolsToIntegrations(tools2, targetIntegrationIds);
|
|
4624
|
+
const hasCompleteCache = () => {
|
|
4625
|
+
for (const integration of this.integrations) {
|
|
4626
|
+
if (!targetIntegrationIds.has(integration.id))
|
|
4627
|
+
continue;
|
|
4628
|
+
for (const toolName of integration.tools) {
|
|
4629
|
+
if (!this.enabledToolNames.has(toolName))
|
|
4630
|
+
continue;
|
|
4631
|
+
if (!this.availableTools.has(toolName))
|
|
4632
|
+
return false;
|
|
4633
|
+
}
|
|
4634
|
+
}
|
|
4635
|
+
return this.availableTools.size > 0;
|
|
4636
|
+
};
|
|
4637
|
+
if (this.availableTools.size > 0 && hasCompleteCache()) {
|
|
4638
|
+
return filterToTargets(this.getEnabledTools());
|
|
4603
4639
|
}
|
|
4604
4640
|
const tools = [];
|
|
4605
|
-
const integrationIds = new Set;
|
|
4606
|
-
for (const integration of this.integrations) {
|
|
4607
|
-
integrationIds.add(integration.id);
|
|
4608
|
-
}
|
|
4609
4641
|
const { parallelWithLimit: parallelWithLimit2 } = await Promise.resolve().then(() => exports_concurrency);
|
|
4610
|
-
const
|
|
4642
|
+
const concurrency = options?.fetchConcurrency ?? 8;
|
|
4643
|
+
const integrationToolsResults = await parallelWithLimit2(Array.from(targetIntegrationIds), async (integrationId) => {
|
|
4611
4644
|
try {
|
|
4612
4645
|
const response = await this.callServerToolInternal("list_tools_by_integration", {
|
|
4613
4646
|
integration: integrationId
|
|
@@ -4618,25 +4651,14 @@ class MCPClientBase {
|
|
|
4618
4651
|
if (item.type === "text" && item.text) {
|
|
4619
4652
|
try {
|
|
4620
4653
|
const parsed = JSON.parse(item.text);
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
}
|
|
4630
|
-
}
|
|
4631
|
-
} else if (parsed.tools && Array.isArray(parsed.tools)) {
|
|
4632
|
-
for (const tool of parsed.tools) {
|
|
4633
|
-
if (tool.name && tool.inputSchema) {
|
|
4634
|
-
integrationTools.push({
|
|
4635
|
-
name: tool.name,
|
|
4636
|
-
description: tool.description,
|
|
4637
|
-
inputSchema: tool.inputSchema
|
|
4638
|
-
});
|
|
4639
|
-
}
|
|
4654
|
+
const parsedTools = Array.isArray(parsed) ? parsed : parsed.tools && Array.isArray(parsed.tools) ? parsed.tools : [];
|
|
4655
|
+
for (const tool of parsedTools) {
|
|
4656
|
+
if (tool.name && tool.inputSchema) {
|
|
4657
|
+
integrationTools.push({
|
|
4658
|
+
name: tool.name,
|
|
4659
|
+
description: tool.description,
|
|
4660
|
+
inputSchema: tool.inputSchema
|
|
4661
|
+
});
|
|
4640
4662
|
}
|
|
4641
4663
|
}
|
|
4642
4664
|
} catch {}
|
|
@@ -4648,14 +4670,40 @@ class MCPClientBase {
|
|
|
4648
4670
|
logger7.error(`Failed to fetch tools for integration ${integrationId}:`, error);
|
|
4649
4671
|
return [];
|
|
4650
4672
|
}
|
|
4651
|
-
},
|
|
4673
|
+
}, concurrency);
|
|
4652
4674
|
for (const integrationTools of integrationToolsResults) {
|
|
4653
4675
|
tools.push(...integrationTools);
|
|
4654
4676
|
}
|
|
4655
4677
|
for (const tool of tools) {
|
|
4656
4678
|
this.availableTools.set(tool.name, tool);
|
|
4657
4679
|
}
|
|
4658
|
-
return tools.filter((tool) => this.enabledToolNames.has(tool.name));
|
|
4680
|
+
return filterToTargets(tools.filter((tool) => this.enabledToolNames.has(tool.name)));
|
|
4681
|
+
}
|
|
4682
|
+
async resolveTargetIntegrationIds(options) {
|
|
4683
|
+
const configuredIds = this.integrations.map((integration) => integration.id);
|
|
4684
|
+
const configuredSet = new Set(configuredIds);
|
|
4685
|
+
if (options?.integrationIds && options.integrationIds.length > 0) {
|
|
4686
|
+
return new Set(options.integrationIds.filter((id) => configuredSet.has(id)));
|
|
4687
|
+
}
|
|
4688
|
+
if (options?.connectedOnly && options.context?.userId) {
|
|
4689
|
+
const connected = await listConnectedProviders(configuredIds, (provider, email, context) => this.oauthManager.getProviderToken(provider, email, context), options.context);
|
|
4690
|
+
return new Set(connected);
|
|
4691
|
+
}
|
|
4692
|
+
return configuredSet;
|
|
4693
|
+
}
|
|
4694
|
+
filterToolsToIntegrations(tools, integrationIds) {
|
|
4695
|
+
if (integrationIds.size === 0) {
|
|
4696
|
+
return [];
|
|
4697
|
+
}
|
|
4698
|
+
const allowedNames = new Set;
|
|
4699
|
+
for (const integration of this.integrations) {
|
|
4700
|
+
if (!integrationIds.has(integration.id))
|
|
4701
|
+
continue;
|
|
4702
|
+
for (const toolName of integration.tools) {
|
|
4703
|
+
allowedNames.add(toolName);
|
|
4704
|
+
}
|
|
4705
|
+
}
|
|
4706
|
+
return tools.filter((tool) => this.enabledToolNames.has(tool.name) && allowedNames.has(tool.name));
|
|
4659
4707
|
}
|
|
4660
4708
|
getOAuthConfig(integrationId) {
|
|
4661
4709
|
const integration = this.integrations.find((p) => p.id === integrationId);
|
|
@@ -5535,9 +5583,6 @@ var logger199 = createLogger("Zoho Writer");
|
|
|
5535
5583
|
// ../integrations/zoho_sprints.ts
|
|
5536
5584
|
init_logger();
|
|
5537
5585
|
var logger200 = createLogger("Zoho Sprints");
|
|
5538
|
-
// ../database/token-store.ts
|
|
5539
|
-
var USABLE_ACCESS_TOKEN_BUFFER_MS = 30 * 1000;
|
|
5540
|
-
var MIN_MEANINGFUL_EXPIRY_MS = Date.UTC(2000, 0, 1);
|
|
5541
5586
|
// ../../node_modules/drizzle-orm/entity.js
|
|
5542
5587
|
var entityKind = Symbol.for("drizzle:entityKind");
|
|
5543
5588
|
var hasOwnEntityKind = Symbol.for("drizzle:hasOwnEntityKind");
|
|
@@ -2729,6 +2729,27 @@ class HttpSessionTransport {
|
|
|
2729
2729
|
// ../client.ts
|
|
2730
2730
|
init_integration_summary();
|
|
2731
2731
|
init_library_metadata();
|
|
2732
|
+
|
|
2733
|
+
// ../database/token-store.ts
|
|
2734
|
+
var USABLE_ACCESS_TOKEN_BUFFER_MS = 30 * 1000;
|
|
2735
|
+
var MIN_MEANINGFUL_EXPIRY_MS = Date.UTC(2000, 0, 1);
|
|
2736
|
+
async function listConnectedProviders(configuredIntegrationIds, getProviderToken, context) {
|
|
2737
|
+
if (!context.userId || configuredIntegrationIds.length === 0) {
|
|
2738
|
+
return [];
|
|
2739
|
+
}
|
|
2740
|
+
const connected = [];
|
|
2741
|
+
await Promise.all(configuredIntegrationIds.map(async (provider) => {
|
|
2742
|
+
try {
|
|
2743
|
+
const token = await getProviderToken(provider, undefined, context);
|
|
2744
|
+
if (token?.accessToken || typeof token?.refreshToken === "string" && token.refreshToken.length > 0) {
|
|
2745
|
+
connected.push(provider);
|
|
2746
|
+
}
|
|
2747
|
+
} catch {}
|
|
2748
|
+
}));
|
|
2749
|
+
return connected.sort();
|
|
2750
|
+
}
|
|
2751
|
+
|
|
2752
|
+
// ../client.ts
|
|
2732
2753
|
init_errors();
|
|
2733
2754
|
init_logger();
|
|
2734
2755
|
|
|
@@ -4415,7 +4436,7 @@ class MCPClientBase {
|
|
|
4415
4436
|
logger7.debug(`Discovered ${totalDiscovered} tools, ${enabledCount} enabled by integrations`);
|
|
4416
4437
|
}
|
|
4417
4438
|
async _callToolByName(name, args, options) {
|
|
4418
|
-
return await this.
|
|
4439
|
+
return await this.callTool(name, args, options);
|
|
4419
4440
|
}
|
|
4420
4441
|
async callTool(name, args, options) {
|
|
4421
4442
|
return await this.callToolWithRetry(name, args, 0, options);
|
|
@@ -4594,20 +4615,32 @@ class MCPClientBase {
|
|
|
4594
4615
|
getEnabledTools() {
|
|
4595
4616
|
return Array.from(this.availableTools.values()).filter((tool) => this.enabledToolNames.has(tool.name));
|
|
4596
4617
|
}
|
|
4597
|
-
async getEnabledToolsAsync() {
|
|
4598
|
-
|
|
4599
|
-
|
|
4618
|
+
async getEnabledToolsAsync(options) {
|
|
4619
|
+
const targetIntegrationIds = await this.resolveTargetIntegrationIds(options);
|
|
4620
|
+
if (targetIntegrationIds.size === 0) {
|
|
4621
|
+
return [];
|
|
4600
4622
|
}
|
|
4601
|
-
|
|
4602
|
-
|
|
4623
|
+
const filterToTargets = (tools2) => this.filterToolsToIntegrations(tools2, targetIntegrationIds);
|
|
4624
|
+
const hasCompleteCache = () => {
|
|
4625
|
+
for (const integration of this.integrations) {
|
|
4626
|
+
if (!targetIntegrationIds.has(integration.id))
|
|
4627
|
+
continue;
|
|
4628
|
+
for (const toolName of integration.tools) {
|
|
4629
|
+
if (!this.enabledToolNames.has(toolName))
|
|
4630
|
+
continue;
|
|
4631
|
+
if (!this.availableTools.has(toolName))
|
|
4632
|
+
return false;
|
|
4633
|
+
}
|
|
4634
|
+
}
|
|
4635
|
+
return this.availableTools.size > 0;
|
|
4636
|
+
};
|
|
4637
|
+
if (this.availableTools.size > 0 && hasCompleteCache()) {
|
|
4638
|
+
return filterToTargets(this.getEnabledTools());
|
|
4603
4639
|
}
|
|
4604
4640
|
const tools = [];
|
|
4605
|
-
const integrationIds = new Set;
|
|
4606
|
-
for (const integration of this.integrations) {
|
|
4607
|
-
integrationIds.add(integration.id);
|
|
4608
|
-
}
|
|
4609
4641
|
const { parallelWithLimit: parallelWithLimit2 } = await Promise.resolve().then(() => exports_concurrency);
|
|
4610
|
-
const
|
|
4642
|
+
const concurrency = options?.fetchConcurrency ?? 8;
|
|
4643
|
+
const integrationToolsResults = await parallelWithLimit2(Array.from(targetIntegrationIds), async (integrationId) => {
|
|
4611
4644
|
try {
|
|
4612
4645
|
const response = await this.callServerToolInternal("list_tools_by_integration", {
|
|
4613
4646
|
integration: integrationId
|
|
@@ -4618,25 +4651,14 @@ class MCPClientBase {
|
|
|
4618
4651
|
if (item.type === "text" && item.text) {
|
|
4619
4652
|
try {
|
|
4620
4653
|
const parsed = JSON.parse(item.text);
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
}
|
|
4630
|
-
}
|
|
4631
|
-
} else if (parsed.tools && Array.isArray(parsed.tools)) {
|
|
4632
|
-
for (const tool of parsed.tools) {
|
|
4633
|
-
if (tool.name && tool.inputSchema) {
|
|
4634
|
-
integrationTools.push({
|
|
4635
|
-
name: tool.name,
|
|
4636
|
-
description: tool.description,
|
|
4637
|
-
inputSchema: tool.inputSchema
|
|
4638
|
-
});
|
|
4639
|
-
}
|
|
4654
|
+
const parsedTools = Array.isArray(parsed) ? parsed : parsed.tools && Array.isArray(parsed.tools) ? parsed.tools : [];
|
|
4655
|
+
for (const tool of parsedTools) {
|
|
4656
|
+
if (tool.name && tool.inputSchema) {
|
|
4657
|
+
integrationTools.push({
|
|
4658
|
+
name: tool.name,
|
|
4659
|
+
description: tool.description,
|
|
4660
|
+
inputSchema: tool.inputSchema
|
|
4661
|
+
});
|
|
4640
4662
|
}
|
|
4641
4663
|
}
|
|
4642
4664
|
} catch {}
|
|
@@ -4648,14 +4670,40 @@ class MCPClientBase {
|
|
|
4648
4670
|
logger7.error(`Failed to fetch tools for integration ${integrationId}:`, error);
|
|
4649
4671
|
return [];
|
|
4650
4672
|
}
|
|
4651
|
-
},
|
|
4673
|
+
}, concurrency);
|
|
4652
4674
|
for (const integrationTools of integrationToolsResults) {
|
|
4653
4675
|
tools.push(...integrationTools);
|
|
4654
4676
|
}
|
|
4655
4677
|
for (const tool of tools) {
|
|
4656
4678
|
this.availableTools.set(tool.name, tool);
|
|
4657
4679
|
}
|
|
4658
|
-
return tools.filter((tool) => this.enabledToolNames.has(tool.name));
|
|
4680
|
+
return filterToTargets(tools.filter((tool) => this.enabledToolNames.has(tool.name)));
|
|
4681
|
+
}
|
|
4682
|
+
async resolveTargetIntegrationIds(options) {
|
|
4683
|
+
const configuredIds = this.integrations.map((integration) => integration.id);
|
|
4684
|
+
const configuredSet = new Set(configuredIds);
|
|
4685
|
+
if (options?.integrationIds && options.integrationIds.length > 0) {
|
|
4686
|
+
return new Set(options.integrationIds.filter((id) => configuredSet.has(id)));
|
|
4687
|
+
}
|
|
4688
|
+
if (options?.connectedOnly && options.context?.userId) {
|
|
4689
|
+
const connected = await listConnectedProviders(configuredIds, (provider, email, context) => this.oauthManager.getProviderToken(provider, email, context), options.context);
|
|
4690
|
+
return new Set(connected);
|
|
4691
|
+
}
|
|
4692
|
+
return configuredSet;
|
|
4693
|
+
}
|
|
4694
|
+
filterToolsToIntegrations(tools, integrationIds) {
|
|
4695
|
+
if (integrationIds.size === 0) {
|
|
4696
|
+
return [];
|
|
4697
|
+
}
|
|
4698
|
+
const allowedNames = new Set;
|
|
4699
|
+
for (const integration of this.integrations) {
|
|
4700
|
+
if (!integrationIds.has(integration.id))
|
|
4701
|
+
continue;
|
|
4702
|
+
for (const toolName of integration.tools) {
|
|
4703
|
+
allowedNames.add(toolName);
|
|
4704
|
+
}
|
|
4705
|
+
}
|
|
4706
|
+
return tools.filter((tool) => this.enabledToolNames.has(tool.name) && allowedNames.has(tool.name));
|
|
4659
4707
|
}
|
|
4660
4708
|
getOAuthConfig(integrationId) {
|
|
4661
4709
|
const integration = this.integrations.find((p) => p.id === integrationId);
|
|
@@ -5535,9 +5583,6 @@ var logger199 = createLogger("Zoho Writer");
|
|
|
5535
5583
|
// ../integrations/zoho_sprints.ts
|
|
5536
5584
|
init_logger();
|
|
5537
5585
|
var logger200 = createLogger("Zoho Sprints");
|
|
5538
|
-
// ../database/token-store.ts
|
|
5539
|
-
var USABLE_ACCESS_TOKEN_BUFFER_MS = 30 * 1000;
|
|
5540
|
-
var MIN_MEANINGFUL_EXPIRY_MS = Date.UTC(2000, 0, 1);
|
|
5541
5586
|
// ../../node_modules/drizzle-orm/entity.js
|
|
5542
5587
|
var entityKind = Symbol.for("drizzle:entityKind");
|
|
5543
5588
|
var hasOwnEntityKind = Symbol.for("drizzle:hasOwnEntityKind");
|
|
@@ -2729,6 +2729,27 @@ class HttpSessionTransport {
|
|
|
2729
2729
|
// ../client.ts
|
|
2730
2730
|
init_integration_summary();
|
|
2731
2731
|
init_library_metadata();
|
|
2732
|
+
|
|
2733
|
+
// ../database/token-store.ts
|
|
2734
|
+
var USABLE_ACCESS_TOKEN_BUFFER_MS = 30 * 1000;
|
|
2735
|
+
var MIN_MEANINGFUL_EXPIRY_MS = Date.UTC(2000, 0, 1);
|
|
2736
|
+
async function listConnectedProviders(configuredIntegrationIds, getProviderToken, context) {
|
|
2737
|
+
if (!context.userId || configuredIntegrationIds.length === 0) {
|
|
2738
|
+
return [];
|
|
2739
|
+
}
|
|
2740
|
+
const connected = [];
|
|
2741
|
+
await Promise.all(configuredIntegrationIds.map(async (provider) => {
|
|
2742
|
+
try {
|
|
2743
|
+
const token = await getProviderToken(provider, undefined, context);
|
|
2744
|
+
if (token?.accessToken || typeof token?.refreshToken === "string" && token.refreshToken.length > 0) {
|
|
2745
|
+
connected.push(provider);
|
|
2746
|
+
}
|
|
2747
|
+
} catch {}
|
|
2748
|
+
}));
|
|
2749
|
+
return connected.sort();
|
|
2750
|
+
}
|
|
2751
|
+
|
|
2752
|
+
// ../client.ts
|
|
2732
2753
|
init_errors();
|
|
2733
2754
|
init_logger();
|
|
2734
2755
|
|
|
@@ -4415,7 +4436,7 @@ class MCPClientBase {
|
|
|
4415
4436
|
logger7.debug(`Discovered ${totalDiscovered} tools, ${enabledCount} enabled by integrations`);
|
|
4416
4437
|
}
|
|
4417
4438
|
async _callToolByName(name, args, options) {
|
|
4418
|
-
return await this.
|
|
4439
|
+
return await this.callTool(name, args, options);
|
|
4419
4440
|
}
|
|
4420
4441
|
async callTool(name, args, options) {
|
|
4421
4442
|
return await this.callToolWithRetry(name, args, 0, options);
|
|
@@ -4594,20 +4615,32 @@ class MCPClientBase {
|
|
|
4594
4615
|
getEnabledTools() {
|
|
4595
4616
|
return Array.from(this.availableTools.values()).filter((tool) => this.enabledToolNames.has(tool.name));
|
|
4596
4617
|
}
|
|
4597
|
-
async getEnabledToolsAsync() {
|
|
4598
|
-
|
|
4599
|
-
|
|
4618
|
+
async getEnabledToolsAsync(options) {
|
|
4619
|
+
const targetIntegrationIds = await this.resolveTargetIntegrationIds(options);
|
|
4620
|
+
if (targetIntegrationIds.size === 0) {
|
|
4621
|
+
return [];
|
|
4600
4622
|
}
|
|
4601
|
-
|
|
4602
|
-
|
|
4623
|
+
const filterToTargets = (tools2) => this.filterToolsToIntegrations(tools2, targetIntegrationIds);
|
|
4624
|
+
const hasCompleteCache = () => {
|
|
4625
|
+
for (const integration of this.integrations) {
|
|
4626
|
+
if (!targetIntegrationIds.has(integration.id))
|
|
4627
|
+
continue;
|
|
4628
|
+
for (const toolName of integration.tools) {
|
|
4629
|
+
if (!this.enabledToolNames.has(toolName))
|
|
4630
|
+
continue;
|
|
4631
|
+
if (!this.availableTools.has(toolName))
|
|
4632
|
+
return false;
|
|
4633
|
+
}
|
|
4634
|
+
}
|
|
4635
|
+
return this.availableTools.size > 0;
|
|
4636
|
+
};
|
|
4637
|
+
if (this.availableTools.size > 0 && hasCompleteCache()) {
|
|
4638
|
+
return filterToTargets(this.getEnabledTools());
|
|
4603
4639
|
}
|
|
4604
4640
|
const tools = [];
|
|
4605
|
-
const integrationIds = new Set;
|
|
4606
|
-
for (const integration of this.integrations) {
|
|
4607
|
-
integrationIds.add(integration.id);
|
|
4608
|
-
}
|
|
4609
4641
|
const { parallelWithLimit: parallelWithLimit2 } = await Promise.resolve().then(() => exports_concurrency);
|
|
4610
|
-
const
|
|
4642
|
+
const concurrency = options?.fetchConcurrency ?? 8;
|
|
4643
|
+
const integrationToolsResults = await parallelWithLimit2(Array.from(targetIntegrationIds), async (integrationId) => {
|
|
4611
4644
|
try {
|
|
4612
4645
|
const response = await this.callServerToolInternal("list_tools_by_integration", {
|
|
4613
4646
|
integration: integrationId
|
|
@@ -4618,25 +4651,14 @@ class MCPClientBase {
|
|
|
4618
4651
|
if (item.type === "text" && item.text) {
|
|
4619
4652
|
try {
|
|
4620
4653
|
const parsed = JSON.parse(item.text);
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
}
|
|
4630
|
-
}
|
|
4631
|
-
} else if (parsed.tools && Array.isArray(parsed.tools)) {
|
|
4632
|
-
for (const tool of parsed.tools) {
|
|
4633
|
-
if (tool.name && tool.inputSchema) {
|
|
4634
|
-
integrationTools.push({
|
|
4635
|
-
name: tool.name,
|
|
4636
|
-
description: tool.description,
|
|
4637
|
-
inputSchema: tool.inputSchema
|
|
4638
|
-
});
|
|
4639
|
-
}
|
|
4654
|
+
const parsedTools = Array.isArray(parsed) ? parsed : parsed.tools && Array.isArray(parsed.tools) ? parsed.tools : [];
|
|
4655
|
+
for (const tool of parsedTools) {
|
|
4656
|
+
if (tool.name && tool.inputSchema) {
|
|
4657
|
+
integrationTools.push({
|
|
4658
|
+
name: tool.name,
|
|
4659
|
+
description: tool.description,
|
|
4660
|
+
inputSchema: tool.inputSchema
|
|
4661
|
+
});
|
|
4640
4662
|
}
|
|
4641
4663
|
}
|
|
4642
4664
|
} catch {}
|
|
@@ -4648,14 +4670,40 @@ class MCPClientBase {
|
|
|
4648
4670
|
logger7.error(`Failed to fetch tools for integration ${integrationId}:`, error);
|
|
4649
4671
|
return [];
|
|
4650
4672
|
}
|
|
4651
|
-
},
|
|
4673
|
+
}, concurrency);
|
|
4652
4674
|
for (const integrationTools of integrationToolsResults) {
|
|
4653
4675
|
tools.push(...integrationTools);
|
|
4654
4676
|
}
|
|
4655
4677
|
for (const tool of tools) {
|
|
4656
4678
|
this.availableTools.set(tool.name, tool);
|
|
4657
4679
|
}
|
|
4658
|
-
return tools.filter((tool) => this.enabledToolNames.has(tool.name));
|
|
4680
|
+
return filterToTargets(tools.filter((tool) => this.enabledToolNames.has(tool.name)));
|
|
4681
|
+
}
|
|
4682
|
+
async resolveTargetIntegrationIds(options) {
|
|
4683
|
+
const configuredIds = this.integrations.map((integration) => integration.id);
|
|
4684
|
+
const configuredSet = new Set(configuredIds);
|
|
4685
|
+
if (options?.integrationIds && options.integrationIds.length > 0) {
|
|
4686
|
+
return new Set(options.integrationIds.filter((id) => configuredSet.has(id)));
|
|
4687
|
+
}
|
|
4688
|
+
if (options?.connectedOnly && options.context?.userId) {
|
|
4689
|
+
const connected = await listConnectedProviders(configuredIds, (provider, email, context) => this.oauthManager.getProviderToken(provider, email, context), options.context);
|
|
4690
|
+
return new Set(connected);
|
|
4691
|
+
}
|
|
4692
|
+
return configuredSet;
|
|
4693
|
+
}
|
|
4694
|
+
filterToolsToIntegrations(tools, integrationIds) {
|
|
4695
|
+
if (integrationIds.size === 0) {
|
|
4696
|
+
return [];
|
|
4697
|
+
}
|
|
4698
|
+
const allowedNames = new Set;
|
|
4699
|
+
for (const integration of this.integrations) {
|
|
4700
|
+
if (!integrationIds.has(integration.id))
|
|
4701
|
+
continue;
|
|
4702
|
+
for (const toolName of integration.tools) {
|
|
4703
|
+
allowedNames.add(toolName);
|
|
4704
|
+
}
|
|
4705
|
+
}
|
|
4706
|
+
return tools.filter((tool) => this.enabledToolNames.has(tool.name) && allowedNames.has(tool.name));
|
|
4659
4707
|
}
|
|
4660
4708
|
getOAuthConfig(integrationId) {
|
|
4661
4709
|
const integration = this.integrations.find((p) => p.id === integrationId);
|
|
@@ -5535,9 +5583,6 @@ var logger199 = createLogger("Zoho Writer");
|
|
|
5535
5583
|
// ../integrations/zoho_sprints.ts
|
|
5536
5584
|
init_logger();
|
|
5537
5585
|
var logger200 = createLogger("Zoho Sprints");
|
|
5538
|
-
// ../database/token-store.ts
|
|
5539
|
-
var USABLE_ACCESS_TOKEN_BUFFER_MS = 30 * 1000;
|
|
5540
|
-
var MIN_MEANINGFUL_EXPIRY_MS = Date.UTC(2000, 0, 1);
|
|
5541
5586
|
// ../../node_modules/drizzle-orm/entity.js
|
|
5542
5587
|
var entityKind = Symbol.for("drizzle:entityKind");
|
|
5543
5588
|
var hasOwnEntityKind = Symbol.for("drizzle:hasOwnEntityKind");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anthropic.d.ts","sourceRoot":"","sources":["../../../src/ai/anthropic.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAkE,KAAK,cAAc,
|
|
1
|
+
{"version":3,"file":"anthropic.d.ts","sourceRoot":"","sources":["../../../src/ai/anthropic.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAkE,KAAK,cAAc,EAA8B,MAAM,YAAY,CAAC;AAU7I,OAAO,KAAK,SAAS,MAAM,mBAAmB,CAAC;AAE/C;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE;QACZ,IAAI,EAAE,QAAQ,CAAC;QACf,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACrC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;QACpB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACxB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,qBAAsB,SAAQ,cAAc;IAC3D,kDAAkD;IAClD,OAAO,CAAC,EAAE,UAAU,CAAC;IACrB;;;;;;;;;OASG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,UAAU,CAAC;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,aAAa,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB;AA+ID;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,CAAC,aAAa,EAAE,CAAC,CAmF1B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,OAAO,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAA,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC,CAAA;CAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACpG,OAAO,CAAC,EAAE,qBAAqB,GAC9B,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,GAAG,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAA,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC,CAAA;CAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAkC5I"}
|
package/dist/ai/anthropic.js
CHANGED
|
@@ -4060,6 +4060,15 @@ async function tryGetProviderTokens(manualTokens) {
|
|
|
4060
4060
|
}
|
|
4061
4061
|
|
|
4062
4062
|
// utils.ts
|
|
4063
|
+
function toEnabledToolsAsyncOptions(options) {
|
|
4064
|
+
if (!options)
|
|
4065
|
+
return;
|
|
4066
|
+
const { integrationIds, connectedOnly, context, fetchConcurrency } = options;
|
|
4067
|
+
if (integrationIds === undefined && connectedOnly === undefined && context === undefined && fetchConcurrency === undefined) {
|
|
4068
|
+
return;
|
|
4069
|
+
}
|
|
4070
|
+
return { integrationIds, connectedOnly, context, fetchConcurrency };
|
|
4071
|
+
}
|
|
4063
4072
|
function getProviderForTool(client, toolName) {
|
|
4064
4073
|
return client.getProviderForTool?.(toolName);
|
|
4065
4074
|
}
|
|
@@ -5141,7 +5150,7 @@ async function handleAnthropicToolCalls(client, messageContent, options) {
|
|
|
5141
5150
|
const getCodeModeTool = async () => {
|
|
5142
5151
|
if (cachedCodeModeTool)
|
|
5143
5152
|
return cachedCodeModeTool;
|
|
5144
|
-
const mcpTools = await client.getEnabledToolsAsync();
|
|
5153
|
+
const mcpTools = await client.getEnabledToolsAsync(toEnabledToolsAsyncOptions(options));
|
|
5145
5154
|
cachedCodeModeTool = buildCodeModeTool(client, {
|
|
5146
5155
|
tools: mcpTools,
|
|
5147
5156
|
providerTokens: options?.providerTokens,
|
|
@@ -5192,7 +5201,7 @@ async function getAnthropicTools(client, options) {
|
|
|
5192
5201
|
}
|
|
5193
5202
|
const finalOptions = providerTokens ? { ...options, providerTokens } : options;
|
|
5194
5203
|
await ensureClientConnected(client);
|
|
5195
|
-
const mcpTools = await client.getEnabledToolsAsync();
|
|
5204
|
+
const mcpTools = await client.getEnabledToolsAsync(toEnabledToolsAsyncOptions(options));
|
|
5196
5205
|
let effectiveMode;
|
|
5197
5206
|
if (options?.mode !== undefined) {
|
|
5198
5207
|
effectiveMode = options.mode;
|
package/dist/ai/google.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google.d.ts","sourceRoot":"","sources":["../../../src/ai/google.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAkE,KAAK,cAAc,
|
|
1
|
+
{"version":3,"file":"google.d.ts","sourceRoot":"","sources":["../../../src/ai/google.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAkE,KAAK,cAAc,EAA8B,MAAM,YAAY,CAAC;AAa7I,OAAO,KAAK,EACV,MAAM,EACN,mBAAmB,EACnB,YAAY,EACZ,IAAI,EACL,MAAM,eAAe,CAAC;AAGvB,MAAM,MAAM,UAAU,GAAG,mBAAmB,CAAC;AAC7C,MAAM,MAAM,kBAAkB,GAAG,YAAY,CAAC;AAC9C,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;AAuB7B;;GAEG;AACH,MAAM,WAAW,kBAAmB,SAAQ,cAAc;IACxD,kDAAkD;IAClD,OAAO,CAAC,EAAE,UAAU,CAAC;IACrB;;;;;;;;;OASG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACzB;AAsGD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAAsB,0BAA0B,CAC9C,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,aAAa,EAAE,kBAAkB,EAAE,GAAG,SAAS,GAAG,IAAI,EACtD,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,MAAM,EAAE,CAAC,CA+DnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyEG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,SAAS,CAAC,GAAG,CAAC,EACtB,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,UAAU,EAAE,CAAC,CAqGvB"}
|
package/dist/ai/google.js
CHANGED
|
@@ -4060,6 +4060,15 @@ async function tryGetProviderTokens(manualTokens) {
|
|
|
4060
4060
|
}
|
|
4061
4061
|
|
|
4062
4062
|
// utils.ts
|
|
4063
|
+
function toEnabledToolsAsyncOptions(options) {
|
|
4064
|
+
if (!options)
|
|
4065
|
+
return;
|
|
4066
|
+
const { integrationIds, connectedOnly, context, fetchConcurrency } = options;
|
|
4067
|
+
if (integrationIds === undefined && connectedOnly === undefined && context === undefined && fetchConcurrency === undefined) {
|
|
4068
|
+
return;
|
|
4069
|
+
}
|
|
4070
|
+
return { integrationIds, connectedOnly, context, fetchConcurrency };
|
|
4071
|
+
}
|
|
4063
4072
|
function getProviderForTool(client, toolName) {
|
|
4064
4073
|
return client.getProviderForTool?.(toolName);
|
|
4065
4074
|
}
|
|
@@ -5207,7 +5216,7 @@ async function executeGoogleFunctionCalls(client, functionCalls, options) {
|
|
|
5207
5216
|
const getCodeModeTool = async () => {
|
|
5208
5217
|
if (cachedCodeModeTool)
|
|
5209
5218
|
return cachedCodeModeTool;
|
|
5210
|
-
const mcpTools = await client.getEnabledToolsAsync();
|
|
5219
|
+
const mcpTools = await client.getEnabledToolsAsync(toEnabledToolsAsyncOptions(options));
|
|
5211
5220
|
cachedCodeModeTool = buildCodeModeTool(client, {
|
|
5212
5221
|
tools: mcpTools,
|
|
5213
5222
|
providerTokens: finalOptions?.providerTokens,
|
|
@@ -5246,7 +5255,7 @@ async function getGoogleTools(client, options) {
|
|
|
5246
5255
|
}
|
|
5247
5256
|
const finalOptions = providerTokens ? { ...options, providerTokens } : options;
|
|
5248
5257
|
await ensureClientConnected(client);
|
|
5249
|
-
const mcpTools = await client.getEnabledToolsAsync();
|
|
5258
|
+
const mcpTools = await client.getEnabledToolsAsync(toEnabledToolsAsyncOptions(options));
|
|
5250
5259
|
let effectiveMode;
|
|
5251
5260
|
if (options?.mode !== undefined) {
|
|
5252
5261
|
effectiveMode = options.mode;
|