mirror of
https://github.com/anomalyco/opencode.git
synced 2026-08-27 22:10:11 -04:00
69 lines
1.8 KiB
TypeScript
69 lines
1.8 KiB
TypeScript
import type { SessionApi } from "@opencode-ai/client/effect/api"
|
|
import type { GenerationOptionsFields, Message, SystemPart } from "@opencode-ai/ai"
|
|
import type { Agent } from "@opencode-ai/schema/agent"
|
|
import type { Model } from "@opencode-ai/schema/model"
|
|
import type { Session } from "@opencode-ai/schema/session"
|
|
import type { JsonSchema, Types } from "effect"
|
|
import type { ModelHooks } from "./registration.js"
|
|
|
|
export interface SessionContext {
|
|
readonly sessionID: Session.ID
|
|
readonly agent: Agent.ID
|
|
readonly model: Model.Ref
|
|
system: Array<SystemPart>
|
|
messages: Array<Message>
|
|
tools: Record<string, { description: string; input: JsonSchema.JsonSchema }>
|
|
/** Request overrides; unset fields retain route and model defaults. */
|
|
generation: Types.DeepMutable<GenerationOptionsFields>
|
|
providerOptions: Record<string, unknown>
|
|
}
|
|
|
|
export interface SessionModelRequest {
|
|
readonly sessionID: Session.ID
|
|
readonly agent: Agent.ID
|
|
readonly model: Model.Ref
|
|
baseURL?: string
|
|
headers: Record<string, string>
|
|
}
|
|
|
|
export interface SessionHttpRequest {
|
|
readonly sessionID: Session.ID
|
|
readonly agent: Agent.ID
|
|
readonly model: Model.Ref
|
|
request: Request
|
|
}
|
|
|
|
export interface SessionHttpResponse {
|
|
readonly sessionID: Session.ID
|
|
readonly agent: Agent.ID
|
|
readonly model: Model.Ref
|
|
readonly request: Request
|
|
response: Response
|
|
}
|
|
|
|
export interface SessionHooks {
|
|
readonly context: SessionContext
|
|
readonly "model.request": SessionModelRequest
|
|
readonly "http.request": SessionHttpRequest
|
|
readonly "http.response": SessionHttpResponse
|
|
}
|
|
|
|
export type SessionDomain = Pick<
|
|
SessionApi<unknown>,
|
|
| "create"
|
|
| "get"
|
|
| "switchAgent"
|
|
| "switchModel"
|
|
| "prompt"
|
|
| "generate"
|
|
| "command"
|
|
| "synthetic"
|
|
| "interrupt"
|
|
| "rename"
|
|
| "move"
|
|
| "wait"
|
|
| "context"
|
|
> & {
|
|
readonly hook: ModelHooks<SessionHooks>
|
|
}
|