orb

module
v0.4.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 30, 2026 License: MIT

README

Orb

A faithful, slim, pure-Go port of Mario Zechner's MIT-licensed pi coding agent, built by Ordalie as an SDK-first Go module and a single static CLI binary. Byte-compatible with upstream pi's session format, wire protocols, config files, and extension examples at the pinned upstream version in UPSTREAM.lock; every divergence is recorded in docs/DECISIONS.md. The orb binary deliberately coexists with upstream's pi.

Install

curl -fsSL https://raw.githubusercontent.com/OrdalieTech/orb/main/scripts/install.sh | sh

This installs orb to ~/.local/bin after verifying the release checksum. Override the directory with ORB_INSTALL_DIR; alternatively, with Go ≥ 1.26.5:

go install github.com/OrdalieTech/orb/cmd/orb@latest

Update

Run orb update. It never replaces its running binary; it prints the exact installer or Go command for your installation, while orb update --extensions updates installed pi packages.

First session

export OPENAI_API_KEY=sk-...          # or ANTHROPIC_API_KEY, or run `orb login`
orb                                  # interactive TUI
orb -p "explain this repository"    # headless print mode

Sessions are plain JSONL, interchangeable with upstream pi: a session written by Orb opens in TS pi and vice versa. orb --mode rpc speaks upstream's RPC protocol; upstream's own RPC test suite runs unmodified against it.

Embed the SDK

import "github.com/OrdalieTech/orb/codingagent"

result, err := codingagent.NewAgentSession(codingagent.AgentSessionOptions{})
if err != nil { log.Fatal(err) }
defer result.Session.Dispose()
result.Session.Prompt(context.Background(), "list the files here")

Thirteen runnable examples live in codingagent/examples, from a minimal session to custom tools, providers, and session runtimes — 01_minimal runs offline against the bundled faux provider.

Run an upstream extension

Orb executes many upstream TypeScript extensions unmodified through a local Node.js or Bun host. Fetch the pirate example from the pinned upstream revision and load it:

curl -fsSLO https://raw.githubusercontent.com/earendil-works/pi/845d6ff1f6643aba440341cce877ce1c43ebbc39/packages/coding-agent/examples/extensions/pirate.ts
orb --extension ./pirate.ts

Run /pirate in the TUI to exercise the extension.

61 of upstream's 69 single-file examples run as-is. In a locked snapshot of the 44 most-downloaded valid Pi packages, 43 load and 39 are exact-compatible — 35 with load-and-registration parity plus four event-driven packages with load-only parity — 88.6% by package count and 96.3% weighted by monthly downloads. In a follow-up run where real Pi installed 30 popular packages into isolated projects, Orb loaded 29 and 15 completed live tool or hook workflows. See the ecosystem matrix, the live matrix, and the bridge guide for the exact package-by-package result and remaining runtime ceilings. .pi/extensions/ in a trusted project and the global agent directory are discovered like upstream.

Provenance

Upstream pi is © Mario Zechner, MIT — this port tracks the exact commit in UPSTREAM.lock and regenerates its conformance goldens from upstream source (make fixtures-check). Orb is MIT too; see LICENSE, CONTRIBUTING.md, and SECURITY.md.

Every GitHub release includes a checksummed orb_<version>_source.tar.gz. To verify that source independently, download it with checksums.txt, run sha256sum -c checksums.txt, extract it, and run CGO_ENABLED=0 go build -buildvcs=false ./cmd/orb; release CI performs the same rebuild before publishing. The flag is required because a source archive intentionally contains no .git metadata.

Directories

Path Synopsis
ai
Package ai provides pi's provider-neutral message and streaming contracts.
Package ai provides pi's provider-neutral message and streaming contracts.
api
models
Package models contains the generated model catalog and its persisted refresh overlay.
Package models contains the generated model catalog and its persisted refresh overlay.
models/internal/cataloggen
Package cataloggen normalizes the models.dev api.json shape into pi models.
Package cataloggen normalizes the models.dev api.json shape into pi models.
providers/faux
Package faux provides a scripted, in-memory provider for agent and provider tests.
Package faux provides a scripted, in-memory provider for agent and provider tests.
Package chat implements the core of the orb chat gateway (D27): platform-agnostic messages, the synchronous turn processor with its durable turn ledger, a preview coalescer, and a local single-process runner with a durable spool.
Package chat implements the core of the orb chat gateway (D27): platform-agnostic messages, the synchronous turn processor with its durable turn ledger, a preview coalescer, and a local single-process runner with a durable spool.
discord
Package discord implements the Discord adapter for the orb chat gateway: Gateway (WebSocket) ingress over the internal RFC 6455 client — hello/heartbeat/identify, READY capture, resume-first reconnects — plus REST delivery with a refreshed typing indicator, streamed preview edits, chunked finalization with mass-mention suppression, and pre-signed attachment download.
Package discord implements the Discord adapter for the orb chat gateway: Gateway (WebSocket) ingress over the internal RFC 6455 client — hello/heartbeat/identify, READY capture, resume-first reconnects — plus REST delivery with a refreshed typing indicator, streamed preview edits, chunked finalization with mass-mention suppression, and pre-signed attachment download.
examples/localbot command
Command localbot runs a minimal Telegram chat gateway: long-poll ingress, the durable local spool, and per-conversation agent sessions under a local data directory.
Command localbot runs a minimal Telegram chat gateway: long-poll ingress, the durable local spool, and per-conversation agent sessions under a local data directory.
googlechat
Package googlechat implements the Google Chat adapter for the orb chat gateway: an HTTP-endpoint Chat app with bearer-JWT-verified ingress, service-account authenticated delivery, and authenticated media download.
Package googlechat implements the Google Chat adapter for the orb chat gateway: an HTTP-endpoint Chat app with bearer-JWT-verified ingress, service-account authenticated delivery, and authenticated media download.
internal/ctxsleep
Package ctxsleep provides a context-aware sleep shared by the chat adapters and processor.
Package ctxsleep provides a context-aware sleep shared by the chat adapters and processor.
internal/graphhook
Package graphhook holds the Meta Graph webhook plumbing shared by the Cloud API chat adapters (WhatsApp today, Messenger next): the one-time hub.challenge subscribe handshake and the X-Hub-Signature-256 raw-body HMAC check.
Package graphhook holds the Meta Graph webhook plumbing shared by the Cloud API chat adapters (WhatsApp today, Messenger next): the one-time hub.challenge subscribe handshake and the X-Hub-Signature-256 raw-body HMAC check.
internal/runechunk
Package runechunk splits platform text at readable rune boundaries.
Package runechunk splits platform text at readable rune boundaries.
internal/wsclient
Package wsclient implements a minimal RFC 6455 WebSocket client on the standard library alone: client role only, no extensions, no compression, no subprotocol negotiation.
Package wsclient implements a minimal RFC 6455 WebSocket client on the standard library alone: client role only, no extensions, no compression, no subprotocol negotiation.
messenger
Package messenger implements the Facebook Messenger (Meta Messenger Platform for Pages) adapter for the orb chat gateway: webhook ingress over the Graph "page" object (hub handshake + HMAC-signed entry[].messaging[] events), final-message delivery via the Send API, sender-action typing, and direct-URL attachment download.
Package messenger implements the Facebook Messenger (Meta Messenger Platform for Pages) adapter for the orb chat gateway: webhook ingress over the Graph "page" object (hub handshake + HMAC-signed entry[].messaging[] events), final-message delivery via the Send API, sender-action typing, and direct-URL attachment download.
slack
Package slack implements the Slack adapter for the orb chat gateway: Events API ingress over HTTP (v0 request signing, url_verification handshake, echo filtering), Web API delivery with a bot token (streamed preview edits via chat.update, mrkdwn finalization with chunking), and authenticated file download.
Package slack implements the Slack adapter for the orb chat gateway: Events API ingress over HTTP (v0 request signing, url_verification handshake, echo filtering), Web API delivery with a bot token (streamed preview edits via chat.update, mrkdwn finalization with chunking), and authenticated file download.
teams
Package teams implements the Microsoft Teams (Bot Framework) adapter for the orb chat gateway, speaking the raw connector REST API with no SDK: JWT-validated webhook ingress, typing plus final-only delivery, markdown-subset formatting with UTF-16 chunking, and authenticated attachment download.
Package teams implements the Microsoft Teams (Bot Framework) adapter for the orb chat gateway, speaking the raw connector REST API with no SDK: JWT-validated webhook ingress, typing plus final-only delivery, markdown-subset formatting with UTF-16 chunking, and authenticated attachment download.
telegram
Package telegram implements the Telegram Bot API adapter for the orb chat gateway: ingress (webhook and long poll), delivery (typing indicator, streamed preview edits, HTML finalization with chunking), and media download.
Package telegram implements the Telegram Bot API adapter for the orb chat gateway: ingress (webhook and long poll), delivery (typing indicator, streamed preview edits, HTML finalization with chunking), and media download.
whatsapp
Package whatsapp implements the WhatsApp Business Cloud API adapter for the orb chat gateway: webhook ingress (hub handshake + HMAC-signed events), final-message delivery with reply threading, and authenticated media download.
Package whatsapp implements the WhatsApp Business Cloud API adapter for the orb chat gateway: webhook ingress (hub handshake + HMAC-signed events), final-message delivery with reply threading, and authenticated media download.
cmd
orb command
Package codingagent provides the high-level SDK for embedding pi's agent capabilities in Go programs.
Package codingagent provides the high-level SDK for embedding pi's agent capabilities in Go programs.
examples/01_minimal command
Minimal SDK usage with all defaults.
Minimal SDK usage with all defaults.
examples/02_custom_model command
Custom model selection and thinking level.
Custom model selection and thinking level.
examples/03_custom_prompt command
Custom system prompt replacement and extension through DefaultResourceLoader.
Custom system prompt replacement and extension through DefaultResourceLoader.
examples/04_skills command
Skills configuration through DefaultResourceLoader discovery and overrides.
Skills configuration through DefaultResourceLoader discovery and overrides.
examples/05_tools command
Tools configuration: tool allowlists and denylists.
Tools configuration: tool allowlists and denylists.
examples/06_extensions command
Extensions configuration through DefaultResourceLoader inline factories.
Extensions configuration through DefaultResourceLoader inline factories.
examples/07_context_files command
Context files discovered and extended through DefaultResourceLoader.
Context files discovered and extended through DefaultResourceLoader.
examples/08_prompt_templates command
Prompt templates discovered and extended through DefaultResourceLoader.
Prompt templates discovered and extended through DefaultResourceLoader.
examples/09_api_keys command
API key and OAuth configuration through ModelRegistry and runtime callbacks.
API key and OAuth configuration through ModelRegistry and runtime callbacks.
examples/10_settings command
Settings configuration through SettingsManager.
Settings configuration through SettingsManager.
examples/11_sessions command
Session management: in-memory, persistent, continue, list, and open.
Session management: in-memory, persistent, continue, list, and open.
examples/12_full_control command
Full control: explicit model, settings, session, ResourceLoader, and tools.
Full control: explicit model, settings, session, ResourceLoader, and tools.
examples/13_session_runtime command
Session runtime demonstrates recreating cwd-bound services when the active AgentSession is replaced and rebinding session-local host state.
Session runtime demonstrates recreating cwd-bound services when the active AgentSession is replaced and rebinding session-local host state.
extensions
Package extensions provides the Go-native extension registry, API surface, and ordered event runner used by the coding agent.
Package extensions provides the Go-native extension registry, API surface, and ordered event runner used by the coding agent.
extensions/host
Package host implements orb's original out-of-process JavaScript extension host protocol and lifecycle manager.
Package host implements orb's original out-of-process JavaScript extension host protocol and lifecycle manager.
mcp
Package mcp implements orb's bundled, settings-driven MCP extension.
Package mcp implements orb's bundled, settings-driven MCP extension.
modes
Package modes contains coding-agent run-mode orchestration.
Package modes contains coding-agent run-mode orchestration.
plugins
Package plugins contains orb's bundled, default-off first-party extensions.
Package plugins contains orb's bundled, default-off first-party extensions.
session
Package session stores coding-agent conversations as pi-compatible JSONL trees.
Package session stores coding-agent conversations as pi-compatible JSONL trees.
conformance
runner
Package runner provides shared conformance-fixture test helpers.
Package runner provides shared conformance-fixture test helpers.
internal
filelock
Package filelock takes locks that upstream pi can interoperate with.
Package filelock takes locks that upstream pi can interoperate with.
ignorerules
Package ignorerules holds the shared gitignore-rule matching loop that both skill loaders (agent/harness and codingagent) port from the npm `ignore` dependency.
Package ignorerules holds the shared gitignore-rule matching loop that both skill loaders (agent/harness and codingagent) port from the npm `ignore` dependency.
jstrim
Package jstrim ports the ECMAScript String.prototype.trim whitespace set (WhiteSpace + LineTerminator), which differs from Go's unicode.IsSpace.
Package jstrim ports the ECMAScript String.prototype.trim whitespace set (WhiteSpace + LineTerminator), which differs from Go's unicode.IsSpace.
partialjson
Package partialjson parses the incomplete JSON emitted while tool-call arguments are streaming.
Package partialjson parses the incomplete JSON emitted while tool-call arguments are streaming.
semver
Package semver implements the subset of npm's semver used by pi package management: exact versions, ranges (^ ~ x-ranges, hyphen, ||, primitives), Satisfies and MaxSatisfying with npm's prerelease-inclusion rule.
Package semver implements the subset of npm's semver used by pi package management: exact versions, ranges (^ ~ x-ranges, hyphen, ||, primitives), Satisfies and MaxSatisfying with npm's prerelease-inclusion rule.
sync
Package upstreamsync analyzes and promotes pinned upstream revisions.
Package upstreamsync analyzes and promotes pinned upstream revisions.
uuidv7
Package uuidv7 generates the monotonic UUID and short entry identifiers used by upstream harness session storage.
Package uuidv7 generates the monotonic UUID and short entry identifiers used by upstream harness session storage.
Package memory defines orb's root-level durable memory SDK seam.
Package memory defines orb's root-level durable memory SDK seam.
agent
Package agentmemory attaches Orb's bounded persistent memory to a plain agent.Agent.
Package agentmemory attaches Orb's bounded persistent memory to a plain agent.Agent.
Package tui provides pi's differential terminal renderer and components.
Package tui provides pi's differential terminal renderer and components.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL