@maind-dev/mcp-bridge 0.4.3 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/build/index.js +5081 -153
  2. package/build/meta.json +1 -0
  3. package/package.json +10 -4
  4. package/build/auth.js +0 -179
  5. package/build/auth.js.map +0 -1
  6. package/build/client-detect.js +0 -109
  7. package/build/client-detect.js.map +0 -1
  8. package/build/device-id.js +0 -149
  9. package/build/device-id.js.map +0 -1
  10. package/build/forward.js +0 -433
  11. package/build/forward.js.map +0 -1
  12. package/build/index.js.map +0 -1
  13. package/build/install/atomic-write.js +0 -115
  14. package/build/install/atomic-write.js.map +0 -1
  15. package/build/install/browser-pair.js +0 -139
  16. package/build/install/browser-pair.js.map +0 -1
  17. package/build/install/client-targets.js +0 -135
  18. package/build/install/client-targets.js.map +0 -1
  19. package/build/install/flags.js +0 -139
  20. package/build/install/flags.js.map +0 -1
  21. package/build/install/hook-merge.js +0 -195
  22. package/build/install/hook-merge.js.map +0 -1
  23. package/build/install/index.js +0 -187
  24. package/build/install/index.js.map +0 -1
  25. package/build/install/json-merge.js +0 -160
  26. package/build/install/json-merge.js.map +0 -1
  27. package/build/install/preamble.js +0 -119
  28. package/build/install/preamble.js.map +0 -1
  29. package/build/install/project-root.js +0 -120
  30. package/build/install/project-root.js.map +0 -1
  31. package/build/install/report.js +0 -89
  32. package/build/install/report.js.map +0 -1
  33. package/build/install/telemetry.js +0 -83
  34. package/build/install/telemetry.js.map +0 -1
  35. package/build/install/toml-merge.js +0 -148
  36. package/build/install/toml-merge.js.map +0 -1
  37. package/build/project-key.js +0 -73
  38. package/build/project-key.js.map +0 -1
  39. package/build/version.js +0 -7
  40. package/build/version.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"inputs":{"src/client-detect.ts":{"bytes":3979,"imports":[],"format":"esm"},"src/forward.ts":{"bytes":20978,"imports":[{"path":"node:readline","kind":"import-statement","external":true},{"path":"node:timers/promises","kind":"import-statement","external":true},{"path":"src/client-detect.ts","kind":"import-statement","original":"./client-detect.js"}],"format":"esm"},"src/device-id.ts":{"bytes":5476,"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:os","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"src/auth.ts":{"bytes":8214,"imports":[{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:os","kind":"import-statement","external":true},{"path":"src/device-id.ts","kind":"import-statement","original":"./device-id.js"}],"format":"esm"},"src/version.ts":{"bytes":305,"imports":[],"format":"esm"},"src/project-key.ts":{"bytes":2719,"imports":[{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true}],"format":"esm"},"src/install/flags.ts":{"bytes":5802,"imports":[],"format":"esm"},"src/install/report.ts":{"bytes":4292,"imports":[],"format":"esm"},"src/install/project-root.ts":{"bytes":4032,"imports":[{"path":"node:fs/promises","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"node:readline","kind":"import-statement","external":true}],"format":"esm"},"src/install/client-targets.ts":{"bytes":5727,"imports":[{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"src/install/atomic-write.ts":{"bytes":4154,"imports":[{"path":"node:fs/promises","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"src/install/json-merge.ts":{"bytes":5180,"imports":[{"path":"src/install/atomic-write.ts","kind":"import-statement","original":"./atomic-write.js"}],"format":"esm"},"src/install/toml-merge.ts":{"bytes":4819,"imports":[{"path":"smol-toml","kind":"import-statement","external":true},{"path":"src/install/atomic-write.ts","kind":"import-statement","original":"./atomic-write.js"}],"format":"esm"},"../../packages/integration-snippets/build/index.js":{"bytes":35437,"imports":[],"format":"esm"},"src/install/preamble.ts":{"bytes":4556,"imports":[{"path":"node:path","kind":"import-statement","external":true},{"path":"../../packages/integration-snippets/build/index.js","kind":"import-statement","original":"@maind-dev/integration-snippets"},{"path":"src/install/atomic-write.ts","kind":"import-statement","original":"./atomic-write.js"}],"format":"esm"},"src/install/hook-merge.ts":{"bytes":8176,"imports":[{"path":"node:path","kind":"import-statement","external":true},{"path":"node:readline","kind":"import-statement","external":true},{"path":"src/install/atomic-write.ts","kind":"import-statement","original":"./atomic-write.js"}],"format":"esm"},"src/install/browser-pair.ts":{"bytes":4543,"imports":[{"path":"src/auth.ts","kind":"import-statement","original":"../auth.js"},{"path":"src/device-id.ts","kind":"import-statement","original":"../device-id.js"}],"format":"esm"},"src/install/telemetry.ts":{"bytes":3027,"imports":[],"format":"esm"},"src/install/index.ts":{"bytes":7285,"imports":[{"path":"node:os","kind":"import-statement","external":true},{"path":"src/version.ts","kind":"import-statement","original":"../version.js"},{"path":"src/install/flags.ts","kind":"import-statement","original":"./flags.js"},{"path":"src/install/report.ts","kind":"import-statement","original":"./report.js"},{"path":"src/install/project-root.ts","kind":"import-statement","original":"./project-root.js"},{"path":"src/install/client-targets.ts","kind":"import-statement","original":"./client-targets.js"},{"path":"src/install/json-merge.ts","kind":"import-statement","original":"./json-merge.js"},{"path":"src/install/toml-merge.ts","kind":"import-statement","original":"./toml-merge.js"},{"path":"src/install/preamble.ts","kind":"import-statement","original":"./preamble.js"},{"path":"src/install/hook-merge.ts","kind":"import-statement","original":"./hook-merge.js"},{"path":"src/install/browser-pair.ts","kind":"import-statement","original":"./browser-pair.js"},{"path":"src/install/telemetry.ts","kind":"import-statement","original":"./telemetry.js"}],"format":"esm"},"../../packages/project-key/build/index.js":{"bytes":3446,"imports":[{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true}],"format":"esm"},"../../packages/code-index/build/parse/keys.js":{"bytes":448,"imports":[],"format":"esm"},"../../packages/code-index/build/parse/types.js":{"bytes":768,"imports":[],"format":"esm"},"../../packages/code-index/build/parse/lang/shared.js":{"bytes":2278,"imports":[],"format":"esm"},"../../packages/code-index/build/parse/lang/python.js":{"bytes":4535,"imports":[{"path":"../../packages/code-index/build/parse/keys.js","kind":"import-statement","original":"../keys.js"},{"path":"../../packages/code-index/build/parse/lang/shared.js","kind":"import-statement","original":"./shared.js"}],"format":"esm"},"../../packages/code-index/build/parse/lang/typescript.js":{"bytes":5949,"imports":[{"path":"../../packages/code-index/build/parse/keys.js","kind":"import-statement","original":"../keys.js"},{"path":"../../packages/code-index/build/parse/lang/shared.js","kind":"import-statement","original":"./shared.js"}],"format":"esm"},"../../packages/code-index/build/parse/tree-sitter/grammars.js":{"bytes":1941,"imports":[{"path":"node:module","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"../../packages/code-index/build/parse/tree-sitter/parser.js":{"bytes":3231,"imports":[{"path":"node:path","kind":"import-statement","external":true},{"path":"web-tree-sitter","kind":"import-statement","external":true},{"path":"../../packages/code-index/build/parse/keys.js","kind":"import-statement","original":"../keys.js"},{"path":"../../packages/code-index/build/parse/types.js","kind":"import-statement","original":"../types.js"},{"path":"../../packages/code-index/build/parse/lang/python.js","kind":"import-statement","original":"../lang/python.js"},{"path":"../../packages/code-index/build/parse/lang/typescript.js","kind":"import-statement","original":"../lang/typescript.js"},{"path":"../../packages/code-index/build/parse/lang/shared.js","kind":"import-statement","original":"../lang/shared.js"},{"path":"../../packages/code-index/build/parse/tree-sitter/grammars.js","kind":"import-statement","original":"./grammars.js"}],"format":"esm"},"../../packages/code-index/build/embed/recipe.js":{"bytes":594,"imports":[],"format":"esm"},"../../packages/code-index/build/embed/types.js":{"bytes":505,"imports":[],"format":"esm"},"../../packages/code-index/build/util/vector.js":{"bytes":707,"imports":[],"format":"esm"},"../../packages/code-index/build/graph/resolve.js":{"bytes":3928,"imports":[{"path":"node:path","kind":"import-statement","external":true},{"path":"../../packages/code-index/build/parse/keys.js","kind":"import-statement","original":"../parse/keys.js"}],"format":"esm"},"../../packages/code-index/build/incremental/discover.js":{"bytes":5200,"imports":[{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"../../packages/code-index/build/parse/types.js","kind":"import-statement","original":"../parse/types.js"}],"format":"esm"},"../../packages/code-index/build/store/schema.js":{"bytes":3047,"imports":[],"format":"esm"},"../../packages/code-index/build/util/identifiers.js":{"bytes":2180,"imports":[],"format":"esm"},"../../packages/code-index/build/query/engine.js":{"bytes":14302,"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"../../packages/code-index/build/embed/recipe.js","kind":"import-statement","original":"../embed/recipe.js"},{"path":"../../packages/code-index/build/embed/types.js","kind":"import-statement","original":"../embed/types.js"},{"path":"../../packages/code-index/build/util/vector.js","kind":"import-statement","original":"../util/vector.js"},{"path":"../../packages/code-index/build/graph/resolve.js","kind":"import-statement","original":"../graph/resolve.js"},{"path":"../../packages/code-index/build/incremental/discover.js","kind":"import-statement","original":"../incremental/discover.js"},{"path":"../../packages/code-index/build/store/schema.js","kind":"import-statement","original":"../store/schema.js"},{"path":"../../packages/code-index/build/util/identifiers.js","kind":"import-statement","original":"../util/identifiers.js"}],"format":"esm"},"../../packages/code-index/build/store/node-sqlite.js":{"bytes":11850,"imports":[{"path":"better-sqlite3","kind":"import-statement","external":true},{"path":"../../packages/code-index/build/store/schema.js","kind":"import-statement","original":"./schema.js"},{"path":"../../packages/code-index/build/util/identifiers.js","kind":"import-statement","original":"../util/identifiers.js"}],"format":"esm"},"../../packages/code-index/build/sync/types.js":{"bytes":1779,"imports":[{"path":"node:crypto","kind":"import-statement","external":true}],"format":"esm"},"../../packages/code-index/build/sync/client.js":{"bytes":10021,"imports":[{"path":"../../packages/code-index/build/store/schema.js","kind":"import-statement","original":"../store/schema.js"},{"path":"../../packages/code-index/build/sync/types.js","kind":"import-statement","original":"./types.js"}],"format":"esm"},"../../packages/code-index/build/node.js":{"bytes":2578,"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"../../packages/project-key/build/index.js","kind":"import-statement","original":"@maind/project-key"},{"path":"../../packages/code-index/build/parse/tree-sitter/parser.js","kind":"import-statement","original":"./parse/tree-sitter/parser.js"},{"path":"../../packages/code-index/build/query/engine.js","kind":"import-statement","original":"./query/engine.js"},{"path":"../../packages/code-index/build/store/node-sqlite.js","kind":"import-statement","original":"./store/node-sqlite.js"},{"path":"../../packages/code-index/build/sync/client.js","kind":"import-statement","original":"./sync/client.js"},{"path":"../../packages/code-index/build/sync/client.js","kind":"import-statement","original":"./sync/client.js"}],"format":"esm"},"src/local-tools/engine.ts":{"bytes":1138,"imports":[{"path":"node:child_process","kind":"import-statement","external":true},{"path":"../../packages/code-index/build/node.js","kind":"import-statement","original":"@maind/code-index/node"}],"format":"esm"},"src/local-tools/token-estimate.ts":{"bytes":898,"imports":[],"format":"esm"},"src/local-tools/savings.ts":{"bytes":3781,"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"src/local-tools/token-estimate.ts","kind":"import-statement","original":"./token-estimate.js"}],"format":"esm"},"src/local-tools/tools.ts":{"bytes":9138,"imports":[{"path":"node:crypto","kind":"import-statement","external":true}],"format":"esm"},"src/local-tools/router.ts":{"bytes":5550,"imports":[{"path":"src/local-tools/engine.ts","kind":"import-statement","original":"./engine.js"},{"path":"src/local-tools/savings.ts","kind":"import-statement","original":"./savings.js"},{"path":"src/local-tools/tools.ts","kind":"import-statement","original":"./tools.js"}],"format":"esm"},"src/functions-origin.ts":{"bytes":714,"imports":[],"format":"esm"},"src/metrics-post.ts":{"bytes":2619,"imports":[{"path":"src/functions-origin.ts","kind":"import-statement","original":"./functions-origin.js"}],"format":"esm"},"../../packages/claude-code-telemetry/dist/types.js":{"bytes":338,"imports":[],"format":"esm"},"../../packages/claude-code-telemetry/dist/transcript.js":{"bytes":2017,"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:fs/promises","kind":"import-statement","external":true},{"path":"node:readline","kind":"import-statement","external":true}],"format":"esm"},"../../packages/claude-code-telemetry/dist/decisions.js":{"bytes":6845,"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:readline","kind":"import-statement","external":true}],"format":"esm"},"../../packages/claude-code-telemetry/dist/effort.js":{"bytes":1858,"imports":[],"format":"esm"},"../../packages/claude-code-telemetry/dist/session-analysis.js":{"bytes":12237,"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:readline","kind":"import-statement","external":true},{"path":"../../packages/claude-code-telemetry/dist/effort.js","kind":"import-statement","original":"./effort.js"}],"format":"esm"},"../../packages/claude-code-telemetry/dist/parse.js":{"bytes":7254,"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:readline","kind":"import-statement","external":true},{"path":"../../packages/claude-code-telemetry/dist/effort.js","kind":"import-statement","original":"./effort.js"},{"path":"../../packages/claude-code-telemetry/dist/types.js","kind":"import-statement","original":"./types.js"}],"format":"esm"},"../../packages/claude-code-telemetry/dist/windows.js":{"bytes":3963,"imports":[],"format":"esm"},"../../packages/claude-code-telemetry/dist/projects.js":{"bytes":3166,"imports":[{"path":"node:fs/promises","kind":"import-statement","external":true},{"path":"node:os","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true}],"format":"esm"},"../../packages/claude-code-telemetry/dist/index.js":{"bytes":685,"imports":[{"path":"../../packages/claude-code-telemetry/dist/types.js","kind":"import-statement","original":"./types.js"},{"path":"../../packages/claude-code-telemetry/dist/transcript.js","kind":"import-statement","original":"./transcript.js"},{"path":"../../packages/claude-code-telemetry/dist/decisions.js","kind":"import-statement","original":"./decisions.js"},{"path":"../../packages/claude-code-telemetry/dist/session-analysis.js","kind":"import-statement","original":"./session-analysis.js"},{"path":"../../packages/claude-code-telemetry/dist/parse.js","kind":"import-statement","original":"./parse.js"},{"path":"../../packages/claude-code-telemetry/dist/effort.js","kind":"import-statement","original":"./effort.js"},{"path":"../../packages/claude-code-telemetry/dist/windows.js","kind":"import-statement","original":"./windows.js"},{"path":"../../packages/claude-code-telemetry/dist/projects.js","kind":"import-statement","original":"./projects.js"}],"format":"esm"},"src/session-end/index.ts":{"bytes":3483,"imports":[{"path":"../../packages/claude-code-telemetry/dist/index.js","kind":"import-statement","original":"@maind/claude-code-telemetry"},{"path":"src/device-id.ts","kind":"import-statement","original":"../device-id.js"},{"path":"src/version.ts","kind":"import-statement","original":"../version.js"}],"format":"esm"},"src/index.ts":{"bytes":9764,"imports":[{"path":"node:crypto","kind":"import-statement","external":true},{"path":"src/forward.ts","kind":"import-statement","original":"./forward.js"},{"path":"src/device-id.ts","kind":"import-statement","original":"./device-id.js"},{"path":"src/auth.ts","kind":"import-statement","original":"./auth.js"},{"path":"src/version.ts","kind":"import-statement","original":"./version.js"},{"path":"src/project-key.ts","kind":"import-statement","original":"./project-key.js"},{"path":"src/install/index.ts","kind":"import-statement","original":"./install/index.js"},{"path":"src/local-tools/router.ts","kind":"import-statement","original":"./local-tools/router.js"},{"path":"src/local-tools/savings.ts","kind":"import-statement","original":"./local-tools/savings.js"},{"path":"src/metrics-post.ts","kind":"import-statement","original":"./metrics-post.js"},{"path":"src/session-end/index.ts","kind":"dynamic-import","original":"./session-end/index.js"}],"format":"esm"}},"outputs":{"build/index.js":{"imports":[{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:os","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:readline","kind":"import-statement","external":true},{"path":"node:os","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:readline","kind":"import-statement","external":true},{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:os","kind":"import-statement","external":true},{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:os","kind":"import-statement","external":true},{"path":"node:fs/promises","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"node:readline","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"node:fs/promises","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"smol-toml","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"node:readline","kind":"import-statement","external":true},{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"web-tree-sitter","kind":"import-statement","external":true},{"path":"node:module","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"node:child_process","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"better-sqlite3","kind":"import-statement","external":true},{"path":"node:fs","kind":"import-statement","external":true},{"path":"node:path","kind":"import-statement","external":true},{"path":"node:crypto","kind":"import-statement","external":true}],"exports":[],"entryPoint":"src/index.ts","inputs":{"src/device-id.ts":{"bytesInOutput":2356},"src/version.ts":{"bytesInOutput":126},"../../packages/claude-code-telemetry/dist/types.js":{"bytesInOutput":110},"../../packages/claude-code-telemetry/dist/transcript.js":{"bytesInOutput":120},"../../packages/claude-code-telemetry/dist/decisions.js":{"bytesInOutput":118},"../../packages/claude-code-telemetry/dist/effort.js":{"bytesInOutput":596},"../../packages/claude-code-telemetry/dist/session-analysis.js":{"bytesInOutput":7774},"../../packages/claude-code-telemetry/dist/parse.js":{"bytesInOutput":147},"../../packages/claude-code-telemetry/dist/windows.js":{"bytesInOutput":219},"../../packages/claude-code-telemetry/dist/projects.js":{"bytesInOutput":326},"../../packages/claude-code-telemetry/dist/index.js":{"bytesInOutput":279},"src/session-end/index.ts":{"bytesInOutput":2476},"src/index.ts":{"bytesInOutput":5306},"src/forward.ts":{"bytesInOutput":13217},"src/client-detect.ts":{"bytesInOutput":2068},"src/auth.ts":{"bytesInOutput":5107},"src/project-key.ts":{"bytesInOutput":1318},"src/install/index.ts":{"bytesInOutput":5049},"src/install/flags.ts":{"bytesInOutput":4255},"src/install/report.ts":{"bytesInOutput":3091},"src/install/project-root.ts":{"bytesInOutput":2188},"src/install/client-targets.ts":{"bytesInOutput":2805},"src/install/atomic-write.ts":{"bytesInOutput":1758},"src/install/json-merge.ts":{"bytesInOutput":3341},"src/install/toml-merge.ts":{"bytesInOutput":3262},"src/install/preamble.ts":{"bytesInOutput":2812},"../../packages/integration-snippets/build/index.js":{"bytesInOutput":27539},"src/install/hook-merge.ts":{"bytesInOutput":5372},"src/install/browser-pair.ts":{"bytesInOutput":2701},"src/install/telemetry.ts":{"bytesInOutput":1798},"src/local-tools/engine.ts":{"bytesInOutput":481},"../../packages/code-index/build/node.js":{"bytesInOutput":530},"../../packages/code-index/build/parse/tree-sitter/parser.js":{"bytesInOutput":2043},"../../packages/code-index/build/parse/keys.js":{"bytesInOutput":169},"../../packages/code-index/build/parse/types.js":{"bytesInOutput":546},"../../packages/code-index/build/parse/lang/shared.js":{"bytesInOutput":1131},"../../packages/code-index/build/parse/lang/python.js":{"bytesInOutput":3747},"../../packages/code-index/build/parse/lang/typescript.js":{"bytesInOutput":4716},"../../packages/code-index/build/parse/tree-sitter/grammars.js":{"bytesInOutput":523},"../../packages/code-index/build/query/engine.js":{"bytesInOutput":10593},"../../packages/code-index/build/embed/recipe.js":{"bytesInOutput":197},"../../packages/code-index/build/embed/types.js":{"bytesInOutput":105},"../../packages/code-index/build/util/vector.js":{"bytesInOutput":339},"../../packages/code-index/build/graph/resolve.js":{"bytesInOutput":2482},"../../packages/code-index/build/incremental/discover.js":{"bytesInOutput":3513},"../../packages/code-index/build/store/schema.js":{"bytesInOutput":2170},"../../packages/code-index/build/util/identifiers.js":{"bytesInOutput":1094},"../../packages/code-index/build/store/node-sqlite.js":{"bytesInOutput":9759},"src/local-tools/savings.ts":{"bytesInOutput":1923},"src/local-tools/token-estimate.ts":{"bytesInOutput":133},"src/local-tools/tools.ts":{"bytesInOutput":7492},"src/local-tools/router.ts":{"bytesInOutput":3827},"src/functions-origin.ts":{"bytesInOutput":259},"src/metrics-post.ts":{"bytesInOutput":1285}},"bytes":169635}}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maind-dev/mcp-bridge",
3
- "version": "0.4.3",
3
+ "version": "0.8.0",
4
4
  "description": "Local MCP bridge for maind.dev — wraps any MCP-compatible client (Claude Code, Cursor, Windsurf) and pins your API key to a single device via the maind device authorization flow.",
5
5
  "type": "module",
6
6
  "main": "./build/index.js",
@@ -13,13 +13,19 @@
13
13
  ],
14
14
  "dependencies": {
15
15
  "@modelcontextprotocol/sdk": "^1.0.0",
16
+ "better-sqlite3": "^12.11.1",
16
17
  "smol-toml": "^1.3.1",
17
- "@maind-dev/integration-snippets": "0.1.0"
18
+ "tree-sitter-wasms": "^0.1.13",
19
+ "web-tree-sitter": "0.24.7"
18
20
  },
19
21
  "devDependencies": {
20
22
  "@types/node": "^20.11.0",
23
+ "esbuild": "^0.24.0",
21
24
  "tsx": "^4.7.0",
22
- "typescript": "^5.4.0"
25
+ "typescript": "^5.4.0",
26
+ "@maind-dev/integration-snippets": "0.1.0",
27
+ "@maind/claude-code-telemetry": "0.0.0",
28
+ "@maind/code-index": "0.0.0"
23
29
  },
24
30
  "engines": {
25
31
  "node": ">=20.0.0"
@@ -36,7 +42,7 @@
36
42
  "access": "public"
37
43
  },
38
44
  "scripts": {
39
- "build": "tsc && chmod +x build/index.js",
45
+ "build": "node scripts/bundle.mjs",
40
46
  "start": "node build/index.js",
41
47
  "dev": "node --watch --watch-path=src --import tsx src/index.ts",
42
48
  "test": "node --import tsx --test 'test/**/*.test.ts'",
package/build/auth.js DELETED
@@ -1,179 +0,0 @@
1
- // Device-Authorization-Flow client (RFC 8628, adapted for Supabase Edge Functions).
2
- //
3
- // Mirrors apps/vscode-extension/src/auth/deviceFlow.ts. The server side
4
- // (device-authorization-start / -poll Edge Functions + approve_device_authorization
5
- // RPC chain) is shared between the bridge and the VS Code extension. By using
6
- // the same flow we get the existing devices-aggregate + revoke-on-pair
7
- // (ADR-103) for free.
8
- //
9
- // Critical: the bridge speaks MCP over stdio. STDOUT is reserved for the JSON-RPC
10
- // protocol — any progress or auth-flow text MUST go to STDERR. Writing to
11
- // STDOUT here would corrupt the MCP framing and crash the upstream client.
12
- import { spawn } from "node:child_process";
13
- import { platform } from "node:os";
14
- import { clientMeta, writeApiKey, clearApiKey, ensureDeviceId } from "./device-id.js";
15
- /**
16
- * Default Supabase Edge Function origin. Override via env `MAIND_FUNCTIONS_ORIGIN`
17
- * for self-hosted/preview environments. Production points at the maind
18
- * project's Supabase Functions endpoint.
19
- */
20
- const DEFAULT_FUNCTIONS_ORIGIN = "https://vsddmiosisvfrairepxv.supabase.co/functions/v1";
21
- function functionsOrigin() {
22
- const v = process.env.MAIND_FUNCTIONS_ORIGIN;
23
- return v && v.length > 0 ? v.replace(/\/+$/, "") : DEFAULT_FUNCTIONS_ORIGIN;
24
- }
25
- /**
26
- * Runs the device-authorization flow end-to-end:
27
- * 1. POST /device-authorization-start → user_code + verification_uri_complete
28
- * 2. Open the verification URL in the user's default browser (best-effort)
29
- * 3. Print the user_code to STDERR as a fallback (so the user can paste manually)
30
- * 4. Poll /device-authorization-poll every `interval` seconds until approved/denied/expired
31
- *
32
- * On approval, persists the returned api_key to disk (api-key file in configDir)
33
- * and returns it for immediate use. On denial/expiry/timeout, returns null —
34
- * the caller should exit non-zero so the MCP client treats the bridge as failed.
35
- */
36
- export async function runDeviceFlow(version) {
37
- const origin = functionsOrigin();
38
- const startUrl = `${origin}/device-authorization-start`;
39
- const pollUrl = `${origin}/device-authorization-poll`;
40
- const meta = clientMeta(version);
41
- const label = `mcp-bridge-${meta.device_id.slice(0, 8)}`;
42
- const startRes = await fetch(startUrl, {
43
- method: "POST",
44
- headers: { "content-type": "application/json" },
45
- body: JSON.stringify({ label, meta }),
46
- });
47
- if (!startRes.ok) {
48
- const txt = await startRes.text();
49
- throw new Error(`device-authorization-start failed: ${startRes.status} ${txt}`);
50
- }
51
- const start = (await startRes.json());
52
- // Best-effort browser open. If it fails (headless servers, CI, restricted
53
- // sandbox), the printed verification_uri + user_code is the fallback path.
54
- await openExternalBrowser(start.verification_uri_complete).catch(() => {
55
- // ignore — printed instructions below cover the fallback
56
- });
57
- printAuthInstructions(start);
58
- const deadline = Date.now() + start.expires_in * 1000;
59
- const intervalMs = Math.max(start.interval, 3) * 1000;
60
- while (Date.now() < deadline) {
61
- await sleep(intervalMs);
62
- const poll = await pollOnce(pollUrl, start.device_code).catch((e) => {
63
- // Transient network failures shouldn't abort the flow; the user has
64
- // expires_in seconds to sort it out. Log to stderr for visibility.
65
- process.stderr.write(`[maind-mcp-bridge] poll error (will retry): ${String(e)}\n`);
66
- return null;
67
- });
68
- if (!poll)
69
- continue;
70
- if (poll.status === "approved") {
71
- writeApiKey(poll.api_key);
72
- process.stderr.write(`[maind-mcp-bridge] signed in (plan: ${poll.plan}). API key saved to ~/.config/maind/api-key\n`);
73
- return { apiKey: poll.api_key, plan: poll.plan };
74
- }
75
- if (poll.status === "denied") {
76
- process.stderr.write("[maind-mcp-bridge] sign-in denied by user\n");
77
- return null;
78
- }
79
- if (poll.status === "expired" || poll.status === "consumed") {
80
- process.stderr.write(`[maind-mcp-bridge] sign-in ${poll.status}\n`);
81
- return null;
82
- }
83
- // status: "pending" → keep polling
84
- }
85
- process.stderr.write("[maind-mcp-bridge] sign-in timed out\n");
86
- return null;
87
- }
88
- async function pollOnce(url, deviceCode) {
89
- const res = await fetch(url, {
90
- method: "POST",
91
- headers: { "content-type": "application/json" },
92
- body: JSON.stringify({ device_code: deviceCode }),
93
- });
94
- if (!res.ok) {
95
- const txt = await res.text();
96
- throw new Error(`poll ${res.status}: ${txt}`);
97
- }
98
- return (await res.json());
99
- }
100
- function sleep(ms) {
101
- return new Promise((resolve) => setTimeout(resolve, ms));
102
- }
103
- function printAuthInstructions(start) {
104
- const lines = [
105
- "",
106
- " ┌─────────────────────────────────────────────────────────────────┐",
107
- " │ │",
108
- " │ maind-mcp-bridge — first-time setup │",
109
- " │ │",
110
- " │ Approve this bridge to bind it to your maind account: │",
111
- " │ │",
112
- ` │ Open: ${pad(start.verification_uri, 56)} │`,
113
- ` │ Code: ${pad(start.user_code, 56)} │`,
114
- " │ │",
115
- ` │ (expires in ${Math.round(start.expires_in / 60)} minutes)`.padEnd(67) + "│",
116
- " │ │",
117
- " └─────────────────────────────────────────────────────────────────┘",
118
- "",
119
- ];
120
- // STDERR — STDOUT is the MCP framing channel
121
- process.stderr.write(lines.join("\n") + "\n");
122
- }
123
- function pad(s, width) {
124
- if (s.length >= width)
125
- return s.slice(0, width);
126
- return s + " ".repeat(width - s.length);
127
- }
128
- /**
129
- * Spawns a platform-appropriate command to open the given URL in the user's
130
- * default browser. Detached so it doesn't keep the bridge process alive.
131
- * Errors are swallowed — the printed verification_uri + user_code in
132
- * printAuthInstructions() is the fallback path.
133
- */
134
- async function openExternalBrowser(url) {
135
- let cmd;
136
- let args;
137
- switch (platform()) {
138
- case "darwin":
139
- cmd = "open";
140
- args = [url];
141
- break;
142
- case "win32":
143
- cmd = "cmd";
144
- args = ["/c", "start", "", url];
145
- break;
146
- default:
147
- cmd = "xdg-open";
148
- args = [url];
149
- break;
150
- }
151
- return new Promise((resolve, reject) => {
152
- try {
153
- const child = spawn(cmd, args, {
154
- stdio: "ignore",
155
- detached: true,
156
- });
157
- child.on("error", reject);
158
- child.unref();
159
- // Resolve immediately — we don't wait for the browser process to finish.
160
- resolve();
161
- }
162
- catch (err) {
163
- reject(err);
164
- }
165
- });
166
- }
167
- /**
168
- * Forces a re-authorization after the server reports the api_key was revoked.
169
- * The device-id is preserved — the server will recognize the re-pair on its
170
- * side and atomically revoke the old key + bind the new one (see ADR-103
171
- * `upsert_device_on_pair`).
172
- */
173
- export async function reauthorize(version) {
174
- clearApiKey();
175
- // Make sure the device-id is materialised even if it wasn't before.
176
- ensureDeviceId();
177
- return runDeviceFlow(version);
178
- }
179
- //# sourceMappingURL=auth.js.map
package/build/auth.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,EAAE;AACF,wEAAwE;AACxE,oFAAoF;AACpF,8EAA8E;AAC9E,uEAAuE;AACvE,sBAAsB;AACtB,EAAE;AACF,kFAAkF;AAClF,0EAA0E;AAC1E,2EAA2E;AAE3E,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAqBtF;;;;GAIG;AACH,MAAM,wBAAwB,GAAG,uDAAuD,CAAC;AAEzF,SAAS,eAAe;IACtB,MAAM,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC;IAC7C,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,wBAAwB,CAAC;AAC9E,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,OAAe;IACjD,MAAM,MAAM,GAAG,eAAe,EAAE,CAAC;IACjC,MAAM,QAAQ,GAAG,GAAG,MAAM,6BAA6B,CAAC;IACxD,MAAM,OAAO,GAAG,GAAG,MAAM,4BAA4B,CAAC;IAEtD,MAAM,IAAI,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IACjC,MAAM,KAAK,GAA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ages/types/src/client-families.ts — DO NOT EDIT IN ISOLATION.
2
- //
3
- // This file lives in the bridge package so the published npm artifact stays
4
- // self-contained (no workspace runtime imports). The mapping MUST match the
5
- // canonical version at packages/types/src/client-families.ts byte-for-byte
6
- // (or at least value-for-value) — apps/mcp-bridge/test/client-detect.test.ts
7
- // asserts data-equivalence and will fail CI on drift.
8
- //
9
- // When adding a new client family or rename pattern: update BOTH files in the
10
- // same commit. The pre-commit hook (Block 5) catches diffs that touch
11
- // apps/mcp-bridge/src/ without a corresponding package.json version bump,
12
- // which is the failure mode that caused the multi-day Codex-as-mcp-bridge
13
- // mis-attribution incident on 2026-05-24..28.
14
- export const CLIENT_FAMILIES = [
15
- "claude-code",
16
- "codex",
17
- "copilot",
18
- "cursor",
19
- "windsurf",
20
- "mcp-bridge",
21
- "vscode-extension",
22
- "claude-desktop",
23
- "mcp-inspector",
24
- "maind-cli",
25
- "unknown",
26
- ];
27
- export const CLIENT_INFO_NAME_PATTERNS = [
28
- // Anthropic
29
- ["claude-code", "claude-code"],
30
- ["claude-cli", "claude-code"],
31
- ["claude-desktop", "claude-desktop"],
32
- ["claude.app", "claude-desktop"],
33
- // OpenAI
34
- ["openai-codex", "codex"],
35
- ["codex-cli", "codex"],
36
- ["codex", "codex"],
37
- // GitHub / Microsoft
38
- ["github-copilot", "copilot"],
39
- ["vscode-copilot", "copilot"],
40
- ["copilot", "copilot"],
41
- // Editors / IDE clients
42
- ["cursor", "cursor"],
43
- ["windsurf", "windsurf"],
44
- ["codeium", "windsurf"],
45
- ["vscode-extension", "vscode-extension"],
46
- ["maind-vscode", "vscode-extension"],
47
- // Tooling
48
- ["mcp-inspector", "mcp-inspector"],
49
- // Headless CI CLI (@maind-dev/cli — `maind context`). Matched before the
50
- // bridge entry; "maind-cli" is not a substring of "maind-mcp-bridge".
51
- ["maind-cli", "maind-cli"],
52
- // Bridge identifying itself explicitly (rare; usually we want the upstream client)
53
- ["maind-mcp-bridge", "mcp-bridge"],
54
- ];
55
- export function mapClientInfoNameToFamily(rawName) {
56
- if (typeof rawName !== "string")
57
- return null;
58
- const name = rawName.trim().toLowerCase();
59
- if (name.length === 0)
60
- return null;
61
- for (const [pattern, family] of CLIENT_INFO_NAME_PATTERNS) {
62
- if (name.includes(pattern))
63
- return family;
64
- }
65
- return null;
66
- }
67
- /**
68
- * Parses an arbitrary string that the bridge is forwarding as a JSON-RPC frame
69
- * and, if it's an MCP `initialize` request with a usable clientInfo.name,
70
- * returns the canonical family + version. Returns null for everything else.
71
- *
72
- * Used by Forwarder.forwardFrame() to auto-detect the client family from the
73
- * very first frame without requiring per-user MAIND_CLIENT_FAMILY config.
74
- *
75
- * Defensively try/catch: a malformed frame is normal (clients send all sorts
76
- * of garbage); we never throw here. Worst case = null = no auto-detection.
77
- */
78
- export function tryExtractInitializeClient(frame) {
79
- let parsed;
80
- try {
81
- parsed = JSON.parse(frame);
82
- }
83
- catch {
84
- return null;
85
- }
86
- if (!isRecord(parsed))
87
- return null;
88
- if (parsed.method !== "initialize")
89
- return null;
90
- const params = parsed.params;
91
- if (!isRecord(params))
92
- return null;
93
- const clientInfo = params.clientInfo;
94
- if (!isRecord(clientInfo))
95
- return null;
96
- const rawName = clientInfo.name;
97
- const family = mapClientInfoNameToFamily(typeof rawName === "string" ? rawName : null);
98
- if (family === null)
99
- return null;
100
- const rawVersion = clientInfo.version;
101
- const version = typeof rawVersion === "string" && rawVersion.length > 0
102
- ? rawVersion.slice(0, 64)
103
- : null;
104
- return { family, version };
105
- }
106
- function isRecord(v) {
107
- return typeof v === "object" && v !== null && !Array.isArray(v);
108
- }
109
- //# sourceMappingURL=client-detect.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client-detect.js","sourceRoot":"","sources":["../src/client-detect.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,EAAE;AACF,4EAA4E;AAC5E,4EAA4E;AAC5E,2EAA2E;AAC3E,6EAA6E;AAC7E,sDAAsD;AACtD,EAAE;AACF,8EAA8E;AAC9E,s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D,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC;QACzB,CAAC,CAAC,IAAI,CAAC;IACX,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AAC7B,CAAC;AAED,SAAS,QAAQ,CAAC,CAAU;IAC1B,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAClE,CAAC"}
@@ -1,149 +0,0 @@
1
- // Stable device identifier persisted on disk. Generated once on first run and
2
- // reused for every subsequent invocation of the bridge. Survives bridge
3
- // upgrades and `npx` cache invalidations because it's stored OUTSIDE the
4
- // package directory (in the user's config dir).
5
- //
6
- // Same role as `ensureDeviceId()` in apps/vscode-extension/src/util/platform.ts —
7
- // the server side relies on this UUID to dedupe (user_id, device_id) and
8
- // revoke the previously-bound api_key on re-pair (see migration
9
- // 20260518000012_devices_aggregate_table.sql).
10
- import { existsSync, mkdirSync, readFileSync, writeFileSync, chmodSync } from "node:fs";
11
- import { homedir, hostname, platform, release } from "node:os";
12
- import { randomUUID } from "node:crypto";
13
- import { join } from "node:path";
14
- /**
15
- * Returns the XDG-style config directory for maind on this platform.
16
- *
17
- * - macOS: `~/Library/Application Support/maind`
18
- * - Linux/BSD: `$XDG_CONFIG_HOME/maind` (default `~/.config/maind`)
19
- * - Windows: `%APPDATA%/maind` (defaults to `~/AppData/Roaming/maind`)
20
- *
21
- * The directory is created on first access with 0700 permissions — the
22
- * api-key file is stored alongside the device-id and must not be world-readable.
23
- */
24
- export function configDir() {
25
- const home = homedir();
26
- const env = process.env;
27
- if (platform() === "darwin") {
28
- return join(home, "Library", "Application Support", "maind");
29
- }
30
- if (platform() === "win32") {
31
- const appdata = env.APPDATA && env.APPDATA.length > 0
32
- ? env.APPDATA
33
- : join(home, "AppData", "Roaming");
34
- return join(appdata, "maind");
35
- }
36
- const xdg = env.XDG_CONFIG_HOME && env.XDG_CONFIG_HOME.length > 0
37
- ? env.XDG_CONFIG_HOME
38
- : join(home, ".config");
39
- return join(xdg, "maind");
40
- }
41
- function ensureDir(path) {
42
- if (existsSync(path))
43
- return;
44
- mkdirSync(path, { recursive: true, mode: 0o700 });
45
- }
46
- const DEVICE_ID_FILE = "device-id";
47
- const API_KEY_FILE = "api-key";
48
- /**
49
- * Reads the persisted device-id, generating one on first call. The value is a
50
- * v4 UUID so it can be sent verbatim to /device-authorization-start as
51
- * `client_meta.device_id` (same shape the VS Code extension uses).
52
- *
53
- * The file is plain text — no encryption needed. Knowledge of the device_id
54
- * alone does not authorize anything; it's an opaque dedup key, not a credential.
55
- */
56
- export function ensureDeviceId() {
57
- const dir = configDir();
58
- ensureDir(dir);
59
- const file = join(dir, DEVICE_ID_FILE);
60
- if (existsSync(file)) {
61
- const stored = readFileSync(file, "utf8").trim();
62
- if (isUuid(stored))
63
- return stored;
64
- // File corrupt or written by a different version — regenerate. Better to
65
- // bind a new device than crash; the user can /devices/unpair the orphan.
66
- }
67
- const id = randomUUID();
68
- writeFileSync(file, id + "\n", { encoding: "utf8", mode: 0o600 });
69
- try {
70
- chmodSync(file, 0o600);
71
- }
72
- catch {
73
- // best-effort; some filesystems (FAT, exFAT on USB sticks) ignore chmod
74
- }
75
- return id;
76
- }
77
- const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
78
- function isUuid(s) {
79
- return UUID_RE.test(s);
80
- }
81
- /**
82
- * Returns the full path to the api-key file. Used by auth.ts to persist the
83
- * key returned by the device-authorization flow.
84
- */
85
- export function apiKeyPath() {
86
- return join(configDir(), API_KEY_FILE);
87
- }
88
- /**
89
- * Persists the api-key with 0600 permissions in the same directory as the
90
- * device-id. Overwrites any existing key (used during re-auth after a server
91
- * 401 device_revoked response).
92
- */
93
- export function writeApiKey(key) {
94
- const dir = configDir();
95
- ensureDir(dir);
96
- const file = apiKeyPath();
97
- writeFileSync(file, key + "\n", { encoding: "utf8", mode: 0o600 });
98
- try {
99
- chmodSync(file, 0o600);
100
- }
101
- catch {
102
- // ignore — see comment in ensureDeviceId()
103
- }
104
- }
105
- /**
106
- * Reads the persisted api-key, returns null if not yet authorized. Trimmed
107
- * because writeApiKey appends a newline.
108
- */
109
- export function readApiKey() {
110
- const file = apiKeyPath();
111
- if (!existsSync(file))
112
- return null;
113
- const raw = readFileSync(file, "utf8").trim();
114
- return raw.length > 0 ? raw : null;
115
- }
116
- /**
117
- * Removes the api-key (but keeps the device-id). Called after a server-side
118
- * revoke so the next invocation triggers a fresh device-flow with the same
119
- * device-id, which the server will recognize as a re-pair and atomically
120
- * revoke the old key + bind the new one via upsert_device_on_pair.
121
- */
122
- export function clearApiKey() {
123
- const file = apiKeyPath();
124
- if (!existsSync(file))
125
- return;
126
- writeFileSync(file, "", { encoding: "utf8", mode: 0o600 });
127
- }
128
- /**
129
- * Best-effort identifier sent in `client_meta.label` so the user can identify
130
- * the binding in the dashboard `/devices` list. Falls back to a static string
131
- * if hostname lookup fails.
132
- */
133
- export function bridgeLabel() {
134
- try {
135
- return `mcp-bridge-${hostname()}`;
136
- }
137
- catch {
138
- return "mcp-bridge";
139
- }
140
- }
141
- export function clientMeta(version) {
142
- return {
143
- os: `${platform()} ${release()}`,
144
- ide: "mcp-bridge",
145
- ext_version: version,
146
- device_id: ensureDeviceId(),
147
- };
148
- }
149
- //# sourceMappingURL=device-id.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"device-id.js","sourceRoot":"","sources":["../src/device-id.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,wEAAwE;AACxE,yEAAyE;AACzE,gDAAgD;AAChD,EAAE;AACF,kFAAkF;AAClF,yEAAyE;AACzE,gEAAgE;AAChE,+CAA+C;AAE/C,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACxF,OAAO,EAAE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