|
|
@@ -97,14 +97,14 @@ export interface Interface {
|
|
|
time: number
|
|
|
direction: "previous" | "next"
|
|
|
}
|
|
|
- }) => Effect.Effect<SessionMessage.Message[], never>
|
|
|
- readonly context: (sessionID: SessionID) => Effect.Effect<SessionMessage.Message[], never>
|
|
|
+ }) => Effect.Effect<SessionMessage.Message[], NotFoundError>
|
|
|
+ readonly context: (sessionID: SessionID) => Effect.Effect<SessionMessage.Message[], NotFoundError>
|
|
|
readonly prompt: (input: {
|
|
|
id?: EventV2.ID
|
|
|
sessionID: SessionID
|
|
|
prompt: Prompt
|
|
|
delivery?: Delivery
|
|
|
- }) => Effect.Effect<SessionMessage.User, never>
|
|
|
+ }) => Effect.Effect<SessionMessage.User, NotFoundError>
|
|
|
readonly shell: (input: { id?: EventV2.ID; sessionID: SessionID; command: string }) => Effect.Effect<void, never>
|
|
|
readonly skill: (input: { id?: EventV2.ID; sessionID: SessionID; skill: string }) => Effect.Effect<void, never>
|
|
|
readonly subagent: (input: {
|
|
|
@@ -116,8 +116,8 @@ export interface Interface {
|
|
|
}) => Effect.Effect<void, NotFoundError>
|
|
|
readonly switchAgent: (input: { sessionID: SessionID; agent: string }) => Effect.Effect<void, never>
|
|
|
readonly switchModel: (input: { sessionID: SessionID; model: ModelV2.Ref }) => Effect.Effect<void, never>
|
|
|
- readonly compact: (sessionID: SessionID) => Effect.Effect<void, never>
|
|
|
- readonly wait: (sessionID: SessionID) => Effect.Effect<void, never>
|
|
|
+ readonly compact: (sessionID: SessionID) => Effect.Effect<void, NotFoundError>
|
|
|
+ readonly wait: (sessionID: SessionID) => Effect.Effect<void, NotFoundError>
|
|
|
}
|
|
|
|
|
|
export class Service extends Context.Service<Service, Interface>()("@opencode/v2/Session") {}
|
|
|
@@ -216,6 +216,7 @@ export const layer = Layer.effect(
|
|
|
return (direction === "previous" ? rows.toReversed() : rows).map((row) => fromRow(row))
|
|
|
}),
|
|
|
messages: Effect.fn("V2Session.messages")(function* (input) {
|
|
|
+ yield* result.get(input.sessionID)
|
|
|
const direction = input.cursor?.direction ?? "next"
|
|
|
let order = input.order ?? "desc"
|
|
|
// Query the adjacent rows in reverse, then flip them back into the requested order below.
|
|
|
@@ -257,6 +258,7 @@ export const layer = Layer.effect(
|
|
|
return rows.map((row) => decode(row))
|
|
|
}),
|
|
|
context: Effect.fn("V2Session.context")(function* (sessionID) {
|
|
|
+ yield* result.get(sessionID)
|
|
|
const rows = Database.use((db) => {
|
|
|
const compaction = db
|
|
|
.select()
|
|
|
@@ -288,7 +290,8 @@ export const layer = Layer.effect(
|
|
|
})
|
|
|
return rows.map((row) => decode(row))
|
|
|
}),
|
|
|
- prompt: Effect.fn("V2Session.prompt")(function* (_input) {
|
|
|
+ prompt: Effect.fn("V2Session.prompt")(function* (input) {
|
|
|
+ yield* result.get(input.sessionID)
|
|
|
return {} as any
|
|
|
}),
|
|
|
shell: Effect.fn("V2Session.shell")(function* (_input) {}),
|
|
|
@@ -328,8 +331,12 @@ export const layer = Layer.effect(
|
|
|
if (!text) return
|
|
|
}).pipe(Effect.forkChild())
|
|
|
}),
|
|
|
- compact: Effect.fn("V2Session.compact")(function* (_sessionID) {}),
|
|
|
- wait: Effect.fn("V2Session.wait")(function* (_sessionID) {}),
|
|
|
+ compact: Effect.fn("V2Session.compact")(function* (sessionID) {
|
|
|
+ yield* result.get(sessionID)
|
|
|
+ }),
|
|
|
+ wait: Effect.fn("V2Session.wait")(function* (sessionID) {
|
|
|
+ yield* result.get(sessionID)
|
|
|
+ }),
|
|
|
})
|
|
|
|
|
|
return result
|