@tangle-network/agent-integrations 0.25.0 → 0.25.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/README.md CHANGED
@@ -1,21 +1,28 @@
1
1
  # @tangle-network/agent-integrations
2
2
 
3
- Vendor-neutral integration contracts for agent apps, sandboxes, and generated
4
- software that need user-authorized access to external systems.
3
+ Integration infrastructure for agent products, sandbox apps, and generated
4
+ software.
5
5
 
6
- The package standardizes connector catalogs, user connections, scoped sandbox
7
- capabilities, action invocation, trigger events, provider adapters, and
8
- first-party connector adapters. Product code can route through hosted gateways,
9
- custom runtimes, or first-party adapters without changing the agent-facing tool
10
- contract.
6
+ Use this package when users connect external accounts and agents or apps need
7
+ controlled read/write access to those accounts. It gives products one stable
8
+ contract for connector discovery, OAuth/API-key connections, scoped sandbox
9
+ capabilities, action invocation, workflow triggers, approval, audit,
10
+ healthchecks, and provider/runtime adapters.
11
+
12
+ The product keeps ownership of UI, tenant policy, persistence, and secret
13
+ storage. `agent-integrations` keeps the runtime contract stable so generated
14
+ apps and agents do not depend on a specific OAuth broker, workflow vendor, or
15
+ provider SDK.
11
16
 
12
17
  ## Contents
13
18
 
14
19
  - [What It Provides](#what-it-provides)
15
20
  - [Architecture](#architecture)
16
21
  - [Install](#install)
22
+ - [Quick Start](#quick-start)
17
23
  - [Core Primitives](#core-primitives)
18
24
  - [Catalog Registry](#catalog-registry)
25
+ - [Product Adoption](#product-adoption)
19
26
  - [Provider Strategy](#provider-strategy)
20
27
  - [Executable Coverage](#executable-coverage)
21
28
  - [Examples](#examples)
@@ -25,7 +32,7 @@ contract.
25
32
  ## What It Provides
26
33
 
27
34
  - A normalized connector/action/trigger catalog.
28
- - First-class Tangle integration contracts for every catalog connector.
35
+ - Tangle integration contracts for every catalog connector.
29
36
  - User-owned connection records that reference secrets without storing raw
30
37
  credentials in public shapes.
31
38
  - Short-lived capability tokens for sandbox-safe access to a subset of a user's
@@ -37,8 +44,8 @@ contract.
37
44
  runtimes, and internal connector registries.
38
45
  - A first-party `ConnectorAdapter` boundary for direct provider execution.
39
46
  - A declarative REST adapter factory for promoting REST APIs from reviewed specs.
40
- - A broad coverage catalog for planning hundreds of integrations without
41
- pretending every catalog item is executable.
47
+ - A broad catalog for discovering hundreds of integrations while keeping
48
+ executable backend state explicit.
42
49
  - A canonical registry that deduplicates overlapping catalogs, keeps support
43
50
  tiers explicit, and reports auth/category conflicts.
44
51
  - App/agent manifests, grants, and sandbox bundles so Builder, generated apps,
@@ -57,8 +64,10 @@ contract.
57
64
  ## Architecture
58
65
 
59
66
  ```txt
60
- connector catalog
67
+ connector contract
61
68
  -> user connection
69
+ -> app/agent manifest
70
+ -> grant
62
71
  -> scoped capability
63
72
  -> policy decision
64
73
  -> provider/action invocation
@@ -80,6 +89,63 @@ Main boundaries:
80
89
  pnpm add @tangle-network/agent-integrations
81
90
  ```
82
91
 
92
+ ## Quick Start
93
+
94
+ ```ts
95
+ import {
96
+ buildDefaultIntegrationRegistry,
97
+ buildIntegrationToolCatalog,
98
+ createIntegrationRuntime,
99
+ createPlatformIntegrationPolicyPreset,
100
+ InMemoryConnectionStore,
101
+ IntegrationHub,
102
+ } from '@tangle-network/agent-integrations'
103
+
104
+ const registry = buildDefaultIntegrationRegistry({
105
+ tangleCatalogRuntimeExecutable: false,
106
+ })
107
+
108
+ const hub = new IntegrationHub({
109
+ providers: [/* native, gateway, or catalog-runtime providers */],
110
+ store: productConnectionStore ?? new InMemoryConnectionStore(),
111
+ capabilitySecret: process.env.INTEGRATION_CAPABILITY_SECRET!,
112
+ policy: createPlatformIntegrationPolicyPreset(),
113
+ })
114
+
115
+ const runtime = createIntegrationRuntime({
116
+ hub,
117
+ grants: productGrantStore,
118
+ })
119
+
120
+ const tools = buildIntegrationToolCatalog(registry.connectors)
121
+ ```
122
+
123
+ For a generated app or sandbox:
124
+
125
+ ```ts
126
+ const resolution = await runtime.resolveManifest(manifest, user)
127
+
128
+ if (resolution.missing.length > 0) {
129
+ // Show connect UI using IntegrationSpec renderers.
130
+ }
131
+
132
+ await runtime.createGrants({
133
+ manifest,
134
+ owner: user,
135
+ grantee: { type: 'app', id: manifest.id },
136
+ })
137
+
138
+ const bundle = await runtime.buildSandboxBundle({
139
+ manifestId: manifest.id,
140
+ subject: { type: 'sandbox', id: sandboxId },
141
+ ttlMs: 15 * 60_000,
142
+ })
143
+ ```
144
+
145
+ Generated code calls your product integration endpoint with the scoped
146
+ capability bundle. It never receives provider refresh tokens, API keys, or raw
147
+ OAuth credentials.
148
+
83
149
  ## Core Primitives
84
150
 
85
151
  | Primitive | Purpose |
@@ -129,9 +195,9 @@ pnpm add @tangle-network/agent-integrations
129
195
 
130
196
  ## Catalog Registry
131
197
 
132
- Every catalog connector has a first-class Tangle contract. Native adapters and
133
- package runtimes are implementation backends behind that contract; product code
134
- should route through `IntegrationHub` either way.
198
+ Every catalog connector has a Tangle contract. Native adapters, hosted gateways,
199
+ and package runtimes are implementation backends behind that contract; product
200
+ code should route through `IntegrationHub` either way.
135
201
 
136
202
  Use `buildDefaultIntegrationRegistry()` before creating tool catalogs or
137
203
  connection pickers. It produces one canonical connector per integration,
@@ -144,16 +210,16 @@ catalogOnly < setupReady < gatewayExecutable < firstPartyExecutable < sandboxExe
144
210
 
145
211
  Use `buildDefaultIntegrationRegistry({ tangleCatalogRuntimeExecutable: true })`
146
212
  when the Tangle catalog runtime is deployed and should be exposed as executable
147
- tools. These states describe the backend currently wired into a product, not
148
- whether the connector has a first-class Tangle contract.
213
+ tools. These states describe the backend currently wired into a product. They
214
+ do not change the connector contract.
149
215
 
150
216
  See [Catalog Registry](./docs/catalog-registry.md).
151
217
 
152
- ## App And Agent Grants
218
+ ## Product Adoption
153
219
 
154
220
  Use `IntegrationManifest` for any app or agent that needs integrations:
155
- Agent Builder-generated apps, tax/legal/GTM/creative agents, Blueprint Agent
156
- sandboxes, and executor-backed workflows all use the same shape.
221
+ generated apps, domain agents, sandbox agents, workflow apps, and
222
+ executor-backed runtimes all use the same shape.
157
223
 
158
224
  ```ts
159
225
  const runtime = createIntegrationRuntime({ hub, grants })
@@ -204,6 +270,9 @@ That installs provider trigger subscriptions against the user's connection and
204
270
  lets the product dispatch normalized events to UI workflows, sync jobs, or
205
271
  agent runs.
206
272
 
273
+ For a full product checklist, see
274
+ [External Product Integration](./docs/external-product-integration.md).
275
+
207
276
  ## Provider Strategy
208
277
 
209
278
  The package deliberately avoids vendor lock-in.
@@ -0,0 +1,203 @@
1
+ # External Product Integration
2
+
3
+ This guide is for product teams using `@tangle-network/agent-integrations`
4
+ outside this repository. The package gives you stable contracts and runtime
5
+ helpers; your product supplies persistence, secret storage, UI, and deployment
6
+ policy.
7
+
8
+ ## Mental Model
9
+
10
+ ```txt
11
+ user connects account
12
+ -> product stores IntegrationConnection + secret refs
13
+ -> app/agent declares IntegrationManifest
14
+ -> product creates IntegrationGrant
15
+ -> sandbox/app receives short-lived capability bundle
16
+ -> sandbox/app invokes product /integrations/invoke endpoint
17
+ -> IntegrationHub validates capability, policy, approval, idempotency
18
+ -> provider backend executes action
19
+ -> product stores audit event and returns normalized result
20
+ ```
21
+
22
+ The invariant: generated apps and agents call the same Tangle integration tools
23
+ no matter whether a connector is backed by a native adapter, hosted gateway, or
24
+ catalog runtime.
25
+
26
+ ## Product-Owned Pieces
27
+
28
+ You must provide:
29
+
30
+ - `IntegrationConnection` storage in your database.
31
+ - `IntegrationGrant` storage mapping user-owned connections to apps, agents, or
32
+ sandboxes.
33
+ - Approval, audit, healthcheck, workflow, and event stores.
34
+ - `IntegrationSecretStore` backed by your vault or KMS.
35
+ - OAuth/API-key connect UI built from `IntegrationSpec` renderers.
36
+ - Tenant policy for which connectors are enabled.
37
+ - Human approval UX for write/destructive actions.
38
+ - A deployed invocation endpoint such as `/v1/integrations/invoke`.
39
+
40
+ The package provides interfaces and helpers for all of these. It does not store
41
+ your secrets or run your product UI.
42
+
43
+ ## Setup Flow
44
+
45
+ 1. Build the registry.
46
+
47
+ ```ts
48
+ import { buildDefaultIntegrationRegistry } from '@tangle-network/agent-integrations'
49
+
50
+ const registry = buildDefaultIntegrationRegistry({
51
+ tangleCatalogRuntimeExecutable: process.env.TANGLE_CATALOG_RUNTIME === '1',
52
+ })
53
+ ```
54
+
55
+ 2. Render setup UI from specs.
56
+
57
+ ```ts
58
+ import {
59
+ listIntegrationSpecs,
60
+ renderConsoleSteps,
61
+ validateCredentialSet,
62
+ } from '@tangle-network/agent-integrations'
63
+
64
+ const spec = listIntegrationSpecs().find((candidate) => candidate.kind === 'google-calendar')
65
+ const steps = renderConsoleSteps(spec!, { host: 'id.example.com' })
66
+ const validation = validateCredentialSet(spec!, submittedCredentials)
67
+ ```
68
+
69
+ 3. Store provider credentials in your vault, then persist an
70
+ `IntegrationConnection` with secret refs, scopes, owner, connector id, and
71
+ status.
72
+
73
+ 4. Run `runIntegrationHealthchecks()` after setup and on a schedule.
74
+
75
+ ## Runtime Flow
76
+
77
+ Create one hub per product runtime.
78
+
79
+ ```ts
80
+ import {
81
+ createConnectorAdapterProvider,
82
+ createDefaultIntegrationActionGuard,
83
+ IntegrationHub,
84
+ createPlatformIntegrationPolicyPreset,
85
+ } from '@tangle-network/agent-integrations'
86
+
87
+ const hub = new IntegrationHub({
88
+ providers: [
89
+ createConnectorAdapterProvider({
90
+ adapters,
91
+ resolveDataSource: (connection) => credentialResolver.resolve(connection),
92
+ }),
93
+ // createHttpIntegrationProvider(...) or createTangleCatalogExecutorProvider(...)
94
+ ],
95
+ store: connections,
96
+ capabilitySecret: process.env.INTEGRATION_CAPABILITY_SECRET!,
97
+ policy: createPlatformIntegrationPolicyPreset(),
98
+ guard: createDefaultIntegrationActionGuard({
99
+ audit,
100
+ idempotency,
101
+ }),
102
+ })
103
+ ```
104
+
105
+ Your `/v1/integrations/invoke` route should:
106
+
107
+ 1. Parse the invocation envelope.
108
+ 2. Validate the capability token.
109
+ 3. Resolve the user's connection and credentials.
110
+ 4. Run policy and approval checks.
111
+ 5. Execute through the matching provider.
112
+ 6. Store an audit event.
113
+ 7. Return a normalized result or `approval_required`.
114
+
115
+ ## Generated Apps And Sandboxes
116
+
117
+ Generated apps declare needs through `IntegrationManifest`.
118
+
119
+ ```ts
120
+ const manifest = {
121
+ id: 'calendar-workout-planner',
122
+ requirements: [
123
+ {
124
+ connectorId: 'google-calendar',
125
+ mode: 'read',
126
+ reason: 'Find open workout windows from calendar events.',
127
+ requiredActions: ['events.list'],
128
+ scopes: ['calendar.read'],
129
+ },
130
+ ],
131
+ }
132
+ ```
133
+
134
+ When a user previews or installs the app:
135
+
136
+ 1. Resolve the manifest against the user's existing connections.
137
+ 2. Ask the user to connect missing accounts.
138
+ 3. Show consent using `renderConsentSummary()`.
139
+ 4. Create grants from the user's connections to the app.
140
+ 5. Build a sandbox bundle with short-lived capabilities.
141
+ 6. Inject the bridge environment into the sandbox.
142
+
143
+ Generated app code should use `createTangleIntegrationsClient()` or the product
144
+ equivalent. It should not call Google, Slack, GitHub, or any provider directly
145
+ with user credentials.
146
+
147
+ ## Workflows And Triggers
148
+
149
+ Use `createIntegrationWorkflowRuntime()` for non-agent automations:
150
+
151
+ - GitHub issue or pull-request sync.
152
+ - Slack message triggers.
153
+ - Calendar event updates.
154
+ - CRM record changes.
155
+ - Webhook-to-sandbox workflows.
156
+
157
+ Inbound provider webhooks should go through `receiveIntegrationWebhook()` for
158
+ signature verification, provider-event dedupe, and normalized event dispatch.
159
+
160
+ ## Long-Tail Connectors
161
+
162
+ The registry distinguishes connector contracts from executable backend state.
163
+ Products can expose long-tail connectors only when they have configured a
164
+ backend:
165
+
166
+ - native adapter
167
+ - hosted integration gateway
168
+ - Tangle catalog runtime
169
+ - product-specific provider
170
+
171
+ Use `buildDefaultIntegrationRegistry({ tangleCatalogRuntimeExecutable: true })`
172
+ only after the catalog runtime is deployed and audited with
173
+ `auditTangleCatalogRuntimePackages()`.
174
+
175
+ ## Security Requirements
176
+
177
+ - Never pass provider refresh tokens or API keys into a sandbox.
178
+ - Use short-lived capability tokens scoped to connector, action, subject, and
179
+ connection.
180
+ - Require approval for writes by default.
181
+ - Deny destructive actions unless the product explicitly enables them.
182
+ - Use idempotency keys for state-changing actions.
183
+ - Store audit events for connect, grant, invoke, approve, revoke, rotate, and
184
+ webhook flows.
185
+ - Redact provider credentials from logs, traces, errors, and generated app
186
+ payloads.
187
+
188
+ ## Launch Checklist
189
+
190
+ - [ ] Connection, grant, approval, audit, healthcheck, workflow, and event stores
191
+ are backed by production persistence.
192
+ - [ ] Secret refs resolve through vault/KMS and never serialize raw credentials.
193
+ - [ ] OAuth/API-key setup UI renders from `IntegrationSpec`.
194
+ - [ ] Connect, revoke, rotate, approve, and audit-log screens exist.
195
+ - [ ] Generated app manifests feed into `resolveManifest()` and
196
+ `createGrants()`.
197
+ - [ ] Sandbox launches receive `buildIntegrationBridgeEnvironment()` output.
198
+ - [ ] Sandbox invocations route through your product integration endpoint.
199
+ - [ ] Writes require approval and idempotency.
200
+ - [ ] Webhooks verify signatures and dedupe provider event ids.
201
+ - [ ] Healthchecks run after setup and on a schedule.
202
+ - [ ] Browser E2E covers connect, consent, preview, invoke, approval, revoke,
203
+ and failure recovery.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/agent-integrations",
3
- "version": "0.25.0",
3
+ "version": "0.25.1",
4
4
  "description": "Vendor-neutral integration contracts and runtime helpers for sandbox and agent apps.",
5
5
  "homepage": "https://github.com/tangle-network/agent-integrations#readme",
6
6
  "repository": {