Dashboard › opencode › Distillation
d41ec21c-df04-4a34-bfda-dcf8bb93e7a3["lore_tm_v1_wnR48urWKhoqVdTPrTi-nFP8JtfTSIyn5NMVmFI5yq0","lore_tm_v1_yx2q0zClGN0FQKPuQydGhYpsqVc1IO6eZ2eq0qZnRUg","lore_tm_v1_uDQr8g5Ek6II3MRuhKTAwGpywq7osJ4z_xGoiAXE8eo","lore_tm_v1__36eIRvRg9ZWDaNS6je0SrG5I1nGPwSg-YcXHwuEg1E","lore_tm_v1_bURKNSdnlq88zGHsbY0OmWsl619mF9nry2aXO_A4fBE","lore_tm_v1_BJB8iCb-zUQRxMERvQ0D56pSuK8Mtyf-QfMW9riNItw","lore_tm_v1_H3-G_Wuz7HNwx5jC8QWCvqppsV0GTReozfYldxYsMWA","lore_tm_v1_swQFEUjwZUq52ECVrX-f3XfcDkM-rC1q-SsV2t_QS0g","lore_tm_v1_rNeqV3-Kwm--l_IU2z3etBVNEgf8bveofxFEJUaJLkg","lore_tm_v1_-8aqIYUV_VcOU1-XhD8xuOhiZhjAG7LtB1GIfKQaWXo"]
Date: Sep 8, 2026
/home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/tool.ts:1-69 defines the Promise plugin tool surface: re-exports CallID and Error plus types Metadata, Options, and Result from @opencode/schema/tool; ToolContext replaces Effect-based progress with (update: Tool.Metadata) => Promise<void>; generic Info<Input, Output> replaces execute with a Promise-returning function; ToolEditor provides list(), get(id), namespace(namespace), add(tool), update(id, update), and remove(id); missing IDs passed to update are ignored./home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/tool.ts:37-69 defines mutable tool hooks: "execute.before" includes tool, sessionID, agent, messageID, id, and mutable input; "execute.after" includes the same invocation identity and input plus either { status: "completed", result } or { status: "error", error }. ToolDomain exposes transform, reload, and hook./home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/permission.ts:7-24 defines PermissionEvaluation with readonly sessionID, optional agent, action, resources, optional metadata, optional source, mutable effect, and optional mutable message; PermissionHooks.evaluate carries that value. PermissionDomain exposes PermissionApi methods "list", "get", and "reply" plus hook./home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/session.ts:13-102 defines Promise session hooks and domain APIs. SessionPrompt carries sessionID, messageID, mutable deep prompt, optional metadata, and delivery; SessionContext carries invocation identity plus mutable system, messages, tools, generation, and providerOptions; SessionRequestKind is "primary" | "compaction" | "title" | "generate"./home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/session.ts:39-83 defines SessionModelRequest with mutable optional baseURL and mutable headers; SessionHttpRequest with mutable request; SessionHttpResponse with readonly request and mutable response; and SessionRetry with SessionError.Error, attempt, and mutable decision, where SessionRetryDecision is { retry: false } | { retry: true; delay: number }. SessionHooks contains prompt, context, "model.request", "http.request", "http.response", and retry./home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/session.ts:85-102 defines SessionDomain as SessionApi methods "create", "get", "switchAgent", "switchModel", "prompt", "generate", "command", "synthetic", "interrupt", "rename", "move", "wait", and "context", plus readonly hook: ModelHooks<SessionHooks>./home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/event.ts:1-3 defines EventDomain as Pick<EventApi, "subscribe">./home/byk/Code/opencode-v2-pilot/packages/schema/src/tool.ts:9-44 defines canonical tool contracts: Metadata = Readonly<Record<string, any>>; branded CallID with brand "Tool.CallID"; Context with sessionID, agent, messageID, id, and Effect-based progress; Namespace with name and description; and Options where codemode?: true may coexist with pinned?: boolean, while a general required codemode: boolean requires pinned?: never./home/byk/Code/opencode-v2-pilot/packages/schema/src/tool.ts:44-102 defines ValueSchema as an Effect Schema.Codec, StandardSchemaV1, or JsonSchema.JsonSchema; tagged Tool.Error with message, optional defect error, and optional string-keyed unknown metadata; content variants Tool.TextContent (type: "text", text) and Tool.FileContent (type: "file", uri, mime, optional name); Result with optional typed output, optional string or content-array content, and optional metadata; and Info with name, input, description, Effect-returning execute, optional output, and optional options.@opencode/schema <- @opencode/protocol <- @opencode/server; Schema owns browser-safe serializable wire/storage contracts, while runtime behavior, service layers, side effects, and host-local details remain in their owning domain packages.V1 legacy contracts under src/v1/; current code must not depend on that subtree, V2 must not remain the permanent replacement-architecture name, and the V1 subtree should be deleted when the legacy runtime is retired.current, shared transitional, or V1-only; V1-only events such as message.updated and message.part.* must remain outside current Protocol/SDK Next unless a current-client requirement is documented; event definitions must have one canonical identity rather than duplicates for generation convenience.PluginID, PluginEvent, PtyInfo, PtyEvent, SessionSchema, AgentSchema, and ModelSchema; consumers should use canonical namespace-qualified members such as Plugin.ID, Question.Info, Session.Info, and Agent.Info, with public leaf packages directly re-exporting reachable canonical domains from @opencode/schema/<domain>.statics(...) for the static-method combinator, same-name interfaces for public Schema.Struct records, type aliases for unions/scalars/arrays/branded scalars/event helpers, readonly public contracts, Types.DeepMutable or purpose-built draft types only at runtime mutation boundaries, Schema.Json for serializable values, and Schema.Unknown for opaque values requiring narrowing.optional(...) so encoded objects omit undefined; raw Schema.optional(...) is only for intentionally encoded undefined properties and must be documented; external convenience defaults should normally use decode-only Schema.withDecodingDefault(...).create(), generated ID schemas to validate the exact emitted prefix including _, legacy loose validators not to be tightened without an explicit compatibility/migration decision, and reusable public schemas to have stable unique domain-qualified identifiers. Contract changes require focused tests for omitted undefined, absence of accidental current-contract Schema.Any, stable/unique identifiers, exact facade/schema identity, and exclusion of V1-only events from current Protocol manifests./home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/adapter.ts:430-494 adapts permission, plugin, reference, RPC, skill, storage, and tool domains. Permission and tool hooks wrap Promise callbacks with Effect.promise(() => Promise.resolve(callback(event))); tool editor reads convert Effect executors with promiseExecutor; tool additions and updates convert Promise executors through executePromiseTool; updates copy output, options, and the converted execute back with Object.assign./home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/adapter.ts:495-581 adapts VCS, websearch, worktree, and session APIs. VCS/websearch/worktree Promise implementations receive an AbortSignal via attempt; session exposes endpoint adapters for create, get, switchAgent, switchModel, prompt, generate, command, synthetic, interrupt, rename, move, wait, and context./home/byk/Code/opencode-v2-pilot/packages/plugin/src/promise/adapter.ts:588-608 acquires plugin setup with Effect.acquireRelease, invokes optional cleanup on release, defines attempt<A> using Effect.tryPromise({ try: evaluate, catch: (cause) => cause }), and defines executePromiseTool using Effect.promise; Promise tool progress calls Effect.runPromise(context.progress(update))./home/byk/Code/opencode-v2-pilot/packages/core/src/permission.ts:16-112 re-exports canonical Permission schema contracts, defines AssertInput, ReplyInput, and AskResult, and defines errors DeclinedError, CorrectedError, BlockedError, and NotFoundError. BlockedError.message uses reason or defaults to Permission denied: ${this.permission}. evaluate(action, resource, ...rulesets) flattens rules, chooses the last wildcard-matching rule, and defaults to { action, resource: "*", effect: "ask" }./home/byk/Code/opencode-v2-pilot/packages/core/src/permission.ts:19,143-183 uses fallback permissions [{ action: "*", resource: "*", effect: "deny" }] when an agent cannot be resolved. Saved project rules become "allow" rules; configured denial is checked before saved rules; otherwise resource effects collapse to "ask" if any resource asks, or "allow"; the mutable "permission"/"evaluate" plugin hook can then change effect and message./home/byk/Code/opencode-v2-pilot/packages/core/src/permission.ts:186-239 creates permission requests with a supplied id or ID.create(), rejects duplicate pending IDs via a defect, publishes Permission.Event.Asked, and removes a pending item if publishing fails. Permission.ask creates pending state only for "ask"; Permission.assert raises BlockedError for "deny", returns for "allow", and waits interruptibly for a reply when prompting./home/byk/Code/opencode-v2-pilot/packages/core/src/util/wildcard.ts:3-14 normalizes \ to /, escapes regex punctuation, maps * to .* and ? to ., special-cases trailing " .*" as optional " (.*)", anchors the generated regex, and uses case-insensitive matching only on Windows ("si" versus "s").Permission.Service and every other required Location service while the layer is constructed, and the executor captures those services.ToolFailure; catchCause must not be used because interruption and defects must survive.Permission.assert and question dismissals travel as defects beneath leaf mapError blankets and resurface as typed failures at SessionModelRequest.executeTool; leaves must never catch or convert them.Permission.CorrectedError, remains typed so the leaf converts it into ToolFailure and the model continues.State to replay synchronous transforms in registration order against a fresh editor.Tool.Service.reload() rebuilds from captured source data without changing registration precedence.dispose Effect.