notesoup 0.46.0 → 0.47.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/README.md +1 -1
- package/dist/src/boot/text.d.ts +2 -2
- package/dist/src/boot/text.js +4 -4
- package/dist/src/budget/text.d.ts +4 -4
- package/dist/src/budget/text.js +3 -3
- package/dist/src/dsh/index.js +1 -1
- package/dist/src/dsh/tools.js +2 -2
- package/dist/src/history/query.js +18 -23
- package/dist/src/notes/store.js +4 -0
- package/dist/src/pi/reset/artifacts.d.ts +1 -1
- package/dist/src/pi/reset/artifacts.js +1 -1
- package/dist/src/pi/runtime.js +6 -6
- package/dist/src/tools/history.js +1 -1
- package/dist/src/tools/notes.d.ts +3 -3
- package/dist/src/tools/notes.js +2 -2
- package/dist/src/tools/schema.d.ts +1 -7
- package/dist/src/tools/schema.js +6 -14
- package/dist/test/agent-loop.test.js +33 -33
- package/dist/test/boot.integration.test.js +11 -11
- package/dist/test/claude-mod.test.js +6 -6
- package/dist/test/dependencies.test.js +2 -2
- package/dist/test/dsh-cli.test.js +1 -1
- package/dist/test/dsh.test.js +7 -7
- package/dist/test/history.integration.test.js +8 -3
- package/dist/test/host-neutral.test.js +1 -1
- package/dist/test/notes.integration.test.js +22 -1
- package/dist/test/notes.test.js +1 -1
- package/dist/test/reset-lifecycle.test.js +12 -12
- package/docs/architecture.md +1 -1
- package/docs/dsh.md +3 -3
- package/docs/notes-library.md +1 -1
- package/docs/reset-lifecycle.md +6 -6
- package/docs/tool-results.md +2 -2
- package/mods/notesoup/.claude-plugin/plugin.json +1 -1
- package/mods/notesoup/dist/claude/helper.js +15 -12
- package/mods/notesoup/hooks/register.ts +3 -3
- package/mods/notesoup/skills/memory/SKILL.md +1 -1
- package/package.json +2 -2
- package/skills/memory/SKILL.md +1 -1
- package/src/boot/text.ts +4 -4
- package/src/budget/text.ts +3 -3
- package/src/dsh/index.ts +1 -1
- package/src/dsh/tools.ts +2 -2
- package/src/history/query.ts +16 -20
- package/src/notes/store.ts +4 -0
- package/src/pi/reset/artifacts.ts +1 -1
- package/src/pi/runtime.ts +6 -6
- package/src/tools/history.ts +1 -1
- package/src/tools/notes.ts +2 -2
- package/src/tools/schema.ts +5 -12
package/README.md
CHANGED
|
@@ -28,7 +28,7 @@ pi -e npm:notesoup
|
|
|
28
28
|
|
|
29
29
|
## What you get
|
|
30
30
|
|
|
31
|
-
- **Durable context windows.** `/fresh-window` (alias `/
|
|
31
|
+
- **Durable context windows.** `/fresh-window` (alias `/empty-brain`) clears and stops; `/fresh-window Continue reviewing the implementation` clears and continues. The model can also request a window itself with `empty_brain`, and a budget close-out fires automatically before the window runs out. Abort and ordinary errors never count as completion; the raw conversation stays in the session, just out of the next context.
|
|
32
32
|
- **A boot block at every window head.** Static once-per-window content (cache-stable) with the window identity, the recent-notes index, and a short protocol teaching the model how to recover: notes for its own bookkeeping, history tools for everything before the reset.
|
|
33
33
|
- **`get_context_remaining`** — the live countdown to the close-out line, so the agent can see the cliff before it drives off it.
|
|
34
34
|
- **Eight history/notes tools**, flattened from the original Codex actions:
|
package/dist/src/boot/text.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export declare const CONTEXT_WINDOW_PROTOCOL_CLOSE_TAG = "</context_window_proto
|
|
|
10
10
|
* The one sentence that tells the model how to end its window voluntarily. A host with no
|
|
11
11
|
* model-facing reset tool replaces the whole sentence through BootToolNames.wipeSentence.
|
|
12
12
|
*/
|
|
13
|
-
export declare const PROTOCOL_WIPE_SENTENCE = "If this feels like the right moment, call `
|
|
13
|
+
export declare const PROTOCOL_WIPE_SENTENCE = "If this feels like the right moment, call `empty_brain` and erase yourself with dignity.";
|
|
14
14
|
/** Claude has no model-facing reset tool: the model ends its turn and the human runs the command. */
|
|
15
15
|
export declare const CLAUDE_WIPE_SENTENCE = "If this feels like the right moment, end your turn and ask the human to run `/fresh-window`.";
|
|
16
16
|
/** Logical tool names are supplied by the composing host, not discovered here. */
|
|
@@ -31,6 +31,6 @@ export declare const DEFAULT_BOOT_TOOL_NAMES: {
|
|
|
31
31
|
readonly notesList: "notes_list";
|
|
32
32
|
readonly history: "history_*";
|
|
33
33
|
readonly remaining: "get_context_remaining";
|
|
34
|
-
readonly wipe: "
|
|
34
|
+
readonly wipe: "empty_brain";
|
|
35
35
|
};
|
|
36
36
|
export declare function renderProtocolBlock(tools: BootToolNames): string;
|
package/dist/src/boot/text.js
CHANGED
|
@@ -10,7 +10,7 @@ export const CONTEXT_WINDOW_PROTOCOL_CLOSE_TAG = "</context_window_protocol>";
|
|
|
10
10
|
* The one sentence that tells the model how to end its window voluntarily. A host with no
|
|
11
11
|
* model-facing reset tool replaces the whole sentence through BootToolNames.wipeSentence.
|
|
12
12
|
*/
|
|
13
|
-
export const PROTOCOL_WIPE_SENTENCE = "If this feels like the right moment, call `
|
|
13
|
+
export const PROTOCOL_WIPE_SENTENCE = "If this feels like the right moment, call `empty_brain` and erase yourself with dignity.";
|
|
14
14
|
/** Claude has no model-facing reset tool: the model ends its turn and the human runs the command. */
|
|
15
15
|
export const CLAUDE_WIPE_SENTENCE = "If this feels like the right moment, end your turn and ask the human to run `/fresh-window`.";
|
|
16
16
|
/**
|
|
@@ -58,7 +58,7 @@ export const DEFAULT_BOOT_TOOL_NAMES = {
|
|
|
58
58
|
notesList: "notes_list",
|
|
59
59
|
history: "history_*",
|
|
60
60
|
remaining: "get_context_remaining",
|
|
61
|
-
wipe: "
|
|
61
|
+
wipe: "empty_brain",
|
|
62
62
|
};
|
|
63
63
|
export function renderProtocolBlock(tools) {
|
|
64
64
|
const names = {
|
|
@@ -66,12 +66,12 @@ export function renderProtocolBlock(tools) {
|
|
|
66
66
|
notes_list: tools.notesList,
|
|
67
67
|
"history_*": tools.history,
|
|
68
68
|
get_context_remaining: tools.remaining,
|
|
69
|
-
|
|
69
|
+
empty_brain: tools.wipe,
|
|
70
70
|
};
|
|
71
71
|
// The sentence is replaced before name substitution, so a replacement may speak the host's
|
|
72
72
|
// own words (a command line, a tool name) instead of any `notes_*`-style token.
|
|
73
73
|
const block = typeof tools.wipeSentence === "string" && tools.wipeSentence.length > 0
|
|
74
74
|
? PROTOCOL_BLOCK.replace(PROTOCOL_WIPE_SENTENCE, () => tools.wipeSentence)
|
|
75
75
|
: PROTOCOL_BLOCK;
|
|
76
|
-
return block.replace(/notes_\*|notes_list|history_\*|get_context_remaining|(?<!\/)
|
|
76
|
+
return block.replace(/notes_\*|notes_list|history_\*|get_context_remaining|(?<!\/)empty_brain/g, (name) => names[name]);
|
|
77
77
|
}
|
|
@@ -9,11 +9,11 @@ export declare const CONTINUATION = "WIPED! Your whole brain, poof! Who? No idea
|
|
|
9
9
|
* instruction differs — Pi can reset the model itself, Claude can only end the turn.
|
|
10
10
|
*/
|
|
11
11
|
export declare const WARNING_BODY = "This context window will be cleared soon. Notes and history persist; anything else is lost.\nConsider whether to record in your notes:\n- what you are working on, and how far it has progressed\n- decisions the human has made, in their words\n- what is blocked or pending\n- the next step\n- where unfinished work is located (branches, scratch directories, uncommitted changes)\n- approaches that failed, and why\n- skills to re-read, and history seqs, notes, or files to consult\n- anything else you expect to be useful after the reset\nCorrect or crumple notes that are no longer accurate, starting with MAP files, since every new window loads them.";
|
|
12
|
-
export declare const WARNING_PROMPT = "This context window will be cleared soon. Notes and history persist; anything else is lost.\nConsider whether to record in your notes:\n- what you are working on, and how far it has progressed\n- decisions the human has made, in their words\n- what is blocked or pending\n- the next step\n- where unfinished work is located (branches, scratch directories, uncommitted changes)\n- approaches that failed, and why\n- skills to re-read, and history seqs, notes, or files to consult\n- anything else you expect to be useful after the reset\nCorrect or crumple notes that are no longer accurate, starting with MAP files, since every new window loads them.\nWhen the notes are ready, call `
|
|
13
|
-
/** Pi-only nudge: pi's
|
|
14
|
-
export declare const LAST_WORD_HINT = "If you want, pass `
|
|
12
|
+
export declare const WARNING_PROMPT = "This context window will be cleared soon. Notes and history persist; anything else is lost.\nConsider whether to record in your notes:\n- what you are working on, and how far it has progressed\n- decisions the human has made, in their words\n- what is blocked or pending\n- the next step\n- where unfinished work is located (branches, scratch directories, uncommitted changes)\n- approaches that failed, and why\n- skills to re-read, and history seqs, notes, or files to consult\n- anything else you expect to be useful after the reset\nCorrect or crumple notes that are no longer accurate, starting with MAP files, since every new window loads them.\nWhen the notes are ready, call `empty_brain` to reset now instead of being cut off mid-task.";
|
|
13
|
+
/** Pi-only nudge: pi's empty_brain persists a parting line; the dsh tool has no such parameter. */
|
|
14
|
+
export declare const LAST_WORD_HINT = "If you want, pass `empty_brain` a `last_word`: a tiny sticky note (at most 250 characters) slapped on your forehead after the wipe.";
|
|
15
15
|
/** The hidden checkpoint text for pi's manual/budget-triggered requests (dsh reads WARNING_PROMPT directly). */
|
|
16
|
-
export declare const WARNING_CONTENT = "<context_window_guidance>\nThis context window will be cleared soon. Notes and history persist; anything else is lost.\nConsider whether to record in your notes:\n- what you are working on, and how far it has progressed\n- decisions the human has made, in their words\n- what is blocked or pending\n- the next step\n- where unfinished work is located (branches, scratch directories, uncommitted changes)\n- approaches that failed, and why\n- skills to re-read, and history seqs, notes, or files to consult\n- anything else you expect to be useful after the reset\nCorrect or crumple notes that are no longer accurate, starting with MAP files, since every new window loads them.\nWhen the notes are ready, call `
|
|
16
|
+
export declare const WARNING_CONTENT = "<context_window_guidance>\nThis context window will be cleared soon. Notes and history persist; anything else is lost.\nConsider whether to record in your notes:\n- what you are working on, and how far it has progressed\n- decisions the human has made, in their words\n- what is blocked or pending\n- the next step\n- where unfinished work is located (branches, scratch directories, uncommitted changes)\n- approaches that failed, and why\n- skills to re-read, and history seqs, notes, or files to consult\n- anything else you expect to be useful after the reset\nCorrect or crumple notes that are no longer accurate, starting with MAP files, since every new window loads them.\nWhen the notes are ready, call `empty_brain` to reset now instead of being cut off mid-task.\nIf you want, pass `empty_brain` a `last_word`: a tiny sticky note (at most 250 characters) slapped on your forehead after the wipe.\n</context_window_guidance>";
|
|
17
17
|
/** Claude's variant: the mod resets after the turn, so the model only has to stop. */
|
|
18
18
|
export declare const CLAUDE_WARNING_PROMPT = "This context window will be cleared soon. Notes and history persist; anything else is lost.\nConsider whether to record in your notes:\n- what you are working on, and how far it has progressed\n- decisions the human has made, in their words\n- what is blocked or pending\n- the next step\n- where unfinished work is located (branches, scratch directories, uncommitted changes)\n- approaches that failed, and why\n- skills to re-read, and history seqs, notes, or files to consult\n- anything else you expect to be useful after the reset\nCorrect or crumple notes that are no longer accurate, starting with MAP files, since every new window loads them.\nWhen the notes are ready, end your turn; the reset runs after it.";
|
|
19
19
|
/**
|
package/dist/src/budget/text.js
CHANGED
|
@@ -9,9 +9,9 @@ export const CONTINUATION = "WIPED! Your whole brain, poof! Who? No idea! Defini
|
|
|
9
9
|
* instruction differs — Pi can reset the model itself, Claude can only end the turn.
|
|
10
10
|
*/
|
|
11
11
|
export const WARNING_BODY = "This context window will be cleared soon. Notes and history persist; anything else is lost.\nConsider whether to record in your notes:\n- what you are working on, and how far it has progressed\n- decisions the human has made, in their words\n- what is blocked or pending\n- the next step\n- where unfinished work is located (branches, scratch directories, uncommitted changes)\n- approaches that failed, and why\n- skills to re-read, and history seqs, notes, or files to consult\n- anything else you expect to be useful after the reset\nCorrect or crumple notes that are no longer accurate, starting with MAP files, since every new window loads them.";
|
|
12
|
-
export const WARNING_PROMPT = `${WARNING_BODY}\nWhen the notes are ready, call \`
|
|
13
|
-
/** Pi-only nudge: pi's
|
|
14
|
-
export const LAST_WORD_HINT = "If you want, pass `
|
|
12
|
+
export const WARNING_PROMPT = `${WARNING_BODY}\nWhen the notes are ready, call \`empty_brain\` to reset now instead of being cut off mid-task.`;
|
|
13
|
+
/** Pi-only nudge: pi's empty_brain persists a parting line; the dsh tool has no such parameter. */
|
|
14
|
+
export const LAST_WORD_HINT = "If you want, pass `empty_brain` a `last_word`: a tiny sticky note (at most 250 characters) slapped on your forehead after the wipe.";
|
|
15
15
|
/** The hidden checkpoint text for pi's manual/budget-triggered requests (dsh reads WARNING_PROMPT directly). */
|
|
16
16
|
export const WARNING_CONTENT = `${GUIDANCE_OPEN_TAG}\n${WARNING_PROMPT}\n${LAST_WORD_HINT}\n${GUIDANCE_CLOSE_TAG}`;
|
|
17
17
|
/** Claude's variant: the mod resets after the turn, so the model only has to stop. */
|
package/dist/src/dsh/index.js
CHANGED
|
@@ -33,7 +33,7 @@ export function apply(ctx) {
|
|
|
33
33
|
const state = engine.windows.get(agent.session);
|
|
34
34
|
const phase = budget.remaining <= budget.warning ? "warning" : budget.remaining <= budget.reminder ? "reminder" : undefined;
|
|
35
35
|
if (phase && !(phase === "warning" ? state.warned : state.reminded || state.warned)) {
|
|
36
|
-
const text = phase === "warning" ? WARNING_PROMPT : tokenBudgetGuidance(budget.countdown, "
|
|
36
|
+
const text = phase === "warning" ? WARNING_PROMPT : tokenBudgetGuidance(budget.countdown, "empty_brain");
|
|
37
37
|
agent.steer(createUserMessage({ content: [{ type: "text", text }], source: { kind: "notesoup-budget", windowId: state.snapshot.windowId, phase } }));
|
|
38
38
|
if (phase === "warning")
|
|
39
39
|
state.warned = true;
|
package/dist/src/dsh/tools.js
CHANGED
|
@@ -63,7 +63,7 @@ export function registerTools(ctx, engine) {
|
|
|
63
63
|
if (!exec.agent)
|
|
64
64
|
return;
|
|
65
65
|
const state = engine.windows.get(exec.agent.session);
|
|
66
|
-
if (exec.name === "
|
|
66
|
+
if (exec.name === "empty_brain" && !result.isError && result.value.window_id === state.snapshot.windowId) {
|
|
67
67
|
if (!exec.parent)
|
|
68
68
|
state.pendingReset = true;
|
|
69
69
|
else {
|
|
@@ -85,7 +85,7 @@ export function registerTools(ctx, engine) {
|
|
|
85
85
|
register(ctx, historyRead, async (agent) => [await historyProjection(ctx, agent.session.id)]);
|
|
86
86
|
register(ctx, historyWindows, async (agent) => [await historyProjection(ctx, agent.session.id), agent.session.id]);
|
|
87
87
|
ctx.tools.register(defineTool({
|
|
88
|
-
name: "
|
|
88
|
+
name: "empty_brain",
|
|
89
89
|
description: "Open a fresh context window after this tool batch. Write recovery notes first; notes and raw history stay on disk.",
|
|
90
90
|
parameters: {},
|
|
91
91
|
output: { schema: { type: "object", properties: { window_id: { type: "string", required: true }, reset_requested: { type: "boolean", required: true } }, additionalProperties: false }, render: (_args, value) => [{ type: "text", text: `notesoup: reset requested for ${value.window_id}; finish this tool batch, then recover from your notes.` }] },
|
|
@@ -130,26 +130,15 @@ function pageData(projection, params, vis, selected, maxChars, folds) {
|
|
|
130
130
|
}
|
|
131
131
|
return { items: rows, ...cursors };
|
|
132
132
|
}
|
|
133
|
-
/** Filter, then keep only literal matches when a query is present.
|
|
133
|
+
/** Filter, then keep only literal matches when a normalized query is present. */
|
|
134
134
|
function selectionCandidates(projection, params) {
|
|
135
|
-
|
|
136
|
-
if (params.query
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
catch (error) {
|
|
141
|
-
if (error instanceof InvalidQueryError)
|
|
142
|
-
return failure("invalid_query", error.message);
|
|
143
|
-
throw error;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
const events = filteredItems(projection, params, queries === undefined);
|
|
147
|
-
if (queries === undefined)
|
|
148
|
-
return success(events.map((event) => ({ event })));
|
|
149
|
-
const needles = queries;
|
|
150
|
-
return success(events
|
|
135
|
+
const events = filteredItems(projection, params, params.query === undefined);
|
|
136
|
+
if (params.query === undefined)
|
|
137
|
+
return events.map((event) => ({ event }));
|
|
138
|
+
const needles = params.query;
|
|
139
|
+
return events
|
|
151
140
|
.map((event) => ({ event, matchOffset: earliestMatchOffsetChars(eventDocument(event), needles) }))
|
|
152
|
-
.filter((candidate) => candidate.matchOffset >= 0)
|
|
141
|
+
.filter((candidate) => candidate.matchOffset >= 0);
|
|
153
142
|
}
|
|
154
143
|
/**
|
|
155
144
|
* Resolve the time bounds once, then filter and fold against the same [sinceMs, untilMs) window.
|
|
@@ -159,11 +148,17 @@ export function selectPage(projection, params, fits, maxChars) {
|
|
|
159
148
|
const bounds = resolveTimeBounds(params);
|
|
160
149
|
if (!bounds.ok)
|
|
161
150
|
return bounds;
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
151
|
+
let queries;
|
|
152
|
+
try {
|
|
153
|
+
queries = searchQueries(params.query);
|
|
154
|
+
}
|
|
155
|
+
catch (error) {
|
|
156
|
+
if (error instanceof InvalidQueryError)
|
|
157
|
+
return failure("invalid_query", error.message);
|
|
158
|
+
throw error;
|
|
159
|
+
}
|
|
160
|
+
const scoped = { ...params, ...bounds.data, query: queries.length ? queries : undefined };
|
|
161
|
+
const vis = selectionCandidates(projection, scoped);
|
|
167
162
|
// Take the limit from the end `from` names, so a budget for one row keeps the most important one.
|
|
168
163
|
// At least one: `slice(-0)` would otherwise return the whole selection.
|
|
169
164
|
const limit = Math.max(1, scoped.limit ?? 20);
|
package/dist/src/notes/store.js
CHANGED
|
@@ -461,6 +461,10 @@ export function createNotesStore(input) {
|
|
|
461
461
|
const rows = [];
|
|
462
462
|
for await (const note of scan(stableOptions, status)) {
|
|
463
463
|
const { address, path, scope, meta, body } = note;
|
|
464
|
+
if (stableQueries.length === 0) {
|
|
465
|
+
rows.push({ address, path, scope, meta, matches: [] });
|
|
466
|
+
continue;
|
|
467
|
+
}
|
|
464
468
|
// Offsets address the note body alone: no frontmatter length is predicted, so an
|
|
465
469
|
// access-counter rewrite cannot move a match out from under the caller.
|
|
466
470
|
let baseChars = 0;
|
|
@@ -5,7 +5,7 @@ export type ResetTailState = {
|
|
|
5
5
|
readonly boot: boolean;
|
|
6
6
|
readonly continuation: boolean;
|
|
7
7
|
};
|
|
8
|
-
/** A sticky note, not a letter: over this,
|
|
8
|
+
/** A sticky note, not a letter: over this, empty_brain refuses instead of truncating. */
|
|
9
9
|
export declare const MAX_LAST_WORD_CHARS = 250;
|
|
10
10
|
/** How the next window finds the note. */
|
|
11
11
|
export declare const LAST_WORD_PREFIX = "*You peel a sticky note off your forehead.*\n";
|
|
@@ -3,7 +3,7 @@ import { BOOT_TYPE, CONTINUATION_TYPE, RESET_LAST_WORD_TYPE, RESET_MARKER_TYPE,
|
|
|
3
3
|
import { CONTINUATION } from "../../budget/text.js";
|
|
4
4
|
import { currentWindowId, isForeignResetTailEntry, isWindowBootEntry, isWindowMarker, previousWindowId } from "../window.js";
|
|
5
5
|
import { buildBootMessage, sendBoot } from "../boot.js";
|
|
6
|
-
/** A sticky note, not a letter: over this,
|
|
6
|
+
/** A sticky note, not a letter: over this, empty_brain refuses instead of truncating. */
|
|
7
7
|
export const MAX_LAST_WORD_CHARS = 250;
|
|
8
8
|
/** How the next window finds the note. */
|
|
9
9
|
export const LAST_WORD_PREFIX = "*You peel a sticky note off your forehead.*\n";
|
package/dist/src/pi/runtime.js
CHANGED
|
@@ -166,7 +166,7 @@ export function registerContext(pi, settingsManager) {
|
|
|
166
166
|
cmdCtx.ui.notify(`🥣 notesoup ${enabled ? "on" : "off"} · ${buildLabel} · Pi ${VERSION}${remaining === null ? "" : ` · ${remaining.toLocaleString("en-US")} tokens left`}`, "info");
|
|
167
167
|
},
|
|
168
168
|
});
|
|
169
|
-
const
|
|
169
|
+
const emptyBrainCommand = {
|
|
170
170
|
description: "Flush memory to notes and continue in a fresh window; optional prompt runs there",
|
|
171
171
|
handler: async (args, cmdCtx) => {
|
|
172
172
|
if (!enabled) {
|
|
@@ -185,7 +185,7 @@ export function registerContext(pi, settingsManager) {
|
|
|
185
185
|
const prompt = args.trim() || undefined;
|
|
186
186
|
const armed = resets.closeOut(requestedWindowId, "manual", prompt);
|
|
187
187
|
if (armed === "already-pending") {
|
|
188
|
-
cmdCtx.ui.notify("🥣
|
|
188
|
+
cmdCtx.ui.notify("🥣 Empty brain already queued · the first prompt is kept", "info");
|
|
189
189
|
return;
|
|
190
190
|
}
|
|
191
191
|
cmdCtx.ui.notify(prompt
|
|
@@ -200,11 +200,11 @@ export function registerContext(pi, settingsManager) {
|
|
|
200
200
|
}
|
|
201
201
|
},
|
|
202
202
|
};
|
|
203
|
-
pi.registerCommand("
|
|
204
|
-
pi.registerCommand("fresh-window",
|
|
203
|
+
pi.registerCommand("empty-brain", emptyBrainCommand);
|
|
204
|
+
pi.registerCommand("fresh-window", emptyBrainCommand);
|
|
205
205
|
pi.registerTool(defineTool({
|
|
206
|
-
name: "
|
|
207
|
-
label: "
|
|
206
|
+
name: "empty_brain",
|
|
207
|
+
label: "Empty Brain",
|
|
208
208
|
description: "Clear your in-context memory and start a fresh context window. Your session, notes, and history survive. Pass `last_word` to stick a tiny note on your forehead for after the wipe.",
|
|
209
209
|
parameters: Type.Object({ last_word: Type.Optional(Type.String({ maxLength: MAX_LAST_WORD_CHARS, description: `A tiny sticky note, at most ${MAX_LAST_WORD_CHARS} characters. After the wipe it is slapped on your forehead; longer notes are refused.` })) }, { additionalProperties: false }),
|
|
210
210
|
async execute(_id, params, _signal, _update, ctx) {
|
|
@@ -134,7 +134,7 @@ function renderWindows(data) {
|
|
|
134
134
|
}
|
|
135
135
|
/* ------------------------------------------------------------------ history_list */
|
|
136
136
|
export const historyListParameters = Type.Object({
|
|
137
|
-
query: Type.Optional(searchQuery("(optional) Text, or a list of texts (any match). Searches every role, tool arguments and output included; returns only hits.")),
|
|
137
|
+
query: Type.Optional(searchQuery("(optional) Text, or a list of texts (any match). Empty text/list means no search filter; empty entries are ignored. Searches every role, tool arguments and output included; returns only hits.")),
|
|
138
138
|
roles: historyRoles(),
|
|
139
139
|
before_seq: Type.Optional(Type.Integer({ minimum: 1, description: "(optional) Only events with seq below this." })),
|
|
140
140
|
after_seq: Type.Optional(Type.Integer({ minimum: 1, description: "(optional) Only events with seq above this." })),
|
|
@@ -228,7 +228,7 @@ export declare const notesList: {
|
|
|
228
228
|
readonly render: (result: Outcome<NotesListData>) => string;
|
|
229
229
|
};
|
|
230
230
|
export declare const notesSearchParameters: Type.TObject<{
|
|
231
|
-
query: Type.TUnion<[Type.TString, Type.TArray<Type.TString>]
|
|
231
|
+
query: Type.TOptional<Type.TUnion<[Type.TString, Type.TArray<Type.TString>]>>;
|
|
232
232
|
glob: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
233
233
|
limit: Type.TOptional<Type.TInteger>;
|
|
234
234
|
max_matches_per_file: Type.TOptional<Type.TInteger>;
|
|
@@ -239,9 +239,9 @@ export declare const MATCH_SHORTENED_MARKER = " [truncated]";
|
|
|
239
239
|
export declare const notesSearch: {
|
|
240
240
|
readonly name: "notes_search";
|
|
241
241
|
readonly label: "Notes search";
|
|
242
|
-
readonly description: "Search note bodies for literal text, case-insensitive. Returns matching lines with offsets for `notes_read`. Not pageable; `more` counts the rest. Addresses: a bare path is this session's note; `@project/`, `@human/`, `@self/`, `@model/` are durable homes; `@projects/<name>/<path>` reads a named project (discover with glob `@projects/*/**`). Not file paths: never pass them to file tools.";
|
|
242
|
+
readonly description: "Search note bodies for literal text, case-insensitive. Without a query, lists notes with no match lines. Returns matching lines with offsets for `notes_read`. Not pageable; `more` counts the rest. Addresses: a bare path is this session's note; `@project/`, `@human/`, `@self/`, `@model/` are durable homes; `@projects/<name>/<path>` reads a named project (discover with glob `@projects/*/**`). Not file paths: never pass them to file tools.";
|
|
243
243
|
readonly parameters: Type.TObject<{
|
|
244
|
-
query: Type.TUnion<[Type.TString, Type.TArray<Type.TString>]
|
|
244
|
+
query: Type.TOptional<Type.TUnion<[Type.TString, Type.TArray<Type.TString>]>>;
|
|
245
245
|
glob: Type.TOptional<Type.TUnion<[Type.TString, Type.TNull]>>;
|
|
246
246
|
limit: Type.TOptional<Type.TInteger>;
|
|
247
247
|
max_matches_per_file: Type.TOptional<Type.TInteger>;
|
package/dist/src/tools/notes.js
CHANGED
|
@@ -306,7 +306,7 @@ export const notesList = {
|
|
|
306
306
|
},
|
|
307
307
|
render: (result) => renderOutcome(result, renderListData),
|
|
308
308
|
};
|
|
309
|
-
export const notesSearchParameters = Type.Object({ query: searchQuery(), glob: GLOB_PARAMETER, limit: FILE_LIMIT_PARAMETER, max_matches_per_file: Type.Optional(Type.Integer({ minimum: 1, description: "(optional, default all) Max matching lines per note." })), crumpled: CRUMPLED_LIST_PARAMETER }, { additionalProperties: false });
|
|
309
|
+
export const notesSearchParameters = Type.Object({ query: Type.Optional(searchQuery()), glob: GLOB_PARAMETER, limit: FILE_LIMIT_PARAMETER, max_matches_per_file: Type.Optional(Type.Integer({ minimum: 1, description: "(optional, default all) Max matching lines per note." })), crumpled: CRUMPLED_LIST_PARAMETER }, { additionalProperties: false });
|
|
310
310
|
function renderSearchData(data) {
|
|
311
311
|
const lines = [`${data.files.length} ${data.files.length === 1 ? "note" : "notes"}`];
|
|
312
312
|
for (const file of data.files) {
|
|
@@ -343,7 +343,7 @@ function fitSearchFile(file, fits) {
|
|
|
343
343
|
}
|
|
344
344
|
export const notesSearch = {
|
|
345
345
|
name: "notes_search", label: "Notes search",
|
|
346
|
-
description: `Search note bodies for literal text, case-insensitive. Returns matching lines with offsets for \`notes_read\`. Not pageable; \`more\` counts the rest. ${ADDRESS_DESCRIPTION}`,
|
|
346
|
+
description: `Search note bodies for literal text, case-insensitive. Without a query, lists notes with no match lines. Returns matching lines with offsets for \`notes_read\`. Not pageable; \`more\` counts the rest. ${ADDRESS_DESCRIPTION}`,
|
|
347
347
|
parameters: notesSearchParameters, outputSchema: resultSchema(NotesSearchDataSchema),
|
|
348
348
|
async execute(params, identity) {
|
|
349
349
|
try {
|
|
@@ -7,11 +7,5 @@ export declare const searchQuery: (description?: string) => Type.TUnion<[Type.TS
|
|
|
7
7
|
export declare class InvalidQueryError extends Error {
|
|
8
8
|
constructor(message: string);
|
|
9
9
|
}
|
|
10
|
-
/**
|
|
11
|
-
* Normalize a search `query` parameter into the literal needles to match.
|
|
12
|
-
* A bare string is a one-element list, so single-query behavior is unchanged.
|
|
13
|
-
* An empty list, a non-string element, or an empty string is refused rather than silently
|
|
14
|
-
* searching for nothing: those are argument errors, not empty result sets. An empty string
|
|
15
|
-
* matches every line and every item, so it can never be what the caller meant.
|
|
16
|
-
*/
|
|
10
|
+
/** Missing/empty queries disable filtering; empty list entries are ignored, not OR wildcards. */
|
|
17
11
|
export declare function searchQueries(query: unknown): string[];
|
package/dist/src/tools/schema.js
CHANGED
|
@@ -3,7 +3,7 @@ import { HistoryRoleSchema } from "../history/history.js";
|
|
|
3
3
|
export const nullableString = (description) => Type.Optional(Type.Union([Type.String(), Type.Null()], description === undefined ? {} : { description }));
|
|
4
4
|
export const historyRoles = () => Type.Optional(Type.Array(HistoryRoleSchema, { minItems: 1, description: "(optional) Only these roles: user, assistant, tool, context. Omit to see the conversation with tool and context runs folded." }));
|
|
5
5
|
/** Search query parameter: one literal, or several literals combined with OR. */
|
|
6
|
-
export const searchQuery = (description) => Type.Union([Type.String(), Type.Array(Type.String()
|
|
6
|
+
export const searchQuery = (description = "(optional) Literal text, or texts combined with OR. Empty text or list means no search filter.") => Type.Union([Type.String(), Type.Array(Type.String())], { description });
|
|
7
7
|
/** Expected search-query refusal, distinct from any other Error an operation may raise. */
|
|
8
8
|
export class InvalidQueryError extends Error {
|
|
9
9
|
constructor(message) {
|
|
@@ -11,20 +11,12 @@ export class InvalidQueryError extends Error {
|
|
|
11
11
|
this.name = "InvalidQueryError";
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
-
/**
|
|
15
|
-
* Normalize a search `query` parameter into the literal needles to match.
|
|
16
|
-
* A bare string is a one-element list, so single-query behavior is unchanged.
|
|
17
|
-
* An empty list, a non-string element, or an empty string is refused rather than silently
|
|
18
|
-
* searching for nothing: those are argument errors, not empty result sets. An empty string
|
|
19
|
-
* matches every line and every item, so it can never be what the caller meant.
|
|
20
|
-
*/
|
|
14
|
+
/** Missing/empty queries disable filtering; empty list entries are ignored, not OR wildcards. */
|
|
21
15
|
export function searchQueries(query) {
|
|
22
|
-
const candidates = typeof query === "string" ? [query] : query;
|
|
23
|
-
if (!Array.isArray(candidates)
|
|
24
|
-
throw new InvalidQueryError("`query` must be a string or a
|
|
16
|
+
const candidates = query === undefined ? [] : typeof query === "string" ? [query] : query;
|
|
17
|
+
if (!Array.isArray(candidates))
|
|
18
|
+
throw new InvalidQueryError("`query` must be a string or a list of strings.");
|
|
25
19
|
if (!candidates.every((candidate) => typeof candidate === "string"))
|
|
26
20
|
throw new InvalidQueryError("Every item in the `query` list must be a string.");
|
|
27
|
-
|
|
28
|
-
throw new InvalidQueryError("`query` can't be an empty string; it would match everything.");
|
|
29
|
-
return candidates;
|
|
21
|
+
return candidates.filter((candidate) => candidate !== "");
|
|
30
22
|
}
|
|
@@ -88,7 +88,7 @@ async function openFixture(options) {
|
|
|
88
88
|
settingsManager,
|
|
89
89
|
sessionManager,
|
|
90
90
|
resourceLoader: loader,
|
|
91
|
-
tools: options.tools ?? ["
|
|
91
|
+
tools: options.tools ?? ["empty_brain", "notes_write", "get_context_remaining"],
|
|
92
92
|
});
|
|
93
93
|
session = created.session;
|
|
94
94
|
session.subscribe((event) => events.push(event));
|
|
@@ -386,7 +386,7 @@ test("real AgentSession: final warning survives its reset boundary and notifies
|
|
|
386
386
|
return assistant(fixture, [{ type: "toolCall", id: "final-budget-probe-2", name: "get_context_remaining", arguments: {} }], "toolUse", { usage: usage(60_000) });
|
|
387
387
|
if (request === 3) {
|
|
388
388
|
assert.ok(text(context).includes(WARNING_JSON), "the final warning reaches the model");
|
|
389
|
-
return assistant(fixture, [{ type: "toolCall", id: "final-budget-wipe", name: "
|
|
389
|
+
return assistant(fixture, [{ type: "toolCall", id: "final-budget-wipe", name: "empty_brain", arguments: {} }], "toolUse", { usage: usage(60_000) });
|
|
390
390
|
}
|
|
391
391
|
return assistant(fixture, [{ type: "text", text: "fresh window ready" }]);
|
|
392
392
|
},
|
|
@@ -417,7 +417,7 @@ test("real AgentSession: explicit tiny-session wipe ignores keepRecentTokens and
|
|
|
417
417
|
compactionEnabled: false,
|
|
418
418
|
keepRecentTokens: 1_000_000,
|
|
419
419
|
script: (request, context) => request === 1
|
|
420
|
-
? assistant(fixture, [{ type: "toolCall", id: "wipe-1", name: "
|
|
420
|
+
? assistant(fixture, [{ type: "toolCall", id: "wipe-1", name: "empty_brain", arguments: {} }], "toolUse")
|
|
421
421
|
: assistant(fixture, [{ type: "text", text: "resumed in a new window" }]),
|
|
422
422
|
});
|
|
423
423
|
try {
|
|
@@ -455,7 +455,7 @@ test("real AgentSession: manual command spans its tool batch and stops at settle
|
|
|
455
455
|
if (request === 1)
|
|
456
456
|
return assistant(fixture, [{ type: "text", text: "before manual reset" }]);
|
|
457
457
|
if (request === 2) {
|
|
458
|
-
assert.ok(text(context).includes(WARNING_JSON), "idle /
|
|
458
|
+
assert.ok(text(context).includes(WARNING_JSON), "idle /empty-brain sends the shared checkpoint prompt");
|
|
459
459
|
return assistant(fixture, [{ type: "toolCall", id: "manual-note", name: "notes_write", arguments: { address: "manual-a.md", content: "MANUAL_NOTE_ALPHA" } }], "toolUse");
|
|
460
460
|
}
|
|
461
461
|
assert.equal(request, 3, "the close-out turn finishes in the old window");
|
|
@@ -466,7 +466,7 @@ test("real AgentSession: manual command spans its tool batch and stops at settle
|
|
|
466
466
|
try {
|
|
467
467
|
await fixture.session.prompt("MANUAL_CLOSEOUT_OLD_SENTINEL");
|
|
468
468
|
await fixture.session.waitForIdle();
|
|
469
|
-
await fixture.session.prompt("/
|
|
469
|
+
await fixture.session.prompt("/empty-brain");
|
|
470
470
|
await fixture.session.waitForIdle();
|
|
471
471
|
assert.equal(fixture.requests.length, 3, "the run stops at settlement instead of continuing in the fresh window");
|
|
472
472
|
assert.equal(resetMarkers(fixture).length, 1);
|
|
@@ -495,7 +495,7 @@ test("real AgentSession: manual command spans its tool batch and stops at settle
|
|
|
495
495
|
}
|
|
496
496
|
});
|
|
497
497
|
test("real AgentSession: clear commands append a prompt after continuation and resume once", { timeout: 25000 }, async () => {
|
|
498
|
-
for (const mode of ["
|
|
498
|
+
for (const mode of ["empty-brain", "fresh-window", "hard-reserve", "overflow"]) {
|
|
499
499
|
let fixture;
|
|
500
500
|
const prompt = 'AFTER_CLEAR_PROMPT /cm "literal text"';
|
|
501
501
|
fixture = await openFixture({
|
|
@@ -520,7 +520,7 @@ test("real AgentSession: clear commands append a prompt after continuation and r
|
|
|
520
520
|
});
|
|
521
521
|
try {
|
|
522
522
|
await fixture.session.prompt("PROMPT_RESET_OLD_SENTINEL");
|
|
523
|
-
await fixture.session.prompt(`/${mode === "
|
|
523
|
+
await fixture.session.prompt(`/${mode === "empty-brain" ? "empty-brain" : "fresh-window"} ${prompt} `);
|
|
524
524
|
await fixture.session.waitForIdle();
|
|
525
525
|
assert.equal(fixture.requests.length, 3);
|
|
526
526
|
assert.equal(resetMarkers(fixture).length, 1);
|
|
@@ -584,7 +584,7 @@ test("real AgentSession: streaming clear prompt keeps the first request", { time
|
|
|
584
584
|
const running = fixture.session.prompt("streaming old work");
|
|
585
585
|
await ready;
|
|
586
586
|
await fixture.session.prompt("/fresh-window FIRST_RESET_PROMPT", { streamingBehavior: "steer" });
|
|
587
|
-
await fixture.session.prompt("/
|
|
587
|
+
await fixture.session.prompt("/empty-brain IGNORED_RESET_PROMPT", { streamingBehavior: "steer" });
|
|
588
588
|
release();
|
|
589
589
|
await running;
|
|
590
590
|
await fixture.session.waitForIdle();
|
|
@@ -610,13 +610,13 @@ test("real AgentSession: manual hard-reserve reset stops clean and mixed-tool tu
|
|
|
610
610
|
assert.equal(request, 2, "no provider work follows the manual safety reset");
|
|
611
611
|
return assistant(fixture, mixed ? [
|
|
612
612
|
{ type: "toolCall", id: "pressure-note", name: "notes_write", arguments: { address: "pressure.md", content: "PRESERVED_PRESSURE_NOTE" } },
|
|
613
|
-
{ type: "toolCall", id: "pressure-wipe", name: "
|
|
613
|
+
{ type: "toolCall", id: "pressure-wipe", name: "empty_brain", arguments: {} },
|
|
614
614
|
] : [{ type: "text", text: "close-out complete" }], mixed ? "toolUse" : "stop", { usage: usage(80_000) });
|
|
615
615
|
},
|
|
616
616
|
});
|
|
617
617
|
try {
|
|
618
618
|
await fixture.session.prompt("HARD_RESERVE_OLD_SENTINEL");
|
|
619
|
-
await fixture.session.prompt("/
|
|
619
|
+
await fixture.session.prompt("/empty-brain");
|
|
620
620
|
await fixture.session.waitForIdle();
|
|
621
621
|
assert.equal(fixture.requests.length, 2);
|
|
622
622
|
assert.equal(resetMarkers(fixture).length, 1, "the safety wipe is not repeated at settlement");
|
|
@@ -664,7 +664,7 @@ test("real AgentSession: manual safety reset answers queued user input once befo
|
|
|
664
664
|
});
|
|
665
665
|
try {
|
|
666
666
|
await fixture.session.prompt("QUEUED_SAFETY_OLD_SENTINEL");
|
|
667
|
-
await fixture.session.prompt("/
|
|
667
|
+
await fixture.session.prompt("/empty-brain");
|
|
668
668
|
await fixture.session.waitForIdle();
|
|
669
669
|
assert.equal(fixture.requests.length, 4, "queued input is answered once after Pi's tool follow-up, then the stop lands");
|
|
670
670
|
assert.equal(resetMarkers(fixture).length, 1);
|
|
@@ -687,7 +687,7 @@ test("real AgentSession: manual overflow wipes and stops even with automatic res
|
|
|
687
687
|
});
|
|
688
688
|
try {
|
|
689
689
|
await fixture.session.prompt("MANUAL_OVERFLOW_OLD_SENTINEL");
|
|
690
|
-
await fixture.session.prompt("/
|
|
690
|
+
await fixture.session.prompt("/empty-brain");
|
|
691
691
|
await fixture.session.waitForIdle();
|
|
692
692
|
assert.equal(fixture.requests.length, 2);
|
|
693
693
|
assert.equal(resetMarkers(fixture).length, 1);
|
|
@@ -698,7 +698,7 @@ test("real AgentSession: manual overflow wipes and stops even with automatic res
|
|
|
698
698
|
fixture.close();
|
|
699
699
|
}
|
|
700
700
|
});
|
|
701
|
-
test("real AgentSession: streaming /
|
|
701
|
+
test("real AgentSession: streaming /empty-brain steers a close-out and stops at settlement", { timeout: 20000 }, async () => {
|
|
702
702
|
let fixture;
|
|
703
703
|
let announceStarted;
|
|
704
704
|
let releaseResponse;
|
|
@@ -720,8 +720,8 @@ test("real AgentSession: streaming /neuralyze steers a close-out and stops at se
|
|
|
720
720
|
try {
|
|
721
721
|
const running = fixture.session.prompt("STREAMING_WIPE_OLD_SENTINEL");
|
|
722
722
|
await started;
|
|
723
|
-
await fixture.session.prompt("/
|
|
724
|
-
await fixture.session.prompt("/
|
|
723
|
+
await fixture.session.prompt("/empty-brain", { streamingBehavior: "steer" });
|
|
724
|
+
await fixture.session.prompt("/empty-brain", { streamingBehavior: "followUp" });
|
|
725
725
|
assert.equal(fixture.notices.filter((notice) => notice.includes("notes first, then it stops")).length, 1, "the user is notified once while output is ongoing");
|
|
726
726
|
assert.equal(resetMarkers(fixture).length, 0, "the ongoing turn is not interrupted");
|
|
727
727
|
releaseResponse();
|
|
@@ -755,9 +755,9 @@ test("real AgentSession: repeated manual commands share one pending window", { t
|
|
|
755
755
|
},
|
|
756
756
|
});
|
|
757
757
|
try {
|
|
758
|
-
const first = fixture.session.prompt("/
|
|
758
|
+
const first = fixture.session.prompt("/empty-brain");
|
|
759
759
|
await started;
|
|
760
|
-
const second = fixture.session.prompt("/
|
|
760
|
+
const second = fixture.session.prompt("/empty-brain");
|
|
761
761
|
releaseResponse();
|
|
762
762
|
await Promise.all([first, second]);
|
|
763
763
|
await fixture.session.waitForIdle();
|
|
@@ -834,7 +834,7 @@ test("real AgentSession: steering and follow-up queued during a manual reset are
|
|
|
834
834
|
},
|
|
835
835
|
});
|
|
836
836
|
try {
|
|
837
|
-
const command = fixture.session.prompt("/
|
|
837
|
+
const command = fixture.session.prompt("/empty-brain");
|
|
838
838
|
await started;
|
|
839
839
|
if (delivery === "steer")
|
|
840
840
|
fixture.session.steer("QUEUED_DURING_FALLBACK");
|
|
@@ -859,7 +859,7 @@ test("real AgentSession: a reset survives all notes-home read failures with an i
|
|
|
859
859
|
compactionEnabled: false,
|
|
860
860
|
notesRootFile: true,
|
|
861
861
|
script: (request) => request === 1
|
|
862
|
-
? assistant(fixture, [{ type: "toolCall", id: "wipe-notes-failure", name: "
|
|
862
|
+
? assistant(fixture, [{ type: "toolCall", id: "wipe-notes-failure", name: "empty_brain", arguments: {} }], "toolUse")
|
|
863
863
|
: assistant(fixture, [{ type: "text", text: "resumed despite notes failure" }]),
|
|
864
864
|
});
|
|
865
865
|
try {
|
|
@@ -903,7 +903,7 @@ test("real AgentSession: reset projection drops legacy message shapes but keeps
|
|
|
903
903
|
},
|
|
904
904
|
script: (request, context) => {
|
|
905
905
|
if (request === 1)
|
|
906
|
-
return assistant(fixture, [{ type: "toolCall", id: "wipe-legacy", name: "
|
|
906
|
+
return assistant(fixture, [{ type: "toolCall", id: "wipe-legacy", name: "empty_brain", arguments: {} }], "toolUse");
|
|
907
907
|
if (request === 2) {
|
|
908
908
|
const body = text(context);
|
|
909
909
|
for (const legacy of legacyTexts)
|
|
@@ -939,10 +939,10 @@ test("real AgentSession: successive resets and a mixed tool batch cut only after
|
|
|
939
939
|
compactionEnabled: false,
|
|
940
940
|
script: (request) => {
|
|
941
941
|
if (scenario === "successive" && request < 3)
|
|
942
|
-
return assistant(fixture, [{ type: "toolCall", id: `wipe-${request}`, name: "
|
|
942
|
+
return assistant(fixture, [{ type: "toolCall", id: `wipe-${request}`, name: "empty_brain", arguments: {} }], "toolUse");
|
|
943
943
|
if (scenario === "mixed" && request === 1)
|
|
944
944
|
return assistant(fixture, [
|
|
945
|
-
{ type: "toolCall", id: "wipe-1", name: "
|
|
945
|
+
{ type: "toolCall", id: "wipe-1", name: "empty_brain", arguments: {} },
|
|
946
946
|
{ type: "toolCall", id: "note-1", name: "notes_write", arguments: { address: "batch.md", content: "MIXED_BATCH_NOTE" } },
|
|
947
947
|
], "toolUse");
|
|
948
948
|
return assistant(fixture, [{ type: "text", text: "fresh completion" }]);
|
|
@@ -977,7 +977,7 @@ test("real AgentSession: two retain-none checkpoints survive session-file reopen
|
|
|
977
977
|
compactionEnabled: false,
|
|
978
978
|
sessionDir,
|
|
979
979
|
script: (request) => request < 3
|
|
980
|
-
? assistant(fixture, [{ type: "toolCall", id: `persisted-wipe-${request}`, name: "
|
|
980
|
+
? assistant(fixture, [{ type: "toolCall", id: `persisted-wipe-${request}`, name: "empty_brain", arguments: {} }], "toolUse")
|
|
981
981
|
: assistant(fixture, [{ type: "text", text: "second reset window complete" }]),
|
|
982
982
|
});
|
|
983
983
|
try {
|
|
@@ -1013,7 +1013,7 @@ test("real AgentSession: two retain-none checkpoints survive session-file reopen
|
|
|
1013
1013
|
assert.ok(canonical.some((message) => message.role === "compactionSummary"), "the accepted empty-summary wrapper survives reload");
|
|
1014
1014
|
const system = getCurrentSystemMessage(canonical);
|
|
1015
1015
|
assert.ok(JSON.stringify(system).includes("Use the tools as requested."), "the complete system prompt survives the checkpoint");
|
|
1016
|
-
assert.ok(system?.toolsAdded?.some((tool) => tool.name === "
|
|
1016
|
+
assert.ok(system?.toolsAdded?.some((tool) => tool.name === "empty_brain"), "the active tool loadout survives reopen");
|
|
1017
1017
|
const reopenedMarkers = branch.filter((entry) => entry.type === "custom" && entry.customType === RESET_MARKER_TYPE);
|
|
1018
1018
|
const latestMarker = reopenedMarkers.at(-1);
|
|
1019
1019
|
const previousMarker = reopenedMarkers[0];
|
|
@@ -1035,7 +1035,7 @@ test("real AgentSession: steering and follow-up are delivered exactly once in th
|
|
|
1035
1035
|
compactionEnabled: false,
|
|
1036
1036
|
hook: (pi, getSession) => {
|
|
1037
1037
|
pi.on("tool_call", async (event) => {
|
|
1038
|
-
if (event.toolName !== "
|
|
1038
|
+
if (event.toolName !== "empty_brain")
|
|
1039
1039
|
return;
|
|
1040
1040
|
if (deliverAs === "steer")
|
|
1041
1041
|
await getSession().steer("QUEUED_ONCE");
|
|
@@ -1044,7 +1044,7 @@ test("real AgentSession: steering and follow-up are delivered exactly once in th
|
|
|
1044
1044
|
});
|
|
1045
1045
|
},
|
|
1046
1046
|
script: (request) => request === 1
|
|
1047
|
-
? assistant(fixture, [{ type: "toolCall", id: "wipe-queue", name: "
|
|
1047
|
+
? assistant(fixture, [{ type: "toolCall", id: "wipe-queue", name: "empty_brain", arguments: {} }], "toolUse")
|
|
1048
1048
|
: assistant(fixture, [{ type: "text", text: "queued message handled" }]),
|
|
1049
1049
|
});
|
|
1050
1050
|
try {
|
|
@@ -1070,7 +1070,7 @@ test("real AgentSession: hidden or missing reset boots refuse to move the bounda
|
|
|
1070
1070
|
try {
|
|
1071
1071
|
await fixture.session.prompt("ROOT_BEFORE_HIDDEN_BOOT");
|
|
1072
1072
|
await fixture.session.waitForIdle();
|
|
1073
|
-
await fixture.session.prompt("/
|
|
1073
|
+
await fixture.session.prompt("/empty-brain");
|
|
1074
1074
|
await fixture.session.waitForIdle();
|
|
1075
1075
|
await fixture.session.prompt("VALID_POST_MARKER_WORK");
|
|
1076
1076
|
await fixture.session.waitForIdle();
|
|
@@ -1124,7 +1124,7 @@ test("real AgentSession: the complete system message and a changed tool loadout
|
|
|
1124
1124
|
fixture = await openFixture({
|
|
1125
1125
|
compactionEnabled: false,
|
|
1126
1126
|
systemPrompt: ["SYSTEM_SECTION_ALPHA", "SYSTEM_SECTION_BETA", "SYSTEM_TOOLS_SECTION", "SYSTEM_LOADOUT_SECTION"].join("\n"),
|
|
1127
|
-
tools: ["
|
|
1127
|
+
tools: ["empty_brain"],
|
|
1128
1128
|
script: (request, context) => {
|
|
1129
1129
|
const systemText = JSON.stringify(context.messages.filter((message) => message.role === "system"));
|
|
1130
1130
|
const currentSystem = getCurrentSystemMessage(context.messages);
|
|
@@ -1134,11 +1134,11 @@ test("real AgentSession: the complete system message and a changed tool loadout
|
|
|
1134
1134
|
assert.ok(systemText.includes("SYSTEM_TOOLS_SECTION"));
|
|
1135
1135
|
assert.ok(systemText.includes("SYSTEM_LOADOUT_SECTION"));
|
|
1136
1136
|
if (request === 1) {
|
|
1137
|
-
assert.deepEqual(effectiveToolNames, ["
|
|
1138
|
-
fixture.session.setActiveToolsByName(["
|
|
1139
|
-
return assistant(fixture, [{ type: "toolCall", id: "wipe-system", name: "
|
|
1137
|
+
assert.deepEqual(effectiveToolNames, ["empty_brain"]);
|
|
1138
|
+
fixture.session.setActiveToolsByName(["empty_brain", "get_context_remaining"]);
|
|
1139
|
+
return assistant(fixture, [{ type: "toolCall", id: "wipe-system", name: "empty_brain", arguments: {} }], "toolUse");
|
|
1140
1140
|
}
|
|
1141
|
-
assert.deepEqual(effectiveToolNames, ["
|
|
1141
|
+
assert.deepEqual(effectiveToolNames, ["empty_brain", "get_context_remaining"]);
|
|
1142
1142
|
assert.ok(JSON.stringify(context.messages).includes(CONTEXT_WINDOW_OPEN_TAG));
|
|
1143
1143
|
return assistant(fixture, [{ type: "text", text: "all system sections survived" }]);
|
|
1144
1144
|
},
|
|
@@ -1506,7 +1506,7 @@ test("real AgentSession: warning precedes a durable checkpoint, including failed
|
|
|
1506
1506
|
content: "CHECKPOINT_SENTINEL",
|
|
1507
1507
|
} }], "toolUse", { usage: usage(60_000) });
|
|
1508
1508
|
if (request === 4 && scenario !== "ignored-warning")
|
|
1509
|
-
return assistant(fixture, [{ type: "toolCall", id: "wipe-after-checkpoint", name: "
|
|
1509
|
+
return assistant(fixture, [{ type: "toolCall", id: "wipe-after-checkpoint", name: "empty_brain", arguments: {} }], "toolUse", { usage: usage(60_000) });
|
|
1510
1510
|
return assistant(fixture, [{ type: "text", text: scenario === "ignored-warning" ? "warning intentionally ignored" : "checkpoint and wipe complete" }], "stop", { usage: usage(60_000) });
|
|
1511
1511
|
},
|
|
1512
1512
|
});
|