@tangle-network/agent-integrations 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +55 -1
- package/dist/index.js +116 -3
- package/dist/index.js.map +1 -1
- package/docs/execution-layer-launch-plan.md +3 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1049,6 +1049,60 @@ interface ConnectorAdapterProviderOptions {
|
|
|
1049
1049
|
declare function createConnectorAdapterProvider(options: ConnectorAdapterProviderOptions): IntegrationProvider;
|
|
1050
1050
|
declare function manifestToConnector(providerId: string, adapter: ConnectorAdapter): IntegrationConnector;
|
|
1051
1051
|
|
|
1052
|
+
interface ImportCatalogOptions {
|
|
1053
|
+
providerId: string;
|
|
1054
|
+
connectorId: string;
|
|
1055
|
+
connectorTitle: string;
|
|
1056
|
+
category?: IntegrationConnectorCategory;
|
|
1057
|
+
auth?: IntegrationConnector['auth'];
|
|
1058
|
+
scopes?: string[];
|
|
1059
|
+
dataClass?: IntegrationDataClass;
|
|
1060
|
+
defaultRisk?: IntegrationActionRisk;
|
|
1061
|
+
}
|
|
1062
|
+
interface OpenApiDocument {
|
|
1063
|
+
openapi?: string;
|
|
1064
|
+
swagger?: string;
|
|
1065
|
+
info?: {
|
|
1066
|
+
title?: string;
|
|
1067
|
+
};
|
|
1068
|
+
paths?: Record<string, Record<string, OpenApiOperation | unknown>>;
|
|
1069
|
+
}
|
|
1070
|
+
interface OpenApiOperation {
|
|
1071
|
+
operationId?: string;
|
|
1072
|
+
summary?: string;
|
|
1073
|
+
description?: string;
|
|
1074
|
+
parameters?: unknown[];
|
|
1075
|
+
requestBody?: unknown;
|
|
1076
|
+
responses?: unknown;
|
|
1077
|
+
security?: Array<Record<string, string[]>>;
|
|
1078
|
+
tags?: string[];
|
|
1079
|
+
}
|
|
1080
|
+
interface GraphqlOperationSpec {
|
|
1081
|
+
name: string;
|
|
1082
|
+
kind: 'query' | 'mutation';
|
|
1083
|
+
description?: string;
|
|
1084
|
+
inputSchema?: unknown;
|
|
1085
|
+
outputSchema?: unknown;
|
|
1086
|
+
requiredScopes?: string[];
|
|
1087
|
+
}
|
|
1088
|
+
interface McpCatalogTool {
|
|
1089
|
+
name: string;
|
|
1090
|
+
description?: string;
|
|
1091
|
+
inputSchema?: unknown;
|
|
1092
|
+
annotations?: {
|
|
1093
|
+
readOnlyHint?: boolean;
|
|
1094
|
+
destructiveHint?: boolean;
|
|
1095
|
+
openWorldHint?: boolean;
|
|
1096
|
+
title?: string;
|
|
1097
|
+
};
|
|
1098
|
+
}
|
|
1099
|
+
interface McpCatalog {
|
|
1100
|
+
tools: McpCatalogTool[];
|
|
1101
|
+
}
|
|
1102
|
+
declare function importOpenApiConnector(document: OpenApiDocument, options: ImportCatalogOptions): IntegrationConnector;
|
|
1103
|
+
declare function importGraphqlConnector(operations: GraphqlOperationSpec[], options: ImportCatalogOptions): IntegrationConnector;
|
|
1104
|
+
declare function importMcpConnector(catalog: McpCatalog, options: ImportCatalogOptions): IntegrationConnector;
|
|
1105
|
+
|
|
1052
1106
|
type IntegrationProviderKind = 'first_party' | 'nango' | 'pipedream' | 'zapier' | 'activepieces' | 'executor' | 'custom';
|
|
1053
1107
|
type IntegrationConnectorCategory = 'email' | 'calendar' | 'chat' | 'crm' | 'storage' | 'docs' | 'database' | 'webhook' | 'workflow' | 'internal' | 'other';
|
|
1054
1108
|
type IntegrationActionRisk = 'read' | 'write' | 'destructive';
|
|
@@ -1345,4 +1399,4 @@ declare function createHttpIntegrationProvider(options: HttpIntegrationProviderO
|
|
|
1345
1399
|
declare function signCapability(capability: IntegrationCapability, secret: string): string;
|
|
1346
1400
|
declare function verifyCapabilityToken(token: string, secret: string): IntegrationCapability;
|
|
1347
1401
|
|
|
1348
|
-
export { type AuthSpec, type CASStrategy, type Capability, type CapabilityClass, type CapabilityMutation, type CapabilityMutationResult, type CapabilityParameterSchema, type CapabilityRead, type CapabilityReadResult, type CompleteAuthRequest, type ConnectorAdapter, type ConnectorAdapterProviderOptions, type ConnectorCredentials, type ConnectorInvocation, type ConnectorManifest, type ConnectorManifestValidationIssue, type ConnectorManifestValidationResult, type ConsistencyModel, CredentialsExpired, DEFAULT_SIGNATURE_TOLERANCE_SECONDS, type DataSourceMetadata, type EventHandlerResult, type ExchangeCodeInput, type GenericHmacVerifyOptions, type GoogleCalendarOptions, type GoogleSheetsOptions, type HttpIntegrationProviderOptions, type HubSpotOptions, InMemoryConnectionStore, InMemoryOAuthFlowStore, type InboundEvent, type IntegrationActionGuard, type IntegrationActionRequest, type IntegrationActionResult, type IntegrationActionRisk, type IntegrationActor, type IntegrationApprovalRequest, type IntegrationApprovalResolution, type IntegrationCapability, type IntegrationConnection, type IntegrationConnectionStore, type IntegrationConnector, type IntegrationConnectorAction, type IntegrationConnectorCategory, type IntegrationConnectorTrigger, type IntegrationDataClass, IntegrationError, type IntegrationGuardContext, IntegrationHub, type IntegrationHubOptions, type IntegrationInvocationEnvelope, type IntegrationPolicyDecision, type IntegrationPolicyEffect, type IntegrationPolicyEngine, type IntegrationPolicyRule, type IntegrationProvider, type IntegrationProviderKind, type IntegrationToolDefinition, type IntegrationToolSearchFilters, type IntegrationToolSearchResult, type IntegrationTriggerEvent, type IntegrationTriggerSubscription, type InvokeWithCapabilityRequest, type IssueCapabilityRequest, type IssuedIntegrationCapability, type McpToolDefinition, type MicrosoftCalendarOptions, type NormalizedIntegrationResult, type NotionDatabaseOptions, type OAuthFlowStore, type OAuthTokens, type ParsedStripeSignatureHeader, type PendingOAuthFlow, type RateLimitSpec, type RefreshInput, type ResolvedDataSource, ResourceContention, type SecretRef, type SlackOptions, type SlackVerifyOptions, type StartAuthRequest, type StartAuthResult, type StartOAuthInput, type StartOAuthOutput, StaticIntegrationPolicyEngine, type StaticIntegrationPolicyOptions, type StripeVerifyOptions, _resetPendingFlowsForTests, assertValidConnectorManifest, buildApprovalRequest, buildIntegrationInvocationEnvelope, buildIntegrationToolCatalog, consumePendingFlow, createConnectorAdapterProvider, createDefaultIntegrationPolicyEngine, createHttpIntegrationProvider, createMockIntegrationProvider, exchangeAuthorizationCode, firstHeader, googleCalendar, googleSheets, hubspot, integrationToolName, invocationRequestFromEnvelope, manifestToConnector, microsoftCalendar, normalizeIntegrationResult, notionDatabase, parseIntegrationToolName, parseStripeSignatureHeader, redactApprovalRequest, redactCapability, redactInvocationEnvelope, refreshAccessToken, sanitizeConnection, searchIntegrationTools, signCapability, slack, slackEventsConnector, startOAuthFlow, stripePackConnector, stripeWebhookReceiverConnector, toMcpTools, twilioSmsConnector, validateConnectorManifest, verifyCapabilityToken, verifyHmacSignature, verifySlackSignature, verifyStripeSignature, webhookConnector };
|
|
1402
|
+
export { type AuthSpec, type CASStrategy, type Capability, type CapabilityClass, type CapabilityMutation, type CapabilityMutationResult, type CapabilityParameterSchema, type CapabilityRead, type CapabilityReadResult, type CompleteAuthRequest, type ConnectorAdapter, type ConnectorAdapterProviderOptions, type ConnectorCredentials, type ConnectorInvocation, type ConnectorManifest, type ConnectorManifestValidationIssue, type ConnectorManifestValidationResult, type ConsistencyModel, CredentialsExpired, DEFAULT_SIGNATURE_TOLERANCE_SECONDS, type DataSourceMetadata, type EventHandlerResult, type ExchangeCodeInput, type GenericHmacVerifyOptions, type GoogleCalendarOptions, type GoogleSheetsOptions, type GraphqlOperationSpec, type HttpIntegrationProviderOptions, type HubSpotOptions, type ImportCatalogOptions, InMemoryConnectionStore, InMemoryOAuthFlowStore, type InboundEvent, type IntegrationActionGuard, type IntegrationActionRequest, type IntegrationActionResult, type IntegrationActionRisk, type IntegrationActor, type IntegrationApprovalRequest, type IntegrationApprovalResolution, type IntegrationCapability, type IntegrationConnection, type IntegrationConnectionStore, type IntegrationConnector, type IntegrationConnectorAction, type IntegrationConnectorCategory, type IntegrationConnectorTrigger, type IntegrationDataClass, IntegrationError, type IntegrationGuardContext, IntegrationHub, type IntegrationHubOptions, type IntegrationInvocationEnvelope, type IntegrationPolicyDecision, type IntegrationPolicyEffect, type IntegrationPolicyEngine, type IntegrationPolicyRule, type IntegrationProvider, type IntegrationProviderKind, type IntegrationToolDefinition, type IntegrationToolSearchFilters, type IntegrationToolSearchResult, type IntegrationTriggerEvent, type IntegrationTriggerSubscription, type InvokeWithCapabilityRequest, type IssueCapabilityRequest, type IssuedIntegrationCapability, type McpCatalog, type McpCatalogTool, type McpToolDefinition, type MicrosoftCalendarOptions, type NormalizedIntegrationResult, type NotionDatabaseOptions, type OAuthFlowStore, type OAuthTokens, type OpenApiDocument, type OpenApiOperation, type ParsedStripeSignatureHeader, type PendingOAuthFlow, type RateLimitSpec, type RefreshInput, type ResolvedDataSource, ResourceContention, type SecretRef, type SlackOptions, type SlackVerifyOptions, type StartAuthRequest, type StartAuthResult, type StartOAuthInput, type StartOAuthOutput, StaticIntegrationPolicyEngine, type StaticIntegrationPolicyOptions, type StripeVerifyOptions, _resetPendingFlowsForTests, assertValidConnectorManifest, buildApprovalRequest, buildIntegrationInvocationEnvelope, buildIntegrationToolCatalog, consumePendingFlow, createConnectorAdapterProvider, createDefaultIntegrationPolicyEngine, createHttpIntegrationProvider, createMockIntegrationProvider, exchangeAuthorizationCode, firstHeader, googleCalendar, googleSheets, hubspot, importGraphqlConnector, importMcpConnector, importOpenApiConnector, integrationToolName, invocationRequestFromEnvelope, manifestToConnector, microsoftCalendar, normalizeIntegrationResult, notionDatabase, parseIntegrationToolName, parseStripeSignatureHeader, redactApprovalRequest, redactCapability, redactInvocationEnvelope, refreshAccessToken, sanitizeConnection, searchIntegrationTools, signCapability, slack, slackEventsConnector, startOAuthFlow, stripePackConnector, stripeWebhookReceiverConnector, toMcpTools, twilioSmsConnector, validateConnectorManifest, verifyCapabilityToken, verifyHmacSignature, verifySlackSignature, verifyStripeSignature, webhookConnector };
|
package/dist/index.js
CHANGED
|
@@ -3068,6 +3068,116 @@ function toRecord(input) {
|
|
|
3068
3068
|
return {};
|
|
3069
3069
|
}
|
|
3070
3070
|
|
|
3071
|
+
// src/importers.ts
|
|
3072
|
+
var HTTP_METHODS = /* @__PURE__ */ new Set(["get", "post", "put", "patch", "delete"]);
|
|
3073
|
+
function importOpenApiConnector(document, options) {
|
|
3074
|
+
const actions = [];
|
|
3075
|
+
for (const [path, methods] of Object.entries(document.paths ?? {})) {
|
|
3076
|
+
for (const [method, rawOperation] of Object.entries(methods)) {
|
|
3077
|
+
const normalizedMethod = method.toLowerCase();
|
|
3078
|
+
if (!HTTP_METHODS.has(normalizedMethod) || !isObject(rawOperation)) continue;
|
|
3079
|
+
const operation = rawOperation;
|
|
3080
|
+
const operationId = operation.operationId ?? `${normalizedMethod}_${path.replace(/[^a-zA-Z0-9]+/g, "_").replace(/^_+|_+$/g, "")}`;
|
|
3081
|
+
actions.push({
|
|
3082
|
+
id: operationId,
|
|
3083
|
+
title: operation.summary ?? titleFromId(operationId),
|
|
3084
|
+
risk: riskFromHttpMethod(normalizedMethod, operation, options.defaultRisk),
|
|
3085
|
+
requiredScopes: scopesFromOpenApiOperation(operation, options.scopes ?? []),
|
|
3086
|
+
dataClass: options.dataClass ?? "private",
|
|
3087
|
+
description: operation.description ?? operation.summary ?? `${normalizedMethod.toUpperCase()} ${path}`,
|
|
3088
|
+
approvalRequired: riskFromHttpMethod(normalizedMethod, operation, options.defaultRisk) !== "read",
|
|
3089
|
+
inputSchema: openApiInputSchema(path, normalizedMethod, operation),
|
|
3090
|
+
outputSchema: operation.responses
|
|
3091
|
+
});
|
|
3092
|
+
}
|
|
3093
|
+
}
|
|
3094
|
+
return connectorFromActions(options, actions);
|
|
3095
|
+
}
|
|
3096
|
+
function importGraphqlConnector(operations, options) {
|
|
3097
|
+
return connectorFromActions(options, operations.map((operation) => ({
|
|
3098
|
+
id: operation.name,
|
|
3099
|
+
title: titleFromId(operation.name),
|
|
3100
|
+
risk: operation.kind === "query" ? "read" : options.defaultRisk ?? "write",
|
|
3101
|
+
requiredScopes: operation.requiredScopes ?? options.scopes ?? [],
|
|
3102
|
+
dataClass: options.dataClass ?? "private",
|
|
3103
|
+
description: operation.description,
|
|
3104
|
+
approvalRequired: operation.kind === "mutation",
|
|
3105
|
+
inputSchema: operation.inputSchema,
|
|
3106
|
+
outputSchema: operation.outputSchema
|
|
3107
|
+
})));
|
|
3108
|
+
}
|
|
3109
|
+
function importMcpConnector(catalog, options) {
|
|
3110
|
+
return connectorFromActions(options, catalog.tools.map((tool) => {
|
|
3111
|
+
const risk = riskFromMcpTool(tool, options.defaultRisk);
|
|
3112
|
+
return {
|
|
3113
|
+
id: tool.name,
|
|
3114
|
+
title: tool.annotations?.title ?? titleFromId(tool.name),
|
|
3115
|
+
risk,
|
|
3116
|
+
requiredScopes: options.scopes ?? [],
|
|
3117
|
+
dataClass: options.dataClass ?? "private",
|
|
3118
|
+
description: tool.description,
|
|
3119
|
+
approvalRequired: risk !== "read",
|
|
3120
|
+
inputSchema: tool.inputSchema
|
|
3121
|
+
};
|
|
3122
|
+
}));
|
|
3123
|
+
}
|
|
3124
|
+
function connectorFromActions(options, actions) {
|
|
3125
|
+
const scopes = unique2([
|
|
3126
|
+
...options.scopes ?? [],
|
|
3127
|
+
...actions.flatMap((action) => action.requiredScopes)
|
|
3128
|
+
]);
|
|
3129
|
+
return {
|
|
3130
|
+
id: options.connectorId,
|
|
3131
|
+
providerId: options.providerId,
|
|
3132
|
+
title: options.connectorTitle,
|
|
3133
|
+
category: options.category ?? "other",
|
|
3134
|
+
auth: options.auth ?? "custom",
|
|
3135
|
+
scopes,
|
|
3136
|
+
actions,
|
|
3137
|
+
metadata: { source: "catalog-importer" }
|
|
3138
|
+
};
|
|
3139
|
+
}
|
|
3140
|
+
function riskFromHttpMethod(method, operation, fallback) {
|
|
3141
|
+
if (method === "get") return "read";
|
|
3142
|
+
if (method === "delete") return "destructive";
|
|
3143
|
+
const text = `${operation.operationId ?? ""} ${operation.summary ?? ""} ${operation.description ?? ""}`.toLowerCase();
|
|
3144
|
+
if (/\b(delete|remove|destroy|cancel|void|revoke|drop)\b/.test(text)) return "destructive";
|
|
3145
|
+
return fallback && fallback !== "read" ? fallback : "write";
|
|
3146
|
+
}
|
|
3147
|
+
function riskFromMcpTool(tool, fallback) {
|
|
3148
|
+
if (tool.annotations?.destructiveHint) return "destructive";
|
|
3149
|
+
if (tool.annotations?.readOnlyHint) return "read";
|
|
3150
|
+
const text = `${tool.name} ${tool.description ?? ""}`.toLowerCase();
|
|
3151
|
+
if (/\b(delete|remove|destroy|cancel|void|revoke|drop)\b/.test(text)) return "destructive";
|
|
3152
|
+
if (/\b(get|list|read|search|find|fetch|query)\b/.test(text)) return "read";
|
|
3153
|
+
return fallback ?? "write";
|
|
3154
|
+
}
|
|
3155
|
+
function scopesFromOpenApiOperation(operation, fallback) {
|
|
3156
|
+
const scopes = (operation.security ?? []).flatMap((entry) => Object.values(entry).flat());
|
|
3157
|
+
return unique2(scopes.length > 0 ? scopes : fallback);
|
|
3158
|
+
}
|
|
3159
|
+
function openApiInputSchema(path, method, operation) {
|
|
3160
|
+
return {
|
|
3161
|
+
type: "object",
|
|
3162
|
+
additionalProperties: true,
|
|
3163
|
+
properties: {
|
|
3164
|
+
path: { const: path },
|
|
3165
|
+
method: { const: method.toUpperCase() },
|
|
3166
|
+
parameters: { type: "object", additionalProperties: true },
|
|
3167
|
+
body: operation.requestBody ?? { type: "object", additionalProperties: true }
|
|
3168
|
+
}
|
|
3169
|
+
};
|
|
3170
|
+
}
|
|
3171
|
+
function titleFromId(id) {
|
|
3172
|
+
return id.replace(/([a-z])([A-Z])/g, "$1 $2").split(/[^a-zA-Z0-9]+/g).filter(Boolean).map((part) => part.slice(0, 1).toUpperCase() + part.slice(1)).join(" ");
|
|
3173
|
+
}
|
|
3174
|
+
function isObject(value) {
|
|
3175
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
3176
|
+
}
|
|
3177
|
+
function unique2(values) {
|
|
3178
|
+
return [...new Set(values)];
|
|
3179
|
+
}
|
|
3180
|
+
|
|
3071
3181
|
// src/index.ts
|
|
3072
3182
|
var IntegrationError = class extends Error {
|
|
3073
3183
|
constructor(message, code) {
|
|
@@ -3142,8 +3252,8 @@ var IntegrationHub = class {
|
|
|
3142
3252
|
id: `cap_${randomUUID2()}`,
|
|
3143
3253
|
subject: request.subject,
|
|
3144
3254
|
connectionId: request.connectionId,
|
|
3145
|
-
scopes:
|
|
3146
|
-
allowedActions:
|
|
3255
|
+
scopes: unique3(request.scopes),
|
|
3256
|
+
allowedActions: unique3(request.allowedActions),
|
|
3147
3257
|
issuedAt: now.toISOString(),
|
|
3148
3258
|
expiresAt: new Date(now.getTime() + request.ttlMs).toISOString(),
|
|
3149
3259
|
metadata: request.metadata
|
|
@@ -3389,7 +3499,7 @@ function base64UrlEncode(value) {
|
|
|
3389
3499
|
function base64UrlDecode(value) {
|
|
3390
3500
|
return Buffer.from(value, "base64url").toString("utf8");
|
|
3391
3501
|
}
|
|
3392
|
-
function
|
|
3502
|
+
function unique3(values) {
|
|
3393
3503
|
return [...new Set(values)];
|
|
3394
3504
|
}
|
|
3395
3505
|
export {
|
|
@@ -3416,6 +3526,9 @@ export {
|
|
|
3416
3526
|
googleCalendar,
|
|
3417
3527
|
googleSheets,
|
|
3418
3528
|
hubspot,
|
|
3529
|
+
importGraphqlConnector,
|
|
3530
|
+
importMcpConnector,
|
|
3531
|
+
importOpenApiConnector,
|
|
3419
3532
|
integrationToolName,
|
|
3420
3533
|
invocationRequestFromEnvelope,
|
|
3421
3534
|
manifestToConnector,
|