@howaboua/pi-agent-board 0.0.3 → 0.0.5
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/CHANGELOG.md +12 -3
- package/INTEGRATION.md +7 -7
- package/README.md +12 -8
- package/dist/viewer/server.js +5 -0
- package/dist/viewer/web/app.js +29 -456
- package/dist/viewer/web/navigation.js +72 -0
- package/dist/viewer/web/posts.js +106 -0
- package/dist/viewer/web/render.js +147 -0
- package/dist/viewer/web/session.js +86 -0
- package/dist/viewer/web/updates.js +106 -0
- package/index.ts +3 -80
- package/package.json +6 -8
- package/src/archive.ts +17 -7
- package/src/awareness.ts +2 -1
- package/src/briefing.ts +6 -8
- package/src/context-briefing.ts +49 -31
- package/src/contract.ts +25 -17
- package/src/identity.ts +81 -17
- package/src/integration.ts +1 -0
- package/src/protocol.ts +2 -2
- package/src/queries.ts +1 -2
- package/src/runtime/catchup.ts +96 -0
- package/src/runtime/coordinator.ts +278 -0
- package/src/runtime/index.ts +113 -0
- package/src/runtime/owner.ts +164 -0
- package/src/runtime/routing.ts +152 -0
- package/src/{turns.ts → runtime/turns.ts} +3 -3
- package/src/search.ts +6 -4
- package/src/settings/panel.ts +87 -0
- package/src/store.ts +40 -5
- package/src/tool.ts +1 -1
- package/src/viewer/server.ts +5 -0
- package/src/viewer/web/app.js +29 -456
- package/src/viewer/web/navigation.js +72 -0
- package/src/viewer/web/posts.js +106 -0
- package/src/viewer/web/render.js +147 -0
- package/src/viewer/web/session.js +86 -0
- package/src/viewer/web/updates.js +106 -0
- package/changelog.ts +0 -337
- package/src/runtime.ts +0 -610
|
@@ -3,9 +3,9 @@ import type {
|
|
|
3
3
|
ExtensionAPI,
|
|
4
4
|
ExtensionContext,
|
|
5
5
|
} from "@earendil-works/pi-coding-agent";
|
|
6
|
-
import { sendPolicyMessage } from "
|
|
7
|
-
import { type BoardBinding, binding } from "
|
|
8
|
-
import type { BoardEnvelope } from "
|
|
6
|
+
import { sendPolicyMessage } from "../delivery.js";
|
|
7
|
+
import { type BoardBinding, binding } from "../identity.js";
|
|
8
|
+
import type { BoardEnvelope } from "../protocol.js";
|
|
9
9
|
|
|
10
10
|
type ActiveEnvelope = Extract<BoardEnvelope, { operation: "board-active" }>;
|
|
11
11
|
type NoticeEnvelope = Extract<BoardEnvelope, { operation: "board-notify" }>;
|
package/src/search.ts
CHANGED
|
@@ -19,10 +19,12 @@ export function searchBoard(
|
|
|
19
19
|
args.push(params.channel_name);
|
|
20
20
|
}
|
|
21
21
|
if (params.author !== undefined) {
|
|
22
|
-
clauses.push(`(author
|
|
23
|
-
SELECT 1 FROM posts a WHERE a.board_id=c.board_id AND a.root=c.thread_id AND a.author
|
|
24
|
-
const
|
|
25
|
-
|
|
22
|
+
clauses.push(`(author IN (SELECT value FROM json_each(?)) OR (kind='summary' AND EXISTS (
|
|
23
|
+
SELECT 1 FROM posts a WHERE a.board_id=c.board_id AND a.root=c.thread_id AND a.author IN (SELECT value FROM json_each(?)))))`);
|
|
24
|
+
const authors = JSON.stringify(
|
|
25
|
+
store.agentIdentities(agentPath(params.author, "/root")),
|
|
26
|
+
);
|
|
27
|
+
args.push(authors, authors);
|
|
26
28
|
}
|
|
27
29
|
if (params.query !== undefined) {
|
|
28
30
|
clauses.push("instr(body_search,?)>0");
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ExtensionAPI,
|
|
3
|
+
ExtensionContext,
|
|
4
|
+
} from "@earendil-works/pi-coding-agent";
|
|
5
|
+
import {
|
|
6
|
+
readBoardSummaryConfig,
|
|
7
|
+
resolveBoardSummaryModel,
|
|
8
|
+
writeBoardSummarySelection,
|
|
9
|
+
} from "../config.js";
|
|
10
|
+
import { requestBoardConsolidation } from "../consolidation.js";
|
|
11
|
+
import { binding } from "../identity.js";
|
|
12
|
+
import type { BoardRuntime } from "../runtime/coordinator.js";
|
|
13
|
+
|
|
14
|
+
export async function openBoardSettings(
|
|
15
|
+
pi: ExtensionAPI,
|
|
16
|
+
ctx: ExtensionContext,
|
|
17
|
+
board: BoardRuntime,
|
|
18
|
+
) {
|
|
19
|
+
if (!ctx.hasUI) {
|
|
20
|
+
ctx.ui.notify("Use /board settings in an interactive session", "warning");
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
try {
|
|
24
|
+
if (binding(ctx).upstream)
|
|
25
|
+
throw new Error("Change Board settings in the owning root session");
|
|
26
|
+
const sessionId = ctx.sessionManager.getSessionId();
|
|
27
|
+
const consolidate =
|
|
28
|
+
"Consolidate one-off threads (sends a prompt to this session's agent)";
|
|
29
|
+
const setting = await ctx.ui.select("Board settings and actions", [
|
|
30
|
+
"Automatic summaries",
|
|
31
|
+
"Summary model",
|
|
32
|
+
consolidate,
|
|
33
|
+
]);
|
|
34
|
+
if (setting === consolidate) {
|
|
35
|
+
if (ctx.sessionManager.getSessionId() !== sessionId)
|
|
36
|
+
throw new Error("Session changed; reopen Board settings");
|
|
37
|
+
requestBoardConsolidation(pi, ctx);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (!setting) return;
|
|
41
|
+
const config = readBoardSummaryConfig(ctx.cwd);
|
|
42
|
+
if (setting === "Automatic summaries") {
|
|
43
|
+
const selected = await ctx.ui.select(
|
|
44
|
+
`Automatic summaries: ${config.automatic ? "on" : "off"}. Summarise on closure? Uses model quota.`,
|
|
45
|
+
["Off", "On"],
|
|
46
|
+
);
|
|
47
|
+
if (selected !== "Off" && selected !== "On") return;
|
|
48
|
+
board.setAutomaticSummaries(ctx, selected === "On");
|
|
49
|
+
ctx.ui.notify(
|
|
50
|
+
`Automatic board summaries: ${selected.toLowerCase()}.`,
|
|
51
|
+
"info",
|
|
52
|
+
);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (setting !== "Summary model") return;
|
|
56
|
+
const selected = await ctx.ui.select(
|
|
57
|
+
`Board summary model (global; current: ${config.selection === "luna" ? "Luna" : "Custom"})`,
|
|
58
|
+
["Luna", "Custom"],
|
|
59
|
+
);
|
|
60
|
+
if (selected !== "Luna" && selected !== "Custom") return;
|
|
61
|
+
writeBoardSummarySelection(
|
|
62
|
+
ctx.cwd,
|
|
63
|
+
selected === "Luna" ? "luna" : "custom",
|
|
64
|
+
);
|
|
65
|
+
try {
|
|
66
|
+
resolveBoardSummaryModel(ctx.cwd);
|
|
67
|
+
} catch (error) {
|
|
68
|
+
ctx.ui.notify(
|
|
69
|
+
`Custom selected. ${error instanceof Error ? error.message : String(error)}`,
|
|
70
|
+
"warning",
|
|
71
|
+
);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
ctx.ui.notify(
|
|
75
|
+
selected === "Custom"
|
|
76
|
+
? `Board summary model: Custom. Edit board.summary.custom in ${config.path}: set provider, model and reasoning.`
|
|
77
|
+
: "Board summary model: Luna (high).",
|
|
78
|
+
"info",
|
|
79
|
+
);
|
|
80
|
+
} catch (error) {
|
|
81
|
+
ctx.ui.notify(
|
|
82
|
+
error instanceof Error ? error.message : String(error),
|
|
83
|
+
"error",
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
return;
|
|
87
|
+
}
|
package/src/store.ts
CHANGED
|
@@ -20,6 +20,7 @@ export interface BoardScope {
|
|
|
20
20
|
rootSessionId: string;
|
|
21
21
|
ownerFolder: string;
|
|
22
22
|
agentName: string;
|
|
23
|
+
legacyAgentName?: string;
|
|
23
24
|
callerSessionId: string;
|
|
24
25
|
members: readonly string[];
|
|
25
26
|
}
|
|
@@ -42,7 +43,9 @@ export class BoardStore {
|
|
|
42
43
|
readonly db: DatabaseSync;
|
|
43
44
|
readonly summaries: ThreadSummaries;
|
|
44
45
|
private readonly hasThreadStatuses: boolean;
|
|
45
|
-
|
|
46
|
+
private readonly aliases: Map<string, string>;
|
|
47
|
+
constructor(path: string, write: boolean, aliases: [string, string][] = []) {
|
|
48
|
+
this.aliases = new Map(aliases);
|
|
46
49
|
const fresh = !existsSync(path);
|
|
47
50
|
if (write && fresh) mkdirSync(dirname(path), { recursive: true });
|
|
48
51
|
this.db = new DatabaseSync(path, { readOnly: !write });
|
|
@@ -75,6 +78,18 @@ export class BoardStore {
|
|
|
75
78
|
throw error;
|
|
76
79
|
}
|
|
77
80
|
}
|
|
81
|
+
canonicalAgent(value: string) {
|
|
82
|
+
return this.aliases.get(value) ?? value;
|
|
83
|
+
}
|
|
84
|
+
agentIdentities(value: string) {
|
|
85
|
+
const canonical = this.canonicalAgent(value);
|
|
86
|
+
return [
|
|
87
|
+
canonical,
|
|
88
|
+
...[...this.aliases]
|
|
89
|
+
.filter(([, native]) => native === canonical)
|
|
90
|
+
.map(([legacy]) => legacy),
|
|
91
|
+
];
|
|
92
|
+
}
|
|
78
93
|
one<T>(sql: string, ...args: SQLInputValue[]): T | undefined {
|
|
79
94
|
return this.db.prepare(sql).get(...args) as T | undefined;
|
|
80
95
|
}
|
|
@@ -186,6 +201,16 @@ export class BoardStore {
|
|
|
186
201
|
enabled: boolean,
|
|
187
202
|
implicit = false,
|
|
188
203
|
) {
|
|
204
|
+
if (
|
|
205
|
+
implicit &&
|
|
206
|
+
this.one(
|
|
207
|
+
"SELECT 1 FROM subscriptions WHERE board_id=? AND target=? AND agent IN (SELECT value FROM json_each(?))",
|
|
208
|
+
board,
|
|
209
|
+
target,
|
|
210
|
+
JSON.stringify(this.agentIdentities(agent)),
|
|
211
|
+
)
|
|
212
|
+
)
|
|
213
|
+
return;
|
|
189
214
|
this.run(
|
|
190
215
|
implicit
|
|
191
216
|
? "INSERT OR IGNORE INTO subscriptions VALUES(?,?,?,1)"
|
|
@@ -194,7 +219,9 @@ export class BoardStore {
|
|
|
194
219
|
);
|
|
195
220
|
}
|
|
196
221
|
private resolve(scope: BoardScope, value: string) {
|
|
197
|
-
const path =
|
|
222
|
+
const path = this.canonicalAgent(
|
|
223
|
+
agentPath(value, scope.legacyAgentName ?? scope.agentName),
|
|
224
|
+
);
|
|
198
225
|
if (!scope.members.includes(path))
|
|
199
226
|
throw new Error(`Agent not bound to this tree: ${path}`);
|
|
200
227
|
return path;
|
|
@@ -307,11 +334,19 @@ export class BoardStore {
|
|
|
307
334
|
).channel_name;
|
|
308
335
|
const target = root === id ? `channel:${channel}` : `thread:${root}`;
|
|
309
336
|
for (const { agent } of this.all<{ agent: string }>(
|
|
310
|
-
|
|
337
|
+
`SELECT s.agent FROM subscriptions s WHERE s.board_id=? AND s.target=? AND s.enabled=1`,
|
|
311
338
|
board,
|
|
312
339
|
target,
|
|
313
|
-
))
|
|
314
|
-
|
|
340
|
+
)) {
|
|
341
|
+
const canonical = this.canonicalAgent(agent);
|
|
342
|
+
const override = this.one<{ enabled: number }>(
|
|
343
|
+
"SELECT enabled FROM subscriptions WHERE board_id=? AND target=? AND agent=?",
|
|
344
|
+
board,
|
|
345
|
+
target,
|
|
346
|
+
canonical,
|
|
347
|
+
);
|
|
348
|
+
if (!override || override.enabled) recipients.add(canonical);
|
|
349
|
+
}
|
|
315
350
|
recipients.delete(scope.agentName);
|
|
316
351
|
const post: PostRecord = {
|
|
317
352
|
message_id: id,
|
package/src/tool.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineTool } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import { BoardParameters } from "./contract.js";
|
|
3
3
|
import { serializeBoardToolResult } from "./response.js";
|
|
4
|
-
import type { BoardRuntime } from "./runtime.js";
|
|
4
|
+
import type { BoardRuntime } from "./runtime/coordinator.js";
|
|
5
5
|
|
|
6
6
|
export function createBoardTool(board: BoardRuntime) {
|
|
7
7
|
return defineTool({
|
package/src/viewer/server.ts
CHANGED
|
@@ -15,6 +15,11 @@ export const PROTOCOL = "pi-board-viewer/1";
|
|
|
15
15
|
const assets = new Map<string, readonly [string, string]>([
|
|
16
16
|
["/", ["web/index.html", "text/html; charset=utf-8"]],
|
|
17
17
|
["/app.js", ["web/app.js", "text/javascript; charset=utf-8"]],
|
|
18
|
+
["/session.js", ["web/session.js", "text/javascript; charset=utf-8"]],
|
|
19
|
+
["/posts.js", ["web/posts.js", "text/javascript; charset=utf-8"]],
|
|
20
|
+
["/render.js", ["web/render.js", "text/javascript; charset=utf-8"]],
|
|
21
|
+
["/navigation.js", ["web/navigation.js", "text/javascript; charset=utf-8"]],
|
|
22
|
+
["/updates.js", ["web/updates.js", "text/javascript; charset=utf-8"]],
|
|
18
23
|
["/style.css", ["web/style.css", "text/css; charset=utf-8"]],
|
|
19
24
|
[
|
|
20
25
|
"/vendor/marked.js",
|