@vantageos/agent-engine 0.3.0-alpha.0 → 0.3.0-alpha.1

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
@@ -106,7 +106,7 @@ components.agentEngine.engine.resolvers.resolveManifest({
106
106
  components.agentEngine.engine.sessions.start({
107
107
  orgId, agentId, createdBy,
108
108
  }) -> { sessionId: string /* the world runId */, workflowId: string }
109
- // 0.3.0: every `sessionId` below IS that runId (string); an unknown, legacy,
109
+ // 0.3.0: every `sessionId` below IS that runId (string); an unknown,
110
110
  // cross-org or non-session id is refused as "Session not found".
111
111
  components.agentEngine.engine.sessions.sendTurn({
112
112
  orgId, sessionId, input,
@@ -1,3 +1,11 @@
1
+ /**
2
+ * Generated `api` utility.
3
+ *
4
+ * THIS CODE IS AUTOMATICALLY GENERATED.
5
+ *
6
+ * To regenerate, run `npx convex dev`.
7
+ * @module
8
+ */
1
9
  import type * as engine_agents from "../engine/agents.js";
2
10
  import type * as engine_awaitEventTimeout from "../engine/awaitEventTimeout.js";
3
11
  import type * as engine_connections from "../engine/connections.js";
@@ -20,7 +28,7 @@ import type * as lib_auth from "../lib/auth.js";
20
28
  import type * as lib_connectionSecret from "../lib/connectionSecret.js";
21
29
  import type * as testFixtures_callerSteps from "../testFixtures/callerSteps.js";
22
30
  import type * as testFixtures_delegationDemoWorkflow from "../testFixtures/delegationDemoWorkflow.js";
23
- import type * as testFixtures_legacyBind from "../testFixtures/legacyBind.js";
31
+ import type * as testFixtures_runBinding from "../testFixtures/runBinding.js";
24
32
  import type * as testFixtures_sandboxDemoWorkflow from "../testFixtures/sandboxDemoWorkflow.js";
25
33
  import type * as testFixtures_vpTool from "../testFixtures/vpTool.js";
26
34
  import type * as testFixtures_wakeupDemoWorkflow from "../testFixtures/wakeupDemoWorkflow.js";
@@ -49,13 +57,29 @@ declare const fullApi: ApiFromModules<{
49
57
  "lib/connectionSecret": typeof lib_connectionSecret;
50
58
  "testFixtures/callerSteps": typeof testFixtures_callerSteps;
51
59
  "testFixtures/delegationDemoWorkflow": typeof testFixtures_delegationDemoWorkflow;
52
- "testFixtures/legacyBind": typeof testFixtures_legacyBind;
60
+ "testFixtures/runBinding": typeof testFixtures_runBinding;
53
61
  "testFixtures/sandboxDemoWorkflow": typeof testFixtures_sandboxDemoWorkflow;
54
62
  "testFixtures/vpTool": typeof testFixtures_vpTool;
55
63
  "testFixtures/wakeupDemoWorkflow": typeof testFixtures_wakeupDemoWorkflow;
56
64
  "testFixtures/wakeupWork": typeof testFixtures_wakeupWork;
57
65
  }>;
66
+ /**
67
+ * A utility for referencing Convex functions in your app's public API.
68
+ *
69
+ * Usage:
70
+ * ```js
71
+ * const myFunctionReference = api.myModule.myFunction;
72
+ * ```
73
+ */
58
74
  export declare const api: FilterApi<typeof fullApi, FunctionReference<any, "public">>;
75
+ /**
76
+ * A utility for referencing Convex functions in your app's internal API.
77
+ *
78
+ * Usage:
79
+ * ```js
80
+ * const myFunctionReference = internal.myModule.myFunction;
81
+ * ```
82
+ */
59
83
  export declare const internal: FilterApi<typeof fullApi, FunctionReference<any, "internal">>;
60
84
  export declare const components: {
61
85
  workflow: import("@convex-dev/workflow/_generated/component.js").ComponentApi<"workflow">;
@@ -1,4 +1,23 @@
1
+ /**
2
+ * Generated `ComponentApi` utility.
3
+ *
4
+ * THIS CODE IS AUTOMATICALLY GENERATED.
5
+ *
6
+ * To regenerate, run `npx convex dev`.
7
+ * @module
8
+ */
1
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
+ */
2
21
  export type ComponentApi<Name extends string | undefined = string | undefined> = {
3
22
  engine: {
4
23
  agents: {
@@ -1,7 +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
+ */
1
9
  import type { DataModelFromSchemaDefinition, DocumentByName, TableNamesInDataModel, SystemTableNames } from "convex/server";
2
10
  import type { GenericId } from "convex/values";
3
11
  import schema from "../schema.js";
12
+ /**
13
+ * The names of all of your Convex tables.
14
+ */
4
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
+ */
5
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
+ */
6
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
+ */
7
45
  export type DataModel = DataModelFromSchemaDefinition<typeof schema>;
@@ -1,14 +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
+ */
1
9
  import type { ActionBuilder, HttpActionBuilder, MutationBuilder, QueryBuilder, GenericActionCtx, GenericMutationCtx, GenericQueryCtx, GenericDatabaseReader, GenericDatabaseWriter } from "convex/server";
2
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
+ */
3
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
+ */
4
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
+ */
5
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
+ */
6
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
+ */
7
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
+ */
8
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
+ */
9
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
+ */
10
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
+ */
11
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
+ */
12
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
+ */
13
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
+ */
14
120
  export type DatabaseWriter = GenericDatabaseWriter<DataModel>;
@@ -23,10 +23,10 @@ export declare const get: import("convex/server").RegisteredQuery<"public", {
23
23
  maxInputTokensPerSession?: number | false | undefined;
24
24
  name: string;
25
25
  orgId: string;
26
- status: "draft" | "live" | "archived";
27
- createdAt: number;
28
- updatedAt: number;
29
26
  instructions: string;
30
27
  model: string;
28
+ status: "draft" | "live" | "archived";
31
29
  createdBy: string;
30
+ createdAt: number;
31
+ updatedAt: number;
32
32
  } | null>>;
@@ -3,7 +3,7 @@ import { internal } from "../_generated/api.js";
3
3
  import { internalMutation, mutation } from "../_generated/server.js";
4
4
  import { assertSameOrg, requireOrgId } from "../lib/auth.js";
5
5
  import { insertEvent, loadSessionRun } from "./sessions.js";
6
- import { findRunIdByCorrelation, legacyCorrelationId, legacySessionOf, loadRun, } from "./world.js";
6
+ import { findRunIdByCorrelation, legacyCorrelationId, loadRun, } from "./world.js";
7
7
  export const schedule = mutation({
8
8
  args: {
9
9
  orgId: v.string(),
@@ -15,14 +15,12 @@ export const schedule = mutation({
15
15
  handler: async (ctx, args) => {
16
16
  const orgId = requireOrgId(args.orgId);
17
17
  const run = await loadSessionRun(ctx, orgId, args.sessionId);
18
- const legacy = await legacySessionOf(ctx, run, orgId);
19
18
  if (args.timeoutMs <= 0) {
20
19
  throw new Error("Validation: timeoutMs must be > 0");
21
20
  }
22
21
  const timeoutRowId = await ctx.db.insert("awaitEventTimeouts", {
23
22
  orgId,
24
23
  runId: run.runId,
25
- sessionId: legacy?._id,
26
24
  awaitedEventName: args.awaitedEventName,
27
25
  deadlineAt: Date.now() + args.timeoutMs,
28
26
  });
@@ -57,11 +55,11 @@ export const fire = internalMutation({
57
55
  let runId = row.runId;
58
56
  if (runId === undefined && row.sessionId !== undefined) {
59
57
  runId =
60
- (await findRunIdByCorrelation(ctx, row.orgId, legacyCorrelationId("sessions", row.sessionId))) ?? undefined;
58
+ (await findRunIdByCorrelation(ctx, row.orgId, legacyCorrelationId("session", row.sessionId))) ?? undefined;
61
59
  }
62
60
  if (runId === undefined)
63
61
  return null;
64
- const run = await loadRun(ctx, row.orgId, runId, "sessions", "Session not found");
62
+ const run = await loadRun(ctx, row.orgId, runId, "session", "Session not found");
65
63
  await insertEvent(ctx, {
66
64
  orgId: row.orgId,
67
65
  run,
@@ -47,8 +47,8 @@ export declare const listByAgent: import("convex/server").RegisteredQuery<"publi
47
47
  }[]>>;
48
48
  export declare const requestAuthorization: import("convex/server").RegisteredMutation<"public", {
49
49
  orgId: string;
50
- workflowId: string;
51
50
  awaitedEventName: string;
51
+ workflowId: string;
52
52
  connectionId: import("convex/values").GenericId<"connections">;
53
53
  url: string;
54
54
  userCode: string;
@@ -24,10 +24,10 @@ export declare const listSubagents: import("convex/server").RegisteredQuery<"pub
24
24
  export declare const delegateToSubagent: import("convex/server").RegisteredAction<"public", {
25
25
  payload?: string | undefined;
26
26
  orgId: string;
27
- workflowId: string;
28
27
  awaitedEventName: string;
29
28
  scope: string;
30
29
  reason: string;
30
+ workflowId: string;
31
31
  cost: number;
32
32
  subagentId: import("convex/values").GenericId<"subagents">;
33
33
  workFunctionHandle: string;
@@ -35,11 +35,11 @@ export declare const delegateToSubagent: import("convex/server").RegisteredActio
35
35
  export declare const invokeAgentClone: import("convex/server").RegisteredAction<"public", {
36
36
  payload?: string | undefined;
37
37
  orgId: string;
38
- workflowId: string;
39
38
  agentId: import("convex/values").GenericId<"agents">;
40
39
  awaitedEventName: string;
41
40
  scope: string;
42
41
  reason: string;
42
+ workflowId: string;
43
43
  cost: number;
44
44
  workFunctionHandle: string;
45
45
  viaAgentTool: boolean;
@@ -61,15 +61,15 @@ export declare const getAgentInternal: import("convex/server").RegisteredQuery<"
61
61
  } | null>>;
62
62
  export declare const recordDelegationStartInternal: import("convex/server").RegisteredMutation<"internal", {
63
63
  orgId: string;
64
- workflowId: string;
65
64
  toolName: string;
66
65
  awaitedEventName: string;
66
+ workflowId: string;
67
67
  parentAgentId: import("convex/values").GenericId<"agents">;
68
68
  childAgentId: import("convex/values").GenericId<"agents">;
69
69
  }, Promise<import("convex/values").GenericId<"delegationRuns">>>;
70
70
  export declare const recordCloneStartInternal: import("convex/server").RegisteredMutation<"internal", {
71
71
  orgId: string;
72
- workflowId: string;
73
72
  agentId: import("convex/values").GenericId<"agents">;
74
73
  awaitedEventName: string;
74
+ workflowId: string;
75
75
  }, Promise<import("convex/values").GenericId<"agentCloneRuns">>>;
@@ -3,10 +3,10 @@ type JobRunStatus = "running" | "completed" | "abandoned" | "cancelled";
3
3
  export declare const workflow: WorkflowManager;
4
4
  export declare const start: import("convex/server").RegisteredMutation<"public", {
5
5
  orgId: string;
6
+ kind: string;
6
7
  stepFunctionHandle: string;
7
8
  totalSteps: number;
8
9
  maxAttemptsPerStep: number;
9
- kind: string;
10
10
  }, Promise<string>>;
11
11
  export declare const getStatus: import("convex/server").RegisteredQuery<"public", {
12
12
  orgId: string;
@@ -22,29 +22,6 @@ export declare const cancel: import("convex/server").RegisteredMutation<"public"
22
22
  orgId: string;
23
23
  jobId: string;
24
24
  }, Promise<null>>;
25
- export declare const getJobInternal: import("convex/server").RegisteredQuery<"internal", {
26
- jobId: import("convex/values").GenericId<"durableJobs">;
27
- }, Promise<{
28
- cursor: number;
29
- totalSteps: number;
30
- maxAttemptsPerStep: number;
31
- status: "running" | "completed" | "abandoned" | "cancelled";
32
- } | null>>;
33
- export declare const runStepInternal: import("convex/server").RegisteredMutation<"internal", {
34
- jobId: import("convex/values").GenericId<"durableJobs">;
35
- stepIndex: number;
36
- }, Promise<null>>;
37
- export declare const markAbandonedInternal: import("convex/server").RegisteredMutation<"internal", {
38
- jobId: import("convex/values").GenericId<"durableJobs">;
39
- stepIndex: number;
40
- error: string;
41
- }, Promise<null>>;
42
- export declare const markCompletedInternal: import("convex/server").RegisteredMutation<"internal", {
43
- jobId: import("convex/values").GenericId<"durableJobs">;
44
- }, Promise<null>>;
45
- export declare const durableJobWorkflowV1: import("convex/server").RegisteredMutation<"internal", import("@convex-dev/workflow").WorkflowArgs<{
46
- jobId: import("convex/values").VId<import("convex/values").GenericId<"durableJobs">, "required">;
47
- }>, WorkflowId>;
48
25
  export declare const getJobInternalV2: import("convex/server").RegisteredQuery<"internal", {
49
26
  orgId: string;
50
27
  runId: string;
@@ -56,14 +33,14 @@ export declare const getJobInternalV2: import("convex/server").RegisteredQuery<"
56
33
  } | null>>;
57
34
  export declare const runStepInternalV2: import("convex/server").RegisteredMutation<"internal", {
58
35
  orgId: string;
59
- stepIndex: number;
60
36
  runId: string;
37
+ stepIndex: number;
61
38
  }, Promise<null>>;
62
39
  export declare const markAbandonedInternalV2: import("convex/server").RegisteredMutation<"internal", {
63
40
  orgId: string;
64
- stepIndex: number;
65
41
  runId: string;
66
42
  error: string;
43
+ stepIndex: number;
67
44
  }, Promise<null>>;
68
45
  export declare const markCompletedInternalV2: import("convex/server").RegisteredMutation<"internal", {
69
46
  orgId: string;