orbitx 0.0.8 → 0.0.9
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.
- package/Readme.md +227 -67
- package/dist/core/agent-providers.d.ts +16 -0
- package/dist/core/agent-providers.d.ts.map +1 -0
- package/dist/core/agent-providers.js +21 -0
- package/dist/core/agent-providers.js.map +1 -0
- package/dist/core/ai-provider.d.ts +69 -1
- package/dist/core/ai-provider.d.ts.map +1 -1
- package/dist/core/ai-provider.js.map +1 -1
- package/dist/core/base-agent.d.ts +8 -4
- package/dist/core/base-agent.d.ts.map +1 -1
- package/dist/core/base-agent.js +220 -88
- package/dist/core/base-agent.js.map +1 -1
- package/dist/core/deepseek-provider.d.ts +10 -3
- package/dist/core/deepseek-provider.d.ts.map +1 -1
- package/dist/core/deepseek-provider.js +144 -39
- package/dist/core/deepseek-provider.js.map +1 -1
- package/dist/core/image-describer.d.ts +13 -0
- package/dist/core/image-describer.d.ts.map +1 -0
- package/dist/core/image-describer.js +33 -0
- package/dist/core/image-describer.js.map +1 -0
- package/dist/core/mcp-client.d.ts +17 -4
- package/dist/core/mcp-client.d.ts.map +1 -1
- package/dist/core/mcp-client.js +32 -16
- package/dist/core/mcp-client.js.map +1 -1
- package/dist/core/mcp-computer.d.ts +10 -2
- package/dist/core/mcp-computer.d.ts.map +1 -1
- package/dist/core/mcp-computer.js +108 -2
- package/dist/core/mcp-computer.js.map +1 -1
- package/dist/core/mcp-fs-storage.d.ts +8 -0
- package/dist/core/mcp-fs-storage.d.ts.map +1 -0
- package/dist/core/mcp-fs-storage.js +27 -0
- package/dist/core/mcp-fs-storage.js.map +1 -0
- package/dist/core/mcp-rng.d.ts +7 -0
- package/dist/core/mcp-rng.d.ts.map +1 -0
- package/dist/core/mcp-rng.js +14 -0
- package/dist/core/mcp-rng.js.map +1 -0
- package/dist/core/mcp-server.d.ts +8 -4
- package/dist/core/mcp-server.d.ts.map +1 -1
- package/dist/core/mcp-server.js +20 -3
- package/dist/core/mcp-server.js.map +1 -1
- package/dist/core/mcp-storage.d.ts +5 -0
- package/dist/core/mcp-storage.d.ts.map +1 -0
- package/dist/core/mcp-storage.js +3 -0
- package/dist/core/mcp-storage.js.map +1 -0
- package/dist/core/mcp.d.ts +37 -3
- package/dist/core/mcp.d.ts.map +1 -1
- package/dist/core/mcp.js +42 -1
- package/dist/core/mcp.js.map +1 -1
- package/dist/core/ollama-provider.d.ts +10 -3
- package/dist/core/ollama-provider.d.ts.map +1 -1
- package/dist/core/ollama-provider.js +122 -41
- package/dist/core/ollama-provider.js.map +1 -1
- package/dist/core/retry.d.ts +10 -0
- package/dist/core/retry.d.ts.map +1 -0
- package/dist/core/retry.js +39 -0
- package/dist/core/retry.js.map +1 -0
- package/dist/core/skill.d.ts +3 -0
- package/dist/core/skill.d.ts.map +1 -1
- package/dist/core/skill.js.map +1 -1
- package/dist/core/tool-schema-translator.d.ts +10 -0
- package/dist/core/tool-schema-translator.d.ts.map +1 -0
- package/dist/core/tool-schema-translator.js +29 -0
- package/dist/core/tool-schema-translator.js.map +1 -0
- package/dist/index.d.ts +34 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +25 -5
- package/dist/index.js.map +1 -1
- package/dist/sandbox.d.ts +2 -0
- package/dist/sandbox.d.ts.map +1 -0
- package/dist/sandbox.js +27 -0
- package/dist/sandbox.js.map +1 -0
- package/dist/skills/backend-security.d.ts +4 -0
- package/dist/skills/backend-security.d.ts.map +1 -0
- package/dist/skills/backend-security.js +74 -0
- package/dist/skills/backend-security.js.map +1 -0
- package/dist/skills/big-task.d.ts +4 -0
- package/dist/skills/big-task.d.ts.map +1 -0
- package/dist/skills/big-task.js +66 -0
- package/dist/skills/big-task.js.map +1 -0
- package/dist/skills/code-verification.d.ts +4 -0
- package/dist/skills/code-verification.d.ts.map +1 -0
- package/dist/skills/code-verification.js +59 -0
- package/dist/skills/code-verification.js.map +1 -0
- package/dist/skills/long-task-efficiency.d.ts +4 -0
- package/dist/skills/long-task-efficiency.d.ts.map +1 -0
- package/dist/skills/long-task-efficiency.js +50 -0
- package/dist/skills/long-task-efficiency.js.map +1 -0
- package/dist/skills/node-backend.d.ts +4 -0
- package/dist/skills/node-backend.d.ts.map +1 -0
- package/dist/skills/node-backend.js +110 -0
- package/dist/skills/node-backend.js.map +1 -0
- package/dist/skills/planner.d.ts +4 -0
- package/dist/skills/planner.d.ts.map +1 -0
- package/dist/skills/planner.js +49 -0
- package/dist/skills/planner.js.map +1 -0
- package/dist/skills/present.d.ts +4 -0
- package/dist/skills/present.d.ts.map +1 -0
- package/dist/skills/present.js +56 -0
- package/dist/skills/present.js.map +1 -0
- package/dist/skills/question-answer.d.ts +4 -0
- package/dist/skills/question-answer.d.ts.map +1 -0
- package/dist/skills/question-answer.js +55 -0
- package/dist/skills/question-answer.js.map +1 -0
- package/dist/skills/react-frontend.d.ts +4 -0
- package/dist/skills/react-frontend.d.ts.map +1 -0
- package/dist/skills/react-frontend.js +111 -0
- package/dist/skills/react-frontend.js.map +1 -0
- package/dist/skills/research.d.ts +4 -0
- package/dist/skills/research.d.ts.map +1 -0
- package/dist/skills/research.js +81 -0
- package/dist/skills/research.js.map +1 -0
- package/dist/skills/shopping.d.ts +4 -0
- package/dist/skills/shopping.d.ts.map +1 -0
- package/dist/skills/shopping.js +71 -0
- package/dist/skills/shopping.js.map +1 -0
- package/dist/skills/ui-ux-design.d.ts +4 -0
- package/dist/skills/ui-ux-design.d.ts.map +1 -0
- package/dist/skills/ui-ux-design.js +70 -0
- package/dist/skills/ui-ux-design.js.map +1 -0
- package/dist/skills/web-end-to-end-test.d.ts +4 -0
- package/dist/skills/web-end-to-end-test.d.ts.map +1 -0
- package/dist/skills/web-end-to-end-test.js +76 -0
- package/dist/skills/web-end-to-end-test.js.map +1 -0
- package/dist/templates/simple.d.ts +1 -1
- package/dist/templates/simple.d.ts.map +1 -1
- package/dist/templates/simple.js +4 -0
- package/dist/templates/simple.js.map +1 -1
- package/dist/tests/mcp.test.js +2 -54
- package/dist/tests/mcp.test.js.map +1 -1
- package/dist/tools/bash/index.d.ts +10 -0
- package/dist/tools/bash/index.d.ts.map +1 -0
- package/dist/tools/bash/index.js +22 -0
- package/dist/tools/bash/index.js.map +1 -0
- package/dist/tools/bash/interaction.d.ts +29 -0
- package/dist/tools/bash/interaction.d.ts.map +1 -0
- package/dist/tools/bash/interaction.js +13 -0
- package/dist/tools/bash/interaction.js.map +1 -0
- package/dist/tools/bash/list.d.ts +4 -0
- package/dist/tools/bash/list.d.ts.map +1 -0
- package/dist/tools/bash/list.js +23 -0
- package/dist/tools/bash/list.js.map +1 -0
- package/dist/tools/bash/logs.d.ts +4 -0
- package/dist/tools/bash/logs.d.ts.map +1 -0
- package/dist/tools/bash/logs.js +47 -0
- package/dist/tools/bash/logs.js.map +1 -0
- package/dist/tools/bash/process-manager.d.ts +35 -0
- package/dist/tools/bash/process-manager.d.ts.map +1 -0
- package/dist/tools/bash/process-manager.js +137 -0
- package/dist/tools/bash/process-manager.js.map +1 -0
- package/dist/tools/bash/run.d.ts +5 -0
- package/dist/tools/bash/run.d.ts.map +1 -0
- package/dist/tools/bash/run.js +57 -0
- package/dist/tools/bash/run.js.map +1 -0
- package/dist/tools/bash/terminate.d.ts +5 -0
- package/dist/tools/bash/terminate.d.ts.map +1 -0
- package/dist/tools/bash/terminate.js +39 -0
- package/dist/tools/bash/terminate.js.map +1 -0
- package/dist/tools/bash/wait.d.ts +5 -0
- package/dist/tools/bash/wait.d.ts.map +1 -0
- package/dist/tools/bash/wait.js +50 -0
- package/dist/tools/bash/wait.js.map +1 -0
- package/dist/tools/bash/write-input.d.ts +5 -0
- package/dist/tools/bash/write-input.d.ts.map +1 -0
- package/dist/tools/bash/write-input.js +47 -0
- package/dist/tools/bash/write-input.js.map +1 -0
- package/dist/tools/browser/click.d.ts +5 -0
- package/dist/tools/browser/click.d.ts.map +1 -0
- package/dist/tools/browser/click.js +44 -0
- package/dist/tools/browser/click.js.map +1 -0
- package/dist/tools/browser/console.d.ts +4 -0
- package/dist/tools/browser/console.d.ts.map +1 -0
- package/dist/tools/browser/console.js +41 -0
- package/dist/tools/browser/console.js.map +1 -0
- package/dist/tools/browser/create-session.d.ts +5 -0
- package/dist/tools/browser/create-session.d.ts.map +1 -0
- package/dist/tools/browser/create-session.js +30 -0
- package/dist/tools/browser/create-session.js.map +1 -0
- package/dist/tools/browser/evaluate-safe.d.ts +10 -0
- package/dist/tools/browser/evaluate-safe.d.ts.map +1 -0
- package/dist/tools/browser/evaluate-safe.js +65 -0
- package/dist/tools/browser/evaluate-safe.js.map +1 -0
- package/dist/tools/browser/fill.d.ts +5 -0
- package/dist/tools/browser/fill.d.ts.map +1 -0
- package/dist/tools/browser/fill.js +78 -0
- package/dist/tools/browser/fill.js.map +1 -0
- package/dist/tools/browser/get-sessions.d.ts +4 -0
- package/dist/tools/browser/get-sessions.d.ts.map +1 -0
- package/dist/tools/browser/get-sessions.js +14 -0
- package/dist/tools/browser/get-sessions.js.map +1 -0
- package/dist/tools/browser/index.d.ts +19 -0
- package/dist/tools/browser/index.d.ts.map +1 -0
- package/dist/tools/browser/index.js +49 -0
- package/dist/tools/browser/index.js.map +1 -0
- package/dist/tools/browser/inject.d.ts +5 -0
- package/dist/tools/browser/inject.d.ts.map +1 -0
- package/dist/tools/browser/inject.js +51 -0
- package/dist/tools/browser/inject.js.map +1 -0
- package/dist/tools/browser/interaction.d.ts +49 -0
- package/dist/tools/browser/interaction.d.ts.map +1 -0
- package/dist/tools/browser/interaction.js +14 -0
- package/dist/tools/browser/interaction.js.map +1 -0
- package/dist/tools/browser/navigate.d.ts +5 -0
- package/dist/tools/browser/navigate.d.ts.map +1 -0
- package/dist/tools/browser/navigate.js +39 -0
- package/dist/tools/browser/navigate.js.map +1 -0
- package/dist/tools/browser/network-status.d.ts +4 -0
- package/dist/tools/browser/network-status.d.ts.map +1 -0
- package/dist/tools/browser/network-status.js +35 -0
- package/dist/tools/browser/network-status.js.map +1 -0
- package/dist/tools/browser/network.d.ts +4 -0
- package/dist/tools/browser/network.d.ts.map +1 -0
- package/dist/tools/browser/network.js +51 -0
- package/dist/tools/browser/network.js.map +1 -0
- package/dist/tools/browser/read-page.d.ts +45 -0
- package/dist/tools/browser/read-page.d.ts.map +1 -0
- package/dist/tools/browser/read-page.js +264 -0
- package/dist/tools/browser/read-page.js.map +1 -0
- package/dist/tools/browser/read.d.ts +5 -0
- package/dist/tools/browser/read.d.ts.map +1 -0
- package/dist/tools/browser/read.js +56 -0
- package/dist/tools/browser/read.js.map +1 -0
- package/dist/tools/browser/remove-session.d.ts +5 -0
- package/dist/tools/browser/remove-session.d.ts.map +1 -0
- package/dist/tools/browser/remove-session.js +29 -0
- package/dist/tools/browser/remove-session.js.map +1 -0
- package/dist/tools/browser/screenshot.d.ts +5 -0
- package/dist/tools/browser/screenshot.d.ts.map +1 -0
- package/dist/tools/browser/screenshot.js +50 -0
- package/dist/tools/browser/screenshot.js.map +1 -0
- package/dist/tools/browser/scroll-info.d.ts +4 -0
- package/dist/tools/browser/scroll-info.d.ts.map +1 -0
- package/dist/tools/browser/scroll-info.js +28 -0
- package/dist/tools/browser/scroll-info.js.map +1 -0
- package/dist/tools/browser/scroll.d.ts +5 -0
- package/dist/tools/browser/scroll.d.ts.map +1 -0
- package/dist/tools/browser/scroll.js +43 -0
- package/dist/tools/browser/scroll.js.map +1 -0
- package/dist/tools/browser/session-manager.d.ts +35 -0
- package/dist/tools/browser/session-manager.d.ts.map +1 -0
- package/dist/tools/browser/session-manager.js +101 -0
- package/dist/tools/browser/session-manager.js.map +1 -0
- package/dist/tools/browser/submit-form.d.ts +5 -0
- package/dist/tools/browser/submit-form.d.ts.map +1 -0
- package/dist/tools/browser/submit-form.js +45 -0
- package/dist/tools/browser/submit-form.js.map +1 -0
- package/dist/tools/fs/create-dir.d.ts +5 -0
- package/dist/tools/fs/create-dir.d.ts.map +1 -0
- package/dist/tools/fs/create-dir.js +28 -0
- package/dist/tools/fs/create-dir.js.map +1 -0
- package/dist/tools/fs/delete.d.ts +5 -0
- package/dist/tools/fs/delete.d.ts.map +1 -0
- package/dist/tools/fs/delete.js +45 -0
- package/dist/tools/fs/delete.js.map +1 -0
- package/dist/tools/fs/edit-file.d.ts +5 -0
- package/dist/tools/fs/edit-file.d.ts.map +1 -0
- package/dist/tools/fs/edit-file.js +74 -0
- package/dist/tools/fs/edit-file.js.map +1 -0
- package/dist/tools/fs/index.d.ts +11 -2
- package/dist/tools/fs/index.d.ts.map +1 -1
- package/dist/tools/fs/index.js +27 -2
- package/dist/tools/fs/index.js.map +1 -1
- package/dist/tools/fs/interaction.d.ts +37 -0
- package/dist/tools/fs/interaction.d.ts.map +1 -0
- package/dist/tools/fs/interaction.js +13 -0
- package/dist/tools/fs/interaction.js.map +1 -0
- package/dist/tools/fs/list-dir.d.ts +5 -0
- package/dist/tools/fs/list-dir.d.ts.map +1 -0
- package/dist/tools/fs/list-dir.js +87 -0
- package/dist/tools/fs/list-dir.js.map +1 -0
- package/dist/tools/fs/move.d.ts +5 -0
- package/dist/tools/fs/move.d.ts.map +1 -0
- package/dist/tools/fs/move.js +44 -0
- package/dist/tools/fs/move.js.map +1 -0
- package/dist/tools/fs/read-file.d.ts +4 -3
- package/dist/tools/fs/read-file.d.ts.map +1 -1
- package/dist/tools/fs/read-file.js +50 -42
- package/dist/tools/fs/read-file.js.map +1 -1
- package/dist/tools/fs/stat.d.ts +5 -0
- package/dist/tools/fs/stat.d.ts.map +1 -0
- package/dist/tools/fs/stat.js +40 -0
- package/dist/tools/fs/stat.js.map +1 -0
- package/dist/tools/fs/utils.d.ts +20 -0
- package/dist/tools/fs/utils.d.ts.map +1 -0
- package/dist/tools/fs/utils.js +33 -0
- package/dist/tools/fs/utils.js.map +1 -0
- package/dist/tools/fs/write-file.d.ts +4 -3
- package/dist/tools/fs/write-file.d.ts.map +1 -1
- package/dist/tools/fs/write-file.js +39 -58
- package/dist/tools/fs/write-file.js.map +1 -1
- package/dist/tools/present/add.d.ts +5 -0
- package/dist/tools/present/add.d.ts.map +1 -0
- package/dist/tools/present/add.js +54 -0
- package/dist/tools/present/add.js.map +1 -0
- package/dist/tools/present/clear.d.ts +5 -0
- package/dist/tools/present/clear.d.ts.map +1 -0
- package/dist/tools/present/clear.js +23 -0
- package/dist/tools/present/clear.js.map +1 -0
- package/dist/tools/present/get-list.d.ts +5 -0
- package/dist/tools/present/get-list.d.ts.map +1 -0
- package/dist/tools/present/get-list.js +24 -0
- package/dist/tools/present/get-list.js.map +1 -0
- package/dist/tools/present/index.d.ts +8 -0
- package/dist/tools/present/index.d.ts.map +1 -0
- package/dist/tools/present/index.js +14 -0
- package/dist/tools/present/index.js.map +1 -0
- package/dist/tools/present/interaction.d.ts +17 -0
- package/dist/tools/present/interaction.d.ts.map +1 -0
- package/dist/tools/present/interaction.js +15 -0
- package/dist/tools/present/interaction.js.map +1 -0
- package/dist/tools/present/utils.d.ts +12 -0
- package/dist/tools/present/utils.d.ts.map +1 -0
- package/dist/tools/present/utils.js +40 -0
- package/dist/tools/present/utils.js.map +1 -0
- package/dist/tools/question-answer/index.d.ts +5 -0
- package/dist/tools/question-answer/index.d.ts.map +1 -0
- package/dist/tools/question-answer/index.js +7 -0
- package/dist/tools/question-answer/index.js.map +1 -0
- package/dist/tools/question-answer/interaction.d.ts +14 -0
- package/dist/tools/question-answer/interaction.d.ts.map +1 -0
- package/dist/tools/question-answer/interaction.js +13 -0
- package/dist/tools/question-answer/interaction.js.map +1 -0
- package/dist/tools/question-answer/question-answer.d.ts +5 -0
- package/dist/tools/question-answer/question-answer.d.ts.map +1 -0
- package/dist/tools/question-answer/question-answer.js +24 -0
- package/dist/tools/question-answer/question-answer.js.map +1 -0
- package/dist/tools/todo/check-task.d.ts +5 -0
- package/dist/tools/todo/check-task.d.ts.map +1 -0
- package/dist/tools/todo/check-task.js +49 -0
- package/dist/tools/todo/check-task.js.map +1 -0
- package/dist/tools/todo/create-list.d.ts +5 -0
- package/dist/tools/todo/create-list.d.ts.map +1 -0
- package/dist/tools/todo/create-list.js +36 -0
- package/dist/tools/todo/create-list.js.map +1 -0
- package/dist/tools/todo/create-task.d.ts +5 -0
- package/dist/tools/todo/create-task.d.ts.map +1 -0
- package/dist/tools/todo/create-task.js +63 -0
- package/dist/tools/todo/create-task.js.map +1 -0
- package/dist/tools/todo/get-list.d.ts +4 -0
- package/dist/tools/todo/get-list.d.ts.map +1 -0
- package/dist/tools/todo/get-list.js +38 -0
- package/dist/tools/todo/get-list.js.map +1 -0
- package/dist/tools/todo/get-lists.d.ts +4 -0
- package/dist/tools/todo/get-lists.d.ts.map +1 -0
- package/dist/tools/todo/get-lists.js +18 -0
- package/dist/tools/todo/get-lists.js.map +1 -0
- package/dist/tools/todo/index.d.ts +12 -0
- package/dist/tools/todo/index.d.ts.map +1 -0
- package/dist/tools/todo/index.js +25 -0
- package/dist/tools/todo/index.js.map +1 -0
- package/dist/tools/todo/interaction.d.ts +30 -0
- package/dist/tools/todo/interaction.d.ts.map +1 -0
- package/dist/tools/todo/interaction.js +13 -0
- package/dist/tools/todo/interaction.js.map +1 -0
- package/dist/tools/todo/remove-list.d.ts +5 -0
- package/dist/tools/todo/remove-list.d.ts.map +1 -0
- package/dist/tools/todo/remove-list.js +42 -0
- package/dist/tools/todo/remove-list.js.map +1 -0
- package/dist/tools/todo/remove-task.d.ts +5 -0
- package/dist/tools/todo/remove-task.d.ts.map +1 -0
- package/dist/tools/todo/remove-task.js +45 -0
- package/dist/tools/todo/remove-task.js.map +1 -0
- package/dist/tools/todo/storage.d.ts +22 -0
- package/dist/tools/todo/storage.d.ts.map +1 -0
- package/dist/tools/todo/storage.js +44 -0
- package/dist/tools/todo/storage.js.map +1 -0
- package/dist/tools/utils/delay.d.ts +10 -0
- package/dist/tools/utils/delay.d.ts.map +1 -0
- package/dist/tools/utils/delay.js +33 -0
- package/dist/tools/utils/delay.js.map +1 -0
- package/dist/tools/utils/get-current-time.d.ts +7 -2
- package/dist/tools/utils/get-current-time.d.ts.map +1 -1
- package/dist/tools/utils/get-current-time.js +12 -31
- package/dist/tools/utils/get-current-time.js.map +1 -1
- package/dist/tools/utils/index.d.ts +2 -0
- package/dist/tools/utils/index.d.ts.map +1 -1
- package/dist/tools/utils/index.js +7 -0
- package/dist/tools/utils/index.js.map +1 -1
- package/package.json +54 -56
- package/dist/templates/researcher.d.ts +0 -27
- package/dist/templates/researcher.d.ts.map +0 -1
- package/dist/templates/researcher.js +0 -70
- package/dist/templates/researcher.js.map +0 -1
- package/dist/tools/www/fetch.d.ts +0 -4
- package/dist/tools/www/fetch.d.ts.map +0 -1
- package/dist/tools/www/fetch.js +0 -147
- package/dist/tools/www/fetch.js.map +0 -1
- package/dist/tools/www/index.d.ts +0 -4
- package/dist/tools/www/index.d.ts.map +0 -1
- package/dist/tools/www/index.js +0 -4
- package/dist/tools/www/index.js.map +0 -1
- package/dist/tools/www/read-web-page.d.ts +0 -4
- package/dist/tools/www/read-web-page.d.ts.map +0 -1
- package/dist/tools/www/read-web-page.js +0 -330
- package/dist/tools/www/read-web-page.js.map +0 -1
- package/dist/tools/www/web-search.d.ts +0 -4
- package/dist/tools/www/web-search.d.ts.map +0 -1
- package/dist/tools/www/web-search.js +0 -82
- package/dist/tools/www/web-search.js.map +0 -1
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Strips the `__name(fn, "fn")` wrapper esbuild injects (with keepNames,
|
|
3
|
+
* which tsx/ts-node/esbuild-register enable by default) around every named
|
|
4
|
+
* `const`/`let` function binding in a module, including plain arrow
|
|
5
|
+
* functions like `const walk = (el) => { ... }`.
|
|
6
|
+
*
|
|
7
|
+
* Why this is needed: Puppeteer's page.evaluate(fn, ...args) serializes
|
|
8
|
+
* `fn` via Function.prototype.toString() and runs the resulting source
|
|
9
|
+
* string inside the browser page, which has no access to this module's
|
|
10
|
+
* scope. Under a plain `tsc` build the callback source is untouched and
|
|
11
|
+
* this is a non-issue. But when the consuming project is executed directly
|
|
12
|
+
* with a TS loader (tsx, ts-node/esbuild, bun, vite-node, etc.), esbuild
|
|
13
|
+
* rewrites every nested named function/arrow assigned to a variable into:
|
|
14
|
+
*
|
|
15
|
+
* const walk = /* @__PURE__ *\/ __name((el) => { ... }, "walk");
|
|
16
|
+
*
|
|
17
|
+
* `__name` only exists as a helper hoisted into that transpiled module's
|
|
18
|
+
* own scope, not inside the isolated page context, so once the callback
|
|
19
|
+
* string is shipped to the page and invoked, referencing `walk` throws
|
|
20
|
+
* `ReferenceError: __name is not defined`.
|
|
21
|
+
*
|
|
22
|
+
* The fix here does not require the consumer to change their loader,
|
|
23
|
+
* tsconfig, or bundler settings, since we control the callback's source at
|
|
24
|
+
* the call site: before serializing, unwrap every `__name(<expr>, "<name>")`
|
|
25
|
+
* back down to the bare `<expr>`, and drop any leftover `__name` helper
|
|
26
|
+
* declaration/import fragments that don't matter once no call sites remain.
|
|
27
|
+
*/
|
|
28
|
+
function stripNameWrapper(source) {
|
|
29
|
+
let out = source;
|
|
30
|
+
// Iteratively unwrap __name(<expr>, "identifier") -> <expr>.
|
|
31
|
+
// Done in a loop (rather than a single regex pass) because __name calls
|
|
32
|
+
// can be nested when a named function itself contains other named
|
|
33
|
+
// consts, and each pass only safely unwraps the innermost balanced call.
|
|
34
|
+
let changed = true;
|
|
35
|
+
while (changed) {
|
|
36
|
+
changed = false;
|
|
37
|
+
out = out.replace(/__name\(((?:[^()]|\([^()]*\))*),\s*"[^"]*"\)/g, (_match, inner) => {
|
|
38
|
+
changed = true;
|
|
39
|
+
return inner;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
// Remove the `/* @__PURE__ */` annotations esbuild leaves behind next to
|
|
43
|
+
// the calls we just stripped; harmless to leave but pointless to keep.
|
|
44
|
+
out = out.replace(/\/\*\s*@__PURE__\s*\*\/\s*/g, "");
|
|
45
|
+
return out;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Drop-in replacement for `page.evaluate(fn, ...args)` that is safe to call
|
|
49
|
+
* from a project run under tsx/ts-node/esbuild as well as a plain `tsc`
|
|
50
|
+
* build. Always use this (instead of page.evaluate directly) for any
|
|
51
|
+
* callback that declares nested named `const`/`let` functions.
|
|
52
|
+
*/
|
|
53
|
+
export async function evaluateSafe(page, fn, ...args) {
|
|
54
|
+
const safeSource = stripNameWrapper(fn.toString());
|
|
55
|
+
// @ts-ignore
|
|
56
|
+
return page.evaluate(
|
|
57
|
+
// @ts-ignore
|
|
58
|
+
(src, evalArgs) => {
|
|
59
|
+
// eslint-disable-next-line no-eval
|
|
60
|
+
const rebuilt = (0, eval)(`(${src})`);
|
|
61
|
+
return rebuilt(...evalArgs);
|
|
62
|
+
}, safeSource, args);
|
|
63
|
+
}
|
|
64
|
+
export default evaluateSafe;
|
|
65
|
+
//# sourceMappingURL=evaluate-safe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evaluate-safe.js","sourceRoot":"","sources":["../../../src/tools/browser/evaluate-safe.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,SAAS,gBAAgB,CAAC,MAAc;IACpC,IAAI,GAAG,GAAG,MAAM,CAAC;IAEjB,6DAA6D;IAC7D,wEAAwE;IACxE,kEAAkE;IAClE,yEAAyE;IACzE,IAAI,OAAO,GAAG,IAAI,CAAC;IACnB,OAAO,OAAO,EAAE,CAAC;QACb,OAAO,GAAG,KAAK,CAAC;QAChB,GAAG,GAAG,GAAG,CAAC,OAAO,CACb,+CAA+C,EAC/C,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;YACd,OAAO,GAAG,IAAI,CAAC;YACf,OAAO,KAAK,CAAC;QACjB,CAAC,CACJ,CAAC;IACN,CAAC;IAED,yEAAyE;IACzE,uEAAuE;IACvE,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,6BAA6B,EAAE,EAAE,CAAC,CAAC;IAErD,OAAO,GAAG,CAAC;AACf,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAC9B,IAAU,EACV,EAAkC,EAClC,GAAG,IAAO;IAEV,MAAM,UAAU,GAAG,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC;IACnD,aAAa;IACb,OAAO,IAAI,CAAC,QAAQ;IAChB,aAAa;IACb,CAAC,GAAW,EAAE,QAAW,EAAE,EAAE;QACzB,mCAAmC;QACnC,MAAM,OAAO,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,IAAI,GAAG,GAAG,CAAC,CAAC;QACtC,OAAO,OAAO,CAAC,GAAG,QAAQ,CAAC,CAAC;IAChC,CAAC,EACD,UAAU,EACV,IAAI,CACP,CAAC;AACN,CAAC;AAED,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fill.d.ts","sourceRoot":"","sources":["../../../src/tools/browser/fill.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAItD,eAAO,MAAM,eAAe,mCAsF1B,CAAC;AAEH,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { MCPTool } from "../../core/mcp.js";
|
|
2
|
+
import { BrowserInteraction } from "./interaction.js";
|
|
3
|
+
import { getSession } from "./session-manager.js";
|
|
4
|
+
import { resolveRef, resolveFormForRef } from "./read-page.js";
|
|
5
|
+
export const BrowserFillTool = () => new MCPTool({
|
|
6
|
+
name: "browser-fill",
|
|
7
|
+
description: "type a value into a fillable element on the page (a ref id previously returned by browser-read, marked [FILLABLE]). " +
|
|
8
|
+
"if the field belongs to a form that has no visible submit button (as flagged by browser-read), set submitOnEnter: true to press Enter afterwards and submit it — the same thing a real user would do in, for example, a search box.",
|
|
9
|
+
inputs: [
|
|
10
|
+
{
|
|
11
|
+
name: "sessionId",
|
|
12
|
+
type: "string",
|
|
13
|
+
description: "session to act on",
|
|
14
|
+
required: true,
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
name: "ref",
|
|
18
|
+
type: "string",
|
|
19
|
+
description: "ref id of the input/textarea/select to fill, e.g. 0x2",
|
|
20
|
+
required: true,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
name: "value",
|
|
24
|
+
type: "string",
|
|
25
|
+
description: "text value to type into the element",
|
|
26
|
+
required: true,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: "submitOnEnter",
|
|
30
|
+
type: "boolean",
|
|
31
|
+
description: "press Enter after typing, submitting the field's form if it has no visible submit button (needed for forms like a plain search box)",
|
|
32
|
+
required: false,
|
|
33
|
+
default: false,
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
customClass: new BrowserInteraction(),
|
|
37
|
+
execute: async (_envID, inputs, _mcp, customClass) => {
|
|
38
|
+
const { sessionId, ref, value, submitOnEnter = false } = inputs;
|
|
39
|
+
if (!sessionId || typeof sessionId !== "string") {
|
|
40
|
+
throw new Error("sessionId must be a non-empty string");
|
|
41
|
+
}
|
|
42
|
+
if (!ref || typeof ref !== "string") {
|
|
43
|
+
throw new Error("ref must be a non-empty string");
|
|
44
|
+
}
|
|
45
|
+
if (typeof value !== "string") {
|
|
46
|
+
throw new Error("value must be a string");
|
|
47
|
+
}
|
|
48
|
+
customClass?.emitBrowserEvent({ type: "filling", sessionId, ref });
|
|
49
|
+
const session = getSession(sessionId);
|
|
50
|
+
const element = await resolveRef(session.page, ref);
|
|
51
|
+
if (!element) {
|
|
52
|
+
throw new Error(`ref "${ref}" was not found on the page (call browser-read again to get fresh refs)`);
|
|
53
|
+
}
|
|
54
|
+
await element.evaluate((el) => {
|
|
55
|
+
el.value = "";
|
|
56
|
+
});
|
|
57
|
+
await element.type(value);
|
|
58
|
+
let formSubmitted = false;
|
|
59
|
+
if (submitOnEnter) {
|
|
60
|
+
await element.press("Enter");
|
|
61
|
+
// A native Enter keypress already triggers the browser's default
|
|
62
|
+
// "submit the enclosing form" behavior for a single-field form.
|
|
63
|
+
// As a fallback for forms/frameworks that swallow the keydown
|
|
64
|
+
// without submitting, explicitly submit the form too if we can
|
|
65
|
+
// identify one that has no visible submit button.
|
|
66
|
+
const formInfo = await resolveFormForRef(session.page, ref);
|
|
67
|
+
if (formInfo && !formInfo.hasSubmitButton) {
|
|
68
|
+
formSubmitted = true;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
message: "success",
|
|
73
|
+
formSubmitted,
|
|
74
|
+
};
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
export default BrowserFillTool;
|
|
78
|
+
//# sourceMappingURL=fill.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fill.js","sourceRoot":"","sources":["../../../src/tools/browser/fill.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAE/D,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,EAAE,CAAC,IAAI,OAAO,CAAqB;IACjE,IAAI,EAAE,cAAc;IACpB,WAAW,EACP,sHAAsH;QACtH,qOAAqO;IACzO,MAAM,EAAE;QACJ;YACI,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,mBAAmB;YAChC,QAAQ,EAAE,IAAI;SACjB;QACD;YACI,IAAI,EAAE,KAAK;YACX,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,uDAAuD;YACpE,QAAQ,EAAE,IAAI;SACjB;QACD;YACI,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,qCAAqC;YAClD,QAAQ,EAAE,IAAI;SACjB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IAAI,CAAC,KAAK,CAAC,CAAC;QAE1B,IAAI,aAAa,GAAG,KAAK,CAAC;QAC1B,IAAI,aAAa,EAAE,CAAC;YAChB,MAAM,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YAC7B,iEAAiE;YACjE,gEAAgE;YAChE,8DAA8D;YAC9D,+DAA+D;YAC/D,kDAAkD;YAClD,MAAM,QAAQ,GAAG,MAAM,iBAAiB,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;YAC5D,IAAI,QAAQ,IAAI,CAAC,QAAQ,CAAC,eAAe,EAAE,CAAC;gBACxC,aAAa,GAAG,IAAI,CAAC;YACzB,CAAC;QACL,CAAC;QAED,OAAO;YACH,OAAO,EAAE,SAAS;YAClB,aAAa;SAChB,CAAC;IACN,CAAC;CACJ,CAAC,CAAC;AAEH,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-sessions.d.ts","sourceRoot":"","sources":["../../../src/tools/browser/get-sessions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAG5C,eAAO,MAAM,sBAAsB,0BASjC,CAAC;AAEH,eAAe,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { MCPTool } from "../../core/mcp.js";
|
|
2
|
+
import { getSessionIds } from "./session-manager.js";
|
|
3
|
+
export const BrowserGetSessionsTool = () => new MCPTool({
|
|
4
|
+
name: "browser-get-sessions",
|
|
5
|
+
description: "get all currently open browser session ids",
|
|
6
|
+
inputs: [],
|
|
7
|
+
execute: async () => {
|
|
8
|
+
return {
|
|
9
|
+
sessions: getSessionIds(),
|
|
10
|
+
};
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
export default BrowserGetSessionsTool;
|
|
14
|
+
//# sourceMappingURL=get-sessions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-sessions.js","sourceRoot":"","sources":["../../../src/tools/browser/get-sessions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,EAAE,CAAC,IAAI,OAAO,CAAC;IACpD,IAAI,EAAE,sBAAsB;IAC5B,WAAW,EAAE,4CAA4C;IACzD,MAAM,EAAE,EAAE;IACV,OAAO,EAAE,KAAK,IAAkB,EAAE;QAC9B,OAAO;YACH,QAAQ,EAAE,aAAa,EAAE;SAC5B,CAAC;IACN,CAAC;CACJ,CAAC,CAAC;AAEH,eAAe,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export { BrowserCreateSessionTool } from "./create-session.js";
|
|
2
|
+
export { BrowserRemoveSessionTool } from "./remove-session.js";
|
|
3
|
+
export { BrowserGetSessionsTool } from "./get-sessions.js";
|
|
4
|
+
export { BrowserNavigateTool } from "./navigate.js";
|
|
5
|
+
export { BrowserConsoleTool } from "./console.js";
|
|
6
|
+
export { BrowserInjectTool } from "./inject.js";
|
|
7
|
+
export { BrowserReadTool } from "./read.js";
|
|
8
|
+
export { BrowserClickTool } from "./click.js";
|
|
9
|
+
export { BrowserFillTool } from "./fill.js";
|
|
10
|
+
export { BrowserSubmitFormTool } from "./submit-form.js";
|
|
11
|
+
export { BrowserScrollInfoTool } from "./scroll-info.js";
|
|
12
|
+
export { BrowserScrollTool } from "./scroll.js";
|
|
13
|
+
export { BrowserNetworkStatusTool } from "./network-status.js";
|
|
14
|
+
export { BrowserNetworkTool } from "./network.js";
|
|
15
|
+
export { BrowserScreenshotTool } from "./screenshot.js";
|
|
16
|
+
export { BrowserInteraction } from "./interaction.js";
|
|
17
|
+
export type { BrowserEvent } from "./interaction.js";
|
|
18
|
+
export declare const BrowserTools: () => (import("../../index.js").MCPTool<undefined> | import("../../index.js").MCPTool<import("./interaction.js").BrowserInteraction>)[];
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/browser/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,YAAY,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAkBrD,eAAO,MAAM,YAAY,yIAgBxB,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export { BrowserCreateSessionTool } from "./create-session.js";
|
|
2
|
+
export { BrowserRemoveSessionTool } from "./remove-session.js";
|
|
3
|
+
export { BrowserGetSessionsTool } from "./get-sessions.js";
|
|
4
|
+
export { BrowserNavigateTool } from "./navigate.js";
|
|
5
|
+
export { BrowserConsoleTool } from "./console.js";
|
|
6
|
+
export { BrowserInjectTool } from "./inject.js";
|
|
7
|
+
export { BrowserReadTool } from "./read.js";
|
|
8
|
+
export { BrowserClickTool } from "./click.js";
|
|
9
|
+
export { BrowserFillTool } from "./fill.js";
|
|
10
|
+
export { BrowserSubmitFormTool } from "./submit-form.js";
|
|
11
|
+
export { BrowserScrollInfoTool } from "./scroll-info.js";
|
|
12
|
+
export { BrowserScrollTool } from "./scroll.js";
|
|
13
|
+
export { BrowserNetworkStatusTool } from "./network-status.js";
|
|
14
|
+
export { BrowserNetworkTool } from "./network.js";
|
|
15
|
+
export { BrowserScreenshotTool } from "./screenshot.js";
|
|
16
|
+
export { BrowserInteraction } from "./interaction.js";
|
|
17
|
+
import { BrowserCreateSessionTool } from "./create-session.js";
|
|
18
|
+
import { BrowserRemoveSessionTool } from "./remove-session.js";
|
|
19
|
+
import { BrowserGetSessionsTool } from "./get-sessions.js";
|
|
20
|
+
import { BrowserNavigateTool } from "./navigate.js";
|
|
21
|
+
import { BrowserConsoleTool } from "./console.js";
|
|
22
|
+
import { BrowserInjectTool } from "./inject.js";
|
|
23
|
+
import { BrowserReadTool } from "./read.js";
|
|
24
|
+
import { BrowserClickTool } from "./click.js";
|
|
25
|
+
import { BrowserFillTool } from "./fill.js";
|
|
26
|
+
import { BrowserSubmitFormTool } from "./submit-form.js";
|
|
27
|
+
import { BrowserScrollInfoTool } from "./scroll-info.js";
|
|
28
|
+
import { BrowserScrollTool } from "./scroll.js";
|
|
29
|
+
import { BrowserNetworkStatusTool } from "./network-status.js";
|
|
30
|
+
import { BrowserNetworkTool } from "./network.js";
|
|
31
|
+
import { BrowserScreenshotTool } from "./screenshot.js";
|
|
32
|
+
export const BrowserTools = () => [
|
|
33
|
+
BrowserCreateSessionTool(),
|
|
34
|
+
BrowserRemoveSessionTool(),
|
|
35
|
+
BrowserGetSessionsTool(),
|
|
36
|
+
BrowserNavigateTool(),
|
|
37
|
+
BrowserConsoleTool(),
|
|
38
|
+
BrowserInjectTool(),
|
|
39
|
+
BrowserReadTool(),
|
|
40
|
+
BrowserClickTool(),
|
|
41
|
+
BrowserFillTool(),
|
|
42
|
+
BrowserSubmitFormTool(),
|
|
43
|
+
BrowserScrollInfoTool(),
|
|
44
|
+
BrowserScrollTool(),
|
|
45
|
+
BrowserNetworkStatusTool(),
|
|
46
|
+
BrowserNetworkTool(),
|
|
47
|
+
BrowserScreenshotTool(),
|
|
48
|
+
];
|
|
49
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/browser/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,O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,EAAE;CAC1B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inject.d.ts","sourceRoot":"","sources":["../../../src/tools/browser/inject.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAKtD,eAAO,MAAM,iBAAiB,mCAuD5B,CAAC;AAEH,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { MCPTool } from "../../core/mcp.js";
|
|
2
|
+
import { BrowserInteraction } from "./interaction.js";
|
|
3
|
+
import { getSession } from "./session-manager.js";
|
|
4
|
+
const OUTPUT_CAP = 5000;
|
|
5
|
+
export const BrowserInjectTool = () => new MCPTool({
|
|
6
|
+
name: "browser-inject",
|
|
7
|
+
description: "evaluate arbitrary JavaScript inside a browser session's page and return its result (capped at 5000 characters)",
|
|
8
|
+
inputs: [
|
|
9
|
+
{
|
|
10
|
+
name: "sessionId",
|
|
11
|
+
type: "string",
|
|
12
|
+
description: "session to inject into",
|
|
13
|
+
required: true,
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
name: "eval",
|
|
17
|
+
type: "string",
|
|
18
|
+
description: "javascript expression/statement to evaluate in the page context",
|
|
19
|
+
required: true,
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
customClass: new BrowserInteraction(),
|
|
23
|
+
execute: async (_envID, inputs, _mcp, customClass) => {
|
|
24
|
+
const { sessionId, eval: code } = inputs;
|
|
25
|
+
if (!sessionId || typeof sessionId !== "string") {
|
|
26
|
+
throw new Error("sessionId must be a non-empty string");
|
|
27
|
+
}
|
|
28
|
+
if (!code || typeof code !== "string") {
|
|
29
|
+
throw new Error("eval must be a non-empty string");
|
|
30
|
+
}
|
|
31
|
+
customClass?.emitBrowserEvent({ type: "injecting", sessionId });
|
|
32
|
+
const session = getSession(sessionId);
|
|
33
|
+
let result;
|
|
34
|
+
try {
|
|
35
|
+
// page.evaluate() accepts a raw string and runs it directly in
|
|
36
|
+
// the page context; wrapping in an async IIFE lets both bare
|
|
37
|
+
// expressions and multi-statement code work, and lets us
|
|
38
|
+
// await any promises the injected code returns.
|
|
39
|
+
result = await session.page.evaluate(`(async () => { ${code} })()`);
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
result = `Error: ${err?.message || String(err)}`;
|
|
43
|
+
}
|
|
44
|
+
const content = typeof result === "string" ? result : JSON.stringify(result);
|
|
45
|
+
return {
|
|
46
|
+
content: (content || "").slice(0, OUTPUT_CAP),
|
|
47
|
+
};
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
export default BrowserInjectTool;
|
|
51
|
+
//# sourceMappingURL=inject.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inject.js","sourceRoot":"","sources":["../../../src/tools/browser/inject.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,MAAM,UAAU,GAAG,IAAI,CAAC;AAExB,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,EAAE,CAAC,IAAI,OAAO,CAAqB;IACnE,IAAI,EAAE,gBAAgB;IACtB,WAAW,EAAE,iHAAiH;IAC9H,MAAM,EAAE;QACJ;YACI,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,wBAAwB;YACrC,QAAQ,EAAE,IAAI;SACjB;QACD;YACI,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,iEAAiE;YAC9E,QAAQ,EAAE,IAAI;SACjB;KACJ;IACD,WAAW,EAAE,IAAI,kBAAkB,EAAE;IACrC,OAAO,EAAE,KAAK,EAC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cp.js";
|
|
2
|
+
export type BrowserEvent = {
|
|
3
|
+
type: "session-created";
|
|
4
|
+
sessionId: string;
|
|
5
|
+
url: string;
|
|
6
|
+
} | {
|
|
7
|
+
type: "session-removed";
|
|
8
|
+
sessionId: string;
|
|
9
|
+
} | {
|
|
10
|
+
type: "navigating";
|
|
11
|
+
sessionId: string;
|
|
12
|
+
url: string;
|
|
13
|
+
} | {
|
|
14
|
+
type: "reading";
|
|
15
|
+
sessionId: string;
|
|
16
|
+
} | {
|
|
17
|
+
type: "clicking";
|
|
18
|
+
sessionId: string;
|
|
19
|
+
ref: string;
|
|
20
|
+
} | {
|
|
21
|
+
type: "filling";
|
|
22
|
+
sessionId: string;
|
|
23
|
+
ref: string;
|
|
24
|
+
} | {
|
|
25
|
+
type: "submitting-form";
|
|
26
|
+
sessionId: string;
|
|
27
|
+
formRef: string;
|
|
28
|
+
} | {
|
|
29
|
+
type: "scrolling";
|
|
30
|
+
sessionId: string;
|
|
31
|
+
position: number;
|
|
32
|
+
} | {
|
|
33
|
+
type: "injecting";
|
|
34
|
+
sessionId: string;
|
|
35
|
+
} | {
|
|
36
|
+
type: "screenshotting";
|
|
37
|
+
sessionId: string;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Shared custom interaction class for all browser tools. A frontend can
|
|
41
|
+
* listen on getEvents() to show live status (e.g. "Searching...",
|
|
42
|
+
* "Navigating to example.com...", "Clicking button...") while the agent
|
|
43
|
+
* drives the browser, without waiting for the tool call itself to resolve.
|
|
44
|
+
*/
|
|
45
|
+
export declare class BrowserInteraction extends MCPCustomClass {
|
|
46
|
+
emitBrowserEvent(event: BrowserEvent): void;
|
|
47
|
+
}
|
|
48
|
+
export default BrowserInteraction;
|
|
49
|
+
//# sourceMappingURL=interaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interaction.d.ts","sourceRoot":"","sources":["../../../src/tools/browser/interaction.ts"],"names":[],"mappings":"AAAA,OAAO,EA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
|
|
4
|
+
* listen on getEvents() to show live status (e.g. "Searching...",
|
|
5
|
+
* "Navigating to example.com...", "Clicking button...") while the agent
|
|
6
|
+
* drives the browser, without waiting for the tool call itself to resolve.
|
|
7
|
+
*/
|
|
8
|
+
export class BrowserInteraction extends MCPCustomClass {
|
|
9
|
+
emitBrowserEvent(event) {
|
|
10
|
+
this.getEvents().emit("browser", event);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export default BrowserInteraction;
|
|
14
|
+
//# sourceMappingURL=interaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interaction.js","sourceRoot":"","sources":["../../../src/tools/browser/interaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAcnD;;;;;GAKG;AACH,MAAM,OAAO,kBAAmB,SAAQ,cAAc;IAClD,gBAAgB,CAAC,KAAmB;QAChC,IAAI,CAAC,SAAS,EAAE,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IAC5C,CAAC;CACJ;AAED,eAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navigate.d.ts","sourceRoot":"","sources":["../../../src/tools/browser/navigate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAGtD,eAAO,MAAM,mBAAmB,mCA2C9B,CAAC;AAEH,eAAe,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { MCPTool } from "../../core/mcp.js";
|
|
2
|
+
import { BrowserInteraction } from "./interaction.js";
|
|
3
|
+
import { getSession } from "./session-manager.js";
|
|
4
|
+
export const BrowserNavigateTool = () => new MCPTool({
|
|
5
|
+
name: "browser-navigate",
|
|
6
|
+
description: "navigate an existing browser session to a new url",
|
|
7
|
+
inputs: [
|
|
8
|
+
{
|
|
9
|
+
name: "sessionId",
|
|
10
|
+
type: "string",
|
|
11
|
+
description: "session to navigate",
|
|
12
|
+
required: true,
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
name: "url",
|
|
16
|
+
type: "string",
|
|
17
|
+
description: "url to navigate to",
|
|
18
|
+
required: true,
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
customClass: new BrowserInteraction(),
|
|
22
|
+
execute: async (_envID, inputs, _mcp, customClass) => {
|
|
23
|
+
const { sessionId, url } = inputs;
|
|
24
|
+
if (!sessionId || typeof sessionId !== "string") {
|
|
25
|
+
throw new Error("sessionId must be a non-empty string");
|
|
26
|
+
}
|
|
27
|
+
if (!url || typeof url !== "string") {
|
|
28
|
+
throw new Error("url must be a non-empty string");
|
|
29
|
+
}
|
|
30
|
+
customClass?.emitBrowserEvent({ type: "navigating", sessionId, url });
|
|
31
|
+
const session = getSession(sessionId);
|
|
32
|
+
await session.page.goto(url, { waitUntil: "domcontentloaded" });
|
|
33
|
+
return {
|
|
34
|
+
message: "success",
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
export default BrowserNavigateTool;
|
|
39
|
+
//# sourceMappingURL=navigate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navigate.js","sourceRoot":"","sources":["../../../src/tools/browser/navigate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,EAAE,CAAC,IAAI,OAAO,CAAqB;IACrE,IAAI,EAAE,kBAAkB;IACxB,WAAW,EAAE,mDAAmD;IAChE,MAAM,EAAE;QACJ;YACI,IAAI,EAAE,WAAW;YACjB,IAAI,EAA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 +1,35 @@
|
|
|
1
|
+
import { MCPTool } from "../../core/mcp.js";
|
|
2
|
+
import { getSession } from "./session-manager.js";
|
|
3
|
+
export const BrowserNetworkStatusTool = () => new MCPTool({
|
|
4
|
+
name: "browser-network-status",
|
|
5
|
+
description: "check whether the page currently has in-flight network activity",
|
|
6
|
+
inputs: [
|
|
7
|
+
{
|
|
8
|
+
name: "sessionId",
|
|
9
|
+
type: "string",
|
|
10
|
+
description: "session to inspect",
|
|
11
|
+
required: true,
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
execute: async (_envID, inputs) => {
|
|
15
|
+
const { sessionId } = inputs;
|
|
16
|
+
if (!sessionId || typeof sessionId !== "string") {
|
|
17
|
+
throw new Error("sessionId must be a non-empty string");
|
|
18
|
+
}
|
|
19
|
+
const session = getSession(sessionId);
|
|
20
|
+
// If the page reports document.readyState complete and there is
|
|
21
|
+
// nothing left in the browser's resource timeline that hasn't
|
|
22
|
+
// finished, we consider the network idle.
|
|
23
|
+
const status = await session.page.evaluate(() => {
|
|
24
|
+
const pending = performance
|
|
25
|
+
.getEntriesByType("resource")
|
|
26
|
+
.some((entry) => entry.responseEnd === 0);
|
|
27
|
+
return document.readyState === "complete" && !pending ? "idle" : "loading";
|
|
28
|
+
});
|
|
29
|
+
return {
|
|
30
|
+
status,
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
export default BrowserNetworkStatusTool;
|
|
35
|
+
//# sourceMappingURL=network-status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"network-status.js","sourceRoot":"","sources":["../../../src/tools/browser/network-status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,EAAE,CAAC,IAAI,OAAO,CAAC;IACtD,IAAI,EAAE,wBAA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|
|
|
1
|
+
import { MCPTool } from "../../core/mcp.js";
|
|
2
|
+
import { getSession } from "./session-manager.js";
|
|
3
|
+
export const BrowserNetworkTool = () => new MCPTool({
|
|
4
|
+
name: "browser-network",
|
|
5
|
+
description: "read network activity logs captured from a browser session (each request/response body capped at 1000 characters)",
|
|
6
|
+
inputs: [
|
|
7
|
+
{
|
|
8
|
+
name: "sessionId",
|
|
9
|
+
type: "string",
|
|
10
|
+
description: "session to read network logs from",
|
|
11
|
+
required: true,
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
name: "limit",
|
|
15
|
+
type: "number",
|
|
16
|
+
description: "max number of entries to return",
|
|
17
|
+
required: false,
|
|
18
|
+
default: 20,
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: "offset",
|
|
22
|
+
type: "number",
|
|
23
|
+
description: "offset into the log buffer",
|
|
24
|
+
required: false,
|
|
25
|
+
default: 0,
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: "type",
|
|
29
|
+
type: "string",
|
|
30
|
+
description: "filter by resource type, e.g. \"fetch\", \"xhr\", \"document\", \"image\", \"media\", or \"all\"",
|
|
31
|
+
required: false,
|
|
32
|
+
default: "all",
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
execute: async (_envID, inputs) => {
|
|
36
|
+
const { sessionId, limit = 20, offset = 0, type = "all" } = inputs;
|
|
37
|
+
if (!sessionId || typeof sessionId !== "string") {
|
|
38
|
+
throw new Error("sessionId must be a non-empty string");
|
|
39
|
+
}
|
|
40
|
+
const session = getSession(sessionId);
|
|
41
|
+
const filtered = type && type !== "all"
|
|
42
|
+
? session.networkLogs.filter((entry) => entry.type === type)
|
|
43
|
+
: session.networkLogs;
|
|
44
|
+
return {
|
|
45
|
+
messages: filtered.slice(offset, offset + limit),
|
|
46
|
+
total: filtered.length,
|
|
47
|
+
};
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
export default BrowserNetworkTool;
|
|
51
|
+
//# sourceMappingURL=network.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"network.js","sourceRoot":"","sources":["../../../src/tools/browser/network.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,EAAE,CAAC,IAAI,OAAO,CAAC;IAChD,IAAI,EAAE,iBAAiB;IACvB,WAAW,EAAE,mHAAmH;IAChI,MAAM,EAAE;QACJ;YACI,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,mCAAmC;YAChD,QAAQ,EAAE,IAAI;SACjB;QACD;YACI,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,iCAAiC;YAC9C,QAAQ,EAAE,KAAK;YACf,OAAO,EAAE,EAAE;SACd;QACD;YACI,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,4BAA4B;YACzC,QAAQ,EAAE,KAAK;YACf,OAAO,EAAE,CAAC;SACb;QACD;YACI,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,kGAAkG;YAC/G,QAAQ,EAAE,KAAK;YACf,OAAO,EAAE,KAAK;SACjB;KACJ;IACD,OAAO,EAAE,KAAK,EAAE,MAAc,EAAE,MAA2B,EAAgB,EAAE;QACzE,MAAM,EAAE,SAAS,EAAE,KAAK,GAAG,EAAE,EAAE,MAAM,GAAG,CAAC,EAAE,IAAI,GAAG,KAAK,EAAE,GAAG,MAAM,CAAC;QAEnE,IAAI,CAAC,SAAS,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE,CAAC;YAC9C,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;QAC5D,CAAC;QAED,MAAM,OAAO,GAAG,UAAU,CAAC,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