| 1 | import type { |
| 2 | CopilotAction, |
| 3 | CopilotActionInvokeResponse, |
| 4 | CopilotActionListResponse, |
| 5 | InvokeCopilotActionRequest |
| 6 | } from "@/types/copilotAction.d" |
| 7 | import type { FlaskBaseResponse } from "@/types/flask.d" |
| 8 | import { HttpClient } from "../httpClient" |
| 9 | |
| 10 | export interface CopilotActionInventoryQuery { |
| 11 | /** Filter by technology type */ |
| 12 | technology?: string |
| 13 | /** Filter by category */ |
| 14 | category?: string |
| 15 | /** Filter by tag */ |
| 16 | tag?: string |
| 17 | /** Free-text search query */ |
| 18 | q?: string |
| 19 | /** Maximum number of results */ |
| 20 | limit?: number |
| 21 | /** Offset for pagination */ |
| 22 | offset?: number |
| 23 | /** Force refresh cache */ |
| 24 | refresh?: boolean |
| 25 | /** Comma-separated extra fields to include */ |
| 26 | include?: string |
| 27 | } |
| 28 | |
| 29 | export default { |
| 30 | /** |
| 31 | * Get inventory of available active response scripts |
| 32 | */ |
| 33 | getInventory(query?: CopilotActionInventoryQuery, signal?: AbortSignal) { |
| 34 | return HttpClient.get<FlaskBaseResponse & CopilotActionListResponse>(`/copilot_action/inventory`, { |
| 35 | params: { |
| 36 | technology: query?.technology, |
| 37 | category: query?.category, |
| 38 | tag: query?.tag, |
| 39 | q: query?.q, |
| 40 | limit: query?.limit || 100, |
| 41 | offset: query?.offset || 0, |
| 42 | refresh: query?.refresh || false, |
| 43 | include: query?.include |
| 44 | }, |
| 45 | signal |
| 46 | }) |
| 47 | }, |
| 48 | |
| 49 | /** |
| 50 | * Get details for a specific active response script |
| 51 | */ |
| 52 | getActionByName(copilotActionName: string) { |
| 53 | return HttpClient.get<FlaskBaseResponse & { copilot_action: CopilotAction }>( |
| 54 | `/copilot_action/inventory/${copilotActionName}` |
| 55 | ) |
| 56 | }, |
| 57 | |
| 58 | /** |
| 59 | * Get available technology types |
| 60 | */ |
| 61 | getTechnologies(signal?: AbortSignal) { |
| 62 | return HttpClient.get<FlaskBaseResponse & { technologies: string[] }>(`/copilot_action/technologies`, { |
| 63 | signal |
| 64 | }) |
| 65 | }, |
| 66 | |
| 67 | /** |
| 68 | * Invoke a Copilot Action on multiple target agents |
| 69 | */ |
| 70 | invokeAction(payload: InvokeCopilotActionRequest) { |
| 71 | return HttpClient.post<FlaskBaseResponse & { responses: CopilotActionInvokeResponse[] }>( |
| 72 | `/copilot_action/invoke`, |
| 73 | payload |
| 74 | ) |
| 75 | } |
| 76 | } |