@tangle-network/agent-integrations 0.7.1 → 0.9.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
@@ -4081,6 +4081,673 @@ function objectSchema() {
4081
4081
  return { type: "object", additionalProperties: true, properties: {} };
4082
4082
  }
4083
4083
 
4084
+ // src/specs/types.ts
4085
+ function specAuthToConnectorAuth(auth) {
4086
+ if (auth.mode === "api_key") return "api_key";
4087
+ if (auth.mode === "oauth2") return "oauth2";
4088
+ if (auth.mode === "none") return "none";
4089
+ return "custom";
4090
+ }
4091
+
4092
+ // src/specs/families.ts
4093
+ var INTEGRATION_FAMILIES = {
4094
+ google: {
4095
+ id: "google",
4096
+ title: "Google OAuth",
4097
+ authMode: "oauth2",
4098
+ consoleUrl: "https://console.cloud.google.com/apis/credentials",
4099
+ authorizationUrl: "https://accounts.google.com/o/oauth2/v2/auth",
4100
+ tokenUrl: "https://oauth2.googleapis.com/token",
4101
+ redirectUriTemplate: "https://{host}/api/integrations/oauth/google/callback",
4102
+ credentialFields: [
4103
+ { label: "Client ID", env: "GOOGLE_OAUTH_CLIENT_ID", description: "Google OAuth client ID.", example: "1234567890-abc.apps.googleusercontent.com", regex: "^[0-9]+-[a-zA-Z0-9_-]+\\.apps\\.googleusercontent\\.com$", secret: false },
4104
+ { label: "Client Secret", env: "GOOGLE_OAUTH_CLIENT_SECRET", description: "Google OAuth client secret.", example: "GOCSPX-...", secret: true }
4105
+ ],
4106
+ consoleSteps: [
4107
+ { id: "project", title: "Select project", detail: "Open Google Cloud Console and select the project that owns the OAuth client." },
4108
+ { id: "consent", title: "Configure consent screen", detail: "Configure OAuth consent, app name, support email, and publishing status appropriate for the deployment." },
4109
+ { id: "client", title: "Create web client", detail: "Create an OAuth client of type Web application." },
4110
+ { id: "redirect", title: "Add redirect URI", detail: "Add {redirectUri} as an authorized redirect URI.", copyValue: "{redirectUri}" },
4111
+ { id: "scopes", title: "Add scopes", detail: "Add the provider scopes listed in this spec." }
4112
+ ],
4113
+ knownQuirks: [
4114
+ { id: "offline-access", severity: "warning", message: "Use access_type=offline and prompt=consent when refresh tokens are required." },
4115
+ { id: "verification", severity: "warning", message: "Sensitive or restricted scopes may require Google verification before broad external use." }
4116
+ ],
4117
+ lifecycle: { supportsRefresh: true, supportsRevoke: true, supportsIncrementalAuth: true, recommendedHealthcheckIntervalHours: 24 }
4118
+ },
4119
+ "microsoft-graph": {
4120
+ id: "microsoft-graph",
4121
+ title: "Microsoft Graph OAuth",
4122
+ authMode: "oauth2",
4123
+ consoleUrl: "https://entra.microsoft.com/#view/Microsoft_AAD_RegisteredApps/ApplicationsListBlade",
4124
+ authorizationUrl: "https://login.microsoftonline.com/common/oauth2/v2.0/authorize",
4125
+ tokenUrl: "https://login.microsoftonline.com/common/oauth2/v2.0/token",
4126
+ redirectUriTemplate: "https://{host}/api/integrations/oauth/microsoft/callback",
4127
+ credentialFields: [
4128
+ { label: "Client ID", env: "MS_OAUTH_CLIENT_ID", description: "Microsoft Entra application client ID.", example: "00000000-0000-0000-0000-000000000000", regex: "^[0-9a-fA-F-]{36}$", secret: false },
4129
+ { label: "Client Secret", env: "MS_OAUTH_CLIENT_SECRET", description: "Microsoft Entra client secret value.", secret: true }
4130
+ ],
4131
+ consoleSteps: [
4132
+ { id: "app", title: "Register app", detail: "Create or open an app registration in Microsoft Entra." },
4133
+ { id: "redirect", title: "Add redirect URI", detail: "Add {redirectUri} as a Web redirect URI.", copyValue: "{redirectUri}" },
4134
+ { id: "secret", title: "Create secret", detail: "Create a client secret and store the secret value, not the secret ID." },
4135
+ { id: "permissions", title: "Add Graph permissions", detail: "Add the delegated Graph scopes listed in this spec and grant admin consent where required." }
4136
+ ],
4137
+ knownQuirks: [
4138
+ { id: "tenant-common", severity: "info", message: "The common tenant supports multi-tenant OAuth; single-tenant deployments should override the tenant segment." },
4139
+ { id: "admin-consent", severity: "warning", message: "Some Graph scopes require tenant admin consent." }
4140
+ ],
4141
+ lifecycle: { supportsRefresh: true, supportsRevoke: true, supportsIncrementalAuth: true, recommendedHealthcheckIntervalHours: 24 }
4142
+ },
4143
+ atlassian: {
4144
+ id: "atlassian",
4145
+ title: "Atlassian OAuth",
4146
+ authMode: "oauth2",
4147
+ consoleUrl: "https://developer.atlassian.com/console/myapps/",
4148
+ authorizationUrl: "https://auth.atlassian.com/authorize",
4149
+ tokenUrl: "https://auth.atlassian.com/oauth/token",
4150
+ redirectUriTemplate: "https://{host}/api/integrations/oauth/atlassian/callback",
4151
+ credentialFields: [
4152
+ { label: "Client ID", description: "Atlassian OAuth client ID.", secret: false },
4153
+ { label: "Client Secret", description: "Atlassian OAuth client secret.", secret: true }
4154
+ ],
4155
+ consoleSteps: [
4156
+ { id: "app", title: "Create OAuth app", detail: "Create an OAuth 2.0 app in the Atlassian developer console." },
4157
+ { id: "redirect", title: "Add callback URL", detail: "Add {redirectUri} as the callback URL.", copyValue: "{redirectUri}" },
4158
+ { id: "apis", title: "Enable APIs", detail: "Enable the Jira or Confluence APIs required by this connector." }
4159
+ ],
4160
+ lifecycle: { supportsRefresh: true, supportsRevoke: false, supportsIncrementalAuth: false, recommendedHealthcheckIntervalHours: 24 }
4161
+ },
4162
+ salesforce: {
4163
+ id: "salesforce",
4164
+ title: "Salesforce OAuth",
4165
+ authMode: "oauth2",
4166
+ consoleUrl: "https://login.salesforce.com",
4167
+ authorizationUrl: "https://login.salesforce.com/services/oauth2/authorize",
4168
+ tokenUrl: "https://login.salesforce.com/services/oauth2/token",
4169
+ redirectUriTemplate: "https://{host}/api/integrations/oauth/salesforce/callback",
4170
+ credentialFields: [
4171
+ { label: "Client ID", env: "SALESFORCE_OAUTH_CLIENT_ID", description: "Salesforce connected app consumer key.", secret: false },
4172
+ { label: "Client Secret", env: "SALESFORCE_OAUTH_CLIENT_SECRET", description: "Salesforce connected app consumer secret.", secret: true }
4173
+ ],
4174
+ consoleSteps: [
4175
+ { id: "connected-app", title: "Create connected app", detail: "Create a Salesforce connected app with OAuth enabled." },
4176
+ { id: "callback", title: "Add callback URL", detail: "Add {redirectUri} as the callback URL.", copyValue: "{redirectUri}" },
4177
+ { id: "scopes", title: "Select scopes", detail: "Add api and refresh_token/offline_access, plus any connector-specific scopes." }
4178
+ ],
4179
+ knownQuirks: [
4180
+ { id: "instance-url", severity: "critical", message: "Runtime calls must use the instance_url returned by the token response." }
4181
+ ],
4182
+ lifecycle: { supportsRefresh: true, supportsRevoke: true, supportsIncrementalAuth: false, recommendedHealthcheckIntervalHours: 24 }
4183
+ },
4184
+ hubspot: {
4185
+ id: "hubspot",
4186
+ title: "HubSpot OAuth",
4187
+ authMode: "oauth2",
4188
+ consoleUrl: "https://developers.hubspot.com/",
4189
+ authorizationUrl: "https://app.hubspot.com/oauth/authorize",
4190
+ tokenUrl: "https://api.hubapi.com/oauth/v1/token",
4191
+ redirectUriTemplate: "https://{host}/api/integrations/oauth/hubspot/callback",
4192
+ credentialFields: [
4193
+ { label: "Client ID", env: "HUBSPOT_OAUTH_CLIENT_ID", description: "HubSpot app client ID.", secret: false },
4194
+ { label: "Client Secret", env: "HUBSPOT_OAUTH_CLIENT_SECRET", description: "HubSpot app client secret.", secret: true }
4195
+ ],
4196
+ consoleSteps: [
4197
+ { id: "app", title: "Create private/public app", detail: "Create a HubSpot app and configure OAuth." },
4198
+ { id: "redirect", title: "Add redirect URL", detail: "Add {redirectUri} to the app redirect URLs.", copyValue: "{redirectUri}" },
4199
+ { id: "scopes", title: "Add CRM scopes", detail: "Add the CRM object scopes listed in this spec." }
4200
+ ],
4201
+ lifecycle: { supportsRefresh: true, supportsRevoke: true, supportsIncrementalAuth: false, recommendedHealthcheckIntervalHours: 24 }
4202
+ },
4203
+ slack: {
4204
+ id: "slack",
4205
+ title: "Slack OAuth",
4206
+ authMode: "oauth2",
4207
+ consoleUrl: "https://api.slack.com/apps",
4208
+ authorizationUrl: "https://slack.com/oauth/v2/authorize",
4209
+ tokenUrl: "https://slack.com/api/oauth.v2.access",
4210
+ redirectUriTemplate: "https://{host}/api/integrations/oauth/slack/callback",
4211
+ credentialFields: [
4212
+ { label: "Client ID", env: "SLACK_OAUTH_CLIENT_ID", description: "Slack app client ID.", secret: false },
4213
+ { label: "Client Secret", env: "SLACK_OAUTH_CLIENT_SECRET", description: "Slack app client secret.", secret: true }
4214
+ ],
4215
+ consoleSteps: [
4216
+ { id: "app", title: "Create Slack app", detail: "Create or open a Slack app." },
4217
+ { id: "redirect", title: "Add redirect URL", detail: "Add {redirectUri} under OAuth & Permissions.", copyValue: "{redirectUri}" },
4218
+ { id: "scopes", title: "Add bot scopes", detail: "Add the bot token scopes listed in this spec and reinstall the app." }
4219
+ ],
4220
+ knownQuirks: [
4221
+ { id: "bot-token", severity: "info", message: "Slack usually returns a bot access token; refresh tokens require token rotation." }
4222
+ ],
4223
+ lifecycle: { supportsRefresh: false, supportsRevoke: true, supportsIncrementalAuth: false, recommendedHealthcheckIntervalHours: 24 }
4224
+ },
4225
+ notion: {
4226
+ id: "notion",
4227
+ title: "Notion OAuth",
4228
+ authMode: "oauth2",
4229
+ consoleUrl: "https://www.notion.so/my-integrations",
4230
+ authorizationUrl: "https://api.notion.com/v1/oauth/authorize",
4231
+ tokenUrl: "https://api.notion.com/v1/oauth/token",
4232
+ redirectUriTemplate: "https://{host}/api/integrations/oauth/notion/callback",
4233
+ credentialFields: [
4234
+ { label: "Client ID", env: "NOTION_OAUTH_CLIENT_ID", description: "Notion integration OAuth client ID.", secret: false },
4235
+ { label: "Client Secret", env: "NOTION_OAUTH_CLIENT_SECRET", description: "Notion integration OAuth client secret.", secret: true }
4236
+ ],
4237
+ consoleSteps: [
4238
+ { id: "integration", title: "Create integration", detail: "Create a Notion public integration." },
4239
+ { id: "redirect", title: "Add redirect URI", detail: "Add {redirectUri} as the redirect URI.", copyValue: "{redirectUri}" },
4240
+ { id: "capabilities", title: "Select capabilities", detail: "Enable read/update/insert capabilities matching this connector." }
4241
+ ],
4242
+ lifecycle: { supportsRefresh: true, supportsRevoke: true, supportsIncrementalAuth: false, recommendedHealthcheckIntervalHours: 24 }
4243
+ },
4244
+ "standard-oauth2": {
4245
+ id: "standard-oauth2",
4246
+ title: "Standard OAuth 2.0",
4247
+ authMode: "oauth2",
4248
+ redirectUriTemplate: "https://{host}/api/integrations/oauth/{kind}/callback",
4249
+ credentialFields: [
4250
+ { label: "Client ID", description: "OAuth client ID.", secret: false },
4251
+ { label: "Client Secret", description: "OAuth client secret.", secret: true }
4252
+ ],
4253
+ consoleSteps: [
4254
+ { id: "app", title: "Create OAuth app", detail: "Create an OAuth app in the provider console." },
4255
+ { id: "redirect", title: "Add redirect URI", detail: "Add {redirectUri} as an allowed redirect URI.", copyValue: "{redirectUri}" },
4256
+ { id: "scopes", title: "Add scopes", detail: "Add the scopes listed in this spec." }
4257
+ ],
4258
+ lifecycle: { supportsRefresh: true, supportsRevoke: false, supportsIncrementalAuth: false, recommendedHealthcheckIntervalHours: 24 }
4259
+ },
4260
+ "api-key": {
4261
+ id: "api-key",
4262
+ title: "API key",
4263
+ authMode: "api_key",
4264
+ credentialFields: [
4265
+ { label: "API Key", description: "Provider API key or token.", example: "sk_...", secret: true }
4266
+ ],
4267
+ consoleSteps: [
4268
+ { id: "token", title: "Create token", detail: "Create an API key/token in the provider console with the minimum required permissions." }
4269
+ ],
4270
+ lifecycle: { supportsRefresh: false, supportsRevoke: true, supportsIncrementalAuth: false, recommendedHealthcheckIntervalHours: 24 }
4271
+ },
4272
+ hmac: {
4273
+ id: "hmac",
4274
+ title: "HMAC secret",
4275
+ authMode: "hmac",
4276
+ credentialFields: [
4277
+ { label: "Signing Secret", description: "Webhook signing secret.", secret: true }
4278
+ ],
4279
+ consoleSteps: [
4280
+ { id: "secret", title: "Configure signing secret", detail: "Configure the shared signing secret in the sender and receiver." }
4281
+ ],
4282
+ lifecycle: { supportsRefresh: false, supportsRevoke: true, supportsIncrementalAuth: false, recommendedHealthcheckIntervalHours: 24 }
4283
+ },
4284
+ none: {
4285
+ id: "none",
4286
+ title: "No authentication",
4287
+ authMode: "none",
4288
+ credentialFields: [],
4289
+ consoleSteps: [
4290
+ { id: "configure", title: "Configure endpoint", detail: "No provider credentials are required." }
4291
+ ],
4292
+ lifecycle: { supportsRefresh: false, supportsRevoke: false, supportsIncrementalAuth: false }
4293
+ }
4294
+ };
4295
+ function getIntegrationFamily(id) {
4296
+ return INTEGRATION_FAMILIES[id];
4297
+ }
4298
+
4299
+ // src/specs/overrides.ts
4300
+ var INTEGRATION_OVERRIDES = {
4301
+ // ── Stripe pack ────────────────────────────────────────────────────
4302
+ // Stripe issues two key types: secret keys (sk_*) and restricted keys
4303
+ // (rk_*). For voice-agent workloads, restricted keys are the right call
4304
+ // — least-privilege scoped to the specific resources the agent can
4305
+ // touch. The hint nudges operators toward that path.
4306
+ "stripe-pack": {
4307
+ consoleUrl: "https://dashboard.stripe.com/apikeys",
4308
+ credentialFields: [
4309
+ {
4310
+ label: "Stripe secret key",
4311
+ description: "Restricted key recommended. Dashboard \u2192 Developers \u2192 API keys \u2192 Create restricted key. Grant write access on Customers, Invoices, and Checkout Sessions.",
4312
+ example: "sk_live_\u2026 or rk_live_\u2026 (use sk_test_\u2026 / rk_test_\u2026 for staging)",
4313
+ regex: "^(sk|rk)_(live|test)_[A-Za-z0-9]+$",
4314
+ secret: true
4315
+ }
4316
+ ],
4317
+ consoleSteps: [
4318
+ {
4319
+ id: "open-keys",
4320
+ title: "Open Stripe API keys",
4321
+ detail: "Visit https://dashboard.stripe.com/apikeys",
4322
+ copyValue: "https://dashboard.stripe.com/apikeys"
4323
+ },
4324
+ {
4325
+ id: "create-restricted",
4326
+ title: "Create a restricted key",
4327
+ detail: 'Click "Create restricted key". Name it something descriptive (e.g. "ph0ny voice agent \u2014 prod"). Grant WRITE on Customers, Invoices, and Checkout Sessions. Leave everything else NONE.'
4328
+ },
4329
+ {
4330
+ id: "paste",
4331
+ title: "Paste the key",
4332
+ detail: "Copy the key Stripe shows once (rk_live_\u2026 or sk_live_\u2026). Paste it into ph0ny. The key is sealed before persistence."
4333
+ }
4334
+ ]
4335
+ },
4336
+ // ── Twilio SMS ─────────────────────────────────────────────────────
4337
+ // Twilio's REST API uses Basic auth with two parts: Account SID
4338
+ // (public-ish, AC…) + Auth Token (secret). The default api-key family
4339
+ // only exposes one field, which doesn't fit. Providing both fields
4340
+ // explicitly lets the consumer's UI render two inputs.
4341
+ "twilio-sms": {
4342
+ consoleUrl: "https://console.twilio.com/",
4343
+ credentialFields: [
4344
+ {
4345
+ label: "Account SID",
4346
+ description: "Your Twilio Account SID. Console \u2192 Account \u2192 API keys & tokens.",
4347
+ example: "AC\u2026 (34 hex chars)",
4348
+ regex: "^AC[a-f0-9]{32}$",
4349
+ secret: false
4350
+ },
4351
+ {
4352
+ label: "Auth Token",
4353
+ description: "Your Twilio Auth Token (or Standard API Key secret). Use a non-primary auth token in production so rotating it won't break other Twilio integrations.",
4354
+ secret: true
4355
+ }
4356
+ ],
4357
+ consoleSteps: [
4358
+ {
4359
+ id: "open",
4360
+ title: "Open Twilio console",
4361
+ detail: "Visit https://console.twilio.com/",
4362
+ copyValue: "https://console.twilio.com/"
4363
+ },
4364
+ {
4365
+ id: "find",
4366
+ title: "Find your Account SID + Auth Token",
4367
+ detail: "Account info is on the dashboard home. For better security, create a Standard API Key (Account \u2192 API keys & tokens \u2192 Create API Key) and use the SID + Secret pair instead of the primary auth token."
4368
+ },
4369
+ {
4370
+ id: "paste",
4371
+ title: "Paste both values",
4372
+ detail: "Account SID is non-secret; Auth Token is sealed before persistence."
4373
+ }
4374
+ ],
4375
+ knownQuirks: [
4376
+ {
4377
+ id: "subaccount-tokens",
4378
+ severity: "info",
4379
+ message: "If you use Twilio subaccounts, paste the SID/Token of the subaccount that owns the phone numbers your agent calls \u2014 not the master account."
4380
+ }
4381
+ ]
4382
+ }
4383
+ };
4384
+ function getIntegrationOverride(kind) {
4385
+ return INTEGRATION_OVERRIDES[kind];
4386
+ }
4387
+
4388
+ // src/specs/registry.ts
4389
+ var EXECUTABLE_KINDS = /* @__PURE__ */ new Set([
4390
+ "google-calendar",
4391
+ "google-sheets",
4392
+ "outlook-calendar",
4393
+ "microsoft-calendar",
4394
+ "slack",
4395
+ "hubspot",
4396
+ "notion",
4397
+ "notion-database",
4398
+ "salesforce",
4399
+ "github",
4400
+ "gitlab",
4401
+ "airtable",
4402
+ "asana",
4403
+ "stripe",
4404
+ "stripe-pack",
4405
+ "twilio",
4406
+ "twilio-sms",
4407
+ "webhook"
4408
+ ]);
4409
+ var KIND_ALIASES = {
4410
+ "outlook-calendar": "microsoft-calendar",
4411
+ notion: "notion-database",
4412
+ stripe: "stripe-pack",
4413
+ twilio: "twilio-sms"
4414
+ };
4415
+ function listIntegrationSpecs() {
4416
+ const connectors = new Map(buildIntegrationCoverageConnectors({ providerId: "spec" }).map((c) => [c.id, c]));
4417
+ return listIntegrationCoverageSpecs().map((coverage) => {
4418
+ const connector = connectors.get(coverage.id);
4419
+ if (!connector) throw new Error(`missing coverage connector for ${coverage.id}`);
4420
+ return specFromCoverage(coverage, connector);
4421
+ });
4422
+ }
4423
+ function getIntegrationSpec(kind) {
4424
+ const canonical = KIND_ALIASES[kind] ?? kind;
4425
+ return listIntegrationSpecs().find((spec) => spec.kind === canonical || KIND_ALIASES[spec.kind] === canonical);
4426
+ }
4427
+ function listExecutableIntegrationSpecs() {
4428
+ return listIntegrationSpecs().filter((spec) => spec.status === "executable");
4429
+ }
4430
+ function integrationSpecToConnector(spec, providerId = "spec") {
4431
+ return {
4432
+ id: spec.kind,
4433
+ providerId,
4434
+ title: spec.title,
4435
+ category: spec.category,
4436
+ auth: spec.auth.mode === "api_key" ? "api_key" : spec.auth.mode === "oauth2" ? "oauth2" : spec.auth.mode === "none" ? "none" : "custom",
4437
+ scopes: spec.permissions.flatMap((permission) => permission.providerScopes),
4438
+ actions: spec.actions,
4439
+ triggers: spec.triggers,
4440
+ metadata: {
4441
+ ...spec.metadata ?? {},
4442
+ source: "integration-spec",
4443
+ status: spec.status,
4444
+ family: spec.family,
4445
+ plannerHints: spec.plannerHints
4446
+ }
4447
+ };
4448
+ }
4449
+ function specFromCoverage(coverage, connector) {
4450
+ const kind = KIND_ALIASES[coverage.id] ?? coverage.id;
4451
+ const family = familyFor(coverage);
4452
+ const familySpec = getIntegrationFamily(family);
4453
+ const permissions = permissionsFor(coverage, connector.actions);
4454
+ const auth = authFor(coverage, family, permissions);
4455
+ const status = statusFor(kind);
4456
+ const override = getIntegrationOverride(kind) ?? getIntegrationOverride(coverage.id);
4457
+ const knownQuirks = override?.knownQuirks ? [...familySpec.knownQuirks ?? [], ...override.knownQuirks] : familySpec.knownQuirks;
4458
+ return {
4459
+ kind,
4460
+ title: connector.title,
4461
+ category: connector.category,
4462
+ status,
4463
+ family,
4464
+ auth,
4465
+ permissions,
4466
+ actions: connector.actions,
4467
+ triggers: connector.triggers,
4468
+ setup: {
4469
+ consoleUrl: override?.consoleUrl ?? familySpec.consoleUrl,
4470
+ consoleSteps: override?.consoleSteps ?? familySpec.consoleSteps,
4471
+ credentialFields: override?.credentialFields ?? credentialFieldsFor(auth),
4472
+ redirectUriTemplate: auth.mode === "oauth2" ? auth.redirectUriTemplate : familySpec.redirectUriTemplate,
4473
+ knownQuirks,
4474
+ postSetup: override?.postSetup,
4475
+ healthcheck: override?.healthcheck ?? healthcheckFor(kind, status, auth)
4476
+ },
4477
+ lifecycle: familySpec.lifecycle,
4478
+ plannerHints: plannerHintsFor(coverage, connector.actions),
4479
+ metadata: { priority: coverage.priority, domains: coverage.domains }
4480
+ };
4481
+ }
4482
+ function familyFor(spec) {
4483
+ if (hmacKinds.has(spec.id)) return "hmac";
4484
+ if (spec.auth === "none") return "none";
4485
+ if (spec.id.startsWith("google-") || spec.domains.includes("google")) return "google";
4486
+ if (spec.id.startsWith("microsoft-") || ["outlook-mail", "outlook-calendar", "onedrive", "sharepoint"].includes(spec.id)) return "microsoft-graph";
4487
+ if (["jira", "confluence", "trello", "bitbucket"].includes(spec.id)) return "atlassian";
4488
+ if (spec.id === "salesforce") return "salesforce";
4489
+ if (spec.id === "hubspot") return "hubspot";
4490
+ if (spec.id === "slack") return "slack";
4491
+ if (spec.id === "notion") return "notion";
4492
+ if (apiKeyKinds.has(spec.id)) return "api-key";
4493
+ return "standard-oauth2";
4494
+ }
4495
+ var apiKeyKinds = /* @__PURE__ */ new Set(["github", "gitlab", "airtable", "asana", "stripe", "twilio", "sendgrid", "postmark"]);
4496
+ var hmacKinds = /* @__PURE__ */ new Set(["webhook"]);
4497
+ function authFor(spec, family, permissions) {
4498
+ const f = INTEGRATION_FAMILIES[family];
4499
+ if (family === "none") return { mode: "none" };
4500
+ if (family === "hmac") {
4501
+ return { mode: "hmac", credential: f.credentialFields[0], signatureHeader: `${spec.id}-signature` };
4502
+ }
4503
+ if (family === "api-key") {
4504
+ return { mode: "api_key", credential: apiKeyFieldFor(spec.id), placement: apiKeyPlacementFor(spec.id) };
4505
+ }
4506
+ const scopes = permissions.flatMap(
4507
+ (permission) => permission.providerScopes.map((providerScope) => ({
4508
+ normalized: permission.normalized,
4509
+ providerScope,
4510
+ title: permission.title,
4511
+ reason: permission.reason,
4512
+ risk: permission.risk,
4513
+ dataClass: permission.dataClass
4514
+ }))
4515
+ );
4516
+ return {
4517
+ mode: "oauth2",
4518
+ authorizationUrl: f.authorizationUrl ?? `https://example.invalid/${spec.id}/authorize`,
4519
+ tokenUrl: f.tokenUrl ?? `https://example.invalid/${spec.id}/token`,
4520
+ clientIdEnv: f.credentialFields.find((field) => !field.secret)?.env,
4521
+ clientSecretEnv: f.credentialFields.find((field) => field.secret)?.env,
4522
+ scopes,
4523
+ extraAuthParams: extraAuthParamsFor(family),
4524
+ redirectUriTemplate: (f.redirectUriTemplate ?? "https://{host}/api/integrations/oauth/{kind}/callback").replace("{kind}", spec.id),
4525
+ pkce: family === "google" || family === "microsoft-graph" ? "supported" : "unsupported"
4526
+ };
4527
+ }
4528
+ function credentialFieldsFor(auth) {
4529
+ if (auth.mode === "api_key" || auth.mode === "hmac") return [auth.credential];
4530
+ if (auth.mode === "oauth2") {
4531
+ return [
4532
+ { label: "Client ID", env: auth.clientIdEnv, description: "OAuth client ID.", secret: false },
4533
+ { label: "Client Secret", env: auth.clientSecretEnv, description: "OAuth client secret.", secret: true }
4534
+ ];
4535
+ }
4536
+ return [];
4537
+ }
4538
+ function permissionsFor(spec, actions) {
4539
+ const dataClass = dataClassFor2(actions);
4540
+ const readScope = providerScopeFor(spec, "read");
4541
+ const writeScope = providerScopeFor(spec, "write");
4542
+ const permissions = [
4543
+ {
4544
+ normalized: `${spec.actionPack}.read`,
4545
+ providerScopes: readScope ? [readScope] : [],
4546
+ title: `${spec.title} read`,
4547
+ risk: "read",
4548
+ dataClass,
4549
+ reason: `Read ${spec.title} data for user-authorized agent workflows.`
4550
+ }
4551
+ ];
4552
+ if (actions.some((a) => a.risk !== "read")) {
4553
+ permissions.push({
4554
+ normalized: `${spec.actionPack}.write`,
4555
+ providerScopes: writeScope ? [writeScope] : [],
4556
+ title: `${spec.title} write`,
4557
+ risk: "write",
4558
+ dataClass,
4559
+ reason: `Create or update ${spec.title} resources after policy approval.`
4560
+ });
4561
+ }
4562
+ return permissions;
4563
+ }
4564
+ function providerScopeFor(spec, mode) {
4565
+ const explicit = explicitScopes[spec.id]?.[mode];
4566
+ if (explicit) return explicit;
4567
+ if (spec.auth === "none") return "";
4568
+ return `${spec.id}.${mode}`;
4569
+ }
4570
+ var explicitScopes = {
4571
+ gmail: { read: "https://www.googleapis.com/auth/gmail.readonly", write: "https://www.googleapis.com/auth/gmail.modify" },
4572
+ "google-calendar": { read: "https://www.googleapis.com/auth/calendar.readonly", write: "https://www.googleapis.com/auth/calendar" },
4573
+ "google-sheets": { read: "https://www.googleapis.com/auth/spreadsheets.readonly", write: "https://www.googleapis.com/auth/spreadsheets" },
4574
+ "google-drive": { read: "https://www.googleapis.com/auth/drive.readonly", write: "https://www.googleapis.com/auth/drive.file" },
4575
+ "google-docs": { read: "https://www.googleapis.com/auth/documents.readonly", write: "https://www.googleapis.com/auth/documents" },
4576
+ "outlook-mail": { read: "Mail.Read", write: "Mail.Send" },
4577
+ "outlook-calendar": { read: "Calendars.Read", write: "Calendars.ReadWrite" },
4578
+ "microsoft-teams": { read: "ChannelMessage.Read.All", write: "ChannelMessage.Send" },
4579
+ onedrive: { read: "Files.Read", write: "Files.ReadWrite" },
4580
+ sharepoint: { read: "Sites.Read.All", write: "Sites.ReadWrite.All" },
4581
+ slack: { read: "channels:read", write: "chat:write" },
4582
+ hubspot: { read: "crm.objects.contacts.read", write: "crm.objects.contacts.write" },
4583
+ salesforce: { read: "api", write: "api" },
4584
+ notion: { read: "", write: "" },
4585
+ github: { read: "repo:read", write: "repo" },
4586
+ gitlab: { read: "read_api", write: "api" },
4587
+ airtable: { read: "data.records:read", write: "data.records:write" },
4588
+ asana: { read: "default", write: "default" },
4589
+ stripe: { read: "read_only", write: "standard" },
4590
+ twilio: { read: "api_key", write: "api_key" }
4591
+ };
4592
+ function plannerHintsFor(spec, actions) {
4593
+ return {
4594
+ useFor: spec.domains.map((domain) => domain.replace(/-/g, " ")),
4595
+ dataFreshness: ["calendar", "chat", "commerce", "finance", "support"].includes(spec.actionPack) ? "near_realtime" : "eventual",
4596
+ writeRisk: actions.some((a) => a.risk === "destructive") ? "high" : actions.some((a) => a.risk === "write") ? "medium" : "low"
4597
+ };
4598
+ }
4599
+ function healthcheckFor(kind, status, auth) {
4600
+ if (status !== "executable") {
4601
+ return { id: `${kind}.static`, level: "static", description: "Catalog-only integration; no executable connector healthcheck is available yet." };
4602
+ }
4603
+ if (auth.mode === "oauth2") {
4604
+ return { id: `${kind}.connection`, level: "connection", description: "Validate a user connection by calling the connector test endpoint." };
4605
+ }
4606
+ if (auth.mode === "api_key") {
4607
+ return { id: `${kind}.connection`, level: "connection", description: "Validate API credentials by calling the connector test endpoint." };
4608
+ }
4609
+ if (auth.mode === "hmac") {
4610
+ return { id: `${kind}.webhook`, level: "webhook", description: "Validate webhook signing configuration with a signed test payload." };
4611
+ }
4612
+ return { id: `${kind}.static`, level: "static", description: "No credentials are required." };
4613
+ }
4614
+ function statusFor(kind) {
4615
+ return EXECUTABLE_KINDS.has(kind) ? "executable" : "catalog";
4616
+ }
4617
+ function dataClassFor2(actions) {
4618
+ if (actions.some((a) => a.dataClass === "secret")) return "secret";
4619
+ if (actions.some((a) => a.dataClass === "sensitive")) return "sensitive";
4620
+ if (actions.some((a) => a.dataClass === "private")) return "private";
4621
+ if (actions.some((a) => a.dataClass === "internal")) return "internal";
4622
+ return "public";
4623
+ }
4624
+ function apiKeyFieldFor(kind) {
4625
+ return {
4626
+ label: `${kind} API key`,
4627
+ description: `API key or token for ${kind}.`,
4628
+ example: kind === "stripe" ? "sk_live_..." : void 0,
4629
+ secret: true
4630
+ };
4631
+ }
4632
+ function apiKeyPlacementFor(kind) {
4633
+ if (kind === "gitlab") return "header";
4634
+ return "bearer";
4635
+ }
4636
+ function extraAuthParamsFor(family) {
4637
+ if (family === "google") return { access_type: "offline", prompt: "consent", include_granted_scopes: "true" };
4638
+ if (family === "notion") return { owner: "user" };
4639
+ return void 0;
4640
+ }
4641
+
4642
+ // src/specs/renderers.ts
4643
+ function renderConsoleSteps(spec, options) {
4644
+ const redirectUri = renderRedirectUri(spec, options);
4645
+ return spec.setup.consoleSteps.map((step) => ({
4646
+ ...step,
4647
+ detail: renderTemplate(step.detail, spec, options, redirectUri),
4648
+ copyValue: step.copyValue ? renderTemplate(step.copyValue, spec, options, redirectUri) : void 0
4649
+ }));
4650
+ }
4651
+ function renderRunbookMarkdown(spec, options) {
4652
+ const steps = renderConsoleSteps(spec, options);
4653
+ const lines = [
4654
+ `# ${spec.title} Integration Setup`,
4655
+ "",
4656
+ `- Kind: \`${spec.kind}\``,
4657
+ `- Status: \`${spec.status}\``,
4658
+ `- Auth: \`${spec.auth.mode}\``,
4659
+ `- Family: \`${spec.family}\``
4660
+ ];
4661
+ if (spec.setup.consoleUrl) lines.push(`- Console: ${spec.setup.consoleUrl}`);
4662
+ if (spec.setup.redirectUriTemplate) lines.push(`- Redirect URI: \`${renderRedirectUri(spec, options)}\``);
4663
+ lines.push("", "## Credentials", "");
4664
+ for (const field of spec.setup.credentialFields) {
4665
+ lines.push(`- ${field.secret ? "[secret] " : ""}${field.label}${field.env ? ` (\`${field.env}\`)` : ""}: ${field.description}`);
4666
+ }
4667
+ lines.push("", "## Permissions", "");
4668
+ for (const permission of spec.permissions) {
4669
+ lines.push(`- \`${permission.normalized}\`: ${permission.providerScopes.length ? permission.providerScopes.map((scope) => `\`${scope}\``).join(", ") : "no provider scope"} - ${permission.reason}`);
4670
+ }
4671
+ lines.push("", "## Console Steps", "");
4672
+ for (const [i, step] of steps.entries()) {
4673
+ lines.push(`${i + 1}. ${step.title}: ${step.detail}`);
4674
+ }
4675
+ if (spec.setup.knownQuirks?.length) {
4676
+ lines.push("", "## Known Quirks", "");
4677
+ for (const quirk of spec.setup.knownQuirks) lines.push(`- ${quirk.severity}: ${quirk.message}`);
4678
+ }
4679
+ return `${lines.join("\n")}
4680
+ `;
4681
+ }
4682
+ function renderAgentToolDescription(spec) {
4683
+ const hints = spec.plannerHints;
4684
+ const useFor = hints?.useFor?.length ? `Use for ${hints.useFor.join(", ")}.` : `Use for ${spec.title} workflows.`;
4685
+ const risk = hints ? `Freshness: ${hints.dataFreshness}. Write risk: ${hints.writeRisk}.` : "";
4686
+ return `${spec.title} (${spec.kind}). ${useFor} ${risk}`.trim();
4687
+ }
4688
+ function buildHealthcheckPlan(spec) {
4689
+ const healthcheck = spec.setup.healthcheck ?? { id: `${spec.kind}.static`, level: "static", description: "No healthcheck defined." };
4690
+ const requires = [];
4691
+ if (healthcheck.level === "connection") requires.push("connection_credentials");
4692
+ if (healthcheck.level === "client_config" && spec.auth.mode === "oauth2") requires.push("client_id", "client_secret");
4693
+ if (spec.auth.mode === "api_key") requires.push("api_key");
4694
+ if (spec.auth.mode === "hmac") requires.push("hmac_secret");
4695
+ return {
4696
+ kind: spec.kind,
4697
+ healthcheck,
4698
+ requires,
4699
+ message: healthcheck.description
4700
+ };
4701
+ }
4702
+ function renderTemplate(template, spec, options, redirectUri) {
4703
+ return template.replaceAll("{host}", options.host).replaceAll("{kind}", spec.kind).replaceAll("{redirectUri}", redirectUri ?? renderRedirectUri(spec, options));
4704
+ }
4705
+ function renderRedirectUri(spec, options) {
4706
+ return (options.callbackPath ?? spec.setup.redirectUriTemplate ?? "").replaceAll("{host}", options.host).replaceAll("{kind}", spec.kind);
4707
+ }
4708
+ function consoleStepsToText(steps) {
4709
+ return steps.map((step, index) => `${index + 1}. ${step.title}: ${step.detail}`).join("\n");
4710
+ }
4711
+
4712
+ // src/specs/validation.ts
4713
+ function validateIntegrationSpec(spec) {
4714
+ const issues = [];
4715
+ if (!spec.kind.trim()) issues.push({ path: "kind", message: "kind is required" });
4716
+ if (!spec.title.trim()) issues.push({ path: "title", message: "title is required" });
4717
+ if (!spec.actions.length) issues.push({ path: "actions", message: "at least one action is required" });
4718
+ if (!spec.permissions.length) issues.push({ path: "permissions", message: "at least one permission is required" });
4719
+ if (spec.auth.mode === "oauth2") {
4720
+ if (!spec.auth.authorizationUrl) issues.push({ path: "auth.authorizationUrl", message: "authorizationUrl is required" });
4721
+ if (!spec.auth.tokenUrl) issues.push({ path: "auth.tokenUrl", message: "tokenUrl is required" });
4722
+ if (!spec.auth.redirectUriTemplate) issues.push({ path: "auth.redirectUriTemplate", message: "redirectUriTemplate is required" });
4723
+ }
4724
+ const actionIds = /* @__PURE__ */ new Set();
4725
+ for (const [index, action] of spec.actions.entries()) {
4726
+ if (actionIds.has(action.id)) issues.push({ path: `actions[${index}].id`, message: `duplicate action id ${action.id}` });
4727
+ actionIds.add(action.id);
4728
+ }
4729
+ return { ok: issues.length === 0, issues };
4730
+ }
4731
+ function assertValidIntegrationSpec(spec) {
4732
+ const result = validateIntegrationSpec(spec);
4733
+ if (!result.ok) {
4734
+ throw new Error(`Invalid integration spec ${spec.kind}: ${result.issues.map((i) => `${i.path}: ${i.message}`).join("; ")}`);
4735
+ }
4736
+ }
4737
+ function validateCredentialFormat(field, value) {
4738
+ if (!value.trim()) return { ok: false, field: field.label, message: `${field.label} is required` };
4739
+ if (field.regex && !new RegExp(field.regex).test(value)) {
4740
+ return { ok: false, field: field.label, message: `${field.label} does not match expected format` };
4741
+ }
4742
+ return { ok: true, field: field.label };
4743
+ }
4744
+ function validateCredentialSet(spec, values) {
4745
+ return spec.setup.credentialFields.map((field) => {
4746
+ const key = field.env ?? field.label;
4747
+ return validateCredentialFormat(field, values[key] ?? "");
4748
+ });
4749
+ }
4750
+
4084
4751
  // src/index.ts
4085
4752
  var IntegrationError = class extends Error {
4086
4753
  constructor(message, code) {
@@ -4408,6 +5075,7 @@ function unique3(values) {
4408
5075
  export {
4409
5076
  CredentialsExpired,
4410
5077
  DEFAULT_SIGNATURE_TOLERANCE_SECONDS,
5078
+ INTEGRATION_FAMILIES,
4411
5079
  InMemoryConnectionStore,
4412
5080
  InMemoryOAuthFlowStore,
4413
5081
  IntegrationError,
@@ -4418,10 +5086,13 @@ export {
4418
5086
  airtableConnector,
4419
5087
  asanaConnector,
4420
5088
  assertValidConnectorManifest,
5089
+ assertValidIntegrationSpec,
4421
5090
  buildApprovalRequest,
5091
+ buildHealthcheckPlan,
4422
5092
  buildIntegrationCoverageConnectors,
4423
5093
  buildIntegrationInvocationEnvelope,
4424
5094
  buildIntegrationToolCatalog,
5095
+ consoleStepsToText,
4425
5096
  consumePendingFlow,
4426
5097
  createConnectorAdapterProvider,
4427
5098
  createDefaultIntegrationPolicyEngine,
@@ -4430,6 +5101,8 @@ export {
4430
5101
  declarativeRestConnector,
4431
5102
  exchangeAuthorizationCode,
4432
5103
  firstHeader,
5104
+ getIntegrationFamily,
5105
+ getIntegrationSpec,
4433
5106
  githubConnector,
4434
5107
  gitlabConnector,
4435
5108
  googleCalendar,
@@ -4439,9 +5112,12 @@ export {
4439
5112
  importMcpConnector,
4440
5113
  importOpenApiConnector,
4441
5114
  integrationCoverageChecklistMarkdown,
5115
+ integrationSpecToConnector,
4442
5116
  integrationToolName,
4443
5117
  invocationRequestFromEnvelope,
5118
+ listExecutableIntegrationSpecs,
4444
5119
  listIntegrationCoverageSpecs,
5120
+ listIntegrationSpecs,
4445
5121
  manifestToConnector,
4446
5122
  microsoftCalendar,
4447
5123
  normalizeIntegrationResult,
@@ -4452,19 +5128,26 @@ export {
4452
5128
  redactCapability,
4453
5129
  redactInvocationEnvelope,
4454
5130
  refreshAccessToken,
5131
+ renderAgentToolDescription,
5132
+ renderConsoleSteps,
5133
+ renderRunbookMarkdown,
4455
5134
  salesforceConnector,
4456
5135
  sanitizeConnection,
4457
5136
  searchIntegrationTools,
4458
5137
  signCapability,
4459
5138
  slack,
4460
5139
  slackEventsConnector,
5140
+ specAuthToConnectorAuth,
4461
5141
  startOAuthFlow,
4462
5142
  stripePackConnector,
4463
5143
  stripeWebhookReceiverConnector,
4464
5144
  toMcpTools,
4465
5145
  twilioSmsConnector,
4466
5146
  validateConnectorManifest,
5147
+ validateCredentialFormat,
5148
+ validateCredentialSet,
4467
5149
  validateIntegrationInvocationEnvelope,
5150
+ validateIntegrationSpec,
4468
5151
  verifyCapabilityToken,
4469
5152
  verifyHmacSignature,
4470
5153
  verifySlackSignature,