mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-07-18 21:21:11 +02:00
First version copilot:
- basic llm call that can perform CRUD actions over dummy workflow json files
This commit is contained in:
parent
055dda35b9
commit
4310b1d45d
11 changed files with 327 additions and 4 deletions
37
apps/cli/src/application/assistant/agents/service.ts
Normal file
37
apps/cli/src/application/assistant/agents/service.ts
Normal 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);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue