Add agent output streaming support (#361)#371
Open
jafreck wants to merge 5 commits into
Open
Conversation
…estrator mock (#361) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #371 +/- ##
==========================================
+ Coverage 91.20% 91.23% +0.03%
==========================================
Files 212 213 +1
Lines 22302 22467 +165
Branches 3498 3525 +27
==========================================
+ Hits 20340 20498 +158
- Misses 1915 1921 +6
- Partials 47 48 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds real-time stdout/stderr streaming from agent processes via an optional
onDatacallback threaded through the entire backend invocation stack. Also introduces anAgentOutputEventtype andFleetEventBus.dispatchAgentOutput()for event-bus consumers. Closes #361Changes
Types and Contracts
packages/framework/src/runtime/backend/contract.ts— AddedAgentInvocationOptionsinterface with optionalonData?: (chunk: string, stream: 'stdout' | 'stderr') => voidfield; updatedAgentBackend.invoke()to accept optional thirdoptionsparameter (backward-compatible)packages/framework/src/core/events.ts— AddedAgentOutputEventtype (type: 'agent-output',issueNumber,agent,chunk,stream) and included it inFrameworkLifecycleEventunionCore Streaming Wiring
packages/framework/src/runtime/commands/exec.ts— AddedonDatatoSpawnOpts;spawnProcess()now callsonDataper chunk for both stdout and stderr while preserving bufferedProcessResultpackages/framework/src/runtime/backend/backend.ts— ThreadedAgentInvocationOptionsthroughrunInvokePipeline()and bothCopilotBackend.invoke()/ClaudeBackend.invoke()packages/framework/src/core/event-bus.ts— AddeddispatchAgentOutput()method toFleetEventBusLauncher Propagation
packages/framework/src/runtime/launcher/agent-launcher.ts— UpdatedlaunchAgent()to accept and forwardAgentInvocationOptionssrc/core/agent-launcher.ts— Updated cadre-applaunchAgent()to accept and forward streaming options to the framework backendTests
packages/framework/__tests__/runtime/commands/exec.test.ts— New tests:onDatacalled per-chunk for stdout/stderr, absentonDatadoes not throw, buffered result is correct whenonDatais wiredpackages/framework/__tests__/runtime/backend/contract.test.ts— Tests forAgentInvocationOptionsshape and optionaloptionsparameterpackages/framework/__tests__/core/events.test.ts— Type-narrowing tests forAgentOutputEventviatype === 'agent-output'discriminantpackages/framework/__tests__/runtime/backend/backend.test.ts— Tests verifyingonDatais forwarded through both backendinvoke()implementationspackages/framework/__tests__/core/event-bus.test.ts— Test fordispatchAgentOutput()event shape and dispatch callpackages/framework/__tests__/runtime/launcher/agent-launcher.test.ts— Streaming pass-through testtests/agent-launcher.test.ts— Test verifyingonDatacallback is forwarded to the backendTesting
All tests pass (
npx vitest runexit code 0) and the build succeeds (npm run buildexit code 0). The one noted regression (error: unknown option '--help') is a pre-existing unrelated issue. New unit tests coveronDatacallback invocation at every layer of the stack—spawnProcess(), backendinvoke(),FleetEventBus.dispatchAgentOutput(), and both launcher implementations—verifying that streaming is additive and all callers without options continue to work unchanged.Closes #361