feat(m3.4): @tronbrowser/sdk and tron run - #31
Merged
Conversation
Public developer SDK + a script runner (PRD M3.4), building on the M3.1–M3.3
Node automation runtime.
import { tron } from '@tronbrowser/sdk';
const browser = await tron.launch({ headless: true });
const page = await browser.newPage();
await page.goto(url); const snap = await page.snapshot(); await browser.close();
tron run ./agent.ts # TS runs directly (Node >=24 strips types)
tron run ./agent.js --headless --trace ./trace
- packages/sdk: Browser (session lifecycle: launch via the tron-session engine,
hand out Pages, tear down the temp profile on close) and Page (goto/reload/
back/forward, snapshot, click/fill/type by ref, extract, screenshot, pdf,
eval, url/title). analyze/step/runTask are declared but throw until M3.5.
Side-effects are injectable; launch reuses TRON_SESSION_BIN so binary
resolution isn't duplicated.
- tron-run.mjs + tron-run-hooks.mjs: the runner registers an ESM resolver hook
mapping @tronbrowser/sdk + /browser-core to the shipped runtime, then imports
the user script (no node_modules, no build). --headless/--profile/--trace
arrive via env and are honored by tron.launch().
- trace.ts: minimal --trace bundle (metadata.json + actions.jsonl) with values
redacted (full trace/replay is M3.7).
- install.sh routes `tron run`; build-release ships browser-core + sdk dist and
the runner files in the launcher payload.
Tests (+8): SDK lifecycle/cleanup/launch-failure with fakes, and an end-to-end
run over the real CDP WebSocket transport incl. multi-page Target.createTarget.
Verified `tron run` for JS and TS (no build) and --trace end-to-end against a
WS CDP stub. Full workspace suite green.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
vu1nz Security Review0 finding(s) in PR #? No security issues found. |
ralyodio
marked this pull request as ready for review
July 4, 2026 12:40
@tronbrowser/sdk imports @tronbrowser/browser-core and resolves it via its built dist, so typecheck/test need the dist present. pnpm builds in topological order (browser-core before sdk), so building first fixes the resolution. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Implements M3.4 — SDK and
tron run(PRD). Basemain(M3.1–M3.3 landed via #28).tron run ./agent.ts # TypeScript runs directly — no build step tron run ./agent.js --headless --profile work --trace ./traceWhat's here
@tronbrowser/sdk—tron.launch()→Browser(launches via thetron-sessionengine, hands outPageobjects, tears down the temp profile on close) andPage(goto/reload/back/forward,snapshot/snapshotText,click/fill/typeby ref,extract,screenshot,pdf,eval,url/title).analyze/step/runTaskdeclared but throw until M3.5. Side-effects injectable; launch reusesTRON_SESSION_BIN.tron-run.mjs+tron-run-hooks.mjs— the runner registers an ESM resolver hook mapping@tronbrowser/sdk+/browser-coreto the shipped runtime, then imports the user script — nonode_modules, no build. TS runs directly (Node ≥24 strips types).--headless/--profile/--tracevia env.trace.ts— minimal--tracebundle (metadata.json+actions.jsonl), values redacted (full trace/replay is M3.7).install.shroutestron run;build-release.shships browser-core + sdk dist and the runner files.Acceptance criteria (PRD §22)
@tronbrowser/sdk.tron run --headlessworks.tron run --tracewrites a trace bundle.Verification — +8 tests (16 in the SDK package)
Target.createTarget.tron runend-to-end for.jsand.ts(no build) and--trace(redactedactions.jsonl) against a WS CDP stub launched throughtron-session.Scope
Requires Node ≥24.
click/filltake@refsfrom a snapshot; richer targets/input later. Fulltron runvs a real browser isn't in CI (no Chromium) — covered by layered tests + WS-stub run. Seedocs/sdk-and-run.md.🤖 Generated with Claude Code