Jelajahi Sumber

fix(schema): loosen agent color response

Dax Raad 3 minggu lalu
induk
melakukan
a817fe5e6c

+ 3 - 1
packages/client/src/promise/generated/types.ts

@@ -8,6 +8,8 @@ export type ModelRef = { id: string; providerID: string; variant?: string }
 
 export type ProviderSettings = { [x: string]: JsonValue }
 
+export type AgentColor = string
+
 export type PermissionV2Effect = "allow" | "deny" | "ask"
 
 export type PluginInfo = { id: string }
@@ -2003,7 +2005,7 @@ export type AgentInfo = {
   description?: string
   mode: "subagent" | "primary" | "all"
   hidden: boolean
-  color?: string
+  color?: AgentColor
   steps?: number
   permissions: PermissionV2Ruleset
 }

+ 1 - 3
packages/schema/src/agent.ts

@@ -16,9 +16,7 @@ export type ID = typeof ID.Type
 export const Name = Schema.String.pipe(Schema.brand("Agent.Name"))
 export type Name = typeof Name.Type
 
-export const Color = Schema.String.annotate({ identifier: "Agent.Color" }).check(
-  Schema.isPattern(/^#[0-9a-fA-F]{6}$/),
-)
+export const Color = Schema.String.annotate({ identifier: "Agent.Color" })
 export type Color = typeof Color.Type
 
 export interface Info extends Schema.Schema.Type<typeof Info> {}

+ 10 - 0
packages/schema/test/agent.test.ts

@@ -0,0 +1,10 @@
+import { expect, test } from "bun:test"
+import { Schema } from "effect"
+import { Agent } from "../src/agent.js"
+
+test("Agent.Color preserves configured colors at the public boundary", () => {
+  const encode = Schema.encodeSync(Agent.Color)
+
+  expect(encode("info")).toBe("info")
+  expect(encode("custom-color")).toBe("custom-color")
+})