refactor(schema): normalize module patterns (#33770)
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
export * as PluginV2 from "./plugin"
|
export * as PluginV2 from "./plugin"
|
||||||
|
|
||||||
import { Context, Deferred, Effect, Exit, Layer, Scope } from "effect"
|
import { Context, Deferred, Effect, Exit, Layer, Scope } from "effect"
|
||||||
import type { Plugin } from "@opencode-ai/plugin/v2/effect"
|
import type { Plugin as PluginRuntime } from "@opencode-ai/plugin/v2/effect"
|
||||||
import { PluginEvent, PluginID } from "@opencode-ai/schema/plugin"
|
import { Plugin } from "@opencode-ai/schema/plugin"
|
||||||
import { AgentV2 } from "./agent"
|
import { AgentV2 } from "./agent"
|
||||||
import { AISDK } from "./aisdk"
|
import { AISDK } from "./aisdk"
|
||||||
import { Catalog } from "./catalog"
|
import { Catalog } from "./catalog"
|
||||||
@@ -15,13 +15,12 @@ import { Reference } from "./reference"
|
|||||||
import { SkillV2 } from "./skill"
|
import { SkillV2 } from "./skill"
|
||||||
import { State } from "./state"
|
import { State } from "./state"
|
||||||
|
|
||||||
export const ID = PluginID
|
export const ID = Plugin.ID
|
||||||
export type ID = typeof ID.Type
|
export type ID = typeof ID.Type
|
||||||
|
export const Event = Plugin.Event
|
||||||
export const Event = PluginEvent
|
|
||||||
|
|
||||||
export interface Interface {
|
export interface Interface {
|
||||||
readonly add: (id: ID, effect: Plugin["effect"]) => Effect.Effect<void>
|
readonly add: (id: ID, effect: PluginRuntime["effect"]) => Effect.Effect<void>
|
||||||
readonly remove: (id: ID) => Effect.Effect<void>
|
readonly remove: (id: ID) => Effect.Effect<void>
|
||||||
readonly wait: (id: ID) => Effect.Effect<void>
|
readonly wait: (id: ID) => Effect.Effect<void>
|
||||||
}
|
}
|
||||||
@@ -38,9 +37,9 @@ export const layer = Layer.effect(
|
|||||||
const loading = new Set<ID>()
|
const loading = new Set<ID>()
|
||||||
const waiters = new Map<ID, Set<Deferred.Deferred<void>>>()
|
const waiters = new Map<ID, Set<Deferred.Deferred<void>>>()
|
||||||
const failures = new Map<ID, Exit.Exit<void, never>>()
|
const failures = new Map<ID, Exit.Exit<void, never>>()
|
||||||
let host: Parameters<Plugin["effect"]>[0]
|
let host: Parameters<PluginRuntime["effect"]>[0]
|
||||||
|
|
||||||
const add = Effect.fn("Plugin.add")(function* (id: ID, effect: Plugin["effect"]) {
|
const add = Effect.fn("Plugin.add")(function* (id: ID, effect: PluginRuntime["effect"]) {
|
||||||
if (loading.has(id)) return yield* Effect.die(`Plugin load cycle detected for ${id}`)
|
if (loading.has(id)) return yield* Effect.die(`Plugin load cycle detected for ${id}`)
|
||||||
|
|
||||||
yield* locks.withLock(id)(
|
yield* locks.withLock(id)(
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import { Slug } from "../util/slug"
|
|||||||
import { EventV2 } from "../event"
|
import { EventV2 } from "../event"
|
||||||
import { Database } from "../database/database"
|
import { Database } from "../database/database"
|
||||||
import { Location } from "../location"
|
import { Location } from "../location"
|
||||||
import { ProjectDirectoriesEvent } from "@opencode-ai/schema/project-directories"
|
import { Event } from "@opencode-ai/schema/project-directories"
|
||||||
import { ProjectCopy } from "@opencode-ai/schema/project-copy"
|
import { ProjectCopy } from "@opencode-ai/schema/project-copy"
|
||||||
|
|
||||||
export const StrategyID = ProjectCopy.StrategyID
|
export const StrategyID = ProjectCopy.StrategyID
|
||||||
@@ -96,7 +96,7 @@ export interface Strategy {
|
|||||||
readonly list: (directory: AbsolutePath) => Effect.Effect<ListEntry[], Git.WorktreeError | DirectoryUnavailableError>
|
readonly list: (directory: AbsolutePath) => Effect.Effect<ListEntry[], Git.WorktreeError | DirectoryUnavailableError>
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Event = ProjectDirectoriesEvent
|
export { Event }
|
||||||
|
|
||||||
export interface Interface {
|
export interface Interface {
|
||||||
readonly register: (strategy: Strategy) => Effect.Effect<void, DuplicateStrategyError>
|
readonly register: (strategy: Strategy) => Effect.Effect<void, DuplicateStrategyError>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { and, asc, desc, eq, isNotNull, isNull, ne, or } from "drizzle-orm"
|
|||||||
import { Context, Effect, Layer, Schema } from "effect"
|
import { Context, Effect, Layer, Schema } from "effect"
|
||||||
import { Database } from "../database/database"
|
import { Database } from "../database/database"
|
||||||
import { LayerNode } from "../effect/layer-node"
|
import { LayerNode } from "../effect/layer-node"
|
||||||
import { AbsolutePath, optionalOmitUndefined } from "../schema"
|
import { AbsolutePath, optional } from "../schema"
|
||||||
import { ProjectSchema } from "./schema"
|
import { ProjectSchema } from "./schema"
|
||||||
import { ProjectDirectoryTable } from "./sql"
|
import { ProjectDirectoryTable } from "./sql"
|
||||||
import type { EffectDrizzleSqlite } from "@opencode-ai/effect-drizzle-sqlite"
|
import type { EffectDrizzleSqlite } from "@opencode-ai/effect-drizzle-sqlite"
|
||||||
@@ -39,7 +39,7 @@ export type ListInput = typeof ListInput.Type
|
|||||||
export const ListOutput = Schema.Array(
|
export const ListOutput = Schema.Array(
|
||||||
Schema.Struct({
|
Schema.Struct({
|
||||||
directory: AbsolutePath,
|
directory: AbsolutePath,
|
||||||
strategy: optionalOmitUndefined(Schema.String),
|
strategy: optional(Schema.String),
|
||||||
}),
|
}),
|
||||||
).annotate({ identifier: "Project.Directories" })
|
).annotate({ identifier: "Project.Directories" })
|
||||||
export type ListOutput = typeof ListOutput.Type
|
export type ListOutput = typeof ListOutput.Type
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ export * as Pty from "./pty"
|
|||||||
|
|
||||||
import type { Disp, Proc } from "#pty"
|
import type { Disp, Proc } from "#pty"
|
||||||
import { Context, Effect, Layer, Schema, Types } from "effect"
|
import { Context, Effect, Layer, Schema, Types } from "effect"
|
||||||
import { PtyEvent, PtyInfo, Pty } from "@opencode-ai/schema/pty"
|
import { Pty } from "@opencode-ai/schema/pty"
|
||||||
import { Config } from "./config"
|
import { Config } from "./config"
|
||||||
import { EventV2 } from "./event"
|
import { EventV2 } from "./event"
|
||||||
import { Location } from "./location"
|
import { Location } from "./location"
|
||||||
@@ -35,8 +35,7 @@ type Active = {
|
|||||||
listeners: Disp[]
|
listeners: Disp[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Info = PtyInfo
|
export const Info = Pty.Info
|
||||||
|
|
||||||
export type Info = Types.DeepMutable<typeof Info.Type>
|
export type Info = Types.DeepMutable<typeof Info.Type>
|
||||||
|
|
||||||
export const CreateInput = Pty.CreateInput
|
export const CreateInput = Pty.CreateInput
|
||||||
@@ -47,6 +46,8 @@ export const UpdateInput = Pty.UpdateInput
|
|||||||
|
|
||||||
export type UpdateInput = Types.DeepMutable<typeof UpdateInput.Type>
|
export type UpdateInput = Types.DeepMutable<typeof UpdateInput.Type>
|
||||||
|
|
||||||
|
export const Event = Pty.Event
|
||||||
|
|
||||||
export type AttachInput = {
|
export type AttachInput = {
|
||||||
// Absolute output cursor to replay from. -1 tails from the current end; omitted replays the full retained buffer.
|
// Absolute output cursor to replay from. -1 tails from the current end; omitted replays the full retained buffer.
|
||||||
readonly cursor?: number
|
readonly cursor?: number
|
||||||
@@ -75,8 +76,6 @@ export class ExitedError extends Schema.TaggedErrorClass<ExitedError>()("Pty.Exi
|
|||||||
ptyID: PtyID,
|
ptyID: PtyID,
|
||||||
}) {}
|
}) {}
|
||||||
|
|
||||||
export const Event = PtyEvent
|
|
||||||
|
|
||||||
export interface Interface {
|
export interface Interface {
|
||||||
readonly list: () => Effect.Effect<Info[]>
|
readonly list: () => Effect.Effect<Info[]>
|
||||||
readonly get: (id: PtyID) => Effect.Effect<Info, NotFoundError>
|
readonly get: (id: PtyID) => Effect.Effect<Info, NotFoundError>
|
||||||
|
|||||||
@@ -3,20 +3,20 @@ import {
|
|||||||
AbsolutePath,
|
AbsolutePath,
|
||||||
DateTimeUtcFromMillis,
|
DateTimeUtcFromMillis,
|
||||||
NonNegativeInt,
|
NonNegativeInt,
|
||||||
optionalOmitUndefined,
|
optional,
|
||||||
PositiveInt,
|
PositiveInt,
|
||||||
RelativePath,
|
RelativePath,
|
||||||
withStatics,
|
statics,
|
||||||
} from "@opencode-ai/schema/schema"
|
} from "@opencode-ai/schema/schema"
|
||||||
|
|
||||||
export {
|
export {
|
||||||
AbsolutePath,
|
AbsolutePath,
|
||||||
DateTimeUtcFromMillis,
|
DateTimeUtcFromMillis,
|
||||||
NonNegativeInt,
|
NonNegativeInt,
|
||||||
optionalOmitUndefined,
|
optional,
|
||||||
PositiveInt,
|
PositiveInt,
|
||||||
RelativePath,
|
RelativePath,
|
||||||
withStatics,
|
statics,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import { ContextSnapshotDecodeError } from "./error"
|
|||||||
import { SessionEvent } from "./event"
|
import { SessionEvent } from "./event"
|
||||||
import { SessionHistory } from "./history"
|
import { SessionHistory } from "./history"
|
||||||
import { SessionInput } from "./input"
|
import { SessionInput } from "./input"
|
||||||
import { SessionMessageID } from "./message-id"
|
import { SessionMessage } from "./message"
|
||||||
import { SessionSchema } from "./schema"
|
import { SessionSchema } from "./schema"
|
||||||
import { SessionContextEpochTable } from "./sql"
|
import { SessionContextEpochTable } from "./sql"
|
||||||
|
|
||||||
@@ -71,7 +71,7 @@ const prepareOnce = Effect.fnUntraced(function* (
|
|||||||
|
|
||||||
yield* events.publish(
|
yield* events.publish(
|
||||||
SessionEvent.ContextUpdated,
|
SessionEvent.ContextUpdated,
|
||||||
{ sessionID, messageID: SessionMessageID.ID.create(), timestamp: yield* DateTime.now, text: result.text },
|
{ sessionID, messageID: SessionMessage.ID.create(), timestamp: yield* DateTime.now, text: result.text },
|
||||||
{ commit: () => advance(db, sessionID, result.snapshot).pipe(Effect.orDie) },
|
{ commit: () => advance(db, sessionID, result.snapshot).pipe(Effect.orDie) },
|
||||||
)
|
)
|
||||||
return { baseline: stored.baseline, baselineSeq: stored.baseline_seq }
|
return { baseline: stored.baseline, baselineSeq: stored.baseline_seq }
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { AbsolutePath, RelativePath } from "../schema"
|
|||||||
import { WorkspaceV2 } from "../workspace"
|
import { WorkspaceV2 } from "../workspace"
|
||||||
import { SessionSchema } from "./schema"
|
import { SessionSchema } from "./schema"
|
||||||
import { SessionTable } from "./sql"
|
import { SessionTable } from "./sql"
|
||||||
import { SessionMessageID } from "./message-id"
|
import { SessionMessage } from "./message"
|
||||||
import { Snapshot } from "../snapshot"
|
import { Snapshot } from "../snapshot"
|
||||||
|
|
||||||
export function fromRow(row: typeof SessionTable.$inferSelect): SessionSchema.Info {
|
export function fromRow(row: typeof SessionTable.$inferSelect): SessionSchema.Info {
|
||||||
@@ -40,7 +40,7 @@ export function fromRow(row: typeof SessionTable.$inferSelect): SessionSchema.In
|
|||||||
workspaceID: row.workspace_id ? WorkspaceV2.ID.make(row.workspace_id) : undefined,
|
workspaceID: row.workspace_id ? WorkspaceV2.ID.make(row.workspace_id) : undefined,
|
||||||
}),
|
}),
|
||||||
subpath: row.path ? RelativePath.make(row.path) : undefined,
|
subpath: row.path ? RelativePath.make(row.path) : undefined,
|
||||||
revert: row.revert ? { ...row.revert, messageID: SessionMessageID.ID.make(row.revert.messageID) } : undefined,
|
revert: row.revert ? { ...row.revert, messageID: SessionMessage.ID.make(row.revert.messageID) } : undefined,
|
||||||
time: {
|
time: {
|
||||||
created: DateTime.makeUnsafe(row.time_created),
|
created: DateTime.makeUnsafe(row.time_created),
|
||||||
updated: DateTime.makeUnsafe(row.time_updated),
|
updated: DateTime.makeUnsafe(row.time_updated),
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
export * as SessionMessageID from "./message-id"
|
|
||||||
export { ID } from "@opencode-ai/schema/session-message-id"
|
|
||||||
@@ -15,7 +15,6 @@ import { WorkspaceV2 } from "../workspace"
|
|||||||
import { SessionContextEpoch } from "./context-epoch"
|
import { SessionContextEpoch } from "./context-epoch"
|
||||||
import { MessageTable, PartTable, SessionInputTable, SessionMessageTable, SessionTable } from "./sql"
|
import { MessageTable, PartTable, SessionInputTable, SessionMessageTable, SessionTable } from "./sql"
|
||||||
import type { DeepMutable } from "../schema"
|
import type { DeepMutable } from "../schema"
|
||||||
import { SessionMessageID } from "./message-id"
|
|
||||||
|
|
||||||
type DatabaseService = Database.Interface["db"]
|
type DatabaseService = Database.Interface["db"]
|
||||||
|
|
||||||
@@ -67,7 +66,7 @@ function sessionRow(info: SessionV1.SessionInfo): typeof SessionTable.$inferInse
|
|||||||
tokens_reasoning: (info.tokens ?? { reasoning: 0 }).reasoning,
|
tokens_reasoning: (info.tokens ?? { reasoning: 0 }).reasoning,
|
||||||
tokens_cache_read: (info.tokens ?? { cache: { read: 0 } }).cache.read,
|
tokens_cache_read: (info.tokens ?? { cache: { read: 0 } }).cache.read,
|
||||||
tokens_cache_write: (info.tokens ?? { cache: { write: 0 } }).cache.write,
|
tokens_cache_write: (info.tokens ?? { cache: { write: 0 } }).cache.write,
|
||||||
revert: info.revert ? { ...info.revert, messageID: SessionMessageID.ID.make(info.revert.messageID) } : null,
|
revert: info.revert ? { ...info.revert, messageID: SessionMessage.ID.make(info.revert.messageID) } : null,
|
||||||
permission: info.permission ? [...info.permission] : undefined,
|
permission: info.permission ? [...info.permission] : undefined,
|
||||||
time_created: info.time.created,
|
time_created: info.time.created,
|
||||||
time_updated: info.time.updated,
|
time_updated: info.time.updated,
|
||||||
|
|||||||
@@ -2,15 +2,14 @@ export * as SessionTodo from "./todo"
|
|||||||
|
|
||||||
import { asc, eq } from "drizzle-orm"
|
import { asc, eq } from "drizzle-orm"
|
||||||
import { Context, Effect, Layer } from "effect"
|
import { Context, Effect, Layer } from "effect"
|
||||||
import { SessionTodo, SessionTodoInfo } from "@opencode-ai/schema/session-todo"
|
import { SessionTodo } from "@opencode-ai/schema/session-todo"
|
||||||
import { Database } from "../database/database"
|
import { Database } from "../database/database"
|
||||||
import { EventV2 } from "../event"
|
import { EventV2 } from "../event"
|
||||||
import { SessionSchema } from "./schema"
|
import { SessionSchema } from "./schema"
|
||||||
import { TodoTable } from "./sql"
|
import { TodoTable } from "./sql"
|
||||||
|
|
||||||
export const Info = SessionTodoInfo
|
export const Info = SessionTodo.Info
|
||||||
export type Info = typeof Info.Type
|
export type Info = typeof Info.Type
|
||||||
|
|
||||||
export const Event = SessionTodo.Event
|
export const Event = SessionTodo.Event
|
||||||
|
|
||||||
export interface Interface {
|
export interface Interface {
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ import { Model } from "@opencode-ai/schema/model"
|
|||||||
import { AgentAttachment, FileAttachment, Prompt, Source } from "@opencode-ai/schema/prompt"
|
import { AgentAttachment, FileAttachment, Prompt, Source } from "@opencode-ai/schema/prompt"
|
||||||
import { Provider } from "@opencode-ai/schema/provider"
|
import { Provider } from "@opencode-ai/schema/provider"
|
||||||
import { Project } from "@opencode-ai/schema/project"
|
import { Project } from "@opencode-ai/schema/project"
|
||||||
|
import { ProjectDirectories } from "@opencode-ai/schema/project-directories"
|
||||||
|
import { PermissionV1 } from "@opencode-ai/schema/permission-v1"
|
||||||
import { Session } from "@opencode-ai/schema/session"
|
import { Session } from "@opencode-ai/schema/session"
|
||||||
import { SessionInput } from "@opencode-ai/schema/session-input"
|
import { SessionInput } from "@opencode-ai/schema/session-input"
|
||||||
import { SessionMessage } from "@opencode-ai/schema/session-message"
|
import { SessionMessage } from "@opencode-ai/schema/session-message"
|
||||||
@@ -20,10 +22,14 @@ import { FileSystem } from "@opencode-ai/schema/filesystem"
|
|||||||
import { Integration } from "@opencode-ai/schema/integration"
|
import { Integration } from "@opencode-ai/schema/integration"
|
||||||
import { LLM } from "@opencode-ai/schema/llm"
|
import { LLM } from "@opencode-ai/schema/llm"
|
||||||
import { Permission } from "@opencode-ai/schema/permission"
|
import { Permission } from "@opencode-ai/schema/permission"
|
||||||
|
import { Plugin } from "@opencode-ai/schema/plugin"
|
||||||
|
import { Pty } from "@opencode-ai/schema/pty"
|
||||||
import { Reference } from "@opencode-ai/schema/reference"
|
import { Reference } from "@opencode-ai/schema/reference"
|
||||||
|
import { SessionTodo } from "@opencode-ai/schema/session-todo"
|
||||||
import { Skill } from "@opencode-ai/schema/skill"
|
import { Skill } from "@opencode-ai/schema/skill"
|
||||||
import { AbsolutePath, DateTimeUtcFromMillis } from "@opencode-ai/schema/schema"
|
import { AbsolutePath, DateTimeUtcFromMillis, optional, statics } from "@opencode-ai/schema/schema"
|
||||||
import { ProviderV2 } from "@opencode-ai/core/provider"
|
import { ProviderV2 } from "@opencode-ai/core/provider"
|
||||||
|
import { PluginV2 } from "@opencode-ai/core/plugin"
|
||||||
|
|
||||||
test("Core reuses the canonical shared schemas", async () => {
|
test("Core reuses the canonical shared schemas", async () => {
|
||||||
const [
|
const [
|
||||||
@@ -35,13 +41,18 @@ test("Core reuses the canonical shared schemas", async () => {
|
|||||||
coreLocation,
|
coreLocation,
|
||||||
coreLLM,
|
coreLLM,
|
||||||
corePermission,
|
corePermission,
|
||||||
|
corePermissionV1,
|
||||||
|
coreProjectCopy,
|
||||||
|
corePty,
|
||||||
coreProject,
|
coreProject,
|
||||||
coreReference,
|
coreReference,
|
||||||
coreSessionInput,
|
coreSessionInput,
|
||||||
coreSessionMessage,
|
coreSessionMessage,
|
||||||
|
coreSessionTodo,
|
||||||
corePrompt,
|
corePrompt,
|
||||||
coreSkill,
|
coreSkill,
|
||||||
coreV2Schema,
|
coreV2Schema,
|
||||||
|
coreSchema,
|
||||||
coreWorkspace,
|
coreWorkspace,
|
||||||
] = await Promise.all([
|
] = await Promise.all([
|
||||||
import("@opencode-ai/core/command"),
|
import("@opencode-ai/core/command"),
|
||||||
@@ -52,13 +63,18 @@ test("Core reuses the canonical shared schemas", async () => {
|
|||||||
import("@opencode-ai/core/location"),
|
import("@opencode-ai/core/location"),
|
||||||
import("@opencode-ai/llm"),
|
import("@opencode-ai/llm"),
|
||||||
import("@opencode-ai/core/permission"),
|
import("@opencode-ai/core/permission"),
|
||||||
|
import("@opencode-ai/core/v1/permission"),
|
||||||
|
import("@opencode-ai/core/project/copy"),
|
||||||
|
import("@opencode-ai/core/pty"),
|
||||||
import("@opencode-ai/core/project/schema"),
|
import("@opencode-ai/core/project/schema"),
|
||||||
import("@opencode-ai/core/reference"),
|
import("@opencode-ai/core/reference"),
|
||||||
import("@opencode-ai/core/session/input"),
|
import("@opencode-ai/core/session/input"),
|
||||||
import("@opencode-ai/core/session/message"),
|
import("@opencode-ai/core/session/message"),
|
||||||
|
import("@opencode-ai/core/session/todo"),
|
||||||
import("@opencode-ai/core/session/prompt"),
|
import("@opencode-ai/core/session/prompt"),
|
||||||
import("@opencode-ai/core/skill"),
|
import("@opencode-ai/core/skill"),
|
||||||
import("@opencode-ai/core/v2-schema"),
|
import("@opencode-ai/core/v2-schema"),
|
||||||
|
import("@opencode-ai/core/schema"),
|
||||||
import("@opencode-ai/core/workspace"),
|
import("@opencode-ai/core/workspace"),
|
||||||
])
|
])
|
||||||
|
|
||||||
@@ -111,6 +127,12 @@ test("Core reuses the canonical shared schemas", async () => {
|
|||||||
[corePermission.Effect, Permission.Effect],
|
[corePermission.Effect, Permission.Effect],
|
||||||
[corePermission.Rule, Permission.Rule],
|
[corePermission.Rule, Permission.Rule],
|
||||||
[corePermission.Ruleset, Permission.Ruleset],
|
[corePermission.Ruleset, Permission.Ruleset],
|
||||||
|
[corePermissionV1.Event, PermissionV1.Event],
|
||||||
|
[coreProjectCopy.Event, ProjectDirectories.Event],
|
||||||
|
[PluginV2.ID, Plugin.ID],
|
||||||
|
[PluginV2.Event, Plugin.Event],
|
||||||
|
[corePty.Info, Pty.Info],
|
||||||
|
[corePty.Event, Pty.Event],
|
||||||
[coreProject.ID, Project.ID],
|
[coreProject.ID, Project.ID],
|
||||||
[coreReference.LocalSource, Reference.LocalSource],
|
[coreReference.LocalSource, Reference.LocalSource],
|
||||||
[coreReference.GitSource, Reference.GitSource],
|
[coreReference.GitSource, Reference.GitSource],
|
||||||
@@ -140,6 +162,8 @@ test("Core reuses the canonical shared schemas", async () => {
|
|||||||
[coreSessionMessage.Assistant, SessionMessage.Assistant],
|
[coreSessionMessage.Assistant, SessionMessage.Assistant],
|
||||||
[coreSessionMessage.Compaction, SessionMessage.Compaction],
|
[coreSessionMessage.Compaction, SessionMessage.Compaction],
|
||||||
[coreSessionMessage.Message, SessionMessage.Message],
|
[coreSessionMessage.Message, SessionMessage.Message],
|
||||||
|
[coreSessionTodo.Info, SessionTodo.Info],
|
||||||
|
[coreSessionTodo.Event, SessionTodo.Event],
|
||||||
[corePrompt.Source, Source],
|
[corePrompt.Source, Source],
|
||||||
[corePrompt.FileAttachment, FileAttachment],
|
[corePrompt.FileAttachment, FileAttachment],
|
||||||
[corePrompt.AgentAttachment, AgentAttachment],
|
[corePrompt.AgentAttachment, AgentAttachment],
|
||||||
@@ -150,6 +174,8 @@ test("Core reuses the canonical shared schemas", async () => {
|
|||||||
[coreSkill.Source, Skill.Source],
|
[coreSkill.Source, Skill.Source],
|
||||||
[coreSkill.Info, Skill.Info],
|
[coreSkill.Info, Skill.Info],
|
||||||
[coreV2Schema.DateTimeUtcFromMillis, DateTimeUtcFromMillis],
|
[coreV2Schema.DateTimeUtcFromMillis, DateTimeUtcFromMillis],
|
||||||
|
[coreSchema.optional, optional],
|
||||||
|
[coreSchema.statics, statics],
|
||||||
[coreWorkspace.ID, Workspace.ID],
|
[coreWorkspace.ID, Workspace.ID],
|
||||||
]
|
]
|
||||||
for (const [core, shared] of schemas) expect(core).toBe(shared)
|
for (const [core, shared] of schemas) expect(core).toBe(shared)
|
||||||
|
|||||||
@@ -6,9 +6,8 @@ import { Deferred, Effect, Layer, Context } from "effect"
|
|||||||
import os from "os"
|
import os from "os"
|
||||||
import { PermissionV1 } from "@opencode-ai/core/v1/permission"
|
import { PermissionV1 } from "@opencode-ai/core/v1/permission"
|
||||||
import { EventV2Bridge } from "@/event-v2-bridge"
|
import { EventV2Bridge } from "@/event-v2-bridge"
|
||||||
import { PermissionV1Event } from "@opencode-ai/schema/permission-v1"
|
|
||||||
|
|
||||||
export const Event = PermissionV1Event
|
export const Event = PermissionV1.Event
|
||||||
|
|
||||||
export interface Interface {
|
export interface Interface {
|
||||||
readonly ask: (input: PermissionV1.AskInput) => Effect.Effect<void, PermissionV1.Error>
|
readonly ask: (input: PermissionV1.AskInput) => Effect.Effect<void, PermissionV1.Error>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import type { AuthOAuthResult, Hooks } from "@opencode-ai/plugin"
|
|||||||
import { serviceUse } from "@opencode-ai/core/effect/service-use"
|
import { serviceUse } from "@opencode-ai/core/effect/service-use"
|
||||||
import { Auth } from "@/auth"
|
import { Auth } from "@/auth"
|
||||||
import { InstanceState } from "@/effect/instance-state"
|
import { InstanceState } from "@/effect/instance-state"
|
||||||
import { optionalOmitUndefined } from "@opencode-ai/core/schema"
|
import { optional } from "@opencode-ai/core/schema"
|
||||||
import { Plugin } from "../plugin"
|
import { Plugin } from "../plugin"
|
||||||
import { ProviderV2 } from "@opencode-ai/core/provider"
|
import { ProviderV2 } from "@opencode-ai/core/provider"
|
||||||
import { Array as Arr, Effect, Layer, Record, Result, Context, Schema } from "effect"
|
import { Array as Arr, Effect, Layer, Record, Result, Context, Schema } from "effect"
|
||||||
@@ -18,14 +18,14 @@ const TextPrompt = Schema.Struct({
|
|||||||
type: Schema.Literal("text"),
|
type: Schema.Literal("text"),
|
||||||
key: Schema.String,
|
key: Schema.String,
|
||||||
message: Schema.String,
|
message: Schema.String,
|
||||||
placeholder: optionalOmitUndefined(Schema.String),
|
placeholder: optional(Schema.String),
|
||||||
when: optionalOmitUndefined(When),
|
when: optional(When),
|
||||||
})
|
})
|
||||||
|
|
||||||
const SelectOption = Schema.Struct({
|
const SelectOption = Schema.Struct({
|
||||||
label: Schema.String,
|
label: Schema.String,
|
||||||
value: Schema.String,
|
value: Schema.String,
|
||||||
hint: optionalOmitUndefined(Schema.String),
|
hint: optional(Schema.String),
|
||||||
})
|
})
|
||||||
|
|
||||||
const SelectPrompt = Schema.Struct({
|
const SelectPrompt = Schema.Struct({
|
||||||
@@ -33,7 +33,7 @@ const SelectPrompt = Schema.Struct({
|
|||||||
key: Schema.String,
|
key: Schema.String,
|
||||||
message: Schema.String,
|
message: Schema.String,
|
||||||
options: Schema.Array(SelectOption),
|
options: Schema.Array(SelectOption),
|
||||||
when: optionalOmitUndefined(When),
|
when: optional(When),
|
||||||
})
|
})
|
||||||
|
|
||||||
const Prompt = Schema.Union([TextPrompt, SelectPrompt])
|
const Prompt = Schema.Union([TextPrompt, SelectPrompt])
|
||||||
@@ -41,7 +41,7 @@ const Prompt = Schema.Union([TextPrompt, SelectPrompt])
|
|||||||
export class Method extends Schema.Class<Method>("ProviderAuthMethod")({
|
export class Method extends Schema.Class<Method>("ProviderAuthMethod")({
|
||||||
type: Schema.Literals(["oauth", "api"]),
|
type: Schema.Literals(["oauth", "api"]),
|
||||||
label: Schema.String,
|
label: Schema.String,
|
||||||
prompts: optionalOmitUndefined(Schema.Array(Prompt)),
|
prompts: optional(Schema.Array(Prompt)),
|
||||||
}) {}
|
}) {}
|
||||||
|
|
||||||
export const Methods = Schema.Record(Schema.String, Schema.Array(Method))
|
export const Methods = Schema.Record(Schema.String, Schema.Array(Method))
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import { InstanceState } from "@/effect/instance-state"
|
|||||||
import { EffectPromise } from "@/effect/promise"
|
import { EffectPromise } from "@/effect/promise"
|
||||||
import { FSUtil } from "@opencode-ai/core/fs-util"
|
import { FSUtil } from "@opencode-ai/core/fs-util"
|
||||||
import { isRecord } from "@/util/record"
|
import { isRecord } from "@/util/record"
|
||||||
import { optionalOmitUndefined } from "@opencode-ai/core/schema"
|
import { optional } from "@opencode-ai/core/schema"
|
||||||
import { ProviderTransform } from "./transform"
|
import { ProviderTransform } from "./transform"
|
||||||
import { ProviderV2 } from "@opencode-ai/core/provider"
|
import { ProviderV2 } from "@opencode-ai/core/provider"
|
||||||
import { ModelV2 } from "@opencode-ai/core/model"
|
import { ModelV2 } from "@opencode-ai/core/model"
|
||||||
@@ -999,8 +999,8 @@ const ProviderCost = Schema.Struct({
|
|||||||
input: Schema.Finite,
|
input: Schema.Finite,
|
||||||
output: Schema.Finite,
|
output: Schema.Finite,
|
||||||
cache: ProviderCacheCost,
|
cache: ProviderCacheCost,
|
||||||
tiers: optionalOmitUndefined(Schema.Array(ProviderCostTier)),
|
tiers: optional(Schema.Array(ProviderCostTier)),
|
||||||
experimentalOver200K: optionalOmitUndefined(
|
experimentalOver200K: optional(
|
||||||
Schema.Struct({
|
Schema.Struct({
|
||||||
input: Schema.Finite,
|
input: Schema.Finite,
|
||||||
output: Schema.Finite,
|
output: Schema.Finite,
|
||||||
@@ -1011,7 +1011,7 @@ const ProviderCost = Schema.Struct({
|
|||||||
|
|
||||||
const ProviderLimit = Schema.Struct({
|
const ProviderLimit = Schema.Struct({
|
||||||
context: Schema.Finite,
|
context: Schema.Finite,
|
||||||
input: optionalOmitUndefined(Schema.Finite),
|
input: optional(Schema.Finite),
|
||||||
output: Schema.Finite,
|
output: Schema.Finite,
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -1020,7 +1020,7 @@ export const Model = Schema.Struct({
|
|||||||
providerID: ProviderV2.ID,
|
providerID: ProviderV2.ID,
|
||||||
api: ProviderApiInfo,
|
api: ProviderApiInfo,
|
||||||
name: Schema.String,
|
name: Schema.String,
|
||||||
family: optionalOmitUndefined(Schema.String),
|
family: optional(Schema.String),
|
||||||
capabilities: ProviderCapabilities,
|
capabilities: ProviderCapabilities,
|
||||||
cost: ProviderCost,
|
cost: ProviderCost,
|
||||||
limit: ProviderLimit,
|
limit: ProviderLimit,
|
||||||
@@ -1028,7 +1028,7 @@ export const Model = Schema.Struct({
|
|||||||
options: Schema.Record(Schema.String, Schema.Any),
|
options: Schema.Record(Schema.String, Schema.Any),
|
||||||
headers: Schema.Record(Schema.String, Schema.String),
|
headers: Schema.Record(Schema.String, Schema.String),
|
||||||
release_date: Schema.String,
|
release_date: Schema.String,
|
||||||
variants: optionalOmitUndefined(Schema.Record(Schema.String, Schema.Record(Schema.String, Schema.Any))),
|
variants: optional(Schema.Record(Schema.String, Schema.Record(Schema.String, Schema.Any))),
|
||||||
}).annotate({ identifier: "Model" })
|
}).annotate({ identifier: "Model" })
|
||||||
export type Model = Types.DeepMutable<Schema.Schema.Type<typeof Model>>
|
export type Model = Types.DeepMutable<Schema.Schema.Type<typeof Model>>
|
||||||
|
|
||||||
@@ -1037,7 +1037,7 @@ export const Info = Schema.Struct({
|
|||||||
name: Schema.String,
|
name: Schema.String,
|
||||||
source: Schema.Literals(["env", "config", "custom", "api"]),
|
source: Schema.Literals(["env", "config", "custom", "api"]),
|
||||||
env: Schema.Array(Schema.String),
|
env: Schema.Array(Schema.String),
|
||||||
key: optionalOmitUndefined(Schema.String),
|
key: optional(Schema.String),
|
||||||
options: Schema.Record(Schema.String, Schema.Any),
|
options: Schema.Record(Schema.String, Schema.Any),
|
||||||
models: Schema.Record(Schema.String, Model),
|
models: Schema.Record(Schema.String, Model),
|
||||||
}).annotate({ identifier: "Provider" })
|
}).annotate({ identifier: "Provider" })
|
||||||
|
|||||||
@@ -2,14 +2,14 @@ import { Schema } from "effect"
|
|||||||
|
|
||||||
import { Identifier } from "@/id/id"
|
import { Identifier } from "@/id/id"
|
||||||
import { SessionV2 } from "@opencode-ai/core/session"
|
import { SessionV2 } from "@opencode-ai/core/session"
|
||||||
import { withStatics } from "@opencode-ai/core/schema"
|
import { statics } from "@opencode-ai/core/schema"
|
||||||
|
|
||||||
export const SessionID = SessionV2.ID
|
export const SessionID = SessionV2.ID
|
||||||
export type SessionID = Schema.Schema.Type<typeof SessionID>
|
export type SessionID = Schema.Schema.Type<typeof SessionID>
|
||||||
|
|
||||||
export const MessageID = Schema.String.check(Schema.isStartsWith("msg")).pipe(
|
export const MessageID = Schema.String.check(Schema.isStartsWith("msg")).pipe(
|
||||||
Schema.brand("MessageID"),
|
Schema.brand("MessageID"),
|
||||||
withStatics((s) => ({
|
statics((s) => ({
|
||||||
ascending: (id?: string) => s.make(Identifier.ascending("message", id)),
|
ascending: (id?: string) => s.make(Identifier.ascending("message", id)),
|
||||||
})),
|
})),
|
||||||
)
|
)
|
||||||
@@ -18,7 +18,7 @@ export type MessageID = Schema.Schema.Type<typeof MessageID>
|
|||||||
|
|
||||||
export const PartID = Schema.String.check(Schema.isStartsWith("prt")).pipe(
|
export const PartID = Schema.String.check(Schema.isStartsWith("prt")).pipe(
|
||||||
Schema.brand("PartID"),
|
Schema.brand("PartID"),
|
||||||
withStatics((s) => ({
|
statics((s) => ({
|
||||||
ascending: (id?: string) => s.make(Identifier.ascending("part", id)),
|
ascending: (id?: string) => s.make(Identifier.ascending("part", id)),
|
||||||
})),
|
})),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -39,11 +39,11 @@ import { SessionID, MessageID, PartID } from "./schema"
|
|||||||
import type { Provider } from "@/provider/provider"
|
import type { Provider } from "@/provider/provider"
|
||||||
import { Global } from "@opencode-ai/core/global"
|
import { Global } from "@opencode-ai/core/global"
|
||||||
import { Effect, Layer, Option, Context, Schema, Types } from "effect"
|
import { Effect, Layer, Option, Context, Schema, Types } from "effect"
|
||||||
import { NonNegativeInt, optionalOmitUndefined } from "@opencode-ai/core/schema"
|
import { NonNegativeInt, optional } from "@opencode-ai/core/schema"
|
||||||
import { RuntimeFlags } from "@/effect/runtime-flags"
|
import { RuntimeFlags } from "@/effect/runtime-flags"
|
||||||
import { ProviderV2 } from "@opencode-ai/core/provider"
|
import { ProviderV2 } from "@opencode-ai/core/provider"
|
||||||
import { ModelV2 } from "@opencode-ai/core/model"
|
import { ModelV2 } from "@opencode-ai/core/model"
|
||||||
import { SessionMessageID } from "@opencode-ai/schema/session-message-id"
|
import { SessionMessage } from "@opencode-ai/schema/session-message"
|
||||||
|
|
||||||
const runtime = makeRuntime(Database.Service, Database.defaultLayer)
|
const runtime = makeRuntime(Database.Service, Database.defaultLayer)
|
||||||
|
|
||||||
@@ -146,7 +146,7 @@ export function toRow(info: Info) {
|
|||||||
tokens_cache_write: (info.tokens ?? EmptyTokens).cache.write,
|
tokens_cache_write: (info.tokens ?? EmptyTokens).cache.write,
|
||||||
revert: info.revert
|
revert: info.revert
|
||||||
? {
|
? {
|
||||||
messageID: SessionMessageID.ID.make(info.revert.messageID),
|
messageID: SessionMessage.ID.make(info.revert.messageID),
|
||||||
partID: info.revert.partID,
|
partID: info.revert.partID,
|
||||||
snapshot: info.revert.snapshot,
|
snapshot: info.revert.snapshot,
|
||||||
diff: info.revert.diff,
|
diff: info.revert.diff,
|
||||||
@@ -178,7 +178,7 @@ const Summary = Schema.Struct({
|
|||||||
additions: Schema.Finite,
|
additions: Schema.Finite,
|
||||||
deletions: Schema.Finite,
|
deletions: Schema.Finite,
|
||||||
files: Schema.Finite,
|
files: Schema.Finite,
|
||||||
diffs: optionalOmitUndefined(Schema.Array(Snapshot.FileDiff)),
|
diffs: optional(Schema.Array(Snapshot.FileDiff)),
|
||||||
})
|
})
|
||||||
|
|
||||||
const Tokens = Schema.Struct({
|
const Tokens = Schema.Struct({
|
||||||
@@ -204,21 +204,21 @@ export const ArchivedTimestamp = Schema.Finite
|
|||||||
const Time = Schema.Struct({
|
const Time = Schema.Struct({
|
||||||
created: NonNegativeInt,
|
created: NonNegativeInt,
|
||||||
updated: NonNegativeInt,
|
updated: NonNegativeInt,
|
||||||
compacting: optionalOmitUndefined(NonNegativeInt),
|
compacting: optional(NonNegativeInt),
|
||||||
archived: optionalOmitUndefined(ArchivedTimestamp),
|
archived: optional(ArchivedTimestamp),
|
||||||
})
|
})
|
||||||
|
|
||||||
const Revert = Schema.Struct({
|
const Revert = Schema.Struct({
|
||||||
messageID: MessageID,
|
messageID: MessageID,
|
||||||
partID: optionalOmitUndefined(PartID),
|
partID: optional(PartID),
|
||||||
snapshot: optionalOmitUndefined(Schema.String),
|
snapshot: optional(Schema.String),
|
||||||
diff: optionalOmitUndefined(Schema.String),
|
diff: optional(Schema.String),
|
||||||
})
|
})
|
||||||
|
|
||||||
const Model = Schema.Struct({
|
const Model = Schema.Struct({
|
||||||
id: ModelV2.ID,
|
id: ModelV2.ID,
|
||||||
providerID: ProviderV2.ID,
|
providerID: ProviderV2.ID,
|
||||||
variant: optionalOmitUndefined(Schema.String),
|
variant: optional(Schema.String),
|
||||||
})
|
})
|
||||||
|
|
||||||
export const Metadata = Schema.Record(Schema.String, Schema.Any)
|
export const Metadata = Schema.Record(Schema.String, Schema.Any)
|
||||||
@@ -227,28 +227,28 @@ export const Info = Schema.Struct({
|
|||||||
id: SessionID,
|
id: SessionID,
|
||||||
slug: Schema.String,
|
slug: Schema.String,
|
||||||
projectID: ProjectV2.ID,
|
projectID: ProjectV2.ID,
|
||||||
workspaceID: optionalOmitUndefined(WorkspaceV2.ID),
|
workspaceID: optional(WorkspaceV2.ID),
|
||||||
directory: Schema.String,
|
directory: Schema.String,
|
||||||
path: optionalOmitUndefined(Schema.String),
|
path: optional(Schema.String),
|
||||||
parentID: optionalOmitUndefined(SessionID),
|
parentID: optional(SessionID),
|
||||||
summary: optionalOmitUndefined(Summary),
|
summary: optional(Summary),
|
||||||
cost: optionalOmitUndefined(Schema.Finite),
|
cost: optional(Schema.Finite),
|
||||||
tokens: optionalOmitUndefined(Tokens),
|
tokens: optional(Tokens),
|
||||||
share: optionalOmitUndefined(Share),
|
share: optional(Share),
|
||||||
title: Schema.String,
|
title: Schema.String,
|
||||||
agent: optionalOmitUndefined(Schema.String),
|
agent: optional(Schema.String),
|
||||||
model: optionalOmitUndefined(Model),
|
model: optional(Model),
|
||||||
version: Schema.String,
|
version: Schema.String,
|
||||||
metadata: optionalOmitUndefined(Metadata),
|
metadata: optional(Metadata),
|
||||||
time: Time,
|
time: Time,
|
||||||
permission: optionalOmitUndefined(PermissionV1.Ruleset),
|
permission: optional(PermissionV1.Ruleset),
|
||||||
revert: optionalOmitUndefined(Revert),
|
revert: optional(Revert),
|
||||||
}).annotate({ identifier: "Session" })
|
}).annotate({ identifier: "Session" })
|
||||||
export type Info = Types.DeepMutable<Schema.Schema.Type<typeof Info>>
|
export type Info = Types.DeepMutable<Schema.Schema.Type<typeof Info>>
|
||||||
|
|
||||||
export const ProjectInfo = Schema.Struct({
|
export const ProjectInfo = Schema.Struct({
|
||||||
id: ProjectV2.ID,
|
id: ProjectV2.ID,
|
||||||
name: optionalOmitUndefined(Schema.String),
|
name: optional(Schema.String),
|
||||||
worktree: Schema.String,
|
worktree: Schema.String,
|
||||||
}).annotate({ identifier: "ProjectSummary" })
|
}).annotate({ identifier: "ProjectSummary" })
|
||||||
export type ProjectInfo = Types.DeepMutable<Schema.Schema.Type<typeof ProjectInfo>>
|
export type ProjectInfo = Types.DeepMutable<Schema.Schema.Type<typeof ProjectInfo>>
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import { Schema } from "effect"
|
import { Schema } from "effect"
|
||||||
|
|
||||||
import { Identifier } from "@/id/id"
|
import { Identifier } from "@/id/id"
|
||||||
import { withStatics } from "@opencode-ai/core/schema"
|
import { statics } from "@opencode-ai/core/schema"
|
||||||
|
|
||||||
export const EventID = Schema.String.check(Schema.isStartsWith("evt")).pipe(
|
export const EventID = Schema.String.check(Schema.isStartsWith("evt")).pipe(
|
||||||
Schema.brand("EventID"),
|
Schema.brand("EventID"),
|
||||||
withStatics((s) => ({
|
statics((s) => ({
|
||||||
ascending: (id?: string) => s.make(Identifier.ascending("event", id)),
|
ascending: (id?: string) => s.make(Identifier.ascending("event", id)),
|
||||||
})),
|
})),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
import { Schema } from "effect"
|
import { Schema } from "effect"
|
||||||
|
|
||||||
import { Identifier } from "@/id/id"
|
import { Identifier } from "@/id/id"
|
||||||
import { withStatics } from "@opencode-ai/core/schema"
|
import { statics } from "@opencode-ai/core/schema"
|
||||||
|
|
||||||
const toolIdSchema = Schema.String.check(Schema.isStartsWith("tool")).pipe(Schema.brand("ToolID"))
|
const toolIdSchema = Schema.String.check(Schema.isStartsWith("tool")).pipe(Schema.brand("ToolID"))
|
||||||
|
|
||||||
export type ToolID = typeof toolIdSchema.Type
|
export type ToolID = typeof toolIdSchema.Type
|
||||||
|
|
||||||
export const ToolID = toolIdSchema.pipe(
|
export const ToolID = toolIdSchema.pipe(
|
||||||
withStatics((schema: typeof toolIdSchema) => ({
|
statics((schema: typeof toolIdSchema) => ({
|
||||||
ascending: (id?: string) => schema.make(Identifier.ascending("tool", id)),
|
ascending: (id?: string) => schema.make(Identifier.ascending("tool", id)),
|
||||||
})),
|
})),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { SessionInput } from "@opencode-ai/schema/session-input"
|
|||||||
import { Prompt } from "@opencode-ai/schema/prompt"
|
import { Prompt } from "@opencode-ai/schema/prompt"
|
||||||
import { Session } from "@opencode-ai/schema/session"
|
import { Session } from "@opencode-ai/schema/session"
|
||||||
import { Project } from "@opencode-ai/schema/project"
|
import { Project } from "@opencode-ai/schema/project"
|
||||||
import { AbsolutePath, PositiveInt, RelativePath, withStatics } from "@opencode-ai/schema/schema"
|
import { AbsolutePath, PositiveInt, RelativePath, statics } from "@opencode-ai/schema/schema"
|
||||||
import { Workspace } from "@opencode-ai/schema/workspace"
|
import { Workspace } from "@opencode-ai/schema/workspace"
|
||||||
import { Context, Encoding, Result, Schema, Struct } from "effect"
|
import { Context, Encoding, Result, Schema, Struct } from "effect"
|
||||||
import { HttpApiEndpoint, HttpApiGroup, HttpApiMiddleware, HttpApiSchema, OpenApi } from "effect/unstable/httpapi"
|
import { HttpApiEndpoint, HttpApiGroup, HttpApiMiddleware, HttpApiSchema, OpenApi } from "effect/unstable/httpapi"
|
||||||
@@ -62,7 +62,7 @@ const decodeSessionsCursor = Schema.decodeUnknownEffect(SessionsCursorJson)
|
|||||||
|
|
||||||
export const SessionsCursor = Schema.String.pipe(
|
export const SessionsCursor = Schema.String.pipe(
|
||||||
Schema.brand("SessionsCursor"),
|
Schema.brand("SessionsCursor"),
|
||||||
withStatics((schema) => {
|
statics((schema) => {
|
||||||
const make = schema.make.bind(schema)
|
const make = schema.make.bind(schema)
|
||||||
return {
|
return {
|
||||||
make: (input: typeof SessionsCursorInput.Type) => make(Encoding.encodeBase64Url(encodeSessionsCursor(input))),
|
make: (input: typeof SessionsCursorInput.Type) => make(Encoding.encodeBase64Url(encodeSessionsCursor(input))),
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { Schema } from "effect"
|
|||||||
import { Model } from "./model"
|
import { Model } from "./model"
|
||||||
import { Permission } from "./permission"
|
import { Permission } from "./permission"
|
||||||
import { Provider } from "./provider"
|
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 const ID = Schema.String.pipe(Schema.brand("AgentV2.ID"))
|
||||||
export type ID = typeof ID.Type
|
export type ID = typeof ID.Type
|
||||||
@@ -30,7 +30,7 @@ export const Info = Schema.Struct({
|
|||||||
})
|
})
|
||||||
.annotate({ identifier: "AgentV2.Info" })
|
.annotate({ identifier: "AgentV2.Info" })
|
||||||
.pipe(
|
.pipe(
|
||||||
withStatics((schema) => ({
|
statics((schema) => ({
|
||||||
empty: (id: ID) =>
|
empty: (id: ID) =>
|
||||||
schema.make({ id, request: { headers: {}, body: {} }, mode: "all", hidden: false, permissions: [] }),
|
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 { Schema } from "effect"
|
||||||
import { IntegrationMethodID } from "./integration-id"
|
import { IntegrationMethodID } from "./integration-id"
|
||||||
import { ascending } from "./identifier"
|
import { ascending } from "./identifier"
|
||||||
import { NonNegativeInt, withStatics } from "./schema"
|
import { NonNegativeInt, statics } from "./schema"
|
||||||
|
|
||||||
export const ID = Schema.String.pipe(
|
export const ID = Schema.String.pipe(
|
||||||
Schema.brand("Credential.ID"),
|
Schema.brand("Credential.ID"),
|
||||||
withStatics((schema) => ({ create: () => schema.make("cred_" + ascending()) })),
|
statics((schema) => ({ create: () => schema.make("cred_" + ascending()) })),
|
||||||
)
|
)
|
||||||
export type ID = typeof ID.Type
|
export type ID = typeof ID.Type
|
||||||
|
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ export * as Event from "./event"
|
|||||||
import { Schema } from "effect"
|
import { Schema } from "effect"
|
||||||
import { ascending } from "./identifier"
|
import { ascending } from "./identifier"
|
||||||
import { Location } from "./location"
|
import { Location } from "./location"
|
||||||
import { withStatics } from "./schema"
|
import { statics } from "./schema"
|
||||||
|
|
||||||
export const ID = Schema.String.check(Schema.isStartsWith("evt_")).pipe(
|
export const ID = Schema.String.check(Schema.isStartsWith("evt_")).pipe(
|
||||||
Schema.brand("Event.ID"),
|
Schema.brand("Event.ID"),
|
||||||
withStatics((schema) => ({ create: () => schema.make("evt_" + ascending()) })),
|
statics((schema) => ({ create: () => schema.make("evt_" + ascending()) })),
|
||||||
)
|
)
|
||||||
export type ID = typeof ID.Type
|
export type ID = typeof ID.Type
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { Schema } from "effect"
|
|||||||
import { define, inventory } from "./event"
|
import { define, inventory } from "./event"
|
||||||
import { Connection } from "./connection"
|
import { Connection } from "./connection"
|
||||||
import { ascending } from "./identifier"
|
import { ascending } from "./identifier"
|
||||||
import { withStatics } from "./schema"
|
import { statics } from "./schema"
|
||||||
import { IntegrationID, IntegrationMethodID } from "./integration-id"
|
import { IntegrationID, IntegrationMethodID } from "./integration-id"
|
||||||
|
|
||||||
export const ID = IntegrationID
|
export const ID = IntegrationID
|
||||||
@@ -102,7 +102,7 @@ export class Info extends Schema.Class<Info>("Integration.Info")({
|
|||||||
|
|
||||||
export const AttemptID = Schema.String.pipe(
|
export const AttemptID = Schema.String.pipe(
|
||||||
Schema.brand("Integration.AttemptID"),
|
Schema.brand("Integration.AttemptID"),
|
||||||
withStatics((schema) => ({ create: () => schema.make("con_" + ascending()) })),
|
statics((schema) => ({ create: () => schema.make("con_" + ascending()) })),
|
||||||
)
|
)
|
||||||
export type AttemptID = typeof AttemptID.Type
|
export type AttemptID = typeof AttemptID.Type
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
export * as Location from "./location"
|
export * as Location from "./location"
|
||||||
|
|
||||||
import { Effect, Schema } from "effect"
|
import { Effect, Schema } from "effect"
|
||||||
import { AbsolutePath, optionalOmitUndefined } from "./schema"
|
import { AbsolutePath, optional } from "./schema"
|
||||||
import { ProjectID } from "./project-id"
|
import { ProjectID } from "./project-id"
|
||||||
import { WorkspaceID } from "./workspace-id"
|
import { WorkspaceID } from "./workspace-id"
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@ export const Ref = Schema.Struct({
|
|||||||
|
|
||||||
export class Info extends Schema.Class<Info>("Location.Info")({
|
export class Info extends Schema.Class<Info>("Location.Info")({
|
||||||
directory: AbsolutePath,
|
directory: AbsolutePath,
|
||||||
workspaceID: optionalOmitUndefined(WorkspaceID),
|
workspaceID: optional(WorkspaceID),
|
||||||
project: Schema.Struct({
|
project: Schema.Struct({
|
||||||
id: ProjectID,
|
id: ProjectID,
|
||||||
directory: AbsolutePath,
|
directory: AbsolutePath,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ export * as Model from "./model"
|
|||||||
|
|
||||||
import { Schema } from "effect"
|
import { Schema } from "effect"
|
||||||
import { Provider } from "./provider"
|
import { Provider } from "./provider"
|
||||||
import { withStatics } from "./schema"
|
import { statics } from "./schema"
|
||||||
|
|
||||||
export const ID = Schema.String.pipe(Schema.brand("ModelV2.ID"))
|
export const ID = Schema.String.pipe(Schema.brand("ModelV2.ID"))
|
||||||
export type ID = typeof ID.Type
|
export type ID = typeof ID.Type
|
||||||
@@ -83,7 +83,7 @@ export const Info = Schema.Struct({
|
|||||||
})
|
})
|
||||||
.annotate({ identifier: "ModelV2.Info" })
|
.annotate({ identifier: "ModelV2.Info" })
|
||||||
.pipe(
|
.pipe(
|
||||||
withStatics((schema) => ({
|
statics((schema) => ({
|
||||||
empty: (providerID: Provider.ID, modelID: ID) =>
|
empty: (providerID: Provider.ID, modelID: ID) =>
|
||||||
schema.make({
|
schema.make({
|
||||||
id: modelID,
|
id: modelID,
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ export * as PermissionSaved from "./permission-saved"
|
|||||||
import { Schema } from "effect"
|
import { Schema } from "effect"
|
||||||
import { ascending } from "./identifier"
|
import { ascending } from "./identifier"
|
||||||
import { ProjectID } from "./project-id"
|
import { ProjectID } from "./project-id"
|
||||||
import { withStatics } from "./schema"
|
import { statics } from "./schema"
|
||||||
|
|
||||||
export const ID = Schema.String.pipe(
|
export const ID = Schema.String.pipe(
|
||||||
Schema.brand("PermissionSaved.ID"),
|
Schema.brand("PermissionSaved.ID"),
|
||||||
withStatics((schema) => ({ create: () => schema.make("psv_" + ascending()) })),
|
statics((schema) => ({ create: () => schema.make("psv_" + ascending()) })),
|
||||||
)
|
)
|
||||||
export type ID = typeof ID.Type
|
export type ID = typeof ID.Type
|
||||||
|
|
||||||
|
|||||||
@@ -4,12 +4,12 @@ import { Schema } from "effect"
|
|||||||
import { define, inventory } from "./event"
|
import { define, inventory } from "./event"
|
||||||
import { ascending } from "./identifier"
|
import { ascending } from "./identifier"
|
||||||
import { Project } from "./project"
|
import { Project } from "./project"
|
||||||
import { withStatics } from "./schema"
|
import { statics } from "./schema"
|
||||||
import { SessionID } from "./session-id"
|
import { SessionID } from "./session-id"
|
||||||
|
|
||||||
export const ID = Schema.String.check(Schema.isStartsWith("per")).pipe(
|
export const ID = Schema.String.check(Schema.isStartsWith("per")).pipe(
|
||||||
Schema.brand("PermissionID"),
|
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
|
export type ID = typeof ID.Type
|
||||||
|
|
||||||
@@ -64,4 +64,3 @@ const Replied = define({
|
|||||||
schema: { sessionID: SessionID, requestID: ID, reply: Reply },
|
schema: { sessionID: SessionID, requestID: ID, reply: Reply },
|
||||||
})
|
})
|
||||||
export const Event = { Asked, Replied, Definitions: inventory(Asked, Replied) }
|
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 { define, inventory } from "./event"
|
||||||
import { ascending } from "./identifier"
|
import { ascending } from "./identifier"
|
||||||
import { SessionID } from "./session-id"
|
import { SessionID } from "./session-id"
|
||||||
import { withStatics } from "./schema"
|
import { statics } from "./schema"
|
||||||
|
|
||||||
export const ID = Schema.String.check(Schema.isStartsWith("per")).pipe(
|
export const ID = Schema.String.check(Schema.isStartsWith("per")).pipe(
|
||||||
Schema.brand("PermissionV2.ID"),
|
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
|
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 const ID = Schema.String.pipe(Schema.brand("Plugin.ID"))
|
||||||
export type ID = typeof ID.Type
|
export type ID = typeof ID.Type
|
||||||
export const PluginID = ID
|
|
||||||
|
|
||||||
const Added = define({
|
const Added = define({
|
||||||
type: "plugin.added",
|
type: "plugin.added",
|
||||||
schema: { id: ID },
|
schema: { id: ID },
|
||||||
})
|
})
|
||||||
export const Event = { Added, Definitions: inventory(Added) }
|
export const Event = { Added, Definitions: inventory(Added) }
|
||||||
export const PluginEvent = Event
|
|
||||||
|
|||||||
@@ -8,4 +8,3 @@ const Updated = define({
|
|||||||
schema: { projectID: Project.ID },
|
schema: { projectID: Project.ID },
|
||||||
})
|
})
|
||||||
export const Event = { Updated, Definitions: inventory(Updated) }
|
export const Event = { Updated, Definitions: inventory(Updated) }
|
||||||
export const ProjectDirectoriesEvent = Event
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { Schema } from "effect"
|
import { Schema } from "effect"
|
||||||
import { withStatics } from "./schema"
|
import { statics } from "./schema"
|
||||||
|
|
||||||
export const ProjectID = Schema.String.pipe(
|
export const ProjectID = Schema.String.pipe(
|
||||||
Schema.brand("Project.ID"),
|
Schema.brand("Project.ID"),
|
||||||
withStatics((schema) => ({ global: schema.make("global") })),
|
statics((schema) => ({ global: schema.make("global") })),
|
||||||
)
|
)
|
||||||
export type ProjectID = typeof ProjectID.Type
|
export type ProjectID = typeof ProjectID.Type
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ export * as Project from "./project"
|
|||||||
|
|
||||||
import { Schema } from "effect"
|
import { Schema } from "effect"
|
||||||
import { define, inventory } from "./event"
|
import { define, inventory } from "./event"
|
||||||
import { NonNegativeInt, optionalOmitUndefined } from "./schema"
|
import { NonNegativeInt, optional } from "./schema"
|
||||||
import { ProjectID } from "./project-id"
|
import { ProjectID } from "./project-id"
|
||||||
|
|
||||||
export const ID = ProjectID
|
export const ID = ProjectID
|
||||||
@@ -10,28 +10,28 @@ export type ID = typeof ID.Type
|
|||||||
|
|
||||||
export const Vcs = Schema.Literal("git")
|
export const Vcs = Schema.Literal("git")
|
||||||
export const Icon = Schema.Struct({
|
export const Icon = Schema.Struct({
|
||||||
url: optionalOmitUndefined(Schema.String),
|
url: optional(Schema.String),
|
||||||
override: optionalOmitUndefined(Schema.String),
|
override: optional(Schema.String),
|
||||||
color: optionalOmitUndefined(Schema.String),
|
color: optional(Schema.String),
|
||||||
})
|
})
|
||||||
export const Commands = Schema.Struct({
|
export const Commands = Schema.Struct({
|
||||||
start: optionalOmitUndefined(
|
start: optional(
|
||||||
Schema.String.annotate({ description: "Startup script to run when creating a new workspace (worktree)" }),
|
Schema.String.annotate({ description: "Startup script to run when creating a new workspace (worktree)" }),
|
||||||
),
|
),
|
||||||
})
|
})
|
||||||
export const Time = Schema.Struct({
|
export const Time = Schema.Struct({
|
||||||
created: NonNegativeInt,
|
created: NonNegativeInt,
|
||||||
updated: NonNegativeInt,
|
updated: NonNegativeInt,
|
||||||
initialized: optionalOmitUndefined(NonNegativeInt),
|
initialized: optional(NonNegativeInt),
|
||||||
})
|
})
|
||||||
|
|
||||||
export const Info = Schema.Struct({
|
export const Info = Schema.Struct({
|
||||||
id: ID,
|
id: ID,
|
||||||
worktree: Schema.String,
|
worktree: Schema.String,
|
||||||
vcs: optionalOmitUndefined(Vcs),
|
vcs: optional(Vcs),
|
||||||
name: optionalOmitUndefined(Schema.String),
|
name: optional(Schema.String),
|
||||||
icon: optionalOmitUndefined(Icon),
|
icon: optional(Icon),
|
||||||
commands: optionalOmitUndefined(Commands),
|
commands: optional(Commands),
|
||||||
time: Time,
|
time: Time,
|
||||||
sandboxes: Schema.Array(Schema.String),
|
sandboxes: Schema.Array(Schema.String),
|
||||||
}).annotate({ identifier: "Project" })
|
}).annotate({ identifier: "Project" })
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Schema } from "effect"
|
import { Schema } from "effect"
|
||||||
import { withStatics } from "./schema"
|
import { statics } from "./schema"
|
||||||
|
|
||||||
export interface Source extends Schema.Schema.Type<typeof Source> {}
|
export interface Source extends Schema.Schema.Type<typeof Source> {}
|
||||||
export const Source = Schema.Struct({
|
export const Source = Schema.Struct({
|
||||||
@@ -18,7 +18,7 @@ export const FileAttachment = Schema.Struct({
|
|||||||
})
|
})
|
||||||
.annotate({ identifier: "Prompt.FileAttachment" })
|
.annotate({ identifier: "Prompt.FileAttachment" })
|
||||||
.pipe(
|
.pipe(
|
||||||
withStatics((schema) => ({
|
statics((schema) => ({
|
||||||
create: (input: FileAttachment) =>
|
create: (input: FileAttachment) =>
|
||||||
schema.make({
|
schema.make({
|
||||||
uri: input.uri,
|
uri: input.uri,
|
||||||
@@ -44,7 +44,7 @@ export const Prompt = Schema.Struct({
|
|||||||
})
|
})
|
||||||
.annotate({ identifier: "Prompt" })
|
.annotate({ identifier: "Prompt" })
|
||||||
.pipe(
|
.pipe(
|
||||||
withStatics((schema) => ({
|
statics((schema) => ({
|
||||||
equivalence: Schema.toEquivalence(schema),
|
equivalence: Schema.toEquivalence(schema),
|
||||||
fromUserMessage: (input: Pick<Prompt, "text" | "files" | "agents">) =>
|
fromUserMessage: (input: Pick<Prompt, "text" | "files" | "agents">) =>
|
||||||
schema.make({
|
schema.make({
|
||||||
|
|||||||
@@ -2,11 +2,11 @@ export * as Provider from "./provider"
|
|||||||
|
|
||||||
import { Schema } from "effect"
|
import { Schema } from "effect"
|
||||||
import { Integration } from "./integration"
|
import { Integration } from "./integration"
|
||||||
import { withStatics } from "./schema"
|
import { statics } from "./schema"
|
||||||
|
|
||||||
export const ID = Schema.String.pipe(
|
export const ID = Schema.String.pipe(
|
||||||
Schema.brand("ProviderV2.ID"),
|
Schema.brand("ProviderV2.ID"),
|
||||||
withStatics((schema) => ({
|
statics((schema) => ({
|
||||||
opencode: schema.make("opencode"),
|
opencode: schema.make("opencode"),
|
||||||
anthropic: schema.make("anthropic"),
|
anthropic: schema.make("anthropic"),
|
||||||
openai: schema.make("openai"),
|
openai: schema.make("openai"),
|
||||||
@@ -57,7 +57,7 @@ export const Info = Schema.Struct({
|
|||||||
})
|
})
|
||||||
.annotate({ identifier: "ProviderV2.Info" })
|
.annotate({ identifier: "ProviderV2.Info" })
|
||||||
.pipe(
|
.pipe(
|
||||||
withStatics((schema) => ({
|
statics((schema) => ({
|
||||||
empty: (id: ID) =>
|
empty: (id: ID) =>
|
||||||
schema.make({
|
schema.make({
|
||||||
id,
|
id,
|
||||||
|
|||||||
@@ -3,13 +3,12 @@ export * as Pty from "./pty"
|
|||||||
import { Schema } from "effect"
|
import { Schema } from "effect"
|
||||||
import { define, inventory } from "./event"
|
import { define, inventory } from "./event"
|
||||||
import { ascending } from "./identifier"
|
import { ascending } from "./identifier"
|
||||||
import { NonNegativeInt, PositiveInt } from "./schema"
|
import { NonNegativeInt, PositiveInt, statics } from "./schema"
|
||||||
import { withStatics } from "./schema"
|
|
||||||
|
|
||||||
const IDSchema = Schema.String.check(Schema.isStartsWith("pty")).pipe(Schema.brand("PtyID"))
|
const IDSchema = Schema.String.check(Schema.isStartsWith("pty")).pipe(Schema.brand("PtyID"))
|
||||||
|
|
||||||
export const ID = IDSchema.pipe(
|
export const ID = IDSchema.pipe(
|
||||||
withStatics((schema: typeof IDSchema) => ({
|
statics((schema: typeof IDSchema) => ({
|
||||||
ascending: (id?: string) => schema.make(id ?? "pty_" + ascending()),
|
ascending: (id?: string) => schema.make(id ?? "pty_" + ascending()),
|
||||||
})),
|
})),
|
||||||
)
|
)
|
||||||
@@ -25,14 +24,12 @@ export const Info = Schema.Struct({
|
|||||||
pid: NonNegativeInt,
|
pid: NonNegativeInt,
|
||||||
exitCode: Schema.optional(NonNegativeInt),
|
exitCode: Schema.optional(NonNegativeInt),
|
||||||
}).annotate({ identifier: "Pty" })
|
}).annotate({ identifier: "Pty" })
|
||||||
export const PtyInfo = Info
|
|
||||||
|
|
||||||
const Created = define({ type: "pty.created", schema: { info: Info } })
|
const Created = define({ type: "pty.created", schema: { info: Info } })
|
||||||
const Updated = define({ type: "pty.updated", schema: { info: Info } })
|
const Updated = define({ type: "pty.updated", schema: { info: Info } })
|
||||||
const Exited = define({ type: "pty.exited", schema: { id: ID, exitCode: NonNegativeInt } })
|
const Exited = define({ type: "pty.exited", schema: { id: ID, exitCode: NonNegativeInt } })
|
||||||
const Deleted = define({ type: "pty.deleted", schema: { id: ID } })
|
const Deleted = define({ type: "pty.deleted", schema: { id: ID } })
|
||||||
export const Event = { Created, Updated, Exited, Deleted, Definitions: inventory(Created, Updated, Exited, Deleted) }
|
export const Event = { Created, Updated, Exited, Deleted, Definitions: inventory(Created, Updated, Exited, Deleted) }
|
||||||
export const PtyEvent = Event
|
|
||||||
|
|
||||||
export const CreateInput = Schema.Struct({
|
export const CreateInput = Schema.Struct({
|
||||||
command: Schema.optional(Schema.String),
|
command: Schema.optional(Schema.String),
|
||||||
|
|||||||
@@ -3,13 +3,13 @@ export * as QuestionV1 from "./question-v1"
|
|||||||
import { Schema } from "effect"
|
import { Schema } from "effect"
|
||||||
import { define, inventory } from "./event"
|
import { define, inventory } from "./event"
|
||||||
import { ascending } from "./identifier"
|
import { ascending } from "./identifier"
|
||||||
import { withStatics } from "./schema"
|
import { statics } from "./schema"
|
||||||
import { SessionID } from "./session-id"
|
import { SessionID } from "./session-id"
|
||||||
import { SessionV1 } from "./session-v1"
|
import { SessionV1 } from "./session-v1"
|
||||||
|
|
||||||
export const ID = Schema.String.check(Schema.isStartsWith("que")).pipe(
|
export const ID = Schema.String.check(Schema.isStartsWith("que")).pipe(
|
||||||
Schema.brand("QuestionID"),
|
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({
|
export const Option = Schema.Struct({
|
||||||
|
|||||||
@@ -4,11 +4,11 @@ import { Schema } from "effect"
|
|||||||
import { define, inventory } from "./event"
|
import { define, inventory } from "./event"
|
||||||
import { ascending } from "./identifier"
|
import { ascending } from "./identifier"
|
||||||
import { SessionID } from "./session-id"
|
import { SessionID } from "./session-id"
|
||||||
import { withStatics } from "./schema"
|
import { statics } from "./schema"
|
||||||
|
|
||||||
export const ID = Schema.String.check(Schema.isStartsWith("que")).pipe(
|
export const ID = Schema.String.check(Schema.isStartsWith("que")).pipe(
|
||||||
Schema.brand("QuestionV2.ID"),
|
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
|
export type ID = typeof ID.Type
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ export * as Revert from "./revert"
|
|||||||
|
|
||||||
import { Schema } from "effect"
|
import { Schema } from "effect"
|
||||||
import { NonNegativeInt, RelativePath } from "./schema"
|
import { NonNegativeInt, RelativePath } from "./schema"
|
||||||
import { SessionMessageID } from "./session-message-id"
|
import { SessionMessage } from "./session-message"
|
||||||
|
|
||||||
export const FileDiff = Schema.Struct({
|
export const FileDiff = Schema.Struct({
|
||||||
path: RelativePath,
|
path: RelativePath,
|
||||||
@@ -14,7 +14,7 @@ export const FileDiff = Schema.Struct({
|
|||||||
export type FileDiff = typeof FileDiff.Type
|
export type FileDiff = typeof FileDiff.Type
|
||||||
|
|
||||||
export const State = Schema.Struct({
|
export const State = Schema.Struct({
|
||||||
messageID: SessionMessageID.ID,
|
messageID: SessionMessage.ID,
|
||||||
partID: Schema.String.pipe(Schema.optional),
|
partID: Schema.String.pipe(Schema.optional),
|
||||||
snapshot: Schema.String.pipe(Schema.optional),
|
snapshot: Schema.String.pipe(Schema.optional),
|
||||||
diff: 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 const AbsolutePath = Schema.String.pipe(Schema.brand("AbsolutePath"))
|
||||||
export type AbsolutePath = typeof AbsolutePath.Type
|
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.optionalKey(schema).pipe(
|
||||||
Schema.decodeTo(Schema.optional(schema), {
|
Schema.decodeTo(Schema.optional(schema), {
|
||||||
decode: SchemaGetter.passthrough({ strict: false }),
|
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) =>
|
<S extends object, M extends Record<string, unknown>>(methods: (schema: S) => M) =>
|
||||||
(schema: S): S & M =>
|
(schema: S): S & M =>
|
||||||
Object.assign(schema, methods(schema))
|
Object.assign(schema, methods(schema))
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import { DateTimeUtcFromMillis, NonNegativeInt, RelativePath } from "./schema"
|
|||||||
import { FileAttachment, Prompt } from "./prompt"
|
import { FileAttachment, Prompt } from "./prompt"
|
||||||
import { SessionID } from "./session-id"
|
import { SessionID } from "./session-id"
|
||||||
import { Location } from "./location"
|
import { Location } from "./location"
|
||||||
import { SessionMessageID } from "./session-message-id"
|
|
||||||
import { SessionMessage } from "./session-message"
|
import { SessionMessage } from "./session-message"
|
||||||
import { Revert } from "./revert"
|
import { Revert } from "./revert"
|
||||||
|
|
||||||
@@ -30,7 +29,7 @@ const Base = {
|
|||||||
}
|
}
|
||||||
const PromptFields = {
|
const PromptFields = {
|
||||||
...Base,
|
...Base,
|
||||||
messageID: SessionMessageID.ID,
|
messageID: SessionMessage.ID,
|
||||||
prompt: Prompt,
|
prompt: Prompt,
|
||||||
delivery: Delivery,
|
delivery: Delivery,
|
||||||
}
|
}
|
||||||
@@ -56,7 +55,7 @@ export const AgentSwitched = Event.define({
|
|||||||
...options,
|
...options,
|
||||||
schema: {
|
schema: {
|
||||||
...Base,
|
...Base,
|
||||||
messageID: SessionMessageID.ID,
|
messageID: SessionMessage.ID,
|
||||||
agent: Schema.String,
|
agent: Schema.String,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -67,7 +66,7 @@ export const ModelSwitched = Event.define({
|
|||||||
...options,
|
...options,
|
||||||
schema: {
|
schema: {
|
||||||
...Base,
|
...Base,
|
||||||
messageID: SessionMessageID.ID,
|
messageID: SessionMessage.ID,
|
||||||
model: Model.Ref,
|
model: Model.Ref,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -103,7 +102,7 @@ export const ContextUpdated = Event.define({
|
|||||||
...options,
|
...options,
|
||||||
schema: {
|
schema: {
|
||||||
...Base,
|
...Base,
|
||||||
messageID: SessionMessageID.ID,
|
messageID: SessionMessage.ID,
|
||||||
text: Schema.String,
|
text: Schema.String,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -114,7 +113,7 @@ export const Synthetic = Event.define({
|
|||||||
...options,
|
...options,
|
||||||
schema: {
|
schema: {
|
||||||
...Base,
|
...Base,
|
||||||
messageID: SessionMessageID.ID,
|
messageID: SessionMessage.ID,
|
||||||
text: Schema.String,
|
text: Schema.String,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -126,7 +125,7 @@ export namespace Shell {
|
|||||||
...options,
|
...options,
|
||||||
schema: {
|
schema: {
|
||||||
...Base,
|
...Base,
|
||||||
messageID: SessionMessageID.ID,
|
messageID: SessionMessage.ID,
|
||||||
callID: Schema.String,
|
callID: Schema.String,
|
||||||
command: Schema.String,
|
command: Schema.String,
|
||||||
},
|
},
|
||||||
@@ -151,7 +150,7 @@ export namespace Step {
|
|||||||
...options,
|
...options,
|
||||||
schema: {
|
schema: {
|
||||||
...Base,
|
...Base,
|
||||||
assistantMessageID: SessionMessageID.ID,
|
assistantMessageID: SessionMessage.ID,
|
||||||
agent: Schema.String,
|
agent: Schema.String,
|
||||||
model: Model.Ref,
|
model: Model.Ref,
|
||||||
snapshot: Schema.String.pipe(Schema.optional),
|
snapshot: Schema.String.pipe(Schema.optional),
|
||||||
@@ -164,7 +163,7 @@ export namespace Step {
|
|||||||
...stepSettlementOptions,
|
...stepSettlementOptions,
|
||||||
schema: {
|
schema: {
|
||||||
...Base,
|
...Base,
|
||||||
assistantMessageID: SessionMessageID.ID,
|
assistantMessageID: SessionMessage.ID,
|
||||||
finish: Schema.String,
|
finish: Schema.String,
|
||||||
cost: Schema.Finite,
|
cost: Schema.Finite,
|
||||||
tokens: Schema.Struct({
|
tokens: Schema.Struct({
|
||||||
@@ -187,7 +186,7 @@ export namespace Step {
|
|||||||
...stepSettlementOptions,
|
...stepSettlementOptions,
|
||||||
schema: {
|
schema: {
|
||||||
...Base,
|
...Base,
|
||||||
assistantMessageID: SessionMessageID.ID,
|
assistantMessageID: SessionMessage.ID,
|
||||||
error: UnknownError,
|
error: UnknownError,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -200,7 +199,7 @@ export namespace Text {
|
|||||||
...options,
|
...options,
|
||||||
schema: {
|
schema: {
|
||||||
...Base,
|
...Base,
|
||||||
assistantMessageID: SessionMessageID.ID,
|
assistantMessageID: SessionMessage.ID,
|
||||||
textID: Schema.String,
|
textID: Schema.String,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -211,7 +210,7 @@ export namespace Text {
|
|||||||
type: "session.next.text.delta",
|
type: "session.next.text.delta",
|
||||||
schema: {
|
schema: {
|
||||||
...Base,
|
...Base,
|
||||||
assistantMessageID: SessionMessageID.ID,
|
assistantMessageID: SessionMessage.ID,
|
||||||
textID: Schema.String,
|
textID: Schema.String,
|
||||||
delta: Schema.String,
|
delta: Schema.String,
|
||||||
},
|
},
|
||||||
@@ -223,7 +222,7 @@ export namespace Text {
|
|||||||
...options,
|
...options,
|
||||||
schema: {
|
schema: {
|
||||||
...Base,
|
...Base,
|
||||||
assistantMessageID: SessionMessageID.ID,
|
assistantMessageID: SessionMessage.ID,
|
||||||
textID: Schema.String,
|
textID: Schema.String,
|
||||||
text: Schema.String,
|
text: Schema.String,
|
||||||
},
|
},
|
||||||
@@ -237,7 +236,7 @@ export namespace Reasoning {
|
|||||||
...options,
|
...options,
|
||||||
schema: {
|
schema: {
|
||||||
...Base,
|
...Base,
|
||||||
assistantMessageID: SessionMessageID.ID,
|
assistantMessageID: SessionMessage.ID,
|
||||||
reasoningID: Schema.String,
|
reasoningID: Schema.String,
|
||||||
providerMetadata: ProviderMetadata.pipe(Schema.optional),
|
providerMetadata: ProviderMetadata.pipe(Schema.optional),
|
||||||
},
|
},
|
||||||
@@ -249,7 +248,7 @@ export namespace Reasoning {
|
|||||||
type: "session.next.reasoning.delta",
|
type: "session.next.reasoning.delta",
|
||||||
schema: {
|
schema: {
|
||||||
...Base,
|
...Base,
|
||||||
assistantMessageID: SessionMessageID.ID,
|
assistantMessageID: SessionMessage.ID,
|
||||||
reasoningID: Schema.String,
|
reasoningID: Schema.String,
|
||||||
delta: Schema.String,
|
delta: Schema.String,
|
||||||
},
|
},
|
||||||
@@ -261,7 +260,7 @@ export namespace Reasoning {
|
|||||||
...options,
|
...options,
|
||||||
schema: {
|
schema: {
|
||||||
...Base,
|
...Base,
|
||||||
assistantMessageID: SessionMessageID.ID,
|
assistantMessageID: SessionMessage.ID,
|
||||||
reasoningID: Schema.String,
|
reasoningID: Schema.String,
|
||||||
text: Schema.String,
|
text: Schema.String,
|
||||||
providerMetadata: ProviderMetadata.pipe(Schema.optional),
|
providerMetadata: ProviderMetadata.pipe(Schema.optional),
|
||||||
@@ -273,7 +272,7 @@ export namespace Reasoning {
|
|||||||
export namespace Tool {
|
export namespace Tool {
|
||||||
const ToolBase = {
|
const ToolBase = {
|
||||||
...Base,
|
...Base,
|
||||||
assistantMessageID: SessionMessageID.ID,
|
assistantMessageID: SessionMessage.ID,
|
||||||
callID: Schema.String,
|
callID: Schema.String,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -401,7 +400,7 @@ export namespace Compaction {
|
|||||||
...options,
|
...options,
|
||||||
schema: {
|
schema: {
|
||||||
...Base,
|
...Base,
|
||||||
messageID: SessionMessageID.ID,
|
messageID: SessionMessage.ID,
|
||||||
reason: Schema.Union([Schema.Literal("auto"), Schema.Literal("manual")]),
|
reason: Schema.Union([Schema.Literal("auto"), Schema.Literal("manual")]),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -411,7 +410,7 @@ export namespace Compaction {
|
|||||||
type: "session.next.compaction.delta",
|
type: "session.next.compaction.delta",
|
||||||
schema: {
|
schema: {
|
||||||
...Base,
|
...Base,
|
||||||
messageID: SessionMessageID.ID,
|
messageID: SessionMessage.ID,
|
||||||
text: Schema.String,
|
text: Schema.String,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -422,7 +421,7 @@ export namespace Compaction {
|
|||||||
...options,
|
...options,
|
||||||
schema: {
|
schema: {
|
||||||
...Base,
|
...Base,
|
||||||
messageID: SessionMessageID.ID,
|
messageID: SessionMessage.ID,
|
||||||
reason: Started.data.fields.reason,
|
reason: Started.data.fields.reason,
|
||||||
text: Schema.String,
|
text: Schema.String,
|
||||||
recent: Schema.String,
|
recent: Schema.String,
|
||||||
@@ -441,7 +440,7 @@ export namespace RevertEvent {
|
|||||||
export const Committed = Event.define({
|
export const Committed = Event.define({
|
||||||
type: "session.next.revert.committed",
|
type: "session.next.revert.committed",
|
||||||
...options,
|
...options,
|
||||||
schema: { ...Base, messageID: SessionMessageID.ID },
|
schema: { ...Base, messageID: SessionMessage.ID },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { Schema } from "effect"
|
import { Schema } from "effect"
|
||||||
import { descending } from "./identifier"
|
import { descending } from "./identifier"
|
||||||
import { withStatics } from "./schema"
|
import { statics } from "./schema"
|
||||||
|
|
||||||
export const SessionID = Schema.String.check(Schema.isStartsWith("ses")).pipe(
|
export const SessionID = Schema.String.check(Schema.isStartsWith("ses")).pipe(
|
||||||
Schema.brand("SessionID"),
|
Schema.brand("SessionID"),
|
||||||
withStatics((schema) => {
|
statics((schema) => {
|
||||||
const create = () => schema.make("ses_" + descending())
|
const create = () => schema.make("ses_" + descending())
|
||||||
return {
|
return {
|
||||||
create,
|
create,
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { Prompt } from "./prompt"
|
|||||||
import { DateTimeUtcFromMillis, NonNegativeInt } from "./schema"
|
import { DateTimeUtcFromMillis, NonNegativeInt } from "./schema"
|
||||||
import { SessionDelivery } from "./session-delivery"
|
import { SessionDelivery } from "./session-delivery"
|
||||||
import { SessionID } from "./session-id"
|
import { SessionID } from "./session-id"
|
||||||
import { SessionMessageID } from "./session-message-id"
|
import { SessionMessage } from "./session-message"
|
||||||
|
|
||||||
export const Delivery = SessionDelivery.Delivery
|
export const Delivery = SessionDelivery.Delivery
|
||||||
export type 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 interface Admitted extends Schema.Schema.Type<typeof Admitted> {}
|
||||||
export const Admitted = Schema.Struct({
|
export const Admitted = Schema.Struct({
|
||||||
admittedSeq: NonNegativeInt,
|
admittedSeq: NonNegativeInt,
|
||||||
id: SessionMessageID.ID,
|
id: SessionMessage.ID,
|
||||||
sessionID: SessionID,
|
sessionID: SessionID,
|
||||||
prompt: Prompt,
|
prompt: Prompt,
|
||||||
delivery: Delivery,
|
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 { ProviderMetadata, ToolContent } from "./llm"
|
||||||
import { Model } from "./model"
|
import { Model } from "./model"
|
||||||
import { FileAttachment, Prompt } from "./prompt"
|
import { FileAttachment, Prompt } from "./prompt"
|
||||||
import { DateTimeUtcFromMillis, RelativePath } from "./schema"
|
import { DateTimeUtcFromMillis, RelativePath, statics } from "./schema"
|
||||||
import { SessionID } from "./session-id"
|
import { SessionID } from "./session-id"
|
||||||
import { SessionMessageID } from "./session-message-id"
|
import { ascending } from "./identifier"
|
||||||
|
|
||||||
export const ID = SessionMessageID.ID
|
export const ID = Schema.String.check(Schema.isStartsWith("msg_")).pipe(
|
||||||
export type ID = SessionMessageID.ID
|
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 interface UnknownError extends Schema.Schema.Type<typeof UnknownError> {}
|
||||||
export const UnknownError = Schema.Struct({
|
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" }),
|
priority: Schema.String.annotate({ description: "Priority level of the task: high, medium, low" }),
|
||||||
}).annotate({ identifier: "Todo" })
|
}).annotate({ identifier: "Todo" })
|
||||||
export type Info = typeof Info.Type
|
export type Info = typeof Info.Type
|
||||||
export const SessionTodoInfo = Info
|
|
||||||
|
|
||||||
const Updated = define({
|
const Updated = define({
|
||||||
type: "todo.updated",
|
type: "todo.updated",
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { PermissionV1 } from "./permission-v1"
|
|||||||
import { Project } from "./project"
|
import { Project } from "./project"
|
||||||
import { Provider } from "./provider"
|
import { Provider } from "./provider"
|
||||||
import { Model } from "./model"
|
import { Model } from "./model"
|
||||||
import { NonNegativeInt, optionalOmitUndefined, withStatics } from "./schema"
|
import { NonNegativeInt, optional, statics } from "./schema"
|
||||||
import { ascending } from "./identifier"
|
import { ascending } from "./identifier"
|
||||||
import { SessionID } from "./session-id"
|
import { SessionID } from "./session-id"
|
||||||
import { WorkspaceID } from "./workspace-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(
|
export const MessageID = Schema.String.check(Schema.isStartsWith("msg")).pipe(
|
||||||
Schema.brand("MessageID"),
|
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 type MessageID = typeof MessageID.Type
|
||||||
|
|
||||||
export const PartID = Schema.String.check(Schema.isStartsWith("prt")).pipe(
|
export const PartID = Schema.String.check(Schema.isStartsWith("prt")).pipe(
|
||||||
Schema.brand("PartID"),
|
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
|
export type PartID = typeof PartID.Type
|
||||||
|
|
||||||
@@ -510,7 +510,7 @@ const SessionSummary = Schema.Struct({
|
|||||||
additions: Schema.Finite,
|
additions: Schema.Finite,
|
||||||
deletions: Schema.Finite,
|
deletions: Schema.Finite,
|
||||||
files: Schema.Finite,
|
files: Schema.Finite,
|
||||||
diffs: optionalOmitUndefined(Schema.Array(FileDiff.Info)),
|
diffs: optional(Schema.Array(FileDiff.Info)),
|
||||||
})
|
})
|
||||||
|
|
||||||
const SessionTokens = Schema.Struct({
|
const SessionTokens = Schema.Struct({
|
||||||
@@ -529,42 +529,42 @@ const SessionShare = Schema.Struct({
|
|||||||
|
|
||||||
const SessionRevert = Schema.Struct({
|
const SessionRevert = Schema.Struct({
|
||||||
messageID: MessageID,
|
messageID: MessageID,
|
||||||
partID: optionalOmitUndefined(PartID),
|
partID: optional(PartID),
|
||||||
snapshot: optionalOmitUndefined(Schema.String),
|
snapshot: optional(Schema.String),
|
||||||
diff: optionalOmitUndefined(Schema.String),
|
diff: optional(Schema.String),
|
||||||
})
|
})
|
||||||
|
|
||||||
const SessionModel = Schema.Struct({
|
const SessionModel = Schema.Struct({
|
||||||
id: Model.ID,
|
id: Model.ID,
|
||||||
providerID: Provider.ID,
|
providerID: Provider.ID,
|
||||||
variant: optionalOmitUndefined(Schema.String),
|
variant: optional(Schema.String),
|
||||||
})
|
})
|
||||||
|
|
||||||
export const SessionInfo = Schema.Struct({
|
export const SessionInfo = Schema.Struct({
|
||||||
id: SessionID,
|
id: SessionID,
|
||||||
slug: Schema.String,
|
slug: Schema.String,
|
||||||
projectID: Project.ID,
|
projectID: Project.ID,
|
||||||
workspaceID: optionalOmitUndefined(WorkspaceID),
|
workspaceID: optional(WorkspaceID),
|
||||||
directory: Schema.String,
|
directory: Schema.String,
|
||||||
path: optionalOmitUndefined(Schema.String),
|
path: optional(Schema.String),
|
||||||
parentID: optionalOmitUndefined(SessionID),
|
parentID: optional(SessionID),
|
||||||
summary: optionalOmitUndefined(SessionSummary),
|
summary: optional(SessionSummary),
|
||||||
cost: optionalOmitUndefined(Schema.Finite),
|
cost: optional(Schema.Finite),
|
||||||
tokens: optionalOmitUndefined(SessionTokens),
|
tokens: optional(SessionTokens),
|
||||||
share: optionalOmitUndefined(SessionShare),
|
share: optional(SessionShare),
|
||||||
title: Schema.String,
|
title: Schema.String,
|
||||||
agent: optionalOmitUndefined(Schema.String),
|
agent: optional(Schema.String),
|
||||||
model: optionalOmitUndefined(SessionModel),
|
model: optional(SessionModel),
|
||||||
version: Schema.String,
|
version: Schema.String,
|
||||||
metadata: optionalOmitUndefined(Schema.Record(Schema.String, Schema.Any)),
|
metadata: optional(Schema.Record(Schema.String, Schema.Any)),
|
||||||
time: Schema.Struct({
|
time: Schema.Struct({
|
||||||
created: NonNegativeInt,
|
created: NonNegativeInt,
|
||||||
updated: NonNegativeInt,
|
updated: NonNegativeInt,
|
||||||
compacting: optionalOmitUndefined(NonNegativeInt),
|
compacting: optional(NonNegativeInt),
|
||||||
archived: optionalOmitUndefined(Schema.Finite),
|
archived: optional(Schema.Finite),
|
||||||
}),
|
}),
|
||||||
permission: optionalOmitUndefined(PermissionV1.Ruleset),
|
permission: optional(PermissionV1.Ruleset),
|
||||||
revert: optionalOmitUndefined(SessionRevert),
|
revert: optional(SessionRevert),
|
||||||
}).annotate({ identifier: "Session" })
|
}).annotate({ identifier: "Session" })
|
||||||
export type SessionInfo = typeof SessionInfo.Type
|
export type SessionInfo = typeof SessionInfo.Type
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { Agent } from "./agent"
|
|||||||
import { Location } from "./location"
|
import { Location } from "./location"
|
||||||
import { Model } from "./model"
|
import { Model } from "./model"
|
||||||
import { Project } from "./project"
|
import { Project } from "./project"
|
||||||
import { DateTimeUtcFromMillis, optionalOmitUndefined, RelativePath } from "./schema"
|
import { DateTimeUtcFromMillis, optional, RelativePath } from "./schema"
|
||||||
import { SessionEvent } from "./session-event"
|
import { SessionEvent } from "./session-event"
|
||||||
import { SessionID } from "./session-id"
|
import { SessionID } from "./session-id"
|
||||||
import { Revert } from "./revert"
|
import { Revert } from "./revert"
|
||||||
@@ -18,7 +18,7 @@ export const Event = SessionEvent
|
|||||||
export interface Info extends Schema.Schema.Type<typeof Info> {}
|
export interface Info extends Schema.Schema.Type<typeof Info> {}
|
||||||
export const Info = Schema.Struct({
|
export const Info = Schema.Struct({
|
||||||
id: ID,
|
id: ID,
|
||||||
parentID: ID.pipe(optionalOmitUndefined),
|
parentID: ID.pipe(optional),
|
||||||
projectID: Project.ID,
|
projectID: Project.ID,
|
||||||
agent: Agent.ID.pipe(Schema.optional),
|
agent: Agent.ID.pipe(Schema.optional),
|
||||||
model: Model.Ref.pipe(Schema.optional),
|
model: Model.Ref.pipe(Schema.optional),
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { Schema } from "effect"
|
import { Schema } from "effect"
|
||||||
import { ascending } from "./identifier"
|
import { ascending } from "./identifier"
|
||||||
import { withStatics } from "./schema"
|
import { statics } from "./schema"
|
||||||
|
|
||||||
export const WorkspaceID = Schema.String.check(Schema.isStartsWith("wrk")).pipe(
|
export const WorkspaceID = Schema.String.check(Schema.isStartsWith("wrk")).pipe(
|
||||||
Schema.brand("WorkspaceV2.ID"),
|
Schema.brand("WorkspaceV2.ID"),
|
||||||
withStatics((schema) => {
|
statics((schema) => {
|
||||||
const create = () => schema.make("wrk_" + ascending())
|
const create = () => schema.make("wrk_" + ascending())
|
||||||
return {
|
return {
|
||||||
ascending: (id?: string) => {
|
ascending: (id?: string) => {
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ Use Effect schemas as the public contract:
|
|||||||
- branded schemas for ids
|
- branded schemas for ids
|
||||||
- `Schema.Class` or `Schema.Struct` for domain data
|
- `Schema.Class` or `Schema.Struct` for domain data
|
||||||
- `Schema.TaggedErrorClass` for expected errors
|
- `Schema.TaggedErrorClass` for expected errors
|
||||||
- existing core helpers like `DeepMutable`, `withStatics`, and integer schemas where appropriate
|
- existing core helpers like `DeepMutable`, `statics`, and integer schemas where appropriate
|
||||||
|
|
||||||
Prefer `Info` objects as the stored domain records. Add static `empty(...)` constructors when update APIs need to create records on first mutation.
|
Prefer `Info` objects as the stored domain records. Add static `empty(...)` constructors when update APIs need to create records on first mutation.
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
```ts
|
```ts
|
||||||
export const ID = Schema.String.pipe(
|
export const ID = Schema.String.pipe(
|
||||||
Schema.brand("ProviderV2.ID"),
|
Schema.brand("ProviderV2.ID"),
|
||||||
withStatics((schema) => ({
|
statics((schema) => ({
|
||||||
opencode: schema.make("opencode"),
|
opencode: schema.make("opencode"),
|
||||||
anthropic: schema.make("anthropic"),
|
anthropic: schema.make("anthropic"),
|
||||||
openai: schema.make("openai"),
|
openai: schema.make("openai"),
|
||||||
|
|||||||
Reference in New Issue
Block a user