@elizaos/agent 2.0.0-alpha.173 → 2.0.0-alpha.192
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/apps/app-companion/src/actions/emote.d.ts.map +1 -1
- package/apps/app-companion/src/actions/emote.js +1 -0
- package/apps/app-elizamaker/src/drop-routes.d.ts +22 -0
- package/apps/app-elizamaker/src/drop-routes.d.ts.map +1 -0
- package/apps/app-elizamaker/src/drop-service.d.ts +26 -0
- package/apps/app-elizamaker/src/drop-service.d.ts.map +1 -0
- package/apps/app-elizamaker/src/index.d.ts +8 -0
- package/apps/app-elizamaker/src/index.d.ts.map +1 -0
- package/apps/app-elizamaker/src/index.js +5 -0
- package/apps/app-elizamaker/src/merkle-tree.d.ts.map +1 -0
- package/apps/app-elizamaker/src/og-tracker.d.ts.map +1 -0
- package/apps/app-elizamaker/src/og-tracker.js +60 -0
- package/apps/app-elizamaker/src/twitter-verify.d.ts +25 -0
- package/apps/app-elizamaker/src/twitter-verify.d.ts.map +1 -0
- package/apps/app-elizamaker/src/twitter-verify.js +168 -0
- package/apps/app-lifeops/src/actions/activity-report.d.ts +13 -0
- package/apps/app-lifeops/src/actions/activity-report.d.ts.map +1 -0
- package/apps/app-lifeops/src/actions/activity-report.js +287 -0
- package/apps/app-lifeops/src/actions/app-blocker.d.ts +5 -0
- package/apps/app-lifeops/src/actions/app-blocker.d.ts.map +1 -0
- package/apps/app-lifeops/src/actions/app-blocker.js +446 -0
- package/apps/app-lifeops/src/actions/autofill.d.ts +35 -0
- package/apps/app-lifeops/src/actions/autofill.d.ts.map +1 -0
- package/apps/app-lifeops/src/actions/autofill.js +340 -0
- package/apps/app-lifeops/src/actions/browser-extension.d.ts +19 -0
- package/apps/app-lifeops/src/actions/browser-extension.d.ts.map +1 -0
- package/apps/app-lifeops/src/actions/browser-extension.js +88 -0
- package/apps/app-lifeops/src/actions/calendar.d.ts.map +1 -1
- package/apps/app-lifeops/src/actions/calendar.js +405 -973
- package/apps/app-lifeops/src/actions/calendly.d.ts +3 -0
- package/apps/app-lifeops/src/actions/calendly.d.ts.map +1 -0
- package/apps/app-lifeops/src/actions/calendly.js +242 -0
- package/apps/app-lifeops/src/actions/checkin.d.ts +4 -0
- package/apps/app-lifeops/src/actions/checkin.d.ts.map +1 -0
- package/apps/app-lifeops/src/actions/checkin.js +72 -0
- package/apps/app-lifeops/src/actions/computer-use.d.ts +14 -0
- package/apps/app-lifeops/src/actions/computer-use.d.ts.map +1 -0
- package/apps/app-lifeops/src/actions/computer-use.js +149 -0
- package/apps/app-lifeops/src/actions/cross-channel-send.d.ts +22 -0
- package/apps/app-lifeops/src/actions/cross-channel-send.d.ts.map +1 -0
- package/apps/app-lifeops/src/actions/cross-channel-send.js +562 -0
- package/apps/app-lifeops/src/actions/device-bus.d.ts +19 -0
- package/apps/app-lifeops/src/actions/device-bus.d.ts.map +1 -0
- package/apps/app-lifeops/src/actions/device-bus.js +233 -0
- package/apps/app-lifeops/src/actions/dossier.d.ts +5 -0
- package/apps/app-lifeops/src/actions/dossier.d.ts.map +1 -0
- package/apps/app-lifeops/src/actions/dossier.js +195 -0
- package/apps/app-lifeops/src/actions/gmail.d.ts.map +1 -1
- package/apps/app-lifeops/src/actions/gmail.js +73 -37
- package/apps/app-lifeops/src/actions/health.d.ts +9 -0
- package/apps/app-lifeops/src/actions/health.d.ts.map +1 -0
- package/apps/app-lifeops/src/actions/health.js +357 -0
- package/apps/app-lifeops/src/actions/inbox.d.ts +3 -1
- package/apps/app-lifeops/src/actions/inbox.d.ts.map +1 -1
- package/apps/app-lifeops/src/actions/inbox.js +279 -152
- package/apps/app-lifeops/src/actions/intent-sync.d.ts +3 -0
- package/apps/app-lifeops/src/actions/intent-sync.d.ts.map +1 -0
- package/apps/app-lifeops/src/actions/intent-sync.js +258 -0
- package/apps/app-lifeops/src/actions/life.d.ts +0 -4
- package/apps/app-lifeops/src/actions/life.d.ts.map +1 -1
- package/apps/app-lifeops/src/actions/life.js +162 -249
- package/apps/app-lifeops/src/actions/lifeops-google-helpers.d.ts.map +1 -1
- package/apps/app-lifeops/src/actions/lifeops-google-helpers.js +11 -3
- package/apps/app-lifeops/src/actions/list-remote-sessions.d.ts +6 -0
- package/apps/app-lifeops/src/actions/list-remote-sessions.d.ts.map +1 -0
- package/apps/app-lifeops/src/actions/list-remote-sessions.js +45 -0
- package/apps/app-lifeops/src/actions/password-manager.d.ts +3 -0
- package/apps/app-lifeops/src/actions/password-manager.d.ts.map +1 -0
- package/apps/app-lifeops/src/actions/password-manager.js +182 -0
- package/apps/app-lifeops/src/actions/relationships.d.ts +9 -0
- package/apps/app-lifeops/src/actions/relationships.d.ts.map +1 -0
- package/apps/app-lifeops/src/actions/relationships.js +504 -0
- package/apps/app-lifeops/src/actions/remote-desktop.d.ts +3 -0
- package/apps/app-lifeops/src/actions/remote-desktop.d.ts.map +1 -0
- package/apps/app-lifeops/src/actions/remote-desktop.js +244 -0
- package/apps/app-lifeops/src/actions/revoke-remote-session.d.ts +6 -0
- package/apps/app-lifeops/src/actions/revoke-remote-session.d.ts.map +1 -0
- package/apps/app-lifeops/src/actions/revoke-remote-session.js +73 -0
- package/apps/app-lifeops/src/actions/scheduling.d.ts +55 -0
- package/apps/app-lifeops/src/actions/scheduling.d.ts.map +1 -0
- package/apps/app-lifeops/src/actions/scheduling.js +914 -0
- package/apps/app-lifeops/src/actions/screen-time.d.ts +8 -0
- package/apps/app-lifeops/src/actions/screen-time.d.ts.map +1 -0
- package/apps/app-lifeops/src/actions/screen-time.js +231 -0
- package/apps/app-lifeops/src/actions/search-across-channels.d.ts +13 -0
- package/apps/app-lifeops/src/actions/search-across-channels.d.ts.map +1 -0
- package/apps/app-lifeops/src/actions/search-across-channels.js +340 -0
- package/apps/app-lifeops/src/actions/start-remote-session.d.ts +14 -0
- package/apps/app-lifeops/src/actions/start-remote-session.d.ts.map +1 -0
- package/apps/app-lifeops/src/actions/start-remote-session.js +138 -0
- package/apps/app-lifeops/src/actions/twilio-call.d.ts +20 -0
- package/apps/app-lifeops/src/actions/twilio-call.d.ts.map +1 -0
- package/apps/app-lifeops/src/actions/twilio-call.js +510 -0
- package/apps/app-lifeops/src/actions/update-owner-profile.d.ts +3 -1
- package/apps/app-lifeops/src/actions/update-owner-profile.d.ts.map +1 -1
- package/apps/app-lifeops/src/actions/update-owner-profile.js +52 -31
- package/apps/app-lifeops/src/actions/website-blocker.d.ts +10 -0
- package/apps/app-lifeops/src/actions/website-blocker.d.ts.map +1 -0
- package/apps/app-lifeops/src/actions/website-blocker.js +539 -0
- package/apps/app-lifeops/src/actions/x-read.d.ts +3 -0
- package/apps/app-lifeops/src/actions/x-read.d.ts.map +1 -0
- package/apps/app-lifeops/src/actions/x-read.js +367 -0
- package/apps/app-lifeops/src/activity-profile/activity-tracker-repo.d.ts +28 -0
- package/apps/app-lifeops/src/activity-profile/activity-tracker-repo.d.ts.map +1 -0
- package/apps/app-lifeops/src/activity-profile/activity-tracker-repo.js +62 -0
- package/apps/app-lifeops/src/activity-profile/activity-tracker-reporting.d.ts +45 -0
- package/apps/app-lifeops/src/activity-profile/activity-tracker-reporting.d.ts.map +1 -0
- package/apps/app-lifeops/src/activity-profile/activity-tracker-reporting.js +112 -0
- package/apps/app-lifeops/src/activity-profile/activity-tracker-service.d.ts +26 -0
- package/apps/app-lifeops/src/activity-profile/activity-tracker-service.d.ts.map +1 -0
- package/apps/app-lifeops/src/activity-profile/activity-tracker-service.js +84 -0
- package/apps/app-lifeops/src/activity-profile/analyzer.d.ts.map +1 -0
- package/apps/app-lifeops/src/activity-profile/analyzer.js +544 -0
- package/apps/app-lifeops/src/activity-profile/proactive-planner.d.ts.map +1 -0
- package/apps/app-lifeops/src/activity-profile/proactive-planner.js +458 -0
- package/apps/app-lifeops/src/activity-profile/proactive-worker.d.ts.map +1 -0
- package/apps/app-lifeops/src/activity-profile/proactive-worker.js +571 -0
- package/apps/app-lifeops/src/activity-profile/profile-metadata.d.ts.map +1 -0
- package/apps/app-lifeops/src/activity-profile/redactor.d.ts +18 -0
- package/apps/app-lifeops/src/activity-profile/redactor.d.ts.map +1 -0
- package/apps/app-lifeops/src/activity-profile/redactor.js +39 -0
- package/apps/app-lifeops/src/activity-profile/service.d.ts +11 -0
- package/apps/app-lifeops/src/activity-profile/service.d.ts.map +1 -0
- package/apps/app-lifeops/src/activity-profile/service.js +229 -0
- package/apps/app-lifeops/src/activity-profile/types.d.ts.map +1 -0
- package/apps/app-lifeops/src/app-blocker/access.d.ts +8 -0
- package/apps/app-lifeops/src/app-blocker/access.d.ts.map +1 -0
- package/apps/app-lifeops/src/app-blocker/access.js +28 -0
- package/apps/app-lifeops/src/app-blocker/engine.d.ts +10 -0
- package/apps/app-lifeops/src/app-blocker/engine.d.ts.map +1 -0
- package/apps/app-lifeops/src/app-blocker/engine.js +43 -0
- package/apps/app-lifeops/src/dossier/action.d.ts +9 -0
- package/apps/app-lifeops/src/dossier/action.d.ts.map +1 -0
- package/apps/app-lifeops/src/dossier/action.js +87 -0
- package/apps/app-lifeops/src/dossier/service.d.ts +145 -0
- package/apps/app-lifeops/src/dossier/service.d.ts.map +1 -0
- package/apps/app-lifeops/src/dossier/service.js +346 -0
- package/apps/app-lifeops/src/followup/actions/listOverdueFollowups.d.ts +3 -0
- package/apps/app-lifeops/src/followup/actions/listOverdueFollowups.d.ts.map +1 -0
- package/apps/app-lifeops/src/followup/actions/listOverdueFollowups.js +47 -0
- package/apps/app-lifeops/src/followup/actions/markFollowupDone.d.ts +3 -0
- package/apps/app-lifeops/src/followup/actions/markFollowupDone.d.ts.map +1 -0
- package/apps/app-lifeops/src/followup/actions/markFollowupDone.js +172 -0
- package/apps/app-lifeops/src/followup/actions/setFollowupThreshold.d.ts +3 -0
- package/apps/app-lifeops/src/followup/actions/setFollowupThreshold.d.ts.map +1 -0
- package/apps/app-lifeops/src/followup/actions/setFollowupThreshold.js +171 -0
- package/apps/app-lifeops/src/followup/followup-tracker.d.ts +81 -0
- package/apps/app-lifeops/src/followup/followup-tracker.d.ts.map +1 -0
- package/apps/app-lifeops/src/followup/followup-tracker.js +251 -0
- package/apps/app-lifeops/src/followup/index.d.ts +5 -0
- package/apps/app-lifeops/src/followup/index.d.ts.map +1 -0
- package/apps/app-lifeops/src/followup/index.js +4 -0
- package/apps/app-lifeops/src/inbox/reflection.d.ts +0 -5
- package/apps/app-lifeops/src/inbox/reflection.d.ts.map +1 -1
- package/apps/app-lifeops/src/inbox/reflection.js +9 -51
- package/apps/app-lifeops/src/inbox/repository.d.ts +0 -1
- package/apps/app-lifeops/src/inbox/repository.d.ts.map +1 -1
- package/apps/app-lifeops/src/inbox/repository.js +18 -118
- package/apps/app-lifeops/src/inbox/triage-classifier.d.ts +4 -6
- package/apps/app-lifeops/src/inbox/triage-classifier.d.ts.map +1 -1
- package/apps/app-lifeops/src/inbox/triage-classifier.js +68 -101
- package/apps/app-lifeops/src/inbox/types.d.ts +4 -42
- package/apps/app-lifeops/src/inbox/types.d.ts.map +1 -1
- package/apps/app-lifeops/src/lifeops/approval-queue.types.d.ts +162 -0
- package/apps/app-lifeops/src/lifeops/approval-queue.types.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/approval-queue.types.js +41 -0
- package/apps/app-lifeops/src/lifeops/autofill-whitelist.d.ts +24 -0
- package/apps/app-lifeops/src/lifeops/autofill-whitelist.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/autofill-whitelist.js +125 -0
- package/apps/app-lifeops/src/lifeops/background-planner-dispatch.d.ts +59 -0
- package/apps/app-lifeops/src/lifeops/background-planner-dispatch.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/background-planner-dispatch.js +129 -0
- package/apps/app-lifeops/src/lifeops/background-planner.d.ts +141 -0
- package/apps/app-lifeops/src/lifeops/background-planner.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/background-planner.js +308 -0
- package/apps/app-lifeops/src/lifeops/browser-extension-store.d.ts +61 -0
- package/apps/app-lifeops/src/lifeops/browser-extension-store.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/browser-extension-store.js +181 -0
- package/apps/app-lifeops/src/lifeops/calendly-client.d.ts +61 -0
- package/apps/app-lifeops/src/lifeops/calendly-client.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/calendly-client.js +218 -0
- package/apps/app-lifeops/src/lifeops/checkin/checkin-service.d.ts +24 -0
- package/apps/app-lifeops/src/lifeops/checkin/checkin-service.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/checkin/checkin-service.js +216 -0
- package/apps/app-lifeops/src/lifeops/checkin/schedule-resolver.d.ts +14 -0
- package/apps/app-lifeops/src/lifeops/checkin/schedule-resolver.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/checkin/schedule-resolver.js +33 -0
- package/apps/app-lifeops/src/lifeops/checkin/types.d.ts +42 -0
- package/apps/app-lifeops/src/lifeops/checkin/types.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/checkin/types.js +7 -0
- package/apps/app-lifeops/src/lifeops/defaults.d.ts +1 -1
- package/apps/app-lifeops/src/lifeops/defaults.d.ts.map +1 -1
- package/apps/app-lifeops/src/lifeops/defaults.js +8 -1
- package/apps/app-lifeops/src/lifeops/discord-browser-scraper.d.ts +106 -0
- package/apps/app-lifeops/src/lifeops/discord-browser-scraper.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/discord-browser-scraper.js +488 -0
- package/apps/app-lifeops/src/lifeops/enforcement-windows.d.ts +34 -0
- package/apps/app-lifeops/src/lifeops/enforcement-windows.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/enforcement-windows.js +110 -0
- package/apps/app-lifeops/src/lifeops/google-connector-gateway.d.ts +13 -0
- package/apps/app-lifeops/src/lifeops/google-connector-gateway.d.ts.map +1 -1
- package/apps/app-lifeops/src/lifeops/google-connector-gateway.js +23 -0
- package/apps/app-lifeops/src/lifeops/google-drive.d.ts +103 -0
- package/apps/app-lifeops/src/lifeops/google-drive.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/google-drive.js +265 -0
- package/apps/app-lifeops/src/lifeops/google-fetch.d.ts +5 -0
- package/apps/app-lifeops/src/lifeops/google-fetch.d.ts.map +1 -1
- package/apps/app-lifeops/src/lifeops/google-fetch.js +12 -1
- package/apps/app-lifeops/src/lifeops/google-gmail.d.ts.map +1 -1
- package/apps/app-lifeops/src/lifeops/google-gmail.js +19 -34
- package/apps/app-lifeops/src/lifeops/google-managed-client.d.ts +12 -1
- package/apps/app-lifeops/src/lifeops/google-managed-client.d.ts.map +1 -1
- package/apps/app-lifeops/src/lifeops/google-managed-client.js +32 -12
- package/apps/app-lifeops/src/lifeops/google-oauth.d.ts +4 -0
- package/apps/app-lifeops/src/lifeops/google-oauth.d.ts.map +1 -1
- package/apps/app-lifeops/src/lifeops/google-oauth.js +99 -13
- package/apps/app-lifeops/src/lifeops/health-bridge.d.ts +57 -0
- package/apps/app-lifeops/src/lifeops/health-bridge.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/health-bridge.js +514 -0
- package/apps/app-lifeops/src/lifeops/imessage-bridge.d.ts +98 -0
- package/apps/app-lifeops/src/lifeops/imessage-bridge.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/imessage-bridge.js +537 -0
- package/apps/app-lifeops/src/lifeops/intent-sync.d.ts +56 -0
- package/apps/app-lifeops/src/lifeops/intent-sync.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/intent-sync.js +223 -0
- package/apps/app-lifeops/src/lifeops/notifications-push.d.ts +37 -0
- package/apps/app-lifeops/src/lifeops/notifications-push.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/notifications-push.js +90 -0
- package/apps/app-lifeops/src/lifeops/owner-profile.d.ts +29 -1
- package/apps/app-lifeops/src/lifeops/owner-profile.d.ts.map +1 -1
- package/apps/app-lifeops/src/lifeops/owner-profile.js +106 -0
- package/apps/app-lifeops/src/lifeops/password-manager-bridge.d.ts +49 -0
- package/apps/app-lifeops/src/lifeops/password-manager-bridge.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/password-manager-bridge.js +374 -0
- package/apps/app-lifeops/src/lifeops/remote-desktop.d.ts +37 -0
- package/apps/app-lifeops/src/lifeops/remote-desktop.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/remote-desktop.js +341 -0
- package/apps/app-lifeops/src/lifeops/repository.d.ts +69 -3
- package/apps/app-lifeops/src/lifeops/repository.d.ts.map +1 -1
- package/apps/app-lifeops/src/lifeops/repository.js +1368 -926
- package/apps/app-lifeops/src/lifeops/runtime.d.ts +1 -0
- package/apps/app-lifeops/src/lifeops/runtime.d.ts.map +1 -1
- package/apps/app-lifeops/src/lifeops/runtime.js +119 -9
- package/apps/app-lifeops/src/lifeops/schema.d.ts +5022 -0
- package/apps/app-lifeops/src/lifeops/schema.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/schema.js +207 -0
- package/apps/app-lifeops/src/lifeops/service-constants.d.ts +51 -0
- package/apps/app-lifeops/src/lifeops/service-constants.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-constants.js +111 -0
- package/apps/app-lifeops/src/lifeops/service-helpers-browser.d.ts +40 -0
- package/apps/app-lifeops/src/lifeops/service-helpers-browser.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-helpers-browser.js +288 -0
- package/apps/app-lifeops/src/lifeops/service-helpers-misc.d.ts +68 -0
- package/apps/app-lifeops/src/lifeops/service-helpers-misc.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-helpers-misc.js +493 -0
- package/apps/app-lifeops/src/lifeops/service-helpers-occurrence.d.ts +17 -0
- package/apps/app-lifeops/src/lifeops/service-helpers-occurrence.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-helpers-occurrence.js +214 -0
- package/apps/app-lifeops/src/lifeops/service-helpers-reminder.d.ts +24 -0
- package/apps/app-lifeops/src/lifeops/service-helpers-reminder.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-helpers-reminder.js +170 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-browser.d.ts +2 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-browser.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-browser.js +769 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-calendar.d.ts +2 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-calendar.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-calendar.js +513 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-core.d.ts +49 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-core.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-core.js +433 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-definitions.d.ts +2 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-definitions.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-definitions.js +353 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-discord.d.ts +2 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-discord.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-discord.js +603 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-dossier.d.ts +2 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-dossier.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-dossier.js +262 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-drive.d.ts +12 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-drive.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-drive.js +230 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-gmail.d.ts +2 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-gmail.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-gmail.js +1013 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-goals.d.ts +2 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-goals.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-goals.js +714 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-google.d.ts +2 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-google.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-google.js +793 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-health.d.ts +2 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-health.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-health.js +55 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-imessage.d.ts +3 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-imessage.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-imessage.js +106 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-relationships.d.ts +2 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-relationships.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-relationships.js +109 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-reminders.d.ts +37 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-reminders.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-reminders.js +2436 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-scheduling.d.ts +2 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-scheduling.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-scheduling.js +149 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-screentime.d.ts +2 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-screentime.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-screentime.js +97 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-signal.d.ts +2 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-signal.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-signal.js +264 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-telegram.d.ts +2 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-telegram.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-telegram.js +270 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-whatsapp.d.ts +2 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-whatsapp.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-whatsapp.js +56 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-workflows.d.ts +2 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-workflows.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-workflows.js +411 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-x-read.d.ts +2 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-x-read.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-x-read.js +190 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-x.d.ts +2 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-x.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-mixin-x.js +120 -0
- package/apps/app-lifeops/src/lifeops/service-normalize-calendar.d.ts +42 -0
- package/apps/app-lifeops/src/lifeops/service-normalize-calendar.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-normalize-calendar.js +294 -0
- package/apps/app-lifeops/src/lifeops/service-normalize-connector.d.ts +18 -0
- package/apps/app-lifeops/src/lifeops/service-normalize-connector.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-normalize-connector.js +317 -0
- package/apps/app-lifeops/src/lifeops/service-normalize-gmail.d.ts +63 -0
- package/apps/app-lifeops/src/lifeops/service-normalize-gmail.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-normalize-gmail.js +553 -0
- package/apps/app-lifeops/src/lifeops/service-normalize-task.d.ts +8 -0
- package/apps/app-lifeops/src/lifeops/service-normalize-task.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-normalize-task.js +333 -0
- package/apps/app-lifeops/src/lifeops/service-normalize.d.ts +27 -0
- package/apps/app-lifeops/src/lifeops/service-normalize.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-normalize.js +193 -0
- package/apps/app-lifeops/src/lifeops/service-types.d.ts +43 -0
- package/apps/app-lifeops/src/lifeops/service-types.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/service-types.js +8 -0
- package/apps/app-lifeops/src/lifeops/service.d.ts +1566 -272
- package/apps/app-lifeops/src/lifeops/service.d.ts.map +1 -1
- package/apps/app-lifeops/src/lifeops/service.js +38 -9256
- package/apps/app-lifeops/src/lifeops/signal-auth.d.ts +26 -0
- package/apps/app-lifeops/src/lifeops/signal-auth.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/signal-auth.js +300 -0
- package/apps/app-lifeops/src/lifeops/signal-runtime-config.d.ts +13 -0
- package/apps/app-lifeops/src/lifeops/signal-runtime-config.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/signal-runtime-config.js +42 -0
- package/apps/app-lifeops/src/lifeops/sql.d.ts +0 -5
- package/apps/app-lifeops/src/lifeops/sql.d.ts.map +1 -1
- package/apps/app-lifeops/src/lifeops/sql.js +5 -125
- package/apps/app-lifeops/src/lifeops/telegram-auth.d.ts +62 -0
- package/apps/app-lifeops/src/lifeops/telegram-auth.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/telegram-auth.js +496 -0
- package/apps/app-lifeops/src/lifeops/telegram-local-client.d.ts +118 -0
- package/apps/app-lifeops/src/lifeops/telegram-local-client.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/telegram-local-client.js +376 -0
- package/apps/app-lifeops/src/lifeops/twilio.d.ts.map +1 -1
- package/apps/app-lifeops/src/lifeops/twilio.js +2 -1
- package/apps/app-lifeops/src/lifeops/unified-search.d.ts +88 -0
- package/apps/app-lifeops/src/lifeops/unified-search.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/unified-search.js +431 -0
- package/apps/app-lifeops/src/lifeops/whatsapp-client.d.ts +47 -0
- package/apps/app-lifeops/src/lifeops/whatsapp-client.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/whatsapp-client.js +198 -0
- package/apps/app-lifeops/src/lifeops/x-poster.d.ts +22 -0
- package/apps/app-lifeops/src/lifeops/x-poster.d.ts.map +1 -1
- package/apps/app-lifeops/src/lifeops/x-poster.js +67 -3
- package/apps/app-lifeops/src/lifeops/x-reader.d.ts +70 -0
- package/apps/app-lifeops/src/lifeops/x-reader.d.ts.map +1 -0
- package/apps/app-lifeops/src/lifeops/x-reader.js +260 -0
- package/apps/app-lifeops/src/plugin.d.ts +12 -1
- package/apps/app-lifeops/src/plugin.d.ts.map +1 -1
- package/apps/app-lifeops/src/plugin.js +245 -26
- package/apps/app-lifeops/src/provider.d.ts.map +1 -1
- package/apps/app-lifeops/src/provider.js +1 -0
- package/apps/app-lifeops/src/providers/activity-profile.d.ts.map +1 -0
- package/apps/app-lifeops/src/providers/activity-profile.js +140 -0
- package/apps/app-lifeops/src/providers/app-blocker.d.ts +3 -0
- package/apps/app-lifeops/src/providers/app-blocker.d.ts.map +1 -0
- package/apps/app-lifeops/src/providers/app-blocker.js +86 -0
- package/apps/app-lifeops/src/providers/cross-channel-context.d.ts +29 -0
- package/apps/app-lifeops/src/providers/cross-channel-context.d.ts.map +1 -0
- package/apps/app-lifeops/src/providers/cross-channel-context.js +193 -0
- package/apps/app-lifeops/src/providers/inbox-triage.d.ts.map +1 -1
- package/apps/app-lifeops/src/providers/inbox-triage.js +1 -0
- package/apps/app-lifeops/src/providers/lifeops.d.ts +1 -1
- package/apps/app-lifeops/src/providers/lifeops.d.ts.map +1 -1
- package/apps/app-lifeops/src/providers/lifeops.js +39 -11
- package/apps/app-lifeops/src/providers/website-blocker.d.ts +4 -0
- package/apps/app-lifeops/src/providers/website-blocker.d.ts.map +1 -0
- package/apps/app-lifeops/src/providers/website-blocker.js +117 -0
- package/apps/app-lifeops/src/remote/pairing-code.d.ts +39 -0
- package/apps/app-lifeops/src/remote/pairing-code.d.ts.map +1 -0
- package/apps/app-lifeops/src/remote/pairing-code.js +76 -0
- package/apps/app-lifeops/src/remote/remote-session-service.d.ts +107 -0
- package/apps/app-lifeops/src/remote/remote-session-service.d.ts.map +1 -0
- package/apps/app-lifeops/src/remote/remote-session-service.js +253 -0
- package/apps/app-lifeops/src/routes/lifeops-browser-packaging.d.ts.map +1 -1
- package/apps/app-lifeops/src/routes/lifeops-browser-packaging.js +9 -3
- package/apps/app-lifeops/src/routes/lifeops-routes.d.ts +1 -1
- package/apps/app-lifeops/src/routes/lifeops-routes.d.ts.map +1 -1
- package/apps/app-lifeops/src/routes/lifeops-routes.js +276 -40
- package/apps/app-lifeops/src/routes/website-blocker-routes.d.ts.map +1 -1
- package/apps/app-lifeops/src/routes/website-blocker-routes.js +8 -13
- package/apps/app-lifeops/src/travel-time/action.d.ts +6 -0
- package/apps/app-lifeops/src/travel-time/action.d.ts.map +1 -0
- package/apps/app-lifeops/src/travel-time/action.js +81 -0
- package/apps/app-lifeops/src/travel-time/service.d.ts +61 -0
- package/apps/app-lifeops/src/travel-time/service.d.ts.map +1 -0
- package/apps/app-lifeops/src/travel-time/service.js +145 -0
- package/apps/app-lifeops/src/types/app-blocker-settings-card.d.ts +2 -0
- package/apps/app-lifeops/src/types/app-blocker-settings-card.d.ts.map +1 -0
- package/apps/app-lifeops/src/types/index.d.ts +3 -0
- package/apps/app-lifeops/src/types/index.d.ts.map +1 -0
- package/apps/app-lifeops/src/types/website-blocker-settings-card.d.ts +2 -0
- package/apps/app-lifeops/src/types/website-blocker-settings-card.d.ts.map +1 -0
- package/apps/app-lifeops/src/website-blocker/access.d.ts +8 -0
- package/apps/app-lifeops/src/website-blocker/access.d.ts.map +1 -0
- package/apps/app-lifeops/src/website-blocker/access.js +32 -0
- package/apps/app-lifeops/src/website-blocker/chat-integration/actions/blockUntilTaskComplete.d.ts +3 -0
- package/apps/app-lifeops/src/website-blocker/chat-integration/actions/blockUntilTaskComplete.d.ts.map +1 -0
- package/apps/app-lifeops/src/website-blocker/chat-integration/actions/blockUntilTaskComplete.js +212 -0
- package/apps/app-lifeops/src/website-blocker/chat-integration/actions/listActiveBlocks.d.ts +3 -0
- package/apps/app-lifeops/src/website-blocker/chat-integration/actions/listActiveBlocks.d.ts.map +1 -0
- package/apps/app-lifeops/src/website-blocker/chat-integration/actions/listActiveBlocks.js +57 -0
- package/apps/app-lifeops/src/website-blocker/chat-integration/actions/releaseBlock.d.ts +3 -0
- package/apps/app-lifeops/src/website-blocker/chat-integration/actions/releaseBlock.d.ts.map +1 -0
- package/apps/app-lifeops/src/website-blocker/chat-integration/actions/releaseBlock.js +98 -0
- package/apps/app-lifeops/src/website-blocker/chat-integration/block-rule-reconciler.d.ts +7 -0
- package/apps/app-lifeops/src/website-blocker/chat-integration/block-rule-reconciler.d.ts.map +1 -0
- package/apps/app-lifeops/src/website-blocker/chat-integration/block-rule-reconciler.js +111 -0
- package/apps/app-lifeops/src/website-blocker/chat-integration/block-rule-schema.d.ts +39 -0
- package/apps/app-lifeops/src/website-blocker/chat-integration/block-rule-schema.d.ts.map +1 -0
- package/apps/app-lifeops/src/website-blocker/chat-integration/block-rule-schema.js +123 -0
- package/apps/app-lifeops/src/website-blocker/chat-integration/block-rule-service.d.ts +21 -0
- package/apps/app-lifeops/src/website-blocker/chat-integration/block-rule-service.d.ts.map +1 -0
- package/apps/app-lifeops/src/website-blocker/chat-integration/block-rule-service.js +227 -0
- package/apps/app-lifeops/src/website-blocker/chat-integration/index.d.ts +8 -0
- package/apps/app-lifeops/src/website-blocker/chat-integration/index.d.ts.map +1 -0
- package/apps/app-lifeops/src/website-blocker/chat-integration/index.js +6 -0
- package/apps/app-lifeops/src/website-blocker/engine.d.ts +116 -0
- package/apps/app-lifeops/src/website-blocker/engine.d.ts.map +1 -0
- package/apps/app-lifeops/src/website-blocker/engine.js +934 -0
- package/apps/app-lifeops/src/website-blocker/permissions.d.ts.map +1 -0
- package/apps/app-lifeops/src/website-blocker/permissions.js +1 -0
- package/apps/app-lifeops/src/website-blocker/public.d.ts +13 -0
- package/apps/app-lifeops/src/website-blocker/public.d.ts.map +1 -0
- package/apps/app-lifeops/src/website-blocker/public.js +10 -0
- package/apps/app-lifeops/src/website-blocker/roles.d.ts +13 -0
- package/apps/app-lifeops/src/website-blocker/roles.d.ts.map +1 -0
- package/apps/app-lifeops/src/website-blocker/roles.js +20 -0
- package/apps/app-lifeops/src/website-blocker/service.d.ts +21 -0
- package/apps/app-lifeops/src/website-blocker/service.d.ts.map +1 -0
- package/apps/app-lifeops/src/website-blocker/service.js +268 -0
- package/apps/app-steward/src/api/tx-service.d.ts +47 -0
- package/apps/app-steward/src/api/tx-service.d.ts.map +1 -0
- package/apps/app-steward/src/api/tx-service.js +156 -0
- package/apps/app-steward/src/api/wallet-routes.d.ts +1 -9
- package/apps/app-steward/src/api/wallet-routes.d.ts.map +1 -1
- package/apps/app-steward/src/routes/wallet-export-guard.d.ts +2 -9
- package/apps/app-steward/src/routes/wallet-export-guard.d.ts.map +1 -1
- package/apps/app-steward/src/types/steward.d.ts +85 -0
- package/apps/app-steward/src/types/steward.d.ts.map +1 -0
- package/apps/app-steward/src/types/steward.js +9 -0
- package/apps/app-training/src/backends/atropos.d.ts +31 -0
- package/apps/app-training/src/backends/atropos.d.ts.map +1 -0
- package/apps/app-training/src/backends/atropos.js +63 -0
- package/apps/app-training/src/backends/native.d.ts +50 -0
- package/apps/app-training/src/backends/native.d.ts.map +1 -0
- package/apps/app-training/src/backends/native.js +128 -0
- package/apps/app-training/src/backends/tinker.d.ts +27 -0
- package/apps/app-training/src/backends/tinker.d.ts.map +1 -0
- package/apps/app-training/src/backends/tinker.js +56 -0
- package/apps/app-training/src/core/privacy-filter.d.ts +73 -0
- package/apps/app-training/src/core/privacy-filter.d.ts.map +1 -0
- package/apps/app-training/src/core/privacy-filter.js +169 -0
- package/apps/app-training/src/core/training-config.d.ts +52 -0
- package/apps/app-training/src/core/training-config.d.ts.map +1 -0
- package/apps/app-training/src/core/training-config.js +140 -0
- package/apps/app-training/src/core/training-orchestrator.d.ts +107 -0
- package/apps/app-training/src/core/training-orchestrator.d.ts.map +1 -0
- package/apps/app-training/src/core/training-orchestrator.js +409 -0
- package/apps/app-training/src/core/trajectory-task-datasets.d.ts +38 -0
- package/apps/app-training/src/core/trajectory-task-datasets.d.ts.map +1 -0
- package/apps/app-training/src/core/trajectory-task-datasets.js +281 -0
- package/apps/app-training/src/optimizers/bootstrap-fewshot.d.ts +42 -0
- package/apps/app-training/src/optimizers/bootstrap-fewshot.d.ts.map +1 -0
- package/apps/app-training/src/optimizers/bootstrap-fewshot.js +91 -0
- package/apps/app-training/src/optimizers/index.d.ts +6 -0
- package/apps/app-training/src/optimizers/index.d.ts.map +1 -0
- package/apps/app-training/src/optimizers/index.js +4 -0
- package/apps/app-training/src/optimizers/instruction-search.d.ts +39 -0
- package/apps/app-training/src/optimizers/instruction-search.d.ts.map +1 -0
- package/apps/app-training/src/optimizers/instruction-search.js +82 -0
- package/apps/app-training/src/optimizers/prompt-evolution.d.ts +39 -0
- package/apps/app-training/src/optimizers/prompt-evolution.d.ts.map +1 -0
- package/apps/app-training/src/optimizers/prompt-evolution.js +111 -0
- package/apps/app-training/src/optimizers/scoring.d.ts +63 -0
- package/apps/app-training/src/optimizers/scoring.d.ts.map +1 -0
- package/apps/app-training/src/optimizers/scoring.js +117 -0
- package/apps/app-training/src/optimizers/types.d.ts +105 -0
- package/apps/app-training/src/optimizers/types.d.ts.map +1 -0
- package/apps/app-training/src/optimizers/types.js +17 -0
- package/apps/app-training/src/services/index.d.ts +1 -0
- package/apps/app-training/src/services/index.d.ts.map +1 -1
- package/apps/app-training/src/services/index.js +1 -0
- package/apps/app-training/src/services/training-trigger.d.ts +166 -0
- package/apps/app-training/src/services/training-trigger.d.ts.map +1 -0
- package/apps/app-training/src/services/training-trigger.js +376 -0
- package/package.json +26 -21
- package/packages/agent/src/actions/app-control.js +1 -1
- package/packages/agent/src/actions/connector-resolver.d.ts.map +1 -1
- package/packages/agent/src/actions/connector-resolver.js +17 -7
- package/packages/agent/src/actions/context-signal-lexicon.d.ts +1 -1
- package/packages/agent/src/actions/context-signal-lexicon.d.ts.map +1 -1
- package/packages/agent/src/actions/context-signal-lexicon.js +7 -1
- package/packages/agent/src/actions/context-signal.d.ts +1 -1
- package/packages/agent/src/actions/context-signal.d.ts.map +1 -1
- package/packages/agent/src/actions/context-signal.js +1 -1
- package/packages/agent/src/actions/eject-plugin.d.ts.map +1 -1
- package/packages/agent/src/actions/eject-plugin.js +3 -1
- package/packages/agent/src/actions/entity-actions.d.ts +1 -0
- package/packages/agent/src/actions/entity-actions.d.ts.map +1 -1
- package/packages/agent/src/actions/entity-actions.js +233 -1
- package/packages/agent/src/actions/get-self-status.d.ts.map +1 -1
- package/packages/agent/src/actions/get-self-status.js +12 -1
- package/packages/agent/src/actions/grounded-action-reply.d.ts.map +1 -1
- package/packages/agent/src/actions/grounded-action-reply.js +1 -1
- package/packages/agent/src/actions/index.d.ts +0 -9
- package/packages/agent/src/actions/index.d.ts.map +1 -1
- package/packages/agent/src/actions/index.js +0 -9
- package/packages/agent/src/actions/install-plugin.d.ts.map +1 -1
- package/packages/agent/src/actions/install-plugin.js +3 -1
- package/packages/agent/src/actions/list-ejected.d.ts.map +1 -1
- package/packages/agent/src/actions/list-ejected.js +5 -3
- package/packages/agent/src/actions/reinject-plugin.d.ts.map +1 -1
- package/packages/agent/src/actions/reinject-plugin.js +3 -1
- package/packages/agent/src/actions/set-user-name.d.ts.map +1 -1
- package/packages/agent/src/actions/set-user-name.js +1 -1
- package/packages/agent/src/actions/sync-plugin.d.ts.map +1 -1
- package/packages/agent/src/actions/sync-plugin.js +5 -6
- package/packages/agent/src/api/agent-admin-routes.js +1 -1
- package/packages/agent/src/api/apps-routes.d.ts +2 -1
- package/packages/agent/src/api/apps-routes.d.ts.map +1 -1
- package/packages/agent/src/api/apps-routes.js +152 -2
- package/packages/agent/src/api/auth-routes.js +1 -1
- package/packages/agent/src/api/bsc-trade.d.ts +0 -4
- package/packages/agent/src/api/bsc-trade.d.ts.map +1 -1
- package/packages/agent/src/api/bsc-trade.js +0 -4
- package/packages/agent/src/api/character-routes.d.ts +2 -1
- package/packages/agent/src/api/character-routes.d.ts.map +1 -1
- package/packages/agent/src/api/chat-augmentation.js +1 -1
- package/packages/agent/src/api/chat-routes.d.ts.map +1 -1
- package/packages/agent/src/api/chat-routes.js +23 -108
- package/packages/agent/src/api/cloud-billing-routes.d.ts +1 -1
- package/packages/agent/src/api/cloud-billing-routes.d.ts.map +1 -1
- package/packages/agent/src/api/cloud-compat-routes.d.ts +1 -1
- package/packages/agent/src/api/cloud-compat-routes.d.ts.map +1 -1
- package/packages/agent/src/api/connector-health.d.ts +1 -1
- package/packages/agent/src/api/connector-health.d.ts.map +1 -1
- package/packages/agent/src/api/conversation-routes.d.ts +2 -2
- package/packages/agent/src/api/conversation-routes.d.ts.map +1 -1
- package/packages/agent/src/api/conversation-routes.js +1 -1
- package/packages/agent/src/api/curated-skills-routes.d.ts +22 -0
- package/packages/agent/src/api/curated-skills-routes.d.ts.map +1 -0
- package/packages/agent/src/api/curated-skills-routes.js +300 -0
- package/packages/agent/src/api/database.d.ts.map +1 -1
- package/packages/agent/src/api/database.js +11 -4
- package/packages/agent/src/api/discord-profiles.d.ts.map +1 -1
- package/packages/agent/src/api/discord-profiles.js +1 -4
- package/packages/agent/src/api/index.d.ts +0 -7
- package/packages/agent/src/api/index.d.ts.map +1 -1
- package/packages/agent/src/api/index.js +0 -7
- package/packages/agent/src/api/knowledge-routes.d.ts +22 -1
- package/packages/agent/src/api/knowledge-routes.d.ts.map +1 -1
- package/packages/agent/src/api/knowledge-routes.js +956 -2
- package/packages/agent/src/api/lifeops-browser-packaging.d.ts +1 -1
- package/packages/agent/src/api/lifeops-browser-packaging.d.ts.map +1 -1
- package/packages/agent/src/api/lifeops-browser-packaging.js +1 -1
- package/packages/agent/src/api/misc-routes.d.ts +2 -2
- package/packages/agent/src/api/misc-routes.d.ts.map +1 -1
- package/packages/agent/src/api/misc-routes.js +43 -6
- package/packages/agent/src/api/plugin-discovery-helpers.d.ts.map +1 -1
- package/packages/agent/src/api/plugin-discovery-helpers.js +2 -2
- package/packages/agent/src/api/plugin-routes.d.ts +1 -1
- package/packages/agent/src/api/plugin-routes.d.ts.map +1 -1
- package/packages/agent/src/api/plugin-routes.js +11 -2
- package/packages/agent/src/api/registry-service.d.ts +1 -1
- package/packages/agent/src/api/registry-service.d.ts.map +1 -1
- package/packages/agent/src/api/relationships-routes.d.ts.map +1 -1
- package/packages/agent/src/api/relationships-routes.js +70 -3
- package/packages/agent/src/api/server-auth.d.ts +2 -9
- package/packages/agent/src/api/server-auth.d.ts.map +1 -1
- package/packages/agent/src/api/server-auth.js +1 -1
- package/packages/agent/src/api/server-helpers-auth.d.ts +39 -0
- package/packages/agent/src/api/server-helpers-auth.d.ts.map +1 -0
- package/packages/agent/src/api/server-helpers-auth.js +432 -0
- package/packages/agent/src/api/server-helpers-config.d.ts +37 -0
- package/packages/agent/src/api/server-helpers-config.d.ts.map +1 -0
- package/packages/agent/src/api/server-helpers-config.js +295 -0
- package/packages/agent/src/api/server-helpers-mcp.d.ts +12 -0
- package/packages/agent/src/api/server-helpers-mcp.d.ts.map +1 -0
- package/packages/agent/src/api/server-helpers-mcp.js +315 -0
- package/packages/agent/src/api/server-helpers-plugin.d.ts +13 -0
- package/packages/agent/src/api/server-helpers-plugin.d.ts.map +1 -0
- package/packages/agent/src/api/server-helpers-plugin.js +158 -0
- package/packages/agent/src/api/server-helpers-swarm.d.ts +57 -0
- package/packages/agent/src/api/server-helpers-swarm.d.ts.map +1 -0
- package/packages/agent/src/api/server-helpers-swarm.js +325 -0
- package/packages/agent/src/api/server-helpers-wallet.d.ts +18 -0
- package/packages/agent/src/api/server-helpers-wallet.d.ts.map +1 -0
- package/packages/agent/src/api/server-helpers-wallet.js +178 -0
- package/packages/agent/src/api/server-helpers.d.ts.map +1 -1
- package/packages/agent/src/api/server-helpers.js +1 -1
- package/packages/agent/src/api/server-types.d.ts +42 -3
- package/packages/agent/src/api/server-types.d.ts.map +1 -1
- package/packages/agent/src/api/server.d.ts +10 -56
- package/packages/agent/src/api/server.d.ts.map +1 -1
- package/packages/agent/src/api/server.js +298 -1436
- package/packages/agent/src/api/signal-routes.d.ts +1 -1
- package/packages/agent/src/api/signal-routes.d.ts.map +1 -1
- package/packages/agent/src/api/signal-routes.js +1 -2
- package/packages/agent/src/api/skill-discovery-helpers.js +2 -0
- package/packages/agent/src/api/skills-routes.d.ts.map +1 -1
- package/packages/agent/src/api/skills-routes.js +69 -0
- package/packages/agent/src/api/static-file-server.js +1 -1
- package/packages/agent/src/api/stream-routes.d.ts +0 -19
- package/packages/agent/src/api/stream-routes.d.ts.map +1 -1
- package/packages/agent/src/api/trade-safety.d.ts +0 -4
- package/packages/agent/src/api/trade-safety.d.ts.map +1 -1
- package/packages/agent/src/api/trade-safety.js +0 -4
- package/packages/agent/src/api/trigger-routes.d.ts +37 -47
- package/packages/agent/src/api/trigger-routes.d.ts.map +1 -1
- package/packages/agent/src/api/trigger-routes.js +89 -18
- package/packages/agent/src/api/tts-routes.d.ts.map +1 -1
- package/packages/agent/src/api/tts-routes.js +1 -1
- package/packages/agent/src/api/tx-service.d.ts +0 -4
- package/packages/agent/src/api/tx-service.d.ts.map +1 -1
- package/packages/agent/src/api/tx-service.js +0 -4
- package/packages/agent/src/api/wallet-bsc-routes.d.ts +0 -4
- package/packages/agent/src/api/wallet-bsc-routes.d.ts.map +1 -1
- package/packages/agent/src/api/wallet-bsc-routes.js +0 -4
- package/packages/agent/src/api/wallet-capability.d.ts +0 -5
- package/packages/agent/src/api/wallet-capability.d.ts.map +1 -1
- package/packages/agent/src/api/wallet-capability.js +0 -5
- package/packages/agent/src/api/wallet-dex-prices.d.ts.map +1 -1
- package/packages/agent/src/api/wallet-dex-prices.js +0 -4
- package/packages/agent/src/api/wallet-env-sync.d.ts.map +1 -1
- package/packages/agent/src/api/wallet-env-sync.js +5 -1
- package/packages/agent/src/api/wallet-evm-balance.d.ts.map +1 -1
- package/packages/agent/src/api/wallet-evm-balance.js +0 -4
- package/packages/agent/src/api/wallet-routes.d.ts +1 -14
- package/packages/agent/src/api/wallet-routes.d.ts.map +1 -1
- package/packages/agent/src/api/wallet-routes.js +9 -15
- package/packages/agent/src/api/wallet-rpc.d.ts +0 -5
- package/packages/agent/src/api/wallet-rpc.d.ts.map +1 -1
- package/packages/agent/src/api/wallet-rpc.js +0 -5
- package/packages/agent/src/api/wallet-trade-routes.d.ts +0 -5
- package/packages/agent/src/api/wallet-trade-routes.d.ts.map +1 -1
- package/packages/agent/src/api/wallet-trade-routes.js +0 -5
- package/packages/agent/src/api/wallet-trading-profile.d.ts +2 -27
- package/packages/agent/src/api/wallet-trading-profile.d.ts.map +1 -1
- package/packages/agent/src/api/wallet-trading-profile.js +0 -5
- package/packages/agent/src/api/wallet.d.ts.map +1 -1
- package/packages/agent/src/api/wallet.js +0 -4
- package/packages/agent/src/api/whatsapp-routes.d.ts +1 -1
- package/packages/agent/src/api/whatsapp-routes.d.ts.map +1 -1
- package/packages/agent/src/api/whatsapp-routes.js +1 -2
- package/packages/agent/src/api/workbench-helpers.d.ts.map +1 -1
- package/packages/agent/src/api/workbench-helpers.js +2 -1
- package/packages/agent/src/api/workbench-routes.d.ts.map +1 -1
- package/packages/agent/src/api/workbench-routes.js +1 -1
- package/packages/agent/src/auth/anthropic.d.ts +0 -5
- package/packages/agent/src/auth/anthropic.d.ts.map +1 -1
- package/packages/agent/src/auth/anthropic.js +0 -5
- package/packages/agent/src/auth/openai-codex.d.ts +0 -5
- package/packages/agent/src/auth/openai-codex.d.ts.map +1 -1
- package/packages/agent/src/auth/openai-codex.js +0 -5
- package/packages/agent/src/cloud/cloud-wallet.d.ts +0 -2
- package/packages/agent/src/cloud/cloud-wallet.d.ts.map +1 -1
- package/packages/agent/src/config/env-vars.d.ts.map +1 -1
- package/packages/agent/src/config/env-vars.js +2 -0
- package/packages/agent/src/config/includes.js +1 -1
- package/packages/agent/src/config/index.d.ts +1 -1
- package/packages/agent/src/config/index.d.ts.map +1 -1
- package/packages/agent/src/config/index.js +1 -1
- package/packages/agent/src/config/plugin-auto-enable.d.ts +8 -0
- package/packages/agent/src/config/plugin-auto-enable.d.ts.map +1 -1
- package/packages/agent/src/config/plugin-auto-enable.js +28 -0
- package/packages/agent/src/config/types.agent-defaults.d.ts +2 -1
- package/packages/agent/src/config/types.agent-defaults.d.ts.map +1 -1
- package/packages/agent/src/config/types.eliza.d.ts +34 -0
- package/packages/agent/src/config/types.eliza.d.ts.map +1 -1
- package/packages/agent/src/contracts/index.d.ts +8 -8
- package/packages/agent/src/contracts/index.d.ts.map +1 -1
- package/packages/agent/src/contracts/index.js +8 -8
- package/packages/agent/src/contracts/onboarding-provider-defaults.d.ts +165 -0
- package/packages/agent/src/contracts/onboarding-provider-defaults.d.ts.map +1 -0
- package/packages/agent/src/contracts/onboarding-provider-defaults.js +189 -0
- package/packages/agent/src/index.d.ts +8 -6
- package/packages/agent/src/index.d.ts.map +1 -1
- package/packages/agent/src/index.js +8 -6
- package/packages/agent/src/providers/conversation-utils.d.ts.map +1 -1
- package/packages/agent/src/providers/conversation-utils.js +2 -3
- package/packages/agent/src/providers/index.d.ts +0 -1
- package/packages/agent/src/providers/index.d.ts.map +1 -1
- package/packages/agent/src/providers/index.js +0 -1
- package/packages/agent/src/providers/user-name.d.ts.map +1 -1
- package/packages/agent/src/providers/user-name.js +1 -1
- package/packages/agent/src/providers/workspace-provider.d.ts +0 -8
- package/packages/agent/src/providers/workspace-provider.d.ts.map +1 -1
- package/packages/agent/src/runtime/custom-actions.js +1 -1
- package/packages/agent/src/runtime/eliza-plugin.d.ts.map +1 -1
- package/packages/agent/src/runtime/eliza-plugin.js +1 -47
- package/packages/agent/src/runtime/eliza.d.ts +1 -91
- package/packages/agent/src/runtime/eliza.d.ts.map +1 -1
- package/packages/agent/src/runtime/eliza.js +109 -12
- package/packages/agent/src/runtime/first-time-setup.d.ts +20 -0
- package/packages/agent/src/runtime/first-time-setup.d.ts.map +1 -1
- package/packages/agent/src/runtime/first-time-setup.js +20 -25
- package/packages/agent/src/runtime/index.d.ts +1 -1
- package/packages/agent/src/runtime/index.d.ts.map +1 -1
- package/packages/agent/src/runtime/index.js +1 -1
- package/packages/agent/src/runtime/plugin-collector.d.ts +0 -12
- package/packages/agent/src/runtime/plugin-collector.d.ts.map +1 -1
- package/packages/agent/src/runtime/plugin-lifecycle.d.ts.map +1 -1
- package/packages/agent/src/runtime/plugin-lifecycle.js +6 -2
- package/packages/agent/src/runtime/plugin-resolver.d.ts.map +1 -1
- package/packages/agent/src/runtime/plugin-resolver.js +6 -7
- package/packages/agent/src/runtime/plugin-types.d.ts +0 -6
- package/packages/agent/src/runtime/plugin-types.d.ts.map +1 -1
- package/packages/agent/src/runtime/roles/src/utils.d.ts +1 -1
- package/packages/agent/src/runtime/roles/src/utils.d.ts.map +1 -1
- package/packages/agent/src/runtime/roles/src/utils.js +1 -1
- package/packages/agent/src/runtime/subagent-output.d.ts +51 -0
- package/packages/agent/src/runtime/subagent-output.d.ts.map +1 -0
- package/packages/agent/src/runtime/subagent-output.js +173 -0
- package/packages/agent/src/runtime/task-heartbeat.d.ts +22 -0
- package/packages/agent/src/runtime/task-heartbeat.d.ts.map +1 -0
- package/packages/agent/src/runtime/task-heartbeat.js +84 -0
- package/packages/agent/src/runtime/trajectory-internals.d.ts +37 -30
- package/packages/agent/src/runtime/trajectory-internals.d.ts.map +1 -1
- package/packages/agent/src/runtime/trajectory-internals.js +73 -47
- package/packages/agent/src/runtime/trajectory-persistence.d.ts +1 -1
- package/packages/agent/src/runtime/trajectory-persistence.d.ts.map +1 -1
- package/packages/agent/src/runtime/trajectory-persistence.js +1 -1
- package/packages/agent/src/runtime/trajectory-storage.d.ts +27 -1
- package/packages/agent/src/runtime/trajectory-storage.d.ts.map +1 -1
- package/packages/agent/src/runtime/trajectory-storage.js +124 -1
- package/packages/agent/src/runtime/web-search-tools.d.ts.map +1 -1
- package/packages/agent/src/security/access.d.ts.map +1 -1
- package/packages/agent/src/security/access.js +6 -26
- package/packages/agent/src/security/audit-log.d.ts +0 -2
- package/packages/agent/src/security/audit-log.d.ts.map +1 -1
- package/packages/agent/src/security/index.d.ts +1 -0
- package/packages/agent/src/security/index.d.ts.map +1 -1
- package/packages/agent/src/security/index.js +1 -0
- package/packages/agent/src/services/app-manager.d.ts +53 -1
- package/packages/agent/src/services/app-manager.d.ts.map +1 -1
- package/packages/agent/src/services/app-manager.js +219 -15
- package/packages/agent/src/services/app-package-modules.d.ts +3 -12
- package/packages/agent/src/services/app-package-modules.d.ts.map +1 -1
- package/packages/agent/src/services/app-package-modules.js +78 -11
- package/packages/agent/src/services/browser-workspace-desktop.d.ts +22 -0
- package/packages/agent/src/services/browser-workspace-desktop.d.ts.map +1 -0
- package/packages/agent/src/services/browser-workspace-desktop.js +1379 -0
- package/packages/agent/src/services/browser-workspace-elements.d.ts +42 -0
- package/packages/agent/src/services/browser-workspace-elements.d.ts.map +1 -0
- package/packages/agent/src/services/browser-workspace-elements.js +508 -0
- package/packages/agent/src/services/browser-workspace-forms.d.ts +19 -0
- package/packages/agent/src/services/browser-workspace-forms.d.ts.map +1 -0
- package/packages/agent/src/services/browser-workspace-forms.js +244 -0
- package/packages/agent/src/services/browser-workspace-helpers.d.ts +20 -0
- package/packages/agent/src/services/browser-workspace-helpers.d.ts.map +1 -0
- package/packages/agent/src/services/browser-workspace-helpers.js +121 -0
- package/packages/agent/src/services/browser-workspace-jsdom.d.ts +16 -0
- package/packages/agent/src/services/browser-workspace-jsdom.d.ts.map +1 -0
- package/packages/agent/src/services/browser-workspace-jsdom.js +223 -0
- package/packages/agent/src/services/browser-workspace-network.d.ts +7 -0
- package/packages/agent/src/services/browser-workspace-network.d.ts.map +1 -0
- package/packages/agent/src/services/browser-workspace-network.js +137 -0
- package/packages/agent/src/services/browser-workspace-snapshots.d.ts +14 -0
- package/packages/agent/src/services/browser-workspace-snapshots.d.ts.map +1 -0
- package/packages/agent/src/services/browser-workspace-snapshots.js +144 -0
- package/packages/agent/src/services/browser-workspace-state.d.ts +22 -0
- package/packages/agent/src/services/browser-workspace-state.d.ts.map +1 -0
- package/packages/agent/src/services/browser-workspace-state.js +129 -0
- package/packages/agent/src/services/browser-workspace-types.d.ts +262 -0
- package/packages/agent/src/services/browser-workspace-types.d.ts.map +1 -0
- package/packages/agent/src/services/browser-workspace-types.js +1 -0
- package/packages/agent/src/services/browser-workspace-web.d.ts +8 -0
- package/packages/agent/src/services/browser-workspace-web.d.ts.map +1 -0
- package/packages/agent/src/services/browser-workspace-web.js +1141 -0
- package/packages/agent/src/services/browser-workspace.d.ts +22 -165
- package/packages/agent/src/services/browser-workspace.d.ts.map +1 -1
- package/packages/agent/src/services/browser-workspace.js +89 -4043
- package/packages/agent/src/services/built-in-app-routes/hyperscape.d.ts.map +1 -1
- package/packages/agent/src/services/built-in-app-routes/hyperscape.js +9 -6
- package/packages/agent/src/services/character-persistence.d.ts.map +1 -1
- package/packages/agent/src/services/character-persistence.js +1 -2
- package/packages/agent/src/services/client-chat-sender.d.ts.map +1 -1
- package/packages/agent/src/services/coding-task-executor.d.ts +2 -8
- package/packages/agent/src/services/coding-task-executor.d.ts.map +1 -1
- package/packages/agent/src/services/coding-task-executor.js +34 -66
- package/packages/agent/src/services/connector-setup-service.d.ts +4 -4
- package/packages/agent/src/services/connector-setup-service.d.ts.map +1 -1
- package/packages/agent/src/services/escalation.d.ts.map +1 -1
- package/packages/agent/src/services/escalation.js +1 -1
- package/packages/agent/src/services/plugin-manager-types.d.ts +1 -0
- package/packages/agent/src/services/plugin-manager-types.d.ts.map +1 -1
- package/packages/agent/src/services/privy-wallets.d.ts +0 -5
- package/packages/agent/src/services/privy-wallets.d.ts.map +1 -1
- package/packages/agent/src/services/privy-wallets.js +0 -5
- package/packages/agent/src/services/registry-client-app-meta.d.ts.map +1 -1
- package/packages/agent/src/services/registry-client-app-meta.js +1 -0
- package/packages/agent/src/services/registry-client-local.d.ts.map +1 -1
- package/packages/agent/src/services/registry-client-local.js +1 -0
- package/packages/agent/src/services/registry-client-network.d.ts.map +1 -1
- package/packages/agent/src/services/registry-client-network.js +1 -0
- package/packages/agent/src/services/registry-client-queries.d.ts +11 -0
- package/packages/agent/src/services/registry-client-queries.d.ts.map +1 -1
- package/packages/agent/src/services/registry-client-queries.js +23 -0
- package/packages/agent/src/services/registry-client-types.d.ts +8 -32
- package/packages/agent/src/services/registry-client-types.d.ts.map +1 -1
- package/packages/agent/src/services/relationships-graph.d.ts +62 -1
- package/packages/agent/src/services/relationships-graph.d.ts.map +1 -1
- package/packages/agent/src/services/relationships-graph.js +116 -6
- package/packages/agent/src/services/signal-pairing.d.ts.map +1 -1
- package/packages/agent/src/services/signal-pairing.js +15 -1
- package/packages/agent/src/services/steward-evm-account.d.ts +0 -4
- package/packages/agent/src/services/steward-evm-account.d.ts.map +1 -1
- package/packages/agent/src/services/steward-evm-account.js +0 -4
- package/packages/agent/src/services/steward-evm-bridge.d.ts +0 -4
- package/packages/agent/src/services/steward-evm-bridge.d.ts.map +1 -1
- package/packages/agent/src/services/steward-evm-bridge.js +0 -4
- package/packages/agent/src/services/steward-wallet.d.ts +1 -6
- package/packages/agent/src/services/steward-wallet.d.ts.map +1 -1
- package/packages/agent/src/services/steward-wallet.js +0 -5
- package/packages/agent/src/services/tts-stream-bridge.d.ts.map +1 -1
- package/packages/agent/src/services/tts-stream-bridge.js +1 -1
- package/packages/agent/src/test-support/route-test-helpers.d.ts +2 -2
- package/packages/agent/src/test-support/route-test-helpers.d.ts.map +1 -1
- package/packages/agent/src/test-support/test-helpers.d.ts +2 -2
- package/packages/agent/src/test-support/test-helpers.d.ts.map +1 -1
- package/packages/agent/src/triggers/runtime.d.ts +1 -0
- package/packages/agent/src/triggers/runtime.d.ts.map +1 -1
- package/packages/agent/src/triggers/runtime.js +67 -16
- package/packages/agent/src/triggers/scheduling.d.ts +6 -1
- package/packages/agent/src/triggers/scheduling.d.ts.map +1 -1
- package/packages/agent/src/triggers/scheduling.js +66 -20
- package/packages/agent/src/triggers/types.d.ts +14 -37
- package/packages/agent/src/triggers/types.d.ts.map +1 -1
- package/packages/agent/src/triggers/types.js +1 -1
- package/packages/agent/src/types/trajectory.d.ts +42 -1
- package/packages/agent/src/types/trajectory.d.ts.map +1 -1
- package/packages/agent/src/types/trajectory.js +2 -1
- package/packages/agent/src/utils/index.d.ts +1 -1
- package/packages/agent/src/utils/index.d.ts.map +1 -1
- package/packages/agent/src/utils/index.js +1 -1
- package/packages/app-core/src/api/client-types-cloud.d.ts +799 -0
- package/packages/app-core/src/api/client-types-cloud.d.ts.map +1 -0
- package/packages/app-core/src/api/client-types-cloud.js +57 -0
- package/packages/app-core/src/api/client-types-core.d.ts +334 -0
- package/packages/app-core/src/api/client-types-core.d.ts.map +1 -0
- package/packages/app-core/src/api/client-types-core.js +22 -0
- package/packages/app-core/src/api/compat-route-shared.d.ts +2 -2
- package/packages/app-core/src/api/compat-route-shared.d.ts.map +1 -1
- package/packages/app-core/src/api/server-cloud-tts.js +1 -1
- package/packages/app-core/src/bridge/native-plugins.d.ts +290 -0
- package/packages/app-core/src/bridge/native-plugins.d.ts.map +1 -0
- package/packages/app-core/src/bridge/native-plugins.js +55 -0
- package/packages/app-core/src/config/boot-config-store.d.ts +121 -2
- package/packages/app-core/src/config/boot-config-store.d.ts.map +1 -1
- package/packages/app-core/src/config/boot-config-store.js +16 -7
- package/packages/app-core/src/services/plugin-installer.d.ts +93 -0
- package/packages/app-core/src/services/plugin-installer.d.ts.map +1 -0
- package/packages/app-core/src/services/plugin-installer.js +611 -0
- package/packages/app-core/src/utils/env.d.ts.map +1 -1
- package/packages/app-core/src/utils/serialise.d.ts +12 -0
- package/packages/app-core/src/utils/serialise.d.ts.map +1 -0
- package/packages/app-core/src/utils/serialise.js +21 -0
- package/packages/native-plugins/activity-tracker/src/index.d.ts +35 -0
- package/packages/native-plugins/activity-tracker/src/index.d.ts.map +1 -0
- package/packages/native-plugins/activity-tracker/src/index.js +102 -0
- package/packages/shared/src/connectors.d.ts.map +1 -1
- package/packages/shared/src/connectors.js +8 -3
- package/packages/shared/src/contracts/apps.d.ts +53 -0
- package/packages/shared/src/contracts/apps.d.ts.map +1 -1
- package/packages/shared/src/contracts/cloud-topology.d.ts.map +1 -1
- package/packages/shared/src/contracts/cloud-topology.js +2 -4
- package/packages/shared/src/contracts/config.d.ts.map +1 -1
- package/packages/shared/src/contracts/index.d.ts +1 -1
- package/packages/shared/src/contracts/index.d.ts.map +1 -1
- package/packages/shared/src/contracts/index.js +1 -1
- package/packages/shared/src/contracts/lifeops-extensions.d.ts +181 -0
- package/packages/shared/src/contracts/lifeops-extensions.d.ts.map +1 -0
- package/packages/shared/src/contracts/lifeops-extensions.js +30 -0
- package/packages/shared/src/contracts/lifeops.d.ts +259 -0
- package/packages/shared/src/contracts/lifeops.d.ts.map +1 -1
- package/packages/shared/src/contracts/lifeops.js +62 -0
- package/packages/shared/src/contracts/onboarding.d.ts +5 -0
- package/packages/shared/src/contracts/onboarding.d.ts.map +1 -1
- package/packages/shared/src/contracts/onboarding.js +7 -6
- package/packages/shared/src/contracts/service-routing.d.ts.map +1 -1
- package/packages/shared/src/contracts/service-routing.js +1 -3
- package/packages/shared/src/contracts/wallet.d.ts +30 -103
- package/packages/shared/src/contracts/wallet.d.ts.map +1 -1
- package/packages/shared/src/env-utils.impl.d.ts.map +1 -1
- package/packages/shared/src/env-utils.impl.js +1 -8
- package/packages/shared/src/i18n/keyword-matching.d.ts.map +1 -1
- package/packages/shared/src/i18n/validation-keywords.d.ts +1 -1
- package/packages/shared/src/i18n/validation-keywords.d.ts.map +1 -1
- package/packages/shared/src/i18n/validation-keywords.js +1 -1
- package/packages/shared/src/index.d.ts +3 -3
- package/packages/shared/src/index.d.ts.map +1 -1
- package/packages/shared/src/index.js +3 -3
- package/packages/shared/src/onboarding-presets.characters.d.ts.map +1 -1
- package/packages/shared/src/onboarding-presets.characters.js +15 -5
- package/packages/shared/src/onboarding-presets.d.ts.map +1 -1
- package/packages/shared/src/onboarding-presets.js +5 -1
- package/packages/shared/src/runtime-env.d.ts.map +1 -1
- package/packages/shared/src/runtime-env.js +2 -7
- package/packages/shared/src/settings-debug.d.ts.map +1 -1
- package/packages/shared/src/settings-debug.js +1 -3
- package/packages/skills/src/formatter.d.ts +44 -0
- package/packages/skills/src/formatter.d.ts.map +1 -0
- package/packages/skills/src/formatter.js +181 -0
- package/packages/skills/src/frontmatter.d.ts +51 -0
- package/packages/skills/src/frontmatter.d.ts.map +1 -0
- package/packages/skills/src/frontmatter.js +155 -0
- package/packages/skills/src/index.d.ts +29 -0
- package/packages/skills/src/index.d.ts.map +1 -0
- package/packages/skills/src/index.js +31 -0
- package/packages/skills/src/loader.d.ts +33 -0
- package/packages/skills/src/loader.d.ts.map +1 -0
- package/packages/skills/src/loader.js +369 -0
- package/packages/skills/src/resolver.d.ts +35 -0
- package/packages/skills/src/resolver.d.ts.map +1 -0
- package/packages/skills/src/resolver.js +146 -0
- package/packages/skills/src/types.d.ts +238 -0
- package/packages/skills/src/types.d.ts.map +1 -0
- package/packages/skills/src/types.js +1 -0
- package/packages/typescript/src/action-docs.d.ts.map +1 -1
- package/packages/typescript/src/action-docs.js +2 -0
- package/packages/typescript/src/actions.d.ts.map +1 -1
- package/packages/typescript/src/actions.js +8 -3
- package/packages/typescript/src/database/inMemoryAdapter.js +1 -1
- package/packages/typescript/src/features/advanced-capabilities/evaluators/factRefinement.d.ts +20 -0
- package/packages/typescript/src/features/advanced-capabilities/evaluators/factRefinement.d.ts.map +1 -0
- package/packages/typescript/src/features/advanced-capabilities/evaluators/factRefinement.js +362 -0
- package/packages/typescript/src/features/advanced-capabilities/evaluators/index.d.ts +3 -0
- package/packages/typescript/src/features/advanced-capabilities/evaluators/index.d.ts.map +1 -1
- package/packages/typescript/src/features/advanced-capabilities/evaluators/index.js +3 -0
- package/packages/typescript/src/features/advanced-capabilities/evaluators/reflection.js +1 -1
- package/packages/typescript/src/features/advanced-capabilities/evaluators/relationshipExtraction.d.ts.map +1 -1
- package/packages/typescript/src/features/advanced-capabilities/evaluators/relationshipExtraction.js +21 -0
- package/packages/typescript/src/features/advanced-capabilities/evaluators/skillExtraction.d.ts +25 -0
- package/packages/typescript/src/features/advanced-capabilities/evaluators/skillExtraction.d.ts.map +1 -0
- package/packages/typescript/src/features/advanced-capabilities/evaluators/skillExtraction.js +367 -0
- package/packages/typescript/src/features/advanced-capabilities/evaluators/skillRefinement.d.ts +21 -0
- package/packages/typescript/src/features/advanced-capabilities/evaluators/skillRefinement.d.ts.map +1 -0
- package/packages/typescript/src/features/advanced-capabilities/evaluators/skillRefinement.js +545 -0
- package/packages/typescript/src/features/advanced-capabilities/form/service.d.ts +1 -5
- package/packages/typescript/src/features/advanced-capabilities/form/service.d.ts.map +1 -1
- package/packages/typescript/src/features/advanced-capabilities/form/service.js +1 -13
- package/packages/typescript/src/features/advanced-capabilities/form/types.d.ts +3 -2
- package/packages/typescript/src/features/advanced-capabilities/form/types.d.ts.map +1 -1
- package/packages/typescript/src/features/advanced-capabilities/providers/facts.d.ts.map +1 -1
- package/packages/typescript/src/features/advanced-capabilities/providers/facts.js +68 -14
- package/packages/typescript/src/features/advanced-memory/services/memory-service.d.ts +1 -0
- package/packages/typescript/src/features/advanced-memory/services/memory-service.d.ts.map +1 -1
- package/packages/typescript/src/features/advanced-memory/services/memory-service.js +31 -11
- package/packages/typescript/src/features/autonomy/execution-facade.d.ts +1 -1
- package/packages/typescript/src/features/autonomy/execution-facade.d.ts.map +1 -1
- package/packages/typescript/src/features/autonomy/execution-facade.js +3 -3
- package/packages/typescript/src/features/basic-capabilities/actions/none.js +1 -1
- package/packages/typescript/src/features/basic-capabilities/index.d.ts.map +1 -1
- package/packages/typescript/src/features/basic-capabilities/index.js +9 -3
- package/packages/typescript/src/features/plugin-manager/coreExtensions.d.ts +4 -11
- package/packages/typescript/src/features/plugin-manager/coreExtensions.d.ts.map +1 -1
- package/packages/typescript/src/features/plugin-manager/coreExtensions.js +0 -23
- package/packages/typescript/src/features/plugin-manager/index.d.ts +1 -1
- package/packages/typescript/src/features/plugin-manager/index.d.ts.map +1 -1
- package/packages/typescript/src/features/plugin-manager/index.js +1 -1
- package/packages/typescript/src/features/plugin-manager/providers/relevance.d.ts.map +1 -1
- package/packages/typescript/src/features/plugin-manager/providers/relevance.js +1 -3
- package/packages/typescript/src/features/trajectories/TrajectoriesService.d.ts +13 -0
- package/packages/typescript/src/features/trajectories/TrajectoriesService.d.ts.map +1 -1
- package/packages/typescript/src/features/trajectories/TrajectoriesService.js +12 -9
- package/packages/typescript/src/features/trajectories/integration.d.ts +1 -1
- package/packages/typescript/src/features/trajectories/integration.d.ts.map +1 -1
- package/packages/typescript/src/features/trajectories/types.d.ts +19 -1
- package/packages/typescript/src/features/trajectories/types.d.ts.map +1 -1
- package/packages/typescript/src/features/trust/index.d.ts +3 -52
- package/packages/typescript/src/features/trust/index.d.ts.map +1 -1
- package/packages/typescript/src/features/trust/index.js +5 -122
- package/packages/typescript/src/features/trust/services/wrappers.d.ts +56 -0
- package/packages/typescript/src/features/trust/services/wrappers.d.ts.map +1 -0
- package/packages/typescript/src/features/trust/services/wrappers.js +124 -0
- package/packages/typescript/src/generated/action-docs.d.ts +207 -3
- package/packages/typescript/src/generated/action-docs.d.ts.map +1 -1
- package/packages/typescript/src/generated/action-docs.js +271 -2
- package/packages/typescript/src/index.node.d.ts +3 -0
- package/packages/typescript/src/index.node.d.ts.map +1 -1
- package/packages/typescript/src/index.node.js +6 -0
- package/packages/typescript/src/optimization/ab-analysis.d.ts +1 -1
- package/packages/typescript/src/optimization/ab-analysis.d.ts.map +1 -1
- package/packages/typescript/src/optimization/ab-analysis.js +1 -1
- package/packages/typescript/src/optimization-root-dir.d.ts +6 -1
- package/packages/typescript/src/optimization-root-dir.d.ts.map +1 -1
- package/packages/typescript/src/optimization-root-dir.js +6 -1
- package/packages/typescript/src/prompts.d.ts +2 -2
- package/packages/typescript/src/prompts.d.ts.map +1 -1
- package/packages/typescript/src/prompts.js +4 -1
- package/packages/typescript/src/runtime.d.ts +3 -0
- package/packages/typescript/src/runtime.d.ts.map +1 -1
- package/packages/typescript/src/runtime.js +20 -5
- package/packages/typescript/src/schemas/character.d.ts +1 -1
- package/packages/typescript/src/schemas/character.d.ts.map +1 -1
- package/packages/typescript/src/schemas/character.js +1 -1
- package/packages/typescript/src/schemas/entity-identity.d.ts +29 -0
- package/packages/typescript/src/schemas/entity-identity.d.ts.map +1 -0
- package/packages/typescript/src/schemas/entity-identity.js +334 -0
- package/packages/typescript/src/schemas/index.d.ts +3 -1
- package/packages/typescript/src/schemas/index.d.ts.map +1 -1
- package/packages/typescript/src/schemas/index.js +2 -1
- package/packages/typescript/src/search.d.ts +0 -22
- package/packages/typescript/src/search.d.ts.map +1 -1
- package/packages/typescript/src/services/message.d.ts +11 -0
- package/packages/typescript/src/services/message.d.ts.map +1 -1
- package/packages/typescript/src/services/message.js +63 -36
- package/packages/typescript/src/services/optimized-prompt-resolver.d.ts +23 -0
- package/packages/typescript/src/services/optimized-prompt-resolver.d.ts.map +1 -0
- package/packages/typescript/src/services/optimized-prompt-resolver.js +50 -0
- package/packages/typescript/src/services/optimized-prompt.d.ts +117 -0
- package/packages/typescript/src/services/optimized-prompt.d.ts.map +1 -0
- package/packages/typescript/src/services/optimized-prompt.js +262 -0
- package/packages/typescript/src/services/relationships.d.ts +225 -0
- package/packages/typescript/src/services/relationships.d.ts.map +1 -1
- package/packages/typescript/src/services/relationships.js +979 -3
- package/packages/typescript/src/services/trajectories.d.ts +9 -0
- package/packages/typescript/src/services/trajectories.d.ts.map +1 -1
- package/packages/typescript/src/trajectory-context.d.ts +7 -0
- package/packages/typescript/src/trajectory-context.d.ts.map +1 -1
- package/packages/typescript/src/trajectory-utils.d.ts +24 -0
- package/packages/typescript/src/trajectory-utils.d.ts.map +1 -1
- package/packages/typescript/src/trajectory-utils.js +19 -0
- package/packages/typescript/src/types/components.d.ts +6 -0
- package/packages/typescript/src/types/components.d.ts.map +1 -1
- package/packages/typescript/src/types/plugin.d.ts +11 -0
- package/packages/typescript/src/types/plugin.d.ts.map +1 -1
- package/packages/typescript/src/types/runtime.d.ts +12 -0
- package/packages/typescript/src/types/runtime.d.ts.map +1 -1
- package/packages/typescript/src/types/service.d.ts +2 -0
- package/packages/typescript/src/types/service.d.ts.map +1 -1
- package/packages/typescript/src/types/service.js +1 -0
- package/packages/typescript/src/types/trigger.d.ts +4 -0
- package/packages/typescript/src/types/trigger.d.ts.map +1 -1
- package/packages/typescript/src/utils/batch-queue/batch-processor.d.ts +2 -3
- package/packages/typescript/src/utils/batch-queue/batch-processor.d.ts.map +1 -1
- package/packages/typescript/src/utils/batch-queue/batch-processor.js +0 -3
- package/packages/typescript/src/utils/crypto-compat.js +1 -1
- package/packages/typescript/src/utils/union-find.d.ts +30 -0
- package/packages/typescript/src/utils/union-find.d.ts.map +1 -0
- package/packages/typescript/src/utils/union-find.js +81 -0
- package/packages/typescript/src/utils.d.ts +1 -0
- package/packages/typescript/src/utils.d.ts.map +1 -1
- package/packages/typescript/src/utils.js +5 -1
- package/apps/app-lifeops/src/actions/inbox-digest.d.ts +0 -2
- package/apps/app-lifeops/src/actions/inbox-digest.d.ts.map +0 -1
- package/apps/app-lifeops/src/actions/inbox-digest.js +0 -1
- package/apps/app-lifeops/src/actions/inbox-respond.d.ts +0 -2
- package/apps/app-lifeops/src/actions/inbox-respond.d.ts.map +0 -1
- package/apps/app-lifeops/src/actions/inbox-respond.js +0 -1
- package/apps/app-lifeops/src/actions/inbox-triage.d.ts +0 -2
- package/apps/app-lifeops/src/actions/inbox-triage.d.ts.map +0 -1
- package/apps/app-lifeops/src/actions/inbox-triage.js +0 -1
- package/apps/app-lifeops/src/lifeops/index.d.ts +0 -25
- package/apps/app-lifeops/src/lifeops/index.d.ts.map +0 -1
- package/apps/app-lifeops/src/lifeops/index.js +0 -24
- package/apps/app-lifeops/src/selfcontrol/access.d.ts +0 -8
- package/apps/app-lifeops/src/selfcontrol/access.d.ts.map +0 -1
- package/apps/app-lifeops/src/selfcontrol/access.js +0 -16
- package/apps/app-lifeops/src/selfcontrol/action.d.ts +0 -10
- package/apps/app-lifeops/src/selfcontrol/action.d.ts.map +0 -1
- package/apps/app-lifeops/src/selfcontrol/action.js +0 -506
- package/apps/app-lifeops/src/selfcontrol/index.d.ts +0 -13
- package/apps/app-lifeops/src/selfcontrol/index.d.ts.map +0 -1
- package/apps/app-lifeops/src/selfcontrol/index.js +0 -10
- package/apps/app-lifeops/src/selfcontrol/permissions.d.ts.map +0 -1
- package/apps/app-lifeops/src/selfcontrol/provider.d.ts +0 -4
- package/apps/app-lifeops/src/selfcontrol/provider.d.ts.map +0 -1
- package/apps/app-lifeops/src/selfcontrol/provider.js +0 -116
- package/apps/app-lifeops/src/selfcontrol/roles.d.ts +0 -19
- package/apps/app-lifeops/src/selfcontrol/roles.d.ts.map +0 -1
- package/apps/app-lifeops/src/selfcontrol/roles.js +0 -41
- package/apps/app-lifeops/src/selfcontrol/selfcontrol.d.ts +0 -97
- package/apps/app-lifeops/src/selfcontrol/selfcontrol.d.ts.map +0 -1
- package/apps/app-lifeops/src/selfcontrol/selfcontrol.js +0 -949
- package/apps/app-lifeops/src/selfcontrol/service.d.ts +0 -21
- package/apps/app-lifeops/src/selfcontrol/service.d.ts.map +0 -1
- package/apps/app-lifeops/src/selfcontrol/service.js +0 -268
- package/packages/agent/src/actions/calendar.d.ts +0 -2
- package/packages/agent/src/actions/calendar.d.ts.map +0 -1
- package/packages/agent/src/actions/calendar.js +0 -1
- package/packages/agent/src/actions/check-balance.d.ts +0 -17
- package/packages/agent/src/actions/check-balance.d.ts.map +0 -1
- package/packages/agent/src/actions/check-balance.js +0 -167
- package/packages/agent/src/actions/execute-trade.d.ts +0 -17
- package/packages/agent/src/actions/execute-trade.d.ts.map +0 -1
- package/packages/agent/src/actions/execute-trade.js +0 -299
- package/packages/agent/src/actions/gmail.d.ts +0 -2
- package/packages/agent/src/actions/gmail.d.ts.map +0 -1
- package/packages/agent/src/actions/gmail.js +0 -1
- package/packages/agent/src/actions/inbox-digest.d.ts +0 -2
- package/packages/agent/src/actions/inbox-digest.d.ts.map +0 -1
- package/packages/agent/src/actions/inbox-digest.js +0 -1
- package/packages/agent/src/actions/inbox-respond.d.ts +0 -2
- package/packages/agent/src/actions/inbox-respond.d.ts.map +0 -1
- package/packages/agent/src/actions/inbox-respond.js +0 -1
- package/packages/agent/src/actions/inbox-triage.d.ts +0 -2
- package/packages/agent/src/actions/inbox-triage.d.ts.map +0 -1
- package/packages/agent/src/actions/inbox-triage.js +0 -1
- package/packages/agent/src/actions/inbox.d.ts +0 -2
- package/packages/agent/src/actions/inbox.d.ts.map +0 -1
- package/packages/agent/src/actions/inbox.js +0 -1
- package/packages/agent/src/actions/life-goal-extractor.d.ts +0 -2
- package/packages/agent/src/actions/life-goal-extractor.d.ts.map +0 -1
- package/packages/agent/src/actions/life-goal-extractor.js +0 -1
- package/packages/agent/src/actions/life-param-extractor.d.ts +0 -2
- package/packages/agent/src/actions/life-param-extractor.d.ts.map +0 -1
- package/packages/agent/src/actions/life-param-extractor.js +0 -1
- package/packages/agent/src/actions/life-recent-context.d.ts +0 -2
- package/packages/agent/src/actions/life-recent-context.d.ts.map +0 -1
- package/packages/agent/src/actions/life-recent-context.js +0 -1
- package/packages/agent/src/actions/life-update-extractor.d.ts +0 -2
- package/packages/agent/src/actions/life-update-extractor.d.ts.map +0 -1
- package/packages/agent/src/actions/life-update-extractor.js +0 -1
- package/packages/agent/src/actions/life.d.ts +0 -2
- package/packages/agent/src/actions/life.d.ts.map +0 -1
- package/packages/agent/src/actions/life.extractor.d.ts +0 -2
- package/packages/agent/src/actions/life.extractor.d.ts.map +0 -1
- package/packages/agent/src/actions/life.extractor.js +0 -1
- package/packages/agent/src/actions/life.js +0 -1
- package/packages/agent/src/actions/lifeops-extraction-config.d.ts +0 -2
- package/packages/agent/src/actions/lifeops-extraction-config.d.ts.map +0 -1
- package/packages/agent/src/actions/lifeops-extraction-config.js +0 -1
- package/packages/agent/src/actions/lifeops-google-helpers.d.ts +0 -2
- package/packages/agent/src/actions/lifeops-google-helpers.d.ts.map +0 -1
- package/packages/agent/src/actions/lifeops-google-helpers.js +0 -1
- package/packages/agent/src/actions/timezone-normalization.d.ts +0 -2
- package/packages/agent/src/actions/timezone-normalization.d.ts.map +0 -1
- package/packages/agent/src/actions/timezone-normalization.js +0 -1
- package/packages/agent/src/actions/transfer-token.d.ts +0 -17
- package/packages/agent/src/actions/transfer-token.d.ts.map +0 -1
- package/packages/agent/src/actions/transfer-token.js +0 -470
- package/packages/agent/src/actions/update-owner-profile.d.ts +0 -2
- package/packages/agent/src/actions/update-owner-profile.d.ts.map +0 -1
- package/packages/agent/src/actions/update-owner-profile.js +0 -1
- package/packages/agent/src/actions/wallet-action-shared.d.ts +0 -15
- package/packages/agent/src/actions/wallet-action-shared.d.ts.map +0 -1
- package/packages/agent/src/actions/wallet-action-shared.js +0 -24
- package/packages/agent/src/activity-profile/analyzer.d.ts.map +0 -1
- package/packages/agent/src/activity-profile/analyzer.js +0 -531
- package/packages/agent/src/activity-profile/proactive-planner.d.ts.map +0 -1
- package/packages/agent/src/activity-profile/proactive-planner.js +0 -455
- package/packages/agent/src/activity-profile/proactive-worker.d.ts.map +0 -1
- package/packages/agent/src/activity-profile/proactive-worker.js +0 -523
- package/packages/agent/src/activity-profile/profile-metadata.d.ts.map +0 -1
- package/packages/agent/src/activity-profile/service.d.ts +0 -11
- package/packages/agent/src/activity-profile/service.d.ts.map +0 -1
- package/packages/agent/src/activity-profile/service.js +0 -226
- package/packages/agent/src/activity-profile/types.d.ts.map +0 -1
- package/packages/agent/src/api/coding-agents-auth-sanitize.d.ts +0 -2
- package/packages/agent/src/api/coding-agents-auth-sanitize.d.ts.map +0 -1
- package/packages/agent/src/api/coding-agents-auth-sanitize.js +0 -1
- package/packages/agent/src/api/coding-agents-preflight-normalize.d.ts +0 -2
- package/packages/agent/src/api/coding-agents-preflight-normalize.d.ts.map +0 -1
- package/packages/agent/src/api/coding-agents-preflight-normalize.js +0 -1
- package/packages/agent/src/api/coordinator-types.d.ts +0 -2
- package/packages/agent/src/api/coordinator-types.d.ts.map +0 -1
- package/packages/agent/src/api/coordinator-types.js +0 -1
- package/packages/agent/src/api/coordinator-wiring.d.ts +0 -2
- package/packages/agent/src/api/coordinator-wiring.d.ts.map +0 -1
- package/packages/agent/src/api/coordinator-wiring.js +0 -1
- package/packages/agent/src/api/drop-routes.d.ts +0 -22
- package/packages/agent/src/api/drop-routes.d.ts.map +0 -1
- package/packages/agent/src/api/drop-service.d.ts +0 -26
- package/packages/agent/src/api/drop-service.d.ts.map +0 -1
- package/packages/agent/src/api/lifeops-routes.d.ts +0 -2
- package/packages/agent/src/api/lifeops-routes.d.ts.map +0 -1
- package/packages/agent/src/api/lifeops-routes.js +0 -1
- package/packages/agent/src/api/merkle-tree.d.ts.map +0 -1
- package/packages/agent/src/api/nft-verify.d.ts +0 -16
- package/packages/agent/src/api/nft-verify.d.ts.map +0 -1
- package/packages/agent/src/api/nft-verify.js +0 -81
- package/packages/agent/src/api/og-tracker.d.ts.map +0 -1
- package/packages/agent/src/api/og-tracker.js +0 -60
- package/packages/agent/src/api/task-agent-message-routing.d.ts +0 -2
- package/packages/agent/src/api/task-agent-message-routing.d.ts.map +0 -1
- package/packages/agent/src/api/task-agent-message-routing.js +0 -1
- package/packages/agent/src/api/twitter-verify.d.ts +0 -25
- package/packages/agent/src/api/twitter-verify.d.ts.map +0 -1
- package/packages/agent/src/api/twitter-verify.js +0 -168
- package/packages/agent/src/api/website-blocker-routes.d.ts +0 -2
- package/packages/agent/src/api/website-blocker-routes.d.ts.map +0 -1
- package/packages/agent/src/api/website-blocker-routes.js +0 -1
- package/packages/agent/src/config/runtime-env.d.ts +0 -2
- package/packages/agent/src/config/runtime-env.d.ts.map +0 -1
- package/packages/agent/src/config/runtime-env.js +0 -1
- package/packages/agent/src/evals/coordinator-eval-client.d.ts +0 -2
- package/packages/agent/src/evals/coordinator-eval-client.d.ts.map +0 -1
- package/packages/agent/src/evals/coordinator-eval-client.js +0 -1
- package/packages/agent/src/evals/coordinator-live-runner.d.ts +0 -2
- package/packages/agent/src/evals/coordinator-live-runner.d.ts.map +0 -1
- package/packages/agent/src/evals/coordinator-live-runner.js +0 -1
- package/packages/agent/src/evals/coordinator-preflight.d.ts +0 -2
- package/packages/agent/src/evals/coordinator-preflight.d.ts.map +0 -1
- package/packages/agent/src/evals/coordinator-preflight.js +0 -1
- package/packages/agent/src/evals/coordinator-scenarios.d.ts +0 -2
- package/packages/agent/src/evals/coordinator-scenarios.d.ts.map +0 -1
- package/packages/agent/src/evals/coordinator-scenarios.js +0 -1
- package/packages/agent/src/lifeops/app-state.d.ts +0 -2
- package/packages/agent/src/lifeops/app-state.d.ts.map +0 -1
- package/packages/agent/src/lifeops/app-state.js +0 -1
- package/packages/agent/src/lifeops/apple-reminders.d.ts +0 -2
- package/packages/agent/src/lifeops/apple-reminders.d.ts.map +0 -1
- package/packages/agent/src/lifeops/apple-reminders.js +0 -1
- package/packages/agent/src/lifeops/defaults.d.ts +0 -2
- package/packages/agent/src/lifeops/defaults.d.ts.map +0 -1
- package/packages/agent/src/lifeops/defaults.js +0 -1
- package/packages/agent/src/lifeops/engine.d.ts +0 -2
- package/packages/agent/src/lifeops/engine.d.ts.map +0 -1
- package/packages/agent/src/lifeops/engine.js +0 -1
- package/packages/agent/src/lifeops/goal-grounding.d.ts +0 -2
- package/packages/agent/src/lifeops/goal-grounding.d.ts.map +0 -1
- package/packages/agent/src/lifeops/goal-grounding.js +0 -1
- package/packages/agent/src/lifeops/goal-semantic-evaluator.d.ts +0 -2
- package/packages/agent/src/lifeops/goal-semantic-evaluator.d.ts.map +0 -1
- package/packages/agent/src/lifeops/goal-semantic-evaluator.js +0 -1
- package/packages/agent/src/lifeops/google-api-error.d.ts +0 -2
- package/packages/agent/src/lifeops/google-api-error.d.ts.map +0 -1
- package/packages/agent/src/lifeops/google-api-error.js +0 -1
- package/packages/agent/src/lifeops/google-calendar.d.ts +0 -2
- package/packages/agent/src/lifeops/google-calendar.d.ts.map +0 -1
- package/packages/agent/src/lifeops/google-calendar.js +0 -1
- package/packages/agent/src/lifeops/google-connector-gateway.d.ts +0 -2
- package/packages/agent/src/lifeops/google-connector-gateway.d.ts.map +0 -1
- package/packages/agent/src/lifeops/google-connector-gateway.js +0 -1
- package/packages/agent/src/lifeops/google-fetch.d.ts +0 -2
- package/packages/agent/src/lifeops/google-fetch.d.ts.map +0 -1
- package/packages/agent/src/lifeops/google-fetch.js +0 -1
- package/packages/agent/src/lifeops/google-gmail.d.ts +0 -2
- package/packages/agent/src/lifeops/google-gmail.d.ts.map +0 -1
- package/packages/agent/src/lifeops/google-gmail.js +0 -1
- package/packages/agent/src/lifeops/google-managed-client.d.ts +0 -2
- package/packages/agent/src/lifeops/google-managed-client.d.ts.map +0 -1
- package/packages/agent/src/lifeops/google-managed-client.js +0 -1
- package/packages/agent/src/lifeops/google-oauth.d.ts +0 -2
- package/packages/agent/src/lifeops/google-oauth.d.ts.map +0 -1
- package/packages/agent/src/lifeops/google-oauth.js +0 -1
- package/packages/agent/src/lifeops/google-scopes.d.ts +0 -2
- package/packages/agent/src/lifeops/google-scopes.d.ts.map +0 -1
- package/packages/agent/src/lifeops/google-scopes.js +0 -1
- package/packages/agent/src/lifeops/index.d.ts +0 -2
- package/packages/agent/src/lifeops/index.d.ts.map +0 -1
- package/packages/agent/src/lifeops/index.js +0 -1
- package/packages/agent/src/lifeops/owner-profile.d.ts +0 -2
- package/packages/agent/src/lifeops/owner-profile.d.ts.map +0 -1
- package/packages/agent/src/lifeops/owner-profile.js +0 -1
- package/packages/agent/src/lifeops/repository.d.ts +0 -2
- package/packages/agent/src/lifeops/repository.d.ts.map +0 -1
- package/packages/agent/src/lifeops/repository.js +0 -1
- package/packages/agent/src/lifeops/runtime.d.ts +0 -2
- package/packages/agent/src/lifeops/runtime.d.ts.map +0 -1
- package/packages/agent/src/lifeops/runtime.js +0 -1
- package/packages/agent/src/lifeops/screen-context.d.ts +0 -2
- package/packages/agent/src/lifeops/screen-context.d.ts.map +0 -1
- package/packages/agent/src/lifeops/screen-context.js +0 -1
- package/packages/agent/src/lifeops/seed-routines.d.ts +0 -2
- package/packages/agent/src/lifeops/seed-routines.d.ts.map +0 -1
- package/packages/agent/src/lifeops/seed-routines.js +0 -1
- package/packages/agent/src/lifeops/service.d.ts +0 -2
- package/packages/agent/src/lifeops/service.d.ts.map +0 -1
- package/packages/agent/src/lifeops/service.js +0 -1
- package/packages/agent/src/lifeops/sql.d.ts +0 -2
- package/packages/agent/src/lifeops/sql.d.ts.map +0 -1
- package/packages/agent/src/lifeops/sql.js +0 -1
- package/packages/agent/src/lifeops/time.d.ts +0 -2
- package/packages/agent/src/lifeops/time.d.ts.map +0 -1
- package/packages/agent/src/lifeops/time.js +0 -1
- package/packages/agent/src/lifeops/twilio.d.ts +0 -2
- package/packages/agent/src/lifeops/twilio.d.ts.map +0 -1
- package/packages/agent/src/lifeops/twilio.js +0 -1
- package/packages/agent/src/lifeops/x-poster.d.ts +0 -2
- package/packages/agent/src/lifeops/x-poster.d.ts.map +0 -1
- package/packages/agent/src/lifeops/x-poster.js +0 -1
- package/packages/agent/src/providers/activity-profile.d.ts.map +0 -1
- package/packages/agent/src/providers/activity-profile.js +0 -140
- package/packages/agent/src/providers/inbox-triage.d.ts +0 -2
- package/packages/agent/src/providers/inbox-triage.d.ts.map +0 -1
- package/packages/agent/src/providers/inbox-triage.js +0 -1
- package/packages/agent/src/providers/lifeops.d.ts +0 -2
- package/packages/agent/src/providers/lifeops.d.ts.map +0 -1
- package/packages/agent/src/providers/lifeops.js +0 -1
- package/packages/agent/src/utils/spoken-text.d.ts +0 -2
- package/packages/agent/src/utils/spoken-text.d.ts.map +0 -1
- package/packages/agent/src/utils/spoken-text.js +0 -1
- package/packages/app-core/src/config/config.d.ts +0 -12
- package/packages/app-core/src/config/config.d.ts.map +0 -1
- package/packages/app-core/src/config/config.js +0 -23
- package/packages/app-core/src/types/index.d.ts +0 -649
- package/packages/app-core/src/types/index.d.ts.map +0 -1
- package/packages/app-core/src/types/lifeops-ui.d.ts +0 -10
- package/packages/app-core/src/types/lifeops-ui.d.ts.map +0 -1
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/append.d.ts +0 -4
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/append.d.ts.map +0 -1
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/append.js +0 -150
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/delete.d.ts +0 -4
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/delete.d.ts.map +0 -1
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/delete.js +0 -136
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/list.d.ts +0 -4
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/list.d.ts.map +0 -1
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/list.js +0 -84
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/read-attachment.d.ts +0 -4
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/read-attachment.d.ts.map +0 -1
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/read-attachment.js +0 -107
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/read-file.d.ts +0 -16
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/read-file.d.ts.map +0 -1
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/read-file.js +0 -187
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/read.d.ts +0 -4
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/read.d.ts.map +0 -1
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/read.js +0 -138
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/remove-from-clipboard.d.ts +0 -4
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/remove-from-clipboard.d.ts.map +0 -1
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/remove-from-clipboard.js +0 -96
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/search.d.ts +0 -4
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/search.d.ts.map +0 -1
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/search.js +0 -139
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/write.d.ts +0 -4
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/write.d.ts.map +0 -1
- package/packages/typescript/src/advanced-capabilities/clipboard/actions/write.js +0 -138
- package/packages/typescript/src/advanced-capabilities/clipboard/index.d.ts +0 -39
- package/packages/typescript/src/advanced-capabilities/clipboard/index.d.ts.map +0 -1
- package/packages/typescript/src/advanced-capabilities/clipboard/index.js +0 -78
- package/packages/typescript/src/advanced-capabilities/clipboard/providers/clipboard.d.ts +0 -4
- package/packages/typescript/src/advanced-capabilities/clipboard/providers/clipboard.d.ts.map +0 -1
- package/packages/typescript/src/advanced-capabilities/clipboard/providers/clipboard.js +0 -62
- package/packages/typescript/src/advanced-capabilities/clipboard/services/attachmentContext.d.ts +0 -16
- package/packages/typescript/src/advanced-capabilities/clipboard/services/attachmentContext.d.ts.map +0 -1
- package/packages/typescript/src/advanced-capabilities/clipboard/services/attachmentContext.js +0 -162
- package/packages/typescript/src/advanced-capabilities/clipboard/services/clipboardService.d.ts +0 -65
- package/packages/typescript/src/advanced-capabilities/clipboard/services/clipboardService.d.ts.map +0 -1
- package/packages/typescript/src/advanced-capabilities/clipboard/services/clipboardService.js +0 -352
- package/packages/typescript/src/advanced-capabilities/clipboard/services/taskClipboardPersistence.d.ts +0 -24
- package/packages/typescript/src/advanced-capabilities/clipboard/services/taskClipboardPersistence.d.ts.map +0 -1
- package/packages/typescript/src/advanced-capabilities/clipboard/services/taskClipboardPersistence.js +0 -63
- package/packages/typescript/src/advanced-capabilities/clipboard/services/taskClipboardService.d.ts +0 -29
- package/packages/typescript/src/advanced-capabilities/clipboard/services/taskClipboardService.d.ts.map +0 -1
- package/packages/typescript/src/advanced-capabilities/clipboard/services/taskClipboardService.js +0 -195
- package/packages/typescript/src/advanced-capabilities/clipboard/specs.d.ts +0 -15
- package/packages/typescript/src/advanced-capabilities/clipboard/specs.d.ts.map +0 -1
- package/packages/typescript/src/advanced-capabilities/clipboard/specs.js +0 -164
- package/packages/typescript/src/advanced-capabilities/clipboard/types.d.ts +0 -92
- package/packages/typescript/src/advanced-capabilities/clipboard/types.d.ts.map +0 -1
- package/packages/typescript/src/advanced-capabilities/clipboard/types.js +0 -4
- package/packages/typescript/src/index.d.ts +0 -12
- package/packages/typescript/src/index.d.ts.map +0 -1
- package/packages/typescript/src/index.js +0 -13
- /package/{packages/agent/src/api → apps/app-elizamaker/src}/drop-routes.js +0 -0
- /package/{packages/agent/src/api → apps/app-elizamaker/src}/drop-service.js +0 -0
- /package/{packages/agent/src/api → apps/app-elizamaker/src}/merkle-tree.d.ts +0 -0
- /package/{packages/agent/src/api → apps/app-elizamaker/src}/merkle-tree.js +0 -0
- /package/{packages/agent/src/api → apps/app-elizamaker/src}/og-tracker.d.ts +0 -0
- /package/{packages/agent → apps/app-lifeops}/src/activity-profile/analyzer.d.ts +0 -0
- /package/{packages/agent → apps/app-lifeops}/src/activity-profile/proactive-planner.d.ts +0 -0
- /package/{packages/agent → apps/app-lifeops}/src/activity-profile/proactive-worker.d.ts +0 -0
- /package/{packages/agent → apps/app-lifeops}/src/activity-profile/profile-metadata.d.ts +0 -0
- /package/{packages/agent → apps/app-lifeops}/src/activity-profile/profile-metadata.js +0 -0
- /package/{packages/agent → apps/app-lifeops}/src/activity-profile/types.d.ts +0 -0
- /package/{packages/agent → apps/app-lifeops}/src/activity-profile/types.js +0 -0
- /package/{packages/agent → apps/app-lifeops}/src/providers/activity-profile.d.ts +0 -0
- /package/apps/app-lifeops/src/{selfcontrol/permissions.js → types/app-blocker-settings-card.js} +0 -0
- /package/{packages/app-core → apps/app-lifeops}/src/types/index.js +0 -0
- /package/{packages/app-core/src/types/lifeops-ui.js → apps/app-lifeops/src/types/website-blocker-settings-card.js} +0 -0
- /package/apps/app-lifeops/src/{selfcontrol → website-blocker}/permissions.d.ts +0 -0
|
@@ -1,4034 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const fromSource = walk(path.dirname(fileURLToPath(import.meta.url)), 24);
|
|
43
|
-
if (fromSource) {
|
|
44
|
-
return fromSource;
|
|
45
|
-
}
|
|
46
|
-
const fromCwd = walk(process.cwd(), 16);
|
|
47
|
-
if (fromCwd) {
|
|
48
|
-
return fromCwd;
|
|
49
|
-
}
|
|
50
|
-
throw new Error("Could not find jsdom on disk (install dependencies: jsdom is listed on @elizaos/agent and apps/app).");
|
|
51
|
-
}
|
|
52
|
-
/** Lazy-load jsdom so importing this module does not require jsdom at parse time (Vitest / server tests). */
|
|
53
|
-
function getJSDOMClass() {
|
|
54
|
-
if (!jsdomCtor) {
|
|
55
|
-
const jsdomPkg = findJsdomPackageJsonPath();
|
|
56
|
-
const jsdomDir = path.dirname(jsdomPkg);
|
|
57
|
-
const meta = JSON.parse(readFileSync(jsdomPkg, "utf8"));
|
|
58
|
-
const mainRel = (meta.main ?? "./lib/api.js").replace(/^\.\//, "");
|
|
59
|
-
const entry = path.join(jsdomDir, mainRel);
|
|
60
|
-
const req = createRequire(jsdomPkg);
|
|
61
|
-
const mod = req(entry);
|
|
62
|
-
jsdomCtor = mod.JSDOM;
|
|
63
|
-
}
|
|
64
|
-
return jsdomCtor;
|
|
65
|
-
}
|
|
66
|
-
const DEFAULT_TIMEOUT_MS = 12_000;
|
|
67
|
-
const DEFAULT_WAIT_INTERVAL_MS = 120;
|
|
68
|
-
const DEFAULT_WEB_PARTITION = "persist:eliza-browser";
|
|
69
|
-
const DESKTOP_BRIDGE_UNAVAILABLE_MESSAGE = "Eliza browser workspace desktop bridge is unavailable.";
|
|
70
|
-
const browserWorkspacePageFetch = globalThis.fetch.bind(globalThis);
|
|
71
|
-
/**
|
|
72
|
-
* Simple async mutex to serialise mutations to webWorkspaceState.
|
|
73
|
-
* Prevents concurrent requests from corrupting tab state or history.
|
|
74
|
-
*/
|
|
75
|
-
let webStateLock = Promise.resolve();
|
|
76
|
-
function withWebStateLock(fn) {
|
|
77
|
-
const next = webStateLock.then(fn, fn);
|
|
78
|
-
webStateLock = next.then(() => { }, () => { });
|
|
79
|
-
return next;
|
|
80
|
-
}
|
|
81
|
-
const webWorkspaceState = {
|
|
82
|
-
nextId: 1,
|
|
83
|
-
tabs: [],
|
|
84
|
-
};
|
|
85
|
-
const browserWorkspaceElementRefs = new Map();
|
|
86
|
-
const browserWorkspaceRuntimeState = new Map();
|
|
87
|
-
let browserWorkspaceClipboardText = "";
|
|
88
|
-
/** @internal - test-only reset */
|
|
89
|
-
export async function __resetBrowserWorkspaceStateForTests() {
|
|
90
|
-
await withWebStateLock(async () => {
|
|
91
|
-
webWorkspaceState.nextId = 1;
|
|
92
|
-
webWorkspaceState.tabs = [];
|
|
93
|
-
browserWorkspaceElementRefs.clear();
|
|
94
|
-
browserWorkspaceRuntimeState.clear();
|
|
95
|
-
browserWorkspaceClipboardText = "";
|
|
96
|
-
});
|
|
97
|
-
webStateLock = Promise.resolve();
|
|
98
|
-
}
|
|
99
|
-
function normalizeEnvValue(value) {
|
|
100
|
-
if (typeof value !== "string") {
|
|
101
|
-
return null;
|
|
102
|
-
}
|
|
103
|
-
const trimmed = value.trim();
|
|
104
|
-
return trimmed.length > 0 ? trimmed : null;
|
|
105
|
-
}
|
|
106
|
-
function normalizeBrowserWorkspaceText(value) {
|
|
107
|
-
return String(value ?? "")
|
|
108
|
-
.replace(/\s+/g, " ")
|
|
109
|
-
.trim();
|
|
110
|
-
}
|
|
111
|
-
function parseBrowserWorkspaceNumberLike(value) {
|
|
112
|
-
if (typeof value === "number" && Number.isFinite(value)) {
|
|
113
|
-
return value;
|
|
114
|
-
}
|
|
115
|
-
if (typeof value !== "string") {
|
|
116
|
-
return undefined;
|
|
117
|
-
}
|
|
118
|
-
const parsed = Number.parseFloat(value.trim());
|
|
119
|
-
return Number.isFinite(parsed) ? parsed : undefined;
|
|
120
|
-
}
|
|
121
|
-
function getBrowserWorkspaceTimestamp() {
|
|
122
|
-
return new Date().toISOString();
|
|
123
|
-
}
|
|
124
|
-
function getBrowserWorkspaceElementRefStateKey(mode, tabId) {
|
|
125
|
-
return `${mode}:${tabId}`;
|
|
126
|
-
}
|
|
127
|
-
function createBrowserWorkspaceRuntimeState() {
|
|
128
|
-
return {
|
|
129
|
-
consoleEntries: [],
|
|
130
|
-
currentFrame: null,
|
|
131
|
-
dialog: null,
|
|
132
|
-
errors: [],
|
|
133
|
-
frameDoms: new Map(),
|
|
134
|
-
highlightedSelector: null,
|
|
135
|
-
lastScreenshotData: null,
|
|
136
|
-
lastSnapshot: null,
|
|
137
|
-
mouse: { buttons: [], x: 0, y: 0 },
|
|
138
|
-
networkHar: { active: false, entries: [], startedAt: null },
|
|
139
|
-
networkNextRequestId: 1,
|
|
140
|
-
networkRequests: [],
|
|
141
|
-
networkRoutes: [],
|
|
142
|
-
settings: {
|
|
143
|
-
credentials: null,
|
|
144
|
-
device: null,
|
|
145
|
-
geo: null,
|
|
146
|
-
headers: {},
|
|
147
|
-
media: null,
|
|
148
|
-
offline: false,
|
|
149
|
-
viewport: null,
|
|
150
|
-
},
|
|
151
|
-
trace: { active: false, entries: [] },
|
|
152
|
-
profiler: { active: false, entries: [] },
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
function getBrowserWorkspaceRuntimeStateKey(mode, tabId) {
|
|
156
|
-
return `${mode}:${tabId}`;
|
|
157
|
-
}
|
|
158
|
-
function getBrowserWorkspaceRuntimeState(mode, tabId) {
|
|
159
|
-
const key = getBrowserWorkspaceRuntimeStateKey(mode, tabId);
|
|
160
|
-
let state = browserWorkspaceRuntimeState.get(key);
|
|
161
|
-
if (!state) {
|
|
162
|
-
state = createBrowserWorkspaceRuntimeState();
|
|
163
|
-
browserWorkspaceRuntimeState.set(key, state);
|
|
164
|
-
}
|
|
165
|
-
return state;
|
|
166
|
-
}
|
|
167
|
-
function clearBrowserWorkspaceRuntimeState(mode, tabId) {
|
|
168
|
-
browserWorkspaceRuntimeState.delete(getBrowserWorkspaceRuntimeStateKey(mode, tabId));
|
|
169
|
-
}
|
|
170
|
-
function resetBrowserWorkspaceRuntimeNavigationState(state) {
|
|
171
|
-
state.currentFrame = null;
|
|
172
|
-
state.dialog = null;
|
|
173
|
-
state.frameDoms.clear();
|
|
174
|
-
state.highlightedSelector = null;
|
|
175
|
-
}
|
|
176
|
-
function appendBrowserWorkspaceTraceEntry(state, entry) {
|
|
177
|
-
if (!state.trace.active) {
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
180
|
-
state.trace.entries.push({
|
|
181
|
-
...entry,
|
|
182
|
-
timestamp: getBrowserWorkspaceTimestamp(),
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
function appendBrowserWorkspaceProfilerEntry(state, entry) {
|
|
186
|
-
if (!state.profiler.active) {
|
|
187
|
-
return;
|
|
188
|
-
}
|
|
189
|
-
state.profiler.entries.push({
|
|
190
|
-
...entry,
|
|
191
|
-
timestamp: getBrowserWorkspaceTimestamp(),
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
function clearBrowserWorkspaceElementRefs(mode, tabId) {
|
|
195
|
-
browserWorkspaceElementRefs.delete(getBrowserWorkspaceElementRefStateKey(mode, tabId));
|
|
196
|
-
}
|
|
197
|
-
function registerBrowserWorkspaceElementRefs(mode, tabId, elements) {
|
|
198
|
-
if (elements.length === 0) {
|
|
199
|
-
clearBrowserWorkspaceElementRefs(mode, tabId);
|
|
200
|
-
return [];
|
|
201
|
-
}
|
|
202
|
-
const refs = new Map();
|
|
203
|
-
const augmented = elements.map((element, index) => {
|
|
204
|
-
const ref = `@e${index + 1}`;
|
|
205
|
-
refs.set(ref, element.selector);
|
|
206
|
-
return { ...element, ref };
|
|
207
|
-
});
|
|
208
|
-
browserWorkspaceElementRefs.set(getBrowserWorkspaceElementRefStateKey(mode, tabId), refs);
|
|
209
|
-
return augmented;
|
|
210
|
-
}
|
|
211
|
-
function resolveBrowserWorkspaceElementRef(mode, tabId, ref) {
|
|
212
|
-
return (browserWorkspaceElementRefs
|
|
213
|
-
.get(getBrowserWorkspaceElementRefStateKey(mode, tabId))
|
|
214
|
-
?.get(ref.trim()) ?? null);
|
|
215
|
-
}
|
|
216
|
-
function resolveBrowserWorkspaceCommandElementRefs(command, mode, tabId) {
|
|
217
|
-
const selector = command.selector?.trim();
|
|
218
|
-
if (!selector) {
|
|
219
|
-
return command;
|
|
220
|
-
}
|
|
221
|
-
const match = selector.match(/^(@e\d+)([\s\S]*)$/i);
|
|
222
|
-
if (!match?.[1]) {
|
|
223
|
-
return command;
|
|
224
|
-
}
|
|
225
|
-
const resolvedSelector = resolveBrowserWorkspaceElementRef(mode, tabId, match[1]);
|
|
226
|
-
if (!resolvedSelector) {
|
|
227
|
-
throw new Error(`Unknown browser snapshot element ref ${match[1]}. Run snapshot or inspect again before reusing element refs.`);
|
|
228
|
-
}
|
|
229
|
-
return {
|
|
230
|
-
...command,
|
|
231
|
-
selector: `${resolvedSelector}${match[2] ?? ""}`,
|
|
232
|
-
};
|
|
233
|
-
}
|
|
234
|
-
function assertBrowserWorkspaceUrl(rawUrl) {
|
|
235
|
-
const trimmed = rawUrl.trim();
|
|
236
|
-
if (trimmed === "about:blank") {
|
|
237
|
-
return trimmed;
|
|
238
|
-
}
|
|
239
|
-
let parsed;
|
|
240
|
-
try {
|
|
241
|
-
parsed = new URL(trimmed);
|
|
242
|
-
}
|
|
243
|
-
catch {
|
|
244
|
-
throw new Error(`browser workspace rejected invalid URL: ${rawUrl}`);
|
|
245
|
-
}
|
|
246
|
-
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
247
|
-
throw new Error(`browser workspace only supports http/https URLs, got ${parsed.protocol}`);
|
|
248
|
-
}
|
|
249
|
-
return parsed.toString();
|
|
250
|
-
}
|
|
251
|
-
function createBrowserWorkspaceDesktopOnlyMessage(subaction) {
|
|
252
|
-
return `Eliza browser workspace ${subaction} is only available in the desktop app.`;
|
|
253
|
-
}
|
|
254
|
-
function createBrowserWorkspaceNotFoundError(tabId) {
|
|
255
|
-
return new Error(`Browser workspace request failed (404): Tab ${tabId} was not found.`);
|
|
256
|
-
}
|
|
257
|
-
function createBrowserWorkspaceCommandTargetError(subaction) {
|
|
258
|
-
return new Error(`Eliza browser workspace ${subaction} requires a current tab. Open or show a tab first, or pass an explicit id.`);
|
|
259
|
-
}
|
|
260
|
-
function inferBrowserWorkspaceTitle(url) {
|
|
261
|
-
if (url === "about:blank") {
|
|
262
|
-
return "New Tab";
|
|
263
|
-
}
|
|
264
|
-
try {
|
|
265
|
-
return new URL(url).hostname.replace(/^www\./, "") || "Eliza Browser";
|
|
266
|
-
}
|
|
267
|
-
catch {
|
|
268
|
-
return "Eliza Browser";
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
function cloneBrowserWorkspaceTab(tab) {
|
|
272
|
-
return { ...tab };
|
|
273
|
-
}
|
|
274
|
-
function cloneBrowserWorkspaceTabs(tabs) {
|
|
275
|
-
return tabs.map((tab) => cloneBrowserWorkspaceTab(tab));
|
|
276
|
-
}
|
|
277
|
-
function cloneWebBrowserWorkspaceTabState(tab) {
|
|
278
|
-
return {
|
|
279
|
-
id: tab.id,
|
|
280
|
-
title: tab.title,
|
|
281
|
-
url: tab.url,
|
|
282
|
-
partition: tab.partition,
|
|
283
|
-
visible: tab.visible,
|
|
284
|
-
createdAt: tab.createdAt,
|
|
285
|
-
updatedAt: tab.updatedAt,
|
|
286
|
-
lastFocusedAt: tab.lastFocusedAt,
|
|
287
|
-
};
|
|
288
|
-
}
|
|
289
|
-
function clearWebBrowserWorkspaceTabElementRefs(tabId) {
|
|
290
|
-
clearBrowserWorkspaceElementRefs("web", tabId);
|
|
291
|
-
}
|
|
292
|
-
function createEmptyWebBrowserWorkspaceDom(url) {
|
|
293
|
-
return new (getJSDOMClass())('<!doctype html><html lang="en"><head><title>New Tab</title></head><body></body></html>', {
|
|
294
|
-
pretendToBeVisual: true,
|
|
295
|
-
url,
|
|
296
|
-
});
|
|
297
|
-
}
|
|
298
|
-
function applyBrowserWorkspaceDomSettings(dom, state) {
|
|
299
|
-
const viewport = state.settings.viewport;
|
|
300
|
-
if (viewport) {
|
|
301
|
-
Object.defineProperty(dom.window, "innerWidth", {
|
|
302
|
-
configurable: true,
|
|
303
|
-
value: viewport.width,
|
|
304
|
-
});
|
|
305
|
-
Object.defineProperty(dom.window, "innerHeight", {
|
|
306
|
-
configurable: true,
|
|
307
|
-
value: viewport.height,
|
|
308
|
-
});
|
|
309
|
-
Object.defineProperty(dom.window, "devicePixelRatio", {
|
|
310
|
-
configurable: true,
|
|
311
|
-
value: viewport.scale,
|
|
312
|
-
});
|
|
313
|
-
}
|
|
314
|
-
Object.defineProperty(dom.window.navigator, "onLine", {
|
|
315
|
-
configurable: true,
|
|
316
|
-
get: () => !state.settings.offline,
|
|
317
|
-
});
|
|
318
|
-
if (state.settings.device) {
|
|
319
|
-
Object.defineProperty(dom.window.navigator, "userAgent", {
|
|
320
|
-
configurable: true,
|
|
321
|
-
value: `ElizaBrowserWorkspace/${state.settings.device}`,
|
|
322
|
-
});
|
|
323
|
-
}
|
|
324
|
-
const matchMedia = (query) => {
|
|
325
|
-
const matches = query.includes("prefers-color-scheme") &&
|
|
326
|
-
((state.settings.media === "dark" && query.includes("dark")) ||
|
|
327
|
-
(state.settings.media === "light" && query.includes("light")));
|
|
328
|
-
return {
|
|
329
|
-
addEventListener() { },
|
|
330
|
-
addListener() { },
|
|
331
|
-
dispatchEvent() {
|
|
332
|
-
return true;
|
|
333
|
-
},
|
|
334
|
-
matches,
|
|
335
|
-
media: query,
|
|
336
|
-
onchange: null,
|
|
337
|
-
removeEventListener() { },
|
|
338
|
-
removeListener() { },
|
|
339
|
-
};
|
|
340
|
-
};
|
|
341
|
-
Object.defineProperty(dom.window, "matchMedia", {
|
|
342
|
-
configurable: true,
|
|
343
|
-
value: matchMedia,
|
|
344
|
-
});
|
|
345
|
-
Object.defineProperty(dom.window.navigator, "clipboard", {
|
|
346
|
-
configurable: true,
|
|
347
|
-
value: {
|
|
348
|
-
readText: async () => browserWorkspaceClipboardText,
|
|
349
|
-
writeText: async (value) => {
|
|
350
|
-
browserWorkspaceClipboardText = String(value ?? "");
|
|
351
|
-
},
|
|
352
|
-
},
|
|
353
|
-
});
|
|
354
|
-
Object.defineProperty(dom.window.navigator, "geolocation", {
|
|
355
|
-
configurable: true,
|
|
356
|
-
value: {
|
|
357
|
-
getCurrentPosition: (success) => {
|
|
358
|
-
const coords = state.settings.geo ?? { latitude: 0, longitude: 0 };
|
|
359
|
-
success({
|
|
360
|
-
coords: {
|
|
361
|
-
accuracy: 1,
|
|
362
|
-
latitude: coords.latitude,
|
|
363
|
-
longitude: coords.longitude,
|
|
364
|
-
},
|
|
365
|
-
timestamp: Date.now(),
|
|
366
|
-
});
|
|
367
|
-
},
|
|
368
|
-
},
|
|
369
|
-
});
|
|
370
|
-
}
|
|
371
|
-
function installBrowserWorkspaceWebRuntime(tab, dom) {
|
|
372
|
-
const state = getBrowserWorkspaceRuntimeState("web", tab.id);
|
|
373
|
-
applyBrowserWorkspaceDomSettings(dom, state);
|
|
374
|
-
const windowRecord = dom.window;
|
|
375
|
-
windowRecord.__elizaBrowserWorkspaceState = state;
|
|
376
|
-
const consoleTarget = dom.window.console;
|
|
377
|
-
if (!consoleTarget.__elizaWrapped) {
|
|
378
|
-
for (const level of ["log", "info", "warn", "error"]) {
|
|
379
|
-
consoleTarget[level] = (...args) => {
|
|
380
|
-
state.consoleEntries.push({
|
|
381
|
-
level,
|
|
382
|
-
message: args
|
|
383
|
-
.map((value) => normalizeBrowserWorkspaceText(value))
|
|
384
|
-
.join(" "),
|
|
385
|
-
timestamp: getBrowserWorkspaceTimestamp(),
|
|
386
|
-
});
|
|
387
|
-
return undefined;
|
|
388
|
-
};
|
|
389
|
-
}
|
|
390
|
-
consoleTarget.__elizaWrapped = true;
|
|
391
|
-
}
|
|
392
|
-
dom.window.alert = (message) => {
|
|
393
|
-
state.dialog = {
|
|
394
|
-
defaultValue: null,
|
|
395
|
-
message: String(message ?? ""),
|
|
396
|
-
open: true,
|
|
397
|
-
type: "alert",
|
|
398
|
-
};
|
|
399
|
-
};
|
|
400
|
-
dom.window.confirm = (message) => {
|
|
401
|
-
state.dialog = {
|
|
402
|
-
defaultValue: null,
|
|
403
|
-
message: String(message ?? ""),
|
|
404
|
-
open: true,
|
|
405
|
-
type: "confirm",
|
|
406
|
-
};
|
|
407
|
-
return false;
|
|
408
|
-
};
|
|
409
|
-
dom.window.prompt = (message, defaultValue) => {
|
|
410
|
-
state.dialog = {
|
|
411
|
-
defaultValue: defaultValue ?? null,
|
|
412
|
-
message: String(message ?? ""),
|
|
413
|
-
open: true,
|
|
414
|
-
type: "prompt",
|
|
415
|
-
};
|
|
416
|
-
return null;
|
|
417
|
-
};
|
|
418
|
-
Object.defineProperty(dom.window, "fetch", {
|
|
419
|
-
configurable: true,
|
|
420
|
-
value: async (input, init) => {
|
|
421
|
-
const inputUrl = typeof input === "string"
|
|
422
|
-
? input
|
|
423
|
-
: input instanceof URL
|
|
424
|
-
? input.toString()
|
|
425
|
-
: typeof input.url === "string"
|
|
426
|
-
? input.url
|
|
427
|
-
: String(input);
|
|
428
|
-
return fetchBrowserWorkspaceTrackedResponse(state, new URL(inputUrl, tab.url).toString(), {
|
|
429
|
-
...init,
|
|
430
|
-
headers: init?.headers ??
|
|
431
|
-
(input.headers
|
|
432
|
-
? input.headers
|
|
433
|
-
: undefined),
|
|
434
|
-
method: init?.method ??
|
|
435
|
-
(typeof input.method === "string"
|
|
436
|
-
? input.method
|
|
437
|
-
: undefined),
|
|
438
|
-
}, "fetch");
|
|
439
|
-
},
|
|
440
|
-
});
|
|
441
|
-
}
|
|
442
|
-
function getWebBrowserWorkspaceTabIndex(tabId) {
|
|
443
|
-
return webWorkspaceState.tabs.findIndex((tab) => tab.id === tabId);
|
|
444
|
-
}
|
|
445
|
-
function getWebBrowserWorkspaceTabState(tabId) {
|
|
446
|
-
const tab = webWorkspaceState.tabs.find((entry) => entry.id === tabId);
|
|
447
|
-
if (!tab) {
|
|
448
|
-
throw createBrowserWorkspaceNotFoundError(tabId);
|
|
449
|
-
}
|
|
450
|
-
return tab;
|
|
451
|
-
}
|
|
452
|
-
function getCurrentWebBrowserWorkspaceTabState() {
|
|
453
|
-
if (webWorkspaceState.tabs.length === 0) {
|
|
454
|
-
return null;
|
|
455
|
-
}
|
|
456
|
-
return (webWorkspaceState.tabs.find((tab) => tab.visible) ??
|
|
457
|
-
[...webWorkspaceState.tabs].sort((left, right) => {
|
|
458
|
-
const leftTime = left.lastFocusedAt ?? left.updatedAt;
|
|
459
|
-
const rightTime = right.lastFocusedAt ?? right.updatedAt;
|
|
460
|
-
return (rightTime.localeCompare(leftTime) || left.id.localeCompare(right.id));
|
|
461
|
-
})[0] ??
|
|
462
|
-
null);
|
|
463
|
-
}
|
|
464
|
-
function createWebBrowserWorkspaceTab(request) {
|
|
465
|
-
const now = getBrowserWorkspaceTimestamp();
|
|
466
|
-
const url = assertBrowserWorkspaceUrl(request.url?.trim() || "about:blank");
|
|
467
|
-
const visible = request.show === true;
|
|
468
|
-
const id = `btab_${webWorkspaceState.nextId++}`;
|
|
469
|
-
const dom = url === "about:blank" ? createEmptyWebBrowserWorkspaceDom(url) : null;
|
|
470
|
-
if (dom) {
|
|
471
|
-
const bootstrapTab = {
|
|
472
|
-
id,
|
|
473
|
-
title: request.title?.trim() || inferBrowserWorkspaceTitle(url),
|
|
474
|
-
url,
|
|
475
|
-
partition: request.partition?.trim() || DEFAULT_WEB_PARTITION,
|
|
476
|
-
visible,
|
|
477
|
-
createdAt: now,
|
|
478
|
-
updatedAt: now,
|
|
479
|
-
lastFocusedAt: visible ? now : null,
|
|
480
|
-
dom,
|
|
481
|
-
history: [url],
|
|
482
|
-
historyIndex: 0,
|
|
483
|
-
loadedUrl: url,
|
|
484
|
-
};
|
|
485
|
-
installBrowserWorkspaceWebRuntime(bootstrapTab, dom);
|
|
486
|
-
return bootstrapTab;
|
|
487
|
-
}
|
|
488
|
-
return {
|
|
489
|
-
id,
|
|
490
|
-
title: request.title?.trim() || inferBrowserWorkspaceTitle(url),
|
|
491
|
-
url,
|
|
492
|
-
partition: request.partition?.trim() || DEFAULT_WEB_PARTITION,
|
|
493
|
-
visible,
|
|
494
|
-
createdAt: now,
|
|
495
|
-
updatedAt: now,
|
|
496
|
-
lastFocusedAt: visible ? now : null,
|
|
497
|
-
dom,
|
|
498
|
-
history: [url],
|
|
499
|
-
historyIndex: 0,
|
|
500
|
-
loadedUrl: url === "about:blank" ? url : null,
|
|
501
|
-
};
|
|
502
|
-
}
|
|
503
|
-
function buildBrowserWorkspaceCssStringLiteral(value) {
|
|
504
|
-
return JSON.stringify(value);
|
|
505
|
-
}
|
|
506
|
-
function buildBrowserWorkspaceElementSelector(element) {
|
|
507
|
-
const escapedId = typeof globalThis.CSS
|
|
508
|
-
?.escape === "function"
|
|
509
|
-
? globalThis.CSS.escape(element.id)
|
|
510
|
-
: element.id.replace(/[^a-zA-Z0-9_-]/g, "\\$&");
|
|
511
|
-
if (element.id) {
|
|
512
|
-
return `#${escapedId}`;
|
|
513
|
-
}
|
|
514
|
-
const testId = element.getAttribute("data-testid")?.trim();
|
|
515
|
-
if (testId) {
|
|
516
|
-
return `[data-testid=${buildBrowserWorkspaceCssStringLiteral(testId)}]`;
|
|
517
|
-
}
|
|
518
|
-
const name = element.getAttribute("name")?.trim();
|
|
519
|
-
if (name) {
|
|
520
|
-
return `${element.tagName.toLowerCase()}[name=${buildBrowserWorkspaceCssStringLiteral(name)}]`;
|
|
521
|
-
}
|
|
522
|
-
const type = element.getAttribute("type")?.trim();
|
|
523
|
-
if (type) {
|
|
524
|
-
return `${element.tagName.toLowerCase()}[type=${buildBrowserWorkspaceCssStringLiteral(type)}]`;
|
|
525
|
-
}
|
|
526
|
-
const parent = element.parentElement;
|
|
527
|
-
if (!parent) {
|
|
528
|
-
return element.tagName.toLowerCase();
|
|
529
|
-
}
|
|
530
|
-
const siblings = parent.children;
|
|
531
|
-
let index = 1;
|
|
532
|
-
for (let cursor = 0; cursor < siblings.length; cursor += 1) {
|
|
533
|
-
const sibling = siblings.item(cursor);
|
|
534
|
-
if (!sibling || sibling.tagName !== element.tagName) {
|
|
535
|
-
continue;
|
|
536
|
-
}
|
|
537
|
-
if (sibling === element) {
|
|
538
|
-
break;
|
|
539
|
-
}
|
|
540
|
-
index += 1;
|
|
541
|
-
}
|
|
542
|
-
return `${element.tagName.toLowerCase()}:nth-of-type(${index})`;
|
|
543
|
-
}
|
|
544
|
-
function createBrowserWorkspaceElementSummary(element) {
|
|
545
|
-
const inputLike = element.tagName === "INPUT" ||
|
|
546
|
-
element.tagName === "TEXTAREA" ||
|
|
547
|
-
element.tagName === "SELECT";
|
|
548
|
-
const elementValue = inputLike
|
|
549
|
-
? (element
|
|
550
|
-
.value ?? null)
|
|
551
|
-
: null;
|
|
552
|
-
return {
|
|
553
|
-
selector: buildBrowserWorkspaceElementSelector(element),
|
|
554
|
-
tag: element.tagName.toLowerCase(),
|
|
555
|
-
text: normalizeBrowserWorkspaceText(inputLike ? elementValue : element.textContent),
|
|
556
|
-
type: element.getAttribute("type"),
|
|
557
|
-
name: element.getAttribute("name"),
|
|
558
|
-
href: element.getAttribute("href"),
|
|
559
|
-
value: typeof elementValue === "string" ? elementValue : null,
|
|
560
|
-
};
|
|
561
|
-
}
|
|
562
|
-
function collectBrowserWorkspaceInspectElements(document) {
|
|
563
|
-
const elements = Array.from(document.querySelectorAll("a, button, input, textarea, select, form, [role='button'], [data-testid]"));
|
|
564
|
-
const summaries = [];
|
|
565
|
-
const seenSelectors = new Set();
|
|
566
|
-
for (const element of elements) {
|
|
567
|
-
const summary = createBrowserWorkspaceElementSummary(element);
|
|
568
|
-
if (seenSelectors.has(summary.selector)) {
|
|
569
|
-
continue;
|
|
570
|
-
}
|
|
571
|
-
seenSelectors.add(summary.selector);
|
|
572
|
-
summaries.push(summary);
|
|
573
|
-
if (summaries.length >= 40) {
|
|
574
|
-
break;
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
return summaries;
|
|
578
|
-
}
|
|
579
|
-
function resolveBrowserWorkspaceIframeDocument(runtime, frameElement, baseUrl) {
|
|
580
|
-
if (!frameElement || frameElement.tagName !== "IFRAME") {
|
|
581
|
-
return null;
|
|
582
|
-
}
|
|
583
|
-
const iframe = frameElement;
|
|
584
|
-
const srcdoc = iframe.getAttribute("srcdoc");
|
|
585
|
-
if (srcdoc?.trim()) {
|
|
586
|
-
const selector = buildBrowserWorkspaceElementSelector(frameElement);
|
|
587
|
-
const cached = runtime.frameDoms.get(selector);
|
|
588
|
-
if (cached) {
|
|
589
|
-
return cached.window.document;
|
|
590
|
-
}
|
|
591
|
-
if (iframe.contentDocument &&
|
|
592
|
-
normalizeBrowserWorkspaceText(iframe.contentDocument.body?.textContent)
|
|
593
|
-
.length > 0) {
|
|
594
|
-
return iframe.contentDocument;
|
|
595
|
-
}
|
|
596
|
-
const parsed = new (getJSDOMClass())(srcdoc, {
|
|
597
|
-
pretendToBeVisual: true,
|
|
598
|
-
url: baseUrl,
|
|
599
|
-
});
|
|
600
|
-
runtime.frameDoms.set(selector, parsed);
|
|
601
|
-
return parsed.window.document;
|
|
602
|
-
}
|
|
603
|
-
if (iframe.contentDocument) {
|
|
604
|
-
return iframe.contentDocument;
|
|
605
|
-
}
|
|
606
|
-
return null;
|
|
607
|
-
}
|
|
608
|
-
function resolveWebBrowserWorkspaceCommandDocument(tab, dom) {
|
|
609
|
-
const state = getBrowserWorkspaceRuntimeState("web", tab.id);
|
|
610
|
-
const frameSelector = state.currentFrame?.trim() || null;
|
|
611
|
-
if (!frameSelector) {
|
|
612
|
-
return { document: dom.window.document, frameSelector: null };
|
|
613
|
-
}
|
|
614
|
-
const frameElement = resolveBrowserWorkspaceElement(dom.window.document, frameSelector);
|
|
615
|
-
const frameDocument = resolveBrowserWorkspaceIframeDocument(state, frameElement, tab.url);
|
|
616
|
-
if (!frameDocument) {
|
|
617
|
-
return { document: dom.window.document, frameSelector: null };
|
|
618
|
-
}
|
|
619
|
-
return { document: frameDocument, frameSelector };
|
|
620
|
-
}
|
|
621
|
-
function getBrowserWorkspaceElementSearchTexts(element) {
|
|
622
|
-
const labelText = element.id && element.ownerDocument
|
|
623
|
-
? Array.from(element.ownerDocument.querySelectorAll(`label[for="${element.id}"]`))
|
|
624
|
-
.map((label) => label.textContent)
|
|
625
|
-
.join(" ")
|
|
626
|
-
: "";
|
|
627
|
-
return [
|
|
628
|
-
element.textContent,
|
|
629
|
-
element.getAttribute("aria-label"),
|
|
630
|
-
element.getAttribute("placeholder"),
|
|
631
|
-
element.getAttribute("title"),
|
|
632
|
-
element.getAttribute("name"),
|
|
633
|
-
element.getAttribute("alt"),
|
|
634
|
-
element.getAttribute("data-testid"),
|
|
635
|
-
labelText,
|
|
636
|
-
element
|
|
637
|
-
.value,
|
|
638
|
-
]
|
|
639
|
-
.map((value) => normalizeBrowserWorkspaceText(value))
|
|
640
|
-
.filter(Boolean);
|
|
641
|
-
}
|
|
642
|
-
function browserWorkspaceTextMatches(candidate, wanted, exact = false) {
|
|
643
|
-
const normalizedCandidate = normalizeBrowserWorkspaceText(candidate).toLowerCase();
|
|
644
|
-
const normalizedWanted = normalizeBrowserWorkspaceText(wanted).toLowerCase();
|
|
645
|
-
if (!normalizedCandidate || !normalizedWanted) {
|
|
646
|
-
return false;
|
|
647
|
-
}
|
|
648
|
-
return exact
|
|
649
|
-
? normalizedCandidate === normalizedWanted
|
|
650
|
-
: normalizedCandidate.includes(normalizedWanted);
|
|
651
|
-
}
|
|
652
|
-
function isBrowserWorkspaceElementVisible(element) {
|
|
653
|
-
if (element.hasAttribute("hidden") ||
|
|
654
|
-
element.getAttribute("aria-hidden") === "true") {
|
|
655
|
-
return false;
|
|
656
|
-
}
|
|
657
|
-
const htmlElement = element;
|
|
658
|
-
const inlineDisplay = htmlElement.style?.display?.trim().toLowerCase();
|
|
659
|
-
const inlineVisibility = htmlElement.style?.visibility?.trim().toLowerCase();
|
|
660
|
-
if (inlineDisplay === "none" || inlineVisibility === "hidden") {
|
|
661
|
-
return false;
|
|
662
|
-
}
|
|
663
|
-
return true;
|
|
664
|
-
}
|
|
665
|
-
function findBrowserWorkspaceElementByLabel(document, labelText, exact = false) {
|
|
666
|
-
const labels = Array.from(document.querySelectorAll("label"));
|
|
667
|
-
for (const label of labels) {
|
|
668
|
-
if (!browserWorkspaceTextMatches(label.textContent ?? "", labelText, exact)) {
|
|
669
|
-
continue;
|
|
670
|
-
}
|
|
671
|
-
const forId = label.getAttribute("for")?.trim();
|
|
672
|
-
if (forId) {
|
|
673
|
-
const explicit = document.getElementById(forId);
|
|
674
|
-
if (explicit) {
|
|
675
|
-
return explicit;
|
|
676
|
-
}
|
|
677
|
-
}
|
|
678
|
-
const nested = label.querySelector("input, textarea, select, button");
|
|
679
|
-
if (nested) {
|
|
680
|
-
return nested;
|
|
681
|
-
}
|
|
682
|
-
}
|
|
683
|
-
return null;
|
|
684
|
-
}
|
|
685
|
-
function getBrowserWorkspaceNativeRole(element) {
|
|
686
|
-
const explicitRole = element.getAttribute("role")?.trim().toLowerCase();
|
|
687
|
-
if (explicitRole) {
|
|
688
|
-
return explicitRole;
|
|
689
|
-
}
|
|
690
|
-
const tag = element.tagName.toLowerCase();
|
|
691
|
-
if (tag === "a" && element.getAttribute("href"))
|
|
692
|
-
return "link";
|
|
693
|
-
if (tag === "button")
|
|
694
|
-
return "button";
|
|
695
|
-
if (tag === "select")
|
|
696
|
-
return "combobox";
|
|
697
|
-
if (tag === "option")
|
|
698
|
-
return "option";
|
|
699
|
-
if (tag === "textarea")
|
|
700
|
-
return "textbox";
|
|
701
|
-
if (tag === "form")
|
|
702
|
-
return "form";
|
|
703
|
-
if (/^h[1-6]$/.test(tag))
|
|
704
|
-
return "heading";
|
|
705
|
-
if (tag === "input") {
|
|
706
|
-
const input = element;
|
|
707
|
-
const type = (input.type || "text").toLowerCase();
|
|
708
|
-
if (type === "checkbox")
|
|
709
|
-
return "checkbox";
|
|
710
|
-
if (type === "radio")
|
|
711
|
-
return "radio";
|
|
712
|
-
if (["button", "submit", "reset", "image"].includes(type)) {
|
|
713
|
-
return "button";
|
|
714
|
-
}
|
|
715
|
-
return "textbox";
|
|
716
|
-
}
|
|
717
|
-
return null;
|
|
718
|
-
}
|
|
719
|
-
function findBrowserWorkspaceElementByRole(document, role, name, exact = false) {
|
|
720
|
-
const wantedRole = role.trim().toLowerCase();
|
|
721
|
-
if (!wantedRole) {
|
|
722
|
-
return null;
|
|
723
|
-
}
|
|
724
|
-
const candidates = Array.from(document.querySelectorAll("a, button, input, textarea, select, option, form, h1, h2, h3, h4, h5, h6, [role], [data-testid]"));
|
|
725
|
-
for (const candidate of candidates) {
|
|
726
|
-
if (getBrowserWorkspaceNativeRole(candidate) !== wantedRole) {
|
|
727
|
-
continue;
|
|
728
|
-
}
|
|
729
|
-
if (!name?.trim()) {
|
|
730
|
-
return candidate;
|
|
731
|
-
}
|
|
732
|
-
const haystacks = getBrowserWorkspaceElementSearchTexts(candidate);
|
|
733
|
-
if (haystacks.some((value) => browserWorkspaceTextMatches(value, name, exact))) {
|
|
734
|
-
return candidate;
|
|
735
|
-
}
|
|
736
|
-
}
|
|
737
|
-
return null;
|
|
738
|
-
}
|
|
739
|
-
function trimBrowserWorkspaceQuotedValue(value) {
|
|
740
|
-
const trimmed = value.trim();
|
|
741
|
-
const hasTextMatch = trimmed.match(/^has-text\((['"])([\s\S]*?)\1\)$/i);
|
|
742
|
-
if (hasTextMatch?.[2]) {
|
|
743
|
-
return hasTextMatch[2].trim();
|
|
744
|
-
}
|
|
745
|
-
if ((trimmed.startsWith('"') && trimmed.endsWith('"')) ||
|
|
746
|
-
(trimmed.startsWith("'") && trimmed.endsWith("'"))) {
|
|
747
|
-
return trimmed.slice(1, -1).trim();
|
|
748
|
-
}
|
|
749
|
-
return trimmed;
|
|
750
|
-
}
|
|
751
|
-
function normalizeBrowserWorkspaceSelectorSyntax(selector) {
|
|
752
|
-
let normalized = selector.trim();
|
|
753
|
-
normalized = normalized.replace(/^role\s*[:=]\s*([a-z0-9_-]+)\s+name\s*[:=]\s*(.+)$/i, "role=$1[name=$2]");
|
|
754
|
-
normalized = normalized.replace(/^((?:label|text|placeholder|alt|title|testid|data-testid)\s*[:=]\s*(?:has-text\((['"])[\s\S]*?\2\)|"[^"]+"|'[^']+'|[^>]+?))\s+((?:input|textarea|select)[\s\S]*)$/i, "$1 >> $3");
|
|
755
|
-
return normalized;
|
|
756
|
-
}
|
|
757
|
-
function parseBrowserWorkspaceSemanticSelector(selector) {
|
|
758
|
-
const trimmed = normalizeBrowserWorkspaceSelectorSyntax(selector);
|
|
759
|
-
const match = trimmed.match(/^([a-z-]+)\s*[:=]\s*(.+)$/i);
|
|
760
|
-
if (!match) {
|
|
761
|
-
return null;
|
|
762
|
-
}
|
|
763
|
-
const kind = match[1]?.trim().toLowerCase();
|
|
764
|
-
const rawValue = match[2]?.trim() ?? "";
|
|
765
|
-
if (!kind || !rawValue) {
|
|
766
|
-
return null;
|
|
767
|
-
}
|
|
768
|
-
switch (kind) {
|
|
769
|
-
case "alt":
|
|
770
|
-
return { findBy: "alt", text: trimBrowserWorkspaceQuotedValue(rawValue) };
|
|
771
|
-
case "css":
|
|
772
|
-
return { selector: trimBrowserWorkspaceQuotedValue(rawValue) };
|
|
773
|
-
case "data-testid":
|
|
774
|
-
case "testid":
|
|
775
|
-
return {
|
|
776
|
-
findBy: "testid",
|
|
777
|
-
text: trimBrowserWorkspaceQuotedValue(rawValue),
|
|
778
|
-
};
|
|
779
|
-
case "label":
|
|
780
|
-
return {
|
|
781
|
-
findBy: "label",
|
|
782
|
-
text: trimBrowserWorkspaceQuotedValue(rawValue),
|
|
783
|
-
};
|
|
784
|
-
case "placeholder":
|
|
785
|
-
return {
|
|
786
|
-
findBy: "placeholder",
|
|
787
|
-
text: trimBrowserWorkspaceQuotedValue(rawValue),
|
|
788
|
-
};
|
|
789
|
-
case "role": {
|
|
790
|
-
const roleMatch = rawValue.match(/^([a-z0-9_-]+)(?:\s*\[\s*name\s*[:=]\s*(.+?)\s*\])?$/i);
|
|
791
|
-
if (!roleMatch?.[1]) {
|
|
792
|
-
return null;
|
|
793
|
-
}
|
|
794
|
-
return {
|
|
795
|
-
findBy: "role",
|
|
796
|
-
name: roleMatch[2]
|
|
797
|
-
? trimBrowserWorkspaceQuotedValue(roleMatch[2])
|
|
798
|
-
: undefined,
|
|
799
|
-
role: roleMatch[1].trim().toLowerCase(),
|
|
800
|
-
};
|
|
801
|
-
}
|
|
802
|
-
case "text":
|
|
803
|
-
return {
|
|
804
|
-
findBy: "text",
|
|
805
|
-
text: trimBrowserWorkspaceQuotedValue(rawValue),
|
|
806
|
-
};
|
|
807
|
-
case "title":
|
|
808
|
-
return {
|
|
809
|
-
findBy: "title",
|
|
810
|
-
text: trimBrowserWorkspaceQuotedValue(rawValue),
|
|
811
|
-
};
|
|
812
|
-
default:
|
|
813
|
-
return null;
|
|
814
|
-
}
|
|
815
|
-
}
|
|
816
|
-
function mergeBrowserWorkspaceSelectorCommand(command, selector) {
|
|
817
|
-
const parsed = parseBrowserWorkspaceSemanticSelector(selector);
|
|
818
|
-
if (!parsed) {
|
|
819
|
-
return null;
|
|
820
|
-
}
|
|
821
|
-
return {
|
|
822
|
-
...command,
|
|
823
|
-
...parsed,
|
|
824
|
-
selector: parsed.selector,
|
|
825
|
-
};
|
|
826
|
-
}
|
|
827
|
-
function queryBrowserWorkspaceSelector(root, selector) {
|
|
828
|
-
try {
|
|
829
|
-
return root.querySelector(selector);
|
|
830
|
-
}
|
|
831
|
-
catch {
|
|
832
|
-
throw new Error(`Invalid selector ${selector}`);
|
|
833
|
-
}
|
|
834
|
-
}
|
|
835
|
-
function queryAllBrowserWorkspaceSelector(root, selector) {
|
|
836
|
-
try {
|
|
837
|
-
return Array.from(root.querySelectorAll(selector));
|
|
838
|
-
}
|
|
839
|
-
catch {
|
|
840
|
-
throw new Error(`Invalid selector ${selector}`);
|
|
841
|
-
}
|
|
842
|
-
}
|
|
843
|
-
function browserWorkspacePatternMatches(pattern, value) {
|
|
844
|
-
const trimmed = pattern.trim();
|
|
845
|
-
if (!trimmed) {
|
|
846
|
-
return false;
|
|
847
|
-
}
|
|
848
|
-
if (!trimmed.includes("*")) {
|
|
849
|
-
return value.includes(trimmed);
|
|
850
|
-
}
|
|
851
|
-
let wildcardPattern = "";
|
|
852
|
-
for (let index = 0; index < trimmed.length; index += 1) {
|
|
853
|
-
const char = trimmed[index] ?? "";
|
|
854
|
-
if (char === "*") {
|
|
855
|
-
const next = trimmed[index + 1];
|
|
856
|
-
if (next === "*") {
|
|
857
|
-
wildcardPattern += ".*";
|
|
858
|
-
index += 1;
|
|
859
|
-
}
|
|
860
|
-
else {
|
|
861
|
-
wildcardPattern += ".*";
|
|
862
|
-
}
|
|
863
|
-
continue;
|
|
864
|
-
}
|
|
865
|
-
wildcardPattern += char.replace(/[|\\{}()[\]^$+?.]/g, "\\$&");
|
|
866
|
-
}
|
|
867
|
-
return new RegExp(`^${wildcardPattern}$`, "i").test(value);
|
|
868
|
-
}
|
|
869
|
-
function normalizeBrowserWorkspaceHeaders(headers) {
|
|
870
|
-
if (!headers) {
|
|
871
|
-
return {};
|
|
872
|
-
}
|
|
873
|
-
return Object.fromEntries(Object.entries(headers).filter((entry) => typeof entry[0] === "string" &&
|
|
874
|
-
entry[0].trim().length > 0 &&
|
|
875
|
-
typeof entry[1] === "string"));
|
|
876
|
-
}
|
|
877
|
-
function findBrowserWorkspaceNetworkRoute(state, url) {
|
|
878
|
-
return ([...state.networkRoutes]
|
|
879
|
-
.reverse()
|
|
880
|
-
.find((route) => browserWorkspacePatternMatches(route.pattern, url)) ??
|
|
881
|
-
null);
|
|
882
|
-
}
|
|
883
|
-
function recordBrowserWorkspaceNetworkRequest(state, request) {
|
|
884
|
-
const entry = {
|
|
885
|
-
...request,
|
|
886
|
-
id: `req_${state.networkNextRequestId++}`,
|
|
887
|
-
timestamp: getBrowserWorkspaceTimestamp(),
|
|
888
|
-
};
|
|
889
|
-
state.networkRequests.push(entry);
|
|
890
|
-
if (state.networkHar.active) {
|
|
891
|
-
state.networkHar.entries.push(entry);
|
|
892
|
-
}
|
|
893
|
-
return entry;
|
|
894
|
-
}
|
|
895
|
-
async function fetchBrowserWorkspaceTrackedResponse(state, url, init = {}, resourceType) {
|
|
896
|
-
if (state.settings.offline) {
|
|
897
|
-
recordBrowserWorkspaceNetworkRequest(state, {
|
|
898
|
-
matchedRoute: null,
|
|
899
|
-
method: String(init.method ?? "GET").toUpperCase(),
|
|
900
|
-
resourceType,
|
|
901
|
-
responseBody: null,
|
|
902
|
-
responseHeaders: {},
|
|
903
|
-
status: 0,
|
|
904
|
-
url,
|
|
905
|
-
});
|
|
906
|
-
throw new Error("Browser workspace is offline.");
|
|
907
|
-
}
|
|
908
|
-
const route = findBrowserWorkspaceNetworkRoute(state, url);
|
|
909
|
-
if (route?.abort) {
|
|
910
|
-
recordBrowserWorkspaceNetworkRequest(state, {
|
|
911
|
-
matchedRoute: route.pattern,
|
|
912
|
-
method: String(init.method ?? "GET").toUpperCase(),
|
|
913
|
-
resourceType,
|
|
914
|
-
responseBody: null,
|
|
915
|
-
responseHeaders: route.headers,
|
|
916
|
-
status: 0,
|
|
917
|
-
url,
|
|
918
|
-
});
|
|
919
|
-
throw new Error(`Browser workspace network route aborted request: ${url}`);
|
|
920
|
-
}
|
|
921
|
-
if (route &&
|
|
922
|
-
(route.body !== null ||
|
|
923
|
-
route.status !== null ||
|
|
924
|
-
Object.keys(route.headers).length > 0)) {
|
|
925
|
-
const response = new Response(route?.body ?? "", {
|
|
926
|
-
headers: route?.headers,
|
|
927
|
-
status: route?.status ?? 200,
|
|
928
|
-
});
|
|
929
|
-
recordBrowserWorkspaceNetworkRequest(state, {
|
|
930
|
-
matchedRoute: route?.pattern ?? null,
|
|
931
|
-
method: String(init.method ?? "GET").toUpperCase(),
|
|
932
|
-
resourceType,
|
|
933
|
-
responseBody: route?.body ?? "",
|
|
934
|
-
responseHeaders: route?.headers ?? {},
|
|
935
|
-
status: route?.status ?? 200,
|
|
936
|
-
url,
|
|
937
|
-
});
|
|
938
|
-
return response;
|
|
939
|
-
}
|
|
940
|
-
const headers = new Headers(init.headers ?? {});
|
|
941
|
-
for (const [key, value] of Object.entries(state.settings.headers)) {
|
|
942
|
-
if (!headers.has(key)) {
|
|
943
|
-
headers.set(key, value);
|
|
944
|
-
}
|
|
945
|
-
}
|
|
946
|
-
if (state.settings.credentials &&
|
|
947
|
-
!headers.has("Authorization") &&
|
|
948
|
-
state.settings.credentials.username) {
|
|
949
|
-
headers.set("Authorization", `Basic ${Buffer.from(`${state.settings.credentials.username}:${state.settings.credentials.password}`).toString("base64")}`);
|
|
950
|
-
}
|
|
951
|
-
const response = await browserWorkspacePageFetch(url, {
|
|
952
|
-
...init,
|
|
953
|
-
headers,
|
|
954
|
-
redirect: init.redirect ?? "follow",
|
|
955
|
-
signal: init.signal ?? AbortSignal.timeout(DEFAULT_TIMEOUT_MS),
|
|
956
|
-
});
|
|
957
|
-
let responseBody = null;
|
|
958
|
-
if (resourceType !== "document") {
|
|
959
|
-
const clone = response.clone();
|
|
960
|
-
try {
|
|
961
|
-
responseBody = await clone.text();
|
|
962
|
-
}
|
|
963
|
-
catch {
|
|
964
|
-
responseBody = null;
|
|
965
|
-
}
|
|
966
|
-
}
|
|
967
|
-
recordBrowserWorkspaceNetworkRequest(state, {
|
|
968
|
-
matchedRoute: null,
|
|
969
|
-
method: String(init.method ?? "GET").toUpperCase(),
|
|
970
|
-
resourceType,
|
|
971
|
-
responseBody,
|
|
972
|
-
responseHeaders: Object.fromEntries(response.headers.entries()),
|
|
973
|
-
status: response.status,
|
|
974
|
-
url: response.url || url,
|
|
975
|
-
});
|
|
976
|
-
return response;
|
|
977
|
-
}
|
|
978
|
-
function escapeBrowserWorkspacePdfText(value) {
|
|
979
|
-
return value
|
|
980
|
-
.replaceAll("\\", "\\\\")
|
|
981
|
-
.replaceAll("(", "\\(")
|
|
982
|
-
.replaceAll(")", "\\)");
|
|
983
|
-
}
|
|
984
|
-
function createBrowserWorkspacePdfBuffer(title, bodyText) {
|
|
985
|
-
const lines = [
|
|
986
|
-
title.trim() || "Eliza Browser Workspace",
|
|
987
|
-
"",
|
|
988
|
-
...bodyText
|
|
989
|
-
.split(/\r?\n/)
|
|
990
|
-
.map((line) => line.trim())
|
|
991
|
-
.filter(Boolean)
|
|
992
|
-
.slice(0, 32),
|
|
993
|
-
];
|
|
994
|
-
const contentLines = lines.map((line, index) => {
|
|
995
|
-
const offset = index === 0 ? "50 750 Td" : "0 -18 Td";
|
|
996
|
-
return `${offset} (${escapeBrowserWorkspacePdfText(line)}) Tj`;
|
|
997
|
-
});
|
|
998
|
-
const stream = `BT\n/F1 12 Tf\n${contentLines.join("\n")}\nET`;
|
|
999
|
-
const objects = [
|
|
1000
|
-
"<< /Type /Catalog /Pages 2 0 R >>",
|
|
1001
|
-
"<< /Type /Pages /Kids [3 0 R] /Count 1 >>",
|
|
1002
|
-
"<< /Type /Page /Parent 2 0 R /MediaBox [0 0 612 792] /Contents 4 0 R /Resources << /Font << /F1 5 0 R >> >> >>",
|
|
1003
|
-
`<< /Length ${Buffer.byteLength(stream, "utf8")} >>\nstream\n${stream}\nendstream`,
|
|
1004
|
-
"<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>",
|
|
1005
|
-
];
|
|
1006
|
-
let pdf = "%PDF-1.4\n";
|
|
1007
|
-
const offsets = [0];
|
|
1008
|
-
for (let index = 0; index < objects.length; index += 1) {
|
|
1009
|
-
offsets.push(Buffer.byteLength(pdf, "utf8"));
|
|
1010
|
-
pdf += `${index + 1} 0 obj\n${objects[index]}\nendobj\n`;
|
|
1011
|
-
}
|
|
1012
|
-
const xrefOffset = Buffer.byteLength(pdf, "utf8");
|
|
1013
|
-
pdf += `xref\n0 ${objects.length + 1}\n0000000000 65535 f \n`;
|
|
1014
|
-
for (let index = 1; index < offsets.length; index += 1) {
|
|
1015
|
-
pdf += `${String(offsets[index]).padStart(10, "0")} 00000 n \n`;
|
|
1016
|
-
}
|
|
1017
|
-
pdf += `trailer\n<< /Size ${objects.length + 1} /Root 1 0 R >>\nstartxref\n${xrefOffset}\n%%EOF`;
|
|
1018
|
-
return Buffer.from(pdf, "utf8");
|
|
1019
|
-
}
|
|
1020
|
-
function createBrowserWorkspaceSyntheticScreenshotData(title, url, bodyText, viewport) {
|
|
1021
|
-
const width = viewport?.width ?? 1280;
|
|
1022
|
-
const height = viewport?.height ?? 720;
|
|
1023
|
-
const lines = [
|
|
1024
|
-
title || "Eliza Browser Workspace",
|
|
1025
|
-
url,
|
|
1026
|
-
"",
|
|
1027
|
-
...bodyText
|
|
1028
|
-
.split(/\r?\n/)
|
|
1029
|
-
.map((line) => line.trim())
|
|
1030
|
-
.filter(Boolean)
|
|
1031
|
-
.slice(0, 18),
|
|
1032
|
-
];
|
|
1033
|
-
const escapedLines = lines.map((line) => line
|
|
1034
|
-
.replaceAll("&", "&")
|
|
1035
|
-
.replaceAll("<", "<")
|
|
1036
|
-
.replaceAll(">", ">"));
|
|
1037
|
-
const svg = `<?xml version="1.0" encoding="UTF-8"?><svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}"><rect width="100%" height="100%" fill="#faf7f1"/><rect x="24" y="24" width="${width - 48}" height="${height - 48}" rx="18" fill="#ffffff" stroke="#d8d1c4"/><text x="48" y="72" font-family="Menlo, Monaco, monospace" font-size="20" fill="#111111">${escapedLines.map((line, index) => `<tspan x="48" dy="${index === 0 ? 0 : 28}">${line}</tspan>`).join("")}</text></svg>`;
|
|
1038
|
-
return Buffer.from(svg, "utf8").toString("base64");
|
|
1039
|
-
}
|
|
1040
|
-
function createBrowserWorkspaceSnapshotRecord(title, url, bodyText) {
|
|
1041
|
-
return {
|
|
1042
|
-
bodyText: normalizeBrowserWorkspaceText(bodyText),
|
|
1043
|
-
title: normalizeBrowserWorkspaceText(title),
|
|
1044
|
-
url: normalizeBrowserWorkspaceText(url),
|
|
1045
|
-
};
|
|
1046
|
-
}
|
|
1047
|
-
function buildBrowserWorkspaceDocumentSnapshotText(document) {
|
|
1048
|
-
const bodyText = normalizeBrowserWorkspaceText(document.body?.textContent);
|
|
1049
|
-
const controlText = Array.from(document.querySelectorAll("input, textarea, select, option:checked"))
|
|
1050
|
-
.map((element) => {
|
|
1051
|
-
const name = element.getAttribute("name") ||
|
|
1052
|
-
element.getAttribute("id") ||
|
|
1053
|
-
element.tagName.toLowerCase();
|
|
1054
|
-
const value = element.tagName === "SELECT"
|
|
1055
|
-
? element.value
|
|
1056
|
-
: "value" in element
|
|
1057
|
-
? element.value
|
|
1058
|
-
: (element.textContent ?? "");
|
|
1059
|
-
return `${name}:${normalizeBrowserWorkspaceText(value)}`;
|
|
1060
|
-
})
|
|
1061
|
-
.filter(Boolean)
|
|
1062
|
-
.join(" ");
|
|
1063
|
-
return normalizeBrowserWorkspaceText(`${bodyText} ${controlText}`);
|
|
1064
|
-
}
|
|
1065
|
-
function diffBrowserWorkspaceSnapshots(before, after) {
|
|
1066
|
-
return {
|
|
1067
|
-
changed: !before ||
|
|
1068
|
-
before.bodyText !== after.bodyText ||
|
|
1069
|
-
before.title !== after.title ||
|
|
1070
|
-
before.url !== after.url,
|
|
1071
|
-
previous: before,
|
|
1072
|
-
current: after,
|
|
1073
|
-
};
|
|
1074
|
-
}
|
|
1075
|
-
async function writeBrowserWorkspaceFile(filePath, contents) {
|
|
1076
|
-
const resolved = path.resolve(filePath);
|
|
1077
|
-
await fsp.mkdir(path.dirname(resolved), { recursive: true });
|
|
1078
|
-
await fsp.writeFile(resolved, contents);
|
|
1079
|
-
return resolved;
|
|
1080
|
-
}
|
|
1081
|
-
function resolveBrowserWorkspaceFindElement(document, command) {
|
|
1082
|
-
switch (command.findBy) {
|
|
1083
|
-
case "alt":
|
|
1084
|
-
return (Array.from(document.querySelectorAll("[alt]")).find((element) => browserWorkspaceTextMatches(element.getAttribute("alt") ?? "", command.text ?? "", command.exact)) ?? null);
|
|
1085
|
-
case "first":
|
|
1086
|
-
return command.selector?.trim()
|
|
1087
|
-
? queryBrowserWorkspaceSelector(document, command.selector)
|
|
1088
|
-
: null;
|
|
1089
|
-
case "label":
|
|
1090
|
-
return command.text?.trim()
|
|
1091
|
-
? findBrowserWorkspaceElementByLabel(document, command.text, command.exact)
|
|
1092
|
-
: null;
|
|
1093
|
-
case "last":
|
|
1094
|
-
return command.selector?.trim()
|
|
1095
|
-
? (queryAllBrowserWorkspaceSelector(document, command.selector).at(-1) ?? null)
|
|
1096
|
-
: null;
|
|
1097
|
-
case "nth":
|
|
1098
|
-
if (!command.selector?.trim()) {
|
|
1099
|
-
return null;
|
|
1100
|
-
}
|
|
1101
|
-
if (typeof command.index !== "number" ||
|
|
1102
|
-
!Number.isInteger(command.index)) {
|
|
1103
|
-
return null;
|
|
1104
|
-
}
|
|
1105
|
-
return (queryAllBrowserWorkspaceSelector(document, command.selector).at(command.index) ?? null);
|
|
1106
|
-
case "placeholder":
|
|
1107
|
-
return (Array.from(document.querySelectorAll("[placeholder]")).find((element) => browserWorkspaceTextMatches(element.getAttribute("placeholder") ?? "", command.text ?? "", command.exact)) ?? null);
|
|
1108
|
-
case "role":
|
|
1109
|
-
return command.role?.trim()
|
|
1110
|
-
? findBrowserWorkspaceElementByRole(document, command.role, command.name, command.exact)
|
|
1111
|
-
: null;
|
|
1112
|
-
case "testid":
|
|
1113
|
-
return command.text?.trim()
|
|
1114
|
-
? document.querySelector(`[data-testid=${buildBrowserWorkspaceCssStringLiteral(command.text)}]`)
|
|
1115
|
-
: null;
|
|
1116
|
-
case "text":
|
|
1117
|
-
return command.text?.trim()
|
|
1118
|
-
? findBrowserWorkspaceElementByText(document, command.text)
|
|
1119
|
-
: null;
|
|
1120
|
-
case "title":
|
|
1121
|
-
return (Array.from(document.querySelectorAll("[title]")).find((element) => browserWorkspaceTextMatches(element.getAttribute("title") ?? "", command.text ?? "", command.exact)) ?? null);
|
|
1122
|
-
default:
|
|
1123
|
-
return null;
|
|
1124
|
-
}
|
|
1125
|
-
}
|
|
1126
|
-
function findBrowserWorkspaceElementByText(document, needle) {
|
|
1127
|
-
const wanted = normalizeBrowserWorkspaceText(needle).toLowerCase();
|
|
1128
|
-
if (!wanted) {
|
|
1129
|
-
return null;
|
|
1130
|
-
}
|
|
1131
|
-
const candidates = Array.from(document.querySelectorAll("a, button, input, textarea, select, option, label, h1, h2, h3, [role='button'], [data-testid]"));
|
|
1132
|
-
for (const element of candidates) {
|
|
1133
|
-
const haystacks = [
|
|
1134
|
-
element.textContent,
|
|
1135
|
-
element.getAttribute("aria-label"),
|
|
1136
|
-
element.getAttribute("placeholder"),
|
|
1137
|
-
element.getAttribute("title"),
|
|
1138
|
-
element.getAttribute("name"),
|
|
1139
|
-
element
|
|
1140
|
-
.value,
|
|
1141
|
-
]
|
|
1142
|
-
.map((value) => normalizeBrowserWorkspaceText(value))
|
|
1143
|
-
.filter(Boolean)
|
|
1144
|
-
.map((value) => value.toLowerCase());
|
|
1145
|
-
if (haystacks.some((value) => value.includes(wanted))) {
|
|
1146
|
-
return element;
|
|
1147
|
-
}
|
|
1148
|
-
}
|
|
1149
|
-
return null;
|
|
1150
|
-
}
|
|
1151
|
-
function resolveBrowserWorkspaceElement(document, selector, text, command) {
|
|
1152
|
-
const normalizedSelector = selector
|
|
1153
|
-
? normalizeBrowserWorkspaceSelectorSyntax(selector)
|
|
1154
|
-
: undefined;
|
|
1155
|
-
if (normalizedSelector) {
|
|
1156
|
-
const selectorChain = normalizedSelector
|
|
1157
|
-
.split(/\s*>>\s*/)
|
|
1158
|
-
.map((segment) => segment.trim())
|
|
1159
|
-
.filter(Boolean);
|
|
1160
|
-
if (selectorChain.length > 1) {
|
|
1161
|
-
let current = resolveBrowserWorkspaceElement(document, selectorChain[0], undefined, command);
|
|
1162
|
-
for (let index = 1; current && index < selectorChain.length; index += 1) {
|
|
1163
|
-
const segment = selectorChain[index];
|
|
1164
|
-
if (!segment) {
|
|
1165
|
-
continue;
|
|
1166
|
-
}
|
|
1167
|
-
if (typeof current.matches === "function" &&
|
|
1168
|
-
current.matches(segment)) {
|
|
1169
|
-
continue;
|
|
1170
|
-
}
|
|
1171
|
-
if (/^(input|textarea|select)(?:\[[^\]]+\])?$/i.test(segment) &&
|
|
1172
|
-
(current.tagName === "INPUT" ||
|
|
1173
|
-
current.tagName === "TEXTAREA" ||
|
|
1174
|
-
current.tagName === "SELECT")) {
|
|
1175
|
-
continue;
|
|
1176
|
-
}
|
|
1177
|
-
current = queryBrowserWorkspaceSelector(current, segment);
|
|
1178
|
-
}
|
|
1179
|
-
return current;
|
|
1180
|
-
}
|
|
1181
|
-
const semanticCommand = mergeBrowserWorkspaceSelectorCommand(command, normalizedSelector);
|
|
1182
|
-
if (semanticCommand) {
|
|
1183
|
-
return resolveBrowserWorkspaceFindElement(document, semanticCommand);
|
|
1184
|
-
}
|
|
1185
|
-
return queryBrowserWorkspaceSelector(document, normalizedSelector);
|
|
1186
|
-
}
|
|
1187
|
-
if (command?.findBy) {
|
|
1188
|
-
return resolveBrowserWorkspaceFindElement(document, command);
|
|
1189
|
-
}
|
|
1190
|
-
const normalizedText = text?.trim();
|
|
1191
|
-
if (normalizedText) {
|
|
1192
|
-
return findBrowserWorkspaceElementByText(document, normalizedText);
|
|
1193
|
-
}
|
|
1194
|
-
return null;
|
|
1195
|
-
}
|
|
1196
|
-
function ensureBrowserWorkspaceFormControlElement(element, subaction) {
|
|
1197
|
-
if (element.tagName === "INPUT" ||
|
|
1198
|
-
element.tagName === "TEXTAREA" ||
|
|
1199
|
-
element.tagName === "SELECT") {
|
|
1200
|
-
return element;
|
|
1201
|
-
}
|
|
1202
|
-
throw new Error(`Eliza browser workspace ${subaction} requires an input, textarea, or select target.`);
|
|
1203
|
-
}
|
|
1204
|
-
function ensureBrowserWorkspaceCheckboxElement(element, subaction) {
|
|
1205
|
-
if (element.tagName === "INPUT") {
|
|
1206
|
-
const input = element;
|
|
1207
|
-
const type = input.type.trim().toLowerCase();
|
|
1208
|
-
if (type === "checkbox" || type === "radio") {
|
|
1209
|
-
return input;
|
|
1210
|
-
}
|
|
1211
|
-
}
|
|
1212
|
-
throw new Error(`Eliza browser workspace ${subaction} requires a checkbox or radio input target.`);
|
|
1213
|
-
}
|
|
1214
|
-
function getBrowserWorkspaceElementStyles(element, window) {
|
|
1215
|
-
const computed = window.getComputedStyle(element);
|
|
1216
|
-
return {
|
|
1217
|
-
display: computed.display || null,
|
|
1218
|
-
visibility: computed.visibility || null,
|
|
1219
|
-
opacity: computed.opacity || null,
|
|
1220
|
-
};
|
|
1221
|
-
}
|
|
1222
|
-
function normalizeBrowserWorkspaceCommand(command) {
|
|
1223
|
-
const raw = command;
|
|
1224
|
-
const normalizedSubaction = typeof raw.subaction === "string"
|
|
1225
|
-
? raw.subaction.trim().toLowerCase()
|
|
1226
|
-
: typeof raw.operation === "string"
|
|
1227
|
-
? raw.operation.trim().toLowerCase()
|
|
1228
|
-
: "";
|
|
1229
|
-
const subaction = normalizedSubaction === "goto"
|
|
1230
|
-
? "navigate"
|
|
1231
|
-
: normalizedSubaction === "read"
|
|
1232
|
-
? "get"
|
|
1233
|
-
: command.subaction;
|
|
1234
|
-
const timeoutMs = parseBrowserWorkspaceNumberLike(command.timeoutMs) ??
|
|
1235
|
-
parseBrowserWorkspaceNumberLike(raw.ms) ??
|
|
1236
|
-
parseBrowserWorkspaceNumberLike(raw.milliseconds);
|
|
1237
|
-
return {
|
|
1238
|
-
...command,
|
|
1239
|
-
subaction,
|
|
1240
|
-
timeoutMs,
|
|
1241
|
-
steps: Array.isArray(command.steps)
|
|
1242
|
-
? command.steps.map((step) => normalizeBrowserWorkspaceCommand(step))
|
|
1243
|
-
: command.steps,
|
|
1244
|
-
};
|
|
1245
|
-
}
|
|
1246
|
-
function getBrowserWorkspaceElementBox(element) {
|
|
1247
|
-
const box = typeof element.getBoundingClientRect === "function"
|
|
1248
|
-
? element.getBoundingClientRect()
|
|
1249
|
-
: {
|
|
1250
|
-
bottom: 0,
|
|
1251
|
-
height: 0,
|
|
1252
|
-
left: 0,
|
|
1253
|
-
right: 0,
|
|
1254
|
-
top: 0,
|
|
1255
|
-
width: 0,
|
|
1256
|
-
x: 0,
|
|
1257
|
-
y: 0,
|
|
1258
|
-
};
|
|
1259
|
-
return {
|
|
1260
|
-
bottom: box.bottom,
|
|
1261
|
-
height: box.height,
|
|
1262
|
-
left: box.left,
|
|
1263
|
-
right: box.right,
|
|
1264
|
-
top: box.top,
|
|
1265
|
-
width: box.width,
|
|
1266
|
-
x: box.x,
|
|
1267
|
-
y: box.y,
|
|
1268
|
-
};
|
|
1269
|
-
}
|
|
1270
|
-
function getBrowserWorkspaceElementValue(element) {
|
|
1271
|
-
if (element.tagName === "INPUT" ||
|
|
1272
|
-
element.tagName === "TEXTAREA" ||
|
|
1273
|
-
element.tagName === "SELECT") {
|
|
1274
|
-
const control = element;
|
|
1275
|
-
if (element.tagName === "INPUT") {
|
|
1276
|
-
const input = control;
|
|
1277
|
-
const type = input.type.trim().toLowerCase();
|
|
1278
|
-
if (type === "checkbox" || type === "radio") {
|
|
1279
|
-
return input.checked;
|
|
1280
|
-
}
|
|
1281
|
-
}
|
|
1282
|
-
return control.value;
|
|
1283
|
-
}
|
|
1284
|
-
return null;
|
|
1285
|
-
}
|
|
1286
|
-
function findClosestBrowserWorkspaceForm(element) {
|
|
1287
|
-
if (!element) {
|
|
1288
|
-
return null;
|
|
1289
|
-
}
|
|
1290
|
-
return (element.tagName === "FORM" ? element : element.closest("form"));
|
|
1291
|
-
}
|
|
1292
|
-
async function activateWebBrowserWorkspaceElement(tab, element, subaction) {
|
|
1293
|
-
const tag = element.tagName.toLowerCase();
|
|
1294
|
-
if (tag === "a") {
|
|
1295
|
-
const href = element.getAttribute("href")?.trim();
|
|
1296
|
-
if (!href) {
|
|
1297
|
-
throw new Error("Target link does not have an href.");
|
|
1298
|
-
}
|
|
1299
|
-
const nextUrl = new URL(href, tab.url).toString();
|
|
1300
|
-
clearWebBrowserWorkspaceTabElementRefs(tab.id);
|
|
1301
|
-
tab.url = assertBrowserWorkspaceUrl(nextUrl);
|
|
1302
|
-
tab.title = inferBrowserWorkspaceTitle(tab.url);
|
|
1303
|
-
tab.dom = null;
|
|
1304
|
-
tab.loadedUrl = null;
|
|
1305
|
-
pushWebBrowserWorkspaceHistory(tab, tab.url);
|
|
1306
|
-
await loadWebBrowserWorkspaceTabDocument(tab);
|
|
1307
|
-
return {
|
|
1308
|
-
mode: "web",
|
|
1309
|
-
subaction,
|
|
1310
|
-
tab: cloneWebBrowserWorkspaceTabState(tab),
|
|
1311
|
-
value: {
|
|
1312
|
-
clickCount: subaction === "dblclick" ? 2 : 1,
|
|
1313
|
-
selector: buildBrowserWorkspaceElementSelector(element),
|
|
1314
|
-
url: tab.url,
|
|
1315
|
-
},
|
|
1316
|
-
};
|
|
1317
|
-
}
|
|
1318
|
-
const inputElement = tag === "input" ? element : null;
|
|
1319
|
-
const inputType = inputElement?.type?.toLowerCase() ?? "";
|
|
1320
|
-
if (inputElement && (inputType === "checkbox" || inputType === "radio")) {
|
|
1321
|
-
inputElement.checked = inputType === "radio" ? true : !inputElement.checked;
|
|
1322
|
-
return {
|
|
1323
|
-
mode: "web",
|
|
1324
|
-
subaction,
|
|
1325
|
-
value: {
|
|
1326
|
-
checked: inputElement.checked,
|
|
1327
|
-
clickCount: subaction === "dblclick" ? 2 : 1,
|
|
1328
|
-
selector: buildBrowserWorkspaceElementSelector(element),
|
|
1329
|
-
},
|
|
1330
|
-
};
|
|
1331
|
-
}
|
|
1332
|
-
const submitForm = findClosestBrowserWorkspaceForm(element);
|
|
1333
|
-
if (submitForm &&
|
|
1334
|
-
(tag === "form" ||
|
|
1335
|
-
tag === "button" ||
|
|
1336
|
-
(tag === "input" &&
|
|
1337
|
-
["button", "image", "submit"].includes(inputType || "submit")))) {
|
|
1338
|
-
await submitWebBrowserWorkspaceForm(tab, submitForm);
|
|
1339
|
-
return {
|
|
1340
|
-
mode: "web",
|
|
1341
|
-
subaction,
|
|
1342
|
-
tab: cloneWebBrowserWorkspaceTabState(tab),
|
|
1343
|
-
value: {
|
|
1344
|
-
clickCount: subaction === "dblclick" ? 2 : 1,
|
|
1345
|
-
selector: buildBrowserWorkspaceElementSelector(element),
|
|
1346
|
-
url: tab.url,
|
|
1347
|
-
},
|
|
1348
|
-
};
|
|
1349
|
-
}
|
|
1350
|
-
return {
|
|
1351
|
-
mode: "web",
|
|
1352
|
-
subaction,
|
|
1353
|
-
value: {
|
|
1354
|
-
clickCount: subaction === "dblclick" ? 2 : 1,
|
|
1355
|
-
selector: buildBrowserWorkspaceElementSelector(element),
|
|
1356
|
-
text: normalizeBrowserWorkspaceText(element.textContent),
|
|
1357
|
-
},
|
|
1358
|
-
};
|
|
1359
|
-
}
|
|
1360
|
-
function setBrowserWorkspaceControlValue(control, nextValue) {
|
|
1361
|
-
control.value = nextValue;
|
|
1362
|
-
if (control.tagName === "TEXTAREA") {
|
|
1363
|
-
control.textContent = nextValue;
|
|
1364
|
-
}
|
|
1365
|
-
control.setAttribute("value", nextValue);
|
|
1366
|
-
}
|
|
1367
|
-
function scrollWebBrowserWorkspaceTarget(dom, element, direction, pixels) {
|
|
1368
|
-
const resolvedPixels = Number.isFinite(pixels)
|
|
1369
|
-
? Math.max(1, Math.abs(pixels))
|
|
1370
|
-
: 240;
|
|
1371
|
-
const axis = direction === "left" || direction === "right" ? "x" : "y";
|
|
1372
|
-
const delta = direction === "up" || direction === "left"
|
|
1373
|
-
? -resolvedPixels
|
|
1374
|
-
: resolvedPixels;
|
|
1375
|
-
if (element && element instanceof dom.window.HTMLElement) {
|
|
1376
|
-
if (axis === "y") {
|
|
1377
|
-
element.scrollTop = (element.scrollTop || 0) + delta;
|
|
1378
|
-
return {
|
|
1379
|
-
axis,
|
|
1380
|
-
selector: buildBrowserWorkspaceElementSelector(element),
|
|
1381
|
-
value: element.scrollTop,
|
|
1382
|
-
};
|
|
1383
|
-
}
|
|
1384
|
-
element.scrollLeft = (element.scrollLeft || 0) + delta;
|
|
1385
|
-
return {
|
|
1386
|
-
axis,
|
|
1387
|
-
selector: buildBrowserWorkspaceElementSelector(element),
|
|
1388
|
-
value: element.scrollLeft,
|
|
1389
|
-
};
|
|
1390
|
-
}
|
|
1391
|
-
const key = axis === "y" ? "__elizaScrollY" : "__elizaScrollX";
|
|
1392
|
-
const current = Number(dom.window[key] ?? 0);
|
|
1393
|
-
const next = current + delta;
|
|
1394
|
-
dom.window[key] = next;
|
|
1395
|
-
return {
|
|
1396
|
-
axis,
|
|
1397
|
-
selector: null,
|
|
1398
|
-
value: next,
|
|
1399
|
-
};
|
|
1400
|
-
}
|
|
1401
|
-
function ensureBrowserWorkspaceDom(tab) {
|
|
1402
|
-
if (tab.dom && tab.loadedUrl === tab.url) {
|
|
1403
|
-
return tab.dom;
|
|
1404
|
-
}
|
|
1405
|
-
throw new Error(`Browser workspace tab ${tab.id} is not loaded yet. Reload or inspect the page first.`);
|
|
1406
|
-
}
|
|
1407
|
-
async function loadWebBrowserWorkspaceTabDocument(tab) {
|
|
1408
|
-
const state = getBrowserWorkspaceRuntimeState("web", tab.id);
|
|
1409
|
-
if (tab.url === "about:blank") {
|
|
1410
|
-
tab.dom = createEmptyWebBrowserWorkspaceDom(tab.url);
|
|
1411
|
-
installBrowserWorkspaceWebRuntime(tab, tab.dom);
|
|
1412
|
-
tab.loadedUrl = tab.url;
|
|
1413
|
-
tab.title = "New Tab";
|
|
1414
|
-
tab.updatedAt = getBrowserWorkspaceTimestamp();
|
|
1415
|
-
return;
|
|
1416
|
-
}
|
|
1417
|
-
const response = await fetchBrowserWorkspaceTrackedResponse(state, tab.url, {}, "document");
|
|
1418
|
-
if (!response.ok) {
|
|
1419
|
-
throw new Error(`Browser workspace web load failed (${response.status}): ${tab.url}`);
|
|
1420
|
-
}
|
|
1421
|
-
const html = await response.text();
|
|
1422
|
-
const finalUrl = assertBrowserWorkspaceUrl(response.url?.trim() || tab.url);
|
|
1423
|
-
const dom = new (getJSDOMClass())(html, {
|
|
1424
|
-
pretendToBeVisual: true,
|
|
1425
|
-
url: finalUrl,
|
|
1426
|
-
});
|
|
1427
|
-
installBrowserWorkspaceWebRuntime(tab, dom);
|
|
1428
|
-
resetBrowserWorkspaceRuntimeNavigationState(state);
|
|
1429
|
-
tab.dom = dom;
|
|
1430
|
-
tab.loadedUrl = finalUrl;
|
|
1431
|
-
tab.url = finalUrl;
|
|
1432
|
-
tab.title =
|
|
1433
|
-
normalizeBrowserWorkspaceText(dom.window.document.title) ||
|
|
1434
|
-
inferBrowserWorkspaceTitle(finalUrl);
|
|
1435
|
-
tab.updatedAt = getBrowserWorkspaceTimestamp();
|
|
1436
|
-
tab.history[tab.historyIndex] = finalUrl;
|
|
1437
|
-
}
|
|
1438
|
-
async function ensureLoadedWebBrowserWorkspaceTabDocument(tab) {
|
|
1439
|
-
if (!tab.dom || tab.loadedUrl !== tab.url) {
|
|
1440
|
-
await loadWebBrowserWorkspaceTabDocument(tab);
|
|
1441
|
-
}
|
|
1442
|
-
return ensureBrowserWorkspaceDom(tab);
|
|
1443
|
-
}
|
|
1444
|
-
function pushWebBrowserWorkspaceHistory(tab, nextUrl) {
|
|
1445
|
-
const nextHistory = tab.history.slice(0, tab.historyIndex + 1);
|
|
1446
|
-
nextHistory.push(nextUrl);
|
|
1447
|
-
tab.history = nextHistory;
|
|
1448
|
-
tab.historyIndex = nextHistory.length - 1;
|
|
1449
|
-
}
|
|
1450
|
-
function findWebBrowserWorkspaceTargetTabId(command) {
|
|
1451
|
-
if (command.id?.trim()) {
|
|
1452
|
-
return command.id.trim();
|
|
1453
|
-
}
|
|
1454
|
-
const current = getCurrentWebBrowserWorkspaceTabState();
|
|
1455
|
-
if (!current) {
|
|
1456
|
-
throw createBrowserWorkspaceCommandTargetError(command.subaction);
|
|
1457
|
-
}
|
|
1458
|
-
return current.id;
|
|
1459
|
-
}
|
|
1460
|
-
function resolveBrowserWorkspaceCurrentTab(tabs) {
|
|
1461
|
-
if (tabs.length === 0) {
|
|
1462
|
-
return null;
|
|
1463
|
-
}
|
|
1464
|
-
return (tabs.find((tab) => tab.visible) ??
|
|
1465
|
-
[...tabs].sort((left, right) => {
|
|
1466
|
-
const leftTime = left.lastFocusedAt ?? left.updatedAt;
|
|
1467
|
-
const rightTime = right.lastFocusedAt ?? right.updatedAt;
|
|
1468
|
-
return (rightTime.localeCompare(leftTime) || left.id.localeCompare(right.id));
|
|
1469
|
-
})[0] ??
|
|
1470
|
-
null);
|
|
1471
|
-
}
|
|
1472
|
-
async function resolveDesktopBrowserWorkspaceTargetTabId(command, env) {
|
|
1473
|
-
if (command.id?.trim()) {
|
|
1474
|
-
return command.id.trim();
|
|
1475
|
-
}
|
|
1476
|
-
const tabs = await listBrowserWorkspaceTabs(env);
|
|
1477
|
-
const current = resolveBrowserWorkspaceCurrentTab(tabs);
|
|
1478
|
-
if (!current) {
|
|
1479
|
-
throw createBrowserWorkspaceCommandTargetError(command.subaction);
|
|
1480
|
-
}
|
|
1481
|
-
return current.id;
|
|
1482
|
-
}
|
|
1483
|
-
async function readErrorBody(response) {
|
|
1484
|
-
try {
|
|
1485
|
-
return (await response.text()).trim().slice(0, 240);
|
|
1486
|
-
}
|
|
1487
|
-
catch {
|
|
1488
|
-
return "";
|
|
1489
|
-
}
|
|
1490
|
-
}
|
|
1491
|
-
async function requestBrowserWorkspace(path, init, env = process.env) {
|
|
1492
|
-
const config = resolveBrowserWorkspaceBridgeConfig(env);
|
|
1493
|
-
if (!config) {
|
|
1494
|
-
throw new Error(getBrowserWorkspaceUnavailableMessage());
|
|
1495
|
-
}
|
|
1496
|
-
const headers = new Headers(init?.headers ?? {});
|
|
1497
|
-
headers.set("Accept", "application/json");
|
|
1498
|
-
if (!headers.has("Content-Type") && init?.body) {
|
|
1499
|
-
headers.set("Content-Type", "application/json");
|
|
1500
|
-
}
|
|
1501
|
-
if (config.token) {
|
|
1502
|
-
headers.set("Authorization", `Bearer ${config.token}`);
|
|
1503
|
-
}
|
|
1504
|
-
const response = await fetch(`${config.baseUrl}${path}`, {
|
|
1505
|
-
...init,
|
|
1506
|
-
headers,
|
|
1507
|
-
signal: AbortSignal.timeout(DEFAULT_TIMEOUT_MS),
|
|
1508
|
-
});
|
|
1509
|
-
if (!response.ok) {
|
|
1510
|
-
const details = await readErrorBody(response);
|
|
1511
|
-
throw new Error(`Browser workspace request failed (${response.status})${details ? `: ${details}` : ""}`);
|
|
1512
|
-
}
|
|
1513
|
-
return (await response.json());
|
|
1514
|
-
}
|
|
1515
|
-
function createDesktopBrowserWorkspaceCommandScript(command) {
|
|
1516
|
-
return `
|
|
1517
|
-
(() => {
|
|
1518
|
-
const command = ${JSON.stringify(command)};
|
|
1519
|
-
const normalize = (value) => String(value ?? "").replace(/\\s+/g, " ").trim();
|
|
1520
|
-
const textMatches = (candidate, wanted, exact = false) => {
|
|
1521
|
-
const left = normalize(candidate).toLowerCase();
|
|
1522
|
-
const right = normalize(wanted).toLowerCase();
|
|
1523
|
-
if (!left || !right) return false;
|
|
1524
|
-
return exact ? left === right : left.includes(right);
|
|
1525
|
-
};
|
|
1526
|
-
const selectorFor = (element) => {
|
|
1527
|
-
if (!element) return "";
|
|
1528
|
-
if (element.id) return "#" + element.id.replace(/[^a-zA-Z0-9_-]/g, "\\\\$&");
|
|
1529
|
-
const testId = element.getAttribute?.("data-testid");
|
|
1530
|
-
if (testId) return \`[data-testid="\${testId}"]\`;
|
|
1531
|
-
const name = element.getAttribute?.("name");
|
|
1532
|
-
if (name) return \`\${element.tagName.toLowerCase()}[name="\${name}"]\`;
|
|
1533
|
-
const type = element.getAttribute?.("type");
|
|
1534
|
-
if (type) return \`\${element.tagName.toLowerCase()}[type="\${type}"]\`;
|
|
1535
|
-
let index = 1;
|
|
1536
|
-
let previous = element.previousElementSibling;
|
|
1537
|
-
while (previous) {
|
|
1538
|
-
if (previous.tagName === element.tagName) index += 1;
|
|
1539
|
-
previous = previous.previousElementSibling;
|
|
1540
|
-
}
|
|
1541
|
-
return \`\${element.tagName.toLowerCase()}:nth-of-type(\${index})\`;
|
|
1542
|
-
};
|
|
1543
|
-
const serialize = (element) => {
|
|
1544
|
-
const value =
|
|
1545
|
-
element instanceof HTMLInputElement ||
|
|
1546
|
-
element instanceof HTMLTextAreaElement ||
|
|
1547
|
-
element instanceof HTMLSelectElement
|
|
1548
|
-
? element.value
|
|
1549
|
-
: null;
|
|
1550
|
-
return {
|
|
1551
|
-
selector: selectorFor(element),
|
|
1552
|
-
tag: element.tagName.toLowerCase(),
|
|
1553
|
-
text: normalize(value ?? element.textContent),
|
|
1554
|
-
type: element.getAttribute?.("type"),
|
|
1555
|
-
name: element.getAttribute?.("name"),
|
|
1556
|
-
href: element.getAttribute?.("href"),
|
|
1557
|
-
value: typeof value === "string" ? value : null,
|
|
1558
|
-
};
|
|
1559
|
-
};
|
|
1560
|
-
const searchTexts = (element) => {
|
|
1561
|
-
const labelText = element.id
|
|
1562
|
-
? Array.from(document.querySelectorAll('label[for="' + element.id + '"]'))
|
|
1563
|
-
.map((label) => label.textContent)
|
|
1564
|
-
.join(" ")
|
|
1565
|
-
: "";
|
|
1566
|
-
return [
|
|
1567
|
-
element.textContent,
|
|
1568
|
-
element.getAttribute?.("aria-label"),
|
|
1569
|
-
element.getAttribute?.("placeholder"),
|
|
1570
|
-
element.getAttribute?.("title"),
|
|
1571
|
-
element.getAttribute?.("name"),
|
|
1572
|
-
element.getAttribute?.("alt"),
|
|
1573
|
-
element.getAttribute?.("data-testid"),
|
|
1574
|
-
labelText,
|
|
1575
|
-
element.value,
|
|
1576
|
-
]
|
|
1577
|
-
.map((value) => normalize(value))
|
|
1578
|
-
.filter(Boolean);
|
|
1579
|
-
};
|
|
1580
|
-
const isVisible = (element) => {
|
|
1581
|
-
if (!element) return false;
|
|
1582
|
-
if (element.hasAttribute?.("hidden") || element.getAttribute?.("aria-hidden") === "true") {
|
|
1583
|
-
return false;
|
|
1584
|
-
}
|
|
1585
|
-
const style = element.style || {};
|
|
1586
|
-
return style.display !== "none" && style.visibility !== "hidden";
|
|
1587
|
-
};
|
|
1588
|
-
const nativeRole = (element) => {
|
|
1589
|
-
const explicit = element.getAttribute?.("role")?.trim()?.toLowerCase();
|
|
1590
|
-
if (explicit) return explicit;
|
|
1591
|
-
const tag = element.tagName.toLowerCase();
|
|
1592
|
-
if (tag === "a" && element.getAttribute?.("href")) return "link";
|
|
1593
|
-
if (tag === "button") return "button";
|
|
1594
|
-
if (tag === "select") return "combobox";
|
|
1595
|
-
if (tag === "option") return "option";
|
|
1596
|
-
if (tag === "textarea") return "textbox";
|
|
1597
|
-
if (tag === "form") return "form";
|
|
1598
|
-
if (/^h[1-6]$/.test(tag)) return "heading";
|
|
1599
|
-
if (tag === "input") {
|
|
1600
|
-
const type = (element.type || "text").toLowerCase();
|
|
1601
|
-
if (type === "checkbox") return "checkbox";
|
|
1602
|
-
if (type === "radio") return "radio";
|
|
1603
|
-
if (["button", "submit", "reset", "image"].includes(type)) return "button";
|
|
1604
|
-
return "textbox";
|
|
1605
|
-
}
|
|
1606
|
-
return null;
|
|
1607
|
-
};
|
|
1608
|
-
const findByText = (wanted) => {
|
|
1609
|
-
const needle = normalize(wanted).toLowerCase();
|
|
1610
|
-
if (!needle) return null;
|
|
1611
|
-
const elements = Array.from(document.querySelectorAll(
|
|
1612
|
-
"a, button, input, textarea, select, option, label, h1, h2, h3, [role='button'], [data-testid]"
|
|
1613
|
-
));
|
|
1614
|
-
for (const element of elements) {
|
|
1615
|
-
const haystacks = [
|
|
1616
|
-
element.textContent,
|
|
1617
|
-
element.getAttribute?.("aria-label"),
|
|
1618
|
-
element.getAttribute?.("placeholder"),
|
|
1619
|
-
element.getAttribute?.("title"),
|
|
1620
|
-
element.getAttribute?.("name"),
|
|
1621
|
-
element.value,
|
|
1622
|
-
]
|
|
1623
|
-
.map((value) => normalize(value))
|
|
1624
|
-
.filter(Boolean)
|
|
1625
|
-
.map((value) => value.toLowerCase());
|
|
1626
|
-
if (haystacks.some((value) => value.includes(needle))) {
|
|
1627
|
-
return element;
|
|
1628
|
-
}
|
|
1629
|
-
}
|
|
1630
|
-
return null;
|
|
1631
|
-
};
|
|
1632
|
-
const findByLabel = (wanted, exact = false) => {
|
|
1633
|
-
const labels = Array.from(document.querySelectorAll("label"));
|
|
1634
|
-
for (const label of labels) {
|
|
1635
|
-
if (!textMatches(label.textContent, wanted, exact)) continue;
|
|
1636
|
-
const forId = label.getAttribute("for");
|
|
1637
|
-
if (forId) {
|
|
1638
|
-
const explicit = document.getElementById(forId);
|
|
1639
|
-
if (explicit) return explicit;
|
|
1640
|
-
}
|
|
1641
|
-
const nested = label.querySelector("input, textarea, select, button");
|
|
1642
|
-
if (nested) return nested;
|
|
1643
|
-
}
|
|
1644
|
-
return null;
|
|
1645
|
-
};
|
|
1646
|
-
const findByRole = (role, name, exact = false) => {
|
|
1647
|
-
const candidates = Array.from(
|
|
1648
|
-
document.querySelectorAll(
|
|
1649
|
-
"a, button, input, textarea, select, option, form, h1, h2, h3, h4, h5, h6, [role], [data-testid]"
|
|
1650
|
-
)
|
|
1651
|
-
);
|
|
1652
|
-
for (const candidate of candidates) {
|
|
1653
|
-
if (nativeRole(candidate) !== role.trim().toLowerCase()) continue;
|
|
1654
|
-
if (!name) return candidate;
|
|
1655
|
-
if (searchTexts(candidate).some((value) => textMatches(value, name, exact))) {
|
|
1656
|
-
return candidate;
|
|
1657
|
-
}
|
|
1658
|
-
}
|
|
1659
|
-
return null;
|
|
1660
|
-
};
|
|
1661
|
-
const trimQuoted = (value) => {
|
|
1662
|
-
const trimmed = String(value || "").trim();
|
|
1663
|
-
const hasTextMatch = trimmed.match(/^has-text\\((?:"([^"]*)"|'([^']*)')\\)$/i);
|
|
1664
|
-
if (hasTextMatch?.[1] || hasTextMatch?.[2]) {
|
|
1665
|
-
return (hasTextMatch[1] || hasTextMatch[2] || "").trim();
|
|
1666
|
-
}
|
|
1667
|
-
if (
|
|
1668
|
-
(trimmed.startsWith('"') && trimmed.endsWith('"')) ||
|
|
1669
|
-
(trimmed.startsWith("'") && trimmed.endsWith("'"))
|
|
1670
|
-
) {
|
|
1671
|
-
return trimmed.slice(1, -1).trim();
|
|
1672
|
-
}
|
|
1673
|
-
return trimmed;
|
|
1674
|
-
};
|
|
1675
|
-
const normalizeSelectorSyntax = (selector) => {
|
|
1676
|
-
let normalized = String(selector || "").trim();
|
|
1677
|
-
normalized = normalized.replace(
|
|
1678
|
-
/^role\\s*[:=]\\s*([a-z0-9_-]+)\\s+name\\s*[:=]\\s*(.+)$/i,
|
|
1679
|
-
"role=$1[name=$2]"
|
|
1680
|
-
);
|
|
1681
|
-
normalized = normalized.replace(
|
|
1682
|
-
/^((?:label|text|placeholder|alt|title|testid|data-testid)\\s*[:=]\\s*(?:has-text\\((?:"[^"]*"|'[^']*')\\)|"[^"]+"|'[^']+'|[^>]+?))\\s+((?:input|textarea|select)[\\s\\S]*)$/i,
|
|
1683
|
-
"$1 >> $2"
|
|
1684
|
-
);
|
|
1685
|
-
return normalized;
|
|
1686
|
-
};
|
|
1687
|
-
const parseSemanticSelector = (selector) => {
|
|
1688
|
-
const trimmed = normalizeSelectorSyntax(selector);
|
|
1689
|
-
const match = trimmed.match(/^([a-z-]+)\\s*[:=]\\s*(.+)$/i);
|
|
1690
|
-
if (!match) return null;
|
|
1691
|
-
const kind = match[1]?.trim()?.toLowerCase();
|
|
1692
|
-
const rawValue = match[2]?.trim() || "";
|
|
1693
|
-
if (!kind || !rawValue) return null;
|
|
1694
|
-
switch (kind) {
|
|
1695
|
-
case "alt":
|
|
1696
|
-
return { findBy: "alt", text: trimQuoted(rawValue) };
|
|
1697
|
-
case "css":
|
|
1698
|
-
return { selector: trimQuoted(rawValue) };
|
|
1699
|
-
case "data-testid":
|
|
1700
|
-
case "testid":
|
|
1701
|
-
return { findBy: "testid", text: trimQuoted(rawValue) };
|
|
1702
|
-
case "label":
|
|
1703
|
-
return { findBy: "label", text: trimQuoted(rawValue) };
|
|
1704
|
-
case "placeholder":
|
|
1705
|
-
return { findBy: "placeholder", text: trimQuoted(rawValue) };
|
|
1706
|
-
case "role": {
|
|
1707
|
-
const roleMatch = rawValue.match(
|
|
1708
|
-
/^([a-z0-9_-]+)(?:\\s*\\[\\s*name\\s*[:=]\\s*(.+?)\\s*\\])?$/i
|
|
1709
|
-
);
|
|
1710
|
-
if (!roleMatch?.[1]) return null;
|
|
1711
|
-
return {
|
|
1712
|
-
findBy: "role",
|
|
1713
|
-
name: roleMatch[2] ? trimQuoted(roleMatch[2]) : undefined,
|
|
1714
|
-
role: roleMatch[1].trim().toLowerCase(),
|
|
1715
|
-
};
|
|
1716
|
-
}
|
|
1717
|
-
case "text":
|
|
1718
|
-
return { findBy: "text", text: trimQuoted(rawValue) };
|
|
1719
|
-
case "title":
|
|
1720
|
-
return { findBy: "title", text: trimQuoted(rawValue) };
|
|
1721
|
-
default:
|
|
1722
|
-
return null;
|
|
1723
|
-
}
|
|
1724
|
-
};
|
|
1725
|
-
const mergeSelectorCommand = (selector) => {
|
|
1726
|
-
const parsed = parseSemanticSelector(selector);
|
|
1727
|
-
if (!parsed) return null;
|
|
1728
|
-
return { ...command, ...parsed, selector: parsed.selector };
|
|
1729
|
-
};
|
|
1730
|
-
const queryOne = (selector) => {
|
|
1731
|
-
try {
|
|
1732
|
-
return document.querySelector(selector);
|
|
1733
|
-
} catch {
|
|
1734
|
-
throw new Error("Invalid selector " + selector);
|
|
1735
|
-
}
|
|
1736
|
-
};
|
|
1737
|
-
const queryAll = (selector) => {
|
|
1738
|
-
try {
|
|
1739
|
-
return Array.from(document.querySelectorAll(selector));
|
|
1740
|
-
} catch {
|
|
1741
|
-
throw new Error("Invalid selector " + selector);
|
|
1742
|
-
}
|
|
1743
|
-
};
|
|
1744
|
-
const findSemantic = (targetCommand = command) => {
|
|
1745
|
-
switch (targetCommand.findBy) {
|
|
1746
|
-
case "alt":
|
|
1747
|
-
return Array.from(document.querySelectorAll("[alt]")).find((element) =>
|
|
1748
|
-
textMatches(
|
|
1749
|
-
element.getAttribute("alt"),
|
|
1750
|
-
targetCommand.text,
|
|
1751
|
-
targetCommand.exact
|
|
1752
|
-
)
|
|
1753
|
-
) || null;
|
|
1754
|
-
case "first":
|
|
1755
|
-
return targetCommand.selector ? queryOne(targetCommand.selector) : null;
|
|
1756
|
-
case "label":
|
|
1757
|
-
return targetCommand.text
|
|
1758
|
-
? findByLabel(targetCommand.text, targetCommand.exact)
|
|
1759
|
-
: null;
|
|
1760
|
-
case "last":
|
|
1761
|
-
return targetCommand.selector
|
|
1762
|
-
? queryAll(targetCommand.selector).at(-1) || null
|
|
1763
|
-
: null;
|
|
1764
|
-
case "nth":
|
|
1765
|
-
return targetCommand.selector && Number.isInteger(targetCommand.index)
|
|
1766
|
-
? queryAll(targetCommand.selector).at(targetCommand.index) || null
|
|
1767
|
-
: null;
|
|
1768
|
-
case "placeholder":
|
|
1769
|
-
return Array.from(document.querySelectorAll("[placeholder]")).find((element) =>
|
|
1770
|
-
textMatches(
|
|
1771
|
-
element.getAttribute("placeholder"),
|
|
1772
|
-
targetCommand.text,
|
|
1773
|
-
targetCommand.exact
|
|
1774
|
-
)
|
|
1775
|
-
) || null;
|
|
1776
|
-
case "role":
|
|
1777
|
-
return targetCommand.role
|
|
1778
|
-
? findByRole(
|
|
1779
|
-
targetCommand.role,
|
|
1780
|
-
targetCommand.name,
|
|
1781
|
-
targetCommand.exact
|
|
1782
|
-
)
|
|
1783
|
-
: null;
|
|
1784
|
-
case "testid":
|
|
1785
|
-
return targetCommand.text
|
|
1786
|
-
? document.querySelector('[data-testid="' + targetCommand.text + '"]')
|
|
1787
|
-
: null;
|
|
1788
|
-
case "text":
|
|
1789
|
-
return targetCommand.text ? findByText(targetCommand.text) : null;
|
|
1790
|
-
case "title":
|
|
1791
|
-
return Array.from(document.querySelectorAll("[title]")).find((element) =>
|
|
1792
|
-
textMatches(
|
|
1793
|
-
element.getAttribute("title"),
|
|
1794
|
-
targetCommand.text,
|
|
1795
|
-
targetCommand.exact
|
|
1796
|
-
)
|
|
1797
|
-
) || null;
|
|
1798
|
-
default:
|
|
1799
|
-
return null;
|
|
1800
|
-
}
|
|
1801
|
-
};
|
|
1802
|
-
const findTarget = () => {
|
|
1803
|
-
if (command.selector) {
|
|
1804
|
-
const selectorChain = normalizeSelectorSyntax(command.selector)
|
|
1805
|
-
.split(/s*>>s*/)
|
|
1806
|
-
.map((segment) => segment.trim())
|
|
1807
|
-
.filter(Boolean);
|
|
1808
|
-
if (selectorChain.length > 1) {
|
|
1809
|
-
let current = queryTarget(selectorChain[0]);
|
|
1810
|
-
for (let index = 1; current && index < selectorChain.length; index += 1) {
|
|
1811
|
-
const segment = selectorChain[index];
|
|
1812
|
-
if (!segment) continue;
|
|
1813
|
-
if (typeof current.matches === "function" && current.matches(segment)) {
|
|
1814
|
-
continue;
|
|
1815
|
-
}
|
|
1816
|
-
if (
|
|
1817
|
-
/^(input|textarea|select)(?:[[^]]+])?$/i.test(segment) &&
|
|
1818
|
-
(current.tagName === "INPUT" ||
|
|
1819
|
-
current.tagName === "TEXTAREA" ||
|
|
1820
|
-
current.tagName === "SELECT")
|
|
1821
|
-
) {
|
|
1822
|
-
continue;
|
|
1823
|
-
}
|
|
1824
|
-
current = queryOneWithin(current, segment);
|
|
1825
|
-
}
|
|
1826
|
-
return current;
|
|
1827
|
-
}
|
|
1828
|
-
return queryTarget(command.selector);
|
|
1829
|
-
}
|
|
1830
|
-
if (command.findBy) return findSemantic();
|
|
1831
|
-
if (command.text) return findByText(command.text);
|
|
1832
|
-
return null;
|
|
1833
|
-
};
|
|
1834
|
-
const queryOneWithin = (root, selector) => {
|
|
1835
|
-
try {
|
|
1836
|
-
return root.querySelector(selector);
|
|
1837
|
-
} catch {
|
|
1838
|
-
throw new Error("Invalid selector " + selector);
|
|
1839
|
-
}
|
|
1840
|
-
};
|
|
1841
|
-
const queryTarget = (selector) => {
|
|
1842
|
-
const semantic = mergeSelectorCommand(selector);
|
|
1843
|
-
if (semantic) return findSemantic(semantic);
|
|
1844
|
-
return queryOne(selector);
|
|
1845
|
-
};
|
|
1846
|
-
const inspect = () =>
|
|
1847
|
-
Array.from(
|
|
1848
|
-
document.querySelectorAll(
|
|
1849
|
-
"a, button, input, textarea, select, form, [role='button'], [data-testid]"
|
|
1850
|
-
)
|
|
1851
|
-
)
|
|
1852
|
-
.slice(0, 40)
|
|
1853
|
-
.map((element) => serialize(element));
|
|
1854
|
-
const snapshot = () => ({
|
|
1855
|
-
title: document.title,
|
|
1856
|
-
url: location.href,
|
|
1857
|
-
bodyText: normalize(document.body?.textContent).slice(0, 800),
|
|
1858
|
-
elements: inspect(),
|
|
1859
|
-
});
|
|
1860
|
-
const setInputValue = (appendMode, target) => {
|
|
1861
|
-
const element = target || findTarget();
|
|
1862
|
-
if (!element) {
|
|
1863
|
-
throw new Error("Target element was not found.");
|
|
1864
|
-
}
|
|
1865
|
-
if (
|
|
1866
|
-
!(
|
|
1867
|
-
element instanceof HTMLInputElement ||
|
|
1868
|
-
element instanceof HTMLTextAreaElement ||
|
|
1869
|
-
element instanceof HTMLSelectElement
|
|
1870
|
-
)
|
|
1871
|
-
) {
|
|
1872
|
-
throw new Error("Target element is not an input, textarea, or select.");
|
|
1873
|
-
}
|
|
1874
|
-
const nextValue = appendMode ? \`\${element.value ?? ""}\${command.value ?? ""}\` : (command.value ?? "");
|
|
1875
|
-
element.value = nextValue;
|
|
1876
|
-
element.dispatchEvent(new Event("input", { bubbles: true }));
|
|
1877
|
-
element.dispatchEvent(new Event("change", { bubbles: true }));
|
|
1878
|
-
return { selector: selectorFor(element), value: element.value };
|
|
1879
|
-
};
|
|
1880
|
-
const setChecked = (targetValue) => {
|
|
1881
|
-
const element = findTarget();
|
|
1882
|
-
if (!element) throw new Error("Target element was not found.");
|
|
1883
|
-
if (!(element instanceof HTMLInputElement)) {
|
|
1884
|
-
throw new Error("Target element is not a checkbox or radio input.");
|
|
1885
|
-
}
|
|
1886
|
-
const type = (element.type || "").toLowerCase();
|
|
1887
|
-
if (type !== "checkbox" && type !== "radio") {
|
|
1888
|
-
throw new Error("Target element is not a checkbox or radio input.");
|
|
1889
|
-
}
|
|
1890
|
-
element.checked = targetValue;
|
|
1891
|
-
element.dispatchEvent(new Event("input", { bubbles: true }));
|
|
1892
|
-
element.dispatchEvent(new Event("change", { bubbles: true }));
|
|
1893
|
-
return { checked: element.checked, selector: selectorFor(element) };
|
|
1894
|
-
};
|
|
1895
|
-
const setSelectValue = () => {
|
|
1896
|
-
const element = findTarget();
|
|
1897
|
-
if (!element) throw new Error("Target element was not found.");
|
|
1898
|
-
if (!(element instanceof HTMLSelectElement)) {
|
|
1899
|
-
throw new Error("Target element is not a select.");
|
|
1900
|
-
}
|
|
1901
|
-
const targetValue = command.value ?? "";
|
|
1902
|
-
const option = Array.from(element.options).find(
|
|
1903
|
-
(entry) =>
|
|
1904
|
-
entry.value === targetValue || textMatches(entry.textContent, targetValue, true)
|
|
1905
|
-
);
|
|
1906
|
-
if (!option) {
|
|
1907
|
-
throw new Error("Select option was not found.");
|
|
1908
|
-
}
|
|
1909
|
-
element.value = option.value;
|
|
1910
|
-
option.selected = true;
|
|
1911
|
-
element.dispatchEvent(new Event("input", { bubbles: true }));
|
|
1912
|
-
element.dispatchEvent(new Event("change", { bubbles: true }));
|
|
1913
|
-
return { selector: selectorFor(element), value: element.value };
|
|
1914
|
-
};
|
|
1915
|
-
const focusElement = (element) => {
|
|
1916
|
-
if (!element) throw new Error("Target element was not found.");
|
|
1917
|
-
if (typeof element.focus === "function") {
|
|
1918
|
-
element.focus();
|
|
1919
|
-
}
|
|
1920
|
-
return {
|
|
1921
|
-
focused: document.activeElement === element,
|
|
1922
|
-
selector: selectorFor(element),
|
|
1923
|
-
};
|
|
1924
|
-
};
|
|
1925
|
-
const hoverElement = (element) => {
|
|
1926
|
-
if (!element) throw new Error("Target element was not found.");
|
|
1927
|
-
element.setAttribute("data-eliza-hover", "true");
|
|
1928
|
-
return { hovered: true, selector: selectorFor(element) };
|
|
1929
|
-
};
|
|
1930
|
-
const activateElement = (subaction, element) => {
|
|
1931
|
-
if (!element) throw new Error("Target element was not found.");
|
|
1932
|
-
if (subaction === "dblclick") {
|
|
1933
|
-
element.dispatchEvent(new MouseEvent("dblclick", { bubbles: true }));
|
|
1934
|
-
}
|
|
1935
|
-
if (typeof element.click === "function") {
|
|
1936
|
-
element.click();
|
|
1937
|
-
}
|
|
1938
|
-
return {
|
|
1939
|
-
clickCount: subaction === "dblclick" ? 2 : 1,
|
|
1940
|
-
element: serialize(element),
|
|
1941
|
-
url: location.href,
|
|
1942
|
-
};
|
|
1943
|
-
};
|
|
1944
|
-
const keyboardTarget = () => findTarget() || document.activeElement || document.body;
|
|
1945
|
-
const keyboardWrite = (appendMode) => {
|
|
1946
|
-
const target = keyboardTarget();
|
|
1947
|
-
if (
|
|
1948
|
-
!(
|
|
1949
|
-
target instanceof HTMLInputElement ||
|
|
1950
|
-
target instanceof HTMLTextAreaElement ||
|
|
1951
|
-
target instanceof HTMLSelectElement
|
|
1952
|
-
)
|
|
1953
|
-
) {
|
|
1954
|
-
throw new Error("Keyboard text input requires an input, textarea, or select target.");
|
|
1955
|
-
}
|
|
1956
|
-
return setInputValue(appendMode, target);
|
|
1957
|
-
};
|
|
1958
|
-
const keyPhase = (phase) => {
|
|
1959
|
-
const target = keyboardTarget();
|
|
1960
|
-
const key = command.key || "Enter";
|
|
1961
|
-
target.dispatchEvent(new KeyboardEvent(phase, { key, bubbles: true }));
|
|
1962
|
-
return { key, phase, selector: selectorFor(target) };
|
|
1963
|
-
};
|
|
1964
|
-
const scrollTarget = () => findTarget();
|
|
1965
|
-
const scroll = () => {
|
|
1966
|
-
const target = scrollTarget();
|
|
1967
|
-
const direction = command.direction || "down";
|
|
1968
|
-
const pixels = Math.max(1, Math.abs(Number(command.pixels) || 240));
|
|
1969
|
-
const axis = direction === "left" || direction === "right" ? "x" : "y";
|
|
1970
|
-
const delta = direction === "up" || direction === "left" ? -pixels : pixels;
|
|
1971
|
-
if (target instanceof HTMLElement) {
|
|
1972
|
-
if (axis === "y") {
|
|
1973
|
-
target.scrollTop = (target.scrollTop || 0) + delta;
|
|
1974
|
-
return { axis, selector: selectorFor(target), value: target.scrollTop };
|
|
1975
|
-
}
|
|
1976
|
-
target.scrollLeft = (target.scrollLeft || 0) + delta;
|
|
1977
|
-
return { axis, selector: selectorFor(target), value: target.scrollLeft };
|
|
1978
|
-
}
|
|
1979
|
-
if (axis === "y") {
|
|
1980
|
-
window.scrollBy(0, delta);
|
|
1981
|
-
return { axis, selector: null, value: window.scrollY };
|
|
1982
|
-
}
|
|
1983
|
-
window.scrollBy(delta, 0);
|
|
1984
|
-
return { axis, selector: null, value: window.scrollX };
|
|
1985
|
-
};
|
|
1986
|
-
const getResult = () => {
|
|
1987
|
-
if (command.getMode === "title") return document.title;
|
|
1988
|
-
if (command.getMode === "url") return location.href;
|
|
1989
|
-
if (command.getMode === "count") {
|
|
1990
|
-
if (!command.selector) throw new Error("count requires selector");
|
|
1991
|
-
const semantic = mergeSelectorCommand(command.selector);
|
|
1992
|
-
return semantic ? Number(Boolean(findSemantic(semantic))) : queryAll(command.selector).length;
|
|
1993
|
-
}
|
|
1994
|
-
const element = findTarget();
|
|
1995
|
-
if (!element) throw new Error("Target element was not found.");
|
|
1996
|
-
switch (command.getMode) {
|
|
1997
|
-
case "attr":
|
|
1998
|
-
if (!command.attribute) throw new Error("attr lookups require attribute");
|
|
1999
|
-
return element.getAttribute(command.attribute);
|
|
2000
|
-
case "box":
|
|
2001
|
-
return element.getBoundingClientRect();
|
|
2002
|
-
case "checked":
|
|
2003
|
-
return element instanceof HTMLInputElement
|
|
2004
|
-
? Boolean(element.checked)
|
|
2005
|
-
: element instanceof HTMLOptionElement
|
|
2006
|
-
? Boolean(element.selected)
|
|
2007
|
-
: false;
|
|
2008
|
-
case "enabled":
|
|
2009
|
-
return "disabled" in element ? !Boolean(element.disabled) : true;
|
|
2010
|
-
case "html":
|
|
2011
|
-
return element.innerHTML;
|
|
2012
|
-
case "styles": {
|
|
2013
|
-
const computed = getComputedStyle(element);
|
|
2014
|
-
return {
|
|
2015
|
-
display: computed.display || null,
|
|
2016
|
-
visibility: computed.visibility || null,
|
|
2017
|
-
opacity: computed.opacity || null,
|
|
2018
|
-
};
|
|
2019
|
-
}
|
|
2020
|
-
case "text":
|
|
2021
|
-
return normalize(element.textContent);
|
|
2022
|
-
case "value":
|
|
2023
|
-
return element.value ?? element.getAttribute?.("value");
|
|
2024
|
-
case "visible":
|
|
2025
|
-
return isVisible(element);
|
|
2026
|
-
default:
|
|
2027
|
-
return normalize(element.textContent);
|
|
2028
|
-
}
|
|
2029
|
-
};
|
|
2030
|
-
const waitForCondition = () =>
|
|
2031
|
-
new Promise((resolve, reject) => {
|
|
2032
|
-
if (
|
|
2033
|
-
!command.selector &&
|
|
2034
|
-
!command.findBy &&
|
|
2035
|
-
!command.text &&
|
|
2036
|
-
!command.url &&
|
|
2037
|
-
!command.script &&
|
|
2038
|
-
Number.isFinite(Number(command.timeoutMs))
|
|
2039
|
-
) {
|
|
2040
|
-
const waitedMs = Math.max(0, Number(command.timeoutMs) || 0);
|
|
2041
|
-
setTimeout(() => resolve({ ok: true, waitedMs }), waitedMs);
|
|
2042
|
-
return;
|
|
2043
|
-
}
|
|
2044
|
-
const deadline = Date.now() + (Number(command.timeoutMs) || 4000);
|
|
2045
|
-
const check = () => {
|
|
2046
|
-
try {
|
|
2047
|
-
if (command.selector && findTarget()) {
|
|
2048
|
-
const found = findTarget();
|
|
2049
|
-
const visible =
|
|
2050
|
-
!command.state || command.state === "visible"
|
|
2051
|
-
? found && isVisible(found)
|
|
2052
|
-
: !found || !isVisible(found);
|
|
2053
|
-
if (visible) {
|
|
2054
|
-
resolve({ ok: true, selector: command.selector, state: command.state || "visible" });
|
|
2055
|
-
return;
|
|
2056
|
-
}
|
|
2057
|
-
}
|
|
2058
|
-
if (
|
|
2059
|
-
command.findBy &&
|
|
2060
|
-
(!command.state || command.state === "visible") &&
|
|
2061
|
-
findSemantic()
|
|
2062
|
-
) {
|
|
2063
|
-
resolve({ findBy: command.findBy, ok: true });
|
|
2064
|
-
return;
|
|
2065
|
-
}
|
|
2066
|
-
if (command.text && normalize(document.body?.textContent).includes(command.text)) {
|
|
2067
|
-
resolve({ ok: true, text: command.text });
|
|
2068
|
-
return;
|
|
2069
|
-
}
|
|
2070
|
-
if (command.url && location.href.includes(command.url)) {
|
|
2071
|
-
resolve({ ok: true, url: location.href });
|
|
2072
|
-
return;
|
|
2073
|
-
}
|
|
2074
|
-
if (command.script) {
|
|
2075
|
-
const fn = new Function("document", "window", "location", "return (" + command.script + ");");
|
|
2076
|
-
if (fn(document, window, location)) {
|
|
2077
|
-
resolve({ ok: true, script: true });
|
|
2078
|
-
return;
|
|
2079
|
-
}
|
|
2080
|
-
}
|
|
2081
|
-
if (Date.now() >= deadline) {
|
|
2082
|
-
reject(new Error("Timed out waiting for browser workspace condition."));
|
|
2083
|
-
return;
|
|
2084
|
-
}
|
|
2085
|
-
setTimeout(check, 100);
|
|
2086
|
-
} catch (error) {
|
|
2087
|
-
reject(error);
|
|
2088
|
-
}
|
|
2089
|
-
};
|
|
2090
|
-
check();
|
|
2091
|
-
});
|
|
2092
|
-
|
|
2093
|
-
switch (command.subaction) {
|
|
2094
|
-
case "inspect":
|
|
2095
|
-
return { title: document.title, url: location.href, elements: inspect() };
|
|
2096
|
-
case "snapshot":
|
|
2097
|
-
return snapshot();
|
|
2098
|
-
case "get":
|
|
2099
|
-
return { value: getResult() };
|
|
2100
|
-
case "find": {
|
|
2101
|
-
const element = findTarget();
|
|
2102
|
-
if (!element) throw new Error("Target element was not found.");
|
|
2103
|
-
switch (command.action) {
|
|
2104
|
-
case "check":
|
|
2105
|
-
return setChecked(true);
|
|
2106
|
-
case "click":
|
|
2107
|
-
return activateElement("click", element);
|
|
2108
|
-
case "fill":
|
|
2109
|
-
return setInputValue(false, element);
|
|
2110
|
-
case "focus":
|
|
2111
|
-
return focusElement(element);
|
|
2112
|
-
case "hover":
|
|
2113
|
-
return hoverElement(element);
|
|
2114
|
-
case "text":
|
|
2115
|
-
case undefined:
|
|
2116
|
-
return { element: serialize(element), value: normalize(element.textContent) };
|
|
2117
|
-
case "type":
|
|
2118
|
-
return setInputValue(true, element);
|
|
2119
|
-
case "uncheck":
|
|
2120
|
-
return setChecked(false);
|
|
2121
|
-
default:
|
|
2122
|
-
throw new Error("Unsupported find action.");
|
|
2123
|
-
}
|
|
2124
|
-
}
|
|
2125
|
-
case "click": {
|
|
2126
|
-
const element = findTarget();
|
|
2127
|
-
return activateElement("click", element);
|
|
2128
|
-
}
|
|
2129
|
-
case "dblclick": {
|
|
2130
|
-
const element = findTarget();
|
|
2131
|
-
return activateElement("dblclick", element);
|
|
2132
|
-
}
|
|
2133
|
-
case "check":
|
|
2134
|
-
return setChecked(true);
|
|
2135
|
-
case "fill":
|
|
2136
|
-
return setInputValue(false);
|
|
2137
|
-
case "focus": {
|
|
2138
|
-
const element = findTarget();
|
|
2139
|
-
return focusElement(element);
|
|
2140
|
-
}
|
|
2141
|
-
case "hover": {
|
|
2142
|
-
const element = findTarget();
|
|
2143
|
-
return hoverElement(element);
|
|
2144
|
-
}
|
|
2145
|
-
case "keyboardinserttext":
|
|
2146
|
-
return keyboardWrite(false);
|
|
2147
|
-
case "keyboardtype":
|
|
2148
|
-
return keyboardWrite(true);
|
|
2149
|
-
case "keydown":
|
|
2150
|
-
return keyPhase("keydown");
|
|
2151
|
-
case "keyup":
|
|
2152
|
-
return keyPhase("keyup");
|
|
2153
|
-
case "type":
|
|
2154
|
-
return setInputValue(true);
|
|
2155
|
-
case "press": {
|
|
2156
|
-
const target = findTarget() ?? document.activeElement ?? document.body;
|
|
2157
|
-
const key = command.key || "Enter";
|
|
2158
|
-
target.dispatchEvent(new KeyboardEvent("keydown", { key, bubbles: true }));
|
|
2159
|
-
target.dispatchEvent(new KeyboardEvent("keyup", { key, bubbles: true }));
|
|
2160
|
-
return { key, url: location.href };
|
|
2161
|
-
}
|
|
2162
|
-
case "scroll":
|
|
2163
|
-
return scroll();
|
|
2164
|
-
case "scrollinto": {
|
|
2165
|
-
const element = findTarget();
|
|
2166
|
-
if (!element) throw new Error("Target element was not found.");
|
|
2167
|
-
if (typeof element.scrollIntoView === "function") {
|
|
2168
|
-
element.scrollIntoView();
|
|
2169
|
-
}
|
|
2170
|
-
return { scrolled: true, selector: selectorFor(element) };
|
|
2171
|
-
}
|
|
2172
|
-
case "select":
|
|
2173
|
-
return setSelectValue();
|
|
2174
|
-
case "uncheck":
|
|
2175
|
-
return setChecked(false);
|
|
2176
|
-
case "wait":
|
|
2177
|
-
return waitForCondition();
|
|
2178
|
-
case "back":
|
|
2179
|
-
history.back();
|
|
2180
|
-
return { url: location.href, title: document.title };
|
|
2181
|
-
case "forward":
|
|
2182
|
-
history.forward();
|
|
2183
|
-
return { url: location.href, title: document.title };
|
|
2184
|
-
case "reload":
|
|
2185
|
-
location.reload();
|
|
2186
|
-
return { url: location.href, title: document.title };
|
|
2187
|
-
default:
|
|
2188
|
-
throw new Error(\`Unsupported desktop browser subaction: \${command.subaction}\`);
|
|
2189
|
-
}
|
|
2190
|
-
})()
|
|
2191
|
-
`.trim();
|
|
2192
|
-
}
|
|
2193
|
-
function createDesktopBrowserWorkspaceUtilityScript(command) {
|
|
2194
|
-
return `
|
|
2195
|
-
(() => {
|
|
2196
|
-
const command = ${JSON.stringify(command)};
|
|
2197
|
-
const normalize = (value) => String(value ?? "").replace(/\\s+/g, " ").trim();
|
|
2198
|
-
const state =
|
|
2199
|
-
window.__elizaBrowserWorkspaceState ||
|
|
2200
|
-
(window.__elizaBrowserWorkspaceState = {
|
|
2201
|
-
clipboardText: "",
|
|
2202
|
-
consoleEntries: [],
|
|
2203
|
-
currentFrame: null,
|
|
2204
|
-
dialog: null,
|
|
2205
|
-
errors: [],
|
|
2206
|
-
highlightedSelector: null,
|
|
2207
|
-
mouse: { buttons: [], x: 0, y: 0 },
|
|
2208
|
-
networkHar: { active: false, entries: [], startedAt: null },
|
|
2209
|
-
networkNextRequestId: 1,
|
|
2210
|
-
networkRequests: [],
|
|
2211
|
-
networkRoutes: [],
|
|
2212
|
-
settings: {
|
|
2213
|
-
credentials: null,
|
|
2214
|
-
device: null,
|
|
2215
|
-
geo: null,
|
|
2216
|
-
headers: {},
|
|
2217
|
-
media: null,
|
|
2218
|
-
offline: false,
|
|
2219
|
-
viewport: null
|
|
2220
|
-
}
|
|
2221
|
-
});
|
|
2222
|
-
const patternMatches = (pattern, value) => {
|
|
2223
|
-
const trimmed = String(pattern ?? "").trim();
|
|
2224
|
-
if (!trimmed) return false;
|
|
2225
|
-
if (!trimmed.includes("*")) return String(value ?? "").includes(trimmed);
|
|
2226
|
-
let wildcard = "";
|
|
2227
|
-
for (let i = 0; i < trimmed.length; i += 1) {
|
|
2228
|
-
const char = trimmed[i];
|
|
2229
|
-
if (char === "*") {
|
|
2230
|
-
if (trimmed[i + 1] === "*") {
|
|
2231
|
-
wildcard += ".*";
|
|
2232
|
-
i += 1;
|
|
2233
|
-
} else {
|
|
2234
|
-
wildcard += ".*";
|
|
2235
|
-
}
|
|
2236
|
-
} else {
|
|
2237
|
-
wildcard += char.replace(/[|\\\\{}()[\\]^$+?.]/g, "\\\\$&");
|
|
2238
|
-
}
|
|
2239
|
-
}
|
|
2240
|
-
return new RegExp("^" + wildcard + "$", "i").test(String(value ?? ""));
|
|
2241
|
-
};
|
|
2242
|
-
const buildSelector = (element) => {
|
|
2243
|
-
if (!element || !element.tagName) return null;
|
|
2244
|
-
const testId = element.getAttribute && element.getAttribute("data-testid");
|
|
2245
|
-
if (testId) return '[data-testid="' + testId + '"]';
|
|
2246
|
-
const name = element.getAttribute && element.getAttribute("name");
|
|
2247
|
-
if (name) return element.tagName.toLowerCase() + '[name="' + name + '"]';
|
|
2248
|
-
const title = element.getAttribute && element.getAttribute("title");
|
|
2249
|
-
if (title) return element.tagName.toLowerCase() + '[title="' + title + '"]';
|
|
2250
|
-
return element.tagName.toLowerCase();
|
|
2251
|
-
};
|
|
2252
|
-
const activeDocument = (() => {
|
|
2253
|
-
if (!state.currentFrame) return document;
|
|
2254
|
-
try {
|
|
2255
|
-
const frame = document.querySelector(state.currentFrame);
|
|
2256
|
-
return frame && frame.contentDocument ? frame.contentDocument : document;
|
|
2257
|
-
} catch {
|
|
2258
|
-
return document;
|
|
2259
|
-
}
|
|
2260
|
-
})();
|
|
2261
|
-
const queryOne = (selector, root = activeDocument) => {
|
|
2262
|
-
try {
|
|
2263
|
-
return root.querySelector(selector);
|
|
2264
|
-
} catch {
|
|
2265
|
-
throw new Error("Invalid selector " + selector);
|
|
2266
|
-
}
|
|
2267
|
-
};
|
|
2268
|
-
const findByText = (needle) => {
|
|
2269
|
-
const wanted = normalize(needle).toLowerCase();
|
|
2270
|
-
if (!wanted) return null;
|
|
2271
|
-
const candidates = Array.from(
|
|
2272
|
-
activeDocument.querySelectorAll(
|
|
2273
|
-
"a, button, input, textarea, select, option, label, h1, h2, h3, [role='button'], [data-testid]"
|
|
2274
|
-
)
|
|
2275
|
-
);
|
|
2276
|
-
return (
|
|
2277
|
-
candidates.find((element) => {
|
|
2278
|
-
const haystacks = [
|
|
2279
|
-
element.textContent,
|
|
2280
|
-
element.getAttribute("aria-label"),
|
|
2281
|
-
element.getAttribute("placeholder"),
|
|
2282
|
-
element.getAttribute("title"),
|
|
2283
|
-
element.getAttribute("name"),
|
|
2284
|
-
element.value
|
|
2285
|
-
]
|
|
2286
|
-
.map((value) => normalize(value).toLowerCase())
|
|
2287
|
-
.filter(Boolean);
|
|
2288
|
-
return haystacks.some((value) => value.includes(wanted));
|
|
2289
|
-
}) || null
|
|
2290
|
-
);
|
|
2291
|
-
};
|
|
2292
|
-
const resolveTarget = () => {
|
|
2293
|
-
if (command.selector) return queryOne(command.selector);
|
|
2294
|
-
if (command.text) return findByText(command.text);
|
|
2295
|
-
return activeDocument.activeElement || activeDocument.body;
|
|
2296
|
-
};
|
|
2297
|
-
const recordRequest = (request) => {
|
|
2298
|
-
const entry = {
|
|
2299
|
-
...request,
|
|
2300
|
-
id: "req_" + state.networkNextRequestId++,
|
|
2301
|
-
timestamp: new Date().toISOString()
|
|
2302
|
-
};
|
|
2303
|
-
state.networkRequests.push(entry);
|
|
2304
|
-
if (state.networkHar.active) state.networkHar.entries.push(entry);
|
|
2305
|
-
return entry;
|
|
2306
|
-
};
|
|
2307
|
-
if (!state.consoleWrapped) {
|
|
2308
|
-
for (const level of ["log", "info", "warn", "error"]) {
|
|
2309
|
-
console[level] = (...args) => {
|
|
2310
|
-
state.consoleEntries.push({
|
|
2311
|
-
level,
|
|
2312
|
-
message: args.map((value) => normalize(value)).join(" "),
|
|
2313
|
-
timestamp: new Date().toISOString()
|
|
2314
|
-
});
|
|
2315
|
-
};
|
|
2316
|
-
}
|
|
2317
|
-
state.consoleWrapped = true;
|
|
2318
|
-
}
|
|
2319
|
-
if (!state.dialogWrapped) {
|
|
2320
|
-
window.alert = (message) => {
|
|
2321
|
-
state.dialog = { defaultValue: null, message: String(message ?? ""), open: true, type: "alert" };
|
|
2322
|
-
};
|
|
2323
|
-
window.confirm = (message) => {
|
|
2324
|
-
state.dialog = { defaultValue: null, message: String(message ?? ""), open: true, type: "confirm" };
|
|
2325
|
-
return false;
|
|
2326
|
-
};
|
|
2327
|
-
window.prompt = (message, defaultValue) => {
|
|
2328
|
-
state.dialog = {
|
|
2329
|
-
defaultValue: defaultValue ?? null,
|
|
2330
|
-
message: String(message ?? ""),
|
|
2331
|
-
open: true,
|
|
2332
|
-
type: "prompt"
|
|
2333
|
-
};
|
|
2334
|
-
return null;
|
|
2335
|
-
};
|
|
2336
|
-
state.dialogWrapped = true;
|
|
2337
|
-
}
|
|
2338
|
-
if (!state.fetchWrapped) {
|
|
2339
|
-
state.originalFetch = window.fetch ? window.fetch.bind(window) : null;
|
|
2340
|
-
window.fetch = async (input, init = {}) => {
|
|
2341
|
-
const inputUrl =
|
|
2342
|
-
typeof input === "string"
|
|
2343
|
-
? input
|
|
2344
|
-
: input instanceof URL
|
|
2345
|
-
? input.toString()
|
|
2346
|
-
: typeof input?.url === "string"
|
|
2347
|
-
? input.url
|
|
2348
|
-
: String(input);
|
|
2349
|
-
const url = new URL(inputUrl, location.href).toString();
|
|
2350
|
-
if (state.settings.offline) {
|
|
2351
|
-
recordRequest({
|
|
2352
|
-
matchedRoute: null,
|
|
2353
|
-
method: String(init.method || "GET").toUpperCase(),
|
|
2354
|
-
resourceType: "fetch",
|
|
2355
|
-
responseBody: null,
|
|
2356
|
-
responseHeaders: {},
|
|
2357
|
-
status: 0,
|
|
2358
|
-
url
|
|
2359
|
-
});
|
|
2360
|
-
throw new Error("Browser workspace is offline.");
|
|
2361
|
-
}
|
|
2362
|
-
const route = [...state.networkRoutes].reverse().find((entry) => patternMatches(entry.pattern, url)) || null;
|
|
2363
|
-
if (route && route.abort) {
|
|
2364
|
-
recordRequest({
|
|
2365
|
-
matchedRoute: route.pattern,
|
|
2366
|
-
method: String(init.method || "GET").toUpperCase(),
|
|
2367
|
-
resourceType: "fetch",
|
|
2368
|
-
responseBody: null,
|
|
2369
|
-
responseHeaders: route.headers || {},
|
|
2370
|
-
status: 0,
|
|
2371
|
-
url
|
|
2372
|
-
});
|
|
2373
|
-
throw new Error("Browser workspace network route aborted request: " + url);
|
|
2374
|
-
}
|
|
2375
|
-
if (route && (route.body !== null || route.status !== null || Object.keys(route.headers || {}).length > 0)) {
|
|
2376
|
-
const response = new Response(route.body || "", {
|
|
2377
|
-
headers: route.headers || {},
|
|
2378
|
-
status: route.status || 200
|
|
2379
|
-
});
|
|
2380
|
-
recordRequest({
|
|
2381
|
-
matchedRoute: route.pattern,
|
|
2382
|
-
method: String(init.method || "GET").toUpperCase(),
|
|
2383
|
-
resourceType: "fetch",
|
|
2384
|
-
responseBody: route.body || "",
|
|
2385
|
-
responseHeaders: route.headers || {},
|
|
2386
|
-
status: route.status || 200,
|
|
2387
|
-
url
|
|
2388
|
-
});
|
|
2389
|
-
return response;
|
|
2390
|
-
}
|
|
2391
|
-
const headers = new Headers(init.headers || {});
|
|
2392
|
-
for (const [key, value] of Object.entries(state.settings.headers || {})) {
|
|
2393
|
-
if (!headers.has(key)) headers.set(key, value);
|
|
2394
|
-
}
|
|
2395
|
-
if (state.settings.credentials && state.settings.credentials.username && !headers.has("Authorization")) {
|
|
2396
|
-
headers.set(
|
|
2397
|
-
"Authorization",
|
|
2398
|
-
"Basic " + btoa(state.settings.credentials.username + ":" + state.settings.credentials.password)
|
|
2399
|
-
);
|
|
2400
|
-
}
|
|
2401
|
-
const response = await state.originalFetch(url, { ...init, headers });
|
|
2402
|
-
recordRequest({
|
|
2403
|
-
matchedRoute: null,
|
|
2404
|
-
method: String(init.method || "GET").toUpperCase(),
|
|
2405
|
-
resourceType: "fetch",
|
|
2406
|
-
responseBody: null,
|
|
2407
|
-
responseHeaders: Object.fromEntries(response.headers.entries()),
|
|
2408
|
-
status: response.status,
|
|
2409
|
-
url: response.url || url
|
|
2410
|
-
});
|
|
2411
|
-
return response;
|
|
2412
|
-
};
|
|
2413
|
-
state.fetchWrapped = true;
|
|
2414
|
-
}
|
|
2415
|
-
Object.defineProperty(navigator, "onLine", {
|
|
2416
|
-
configurable: true,
|
|
2417
|
-
get: () => !state.settings.offline
|
|
2418
|
-
});
|
|
2419
|
-
switch (command.subaction) {
|
|
2420
|
-
case "clipboard": {
|
|
2421
|
-
const action = command.clipboardAction || "read";
|
|
2422
|
-
if (action === "read") return state.clipboardText;
|
|
2423
|
-
if (action === "write") {
|
|
2424
|
-
state.clipboardText = command.value || command.text || "";
|
|
2425
|
-
return state.clipboardText;
|
|
2426
|
-
}
|
|
2427
|
-
if (action === "copy") {
|
|
2428
|
-
const target = resolveTarget();
|
|
2429
|
-
state.clipboardText =
|
|
2430
|
-
target && typeof target.value === "string"
|
|
2431
|
-
? String(target.value || "")
|
|
2432
|
-
: normalize(target?.textContent || activeDocument.body?.textContent);
|
|
2433
|
-
return state.clipboardText;
|
|
2434
|
-
}
|
|
2435
|
-
const target = resolveTarget();
|
|
2436
|
-
if (target && typeof target.value === "string") {
|
|
2437
|
-
target.value = String(target.value || "") + state.clipboardText;
|
|
2438
|
-
target.setAttribute("value", target.value);
|
|
2439
|
-
return { selector: buildSelector(target), value: target.value };
|
|
2440
|
-
}
|
|
2441
|
-
return state.clipboardText;
|
|
2442
|
-
}
|
|
2443
|
-
case "mouse": {
|
|
2444
|
-
const action = command.mouseAction || "move";
|
|
2445
|
-
if (action === "move") {
|
|
2446
|
-
state.mouse.x = typeof command.x === "number" ? command.x : state.mouse.x;
|
|
2447
|
-
state.mouse.y = typeof command.y === "number" ? command.y : state.mouse.y;
|
|
2448
|
-
return state.mouse;
|
|
2449
|
-
}
|
|
2450
|
-
if (action === "down") {
|
|
2451
|
-
const button = command.button || "left";
|
|
2452
|
-
state.mouse.buttons = Array.from(new Set([...(state.mouse.buttons || []), button]));
|
|
2453
|
-
return state.mouse;
|
|
2454
|
-
}
|
|
2455
|
-
if (action === "up") {
|
|
2456
|
-
const button = command.button || "left";
|
|
2457
|
-
state.mouse.buttons = (state.mouse.buttons || []).filter((entry) => entry !== button);
|
|
2458
|
-
return state.mouse;
|
|
2459
|
-
}
|
|
2460
|
-
window.scrollBy(command.deltaX || 0, command.deltaY || command.pixels || 240);
|
|
2461
|
-
return { axis: Math.abs(command.deltaY || 0) >= Math.abs(command.deltaX || 0) ? "y" : "x", value: window.scrollY };
|
|
2462
|
-
}
|
|
2463
|
-
case "drag": {
|
|
2464
|
-
const source = resolveTarget();
|
|
2465
|
-
const target = command.value ? queryOne(command.value) : null;
|
|
2466
|
-
if (!source || !target) throw new Error("Eliza browser workspace drag requires source selector and target selector in value.");
|
|
2467
|
-
source.setAttribute("data-eliza-dragging", "true");
|
|
2468
|
-
target.setAttribute("data-eliza-drop-target", "true");
|
|
2469
|
-
return { source: buildSelector(source), target: buildSelector(target) };
|
|
2470
|
-
}
|
|
2471
|
-
case "upload": {
|
|
2472
|
-
const target = resolveTarget();
|
|
2473
|
-
if (!target || target.tagName !== "INPUT") throw new Error("Eliza browser workspace upload requires a file input target.");
|
|
2474
|
-
const files = Array.isArray(command.files) ? command.files.map((entry) => String(entry).split(/[\\\\/]/).pop()) : [];
|
|
2475
|
-
target.setAttribute("data-eliza-uploaded-files", files.join(","));
|
|
2476
|
-
return { files, selector: buildSelector(target) };
|
|
2477
|
-
}
|
|
2478
|
-
case "set": {
|
|
2479
|
-
const action = command.setAction || "viewport";
|
|
2480
|
-
if (action === "viewport") {
|
|
2481
|
-
state.settings.viewport = { width: command.width || 1280, height: command.height || 720, scale: command.scale || 1 };
|
|
2482
|
-
} else if (action === "device") {
|
|
2483
|
-
state.settings.device = command.device || null;
|
|
2484
|
-
} else if (action === "geo") {
|
|
2485
|
-
state.settings.geo =
|
|
2486
|
-
typeof command.latitude === "number" && typeof command.longitude === "number"
|
|
2487
|
-
? { latitude: command.latitude, longitude: command.longitude }
|
|
2488
|
-
: null;
|
|
2489
|
-
} else if (action === "offline") {
|
|
2490
|
-
state.settings.offline = Boolean(command.offline);
|
|
2491
|
-
} else if (action === "headers") {
|
|
2492
|
-
state.settings.headers = command.headers || {};
|
|
2493
|
-
} else if (action === "credentials") {
|
|
2494
|
-
state.settings.credentials =
|
|
2495
|
-
command.username || command.password
|
|
2496
|
-
? { username: command.username || "", password: command.password || "" }
|
|
2497
|
-
: null;
|
|
2498
|
-
} else if (action === "media") {
|
|
2499
|
-
state.settings.media = command.media || null;
|
|
2500
|
-
}
|
|
2501
|
-
return state.settings;
|
|
2502
|
-
}
|
|
2503
|
-
case "cookies": {
|
|
2504
|
-
const action = command.cookieAction || "get";
|
|
2505
|
-
if (action === "clear") {
|
|
2506
|
-
const current = document.cookie || "";
|
|
2507
|
-
current.split(/;\\s*/).forEach((entry) => {
|
|
2508
|
-
const name = entry.split("=")[0];
|
|
2509
|
-
if (name) document.cookie = name + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/";
|
|
2510
|
-
});
|
|
2511
|
-
return { cleared: true };
|
|
2512
|
-
}
|
|
2513
|
-
if (action === "set") {
|
|
2514
|
-
const name = command.name || command.entryKey;
|
|
2515
|
-
if (!name) throw new Error("Eliza browser workspace cookies set requires name.");
|
|
2516
|
-
document.cookie = name + "=" + (command.value || "") + "; path=/";
|
|
2517
|
-
}
|
|
2518
|
-
const cookieString = document.cookie || "";
|
|
2519
|
-
return Object.fromEntries(
|
|
2520
|
-
cookieString
|
|
2521
|
-
.split(/;\\s*/)
|
|
2522
|
-
.filter(Boolean)
|
|
2523
|
-
.map((entry) => {
|
|
2524
|
-
const [name, ...rest] = entry.split("=");
|
|
2525
|
-
return [name, rest.join("=")];
|
|
2526
|
-
})
|
|
2527
|
-
);
|
|
2528
|
-
}
|
|
2529
|
-
case "storage": {
|
|
2530
|
-
const storage = command.storageArea === "session" ? sessionStorage : localStorage;
|
|
2531
|
-
const action = command.storageAction || "get";
|
|
2532
|
-
if (action === "clear") {
|
|
2533
|
-
storage.clear();
|
|
2534
|
-
return { cleared: true };
|
|
2535
|
-
}
|
|
2536
|
-
if (action === "set") {
|
|
2537
|
-
const key = command.entryKey || command.name;
|
|
2538
|
-
if (!key) throw new Error("Eliza browser workspace storage set requires entryKey.");
|
|
2539
|
-
storage.setItem(key, command.value || "");
|
|
2540
|
-
}
|
|
2541
|
-
if (command.entryKey || command.name) {
|
|
2542
|
-
return storage.getItem(command.entryKey || command.name);
|
|
2543
|
-
}
|
|
2544
|
-
const out = {};
|
|
2545
|
-
for (let i = 0; i < storage.length; i += 1) {
|
|
2546
|
-
const key = storage.key(i);
|
|
2547
|
-
if (key) out[key] = storage.getItem(key) || "";
|
|
2548
|
-
}
|
|
2549
|
-
return out;
|
|
2550
|
-
}
|
|
2551
|
-
case "network": {
|
|
2552
|
-
const action = command.networkAction || "requests";
|
|
2553
|
-
if (action === "route") {
|
|
2554
|
-
if (!command.url) throw new Error("Eliza browser workspace network route requires url pattern.");
|
|
2555
|
-
state.networkRoutes.push({
|
|
2556
|
-
abort: Boolean(command.offline),
|
|
2557
|
-
body: command.responseBody ?? null,
|
|
2558
|
-
headers: command.responseHeaders || {},
|
|
2559
|
-
pattern: command.url,
|
|
2560
|
-
status: typeof command.responseStatus === "number" ? command.responseStatus : null
|
|
2561
|
-
});
|
|
2562
|
-
return state.networkRoutes;
|
|
2563
|
-
}
|
|
2564
|
-
if (action === "unroute") {
|
|
2565
|
-
state.networkRoutes = command.url
|
|
2566
|
-
? state.networkRoutes.filter((entry) => entry.pattern !== command.url)
|
|
2567
|
-
: [];
|
|
2568
|
-
return state.networkRoutes;
|
|
2569
|
-
}
|
|
2570
|
-
if (action === "request") {
|
|
2571
|
-
return state.networkRequests.find((entry) => entry.id === command.requestId) || null;
|
|
2572
|
-
}
|
|
2573
|
-
if (action === "harstart") {
|
|
2574
|
-
state.networkHar = { active: true, entries: [], startedAt: new Date().toISOString() };
|
|
2575
|
-
return state.networkHar;
|
|
2576
|
-
}
|
|
2577
|
-
if (action === "harstop") {
|
|
2578
|
-
state.networkHar.active = false;
|
|
2579
|
-
return { log: { entries: state.networkHar.entries, startedAt: state.networkHar.startedAt } };
|
|
2580
|
-
}
|
|
2581
|
-
let requests = [...state.networkRequests];
|
|
2582
|
-
if (command.filter) requests = requests.filter((entry) => entry.url.includes(command.filter));
|
|
2583
|
-
if (command.method) requests = requests.filter((entry) => entry.method === String(command.method).toUpperCase());
|
|
2584
|
-
if (command.status) requests = requests.filter((entry) => String(entry.status || "") === String(command.status));
|
|
2585
|
-
return requests;
|
|
2586
|
-
}
|
|
2587
|
-
case "dialog": {
|
|
2588
|
-
const action = command.dialogAction || "status";
|
|
2589
|
-
if (action === "status") return state.dialog;
|
|
2590
|
-
if (state.dialog) state.dialog.open = false;
|
|
2591
|
-
const result =
|
|
2592
|
-
action === "accept"
|
|
2593
|
-
? { accepted: true, dialog: state.dialog, promptText: command.promptText || command.value || null }
|
|
2594
|
-
: { accepted: false, dialog: state.dialog };
|
|
2595
|
-
state.dialog = null;
|
|
2596
|
-
return result;
|
|
2597
|
-
}
|
|
2598
|
-
case "console":
|
|
2599
|
-
if (command.consoleAction === "clear") state.consoleEntries = [];
|
|
2600
|
-
return state.consoleEntries;
|
|
2601
|
-
case "errors":
|
|
2602
|
-
if (command.consoleAction === "clear") state.errors = [];
|
|
2603
|
-
return state.errors;
|
|
2604
|
-
case "highlight": {
|
|
2605
|
-
const target = resolveTarget();
|
|
2606
|
-
if (!target) throw new Error("Target element was not found.");
|
|
2607
|
-
target.setAttribute("data-eliza-highlight", "true");
|
|
2608
|
-
state.highlightedSelector = buildSelector(target);
|
|
2609
|
-
return { selector: state.highlightedSelector };
|
|
2610
|
-
}
|
|
2611
|
-
case "frame": {
|
|
2612
|
-
if ((command.frameAction || "select") === "main") {
|
|
2613
|
-
state.currentFrame = null;
|
|
2614
|
-
return { frame: null };
|
|
2615
|
-
}
|
|
2616
|
-
const frame = command.selector ? document.querySelector(command.selector) : null;
|
|
2617
|
-
if (!frame || frame.tagName !== "IFRAME") throw new Error("Eliza browser workspace frame select requires an iframe selector.");
|
|
2618
|
-
state.currentFrame = buildSelector(frame);
|
|
2619
|
-
return { frame: state.currentFrame };
|
|
2620
|
-
}
|
|
2621
|
-
default:
|
|
2622
|
-
throw new Error("Unsupported desktop browser workspace utility subaction: " + command.subaction);
|
|
2623
|
-
}
|
|
2624
|
-
})()
|
|
2625
|
-
`.trim();
|
|
2626
|
-
}
|
|
2627
|
-
async function executeDesktopBrowserWorkspaceUtilityCommand(command, env) {
|
|
2628
|
-
const id = await resolveDesktopBrowserWorkspaceTargetTabId(command, env);
|
|
2629
|
-
const startedAt = Date.now();
|
|
2630
|
-
const result = await evaluateBrowserWorkspaceTab({
|
|
2631
|
-
id,
|
|
2632
|
-
script: createDesktopBrowserWorkspaceUtilityScript({
|
|
2633
|
-
...command,
|
|
2634
|
-
id,
|
|
2635
|
-
}),
|
|
2636
|
-
}, env);
|
|
2637
|
-
const runtime = getBrowserWorkspaceRuntimeState("desktop", id);
|
|
2638
|
-
appendBrowserWorkspaceTraceEntry(runtime, {
|
|
2639
|
-
subaction: command.subaction,
|
|
2640
|
-
type: "utility",
|
|
2641
|
-
});
|
|
2642
|
-
appendBrowserWorkspaceProfilerEntry(runtime, {
|
|
2643
|
-
durationMs: Date.now() - startedAt,
|
|
2644
|
-
subaction: command.subaction,
|
|
2645
|
-
type: "utility",
|
|
2646
|
-
});
|
|
2647
|
-
return {
|
|
2648
|
-
mode: "desktop",
|
|
2649
|
-
subaction: command.subaction,
|
|
2650
|
-
value: result,
|
|
2651
|
-
};
|
|
2652
|
-
}
|
|
2653
|
-
async function getDesktopBrowserWorkspaceSnapshotRecord(command, env) {
|
|
2654
|
-
const id = await resolveDesktopBrowserWorkspaceTargetTabId(command, env);
|
|
2655
|
-
const result = await evaluateBrowserWorkspaceTab({
|
|
2656
|
-
id,
|
|
2657
|
-
script: `
|
|
2658
|
-
(() => {
|
|
2659
|
-
const activeDocument = (() => {
|
|
2660
|
-
const state = window.__elizaBrowserWorkspaceState || {};
|
|
2661
|
-
if (!state.currentFrame) return document;
|
|
2662
|
-
try {
|
|
2663
|
-
const frame = document.querySelector(state.currentFrame);
|
|
2664
|
-
return frame && frame.contentDocument ? frame.contentDocument : document;
|
|
2665
|
-
} catch {
|
|
2666
|
-
return document;
|
|
2667
|
-
}
|
|
2668
|
-
})();
|
|
2669
|
-
const normalize = (value) => String(value ?? "").replace(/\\s+/g, " ").trim();
|
|
2670
|
-
const controlText = Array.from(activeDocument.querySelectorAll("input, textarea, select, option:checked"))
|
|
2671
|
-
.map((element) => {
|
|
2672
|
-
const name = element.getAttribute("name") || element.getAttribute("id") || element.tagName.toLowerCase();
|
|
2673
|
-
const value =
|
|
2674
|
-
element.tagName === "SELECT"
|
|
2675
|
-
? element.value
|
|
2676
|
-
: typeof element.value === "string"
|
|
2677
|
-
? element.value
|
|
2678
|
-
: element.textContent || "";
|
|
2679
|
-
return name + ":" + normalize(value);
|
|
2680
|
-
})
|
|
2681
|
-
.filter(Boolean)
|
|
2682
|
-
.join(" ");
|
|
2683
|
-
return {
|
|
2684
|
-
bodyText: normalize((activeDocument.body?.textContent || "") + " " + controlText),
|
|
2685
|
-
title: normalize(document.title),
|
|
2686
|
-
url: location.href
|
|
2687
|
-
};
|
|
2688
|
-
})()
|
|
2689
|
-
`.trim(),
|
|
2690
|
-
}, env);
|
|
2691
|
-
return result;
|
|
2692
|
-
}
|
|
2693
|
-
async function getDesktopBrowserWorkspaceSessionState(command, env) {
|
|
2694
|
-
const id = await resolveDesktopBrowserWorkspaceTargetTabId(command, env);
|
|
2695
|
-
const result = await evaluateBrowserWorkspaceTab({
|
|
2696
|
-
id,
|
|
2697
|
-
script: `
|
|
2698
|
-
(() => {
|
|
2699
|
-
const state = window.__elizaBrowserWorkspaceState || {};
|
|
2700
|
-
const readStorage = (storage) => {
|
|
2701
|
-
const out = {};
|
|
2702
|
-
for (let i = 0; i < storage.length; i += 1) {
|
|
2703
|
-
const key = storage.key(i);
|
|
2704
|
-
if (key) out[key] = storage.getItem(key) || "";
|
|
2705
|
-
}
|
|
2706
|
-
return out;
|
|
2707
|
-
};
|
|
2708
|
-
const cookies = Object.fromEntries(
|
|
2709
|
-
String(document.cookie || "")
|
|
2710
|
-
.split(/;\\s*/)
|
|
2711
|
-
.filter(Boolean)
|
|
2712
|
-
.map((entry) => {
|
|
2713
|
-
const [name, ...rest] = entry.split("=");
|
|
2714
|
-
return [name, rest.join("=")];
|
|
2715
|
-
})
|
|
2716
|
-
);
|
|
2717
|
-
return {
|
|
2718
|
-
clipboard: state.clipboardText || "",
|
|
2719
|
-
cookies,
|
|
2720
|
-
localStorage: readStorage(localStorage),
|
|
2721
|
-
sessionStorage: readStorage(sessionStorage),
|
|
2722
|
-
settings: state.settings || {},
|
|
2723
|
-
url: location.href
|
|
2724
|
-
};
|
|
2725
|
-
})()
|
|
2726
|
-
`.trim(),
|
|
2727
|
-
}, env);
|
|
2728
|
-
return result;
|
|
2729
|
-
}
|
|
2730
|
-
async function loadDesktopBrowserWorkspaceSessionState(command, payload, env) {
|
|
2731
|
-
const id = await resolveDesktopBrowserWorkspaceTargetTabId(command, env);
|
|
2732
|
-
await evaluateBrowserWorkspaceTab({
|
|
2733
|
-
id,
|
|
2734
|
-
script: `
|
|
2735
|
-
(() => {
|
|
2736
|
-
const payload = ${JSON.stringify(payload)};
|
|
2737
|
-
const state =
|
|
2738
|
-
window.__elizaBrowserWorkspaceState ||
|
|
2739
|
-
(window.__elizaBrowserWorkspaceState = { settings: {} });
|
|
2740
|
-
localStorage.clear();
|
|
2741
|
-
for (const [key, value] of Object.entries(payload.localStorage || {})) {
|
|
2742
|
-
localStorage.setItem(key, String(value ?? ""));
|
|
2743
|
-
}
|
|
2744
|
-
sessionStorage.clear();
|
|
2745
|
-
for (const [key, value] of Object.entries(payload.sessionStorage || {})) {
|
|
2746
|
-
sessionStorage.setItem(key, String(value ?? ""));
|
|
2747
|
-
}
|
|
2748
|
-
for (const [key, value] of Object.entries(payload.cookies || {})) {
|
|
2749
|
-
document.cookie = key + "=" + String(value ?? "") + "; path=/";
|
|
2750
|
-
}
|
|
2751
|
-
state.clipboardText = typeof payload.clipboard === "string" ? payload.clipboard : "";
|
|
2752
|
-
state.settings = typeof payload.settings === "object" && payload.settings ? payload.settings : state.settings;
|
|
2753
|
-
return { loaded: true };
|
|
2754
|
-
})()
|
|
2755
|
-
`.trim(),
|
|
2756
|
-
}, env);
|
|
2757
|
-
}
|
|
2758
|
-
async function executeDesktopBrowserWorkspaceDomCommand(command, env) {
|
|
2759
|
-
const id = await resolveDesktopBrowserWorkspaceTargetTabId(command, env);
|
|
2760
|
-
const startedAt = Date.now();
|
|
2761
|
-
command = resolveBrowserWorkspaceCommandElementRefs(command, "desktop", id);
|
|
2762
|
-
const result = await evaluateBrowserWorkspaceTab({
|
|
2763
|
-
id,
|
|
2764
|
-
script: createDesktopBrowserWorkspaceCommandScript({
|
|
2765
|
-
...command,
|
|
2766
|
-
id,
|
|
2767
|
-
}),
|
|
2768
|
-
}, env);
|
|
2769
|
-
if (command.subaction === "inspect" || command.subaction === "snapshot") {
|
|
2770
|
-
const value = result && typeof result === "object" && !Array.isArray(result)
|
|
2771
|
-
? result
|
|
2772
|
-
: null;
|
|
2773
|
-
const elements = registerBrowserWorkspaceElementRefs("desktop", id, Array.isArray(value?.elements) ? value.elements : []);
|
|
2774
|
-
return {
|
|
2775
|
-
mode: "desktop",
|
|
2776
|
-
subaction: command.subaction,
|
|
2777
|
-
elements,
|
|
2778
|
-
value: result,
|
|
2779
|
-
};
|
|
2780
|
-
}
|
|
2781
|
-
const runtime = getBrowserWorkspaceRuntimeState("desktop", id);
|
|
2782
|
-
appendBrowserWorkspaceTraceEntry(runtime, {
|
|
2783
|
-
subaction: command.subaction,
|
|
2784
|
-
type: "dom",
|
|
2785
|
-
});
|
|
2786
|
-
appendBrowserWorkspaceProfilerEntry(runtime, {
|
|
2787
|
-
durationMs: Date.now() - startedAt,
|
|
2788
|
-
subaction: command.subaction,
|
|
2789
|
-
type: "dom",
|
|
2790
|
-
});
|
|
2791
|
-
return {
|
|
2792
|
-
mode: "desktop",
|
|
2793
|
-
subaction: command.subaction,
|
|
2794
|
-
value: result && typeof result === "object" && !Array.isArray(result)
|
|
2795
|
-
? (result.value ?? result)
|
|
2796
|
-
: result,
|
|
2797
|
-
};
|
|
2798
|
-
}
|
|
2799
|
-
async function sleep(ms) {
|
|
2800
|
-
await new Promise((resolve) => setTimeout(resolve, ms));
|
|
2801
|
-
}
|
|
2802
|
-
async function submitWebBrowserWorkspaceForm(tab, form) {
|
|
2803
|
-
const state = getBrowserWorkspaceRuntimeState("web", tab.id);
|
|
2804
|
-
const dom = ensureBrowserWorkspaceDom(tab);
|
|
2805
|
-
const action = form.getAttribute("action")?.trim() || tab.url;
|
|
2806
|
-
const method = (form.getAttribute("method")?.trim() || "get").toLowerCase();
|
|
2807
|
-
const submitUrl = new URL(action, tab.url).toString();
|
|
2808
|
-
const formData = new dom.window.FormData(form);
|
|
2809
|
-
const searchParams = new URLSearchParams();
|
|
2810
|
-
for (const [key, value] of formData.entries()) {
|
|
2811
|
-
searchParams.append(key, String(value));
|
|
2812
|
-
}
|
|
2813
|
-
if (method === "get") {
|
|
2814
|
-
const nextUrl = new URL(submitUrl);
|
|
2815
|
-
nextUrl.search = searchParams.toString();
|
|
2816
|
-
clearWebBrowserWorkspaceTabElementRefs(tab.id);
|
|
2817
|
-
tab.url = nextUrl.toString();
|
|
2818
|
-
tab.title = inferBrowserWorkspaceTitle(tab.url);
|
|
2819
|
-
tab.dom = null;
|
|
2820
|
-
tab.loadedUrl = null;
|
|
2821
|
-
pushWebBrowserWorkspaceHistory(tab, tab.url);
|
|
2822
|
-
await loadWebBrowserWorkspaceTabDocument(tab);
|
|
2823
|
-
return;
|
|
2824
|
-
}
|
|
2825
|
-
const response = await fetchBrowserWorkspaceTrackedResponse(state, submitUrl, {
|
|
2826
|
-
body: searchParams.toString(),
|
|
2827
|
-
headers: {
|
|
2828
|
-
"Content-Type": "application/x-www-form-urlencoded; charset=utf-8",
|
|
2829
|
-
},
|
|
2830
|
-
method: method.toUpperCase(),
|
|
2831
|
-
}, "document");
|
|
2832
|
-
if (!response.ok) {
|
|
2833
|
-
throw new Error(`Browser workspace form submit failed (${response.status}): ${submitUrl}`);
|
|
2834
|
-
}
|
|
2835
|
-
const html = await response.text();
|
|
2836
|
-
const finalUrl = assertBrowserWorkspaceUrl(response.url?.trim() || submitUrl);
|
|
2837
|
-
const nextDom = new (getJSDOMClass())(html, {
|
|
2838
|
-
pretendToBeVisual: true,
|
|
2839
|
-
url: finalUrl,
|
|
2840
|
-
});
|
|
2841
|
-
installBrowserWorkspaceWebRuntime(tab, nextDom);
|
|
2842
|
-
resetBrowserWorkspaceRuntimeNavigationState(state);
|
|
2843
|
-
clearWebBrowserWorkspaceTabElementRefs(tab.id);
|
|
2844
|
-
tab.url = finalUrl;
|
|
2845
|
-
tab.dom = nextDom;
|
|
2846
|
-
tab.loadedUrl = finalUrl;
|
|
2847
|
-
tab.title =
|
|
2848
|
-
normalizeBrowserWorkspaceText(nextDom.window.document.title) ||
|
|
2849
|
-
inferBrowserWorkspaceTitle(finalUrl);
|
|
2850
|
-
tab.updatedAt = getBrowserWorkspaceTimestamp();
|
|
2851
|
-
pushWebBrowserWorkspaceHistory(tab, finalUrl);
|
|
2852
|
-
}
|
|
2853
|
-
function readBrowserWorkspaceStorage(storage) {
|
|
2854
|
-
const entries = {};
|
|
2855
|
-
for (let index = 0; index < storage.length; index += 1) {
|
|
2856
|
-
const key = storage.key(index);
|
|
2857
|
-
if (!key) {
|
|
2858
|
-
continue;
|
|
2859
|
-
}
|
|
2860
|
-
entries[key] = storage.getItem(key) ?? "";
|
|
2861
|
-
}
|
|
2862
|
-
return entries;
|
|
2863
|
-
}
|
|
2864
|
-
function readBrowserWorkspaceCookies(document) {
|
|
2865
|
-
const cookieString = document.cookie || "";
|
|
2866
|
-
if (!cookieString.trim()) {
|
|
2867
|
-
return {};
|
|
2868
|
-
}
|
|
2869
|
-
return Object.fromEntries(cookieString
|
|
2870
|
-
.split(/;\s*/)
|
|
2871
|
-
.map((entry) => {
|
|
2872
|
-
const [name, ...rest] = entry.split("=");
|
|
2873
|
-
return [name ?? "", rest.join("=")];
|
|
2874
|
-
})
|
|
2875
|
-
.filter((entry) => entry[0].trim().length > 0));
|
|
2876
|
-
}
|
|
2877
|
-
function applyBrowserWorkspaceStateToWebDocument(document, snapshot) {
|
|
2878
|
-
const localEntries = snapshot.localStorage && typeof snapshot.localStorage === "object"
|
|
2879
|
-
? snapshot.localStorage
|
|
2880
|
-
: {};
|
|
2881
|
-
const sessionEntries = snapshot.sessionStorage && typeof snapshot.sessionStorage === "object"
|
|
2882
|
-
? snapshot.sessionStorage
|
|
2883
|
-
: {};
|
|
2884
|
-
const cookies = snapshot.cookies && typeof snapshot.cookies === "object"
|
|
2885
|
-
? snapshot.cookies
|
|
2886
|
-
: {};
|
|
2887
|
-
document.defaultView?.localStorage.clear();
|
|
2888
|
-
for (const [key, value] of Object.entries(localEntries)) {
|
|
2889
|
-
document.defaultView?.localStorage.setItem(key, String(value ?? ""));
|
|
2890
|
-
}
|
|
2891
|
-
document.defaultView?.sessionStorage.clear();
|
|
2892
|
-
for (const [key, value] of Object.entries(sessionEntries)) {
|
|
2893
|
-
document.defaultView?.sessionStorage.setItem(key, String(value ?? ""));
|
|
2894
|
-
}
|
|
2895
|
-
for (const [key, value] of Object.entries(cookies)) {
|
|
2896
|
-
document.cookie = `${key}=${String(value ?? "")}; path=/`;
|
|
2897
|
-
}
|
|
2898
|
-
}
|
|
2899
|
-
async function executeWebBrowserWorkspaceUtilityCommand(command) {
|
|
2900
|
-
return withWebStateLock(async () => {
|
|
2901
|
-
if (![
|
|
2902
|
-
"clipboard",
|
|
2903
|
-
"console",
|
|
2904
|
-
"cookies",
|
|
2905
|
-
"diff",
|
|
2906
|
-
"dialog",
|
|
2907
|
-
"drag",
|
|
2908
|
-
"errors",
|
|
2909
|
-
"eval",
|
|
2910
|
-
"frame",
|
|
2911
|
-
"highlight",
|
|
2912
|
-
"mouse",
|
|
2913
|
-
"network",
|
|
2914
|
-
"pdf",
|
|
2915
|
-
"screenshot",
|
|
2916
|
-
"set",
|
|
2917
|
-
"state",
|
|
2918
|
-
"storage",
|
|
2919
|
-
"trace",
|
|
2920
|
-
"profiler",
|
|
2921
|
-
"upload",
|
|
2922
|
-
].includes(command.subaction)) {
|
|
2923
|
-
return null;
|
|
2924
|
-
}
|
|
2925
|
-
const id = findWebBrowserWorkspaceTargetTabId(command);
|
|
2926
|
-
const tab = getWebBrowserWorkspaceTabState(id);
|
|
2927
|
-
const dom = await ensureLoadedWebBrowserWorkspaceTabDocument(tab);
|
|
2928
|
-
const runtime = getBrowserWorkspaceRuntimeState("web", id);
|
|
2929
|
-
const frameContext = resolveWebBrowserWorkspaceCommandDocument(tab, dom);
|
|
2930
|
-
const document = frameContext.document;
|
|
2931
|
-
const resolveTarget = () => resolveBrowserWorkspaceElement(document, command.selector, command.text, command);
|
|
2932
|
-
switch (command.subaction) {
|
|
2933
|
-
case "eval": {
|
|
2934
|
-
if (!command.script?.trim()) {
|
|
2935
|
-
throw new Error("Eliza browser workspace eval requires script.");
|
|
2936
|
-
}
|
|
2937
|
-
try {
|
|
2938
|
-
let value;
|
|
2939
|
-
try {
|
|
2940
|
-
value = new Function("document", "fetch", "alert", "confirm", "prompt", "window", "location", "navigator", "localStorage", "sessionStorage", "console", `return (${command.script});`)(document, dom.window.fetch.bind(dom.window), dom.window.alert.bind(dom.window), dom.window.confirm.bind(dom.window), dom.window.prompt.bind(dom.window), dom.window, dom.window.location, dom.window.navigator, dom.window.localStorage, dom.window.sessionStorage, dom.window.console);
|
|
2941
|
-
}
|
|
2942
|
-
catch {
|
|
2943
|
-
value = new Function("document", "fetch", "alert", "confirm", "prompt", "window", "location", "navigator", "localStorage", "sessionStorage", "console", command.script)(document, dom.window.fetch.bind(dom.window), dom.window.alert.bind(dom.window), dom.window.confirm.bind(dom.window), dom.window.prompt.bind(dom.window), dom.window, dom.window.location, dom.window.navigator, dom.window.localStorage, dom.window.sessionStorage, dom.window.console);
|
|
2944
|
-
}
|
|
2945
|
-
if (value &&
|
|
2946
|
-
typeof value === "object" &&
|
|
2947
|
-
typeof value.then === "function") {
|
|
2948
|
-
value = await value;
|
|
2949
|
-
}
|
|
2950
|
-
return { mode: "web", subaction: command.subaction, value };
|
|
2951
|
-
}
|
|
2952
|
-
catch (error) {
|
|
2953
|
-
runtime.errors.push({
|
|
2954
|
-
message: error instanceof Error ? error.message : String(error),
|
|
2955
|
-
stack: error instanceof Error ? (error.stack ?? null) : null,
|
|
2956
|
-
timestamp: getBrowserWorkspaceTimestamp(),
|
|
2957
|
-
});
|
|
2958
|
-
throw error;
|
|
2959
|
-
}
|
|
2960
|
-
}
|
|
2961
|
-
case "screenshot": {
|
|
2962
|
-
const data = createBrowserWorkspaceSyntheticScreenshotData(tab.title, tab.url, buildBrowserWorkspaceDocumentSnapshotText(document), runtime.settings.viewport ?? undefined);
|
|
2963
|
-
runtime.lastScreenshotData = data;
|
|
2964
|
-
if (command.filePath?.trim() || command.outputPath?.trim()) {
|
|
2965
|
-
const targetPath = command.filePath?.trim() || command.outputPath?.trim() || "";
|
|
2966
|
-
await writeBrowserWorkspaceFile(targetPath, Buffer.from(data, "base64"));
|
|
2967
|
-
return {
|
|
2968
|
-
mode: "web",
|
|
2969
|
-
subaction: command.subaction,
|
|
2970
|
-
snapshot: { data },
|
|
2971
|
-
value: { path: path.resolve(targetPath) },
|
|
2972
|
-
};
|
|
2973
|
-
}
|
|
2974
|
-
return {
|
|
2975
|
-
mode: "web",
|
|
2976
|
-
subaction: command.subaction,
|
|
2977
|
-
snapshot: { data },
|
|
2978
|
-
};
|
|
2979
|
-
}
|
|
2980
|
-
case "clipboard": {
|
|
2981
|
-
const action = command.clipboardAction ?? "read";
|
|
2982
|
-
if (action === "read") {
|
|
2983
|
-
return {
|
|
2984
|
-
mode: "web",
|
|
2985
|
-
subaction: command.subaction,
|
|
2986
|
-
value: browserWorkspaceClipboardText,
|
|
2987
|
-
};
|
|
2988
|
-
}
|
|
2989
|
-
if (action === "write") {
|
|
2990
|
-
browserWorkspaceClipboardText = command.value ?? command.text ?? "";
|
|
2991
|
-
return {
|
|
2992
|
-
mode: "web",
|
|
2993
|
-
subaction: command.subaction,
|
|
2994
|
-
value: browserWorkspaceClipboardText,
|
|
2995
|
-
};
|
|
2996
|
-
}
|
|
2997
|
-
if (action === "copy") {
|
|
2998
|
-
const target = resolveTarget();
|
|
2999
|
-
browserWorkspaceClipboardText =
|
|
3000
|
-
target && "value" in target
|
|
3001
|
-
? String(target.value ?? "")
|
|
3002
|
-
: normalizeBrowserWorkspaceText(target?.textContent ?? document.body?.textContent);
|
|
3003
|
-
return {
|
|
3004
|
-
mode: "web",
|
|
3005
|
-
subaction: command.subaction,
|
|
3006
|
-
value: browserWorkspaceClipboardText,
|
|
3007
|
-
};
|
|
3008
|
-
}
|
|
3009
|
-
const target = resolveTarget() ?? document.activeElement;
|
|
3010
|
-
if (target &&
|
|
3011
|
-
(target.tagName === "INPUT" ||
|
|
3012
|
-
target.tagName === "TEXTAREA" ||
|
|
3013
|
-
target.tagName === "SELECT")) {
|
|
3014
|
-
const control = ensureBrowserWorkspaceFormControlElement(target, "clipboard");
|
|
3015
|
-
setBrowserWorkspaceControlValue(control, `${control.value ?? ""}${browserWorkspaceClipboardText}`);
|
|
3016
|
-
return {
|
|
3017
|
-
mode: "web",
|
|
3018
|
-
subaction: command.subaction,
|
|
3019
|
-
value: {
|
|
3020
|
-
selector: buildBrowserWorkspaceElementSelector(control),
|
|
3021
|
-
value: control.value,
|
|
3022
|
-
},
|
|
3023
|
-
};
|
|
3024
|
-
}
|
|
3025
|
-
return {
|
|
3026
|
-
mode: "web",
|
|
3027
|
-
subaction: command.subaction,
|
|
3028
|
-
value: browserWorkspaceClipboardText,
|
|
3029
|
-
};
|
|
3030
|
-
}
|
|
3031
|
-
case "mouse": {
|
|
3032
|
-
const action = command.mouseAction ?? "move";
|
|
3033
|
-
if (action === "move") {
|
|
3034
|
-
runtime.mouse.x = command.x ?? runtime.mouse.x;
|
|
3035
|
-
runtime.mouse.y = command.y ?? runtime.mouse.y;
|
|
3036
|
-
}
|
|
3037
|
-
else if (action === "down") {
|
|
3038
|
-
const button = command.button ?? "left";
|
|
3039
|
-
runtime.mouse.buttons = Array.from(new Set([...runtime.mouse.buttons, button]));
|
|
3040
|
-
}
|
|
3041
|
-
else if (action === "up") {
|
|
3042
|
-
const button = command.button ?? "left";
|
|
3043
|
-
runtime.mouse.buttons = runtime.mouse.buttons.filter((entry) => entry !== button);
|
|
3044
|
-
}
|
|
3045
|
-
else {
|
|
3046
|
-
return {
|
|
3047
|
-
mode: "web",
|
|
3048
|
-
subaction: command.subaction,
|
|
3049
|
-
value: scrollWebBrowserWorkspaceTarget(dom, resolveTarget(), (command.deltaY ?? 0) < 0 ? "up" : "down", Math.abs(command.deltaY ?? command.pixels ?? 240)),
|
|
3050
|
-
};
|
|
3051
|
-
}
|
|
3052
|
-
return {
|
|
3053
|
-
mode: "web",
|
|
3054
|
-
subaction: command.subaction,
|
|
3055
|
-
value: runtime.mouse,
|
|
3056
|
-
};
|
|
3057
|
-
}
|
|
3058
|
-
case "drag": {
|
|
3059
|
-
const source = resolveTarget();
|
|
3060
|
-
const target = command.value
|
|
3061
|
-
? resolveBrowserWorkspaceElement(document, command.value)
|
|
3062
|
-
: null;
|
|
3063
|
-
if (!source || !target) {
|
|
3064
|
-
throw new Error("Eliza browser workspace drag requires source selector and target selector in value.");
|
|
3065
|
-
}
|
|
3066
|
-
source.setAttribute("data-eliza-dragging", "true");
|
|
3067
|
-
target.setAttribute("data-eliza-drop-target", "true");
|
|
3068
|
-
return {
|
|
3069
|
-
mode: "web",
|
|
3070
|
-
subaction: command.subaction,
|
|
3071
|
-
value: {
|
|
3072
|
-
source: buildBrowserWorkspaceElementSelector(source),
|
|
3073
|
-
target: buildBrowserWorkspaceElementSelector(target),
|
|
3074
|
-
},
|
|
3075
|
-
};
|
|
3076
|
-
}
|
|
3077
|
-
case "upload": {
|
|
3078
|
-
const target = resolveTarget();
|
|
3079
|
-
if (!target || target.tagName !== "INPUT") {
|
|
3080
|
-
throw new Error("Eliza browser workspace upload requires a file input target.");
|
|
3081
|
-
}
|
|
3082
|
-
const files = (command.files ?? []).map((entry) => path.basename(entry));
|
|
3083
|
-
target.setAttribute("data-eliza-uploaded-files", files.join(","));
|
|
3084
|
-
return {
|
|
3085
|
-
mode: "web",
|
|
3086
|
-
subaction: command.subaction,
|
|
3087
|
-
value: {
|
|
3088
|
-
files,
|
|
3089
|
-
selector: buildBrowserWorkspaceElementSelector(target),
|
|
3090
|
-
},
|
|
3091
|
-
};
|
|
3092
|
-
}
|
|
3093
|
-
case "set": {
|
|
3094
|
-
const action = command.setAction ?? "viewport";
|
|
3095
|
-
if (action === "viewport") {
|
|
3096
|
-
runtime.settings.viewport = {
|
|
3097
|
-
height: Math.max(1, Math.round(command.height ?? 720)),
|
|
3098
|
-
scale: Math.max(1, Number(command.scale ?? 1)),
|
|
3099
|
-
width: Math.max(1, Math.round(command.width ?? 1280)),
|
|
3100
|
-
};
|
|
3101
|
-
}
|
|
3102
|
-
else if (action === "device") {
|
|
3103
|
-
runtime.settings.device = command.device ?? null;
|
|
3104
|
-
}
|
|
3105
|
-
else if (action === "geo") {
|
|
3106
|
-
runtime.settings.geo =
|
|
3107
|
-
typeof command.latitude === "number" &&
|
|
3108
|
-
typeof command.longitude === "number"
|
|
3109
|
-
? { latitude: command.latitude, longitude: command.longitude }
|
|
3110
|
-
: null;
|
|
3111
|
-
}
|
|
3112
|
-
else if (action === "offline") {
|
|
3113
|
-
runtime.settings.offline = Boolean(command.offline);
|
|
3114
|
-
}
|
|
3115
|
-
else if (action === "headers") {
|
|
3116
|
-
runtime.settings.headers = normalizeBrowserWorkspaceHeaders(command.headers);
|
|
3117
|
-
}
|
|
3118
|
-
else if (action === "credentials") {
|
|
3119
|
-
runtime.settings.credentials =
|
|
3120
|
-
command.username || command.password
|
|
3121
|
-
? {
|
|
3122
|
-
password: command.password ?? "",
|
|
3123
|
-
username: command.username ?? "",
|
|
3124
|
-
}
|
|
3125
|
-
: null;
|
|
3126
|
-
}
|
|
3127
|
-
else if (action === "media") {
|
|
3128
|
-
runtime.settings.media = command.media ?? null;
|
|
3129
|
-
}
|
|
3130
|
-
applyBrowserWorkspaceDomSettings(dom, runtime);
|
|
3131
|
-
return {
|
|
3132
|
-
mode: "web",
|
|
3133
|
-
subaction: command.subaction,
|
|
3134
|
-
value: runtime.settings,
|
|
3135
|
-
};
|
|
3136
|
-
}
|
|
3137
|
-
case "cookies": {
|
|
3138
|
-
const action = command.cookieAction ?? "get";
|
|
3139
|
-
if (action === "clear") {
|
|
3140
|
-
for (const key of Object.keys(readBrowserWorkspaceCookies(document))) {
|
|
3141
|
-
document.cookie = `${key}=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/`;
|
|
3142
|
-
}
|
|
3143
|
-
return {
|
|
3144
|
-
mode: "web",
|
|
3145
|
-
subaction: command.subaction,
|
|
3146
|
-
value: { cleared: true },
|
|
3147
|
-
};
|
|
3148
|
-
}
|
|
3149
|
-
if (action === "set") {
|
|
3150
|
-
const cookieName = command.name?.trim() || command.entryKey?.trim();
|
|
3151
|
-
if (!cookieName) {
|
|
3152
|
-
throw new Error("Eliza browser workspace cookies set requires name.");
|
|
3153
|
-
}
|
|
3154
|
-
document.cookie = `${cookieName}=${command.value ?? ""}; path=/`;
|
|
3155
|
-
}
|
|
3156
|
-
return {
|
|
3157
|
-
mode: "web",
|
|
3158
|
-
subaction: command.subaction,
|
|
3159
|
-
value: readBrowserWorkspaceCookies(document),
|
|
3160
|
-
};
|
|
3161
|
-
}
|
|
3162
|
-
case "storage": {
|
|
3163
|
-
const area = command.storageArea === "session"
|
|
3164
|
-
? dom.window.sessionStorage
|
|
3165
|
-
: dom.window.localStorage;
|
|
3166
|
-
const action = command.storageAction ?? "get";
|
|
3167
|
-
if (action === "clear") {
|
|
3168
|
-
area.clear();
|
|
3169
|
-
return {
|
|
3170
|
-
mode: "web",
|
|
3171
|
-
subaction: command.subaction,
|
|
3172
|
-
value: { cleared: true },
|
|
3173
|
-
};
|
|
3174
|
-
}
|
|
3175
|
-
if (action === "set") {
|
|
3176
|
-
const key = command.entryKey?.trim() || command.name?.trim();
|
|
3177
|
-
if (!key) {
|
|
3178
|
-
throw new Error("Eliza browser workspace storage set requires entryKey.");
|
|
3179
|
-
}
|
|
3180
|
-
area.setItem(key, command.value ?? "");
|
|
3181
|
-
}
|
|
3182
|
-
if (command.entryKey?.trim() || command.name?.trim()) {
|
|
3183
|
-
const key = command.entryKey?.trim() || command.name?.trim() || "";
|
|
3184
|
-
return {
|
|
3185
|
-
mode: "web",
|
|
3186
|
-
subaction: command.subaction,
|
|
3187
|
-
value: area.getItem(key),
|
|
3188
|
-
};
|
|
3189
|
-
}
|
|
3190
|
-
return {
|
|
3191
|
-
mode: "web",
|
|
3192
|
-
subaction: command.subaction,
|
|
3193
|
-
value: readBrowserWorkspaceStorage(area),
|
|
3194
|
-
};
|
|
3195
|
-
}
|
|
3196
|
-
case "network": {
|
|
3197
|
-
const action = command.networkAction ?? "requests";
|
|
3198
|
-
if (action === "route") {
|
|
3199
|
-
const pattern = command.url?.trim();
|
|
3200
|
-
if (!pattern) {
|
|
3201
|
-
throw new Error("Eliza browser workspace network route requires url pattern.");
|
|
3202
|
-
}
|
|
3203
|
-
runtime.networkRoutes.push({
|
|
3204
|
-
abort: Boolean(command.offline),
|
|
3205
|
-
body: command.responseBody ?? null,
|
|
3206
|
-
headers: normalizeBrowserWorkspaceHeaders(command.responseHeaders),
|
|
3207
|
-
pattern,
|
|
3208
|
-
status: typeof command.responseStatus === "number"
|
|
3209
|
-
? command.responseStatus
|
|
3210
|
-
: null,
|
|
3211
|
-
});
|
|
3212
|
-
return {
|
|
3213
|
-
mode: "web",
|
|
3214
|
-
subaction: command.subaction,
|
|
3215
|
-
value: runtime.networkRoutes,
|
|
3216
|
-
};
|
|
3217
|
-
}
|
|
3218
|
-
if (action === "unroute") {
|
|
3219
|
-
runtime.networkRoutes = command.url?.trim()
|
|
3220
|
-
? runtime.networkRoutes.filter((route) => route.pattern !== command.url?.trim())
|
|
3221
|
-
: [];
|
|
3222
|
-
return {
|
|
3223
|
-
mode: "web",
|
|
3224
|
-
subaction: command.subaction,
|
|
3225
|
-
value: runtime.networkRoutes,
|
|
3226
|
-
};
|
|
3227
|
-
}
|
|
3228
|
-
if (action === "request") {
|
|
3229
|
-
const request = runtime.networkRequests.find((entry) => entry.id === command.requestId);
|
|
3230
|
-
return {
|
|
3231
|
-
mode: "web",
|
|
3232
|
-
subaction: command.subaction,
|
|
3233
|
-
value: request ?? null,
|
|
3234
|
-
};
|
|
3235
|
-
}
|
|
3236
|
-
if (action === "harstart") {
|
|
3237
|
-
runtime.networkHar = {
|
|
3238
|
-
active: true,
|
|
3239
|
-
entries: [],
|
|
3240
|
-
startedAt: getBrowserWorkspaceTimestamp(),
|
|
3241
|
-
};
|
|
3242
|
-
return {
|
|
3243
|
-
mode: "web",
|
|
3244
|
-
subaction: command.subaction,
|
|
3245
|
-
value: runtime.networkHar,
|
|
3246
|
-
};
|
|
3247
|
-
}
|
|
3248
|
-
if (action === "harstop") {
|
|
3249
|
-
runtime.networkHar.active = false;
|
|
3250
|
-
const har = {
|
|
3251
|
-
log: {
|
|
3252
|
-
entries: runtime.networkHar.entries,
|
|
3253
|
-
startedAt: runtime.networkHar.startedAt,
|
|
3254
|
-
},
|
|
3255
|
-
};
|
|
3256
|
-
if (command.filePath?.trim() || command.outputPath?.trim()) {
|
|
3257
|
-
const targetPath = command.filePath?.trim() || command.outputPath?.trim() || "";
|
|
3258
|
-
await writeBrowserWorkspaceFile(targetPath, JSON.stringify(har, null, 2));
|
|
3259
|
-
return {
|
|
3260
|
-
mode: "web",
|
|
3261
|
-
subaction: command.subaction,
|
|
3262
|
-
value: { path: path.resolve(targetPath), ...har },
|
|
3263
|
-
};
|
|
3264
|
-
}
|
|
3265
|
-
return { mode: "web", subaction: command.subaction, value: har };
|
|
3266
|
-
}
|
|
3267
|
-
let requests = [...runtime.networkRequests];
|
|
3268
|
-
if (command.filter?.trim()) {
|
|
3269
|
-
requests = requests.filter((entry) => entry.url.includes(command.filter ?? ""));
|
|
3270
|
-
}
|
|
3271
|
-
if (command.method?.trim()) {
|
|
3272
|
-
requests = requests.filter((entry) => entry.method.toUpperCase() ===
|
|
3273
|
-
command.method?.trim().toUpperCase());
|
|
3274
|
-
}
|
|
3275
|
-
if (command.status?.trim()) {
|
|
3276
|
-
const statusFilter = command.status.trim();
|
|
3277
|
-
requests = requests.filter((entry) => {
|
|
3278
|
-
if (entry.status === null) {
|
|
3279
|
-
return false;
|
|
3280
|
-
}
|
|
3281
|
-
if (/^\dxx$/i.test(statusFilter)) {
|
|
3282
|
-
return String(entry.status).startsWith(statusFilter[0] ?? "");
|
|
3283
|
-
}
|
|
3284
|
-
return String(entry.status) === statusFilter;
|
|
3285
|
-
});
|
|
3286
|
-
}
|
|
3287
|
-
return { mode: "web", subaction: command.subaction, value: requests };
|
|
3288
|
-
}
|
|
3289
|
-
case "dialog": {
|
|
3290
|
-
const action = command.dialogAction ?? "status";
|
|
3291
|
-
if (action === "status") {
|
|
3292
|
-
return {
|
|
3293
|
-
mode: "web",
|
|
3294
|
-
subaction: command.subaction,
|
|
3295
|
-
value: runtime.dialog,
|
|
3296
|
-
};
|
|
3297
|
-
}
|
|
3298
|
-
if (runtime.dialog) {
|
|
3299
|
-
runtime.dialog.open = false;
|
|
3300
|
-
}
|
|
3301
|
-
const result = action === "accept"
|
|
3302
|
-
? {
|
|
3303
|
-
accepted: true,
|
|
3304
|
-
dialog: runtime.dialog,
|
|
3305
|
-
promptText: command.promptText ?? command.value ?? null,
|
|
3306
|
-
}
|
|
3307
|
-
: { accepted: false, dialog: runtime.dialog };
|
|
3308
|
-
runtime.dialog = null;
|
|
3309
|
-
return { mode: "web", subaction: command.subaction, value: result };
|
|
3310
|
-
}
|
|
3311
|
-
case "console": {
|
|
3312
|
-
if (command.consoleAction === "clear") {
|
|
3313
|
-
runtime.consoleEntries = [];
|
|
3314
|
-
}
|
|
3315
|
-
return {
|
|
3316
|
-
mode: "web",
|
|
3317
|
-
subaction: command.subaction,
|
|
3318
|
-
value: runtime.consoleEntries,
|
|
3319
|
-
};
|
|
3320
|
-
}
|
|
3321
|
-
case "errors": {
|
|
3322
|
-
if (command.consoleAction === "clear") {
|
|
3323
|
-
runtime.errors = [];
|
|
3324
|
-
}
|
|
3325
|
-
return {
|
|
3326
|
-
mode: "web",
|
|
3327
|
-
subaction: command.subaction,
|
|
3328
|
-
value: runtime.errors,
|
|
3329
|
-
};
|
|
3330
|
-
}
|
|
3331
|
-
case "highlight": {
|
|
3332
|
-
const target = resolveTarget();
|
|
3333
|
-
if (!target) {
|
|
3334
|
-
throw new Error("Target element was not found.");
|
|
3335
|
-
}
|
|
3336
|
-
target.setAttribute("data-eliza-highlight", "true");
|
|
3337
|
-
runtime.highlightedSelector =
|
|
3338
|
-
buildBrowserWorkspaceElementSelector(target);
|
|
3339
|
-
return {
|
|
3340
|
-
mode: "web",
|
|
3341
|
-
subaction: command.subaction,
|
|
3342
|
-
value: { selector: runtime.highlightedSelector },
|
|
3343
|
-
};
|
|
3344
|
-
}
|
|
3345
|
-
case "frame": {
|
|
3346
|
-
const action = command.frameAction ?? "select";
|
|
3347
|
-
if (action === "main") {
|
|
3348
|
-
runtime.currentFrame = null;
|
|
3349
|
-
return {
|
|
3350
|
-
mode: "web",
|
|
3351
|
-
subaction: command.subaction,
|
|
3352
|
-
value: { frame: null },
|
|
3353
|
-
};
|
|
3354
|
-
}
|
|
3355
|
-
const frame = resolveBrowserWorkspaceElement(dom.window.document, command.selector);
|
|
3356
|
-
if (!frame || frame.tagName !== "IFRAME") {
|
|
3357
|
-
throw new Error("Eliza browser workspace frame select requires an iframe selector.");
|
|
3358
|
-
}
|
|
3359
|
-
runtime.currentFrame = buildBrowserWorkspaceElementSelector(frame);
|
|
3360
|
-
return {
|
|
3361
|
-
mode: "web",
|
|
3362
|
-
subaction: command.subaction,
|
|
3363
|
-
value: { frame: runtime.currentFrame },
|
|
3364
|
-
};
|
|
3365
|
-
}
|
|
3366
|
-
case "diff": {
|
|
3367
|
-
const snapshot = createBrowserWorkspaceSnapshotRecord(tab.title, tab.url, buildBrowserWorkspaceDocumentSnapshotText(document));
|
|
3368
|
-
if (command.diffAction === "url") {
|
|
3369
|
-
const leftUrl = command.url?.trim() || tab.url;
|
|
3370
|
-
const rightUrl = command.secondaryUrl?.trim();
|
|
3371
|
-
if (!rightUrl) {
|
|
3372
|
-
throw new Error("Eliza browser workspace diff url requires secondaryUrl.");
|
|
3373
|
-
}
|
|
3374
|
-
const left = await fetchBrowserWorkspaceTrackedResponse(runtime, leftUrl, {}, "document");
|
|
3375
|
-
const right = await fetchBrowserWorkspaceTrackedResponse(runtime, rightUrl, {}, "document");
|
|
3376
|
-
const leftSnapshot = createBrowserWorkspaceSnapshotRecord(leftUrl, left.url || leftUrl, await left.text());
|
|
3377
|
-
const rightSnapshot = createBrowserWorkspaceSnapshotRecord(rightUrl, right.url || rightUrl, await right.text());
|
|
3378
|
-
return {
|
|
3379
|
-
mode: "web",
|
|
3380
|
-
subaction: command.subaction,
|
|
3381
|
-
value: diffBrowserWorkspaceSnapshots(leftSnapshot, rightSnapshot),
|
|
3382
|
-
};
|
|
3383
|
-
}
|
|
3384
|
-
if (command.diffAction === "screenshot") {
|
|
3385
|
-
const currentData = runtime.lastScreenshotData ??
|
|
3386
|
-
createBrowserWorkspaceSyntheticScreenshotData(tab.title, tab.url, buildBrowserWorkspaceDocumentSnapshotText(document), runtime.settings.viewport ?? undefined);
|
|
3387
|
-
const baseline = command.baselinePath?.trim()
|
|
3388
|
-
? await fsp.readFile(path.resolve(command.baselinePath.trim()), "base64")
|
|
3389
|
-
: runtime.lastScreenshotData;
|
|
3390
|
-
runtime.lastScreenshotData = currentData;
|
|
3391
|
-
return {
|
|
3392
|
-
mode: "web",
|
|
3393
|
-
subaction: command.subaction,
|
|
3394
|
-
value: {
|
|
3395
|
-
baselineLength: baseline?.length ?? 0,
|
|
3396
|
-
changed: baseline !== currentData,
|
|
3397
|
-
currentLength: currentData.length,
|
|
3398
|
-
},
|
|
3399
|
-
};
|
|
3400
|
-
}
|
|
3401
|
-
const baseline = command.baselinePath?.trim()
|
|
3402
|
-
? JSON.parse(await fsp.readFile(path.resolve(command.baselinePath.trim()), "utf8"))
|
|
3403
|
-
: runtime.lastSnapshot;
|
|
3404
|
-
const diff = diffBrowserWorkspaceSnapshots(baseline, snapshot);
|
|
3405
|
-
runtime.lastSnapshot = snapshot;
|
|
3406
|
-
return { mode: "web", subaction: command.subaction, value: diff };
|
|
3407
|
-
}
|
|
3408
|
-
case "trace": {
|
|
3409
|
-
if (command.traceAction === "stop") {
|
|
3410
|
-
runtime.trace.active = false;
|
|
3411
|
-
const traceValue = { entries: runtime.trace.entries };
|
|
3412
|
-
if (command.filePath?.trim() || command.outputPath?.trim()) {
|
|
3413
|
-
const targetPath = command.filePath?.trim() || command.outputPath?.trim() || "";
|
|
3414
|
-
await writeBrowserWorkspaceFile(targetPath, JSON.stringify(traceValue, null, 2));
|
|
3415
|
-
return {
|
|
3416
|
-
mode: "web",
|
|
3417
|
-
subaction: command.subaction,
|
|
3418
|
-
value: { path: path.resolve(targetPath), ...traceValue },
|
|
3419
|
-
};
|
|
3420
|
-
}
|
|
3421
|
-
return {
|
|
3422
|
-
mode: "web",
|
|
3423
|
-
subaction: command.subaction,
|
|
3424
|
-
value: traceValue,
|
|
3425
|
-
};
|
|
3426
|
-
}
|
|
3427
|
-
runtime.trace = { active: true, entries: [] };
|
|
3428
|
-
runtime.trace.entries.push({
|
|
3429
|
-
command: "trace:start",
|
|
3430
|
-
timestamp: getBrowserWorkspaceTimestamp(),
|
|
3431
|
-
});
|
|
3432
|
-
return {
|
|
3433
|
-
mode: "web",
|
|
3434
|
-
subaction: command.subaction,
|
|
3435
|
-
value: { active: true },
|
|
3436
|
-
};
|
|
3437
|
-
}
|
|
3438
|
-
case "profiler": {
|
|
3439
|
-
if (command.profilerAction === "stop") {
|
|
3440
|
-
runtime.profiler.active = false;
|
|
3441
|
-
const profileValue = { entries: runtime.profiler.entries };
|
|
3442
|
-
if (command.filePath?.trim() || command.outputPath?.trim()) {
|
|
3443
|
-
const targetPath = command.filePath?.trim() || command.outputPath?.trim() || "";
|
|
3444
|
-
await writeBrowserWorkspaceFile(targetPath, JSON.stringify(profileValue, null, 2));
|
|
3445
|
-
return {
|
|
3446
|
-
mode: "web",
|
|
3447
|
-
subaction: command.subaction,
|
|
3448
|
-
value: { path: path.resolve(targetPath), ...profileValue },
|
|
3449
|
-
};
|
|
3450
|
-
}
|
|
3451
|
-
return {
|
|
3452
|
-
mode: "web",
|
|
3453
|
-
subaction: command.subaction,
|
|
3454
|
-
value: profileValue,
|
|
3455
|
-
};
|
|
3456
|
-
}
|
|
3457
|
-
runtime.profiler = {
|
|
3458
|
-
active: true,
|
|
3459
|
-
entries: [
|
|
3460
|
-
{
|
|
3461
|
-
command: "profiler:start",
|
|
3462
|
-
timestamp: getBrowserWorkspaceTimestamp(),
|
|
3463
|
-
},
|
|
3464
|
-
],
|
|
3465
|
-
};
|
|
3466
|
-
return {
|
|
3467
|
-
mode: "web",
|
|
3468
|
-
subaction: command.subaction,
|
|
3469
|
-
value: { active: true },
|
|
3470
|
-
};
|
|
3471
|
-
}
|
|
3472
|
-
case "state": {
|
|
3473
|
-
if (command.stateAction === "load") {
|
|
3474
|
-
const filePath = command.filePath?.trim() || command.outputPath?.trim();
|
|
3475
|
-
if (!filePath) {
|
|
3476
|
-
throw new Error("Eliza browser workspace state load requires filePath.");
|
|
3477
|
-
}
|
|
3478
|
-
const payload = JSON.parse(await fsp.readFile(path.resolve(filePath), "utf8"));
|
|
3479
|
-
applyBrowserWorkspaceStateToWebDocument(document, payload);
|
|
3480
|
-
if (payload.settings && typeof payload.settings === "object") {
|
|
3481
|
-
runtime.settings = {
|
|
3482
|
-
...runtime.settings,
|
|
3483
|
-
...payload.settings,
|
|
3484
|
-
};
|
|
3485
|
-
applyBrowserWorkspaceDomSettings(dom, runtime);
|
|
3486
|
-
}
|
|
3487
|
-
browserWorkspaceClipboardText =
|
|
3488
|
-
typeof payload.clipboard === "string"
|
|
3489
|
-
? payload.clipboard
|
|
3490
|
-
: browserWorkspaceClipboardText;
|
|
3491
|
-
return {
|
|
3492
|
-
mode: "web",
|
|
3493
|
-
subaction: command.subaction,
|
|
3494
|
-
value: { loaded: true },
|
|
3495
|
-
};
|
|
3496
|
-
}
|
|
3497
|
-
const payload = {
|
|
3498
|
-
clipboard: browserWorkspaceClipboardText,
|
|
3499
|
-
cookies: readBrowserWorkspaceCookies(document),
|
|
3500
|
-
localStorage: readBrowserWorkspaceStorage(dom.window.localStorage),
|
|
3501
|
-
sessionStorage: readBrowserWorkspaceStorage(dom.window.sessionStorage),
|
|
3502
|
-
settings: runtime.settings,
|
|
3503
|
-
url: tab.url,
|
|
3504
|
-
};
|
|
3505
|
-
const filePath = command.filePath?.trim() || command.outputPath?.trim();
|
|
3506
|
-
if (filePath) {
|
|
3507
|
-
await writeBrowserWorkspaceFile(filePath, JSON.stringify(payload, null, 2));
|
|
3508
|
-
return {
|
|
3509
|
-
mode: "web",
|
|
3510
|
-
subaction: command.subaction,
|
|
3511
|
-
value: { path: path.resolve(filePath), ...payload },
|
|
3512
|
-
};
|
|
3513
|
-
}
|
|
3514
|
-
return { mode: "web", subaction: command.subaction, value: payload };
|
|
3515
|
-
}
|
|
3516
|
-
case "pdf": {
|
|
3517
|
-
const filePath = command.filePath?.trim() || command.outputPath?.trim();
|
|
3518
|
-
if (!filePath) {
|
|
3519
|
-
throw new Error("Eliza browser workspace pdf requires filePath.");
|
|
3520
|
-
}
|
|
3521
|
-
const pdf = createBrowserWorkspacePdfBuffer(tab.title, normalizeBrowserWorkspaceText(document.body?.textContent));
|
|
3522
|
-
const resolved = await writeBrowserWorkspaceFile(filePath, pdf);
|
|
3523
|
-
return {
|
|
3524
|
-
mode: "web",
|
|
3525
|
-
subaction: command.subaction,
|
|
3526
|
-
value: { path: resolved, size: pdf.byteLength },
|
|
3527
|
-
};
|
|
3528
|
-
}
|
|
3529
|
-
default:
|
|
3530
|
-
return null;
|
|
3531
|
-
}
|
|
3532
|
-
});
|
|
3533
|
-
}
|
|
3534
|
-
async function executeWebBrowserWorkspaceDomCommand(command) {
|
|
3535
|
-
return withWebStateLock(async () => {
|
|
3536
|
-
const id = findWebBrowserWorkspaceTargetTabId(command);
|
|
3537
|
-
command = resolveBrowserWorkspaceCommandElementRefs(command, "web", id);
|
|
3538
|
-
const tab = getWebBrowserWorkspaceTabState(id);
|
|
3539
|
-
const dom = await ensureLoadedWebBrowserWorkspaceTabDocument(tab);
|
|
3540
|
-
const frameContext = resolveWebBrowserWorkspaceCommandDocument(tab, dom);
|
|
3541
|
-
const document = frameContext.document;
|
|
3542
|
-
const resolveTarget = () => resolveBrowserWorkspaceElement(document, command.selector, command.text, command);
|
|
3543
|
-
switch (command.subaction) {
|
|
3544
|
-
case "inspect":
|
|
3545
|
-
clearWebBrowserWorkspaceTabElementRefs(tab.id);
|
|
3546
|
-
return {
|
|
3547
|
-
mode: "web",
|
|
3548
|
-
subaction: command.subaction,
|
|
3549
|
-
elements: registerBrowserWorkspaceElementRefs("web", tab.id, collectBrowserWorkspaceInspectElements(document)),
|
|
3550
|
-
value: {
|
|
3551
|
-
title: tab.title,
|
|
3552
|
-
url: tab.url,
|
|
3553
|
-
},
|
|
3554
|
-
};
|
|
3555
|
-
case "snapshot":
|
|
3556
|
-
clearWebBrowserWorkspaceTabElementRefs(tab.id);
|
|
3557
|
-
return {
|
|
3558
|
-
mode: "web",
|
|
3559
|
-
subaction: command.subaction,
|
|
3560
|
-
elements: registerBrowserWorkspaceElementRefs("web", tab.id, collectBrowserWorkspaceInspectElements(document)),
|
|
3561
|
-
value: {
|
|
3562
|
-
bodyText: buildBrowserWorkspaceDocumentSnapshotText(document).slice(0, 800),
|
|
3563
|
-
title: tab.title,
|
|
3564
|
-
url: tab.url,
|
|
3565
|
-
},
|
|
3566
|
-
};
|
|
3567
|
-
case "get": {
|
|
3568
|
-
if (command.getMode === "title") {
|
|
3569
|
-
return {
|
|
3570
|
-
mode: "web",
|
|
3571
|
-
subaction: command.subaction,
|
|
3572
|
-
value: tab.title,
|
|
3573
|
-
};
|
|
3574
|
-
}
|
|
3575
|
-
if (command.getMode === "url") {
|
|
3576
|
-
return { mode: "web", subaction: command.subaction, value: tab.url };
|
|
3577
|
-
}
|
|
3578
|
-
if (command.getMode === "count") {
|
|
3579
|
-
if (!command.selector?.trim()) {
|
|
3580
|
-
throw new Error("Eliza browser workspace get count requires selector.");
|
|
3581
|
-
}
|
|
3582
|
-
const semanticCommand = mergeBrowserWorkspaceSelectorCommand(command, command.selector);
|
|
3583
|
-
return {
|
|
3584
|
-
mode: "web",
|
|
3585
|
-
subaction: command.subaction,
|
|
3586
|
-
value: semanticCommand
|
|
3587
|
-
? Number(Boolean(resolveBrowserWorkspaceFindElement(document, semanticCommand)))
|
|
3588
|
-
: queryAllBrowserWorkspaceSelector(document, command.selector)
|
|
3589
|
-
.length,
|
|
3590
|
-
};
|
|
3591
|
-
}
|
|
3592
|
-
const element = resolveTarget();
|
|
3593
|
-
if (!element) {
|
|
3594
|
-
throw new Error("Target element was not found.");
|
|
3595
|
-
}
|
|
3596
|
-
let value;
|
|
3597
|
-
switch (command.getMode) {
|
|
3598
|
-
case "attr":
|
|
3599
|
-
if (!command.attribute?.trim()) {
|
|
3600
|
-
throw new Error("Eliza browser workspace attr lookups require attribute.");
|
|
3601
|
-
}
|
|
3602
|
-
value = element.getAttribute(command.attribute);
|
|
3603
|
-
break;
|
|
3604
|
-
case "box":
|
|
3605
|
-
value = getBrowserWorkspaceElementBox(element);
|
|
3606
|
-
break;
|
|
3607
|
-
case "checked":
|
|
3608
|
-
value =
|
|
3609
|
-
element.tagName === "INPUT"
|
|
3610
|
-
? Boolean(element.checked)
|
|
3611
|
-
: element.tagName === "OPTION"
|
|
3612
|
-
? Boolean(element.selected)
|
|
3613
|
-
: false;
|
|
3614
|
-
break;
|
|
3615
|
-
case "enabled":
|
|
3616
|
-
value =
|
|
3617
|
-
"disabled" in element
|
|
3618
|
-
? !element.disabled
|
|
3619
|
-
: true;
|
|
3620
|
-
break;
|
|
3621
|
-
case "html":
|
|
3622
|
-
value = element.innerHTML;
|
|
3623
|
-
break;
|
|
3624
|
-
case "styles":
|
|
3625
|
-
value = getBrowserWorkspaceElementStyles(element, dom.window);
|
|
3626
|
-
break;
|
|
3627
|
-
case "value":
|
|
3628
|
-
value = getBrowserWorkspaceElementValue(element);
|
|
3629
|
-
break;
|
|
3630
|
-
case "visible":
|
|
3631
|
-
value = isBrowserWorkspaceElementVisible(element);
|
|
3632
|
-
break;
|
|
3633
|
-
default:
|
|
3634
|
-
value = normalizeBrowserWorkspaceText(element.textContent);
|
|
3635
|
-
break;
|
|
3636
|
-
}
|
|
3637
|
-
return { mode: "web", subaction: command.subaction, value };
|
|
3638
|
-
}
|
|
3639
|
-
case "find": {
|
|
3640
|
-
const element = resolveTarget();
|
|
3641
|
-
if (!element) {
|
|
3642
|
-
throw new Error("Target element was not found.");
|
|
3643
|
-
}
|
|
3644
|
-
switch (command.action) {
|
|
3645
|
-
case "check": {
|
|
3646
|
-
const input = ensureBrowserWorkspaceCheckboxElement(element, "check");
|
|
3647
|
-
input.checked = true;
|
|
3648
|
-
return {
|
|
3649
|
-
mode: "web",
|
|
3650
|
-
subaction: command.subaction,
|
|
3651
|
-
value: {
|
|
3652
|
-
checked: input.checked,
|
|
3653
|
-
selector: buildBrowserWorkspaceElementSelector(input),
|
|
3654
|
-
},
|
|
3655
|
-
};
|
|
3656
|
-
}
|
|
3657
|
-
case "click":
|
|
3658
|
-
return {
|
|
3659
|
-
...(await activateWebBrowserWorkspaceElement(tab, element, "click")),
|
|
3660
|
-
subaction: command.subaction,
|
|
3661
|
-
};
|
|
3662
|
-
case "fill": {
|
|
3663
|
-
const control = ensureBrowserWorkspaceFormControlElement(element, "fill");
|
|
3664
|
-
setBrowserWorkspaceControlValue(control, command.value ?? "");
|
|
3665
|
-
return {
|
|
3666
|
-
mode: "web",
|
|
3667
|
-
subaction: command.subaction,
|
|
3668
|
-
value: {
|
|
3669
|
-
selector: buildBrowserWorkspaceElementSelector(control),
|
|
3670
|
-
value: control.value,
|
|
3671
|
-
},
|
|
3672
|
-
};
|
|
3673
|
-
}
|
|
3674
|
-
case "focus":
|
|
3675
|
-
if (typeof element.focus === "function") {
|
|
3676
|
-
element.focus();
|
|
3677
|
-
}
|
|
3678
|
-
return {
|
|
3679
|
-
mode: "web",
|
|
3680
|
-
subaction: command.subaction,
|
|
3681
|
-
value: {
|
|
3682
|
-
focused: document.activeElement === element,
|
|
3683
|
-
selector: buildBrowserWorkspaceElementSelector(element),
|
|
3684
|
-
},
|
|
3685
|
-
};
|
|
3686
|
-
case "hover":
|
|
3687
|
-
element.setAttribute("data-eliza-hover", "true");
|
|
3688
|
-
return {
|
|
3689
|
-
mode: "web",
|
|
3690
|
-
subaction: command.subaction,
|
|
3691
|
-
value: {
|
|
3692
|
-
hovered: true,
|
|
3693
|
-
selector: buildBrowserWorkspaceElementSelector(element),
|
|
3694
|
-
},
|
|
3695
|
-
};
|
|
3696
|
-
case "type": {
|
|
3697
|
-
const control = ensureBrowserWorkspaceFormControlElement(element, "type");
|
|
3698
|
-
setBrowserWorkspaceControlValue(control, `${control.value ?? ""}${command.value ?? ""}`);
|
|
3699
|
-
return {
|
|
3700
|
-
mode: "web",
|
|
3701
|
-
subaction: command.subaction,
|
|
3702
|
-
value: {
|
|
3703
|
-
selector: buildBrowserWorkspaceElementSelector(control),
|
|
3704
|
-
value: control.value,
|
|
3705
|
-
},
|
|
3706
|
-
};
|
|
3707
|
-
}
|
|
3708
|
-
case "uncheck": {
|
|
3709
|
-
const input = ensureBrowserWorkspaceCheckboxElement(element, "uncheck");
|
|
3710
|
-
input.checked = false;
|
|
3711
|
-
return {
|
|
3712
|
-
mode: "web",
|
|
3713
|
-
subaction: command.subaction,
|
|
3714
|
-
value: {
|
|
3715
|
-
checked: input.checked,
|
|
3716
|
-
selector: buildBrowserWorkspaceElementSelector(input),
|
|
3717
|
-
},
|
|
3718
|
-
};
|
|
3719
|
-
}
|
|
3720
|
-
case "text":
|
|
3721
|
-
case undefined:
|
|
3722
|
-
return {
|
|
3723
|
-
mode: "web",
|
|
3724
|
-
subaction: command.subaction,
|
|
3725
|
-
value: {
|
|
3726
|
-
element: createBrowserWorkspaceElementSummary(element),
|
|
3727
|
-
text: normalizeBrowserWorkspaceText(element.textContent),
|
|
3728
|
-
},
|
|
3729
|
-
};
|
|
3730
|
-
default:
|
|
3731
|
-
throw new Error(`Unsupported browser workspace find action: ${command.action}`);
|
|
3732
|
-
}
|
|
3733
|
-
}
|
|
3734
|
-
case "check": {
|
|
3735
|
-
const element = resolveTarget();
|
|
3736
|
-
if (!element) {
|
|
3737
|
-
throw new Error("Target element was not found.");
|
|
3738
|
-
}
|
|
3739
|
-
const input = ensureBrowserWorkspaceCheckboxElement(element, "check");
|
|
3740
|
-
input.checked = true;
|
|
3741
|
-
return {
|
|
3742
|
-
mode: "web",
|
|
3743
|
-
subaction: command.subaction,
|
|
3744
|
-
value: {
|
|
3745
|
-
checked: input.checked,
|
|
3746
|
-
selector: buildBrowserWorkspaceElementSelector(input),
|
|
3747
|
-
},
|
|
3748
|
-
};
|
|
3749
|
-
}
|
|
3750
|
-
case "fill":
|
|
3751
|
-
case "type": {
|
|
3752
|
-
const element = resolveTarget();
|
|
3753
|
-
if (!element) {
|
|
3754
|
-
throw new Error("Target element was not found.");
|
|
3755
|
-
}
|
|
3756
|
-
const control = ensureBrowserWorkspaceFormControlElement(element, command.subaction);
|
|
3757
|
-
const nextValue = command.subaction === "type"
|
|
3758
|
-
? `${control.value ?? ""}${command.value ?? ""}`
|
|
3759
|
-
: (command.value ?? "");
|
|
3760
|
-
setBrowserWorkspaceControlValue(control, nextValue);
|
|
3761
|
-
return {
|
|
3762
|
-
mode: "web",
|
|
3763
|
-
subaction: command.subaction,
|
|
3764
|
-
value: {
|
|
3765
|
-
selector: buildBrowserWorkspaceElementSelector(control),
|
|
3766
|
-
value: nextValue,
|
|
3767
|
-
},
|
|
3768
|
-
};
|
|
3769
|
-
}
|
|
3770
|
-
case "focus": {
|
|
3771
|
-
const element = resolveTarget();
|
|
3772
|
-
if (!element) {
|
|
3773
|
-
throw new Error("Target element was not found.");
|
|
3774
|
-
}
|
|
3775
|
-
if (typeof element.focus === "function") {
|
|
3776
|
-
element.focus();
|
|
3777
|
-
}
|
|
3778
|
-
return {
|
|
3779
|
-
mode: "web",
|
|
3780
|
-
subaction: command.subaction,
|
|
3781
|
-
value: {
|
|
3782
|
-
focused: document.activeElement === element,
|
|
3783
|
-
selector: buildBrowserWorkspaceElementSelector(element),
|
|
3784
|
-
},
|
|
3785
|
-
};
|
|
3786
|
-
}
|
|
3787
|
-
case "hover": {
|
|
3788
|
-
const element = resolveTarget();
|
|
3789
|
-
if (!element) {
|
|
3790
|
-
throw new Error("Target element was not found.");
|
|
3791
|
-
}
|
|
3792
|
-
element.setAttribute("data-eliza-hover", "true");
|
|
3793
|
-
return {
|
|
3794
|
-
mode: "web",
|
|
3795
|
-
subaction: command.subaction,
|
|
3796
|
-
value: {
|
|
3797
|
-
hovered: true,
|
|
3798
|
-
selector: buildBrowserWorkspaceElementSelector(element),
|
|
3799
|
-
},
|
|
3800
|
-
};
|
|
3801
|
-
}
|
|
3802
|
-
case "keyboardinserttext":
|
|
3803
|
-
case "keyboardtype": {
|
|
3804
|
-
const active = document.activeElement;
|
|
3805
|
-
if (!active ||
|
|
3806
|
-
!(active.tagName === "INPUT" ||
|
|
3807
|
-
active.tagName === "TEXTAREA" ||
|
|
3808
|
-
active.tagName === "SELECT")) {
|
|
3809
|
-
throw new Error("Eliza browser workspace keyboard text input requires a focused input target.");
|
|
3810
|
-
}
|
|
3811
|
-
const control = ensureBrowserWorkspaceFormControlElement(active, command.subaction === "keyboardtype" ? "type" : "keyboardinserttext");
|
|
3812
|
-
const nextValue = command.subaction === "keyboardtype"
|
|
3813
|
-
? `${control.value ?? ""}${command.value ?? ""}`
|
|
3814
|
-
: (command.value ?? "");
|
|
3815
|
-
setBrowserWorkspaceControlValue(control, nextValue);
|
|
3816
|
-
return {
|
|
3817
|
-
mode: "web",
|
|
3818
|
-
subaction: command.subaction,
|
|
3819
|
-
value: {
|
|
3820
|
-
selector: buildBrowserWorkspaceElementSelector(control),
|
|
3821
|
-
value: control.value,
|
|
3822
|
-
},
|
|
3823
|
-
};
|
|
3824
|
-
}
|
|
3825
|
-
case "keydown":
|
|
3826
|
-
case "keyup":
|
|
3827
|
-
return {
|
|
3828
|
-
mode: "web",
|
|
3829
|
-
subaction: command.subaction,
|
|
3830
|
-
value: {
|
|
3831
|
-
key: command.key?.trim() || "Enter",
|
|
3832
|
-
selector: document.activeElement &&
|
|
3833
|
-
document.activeElement instanceof Element
|
|
3834
|
-
? buildBrowserWorkspaceElementSelector(document.activeElement)
|
|
3835
|
-
: null,
|
|
3836
|
-
},
|
|
3837
|
-
};
|
|
3838
|
-
case "click": {
|
|
3839
|
-
const element = resolveTarget();
|
|
3840
|
-
if (!element) {
|
|
3841
|
-
throw new Error("Target element was not found.");
|
|
3842
|
-
}
|
|
3843
|
-
return activateWebBrowserWorkspaceElement(tab, element, "click");
|
|
3844
|
-
}
|
|
3845
|
-
case "dblclick": {
|
|
3846
|
-
const element = resolveTarget();
|
|
3847
|
-
if (!element) {
|
|
3848
|
-
throw new Error("Target element was not found.");
|
|
3849
|
-
}
|
|
3850
|
-
return activateWebBrowserWorkspaceElement(tab, element, "dblclick");
|
|
3851
|
-
}
|
|
3852
|
-
case "press": {
|
|
3853
|
-
const key = command.key?.trim() || "Enter";
|
|
3854
|
-
const element = resolveTarget();
|
|
3855
|
-
const form = findClosestBrowserWorkspaceForm(element);
|
|
3856
|
-
if (key === "Enter" && form) {
|
|
3857
|
-
await submitWebBrowserWorkspaceForm(tab, form);
|
|
3858
|
-
return {
|
|
3859
|
-
mode: "web",
|
|
3860
|
-
subaction: command.subaction,
|
|
3861
|
-
tab: cloneWebBrowserWorkspaceTabState(tab),
|
|
3862
|
-
value: { key, url: tab.url },
|
|
3863
|
-
};
|
|
3864
|
-
}
|
|
3865
|
-
return { mode: "web", subaction: command.subaction, value: { key } };
|
|
3866
|
-
}
|
|
3867
|
-
case "scroll": {
|
|
3868
|
-
return {
|
|
3869
|
-
mode: "web",
|
|
3870
|
-
subaction: command.subaction,
|
|
3871
|
-
value: scrollWebBrowserWorkspaceTarget(dom, resolveTarget(), command.direction ?? "down", command.pixels ?? 240),
|
|
3872
|
-
};
|
|
3873
|
-
}
|
|
3874
|
-
case "scrollinto": {
|
|
3875
|
-
const element = resolveTarget();
|
|
3876
|
-
if (!element) {
|
|
3877
|
-
throw new Error("Target element was not found.");
|
|
3878
|
-
}
|
|
3879
|
-
if (typeof element.focus === "function") {
|
|
3880
|
-
element.focus();
|
|
3881
|
-
}
|
|
3882
|
-
return {
|
|
3883
|
-
mode: "web",
|
|
3884
|
-
subaction: command.subaction,
|
|
3885
|
-
value: {
|
|
3886
|
-
scrolled: true,
|
|
3887
|
-
selector: buildBrowserWorkspaceElementSelector(element),
|
|
3888
|
-
},
|
|
3889
|
-
};
|
|
3890
|
-
}
|
|
3891
|
-
case "select": {
|
|
3892
|
-
const element = resolveTarget();
|
|
3893
|
-
if (!element) {
|
|
3894
|
-
throw new Error("Target element was not found.");
|
|
3895
|
-
}
|
|
3896
|
-
if (element.tagName !== "SELECT") {
|
|
3897
|
-
throw new Error("Eliza browser workspace select requires a select target.");
|
|
3898
|
-
}
|
|
3899
|
-
const select = ensureBrowserWorkspaceFormControlElement(element, "select");
|
|
3900
|
-
const option = Array.from(select.options).find((entry) => entry.value === (command.value ?? "") ||
|
|
3901
|
-
browserWorkspaceTextMatches(entry.textContent ?? "", command.value ?? "", true));
|
|
3902
|
-
if (!option) {
|
|
3903
|
-
throw new Error("Select option was not found.");
|
|
3904
|
-
}
|
|
3905
|
-
select.value = option.value;
|
|
3906
|
-
option.selected = true;
|
|
3907
|
-
return {
|
|
3908
|
-
mode: "web",
|
|
3909
|
-
subaction: command.subaction,
|
|
3910
|
-
value: {
|
|
3911
|
-
selector: buildBrowserWorkspaceElementSelector(select),
|
|
3912
|
-
value: select.value,
|
|
3913
|
-
},
|
|
3914
|
-
};
|
|
3915
|
-
}
|
|
3916
|
-
case "uncheck": {
|
|
3917
|
-
const element = resolveTarget();
|
|
3918
|
-
if (!element) {
|
|
3919
|
-
throw new Error("Target element was not found.");
|
|
3920
|
-
}
|
|
3921
|
-
const input = ensureBrowserWorkspaceCheckboxElement(element, "uncheck");
|
|
3922
|
-
input.checked = false;
|
|
3923
|
-
return {
|
|
3924
|
-
mode: "web",
|
|
3925
|
-
subaction: command.subaction,
|
|
3926
|
-
value: {
|
|
3927
|
-
checked: input.checked,
|
|
3928
|
-
selector: buildBrowserWorkspaceElementSelector(input),
|
|
3929
|
-
},
|
|
3930
|
-
};
|
|
3931
|
-
}
|
|
3932
|
-
case "wait": {
|
|
3933
|
-
if (!command.selector &&
|
|
3934
|
-
!command.findBy &&
|
|
3935
|
-
!command.text &&
|
|
3936
|
-
!command.url &&
|
|
3937
|
-
!command.script &&
|
|
3938
|
-
typeof command.timeoutMs === "number" &&
|
|
3939
|
-
Number.isFinite(command.timeoutMs)) {
|
|
3940
|
-
const waitedMs = Math.max(0, command.timeoutMs);
|
|
3941
|
-
await sleep(waitedMs);
|
|
3942
|
-
return {
|
|
3943
|
-
mode: "web",
|
|
3944
|
-
subaction: command.subaction,
|
|
3945
|
-
value: { waitedMs },
|
|
3946
|
-
};
|
|
3947
|
-
}
|
|
3948
|
-
const timeoutMs = typeof command.timeoutMs === "number" &&
|
|
3949
|
-
Number.isFinite(command.timeoutMs)
|
|
3950
|
-
? Math.max(100, command.timeoutMs)
|
|
3951
|
-
: DEFAULT_TIMEOUT_MS;
|
|
3952
|
-
const deadline = Date.now() + timeoutMs;
|
|
3953
|
-
while (Date.now() <= deadline) {
|
|
3954
|
-
await ensureLoadedWebBrowserWorkspaceTabDocument(tab);
|
|
3955
|
-
const currentDom = ensureBrowserWorkspaceDom(tab);
|
|
3956
|
-
const currentDocument = currentDom.window.document;
|
|
3957
|
-
const matchesSelector = command.selector?.trim()
|
|
3958
|
-
? (() => {
|
|
3959
|
-
const found = resolveBrowserWorkspaceElement(currentDocument, command.selector, undefined, command);
|
|
3960
|
-
if (!command.state || command.state === "visible") {
|
|
3961
|
-
return found
|
|
3962
|
-
? isBrowserWorkspaceElementVisible(found)
|
|
3963
|
-
: false;
|
|
3964
|
-
}
|
|
3965
|
-
return !found || !isBrowserWorkspaceElementVisible(found);
|
|
3966
|
-
})()
|
|
3967
|
-
: false;
|
|
3968
|
-
const matchesFind = command.findBy
|
|
3969
|
-
? Boolean(resolveBrowserWorkspaceFindElement(currentDocument, command))
|
|
3970
|
-
: false;
|
|
3971
|
-
const matchesText = command.text?.trim()
|
|
3972
|
-
? normalizeBrowserWorkspaceText(currentDocument.body?.textContent).includes(command.text.trim())
|
|
3973
|
-
: false;
|
|
3974
|
-
const matchesUrl = command.url?.trim()
|
|
3975
|
-
? tab.url.includes(command.url.trim())
|
|
3976
|
-
: false;
|
|
3977
|
-
const matchesScript = command.script?.trim()
|
|
3978
|
-
? Boolean(new Function("document", "window", "location", `return (${command.script});`)(currentDocument, currentDom.window, currentDom.window.location))
|
|
3979
|
-
: false;
|
|
3980
|
-
if (matchesSelector ||
|
|
3981
|
-
matchesFind ||
|
|
3982
|
-
matchesText ||
|
|
3983
|
-
matchesUrl ||
|
|
3984
|
-
matchesScript ||
|
|
3985
|
-
(!command.selector &&
|
|
3986
|
-
!command.findBy &&
|
|
3987
|
-
!command.text &&
|
|
3988
|
-
!command.url &&
|
|
3989
|
-
!command.script)) {
|
|
3990
|
-
return {
|
|
3991
|
-
mode: "web",
|
|
3992
|
-
subaction: command.subaction,
|
|
3993
|
-
value: {
|
|
3994
|
-
findBy: command.findBy ?? null,
|
|
3995
|
-
selector: command.selector ?? null,
|
|
3996
|
-
state: command.state ?? null,
|
|
3997
|
-
text: command.text ?? null,
|
|
3998
|
-
url: tab.url,
|
|
3999
|
-
},
|
|
4000
|
-
};
|
|
4001
|
-
}
|
|
4002
|
-
await sleep(DEFAULT_WAIT_INTERVAL_MS);
|
|
4003
|
-
}
|
|
4004
|
-
throw new Error("Timed out waiting for browser workspace condition.");
|
|
4005
|
-
}
|
|
4006
|
-
default:
|
|
4007
|
-
throw new Error(`Unsupported web browser workspace subaction: ${command.subaction}`);
|
|
4008
|
-
}
|
|
4009
|
-
});
|
|
4010
|
-
}
|
|
4011
|
-
export function resolveBrowserWorkspaceBridgeConfig(env = process.env) {
|
|
4012
|
-
const baseUrl = normalizeEnvValue(env.ELIZA_BROWSER_WORKSPACE_URL) ??
|
|
4013
|
-
normalizeEnvValue(env.ELIZA_BROWSER_WORKSPACE_URL);
|
|
4014
|
-
if (!baseUrl) {
|
|
4015
|
-
return null;
|
|
4016
|
-
}
|
|
4017
|
-
return {
|
|
4018
|
-
baseUrl: baseUrl.replace(/\/+$/, ""),
|
|
4019
|
-
token: normalizeEnvValue(env.ELIZA_BROWSER_WORKSPACE_TOKEN) ??
|
|
4020
|
-
normalizeEnvValue(env.ELIZA_BROWSER_WORKSPACE_TOKEN),
|
|
4021
|
-
};
|
|
4022
|
-
}
|
|
4023
|
-
export function isBrowserWorkspaceBridgeConfigured(env = process.env) {
|
|
4024
|
-
return resolveBrowserWorkspaceBridgeConfig(env) !== null;
|
|
4025
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Browser workspace — public API surface.
|
|
3
|
+
*
|
|
4
|
+
* Implementation is split across sibling modules:
|
|
5
|
+
* browser-workspace-types.ts — all exported types and interfaces
|
|
6
|
+
* browser-workspace-state.ts — global mutable state and CRUD helpers
|
|
7
|
+
* browser-workspace-helpers.ts — small utilities, error factories, command normalization
|
|
8
|
+
* browser-workspace-jsdom.ts — JSDOM loading, DOM creation, runtime setup
|
|
9
|
+
* browser-workspace-elements.ts — element finding, selector parsing, inspection
|
|
10
|
+
* browser-workspace-network.ts — network interception, HAR, tracked fetch
|
|
11
|
+
* browser-workspace-forms.ts — form control interaction, activation, scrolling
|
|
12
|
+
* browser-workspace-snapshots.ts — document snapshots, diff, PDF/screenshot
|
|
13
|
+
* browser-workspace-desktop.ts — desktop bridge HTTP client and script generators
|
|
14
|
+
* browser-workspace-web.ts — web-mode command execution
|
|
15
|
+
*
|
|
16
|
+
* This file re-exports every public symbol so external consumers are unaffected.
|
|
17
|
+
*/
|
|
18
|
+
import * as fsp from "node:fs/promises";
|
|
19
|
+
import * as path from "node:path";
|
|
20
|
+
// ── Re-export state ──────────────────────────────────────────────────
|
|
21
|
+
export { __resetBrowserWorkspaceStateForTests } from "./browser-workspace-state.js";
|
|
22
|
+
// ── Re-export desktop bridge ─────────────────────────────────────────
|
|
23
|
+
import { evaluateBrowserWorkspaceTab as evaluateBrowserWorkspaceTabDesktop, executeDesktopBrowserWorkspaceDomCommand, executeDesktopBrowserWorkspaceUtilityCommand, getBrowserWorkspaceUnavailableMessage, getDesktopBrowserWorkspaceSessionState, getDesktopBrowserWorkspaceSnapshotRecord, isBrowserWorkspaceBridgeConfigured, loadDesktopBrowserWorkspaceSessionState, requestBrowserWorkspace, resolveBrowserWorkspaceBridgeConfig, resolveDesktopBrowserWorkspaceTargetTabId, snapshotBrowserWorkspaceTab as snapshotBrowserWorkspaceTabDesktop, } from "./browser-workspace-desktop.js";
|
|
24
|
+
// ── Re-export helpers ────────────────────────────────────────────────
|
|
25
|
+
import { assertBrowserWorkspaceUrl, createBrowserWorkspaceNotFoundError, DEFAULT_WEB_PARTITION, inferBrowserWorkspaceTitle, normalizeBrowserWorkspaceCommand, sleep, } from "./browser-workspace-helpers.js";
|
|
26
|
+
export { getBrowserWorkspaceUnavailableMessage, isBrowserWorkspaceBridgeConfigured, resolveBrowserWorkspaceBridgeConfig, };
|
|
27
|
+
// ── Re-export forms ─────────────────────────────────────────────────
|
|
28
|
+
import { clearWebBrowserWorkspaceTabElementRefs, cloneWebBrowserWorkspaceTabState, loadWebBrowserWorkspaceTabDocument, pushWebBrowserWorkspaceHistory, } from "./browser-workspace-forms.js";
|
|
29
|
+
// ── Re-export network ────────────────────────────────────────────────
|
|
30
|
+
import { browserWorkspacePageFetch } from "./browser-workspace-helpers.js";
|
|
31
|
+
// ── Re-export jsdom ──────────────────────────────────────────────────
|
|
32
|
+
import { createEmptyWebBrowserWorkspaceDom, installBrowserWorkspaceWebRuntime, } from "./browser-workspace-jsdom.js";
|
|
33
|
+
// ── Re-export snapshots ──────────────────────────────────────────────
|
|
34
|
+
import { createBrowserWorkspacePdfBuffer, createBrowserWorkspaceSnapshotRecord, diffBrowserWorkspaceSnapshots, } from "./browser-workspace-snapshots.js";
|
|
35
|
+
// ── Imports for state ────────────────────────────────────────────────
|
|
36
|
+
import { clearBrowserWorkspaceElementRefs, clearBrowserWorkspaceRuntimeState, getBrowserWorkspaceRuntimeState, getBrowserWorkspaceTimestamp, resetBrowserWorkspaceRuntimeNavigationState, webWorkspaceState, withWebStateLock, } from "./browser-workspace-state.js";
|
|
37
|
+
// ── Re-export web ────────────────────────────────────────────────────
|
|
38
|
+
import { executeWebBrowserWorkspaceDomCommand, executeWebBrowserWorkspaceUtilityCommand, findWebBrowserWorkspaceTargetTabId, getWebBrowserWorkspaceTabIndex, getWebBrowserWorkspaceTabState, } from "./browser-workspace-web.js";
|
|
39
|
+
// ────────────────────────────────────────────────────────────────────
|
|
40
|
+
// Public API functions
|
|
41
|
+
// ────────────────────────────────────────────────────────────────────
|
|
4026
42
|
export function getBrowserWorkspaceMode(env = process.env) {
|
|
4027
43
|
return isBrowserWorkspaceBridgeConfigured(env) ? "desktop" : "web";
|
|
4028
44
|
}
|
|
4029
|
-
export function getBrowserWorkspaceUnavailableMessage() {
|
|
4030
|
-
return DESKTOP_BRIDGE_UNAVAILABLE_MESSAGE;
|
|
4031
|
-
}
|
|
4032
45
|
export async function getBrowserWorkspaceSnapshot(env = process.env) {
|
|
4033
46
|
return {
|
|
4034
47
|
mode: getBrowserWorkspaceMode(env),
|
|
@@ -4037,7 +50,16 @@ export async function getBrowserWorkspaceSnapshot(env = process.env) {
|
|
|
4037
50
|
}
|
|
4038
51
|
export async function listBrowserWorkspaceTabs(env = process.env) {
|
|
4039
52
|
if (!isBrowserWorkspaceBridgeConfigured(env)) {
|
|
4040
|
-
return
|
|
53
|
+
return webWorkspaceState.tabs.map((tab) => ({
|
|
54
|
+
id: tab.id,
|
|
55
|
+
title: tab.title,
|
|
56
|
+
url: tab.url,
|
|
57
|
+
partition: tab.partition,
|
|
58
|
+
visible: tab.visible,
|
|
59
|
+
createdAt: tab.createdAt,
|
|
60
|
+
updatedAt: tab.updatedAt,
|
|
61
|
+
lastFocusedAt: tab.lastFocusedAt,
|
|
62
|
+
}));
|
|
4041
63
|
}
|
|
4042
64
|
const payload = await requestBrowserWorkspace("/tabs", undefined, env);
|
|
4043
65
|
return Array.isArray(payload.tabs) ? payload.tabs : [];
|
|
@@ -4045,7 +67,28 @@ export async function listBrowserWorkspaceTabs(env = process.env) {
|
|
|
4045
67
|
export async function openBrowserWorkspaceTab(request, env = process.env) {
|
|
4046
68
|
if (!isBrowserWorkspaceBridgeConfigured(env)) {
|
|
4047
69
|
return withWebStateLock(() => {
|
|
4048
|
-
const
|
|
70
|
+
const now = getBrowserWorkspaceTimestamp();
|
|
71
|
+
const url = assertBrowserWorkspaceUrl(request.url?.trim() || "about:blank");
|
|
72
|
+
const visible = request.show === true;
|
|
73
|
+
const id = `btab_${webWorkspaceState.nextId++}`;
|
|
74
|
+
const dom = url === "about:blank" ? createEmptyWebBrowserWorkspaceDom(url) : null;
|
|
75
|
+
const tab = {
|
|
76
|
+
id,
|
|
77
|
+
title: request.title?.trim() || inferBrowserWorkspaceTitle(url),
|
|
78
|
+
url,
|
|
79
|
+
partition: request.partition?.trim() || DEFAULT_WEB_PARTITION,
|
|
80
|
+
visible,
|
|
81
|
+
createdAt: now,
|
|
82
|
+
updatedAt: now,
|
|
83
|
+
lastFocusedAt: visible ? now : null,
|
|
84
|
+
dom,
|
|
85
|
+
history: [url],
|
|
86
|
+
historyIndex: 0,
|
|
87
|
+
loadedUrl: url === "about:blank" ? url : null,
|
|
88
|
+
};
|
|
89
|
+
if (dom) {
|
|
90
|
+
installBrowserWorkspaceWebRuntime(tab, dom);
|
|
91
|
+
}
|
|
4049
92
|
getBrowserWorkspaceRuntimeState("web", tab.id);
|
|
4050
93
|
clearWebBrowserWorkspaceTabElementRefs(tab.id);
|
|
4051
94
|
if (tab.visible) {
|
|
@@ -4073,6 +116,9 @@ export async function navigateBrowserWorkspaceTab(request, env = process.env) {
|
|
|
4073
116
|
throw createBrowserWorkspaceNotFoundError(request.id);
|
|
4074
117
|
}
|
|
4075
118
|
const existing = webWorkspaceState.tabs[index];
|
|
119
|
+
if (!existing) {
|
|
120
|
+
throw createBrowserWorkspaceNotFoundError(request.id);
|
|
121
|
+
}
|
|
4076
122
|
const updatedAt = getBrowserWorkspaceTimestamp();
|
|
4077
123
|
const state = getBrowserWorkspaceRuntimeState("web", existing.id);
|
|
4078
124
|
clearWebBrowserWorkspaceTabElementRefs(existing.id);
|
|
@@ -4126,9 +172,13 @@ export async function hideBrowserWorkspaceTab(id, env = process.env) {
|
|
|
4126
172
|
if (index < 0) {
|
|
4127
173
|
throw createBrowserWorkspaceNotFoundError(id);
|
|
4128
174
|
}
|
|
175
|
+
const existing = webWorkspaceState.tabs[index];
|
|
176
|
+
if (!existing) {
|
|
177
|
+
throw createBrowserWorkspaceNotFoundError(id);
|
|
178
|
+
}
|
|
4129
179
|
const updatedAt = getBrowserWorkspaceTimestamp();
|
|
4130
180
|
const nextTab = {
|
|
4131
|
-
...
|
|
181
|
+
...existing,
|
|
4132
182
|
visible: false,
|
|
4133
183
|
updatedAt,
|
|
4134
184
|
};
|
|
@@ -4153,21 +203,14 @@ export async function closeBrowserWorkspaceTab(id, env = process.env) {
|
|
|
4153
203
|
return payload.closed === true;
|
|
4154
204
|
}
|
|
4155
205
|
export async function evaluateBrowserWorkspaceTab(request, env = process.env) {
|
|
4156
|
-
|
|
4157
|
-
throw new Error(createBrowserWorkspaceDesktopOnlyMessage("eval"));
|
|
4158
|
-
}
|
|
4159
|
-
const payload = await requestBrowserWorkspace(`/tabs/${encodeURIComponent(request.id)}/eval`, {
|
|
4160
|
-
method: "POST",
|
|
4161
|
-
body: JSON.stringify({ script: request.script }),
|
|
4162
|
-
}, env);
|
|
4163
|
-
return payload.result;
|
|
206
|
+
return evaluateBrowserWorkspaceTabDesktop(request, env);
|
|
4164
207
|
}
|
|
4165
208
|
export async function snapshotBrowserWorkspaceTab(id, env = process.env) {
|
|
4166
|
-
|
|
4167
|
-
throw new Error(createBrowserWorkspaceDesktopOnlyMessage("snapshot"));
|
|
4168
|
-
}
|
|
4169
|
-
return await requestBrowserWorkspace(`/tabs/${encodeURIComponent(id)}/snapshot`, undefined, env);
|
|
209
|
+
return snapshotBrowserWorkspaceTabDesktop(id, env);
|
|
4170
210
|
}
|
|
211
|
+
// ────────────────────────────────────────────────────────────────────
|
|
212
|
+
// Main command router
|
|
213
|
+
// ────────────────────────────────────────────────────────────────────
|
|
4171
214
|
export async function executeBrowserWorkspaceCommand(command, env = process.env) {
|
|
4172
215
|
command = normalizeBrowserWorkspaceCommand(command);
|
|
4173
216
|
switch (command.subaction) {
|
|
@@ -4357,6 +400,7 @@ export async function executeBrowserWorkspaceCommand(command, env = process.env)
|
|
|
4357
400
|
const payload = { entries: target.entries };
|
|
4358
401
|
const filePath = command.filePath?.trim() || command.outputPath?.trim();
|
|
4359
402
|
if (filePath) {
|
|
403
|
+
const { writeBrowserWorkspaceFile } = await import("./browser-workspace-helpers.js");
|
|
4360
404
|
await writeBrowserWorkspaceFile(filePath, JSON.stringify(payload, null, 2));
|
|
4361
405
|
return {
|
|
4362
406
|
mode: "desktop",
|
|
@@ -4403,6 +447,7 @@ export async function executeBrowserWorkspaceCommand(command, env = process.env)
|
|
|
4403
447
|
const payload = await getDesktopBrowserWorkspaceSessionState(command, env);
|
|
4404
448
|
const filePath = command.filePath?.trim() || command.outputPath?.trim();
|
|
4405
449
|
if (filePath) {
|
|
450
|
+
const { writeBrowserWorkspaceFile } = await import("./browser-workspace-helpers.js");
|
|
4406
451
|
await writeBrowserWorkspaceFile(filePath, JSON.stringify(payload, null, 2));
|
|
4407
452
|
return {
|
|
4408
453
|
mode: "desktop",
|
|
@@ -4422,6 +467,7 @@ export async function executeBrowserWorkspaceCommand(command, env = process.env)
|
|
|
4422
467
|
}
|
|
4423
468
|
const snapshot = await getDesktopBrowserWorkspaceSnapshotRecord(command, env);
|
|
4424
469
|
const pdf = createBrowserWorkspacePdfBuffer(snapshot.title, snapshot.bodyText);
|
|
470
|
+
const { writeBrowserWorkspaceFile } = await import("./browser-workspace-helpers.js");
|
|
4425
471
|
const resolved = await writeBrowserWorkspaceFile(filePath, pdf);
|
|
4426
472
|
return {
|
|
4427
473
|
mode: "desktop",
|