Repository navigation
Conversation
javo chat-bridge runs in a chat pod. It starts pi --mode rpc for each active conversation (at most four, idle ones stopped after 10 minutes), reads pi's output split on line feeds only, and turns pi's events into the AI SDK's UI message stream: text, reasoning, tool calls and their results, steps, and a finish with token counts. Parts are tracked by pi's contentIndex, since text and thinking can end after a tool call of the same message starts. Part ids carry the reply's id, so pi's short tool ids stay unique. The system prompt and pi's repeated usage blocks are dropped. History is read back from pi with get_messages. Stop sends abort. A message while a reply streams is refused. Extension dialogs are answered as canceled. Requests the app proxy forwards are refused, and no prompt or reply is logged. The tests replay pi 1.4.0 output recorded in the spike (#26). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A private agents template of kind chat, on the agents environment, that runs javo chat-bridge in place of ttyd. chat-start.sh sets pi's model up with pi-setup.mjs, as the pi template does, then starts the bridge. The model key and API token stay in the helper sidecar. Conversations are kept in ~/.pi/agent/chat-sessions, apart from the terminal's sessions, so pi --continue in the terminal never opens a chat. The app proxy sets X-Javo-App-Proxy on what it forwards to the app, and the bridge refuses it. On a host the bridge listens on loopback only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
List conversations, load one, send a message and stream the reply, and stop a reply. The gateway finds the caller's running chat app among their own apps; the request names a conversation, never an app or an owner. An app's or a job's own token is refused. The pod runs code as its owner, so its answers are checked: JSON answers are re-encoded from known fields, and the reply stream is passed on one event at a time, each a JSON object of a known chunk type, with the gateway's own content type. A stream that breaks off ends with an error and a finish. Chat counts as use of the app for "Stop when idle". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
readEvent read each line with ReadString and checked maxEvent only after it returned, so a chat pod that never sent a line feed grew the gateway's memory without limit. Read with ReadSlice and check the size per chunk, as the bridge's readLine does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QW4EexUmtM5t6pBngqzst3
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.
Closes #28.
What changed
internal/chatbridge,javo chat-bridge): runs in a chat pod and startspi --mode rpcfor each active conversation, at most four at once. Pi processes idle for 10 minutes are stopped. It reads pi's output split on line feeds only.dynamic: true), steps, and a finish with token counts in the message metadata.contentIndex. Part ids carry the reply's id, so pi's short tool ids stay unique.get_messages. Stop sendsabort.chat(kindchat, private,agentsenvironment):chat-start.shrunspi-setup.mjs, then the bridge. The model key and API token stay in the helper sidecar.~/.pi/agent/chat-sessions, apart from the terminal's sessions.X-Javo-App-Proxyand the bridge refuses it, so the app's own address never opens chat. Chat is reached only through/api/chat./api/chat: list conversations, load one, send a message and stream the reply, stop a reply.Why
Pi only ran as a terminal. The chat UI (#29) needs an HTTP endpoint that streams what
useChatreads, routed to a pi that runs as the signed-in person.Differences from the issue
pi --session-idopens that conversation or creates it.~/.pi/agent/chat-sessions, not pi's default folder for the working directory. Otherwisepi --continuein the terminal would reopen the latest chat./api/chat.How to test
On a cluster (
make upwith an agent model configured), create a pi chat app, then:What was checked
make test-localand the pod script tests.Not checked
/opt/javo-env, pi onPATH, the agent lock) and a signed-incurlthrough the real gateway. The issue asks for the Docker and process results to be recorded.restichere) and the shell prompt tests (macOS bash 3.2) fail on this Mac, the same as on cleanmain.Follow-ups
🤖 Generated with Claude Code