Package Exports
- @contractspec/lib.contracts-integrations
- @contractspec/lib.contracts-integrations/contracts-integrations.feature
- @contractspec/lib.contracts-integrations/integrations
- @contractspec/lib.contracts-integrations/integrations/auth
- @contractspec/lib.contracts-integrations/integrations/auth-helpers
- @contractspec/lib.contracts-integrations/integrations/binding
- @contractspec/lib.contracts-integrations/integrations/byok
- @contractspec/lib.contracts-integrations/integrations/connection
- @contractspec/lib.contracts-integrations/integrations/credentials
- @contractspec/lib.contracts-integrations/integrations/docs/integrations.docblock
- @contractspec/lib.contracts-integrations/integrations/health
- @contractspec/lib.contracts-integrations/integrations/health/contracts
- @contractspec/lib.contracts-integrations/integrations/health/contracts/activities
- @contractspec/lib.contracts-integrations/integrations/health/contracts/biometrics
- @contractspec/lib.contracts-integrations/integrations/health/contracts/nutrition
- @contractspec/lib.contracts-integrations/integrations/health/contracts/sleep
- @contractspec/lib.contracts-integrations/integrations/health/contracts/webhooks
- @contractspec/lib.contracts-integrations/integrations/health/contracts/workouts
- @contractspec/lib.contracts-integrations/integrations/health/guards
- @contractspec/lib.contracts-integrations/integrations/health/health.capability
- @contractspec/lib.contracts-integrations/integrations/health/health.feature
- @contractspec/lib.contracts-integrations/integrations/health/models
- @contractspec/lib.contracts-integrations/integrations/health/telemetry
- @contractspec/lib.contracts-integrations/integrations/integrations.capability
- @contractspec/lib.contracts-integrations/integrations/integrations.feature
- @contractspec/lib.contracts-integrations/integrations/meeting-recorder/contracts
- @contractspec/lib.contracts-integrations/integrations/meeting-recorder/contracts/meetings
- @contractspec/lib.contracts-integrations/integrations/meeting-recorder/contracts/transcripts
- @contractspec/lib.contracts-integrations/integrations/meeting-recorder/contracts/webhooks
- @contractspec/lib.contracts-integrations/integrations/meeting-recorder/meeting-recorder.capability
- @contractspec/lib.contracts-integrations/integrations/meeting-recorder/meeting-recorder.feature
- @contractspec/lib.contracts-integrations/integrations/meeting-recorder/models
- @contractspec/lib.contracts-integrations/integrations/meeting-recorder/telemetry
- @contractspec/lib.contracts-integrations/integrations/openbanking/contracts
- @contractspec/lib.contracts-integrations/integrations/openbanking/contracts/accounts
- @contractspec/lib.contracts-integrations/integrations/openbanking/contracts/balances
- @contractspec/lib.contracts-integrations/integrations/openbanking/contracts/transactions
- @contractspec/lib.contracts-integrations/integrations/openbanking/guards
- @contractspec/lib.contracts-integrations/integrations/openbanking/models
- @contractspec/lib.contracts-integrations/integrations/openbanking/openbanking.capability
- @contractspec/lib.contracts-integrations/integrations/openbanking/openbanking.feature
- @contractspec/lib.contracts-integrations/integrations/openbanking/telemetry
- @contractspec/lib.contracts-integrations/integrations/operations
- @contractspec/lib.contracts-integrations/integrations/providers
- @contractspec/lib.contracts-integrations/integrations/providers/analytics
- @contractspec/lib.contracts-integrations/integrations/providers/analytics-reader
- @contractspec/lib.contracts-integrations/integrations/providers/analytics-writer
- @contractspec/lib.contracts-integrations/integrations/providers/apple-health
- @contractspec/lib.contracts-integrations/integrations/providers/calendar
- @contractspec/lib.contracts-integrations/integrations/providers/composio
- @contractspec/lib.contracts-integrations/integrations/providers/database
- @contractspec/lib.contracts-integrations/integrations/providers/deepgram
- @contractspec/lib.contracts-integrations/integrations/providers/eightsleep
- @contractspec/lib.contracts-integrations/integrations/providers/elevenlabs
- @contractspec/lib.contracts-integrations/integrations/providers/email
- @contractspec/lib.contracts-integrations/integrations/providers/embedding
- @contractspec/lib.contracts-integrations/integrations/providers/fal
- @contractspec/lib.contracts-integrations/integrations/providers/fal-image
- @contractspec/lib.contracts-integrations/integrations/providers/fathom
- @contractspec/lib.contracts-integrations/integrations/providers/fireflies
- @contractspec/lib.contracts-integrations/integrations/providers/fitbit
- @contractspec/lib.contracts-integrations/integrations/providers/garmin
- @contractspec/lib.contracts-integrations/integrations/providers/gcs-storage
- @contractspec/lib.contracts-integrations/integrations/providers/gmail
- @contractspec/lib.contracts-integrations/integrations/providers/google-calendar
- @contractspec/lib.contracts-integrations/integrations/providers/google-drive
- @contractspec/lib.contracts-integrations/integrations/providers/gradium
- @contractspec/lib.contracts-integrations/integrations/providers/granola
- @contractspec/lib.contracts-integrations/integrations/providers/health
- @contractspec/lib.contracts-integrations/integrations/providers/health-provider-shared
- @contractspec/lib.contracts-integrations/integrations/providers/image
- @contractspec/lib.contracts-integrations/integrations/providers/jira
- @contractspec/lib.contracts-integrations/integrations/providers/linear
- @contractspec/lib.contracts-integrations/integrations/providers/llm
- @contractspec/lib.contracts-integrations/integrations/providers/meeting-recorder
- @contractspec/lib.contracts-integrations/integrations/providers/messaging
- @contractspec/lib.contracts-integrations/integrations/providers/messaging-github
- @contractspec/lib.contracts-integrations/integrations/providers/messaging-slack
- @contractspec/lib.contracts-integrations/integrations/providers/messaging-telegram
- @contractspec/lib.contracts-integrations/integrations/providers/messaging-whatsapp-meta
- @contractspec/lib.contracts-integrations/integrations/providers/messaging-whatsapp-twilio
- @contractspec/lib.contracts-integrations/integrations/providers/mistral
- @contractspec/lib.contracts-integrations/integrations/providers/mistral-conversational
- @contractspec/lib.contracts-integrations/integrations/providers/mistral-stt
- @contractspec/lib.contracts-integrations/integrations/providers/myfitnesspal
- @contractspec/lib.contracts-integrations/integrations/providers/notion
- @contractspec/lib.contracts-integrations/integrations/providers/openai-image
- @contractspec/lib.contracts-integrations/integrations/providers/openai-realtime
- @contractspec/lib.contracts-integrations/integrations/providers/openbanking
- @contractspec/lib.contracts-integrations/integrations/providers/openwearables
- @contractspec/lib.contracts-integrations/integrations/providers/oura
- @contractspec/lib.contracts-integrations/integrations/providers/payments
- @contractspec/lib.contracts-integrations/integrations/providers/peloton
- @contractspec/lib.contracts-integrations/integrations/providers/posthog
- @contractspec/lib.contracts-integrations/integrations/providers/posthog-llm-telemetry
- @contractspec/lib.contracts-integrations/integrations/providers/postmark
- @contractspec/lib.contracts-integrations/integrations/providers/powens
- @contractspec/lib.contracts-integrations/integrations/providers/project-management
- @contractspec/lib.contracts-integrations/integrations/providers/provider-delta
- @contractspec/lib.contracts-integrations/integrations/providers/qdrant
- @contractspec/lib.contracts-integrations/integrations/providers/registry
- @contractspec/lib.contracts-integrations/integrations/providers/sms
- @contractspec/lib.contracts-integrations/integrations/providers/storage
- @contractspec/lib.contracts-integrations/integrations/providers/strava
- @contractspec/lib.contracts-integrations/integrations/providers/stripe
- @contractspec/lib.contracts-integrations/integrations/providers/supabase-postgres
- @contractspec/lib.contracts-integrations/integrations/providers/supabase-vector
- @contractspec/lib.contracts-integrations/integrations/providers/tldv
- @contractspec/lib.contracts-integrations/integrations/providers/twilio-sms
- @contractspec/lib.contracts-integrations/integrations/providers/vector-store
- @contractspec/lib.contracts-integrations/integrations/providers/video
- @contractspec/lib.contracts-integrations/integrations/providers/voice
- @contractspec/lib.contracts-integrations/integrations/providers/voice-video-sync
- @contractspec/lib.contracts-integrations/integrations/providers/whoop
- @contractspec/lib.contracts-integrations/integrations/runtime
- @contractspec/lib.contracts-integrations/integrations/secrets
- @contractspec/lib.contracts-integrations/integrations/secrets-types
- @contractspec/lib.contracts-integrations/integrations/secrets/aws-secret-manager
- @contractspec/lib.contracts-integrations/integrations/secrets/env-secret-provider
- @contractspec/lib.contracts-integrations/integrations/secrets/gcp-secret-manager
- @contractspec/lib.contracts-integrations/integrations/secrets/manager
- @contractspec/lib.contracts-integrations/integrations/secrets/provider
- @contractspec/lib.contracts-integrations/integrations/secrets/scaleway-secret-manager
- @contractspec/lib.contracts-integrations/integrations/spec
- @contractspec/lib.contracts-integrations/integrations/transport
- @contractspec/lib.contracts-integrations/integrations/versioning
Readme
@contractspec/lib.contracts-integrations
@contractspec/lib.contracts-integrations defines provider-agnostic contracts for integration specs, connection/runtime handling, secret resolution, health and telemetry, and capability-level provider interfaces such as LLM, embeddings, vector stores, email, and storage.
Website: https://contractspec.io
Installation
bun add @contractspec/lib.contracts-integrations
or
npm install @contractspec/lib.contracts-integrations
What belongs here
This package owns the contract layer for external integrations:
- Integration spec model and registries.
- Connection, auth, transport, versioning, and BYOK contracts.
- Runtime guards and health/telemetry helpers.
- Secret provider abstraction and secret-provider manager.
- Capability-level provider interfaces such as
LLMProviderandVectorStoreProvider. - Provider delta contracts for cursor, lease, webhook, replay, dedupe, idempotency, and tombstone state.
- Shipped provider/domain spec registrations.
- Integration connection operations contracts.
Use this package when you need shared integration contracts. Do not use it as the SDK-backed implementation layer or as the integration persistence runtime.
Core workflows
Define and register an integration spec
import {
defineIntegration,
IntegrationSpecRegistry,
} from "@contractspec/lib.contracts-integrations";
const registry = new IntegrationSpecRegistry();
const spec = defineIntegration({
meta: {
key: "payments.example",
version: 1,
title: "Example Payments",
owners: ["@platform.integrations"],
tags: ["payments"],
category: "payments",
},
supportedModes: ["managed", "byok"],
capabilities: {
provides: [{ key: "payments.process" }],
},
configSchema: {
schema: { type: "object" },
},
secretSchema: {
schema: { type: "object" },
},
});
registry.register(spec);Consume runtime contracts with secrets and guards
import {
IntegrationCallGuard,
} from "@contractspec/lib.contracts-integrations/integrations/runtime";
import {
EnvSecretProvider,
SecretProviderManager,
} from "@contractspec/lib.contracts-integrations/integrations/secrets";
const secretProvider = new SecretProviderManager({
providers: [
{ provider: new EnvSecretProvider(), priority: 100 },
],
});
const guard = new IntegrationCallGuard(secretProvider);
const result = await guard.executeWithGuards(
"primary-llm",
"chat",
{},
resolvedAppConfig,
async (connection, secrets) => {
return llmAdapter.chat(connection, secrets, input);
}
);Typical flow:
- Declare an
IntegrationSpecthat describes config, secrets, auth, transport, and version policy. - Register specs in an
IntegrationSpecRegistryor usecreateDefaultIntegrationSpecRegistry(). - Bind tenant connections and secret references outside this package.
- Resolve secrets and execute guarded runtime calls through
IntegrationCallGuard.
Model provider delta sync state
import type {
ProviderDeltaSyncState,
} from "@contractspec/lib.contracts-integrations/integrations/providers/provider-delta";
const delta: ProviderDeltaSyncState = {
lease: {
holder: "knowledge-sync-worker",
expiresAt: "2026-04-30T13:00:00.000Z",
renewalWindowMs: 60_000,
},
cursor: {
cursor: "gmail-history-123",
watermarkVersion: "history-v1",
},
webhookChannel: {
channelId: "google-channel-1",
resourceId: "google-resource-1",
expiresAt: "2026-04-30T14:00:00.000Z",
},
providerEventId: "provider-event-1",
dedupeKey: "gmail:provider-event-1",
idempotencyKey: "tenant:gmail:provider-event-1",
replayCheckpoint: {
checkpointId: "replay-1",
},
};Delta-aware providers should attach this state before runtime sync starts so callers can renew leases, resume from provider cursors/watermarks, preserve webhook expiry, dedupe provider events, run idempotently, replay from checkpoints, and skip tombstoned source records.
API map
Spec model and registries
IntegrationSpec: provider-agnostic contract for a shipped or custom integration.IntegrationSpecRegistry: registry for integration specs with category-based lookup.defineIntegration: helper for authoring specs.makeIntegrationSpecKey: canonical key formatter for spec identity.createDefaultIntegrationSpecRegistry: registry builder for shipped provider specs.filterByTransport,filterByAuthMethod,filterVersioned,filterByokRotatable: spec filtering helpers.
Connections, auth, transport, versioning, and BYOK
IntegrationConnectionandConnectionStatus: tenant-bound connection shape and readiness state.IntegrationAuthConfig,findAuthConfig,supportsAuthMethod: auth contract and helpers.IntegrationTransportConfig,findTransportConfig,supportsTransport: transport contract and helpers.IntegrationVersionPolicy,resolveApiVersion,getVersionInfo,isVersionDeprecated,getActiveVersions: API-version policy helpers.ByokKeyLifecycleand BYOK metadata/result types: key validation and rotation contracts.IntegrationCredentialManifestand helpers from./integrations/credentials: managed/BYOK credential requirements, env aliases, validation strategy, rotation policy, and compatibility mapping from legacy schemas.
Runtime, health, and telemetry
IntegrationCallGuard: guarded execution with secret resolution, retries, and telemetry. Exported from./integrations/runtime.IntegrationCallResult,IntegrationCallError,IntegrationTelemetryEvent: runtime result/telemetry contracts.IntegrationHealthService: structured health checks and telemetry emission.resolveIntegrationRequestContext,resolveAuthMethod,DefaultTransportResolver, and related helpers: runtime resolution utilities.
Secrets
SecretProvider: provider-agnostic secret backend interface. Exported from./integrations/secrets/provider.SecretProviderManager: priority-ordered composite secret provider. Exported from./integrations/secretsor./integrations/secrets/manager.SecretProviderError: structured secret-provider error.parseSecretUri: parseprovider://path?...references.normalizeSecretPayload: normalize text/binary/base64 payloads before writes.
Operations and provider interfaces
- Integration connection operations:
CreateIntegrationConnection,UpdateIntegrationConnection,DeleteIntegrationConnection,ListIntegrationConnections,TestIntegrationConnection. - Frequently consumed provider contracts:
LLMProviderEmbeddingProviderVectorStoreProviderEmailInboundProviderEmailOutboundProviderGoogleDriveProviderObjectStorageProvider
- Delta-aware provider contracts:
ProviderDeltaSyncStateProviderDeltaEnvelopeisProviderDeltaTombstoned
Public surface
The root barrel re-exports common integration contracts from:
- spec and registry helpers
- auth, binding, BYOK, connection, transport, and versioning
- health helpers
- operations contracts
- provider interfaces
- selected domain contracts such as
health,meeting-recorder, andopenbanking
Runtime and secret-management helpers live under ./integrations/runtime and ./integrations/secrets*.
The exhaustive public surface lives under ./integrations/* in package.json.
Use the README as a guide to the main clusters. Use package.json as the authoritative export map for all subpaths, including the many provider and domain-specific entrypoints.
Operational semantics and gotchas
IntegrationCallGuardfails fast when a slot is missing or a connection is not ready.IntegrationCallGuarddefaults to3attempts with250 msbackoff.- Retry only happens when
shouldRetry()returns true; the default implementation looks for a truthyretryablefield on the error. IntegrationSpeccarries config and secret schemas, but raw secrets live behindsecretRefandSecretProvider.SecretProviderManagerdelegates in descending priority order and preserves registration order for ties.resolveApiVersion()uses connection override first, then policy default.IntegrationHealthService.check()returns structured results instead of throwing health failures upward.- Registry filters only match specs that explicitly declare auth methods, transports, version policies, or BYOK support.
- Credential manifests describe required config and secret references per ownership mode; they do not carry raw credential values.
ProviderDeltaSyncStateis the shared contract for sync leases, provider cursors/watermarks, webhook channel expiry, replay checkpoints, dedupe/idempotency keys, provider event IDs, and tombstones.- Gmail and Google Drive specs advertise
provider.delta.watch; Drive also advertisesknowledge.ingestion.drive. - This package defines contracts and shipped spec registrations. SDK-backed implementations live elsewhere.
When not to use this package
- Do not use it as a provider SDK implementation layer.
- Do not use it as the secret storage backend itself.
- Do not use it as the integration persistence database layer.
- Do not use it as the app-config slot/binding resolver.
Related packages
@contractspec/lib.contracts-spec: upstream spec system consumed by integration contracts and operations.@contractspec/lib.schema: schema types used by operation and config shapes.@contractspec/integration.runtime: runtime composition layer built on top of these contracts.@contractspec/integration.providers-impls: SDK-backed provider implementations for many of these interfaces.@contractspec/lib.knowledge: major consumer of embedding, vector-store, email, storage, and LLM provider interfaces.
Local commands
bun run lint:checkbun run typecheckbun test