feat(pty): expose shells and connect tokens

This commit is contained in:
Brendan Allan 2026-07-21 19:02:12 +08:00
commit dbe7b937ef
No known key found for this signature in database
GPG key ID: 41E835AEA046A32E
6 changed files with 50 additions and 4 deletions

View file

@ -78,6 +78,7 @@ export class ExitedError extends Schema.TaggedErrorClass<ExitedError>()("Pty.Exi
}) {}
export interface Interface {
readonly shells: () => Effect.Effect<ReadonlyArray<Pty.Shell>>
readonly list: () => Effect.Effect<Info[]>
readonly get: (id: PtyID) => Effect.Effect<Info, NotFoundError>
readonly create: (input: CreateInput) => Effect.Effect<Info>
@ -158,6 +159,10 @@ export const layer = (options?: ShellSelect.Options) => Layer.effect(
return Array.from(sessions.values()).map((session) => session.info)
})
const shells = Effect.fn("Pty.shells")(function* () {
return yield* Effect.promise(() => ShellSelect.list(options))
})
const get = Effect.fn("Pty.get")(function* (id: PtyID) {
return (yield* requireSession(id)).info
})
@ -309,7 +314,7 @@ export const layer = (options?: ShellSelect.Options) => Layer.effect(
}
})
return Service.of({ list, get, create, update, remove, write, attach })
return Service.of({ shells, list, get, create, update, remove, write, attach })
}),
)