feat: execute agent actions (#134)

This commit is contained in:
2026-06-14 23:08:28 +01:00
committed by GitHub
parent 9836d7499b
commit fc443d967d
8 changed files with 92 additions and 170 deletions

View File

@@ -3,22 +3,10 @@ export interface QueryAgentAsk {
message: string
}
export interface ProposedAction {
id: string
title: string
description: string
sourceId?: string
actionId?: string
params?: unknown
requiresConfirmation: true
createdAt: string
}
export type QueryAgentEvent =
| { type: "text_delta"; text: string }
| { type: "tool_start"; toolName: string }
| { type: "tool_end"; toolName: string; ok: boolean }
| { type: "action_proposed"; action: ProposedAction }
| { type: "done" }
| { type: "error"; message: string }
@@ -30,7 +18,6 @@ export interface QueryAgent {
export interface QueryAgentResponse {
message: string
proposedActions: ProposedAction[]
}
export class QueryAgentError extends Error {
@@ -45,16 +32,12 @@ export async function collectQueryAgentResponse(
input: QueryAgentAsk,
): Promise<QueryAgentResponse> {
let message = ""
const proposedActions: ProposedAction[] = []
for await (const event of agent.ask(input)) {
switch (event.type) {
case "text_delta":
message += event.text
break
case "action_proposed":
proposedActions.push(event.action)
break
case "error":
throw new QueryAgentError(event.message)
case "tool_start":
@@ -64,5 +47,5 @@ export async function collectQueryAgentResponse(
}
}
return { message, proposedActions }
return { message }
}