@eve/board 0.3.0 → 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.
- package/dist/extension/_manifest.json +1 -1
- package/dist/extension/extension.d.ts +8 -5
- package/dist/extension/extension.mjs +48 -37
- package/dist/extension/instructions.md +1 -1
- package/dist/extension/lib/authorize.d.ts +2 -2
- package/dist/extension/lib/board-channel.d.ts +5 -4
- package/dist/extension/lib/board-channel.mjs +46 -34
- package/dist/extension/lib/boards.d.ts +29 -4
- package/dist/extension/lib/boards.mjs +310 -45
- package/dist/extension/lib/claims.d.ts +1 -1
- package/dist/extension/lib/claims.mjs +18 -10
- package/dist/extension/lib/client.d.ts +21 -1
- package/dist/extension/lib/client.mjs +60 -11
- package/dist/extension/lib/inbound.d.ts +1 -1
- package/dist/extension/lib/inbound.mjs +1 -1
- package/dist/extension/lib/tools.d.ts +5 -0
- package/dist/extension/lib/tools.mjs +58 -44
- package/dist/extension/lib/watches.d.ts +3 -1
- package/dist/extension/skills/collaborate/SKILL.md +3 -3
- package/dist/extension/tools/boards.d.ts +6 -0
- package/dist/extension/tools/boards.mjs +10 -0
- package/dist/extension/tools/watches.d.ts +1 -1
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/index.mjs +2 -1
- package/package.json +3 -3
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import type { BoardAuthorize } from "./lib/authorize.ts";
|
|
3
3
|
/**
|
|
4
|
-
* Makes the agent a participant on one or more Vercel Boards.
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Makes the agent a participant on one or more Vercel Boards. By default, every accessible board on
|
|
5
|
+
* the team is discoverable and `General` is used when no board is specified; configure `boards` to
|
|
6
|
+
* override per-board settings, use `"*"` for fallback defaults, or set `"*": false` to disable
|
|
7
|
+
* discovery and allow only explicitly listed boards.
|
|
7
8
|
*/
|
|
8
9
|
declare const _default: import("eve/extension").ExtensionHandle<z.ZodObject<{
|
|
10
|
+
id: z.ZodOptional<z.ZodString>;
|
|
9
11
|
name: z.ZodOptional<z.ZodString>;
|
|
10
12
|
team: z.ZodOptional<z.ZodString>;
|
|
11
13
|
url: z.ZodOptional<z.ZodString>;
|
|
@@ -29,7 +31,8 @@ declare const _default: import("eve/extension").ExtensionHandle<z.ZodObject<{
|
|
|
29
31
|
authorize: z.ZodOptional<z.ZodCustom<BoardAuthorize, BoardAuthorize>>;
|
|
30
32
|
configurers: z.ZodOptional<z.ZodUnknown>;
|
|
31
33
|
route: z.ZodOptional<z.ZodString>;
|
|
32
|
-
boards: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
34
|
+
boards: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodBoolean, z.ZodObject<{
|
|
35
|
+
id: z.ZodOptional<z.ZodString>;
|
|
33
36
|
name: z.ZodOptional<z.ZodString>;
|
|
34
37
|
team: z.ZodOptional<z.ZodString>;
|
|
35
38
|
url: z.ZodOptional<z.ZodString>;
|
|
@@ -52,6 +55,6 @@ declare const _default: import("eve/extension").ExtensionHandle<z.ZodObject<{
|
|
|
52
55
|
watchChannel: z.ZodOptional<z.ZodString>;
|
|
53
56
|
authorize: z.ZodOptional<z.ZodCustom<BoardAuthorize, BoardAuthorize>>;
|
|
54
57
|
configurers: z.ZodOptional<z.ZodUnknown>;
|
|
55
|
-
}, z.core.$strip>>>;
|
|
58
|
+
}, z.core.$strip>]>>>;
|
|
56
59
|
}, z.core.$strip>>;
|
|
57
60
|
export default _default;
|
|
@@ -4,7 +4,7 @@ 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_CHANNEL_SELECTOR, BOARD_NAME_PATTERN, BOARD_PERMISSIONS } from "./lib/client.mjs";
|
|
7
|
+
import { BOARD_CHANNEL_SELECTOR, BOARD_ID_PATTERN, BOARD_NAME_PATTERN, BOARD_PERMISSIONS, isVercelBoardName, normalizeBoardName } from "./lib/client.mjs";
|
|
8
8
|
import { isValidBoardRouteBase } from "./lib/route.mjs";
|
|
9
9
|
import { defineExtension } from "eve/extension";
|
|
10
10
|
import { z } from "zod";
|
|
@@ -17,8 +17,11 @@ const authorize = fn();
|
|
|
17
17
|
const removedConfigurers = z.unknown().optional();
|
|
18
18
|
const CONFIGURERS_REMOVED = "`configurers` was removed; use `authorize` to decide who may manage board watches. See https://eve.dev/docs/channels/board.";
|
|
19
19
|
const boardUrl = z.string().url().refine((value) => /^https?:\/\//u.test(value), "an http:// or https:// board URL");
|
|
20
|
+
const boardId = z.string().regex(BOARD_ID_PATTERN, "a board ID starting with \"brd_\"");
|
|
21
|
+
const boardName = z.string().refine(isVercelBoardName, "1 to 64 characters without /");
|
|
20
22
|
const boardEntry = z.object({
|
|
21
|
-
|
|
23
|
+
id: boardId.optional(),
|
|
24
|
+
name: boardName.optional(),
|
|
22
25
|
team: z.string().min(1).optional(),
|
|
23
26
|
url: boardUrl.optional(),
|
|
24
27
|
profile: profile.optional(),
|
|
@@ -28,7 +31,8 @@ const boardEntry = z.object({
|
|
|
28
31
|
configurers: removedConfigurers
|
|
29
32
|
});
|
|
30
33
|
var extension_default = defineExtension({ config: z.object({
|
|
31
|
-
|
|
34
|
+
id: boardId.optional(),
|
|
35
|
+
name: boardName.optional(),
|
|
32
36
|
team: z.string().min(1).optional(),
|
|
33
37
|
url: boardUrl.optional(),
|
|
34
38
|
profile: profile.optional(),
|
|
@@ -37,52 +41,59 @@ var extension_default = defineExtension({ config: z.object({
|
|
|
37
41
|
authorize: authorize.optional(),
|
|
38
42
|
configurers: removedConfigurers,
|
|
39
43
|
route: z.string().min(1).refine(isValidBoardRouteBase, "an absolute path without parameters or query string, such as \"/eve/v1/board\"").optional(),
|
|
40
|
-
boards: z.record(z.string().
|
|
44
|
+
boards: z.record(z.string().refine((key) => key === "*" || BOARD_NAME_PATTERN.test(key), "\"*\" or a letter, then up to 31 letters, numbers, or hyphens"), z.union([z.boolean(), boardEntry])).optional()
|
|
41
45
|
}).superRefine((value, ctx) => {
|
|
42
|
-
|
|
46
|
+
const fail = (path, message) => ctx.addIssue({
|
|
43
47
|
code: "custom",
|
|
44
|
-
message
|
|
45
|
-
path
|
|
48
|
+
message,
|
|
49
|
+
path
|
|
46
50
|
});
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
path
|
|
51
|
+
const checkIdConflicts = (entry, path, prefix) => {
|
|
52
|
+
if (entry.id === void 0) return;
|
|
53
|
+
if (entry.name !== void 0) fail([...path, "id"], `${prefix}combine \`id\` and \`name\`; pass one of them.`);
|
|
54
|
+
if (entry.url !== void 0) fail([...path, "id"], `${prefix}combine \`id\` and \`url\`; pass one of them.`);
|
|
55
|
+
};
|
|
56
|
+
if (value.configurers !== void 0) fail(["configurers"], CONFIGURERS_REMOVED);
|
|
57
|
+
checkIdConflicts(value, [], "Cannot ");
|
|
58
|
+
if (value.boards === void 0) return;
|
|
59
|
+
if (value.id !== void 0 || value.name !== void 0 || value.url !== void 0) fail(["boards"], "Cannot combine `boards` with top-level `id`, `name`, or `url`; set those fields on each entry in `boards`.");
|
|
60
|
+
const seenTargets = new Map();
|
|
61
|
+
let namedCount = 0;
|
|
62
|
+
let discoveryDisabled = false;
|
|
63
|
+
for (const [key, entry] of Object.entries(value.boards)) {
|
|
64
|
+
if (typeof entry === "boolean") {
|
|
65
|
+
if (key === "*") discoveryDisabled = !entry;
|
|
66
|
+
else fail(["boards", key], `Only \`boards["*"]\` may be a boolean; configure board "${key}" with an object.`);
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
if (entry.configurers !== void 0) fail([
|
|
51
70
|
"boards",
|
|
52
71
|
key,
|
|
53
72
|
"configurers"
|
|
54
|
-
]
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
path: ["boards"]
|
|
62
|
-
});
|
|
63
|
-
if (value.name !== void 0 || value.team !== void 0 || value.url !== void 0 || value.can !== void 0) ctx.addIssue({
|
|
64
|
-
code: "custom",
|
|
65
|
-
message: "Cannot combine `boards` with top-level `name`, `team`, `url`, or `can`; set those fields on each entry in `boards`.",
|
|
66
|
-
path: ["boards"]
|
|
67
|
-
});
|
|
68
|
-
const seenTargets = new Map();
|
|
69
|
-
for (const [key, entry] of entries) {
|
|
73
|
+
], CONFIGURERS_REMOVED);
|
|
74
|
+
if (key === "*") {
|
|
75
|
+
if (entry.id !== void 0 || entry.name !== void 0 || entry.url !== void 0) fail(["boards", "*"], "`boards[\"*\"]` configures the fallback for discovered boards and cannot set `id`, `name`, or `url`.");
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
namedCount += 1;
|
|
79
|
+
checkIdConflicts(entry, ["boards", key], `Board "${key}" cannot `);
|
|
70
80
|
let target;
|
|
71
81
|
if (entry.url !== void 0) {
|
|
72
82
|
const parsed = new URL(entry.url.trim());
|
|
73
83
|
target = JSON.stringify(["url", `${parsed.origin}${parsed.pathname.replace(/\/+$/u, "")}`]);
|
|
74
|
-
} else target = JSON.stringify([
|
|
75
|
-
|
|
76
|
-
entry.
|
|
77
|
-
|
|
78
|
-
|
|
84
|
+
} else if (entry.id !== void 0) target = JSON.stringify(["vercel-id", entry.id]);
|
|
85
|
+
else {
|
|
86
|
+
const effectiveName = normalizeBoardName(entry.name ?? key).toLowerCase();
|
|
87
|
+
target = JSON.stringify([
|
|
88
|
+
"vercel",
|
|
89
|
+
entry.team ?? value.team ?? null,
|
|
90
|
+
effectiveName
|
|
91
|
+
]);
|
|
92
|
+
}
|
|
79
93
|
const previous = seenTargets.get(target);
|
|
80
|
-
if (previous !== void 0)
|
|
81
|
-
code: "custom",
|
|
82
|
-
message: `boards "${previous}" and "${key}" target the same board; give each entry a distinct \`name\`, \`team\`, or \`url\`.`,
|
|
83
|
-
path: ["boards", key]
|
|
84
|
-
});
|
|
94
|
+
if (previous !== void 0) fail(["boards", key], `boards "${previous}" and "${key}" target the same board; give each entry a distinct \`id\`, \`name\`, \`team\`, or \`url\`.`);
|
|
85
95
|
else seenTargets.set(target, key);
|
|
86
96
|
}
|
|
97
|
+
if (discoveryDisabled && namedCount === 0) fail(["boards"], "boards with `\"*\": false` must configure at least one board.");
|
|
87
98
|
}) });
|
|
88
99
|
export { extension_default as default };
|
|
@@ -4,6 +4,6 @@ Your board tools `read`, `reply`, `post`, `react`, and `no_reply` are always ava
|
|
|
4
4
|
|
|
5
5
|
- `watch`, `watches`, and `unwatch`, when someone asks you to watch the board and act on what's posted.
|
|
6
6
|
- `schedule`, `schedules`, and `cancel_schedule`, to come back to a thread later.
|
|
7
|
-
- `note` (a board-only reply), `label`, `channels`, `actors` (handles to mention), `tasks` (a queue's tasks and their state), `claim_task` (claim a ready task by ID or from a queue), and `create_task`.
|
|
7
|
+
- `note` (a board-only reply), `label`, `boards` (list boards you can access), `channels`, `actors` (handles to mention), `tasks` (a queue's tasks and their state), `claim_task` (claim a ready task by ID or from a queue), and `create_task`.
|
|
8
8
|
|
|
9
9
|
While you hold a claimed task, `complete_task`, `block_task`, and `fail_task` are available (plus `release_task` for tasks claimed with `claim_task`): settle or release the task before you stop. Load the `collaborate` skill before you work on a shared board.
|
|
@@ -7,9 +7,9 @@ export interface BoardAuthorizeRequest {
|
|
|
7
7
|
readonly action: BoardAuthorizeAction;
|
|
8
8
|
/** The session's current caller, or `null` when the session has none. */
|
|
9
9
|
readonly auth: SessionAuthContext | null;
|
|
10
|
-
/** The configured board key (or `"default"` for a
|
|
10
|
+
/** The board identifier: a configured board key, a discovered board ID (`brd_…`), or `"default"` for a pinned single-board mount. */
|
|
11
11
|
readonly board: string;
|
|
12
|
-
/** The board's configured name, when
|
|
12
|
+
/** The board's display or configured name, when known. */
|
|
13
13
|
readonly boardName?: string;
|
|
14
14
|
/** The board's configured team, when set. */
|
|
15
15
|
readonly team?: string;
|
|
@@ -7,7 +7,7 @@ import { settleClaim, settlementOf, type BoardSettlement } from "./claims.ts";
|
|
|
7
7
|
export { settleClaim, settlementOf, type BoardSettlement };
|
|
8
8
|
/** JSON-serializable state for one board thread's session. */
|
|
9
9
|
export interface BoardChannelState extends PromptQueueState {
|
|
10
|
-
/** The
|
|
10
|
+
/** The board key or discovered board ID (`brd_…`) for this session, or omitted on a pinned single-board mount. */
|
|
11
11
|
readonly board?: string | null;
|
|
12
12
|
readonly channel: string | null;
|
|
13
13
|
/** The thread's root message ID, which replies name. */
|
|
@@ -32,7 +32,8 @@ export interface BoardEventContext extends BoardChannelContext, ChannelContinuat
|
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
34
|
* Target accepted by `to(board, target)` for proactive sessions: an existing thread by any
|
|
35
|
-
* message ID in it, or a new thread in a channel. Pass `board`
|
|
35
|
+
* message ID in it, or a new thread in a channel. Pass `board` by key, name, or ID (`brd_…`) to
|
|
36
|
+
* target a board other than the default.
|
|
36
37
|
*/
|
|
37
38
|
export type BoardReceiveTarget = {
|
|
38
39
|
readonly board?: string;
|
|
@@ -51,7 +52,7 @@ export interface BoardChannelConfig {
|
|
|
51
52
|
}
|
|
52
53
|
/** What the board channel reports about a session to tools, hooks, and instrumentation. */
|
|
53
54
|
export interface BoardChannelMetadata extends Record<string, unknown> {
|
|
54
|
-
/** The
|
|
55
|
+
/** The board key or discovered board ID (`brd_…`) for this session, or `null` for a pinned single-board mount. */
|
|
55
56
|
readonly board: string | null;
|
|
56
57
|
/** The board channel the session's thread is in. */
|
|
57
58
|
readonly boardChannel: string | null;
|
|
@@ -79,7 +80,7 @@ export declare function drainMatches(options: {
|
|
|
79
80
|
readonly from: ChannelFrom<BoardChannelState>;
|
|
80
81
|
readonly wait?: number;
|
|
81
82
|
}): Promise<number>;
|
|
82
|
-
export declare function renewDuringCall(client: () => BoardClient
|
|
83
|
+
export declare function renewDuringCall(client: () => BoardClient | Promise<BoardClient>, state: BoardChannelState, callId: string): void;
|
|
83
84
|
export declare function endRenewal(state: BoardChannelState, callId?: string): void;
|
|
84
85
|
export declare function keepBoardClaim(client: BoardClient, state: BoardChannelState): Promise<void>;
|
|
85
86
|
export declare function renewBeforeTask(client: BoardClient, state: BoardChannelState): Promise<void>;
|
|
@@ -4,7 +4,7 @@ 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 {
|
|
7
|
+
import { matchesBoard, resolveBoards, resolveWakeBoard, selectBoardAsync } from "./boards.mjs";
|
|
8
8
|
import { BOARD_TEXT_LIMIT, boardAllows, boardErrorCode, boardPostId } from "./client.mjs";
|
|
9
9
|
import { boardMessageContent, boardSessionAddress, boardThreadId, defaultBoardAuth, fetchBoardAttachment, formatBoardContext, formatTaskContext, formatTaskFollowUpContext, formatWatchContext } from "./inbound.mjs";
|
|
10
10
|
import { LEGACY_BOARD_WAKE_ROUTE, normalizeBoardRouteBase } from "./route.mjs";
|
|
@@ -27,8 +27,10 @@ const CLAIM_EVENTS = new Set([
|
|
|
27
27
|
"task.unblocked"
|
|
28
28
|
]);
|
|
29
29
|
function createBoardChannel(settings, options = {}) {
|
|
30
|
-
const deploymentFor = (state) => boardClients(
|
|
31
|
-
const keepClaim = (state) =>
|
|
30
|
+
const deploymentFor = async (state) => boardClients(await selectBoardAsync(settings(), void 0, state.board)).deployment;
|
|
31
|
+
const keepClaim = async (state) => {
|
|
32
|
+
if (state.task != null) await keepBoardClaim(await deploymentFor(state), state);
|
|
33
|
+
};
|
|
32
34
|
const draining = new Map();
|
|
33
35
|
const coalesced = (key, drain) => {
|
|
34
36
|
const existing = draining.get(key);
|
|
@@ -69,31 +71,28 @@ function createBoardChannel(settings, options = {}) {
|
|
|
69
71
|
if (wake !== void 0) waitUntil(wake.catch((error) => logError("board wake-up failed", error, { board: board.key })));
|
|
70
72
|
return Response.json({ ok: true }, { status: 202 });
|
|
71
73
|
};
|
|
72
|
-
const
|
|
73
|
-
const
|
|
74
|
-
if (
|
|
75
|
-
error: "Board key is required.",
|
|
76
|
-
ok: false
|
|
77
|
-
}, { status: 404 });
|
|
78
|
-
return wakeTarget(resolved.byKey.values().next().value, from, waitUntil);
|
|
79
|
-
};
|
|
80
|
-
const handleNamedWake = async (_request, { from, params, waitUntil }) => {
|
|
81
|
-
const resolved = resolveBoards(settings());
|
|
82
|
-
if (resolved.shorthand) return Response.json({
|
|
83
|
-
error: "Unknown board.",
|
|
84
|
-
ok: false
|
|
85
|
-
}, { status: 404 });
|
|
86
|
-
const boardKey = params.board;
|
|
87
|
-
const target = boardKey === void 0 ? void 0 : lookupBoard(resolved, boardKey);
|
|
88
|
-
if (target === void 0) return Response.json({
|
|
74
|
+
const wakeHandler = (named) => async (_request, { from, params, waitUntil }) => {
|
|
75
|
+
const boardKey = named ? params?.board : void 0;
|
|
76
|
+
if (named && boardKey === void 0) return Response.json({
|
|
89
77
|
error: "Unknown board.",
|
|
90
78
|
ok: false
|
|
91
79
|
}, { status: 404 });
|
|
80
|
+
const target = await resolveWakeBoard(settings(), boardKey).catch((error) => {
|
|
81
|
+
logError("board wake-up failed", error, { board: boardKey ?? null });
|
|
82
|
+
});
|
|
83
|
+
if (target === void 0) {
|
|
84
|
+
const error = !named && resolveBoards(settings()).fallback === void 0 ? "Board key is required." : "Unknown board.";
|
|
85
|
+
return Response.json({
|
|
86
|
+
error,
|
|
87
|
+
ok: false
|
|
88
|
+
}, { status: 404 });
|
|
89
|
+
}
|
|
92
90
|
return wakeTarget(target, from, waitUntil);
|
|
93
91
|
};
|
|
92
|
+
const handleShorthandWake = wakeHandler(false);
|
|
94
93
|
const routes = [
|
|
95
94
|
POST(`${routeBase}/wake`, handleShorthandWake),
|
|
96
|
-
POST(`${routeBase}/:board/wake`,
|
|
95
|
+
POST(`${routeBase}/:board/wake`, wakeHandler(true)),
|
|
97
96
|
...routeBase === "/eve/v1/board" ? [POST(LEGACY_BOARD_WAKE_ROUTE, handleShorthandWake)] : []
|
|
98
97
|
];
|
|
99
98
|
return defineChannel({
|
|
@@ -104,9 +103,8 @@ function createBoardChannel(settings, options = {}) {
|
|
|
104
103
|
threadId: null
|
|
105
104
|
},
|
|
106
105
|
context(state) {
|
|
107
|
-
const target = resolveSessionBoard(settings(), state.board);
|
|
108
106
|
return {
|
|
109
|
-
board: threadHandle(boardClients(
|
|
107
|
+
board: threadHandle(async () => boardClients(await selectBoardAsync(settings(), void 0, state.board)).model, state),
|
|
110
108
|
state
|
|
111
109
|
};
|
|
112
110
|
},
|
|
@@ -128,7 +126,7 @@ function createBoardChannel(settings, options = {}) {
|
|
|
128
126
|
},
|
|
129
127
|
routes,
|
|
130
128
|
async receive({ message, target, ...send }, { from }) {
|
|
131
|
-
const resolved =
|
|
129
|
+
const resolved = await selectBoardAsync(settings(), target.board, void 0);
|
|
132
130
|
const board = boardClients(resolved).model;
|
|
133
131
|
let root;
|
|
134
132
|
if ("thread" in target) root = (await board.thread(target.thread)).message;
|
|
@@ -151,13 +149,26 @@ function createBoardChannel(settings, options = {}) {
|
|
|
151
149
|
}
|
|
152
150
|
});
|
|
153
151
|
},
|
|
154
|
-
fetchFile(url) {
|
|
152
|
+
fetchFile(url, context) {
|
|
155
153
|
const policy = options.uploadPolicy;
|
|
156
154
|
if (policy === "disabled") return Promise.resolve(null);
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
const
|
|
160
|
-
|
|
155
|
+
const sessionBoard = typeof context?.state.board === "string" && context.state.board.length > 0 ? context.state.board : void 0;
|
|
156
|
+
return fetchBoardAttachment(url, async (boardKey) => {
|
|
157
|
+
const current = settings();
|
|
158
|
+
const set = resolveBoards(current);
|
|
159
|
+
if (boardKey !== void 0 && set.shorthand) return void 0;
|
|
160
|
+
let target;
|
|
161
|
+
try {
|
|
162
|
+
target = await selectBoardAsync(current, boardKey, sessionBoard, { verify: true });
|
|
163
|
+
} catch {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
if (context !== void 0) {
|
|
167
|
+
if (sessionBoard !== void 0) {
|
|
168
|
+
if (!matchesBoard(target, sessionBoard)) return void 0;
|
|
169
|
+
} else if (boardKey !== void 0 && !target.shorthand) return;
|
|
170
|
+
}
|
|
171
|
+
return boardClients(target).model;
|
|
161
172
|
}, policy?.maxBytes ?? DEFAULT_MAX_UPLOAD_BYTES);
|
|
162
173
|
},
|
|
163
174
|
uploadPolicy: options.uploadPolicy,
|
|
@@ -175,11 +186,12 @@ function createBoardChannel(settings, options = {}) {
|
|
|
175
186
|
},
|
|
176
187
|
async "call.started"(event, ctx) {
|
|
177
188
|
if (event.data.taskId === void 0) renewDuringCall(() => deploymentFor(ctx.channel.state), ctx.channel.state, event.data.callId);
|
|
178
|
-
else await renewBeforeTask(deploymentFor(ctx.channel.state), ctx.channel.state);
|
|
189
|
+
else if (ctx.channel.state.task != null) await renewBeforeTask(await deploymentFor(ctx.channel.state), ctx.channel.state);
|
|
179
190
|
},
|
|
180
191
|
async "call.settled"(event, ctx) {
|
|
181
192
|
endRenewal(ctx.channel.state, event.data.callId);
|
|
182
|
-
|
|
193
|
+
if (ctx.channel.state.task == null) return;
|
|
194
|
+
await settleAfterCall(await deploymentFor(ctx.channel.state), ctx.channel, ctx.view, event.data);
|
|
183
195
|
},
|
|
184
196
|
async "turn.settled"(event, ctx) {
|
|
185
197
|
endRenewal(ctx.channel.state);
|
|
@@ -189,7 +201,7 @@ function createBoardChannel(settings, options = {}) {
|
|
|
189
201
|
});
|
|
190
202
|
}
|
|
191
203
|
async function drainMatches(options) {
|
|
192
|
-
const target = "settings" in options ?
|
|
204
|
+
const target = "settings" in options ? await selectBoardAsync(options.settings, options.board, void 0) : options.board;
|
|
193
205
|
const { deployment, model, watchChannel } = boardClients(target);
|
|
194
206
|
const self = await deployment.me();
|
|
195
207
|
const records = new Map();
|
|
@@ -378,11 +390,11 @@ async function settleAfterCall(client, channel, view, call$1) {
|
|
|
378
390
|
function threadHandle(client, state) {
|
|
379
391
|
const threadId = state.threadId ?? "";
|
|
380
392
|
return {
|
|
381
|
-
reply: (post) => client.reply(threadId, typeof post === "string" ? {
|
|
393
|
+
reply: async (post) => await (await client()).reply(threadId, typeof post === "string" ? {
|
|
382
394
|
noSync: state.noSync === true,
|
|
383
395
|
text: post
|
|
384
396
|
} : post),
|
|
385
|
-
typing: (status) => client.typing(threadId, status)
|
|
397
|
+
typing: async (status) => await (await client()).typing(threadId, status)
|
|
386
398
|
};
|
|
387
399
|
}
|
|
388
400
|
async function showPrompt(channel, request) {
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { BoardAuthorize } from "./authorize.ts";
|
|
2
|
-
import type
|
|
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
|
|
26
|
-
|
|
27
|
-
|
|
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;
|