This reverts commit 56c7b59eaf.
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import { io, type Socket } from 'socket.io-client'
|
||||
import type { ApprovalChoice } from '../../utils/approval-commands'
|
||||
import { request, getBaseUrlValue, getApiKey } from '../client'
|
||||
|
||||
export type ContentBlock =
|
||||
@@ -40,14 +39,6 @@ export interface RunEvent {
|
||||
/** Final response text on `run.completed`. May be empty/null if the agent
|
||||
* silently swallowed an upstream error — see chat store for fallback. */
|
||||
output?: string | null
|
||||
command?: string
|
||||
description?: string
|
||||
pattern_key?: string
|
||||
pattern_keys?: string[]
|
||||
choices?: ApprovalChoice[]
|
||||
resolved?: number
|
||||
choice?: ApprovalChoice
|
||||
all?: boolean
|
||||
usage?: {
|
||||
input_tokens: number
|
||||
output_tokens: number
|
||||
@@ -84,8 +75,6 @@ const sessionEventHandlers = new Map<string, {
|
||||
onCompressionCompleted: (event: RunEvent) => void
|
||||
onAbortStarted: (event: RunEvent) => void
|
||||
onAbortCompleted: (event: RunEvent) => void
|
||||
onApprovalRequest: (event: RunEvent) => void
|
||||
onApprovalResponded: (event: RunEvent) => void
|
||||
onUsageUpdated: (event: RunEvent) => void
|
||||
onRunQueued?: (event: RunEvent) => void
|
||||
}>()
|
||||
@@ -286,32 +275,6 @@ function globalAbortCompletedHandler(event: RunEvent): void {
|
||||
sessionEventHandlers.delete(sid)
|
||||
}
|
||||
|
||||
/**
|
||||
* Global approval.request event handler
|
||||
*/
|
||||
function globalApprovalRequestHandler(event: RunEvent): void {
|
||||
const sid = event.session_id
|
||||
if (!sid) return
|
||||
|
||||
const handlers = sessionEventHandlers.get(sid)
|
||||
if (handlers?.onApprovalRequest) {
|
||||
handlers.onApprovalRequest(event)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Global approval.responded event handler
|
||||
*/
|
||||
function globalApprovalRespondedHandler(event: RunEvent): void {
|
||||
const sid = event.session_id
|
||||
if (!sid) return
|
||||
|
||||
const handlers = sessionEventHandlers.get(sid)
|
||||
if (handlers?.onApprovalResponded) {
|
||||
handlers.onApprovalResponded(event)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Global usage.updated event handler
|
||||
*/
|
||||
@@ -347,8 +310,6 @@ export function registerSessionHandlers(
|
||||
onCompressionCompleted: (event: RunEvent) => void
|
||||
onAbortStarted: (event: RunEvent) => void
|
||||
onAbortCompleted: (event: RunEvent) => void
|
||||
onApprovalRequest: (event: RunEvent) => void
|
||||
onApprovalResponded: (event: RunEvent) => void
|
||||
onUsageUpdated: (event: RunEvent) => void
|
||||
onRunQueued?: (event: RunEvent) => void
|
||||
}
|
||||
@@ -431,11 +392,6 @@ export function connectChatRun(): Socket {
|
||||
chatRunSocket.on('abort.started', globalAbortStartedHandler)
|
||||
chatRunSocket.on('abort.completed', globalAbortCompletedHandler)
|
||||
|
||||
// Approval events
|
||||
chatRunSocket.on('approval.requested', globalApprovalRequestHandler)
|
||||
chatRunSocket.on('approval.request', globalApprovalRequestHandler)
|
||||
chatRunSocket.on('approval.responded', globalApprovalRespondedHandler)
|
||||
|
||||
// Usage events
|
||||
chatRunSocket.on('usage.updated', globalUsageUpdatedHandler)
|
||||
|
||||
@@ -563,14 +519,6 @@ export function startRunViaSocket(
|
||||
closed = true
|
||||
onDone()
|
||||
},
|
||||
onApprovalRequest: (evt: RunEvent) => {
|
||||
if (closed) return
|
||||
onEvent(evt)
|
||||
},
|
||||
onApprovalResponded: (evt: RunEvent) => {
|
||||
if (closed) return
|
||||
onEvent(evt)
|
||||
},
|
||||
onUsageUpdated: (evt: RunEvent) => {
|
||||
if (closed) return
|
||||
onEvent(evt)
|
||||
@@ -596,16 +544,6 @@ export function startRunViaSocket(
|
||||
}
|
||||
}
|
||||
|
||||
export function submitApprovalViaSocket(
|
||||
sessionId: string,
|
||||
choice: ApprovalChoice,
|
||||
all = false,
|
||||
): Socket {
|
||||
const socket = connectChatRun()
|
||||
socket.emit('approval.respond', { session_id: sessionId, choice, all })
|
||||
return socket
|
||||
}
|
||||
|
||||
export async function fetchModels(): Promise<{ data: Array<{ id: string }> }> {
|
||||
return request('/api/hermes/v1/models')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user