@tangle-network/agent-integrations 0.25.7 → 0.27.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/README.md +11 -2
- package/dist/bin/tangle-catalog-runtime.js +6 -2
- package/dist/bin/tangle-catalog-runtime.js.map +1 -1
- package/dist/catalog.d.ts +4 -1
- package/dist/catalog.js +6 -2
- package/dist/chunk-2TW2QKGZ.js +94 -0
- package/dist/chunk-2TW2QKGZ.js.map +1 -0
- package/dist/chunk-ATYHZXLL.js +457 -0
- package/dist/chunk-ATYHZXLL.js.map +1 -0
- package/dist/{chunk-A5I3EYU5.js → chunk-ICSBYCE2.js} +122 -1
- package/dist/chunk-ICSBYCE2.js.map +1 -0
- package/dist/{chunk-WC63AI4Q.js → chunk-JU25UDN2.js} +1252 -225
- package/dist/chunk-JU25UDN2.js.map +1 -0
- package/dist/chunk-P24T3MLM.js +106 -0
- package/dist/chunk-P24T3MLM.js.map +1 -0
- package/dist/chunk-SVQ4PHDZ.js +129 -0
- package/dist/chunk-SVQ4PHDZ.js.map +1 -0
- package/dist/connect/index.d.ts +112 -0
- package/dist/connect/index.js +14 -0
- package/dist/connect/index.js.map +1 -0
- package/dist/connectors/adapters/index.d.ts +593 -1
- package/dist/connectors/adapters/index.js +22 -1
- package/dist/connectors/index.d.ts +2 -1
- package/dist/connectors/index.js +32 -10
- package/dist/index.d.ts +5 -2
- package/dist/index.js +57 -11
- package/dist/middleware/index.d.ts +137 -0
- package/dist/middleware/index.js +14 -0
- package/dist/middleware/index.js.map +1 -0
- package/dist/registry.d.ts +165 -2
- package/dist/registry.js +6 -2
- package/dist/runtime.d.ts +4 -1
- package/dist/runtime.js +6 -2
- package/dist/specs.d.ts +4 -1
- package/dist/tangle-catalog-runtime.d.ts +4 -1
- package/dist/tangle-catalog-runtime.js +6 -2
- package/dist/tangle-id-CTU4kGId.d.ts +553 -0
- package/dist/webhooks/index.d.ts +193 -0
- package/dist/webhooks/index.js +285 -0
- package/dist/webhooks/index.js.map +1 -0
- package/examples/discover-capabilities.ts +46 -0
- package/examples/webhook-router.ts +56 -0
- package/package.json +25 -12
- package/dist/chunk-A5I3EYU5.js.map +0 -1
- package/dist/chunk-WC63AI4Q.js.map +0 -1
- package/dist/index-BQY5ry2s.d.ts +0 -808
|
@@ -1199,6 +1199,125 @@ function secretKey(ref) {
|
|
|
1199
1199
|
return `${ref.provider}:${ref.id}`;
|
|
1200
1200
|
}
|
|
1201
1201
|
|
|
1202
|
+
// src/discovery.ts
|
|
1203
|
+
async function discoverWorkspaceCapabilities(input) {
|
|
1204
|
+
const connections = await resolveConnections(input);
|
|
1205
|
+
const connectors = await resolveConnectors(input);
|
|
1206
|
+
const activeConnectionsByConnector = /* @__PURE__ */ new Map();
|
|
1207
|
+
for (const conn of connections) {
|
|
1208
|
+
if (conn.status !== "active") continue;
|
|
1209
|
+
if (!activeConnectionsByConnector.has(conn.connectorId)) {
|
|
1210
|
+
activeConnectionsByConnector.set(conn.connectorId, conn);
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
const capabilities = [];
|
|
1214
|
+
const triggers = [];
|
|
1215
|
+
const countsByConnector = {};
|
|
1216
|
+
const unreachableConnectors = [];
|
|
1217
|
+
for (const connector of connectors) {
|
|
1218
|
+
const connection = activeConnectionsByConnector.get(connector.id);
|
|
1219
|
+
const connected = Boolean(connection);
|
|
1220
|
+
if (!connected && !input.includeUnconnected) continue;
|
|
1221
|
+
const grantedScopes = new Set(connection?.grantedScopes ?? []);
|
|
1222
|
+
let actionsAdded = 0;
|
|
1223
|
+
for (const action of connector.actions) {
|
|
1224
|
+
const missing2 = action.requiredScopes.filter((scope) => !grantedScopes.has(scope));
|
|
1225
|
+
if (connected && missing2.length > 0 && !input.includeMissingScopes) continue;
|
|
1226
|
+
capabilities.push(toCapability(connector, action, connection));
|
|
1227
|
+
actionsAdded += 1;
|
|
1228
|
+
}
|
|
1229
|
+
for (const trigger2 of connector.triggers ?? []) {
|
|
1230
|
+
const missing2 = trigger2.requiredScopes.filter((scope) => !grantedScopes.has(scope));
|
|
1231
|
+
if (connected && missing2.length > 0 && !input.includeMissingScopes) continue;
|
|
1232
|
+
triggers.push(toTrigger2(connector, trigger2, connection));
|
|
1233
|
+
}
|
|
1234
|
+
countsByConnector[connector.id] = actionsAdded;
|
|
1235
|
+
if (connected && actionsAdded === 0 && connector.actions.length > 0) {
|
|
1236
|
+
unreachableConnectors.push({
|
|
1237
|
+
connectorId: connector.id,
|
|
1238
|
+
reason: "all_actions_missing_scope"
|
|
1239
|
+
});
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
return { capabilities, triggers, countsByConnector, unreachableConnectors };
|
|
1243
|
+
}
|
|
1244
|
+
async function resolveConnections(input) {
|
|
1245
|
+
if (input.connections) return input.connections;
|
|
1246
|
+
if (input.store) return await input.store.listByOwner(input.owner);
|
|
1247
|
+
throw new Error("discoverWorkspaceCapabilities: provide either connections or store");
|
|
1248
|
+
}
|
|
1249
|
+
async function resolveConnectors(input) {
|
|
1250
|
+
if (input.connectors) return input.connectors;
|
|
1251
|
+
if (input.providers) {
|
|
1252
|
+
const lists = await Promise.all(input.providers.map((p) => Promise.resolve(p.listConnectors())));
|
|
1253
|
+
return lists.flat();
|
|
1254
|
+
}
|
|
1255
|
+
throw new Error("discoverWorkspaceCapabilities: provide either connectors or providers");
|
|
1256
|
+
}
|
|
1257
|
+
function toCapability(connector, action, connection) {
|
|
1258
|
+
return {
|
|
1259
|
+
id: `${connector.id}.${action.id}`,
|
|
1260
|
+
title: action.title,
|
|
1261
|
+
description: action.description,
|
|
1262
|
+
category: connector.category,
|
|
1263
|
+
connectorId: connector.id,
|
|
1264
|
+
providerId: connector.providerId,
|
|
1265
|
+
actionId: action.id,
|
|
1266
|
+
scopes: action.requiredScopes,
|
|
1267
|
+
risk: action.risk,
|
|
1268
|
+
dataClass: action.dataClass,
|
|
1269
|
+
toolSchema: {
|
|
1270
|
+
name: `${connector.id}.${action.id}`,
|
|
1271
|
+
description: action.description,
|
|
1272
|
+
inputSchema: action.inputSchema,
|
|
1273
|
+
outputSchema: action.outputSchema
|
|
1274
|
+
},
|
|
1275
|
+
connected: Boolean(connection),
|
|
1276
|
+
connectionId: connection?.id,
|
|
1277
|
+
approvalRequired: action.approvalRequired
|
|
1278
|
+
};
|
|
1279
|
+
}
|
|
1280
|
+
function toTrigger2(connector, trigger2, connection) {
|
|
1281
|
+
return {
|
|
1282
|
+
id: `${connector.id}.${trigger2.id}`,
|
|
1283
|
+
title: trigger2.title,
|
|
1284
|
+
description: trigger2.description,
|
|
1285
|
+
category: connector.category,
|
|
1286
|
+
connectorId: connector.id,
|
|
1287
|
+
providerId: connector.providerId,
|
|
1288
|
+
triggerId: trigger2.id,
|
|
1289
|
+
scopes: trigger2.requiredScopes,
|
|
1290
|
+
dataClass: trigger2.dataClass,
|
|
1291
|
+
connected: Boolean(connection),
|
|
1292
|
+
connectionId: connection?.id
|
|
1293
|
+
};
|
|
1294
|
+
}
|
|
1295
|
+
function filterDiscoveryByWorkspaceScopes(discovery, workspaceScopes, opts = {}) {
|
|
1296
|
+
if (workspaceScopes.length === 0 && !opts.denyByDefault) return discovery;
|
|
1297
|
+
const granted = new Set(workspaceScopes);
|
|
1298
|
+
const hasWildcard = granted.has("tangle:*");
|
|
1299
|
+
function allowed(connectorId, scopes) {
|
|
1300
|
+
if (hasWildcard) return true;
|
|
1301
|
+
if (granted.has(`${connectorId}:*`)) return true;
|
|
1302
|
+
for (const scope of scopes) {
|
|
1303
|
+
if (!granted.has(scope)) return false;
|
|
1304
|
+
}
|
|
1305
|
+
return true;
|
|
1306
|
+
}
|
|
1307
|
+
const capabilities = discovery.capabilities.filter((cap) => allowed(cap.connectorId, cap.scopes));
|
|
1308
|
+
const triggers = discovery.triggers.filter((t) => allowed(t.connectorId, t.scopes));
|
|
1309
|
+
const countsByConnector = {};
|
|
1310
|
+
for (const cap of capabilities) {
|
|
1311
|
+
countsByConnector[cap.connectorId] = (countsByConnector[cap.connectorId] ?? 0) + 1;
|
|
1312
|
+
}
|
|
1313
|
+
return {
|
|
1314
|
+
capabilities,
|
|
1315
|
+
triggers,
|
|
1316
|
+
countsByConnector,
|
|
1317
|
+
unreachableConnectors: discovery.unreachableConnectors
|
|
1318
|
+
};
|
|
1319
|
+
}
|
|
1320
|
+
|
|
1202
1321
|
// src/events.ts
|
|
1203
1322
|
var InMemoryIntegrationEventStore = class {
|
|
1204
1323
|
events = /* @__PURE__ */ new Map();
|
|
@@ -4373,6 +4492,8 @@ export {
|
|
|
4373
4492
|
resolveConnectionCredentials,
|
|
4374
4493
|
createCredentialBackedAdapterProvider,
|
|
4375
4494
|
revokeConnection,
|
|
4495
|
+
discoverWorkspaceCapabilities,
|
|
4496
|
+
filterDiscoveryByWorkspaceScopes,
|
|
4376
4497
|
InMemoryIntegrationEventStore,
|
|
4377
4498
|
receiveIntegrationWebhook,
|
|
4378
4499
|
storedEventToTriggerEvent,
|
|
@@ -4431,4 +4552,4 @@ export {
|
|
|
4431
4552
|
signCapability,
|
|
4432
4553
|
verifyCapabilityToken
|
|
4433
4554
|
};
|
|
4434
|
-
//# sourceMappingURL=chunk-
|
|
4555
|
+
//# sourceMappingURL=chunk-ICSBYCE2.js.map
|