@howaboua/pi-agent-comms 0.0.1-dev.14.1.g7d1d3da173aa → 0.0.2
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 +22 -0
- package/README.md +4 -4
- package/docs/BOARD.md +2 -2
- package/docs/NOTES.md +14 -2
- package/package.json +5 -5
- package/src/board/briefing.ts +2 -2
- package/src/board/contract.ts +31 -27
- package/src/board/identity.ts +49 -29
- package/src/board/protocol.ts +98 -59
- package/src/board/settings/panel.ts +11 -8
- package/src/board/tool.ts +5 -0
- package/src/guidance.ts +14 -14
- package/src/notes/AGENTS.md +1 -1
- package/src/notes/attachment-snapshot.ts +33 -20
- package/src/notes/feature.ts +67 -1
- package/src/notes/history-search-pruning.mjs +110 -76
- package/src/notes/history-search-worker.mjs +1 -1
- package/src/notes/integrations.ts +6 -3
- package/src/notes/note-result.ts +70 -39
- package/src/notes/notes-lookup.ts +1 -1
- package/src/notes/query-input.ts +1 -0
- package/src/notes/saved-session-access.ts +12 -8
- package/src/notes/saved-session.ts +31 -15
- package/src/notes/saved-sharing-records.ts +110 -75
- package/src/notes/session-pruning-cleanup.mjs +163 -0
- package/src/notes/session-pruning-exit.mjs +312 -0
- package/src/notes/session-pruning-screen.ts +1 -1
- package/src/notes/session-pruning-sparse.mjs +133 -0
- package/src/notes/session-pruning-state.mjs +123 -0
- package/src/notes/session-pruning.ts +34 -1
- package/src/notes/settings-controls.ts +13 -17
- package/src/notes/settings-screen.ts +2 -6
- package/src/notes/shared-notes.ts +19 -11
- package/src/notes/shared-session-reader.ts +4 -2
- package/src/notes/tool-contracts.ts +71 -44
- package/src/notes/tools.ts +2 -2
- package/src/notes/tree-handoff-read.ts +47 -32
- package/src/notes/window-message.ts +6 -18
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# @howaboua/pi-agent-comms
|
|
2
|
+
|
|
3
|
+
## 0.0.2
|
|
4
|
+
|
|
5
|
+
- Notes lookup warnings now distinguish unavailable remote notes from local checkpoints.
|
|
6
|
+
- Notes guidance calls for fewer, shorter updates, using task notes and/or checkpoints with History links instead of copied investigation or harness detail.
|
|
7
|
+
- Notes guidance keeps no-action report updates to their ID and outcome when checkpointing is needed.
|
|
8
|
+
- Retired session records are removed automatically after Pi exits.
|
|
9
|
+
- Board guidance skips report posts without a new peer-relevant change.
|
|
10
|
+
- Board guidance keeps distinct topics in focused threads instead of catch-alls.
|
|
11
|
+
- Communication guidance distinguishes non-waking notes and board posts from direct messages, regardless of messaging tool.
|
|
12
|
+
- Notes and Board settings now open on matching Enabled controls.
|
|
13
|
+
|
|
14
|
+
## 0.0.1
|
|
15
|
+
|
|
16
|
+
- Requires Node.js 22.19 or newer.
|
|
17
|
+
- Initial release combining session notes, searchable history, context rollover and agent boards. Agent Comms is an alternative to the maintained standalone Notes Compaction and Agent Board packages, preserving existing data and settings. Do not load both alternatives together.
|
|
18
|
+
- Notes and Board work independently and initialise on demand. Each has an Off setting.
|
|
19
|
+
- Notes reads accept `end_line` as an alias for `stop_line`.
|
|
20
|
+
- `/notes` and `/board` open their settings tabs. The Board tab opens the discussion viewer.
|
|
21
|
+
- Added context recovery from saved checkpoints and selected past user messages, with current instructions taking precedence.
|
|
22
|
+
- Shared Notes and Board references account for recipient access, with self-contained replies when access is unavailable or unknown.
|
package/README.md
CHANGED
|
@@ -4,18 +4,18 @@ Keep checkpoints and searchable session history across fresh context windows, an
|
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
|
-
Requires Pi 1.5.0 or newer and Node.js 22.
|
|
7
|
+
Requires Pi 1.5.0 or newer and Node.js 22.19 or newer.
|
|
8
8
|
|
|
9
9
|
Agent Comms is the combined alternative to the maintained standalone [Notes Compaction](../pi-notes-compaction) and [Agent Board](../pi-agent-board) packages. All three receive shared implementation improvements. The standalone packages are not deprecated.
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
For shared agent families, update Shepherdr in controllers and workers together. The Core-based release supports Agent Comms and the standalone providers. Older Shepherdr releases require the standalone packages.
|
|
12
12
|
|
|
13
13
|
Choose Agent Comms for both features in one package, or keep the standalone packages. Do not load Agent Comms alongside either standalone extension. To switch to Agent Comms:
|
|
14
14
|
|
|
15
15
|
```sh
|
|
16
16
|
pi remove npm:@howaboua/pi-notes-compaction
|
|
17
17
|
pi remove npm:@howaboua/pi-agent-board
|
|
18
|
-
pi install npm:@howaboua/pi-agent-comms
|
|
18
|
+
pi install npm:@howaboua/pi-agent-comms
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
For a source checkout, install from the repository root:
|
|
@@ -37,7 +37,7 @@ Existing notes, history, settings, model roles, board archives, subscriptions, v
|
|
|
37
37
|
- Tab or Shift-Tab switches between Notes and Board. `/board settings` remains an alias for the Board tab.
|
|
38
38
|
- `/roles` opens Notes' model roles subview, also available through **Model roles** in Notes.
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
Both tabs open on **Enabled**. Notes offers **Off**, **On** (all models, the default) and **Whitelist**. Board offers **Off** and **On**, with **Scope** selecting session, folder or global settings. Board also retains `/board on|off [session|folder|global]` and `/board status`. Turning either feature off does not turn the other off or delete its data. Inactive features defer initialisation; retained Notes projections can still load to preserve previously retired history.
|
|
41
41
|
|
|
42
42
|
## Guides
|
|
43
43
|
|
package/docs/BOARD.md
CHANGED
|
@@ -8,7 +8,7 @@ Part of [Pi Agent Comms](../README.md).
|
|
|
8
8
|
|
|
9
9
|
## Install
|
|
10
10
|
|
|
11
|
-
Requires Pi 1.5.0 or newer and Node.js 22.
|
|
11
|
+
Requires Pi 1.5.0 or newer and Node.js 22.19 or newer. See the [installation choices and replacement steps](../README.md#install).
|
|
12
12
|
|
|
13
13
|
```sh
|
|
14
14
|
pi install npm:@howaboua/pi-agent-comms
|
|
@@ -27,7 +27,7 @@ Reload Pi after installation. Ask the agent to post a note to the board, then ru
|
|
|
27
27
|
## Board settings
|
|
28
28
|
|
|
29
29
|
- `/board` opens the Board tab. `/notes` opens the Notes tab. Tab or Shift-Tab switches between them.
|
|
30
|
-
- `/board settings` is an alias for the Board tab.
|
|
30
|
+
- `/board settings` is an alias for the Board tab. **Enabled** switches Board on or off; **Scope** selects session, folder or global settings. The tab also offers **Open viewer**, consolidation, automatic summaries and the global summary model: Luna or Custom.
|
|
31
31
|
- `/board status` shows the current board and enablement.
|
|
32
32
|
- `/board on` enables the board for this session.
|
|
33
33
|
- `/board off` disables it without deleting history.
|
package/docs/NOTES.md
CHANGED
|
@@ -6,7 +6,7 @@ Part of [Pi Agent Comms](../README.md).
|
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
9
|
-
Requires Pi 1.5.0 or newer and Node.js 22.
|
|
9
|
+
Requires Pi 1.5.0 or newer and Node.js 22.19 or newer. See the [installation choices and replacement steps](../README.md#install).
|
|
10
10
|
|
|
11
11
|
```sh
|
|
12
12
|
pi install npm:@howaboua/pi-agent-comms
|
|
@@ -44,6 +44,18 @@ Idle rollover is off by default. Choose 25m, 55m, 2h, 6h or 12h in `/notes`. Hou
|
|
|
44
44
|
|
|
45
45
|
## Management
|
|
46
46
|
|
|
47
|
+
### Session pruning
|
|
48
|
+
|
|
49
|
+
Open **Session auto-pruning** in `/notes` to set this session's retention limits. **Run now** previews and confirms irreversible removal of retired payloads. Automatic pruning runs after a new window's first completed turn. Saved SQLite notes and current context remain intact. Settings follow the session on resume. New and forked sessions start with pruning off.
|
|
50
|
+
|
|
51
|
+
Live pruning keeps every history entry ID so Pi can still navigate its in-memory tree safely. With retention enabled, Notes automatically removes retired empty records after Pi exits. A separate helper waits for the actual process to end before changing the saved tree. Reloading, forking and switching sessions do not trigger this cleanup. No command or additional confirmation is needed. No backup is kept. Memory savings apply when the pruned session next opens.
|
|
52
|
+
|
|
53
|
+
Physical cleanup currently requires Linux and an available `node` executable. Other platforms retain live payload pruning. Cleanup skips another registered local Notes process using the same saved session, known open-file holders and files that change during preparation. A simultaneous reopen is checked against the saved generation. If cleanup won that race, the new Pi process stops and asks you to reopen it rather than continue with a stale tree. Failures are reported when the session next opens. Tree branches, labels, compaction boundaries and supported Notes archive references are retained. Other content and saved notes are unchanged.
|
|
54
|
+
|
|
55
|
+
Coordination covers local processes running this Notes release under the same OS user. Keep session storage free of concurrent writers from other machines, other OS users, older Notes versions and external JSONL editors while a Notes-enabled process is closing. Unrelated sessions do not block cleanup.
|
|
56
|
+
|
|
57
|
+
Update Observatory before applying if you use its historical index. Older versions may block the rewritten file. Current versions reconcile removed records without discarding indexed statistics.
|
|
58
|
+
|
|
47
59
|
### Model roles
|
|
48
60
|
|
|
49
61
|
`/roles` opens the read-only model roles subview of Notes. You can also choose
|
|
@@ -89,7 +101,7 @@ recovery keep their existing Notes settings.
|
|
|
89
101
|
|
|
90
102
|
`/notes` opens the settings panel in interactive Pi. It shows continuity status, storage counts and remote capabilities. Changes save immediately.
|
|
91
103
|
|
|
92
|
-
- **
|
|
104
|
+
- **Enabled** selects **Off**, **On** (all models, the default) or **Whitelist**. Whitelist enables Notes only for exact model IDs in the global settings file, regardless of provider. Off disables Notes independently of Board. Switching models applies the choice immediately; other models keep their installed compaction behaviour. Inactive Notes defers initialisation, but retained context projections can still load to preserve previously retired history.
|
|
93
105
|
- **Normal compaction** uses the installed Pi or PCC compaction flow for `/compact` and `new_context`. Off keeps notes-only rollover, the default.
|
|
94
106
|
- **New window requests** controls the agent's `new_context` tool independently of the compaction method. **off** disables the tool. **pi-limits** uses Pi's eligibility check and continues in the current window when there is too little history. **unrestricted**, the default, accepts requests at any size. With normal compaction on and nothing to summarise, unrestricted requests open a new window identity without discarding the existing context. Manual `/compact` and idle rollover retain their separate policies.
|
|
95
107
|
- **Idle rollover** selects the interval or disables it.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@howaboua/pi-agent-comms",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "Session notes, context continuity and agent message boards for Pi",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
]
|
|
37
37
|
},
|
|
38
38
|
"engines": {
|
|
39
|
-
"node": ">=22.
|
|
39
|
+
"node": ">=22.19.0"
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
42
|
"build": "node scripts/build-viewer.mjs",
|
|
@@ -48,13 +48,14 @@
|
|
|
48
48
|
"pack:dry": "npm pack --dry-run"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
+
"@earendil-works/pi-schema": "1.5.2",
|
|
51
52
|
"better-sqlite3": "13.0.3",
|
|
52
53
|
"dompurify": "3.4.17",
|
|
53
54
|
"marked": "18.2.0",
|
|
54
55
|
"unicode-case-folding": "1.1.2"
|
|
55
56
|
},
|
|
56
57
|
"devDependencies": {
|
|
57
|
-
"@howaboua/pi-codex-conversion": "
|
|
58
|
+
"@howaboua/pi-codex-conversion": "5.0.0",
|
|
58
59
|
"@types/better-sqlite3": "9.6.0"
|
|
59
60
|
},
|
|
60
61
|
"peerDependencies": {
|
|
@@ -62,8 +63,7 @@
|
|
|
62
63
|
"@earendil-works/pi-agent-core": ">=1.0.4",
|
|
63
64
|
"@earendil-works/pi-ai": ">=1.1.0",
|
|
64
65
|
"@earendil-works/pi-tui": ">=1.1.0",
|
|
65
|
-
"@howaboua/pi-codex-conversion": ">=
|
|
66
|
-
"typebox": "*"
|
|
66
|
+
"@howaboua/pi-codex-conversion": ">=5.0.0"
|
|
67
67
|
},
|
|
68
68
|
"peerDependenciesMeta": {
|
|
69
69
|
"@howaboua/pi-codex-conversion": {
|
package/src/board/briefing.ts
CHANGED
|
@@ -17,8 +17,8 @@ export function boardBriefing(
|
|
|
17
17
|
state,
|
|
18
18
|
member ? "Follow your assigned scope." : "",
|
|
19
19
|
gpt
|
|
20
|
-
? "Channels=workstreams; threads=topics. Reuse
|
|
21
|
-
: "Channels group workstreams
|
|
20
|
+
? "Channels=workstreams; threads=focused topics, not catch-alls. Reuse matching threads/channels; distinct topics→separate threads, distinct coordination needs→new channels, not task/results. Read≠subscribe; threads→replies, channels→new threads."
|
|
21
|
+
: "Channels group workstreams; threads cover focused topics, not catch-alls. Reuse matching threads and channels; separate distinct topics into threads. Create channels for distinct coordination needs, not task or result announcements. Reading does not subscribe: subscribe to threads for replies, channels for new threads.",
|
|
22
22
|
]
|
|
23
23
|
.filter(Boolean)
|
|
24
24
|
.join(" ");
|
package/src/board/contract.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import {
|
|
2
|
+
arr,
|
|
3
|
+
bool,
|
|
4
|
+
compile,
|
|
5
|
+
int,
|
|
6
|
+
obj,
|
|
7
|
+
oneOf,
|
|
8
|
+
opt,
|
|
9
|
+
type Static,
|
|
10
|
+
str,
|
|
11
|
+
} from "@earendil-works/pi-schema";
|
|
7
12
|
|
|
8
13
|
const BOARD_ACTIONS = [
|
|
9
14
|
"help",
|
|
@@ -21,22 +26,23 @@ const BOARD_ACTIONS = [
|
|
|
21
26
|
] as const;
|
|
22
27
|
const THREAD_STATUSES = ["open", "completed", "abandoned"] as const;
|
|
23
28
|
export type ThreadStatus = (typeof THREAD_STATUSES)[number];
|
|
24
|
-
export const BoardParameters =
|
|
25
|
-
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
export const BoardParameters = obj(
|
|
30
|
+
{
|
|
31
|
+
action: opt({ ...oneOf(BOARD_ACTIONS), type: "string" }),
|
|
32
|
+
},
|
|
33
|
+
{ open: true },
|
|
29
34
|
);
|
|
30
|
-
const
|
|
31
|
-
const
|
|
35
|
+
const positive = opt(int({ minimum: 1, maximum: 0xffffffff }));
|
|
36
|
+
const string = opt(str());
|
|
37
|
+
const Request = obj(
|
|
32
38
|
{
|
|
33
|
-
action:
|
|
39
|
+
action: { ...oneOf(BOARD_ACTIONS), type: "string" },
|
|
34
40
|
channel_name: string,
|
|
35
41
|
new_channel_name: string,
|
|
36
42
|
thread_id: string,
|
|
37
43
|
message_id: string,
|
|
38
44
|
text: string,
|
|
39
|
-
status:
|
|
45
|
+
status: opt({ ...oneOf(THREAD_STATUSES), type: "string" }),
|
|
40
46
|
comment: string,
|
|
41
47
|
query: string,
|
|
42
48
|
author: string,
|
|
@@ -44,21 +50,17 @@ const Request = Type.Object(
|
|
|
44
50
|
after_message_id: string,
|
|
45
51
|
board_id: string,
|
|
46
52
|
cursor: string,
|
|
47
|
-
full:
|
|
48
|
-
subscribe:
|
|
49
|
-
recent_first:
|
|
50
|
-
sort:
|
|
53
|
+
full: opt(bool()),
|
|
54
|
+
subscribe: opt(bool()),
|
|
55
|
+
recent_first: opt(bool()),
|
|
56
|
+
sort: opt({ ...oneOf(["created", "activity"]), type: "string" }),
|
|
51
57
|
limit: positive,
|
|
52
58
|
max_chars_per_post: positive,
|
|
53
59
|
limit_chars: positive,
|
|
54
|
-
offset_chars:
|
|
55
|
-
|
|
56
|
-
),
|
|
57
|
-
agents_to_notify: Type.Optional(
|
|
58
|
-
Type.Array(Type.String(), { maxItems: 256 }),
|
|
59
|
-
),
|
|
60
|
+
offset_chars: opt(int({ minimum: 0, maximum: 0xffffffff })),
|
|
61
|
+
agents_to_notify: opt(arr(str(), { maxItems: 256 })),
|
|
60
62
|
},
|
|
61
|
-
{
|
|
63
|
+
{ open: false },
|
|
62
64
|
);
|
|
63
65
|
export type BoardParams = Static<typeof Request>;
|
|
64
66
|
export type BoardAction = BoardParams["action"];
|
|
@@ -115,6 +117,8 @@ const requiredFields: Partial<Record<BoardAction, string[]>> = {
|
|
|
115
117
|
read_thread: ["thread_id"],
|
|
116
118
|
read_post: ["message_id"],
|
|
117
119
|
};
|
|
120
|
+
const requestValidator = compile(Request);
|
|
121
|
+
|
|
118
122
|
export function parseBoardRequest(value: unknown): BoardParams {
|
|
119
123
|
if (
|
|
120
124
|
value === undefined ||
|
|
@@ -124,7 +128,7 @@ export function parseBoardRequest(value: unknown): BoardParams {
|
|
|
124
128
|
Object.keys(value).length === 0)
|
|
125
129
|
)
|
|
126
130
|
return { action: "help" };
|
|
127
|
-
if (!
|
|
131
|
+
if (!requestValidator.check(value))
|
|
128
132
|
throw new Error("Invalid board request; call board help");
|
|
129
133
|
const request = { ...(value as BoardParams) };
|
|
130
134
|
const allowed = new Set(["action", ...fields[request.action]]);
|
package/src/board/identity.ts
CHANGED
|
@@ -3,58 +3,75 @@ import type {
|
|
|
3
3
|
ExtensionAPI,
|
|
4
4
|
ExtensionContext,
|
|
5
5
|
} from "@earendil-works/pi-coding-agent";
|
|
6
|
-
import {
|
|
7
|
-
|
|
6
|
+
import {
|
|
7
|
+
bool,
|
|
8
|
+
compile,
|
|
9
|
+
lit,
|
|
10
|
+
nul,
|
|
11
|
+
obj,
|
|
12
|
+
opt,
|
|
13
|
+
type Static,
|
|
14
|
+
str,
|
|
15
|
+
union,
|
|
16
|
+
} from "@earendil-works/pi-schema";
|
|
8
17
|
import { readBoardConfig } from "./config.js";
|
|
9
18
|
|
|
10
|
-
const nativeId =
|
|
11
|
-
export const BindingSchema =
|
|
19
|
+
const nativeId = str({ pattern: "^[a-zA-Z0-9_.-]+$" });
|
|
20
|
+
export const BindingSchema = obj(
|
|
12
21
|
{
|
|
13
|
-
protocol:
|
|
22
|
+
protocol: lit(1),
|
|
14
23
|
boardId: nativeId,
|
|
15
24
|
rootSessionId: nativeId,
|
|
16
25
|
sessionId: nativeId,
|
|
17
|
-
agentName:
|
|
26
|
+
agentName: str({
|
|
18
27
|
pattern: "^/[a-zA-Z0-9_.-]+(?:/[a-zA-Z0-9_-]+)*$",
|
|
19
28
|
}),
|
|
20
|
-
legacyAgentName:
|
|
21
|
-
|
|
22
|
-
),
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
enabled: Type.Boolean(),
|
|
27
|
-
upstream: Type.Optional(Type.String({ minLength: 1 })),
|
|
29
|
+
legacyAgentName: opt(str({ pattern: "^/root(?:/[a-zA-Z0-9_-]+)*$" })),
|
|
30
|
+
parentSessionId: opt(nativeId),
|
|
31
|
+
ownerFolder: str({ minLength: 1 }),
|
|
32
|
+
databasePath: str({ minLength: 1 }),
|
|
33
|
+
enabled: bool(),
|
|
34
|
+
upstream: opt(str({ minLength: 1 })),
|
|
28
35
|
},
|
|
29
|
-
{
|
|
36
|
+
{ open: false },
|
|
30
37
|
);
|
|
31
38
|
export type BoardBinding = Static<typeof BindingSchema>;
|
|
32
|
-
const ChildSchema =
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
})
|
|
39
|
+
const ChildSchema = obj(
|
|
40
|
+
{
|
|
41
|
+
parentSessionId: nativeId,
|
|
42
|
+
binding: BindingSchema,
|
|
43
|
+
machine: str(),
|
|
44
|
+
sessionFile: str({ minLength: 1 }),
|
|
45
|
+
},
|
|
46
|
+
{ open: true },
|
|
47
|
+
);
|
|
38
48
|
type BoardChild = Static<typeof ChildSchema>;
|
|
39
49
|
const BINDING = "shepherdr-board-binding";
|
|
40
50
|
const MEMBER = "shepherdr-board-member";
|
|
41
51
|
const CHILD = "shepherdr-board-child";
|
|
42
52
|
const SETTING = "shepherdr-board-setting";
|
|
43
53
|
const defaults = new WeakMap<ExtensionContext["sessionManager"], boolean>();
|
|
54
|
+
const bindingSchemaValidator = compile(BindingSchema);
|
|
55
|
+
const childSchemaValidator = compile(ChildSchema);
|
|
56
|
+
|
|
44
57
|
export function setBoardDefault(ctx: ExtensionContext, enabled: boolean) {
|
|
45
58
|
defaults.set(ctx.sessionManager, enabled);
|
|
46
59
|
}
|
|
47
60
|
const REMOVED = "shepherdr-board-removed";
|
|
48
|
-
const SettingSchema =
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
61
|
+
const SettingSchema = obj(
|
|
62
|
+
{
|
|
63
|
+
sessionId: nativeId,
|
|
64
|
+
enabled: union([bool(), nul()]),
|
|
65
|
+
},
|
|
66
|
+
{ open: true },
|
|
67
|
+
);
|
|
68
|
+
const settingSchemaValidator = compile(SettingSchema);
|
|
52
69
|
|
|
53
70
|
function sessionBoardSetting(ctx: ExtensionContext): boolean | undefined {
|
|
54
71
|
let enabled: boolean | undefined;
|
|
55
72
|
for (const entry of ctx.sessionManager.getEntries()) {
|
|
56
73
|
if (entry.type !== "custom" || entry.customType !== SETTING) continue;
|
|
57
|
-
if (!
|
|
74
|
+
if (!settingSchemaValidator.check(entry.data))
|
|
58
75
|
throw new Error("Invalid saved board setting");
|
|
59
76
|
const value = entry.data as Static<typeof SettingSchema>;
|
|
60
77
|
if (value.sessionId === ctx.sessionManager.getSessionId())
|
|
@@ -100,7 +117,7 @@ export function rootBoardSetting(ctx: ExtensionContext) {
|
|
|
100
117
|
}
|
|
101
118
|
|
|
102
119
|
export function parseBinding(value: unknown): BoardBinding {
|
|
103
|
-
if (!
|
|
120
|
+
if (!bindingSchemaValidator.check(value))
|
|
104
121
|
throw new Error("Invalid Shepherdr board binding");
|
|
105
122
|
const saved = value as BoardBinding;
|
|
106
123
|
assertSessionIdentity(saved.sessionId, saved.rootSessionId);
|
|
@@ -189,7 +206,7 @@ export function children(ctx: ExtensionContext): BoardChild[] {
|
|
|
189
206
|
continue;
|
|
190
207
|
}
|
|
191
208
|
if (entry.type !== "custom" || entry.customType !== CHILD) continue;
|
|
192
|
-
if (!
|
|
209
|
+
if (!childSchemaValidator.check(entry.data))
|
|
193
210
|
throw new Error("Invalid saved board child route");
|
|
194
211
|
const value = entry.data as BoardChild;
|
|
195
212
|
if (
|
|
@@ -224,7 +241,10 @@ export function boardAliases(
|
|
|
224
241
|
let member: BoardBinding;
|
|
225
242
|
if ([BINDING, MEMBER, REMOVED].includes(entry.customType))
|
|
226
243
|
member = parseBinding(entry.data);
|
|
227
|
-
else if (
|
|
244
|
+
else if (
|
|
245
|
+
entry.customType === CHILD &&
|
|
246
|
+
childSchemaValidator.check(entry.data)
|
|
247
|
+
)
|
|
228
248
|
member = parseBinding((entry.data as BoardChild).binding);
|
|
229
249
|
else continue;
|
|
230
250
|
if (member.boardId === boardId && member.legacyAgentName) {
|
package/src/board/protocol.ts
CHANGED
|
@@ -1,70 +1,109 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
arr,
|
|
3
|
+
bool,
|
|
4
|
+
compile,
|
|
5
|
+
int,
|
|
6
|
+
lit,
|
|
7
|
+
nul,
|
|
8
|
+
obj,
|
|
9
|
+
opt,
|
|
10
|
+
type Static,
|
|
11
|
+
str,
|
|
12
|
+
union,
|
|
13
|
+
unknown,
|
|
14
|
+
} from "@earendil-works/pi-schema";
|
|
3
15
|
import { BindingSchema } from "./identity.js";
|
|
4
16
|
|
|
5
|
-
const NoticeSchema =
|
|
17
|
+
const NoticeSchema = obj(
|
|
6
18
|
{
|
|
7
|
-
message_id:
|
|
8
|
-
channel_name:
|
|
9
|
-
author:
|
|
10
|
-
thread_id:
|
|
11
|
-
created_at:
|
|
12
|
-
text_preview:
|
|
13
|
-
n_chars:
|
|
14
|
-
truncated:
|
|
19
|
+
message_id: str(),
|
|
20
|
+
channel_name: str(),
|
|
21
|
+
author: str(),
|
|
22
|
+
thread_id: str(),
|
|
23
|
+
created_at: str(),
|
|
24
|
+
text_preview: str({ maxLength: 300 }),
|
|
25
|
+
n_chars: int({ minimum: 0 }),
|
|
26
|
+
truncated: bool(),
|
|
15
27
|
},
|
|
16
|
-
{
|
|
28
|
+
{ open: false },
|
|
17
29
|
);
|
|
18
|
-
const Protocol =
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
30
|
+
const Protocol = union([
|
|
31
|
+
obj(
|
|
32
|
+
{
|
|
33
|
+
operation: lit("board-catchup"),
|
|
34
|
+
caller: BindingSchema,
|
|
35
|
+
seen: arr(str()),
|
|
36
|
+
},
|
|
37
|
+
{ open: true },
|
|
38
|
+
),
|
|
39
|
+
obj(
|
|
40
|
+
{
|
|
41
|
+
operation: lit("board-bind"),
|
|
42
|
+
binding: BindingSchema,
|
|
43
|
+
},
|
|
44
|
+
{ open: true },
|
|
45
|
+
),
|
|
46
|
+
obj(
|
|
47
|
+
{
|
|
48
|
+
operation: lit("board-register"),
|
|
49
|
+
caller: BindingSchema,
|
|
50
|
+
member: BindingSchema,
|
|
51
|
+
},
|
|
52
|
+
{ open: true },
|
|
53
|
+
),
|
|
54
|
+
obj(
|
|
55
|
+
{
|
|
56
|
+
operation: lit("board-unregister"),
|
|
57
|
+
caller: BindingSchema,
|
|
58
|
+
member: BindingSchema,
|
|
59
|
+
},
|
|
60
|
+
{ open: true },
|
|
61
|
+
),
|
|
62
|
+
obj(
|
|
63
|
+
{
|
|
64
|
+
operation: lit("board-enabled"),
|
|
65
|
+
boardId: str(),
|
|
66
|
+
enabled: bool(),
|
|
67
|
+
},
|
|
68
|
+
{ open: true },
|
|
69
|
+
),
|
|
70
|
+
obj(
|
|
71
|
+
{
|
|
72
|
+
operation: lit("board-active"),
|
|
73
|
+
caller: BindingSchema,
|
|
74
|
+
turnId: union([str(), nul()]),
|
|
75
|
+
previousTurnId: opt(str()),
|
|
76
|
+
},
|
|
77
|
+
{ open: true },
|
|
78
|
+
),
|
|
79
|
+
obj(
|
|
80
|
+
{
|
|
81
|
+
operation: lit("board-call"),
|
|
82
|
+
caller: BindingSchema,
|
|
83
|
+
params: unknown(),
|
|
84
|
+
requestId: str(),
|
|
85
|
+
},
|
|
86
|
+
{ open: true },
|
|
87
|
+
),
|
|
88
|
+
obj(
|
|
89
|
+
{
|
|
90
|
+
operation: lit("board-notify"),
|
|
91
|
+
boardId: str(),
|
|
92
|
+
target: str(),
|
|
93
|
+
route: opt(arr(str())),
|
|
94
|
+
sessionId: str(),
|
|
95
|
+
turnId: str(),
|
|
96
|
+
notice: NoticeSchema,
|
|
97
|
+
},
|
|
98
|
+
{ open: true },
|
|
99
|
+
),
|
|
64
100
|
]);
|
|
65
101
|
export type BoardEnvelope = Static<typeof Protocol>;
|
|
102
|
+
const protocolValidator = compile(Protocol);
|
|
103
|
+
|
|
66
104
|
export function parseEnvelope(value: unknown): BoardEnvelope {
|
|
67
|
-
if (!
|
|
105
|
+
if (!protocolValidator.check(value))
|
|
106
|
+
throw new Error("Invalid board host request");
|
|
68
107
|
return value as BoardEnvelope;
|
|
69
108
|
}
|
|
70
109
|
export function isBoardEnvelope(value: unknown): boolean {
|
|
@@ -33,7 +33,7 @@ export async function openBoardSettings(
|
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
35
|
let scope: BoardScope = "session";
|
|
36
|
-
let selected = "
|
|
36
|
+
let selected = "enabled";
|
|
37
37
|
const sessionId = ctx.sessionManager.getSessionId();
|
|
38
38
|
while (true) {
|
|
39
39
|
try {
|
|
@@ -41,18 +41,18 @@ export async function openBoardSettings(
|
|
|
41
41
|
const action = await ctx.ui.custom<Action>((tui, theme, _kb, done) => {
|
|
42
42
|
const list = new SettingsList(
|
|
43
43
|
[
|
|
44
|
+
{
|
|
45
|
+
id: "enabled",
|
|
46
|
+
label: "Enabled",
|
|
47
|
+
currentValue: board.enabled(ctx) ? "On" : "Off",
|
|
48
|
+
values: ["Off", "On"],
|
|
49
|
+
},
|
|
44
50
|
{
|
|
45
51
|
id: "scope",
|
|
46
52
|
label: "Scope",
|
|
47
53
|
currentValue: scope,
|
|
48
54
|
values: ["session", "folder", "global"],
|
|
49
55
|
},
|
|
50
|
-
{
|
|
51
|
-
id: "enabled",
|
|
52
|
-
label: "Board",
|
|
53
|
-
currentValue: board.enabled(ctx) ? "on" : "off",
|
|
54
|
-
values: ["off", "on"],
|
|
55
|
-
},
|
|
56
56
|
{
|
|
57
57
|
id: "automatic",
|
|
58
58
|
label: "Automatic summaries",
|
|
@@ -106,6 +106,9 @@ export async function openBoardSettings(
|
|
|
106
106
|
...wrap(
|
|
107
107
|
`${tabs ? "Tab switch tab · " : ""}↑/↓ select · Enter/Space change · Esc close`,
|
|
108
108
|
).map((line) => theme.fg("dim", line)),
|
|
109
|
+
...wrap("Settings saved immediately").map((line) =>
|
|
110
|
+
theme.fg("dim", line),
|
|
111
|
+
),
|
|
109
112
|
rule,
|
|
110
113
|
].map((line) => truncateToWidth(line, width, ""));
|
|
111
114
|
},
|
|
@@ -139,7 +142,7 @@ export async function openBoardSettings(
|
|
|
139
142
|
if (binding(ctx).upstream)
|
|
140
143
|
throw new Error("Change Board settings in the owning root session");
|
|
141
144
|
if (action.id === "enabled")
|
|
142
|
-
await board.setSetting(ctx, scope, action.value === "
|
|
145
|
+
await board.setSetting(ctx, scope, action.value === "On");
|
|
143
146
|
else if (action.id === "automatic")
|
|
144
147
|
board.setAutomaticSummaries(ctx, action.value === "on");
|
|
145
148
|
else if (action.id === "model") {
|
package/src/board/tool.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { defineTool } from "@earendil-works/pi-coding-agent";
|
|
2
|
+
import { compile } from "@earendil-works/pi-schema";
|
|
2
3
|
import { BoardParameters } from "./contract.js";
|
|
3
4
|
import { serializeBoardToolResult } from "./response.js";
|
|
4
5
|
import type { BoardRuntime } from "./runtime/coordinator.js";
|
|
5
6
|
|
|
7
|
+
const boardParametersValidator = compile(BoardParameters);
|
|
8
|
+
|
|
6
9
|
export function createBoardTool(board: BoardRuntime) {
|
|
7
10
|
return defineTool({
|
|
8
11
|
name: "board",
|
|
@@ -12,6 +15,8 @@ export function createBoardTool(board: BoardRuntime) {
|
|
|
12
15
|
executionMode: "sequential",
|
|
13
16
|
async execute(id, params, signal, _onUpdate, ctx) {
|
|
14
17
|
signal?.throwIfAborted();
|
|
18
|
+
if (!boardParametersValidator.check(params))
|
|
19
|
+
throw new Error("Invalid board request; call board help");
|
|
15
20
|
const value = await board.execute(ctx, params, id);
|
|
16
21
|
return {
|
|
17
22
|
content: [
|