Skip to content

feat(wasm): add @everruns/markkit-wasm browser and edge package - #32

Merged
chaliy merged 9 commits into
mainfrom
claude/project-thread-mwewa8
Oct 27, 2026
Merged

chaliy merged 9 commits into
mainfrom
claude/project-thread-mwewa8

Conversation

@chaliy

@chaliy chaliy commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Михайло · project thread

What changed

New npm package @everruns/markkit-wasm (crates/markkit-wasm), modeled on bashkit-wasm: Markkit compiled to wasm32-unknown-unknown via wasm-bindgen --target web.

  • Single-threaded: no SharedArrayBuffer, no COOP/COEP headers. Runs in browsers (incl. iframes), Cloudflare/Vercel/Deno edge, Node, Deno, Bun.
  • Features: html, docx, spreadsheet, tool. No URL fetching (reqwest needs sockets; host fetches and keeps network policy).
  • JS API: initMarkkit(), new Markkit(options) with extractHtml, extractDocument (markdown, title, format, warnings, stats, camelCase metadata), extractBytes; new MarkkitTool(options) with toolDefinition(), schemas, systemPrompt(), execute(args) (rejections carry userFacing).
  • Options are camelCase builder fields; unknown keys and wrong types throw invalid options (routed through serde_json::Value, since serde-wasm-bindgen only reads named fields and would silently ignore typos).
  • Hand-written index.d.ts; scripts/build.sh (wasm-release profile, opt-level = "z", optional wasm-opt); scripts/install-wasm-bindgen.sh pins the CLI to Cargo.lock.
  • CI: new wasm job (core cargo check for wasm32, build, node --test, npm archive contents) gating Check. publish-wasm.yml: workflow_dispatch, dry run by default, npm trusted publishing (OIDC).
  • Knowledge: runtimes/wasm-package.md; release process bumps both npm package.json versions (a test pins wasm package.json to the crate version).
  • Cleanup: untracks crates/markkit-wasm/pkg/ build output that slipped into feat(tool): add MarkkitTool LLM agent tool (Everruns toolkit contract) #19's merge commit; .gitignore now covers it.

Why

Roadmap: WASM package like bashkit-wasm, so markkit (and its agent tool) runs where a native addon can't load.

Before / After

Before: no browser/edge option; @everruns/markkit is a Linux x64 native addon only.

After:

$ node --test crates/markkit-wasm/__test__/*.test.mjs
# tests 17
# pass 17
# fail 0

Headless Chromium smoke (plain HTTP server, no special headers): initMarkkit() + extractHtml("<h1>Browser</h1>") + MarkkitTool.execute({html}) → "# Browser\n|tool\n".

Bundle: ~1.4 MB unoptimized .wasm (before wasm-opt).

Risk

  • Low for existing users: new crate; core unchanged.
  • Same untrusted-input guarantees as native (archive/grid limits tested through wasm). With panic = "abort" a parser panic would trap the instance; S9 says parsers return errors.
  • Real publish needs the npm trusted publisher configured for @everruns/markkit-wasm.

Checklist

  • Tests added or updated (17 Node tests: options + validation, HTML, bytes, metadata, DOCX via zip/XML, archive limit, malformed input, version parity, tool)
  • Backward compatibility considered

Opt-in `tool` feature adds markkit::tool: MarkkitToolBuilder -> MarkkitTool
-> single-use ToolExecution, mirroring bashkit's tool module. One call
converts a url, html or base64 document to Markdown; args validated before
execution, base64 bounded before decode, URL via the SSRF guard, output
capped by max_output_chars. Adds Markkit::extract_url_document.
wasm-bindgen build of markkit (html, docx, spreadsheet, tool) for
wasm32-unknown-unknown: single-threaded, no COOP/COEP, no URL fetching.
Markkit class with validated camelCase options plus MarkkitTool. Node
tests, CI job gating Check, and an OIDC npm publisher.
@chaliy chaliy self-assigned this Oct 26, 2026
@chaliy
chaliy merged commit cb0e467 into main Oct 27, 2026
11 checks passed
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