@tangle-network/agent-integrations 0.18.0 → 0.20.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.js CHANGED
@@ -18,7 +18,7 @@ import {
18
18
  validateCredentialFormat,
19
19
  validateCredentialSet,
20
20
  validateIntegrationSpec
21
- } from "./chunk-DIJ3I66K.js";
21
+ } from "./chunk-L6WBPDUP.js";
22
22
 
23
23
  // src/index.ts
24
24
  import { createHmac as createHmac4, randomUUID as randomUUID4, timingSafeEqual as timingSafeEqual3 } from "crypto";
@@ -223,7 +223,7 @@ function defaultActions(id, scopes, dataClass) {
223
223
  dataClass,
224
224
  approvalRequired: true,
225
225
  inputSchema: { type: "object", additionalProperties: true, properties: {} },
226
- description: `Create or update a ${id} record through an Activepieces-backed connector.`
226
+ description: `Create or update a ${id} record through a catalog-backed connector.`
227
227
  }
228
228
  ];
229
229
  }
@@ -250,6 +250,7 @@ var DEFAULT_SOURCE_PRECEDENCE = {
250
250
  "first-party": 500,
251
251
  spec: 400,
252
252
  gateway: 300,
253
+ "tangle-catalog": 100,
253
254
  activepieces: 100,
254
255
  coverage: 50
255
256
  };
@@ -262,7 +263,7 @@ var SUPPORT_RANK = {
262
263
  };
263
264
  function buildDefaultIntegrationRegistry(options = {}) {
264
265
  const includeSpecs = options.includeSpecs ?? true;
265
- const includeActivepieces = options.includeActivepieces ?? true;
266
+ const includeTangleCatalog = options.includeTangleCatalog ?? options.includeActivepieces ?? true;
266
267
  const sources = [];
267
268
  if (includeSpecs) {
268
269
  sources.push({
@@ -270,10 +271,27 @@ function buildDefaultIntegrationRegistry(options = {}) {
270
271
  connectors: listIntegrationSpecs().map((spec) => integrationSpecToConnector(spec, "spec"))
271
272
  });
272
273
  }
273
- if (includeActivepieces) {
274
+ if (includeTangleCatalog) {
274
275
  sources.push({
275
- id: "activepieces",
276
- connectors: buildActivepiecesConnectors()
276
+ id: "tangle-catalog",
277
+ connectors: buildActivepiecesConnectors({ providerId: "tangle-catalog" }).map((connector) => ({
278
+ ...connector,
279
+ providerId: "tangle-catalog",
280
+ metadata: {
281
+ source: "tangle-integrations-catalog",
282
+ providerId: "tangle-catalog",
283
+ executable: connector.metadata?.executable,
284
+ runtime: "tangle-catalog-runtime",
285
+ catalogOnly: connector.metadata?.catalogOnly,
286
+ supportTier: connector.metadata?.supportTier,
287
+ catalogActionCount: connector.metadata?.catalogActionCount,
288
+ catalogTriggerCount: connector.metadata?.catalogTriggerCount,
289
+ license: connector.metadata?.license,
290
+ version: connector.metadata?.version,
291
+ domains: Array.isArray(connector.metadata?.domains) ? connector.metadata.domains.filter((domain) => typeof domain === "string" && !domain.toLowerCase().includes("activepieces")) : void 0,
292
+ ...connector.metadata?.overridden ? { overridden: true } : {}
293
+ }
294
+ }))
277
295
  });
278
296
  }
279
297
  return composeIntegrationRegistry(sources);
@@ -341,7 +359,7 @@ function inferIntegrationSupportTier(connector) {
341
359
  if (metadata.source === "first-party-adapter" || connector.providerId === "first-party") return "firstPartyExecutable";
342
360
  if (metadata.source === "gateway-catalog" && metadata.executable === true) return "gatewayExecutable";
343
361
  if (metadata.source === "integration-spec") return "setupReady";
344
- if (metadata.source === "coverage-catalog" || metadata.source === "activepieces-community" || metadata.catalogOnly === true) return "catalogOnly";
362
+ if (metadata.source === "coverage-catalog" || metadata.source === "activepieces-community" || metadata.source === "tangle-integrations-catalog" || metadata.catalogOnly === true) return "catalogOnly";
345
363
  if (connector.actions.length > 0) return "gatewayExecutable";
346
364
  return "catalogOnly";
347
365
  }
@@ -2139,10 +2157,11 @@ async function exchangeAuthorizationCode(input) {
2139
2157
  redirect_uri: input.redirectUri,
2140
2158
  code_verifier: input.codeVerifier
2141
2159
  });
2142
- const res = await fetch(input.tokenUrl, {
2160
+ const res = await (input.fetchImpl ?? fetch)(input.tokenUrl, {
2143
2161
  method: "POST",
2144
2162
  headers: { "content-type": "application/x-www-form-urlencoded", accept: "application/json" },
2145
- body
2163
+ body,
2164
+ signal: input.signal
2146
2165
  });
2147
2166
  if (!res.ok) {
2148
2167
  const text = await res.text().catch(() => "");
@@ -2164,10 +2183,11 @@ async function refreshAccessToken(input) {
2164
2183
  client_secret: input.clientSecret,
2165
2184
  refresh_token: input.refreshToken
2166
2185
  });
2167
- const res = await fetch(input.tokenUrl, {
2186
+ const res = await (input.fetchImpl ?? fetch)(input.tokenUrl, {
2168
2187
  method: "POST",
2169
2188
  headers: { "content-type": "application/x-www-form-urlencoded", accept: "application/json" },
2170
- body
2189
+ body,
2190
+ signal: input.signal
2171
2191
  });
2172
2192
  if (!res.ok) {
2173
2193
  const text = await res.text().catch(() => "");
@@ -5820,19 +5840,23 @@ function createActivepiecesExecutorProvider(options) {
5820
5840
  // src/activepieces-runtime.ts
5821
5841
  import { createHmac as createHmac3, randomUUID as randomUUID3, timingSafeEqual as timingSafeEqual2 } from "crypto";
5822
5842
  var ACTIVEPIECES_RUNTIME_SIGNATURE_HEADER = "x-tangle-activepieces-signature";
5843
+ var TANGLE_CATALOG_RUNTIME_SIGNATURE_HEADER = "x-tangle-catalog-signature";
5823
5844
  function createActivepiecesHttpExecutor(options) {
5824
5845
  const endpoint = options.endpoint.replace(/\/$/, "");
5846
+ const path = options.path ?? "/v1/activepieces/actions/invoke";
5847
+ const normalizedPath = path.startsWith("/") ? path : `/${path}`;
5848
+ const signatureHeader = options.signatureHeader ?? ACTIVEPIECES_RUNTIME_SIGNATURE_HEADER;
5825
5849
  const fetchImpl = options.fetchImpl ?? fetch;
5826
5850
  const requestId = options.requestId ?? (() => `apexec_${randomUUID3()}`);
5827
5851
  return async (invocation) => {
5828
5852
  const body = buildActivepiecesRuntimeRequest(invocation, requestId());
5829
5853
  const serialized = JSON.stringify(body);
5830
- const response = await fetchImpl(`${endpoint}/v1/activepieces/actions/invoke`, {
5854
+ const response = await fetchImpl(`${endpoint}${normalizedPath}`, {
5831
5855
  method: "POST",
5832
5856
  headers: {
5833
5857
  "content-type": "application/json",
5834
5858
  ...options.headers,
5835
- ...options.secret ? { [ACTIVEPIECES_RUNTIME_SIGNATURE_HEADER]: signActivepiecesRuntimeRequest(serialized, options.secret) } : {}
5859
+ ...options.secret ? { [signatureHeader]: signActivepiecesRuntimeRequest(serialized, options.secret) } : {}
5836
5860
  },
5837
5861
  body: serialized,
5838
5862
  signal: AbortSignal.timeout(options.timeoutMs ?? 3e4)
@@ -5885,6 +5909,66 @@ function verifyActivepiecesRuntimeSignature(serializedBody, signature, secret) {
5885
5909
  const right = Buffer.from(expected);
5886
5910
  return left.length === right.length && timingSafeEqual2(left, right);
5887
5911
  }
5912
+ function createTangleCatalogHttpExecutor(options) {
5913
+ const endpoint = options.endpoint.replace(/\/$/, "");
5914
+ const path = options.path ?? "/v1/integration-catalog/actions/invoke";
5915
+ const normalizedPath = path.startsWith("/") ? path : `/${path}`;
5916
+ const signatureHeader = options.signatureHeader ?? TANGLE_CATALOG_RUNTIME_SIGNATURE_HEADER;
5917
+ const fetchImpl = options.fetchImpl ?? fetch;
5918
+ const requestId = options.requestId ?? (() => `tcat_${randomUUID3()}`);
5919
+ return async (invocation) => {
5920
+ const body = buildTangleCatalogRuntimeRequest(invocation, requestId());
5921
+ const serialized = JSON.stringify(body);
5922
+ const response = await fetchImpl(`${endpoint}${normalizedPath}`, {
5923
+ method: "POST",
5924
+ headers: {
5925
+ "content-type": "application/json",
5926
+ ...options.headers,
5927
+ ...options.secret ? { [signatureHeader]: signTangleCatalogRuntimeRequest(serialized, options.secret) } : {}
5928
+ },
5929
+ body: serialized,
5930
+ signal: AbortSignal.timeout(options.timeoutMs ?? 3e4)
5931
+ });
5932
+ const parsed = await response.json().catch(() => void 0);
5933
+ if (!response.ok) {
5934
+ return parsed ?? {
5935
+ ok: false,
5936
+ action: invocation.request.action,
5937
+ output: { message: `Tangle catalog runtime returned HTTP ${response.status}.` }
5938
+ };
5939
+ }
5940
+ return parsed ?? {
5941
+ ok: false,
5942
+ action: invocation.request.action,
5943
+ output: { message: "Tangle catalog runtime returned an empty response." }
5944
+ };
5945
+ };
5946
+ }
5947
+ function buildTangleCatalogRuntimeRequest(invocation, requestId = `tcat_${randomUUID3()}`) {
5948
+ return {
5949
+ version: 1,
5950
+ requestId,
5951
+ providerId: invocation.connection.providerId,
5952
+ connection: invocation.connection,
5953
+ connector: {
5954
+ id: invocation.connector.id,
5955
+ title: invocation.connector.title,
5956
+ auth: invocation.connector.auth,
5957
+ scopes: invocation.connector.scopes,
5958
+ metadata: invocation.connector.metadata
5959
+ },
5960
+ piece: invocation.piece,
5961
+ action: {
5962
+ id: invocation.request.action,
5963
+ input: invocation.request.input,
5964
+ idempotencyKey: invocation.request.idempotencyKey,
5965
+ dryRun: invocation.request.dryRun,
5966
+ metadata: invocation.request.metadata
5967
+ }
5968
+ };
5969
+ }
5970
+ var signTangleCatalogRuntimeRequest = signActivepiecesRuntimeRequest;
5971
+ var verifyTangleCatalogRuntimeSignature = verifyActivepiecesRuntimeSignature;
5888
5972
 
5889
5973
  // src/catalog-freshness.ts
5890
5974
  var ACTIVEPIECES_PUBLIC_CATALOG_URL = "https://www.activepieces.com/pieces";
@@ -6016,6 +6100,124 @@ async function checkActivepiecesPublicCatalog(input) {
6016
6100
  }
6017
6101
  }
6018
6102
 
6103
+ // src/tangle-catalog.ts
6104
+ var TANGLE_INTEGRATIONS_CATALOG_PROVIDER_ID = "tangle-catalog";
6105
+ var TANGLE_INTEGRATIONS_CATALOG_SOURCE = "tangle-integrations-catalog";
6106
+ function listTangleIntegrationCatalogEntries() {
6107
+ return listActivepiecesCatalogEntries().map((entry) => sanitizeEntry(entry));
6108
+ }
6109
+ function buildTangleIntegrationCatalogConnectors(options = {}) {
6110
+ const providerId = options.providerId ?? TANGLE_INTEGRATIONS_CATALOG_PROVIDER_ID;
6111
+ return buildActivepiecesConnectors({
6112
+ ...options,
6113
+ providerId
6114
+ }).map((connector) => sanitizeConnector(connector, providerId));
6115
+ }
6116
+ function createTangleCatalogExecutorProvider(options) {
6117
+ const providerId = options.id ?? TANGLE_INTEGRATIONS_CATALOG_PROVIDER_ID;
6118
+ const connectors = options.connectors ?? buildTangleIntegrationCatalogConnectors({
6119
+ providerId,
6120
+ includeCatalogActions: true,
6121
+ executable: true
6122
+ });
6123
+ const byEntry = new Map(listActivepiecesCatalogEntries().map((entry) => [entry.id, entry]));
6124
+ return createCatalogExecutorProvider({
6125
+ id: providerId,
6126
+ kind: "tangle_catalog",
6127
+ connectors,
6128
+ startAuth: options.startAuth,
6129
+ completeAuth: options.completeAuth,
6130
+ executeAction: async ({ connection, request, connector, action }) => {
6131
+ const importedEntry = byEntry.get(connector.id);
6132
+ if (!importedEntry) {
6133
+ throw new IntegrationError(`Tangle catalog entry ${connector.id} not found.`, "connector_not_found");
6134
+ }
6135
+ const catalogAction = importedEntry.actions.find((candidate) => candidate.id === action.id);
6136
+ return options.executeAction({
6137
+ connection,
6138
+ request,
6139
+ connector,
6140
+ catalogEntry: sanitizeEntry(importedEntry),
6141
+ piece: {
6142
+ id: importedEntry.id,
6143
+ version: importedEntry.version,
6144
+ actionId: action.id,
6145
+ upstreamActionName: catalogAction?.upstreamName
6146
+ }
6147
+ });
6148
+ }
6149
+ });
6150
+ }
6151
+ var extractExternalCatalogPublicCount = extractActivepiecesPublicPieceCount;
6152
+ async function auditTangleIntegrationCatalogFreshness(options = {}) {
6153
+ const result = await auditIntegrationCatalogFreshness(options);
6154
+ return {
6155
+ ok: result.ok,
6156
+ generatedAt: result.generatedAt,
6157
+ local: {
6158
+ catalogEntries: result.local.activepiecesEntries,
6159
+ catalogConnectors: result.local.activepiecesConnectors,
6160
+ catalogActions: result.local.activepiecesActions,
6161
+ catalogTriggers: result.local.activepiecesTriggers,
6162
+ executableCatalogConnectors: result.local.executableActivepiecesConnectors,
6163
+ executableCatalogActions: result.local.executableActivepiecesActions,
6164
+ executableCatalogTriggers: result.local.executableActivepiecesTriggers,
6165
+ executableToolDefinitions: result.local.executableToolDefinitions,
6166
+ unsupportedExecutableConnectorIds: result.local.unsupportedExecutableConnectorIds,
6167
+ registryEntries: result.local.registryEntries,
6168
+ registrySummary: result.local.registrySummary,
6169
+ conflictSamples: result.local.conflictSamples
6170
+ },
6171
+ upstream: result.upstream ? {
6172
+ externalEntries: result.upstream.activepiecesPieces,
6173
+ externalDelta: result.upstream.activepiecesDelta,
6174
+ checkedUrl: result.upstream.checkedUrl,
6175
+ warning: result.upstream.warning
6176
+ } : void 0,
6177
+ warnings: result.warnings.map((warning) => warning.replaceAll("Activepieces", "Tangle Integrations Catalog"))
6178
+ };
6179
+ }
6180
+ function sanitizeEntry(entry) {
6181
+ return {
6182
+ id: entry.id,
6183
+ title: entry.title,
6184
+ description: entry.description,
6185
+ category: entry.category,
6186
+ auth: entry.auth,
6187
+ domains: entry.domains.filter((domain) => !domain.toLowerCase().includes("activepieces")),
6188
+ actions: entry.actions.map((action) => ({
6189
+ id: action.id,
6190
+ title: action.title,
6191
+ risk: action.risk
6192
+ })),
6193
+ triggers: entry.triggers.map((trigger2) => ({
6194
+ id: trigger2.id,
6195
+ title: trigger2.title
6196
+ }))
6197
+ };
6198
+ }
6199
+ function sanitizeConnector(connector, providerId) {
6200
+ const metadata = connector.metadata ?? {};
6201
+ return {
6202
+ ...connector,
6203
+ providerId,
6204
+ metadata: {
6205
+ source: TANGLE_INTEGRATIONS_CATALOG_SOURCE,
6206
+ providerId,
6207
+ executable: metadata.executable,
6208
+ runtime: "tangle-catalog-runtime",
6209
+ catalogOnly: metadata.catalogOnly,
6210
+ supportTier: metadata.supportTier,
6211
+ catalogActionCount: metadata.catalogActionCount,
6212
+ catalogTriggerCount: metadata.catalogTriggerCount,
6213
+ license: metadata.license,
6214
+ version: metadata.version,
6215
+ domains: Array.isArray(metadata.domains) ? metadata.domains.filter((domain) => typeof domain === "string" && !domain.toLowerCase().includes("activepieces")) : void 0,
6216
+ ...metadata.overridden ? { overridden: true } : {}
6217
+ }
6218
+ };
6219
+ }
6220
+
6019
6221
  // src/runtime.ts
6020
6222
  var InMemoryIntegrationGrantStore = class {
6021
6223
  grants = /* @__PURE__ */ new Map();
@@ -6669,6 +6871,9 @@ export {
6669
6871
  PROVIDER_PASSTHROUGH_ACTION,
6670
6872
  ResourceContention,
6671
6873
  StaticIntegrationPolicyEngine,
6874
+ TANGLE_CATALOG_RUNTIME_SIGNATURE_HEADER,
6875
+ TANGLE_INTEGRATIONS_CATALOG_PROVIDER_ID,
6876
+ TANGLE_INTEGRATIONS_CATALOG_SOURCE,
6672
6877
  TangleIntegrationsClient,
6673
6878
  _resetPendingFlowsForTests,
6674
6879
  adapterManifestsToConnectors,
@@ -6678,6 +6883,7 @@ export {
6678
6883
  assertValidIntegrationManifest,
6679
6884
  assertValidIntegrationSpec,
6680
6885
  auditIntegrationCatalogFreshness,
6886
+ auditTangleIntegrationCatalogFreshness,
6681
6887
  buildActivepiecesConnectors,
6682
6888
  buildActivepiecesRuntimeRequest,
6683
6889
  buildApprovalRequest,
@@ -6689,6 +6895,8 @@ export {
6689
6895
  buildIntegrationCoverageConnectors,
6690
6896
  buildIntegrationInvocationEnvelope,
6691
6897
  buildIntegrationToolCatalog,
6898
+ buildTangleCatalogRuntimeRequest,
6899
+ buildTangleIntegrationCatalogConnectors,
6692
6900
  calendarExercisePlannerManifest,
6693
6901
  canonicalActionConnectorId,
6694
6902
  canonicalConnectorId,
@@ -6713,6 +6921,8 @@ export {
6713
6921
  createIntegrationWorkflowRuntime,
6714
6922
  createMockIntegrationProvider,
6715
6923
  createPlatformIntegrationPolicyPreset,
6924
+ createTangleCatalogExecutorProvider,
6925
+ createTangleCatalogHttpExecutor,
6716
6926
  createTangleIntegrationsClient,
6717
6927
  declarativeRestConnector,
6718
6928
  decodeIntegrationBridgePayload,
@@ -6721,6 +6931,7 @@ export {
6721
6931
  exchangeAuthorizationCode,
6722
6932
  explainMissingRequirements,
6723
6933
  extractActivepiecesPublicPieceCount,
6934
+ extractExternalCatalogPublicCount,
6724
6935
  firstHeader,
6725
6936
  getActivepiecesOverride,
6726
6937
  getIntegrationFamily,
@@ -6744,6 +6955,7 @@ export {
6744
6955
  listExecutableIntegrationSpecs,
6745
6956
  listIntegrationCoverageSpecs,
6746
6957
  listIntegrationSpecs,
6958
+ listTangleIntegrationCatalogEntries,
6747
6959
  manifestToConnector,
6748
6960
  microsoftCalendar,
6749
6961
  normalizeGatewayCatalog,
@@ -6775,6 +6987,7 @@ export {
6775
6987
  searchIntegrationTools,
6776
6988
  signActivepiecesRuntimeRequest,
6777
6989
  signCapability,
6990
+ signTangleCatalogRuntimeRequest,
6778
6991
  slack,
6779
6992
  slackEventsConnector,
6780
6993
  specAuthToConnectorAuth,
@@ -6798,6 +7011,7 @@ export {
6798
7011
  verifyHmacSignature,
6799
7012
  verifySlackSignature,
6800
7013
  verifyStripeSignature,
7014
+ verifyTangleCatalogRuntimeSignature,
6801
7015
  verifyTwilioSignature,
6802
7016
  webhookConnector
6803
7017
  };