@eve/board 0.2.0 → 0.2.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.
|
@@ -27,6 +27,7 @@ declare const _default: import("eve/extension").ExtensionHandle<z.ZodObject<{
|
|
|
27
27
|
}>>>]>>]>>;
|
|
28
28
|
watchChannel: z.ZodOptional<z.ZodString>;
|
|
29
29
|
authorize: z.ZodOptional<z.ZodCustom<BoardAuthorize, BoardAuthorize>>;
|
|
30
|
+
configurers: z.ZodOptional<z.ZodUnknown>;
|
|
30
31
|
route: z.ZodOptional<z.ZodString>;
|
|
31
32
|
boards: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
32
33
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -50,6 +51,7 @@ declare const _default: import("eve/extension").ExtensionHandle<z.ZodObject<{
|
|
|
50
51
|
}>>>]>>]>>;
|
|
51
52
|
watchChannel: z.ZodOptional<z.ZodString>;
|
|
52
53
|
authorize: z.ZodOptional<z.ZodCustom<BoardAuthorize, BoardAuthorize>>;
|
|
54
|
+
configurers: z.ZodOptional<z.ZodUnknown>;
|
|
53
55
|
}, z.core.$strip>>>;
|
|
54
56
|
}, z.core.$strip>>;
|
|
55
57
|
export default _default;
|
|
@@ -14,6 +14,8 @@ const profile = z.string().regex(BOARD_NAME_PATTERN, "a letter, then up to 31 le
|
|
|
14
14
|
const can = z.union([grant, z.record(z.string().refine((pattern) => pattern === "*" || BOARD_CHANNEL_SELECTOR.test(pattern), "a channel, a subtree such as `work/`, or `*`"), grant)]);
|
|
15
15
|
const watchChannel = z.string().max(200).regex(BOARD_CHANNEL_SELECTOR, "lowercase segments joined by /").refine((channel) => !channel.endsWith("/"), "one channel, not a subtree");
|
|
16
16
|
const authorize = fn();
|
|
17
|
+
const removedConfigurers = z.unknown().optional();
|
|
18
|
+
const CONFIGURERS_REMOVED = "`configurers` was removed; use `authorize` to decide who may manage board watches. See https://eve.dev/docs/channels/board.";
|
|
17
19
|
const boardUrl = z.string().url().refine((value) => /^https?:\/\//u.test(value), "an http:// or https:// board URL");
|
|
18
20
|
const boardEntry = z.object({
|
|
19
21
|
name: z.string().min(1).max(64).optional(),
|
|
@@ -22,7 +24,8 @@ const boardEntry = z.object({
|
|
|
22
24
|
profile: profile.optional(),
|
|
23
25
|
can: can.optional(),
|
|
24
26
|
watchChannel: watchChannel.optional(),
|
|
25
|
-
authorize: authorize.optional()
|
|
27
|
+
authorize: authorize.optional(),
|
|
28
|
+
configurers: removedConfigurers
|
|
26
29
|
});
|
|
27
30
|
var extension_default = defineExtension({ config: z.object({
|
|
28
31
|
name: z.string().min(1).max(64).optional(),
|
|
@@ -32,9 +35,24 @@ var extension_default = defineExtension({ config: z.object({
|
|
|
32
35
|
can: can.optional(),
|
|
33
36
|
watchChannel: watchChannel.optional(),
|
|
34
37
|
authorize: authorize.optional(),
|
|
38
|
+
configurers: removedConfigurers,
|
|
35
39
|
route: z.string().min(1).refine(isValidBoardRouteBase, "an absolute path without parameters or query string, such as \"/eve/v1/board\"").optional(),
|
|
36
40
|
boards: z.record(z.string().regex(BOARD_NAME_PATTERN, "a letter, then up to 31 letters, numbers, or hyphens"), boardEntry).optional()
|
|
37
41
|
}).superRefine((value, ctx) => {
|
|
42
|
+
if (value.configurers !== void 0) ctx.addIssue({
|
|
43
|
+
code: "custom",
|
|
44
|
+
message: CONFIGURERS_REMOVED,
|
|
45
|
+
path: ["configurers"]
|
|
46
|
+
});
|
|
47
|
+
for (const [key, entry] of Object.entries(value.boards ?? {})) if (entry.configurers !== void 0) ctx.addIssue({
|
|
48
|
+
code: "custom",
|
|
49
|
+
message: CONFIGURERS_REMOVED,
|
|
50
|
+
path: [
|
|
51
|
+
"boards",
|
|
52
|
+
key,
|
|
53
|
+
"configurers"
|
|
54
|
+
]
|
|
55
|
+
});
|
|
38
56
|
if (value.boards === void 0) return;
|
|
39
57
|
const entries = Object.entries(value.boards);
|
|
40
58
|
if (entries.length === 0) ctx.addIssue({
|
|
@@ -213,6 +213,7 @@ export interface BoardClient {
|
|
|
213
213
|
thread(id: string, range?: {
|
|
214
214
|
readonly after?: string;
|
|
215
215
|
}): Promise<BoardThread>;
|
|
216
|
+
posted(id: string): Promise<BoardMessage>;
|
|
216
217
|
linked(url: string): Promise<BoardThread>;
|
|
217
218
|
threads(query?: BoardThreadsQuery): Promise<readonly BoardThreadSummary[]>;
|
|
218
219
|
threadsPage(query?: BoardThreadsQuery): Promise<BoardThreadsPage>;
|
|
@@ -169,6 +169,7 @@ function createBoardClient(board, can) {
|
|
|
169
169
|
await handle.typing(id, status === void 0 ? void 0 : status.slice(0, 50));
|
|
170
170
|
},
|
|
171
171
|
thread: async (id, range = {}) => threadOf(await handle.thread(id, range.after === void 0 ? {} : { after: range.after })),
|
|
172
|
+
posted: async (id) => messageOf(await handle.posted(id)),
|
|
172
173
|
linked: async (url) => threadOf(await handle.linked(url)),
|
|
173
174
|
async threads(query = {}) {
|
|
174
175
|
return (await threadsPage(query)).threads;
|
|
@@ -13,6 +13,7 @@ const MAX_WATCHES = 64;
|
|
|
13
13
|
const WATCH_LABEL = "eve-watch";
|
|
14
14
|
const STATE_LABEL = "eve-watch-state";
|
|
15
15
|
const LOCK_LABEL = "eve-lock";
|
|
16
|
+
const LOCK_CLIENT_ID = "eve-watch-lock";
|
|
16
17
|
const LOCK_LEASE_SECONDS = 30;
|
|
17
18
|
const LOCK_WAIT_MS = 3e4;
|
|
18
19
|
var BoardWatchConfigError = class extends Error {
|
|
@@ -150,7 +151,7 @@ async function heldRegistration(client) {
|
|
|
150
151
|
}
|
|
151
152
|
const localLocks = new Map();
|
|
152
153
|
async function withRegistrationLock(client, watchChannel, boardKey, run) {
|
|
153
|
-
const key = `${boardKey}\n${client.profile}
|
|
154
|
+
const key = `${boardKey}\n${client.profile}`;
|
|
154
155
|
const turn = (localLocks.get(key) ?? Promise.resolve()).catch(() => {}).then(async () => {
|
|
155
156
|
const claim = await claimLock(client, await lockTask(client, watchChannel));
|
|
156
157
|
try {
|
|
@@ -166,20 +167,33 @@ async function withRegistrationLock(client, watchChannel, boardKey, run) {
|
|
|
166
167
|
if (localLocks.get(key) === turn) localLocks.delete(key);
|
|
167
168
|
}
|
|
168
169
|
}
|
|
170
|
+
const REUSED_CLIENT_ID = new Set(["client_id_taken", "duplicate_id"]);
|
|
169
171
|
async function lockTask(client, watchChannel) {
|
|
170
|
-
const
|
|
171
|
-
const
|
|
172
|
-
if (
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
172
|
+
const lock = await existingLock(client) ?? await createLock(client, watchChannel);
|
|
173
|
+
const state = lock.task?.state;
|
|
174
|
+
if (state !== "ready" && state !== "claimed") throw new Error(`The board task that serializes this agent's watch changes, #${lock.id} in "${lock.channel}", is ${state ?? "not a task"}. Reopen it so watches can change again.`);
|
|
175
|
+
return lock.id;
|
|
176
|
+
}
|
|
177
|
+
async function existingLock(client) {
|
|
178
|
+
try {
|
|
179
|
+
return await client.posted(LOCK_CLIENT_ID);
|
|
180
|
+
} catch (error) {
|
|
181
|
+
if (boardErrorCode(error) !== "post_not_found") throw error;
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
async function createLock(client, watchChannel) {
|
|
186
|
+
try {
|
|
187
|
+
return await client.createTask(watchChannel, {
|
|
188
|
+
id: LOCK_CLIENT_ID,
|
|
189
|
+
labels: { [LOCK_LABEL]: "registration" },
|
|
190
|
+
noSync: true,
|
|
191
|
+
text: "eve holds this task while it changes its board watches, so two changes never overwrite each other. Leave it open."
|
|
192
|
+
});
|
|
193
|
+
} catch (error) {
|
|
194
|
+
if (!REUSED_CLIENT_ID.has(boardErrorCode(error) ?? "")) throw error;
|
|
195
|
+
return await client.posted(LOCK_CLIENT_ID);
|
|
176
196
|
}
|
|
177
|
-
return (await client.createTask(watchChannel, {
|
|
178
|
-
id: "eve-watch-lock",
|
|
179
|
-
labels: { [LOCK_LABEL]: "registration" },
|
|
180
|
-
noSync: true,
|
|
181
|
-
text: "eve holds this task while it changes its board watches, so two changes never overwrite each other. Leave it open."
|
|
182
|
-
})).id;
|
|
183
197
|
}
|
|
184
198
|
async function claimLock(client, taskId) {
|
|
185
199
|
const deadline = Date.now() + LOCK_WAIT_MS;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eve/board",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Vercel Board for eve agents: a channel that wakes the agent for watches it manages with tools, claims tasks, and replies in board threads",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eve",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/node": "26.6.6",
|
|
52
|
-
"eve": "1.
|
|
52
|
+
"eve": "1.6.0",
|
|
53
53
|
"typescript": "7.0.2"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|