Skip to content

feat(m3.4): @tronbrowser/sdk and tron run - #31

Merged
ralyodio merged 2 commits into
mainfrom
worktree-m3.4-sdk-run
Jul 4, 2026
Merged

feat(m3.4): @tronbrowser/sdk and tron run#31
ralyodio merged 2 commits into
mainfrom
worktree-m3.4-sdk-run

Conversation

@ralyodio

@ralyodio ralyodio commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Implements M3.4 — SDK and tron run (PRD). Base main (M3.1–M3.3 landed via #28).

import { tron } from '@tronbrowser/sdk';
const browser = await tron.launch({ headless: true });
const page = await browser.newPage();
await page.goto('https://example.com/contact');
const snap = await page.snapshot();
await browser.close();
tron run ./agent.ts            # TypeScript runs directly — no build step
tron run ./agent.js --headless --profile work --trace ./trace

What's here

  • @tronbrowser/sdktron.launch()Browser (launches via the tron-session engine, hands out Page objects, tears down the temp profile on close) and Page (goto/reload/back/forward, snapshot/snapshotText, click/fill/type by ref, extract, screenshot, pdf, eval, url/title). analyze/step/runTask declared but throw until M3.5. Side-effects injectable; launch reuses TRON_SESSION_BIN.
  • 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. TS runs directly (Node ≥24 strips types). --headless/--profile/--trace via env.
  • trace.ts — minimal --trace bundle (metadata.json + actions.jsonl), values redacted (full trace/replay is M3.7).
  • install.sh routes tron run; build-release.sh ships browser-core + sdk dist and the runner files.

Acceptance criteria (PRD §22)

  • ✅ Import from @tronbrowser/sdk.
  • ✅ JS + TS scripts launch, navigate, snapshot, act, extract, close.
  • tron run --headless works.
  • tron run --trace writes a trace bundle.

Verification — +8 tests (16 in the SDK package)

  • SDK lifecycle with fakes: headless/profile via env, newPage, snapshot/extract/screenshot, cleanup, launch-failure teardown, analyze()→M3.5.
  • End-to-end over the real CDP WebSocket transport: launch → newPage → goto → snapshot, plus multi-page Target.createTarget.
  • Manually verified tron run end-to-end for .js and .ts (no build) and --trace (redacted actions.jsonl) against a WS CDP stub launched through tron-session.
  • Full workspace suite green; typecheck/lint clean.

Scope

Requires Node ≥24. click/fill take @refs from a snapshot; richer targets/input later. Full tron run vs a real browser isn't in CI (no Chromium) — covered by layered tests + WS-stub run. See docs/sdk-and-run.md.

🤖 Generated with Claude Code

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>
@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown

vu1nz Security Review

0 finding(s) in PR #?

No security issues found.

@ralyodio
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>
@ralyodio
ralyodio merged commit 9059aed into main Jul 4, 2026
7 checks passed
@ralyodio
ralyodio deleted the worktree-m3.4-sdk-run branch July 4, 2026 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant