Dashboard › opencode › Distillation
24080570-68a0-45b1-945d-c723db7191e3["lore_tm_v1_8q0VIxuWpzTS3MgMQbOpvmLRDpBf1-rO91arMiGO8RY","lore_tm_v1_SuZSm5AlCuLtPSuQsqk-NSBd55vYd_yIiJ4taNdT7HA","lore_tm_v1_gAMbbXkCGWvq3HcmCvzWSIJsdUIO4xn7RzGtu9Y1d80","lore_tm_v1_T-encJWKEp4F8DLof84ukyg6TDk4MLR_W1Ncym0U9II","lore_tm_v1_apq-JhXPNCNJLcLKo05CiwgdFAn5lihdL2GUGeeFuWk"]
Date: Sep 8, 2026
packages/plugin/src/promise/permission.ts defines the Promise permission counterpart: PermissionEvaluation contains readonly sessionID, optional agent, action, resources, optional metadata, optional source, mutable effect, and optional mutable message; PermissionHooks exposes evaluate: PermissionEvaluation; PermissionAssertInput contains sessionID, action, resources, optional save, metadata, source, and agent.packages/plugin/src/promise/permission.ts:32-35 defines PermissionDomain as Pick<PermissionApi, "list" | "get" | "reply"> plus assert: (input: PermissionAssertInput) => Promise<void> and hook: Hooks<PermissionHooks>.packages/plugin/src/promise/adapter.ts adapts Promise plugins into Effect plugins through fromPromise(plugin: Plugin), preserving the existing Effect-only Core runtime; registrations created during async setup attach to the plugin scope, unloading runs the optional setup cleanup, and captured fiber context preserves boot-time batching so Promise transforms coalesce into one reload per domain.packages/plugin/src/promise/adapter.ts:44-74 defines makeStreams(): each async iterator is built with Stream.toAsyncIterableWith(stream, context), owns cleanup tracked in a Set, closes on completion/error/return, supports AbortSignal, removes abort listeners during close, and a plugin-scope finalizer closes all active subscriptions.packages/plugin/src/promise/adapter.ts:76-165 defines rpcFromEffect(host, streams): local RPC methods run through Effect.runPromiseWith(context) with optional abort signals; events.subscribe returns an async iterable; events.on creates an AbortController, combines external signals with AbortSignal.any, logs iteration failures, and returns an unsubscribe function; Promise handlers are wrapped with Effect.tryPromise; ReturnedRpcError preserves type, message, and optional data; hostRpcError() translates only ReturnedRpcError through context.error.packages/plugin/src/promise/adapter.ts:167-203 caches endpoint adapters in compiledEndpoints: WeakMap<object, CompiledEndpoint>. compileEndpoint() rejects more than one payload or success schema with Error("Unsupported API schema cardinality: ..."), decodes params/query/headers/payload schemas, defaults success to HttpApiSchema.NoContent, unwraps a sole { data: ... } success property when applicable, and compiles Schema.decodeUnknownEffect and Schema.encodeUnknownEffect.packages/plugin/src/promise/adapter.ts:219-237 dynamically imports ClientApi and OpenCodeEvent, then obtains endpoint groups for server.agent, server.command, server.experimental, server.generate, server.integration, server.mcp, server.model, server.plugin, server.permission, server.provider, server.reference, server.session, server.skill, server.vcs, server.websearch, and server.worktree.packages/plugin/src/promise/adapter.ts:241-282 uses captured scope context for register() and run(). register() converts an Effect host registration into { dispose: () => Promise<void> }; promiseExecutor() converts Effect tool execution to Promise execution while adapting progress updates; adaptApiMethod() decodes request inputs from the endpoint schema, invokes the host method, returns undefined for no-content endpoints, and schema-encodes other outputs; generic transform() registers Promise editor callbacks against Effect domains.packages/plugin/src/promise/adapter.ts:284-587 builds a Promise Plugin.Context exposing domains app, location, options, agent, aisdk, catalog, command, event, experimental.terminal, generate, integration, mcp, permission, plugin, reference, rpc, skill, storage, tool, vcs, websearch, worktree, session, and shell.packages/plugin/src/promise/adapter.ts:430-437 maps hook to host.permission.hook with Promise callbacks wrapped by Effect.promise, maps assert to run(host.permission.assert(input)), and maps list, get, and reply through endpoint-aware adaptApiMethod() using PermissionEndpoints["session.permission.list"], PermissionEndpoints["session.permission.get"], and PermissionEndpoints["session.permission.reply"].packages/plugin/src/promise/adapter.ts:458-495 exposes reload, transform, and hook; editor list() and get(id) convert captured Effect executors with promiseExecutor; add(tool) wraps Promise execution with executePromiseTool; update(id, update) presents a Promise-compatible mutable Info, applies updates, then writes output, options, and a wrapped executor back to the host tool; namespace and remove pass through.packages/plugin/src/promise/adapter.ts:597-609 defines attempt() with Effect.tryPromise({ try: evaluate, catch: (cause) => cause }); executePromiseTool() uses Effect.promise and adapts progress through Effect.runPromise(context.progress(update)).packages/plugin/src/promise/adapter.ts:379-419 passes editor list, get, update, and remove; method updates preserve list/remove, adapt authorize for both "auto" callbacks and code-taking callbacks, and adapt optional credential refresh from Promise to Effect.packages/plugin/src/promise/adapter.ts wrap Promise operations with abort-aware attempt(): VCS definitions adapt info, optional bound base, branches, status, and diff; web-search definitions adapt execute; both retain their editor default behavior.packages/plugin/src/promise/adapter.ts:543-562 exposes API methods list, create, remove, refresh, and reload; transformed definitions adapt create, remove, and list(directory) through abort-aware attempt().packages/plugin/src/promise/adapter.ts:564-582 exposes hook, create, get, switchAgent, switchModel, prompt, generate, command, synthetic, interrupt, rename, move, wait, and context, with API methods compiled against the matching SessionEndpoints.packages/core/test/plugin/host.ts exports host(overrides: Overrides = {}): Plugin.Context; default app metadata is { name: "test", version: "test", channel: "test" }, default location is /workspace with Project.ID.global, and unused domain methods fail via named Effect.die("unused ...") placeholders while event.subscribe defaults to Stream.empty.packages/core/test/plugin/host.ts includes complete stubs for rpc, agent, aisdk, catalog, command, event, experimental.terminal, generate, integration, mcp, permission, plugin, reference, skill, storage, shell, tool, vcs, worktree, websearch, and session; session methods permit individual overrides through Partial<Plugin.Context["session"]>.packages/core/test/plugin/host.ts:182-223 exports agentHost(agent): get converts IDs through Agent.ID.make, returns a synthetic / location and cloned agentInfo, fails with Error("Agent not found: ...") when absent, delegates reload, and adapts editor list, get, default, update, and remove while restoring branded agent IDs.packages/core/test/plugin/host.ts:225-307 exports catalogHost(catalog): model listing returns a synthetic / location; transforms adapt provider list/get/update/remove, model get/update/remove, and default-model get/set; updates restore branded Provider.ID, Model.ID, optional Model.Family, and Model.VariantID values.packages/core/test/plugin/host.ts:309-428 exports integrationHost(integration): connection methods brand integration/credential IDs; transform adapts integration and method editor operations; OAuth authorization adapts "auto" and code callbacks and restores Credential.OAuth plus branded Integration.MethodID; optional refresh is preserved; "env" and "command" method variants receive variant-specific handling.packages/core/test/plugin/host.ts:430-464 exports webSearchHost(websearch) using location /tmp/websearch-test and project ID "websearch-test"; query brands optional providerID with WebSearch.ID.make; transforms brand provider IDs and adapt default selection, preserving false and "random" while branding explicit selections.packages/core/test/plugin/host.ts:474-516 avoid leaking mutable internal structures: agentInfo() clones model, request settings/headers/body, and permissions; providerInfo() clones settings/headers/body; modelInfo() clones settings/headers/body, capability input/output arrays, variants and their settings/headers/body, time, costs including tier/cache, and limits.