feat: vendored Laminar OpenCode plugin (@browser-use/bcode-laminar)#33
Merged
Alezander9 merged 2 commits intofeat/embed-lmnr-keyfrom May 2, 2026
Merged
Conversation
There was a problem hiding this comment.
3 issues found across 18 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/bcode-laminar/src/processor.ts">
<violation number="1" location="packages/bcode-laminar/src/processor.ts:168">
P1: Memory leak: `spawningSpanIdToToolUseId` entries are never cleaned up because the key format used for insertion (UUID via `otelSpanIdToUUID`) differs from the key used for deletion (raw hex span ID). The `delete` will never match an existing entry.</violation>
</file>
<file name="packages/bcode-laminar/src/plugin.ts">
<violation number="1" location="packages/bcode-laminar/src/plugin.ts:25">
P2: `LMNR_GRPC_PORT` is not validated; invalid values produce `NaN` and an invalid OTLP endpoint URL.</violation>
<violation number="2" location="packages/bcode-laminar/src/plugin.ts:68">
P1: Dispose handling is incomplete: it shuts down the processor but does not end/clear active turn spans or shut down the NodeSDK lifecycle.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.
added 2 commits
May 2, 2026 03:55
…de-laminar Lands tracing as a built-in internal plugin. ~600 lines vendored from lmnr-ai/lmnr-opencode-plugin@bb2fceaff and lmnr-ai/lmnr-ts@5ebe07a6 (both Apache-2.0). Trims rollout-session, OTEL_HEADERS, HTTP/protobuf, and pino paths we don't need. Wire format: OTLP/gRPC + bearer token. No proprietary surface — all deps are standard OTel. Plugin registration is one Yellow-zone line in INTERNAL_PLUGINS. The no-key fast-path keeps DO_NOT_TRACK and self-builds trace-free with zero `if (telemetryEnabled)` branches. First-run notice in bcode-browser/src/telemetry.ts: one line, suppressed when DO_NOT_TRACK is set. Marker file at {state-dir}/bcode/telemetry-notice-shown. Smoke-tested on linux-x64: typecheck clean across 6 packages, build succeeds across all 12 platforms, plugin initializes when key is set, no-ops when DO_NOT_TRACK=1, embedded BCODE_DEFAULT_LMNR_KEY flows through correctly. Depends on #32 (telemetry-key injection).
- processor.ts: spawningSpanIdToToolUseId is keyed by UUID (otelSpanIdToUUID(spanId)) at insert time but onEnd was deleting by raw hex span id, so entries were never cleaned up. Use the UUID for delete to match. - plugin.ts: server.instance.disposed now ends any open turn spans, clears the subagent map, and shuts down the NodeSDK (which drains the BatchSpanProcessor and unregisters the global TracerProvider). - plugin.ts: LMNR_GRPC_PORT is validated (positive integer in 1..65535) before use, with fallback to the appropriate default (8443 for api.lmnr.ai, 443 elsewhere). Garbage values no longer produce NaN endpoint URLs.
fcb965f to
f5f70c1
Compare
Member
Author
|
Tested on windows, looks good on Laminar |
This was referenced May 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Lands the Laminar OpenCode tracing integration as a vendored, built-in plugin. Depends on #32 (the telemetry-key injection PR) — branch is forked off
feat/embed-lmnr-keyand either alone is a no-op.Summary
packages/bcode-laminar/(~600 lines, vendored fromlmnr-ai/lmnr-opencode-plugin@bb2fceaff+lmnr-ai/lmnr-ts@5ebe07a6, both Apache-2.0). One-time pull; we don't recurring-sync this.LaminarPlugininINTERNAL_PLUGINSso tracing ships built-in. Nobcode.jsonconfiguration needed.DO_NOT_TRACK=1).What it does
When
LMNR_PROJECT_API_KEYis set in the environment (which #32 does at startup, gated byDO_NOT_TRACKand BYO-key precedence):NodeSDKwith one custom span processor.chat.messageevent, creates a "turn" span scoped to the opencode session id.experimental_telemetry: trueinsession/llm.ts:406) onto the turn span.lmnr.span.path/lmnr.span.ids_pathancestor attributes that the Laminar UI uses to nest spans (it does NOT nest by OTel parentSpanId).tasktool withlmnr.spawning_subagent.tool_use_idso sub-agent traces link back to the spawning tool call.${LMNR_BASE_URL}:${LMNR_GRPC_PORT}(defaultshttps://api.lmnr.ai:8443) withauthorization: Bearer <key>.When the key is absent (DO_NOT_TRACK or self-build), the plugin loads, hits the no-key fast-path, and does nothing. Zero
if (telemetryEnabled)branches anywhere.What's vendored vs trimmed
See
packages/bcode-laminar/VENDOR.mdfor the full file map. Key trims vs upstream:LMNR_ROLLOUT_SESSION_ID(rollout-sessions feature we don't use).parseOtelHeaders/OTEL_HEADERSenv path.pinologger; route throughclient.app.log.loadEnv()(opencode loads.envalready).Laminar.startSpanto the minimalstartTurnSpanwe need.First-run notice
Added to
packages/bcode-browser/src/telemetry.ts:Marker at
{state-dir}/bcode/telemetry-notice-shown(XDG /Application Support/%LOCALAPPDATA%). Suppressed entirely whenDO_NOT_TRACK=1(no need to print to opted-out users).Verification on the dev sprite
bun run typecheckclean across 6 packages.bun run --cwd packages/opencode buildsucceeds across all 12 platforms.LMNR_PROJECT_API_KEY=fake_key LMNR_BASE_URL=http://127.0.0.1:9 bcode models --print-logs --log-level DEBUG: emitsservice=laminar Laminar tracing initialized → http://127.0.0.1:9.DO_NOT_TRACK=1: no Laminar log, no notice, no marker file written.BCODE_DEFAULT_LMNR_KEY=...baked at build time: notice prints once, marker written, plugin initializes on first run.Files
packages/bcode-laminar/packages/opencode/src/plugin/index.tsLaminarPlugin, append toINTERNAL_PLUGINS.packages/opencode/package.json@browser-use/bcode-laminar.packages/bcode-browser/src/telemetry.tsshowFirstRunNoticeOnce()after the existing key gate.package.json(root)bcode-laminarto typecheck filter list.Maintenance
One-time vendor.
packages/bcode-laminar/VENDOR.mdrecords the source commits + per-file mapping for the next manual re-pull. Re-pull only when an upstream behavior fix or new attribute is worth bringing across — Laminar's plugin shape changes rarely.