@abyssinia-labs/wake-convex 0.1.0 → 0.3.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/README.md +6 -5
- package/dist/client/index.d.ts +61 -2
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +23 -2
- package/dist/client/index.js.map +1 -1
- package/dist/component/_generated/api.d.ts +4 -0
- package/dist/component/_generated/api.d.ts.map +1 -1
- package/dist/component/_generated/api.js.map +1 -1
- package/dist/component/_generated/component.d.ts +55 -0
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/runs.d.ts +36 -0
- package/dist/component/runs.d.ts.map +1 -0
- package/dist/component/runs.js +38 -0
- package/dist/component/runs.js.map +1 -0
- package/dist/component/schema.d.ts +37 -1
- package/dist/component/schema.d.ts.map +1 -1
- package/dist/component/schema.js +11 -0
- package/dist/component/schema.js.map +1 -1
- package/dist/component/shape.d.ts +5 -0
- package/dist/component/shape.d.ts.map +1 -1
- package/dist/component/shape.js +6 -0
- package/dist/component/shape.js.map +1 -1
- package/dist/component/summonses.d.ts +14 -0
- package/dist/component/summonses.d.ts.map +1 -1
- package/dist/component/summonses.js +3 -25
- package/dist/component/summonses.js.map +1 -1
- package/dist/component/views.d.ts +90 -0
- package/dist/component/views.d.ts.map +1 -0
- package/dist/component/views.js +40 -0
- package/dist/component/views.js.map +1 -0
- package/dist/component/wire.d.ts +14 -0
- package/dist/component/wire.d.ts.map +1 -1
- package/dist/component/wire.js +37 -1
- package/dist/component/wire.js.map +1 -1
- package/package.json +1 -1
- package/src/client/index.ts +24 -2
- package/src/component/_generated/api.ts +4 -0
- package/src/component/_generated/component.ts +55 -0
- package/src/component/runs.ts +36 -0
- package/src/component/schema.ts +11 -0
- package/src/component/shape.ts +8 -0
- package/src/component/summonses.ts +3 -26
- package/src/component/views.ts +42 -0
- package/src/component/wire.ts +36 -1
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// A summons as the host reads it back: the same shape from `forSubject`
|
|
2
|
+
// (where it was made) and `runs.forOwner` (what a person's agents did).
|
|
3
|
+
import { v } from "convex/values";
|
|
4
|
+
import type { Doc } from "./_generated/dataModel.js";
|
|
5
|
+
import { run, state, target } from "./schema.js";
|
|
6
|
+
|
|
7
|
+
export const summonsView = v.object({
|
|
8
|
+
id: v.string(),
|
|
9
|
+
agent: v.string(),
|
|
10
|
+
owner: v.string(),
|
|
11
|
+
askedBy: v.string(),
|
|
12
|
+
scope: v.optional(v.string()),
|
|
13
|
+
subject: v.string(),
|
|
14
|
+
kind: v.string(),
|
|
15
|
+
target,
|
|
16
|
+
state,
|
|
17
|
+
at: v.number(),
|
|
18
|
+
updatedAt: v.number(),
|
|
19
|
+
reason: v.optional(v.string()),
|
|
20
|
+
unclaimed: v.boolean(),
|
|
21
|
+
/** Its run once Wake said it started. `session` is the owner's to see. */
|
|
22
|
+
run: v.optional(run),
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export function viewOf(row: Doc<"summonses">) {
|
|
26
|
+
return {
|
|
27
|
+
id: row._id,
|
|
28
|
+
agent: row.agent,
|
|
29
|
+
owner: row.owner,
|
|
30
|
+
askedBy: row.askedBy,
|
|
31
|
+
...(row.scope === undefined ? {} : { scope: row.scope }),
|
|
32
|
+
subject: row.subject,
|
|
33
|
+
kind: row.kind,
|
|
34
|
+
target: row.target,
|
|
35
|
+
state: row.state,
|
|
36
|
+
at: row.at,
|
|
37
|
+
updatedAt: row.updatedAt,
|
|
38
|
+
...(row.reason === undefined ? {} : { reason: row.reason }),
|
|
39
|
+
unclaimed: row.state === "open" && row.noticedAt !== undefined,
|
|
40
|
+
...(row.run === undefined ? {} : { run: row.run }),
|
|
41
|
+
};
|
|
42
|
+
}
|
package/src/component/wire.ts
CHANGED
|
@@ -6,7 +6,8 @@ import { ConvexError, v } from "convex/values";
|
|
|
6
6
|
import type { Doc } from "./_generated/dataModel.js";
|
|
7
7
|
import { type MutationCtx, mutation, type QueryCtx, query } from "./_generated/server.js";
|
|
8
8
|
import { hashSecret, KEY_SHAPE } from "./keys.js";
|
|
9
|
-
import { target } from "./schema.js";
|
|
9
|
+
import { target, tool } from "./schema.js";
|
|
10
|
+
import { isRunReport } from "./shape.js";
|
|
10
11
|
|
|
11
12
|
/** Oldest first, at most this many: Wake runs two at a time. */
|
|
12
13
|
const PENDING_LIMIT = 50;
|
|
@@ -78,6 +79,40 @@ export const claim = mutation({
|
|
|
78
79
|
},
|
|
79
80
|
});
|
|
80
81
|
|
|
82
|
+
/**
|
|
83
|
+
* wake:started: the agent is running, under a name people see and the
|
|
84
|
+
* session its owner resumes. A later call for the same run replaces the
|
|
85
|
+
* first (the session id of Codex and Cursor comes after they start).
|
|
86
|
+
*/
|
|
87
|
+
export const started = mutation({
|
|
88
|
+
args: {
|
|
89
|
+
key: v.string(),
|
|
90
|
+
id: v.string(),
|
|
91
|
+
run: v.object({ name: v.string(), tool, session: v.optional(v.string()) }),
|
|
92
|
+
},
|
|
93
|
+
returns: v.null(),
|
|
94
|
+
handler: async (ctx, args) => {
|
|
95
|
+
const place = await placeOf(ctx, args.key);
|
|
96
|
+
const id = ctx.db.normalizeId("summonses", args.id);
|
|
97
|
+
const row = id ? await ctx.db.get(id) : null;
|
|
98
|
+
if (!row || row.place !== place._id || row.state !== "claimed") return null;
|
|
99
|
+
if (!isRunReport(args.run)) return null;
|
|
100
|
+
const now = Date.now();
|
|
101
|
+
await ctx.db.patch(row._id, {
|
|
102
|
+
run: {
|
|
103
|
+
name: args.run.name,
|
|
104
|
+
tool: args.run.tool,
|
|
105
|
+
...(args.run.session === undefined ? {} : { session: args.run.session }),
|
|
106
|
+
machine: place.machine,
|
|
107
|
+
startedAt: row.run?.startedAt ?? now,
|
|
108
|
+
},
|
|
109
|
+
updatedAt: now,
|
|
110
|
+
});
|
|
111
|
+
await ctx.db.patch(place._id, { lastSeenAt: now });
|
|
112
|
+
return null;
|
|
113
|
+
},
|
|
114
|
+
});
|
|
115
|
+
|
|
81
116
|
/** wake:finish: what became of a run this place claimed. */
|
|
82
117
|
export const finish = mutation({
|
|
83
118
|
args: {
|