Dashboard › opencode › Distillation
d0e5f8ee-ded1-4b06-bdf4-2de9ae7d74e9["lore_tm_v1_s6Gll7aEuTlrPWMUvR9aVoGnX0yeoQ3Z3nSph8X5dRA","lore_tm_v1_dwRL8d4JFzYxpbKvjvQo7GCJbZqyQiYv0cq30Z9iLFw","lore_tm_v1_BENrF2hMDTyDyJlUGkfwPwOz2vbX9rmbj9JpYeMdKCA","lore_tm_v1_uZYlhX3RMXRkNUldq7hzuISHc59VA434SOIggrT_t0o","lore_tm_v1_lVo9KbiBCd9ADnR7abqbIILiB_0cA3Pg_rAMNB3WtXY","lore_tm_v1_1q2me6nVEo95HhxT3H7UkNsh-0BVi2cWH_H5J1WvSNY"]
visibilitychange should always be fired.Found 100 matches (more matches available) and was truncated. It showed extensive v1/v2 branching in /home/byk/Code/opencode/packages/app/src/context/, including global-sync/bootstrap.ts, permission.tsx, layout.tsx, directory-sync.ts, terminal.tsx, server-session.ts, and server-sdk.tsx./home/byk/Code/opencode/packages/app/src/context/server-sdk.tsx imports the current Event type from @opencode-ai/sdk/v2/client and legacy OpenCodeEvent from @opencode-ai/client/promise; ServerEvent is Event & { current?: OpenCodeEvent }.adaptServerEvent() in /home/byk/Code/opencode/packages/app/src/context/server-sdk.tsx:28-57 maps legacy/current events: permission.v2.asked β permission.asked, permission.v2.replied β permission.replied, question.v2.asked β question.asked, question.v2.replied β question.replied, and question.v2.rejected β question.rejected; each adapted event retains the source as current.permission.v2.asked, adaptServerEvent() maps data.action to permission, data.resources to patterns, defaults data.save to [], defaults data.metadata to {}, and maps a tool source to { messageID, callID }.enqueueServerEvent() in /home/byk/Code/opencode/packages/app/src/context/server-sdk.tsx:68-77 only replaces the immediately previous queued event when both have the same coalescing key. Coalescing keys exist for lsp.updated by directory and message.part.updated by directory, messageID, and part id.coalesceServerEvents() in /home/byk/Code/opencode/packages/app/src/context/server-sdk.tsx:79-139 concatenates adjacent compatible current-protocol deltas for session.text.delta, session.reasoning.delta, session.tool.input.delta, and session.compaction.delta; compaction fragments use data.text, while the others use data.delta.coalesceServerEvents() also concatenates adjacent legacy message.part.delta events only when directory, messageID, partID, and field match./home/byk/Code/opencode/packages/app/src/context/server-sdk.tsx:151-159 are: tool input β event type, sessionID, assistantMessageID, and callID; compaction β event type and sessionID; text/reasoning β event type, sessionID, assistantMessageID, and ordinal.resumeStreamAfterPageShow() in /home/byk/Code/opencode/packages/app/src/context/server-sdk.tsx:162-165 invokes start() only when PageTransitionEvent.persisted is true.createServerSdkContextBase() uses platform.fetch for event streaming only when the server URL is plain http: and non-loopback; localhost, 127.0.0.1, and ::1 do not use that override. Invalid URLs also leave eventFetch undefined./home/byk/Code/opencode/packages/app/src/context/server-sdk.tsx are FLUSH_FRAME_MS = 16, STREAM_YIELD_MS = 8, RECONNECT_DELAY_INITIAL_MS = 250, RECONNECT_DELAY_MAX_MS = 5_000, and HEARTBEAT_TIMEOUT_MS = 15_000./home/byk/Code/opencode/packages/app/src/context/server-sdk.tsx flushes no faster than every 16 ms, calls coalesceServerEvents(), emits the resulting events inside Solidβs batch(), and reuses alternating queue and buffer arrays.(await eventSdk.global.event({ signal })).stream for protocol "v1" and eventApi.event.subscribe({ signal }) otherwise. Legacy events use event.directory ?? "global" and event.payload; current events use event.location?.directory ?? "global" and adaptServerEvent(event). Legacy events whose payload type is "sync" are skipped.await wait(0) after at least STREAM_YIELD_MS = 8, resets the heartbeat and reconnect delay on every event, marks the connection active, and suppresses repeated stream-error logging until another event arrives.started, generation, attempt, and run to prevent duplicate runs and stale loops. stop() sets started = false, increments generation, and aborts the active attempt; final completion flushes queued events./home/byk/Code/opencode/packages/app/src/context/server-sdk.tsx:359-388 registers page/network recovery listeners: pagehide calls stop; persisted pageshow calls start; visible visibilitychange calls resumeIfIdle; window focus calls resumeIfIdle; and online resets reconnect delay and either starts a stopped stream or aborts the active attempt.resumeIfIdle() immediately restarts a stopped stream; for a started stream, it aborts the active attempt only when Date.now() - lastEventAt >= 5_000, after resetting reconnect delay to 250 ms./home/byk/Code/opencode/packages/app/src/context/server-sdk.tsx:390-394 calls stop(), aborts the context-level AbortController, and flushes queued events.reconnecting is true only after at least one successful connection (everConnected) and a subsequent disconnect, avoiding an initial-load reconnecting flash. catchingUp is independently true while catchUpCount() > 0.beginCatchUp() increments catchUpCount and returns an idempotent completion callback that decrements the count without allowing it below 0.createDirSdkContext() in /home/byk/Code/opencode/packages/app/src/context/server-sdk.tsx:493-524 creates a directory-scoped current client, relays global server events for that directory into an emitter keyed by event type, cleans up the subscription with onCleanup(unsub), and creates a compatible API with current and legacy clients./home/byk/Code/opencode/packages/app/src/utils/server.ts defines authTokenFromCredentials() as Base64 encoding of ${username ?? "opencode"}:${password}.authFromToken() in /home/byk/Code/opencode/packages/app/src/utils/server.ts:10-19 Base64-decodes a token, rejects missing/invalid decoded content or content without :, defaults an empty username to "opencode", and preserves everything after the first colon as the password.createSdkForServer() and createApiForServer() attach Authorization: Basic ${authTokenFromCredentials(...)} only when server.password exists. createSdkForServer() merges caller headers first and then overwrites Authorization with server credentials./home/byk/Code/opencode/packages/app/node_modules/@opencode-ai/client/dist/promise/generated/client.js caps the accumulated SSE buffer at maxSseEventBytes = 16 * 1024 * 1024; exceeding it throws ClientError("SseEventTooLarge").ClientError("Transport", { cause }); declared HTTP statuses are parsed and thrown as JSON, while undeclared statuses cancel the body and throw ClientError("UnexpectedStatus", { cause: { status } }).Uint8Array; empty responses cancel the body and return undefined; non-empty responses are parsed as JSON.text/event-stream, rejects a null body as ClientError("MalformedResponse"), normalizes CRLF and CR to LF, combines all data: lines in each blank-line-delimited block, JSON-parses nonempty data, and cancels/releases the reader in finally.appendQuery() in /home/byk/Code/opencode/packages/app/node_modules/@opencode-ai/client/dist/promise/generated/client.js:1096-1114 omits undefined, serializes null as the literal "null", repeats keys for arrays, recursively encodes objects as bracketed keys such as key[child], and stringifies scalar values.application/json or any content type containing +json; unsupported content types cause body cancellation and ClientError("UnsupportedContentType"), while empty or invalid JSON causes ClientError("MalformedResponse").session.list request includes query fields workspace, limit, order, search, parentID, directory, project, subpath, and cursor; its declared error statuses are 400 and 401.session.prompt contract differs from the current protocol source: its body contains required-indexed fields id, text, files, agents, metadata, delivery, and resume, and its declared statuses are 409, 400, 404, and 401.session.interrupt as POST /api/session/:sessionID/interrupt, success 204, with only 404, 400, and 401 declared; HTTP 499 is not declared there.Found 28 matches. In addition to app and core usage, hits include /home/byk/Code/opencode/packages/opencode/src/cli/cmd/debug/v2.ts, which reports catalog.model.default() as an optional model ID; /home/byk/Code/opencode/packages/core/src/plugin/host.ts and packages/core/test/plugin/host.ts, which expose/get/set the draft default model; and /home/byk/Code/opencode/packages/core/src/config/plugin/provider.ts, which calls catalog.model.default.set(model.providerID, model.modelID)./home/byk/Code/opencode/packages/core/test/catalog.test.ts cover selecting a newer model, preserving an explicitly configured older model, choosing the newest model when not configured, and behavior involving a disabled provider/model./home/byk/Code/opencode/packages/llm/src/protocols/anthropic-messages.ts:510 computes the output limit as request.model.defaults?.limits?.output ?? request.model.route.defaults.limits?.output ?? 4096./home/byk/Code/opencode/packages/llm/test/llm.test.ts:124-127 expects model defaults of limits: { context: 128_000, output: 8_192 }, generation: { maxTokens: 1_024, stop: ["END"] }, providerOptions: { openai: { parallelToolCalls: false } }, and http: { body: { extra_body: true } }.