diff --git a/packages/opencode/src/control-plane/schema.ts b/packages/opencode/src/control-plane/schema.ts index a106ae8990..53ce0cff97 100644 --- a/packages/opencode/src/control-plane/schema.ts +++ b/packages/opencode/src/control-plane/schema.ts @@ -1,12 +1,10 @@ import { Schema } from "effect" import { Identifier } from "@/id/id" -import { zod, ZodOverride } from "@opencode-ai/core/effect-zod" +import { zod } from "@opencode-ai/core/effect-zod" import { withStatics } from "@opencode-ai/core/schema" -const workspaceIdSchema = Schema.String.check(Schema.isStartsWith("wrk")) - .annotate({ [ZodOverride]: Identifier.schema("workspace") }) - .pipe(Schema.brand("WorkspaceID")) +const workspaceIdSchema = Schema.String.check(Schema.isStartsWith("wrk")).pipe(Schema.brand("WorkspaceID")) export type WorkspaceID = typeof workspaceIdSchema.Type diff --git a/packages/opencode/src/id/id.ts b/packages/opencode/src/id/id.ts index 6d9a6447a0..9e163cd6b8 100644 --- a/packages/opencode/src/id/id.ts +++ b/packages/opencode/src/id/id.ts @@ -1,4 +1,3 @@ -import z from "zod" import { randomBytes } from "crypto" const prefixes = { @@ -7,19 +6,12 @@ const prefixes = { message: "msg", permission: "per", question: "que", - user: "usr", part: "prt", pty: "pty", tool: "tool", workspace: "wrk", - entry: "ent", - account: "act", } as const -export function schema(prefix: keyof typeof prefixes) { - return z.string().startsWith(prefixes[prefix]) -} - const LENGTH = 26 // State for monotonic ID generation diff --git a/packages/opencode/src/permission/schema.ts b/packages/opencode/src/permission/schema.ts index 725030935d..f7c6e2c5b7 100644 --- a/packages/opencode/src/permission/schema.ts +++ b/packages/opencode/src/permission/schema.ts @@ -1,12 +1,12 @@ import { Schema } from "effect" import { Identifier } from "@/id/id" -import { zod, ZodOverride } from "@opencode-ai/core/effect-zod" +import { zod } from "@opencode-ai/core/effect-zod" import { Newtype } from "@opencode-ai/core/schema" export class PermissionID extends Newtype()( "PermissionID", - Schema.String.check(Schema.isStartsWith("per")).annotate({ [ZodOverride]: Identifier.schema("permission") }), + Schema.String.check(Schema.isStartsWith("per")), ) { static ascending(id?: string): PermissionID { return this.make(Identifier.ascending("permission", id)) diff --git a/packages/opencode/src/pty/schema.ts b/packages/opencode/src/pty/schema.ts index f6508bace0..fadb0457e7 100644 --- a/packages/opencode/src/pty/schema.ts +++ b/packages/opencode/src/pty/schema.ts @@ -1,12 +1,10 @@ import { Schema } from "effect" import { Identifier } from "@/id/id" -import { zod, ZodOverride } from "@opencode-ai/core/effect-zod" +import { zod } from "@opencode-ai/core/effect-zod" import { withStatics } from "@opencode-ai/core/schema" -const ptyIdSchema = Schema.String.check(Schema.isStartsWith("pty")) - .annotate({ [ZodOverride]: Identifier.schema("pty") }) - .pipe(Schema.brand("PtyID")) +const ptyIdSchema = Schema.String.check(Schema.isStartsWith("pty")).pipe(Schema.brand("PtyID")) export type PtyID = typeof ptyIdSchema.Type diff --git a/packages/opencode/src/question/schema.ts b/packages/opencode/src/question/schema.ts index c18eca3e23..1856c94bc7 100644 --- a/packages/opencode/src/question/schema.ts +++ b/packages/opencode/src/question/schema.ts @@ -1,13 +1,10 @@ import { Schema } from "effect" import { Identifier } from "@/id/id" -import { zod, ZodOverride } from "@opencode-ai/core/effect-zod" +import { zod } from "@opencode-ai/core/effect-zod" import { Newtype } from "@opencode-ai/core/schema" -export class QuestionID extends Newtype()( - "QuestionID", - Schema.String.check(Schema.isStartsWith("que")).annotate({ [ZodOverride]: Identifier.schema("question") }), -) { +export class QuestionID extends Newtype()("QuestionID", Schema.String.check(Schema.isStartsWith("que"))) { static ascending(id?: string): QuestionID { return this.make(Identifier.ascending("question", id)) } diff --git a/packages/opencode/src/session/schema.ts b/packages/opencode/src/session/schema.ts index 11085eeb56..991c9ccc6b 100644 --- a/packages/opencode/src/session/schema.ts +++ b/packages/opencode/src/session/schema.ts @@ -1,47 +1,35 @@ import { Schema } from "effect" import { Identifier } from "@/id/id" -import { zod, ZodOverride } from "@opencode-ai/core/effect-zod" +import { zod } from "@opencode-ai/core/effect-zod" import { withStatics } from "@opencode-ai/core/schema" -export const SessionID = Schema.String.check(Schema.isStartsWith("ses")) - .annotate({ - [ZodOverride]: Identifier.schema("session"), - }) - .pipe( - Schema.brand("SessionID"), - withStatics((s) => ({ - descending: (id?: string) => s.make(Identifier.descending("session", id)), - zod: zod(s), - })), - ) +export const SessionID = Schema.String.check(Schema.isStartsWith("ses")).pipe( + Schema.brand("SessionID"), + withStatics((s) => ({ + descending: (id?: string) => s.make(Identifier.descending("session", id)), + zod: zod(s), + })), +) export type SessionID = Schema.Schema.Type -export const MessageID = Schema.String.check(Schema.isStartsWith("msg")) - .annotate({ - [ZodOverride]: Identifier.schema("message"), - }) - .pipe( - Schema.brand("MessageID"), - withStatics((s) => ({ - ascending: (id?: string) => s.make(Identifier.ascending("message", id)), - zod: zod(s), - })), - ) +export const MessageID = Schema.String.check(Schema.isStartsWith("msg")).pipe( + Schema.brand("MessageID"), + withStatics((s) => ({ + ascending: (id?: string) => s.make(Identifier.ascending("message", id)), + zod: zod(s), + })), +) export type MessageID = Schema.Schema.Type -export const PartID = Schema.String.check(Schema.isStartsWith("prt")) - .annotate({ - [ZodOverride]: Identifier.schema("part"), - }) - .pipe( - Schema.brand("PartID"), - withStatics((s) => ({ - ascending: (id?: string) => s.make(Identifier.ascending("part", id)), - zod: zod(s), - })), - ) +export const PartID = Schema.String.check(Schema.isStartsWith("prt")).pipe( + Schema.brand("PartID"), + withStatics((s) => ({ + ascending: (id?: string) => s.make(Identifier.ascending("part", id)), + zod: zod(s), + })), +) export type PartID = Schema.Schema.Type diff --git a/packages/opencode/src/sync/schema.ts b/packages/opencode/src/sync/schema.ts index e4e2e75b73..dde2e53d17 100644 --- a/packages/opencode/src/sync/schema.ts +++ b/packages/opencode/src/sync/schema.ts @@ -1,10 +1,10 @@ import { Schema } from "effect" import { Identifier } from "@/id/id" -import { zod, ZodOverride } from "@opencode-ai/core/effect-zod" +import { zod } from "@opencode-ai/core/effect-zod" import { withStatics } from "@opencode-ai/core/schema" -export const EventID = Schema.String.annotate({ [ZodOverride]: Identifier.schema("event") }).pipe( +export const EventID = Schema.String.check(Schema.isStartsWith("evt")).pipe( Schema.brand("EventID"), withStatics((s) => ({ ascending: (id?: string) => s.make(Identifier.ascending("event", id)), diff --git a/packages/opencode/src/tool/schema.ts b/packages/opencode/src/tool/schema.ts index b6c263a4ce..a80d915153 100644 --- a/packages/opencode/src/tool/schema.ts +++ b/packages/opencode/src/tool/schema.ts @@ -1,10 +1,10 @@ import { Schema } from "effect" import { Identifier } from "@/id/id" -import { zod, ZodOverride } from "@opencode-ai/core/effect-zod" +import { zod } from "@opencode-ai/core/effect-zod" import { withStatics } from "@opencode-ai/core/schema" -const toolIdSchema = Schema.String.annotate({ [ZodOverride]: Identifier.schema("tool") }).pipe(Schema.brand("ToolID")) +const toolIdSchema = Schema.String.check(Schema.isStartsWith("tool")).pipe(Schema.brand("ToolID")) export type ToolID = typeof toolIdSchema.Type