andy-stack_vaultkeeper-ai/Services/AIServices/QuickAgent.ts
Andrew Beal f693933950 refactor: replace Spinner boolean prop with customizable background color
Replace alternateBackground boolean prop with background string prop to allow direct CSS variable specification. Update QuickActionsService to add apply template action with file selection modal, timeout handling, and loading notices. Add helper method for markdown file retrieval.
2026-04-23 15:57:27 +01:00

57 lines
No EOL
2.1 KiB
TypeScript

import { AgentType } from "Enums/AgentType";
import { BaseAgent } from "./BaseAgent";
import { Conversation } from "Conversations/Conversation";
import { Exception } from "Helpers/Exception";
import { AIToolUsageMode } from "Enums/AIToolUsageMode";
import type { IChatServiceCallbacks } from "Services/ChatService";
import { ConversationContent } from "Conversations/ConversationContent";
import { Role } from "Enums/Role";
export class QuickAgent extends BaseAgent {
public async quickAction(action: string, context: string): Promise<string | null> {
this.setAgentPromptAndTools(action);
const conversation = new Conversation();
const conversationContent = new ConversationContent({
role: Role.User,
content: context,
});
conversation.contents.push(conversationContent);
const result = await this.requestAgentResponse(AgentType.QuickAction, conversation, this.callbacks());
if (conversation.contents.last()?.errorType) {
return null;
}
return result;
}
private setAgentPromptAndTools(instruction: string): void {
if (!this.ai) {
Exception.throw("Error: No AI provider has been set!");
}
this.ai.agentType = AgentType.QuickAction;
this.ai.aiToolUsageMode = AIToolUsageMode.Disabled;
this.ai.systemPrompt = instruction;
this.ai.userInstruction = ""; // do not include user instruction for quick agent
this.ai.aiToolDefinitions = []; // no tools for quick agent
}
private callbacks(): IChatServiceCallbacks {
return {
onSubmit: () => {},
onStreamingUpdate: () => {},
onThoughtUpdate: () => {},
onToolCallStarted: () => {},
onPlanningStarted: () => {},
onPlanningFinished: () => {},
onUserQuestion: async () => new Promise<string>(() => {}),
onPlanUpdate: () => {},
onPlanStepUpdate: () => {},
onPlanReset: () => {},
onComplete: () => {},
};
}
}