First version copilot:

- basic llm call that can perform CRUD actions over dummy workflow json files
This commit is contained in:
tusharmagar 2025-10-30 16:09:19 +08:00 committed by Ramnique Singh
parent 055dda35b9
commit 4310b1d45d
11 changed files with 327 additions and 4 deletions

View file

@ -0,0 +1,37 @@
import { z } from "zod";
import { Agent } from "../../entities/agent.js";
import { deleteJson, listJson, readJson, writeJson } from "../services/storage.js";
export type AgentId = string;
export function listAgents(): AgentId[] {
return listJson("agents");
}
export function getAgent(id: AgentId): z.infer<typeof Agent> | undefined {
const raw = readJson<unknown>("agents", id);
if (!raw) return undefined;
return Agent.parse(raw);
}
export function upsertAgent(
id: AgentId,
value: Partial<z.infer<typeof Agent>>
): z.infer<typeof Agent> {
const existing = readJson<unknown>("agents", id) as Partial<z.infer<typeof Agent>> | undefined;
const merged = {
name: id,
model: "openai:gpt-4o-mini",
description: "",
instructions: "",
...(existing ?? {}),
...value,
} satisfies Partial<z.infer<typeof Agent>>;
const parsed = Agent.parse(merged);
writeJson("agents", id, parsed);
return parsed;
}
export function deleteAgent(id: AgentId): boolean {
return deleteJson("agents", id);
}