Parcourir la source

fix(core): migrate named agent colors (#38414)

James Long il y a 3 semaines
Parent
commit
f1f0f47ee2

+ 5 - 2
packages/core/src/v1/config/agent.ts

@@ -4,7 +4,10 @@ import { Schema, SchemaGetter } from "effect"
 import { PositiveInt } from "../../schema"
 import { ConfigPermissionV1 } from "./permission"
 
-const Color = Schema.String.check(Schema.isPattern(/^#[0-9a-fA-F]{6}$/))
+const Color = Schema.Union([
+  Schema.String.check(Schema.isPattern(/^#[0-9a-fA-F]{6}$/)),
+  Schema.Literals(["primary", "secondary", "accent", "success", "warning", "error", "info"]),
+])
 
 const AgentSchema = Schema.StructWithRest(
   Schema.Struct({
@@ -26,7 +29,7 @@ const AgentSchema = Schema.StructWithRest(
     }),
     options: Schema.optional(Schema.Record(Schema.String, Schema.Any)),
     color: Schema.optional(Color).annotate({
-      description: "Hex color code (e.g., #FF5733)",
+      description: "Hex color code (e.g., #FF5733) or theme color (e.g., primary)",
     }),
     steps: Schema.optional(PositiveInt).annotate({
       description: "Maximum number of agentic iterations before forcing text-only response",

+ 1 - 1
packages/core/src/v1/config/migrate.ts

@@ -161,7 +161,7 @@ export function migrateAgent(info: ConfigAgentV1.Info) {
     description: info.description,
     mode: info.mode,
     hidden: info.hidden,
-    color: info.color,
+    color: info.color === undefined ? undefined : info.color.startsWith("#") ? info.color : "#aaaaaa",
     steps: info.steps,
     disabled: info.disable,
     permissions: permissions(info.permission),