@okrlinkhub/agent-factory 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +109 -19
- package/dist/client/bridge.d.ts +64 -0
- package/dist/client/bridge.d.ts.map +1 -0
- package/dist/client/bridge.js +174 -0
- package/dist/client/bridge.js.map +1 -0
- package/dist/client/index.d.ts +54 -40
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +46 -0
- package/dist/client/index.js.map +1 -1
- package/dist/component/_generated/component.d.ts +102 -48
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/config.d.ts +9 -15
- package/dist/component/config.d.ts.map +1 -1
- package/dist/component/config.js +1 -3
- package/dist/component/config.js.map +1 -1
- package/dist/component/lib.d.ts +3 -2
- package/dist/component/lib.d.ts.map +1 -1
- package/dist/component/lib.js +3 -2
- package/dist/component/lib.js.map +1 -1
- package/dist/component/providers/fly.d.ts +12 -0
- package/dist/component/providers/fly.d.ts.map +1 -1
- package/dist/component/providers/fly.js +91 -2
- package/dist/component/providers/fly.js.map +1 -1
- package/dist/component/queue.d.ts +24 -36
- package/dist/component/queue.d.ts.map +1 -1
- package/dist/component/queue.js +171 -193
- package/dist/component/queue.js.map +1 -1
- package/dist/component/scheduler.d.ts +38 -11
- package/dist/component/scheduler.d.ts.map +1 -1
- package/dist/component/scheduler.js +144 -85
- package/dist/component/scheduler.js.map +1 -1
- package/dist/component/schema.d.ts +24 -185
- package/dist/component/schema.d.ts.map +1 -1
- package/dist/component/schema.js +8 -74
- package/dist/component/schema.js.map +1 -1
- package/package.json +2 -2
- package/src/client/bridge.test.ts +93 -0
- package/src/client/bridge.ts +269 -0
- package/src/client/index.ts +55 -0
- package/src/component/_generated/component.ts +112 -46
- package/src/component/config.ts +1 -4
- package/src/component/lib.test.ts +138 -6
- package/src/component/lib.ts +6 -1
- package/src/component/providers/fly.ts +103 -2
- package/src/component/queue.ts +257 -256
- package/src/component/scheduler.ts +182 -98
- package/src/component/schema.ts +10 -116
package/README.md
CHANGED
|
@@ -56,7 +56,12 @@ Verify status:
|
|
|
56
56
|
|
|
57
57
|
```sh
|
|
58
58
|
npx convex run example:secretStatus '{
|
|
59
|
-
"secretRefs": [
|
|
59
|
+
"secretRefs": [
|
|
60
|
+
"convex.url",
|
|
61
|
+
"fly.apiToken",
|
|
62
|
+
"telegram.botToken",
|
|
63
|
+
"agent-bridge.serviceKey.default"
|
|
64
|
+
]
|
|
60
65
|
}'
|
|
61
66
|
```
|
|
62
67
|
|
|
@@ -124,7 +129,6 @@ This cron is a safety net. The primary path remains enqueue-triggered reconcile.
|
|
|
124
129
|
|
|
125
130
|
### LLM configuration (Fly env)
|
|
126
131
|
|
|
127
|
-
LLM selection is intentionally **not stored in `agentProfiles`** anymore.
|
|
128
132
|
The model/provider is controlled by Fly worker environment variables (for example `OPENCLAW_AGENT_MODEL`, `MOONSHOT_API_KEY`, `OPENAI_API_KEY`) and applied at runtime by the worker image bootstrap.
|
|
129
133
|
|
|
130
134
|
Why:
|
|
@@ -144,6 +148,83 @@ If you use `exposeApi(...)`, the worker contract is available directly on the co
|
|
|
144
148
|
- `workerComplete`
|
|
145
149
|
- `workerFail`
|
|
146
150
|
|
|
151
|
+
### Native integration with `agent-bridge` (no consumer glue code)
|
|
152
|
+
|
|
153
|
+
`agent-factory` now exposes a native contract for bridge execution. You only configure profile + secrets in the component.
|
|
154
|
+
|
|
155
|
+
1) Configure an agent profile with bridge settings:
|
|
156
|
+
|
|
157
|
+
```ts
|
|
158
|
+
await ctx.runMutation(components.agentFactory.lib.configureAgent, {
|
|
159
|
+
agentKey: "default",
|
|
160
|
+
version: "1.0.0",
|
|
161
|
+
soulMd: "# Soul",
|
|
162
|
+
clientMd: "# Client",
|
|
163
|
+
skills: ["agent-bridge"],
|
|
164
|
+
secretsRef: [],
|
|
165
|
+
bridgeConfig: {
|
|
166
|
+
enabled: true,
|
|
167
|
+
baseUrl: "https://<your-consumer>.convex.site",
|
|
168
|
+
serviceId: "openclaw-prod",
|
|
169
|
+
appKey: "crm",
|
|
170
|
+
},
|
|
171
|
+
enabled: true,
|
|
172
|
+
});
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
2) Import bridge service key in component secrets:
|
|
176
|
+
|
|
177
|
+
```sh
|
|
178
|
+
npx convex run example:importSecret '{
|
|
179
|
+
"secretRef": "agent-bridge.serviceKey.default",
|
|
180
|
+
"plaintextValue": "abs_live_XXXXXXXXXXXXXXXX"
|
|
181
|
+
}'
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Naming convention supported by hydration resolver:
|
|
185
|
+
- per-agent service key: `agent-bridge.serviceKey.<agentKey>` (recommended)
|
|
186
|
+
- global service key fallback: `agent-bridge.serviceKey`
|
|
187
|
+
- optional profile override: `bridgeConfig.serviceKeySecretRef`
|
|
188
|
+
- optional per-agent/global overrides for `baseUrl`, `serviceId`, `appKey` via:
|
|
189
|
+
- `agent-bridge.baseUrl.<agentKey>` / `agent-bridge.baseUrl`
|
|
190
|
+
- `agent-bridge.serviceId.<agentKey>` / `agent-bridge.serviceId`
|
|
191
|
+
- `agent-bridge.appKey.<agentKey>` / `agent-bridge.appKey`
|
|
192
|
+
|
|
193
|
+
Hydration includes `bridgeRuntimeConfig` for the worker loop.
|
|
194
|
+
|
|
195
|
+
3) In worker runtime use built-in helpers from this package:
|
|
196
|
+
|
|
197
|
+
```ts
|
|
198
|
+
import {
|
|
199
|
+
maybeExecuteBridgeToolCall,
|
|
200
|
+
resolveBridgeRuntimeConfig,
|
|
201
|
+
} from "@okrlinkhub/agent-factory";
|
|
202
|
+
|
|
203
|
+
const resolved = resolveBridgeRuntimeConfig(hydration.bridgeRuntimeConfig);
|
|
204
|
+
if (resolved.ok) {
|
|
205
|
+
// Optional proactive resolution check
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const toolResult = await maybeExecuteBridgeToolCall({
|
|
209
|
+
toolName: pendingToolCall.toolName,
|
|
210
|
+
toolArgs,
|
|
211
|
+
hydratedConfig: hydration.bridgeRuntimeConfig,
|
|
212
|
+
userToken: maybeUserJwtOrNull,
|
|
213
|
+
});
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
`maybeExecuteBridgeToolCall` handles:
|
|
217
|
+
- `bridge.<functionKey>` mapping to `POST /agent/execute`
|
|
218
|
+
- strict headers (`X-Agent-Service-Id`, `X-Agent-Service-Key`, `X-Agent-App`)
|
|
219
|
+
- retry for `429` and `5xx`
|
|
220
|
+
- deterministic response object to map back into conversation/tool messages
|
|
221
|
+
|
|
222
|
+
Fallback env (worker-side only, used when hydration misses values):
|
|
223
|
+
- `OPENCLAW_AGENT_BRIDGE_BASE_URL` or `AGENT_BRIDGE_BASE_URL`
|
|
224
|
+
- `OPENCLAW_SERVICE_ID` or `AGENT_BRIDGE_SERVICE_ID`
|
|
225
|
+
- `OPENCLAW_SERVICE_KEY` or `AGENT_BRIDGE_SERVICE_KEY`
|
|
226
|
+
- `OPENCLAW_AGENT_APP` / `OPENCLAW_APP_KEY` / `AGENT_BRIDGE_APP_KEY`
|
|
227
|
+
|
|
147
228
|
### HTTP Routes
|
|
148
229
|
|
|
149
230
|
You can mount an ingress webhook route in your app:
|
|
@@ -233,11 +314,7 @@ Core tables:
|
|
|
233
314
|
- `workers`
|
|
234
315
|
- `secrets`
|
|
235
316
|
|
|
236
|
-
Hydration
|
|
237
|
-
- `workspaceDocuments`
|
|
238
|
-
- `agentSkills`
|
|
239
|
-
- `skillAssets`
|
|
240
|
-
- `hydrationSnapshots`
|
|
317
|
+
Hydration/runtime tables:
|
|
241
318
|
- `conversationHydrationCache`
|
|
242
319
|
- `dataSnapshots`
|
|
243
320
|
|
|
@@ -247,18 +324,16 @@ Hydration-optimized tables:
|
|
|
247
324
|
- Pre-stop drain protocol added: worker snapshots `/data` before termination and uploads archive metadata into `dataSnapshots`.
|
|
248
325
|
- Restore on boot added: new workers can rehydrate from latest snapshot archive.
|
|
249
326
|
- Hydration improved with `conversationHydrationCache` delta usage.
|
|
250
|
-
- `skillAssets`
|
|
327
|
+
- `agentSkills` and `skillAssets` removed from schema: skills must be baked into the OpenClaw worker image.
|
|
251
328
|
- Worker control/snapshot APIs exposed for runtime loop (`workerControlState`, snapshot upload/finalize/fail, restore lookup).
|
|
252
329
|
|
|
253
|
-
## OpenClaw workspace
|
|
330
|
+
## OpenClaw workspace persistence
|
|
254
331
|
|
|
255
|
-
| OpenClaw source |
|
|
332
|
+
| OpenClaw source | Persistence layer |
|
|
256
333
|
|---|---|
|
|
257
|
-
| `AGENTS.md`, `SOUL.md`, `USER.md`, `IDENTITY.md`, `HEARTBEAT.md`, `TOOLS.md` | `
|
|
258
|
-
| `memory/YYYY-MM-DD.md`, `MEMORY.md` |
|
|
259
|
-
|
|
|
260
|
-
| `skills/*/scripts/*`, `skills/*/config/*` metadata | `skillAssets` |
|
|
261
|
-
| Compiled hydration payload | `hydrationSnapshots` |
|
|
334
|
+
| `AGENTS.md`, `SOUL.md`, `USER.md`, `IDENTITY.md`, `HEARTBEAT.md`, `TOOLS.md` | worker filesystem backup (`/data/workspace`) |
|
|
335
|
+
| `memory/YYYY-MM-DD.md`, `MEMORY.md` | worker filesystem backup (`/data/workspace`) |
|
|
336
|
+
| Skills and related assets | bundled directly in worker image (`openclaw-okr-image`) |
|
|
262
337
|
| Conversation-specific deltas | `conversationHydrationCache` |
|
|
263
338
|
|
|
264
339
|
## Failure model
|
|
@@ -275,7 +350,6 @@ Hydration-optimized tables:
|
|
|
275
350
|
- retry policy
|
|
276
351
|
- lease policy
|
|
277
352
|
- scaling policy
|
|
278
|
-
- hydration policy
|
|
279
353
|
- provider config
|
|
280
354
|
|
|
281
355
|
## Fly.io provider notes
|
|
@@ -286,15 +360,31 @@ The current provider implementation uses Fly Machines API endpoints for:
|
|
|
286
360
|
- cordon machine
|
|
287
361
|
- terminate machine
|
|
288
362
|
|
|
289
|
-
### Worker image
|
|
363
|
+
### Worker image setup (required first step for custom skills)
|
|
364
|
+
|
|
365
|
+
Any new skill you want inside OpenClaw agents must be added to the worker image source repo:
|
|
366
|
+
- https://github.com/okrlinkhub/openclaw-okr-image
|
|
367
|
+
|
|
368
|
+
Fork this repository to maintain your own image with your custom skills/assets.
|
|
369
|
+
|
|
370
|
+
First required flow:
|
|
371
|
+
1) Take the image repo (fork/clone your own `openclaw-okr-image`).
|
|
372
|
+
2) Build and deploy it on your own Fly app.
|
|
373
|
+
- Recommended build mode: remote Fly builder, `depot` disabled, `--remote-only`.
|
|
374
|
+
3) Use the published image as reference in `src/component/config.ts` (`DEFAULT_WORKER_IMAGE` is the source of truth).
|
|
375
|
+
4) Repeat the same process for every runtime/skills update.
|
|
376
|
+
|
|
377
|
+
**Enterprise security model**: The worker image enforces a security policy where only skills explicitly included by the image maintainer are installed by default. Any other skills that may be present in the workspace are automatically removed on each worker startup. This ensures that only approved, vetted skills from the image source can execute within your OpenClaw agents.
|
|
378
|
+
|
|
379
|
+
### Worker image update procedure
|
|
290
380
|
|
|
291
381
|
When you update the worker runtime (for example in `openclaw-okr-image/worker.mjs`), use this flow to publish and roll out safely.
|
|
292
382
|
|
|
293
|
-
1) Deploy with Fly
|
|
383
|
+
1) Deploy with remote Fly builder (explicitly disabling Depot):
|
|
294
384
|
|
|
295
385
|
```sh
|
|
296
386
|
cd /path/to/openclaw-okr-image
|
|
297
|
-
fly deploy --
|
|
387
|
+
fly deploy --remote-only --depot=false --yes
|
|
298
388
|
```
|
|
299
389
|
|
|
300
390
|
2) If deployment fails with `CONVEX_URL not set`, set the secret and retry:
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export type HydratedBridgeRuntimeConfig = {
|
|
2
|
+
baseUrl: string | null;
|
|
3
|
+
serviceId: string | null;
|
|
4
|
+
appKey: string | null;
|
|
5
|
+
serviceKey: string | null;
|
|
6
|
+
serviceKeySecretRef: string | null;
|
|
7
|
+
};
|
|
8
|
+
export type ResolvedBridgeRuntimeConfig = {
|
|
9
|
+
baseUrl: string;
|
|
10
|
+
serviceId: string;
|
|
11
|
+
appKey: string;
|
|
12
|
+
serviceKey: string;
|
|
13
|
+
};
|
|
14
|
+
export type BridgeExecutionResult = {
|
|
15
|
+
success: boolean;
|
|
16
|
+
status: number;
|
|
17
|
+
functionKey: string;
|
|
18
|
+
result?: unknown;
|
|
19
|
+
error?: string;
|
|
20
|
+
};
|
|
21
|
+
type ExecuteBridgeFunctionArgs = {
|
|
22
|
+
config: ResolvedBridgeRuntimeConfig;
|
|
23
|
+
functionKey: string;
|
|
24
|
+
args: Record<string, unknown>;
|
|
25
|
+
userToken?: string | null;
|
|
26
|
+
auditHeaders?: Record<string, string | undefined>;
|
|
27
|
+
fetchImpl?: typeof fetch;
|
|
28
|
+
retry?: {
|
|
29
|
+
maxAttempts?: number;
|
|
30
|
+
baseDelayMs?: number;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
type MaybeExecuteBridgeToolCallArgs = {
|
|
34
|
+
toolName: string;
|
|
35
|
+
toolArgs: Record<string, unknown>;
|
|
36
|
+
hydratedConfig: HydratedBridgeRuntimeConfig | null;
|
|
37
|
+
userToken?: string | null;
|
|
38
|
+
fetchImpl?: typeof fetch;
|
|
39
|
+
retry?: {
|
|
40
|
+
maxAttempts?: number;
|
|
41
|
+
baseDelayMs?: number;
|
|
42
|
+
};
|
|
43
|
+
env?: Record<string, string | undefined>;
|
|
44
|
+
};
|
|
45
|
+
type MaybeExecuteBridgeToolCallResult = {
|
|
46
|
+
handled: false;
|
|
47
|
+
} | {
|
|
48
|
+
handled: true;
|
|
49
|
+
functionKey: string;
|
|
50
|
+
response: BridgeExecutionResult;
|
|
51
|
+
};
|
|
52
|
+
export declare function resolveBridgeRuntimeConfig(hydratedConfig: HydratedBridgeRuntimeConfig | null | undefined, env?: Record<string, string | undefined>): {
|
|
53
|
+
ok: true;
|
|
54
|
+
config: ResolvedBridgeRuntimeConfig;
|
|
55
|
+
} | {
|
|
56
|
+
ok: false;
|
|
57
|
+
error: string;
|
|
58
|
+
};
|
|
59
|
+
export declare function isBridgeToolName(toolName: string): boolean;
|
|
60
|
+
export declare function bridgeFunctionKeyFromToolName(toolName: string): string | null;
|
|
61
|
+
export declare function executeBridgeFunction(input: ExecuteBridgeFunctionArgs): Promise<BridgeExecutionResult>;
|
|
62
|
+
export declare function maybeExecuteBridgeToolCall(input: MaybeExecuteBridgeToolCallArgs): Promise<MaybeExecuteBridgeToolCallResult>;
|
|
63
|
+
export {};
|
|
64
|
+
//# sourceMappingURL=bridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../../src/client/bridge.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,2BAA2B,GAAG;IACxC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,mBAAmB,EAAE,MAAM,GAAG,IAAI,CAAC;CACpC,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG;IACxC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,KAAK,yBAAyB,GAAG;IAC/B,MAAM,EAAE,2BAA2B,CAAC;IACpC,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,GAAG,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ED,wBAAgB,6BAA6B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAK7E;AAED,wBAAsB,qBAAqB,CACzC,KAAK,EAAE,yBAAyB,GAC/B,OAAO,CAAC,qBAAqB,CAAC,CA2ChC;AAED,wBAAsB,0BAA0B,CAC9C,KAAK,EAAE,8BAA8B,GACpC,OAAO,CAAC,gCAAgC,CAAC,CAiC3C"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
const BRIDGE_ENV_KEYS = {
|
|
2
|
+
baseUrl: ["OPENCLAW_AGENT_BRIDGE_BASE_URL", "AGENT_BRIDGE_BASE_URL"],
|
|
3
|
+
serviceId: ["OPENCLAW_SERVICE_ID", "AGENT_BRIDGE_SERVICE_ID"],
|
|
4
|
+
serviceKey: ["OPENCLAW_SERVICE_KEY", "AGENT_BRIDGE_SERVICE_KEY"],
|
|
5
|
+
appKey: ["OPENCLAW_AGENT_APP", "OPENCLAW_APP_KEY", "AGENT_BRIDGE_APP_KEY"],
|
|
6
|
+
};
|
|
7
|
+
export function resolveBridgeRuntimeConfig(hydratedConfig, env = process.env) {
|
|
8
|
+
const baseUrl = pickValue(hydratedConfig?.baseUrl, readEnv(env, BRIDGE_ENV_KEYS.baseUrl));
|
|
9
|
+
const serviceId = pickValue(hydratedConfig?.serviceId, readEnv(env, BRIDGE_ENV_KEYS.serviceId));
|
|
10
|
+
const serviceKey = pickValue(hydratedConfig?.serviceKey, readEnv(env, BRIDGE_ENV_KEYS.serviceKey));
|
|
11
|
+
const appKey = pickValue(hydratedConfig?.appKey, readEnv(env, BRIDGE_ENV_KEYS.appKey));
|
|
12
|
+
const missing = [];
|
|
13
|
+
if (!baseUrl)
|
|
14
|
+
missing.push("baseUrl");
|
|
15
|
+
if (!serviceId)
|
|
16
|
+
missing.push("serviceId");
|
|
17
|
+
if (!serviceKey)
|
|
18
|
+
missing.push("serviceKey");
|
|
19
|
+
if (!appKey)
|
|
20
|
+
missing.push("appKey");
|
|
21
|
+
if (missing.length > 0) {
|
|
22
|
+
return {
|
|
23
|
+
ok: false,
|
|
24
|
+
error: `Agent Bridge config incompleta: ${missing.join(", ")}`,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
const resolvedBaseUrl = baseUrl;
|
|
28
|
+
const resolvedServiceId = serviceId;
|
|
29
|
+
const resolvedServiceKey = serviceKey;
|
|
30
|
+
const resolvedAppKey = appKey;
|
|
31
|
+
return {
|
|
32
|
+
ok: true,
|
|
33
|
+
config: {
|
|
34
|
+
baseUrl: normalizeBaseUrl(resolvedBaseUrl),
|
|
35
|
+
serviceId: resolvedServiceId,
|
|
36
|
+
serviceKey: resolvedServiceKey,
|
|
37
|
+
appKey: resolvedAppKey,
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export function isBridgeToolName(toolName) {
|
|
42
|
+
return /^bridge\.[A-Za-z0-9._-]+$/.test(toolName);
|
|
43
|
+
}
|
|
44
|
+
export function bridgeFunctionKeyFromToolName(toolName) {
|
|
45
|
+
if (!isBridgeToolName(toolName)) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
return toolName.slice("bridge.".length);
|
|
49
|
+
}
|
|
50
|
+
export async function executeBridgeFunction(input) {
|
|
51
|
+
const fetchImpl = input.fetchImpl ?? fetch;
|
|
52
|
+
const maxAttempts = Math.max(1, input.retry?.maxAttempts ?? 3);
|
|
53
|
+
const baseDelayMs = Math.max(50, input.retry?.baseDelayMs ?? 250);
|
|
54
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt += 1) {
|
|
55
|
+
const response = await fetchImpl(`${input.config.baseUrl}/agent/execute`, {
|
|
56
|
+
method: "POST",
|
|
57
|
+
headers: {
|
|
58
|
+
"Content-Type": "application/json",
|
|
59
|
+
"X-Agent-Service-Id": input.config.serviceId,
|
|
60
|
+
"X-Agent-Service-Key": input.config.serviceKey,
|
|
61
|
+
"X-Agent-App": input.config.appKey,
|
|
62
|
+
...(input.userToken ? { Authorization: `Bearer ${input.userToken}` } : {}),
|
|
63
|
+
...sanitizeHeaderValues(input.auditHeaders),
|
|
64
|
+
},
|
|
65
|
+
body: JSON.stringify({
|
|
66
|
+
functionKey: input.functionKey,
|
|
67
|
+
args: input.args,
|
|
68
|
+
}),
|
|
69
|
+
});
|
|
70
|
+
const body = await safeParseJson(response);
|
|
71
|
+
const executionResult = {
|
|
72
|
+
success: response.ok && body?.success === true,
|
|
73
|
+
status: response.status,
|
|
74
|
+
functionKey: input.functionKey,
|
|
75
|
+
result: body?.result,
|
|
76
|
+
error: body?.error ?? (response.ok ? undefined : `HTTP ${response.status}`),
|
|
77
|
+
};
|
|
78
|
+
if (!shouldRetry(response.status) || attempt >= maxAttempts) {
|
|
79
|
+
return executionResult;
|
|
80
|
+
}
|
|
81
|
+
const backoff = baseDelayMs * 2 ** (attempt - 1);
|
|
82
|
+
await sleep(backoff);
|
|
83
|
+
}
|
|
84
|
+
return {
|
|
85
|
+
success: false,
|
|
86
|
+
status: 500,
|
|
87
|
+
functionKey: input.functionKey,
|
|
88
|
+
error: "Bridge execution failed without response",
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
export async function maybeExecuteBridgeToolCall(input) {
|
|
92
|
+
const functionKey = bridgeFunctionKeyFromToolName(input.toolName);
|
|
93
|
+
if (!functionKey) {
|
|
94
|
+
return { handled: false };
|
|
95
|
+
}
|
|
96
|
+
const resolved = resolveBridgeRuntimeConfig(input.hydratedConfig, input.env);
|
|
97
|
+
if (!resolved.ok) {
|
|
98
|
+
return {
|
|
99
|
+
handled: true,
|
|
100
|
+
functionKey,
|
|
101
|
+
response: {
|
|
102
|
+
success: false,
|
|
103
|
+
status: 400,
|
|
104
|
+
functionKey,
|
|
105
|
+
error: resolved.error,
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
const response = await executeBridgeFunction({
|
|
110
|
+
config: resolved.config,
|
|
111
|
+
functionKey,
|
|
112
|
+
args: input.toolArgs,
|
|
113
|
+
userToken: input.userToken,
|
|
114
|
+
fetchImpl: input.fetchImpl,
|
|
115
|
+
retry: input.retry,
|
|
116
|
+
});
|
|
117
|
+
return {
|
|
118
|
+
handled: true,
|
|
119
|
+
functionKey,
|
|
120
|
+
response,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
function readEnv(env, keys) {
|
|
124
|
+
for (const key of keys) {
|
|
125
|
+
const value = env[key];
|
|
126
|
+
if (value && value.trim().length > 0) {
|
|
127
|
+
return value.trim();
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
function pickValue(primary, fallback) {
|
|
133
|
+
if (primary && primary.trim().length > 0) {
|
|
134
|
+
return primary.trim();
|
|
135
|
+
}
|
|
136
|
+
return fallback;
|
|
137
|
+
}
|
|
138
|
+
function normalizeBaseUrl(baseUrl) {
|
|
139
|
+
return baseUrl.endsWith("/") ? baseUrl.slice(0, -1) : baseUrl;
|
|
140
|
+
}
|
|
141
|
+
function shouldRetry(status) {
|
|
142
|
+
return status === 429 || status >= 500;
|
|
143
|
+
}
|
|
144
|
+
function sleep(ms) {
|
|
145
|
+
return new Promise((resolve) => {
|
|
146
|
+
setTimeout(resolve, ms);
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
async function safeParseJson(response) {
|
|
150
|
+
const contentType = response.headers.get("content-type");
|
|
151
|
+
if (!contentType?.toLowerCase().includes("application/json")) {
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
try {
|
|
155
|
+
return (await response.json());
|
|
156
|
+
}
|
|
157
|
+
catch {
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
function sanitizeHeaderValues(headers) {
|
|
162
|
+
if (!headers) {
|
|
163
|
+
return {};
|
|
164
|
+
}
|
|
165
|
+
const output = {};
|
|
166
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
167
|
+
if (!value || value.trim().length === 0) {
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
output[key] = value;
|
|
171
|
+
}
|
|
172
|
+
return output;
|
|
173
|
+
}
|
|
174
|
+
//# sourceMappingURL=bridge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge.js","sourceRoot":"","sources":["../../src/client/bridge.ts"],"names":[],"mappings":"AA2DA,MAAM,eAAe,GAAG;IACtB,OAAO,EAAE,CAAC,gCAAgC,EAAE,uBAAuB,CAAC;IACpE,SAAS,EAAE,CAAC,qBAAqB,EAAE,yBAAyB,CAAC;IAC7D,UAAU,EAAE,CAAC,sBAAsB,EAAE,0BAA0B,CAAC;IAChE,MAAM,EAAE,CAAC,oBAAoB,EAAE,kBAAkB,EAAE,sBAAsB,CAAC;CAClE,CAAC;AAEX,MAAM,UAAU,0BAA0B,CACxC,cAA8D,EAC9D,MAA0C,OAAO,CAAC,GAAyC;IAU3F,MAAM,OAAO,GAAG,SAAS,CAAC,cAAc,EAAE,OAAO,EAAE,OAAO,CAAC,GAAG,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC;IAC1F,MAAM,SAAS,GAAG,SAAS,CAAC,cAAc,EAAE,SAAS,EAAE,OAAO,CAAC,GAAG,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC,CAAC;IAChG,MAAM,UAAU,GAAG,SAAS,CAC1B,cAAc,EAAE,UAAU,EAC1B,OAAO,CAAC,GAAG,EAAE,eAAe,CAAC,UAAU,CAAC,CACzC,CAAC;IACF,MAAM,MAAM,GAAG,SAAS,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,CAAC,GAAG,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC;IAEvF,MAAM,OAAO,GAAkB,EAAE,CAAC;IAClC,IAAI,CAAC,OAAO;QAAE,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACtC,IAAI,CAAC,SAAS;QAAE,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IA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AC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IACzD,IAAI,CAAC,WAAW,EAAE,WAAW,EAAE,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC;QAC7D,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,CAAC;QACH,OAAO,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAwB,CAAC;IACxD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,SAAS,oBAAoB,CAC3B,OAAuD;IAEvD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,MAAM,MAAM,GAA2B,EAAE,CAAC;IAC1C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACnD,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxC,SAAS;QACX,CAAC;QACD,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACtB,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Auth, HttpRouter } from "convex/server";
|
|
2
2
|
import type { ComponentApi } from "../component/_generated/component.js";
|
|
3
|
+
export { bridgeFunctionKeyFromToolName, executeBridgeFunction, isBridgeToolName, maybeExecuteBridgeToolCall, resolveBridgeRuntimeConfig, type BridgeExecutionResult, type HydratedBridgeRuntimeConfig, type ResolvedBridgeRuntimeConfig, } from "./bridge.js";
|
|
3
4
|
export declare function exposeApi(component: ComponentApi, options: {
|
|
4
5
|
auth: (ctx: {
|
|
5
6
|
auth: Auth;
|
|
@@ -17,12 +18,12 @@ export declare function exposeApi(component: ComponentApi, options: {
|
|
|
17
18
|
queuedReady: number;
|
|
18
19
|
}>>;
|
|
19
20
|
enqueue: import("convex/server").RegisteredMutation<"public", {
|
|
20
|
-
metadata?: Record<string, string> | undefined;
|
|
21
|
-
priority?: number | undefined;
|
|
22
21
|
externalMessageId?: string | undefined;
|
|
23
22
|
rawUpdateJson?: string | undefined;
|
|
24
|
-
|
|
23
|
+
metadata?: Record<string, string> | undefined;
|
|
24
|
+
priority?: number | undefined;
|
|
25
25
|
conversationId: string;
|
|
26
|
+
agentKey: string;
|
|
26
27
|
provider: string;
|
|
27
28
|
providerUserId: string;
|
|
28
29
|
messageText: string;
|
|
@@ -58,18 +59,18 @@ export declare function exposeApi(component: ComponentApi, options: {
|
|
|
58
59
|
};
|
|
59
60
|
} | null>>;
|
|
60
61
|
workerHeartbeat: import("convex/server").RegisteredMutation<"public", {
|
|
61
|
-
messageId: string;
|
|
62
62
|
workerId: string;
|
|
63
|
+
messageId: string;
|
|
63
64
|
leaseId: string;
|
|
64
65
|
}, Promise<boolean>>;
|
|
65
66
|
workerComplete: import("convex/server").RegisteredMutation<"public", {
|
|
66
|
-
messageId: string;
|
|
67
67
|
workerId: string;
|
|
68
|
+
messageId: string;
|
|
68
69
|
leaseId: string;
|
|
69
70
|
}, Promise<boolean>>;
|
|
70
71
|
workerFail: import("convex/server").RegisteredMutation<"public", {
|
|
71
|
-
messageId: string;
|
|
72
72
|
workerId: string;
|
|
73
|
+
messageId: string;
|
|
73
74
|
leaseId: string;
|
|
74
75
|
errorMessage: string;
|
|
75
76
|
}, Promise<{
|
|
@@ -78,10 +79,17 @@ export declare function exposeApi(component: ComponentApi, options: {
|
|
|
78
79
|
requeued: boolean;
|
|
79
80
|
}>>;
|
|
80
81
|
workerHydrationBundle: import("convex/server").RegisteredQuery<"public", {
|
|
81
|
-
workspaceId: string;
|
|
82
82
|
messageId: string;
|
|
83
|
+
workspaceId: string;
|
|
83
84
|
}, Promise<{
|
|
84
85
|
agentKey: string;
|
|
86
|
+
bridgeRuntimeConfig: null | {
|
|
87
|
+
appKey: null | string;
|
|
88
|
+
baseUrl: null | string;
|
|
89
|
+
serviceId: null | string;
|
|
90
|
+
serviceKey: null | string;
|
|
91
|
+
serviceKeySecretRef: null | string;
|
|
92
|
+
};
|
|
85
93
|
conversationId: string;
|
|
86
94
|
conversationState: {
|
|
87
95
|
contextHistory: Array<{
|
|
@@ -104,28 +112,6 @@ export declare function exposeApi(component: ComponentApi, options: {
|
|
|
104
112
|
providerUserId: string;
|
|
105
113
|
rawUpdateJson?: string;
|
|
106
114
|
};
|
|
107
|
-
snapshot: null | {
|
|
108
|
-
compiledPromptStack: Array<{
|
|
109
|
-
content: string;
|
|
110
|
-
section: string;
|
|
111
|
-
}>;
|
|
112
|
-
memoryWindow: Array<{
|
|
113
|
-
excerpt: string;
|
|
114
|
-
path: string;
|
|
115
|
-
}>;
|
|
116
|
-
skillsBundle: Array<{
|
|
117
|
-
assets?: Array<{
|
|
118
|
-
assetPath: string;
|
|
119
|
-
assetType: "script" | "config" | "venv" | "other";
|
|
120
|
-
contentHash: string;
|
|
121
|
-
sizeBytes: number;
|
|
122
|
-
}>;
|
|
123
|
-
manifestMd: string;
|
|
124
|
-
skillKey: string;
|
|
125
|
-
}>;
|
|
126
|
-
snapshotId: string;
|
|
127
|
-
snapshotKey: string;
|
|
128
|
-
};
|
|
129
115
|
telegramBotToken: null | string;
|
|
130
116
|
} | null>>;
|
|
131
117
|
workerConversationHasQueued: import("convex/server").RegisteredQuery<"public", {
|
|
@@ -149,21 +135,21 @@ export declare function exposeApi(component: ComponentApi, options: {
|
|
|
149
135
|
workerPrepareSnapshotUpload: import("convex/server").RegisteredMutation<"public", {
|
|
150
136
|
conversationId?: string | undefined;
|
|
151
137
|
agentKey: string;
|
|
152
|
-
workspaceId: string;
|
|
153
138
|
workerId: string;
|
|
154
|
-
|
|
139
|
+
workspaceId: string;
|
|
140
|
+
reason: "drain" | "signal" | "manual";
|
|
155
141
|
}, Promise<any>>;
|
|
156
142
|
workerFinalizeSnapshotUpload: import("convex/server").RegisteredMutation<"public", {
|
|
157
143
|
workerId: string;
|
|
158
|
-
storageId: string;
|
|
159
144
|
snapshotId: string;
|
|
145
|
+
storageId: string;
|
|
160
146
|
sha256: string;
|
|
161
147
|
sizeBytes: number;
|
|
162
148
|
}, Promise<any>>;
|
|
163
149
|
workerFailSnapshotUpload: import("convex/server").RegisteredMutation<"public", {
|
|
164
150
|
workerId: string;
|
|
165
|
-
error: string;
|
|
166
151
|
snapshotId: string;
|
|
152
|
+
error: string;
|
|
167
153
|
}, Promise<any>>;
|
|
168
154
|
workerLatestSnapshotForRestore: import("convex/server").RegisteredQuery<"public", {
|
|
169
155
|
conversationId?: string | undefined;
|
|
@@ -181,8 +167,8 @@ export declare function exposeApi(component: ComponentApi, options: {
|
|
|
181
167
|
seedDefaultAgent: import("convex/server").RegisteredMutation<"public", {}, Promise<string>>;
|
|
182
168
|
importSecret: import("convex/server").RegisteredMutation<"public", {
|
|
183
169
|
metadata?: Record<string, string> | undefined;
|
|
184
|
-
plaintextValue: string;
|
|
185
170
|
secretRef: string;
|
|
171
|
+
plaintextValue: string;
|
|
186
172
|
}, Promise<{
|
|
187
173
|
secretId: string;
|
|
188
174
|
secretRef: string;
|
|
@@ -197,10 +183,9 @@ export declare function exposeApi(component: ComponentApi, options: {
|
|
|
197
183
|
}[]>>;
|
|
198
184
|
startWorkers: import("convex/server").RegisteredAction<"public", {
|
|
199
185
|
workspaceId?: string | undefined;
|
|
200
|
-
convexUrl?: string | undefined;
|
|
201
186
|
flyApiToken?: string | undefined;
|
|
187
|
+
convexUrl?: string | undefined;
|
|
202
188
|
scalingPolicy?: {
|
|
203
|
-
minWorkers: number;
|
|
204
189
|
maxWorkers: number;
|
|
205
190
|
queuePerWorkerTarget: number;
|
|
206
191
|
spawnStep: number;
|
|
@@ -209,15 +194,44 @@ export declare function exposeApi(component: ComponentApi, options: {
|
|
|
209
194
|
} | undefined;
|
|
210
195
|
}, Promise<{
|
|
211
196
|
activeWorkers: number;
|
|
212
|
-
desiredWorkers: number;
|
|
213
197
|
spawned: number;
|
|
214
198
|
terminated: number;
|
|
215
199
|
}>>;
|
|
200
|
+
checkIdleShutdowns: import("convex/server").RegisteredAction<"public", {
|
|
201
|
+
flyApiToken?: string | undefined;
|
|
202
|
+
}, Promise<any>>;
|
|
203
|
+
deleteFlyVolume: import("convex/server").RegisteredAction<"public", {
|
|
204
|
+
flyApiToken?: string | undefined;
|
|
205
|
+
appName: string;
|
|
206
|
+
volumeId: string;
|
|
207
|
+
}, Promise<any>>;
|
|
208
|
+
recoverQueue: import("convex/server").RegisteredAction<"public", {
|
|
209
|
+
nowMs?: number | undefined;
|
|
210
|
+
workspaceId?: string | undefined;
|
|
211
|
+
scalingPolicy?: {
|
|
212
|
+
maxWorkers: number;
|
|
213
|
+
queuePerWorkerTarget: number;
|
|
214
|
+
spawnStep: number;
|
|
215
|
+
idleTimeoutMs: number;
|
|
216
|
+
reconcileIntervalMs: number;
|
|
217
|
+
} | undefined;
|
|
218
|
+
releaseLimit?: number | undefined;
|
|
219
|
+
}, Promise<{
|
|
220
|
+
released: {
|
|
221
|
+
requeued: number;
|
|
222
|
+
unlocked: number;
|
|
223
|
+
};
|
|
224
|
+
reconcile: {
|
|
225
|
+
activeWorkers: number;
|
|
226
|
+
spawned: number;
|
|
227
|
+
terminated: number;
|
|
228
|
+
};
|
|
229
|
+
}>>;
|
|
216
230
|
bindUserAgent: import("convex/server").RegisteredMutation<"public", {
|
|
217
231
|
metadata?: Record<string, string> | undefined;
|
|
218
232
|
source?: "manual" | "telegram_pairing" | "api" | undefined;
|
|
219
|
-
telegramChatId?: string | undefined;
|
|
220
233
|
telegramUserId?: string | undefined;
|
|
234
|
+
telegramChatId?: string | undefined;
|
|
221
235
|
agentKey: string;
|
|
222
236
|
consumerUserId: string;
|
|
223
237
|
}, Promise<{
|
|
@@ -256,8 +270,8 @@ export declare function exposeApi(component: ComponentApi, options: {
|
|
|
256
270
|
telegramUserId: null | string;
|
|
257
271
|
} | null>>;
|
|
258
272
|
resolveAgentForTelegram: import("convex/server").RegisteredQuery<"public", {
|
|
259
|
-
telegramChatId?: string | undefined;
|
|
260
273
|
telegramUserId?: string | undefined;
|
|
274
|
+
telegramChatId?: string | undefined;
|
|
261
275
|
}, Promise<{
|
|
262
276
|
agentKey: null | string;
|
|
263
277
|
consumerUserId: null | string;
|
|
@@ -278,8 +292,8 @@ export declare function exposeApi(component: ComponentApi, options: {
|
|
|
278
292
|
usedAt: null | number;
|
|
279
293
|
}>>;
|
|
280
294
|
consumePairingCode: import("convex/server").RegisteredMutation<"public", {
|
|
281
|
-
telegramChatId: string;
|
|
282
295
|
telegramUserId: string;
|
|
296
|
+
telegramChatId: string;
|
|
283
297
|
code: string;
|
|
284
298
|
}, Promise<{
|
|
285
299
|
agentKey: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AAEzE,OAAO,EACL,6BAA6B,EAC7B,qBAAqB,EACrB,gBAAgB,EAChB,0BAA0B,EAC1B,0BAA0B,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,2BAA2B,EAChC,KAAK,2BAA2B,GACjC,MAAM,aAAa,CAAC;AAErB,wBAAgB,SAAS,CACvB,SAAS,EAAE,YAAY,EACvB,OAAO,EAAE;IACP,IAAI,EAAE,CACJ,GAAG,EAAE;QAAE,IAAI,EAAE,IAAI,CAAA;KAAE,EACnB,SAA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