Run Polytoken as an agent inside the Orca desktop app — no Orca fork,
no upstream changes — by masquerading as the Pi agent entry. Polytoken
sessions launch from Orca's Pi entry, report live working / blocked / done
status to Orca's status chips, and resume into the same conversation via
Orca's Resume.
Orca Pi entry ──> ~/.local/bin/pi (shim)
└─> ~/.config/polytoken/orca-bridge/pi-polytoken (wrapper)
├─ no --session ──> exec polytoken new
└─ --session P ──> exec polytoken continue <id> (P basename)
Polytoken hooks (~/.config/polytoken/hooks.json, 7 managed entries)
└─> ~/.config/polytoken/orca-bridge/orca-pi-hook.sh
├─ session_start -> session_start {session_id, session_file}
├─ pre_user_prompt -> before_agent_start {prompt}
├─ pre_tool_use -> tool_call {tool_name, tool_input} (ask_user_question => blocked)
├─ notification -> tool_call ask_user_question (=> blocked)
├─ post_tool_use(_fail) -> tool_execution_end
└─ stop -> agent_end (=> done)
└─ POST http://127.0.0.1:$PORT/hook/pi (Orca agent-hook listener)
The pinned Orca transport + dialect contract, with provenance for every
fact, lives in docs/orca-pi-contract.md.
- macOS (POSIX) with
sh,curl,jq(macOS ships/usr/bin/jq),node(only for the test-suite fake listener) polytokenon PATH- Orca with Settings → Agents → status hooks enabled (already the default on this machine)
sh bridge/install-bridge.sh --path-shim-forceInstalls pi-polytoken + orca-pi-hook.sh (0755) under
~/.config/polytoken/orca-bridge/, merges the seven managed hook entries
into ~/.config/polytoken/hooks.json (validate → stage → commit; timestamped
backups in orca-bridge/backups/; idempotent; unrelated entries preserved),
and creates the PATH shim ~/.local/bin/pi -> pi-polytoken.
--path-shim-force deliberately shadows a real pi elsewhere on PATH
(this machine has homebrew Pi at /opt/homebrew/bin/pi — it stays intact
and invocable by absolute path; only PATH resolution changes). Without
--force the installer refuses loudly if any other pi exists.
sh bridge/install-wrapper.sh [--path-shim | --path-shim-force]- Settings → Agents: enable Pi (it is disabled by default on this
machine —
settings.disabledTuiAgentscontainspi; the picker entry and--agent piCLI launches are refused while disabled). - Pick Pi from the agent combobox in any worktree. Orca's
pilaunch resolves through the shim to Polytoken. (Verified 2026-08-18: PATH resolution of the shim works in both login-shell panes and direct-exec panes; see "Verification status".)
- Launch: pick Pi in the agent combobox → Polytoken TUI starts in the worktree. Tabs/chips will say "Pi" (accepted trade-off).
- Status: the worktree chip shows
workingduring turns,blocked(worktree status "permission") while a Polytoken question overlay is up,doneat end of turn. - Resume: close the pane, then use Orca's Resume — Orca relaunches
pi --session <log.jsonl>, the wrapper maps it topolytoken continue <session-id>, and the prior conversation is back. - Every wrapper invocation is recorded in
~/.config/polytoken/orca-bridge/pi-polytoken.argv.log(bounded, stdin never logged) — useful to see exactly what Orca passed.
All logic is covered by 79 shell tests runnable anywhere
(sh bridge/test/test_*.sh — no Orca needed). Most recently re-verified
against production Orca 1.4.205 (2026-09-18, self-served via orca CLI
in a scratch worktree; earlier full verification on 1.4.184, 2026-08-18 —
see docs/orca-pi-contract.md §7 for what changed between versions):
| Capability | Status |
|---|---|
| Shim PATH resolution in Orca panes | ✅ verified live (1.4.184 + 1.4.205) |
pi → polytoken new in a real Orca pane |
✅ verified live (1.4.184 + 1.4.205) |
Chip cycle working → done during a real turn |
✅ verified live (1.4.184 + 1.4.205) |
Chip blocked on ask_user_question overlay |
✅ verified live (1.4.184 + 1.4.205; answering the overlay needs the GUI — terminal-sent keystrokes are ignored) |
Resume: pi --session <log.jsonl> → polytoken continue <id>, same session + prior conversation |
✅ verified live (1.4.184 + 1.4.205, sessions-v1 paths) |
| Launch from the Pi picker entry (AC.2) | ✅ delegated — operator accepted the CLI verification as witness (2026-09-18); the combobox path itself was not exercised (Pi remains disabled in Settings → Agents) |
| Orca Resume UI click (vs. the recorded argv shape, already proven) | ✅ delegated — same basis; the pi --session relaunch itself was verified live in a real Orca pane |
Witness decision (2026-09-18): the operator judged the orca-CLI verification sufficient for v0/v1/v2; the tags are cut on that basis. The two UI interactions above remain available as optional extras.
Note: Orca 1.4.205 has no native Polytoken agent (the polytoken
hook files some tools install under ~/.orca/agent-hooks/ belong to an
unreleased upstream PR and their /hook/polytoken route 404s on 1.4.205).
The Pi masquerade remains the only working integration — details in
docs/orca-pi-contract.md §7.2.
The operator accepted the orca-CLI verification as the smoke witness for
all three milestones; v0/v1/v2 are tagged on that basis (2026-09-18, Orca
1.4.205). Note AC.2's combobox launch path itself was never exercised —
Pi is still in disabledTuiAgents — so if you ever enable Pi and want
the UI witnessed too:
- Orca → Settings → Agents: enable Pi (currently disabled;
--agent piCLI launches are refused until then). - Picker smoke (AC.2): open any worktree, pick Pi from the agent
combobox → the Polytoken TUI must start there. Watch the chip:
workingduring a turn,blocked(worktree shows "permission") when you answer a question,doneat rest. The exact launch argv is recorded automatically in~/.config/polytoken/orca-bridge/pi-polytoken.argv.log. - Resume smoke (AC.6): exit the pane (Ctrl-C or /quit), then use Orca's Resume → the same session must come back (same session id, prior conversation visible).
If anything misbehaves: sh bridge/test/test_orca_pi_hook.sh re-validates
the dialect against pinned fixtures; uninstall is one command (below).
- Everything is labeled "Pi" in Orca UI and telemetry (by design).
- Session-history panel: Polytoken sessions do not appear in Orca's Pi session-history listing (Orca scans a Pi-specific store we do not write). Sessions remain resumable via live/recent panes; this is the documented v2 decision (resume-only).
notificationevents are Polytoken harness events (job completions, service restarts), not permission prompts; the bridge surfaces their.summaryas a blocked flash. Real interaction blocking comes fromask_user_question.- Direct-exec panes (
terminal create --command pi, no shell): the Polytoken TUI's cursor-position probe can fail if the pane was never displayed (observed once in a headless worktree). Login-shell panes and visible panes are unaffected; if you hit it, open/switch to the tab and relaunch. - macOS/POSIX only.
sh bridge/uninstall-bridge.sh # removes hooks entries, scripts, our shim
# or, for a wrapper-only install:
sh bridge/uninstall-wrapper.shBoth refuse to touch anything they do not own (retargeted shims, unrelated
orca-* hook entries, real pi binaries). uninstall-bridge.sh is the
one to use once the bridge is installed.
Orca auto-updates; the hook dialect/transport may drift. Re-verify in one
command: sh bridge/test/test_orca_pi_hook.sh (fixtures mirror Orca's own
listener expectations), then check docs/orca-pi-contract.md §7 (drift
notes per Orca release) and §9 (smoke log) for the Orca version each
verification ran against.