@vantageos/agent-engine 0.1.0-alpha.1 → 0.1.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -39,7 +39,8 @@ ligne"** below, in this table and in the code comments next to the field.
39
39
  | MCP/OpenAPI connections (`defineMcpClientConnection`) | `public/definitions/connections/mcp.ts:23-48` | `connections` child table | direct parity. Our VantagePeers tools (memory, tasks, messages, notes) are wired here as an MCP connection, on by default — **notre ligne**, mvp §2.2 |
40
40
  | Declared subagents, root-only `agent` tool | https://eve.dev/docs/subagents | `subagents` child table (`parentAgentId` -> `childAgentId`, recursive) | direct parity. **Isolation strict, "inherits nothing from the root's authored slots"** — a subagent row only declares the link + exposed tool name; it never inlines the parent's skills/connections/approvals |
41
41
  | `sandbox` | `agent-definition.ts:150-160` | `sandboxConfig` child table (Vercel Sandbox, egress policy, allowlist) | direct parity, I0 §8 |
42
- | `schedules` / hooks -> "habits" | `manifest.ts:143`, `:726` | `habits` child table (dynamic cron per agent/org, `@convex-dev/crons`) | **notre ligne (naming)** — Eve calls these schedules/hooks; we call them habits (product decision) and back them with runtime-registered crons instead of static config |
42
+ | `schedules` / hooks -> "habits" | `manifest.ts:143`, `:726` | `habits` + `habitRuns` child tables (dynamic cron per agent/org, `@convex-dev/crons`, see "Mandates & habits (T4)" below) | **notre ligne (naming + mechanism)** — Eve calls these schedules/hooks; we call them habits (product decision) and back them with runtime-registered crons instead of static config |
43
+ | *(no equivalent)* — bounded per-agent authority | not present in `vercel/eve` | `mandates` + `approvalRequests` child tables (`@convex-dev/rate-limiter` + `@convex-dev/sharded-counter`, see "Mandates & habits (T4)" below) | **notre ligne** — SYNTHESE §2 "la réponse à la peur de lâcher les commandes"; a weighted, data-driven spending cap per org+agent+scope, overrun => human approval request, never a silent workaround |
43
44
  | Session/turn resolver boundaries (`ALLOWED_DYNAMIC_INSTRUCTION_EVENTS = {session.started, turn.started}`) | `dynamic-tool-definition.ts:40-46` | `sessionEvents.name` union (`session.started`, `turn.started`, ...) + `engine/resolvers.ts:resolveManifest` | direct parity — same event names, same "reread the aggregate, never cache" contract |
44
45
  | `subagents` used for inter-agent collaboration | eve docs | **not used** — collaboration goes through VantagePeers MCP tools instead | **notre ligne** — explicit Laurent decision (mvp-evevantage.md §2.5): "la collaboration entre agents n'arrive pas par les `subagents` d'eve" |
45
46
  | `outputSchema`, `compaction`, `modelOptions`, `channels` | `agent-definition.ts:124-146,313-330`, `manifest.ts:56-77` | out of scope this lot | left for a later I-cycle, documented as deliberately deferred (mvp §2.5) |
@@ -53,10 +54,11 @@ Child tables (>= 7, every index starts with `orgId`):
53
54
  1. `skills` — contextual procedures
54
55
  2. `subagents` — recursive declared delegation, strict isolation
55
56
  3. `connections` — MCP/OpenAPI (VantagePeers tools included)
56
- 4. `habits` — dynamic crons (habits, notre ligne naming)
57
+ 4. `habits` (+ `habitRuns`) — dynamic crons (habits, notre ligne, T4)
57
58
  5. `sandboxConfig` — Vercel Sandbox settings
58
59
  6. `toolApprovals` — `always` / `once` / `never` per tool
59
60
  7. `modelKeys` — BYOK, server-only, split from `agents`
61
+ 8. `mandates` (+ `approvalRequests`) — bounded authority (notre ligne, T4)
60
62
 
61
63
  Engine tables: `sessions`, `sessionEvents`, `awaitEventTimeouts`.
62
64
 
@@ -126,6 +128,72 @@ reads without needing to know our internals):
126
128
  job is marked `abandoned` with `abandonedAtStep` + `lastError`, and no
127
129
  further step runs.
128
130
 
131
+ ## Mandates & habits (T4) — NOTRE LIGNE, EveVantage's two product differentiators
132
+
133
+ SYNTHESE.md §2: *"Deux arguments de vente que personne n'a"* — mandates
134
+ ("cet agent peut engager jusqu'à X ; au-delà, il me demande") and habits
135
+ ("tous les matins, relève les mails, classe, fais le point"). Both are
136
+ **declared divergences from `vercel/eve`** — Eve has no concept of a
137
+ weighted spending cap or a runtime-editable recurrence; this is our line,
138
+ not a silent gap.
139
+
140
+ ### Mandates — `convex/mandates.ts` (`mandates`, `approvalRequests` tables)
141
+
142
+ **Notre ligne**: bounded authority per agent+org+scope. A mandate is a
143
+ DATA ROW (`mandates.{kind,rate,period,capacity}`), never a constant in
144
+ code — a client changing their mind is a `mandates.set` mutation, zero
145
+ deploy. `spend(agentId, scope, cost, reason)` is the single choke point
146
+ every costed action must pass through:
147
+
148
+ - **fails-closed**: no mandate row for `orgId+agentId+scope` => throws
149
+ immediately (`Mandate refused: no mandate configured for scope "..."`).
150
+ There is no "unlimited by default" path.
151
+ - **overrun => human approval, never a silent workaround**: when
152
+ `@convex-dev/rate-limiter`'s `limit()` (called with an **inline dynamic
153
+ `config`** built from the DB row — see rate-limiter README "Define a
154
+ rate limit inline / dynamically") returns `ok: false`, `spend` inserts
155
+ an `approvalRequests` row (`status: "pending"`) and returns
156
+ `{ ok: false, approvalId }`. It deliberately does **not** throw on this
157
+ path: Convex mutations are single transactions, and throwing after
158
+ `ctx.db.insert` would roll the insert back along with everything else —
159
+ destroying the very approval record the guard exists to leave behind.
160
+ Callers (the session/workflow engine) are REQUIRED to check `.ok` and
161
+ treat `false` as a hard refusal; the only way authority is restored is
162
+ an explicit human `resolveApproval(approvalId, "approved", resolvedBy)`.
163
+ - **rollups via `@convex-dev/sharded-counter`** (`usageCount` query), one
164
+ bucket per `orgId:agentId:scope` key — I0 §7.4: no canary/alpha
165
+ dependency for a guardrail. `@convex-dev/aggregate` (also I0-approved,
166
+ also official, also no canary) is the natural next step for time-
167
+ windowed billing rollups; not wired in this lot, called out here rather
168
+ than silently left out.
169
+ - `count` passed to `rateLimiter.limit` is a WEIGHTED cost (tokens, euros,
170
+ calls — whatever the scope means), never a bare call counter.
171
+
172
+ ### Habits — `convex/habits.ts` (`habits`, `habitRuns` tables)
173
+
174
+ **Notre ligne (naming + mechanism)**: Eve's closest concept is
175
+ `schedules`/`hooks`, statically declared in a compiled agent. Habits are
176
+ runtime DATA: `habits.cronExpression` is a column, and the actual
177
+ recurrence is a **dynamically registered `@convex-dev/crons` job**
178
+ (`Crons.register`/`.delete`, never a static `convex/crons.ts` entry).
179
+
180
+ - `create` writes the habit row and registers its cron in the SAME
181
+ mutation transaction — `@convex-dev/crons` guarantees the cron "is
182
+ guaranteed to exist after the mutation that creates them has run"
183
+ (README), so the very next tick can fire it with zero deploy.
184
+ - `updateSchedule` edits `cronExpression`/`prompt`/`name` at runtime:
185
+ deletes the old cron registration, registers a fresh one from the new
186
+ cadence, still inside one transaction.
187
+ - `disable` is a HARD stop: it deletes the runtime cron registration
188
+ (not a soft `enabled` flag the target function checks) — after it
189
+ resolves there is no scheduled function left that could fire the habit.
190
+ `run` (the cron-invoked internal mutation) also re-checks `enabled` as
191
+ defence in depth for any run already in flight.
192
+ - `enable` re-registers from the habit's own `cronExpression` data.
193
+ - Every tick writes a `habitRuns` proof row — this is what makes "fires
194
+ its first run without a deploy" and "a disabled habit does not fire
195
+ again" PROVABLE in `habits.test.ts` rather than asserted on trust.
196
+
129
197
  ## `convex/_generated/` freshness -- two gates, not one
130
198
 
131
199
  `convex/_generated/api.d.ts` carries an "AUTOMATICALLY GENERATED" header
@@ -215,16 +283,32 @@ that all contributors run) is Pi's to make, not this PR's.
215
283
  interruption); a step that always fails is retried and the job is
216
284
  `abandoned` (never touching the next step); a step that fails once then
217
285
  succeeds still reaches `completed`; cross-org `getStatus` is denied.
286
+ - `convex/mandates.test.ts` — mandates, three-pole probe: MUST_PASS (spend
287
+ under cap succeeds, rollup counts it), MUST_BLOCK (spend at cap is
288
+ refused, `approvalRequests` row created), MUST_REFUSE (no mandate
289
+ configured => fails-closed, names the missing scope, no approval row
290
+ created) + org isolation + human `resolveApproval`.
291
+ - `convex/habits.test.ts` — habits, three-pole probe: MUST_PASS (a habit
292
+ created at runtime fires its first run with zero deploy), MUST_BLOCK (a
293
+ disabled habit does not fire again after further clock advances),
294
+ MUST_REFUSE (`enable` on an already-enabled habit is a documented
295
+ no-op, not a silent double-registration) + full runtime lifecycle
296
+ (create / updateSchedule / disable / enable, no redeploy at any step).
297
+ - `component/durableJob.componentPackaging.test.ts` — the SAME contract
298
+ (long job survives, abandon-after-N, org isolation, cancel), but run
299
+ against `component/_generated/api` — the exact source tree compiled to
300
+ `dist/component/` and published — proving the migrated, packaged code
301
+ itself, not only the repo-root dev app.
218
302
 
219
303
  Run: `npx vitest run` (or `npm test`).
220
304
 
221
- ## Packaging & publication (T2-TER)
305
+ ## Packaging & publication (T2-TER, functions since T2-QUATER)
222
306
 
223
307
  `@vantageos/agent-engine` is published to npm under the `alpha` dist-tag
224
308
  (`npm view @vantageos/agent-engine version` / `dist-tags`, read from the
225
309
  registry after publish, never from `npm publish`'s own exit status). The
226
310
  package exposes a resolvable `"./convex.config"` subpath (types + JS,
227
- built by `npm run build` from `convex/component/convex.config.ts` via
311
+ built by `npm run build` from `component/convex.config.ts` via
228
312
  `tsc -p tsconfig.build.json` into `dist/component/`), so a consumer's
229
313
  `convex/convex.config.ts` can do:
230
314
 
@@ -237,21 +321,118 @@ app.use(agentEngine);
237
321
  export default app;
238
322
  ```
239
323
 
240
- **Known remaining gap, stated here where it is read (not only in a
241
- message):** `convex/component/convex.config.ts` currently declares only
242
- the component's identity (`defineComponent("agentEngine")`) and its
243
- sub-component composition (workflow + 2 workpools + agent). It does not
244
- yet re-host this repo's schema/functions (`convex/schema.ts`,
245
- `convex/agents.ts`, `convex/skills.ts`, `convex/engine/**`) inside the
246
- component boundary, so `components.agentEngine.engine.durableJob.*` etc.
247
- are not yet callable from a consumer through the published component --
248
- see `examples/vantage-peers-long-task/README.md` "Packaging note" for the
249
- full detail and exactly what remains.
324
+ ### What's callable, and what isn't (read this before wiring a consumer)
325
+
326
+ Since T2-QUATER, `component/` (sibling of `convex/`, NOT nested under it —
327
+ see "Why `component/` and not `convex/component/`" below) hosts the
328
+ **actual, compiled, published functions** for a real slice of the engine,
329
+ not just the component's identity. T2-QUINQUIES widens this to the
330
+ SESSIONS surface — EveVantage V4's conversation thread.
331
+
332
+ - `component/schema.ts` — `durableJobs`, `agents`, `toolApprovals`,
333
+ `sessions`, `sessionEvents` (+ a test-only `callerStepInvocations`
334
+ fixture table).
335
+ - `component/engine/durableJob.ts` — `start` / `getStatus` / `cancel`.
336
+ - `component/engine/agents.ts` — `create` / `get` (minimal root-sheet
337
+ bootstrap; no `update`/`list`/skills/connections in this pass).
338
+ - `component/engine/resolvers.ts` — `resolveManifest` (dynamic reread at
339
+ session/turn boundaries; returns `agentId`/`name`/`instructions`/`model`/
340
+ `toolApprovals` — `skills`/`connections` NOT included in this pass).
341
+ - `component/engine/sessions.ts` — the conversation thread contract.
342
+ - `component/engine/toolApprovals.ts` — `respond`.
343
+ - `component/lib/auth.ts` — `requireOrgId` / `assertSameOrg`: orgId is
344
+ derived server-side and is the first field of every index; deny by
345
+ default travels WITH the component, not just with this repo's own app.
346
+
347
+ **Callable through the published component today** (function signatures —
348
+ all args/returns are explicit Convex validators, see the source files
349
+ above for the exact `v.*` shapes):
350
+
351
+ ```
352
+ components.agentEngine.engine.durableJob.start({ kind, stepFunctionHandle, totalSteps, maxAttemptsPerStep }) -> Id<"durableJobs">
353
+ components.agentEngine.engine.durableJob.getStatus({ jobId }) -> { status, cursor, totalSteps, lastError?, abandonedAtStep? }
354
+ components.agentEngine.engine.durableJob.cancel({ jobId }) -> null
355
+
356
+ components.agentEngine.engine.agents.create({ name, instructions, model }) -> Id<"agents">
357
+ components.agentEngine.engine.agents.get({ agentId }) -> agent | null
358
+
359
+ components.agentEngine.engine.resolvers.resolveManifest({ sessionId }) -> { agentId, name, instructions, model, toolApprovals[] }
360
+
361
+ components.agentEngine.engine.sessions.start({ agentId }) -> Id<"sessions"> // session.started
362
+ components.agentEngine.engine.sessions.sendTurn({ sessionId, input }) -> null // turn.started, rereads resolveManifest
363
+ components.agentEngine.engine.sessions.appendReasoning({ sessionId, chunk }) -> null // streamed reasoning event
364
+ components.agentEngine.engine.sessions.requestToolCall({ sessionId, toolName, argsJson }) -> { authorized, approvalPending }
365
+ components.agentEngine.engine.sessions.completeToolCall({ sessionId, toolName, resultJson }) -> null
366
+ components.agentEngine.engine.sessions.completeTurn({ sessionId }) -> null // turn.completed
367
+ components.agentEngine.engine.sessions.listEvents({ sessionId }) -> sessionEvent[] // replay on reconnect (ordered by createdAt)
368
+
369
+ components.agentEngine.engine.toolApprovals.respond({ sessionId, toolName, approval: "always"|"once"|"never" }) -> null
370
+ ```
371
+
372
+ Streaming model: `sessionEvents` IS the transport. Convex query
373
+ subscriptions on `sessions.listEvents` push every new row (reasoning
374
+ chunk, tool-call lifecycle, approval lifecycle) to every subscriber live —
375
+ there is no separate streaming channel to wire. A client that reconnects
376
+ calls `listEvents` once to rebuild the whole thread, then keeps
377
+ subscribing.
378
+
379
+ Tool-approval gate (`toolApprovals.approval`, default `"never"`):
380
+ `"never"` never pauses; `"always"` pauses (raises
381
+ `tool.approval.requested`) on every `requestToolCall`; `"once"` pauses
382
+ unless `tool.approval.resolved` for that tool was already recorded EARLIER
383
+ IN THE SAME SESSION. `toolApprovals.respond` both writes the standing
384
+ policy (upsert on `orgId`+`agentId`+`toolName`) and appends
385
+ `tool.approval.resolved` for the calling session.
386
+
387
+ Verified two ways, same discipline as T2-QUATER: (1)
388
+ `component/durableJob.componentPackaging.test.ts` +
389
+ `component/sessions.componentPackaging.test.ts` run `convex-test` directly
390
+ against `component/_generated/api` (the exact source tree
391
+ `tsc -p tsconfig.build.json` compiles into `dist/component/`, which is
392
+ what `npm pack` ships); (2) a from-scratch consumer probe (install the
393
+ published tarball into a bare `npx convex dev` project, register the
394
+ component, call `sessions.start`/`sendTurn` from the consumer's own
395
+ function, confirm unauthenticated calls throw from the package's own
396
+ `lib/auth`) — see the T2-QUINQUIES completion report for the verbatim
397
+ transcript.
398
+
399
+ **NOT yet callable through the published component** (still only exists in
400
+ this repo's OWN dev/test deployment under `convex/schema.ts` +
401
+ `convex/agents.ts` + `convex/skills.ts`, used by `npx convex dev` and the
402
+ repo-root `convex-test` suite): `skills`, `connections`, `subagents`,
403
+ `habits`, `sandboxConfig`, `modelKeys`, `mandates`, `approvalRequests`,
404
+ `awaitEventTimeouts`, `wakeableWork`, `engine/wakeup.ts`,
405
+ `engine/workflows.ts` (`sessionWorkflowV1` — this pass's `sessions` is
406
+ deliberately NOT tied to a `@convex-dev/workflow` run; see
407
+ `component/schema.ts`'s `sessions` table comment for why). Porting each of
408
+ those under `component/` without a working component-level `convex-test`
409
+ harness behind it would ship unverified code — Day 128 forbids that; it is
410
+ deliberately left for the next, separately-scoped migration.
411
+
412
+ ### Why `component/` and not `convex/component/`
413
+
414
+ `npx convex codegen --component-dir <path>` builds a synthetic root app
415
+ that does `import component from "<relative-import-to-path>"`. When
416
+ `<path>` is nested INSIDE the functions directory it resolves from
417
+ (`convex/`), that relative import comes out as a bare specifier with no
418
+ leading `./` or `../` (e.g. `"component/convex.config.js"`), which esbuild
419
+ correctly refuses to resolve as a relative path — not a bug in our code,
420
+ a corner case of running `--component-dir` against a directory nested
421
+ under the default functions directory. Moving the component's source tree
422
+ one level up, to `component/` (a sibling of `convex/`, mirroring how
423
+ `@convex-dev/workflow` itself keeps its component source under `src/component`,
424
+ outside its `example/convex` app directory) makes the generated relative
425
+ import start with `../`, which resolves — measured empirically against
426
+ this exact repo layout, not guessed.
250
427
 
251
428
  ## Status
252
429
 
253
430
  T1 (schema + durable session engine, PR #1) merged @
254
431
  `9f3401ba63e6e663af95e9e4f5da42bc30b3550b`. I1 (long-task survival
255
- contract, `engine/durableJob.ts`) — not merged, Eta reviews, merge on Pi
256
- token. T2-TER (this PR, npm packaging + component identity + publication)
257
- — see "Packaging & publication" above; **not merged**.
432
+ contract, `engine/durableJob.ts`) — not merged, Eta reviews. T4 (mandates
433
+ + habits) — **not merged** — Eta reviews, merge on Pi token. T2-TER (npm
434
+ packaging + component identity + publication) and T2-QUATER (this pass:
435
+ migrated `durableJob` + its schema + `lib/auth.ts` under the actual
436
+ component boundary, `component/`, with its own `_generated/` and its own
437
+ green `convex-test` suite) — see "Packaging & publication" above; **not
438
+ merged**.
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Generated `api` utility.
3
+ *
4
+ * THIS CODE IS AUTOMATICALLY GENERATED.
5
+ *
6
+ * To regenerate, run `npx convex dev`.
7
+ * @module
8
+ */
9
+ import type * as engine_agents from "../engine/agents.js";
10
+ import type * as engine_durableJob from "../engine/durableJob.js";
11
+ import type * as engine_resolvers from "../engine/resolvers.js";
12
+ import type * as engine_sessions from "../engine/sessions.js";
13
+ import type * as engine_toolApprovals from "../engine/toolApprovals.js";
14
+ import type * as lib_auth from "../lib/auth.js";
15
+ import type * as testFixtures_callerSteps from "../testFixtures/callerSteps.js";
16
+ import type { ApiFromModules, FilterApi, FunctionReference } from "convex/server";
17
+ declare const fullApi: ApiFromModules<{
18
+ "engine/agents": typeof engine_agents;
19
+ "engine/durableJob": typeof engine_durableJob;
20
+ "engine/resolvers": typeof engine_resolvers;
21
+ "engine/sessions": typeof engine_sessions;
22
+ "engine/toolApprovals": typeof engine_toolApprovals;
23
+ "lib/auth": typeof lib_auth;
24
+ "testFixtures/callerSteps": typeof testFixtures_callerSteps;
25
+ }>;
26
+ /**
27
+ * A utility for referencing Convex functions in your app's public API.
28
+ *
29
+ * Usage:
30
+ * ```js
31
+ * const myFunctionReference = api.myModule.myFunction;
32
+ * ```
33
+ */
34
+ export declare const api: FilterApi<typeof fullApi, FunctionReference<any, "public">>;
35
+ /**
36
+ * A utility for referencing Convex functions in your app's internal API.
37
+ *
38
+ * Usage:
39
+ * ```js
40
+ * const myFunctionReference = internal.myModule.myFunction;
41
+ * ```
42
+ */
43
+ export declare const internal: FilterApi<typeof fullApi, FunctionReference<any, "internal">>;
44
+ export declare const components: {
45
+ workflow: import("@convex-dev/workflow/_generated/component.js").ComponentApi<"workflow">;
46
+ agentTurnPool: import("@convex-dev/workpool/_generated/component.js").ComponentApi<"agentTurnPool">;
47
+ wakeupPool: import("@convex-dev/workpool/_generated/component.js").ComponentApi<"wakeupPool">;
48
+ agent: import("@convex-dev/agent/_generated/component.js").ComponentApi<"agent">;
49
+ };
50
+ export {};
@@ -0,0 +1,30 @@
1
+ /* eslint-disable */
2
+ /**
3
+ * Generated `api` utility.
4
+ *
5
+ * THIS CODE IS AUTOMATICALLY GENERATED.
6
+ *
7
+ * To regenerate, run `npx convex dev`.
8
+ * @module
9
+ */
10
+ import { anyApi, componentsGeneric } from "convex/server";
11
+ const fullApi = anyApi;
12
+ /**
13
+ * A utility for referencing Convex functions in your app's public API.
14
+ *
15
+ * Usage:
16
+ * ```js
17
+ * const myFunctionReference = api.myModule.myFunction;
18
+ * ```
19
+ */
20
+ export const api = anyApi;
21
+ /**
22
+ * A utility for referencing Convex functions in your app's internal API.
23
+ *
24
+ * Usage:
25
+ * ```js
26
+ * const myFunctionReference = internal.myModule.myFunction;
27
+ * ```
28
+ */
29
+ export const internal = anyApi;
30
+ export const components = componentsGeneric();
@@ -0,0 +1,124 @@
1
+ /**
2
+ * Generated `ComponentApi` utility.
3
+ *
4
+ * THIS CODE IS AUTOMATICALLY GENERATED.
5
+ *
6
+ * To regenerate, run `npx convex dev`.
7
+ * @module
8
+ */
9
+ import type { FunctionReference } from "convex/server";
10
+ /**
11
+ * A utility for referencing a Convex component's exposed API.
12
+ *
13
+ * Useful when expecting a parameter like `components.myComponent`.
14
+ * Usage:
15
+ * ```ts
16
+ * async function myFunction(ctx: QueryCtx, component: ComponentApi) {
17
+ * return ctx.runQuery(component.someFile.someQuery, { ...args });
18
+ * }
19
+ * ```
20
+ */
21
+ export type ComponentApi<Name extends string | undefined = string | undefined> = {
22
+ engine: {
23
+ agents: {
24
+ create: FunctionReference<"mutation", "internal", {
25
+ instructions: string;
26
+ model: string;
27
+ name: string;
28
+ }, string, Name>;
29
+ get: FunctionReference<"query", "internal", {
30
+ agentId: string;
31
+ }, {
32
+ _creationTime: number;
33
+ _id: string;
34
+ createdAt: number;
35
+ createdBy: string;
36
+ instructions: string;
37
+ model: string;
38
+ name: string;
39
+ orgId: string;
40
+ status: "draft" | "live" | "archived";
41
+ updatedAt: number;
42
+ } | null, Name>;
43
+ };
44
+ durableJob: {
45
+ cancel: FunctionReference<"mutation", "internal", {
46
+ jobId: string;
47
+ }, null, Name>;
48
+ getStatus: FunctionReference<"query", "internal", {
49
+ jobId: string;
50
+ }, {
51
+ abandonedAtStep?: number;
52
+ cursor: number;
53
+ lastError?: string;
54
+ status: "running" | "completed" | "abandoned" | "cancelled";
55
+ totalSteps: number;
56
+ }, Name>;
57
+ start: FunctionReference<"mutation", "internal", {
58
+ kind: string;
59
+ maxAttemptsPerStep: number;
60
+ stepFunctionHandle: string;
61
+ totalSteps: number;
62
+ }, string, Name>;
63
+ };
64
+ resolvers: {
65
+ resolveManifest: FunctionReference<"query", "internal", {
66
+ sessionId: string;
67
+ }, {
68
+ agentId: string;
69
+ instructions: string;
70
+ model: string;
71
+ name: string;
72
+ toolApprovals: Array<{
73
+ approval: "always" | "once" | "never";
74
+ toolName: string;
75
+ }>;
76
+ }, Name>;
77
+ };
78
+ sessions: {
79
+ appendReasoning: FunctionReference<"mutation", "internal", {
80
+ chunk: string;
81
+ sessionId: string;
82
+ }, null, Name>;
83
+ completeToolCall: FunctionReference<"mutation", "internal", {
84
+ resultJson: string;
85
+ sessionId: string;
86
+ toolName: string;
87
+ }, null, Name>;
88
+ completeTurn: FunctionReference<"mutation", "internal", {
89
+ sessionId: string;
90
+ }, null, Name>;
91
+ listEvents: FunctionReference<"query", "internal", {
92
+ sessionId: string;
93
+ }, Array<{
94
+ _creationTime: number;
95
+ _id: string;
96
+ createdAt: number;
97
+ name: "session.started" | "turn.started" | "turn.reasoning" | "turn.toolCall.requested" | "turn.toolCall.completed" | "turn.completed" | "tool.approval.requested" | "tool.approval.resolved";
98
+ payload?: string;
99
+ }>, Name>;
100
+ requestToolCall: FunctionReference<"mutation", "internal", {
101
+ argsJson: string;
102
+ sessionId: string;
103
+ toolName: string;
104
+ }, {
105
+ approvalPending: boolean;
106
+ authorized: boolean;
107
+ }, Name>;
108
+ sendTurn: FunctionReference<"mutation", "internal", {
109
+ input: string;
110
+ sessionId: string;
111
+ }, null, Name>;
112
+ start: FunctionReference<"mutation", "internal", {
113
+ agentId: string;
114
+ }, string, Name>;
115
+ };
116
+ toolApprovals: {
117
+ respond: FunctionReference<"mutation", "internal", {
118
+ approval: "always" | "once" | "never";
119
+ sessionId: string;
120
+ toolName: string;
121
+ }, null, Name>;
122
+ };
123
+ };
124
+ };
@@ -0,0 +1,10 @@
1
+ /* eslint-disable */
2
+ /**
3
+ * Generated `ComponentApi` utility.
4
+ *
5
+ * THIS CODE IS AUTOMATICALLY GENERATED.
6
+ *
7
+ * To regenerate, run `npx convex dev`.
8
+ * @module
9
+ */
10
+ export {};
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Generated data model types.
3
+ *
4
+ * THIS CODE IS AUTOMATICALLY GENERATED.
5
+ *
6
+ * To regenerate, run `npx convex dev`.
7
+ * @module
8
+ */
9
+ import type { DataModelFromSchemaDefinition, DocumentByName, TableNamesInDataModel, SystemTableNames } from "convex/server";
10
+ import type { GenericId } from "convex/values";
11
+ import schema from "../schema.js";
12
+ /**
13
+ * The names of all of your Convex tables.
14
+ */
15
+ export type TableNames = TableNamesInDataModel<DataModel>;
16
+ /**
17
+ * The type of a document stored in Convex.
18
+ *
19
+ * @typeParam TableName - A string literal type of the table name (like "users").
20
+ */
21
+ export type Doc<TableName extends TableNames> = DocumentByName<DataModel, TableName>;
22
+ /**
23
+ * An identifier for a document in Convex.
24
+ *
25
+ * Convex documents are uniquely identified by their `Id`, which is accessible
26
+ * on the `_id` field. To learn more, see [Document IDs](https://docs.convex.dev/using/document-ids).
27
+ *
28
+ * Documents can be loaded using `db.get(tableName, id)` in query and mutation functions.
29
+ *
30
+ * IDs are just strings at runtime, but this type can be used to distinguish them from other
31
+ * strings when type checking.
32
+ *
33
+ * @typeParam TableName - A string literal type of the table name (like "users").
34
+ */
35
+ export type Id<TableName extends TableNames | SystemTableNames> = GenericId<TableName>;
36
+ /**
37
+ * A type describing your Convex data model.
38
+ *
39
+ * This type includes information about what tables you have, the type of
40
+ * documents stored in those tables, and the indexes defined on them.
41
+ *
42
+ * This type is used to parameterize methods like `queryGeneric` and
43
+ * `mutationGeneric` to make them type-safe.
44
+ */
45
+ export type DataModel = DataModelFromSchemaDefinition<typeof schema>;
@@ -0,0 +1,10 @@
1
+ /* eslint-disable */
2
+ /**
3
+ * Generated data model types.
4
+ *
5
+ * THIS CODE IS AUTOMATICALLY GENERATED.
6
+ *
7
+ * To regenerate, run `npx convex dev`.
8
+ * @module
9
+ */
10
+ export {};
@@ -0,0 +1,120 @@
1
+ /**
2
+ * Generated utilities for implementing server-side Convex query and mutation functions.
3
+ *
4
+ * THIS CODE IS AUTOMATICALLY GENERATED.
5
+ *
6
+ * To regenerate, run `npx convex dev`.
7
+ * @module
8
+ */
9
+ import type { ActionBuilder, HttpActionBuilder, MutationBuilder, QueryBuilder, GenericActionCtx, GenericMutationCtx, GenericQueryCtx, GenericDatabaseReader, GenericDatabaseWriter } from "convex/server";
10
+ import type { DataModel } from "./dataModel.js";
11
+ /**
12
+ * Define a query in this Convex app's public API.
13
+ *
14
+ * This function will be allowed to read your Convex database and will be accessible from the client.
15
+ *
16
+ * @param func - The query function. It receives a {@link QueryCtx} as its first argument.
17
+ * @returns The wrapped query. Include this as an `export` to name it and make it accessible.
18
+ */
19
+ export declare const query: QueryBuilder<DataModel, "public">;
20
+ /**
21
+ * Define a query that is only accessible from other Convex functions (but not from the client).
22
+ *
23
+ * This function will be allowed to read from your Convex database. It will not be accessible from the client.
24
+ *
25
+ * @param func - The query function. It receives a {@link QueryCtx} as its first argument.
26
+ * @returns The wrapped query. Include this as an `export` to name it and make it accessible.
27
+ */
28
+ export declare const internalQuery: QueryBuilder<DataModel, "internal">;
29
+ /**
30
+ * Define a mutation in this Convex app's public API.
31
+ *
32
+ * This function will be allowed to modify your Convex database and will be accessible from the client.
33
+ *
34
+ * @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
35
+ * @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
36
+ */
37
+ export declare const mutation: MutationBuilder<DataModel, "public">;
38
+ /**
39
+ * Define a mutation that is only accessible from other Convex functions (but not from the client).
40
+ *
41
+ * This function will be allowed to modify your Convex database. It will not be accessible from the client.
42
+ *
43
+ * @param func - The mutation function. It receives a {@link MutationCtx} as its first argument.
44
+ * @returns The wrapped mutation. Include this as an `export` to name it and make it accessible.
45
+ */
46
+ export declare const internalMutation: MutationBuilder<DataModel, "internal">;
47
+ /**
48
+ * Define an action in this Convex app's public API.
49
+ *
50
+ * An action is a function which can execute any JavaScript code, including non-deterministic
51
+ * code and code with side-effects, like calling third-party services.
52
+ * They can be run in Convex's JavaScript environment or in Node.js using the "use node" directive.
53
+ * They can interact with the database indirectly by calling queries and mutations using the {@link ActionCtx}.
54
+ *
55
+ * @param func - The action. It receives an {@link ActionCtx} as its first argument.
56
+ * @returns The wrapped action. Include this as an `export` to name it and make it accessible.
57
+ */
58
+ export declare const action: ActionBuilder<DataModel, "public">;
59
+ /**
60
+ * Define an action that is only accessible from other Convex functions (but not from the client).
61
+ *
62
+ * @param func - The function. It receives an {@link ActionCtx} as its first argument.
63
+ * @returns The wrapped function. Include this as an `export` to name it and make it accessible.
64
+ */
65
+ export declare const internalAction: ActionBuilder<DataModel, "internal">;
66
+ /**
67
+ * Define an HTTP action.
68
+ *
69
+ * The wrapped function will be used to respond to HTTP requests received
70
+ * by a Convex deployment if the requests matches the path and method where
71
+ * this action is routed. Be sure to route your httpAction in `convex/http.js`.
72
+ *
73
+ * @param func - The function. It receives an {@link ActionCtx} as its first argument
74
+ * and a Fetch API `Request` object as its second.
75
+ * @returns The wrapped function. Import this function from `convex/http.js` and route it to hook it up.
76
+ */
77
+ export declare const httpAction: HttpActionBuilder;
78
+ /**
79
+ * A set of services for use within Convex query functions.
80
+ *
81
+ * The query context is passed as the first argument to any Convex query
82
+ * function run on the server.
83
+ *
84
+ * If you're using code generation, use the `QueryCtx` type in `convex/_generated/server.d.ts` instead.
85
+ */
86
+ export type QueryCtx = GenericQueryCtx<DataModel>;
87
+ /**
88
+ * A set of services for use within Convex mutation functions.
89
+ *
90
+ * The mutation context is passed as the first argument to any Convex mutation
91
+ * function run on the server.
92
+ *
93
+ * If you're using code generation, use the `MutationCtx` type in `convex/_generated/server.d.ts` instead.
94
+ */
95
+ export type MutationCtx = GenericMutationCtx<DataModel>;
96
+ /**
97
+ * A set of services for use within Convex action functions.
98
+ *
99
+ * The action context is passed as the first argument to any Convex action
100
+ * function run on the server.
101
+ */
102
+ export type ActionCtx = GenericActionCtx<DataModel>;
103
+ /**
104
+ * An interface to read from the database within Convex query functions.
105
+ *
106
+ * The two entry points are {@link DatabaseReader.get}, which fetches a single
107
+ * document by its {@link Id}, or {@link DatabaseReader.query}, which starts
108
+ * building a query.
109
+ */
110
+ export type DatabaseReader = GenericDatabaseReader<DataModel>;
111
+ /**
112
+ * An interface to read from and write to the database within Convex mutation
113
+ * functions.
114
+ *
115
+ * Convex guarantees that all writes within a single mutation are
116
+ * executed atomically, so you never have to worry about partial writes leaving
117
+ * your data in an inconsistent state. See [the Convex Guide](https://docs.convex.dev/understanding/convex-fundamentals/functions#atomicity-and-optimistic-concurrency-control)
118
+ * for the guarantees Convex provides your functions.
119
+ */
120
+ export type DatabaseWriter = GenericDatabaseWriter<DataModel>;