Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,8 @@
"description": "Description of the agent - for what purposes should be used, what are his strengths, etc."
},
"subagentEnabled": {
"type": "string",
"type": "boolean",
"default": false,
"description": "If the agent could be used as subagent of another agent to execute a specific task."
},
"systemInstruction": {
Expand All @@ -359,6 +360,14 @@
"description": "The system instructions for this agent",
"default": ""
},
"system_instruction": {
"type": "array",
"items": {
"type": "string"
},
"description": "Deprecated alias for systemInstruction",
"default": ""
},
"toolsModel": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -401,8 +410,7 @@
}
},
"required": [
"name",
"system_instruction"
"name"
]
},
"default": [
Expand Down Expand Up @@ -1231,6 +1239,14 @@
"description": "The system instructions for this agent",
"default": ""
},
"system_instruction": {
"type": "array",
"items": {
"type": "string"
},
"description": "Deprecated alias for systemInstruction",
"default": ""
},
"tools": {
"type": "array",
"items": {
Expand Down
45 changes: 44 additions & 1 deletion src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import OpenAI from "openai";
import https from "https";
import fs from "fs";
import {translations} from "./translations"
import { Agent } from "./types";
import { Utils } from "./utils";

export class Configuration {
Expand Down Expand Up @@ -265,7 +266,7 @@ export class Configuration {
this.embeddings_models_list = config.get("embeddings_models_list")??new Array();
this.tools_models_list = config.get("tools_models_list")??new Array();
this.envs_list = config.get("envs_list")??new Array();
this.agents_list = config.get("agents_list")??new Array();
this.agents_list = this.normalizeAgents(config.get("agents_list") ?? new Array());
this.agent_rules = String(config.get<string>("agent_rules"));
this.agent_commands = config.get("agent_commands")??new Array();
this.env_start_last_used = Boolean(config.get<boolean>("env_start_last_used", true));
Expand All @@ -282,6 +283,48 @@ export class Configuration {
this.health_check_tools_enabled = Boolean(config.get<boolean>("health_check_tools_enabled"));
};

private normalizeAgents(rawAgents: unknown): Agent[] {
if (!Array.isArray(rawAgents)) {
return [];
}

return rawAgents.map((rawAgent) => this.normalizeAgent(rawAgent));
}

private normalizeAgent(rawAgent: unknown): Agent {
const agent = (rawAgent && typeof rawAgent === 'object' ? rawAgent : {}) as Record<string, unknown>;
const systemInstructionValue = agent.systemInstruction ?? agent.system_instruction ?? [];
const subagentEnabledValue = agent.subagentEnabled;

let systemInstruction: string[];
if (Array.isArray(systemInstructionValue)) {
systemInstruction = systemInstructionValue.map((value) => String(value));
} else if (typeof systemInstructionValue === 'string') {
systemInstruction = systemInstructionValue.split(/\r?\n/);
} else {
systemInstruction = [];
}

let subagentEnabled: boolean | undefined;
if (typeof subagentEnabledValue === 'boolean') {
subagentEnabled = subagentEnabledValue;
} else if (typeof subagentEnabledValue === 'string') {
subagentEnabled = subagentEnabledValue.toLowerCase() === 'true';
}

return {
...agent,
name: String(agent.name ?? ''),
description: agent.description !== undefined ? String(agent.description) : undefined,
systemInstruction,
subagentEnabled,
tools: Array.isArray(agent.tools) ? agent.tools.map((tool) => String(tool)) : undefined,
toolsModel: agent.toolsModel && typeof agent.toolsModel === 'object'
? { ...(agent.toolsModel as Record<string, unknown>) }
: undefined,
} as Agent;
}

getUiText = (uiText: string): string | undefined => {
let langTexts = this.uiLanguages.get(this.language);
if (langTexts == undefined) langTexts = this.uiLanguages.get("en");
Expand Down
2 changes: 1 addition & 1 deletion src/llama-chat-model-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export class LlamaChatModelProvider implements vscode.LanguageModelChatProvider
.join(''),
}));

const tools = options.tools?.map((t: vscode.LanguageModelToolInformation) => ({
const tools = options.tools?.map((t) => ({
type: 'function',
function: {
name: t.name,
Expand Down
77 changes: 0 additions & 77 deletions src/vscode-lm-chat-shim.d.ts

This file was deleted.