You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
AI code review — automated review for reference; please use your judgment.
packages/core/src/plugin/host.ts:509 — message cursors encode only {id, order, direction} with no sessionID binding, so a cursor issued while paging session A can be replayed against session B where it silently anchors to whatever row matches the embedded id — embed the sessionID (and validate it against input.sessionID on decode) so paginating one session can't be steered by another's cursor.
packages/core/src/plugin/host.ts:487 — cursors are plain base64url JSON of the entire query; any caller can edit workspace, search, order, or parentID inside a returned cursor and hand it back (sessionListQuery re-trusts decoded values) — acceptable for trusted local plugins, but worth an explicit comment documenting the trust model, or an HMAC over the payload if these ever cross a privilege boundary.
packages/core/src/plugin/host.ts:471 — both code paths fail with a bare new Error("Invalid cursor"), and sessionMessages also rejects cursor + order combinations with the same opaque message — plugin authors will have a hard time telling a corrupted cursor from a misuse error — differentiate messages ("cursor is not valid", "pass either cursor or order, not both").
packages/core/test/plugin.test.ts:28 — good happy-path coverage of pagination and protocol passthrough, but no negative tests: invalid base64/JSON, schema-invalid cursor payloads, the cursor+order guard, and (per item 1) a children cursor carrying a forged parentID — those are the branches most likely to rot.
Nit — packages/core/src/plugin/host.ts:458 — limit: input?.limit ?? 50 duplicates the default in two places (sessions and messages); hoist a shared constant so server/pagination defaults stay aligned if they change.
Overall: solid API addition — the cursor design mirrors the client, the effect/promise adapters stay in sync, and the docs table is updated. Item 1 is the only real correctness gap; the rest is hardening. Thanks!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ctx.session.listctx.session.childrenfor direct child traversal andctx.session.messagesfor retained message historyValidation
bun typecheck(packages/client)bun typecheck(packages/plugin)bun typecheck(packages/core)bun test test/plugin.test.ts test/plugin/promise.test.ts(packages/core)Requested by: @rekram1-node (Aiden via Slack)