@vantageos/agent-engine 0.1.0-alpha.4 → 0.1.0-alpha.6

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 (41) hide show
  1. package/README.md +285 -46
  2. package/dist/component/_generated/api.d.ts +31 -0
  3. package/dist/component/_generated/component.d.ts +365 -3
  4. package/dist/component/convex.config.js +19 -0
  5. package/dist/component/engine/agents.d.ts +10 -0
  6. package/dist/component/engine/agents.js +21 -0
  7. package/dist/component/engine/awaitEventTimeout.d.ts +13 -0
  8. package/dist/component/engine/awaitEventTimeout.js +82 -0
  9. package/dist/component/engine/delegation.d.ts +75 -0
  10. package/dist/component/engine/delegation.js +329 -0
  11. package/dist/component/engine/directory.d.ts +9 -0
  12. package/dist/component/engine/directory.js +45 -0
  13. package/dist/component/engine/habits.d.ts +70 -0
  14. package/dist/component/engine/habits.js +219 -0
  15. package/dist/component/engine/mandates.d.ts +74 -0
  16. package/dist/component/engine/mandates.js +272 -0
  17. package/dist/component/engine/sandboxCallback.d.ts +36 -0
  18. package/dist/component/engine/sandboxCallback.js +262 -0
  19. package/dist/component/engine/sessions.d.ts +7 -2
  20. package/dist/component/engine/sessions.js +75 -15
  21. package/dist/component/engine/toolApprovals.d.ts +2 -1
  22. package/dist/component/engine/toolApprovals.js +64 -26
  23. package/dist/component/engine/vpConnection.d.ts +69 -0
  24. package/dist/component/engine/vpConnection.js +221 -0
  25. package/dist/component/engine/wakeup.d.ts +33 -0
  26. package/dist/component/engine/wakeup.js +230 -0
  27. package/dist/component/engine/workflows.d.ts +11 -0
  28. package/dist/component/engine/workflows.js +87 -0
  29. package/dist/component/schema.d.ts +365 -4
  30. package/dist/component/schema.js +360 -1
  31. package/dist/component/testFixtures/delegationDemoWorkflow.d.ts +18 -0
  32. package/dist/component/testFixtures/delegationDemoWorkflow.js +76 -0
  33. package/dist/component/testFixtures/sandboxDemoWorkflow.d.ts +19 -0
  34. package/dist/component/testFixtures/sandboxDemoWorkflow.js +69 -0
  35. package/dist/component/testFixtures/vpTool.d.ts +4 -0
  36. package/dist/component/testFixtures/vpTool.js +25 -0
  37. package/dist/component/testFixtures/wakeupDemoWorkflow.d.ts +19 -0
  38. package/dist/component/testFixtures/wakeupDemoWorkflow.js +77 -0
  39. package/dist/component/testFixtures/wakeupWork.d.ts +8 -0
  40. package/dist/component/testFixtures/wakeupWork.js +21 -0
  41. package/package.json +2 -1
@@ -0,0 +1,75 @@
1
+ import type { Id } from "../_generated/dataModel.js";
2
+ export declare const BUILTIN_AGENT_TOOL_NAME = "agent";
3
+ export declare const declareSubagent: import("convex/server").RegisteredMutation<"public", {
4
+ description?: string | undefined;
5
+ orgId: string;
6
+ toolName: string;
7
+ parentAgentId: import("convex/values").GenericId<"agents">;
8
+ childAgentId: import("convex/values").GenericId<"agents">;
9
+ }, Promise<import("convex/values").GenericId<"subagents">>>;
10
+ export declare const listSubagents: import("convex/server").RegisteredQuery<"public", {
11
+ orgId: string;
12
+ parentAgentId: import("convex/values").GenericId<"agents">;
13
+ }, Promise<{
14
+ _id: import("convex/values").GenericId<"subagents">;
15
+ _creationTime: number;
16
+ description?: string | undefined;
17
+ orgId: string;
18
+ createdAt: number;
19
+ toolName: string;
20
+ enabled: boolean;
21
+ parentAgentId: import("convex/values").GenericId<"agents">;
22
+ childAgentId: import("convex/values").GenericId<"agents">;
23
+ }[]>>;
24
+ export declare const delegateToSubagent: import("convex/server").RegisteredAction<"public", {
25
+ payload?: string | undefined;
26
+ orgId: string;
27
+ workflowId: string;
28
+ awaitedEventName: string;
29
+ scope: string;
30
+ reason: string;
31
+ cost: number;
32
+ subagentId: import("convex/values").GenericId<"subagents">;
33
+ workFunctionHandle: string;
34
+ }, Promise<Id<"delegationRuns">>>;
35
+ export declare const invokeAgentClone: import("convex/server").RegisteredAction<"public", {
36
+ payload?: string | undefined;
37
+ orgId: string;
38
+ workflowId: string;
39
+ agentId: import("convex/values").GenericId<"agents">;
40
+ awaitedEventName: string;
41
+ scope: string;
42
+ reason: string;
43
+ cost: number;
44
+ workFunctionHandle: string;
45
+ viaAgentTool: boolean;
46
+ }, Promise<Id<"agentCloneRuns">>>;
47
+ export declare const getSubagentInternal: import("convex/server").RegisteredQuery<"internal", {
48
+ orgId: string;
49
+ subagentId: import("convex/values").GenericId<"subagents">;
50
+ }, Promise<{
51
+ parentAgentId: import("convex/values").GenericId<"agents">;
52
+ childAgentId: import("convex/values").GenericId<"agents">;
53
+ toolName: string;
54
+ enabled: boolean;
55
+ } | null>>;
56
+ export declare const getAgentInternal: import("convex/server").RegisteredQuery<"internal", {
57
+ orgId: string;
58
+ agentId: import("convex/values").GenericId<"agents">;
59
+ }, Promise<{
60
+ _id: import("convex/values").GenericId<"agents">;
61
+ } | null>>;
62
+ export declare const recordDelegationStartInternal: import("convex/server").RegisteredMutation<"internal", {
63
+ orgId: string;
64
+ workflowId: string;
65
+ toolName: string;
66
+ awaitedEventName: string;
67
+ parentAgentId: import("convex/values").GenericId<"agents">;
68
+ childAgentId: import("convex/values").GenericId<"agents">;
69
+ }, Promise<import("convex/values").GenericId<"delegationRuns">>>;
70
+ export declare const recordCloneStartInternal: import("convex/server").RegisteredMutation<"internal", {
71
+ orgId: string;
72
+ workflowId: string;
73
+ agentId: import("convex/values").GenericId<"agents">;
74
+ awaitedEventName: string;
75
+ }, Promise<import("convex/values").GenericId<"agentCloneRuns">>>;
@@ -0,0 +1,329 @@
1
+ import { v } from "convex/values";
2
+ import { api, internal } from "../_generated/api.js";
3
+ import { action, internalMutation, internalQuery, mutation, query, } from "../_generated/server.js";
4
+ import { assertSameOrg, requireOrgId } from "../lib/auth.js";
5
+ // engine/delegation — C6 (SYNTHESE.md §4.d): "un agent qui délègue à un
6
+ // autre agent = LE MÊME système pause/réveil (awaitEvent/sendEvent) que le
7
+ // pont sandbox -- un seul système à écrire, pas deux". Ported from
8
+ // convex/engine/delegation.ts (repo-root prototype, I6) into the component
9
+ // boundary (C6). Every delegation path below (declared subagent AND the
10
+ // built-in `agent` clone tool) terminates in exactly ONE call to
11
+ // `engine.wakeup.enqueue` -- the SAME public action C2/C3 already ships,
12
+ // imported here and never reimplemented.
13
+ // grep proof: this file makes zero calls to `wakeupPool.*` / `workflow.*`
14
+ // directly; the only wake-capable call in this module is
15
+ // `api.engine.wakeup.enqueue` at the bottom of `delegateToSubagent` and
16
+ // `invokeAgentClone`.
17
+ //
18
+ // C6 orgId discipline (component/lib/auth.ts): every PUBLIC function takes
19
+ // `orgId` as an explicit ARGUMENT (auth does not propagate across a
20
+ // component boundary), same as engine/mandates.ts (C3) / engine/wakeup.ts
21
+ // (C2). `delegateToSubagent`/`invokeAgentClone` are `action`s because they
22
+ // each call `api.engine.wakeup.enqueue` (itself an action, C3's two-
23
+ // transaction funding protocol) -- `orgId` is threaded explicitly through
24
+ // every hop, never relying on any identity propagation across the boundary.
25
+ // Reserved tool name for the built-in, root-only, non-recursive clone tool
26
+ // (eve.dev/docs/subagents). A declared subagent may never claim this name --
27
+ // that would silently shadow the built-in, which eve explicitly refuses to
28
+ // do ("eve rejects the build rather than picking a winner").
29
+ export const BUILTIN_AGENT_TOOL_NAME = "agent";
30
+ // ---------------------------------------------------------------------
31
+ // (a.1) DECLARED SUBAGENTS -- strict isolation, build-time collision guard
32
+ // ---------------------------------------------------------------------
33
+ // declareSubagent — registers a declared subagent as a NAMED tool on the
34
+ // parent. Isolation is by construction: this mutation writes ONLY the
35
+ // parent->child link + toolName; it never copies a single field out of the
36
+ // child's own `skills`/`connections`/`toolApprovals` rows onto the parent,
37
+ // and never will -- a declared subagent's own aggregate is the ONLY place
38
+ // its slots ever live (eve.dev/docs/subagents, verbatim: "a declared
39
+ // subagent inherits nothing from the root's authored slots").
40
+ //
41
+ // BUILD-TIME COLLISION GUARD: `toolName` must be unique among (1) the
42
+ // reserved built-in `agent` tool name, (2) every OTHER declared subagent of
43
+ // this same parent, and (3) every `toolApprovals` row already registered
44
+ // for this parent (a toolApprovals row is how this engine represents "a
45
+ // named tool this agent already exposes"). Any collision REJECTS the
46
+ // mutation -- the row is never written, there is no silent "last one wins".
47
+ export const declareSubagent = mutation({
48
+ args: {
49
+ orgId: v.string(),
50
+ parentAgentId: v.id("agents"),
51
+ childAgentId: v.id("agents"),
52
+ toolName: v.string(),
53
+ description: v.optional(v.string()),
54
+ },
55
+ returns: v.id("subagents"),
56
+ handler: async (ctx, args) => {
57
+ const orgId = requireOrgId(args.orgId);
58
+ const parent = await ctx.db.get(args.parentAgentId);
59
+ assertSameOrg(orgId, parent, "Parent agent not found");
60
+ const child = await ctx.db.get(args.childAgentId);
61
+ assertSameOrg(orgId, child, "Child agent not found");
62
+ const toolName = args.toolName.trim();
63
+ if (toolName.length === 0) {
64
+ throw new Error("Validation: toolName must not be empty");
65
+ }
66
+ if (args.parentAgentId === args.childAgentId) {
67
+ throw new Error("Build rejected: an agent cannot be declared as its own subagent");
68
+ }
69
+ if (toolName === BUILTIN_AGENT_TOOL_NAME) {
70
+ throw new Error(`Build rejected: tool name "${toolName}" collides with the built-in ` +
71
+ `"agent" clone tool -- eve rejects the build rather than picking a winner`);
72
+ }
73
+ const collidingSubagent = await ctx.db
74
+ .query("subagents")
75
+ .withIndex("by_org_parent_tool", (q) => q.eq("orgId", orgId).eq("parentAgentId", args.parentAgentId).eq("toolName", toolName))
76
+ .first();
77
+ if (collidingSubagent) {
78
+ throw new Error(`Build rejected: tool name "${toolName}" already claimed by another ` +
79
+ `declared subagent of this agent -- eve rejects the build rather ` +
80
+ `than picking a winner`);
81
+ }
82
+ const collidingTool = await ctx.db
83
+ .query("toolApprovals")
84
+ .withIndex("by_org_agent_tool", (q) => q.eq("orgId", orgId).eq("agentId", args.parentAgentId).eq("toolName", toolName))
85
+ .first();
86
+ if (collidingTool) {
87
+ throw new Error(`Build rejected: tool name "${toolName}" collides with an existing ` +
88
+ `tool already registered on this agent -- eve rejects the build ` +
89
+ `rather than picking a winner`);
90
+ }
91
+ const now = Date.now();
92
+ return await ctx.db.insert("subagents", {
93
+ orgId,
94
+ parentAgentId: args.parentAgentId,
95
+ childAgentId: args.childAgentId,
96
+ toolName,
97
+ description: args.description,
98
+ enabled: true,
99
+ createdAt: now,
100
+ });
101
+ },
102
+ });
103
+ export const listSubagents = query({
104
+ args: { orgId: v.string(), parentAgentId: v.id("agents") },
105
+ returns: v.array(v.object({
106
+ _id: v.id("subagents"),
107
+ _creationTime: v.number(),
108
+ orgId: v.string(),
109
+ parentAgentId: v.id("agents"),
110
+ childAgentId: v.id("agents"),
111
+ toolName: v.string(),
112
+ description: v.optional(v.string()),
113
+ enabled: v.boolean(),
114
+ createdAt: v.number(),
115
+ })),
116
+ handler: async (ctx, args) => {
117
+ const orgId = requireOrgId(args.orgId);
118
+ return await ctx.db
119
+ .query("subagents")
120
+ .withIndex("by_org_parent", (q) => q.eq("orgId", orgId).eq("parentAgentId", args.parentAgentId))
121
+ .collect();
122
+ },
123
+ });
124
+ // ---------------------------------------------------------------------
125
+ // (a.2) DELEGATION -- reuses `engine.wakeup.enqueue` end to end
126
+ // ---------------------------------------------------------------------
127
+ // delegateToSubagent — A delegates to a declared subagent B by the SAME
128
+ // pause/réveil mechanism the sandbox bridge (C5) uses: it enqueues the
129
+ // caller-supplied `workFunctionHandle` (an action that performs B's turn)
130
+ // through `api.engine.wakeup.enqueue`. That enqueue funds through
131
+ // `mandates.spendInternal` (C3's own choke point, untouched), puts the work
132
+ // into `wakeupPool`, and when it resolves, `engine.wakeup.onWorkComplete`
133
+ // calls `workflow.sendEvent` (workflowId, awaitedEventName, ...) -- waking
134
+ // whatever workflow step A's own session parked on `step.awaitEvent`. There
135
+ // is no second onComplete/sendEvent path anywhere in this file.
136
+ export const delegateToSubagent = action({
137
+ args: {
138
+ orgId: v.string(),
139
+ subagentId: v.id("subagents"),
140
+ scope: v.string(),
141
+ cost: v.number(),
142
+ reason: v.string(),
143
+ workflowId: v.string(),
144
+ awaitedEventName: v.string(),
145
+ workFunctionHandle: v.string(),
146
+ payload: v.optional(v.string()),
147
+ },
148
+ returns: v.id("delegationRuns"),
149
+ handler: async (ctx, args) => {
150
+ const orgId = requireOrgId(args.orgId);
151
+ const subagent = await ctx.runQuery(internal.engine.delegation.getSubagentInternal, {
152
+ orgId,
153
+ subagentId: args.subagentId,
154
+ });
155
+ if (!subagent) {
156
+ throw new Error("Subagent not found");
157
+ }
158
+ if (!subagent.enabled) {
159
+ throw new Error(`Subagent "${subagent.toolName}" is disabled`);
160
+ }
161
+ const delegationRunId = await ctx.runMutation(internal.engine.delegation.recordDelegationStartInternal, {
162
+ orgId,
163
+ parentAgentId: subagent.parentAgentId,
164
+ childAgentId: subagent.childAgentId,
165
+ toolName: subagent.toolName,
166
+ workflowId: args.workflowId,
167
+ awaitedEventName: args.awaitedEventName,
168
+ });
169
+ // THE reuse point: no bespoke pause/wake code below this line -- this
170
+ // is a direct call into C2/C3's own PUBLIC `engine.wakeup.enqueue`
171
+ // action. `orgId` is threaded explicitly (no identity propagation
172
+ // across the component boundary).
173
+ await ctx.runAction(api.engine.wakeup.enqueue, {
174
+ orgId,
175
+ agentId: subagent.childAgentId,
176
+ scope: args.scope,
177
+ cost: args.cost,
178
+ reason: args.reason,
179
+ workflowId: args.workflowId,
180
+ awaitedEventName: args.awaitedEventName,
181
+ workFunctionHandle: args.workFunctionHandle,
182
+ payload: args.payload,
183
+ });
184
+ return delegationRunId;
185
+ },
186
+ });
187
+ // ---------------------------------------------------------------------
188
+ // (a.3) BUILT-IN `agent` TOOL -- root-only clone, NOT recursive
189
+ // ---------------------------------------------------------------------
190
+ // invokeAgentClone — the built-in `agent` tool (eve.dev/docs/subagents): a
191
+ // clone of the ROOT agent, invocable by the root itself, but the clone
192
+ // CANNOT call itself again. `viaAgentTool` is the recursion guard: the
193
+ // root's own first call always passes `viaAgentTool: false` (or omits it).
194
+ // Anything invoking this action must set `viaAgentTool: true` on any call
195
+ // made FROM INSIDE a clone's own work -- and that is exactly the value this
196
+ // handler refuses. There is no code path in this engine that can reach the
197
+ // pool a second time for the same clone chain: the guard runs BEFORE
198
+ // `wakeup.enqueue` is ever called, so a recursive attempt never enters the
199
+ // workpool at all.
200
+ export const invokeAgentClone = action({
201
+ args: {
202
+ orgId: v.string(),
203
+ agentId: v.id("agents"),
204
+ scope: v.string(),
205
+ cost: v.number(),
206
+ reason: v.string(),
207
+ workflowId: v.string(),
208
+ awaitedEventName: v.string(),
209
+ workFunctionHandle: v.string(),
210
+ payload: v.optional(v.string()),
211
+ viaAgentTool: v.boolean(),
212
+ },
213
+ returns: v.id("agentCloneRuns"),
214
+ handler: async (ctx, args) => {
215
+ const orgId = requireOrgId(args.orgId);
216
+ if (args.viaAgentTool) {
217
+ throw new Error("Build rejected: the built-in \"agent\" clone tool is root-only and " +
218
+ "NOT recursive -- a clone invocation cannot invoke the agent tool " +
219
+ "again");
220
+ }
221
+ const agent = await ctx.runQuery(internal.engine.delegation.getAgentInternal, {
222
+ orgId,
223
+ agentId: args.agentId,
224
+ });
225
+ if (!agent) {
226
+ throw new Error("Agent not found");
227
+ }
228
+ const cloneRunId = await ctx.runMutation(internal.engine.delegation.recordCloneStartInternal, {
229
+ orgId,
230
+ agentId: args.agentId,
231
+ workflowId: args.workflowId,
232
+ awaitedEventName: args.awaitedEventName,
233
+ });
234
+ // Same reuse point as `delegateToSubagent`: one call into the SAME
235
+ // public `engine.wakeup.enqueue`, nothing bespoke.
236
+ await ctx.runAction(api.engine.wakeup.enqueue, {
237
+ orgId,
238
+ agentId: args.agentId,
239
+ scope: args.scope,
240
+ cost: args.cost,
241
+ reason: args.reason,
242
+ workflowId: args.workflowId,
243
+ awaitedEventName: args.awaitedEventName,
244
+ workFunctionHandle: args.workFunctionHandle,
245
+ payload: args.payload,
246
+ });
247
+ return cloneRunId;
248
+ },
249
+ });
250
+ // ---------------------------------------------------------------------
251
+ // INTERNAL helpers -- unreachable from any client, same discipline as
252
+ // `engine/wakeup.enqueueInternal`.
253
+ // ---------------------------------------------------------------------
254
+ export const getSubagentInternal = internalQuery({
255
+ args: { orgId: v.string(), subagentId: v.id("subagents") },
256
+ returns: v.union(v.object({
257
+ parentAgentId: v.id("agents"),
258
+ childAgentId: v.id("agents"),
259
+ toolName: v.string(),
260
+ enabled: v.boolean(),
261
+ }), v.null()),
262
+ handler: async (ctx, args) => {
263
+ const row = await ctx.db.get(args.subagentId);
264
+ if (!row || row.orgId !== args.orgId)
265
+ return null;
266
+ return {
267
+ parentAgentId: row.parentAgentId,
268
+ childAgentId: row.childAgentId,
269
+ toolName: row.toolName,
270
+ enabled: row.enabled,
271
+ };
272
+ },
273
+ });
274
+ export const getAgentInternal = internalQuery({
275
+ args: { orgId: v.string(), agentId: v.id("agents") },
276
+ returns: v.union(v.object({ _id: v.id("agents") }), v.null()),
277
+ handler: async (ctx, args) => {
278
+ const row = await ctx.db.get(args.agentId);
279
+ if (!row || row.orgId !== args.orgId)
280
+ return null;
281
+ return { _id: row._id };
282
+ },
283
+ });
284
+ export const recordDelegationStartInternal = internalMutation({
285
+ args: {
286
+ orgId: v.string(),
287
+ parentAgentId: v.id("agents"),
288
+ childAgentId: v.id("agents"),
289
+ toolName: v.string(),
290
+ workflowId: v.string(),
291
+ awaitedEventName: v.string(),
292
+ },
293
+ returns: v.id("delegationRuns"),
294
+ handler: async (ctx, args) => {
295
+ const now = Date.now();
296
+ return await ctx.db.insert("delegationRuns", {
297
+ orgId: args.orgId,
298
+ parentAgentId: args.parentAgentId,
299
+ childAgentId: args.childAgentId,
300
+ toolName: args.toolName,
301
+ workflowId: args.workflowId,
302
+ awaitedEventName: args.awaitedEventName,
303
+ status: "pending",
304
+ createdAt: now,
305
+ updatedAt: now,
306
+ });
307
+ },
308
+ });
309
+ export const recordCloneStartInternal = internalMutation({
310
+ args: {
311
+ orgId: v.string(),
312
+ agentId: v.id("agents"),
313
+ workflowId: v.string(),
314
+ awaitedEventName: v.string(),
315
+ },
316
+ returns: v.id("agentCloneRuns"),
317
+ handler: async (ctx, args) => {
318
+ const now = Date.now();
319
+ return await ctx.db.insert("agentCloneRuns", {
320
+ orgId: args.orgId,
321
+ agentId: args.agentId,
322
+ workflowId: args.workflowId,
323
+ awaitedEventName: args.awaitedEventName,
324
+ status: "pending",
325
+ createdAt: now,
326
+ updatedAt: now,
327
+ });
328
+ },
329
+ });
@@ -0,0 +1,9 @@
1
+ export declare const listByOrg: import("convex/server").RegisteredQuery<"public", {
2
+ orgId: string;
3
+ }, Promise<{
4
+ _id: import("convex/values").GenericId<"agents">;
5
+ name: string;
6
+ status: "draft" | "live" | "archived";
7
+ model: string;
8
+ createdAt: number;
9
+ }[]>>;
@@ -0,0 +1,45 @@
1
+ import { v } from "convex/values";
2
+ import { query } from "../_generated/server.js";
3
+ import { requireOrgId } from "../lib/auth.js";
4
+ // engine/directory — component-boundary port of the app-level
5
+ // `convex/directory.ts:listByOrg` (M-COMPLETION C1, VP k1717xyrn25n99h6j10m48f1jx8akg6v).
6
+ //
7
+ // Trust-boundary divergence from the app-level prototype (see
8
+ // component/lib/auth.ts): auth does NOT propagate across a component
9
+ // boundary, so `orgId` is a caller-supplied ARGUMENT here (deny by default
10
+ // via `requireOrgId(args.orgId)`), never read from `ctx.auth`. The consumer
11
+ // app has already authenticated its user and resolved orgId on its own
12
+ // side before calling in.
13
+ //
14
+ // Shape divergence: the app-level prototype also reports
15
+ // `subagentCount`/`connectionCount` by joining the `subagents` and
16
+ // `connections` tables. Those tables are NOT (yet) re-hosted inside this
17
+ // component boundary (see component/schema.ts SCOPE note) -- porting a
18
+ // join against tables this component does not own would violate component
19
+ // isolation. `listByOrg` here therefore returns only what this component's
20
+ // own `agents` table can answer; counts can be added once `subagents`/
21
+ // `connections` gain their own component-level test harness.
22
+ export const listByOrg = query({
23
+ args: { orgId: v.string() },
24
+ returns: v.array(v.object({
25
+ _id: v.id("agents"),
26
+ name: v.string(),
27
+ status: v.union(v.literal("draft"), v.literal("live"), v.literal("archived")),
28
+ model: v.string(),
29
+ createdAt: v.number(),
30
+ })),
31
+ handler: async (ctx, args) => {
32
+ const orgId = requireOrgId(args.orgId);
33
+ const agents = await ctx.db
34
+ .query("agents")
35
+ .withIndex("by_org", (q) => q.eq("orgId", orgId))
36
+ .collect();
37
+ return agents.map((agent) => ({
38
+ _id: agent._id,
39
+ name: agent.name,
40
+ status: agent.status,
41
+ model: agent.model,
42
+ createdAt: agent.createdAt,
43
+ }));
44
+ },
45
+ });
@@ -0,0 +1,70 @@
1
+ export declare const create: import("convex/server").RegisteredMutation<"public", {
2
+ name: string;
3
+ orgId: string;
4
+ agentId: import("convex/values").GenericId<"agents">;
5
+ cronExpression: string;
6
+ prompt: string;
7
+ }, Promise<import("convex/values").GenericId<"habits">>>;
8
+ export declare const get: import("convex/server").RegisteredQuery<"public", {
9
+ orgId: string;
10
+ habitId: import("convex/values").GenericId<"habits">;
11
+ }, Promise<{
12
+ _id: import("convex/values").GenericId<"habits">;
13
+ _creationTime: number;
14
+ cronJobId?: string | undefined;
15
+ lastRunAt?: number | undefined;
16
+ name: string;
17
+ orgId: string;
18
+ createdAt: number;
19
+ updatedAt: number;
20
+ agentId: import("convex/values").GenericId<"agents">;
21
+ cronExpression: string;
22
+ prompt: string;
23
+ enabled: boolean;
24
+ } | null>>;
25
+ export declare const listForAgent: import("convex/server").RegisteredQuery<"public", {
26
+ orgId: string;
27
+ agentId: import("convex/values").GenericId<"agents">;
28
+ }, Promise<{
29
+ _id: import("convex/values").GenericId<"habits">;
30
+ _creationTime: number;
31
+ cronJobId?: string | undefined;
32
+ lastRunAt?: number | undefined;
33
+ name: string;
34
+ orgId: string;
35
+ createdAt: number;
36
+ updatedAt: number;
37
+ agentId: import("convex/values").GenericId<"agents">;
38
+ cronExpression: string;
39
+ prompt: string;
40
+ enabled: boolean;
41
+ }[]>>;
42
+ export declare const updateSchedule: import("convex/server").RegisteredMutation<"public", {
43
+ name?: string | undefined;
44
+ cronExpression?: string | undefined;
45
+ prompt?: string | undefined;
46
+ orgId: string;
47
+ habitId: import("convex/values").GenericId<"habits">;
48
+ }, Promise<null>>;
49
+ export declare const disable: import("convex/server").RegisteredMutation<"public", {
50
+ orgId: string;
51
+ habitId: import("convex/values").GenericId<"habits">;
52
+ }, Promise<null>>;
53
+ export declare const enable: import("convex/server").RegisteredMutation<"public", {
54
+ orgId: string;
55
+ habitId: import("convex/values").GenericId<"habits">;
56
+ }, Promise<null>>;
57
+ export declare const run: import("convex/server").RegisteredMutation<"internal", {
58
+ habitId: import("convex/values").GenericId<"habits">;
59
+ }, Promise<null>>;
60
+ export declare const listRuns: import("convex/server").RegisteredQuery<"public", {
61
+ orgId: string;
62
+ habitId: import("convex/values").GenericId<"habits">;
63
+ }, Promise<{
64
+ _id: import("convex/values").GenericId<"habitRuns">;
65
+ _creationTime: number;
66
+ orgId: string;
67
+ agentId: import("convex/values").GenericId<"agents">;
68
+ habitId: import("convex/values").GenericId<"habits">;
69
+ ranAt: number;
70
+ }[]>>;