{"_id":"@botfather/units-agent-middleware","_rev":"2-f7bc17e7dbecd65710ddb4b7092bbb39","name":"@botfather/units-agent-middleware","dist-tags":{"latest":"0.1.2"},"versions":{"0.1.1":{"name":"@botfather/units-agent-middleware","version":"0.1.1","license":"MIT","_id":"@botfather/units-agent-middleware@0.1.1","maintainers":[{"name":"botfather","email":"mohan.tushar.11@gmail.com"}],"homepage":"https://github.com/Botfather/units/tree/main/packages/units-agent-middleware","bugs":{"url":"https://github.com/Botfather/units/issues"},"dist":{"shasum":"941ebc5340b3d90da486fcfef89af0a5e1e97b7e","tarball":"https://registry.npmjs.org/@botfather/units-agent-middleware/-/units-agent-middleware-0.1.1.tgz","fileCount":5,"integrity":"sha512-jgjZGGtnBqVDKg7uIVRIG4ast8khGmy1XETZMn7aTvbMjuAmHRjsB0O8c91vW0Xf2sxH6vuDd0p+2AtuhFPlLQ==","signatures":[{"sig":"MEUCIHsAutmdbjKTrQjMlYVODcmXqGZO/P5bQLBFBoSPOAjAAiEAv/SFfwdad8f23EgPUmKcjZQpX/Q9IBVXYzYQQXJY8Zo=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@botfather%2funits-agent-middleware@0.1.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":10252},"main":"./index.js","type":"module","_from":"file:botfather-units-agent-middleware-0.1.1.tgz","types":"./index.d.ts","_npmUser":{"name":"botfather","email":"mohan.tushar.11@gmail.com"},"_resolved":"/tmp/39a654d61a2c7be29eb7d0f734144263/botfather-units-agent-middleware-0.1.1.tgz","_integrity":"sha512-jgjZGGtnBqVDKg7uIVRIG4ast8khGmy1XETZMn7aTvbMjuAmHRjsB0O8c91vW0Xf2sxH6vuDd0p+2AtuhFPlLQ==","repository":{"url":"git+https://github.com/Botfather/units.git","type":"git","directory":"packages/units-agent-middleware"},"_npmVersion":"11.17.0","description":"Agent-agnostic middleware for rewriting UI trees with Units transform programs.","directories":{},"_nodeVersion":"22.14.0","dependencies":{"@botfather/units":"2.0.0","@botfather/units-ui-ir":"0.1.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/units-agent-middleware_0.1.1_1782196782677_0.6466418046923028","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@botfather/units-agent-middleware","version":"0.1.2","description":"Agent-agnostic middleware for rewriting UI trees with Units transform programs.","license":"MIT","type":"module","repository":{"type":"git","url":"git+https://github.com/Botfather/units.git","directory":"packages/units-agent-middleware"},"homepage":"https://github.com/Botfather/units/tree/main/packages/units-agent-middleware","bugs":{"url":"https://github.com/Botfather/units/issues"},"main":"./index.js","types":"./index.d.ts","dependencies":{"@botfather/units":"2.0.1","@botfather/units-ui-ir":"0.1.1"},"publishConfig":{"access":"public"},"_id":"@botfather/units-agent-middleware@0.1.2","_integrity":"sha512-II51UMXWNfWAoMMTFA+nFw3L9Tc6wdqi0K7eu3iALMVP/BpD16KQAMkPweTAXQ0n3YkOmgb+O4PAjw59D5LYrw==","_resolved":"/tmp/f4f8fe6d4d70b1e4f9215454562f334e/botfather-units-agent-middleware-0.1.2.tgz","_from":"file:botfather-units-agent-middleware-0.1.2.tgz","_nodeVersion":"24.16.0","_npmVersion":"11.17.0","dist":{"integrity":"sha512-II51UMXWNfWAoMMTFA+nFw3L9Tc6wdqi0K7eu3iALMVP/BpD16KQAMkPweTAXQ0n3YkOmgb+O4PAjw59D5LYrw==","shasum":"f589350b06d83138ca0a8dc641ef4730142fd230","tarball":"https://registry.npmjs.org/@botfather/units-agent-middleware/-/units-agent-middleware-0.1.2.tgz","fileCount":5,"unpackedSize":10252,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@botfather%2funits-agent-middleware@0.1.2","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDBfhB2PcrPWdOzkyakqblnPPxpWWlKkVjeyJV4HOUmkQIgOCB+6jlLMlS4qhosrqoex5fpL4W28g4cGXX+sDdzt2A="}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:64fecf05-838f-4260-bde5-f501e63b043e"}},"directories":{},"maintainers":[{"name":"botfather","email":"mohan.tushar.11@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/units-agent-middleware_0.1.2_1782219357007_0.3805875046446767"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-23T06:39:42.567Z","modified":"2026-06-23T12:55:57.438Z","0.1.1":"2026-06-23T06:39:42.813Z","0.1.2":"2026-06-23T12:55:57.159Z"},"bugs":{"url":"https://github.com/Botfather/units/issues"},"license":"MIT","homepage":"https://github.com/Botfather/units/tree/main/packages/units-agent-middleware","repository":{"type":"git","url":"git+https://github.com/Botfather/units.git","directory":"packages/units-agent-middleware"},"description":"Agent-agnostic middleware for rewriting UI trees with Units transform programs.","maintainers":[{"name":"botfather","email":"mohan.tushar.11@gmail.com"}],"readme":"# @botfather/units-agent-middleware\n\nFramework-agnostic middleware that rewrites host UI trees using verified Units transform programs before passing data to an LLM agent.\n\n## Install\n\n```sh\nnpm install @botfather/units-agent-middleware @botfather/units\n```\n\n## Usage\n\n```js\nimport { createUnitsAgentMiddleware } from \"@botfather/units-agent-middleware\";\n\nconst middleware = createUnitsAgentMiddleware({\n  libraryDir: \".units/library\",\n  gates: {\n    action_recall: 1,\n    name_recall: 0.98,\n    text_f1: 0.95,\n  },\n});\n\nconst result = await middleware.rewrite({\n  tree: rawDomLikeTree,\n  sourceType: \"dom\",\n  taskContext: { task: \"summarize_ui\" },\n});\n```\n\nSupported `sourceType` values include `dom`, `a11y`, `ir`, `react`, and `slack`. Slack Block Kit payloads are normalized through `@botfather/units-ui-ir`; aliases `block-kit`, `blockkit`, and `mrkdwn` also route to `slack`.\n\n`rewrite` returns transformed tree output, trace metadata, chosen program metadata, and fallback pass-through output when no verified program passes gates.\n\nReturned `agent_tree` payloads use compact serialization defaults optimized for token usage (including redundant `name`/`text` dedupe, implicit-action omission, empty text leaf pruning, and text-id omission). Pass `serializerOptions: { includeRedundantNameText: true, includeImplicitActions: true, includeTextIds: true }` to preserve both fields, role-implicit actions, and text ids when needed.\n","readmeFilename":"README.md"}