You've already forked agentic-coding-workflow
改动
This commit is contained in:
@@ -16,6 +16,7 @@ export interface UseAcpStreamReturn {
|
||||
sessionStatus: Ref<SessionStatus>
|
||||
events: Ref<AcpEvent[]>
|
||||
pendingPermissions: Ref<PermissionRequest[]>
|
||||
errorMsg: Ref<string | null>
|
||||
prompt: (text: string, agentSessionID: string) => void
|
||||
cancel: (agentSessionID: string) => void
|
||||
reconnect: () => void
|
||||
@@ -49,6 +50,7 @@ export function useAcpStream(sessionId: string): UseAcpStreamReturn {
|
||||
const sessionStatus = ref<SessionStatus>('starting')
|
||||
const events = ref<AcpEvent[]>([])
|
||||
const pendingPermissions = ref<PermissionRequest[]>([])
|
||||
const errorMsg = ref<string | null>(null)
|
||||
const lastEventID = ref(0)
|
||||
|
||||
function upsertPermission(p: PermissionRequest) {
|
||||
@@ -118,6 +120,13 @@ export function useAcpStream(sessionId: string): UseAcpStreamReturn {
|
||||
return
|
||||
}
|
||||
|
||||
// 客户端错误帧(bad json / 无权限 / 方法不允许 / 转发失败)——单独提示,不进 events 流。
|
||||
if (obj.kind === 'client_error') {
|
||||
const msg = typeof obj.message === 'string' ? obj.message : 'client error'
|
||||
errorMsg.value = msg
|
||||
return
|
||||
}
|
||||
|
||||
// Initial state event from server
|
||||
if (obj.kind === 'state') {
|
||||
const s = (parsed as ServerStateEvent).status
|
||||
@@ -209,5 +218,5 @@ export function useAcpStream(sessionId: string): UseAcpStreamReturn {
|
||||
connect()
|
||||
onScopeDispose(close)
|
||||
|
||||
return { status, sessionStatus, events, pendingPermissions, prompt, cancel, reconnect, close }
|
||||
return { status, sessionStatus, events, pendingPermissions, errorMsg, prompt, cancel, reconnect, close }
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ export type StreamStatus = 'idle' | 'connecting' | 'streaming' | 'closed' | 'err
|
||||
export interface UseRunStreamReturn {
|
||||
status: Ref<StreamStatus>
|
||||
runStatus: Ref<RunState>
|
||||
exitCode: Ref<number | null>
|
||||
logs: Ref<LogLine[]>
|
||||
reconnect: () => void
|
||||
close: () => void
|
||||
@@ -24,11 +25,13 @@ interface WireFrame {
|
||||
text?: string
|
||||
ts?: string
|
||||
status?: RunState
|
||||
exit_code?: number
|
||||
}
|
||||
|
||||
export function useRunStream(profileId: string): UseRunStreamReturn {
|
||||
const status = ref<StreamStatus>('idle')
|
||||
const runStatus = ref<RunState>('stopped')
|
||||
const exitCode = ref<number | null>(null)
|
||||
const logs = ref<LogLine[]>([])
|
||||
const lastLogID = ref(0)
|
||||
|
||||
@@ -62,6 +65,7 @@ export function useRunStream(profileId: string): UseRunStreamReturn {
|
||||
|
||||
if (parsed.kind === 'state') {
|
||||
if (parsed.status) runStatus.value = parsed.status
|
||||
exitCode.value = parsed.exit_code ?? null
|
||||
return
|
||||
}
|
||||
if (parsed.kind === 'slow_consumer_disconnect') {
|
||||
@@ -124,5 +128,5 @@ export function useRunStream(profileId: string): UseRunStreamReturn {
|
||||
connect()
|
||||
onScopeDispose(close)
|
||||
|
||||
return { status, runStatus, logs, reconnect, close, clear }
|
||||
return { status, runStatus, exitCode, logs, reconnect, close, clear }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user