@okrlinkhub/agent-bridge 3.1.2 → 3.1.3
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 +177 -139
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,32 +2,32 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://badge.fury.io/js/@okrlinkhub%2Fagent-bridge)
|
|
4
4
|
|
|
5
|
-
`@okrlinkhub/agent-bridge`
|
|
5
|
+
`@okrlinkhub/agent-bridge` exposes an HTTP gateway for external agents with a **config-first** approach:
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
7
|
+
- declare exposed Convex functions in a single file;
|
|
8
|
+
- configure permissions in batch only for those functions;
|
|
9
|
+
- no changes to existing Convex queries/mutations/actions.
|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## Installation
|
|
12
12
|
|
|
13
13
|
```sh
|
|
14
14
|
npm install @okrlinkhub/agent-bridge
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
##
|
|
17
|
+
## Quick setup
|
|
18
18
|
|
|
19
|
-
### 1)
|
|
19
|
+
### 1) Initialize files in the consumer project
|
|
20
20
|
|
|
21
21
|
```sh
|
|
22
22
|
npx @okrlinkhub/agent-bridge init
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
This creates:
|
|
26
26
|
|
|
27
|
-
- `agent-bridge.config.ts`
|
|
27
|
+
- `agent-bridge.config.ts` (project root)
|
|
28
28
|
- `convex/agentBridge.ts`
|
|
29
29
|
|
|
30
|
-
### 2)
|
|
30
|
+
### 2) Enable the component in `convex/convex.config.ts`
|
|
31
31
|
|
|
32
32
|
```ts
|
|
33
33
|
import { defineApp } from "convex/server";
|
|
@@ -38,7 +38,7 @@ app.use(agentBridge);
|
|
|
38
38
|
export default app;
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
-
### 3)
|
|
41
|
+
### 3) Mount routes in `convex/http.ts`
|
|
42
42
|
|
|
43
43
|
```ts
|
|
44
44
|
import { httpRouter } from "convex/server";
|
|
@@ -49,7 +49,7 @@ registerAgentBridgeRoutes(http);
|
|
|
49
49
|
export default http;
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
Optional: customize auth in `registerRoutes`:
|
|
53
53
|
|
|
54
54
|
```ts
|
|
55
55
|
registerRoutes(http, components.agentBridge, bridgeConfig, {
|
|
@@ -59,9 +59,9 @@ registerRoutes(http, components.agentBridge, bridgeConfig, {
|
|
|
59
59
|
});
|
|
60
60
|
```
|
|
61
61
|
|
|
62
|
-
`linkingMode: "component_api_only"`
|
|
62
|
+
`linkingMode: "component_api_only"` is the default and keeps linking on the component's Convex API (no HTTP linking endpoints exposed by the bridge).
|
|
63
63
|
|
|
64
|
-
### 4)
|
|
64
|
+
### 4) Configure exposed functions in `agent-bridge.config.ts`
|
|
65
65
|
|
|
66
66
|
```ts
|
|
67
67
|
import { api } from "./convex/_generated/api";
|
|
@@ -75,7 +75,7 @@ export default defineAgentBridgeConfig({
|
|
|
75
75
|
},
|
|
76
76
|
metadata: {
|
|
77
77
|
"cart.calculatePrice": {
|
|
78
|
-
description: "
|
|
78
|
+
description: "Calculate total price",
|
|
79
79
|
riskLevel: "low",
|
|
80
80
|
category: "commerce",
|
|
81
81
|
},
|
|
@@ -83,36 +83,36 @@ export default defineAgentBridgeConfig({
|
|
|
83
83
|
});
|
|
84
84
|
```
|
|
85
85
|
|
|
86
|
-
##
|
|
86
|
+
## Exposed HTTP endpoints
|
|
87
87
|
|
|
88
88
|
- `POST /agent/execute`
|
|
89
89
|
- `GET /agent/functions`
|
|
90
90
|
|
|
91
91
|
### `POST /agent/execute`
|
|
92
92
|
|
|
93
|
-
|
|
93
|
+
Required headers (strict-only):
|
|
94
94
|
|
|
95
95
|
- `X-Agent-Service-Id: <service-id>`
|
|
96
96
|
- `X-Agent-Service-Key: <service-key>`
|
|
97
|
-
- `X-Agent-App: <app-key>` (
|
|
97
|
+
- `X-Agent-App: <app-key>` (e.g. `crm`, `billing`)
|
|
98
98
|
|
|
99
|
-
|
|
99
|
+
Optional header for Convex user context:
|
|
100
100
|
|
|
101
101
|
- `Authorization: Bearer <user-jwt>`
|
|
102
102
|
|
|
103
|
-
|
|
103
|
+
Optional headers for audit linking (hashed in bridge logs):
|
|
104
104
|
|
|
105
105
|
- `X-Agent-Link-Provider`
|
|
106
106
|
- `X-Agent-Link-Provider-User-Id`
|
|
107
107
|
- `X-Agent-Link-User-Subject`
|
|
108
108
|
- `X-Agent-Link-Status`
|
|
109
109
|
|
|
110
|
-
|
|
110
|
+
When to use:
|
|
111
111
|
|
|
112
|
-
-
|
|
113
|
-
-
|
|
112
|
+
- If the target function uses `ctx.auth.getUserIdentity()`, always send `Authorization`.
|
|
113
|
+
- If the function is service-only, `Authorization` can be omitted.
|
|
114
114
|
|
|
115
|
-
|
|
115
|
+
Required body:
|
|
116
116
|
|
|
117
117
|
```json
|
|
118
118
|
{
|
|
@@ -121,27 +121,27 @@ Body richiesto:
|
|
|
121
121
|
}
|
|
122
122
|
```
|
|
123
123
|
|
|
124
|
-
|
|
124
|
+
Response:
|
|
125
125
|
|
|
126
|
-
-
|
|
127
|
-
-
|
|
126
|
+
- success: `{ "success": true, "result": ... }`
|
|
127
|
+
- error: `{ "success": false, "error": "..." }`
|
|
128
128
|
|
|
129
|
-
|
|
129
|
+
Main status codes: `401`, `403`, `404`, `429`, `500`.
|
|
130
130
|
|
|
131
131
|
## User context cross-app (best practice)
|
|
132
132
|
|
|
133
|
-
|
|
133
|
+
To use Agent Bridge in Convex apps with different auth stacks, follow this contract:
|
|
134
134
|
|
|
135
|
-
1. **Service auth** (
|
|
136
|
-
2. **User auth** (
|
|
135
|
+
1. **Service auth** (always): `X-Agent-Service-Id`, `X-Agent-Service-Key`, `X-Agent-App`
|
|
136
|
+
2. **User auth** (when needed): `Authorization: Bearer <user-jwt>`
|
|
137
137
|
|
|
138
|
-
|
|
138
|
+
Common token sources:
|
|
139
139
|
|
|
140
|
-
- `nextauth_convex`:
|
|
141
|
-
- `auth0`:
|
|
142
|
-
- `custom_oidc`:
|
|
140
|
+
- `nextauth_convex`: read `session.convexToken` server-side
|
|
141
|
+
- `auth0`: use Auth0 access token valid for Convex
|
|
142
|
+
- `custom_oidc`: use OIDC token from the app's provider
|
|
143
143
|
|
|
144
|
-
|
|
144
|
+
The package includes reusable helpers:
|
|
145
145
|
|
|
146
146
|
```ts
|
|
147
147
|
import {
|
|
@@ -156,7 +156,7 @@ import {
|
|
|
156
156
|
} from "@okrlinkhub/agent-bridge";
|
|
157
157
|
```
|
|
158
158
|
|
|
159
|
-
|
|
159
|
+
Quick example:
|
|
160
160
|
|
|
161
161
|
```ts
|
|
162
162
|
const tokenAdapter = createNextAuthConvexTokenAdapter({
|
|
@@ -176,32 +176,117 @@ const headers = buildAgentBridgeStrictHeaders({
|
|
|
176
176
|
});
|
|
177
177
|
```
|
|
178
178
|
|
|
179
|
-
|
|
179
|
+
Notes:
|
|
180
180
|
|
|
181
|
-
- `validateJwtClaims`
|
|
182
|
-
-
|
|
181
|
+
- `validateJwtClaims` only checks claims (`exp`, `iss`, `aud`) and does not replace Convex's cryptographic validation.
|
|
182
|
+
- Never log user tokens or service keys.
|
|
183
183
|
|
|
184
|
-
##
|
|
184
|
+
## Environment variables — detailed setup
|
|
185
185
|
|
|
186
|
-
|
|
186
|
+
**Single source of truth:** `.env.local` in the project root.
|
|
187
187
|
|
|
188
|
-
|
|
189
|
-
- `AGENT_BRIDGE_SERVICE_KEYS_JSON={"openclaw-prod":"<key>","openclaw-staging":"<key>"}`
|
|
190
|
-
- `AGENT_BRIDGE_AUDIT_HASH_SALT="<random-long-secret>"` (raccomandata per hashing audit)
|
|
191
|
-
2. In Convex registra un agente per app con `appKey` univoco:
|
|
192
|
-
- `crm`, `billing`, `warehouse`, ecc.
|
|
193
|
-
3. OpenClaw invia per ogni chiamata:
|
|
194
|
-
- `X-Agent-Service-Id` (identita istanza)
|
|
195
|
-
- `X-Agent-Service-Key` (chiave della specifica istanza)
|
|
196
|
-
- `X-Agent-App` (varia per app target)
|
|
188
|
+
Put all variables in `.env.local`, then sync them to Convex, Vercel, and Fly.io (or Railway) according to the matrix below.
|
|
197
189
|
|
|
198
|
-
###
|
|
190
|
+
### Sync matrix (from .env.local to platforms)
|
|
199
191
|
|
|
200
|
-
|
|
192
|
+
| Variable | Convex | Vercel | Fly.io / Railway |
|
|
193
|
+
|----------|--------|--------|-----------------|
|
|
194
|
+
| AGENT_BRIDGE_SERVICE_KEYS_JSON | ✓ | — | — |
|
|
195
|
+
| AGENT_BRIDGE_AUDIT_HASH_SALT | ✓ | — | — |
|
|
196
|
+
| PUBLISHED_SITE_URL | ✓ | — | — |
|
|
197
|
+
| AGENT_BRIDGE_BASE_URL | — | ✓ | — |
|
|
198
|
+
| APP_BASE_URL_MAP_JSON | — | ✓ | ✓ |
|
|
199
|
+
| OPENCLAW_SERVICE_ID | — | ✓ | ✓ |
|
|
200
|
+
| OPENCLAW_SERVICE_KEY | — | ✓ | ✓ |
|
|
201
|
+
|
|
202
|
+
**Important:** This package reads only `AGENT_BRIDGE_SERVICE_KEYS_JSON`, `AGENT_BRIDGE_AUDIT_HASH_SALT`, and `APP_BASE_URL_MAP_JSON`. Variables like `OPENCLAW_*`, `PUBLISHED_SITE_URL`, and `AGENT_BRIDGE_BASE_URL` belong to the integration flow (OpenClaw + frontend/BFF), not the package runtime.
|
|
203
|
+
|
|
204
|
+
### Where do service_id and service_key come from?
|
|
205
|
+
|
|
206
|
+
- **service_id:** You choose it. A readable identifier for the service instance calling the bridge (e.g. `openclaw-prod`, `openclaw-staging`, `my-agent`).
|
|
207
|
+
- **service_key:** Generate it with the package helper. A cryptographic secret (format `abs_live_<random>`).
|
|
208
|
+
|
|
209
|
+
**Flow:**
|
|
210
|
+
|
|
211
|
+
1. Choose a `service_id` (e.g. `openclaw-prod`).
|
|
212
|
+
2. Generate the `service_key` (see below).
|
|
213
|
+
3. Add the pair to `AGENT_BRIDGE_SERVICE_KEYS_JSON` on Convex.
|
|
214
|
+
4. Use the same `service_id` and `service_key` in `OPENCLAW_SERVICE_ID` and `OPENCLAW_SERVICE_KEY` on Vercel/Fly.io/Railway.
|
|
215
|
+
|
|
216
|
+
**Generate service_key (Node.js, requires package installed):**
|
|
217
|
+
|
|
218
|
+
```sh
|
|
219
|
+
node -e "import('@okrlinkhub/agent-bridge').then(m => console.log(m.generateAgentBridgeServiceKey()))"
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
Or in TypeScript:
|
|
223
|
+
|
|
224
|
+
```ts
|
|
225
|
+
import { generateAgentBridgeServiceKey } from "@okrlinkhub/agent-bridge";
|
|
226
|
+
|
|
227
|
+
const serviceKey = generateAgentBridgeServiceKey(); // e.g. abs_live_abc123...
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
**Generate AGENT_BRIDGE_AUDIT_HASH_SALT:**
|
|
231
|
+
|
|
232
|
+
```sh
|
|
233
|
+
openssl rand -base64 32
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
Or with Node.js:
|
|
237
|
+
|
|
238
|
+
```sh
|
|
239
|
+
node -e "console.log(require('crypto').randomBytes(32).toString('base64'))"
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### Complete .env.local example
|
|
243
|
+
|
|
244
|
+
```env
|
|
245
|
+
# Convex (sync to Convex Dashboard)
|
|
246
|
+
AGENT_BRIDGE_SERVICE_KEYS_JSON={"openclaw-prod":"abs_live_xxx","openclaw-staging":"abs_live_yyy"}
|
|
247
|
+
AGENT_BRIDGE_AUDIT_HASH_SALT=<random-32-chars>
|
|
248
|
+
PUBLISHED_SITE_URL=https://app.example.com
|
|
249
|
+
|
|
250
|
+
# Vercel / Fly.io / Railway (sync to all platforms)
|
|
251
|
+
APP_BASE_URL_MAP_JSON={"crm":"https://crm.example.com","billing":"https://billing.example.com"}
|
|
252
|
+
OPENCLAW_SERVICE_ID=openclaw-prod
|
|
253
|
+
OPENCLAW_SERVICE_KEY=abs_live_xxx
|
|
254
|
+
|
|
255
|
+
# Vercel only (BFF that invokes the bridge)
|
|
256
|
+
AGENT_BRIDGE_BASE_URL=https://your-deployment.convex.site
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### Convex Dashboard — step by step
|
|
260
|
+
|
|
261
|
+
1. Go to [dashboard.convex.dev](https://dashboard.convex.dev).
|
|
262
|
+
2. Select your consumer app project.
|
|
263
|
+
3. Sidebar → **Settings** → **Environment Variables**.
|
|
264
|
+
4. Click **Add Environment Variable**.
|
|
265
|
+
5. **Name:** `AGENT_BRIDGE_SERVICE_KEYS_JSON`
|
|
266
|
+
6. **Value:** JSON (e.g. `{"openclaw-prod":"abs_live_xxx"}`). No extra spaces, use double quotes.
|
|
267
|
+
7. Select **Development** and **Production**.
|
|
268
|
+
8. Click **Save**.
|
|
269
|
+
|
|
270
|
+
Repeat for `AGENT_BRIDGE_AUDIT_HASH_SALT` and `PUBLISHED_SITE_URL`.
|
|
271
|
+
|
|
272
|
+
### OpenClaw multi-app setup
|
|
273
|
+
|
|
274
|
+
For multiple OpenClaw instances managing multiple apps:
|
|
275
|
+
|
|
276
|
+
1. In Convex, set the variables from the matrix above.
|
|
277
|
+
2. Register an agent per app with a unique `appKey`: `crm`, `billing`, `warehouse`, etc.
|
|
278
|
+
3. OpenClaw sends for each call:
|
|
279
|
+
- `X-Agent-Service-Id` (instance identity)
|
|
280
|
+
- `X-Agent-Service-Key` (key for that instance)
|
|
281
|
+
- `X-Agent-App` (varies by target app)
|
|
282
|
+
|
|
283
|
+
### Multi-app URL routing (appKey -> baseUrl)
|
|
284
|
+
|
|
285
|
+
When OpenClaw must call multiple consumer apps (e.g. `execute-on-behalf` endpoint), use:
|
|
201
286
|
|
|
202
287
|
- `APP_BASE_URL_MAP_JSON={"crm":"https://crm.example.com","billing":"https://billing.example.com"}`
|
|
203
288
|
|
|
204
|
-
|
|
289
|
+
Package helpers:
|
|
205
290
|
|
|
206
291
|
```ts
|
|
207
292
|
import {
|
|
@@ -222,78 +307,31 @@ if (!resolvedBaseUrl.ok) {
|
|
|
222
307
|
// resolvedBaseUrl.baseUrl => https://crm.example.com
|
|
223
308
|
```
|
|
224
309
|
|
|
225
|
-
Policy:
|
|
226
|
-
|
|
227
|
-
## Matrice variabili ambiente (Convex vs Vercel vs Railway)
|
|
228
|
-
|
|
229
|
-
Questa e la parte piu soggetta a errori: le variabili con nome simile non vanno tutte nello stesso posto.
|
|
310
|
+
Policy: no fallback to legacy `APP_BASE_URL`. If `appKey` is not in the map, fail explicitly.
|
|
230
311
|
|
|
231
|
-
|
|
232
|
-
- In questo package sono lette direttamente solo: `AGENT_BRIDGE_SERVICE_KEYS_JSON`, `AGENT_BRIDGE_AUDIT_HASH_SALT`, `APP_BASE_URL_MAP_JSON`.
|
|
233
|
-
- Le variabili `OPENCLAW_*`, `PUBLISHED_SITE_URL`, `AGENT_BRIDGE_BASE_URL` appartengono al flusso di integrazione (OpenClaw + frontend/BFF), non al runtime interno del package.
|
|
312
|
+
### Platform-specific setup
|
|
234
313
|
|
|
235
|
-
|
|
314
|
+
**Vercel:** Project → Settings → Environment Variables. Sync variables from `.env.local` per the matrix. Set for Production, Preview, and Development.
|
|
236
315
|
|
|
237
|
-
|
|
238
|
-
- Convex Dashboard -> Project Settings -> Environment Variables (sia dev che prod, con valori coerenti per ambiente).
|
|
316
|
+
**Fly.io:** App → Secrets (or `fly secrets set KEY=value`). Sync `APP_BASE_URL_MAP_JSON`, `OPENCLAW_SERVICE_ID`, `OPENCLAW_SERVICE_KEY` from `.env.local`.
|
|
239
317
|
|
|
240
|
-
|
|
241
|
-
- `AGENT_BRIDGE_SERVICE_KEYS_JSON` (**obbligatoria**): mappa JSON `serviceId -> serviceKey`.
|
|
242
|
-
- Esempio: `{"openclaw-prod":"abs_live_...","openclaw-staging":"abs_live_..."}`
|
|
243
|
-
- Deve contenere la coppia usata da OpenClaw (`OPENCLAW_SERVICE_ID` / `OPENCLAW_SERVICE_KEY`).
|
|
244
|
-
- `AGENT_BRIDGE_AUDIT_HASH_SALT` (**fortemente raccomandata**): segreto lungo usato per hash nei log audit del bridge.
|
|
245
|
-
- `OPENCLAW_LINKING_SHARED_SECRET` (**obbligatoria se usi i flussi linking cross-service**): segreto condiviso da mantenere identico anche dove fai validazione linking lato app/OpenClaw.
|
|
246
|
-
- `PUBLISHED_SITE_URL` (**consigliata**): URL pubblico canonico del sito/app consumer, utile nei flussi che richiedono URL assoluti (es. redirect/callback/linking UX).
|
|
318
|
+
**Railway:** Service → Variables. Same variables as Fly.io.
|
|
247
319
|
|
|
248
|
-
###
|
|
320
|
+
### Consistency checklist
|
|
249
321
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
Variabili:
|
|
255
|
-
- `APP_BASE_URL_MAP_JSON` (**obbligatoria**): mappa `appKey -> baseUrl` per routing multi-app.
|
|
256
|
-
- `OPENCLAW_SERVICE_ID` (**obbligatoria**): id servizio usato negli header strict.
|
|
257
|
-
- `OPENCLAW_SERVICE_KEY` (**obbligatoria**): chiave servizio associata all'id sopra.
|
|
258
|
-
- `OPENCLAW_LINKING_SHARED_SECRET` (**obbligatoria se linking attivo**): deve essere identica a Convex/Railway.
|
|
259
|
-
- `AGENT_BRIDGE_BASE_URL` (**obbligatoria nel BFF che invoca il bridge**): base URL del bridge/endpoint applicativo usato dalle chiamate server-side.
|
|
260
|
-
|
|
261
|
-
### C) Variabili in Railway (agente OpenClaw deployato su Railway)
|
|
262
|
-
|
|
263
|
-
Dove impostarle:
|
|
264
|
-
- Railway -> Service -> Variables (servizio OpenClaw/Gateway).
|
|
265
|
-
|
|
266
|
-
Variabili:
|
|
267
|
-
- `APP_BASE_URL_MAP_JSON` (**obbligatoria**): stessa semantica della mappa usata lato Vercel.
|
|
268
|
-
- `OPENCLAW_LINKING_SHARED_SECRET` (**obbligatoria se linking attivo**): stesso valore di Convex/Vercel.
|
|
269
|
-
- `OPENCLAW_SERVICE_ID` (**obbligatoria**)
|
|
270
|
-
- `OPENCLAW_SERVICE_KEY` (**obbligatoria**)
|
|
271
|
-
- `OPENCLAW_GATEWAY_TRUSTED_PROXIES=127.0.0.1` (**essenziale su Railway**, anche se non e una variabile del bridge): necessaria per corretta gestione proxy/header nel gateway.
|
|
272
|
-
|
|
273
|
-
### Regole di consistenza (checklist anti-errori)
|
|
274
|
-
|
|
275
|
-
- `OPENCLAW_SERVICE_ID` e `OPENCLAW_SERVICE_KEY` devono combaciare con una entry in `AGENT_BRIDGE_SERVICE_KEYS_JSON` su Convex.
|
|
276
|
-
- `OPENCLAW_LINKING_SHARED_SECRET` deve essere identico in tutti i componenti che partecipano al linking.
|
|
277
|
-
- `APP_BASE_URL_MAP_JSON` deve avere le stesse `appKey` usate in `X-Agent-App` e nelle route map.
|
|
278
|
-
- Nessun fallback a `APP_BASE_URL` singola: se `appKey` non e mappata, fallire esplicitamente.
|
|
279
|
-
- Non loggare mai segreti (`OPENCLAW_SERVICE_KEY`, shared secret, bearer token).
|
|
280
|
-
|
|
281
|
-
Puoi generare una service key con l'helper del package:
|
|
282
|
-
|
|
283
|
-
```ts
|
|
284
|
-
import { generateAgentBridgeServiceKey } from "@okrlinkhub/agent-bridge";
|
|
285
|
-
|
|
286
|
-
const serviceKey = generateAgentBridgeServiceKey(); // es: abs_live_<random>
|
|
287
|
-
```
|
|
322
|
+
1. `OPENCLAW_SERVICE_ID` + `OPENCLAW_SERVICE_KEY` must match an entry in `AGENT_BRIDGE_SERVICE_KEYS_JSON` on Convex.
|
|
323
|
+
2. `appKey` values in `APP_BASE_URL_MAP_JSON` must match `X-Agent-App` in requests and the database.
|
|
324
|
+
3. No fallback to a single `APP_BASE_URL`: if `appKey` is not mapped, fail explicitly.
|
|
325
|
+
4. Never log secrets (`OPENCLAW_SERVICE_KEY`, bearer token).
|
|
288
326
|
|
|
289
|
-
|
|
290
|
-
-
|
|
291
|
-
-
|
|
292
|
-
-
|
|
327
|
+
Benefits:
|
|
328
|
+
- centralized control and debugging in the Convex bridge;
|
|
329
|
+
- no multiple API key submissions in requests;
|
|
330
|
+
- rotation and per-app policies managed in the bridge.
|
|
293
331
|
|
|
294
|
-
##
|
|
332
|
+
## Agent and permission management
|
|
295
333
|
|
|
296
|
-
|
|
334
|
+
Component mutations/queries available in `components.agentBridge`:
|
|
297
335
|
|
|
298
336
|
- `agents.createAgent`
|
|
299
337
|
- `agents.updateAgent`
|
|
@@ -310,17 +348,17 @@ Mutation/query del componente disponibili in `components.agentBridge`:
|
|
|
310
348
|
- `linking.revokeLink`
|
|
311
349
|
- `linking.listLinks`
|
|
312
350
|
|
|
313
|
-
### Link
|
|
351
|
+
### Link registry in the component (per-app)
|
|
314
352
|
|
|
315
|
-
|
|
353
|
+
The user link registry is persisted in the component's Convex DB:
|
|
316
354
|
|
|
317
|
-
-
|
|
355
|
+
- logical key: `provider + providerUserId + appKey`
|
|
318
356
|
- target: `appUserSubject`
|
|
319
|
-
-
|
|
357
|
+
- status: `active | revoked | expired`
|
|
320
358
|
|
|
321
|
-
|
|
359
|
+
Each app that installs the component keeps its own registry in its Convex deployment, without a centralized cross-app database.
|
|
322
360
|
|
|
323
|
-
###
|
|
361
|
+
### Batch permissions example
|
|
324
362
|
|
|
325
363
|
```ts
|
|
326
364
|
await ctx.runMutation(components.agentBridge.permissions.setAgentPermissions, {
|
|
@@ -337,29 +375,29 @@ await ctx.runMutation(components.agentBridge.permissions.setAgentPermissions, {
|
|
|
337
375
|
});
|
|
338
376
|
```
|
|
339
377
|
|
|
340
|
-
## Breaking change strict-only
|
|
378
|
+
## Breaking change: strict-only
|
|
341
379
|
|
|
342
|
-
|
|
343
|
-
- `X-Agent-API-Key`
|
|
344
|
-
-
|
|
345
|
-
-
|
|
380
|
+
As of this version:
|
|
381
|
+
- `X-Agent-API-Key` is no longer supported in the HTTP runtime;
|
|
382
|
+
- there is no single-key fallback;
|
|
383
|
+
- the triad `X-Agent-Service-Id` + `X-Agent-Service-Key` + `X-Agent-App` is required.
|
|
346
384
|
|
|
347
|
-
##
|
|
385
|
+
## Migration 0.2 -> next major
|
|
348
386
|
|
|
349
|
-
|
|
387
|
+
Main breaking changes:
|
|
350
388
|
|
|
351
|
-
-
|
|
352
|
-
-
|
|
353
|
-
-
|
|
389
|
+
- removed token/instance token provisioning flow;
|
|
390
|
+
- removed runtime function registration via `createFunctionHandle`;
|
|
391
|
+
- removed use of legacy `AgentBridge` class.
|
|
354
392
|
|
|
355
|
-
|
|
393
|
+
New flow:
|
|
356
394
|
|
|
357
|
-
1.
|
|
358
|
-
2. auth
|
|
359
|
-
3. policy
|
|
360
|
-
4.
|
|
395
|
+
1. configure functions in `agent-bridge.config.ts`;
|
|
396
|
+
2. strict auth via `X-Agent-Service-Id` + `X-Agent-Service-Key` + `X-Agent-App`;
|
|
397
|
+
3. batch policy via component mutations;
|
|
398
|
+
4. centralized logs in `agentLogs`.
|
|
361
399
|
|
|
362
|
-
##
|
|
400
|
+
## Local development
|
|
363
401
|
|
|
364
402
|
```sh
|
|
365
403
|
npm i
|