Commit Graph

12 Commits

Author SHA1 Message Date
ismeth 9a39c423d4 fix(switch-agent): detect HTTP error responses from SDK client on TUI navigation
The v1 SDK client does not throw on 4xx/5xx — it resolves with an
{ error } object. navigateTuiToSession was treating any resolved promise
as success, silently misreporting failed navigation.
2026-04-15 16:48:50 +09:00
ismeth 0b604c8d35 fix(switch-agent): use direct HTTP POST for TUI navigation instead of missing SDK method
The v1 SDK Tui class has no selectSession method (only exists in v2).
Commit 4150e26d regressed this by replacing the working _client.post()
direct HTTP call with client.tui.selectSession() which silently failed.

Reverts to bypassing the SDK and POSTing to /tui/select-session directly,
which works regardless of SDK version.
2026-04-15 16:48:50 +09:00
ismeth 597fdb7a51 fix(switch-agent): correct selectSession call signature for TUI navigation
- Fix TuiService type to match actual API: { body: { sessionID } }
- Fix selectSession call arg shape (was { sessionID }, now { body: { sessionID } })
- Add logging on both TUI failure paths (service unavailable / navigation error)
- Remove redundant inline idle-handling from polling path (already handled by
  event-based session-idle-event-handler)
2026-04-15 16:48:50 +09:00
ismeth 37f03b4238 fix(switch-agent): use native tui.selectSession, use cross-platform symlink test target 2026-04-15 16:48:50 +09:00
ismeth 68cd8814d8 refactor(switch-agent): replace as-any with type guard, use const tuple for agent names 2026-04-15 16:48:49 +09:00
ismeth 102b754f1e fix(athena): remove athena primary from delegation list and switch_agent targets
Athena primary should not be routable via switch_agent or appear in the
delegation table. Only athena-junior (subagent) remains delegatable via task().

- Remove athena from ALLOWED_AGENTS and DESCRIPTION in switch-agent tool
- Remove ATHENA_PROMPT_METADATA from agentMetadata, agent.ts, barrel export
- Update switch-agent test to assert athena rejection
- Remove ATHENA_PROMPT_METADATA test block
2026-04-15 16:48:47 +09:00
ismeth efc53de531 feat(athena): complete delegation routing fix with mode-aware delegation table
- Re-add ATHENA_PROMPT_METADATA with tight triggers and avoidWhen guardrails
- Update switch_agent tool description with permanent handoff guardrail
- Make buildDelegationTable mode-aware: switch_agent for primary, task() for subagent
- Pass agent mode through general-agents to AvailableAgent interface
- Improve primary agent error messages in subagent-resolver with alternatives
- Add council-first bias to Athena interactive prompt
- Update athena-junior trigger text for clearer task() invocation guidance
- Add tests for ATHENA_PROMPT_METADATA shape, triggers, useWhen, avoidWhen
2026-04-15 16:48:46 +09:00
ismeth e01742c8b2 feat(athena): add athena to switch-agent and call-omo-agent allowed lists 2026-04-15 16:48:45 +09:00
ismeth 34faa7c67c refactor(switch-agent): replace deferred hook system with direct session.create + promptAsync
Adopt the opencode-handoff pattern: switch_agent now creates a new session
and sends the context via promptAsync immediately in the tool's execute
function, then navigates the TUI to the new session.

Removes ~1700 LOC of complexity: persistent state management, event-based
hook monitoring, retry logic, session idle waiting, apply verification,
and terminal detection — all replaced by 3 SDK calls.

Deleted: src/features/agent-switch/ (14 files), src/hooks/agent-switch/ (4 files)
Updated: Athena prompt to announce handoff before calling switch_agent
2026-04-15 16:48:01 +09:00
ismeth e52ccd1b04 fix(agent-switch): create fresh session for handoff apply 2026-04-15 16:47:37 +09:00
ismeth 8de10c1f2b fix(agent-switch): make handoff durable and sync CLI TUI selection 2026-04-15 16:18:19 +09:00
ismeth 84185490f9 refactor(athena): rename session_handoff to switch_agent to avoid confusion with /handoff command
Rename across all layers to eliminate naming ambiguity:
- Tool: session_handoff → switch_agent
- Hook: agent-handoff → agent-switch
- Feature: agent-handoff/ → agent-switch/
- Types: SessionHandoffArgs → SwitchAgentArgs, PendingHandoff → PendingSwitch
- Functions: setPendingHandoff → setPendingSwitch, consumePendingHandoff → consumePendingSwitch

/handoff = inter-session context summary (existing command)
switch_agent = intra-session active agent change (our new tool)
2026-04-15 15:47:13 +09:00