Open
Conversation
Add belaykit/pi package that wraps the pi CLI (github.com/badlogic/pi-mono) as a belaykit.Agent implementation. - Runs pi in --mode json for structured JSONL event streaming - Maps pi events to belaykit EventTypes (assistant, tool_use, tool_result, etc.) - Extracts real token usage and cost from pi's usage data in message_end events - Supports pi-specific options: provider, thinking level, tool control, extensions, workdir - Includes PricingForModel/ContextWindowForModel for common models across providers - Full observability integration via RecordCompletion with actual token counts
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.
Add
belaykit/pipackage — a provider that wraps the pi coding agent CLI as abelaykit.Agentimplementation.What it does
Runs
pi --mode json --no-session -p <prompt>and parses the JSONL event stream, mapping pi's events to belaykit'sEventtypes:sessionEventSystemturn_startEventAssistantStartmessage_update(text_delta)EventAssistanttool_execution_startEventToolUsetool_execution_endEventToolResultmessage_endagent_endEventResultPi-specific options
Beyond the standard
WithExecutable,WithDefaultModel,WithDefaultEventHandler,WithObservability:WithDefaultProvider— set LLM provider (anthropic, openai, google, etc.)WithDefaultThinking— set thinking level (off, minimal, low, medium, high, xhigh)WithTools/WithNoTools— control which built-in tools are availableWithExtension— load pi extensionsWithWorkDir— set the working directory for the pi processUsage
Token usage
Unlike shelling out to Claude CLI (which reports cost directly in its result event), pi reports per-message usage in
message_endevents with input/output token counts and cost breakdowns. The provider accumulates these across all messages and passes real numbers toRecordCompletion.Files
pi/pi.go—Clientstruct,Runimplementation, JSONL parserpi/options.go—ClientOptionfunctionspi/models.go—PricingForModel,ContextWindowForModelhelpers