mgamadeus / ddd-browser
Browser sessions and website analysis for mgamadeus/ddd: agent-controllable browsing, screenshots, rendered page to markdown, design extraction, on-site SEO, performance and tech audits
Package info
github.com/ddd-framework/ddd-browser
Language:JavaScript
pkg:composer/mgamadeus/ddd-browser
Requires
- php: >=8.3
- mgamadeus/ddd: ^3.40.0
- mgamadeus/ddd-argus: ^1.7.0
Requires (Dev)
- mgamadeus/ddd-agents: ^0.1.37
- phpunit/phpunit: ^9.5
Suggests
- mgamadeus/ddd-agents: ^0.1.37 — adds the browser session and design tools and skills for agents (owner consent for submissions and unknown URLs)
- mgamadeus/ddd-site-insights: Shows the on-site findings of a page next to its Search Console data
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-24 00:06:20 UTC
README
Browser sessions and website analysis for mgamadeus/ddd: an agent drives a real browser (navigate, accessibility snapshot with refs, click, type, select, keys, scroll, screenshots, tabs) and reads a page's design (design tokens, computed styles with their CSS rules, assets). Page audits (SEO, performance, tech) and site crawls follow in later releases.
One repository, two artefacts released by one tag vX.Y.Z:
| Artefact | Source |
|---|---|
Composer mgamadeus/ddd-browser |
src/, config/, tests/ |
Image ghcr.io/ddd-framework/ddd-browser-renderer:X.Y.Z (private) |
renderer/: real Chrome stable driven by Patchright, Xvfb |
The renderer is a separate service: it has internet, but no data and no secrets except its caller tokens. The application never renders or executes foreign content itself.
Install
composer require mgamadeus/ddd-browser(withmgamadeus/ddd-agents≥ 0.1.37 for the agent tools).- Run the renderer (one deployment in role
stateless, one in rolesession— or one in roleall) and configureconfig/app/Browser/renderer.php(or the env variables it names):BROWSER_RENDERER_ENDPOINT,BROWSER_RENDERER_SESSION_ENDPOINT,BROWSER_RENDERER_TOKEN(the token of this application's caller class). php bin/console app:browser:check-rendererin the deploy: exit 1 when a deployment is unreachable, not ready, speaks an incompatible contract, or the sessions deployment serves no session routes.- Tables (through the schema diff):
BrowserSessions,BrowserSessionEvents. - Switch sessions on:
Browser.sessions.enabled(config/app/Browser/sessions.php). Interactive browsing is for staff only: by default an admin account (BrowserAccessService::isInteractiveBrowsingAllowed(), override in a same-path subclass). - A file sink for exported assets and design token files: a service implementing
DDD\Domain\Browser\Services\BrowserFileSink(autoconfigured, tagbrowser.file_sink). It is the host's upload intake: type from the bytes, executable content refused, malware scan; the file lands in the workspace as untrusted with its origin. Without itbrowserExportAssetsrefuses and design tokens are not saved as a file. Target convention: everything taken from one site goes to the folderweb/<domain>(BrowserFileToStore::$targetFolder) under the renderer's file names (design-tokens.json,logo.svg,logo-on-dark.svg,logo.png,logo-original.<ext>,stylesheet-NN-<name>.css,screenshot-viewport.png,screenshot-page.jpg,font-<name>), side by side: the token file names the logo files. - With ddd-agents: bind the skills in the host's
config/app/AI/skillPackages.php:'Browser.Session' => ['browser.session'],'Browser.Design' => ['browser.design'], and gate them for staff. - A daily cron for
app:browser:purge-sessions(Browser.sessions.retentionDays, default 90).
Agent tools
| Package (skill) | Tools |
|---|---|
browser.session (Browser.Session) |
browserNavigate, browserSnapshot, browserClick, browserType, browserSelectOption, browserPressKey, browserScroll, browserScreenshot, browserTabs, browserClose |
browser.design (Browser.Design) |
browserExtractDesign, browserInspect, browserExportAssets |
Every tool returns untrusted content (page strings inside untrusted marks) and is a READ for the platform
(browserExportAssets writes the workspace). Rules:
- A URL the model writes runs only when it stands in an operator message, is the bare start page of a host an operator message names, or appeared in full in a tool result; following a link by ref always runs. Anything else asks the operator through the ddd-agents owner consent; without an operator it is refused.
- A typed text runs only when it stands in an operator message (at most 200 characters); anything else asks.
- Submissions: the renderer aborts every request that would send data (a non-GET navigation, typed text to
another site) and answers
CONSENT_REQUIREDwith target, fields and values. After the operator's yes the tool repeats the same action once with the renderer's release token. - No credentials: password and payment fields are refused in the renderer; no uploads, no logins, no profile.
- SSRF: a navigation target that is not a public http(s) host is refused before the call; the renderer checks every request and redirect hop again.
- Sessions and their log (navigations with redirects, typed texts, consent questions and releases, refusals, stored
files) are kept in
BrowserSessions/BrowserSessionEventsfor the admin.
Renderer contract
Contract version = the package version; BrowserRendererContract::CONTRACT_VERSION (PHP) and
renderer/package.json "version" (the release workflow writes the tag's version into it before the image build). The
PHP side needs at least BrowserRendererContract::MINIMUM_CONTRACT_VERSION within the same major. Within a major the
contract only grows: the renderer is deployed first, then the PHP release that reads a new field.
- Health:
GET /healthz(no auth): 200{status: "ok", contractVersion, chromeVersion, role}or 503{status: "starting", contractVersion, role}.contractVersionis the full release tag (e.g.0.1.0-rc.3).app:browser:check-renderercompares it by semver compatibility, not by string: same major, core version at leastMINIMUM_CONTRACT_VERSION, a pre-release suffix allowed. The release workflow checks thatCONTRACT_VERSIONis the core of the release tag. - Role: env
RENDER_ROLE=stateless|session|all(defaultstateless). Session routes exist only insessionandall; outside its role the renderer answers 404 (the check command says so). - Caller classes: the renderer's env
RENDER_TOKENS_<CLASS>defines a class (e.g.SHOP_PROD→ caller classshop-prod) with its own limits; a full class answers 429 withRetry-After(the tools say "busy, retry in n s", never retry blindly). PHP sendsX-Render-Token(the host's token of its caller class). - Session routes:
POSTJSON underX-Render-Token, at/browser/session/{open,navigate,snapshot,act,screenshot,tabs,analyse,log,close}.- Envelope: every page outcome is HTTP 200
{status: 200, data: {reason, …}}; a renderer fault is{status, error}with that HTTP status. - Every body carries
sessionKey(random 32 hex) and an optionaltab(t1, default the active tab).navigatewithoutsessionKeyopens a session and returns its key. A key of another caller class, a closed or an expired session answersreason: SESSION_GONEwithcause(idle, maxAge, closed, transferLimit, shutdown, unknown). - Refs:
e12, or with a frame prefixf3e12(BrowserRendererContract::REF_PATTERN, checked before the call). navigate{url, tab?, newTab?, cookieBanners?}→{sessionKey, tab, finalUrl, statusCode, title, redirects[], consent: {cmp, action}, challengeVendor?, snapshot: {mode: "outline", text, …}}snapshot{mode: outline|interactive|text, ref?, find?, cursor?, maxChars? (6000)}→{text, nextCursor|null, items}; a ref of an older snapshot →STALE_REF.act{action: click|type|select|press|scroll, ref, text?, submit?, values?, key?, direction?, releaseToken?}→{url, title, navigated, changed (≤ 1,500 characters), newTabs[], dialogs[], released[], releaseUsed (when a releaseToken was sent), submissions[]}.CONSENT_REQUIRED:submissions[{kind, method, target (origin + path), url, resourceType, frame, fields[{name, value, typed}], typed[], releaseToken, expiresAt}].kind: submissionis releasable: PHP asks the operator and, after the yes, repeats the same act withreleaseToken, which lets exactly one matching request through, once (method + origin + path + hash of the field names and typed values; 15 minutes, this session only).kind: dropped(a script request carrying typed text to another site,releaseToken: null) is gone for good: the tool says so and asks nobody.- Reasons:
OK,SESSION_GONE,STALE_REF,BLOCKED,UNRESOLVABLE,TOO_MANY_REDIRECTS,TIMEOUT,FETCH_FAILED,BOT_CHALLENGE(challengeVendor),CONSENT_REQUIRED,FIELD_REFUSED,NOT_A_FIELD,INVALID_OPTION,RELEASE_INVALID,ACTION_FAILED,ACTION_TIMEOUT,TAB_LIMIT,NO_SUCH_TAB,LIMIT_REACHED,OUT_OF_RANGE,NO_PAGE,UNSUPPORTED_FRAME,BUSY; each becomes a tool sentence with the next move (BrowserAgentAnswersService::buildRefusalText()). - Deadlines in the renderer: navigate 45 s, analyse 60 s, others 30–40 s. PHP waits up to
Browser.renderer.sessionActionTimeoutSeconds(65); the tools' execution ceilings are above that (80 s, 140 s for a tool that may call twice). screenshot{target: viewport|element|fullPage, ref?, fromY?, height?, format?, quality?}→{content (base64), format, width, height, truncated}. PHP cuts the parts (4,000 px as two pictures) and decodes the image through Core'sRasterImageDecoder(PNG/JPEG only).tabs{action: list|open|select|close, tab?, url?}→{tabs[{tab, url, title, active}]}analyse{name: design|inspect|assets, ref?, properties?, kinds?}:design→{tokens, summary (markdown ≤ 5,000)}.tokensis passed through unchanged and stored asweb/<domain>/design-tokens.json:palette {primary, accent, text, textMuted, surface, background, border, link},paletteDetails,chart[],contrast[],typography.h1|h2|h3|body|button {family, stack, category, fallback, …},fonts[],scales.radius|shadow|spacing [{value, count}],components,logo {file: "logo.png", svgFile, onDarkFile, …},customProperties {total, top[]},source {url, title, fetchedAt, viewport}.inspect→{element, styles, box, rules[], summary}(main frame only).assets(kinds: stylesheets, logo, screenshots, fonts) →{files[{kind, name, mimeType, sourceUrl, size, content (base64)}], skipped[], note}. Names:logo.svg(sanitized),logo-on-dark.svg,logo.png,logo-original.<ext>,stylesheet-NN-<name>.css,screenshot-viewport.png,screenshot-page.jpg,font-<name>. The host's file sink stores them under these names next todesign-tokens.json; the type is read from the bytes (themimeTypeis a hint), an SVG is only ever a stored file.
- There is no
/browser/fetchroute: asset bytes come only throughanalyse assets. log{since?}→{events[{seq, time, type, …}], nextSeq}close→{reason: "CLOSED"}
- Envelope: every page outcome is HTTP 200
Console
| Command | |
|---|---|
app:browser:check-renderer [--format=json] |
the deploy check of both deployments (exit 1 on a problem) |
app:browser:purge-sessions [--dryRun] |
deletes sessions and their log after the retention time (500 per run) |
License
MIT. The renderer image bundles Google Chrome (proprietary) and third-party components with their own licences; see
renderer/.