@spinabot/brigade 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/convex/_generated/api.d.ts +85 -0
- package/convex/_generated/api.js +23 -0
- package/convex/_generated/dataModel.d.ts +60 -0
- package/convex/_generated/server.d.ts +143 -0
- package/convex/_generated/server.js +93 -0
- package/convex/admin.d.ts +57 -0
- package/convex/admin.ts +315 -0
- package/convex/auth.d.ts +159 -0
- package/convex/auth.ts +217 -0
- package/convex/blobs.d.ts +38 -0
- package/convex/blobs.ts +115 -0
- package/convex/channels.d.ts +150 -0
- package/convex/channels.ts +455 -0
- package/convex/config.d.ts +67 -0
- package/convex/config.ts +168 -0
- package/convex/cron.d.ts +237 -0
- package/convex/cron.ts +199 -0
- package/convex/execApprovals.d.ts +31 -0
- package/convex/execApprovals.ts +58 -0
- package/convex/extensions.d.ts +30 -0
- package/convex/extensions.ts +51 -0
- package/convex/health.d.ts +18 -0
- package/convex/health.ts +69 -0
- package/convex/instance.d.ts +34 -0
- package/convex/instance.ts +82 -0
- package/convex/logs.d.ts +178 -0
- package/convex/logs.ts +253 -0
- package/convex/memory.d.ts +354 -0
- package/convex/memory.ts +536 -0
- package/convex/messages.d.ts +124 -0
- package/convex/messages.ts +347 -0
- package/convex/org.d.ts +75 -0
- package/convex/org.ts +99 -0
- package/convex/schema.d.ts +1130 -0
- package/convex/schema.ts +847 -0
- package/convex/sessions.d.ts +100 -0
- package/convex/sessions.ts +105 -0
- package/convex/skills.d.ts +73 -0
- package/convex/skills.ts +102 -0
- package/convex/subagents.d.ts +214 -0
- package/convex/subagents.ts +99 -0
- package/convex/tsconfig.json +23 -0
- package/convex/whatsappAuth.d.ts +52 -0
- package/convex/whatsappAuth.ts +151 -0
- package/convex/workspace.d.ts +49 -0
- package/convex/workspace.ts +106 -0
- package/dist/buildstamp.json +1 -1
- package/dist/cli/commands/convex-cmd.d.ts +27 -0
- package/dist/cli/commands/convex-cmd.d.ts.map +1 -0
- package/dist/cli/commands/convex-cmd.js +162 -0
- package/dist/cli/commands/convex-cmd.js.map +1 -0
- package/dist/cli/program/build-program.d.ts.map +1 -1
- package/dist/cli/program/build-program.js +64 -0
- package/dist/cli/program/build-program.js.map +1 -1
- package/dist/config/paths.d.ts +3 -0
- package/dist/config/paths.d.ts.map +1 -1
- package/dist/config/paths.js +39 -0
- package/dist/config/paths.js.map +1 -1
- package/package.json +7 -1
- package/scripts/convex-dev.mjs +321 -0
- package/scripts/convex-push.mjs +69 -0
- package/scripts/install-convex.mjs +123 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
export declare const getEntry: import("convex/server").RegisteredQuery<"public", {
|
|
2
|
+
agentId: string;
|
|
3
|
+
sessionKey: string;
|
|
4
|
+
}, Promise<{
|
|
5
|
+
_id: import("convex/values").GenericId<"sessions">;
|
|
6
|
+
_creationTime: number;
|
|
7
|
+
modelId?: string | undefined;
|
|
8
|
+
provider?: string | undefined;
|
|
9
|
+
authProfile?: string | undefined;
|
|
10
|
+
thinkingLevel?: string | undefined;
|
|
11
|
+
subagent?: {
|
|
12
|
+
parentRunId?: string | undefined;
|
|
13
|
+
spawnedWorkspaceDir?: string | undefined;
|
|
14
|
+
label?: string | undefined;
|
|
15
|
+
cleanup?: "delete" | "keep" | undefined;
|
|
16
|
+
spawnDepth: number;
|
|
17
|
+
spawnedBy: string;
|
|
18
|
+
spawnedAt: string;
|
|
19
|
+
} | undefined;
|
|
20
|
+
extra?: ArrayBuffer | undefined;
|
|
21
|
+
agentId: string;
|
|
22
|
+
sessionKey: string;
|
|
23
|
+
sessionId: string;
|
|
24
|
+
createdAt: number;
|
|
25
|
+
lastUsedAt: number;
|
|
26
|
+
} | null>>;
|
|
27
|
+
export declare const listEntries: import("convex/server").RegisteredQuery<"public", {
|
|
28
|
+
subagentOnly?: boolean | undefined;
|
|
29
|
+
agentId: string;
|
|
30
|
+
}, Promise<{
|
|
31
|
+
_id: import("convex/values").GenericId<"sessions">;
|
|
32
|
+
_creationTime: number;
|
|
33
|
+
modelId?: string | undefined;
|
|
34
|
+
provider?: string | undefined;
|
|
35
|
+
authProfile?: string | undefined;
|
|
36
|
+
thinkingLevel?: string | undefined;
|
|
37
|
+
subagent?: {
|
|
38
|
+
parentRunId?: string | undefined;
|
|
39
|
+
spawnedWorkspaceDir?: string | undefined;
|
|
40
|
+
label?: string | undefined;
|
|
41
|
+
cleanup?: "delete" | "keep" | undefined;
|
|
42
|
+
spawnDepth: number;
|
|
43
|
+
spawnedBy: string;
|
|
44
|
+
spawnedAt: string;
|
|
45
|
+
} | undefined;
|
|
46
|
+
extra?: ArrayBuffer | undefined;
|
|
47
|
+
agentId: string;
|
|
48
|
+
sessionKey: string;
|
|
49
|
+
sessionId: string;
|
|
50
|
+
createdAt: number;
|
|
51
|
+
lastUsedAt: number;
|
|
52
|
+
}[]>>;
|
|
53
|
+
export declare const upsertEntry: import("convex/server").RegisteredMutation<"public", {
|
|
54
|
+
modelId?: string | undefined;
|
|
55
|
+
provider?: string | undefined;
|
|
56
|
+
createdAt?: number | undefined;
|
|
57
|
+
lastUsedAt?: number | undefined;
|
|
58
|
+
authProfile?: string | undefined;
|
|
59
|
+
thinkingLevel?: string | undefined;
|
|
60
|
+
subagent?: {
|
|
61
|
+
parentRunId?: string | undefined;
|
|
62
|
+
spawnedWorkspaceDir?: string | undefined;
|
|
63
|
+
label?: string | undefined;
|
|
64
|
+
cleanup?: "delete" | "keep" | undefined;
|
|
65
|
+
spawnDepth: number;
|
|
66
|
+
spawnedBy: string;
|
|
67
|
+
spawnedAt: string;
|
|
68
|
+
} | undefined;
|
|
69
|
+
extra?: ArrayBuffer | undefined;
|
|
70
|
+
agentId: string;
|
|
71
|
+
sessionKey: string;
|
|
72
|
+
sessionId: string;
|
|
73
|
+
}, Promise<{
|
|
74
|
+
_id: import("convex/values").GenericId<"sessions">;
|
|
75
|
+
_creationTime: number;
|
|
76
|
+
modelId?: string | undefined;
|
|
77
|
+
provider?: string | undefined;
|
|
78
|
+
authProfile?: string | undefined;
|
|
79
|
+
thinkingLevel?: string | undefined;
|
|
80
|
+
subagent?: {
|
|
81
|
+
parentRunId?: string | undefined;
|
|
82
|
+
spawnedWorkspaceDir?: string | undefined;
|
|
83
|
+
label?: string | undefined;
|
|
84
|
+
cleanup?: "delete" | "keep" | undefined;
|
|
85
|
+
spawnDepth: number;
|
|
86
|
+
spawnedBy: string;
|
|
87
|
+
spawnedAt: string;
|
|
88
|
+
} | undefined;
|
|
89
|
+
extra?: ArrayBuffer | undefined;
|
|
90
|
+
agentId: string;
|
|
91
|
+
sessionKey: string;
|
|
92
|
+
sessionId: string;
|
|
93
|
+
createdAt: number;
|
|
94
|
+
lastUsedAt: number;
|
|
95
|
+
} | null>>;
|
|
96
|
+
export declare const deleteEntry: import("convex/server").RegisteredMutation<"public", {
|
|
97
|
+
agentId: string;
|
|
98
|
+
sessionKey: string;
|
|
99
|
+
}, Promise<boolean>>;
|
|
100
|
+
//# sourceMappingURL=sessions.d.ts.map
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// convex/sessions.ts — sessions index
|
|
2
|
+
import { v } from "convex/values";
|
|
3
|
+
import { mutation, query } from "./_generated/server.js";
|
|
4
|
+
|
|
5
|
+
const Subagent = v.object({
|
|
6
|
+
spawnDepth: v.number(),
|
|
7
|
+
spawnedBy: v.string(),
|
|
8
|
+
parentRunId: v.optional(v.string()),
|
|
9
|
+
label: v.optional(v.string()),
|
|
10
|
+
cleanup: v.optional(v.union(v.literal("delete"), v.literal("keep"))),
|
|
11
|
+
spawnedAt: v.string(),
|
|
12
|
+
spawnedWorkspaceDir: v.optional(v.string()),
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export const getEntry = query({
|
|
16
|
+
args: { agentId: v.string(), sessionKey: v.string() },
|
|
17
|
+
handler: async (ctx, args) => {
|
|
18
|
+
return ctx.db
|
|
19
|
+
.query("sessions")
|
|
20
|
+
.withIndex("by_agent_key", (q) =>
|
|
21
|
+
q.eq("agentId", args.agentId).eq("sessionKey", args.sessionKey),
|
|
22
|
+
)
|
|
23
|
+
.first();
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export const listEntries = query({
|
|
28
|
+
args: { agentId: v.string(), subagentOnly: v.optional(v.boolean()) },
|
|
29
|
+
handler: async (ctx, args) => {
|
|
30
|
+
const all = await ctx.db
|
|
31
|
+
.query("sessions")
|
|
32
|
+
.withIndex("by_agent_lastUsed", (q) => q.eq("agentId", args.agentId))
|
|
33
|
+
.order("desc")
|
|
34
|
+
.collect();
|
|
35
|
+
if (args.subagentOnly) return all.filter((s) => s.subagent !== undefined);
|
|
36
|
+
return all;
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
export const upsertEntry = mutation({
|
|
41
|
+
args: {
|
|
42
|
+
agentId: v.string(),
|
|
43
|
+
sessionKey: v.string(),
|
|
44
|
+
sessionId: v.string(),
|
|
45
|
+
createdAt: v.optional(v.number()),
|
|
46
|
+
lastUsedAt: v.optional(v.number()),
|
|
47
|
+
provider: v.optional(v.string()),
|
|
48
|
+
modelId: v.optional(v.string()),
|
|
49
|
+
authProfile: v.optional(v.string()),
|
|
50
|
+
thinkingLevel: v.optional(v.string()),
|
|
51
|
+
subagent: v.optional(Subagent),
|
|
52
|
+
extra: v.optional(v.bytes()),
|
|
53
|
+
},
|
|
54
|
+
handler: async (ctx, args) => {
|
|
55
|
+
const existing = await ctx.db
|
|
56
|
+
.query("sessions")
|
|
57
|
+
.withIndex("by_agent_key", (q) =>
|
|
58
|
+
q.eq("agentId", args.agentId).eq("sessionKey", args.sessionKey),
|
|
59
|
+
)
|
|
60
|
+
.first();
|
|
61
|
+
const now = Date.now();
|
|
62
|
+
if (existing) {
|
|
63
|
+
// MERGE, never replace — mirrors the filesystem store's
|
|
64
|
+
// read-modify-write (src/sessions/session-store.ts): fields the
|
|
65
|
+
// caller omits keep their stored value, `createdAt` is set once at
|
|
66
|
+
// creation, and `subagent` is write-once (only applied when the
|
|
67
|
+
// row doesn't carry one yet — session-store.ts:351-367).
|
|
68
|
+
const patch: Record<string, unknown> = {
|
|
69
|
+
sessionId: args.sessionId,
|
|
70
|
+
lastUsedAt: args.lastUsedAt ?? now,
|
|
71
|
+
};
|
|
72
|
+
if (args.provider !== undefined) patch.provider = args.provider;
|
|
73
|
+
if (args.modelId !== undefined) patch.modelId = args.modelId;
|
|
74
|
+
if (args.authProfile !== undefined) patch.authProfile = args.authProfile;
|
|
75
|
+
if (args.thinkingLevel !== undefined) patch.thinkingLevel = args.thinkingLevel;
|
|
76
|
+
if (args.extra !== undefined) patch.extra = args.extra;
|
|
77
|
+
if (args.subagent !== undefined && existing.subagent === undefined) {
|
|
78
|
+
patch.subagent = args.subagent;
|
|
79
|
+
}
|
|
80
|
+
await ctx.db.patch(existing._id, patch);
|
|
81
|
+
return await ctx.db.get(existing._id);
|
|
82
|
+
}
|
|
83
|
+
const id = await ctx.db.insert("sessions", {
|
|
84
|
+
...args,
|
|
85
|
+
createdAt: args.createdAt ?? now,
|
|
86
|
+
lastUsedAt: args.lastUsedAt ?? now,
|
|
87
|
+
});
|
|
88
|
+
return await ctx.db.get(id);
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
export const deleteEntry = mutation({
|
|
93
|
+
args: { agentId: v.string(), sessionKey: v.string() },
|
|
94
|
+
handler: async (ctx, args) => {
|
|
95
|
+
const existing = await ctx.db
|
|
96
|
+
.query("sessions")
|
|
97
|
+
.withIndex("by_agent_key", (q) =>
|
|
98
|
+
q.eq("agentId", args.agentId).eq("sessionKey", args.sessionKey),
|
|
99
|
+
)
|
|
100
|
+
.first();
|
|
101
|
+
if (!existing) return false;
|
|
102
|
+
await ctx.db.delete(existing._id);
|
|
103
|
+
return true;
|
|
104
|
+
},
|
|
105
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
export declare const list: import("convex/server").RegisteredQuery<"public", {
|
|
2
|
+
agentId?: string | null | undefined;
|
|
3
|
+
source?: "bundled" | "config" | "managed" | "personal" | "project" | "workspace" | undefined;
|
|
4
|
+
ownerId: string;
|
|
5
|
+
}, Promise<{
|
|
6
|
+
_id: import("convex/values").GenericId<"skills">;
|
|
7
|
+
_creationTime: number;
|
|
8
|
+
agentId: string | null;
|
|
9
|
+
name: string;
|
|
10
|
+
source: "bundled" | "config" | "managed" | "personal" | "project" | "workspace";
|
|
11
|
+
description: string;
|
|
12
|
+
createdAt: number;
|
|
13
|
+
ownerId: string;
|
|
14
|
+
updatedAt: number;
|
|
15
|
+
frontmatter: string;
|
|
16
|
+
body: string;
|
|
17
|
+
eligibility: {
|
|
18
|
+
os: string[];
|
|
19
|
+
requiresBins: string[];
|
|
20
|
+
requiresAnyBins: string[];
|
|
21
|
+
requiresEnv: string[];
|
|
22
|
+
requiresConfig: string[];
|
|
23
|
+
};
|
|
24
|
+
disableModelInvocation: boolean;
|
|
25
|
+
}[]>>;
|
|
26
|
+
export declare const get: import("convex/server").RegisteredQuery<"public", {
|
|
27
|
+
name: string;
|
|
28
|
+
ownerId: string;
|
|
29
|
+
}, Promise<{
|
|
30
|
+
_id: import("convex/values").GenericId<"skills">;
|
|
31
|
+
_creationTime: number;
|
|
32
|
+
agentId: string | null;
|
|
33
|
+
name: string;
|
|
34
|
+
source: "bundled" | "config" | "managed" | "personal" | "project" | "workspace";
|
|
35
|
+
description: string;
|
|
36
|
+
createdAt: number;
|
|
37
|
+
ownerId: string;
|
|
38
|
+
updatedAt: number;
|
|
39
|
+
frontmatter: string;
|
|
40
|
+
body: string;
|
|
41
|
+
eligibility: {
|
|
42
|
+
os: string[];
|
|
43
|
+
requiresBins: string[];
|
|
44
|
+
requiresAnyBins: string[];
|
|
45
|
+
requiresEnv: string[];
|
|
46
|
+
requiresConfig: string[];
|
|
47
|
+
};
|
|
48
|
+
disableModelInvocation: boolean;
|
|
49
|
+
} | null>>;
|
|
50
|
+
export declare const upsert: import("convex/server").RegisteredMutation<"public", {
|
|
51
|
+
agentId: string | null;
|
|
52
|
+
name: string;
|
|
53
|
+
source: "bundled" | "config" | "managed" | "personal" | "project" | "workspace";
|
|
54
|
+
description: string;
|
|
55
|
+
ownerId: string;
|
|
56
|
+
frontmatter: string;
|
|
57
|
+
body: string;
|
|
58
|
+
eligibility: {
|
|
59
|
+
os: string[];
|
|
60
|
+
requiresBins: string[];
|
|
61
|
+
requiresAnyBins: string[];
|
|
62
|
+
requiresEnv: string[];
|
|
63
|
+
requiresConfig: string[];
|
|
64
|
+
};
|
|
65
|
+
disableModelInvocation: boolean;
|
|
66
|
+
}, Promise<{
|
|
67
|
+
created: boolean;
|
|
68
|
+
}>>;
|
|
69
|
+
export declare const remove: import("convex/server").RegisteredMutation<"public", {
|
|
70
|
+
name: string;
|
|
71
|
+
ownerId: string;
|
|
72
|
+
}, Promise<boolean>>;
|
|
73
|
+
//# sourceMappingURL=skills.d.ts.map
|
package/convex/skills.ts
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// convex/skills.ts
|
|
2
|
+
import { v } from "convex/values";
|
|
3
|
+
import { mutation, query } from "./_generated/server.js";
|
|
4
|
+
|
|
5
|
+
const Source = v.union(
|
|
6
|
+
v.literal("bundled"),
|
|
7
|
+
v.literal("config"),
|
|
8
|
+
v.literal("managed"),
|
|
9
|
+
v.literal("personal"),
|
|
10
|
+
v.literal("project"),
|
|
11
|
+
v.literal("workspace"),
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
export const list = query({
|
|
15
|
+
args: {
|
|
16
|
+
ownerId: v.string(),
|
|
17
|
+
// Optional scoping: workspace skills are per-agent, so the mirror sync
|
|
18
|
+
// must fetch only THIS agent's workspace skills — without it every
|
|
19
|
+
// agent's skills bleed into every workspace on boot.
|
|
20
|
+
source: v.optional(Source),
|
|
21
|
+
agentId: v.optional(v.union(v.string(), v.null())),
|
|
22
|
+
},
|
|
23
|
+
handler: async (ctx, args) => {
|
|
24
|
+
if (args.source !== undefined && args.agentId !== undefined) {
|
|
25
|
+
const agentId = args.agentId;
|
|
26
|
+
const source = args.source;
|
|
27
|
+
return ctx.db
|
|
28
|
+
.query("skills")
|
|
29
|
+
.withIndex("by_owner_scope_name", (q) =>
|
|
30
|
+
q.eq("ownerId", args.ownerId).eq("source", source).eq("agentId", agentId),
|
|
31
|
+
)
|
|
32
|
+
.collect();
|
|
33
|
+
}
|
|
34
|
+
if (args.source !== undefined) {
|
|
35
|
+
const source = args.source;
|
|
36
|
+
return ctx.db
|
|
37
|
+
.query("skills")
|
|
38
|
+
.withIndex("by_owner_source", (q) => q.eq("ownerId", args.ownerId).eq("source", source))
|
|
39
|
+
.collect();
|
|
40
|
+
}
|
|
41
|
+
return ctx.db
|
|
42
|
+
.query("skills")
|
|
43
|
+
.withIndex("by_owner_source", (q) => q.eq("ownerId", args.ownerId))
|
|
44
|
+
.collect();
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
export const get = query({
|
|
49
|
+
args: { ownerId: v.string(), name: v.string() },
|
|
50
|
+
handler: async (ctx, args) => {
|
|
51
|
+
return ctx.db
|
|
52
|
+
.query("skills")
|
|
53
|
+
.withIndex("by_owner_name", (q) => q.eq("ownerId", args.ownerId).eq("name", args.name))
|
|
54
|
+
.first();
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
export const upsert = mutation({
|
|
59
|
+
args: {
|
|
60
|
+
ownerId: v.string(),
|
|
61
|
+
source: Source,
|
|
62
|
+
agentId: v.union(v.string(), v.null()),
|
|
63
|
+
name: v.string(),
|
|
64
|
+
description: v.string(),
|
|
65
|
+
frontmatter: v.string(),
|
|
66
|
+
body: v.string(),
|
|
67
|
+
eligibility: v.object({
|
|
68
|
+
os: v.array(v.string()),
|
|
69
|
+
requiresBins: v.array(v.string()),
|
|
70
|
+
requiresAnyBins: v.array(v.string()),
|
|
71
|
+
requiresEnv: v.array(v.string()),
|
|
72
|
+
requiresConfig: v.array(v.string()),
|
|
73
|
+
}),
|
|
74
|
+
disableModelInvocation: v.boolean(),
|
|
75
|
+
},
|
|
76
|
+
handler: async (ctx, args) => {
|
|
77
|
+
const existing = await ctx.db
|
|
78
|
+
.query("skills")
|
|
79
|
+
.withIndex("by_owner_name", (q) => q.eq("ownerId", args.ownerId).eq("name", args.name))
|
|
80
|
+
.first();
|
|
81
|
+
const now = Date.now();
|
|
82
|
+
if (existing) {
|
|
83
|
+
await ctx.db.replace(existing._id, { ...args, createdAt: existing.createdAt, updatedAt: now });
|
|
84
|
+
return { created: false };
|
|
85
|
+
}
|
|
86
|
+
await ctx.db.insert("skills", { ...args, createdAt: now, updatedAt: now });
|
|
87
|
+
return { created: true };
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
export const remove = mutation({
|
|
92
|
+
args: { ownerId: v.string(), name: v.string() },
|
|
93
|
+
handler: async (ctx, args) => {
|
|
94
|
+
const existing = await ctx.db
|
|
95
|
+
.query("skills")
|
|
96
|
+
.withIndex("by_owner_name", (q) => q.eq("ownerId", args.ownerId).eq("name", args.name))
|
|
97
|
+
.first();
|
|
98
|
+
if (!existing) return false;
|
|
99
|
+
await ctx.db.delete(existing._id);
|
|
100
|
+
return true;
|
|
101
|
+
},
|
|
102
|
+
});
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
export declare const get: import("convex/server").RegisteredQuery<"public", {
|
|
2
|
+
ownerId: string;
|
|
3
|
+
runId: string;
|
|
4
|
+
}, Promise<{
|
|
5
|
+
_id: import("convex/values").GenericId<"subagentRuns">;
|
|
6
|
+
_creationTime: number;
|
|
7
|
+
model?: string | undefined;
|
|
8
|
+
workspaceDir?: string | undefined;
|
|
9
|
+
label?: string | undefined;
|
|
10
|
+
controllerSessionKey?: string | undefined;
|
|
11
|
+
requesterOrigin?: ArrayBuffer | undefined;
|
|
12
|
+
runTimeoutSeconds?: number | undefined;
|
|
13
|
+
spawnMode?: "session" | "run" | undefined;
|
|
14
|
+
startedAt?: number | undefined;
|
|
15
|
+
sessionStartedAt?: number | undefined;
|
|
16
|
+
accumulatedRuntimeMs?: number | undefined;
|
|
17
|
+
endedAt?: number | undefined;
|
|
18
|
+
outcome?: {
|
|
19
|
+
text?: ArrayBuffer | undefined;
|
|
20
|
+
error?: string | undefined;
|
|
21
|
+
reason?: string | undefined;
|
|
22
|
+
status: "error" | "timeout" | "ok" | "abort";
|
|
23
|
+
} | undefined;
|
|
24
|
+
archiveAtMs?: number | undefined;
|
|
25
|
+
cleanupCompletedAt?: number | undefined;
|
|
26
|
+
cleanupHandled?: boolean | undefined;
|
|
27
|
+
suppressAnnounceReason?: "steer-restart" | "killed" | undefined;
|
|
28
|
+
expectsCompletionMessage?: boolean | undefined;
|
|
29
|
+
announceRetryCount?: number | undefined;
|
|
30
|
+
lastAnnounceRetryAt?: number | undefined;
|
|
31
|
+
endedReason?: string | undefined;
|
|
32
|
+
wakeOnDescendantSettle?: boolean | undefined;
|
|
33
|
+
frozenResultText?: ArrayBuffer | undefined;
|
|
34
|
+
frozenResultCapturedAt?: number | undefined;
|
|
35
|
+
fallbackFrozenResultText?: ArrayBuffer | undefined;
|
|
36
|
+
fallbackFrozenResultCapturedAt?: number | undefined;
|
|
37
|
+
endedHookEmittedAt?: number | undefined;
|
|
38
|
+
completionAnnouncedAt?: number | undefined;
|
|
39
|
+
attachmentsDir?: string | undefined;
|
|
40
|
+
attachmentsRootDir?: string | undefined;
|
|
41
|
+
retainAttachmentsOnKeep?: boolean | undefined;
|
|
42
|
+
createdAt: number;
|
|
43
|
+
ownerId: string;
|
|
44
|
+
cleanup: "delete" | "keep";
|
|
45
|
+
runId: string;
|
|
46
|
+
childSessionKey: string;
|
|
47
|
+
requesterSessionKey: string;
|
|
48
|
+
requesterDisplayKey: string;
|
|
49
|
+
task: ArrayBuffer;
|
|
50
|
+
} | null>>;
|
|
51
|
+
export declare const getByChildSessionKey: import("convex/server").RegisteredQuery<"public", {
|
|
52
|
+
ownerId: string;
|
|
53
|
+
childSessionKey: string;
|
|
54
|
+
}, Promise<{
|
|
55
|
+
_id: import("convex/values").GenericId<"subagentRuns">;
|
|
56
|
+
_creationTime: number;
|
|
57
|
+
model?: string | undefined;
|
|
58
|
+
workspaceDir?: string | undefined;
|
|
59
|
+
label?: string | undefined;
|
|
60
|
+
controllerSessionKey?: string | undefined;
|
|
61
|
+
requesterOrigin?: ArrayBuffer | undefined;
|
|
62
|
+
runTimeoutSeconds?: number | undefined;
|
|
63
|
+
spawnMode?: "session" | "run" | undefined;
|
|
64
|
+
startedAt?: number | undefined;
|
|
65
|
+
sessionStartedAt?: number | undefined;
|
|
66
|
+
accumulatedRuntimeMs?: number | undefined;
|
|
67
|
+
endedAt?: number | undefined;
|
|
68
|
+
outcome?: {
|
|
69
|
+
text?: ArrayBuffer | undefined;
|
|
70
|
+
error?: string | undefined;
|
|
71
|
+
reason?: string | undefined;
|
|
72
|
+
status: "error" | "timeout" | "ok" | "abort";
|
|
73
|
+
} | undefined;
|
|
74
|
+
archiveAtMs?: number | undefined;
|
|
75
|
+
cleanupCompletedAt?: number | undefined;
|
|
76
|
+
cleanupHandled?: boolean | undefined;
|
|
77
|
+
suppressAnnounceReason?: "steer-restart" | "killed" | undefined;
|
|
78
|
+
expectsCompletionMessage?: boolean | undefined;
|
|
79
|
+
announceRetryCount?: number | undefined;
|
|
80
|
+
lastAnnounceRetryAt?: number | undefined;
|
|
81
|
+
endedReason?: string | undefined;
|
|
82
|
+
wakeOnDescendantSettle?: boolean | undefined;
|
|
83
|
+
frozenResultText?: ArrayBuffer | undefined;
|
|
84
|
+
frozenResultCapturedAt?: number | undefined;
|
|
85
|
+
fallbackFrozenResultText?: ArrayBuffer | undefined;
|
|
86
|
+
fallbackFrozenResultCapturedAt?: number | undefined;
|
|
87
|
+
endedHookEmittedAt?: number | undefined;
|
|
88
|
+
completionAnnouncedAt?: number | undefined;
|
|
89
|
+
attachmentsDir?: string | undefined;
|
|
90
|
+
attachmentsRootDir?: string | undefined;
|
|
91
|
+
retainAttachmentsOnKeep?: boolean | undefined;
|
|
92
|
+
createdAt: number;
|
|
93
|
+
ownerId: string;
|
|
94
|
+
cleanup: "delete" | "keep";
|
|
95
|
+
runId: string;
|
|
96
|
+
childSessionKey: string;
|
|
97
|
+
requesterSessionKey: string;
|
|
98
|
+
requesterDisplayKey: string;
|
|
99
|
+
task: ArrayBuffer;
|
|
100
|
+
} | null>>;
|
|
101
|
+
export declare const listByRequester: import("convex/server").RegisteredQuery<"public", {
|
|
102
|
+
ownerId: string;
|
|
103
|
+
requesterSessionKey: string;
|
|
104
|
+
}, Promise<{
|
|
105
|
+
_id: import("convex/values").GenericId<"subagentRuns">;
|
|
106
|
+
_creationTime: number;
|
|
107
|
+
model?: string | undefined;
|
|
108
|
+
workspaceDir?: string | undefined;
|
|
109
|
+
label?: string | undefined;
|
|
110
|
+
controllerSessionKey?: string | undefined;
|
|
111
|
+
requesterOrigin?: ArrayBuffer | undefined;
|
|
112
|
+
runTimeoutSeconds?: number | undefined;
|
|
113
|
+
spawnMode?: "session" | "run" | undefined;
|
|
114
|
+
startedAt?: number | undefined;
|
|
115
|
+
sessionStartedAt?: number | undefined;
|
|
116
|
+
accumulatedRuntimeMs?: number | undefined;
|
|
117
|
+
endedAt?: number | undefined;
|
|
118
|
+
outcome?: {
|
|
119
|
+
text?: ArrayBuffer | undefined;
|
|
120
|
+
error?: string | undefined;
|
|
121
|
+
reason?: string | undefined;
|
|
122
|
+
status: "error" | "timeout" | "ok" | "abort";
|
|
123
|
+
} | undefined;
|
|
124
|
+
archiveAtMs?: number | undefined;
|
|
125
|
+
cleanupCompletedAt?: number | undefined;
|
|
126
|
+
cleanupHandled?: boolean | undefined;
|
|
127
|
+
suppressAnnounceReason?: "steer-restart" | "killed" | undefined;
|
|
128
|
+
expectsCompletionMessage?: boolean | undefined;
|
|
129
|
+
announceRetryCount?: number | undefined;
|
|
130
|
+
lastAnnounceRetryAt?: number | undefined;
|
|
131
|
+
endedReason?: string | undefined;
|
|
132
|
+
wakeOnDescendantSettle?: boolean | undefined;
|
|
133
|
+
frozenResultText?: ArrayBuffer | undefined;
|
|
134
|
+
frozenResultCapturedAt?: number | undefined;
|
|
135
|
+
fallbackFrozenResultText?: ArrayBuffer | undefined;
|
|
136
|
+
fallbackFrozenResultCapturedAt?: number | undefined;
|
|
137
|
+
endedHookEmittedAt?: number | undefined;
|
|
138
|
+
completionAnnouncedAt?: number | undefined;
|
|
139
|
+
attachmentsDir?: string | undefined;
|
|
140
|
+
attachmentsRootDir?: string | undefined;
|
|
141
|
+
retainAttachmentsOnKeep?: boolean | undefined;
|
|
142
|
+
createdAt: number;
|
|
143
|
+
ownerId: string;
|
|
144
|
+
cleanup: "delete" | "keep";
|
|
145
|
+
runId: string;
|
|
146
|
+
childSessionKey: string;
|
|
147
|
+
requesterSessionKey: string;
|
|
148
|
+
requesterDisplayKey: string;
|
|
149
|
+
task: ArrayBuffer;
|
|
150
|
+
}[]>>;
|
|
151
|
+
export declare const put: import("convex/server").RegisteredMutation<"public", {
|
|
152
|
+
record: any;
|
|
153
|
+
ownerId: string;
|
|
154
|
+
}, Promise<void>>;
|
|
155
|
+
export declare const markCompleted: import("convex/server").RegisteredMutation<"public", {
|
|
156
|
+
error?: string | undefined;
|
|
157
|
+
endedHookEmittedAt?: number | undefined;
|
|
158
|
+
reason: string;
|
|
159
|
+
ownerId: string;
|
|
160
|
+
runId: string;
|
|
161
|
+
endedAt: number;
|
|
162
|
+
outcome: any;
|
|
163
|
+
}, Promise<{
|
|
164
|
+
_id: import("convex/values").GenericId<"subagentRuns">;
|
|
165
|
+
_creationTime: number;
|
|
166
|
+
model?: string | undefined;
|
|
167
|
+
workspaceDir?: string | undefined;
|
|
168
|
+
label?: string | undefined;
|
|
169
|
+
controllerSessionKey?: string | undefined;
|
|
170
|
+
requesterOrigin?: ArrayBuffer | undefined;
|
|
171
|
+
runTimeoutSeconds?: number | undefined;
|
|
172
|
+
spawnMode?: "session" | "run" | undefined;
|
|
173
|
+
startedAt?: number | undefined;
|
|
174
|
+
sessionStartedAt?: number | undefined;
|
|
175
|
+
accumulatedRuntimeMs?: number | undefined;
|
|
176
|
+
endedAt?: number | undefined;
|
|
177
|
+
outcome?: {
|
|
178
|
+
text?: ArrayBuffer | undefined;
|
|
179
|
+
error?: string | undefined;
|
|
180
|
+
reason?: string | undefined;
|
|
181
|
+
status: "error" | "timeout" | "ok" | "abort";
|
|
182
|
+
} | undefined;
|
|
183
|
+
archiveAtMs?: number | undefined;
|
|
184
|
+
cleanupCompletedAt?: number | undefined;
|
|
185
|
+
cleanupHandled?: boolean | undefined;
|
|
186
|
+
suppressAnnounceReason?: "steer-restart" | "killed" | undefined;
|
|
187
|
+
expectsCompletionMessage?: boolean | undefined;
|
|
188
|
+
announceRetryCount?: number | undefined;
|
|
189
|
+
lastAnnounceRetryAt?: number | undefined;
|
|
190
|
+
endedReason?: string | undefined;
|
|
191
|
+
wakeOnDescendantSettle?: boolean | undefined;
|
|
192
|
+
frozenResultText?: ArrayBuffer | undefined;
|
|
193
|
+
frozenResultCapturedAt?: number | undefined;
|
|
194
|
+
fallbackFrozenResultText?: ArrayBuffer | undefined;
|
|
195
|
+
fallbackFrozenResultCapturedAt?: number | undefined;
|
|
196
|
+
endedHookEmittedAt?: number | undefined;
|
|
197
|
+
completionAnnouncedAt?: number | undefined;
|
|
198
|
+
attachmentsDir?: string | undefined;
|
|
199
|
+
attachmentsRootDir?: string | undefined;
|
|
200
|
+
retainAttachmentsOnKeep?: boolean | undefined;
|
|
201
|
+
createdAt: number;
|
|
202
|
+
ownerId: string;
|
|
203
|
+
cleanup: "delete" | "keep";
|
|
204
|
+
runId: string;
|
|
205
|
+
childSessionKey: string;
|
|
206
|
+
requesterSessionKey: string;
|
|
207
|
+
requesterDisplayKey: string;
|
|
208
|
+
task: ArrayBuffer;
|
|
209
|
+
} | null>>;
|
|
210
|
+
export declare const remove: import("convex/server").RegisteredMutation<"public", {
|
|
211
|
+
ownerId: string;
|
|
212
|
+
runId: string;
|
|
213
|
+
}, Promise<boolean>>;
|
|
214
|
+
//# sourceMappingURL=subagents.d.ts.map
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// convex/subagents.ts — subagentRuns
|
|
2
|
+
import { v } from "convex/values";
|
|
3
|
+
import { mutation, query } from "./_generated/server.js";
|
|
4
|
+
|
|
5
|
+
export const get = query({
|
|
6
|
+
args: { ownerId: v.string(), runId: v.string() },
|
|
7
|
+
handler: async (ctx, args) => {
|
|
8
|
+
return ctx.db
|
|
9
|
+
.query("subagentRuns")
|
|
10
|
+
.withIndex("by_runId", (q) => q.eq("ownerId", args.ownerId).eq("runId", args.runId))
|
|
11
|
+
.first();
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export const getByChildSessionKey = query({
|
|
16
|
+
args: { ownerId: v.string(), childSessionKey: v.string() },
|
|
17
|
+
handler: async (ctx, args) => {
|
|
18
|
+
return ctx.db
|
|
19
|
+
.query("subagentRuns")
|
|
20
|
+
.withIndex("by_childSessionKey_active", (q) =>
|
|
21
|
+
q.eq("ownerId", args.ownerId).eq("childSessionKey", args.childSessionKey),
|
|
22
|
+
)
|
|
23
|
+
.order("desc")
|
|
24
|
+
.first();
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export const listByRequester = query({
|
|
29
|
+
args: { ownerId: v.string(), requesterSessionKey: v.string() },
|
|
30
|
+
handler: async (ctx, args) => {
|
|
31
|
+
return ctx.db
|
|
32
|
+
.query("subagentRuns")
|
|
33
|
+
.withIndex("by_requester_createdAt", (q) =>
|
|
34
|
+
q.eq("ownerId", args.ownerId).eq("requesterSessionKey", args.requesterSessionKey),
|
|
35
|
+
)
|
|
36
|
+
.collect();
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
export const put = mutation({
|
|
41
|
+
args: { ownerId: v.string(), record: v.any() },
|
|
42
|
+
handler: async (ctx, args) => {
|
|
43
|
+
const record = args.record as Record<string, unknown> & { runId?: string };
|
|
44
|
+
const runId = record.runId;
|
|
45
|
+
if (typeof runId !== "string" || runId.length === 0) {
|
|
46
|
+
throw new Error("subagents.put: record requires `runId`");
|
|
47
|
+
}
|
|
48
|
+
const existing = await ctx.db
|
|
49
|
+
.query("subagentRuns")
|
|
50
|
+
.withIndex("by_runId", (q) => q.eq("ownerId", args.ownerId).eq("runId", runId))
|
|
51
|
+
.first();
|
|
52
|
+
const payload = { ...record, ownerId: args.ownerId };
|
|
53
|
+
if (existing) {
|
|
54
|
+
await ctx.db.replace(existing._id, payload as never);
|
|
55
|
+
} else {
|
|
56
|
+
await ctx.db.insert("subagentRuns", payload as never);
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
export const markCompleted = mutation({
|
|
62
|
+
args: {
|
|
63
|
+
ownerId: v.string(),
|
|
64
|
+
runId: v.string(),
|
|
65
|
+
endedAt: v.number(),
|
|
66
|
+
outcome: v.any(),
|
|
67
|
+
reason: v.string(),
|
|
68
|
+
error: v.optional(v.string()),
|
|
69
|
+
endedHookEmittedAt: v.optional(v.number()),
|
|
70
|
+
},
|
|
71
|
+
handler: async (ctx, args) => {
|
|
72
|
+
const existing = await ctx.db
|
|
73
|
+
.query("subagentRuns")
|
|
74
|
+
.withIndex("by_runId", (q) => q.eq("ownerId", args.ownerId).eq("runId", args.runId))
|
|
75
|
+
.first();
|
|
76
|
+
if (!existing) return null;
|
|
77
|
+
await ctx.db.patch(existing._id, {
|
|
78
|
+
endedAt: args.endedAt,
|
|
79
|
+
outcome: args.outcome as never,
|
|
80
|
+
endedReason: args.reason,
|
|
81
|
+
...(args.error !== undefined ? { outcome: { ...(args.outcome as object), error: args.error } as never } : {}),
|
|
82
|
+
...(args.endedHookEmittedAt !== undefined ? { endedHookEmittedAt: args.endedHookEmittedAt } : {}),
|
|
83
|
+
});
|
|
84
|
+
return await ctx.db.get(existing._id);
|
|
85
|
+
},
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
export const remove = mutation({
|
|
89
|
+
args: { ownerId: v.string(), runId: v.string() },
|
|
90
|
+
handler: async (ctx, args) => {
|
|
91
|
+
const existing = await ctx.db
|
|
92
|
+
.query("subagentRuns")
|
|
93
|
+
.withIndex("by_runId", (q) => q.eq("ownerId", args.ownerId).eq("runId", args.runId))
|
|
94
|
+
.first();
|
|
95
|
+
if (!existing) return false;
|
|
96
|
+
await ctx.db.delete(existing._id);
|
|
97
|
+
return true;
|
|
98
|
+
},
|
|
99
|
+
});
|