feat(plugin): add tool progress reporting
This commit is contained in:
parent
6039f54126
commit
915be9b54d
36 changed files with 196 additions and 92 deletions
|
|
@ -2499,8 +2499,12 @@ function WebSearch(props: ToolProps) {
|
|||
function Subagent(props: ToolProps) {
|
||||
const { navigate } = useRoute()
|
||||
const data = useData()
|
||||
const sessionID = createMemo(() => stringValue(props.metadata.sessionID) ?? stringValue(props.metadata.sessionId))
|
||||
const description = createMemo(() => stringValue(props.input.description))
|
||||
const input = createMemo(() => (typeof props.part.state.input === "string" ? {} : props.part.state.input))
|
||||
const metadata = createMemo(() =>
|
||||
props.part.state.status === "streaming" ? {} : props.part.state.structured,
|
||||
)
|
||||
const sessionID = createMemo(() => stringValue(metadata().sessionID) ?? stringValue(metadata().sessionId))
|
||||
const description = createMemo(() => stringValue(input().description))
|
||||
const isRunning = createMemo(() => {
|
||||
const id = sessionID()
|
||||
return props.part.state.status === "running" || Boolean(id && data.session.status(id) === "running")
|
||||
|
|
@ -2518,12 +2522,12 @@ function Subagent(props: ToolProps) {
|
|||
if (id) navigate({ type: "session", sessionID: id })
|
||||
}}
|
||||
status={
|
||||
props.input.background === true || props.metadata.status === "running" ? (
|
||||
input().background === true || metadata().status === "running" ? (
|
||||
<StatusBadge>Background</StatusBadge>
|
||||
) : undefined
|
||||
}
|
||||
>
|
||||
{`${Locale.titlecase(stringValue(props.input.agent) ?? stringValue(props.input.subagent_type) ?? "General")} Subagent — ${description() ?? "Subagent"}`}
|
||||
{`${Locale.titlecase(stringValue(input().agent) ?? stringValue(input().subagent_type) ?? "General")} Subagent — ${description() ?? "Subagent"}`}
|
||||
</InlineTool>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2229,11 +2229,35 @@ test("settles pending tools when a live failure arrives", async () => {
|
|||
state: { call: true },
|
||||
},
|
||||
})
|
||||
emitEvent(events, {
|
||||
id: "evt_progress_1",
|
||||
created: 0,
|
||||
type: "session.tool.progress",
|
||||
durable: durable("session-1", 5),
|
||||
data: {
|
||||
sessionID: "session-1",
|
||||
assistantMessageID: "msg_explicit_assistant_9",
|
||||
callID: "call-1",
|
||||
structured: { sessionID: "session-child", status: "running" },
|
||||
content: [],
|
||||
},
|
||||
})
|
||||
|
||||
await wait(() => {
|
||||
const assistant = sync.session.message.get("session-1", "msg_explicit_assistant_9")
|
||||
return (
|
||||
assistant?.type === "assistant" &&
|
||||
assistant.content[0]?.type === "tool" &&
|
||||
assistant.content[0].state.status === "running" &&
|
||||
assistant.content[0].state.structured.sessionID === "session-child"
|
||||
)
|
||||
})
|
||||
|
||||
emitEvent(events, {
|
||||
id: "evt_failed_1",
|
||||
created: 0,
|
||||
type: "session.tool.failed",
|
||||
durable: durable("session-1", 5),
|
||||
durable: durable("session-1", 6),
|
||||
data: {
|
||||
sessionID: "session-1",
|
||||
assistantMessageID: "msg_explicit_assistant_9",
|
||||
|
|
@ -2264,7 +2288,7 @@ test("settles pending tools when a live failure arrives", async () => {
|
|||
if (tool.state.status !== "error") return
|
||||
expect(tool.state.error).toEqual({ type: "unknown", message: "aborted" })
|
||||
expect(tool.state.input).toEqual({})
|
||||
expect(tool.state.structured).toEqual({})
|
||||
expect(tool.state.structured).toEqual({ sessionID: "session-child", status: "running" })
|
||||
expect(tool.state.content).toEqual([])
|
||||
expect(tool.executed).toBe(false)
|
||||
expect(tool.providerState).toEqual({ call: true })
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue