Skip to content

v0.3.0 — production-ready SDK surface + action executor - #2

Merged
rrader26 merged 1 commit into
mainfrom
feat/v0.3.0-runtime-sdk
May 10, 2026
Merged

v0.3.0 — production-ready SDK surface + action executor#2
rrader26 merged 1 commit into
mainfrom
feat/v0.3.0-runtime-sdk

Conversation

@rrader26

Copy link
Copy Markdown
Contributor

Summary

First production-ready release. Builds the high-level SDK surface, structured error hierarchy, observability hooks, and session persistence on top of the v0.2 wire-format conversion.

  • createBrowser() / Browser / Page — small SDK surface (page.goto, page.snapshot, page.execute) any AI can drive. Library-only — no agent loop, no LLM client, no prompts. Caller (Claude, GPT, AP flow, etc.) brings the loop.
  • executeAction() covers all 17 ActionTypes with a single execute(actionId, value?) entry point. Validates values, classifies errors, disposes handles in finally.
  • Error hierarchyAgentMarkErrorSnapshotError, ExecutionError (+ 5 specialized subclasses), SessionError. Stable error codes, prototype-chain safe, isAgentMarkError() type guard.
  • Branded IDsActionId, MediaId, RegionId for nominal type safety with zero runtime cost.
  • Logger — pluggable Logger interface; noopLogger (default) + consoleLogger (JSON-lines). Typed AgentMarkEvent event catalog.
  • Sessionsbrowser.saveSession(path) + sessionPath option, atomic temp+rename writes, versioned file format.
  • Honeypot refusal — bot-trap fields throw ActionDisabledError, never execute.

Numbers

  • 141 tests (was 90): 25 executor unit + 5 session unit + 11 benchmark + 10 real-Chromium integration + 90 pre-existing.
  • 55× overall token reduction vs simulated raw HTML across the fixture suite (per-fixture range 43-72×). Locked in as a benchmark assertion to catch serializer regressions.
  • < 5ms per build+serialize on every fixture (averaged over 100 iterations).
  • Build clean with strict: true, zero any in new code.

CI changes

Three jobs now gate publish:

  • test — Node 20 + 22 unit tests on Linux
  • integration — installs Chromium, runs AGENTMARK_INTEGRATION=1 against the new SDK surface
  • macos-smoke — catches cross-platform regressions in converter / serializer paths

Test plan

  • npm install && npm run build && npm test — all 131 unit + benchmark tests pass
  • AGENTMARK_INTEGRATION=1 npm test (with Chromium installed) — 10 integration tests pass
  • CI: green on test, integration, macos-smoke
  • Smoke-test the SDK end-to-end: npx tsx examples/basic.ts
  • Smoke-test the caller's-loop pattern: ANTHROPIC_API_KEY=… npx tsx examples/with-claude.ts "find the contact email" "https://example.com"
  • Verify no breaking changes to existing exports: convertPage(), serializeSnapshot(), parseSnapshot(), validateSnapshot(), InMemoryActionBinding all still importable and work
  • Skim the new public API in src/index.ts for naming consistency
  • CHANGELOG.md and README.md read sensibly to a fresh visitor

🤖 Generated with Claude Code

…vability (v0.3.0)

This is the first production-ready release. Adds the high-level SDK surface,
structured error hierarchy, observability hooks, and session persistence on
top of the v0.2 wire-format conversion.

API additions
- createBrowser() / Browser / Page wrappers — small surface (page.goto,
  page.snapshot, page.execute) hides Playwright details while keeping
  .raw escape hatches.
- executeAction() covers all 17 ActionTypes with one execute(actionId, value?)
  entry point. Resolves binding, dispatches Playwright op, validates value
  types, classifies errors, disposes element handles in finally.
- AgentMarkError hierarchy with stable error codes: SnapshotError,
  ExecutionError (+ ActionNotFoundError, ActionDisabledError, ActionTypeError,
  ElementNotFoundError, ExecutionTimeoutError), SessionError. Prototype-chain
  preserved; isAgentMarkError() type guard.
- Branded ID types — ActionId, MediaId, RegionId for nominal type safety,
  zero runtime overhead.
- Pluggable Logger interface — noopLogger (default, zero-overhead) and
  consoleLogger (JSON-lines for dev). Threaded through Browser → Page →
  executor; emits typed AgentMarkEvent strings.
- Session persistence — browser.saveSession(path) / sessionPath option for
  cookie + storageState round-trips. Atomic write via temp+rename.
  Versioned file format (session_format: '1').
- Honeypot refusal — actions marked honeypot: true throw ActionDisabledError.

Tests (141 total, all passing)
- 25 new unit tests for the executor (pre-flight validation, value types,
  element resolution, observability, error hierarchy, prototype chain).
- 5 new unit tests for session persistence (load, version mismatch, missing
  fields, invalid JSON, missing file).
- 11 new benchmark tests with absolute byte budgets per fixture and 5ms
  speed budgets. Prints compression-ratio summary table on every run
  (current baseline: 55x overall token savings vs simulated raw HTML).
- 10 new real-Chromium integration tests gated on AGENTMARK_INTEGRATION=1.
  Covers snapshot capture, form fill + submit + redirect (including the
  password-redaction security feature), disabled-action refusal,
  navigation invalidation, session round-trip across browser instances,
  idempotent close, end-to-end logger event flow.

Infra
- CI now has three jobs: test (Node 20+22 unit), integration (Chromium +
  AGENTMARK_INTEGRATION=1), macos-smoke (cross-platform regression catch).
  All gate publish.
- examples/basic.ts — snapshot + dump available actions to stdout.
- examples/with-claude.ts — caller's-loop demo using @anthropic-ai/sdk
  tool use; proves library-only positioning by showing the loop lives in
  the caller, not in AgentMark.
- CHANGELOG.md — full v0.3.0 release notes plus retroactive v0.2.0 / v0.1.0.
- README rewritten with SDK quick-start as headline; observability and
  error-handling sections added; lower-level APIs preserved.

Production-readiness gates cleared
- Type safety: zero any in new code; branded IDs prevent type confusion
- Error taxonomy: full hierarchy, stable codes, prototype-chain safe
- Observability: every public op emits structured events; default no-op
- Atomic writes: sessions never leave partial files
- Backwards compatibility: all 90 v0.2 tests still passing
- Cross-platform: build clean; CI now Linux + macOS

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

2 participants