notesoup 0.59.1 → 0.60.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 +3 -17
- package/dist/plugins/claude/src/helper.js +3 -4
- package/dist/plugins/codex/src/mcp.js +1 -2
- package/dist/plugins/dsh/tools.js +1 -2
- package/dist/plugins/pi/notes/tools.d.ts +1 -1
- package/dist/plugins/pi/notes/tools.js +2 -3
- package/dist/src/history/claude.d.ts +3 -1
- package/dist/src/history/claude.js +40 -4
- package/dist/src/history/history.d.ts +10 -11
- package/dist/src/history/history.js +8 -19
- package/dist/src/history/prefilter.d.ts +1 -1
- package/dist/src/history/prefilter.js +14 -9
- package/dist/src/history/query.d.ts +3 -14
- package/dist/src/history/query.js +73 -85
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/notes/address.js +3 -3
- package/dist/src/notes/store.d.ts +2 -4
- package/dist/src/notes/store.js +1 -2
- package/dist/src/tools/history.d.ts +4 -6
- package/dist/src/tools/history.js +69 -29
- package/dist/src/tools/notes.d.ts +18 -78
- package/dist/src/tools/notes.js +39 -50
- package/dist/src/tools/schema.d.ts +0 -1
- package/dist/src/tools/schema.js +0 -1
- package/dist/test/claude-history.test.js +27 -6
- package/dist/test/claude-mod.test.js +19 -8
- package/dist/test/codex-history.test.js +1 -1
- package/dist/test/codex-plugin.test.js +1 -2
- package/dist/test/dependencies.test.js +2 -2
- package/dist/test/dsh.test.js +2 -2
- package/dist/test/history-corpus.test.js +21 -36
- package/dist/test/history-prefilter.test.js +5 -0
- package/dist/test/history-summary-cache.test.js +3 -3
- package/dist/test/history.integration.test.js +53 -106
- package/dist/test/host-neutral.test.js +1 -1
- package/dist/test/note-policy.test.js +5 -5
- package/dist/test/notes-cwd.test.js +5 -5
- package/dist/test/notes-query-namespaces.test.js +2 -6
- package/dist/test/notes.integration.test.js +30 -35
- package/dist/test/notes.test.js +12 -14
- package/dist/test/project-namespace.test.js +3 -3
- package/docs/architecture.md +3 -3
- package/docs/claude-code-mod.md +5 -3
- package/docs/codex.md +1 -1
- package/docs/dsh.md +2 -2
- package/docs/history-sessions.md +9 -10
- package/docs/notes-library.md +3 -3
- package/docs/tool-results.md +12 -6
- package/package.json +1 -1
- package/plugins/claude/dist/claude/helper.js +214 -173
- package/plugins/claude/hooks/register.ts +8 -6
- package/plugins/claude/skills/memory/SKILL.md +6 -6
- package/plugins/claude/src/helper.ts +3 -4
- package/plugins/codex/README.md +1 -1
- package/plugins/codex/dist/codex/notesoup.js +176 -160
- package/plugins/codex/src/mcp.ts +1 -2
- package/plugins/dsh/tools.ts +1 -2
- package/plugins/paseo/README.md +16 -0
- package/plugins/paseo/client/brain-empty-card.tsx +5 -3
- package/plugins/paseo/client/markdown-core.tsx +189 -0
- package/plugins/paseo/client/markdown.tsx +38 -135
- package/plugins/paseo/client/notes-op-card.tsx +15 -12
- package/plugins/paseo/client/paper-card.tsx +1 -3
- package/plugins/paseo/client/sticky-card.tsx +2 -1
- package/plugins/paseo/client/typography.ts +24 -0
- package/plugins/paseo/test/markdown-core.test.ts +75 -0
- package/plugins/pi/notes/tools.ts +2 -3
- package/skills/memory/SKILL.md +6 -6
- package/src/history/claude.ts +31 -4
- package/src/history/history.ts +11 -16
- package/src/history/prefilter.ts +13 -9
- package/src/history/query.ts +67 -99
- package/src/index.ts +1 -1
- package/src/notes/address.ts +2 -2
- package/src/notes/store.ts +3 -6
- package/src/tools/history.ts +60 -29
- package/src/tools/notes.ts +39 -54
- package/src/tools/schema.ts +0 -1
|
@@ -24947,6 +24947,7 @@ var HistoryFoldedRowSchema = typebox_exports.Object({
|
|
|
24947
24947
|
var HistoryPageItemSchema = typebox_exports.Object({
|
|
24948
24948
|
session: typebox_exports.Optional(typebox_exports.String()),
|
|
24949
24949
|
folded_before: typebox_exports.Optional(HistoryFoldedRowSchema),
|
|
24950
|
+
context: typebox_exports.Optional(typebox_exports.Literal(true, { description: "A neighbor of a search hit, not a hit in this page." })),
|
|
24950
24951
|
seq: typebox_exports.Integer({ minimum: 1 }),
|
|
24951
24952
|
role: HistoryRoleSchema,
|
|
24952
24953
|
created_at: typebox_exports.Union([typebox_exports.String(), typebox_exports.Null()]),
|
|
@@ -24976,20 +24977,17 @@ function visibleItem(event, maxChars, matchOffset) {
|
|
|
24976
24977
|
function allItems(projection) {
|
|
24977
24978
|
return projection.windows.flatMap((current) => current.items);
|
|
24978
24979
|
}
|
|
24979
|
-
function
|
|
24980
|
-
|
|
24981
|
-
|
|
24982
|
-
|
|
24983
|
-
|
|
24984
|
-
const at = Date.parse(event.createdAt);
|
|
24985
|
-
return !Number.isNaN(at) && (params.sinceMs === void 0 || at >= params.sinceMs) && (params.untilMs === void 0 || at < params.untilMs);
|
|
24980
|
+
function compareBound(event, bound) {
|
|
24981
|
+
return "seq" in bound ? event.seq - bound.seq : Date.parse(event.createdAt ?? "") - bound.at;
|
|
24982
|
+
}
|
|
24983
|
+
function matchesFilter(event, { after, before, roles }) {
|
|
24984
|
+
return (!after || compareBound(event, after) > 0) && (!before || compareBound(event, before) < 0) && (!roles || roles.includes(event.role));
|
|
24986
24985
|
}
|
|
24987
24986
|
function filteredItems(projection, params) {
|
|
24988
|
-
return allItems(projection).filter((
|
|
24987
|
+
return allItems(projection).filter((event) => matchesFilter(event, params)).sort((a, b) => a.seq - b.seq);
|
|
24989
24988
|
}
|
|
24990
24989
|
|
|
24991
24990
|
// src/tools/schema.ts
|
|
24992
|
-
var nullableString = (description) => typebox_exports.Optional(typebox_exports.Union([typebox_exports.String(), typebox_exports.Null()], description === void 0 ? {} : { description }));
|
|
24993
24991
|
var historyRoles = () => typebox_exports.Optional(typebox_exports.Array(HistoryRoleSchema, { minItems: 1, description: "Only these voices: user, assistant, tool, context. Without roles or query, tool and context runs fold into one line." }));
|
|
24994
24992
|
function paramProblem(schema, params) {
|
|
24995
24993
|
const first = Errors2(schema, params).find((error2) => error2.keyword !== "boolean");
|
|
@@ -25097,8 +25095,8 @@ function globToRegExp(pattern) {
|
|
|
25097
25095
|
return new RegExp(`${source}$`);
|
|
25098
25096
|
}
|
|
25099
25097
|
function assertGlobPattern(value) {
|
|
25100
|
-
if (value === void 0
|
|
25101
|
-
if (typeof value !== "string") throw new NoteError("invalid_pattern", `glob ${shown(value)} must be a string.`);
|
|
25098
|
+
if (value === void 0) return void 0;
|
|
25099
|
+
if (typeof value !== "string" || !value) throw new NoteError("invalid_pattern", `glob ${shown(value)} must be a non-empty string; omit it for the current notebooks.`);
|
|
25102
25100
|
if (value.includes("\0") || value.includes("\\")) throw new NoteError("invalid_pattern", `glob ${shown(value)} can't contain "\\" or NUL.`);
|
|
25103
25101
|
return value;
|
|
25104
25102
|
}
|
|
@@ -25952,8 +25950,7 @@ function createNotesStore(input) {
|
|
|
25952
25950
|
}));
|
|
25953
25951
|
}
|
|
25954
25952
|
async function* scan(options, status) {
|
|
25955
|
-
const
|
|
25956
|
-
const pattern = glob === "@default" ? void 0 : glob;
|
|
25953
|
+
const pattern = assertGlobPattern(options.glob);
|
|
25957
25954
|
const normalized = normalizePattern(pattern, identity);
|
|
25958
25955
|
const matcher = normalized === void 0 ? void 0 : globToRegExp(normalized);
|
|
25959
25956
|
const namespaces = await namespacesForPattern(pattern, identity, status);
|
|
@@ -26163,7 +26160,7 @@ function withWarnings(text2, data) {
|
|
|
26163
26160
|
var CRUMPLED_PARAMETER = typebox_exports.Optional(typebox_exports.Boolean({ description: "`true` balls the page up: gone from list and search, still readable. `false` smooths it flat again." }));
|
|
26164
26161
|
var CRUMPLED_LIST_PARAMETER = typebox_exports.Optional(typebox_exports.Boolean({ description: "Only the crumpled balls." }));
|
|
26165
26162
|
var FILE_LIMIT_PARAMETER = typebox_exports.Optional(typebox_exports.Integer({ minimum: 1, description: "How many pages at most." }));
|
|
26166
|
-
var GLOB_PARAMETER =
|
|
26163
|
+
var GLOB_PARAMETER = typebox_exports.Optional(typebox_exports.String({ minLength: 1, description: "Which drawers to open. Leave it out for this session and your current notebooks. `@project/**` one shelf \xB7 `MAP.md` that page in every notebook \xB7 `**` everything \xB7 `@sessions/*/**` every session." }));
|
|
26167
26164
|
var CWD_PARAMETER = typebox_exports.Optional(typebox_exports.String({ minLength: 1, description: "Treat this directory's project as `@project/`." }));
|
|
26168
26165
|
var ADDRESS_PARAMETER = typebox_exports.String({ description: "Which drawer the page sits in. `plan.md` \u2014 this session's desk, cleared when it ends. `@project/` this project's shelf \xB7 `@human/` your human's file \xB7 `@self/` your own notebook \xB7 `@model/` your brain's. `@projects/<name>/`, `@sessions/<id>/`, `@agents/<name>/`, `@models/<name>/` \u2014 someone else's shelf: read only. Paper, not files: hand one to read/write/edit/bash and a real `@project` folder is born." });
|
|
26169
26166
|
function failureOf(error2) {
|
|
@@ -26253,11 +26250,6 @@ var MatchSchema = typebox_exports.Object({
|
|
|
26253
26250
|
text: typebox_exports.String(),
|
|
26254
26251
|
offset_chars: typebox_exports.Integer()
|
|
26255
26252
|
}, { additionalProperties: false });
|
|
26256
|
-
var SearchedFileSchema = typebox_exports.Object({
|
|
26257
|
-
...ListedFileSchema.properties,
|
|
26258
|
-
matches: typebox_exports.Array(MatchSchema),
|
|
26259
|
-
more_matches: typebox_exports.Optional(typebox_exports.Integer({ minimum: 1 }))
|
|
26260
|
-
}, { additionalProperties: false });
|
|
26261
26253
|
var SnapshotSchema = {
|
|
26262
26254
|
more: typebox_exports.Integer({ description: "How many more were left out." }),
|
|
26263
26255
|
namespaces_unavailable: typebox_exports.Array(typebox_exports.String(), { description: "Unreadable notebooks or notes." })
|
|
@@ -26282,11 +26274,11 @@ var NotesReadDataSchema = typebox_exports.Object({
|
|
|
26282
26274
|
...TextWindowSchema.properties
|
|
26283
26275
|
}, { additionalProperties: false });
|
|
26284
26276
|
var NotesListDataSchema = typebox_exports.Object({
|
|
26285
|
-
files: typebox_exports.Array(
|
|
26286
|
-
|
|
26287
|
-
|
|
26288
|
-
|
|
26289
|
-
|
|
26277
|
+
files: typebox_exports.Array(typebox_exports.Object({
|
|
26278
|
+
...ListedFileSchema.properties,
|
|
26279
|
+
matches: typebox_exports.Optional(typebox_exports.Array(MatchSchema)),
|
|
26280
|
+
more_matches: typebox_exports.Optional(typebox_exports.Integer({ minimum: 1 }))
|
|
26281
|
+
}, { additionalProperties: false })),
|
|
26290
26282
|
...SnapshotSchema
|
|
26291
26283
|
}, { additionalProperties: false });
|
|
26292
26284
|
function snapshot(rows, limit, status, renderData, shrink) {
|
|
@@ -26402,41 +26394,24 @@ var notesRead = {
|
|
|
26402
26394
|
},
|
|
26403
26395
|
render: (result) => renderOutcome(result, renderReadData)
|
|
26404
26396
|
};
|
|
26405
|
-
var notesListParameters = typebox_exports.Object({
|
|
26397
|
+
var notesListParameters = typebox_exports.Object({
|
|
26398
|
+
glob: GLOB_PARAMETER,
|
|
26399
|
+
query: typebox_exports.Optional(searchQuery()),
|
|
26400
|
+
max_matches_per_file: typebox_exports.Optional(typebox_exports.Integer({ minimum: 1, description: "How many hit lines per note at most; requires a query." })),
|
|
26401
|
+
crumpled: CRUMPLED_LIST_PARAMETER,
|
|
26402
|
+
limit: FILE_LIMIT_PARAMETER,
|
|
26403
|
+
cwd: CWD_PARAMETER
|
|
26404
|
+
}, { additionalProperties: false });
|
|
26406
26405
|
function renderListData(data) {
|
|
26407
26406
|
const lines = [`${data.files.length} ${data.files.length === 1 ? "note" : "notes"}`];
|
|
26408
26407
|
for (const file of data.files) {
|
|
26409
|
-
|
|
26410
|
-
|
|
26411
|
-
|
|
26412
|
-
|
|
26413
|
-
|
|
26414
|
-
return lines.join("\n");
|
|
26415
|
-
}
|
|
26416
|
-
var notesList = {
|
|
26417
|
-
name: "notes_list",
|
|
26418
|
-
label: "Notes list",
|
|
26419
|
-
description: "Leaf through the drawers, newest pages on top. One pass; `more` counts pages left on the pile \u2014 narrow `glob`.",
|
|
26420
|
-
parameters: notesListParameters,
|
|
26421
|
-
outputSchema: resultSchema(NotesListDataSchema),
|
|
26422
|
-
async execute(params, context2) {
|
|
26423
|
-
try {
|
|
26424
|
-
const identity = notesIdentityForCall(context2, params.cwd);
|
|
26425
|
-
const { rows, status } = await createNotesStore(identity).listWithStatus({ glob: params.glob ?? void 0, crumpled: params.crumpled });
|
|
26426
|
-
return snapshot(rows.map((row) => listedFile(row, identity)), params.limit, status, renderListData);
|
|
26427
|
-
} catch (error2) {
|
|
26428
|
-
return failureOf(error2);
|
|
26429
|
-
}
|
|
26430
|
-
},
|
|
26431
|
-
render: (result) => renderOutcome(result, renderListData)
|
|
26432
|
-
};
|
|
26433
|
-
var notesSearchParameters = typebox_exports.Object({ query: typebox_exports.Optional(searchQuery()), glob: GLOB_PARAMETER, limit: FILE_LIMIT_PARAMETER, max_matches_per_file: typebox_exports.Optional(typebox_exports.Integer({ minimum: 1, description: "How many hit lines per page at most." })), crumpled: CRUMPLED_LIST_PARAMETER, cwd: CWD_PARAMETER }, { additionalProperties: false });
|
|
26434
|
-
function renderSearchData(data) {
|
|
26435
|
-
const lines = [`${data.files.length} ${data.files.length === 1 ? "note" : "notes"}`];
|
|
26436
|
-
for (const file of data.files) {
|
|
26437
|
-
lines.push(`- ${renderIdentity(file)} | ${renderPolicy(file)} | updated ${file.updated_at} | ${file.matches.length} ${file.matches.length === 1 ? "match" : "matches"}${file.more_matches ? `, ${file.more_matches} more lines` : ""}`);
|
|
26408
|
+
const fields = [`- ${renderIdentity(file)}`, renderPolicy(file), `updated ${file.updated_at}`];
|
|
26409
|
+
if (file.last_accessed !== void 0) fields.push(`accessed ${file.last_accessed}`);
|
|
26410
|
+
if (file.crumpled_at !== void 0) fields.push(`crumpled ${file.crumpled_at}`);
|
|
26411
|
+
if (file.matches) fields.push(`${file.matches.length} ${file.matches.length === 1 ? "match" : "matches"}${file.more_matches ? `, ${file.more_matches} more lines` : ""}`);
|
|
26412
|
+
lines.push(fields.join(" | "));
|
|
26438
26413
|
lines.push(...file.warnings.map((warning) => ` ${warning}`));
|
|
26439
|
-
for (const match of file.matches) lines.push(` line ${match.line} at offset_chars ${match.offset_chars}: ${match.text}`);
|
|
26414
|
+
for (const match of file.matches ?? []) lines.push(` line ${match.line} at offset_chars ${match.offset_chars}: ${match.text}`);
|
|
26440
26415
|
}
|
|
26441
26416
|
if (data.more > 0) lines.push(`${data.more} more matching notes omitted; narrow with glob`);
|
|
26442
26417
|
for (const namespace of data.namespaces_unavailable) lines.push(`${namespace} could not be read`);
|
|
@@ -26460,26 +26435,34 @@ function fitSearchFile(file, fits) {
|
|
|
26460
26435
|
const withText = (text2) => ({ ...keepMatches(file, 1), matches: [{ ...first, text: `${text2}${MATCH_SHORTENED_MARKER}` }] });
|
|
26461
26436
|
return withText(prefixFit(first.text, (text2) => fits(withText(text2))));
|
|
26462
26437
|
}
|
|
26463
|
-
var
|
|
26464
|
-
name: "
|
|
26465
|
-
label: "Notes
|
|
26466
|
-
description: "
|
|
26467
|
-
parameters:
|
|
26468
|
-
outputSchema: resultSchema(
|
|
26438
|
+
var notesList = {
|
|
26439
|
+
name: "notes_list",
|
|
26440
|
+
label: "Notes list",
|
|
26441
|
+
description: "List or search notes, newest pages on top. A query matches literal text (ignoring case) and returns hit lines and read offsets. One pass; `more` counts pages left on the pile \u2014 narrow `glob`.",
|
|
26442
|
+
parameters: notesListParameters,
|
|
26443
|
+
outputSchema: resultSchema(NotesListDataSchema),
|
|
26469
26444
|
async execute(params, context2) {
|
|
26470
26445
|
try {
|
|
26446
|
+
const queries = searchQueries(params.query);
|
|
26447
|
+
const { glob, crumpled, limit } = params;
|
|
26448
|
+
if (!queries.length && params.max_matches_per_file !== void 0) return failure2("invalid_params", "`max_matches_per_file` requires a non-empty `query`.");
|
|
26471
26449
|
const identity = notesIdentityForCall(context2, params.cwd);
|
|
26472
|
-
const
|
|
26450
|
+
const store = createNotesStore(identity);
|
|
26451
|
+
if (!queries.length) {
|
|
26452
|
+
const { rows: rows2, status: status2 } = await store.listWithStatus({ glob, crumpled });
|
|
26453
|
+
return snapshot(rows2.map((row) => listedFile(row, identity)), limit, status2, renderListData);
|
|
26454
|
+
}
|
|
26455
|
+
const { rows, status } = await store.searchWithStatus(queries, { glob, crumpled });
|
|
26473
26456
|
const files = rows.sort((a, b) => b.meta.updatedAt - a.meta.updatedAt || a.address.localeCompare(b.address)).map((row) => keepMatches({
|
|
26474
26457
|
...listedFile(row, identity),
|
|
26475
26458
|
matches: row.matches.map((match) => ({ line: match.line, text: match.text, offset_chars: match.offsetChars }))
|
|
26476
26459
|
}, params.max_matches_per_file));
|
|
26477
|
-
return snapshot(files,
|
|
26460
|
+
return snapshot(files, limit, status, renderListData, fitSearchFile);
|
|
26478
26461
|
} catch (error2) {
|
|
26479
26462
|
return failureOf(error2);
|
|
26480
26463
|
}
|
|
26481
26464
|
},
|
|
26482
|
-
render: (result) => renderOutcome(result,
|
|
26465
|
+
render: (result) => renderOutcome(result, renderListData)
|
|
26483
26466
|
};
|
|
26484
26467
|
|
|
26485
26468
|
// src/history/query.ts
|
|
@@ -26491,23 +26474,6 @@ function markMultiPage(page) {
|
|
|
26491
26474
|
multiPages.add(page);
|
|
26492
26475
|
return page;
|
|
26493
26476
|
}
|
|
26494
|
-
var ISO_8601 = /^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[+-]\d{2}:?\d{2})?$/;
|
|
26495
|
-
function timeBound(name, value) {
|
|
26496
|
-
if (value === void 0) return success(void 0);
|
|
26497
|
-
const match = ISO_8601.exec(value);
|
|
26498
|
-
const at = match === null ? void 0 : Date.parse(match[1] === void 0 ? `${value}Z` : value);
|
|
26499
|
-
return at === void 0 || Number.isNaN(at) ? failure2("invalid_time", `\`${name}\` isn't an ISO 8601 time: "${value}".`) : success(at);
|
|
26500
|
-
}
|
|
26501
|
-
function resolveTimeBounds(params) {
|
|
26502
|
-
const since = timeBound("since", params.since);
|
|
26503
|
-
if (!since.ok) return since;
|
|
26504
|
-
const until = timeBound("until", params.until);
|
|
26505
|
-
if (!until.ok) return until;
|
|
26506
|
-
if (since.data !== void 0 && until.data !== void 0 && since.data >= until.data) {
|
|
26507
|
-
return failure2("invalid_time", "`since` must be earlier than `until`.");
|
|
26508
|
-
}
|
|
26509
|
-
return success({ ...since.data === void 0 ? {} : { sinceMs: since.data }, ...until.data === void 0 ? {} : { untilMs: until.data } });
|
|
26510
|
-
}
|
|
26511
26477
|
var HistoryPageSchema = typebox_exports.Object({
|
|
26512
26478
|
notice: typebox_exports.Optional(typebox_exports.String()),
|
|
26513
26479
|
items: typebox_exports.Array(HistoryPageItemSchema),
|
|
@@ -26540,22 +26506,29 @@ function foldedRun(events, session) {
|
|
|
26540
26506
|
const tools2 = Object.fromEntries(entries);
|
|
26541
26507
|
return { ...session === void 0 ? {} : { session }, first_seq: events[0].seq, last_seq: events.at(-1).seq, count: events.length, tools: tools2 };
|
|
26542
26508
|
}
|
|
26509
|
+
var visible = (event) => event.role !== "user" && event.role !== "assistant" || eventDocument(event) !== "";
|
|
26510
|
+
function* queryHits(projection, params, session) {
|
|
26511
|
+
const { query, context: context2 } = params;
|
|
26512
|
+
const events = filteredItems(projection, context2 ? {} : params).filter(visible);
|
|
26513
|
+
for (const [index, event] of events.entries()) {
|
|
26514
|
+
if (context2 && !matchesFilter(event, params)) continue;
|
|
26515
|
+
const matchOffset = earliestMatchOffsetChars(eventDocument(event), query);
|
|
26516
|
+
if (matchOffset >= 0) yield { event, session, matchOffset, neighbors: context2 ? { events, index } : void 0 };
|
|
26517
|
+
}
|
|
26518
|
+
}
|
|
26543
26519
|
function prepareSelection(projection, params) {
|
|
26544
|
-
const
|
|
26520
|
+
const { query, roles, session } = params;
|
|
26521
|
+
if (query) return { candidates: [...queryHits(projection, params, session)] };
|
|
26545
26522
|
const candidates = [];
|
|
26546
26523
|
let run = [];
|
|
26547
|
-
for (const event of filteredItems(projection, params)) {
|
|
26548
|
-
if (
|
|
26549
|
-
|
|
26550
|
-
|
|
26524
|
+
for (const event of filteredItems(projection, params).filter(visible)) {
|
|
26525
|
+
if (!roles && (event.role === "tool" || event.role === "context")) run.push(event);
|
|
26526
|
+
else {
|
|
26527
|
+
candidates.push({ event, session, before: foldedRun(run, session) });
|
|
26528
|
+
run = [];
|
|
26551
26529
|
}
|
|
26552
|
-
if ((event.role === "user" || event.role === "assistant") && eventDocument(event) === "") continue;
|
|
26553
|
-
const matchOffset = params.query === void 0 ? void 0 : earliestMatchOffsetChars(eventDocument(event), params.query);
|
|
26554
|
-
if (matchOffset !== void 0 && matchOffset < 0) continue;
|
|
26555
|
-
candidates.push({ event, ...params.session === void 0 ? {} : { session: params.session }, matchOffset, before: foldedRun(run, params.session) });
|
|
26556
|
-
run = [];
|
|
26557
26530
|
}
|
|
26558
|
-
return { candidates,
|
|
26531
|
+
return { candidates, tail: foldedRun(run, session) };
|
|
26559
26532
|
}
|
|
26560
26533
|
function pageData(prepared, start, end, maxChars, preview) {
|
|
26561
26534
|
const { candidates, tail } = prepared;
|
|
@@ -26568,38 +26541,51 @@ function pageData(prepared, start, end, maxChars, preview) {
|
|
|
26568
26541
|
const page = {
|
|
26569
26542
|
items,
|
|
26570
26543
|
...end === candidates.length && tail ? { folded_after: tail } : {},
|
|
26571
|
-
has_older: start > 0 && start < end || !!prepared.discarded && prepared.
|
|
26572
|
-
has_newer: end < candidates.length && start < end || !!prepared.discarded && prepared.
|
|
26544
|
+
has_older: start > 0 && start < end || !!prepared.discarded && !prepared.forward,
|
|
26545
|
+
has_newer: end < candidates.length && start < end || !!prepared.discarded && !!prepared.forward
|
|
26573
26546
|
};
|
|
26574
26547
|
return prepared.multi ? markMultiPage(page) : page;
|
|
26575
26548
|
}
|
|
26576
|
-
function resolveSelection(params) {
|
|
26577
|
-
const bounds = resolveTimeBounds(params);
|
|
26578
|
-
if (!bounds.ok) return bounds;
|
|
26579
|
-
try {
|
|
26580
|
-
const queries = searchQueries(params.query);
|
|
26581
|
-
return success({ ...params, ...bounds.data, query: queries.length ? queries : void 0 });
|
|
26582
|
-
} catch (error2) {
|
|
26583
|
-
if (error2 instanceof InvalidQueryError) return failure2("invalid_query", error2.message);
|
|
26584
|
-
throw error2;
|
|
26585
|
-
}
|
|
26586
|
-
}
|
|
26587
26549
|
function selectPage(projection, params, fits, maxChars) {
|
|
26588
|
-
|
|
26589
|
-
if (!scoped.ok) return scoped;
|
|
26590
|
-
return selectPrepared(prepareSelection(projection, scoped.data), scoped.data, fits, maxChars);
|
|
26591
|
-
}
|
|
26592
|
-
function corpusSelection(params) {
|
|
26593
|
-
if (params.before_seq !== void 0 || params.after_seq !== void 0) return failure2("invalid_bounds", "`before_seq` and `after_seq` are per-session; omit them for wildcard session search.");
|
|
26594
|
-
return resolveSelection(params);
|
|
26550
|
+
return selectPrepared(prepareSelection(projection, params), params, fits, maxChars);
|
|
26595
26551
|
}
|
|
26596
26552
|
function sessionRepresentative(projection, scoped) {
|
|
26597
|
-
const events = filteredItems(projection, scoped).filter(
|
|
26553
|
+
const events = filteredItems(projection, scoped).filter(visible);
|
|
26598
26554
|
if (scoped.roles) return events.at(-1);
|
|
26599
26555
|
return events.find((event) => event.role === "user") ?? events.filter((event) => event.role === "assistant").at(-1) ?? events.at(-1);
|
|
26600
26556
|
}
|
|
26601
|
-
|
|
26602
|
-
|
|
26557
|
+
function eventTime(timestamp) {
|
|
26558
|
+
const at = Date.parse(timestamp ?? "");
|
|
26559
|
+
return Number.isNaN(at) ? -Infinity : at;
|
|
26560
|
+
}
|
|
26561
|
+
var compareCorpus = (a, b) => eventTime(a.event.createdAt) - eventTime(b.event.createdAt) || a.session.localeCompare(b.session) || a.event.seq - b.event.seq;
|
|
26562
|
+
function addContext(page, hits, radius, fits, maxChars) {
|
|
26563
|
+
const key = (session, seq) => `${session ?? ""}\0${seq}`;
|
|
26564
|
+
const seen = new Set(page.items.map((item) => key(item.session, item.seq)));
|
|
26565
|
+
const compare = (a, b) => (isMultiPage(page) ? eventTime(a.created_at) - eventTime(b.created_at) || a.session.localeCompare(b.session) : 0) || a.seq - b.seq;
|
|
26566
|
+
for (let distance = 1; distance <= radius; distance++) {
|
|
26567
|
+
let found = false;
|
|
26568
|
+
for (const { neighbors, session } of hits) {
|
|
26569
|
+
if (!neighbors) continue;
|
|
26570
|
+
for (const index of [neighbors.index - distance, neighbors.index + distance]) {
|
|
26571
|
+
const event = neighbors.events[index];
|
|
26572
|
+
if (!event) continue;
|
|
26573
|
+
found = true;
|
|
26574
|
+
const id2 = key(session, event.seq);
|
|
26575
|
+
if (seen.has(id2)) continue;
|
|
26576
|
+
const item = { ...visibleItem(event, maxChars), ...session === void 0 ? {} : { session }, context: true };
|
|
26577
|
+
const previous = page.items;
|
|
26578
|
+
page.items = [...previous, item].sort(compare);
|
|
26579
|
+
if (!fits(page)) {
|
|
26580
|
+
page.items = previous;
|
|
26581
|
+
return;
|
|
26582
|
+
}
|
|
26583
|
+
seen.add(id2);
|
|
26584
|
+
}
|
|
26585
|
+
}
|
|
26586
|
+
if (!found) return;
|
|
26587
|
+
}
|
|
26588
|
+
}
|
|
26603
26589
|
var CorpusCollector = class {
|
|
26604
26590
|
constructor(scoped) {
|
|
26605
26591
|
this.scoped = scoped;
|
|
@@ -26618,7 +26604,7 @@ var CorpusCollector = class {
|
|
|
26618
26604
|
}
|
|
26619
26605
|
if (this.candidates.length === this.limit) {
|
|
26620
26606
|
this.discarded = true;
|
|
26621
|
-
if (this.scoped.
|
|
26607
|
+
if (this.scoped.after) {
|
|
26622
26608
|
if (low === this.limit) return;
|
|
26623
26609
|
this.candidates.pop();
|
|
26624
26610
|
} else {
|
|
@@ -26638,22 +26624,16 @@ var CorpusCollector = class {
|
|
|
26638
26624
|
/** Returns whether this session contributes an overview representative. */
|
|
26639
26625
|
add(session, projection) {
|
|
26640
26626
|
if (this.scoped.query === void 0) return this.addRepresentative(session, sessionRepresentative(projection, this.scoped));
|
|
26641
|
-
for (const
|
|
26642
|
-
const document = eventDocument(event);
|
|
26643
|
-
if ((event.role === "user" || event.role === "assistant") && document === "") continue;
|
|
26644
|
-
const matchOffset = earliestMatchOffsetChars(document, this.scoped.query);
|
|
26645
|
-
if (matchOffset >= 0) this.admit({ session, event, matchOffset });
|
|
26646
|
-
}
|
|
26627
|
+
for (const hit of queryHits(projection, this.scoped, session)) this.admit(hit);
|
|
26647
26628
|
return true;
|
|
26648
26629
|
}
|
|
26649
26630
|
page(fits, maxChars, unvisited = false) {
|
|
26650
|
-
return selectPrepared({ candidates: this.candidates, multi: true, discarded: this.discarded || unvisited,
|
|
26631
|
+
return selectPrepared({ candidates: this.candidates, multi: true, discarded: this.discarded || unvisited, forward: !!this.scoped.after }, this.scoped, fits, maxChars);
|
|
26651
26632
|
}
|
|
26652
26633
|
};
|
|
26653
26634
|
function selectPrepared(prepared, scoped, fits, maxChars) {
|
|
26654
26635
|
const { candidates } = prepared;
|
|
26655
|
-
const
|
|
26656
|
-
const newest = from === "newest";
|
|
26636
|
+
const newest = scoped.after === void 0;
|
|
26657
26637
|
let start = newest ? candidates.length : 0;
|
|
26658
26638
|
let end = start;
|
|
26659
26639
|
const limit = Math.max(1, scoped.limit ?? 20);
|
|
@@ -26675,6 +26655,7 @@ function selectPrepared(prepared, scoped, fits, maxChars) {
|
|
|
26675
26655
|
}
|
|
26676
26656
|
const page = pageData(prepared, start, end, maxChars);
|
|
26677
26657
|
if (!fits(page)) return { ok: false, pageTooLarge: { count: page.items.length, multi: prepared.multi === true } };
|
|
26658
|
+
if (scoped.context) addContext(page, candidates.slice(start, end), scoped.context, fits, maxChars);
|
|
26678
26659
|
return success(page);
|
|
26679
26660
|
}
|
|
26680
26661
|
|
|
@@ -26765,7 +26746,7 @@ function toolHeader(item) {
|
|
|
26765
26746
|
}
|
|
26766
26747
|
function renderPageItem(item) {
|
|
26767
26748
|
const tool = toolHeader(item);
|
|
26768
|
-
const lines =
|
|
26749
|
+
const lines = [header(item) + (item.context ? " | search context" : ""), ...tool ? [tool] : []];
|
|
26769
26750
|
if (item.truncated) lines.push(`[truncated; from offset ${item.offset_chars ?? 0}]`);
|
|
26770
26751
|
lines.push(item.content);
|
|
26771
26752
|
return lines.join("\n");
|
|
@@ -26774,7 +26755,7 @@ function renderFoldedRow(row) {
|
|
|
26774
26755
|
const tools2 = Object.entries(row.tools).map(([name, count]) => `${name} ${count}`).join(", ");
|
|
26775
26756
|
const identity = row.session === void 0 ? {} : { session: row.session };
|
|
26776
26757
|
const expand = `
|
|
26777
|
-
\u2192 expand: ${JSON.stringify({ ...identity,
|
|
26758
|
+
\u2192 expand: ${JSON.stringify({ ...identity, after: row.first_seq - 1, before: row.last_seq + 1, roles: ["tool", "context"] })}`;
|
|
26778
26759
|
return `${row.session === void 0 ? "" : `session ${row.session} | `}seqs ${row.first_seq}-${row.last_seq} | folded ${row.count} events${tools2 ? ` | ${tools2}` : ""}${expand}`;
|
|
26779
26760
|
}
|
|
26780
26761
|
function renderPage(page) {
|
|
@@ -26784,13 +26765,14 @@ function renderPage(page) {
|
|
|
26784
26765
|
const directions = [page.has_older && "older", page.has_newer && "newer"].filter(Boolean).join("|");
|
|
26785
26766
|
return (page.notice ?? "") + body + (directions ? `
|
|
26786
26767
|
|
|
26787
|
-
\u2192 more ${directions} results: narrow with
|
|
26768
|
+
\u2192 more ${directions} results: narrow with time bounds (after/before), query, roles or the session pattern` : "");
|
|
26788
26769
|
}
|
|
26789
|
-
const
|
|
26790
|
-
const
|
|
26770
|
+
const hits = page.items.filter((item) => !item.context);
|
|
26771
|
+
const first = hits[0];
|
|
26772
|
+
const last = hits.at(-1);
|
|
26791
26773
|
const cursors = [
|
|
26792
|
-
page.has_older ? `\u2192 older: ${JSON.stringify({
|
|
26793
|
-
page.has_newer ? `\u2192 newer: ${JSON.stringify({
|
|
26774
|
+
page.has_older ? `\u2192 older: ${JSON.stringify({ session: first.session, before: first.seq })}` : "",
|
|
26775
|
+
page.has_newer ? `\u2192 newer: ${JSON.stringify({ session: last.session, after: last.seq })}` : ""
|
|
26794
26776
|
].filter((line) => line !== "");
|
|
26795
26777
|
return (page.notice ?? "") + (cursors.length === 0 ? body : `${body}
|
|
26796
26778
|
|
|
@@ -26798,28 +26780,54 @@ ${cursors.join(" | ")}`);
|
|
|
26798
26780
|
}
|
|
26799
26781
|
function renderRead(data) {
|
|
26800
26782
|
const tool = toolHeader(data);
|
|
26801
|
-
const neighborhood = `neighborhood \u2192 \`history_list\`(${JSON.stringify({ ...data.session === void 0 ? {} : { session: data.session },
|
|
26783
|
+
const neighborhood = `neighborhood \u2192 \`history_list\`(${JSON.stringify({ ...data.session === void 0 ? {} : { session: data.session }, after: Math.max(0, data.seq - 10), before: data.seq + 10 })})`;
|
|
26802
26784
|
return (data.notice ?? "") + [header(data), ...tool ? [tool] : [], neighborhood, "", data.total_chars === 0 ? "No visible text recorded for this event." : renderTextWindow(data)].join("\n");
|
|
26803
26785
|
}
|
|
26804
26786
|
var plainText = (text2) => text2;
|
|
26805
26787
|
function pageOutcome(result) {
|
|
26806
26788
|
if (!("pageTooLarge" in result)) return result;
|
|
26807
26789
|
const { count, multi } = result.pageTooLarge;
|
|
26808
|
-
const narrow = multi ? "narrow the session pattern, query, roles or `
|
|
26790
|
+
const narrow = multi ? "narrow the session pattern, query, roles or time bounds (`after`/`before`), or read one session/seq with `history_read`" : "narrow with `after`/`before`, pass `roles` to skip folding, or `history_read` one seq";
|
|
26809
26791
|
return failure2("page_too_large", `Even trimmed to their shortest, these ${count} rows${multi ? "" : " and their folded runs"} fill the ${TOOL_OUTPUT_LIMIT} a call can carry; ${narrow}.`);
|
|
26810
26792
|
}
|
|
26793
|
+
var boundParameter = (description) => typebox_exports.Optional(typebox_exports.Union([typebox_exports.String(), typebox_exports.Number()], { description: `${description} Use a seq (number or digits) or ISO 8601 time (UTC without offset); wildcards take only times.` }));
|
|
26811
26794
|
var historyListParameters = typebox_exports.Object({
|
|
26812
26795
|
session: typebox_exports.Optional(typebox_exports.String({ minLength: 1, description: "Whose record: a session ID or prefix (pi:, claude:, codex:, dsh: allowed). Leave it out for this one. `*` means every recent session." })),
|
|
26813
|
-
query: typebox_exports.Optional(searchQuery("Text to look for, or a list (any match). Searches what was said, tool arguments and output.")),
|
|
26814
26796
|
roles: historyRoles(),
|
|
26815
|
-
|
|
26816
|
-
|
|
26817
|
-
|
|
26818
|
-
|
|
26819
|
-
|
|
26820
|
-
limit: typebox_exports.Optional(typebox_exports.Integer({ minimum: 1, maximum: 500, description: "How many entries per page; folded runs don't count." })),
|
|
26797
|
+
query: typebox_exports.Optional(searchQuery("Text to look for, or a list (any match). Searches what was said, tool arguments and output.")),
|
|
26798
|
+
after: boundParameter("Start strictly after this bound, paging forward; 0 starts at the oldest event."),
|
|
26799
|
+
before: boundParameter("Stop strictly before this bound; without `after`, take the newest eligible events."),
|
|
26800
|
+
context: typebox_exports.Optional(typebox_exports.Integer({ minimum: 0, maximum: Number.MAX_SAFE_INTEGER, description: "Neighboring events on each side of a hit in its own session; requires a query." })),
|
|
26801
|
+
limit: typebox_exports.Optional(typebox_exports.Integer({ minimum: 1, maximum: 500, description: "How many events or hits per page; folds and search context don't count." })),
|
|
26821
26802
|
max_chars_per_item: typebox_exports.Optional(typebox_exports.Integer({ minimum: 1, maximum: MAX_READ_WINDOW_CHARS, description: "How much of each entry to show." }))
|
|
26822
26803
|
}, { additionalProperties: false });
|
|
26804
|
+
var ISO_8601 = /^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/;
|
|
26805
|
+
function parseBound(name, value) {
|
|
26806
|
+
if (value === void 0) return success(void 0);
|
|
26807
|
+
if (typeof value === "number" || /^\d+$/.test(value)) {
|
|
26808
|
+
const seq = Number(value);
|
|
26809
|
+
if (Number.isSafeInteger(seq) && seq >= 0) return success({ seq });
|
|
26810
|
+
} else if (typeof value === "string") {
|
|
26811
|
+
const match = ISO_8601.exec(value);
|
|
26812
|
+
const at = match ? Date.parse(match[1] ? value : `${value}Z`) : NaN;
|
|
26813
|
+
if (!Number.isNaN(at) && new Date(value.slice(0, 10)).toISOString().startsWith(value.slice(0, 10))) return success({ at });
|
|
26814
|
+
}
|
|
26815
|
+
return failure2("invalid_bounds", `\`${name}\` must be a non-negative integer seq or an ISO 8601 time; got ${JSON.stringify(value)}.`);
|
|
26816
|
+
}
|
|
26817
|
+
function parseSelection(params) {
|
|
26818
|
+
const after = parseBound("after", params.after);
|
|
26819
|
+
if (!after.ok) return after;
|
|
26820
|
+
const before = parseBound("before", params.before);
|
|
26821
|
+
if (!before.ok) return before;
|
|
26822
|
+
try {
|
|
26823
|
+
const query = searchQueries(params.query);
|
|
26824
|
+
if (!query.length && params.context !== void 0) return failure2("invalid_params", "`context` requires a non-empty `query`.");
|
|
26825
|
+
return success({ after: after.data, before: before.data, query: query.length ? query : void 0, roles: params.roles, context: params.context, limit: params.limit });
|
|
26826
|
+
} catch (error2) {
|
|
26827
|
+
if (error2 instanceof InvalidQueryError) return failure2("invalid_query", error2.message);
|
|
26828
|
+
throw error2;
|
|
26829
|
+
}
|
|
26830
|
+
}
|
|
26823
26831
|
var historyList = {
|
|
26824
26832
|
name: "history_list",
|
|
26825
26833
|
label: "History list items",
|
|
@@ -26827,32 +26835,34 @@ var historyList = {
|
|
|
26827
26835
|
parameters: historyListParameters,
|
|
26828
26836
|
outputSchema: resultSchema(HistoryPageSchema),
|
|
26829
26837
|
async execute(params, context2, wrapText = plainText) {
|
|
26838
|
+
const selection = parseSelection(params);
|
|
26839
|
+
if (!selection.ok) return selection;
|
|
26840
|
+
const scoped = selection.data;
|
|
26830
26841
|
const fits = (page) => fitsResult(success(page), (result2) => wrapText(renderOutcome(result2, renderPage)));
|
|
26831
26842
|
const maxChars = params.max_chars_per_item ?? HISTORY_PREVIEW_CHARS;
|
|
26832
|
-
if (params.session === void 0) return pageOutcome(selectPage(await currentHistory(context2),
|
|
26843
|
+
if (params.session === void 0) return pageOutcome(selectPage(await currentHistory(context2), scoped, fits, maxChars));
|
|
26833
26844
|
const selector = parseSessionSelector(params.session);
|
|
26834
26845
|
if (!selector.ok) return selector;
|
|
26835
26846
|
const corpus = "corpus" in context2 ? context2.corpus : void 0;
|
|
26836
26847
|
if (selector.data.wildcard) {
|
|
26837
|
-
const
|
|
26838
|
-
if (
|
|
26848
|
+
const { after, before, query, roles } = scoped;
|
|
26849
|
+
if (after && "seq" in after || before && "seq" in before) return failure2("invalid_bounds", "Wildcard history requires times, not seqs, for `after` and `before`.");
|
|
26839
26850
|
if (corpus === void 0) return failure2("unknown_session", "This host supplied no cross-session history corpus.");
|
|
26840
26851
|
const sessions = (await corpus.sessions(selector.data.harness)).filter((session) => matchesSession(session, selector.data));
|
|
26841
|
-
|
|
26842
|
-
|
|
26843
|
-
const
|
|
26844
|
-
const collector = new CorpusCollector(scoped.data);
|
|
26852
|
+
if (!query) sessions.sort((a, b) => (after ? a.modifiedAt - b.modifiedAt : b.modifiedAt - a.modifiedAt) || sessionIdentity(a).localeCompare(sessionIdentity(b)));
|
|
26853
|
+
const representative = !query && !roles && !after && !before;
|
|
26854
|
+
const collector = new CorpusCollector(scoped);
|
|
26845
26855
|
let qualifying = 0;
|
|
26846
26856
|
const notices = [];
|
|
26847
26857
|
let unvisited = false;
|
|
26848
26858
|
for (const [index, session] of sessions.entries()) {
|
|
26849
|
-
const result3 = representative ? await loadHistoryRepresentative(session) : await loadHistorySession(session,
|
|
26859
|
+
const result3 = representative ? await loadHistoryRepresentative(session) : await loadHistorySession(session, query);
|
|
26850
26860
|
if (!result3.ok || !result3.data) continue;
|
|
26851
26861
|
const added = "projection" in result3.data ? collector.add(sessionIdentity(session), result3.data.projection) : collector.addRepresentative(sessionIdentity(session), result3.data.event);
|
|
26852
26862
|
if (!added) continue;
|
|
26853
26863
|
qualifying++;
|
|
26854
26864
|
if (result3.data.notice) notices.push(`session ${sessionIdentity(session)}: ${result3.data.notice}`);
|
|
26855
|
-
if (!
|
|
26865
|
+
if (!query && qualifying >= Math.min(500, Math.max(1, params.limit ?? 20))) {
|
|
26856
26866
|
unvisited = index + 1 < sessions.length;
|
|
26857
26867
|
break;
|
|
26858
26868
|
}
|
|
@@ -26866,7 +26876,7 @@ var historyList = {
|
|
|
26866
26876
|
const loaded = await loadHistorySession(target.data);
|
|
26867
26877
|
if (!loaded.ok) return loaded;
|
|
26868
26878
|
const notice = loaded.data.notice === void 0 ? {} : { notice: loaded.data.notice };
|
|
26869
|
-
const result = pageOutcome(selectPage(loaded.data.projection, { ...
|
|
26879
|
+
const result = pageOutcome(selectPage(loaded.data.projection, { ...scoped, session: sessionIdentity(target.data) }, (page) => fits({ ...page, ...notice }), maxChars));
|
|
26870
26880
|
return result.ok ? success({ ...result.data, ...notice }) : result;
|
|
26871
26881
|
},
|
|
26872
26882
|
render: (result) => renderOutcome(result, renderPage)
|
|
@@ -27684,6 +27694,11 @@ function piHistoryFromJsonl(text2, sessionId) {
|
|
|
27684
27694
|
|
|
27685
27695
|
// src/history/claude.ts
|
|
27686
27696
|
import { isDeepStrictEqual } from "node:util";
|
|
27697
|
+
var UnpersistedClaudeHead = class extends Error {
|
|
27698
|
+
constructor() {
|
|
27699
|
+
super("Claude history active head is not persisted yet; retry after the transcript write");
|
|
27700
|
+
}
|
|
27701
|
+
};
|
|
27687
27702
|
var MESSAGE_TYPES = /* @__PURE__ */ new Set(["user", "assistant", "system", "attachment"]);
|
|
27688
27703
|
var NON_TEXT_BLOCKS = /* @__PURE__ */ new Set(["thinking", "redacted_thinking", "image", "document", "audio", "video", "server_tool_use", "web_search_tool_result", "tool_reference"]);
|
|
27689
27704
|
function object3(value) {
|
|
@@ -27826,7 +27841,7 @@ function claudeHistoryFromRows(rows, source) {
|
|
|
27826
27841
|
return version2.position;
|
|
27827
27842
|
}
|
|
27828
27843
|
if (!source.headUuid) throw new Error("Claude history has no confirmed active head yet; wait for a main-session append after startup/resume");
|
|
27829
|
-
if (!nodes.has(source.headUuid)) throw new
|
|
27844
|
+
if (!nodes.has(source.headUuid)) throw new UnpersistedClaudeHead();
|
|
27830
27845
|
const selected = /* @__PURE__ */ new Set(), visited = /* @__PURE__ */ new Set(), visiting = /* @__PURE__ */ new Set();
|
|
27831
27846
|
const stack = [{ uuid: source.headUuid, historical: false }];
|
|
27832
27847
|
while (stack.length > 0) {
|
|
@@ -27959,7 +27974,7 @@ function createHistoryPrefilter(queries) {
|
|
|
27959
27974
|
}).filter((literal2) => !literal2.test(PRESENTATION));
|
|
27960
27975
|
}));
|
|
27961
27976
|
const fallback = !alternatives.length || alternatives.some((tokens) => tokens.length === 0);
|
|
27962
|
-
return async (chunks, codex = false) => {
|
|
27977
|
+
return async (chunks, codex = false, stopOnHit = false) => {
|
|
27963
27978
|
const decoder = new StringDecoder("utf8");
|
|
27964
27979
|
const seen = alternatives.map((tokens) => tokens.map(() => false));
|
|
27965
27980
|
let rawTail = "", normalizedTail = "", pending = "", possible = fallback;
|
|
@@ -27987,17 +28002,19 @@ function createHistoryPrefilter(queries) {
|
|
|
27987
28002
|
rawTail = raw.slice(-overlap);
|
|
27988
28003
|
normalizedTail = normalized.slice(-overlap);
|
|
27989
28004
|
};
|
|
27990
|
-
for await (const chunk of chunks)
|
|
28005
|
+
for await (const chunk of chunks) {
|
|
28006
|
+
if (!possible) scan(decoder.write(chunk));
|
|
28007
|
+
if (possible && stopOnHit) return true;
|
|
28008
|
+
}
|
|
27991
28009
|
if (!possible) scan(decoder.end(), true);
|
|
27992
28010
|
return possible;
|
|
27993
28011
|
};
|
|
27994
28012
|
}
|
|
27995
28013
|
async function historyFileMayMatch(path, prefilter, codex = false, maxBytes = codex ? CODEX_TRANSCRIPT_MAX_BYTES : Infinity) {
|
|
27996
|
-
if (codex)
|
|
27997
|
-
|
|
27998
|
-
|
|
27999
|
-
|
|
28000
|
-
const compressed = codex && path.endsWith(".jsonl.zst");
|
|
28014
|
+
if (!codex) return prefilter(createReadStream(path), false, true);
|
|
28015
|
+
const info = await stat2(path);
|
|
28016
|
+
if (!info.isFile() || info.size > maxBytes) throw new Error("Unavailable Codex transcript: read size limit exceeded or not a regular file");
|
|
28017
|
+
const compressed = path.endsWith(".jsonl.zst");
|
|
28001
28018
|
if (compressed && typeof zlib2.createZstdDecompress !== "function") throw new Error("Compressed Codex rollouts require Node >=22.15 (createZstdDecompress)");
|
|
28002
28019
|
const input = createReadStream(path);
|
|
28003
28020
|
const consume = async (chunks) => {
|
|
@@ -28510,7 +28527,6 @@ var OPERATIONS = {
|
|
|
28510
28527
|
notes_update: { operation: notesUpdate, history: false },
|
|
28511
28528
|
notes_read: { operation: notesRead, history: false },
|
|
28512
28529
|
notes_list: { operation: notesList, history: false },
|
|
28513
|
-
notes_search: { operation: notesSearch, history: false },
|
|
28514
28530
|
history_list: { operation: historyList, history: true },
|
|
28515
28531
|
history_read: { operation: historyRead, history: true }
|
|
28516
28532
|
};
|
package/plugins/codex/src/mcp.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { CallToolRequestSchema, ListToolsRequestSchema, type CallToolResult, typ
|
|
|
5
5
|
import { Check } from "typebox/value";
|
|
6
6
|
import { paramProblem } from "../../../src/tools/schema.js";
|
|
7
7
|
import type { TSchema } from "typebox";
|
|
8
|
-
import { notesList, notesRead,
|
|
8
|
+
import { notesList, notesRead, notesUpdate, notesWrite } from "../../../src/tools/notes.js";
|
|
9
9
|
import { historyList, historyRead } from "../../../src/tools/history.js";
|
|
10
10
|
import type { Outcome } from "../../../src/result.js";
|
|
11
11
|
import { wireResult, type Operation } from "../../../src/tools/result.js";
|
|
@@ -25,7 +25,6 @@ const OPERATIONS: Record<string, Bound> = {
|
|
|
25
25
|
notes_update: { operation: notesUpdate as unknown as Bound["operation"], history: false },
|
|
26
26
|
notes_read: { operation: notesRead as unknown as Bound["operation"], history: false },
|
|
27
27
|
notes_list: { operation: notesList as unknown as Bound["operation"], history: false },
|
|
28
|
-
notes_search: { operation: notesSearch as unknown as Bound["operation"], history: false },
|
|
29
28
|
history_list: { operation: historyList as unknown as Bound["operation"], history: true },
|
|
30
29
|
history_read: { operation: historyRead as unknown as Bound["operation"], history: true },
|
|
31
30
|
};
|