Dashboard › opencode › Distillation
09f8b3ca-53bf-49e9-b8fe-69d2c04fe63e["lore_tm_v1_Pgk2qmpolJS-ZWlMZcEG1B96wgWa1cbzgv1m7x9WLgA","lore_tm_v1_RYZeopsdj6HcOmhLf6VfDLlwiuPtP0vHK9x9KGq6ndU","lore_tm_v1_A8fHQCCtQr9xt06WM8XPAbeI4rj20VlD5MmYe7hbS6g","lore_tm_v1_7ZcIGnhQgxUoiLjML2qpRNmc45Tdj-GwHGuBnFFDWLQ","lore_tm_v1_chdxdVEoPZtHm98A-OJj0aHW75cD52Rcba2UchQzAso","lore_tm_v1_EZujBZANCM1T3mVtpLIGmVL1xUFGIfs803ZHh_E7seg"]
Date: Sep 8, 2026
/home/byk/Code/opencode-v2-pilot/packages/core/src/session/runner/to-llm-message.ts:230-280 converts location-switched into a user message stating the new directory; converts user messages into skill text, nonempty message text, and attachments while preserving metadata and nonempty agents; drops empty user content; converts synthetic into a user message containing message.text without metadata; converts skill into a user message with metadata; and converts system through Message.system(message.text)./home/byk/Code/opencode-v2-pilot/packages/core/src/session/runner/to-llm-message.ts:263-280 omits shell messages whose message.metadata?.background === true, because background shell results enter context through their completion inbox item. Foreground shell messages become user messages containing the exact command and message.output?.output ?? ""; completed compactions replay decoded provider context when SessionProviderContext.isCheckpoint(message), while incomplete compactions are omitted./home/byk/Code/opencode-v2-pilot/packages/core/src/tool.ts:21-60 defines RegistrationError with name and message; mutable Editor operations list, get, namespace, add, update, and remove; tool state containing tools, namespaces, and registration errors; NormalizedResult with normalized ReadonlyArray<Tool.Content>; and Snapshot with definitions, optional codeModeCatalog, and execute(...). Snapshot.execute accepts sessionID, agent, messageID, ToolCall, optional progress, and optional surviving request definitions keyed by advertised names./home/byk/Code/opencode-v2-pilot/packages/core/src/tool.ts:72-100 implements normalizeImages: only base64 data-URI image file content is passed to image.normalize; successful normalization replaces URI/content and MIME; Image.ResizerUnavailableError preserves the original image; Image.DecodeError and Image.SizeError omit affected images and append counted text notices respectively saying they “could not be decoded.” or “could not be resized below the image size limit.”/home/byk/Code/opencode-v2-pilot/packages/core/src/tool.ts:102-154 triggers tool.execute.before with tool name, sessionID, agent, messageID, call ID, and input. executeTool runs the tool, catches Tool.Error, triggers tool.execute.after with status: "error" and a mutable error on failure or status: "completed" and a mutable result on success, then normalizes result content and images while preserving optional output and metadata./home/byk/Code/opencode-v2-pilot/packages/core/src/tool.ts:157-215 stores tools and namespaces through State.create under the name "tool". Invalid namespace/tool registrations are accumulated and later logged as Skipping invalid ${kind} registration; update preserves the original tool name, id, and namespace; remove deletes by ID./home/byk/Code/opencode-v2-pilot/packages/core/src/tool.ts:220-269 builds permission-filtered tool snapshots: tools wholly denied by the last matching wildcard rule with resource === "*" and effect === "deny" are excluded; tools with options.codemode === false are exposed directly; remaining tools form the CodeMode inventory; and the synthetic execute tool/catalog exists unless permission action "execute" is wholly disabled. Direct definitions are sorted lexicographically before the optional CodeMode definition./home/byk/Code/opencode-v2-pilot/packages/core/src/tool.ts:249-267 executes a requested tool only after beforeExecute may repair or alias its name/input. If request-scoped definitions removed a direct tool or CodeMode execute, execution fails with Tool is not available for this request: ${event.tool}; aliases resolve via requested?.name; CodeMode dispatches when the resolved name is "execute"; unresolved names fail with Unknown tool: ${name}./home/byk/Code/opencode-v2-pilot/packages/core/src/tool.ts:276-315 validates tool registration names against /^[A-Za-z0-9_-]{1,64}$/; validates each namespace segment with the same pattern; reserves the effective name "execute" for CodeMode when tool.options?.codemode === false; validates generated definitions with ToolDefinition.make(definition(tool)); and exposes a location node depending on PluginHooks.node and Image.node./home/byk/Code/opencode-v2-pilot/packages/core/src/tool/runtime.ts:9-26 caches up to 100 conversions from JSON Schema to Effect codecs, treating conversion failures as unavailable. definition(tool) emits a tool definition with effectiveName(tool), description, input JSON Schema, and an output JSON Schema only when tool.output is defined./home/byk/Code/opencode-v2-pilot/packages/core/src/tool/runtime.ts:28-60 enforces tool execution contracts at the plugin boundary: input is decoded first; foreign typed failures are converted into Tool.Error, while defects/declines and interrupts are untouched. A tool without an output schema defects if it returns output; a tool with an output schema returns Tool.Error("Tool did not return its declared output") when output is absent; declared output is encoded/validated before normalized content and optional metadata are returned./home/byk/Code/opencode-v2-pilot/packages/core/src/tool/runtime.ts:62-99 validates Standard Schema directly, Effect Schema directly, and raw JSON Schema through the cached codec; an unconvertible JSON Schema passes input through unchanged. Invalid arguments report at most the first 5 issues with dotted/indexed paths, append an exact remaining-issue count, include pretty-printed supplied JSON, and instruct the caller to update arguments and call the tool again./home/byk/Code/opencode-v2-pilot/packages/core/src/tool/runtime.ts:101-131 detects draft-07 JSON Schema when $schema contains "draft-07" or the document has definitions; otherwise it uses draft 2020-12. Output validation uses Schema.encodeEffect for Effect schemas, Standard Schema validation for standard schemas, and Schema.Json decoding for raw JSON schemas, with distinct errors for invalid output-schema values and non-JSON values./home/byk/Code/opencode-v2-pilot/packages/core/src/tool/runtime.ts:134-169 recognizes Standard Schema through a non-null object’s "~standard" property and Standard JSON Schema through "jsonSchema" in schema["~standard"]. Input schemas may be absent and then emit {}; Standard JSON Schema conversion targets "draft-2020-12" with io: "input" or "output"; Zod v4 $ZodType uses toJSONSchema; unsupported vendors throw Schema vendor "${vendor}" does not support JSON Schema conversion./home/byk/Code/opencode-v2-pilot/packages/core/src/tool/runtime.ts:172-180 begins normalization of Effect-generated JSON Schema to improve inference-provider compatibility: safe allOf constraints are flattened when no keyword would be overwritten, acyclic local $ref values are inlined, unused $defs are removed, and recursive references remain intact to avoid nonterminating expansion.