@howaboua/pi-agent-comms 0.0.2 → 0.0.3
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 +9 -0
- package/dist/viewer/web/app.js +6 -6
- package/dist/viewer/web/render.js +2 -2
- package/docs/NOTES.md +6 -1
- package/package.json +75 -74
- package/src/board/activity.ts +1 -0
- package/src/board/delivery.ts +8 -6
- package/src/board/runtime/activation.ts +2 -3
- package/src/board/runtime/catchup.ts +1 -1
- package/src/board/viewer/web/app.js +6 -6
- package/src/board/viewer/web/render.js +2 -2
- package/src/notes/AGENTS.md +2 -2
- package/src/notes/activation.ts +1 -0
- package/src/notes/bridge.ts +4 -2
- package/src/notes/context-owner.ts +5 -5
- package/src/notes/fresh-notes.ts +46 -5
- package/src/notes/history-search-pruning.mjs +1 -1
- package/src/notes/history-windows.ts +1 -1
- package/src/notes/index.ts +9 -3
- package/src/notes/integrations.ts +83 -45
- package/src/notes/lifecycle.ts +11 -2
- package/src/notes/model-roles.ts +2 -2
- package/src/notes/rollover.ts +34 -5
- package/src/notes/session-pruning-cleanup.mjs +1 -0
- package/src/notes/session-pruning-transaction.ts +1 -0
- package/src/notes/settings-controls.ts +10 -0
- package/src/notes/settings.ts +13 -6
- package/src/notes/shared-notes.ts +52 -30
- package/src/notes/tool-contracts.ts +24 -5
- package/src/notes/tools.ts +51 -29
- package/src/notes/tree-checkpoint.ts +12 -13
- package/src/notes/windows.ts +10 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @howaboua/pi-agent-comms
|
|
2
2
|
|
|
3
|
+
## 0.0.3
|
|
4
|
+
|
|
5
|
+
- Added `new_context({resume: false})` to finish a reply and open fresh context without continuing automatically.
|
|
6
|
+
- Added same-cell rollover after an awaited note save in Code and Notebook.
|
|
7
|
+
- Role guidance now directs agents to choose presets for sustained phase changes.
|
|
8
|
+
- Unknown shortened UUIDs now report how to retry without scanning saved conversations. Full addresses and live routing remain available.
|
|
9
|
+
- Notes, History and Board examples no longer prescribe `await`.
|
|
10
|
+
- New Notes whitelists use GPT-6.2 Sol and Astra alongside GPT-6 Luna.
|
|
11
|
+
|
|
3
12
|
## 0.0.2
|
|
4
13
|
|
|
5
14
|
- Notes lookup warnings now distinguish unavailable remote notes from local checkpoints.
|
package/dist/viewer/web/app.js
CHANGED
|
@@ -22,25 +22,25 @@ const { refresh, moreThreads, moreReplies } = createUpdates(renderer);
|
|
|
22
22
|
|
|
23
23
|
$("boards").onchange = () => run(() => loadBoard($("boards").value));
|
|
24
24
|
$("author").onchange = () =>
|
|
25
|
-
run(async () => {
|
|
25
|
+
void run(async () => {
|
|
26
26
|
state.author = $("author").value;
|
|
27
27
|
await loadList();
|
|
28
28
|
});
|
|
29
29
|
$("search-form").onsubmit = (event) => {
|
|
30
30
|
event.preventDefault();
|
|
31
|
-
run(async () => {
|
|
31
|
+
void run(async () => {
|
|
32
32
|
state.query = $("search").value.trim();
|
|
33
33
|
state.searchFull = $("search-full").checked;
|
|
34
34
|
await loadList();
|
|
35
35
|
});
|
|
36
36
|
};
|
|
37
37
|
$("search-full").onchange = () =>
|
|
38
|
-
run(async () => {
|
|
38
|
+
void run(async () => {
|
|
39
39
|
state.searchFull = $("search-full").checked;
|
|
40
40
|
await loadList();
|
|
41
41
|
});
|
|
42
42
|
$("full-discussion").onchange = () =>
|
|
43
|
-
run(() => openThread(state.thread, $("full-discussion").checked));
|
|
43
|
+
void run(() => openThread(state.thread, $("full-discussion").checked));
|
|
44
44
|
$("refresh").onclick = () => run(() => refresh(true));
|
|
45
45
|
$("back").onclick = () => {
|
|
46
46
|
document.body.classList.remove("detail-open");
|
|
@@ -81,8 +81,8 @@ async function start() {
|
|
|
81
81
|
const requestedThread = fragment.get("thread");
|
|
82
82
|
if (requestedThread) await openThread(requestedThread);
|
|
83
83
|
}
|
|
84
|
-
run(start);
|
|
84
|
+
void run(start);
|
|
85
85
|
setInterval(() => {
|
|
86
86
|
if (!document.hidden && $("live").checked && state.board && !busy && !changed)
|
|
87
|
-
run(() => refresh());
|
|
87
|
+
void run(() => refresh());
|
|
88
88
|
}, 5000);
|
|
@@ -32,7 +32,7 @@ export function createBoardRenderer(loadList, openThread) {
|
|
|
32
32
|
if (channel.posts !== undefined)
|
|
33
33
|
button.append(node("small", "", String(channel.posts)));
|
|
34
34
|
button.onclick = () =>
|
|
35
|
-
run(async () => {
|
|
35
|
+
void run(async () => {
|
|
36
36
|
state.channel = channel.name;
|
|
37
37
|
await loadList();
|
|
38
38
|
renderBoard();
|
|
@@ -106,7 +106,7 @@ export function createBoardRenderer(loadList, openThread) {
|
|
|
106
106
|
if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey)
|
|
107
107
|
return;
|
|
108
108
|
event.preventDefault();
|
|
109
|
-
run(() => openThread(thread.id));
|
|
109
|
+
void run(() => openThread(thread.id));
|
|
110
110
|
};
|
|
111
111
|
return link;
|
|
112
112
|
}),
|
package/docs/NOTES.md
CHANGED
|
@@ -34,8 +34,12 @@ In Code Mode and Notebook, plaintext notes and history return ordinary JavaScrip
|
|
|
34
34
|
|
|
35
35
|
By default, `new_context` starts a fresh window without generating a summary. The agent receives recent note paths, and Pi's saved history remains available for lookup.
|
|
36
36
|
|
|
37
|
+
Turn on **Task-completion rollover** in `/notes` to let the agent call `new_context({resume: false})` when its task is complete. It finishes its reply, then opens a fresh window without starting another turn. The next input starts work in that window. This option is off by default. Omitting `resume`, or setting it to `true`, continues immediately as before.
|
|
38
|
+
|
|
37
39
|
The tool requires a successful checkpoint write immediately before the request. Direct `notes` writes and writes completed through `exec` or `wait` count. A missing, pending or failed write keeps the current run active and asks the agent to save a note first.
|
|
38
40
|
|
|
41
|
+
Code and Notebook also accept `await tools.new_context(...)` after an awaited note save in the same cell. The native tool remains the advertised entry point. The nested callable does not add prompt guidance or a discovery listing.
|
|
42
|
+
|
|
39
43
|
Reminders arrive at 85% and 90% context use. With normal compaction off, `/compact` opens a fresh window immediately if the latest completed turn saved fresh notes. Otherwise it requests a checkpoint first. The new window waits for your next prompt; it does not start a continuation turn. Abort, errors and failed writes retain the old context. Overflow recovery still uses Pi's normal compaction.
|
|
40
44
|
|
|
41
45
|
Pi rejects `/compact` when there is too little history to prepare compaction, before extensions run. `new_context` follows the separate **New window requests** setting.
|
|
@@ -104,6 +108,7 @@ recovery keep their existing Notes settings.
|
|
|
104
108
|
- **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.
|
|
105
109
|
- **Normal compaction** uses the installed Pi or PCC compaction flow for `/compact` and `new_context`. Off keeps notes-only rollover, the default.
|
|
106
110
|
- **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.
|
|
111
|
+
- **Task-completion rollover** permits `resume: false` in `new_context`. Off by default. Checkpoint and new-window eligibility rules still apply. Aborting or failing the run cancels its pending task-completion rollover.
|
|
107
112
|
- **Idle rollover** selects the interval or disables it.
|
|
108
113
|
- **Prune missing sessions** removes notes, cached responses and history index entries for missing session files after confirmation. Unknown paths, permission errors and the active session are retained.
|
|
109
114
|
|
|
@@ -114,7 +119,7 @@ The whitelist is preseeded in `<Pi agent directory>/notes-compaction/settings.js
|
|
|
114
119
|
```json
|
|
115
120
|
{
|
|
116
121
|
"active": "whitelist",
|
|
117
|
-
"modelWhitelist": ["gpt-6-astra", "gpt-6-sol", "gpt-6-luna"
|
|
122
|
+
"modelWhitelist": ["gpt-6.2-astra", "gpt-6.2-sol", "gpt-6-luna"],
|
|
118
123
|
"normalCompaction": false,
|
|
119
124
|
"rankedHistorySearch": false,
|
|
120
125
|
"newWindowRequests": "unrestricted",
|
package/package.json
CHANGED
|
@@ -1,76 +1,77 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
2
|
+
"name": "@howaboua/pi-agent-comms",
|
|
3
|
+
"version": "0.0.3",
|
|
4
|
+
"description": "Session notes, context continuity and agent message boards for Pi",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/IgorWarzocha/howaboua-pi-stuff.git",
|
|
10
|
+
"directory": "packages/pi-agent-comms"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"index.ts",
|
|
14
|
+
"src",
|
|
15
|
+
"dist",
|
|
16
|
+
"docs",
|
|
17
|
+
"README.md",
|
|
18
|
+
"INTEGRATION.md",
|
|
19
|
+
"PCC-INTEGRATION.md",
|
|
20
|
+
"LICENSE",
|
|
21
|
+
"tsconfig.json",
|
|
22
|
+
"CHANGELOG.md"
|
|
23
|
+
],
|
|
24
|
+
"main": "index.ts",
|
|
25
|
+
"exports": {
|
|
26
|
+
".": "./index.ts",
|
|
27
|
+
"./context-sharing": "./src/notes/context-sharing.ts",
|
|
28
|
+
"./saved-session": "./src/notes/saved-session.mjs",
|
|
29
|
+
"./saved-session-index": "./src/notes/saved-session-index.mjs",
|
|
30
|
+
"./runtime": "./src/board/runtime/index.ts",
|
|
31
|
+
"./integration": "./src/board/integration.ts"
|
|
32
|
+
},
|
|
33
|
+
"pi": {
|
|
34
|
+
"extensions": [
|
|
35
|
+
"./index.ts"
|
|
36
|
+
]
|
|
37
|
+
},
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=22.19.0"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "node scripts/build-viewer.mjs",
|
|
43
|
+
"check": "bun run lint && bun run typecheck",
|
|
44
|
+
"lint": "bun run format:check && oxlint --type-aware",
|
|
45
|
+
"format": "oxfmt --write '**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx,json,jsonc,json5,css}'",
|
|
46
|
+
"typecheck": "tsrs --noEmit",
|
|
47
|
+
"prepack": "bun run check && bun run build",
|
|
48
|
+
"pack:dry": "npm pack --dry-run",
|
|
49
|
+
"format:check": "oxfmt --check '**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx,json,jsonc,json5,css}'"
|
|
50
|
+
},
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"@earendil-works/pi-schema": "1.5.2",
|
|
53
|
+
"better-sqlite3": "13.0.3",
|
|
54
|
+
"dompurify": "3.4.17",
|
|
55
|
+
"marked": "18.2.0",
|
|
56
|
+
"unicode-case-folding": "1.1.2"
|
|
57
|
+
},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"@howaboua/pi-codex-conversion": "5.0.1",
|
|
60
|
+
"@types/better-sqlite3": "9.6.0"
|
|
61
|
+
},
|
|
62
|
+
"peerDependencies": {
|
|
63
|
+
"@earendil-works/pi-coding-agent": ">=1.5.0",
|
|
64
|
+
"@earendil-works/pi-agent-core": ">=1.0.4",
|
|
65
|
+
"@earendil-works/pi-ai": ">=1.1.0",
|
|
66
|
+
"@earendil-works/pi-tui": ">=1.1.0",
|
|
67
|
+
"@howaboua/pi-codex-conversion": ">=5.0.1"
|
|
68
|
+
},
|
|
69
|
+
"peerDependenciesMeta": {
|
|
70
|
+
"@howaboua/pi-codex-conversion": {
|
|
71
|
+
"optional": true
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"publishConfig": {
|
|
75
|
+
"access": "public"
|
|
76
|
+
}
|
|
76
77
|
}
|
package/src/board/activity.ts
CHANGED
|
@@ -102,6 +102,7 @@ function boardRow(entry: SessionEntry): BoardRow | undefined {
|
|
|
102
102
|
label: [label, channel]
|
|
103
103
|
.filter(Boolean)
|
|
104
104
|
.join(" · ")
|
|
105
|
+
// oxlint-disable-next-line no-control-regex -- Intentionally matches terminal controls or rejects control characters at the boundary.
|
|
105
106
|
.replace(/[\r\n\t\x00-\x1f\x7f]/g, " "),
|
|
106
107
|
detail: () => JSON.stringify(entry.data, null, 2) ?? "",
|
|
107
108
|
};
|
package/src/board/delivery.ts
CHANGED
|
@@ -10,12 +10,14 @@ type Delivery =
|
|
|
10
10
|
let optionalDelivery: Promise<Delivery | undefined> | undefined;
|
|
11
11
|
|
|
12
12
|
function loadDelivery() {
|
|
13
|
-
return (optionalDelivery ??=
|
|
14
|
-
"@howaboua/pi-codex-conversion/developer-messages"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
return (optionalDelivery ??=
|
|
14
|
+
import("@howaboua/pi-codex-conversion/developer-messages").catch(
|
|
15
|
+
(error) => {
|
|
16
|
+
if (isMissingOptionalModule(error, "developer-messages"))
|
|
17
|
+
return undefined;
|
|
18
|
+
throw error;
|
|
19
|
+
},
|
|
20
|
+
));
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
export function isMissingOptionalModule(error: unknown, subpath: string) {
|
|
@@ -8,9 +8,8 @@ export async function activateBoard(pi: ExtensionAPI, runtime: BoardRuntime) {
|
|
|
8
8
|
const tool = createBoardTool(runtime);
|
|
9
9
|
pi.registerTool(tool);
|
|
10
10
|
try {
|
|
11
|
-
const { registerGptPromptMode, prepareGptPromptMode } =
|
|
12
|
-
"@howaboua/pi-codex-conversion/prompt-mode"
|
|
13
|
-
);
|
|
11
|
+
const { registerGptPromptMode, prepareGptPromptMode } =
|
|
12
|
+
await import("@howaboua/pi-codex-conversion/prompt-mode");
|
|
14
13
|
runtime.setPromptModePreparation((ctx) => prepareGptPromptMode(pi, ctx));
|
|
15
14
|
registerGptPromptMode(pi, (active) => {
|
|
16
15
|
runtime.gptPromptMode = active;
|
|
@@ -22,25 +22,25 @@ const { refresh, moreThreads, moreReplies } = createUpdates(renderer);
|
|
|
22
22
|
|
|
23
23
|
$("boards").onchange = () => run(() => loadBoard($("boards").value));
|
|
24
24
|
$("author").onchange = () =>
|
|
25
|
-
run(async () => {
|
|
25
|
+
void run(async () => {
|
|
26
26
|
state.author = $("author").value;
|
|
27
27
|
await loadList();
|
|
28
28
|
});
|
|
29
29
|
$("search-form").onsubmit = (event) => {
|
|
30
30
|
event.preventDefault();
|
|
31
|
-
run(async () => {
|
|
31
|
+
void run(async () => {
|
|
32
32
|
state.query = $("search").value.trim();
|
|
33
33
|
state.searchFull = $("search-full").checked;
|
|
34
34
|
await loadList();
|
|
35
35
|
});
|
|
36
36
|
};
|
|
37
37
|
$("search-full").onchange = () =>
|
|
38
|
-
run(async () => {
|
|
38
|
+
void run(async () => {
|
|
39
39
|
state.searchFull = $("search-full").checked;
|
|
40
40
|
await loadList();
|
|
41
41
|
});
|
|
42
42
|
$("full-discussion").onchange = () =>
|
|
43
|
-
run(() => openThread(state.thread, $("full-discussion").checked));
|
|
43
|
+
void run(() => openThread(state.thread, $("full-discussion").checked));
|
|
44
44
|
$("refresh").onclick = () => run(() => refresh(true));
|
|
45
45
|
$("back").onclick = () => {
|
|
46
46
|
document.body.classList.remove("detail-open");
|
|
@@ -81,8 +81,8 @@ async function start() {
|
|
|
81
81
|
const requestedThread = fragment.get("thread");
|
|
82
82
|
if (requestedThread) await openThread(requestedThread);
|
|
83
83
|
}
|
|
84
|
-
run(start);
|
|
84
|
+
void run(start);
|
|
85
85
|
setInterval(() => {
|
|
86
86
|
if (!document.hidden && $("live").checked && state.board && !busy && !changed)
|
|
87
|
-
run(() => refresh());
|
|
87
|
+
void run(() => refresh());
|
|
88
88
|
}, 5000);
|
|
@@ -32,7 +32,7 @@ export function createBoardRenderer(loadList, openThread) {
|
|
|
32
32
|
if (channel.posts !== undefined)
|
|
33
33
|
button.append(node("small", "", String(channel.posts)));
|
|
34
34
|
button.onclick = () =>
|
|
35
|
-
run(async () => {
|
|
35
|
+
void run(async () => {
|
|
36
36
|
state.channel = channel.name;
|
|
37
37
|
await loadList();
|
|
38
38
|
renderBoard();
|
|
@@ -106,7 +106,7 @@ export function createBoardRenderer(loadList, openThread) {
|
|
|
106
106
|
if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey)
|
|
107
107
|
return;
|
|
108
108
|
event.preventDefault();
|
|
109
|
-
run(() => openThread(thread.id));
|
|
109
|
+
void run(() => openThread(thread.id));
|
|
110
110
|
};
|
|
111
111
|
return link;
|
|
112
112
|
}),
|
package/src/notes/AGENTS.md
CHANGED
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
- Notes publishes one canonical payload as text and structuredContent with outputSchema. Preserve it through sharing and alias remapping; PCC consumes it directly. History keeps canonical content. Never derive values from freshness or routing details. Only Notes permits protected-output delivery.
|
|
7
7
|
- History's FTS index is derived and opt-in for the current session only. Disabled and other saved-session reads never build indexes; explicit pruning may delete existing rows. Reconcile committed JSONL pruning generations before indexing: the live SessionManager remains stale until restart. Rank only retired user/assistant visible text: Notes `trim=true` boundaries plus normal compaction's kept-entry cut, not window ID alone. Untrimmed initialization/rollover preserves live context. Never index calls, results, thinking or custom metadata. Explicit live/tool scopes and shared reads stay literal; full canonical reads remain intact. Scope ranked queries to selected JSONL entries after branch/window/tool filters; cached rows are not permission to return them. Keep user queries out of raw FTS syntax and Notes search unchanged.
|
|
8
8
|
- History caches lazy metadata by immutable Pi entry identity, not full rendered content: live entries retain cache values for the session lifetime. Never mutate cached entries. Its checked `.mjs` worker runs outside jiti; Node refuses type stripping under `node_modules`. Keep worker protocol imports type-only and probe a real installed-directory copy, not a checkout symlink.
|
|
9
|
-
- Register compaction preparation through the optional public PCC API so cancellation and projected branch preparation precede provider work in either load order.
|
|
9
|
+
- Register compaction preparation through the optional public PCC API so cancellation and projected branch preparation precede provider work in either load order. Tool requests keep eligibility policy independent of continuation: opt-in resume:false waits for successful run settlement, without abort/terminate or a successor kickoff. Manual and idle policies stay separate. Keep the pre-settlement final reply intact.
|
|
10
10
|
- Pi's `Compaction cancelled` notice during Notes-only rollover is cosmetic, not a defect, blocker or delivery caveat. Check the actual window transition instead of chasing or repeatedly reporting the notice.
|
|
11
11
|
- Await optional context-window preparation before a notes-only history cut, then recheck session/window validity. Summary compaction owns its refresh already; identity-only windows do not repeat it.
|
|
12
12
|
- Pi-limited notes-only requests cancel their own eligible pre-compaction hook before provider work. Only that owned cancellation permits rollover; Pi's exact no-work errors retain the window, other failures remain failures. Request permission never changes idle or manual policy.
|
|
13
|
-
- new_context requires a successful own save in the immediately preceding tool-call group, including parallel peers, or completed same-group predecessors.
|
|
13
|
+
- new_context requires a successful own save in the immediately preceding tool-call group, including parallel peers, or completed same-group predecessors. The unadvertised Code/Notebook callable uses the original exec ID and Notes-owned completed-write ledger, not an unfinished parent-cell result. Keep native model-only exposure and omit the nested callable from prompt/discovery listings. Never flatten groups into a last-call check or accept saves from older groups. Routed writes neither satisfy nor invalidate a local checkpoint in a mixed cell. Idle freshness still requires a completed run.
|
|
14
14
|
- Persist pending nested-write evidence before execution; only its matching completion may replace it. `pending` is required: starts are `pending:true,saved:false`; successful completions are `pending:false,saved:true`. Keep producers, readiness readers, save indicator and cutoff on this persisted meaning; semantic changes require an explicit protocol change, not incidental release edits. Pi's incomplete nested-call log also means omitted arguments, not necessarily unfinished writes.
|
|
15
15
|
- Tree navigation to a user/custom prompt stops at its parent, possibly after that prompt's preparation marker. A marker without delivered conversation must not stale the previous saved checkpoint; explicit run-scoped write proof stays strict.
|
|
16
16
|
- Custom kickoffs skip input hooks. The custom-turn-admission event owns pre-kickoff idle rollover; compaction must finish before Pi reserves startup as busy. Successor custom turns run every before_agent_start hook.
|
package/src/notes/activation.ts
CHANGED
|
@@ -95,6 +95,7 @@ export function createNotesActivation(
|
|
|
95
95
|
settings = value;
|
|
96
96
|
lifecycle.normalCompaction = value.normalCompaction;
|
|
97
97
|
lifecycle.newWindowRequests = value.newWindowRequests;
|
|
98
|
+
lifecycle.taskCompletionRollover = value.taskCompletionRollover;
|
|
98
99
|
lifecycle.idleMinutes = value.idleMinutes;
|
|
99
100
|
lifecycle.taskBoundaryReminder = value.taskBoundaryReminder;
|
|
100
101
|
}
|
package/src/notes/bridge.ts
CHANGED
|
@@ -49,8 +49,10 @@ export interface NoteSnapshotData {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
/** JSON-safe raw provenance. Projection belongs to the requesting runtime. */
|
|
52
|
-
export interface SerializedCachedResponse
|
|
53
|
-
|
|
52
|
+
export interface SerializedCachedResponse extends Omit<
|
|
53
|
+
CachedResponse,
|
|
54
|
+
"bytes"
|
|
55
|
+
> {
|
|
54
56
|
bytesBase64: string;
|
|
55
57
|
}
|
|
56
58
|
|
|
@@ -54,8 +54,8 @@ export function createNotesContextOwner(
|
|
|
54
54
|
| undefined;
|
|
55
55
|
return Boolean(
|
|
56
56
|
data?.version === 2 &&
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
Array.isArray(data.agents) &&
|
|
58
|
+
data.agents.length === 0,
|
|
59
59
|
);
|
|
60
60
|
}
|
|
61
61
|
// Foreign plain custom entries may be startup metadata. Notes state
|
|
@@ -87,9 +87,9 @@ export function createNotesContextOwner(
|
|
|
87
87
|
const details = windowDetails(entry);
|
|
88
88
|
return Boolean(
|
|
89
89
|
details &&
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
details.identity.windowNumber === 0 &&
|
|
91
|
+
!details.trim &&
|
|
92
|
+
(details.kind === "window" || details.kind === "identity"),
|
|
93
93
|
);
|
|
94
94
|
}),
|
|
95
95
|
snapshotNotes: exportNotesSnapshot,
|
package/src/notes/fresh-notes.ts
CHANGED
|
@@ -58,17 +58,58 @@ export function hasPrecedingNoteWrite(
|
|
|
58
58
|
windowId: string | undefined,
|
|
59
59
|
runId: string,
|
|
60
60
|
requestCallId: string,
|
|
61
|
+
parentCallId?: string,
|
|
61
62
|
): boolean {
|
|
62
63
|
const { messages, receipts, outcomes } = noteEvidence(
|
|
63
64
|
branch,
|
|
64
65
|
windowId,
|
|
65
66
|
runId,
|
|
66
67
|
);
|
|
68
|
+
if (parentCallId) {
|
|
69
|
+
// The running cell has no result yet. Only Notes-owned completed write
|
|
70
|
+
// outcomes under its exec/wait scopes can prove a same-cell save.
|
|
71
|
+
const issuingCall = messages.findLastIndex(
|
|
72
|
+
(message) =>
|
|
73
|
+
message.role === "assistant" &&
|
|
74
|
+
message.content.some(
|
|
75
|
+
(block) => block.type === "toolCall" && block.id === parentCallId,
|
|
76
|
+
),
|
|
77
|
+
);
|
|
78
|
+
if (issuingCall < 0) return false;
|
|
79
|
+
const parents = new Set([parentCallId]);
|
|
80
|
+
const initial = messages.find(
|
|
81
|
+
(message) =>
|
|
82
|
+
message.role === "toolResult" && message.toolCallId === parentCallId,
|
|
83
|
+
);
|
|
84
|
+
const cell = initial?.role === "toolResult" ? codeCell(initial) : undefined;
|
|
85
|
+
if (cell) {
|
|
86
|
+
for (const message of messages.slice(issuingCall)) {
|
|
87
|
+
if (message.role !== "assistant") continue;
|
|
88
|
+
for (const call of message.content) {
|
|
89
|
+
if (
|
|
90
|
+
call.type === "toolCall" &&
|
|
91
|
+
call.name === "wait" &&
|
|
92
|
+
call.arguments["cell_id"] === cell.id
|
|
93
|
+
)
|
|
94
|
+
parents.add(call.id);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
const local = outcomes.filter(
|
|
99
|
+
(item) => parents.has(item.parentCallId) && item.origin !== "routed",
|
|
100
|
+
);
|
|
101
|
+
if (local.length)
|
|
102
|
+
return (
|
|
103
|
+
receipts.length > 0 &&
|
|
104
|
+
local.every((item) => !item.pending && item.saved)
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
const issuingCallId = parentCallId ?? requestCallId;
|
|
67
108
|
const request = messages.findLastIndex(
|
|
68
109
|
(message) =>
|
|
69
110
|
message.role === "assistant" &&
|
|
70
111
|
message.content.some(
|
|
71
|
-
(block) => block.type === "toolCall" && block.id ===
|
|
112
|
+
(block) => block.type === "toolCall" && block.id === issuingCallId,
|
|
72
113
|
),
|
|
73
114
|
);
|
|
74
115
|
if (request < 0) return false;
|
|
@@ -83,7 +124,7 @@ export function hasPrecedingNoteWrite(
|
|
|
83
124
|
const current = groups.pop() ?? [];
|
|
84
125
|
const predecessors = current.slice(
|
|
85
126
|
0,
|
|
86
|
-
current.findIndex((call) => call.id ===
|
|
127
|
+
current.findIndex((call) => call.id === issuingCallId),
|
|
87
128
|
);
|
|
88
129
|
const calls = predecessors.length ? predecessors : (groups.at(-1) ?? []);
|
|
89
130
|
const allResults = messages.flatMap((message) =>
|
|
@@ -140,9 +181,9 @@ function noteEvidence(
|
|
|
140
181
|
.filter((receipt): receipt is NoteReceipt =>
|
|
141
182
|
Boolean(
|
|
142
183
|
receipt &&
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
184
|
+
receipt.origin !== "routed" &&
|
|
185
|
+
receipt.windowId === windowId &&
|
|
186
|
+
(!runId || receipt.runId === runId),
|
|
146
187
|
),
|
|
147
188
|
);
|
|
148
189
|
const messages = buildSessionProjection(run).messages;
|
|
@@ -113,7 +113,7 @@ async function* records(input, start, size) {
|
|
|
113
113
|
const buffer = Buffer.alloc(64 * 1024);
|
|
114
114
|
const decoder = new StringDecoder("utf8");
|
|
115
115
|
let pending = "";
|
|
116
|
-
for (let position = start; position < size;
|
|
116
|
+
for (let position = start; position < size;) {
|
|
117
117
|
const { bytesRead } = await input.read(
|
|
118
118
|
buffer,
|
|
119
119
|
0,
|
package/src/notes/index.ts
CHANGED
|
@@ -32,13 +32,17 @@ export async function createNotesRuntime(pi: ExtensionAPI, store: NotesStore) {
|
|
|
32
32
|
lifecycle.windows.projectBranch(entries),
|
|
33
33
|
);
|
|
34
34
|
let refreshNested = () => {};
|
|
35
|
+
let refreshTools = () => {};
|
|
35
36
|
const activation = createNotesActivation(
|
|
36
37
|
pi,
|
|
37
38
|
store,
|
|
38
39
|
search,
|
|
39
40
|
lifecycle,
|
|
40
41
|
settingsPath,
|
|
41
|
-
() =>
|
|
42
|
+
() => {
|
|
43
|
+
refreshTools();
|
|
44
|
+
refreshNested();
|
|
45
|
+
},
|
|
42
46
|
);
|
|
43
47
|
const stopAdmission = pi.events.on(
|
|
44
48
|
"pi-notes-compaction:custom-turn-admission:v1",
|
|
@@ -59,12 +63,14 @@ export async function createNotesRuntime(pi: ExtensionAPI, store: NotesStore) {
|
|
|
59
63
|
},
|
|
60
64
|
);
|
|
61
65
|
const roles = createModelRoles(pi, activation, lifecycle);
|
|
62
|
-
const
|
|
66
|
+
const toolRegistration = createTools(pi, store, lifecycle, search, roles);
|
|
67
|
+
const { tools } = toolRegistration;
|
|
68
|
+
refreshTools = toolRegistration.refresh;
|
|
63
69
|
refreshNested = await registerNotesToolIntegrations(
|
|
64
70
|
pi,
|
|
65
71
|
lifecycle,
|
|
66
72
|
activation,
|
|
67
|
-
|
|
73
|
+
toolRegistration,
|
|
68
74
|
);
|
|
69
75
|
for (const tool of tools) pi.registerTool(tool);
|
|
70
76
|
const owner = createNotesContextOwner(pi, store, lifecycle, search);
|