refactor(schema): normalize module patterns (#33770)
This commit is contained in:
parent
5565a8ee10
commit
7854f5b9f7
50 changed files with 204 additions and 202 deletions
|
|
@ -4,7 +4,7 @@ import { Schema } from "effect"
|
|||
import { Model } from "./model"
|
||||
import { Permission } from "./permission"
|
||||
import { Provider } from "./provider"
|
||||
import { PositiveInt, withStatics } from "./schema"
|
||||
import { PositiveInt, statics } from "./schema"
|
||||
|
||||
export const ID = Schema.String.pipe(Schema.brand("AgentV2.ID"))
|
||||
export type ID = typeof ID.Type
|
||||
|
|
@ -30,7 +30,7 @@ export const Info = Schema.Struct({
|
|||
})
|
||||
.annotate({ identifier: "AgentV2.Info" })
|
||||
.pipe(
|
||||
withStatics((schema) => ({
|
||||
statics((schema) => ({
|
||||
empty: (id: ID) =>
|
||||
schema.make({ id, request: { headers: {}, body: {} }, mode: "all", hidden: false, permissions: [] }),
|
||||
})),
|
||||
|
|
|
|||
|
|
@ -3,11 +3,11 @@ export * as Credential from "./credential"
|
|||
import { Schema } from "effect"
|
||||
import { IntegrationMethodID } from "./integration-id"
|
||||
import { ascending } from "./identifier"
|
||||
import { NonNegativeInt, withStatics } from "./schema"
|
||||
import { NonNegativeInt, statics } from "./schema"
|
||||
|
||||
export const ID = Schema.String.pipe(
|
||||
Schema.brand("Credential.ID"),
|
||||
withStatics((schema) => ({ create: () => schema.make("cred_" + ascending()) })),
|
||||
statics((schema) => ({ create: () => schema.make("cred_" + ascending()) })),
|
||||
)
|
||||
export type ID = typeof ID.Type
|
||||
|
||||
|
|
|
|||
|
|
@ -3,11 +3,11 @@ export * as Event from "./event"
|
|||
import { Schema } from "effect"
|
||||
import { ascending } from "./identifier"
|
||||
import { Location } from "./location"
|
||||
import { withStatics } from "./schema"
|
||||
import { statics } from "./schema"
|
||||
|
||||
export const ID = Schema.String.check(Schema.isStartsWith("evt_")).pipe(
|
||||
Schema.brand("Event.ID"),
|
||||
withStatics((schema) => ({ create: () => schema.make("evt_" + ascending()) })),
|
||||
statics((schema) => ({ create: () => schema.make("evt_" + ascending()) })),
|
||||
)
|
||||
export type ID = typeof ID.Type
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { Schema } from "effect"
|
|||
import { define, inventory } from "./event"
|
||||
import { Connection } from "./connection"
|
||||
import { ascending } from "./identifier"
|
||||
import { withStatics } from "./schema"
|
||||
import { statics } from "./schema"
|
||||
import { IntegrationID, IntegrationMethodID } from "./integration-id"
|
||||
|
||||
export const ID = IntegrationID
|
||||
|
|
@ -102,7 +102,7 @@ export class Info extends Schema.Class<Info>("Integration.Info")({
|
|||
|
||||
export const AttemptID = Schema.String.pipe(
|
||||
Schema.brand("Integration.AttemptID"),
|
||||
withStatics((schema) => ({ create: () => schema.make("con_" + ascending()) })),
|
||||
statics((schema) => ({ create: () => schema.make("con_" + ascending()) })),
|
||||
)
|
||||
export type AttemptID = typeof AttemptID.Type
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
export * as Location from "./location"
|
||||
|
||||
import { Effect, Schema } from "effect"
|
||||
import { AbsolutePath, optionalOmitUndefined } from "./schema"
|
||||
import { AbsolutePath, optional } from "./schema"
|
||||
import { ProjectID } from "./project-id"
|
||||
import { WorkspaceID } from "./workspace-id"
|
||||
|
||||
|
|
@ -16,7 +16,7 @@ export const Ref = Schema.Struct({
|
|||
|
||||
export class Info extends Schema.Class<Info>("Location.Info")({
|
||||
directory: AbsolutePath,
|
||||
workspaceID: optionalOmitUndefined(WorkspaceID),
|
||||
workspaceID: optional(WorkspaceID),
|
||||
project: Schema.Struct({
|
||||
id: ProjectID,
|
||||
directory: AbsolutePath,
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ export * as Model from "./model"
|
|||
|
||||
import { Schema } from "effect"
|
||||
import { Provider } from "./provider"
|
||||
import { withStatics } from "./schema"
|
||||
import { statics } from "./schema"
|
||||
|
||||
export const ID = Schema.String.pipe(Schema.brand("ModelV2.ID"))
|
||||
export type ID = typeof ID.Type
|
||||
|
|
@ -83,7 +83,7 @@ export const Info = Schema.Struct({
|
|||
})
|
||||
.annotate({ identifier: "ModelV2.Info" })
|
||||
.pipe(
|
||||
withStatics((schema) => ({
|
||||
statics((schema) => ({
|
||||
empty: (providerID: Provider.ID, modelID: ID) =>
|
||||
schema.make({
|
||||
id: modelID,
|
||||
|
|
|
|||
|
|
@ -3,11 +3,11 @@ export * as PermissionSaved from "./permission-saved"
|
|||
import { Schema } from "effect"
|
||||
import { ascending } from "./identifier"
|
||||
import { ProjectID } from "./project-id"
|
||||
import { withStatics } from "./schema"
|
||||
import { statics } from "./schema"
|
||||
|
||||
export const ID = Schema.String.pipe(
|
||||
Schema.brand("PermissionSaved.ID"),
|
||||
withStatics((schema) => ({ create: () => schema.make("psv_" + ascending()) })),
|
||||
statics((schema) => ({ create: () => schema.make("psv_" + ascending()) })),
|
||||
)
|
||||
export type ID = typeof ID.Type
|
||||
|
||||
|
|
|
|||
|
|
@ -4,12 +4,12 @@ import { Schema } from "effect"
|
|||
import { define, inventory } from "./event"
|
||||
import { ascending } from "./identifier"
|
||||
import { Project } from "./project"
|
||||
import { withStatics } from "./schema"
|
||||
import { statics } from "./schema"
|
||||
import { SessionID } from "./session-id"
|
||||
|
||||
export const ID = Schema.String.check(Schema.isStartsWith("per")).pipe(
|
||||
Schema.brand("PermissionID"),
|
||||
withStatics((schema) => ({ ascending: (id?: string) => schema.make(id ?? "per_" + ascending()) })),
|
||||
statics((schema) => ({ ascending: (id?: string) => schema.make(id ?? "per_" + ascending()) })),
|
||||
)
|
||||
export type ID = typeof ID.Type
|
||||
|
||||
|
|
@ -64,4 +64,3 @@ const Replied = define({
|
|||
schema: { sessionID: SessionID, requestID: ID, reply: Reply },
|
||||
})
|
||||
export const Event = { Asked, Replied, Definitions: inventory(Asked, Replied) }
|
||||
export const PermissionV1Event = Event
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@ import { Schema } from "effect"
|
|||
import { define, inventory } from "./event"
|
||||
import { ascending } from "./identifier"
|
||||
import { SessionID } from "./session-id"
|
||||
import { withStatics } from "./schema"
|
||||
import { statics } from "./schema"
|
||||
|
||||
export const ID = Schema.String.check(Schema.isStartsWith("per")).pipe(
|
||||
Schema.brand("PermissionV2.ID"),
|
||||
withStatics((schema) => ({ create: (id?: string) => schema.make(id ?? "per_" + ascending()) })),
|
||||
statics((schema) => ({ create: (id?: string) => schema.make(id ?? "per_" + ascending()) })),
|
||||
)
|
||||
export type ID = typeof ID.Type
|
||||
|
||||
|
|
|
|||
|
|
@ -5,11 +5,9 @@ import { define, inventory } from "./event"
|
|||
|
||||
export const ID = Schema.String.pipe(Schema.brand("Plugin.ID"))
|
||||
export type ID = typeof ID.Type
|
||||
export const PluginID = ID
|
||||
|
||||
const Added = define({
|
||||
type: "plugin.added",
|
||||
schema: { id: ID },
|
||||
})
|
||||
export const Event = { Added, Definitions: inventory(Added) }
|
||||
export const PluginEvent = Event
|
||||
|
|
|
|||
|
|
@ -8,4 +8,3 @@ const Updated = define({
|
|||
schema: { projectID: Project.ID },
|
||||
})
|
||||
export const Event = { Updated, Definitions: inventory(Updated) }
|
||||
export const ProjectDirectoriesEvent = Event
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import { Schema } from "effect"
|
||||
import { withStatics } from "./schema"
|
||||
import { statics } from "./schema"
|
||||
|
||||
export const ProjectID = Schema.String.pipe(
|
||||
Schema.brand("Project.ID"),
|
||||
withStatics((schema) => ({ global: schema.make("global") })),
|
||||
statics((schema) => ({ global: schema.make("global") })),
|
||||
)
|
||||
export type ProjectID = typeof ProjectID.Type
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ export * as Project from "./project"
|
|||
|
||||
import { Schema } from "effect"
|
||||
import { define, inventory } from "./event"
|
||||
import { NonNegativeInt, optionalOmitUndefined } from "./schema"
|
||||
import { NonNegativeInt, optional } from "./schema"
|
||||
import { ProjectID } from "./project-id"
|
||||
|
||||
export const ID = ProjectID
|
||||
|
|
@ -10,28 +10,28 @@ export type ID = typeof ID.Type
|
|||
|
||||
export const Vcs = Schema.Literal("git")
|
||||
export const Icon = Schema.Struct({
|
||||
url: optionalOmitUndefined(Schema.String),
|
||||
override: optionalOmitUndefined(Schema.String),
|
||||
color: optionalOmitUndefined(Schema.String),
|
||||
url: optional(Schema.String),
|
||||
override: optional(Schema.String),
|
||||
color: optional(Schema.String),
|
||||
})
|
||||
export const Commands = Schema.Struct({
|
||||
start: optionalOmitUndefined(
|
||||
start: optional(
|
||||
Schema.String.annotate({ description: "Startup script to run when creating a new workspace (worktree)" }),
|
||||
),
|
||||
})
|
||||
export const Time = Schema.Struct({
|
||||
created: NonNegativeInt,
|
||||
updated: NonNegativeInt,
|
||||
initialized: optionalOmitUndefined(NonNegativeInt),
|
||||
initialized: optional(NonNegativeInt),
|
||||
})
|
||||
|
||||
export const Info = Schema.Struct({
|
||||
id: ID,
|
||||
worktree: Schema.String,
|
||||
vcs: optionalOmitUndefined(Vcs),
|
||||
name: optionalOmitUndefined(Schema.String),
|
||||
icon: optionalOmitUndefined(Icon),
|
||||
commands: optionalOmitUndefined(Commands),
|
||||
vcs: optional(Vcs),
|
||||
name: optional(Schema.String),
|
||||
icon: optional(Icon),
|
||||
commands: optional(Commands),
|
||||
time: Time,
|
||||
sandboxes: Schema.Array(Schema.String),
|
||||
}).annotate({ identifier: "Project" })
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { Schema } from "effect"
|
||||
import { withStatics } from "./schema"
|
||||
import { statics } from "./schema"
|
||||
|
||||
export interface Source extends Schema.Schema.Type<typeof Source> {}
|
||||
export const Source = Schema.Struct({
|
||||
|
|
@ -18,7 +18,7 @@ export const FileAttachment = Schema.Struct({
|
|||
})
|
||||
.annotate({ identifier: "Prompt.FileAttachment" })
|
||||
.pipe(
|
||||
withStatics((schema) => ({
|
||||
statics((schema) => ({
|
||||
create: (input: FileAttachment) =>
|
||||
schema.make({
|
||||
uri: input.uri,
|
||||
|
|
@ -44,7 +44,7 @@ export const Prompt = Schema.Struct({
|
|||
})
|
||||
.annotate({ identifier: "Prompt" })
|
||||
.pipe(
|
||||
withStatics((schema) => ({
|
||||
statics((schema) => ({
|
||||
equivalence: Schema.toEquivalence(schema),
|
||||
fromUserMessage: (input: Pick<Prompt, "text" | "files" | "agents">) =>
|
||||
schema.make({
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@ export * as Provider from "./provider"
|
|||
|
||||
import { Schema } from "effect"
|
||||
import { Integration } from "./integration"
|
||||
import { withStatics } from "./schema"
|
||||
import { statics } from "./schema"
|
||||
|
||||
export const ID = Schema.String.pipe(
|
||||
Schema.brand("ProviderV2.ID"),
|
||||
withStatics((schema) => ({
|
||||
statics((schema) => ({
|
||||
opencode: schema.make("opencode"),
|
||||
anthropic: schema.make("anthropic"),
|
||||
openai: schema.make("openai"),
|
||||
|
|
@ -57,7 +57,7 @@ export const Info = Schema.Struct({
|
|||
})
|
||||
.annotate({ identifier: "ProviderV2.Info" })
|
||||
.pipe(
|
||||
withStatics((schema) => ({
|
||||
statics((schema) => ({
|
||||
empty: (id: ID) =>
|
||||
schema.make({
|
||||
id,
|
||||
|
|
|
|||
|
|
@ -3,13 +3,12 @@ export * as Pty from "./pty"
|
|||
import { Schema } from "effect"
|
||||
import { define, inventory } from "./event"
|
||||
import { ascending } from "./identifier"
|
||||
import { NonNegativeInt, PositiveInt } from "./schema"
|
||||
import { withStatics } from "./schema"
|
||||
import { NonNegativeInt, PositiveInt, statics } from "./schema"
|
||||
|
||||
const IDSchema = Schema.String.check(Schema.isStartsWith("pty")).pipe(Schema.brand("PtyID"))
|
||||
|
||||
export const ID = IDSchema.pipe(
|
||||
withStatics((schema: typeof IDSchema) => ({
|
||||
statics((schema: typeof IDSchema) => ({
|
||||
ascending: (id?: string) => schema.make(id ?? "pty_" + ascending()),
|
||||
})),
|
||||
)
|
||||
|
|
@ -25,14 +24,12 @@ export const Info = Schema.Struct({
|
|||
pid: NonNegativeInt,
|
||||
exitCode: Schema.optional(NonNegativeInt),
|
||||
}).annotate({ identifier: "Pty" })
|
||||
export const PtyInfo = Info
|
||||
|
||||
const Created = define({ type: "pty.created", schema: { info: Info } })
|
||||
const Updated = define({ type: "pty.updated", schema: { info: Info } })
|
||||
const Exited = define({ type: "pty.exited", schema: { id: ID, exitCode: NonNegativeInt } })
|
||||
const Deleted = define({ type: "pty.deleted", schema: { id: ID } })
|
||||
export const Event = { Created, Updated, Exited, Deleted, Definitions: inventory(Created, Updated, Exited, Deleted) }
|
||||
export const PtyEvent = Event
|
||||
|
||||
export const CreateInput = Schema.Struct({
|
||||
command: Schema.optional(Schema.String),
|
||||
|
|
|
|||
|
|
@ -3,13 +3,13 @@ export * as QuestionV1 from "./question-v1"
|
|||
import { Schema } from "effect"
|
||||
import { define, inventory } from "./event"
|
||||
import { ascending } from "./identifier"
|
||||
import { withStatics } from "./schema"
|
||||
import { statics } from "./schema"
|
||||
import { SessionID } from "./session-id"
|
||||
import { SessionV1 } from "./session-v1"
|
||||
|
||||
export const ID = Schema.String.check(Schema.isStartsWith("que")).pipe(
|
||||
Schema.brand("QuestionID"),
|
||||
withStatics((schema) => ({ ascending: (id?: string) => schema.make(id ?? "que_" + ascending()) })),
|
||||
statics((schema) => ({ ascending: (id?: string) => schema.make(id ?? "que_" + ascending()) })),
|
||||
)
|
||||
|
||||
export const Option = Schema.Struct({
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@ import { Schema } from "effect"
|
|||
import { define, inventory } from "./event"
|
||||
import { ascending } from "./identifier"
|
||||
import { SessionID } from "./session-id"
|
||||
import { withStatics } from "./schema"
|
||||
import { statics } from "./schema"
|
||||
|
||||
export const ID = Schema.String.check(Schema.isStartsWith("que")).pipe(
|
||||
Schema.brand("QuestionV2.ID"),
|
||||
withStatics((schema) => ({ ascending: (id?: string) => schema.make(id ?? "que_" + ascending()) })),
|
||||
statics((schema) => ({ ascending: (id?: string) => schema.make(id ?? "que_" + ascending()) })),
|
||||
)
|
||||
export type ID = typeof ID.Type
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ export * as Revert from "./revert"
|
|||
|
||||
import { Schema } from "effect"
|
||||
import { NonNegativeInt, RelativePath } from "./schema"
|
||||
import { SessionMessageID } from "./session-message-id"
|
||||
import { SessionMessage } from "./session-message"
|
||||
|
||||
export const FileDiff = Schema.Struct({
|
||||
path: RelativePath,
|
||||
|
|
@ -14,7 +14,7 @@ export const FileDiff = Schema.Struct({
|
|||
export type FileDiff = typeof FileDiff.Type
|
||||
|
||||
export const State = Schema.Struct({
|
||||
messageID: SessionMessageID.ID,
|
||||
messageID: SessionMessage.ID,
|
||||
partID: Schema.String.pipe(Schema.optional),
|
||||
snapshot: Schema.String.pipe(Schema.optional),
|
||||
diff: Schema.String.pipe(Schema.optional),
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ export type RelativePath = typeof RelativePath.Type
|
|||
export const AbsolutePath = Schema.String.pipe(Schema.brand("AbsolutePath"))
|
||||
export type AbsolutePath = typeof AbsolutePath.Type
|
||||
|
||||
export const optionalOmitUndefined = <S extends Schema.Top>(schema: S) =>
|
||||
export const optional = <S extends Schema.Top>(schema: S) =>
|
||||
Schema.optionalKey(schema).pipe(
|
||||
Schema.decodeTo(Schema.optional(schema), {
|
||||
decode: SchemaGetter.passthrough({ strict: false }),
|
||||
|
|
@ -17,7 +17,7 @@ export const optionalOmitUndefined = <S extends Schema.Top>(schema: S) =>
|
|||
}),
|
||||
)
|
||||
|
||||
export const withStatics =
|
||||
export const statics =
|
||||
<S extends object, M extends Record<string, unknown>>(methods: (schema: S) => M) =>
|
||||
(schema: S): S & M =>
|
||||
Object.assign(schema, methods(schema))
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import { DateTimeUtcFromMillis, NonNegativeInt, RelativePath } from "./schema"
|
|||
import { FileAttachment, Prompt } from "./prompt"
|
||||
import { SessionID } from "./session-id"
|
||||
import { Location } from "./location"
|
||||
import { SessionMessageID } from "./session-message-id"
|
||||
import { SessionMessage } from "./session-message"
|
||||
import { Revert } from "./revert"
|
||||
|
||||
|
|
@ -30,7 +29,7 @@ const Base = {
|
|||
}
|
||||
const PromptFields = {
|
||||
...Base,
|
||||
messageID: SessionMessageID.ID,
|
||||
messageID: SessionMessage.ID,
|
||||
prompt: Prompt,
|
||||
delivery: Delivery,
|
||||
}
|
||||
|
|
@ -56,7 +55,7 @@ export const AgentSwitched = Event.define({
|
|||
...options,
|
||||
schema: {
|
||||
...Base,
|
||||
messageID: SessionMessageID.ID,
|
||||
messageID: SessionMessage.ID,
|
||||
agent: Schema.String,
|
||||
},
|
||||
})
|
||||
|
|
@ -67,7 +66,7 @@ export const ModelSwitched = Event.define({
|
|||
...options,
|
||||
schema: {
|
||||
...Base,
|
||||
messageID: SessionMessageID.ID,
|
||||
messageID: SessionMessage.ID,
|
||||
model: Model.Ref,
|
||||
},
|
||||
})
|
||||
|
|
@ -103,7 +102,7 @@ export const ContextUpdated = Event.define({
|
|||
...options,
|
||||
schema: {
|
||||
...Base,
|
||||
messageID: SessionMessageID.ID,
|
||||
messageID: SessionMessage.ID,
|
||||
text: Schema.String,
|
||||
},
|
||||
})
|
||||
|
|
@ -114,7 +113,7 @@ export const Synthetic = Event.define({
|
|||
...options,
|
||||
schema: {
|
||||
...Base,
|
||||
messageID: SessionMessageID.ID,
|
||||
messageID: SessionMessage.ID,
|
||||
text: Schema.String,
|
||||
},
|
||||
})
|
||||
|
|
@ -126,7 +125,7 @@ export namespace Shell {
|
|||
...options,
|
||||
schema: {
|
||||
...Base,
|
||||
messageID: SessionMessageID.ID,
|
||||
messageID: SessionMessage.ID,
|
||||
callID: Schema.String,
|
||||
command: Schema.String,
|
||||
},
|
||||
|
|
@ -151,7 +150,7 @@ export namespace Step {
|
|||
...options,
|
||||
schema: {
|
||||
...Base,
|
||||
assistantMessageID: SessionMessageID.ID,
|
||||
assistantMessageID: SessionMessage.ID,
|
||||
agent: Schema.String,
|
||||
model: Model.Ref,
|
||||
snapshot: Schema.String.pipe(Schema.optional),
|
||||
|
|
@ -164,7 +163,7 @@ export namespace Step {
|
|||
...stepSettlementOptions,
|
||||
schema: {
|
||||
...Base,
|
||||
assistantMessageID: SessionMessageID.ID,
|
||||
assistantMessageID: SessionMessage.ID,
|
||||
finish: Schema.String,
|
||||
cost: Schema.Finite,
|
||||
tokens: Schema.Struct({
|
||||
|
|
@ -187,7 +186,7 @@ export namespace Step {
|
|||
...stepSettlementOptions,
|
||||
schema: {
|
||||
...Base,
|
||||
assistantMessageID: SessionMessageID.ID,
|
||||
assistantMessageID: SessionMessage.ID,
|
||||
error: UnknownError,
|
||||
},
|
||||
})
|
||||
|
|
@ -200,7 +199,7 @@ export namespace Text {
|
|||
...options,
|
||||
schema: {
|
||||
...Base,
|
||||
assistantMessageID: SessionMessageID.ID,
|
||||
assistantMessageID: SessionMessage.ID,
|
||||
textID: Schema.String,
|
||||
},
|
||||
})
|
||||
|
|
@ -211,7 +210,7 @@ export namespace Text {
|
|||
type: "session.next.text.delta",
|
||||
schema: {
|
||||
...Base,
|
||||
assistantMessageID: SessionMessageID.ID,
|
||||
assistantMessageID: SessionMessage.ID,
|
||||
textID: Schema.String,
|
||||
delta: Schema.String,
|
||||
},
|
||||
|
|
@ -223,7 +222,7 @@ export namespace Text {
|
|||
...options,
|
||||
schema: {
|
||||
...Base,
|
||||
assistantMessageID: SessionMessageID.ID,
|
||||
assistantMessageID: SessionMessage.ID,
|
||||
textID: Schema.String,
|
||||
text: Schema.String,
|
||||
},
|
||||
|
|
@ -237,7 +236,7 @@ export namespace Reasoning {
|
|||
...options,
|
||||
schema: {
|
||||
...Base,
|
||||
assistantMessageID: SessionMessageID.ID,
|
||||
assistantMessageID: SessionMessage.ID,
|
||||
reasoningID: Schema.String,
|
||||
providerMetadata: ProviderMetadata.pipe(Schema.optional),
|
||||
},
|
||||
|
|
@ -249,7 +248,7 @@ export namespace Reasoning {
|
|||
type: "session.next.reasoning.delta",
|
||||
schema: {
|
||||
...Base,
|
||||
assistantMessageID: SessionMessageID.ID,
|
||||
assistantMessageID: SessionMessage.ID,
|
||||
reasoningID: Schema.String,
|
||||
delta: Schema.String,
|
||||
},
|
||||
|
|
@ -261,7 +260,7 @@ export namespace Reasoning {
|
|||
...options,
|
||||
schema: {
|
||||
...Base,
|
||||
assistantMessageID: SessionMessageID.ID,
|
||||
assistantMessageID: SessionMessage.ID,
|
||||
reasoningID: Schema.String,
|
||||
text: Schema.String,
|
||||
providerMetadata: ProviderMetadata.pipe(Schema.optional),
|
||||
|
|
@ -273,7 +272,7 @@ export namespace Reasoning {
|
|||
export namespace Tool {
|
||||
const ToolBase = {
|
||||
...Base,
|
||||
assistantMessageID: SessionMessageID.ID,
|
||||
assistantMessageID: SessionMessage.ID,
|
||||
callID: Schema.String,
|
||||
}
|
||||
|
||||
|
|
@ -401,7 +400,7 @@ export namespace Compaction {
|
|||
...options,
|
||||
schema: {
|
||||
...Base,
|
||||
messageID: SessionMessageID.ID,
|
||||
messageID: SessionMessage.ID,
|
||||
reason: Schema.Union([Schema.Literal("auto"), Schema.Literal("manual")]),
|
||||
},
|
||||
})
|
||||
|
|
@ -411,7 +410,7 @@ export namespace Compaction {
|
|||
type: "session.next.compaction.delta",
|
||||
schema: {
|
||||
...Base,
|
||||
messageID: SessionMessageID.ID,
|
||||
messageID: SessionMessage.ID,
|
||||
text: Schema.String,
|
||||
},
|
||||
})
|
||||
|
|
@ -422,7 +421,7 @@ export namespace Compaction {
|
|||
...options,
|
||||
schema: {
|
||||
...Base,
|
||||
messageID: SessionMessageID.ID,
|
||||
messageID: SessionMessage.ID,
|
||||
reason: Started.data.fields.reason,
|
||||
text: Schema.String,
|
||||
recent: Schema.String,
|
||||
|
|
@ -441,7 +440,7 @@ export namespace RevertEvent {
|
|||
export const Committed = Event.define({
|
||||
type: "session.next.revert.committed",
|
||||
...options,
|
||||
schema: { ...Base, messageID: SessionMessageID.ID },
|
||||
schema: { ...Base, messageID: SessionMessage.ID },
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import { Schema } from "effect"
|
||||
import { descending } from "./identifier"
|
||||
import { withStatics } from "./schema"
|
||||
import { statics } from "./schema"
|
||||
|
||||
export const SessionID = Schema.String.check(Schema.isStartsWith("ses")).pipe(
|
||||
Schema.brand("SessionID"),
|
||||
withStatics((schema) => {
|
||||
statics((schema) => {
|
||||
const create = () => schema.make("ses_" + descending())
|
||||
return {
|
||||
create,
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import { Prompt } from "./prompt"
|
|||
import { DateTimeUtcFromMillis, NonNegativeInt } from "./schema"
|
||||
import { SessionDelivery } from "./session-delivery"
|
||||
import { SessionID } from "./session-id"
|
||||
import { SessionMessageID } from "./session-message-id"
|
||||
import { SessionMessage } from "./session-message"
|
||||
|
||||
export const Delivery = SessionDelivery.Delivery
|
||||
export type Delivery = SessionDelivery.Delivery
|
||||
|
|
@ -13,7 +13,7 @@ export type Delivery = SessionDelivery.Delivery
|
|||
export interface Admitted extends Schema.Schema.Type<typeof Admitted> {}
|
||||
export const Admitted = Schema.Struct({
|
||||
admittedSeq: NonNegativeInt,
|
||||
id: SessionMessageID.ID,
|
||||
id: SessionMessage.ID,
|
||||
sessionID: SessionID,
|
||||
prompt: Prompt,
|
||||
delivery: Delivery,
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
export * as SessionMessageID from "./session-message-id"
|
||||
|
||||
import { Schema } from "effect"
|
||||
import { ascending } from "./identifier"
|
||||
import { withStatics } from "./schema"
|
||||
|
||||
export const ID = Schema.String.check(Schema.isStartsWith("msg_")).pipe(
|
||||
Schema.brand("Session.Message.ID"),
|
||||
withStatics((schema) => ({ create: () => schema.make("msg_" + ascending()) })),
|
||||
)
|
||||
export type ID = typeof ID.Type
|
||||
|
|
@ -4,12 +4,15 @@ import { Schema } from "effect"
|
|||
import { ProviderMetadata, ToolContent } from "./llm"
|
||||
import { Model } from "./model"
|
||||
import { FileAttachment, Prompt } from "./prompt"
|
||||
import { DateTimeUtcFromMillis, RelativePath } from "./schema"
|
||||
import { DateTimeUtcFromMillis, RelativePath, statics } from "./schema"
|
||||
import { SessionID } from "./session-id"
|
||||
import { SessionMessageID } from "./session-message-id"
|
||||
import { ascending } from "./identifier"
|
||||
|
||||
export const ID = SessionMessageID.ID
|
||||
export type ID = SessionMessageID.ID
|
||||
export const ID = Schema.String.check(Schema.isStartsWith("msg_")).pipe(
|
||||
Schema.brand("Session.Message.ID"),
|
||||
statics((schema) => ({ create: () => schema.make("msg_" + ascending()) })),
|
||||
)
|
||||
export type ID = typeof ID.Type
|
||||
|
||||
export interface UnknownError extends Schema.Schema.Type<typeof UnknownError> {}
|
||||
export const UnknownError = Schema.Struct({
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ export const Info = Schema.Struct({
|
|||
priority: Schema.String.annotate({ description: "Priority level of the task: high, medium, low" }),
|
||||
}).annotate({ identifier: "Todo" })
|
||||
export type Info = typeof Info.Type
|
||||
export const SessionTodoInfo = Info
|
||||
|
||||
const Updated = define({
|
||||
type: "todo.updated",
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import { PermissionV1 } from "./permission-v1"
|
|||
import { Project } from "./project"
|
||||
import { Provider } from "./provider"
|
||||
import { Model } from "./model"
|
||||
import { NonNegativeInt, optionalOmitUndefined, withStatics } from "./schema"
|
||||
import { NonNegativeInt, optional, statics } from "./schema"
|
||||
import { ascending } from "./identifier"
|
||||
import { SessionID } from "./session-id"
|
||||
import { WorkspaceID } from "./workspace-id"
|
||||
|
|
@ -16,13 +16,13 @@ const Timestamp = Schema.Finite.check(Schema.isGreaterThanOrEqualTo(0))
|
|||
|
||||
export const MessageID = Schema.String.check(Schema.isStartsWith("msg")).pipe(
|
||||
Schema.brand("MessageID"),
|
||||
withStatics((schema) => ({ ascending: (id?: string) => schema.make(id ?? "msg_" + ascending()) })),
|
||||
statics((schema) => ({ ascending: (id?: string) => schema.make(id ?? "msg_" + ascending()) })),
|
||||
)
|
||||
export type MessageID = typeof MessageID.Type
|
||||
|
||||
export const PartID = Schema.String.check(Schema.isStartsWith("prt")).pipe(
|
||||
Schema.brand("PartID"),
|
||||
withStatics((schema) => ({ ascending: (id?: string) => schema.make(id ?? "prt_" + ascending()) })),
|
||||
statics((schema) => ({ ascending: (id?: string) => schema.make(id ?? "prt_" + ascending()) })),
|
||||
)
|
||||
export type PartID = typeof PartID.Type
|
||||
|
||||
|
|
@ -510,7 +510,7 @@ const SessionSummary = Schema.Struct({
|
|||
additions: Schema.Finite,
|
||||
deletions: Schema.Finite,
|
||||
files: Schema.Finite,
|
||||
diffs: optionalOmitUndefined(Schema.Array(FileDiff.Info)),
|
||||
diffs: optional(Schema.Array(FileDiff.Info)),
|
||||
})
|
||||
|
||||
const SessionTokens = Schema.Struct({
|
||||
|
|
@ -529,42 +529,42 @@ const SessionShare = Schema.Struct({
|
|||
|
||||
const SessionRevert = Schema.Struct({
|
||||
messageID: MessageID,
|
||||
partID: optionalOmitUndefined(PartID),
|
||||
snapshot: optionalOmitUndefined(Schema.String),
|
||||
diff: optionalOmitUndefined(Schema.String),
|
||||
partID: optional(PartID),
|
||||
snapshot: optional(Schema.String),
|
||||
diff: optional(Schema.String),
|
||||
})
|
||||
|
||||
const SessionModel = Schema.Struct({
|
||||
id: Model.ID,
|
||||
providerID: Provider.ID,
|
||||
variant: optionalOmitUndefined(Schema.String),
|
||||
variant: optional(Schema.String),
|
||||
})
|
||||
|
||||
export const SessionInfo = Schema.Struct({
|
||||
id: SessionID,
|
||||
slug: Schema.String,
|
||||
projectID: Project.ID,
|
||||
workspaceID: optionalOmitUndefined(WorkspaceID),
|
||||
workspaceID: optional(WorkspaceID),
|
||||
directory: Schema.String,
|
||||
path: optionalOmitUndefined(Schema.String),
|
||||
parentID: optionalOmitUndefined(SessionID),
|
||||
summary: optionalOmitUndefined(SessionSummary),
|
||||
cost: optionalOmitUndefined(Schema.Finite),
|
||||
tokens: optionalOmitUndefined(SessionTokens),
|
||||
share: optionalOmitUndefined(SessionShare),
|
||||
path: optional(Schema.String),
|
||||
parentID: optional(SessionID),
|
||||
summary: optional(SessionSummary),
|
||||
cost: optional(Schema.Finite),
|
||||
tokens: optional(SessionTokens),
|
||||
share: optional(SessionShare),
|
||||
title: Schema.String,
|
||||
agent: optionalOmitUndefined(Schema.String),
|
||||
model: optionalOmitUndefined(SessionModel),
|
||||
agent: optional(Schema.String),
|
||||
model: optional(SessionModel),
|
||||
version: Schema.String,
|
||||
metadata: optionalOmitUndefined(Schema.Record(Schema.String, Schema.Any)),
|
||||
metadata: optional(Schema.Record(Schema.String, Schema.Any)),
|
||||
time: Schema.Struct({
|
||||
created: NonNegativeInt,
|
||||
updated: NonNegativeInt,
|
||||
compacting: optionalOmitUndefined(NonNegativeInt),
|
||||
archived: optionalOmitUndefined(Schema.Finite),
|
||||
compacting: optional(NonNegativeInt),
|
||||
archived: optional(Schema.Finite),
|
||||
}),
|
||||
permission: optionalOmitUndefined(PermissionV1.Ruleset),
|
||||
revert: optionalOmitUndefined(SessionRevert),
|
||||
permission: optional(PermissionV1.Ruleset),
|
||||
revert: optional(SessionRevert),
|
||||
}).annotate({ identifier: "Session" })
|
||||
export type SessionInfo = typeof SessionInfo.Type
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import { Agent } from "./agent"
|
|||
import { Location } from "./location"
|
||||
import { Model } from "./model"
|
||||
import { Project } from "./project"
|
||||
import { DateTimeUtcFromMillis, optionalOmitUndefined, RelativePath } from "./schema"
|
||||
import { DateTimeUtcFromMillis, optional, RelativePath } from "./schema"
|
||||
import { SessionEvent } from "./session-event"
|
||||
import { SessionID } from "./session-id"
|
||||
import { Revert } from "./revert"
|
||||
|
|
@ -18,7 +18,7 @@ export const Event = SessionEvent
|
|||
export interface Info extends Schema.Schema.Type<typeof Info> {}
|
||||
export const Info = Schema.Struct({
|
||||
id: ID,
|
||||
parentID: ID.pipe(optionalOmitUndefined),
|
||||
parentID: ID.pipe(optional),
|
||||
projectID: Project.ID,
|
||||
agent: Agent.ID.pipe(Schema.optional),
|
||||
model: Model.Ref.pipe(Schema.optional),
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import { Schema } from "effect"
|
||||
import { ascending } from "./identifier"
|
||||
import { withStatics } from "./schema"
|
||||
import { statics } from "./schema"
|
||||
|
||||
export const WorkspaceID = Schema.String.check(Schema.isStartsWith("wrk")).pipe(
|
||||
Schema.brand("WorkspaceV2.ID"),
|
||||
withStatics((schema) => {
|
||||
statics((schema) => {
|
||||
const create = () => schema.make("wrk_" + ascending())
|
||||
return {
|
||||
ascending: (id?: string) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue