notesoup 0.61.0 → 0.62.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.
Files changed (200) hide show
  1. package/.agents/plugins/marketplace.json +15 -0
  2. package/README.md +14 -11
  3. package/dist/plugins/antigravity/src/cli.d.ts +1 -0
  4. package/dist/plugins/antigravity/src/cli.js +23 -0
  5. package/dist/plugins/antigravity/src/hooks.d.ts +18 -0
  6. package/dist/plugins/antigravity/src/hooks.js +53 -0
  7. package/dist/plugins/antigravity/src/identity.d.ts +26 -0
  8. package/dist/plugins/antigravity/src/identity.js +129 -0
  9. package/dist/plugins/claude/src/helper.js +2 -1
  10. package/dist/plugins/codex/src/hooks.js +1 -0
  11. package/dist/plugins/codex/src/identity.d.ts +6 -1
  12. package/dist/plugins/codex/src/identity.js +13 -1
  13. package/dist/plugins/codex/src/mcp.d.ts +35 -7
  14. package/dist/plugins/codex/src/mcp.js +26 -88
  15. package/dist/plugins/codex/src/text.js +3 -3
  16. package/dist/plugins/dsh/tools.js +8 -4
  17. package/dist/plugins/mcp/operations.d.ts +15 -0
  18. package/dist/plugins/mcp/operations.js +43 -0
  19. package/dist/plugins/mcp/server.d.ts +14 -0
  20. package/dist/plugins/mcp/server.js +13 -0
  21. package/dist/plugins/pi/budget.d.ts +1 -1
  22. package/dist/plugins/pi/budget.js +3 -2
  23. package/dist/plugins/pi/entries.d.ts +1 -0
  24. package/dist/plugins/pi/entries.js +1 -0
  25. package/dist/plugins/pi/history-tools.js +2 -1
  26. package/dist/plugins/pi/history.js +18 -1
  27. package/dist/plugins/pi/notes/tools.js +7 -3
  28. package/dist/plugins/pi/render.d.ts +7 -1
  29. package/dist/plugins/pi/render.js +2 -2
  30. package/dist/plugins/pi/reset/lifecycle.d.ts +1 -1
  31. package/dist/plugins/pi/reset/lifecycle.js +8 -9
  32. package/dist/plugins/pi/runtime.js +102 -61
  33. package/dist/plugins/pi/tool-result.js +7 -7
  34. package/dist/plugins/pi/window.d.ts +33 -3
  35. package/dist/plugins/pi/window.js +209 -9
  36. package/dist/src/boot/render.js +18 -15
  37. package/dist/src/boot/text.d.ts +3 -1
  38. package/dist/src/boot/text.js +22 -20
  39. package/dist/src/budget/text.d.ts +2 -2
  40. package/dist/src/budget/text.js +13 -13
  41. package/dist/src/history/claude.d.ts +2 -0
  42. package/dist/src/history/claude.js +46 -0
  43. package/dist/src/history/codex-transcript.js +7 -5
  44. package/dist/src/history/codex.js +3 -0
  45. package/dist/src/history/corpus.d.ts +28 -1
  46. package/dist/src/history/corpus.js +40 -0
  47. package/dist/src/history/history.d.ts +37 -46
  48. package/dist/src/history/history.js +21 -40
  49. package/dist/src/history/local.js +67 -32
  50. package/dist/src/history/pi.d.ts +2 -1
  51. package/dist/src/history/pi.js +122 -48
  52. package/dist/src/history/prefilter.js +76 -19
  53. package/dist/src/history/query.d.ts +28 -49
  54. package/dist/src/history/query.js +83 -68
  55. package/dist/src/history/summary-cache.d.ts +8 -1
  56. package/dist/src/history/summary-cache.js +138 -12
  57. package/dist/src/index.d.ts +1 -1
  58. package/dist/src/index.js +1 -1
  59. package/dist/src/notes/errors.d.ts +1 -1
  60. package/dist/src/notes/frontmatter.d.ts +0 -2
  61. package/dist/src/notes/frontmatter.js +0 -2
  62. package/dist/src/notes/index.d.ts +1 -1
  63. package/dist/src/notes/index.js +1 -1
  64. package/dist/src/notes/policy.d.ts +15 -1
  65. package/dist/src/notes/policy.js +46 -5
  66. package/dist/src/notes/store.d.ts +12 -0
  67. package/dist/src/notes/store.js +16 -20
  68. package/dist/src/text-match.d.ts +10 -1
  69. package/dist/src/text-match.js +42 -3
  70. package/dist/src/tools/dream.d.ts +22 -93
  71. package/dist/src/tools/dream.js +30 -27
  72. package/dist/src/tools/history.d.ts +33 -26
  73. package/dist/src/tools/history.js +257 -163
  74. package/dist/src/tools/notes.d.ts +51 -163
  75. package/dist/src/tools/notes.js +146 -100
  76. package/dist/src/tools/output.d.ts +2 -1
  77. package/dist/src/tools/output.js +2 -1
  78. package/dist/src/tools/result.d.ts +4 -7
  79. package/dist/src/tools/result.js +8 -9
  80. package/dist/src/tools/schema.d.ts +4 -1
  81. package/dist/src/tools/schema.js +25 -1
  82. package/dist/test/agent-loop.test.js +198 -16
  83. package/dist/test/antigravity-live.test.d.ts +1 -0
  84. package/dist/test/antigravity-live.test.js +142 -0
  85. package/dist/test/antigravity-plugin.test.d.ts +1 -0
  86. package/dist/test/antigravity-plugin.test.js +101 -0
  87. package/dist/test/boot.integration.test.js +133 -14
  88. package/dist/test/claude-history.test.js +14 -13
  89. package/dist/test/claude-mod.test.js +9 -6
  90. package/dist/test/codex-history.test.js +15 -3
  91. package/dist/test/codex-plugin.test.js +76 -38
  92. package/dist/test/dependencies.test.js +7 -3
  93. package/dist/test/dream-skill.test.js +3 -3
  94. package/dist/test/dream-tools.test.js +101 -56
  95. package/dist/test/dsh.test.js +34 -19
  96. package/dist/test/helpers/dependency-graph.js +2 -2
  97. package/dist/test/helpers/extension.d.ts +65 -2
  98. package/dist/test/helpers/extension.js +72 -3
  99. package/dist/test/history-corpus.test.js +79 -77
  100. package/dist/test/history-summary-cache.test.js +97 -9
  101. package/dist/test/history.integration.test.js +234 -168
  102. package/dist/test/host-neutral.test.js +69 -19
  103. package/dist/test/marker.test.js +1 -1
  104. package/dist/test/note-policy.test.js +96 -77
  105. package/dist/test/notes.integration.test.js +212 -94
  106. package/dist/test/notes.test.js +184 -113
  107. package/dist/test/pi-render.test.js +20 -12
  108. package/dist/test/project-namespace.test.js +3 -2
  109. package/dist/test/reset-lifecycle.test.js +2 -2
  110. package/docs/antigravity.md +44 -0
  111. package/docs/architecture.md +6 -4
  112. package/docs/claude-code-mod.md +2 -2
  113. package/docs/codex.md +36 -38
  114. package/docs/dsh.md +3 -3
  115. package/docs/history-sessions.md +28 -50
  116. package/docs/notes-library.md +4 -4
  117. package/docs/skills.md +3 -3
  118. package/docs/tool-results.md +47 -28
  119. package/package.json +3 -2
  120. package/playbook.md +1 -1
  121. package/plugins/antigravity/dist/antigravity/notesoup.js +26886 -0
  122. package/plugins/antigravity/hooks.json +7 -0
  123. package/plugins/antigravity/mcp_config.json +8 -0
  124. package/plugins/antigravity/plugin.json +6 -0
  125. package/plugins/antigravity/src/cli.ts +22 -0
  126. package/plugins/antigravity/src/hooks.ts +51 -0
  127. package/plugins/antigravity/src/identity.ts +127 -0
  128. package/plugins/claude/.claude-plugin/plugin.json +1 -1
  129. package/plugins/claude/dist/claude/helper.js +1059 -534
  130. package/plugins/claude/hooks/register.ts +2 -2
  131. package/plugins/claude/playbook.md +1 -1
  132. package/plugins/claude/skills/dream/SKILL.md +1 -1
  133. package/plugins/claude/skills/notesoup/SKILL.md +92 -0
  134. package/plugins/claude/src/helper.ts +2 -1
  135. package/plugins/codex/.codex-plugin/plugin.json +8 -0
  136. package/plugins/codex/.mcp.json +11 -0
  137. package/plugins/codex/README.md +5 -21
  138. package/plugins/codex/dist/codex/notesoup.js +18480 -17946
  139. package/plugins/codex/src/hooks.ts +1 -0
  140. package/plugins/codex/src/identity.ts +14 -1
  141. package/plugins/codex/src/mcp.ts +28 -98
  142. package/plugins/codex/src/text.ts +3 -3
  143. package/plugins/dsh/tools.ts +8 -4
  144. package/plugins/mcp/operations.ts +50 -0
  145. package/plugins/mcp/server.ts +23 -0
  146. package/plugins/paseo/README.md +5 -10
  147. package/plugins/paseo/client/brain-empty-card.tsx +3 -3
  148. package/plugins/paseo/client/markdown.tsx +50 -38
  149. package/plugins/paseo/client/notes-op-card.tsx +12 -9
  150. package/plugins/paseo/client/paper-card.tsx +6 -5
  151. package/plugins/paseo/client/paper-palette.ts +2 -9
  152. package/plugins/paseo/client/sticky-card.tsx +2 -2
  153. package/plugins/paseo/client/tool-result.ts +7 -14
  154. package/plugins/paseo/package-lock.json +3406 -0
  155. package/plugins/paseo/package.json +1 -0
  156. package/plugins/paseo/test/markdown-core.test.ts +73 -66
  157. package/plugins/pi/budget.ts +3 -3
  158. package/plugins/pi/entries.ts +1 -0
  159. package/plugins/pi/history-tools.ts +2 -1
  160. package/plugins/pi/history.ts +30 -1
  161. package/plugins/pi/notes/tools.ts +7 -3
  162. package/plugins/pi/render.ts +6 -6
  163. package/plugins/pi/reset/lifecycle.ts +9 -10
  164. package/plugins/pi/runtime.ts +96 -60
  165. package/plugins/pi/tool-result.ts +8 -8
  166. package/plugins/pi/window.ts +198 -9
  167. package/skills/dream/SKILL.md +1 -1
  168. package/skills/notesoup/SKILL.md +92 -0
  169. package/src/boot/render.ts +18 -15
  170. package/src/boot/text.ts +23 -19
  171. package/src/budget/text.ts +13 -13
  172. package/src/history/claude.ts +41 -0
  173. package/src/history/codex-transcript.ts +6 -4
  174. package/src/history/codex.ts +2 -0
  175. package/src/history/corpus.ts +51 -2
  176. package/src/history/history.ts +35 -44
  177. package/src/history/local.ts +67 -27
  178. package/src/history/pi.ts +113 -35
  179. package/src/history/prefilter.ts +73 -15
  180. package/src/history/query.ts +93 -73
  181. package/src/history/summary-cache.ts +142 -17
  182. package/src/index.ts +1 -1
  183. package/src/notes/errors.ts +1 -1
  184. package/src/notes/frontmatter.ts +0 -3
  185. package/src/notes/index.ts +1 -1
  186. package/src/notes/policy.ts +44 -5
  187. package/src/notes/store.ts +17 -20
  188. package/src/text-match.ts +46 -4
  189. package/src/tools/dream.ts +29 -31
  190. package/src/tools/history.ts +249 -142
  191. package/src/tools/notes.ts +145 -113
  192. package/src/tools/output.ts +2 -1
  193. package/src/tools/result.ts +12 -11
  194. package/src/tools/schema.ts +24 -1
  195. package/plugins/claude/skills/memory/SKILL.md +0 -69
  196. package/plugins/codex/mcp.json +0 -10
  197. package/plugins/codex/plugin.json +0 -6
  198. package/plugins/paseo/client/markdown-core.tsx +0 -189
  199. package/plugins/paseo/client/typography.ts +0 -24
  200. package/skills/memory/SKILL.md +0 -69
@@ -107,12 +107,31 @@ export function manager(persisted = false) {
107
107
  const dir = mkdtempSync(join(tmpdir(), "notesoup-session-"));
108
108
  return SessionManager.create("/private/tmp/notesoup-test", dir);
109
109
  }
110
- export function makeExtension(sessionManager, settingsManager) {
111
- const captured = { tools: new Map(), handlers: new Map(), commands: new Map(), sent: [], contextMessages: [], flags: [] };
110
+ export function makeExtension(sessionManager, settingsManager, options = {}) {
111
+ const listeners = new Map();
112
+ const events = {
113
+ on(channel, handler) {
114
+ const handlers = listeners.get(channel) ?? new Set();
115
+ handlers.add(handler);
116
+ listeners.set(channel, handlers);
117
+ return () => { handlers.delete(handler); };
118
+ },
119
+ emit(channel, data) {
120
+ for (const handler of listeners.get(channel) ?? [])
121
+ handler(data);
122
+ },
123
+ };
124
+ const captured = {
125
+ tools: new Map(), handlers: new Map(), commands: new Map(), sent: [],
126
+ contextMessages: [], flags: [], flagValues: new Map(Object.entries(options.flags ?? {})), events,
127
+ };
112
128
  const api = {
113
129
  registerFlag(name) {
114
130
  captured.flags.push(name);
115
131
  },
132
+ getFlag(name) {
133
+ return captured.flagValues.get(name);
134
+ },
116
135
  registerTool(tool) {
117
136
  captured.tools.set(tool.name, tool);
118
137
  },
@@ -127,6 +146,7 @@ export function makeExtension(sessionManager, settingsManager) {
127
146
  appendEntry(customType, data) {
128
147
  sessionManager.appendCustomEntry(customType, data);
129
148
  },
149
+ events,
130
150
  sendMessage(message, options) {
131
151
  captured.sent.push({ message, options });
132
152
  sessionManager.appendCustomMessageEntry(message.customType, message.content, message.display, message.details);
@@ -271,7 +291,25 @@ function isTextWindow(value) {
271
291
  return typeof candidate.text === "string" && typeof candidate.total_chars === "number" &&
272
292
  (candidate.next_offset_chars === null || typeof candidate.next_offset_chars === "number");
273
293
  }
274
- /** Data of a successful outcome, asserting both the structured success and the non-error result. */
294
+ /** Plain-text operation success, with no structured wire payload. */
295
+ export function resultText(result) {
296
+ assert.ok(!result.isError, "expected a successful result");
297
+ assert.equal(result.structuredContent, undefined, "plain-text result has no structured payload");
298
+ const first = result.content[0];
299
+ assert.ok(first && first.type === "text", "tool result carries text");
300
+ return first.text;
301
+ }
302
+ /** Plain-text operation refusal, preserving its error code and message. */
303
+ export function resultTextError(result) {
304
+ assert.equal(result.isError, true, "expected a refusal");
305
+ assert.equal(result.structuredContent, undefined, "plain-text refusal has no structured payload");
306
+ const first = result.content[0];
307
+ assert.ok(first && first.type === "text", "tool result carries text");
308
+ const match = /^error: ([^:]+): ([\s\S]*)$/.exec(first.text);
309
+ assert.ok(match, "refusal carries a code and message");
310
+ return { code: match[1], message: match[2] };
311
+ }
312
+ /** Data of a successful notes_read outcome, asserting both the structured success and the non-error result. */
275
313
  export function resultData(result) {
276
314
  const outcome = outcomeOf(result);
277
315
  assert.equal("error" in outcome, false, `expected success, got refusal ${JSON.stringify(outcome)}`);
@@ -334,6 +372,37 @@ export async function runHandlers(captured, name, event, ctx) {
334
372
  ctx.isIdle = isIdle;
335
373
  }
336
374
  }
375
+ /** Run every registered input handler in order, as Pi does before appending the prompt. */
376
+ export async function runInput(captured, ctx, event = { type: "input", text: "hello", source: "interactive" }) {
377
+ for (const handler of captured.handlers.get("input") ?? [])
378
+ await handler(event, ctx);
379
+ }
380
+ /** Run before_agent_start with an event shaped like Pi's, returning the handler's result and the mutated event. */
381
+ export async function runBeforeAgentStart(captured, ctx, options = {}) {
382
+ const skills = (options.skills ?? []).map((skill) => ({
383
+ name: skill.name,
384
+ description: `${skill.name} skill`,
385
+ filePath: skill.filePath,
386
+ baseDir: dirname(skill.filePath),
387
+ sourceInfo: {},
388
+ disableModelInvocation: false,
389
+ }));
390
+ const event = {
391
+ type: "before_agent_start",
392
+ messageType: options.messageType ?? "user",
393
+ prompt: "hello",
394
+ ...(options.message ? { message: { role: "custom", content: "custom", display: false, timestamp: 0, ...options.message } } : {}),
395
+ systemPrompt: "",
396
+ systemPromptOptions: { sections: {}, skills },
397
+ };
398
+ let result;
399
+ for (const handler of captured.handlers.get("before_agent_start") ?? []) {
400
+ const returned = (await handler(event, ctx));
401
+ if (returned)
402
+ result = returned;
403
+ }
404
+ return { event, result };
405
+ }
337
406
  export async function runCommand(captured, name, args, ctx) {
338
407
  const command = captured.commands.get(name);
339
408
  assert.ok(command, `${name} command registered`);
@@ -11,7 +11,7 @@ import { parseSessionSelector } from "../src/history/corpus.js";
11
11
  import { allItems, projectHistory } from "../src/history/history.js";
12
12
  import { claudeHistoryFromJsonl, offlineClaudeHead, offlineClaudeHistoryFromJsonl } from "../src/history/claude.js";
13
13
  import { piHistoryFromJsonl } from "../src/history/pi.js";
14
- import { historyList, historyRead } from "../src/tools/history.js";
14
+ import { historyList, historySearch, historyRead } from "../src/tools/history.js";
15
15
  import { TOOL_OUTPUT_MAX_BYTES } from "../src/tools/output.js";
16
16
  const AT = "2026-10-06T01:02:03.000Z";
17
17
  const CODEX = "019a0000-0000-7000-8000-000000000001";
@@ -60,15 +60,14 @@ async function fixture(t) {
60
60
  return { home, roots, put, ctx, corpus, piPath, claudePath, codexPath, codexText };
61
61
  }
62
62
  test("session schemas are optional and non-empty, while the current projection keeps its exact wire shape", async () => {
63
- for (const operation of [historyList, historyRead]) {
64
- const params = operation === historyRead ? { seq: 1 } : {};
63
+ for (const operation of [historyList, historySearch, historyRead]) {
64
+ const params = operation === historyRead ? { seq: 1 } : operation === historySearch ? { query: "needle" } : {};
65
65
  assert.equal(Check(operation.parameters, params), true);
66
66
  assert.equal(Check(operation.parameters, { ...params, session: "" }), false);
67
67
  assert.equal(Check(operation.parameters, { ...params, session: "claude:a" }), true);
68
68
  }
69
69
  const p = projection();
70
70
  const page = await historyList.execute({ limit: 1 }, p);
71
- assert.ok(Check(historyList.outputSchema, page.ok ? page.data : page));
72
71
  assert.equal("session" in data(page).items[0], false);
73
72
  assert.equal(data(page).has_older, true);
74
73
  assert.match(historyList.render(page), /^seq 5 \| user/);
@@ -112,25 +111,24 @@ test("all single-session recipes preserve the resolved identity, including folde
112
111
  { seq: 4, windowId: "w", role: "assistant", text: "last" },
113
112
  ] }], 4, new Set([1, 2, 3, 4]));
114
113
  const ctx = context([descriptor("claude", "target-session", p)]);
115
- const page = await historyList.execute({ session: "claude:target", limit: 1, before: 5 }, ctx);
114
+ const filters = { roles: ["user", "assistant"], limit: 1, max_chars_per_item: 3 };
115
+ const page = await historyList.execute({ session: "claude:target", before: 5, ...filters }, ctx);
116
116
  assert.equal(data(page).has_older, true);
117
- assert.match(historyList.render(page), /→ older: \{"session":"claude:target-session","before":4\}/);
118
- const first = await historyList.execute({ session: "target", after: 0, limit: 1 }, ctx);
117
+ assert.deepEqual(JSON.parse(/→ older: (\{[^}]+\})/.exec(historyList.render(page))[1]), { session: "claude:target-session", ...filters, before: 4 });
118
+ const first = await historyList.execute({ session: "target", after: 0, before: 5, ...filters }, ctx);
119
119
  assert.equal(data(first).has_newer, true);
120
- assert.match(historyList.render(first), /→ newer: \{"session":"claude:target-session","after":1\}/);
120
+ assert.deepEqual(JSON.parse(/→ newer: (\{[^}]+\})/.exec(historyList.render(first))[1]), { session: "claude:target-session", ...filters, after: 1 });
121
121
  const foldPage = await historyList.execute({ session: "target", limit: 3 }, ctx);
122
122
  const expand = /→ expand: (\{[^\n]+\})/.exec(historyList.render(foldPage));
123
123
  assert.ok(expand);
124
124
  const recipe = JSON.parse(expand[1]);
125
125
  assert.equal(recipe.session, "claude:target-session");
126
126
  assert.deepEqual(data(await historyList.execute(recipe, ctx)).items.map((item) => item.seq), [2]);
127
- assert.match(historyList.render(foldPage), /session claude:target-session \| seq 1 \| user/);
127
+ assert.match(historyList.render(foldPage), /=== session claude:target-session ===\nseq 1 \| user/);
128
128
  const read = await historyRead.execute({ session: "target", seq: 3 }, ctx);
129
129
  assert.equal(data(read).session, "claude:target-session");
130
130
  assert.match(historyRead.render(read), /^session claude:target-session \| seq 3 \| user/);
131
- assert.match(historyRead.render(read), /neighborhood.*"session":"claude:target-session"/);
132
- assert.ok(Check(historyRead.outputSchema, data(read)));
133
- assert.ok(Check(historyList.outputSchema, data(foldPage)));
131
+ assert.match(historyRead.render(read), /→ history_list: .*"session":"claude:target-session"/);
134
132
  });
135
133
  test("recipes expand a fold at seq 1 and read its neighborhood from the start", async () => {
136
134
  const p = projectHistory([{ windowId: "w", items: [
@@ -139,7 +137,8 @@ test("recipes expand a fold at seq 1 and read its neighborhood from the start",
139
137
  { seq: 3, windowId: "w", role: "user", text: "hello" },
140
138
  ] }], 3, new Set([1, 2, 3]));
141
139
  const ctx = context([descriptor("claude", "first-fold", p)]);
142
- const folded = await historyList.execute({ session: "first-fold" }, ctx);
140
+ const folded = await historyList.execute({ session: "first-fold", before: 3 }, ctx);
141
+ assert.match(historyList.render(folded), /^=== session claude:first-fold ===\nseqs 1-2/);
143
142
  const expand = /→ expand: (\{[^\n]+\})/.exec(historyList.render(folded));
144
143
  assert.ok(expand);
145
144
  const recipe = JSON.parse(expand[1]);
@@ -147,17 +146,21 @@ test("recipes expand a fold at seq 1 and read its neighborhood from the start",
147
146
  assert.ok(Check(historyList.parameters, recipe));
148
147
  assert.deepEqual(data(await historyList.execute(recipe, ctx)).items.map((item) => item.seq), [1, 2]);
149
148
  const read = await historyRead.execute({ session: "first-fold", seq: 3 }, ctx);
150
- const neighborhood = /neighborhood → `history_list`\((\{[^\n]+\})\)/.exec(historyRead.render(read));
149
+ const neighborhood = /→ history_list: (\{[^\n]+\})/.exec(historyRead.render(read));
151
150
  assert.ok(neighborhood);
152
151
  const nearby = JSON.parse(neighborhood[1]);
153
152
  assert.equal(nearby.after, 0);
154
153
  assert.ok(Check(historyList.parameters, nearby));
155
154
  assert.ok(data(await historyList.execute(nearby, ctx)).items.length > 0);
156
155
  });
157
- test("wildcard refusals precede discovery, and read accepts no wildcard selector", async () => {
156
+ test("bounds and wildcard refusals precede discovery, and read accepts no wildcard selector", async () => {
158
157
  const ctx = { current: () => { throw new Error("must not load current"); }, corpus: { currentHarness: "pi", sessions: async () => { throw new Error("must not discover"); } } };
159
- assert.match(refusal(await historyList.execute({ session: "pi:*", query: "needle", after: "3" }, ctx), "invalid_bounds"), /requires times/);
158
+ refusal(await historyList.execute({ session: "pi:*", after: 1 }, ctx), "invalid_bounds");
159
+ refusal(await historyList.execute({ session: "pi:*", before: 5 }, ctx), "invalid_bounds");
160
+ refusal(await historyList.execute({ session: "pi:*", since: "3" }, ctx), "invalid_bounds");
160
161
  refusal(await historyRead.execute({ session: "*", seq: 1 }, ctx), "invalid_session");
162
+ refusal(await historySearch.execute({ session: "*", query: "needle", since: "3" }, ctx), "invalid_bounds");
163
+ assert.deepEqual(data(await historySearch.execute({ session: "*", query: "" }, ctx)), { items: [], has_older: false, has_newer: false });
161
164
  });
162
165
  test("native filesystem discovery decodes three harnesses, compressed Codex, and keeps source bytes/mtime unchanged", async (t) => {
163
166
  const f = await fixture(t);
@@ -183,30 +186,31 @@ test("native filesystem discovery decodes three harnesses, compressed Codex, and
183
186
  });
184
187
  test("wildcard query merges every role chronologically, limits from either end, and returns no folds/cursors", async (t) => {
185
188
  const { ctx } = await fixture(t);
186
- const result = await historyList.execute({ session: "*", query: ["", "nEeDlE"], limit: 20 }, ctx);
189
+ const result = await historySearch.execute({ session: "*", query: ["", "nEeDlE"], limit: 20 }, ctx);
187
190
  const page = data(result);
188
191
  assert.deepEqual(page.items.map((item) => "role" in item ? [item.session, item.seq, item.role] : null), [
189
192
  ["pi:pi-one", 1, "user"], ["claude:claude-one", 1, "user"], ["pi:pi-one", 3, "tool"], ["claude:claude-one", 2, "context"], [`codex:${CODEX}`, 2, "assistant"],
190
193
  ]);
191
194
  assert.equal(page.has_older, false);
192
195
  assert.equal(page.has_newer, false);
193
- const newestResult = await historyList.execute({ session: "*", query: "needle", limit: 2 }, ctx);
196
+ const newestResult = await historySearch.execute({ session: "*", query: "needle", limit: 2 }, ctx);
194
197
  const newest = data(newestResult);
195
198
  assert.deepEqual(newest.items, page.items.slice(-2));
196
199
  assert.equal(newest.has_older, true);
197
200
  assert.equal(newest.has_newer, false);
198
- const oldestResult = await historyList.execute({ session: "*", query: "needle", limit: 2, after: "2026-10-06" }, ctx);
201
+ const oldestResult = await historySearch.execute({ session: "*", query: "needle", limit: 2, since: "2026-10-06" }, ctx);
199
202
  const oldest = data(oldestResult);
200
203
  assert.deepEqual(oldest.items, page.items.slice(0, 2));
201
204
  assert.equal(oldest.has_older, false);
202
205
  assert.equal(oldest.has_newer, true);
203
- const filtered = data(await historyList.execute({ session: "*", query: "needle", roles: ["tool", "context"], after: "2026-10-06T01:02:04", before: "2026-10-06T01:02:07Z" }, ctx));
206
+ const filtered = data(await historySearch.execute({ session: "*", query: "needle", roles: ["tool", "context"], since: "2026-10-06T01:02:04", until: "2026-10-06T01:02:07Z" }, ctx));
204
207
  assert.deepEqual(filtered.items.map((item) => item.role), ["tool"]);
205
- const harness = data(await historyList.execute({ session: "claude:*", query: "needle" }, ctx));
208
+ const harness = data(await historySearch.execute({ session: "claude:*", query: "needle" }, ctx));
206
209
  assert.ok(harness.items.every((item) => "session" in item && item.session === "claude:claude-one"));
207
- assert.equal(data(await historyList.execute({ session: "pi:absent*", query: "needle" }, ctx)).items.length, 0);
208
- assert.ok(Check(historyList.outputSchema, page));
209
- assert.match(historyList.render(result), /session pi:pi-one \| seq 1 \| user/);
210
+ assert.equal(data(await historySearch.execute({ session: "pi:absent*", query: "needle" }, ctx)).items.length, 0);
211
+ const text = historySearch.render(result);
212
+ assert.deepEqual([...text.matchAll(/^=== session (.+) ===$/gm)].map(match => match[1]), ["pi:pi-one", "claude:claude-one", `codex:${CODEX}`]);
213
+ assert.match(text, /=== session pi:pi-one ===\nseq 1 \| user[\s\S]*?\nseq 3 \| tool[\s\S]*?\n=== session claude:claude-one ===/);
210
214
  });
211
215
  test("bounded wildcard search scans every session and orders untimed and tied matches", async () => {
212
216
  const seen = [];
@@ -223,23 +227,23 @@ test("bounded wildcard search scans every session and orders untimed and tied ma
223
227
  }));
224
228
  const ctx = context(sessions);
225
229
  const ids = (page) => page.items.map((item) => "seq" in item ? [item.session, item.seq] : null);
226
- assert.deepEqual(ids(data(await historyList.execute({ session: "*", query: "needle", after: "2026-10-06", limit: 3 }, ctx))), [["pi:a", 3], ["pi:a", 4], ["pi:a", 5]]);
230
+ assert.deepEqual(ids(data(await historySearch.execute({ session: "*", query: "needle", since: "2026-10-06", limit: 3 }, ctx))), [["pi:a", 3], ["pi:a", 4], ["pi:a", 5]]);
227
231
  assert.deepEqual(seen, ["z", "a", "m"]);
228
232
  seen.length = 0;
229
- assert.deepEqual(ids(data(await historyList.execute({ session: "*", query: "needle", limit: 3 }, ctx))), [["pi:z", 198], ["pi:z", 199], ["pi:z", 200]]);
233
+ assert.deepEqual(ids(data(await historySearch.execute({ session: "*", query: "needle", limit: 3 }, ctx))), [["pi:z", 198], ["pi:z", 199], ["pi:z", 200]]);
230
234
  assert.deepEqual(seen, ["z", "a", "m"]);
231
235
  });
232
- test("query-less wildcards browse recent sessions, normalize empty queries, and keep canonical IDs", async (t) => {
236
+ test("wildcard history_list browses recent sessions, keeps canonical IDs, and history_search returns empty for empty queries", async (t) => {
233
237
  const { ctx } = await fixture(t);
234
- for (const query of [undefined, "", [], ["", ""]]) {
235
- const result = await historyList.execute({ session: "*", query }, ctx);
236
- const page = data(result);
237
- assert.deepEqual(page.items.map((item) => "seq" in item ? [item.session, item.seq, item.role] : null), [
238
- ["pi:pi-one", 1, "user"], ["claude:claude-one", 1, "user"], ["pi:current", 1, "user"], [`codex:${CODEX}`, 2, "assistant"],
239
- ]);
240
- assert.equal(page.has_older, false);
241
- assert.equal(page.has_newer, false);
242
- assert.ok(Check(historyList.outputSchema, page));
238
+ const result = await historyList.execute({ session: "*" }, ctx);
239
+ const page = data(result);
240
+ assert.deepEqual(page.items.map((item) => "seq" in item ? [item.session, item.seq, item.role] : null), [
241
+ ["pi:pi-one", 1, "user"], ["claude:claude-one", 1, "user"], ["pi:current", 1, "user"], [`codex:${CODEX}`, 2, "assistant"],
242
+ ]);
243
+ assert.equal(page.has_older, false);
244
+ assert.equal(page.has_newer, false);
245
+ for (const query of ["", [], ["", ""]]) {
246
+ assert.deepEqual(data(await historySearch.execute({ session: "*", query }, ctx)), { items: [], has_older: false, has_newer: false });
243
247
  }
244
248
  const harness = data(await historyList.execute({ session: "claude:*" }, ctx));
245
249
  assert.deepEqual(harness.items.map((item) => item.session), ["claude:claude-one"]);
@@ -265,7 +269,7 @@ test("session overviews order discovery by mtime, stop at the session limit, the
265
269
  assert.deepEqual(loaded, Array.from({ length: 20 }, (_, index) => 24 - index));
266
270
  assert.deepEqual(recent.items.map((item) => item.session), loaded.map((index) => `pi:s-${index}`));
267
271
  loaded.length = 0;
268
- const oldest = data(await historyList.execute({ session: "*", after: AT, limit: 2 }, ctx));
272
+ const oldest = data(await historyList.execute({ session: "*", since: AT, limit: 2 }, ctx));
269
273
  assert.equal(oldest.has_older, false);
270
274
  assert.equal(oldest.has_newer, true);
271
275
  assert.deepEqual(loaded, [0, 1]);
@@ -295,11 +299,11 @@ test("session representatives respect visibility, role/time filters, opening use
295
299
  assert.deepEqual(await chosen({ roles: ["context", "tool"] }), [8]);
296
300
  assert.deepEqual(await chosen({ roles: ["tool"] }), [6]);
297
301
  assert.deepEqual(await chosen({ roles: [] }), []);
298
- assert.deepEqual(await chosen({ after: at(1), before: at(3) }), [4]);
299
- assert.deepEqual(await chosen({ after: at(2) }), [5]);
300
- assert.deepEqual(await chosen({ before: at(1) }), [1]);
301
- assert.deepEqual(await chosen({ after: at(4) }), [8]);
302
- assert.deepEqual(await chosen({ after: at(4), roles: ["user"] }), []);
302
+ assert.deepEqual(await chosen({ since: at(1), until: at(3) }), [4]);
303
+ assert.deepEqual(await chosen({ since: at(2) }), [5]);
304
+ assert.deepEqual(await chosen({ until: at(1) }), [1]);
305
+ assert.deepEqual(await chosen({ since: at(4) }), [8]);
306
+ assert.deepEqual(await chosen({ since: at(4), roles: ["user"] }), []);
303
307
  const noUsers = { ...p, windows: p.windows.map((window) => ({ ...window, items: window.items.filter((item) => item.role !== "user") })) };
304
308
  const fallback = data(await historyList.execute({ session: "*" }, context([descriptor("pi", "assistant-topic", noUsers)])));
305
309
  assert.deepEqual(fallback.items.map((item) => "seq" in item ? item.seq : null), [4]);
@@ -325,7 +329,7 @@ test("wildcard queries reach lazy loaders and pre-filtered misses are not errors
325
329
  { ...descriptor("pi", "broken"), async load(queries) { seen.push(queries); throw new Error("unsupported"); } },
326
330
  { ...descriptor("claude", "hit"), async load(queries) { seen.push(queries); return { projection: projection("other") }; } },
327
331
  ]);
328
- const page = data(await historyList.execute({ session: "*", query: ["", "needle", "other"] }, ctx));
332
+ const page = data(await historySearch.execute({ session: "*", query: ["", "needle", "other"] }, ctx));
329
333
  assert.equal(page.items.length, 5);
330
334
  assert.ok(page.items.every((item) => item.session === "claude:hit"));
331
335
  assert.deepEqual(seen, [["needle", "other"], ["needle", "other"], ["needle", "other"]]);
@@ -334,7 +338,9 @@ test("wildcard queries reach lazy loaders and pre-filtered misses are not errors
334
338
  });
335
339
  test("query offsets and text continuation retain cross-session identity and Unicode coordinates", async (t) => {
336
340
  const { ctx } = await fixture(t);
337
- const page = data(await historyList.execute({ session: "pi:*", query: "NEEDLE", roles: ["user"], max_chars_per_item: 3 }, ctx));
341
+ const result = await historySearch.execute({ session: "pi:pi-one", query: "NEEDLE", roles: ["user"], max_chars_per_item: 3 }, ctx);
342
+ assert.match(historySearch.render(result), /^=== session pi:pi-one ===\nseq 1 \| user \| [^|\n]+ \| offset_chars 5\nNEE \[truncated\]/);
343
+ const page = data(result);
338
344
  const hit = page.items[0];
339
345
  assert.ok("seq" in hit);
340
346
  assert.equal(hit.offset_chars, 5);
@@ -348,7 +354,7 @@ test("query offsets and text continuation retain cross-session identity and Unic
348
354
  });
349
355
  test("wildcard glob metacharacters other than * stay literal, with deterministic timestamp ties", async () => {
350
356
  const ctx = context([descriptor("pi", "a.b"), descriptor("pi", "axb"), descriptor("claude", "a.b")]);
351
- const page = data(await historyList.execute({ session: "a.*", query: "needle", limit: 500 }, ctx));
357
+ const page = data(await historySearch.execute({ session: "a.*", query: "needle", limit: 500 }, ctx));
352
358
  assert.ok(page.items.every((item) => "session" in item && ["pi:a.b", "claude:a.b"].includes(item.session)));
353
359
  assert.deepEqual(page.items.slice(0, 2).map((item) => "session" in item ? item.session : ""), ["claude:a.b", "pi:a.b"]);
354
360
  });
@@ -358,7 +364,7 @@ test("root overrides/env homes are hermetic, missing roots are empty, and foreig
358
364
  const current = { harness: "dsh", id: "unreadable", load: async () => { throw new Error("current unavailable"); } };
359
365
  const ctx = { current: () => { throw new Error("must not read current"); }, corpus: localHistoryCorpus({ roots, env: {}, summaryCacheRoot: join(f.home, "history-cache"), home: join(f.home, "absent"), current }) };
360
366
  assert.equal(data(await historyRead.execute({ session: "pi:pi-one", seq: 1 }, ctx)).session, "pi:pi-one");
361
- assert.equal(data(await historyList.execute({ session: "pi:*", query: "needle" }, ctx)).items.length, 2);
367
+ assert.equal(data(await historySearch.execute({ session: "pi:*", query: "needle" }, ctx)).items.length, 2);
362
368
  const env = { PI_CODING_AGENT_DIR: dirname(f.roots.pi), CLAUDE_CONFIG_DIR: dirname(f.roots.claude), CODEX_HOME: dirname(f.roots.codex) };
363
369
  const configured = localHistoryCorpus({ current, summaryCacheRoot: join(f.home, "history-cache"), home: join(f.home, "absent"), env });
364
370
  assert.equal((await configured.sessions()).length, 4);
@@ -372,18 +378,17 @@ test("DSH service descriptors participate in resolution/search only when supplie
372
378
  const ctx = { current: () => projection(), corpus };
373
379
  assert.equal(data(await historyRead.execute({ session: "dsh:dsh", seq: 1 }, ctx)).session, "dsh:dsh-one");
374
380
  assert.equal(data(await historyRead.execute({ session: "pi-one", seq: 1 }, ctx)).text, "live needle 1");
375
- const page = data(await historyList.execute({ session: "dsh:*", query: "needle" }, ctx));
381
+ const page = data(await historySearch.execute({ session: "dsh:*", query: "needle" }, ctx));
376
382
  assert.equal(page.items.length, 5);
377
383
  assert.ok(page.items.every((item) => "role" in item && item.role === "context"));
378
384
  assert.equal((await corpus.sessions()).filter((session) => session.harness === "pi" && session.id === "pi-one").length, 1);
379
385
  });
380
- test("oversized cross-session reads/searches obey both wire budgets and retain canonical identities", async () => {
386
+ test("oversized cross-session reads/searches obey the rendered text budget and retain canonical identities", async () => {
381
387
  const p = projection("😀".repeat(40_000));
382
388
  const ctx = context([descriptor("codex", "long-id", p)]);
383
- const list = await historyList.execute({ session: "*", query: "😀", max_chars_per_item: 50_000, limit: 500 }, ctx);
389
+ const list = await historySearch.execute({ session: "*", query: "😀", max_chars_per_item: 50_000, limit: 500 }, ctx);
384
390
  const page = data(list);
385
- assert.ok(Buffer.byteLength(JSON.stringify(page)) <= TOOL_OUTPUT_MAX_BYTES);
386
- assert.ok(Buffer.byteLength(historyList.render(list)) <= TOOL_OUTPUT_MAX_BYTES);
391
+ assert.ok(Buffer.byteLength(historySearch.render(list)) <= TOOL_OUTPUT_MAX_BYTES);
387
392
  assert.equal(page.items.length, 1);
388
393
  assert.equal(page.has_older, true);
389
394
  assert.equal(page.has_newer, false);
@@ -391,12 +396,10 @@ test("oversized cross-session reads/searches obey both wire budgets and retain c
391
396
  assert.ok("seq" in item && item.truncated);
392
397
  assert.equal(item.session, "codex:long-id");
393
398
  const read = await historyRead.execute({ session: item.session, seq: item.seq, max_chars: 50_000 }, ctx);
394
- assert.ok(Buffer.byteLength(JSON.stringify(data(read))) <= TOOL_OUTPUT_MAX_BYTES);
395
399
  assert.ok(Buffer.byteLength(historyRead.render(read)) <= TOOL_OUTPUT_MAX_BYTES);
396
400
  assert.equal(data(read).session, "codex:long-id");
397
401
  assert.ok(data(read).next_offset_chars > 0);
398
402
  const overview = await historyList.execute({ session: "*", max_chars_per_item: 50_000 }, ctx);
399
- assert.ok(Buffer.byteLength(JSON.stringify(data(overview))) <= TOOL_OUTPUT_MAX_BYTES);
400
403
  assert.ok(Buffer.byteLength(historyList.render(overview)) <= TOOL_OUTPUT_MAX_BYTES);
401
404
  assert.equal(data(overview).items.length, 1);
402
405
  assert.equal(data(overview).has_older, false);
@@ -404,12 +407,12 @@ test("oversized cross-session reads/searches obey both wire budgets and retain c
404
407
  });
405
408
  test("wildcard byte budgets report retained candidates beyond either end", async () => {
406
409
  const ctx = context([descriptor("pi", "large", projection("needle " + "x".repeat(20_000)))]);
407
- for (const after of [undefined, AT]) {
408
- const result = await historyList.execute({ session: "*", query: "needle", after, limit: 5, max_chars_per_item: 50_000 }, ctx);
410
+ for (const since of [undefined, AT]) {
411
+ const result = await historySearch.execute({ session: "*", query: "needle", since, limit: 5, max_chars_per_item: 50_000 }, ctx);
409
412
  const page = data(result);
410
413
  assert.ok(page.items.length < 5);
411
- assert.equal(page.has_older, after === undefined);
412
- assert.equal(page.has_newer, after !== undefined);
414
+ assert.equal(page.has_older, since === undefined);
415
+ assert.equal(page.has_newer, since !== undefined);
413
416
  }
414
417
  });
415
418
  test("qualified lookup and current-harness matches do not inspect unrelated roots", async (t) => {
@@ -420,19 +423,19 @@ test("qualified lookup and current-harness matches do not inspect unrelated root
420
423
  const ctx = { current: () => projection(), corpus: localHistoryCorpus({ current, summaryCacheRoot: join(f.home, "history-cache"), roots: { pi: f.roots.pi, claude: notDirectory, codex: null }, env: {} }) };
421
424
  assert.equal(data(await historyRead.execute({ session: "pi-one", seq: 1 }, ctx)).session, "pi:pi-one");
422
425
  assert.equal(data(await historyRead.execute({ session: "pi:pi-one", seq: 1 }, ctx)).session, "pi:pi-one");
423
- assert.equal(data(await historyList.execute({ session: "pi:*", query: "needle" }, ctx)).items.length, 7);
426
+ assert.equal(data(await historySearch.execute({ session: "pi:*", query: "needle" }, ctx)).items.length, 7);
424
427
  });
425
428
  test("cross-session Claude gaps are visible even on an empty page, budgeted, and outside document offsets", async (t) => {
426
429
  const f = await fixture(t);
427
430
  await f.put(f.claudePath, rows([{ type: "assistant", uuid: "head", parentUuid: "missing", sessionId: "claude-one", timestamp: AT, message: { role: "assistant", content: "😀needle" + "x".repeat(50_000) } }]));
428
- const empty = await historyList.execute({ session: "claude:claude-one", query: "absent" }, f.ctx);
431
+ const empty = await historySearch.execute({ session: "claude:claude-one", query: "absent" }, f.ctx);
429
432
  assert.equal(data(empty).items.length, 0);
430
433
  assert.match(data(empty).notice, /missing ancestor.*"missing"/);
431
- const emptyText = historyList.render(empty);
434
+ const emptyText = historySearch.render(empty);
435
+ assert.match(emptyText, /=== session claude:claude-one ===\nNo events match/);
432
436
  assert.ok(emptyText.includes(data(empty).notice), "the gap notice survives an empty page");
433
- const list = await historyList.execute({ session: "claude:*", query: "needle", max_chars_per_item: 50_000 }, f.ctx);
434
- assert.ok(Buffer.byteLength(JSON.stringify(data(list))) <= TOOL_OUTPUT_MAX_BYTES);
435
- assert.ok(Buffer.byteLength(historyList.render(list)) <= TOOL_OUTPUT_MAX_BYTES);
437
+ const list = await historySearch.execute({ session: "claude:*", query: "needle", max_chars_per_item: 50_000 }, f.ctx);
438
+ assert.ok(Buffer.byteLength(historySearch.render(list)) <= TOOL_OUTPUT_MAX_BYTES);
436
439
  const hit = data(list).items[0];
437
440
  assert.ok("seq" in hit);
438
441
  assert.equal(hit.offset_chars, 1);
@@ -440,7 +443,6 @@ test("cross-session Claude gaps are visible even on an empty page, budgeted, and
440
443
  assert.match(data(read).notice, /history is incomplete/);
441
444
  assert.ok(data(read).text.startsWith("needle"));
442
445
  assert.ok(!data(read).text.includes("missing ancestor"));
443
- assert.ok(Buffer.byteLength(JSON.stringify(data(read))) <= TOOL_OUTPUT_MAX_BYTES);
444
446
  assert.ok(Buffer.byteLength(historyRead.render(read)) <= TOOL_OUTPUT_MAX_BYTES);
445
447
  });
446
448
  test("wildcards skip corrupt and unreadable sessions, while single-session lists and reads still refuse", async (t) => {
@@ -449,13 +451,13 @@ test("wildcards skip corrupt and unreadable sessions, while single-session lists
449
451
  const sessions = await f.corpus.sessions();
450
452
  await rm(f.claudePath);
451
453
  const ctx = { current: () => projection(), corpus: { currentHarness: "pi", sessions: async () => sessions } };
452
- for (const query of [undefined, "needle"]) {
453
- const page = data(await historyList.execute({ session: "*", query }, ctx));
454
+ for (const result of [await historyList.execute({ session: "*" }, ctx), await historySearch.execute({ session: "*", query: "needle" }, ctx)]) {
455
+ const page = data(result);
454
456
  assert.ok(page.items.length > 0);
455
457
  assert.ok(page.items.every((item) => item.session !== "pi:broken" && item.session !== "claude:claude-one"));
456
458
  }
457
459
  for (const session of ["pi:broken", "claude:claude-one"]) {
458
- assert.ok(refusal(await historyList.execute({ session, query: "absent" }, ctx), "history_unavailable").includes(session));
460
+ assert.ok(refusal(await historySearch.execute({ session, query: "absent" }, ctx), "history_unavailable").includes(session));
459
461
  refusal(await historyRead.execute({ session, seq: 1 }, ctx), "history_unavailable");
460
462
  }
461
463
  });
@@ -551,10 +553,10 @@ test("streaming filtering never loses escaped JSON, Unicode or OR-query matches"
551
553
  const codexText = escapeText(f.codexText.replace("Codex needle", JSON.stringify(content).slice(1, -1)));
552
554
  await f.put(f.codexPath, zstdCompressSync(Buffer.from(codexText)));
553
555
  for (const query of ["needle", "你好", "😀", 'quote"slash\\', "line\nbreak", "İ", "longs", "caseς", ["absentword", "needle"]]) {
554
- const page = data(await historyList.execute({ session: "*", query }, f.ctx));
556
+ const page = data(await historySearch.execute({ session: "*", query }, f.ctx));
555
557
  assert.deepEqual(page.items.map((item) => item.session), ["claude:claude-one", "pi:pi-one", `codex:${CODEX}`], JSON.stringify(query));
556
558
  }
557
- assert.deepEqual(data(await historyList.execute({ session: "*", query: "absentword" }, f.ctx)).items, []);
559
+ assert.deepEqual(data(await historySearch.execute({ session: "*", query: "absentword" }, f.ctx)).items, []);
558
560
  });
559
561
  test("streaming filtering preserves generated tool documents, compact arguments and nested JSON escapes", async (t) => {
560
562
  const f = await fixture(t);
@@ -563,19 +565,19 @@ test("streaming filtering preserves generated tool documents, compact arguments
563
565
  { type: "message", id: "t", parentId: null, timestamp: AT, message: { role: "toolResult", content: [{ type: "text", text: "done" }] } },
564
566
  ]));
565
567
  for (const query of ["unknown", "arguments", "output"]) {
566
- const page = data(await historyList.execute({ session: "pi:pi-*", query }, f.ctx));
568
+ const page = data(await historySearch.execute({ session: "pi:pi-*", query }, f.ctx));
567
569
  assert.equal(page.items.length, 1, query);
568
570
  }
569
571
  await f.put(f.piPath, rows([
570
572
  { type: "session", id: "pi-one" },
571
573
  { type: "message", id: "t", parentId: null, timestamp: AT, message: { role: "assistant", content: [{ type: "toolCall", id: "c", name: "read", arguments: { value: "\ud800" } }] } },
572
574
  ]));
573
- assert.equal(data(await historyList.execute({ session: "pi:pi-*", query: "ud" }, f.ctx)).items.length, 1);
575
+ assert.equal(data(await historySearch.execute({ session: "pi:pi-*", query: "ud" }, f.ctx)).items.length, 1);
574
576
  const codexRows = f.codexText.split("\n").filter(Boolean).map((line) => JSON.parse(line));
575
577
  codexRows[1].payload = { type: "function_call", call_id: "t", name: "read", arguments: '{ "path" : "\\u006eeedle" }' };
576
578
  await f.put(f.codexPath, zstdCompressSync(Buffer.from(rows(codexRows))));
577
579
  for (const query of ["needle", '"path":"needle"']) {
578
- const page = data(await historyList.execute({ session: "codex:*", query }, f.ctx));
580
+ const page = data(await historySearch.execute({ session: "codex:*", query }, f.ctx));
579
581
  assert.equal(page.items.length, 1, query);
580
582
  }
581
583
  });
@@ -593,7 +595,7 @@ test("Codex streaming prefilter preserves query hits inherited through a split h
593
595
  ]);
594
596
  // Put the inheritance sentinel across the filesystem stream's 64KiB boundary.
595
597
  await f.put(join(dirname(f.codexPath), `rollout-2026-10-06T01-02-03-${child}.jsonl`), " ".repeat(65535 - childText.indexOf('"history_base"')) + childText);
596
- const page = data(await historyList.execute({ session: `codex:${child}*`, query: "ancestralneedle" }, f.ctx));
598
+ const page = data(await historySearch.execute({ session: `codex:${child}*`, query: "ancestralneedle" }, f.ctx));
597
599
  assert.deepEqual(page.items.map((item) => "seq" in item ? [item.session, item.seq] : null), [[`codex:${child}`, 2]]);
598
600
  });
599
601
  test("streaming search agrees with strict decoding across chunk and event-time boundaries", async (t) => {
@@ -621,7 +623,7 @@ test("streaming search agrees with strict decoding across chunk and event-time b
621
623
  for (const query of ["needle", "longs", "caseς", "k", "𐐨", "你好", "😀", "absentword", ["absentword", "needle"]]) {
622
624
  for (const bounds of [{}, { since: AT, until: "2026-10-06T01:02:08Z" }, { since: "2026-10-06T01:02:08Z" }, { until: AT }]) {
623
625
  const args = { session: "*", query, limit: 20, ...bounds };
624
- assert.deepEqual(await historyList.execute(args, f.ctx), await historyList.execute(args, strict), JSON.stringify({ compressed, ...args }));
626
+ assert.deepEqual(await historySearch.execute(args, f.ctx), await historySearch.execute(args, strict), JSON.stringify({ compressed, ...args }));
625
627
  }
626
628
  }
627
629
  }
@@ -629,8 +631,8 @@ test("streaming search agrees with strict decoding across chunk and event-time b
629
631
  test("stream failures skip wildcard sessions but explicit selections still refuse", async (t) => {
630
632
  const f = await fixture(t);
631
633
  await f.put(f.codexPath, "not-zstd");
632
- assert.deepEqual(data(await historyList.execute({ session: "codex:*", query: "absentword" }, f.ctx)).items, []);
633
- refusal(await historyList.execute({ session: `codex:${CODEX}`, query: "absentword" }, f.ctx), "history_unavailable");
634
+ assert.deepEqual(data(await historySearch.execute({ session: "codex:*", query: "absentword" }, f.ctx)).items, []);
635
+ refusal(await historySearch.execute({ session: `codex:${CODEX}`, query: "absentword" }, f.ctx), "history_unavailable");
634
636
  });
635
637
  test("offline Claude attachments and retry branches are readable and searchable through session selectors", async (t) => {
636
638
  const f = await fixture(t);
@@ -643,7 +645,7 @@ test("offline Claude attachments and retry branches are readable and searchable
643
645
  assert.equal(data(await historyRead.execute({ session: "claude:claude-one", seq: 3 }, f.ctx)).text, "rightneedle");
644
646
  refusal(await historyRead.execute({ session: "claude:claude-one", seq: 2 }, f.ctx), "not_on_branch");
645
647
  for (const session of ["claude:claude-one", "claude:*"]) {
646
- const page = data(await historyList.execute({ session, query: "needle" }, f.ctx));
648
+ const page = data(await historySearch.execute({ session, query: "needle" }, f.ctx));
647
649
  assert.deepEqual(page.items.map((item) => "seq" in item ? item.seq : null), [3]);
648
650
  }
649
651
  assert.deepEqual(data(await historyList.execute({ session: "claude:*" }, f.ctx)).items.map((item) => "seq" in item ? item.seq : null), [1]);