@spinabot/brigade 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/convex/_generated/api.d.ts +85 -0
  2. package/convex/_generated/api.js +23 -0
  3. package/convex/_generated/dataModel.d.ts +60 -0
  4. package/convex/_generated/server.d.ts +143 -0
  5. package/convex/_generated/server.js +93 -0
  6. package/convex/admin.d.ts +57 -0
  7. package/convex/admin.ts +315 -0
  8. package/convex/auth.d.ts +159 -0
  9. package/convex/auth.ts +217 -0
  10. package/convex/blobs.d.ts +38 -0
  11. package/convex/blobs.ts +115 -0
  12. package/convex/channels.d.ts +150 -0
  13. package/convex/channels.ts +455 -0
  14. package/convex/config.d.ts +67 -0
  15. package/convex/config.ts +168 -0
  16. package/convex/cron.d.ts +237 -0
  17. package/convex/cron.ts +199 -0
  18. package/convex/execApprovals.d.ts +31 -0
  19. package/convex/execApprovals.ts +58 -0
  20. package/convex/extensions.d.ts +30 -0
  21. package/convex/extensions.ts +51 -0
  22. package/convex/health.d.ts +18 -0
  23. package/convex/health.ts +69 -0
  24. package/convex/instance.d.ts +34 -0
  25. package/convex/instance.ts +82 -0
  26. package/convex/logs.d.ts +178 -0
  27. package/convex/logs.ts +253 -0
  28. package/convex/memory.d.ts +354 -0
  29. package/convex/memory.ts +536 -0
  30. package/convex/messages.d.ts +124 -0
  31. package/convex/messages.ts +347 -0
  32. package/convex/org.d.ts +75 -0
  33. package/convex/org.ts +99 -0
  34. package/convex/schema.d.ts +1130 -0
  35. package/convex/schema.ts +847 -0
  36. package/convex/sessions.d.ts +100 -0
  37. package/convex/sessions.ts +105 -0
  38. package/convex/skills.d.ts +73 -0
  39. package/convex/skills.ts +102 -0
  40. package/convex/subagents.d.ts +214 -0
  41. package/convex/subagents.ts +99 -0
  42. package/convex/tsconfig.json +23 -0
  43. package/convex/whatsappAuth.d.ts +52 -0
  44. package/convex/whatsappAuth.ts +151 -0
  45. package/convex/workspace.d.ts +49 -0
  46. package/convex/workspace.ts +106 -0
  47. package/dist/buildstamp.json +1 -1
  48. package/package.json +7 -1
  49. package/scripts/convex-dev.mjs +321 -0
  50. package/scripts/convex-push.mjs +69 -0
  51. package/scripts/install-convex.mjs +123 -0
@@ -0,0 +1,38 @@
1
+ export declare const generateUploadUrl: import("convex/server").RegisteredMutation<"public", {
2
+ sha256: string;
3
+ ownerId: string;
4
+ }, Promise<{
5
+ uploadUrl: string;
6
+ storageId: string | null;
7
+ existed: boolean;
8
+ ownerId: string;
9
+ }>>;
10
+ export declare const recordUpload: import("convex/server").RegisteredMutation<"public", {
11
+ contentType?: string | undefined;
12
+ sha256: string;
13
+ size: number;
14
+ ownerId: string;
15
+ storageId: import("convex/values").GenericId<"_storage">;
16
+ }, Promise<{
17
+ existed: boolean;
18
+ }>>;
19
+ export declare const getMeta: import("convex/server").RegisteredQuery<"public", {
20
+ sha256: string;
21
+ }, Promise<{
22
+ _id: import("convex/values").GenericId<"brigadeBlobs">;
23
+ _creationTime: number;
24
+ sha256: string;
25
+ size: number;
26
+ ownerId: string;
27
+ storageId: import("convex/values").GenericId<"_storage">;
28
+ mime: string;
29
+ refcount: number;
30
+ lastTouchedAt: number;
31
+ } | null>>;
32
+ export declare const getDownloadUrl: import("convex/server").RegisteredQuery<"public", {
33
+ sha256: string;
34
+ }, Promise<string | null>>;
35
+ export declare const remove: import("convex/server").RegisteredMutation<"public", {
36
+ sha256: string;
37
+ }, Promise<boolean>>;
38
+ //# sourceMappingURL=blobs.d.ts.map
@@ -0,0 +1,115 @@
1
+ // convex/blobs.ts — content-addressed bytes via Convex File Storage.
2
+ //
3
+ // Public surface:
4
+ // generateUploadUrl(sha256) — operator-facing one-time URL (client PUTs bytes)
5
+ // recordUpload(sha256, storageId, contentType?, size?)
6
+ // getUrl(sha256) — short-lived signed URL for download
7
+ // delete(sha256) — remove blob + storage row
8
+ //
9
+ // `brigadeBlobs` is the metadata side; the actual byte storage lives in
10
+ // Convex's `_storage` table managed by `storage.generateUploadUrl` and
11
+ // `storage.getUrl`.
12
+
13
+ import { v } from "convex/values";
14
+ import { mutation, query } from "./_generated/server.js";
15
+
16
+ export const generateUploadUrl = mutation({
17
+ args: { ownerId: v.string(), sha256: v.string() },
18
+ handler: async (ctx, args) => {
19
+ // Brief OCC: if this sha already has a row, hand back the existing
20
+ // upload URL so re-uploaders don't get a fresh storageId.
21
+ const existing = await ctx.db
22
+ .query("brigadeBlobs")
23
+ .withIndex("by_sha256", (q) => q.eq("sha256", args.sha256))
24
+ .first();
25
+ if (existing) {
26
+ return {
27
+ uploadUrl: await ctx.storage.generateUploadUrl(),
28
+ storageId: existing.storageId,
29
+ existed: true,
30
+ ownerId: args.ownerId,
31
+ };
32
+ }
33
+ return {
34
+ uploadUrl: await ctx.storage.generateUploadUrl(),
35
+ storageId: null as string | null,
36
+ existed: false,
37
+ ownerId: args.ownerId,
38
+ };
39
+ },
40
+ });
41
+
42
+ export const recordUpload = mutation({
43
+ args: {
44
+ ownerId: v.string(),
45
+ sha256: v.string(),
46
+ storageId: v.id("_storage"),
47
+ contentType: v.optional(v.string()),
48
+ size: v.number(),
49
+ },
50
+ handler: async (ctx, args) => {
51
+ const existing = await ctx.db
52
+ .query("brigadeBlobs")
53
+ .withIndex("by_sha256", (q) => q.eq("sha256", args.sha256))
54
+ .first();
55
+ if (existing) {
56
+ await ctx.db.patch(existing._id, {
57
+ refcount: (existing.refcount as number ?? 0) + 1,
58
+ lastTouchedAt: Date.now(),
59
+ });
60
+ return { existed: true };
61
+ }
62
+ await ctx.db.insert("brigadeBlobs", {
63
+ ownerId: args.ownerId,
64
+ sha256: args.sha256,
65
+ storageId: args.storageId,
66
+ mime: args.contentType ?? "application/octet-stream",
67
+ size: args.size,
68
+ refcount: 1,
69
+ lastTouchedAt: Date.now(),
70
+ });
71
+ return { existed: false };
72
+ },
73
+ });
74
+
75
+ export const getMeta = query({
76
+ args: { sha256: v.string() },
77
+ handler: async (ctx, args) => {
78
+ return ctx.db
79
+ .query("brigadeBlobs")
80
+ .withIndex("by_sha256", (q) => q.eq("sha256", args.sha256))
81
+ .first();
82
+ },
83
+ });
84
+
85
+ export const getDownloadUrl = query({
86
+ args: { sha256: v.string() },
87
+ handler: async (ctx, args) => {
88
+ const row = await ctx.db
89
+ .query("brigadeBlobs")
90
+ .withIndex("by_sha256", (q) => q.eq("sha256", args.sha256))
91
+ .first();
92
+ if (!row) return null;
93
+ return ctx.storage.getUrl(row.storageId);
94
+ },
95
+ });
96
+
97
+ export const remove = mutation({
98
+ args: { sha256: v.string() },
99
+ handler: async (ctx, args) => {
100
+ const row = await ctx.db
101
+ .query("brigadeBlobs")
102
+ .withIndex("by_sha256", (q) => q.eq("sha256", args.sha256))
103
+ .first();
104
+ if (!row) return false;
105
+ // Decrement refcount; only delete when zero.
106
+ const next = (row.refcount as number ?? 1) - 1;
107
+ if (next > 0) {
108
+ await ctx.db.patch(row._id, { refcount: next, lastTouchedAt: Date.now() });
109
+ return false;
110
+ }
111
+ await ctx.storage.delete(row.storageId);
112
+ await ctx.db.delete(row._id);
113
+ return true;
114
+ },
115
+ });
@@ -0,0 +1,150 @@
1
+ export declare const listAccess: import("convex/server").RegisteredQuery<"public", {
2
+ accountId: string;
3
+ kind: "allow-from" | "group-allow-from" | "pairing";
4
+ channelId: string;
5
+ ownerId: string;
6
+ }, Promise<{
7
+ _id: import("convex/values").GenericId<"channelAccess">;
8
+ _creationTime: number;
9
+ code?: ArrayBuffer | undefined;
10
+ senderName?: string | undefined;
11
+ createdAt?: number | undefined;
12
+ lastSeenAt?: number | undefined;
13
+ accountId: string;
14
+ kind: "allow-from" | "group-allow-from" | "pairing";
15
+ channelId: string;
16
+ ownerId: string;
17
+ senderId: ArrayBuffer;
18
+ }[]>>;
19
+ /** Every access row for the owner — single-operator scale keeps this tiny.
20
+ * Boot hydration uses it to fill the in-process access cache in one query
21
+ * instead of guessing the channel/account layout from config. */
22
+ export declare const listAllAccess: import("convex/server").RegisteredQuery<"public", {
23
+ ownerId: string;
24
+ }, Promise<{
25
+ _id: import("convex/values").GenericId<"channelAccess">;
26
+ _creationTime: number;
27
+ code?: ArrayBuffer | undefined;
28
+ senderName?: string | undefined;
29
+ createdAt?: number | undefined;
30
+ lastSeenAt?: number | undefined;
31
+ accountId: string;
32
+ kind: "allow-from" | "group-allow-from" | "pairing";
33
+ channelId: string;
34
+ ownerId: string;
35
+ senderId: ArrayBuffer;
36
+ }[]>>;
37
+ /** Replace the row set for one (channel, account, kind) in a single
38
+ * transaction — the convex-mode realisation of the filesystem's
39
+ * whole-file atomic write. Caller-supplied codes/timestamps are
40
+ * authoritative so locally-generated pairing codes survive verbatim. */
41
+ export declare const reconcileAccess: import("convex/server").RegisteredMutation<"public", {
42
+ accountId: string;
43
+ kind: "allow-from" | "group-allow-from" | "pairing";
44
+ channelId: string;
45
+ ownerId: string;
46
+ rows: {
47
+ code?: ArrayBuffer | undefined;
48
+ senderName?: string | undefined;
49
+ createdAt: number;
50
+ senderId: ArrayBuffer;
51
+ lastSeenAt: number;
52
+ }[];
53
+ }, Promise<{
54
+ count: number;
55
+ }>>;
56
+ export declare const upsertAccess: import("convex/server").RegisteredMutation<"public", {
57
+ code?: ArrayBuffer | undefined;
58
+ senderName?: string | undefined;
59
+ accountId: string;
60
+ kind: "allow-from" | "group-allow-from" | "pairing";
61
+ channelId: string;
62
+ ownerId: string;
63
+ senderId: ArrayBuffer;
64
+ }, Promise<{
65
+ changed: boolean;
66
+ }>>;
67
+ export declare const removeAccess: import("convex/server").RegisteredMutation<"public", {
68
+ accountId: string;
69
+ kind: "allow-from" | "group-allow-from" | "pairing";
70
+ channelId: string;
71
+ ownerId: string;
72
+ senderId: ArrayBuffer;
73
+ }, Promise<boolean>>;
74
+ export declare const eraseAccount: import("convex/server").RegisteredMutation<"public", {
75
+ accountId: string;
76
+ channelId: string;
77
+ ownerId: string;
78
+ }, Promise<void>>;
79
+ export declare const upsertPairingRequest: import("convex/server").RegisteredMutation<"public", {
80
+ senderName?: string | undefined;
81
+ accountId: string;
82
+ channelId: string;
83
+ ownerId: string;
84
+ senderId: ArrayBuffer;
85
+ }, Promise<{
86
+ code: string;
87
+ isNew: boolean;
88
+ }>>;
89
+ export declare const approvePairing: import("convex/server").RegisteredMutation<"public", {
90
+ code: string;
91
+ accountId: string;
92
+ channelId: string;
93
+ ownerId: string;
94
+ }, Promise<{
95
+ code: string;
96
+ senderId: string;
97
+ senderName: string | null;
98
+ } | null>>;
99
+ export declare const revokePairing: import("convex/server").RegisteredMutation<"public", {
100
+ code: string;
101
+ accountId: string;
102
+ channelId: string;
103
+ ownerId: string;
104
+ }, Promise<boolean>>;
105
+ export declare const generateMediaUploadUrl: import("convex/server").RegisteredMutation<"public", {}, Promise<string>>;
106
+ export declare const recordMediaBlob: import("convex/server").RegisteredMutation<"public", {
107
+ fileName?: string | undefined;
108
+ accountId: string;
109
+ channelId: string;
110
+ mimeType: string;
111
+ bytes: number;
112
+ index: number;
113
+ ownerId: string;
114
+ messageId: string;
115
+ storageId: import("convex/values").GenericId<"_storage">;
116
+ }, Promise<{
117
+ ok: boolean;
118
+ }>>;
119
+ export declare const getMediaBlobUrl: import("convex/server").RegisteredQuery<"public", {
120
+ accountId: string;
121
+ channelId: string;
122
+ index: number;
123
+ ownerId: string;
124
+ messageId: string;
125
+ }, Promise<{
126
+ url: string;
127
+ mimeType: string;
128
+ bytes: number;
129
+ } | null>>;
130
+ export declare const writeAuthFile: import("convex/server").RegisteredMutation<"public", {
131
+ accountId: string;
132
+ ownerId: string;
133
+ fileKey: string;
134
+ contentB64: ArrayBuffer;
135
+ }, Promise<void>>;
136
+ export declare const readAuthFile: import("convex/server").RegisteredQuery<"public", {
137
+ accountId: string;
138
+ ownerId: string;
139
+ fileKey: string;
140
+ }, Promise<{
141
+ _id: import("convex/values").GenericId<"whatsappAuthFile">;
142
+ _creationTime: number;
143
+ accountId: string;
144
+ ownerId: string;
145
+ updatedAt: number;
146
+ fileKey: string;
147
+ contentB64: ArrayBuffer;
148
+ contentVersion: number;
149
+ } | null>>;
150
+ //# sourceMappingURL=channels.d.ts.map