How maxigp0/opencode-session-bridge works
opencode-session-bridge is an OpenCode v2 plugin for managing independent sessions and orchestrating work across them. The main workflow enters through the registered session tools, validates and authorizes requests, invokes OpenCode session APIs, then waits for the requested turn and formats bounded results. Separate capabilities cover transcript and permission management, ownership tracking, worktrees, and race candidates. The excerpts show selected calls; broader tool capabilities and some subsystem links are grounded in the README, so unsampled internal call paths are not inferred.
Main entry points: tools.ts Session tools · orchestration.ts Session orchestration · worktrees.ts Worktree management · wait.ts Turn waiting
Components 20
Plugin entry
- Plugin setup
index.ts - Session tools
src/tools.ts - Options and policy
src/options.ts - Input validation
src/validation.ts
Session workflows
- Turn waiting
src/wait.ts - Request runtime
src/runtime.ts - Session orchestration
src/orchestration.ts - Background queue
src/queue.ts - Live session state
src/live.ts - Retry state
src/retry.ts
State and output
- Structured output
src/output.ts - Transcript formatting
src/format.ts - Language strings
src/i18n.ts - Ownership registry
src/registry.ts
Project orchestration
- Directory safety
src/directories.ts - Worktree management
src/worktrees.ts - Git operations
src/git.ts - Race candidates
src/races.ts
Other components
- OpenCode agent
- OpenCode host
Connections 26
- OpenCode agent → Plugin setup: invokes tools
README.md - Plugin setup → Session tools: registers
index.ts - Plugin setup → Options and policy: configures
index.ts - Session tools → Input validation: validates input
src/tools.ts - Session tools → Request runtime: guards requests
src/tools.ts - Session tools → OpenCode host: calls session APIs
README.md - Session tools → Turn waiting: waits for turns
src/tools.ts - Session tools → Session orchestration: delegates workflows
src/orchestration.ts - Session tools → Structured output: builds results
src/tools.ts - Turn waiting → OpenCode host: reads events and sessions
src/wait.ts - Turn waiting → Retry state: reads retry state
src/wait.ts - Session orchestration → Turn waiting: waits for turns
src/orchestration.ts - Session orchestration → Ownership registry: records ownership
src/orchestration.ts - Session orchestration → Race candidates: analyzes candidates
src/orchestration.ts - Session orchestration → Worktree management: cleans worktrees
src/orchestration.ts - Session tools → Background queue: tracks queued prompts
README.md - Session tools → Live session state: reports live state
README.md - Structured output → Transcript formatting: renders transcript
src/output.ts - Transcript formatting → Language strings: translates labels
src/format.ts - Ownership registry → Directory safety: keys by directory
src/registry.ts - Worktree management → Directory safety: validates paths
src/worktrees.ts - Worktree management → Git operations: runs Git helpers
src/worktrees.ts - Session tools → Worktree management: manages worktrees
README.md - Session tools → Race candidates: runs race tools
README.md - Race candidates → Git operations: uses patch helpers
src/races.ts - Race candidates → Worktree management: uses candidate worktrees
README.md