@eve/board 0.2.1 → 0.4.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 (44) hide show
  1. package/dist/extension/_manifest.json +1 -1
  2. package/dist/extension/extension.d.ts +8 -5
  3. package/dist/extension/extension.mjs +48 -37
  4. package/dist/extension/hooks/claims.d.ts +2 -0
  5. package/dist/extension/hooks/claims.mjs +11 -0
  6. package/dist/extension/instructions.md +2 -2
  7. package/dist/extension/lib/authorize.d.ts +9 -6
  8. package/dist/extension/lib/board-channel.d.ts +7 -18
  9. package/dist/extension/lib/board-channel.mjs +59 -141
  10. package/dist/extension/lib/boards.d.ts +29 -4
  11. package/dist/extension/lib/boards.mjs +310 -45
  12. package/dist/extension/lib/claims.d.ts +38 -0
  13. package/dist/extension/lib/claims.mjs +239 -0
  14. package/dist/extension/lib/client.d.ts +41 -1
  15. package/dist/extension/lib/client.mjs +89 -12
  16. package/dist/extension/lib/inbound.d.ts +1 -1
  17. package/dist/extension/lib/inbound.mjs +1 -1
  18. package/dist/extension/lib/tools.d.ts +206 -9
  19. package/dist/extension/lib/tools.mjs +310 -52
  20. package/dist/extension/lib/watches.d.ts +3 -1
  21. package/dist/extension/lib/watches.mjs +1 -1
  22. package/dist/extension/skills/collaborate/SKILL.md +9 -6
  23. package/dist/extension/tools/block_task.d.ts +1 -1
  24. package/dist/extension/tools/block_task.mjs +2 -1
  25. package/dist/extension/tools/boards.d.ts +6 -0
  26. package/dist/extension/tools/boards.mjs +10 -0
  27. package/dist/extension/tools/claim_task.d.ts +70 -0
  28. package/dist/extension/tools/claim_task.mjs +10 -0
  29. package/dist/extension/tools/complete_task.d.ts +1 -1
  30. package/dist/extension/tools/complete_task.mjs +2 -1
  31. package/dist/extension/tools/create_task.d.ts +5 -0
  32. package/dist/extension/tools/fail_task.d.ts +1 -1
  33. package/dist/extension/tools/fail_task.mjs +2 -1
  34. package/dist/extension/tools/note.d.ts +5 -0
  35. package/dist/extension/tools/post.d.ts +10 -0
  36. package/dist/extension/tools/read.d.ts +40 -0
  37. package/dist/extension/tools/release_task.d.ts +3 -0
  38. package/dist/extension/tools/release_task.mjs +11 -0
  39. package/dist/extension/tools/reply.d.ts +10 -0
  40. package/dist/extension/tools/tasks.d.ts +40 -0
  41. package/dist/extension/tools/tasks.mjs +10 -0
  42. package/dist/tools/index.d.ts +4 -0
  43. package/dist/tools/index.mjs +5 -1
  44. package/package.json +4 -4
@@ -1,11 +1,13 @@
1
1
  import type { BoardAuthorize } from "./authorize.ts";
2
- import type { BoardCan, BoardSettings } from "./client.ts";
2
+ import { type BoardCan, type BoardSettings } from "./client.ts";
3
3
  export declare const DEFAULT_BOARD_KEY = "default";
4
4
  export declare const DEFAULT_WATCH_CHANNEL = "eve-config/watches";
5
5
  export interface ResolvedBoardConfig {
6
6
  readonly key: string;
7
7
  readonly shorthand: boolean;
8
+ readonly id?: string;
8
9
  readonly name?: string;
10
+ readonly ensure?: boolean;
9
11
  readonly team?: string;
10
12
  readonly url?: string;
11
13
  readonly profile?: string;
@@ -15,14 +17,37 @@ export interface ResolvedBoardConfig {
15
17
  readonly routeBase: string;
16
18
  readonly registrationRouteBase: string;
17
19
  }
20
+ export interface ResolvedBoardFallback {
21
+ readonly team?: string;
22
+ readonly profile?: string;
23
+ readonly can?: BoardCan;
24
+ readonly watchChannel: string;
25
+ readonly authorize?: BoardAuthorize;
26
+ }
18
27
  export interface ResolvedBoardSet {
19
28
  readonly shorthand: boolean;
20
29
  readonly routeBase: string;
21
30
  readonly byKey: ReadonlyMap<string, ResolvedBoardConfig>;
22
31
  readonly keys: readonly string[];
32
+ readonly fallback?: ResolvedBoardFallback;
33
+ }
34
+ export interface AccessibleBoardSummary {
35
+ readonly board: string;
36
+ readonly id?: string;
37
+ readonly name?: string;
38
+ readonly default?: boolean;
39
+ readonly visibility?: "team" | "private";
40
+ readonly team?: string;
23
41
  }
42
+ export declare function matchesBoard(board: ResolvedBoardConfig, ref: string): boolean;
24
43
  export declare function resolveBoards(settings: BoardSettings): ResolvedBoardSet;
25
- export declare function lookupBoard(set: ResolvedBoardSet, key: string): ResolvedBoardConfig | undefined;
26
- export declare function selectBoard(set: ResolvedBoardSet, requestedKey: string | undefined, sessionKey?: string | null): ResolvedBoardConfig;
27
- export declare function resolveSessionBoard(settings: BoardSettings, sessionKey?: string | null): ResolvedBoardConfig;
44
+ export declare function selectBoardAsync(settings: BoardSettings, requestedKey: string | undefined, sessionKey?: string | null, options?: {
45
+ readonly needsMetadata?: boolean;
46
+ readonly verify?: boolean;
47
+ }): Promise<ResolvedBoardConfig>;
48
+ export declare function resolveWakeBoard(settings: BoardSettings, boardParam?: string): Promise<ResolvedBoardConfig | undefined>;
49
+ export declare function listAccessibleBoards(settings: BoardSettings): Promise<{
50
+ readonly boards: readonly AccessibleBoardSummary[];
51
+ readonly defaultBoardId: string | null;
52
+ }>;
28
53
  export declare function formatConfiguredBoards(settings: BoardSettings): string | null;
@@ -4,100 +4,365 @@ import { createRequire as __eveCreateRequire } from "node:module";
4
4
  const __filename = __eveFileURLToPath(import.meta.url);
5
5
  __eveDirname(__filename);
6
6
  __eveCreateRequire(import.meta.url);
7
+ import { BOARD_ID_PATTERN, getCached, isVercelBoardName, listTeamBoards, normalizeBoardName, setCached } from "./client.mjs";
7
8
  import { normalizeBoardRouteBase } from "./route.mjs";
8
9
  const DEFAULT_BOARD_KEY = "default";
9
10
  const DEFAULT_WATCH_CHANNEL = "eve-config/watches";
11
+ const DISCOVERY_TTL_MS = 6e4;
12
+ const WAKE_MISS_WINDOW_MS = 6e4;
13
+ const MAX_WAKE_MISS_REFRESHES = 5;
14
+ const MAX_DIRECTORY_TEAMS = 32;
15
+ const directoryCache = new Map();
16
+ function hasBoardUrlEnv() {
17
+ return Boolean(process.env.BOARD_URL?.trim());
18
+ }
19
+ function normalizedNameKey(name) {
20
+ return normalizeBoardName(name).toLowerCase();
21
+ }
22
+ function directoryKey(team) {
23
+ return JSON.stringify([
24
+ team ?? null,
25
+ process.env.BOARD_TOKEN ?? null,
26
+ process.env.VERCEL_ORG_ID ?? null,
27
+ process.env.VERCEL_AUTH_TOKEN ?? null
28
+ ]);
29
+ }
30
+ function directoryEntry(team) {
31
+ const key = directoryKey(team);
32
+ const existing = getCached(directoryCache, key);
33
+ if (existing !== void 0) return existing;
34
+ const created = {
35
+ fetchedAt: 0,
36
+ wakeRefreshes: []
37
+ };
38
+ setCached(directoryCache, key, created, MAX_DIRECTORY_TEAMS);
39
+ return created;
40
+ }
41
+ async function getDirectory(team, options = {}) {
42
+ const entry = directoryEntry(team);
43
+ const now = Date.now();
44
+ if (options.fresh !== true && entry.listed !== void 0 && now - entry.fetchedAt < DISCOVERY_TTL_MS) return {
45
+ listed: entry.listed,
46
+ refreshed: false
47
+ };
48
+ if (entry.inFlight === void 0) {
49
+ if (options.throttle === true) {
50
+ entry.wakeRefreshes = entry.wakeRefreshes.filter((timestamp) => now - timestamp < WAKE_MISS_WINDOW_MS);
51
+ if (entry.wakeRefreshes.length >= MAX_WAKE_MISS_REFRESHES) return {
52
+ listed: entry.listed,
53
+ refreshed: false
54
+ };
55
+ entry.wakeRefreshes.push(now);
56
+ }
57
+ const request = listTeamBoards(team === void 0 ? void 0 : { team }).then((listed) => {
58
+ entry.listed = listed;
59
+ entry.fetchedAt = Date.now();
60
+ if (entry.inFlight === request) entry.inFlight = void 0;
61
+ return listed;
62
+ }, (error) => {
63
+ if (entry.inFlight === request) entry.inFlight = void 0;
64
+ throw error;
65
+ });
66
+ entry.inFlight = request;
67
+ }
68
+ return {
69
+ listed: await entry.inFlight,
70
+ refreshed: true
71
+ };
72
+ }
73
+ function defaultListedBoard(directory) {
74
+ return directory.defaultBoardId == null ? void 0 : directory.boards.find((board) => board.id === directory.defaultBoardId);
75
+ }
76
+ function findListedBoard(directory, query) {
77
+ if (BOARD_ID_PATTERN.test(query)) return directory.boards.find((board) => board.id === query);
78
+ if (!isVercelBoardName(query)) return void 0;
79
+ const normalized = normalizedNameKey(query);
80
+ const byName = directory.boards.find((board) => normalizedNameKey(board.name) === normalized);
81
+ if (byName !== void 0) return byName;
82
+ return normalized === "general" ? defaultListedBoard(directory) : void 0;
83
+ }
84
+ async function entryListedBoard(entry, fallback, directory, throttle = false) {
85
+ if (entry.url !== void 0) return void 0;
86
+ let own = directory;
87
+ if (own === void 0 || (entry.team ?? null) !== (fallback.team ?? null)) {
88
+ ({listed: own} = await getDirectory(entry.team, { throttle }));
89
+ if (own === void 0) throw Object.assign(new Error(`Couldn't verify the settings for board "${entry.key}". Try again shortly.`), { code: "board_unverified" });
90
+ }
91
+ return findListedBoard(own, entry.id ?? entry.name ?? "");
92
+ }
93
+ async function matchStaticOverride(set, fallback, listed, directory, throttle = false) {
94
+ const entries = [...set.byKey.values()];
95
+ const byId = entries.find((entry) => entry.id === listed.id);
96
+ if (byId !== void 0) return byId;
97
+ const listedName = normalizedNameKey(listed.name);
98
+ const isDefault = listed.id === directory.defaultBoardId;
99
+ for (const entry of entries) {
100
+ if (entry.id !== void 0 || entry.name === void 0) continue;
101
+ const name = normalizedNameKey(entry.name);
102
+ if (name !== listedName && !(isDefault && name === "general")) continue;
103
+ if ((await entryListedBoard(entry, fallback, directory, throttle))?.id === listed.id) return entry;
104
+ }
105
+ }
106
+ function fallbackBoardConfig(set, fallback, id, name) {
107
+ return {
108
+ ...fallback,
109
+ id,
110
+ key: id,
111
+ ...name !== void 0 && { name },
112
+ registrationRouteBase: `${set.routeBase}/${id}`,
113
+ routeBase: set.routeBase,
114
+ shorthand: false
115
+ };
116
+ }
117
+ async function dynamicBoardConfig(set, fallback, listed, directory, throttle = false) {
118
+ const override = await matchStaticOverride(set, fallback, listed, directory, throttle);
119
+ if (override !== void 0) return {
120
+ ...override,
121
+ id: listed.id,
122
+ name: listed.name
123
+ };
124
+ return fallbackBoardConfig(set, fallback, listed.id, listed.name);
125
+ }
126
+ function lookupStaticOrId(set, ref) {
127
+ const direct = set.byKey.get(ref);
128
+ if (direct !== void 0) return direct;
129
+ if (!BOARD_ID_PATTERN.test(ref)) return void 0;
130
+ return [...set.byKey.values()].find((entry) => entry.id === ref);
131
+ }
132
+ async function resolveFromDirectory(set, fallback, pick, throttle = false) {
133
+ let { listed, refreshed } = await getDirectory(fallback.team, { throttle });
134
+ let found = listed === void 0 ? void 0 : pick(listed);
135
+ if (found === void 0 && !refreshed) {
136
+ ({listed} = await getDirectory(fallback.team, {
137
+ fresh: true,
138
+ throttle
139
+ }));
140
+ found = listed === void 0 ? void 0 : pick(listed);
141
+ }
142
+ if (found === void 0 || listed === void 0) return void 0;
143
+ return await dynamicBoardConfig(set, fallback, found, listed, throttle);
144
+ }
145
+ async function enrichMetadata(fallback, board, needsMetadata) {
146
+ if (needsMetadata !== true) return board;
147
+ const match = await entryListedBoard(board, fallback).catch(() => void 0);
148
+ return match === void 0 ? board : {
149
+ ...board,
150
+ id: match.id,
151
+ name: match.name
152
+ };
153
+ }
154
+ function staticBoardSummary(entry, extra) {
155
+ return {
156
+ board: entry.key,
157
+ ...extra?.default !== void 0 && { default: extra.default },
158
+ ...entry.id !== void 0 && { id: entry.id },
159
+ ...entry.name !== void 0 && { name: entry.name },
160
+ ...entry.team !== void 0 && { team: entry.team }
161
+ };
162
+ }
163
+ function singleBoardSet(routeBase, entry) {
164
+ const resolved = {
165
+ ...entry,
166
+ key: DEFAULT_BOARD_KEY,
167
+ registrationRouteBase: routeBase,
168
+ routeBase,
169
+ shorthand: true
170
+ };
171
+ return {
172
+ byKey: new Map([[DEFAULT_BOARD_KEY, resolved]]),
173
+ keys: [DEFAULT_BOARD_KEY],
174
+ routeBase,
175
+ shorthand: true
176
+ };
177
+ }
178
+ function matchesBoard(board, ref) {
179
+ return board.key === ref || board.id === ref;
180
+ }
10
181
  function resolveBoards(settings) {
11
182
  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
- }
183
+ const pinnedByEnv = hasBoardUrlEnv();
184
+ if (settings.boards === void 0 && (settings.id !== void 0 || settings.name !== void 0 || settings.url !== void 0 || pinnedByEnv)) return singleBoardSet(routeBase, {
185
+ authorize: settings.authorize,
186
+ can: settings.can,
187
+ ...settings.id !== void 0 && { id: settings.id },
188
+ ...settings.name !== void 0 && { name: settings.name },
189
+ profile: settings.profile,
190
+ team: settings.team,
191
+ url: settings.url,
192
+ watchChannel: settings.watchChannel ?? "eve-config/watches"
193
+ });
194
+ const rawBoards = settings.boards ?? {};
195
+ const wildcard = rawBoards["*"];
196
+ const wildcardObj = typeof wildcard === "object" && wildcard !== null ? wildcard : void 0;
197
+ const discover = !pinnedByEnv && wildcard !== false;
33
198
  const byKey = new Map();
34
199
  const keys = [];
35
- for (const [key, entry] of Object.entries(settings.boards)) {
200
+ for (const [key, entry] of Object.entries(rawBoards)) {
201
+ if (key === "*" || typeof entry !== "object" || entry === null) continue;
202
+ const keyDerivedName = entry.name === void 0 && entry.id === void 0 && entry.url === void 0;
203
+ const effectiveName = keyDerivedName ? key : entry.name;
36
204
  byKey.set(key, {
37
205
  authorize: entry.authorize ?? settings.authorize,
38
- can: entry.can,
206
+ can: entry.can ?? settings.can,
207
+ ...keyDerivedName && { ensure: false },
208
+ ...entry.id !== void 0 && { id: entry.id },
39
209
  key,
40
- name: entry.name,
210
+ ...effectiveName !== void 0 && { name: effectiveName },
41
211
  profile: entry.profile ?? settings.profile,
42
212
  registrationRouteBase: `${routeBase}/${key}`,
43
213
  routeBase,
44
214
  shorthand: false,
45
- team: entry.team,
215
+ team: entry.team ?? settings.team,
46
216
  url: entry.url,
47
217
  watchChannel: entry.watchChannel ?? settings.watchChannel ?? "eve-config/watches"
48
218
  });
49
219
  keys.push(key);
50
220
  }
51
- if (keys.length === 0) throw new Error("Board extension `boards` must configure at least one board.");
221
+ if (!discover && keys.length === 0) {
222
+ if (pinnedByEnv && wildcard !== false) return singleBoardSet(routeBase, {
223
+ authorize: wildcardObj?.authorize ?? settings.authorize,
224
+ can: wildcardObj?.can ?? settings.can,
225
+ profile: wildcardObj?.profile ?? settings.profile,
226
+ team: wildcardObj?.team ?? settings.team,
227
+ watchChannel: wildcardObj?.watchChannel ?? settings.watchChannel ?? "eve-config/watches"
228
+ });
229
+ throw new Error("Board extension `boards` with `\"*\": false` must configure at least one board.");
230
+ }
231
+ const fallback = discover ? {
232
+ authorize: wildcardObj?.authorize ?? settings.authorize,
233
+ can: wildcardObj?.can ?? settings.can,
234
+ profile: wildcardObj?.profile ?? settings.profile,
235
+ team: wildcardObj?.team ?? settings.team,
236
+ watchChannel: wildcardObj?.watchChannel ?? settings.watchChannel ?? "eve-config/watches"
237
+ } : void 0;
52
238
  return {
53
239
  byKey,
240
+ ...fallback !== void 0 && { fallback },
54
241
  keys,
55
242
  routeBase,
56
243
  shorthand: false
57
244
  };
58
245
  }
59
- function lookupBoard(set, key) {
60
- return set.byKey.get(key);
61
- }
62
- function selectBoard(set, requestedKey, sessionKey) {
246
+ function selectStaticBoard(set, requestedKey, sessionKey) {
63
247
  if (requestedKey !== void 0) {
64
- const found = lookupBoard(set, requestedKey);
248
+ const found = lookupStaticOrId(set, requestedKey);
65
249
  if (found !== void 0) return found;
66
250
  throw new Error(`Unknown board "${requestedKey}". Configured boards: ${set.keys.join(", ")}.`);
67
251
  }
68
252
  if (sessionKey != null && sessionKey.length > 0) {
69
- const found = lookupBoard(set, sessionKey);
253
+ const found = lookupStaticOrId(set, sessionKey);
70
254
  if (found !== void 0) return found;
71
255
  throw new Error(`Board "${sessionKey}" from this session is no longer configured. Configured boards: ${set.keys.join(", ")}.`);
72
256
  }
73
257
  if (set.byKey.size === 1) return set.byKey.values().next().value;
74
258
  throw new Error(`Pass \`board\` to choose which board to use. Configured boards: ${set.keys.join(", ")}.`);
75
259
  }
76
- function resolveSessionBoard(settings, sessionKey) {
260
+ async function selectBoardAsync(settings, requestedKey, sessionKey, options = {}) {
77
261
  const set = resolveBoards(settings);
262
+ const fallback = set.fallback;
263
+ if (fallback === void 0) return selectStaticBoard(set, requestedKey, sessionKey);
264
+ if (requestedKey !== void 0) {
265
+ const staticHit = lookupStaticOrId(set, requestedKey);
266
+ if (staticHit !== void 0) return await enrichMetadata(fallback, staticHit, options.needsMetadata);
267
+ const resolved = BOARD_ID_PATTERN.test(requestedKey) || isVercelBoardName(requestedKey) ? await resolveFromDirectory(set, fallback, (directory) => findListedBoard(directory, requestedKey)) : void 0;
268
+ if (resolved !== void 0) return resolved;
269
+ throw new Error(`Unknown or inaccessible board "${requestedKey}". Call \`boards\` to list boards you can access.`);
270
+ }
78
271
  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(", ")}.`);
272
+ const staticHit = lookupStaticOrId(set, sessionKey);
273
+ if (staticHit !== void 0) return await enrichMetadata(fallback, staticHit, options.needsMetadata);
274
+ if (BOARD_ID_PATTERN.test(sessionKey)) {
275
+ if (options.needsMetadata !== true && options.verify !== true && ![...set.byKey.values()].some((entry) => entry.id === void 0 && entry.url === void 0)) return fallbackBoardConfig(set, fallback, sessionKey);
276
+ const resolved = await resolveFromDirectory(set, fallback, (directory) => directory.boards.find((board) => board.id === sessionKey));
277
+ if (resolved !== void 0) return resolved;
278
+ throw new Error(`Board "${sessionKey}" from this session is no longer accessible.`);
279
+ }
280
+ throw new Error(`Board "${sessionKey}" from this session is no longer configured.`);
82
281
  }
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(", ")}).`);
282
+ const defaultBoard = await resolveFromDirectory(set, fallback, defaultListedBoard);
283
+ if (defaultBoard !== void 0) return defaultBoard;
284
+ throw new Error("This deployment has no access to the team's default board. Pass `board` (call `boards` to list available boards) or grant access to the default board.");
285
+ }
286
+ async function resolveWakeBoard(settings, boardParam) {
287
+ const set = resolveBoards(settings);
288
+ const fallback = set.fallback;
289
+ if (boardParam === void 0) {
290
+ if (set.shorthand) return set.byKey.values().next().value;
291
+ if (fallback === void 0) return void 0;
292
+ return await resolveFromDirectory(set, fallback, defaultListedBoard, true);
293
+ }
294
+ if (set.shorthand) return void 0;
295
+ const staticHit = set.byKey.get(boardParam);
296
+ if (staticHit !== void 0) return staticHit;
297
+ if (fallback === void 0 || !BOARD_ID_PATTERN.test(boardParam)) return void 0;
298
+ return await resolveFromDirectory(set, fallback, (directory) => directory.boards.find((board) => board.id === boardParam), true);
299
+ }
300
+ async function listAccessibleBoards(settings) {
301
+ const set = resolveBoards(settings);
302
+ if (set.shorthand) {
303
+ const entry = set.byKey.values().next().value;
304
+ return {
305
+ boards: [staticBoardSummary(entry, { default: true })],
306
+ defaultBoardId: entry.id ?? null
307
+ };
308
+ }
309
+ const fallback = set.fallback;
310
+ if (fallback === void 0) return {
311
+ boards: [...set.byKey.values()].map((entry) => staticBoardSummary(entry)),
312
+ defaultBoardId: null
313
+ };
314
+ const { listed } = await getDirectory(fallback.team, { fresh: true });
315
+ const directory = listed;
316
+ const matchedStaticKeys = new Set();
317
+ const boards = await Promise.all(directory.boards.map(async (entry) => {
318
+ const override = await matchStaticOverride(set, fallback, entry, directory);
319
+ if (override !== void 0) matchedStaticKeys.add(override.key);
320
+ const team = override?.team ?? fallback.team;
321
+ return {
322
+ board: override?.key ?? entry.id,
323
+ default: entry.id === directory.defaultBoardId,
324
+ id: entry.id,
325
+ name: entry.name,
326
+ ...team !== void 0 && { team },
327
+ ...entry.visibility !== void 0 && { visibility: entry.visibility }
328
+ };
329
+ }));
330
+ for (const entry of set.byKey.values()) if (!matchedStaticKeys.has(entry.key)) boards.push(staticBoardSummary(entry));
331
+ return {
332
+ boards,
333
+ defaultBoardId: directory.defaultBoardId
334
+ };
85
335
  }
86
336
  function formatConfiguredBoards(settings) {
87
337
  const set = resolveBoards(settings);
88
338
  if (set.shorthand) return null;
89
- const lines = [...set.byKey.values()].map((entry) => {
90
- const label = entry.name ?? "team default board";
339
+ const staticLines = [...set.byKey.values()].map((entry) => {
340
+ const label = entry.name ?? entry.id ?? "team default board";
91
341
  const team = entry.team === void 0 ? "" : ` (team \`${entry.team}\`)`;
92
342
  return `- \`${entry.key}\`: ${label}${team}`;
93
343
  });
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.`;
344
+ if (set.fallback === void 0) {
345
+ 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.`;
346
+ return [
347
+ "## Configured boards",
348
+ "",
349
+ ...staticLines,
350
+ "",
351
+ `In a session a board started, replies stay on that board and board tools default to that board. ${requirement}`
352
+ ].join("\n");
353
+ }
95
354
  return [
96
- "## Configured boards",
355
+ "## Boards",
97
356
  "",
98
- ...lines,
357
+ `You can use any accessible board on ${set.fallback.team === void 0 ? "your team" : `team \`${set.fallback.team}\``}. Call \`boards\` to discover available boards.`,
358
+ ...staticLines.length > 0 ? [
359
+ "",
360
+ "Configured boards:",
361
+ "",
362
+ ...staticLines
363
+ ] : [],
99
364
  "",
100
- `In a session a board started, replies stay on that board and board tools default to that board. ${requirement}`
365
+ "In a session a board started, replies stay on that board and board tools default to that board. Outside a board session, omitting `board` uses the team's default board (`General`); pass `board` with a board's name, ID (`brd_…`), or configured key to target another board."
101
366
  ].join("\n");
102
367
  }
103
- export { DEFAULT_BOARD_KEY, DEFAULT_WATCH_CHANNEL, formatConfiguredBoards, lookupBoard, resolveBoards, resolveSessionBoard, selectBoard };
368
+ export { DEFAULT_BOARD_KEY, DEFAULT_WATCH_CHANNEL, formatConfiguredBoards, listAccessibleBoards, matchesBoard, resolveBoards, resolveWakeBoard, selectBoardAsync };
@@ -0,0 +1,38 @@
1
+ import type { HookDefinition } from "eve/hooks";
2
+ import { type BoardClaim, type BoardClient, type BoardSettings } from "./client.ts";
3
+ export declare const CLAIM_LEASE_SECONDS = 3600;
4
+ export declare const CLAIM_WATCH_LABEL = "eve-claim-watch";
5
+ export interface SessionBoardClaim {
6
+ readonly board: string;
7
+ readonly channel: string;
8
+ readonly claim: BoardClaim;
9
+ }
10
+ export declare function readSessionClaim(): SessionBoardClaim | null;
11
+ export declare function writeSessionClaim(claim: SessionBoardClaim): void;
12
+ export declare function clearSessionClaim(): void;
13
+ export interface ClaimSlot {
14
+ get(): BoardClaim | null;
15
+ set(claim: BoardClaim | null): void;
16
+ }
17
+ export interface BoardSettlement {
18
+ readonly settled: "completed" | "failed" | "blocked" | "released";
19
+ readonly task: string;
20
+ readonly result?: string;
21
+ readonly reason?: string;
22
+ readonly kind?: string;
23
+ }
24
+ export declare function settlementOf(output: unknown, taskId: string, capability: {
25
+ readonly kind: string;
26
+ readonly name: string;
27
+ }): BoardSettlement | undefined;
28
+ export declare function renewClaimDuringCall(client: () => BoardClient | Promise<BoardClient>, claim: BoardClaim | null, callId: string): void;
29
+ export declare function stopClaimRenewal(token: string): void;
30
+ export declare function endClaimRenewal(slot: ClaimSlot, callId?: string): void;
31
+ export declare function keepClaimInSlot(client: BoardClient, slot: ClaimSlot): Promise<void>;
32
+ export declare function renewClaimBeforeTask(client: BoardClient, slot: ClaimSlot): Promise<void>;
33
+ export declare function settleClaim(client: BoardClient, claim: BoardClaim, settlement: BoardSettlement): Promise<{
34
+ readonly claimLost?: boolean;
35
+ readonly errorId?: string;
36
+ readonly problem?: string;
37
+ }>;
38
+ export declare function createBoardClaimsHook(settings: () => BoardSettings): HookDefinition;