Dashboard › opencode › Distillation
7ed97254-4ddb-42c1-95ce-2b4d42c09b95["lore_tm_v1_PjTE63MdjvdYCUTTDyE_tWYO4hA-0lsdLKD9b9b3gqU","lore_tm_v1_w6x7Q0R2uAhJinEAtaAczWVklyeujHbFbNCxsINKxYY","lore_tm_v1_eJEdr1s3G9u69H54GRNvbUWZZ_bhHFyFhI1miFeS6ew","lore_tm_v1_vxk97i3NRrR6U-MKlNfM-RHgkUMybE2VSuP3LTlyuOc","lore_tm_v1_IQ8rJXbz2ulqTGavxJJyj79aiAozd6H29LMpZ7hq9QA","lore_tm_v1_0CFC4GwHsP2Yfg9UfrQVsxeNTZhlr_j875ygMhbgDy8","lore_tm_v1_irLH57-9d71vSpDrsROX2YHVYZnqT7_QpetsNzipSMs","lore_tm_v1_UEKIZxI73AKzdKSSdDqYUcrwAcnL99MJ1bLObTPOjqc","lore_tm_v1_EhZuPatGz5fjdwGXK0RvkyK8VZ65wPhJQUeeymJzrUc","lore_tm_v1_AevOI2sDDTNOoLBt1QyXdnOggA9BrT5S12JmGW8oB0Q","lore_tm_v1_PaRibAWfx9-KWxfe-g7LmJMwIseIe8rWx5zwtNG5Bqo","lore_tm_v1_00K_Un8XTaZOAqznA3KYKoGDbNlztFuRF8HULD3G00c","lore_tm_v1_3_zcZW2W4fncsWaS3WTV67osdL56QLt7yg8yoCnSS1U"]
/home/byk/Code/opencode/packages/core/src/effect/app-node-builder.ts defines build<A, E>(root: LayerNode.Node<A, E, any>, replacements: LayerNode.Replacements = []); it lazily builds LocationServiceMap only when LayerNode.hasUnbound(root, LocationServiceMap.node) and no replacement with the same node.name exists, then calls LayerNode.compile(root, allReplacements)./home/byk/Code/opencode/packages/opencode/src/session/retry.ts:90-98 implements this through status !== undefined && status >= 500./home/byk/Code/opencode/packages/opencode/src/session/retry.ts configures retries with RETRY_INITIAL_DELAY = 2000, RETRY_BACKOFF_FACTOR = 2, RETRY_JITTER_FACTOR = 0.25, RETRY_MAX_DELAY_NO_HEADERS = 30_000, RETRY_MAX_DELAY = 2_147_483_647, and RETRY_MAX_RETRIES = 5./home/byk/Code/opencode/packages/opencode/src/session/retry.ts prioritizes retry-after-ms, then numeric or HTTP-date retry-after; otherwise it uses exponential backoff plus jitter. Delays with response headers are capped at 2_147_483_647 ms, while delays without headers are additionally capped at 30_000 ms./home/byk/Code/opencode/packages/opencode/src/session/retry.ts excludes SessionV1.ContextOverflowError from retries; API errors qualify when isRetryable, HTTP status is at least 500, or message/responseBody matches retryable patterns covering 429/5xx, rate limits, overloads, network failures, timeouts, retry requests, resource exhaustion, and temporary capacity./home/byk/Code/opencode/packages/opencode/src/session/retry.ts uses GO_UPSELL_MESSAGE = "Free usage exceeded, subscribe to Go" and GO_UPSELL_URL = "https://opencode.ai/go"; FreeUsageLimitError returns action reason free_tier_limit, title "Free limit reached", label "subscribe", and advertises OpenCode Go for $10/month.GoUsageLimitError handling in /home/byk/Code/opencode/packages/opencode/src/session/retry.ts parses workspace, limitName, and retry-after, formats reset time in days/hours/minutes, and returns an account_rate_limit action with title "Go limit reached", label "open settings", and link https://opencode.ai/workspace/${workspace}/go.policy() in /home/byk/Code/opencode/packages/opencode/src/session/retry.ts stops when an error is non-retryable or meta.attempt > RETRY_MAX_RETRIES; otherwise it calculates wait, records { attempt, message, action, next: now + wait }, and schedules Duration.millis(wait)./home/byk/Code/opencode/packages/opencode/src/server/routes/instance/httpapi/lifecycle.ts uses WeakMap<object, MarkedInstance> named disposeAfterResponse to hand disposal state from an endpoint pre-response handler to outer disposeMiddleware, keyed by the original request.source.markInstanceForDisposal() appends a pre-response handler that stores { ctx, store, bridge }; disposeMiddleware sends/obtains the response first, deletes the marker, then runs marked.store.dispose(marked.ctx) uninterruptibly through marked.bridge.run(), logging "instance disposal failed" on failure.markInstanceForReload(ctx, next) in /home/byk/Code/opencode/packages/opencode/src/server/routes/instance/httpapi/lifecycle.ts performs marked.store.reload(next) uninterruptibly in the pre-response phase and preserves the response via Effect.as(...)./home/byk/Code/opencode/packages/opencode/script/build-node.ts builds ./src/node.ts into ./dist/node with Bun configuration target: "node", format: "esm", sourcemap: "linked", externals "jsonc-parser" and "@lydell/node-pty", generated definitions OPENCODE_MODELS_DEV, OPENCODE_VERSION, and OPENCODE_CHANNEL, plus an empty "opencode-web-ui.gen.ts" file./home/byk/Code/opencode/packages/opencode/src/node.ts exports Config, Server, bootstrap, and Database.never : Item extends Node<infer A, as part of Output<Item>; the shown definition is export type Output<Item> = [Item] extends [never] ? never : Item extends Node<infer A, unknown, any> ? A : never.never : Item extends Node<unknown, as part of Error<Item>; the shown definition is export type Error<Item> = [Item] extends [never] ? never : Item extends Node<unknown, infer E, any> ? E : never.type NodeTag<Item> = [Item] extends [never] ? undefined : Item extends Node<unknown, unknown, infer T> ? T : never and Node<A, E = never, T extends Tag | undefined = undefined>./home/byk/Code/opencode/packages/opencode/src/cli/bootstrap.ts defines bootstrap<T>(directory, cb): it loads an instance with InstanceRuntime.load({ directory }), runs cb under context.provide(ctx, cb), and guarantees InstanceRuntime.disposeInstance(ctx) in finally./home/byk/Code/opencode/packages/core/src/event/sql.ts defines EventSequenceTable as SQLite table "event_sequence" with primary key aggregate_id, required integer seq, and optional owner_id./home/byk/Code/opencode/packages/core/src/event/sql.ts defines EventTable as SQLite table "event" with primary-key id, cascading foreign key aggregate_id β EventSequenceTable.aggregate_id, required seq, type, and JSON data; indexes are unique "event_aggregate_seq_idx" on (aggregate_id, seq) and "event_aggregate_type_seq_idx" on (aggregate_id, type, seq)./home/byk/Code/opencode/packages/core/src/event.ts publish() derives event location from options.location or the optional Location.Service, creates an ID with ID.create() when absent, and passes optional metadata and commit settings to publishEvent()./home/byk/Code/opencode/packages/core/src/event.ts rejects unknown/non-durable event types with InvalidDurableEventError, decodes event data through the registered schema, supports ownerID and strictOwner, and optionally publishes successfully committed replay events.replayAll() requires every event to share one aggregateID and have contiguous sequence values beginning at the first eventβs seq; failures use exact messages "Replay events must belong to the same aggregate" and Replay sequence mismatch at index ${index}: expected ${seq}, got ${event.seq}./home/byk/Code/opencode/packages/core/src/event.ts include remove() deleting both sequence and event rows transactionally, claim() setting owner_id, typed subscribe(), all, durable, listen, project, replay, and replayAll./home/byk/Code/opencode/packages/core/src/event.ts uses a sliding PubSub<void> of capacity 1, reads rows where seq > after in ascending order, updates its sequence from the last event, emits historical events first, then re-reads and emits live events on wake notifications./home/byk/Code/opencode/packages/opencode/src/session/message-v2.ts documents that filterCompacted reorders messages as [compaction-user, summary, ...retained tail..., continue-user], so latest() determines chronology by info.time.created and uses info.id only as a deterministic tie-breaker for imported messages with potentially non-monotonic IDs.latest(msgs) in /home/byk/Code/opencode/packages/opencode/src/session/message-v2.ts selects the latest user, assistant, and finished assistant messages; it returns compaction/subtask parts only from messages after the latest finished assistant, using isAfter() to compare creation time and then ID.fromError() in /home/byk/Code/opencode/packages/opencode/src/session/message-v2.ts maps AbortError to AbortedError, LoadAPIKeyError to AuthError, ECONNRESET to retryable APIError message "Connection reset by server", non-aborted ZlibError to retryable "Response decompression failed", and ProviderError.HeaderTimeoutError to a retryable APIError carrying timeoutMs.