History

Remove dead agent task APIs and unused public endpoints

Rhys Sullivan committed 9 months ago

Commit 157305d1 parent acc3e5c8 files · +2 −251Browse files

Unified · Split

8 files
  1. executor/convex/_generated/api.d.ts +0 −65
  2. executor/convex/accounts.ts +0 −8
  3. executor/convex/database.ts +1 −94
  4. executor/convex/executorNode.ts +0 −29
  5. executor/convex/schema.ts +0 −17
  6. executor/convex/workspace.ts +0 −34
  7. executor/convex/workspaces.ts +1 −3
  8. executor/wipe-convex-db.ts +0 −1
executor/convex/_generated/api.d.ts+0−65
@@ -135,38 +135,6 @@ export declare const api: { · 134 unmodified lines
135135 any
136136 >;
137137 };
138− database: {
139− createAgentTask: FunctionReference<
140− "mutation",
141− "public",
142− {
143− actorId: string;
144− id: string;
145− prompt: string;
146− requesterId: string;
147− workspaceId: Id<"workspaces">;
148− },
149− any
150− >;
151− getAgentTask: FunctionReference<
152− "query",
153− "public",
154− { agentTaskId: string },
155− any
156− >;
157− updateAgentTask: FunctionReference<
158− "mutation",
159− "public",
160− {
161− agentTaskId: string;
162− codeRuns?: number;
163− error?: string;
164− resultText?: string;
165− status?: "running" | "completed" | "failed";
166− },
167− any
168− >;
169− };
170138 executor: {
171139 createTask: FunctionReference<
172140 "mutation",
@@ -198,17 +166,6 @@ export declare const api: { · 25 unmodified lines
198166 >;
199167 };
200168 executorNode: {
201− listTools: FunctionReference<
202− "action",
203− "public",
204− {
205− actorId?: string;
206− clientId?: string;
207− sessionId?: string;
208− workspaceId: Id<"workspaces">;
209− },
210− any
211− >;
212169 listToolsWithWarnings: FunctionReference<
213170 "action",
214171 "public",
@@ -332,18 +289,6 @@ export declare const api: { · 117 unmodified lines
332289 { sessionId?: string; sourceId: string; workspaceId: Id<"workspaces"> },
333290 any
334291 >;
335− getRequestContext: FunctionReference<
336− "query",
337− "public",
338− { sessionId?: string; workspaceId: Id<"workspaces"> },
339− any
340− >;
341− getTask: FunctionReference<
342− "query",
343− "public",
344− { sessionId?: string; taskId: string; workspaceId: Id<"workspaces"> },
345− any
346− >;
347292 getTaskInWorkspace: FunctionReference<
348293 "query",
349294 "public",
@@ -356,16 +301,6 @@ export declare const api: { · 6 unmodified lines
356301 { sessionId?: string; workspaceId: Id<"workspaces"> },
357302 any
358303 >;
359− listApprovals: FunctionReference<
360− "query",
361− "public",
362− {
363− sessionId?: string;
364− status?: "pending" | "approved" | "denied";
365− workspaceId: Id<"workspaces">;
366− },
367− any
368− >;
369304 listCredentialProviders: FunctionReference<"query", "public", {}, any>;
370305 listCredentials: FunctionReference<
371306 "query",
executor/convex/accounts.ts+0−8
@@ -58,14 +58,6 @@ async function deleteWorkspaceData( · 57 unmodified lines
5858 await ctx.db.delete(source._id);
5959 }
6060
61− const agentTasks = await ctx.db
62− .query("agentTasks")
63− .withIndex("by_workspace_created", (q) => q.eq("workspaceId", workspaceId))
64− .collect();
65− for (const agentTask of agentTasks) {
66− await ctx.db.delete(agentTask._id);
67− }
68−
6961 const cachedToolsets = await ctx.db
7062 .query("workspaceToolCache")
7163 .withIndex("by_workspace", (q) => q.eq("workspaceId", workspaceId))
executor/convex/database.ts+1−94
@@ -1,8 +1,6 @@
11 import { v } from "convex/values";
22 import type { Doc } from "./_generated/dataModel";
3−import { mutation,
4−query,
5−type MutationCtx, type QueryCtx } from "./_generated/server";
3+import { type MutationCtx, type QueryCtx } from "./_generated/server";
64 import { internalMutation, internalQuery } from "./_generated/server";
75 import { ensureUniqueSlug } from "../lib/slug";
86 import type { TaskStatus } from "../lib/types";
@@ -25,7 +23,6 @@ const credentialProviderValidator = v.union( · 16 unmodified lines
2523 v.literal("workos-vault"),
2624 );
2725 const toolSourceTypeValidator = v.union(v.literal("mcp"), v.literal("openapi"), v.literal("graphql"));
28−const agentTaskStatusValidator = v.union(v.literal("running"), v.literal("completed"), v.literal("failed"));
2926
3027 function slugify(input: string): string {
3128 const slug = input
@@ -610,96 +607,6 @@ export const getApprovalInWorkspace = internalQuery({ · 578 unmodified lines
610607 },
611608 });
612609
613−// ── Agent Tasks ──
614−
615−function mapAgentTask(doc: Doc<"agentTasks">) {
616− return {
617− id: doc.agentTaskId,
618− prompt: doc.prompt,
619− requesterId: doc.requesterId,
620− workspaceId: doc.workspaceId,
621− actorId: doc.actorId,
622− status: doc.status,
623− resultText: doc.resultText,
624− error: doc.error,
625− codeRuns: doc.codeRuns ?? 0,
626− createdAt: doc.createdAt,
627− updatedAt: doc.updatedAt,
628− };
629−}
630−
631−async function getAgentTaskDoc(ctx: { db: QueryCtx["db"] }, agentTaskId: string) {
632− return await ctx.db
633− .query("agentTasks")
634− .withIndex("by_agent_task_id", (q) => q.eq("agentTaskId", agentTaskId))
635− .unique();
636−}
637−
638−export const createAgentTask = mutation({
639− args: {
640− id: v.string(),
641− prompt: v.string(),
642− requesterId: v.string(),
643− workspaceId: v.id("workspaces"),
644− actorId: v.string(),
645− },
646− handler: async (ctx, args) => {
647− const existing = await getAgentTaskDoc(ctx, args.id);
648− if (existing) {
649− throw new Error(`Agent task already exists: ${args.id}`);
650− }
651−
652− const now = Date.now();
653− await ctx.db.insert("agentTasks", {
654− agentTaskId: args.id,
655− prompt: args.prompt,
656− requesterId: args.requesterId,
657− workspaceId: args.workspaceId,
658− actorId: args.actorId,
659− status: "running",
660− codeRuns: 0,
661− createdAt: now,
662− updatedAt: now,
663− });
664−
665− const created = await getAgentTaskDoc(ctx, args.id);
666− if (!created) throw new Error(`Failed to fetch created agent task ${args.id}`);
667− return mapAgentTask(created);
668− },
669−});
670−
671−export const getAgentTask = query({
672− args: { agentTaskId: v.string() },
673− handler: async (ctx, args) => {
674− const doc = await getAgentTaskDoc(ctx, args.agentTaskId);
675− return doc ? mapAgentTask(doc) : null;
676− },
677−});
678−
679−export const updateAgentTask = mutation({
680− args: {
681− agentTaskId: v.string(),
682− status: v.optional(agentTaskStatusValidator),
683− resultText: v.optional(v.string()),
684− error: v.optional(v.string()),
685− codeRuns: v.optional(v.number()),
686− },
687− handler: async (ctx, args) => {
688− const doc = await getAgentTaskDoc(ctx, args.agentTaskId);
689− if (!doc) return null;
690−
691− const patch: Record<string, unknown> = { updatedAt: Date.now() };
692− if (args.status !== undefined) patch.status = args.status;
693− if (args.resultText !== undefined) patch.resultText = args.resultText;
694− if (args.error !== undefined) patch.error = args.error;
695− if (args.codeRuns !== undefined) patch.codeRuns = args.codeRuns;
696−
697− await ctx.db.patch(doc._id, patch);
698− const updated = await getAgentTaskDoc(ctx, args.agentTaskId);
699− return updated ? mapAgentTask(updated) : null;
700− },
701−});
702−
703610 export const bootstrapAnonymousSession = internalMutation({
704611 args: { sessionId: v.optional(v.string()) },
705612 handler: async (ctx, args) => {
executor/convex/executorNode.ts+0−29
@@ -934,35 +934,6 @@ async function invokeTool(ctx: ActionCtx, task: TaskRecord, call: ToolCallReques · 933 unmodified lines
934934 }
935935 }
936936
937−export const listTools = action({
938− args: {
939− workspaceId: v.id("workspaces"),
940− actorId: v.optional(v.string()),
941− clientId: v.optional(v.string()),
942− sessionId: v.optional(v.string()),
943− },
944− handler: async (ctx, args): Promise<ToolDescriptor[]> => {
945− const access = await ctx.runQuery(internal.workspaceAuthInternal.getWorkspaceAccessForRequest, {
946− workspaceId: args.workspaceId,
947− sessionId: args.sessionId,
948− });
949− const canonicalActorId = actorIdForAccount({
950− _id: access.accountId,
951− provider: access.provider,
952− providerAccountId: access.providerAccountId,
953− });
954− if (args.actorId && args.actorId !== canonicalActorId) {
955− throw new Error("actorId must match the authenticated workspace actor");
956− }
957−
958− return await listToolsForContext(ctx, {
959− workspaceId: args.workspaceId,
960− actorId: canonicalActorId,
961− clientId: args.clientId,
962− });
963− },
964−});
965−
966937 export const listToolsWithWarnings = action({
967938 args: {
968939 workspaceId: v.id("workspaces"),
executor/convex/schema.ts+0−17
@@ -41,7 +41,6 @@ const credentialProvider = v.union( · 40 unmodified lines
4141 v.literal("workos-vault"),
4242 );
4343 const toolSourceType = v.union(v.literal("mcp"), v.literal("openapi"), v.literal("graphql"));
44−const agentTaskStatus = v.union(v.literal("running"), v.literal("completed"), v.literal("failed"));
4544
4645 export default defineSchema({
4746 accounts: defineTable({
@@ -260,22 +259,6 @@ export default defineSchema({ · 212 unmodified lines
260259 .index("by_workspace_updated", ["workspaceId", "updatedAt"])
261260 .index("by_workspace_name", ["workspaceId", "name"]),
262261
263− agentTasks: defineTable({
264− agentTaskId: v.string(), // domain ID: atask_<timestamp>_<counter>
265− prompt: v.string(),
266− requesterId: v.string(), // external ID (e.g. Discord user snowflake)
267− workspaceId: v.id("workspaces"),
268− actorId: v.string(), // account._id or anon_<uuid>
269− status: agentTaskStatus,
270− resultText: v.optional(v.string()),
271− error: v.optional(v.string()),
272− codeRuns: v.number(),
273− createdAt: v.number(),
274− updatedAt: v.number(),
275− })
276− .index("by_agent_task_id", ["agentTaskId"])
277− .index("by_workspace_created", ["workspaceId", "createdAt"]),
278−
279262 openApiSpecCache: defineTable({
280263 specUrl: v.string(),
281264 storageId: v.id("_storage"),
executor/convex/workspace.ts+0−34
@@ -2,9 +2,7 @@ import { v } from "convex/values"; · 1 unmodified line
22 import { internal } from "./_generated/api";
33 import { mutation, query } from "./_generated/server";
44 import { workspaceMutation, workspaceQuery } from "../lib/functionBuilders";
5−import { actorIdForAccount } from "../lib/identity";
65
7−const approvalStatusValidator = v.union(v.literal("pending"), v.literal("approved"), v.literal("denied"));
86 const policyDecisionValidator = v.union(v.literal("allow"), v.literal("require_approval"), v.literal("deny"));
97 const credentialScopeValidator = v.union(v.literal("workspace"), v.literal("actor"));
108 const credentialProviderValidator = v.union(v.literal("managed"), v.literal("workos-vault"));
@@ -31,26 +29,6 @@ export const listRuntimeTargets = query({ · 20 unmodified lines
3129 },
3230 });
3331
34−export const getRequestContext = workspaceQuery({
35− args: {},
36− handler: async (ctx) => {
37− return {
38− workspaceId: ctx.workspaceId,
39− actorId: actorIdForAccount(ctx.account as { _id: string; provider: string; providerAccountId: string }),
40− };
41− },
42−});
43−
44−export const getTask = workspaceQuery({
45− args: { taskId: v.string() },
46− handler: async (ctx, args) => {
47− return await ctx.runQuery(internal.database.getTaskInWorkspace, {
48− taskId: args.taskId,
49− workspaceId: ctx.workspaceId,
50− });
51− },
52−});
53−
5432 export const getTaskInWorkspace = workspaceQuery({
5533 args: { taskId: v.string() },
5634 handler: async (ctx, args) => {
@@ -70,18 +48,6 @@ export const listTasks = workspaceQuery({ · 13 unmodified lines
7048 },
7149 });
7250
73−export const listApprovals = workspaceQuery({
74− args: {
75− status: v.optional(approvalStatusValidator),
76− },
77− handler: async (ctx, args) => {
78− return await ctx.runQuery(internal.database.listApprovals, {
79− workspaceId: ctx.workspaceId,
80− status: args.status,
81− });
82− },
83−});
84−
8551 export const listPendingApprovals = workspaceQuery({
8652 args: {},
8753 handler: async (ctx) => {
executor/convex/workspaces.ts+1−3
@@ -26,7 +26,6 @@ async function workspaceHasActivity( · 25 unmodified lines
2626 policy,
2727 credential,
2828 toolSource,
29− agentTask,
3029 member,
3130 ] = await Promise.all([
3231 ctx.db.query("tasks").withIndex("by_workspace_created", (q) => q.eq("workspaceId", workspaceId)).first(),
@@ -37,11 +36,10 @@ async function workspaceHasActivity( · 4 unmodified lines
3736 .withIndex("by_workspace_created", (q) => q.eq("workspaceId", workspaceId))
3837 .first(),
3938 ctx.db.query("toolSources").withIndex("by_workspace_updated", (q) => q.eq("workspaceId", workspaceId)).first(),
40− ctx.db.query("agentTasks").withIndex("by_workspace_created", (q) => q.eq("workspaceId", workspaceId)).first(),
4139 ctx.db.query("workspaceMembers").withIndex("by_workspace", (q) => q.eq("workspaceId", workspaceId)).first(),
4240 ]);
4341
44− return Boolean(task || approval || policy || credential || toolSource || agentTask || member);
42+ return Boolean(task || approval || policy || credential || toolSource || member);
4543 }
4644
4745 async function filterDisplayWorkspaces(
executor/wipe-convex-db.ts+0−1
@@ -3,7 +3,6 @@ import { $ } from "bun"; · 2 unmodified lines
33 const tables = [
44 "accessPolicies",
55 "accounts",
6− "agentTasks",
76 "anonymousSessions",
87 "approvals",
98 "billingCustomers",

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t