mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-09-19 01:51:21 +08:00
69 lines
2.3 KiB
TypeScript
69 lines
2.3 KiB
TypeScript
export * as Pty from "./pty"
|
|
|
|
import { Schema } from "effect"
|
|
import { optional } from "./schema"
|
|
import { define, inventory } from "./event"
|
|
import { ascending } from "./identifier"
|
|
import { SessionID } from "./session-id" // kilocode_change
|
|
import { NonNegativeInt, PositiveInt, statics } from "./schema"
|
|
|
|
const IDSchema = Schema.String.check(Schema.isStartsWith("pty")).pipe(Schema.brand("PtyID"))
|
|
|
|
export const ID = IDSchema.pipe(
|
|
statics((schema: typeof IDSchema) => {
|
|
const create = () => schema.make("pty_" + ascending())
|
|
return {
|
|
create,
|
|
ascending: (id?: string) => (id === undefined ? create() : schema.make(id)),
|
|
}
|
|
}),
|
|
)
|
|
export type ID = typeof ID.Type
|
|
|
|
export const Info = Schema.Struct({
|
|
id: ID,
|
|
title: Schema.String,
|
|
command: Schema.String,
|
|
args: Schema.Array(Schema.String),
|
|
cwd: Schema.String,
|
|
status: Schema.Literals(["running", "exited"]),
|
|
pid: NonNegativeInt,
|
|
exitCode: optional(NonNegativeInt),
|
|
sessionID: optional(Schema.NullOr(SessionID)), // kilocode_change - Kilo associates PTYs with sessions
|
|
}).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 } })
|
|
export const Event = { Created, Updated, Exited, Deleted, Definitions: inventory(Created, Updated, Exited, Deleted) }
|
|
|
|
export const CreateInput = Schema.Struct({
|
|
command: optional(Schema.String),
|
|
args: optional(Schema.Array(Schema.String)),
|
|
cwd: optional(Schema.String),
|
|
title: optional(Schema.String),
|
|
env: optional(Schema.Record(Schema.String, Schema.String)),
|
|
// kilocode_change start - spawn with initial terminal dimensions
|
|
size: optional(
|
|
Schema.Struct({
|
|
rows: PositiveInt,
|
|
cols: PositiveInt,
|
|
}),
|
|
),
|
|
// kilocode_change end
|
|
})
|
|
export interface CreateInput extends Schema.Schema.Type<typeof CreateInput> {}
|
|
|
|
export const UpdateInput = Schema.Struct({
|
|
title: optional(Schema.String),
|
|
size: optional(
|
|
Schema.Struct({
|
|
rows: PositiveInt,
|
|
cols: PositiveInt,
|
|
}),
|
|
),
|
|
})
|
|
export interface UpdateInput extends Schema.Schema.Type<typeof UpdateInput> {}
|