@okrlinkhub/agent-bridge 0.1.0 → 2.0.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 +96 -127
- package/dist/cli/init.d.ts +3 -0
- package/dist/cli/init.d.ts.map +1 -0
- package/dist/cli/init.js +100 -0
- package/dist/cli/init.js.map +1 -0
- package/dist/client/index.d.ts +50 -173
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +129 -263
- package/dist/client/index.js.map +1 -1
- package/dist/component/_generated/api.d.ts +4 -4
- package/dist/component/_generated/api.d.ts.map +1 -1
- package/dist/component/_generated/component.d.ts +66 -162
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/agentBridgeUtils.d.ts +8 -0
- package/dist/component/agentBridgeUtils.d.ts.map +1 -0
- package/dist/component/agentBridgeUtils.js +33 -0
- package/dist/component/agentBridgeUtils.js.map +1 -0
- package/dist/component/agents.d.ts +27 -0
- package/dist/component/agents.d.ts.map +1 -0
- package/dist/component/agents.js +94 -0
- package/dist/component/agents.js.map +1 -0
- package/dist/component/gateway.d.ts +30 -44
- package/dist/component/gateway.d.ts.map +1 -1
- package/dist/component/gateway.js +127 -132
- package/dist/component/gateway.js.map +1 -1
- package/dist/component/permissions.d.ts +30 -84
- package/dist/component/permissions.d.ts.map +1 -1
- package/dist/component/permissions.js +80 -203
- package/dist/component/permissions.js.map +1 -1
- package/dist/component/schema.d.ts +55 -153
- package/dist/component/schema.d.ts.map +1 -1
- package/dist/component/schema.js +30 -80
- package/dist/component/schema.js.map +1 -1
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +2 -3
- package/dist/react/index.js.map +1 -1
- package/package.json +7 -3
- package/src/cli/init.ts +116 -0
- package/src/client/index.ts +228 -389
- package/src/component/_generated/api.ts +4 -4
- package/src/component/_generated/component.ts +79 -195
- package/src/component/agentBridgeUtils.ts +52 -0
- package/src/component/agents.ts +106 -0
- package/src/component/gateway.ts +149 -163
- package/src/component/permissions.ts +89 -259
- package/src/component/schema.ts +31 -96
- package/src/react/index.ts +5 -6
- package/dist/component/provisioning.d.ts +0 -87
- package/dist/component/provisioning.d.ts.map +0 -1
- package/dist/component/provisioning.js +0 -343
- package/dist/component/provisioning.js.map +0 -1
- package/dist/component/registry.d.ts +0 -46
- package/dist/component/registry.d.ts.map +0 -1
- package/dist/component/registry.js +0 -121
- package/dist/component/registry.js.map +0 -1
- package/src/component/provisioning.ts +0 -402
- package/src/component/registry.ts +0 -152
|
@@ -1,241 +1,118 @@
|
|
|
1
1
|
import { v } from "convex/values";
|
|
2
|
-
import { mutation, query
|
|
3
|
-
|
|
4
|
-
const
|
|
2
|
+
import { mutation, query } from "./_generated/server.js";
|
|
3
|
+
import { patternMatchesAvailableFunctions } from "./agentBridgeUtils.js";
|
|
4
|
+
const permissionRuleValidator = v.object({
|
|
5
|
+
pattern: v.string(),
|
|
5
6
|
permission: v.union(v.literal("allow"), v.literal("deny"), v.literal("rate_limited")),
|
|
6
7
|
rateLimitConfig: v.optional(v.object({
|
|
7
8
|
requestsPerHour: v.number(),
|
|
8
|
-
tokenBudget: v.number(),
|
|
9
|
+
tokenBudget: v.optional(v.number()),
|
|
9
10
|
})),
|
|
10
|
-
matchedPattern: v.optional(v.string()),
|
|
11
11
|
});
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Calculate specificity score for a pattern.
|
|
15
|
-
* More specific patterns (longer fixed prefix before the first wildcard)
|
|
16
|
-
* get higher scores.
|
|
17
|
-
*/
|
|
18
|
-
function patternSpecificity(pattern) {
|
|
19
|
-
const wildcardIndex = pattern.indexOf("*");
|
|
20
|
-
if (wildcardIndex === -1)
|
|
21
|
-
return pattern.length;
|
|
22
|
-
return wildcardIndex;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Check if a function name matches a permission pattern.
|
|
26
|
-
* Supports "*" as a wildcard that matches any characters.
|
|
27
|
-
* Examples: "okr:*" matches "okr:getObjectives", "*" matches anything.
|
|
28
|
-
*/
|
|
29
|
-
function matchesPattern(functionName, pattern) {
|
|
30
|
-
if (pattern === "*")
|
|
31
|
-
return true;
|
|
32
|
-
// Escape regex special chars except *, then replace * with .*
|
|
33
|
-
const escaped = pattern.replace(/[.+?^${}()|[\]\\]/g, "\\$&");
|
|
34
|
-
const regexStr = "^" + escaped.replace(/\*/g, ".*") + "$";
|
|
35
|
-
const regex = new RegExp(regexStr);
|
|
36
|
-
return regex.test(functionName);
|
|
37
|
-
}
|
|
38
|
-
// --- Public functions ---
|
|
39
|
-
/**
|
|
40
|
-
* Set a permission for an agent on a specific app.
|
|
41
|
-
* If a permission with the same agentId + appName + functionPattern exists, it is updated.
|
|
42
|
-
*/
|
|
43
|
-
export const setPermission = mutation({
|
|
12
|
+
export const setAgentPermissions = mutation({
|
|
44
13
|
args: {
|
|
45
|
-
agentId: v.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
permission: v.union(v.literal("allow"), v.literal("deny"), v.literal("rate_limited")),
|
|
49
|
-
rateLimitConfig: v.optional(v.object({
|
|
50
|
-
requestsPerHour: v.number(),
|
|
51
|
-
tokenBudget: v.number(),
|
|
52
|
-
})),
|
|
53
|
-
createdBy: v.string(),
|
|
14
|
+
agentId: v.id("agents"),
|
|
15
|
+
rules: v.array(permissionRuleValidator),
|
|
16
|
+
availableFunctionKeys: v.array(v.string()),
|
|
54
17
|
},
|
|
55
|
-
returns: v.
|
|
18
|
+
returns: v.number(),
|
|
56
19
|
handler: async (ctx, args) => {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const match = existing.find((p) => p.functionPattern === args.functionPattern);
|
|
63
|
-
if (match) {
|
|
64
|
-
await ctx.db.patch(match._id, {
|
|
65
|
-
permission: args.permission,
|
|
66
|
-
rateLimitConfig: args.rateLimitConfig,
|
|
67
|
-
createdBy: args.createdBy,
|
|
68
|
-
createdAt: Date.now(),
|
|
69
|
-
});
|
|
70
|
-
return match._id;
|
|
20
|
+
for (const rule of args.rules) {
|
|
21
|
+
const isValid = patternMatchesAvailableFunctions(rule.pattern, args.availableFunctionKeys);
|
|
22
|
+
if (!isValid) {
|
|
23
|
+
throw new Error(`Pattern "${rule.pattern}" does not match any configured function`);
|
|
24
|
+
}
|
|
71
25
|
}
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
functionPattern: args.functionPattern,
|
|
76
|
-
permission: args.permission,
|
|
77
|
-
rateLimitConfig: args.rateLimitConfig,
|
|
78
|
-
createdAt: Date.now(),
|
|
79
|
-
createdBy: args.createdBy,
|
|
80
|
-
});
|
|
81
|
-
return id;
|
|
82
|
-
},
|
|
83
|
-
});
|
|
84
|
-
/**
|
|
85
|
-
* Remove a specific permission.
|
|
86
|
-
*/
|
|
87
|
-
export const removePermission = mutation({
|
|
88
|
-
args: {
|
|
89
|
-
agentId: v.string(),
|
|
90
|
-
appName: v.string(),
|
|
91
|
-
functionPattern: v.string(),
|
|
92
|
-
},
|
|
93
|
-
returns: v.boolean(),
|
|
94
|
-
handler: async (ctx, args) => {
|
|
95
|
-
const perms = await ctx.db
|
|
96
|
-
.query("functionPermissions")
|
|
97
|
-
.withIndex("by_agent_and_app", (q) => q.eq("agentId", args.agentId).eq("appName", args.appName))
|
|
98
|
-
.collect();
|
|
99
|
-
const match = perms.find((p) => p.functionPattern === args.functionPattern);
|
|
100
|
-
if (!match)
|
|
101
|
-
return false;
|
|
102
|
-
await ctx.db.delete(match._id);
|
|
103
|
-
return true;
|
|
104
|
-
},
|
|
105
|
-
});
|
|
106
|
-
/**
|
|
107
|
-
* Check permission for a specific function call.
|
|
108
|
-
* Applies pattern matching with specificity ordering (most specific pattern wins).
|
|
109
|
-
* Default: deny if no matching pattern is found.
|
|
110
|
-
*/
|
|
111
|
-
export const checkPermission = query({
|
|
112
|
-
args: {
|
|
113
|
-
agentId: v.string(),
|
|
114
|
-
appName: v.string(),
|
|
115
|
-
functionName: v.string(),
|
|
116
|
-
},
|
|
117
|
-
returns: permissionResultValidator,
|
|
118
|
-
handler: async (ctx, args) => {
|
|
119
|
-
const permissions = await ctx.db
|
|
120
|
-
.query("functionPermissions")
|
|
121
|
-
.withIndex("by_agent_and_app", (q) => q.eq("agentId", args.agentId).eq("appName", args.appName))
|
|
26
|
+
const existingRules = await ctx.db
|
|
27
|
+
.query("agentPermissions")
|
|
28
|
+
.withIndex("by_agentId", (q) => q.eq("agentId", args.agentId))
|
|
122
29
|
.collect();
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
30
|
+
for (const existingRule of existingRules) {
|
|
31
|
+
await ctx.db.delete(existingRule._id);
|
|
32
|
+
}
|
|
33
|
+
for (const rule of args.rules) {
|
|
34
|
+
await ctx.db.insert("agentPermissions", {
|
|
35
|
+
agentId: args.agentId,
|
|
36
|
+
functionPattern: rule.pattern,
|
|
37
|
+
permission: rule.permission,
|
|
38
|
+
rateLimitConfig: rule.rateLimitConfig,
|
|
39
|
+
updatedAt: Date.now(),
|
|
40
|
+
});
|
|
131
41
|
}
|
|
132
|
-
|
|
133
|
-
const best = matches[0];
|
|
134
|
-
return {
|
|
135
|
-
permission: best.permission,
|
|
136
|
-
rateLimitConfig: best.rateLimitConfig,
|
|
137
|
-
matchedPattern: best.functionPattern,
|
|
138
|
-
};
|
|
42
|
+
return args.rules.length;
|
|
139
43
|
},
|
|
140
44
|
});
|
|
141
|
-
|
|
142
|
-
* List all permissions for an agent on a specific app.
|
|
143
|
-
*/
|
|
144
|
-
export const listPermissions = query({
|
|
45
|
+
export const listAgentPermissions = query({
|
|
145
46
|
args: {
|
|
146
|
-
agentId: v.
|
|
147
|
-
appName: v.string(),
|
|
47
|
+
agentId: v.id("agents"),
|
|
148
48
|
},
|
|
149
49
|
returns: v.array(v.object({
|
|
150
50
|
functionPattern: v.string(),
|
|
151
51
|
permission: v.union(v.literal("allow"), v.literal("deny"), v.literal("rate_limited")),
|
|
152
52
|
rateLimitConfig: v.optional(v.object({
|
|
153
53
|
requestsPerHour: v.number(),
|
|
154
|
-
tokenBudget: v.number(),
|
|
54
|
+
tokenBudget: v.optional(v.number()),
|
|
155
55
|
})),
|
|
156
|
-
|
|
157
|
-
createdBy: v.string(),
|
|
56
|
+
updatedAt: v.number(),
|
|
158
57
|
})),
|
|
159
58
|
handler: async (ctx, args) => {
|
|
160
|
-
const
|
|
161
|
-
.query("
|
|
162
|
-
.withIndex("
|
|
59
|
+
const rules = await ctx.db
|
|
60
|
+
.query("agentPermissions")
|
|
61
|
+
.withIndex("by_agentId", (q) => q.eq("agentId", args.agentId))
|
|
163
62
|
.collect();
|
|
164
|
-
return
|
|
165
|
-
functionPattern:
|
|
166
|
-
permission:
|
|
167
|
-
rateLimitConfig:
|
|
168
|
-
|
|
169
|
-
createdBy: p.createdBy,
|
|
63
|
+
return rules.map((rule) => ({
|
|
64
|
+
functionPattern: rule.functionPattern,
|
|
65
|
+
permission: rule.permission,
|
|
66
|
+
rateLimitConfig: rule.rateLimitConfig,
|
|
67
|
+
updatedAt: rule.updatedAt,
|
|
170
68
|
}));
|
|
171
69
|
},
|
|
172
70
|
});
|
|
173
|
-
|
|
174
|
-
* Remove all permissions for a specific agent on a specific app.
|
|
175
|
-
*/
|
|
176
|
-
export const clearPermissions = mutation({
|
|
71
|
+
export const setFunctionOverrides = mutation({
|
|
177
72
|
args: {
|
|
178
|
-
|
|
179
|
-
|
|
73
|
+
overrides: v.array(v.object({
|
|
74
|
+
key: v.string(),
|
|
75
|
+
enabled: v.boolean(),
|
|
76
|
+
globalRateLimit: v.optional(v.number()),
|
|
77
|
+
})),
|
|
78
|
+
availableFunctionKeys: v.array(v.string()),
|
|
180
79
|
},
|
|
181
80
|
returns: v.number(),
|
|
182
81
|
handler: async (ctx, args) => {
|
|
183
|
-
const
|
|
184
|
-
.
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
82
|
+
for (const override of args.overrides) {
|
|
83
|
+
if (!args.availableFunctionKeys.includes(override.key)) {
|
|
84
|
+
throw new Error(`Function "${override.key}" is not exposed in config`);
|
|
85
|
+
}
|
|
86
|
+
const existing = await ctx.db
|
|
87
|
+
.query("agentFunctions")
|
|
88
|
+
.withIndex("by_key", (q) => q.eq("key", override.key))
|
|
89
|
+
.unique();
|
|
90
|
+
if (existing) {
|
|
91
|
+
await ctx.db.patch(existing._id, {
|
|
92
|
+
enabled: override.enabled,
|
|
93
|
+
globalRateLimit: override.globalRateLimit,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
await ctx.db.insert("agentFunctions", {
|
|
98
|
+
key: override.key,
|
|
99
|
+
enabled: override.enabled,
|
|
100
|
+
globalRateLimit: override.globalRateLimit,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
189
103
|
}
|
|
190
|
-
return
|
|
104
|
+
return args.overrides.length;
|
|
191
105
|
},
|
|
192
106
|
});
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
returns: v.object({
|
|
203
|
-
functionName: v.string(),
|
|
204
|
-
permissions: v.array(v.object({
|
|
205
|
-
functionPattern: v.string(),
|
|
206
|
-
permission: v.union(v.literal("allow"), v.literal("deny"), v.literal("rate_limited")),
|
|
207
|
-
specificity: v.number(),
|
|
208
|
-
})),
|
|
209
|
-
matches: v.array(v.object({
|
|
210
|
-
functionPattern: v.string(),
|
|
211
|
-
permission: v.union(v.literal("allow"), v.literal("deny"), v.literal("rate_limited")),
|
|
212
|
-
specificity: v.number(),
|
|
213
|
-
})),
|
|
214
|
-
bestMatch: v.optional(v.object({
|
|
215
|
-
functionPattern: v.string(),
|
|
216
|
-
permission: v.union(v.literal("allow"), v.literal("deny"), v.literal("rate_limited")),
|
|
217
|
-
specificity: v.number(),
|
|
218
|
-
})),
|
|
219
|
-
}),
|
|
220
|
-
handler: async (ctx, args) => {
|
|
221
|
-
const permissions = await ctx.db
|
|
222
|
-
.query("functionPermissions")
|
|
223
|
-
.withIndex("by_agent_and_app", (q) => q.eq("agentId", args.agentId).eq("appName", args.appName))
|
|
224
|
-
.collect();
|
|
225
|
-
const withSpecificity = permissions.map((p) => ({
|
|
226
|
-
functionPattern: p.functionPattern,
|
|
227
|
-
permission: p.permission,
|
|
228
|
-
specificity: patternSpecificity(p.functionPattern),
|
|
229
|
-
}));
|
|
230
|
-
const matches = withSpecificity
|
|
231
|
-
.filter((p) => matchesPattern(args.functionName, p.functionPattern))
|
|
232
|
-
.sort((a, b) => b.specificity - a.specificity);
|
|
233
|
-
return {
|
|
234
|
-
functionName: args.functionName,
|
|
235
|
-
permissions: withSpecificity,
|
|
236
|
-
matches,
|
|
237
|
-
bestMatch: matches[0],
|
|
238
|
-
};
|
|
107
|
+
export const listFunctionOverrides = query({
|
|
108
|
+
args: {},
|
|
109
|
+
returns: v.array(v.object({
|
|
110
|
+
key: v.string(),
|
|
111
|
+
enabled: v.boolean(),
|
|
112
|
+
globalRateLimit: v.optional(v.number()),
|
|
113
|
+
})),
|
|
114
|
+
handler: async (ctx) => {
|
|
115
|
+
return await ctx.db.query("agentFunctions").collect();
|
|
239
116
|
},
|
|
240
117
|
});
|
|
241
118
|
//# sourceMappingURL=permissions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permissions.js","sourceRoot":"","sources":["../../src/component/permissions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"permissions.js","sourceRoot":"","sources":["../../src/component/permissions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,KA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,EAAE,CAAC,CAAC,OAAO,EAAE;QACpB,eAAe,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;KACxC,CAAC,CACH;IACD,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE;QACrB,OAAO,MAAM,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,OAAO,EAAE,CAAC;IACxD,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -1,175 +1,77 @@
|
|
|
1
1
|
declare const _default: import("convex/server").SchemaDefinition<{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
expiresAt: number;
|
|
10
|
-
isActive: boolean;
|
|
11
|
-
}, {
|
|
12
|
-
tokenHash: import("convex/values").VString<string, "required">;
|
|
13
|
-
employeeEmail: import("convex/values").VString<string, "required">;
|
|
14
|
-
department: import("convex/values").VString<string, "required">;
|
|
15
|
-
maxApps: import("convex/values").VFloat64<number, "required">;
|
|
16
|
-
usedCount: import("convex/values").VFloat64<number, "required">;
|
|
17
|
-
expiresAt: import("convex/values").VFloat64<number, "required">;
|
|
18
|
-
isActive: import("convex/values").VBoolean<boolean, "required">;
|
|
19
|
-
createdBy: import("convex/values").VString<string, "required">;
|
|
20
|
-
}, "required", "createdBy" | "department" | "employeeEmail" | "maxApps" | "tokenHash" | "usedCount" | "expiresAt" | "isActive">, {
|
|
21
|
-
by_token_hash: ["tokenHash", "_creationTime"];
|
|
22
|
-
by_email: ["employeeEmail", "_creationTime"];
|
|
23
|
-
}, {}, {}>;
|
|
24
|
-
registeredAgents: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
25
|
-
revokedBy?: string | undefined;
|
|
26
|
-
revokedAt?: number | undefined;
|
|
27
|
-
agentId: string;
|
|
28
|
-
department: string;
|
|
29
|
-
employeeEmail: string;
|
|
30
|
-
isActive: boolean;
|
|
31
|
-
firstRegisteredAt: number;
|
|
32
|
-
lastSeenAt: number;
|
|
33
|
-
}, {
|
|
34
|
-
agentId: import("convex/values").VString<string, "required">;
|
|
35
|
-
employeeEmail: import("convex/values").VString<string, "required">;
|
|
36
|
-
department: import("convex/values").VString<string, "required">;
|
|
37
|
-
firstRegisteredAt: import("convex/values").VFloat64<number, "required">;
|
|
38
|
-
lastSeenAt: import("convex/values").VFloat64<number, "required">;
|
|
39
|
-
isActive: import("convex/values").VBoolean<boolean, "required">;
|
|
40
|
-
revokedAt: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
41
|
-
revokedBy: import("convex/values").VString<string | undefined, "optional">;
|
|
42
|
-
}, "required", "agentId" | "department" | "employeeEmail" | "revokedBy" | "isActive" | "firstRegisteredAt" | "lastSeenAt" | "revokedAt">, {
|
|
43
|
-
by_agent_id: ["agentId", "_creationTime"];
|
|
44
|
-
by_email: ["employeeEmail", "_creationTime"];
|
|
45
|
-
}, {}, {}>;
|
|
46
|
-
agentAppInstances: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
47
|
-
appName: string;
|
|
48
|
-
agentId: string;
|
|
49
|
-
expiresAt: number;
|
|
50
|
-
instanceTokenHash: string;
|
|
51
|
-
registeredAt: number;
|
|
52
|
-
lastActivityAt: number;
|
|
53
|
-
monthlyRequests: number;
|
|
54
|
-
}, {
|
|
55
|
-
agentId: import("convex/values").VString<string, "required">;
|
|
56
|
-
appName: import("convex/values").VString<string, "required">;
|
|
57
|
-
instanceTokenHash: import("convex/values").VString<string, "required">;
|
|
58
|
-
registeredAt: import("convex/values").VFloat64<number, "required">;
|
|
59
|
-
expiresAt: import("convex/values").VFloat64<number, "required">;
|
|
60
|
-
lastActivityAt: import("convex/values").VFloat64<number, "required">;
|
|
61
|
-
monthlyRequests: import("convex/values").VFloat64<number, "required">;
|
|
62
|
-
}, "required", "appName" | "agentId" | "expiresAt" | "instanceTokenHash" | "registeredAt" | "lastActivityAt" | "monthlyRequests">, {
|
|
63
|
-
by_instance_token_hash: ["instanceTokenHash", "_creationTime"];
|
|
64
|
-
by_agent_and_app: ["agentId", "appName", "_creationTime"];
|
|
65
|
-
}, {}, {}>;
|
|
66
|
-
functionRegistry: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
67
|
-
description?: string | undefined;
|
|
68
|
-
appName: string;
|
|
69
|
-
functionName: string;
|
|
70
|
-
functionHandle: string;
|
|
71
|
-
functionType: "query" | "mutation" | "action";
|
|
72
|
-
registeredAt: number;
|
|
2
|
+
agents: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
3
|
+
lastUsed?: number | undefined;
|
|
4
|
+
enabled: boolean;
|
|
5
|
+
name: string;
|
|
6
|
+
rateLimit: number;
|
|
7
|
+
apiKeyHash: string;
|
|
8
|
+
createdAt: number;
|
|
73
9
|
}, {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}, "required", "
|
|
81
|
-
|
|
10
|
+
name: import("convex/values").VString<string, "required">;
|
|
11
|
+
apiKeyHash: import("convex/values").VString<string, "required">;
|
|
12
|
+
enabled: import("convex/values").VBoolean<boolean, "required">;
|
|
13
|
+
rateLimit: import("convex/values").VFloat64<number, "required">;
|
|
14
|
+
lastUsed: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
15
|
+
createdAt: import("convex/values").VFloat64<number, "required">;
|
|
16
|
+
}, "required", "enabled" | "name" | "rateLimit" | "apiKeyHash" | "lastUsed" | "createdAt">, {
|
|
17
|
+
by_apiKeyHash: ["apiKeyHash", "_creationTime"];
|
|
18
|
+
by_enabled: ["enabled", "_creationTime"];
|
|
82
19
|
}, {}, {}>;
|
|
83
|
-
|
|
20
|
+
agentPermissions: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
84
21
|
rateLimitConfig?: {
|
|
22
|
+
tokenBudget?: number | undefined;
|
|
85
23
|
requestsPerHour: number;
|
|
86
|
-
tokenBudget: number;
|
|
87
24
|
} | undefined;
|
|
88
|
-
|
|
89
|
-
agentId: string;
|
|
90
|
-
permission: "allow" | "deny" | "rate_limited";
|
|
25
|
+
agentId: import("convex/values").GenericId<"agents">;
|
|
91
26
|
functionPattern: string;
|
|
92
|
-
|
|
93
|
-
|
|
27
|
+
permission: "allow" | "deny" | "rate_limited";
|
|
28
|
+
updatedAt: number;
|
|
94
29
|
}, {
|
|
95
|
-
agentId: import("convex/values").
|
|
96
|
-
appName: import("convex/values").VString<string, "required">;
|
|
30
|
+
agentId: import("convex/values").VId<import("convex/values").GenericId<"agents">, "required">;
|
|
97
31
|
functionPattern: import("convex/values").VString<string, "required">;
|
|
98
32
|
permission: import("convex/values").VUnion<"allow" | "deny" | "rate_limited", [import("convex/values").VLiteral<"allow", "required">, import("convex/values").VLiteral<"deny", "required">, import("convex/values").VLiteral<"rate_limited", "required">], "required", never>;
|
|
99
33
|
rateLimitConfig: import("convex/values").VObject<{
|
|
34
|
+
tokenBudget?: number | undefined;
|
|
100
35
|
requestsPerHour: number;
|
|
101
|
-
tokenBudget: number;
|
|
102
36
|
} | undefined, {
|
|
103
37
|
requestsPerHour: import("convex/values").VFloat64<number, "required">;
|
|
104
|
-
tokenBudget: import("convex/values").VFloat64<number, "
|
|
38
|
+
tokenBudget: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
105
39
|
}, "optional", "requestsPerHour" | "tokenBudget">;
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
by_agent_and_app: ["agentId", "appName", "_creationTime"];
|
|
110
|
-
by_app_and_pattern: ["appName", "functionPattern", "_creationTime"];
|
|
40
|
+
updatedAt: import("convex/values").VFloat64<number, "required">;
|
|
41
|
+
}, "required", "agentId" | "functionPattern" | "permission" | "rateLimitConfig" | "updatedAt" | "rateLimitConfig.requestsPerHour" | "rateLimitConfig.tokenBudget">, {
|
|
42
|
+
by_agentId: ["agentId", "_creationTime"];
|
|
111
43
|
}, {}, {}>;
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
agentId: string;
|
|
117
|
-
functionCalled: string;
|
|
118
|
-
permission: string;
|
|
119
|
-
timestamp: number;
|
|
44
|
+
agentFunctions: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
45
|
+
globalRateLimit?: number | undefined;
|
|
46
|
+
enabled: boolean;
|
|
47
|
+
key: string;
|
|
120
48
|
}, {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
errorMessage: import("convex/values").VString<string | undefined, "optional">;
|
|
127
|
-
durationMs: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
128
|
-
}, "required", "appName" | "agentId" | "durationMs" | "errorMessage" | "functionCalled" | "permission" | "timestamp">, {
|
|
129
|
-
by_agent_and_timestamp: ["agentId", "timestamp", "_creationTime"];
|
|
130
|
-
by_app_and_function: ["appName", "functionCalled", "_creationTime"];
|
|
49
|
+
key: import("convex/values").VString<string, "required">;
|
|
50
|
+
enabled: import("convex/values").VBoolean<boolean, "required">;
|
|
51
|
+
globalRateLimit: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
52
|
+
}, "required", "enabled" | "key" | "globalRateLimit">, {
|
|
53
|
+
by_key: ["key", "_creationTime"];
|
|
131
54
|
}, {}, {}>;
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
pattern: string;
|
|
141
|
-
}[];
|
|
142
|
-
configuredAt: number;
|
|
55
|
+
agentLogs: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
56
|
+
error?: string | undefined;
|
|
57
|
+
result?: any;
|
|
58
|
+
agentId: import("convex/values").GenericId<"agents">;
|
|
59
|
+
functionKey: string;
|
|
60
|
+
args: any;
|
|
61
|
+
duration: number;
|
|
62
|
+
timestamp: number;
|
|
143
63
|
}, {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
tokenBudget: number;
|
|
156
|
-
} | undefined;
|
|
157
|
-
permission: "allow" | "deny" | "rate_limited";
|
|
158
|
-
pattern: string;
|
|
159
|
-
}, {
|
|
160
|
-
pattern: import("convex/values").VString<string, "required">;
|
|
161
|
-
permission: import("convex/values").VUnion<"allow" | "deny" | "rate_limited", [import("convex/values").VLiteral<"allow", "required">, import("convex/values").VLiteral<"deny", "required">, import("convex/values").VLiteral<"rate_limited", "required">], "required", never>;
|
|
162
|
-
rateLimitConfig: import("convex/values").VObject<{
|
|
163
|
-
requestsPerHour: number;
|
|
164
|
-
tokenBudget: number;
|
|
165
|
-
} | undefined, {
|
|
166
|
-
requestsPerHour: import("convex/values").VFloat64<number, "required">;
|
|
167
|
-
tokenBudget: import("convex/values").VFloat64<number, "required">;
|
|
168
|
-
}, "optional", "requestsPerHour" | "tokenBudget">;
|
|
169
|
-
}, "required", "permission" | "rateLimitConfig" | "rateLimitConfig.requestsPerHour" | "rateLimitConfig.tokenBudget" | "pattern">, "required">;
|
|
170
|
-
configuredAt: import("convex/values").VFloat64<number, "required">;
|
|
171
|
-
}, "required", "appName" | "defaultPermissions" | "configuredAt">, {
|
|
172
|
-
by_app_name: ["appName", "_creationTime"];
|
|
64
|
+
agentId: import("convex/values").VId<import("convex/values").GenericId<"agents">, "required">;
|
|
65
|
+
functionKey: import("convex/values").VString<string, "required">;
|
|
66
|
+
args: import("convex/values").VAny<any, "required", string>;
|
|
67
|
+
result: import("convex/values").VAny<any, "optional", string>;
|
|
68
|
+
error: import("convex/values").VString<string | undefined, "optional">;
|
|
69
|
+
duration: import("convex/values").VFloat64<number, "required">;
|
|
70
|
+
timestamp: import("convex/values").VFloat64<number, "required">;
|
|
71
|
+
}, "required", "agentId" | "functionKey" | "args" | "duration" | "error" | "result" | "timestamp" | `args.${string}` | `result.${string}`>, {
|
|
72
|
+
by_agentId_and_timestamp: ["agentId", "timestamp", "_creationTime"];
|
|
73
|
+
by_functionKey: ["functionKey", "_creationTime"];
|
|
74
|
+
by_timestamp: ["timestamp", "_creationTime"];
|
|
173
75
|
}, {}, {}>;
|
|
174
76
|
}, true>;
|
|
175
77
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/component/schema.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/component/schema.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,wBA+CG"}
|