refactor(schema): declare event durability at definition level (#35172)
This commit is contained in:
parent
bd8d858bf7
commit
de476aa51b
53 changed files with 700 additions and 1165 deletions
|
|
@ -1,14 +1,14 @@
|
|||
export * as Agent from "./agent.js"
|
||||
|
||||
import { Schema } from "effect"
|
||||
import { define, inventory } from "./event.js"
|
||||
import { ephemeral, inventory } from "./event.js"
|
||||
import { optional } from "./schema.js"
|
||||
import { Model } from "./model.js"
|
||||
import { Permission } from "./permission.js"
|
||||
import { Provider } from "./provider.js"
|
||||
import { PositiveInt, statics } from "./schema.js"
|
||||
|
||||
const Updated = define({ type: "agent.updated", schema: {} })
|
||||
const Updated = ephemeral({ type: "agent.updated", schema: {} })
|
||||
|
||||
export const ID = Schema.String.pipe(Schema.brand("AgentV2.ID"))
|
||||
export type ID = typeof ID.Type
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
export * as Catalog from "./catalog.js"
|
||||
|
||||
import { define, inventory } from "./event.js"
|
||||
import { ephemeral, inventory } from "./event.js"
|
||||
|
||||
const Updated = define({ type: "catalog.updated", schema: {} })
|
||||
const Updated = ephemeral({ type: "catalog.updated", schema: {} })
|
||||
export const Event = { Updated, Definitions: inventory(Updated) }
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
export * as Command from "./command.js"
|
||||
|
||||
import { Schema } from "effect"
|
||||
import { define, inventory } from "./event.js"
|
||||
import { ephemeral, inventory } from "./event.js"
|
||||
import { optional } from "./schema.js"
|
||||
import { Model } from "./model.js"
|
||||
|
||||
const Updated = define({ type: "command.updated", schema: {} })
|
||||
const Updated = ephemeral({ type: "command.updated", schema: {} })
|
||||
|
||||
export interface Info extends Schema.Schema.Type<typeof Info> {}
|
||||
export const Info = Schema.Struct({
|
||||
|
|
|
|||
|
|
@ -5,11 +5,8 @@ import { SessionEvent } from "./session-event.js"
|
|||
import { SessionV1 } from "./session-v1.js"
|
||||
|
||||
export const SessionDurable = {
|
||||
definitions: Event.durable(SessionEvent.DurableDefinitions),
|
||||
definitions: Event.durableMap(SessionEvent.Definitions),
|
||||
schema: SessionEvent.Durable,
|
||||
} as const
|
||||
|
||||
export const Durable = Event.durable([
|
||||
...SessionV1.Event.Definitions.filter((definition) => definition.durable !== undefined),
|
||||
...SessionEvent.DurableDefinitions,
|
||||
])
|
||||
export const Durable = Event.durableMap([...SessionV1.Event.Definitions, ...SessionEvent.Definitions])
|
||||
|
|
|
|||
|
|
@ -36,8 +36,12 @@ import { VcsEvent } from "./vcs-event.js"
|
|||
import { WorkspaceEvent } from "./workspace-event.js"
|
||||
import { WorktreeEvent } from "./worktree-event.js"
|
||||
|
||||
const sessionV1DurableDefinitions = SessionV1.Event.Definitions.filter((definition) => definition.durable !== undefined)
|
||||
const sessionV1LiveDefinitions = SessionV1.Event.Definitions.filter((definition) => definition.durable === undefined)
|
||||
const sessionV1DurableDefinitions = SessionV1.Event.Definitions.filter(
|
||||
(definition) => definition.durability === "durable",
|
||||
)
|
||||
const sessionV1LiveDefinitions = SessionV1.Event.Definitions.filter(
|
||||
(definition) => definition.durability === "ephemeral",
|
||||
)
|
||||
|
||||
const coreDefinitions = Event.inventory(...sessionV1DurableDefinitions, ...SessionEvent.Definitions)
|
||||
|
||||
|
|
|
|||
|
|
@ -24,50 +24,70 @@ export type Seq = typeof Seq.Type
|
|||
export const Version = Schema.Int.check(Schema.isGreaterThanOrEqualTo(1)).pipe(Schema.brand("Event.Version"))
|
||||
export type Version = typeof Version.Type
|
||||
|
||||
export type Definition<
|
||||
const DurableEnvelope = Schema.Struct({ aggregateID: Schema.String, seq: Seq, version: Version })
|
||||
export type DurableEnvelope = typeof DurableEnvelope.Type
|
||||
|
||||
export type DurableDefinition<
|
||||
Type extends string = string,
|
||||
DataSchema extends Schema.Codec<unknown, unknown> = Schema.Codec<unknown, unknown>,
|
||||
> = Schema.Top & {
|
||||
readonly type: Type
|
||||
readonly durable?: {
|
||||
readonly durability: "durable"
|
||||
readonly durable: {
|
||||
readonly version: number
|
||||
readonly aggregate: string
|
||||
}
|
||||
readonly data: DataSchema
|
||||
}
|
||||
|
||||
export type EphemeralDefinition<
|
||||
Type extends string = string,
|
||||
DataSchema extends Schema.Codec<unknown, unknown> = Schema.Codec<unknown, unknown>,
|
||||
> = Schema.Top & {
|
||||
readonly type: Type
|
||||
readonly durability: "ephemeral"
|
||||
readonly durable?: never
|
||||
readonly data: DataSchema
|
||||
}
|
||||
|
||||
export type Definition<
|
||||
Type extends string = string,
|
||||
DataSchema extends Schema.Codec<unknown, unknown> = Schema.Codec<unknown, unknown>,
|
||||
> = DurableDefinition<Type, DataSchema> | EphemeralDefinition<Type, DataSchema>
|
||||
|
||||
export type Data<D extends Definition> = Schema.Schema.Type<D["data"]>
|
||||
|
||||
export type Payload<D extends Definition = Definition> = {
|
||||
type PayloadBase<D extends Definition> = {
|
||||
readonly id: ID
|
||||
readonly type: D["type"]
|
||||
readonly data: Data<D>
|
||||
readonly durable?: {
|
||||
readonly aggregateID: string
|
||||
readonly seq: Seq
|
||||
readonly version: Version
|
||||
}
|
||||
readonly location?: Location.Ref
|
||||
readonly metadata?: Record<string, unknown>
|
||||
}
|
||||
|
||||
export function define<
|
||||
const Type extends string,
|
||||
const Fields extends Readonly<Record<PropertyKey, Schema.Codec<unknown, unknown>>>,
|
||||
>(input: {
|
||||
export type Payload<D extends Definition = Definition> = D extends DurableDefinition
|
||||
? PayloadBase<D> & { readonly durable: DurableEnvelope }
|
||||
: PayloadBase<D> & { readonly durable?: never }
|
||||
|
||||
type Input<Type extends string, Fields extends Readonly<Record<PropertyKey, Schema.Codec<unknown, unknown>>>> = {
|
||||
readonly type: Type
|
||||
readonly durable?: {
|
||||
readonly version: number
|
||||
readonly aggregate: string
|
||||
}
|
||||
readonly schema: Fields
|
||||
}) {
|
||||
}
|
||||
|
||||
export function durable<
|
||||
const Type extends string,
|
||||
const Fields extends Readonly<Record<PropertyKey, Schema.Codec<unknown, unknown>>>,
|
||||
>(input: Input<Type, Fields> & { readonly durable: NonNullable<Input<Type, Fields>["durable"]> }) {
|
||||
const data = Schema.Struct(input.schema)
|
||||
return Schema.Struct({
|
||||
id: ID,
|
||||
metadata: optional(Schema.Record(Schema.String, Schema.Unknown)),
|
||||
type: Schema.Literal(input.type),
|
||||
durable: optional(Schema.Struct({ aggregateID: Schema.String, seq: Seq, version: Version })),
|
||||
durable: DurableEnvelope,
|
||||
location: optional(Location.Ref),
|
||||
data,
|
||||
})
|
||||
|
|
@ -75,10 +95,34 @@ export function define<
|
|||
.pipe(
|
||||
statics(() => ({
|
||||
type: input.type,
|
||||
...(input.durable === undefined ? {} : { durable: input.durable }),
|
||||
durability: "durable" as const,
|
||||
durable: input.durable,
|
||||
data,
|
||||
})),
|
||||
) satisfies Definition<Type, typeof data>
|
||||
) satisfies DurableDefinition<Type, typeof data>
|
||||
}
|
||||
|
||||
export function ephemeral<
|
||||
const Type extends string,
|
||||
const Fields extends Readonly<Record<PropertyKey, Schema.Codec<unknown, unknown>>>,
|
||||
>(input: Omit<Input<Type, Fields>, "durable">) {
|
||||
const data = Schema.Struct(input.schema)
|
||||
return Schema.Struct({
|
||||
id: ID,
|
||||
metadata: optional(Schema.Record(Schema.String, Schema.Unknown)),
|
||||
type: Schema.Literal(input.type),
|
||||
location: optional(Location.Ref),
|
||||
data,
|
||||
})
|
||||
.annotate({ identifier: input.type })
|
||||
.pipe(
|
||||
statics(() => ({
|
||||
type: input.type,
|
||||
durability: "ephemeral" as const,
|
||||
durable: undefined,
|
||||
data,
|
||||
})),
|
||||
) satisfies EphemeralDefinition<Type, typeof data>
|
||||
}
|
||||
|
||||
export function inventory<const Definitions extends ReadonlyArray<Definition>>(...definitions: Definitions) {
|
||||
|
|
@ -107,15 +151,15 @@ export function versionedType(type: string, version: number) {
|
|||
return `${type}.${version}`
|
||||
}
|
||||
|
||||
export function durable<const Definitions extends ReadonlyArray<Definition>>(definitions: Definitions) {
|
||||
export function durableMap<const Definitions extends ReadonlyArray<Definition>>(definitions: Definitions) {
|
||||
return readonlyMap(
|
||||
definitions.reduce((result, definition) => {
|
||||
if (!definition.durable) return result
|
||||
if (definition.durability !== "durable") return result
|
||||
const key = versionedType(definition.type, definition.durable.version)
|
||||
if (result.has(key)) throw new Error(`Duplicate durable event definition for ${key}`)
|
||||
result.set(key, definition)
|
||||
return result
|
||||
}, new Map<string, Definitions[number]>()),
|
||||
}, new Map<string, DurableDefinition>()),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
export * as FileSystemWatcher from "./filesystem-watcher.js"
|
||||
|
||||
import { Schema } from "effect"
|
||||
import { define, inventory } from "./event.js"
|
||||
import { ephemeral, inventory } from "./event.js"
|
||||
|
||||
const Updated = define({
|
||||
const Updated = ephemeral({
|
||||
type: "file.watcher.updated",
|
||||
schema: {
|
||||
file: Schema.String,
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@ export * as FileSystem from "./filesystem.js"
|
|||
|
||||
import { Schema } from "effect"
|
||||
import { optional } from "./schema.js"
|
||||
import { define, inventory } from "./event.js"
|
||||
import { ephemeral, inventory } from "./event.js"
|
||||
import { NonNegativeInt, PositiveInt, RelativePath } from "./schema.js"
|
||||
|
||||
const Edited = define({
|
||||
const Edited = ephemeral({
|
||||
type: "file.edited",
|
||||
schema: { file: Schema.String },
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
export * as Form from "./form.js"
|
||||
|
||||
import { Schema } from "effect"
|
||||
import { define, inventory } from "./event.js"
|
||||
import { ephemeral, inventory } from "./event.js"
|
||||
import { ascending } from "./identifier.js"
|
||||
import { NonNegativeInt, optional, statics } from "./schema.js"
|
||||
|
||||
|
|
@ -127,9 +127,11 @@ export interface UrlInfo extends Schema.Schema.Type<typeof UrlInfo> {}
|
|||
export const Info = Schema.Union([FormInfo, UrlInfo]).pipe(Schema.toTaggedUnion("mode"))
|
||||
export type Info = FormInfo | UrlInfo
|
||||
|
||||
export const Value = Schema.Union([Schema.String, Schema.Number, Schema.Boolean, Schema.Array(Schema.String)]).annotate({
|
||||
identifier: "Form.Value",
|
||||
})
|
||||
export const Value = Schema.Union([Schema.String, Schema.Number, Schema.Boolean, Schema.Array(Schema.String)]).annotate(
|
||||
{
|
||||
identifier: "Form.Value",
|
||||
},
|
||||
)
|
||||
export type Value = typeof Value.Type
|
||||
|
||||
export const Answer = Schema.Record(Schema.String, Value).annotate({ identifier: "Form.Answer" })
|
||||
|
|
@ -149,8 +151,8 @@ export const Reply = Schema.Struct({
|
|||
}).annotate({ identifier: "Form.Reply" })
|
||||
export interface Reply extends Schema.Schema.Type<typeof Reply> {}
|
||||
|
||||
const Created = define({ type: "form.created", schema: { form: Info } })
|
||||
const Replied = define({ type: "form.replied", schema: { id: ID, sessionID: Schema.String, answer: Answer } })
|
||||
const Cancelled = define({ type: "form.cancelled", schema: { id: ID, sessionID: Schema.String } })
|
||||
const Created = ephemeral({ type: "form.created", schema: { form: Info } })
|
||||
const Replied = ephemeral({ type: "form.replied", schema: { id: ID, sessionID: Schema.String, answer: Answer } })
|
||||
const Cancelled = ephemeral({ type: "form.cancelled", schema: { id: ID, sessionID: Schema.String } })
|
||||
|
||||
export const Event = { Created, Replied, Cancelled, Definitions: inventory(Created, Replied, Cancelled) }
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ export * as IdeEvent from "./ide-event.js"
|
|||
import { Schema } from "effect"
|
||||
import { Event } from "./event.js"
|
||||
|
||||
export const Installed = Event.define({
|
||||
export const Installed = Event.ephemeral({
|
||||
type: "ide.installed",
|
||||
schema: {
|
||||
ide: Schema.String,
|
||||
|
|
|
|||
|
|
@ -3,14 +3,14 @@ export * as InstallationEvent from "./installation-event.js"
|
|||
import { Schema } from "effect"
|
||||
import { Event } from "./event.js"
|
||||
|
||||
export const Updated = Event.define({
|
||||
export const Updated = Event.ephemeral({
|
||||
type: "installation.updated",
|
||||
schema: {
|
||||
version: Schema.String,
|
||||
},
|
||||
})
|
||||
|
||||
export const UpdateAvailable = Event.define({
|
||||
export const UpdateAvailable = Event.ephemeral({
|
||||
type: "installation.update-available",
|
||||
schema: {
|
||||
version: Schema.String,
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ export * as Integration from "./integration.js"
|
|||
|
||||
import { Schema } from "effect"
|
||||
import { optional } from "./schema.js"
|
||||
import { define, inventory } from "./event.js"
|
||||
import { ephemeral, inventory } from "./event.js"
|
||||
import { Connection } from "./connection.js"
|
||||
import { ascending } from "./identifier.js"
|
||||
import { statics } from "./schema.js"
|
||||
|
|
@ -76,11 +76,11 @@ export type Method = typeof Method.Type
|
|||
export const Inputs = Schema.Record(Schema.String, Schema.String).annotate({ identifier: "Integration.Inputs" })
|
||||
export type Inputs = typeof Inputs.Type
|
||||
|
||||
const Updated = define({
|
||||
const Updated = ephemeral({
|
||||
type: "integration.updated",
|
||||
schema: {},
|
||||
})
|
||||
const ConnectionUpdated = define({
|
||||
const ConnectionUpdated = ephemeral({
|
||||
type: "integration.connection.updated",
|
||||
schema: { integrationID: ID },
|
||||
})
|
||||
|
|
|
|||
|
|
@ -2,6 +2,6 @@ export * as LspEvent from "./lsp-event.js"
|
|||
|
||||
import { Event } from "./event.js"
|
||||
|
||||
export const Updated = Event.define({ type: "lsp.updated", schema: {} })
|
||||
export const Updated = Event.ephemeral({ type: "lsp.updated", schema: {} })
|
||||
|
||||
export const Definitions = Event.inventory(Updated)
|
||||
|
|
|
|||
|
|
@ -3,14 +3,14 @@ export * as McpEvent from "./mcp-event.js"
|
|||
import { Schema } from "effect"
|
||||
import { Event } from "./event.js"
|
||||
|
||||
export const ToolsChanged = Event.define({
|
||||
export const ToolsChanged = Event.ephemeral({
|
||||
type: "mcp.tools.changed",
|
||||
schema: {
|
||||
server: Schema.String,
|
||||
},
|
||||
})
|
||||
|
||||
export const BrowserOpenFailed = Event.define({
|
||||
export const BrowserOpenFailed = Event.ephemeral({
|
||||
type: "mcp.browser.open.failed",
|
||||
schema: {
|
||||
mcpName: Schema.String,
|
||||
|
|
@ -20,7 +20,7 @@ export const BrowserOpenFailed = Event.define({
|
|||
|
||||
// Emitted whenever a server's connection status settles (connected, failed, needs_auth, closed) so
|
||||
// observers can refresh status without polling.
|
||||
export const StatusChanged = Event.define({
|
||||
export const StatusChanged = Event.ephemeral({
|
||||
type: "mcp.status.changed",
|
||||
schema: {
|
||||
server: Schema.String,
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
export * as ModelsDev from "./models-dev.js"
|
||||
|
||||
import { define, inventory } from "./event.js"
|
||||
import { ephemeral, inventory } from "./event.js"
|
||||
|
||||
const Refreshed = define({
|
||||
const Refreshed = ephemeral({
|
||||
type: "models-dev.refreshed",
|
||||
schema: {},
|
||||
})
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ export * as Permission from "./permission.js"
|
|||
|
||||
import { Schema } from "effect"
|
||||
import { optional } from "./schema.js"
|
||||
import { define, inventory } from "./event.js"
|
||||
import { ephemeral, inventory } from "./event.js"
|
||||
import { ascending } from "./identifier.js"
|
||||
import { SessionID } from "./session-id.js"
|
||||
import { statics } from "./schema.js"
|
||||
|
|
@ -40,8 +40,8 @@ export interface Request extends Schema.Schema.Type<typeof Request> {}
|
|||
export const Reply = Schema.Literals(["once", "always", "reject"]).annotate({ identifier: "PermissionV2.Reply" })
|
||||
export type Reply = typeof Reply.Type
|
||||
|
||||
const Asked = define({ type: "permission.v2.asked", schema: Request.fields })
|
||||
const Replied = define({
|
||||
const Asked = ephemeral({ type: "permission.v2.asked", schema: Request.fields })
|
||||
const Replied = ephemeral({
|
||||
type: "permission.v2.replied",
|
||||
schema: {
|
||||
sessionID: SessionID,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
export * as Plugin from "./plugin.js"
|
||||
|
||||
import { Schema } from "effect"
|
||||
import { define, inventory } from "./event.js"
|
||||
import { ephemeral, inventory } from "./event.js"
|
||||
|
||||
export const ID = Schema.String.pipe(Schema.brand("Plugin.ID"))
|
||||
export type ID = typeof ID.Type
|
||||
|
|
@ -11,7 +11,7 @@ export const Info = Schema.Struct({
|
|||
id: ID,
|
||||
}).annotate({ identifier: "Plugin.Info" })
|
||||
|
||||
const Added = define({
|
||||
const Added = ephemeral({
|
||||
type: "plugin.added",
|
||||
schema: { id: ID },
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
export * as ProjectDirectories from "./project-directories.js"
|
||||
|
||||
import { define, inventory } from "./event.js"
|
||||
import { ephemeral, inventory } from "./event.js"
|
||||
import { Project } from "./project.js"
|
||||
|
||||
const Updated = define({
|
||||
const Updated = ephemeral({
|
||||
type: "project.directories.updated",
|
||||
schema: { projectID: Project.ID },
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
export * as Project from "./project.js"
|
||||
|
||||
import { Schema } from "effect"
|
||||
import { define, inventory } from "./event.js"
|
||||
import { ephemeral, inventory } from "./event.js"
|
||||
import { AbsolutePath, NonNegativeInt, optional } from "./schema.js"
|
||||
import { ProjectID } from "./project-id.js"
|
||||
|
||||
|
|
@ -56,5 +56,5 @@ export const Info = Schema.Struct({
|
|||
}).annotate({ identifier: "Project" })
|
||||
export interface Info extends Schema.Schema.Type<typeof Info> {}
|
||||
|
||||
const Updated = define({ type: "project.updated", schema: Info.fields })
|
||||
const Updated = ephemeral({ type: "project.updated", schema: Info.fields })
|
||||
export const Event = { Updated, Definitions: inventory(Updated) }
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ export * as Pty from "./pty.js"
|
|||
|
||||
import { Schema } from "effect"
|
||||
import { optional } from "./schema.js"
|
||||
import { define, inventory } from "./event.js"
|
||||
import { ephemeral, inventory } from "./event.js"
|
||||
import { ascending } from "./identifier.js"
|
||||
import { NonNegativeInt, PositiveInt, statics } from "./schema.js"
|
||||
|
||||
|
|
@ -31,10 +31,10 @@ export const Info = Schema.Struct({
|
|||
}).annotate({ identifier: "Pty" })
|
||||
export interface Info extends Schema.Schema.Type<typeof 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 } })
|
||||
const Created = ephemeral({ type: "pty.created", schema: { info: Info } })
|
||||
const Updated = ephemeral({ type: "pty.updated", schema: { info: Info } })
|
||||
const Exited = ephemeral({ type: "pty.exited", schema: { id: ID, exitCode: NonNegativeInt } })
|
||||
const Deleted = ephemeral({ type: "pty.deleted", schema: { id: ID } })
|
||||
export const Event = { Created, Updated, Exited, Deleted, Definitions: inventory(Created, Updated, Exited, Deleted) }
|
||||
|
||||
export const CreateInput = Schema.Struct({
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ export * as Question from "./question.js"
|
|||
|
||||
import { Schema } from "effect"
|
||||
import { optional } from "./schema.js"
|
||||
import { define, inventory } from "./event.js"
|
||||
import { ephemeral, inventory } from "./event.js"
|
||||
import { ascending } from "./identifier.js"
|
||||
import { SessionID } from "./session-id.js"
|
||||
import { statics } from "./schema.js"
|
||||
|
|
@ -67,8 +67,8 @@ export const Reply = Schema.Struct({
|
|||
}).annotate({ identifier: "QuestionV2.Reply" })
|
||||
export interface Reply extends Schema.Schema.Type<typeof Reply> {}
|
||||
|
||||
const Asked = define({ type: "question.v2.asked", schema: Request.fields })
|
||||
const Replied = define({
|
||||
const Asked = ephemeral({ type: "question.v2.asked", schema: Request.fields })
|
||||
const Replied = ephemeral({
|
||||
type: "question.v2.replied",
|
||||
schema: {
|
||||
sessionID: SessionID,
|
||||
|
|
@ -76,7 +76,7 @@ const Replied = define({
|
|||
answers: Schema.Array(Answer),
|
||||
},
|
||||
})
|
||||
const Rejected = define({
|
||||
const Rejected = ephemeral({
|
||||
type: "question.v2.rejected",
|
||||
schema: {
|
||||
sessionID: SessionID,
|
||||
|
|
|
|||
|
|
@ -2,10 +2,10 @@ export * as Reference from "./reference.js"
|
|||
|
||||
import { Schema } from "effect"
|
||||
import { optional } from "./schema.js"
|
||||
import { define, inventory } from "./event.js"
|
||||
import { ephemeral, inventory } from "./event.js"
|
||||
import { AbsolutePath } from "./schema.js"
|
||||
|
||||
const Updated = define({ type: "reference.updated", schema: {} })
|
||||
const Updated = ephemeral({ type: "reference.updated", schema: {} })
|
||||
export const Event = { Updated, Definitions: inventory(Updated) }
|
||||
|
||||
export interface LocalSource extends Schema.Schema.Type<typeof LocalSource> {}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ export * as ServerEvent from "./server-event.js"
|
|||
|
||||
import { Event } from "./event.js"
|
||||
|
||||
export const Connected = Event.define({ type: "server.connected", schema: {} })
|
||||
export const Disposed = Event.define({ type: "global.disposed", schema: {} })
|
||||
export const Connected = Event.ephemeral({ type: "server.connected", schema: {} })
|
||||
export const Disposed = Event.ephemeral({ type: "global.disposed", schema: {} })
|
||||
|
||||
export const Definitions = Event.inventory(Connected, Disposed)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ export * as SessionCompactionEvent from "./session-compaction-event.js"
|
|||
import { Event } from "./event.js"
|
||||
import { SessionID } from "./session-id.js"
|
||||
|
||||
export const Compacted = Event.define({
|
||||
export const Compacted = Event.ephemeral({
|
||||
type: "session.compacted",
|
||||
schema: {
|
||||
sessionID: SessionID,
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ const stepSettlementOptions = {
|
|||
export const UnknownError = SessionMessage.UnknownError
|
||||
export type UnknownError = SessionMessage.UnknownError
|
||||
|
||||
export const AgentSwitched = Event.define({
|
||||
export const AgentSwitched = Event.durable({
|
||||
type: "session.next.agent.switched",
|
||||
...options,
|
||||
schema: {
|
||||
|
|
@ -62,7 +62,7 @@ export const AgentSwitched = Event.define({
|
|||
})
|
||||
export type AgentSwitched = typeof AgentSwitched.Type
|
||||
|
||||
export const ModelSwitched = Event.define({
|
||||
export const ModelSwitched = Event.durable({
|
||||
type: "session.next.model.switched",
|
||||
...options,
|
||||
schema: {
|
||||
|
|
@ -73,7 +73,7 @@ export const ModelSwitched = Event.define({
|
|||
})
|
||||
export type ModelSwitched = typeof ModelSwitched.Type
|
||||
|
||||
export const Moved = Event.define({
|
||||
export const Moved = Event.durable({
|
||||
type: "session.next.moved",
|
||||
...options,
|
||||
schema: {
|
||||
|
|
@ -84,7 +84,7 @@ export const Moved = Event.define({
|
|||
})
|
||||
export type Moved = typeof Moved.Type
|
||||
|
||||
export const Renamed = Event.define({
|
||||
export const Renamed = Event.durable({
|
||||
type: "session.next.renamed",
|
||||
...options,
|
||||
schema: {
|
||||
|
|
@ -94,7 +94,7 @@ export const Renamed = Event.define({
|
|||
})
|
||||
export type Renamed = typeof Renamed.Type
|
||||
|
||||
export const Forked = Event.define({
|
||||
export const Forked = Event.durable({
|
||||
type: "session.next.forked",
|
||||
...options,
|
||||
schema: {
|
||||
|
|
@ -105,21 +105,21 @@ export const Forked = Event.define({
|
|||
})
|
||||
export type Forked = typeof Forked.Type
|
||||
|
||||
export const Prompted = Event.define({
|
||||
export const Prompted = Event.durable({
|
||||
type: "session.next.prompted",
|
||||
...options,
|
||||
schema: PromptFields,
|
||||
})
|
||||
export type Prompted = typeof Prompted.Type
|
||||
|
||||
export const PromptAdmitted = Event.define({
|
||||
export const PromptAdmitted = Event.durable({
|
||||
type: "session.next.prompt.admitted",
|
||||
...options,
|
||||
schema: PromptFields,
|
||||
})
|
||||
export type PromptAdmitted = typeof PromptAdmitted.Type
|
||||
|
||||
export const ExecutionSettled = Event.define({
|
||||
export const ExecutionSettled = Event.ephemeral({
|
||||
type: "session.next.execution.settled",
|
||||
schema: {
|
||||
...Base,
|
||||
|
|
@ -129,7 +129,7 @@ export const ExecutionSettled = Event.define({
|
|||
})
|
||||
export type ExecutionSettled = typeof ExecutionSettled.Type
|
||||
|
||||
export const ContextUpdated = Event.define({
|
||||
export const ContextUpdated = Event.durable({
|
||||
type: "session.next.context.updated",
|
||||
...options,
|
||||
schema: {
|
||||
|
|
@ -140,7 +140,7 @@ export const ContextUpdated = Event.define({
|
|||
})
|
||||
export type ContextUpdated = typeof ContextUpdated.Type
|
||||
|
||||
export const Synthetic = Event.define({
|
||||
export const Synthetic = Event.durable({
|
||||
type: "session.next.synthetic",
|
||||
...options,
|
||||
schema: {
|
||||
|
|
@ -154,7 +154,7 @@ export const Synthetic = Event.define({
|
|||
export type Synthetic = typeof Synthetic.Type
|
||||
|
||||
export namespace Skill {
|
||||
export const Activated = Event.define({
|
||||
export const Activated = Event.durable({
|
||||
type: "session.next.skill.activated",
|
||||
...options,
|
||||
schema: {
|
||||
|
|
@ -168,7 +168,7 @@ export namespace Skill {
|
|||
}
|
||||
|
||||
export namespace Shell {
|
||||
export const Started = Event.define({
|
||||
export const Started = Event.durable({
|
||||
type: "session.next.shell.started",
|
||||
...options,
|
||||
schema: {
|
||||
|
|
@ -180,7 +180,7 @@ export namespace Shell {
|
|||
})
|
||||
export type Started = typeof Started.Type
|
||||
|
||||
export const Ended = Event.define({
|
||||
export const Ended = Event.durable({
|
||||
type: "session.next.shell.ended",
|
||||
...options,
|
||||
schema: {
|
||||
|
|
@ -193,7 +193,7 @@ export namespace Shell {
|
|||
}
|
||||
|
||||
export namespace Step {
|
||||
export const Started = Event.define({
|
||||
export const Started = Event.durable({
|
||||
type: "session.next.step.started",
|
||||
...options,
|
||||
schema: {
|
||||
|
|
@ -206,7 +206,7 @@ export namespace Step {
|
|||
})
|
||||
export type Started = typeof Started.Type
|
||||
|
||||
export const Ended = Event.define({
|
||||
export const Ended = Event.durable({
|
||||
type: "session.next.step.ended",
|
||||
...stepSettlementOptions,
|
||||
schema: {
|
||||
|
|
@ -229,7 +229,7 @@ export namespace Step {
|
|||
})
|
||||
export type Ended = typeof Ended.Type
|
||||
|
||||
export const Failed = Event.define({
|
||||
export const Failed = Event.durable({
|
||||
type: "session.next.step.failed",
|
||||
...stepSettlementOptions,
|
||||
schema: {
|
||||
|
|
@ -242,7 +242,7 @@ export namespace Step {
|
|||
}
|
||||
|
||||
export namespace Text {
|
||||
export const Started = Event.define({
|
||||
export const Started = Event.durable({
|
||||
type: "session.next.text.started",
|
||||
...options,
|
||||
schema: {
|
||||
|
|
@ -254,7 +254,7 @@ export namespace Text {
|
|||
export type Started = typeof Started.Type
|
||||
|
||||
// Stream fragments are live-only; Text.Ended is the replayable full-value boundary.
|
||||
export const Delta = Event.define({
|
||||
export const Delta = Event.ephemeral({
|
||||
type: "session.next.text.delta",
|
||||
schema: {
|
||||
...Base,
|
||||
|
|
@ -265,7 +265,7 @@ export namespace Text {
|
|||
})
|
||||
export type Delta = typeof Delta.Type
|
||||
|
||||
export const Ended = Event.define({
|
||||
export const Ended = Event.durable({
|
||||
type: "session.next.text.ended",
|
||||
...options,
|
||||
schema: {
|
||||
|
|
@ -279,7 +279,7 @@ export namespace Text {
|
|||
}
|
||||
|
||||
export namespace Reasoning {
|
||||
export const Started = Event.define({
|
||||
export const Started = Event.durable({
|
||||
type: "session.next.reasoning.started",
|
||||
...options,
|
||||
schema: {
|
||||
|
|
@ -292,7 +292,7 @@ export namespace Reasoning {
|
|||
export type Started = typeof Started.Type
|
||||
|
||||
// Stream fragments are live-only; Reasoning.Ended is the replayable full-value boundary.
|
||||
export const Delta = Event.define({
|
||||
export const Delta = Event.ephemeral({
|
||||
type: "session.next.reasoning.delta",
|
||||
schema: {
|
||||
...Base,
|
||||
|
|
@ -303,7 +303,7 @@ export namespace Reasoning {
|
|||
})
|
||||
export type Delta = typeof Delta.Type
|
||||
|
||||
export const Ended = Event.define({
|
||||
export const Ended = Event.durable({
|
||||
type: "session.next.reasoning.ended",
|
||||
...options,
|
||||
schema: {
|
||||
|
|
@ -325,7 +325,7 @@ export namespace Tool {
|
|||
}
|
||||
|
||||
export namespace Input {
|
||||
export const Started = Event.define({
|
||||
export const Started = Event.durable({
|
||||
type: "session.next.tool.input.started",
|
||||
...options,
|
||||
schema: {
|
||||
|
|
@ -336,7 +336,7 @@ export namespace Tool {
|
|||
export type Started = typeof Started.Type
|
||||
|
||||
// Stream fragments are live-only; Input.Ended is the replayable raw-input boundary.
|
||||
export const Delta = Event.define({
|
||||
export const Delta = Event.ephemeral({
|
||||
type: "session.next.tool.input.delta",
|
||||
schema: {
|
||||
...ToolBase,
|
||||
|
|
@ -345,7 +345,7 @@ export namespace Tool {
|
|||
})
|
||||
export type Delta = typeof Delta.Type
|
||||
|
||||
export const Ended = Event.define({
|
||||
export const Ended = Event.durable({
|
||||
type: "session.next.tool.input.ended",
|
||||
...options,
|
||||
schema: {
|
||||
|
|
@ -356,7 +356,7 @@ export namespace Tool {
|
|||
export type Ended = typeof Ended.Type
|
||||
}
|
||||
|
||||
export const Called = Event.define({
|
||||
export const Called = Event.durable({
|
||||
type: "session.next.tool.called",
|
||||
...options,
|
||||
schema: {
|
||||
|
|
@ -375,7 +375,7 @@ export namespace Tool {
|
|||
* Replayable bounded running-tool state. Tools should checkpoint semantic
|
||||
* transitions or at a bounded cadence, not persist every stdout/stderr chunk.
|
||||
*/
|
||||
export const Progress = Event.define({
|
||||
export const Progress = Event.durable({
|
||||
type: "session.next.tool.progress",
|
||||
...options,
|
||||
schema: {
|
||||
|
|
@ -386,7 +386,7 @@ export namespace Tool {
|
|||
})
|
||||
export type Progress = typeof Progress.Type
|
||||
|
||||
export const Success = Event.define({
|
||||
export const Success = Event.durable({
|
||||
type: "session.next.tool.success",
|
||||
...options,
|
||||
schema: {
|
||||
|
|
@ -403,7 +403,7 @@ export namespace Tool {
|
|||
})
|
||||
export type Success = typeof Success.Type
|
||||
|
||||
export const Failed = Event.define({
|
||||
export const Failed = Event.durable({
|
||||
type: "session.next.tool.failed",
|
||||
...options,
|
||||
schema: {
|
||||
|
|
@ -431,7 +431,7 @@ export const RetryError = Schema.Struct({
|
|||
})
|
||||
export interface RetryError extends Schema.Schema.Type<typeof RetryError> {}
|
||||
|
||||
export const Retried = Event.define({
|
||||
export const Retried = Event.durable({
|
||||
type: "session.next.retried",
|
||||
...options,
|
||||
schema: {
|
||||
|
|
@ -443,7 +443,7 @@ export const Retried = Event.define({
|
|||
export type Retried = typeof Retried.Type
|
||||
|
||||
export namespace Compaction {
|
||||
export const Started = Event.define({
|
||||
export const Started = Event.durable({
|
||||
type: "session.next.compaction.started",
|
||||
...options,
|
||||
schema: {
|
||||
|
|
@ -454,7 +454,7 @@ export namespace Compaction {
|
|||
})
|
||||
export type Started = typeof Started.Type
|
||||
|
||||
export const Delta = Event.define({
|
||||
export const Delta = Event.ephemeral({
|
||||
type: "session.next.compaction.delta",
|
||||
schema: {
|
||||
...Base,
|
||||
|
|
@ -464,7 +464,7 @@ export namespace Compaction {
|
|||
})
|
||||
export type Delta = typeof Delta.Type
|
||||
|
||||
export const Ended = Event.define({
|
||||
export const Ended = Event.durable({
|
||||
type: "session.next.compaction.ended",
|
||||
...options,
|
||||
schema: {
|
||||
|
|
@ -479,53 +479,19 @@ export namespace Compaction {
|
|||
}
|
||||
|
||||
export namespace RevertEvent {
|
||||
export const Staged = Event.define({
|
||||
export const Staged = Event.durable({
|
||||
type: "session.next.revert.staged",
|
||||
...options,
|
||||
schema: { ...Base, revert: Revert.State },
|
||||
})
|
||||
export const Cleared = Event.define({ type: "session.next.revert.cleared", ...options, schema: Base })
|
||||
export const Committed = Event.define({
|
||||
export const Cleared = Event.durable({ type: "session.next.revert.cleared", ...options, schema: Base })
|
||||
export const Committed = Event.durable({
|
||||
type: "session.next.revert.committed",
|
||||
...options,
|
||||
schema: { ...Base, messageID: SessionMessage.ID },
|
||||
})
|
||||
}
|
||||
|
||||
export const DurableDefinitions = Event.inventory(
|
||||
AgentSwitched,
|
||||
ModelSwitched,
|
||||
Moved,
|
||||
Renamed,
|
||||
Forked,
|
||||
Prompted,
|
||||
PromptAdmitted,
|
||||
ContextUpdated,
|
||||
Synthetic,
|
||||
Skill.Activated,
|
||||
Shell.Started,
|
||||
Shell.Ended,
|
||||
Step.Started,
|
||||
Step.Ended,
|
||||
Step.Failed,
|
||||
Text.Started,
|
||||
Text.Ended,
|
||||
Tool.Input.Started,
|
||||
Tool.Input.Ended,
|
||||
Tool.Called,
|
||||
Tool.Progress,
|
||||
Tool.Success,
|
||||
Tool.Failed,
|
||||
Reasoning.Started,
|
||||
Reasoning.Ended,
|
||||
Retried,
|
||||
Compaction.Started,
|
||||
Compaction.Ended,
|
||||
RevertEvent.Staged,
|
||||
RevertEvent.Cleared,
|
||||
RevertEvent.Committed,
|
||||
)
|
||||
|
||||
export const Definitions = Event.inventory(
|
||||
AgentSwitched,
|
||||
ModelSwitched,
|
||||
|
|
@ -565,6 +531,10 @@ export const Definitions = Event.inventory(
|
|||
RevertEvent.Committed,
|
||||
)
|
||||
|
||||
export const DurableDefinitions = Event.inventory(
|
||||
...Definitions.filter((definition) => definition.durability === "durable"),
|
||||
)
|
||||
|
||||
export const Durable = Schema.Union(DurableDefinitions, { mode: "oneOf" })
|
||||
.pipe(Schema.toTaggedUnion("type"))
|
||||
.annotate({ identifier: "SessionDurableEvent" })
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ export const Info = Schema.Union([
|
|||
]).annotate({ identifier: "SessionStatus" })
|
||||
export type Info = Schema.Schema.Type<typeof Info>
|
||||
|
||||
export const Status = Event.define({
|
||||
export const Status = Event.ephemeral({
|
||||
type: "session.status",
|
||||
schema: {
|
||||
sessionID: SessionID,
|
||||
|
|
@ -41,7 +41,7 @@ export const Status = Event.define({
|
|||
})
|
||||
|
||||
// deprecated
|
||||
export const Idle = Event.define({
|
||||
export const Idle = Event.ephemeral({
|
||||
type: "session.idle",
|
||||
schema: {
|
||||
sessionID: SessionID,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
export * as SessionTodo from "./session-todo.js"
|
||||
|
||||
import { Schema } from "effect"
|
||||
import { define, inventory } from "./event.js"
|
||||
import { ephemeral, inventory } from "./event.js"
|
||||
import { SessionID } from "./session-id.js"
|
||||
|
||||
export const Info = Schema.Struct({
|
||||
|
|
@ -15,7 +15,7 @@ export const Info = Schema.Struct({
|
|||
}).annotate({ identifier: "Todo" })
|
||||
export interface Info extends Schema.Schema.Type<typeof Info> {}
|
||||
|
||||
const Updated = define({
|
||||
const Updated = ephemeral({
|
||||
type: "todo.updated",
|
||||
schema: {
|
||||
sessionID: SessionID,
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ export * as Shell from "./shell.js"
|
|||
|
||||
import { Schema } from "effect"
|
||||
import { optional } from "./schema.js"
|
||||
import { define, inventory } from "./event.js"
|
||||
import { ephemeral, inventory } from "./event.js"
|
||||
import { ascending } from "./identifier.js"
|
||||
import { NonNegativeInt, statics } from "./schema.js"
|
||||
|
||||
|
|
@ -49,9 +49,9 @@ export const Info = Schema.Struct({
|
|||
}).annotate({ identifier: "Shell" })
|
||||
export interface Info extends Schema.Schema.Type<typeof Info> {}
|
||||
|
||||
const Created = define({ type: "shell.created", schema: { info: Info } })
|
||||
const Exited = define({ type: "shell.exited", schema: { id: ID, exit: optional(Schema.Number), status: Status } })
|
||||
const Deleted = define({ type: "shell.deleted", schema: { id: ID } })
|
||||
const Created = ephemeral({ type: "shell.created", schema: { info: Info } })
|
||||
const Exited = ephemeral({ type: "shell.exited", schema: { id: ID, exit: optional(Schema.Number), status: Status } })
|
||||
const Deleted = ephemeral({ type: "shell.deleted", schema: { id: ID } })
|
||||
export const Event = { Created, Exited, Deleted, Definitions: inventory(Created, Exited, Deleted) }
|
||||
|
||||
export const CreateInput = Schema.Struct({
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ export * as Skill from "./skill.js"
|
|||
import { Schema } from "effect"
|
||||
import { optional } from "./schema.js"
|
||||
import { AbsolutePath } from "./schema.js"
|
||||
import { define, inventory } from "./event.js"
|
||||
import { ephemeral, inventory } from "./event.js"
|
||||
|
||||
export interface DirectorySource extends Schema.Schema.Type<typeof DirectorySource> {}
|
||||
export const DirectorySource = Schema.Struct({
|
||||
|
|
@ -27,7 +27,7 @@ export const Info = Schema.Struct({
|
|||
content: Schema.String,
|
||||
}).annotate({ identifier: "SkillV2.Info" })
|
||||
|
||||
const Updated = define({ type: "skill.updated", schema: {} })
|
||||
const Updated = ephemeral({ type: "skill.updated", schema: {} })
|
||||
export const Event = { Updated, Definitions: inventory(Updated) }
|
||||
|
||||
export interface EmbeddedSource extends Schema.Schema.Type<typeof EmbeddedSource> {}
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@ import { SessionID } from "./session-id.js"
|
|||
|
||||
const DEFAULT_TOAST_DURATION = 5000
|
||||
|
||||
export const PromptAppend = Event.define({ type: "tui.prompt.append", schema: { text: Schema.String } })
|
||||
export const PromptAppend = Event.ephemeral({ type: "tui.prompt.append", schema: { text: Schema.String } })
|
||||
|
||||
export const CommandExecute = Event.define({
|
||||
export const CommandExecute = Event.ephemeral({
|
||||
type: "tui.command.execute",
|
||||
schema: {
|
||||
command: Schema.Union([
|
||||
|
|
@ -38,7 +38,7 @@ export const CommandExecute = Event.define({
|
|||
},
|
||||
})
|
||||
|
||||
export const ToastShow = Event.define({
|
||||
export const ToastShow = Event.ephemeral({
|
||||
type: "tui.toast.show",
|
||||
schema: {
|
||||
title: optional(Schema.String),
|
||||
|
|
@ -50,7 +50,7 @@ export const ToastShow = Event.define({
|
|||
},
|
||||
})
|
||||
|
||||
export const SessionSelect = Event.define({
|
||||
export const SessionSelect = Event.ephemeral({
|
||||
type: "tui.session.select",
|
||||
schema: {
|
||||
sessionID: SessionID.annotate({ description: "Session ID to navigate to" }),
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
export * as LegacyEvent from "./legacy-event.js"
|
||||
|
||||
import { Schema } from "effect"
|
||||
import { define, inventory } from "../event.js"
|
||||
import { ephemeral, inventory } from "../event.js"
|
||||
import { SessionID } from "../session-id.js"
|
||||
import { SessionV1 } from "./session.js"
|
||||
|
||||
export const CommandExecuted = define({
|
||||
export const CommandExecuted = ephemeral({
|
||||
type: "command.executed",
|
||||
schema: {
|
||||
name: Schema.String,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
export * as PermissionV1 from "./permission.js"
|
||||
|
||||
import { Schema } from "effect"
|
||||
import { define, inventory } from "../event.js"
|
||||
import { ephemeral, inventory } from "../event.js"
|
||||
import { ascending } from "../identifier.js"
|
||||
import { Project } from "../project.js"
|
||||
import { statics } from "../schema.js"
|
||||
|
|
@ -58,8 +58,8 @@ export const ReplyInput = Schema.Struct({ requestID: ID, ...ReplyBody.fields }).
|
|||
})
|
||||
export type ReplyInput = typeof ReplyInput.Type
|
||||
|
||||
const Asked = define({ type: "permission.asked", schema: Request.fields })
|
||||
const Replied = define({
|
||||
const Asked = ephemeral({ type: "permission.asked", schema: Request.fields })
|
||||
const Replied = ephemeral({
|
||||
type: "permission.replied",
|
||||
schema: { sessionID: SessionID, requestID: ID, reply: Reply },
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
export * as QuestionV1 from "./question.js"
|
||||
|
||||
import { Schema } from "effect"
|
||||
import { define, inventory } from "../event.js"
|
||||
import { ephemeral, inventory } from "../event.js"
|
||||
import { ascending } from "../identifier.js"
|
||||
import { statics } from "../schema.js"
|
||||
import { SessionID } from "../session-id.js"
|
||||
|
|
@ -55,9 +55,9 @@ export const Rejected = Schema.Struct({ sessionID: SessionID, requestID: ID }).a
|
|||
identifier: "QuestionRejected",
|
||||
})
|
||||
|
||||
const Asked = define({ type: "question.asked", schema: Request.fields })
|
||||
const RepliedEvent = define({ type: "question.replied", schema: Replied.fields })
|
||||
const RejectedEvent = define({ type: "question.rejected", schema: Rejected.fields })
|
||||
const Asked = ephemeral({ type: "question.asked", schema: Request.fields })
|
||||
const RepliedEvent = ephemeral({ type: "question.replied", schema: Replied.fields })
|
||||
const RejectedEvent = ephemeral({ type: "question.rejected", schema: Rejected.fields })
|
||||
export const Event = {
|
||||
Asked,
|
||||
Replied: RepliedEvent,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
export * as SessionV1 from "./session.js"
|
||||
|
||||
import { Effect, Schema, Types } from "effect"
|
||||
import { define, inventory } from "../event.js"
|
||||
import { durable, ephemeral, inventory } from "../event.js"
|
||||
import { FileDiff } from "../file-diff.js"
|
||||
import { Project } from "../project.js"
|
||||
import { Provider } from "../provider.js"
|
||||
|
|
@ -569,7 +569,7 @@ export const SessionInfo = Schema.Struct({
|
|||
export type SessionInfo = typeof SessionInfo.Type
|
||||
|
||||
const events = {
|
||||
Created: define({
|
||||
Created: durable({
|
||||
type: "session.created",
|
||||
...options,
|
||||
schema: {
|
||||
|
|
@ -577,7 +577,7 @@ const events = {
|
|||
info: SessionInfo,
|
||||
},
|
||||
}),
|
||||
Updated: define({
|
||||
Updated: durable({
|
||||
type: "session.updated",
|
||||
...options,
|
||||
schema: {
|
||||
|
|
@ -585,7 +585,7 @@ const events = {
|
|||
info: SessionInfo,
|
||||
},
|
||||
}),
|
||||
Deleted: define({
|
||||
Deleted: durable({
|
||||
type: "session.deleted",
|
||||
...options,
|
||||
schema: {
|
||||
|
|
@ -593,7 +593,7 @@ const events = {
|
|||
info: SessionInfo,
|
||||
},
|
||||
}),
|
||||
MessageUpdated: define({
|
||||
MessageUpdated: durable({
|
||||
type: "message.updated",
|
||||
...options,
|
||||
schema: {
|
||||
|
|
@ -601,7 +601,7 @@ const events = {
|
|||
info: Info,
|
||||
},
|
||||
}),
|
||||
MessageRemoved: define({
|
||||
MessageRemoved: durable({
|
||||
type: "message.removed",
|
||||
...options,
|
||||
schema: {
|
||||
|
|
@ -609,7 +609,7 @@ const events = {
|
|||
messageID: MessageID,
|
||||
},
|
||||
}),
|
||||
PartUpdated: define({
|
||||
PartUpdated: durable({
|
||||
type: "message.part.updated",
|
||||
...options,
|
||||
schema: {
|
||||
|
|
@ -618,7 +618,7 @@ const events = {
|
|||
time: Schema.Finite,
|
||||
},
|
||||
}),
|
||||
PartRemoved: define({
|
||||
PartRemoved: durable({
|
||||
type: "message.part.removed",
|
||||
...options,
|
||||
schema: {
|
||||
|
|
@ -629,7 +629,7 @@ const events = {
|
|||
}),
|
||||
}
|
||||
|
||||
export const PartDelta = define({
|
||||
export const PartDelta = ephemeral({
|
||||
type: "message.part.delta",
|
||||
schema: {
|
||||
sessionID: SessionID,
|
||||
|
|
@ -640,7 +640,7 @@ export const PartDelta = define({
|
|||
},
|
||||
})
|
||||
|
||||
export const Diff = define({
|
||||
export const Diff = ephemeral({
|
||||
type: "session.diff",
|
||||
schema: {
|
||||
sessionID: SessionID,
|
||||
|
|
@ -648,7 +648,7 @@ export const Diff = define({
|
|||
},
|
||||
})
|
||||
|
||||
export const Error = define({
|
||||
export const Error = ephemeral({
|
||||
type: "session.error",
|
||||
schema: {
|
||||
sessionID: Schema.optional(SessionID),
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { Schema } from "effect"
|
|||
import { optional } from "./schema.js"
|
||||
import { Event } from "./event.js"
|
||||
|
||||
export const BranchUpdated = Event.define({
|
||||
export const BranchUpdated = Event.ephemeral({
|
||||
type: "vcs.branch.updated",
|
||||
schema: {
|
||||
branch: optional(Schema.String),
|
||||
|
|
|
|||
|
|
@ -10,21 +10,21 @@ export const ConnectionStatus = Schema.Struct({
|
|||
}).annotate({ identifier: "WorkspaceEvent.ConnectionStatus" })
|
||||
export interface ConnectionStatus extends Schema.Schema.Type<typeof ConnectionStatus> {}
|
||||
|
||||
export const Ready = Event.define({
|
||||
export const Ready = Event.ephemeral({
|
||||
type: "workspace.ready",
|
||||
schema: {
|
||||
name: Schema.String,
|
||||
},
|
||||
})
|
||||
|
||||
export const Failed = Event.define({
|
||||
export const Failed = Event.ephemeral({
|
||||
type: "workspace.failed",
|
||||
schema: {
|
||||
message: Schema.String,
|
||||
},
|
||||
})
|
||||
|
||||
export const Status = Event.define({
|
||||
export const Status = Event.ephemeral({
|
||||
type: "workspace.status",
|
||||
schema: ConnectionStatus.fields,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import { Schema } from "effect"
|
|||
import { optional } from "./schema.js"
|
||||
import { Event } from "./event.js"
|
||||
|
||||
export const Ready = Event.define({
|
||||
export const Ready = Event.ephemeral({
|
||||
type: "worktree.ready",
|
||||
schema: {
|
||||
name: Schema.String,
|
||||
|
|
@ -12,7 +12,7 @@ export const Ready = Event.define({
|
|||
},
|
||||
})
|
||||
|
||||
export const Failed = Event.define({
|
||||
export const Failed = Event.ephemeral({
|
||||
type: "worktree.failed",
|
||||
schema: {
|
||||
message: Schema.String,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue