Skip to content

Add the WebBrain for websites widget as embed/ - #3288

Open
esokullu wants to merge 2 commits into
webbrain-one:mainfrom
esokullu:embed-widget
Open

esokullu wants to merge 2 commits into
webbrain-one:mainfrom
esokullu:embed-widget

Conversation

@esokullu

Copy link
Copy Markdown
Collaborator

Moves the WebBrain for websites widget (the script site owners add with <script src=".../embed.js">) into this repo as embed/, next to the extension code it is built from. Until now it lived in a separate private repo that pinned this one as a submodule.

Why here

  • embed.js bundles the extension's GPL-3.0-or-later code (accessibility tree, content script, activity indicator, markdown renderer, calculator) and is sent to every visitor of every site that uses it, so its source has to be public. This repo already is.
  • No submodule to keep in sync: the widget always builds from the current extension code.
  • A change to a bundled extension file now runs the widget's build and tests in the same pull request, instead of breaking customer sites later.

What is added

  • embed/src/bundle.js: assembles embed.js from src/chrome plus embed/src/widget-runtime.js (launcher, chat panel, agent loop). Same logic as before, with paths pointing at src/chrome instead of upstream/webbrain.
  • embed/src/agent-spec.js: exports the Ask and Act prompts and tools as tools.json, so the server that answers the widget uses the extension's own definitions.
  • npm run build writes embed/dist/: embed.js, tools.json, icons, VERSION.json (version, commit, source link) and SHA256SUMS. No dependencies to install.
  • embed/test/embed.test.mjs: tool filtering by mode, the bundle's contents (license header and source link included), the agent spec, and the release files and their checksums.
  • .github/workflows/embed.yml: builds and tests on pull requests that touch embed/ or the bundled extension files. Pushing a tag like embed-v1.0.0 publishes a GitHub release with the files above. The release is never marked as the latest, so extension releases stay on top.

How it is used

sites.webbrain.one (private webbrain-sites repo) pins a release with php bin/update-embed.php 1.0.0, which verifies every file against SHA256SUMS, and reports the version and source link from GET /api/meta.

Checks

  • cd embed && npm run build && npm test: 4/4 pass (Node 22 here, Node 26 on macOS), including in a copy of the repo without node_modules, the way CI runs it.
  • Full node test/run.js: 2542 passed, 4 failed. The same 4 fail on main without this change (WebGPU worker contracts, new locales in dropdowns, streamed raw tool-call text, Providers page search box).
  • Loaded the built widget on the playground: it reads the page through the extension's accessibility tree and answers, with no console errors.

After merging, push embed-v1.0.0 to publish the first release.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EsDq6DxFiLVCyWkC3JtHbh

The widget site owners add with <script src=".../embed.js"> now lives
here, next to the extension code it is built from, instead of in a
separate repo that pinned this one as a submodule.

- embed/src/bundle.js assembles embed.js from src/chrome's
  accessibility tree, content script, activity indicator, activity
  brain, markdown renderer and calculator, plus
  embed/src/widget-runtime.js (launcher, chat panel, agent loop).
- embed/src/agent-spec.js exports the Ask and Act prompts and tools as
  tools.json, so the server answering the widget uses the extension's
  own definitions.
- npm run build writes embed/dist/: embed.js, tools.json, icons,
  VERSION.json (version, commit, source link) and SHA256SUMS.
- The Embed widget workflow builds and tests on pull requests that
  touch embed/ or the bundled extension files, and publishes a GitHub
  release on embed-v* tags (never marked as the latest release).

The widget is GPL-3.0-or-later like the rest of WebBrain; every
embed.js states its license and links to its source.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EsDq6DxFiLVCyWkC3JtHbh
@vercel

vercel Bot commented Oct 30, 2026

Copy link
Copy Markdown

@esokullu is attempting to deploy a commit to the esokullu's projects Team on Vercel.

A member of the Team first needs to authorize it.

Security and privacy:
- navigate only follows http(s) URLs and keeps the unsaved-changes guard.
- Tool results no longer carry password, hidden or other credential field
  values (uses the extension's credential-fields.js).
- Page content, the page title and URL, selections and inline-trigger text
  are wrapped like the extension's _wrapUntrusted, with a per-call nonce.
- data-webbrain-act only stages its prompt for the visitor to send, and
  synthetic clicks (the agent's own) never start a run.
- The widget runs only the tools tools.json lists for the turn's mode, and
  Act stays off unless the site config sets modePolicy: "ask_and_act".

Agent loop:
- Each run has its own abort signal and history, so a stopped or replaced
  run never acts again and Stop no longer shows a null.signal error.
- done, Stop and the step limit leave no tool call without a result.
- Hiding the widget host during page actions is re-entrant and skipped for
  waits, so the widget can't be left inert and Stop works during waits.
- The activity indicator gets a heartbeat and is not hidden by an older run.

Tools and UI:
- read_page uses the extension's windowed path; results and page text are
  capped. get_interactive_elements uses the ordering click({index}) reads.
- get_accessibility_tree defaults to "all" and continuationArgs are spread.
- Rich-editor typing and synthetic key presses report what they can't do.
- Wait timeouts follow the requested timeout; content.js gets a deadline.
- Hidden quick chips no longer take page clicks; IME Enter doesn't send;
  widget keys don't reach site shortcuts; `$` in page text stays literal.

Build and CI:
- The bundle is parsed as a classic script, and the build fails when an
  extension helper the widget uses is renamed.
- New test:browser loads embed.js in Chrome; CI runs it and watches
  src/chrome/** plus the root package files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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