feat(cli-run): show agent/model header and suppress toast output
This commit is contained in:
parent
4d3cce685d
commit
5f9cfcbcf3
@ -141,6 +141,22 @@ export function handleMessageUpdated(ctx: RunContext, payload: EventPayload, sta
|
|||||||
state.hasReceivedMeaningfulWork = true
|
state.hasReceivedMeaningfulWork = true
|
||||||
state.messageCount++
|
state.messageCount++
|
||||||
state.lastPartText = ""
|
state.lastPartText = ""
|
||||||
|
|
||||||
|
const agent = props?.info?.agent ?? null
|
||||||
|
const model = props?.info?.modelID ?? null
|
||||||
|
if (agent !== state.currentAgent || model !== state.currentModel) {
|
||||||
|
state.currentAgent = agent
|
||||||
|
state.currentModel = model
|
||||||
|
printAgentHeader(agent, model)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function printAgentHeader(agent: string | null, model: string | null): void {
|
||||||
|
if (!agent && !model) return
|
||||||
|
const agentLabel = agent ? pc.bold(pc.magenta(agent)) : ""
|
||||||
|
const modelLabel = model ? pc.dim(model) : ""
|
||||||
|
const separator = agent && model ? " " : ""
|
||||||
|
process.stdout.write(`\n${agentLabel}${separator}${modelLabel}\n`)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function handleToolExecute(ctx: RunContext, payload: EventPayload, state: EventState): void {
|
export function handleToolExecute(ctx: RunContext, payload: EventPayload, state: EventState): void {
|
||||||
@ -193,19 +209,14 @@ export function handleTuiToast(_ctx: RunContext, payload: EventPayload, state: E
|
|||||||
if (payload.type !== "tui.toast.show") return
|
if (payload.type !== "tui.toast.show") return
|
||||||
|
|
||||||
const props = payload.properties as TuiToastShowProps | undefined
|
const props = payload.properties as TuiToastShowProps | undefined
|
||||||
const title = props?.title ? `${props.title}: ` : ""
|
|
||||||
const message = props?.message?.trim()
|
|
||||||
const variant = props?.variant ?? "info"
|
const variant = props?.variant ?? "info"
|
||||||
|
|
||||||
if (!message) return
|
|
||||||
|
|
||||||
if (variant === "error") {
|
if (variant === "error") {
|
||||||
state.mainSessionError = true
|
const title = props?.title ? `${props.title}: ` : ""
|
||||||
state.lastError = `${title}${message}`
|
const message = props?.message?.trim()
|
||||||
console.error(pc.red(`\n[tui.toast.error] ${state.lastError}`))
|
if (message) {
|
||||||
return
|
state.mainSessionError = true
|
||||||
|
state.lastError = `${title}${message}`
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const colorize = variant === "warning" ? pc.yellow : pc.dim
|
|
||||||
console.log(colorize(`[toast:${variant}] ${title}${message}`))
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,6 +9,10 @@ export interface EventState {
|
|||||||
hasReceivedMeaningfulWork: boolean
|
hasReceivedMeaningfulWork: boolean
|
||||||
/** Count of assistant messages for the main session */
|
/** Count of assistant messages for the main session */
|
||||||
messageCount: number
|
messageCount: number
|
||||||
|
/** Current agent name from the latest assistant message */
|
||||||
|
currentAgent: string | null
|
||||||
|
/** Current model ID from the latest assistant message */
|
||||||
|
currentModel: string | null
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createEventState(): EventState {
|
export function createEventState(): EventState {
|
||||||
@ -21,5 +25,7 @@ export function createEventState(): EventState {
|
|||||||
currentTool: null,
|
currentTool: null,
|
||||||
hasReceivedMeaningfulWork: false,
|
hasReceivedMeaningfulWork: false,
|
||||||
messageCount: 0,
|
messageCount: 0,
|
||||||
|
currentAgent: null,
|
||||||
|
currentModel: null,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user