@@ -2,12 +2,12 @@ import { BusEvent } from "@/bus/bus-event"
22import { Bus } from "@/bus"
33import { type IPty } from "bun-pty"
44import z from "zod"
5- import { Identifier } from "../id/id"
65import { Log } from "../util/log"
76import { Instance } from "../project/instance"
87import { lazy } from "@opencode-ai/util/lazy"
98import { Shell } from "@/shell/shell"
109import { Plugin } from "@/plugin"
10+ import { PtyID } from "./schema"
1111
1212export namespace Pty {
1313 const log = Log . create ( { service : "pty" } )
@@ -40,7 +40,7 @@ export namespace Pty {
4040
4141 export const Info = z
4242 . object ( {
43- id : Identifier . schema ( "pty" ) ,
43+ id : PtyID . zod ,
4444 title : z . string ( ) ,
4545 command : z . string ( ) ,
4646 args : z . array ( z . string ( ) ) ,
@@ -77,8 +77,8 @@ export namespace Pty {
7777 export const Event = {
7878 Created : BusEvent . define ( "pty.created" , z . object ( { info : Info } ) ) ,
7979 Updated : BusEvent . define ( "pty.updated" , z . object ( { info : Info } ) ) ,
80- Exited : BusEvent . define ( "pty.exited" , z . object ( { id : Identifier . schema ( "pty" ) , exitCode : z . number ( ) } ) ) ,
81- Deleted : BusEvent . define ( "pty.deleted" , z . object ( { id : Identifier . schema ( "pty" ) } ) ) ,
80+ Exited : BusEvent . define ( "pty.exited" , z . object ( { id : PtyID . zod , exitCode : z . number ( ) } ) ) ,
81+ Deleted : BusEvent . define ( "pty.deleted" , z . object ( { id : PtyID . zod } ) ) ,
8282 }
8383
8484 interface ActiveSession {
@@ -118,7 +118,7 @@ export namespace Pty {
118118 }
119119
120120 export async function create ( input : CreateInput ) {
121- const id = Identifier . create ( "pty" , false )
121+ const id = PtyID . ascending ( )
122122 const command = input . command || Shell . preferred ( )
123123 const args = input . args || [ ]
124124 if ( command . endsWith ( "sh" ) ) {
@@ -234,7 +234,7 @@ export namespace Pty {
234234 }
235235 }
236236 session . subscribers . clear ( )
237- Bus . publish ( Event . Deleted , { id } )
237+ Bus . publish ( Event . Deleted , { id : session . info . id } )
238238 }
239239
240240 export function resize ( id : string , cols : number , rows : number ) {
0 commit comments