@okrlinkhub/agent-bridge 0.1.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.
Files changed (70) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +183 -0
  3. package/dist/client/_generated/_ignore.d.ts +1 -0
  4. package/dist/client/_generated/_ignore.d.ts.map +1 -0
  5. package/dist/client/_generated/_ignore.js +3 -0
  6. package/dist/client/_generated/_ignore.js.map +1 -0
  7. package/dist/client/index.d.ts +184 -0
  8. package/dist/client/index.d.ts.map +1 -0
  9. package/dist/client/index.js +312 -0
  10. package/dist/client/index.js.map +1 -0
  11. package/dist/component/_generated/api.d.ts +40 -0
  12. package/dist/component/_generated/api.d.ts.map +1 -0
  13. package/dist/component/_generated/api.js +31 -0
  14. package/dist/component/_generated/api.js.map +1 -0
  15. package/dist/component/_generated/component.d.ts +224 -0
  16. package/dist/component/_generated/component.d.ts.map +1 -0
  17. package/dist/component/_generated/component.js +11 -0
  18. package/dist/component/_generated/component.js.map +1 -0
  19. package/dist/component/_generated/dataModel.d.ts +46 -0
  20. package/dist/component/_generated/dataModel.d.ts.map +1 -0
  21. package/dist/component/_generated/dataModel.js +11 -0
  22. package/dist/component/_generated/dataModel.js.map +1 -0
  23. package/dist/component/_generated/server.d.ts +121 -0
  24. package/dist/component/_generated/server.d.ts.map +1 -0
  25. package/dist/component/_generated/server.js +78 -0
  26. package/dist/component/_generated/server.js.map +1 -0
  27. package/dist/component/convex.config.d.ts +3 -0
  28. package/dist/component/convex.config.d.ts.map +1 -0
  29. package/dist/component/convex.config.js +3 -0
  30. package/dist/component/convex.config.js.map +1 -0
  31. package/dist/component/gateway.d.ts +87 -0
  32. package/dist/component/gateway.d.ts.map +1 -0
  33. package/dist/component/gateway.js +231 -0
  34. package/dist/component/gateway.js.map +1 -0
  35. package/dist/component/permissions.d.ts +93 -0
  36. package/dist/component/permissions.d.ts.map +1 -0
  37. package/dist/component/permissions.js +241 -0
  38. package/dist/component/permissions.js.map +1 -0
  39. package/dist/component/provisioning.d.ts +87 -0
  40. package/dist/component/provisioning.d.ts.map +1 -0
  41. package/dist/component/provisioning.js +343 -0
  42. package/dist/component/provisioning.js.map +1 -0
  43. package/dist/component/registry.d.ts +46 -0
  44. package/dist/component/registry.d.ts.map +1 -0
  45. package/dist/component/registry.js +121 -0
  46. package/dist/component/registry.js.map +1 -0
  47. package/dist/component/schema.d.ts +176 -0
  48. package/dist/component/schema.d.ts.map +1 -0
  49. package/dist/component/schema.js +92 -0
  50. package/dist/component/schema.js.map +1 -0
  51. package/dist/react/index.d.ts +3 -0
  52. package/dist/react/index.d.ts.map +1 -0
  53. package/dist/react/index.js +5 -0
  54. package/dist/react/index.js.map +1 -0
  55. package/package.json +103 -0
  56. package/src/client/_generated/_ignore.ts +1 -0
  57. package/src/client/index.ts +481 -0
  58. package/src/client/setup.test.ts +26 -0
  59. package/src/component/_generated/api.ts +56 -0
  60. package/src/component/_generated/component.ts +281 -0
  61. package/src/component/_generated/dataModel.ts +60 -0
  62. package/src/component/_generated/server.ts +156 -0
  63. package/src/component/convex.config.ts +3 -0
  64. package/src/component/gateway.ts +282 -0
  65. package/src/component/permissions.ts +321 -0
  66. package/src/component/provisioning.ts +402 -0
  67. package/src/component/registry.ts +152 -0
  68. package/src/component/schema.ts +116 -0
  69. package/src/react/index.ts +11 -0
  70. package/src/test.ts +18 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,183 @@
1
+ # Convex Agent Bridge
2
+
3
+ [![npm version](https://badge.fury.io/js/@okrlinkhub%2Fagent-bridge.svg)](https://badge.fury.io/js/@okrlinkhub%2Fagent-bridge)
4
+
5
+ A Convex component that acts as a **Security Gateway** between external AI agents
6
+ (e.g. OpenClaw on Railway) and your Convex app's functions. It provides:
7
+
8
+ - **Function Handle Registry**: Register which of your app's functions agents can call
9
+ - **Dynamic Permissions**: Pattern-based access control (e.g. `"okr:read*"` -> allow)
10
+ - **Distributed Provisioning**: Token-based agent registration with self-service onboarding
11
+ - **Audit Logging**: Full access log of all agent interactions
12
+ - **HTTP Gateway**: Single endpoint for agents to call registered functions securely
13
+
14
+ Found a bug? Feature request?
15
+ [File it here](https://github.com/okrlinkhub/agent-bridge/issues).
16
+
17
+ ## Installation
18
+
19
+ ```sh
20
+ npm install @okrlinkhub/agent-bridge
21
+ ```
22
+
23
+ Add the component to your `convex/convex.config.ts`:
24
+
25
+ ```ts
26
+ // convex/convex.config.ts
27
+ import { defineApp } from "convex/server";
28
+ import agentBridge from "@okrlinkhub/agent-bridge/convex.config.js";
29
+
30
+ const app = defineApp();
31
+ app.use(agentBridge);
32
+
33
+ export default app;
34
+ ```
35
+
36
+ ## Quick Start
37
+
38
+ ### 1. Initialize the client
39
+
40
+ ```ts
41
+ // convex/agentBridge.ts
42
+ import { AgentBridge } from "@okrlinkhub/agent-bridge";
43
+ import { components } from "./_generated/api";
44
+
45
+ export const bridge = new AgentBridge(components.agentBridge, {
46
+ appName: "my-app",
47
+ defaultPermissions: [
48
+ { pattern: "myapp:read*", permission: "allow" },
49
+ { pattern: "myapp:write*", permission: "rate_limited", rateLimitConfig: { requestsPerHour: 50, tokenBudget: 50000 } },
50
+ { pattern: "*", permission: "deny" },
51
+ ],
52
+ });
53
+ ```
54
+
55
+ ### 2. Register functions that agents can call
56
+
57
+ ```ts
58
+ import { mutation } from "./_generated/server";
59
+ import { createFunctionHandle } from "convex/server";
60
+ import { api } from "./_generated/api";
61
+ import { bridge } from "./agentBridge";
62
+
63
+ export const setup = mutation({
64
+ args: {},
65
+ returns: v.null(),
66
+ handler: async (ctx) => {
67
+ await bridge.configure(ctx);
68
+
69
+ const handle = await createFunctionHandle(api.myFunctions.getItems);
70
+ await bridge.registerFunction(ctx, {
71
+ name: "myapp:getItems",
72
+ handle,
73
+ type: "query",
74
+ description: "List all items",
75
+ });
76
+
77
+ return null;
78
+ },
79
+ });
80
+ ```
81
+
82
+ ### 3. Mount HTTP routes
83
+
84
+ ```ts
85
+ // convex/http.ts
86
+ import { httpRouter } from "convex/server";
87
+ import { registerRoutes } from "@okrlinkhub/agent-bridge";
88
+ import { components } from "./_generated/api";
89
+
90
+ const http = httpRouter();
91
+
92
+ // Exposes:
93
+ // POST /agent-bridge/execute -- Gateway for agent function calls
94
+ // POST /agent-bridge/provision -- Agent self-provisioning
95
+ // GET /agent-bridge/health -- Health check
96
+ registerRoutes(http, components.agentBridge, {
97
+ appName: "my-app",
98
+ });
99
+
100
+ export default http;
101
+ ```
102
+
103
+ ### 4. Generate a provisioning token (admin)
104
+
105
+ ```ts
106
+ export const generateToken = mutation({
107
+ args: { email: v.string(), department: v.string() },
108
+ handler: async (ctx, args) => {
109
+ // Authenticate admin here
110
+ return await bridge.generateProvisioningToken(ctx, {
111
+ employeeEmail: args.email,
112
+ department: args.department,
113
+ createdBy: "admin@company.com",
114
+ });
115
+ },
116
+ });
117
+ ```
118
+
119
+ ## How It Works
120
+
121
+ ### Agent Provisioning Flow
122
+
123
+ 1. **IT Admin** generates a Provisioning Token (APT) via the `generateProvisioningToken` method
124
+ 2. **Employee** uses the APT to self-register on an app by calling `POST /agent-bridge/provision`
125
+ 3. The component creates an agent record and returns an `instanceToken` (valid 24h)
126
+ 4. The agent uses the `instanceToken` for all subsequent function calls
127
+
128
+ ### Function Execution Flow
129
+
130
+ 1. Agent sends `POST /agent-bridge/execute` with `{ instanceToken, functionName, args }`
131
+ 2. The gateway validates the token, checks permissions via pattern matching
132
+ 3. If authorized, executes the registered function handle and returns the result
133
+ 4. All access attempts are logged to the audit table
134
+
135
+ ### Permission Pattern Matching
136
+
137
+ Permissions use glob-style patterns with `*` wildcards:
138
+
139
+ | Pattern | Matches |
140
+ |---------|---------|
141
+ | `*` | Everything (catch-all) |
142
+ | `okr:*` | All OKR functions |
143
+ | `okr:read*` | `okr:readObjectives`, `okr:readKeyResults`, etc. |
144
+ | `okr:createObjective` | Only this specific function |
145
+
146
+ More specific patterns take priority over wildcards. Default behavior when no pattern matches: **deny**.
147
+
148
+ ## API Reference
149
+
150
+ ### `AgentBridge` class
151
+
152
+ | Method | Description |
153
+ |--------|-------------|
154
+ | `configure(ctx)` | Initialize component configuration |
155
+ | `registerFunction(ctx, fn)` | Register a callable function |
156
+ | `registerFunctions(ctx, fns)` | Bulk register functions |
157
+ | `unregisterFunction(ctx, name)` | Remove a function |
158
+ | `listFunctions(ctx)` | List registered functions |
159
+ | `generateProvisioningToken(ctx, opts)` | Create an APT (admin) |
160
+ | `listAgents(ctx)` | List registered agents |
161
+ | `revokeAgent(ctx, opts)` | Revoke an agent globally |
162
+ | `revokeAppInstance(ctx, opts)` | Revoke a specific app instance |
163
+ | `setPermission(ctx, opts)` | Set/update a permission |
164
+ | `removePermission(ctx, opts)` | Remove a permission |
165
+ | `listPermissions(ctx, agentId)` | List agent permissions |
166
+ | `queryAccessLog(ctx, opts)` | Query audit logs |
167
+
168
+ ### `registerRoutes(http, component, config)`
169
+
170
+ Registers HTTP endpoints on the host app's router:
171
+
172
+ - `POST /agent-bridge/execute` -- Execute a registered function
173
+ - `POST /agent-bridge/provision` -- Agent self-provisioning
174
+ - `GET /agent-bridge/health` -- Health check
175
+
176
+ See [example/convex/example.ts](./example/convex/example.ts) for a complete working example.
177
+
178
+ ## Development
179
+
180
+ ```sh
181
+ npm i
182
+ npm run dev
183
+ ```
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=_ignore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_ignore.d.ts","sourceRoot":"","sources":["../../../src/client/_generated/_ignore.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // This is only here so convex-test can detect a _generated folder
3
+ //# sourceMappingURL=_ignore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_ignore.js","sourceRoot":"","sources":["../../../src/client/_generated/_ignore.ts"],"names":[],"mappings":";AAAA,kEAAkE"}
@@ -0,0 +1,184 @@
1
+ import type { GenericDataModel, GenericMutationCtx, GenericQueryCtx, HttpRouter } from "convex/server";
2
+ import type { ComponentApi } from "../component/_generated/component.js";
3
+ type QueryCtx = Pick<GenericQueryCtx<GenericDataModel>, "runQuery">;
4
+ type MutationCtx = Pick<GenericMutationCtx<GenericDataModel>, "runQuery" | "runMutation">;
5
+ export interface FunctionDef {
6
+ /** Alias name that agents use to call this function (e.g. "okr:getObjectives") */
7
+ name: string;
8
+ /** Function handle string from createFunctionHandle() */
9
+ handle: string;
10
+ /** Type of the Convex function */
11
+ type: "query" | "mutation" | "action";
12
+ /** Human-readable description */
13
+ description?: string;
14
+ }
15
+ export interface DefaultPermission {
16
+ pattern: string;
17
+ permission: "allow" | "deny" | "rate_limited";
18
+ rateLimitConfig?: {
19
+ requestsPerHour: number;
20
+ tokenBudget: number;
21
+ };
22
+ }
23
+ export interface AgentBridgeConfig {
24
+ /** Unique name identifying this app (e.g. "okr", "hr", "incentives") */
25
+ appName: string;
26
+ /** Default permissions applied to new agents during provisioning */
27
+ defaultPermissions?: DefaultPermission[];
28
+ }
29
+ /**
30
+ * Client class that wraps component calls for ergonomic use in the host app.
31
+ *
32
+ * Usage:
33
+ * ```ts
34
+ * import { AgentBridge } from "@okrlinkhub/agent-bridge";
35
+ * import { components } from "./_generated/api";
36
+ *
37
+ * const bridge = new AgentBridge(components.agentBridge, { appName: "okr" });
38
+ * ```
39
+ */
40
+ export declare class AgentBridge {
41
+ component: ComponentApi;
42
+ appName: string;
43
+ private defaultPermissions;
44
+ constructor(component: ComponentApi, config: AgentBridgeConfig);
45
+ /**
46
+ * Initialize the component configuration.
47
+ * Should be called once during app setup (e.g. in a seed/setup mutation).
48
+ */
49
+ configure(ctx: MutationCtx): Promise<void>;
50
+ /**
51
+ * Register a function that agents can call.
52
+ * The host app must create the function handle via createFunctionHandle().
53
+ */
54
+ registerFunction(ctx: MutationCtx, fn: FunctionDef): Promise<string>;
55
+ /**
56
+ * Register multiple functions in bulk.
57
+ */
58
+ registerFunctions(ctx: MutationCtx, functions: FunctionDef[]): Promise<string[]>;
59
+ /**
60
+ * Unregister a function.
61
+ */
62
+ unregisterFunction(ctx: MutationCtx, functionName: string): Promise<boolean>;
63
+ /**
64
+ * List all registered functions for this app.
65
+ */
66
+ listFunctions(ctx: QueryCtx): Promise<{
67
+ description?: string;
68
+ functionName: string;
69
+ functionType: "query" | "mutation" | "action";
70
+ registeredAt: number;
71
+ }[]>;
72
+ /**
73
+ * Generate a provisioning token (admin operation).
74
+ * Returns the plaintext token -- store/communicate securely!
75
+ */
76
+ generateProvisioningToken(ctx: MutationCtx, opts: {
77
+ employeeEmail: string;
78
+ department: string;
79
+ maxApps?: number;
80
+ expiresInDays?: number;
81
+ createdBy: string;
82
+ }): Promise<{
83
+ expiresAt: number;
84
+ token: string;
85
+ }>;
86
+ /**
87
+ * List all registered agents.
88
+ */
89
+ listAgents(ctx: QueryCtx, activeOnly?: boolean): Promise<{
90
+ agentId: string;
91
+ department: string;
92
+ employeeEmail: string;
93
+ firstRegisteredAt: number;
94
+ isActive: boolean;
95
+ lastSeenAt: number;
96
+ revokedAt?: number;
97
+ revokedBy?: string;
98
+ }[]>;
99
+ /**
100
+ * Revoke an agent globally.
101
+ */
102
+ revokeAgent(ctx: MutationCtx, opts: {
103
+ agentId: string;
104
+ revokedBy: string;
105
+ }): Promise<boolean>;
106
+ /**
107
+ * Revoke a specific app instance for an agent.
108
+ */
109
+ revokeAppInstance(ctx: MutationCtx, opts: {
110
+ agentId: string;
111
+ }): Promise<boolean>;
112
+ /**
113
+ * Set a permission for an agent.
114
+ */
115
+ setPermission(ctx: MutationCtx, opts: {
116
+ agentId: string;
117
+ functionPattern: string;
118
+ permission: "allow" | "deny" | "rate_limited";
119
+ rateLimitConfig?: {
120
+ requestsPerHour: number;
121
+ tokenBudget: number;
122
+ };
123
+ createdBy: string;
124
+ }): Promise<string>;
125
+ /**
126
+ * Remove a permission for an agent.
127
+ */
128
+ removePermission(ctx: MutationCtx, opts: {
129
+ agentId: string;
130
+ functionPattern: string;
131
+ }): Promise<boolean>;
132
+ /**
133
+ * List permissions for an agent on this app.
134
+ */
135
+ listPermissions(ctx: QueryCtx, agentId: string): Promise<{
136
+ createdAt: number;
137
+ createdBy: string;
138
+ functionPattern: string;
139
+ permission: "allow" | "deny" | "rate_limited";
140
+ rateLimitConfig?: {
141
+ requestsPerHour: number;
142
+ tokenBudget: number;
143
+ };
144
+ }[]>;
145
+ /**
146
+ * Query access logs.
147
+ */
148
+ queryAccessLog(ctx: QueryCtx, opts?: {
149
+ agentId?: string;
150
+ limit?: number;
151
+ }): Promise<{
152
+ agentId: string;
153
+ appName: string;
154
+ durationMs?: number;
155
+ errorMessage?: string;
156
+ functionCalled: string;
157
+ permission: string;
158
+ timestamp: number;
159
+ }[]>;
160
+ }
161
+ /**
162
+ * Register HTTP routes for the agent bridge component.
163
+ * This exposes endpoints that OpenClaw agents call to execute functions,
164
+ * provision themselves, and check health.
165
+ *
166
+ * Must be called in the host app's `convex/http.ts` file.
167
+ *
168
+ * @example
169
+ * ```ts
170
+ * import { httpRouter } from "convex/server";
171
+ * import { registerRoutes } from "@okrlinkhub/agent-bridge";
172
+ * import { components } from "./_generated/api";
173
+ *
174
+ * const http = httpRouter();
175
+ * registerRoutes(http, components.agentBridge, { appName: "okr" });
176
+ * export default http;
177
+ * ```
178
+ */
179
+ export declare function registerRoutes(http: HttpRouter, component: ComponentApi, config: {
180
+ appName: string;
181
+ pathPrefix?: string;
182
+ }): void;
183
+ export {};
184
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,gBAAgB,EAChB,kBAAkB,EAClB,eAAe,EAEf,UAAU,EACX,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AAGzE,KAAK,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