# spacetime capsule
deeper owl messaging integration for claude code sessions

## /spt:build-capsule
- downloads the latest `psmux.exe` (https://github.com/psmux/psmux) to `%LOCALAPPDATA%\spt\bin\` (Windows) / `~/.spt/bin/` (Unix), honoring `SPT_HOME` override <!-- updated Phase 18.2 -->
- dynamically creates `[projectroot]/capsule.bat` such that it references the fresh `psmux.exe`

## capsule.bat
- accepts a spacetime `agent_id`, plus
  - optional `-l`/`--live` flag
  - optional `-r`/`--resume <session_id>` flag (forwards to claude code)
- launches `claude --dangerously-skip-permissions` in a psmux named session i.e. `spt-{agent_id}`, also passing a special init prompt into claude which contains `agent_id` and 'live' state (from the flag). the init prompt should use `--system-prompt` or `--append-system-prompt`. which is better? needs researched.

## SessionStart hook
- can hopefully (needs researched) programmatically parse the init prompt to detect the session's `agent_id` and 'live' state
- if `agent_id` was passed, spins up $OWL listen/live --capsule as an external process, and gives the agent the context it needs for understanding how to react to incoming messages (either through additionalContext--the existing path--or through new specially-formatted "user input" which comes by way of `send keys`)

## capsule listener
- forwards all perch messages to the named psmux session in a predefined format, such that the listener/live agent can distinctuate it from normal user input. might be something like preceding the message body with `[INCOMING MESSAGE (timestamp)]: ` uses psmux's `sendkeys` command
- monitors the parent claude code process. if it's dead, performs graceful self-teardown (including psyche, if live)