Skip to content

Commit d2064c8

Browse files
ericdalloeca-agent
andcommitted
Add background jobs support
- Add jobs:updated SSE event handling in transport bridge - Add REST API methods: jobsList, jobsReadOutput, jobsKill - Add outbound message routing for jobs/list, jobs/readOutput, jobs/kill - Update type definitions with job-related SSE, dispatch, and outbound types - Update eca-webview submodule with full UI implementation 🤖 Generated with [eca](https://eca.dev) Co-Authored-By: eca-agent <git@eca.dev>
1 parent a654cf3 commit d2064c8

File tree

5 files changed

+54
-4
lines changed

5 files changed

+54
-4
lines changed

src/bridge/api.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,25 @@ export class EcaRemoteApi {
268268
return this.request(`/mcp/${encodeURIComponent(name)}/enable`, { method: 'POST' });
269269
}
270270

271+
// ---------------------------------------------------------------------------
272+
// Background Jobs
273+
// ---------------------------------------------------------------------------
274+
275+
/** List all background jobs. */
276+
async jobsList(): Promise<unknown> {
277+
return this.request('/jobs');
278+
}
279+
280+
/** Read output from a background job. */
281+
async jobsReadOutput(jobId: string): Promise<unknown> {
282+
return this.request(`/jobs/${encodeURIComponent(jobId)}/output`);
283+
}
284+
285+
/** Kill a running background job. */
286+
async jobsKill(jobId: string): Promise<unknown> {
287+
return this.request(`/jobs/${encodeURIComponent(jobId)}/kill`, { method: 'POST' });
288+
}
289+
271290
// ---------------------------------------------------------------------------
272291
// SSE
273292
// ---------------------------------------------------------------------------

src/bridge/outbound-handler.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,25 @@ export async function handleOutbound(
189189
}
190190
break;
191191

192+
// --- Background Jobs ---
193+
case 'jobs/list': {
194+
const jobsResult = await api.jobsList();
195+
dispatch('jobs/list', { requestId: data.requestId, ...(jobsResult as object) });
196+
break;
197+
}
198+
199+
case 'jobs/readOutput': {
200+
const outputResult = await api.jobsReadOutput(data.jobId);
201+
dispatch('jobs/readOutput', { requestId: data.requestId, ...(outputResult as object) });
202+
break;
203+
}
204+
205+
case 'jobs/kill': {
206+
const killResult = await api.jobsKill(data.jobId);
207+
dispatch('jobs/kill', { requestId: data.requestId, ...(killResult as object) });
208+
break;
209+
}
210+
192211
// --- Ignored (no web equivalent) ---
193212
case 'editor/openFile':
194213
case 'editor/openGlobalConfig':

src/bridge/transport.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,10 @@ export class WebBridge {
719719
break;
720720
}
721721

722+
case 'jobs:updated':
723+
this.dispatch('jobs/updated', data);
724+
break;
725+
722726
case 'session:disconnecting':
723727
console.warn('[Bridge] Server shutting down:', data.reason);
724728
this.dispatch('server/statusChanged', 'Stopped');

src/bridge/types.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@ export type SSEEventType =
167167
| 'chat:status-changed'
168168
| 'config:updated'
169169
| 'tool:server-updated'
170-
| 'trust:updated';
170+
| 'trust:updated'
171+
| 'jobs:updated';
171172

172173
export interface SSESessionConnectedPayload {
173174
workspaceFolders?: WorkspaceFolder[];
@@ -265,7 +266,10 @@ export type OutboundMessage =
265266
| { type: 'mcp/connectServer'; data: { name: string } }
266267
| { type: 'mcp/logoutServer'; data: { name: string } }
267268
| { type: 'mcp/updateServer'; data: { requestId?: string } }
268-
| { type: 'server/setTrust'; data: boolean };
269+
| { type: 'server/setTrust'; data: boolean }
270+
| { type: 'jobs/list'; data: { requestId?: string } }
271+
| { type: 'jobs/readOutput'; data: { requestId?: string; jobId: string } }
272+
| { type: 'jobs/kill'; data: { requestId?: string; jobId: string } };
269273

270274
export interface UserPromptData {
271275
chatId?: string;
@@ -334,4 +338,8 @@ export type DispatchType =
334338
| 'chat/queryCommands'
335339
| 'chat/queryFiles'
336340
| 'editor/readInput'
337-
| 'editor/saveClipboardImage';
341+
| 'editor/saveClipboardImage'
342+
| 'jobs/updated'
343+
| 'jobs/list'
344+
| 'jobs/readOutput'
345+
| 'jobs/kill';

0 commit comments

Comments
 (0)