The existing abort test mocked the executor to always reject, meaning it
would pass even if the abort wiring was broken. Add a test that actually
fires the caller's AbortSignal and asserts it propagates through the
abortListener -> session.abort() -> internal AbortController -> executor
chain.
Adds 58 tests covering lifecycle events, activity translation, config
buffering, session state persistence, auth setup, error handling, abort,
and concurrent send() guard for both new protocol implementations.
Also fixes a timing bug in RemoteSubagentProtocol where _sessionState was
persisted in a finally block, causing it to be written after the result
promise settled. Moved _saveSessionState() calls to run synchronously
before each _resultResolve/_resultReject so callers see updated
contextId/taskId immediately after getResult() settles.
Introduce LocalSubagentProtocol and RemoteSubagentProtocol that implement
AgentProtocol, wrapping LocalAgentExecutor and A2A client streaming
respectively. LocalSubagentSession and RemoteSubagentSession extend
AgentSession and are the public entry points.
- LocalSubagentProtocol: translates SubagentActivityEvent -> AgentEvent
(THOUGHT_CHUNK->message/thought, TOOL_CALL_START->tool_request,
TOOL_CALL_END->tool_response, ERROR->error). Accepts optional
rawActivityCallback for rich SubagentProgress display without losing
displayName/errorType detail that AgentEvent types do not carry.
- RemoteSubagentProtocol: wraps A2A sendMessageStream, maintains
contextId/taskId session state, tracks SubagentProgress per chunk
for error recovery, and returns a ToolResult with proper
SubagentProgress as returnDisplay.
- LocalSubagentInvocation: now uses LocalSubagentSession internally,
preserving all existing SubagentProgress display logic via
rawActivityCallback. External AbortSignal wired through session.abort().
- RemoteAgentInvocation: now uses RemoteSubagentSession, subscribing
to message events for live progress updates.
- SubagentToolWrapper and SubagentTool: add optional onAgentEvent
callback for future parent session observability (currently unused,
wired through invocation constructors to avoid a second pass later).
- index.ts: export LocalSubagentSession and RemoteSubagentSession.
No behavioral change to SubagentProgress display or ToolResult output.
Co-authored-by: gemini-cli-robot <224641728+gemini-cli-robot@users.noreply.github.com>
Co-authored-by: Sam Roberts <158088236+g-samroberts@users.noreply.github.com>