@tangle-network/agent-integrations 0.16.0 → 0.16.1

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 CHANGED
@@ -1,2499 +1 @@
1
- type IntegrationSupportTier = 'catalogOnly' | 'setupReady' | 'gatewayExecutable' | 'firstPartyExecutable' | 'sandboxExecutable';
2
- interface IntegrationCatalogSource {
3
- id: string;
4
- connectors: IntegrationConnector[];
5
- precedence?: number;
6
- }
7
- interface IntegrationRegistrySourceRef {
8
- sourceId: string;
9
- providerId: string;
10
- connectorId: string;
11
- supportTier: IntegrationSupportTier;
12
- actionCount: number;
13
- triggerCount: number;
14
- }
15
- interface IntegrationRegistryConflict {
16
- field: 'auth' | 'category';
17
- values: Array<{
18
- value: string;
19
- sourceId: string;
20
- connectorId: string;
21
- }>;
22
- }
23
- interface IntegrationRegistryEntry {
24
- canonicalId: string;
25
- connector: IntegrationConnector;
26
- aliases: string[];
27
- supportTier: IntegrationSupportTier;
28
- sources: IntegrationRegistrySourceRef[];
29
- conflicts: IntegrationRegistryConflict[];
30
- }
31
- interface IntegrationRegistry {
32
- entries: IntegrationRegistryEntry[];
33
- connectors: IntegrationConnector[];
34
- byId: Map<string, IntegrationRegistryEntry>;
35
- }
36
- interface IntegrationRegistrySummary {
37
- totalEntries: number;
38
- totalSources: number;
39
- toolBindableEntries: number;
40
- conflictEntries: number;
41
- bySupportTier: Record<IntegrationSupportTier, number>;
42
- }
43
- interface ComposeIntegrationRegistryOptions {
44
- aliases?: Record<string, string>;
45
- sourcePrecedence?: Record<string, number>;
46
- }
47
- declare function buildDefaultIntegrationRegistry(options?: {
48
- includeSpecs?: boolean;
49
- includeActivepieces?: boolean;
50
- }): IntegrationRegistry;
51
- declare function composeIntegrationRegistry(sources: IntegrationCatalogSource[], options?: ComposeIntegrationRegistryOptions): IntegrationRegistry;
52
- declare function summarizeIntegrationRegistry(registry: IntegrationRegistry): IntegrationRegistrySummary;
53
- declare function canonicalConnectorId(id: string, aliases?: Record<string, string>): string;
54
- declare function inferIntegrationSupportTier(connector: IntegrationConnector): IntegrationSupportTier;
55
-
56
- type IntegrationAuditEventType = 'connection.created' | 'connection.updated' | 'connection.revoked' | 'grant.created' | 'grant.revoked' | 'capability.issued' | 'action.invoked' | 'action.failed' | 'trigger.subscribed' | 'trigger.received' | 'workflow.installed' | 'approval.requested' | 'approval.resolved' | 'healthcheck.completed';
57
- interface IntegrationAuditEvent {
58
- id: string;
59
- type: IntegrationAuditEventType;
60
- occurredAt: string;
61
- actor?: IntegrationActor;
62
- connectionId?: string;
63
- providerId?: string;
64
- connectorId?: string;
65
- action?: string;
66
- risk?: IntegrationConnectorAction['risk'];
67
- dataClass?: IntegrationDataClass;
68
- ok?: boolean;
69
- message?: string;
70
- metadata?: Record<string, unknown>;
71
- }
72
- interface IntegrationAuditSink {
73
- record(event: IntegrationAuditEvent): Promise<void> | void;
74
- }
75
- interface IntegrationAuditStore extends IntegrationAuditSink {
76
- list(filter?: IntegrationAuditFilter): Promise<IntegrationAuditEvent[]> | IntegrationAuditEvent[];
77
- }
78
- interface IntegrationAuditFilter {
79
- type?: IntegrationAuditEventType;
80
- actor?: IntegrationActor;
81
- connectionId?: string;
82
- providerId?: string;
83
- connectorId?: string;
84
- action?: string;
85
- }
86
- declare class InMemoryIntegrationAuditStore implements IntegrationAuditStore {
87
- private readonly events;
88
- record(event: IntegrationAuditEvent): void;
89
- list(filter?: IntegrationAuditFilter): IntegrationAuditEvent[];
90
- }
91
- declare function createIntegrationAuditEvent(input: Omit<IntegrationAuditEvent, 'id' | 'occurredAt'> & {
92
- id?: string;
93
- occurredAt?: string | Date;
94
- now?: () => Date;
95
- }): IntegrationAuditEvent;
96
- declare function createAuditingActionGuard(options: {
97
- sink: IntegrationAuditSink;
98
- subject?: IntegrationActor;
99
- now?: () => Date;
100
- includeInputPreview?: boolean;
101
- }): IntegrationActionGuard;
102
- declare function sanitizeAuditConnection(connection: IntegrationConnection): Record<string, unknown>;
103
-
104
- type IntegrationApprovalStatus = 'pending' | 'approved' | 'denied' | 'expired';
105
- interface IntegrationApprovalRecord {
106
- id: string;
107
- request: IntegrationApprovalRequest;
108
- status: IntegrationApprovalStatus;
109
- requestedAt: string;
110
- resolvedAt?: string;
111
- resolvedBy?: IntegrationActor;
112
- reason?: string;
113
- expiresAt?: string;
114
- metadata?: Record<string, unknown>;
115
- }
116
- interface IntegrationApprovalStore {
117
- get(approvalId: string): Promise<IntegrationApprovalRecord | undefined> | IntegrationApprovalRecord | undefined;
118
- put(record: IntegrationApprovalRecord): Promise<void> | void;
119
- list(filter?: IntegrationApprovalFilter): Promise<IntegrationApprovalRecord[]> | IntegrationApprovalRecord[];
120
- }
121
- interface IntegrationApprovalFilter {
122
- status?: IntegrationApprovalStatus;
123
- connectionId?: string;
124
- connectorId?: string;
125
- action?: string;
126
- actor?: IntegrationActor;
127
- }
128
- interface ApprovalBackedPolicyOptions {
129
- base: IntegrationPolicyEngine;
130
- store: IntegrationApprovalStore;
131
- audit?: IntegrationAuditSink;
132
- now?: () => Date;
133
- approvalTtlMs?: number;
134
- }
135
- declare class InMemoryIntegrationApprovalStore implements IntegrationApprovalStore {
136
- private readonly records;
137
- get(approvalId: string): IntegrationApprovalRecord | undefined;
138
- put(record: IntegrationApprovalRecord): void;
139
- list(filter?: IntegrationApprovalFilter): IntegrationApprovalRecord[];
140
- }
141
- declare class ApprovalBackedPolicyEngine implements IntegrationPolicyEngine {
142
- private readonly base;
143
- private readonly store;
144
- private readonly audit;
145
- private readonly now;
146
- private readonly approvalTtlMs;
147
- constructor(options: ApprovalBackedPolicyOptions);
148
- decide(ctx: IntegrationGuardContext & {
149
- subject: IntegrationActor;
150
- }): Promise<IntegrationPolicyDecision>;
151
- private findApprovedRecord;
152
- }
153
- declare function createApprovalBackedPolicyEngine(options: ApprovalBackedPolicyOptions): ApprovalBackedPolicyEngine;
154
- declare function resolveIntegrationApproval(input: {
155
- store: IntegrationApprovalStore;
156
- approvalId: string;
157
- approved: boolean;
158
- resolvedBy: IntegrationActor;
159
- reason?: string;
160
- metadata?: Record<string, unknown>;
161
- audit?: IntegrationAuditSink;
162
- now?: () => Date;
163
- }): Promise<IntegrationApprovalRecord>;
164
-
165
- declare const CANONICAL_INTEGRATION_ACTIONS: {
166
- readonly googleCalendarEventsList: "google-calendar.events.list";
167
- readonly googleCalendarEventsCreate: "google-calendar.events.create";
168
- readonly gmailMessagesSearch: "gmail.messages.search";
169
- readonly gmailMessagesSend: "gmail.messages.send";
170
- readonly googleDriveFilesSearch: "google-drive.files.search";
171
- readonly googleDriveFilesRead: "google-drive.files.read";
172
- readonly githubRepositoriesGet: "github.repositories.get";
173
- readonly githubIssuesSearch: "github.issues.search";
174
- readonly githubIssuesCreate: "github.issues.create";
175
- readonly githubPullRequestsComment: "github.pull-requests.comment";
176
- readonly slackChannelsList: "slack.channels.list";
177
- readonly slackMessagesSearch: "slack.messages.search";
178
- readonly slackMessagesPost: "slack.messages.post";
179
- readonly providerHttpRequest: "provider.http.request";
180
- };
181
- type CanonicalIntegrationActionId = typeof CANONICAL_INTEGRATION_ACTIONS[keyof typeof CANONICAL_INTEGRATION_ACTIONS];
182
- interface CanonicalLaunchConnectorOptions {
183
- providerId?: string;
184
- includeProviderPassthrough?: boolean;
185
- }
186
- declare function buildCanonicalLaunchConnectors(options?: CanonicalLaunchConnectorOptions): IntegrationConnector[];
187
- declare function canonicalActionConnectorId(actionId: string): string | undefined;
188
-
189
- interface IntegrationToolDefinition {
190
- name: string;
191
- title: string;
192
- description: string;
193
- providerId: string;
194
- connectorId: string;
195
- connectorTitle: string;
196
- category: IntegrationConnectorCategory;
197
- action: IntegrationConnectorAction;
198
- risk: IntegrationActionRisk;
199
- dataClass: IntegrationDataClass;
200
- requiredScopes: string[];
201
- inputSchema?: unknown;
202
- outputSchema?: unknown;
203
- tags: string[];
204
- }
205
- interface IntegrationToolSearchFilters {
206
- providerId?: string;
207
- connectorId?: string;
208
- category?: IntegrationConnectorCategory;
209
- maxRisk?: IntegrationActionRisk;
210
- dataClass?: IntegrationDataClass;
211
- limit?: number;
212
- }
213
- interface IntegrationToolSearchResult {
214
- tool: IntegrationToolDefinition;
215
- score: number;
216
- matched: string[];
217
- }
218
- interface McpToolDefinition {
219
- name: string;
220
- description: string;
221
- inputSchema: unknown;
222
- }
223
- declare function integrationToolName(providerId: string, connectorId: string, actionId: string): string;
224
- declare function parseIntegrationToolName(name: string): {
225
- providerId: string;
226
- connectorId: string;
227
- actionId: string;
228
- };
229
- declare function buildIntegrationToolCatalog(connectors: IntegrationConnector[]): IntegrationToolDefinition[];
230
- declare function searchIntegrationTools(catalog: IntegrationToolDefinition[], query: string, filters?: IntegrationToolSearchFilters): IntegrationToolSearchResult[];
231
- declare function toMcpTools(tools: IntegrationToolDefinition[]): McpToolDefinition[];
232
-
233
- type IntegrationRequirementMode = 'read' | 'write' | 'trigger';
234
- type IntegrationRequirementStatus = 'ready' | 'missing_connection' | 'not_executable' | 'unknown_connector';
235
- interface IntegrationRequirement {
236
- id: string;
237
- connectorId: string;
238
- reason: string;
239
- mode: IntegrationRequirementMode;
240
- requiredActions?: string[];
241
- requiredTriggers?: string[];
242
- requiredScopes?: string[];
243
- optional?: boolean;
244
- }
245
- interface IntegrationManifest {
246
- id: string;
247
- title?: string;
248
- owner?: IntegrationActor;
249
- requirements: IntegrationRequirement[];
250
- metadata?: Record<string, unknown>;
251
- }
252
- interface IntegrationRequirementResolution {
253
- requirement: IntegrationRequirement;
254
- status: IntegrationRequirementStatus;
255
- connector?: IntegrationConnector;
256
- registryEntry?: IntegrationRegistryEntry;
257
- connection?: IntegrationConnection;
258
- missingScopes: string[];
259
- missingActions: string[];
260
- missingTriggers: string[];
261
- message: string;
262
- }
263
- interface IntegrationManifestResolution {
264
- manifest: IntegrationManifest;
265
- owner: IntegrationActor;
266
- ready: IntegrationRequirementResolution[];
267
- missing: IntegrationRequirementResolution[];
268
- optionalMissing: IntegrationRequirementResolution[];
269
- }
270
- interface IntegrationGrant {
271
- id: string;
272
- manifestId: string;
273
- requirementId: string;
274
- owner: IntegrationActor;
275
- grantee: IntegrationActor;
276
- connectionId: string;
277
- connectorId: string;
278
- scopes: string[];
279
- allowedActions: string[];
280
- allowedTriggers: string[];
281
- status: 'active' | 'revoked';
282
- createdAt: string;
283
- updatedAt: string;
284
- metadata?: Record<string, unknown>;
285
- }
286
- interface IntegrationGrantStore {
287
- get(grantId: string): Promise<IntegrationGrant | undefined> | IntegrationGrant | undefined;
288
- put(grant: IntegrationGrant): Promise<void> | void;
289
- listByManifest(manifestId: string, grantee?: IntegrationActor): Promise<IntegrationGrant[]> | IntegrationGrant[];
290
- listByGrantee(grantee: IntegrationActor): Promise<IntegrationGrant[]> | IntegrationGrant[];
291
- delete?(grantId: string): Promise<void> | void;
292
- }
293
- interface IntegrationCapabilityBinding {
294
- requirementId: string;
295
- connectorId: string;
296
- connectionId: string;
297
- grantId: string;
298
- scopes: string[];
299
- allowedActions: string[];
300
- allowedTriggers: string[];
301
- capability: IssuedIntegrationCapability;
302
- }
303
- interface IntegrationSandboxBundle {
304
- manifestId: string;
305
- subject: IntegrationActor;
306
- capabilities: IntegrationCapabilityBinding[];
307
- connectors: IntegrationConnector[];
308
- tools: IntegrationToolDefinition[];
309
- expiresAt: string;
310
- }
311
- interface IntegrationRuntimeHub {
312
- listRegistry(): Promise<IntegrationRegistry> | IntegrationRegistry;
313
- listConnections(owner: IntegrationActor): Promise<IntegrationConnection[]> | IntegrationConnection[];
314
- issueCapability(input: {
315
- subject: IntegrationActor;
316
- connectionId: string;
317
- scopes: string[];
318
- allowedActions: string[];
319
- ttlMs: number;
320
- metadata?: Record<string, unknown>;
321
- }): Promise<IssuedIntegrationCapability> | IssuedIntegrationCapability;
322
- }
323
- interface IntegrationRuntimeOptions {
324
- hub: IntegrationRuntimeHub;
325
- grants?: IntegrationGrantStore;
326
- now?: () => Date;
327
- }
328
- declare class InMemoryIntegrationGrantStore implements IntegrationGrantStore {
329
- private readonly grants;
330
- get(grantId: string): IntegrationGrant | undefined;
331
- put(grant: IntegrationGrant): void;
332
- listByManifest(manifestId: string, grantee?: IntegrationActor): IntegrationGrant[];
333
- listByGrantee(grantee: IntegrationActor): IntegrationGrant[];
334
- delete(grantId: string): void;
335
- }
336
- declare class IntegrationRuntime {
337
- private readonly hub;
338
- private readonly grants;
339
- private readonly now;
340
- constructor(options: IntegrationRuntimeOptions);
341
- registry(): Promise<IntegrationRegistry>;
342
- resolveManifest(manifest: IntegrationManifest, owner: IntegrationActor): Promise<IntegrationManifestResolution>;
343
- createGrants(input: {
344
- manifest: IntegrationManifest;
345
- owner: IntegrationActor;
346
- grantee: IntegrationActor;
347
- metadata?: Record<string, unknown>;
348
- }): Promise<IntegrationGrant[]>;
349
- buildSandboxBundle(input: {
350
- manifestId: string;
351
- subject: IntegrationActor;
352
- ttlMs: number;
353
- grantee?: IntegrationActor;
354
- }): Promise<IntegrationSandboxBundle>;
355
- }
356
- declare function createIntegrationRuntime(options: IntegrationRuntimeOptions): IntegrationRuntime;
357
-
358
- declare const DEFAULT_INTEGRATION_BRIDGE_ENV = "TANGLE_INTEGRATION_BUNDLE";
359
- interface IntegrationBridgePayload {
360
- version: 1;
361
- manifestId: string;
362
- subject: IntegrationSandboxBundle['subject'];
363
- expiresAt: string;
364
- tools: IntegrationBridgeToolBinding[];
365
- }
366
- interface IntegrationBridgeToolBinding {
367
- name: string;
368
- title: string;
369
- connectorId: string;
370
- connectionId: string;
371
- action: string;
372
- risk: string;
373
- dataClass: string;
374
- requiredScopes: string[];
375
- capabilityToken: string;
376
- }
377
- declare function buildIntegrationBridgePayload(bundle: IntegrationSandboxBundle): IntegrationBridgePayload;
378
- declare function encodeIntegrationBridgePayload(payload: IntegrationBridgePayload): string;
379
- declare function decodeIntegrationBridgePayload(encoded: string): IntegrationBridgePayload;
380
- declare function buildIntegrationBridgeEnvironment(bundle: IntegrationSandboxBundle, options?: {
381
- envVar?: string;
382
- }): Record<string, string>;
383
- declare function parseIntegrationBridgeEnvironment(env: Record<string, string | undefined>, options?: {
384
- envVar?: string;
385
- }): IntegrationBridgePayload;
386
- declare function redactIntegrationBridgePayload(payload: IntegrationBridgePayload): IntegrationBridgePayload;
387
-
388
- interface TangleIntegrationsClientOptions {
389
- endpoint: string;
390
- bridge?: IntegrationBridgePayload;
391
- env?: Record<string, string | undefined>;
392
- envVar?: string;
393
- fetchImpl?: typeof fetch;
394
- getCapabilityToken?: (tool: IntegrationBridgeToolBinding) => string | Promise<string>;
395
- }
396
- interface TangleIntegrationInvokeInput<TInput = unknown> {
397
- tool: string;
398
- input?: TInput;
399
- idempotencyKey?: string;
400
- dryRun?: boolean;
401
- metadata?: Record<string, unknown>;
402
- }
403
- interface TangleIntegrationInvokeResult<TOutput = unknown> {
404
- status: 'ok' | 'approval_required' | 'failed';
405
- action: string;
406
- output?: TOutput;
407
- approval?: unknown;
408
- error?: string;
409
- metadata?: Record<string, unknown>;
410
- }
411
- declare class TangleIntegrationsClient {
412
- private readonly endpoint;
413
- private readonly bridge;
414
- private readonly fetchImpl;
415
- private readonly getCapabilityToken;
416
- constructor(options: TangleIntegrationsClientOptions);
417
- tools(): IntegrationBridgeToolBinding[];
418
- findTool(toolOrAction: string): IntegrationBridgeToolBinding;
419
- invoke<TOutput = unknown, TInput = unknown>(input: TangleIntegrationInvokeInput<TInput>): Promise<TangleIntegrationInvokeResult<TOutput>>;
420
- }
421
- declare function createTangleIntegrationsClient(options: TangleIntegrationsClientOptions): TangleIntegrationsClient;
422
-
423
- interface ConsentSummary {
424
- title: string;
425
- body: string;
426
- bullets: string[];
427
- primaryAction: string;
428
- risk: 'read' | 'write' | 'destructive';
429
- connectorIds: string[];
430
- }
431
- interface RenderConsentOptions {
432
- appName?: string;
433
- connectors?: IntegrationConnector[];
434
- }
435
- declare function renderConsentSummary(manifestOrResolution: IntegrationManifest | IntegrationManifestResolution, options?: RenderConsentOptions): ConsentSummary;
436
- declare function renderApprovalCopy(input: {
437
- appName: string;
438
- connectorTitle: string;
439
- action: IntegrationConnectorAction;
440
- approvalId?: string;
441
- }): ConsentSummary;
442
-
443
- /**
444
- * Connector primitives — the contract a concrete first-party integration
445
- * (Google Calendar, HubSpot, Stripe, ...) implements. Lower level than the
446
- * hub-side `IntegrationProvider` interface from `../index.ts`: a single
447
- * `IntegrationProvider` typically wraps several connectors (e.g., a
448
- * "first-party" provider that lists all your shipped connectors as a
449
- * single catalog).
450
- *
451
- * Layering:
452
- *
453
- * IntegrationHub — vendor-neutral facade (../index.ts)
454
- * ↓
455
- * IntegrationProvider — one per vendor (Nango/Composio/first-party)
456
- * ↓
457
- * ConnectorAdapter (this file) — one per integration (Google Calendar, ...)
458
- * ↓
459
- * upstream HTTP API — vendor SDK / fetch / OAuth
460
- *
461
- * Three load-bearing decisions encoded here:
462
- *
463
- * 1. Capabilities are typed (`read` vs `mutation`). Every mutation MUST
464
- * declare a CAS strategy. Conflict resolution is the SDK's job, not the
465
- * connector's. `validateConnectorManifest()` rejects unsafe manifests
466
- * before a connector is registered.
467
- *
468
- * 2. ConsistencyModel pins what the rest of the system can assume:
469
- * authoritative → the source IS the truth (Calendar, payments)
470
- * cache → we mirror with TTL and may serve stale (price list)
471
- * advisory → informational only (FAQ doc)
472
- * Agent planners can (and should) refuse to promise outcomes based on
473
- * `cache`/`advisory` data without a live `authoritative` confirmation.
474
- *
475
- * 3. Capabilities surface to the calling agent's tool registry by
476
- * transformation, not by hand-wiring. Adding a connector automatically
477
- * expands the agent's toolbelt for that specific user without touching
478
- * the prompt or runner.
479
- */
480
- /** Minimal JSON-schema shape used for capability arg validation. We
481
- * intentionally don't pull `@types/json-schema` — most consumers already
482
- * declare parameters as `Record<string, unknown>` and the
483
- * shape is whatever the LLM SDK's structured-output expects. Keep the
484
- * contract loose at the boundary; tighten via runtime zod where needed. */
485
- type CapabilityParameterSchema = Record<string, unknown>;
486
- /** What the rest of the system is allowed to assume about freshness. */
487
- type ConsistencyModel = 'authoritative' | 'cache' | 'advisory';
488
- /** Capability classes. `read` is safe to retry; `mutation` must go through
489
- * MutationGuard (CAS + idempotency). `subscribe` is reserved for future
490
- * push-driven sources (webhook callbacks) and is not yet wired. */
491
- type CapabilityClass = 'read' | 'mutation' | 'subscribe';
492
- /** Compare-and-swap strategy a mutation uses to detect conflicts. */
493
- type CASStrategy =
494
- /** Upstream returns an etag/sequence on read, accepts If-Match on write
495
- * (Google Calendar, GitHub, GDocs revision_id). The connector returns
496
- * 412 / Precondition Failed on conflict; the SDK maps to ResourceContention. */
497
- 'etag-if-match'
498
- /** Upstream guarantees exactly-once-per-key (Stripe, idempotent webhooks).
499
- * The SDK passes the idempotency key through; no etag check. */
500
- | 'native-idempotency'
501
- /** No upstream concurrency control. Connector MUST do read-then-write
502
- * and verify nothing changed in-between (best-effort). Suitable only
503
- * for low-contention single-user resources; rejected for any
504
- * consistencyModel='authoritative' write that may race. */
505
- | 'optimistic-read-verify'
506
- /** Source is not contended (e.g. logging, telemetry). Mutations are
507
- * fire-and-forget. Marks the capability as not eligible for
508
- * authoritative writes. */
509
- | 'none';
510
- interface CapabilityRead {
511
- name: string;
512
- class: 'read';
513
- description: string;
514
- /** JSON-schema for the tool args the agent passes when invoking. */
515
- parameters: CapabilityParameterSchema;
516
- /** Optional: declare which scopes (per the connector manifest) this
517
- * capability requires. The capability is hidden from the agent's
518
- * tool registry if the user's grant didn't include them. */
519
- requiredScopes?: string[];
520
- }
521
- interface CapabilityMutation {
522
- name: string;
523
- class: 'mutation';
524
- description: string;
525
- parameters: CapabilityParameterSchema;
526
- /** Mandatory: how does the connector guarantee at-most-once + conflict-detect? */
527
- cas: CASStrategy;
528
- /** True for capabilities that affect resources outside the calling user
529
- * (e.g. booking against a shared calendar, charging a card). The agent's
530
- * planner treats these specially: requires explicit caller confirmation
531
- * before the call. */
532
- externalEffect: boolean;
533
- requiredScopes?: string[];
534
- }
535
- type Capability = CapabilityRead | CapabilityMutation;
536
- /** OAuth2 scope catalog the user has granted us, plus arbitrary metadata
537
- * the connector pinned at connect-time (calendar id, sheet id, webhook
538
- * url, …). `metadata` MUST NOT contain secrets — those go in the
539
- * encrypted credentials envelope. */
540
- interface DataSourceMetadata {
541
- scopes: string[];
542
- [key: string]: unknown;
543
- }
544
- /** A connected, authenticated, ready-to-call data source for a project.
545
- * Persistence shape mirrors the product's connection/source row but normalized — the
546
- * encrypted credentials envelope is decrypted at hand-out time and held
547
- * in memory only for the duration of the call. */
548
- interface ResolvedDataSource {
549
- id: string;
550
- projectId: string;
551
- publishedAgentId: string | null;
552
- kind: string;
553
- label: string;
554
- consistencyModel: ConsistencyModel;
555
- scopes: string[];
556
- metadata: Record<string, unknown>;
557
- /** Unwrapped credentials handed to the connector at call-time. Never
558
- * persisted in this shape; never logged. */
559
- credentials: ConnectorCredentials;
560
- status: 'active' | 'revoked' | 'error';
561
- }
562
- /** Discriminated union of credential shapes. Connectors that need new
563
- * shapes extend this union — `kind` is sealed via the tagged pattern so
564
- * TypeScript catches an exhaustiveness gap at compile time. */
565
- type ConnectorCredentials = {
566
- kind: 'oauth2';
567
- accessToken: string;
568
- refreshToken?: string;
569
- expiresAt?: number;
570
- } | {
571
- kind: 'api-key';
572
- apiKey: string;
573
- } | {
574
- kind: 'hmac';
575
- secret: string;
576
- } | {
577
- kind: 'none';
578
- };
579
- /** Result of a read capability invocation. */
580
- interface CapabilityReadResult {
581
- /** Free-form payload — the connector's data shape. The agent receives
582
- * this as the tool result; planners consume it via JSON-shape contract
583
- * declared in the capability's `parameters` (output schema). */
584
- data: unknown;
585
- /** Optional etag/sequence the caller can reuse for a subsequent CAS
586
- * mutation. */
587
- etag?: string;
588
- /** When this read happened (UTC ms since epoch). */
589
- fetchedAt: number;
590
- }
591
- /** Result of a mutation capability invocation. Either committed (with the
592
- * resulting etag/sequence so the caller can chain mutations), or
593
- * contended (the upstream rejected with a state mismatch — the agent
594
- * should re-read and retry, or surface alternatives to the caller). */
595
- type CapabilityMutationResult = {
596
- status: 'committed';
597
- data: unknown;
598
- etagAfter?: string;
599
- committedAt: number;
600
- /** True iff this commit was returned from the idempotency store
601
- * rather than executed against upstream. The caller can use this
602
- * to suppress confirmation messages on retry. */
603
- idempotentReplay: boolean;
604
- } | {
605
- status: 'conflict';
606
- /** Best-effort alternative options the upstream surfaced (e.g.,
607
- * next-available calendar slots after a booking conflict). */
608
- alternatives: unknown[];
609
- /** The current authoritative state, if the connector could re-read
610
- * cheaply. */
611
- currentState?: unknown;
612
- message: string;
613
- } | {
614
- status: 'rate-limited';
615
- /** Wall-clock ms the caller should wait before retrying. The SDK
616
- * computes this from the bucket's refill schedule so the agent
617
- * doesn't have to guess. */
618
- retryAfterMs: number;
619
- message: string;
620
- };
621
- /** Inputs the SDK passes into the connector's executeRead / executeMutation. */
622
- interface ConnectorInvocation {
623
- source: ResolvedDataSource;
624
- capabilityName: string;
625
- args: Record<string, unknown>;
626
- /** Idempotency key the caller (or the SDK's defaulting policy) supplied.
627
- * Always present at the connector boundary — the SDK manufactures one
628
- * if the agent didn't pass one. */
629
- idempotencyKey: string;
630
- /** Optional caller-supplied etag the connector should send as If-Match. */
631
- expectedEtag?: string;
632
- /** Product/session id (if any) for forensic logging. */
633
- callSessionId?: string;
634
- }
635
- /** A single inbound event extracted from a push payload. The webhook
636
- * receiver persists one `InboundEvent` row per entry the connector returns. */
637
- interface InboundEvent {
638
- eventType: string;
639
- providerEventId?: string;
640
- payload: Record<string, unknown>;
641
- }
642
- /** Adapter response from an inbound-webhook dispatch. The receiver persists
643
- * every `events[]` entry, then either honors the connector's `response`
644
- * override (Slack `url_verification` echo, provider-specific 2xx body) or
645
- * defaults to `{status: 200, body: {received: true, count: events.length}}`. */
646
- interface EventHandlerResult {
647
- events: InboundEvent[];
648
- /** Optional: how to respond to the provider. Stripe wants 200 within
649
- * 30s; Slack wants the challenge param echoed. */
650
- response?: {
651
- status: number;
652
- body: unknown;
653
- headers?: Record<string, string>;
654
- };
655
- }
656
- /**
657
- * Connector adapter — one per integration kind. Stateless. The SDK holds
658
- * the persistence + crypto + mutation-guard concerns; the adapter only
659
- * knows how to talk to its upstream.
660
- */
661
- interface ConnectorAdapter {
662
- /** Manifest entry the registry uses to render UI + validate args. */
663
- manifest: ConnectorManifest;
664
- /** Read invocation. Required when manifest.capabilities contains reads.
665
- * Should return whatever shape the capability declared
666
- * in its parameters output schema. */
667
- executeRead?(inv: ConnectorInvocation): Promise<CapabilityReadResult>;
668
- /** Mutation invocation. Required when manifest.capabilities contains mutations.
669
- * Throws ResourceContention on a CAS miss; throws
670
- * any other Error for upstream failures. The MutationGuard wraps this
671
- * with idempotency-key short-circuit + audit logging — adapters do
672
- * NOT manage their own dedup. */
673
- executeMutation?(inv: ConnectorInvocation): Promise<CapabilityMutationResult>;
674
- /** Inbound webhook signature verifier. Called BEFORE handleInboundEvent.
675
- * MUST use constant-time comparison (`crypto.timingSafeEqual`) for any
676
- * HMAC check. The receiver returns 401 on `valid=false` without invoking
677
- * handleInboundEvent. Optional: connectors that don't accept push events
678
- * omit this method and the receiver returns 405 for the kind. */
679
- verifySignature?(input: {
680
- rawBody: string;
681
- headers: Record<string, string | string[] | undefined>;
682
- source: ResolvedDataSource;
683
- }): {
684
- valid: boolean;
685
- reason?: string;
686
- };
687
- /** Inbound webhook dispatch. Called AFTER verifySignature passes. The
688
- * adapter parses the provider payload and emits zero-or-more
689
- * `InboundEvent` rows; the receiver persists them as one row each (modulo
690
- * the (dataSourceId, providerEventId) dedup unique). The optional
691
- * `response` overrides the receiver's default 200 (Slack `url_verification`
692
- * needs to echo the challenge in the body to pass Slack's app-config check). */
693
- handleInboundEvent?(input: {
694
- source: ResolvedDataSource;
695
- rawBody: string;
696
- headers: Record<string, string | string[] | undefined>;
697
- }): Promise<EventHandlerResult>;
698
- /** OAuth callback handler — exchanges the auth code for tokens, returns
699
- * the credentials envelope + scopes + metadata. Only present for
700
- * oauth2-style adapters. */
701
- exchangeOAuth?(input: {
702
- code: string;
703
- state: string;
704
- codeVerifier: string;
705
- redirectUri: string;
706
- }): Promise<{
707
- credentials: ConnectorCredentials;
708
- scopes: string[];
709
- metadata: Record<string, unknown>;
710
- }>;
711
- /** Refresh access token. Only required for oauth2 adapters with
712
- * short-lived access tokens. */
713
- refreshToken?(input: ConnectorCredentials): Promise<ConnectorCredentials>;
714
- /** Health check — invoked when the user clicks "Test connection" in the
715
- * UI. Should perform the cheapest possible read that proves the grant
716
- * is still valid. Returns `{ok: false, reason}` rather than throwing
717
- * for the common case (token expired, scope missing). */
718
- test(source: ResolvedDataSource): Promise<{
719
- ok: true;
720
- } | {
721
- ok: false;
722
- reason: string;
723
- }>;
724
- }
725
- /** Static manifest a connector module exports. Drives the UI catalog,
726
- * scope display, capability discovery for the agent's tool registry. */
727
- interface ConnectorManifest {
728
- /** Stable kind id used as the foreign key in DataSource.kind. */
729
- kind: string;
730
- /** Human label shown in the UI catalog. */
731
- displayName: string;
732
- /** One-paragraph description shown next to the connect button. */
733
- description: string;
734
- /** Auth shape this connector requires. */
735
- auth: AuthSpec;
736
- /** Capability catalog — the agent's tool registry derives ToolDefinition
737
- * entries from this list at request time. */
738
- capabilities: Capability[];
739
- /** ConsistencyModel default for this kind — overridable per DataSource
740
- * if a particular instance is special (e.g., a user marks a sheet as
741
- * `cache` because they refresh it nightly). */
742
- defaultConsistencyModel: ConsistencyModel;
743
- /** Connector category for UI grouping. */
744
- category: 'calendar' | 'spreadsheet' | 'crm' | 'doc' | 'webhook' | 'storage' | 'comms' | 'commerce' | 'other';
745
- /** Optional icon URL or named icon. */
746
- icon?: string;
747
- /** Optional per-kind rate-limit budget. The SDK enforces it inside
748
- * `executeGuardedMutation` and the read path of `/invoke`. Omit to
749
- * leave the connector unrestricted. */
750
- rateLimit?: RateLimitSpec;
751
- }
752
- /** Token-bucket budget the SDK enforces against the connector's upstream.
753
- * We meter on OUR side rather than letting the upstream reject so a
754
- * chatty agent can't burn quota that's shared across customers (almost
755
- * every OAuth client is). */
756
- interface RateLimitSpec {
757
- /** Max requests per window. */
758
- requests: number;
759
- /** Window in ms. */
760
- windowMs: number;
761
- /** Whether to apply across all DataSources sharing the same OAuth
762
- * client (true; default), or per-DataSource (false). The former
763
- * matches how upstreams meter (per-app), so almost always pick true. */
764
- scope?: 'oauth-client' | 'data-source';
765
- }
766
- type AuthSpec = {
767
- kind: 'oauth2';
768
- /** Authorization endpoint URL. */
769
- authorizationUrl: string;
770
- /** Token endpoint URL. */
771
- tokenUrl: string;
772
- /** Scopes requested in the authorization grant. The user UI shows
773
- * these so the customer knows what's being shared. */
774
- scopes: string[];
775
- /** Whether the connector supports incremental authorization (Google
776
- * does; many don't). */
777
- incremental?: boolean;
778
- /** Env-var name holding the OAuth client_id. */
779
- clientIdEnv: string;
780
- /** Env-var name holding the OAuth client_secret. */
781
- clientSecretEnv: string;
782
- /** Optional extra params attached to the authorization URL (e.g.,
783
- * Google's `access_type=offline&prompt=consent` to obtain refresh
784
- * tokens). */
785
- extraAuthParams?: Record<string, string>;
786
- } | {
787
- kind: 'api-key';
788
- /** UI hint shown when collecting the key. */
789
- hint: string;
790
- } | {
791
- kind: 'hmac';
792
- } | {
793
- kind: 'none';
794
- };
795
- /** Thrown by `executeMutation` when upstream rejects on CAS — caught and
796
- * rewrapped by MutationGuard. */
797
- declare class ResourceContention extends Error {
798
- readonly alternatives: unknown[];
799
- readonly currentState?: unknown | undefined;
800
- readonly name = "ResourceContention";
801
- constructor(message: string, alternatives?: unknown[], currentState?: unknown | undefined);
802
- }
803
- /** Thrown when the connector finds the user's grant has been revoked or
804
- * the access token is no longer valid AND refresh failed. Surfaces to
805
- * the UI as "Reconnect required". */
806
- declare class CredentialsExpired extends Error {
807
- readonly dataSourceId: string;
808
- readonly name = "CredentialsExpired";
809
- constructor(message: string, dataSourceId: string);
810
- }
811
- interface ConnectorManifestValidationIssue {
812
- path: string;
813
- message: string;
814
- }
815
- interface ConnectorManifestValidationResult {
816
- ok: boolean;
817
- issues: ConnectorManifestValidationIssue[];
818
- }
819
- /** Validate the static connector manifest before a provider registers it.
820
- * This catches the expensive mistakes early: duplicate capability names,
821
- * mutation capabilities without CAS, authoritative fire-and-forget writes,
822
- * and invalid rate-limit specs. */
823
- declare function validateConnectorManifest(manifest: ConnectorManifest): ConnectorManifestValidationResult;
824
- declare function assertValidConnectorManifest(manifest: ConnectorManifest): void;
825
-
826
- interface ConnectorAdapterProviderOptions {
827
- id?: string;
828
- kind?: IntegrationProviderKind;
829
- adapters: ConnectorAdapter[];
830
- resolveDataSource: (connection: IntegrationConnection) => Promise<ResolvedDataSource> | ResolvedDataSource;
831
- now?: () => Date;
832
- }
833
- declare function createConnectorAdapterProvider(options: ConnectorAdapterProviderOptions): IntegrationProvider;
834
- declare function manifestToConnector(providerId: string, adapter: ConnectorAdapter): IntegrationConnector;
835
-
836
- interface IntegrationSecretStore {
837
- get(ref: SecretRef): Promise<ConnectorCredentials | undefined> | ConnectorCredentials | undefined;
838
- put(ref: SecretRef, credentials: ConnectorCredentials): Promise<void> | void;
839
- delete?(ref: SecretRef): Promise<void> | void;
840
- }
841
- interface ConnectionCredentialResolverOptions {
842
- secrets: IntegrationSecretStore;
843
- connections?: IntegrationConnectionStore;
844
- adapters?: ConnectorAdapter[];
845
- now?: () => Date;
846
- markConnectionError?: (connection: IntegrationConnection, error: Error) => Promise<void> | void;
847
- }
848
- declare class InMemoryIntegrationSecretStore implements IntegrationSecretStore {
849
- private readonly secrets;
850
- get(ref: SecretRef): ConnectorCredentials | undefined;
851
- put(ref: SecretRef, credentials: ConnectorCredentials): void;
852
- delete(ref: SecretRef): void;
853
- }
854
- declare function createConnectionCredentialResolver(options: ConnectionCredentialResolverOptions): (connection: IntegrationConnection) => Promise<ResolvedDataSource>;
855
- declare function resolveConnectionCredentials(input: IntegrationConnection, options: ConnectionCredentialResolverOptions): Promise<ConnectorCredentials>;
856
- declare function createCredentialBackedAdapterProvider(options: Omit<ConnectorAdapterProviderOptions, 'resolveDataSource'> & ConnectionCredentialResolverOptions): IntegrationProvider;
857
- declare function revokeConnection(input: {
858
- connection: IntegrationConnection;
859
- connections?: IntegrationConnectionStore;
860
- secrets?: IntegrationSecretStore;
861
- now?: () => Date;
862
- }): Promise<IntegrationConnection>;
863
-
864
- type IntegrationErrorCode = 'missing_connection' | 'missing_grant' | 'approval_required' | 'approval_denied' | 'connection_revoked' | 'connection_expired' | 'scope_missing' | 'action_denied' | 'action_not_found' | 'provider_rate_limited' | 'provider_auth_failed' | 'provider_unavailable' | 'provider_error' | 'capability_expired' | 'capability_invalid' | 'manifest_invalid' | 'passthrough_disabled' | 'input_invalid' | 'unknown';
865
- interface IntegrationUserAction {
866
- type: 'connect' | 'reconnect' | 'approve' | 'retry' | 'contact_support' | 'change_request';
867
- label: string;
868
- connectorId?: string;
869
- approvalId?: string;
870
- }
871
- declare class IntegrationRuntimeError extends Error {
872
- readonly code: IntegrationErrorCode;
873
- readonly status: number;
874
- readonly userAction?: IntegrationUserAction;
875
- readonly metadata?: Record<string, unknown>;
876
- constructor(input: {
877
- code: IntegrationErrorCode;
878
- message: string;
879
- status?: number;
880
- userAction?: IntegrationUserAction;
881
- metadata?: Record<string, unknown>;
882
- });
883
- }
884
- interface NormalizedIntegrationError {
885
- ok: false;
886
- code: IntegrationErrorCode;
887
- message: string;
888
- status: number;
889
- userAction?: IntegrationUserAction;
890
- metadata?: Record<string, unknown>;
891
- }
892
- declare function normalizeIntegrationError(error: unknown): NormalizedIntegrationError;
893
- declare function statusForCode(code: IntegrationErrorCode): number;
894
-
895
- interface IntegrationWorkflowDefinition {
896
- id: string;
897
- title?: string;
898
- manifest: IntegrationManifest;
899
- trigger: {
900
- requirementId: string;
901
- triggerId: string;
902
- targetUrl?: string;
903
- };
904
- metadata?: Record<string, unknown>;
905
- }
906
- interface InstalledIntegrationWorkflow {
907
- id: string;
908
- workflowId: string;
909
- manifestId: string;
910
- owner: IntegrationActor;
911
- grantee: IntegrationActor;
912
- triggerGrantId: string;
913
- subscription: IntegrationTriggerSubscription;
914
- status: 'active' | 'paused' | 'error';
915
- createdAt: string;
916
- metadata?: Record<string, unknown>;
917
- }
918
- interface IntegrationWorkflowStore {
919
- put(workflow: InstalledIntegrationWorkflow): Promise<void> | void;
920
- get(id: string): Promise<InstalledIntegrationWorkflow | undefined> | InstalledIntegrationWorkflow | undefined;
921
- list(): Promise<InstalledIntegrationWorkflow[]> | InstalledIntegrationWorkflow[];
922
- listByWorkflow(workflowId: string): Promise<InstalledIntegrationWorkflow[]> | InstalledIntegrationWorkflow[];
923
- listByOwner(owner: IntegrationActor): Promise<InstalledIntegrationWorkflow[]> | InstalledIntegrationWorkflow[];
924
- }
925
- interface IntegrationWorkflowRuntimeHub {
926
- subscribeTrigger(connectionId: string, trigger: string, targetUrl?: string): Promise<IntegrationTriggerSubscription> | IntegrationTriggerSubscription;
927
- }
928
- interface IntegrationWorkflowRuntimeOptions {
929
- runtime: IntegrationRuntime;
930
- hub: IntegrationWorkflowRuntimeHub;
931
- grants: IntegrationGrantStore;
932
- store?: IntegrationWorkflowStore;
933
- now?: () => Date;
934
- }
935
- declare class InMemoryIntegrationWorkflowStore implements IntegrationWorkflowStore {
936
- private readonly workflows;
937
- put(workflow: InstalledIntegrationWorkflow): void;
938
- get(id: string): InstalledIntegrationWorkflow | undefined;
939
- list(): InstalledIntegrationWorkflow[];
940
- listByWorkflow(workflowId: string): InstalledIntegrationWorkflow[];
941
- listByOwner(owner: IntegrationActor): InstalledIntegrationWorkflow[];
942
- }
943
- declare class IntegrationWorkflowRuntime {
944
- private readonly runtime;
945
- private readonly hub;
946
- private readonly grants;
947
- private readonly store;
948
- private readonly now;
949
- constructor(options: IntegrationWorkflowRuntimeOptions);
950
- install(input: {
951
- workflow: IntegrationWorkflowDefinition;
952
- owner: IntegrationActor;
953
- grantee: IntegrationActor;
954
- }): Promise<InstalledIntegrationWorkflow>;
955
- dispatchEvent<T = unknown>(event: IntegrationTriggerEvent<T>, handler: (input: {
956
- event: IntegrationTriggerEvent<T>;
957
- workflows: InstalledIntegrationWorkflow[];
958
- }) => Promise<void> | void): Promise<{
959
- matched: InstalledIntegrationWorkflow[];
960
- }>;
961
- }
962
- declare function createIntegrationWorkflowRuntime(options: IntegrationWorkflowRuntimeOptions): IntegrationWorkflowRuntime;
963
-
964
- interface StoredIntegrationEvent {
965
- id: string;
966
- sourceId: string;
967
- connectorId: string;
968
- eventType: string;
969
- providerEventId?: string;
970
- receivedAt: string;
971
- payload: Record<string, unknown>;
972
- dispatchedAt?: string;
973
- metadata?: Record<string, unknown>;
974
- }
975
- interface IntegrationEventStore {
976
- put(event: StoredIntegrationEvent): Promise<void> | void;
977
- hasProviderEvent(sourceId: string, providerEventId: string): Promise<boolean> | boolean;
978
- list(): Promise<StoredIntegrationEvent[]> | StoredIntegrationEvent[];
979
- }
980
- interface IntegrationWebhookReceiverResult {
981
- status: number;
982
- body: unknown;
983
- headers?: Record<string, string>;
984
- received: StoredIntegrationEvent[];
985
- duplicates: StoredIntegrationEvent[];
986
- }
987
- declare class InMemoryIntegrationEventStore implements IntegrationEventStore {
988
- private readonly events;
989
- private readonly providerIds;
990
- put(event: StoredIntegrationEvent): void;
991
- hasProviderEvent(sourceId: string, providerEventId: string): boolean;
992
- list(): StoredIntegrationEvent[];
993
- }
994
- declare function receiveIntegrationWebhook(input: {
995
- adapter: ConnectorAdapter;
996
- source: ResolvedDataSource;
997
- rawBody: string;
998
- headers: Record<string, string | string[] | undefined>;
999
- store: IntegrationEventStore;
1000
- workflowRuntime?: IntegrationWorkflowRuntime;
1001
- now?: () => Date;
1002
- }): Promise<IntegrationWebhookReceiverResult>;
1003
- declare function storedEventToTriggerEvent(event: StoredIntegrationEvent, source: ResolvedDataSource): IntegrationTriggerEvent;
1004
-
1005
- interface IntegrationIdempotencyRecord {
1006
- key: string;
1007
- requestHash: string;
1008
- result: IntegrationActionResult;
1009
- createdAt: string;
1010
- }
1011
- interface IntegrationIdempotencyStore {
1012
- get(key: string): Promise<IntegrationIdempotencyRecord | undefined> | IntegrationIdempotencyRecord | undefined;
1013
- put(record: IntegrationIdempotencyRecord): Promise<void> | void;
1014
- }
1015
- interface IntegrationRateLimitDecision {
1016
- allowed: boolean;
1017
- retryAfterMs?: number;
1018
- reason?: string;
1019
- }
1020
- interface IntegrationRateLimiter {
1021
- check(ctx: IntegrationGuardContext): Promise<IntegrationRateLimitDecision> | IntegrationRateLimitDecision;
1022
- }
1023
- declare class InMemoryIntegrationIdempotencyStore implements IntegrationIdempotencyStore {
1024
- private readonly records;
1025
- get(key: string): IntegrationIdempotencyRecord | undefined;
1026
- put(record: IntegrationIdempotencyRecord): void;
1027
- }
1028
- declare class DefaultIntegrationActionGuard implements IntegrationActionGuard {
1029
- private readonly idempotency;
1030
- private readonly audit;
1031
- private readonly rateLimiter;
1032
- private readonly now;
1033
- constructor(options?: {
1034
- idempotency?: IntegrationIdempotencyStore;
1035
- audit?: IntegrationAuditSink;
1036
- rateLimiter?: IntegrationRateLimiter;
1037
- now?: () => Date;
1038
- });
1039
- invokeAction(ctx: IntegrationGuardContext, proceed: () => Promise<IntegrationActionResult>): Promise<IntegrationActionResult>;
1040
- private writeIdempotency;
1041
- }
1042
- declare function createDefaultIntegrationActionGuard(options?: ConstructorParameters<typeof DefaultIntegrationActionGuard>[0]): DefaultIntegrationActionGuard;
1043
-
1044
- type IntegrationHealthcheckStatus = 'healthy' | 'degraded' | 'unhealthy' | 'unknown';
1045
- interface IntegrationHealthcheckCheck {
1046
- id: string;
1047
- status: IntegrationHealthcheckStatus;
1048
- message: string;
1049
- metadata?: Record<string, unknown>;
1050
- }
1051
- interface IntegrationHealthcheckResult {
1052
- connectionId: string;
1053
- providerId: string;
1054
- connectorId: string;
1055
- status: IntegrationHealthcheckStatus;
1056
- checkedAt: string;
1057
- checks: IntegrationHealthcheckCheck[];
1058
- metadata?: Record<string, unknown>;
1059
- }
1060
- interface IntegrationHealthcheckStore {
1061
- put(result: IntegrationHealthcheckResult): Promise<void> | void;
1062
- get(connectionId: string): Promise<IntegrationHealthcheckResult | undefined> | IntegrationHealthcheckResult | undefined;
1063
- list(): Promise<IntegrationHealthcheckResult[]> | IntegrationHealthcheckResult[];
1064
- }
1065
- declare class InMemoryIntegrationHealthcheckStore implements IntegrationHealthcheckStore {
1066
- private readonly results;
1067
- put(result: IntegrationHealthcheckResult): void;
1068
- get(connectionId: string): IntegrationHealthcheckResult | undefined;
1069
- list(): IntegrationHealthcheckResult[];
1070
- }
1071
- declare function runIntegrationHealthcheck(input: {
1072
- connection: IntegrationConnection;
1073
- connector?: IntegrationConnector;
1074
- registry?: IntegrationRegistry;
1075
- test?: (connection: IntegrationConnection, connector: IntegrationConnector) => Promise<IntegrationActionResult | boolean> | IntegrationActionResult | boolean;
1076
- audit?: IntegrationAuditSink;
1077
- now?: () => Date;
1078
- }): Promise<IntegrationHealthcheckResult>;
1079
- declare function runIntegrationHealthchecks(input: {
1080
- connections: IntegrationConnection[];
1081
- registry?: IntegrationRegistry;
1082
- store?: IntegrationHealthcheckStore;
1083
- audit?: IntegrationAuditSink;
1084
- now?: () => Date;
1085
- test?: (connection: IntegrationConnection, connector: IntegrationConnector) => Promise<IntegrationActionResult | boolean> | IntegrationActionResult | boolean;
1086
- }): Promise<IntegrationHealthcheckResult[]>;
1087
- declare function healthcheckRequest(action?: string): IntegrationActionRequest;
1088
-
1089
- interface ManifestValidationIssue {
1090
- path: string;
1091
- message: string;
1092
- }
1093
- interface ManifestValidationResult {
1094
- ok: boolean;
1095
- issues: ManifestValidationIssue[];
1096
- }
1097
- interface InferIntegrationRequirementsOptions {
1098
- manifestId: string;
1099
- title?: string;
1100
- tools: Array<string | {
1101
- action: string;
1102
- reason?: string;
1103
- mode?: IntegrationRequirementMode;
1104
- connectorId?: string;
1105
- scopes?: string[];
1106
- }>;
1107
- metadata?: Record<string, unknown>;
1108
- }
1109
- interface MissingRequirementExplanation {
1110
- requirementId: string;
1111
- connectorId: string;
1112
- status: string;
1113
- message: string;
1114
- userAction: 'connect' | 'enable' | 'ignore_optional';
1115
- }
1116
- declare function validateIntegrationManifest(manifest: IntegrationManifest): ManifestValidationResult;
1117
- declare function assertValidIntegrationManifest(manifest: IntegrationManifest): void;
1118
- declare function inferIntegrationManifestFromTools(options: InferIntegrationRequirementsOptions): IntegrationManifest;
1119
- declare function explainMissingRequirements(resolution: IntegrationManifestResolution): MissingRequirementExplanation[];
1120
- declare function calendarExercisePlannerManifest(id?: string): IntegrationManifest;
1121
-
1122
- interface ProviderHttpRequestInput {
1123
- method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
1124
- path: string;
1125
- query?: Record<string, string | number | boolean | undefined>;
1126
- headers?: Record<string, string>;
1127
- body?: unknown;
1128
- }
1129
- interface ProviderPassthroughPolicy {
1130
- enabled: boolean;
1131
- allowedMethods?: ProviderHttpRequestInput['method'][];
1132
- allowedPathPrefixes?: string[];
1133
- maxBodyBytes?: number;
1134
- }
1135
- declare const PROVIDER_PASSTHROUGH_ACTION: "provider.http.request";
1136
- declare function validateProviderPassthroughRequest(input: ProviderHttpRequestInput, policy: ProviderPassthroughPolicy): void;
1137
-
1138
- type IntegrationPolicyEffect = 'allow' | 'require_approval' | 'deny';
1139
- interface IntegrationPolicyRule {
1140
- id: string;
1141
- effect: IntegrationPolicyEffect;
1142
- reason: string;
1143
- providerId?: string;
1144
- connectorId?: string;
1145
- action?: string;
1146
- maxRisk?: IntegrationActionRisk;
1147
- risk?: IntegrationActionRisk;
1148
- dataClass?: IntegrationDataClass;
1149
- }
1150
- interface StaticIntegrationPolicyOptions {
1151
- rules?: IntegrationPolicyRule[];
1152
- defaultReadEffect?: IntegrationPolicyEffect;
1153
- defaultWriteEffect?: IntegrationPolicyEffect;
1154
- defaultDestructiveEffect?: IntegrationPolicyEffect;
1155
- now?: () => Date;
1156
- }
1157
- interface IntegrationApprovalResolution {
1158
- approvalId: string;
1159
- approved: boolean;
1160
- resolvedBy: string;
1161
- resolvedAt: string;
1162
- reason?: string;
1163
- metadata?: Record<string, unknown>;
1164
- }
1165
- declare class StaticIntegrationPolicyEngine implements IntegrationPolicyEngine {
1166
- private readonly rules;
1167
- private readonly defaultReadEffect;
1168
- private readonly defaultWriteEffect;
1169
- private readonly defaultDestructiveEffect;
1170
- private readonly now;
1171
- constructor(options?: StaticIntegrationPolicyOptions);
1172
- decide(ctx: IntegrationGuardContext & {
1173
- subject: {
1174
- type: string;
1175
- id: string;
1176
- };
1177
- }): IntegrationPolicyDecision;
1178
- private defaultEffect;
1179
- }
1180
- declare function createDefaultIntegrationPolicyEngine(options?: Omit<StaticIntegrationPolicyOptions, 'rules'>): StaticIntegrationPolicyEngine;
1181
- declare function buildApprovalRequest(ctx: IntegrationGuardContext & {
1182
- subject: {
1183
- type: string;
1184
- id: string;
1185
- };
1186
- }, reason: string, requestedAt: Date): IntegrationApprovalRequest;
1187
- declare function redactApprovalRequest(request: IntegrationApprovalRequest): IntegrationApprovalRequest;
1188
-
1189
- interface PlatformIntegrationPolicyPresetOptions extends Omit<StaticIntegrationPolicyOptions, 'defaultReadEffect' | 'defaultWriteEffect' | 'defaultDestructiveEffect'> {
1190
- allowWritesWithoutApproval?: boolean;
1191
- allowDestructiveActions?: boolean;
1192
- allowProviderPassthrough?: boolean;
1193
- }
1194
- declare function createPlatformIntegrationPolicyPreset(options?: PlatformIntegrationPolicyPresetOptions): StaticIntegrationPolicyEngine;
1195
-
1196
- /**
1197
- * Generic OAuth2 helper used by every oauth-shaped connector (Google
1198
- * Calendar, Sheets, Drive, HubSpot, Salesforce, Zoom, ...).
1199
- *
1200
- * Everything PKCE-aware. Opaque-state CSRF guard. Refresh-token aware.
1201
- * No connector-specific logic lives here — adapters hand a `clientId`,
1202
- * `clientSecret`, `tokenUrl`, optional `extraAuthParams` and the rest is
1203
- * mechanical.
1204
- *
1205
- * State and code_verifier are kept in a short-TTL flow store keyed by the
1206
- * opaque `state` we round-trip through the provider. The default store is
1207
- * in-memory for local/dev and tests. Production deployments should inject a
1208
- * durable store backed by KV/Redis/D1/etc. so callbacks can land on any worker.
1209
- */
1210
- interface PendingOAuthFlow {
1211
- /** code_verifier for PKCE. */
1212
- codeVerifier: string;
1213
- /** Opaque-state value also returned in the OAuth redirect. */
1214
- state: string;
1215
- /** Project the user is connecting under. */
1216
- projectId: string;
1217
- /** Connector kind (e.g. 'google-calendar'). */
1218
- kind: string;
1219
- /** Operator-supplied label that becomes DataSource.label. */
1220
- label: string;
1221
- /** When we drop the entry. */
1222
- expiresAt: number;
1223
- /** The redirectUri we used in the start step — must match exactly on
1224
- * the callback exchange. */
1225
- redirectUri: string;
1226
- }
1227
- interface OAuthFlowStore {
1228
- put(state: string, flow: PendingOAuthFlow): Promise<void> | void;
1229
- consume(state: string): Promise<PendingOAuthFlow | undefined> | PendingOAuthFlow | undefined;
1230
- sweep?(now: number): Promise<void> | void;
1231
- clear?(): Promise<void> | void;
1232
- }
1233
- declare class InMemoryOAuthFlowStore implements OAuthFlowStore {
1234
- private readonly pendingFlows;
1235
- put(state: string, flow: PendingOAuthFlow): void;
1236
- consume(state: string): PendingOAuthFlow | undefined;
1237
- sweep(now: number): void;
1238
- clear(): void;
1239
- }
1240
- interface StartOAuthInput {
1241
- projectId: string;
1242
- kind: string;
1243
- label: string;
1244
- authorizationUrl: string;
1245
- scopes: string[];
1246
- clientId: string;
1247
- redirectUri: string;
1248
- /** Optional extra query params; Google needs `access_type=offline` and
1249
- * `prompt=consent` to issue refresh tokens reliably. */
1250
- extraAuthParams?: Record<string, string>;
1251
- /** Optional flow store. Use a durable store in distributed production
1252
- * runtimes; omitted means local in-memory storage. */
1253
- store?: OAuthFlowStore;
1254
- /** Override clock for tests. */
1255
- now?: number;
1256
- }
1257
- interface StartOAuthOutput {
1258
- /** URL the SPA should redirect the user to. */
1259
- authorizationUrl: string;
1260
- /** State token — caller stashes this in localStorage to verify on
1261
- * callback. */
1262
- state: string;
1263
- }
1264
- /** Build the authorization URL + state. SPA navigates the user there;
1265
- * user consents; provider redirects back to redirectUri with `code` +
1266
- * `state`. The caller's callback then invokes `consumePendingFlow`. */
1267
- declare function startOAuthFlow(input: StartOAuthInput): StartOAuthOutput;
1268
- /** Look up + remove the pending flow record. Throws if state is unknown
1269
- * or expired (CSRF guard / replay protection). */
1270
- declare function consumePendingFlow(state: string, store?: OAuthFlowStore): Promise<PendingOAuthFlow>;
1271
- interface ExchangeCodeInput {
1272
- tokenUrl: string;
1273
- clientId: string;
1274
- clientSecret: string;
1275
- code: string;
1276
- codeVerifier: string;
1277
- redirectUri: string;
1278
- }
1279
- interface OAuthTokens {
1280
- accessToken: string;
1281
- refreshToken?: string;
1282
- expiresIn?: number;
1283
- scope?: string;
1284
- tokenType?: string;
1285
- }
1286
- /** POST authorization code → token endpoint. Provider-agnostic; if a
1287
- * provider returns a non-standard JSON shape, the adapter wraps this
1288
- * call rather than reaching into the helper. */
1289
- declare function exchangeAuthorizationCode(input: ExchangeCodeInput): Promise<OAuthTokens>;
1290
- interface RefreshInput {
1291
- tokenUrl: string;
1292
- clientId: string;
1293
- clientSecret: string;
1294
- refreshToken: string;
1295
- }
1296
- /** Refresh an access token. Returns the new tokens — the connector layer
1297
- * is responsible for re-encrypting + persisting the envelope. */
1298
- declare function refreshAccessToken(input: RefreshInput): Promise<OAuthTokens>;
1299
- /** Test-only — drop pending flows between unit-test runs. */
1300
- declare function _resetPendingFlowsForTests(): void;
1301
-
1302
- /**
1303
- * Inbound webhook signature verifiers — provider-specific HMAC schemes.
1304
- *
1305
- * Each signature scheme is a pure function:
1306
- * (rawBody: string, headers, secret, now?) → boolean
1307
- *
1308
- * Constant-time comparison via `crypto.timingSafeEqual`. Timestamps are
1309
- * checked against a configurable tolerance to bound replay risk; the default
1310
- * mirrors the upstream provider's documented window (Stripe: 5 min, Slack: 5 min).
1311
- *
1312
- * These verifiers are the building blocks for any inbound-webhook receiver
1313
- * (a route + a `verify` call + a per-event handler). They live in this
1314
- * package so every consumer of the integration substrate gets correct
1315
- * verification — not just one product reimplementing it.
1316
- */
1317
- /** Default replay-protection window. Providers commonly use 5 minutes. */
1318
- declare const DEFAULT_SIGNATURE_TOLERANCE_SECONDS: number;
1319
- interface ParsedStripeSignatureHeader {
1320
- t: number;
1321
- sigs: string[];
1322
- }
1323
- declare function parseStripeSignatureHeader(header: string): ParsedStripeSignatureHeader | null;
1324
- interface StripeVerifyOptions {
1325
- /** Replay-protection window in seconds. Default 300. */
1326
- toleranceSeconds?: number;
1327
- /** Override `now()` for tests. UTC seconds. */
1328
- now?: number;
1329
- }
1330
- /** Verify a Stripe webhook signature against the raw request body. */
1331
- declare function verifyStripeSignature(rawBody: string, signatureHeader: string, secret: string, options?: StripeVerifyOptions): boolean;
1332
- interface SlackVerifyOptions {
1333
- toleranceSeconds?: number;
1334
- now?: number;
1335
- }
1336
- declare function verifySlackSignature(rawBody: string, signatureHeader: string, timestampHeader: string, secret: string, options?: SlackVerifyOptions): boolean;
1337
- interface GenericHmacVerifyOptions {
1338
- /** sha256 (default) | sha1 | sha512 — matches the algorithm the receiver
1339
- * computed at sign time. */
1340
- algorithm?: 'sha256' | 'sha1' | 'sha512';
1341
- /** Optional prefix the receiver prepends to the signature in the header
1342
- * (e.g., `'sha256='`). Stripped before constant-time comparison. */
1343
- signaturePrefix?: string;
1344
- /** Lowercase comparison (most providers emit hex-lowercase). Default true. */
1345
- lowercaseHex?: boolean;
1346
- }
1347
- declare function verifyHmacSignature(rawBody: string, signatureHeader: string, secret: string, options?: GenericHmacVerifyOptions): boolean;
1348
- interface TwilioVerifyOptions {
1349
- /** Skip verification when the auth token isn't configured. Useful in
1350
- * dev where the receiver wants to accept any payload. Default `false`
1351
- * — production should always require a configured token. */
1352
- skipWhenAuthTokenMissing?: boolean;
1353
- /** When true, sign the raw body instead of the URL-encoded sorted-params
1354
- * reduction. Twilio uses raw-body signing for `application/json`
1355
- * webhook bodies. Default `false`. */
1356
- bodyAsRaw?: boolean;
1357
- /** When `bodyAsRaw` is true, the raw body to sign. Ignored otherwise. */
1358
- rawBody?: string;
1359
- }
1360
- /** Verify a Twilio webhook signature. */
1361
- declare function verifyTwilioSignature(input: {
1362
- authToken: string | null | undefined;
1363
- signatureHeader: string | string[] | undefined;
1364
- fullUrl: string | null | undefined;
1365
- params: Record<string, string> | undefined;
1366
- }, options?: TwilioVerifyOptions): boolean;
1367
- declare function firstHeader(headers: Record<string, string | string[] | undefined>, name: string): string | undefined;
1368
-
1369
- /**
1370
- * Google Calendar connector — CAS reference implementation.
1371
- *
1372
- * Scopes: `https://www.googleapis.com/auth/calendar` covers list/insert/
1373
- * patch on the user's calendars. We could split read/write but for v1 the
1374
- * single scope keeps the consent screen simple; an operator who wants
1375
- * read-only-Calendar can pick a different `kind` later (`google-calendar-readonly`).
1376
- *
1377
- * The two capabilities the agent actually needs:
1378
- *
1379
- * list_availability(calendarId, timeMin, timeMax)
1380
- * → {busy: [{start, end}], events: [{id, etag, start, end, summary}]}
1381
- * Read; no CAS. Cheap (events.list).
1382
- *
1383
- * book_slot(calendarId, start, end, summary, attendees?)
1384
- * → {eventId, etag}
1385
- * Mutation. CAS by Calendar's own conflict-detection: we re-list
1386
- * events for the requested window inside the same call, and if any
1387
- * OVERLAP exists we return `conflict` with the next-3 free slots
1388
- * mined from the user's freebusy, instead of inserting.
1389
- *
1390
- * Why pre-flight read-then-insert rather than relying on If-Match:
1391
- * `events.insert` doesn't take If-Match (you can't precondition an
1392
- * insert against a non-existent resource). Calendar's own
1393
- * `freebusy.query` is the canonical conflict signal. The whole flow is:
1394
- *
1395
- * 1. freebusy.query for [start, end] on this calendarId
1396
- * 2. if busy → emit ResourceContention with next-3 free slots
1397
- * (computed by walking forward in 30-min steps until 3 free
1398
- * windows of (end-start) duration found)
1399
- * 3. else events.insert with idempotency-key as `requestId` (a Calendar
1400
- * API feature that gives us per-key dedup at upstream)
1401
- *
1402
- * Step 3's `requestId` parameter means a retry of the same idempotency
1403
- * key on the same calendar will return the original event rather than
1404
- * creating a duplicate, which composes correctly with our MutationGuard's
1405
- * idempotency record (which short-circuits before ever hitting upstream
1406
- * on the second call). Defense-in-depth.
1407
- */
1408
-
1409
- /** OAuth client config the factory closes over. Caller resolves these
1410
- * at construction time (env, DB, secret manager — package doesn't care). */
1411
- interface GoogleCalendarOptions {
1412
- clientId: string;
1413
- clientSecret: string;
1414
- }
1415
- declare function googleCalendar(opts: GoogleCalendarOptions): ConnectorAdapter;
1416
-
1417
- /**
1418
- * Google Sheets connector — live KB source + writable rows.
1419
- *
1420
- * The flagship for the "agent reads from a live spreadsheet" UX. The
1421
- * customer points the connection at a Sheet (spreadsheetId + sheetName +
1422
- * headerRow). We expose:
1423
- *
1424
- * list_rows(filter?, limit?)
1425
- * → {rows: [{...header→cell}], nextCursor?}
1426
- * Cheap; just spreadsheets.values.get with the configured range.
1427
- *
1428
- * query_rows(predicate)
1429
- * → same shape as list_rows but with a structured filter (k=v pairs
1430
- * ANDed together). Simple and explainable; no SQL.
1431
- *
1432
- * update_row(rowKey, patch)
1433
- * → {row: {...header→cell}, updatedRange}
1434
- * Mutation. CAS via Sheets' spreadsheets.values.update + a
1435
- * pre-flight read of the row's revisionId-equivalent hash. Sheets
1436
- * doesn't expose a per-row etag, so we synthesize one — see
1437
- * `rowFingerprint`. If the fingerprint doesn't match what the agent
1438
- * last read, we surface ResourceContention with the current row in
1439
- * `currentState`.
1440
- *
1441
- * KB binding: when a Sheet is `consistencyModel: 'cache'` (the default
1442
- * for spreadsheets — they're slow-moving), the system also indexes the
1443
- * rows as KB chunks. The KB build pipeline calls `list_rows` and emits
1444
- * one markdown page per row; on a connector-level "refresh" event the
1445
- * agent's KB rebuilds.
1446
- */
1447
-
1448
- /** OAuth client config the factory closes over. Caller resolves these
1449
- * at construction time (env, DB, secret manager — package doesn't care). */
1450
- interface GoogleSheetsOptions {
1451
- clientId: string;
1452
- clientSecret: string;
1453
- }
1454
- declare function googleSheets(opts: GoogleSheetsOptions): ConnectorAdapter;
1455
-
1456
- /**
1457
- * Microsoft Graph Calendar connector — the Outlook half of the
1458
- * voice-agent's "book me a slot" surface.
1459
- *
1460
- * Mirrors the Google Calendar pattern almost line-for-line, with two
1461
- * upstream-specific quirks worth calling out:
1462
- *
1463
- * 1. Graph exposes `@odata.etag` on every event resource AND honors
1464
- * `If-Match` on `events.patch` / `events.delete`. So unlike Calendar
1465
- * (insert can't be preconditioned against a non-existent resource),
1466
- * we DO get real etag CAS for updates after the booking. We still
1467
- * use the freebusy pre-flight for the create path, because the
1468
- * "two callers grab the same slot" race happens before any event
1469
- * exists.
1470
- *
1471
- * 2. `getSchedule` is the Graph equivalent of `freeBusy.query`. Same
1472
- * shape: send `[start, end]` plus the calendar's email/UPN, get
1473
- * back a `scheduleItems` list of busy windows.
1474
- *
1475
- * Why the same flow ports cleanly: the conflict mode is identical
1476
- * ("did someone else grab this slot between read and write?"). The
1477
- * mechanism — pre-flight read + idempotent insert — composes regardless
1478
- * of whether upstream gives us a request-id dedup feature. Graph does
1479
- * not have a `requestId` analogue on `events.create`, so we rely
1480
- * exclusively on MutationGuard's idempotency-key short-circuit ABOVE
1481
- * the connector. That layer prevents duplicate inserts on retry.
1482
- */
1483
-
1484
- /** OAuth client config the factory closes over. Caller resolves these
1485
- * at construction time (env, DB, secret manager — package doesn't care). */
1486
- interface MicrosoftCalendarOptions {
1487
- clientId: string;
1488
- clientSecret: string;
1489
- }
1490
- declare function microsoftCalendar(opts: MicrosoftCalendarOptions): ConnectorAdapter;
1491
-
1492
- /**
1493
- * HubSpot CRM connector — three load-bearing capabilities, picked to
1494
- * cover the voice-agent's CRM hot path without trying to swallow all of
1495
- * HubSpot's surface in v1.
1496
- *
1497
- * find_contact(email)
1498
- * → {contact: {id, properties}} | {found: false}
1499
- * POST /crm/v3/objects/contacts/search with an email-equality filter.
1500
- * Cheap, idempotent, no CAS needed (read).
1501
- *
1502
- * upsert_contact(email, properties)
1503
- * → {contactId, created}
1504
- * Mutation. CAS strategy = native-idempotency, BUT: HubSpot's
1505
- * `idempotencyKey` query param is ONLY available on the v3 *batch*
1506
- * endpoints (`/crm/v3/objects/contacts/batch/upsert`). The
1507
- * single-record endpoints don't honor it. We use the batch endpoint
1508
- * with a single-element array to get native idempotency on retry.
1509
- *
1510
- * create_note(contactId, body)
1511
- * → {noteId}
1512
- * Mutation that logs a note engagement on a contact and associates
1513
- * it. Notes are append-only — there's no conflict to detect — so we
1514
- * use native-idempotency via the same batch trick on
1515
- * `/crm/v3/objects/notes/batch/create`.
1516
- *
1517
- * Why three and not thirty: the agent's leverage on HubSpot is
1518
- * "remember who I just spoke to". `find_contact` lets the agent address
1519
- * a returning caller by name; `upsert_contact` captures a new one
1520
- * without duplicates; `create_note` writes the call's outcome as a CRM
1521
- * activity. Anything beyond these (deals, tickets, lists) lives in
1522
- * Tier-2 specific kinds — keeping the manifest tight keeps the agent's
1523
- * tool registry comprehensible.
1524
- */
1525
-
1526
- /** OAuth client config the factory closes over. Caller resolves these
1527
- * at construction time (env, DB, secret manager — package doesn't care). */
1528
- interface HubSpotOptions {
1529
- clientId: string;
1530
- clientSecret: string;
1531
- }
1532
- declare function hubspot(opts: HubSpotOptions): ConnectorAdapter;
1533
-
1534
- /**
1535
- * Slack connector — bot-token OAuth, three messaging-oriented capabilities.
1536
- *
1537
- * post_message(channel, text|blocks) → mutation; cas: 'none'
1538
- * lookup_user(email) → read
1539
- * list_channels(types?, limit?) → read
1540
- *
1541
- * Why `cas: 'none'` is acceptable here (and only here in this batch):
1542
- * Slack messages are advisory — we set
1543
- * `defaultConsistencyModel: 'advisory'`. The registry validator allows
1544
- * `cas: 'none'` only on non-authoritative connectors precisely so that
1545
- * append-only messaging surfaces don't have to invent fake CAS theatre.
1546
- * The agent's planner already treats `advisory` data as informational
1547
- * and does not promise outcomes based on its post results without
1548
- * a separate authoritative confirm. MutationGuard's idempotency-key
1549
- * dedup remains in force above the connector — a retry of the same
1550
- * post_message call will short-circuit before reaching Slack.
1551
- *
1552
- * Auth: standard OAuth2. Slack's `/oauth.v2.access` returns a bot
1553
- * `access_token` (`xoxb-…`) but does NOT return a refresh_token unless
1554
- * the app has rotated tokens enabled. Bot tokens are long-lived by
1555
- * default; we surface refreshToken handling but treat its absence as
1556
- * normal rather than an error.
1557
- */
1558
-
1559
- /** OAuth client config the factory closes over. Caller resolves these
1560
- * at construction time (env, DB, secret manager — package doesn't care). */
1561
- interface SlackOptions {
1562
- clientId: string;
1563
- clientSecret: string;
1564
- }
1565
- declare function slack(opts: SlackOptions): ConnectorAdapter;
1566
-
1567
- /**
1568
- * Notion database connector — query + page-level CRUD against a single
1569
- * connected database.
1570
- *
1571
- * query_database(filter?, pageSize?) → read
1572
- * create_page(properties) → mutation; cas: 'native-idempotency'
1573
- * update_page(pageId, properties) → mutation; cas: 'etag-if-match'
1574
- *
1575
- * CAS quirks worth flagging:
1576
- *
1577
- * 1. Notion added support for the `Idempotency-Key` HTTP header on
1578
- * mutating requests. We forward our SDK's idempotency key on
1579
- * create_page, which gives at-most-once semantics under the same
1580
- * key for ~24h. MutationGuard's record short-circuits above us;
1581
- * Notion's dedup is the second line of defense.
1582
- *
1583
- * 2. Notion does NOT expose a per-page etag the way Graph does. The
1584
- * canonical drift signal is `last_edited_time` (RFC3339). Our
1585
- * `update_page` capability accepts an `expectedLastEditedTime` arg;
1586
- * if supplied, we GET the page first and compare. Mismatch →
1587
- * ResourceContention with the current page state. Conflict-free
1588
- * callers can omit the field (last-write-wins, the Notion default).
1589
- *
1590
- * Auth: standard OAuth2. Notion's token endpoint follows RFC 6749 with
1591
- * one twist — the workspace_id and bot_id come back in the response and
1592
- * we stash them in `metadata` so the agent can address resources by
1593
- * workspace where useful.
1594
- */
1595
-
1596
- /** OAuth client config the factory closes over. Caller resolves these
1597
- * at construction time (env, DB, secret manager — package doesn't care). */
1598
- interface NotionDatabaseOptions {
1599
- clientId: string;
1600
- clientSecret: string;
1601
- }
1602
- declare function notionDatabase(opts: NotionDatabaseOptions): ConnectorAdapter;
1603
-
1604
- type RestCredentialPlacement = {
1605
- kind: 'bearer';
1606
- } | {
1607
- kind: 'header';
1608
- header: string;
1609
- prefix?: string;
1610
- } | {
1611
- kind: 'query';
1612
- parameter: string;
1613
- };
1614
- interface RestConnectorSpec {
1615
- kind: string;
1616
- displayName: string;
1617
- description: string;
1618
- auth: ConnectorAdapter['manifest']['auth'];
1619
- category: ConnectorAdapter['manifest']['category'];
1620
- defaultConsistencyModel: ConnectorAdapter['manifest']['defaultConsistencyModel'];
1621
- baseUrl: string | {
1622
- metadataKey: string;
1623
- fallback?: string;
1624
- };
1625
- credentialPlacement?: RestCredentialPlacement;
1626
- defaultHeaders?: Record<string, string>;
1627
- capabilities: RestOperationSpec[];
1628
- test?: RestRequestSpec;
1629
- }
1630
- interface RestOperationSpec {
1631
- name: string;
1632
- class: 'read' | 'mutation';
1633
- description: string;
1634
- parameters: Record<string, unknown>;
1635
- requiredScopes?: string[];
1636
- request: RestRequestSpec;
1637
- cas?: 'etag-if-match' | 'native-idempotency' | 'optimistic-read-verify' | 'none';
1638
- externalEffect?: boolean;
1639
- }
1640
- interface RestRequestSpec {
1641
- method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
1642
- path: string;
1643
- query?: Record<string, string | number | boolean | undefined>;
1644
- headers?: Record<string, string>;
1645
- body?: 'args' | string | Record<string, unknown>;
1646
- }
1647
- declare function declarativeRestConnector(spec: RestConnectorSpec): ConnectorAdapter;
1648
-
1649
- /**
1650
- * Twilio SMS connector — outbound texts + recent-message lookup. The
1651
- * agent's "send the caller a confirmation link" surface.
1652
- *
1653
- * Auth: HTTP Basic (Account SID + Auth Token). Twilio's API key auth
1654
- * also supports SID/Secret pairs; we accept either by treating the
1655
- * stored apiKey envelope as `accountSid:authToken` (or
1656
- * `accountSid:keySid:secret`) — the connector parses it at call time.
1657
- *
1658
- * send_sms(to, body)
1659
- * Mutation. CAS = native-idempotency. Twilio added the
1660
- * `Idempotency-Key` HTTP header to POST /Messages in 2024 — same
1661
- * key + same args within 24h returns the original Message resource
1662
- * instead of sending a second SMS. MutationGuard's record short-
1663
- * circuits before us; Twilio's own dedup is defense-in-depth.
1664
- *
1665
- * lookup_number(phoneNumber)
1666
- * Read. Hits /v1/PhoneNumbers/{e164} on Lookup API. Confirms the
1667
- * number is real, returns carrier info if the caller has Lookup
1668
- * enabled on their account.
1669
- *
1670
- * find_recent_messages(toOrFrom?, limit?)
1671
- * Read. Returns the most recent Messages on the account, optionally
1672
- * filtered by To/From. Useful for "did the confirmation actually
1673
- * send?" introspection inside an agent run.
1674
- */
1675
-
1676
- declare const twilioSmsConnector: ConnectorAdapter;
1677
-
1678
- /**
1679
- * Stripe pack connector — single connector kind packing 3 capabilities,
1680
- * validating the "connector pack" concept (one auth handshake, multiple
1681
- * related capabilities) without exploding the registry into
1682
- * `stripe-customers`, `stripe-checkout`, `stripe-invoices` triplets.
1683
- *
1684
- * find_customer(email) → read; CAS n/a
1685
- * create_invoice(customerId, items) → mutation; cas: 'native-idempotency'
1686
- * create_checkout_session(...) → mutation; cas: 'native-idempotency'
1687
- *
1688
- * Auth: API key (Stripe restricted key). Operator pastes the key into
1689
- * the Connections UI. We never see their account password / OAuth flow;
1690
- * Stripe restricted keys are the customer's responsibility (they pick
1691
- * which permissions the key carries). The kind exposes a webhook URL
1692
- * post-connect for the operator to paste into the Stripe dashboard —
1693
- * we'll wire the receiver to P-3's inbound webhook surface in a later
1694
- * commit. That URL is returned in `metadata.webhookUrl` so the UI can
1695
- * render it.
1696
- *
1697
- * Why this is the textbook example of `cas: 'native-idempotency'`:
1698
- * Stripe's `Idempotency-Key` HTTP header is THE reference implementation
1699
- * of native idempotency. Same key + same args within 24h returns the
1700
- * stored response (Stripe's words, not ours). Same key + different args
1701
- * → 400 with `idempotency_error`. We forward the SDK's idempotency key
1702
- * directly. MutationGuard short-circuits before us on retry; Stripe's
1703
- * own dedup is the second line of defense.
1704
- */
1705
-
1706
- declare const stripePackConnector: ConnectorAdapter;
1707
-
1708
- /**
1709
- * Universal webhook connector — the long-tail escape hatch.
1710
- *
1711
- * The user declares a target URL + a JSON-schema for the request body
1712
- * the agent should send, plus an optional shared secret. We sign every
1713
- * outbound POST with HMAC-SHA256 over `timestamp.body` and forward the
1714
- * agent's idempotency key as a header. The receiving system enforces
1715
- * its own idempotency.
1716
- *
1717
- * One adapter, two capabilities. Both arity-1 — `body` is whatever JSON
1718
- * the agent's planner constructs from the operator-defined schema (which
1719
- * lives in DataSource.metadata.requestSchema). The agent's planner reads
1720
- * that schema at request time and constructs valid args.
1721
- *
1722
- * Why one connector covers 50 systems badly and 1 system well: the agent
1723
- * gets a generic "send_event" tool that doesn't *know* what the upstream
1724
- * does with the payload. That's fine for fire-and-forget event posting
1725
- * (Zapier-style); it's wrong for booking against a calendar where you
1726
- * need conflict-resolution. So webhook's `post_event` capability is
1727
- * marked `cas: 'native-idempotency'` (we forward the key — the receiver
1728
- * MUST honor it) and `defaultConsistencyModel: 'advisory'`. Anyone
1729
- * needing real CAS uses a kind-specific connector (Calendar, Sheets, ...).
1730
- */
1731
-
1732
- declare const webhookConnector: ConnectorAdapter;
1733
-
1734
- /**
1735
- * Stripe inbound-webhook receiver — push-only side of a Stripe connector.
1736
- *
1737
- * The full Stripe connector (charges/customers/invoices read+mutation) is
1738
- * tracked in INTEGRATIONS.md as separate `stripe-customers` / `stripe-invoices`
1739
- * rows. This adapter only ships the inbound surface today: receive a push,
1740
- * verify the signature, persist one `InboundEvent` per Stripe event so the
1741
- * agent's runtime can react (e.g. payment_failed → outbound dunning call).
1742
- *
1743
- * Why a dedicated `kind: 'stripe'` rather than reusing the billing webhook
1744
- * at /api/billing/stripe-webhook: that route is hard-coded for OUR Stripe
1745
- * account (Builder subscription state). This connector is for the customer's
1746
- * OWN Stripe account — they paste their `whsec_*` and we listen on a
1747
- * per-DataSource URL, /api/webhooks/inbound/stripe/:dataSourceId.
1748
- *
1749
- * Signature scheme: Stripe's `t=<unix>,v1=<hmac>` header. HMAC is
1750
- * sha256(`${t}.${rawBody}`) keyed by the customer's webhook secret. We use
1751
- * `timingSafeEqual` to defeat timing oracles and bound timestamp skew at
1752
- * 5 minutes (Stripe's recommendation) to thwart replay against captured
1753
- * signatures.
1754
- */
1755
-
1756
- declare const stripeWebhookReceiverConnector: ConnectorAdapter;
1757
-
1758
- /**
1759
- * Slack Events API inbound receiver.
1760
- *
1761
- * Slack sends two distinct request shapes to the same webhook URL:
1762
- *
1763
- * 1. `url_verification` — a one-off handshake during app-config. The body
1764
- * contains a `challenge` string we MUST echo back as the response body
1765
- * (Slack's app-config UI fails the URL otherwise). No InboundEvent is
1766
- * persisted for this — it's an infrastructure ping, not a user event.
1767
- *
1768
- * 2. `event_callback` — every actual workspace event (message posted,
1769
- * reaction added, channel created, …). We persist one InboundEvent
1770
- * keyed by `event_id` so a Slack retry (Slack retries 3 times on any
1771
- * non-2xx) is deduped at the unique constraint, not after we've
1772
- * double-processed.
1773
- *
1774
- * Signature scheme: `v0=<hmac(sha256, "v0:<timestamp>:<rawBody>")>` keyed by
1775
- * the app's signing secret. Header `X-Slack-Request-Timestamp` carries the
1776
- * timestamp; we reject anything older than 5 minutes (Slack's recommendation)
1777
- * to bound replay risk.
1778
- */
1779
-
1780
- declare const slackEventsConnector: ConnectorAdapter;
1781
-
1782
- declare const githubConnector: ConnectorAdapter;
1783
-
1784
- declare const gitlabConnector: ConnectorAdapter;
1785
-
1786
- declare const airtableConnector: ConnectorAdapter;
1787
-
1788
- declare const asanaConnector: ConnectorAdapter;
1789
-
1790
- declare const salesforceConnector: ConnectorAdapter;
1791
-
1792
- interface IntegrationInvocationEnvelope {
1793
- kind: 'integration.invocation';
1794
- capabilityToken: string;
1795
- toolName: string;
1796
- action: string;
1797
- input?: unknown;
1798
- idempotencyKey: string;
1799
- dryRun?: boolean;
1800
- metadata?: Record<string, unknown>;
1801
- }
1802
- interface IntegrationInvocationEnvelopeValidationOptions {
1803
- connectors?: IntegrationConnector[];
1804
- maxInputBytes?: number;
1805
- requireKnownTool?: boolean;
1806
- }
1807
- type NormalizedIntegrationResult = {
1808
- status: 'ok';
1809
- action: string;
1810
- output?: unknown;
1811
- metadata?: Record<string, unknown>;
1812
- } | {
1813
- status: 'approval_required';
1814
- action: string;
1815
- approval: IntegrationApprovalRequest;
1816
- metadata?: Record<string, unknown>;
1817
- } | {
1818
- status: 'failed';
1819
- action: string;
1820
- error: string;
1821
- metadata?: Record<string, unknown>;
1822
- };
1823
- interface IntegrationSandboxHostHub {
1824
- invokeWithCapability(token: string, request: InvokeWithCapabilityRequest): Promise<IntegrationActionResult> | IntegrationActionResult;
1825
- }
1826
- interface IntegrationSandboxHostOptions extends IntegrationInvocationEnvelopeValidationOptions {
1827
- hub: IntegrationSandboxHostHub;
1828
- }
1829
- declare function buildIntegrationInvocationEnvelope(input: {
1830
- capabilityToken: string;
1831
- toolName: string;
1832
- args?: unknown;
1833
- idempotencyKey: string;
1834
- dryRun?: boolean;
1835
- metadata?: Record<string, unknown>;
1836
- }): IntegrationInvocationEnvelope;
1837
- declare function invocationRequestFromEnvelope(envelope: IntegrationInvocationEnvelope): InvokeWithCapabilityRequest;
1838
- declare function validateIntegrationInvocationEnvelope(envelope: IntegrationInvocationEnvelope, options?: IntegrationInvocationEnvelopeValidationOptions): void;
1839
- declare function redactInvocationEnvelope(envelope: IntegrationInvocationEnvelope): Omit<IntegrationInvocationEnvelope, 'capabilityToken'> & {
1840
- capabilityToken: '[REDACTED]';
1841
- };
1842
- declare function redactCapability(capability: IntegrationCapability): IntegrationCapability;
1843
- declare function normalizeIntegrationResult(result: IntegrationActionResult): NormalizedIntegrationResult;
1844
- declare function dispatchIntegrationInvocation(envelope: IntegrationInvocationEnvelope, options: IntegrationSandboxHostOptions): Promise<NormalizedIntegrationResult>;
1845
- declare class IntegrationSandboxHost {
1846
- private readonly options;
1847
- constructor(options: IntegrationSandboxHostOptions);
1848
- dispatch(envelope: IntegrationInvocationEnvelope): Promise<NormalizedIntegrationResult>;
1849
- }
1850
-
1851
- interface ImportCatalogOptions {
1852
- providerId: string;
1853
- connectorId: string;
1854
- connectorTitle: string;
1855
- category?: IntegrationConnectorCategory;
1856
- auth?: IntegrationConnector['auth'];
1857
- scopes?: string[];
1858
- dataClass?: IntegrationDataClass;
1859
- defaultRisk?: IntegrationActionRisk;
1860
- }
1861
- interface OpenApiDocument {
1862
- openapi?: string;
1863
- swagger?: string;
1864
- info?: {
1865
- title?: string;
1866
- };
1867
- paths?: Record<string, Record<string, OpenApiOperation | unknown>>;
1868
- }
1869
- interface OpenApiOperation {
1870
- operationId?: string;
1871
- summary?: string;
1872
- description?: string;
1873
- parameters?: unknown[];
1874
- requestBody?: unknown;
1875
- responses?: unknown;
1876
- security?: Array<Record<string, string[]>>;
1877
- tags?: string[];
1878
- }
1879
- interface GraphqlOperationSpec {
1880
- name: string;
1881
- kind: 'query' | 'mutation';
1882
- description?: string;
1883
- inputSchema?: unknown;
1884
- outputSchema?: unknown;
1885
- requiredScopes?: string[];
1886
- }
1887
- interface McpCatalogTool {
1888
- name: string;
1889
- description?: string;
1890
- inputSchema?: unknown;
1891
- annotations?: {
1892
- readOnlyHint?: boolean;
1893
- destructiveHint?: boolean;
1894
- openWorldHint?: boolean;
1895
- title?: string;
1896
- };
1897
- }
1898
- interface McpCatalog {
1899
- tools: McpCatalogTool[];
1900
- }
1901
- declare function importOpenApiConnector(document: OpenApiDocument, options: ImportCatalogOptions): IntegrationConnector;
1902
- declare function importGraphqlConnector(operations: GraphqlOperationSpec[], options: ImportCatalogOptions): IntegrationConnector;
1903
- declare function importMcpConnector(catalog: McpCatalog, options: ImportCatalogOptions): IntegrationConnector;
1904
-
1905
- interface GatewayCatalogProviderOptions {
1906
- id: string;
1907
- kind: Extract<IntegrationProviderKind, 'nango' | 'pipedream' | 'activepieces' | 'zapier' | 'executor' | 'custom'>;
1908
- fetchCatalog: () => Promise<GatewayCatalogEntry[]> | GatewayCatalogEntry[];
1909
- startAuth?: (request: StartAuthRequest) => Promise<StartAuthResult> | StartAuthResult;
1910
- completeAuth?: (request: CompleteAuthRequest) => Promise<IntegrationConnection> | IntegrationConnection;
1911
- invokeAction?: (connection: IntegrationConnection, request: IntegrationActionRequest) => Promise<IntegrationActionResult> | IntegrationActionResult;
1912
- cacheTtlMs?: number;
1913
- now?: () => Date;
1914
- }
1915
- interface GatewayCatalogEntry {
1916
- id?: string;
1917
- key?: string;
1918
- name?: string;
1919
- title?: string;
1920
- category?: string;
1921
- auth?: 'oauth2' | 'api_key' | 'none' | 'custom' | string;
1922
- scopes?: string[];
1923
- actions?: GatewayCatalogAction[];
1924
- triggers?: GatewayCatalogTrigger[];
1925
- metadata?: Record<string, unknown>;
1926
- }
1927
- interface GatewayCatalogAction {
1928
- id?: string;
1929
- key?: string;
1930
- name?: string;
1931
- title?: string;
1932
- description?: string;
1933
- risk?: 'read' | 'write' | 'destructive' | string;
1934
- scopes?: string[];
1935
- requiredScopes?: string[];
1936
- dataClass?: IntegrationDataClass | string;
1937
- approvalRequired?: boolean;
1938
- inputSchema?: unknown;
1939
- outputSchema?: unknown;
1940
- }
1941
- interface GatewayCatalogTrigger {
1942
- id?: string;
1943
- key?: string;
1944
- name?: string;
1945
- title?: string;
1946
- description?: string;
1947
- scopes?: string[];
1948
- requiredScopes?: string[];
1949
- dataClass?: IntegrationDataClass | string;
1950
- payloadSchema?: unknown;
1951
- }
1952
- declare function createGatewayCatalogProvider(options: GatewayCatalogProviderOptions): IntegrationProvider;
1953
- declare function normalizeGatewayCatalog(entries: GatewayCatalogEntry[], options: {
1954
- providerId: string;
1955
- providerKind: IntegrationProviderKind;
1956
- }): IntegrationConnector[];
1957
-
1958
- interface ActivepiecesCatalogEntry {
1959
- id: string;
1960
- title: string;
1961
- description: string;
1962
- npmPackage?: string;
1963
- version?: string;
1964
- category: IntegrationConnectorCategory;
1965
- auth: IntegrationConnector['auth'];
1966
- domains: string[];
1967
- actions: Array<{
1968
- id: string;
1969
- title: string;
1970
- risk: IntegrationActionRisk;
1971
- }>;
1972
- triggers: Array<{
1973
- id: string;
1974
- title: string;
1975
- }>;
1976
- source: {
1977
- repository: string;
1978
- path: string;
1979
- license: 'MIT';
1980
- };
1981
- }
1982
- declare function listActivepiecesCatalogEntries(): ActivepiecesCatalogEntry[];
1983
- declare function buildActivepiecesConnectors(options?: {
1984
- providerId?: string;
1985
- includeCatalogActions?: boolean;
1986
- }): IntegrationConnector[];
1987
-
1988
- interface ActivepiecesPieceOverride {
1989
- category?: IntegrationConnectorCategory;
1990
- actionRisks?: Record<string, IntegrationActionRisk>;
1991
- approvalRequired?: Record<string, boolean>;
1992
- }
1993
- declare const ACTIVEPIECES_OVERRIDES: Record<string, ActivepiecesPieceOverride>;
1994
- declare function getActivepiecesOverride(id: string): ActivepiecesPieceOverride | undefined;
1995
-
1996
- type IntegrationCoveragePriority = 'tier_0' | 'tier_1' | 'tier_2' | 'long_tail';
1997
- interface IntegrationCoverageSpec {
1998
- id: string;
1999
- title: string;
2000
- category: IntegrationConnectorCategory;
2001
- auth: IntegrationConnector['auth'];
2002
- priority: IntegrationCoveragePriority;
2003
- providerKinds: IntegrationProviderKind[];
2004
- domains: string[];
2005
- actionPack: IntegrationActionPack;
2006
- scopes?: string[];
2007
- }
2008
- type IntegrationActionPack = 'email' | 'calendar' | 'chat' | 'crm' | 'storage' | 'docs' | 'database' | 'project' | 'support' | 'marketing' | 'sales' | 'commerce' | 'finance' | 'hr' | 'dev' | 'ai' | 'analytics' | 'workflow' | 'webhook';
2009
- declare function listIntegrationCoverageSpecs(): IntegrationCoverageSpec[];
2010
- declare function buildIntegrationCoverageConnectors(options?: {
2011
- providerId?: string;
2012
- priorities?: IntegrationCoveragePriority[];
2013
- categories?: IntegrationConnectorCategory[];
2014
- actionPacks?: IntegrationActionPack[];
2015
- }): IntegrationConnector[];
2016
- declare function integrationCoverageChecklistMarkdown(): string;
2017
-
2018
- type IntegrationAuthMode = 'oauth2' | 'api_key' | 'hmac' | 'none' | 'custom';
2019
- type IntegrationSpecStatus = 'catalog' | 'executable' | 'deprecated';
2020
- type IntegrationFamilyId = 'google' | 'microsoft-graph' | 'atlassian' | 'salesforce' | 'hubspot' | 'slack' | 'notion' | 'standard-oauth2' | 'api-key' | 'hmac' | 'none';
2021
- type NormalizedPermission = `${string}.read` | `${string}.write` | `${string}.delete` | `${string}.admin`;
2022
- interface IntegrationSpec {
2023
- kind: string;
2024
- title: string;
2025
- category: IntegrationConnectorCategory;
2026
- status: IntegrationSpecStatus;
2027
- family: IntegrationFamilyId;
2028
- auth: IntegrationAuthSpec;
2029
- permissions: PermissionDescriptor[];
2030
- actions: IntegrationConnectorAction[];
2031
- triggers?: IntegrationConnectorTrigger[];
2032
- setup: IntegrationSetupSpec;
2033
- lifecycle?: IntegrationLifecycleSpec;
2034
- plannerHints?: IntegrationPlannerHints;
2035
- metadata?: Record<string, unknown>;
2036
- }
2037
- type IntegrationAuthSpec = OAuth2AuthSpec | ApiKeyAuthSpec | HmacAuthSpec | NoneAuthSpec | CustomAuthSpec;
2038
- interface OAuth2AuthSpec {
2039
- mode: 'oauth2';
2040
- authorizationUrl: string;
2041
- tokenUrl: string;
2042
- clientIdEnv?: string;
2043
- clientSecretEnv?: string;
2044
- scopes: ScopeDescriptor[];
2045
- extraAuthParams?: Record<string, string>;
2046
- redirectUriTemplate: string;
2047
- pkce?: 'required' | 'supported' | 'unsupported';
2048
- }
2049
- interface ApiKeyAuthSpec {
2050
- mode: 'api_key';
2051
- credential: CredentialFieldSpec;
2052
- placement?: 'bearer' | 'header' | 'query' | 'basic';
2053
- }
2054
- interface HmacAuthSpec {
2055
- mode: 'hmac';
2056
- credential: CredentialFieldSpec;
2057
- signatureHeader?: string;
2058
- }
2059
- interface NoneAuthSpec {
2060
- mode: 'none';
2061
- }
2062
- interface CustomAuthSpec {
2063
- mode: 'custom';
2064
- description: string;
2065
- }
2066
- interface ScopeDescriptor {
2067
- normalized: NormalizedPermission;
2068
- providerScope: string;
2069
- title: string;
2070
- reason: string;
2071
- risk: IntegrationActionRisk;
2072
- dataClass: IntegrationDataClass;
2073
- }
2074
- interface PermissionDescriptor {
2075
- normalized: NormalizedPermission;
2076
- providerScopes: string[];
2077
- title: string;
2078
- risk: IntegrationActionRisk;
2079
- dataClass: IntegrationDataClass;
2080
- reason: string;
2081
- }
2082
- interface CredentialFieldSpec {
2083
- label: string;
2084
- description: string;
2085
- env?: string;
2086
- example?: string;
2087
- regex?: string;
2088
- secret: boolean;
2089
- }
2090
- interface ConsoleStep {
2091
- id: string;
2092
- title: string;
2093
- detail: string;
2094
- copyValue?: string;
2095
- }
2096
- interface Quirk {
2097
- id: string;
2098
- severity: 'info' | 'warning' | 'critical';
2099
- message: string;
2100
- }
2101
- interface PostSetupCheck {
2102
- id: string;
2103
- title: string;
2104
- detail: string;
2105
- }
2106
- interface HealthcheckSpec {
2107
- id: string;
2108
- level: 'client_config' | 'connection' | 'webhook' | 'static';
2109
- method?: 'GET' | 'POST';
2110
- url?: string;
2111
- expectedStatus?: number[];
2112
- description: string;
2113
- }
2114
- interface IntegrationSetupSpec {
2115
- consoleUrl?: string;
2116
- consoleSteps: ConsoleStep[];
2117
- credentialFields: CredentialFieldSpec[];
2118
- redirectUriTemplate?: string;
2119
- knownQuirks?: Quirk[];
2120
- postSetup?: PostSetupCheck[];
2121
- healthcheck?: HealthcheckSpec;
2122
- }
2123
- interface IntegrationLifecycleSpec {
2124
- supportsRefresh: boolean;
2125
- supportsRevoke: boolean;
2126
- supportsIncrementalAuth: boolean;
2127
- recommendedHealthcheckIntervalHours?: number;
2128
- freshnessSloMinutes?: number;
2129
- }
2130
- interface IntegrationPlannerHints {
2131
- useFor: string[];
2132
- avoidFor?: string[];
2133
- dataFreshness: 'realtime' | 'near_realtime' | 'eventual' | 'manual';
2134
- writeRisk: 'low' | 'medium' | 'high';
2135
- }
2136
- interface IntegrationFamilySpec {
2137
- id: IntegrationFamilyId;
2138
- title: string;
2139
- authMode: IntegrationAuthMode;
2140
- consoleUrl?: string;
2141
- authorizationUrl?: string;
2142
- tokenUrl?: string;
2143
- redirectUriTemplate?: string;
2144
- credentialFields: CredentialFieldSpec[];
2145
- consoleSteps: ConsoleStep[];
2146
- knownQuirks?: Quirk[];
2147
- lifecycle: IntegrationLifecycleSpec;
2148
- }
2149
- interface IntegrationSpecValidationIssue {
2150
- path: string;
2151
- message: string;
2152
- }
2153
- interface IntegrationSpecValidationResult {
2154
- ok: boolean;
2155
- issues: IntegrationSpecValidationIssue[];
2156
- }
2157
- interface RenderSpecOptions {
2158
- host: string;
2159
- callbackPath?: string;
2160
- }
2161
- interface RenderedConsoleStep extends ConsoleStep {
2162
- detail: string;
2163
- copyValue?: string;
2164
- }
2165
- interface CredentialValidationInput {
2166
- field: CredentialFieldSpec;
2167
- value: string;
2168
- }
2169
- interface CredentialValidationResult {
2170
- ok: boolean;
2171
- field: string;
2172
- message?: string;
2173
- }
2174
- interface HealthcheckPlan {
2175
- kind: string;
2176
- healthcheck: HealthcheckSpec;
2177
- requires: Array<'client_id' | 'client_secret' | 'api_key' | 'hmac_secret' | 'connection_credentials'>;
2178
- message: string;
2179
- }
2180
- declare function specAuthToConnectorAuth(auth: IntegrationAuthSpec): IntegrationConnector['auth'];
2181
-
2182
- declare const INTEGRATION_FAMILIES: Record<IntegrationFamilyId, IntegrationFamilySpec>;
2183
- declare function getIntegrationFamily(id: IntegrationFamilyId): IntegrationFamilySpec;
2184
-
2185
- declare function listIntegrationSpecs(): IntegrationSpec[];
2186
- declare function getIntegrationSpec(kind: string): IntegrationSpec | undefined;
2187
- declare function listExecutableIntegrationSpecs(): IntegrationSpec[];
2188
- declare function integrationSpecToConnector(spec: IntegrationSpec, providerId?: string): IntegrationConnector;
2189
-
2190
- declare function renderConsoleSteps(spec: IntegrationSpec, options: RenderSpecOptions): RenderedConsoleStep[];
2191
- declare function renderRunbookMarkdown(spec: IntegrationSpec, options: RenderSpecOptions): string;
2192
- declare function renderAgentToolDescription(spec: IntegrationSpec): string;
2193
- declare function buildHealthcheckPlan(spec: IntegrationSpec): HealthcheckPlan;
2194
- declare function consoleStepsToText(steps: ConsoleStep[]): string;
2195
-
2196
- declare function validateIntegrationSpec(spec: IntegrationSpec): IntegrationSpecValidationResult;
2197
- declare function assertValidIntegrationSpec(spec: IntegrationSpec): void;
2198
- declare function validateCredentialFormat(field: CredentialFieldSpec, value: string): CredentialValidationResult;
2199
- declare function validateCredentialSet(spec: IntegrationSpec, values: Record<string, string>): CredentialValidationResult[];
2200
-
2201
- type IntegrationProviderKind = 'first_party' | 'nango' | 'pipedream' | 'zapier' | 'activepieces' | 'executor' | 'custom';
2202
- type IntegrationConnectorCategory = 'email' | 'calendar' | 'chat' | 'crm' | 'storage' | 'docs' | 'database' | 'webhook' | 'workflow' | 'internal' | 'other';
2203
- type IntegrationActionRisk = 'read' | 'write' | 'destructive';
2204
- type IntegrationDataClass = 'public' | 'internal' | 'private' | 'sensitive' | 'secret';
2205
- interface IntegrationActor {
2206
- type: 'user' | 'team' | 'app' | 'agent' | 'sandbox' | 'system';
2207
- id: string;
2208
- }
2209
- interface IntegrationConnectorAction {
2210
- id: string;
2211
- title: string;
2212
- risk: IntegrationActionRisk;
2213
- requiredScopes: string[];
2214
- dataClass: IntegrationDataClass;
2215
- description?: string;
2216
- approvalRequired?: boolean;
2217
- inputSchema?: unknown;
2218
- outputSchema?: unknown;
2219
- }
2220
- interface IntegrationConnectorTrigger {
2221
- id: string;
2222
- title: string;
2223
- requiredScopes: string[];
2224
- dataClass: IntegrationDataClass;
2225
- description?: string;
2226
- payloadSchema?: unknown;
2227
- }
2228
- interface IntegrationConnector {
2229
- id: string;
2230
- providerId: string;
2231
- title: string;
2232
- category: IntegrationConnectorCategory;
2233
- auth: 'oauth2' | 'api_key' | 'none' | 'custom';
2234
- scopes: string[];
2235
- actions: IntegrationConnectorAction[];
2236
- triggers?: IntegrationConnectorTrigger[];
2237
- metadata?: Record<string, unknown>;
2238
- }
2239
- interface SecretRef {
2240
- provider: string;
2241
- id: string;
2242
- label?: string;
2243
- }
2244
- interface IntegrationConnection {
2245
- id: string;
2246
- owner: IntegrationActor;
2247
- providerId: string;
2248
- connectorId: string;
2249
- status: 'pending' | 'active' | 'expired' | 'revoked' | 'error';
2250
- grantedScopes: string[];
2251
- account?: {
2252
- id?: string;
2253
- email?: string;
2254
- displayName?: string;
2255
- };
2256
- secretRef?: SecretRef;
2257
- createdAt: string;
2258
- updatedAt: string;
2259
- expiresAt?: string;
2260
- lastUsedAt?: string;
2261
- metadata?: Record<string, unknown>;
2262
- }
2263
- interface StartAuthRequest {
2264
- connectorId: string;
2265
- owner: IntegrationActor;
2266
- requestedScopes: string[];
2267
- redirectUri: string;
2268
- state?: string;
2269
- metadata?: Record<string, unknown>;
2270
- }
2271
- interface StartAuthResult {
2272
- providerId: string;
2273
- connectorId: string;
2274
- authUrl: string;
2275
- state: string;
2276
- expiresAt?: string;
2277
- metadata?: Record<string, unknown>;
2278
- }
2279
- interface CompleteAuthRequest {
2280
- connectorId: string;
2281
- owner: IntegrationActor;
2282
- code?: string;
2283
- state: string;
2284
- redirectUri: string;
2285
- metadata?: Record<string, unknown>;
2286
- }
2287
- interface IntegrationActionRequest {
2288
- connectionId: string;
2289
- action: string;
2290
- input?: unknown;
2291
- idempotencyKey?: string;
2292
- dryRun?: boolean;
2293
- metadata?: Record<string, unknown>;
2294
- }
2295
- interface IntegrationActionResult<T = unknown> {
2296
- ok: boolean;
2297
- action: string;
2298
- output?: T;
2299
- externalId?: string;
2300
- warnings?: string[];
2301
- metadata?: Record<string, unknown>;
2302
- }
2303
- interface IntegrationTriggerSubscription {
2304
- id: string;
2305
- connectionId: string;
2306
- trigger: string;
2307
- targetUrl?: string;
2308
- status: 'active' | 'paused' | 'error';
2309
- createdAt: string;
2310
- metadata?: Record<string, unknown>;
2311
- }
2312
- interface IntegrationTriggerEvent<T = unknown> {
2313
- id: string;
2314
- providerId: string;
2315
- connectorId: string;
2316
- connectionId: string;
2317
- trigger: string;
2318
- occurredAt: string;
2319
- payload: T;
2320
- metadata?: Record<string, unknown>;
2321
- }
2322
- interface IntegrationProvider {
2323
- id: string;
2324
- kind: IntegrationProviderKind;
2325
- listConnectors(): Promise<IntegrationConnector[]> | IntegrationConnector[];
2326
- startAuth?(request: StartAuthRequest): Promise<StartAuthResult> | StartAuthResult;
2327
- completeAuth?(request: CompleteAuthRequest): Promise<IntegrationConnection> | IntegrationConnection;
2328
- invokeAction(connection: IntegrationConnection, request: IntegrationActionRequest): Promise<IntegrationActionResult> | IntegrationActionResult;
2329
- subscribeTrigger?(connection: IntegrationConnection, trigger: string, targetUrl?: string): Promise<IntegrationTriggerSubscription> | IntegrationTriggerSubscription;
2330
- unsubscribeTrigger?(subscriptionId: string): Promise<void> | void;
2331
- normalizeTriggerEvent?(raw: unknown): Promise<IntegrationTriggerEvent> | IntegrationTriggerEvent;
2332
- }
2333
- interface IntegrationConnectionStore {
2334
- get(connectionId: string): Promise<IntegrationConnection | undefined> | IntegrationConnection | undefined;
2335
- put(connection: IntegrationConnection): Promise<void> | void;
2336
- listByOwner(owner: IntegrationActor): Promise<IntegrationConnection[]> | IntegrationConnection[];
2337
- delete?(connectionId: string): Promise<void> | void;
2338
- }
2339
- interface IssueCapabilityRequest {
2340
- subject: IntegrationActor;
2341
- connectionId: string;
2342
- scopes: string[];
2343
- allowedActions: string[];
2344
- ttlMs: number;
2345
- metadata?: Record<string, unknown>;
2346
- }
2347
- interface IntegrationCapability {
2348
- id: string;
2349
- subject: IntegrationActor;
2350
- connectionId: string;
2351
- scopes: string[];
2352
- allowedActions: string[];
2353
- issuedAt: string;
2354
- expiresAt: string;
2355
- metadata?: Record<string, unknown>;
2356
- }
2357
- interface IssuedIntegrationCapability {
2358
- capability: IntegrationCapability;
2359
- token: string;
2360
- }
2361
- /**
2362
- * Wraps every action invocation with cross-cutting discipline (idempotency,
2363
- * conflict detection, rate-limiting, audit logging). Optional. When set on
2364
- * the hub, runs BEFORE provider.invokeAction; can short-circuit (return a
2365
- * result directly) or pass through (call `proceed()` to invoke the provider).
2366
- *
2367
- * Why this hook exists: production deployments need conflict-resolution
2368
- * guarantees that span every provider — first-party, Nango, Composio,
2369
- * webhook receivers — and providers shouldn't re-implement them. The
2370
- * canonical implementation is a "MutationGuard" that:
2371
- * 1. Short-circuits on a known idempotency key (returns recorded response).
2372
- * 2. Refuses same-key-different-args (drift detection).
2373
- * 3. Wraps `proceed()` and audit-logs the outcome.
2374
- * 4. Translates upstream conflict signals into a structured result with
2375
- * alternatives the agent can act on.
2376
- *
2377
- * Implementations live in consumers (every product has different
2378
- * persistence + telemetry needs); this interface is the contract.
2379
- */
2380
- interface IntegrationActionGuard {
2381
- /** Wrap an invokeAction call. Implementations MUST call `proceed()` to
2382
- * invoke the underlying provider unless they're returning a cached or
2383
- * short-circuited result.
2384
- *
2385
- * @param ctx connection + request the hub is about to dispatch
2386
- * @param proceed call to invoke the wrapped provider; returns the
2387
- * underlying IntegrationActionResult
2388
- * @returns the result the hub should return to the caller
2389
- */
2390
- invokeAction(ctx: IntegrationGuardContext, proceed: () => Promise<IntegrationActionResult>): Promise<IntegrationActionResult>;
2391
- }
2392
- interface IntegrationGuardContext {
2393
- connection: IntegrationConnection;
2394
- request: IntegrationActionRequest;
2395
- /** The action descriptor from the connector manifest, if discovered. */
2396
- action?: IntegrationConnectorAction;
2397
- }
2398
- type IntegrationPolicyDecision = {
2399
- decision: 'allow';
2400
- reason: string;
2401
- metadata?: Record<string, unknown>;
2402
- } | {
2403
- decision: 'require_approval';
2404
- reason: string;
2405
- approval: IntegrationApprovalRequest;
2406
- metadata?: Record<string, unknown>;
2407
- } | {
2408
- decision: 'deny';
2409
- reason: string;
2410
- metadata?: Record<string, unknown>;
2411
- };
2412
- interface IntegrationApprovalRequest {
2413
- id: string;
2414
- connectionId: string;
2415
- providerId: string;
2416
- connectorId: string;
2417
- action: string;
2418
- actor: IntegrationActor;
2419
- risk: IntegrationActionRisk;
2420
- dataClass: IntegrationDataClass;
2421
- reason: string;
2422
- requestedAt: string;
2423
- inputPreview?: unknown;
2424
- metadata?: Record<string, unknown>;
2425
- }
2426
- interface IntegrationPolicyEngine {
2427
- decide(ctx: IntegrationGuardContext & {
2428
- subject: IntegrationActor;
2429
- }): Promise<IntegrationPolicyDecision> | IntegrationPolicyDecision;
2430
- }
2431
- interface IntegrationHubOptions {
2432
- providers: IntegrationProvider[];
2433
- store: IntegrationConnectionStore;
2434
- capabilitySecret: string;
2435
- /** Optional cross-cutting guard. If provided, every invokeAction call
2436
- * passes through it before reaching the provider. See {@link IntegrationActionGuard}. */
2437
- guard?: IntegrationActionGuard;
2438
- /** Optional policy engine. Runs after capability/scope checks and before
2439
- * provider invocation. Use it to pause writes, deny destructive actions,
2440
- * or apply tenant-specific allow rules. */
2441
- policy?: IntegrationPolicyEngine;
2442
- now?: () => Date;
2443
- }
2444
- interface HttpIntegrationProviderOptions {
2445
- id: string;
2446
- kind?: IntegrationProviderKind;
2447
- connectors: IntegrationConnector[];
2448
- baseUrl: string;
2449
- bearer?: string;
2450
- fetchImpl?: typeof fetch;
2451
- }
2452
- interface InvokeWithCapabilityRequest extends Omit<IntegrationActionRequest, 'connectionId'> {
2453
- connectionId?: never;
2454
- }
2455
- declare class IntegrationError extends Error {
2456
- readonly code: 'provider_not_found' | 'connector_not_found' | 'connection_not_found' | 'connection_not_active' | 'auth_not_supported' | 'capability_invalid' | 'capability_expired' | 'scope_denied' | 'action_denied' | 'action_not_found' | 'approval_required' | 'policy_denied';
2457
- constructor(message: string, code: 'provider_not_found' | 'connector_not_found' | 'connection_not_found' | 'connection_not_active' | 'auth_not_supported' | 'capability_invalid' | 'capability_expired' | 'scope_denied' | 'action_denied' | 'action_not_found' | 'approval_required' | 'policy_denied');
2458
- }
2459
- declare class InMemoryConnectionStore implements IntegrationConnectionStore {
2460
- private readonly connections;
2461
- get(connectionId: string): IntegrationConnection | undefined;
2462
- put(connection: IntegrationConnection): void;
2463
- listByOwner(owner: IntegrationActor): IntegrationConnection[];
2464
- delete(connectionId: string): void;
2465
- }
2466
- declare class IntegrationHub {
2467
- private readonly providers;
2468
- private readonly store;
2469
- private readonly capabilitySecret;
2470
- private readonly guard;
2471
- private readonly policy;
2472
- private readonly now;
2473
- constructor(options: IntegrationHubOptions);
2474
- listConnectors(): Promise<IntegrationConnector[]>;
2475
- listRegistry(options?: ComposeIntegrationRegistryOptions): Promise<IntegrationRegistry>;
2476
- startAuth(providerId: string, request: StartAuthRequest): Promise<StartAuthResult>;
2477
- completeAuth(providerId: string, request: CompleteAuthRequest): Promise<IntegrationConnection>;
2478
- upsertConnection(connection: IntegrationConnection): Promise<IntegrationConnection>;
2479
- listConnections(owner: IntegrationActor): Promise<IntegrationConnection[]>;
2480
- issueCapability(request: IssueCapabilityRequest): Promise<IssuedIntegrationCapability>;
2481
- verifyCapability(token: string): IntegrationCapability;
2482
- invokeWithCapability(token: string, request: InvokeWithCapabilityRequest): Promise<IntegrationActionResult>;
2483
- subscribeTrigger(connectionId: string, trigger: string, targetUrl?: string): Promise<IntegrationTriggerSubscription>;
2484
- private requireProvider;
2485
- private requireConnector;
2486
- private requireConnection;
2487
- private assertConnectionActive;
2488
- }
2489
- declare function sanitizeConnection(connection: IntegrationConnection): Record<string, unknown>;
2490
- declare function createMockIntegrationProvider(options?: {
2491
- id?: string;
2492
- connectors?: IntegrationConnector[];
2493
- onInvoke?: (connection: IntegrationConnection, request: IntegrationActionRequest) => IntegrationActionResult | Promise<IntegrationActionResult>;
2494
- }): IntegrationProvider;
2495
- declare function createHttpIntegrationProvider(options: HttpIntegrationProviderOptions): IntegrationProvider;
2496
- declare function signCapability(capability: IntegrationCapability, secret: string): string;
2497
- declare function verifyCapabilityToken(token: string, secret: string): IntegrationCapability;
2498
-
2499
- export { ACTIVEPIECES_OVERRIDES, type ActivepiecesCatalogEntry, type ActivepiecesPieceOverride, type ApiKeyAuthSpec, ApprovalBackedPolicyEngine, type ApprovalBackedPolicyOptions, type AuthSpec, CANONICAL_INTEGRATION_ACTIONS, type CASStrategy, type CanonicalIntegrationActionId, type CanonicalLaunchConnectorOptions, type Capability, type CapabilityClass, type CapabilityMutation, type CapabilityMutationResult, type CapabilityParameterSchema, type CapabilityRead, type CapabilityReadResult, type CompleteAuthRequest, type ComposeIntegrationRegistryOptions, type ConnectionCredentialResolverOptions, type ConnectorAdapter, type ConnectorAdapterProviderOptions, type ConnectorCredentials, type ConnectorInvocation, type ConnectorManifest, type ConnectorManifestValidationIssue, type ConnectorManifestValidationResult, type ConsentSummary, type ConsistencyModel, type ConsoleStep, type CredentialFieldSpec, type CredentialValidationInput, type CredentialValidationResult, CredentialsExpired, type CustomAuthSpec, DEFAULT_INTEGRATION_BRIDGE_ENV, DEFAULT_SIGNATURE_TOLERANCE_SECONDS, type DataSourceMetadata, DefaultIntegrationActionGuard, type EventHandlerResult, type ExchangeCodeInput, type GatewayCatalogAction, type GatewayCatalogEntry, type GatewayCatalogProviderOptions, type GatewayCatalogTrigger, type GenericHmacVerifyOptions, type GoogleCalendarOptions, type GoogleSheetsOptions, type GraphqlOperationSpec, type HealthcheckPlan, type HealthcheckSpec, type HmacAuthSpec, type HttpIntegrationProviderOptions, type HubSpotOptions, INTEGRATION_FAMILIES, type ImportCatalogOptions, InMemoryConnectionStore, InMemoryIntegrationApprovalStore, InMemoryIntegrationAuditStore, InMemoryIntegrationEventStore, InMemoryIntegrationGrantStore, InMemoryIntegrationHealthcheckStore, InMemoryIntegrationIdempotencyStore, InMemoryIntegrationSecretStore, InMemoryIntegrationWorkflowStore, InMemoryOAuthFlowStore, type InboundEvent, type InferIntegrationRequirementsOptions, type InstalledIntegrationWorkflow, type IntegrationActionGuard, type IntegrationActionPack, type IntegrationActionRequest, type IntegrationActionResult, type IntegrationActionRisk, type IntegrationActor, type IntegrationApprovalFilter, type IntegrationApprovalRecord, type IntegrationApprovalRequest, type IntegrationApprovalResolution, type IntegrationApprovalStatus, type IntegrationApprovalStore, type IntegrationAuditEvent, type IntegrationAuditEventType, type IntegrationAuditFilter, type IntegrationAuditSink, type IntegrationAuditStore, type IntegrationAuthMode, type IntegrationAuthSpec, type IntegrationBridgePayload, type IntegrationBridgeToolBinding, type IntegrationCapability, type IntegrationCapabilityBinding, type IntegrationCatalogSource, type IntegrationConnection, type IntegrationConnectionStore, type IntegrationConnector, type IntegrationConnectorAction, type IntegrationConnectorCategory, type IntegrationConnectorTrigger, type IntegrationCoveragePriority, type IntegrationCoverageSpec, type IntegrationDataClass, IntegrationError, type IntegrationErrorCode, type IntegrationEventStore, type IntegrationFamilyId, type IntegrationFamilySpec, type IntegrationGrant, type IntegrationGrantStore, type IntegrationGuardContext, type IntegrationHealthcheckCheck, type IntegrationHealthcheckResult, type IntegrationHealthcheckStatus, type IntegrationHealthcheckStore, IntegrationHub, type IntegrationHubOptions, type IntegrationIdempotencyRecord, type IntegrationIdempotencyStore, type IntegrationInvocationEnvelope, type IntegrationInvocationEnvelopeValidationOptions, type IntegrationLifecycleSpec, type IntegrationManifest, type IntegrationManifestResolution, type IntegrationPlannerHints, type IntegrationPolicyDecision, type IntegrationPolicyEffect, type IntegrationPolicyEngine, type IntegrationPolicyRule, type IntegrationProvider, type IntegrationProviderKind, type IntegrationRateLimitDecision, type IntegrationRateLimiter, type IntegrationRegistry, type IntegrationRegistryConflict, type IntegrationRegistryEntry, type IntegrationRegistrySourceRef, type IntegrationRegistrySummary, type IntegrationRequirement, type IntegrationRequirementMode, type IntegrationRequirementResolution, type IntegrationRequirementStatus, IntegrationRuntime, IntegrationRuntimeError, type IntegrationRuntimeHub, type IntegrationRuntimeOptions, type IntegrationSandboxBundle, IntegrationSandboxHost, type IntegrationSandboxHostHub, type IntegrationSandboxHostOptions, type IntegrationSecretStore, type IntegrationSetupSpec, type IntegrationSpec, type IntegrationSpecStatus, type IntegrationSpecValidationIssue, type IntegrationSpecValidationResult, type IntegrationSupportTier, type IntegrationToolDefinition, type IntegrationToolSearchFilters, type IntegrationToolSearchResult, type IntegrationTriggerEvent, type IntegrationTriggerSubscription, type IntegrationUserAction, type IntegrationWebhookReceiverResult, type IntegrationWorkflowDefinition, IntegrationWorkflowRuntime, type IntegrationWorkflowRuntimeHub, type IntegrationWorkflowRuntimeOptions, type IntegrationWorkflowStore, type InvokeWithCapabilityRequest, type IssueCapabilityRequest, type IssuedIntegrationCapability, type ManifestValidationIssue, type ManifestValidationResult, type McpCatalog, type McpCatalogTool, type McpToolDefinition, type MicrosoftCalendarOptions, type MissingRequirementExplanation, type NoneAuthSpec, type NormalizedIntegrationError, type NormalizedIntegrationResult, type NormalizedPermission, type NotionDatabaseOptions, type OAuth2AuthSpec, type OAuthFlowStore, type OAuthTokens, type OpenApiDocument, type OpenApiOperation, PROVIDER_PASSTHROUGH_ACTION, type ParsedStripeSignatureHeader, type PendingOAuthFlow, type PermissionDescriptor, type PlatformIntegrationPolicyPresetOptions, type PostSetupCheck, type ProviderHttpRequestInput, type ProviderPassthroughPolicy, type Quirk, type RateLimitSpec, type RefreshInput, type RenderConsentOptions, type RenderSpecOptions, type RenderedConsoleStep, type ResolvedDataSource, ResourceContention, type RestConnectorSpec, type RestCredentialPlacement, type RestOperationSpec, type RestRequestSpec, type ScopeDescriptor, type SecretRef, type SlackOptions, type SlackVerifyOptions, type StartAuthRequest, type StartAuthResult, type StartOAuthInput, type StartOAuthOutput, StaticIntegrationPolicyEngine, type StaticIntegrationPolicyOptions, type StoredIntegrationEvent, type StripeVerifyOptions, type TangleIntegrationInvokeInput, type TangleIntegrationInvokeResult, TangleIntegrationsClient, type TangleIntegrationsClientOptions, type TwilioVerifyOptions, _resetPendingFlowsForTests, airtableConnector, asanaConnector, assertValidConnectorManifest, assertValidIntegrationManifest, assertValidIntegrationSpec, buildActivepiecesConnectors, buildApprovalRequest, buildCanonicalLaunchConnectors, buildDefaultIntegrationRegistry, buildHealthcheckPlan, buildIntegrationBridgeEnvironment, buildIntegrationBridgePayload, buildIntegrationCoverageConnectors, buildIntegrationInvocationEnvelope, buildIntegrationToolCatalog, calendarExercisePlannerManifest, canonicalActionConnectorId, canonicalConnectorId, composeIntegrationRegistry, consoleStepsToText, consumePendingFlow, createApprovalBackedPolicyEngine, createAuditingActionGuard, createConnectionCredentialResolver, createConnectorAdapterProvider, createCredentialBackedAdapterProvider, createDefaultIntegrationActionGuard, createDefaultIntegrationPolicyEngine, createGatewayCatalogProvider, createHttpIntegrationProvider, createIntegrationAuditEvent, createIntegrationRuntime, createIntegrationWorkflowRuntime, createMockIntegrationProvider, createPlatformIntegrationPolicyPreset, createTangleIntegrationsClient, declarativeRestConnector, decodeIntegrationBridgePayload, dispatchIntegrationInvocation, encodeIntegrationBridgePayload, exchangeAuthorizationCode, explainMissingRequirements, firstHeader, getActivepiecesOverride, getIntegrationFamily, getIntegrationSpec, githubConnector, gitlabConnector, googleCalendar, googleSheets, healthcheckRequest, hubspot, importGraphqlConnector, importMcpConnector, importOpenApiConnector, inferIntegrationManifestFromTools, inferIntegrationSupportTier, integrationCoverageChecklistMarkdown, integrationSpecToConnector, integrationToolName, invocationRequestFromEnvelope, listActivepiecesCatalogEntries, listExecutableIntegrationSpecs, listIntegrationCoverageSpecs, listIntegrationSpecs, manifestToConnector, microsoftCalendar, normalizeGatewayCatalog, normalizeIntegrationError, normalizeIntegrationResult, notionDatabase, parseIntegrationBridgeEnvironment, parseIntegrationToolName, parseStripeSignatureHeader, receiveIntegrationWebhook, redactApprovalRequest, redactCapability, redactIntegrationBridgePayload, redactInvocationEnvelope, refreshAccessToken, renderAgentToolDescription, renderApprovalCopy, renderConsentSummary, renderConsoleSteps, renderRunbookMarkdown, resolveConnectionCredentials, resolveIntegrationApproval, revokeConnection, runIntegrationHealthcheck, runIntegrationHealthchecks, salesforceConnector, sanitizeAuditConnection, sanitizeConnection, searchIntegrationTools, signCapability, slack, slackEventsConnector, specAuthToConnectorAuth, startOAuthFlow, statusForCode, storedEventToTriggerEvent, stripePackConnector, stripeWebhookReceiverConnector, summarizeIntegrationRegistry, toMcpTools, twilioSmsConnector, validateConnectorManifest, validateCredentialFormat, validateCredentialSet, validateIntegrationInvocationEnvelope, validateIntegrationManifest, validateIntegrationSpec, validateProviderPassthroughRequest, verifyCapabilityToken, verifyHmacSignature, verifySlackSignature, verifyStripeSignature, verifyTwilioSignature, webhookConnector };
1
+ export { A as ACTIVEPIECES_OVERRIDES, a as ActivepiecesCatalogEntry, b as ActivepiecesPieceOverride, ApiKeyAuthSpec, c as ApprovalBackedPolicyEngine, d as ApprovalBackedPolicyOptions, e as AuthSpec, C as CANONICAL_INTEGRATION_ACTIONS, f as CASStrategy, g as CanonicalIntegrationActionId, h as CanonicalLaunchConnectorOptions, i as Capability, j as CapabilityClass, k as CapabilityMutation, l as CapabilityMutationResult, m as CapabilityParameterSchema, n as CapabilityRead, o as CapabilityReadResult, p as CompleteAuthRequest, q as ComposeIntegrationRegistryOptions, r as ConnectionCredentialResolverOptions, s as ConnectorAdapter, t as ConnectorAdapterProviderOptions, u as ConnectorCredentials, v as ConnectorInvocation, w as ConnectorManifest, x as ConnectorManifestValidationIssue, y as ConnectorManifestValidationResult, z as ConsentSummary, B as ConsistencyModel, ConsoleStep, CredentialFieldSpec, CredentialValidationInput, CredentialValidationResult, D as CredentialsExpired, CustomAuthSpec, E as DEFAULT_INTEGRATION_BRIDGE_ENV, F as DEFAULT_SIGNATURE_TOLERANCE_SECONDS, G as DataSourceMetadata, H as DefaultIntegrationActionGuard, I as EventHandlerResult, J as ExchangeCodeInput, K as GatewayCatalogAction, L as GatewayCatalogEntry, M as GatewayCatalogProviderOptions, N as GatewayCatalogTrigger, O as GenericHmacVerifyOptions, P as GoogleCalendarOptions, Q as GoogleSheetsOptions, R as GraphqlOperationSpec, HealthcheckPlan, HealthcheckSpec, HmacAuthSpec, S as HttpIntegrationProviderOptions, T as HubSpotOptions, INTEGRATION_FAMILIES, U as ImportCatalogOptions, V as InMemoryConnectionStore, W as InMemoryIntegrationApprovalStore, X as InMemoryIntegrationAuditStore, Y as InMemoryIntegrationEventStore, Z as InMemoryIntegrationGrantStore, _ as InMemoryIntegrationHealthcheckStore, $ as InMemoryIntegrationIdempotencyStore, a0 as InMemoryIntegrationSecretStore, a1 as InMemoryIntegrationWorkflowStore, a2 as InMemoryOAuthFlowStore, a3 as InboundEvent, a4 as InferIntegrationRequirementsOptions, a5 as InstalledIntegrationWorkflow, a6 as IntegrationActionGuard, a7 as IntegrationActionPack, a8 as IntegrationActionRequest, a9 as IntegrationActionResult, aa as IntegrationActionRisk, ab as IntegrationActor, ac as IntegrationApprovalFilter, ad as IntegrationApprovalRecord, ae as IntegrationApprovalRequest, af as IntegrationApprovalResolution, ag as IntegrationApprovalStatus, ah as IntegrationApprovalStore, ai as IntegrationAuditEvent, aj as IntegrationAuditEventType, ak as IntegrationAuditFilter, al as IntegrationAuditSink, am as IntegrationAuditStore, IntegrationAuthMode, IntegrationAuthSpec, an as IntegrationBridgePayload, ao as IntegrationBridgeToolBinding, ap as IntegrationCapability, aq as IntegrationCapabilityBinding, ar as IntegrationCatalogSource, as as IntegrationConnection, at as IntegrationConnectionStore, au as IntegrationConnector, av as IntegrationConnectorAction, aw as IntegrationConnectorCategory, ax as IntegrationConnectorTrigger, ay as IntegrationCoveragePriority, az as IntegrationCoverageSpec, aA as IntegrationDataClass, aB as IntegrationError, aC as IntegrationErrorCode, aD as IntegrationEventStore, IntegrationFamilyId, IntegrationFamilySpec, aE as IntegrationGrant, aF as IntegrationGrantStore, aG as IntegrationGuardContext, aH as IntegrationHealthcheckCheck, aI as IntegrationHealthcheckResult, aJ as IntegrationHealthcheckStatus, aK as IntegrationHealthcheckStore, aL as IntegrationHub, aM as IntegrationHubOptions, aN as IntegrationIdempotencyRecord, aO as IntegrationIdempotencyStore, aP as IntegrationInvocationEnvelope, aQ as IntegrationInvocationEnvelopeValidationOptions, IntegrationLifecycleSpec, aR as IntegrationManifest, aS as IntegrationManifestResolution, IntegrationPlannerHints, aT as IntegrationPolicyDecision, aU as IntegrationPolicyEffect, aV as IntegrationPolicyEngine, aW as IntegrationPolicyRule, aX as IntegrationProvider, aY as IntegrationProviderKind, aZ as IntegrationRateLimitDecision, a_ as IntegrationRateLimiter, a$ as IntegrationRegistry, b0 as IntegrationRegistryConflict, b1 as IntegrationRegistryEntry, b2 as IntegrationRegistrySourceRef, b3 as IntegrationRegistrySummary, b4 as IntegrationRequirement, b5 as IntegrationRequirementMode, b6 as IntegrationRequirementResolution, b7 as IntegrationRequirementStatus, b8 as IntegrationRuntime, b9 as IntegrationRuntimeError, ba as IntegrationRuntimeHub, bb as IntegrationRuntimeOptions, bc as IntegrationSandboxBundle, bd as IntegrationSandboxHost, be as IntegrationSandboxHostHub, bf as IntegrationSandboxHostOptions, bg as IntegrationSecretStore, IntegrationSetupSpec, IntegrationSpec, IntegrationSpecStatus, IntegrationSpecValidationIssue, IntegrationSpecValidationResult, bh as IntegrationSupportTier, bi as IntegrationToolDefinition, bj as IntegrationToolSearchFilters, bk as IntegrationToolSearchResult, bl as IntegrationTriggerEvent, bm as IntegrationTriggerSubscription, bn as IntegrationUserAction, bo as IntegrationWebhookReceiverResult, bp as IntegrationWorkflowDefinition, bq as IntegrationWorkflowRuntime, br as IntegrationWorkflowRuntimeHub, bs as IntegrationWorkflowRuntimeOptions, bt as IntegrationWorkflowStore, bu as InvokeWithCapabilityRequest, bv as IssueCapabilityRequest, bw as IssuedIntegrationCapability, bx as ManifestValidationIssue, by as ManifestValidationResult, bz as McpCatalog, bA as McpCatalogTool, bB as McpToolDefinition, bC as MicrosoftCalendarOptions, bD as MissingRequirementExplanation, NoneAuthSpec, bE as NormalizedIntegrationError, bF as NormalizedIntegrationResult, NormalizedPermission, bG as NotionDatabaseOptions, OAuth2AuthSpec, bH as OAuthFlowStore, bI as OAuthTokens, bJ as OpenApiDocument, bK as OpenApiOperation, bL as PROVIDER_PASSTHROUGH_ACTION, bM as ParsedStripeSignatureHeader, bN as PendingOAuthFlow, PermissionDescriptor, bO as PlatformIntegrationPolicyPresetOptions, PostSetupCheck, bP as ProviderHttpRequestInput, bQ as ProviderPassthroughPolicy, Quirk, bR as RateLimitSpec, bS as RefreshInput, bT as RenderConsentOptions, RenderSpecOptions, RenderedConsoleStep, bU as ResolvedDataSource, bV as ResourceContention, bW as RestConnectorSpec, bX as RestCredentialPlacement, bY as RestOperationSpec, bZ as RestRequestSpec, ScopeDescriptor, b_ as SecretRef, b$ as SlackOptions, c0 as SlackVerifyOptions, c1 as StartAuthRequest, c2 as StartAuthResult, c3 as StartOAuthInput, c4 as StartOAuthOutput, c5 as StaticIntegrationPolicyEngine, c6 as StaticIntegrationPolicyOptions, c7 as StoredIntegrationEvent, c8 as StripeVerifyOptions, c9 as TangleIntegrationInvokeInput, ca as TangleIntegrationInvokeResult, cb as TangleIntegrationsClient, cc as TangleIntegrationsClientOptions, cd as TwilioVerifyOptions, ce as _resetPendingFlowsForTests, cf as airtableConnector, cg as asanaConnector, ch as assertValidConnectorManifest, ci as assertValidIntegrationManifest, assertValidIntegrationSpec, cj as buildActivepiecesConnectors, ck as buildApprovalRequest, cl as buildCanonicalLaunchConnectors, cm as buildDefaultIntegrationRegistry, buildHealthcheckPlan, cn as buildIntegrationBridgeEnvironment, co as buildIntegrationBridgePayload, cp as buildIntegrationCoverageConnectors, cq as buildIntegrationInvocationEnvelope, cr as buildIntegrationToolCatalog, cs as calendarExercisePlannerManifest, ct as canonicalActionConnectorId, cu as canonicalConnectorId, cv as composeIntegrationRegistry, consoleStepsToText, cw as consumePendingFlow, cx as createApprovalBackedPolicyEngine, cy as createAuditingActionGuard, cz as createConnectionCredentialResolver, cA as createConnectorAdapterProvider, cB as createCredentialBackedAdapterProvider, cC as createDefaultIntegrationActionGuard, cD as createDefaultIntegrationPolicyEngine, cE as createGatewayCatalogProvider, cF as createHttpIntegrationProvider, cG as createIntegrationAuditEvent, cH as createIntegrationRuntime, cI as createIntegrationWorkflowRuntime, cJ as createMockIntegrationProvider, cK as createPlatformIntegrationPolicyPreset, cL as createTangleIntegrationsClient, cM as declarativeRestConnector, cN as decodeIntegrationBridgePayload, cO as dispatchIntegrationInvocation, cP as encodeIntegrationBridgePayload, cQ as exchangeAuthorizationCode, cR as explainMissingRequirements, cS as firstHeader, cT as getActivepiecesOverride, getIntegrationFamily, getIntegrationSpec, cU as githubConnector, cV as gitlabConnector, cW as googleCalendar, cX as googleSheets, cY as healthcheckRequest, cZ as hubspot, c_ as importGraphqlConnector, c$ as importMcpConnector, d0 as importOpenApiConnector, d1 as inferIntegrationManifestFromTools, d2 as inferIntegrationSupportTier, d3 as integrationCoverageChecklistMarkdown, integrationSpecToConnector, d4 as integrationToolName, d5 as invocationRequestFromEnvelope, d6 as listActivepiecesCatalogEntries, listExecutableIntegrationSpecs, d7 as listIntegrationCoverageSpecs, listIntegrationSpecs, d8 as manifestToConnector, d9 as microsoftCalendar, da as normalizeGatewayCatalog, db as normalizeIntegrationError, dc as normalizeIntegrationResult, dd as notionDatabase, de as parseIntegrationBridgeEnvironment, df as parseIntegrationToolName, dg as parseStripeSignatureHeader, dh as receiveIntegrationWebhook, di as redactApprovalRequest, dj as redactCapability, dk as redactIntegrationBridgePayload, dl as redactInvocationEnvelope, dm as refreshAccessToken, renderAgentToolDescription, dn as renderApprovalCopy, dp as renderConsentSummary, renderConsoleSteps, renderRunbookMarkdown, dq as resolveConnectionCredentials, dr as resolveIntegrationApproval, ds as revokeConnection, dt as runIntegrationHealthcheck, du as runIntegrationHealthchecks, dv as salesforceConnector, dw as sanitizeAuditConnection, dx as sanitizeConnection, dy as searchIntegrationTools, dz as signCapability, dA as slack, dB as slackEventsConnector, specAuthToConnectorAuth, dC as startOAuthFlow, dD as statusForCode, dE as storedEventToTriggerEvent, dF as stripePackConnector, dG as stripeWebhookReceiverConnector, dH as summarizeIntegrationRegistry, dI as toMcpTools, dJ as twilioSmsConnector, dK as validateConnectorManifest, validateCredentialFormat, validateCredentialSet, dL as validateIntegrationInvocationEnvelope, dM as validateIntegrationManifest, validateIntegrationSpec, dN as validateProviderPassthroughRequest, dO as verifyCapabilityToken, dP as verifyHmacSignature, dQ as verifySlackSignature, dR as verifyStripeSignature, dS as verifyTwilioSignature, dT as webhookConnector } from './specs.js';