Dashboard › opencode › Distillation
1a933a0e-c435-4d54-913e-e4a2c05ad041["lore_tm_v1_aEIDCi3AMkNhDJPUELu7nY3AmKX23BvQ9UUedDTIxTE","lore_tm_v1_9c10pa7Lq1bpCOnkfVE9pyfsxl8ChH9XQWcG8Dfqlwc","lore_tm_v1_eUTkTJwCa4FORFWjFh1cFTNv9Zlo0CmUxDrq8lGGPII","lore_tm_v1_jKUskjb9AQUUWSQucipzC-B042qHwSSvieB9W0RF24Y","lore_tm_v1_Qh3cCCDrMhgOqSVW84rjTOIwjRkOgjMJcLSVEFVUEDA","lore_tm_v1_ca3PVnSRbBeRpl6FVURfP-2tIt_VXy2t3T6__TA6Bho","lore_tm_v1_f3YzJV1NtBFDCDVYRculxY33V3zw-EK7EsPZ2rK0Ftk","lore_tm_v1_Je3dQ-sAH0wRqcFTMo5WhBUp_ClLx2moyB4mUJ6Oahk","lore_tm_v1_acMVE-EhTRqFzFlr7Xy-s61wY0hCROnOhcnukSvnSvE","lore_tm_v1_wbKFWkPdBWlL-N8_GMR5HzGOfBdNU4N9PMW7VMUDaV8","lore_tm_v1_FqORMKc9M-Vi0ceQTk5P9UgAqMcrlepZZuhSCLu9OeU","lore_tm_v1_KS2JOEq2IKTP1FaMV3K4rXzbeChbfcYaWc9aWS0uKSo","lore_tm_v1_RNJyvU1ByHlATmzToudy0o8vozAgGmQfxrnmn8GAiAw"]
/home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/session.ts (102 lines). It imports SessionApi, GenerationOptionsFields, Message, SystemPart, Agent, Model, PromptInput, Session, SessionInbox, SessionError, SessionMessage, JsonSchema, Types, and ModelHooks.SessionPrompt contains readonly sessionID: Session.ID, readonly messageID: SessionMessage.ID, mutable prompt: Types.DeepMutable<PromptInput.Prompt>, optional mutable metadata?: Record<string, unknown>, and mutable delivery: SessionInbox.Delivery.SessionContext contains readonly sessionID, agent, and model; mutable system: Array<SystemPart>, messages: Array<Message>, tools: Record<string, { description: string; input: JsonSchema.JsonSchema }>, generation: Types.DeepMutable<GenerationOptionsFields>, and providerOptions: Record<string, unknown>. Unset generation fields retain route and model defaults.SessionRequestKind is exactly "primary" | "compaction" | "title" | "generate"; auxiliary requests share the Session hook identity but are distinguished from the agent loop by this kind.SessionModelRequest contains readonly sessionID, agent, model, and kind, plus mutable optional baseURL?: string and mutable headers: Record<string, string>.SessionHttpRequest contains readonly sessionID, agent, model, and kind, plus mutable request: Request; SessionHttpResponse contains the same readonly identity and kind, readonly request: Request, and mutable response: Response.SessionRetryDecision is { retry: false } | { retry: true; delay: number }; SessionRetry contains readonly sessionID, agent, model, error: SessionError.Error, and attempt: number, with mutable decision: SessionRetryDecision.SessionHooks maps prompt, context, "model.request", "http.request", "http.response", and retry to their respective interfaces.SessionDomain picks create, get, switchAgent, switchModel, prompt, generate, command, synthetic, interrupt, rename, move, wait, and context from SessionApi, and adds readonly hook: ModelHooks<SessionHooks>./home/byk/Code/opencode-v2-pilot/packages/core/test/session-model-request-hooks.test.ts lines 47 and 52 register session hooks "http.request" and "http.response"; /home/byk/Code/opencode-v2-pilot/packages/core/test/plugin/provider-openai.test.ts line 47 triggers "model.request" and lines 59-60 check for "http.request"/"http.response"; /home/byk/Code/opencode-v2-pilot/packages/core/test/plugin/provider-github-copilot.test.ts lines 50 and 230 trigger "model.request" and line 155 triggers "http.request"; /home/byk/Code/opencode-v2-pilot/packages/core/test/plugin/provider-azure.test.ts lines 280 and 295 trigger "http.request" for Azure and Foundry; /home/byk/Code/opencode-v2-pilot/packages/core/test/session-title.test.ts line 276 registers "model.request"; /home/byk/Code/opencode-v2-pilot/packages/core/test/session-runner.test.ts lines 1517 and 2405 register "model.request"; /home/byk/Code/opencode-v2-pilot/packages/core/test/session-native-compaction.test.ts lines 188 and 403 register "model.request" and line 193 registers "http.request"./home/byk/Code/opencode-v2-pilot/packages/core/test/session-model-request-hooks.test.ts (80 lines). Its KINDS are ordered ["primary", "compaction", "title", "generate"]; fixture session ID is ses_hook_kind, project is Project.ID.global, cost and all token counts are zero, timestamps use DateTime.makeUnsafe(0), and location is /project.gpt-5.5 from provider test, with capabilities { tools: true, input: ["text"], output: ["text"] }, no costs, and limits { context: 200_000, output: 32_000 }; its transport dies with "unused WebSocket execution" if WebSocket execution occurs."tags every Session request kind on http.request and http.response" registers both hooks, prepares each of the 4 SessionRequestKind values with agent ID build, sends POST requests to https://example.test/v1/chat/completions, returns status 200, and expects alternating request/response observations for every kind with agent build./home/byk/Code/opencode-v2-pilot/packages/core/test/session-model-request.test.ts (114 lines), testing unsupportedParts and boundImages.unsupportedParts tests: unsupported user image/png file logo.png and application/pdf file document.pdf become visible ERROR: Cannot read ... (this model does not support image/pdf input). Inform the user. text; unsupported logo.png nested in tool read result call_1 is similarly replaced; supported image media is preserved when capabilities include ["text", "image"].boundImages tests: a small image remains unchanged and the original messages array is returned; three images of exactly 9 * 1024 * 1024 characters cause first.png and second.png to become text while retaining third.png; two tool-result images of exactly 13 * 1024 * 1024 characters cause first.png to become text while retaining second.png./home/byk/Code/opencode-v2-pilot/packages/core/src/session/model-request.ts: "model.request" at line 224, "http.request" at line 249, and "http.response" at line 261./home/byk/Code/opencode-v2-pilot/packages/core/src/session/model-request.ts:199-205 defines HookScope with readonly sessionID: SessionSchema.ID, agent: Agent.ID, model: Model.Ref, and kind: SessionRequestKind.sessionHeaders() emits "x-session-affinity", "X-Session-Id", optional "x-parent-session-id", "User-Agent", "x-opencode-project", "x-opencode-session", and "x-opencode-client" headers.promptCacheKey(sessionID) strips the ses_ prefix only when the ID matches /^ses_[0-9a-f]{64}$/; otherwise it returns the full session ID.applyModelHooks() triggers "session"/"model.request" with the hook scope, current string baseURL when available, and copied HTTP headers. If the hook changes baseURL, it updates the model route endpoint; it rebuilds HttpOptions, preserving body and query and omitting headers if the hook leaves an empty header object.httpMiddleware() exposes each exchange through web-standard Request/Response: it triggers "http.request", converts the returned request back to HttpClientRequest, clones and restores a request body as Uint8Array using its content-type, invokes the handler, then triggers "http.response". Response bodies are forced to null for statuses 204, 205, and 304; other response streams are converted with Stream.toReadableStreamEffect. The hook-modified response is converted back with HttpClientResponse.fromWeb(sent, after.response), and non-Error failures become new Error(String(cause)).SessionModelRequest.Interface.prepare(input) builds an outbound model request and matching tool-call capability without executing the request or mutating Session state; Service is registered as @opencode/SessionModelRequest.SessionModelRequest.prepare defaults missing tools to no definitions and an executor returning new Tool.Error({ message: "Tools are not available for this request" }).SessionModelRequest.prepare: a registry maps canonical tool names to tools; a given map relates mutable hook-facing definition objects to their tools; hooks may edit descriptions/schemas, rename by moving a definition to another key, or remove tools; identity matching wins over key matching; invented definitions matching neither identity nor key are dropped; canonical tool.name is preserved so renamed calls can be translated back during execution."session"/"context" hook receives session ID, contextAgentID ?? agentID, resolved model ref, transcript system/messages, mutable tool definitions, and initially empty generation and providerOptions; it is skipped only when input.contextHooks === false.input.scope.agentID and input.kind; sets session headers; derives the cache key from session.fork?.sessionID ?? session.id; uses context-hook-modified system/messages/tools; processes messages through boundImages(unsupportedParts(...)); and emits generation/providerOptions only when nonempty.Error("Provider context is incompatible with the route selected by model request hooks"). A TODO says to persist cache lineage so nested forks reuse the root sessionβs cache key.hooks.has("session", "http.request", resolved.ref.providerID) or hooks.has("session", "http.response", resolved.ref.providerID) succeeds. Responses WebSocket support additionally requires model capability responsesWebsockets === true and provider config flag responsesWebSocketFlag(providerID) defaulting to false; session WebSocket transport is used only when input.webSocket === "session", the flag is enabled, and no HTTP hooks are present.executeTool delegates to tools.execute({ ...input, definitions: hooked }) and converts defects recognized by declineDefect into failures; retry(event) triggers "session"/"retry" and discards the returned value. prepare returns { request, options, retry, executeTool }.SessionModelRequest location node depends on PluginHooks.node, SessionModelTransport.node, and App.node./home/byk/Code/opencode-v2-pilot/packages/plugin/test/host.test.ts (156 lines). Every fixture entrypoint contains throw new Error("Plugin code must not run during resolution"), ensuring Host.resolve only resolves paths and does not evaluate plugin code.Host.resolve test cases in /home/byk/Code/opencode-v2-pilot/packages/plugin/test/host.test.ts: (1) without package.json, conventional index.ts, tui.tsx, and rpc.ts resolve as server/TUI/RPC; (2) a TUI-only directory resolves only tui.tsx; (3) installed packages without exports use either default index.js or explicit main: "lib/backend.js", with tui.js and rpc.js; (4) a local package with package.json but no exports resolves conventional index.js, tui.js, and rpc.js; (5) explicit exports prefer "./server": "./dist/backend.js" over root ".", alongside "./tui" and "./rpc"; (6) when exports use conditions, import paths ./dist/server.mjs and ./dist/tui.mjs are preferred over require .cjs paths, with no RPC; (7) a TUI-only "./tui" export does not fall back to unexported index.js, server.js, or rpc.js; (8) an exported missing file yields { server: undefined, tui: undefined, rpc: undefined }.Host.resolve fixture creates temporary roots under opencode-host-, optionally installs at node_modules/@fixture/plugin, converts paths with pathToFileURL, and recursively removes the root through Symbol.asyncDispose./home/byk/Code/opencode-v2-pilot/packages/plugin/package.json for @opencode/plugin version 1.18.15, an MIT-licensed ESM package.@opencode/plugin scripts are "test": "bun test --only-failures", "typecheck": "tsgo --noEmit", and "build": "tsc -p tsconfig.build.json".@opencode/plugin exports "." as ./src/promise/index.ts, "./effect" as ./src/effect/index.ts, "./host" as ./src/host.ts, "./tui" as ./src/tui/index.ts, and "./*" as ./src/*.ts; #plugin-source maps Bun to ./src/source.bun.ts and Node/default to ./src/source.node.ts; published files are limited to dist.@opencode/plugin dependencies: @ai-sdk/provider 3.0.8; workspace packages @opencode/ai, @opencode/client, @opencode/protocol, @opencode/schema, and @opencode/util; catalog packages @standard-schema/spec, effect, and zod.@opencode/theme workspace:*, @opentui/core >=0.5.10, @opentui/solid >=0.5.10, and solid-js >=1.9.0. Dev dependencies include workspace @opencode/theme; catalog @opentui/core, @opentui/solid, @tsconfig/bun, @tsconfig/node22, @types/bun, @types/node, solid-js, typescript, and @typescript/native-preview./home/byk/Code/opencode-v2-pilot/packages/sdk/test/import-boundaries.test.ts, /home/byk/Code/opencode-v2-pilot/packages/session-ui/src/import-boundaries.test.ts, /home/byk/Code/opencode-v2-pilot/packages/server/test/session-import.test.ts, /home/byk/Code/opencode-v2-pilot/packages/ui/src/theme/v2/resolve.test.ts, /home/byk/Code/opencode-v2-pilot/packages/tui/test/theme/v2/resolve.test.ts, /home/byk/Code/opencode-v2-pilot/packages/client/test/import-boundaries.test.ts, /home/byk/Code/opencode-v2-pilot/packages/core/test/model-resolver.test.ts, /home/byk/Code/opencode-v2-pilot/packages/core/test/mcp-import-boundary.test.ts, /home/byk/Code/opencode-v2-pilot/packages/cli/test/import-export.test.ts, /home/byk/Code/opencode-v2-pilot/packages/cli/test/import-boundaries.test.ts, /home/byk/Code/opencode-v2-pilot/packages/app/test-browser/session-resolution.test.ts, /home/byk/Code/opencode-v2-pilot/packages/app/src/session/commands/export.test.ts, /home/byk/Code/opencode-v2-pilot/packages/app/src/session/session-resolution.test.ts, and /home/byk/Code/opencode-v2-pilot/packages/ai/test/exports.test.ts./home/byk/Code/opencode-lore/packages/opencode: package.json, tsconfig.json, tests test/index.test.ts, test/routing.e2e.test.ts, test/internal.test.ts, test/gateway-smoke.test.ts, test/subagent-detection.test.ts, test/tui-silence.test.ts, and test/session-state.test.ts; sources src/internal.ts and src/index.ts; script scripts/list-sessions.ts; evaluation files eval/session_eval.ts, eval/extract_session.ts, eval/coding_eval.ts, and eval/backfill.ts; data eval/data/coding_memory_eval.json, eval/data/sessions/cli-sentry-issue.json, eval/data/sessions/cli-nightly.json, and eval/data/coding_session_eval.json.