Dashboard › opencode › Distillation
c857640e-9bc6-4d9b-9921-07b33e152330["lore_tm_v1_J7CpVdrbxFtzfm-gDyjtwdxLZuXeK9vGPa50aNE-8tA"]
HttpOptions, LanguageModel, LLM, LLMRequest, Message, and SystemPart from @opencode/ai; StreamOptions from @opencode/ai/route; SessionRequestKind, Agent, Model, and Content; Effect primitives; HttpClientRequest/HttpClientResponse; makeLocationNode; App; and Permission."x-session-affinity": session.id, "X-Session-Id": session.id, conditional "x-parent-session-id": session.parentID, "User-Agent": App.useragent(app), "x-opencode-project": session.projectID, "x-opencode-session": session.id, and "x-opencode-client": app.name.promptCacheKey(sessionID: SessionSchema.ID) strips the ses_ prefix only when the session ID matches /^ses_[0-9a-f]{64}$/; otherwise it returns the session ID unchanged.applyModelHooks(hooks: PluginHooks.Interface, scope: HookScope, request: LLMRequest) triggers the "session" / "model.request" hook with the hook scope, the current route endpoint baseURL when it is a string, and a copy of request.http?.headers."model.request" hook returns a changed, defined baseURL, applyModelHooks() replaces the request route endpoint through request.model.route.with({ endpoint: { baseURL: event.baseURL } }); otherwise it retains the existing route and model.applyModelHooks() rebuilds request.http as new HttpOptions(...), preserving the prior body and query, using hook-returned headers, and setting headers to undefined when Object.keys(event.headers).length === 0.httpMiddleware(hooks, scope) implements NonNullable<StreamOptions["http"]> and exposes outbound HTTP exchanges to "session" / "http.request" and "session" / "http.response" hooks using web-standard Request and Response values.httpMiddleware() converts the Effect HTTP request with HttpClientRequest.toWeb(request), passes it through the "http.request" hook, and reconstructs it with HttpClientRequest.fromWeb(before.request).httpMiddleware() clones it, reads its arrayBuffer(), converts that to Uint8Array, and applies it via HttpClientRequest.bodyUint8Array(...), preserving the "content-type" header when present.httpMiddleware() invokes the "http.response" hook with the modified request and a web Response; response bodies are forced to null for HTTP statuses 204, 205, and 304, while other bodies use Stream.toReadableStreamEffect(response.stream).httpMiddleware() converts the hook-returned response back through HttpClientResponse.fromWeb(sent, after.response) and maps non-Error causes to new Error(String(cause)).Interface defines readonly prepare: (input: PrepareInput) => Effect.Effect<Prepared>; documentation states it builds one outbound model request paired with its matching tool-call capability, without executing the request or mutating Session state.Service is declared as Context.Service<Service, Interface>()("@opencode/SessionModelRequest"); its layer obtains PluginHooks.Service, SessionModelTransport.Service, and App.Metadata, and defines Effect.fn("SessionModelRequest.prepare").type === "compaction", preparation defects via Effect.die(new Error("Provider context is incompatible with the route selected by model request hooks")).prepare has no error channel, so provider-context incompatibility surfaces as a defect like hook failures.hasHttpHooks is true when either hooks.has("session", "http.request", resolved.ref.providerID) or hooks.has("session", "http.response", resolved.ref.providerID) succeeds.resolved.capabilities.responsesWebsockets === true and the provider-specific responsesWebSocketFlag(resolved.ref.providerID) configuration resolves true; the configuration defaults to false via Config.withDefault(false) and uses Effect.orDie.httpMiddleware(hooks, { sessionID: session.id, agent: input.scope.agentID, ... }), pairing the middleware scope with the current session and agent.