@prmichaelsen/acp-mcp 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -0
- package/README.md +10 -3
- package/agent/design/local.progress-streaming.md +940 -0
- package/agent/milestones/milestone-4-progress-streaming-server.md +84 -0
- package/agent/milestones/milestone-5-progress-streaming-wrapper.md +71 -0
- package/agent/milestones/milestone-6-progress-streaming-client.md +79 -0
- package/agent/progress.yaml +93 -13
- package/agent/tasks/milestone-4-progress-streaming-server/task-6-add-ssh-stream-execution.md +149 -0
- package/agent/tasks/milestone-4-progress-streaming-server/task-7-implement-progress-streaming.md +191 -0
- package/agent/tasks/milestone-4-progress-streaming-server/task-8-update-server-handlers.md +109 -0
- package/agent/tasks/milestone-4-progress-streaming-server/task-9-testing-documentation.md +192 -0
- package/dist/server-factory.js +130 -6
- package/dist/server-factory.js.map +2 -2
- package/dist/server.js +130 -6
- package/dist/server.js.map +2 -2
- package/dist/tools/acp-remote-execute-command.d.ts +4 -1
- package/dist/utils/ssh-connection.d.ts +13 -0
- package/package.json +1 -1
- package/src/server-factory.ts +3 -2
- package/src/server.ts +3 -2
- package/src/tools/acp-remote-execute-command.ts +116 -7
- package/src/utils/ssh-connection.ts +66 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Milestone 4: Progress Streaming - Server Implementation (acp-mcp)
|
|
2
|
+
|
|
3
|
+
**Goal**: Implement server-side progress streaming support in acp-mcp
|
|
4
|
+
**Duration**: 1 week
|
|
5
|
+
**Dependencies**: None
|
|
6
|
+
**Status**: Not Started
|
|
7
|
+
**Project**: acp-mcp (this project)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
Implement the server-side infrastructure for real-time progress streaming in acp-mcp. This includes SSH streaming execution, progress notification sending, and graceful fallback for clients that don't support progress.
|
|
14
|
+
|
|
15
|
+
This milestone focuses ONLY on the acp-mcp server implementation. Client-side changes (mcp-auth, agentbase.me) are separate milestones.
|
|
16
|
+
|
|
17
|
+
## Deliverables
|
|
18
|
+
|
|
19
|
+
- ✅ SSH streaming execution method (`execStream()`)
|
|
20
|
+
- ✅ Progress notification support in `acp_remote_execute_command`
|
|
21
|
+
- ✅ Graceful fallback to timeout mode
|
|
22
|
+
- ✅ Rate limiting for progress notifications
|
|
23
|
+
- ✅ Comprehensive error handling
|
|
24
|
+
- ✅ Unit and integration tests
|
|
25
|
+
- ✅ Documentation updates
|
|
26
|
+
|
|
27
|
+
## Success Criteria
|
|
28
|
+
|
|
29
|
+
- [ ] `execStream()` method implemented in SSHConnectionManager
|
|
30
|
+
- [ ] `acp_remote_execute_command` sends progress notifications when `progressToken` provided
|
|
31
|
+
- [ ] Falls back to timeout mode when no `progressToken`
|
|
32
|
+
- [ ] Progress notifications include stdout chunks
|
|
33
|
+
- [ ] Rate limiting prevents notification spam
|
|
34
|
+
- [ ] All existing tests still pass
|
|
35
|
+
- [ ] New tests for streaming added
|
|
36
|
+
- [ ] TypeScript compiles without errors
|
|
37
|
+
- [ ] Build completes successfully
|
|
38
|
+
- [ ] README.md documents progress support
|
|
39
|
+
- [ ] CHANGELOG.md updated for v0.7.0
|
|
40
|
+
- [ ] Version bumped to 0.7.0
|
|
41
|
+
|
|
42
|
+
## Key Files to Create
|
|
43
|
+
|
|
44
|
+
- None (all modifications to existing files)
|
|
45
|
+
|
|
46
|
+
## Key Files to Modify
|
|
47
|
+
|
|
48
|
+
- `src/utils/ssh-connection.ts` - Add `execStream()` method
|
|
49
|
+
- `src/tools/acp-remote-execute-command.ts` - Add progress streaming
|
|
50
|
+
- `src/server.ts` - Pass `extra` parameter to handlers
|
|
51
|
+
- `src/server-factory.ts` - Pass `extra` parameter to handlers
|
|
52
|
+
- `README.md` - Document progress support
|
|
53
|
+
- `CHANGELOG.md` - v0.7.0 entry
|
|
54
|
+
- `package.json` - Version bump
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## Tasks
|
|
59
|
+
|
|
60
|
+
### Task 6: Add SSH Stream Execution Method
|
|
61
|
+
**File**: `agent/tasks/milestone-4-progress-streaming-server/task-6-add-ssh-stream-execution.md`
|
|
62
|
+
**Estimated**: 3-4 hours
|
|
63
|
+
**Priority**: High
|
|
64
|
+
|
|
65
|
+
### Task 7: Implement Progress Streaming in Execute Command
|
|
66
|
+
**File**: `agent/tasks/milestone-4-progress-streaming-server/task-7-implement-progress-streaming.md`
|
|
67
|
+
**Estimated**: 4-5 hours
|
|
68
|
+
**Priority**: High
|
|
69
|
+
|
|
70
|
+
### Task 8: Update Server Request Handlers
|
|
71
|
+
**File**: `agent/tasks/milestone-4-progress-streaming-server/task-8-update-server-handlers.md`
|
|
72
|
+
**Estimated**: 1-2 hours
|
|
73
|
+
**Priority**: Medium
|
|
74
|
+
|
|
75
|
+
### Task 9: Testing and Documentation
|
|
76
|
+
**File**: `agent/tasks/milestone-4-progress-streaming-server/task-9-testing-documentation.md`
|
|
77
|
+
**Estimated**: 3-4 hours
|
|
78
|
+
**Priority**: High
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
**Next Milestone**: M5 - Progress Streaming - Wrapper Integration (mcp-auth)
|
|
83
|
+
**Blockers**: None
|
|
84
|
+
**Related Design**: [`agent/design/local.progress-streaming.md`](../design/local.progress-streaming.md)
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Milestone 5: Progress Streaming - Wrapper Integration (mcp-auth)
|
|
2
|
+
|
|
3
|
+
**Goal**: Integrate progress streaming support in mcp-auth wrapper
|
|
4
|
+
**Duration**: 3-5 days
|
|
5
|
+
**Dependencies**: M4 (acp-mcp server implementation)
|
|
6
|
+
**Status**: Not Started
|
|
7
|
+
**Project**: mcp-auth (separate repository)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
Update the mcp-auth wrapper to pass through progress notifications from acp-mcp to clients. This enables progress streaming for multi-tenant deployments where mcp-auth sits between clients and acp-mcp servers.
|
|
14
|
+
|
|
15
|
+
**Note**: This milestone is for a DIFFERENT project (mcp-auth). Implementation happens in the mcp-auth repository, not acp-mcp.
|
|
16
|
+
|
|
17
|
+
## Deliverables
|
|
18
|
+
|
|
19
|
+
- ✅ Progress token pass-through from client to acp-mcp
|
|
20
|
+
- ✅ Progress notification forwarding from acp-mcp to client
|
|
21
|
+
- ✅ Per-user progress tracking (multi-tenant)
|
|
22
|
+
- ✅ Error handling for progress failures
|
|
23
|
+
- ✅ Testing with multiple concurrent users
|
|
24
|
+
- ✅ Documentation updates
|
|
25
|
+
|
|
26
|
+
## Success Criteria
|
|
27
|
+
|
|
28
|
+
- [ ] mcp-auth passes `progressToken` from client to acp-mcp
|
|
29
|
+
- [ ] mcp-auth forwards progress notifications from acp-mcp to correct client
|
|
30
|
+
- [ ] Multiple users can stream progress simultaneously
|
|
31
|
+
- [ ] Progress notifications don't leak between users
|
|
32
|
+
- [ ] Existing functionality unaffected
|
|
33
|
+
- [ ] Tests verify progress pass-through
|
|
34
|
+
- [ ] Documentation updated
|
|
35
|
+
|
|
36
|
+
## Key Files to Create
|
|
37
|
+
|
|
38
|
+
- `src/progress-manager.ts` - Manage per-user progress streams (in mcp-auth)
|
|
39
|
+
|
|
40
|
+
## Key Files to Modify
|
|
41
|
+
|
|
42
|
+
- `src/server-factory.ts` - Pass through progressToken (in mcp-auth)
|
|
43
|
+
- `src/notification-handler.ts` - Forward progress notifications (in mcp-auth)
|
|
44
|
+
- `README.md` - Document progress support (in mcp-auth)
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Tasks
|
|
49
|
+
|
|
50
|
+
### Task 10: Implement Progress Token Pass-Through
|
|
51
|
+
**Project**: mcp-auth
|
|
52
|
+
**Estimated**: 2-3 hours
|
|
53
|
+
|
|
54
|
+
### Task 11: Implement Progress Notification Forwarding
|
|
55
|
+
**Project**: mcp-auth
|
|
56
|
+
**Estimated**: 3-4 hours
|
|
57
|
+
|
|
58
|
+
### Task 12: Add Multi-Tenant Progress Tracking
|
|
59
|
+
**Project**: mcp-auth
|
|
60
|
+
**Estimated**: 2-3 hours
|
|
61
|
+
|
|
62
|
+
### Task 13: Testing and Documentation (mcp-auth)
|
|
63
|
+
**Project**: mcp-auth
|
|
64
|
+
**Estimated**: 2-3 hours
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
**Next Milestone**: M6 - Progress Streaming - Client Integration (agentbase.me)
|
|
69
|
+
**Blockers**: M4 must be complete
|
|
70
|
+
**Related Design**: [`agent/design/local.progress-streaming.md`](../design/local.progress-streaming.md)
|
|
71
|
+
**Repository**: https://github.com/prmichaelsen/mcp-auth (separate project)
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Milestone 6: Progress Streaming - Client Integration (agentbase.me)
|
|
2
|
+
|
|
3
|
+
**Goal**: Implement client-side progress streaming UI in agentbase.me
|
|
4
|
+
**Duration**: 1 week
|
|
5
|
+
**Dependencies**: M4 (server), M5 (wrapper)
|
|
6
|
+
**Status**: Not Started
|
|
7
|
+
**Project**: agentbase.me (separate repository)
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
Build the client-side UI for displaying real-time progress from long-running commands. This includes progress bars, live output streaming, and user controls for managing long-running processes.
|
|
14
|
+
|
|
15
|
+
**Note**: This milestone is for a DIFFERENT project (agentbase.me). Implementation happens in the agentbase.me repository, not acp-mcp.
|
|
16
|
+
|
|
17
|
+
## Deliverables
|
|
18
|
+
|
|
19
|
+
- ✅ Progress UI component for command execution
|
|
20
|
+
- ✅ Real-time output streaming display
|
|
21
|
+
- ✅ Progress bar with percentage (when available)
|
|
22
|
+
- ✅ Cancel/stop button for long-running commands
|
|
23
|
+
- ✅ History of streamed output
|
|
24
|
+
- ✅ Error handling and retry logic
|
|
25
|
+
- ✅ User preferences for progress display
|
|
26
|
+
|
|
27
|
+
## Success Criteria
|
|
28
|
+
|
|
29
|
+
- [ ] UI displays progress notifications in real-time
|
|
30
|
+
- [ ] Users can see live output from commands
|
|
31
|
+
- [ ] Progress bar updates as command executes
|
|
32
|
+
- [ ] Users can cancel long-running commands
|
|
33
|
+
- [ ] Output history is preserved and scrollable
|
|
34
|
+
- [ ] Errors are displayed clearly
|
|
35
|
+
- [ ] Works on desktop and mobile
|
|
36
|
+
- [ ] Accessible (WCAG 2.1 AA)
|
|
37
|
+
|
|
38
|
+
## Key Files to Create
|
|
39
|
+
|
|
40
|
+
- `components/ProgressStream.tsx` - Progress streaming component (in agentbase.me)
|
|
41
|
+
- `hooks/useProgressStream.ts` - Progress streaming hook (in agentbase.me)
|
|
42
|
+
- `services/progress-service.ts` - Progress notification handler (in agentbase.me)
|
|
43
|
+
|
|
44
|
+
## Key Files to Modify
|
|
45
|
+
|
|
46
|
+
- `components/CommandExecutor.tsx` - Integrate progress UI (in agentbase.me)
|
|
47
|
+
- `services/mcp-client.ts` - Handle progress callbacks (in agentbase.me)
|
|
48
|
+
- `styles/progress.css` - Progress UI styles (in agentbase.me)
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Tasks
|
|
53
|
+
|
|
54
|
+
### Task 14: Create Progress UI Component
|
|
55
|
+
**Project**: agentbase.me
|
|
56
|
+
**Estimated**: 4-6 hours
|
|
57
|
+
|
|
58
|
+
### Task 15: Implement Progress Streaming Hook
|
|
59
|
+
**Project**: agentbase.me
|
|
60
|
+
**Estimated**: 3-4 hours
|
|
61
|
+
|
|
62
|
+
### Task 16: Integrate with MCP Client
|
|
63
|
+
**Project**: agentbase.me
|
|
64
|
+
**Estimated**: 2-3 hours
|
|
65
|
+
|
|
66
|
+
### Task 17: Add User Controls (Cancel, Pause)
|
|
67
|
+
**Project**: agentbase.me
|
|
68
|
+
**Estimated**: 3-4 hours
|
|
69
|
+
|
|
70
|
+
### Task 18: Testing and Polish
|
|
71
|
+
**Project**: agentbase.me
|
|
72
|
+
**Estimated**: 4-5 hours
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
**Next Milestone**: None (feature complete)
|
|
77
|
+
**Blockers**: M4 and M5 must be complete
|
|
78
|
+
**Related Design**: [`agent/design/local.progress-streaming.md`](../design/local.progress-streaming.md)
|
|
79
|
+
**Repository**: https://github.com/prmichaelsen/agentbase.me (separate project)
|
package/agent/progress.yaml
CHANGED
|
@@ -3,7 +3,7 @@ project:
|
|
|
3
3
|
version: 0.6.0
|
|
4
4
|
started: 2026-02-22
|
|
5
5
|
status: in_progress
|
|
6
|
-
current_milestone:
|
|
6
|
+
current_milestone: M4
|
|
7
7
|
description: |
|
|
8
8
|
MCP server for remote machine operations via SSH.
|
|
9
9
|
Provides core tools for executing commands, reading/writing files,
|
|
@@ -41,7 +41,7 @@ milestones:
|
|
|
41
41
|
|
|
42
42
|
- id: M3
|
|
43
43
|
name: Enhancements and Additional Features
|
|
44
|
-
status:
|
|
44
|
+
status: completed
|
|
45
45
|
progress: 100%
|
|
46
46
|
started: 2026-02-23
|
|
47
47
|
completed: 2026-02-23
|
|
@@ -52,6 +52,20 @@ milestones:
|
|
|
52
52
|
Fixed critical bug with incomplete directory listings.
|
|
53
53
|
Implemented comprehensive file metadata in list_files tool.
|
|
54
54
|
Breaking change released as v0.6.0.
|
|
55
|
+
|
|
56
|
+
- id: M4
|
|
57
|
+
name: Progress Streaming - Server Implementation
|
|
58
|
+
status: in_progress
|
|
59
|
+
progress: 25%
|
|
60
|
+
started: null
|
|
61
|
+
completed: null
|
|
62
|
+
estimated_weeks: 1
|
|
63
|
+
tasks_completed: 1
|
|
64
|
+
tasks_total: 4
|
|
65
|
+
notes: |
|
|
66
|
+
Implement real-time progress streaming for long-running commands.
|
|
67
|
+
Uses MCP SDK's native progress notification system.
|
|
68
|
+
Target version: v0.7.0
|
|
55
69
|
|
|
56
70
|
tasks:
|
|
57
71
|
milestone_1:
|
|
@@ -107,17 +121,86 @@ tasks:
|
|
|
107
121
|
while read_file expected absolute paths (e.g., "/home/user/project/package.json").
|
|
108
122
|
Fix: Modified list_files to return absolute paths.
|
|
109
123
|
Breaking change released as v0.5.0.
|
|
124
|
+
|
|
125
|
+
milestone_3:
|
|
126
|
+
- id: task-5
|
|
127
|
+
name: Fix Incomplete Directory Listings (GitHub Issue #2)
|
|
128
|
+
status: completed
|
|
129
|
+
file: agent/tasks/task-5-fix-incomplete-directory-listings.md
|
|
130
|
+
estimated_hours: 3-4
|
|
131
|
+
actual_hours: 1
|
|
132
|
+
completed_date: 2026-02-23
|
|
133
|
+
priority: critical
|
|
134
|
+
github_issue: 2
|
|
135
|
+
notes: |
|
|
136
|
+
CRITICAL bug resolved!
|
|
137
|
+
Root cause: SFTP readdir() filters hidden files (protocol behavior).
|
|
138
|
+
Solution: Hybrid approach - shell ls + SFTP stat().
|
|
139
|
+
Breaking change released as v0.6.0.
|
|
140
|
+
|
|
141
|
+
milestone_4:
|
|
142
|
+
- id: task-6
|
|
143
|
+
name: Add SSH Stream Execution Method
|
|
144
|
+
status: completed
|
|
145
|
+
file: agent/tasks/milestone-4-progress-streaming-server/task-6-add-ssh-stream-execution.md
|
|
146
|
+
estimated_hours: 3-4
|
|
147
|
+
actual_hours: 0.5
|
|
148
|
+
completed_date: 2026-02-23
|
|
149
|
+
priority: high
|
|
150
|
+
notes: |
|
|
151
|
+
Foundation for progress streaming - COMPLETED!
|
|
152
|
+
Added execStream() method to SSHConnectionManager.
|
|
153
|
+
Returns streams for real-time output processing.
|
|
154
|
+
|
|
155
|
+
- id: task-7
|
|
156
|
+
name: Implement Progress Streaming in Execute Command
|
|
157
|
+
status: not_started
|
|
158
|
+
file: agent/tasks/milestone-4-progress-streaming-server/task-7-implement-progress-streaming.md
|
|
159
|
+
estimated_hours: 4-5
|
|
160
|
+
actual_hours: null
|
|
161
|
+
completed_date: null
|
|
162
|
+
priority: high
|
|
163
|
+
dependencies: task-6
|
|
164
|
+
notes: |
|
|
165
|
+
Core progress streaming implementation.
|
|
166
|
+
Send progress notifications for stdout chunks.
|
|
167
|
+
|
|
168
|
+
- id: task-8
|
|
169
|
+
name: Update Server Request Handlers
|
|
170
|
+
status: not_started
|
|
171
|
+
file: agent/tasks/milestone-4-progress-streaming-server/task-8-update-server-handlers.md
|
|
172
|
+
estimated_hours: 1-2
|
|
173
|
+
actual_hours: null
|
|
174
|
+
completed_date: null
|
|
175
|
+
priority: medium
|
|
176
|
+
dependencies: task-7
|
|
177
|
+
notes: |
|
|
178
|
+
Pass extra parameter to tool handlers.
|
|
179
|
+
Update both server.ts and server-factory.ts.
|
|
180
|
+
|
|
181
|
+
- id: task-9
|
|
182
|
+
name: Testing and Documentation
|
|
183
|
+
status: not_started
|
|
184
|
+
file: agent/tasks/milestone-4-progress-streaming-server/task-9-testing-documentation.md
|
|
185
|
+
estimated_hours: 3-4
|
|
186
|
+
actual_hours: null
|
|
187
|
+
completed_date: null
|
|
188
|
+
priority: high
|
|
189
|
+
dependencies: task-6, task-7, task-8
|
|
190
|
+
notes: |
|
|
191
|
+
Comprehensive testing and documentation for v0.7.0.
|
|
192
|
+
Unit tests, integration tests, README, CHANGELOG updates.
|
|
110
193
|
|
|
111
194
|
documentation:
|
|
112
|
-
design_documents:
|
|
113
|
-
milestone_documents:
|
|
195
|
+
design_documents: 2
|
|
196
|
+
milestone_documents: 6
|
|
114
197
|
pattern_documents: 0
|
|
115
|
-
task_documents:
|
|
198
|
+
task_documents: 9
|
|
116
199
|
|
|
117
200
|
progress:
|
|
118
201
|
planning: 100%
|
|
119
|
-
implementation:
|
|
120
|
-
overall:
|
|
202
|
+
implementation: 75%
|
|
203
|
+
overall: 80%
|
|
121
204
|
|
|
122
205
|
recent_work:
|
|
123
206
|
- date: 2026-02-23
|
|
@@ -215,13 +298,10 @@ recent_work:
|
|
|
215
298
|
next_steps:
|
|
216
299
|
- Deploy v0.6.0 to npm registry
|
|
217
300
|
- Test new list_files functionality with hidden files
|
|
218
|
-
- Verify comprehensive metadata is returned correctly
|
|
219
|
-
- Test with mcp-auth wrapper for agentbase.me integration
|
|
220
301
|
- Close GitHub Issue #2 after production verification
|
|
221
|
-
-
|
|
222
|
-
-
|
|
223
|
-
-
|
|
224
|
-
- Plan Milestone 4 (if additional features needed)
|
|
302
|
+
- Start M4: Progress Streaming - Server Implementation
|
|
303
|
+
- Implement Task 6: Add SSH Stream Execution Method
|
|
304
|
+
- Coordinate with mcp-auth and agentbase.me for M5 and M6
|
|
225
305
|
|
|
226
306
|
notes:
|
|
227
307
|
- Project designed for Task 128 (ACP Remote Development Integration)
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# Task 6: Add SSH Stream Execution Method
|
|
2
|
+
|
|
3
|
+
**Milestone**: M4 - Progress Streaming - Server Implementation
|
|
4
|
+
**Estimated Time**: 3-4 hours
|
|
5
|
+
**Dependencies**: None
|
|
6
|
+
**Status**: Not Started
|
|
7
|
+
**Priority**: High
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Objective
|
|
12
|
+
|
|
13
|
+
Add a streaming execution method to SSHConnectionManager that returns streams instead of buffered output. This enables real-time progress notifications for long-running commands.
|
|
14
|
+
|
|
15
|
+
## Context
|
|
16
|
+
|
|
17
|
+
**Design Reference**: [`agent/design/local.progress-streaming.md`](../../design/local.progress-streaming.md)
|
|
18
|
+
|
|
19
|
+
**Current State**: `SSHConnectionManager.execWithTimeout()` buffers all output and returns it at the end
|
|
20
|
+
|
|
21
|
+
**Desired State**: New `execStream()` method that returns stdout/stderr streams and exit code promise
|
|
22
|
+
|
|
23
|
+
**Why This Task**: Foundation for progress streaming - must have streams before we can send progress notifications
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Steps
|
|
28
|
+
|
|
29
|
+
### 1. Add execStream() Method Signature
|
|
30
|
+
|
|
31
|
+
**File**: `src/utils/ssh-connection.ts`
|
|
32
|
+
|
|
33
|
+
**Actions**:
|
|
34
|
+
- Add new method after `execWithTimeout()`
|
|
35
|
+
- Return type: `Promise<{ stream: NodeJS.ReadableStream; stderr: NodeJS.ReadableStream; exitCode: Promise<number> }>`
|
|
36
|
+
- Parameters: `command: string`, `cwd?: string`
|
|
37
|
+
|
|
38
|
+
### 2. Implement Stream Execution
|
|
39
|
+
|
|
40
|
+
**Actions**:
|
|
41
|
+
- Connect to SSH if not connected
|
|
42
|
+
- Build full command (with `cd` if cwd provided)
|
|
43
|
+
- Call `this.client.exec()` to get stream
|
|
44
|
+
- Return stream, stderr stream, and exit code promise
|
|
45
|
+
- Add comprehensive logging
|
|
46
|
+
|
|
47
|
+
**Code Pattern**:
|
|
48
|
+
```typescript
|
|
49
|
+
async execStream(
|
|
50
|
+
command: string,
|
|
51
|
+
cwd?: string
|
|
52
|
+
): Promise<{
|
|
53
|
+
stream: NodeJS.ReadableStream;
|
|
54
|
+
stderr: NodeJS.ReadableStream;
|
|
55
|
+
exitCode: Promise<number>;
|
|
56
|
+
}> {
|
|
57
|
+
if (!this.connected) {
|
|
58
|
+
await this.connect();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const fullCommand = cwd ? `cd "${cwd}" && ${command}` : command;
|
|
62
|
+
logger.sshCommand(fullCommand, cwd);
|
|
63
|
+
|
|
64
|
+
return new Promise((resolve, reject) => {
|
|
65
|
+
this.client.exec(fullCommand, (err, stream) => {
|
|
66
|
+
if (err) {
|
|
67
|
+
logger.error('SSH exec failed', { command: fullCommand, error: err.message });
|
|
68
|
+
reject(err);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const exitCodePromise = new Promise<number>((resolveExit) => {
|
|
73
|
+
stream.on('close', (code: number) => {
|
|
74
|
+
logger.debug('SSH stream closed', { command: fullCommand, exitCode: code });
|
|
75
|
+
resolveExit(code);
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
resolve({
|
|
80
|
+
stream: stream,
|
|
81
|
+
stderr: stream.stderr,
|
|
82
|
+
exitCode: exitCodePromise,
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### 3. Add Error Handling
|
|
90
|
+
|
|
91
|
+
**Actions**:
|
|
92
|
+
- Handle stream errors
|
|
93
|
+
- Handle connection loss during streaming
|
|
94
|
+
- Log all error conditions
|
|
95
|
+
- Ensure streams are properly closed
|
|
96
|
+
|
|
97
|
+
### 4. Add Stream Event Logging
|
|
98
|
+
|
|
99
|
+
**Actions**:
|
|
100
|
+
- Log when stream starts
|
|
101
|
+
- Log when stream closes
|
|
102
|
+
- Log exit code
|
|
103
|
+
- Log any errors
|
|
104
|
+
|
|
105
|
+
### 5. Test Method
|
|
106
|
+
|
|
107
|
+
**Actions**:
|
|
108
|
+
- Build project: `npm run build`
|
|
109
|
+
- Verify TypeScript compiles
|
|
110
|
+
- Manual test with simple command
|
|
111
|
+
- Test with command that produces output
|
|
112
|
+
- Test with command that fails
|
|
113
|
+
- Test with long-running command
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## Verification
|
|
118
|
+
|
|
119
|
+
- [ ] `execStream()` method added to SSHConnectionManager
|
|
120
|
+
- [ ] Returns correct type (stream, stderr, exitCode promise)
|
|
121
|
+
- [ ] Handles working directory changes
|
|
122
|
+
- [ ] Logs command execution
|
|
123
|
+
- [ ] Handles errors gracefully
|
|
124
|
+
- [ ] TypeScript compiles without errors
|
|
125
|
+
- [ ] Build completes successfully
|
|
126
|
+
- [ ] Manual testing successful
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## Expected Output
|
|
131
|
+
|
|
132
|
+
### Files Modified
|
|
133
|
+
- `src/utils/ssh-connection.ts` - Added `execStream()` method
|
|
134
|
+
|
|
135
|
+
### Method Signature
|
|
136
|
+
```typescript
|
|
137
|
+
async execStream(
|
|
138
|
+
command: string,
|
|
139
|
+
cwd?: string
|
|
140
|
+
): Promise<{
|
|
141
|
+
stream: NodeJS.ReadableStream;
|
|
142
|
+
stderr: NodeJS.ReadableStream;
|
|
143
|
+
exitCode: Promise<number>;
|
|
144
|
+
}>
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
**Next Task**: [Task 7: Implement Progress Streaming](task-7-implement-progress-streaming.md)
|