Agents crud (#9084)

This commit is contained in:
Jack Amadeo
2026-05-11 13:33:32 -04:00
committed by GitHub
parent 40d4b118bb
commit a38922d95e
43 changed files with 1463 additions and 1458 deletions
+37 -7
View File
@@ -124,6 +124,22 @@ export function buildInitScript(options?: {
supportingFiles: [],
});
const personaToSourceEntry = (p) => ({
type: "agent",
name: p.displayName ?? p.name,
description: p.description ?? "Agent",
content: p.systemPrompt ?? p.content ?? "",
path: p.id ?? p.path ?? ("/mock/.agents/agents/" + (p.displayName ?? p.name)),
global: p.global ?? true,
writable: p.writable ?? !p.isBuiltin,
supportingFiles: [],
properties: {
provider: p.provider,
model: p.model,
avatar: typeof p.avatar === "string" ? p.avatar : p.avatar?.value,
},
});
const projectToSourceEntry = (p) => ({
type: "project",
name: p.id ?? p.name?.toLowerCase(),
@@ -263,30 +279,42 @@ export function buildInitScript(options?: {
return jsonRpcResult(message.id, {});
case "_goose/sources/list": {
const sourceType = message.params?.type;
if (sourceType === "agent") {
return jsonRpcResult(message.id, { sources: PERSONAS.map(personaToSourceEntry) });
}
if (sourceType === "project") {
return jsonRpcResult(message.id, { sources: PROJECTS.map(projectToSourceEntry) });
}
return jsonRpcResult(message.id, { sources: SKILLS.map(skillToSourceEntry) });
}
case "_goose/sources/create":
case "_goose/sources/create": {
const sourceType = message.params?.type ?? "skill";
const name = message.params?.name ?? (sourceType === "agent" ? "New Agent" : "new-skill");
return jsonRpcResult(message.id, {
source: {
name: message.params?.name ?? "new-skill",
type: "skill",
name,
type: sourceType,
description: message.params?.description ?? "",
content: message.params?.content ?? "",
path: "/mock/.agents/skills/" + (message.params?.name ?? "new-skill"),
path: "/mock/.agents/" + (sourceType === "agent" ? "agents" : "skills") + "/" + name,
global: message.params?.global ?? true,
writable: true,
supportingFiles: [],
properties: message.params?.properties ?? {},
},
});
}
case "_goose/sources/update":
case "goose/sources/update": {
const path = message.params?.path ?? "/mock/.agents/skills/updated-skill";
const sourceType = message.params?.type ?? "skill";
const path =
message.params?.path ??
(sourceType === "agent" ? "/mock/.agents/agents/updated-agent" : "/mock/.agents/skills/updated-skill");
const nextName = message.params?.name;
const name =
typeof nextName === "string" && nextName.length > 0
? nextName
: String(path).split("/").filter(Boolean).at(-1) ?? "updated-skill";
: String(path).split("/").filter(Boolean).at(-1) ?? (sourceType === "agent" ? "updated-agent" : "updated-skill");
const segments = String(path).split("/").filter(Boolean);
if (segments.length > 0) {
segments[segments.length - 1] = name;
@@ -295,12 +323,14 @@ export function buildInitScript(options?: {
return jsonRpcResult(message.id, {
source: {
name,
type: "skill",
type: sourceType,
description: message.params?.description ?? "",
content: message.params?.content ?? "",
path: updatedPath,
global: message.params?.global ?? true,
writable: true,
supportingFiles: [],
properties: message.params?.properties ?? {},
},
});
}