Repository navigation
Conversation
…s (host.registerPiSessionCompanion)
vitalNohj
force-pushed
the
feat/pi-session-companions
branch
from
November 3, 2026 12:46
dc9ed14 to
18e504c
Compare
Contributor
Author
|
Rebased onto Tests on beta.6: Real-world check. I used a separate Pi Pocket instance built from this branch, with an extension that registers a companion. It ran on a real 42 MB, 5,644-message Pi session that has a companion file beside it.
|
vitalNohj
marked this pull request as ready for review
November 3, 2026 12:46
…ession-companions # Conflicts: # src/server/pi-sessions.ts
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
Some Pi extensions keep a file of their own next to a Pi session file, for example
<session>.jsonl.notes.mdor a state file for that session. When a person continues the session in Pocket, those files need to come along with the conversion. Today the copy gets the conversation and the extension's file is left behind. Only the extension knows what its file means and how to use it in the copy.This adds one experimental extension point,
host.registerPiSessionCompanion. An extension names a suffix. Pocket then:<session>.jsonl<suffix>beside the session file and lists it in the preview ("Includes: …");Pocket never reads, copies or changes the file. It only knows the extension's suffix and label.
Why core (C16)
docs/examples/pi-notes.ts.How
PiSessions.registerCompanionchecks the suffix with/^\.[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/, so a suffix can't contain/or..and can't reach outside the session's folder. It returns a function that removes the registration.stat, regular files only) and returns their labels ascompanions.writePiSessionnow returns which written entry came from which Pi entry. After the commit,continuePiSessionbuilds the copy's context view and calls each companion in turn. Each call has a 60 s limit.continuePiSessionreturns{ id, notes? }, and the sheet adds the notes to its "Continued from Pi" notice.Host.registerPiSessionCompanion,PiSessionCompanionandPiSessionContinuedare intypes/pocket.d.tswith@since 0.28.0 @experimental. They have a reference entry, a row in the API versions table, a guide (docs/extensions/pi-session-companions.md), and a sentence indocs/features.md.Example (separate commit)
docs/examples/pi-notes.tsbrings<session>.jsonl.notes.mdalong. It copies the notes into its own folder and shows them in that session's system prompt, quoted withhost.text.defang. It checks thathost.registerPiSessionCompanionexists, so it still loads on an older Pocket.Tests
test/pi-sessions.test.ts, an extension's file beside Pi's session comes along, uses three companions: one that works, one that throws, and one whose file is missing. It checks that:fromis a real Pi entry id;test/docs-examples.test.tshas a new test for the Pi notes example, end to end, and adds the example to the drop-in list.pi-sessions,docs-examples,model-providers,extension*, docs,public-links) pass, 105 tests.node test/types-file.tsandnode docs-site/check-reference.mjspass, and so does ESLint.Use cases
entriesgives each copied message with the Pi entry it came from, so the extension can translate its ids to the copy's.