mirror of
https://github.com/kennethnym/aris.git
synced 2026-06-16 04:21:17 +01:00
feat: execute agent actions (#134)
This commit is contained in:
@@ -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 }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user