miadi-orchestration-kit

T1 → T8: Pi observability, 2026-10-22

Issue: https://github.com/jgwill/miadi-orchestration-kit/issues/99

Already running on gaia

A local service was prepared before implementation, to let William watch the existing sanitized hooks while the package was built:

Only the mia account was cut over. ~/.pi/agent/settings.json now adds the local package and removes the binscripts extension entry, with unrelated settings preserved. Backup: ~/.pi/agent/settings.json.before-miadi-pi-observability-1792703289496. Other accounts, binscripts’ live code and T8’s reference checkout remain untouched. Existing Pi processes keep their loaded legacy extension until /reload at an idle boundary or restart. Do not inject /reload into a busy agent. A newly started ordinary pi in T8’s directory uses the package without -e.

T8’s first loop

  1. Read README.md for events, limits, privacy and omitted Claude-only capabilities. Keep existing capture active if running; reload only when idle.
  2. Start ordinary Pi from T8’s terminal, or idle-reload an already started process. Find its native session ID in /src/_sessiondata/data/terminal_bindings.jsonl by tmux.session, not by a guessed transcript filename.
  3. Start its explicit local forwarder (a separate supervised terminal/window):

    export OBS_TOKEN_FILE=/home/mia/.local/share/miadi/pi-observability/token
    node /workspace/repos/jgwill/miadi-orchestration-kit/pi/miadi-session-observability/scripts/forward.mjs \
      --session <native-pi-session-id> --watch
    
  4. Open the native session row in the dashboard. Verify a user prompt, tool call/result, failing tool, model change, one token/cost rollup and the prompt/context snapshot references. Do not load the reference repo’s extension/pi-observability.ts alongside this capture: it independently assigns seq from zero and can collide for the same session ID.
  5. T8 can either keep the supplied forwarder or write a consumer of _pi_observability.jsonl. Reuse event IDs and sequence numbers when replaying; never renumber on reconnect. The canonical stream matches shared/types.ts event discriminators/envelope/payload names, with additive schema, miadi, snapshot refs, cost_reported, durations and error correlation. Native Pi turn_index can restart with a new run; use miadi.run_id to distinguish runs and miadi.prompt_id for the most recently observed input event. This does not claim every custom/queued run has a fresh human prompt.
  6. The reference server stores payload and selected envelope fields only: additive schema/miadi envelope metadata is dropped from its SQLite/SSE reconstruction. T1 therefore mirrors correlation in payload.miadi, which survives unchanged; T8 can project that into team/episode/run UI without losing existing records. Do not confuse a terminal team with a dashboard pool.
  7. Snapshot paths are relative to that session’s capture directory, never arbitrary client-supplied host paths. The server currently has no snapshot-file endpoint; T8 must add an authenticated, traversal-safe reader or keep inspection local. The changed prompt is also inline in canonical agent_start, so basic prompt inspection works now. The context event’s snapshot reference does not make the full context magically browser-readable.

Validation performed

Remaining decisions / honest gaps