feat: ui attach rpc support
This commit is contained in:
@@ -1,4 +1,10 @@
|
||||
import type { AgentSessionEvent, RpcCommand, RpcResponse } from "@earendil-works/pi-coding-agent";
|
||||
import type {
|
||||
AgentSessionEvent,
|
||||
RpcCommand,
|
||||
RpcExtensionUIRequest,
|
||||
RpcExtensionUIResponse,
|
||||
RpcResponse,
|
||||
} from "@earendil-works/pi-coding-agent";
|
||||
import type { InstanceStatus } from "../types.ts";
|
||||
|
||||
export interface SpawnRequest {
|
||||
@@ -121,8 +127,13 @@ export interface ResponseMap {
|
||||
}
|
||||
|
||||
export type OrchestratorResponse = ResponseMap[keyof ResponseMap] | ErrorResponse;
|
||||
export type AttachClientRequest = AttachRpcRequest;
|
||||
export type AttachServerResponse = AttachReadyResponse | AttachEventResponse | AttachRpcResponse | ErrorResponse;
|
||||
export type AttachClientRequest = AttachRpcRequest | RpcExtensionUIResponse;
|
||||
export type AttachServerResponse =
|
||||
| AttachReadyResponse
|
||||
| AttachEventResponse
|
||||
| AttachRpcResponse
|
||||
| RpcExtensionUIRequest
|
||||
| ErrorResponse;
|
||||
export type ProtocolMessage = OrchestratorRequest | OrchestratorResponse | AttachClientRequest | AttachServerResponse;
|
||||
|
||||
export type ResponseFor<T extends OrchestratorRequest> = T extends { type: infer K }
|
||||
|
||||
@@ -35,6 +35,7 @@ export interface IpcRequestHandler {
|
||||
instanceId: string,
|
||||
onEvent: (response: AttachRpcResponse) => void,
|
||||
onSessionEvent: (event: import("@earendil-works/pi-coding-agent").AgentSessionEvent) => void,
|
||||
onUiRequest: (request: import("@earendil-works/pi-coding-agent").RpcExtensionUIRequest) => void,
|
||||
):
|
||||
| {
|
||||
handleRequest(request: AttachClientRequest): Promise<void>;
|
||||
@@ -80,6 +81,9 @@ export async function startIpcServer(handler: IpcRequestHandler): Promise<Server
|
||||
(event) => {
|
||||
socket.write(encodeMessage({ type: "attach_event", event }));
|
||||
},
|
||||
(request) => {
|
||||
socket.write(encodeMessage(request));
|
||||
},
|
||||
);
|
||||
if (!attachment) {
|
||||
socket.end(
|
||||
|
||||
Reference in New Issue
Block a user