@opencode/schema 0.0.0-dev-20783 → 0.0.0-dev-20786

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,7 @@ import { Permission } from "../permission.js";
4
4
  import { optional, PositiveInt } from "../schema.js";
5
5
  import { ConfigModel } from "./model.js";
6
6
  import { ConfigProvider } from "./provider.js";
7
- export const Color = Schema.String.check(Schema.isPattern(/^#[0-9a-fA-F]{6}$/));
7
+ export const Color = Schema.String.check(Schema.isPattern(/^#[0-9a-fA-F]{6}$/u));
8
8
  export class Info extends Schema.Class("Config.Agent")({
9
9
  model: ConfigModel.Selection.pipe(optional),
10
10
  request: ConfigProvider.Request.pipe(optional),
@@ -3,15 +3,15 @@ import { Schema, SchemaGetter } from "effect";
3
3
  import { Model } from "../model.js";
4
4
  import { Provider } from "../provider.js";
5
5
  import { optional } from "../schema.js";
6
- const ProviderID = Provider.ID.check(Schema.isPattern(/^[^/#]+$/));
7
- const ModelID = Model.ID.check(Schema.isPattern(/^[^#]+$/));
8
- const VariantID = Model.VariantID.check(Schema.isPattern(/^[^#]+$/));
6
+ const ProviderID = Provider.ID.check(Schema.isPattern(/^[^/#]+$/u));
7
+ const ModelID = Model.ID.check(Schema.isPattern(/^[^#]+$/u));
8
+ const VariantID = Model.VariantID.check(Schema.isPattern(/^[^#]+$/u));
9
9
  const Explicit = Schema.Struct({
10
10
  providerID: ProviderID,
11
11
  model: ModelID,
12
12
  variant: VariantID.pipe(optional),
13
13
  });
14
- const Short = Schema.String.check(Schema.isPattern(/^[^/#]+\/[^#]+(?:#[^#]+)?$/));
14
+ const Short = Schema.String.check(Schema.isPattern(/^[^/#]+\/[^#]+(?:#[^#]+)?$/u));
15
15
  export const Selection = Schema.Union([Short, Explicit])
16
16
  .pipe(Schema.decodeTo(Explicit, {
17
17
  decode: SchemaGetter.transform((input) => (typeof input === "string" ? parse(input) : input)),
package/dist/event.js CHANGED
@@ -4,7 +4,7 @@ import { optional } from "./schema.js";
4
4
  import { ascending } from "./identifier.js";
5
5
  import { Location } from "./location.js";
6
6
  import { statics } from "./schema.js";
7
- export const ID = Schema.String.check(Schema.isStartsWith("evt_")).pipe(Schema.brand("Event.ID"), statics((schema) => ({ create: () => schema.make("evt_" + ascending()) })));
7
+ export const ID = Schema.String.check(Schema.isStartingWith("evt_")).pipe(Schema.brand("Event.ID"), statics((schema) => ({ create: () => schema.make("evt_" + ascending()) })));
8
8
  /**
9
9
  * Position in one aggregate's durable log. Values originate from the durable
10
10
  * event envelope and synced markers;
package/dist/form.js CHANGED
@@ -3,7 +3,7 @@ import { Schema } from "effect";
3
3
  import { ephemeral, inventory } from "./event.js";
4
4
  import { ascending } from "./identifier.js";
5
5
  import { NonNegativeInt, optional, statics } from "./schema.js";
6
- const IDSchema = Schema.String.check(Schema.isStartsWith("frm_")).pipe(Schema.brand("Form.ID"));
6
+ const IDSchema = Schema.String.check(Schema.isStartingWith("frm_")).pipe(Schema.brand("Form.ID"));
7
7
  export const ID = IDSchema.pipe(statics((schema) => ({ create: (id) => schema.make(id ?? "frm_" + ascending()) })));
8
8
  export const Metadata = Schema.Record(Schema.String, Schema.Unknown).annotate({ identifier: "Form.Metadata" });
9
9
  export const Option = Schema.Struct({
@@ -5,7 +5,7 @@ import { Schema } from "effect";
5
5
  * derives the namespaced Instructions key as `api/<key>`, keeping the
6
6
  * `api/*` namespace enforced by construction.
7
7
  */
8
- export const Key = Schema.String.check(Schema.isPattern(/^[a-z0-9][a-z0-9._-]*$/)).annotate({
8
+ export const Key = Schema.String.check(Schema.isPattern(/^[a-z0-9][a-z0-9._-]*$/u)).annotate({
9
9
  identifier: "InstructionEntry.Key",
10
10
  description: "Instruction entry key (lowercase alphanumerics plus . _ -)",
11
11
  });
@@ -1,7 +1,7 @@
1
1
  export * as Instruction from "./instruction.js";
2
2
  import { Schema } from "effect";
3
- export const Key = Schema.String.check(Schema.isPattern(/^[a-z0-9][a-z0-9._-]*\/[a-z0-9][a-z0-9._/-]*$/)).pipe(Schema.brand("Instruction.Key"));
4
- export const Hash = Schema.String.check(Schema.isPattern(/^[a-f0-9]{64}$/)).pipe(Schema.brand("Instruction.Hash"));
3
+ export const Key = Schema.String.check(Schema.isPattern(/^[a-z0-9][a-z0-9._-]*\/[a-z0-9][a-z0-9._/-]*$/u)).pipe(Schema.brand("Instruction.Key"));
4
+ export const Hash = Schema.String.check(Schema.isPattern(/^[a-f0-9]{64}$/u)).pipe(Schema.brand("Instruction.Hash"));
5
5
  export const Values = Schema.Record(Key, Hash);
6
6
  export const Removed = Schema.Literal("removed");
7
7
  export const removed = Removed.make("removed");
@@ -5,7 +5,7 @@ import { ephemeral, inventory } from "./event.js";
5
5
  import { ascending } from "./identifier.js";
6
6
  import { SessionID } from "./session-id.js";
7
7
  import { statics } from "./schema.js";
8
- export const ID = Schema.String.check(Schema.isStartsWith("per")).pipe(Schema.brand("Permission.ID"), statics((schema) => ({ create: (id) => schema.make(id ?? "per_" + ascending()) })));
8
+ export const ID = Schema.String.check(Schema.isStartingWith("per")).pipe(Schema.brand("Permission.ID"), statics((schema) => ({ create: (id) => schema.make(id ?? "per_" + ascending()) })));
9
9
  export const Source = Schema.Union([
10
10
  Schema.Struct({
11
11
  type: Schema.Literal("tool"),
package/dist/project.js CHANGED
@@ -4,7 +4,7 @@ import { ephemeral, inventory } from "./event.js";
4
4
  import { AbsolutePath, NonNegativeInt, optional } from "./schema.js";
5
5
  import { ProjectID } from "./project-id.js";
6
6
  export const ID = ProjectID;
7
- export const Vcs = Schema.String.check(Schema.isPattern(/^[a-z][a-z0-9._-]*$/)).annotate({
7
+ export const Vcs = Schema.String.check(Schema.isPattern(/^[a-z][a-z0-9._-]*$/u)).annotate({
8
8
  identifier: "Project.Vcs",
9
9
  });
10
10
  export const Current = Schema.Struct({
package/dist/prompt.js CHANGED
@@ -13,7 +13,7 @@ export const FileSource = Schema.Union([
13
13
  ])
14
14
  .pipe(Schema.toTaggedUnion("type"))
15
15
  .annotate({ identifier: "Prompt.FileSource" });
16
- export const Base64 = Schema.String.check(Schema.isPattern(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/)).annotate({ identifier: "Prompt.Base64" });
16
+ export const Base64 = Schema.String.check(Schema.isPattern(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/u)).annotate({ identifier: "Prompt.Base64" });
17
17
  export const FileAttachment = Schema.Struct({
18
18
  data: Base64,
19
19
  mime: Schema.String,
package/dist/pty.js CHANGED
@@ -4,7 +4,7 @@ import { optional } from "./schema.js";
4
4
  import { ephemeral, inventory } from "./event.js";
5
5
  import { ascending } from "./identifier.js";
6
6
  import { NonNegativeInt, PositiveInt, statics } from "./schema.js";
7
- const IDSchema = Schema.String.check(Schema.isStartsWith("pty")).pipe(Schema.brand("PtyID"));
7
+ const IDSchema = Schema.String.check(Schema.isStartingWith("pty")).pipe(Schema.brand("PtyID"));
8
8
  export const ID = IDSchema.pipe(statics((schema) => {
9
9
  const create = () => schema.make("pty_" + ascending());
10
10
  return {
package/dist/schema.d.ts CHANGED
@@ -6,5 +6,6 @@ export type RelativePath = typeof RelativePath.Type;
6
6
  export declare const AbsolutePath: Schema.brand<Schema.String, "AbsolutePath">;
7
7
  export type AbsolutePath = typeof AbsolutePath.Type;
8
8
  export declare const optional: <S extends Schema.Top>(schema: S) => Schema.decodeTo<Schema.optional<Schema.toType<S>>, Schema.optionalKey<S>, never, never>;
9
+ export declare const withStatics: <S extends object, M extends Record<string, unknown>>(schema: S, methods: M) => S & M;
9
10
  export declare const statics: <S extends object, M extends Record<string, unknown>>(methods: (schema: S) => M) => (schema: S) => S & M;
10
11
  export declare const DateTimeUtcFromMillis: Schema.decodeTo<Schema.DateTimeUtc, Schema.Finite, never, never>;
package/dist/schema.js CHANGED
@@ -7,7 +7,10 @@ export const optional = (schema) => Schema.optionalKey(schema).pipe(Schema.decod
7
7
  decode: SchemaGetter.passthrough({ strict: false }),
8
8
  encode: SchemaGetter.transformOptional(Option.filter((value) => value !== undefined)),
9
9
  }));
10
- export const statics = (methods) => (schema) => Object.assign(schema, methods(schema));
10
+ // Effect schemas expose `make` through prototype getters, so `Object.assign` cannot override it.
11
+ // Defining the properties replaces a constructor as long as the schema's own `make` has not been read.
12
+ export const withStatics = (schema, methods) => Object.defineProperties(schema, Object.getOwnPropertyDescriptors(methods));
13
+ export const statics = (methods) => (schema) => withStatics(schema, methods(schema));
11
14
  export const DateTimeUtcFromMillis = Schema.Finite.pipe(Schema.decodeTo(Schema.DateTimeUtc, {
12
15
  decode: SchemaGetter.transform((value) => DateTime.makeUnsafe(value)),
13
16
  encode: SchemaGetter.transform((value) => DateTime.toEpochMillis(value)),
@@ -1,7 +1,7 @@
1
1
  import { Schema } from "effect";
2
2
  import { descending } from "./identifier.js";
3
3
  import { statics } from "./schema.js";
4
- export const SessionID = Schema.String.check(Schema.isStartsWith("ses")).pipe(Schema.brand("SessionID"), statics((schema) => {
4
+ export const SessionID = Schema.String.check(Schema.isStartingWith("ses")).pipe(Schema.brand("SessionID"), statics((schema) => {
5
5
  const create = () => schema.make("ses_" + descending());
6
6
  return {
7
7
  create,
@@ -18,7 +18,7 @@ import { Skill as SkillSchema } from "./skill.js";
18
18
  import { Money } from "./money.js";
19
19
  import { Snapshot } from "./snapshot.js";
20
20
  import { TokenUsage } from "./token-usage.js";
21
- export const ID = Schema.String.check(Schema.isStartsWith("msg_")).pipe(Schema.brand("Session.Message.ID"), statics((schema) => ({
21
+ export const ID = Schema.String.check(Schema.isStartingWith("msg_")).pipe(Schema.brand("Session.Message.ID"), statics((schema) => ({
22
22
  create: () => schema.make("msg_" + ascending()),
23
23
  fromEvent: (eventID) => schema.make(eventID.replace(/^evt_/, "msg_")),
24
24
  })));
package/dist/shell.js CHANGED
@@ -4,7 +4,7 @@ import { optional } from "./schema.js";
4
4
  import { ephemeral, inventory } from "./event.js";
5
5
  import { ascending } from "./identifier.js";
6
6
  import { NonNegativeInt, statics } from "./schema.js";
7
- const IDSchema = Schema.String.check(Schema.isStartsWith("sh_")).pipe(Schema.brand("Shell.ID"));
7
+ const IDSchema = Schema.String.check(Schema.isStartingWith("sh_")).pipe(Schema.brand("Shell.ID"));
8
8
  export const ID = IDSchema.pipe(statics((schema) => {
9
9
  const create = () => schema.make("sh_" + ascending());
10
10
  return {
@@ -5,7 +5,7 @@ import { ascending } from "../identifier.js";
5
5
  import { Project } from "../project.js";
6
6
  import { statics } from "../schema.js";
7
7
  import { SessionID } from "../session-id.js";
8
- export const ID = Schema.String.check(Schema.isStartsWith("per")).pipe(Schema.brand("PermissionV1.ID"), statics((schema) => ({ ascending: (id) => schema.make(id ?? "per_" + ascending()) })));
8
+ export const ID = Schema.String.check(Schema.isStartingWith("per")).pipe(Schema.brand("PermissionV1.ID"), statics((schema) => ({ ascending: (id) => schema.make(id ?? "per_" + ascending()) })));
9
9
  export const Action = Schema.Literals(["allow", "deny", "ask"]).annotate({ identifier: "PermissionV1.Action" });
10
10
  export const Rule = Schema.Struct({ permission: Schema.String, pattern: Schema.String, action: Action }).annotate({
11
11
  identifier: "PermissionV1.Rule",
@@ -11,8 +11,8 @@ import { WorkspaceID } from "../workspace-id.js";
11
11
  import { PermissionV1 } from "./permission.js";
12
12
  import { FileDiff } from "../file-diff.js";
13
13
  const Timestamp = Schema.Finite.check(Schema.isGreaterThanOrEqualTo(0));
14
- export const MessageID = Schema.String.check(Schema.isStartsWith("msg")).pipe(Schema.brand("SessionV1.MessageID"), statics((schema) => ({ ascending: (id) => schema.make(id ?? "msg_" + ascending()) })));
15
- export const PartID = Schema.String.check(Schema.isStartsWith("prt")).pipe(Schema.brand("SessionV1.PartID"), statics((schema) => ({ ascending: (id) => schema.make(id ?? "prt_" + ascending()) })));
14
+ export const MessageID = Schema.String.check(Schema.isStartingWith("msg")).pipe(Schema.brand("SessionV1.MessageID"), statics((schema) => ({ ascending: (id) => schema.make(id ?? "msg_" + ascending()) })));
15
+ export const PartID = Schema.String.check(Schema.isStartingWith("prt")).pipe(Schema.brand("SessionV1.PartID"), statics((schema) => ({ ascending: (id) => schema.make(id ?? "prt_" + ascending()) })));
16
16
  const namedError = (name, fields) => {
17
17
  const schema = Schema.Struct({ name: Schema.Literal(name), data: Schema.Struct(fields) }).annotate({
18
18
  identifier: name,
@@ -1,7 +1,7 @@
1
1
  import { Schema } from "effect";
2
2
  import { ascending } from "./identifier.js";
3
3
  import { statics } from "./schema.js";
4
- export const WorkspaceID = Schema.String.check(Schema.isStartsWith("wrk")).pipe(Schema.brand("Workspace.ID"), statics((schema) => {
4
+ export const WorkspaceID = Schema.String.check(Schema.isStartingWith("wrk")).pipe(Schema.brand("Workspace.ID"), statics((schema) => {
5
5
  const create = () => schema.make("wrk_" + ascending());
6
6
  return {
7
7
  ascending: (id) => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@opencode/schema",
4
- "version": "0.0.0-dev-20783",
4
+ "version": "0.0.0-dev-20786",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -31,7 +31,7 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@standard-schema/spec": "1.1.0",
34
- "effect": "4.0.0-rc.112"
34
+ "effect": "4.0.0-rc.118"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@tsconfig/bun": "1.0.9",