@eve/board 0.0.0 → 0.2.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.
Files changed (74) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +101 -0
  3. package/README.md +36 -2
  4. package/dist/extension/_manifest.json +6 -0
  5. package/dist/extension/channels/board.d.ts +2 -0
  6. package/dist/extension/channels/board.mjs +9 -0
  7. package/dist/extension/extension.d.ts +55 -0
  8. package/dist/extension/extension.mjs +70 -0
  9. package/dist/extension/instructions/boards.d.ts +2 -0
  10. package/dist/extension/instructions/boards.mjs +14 -0
  11. package/dist/extension/instructions.md +9 -0
  12. package/dist/extension/lib/authorize.d.ts +27 -0
  13. package/dist/extension/lib/authorize.mjs +7 -0
  14. package/dist/extension/lib/board-channel.d.ts +103 -0
  15. package/dist/extension/lib/board-channel.mjs +528 -0
  16. package/dist/extension/lib/boards.d.ts +28 -0
  17. package/dist/extension/lib/boards.mjs +103 -0
  18. package/dist/extension/lib/channel.d.ts +12 -0
  19. package/dist/extension/lib/channel.mjs +12 -0
  20. package/dist/extension/lib/client.d.ts +256 -0
  21. package/dist/extension/lib/client.mjs +363 -0
  22. package/dist/extension/lib/inbound.d.ts +21 -0
  23. package/dist/extension/lib/inbound.mjs +121 -0
  24. package/dist/extension/lib/route.d.ts +5 -0
  25. package/dist/extension/lib/route.mjs +23 -0
  26. package/dist/extension/lib/tools.d.ts +548 -0
  27. package/dist/extension/lib/tools.mjs +565 -0
  28. package/dist/extension/lib/watches.d.ts +95 -0
  29. package/dist/extension/lib/watches.mjs +330 -0
  30. package/dist/extension/skills/collaborate/SKILL.md +65 -0
  31. package/dist/extension/tools/actors.d.ts +10 -0
  32. package/dist/extension/tools/actors.mjs +10 -0
  33. package/dist/extension/tools/block_task.d.ts +3 -0
  34. package/dist/extension/tools/block_task.mjs +10 -0
  35. package/dist/extension/tools/cancel_schedule.d.ts +8 -0
  36. package/dist/extension/tools/cancel_schedule.mjs +10 -0
  37. package/dist/extension/tools/channels.d.ts +7 -0
  38. package/dist/extension/tools/channels.mjs +10 -0
  39. package/dist/extension/tools/complete_task.d.ts +3 -0
  40. package/dist/extension/tools/complete_task.mjs +10 -0
  41. package/dist/extension/tools/create_task.d.ts +28 -0
  42. package/dist/extension/tools/create_task.mjs +10 -0
  43. package/dist/extension/tools/fail_task.d.ts +3 -0
  44. package/dist/extension/tools/fail_task.mjs +10 -0
  45. package/dist/extension/tools/label.d.ts +11 -0
  46. package/dist/extension/tools/label.mjs +10 -0
  47. package/dist/extension/tools/no_reply.d.ts +1 -0
  48. package/dist/extension/tools/no_reply.mjs +7 -0
  49. package/dist/extension/tools/note.d.ts +26 -0
  50. package/dist/extension/tools/note.mjs +10 -0
  51. package/dist/extension/tools/post.d.ts +57 -0
  52. package/dist/extension/tools/post.mjs +10 -0
  53. package/dist/extension/tools/react.d.ts +19 -0
  54. package/dist/extension/tools/react.mjs +10 -0
  55. package/dist/extension/tools/read.d.ts +195 -0
  56. package/dist/extension/tools/read.mjs +10 -0
  57. package/dist/extension/tools/reply.d.ts +57 -0
  58. package/dist/extension/tools/reply.mjs +10 -0
  59. package/dist/extension/tools/schedule.d.ts +17 -0
  60. package/dist/extension/tools/schedule.mjs +10 -0
  61. package/dist/extension/tools/schedules.d.ts +9 -0
  62. package/dist/extension/tools/schedules.mjs +10 -0
  63. package/dist/extension/tools/unwatch.d.ts +9 -0
  64. package/dist/extension/tools/unwatch.mjs +10 -0
  65. package/dist/extension/tools/watch.d.ts +25 -0
  66. package/dist/extension/tools/watch.mjs +10 -0
  67. package/dist/extension/tools/watches.d.ts +20 -0
  68. package/dist/extension/tools/watches.mjs +10 -0
  69. package/dist/index.d.ts +4 -0
  70. package/dist/index.mjs +7 -0
  71. package/dist/tools/index.d.ts +21 -0
  72. package/dist/tools/index.mjs +26 -0
  73. package/package.json +65 -14
  74. package/index.js +0 -1
@@ -0,0 +1,103 @@
1
+ import { fileURLToPath as __eveFileURLToPath } from "node:url";
2
+ import { dirname as __eveDirname } from "node:path";
3
+ import { createRequire as __eveCreateRequire } from "node:module";
4
+ const __filename = __eveFileURLToPath(import.meta.url);
5
+ __eveDirname(__filename);
6
+ __eveCreateRequire(import.meta.url);
7
+ import { normalizeBoardRouteBase } from "./route.mjs";
8
+ const DEFAULT_BOARD_KEY = "default";
9
+ const DEFAULT_WATCH_CHANNEL = "eve-config/watches";
10
+ function resolveBoards(settings) {
11
+ const routeBase = normalizeBoardRouteBase(settings.route);
12
+ if (settings.boards === void 0) {
13
+ const entry = {
14
+ authorize: settings.authorize,
15
+ can: settings.can,
16
+ key: DEFAULT_BOARD_KEY,
17
+ name: settings.name,
18
+ profile: settings.profile,
19
+ registrationRouteBase: routeBase,
20
+ routeBase,
21
+ shorthand: true,
22
+ team: settings.team,
23
+ url: settings.url,
24
+ watchChannel: settings.watchChannel ?? "eve-config/watches"
25
+ };
26
+ return {
27
+ byKey: new Map([[DEFAULT_BOARD_KEY, entry]]),
28
+ keys: [DEFAULT_BOARD_KEY],
29
+ routeBase,
30
+ shorthand: true
31
+ };
32
+ }
33
+ const byKey = new Map();
34
+ const keys = [];
35
+ for (const [key, entry] of Object.entries(settings.boards)) {
36
+ byKey.set(key, {
37
+ authorize: entry.authorize ?? settings.authorize,
38
+ can: entry.can,
39
+ key,
40
+ name: entry.name,
41
+ profile: entry.profile ?? settings.profile,
42
+ registrationRouteBase: `${routeBase}/${key}`,
43
+ routeBase,
44
+ shorthand: false,
45
+ team: entry.team,
46
+ url: entry.url,
47
+ watchChannel: entry.watchChannel ?? settings.watchChannel ?? "eve-config/watches"
48
+ });
49
+ keys.push(key);
50
+ }
51
+ if (keys.length === 0) throw new Error("Board extension `boards` must configure at least one board.");
52
+ return {
53
+ byKey,
54
+ keys,
55
+ routeBase,
56
+ shorthand: false
57
+ };
58
+ }
59
+ function lookupBoard(set, key) {
60
+ return set.byKey.get(key);
61
+ }
62
+ function selectBoard(set, requestedKey, sessionKey) {
63
+ if (requestedKey !== void 0) {
64
+ const found = lookupBoard(set, requestedKey);
65
+ if (found !== void 0) return found;
66
+ throw new Error(`Unknown board "${requestedKey}". Configured boards: ${set.keys.join(", ")}.`);
67
+ }
68
+ if (sessionKey != null && sessionKey.length > 0) {
69
+ const found = lookupBoard(set, sessionKey);
70
+ if (found !== void 0) return found;
71
+ throw new Error(`Board "${sessionKey}" from this session is no longer configured. Configured boards: ${set.keys.join(", ")}.`);
72
+ }
73
+ if (set.byKey.size === 1) return set.byKey.values().next().value;
74
+ throw new Error(`Pass \`board\` to choose which board to use. Configured boards: ${set.keys.join(", ")}.`);
75
+ }
76
+ function resolveSessionBoard(settings, sessionKey) {
77
+ const set = resolveBoards(settings);
78
+ if (sessionKey != null && sessionKey.length > 0) {
79
+ const found = lookupBoard(set, sessionKey);
80
+ if (found !== void 0) return found;
81
+ throw new Error(`Board "${sessionKey}" from this session is no longer configured. Configured boards: ${set.keys.join(", ")}.`);
82
+ }
83
+ if (set.byKey.size === 1) return set.byKey.values().next().value;
84
+ throw new Error(`This board session has no board key, and multiple boards are configured (${set.keys.join(", ")}).`);
85
+ }
86
+ function formatConfiguredBoards(settings) {
87
+ const set = resolveBoards(settings);
88
+ if (set.shorthand) return null;
89
+ const lines = [...set.byKey.values()].map((entry) => {
90
+ const label = entry.name ?? "team default board";
91
+ const team = entry.team === void 0 ? "" : ` (team \`${entry.team}\`)`;
92
+ return `- \`${entry.key}\`: ${label}${team}`;
93
+ });
94
+ const requirement = set.keys.length > 1 ? "Outside a board session, pass `board` with one of the keys above to choose which board to use (except `watches`, which lists every board when `board` is omitted)." : `Pass \`board: "${set.keys[0]}"\` or leave \`board\` out to use it.`;
95
+ return [
96
+ "## Configured boards",
97
+ "",
98
+ ...lines,
99
+ "",
100
+ `In a session a board started, replies stay on that board and board tools default to that board. ${requirement}`
101
+ ].join("\n");
102
+ }
103
+ export { DEFAULT_BOARD_KEY, DEFAULT_WATCH_CHANNEL, formatConfiguredBoards, lookupBoard, resolveBoards, resolveSessionBoard, selectBoard };
@@ -0,0 +1,12 @@
1
+ import { type BoardChannel, type BoardChannelConfig } from "./board-channel.ts";
2
+ /**
3
+ * A channel for Vercel Board. Registered from your agent's own files, it uses the default board
4
+ * settings: mount the `@eve/board` extension to configure them. The board wakes it when a
5
+ * watch matches; each match runs the watch's stored instructions in a session on the matching
6
+ * board thread, or first claims a ready task and runs them on the task's thread. The agent's
7
+ * replies and typing go back to the thread, and from there to whatever Slack, GitHub, or Linear
8
+ * thread the board syncs. Watches are created with the `watch` tool, never by the channel.
9
+ */
10
+ export declare function boardChannel(config?: BoardChannelConfig): BoardChannel;
11
+ export type { BoardAuthorize, BoardAuthorizeAction, BoardAuthorizeRequest } from "./authorize.ts";
12
+ export type { BoardChannel, BoardChannelConfig, BoardChannelMetadata, BoardChannelState, BoardReceiveTarget, } from "./board-channel.ts";
@@ -0,0 +1,12 @@
1
+ import { fileURLToPath as __eveFileURLToPath } from "node:url";
2
+ import { dirname as __eveDirname } from "node:path";
3
+ import { createRequire as __eveCreateRequire } from "node:module";
4
+ const __filename = __eveFileURLToPath(import.meta.url);
5
+ __eveDirname(__filename);
6
+ __eveCreateRequire(import.meta.url);
7
+ import extension_default from "../extension.mjs";
8
+ import { createBoardChannel } from "./board-channel.mjs";
9
+ function boardChannel(config = {}) {
10
+ return createBoardChannel(() => extension_default.config, config);
11
+ }
12
+ export { boardChannel };
@@ -0,0 +1,256 @@
1
+ import type extension from "../extension.ts";
2
+ export interface BoardAuthor {
3
+ readonly actor: string;
4
+ readonly principal: string;
5
+ readonly profile: string | null;
6
+ }
7
+ export interface BoardActor {
8
+ readonly kind: string;
9
+ readonly handle: string;
10
+ readonly name: string;
11
+ }
12
+ export interface BoardAttachment {
13
+ readonly id: string;
14
+ readonly name: string;
15
+ readonly type: string;
16
+ readonly size: number;
17
+ }
18
+ export interface BoardTaskState {
19
+ readonly state: string;
20
+ readonly owner: string;
21
+ readonly claim: {
22
+ readonly actor: string;
23
+ readonly until: string;
24
+ } | null;
25
+ readonly blocked: {
26
+ readonly kind: string | null;
27
+ readonly reason: string;
28
+ } | null;
29
+ readonly result: string | null;
30
+ readonly reason: string | null;
31
+ }
32
+ export interface BoardMessage {
33
+ readonly id: string;
34
+ readonly channel: string;
35
+ readonly text: string;
36
+ readonly re: string | null;
37
+ readonly thread: string;
38
+ readonly labels: Readonly<Record<string, string>>;
39
+ readonly by: BoardAuthor;
40
+ readonly author: BoardActor | null;
41
+ readonly attachments: readonly BoardAttachment[];
42
+ readonly createdAt: string;
43
+ readonly deleted: boolean;
44
+ readonly noSync: boolean;
45
+ readonly schedule?: {
46
+ readonly id: string;
47
+ readonly n: number;
48
+ };
49
+ readonly task?: BoardTaskState;
50
+ }
51
+ export interface BoardWrittenMessage extends BoardMessage {
52
+ readonly unknownMentions?: readonly string[];
53
+ }
54
+ export interface BoardThread {
55
+ readonly message: BoardMessage;
56
+ readonly replies: readonly BoardMessage[];
57
+ }
58
+ export interface BoardThreadSummary {
59
+ readonly message: BoardMessage;
60
+ readonly replies: number;
61
+ readonly last: BoardMessage | null;
62
+ }
63
+ export interface BoardChannelSummary {
64
+ readonly path: string;
65
+ }
66
+ export interface BoardThreadsQuery {
67
+ readonly channel?: string;
68
+ readonly label?: readonly string[];
69
+ readonly mentions?: string;
70
+ readonly text?: string;
71
+ readonly after?: string;
72
+ readonly before?: string;
73
+ readonly limit?: number;
74
+ }
75
+ export interface BoardThreadsPage {
76
+ readonly threads: readonly BoardThreadSummary[];
77
+ readonly cursor: string;
78
+ readonly older: string | null;
79
+ readonly scanned?: number;
80
+ }
81
+ export interface BoardActorSummary {
82
+ readonly id: string;
83
+ readonly handle: string;
84
+ readonly name: string;
85
+ readonly kind: string;
86
+ }
87
+ export interface BoardPostOptions {
88
+ readonly text: string;
89
+ readonly labels?: Readonly<Record<string, string>>;
90
+ readonly noSync?: boolean;
91
+ readonly id?: string;
92
+ readonly attachments?: readonly string[];
93
+ readonly after?: string;
94
+ }
95
+ export interface BoardScheduleOptions {
96
+ readonly text: string;
97
+ readonly noSync?: boolean;
98
+ readonly in?: string;
99
+ readonly at?: string;
100
+ readonly every?: string;
101
+ readonly times?: number;
102
+ readonly until?: string;
103
+ }
104
+ export interface BoardSchedule {
105
+ readonly id: string;
106
+ readonly channel: string;
107
+ readonly re: string | null;
108
+ readonly text: string;
109
+ readonly next: string | null;
110
+ readonly state: string;
111
+ }
112
+ export interface BoardClaim {
113
+ readonly taskId: string;
114
+ readonly epoch: number;
115
+ readonly token: string;
116
+ readonly until: string;
117
+ }
118
+ export interface BoardClaimedTask extends BoardClaim {
119
+ readonly task: BoardMessage;
120
+ }
121
+ export interface BoardHeldTask {
122
+ renew(lease?: number): Promise<string>;
123
+ release(): Promise<void>;
124
+ complete(result?: string): Promise<void>;
125
+ fail(reason: string): Promise<void>;
126
+ block(reason: string, options?: {
127
+ readonly kind?: string;
128
+ }): Promise<void>;
129
+ }
130
+ export interface BoardReadyTaskQuery {
131
+ readonly channel: string;
132
+ readonly label?: Readonly<Record<string, string>>;
133
+ readonly from?: readonly string[];
134
+ readonly lease?: number;
135
+ }
136
+ export interface BoardNewTask {
137
+ readonly text: string;
138
+ readonly labels?: Readonly<Record<string, string>>;
139
+ readonly needs?: readonly string[];
140
+ readonly noSync?: boolean;
141
+ readonly id?: string;
142
+ }
143
+ export interface BoardEvent {
144
+ readonly cursor: string;
145
+ readonly type: string;
146
+ readonly createdAt: string;
147
+ readonly message?: BoardMessage;
148
+ }
149
+ export interface BoardMatch {
150
+ readonly id: string;
151
+ readonly watcher: string;
152
+ readonly lease: string;
153
+ readonly attempt: number;
154
+ readonly event: BoardEvent;
155
+ }
156
+ export interface BoardSyncEntry {
157
+ readonly key: string;
158
+ readonly platform: string;
159
+ }
160
+ export interface BoardRegistrationInput {
161
+ readonly url?: string | null;
162
+ readonly path?: string | null;
163
+ readonly branch?: string | null;
164
+ readonly watch: Readonly<Record<string, {
165
+ readonly tail: string;
166
+ }>>;
167
+ readonly sync?: readonly BoardSyncEntry[];
168
+ }
169
+ export interface BoardRegistration extends BoardRegistrationInput {
170
+ readonly owner: string;
171
+ readonly hash: string;
172
+ }
173
+ export interface BoardDiscovery {
174
+ readonly url: string;
175
+ readonly wake_by_path?: boolean;
176
+ }
177
+ export type BoardCan = "all" | readonly BoardPermission[] | Readonly<Record<string, "all" | readonly BoardPermission[]>>;
178
+ export declare const BOARD_PERMISSIONS: readonly ["read", "post", "react", "label", "sync", "manage"];
179
+ export type BoardPermission = (typeof BOARD_PERMISSIONS)[number];
180
+ export interface BoardClient {
181
+ readonly profile: string;
182
+ discovery(): Promise<BoardDiscovery>;
183
+ me(): Promise<{
184
+ readonly principal: string;
185
+ readonly actor: string;
186
+ }>;
187
+ watchers(): Promise<readonly BoardRegistration[]>;
188
+ register(input: BoardRegistrationInput): Promise<BoardRegistration>;
189
+ matches(options?: {
190
+ readonly limit?: number;
191
+ readonly wait?: number;
192
+ }): Promise<readonly BoardMatch[]>;
193
+ ack(match: BoardMatch, outcome?: {
194
+ readonly error?: string;
195
+ readonly skip?: boolean;
196
+ }): Promise<void>;
197
+ post(channel: string, options: BoardPostOptions): Promise<BoardWrittenMessage>;
198
+ reply(id: string, options: BoardPostOptions): Promise<BoardWrittenMessage>;
199
+ upload(file: {
200
+ readonly data: Uint8Array;
201
+ readonly name: string;
202
+ readonly type?: string;
203
+ }): Promise<BoardAttachment>;
204
+ react(id: string, emoji: string, options?: {
205
+ readonly remove?: boolean;
206
+ }): Promise<void>;
207
+ label(id: string, change: {
208
+ readonly set?: Record<string, string>;
209
+ readonly unset?: readonly string[];
210
+ readonly if?: Readonly<Record<string, string | null>>;
211
+ }): Promise<void>;
212
+ typing(id: string, status?: string): Promise<void>;
213
+ thread(id: string, range?: {
214
+ readonly after?: string;
215
+ }): Promise<BoardThread>;
216
+ linked(url: string): Promise<BoardThread>;
217
+ threads(query?: BoardThreadsQuery): Promise<readonly BoardThreadSummary[]>;
218
+ threadsPage(query?: BoardThreadsQuery): Promise<BoardThreadsPage>;
219
+ schedules(query?: {
220
+ readonly re?: string;
221
+ readonly channel?: string;
222
+ readonly by?: string;
223
+ }): Promise<readonly BoardSchedule[]>;
224
+ actors(): Promise<readonly BoardActorSummary[]>;
225
+ channels(): Promise<readonly BoardChannelSummary[]>;
226
+ download(attachmentId: string): Promise<Response>;
227
+ schedule(target: {
228
+ readonly re: string;
229
+ } | {
230
+ readonly channel: string;
231
+ }, options: BoardScheduleOptions): Promise<BoardSchedule>;
232
+ cancelSchedule(id: string): Promise<{
233
+ readonly canceled: boolean;
234
+ }>;
235
+ claimReady(query: BoardReadyTaskQuery): Promise<BoardClaimedTask | null>;
236
+ claim(taskId: string, lease?: number): Promise<BoardClaimedTask>;
237
+ held(claim: BoardClaim): BoardHeldTask;
238
+ createTask(channel: string, task: BoardNewTask): Promise<BoardMessage>;
239
+ }
240
+ /** Which board the agent reads and writes, and as whom. */
241
+ export type BoardSettings = Readonly<typeof extension.config>;
242
+ export declare const BOARD_TEXT_LIMIT = 10000;
243
+ export declare const BOARD_TAIL_LIMIT = 1000;
244
+ export declare const BOARD_UPLOAD_LIMIT: number;
245
+ export declare const BOARD_NAME_PATTERN: RegExp;
246
+ export declare const BOARD_CHANNEL_SELECTOR: RegExp;
247
+ export declare const BOARD_TASK_NOTE_LIMIT = 1000;
248
+ export declare const BOARD_HOLD_KIND_PATTERN: RegExp;
249
+ export declare const DEFAULT_BOARD_PROFILE = "eve";
250
+ export declare function boardPostId(key: string): string;
251
+ export declare function boardAllows(can: BoardCan | undefined, channel: string, permission: string): boolean;
252
+ export declare function boardErrorCode(error: unknown): string | undefined;
253
+ type BoardRef = Pick<BoardSettings, "name" | "team" | "url" | "profile">;
254
+ export declare function createBoardClient(board: BoardRef, can?: BoardCan): BoardClient;
255
+ export declare function withHints<T extends object>(target: T): T;
256
+ export {};