@zyro-sec/gui-plugins 0.0.0-stage → 1.0.4
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/AGENTS.md +116 -0
- package/README.md +874 -3
- package/bunfig.toml +3 -0
- package/happydom.ts +77 -0
- package/package.json +63 -4
- package/src/browser/activation-delay.ts +134 -0
- package/src/browser/address-machine.ts +468 -0
- package/src/browser/address.ts +111 -0
- package/src/browser/agent-rendering.ts +61 -0
- package/src/browser/analysis.ts +260 -0
- package/src/browser/artifact-link.ts +69 -0
- package/src/browser/artifact-links.ts +55 -0
- package/src/browser/artifact-preview.ts +61 -0
- package/src/browser/assets/viewport-device-chevron.svg +5 -0
- package/src/browser/assets/viewport-rotate.svg +7 -0
- package/src/browser/bar.css +562 -0
- package/src/browser/capture.ts +158 -0
- package/src/browser/cdp.ts +97 -0
- package/src/browser/child-targets.ts +30 -0
- package/src/browser/choices.tsx +42 -0
- package/src/browser/chromium.ts +3018 -0
- package/src/browser/comment.css +38 -0
- package/src/browser/comment.ts +98 -0
- package/src/browser/connection.ts +122 -0
- package/src/browser/default-browser.ts +59 -0
- package/src/browser/diagnostics-machine.ts +522 -0
- package/src/browser/diagnostics.ts +317 -0
- package/src/browser/dialog-machine.ts +268 -0
- package/src/browser/disk/contained-file.ts +43 -0
- package/src/browser/disk/handle-path.fixture.ts +99 -0
- package/src/browser/disk/handle-path.ts +122 -0
- package/src/browser/disk/index.ts +5 -0
- package/src/browser/disk/preview-scope.ts +90 -0
- package/src/browser/electron-address.fixture.ts +143 -0
- package/src/browser/electron-app-badge.fixture.ts +97 -0
- package/src/browser/electron-crash.fixture.ts +216 -0
- package/src/browser/electron-dialogs.fixture.ts +114 -0
- package/src/browser/electron-history.fixture.ts +61 -0
- package/src/browser/electron-icon.fixture.ts +145 -0
- package/src/browser/electron-import-choice.fixture.ts +58 -0
- package/src/browser/electron-links.fixture.ts +549 -0
- package/src/browser/electron-main.ts +85 -0
- package/src/browser/electron-media.fixture.ts +66 -0
- package/src/browser/electron-open.fixture.ts +351 -0
- package/src/browser/electron-page.fixture.ts +253 -0
- package/src/browser/electron-restore.fixture.ts +135 -0
- package/src/browser/electron-run.ts +184 -0
- package/src/browser/electron-sign-in-copy.fixture.ts +365 -0
- package/src/browser/electron-webauthn.fixture.ts +229 -0
- package/src/browser/electron-workers.fixture.ts +54 -0
- package/src/browser/errors.ts +175 -0
- package/src/browser/failure-view.tsx +92 -0
- package/src/browser/failure.ts +174 -0
- package/src/browser/field-value.ts +60 -0
- package/src/browser/file-choosers.ts +42 -0
- package/src/browser/file-verification.ts +18 -0
- package/src/browser/files.ts +134 -0
- package/src/browser/find-bar.tsx +80 -0
- package/src/browser/find-machine.ts +43 -0
- package/src/browser/history/earlier.ts +23 -0
- package/src/browser/history/index.ts +5 -0
- package/src/browser/history/ipc.ts +44 -0
- package/src/browser/history/match.ts +196 -0
- package/src/browser/history/page.ts +86 -0
- package/src/browser/history/search.ts +209 -0
- package/src/browser/history/store.ts +272 -0
- package/src/browser/history/suggest.ts +51 -0
- package/src/browser/history/visits.ts +59 -0
- package/src/browser/host-display.ts +32 -0
- package/src/browser/i18n/am.ts +42 -0
- package/src/browser/i18n/ar.ts +46 -0
- package/src/browser/i18n/az.ts +42 -0
- package/src/browser/i18n/bg.ts +42 -0
- package/src/browser/i18n/bn.ts +42 -0
- package/src/browser/i18n/br.ts +44 -0
- package/src/browser/i18n/bs.ts +43 -0
- package/src/browser/i18n/ca.ts +44 -0
- package/src/browser/i18n/cs.ts +44 -0
- package/src/browser/i18n/da.ts +42 -0
- package/src/browser/i18n/de.ts +43 -0
- package/src/browser/i18n/dv.ts +43 -0
- package/src/browser/i18n/dz.ts +42 -0
- package/src/browser/i18n/el.ts +44 -0
- package/src/browser/i18n/en.ts +455 -0
- package/src/browser/i18n/es.ts +44 -0
- package/src/browser/i18n/et.ts +42 -0
- package/src/browser/i18n/fa.ts +42 -0
- package/src/browser/i18n/fi.ts +42 -0
- package/src/browser/i18n/fo.ts +42 -0
- package/src/browser/i18n/fr.ts +45 -0
- package/src/browser/i18n/he.ts +43 -0
- package/src/browser/i18n/hi.ts +42 -0
- package/src/browser/i18n/hr.ts +43 -0
- package/src/browser/i18n/hu.ts +43 -0
- package/src/browser/i18n/hy.ts +42 -0
- package/src/browser/i18n/id.ts +42 -0
- package/src/browser/i18n/is.ts +42 -0
- package/src/browser/i18n/it.ts +44 -0
- package/src/browser/i18n/ja.ts +42 -0
- package/src/browser/i18n/ka.ts +42 -0
- package/src/browser/i18n/km.ts +42 -0
- package/src/browser/i18n/ko.ts +42 -0
- package/src/browser/i18n/lo.ts +42 -0
- package/src/browser/i18n/lt.ts +44 -0
- package/src/browser/i18n/lv.ts +43 -0
- package/src/browser/i18n/mk.ts +42 -0
- package/src/browser/i18n/mn.ts +42 -0
- package/src/browser/i18n/ms.ts +42 -0
- package/src/browser/i18n/my.ts +43 -0
- package/src/browser/i18n/ne.ts +42 -0
- package/src/browser/i18n/nl.ts +42 -0
- package/src/browser/i18n/no.ts +42 -0
- package/src/browser/i18n/pa.ts +42 -0
- package/src/browser/i18n/pl.ts +44 -0
- package/src/browser/i18n/ro.ts +43 -0
- package/src/browser/i18n/ru.ts +44 -0
- package/src/browser/i18n/si.ts +42 -0
- package/src/browser/i18n/sk.ts +44 -0
- package/src/browser/i18n/sl.ts +44 -0
- package/src/browser/i18n/sq.ts +43 -0
- package/src/browser/i18n/sr.ts +43 -0
- package/src/browser/i18n/sv.ts +42 -0
- package/src/browser/i18n/tg.ts +42 -0
- package/src/browser/i18n/th.ts +42 -0
- package/src/browser/i18n/tk.ts +42 -0
- package/src/browser/i18n/tr.ts +42 -0
- package/src/browser/i18n/uk.ts +44 -0
- package/src/browser/i18n/ur.ts +42 -0
- package/src/browser/i18n/uz.ts +42 -0
- package/src/browser/i18n/vi.ts +42 -0
- package/src/browser/i18n/zh.ts +42 -0
- package/src/browser/i18n/zht.ts +42 -0
- package/src/browser/icon-image.ts +110 -0
- package/src/browser/icon-samples.ts +110 -0
- package/src/browser/icon.ts +72 -0
- package/src/browser/import-prompt.tsx +265 -0
- package/src/browser/index.ts +97 -0
- package/src/browser/ipc.ts +304 -0
- package/src/browser/jobs-machine.ts +181 -0
- package/src/browser/jobs.ts +373 -0
- package/src/browser/keys.ts +109 -0
- package/src/browser/lighthouse.ts +103 -0
- package/src/browser/link.ts +19 -0
- package/src/browser/machine.ts +1522 -0
- package/src/browser/main-machine.ts +99 -0
- package/src/browser/main.ts +394 -0
- package/src/browser/media-gate.ts +131 -0
- package/src/browser/mobile-emulation.ts +121 -0
- package/src/browser/model-machine.ts +93 -0
- package/src/browser/model.ts +1173 -0
- package/src/browser/native-page-menu.ts +189 -0
- package/src/browser/navigation-deadline.ts +20 -0
- package/src/browser/navigation-turn.ts +118 -0
- package/src/browser/network.ts +140 -0
- package/src/browser/notice-actions.ts +52 -0
- package/src/browser/overlay-machine.ts +330 -0
- package/src/browser/page-find.ts +71 -0
- package/src/browser/page-icon.tsx +27 -0
- package/src/browser/page-log.ts +276 -0
- package/src/browser/page-machine.ts +329 -0
- package/src/browser/page-menu.ts +158 -0
- package/src/browser/page-prompts.ts +753 -0
- package/src/browser/pane-machine.ts +664 -0
- package/src/browser/pane.ts +1335 -0
- package/src/browser/panel.fixture.tsx +2046 -0
- package/src/browser/panel.stories.tsx +147 -0
- package/src/browser/panel.tsx +2029 -0
- package/src/browser/passkey-groups.ts +34 -0
- package/src/browser/picker-machine.ts +214 -0
- package/src/browser/plugin-tabs.ts +26 -0
- package/src/browser/policy.ts +439 -0
- package/src/browser/preview.ts +40 -0
- package/src/browser/profile/chromium.ts +198 -0
- package/src/browser/profile/compatibility.ts +177 -0
- package/src/browser/profile/cookie.ts +215 -0
- package/src/browser/profile/database.ts +116 -0
- package/src/browser/profile/electron-import.fixture.ts +43 -0
- package/src/browser/profile/electron-link.fixture.ts +137 -0
- package/src/browser/profile/extension-api/action.ts +276 -0
- package/src/browser/profile/extension-api/api.ts +112 -0
- package/src/browser/profile/extension-api/app-badge.js +19 -0
- package/src/browser/profile/extension-api/context-menus.ts +327 -0
- package/src/browser/profile/extension-api/cookies.ts +192 -0
- package/src/browser/profile/extension-api/event-page.ts +73 -0
- package/src/browser/profile/extension-api/frame-styles.js +46 -0
- package/src/browser/profile/extension-api/host.ts +291 -0
- package/src/browser/profile/extension-api/index.ts +119 -0
- package/src/browser/profile/extension-api/label.ts +4 -0
- package/src/browser/profile/extension-api/manifest.ts +76 -0
- package/src/browser/profile/extension-api/match-pattern.ts +98 -0
- package/src/browser/profile/extension-api/notifications.ts +100 -0
- package/src/browser/profile/extension-api/permissions.ts +51 -0
- package/src/browser/profile/extension-api/popup.ts +200 -0
- package/src/browser/profile/extension-api/preload.js +203 -0
- package/src/browser/profile/extension-api/resource.ts +36 -0
- package/src/browser/profile/extension-api/storage-sync.ts +167 -0
- package/src/browser/profile/extension-api/stubs.ts +152 -0
- package/src/browser/profile/extension-api/styles.ts +230 -0
- package/src/browser/profile/extension-api/tab-activity.ts +23 -0
- package/src/browser/profile/extension-api/tabs.ts +545 -0
- package/src/browser/profile/extension-api/web-navigation.ts +172 -0
- package/src/browser/profile/extension-api/worker-events.ts +114 -0
- package/src/browser/profile/extensions.ts +491 -0
- package/src/browser/profile/filter-startup.fixture.ts +111 -0
- package/src/browser/profile/filter-startup.ts +178 -0
- package/src/browser/profile/firefox.ts +119 -0
- package/src/browser/profile/history.ts +146 -0
- package/src/browser/profile/import.ts +37 -0
- package/src/browser/profile/index.ts +694 -0
- package/src/browser/profile/install.ts +131 -0
- package/src/browser/profile/integrity.ts +56 -0
- package/src/browser/profile/ipc.ts +306 -0
- package/src/browser/profile/link-machine.ts +183 -0
- package/src/browser/profile/link.ts +335 -0
- package/src/browser/profile/made-up-firefox.fixture.ts +67 -0
- package/src/browser/profile/previews.ts +70 -0
- package/src/browser/profile/probe.ts +43 -0
- package/src/browser/profile/range.ts +14 -0
- package/src/browser/profile/review.ts +38 -0
- package/src/browser/profile/safari.ts +77 -0
- package/src/browser/profile/serve.ts +117 -0
- package/src/browser/profile/sites.ts +74 -0
- package/src/browser/profile/sources.ts +682 -0
- package/src/browser/profiling-machine.ts +554 -0
- package/src/browser/profiling.ts +404 -0
- package/src/browser/prompt-gate.ts +41 -0
- package/src/browser/prompt-keys.ts +120 -0
- package/src/browser/prompt-machine.ts +242 -0
- package/src/browser/prompts.tsx +594 -0
- package/src/browser/refs.ts +65 -0
- package/src/browser/refusal-bar.tsx +163 -0
- package/src/browser/refusal-notice.ts +60 -0
- package/src/browser/remote-address.ts +1 -0
- package/src/browser/remote-preview.ts +56 -0
- package/src/browser/renderer.tsx +683 -0
- package/src/browser/restore.ts +77 -0
- package/src/browser/saved-tabs.ts +135 -0
- package/src/browser/scheme.ts +1 -0
- package/src/browser/session-guard.ts +94 -0
- package/src/browser/settings-view.ts +49 -0
- package/src/browser/settings.fixture.tsx +306 -0
- package/src/browser/settings.tsx +1036 -0
- package/src/browser/site-auth.ts +58 -0
- package/src/browser/site-chooser.fixture.tsx +222 -0
- package/src/browser/site-chooser.tsx +778 -0
- package/src/browser/site-keys.ts +35 -0
- package/src/browser/site-machine.ts +134 -0
- package/src/browser/site-permissions.ts +239 -0
- package/src/browser/site-search.ts +26 -0
- package/src/browser/snapshot.ts +440 -0
- package/src/browser/system-media.ts +80 -0
- package/src/browser/tab-openers.ts +65 -0
- package/src/browser/tabs.css +20 -0
- package/src/browser/viewport-controls-machine.ts +134 -0
- package/src/browser/viewport-controls.tsx +170 -0
- package/src/browser/viewport-handles.tsx +119 -0
- package/src/browser/viewport-layout.ts +24 -0
- package/src/browser/viewport-native.ts +99 -0
- package/src/browser/viewport-preset-menu.tsx +69 -0
- package/src/browser/viewport-presets.ts +28 -0
- package/src/browser/viewport-toolbar-machine.ts +94 -0
- package/src/browser/webauthn-gate.ts +222 -0
- package/src/browser/window-open.ts +143 -0
- package/src/browser/wire.ts +20 -0
- package/src/browser/workspace-file.ts +126 -0
- package/src/browser/workspace-pages.ts +156 -0
- package/src/btw/i18n/en.ts +12 -0
- package/src/btw/index.ts +31 -0
- package/src/btw/machine.ts +341 -0
- package/src/btw/model.ts +222 -0
- package/src/btw/panel.tsx +229 -0
- package/src/btw/renderer.tsx +125 -0
- package/src/context/catalog-machine.ts +153 -0
- package/src/context/catalog.ts +123 -0
- package/src/context/export.ts +57 -0
- package/src/context/format.ts +32 -0
- package/src/context/i18n/am.ts +31 -0
- package/src/context/i18n/ar.ts +31 -0
- package/src/context/i18n/az.ts +31 -0
- package/src/context/i18n/bg.ts +31 -0
- package/src/context/i18n/bn.ts +31 -0
- package/src/context/i18n/br.ts +31 -0
- package/src/context/i18n/bs.ts +31 -0
- package/src/context/i18n/ca.ts +31 -0
- package/src/context/i18n/cs.ts +31 -0
- package/src/context/i18n/da.ts +31 -0
- package/src/context/i18n/de.ts +31 -0
- package/src/context/i18n/dv.ts +31 -0
- package/src/context/i18n/dz.ts +31 -0
- package/src/context/i18n/el.ts +31 -0
- package/src/context/i18n/en.ts +31 -0
- package/src/context/i18n/es.ts +31 -0
- package/src/context/i18n/et.ts +31 -0
- package/src/context/i18n/fa.ts +31 -0
- package/src/context/i18n/fi.ts +31 -0
- package/src/context/i18n/fo.ts +31 -0
- package/src/context/i18n/fr.ts +31 -0
- package/src/context/i18n/he.ts +31 -0
- package/src/context/i18n/hi.ts +31 -0
- package/src/context/i18n/hr.ts +31 -0
- package/src/context/i18n/hu.ts +31 -0
- package/src/context/i18n/hy.ts +31 -0
- package/src/context/i18n/id.ts +31 -0
- package/src/context/i18n/is.ts +31 -0
- package/src/context/i18n/it.ts +31 -0
- package/src/context/i18n/ja.ts +31 -0
- package/src/context/i18n/ka.ts +31 -0
- package/src/context/i18n/km.ts +31 -0
- package/src/context/i18n/ko.ts +31 -0
- package/src/context/i18n/lo.ts +31 -0
- package/src/context/i18n/lt.ts +31 -0
- package/src/context/i18n/lv.ts +31 -0
- package/src/context/i18n/mk.ts +31 -0
- package/src/context/i18n/mn.ts +31 -0
- package/src/context/i18n/ms.ts +31 -0
- package/src/context/i18n/my.ts +31 -0
- package/src/context/i18n/ne.ts +31 -0
- package/src/context/i18n/nl.ts +31 -0
- package/src/context/i18n/no.ts +31 -0
- package/src/context/i18n/pa.ts +31 -0
- package/src/context/i18n/pl.ts +31 -0
- package/src/context/i18n/ro.ts +31 -0
- package/src/context/i18n/ru.ts +31 -0
- package/src/context/i18n/si.ts +31 -0
- package/src/context/i18n/sk.ts +31 -0
- package/src/context/i18n/sl.ts +31 -0
- package/src/context/i18n/sq.ts +31 -0
- package/src/context/i18n/sr.ts +31 -0
- package/src/context/i18n/sv.ts +31 -0
- package/src/context/i18n/tg.ts +31 -0
- package/src/context/i18n/th.ts +31 -0
- package/src/context/i18n/tk.ts +31 -0
- package/src/context/i18n/tr.ts +31 -0
- package/src/context/i18n/uk.ts +31 -0
- package/src/context/i18n/ur.ts +31 -0
- package/src/context/i18n/uz.ts +31 -0
- package/src/context/i18n/vi.ts +31 -0
- package/src/context/i18n/zh.ts +31 -0
- package/src/context/i18n/zht.ts +31 -0
- package/src/context/index.ts +71 -0
- package/src/context/indicator.tsx +199 -0
- package/src/context/machine.ts +271 -0
- package/src/context/renderer.tsx +72 -0
- package/src/context/tab.tsx +439 -0
- package/src/debug/bar.tsx +409 -0
- package/src/debug/contract.ts +45 -0
- package/src/debug/focus-machine.ts +84 -0
- package/src/debug/heap-machine.ts +229 -0
- package/src/debug/i18n/am.ts +50 -0
- package/src/debug/i18n/ar.ts +50 -0
- package/src/debug/i18n/az.ts +50 -0
- package/src/debug/i18n/bg.ts +53 -0
- package/src/debug/i18n/bn.ts +50 -0
- package/src/debug/i18n/br.ts +51 -0
- package/src/debug/i18n/bs.ts +52 -0
- package/src/debug/i18n/ca.ts +53 -0
- package/src/debug/i18n/cs.ts +52 -0
- package/src/debug/i18n/da.ts +51 -0
- package/src/debug/i18n/de.ts +50 -0
- package/src/debug/i18n/dv.ts +51 -0
- package/src/debug/i18n/dz.ts +52 -0
- package/src/debug/i18n/el.ts +54 -0
- package/src/debug/i18n/en.ts +50 -0
- package/src/debug/i18n/es.ts +52 -0
- package/src/debug/i18n/et.ts +50 -0
- package/src/debug/i18n/fa.ts +50 -0
- package/src/debug/i18n/fi.ts +50 -0
- package/src/debug/i18n/fo.ts +50 -0
- package/src/debug/i18n/fr.ts +52 -0
- package/src/debug/i18n/he.ts +50 -0
- package/src/debug/i18n/hi.ts +50 -0
- package/src/debug/i18n/hr.ts +52 -0
- package/src/debug/i18n/hu.ts +52 -0
- package/src/debug/i18n/hy.ts +52 -0
- package/src/debug/i18n/id.ts +51 -0
- package/src/debug/i18n/is.ts +50 -0
- package/src/debug/i18n/it.ts +52 -0
- package/src/debug/i18n/ja.ts +50 -0
- package/src/debug/i18n/ka.ts +50 -0
- package/src/debug/i18n/km.ts +50 -0
- package/src/debug/i18n/ko.ts +50 -0
- package/src/debug/i18n/lo.ts +50 -0
- package/src/debug/i18n/lt.ts +51 -0
- package/src/debug/i18n/lv.ts +50 -0
- package/src/debug/i18n/mk.ts +53 -0
- package/src/debug/i18n/mn.ts +52 -0
- package/src/debug/i18n/ms.ts +51 -0
- package/src/debug/i18n/my.ts +53 -0
- package/src/debug/i18n/ne.ts +50 -0
- package/src/debug/i18n/nl.ts +50 -0
- package/src/debug/i18n/no.ts +50 -0
- package/src/debug/i18n/pa.ts +50 -0
- package/src/debug/i18n/pl.ts +51 -0
- package/src/debug/i18n/ro.ts +52 -0
- package/src/debug/i18n/ru.ts +51 -0
- package/src/debug/i18n/si.ts +50 -0
- package/src/debug/i18n/sk.ts +52 -0
- package/src/debug/i18n/sl.ts +50 -0
- package/src/debug/i18n/sq.ts +52 -0
- package/src/debug/i18n/sr.ts +52 -0
- package/src/debug/i18n/sv.ts +51 -0
- package/src/debug/i18n/tg.ts +51 -0
- package/src/debug/i18n/th.ts +50 -0
- package/src/debug/i18n/tk.ts +51 -0
- package/src/debug/i18n/tr.ts +50 -0
- package/src/debug/i18n/uk.ts +50 -0
- package/src/debug/i18n/ur.ts +50 -0
- package/src/debug/i18n/uz.ts +51 -0
- package/src/debug/i18n/vi.ts +51 -0
- package/src/debug/i18n/zh.ts +49 -0
- package/src/debug/i18n/zht.ts +50 -0
- package/src/debug/index.ts +79 -0
- package/src/debug/main.ts +417 -0
- package/src/debug/memory-infra.ts +159 -0
- package/src/debug/memory-log.ts +65 -0
- package/src/debug/memory-machine.ts +151 -0
- package/src/debug/memory-record.ts +36 -0
- package/src/debug/motion-machine.ts +229 -0
- package/src/debug/motion.tsx +697 -0
- package/src/debug/options.ts +15 -0
- package/src/debug/renderer.tsx +185 -0
- package/src/debug/server-heap.ts +63 -0
- package/src/debug/signal.ts +13 -0
- package/src/details/config-action-machine.ts +107 -0
- package/src/details/config-file.ts +43 -0
- package/src/details/details.css +555 -0
- package/src/details/flyout-machine.ts +252 -0
- package/src/details/flyout-motion.ts +26 -0
- package/src/details/i18n/am.ts +68 -0
- package/src/details/i18n/ar.ts +71 -0
- package/src/details/i18n/az.ts +71 -0
- package/src/details/i18n/bg.ts +73 -0
- package/src/details/i18n/bn.ts +71 -0
- package/src/details/i18n/br.ts +71 -0
- package/src/details/i18n/bs.ts +72 -0
- package/src/details/i18n/ca.ts +72 -0
- package/src/details/i18n/cs.ts +71 -0
- package/src/details/i18n/da.ts +71 -0
- package/src/details/i18n/de.ts +73 -0
- package/src/details/i18n/dv.ts +73 -0
- package/src/details/i18n/dz.ts +72 -0
- package/src/details/i18n/el.ts +73 -0
- package/src/details/i18n/en.ts +71 -0
- package/src/details/i18n/es.ts +72 -0
- package/src/details/i18n/et.ts +72 -0
- package/src/details/i18n/fa.ts +71 -0
- package/src/details/i18n/fi.ts +71 -0
- package/src/details/i18n/fo.ts +72 -0
- package/src/details/i18n/fr.ts +73 -0
- package/src/details/i18n/he.ts +71 -0
- package/src/details/i18n/hi.ts +71 -0
- package/src/details/i18n/hr.ts +72 -0
- package/src/details/i18n/hu.ts +72 -0
- package/src/details/i18n/hy.ts +72 -0
- package/src/details/i18n/id.ts +71 -0
- package/src/details/i18n/is.ts +71 -0
- package/src/details/i18n/it.ts +73 -0
- package/src/details/i18n/ja.ts +71 -0
- package/src/details/i18n/ka.ts +72 -0
- package/src/details/i18n/km.ts +72 -0
- package/src/details/i18n/ko.ts +71 -0
- package/src/details/i18n/lo.ts +72 -0
- package/src/details/i18n/lt.ts +72 -0
- package/src/details/i18n/lv.ts +72 -0
- package/src/details/i18n/mk.ts +73 -0
- package/src/details/i18n/mn.ts +71 -0
- package/src/details/i18n/ms.ts +71 -0
- package/src/details/i18n/my.ts +72 -0
- package/src/details/i18n/ne.ts +71 -0
- package/src/details/i18n/nl.ts +71 -0
- package/src/details/i18n/no.ts +71 -0
- package/src/details/i18n/pa.ts +71 -0
- package/src/details/i18n/pl.ts +72 -0
- package/src/details/i18n/ro.ts +72 -0
- package/src/details/i18n/ru.ts +72 -0
- package/src/details/i18n/si.ts +71 -0
- package/src/details/i18n/sk.ts +71 -0
- package/src/details/i18n/sl.ts +73 -0
- package/src/details/i18n/sq.ts +71 -0
- package/src/details/i18n/sr.ts +72 -0
- package/src/details/i18n/sv.ts +72 -0
- package/src/details/i18n/tg.ts +71 -0
- package/src/details/i18n/th.ts +72 -0
- package/src/details/i18n/tk.ts +72 -0
- package/src/details/i18n/tr.ts +71 -0
- package/src/details/i18n/uk.ts +71 -0
- package/src/details/i18n/ur.ts +71 -0
- package/src/details/i18n/uz.ts +72 -0
- package/src/details/i18n/vi.ts +71 -0
- package/src/details/i18n/zh.ts +69 -0
- package/src/details/i18n/zht.ts +70 -0
- package/src/details/index.ts +71 -0
- package/src/details/location-menu.tsx +82 -0
- package/src/details/location-workspace.tsx +39 -0
- package/src/details/mcp-machine.ts +278 -0
- package/src/details/panel.tsx +27 -0
- package/src/details/paths.ts +17 -0
- package/src/details/popover-machine.ts +97 -0
- package/src/details/popover.tsx +179 -0
- package/src/details/renderer.tsx +99 -0
- package/src/details/server-panel.tsx +1632 -0
- package/src/details/service-load-machine.ts +246 -0
- package/src/details/workspace-menu.tsx +490 -0
- package/src/details/workspace-move-machine.ts +643 -0
- package/src/file/apps.ts +25 -0
- package/src/file/arrival-guard-machine.ts +59 -0
- package/src/file/artifact-toolbar.tsx +161 -0
- package/src/file/artifact-view-machine.ts +396 -0
- package/src/file/artifact-view.css +336 -0
- package/src/file/artifact-view.tsx +1031 -0
- package/src/file/artifact.ts +225 -0
- package/src/file/browser.stories.tsx +57 -0
- package/src/file/browser.tsx +502 -0
- package/src/file/context.ts +67 -0
- package/src/file/contract.ts +10 -0
- package/src/file/drag.ts +35 -0
- package/src/file/find.tsx +376 -0
- package/src/file/i18n/am.ts +56 -0
- package/src/file/i18n/ar.ts +64 -0
- package/src/file/i18n/az.ts +56 -0
- package/src/file/i18n/bg.ts +56 -0
- package/src/file/i18n/bn.ts +56 -0
- package/src/file/i18n/br.ts +58 -0
- package/src/file/i18n/bs.ts +58 -0
- package/src/file/i18n/ca.ts +58 -0
- package/src/file/i18n/cs.ts +60 -0
- package/src/file/i18n/da.ts +56 -0
- package/src/file/i18n/de.ts +56 -0
- package/src/file/i18n/dv.ts +56 -0
- package/src/file/i18n/dz.ts +56 -0
- package/src/file/i18n/el.ts +56 -0
- package/src/file/i18n/en.ts +63 -0
- package/src/file/i18n/es.ts +58 -0
- package/src/file/i18n/et.ts +56 -0
- package/src/file/i18n/fa.ts +56 -0
- package/src/file/i18n/fi.ts +56 -0
- package/src/file/i18n/fo.ts +56 -0
- package/src/file/i18n/fr.ts +58 -0
- package/src/file/i18n/he.ts +58 -0
- package/src/file/i18n/hi.ts +56 -0
- package/src/file/i18n/hr.ts +58 -0
- package/src/file/i18n/hu.ts +56 -0
- package/src/file/i18n/hy.ts +56 -0
- package/src/file/i18n/id.ts +56 -0
- package/src/file/i18n/is.ts +56 -0
- package/src/file/i18n/it.ts +58 -0
- package/src/file/i18n/ja.ts +56 -0
- package/src/file/i18n/ka.ts +56 -0
- package/src/file/i18n/km.ts +56 -0
- package/src/file/i18n/ko.ts +56 -0
- package/src/file/i18n/lo.ts +56 -0
- package/src/file/i18n/lt.ts +60 -0
- package/src/file/i18n/lv.ts +58 -0
- package/src/file/i18n/mk.ts +56 -0
- package/src/file/i18n/mn.ts +56 -0
- package/src/file/i18n/ms.ts +56 -0
- package/src/file/i18n/my.ts +56 -0
- package/src/file/i18n/ne.ts +56 -0
- package/src/file/i18n/nl.ts +56 -0
- package/src/file/i18n/no.ts +56 -0
- package/src/file/i18n/pa.ts +56 -0
- package/src/file/i18n/pl.ts +60 -0
- package/src/file/i18n/ro.ts +58 -0
- package/src/file/i18n/ru.ts +60 -0
- package/src/file/i18n/si.ts +56 -0
- package/src/file/i18n/sk.ts +60 -0
- package/src/file/i18n/sl.ts +60 -0
- package/src/file/i18n/sq.ts +56 -0
- package/src/file/i18n/sr.ts +58 -0
- package/src/file/i18n/sv.ts +56 -0
- package/src/file/i18n/tg.ts +56 -0
- package/src/file/i18n/th.ts +56 -0
- package/src/file/i18n/tk.ts +56 -0
- package/src/file/i18n/tr.ts +56 -0
- package/src/file/i18n/uk.ts +60 -0
- package/src/file/i18n/ur.ts +57 -0
- package/src/file/i18n/uz.ts +56 -0
- package/src/file/i18n/vi.ts +56 -0
- package/src/file/i18n/zh.ts +56 -0
- package/src/file/i18n/zht.ts +56 -0
- package/src/file/index.ts +76 -0
- package/src/file/label.tsx +22 -0
- package/src/file/link-exists-machine.ts +137 -0
- package/src/file/link-open-machine.ts +249 -0
- package/src/file/list.tsx +224 -0
- package/src/file/mobile.css +35 -0
- package/src/file/mobile.tsx +116 -0
- package/src/file/open-in-app-machine.ts +185 -0
- package/src/file/open-in-app.tsx +395 -0
- package/src/file/path.ts +43 -0
- package/src/file/picker-machine.ts +190 -0
- package/src/file/pierre-tree-machine.ts +679 -0
- package/src/file/pierre-tree.tsx +503 -0
- package/src/file/renderer.tsx +1030 -0
- package/src/file/resolve-link.ts +152 -0
- package/src/file/scroll-machine.ts +272 -0
- package/src/file/search-machine.ts +202 -0
- package/src/file/styles.ts +5 -0
- package/src/file/tabs.css +15 -0
- package/src/file/tree-focus.css +6 -0
- package/src/file/tree-model.ts +239 -0
- package/src/file/view.tsx +572 -0
- package/src/goal/goal.css +43 -0
- package/src/goal/i18n/en.ts +12 -0
- package/src/goal/icons/active.svg +13 -0
- package/src/goal/icons/complete.svg +4 -0
- package/src/goal/icons/paused.svg +4 -0
- package/src/goal/index.ts +9 -0
- package/src/goal/machine.ts +364 -0
- package/src/goal/renderer.tsx +287 -0
- package/src/icon-name.typecheck.ts +9 -0
- package/src/main.ts +35 -0
- package/src/microsoft-office/document.tsx +436 -0
- package/src/microsoft-office/document.worker.ts +360 -0
- package/src/microsoft-office/fonts-cjk.ts +3 -0
- package/src/microsoft-office/fonts.ts +75 -0
- package/src/microsoft-office/i18n/en.ts +22 -0
- package/src/microsoft-office/index.ts +7 -0
- package/src/microsoft-office/links.ts +22 -0
- package/src/microsoft-office/office-worker.ts +124 -0
- package/src/microsoft-office/pages-machine.ts +356 -0
- package/src/microsoft-office/pages.tsx +387 -0
- package/src/microsoft-office/paper.ts +2 -0
- package/src/microsoft-office/presentation.tsx +303 -0
- package/src/microsoft-office/presentation.worker.ts +373 -0
- package/src/microsoft-office/renderer.tsx +57 -0
- package/src/microsoft-office/sheet-activate.ts +35 -0
- package/src/microsoft-office/sheet-cells.ts +188 -0
- package/src/microsoft-office/sheet-frame-machine.ts +286 -0
- package/src/microsoft-office/sheet-frame.ts +158 -0
- package/src/microsoft-office/sheet-paint.ts +357 -0
- package/src/microsoft-office/sheet-pick-machine.ts +138 -0
- package/src/microsoft-office/sheet-pointer-machine.ts +169 -0
- package/src/microsoft-office/sheet-protocol.ts +88 -0
- package/src/microsoft-office/slide-fonts-machine.ts +290 -0
- package/src/microsoft-office/slide-fonts.ts +157 -0
- package/src/microsoft-office/slide-paint-machine.ts +322 -0
- package/src/microsoft-office/slide-protocol.ts +50 -0
- package/src/microsoft-office/slide-text.ts +334 -0
- package/src/microsoft-office/spreadsheet.tsx +1165 -0
- package/src/microsoft-office/spreadsheet.worker.ts +259 -0
- package/src/microsoft-office/word-images.ts +105 -0
- package/src/microsoft-office/word-layout-machine.ts +219 -0
- package/src/microsoft-office/word-paint-machine.ts +174 -0
- package/src/microsoft-office/word-protocol.ts +78 -0
- package/src/microsoft-office/word-text.ts +260 -0
- package/src/microsoft-office/worker-machine.ts +111 -0
- package/src/microsoft-office/worker-rpc-machine.ts +336 -0
- package/src/microsoft-office/worker-rpc.fixture.ts +90 -0
- package/src/microsoft-office/worker-rpc.ts +292 -0
- package/src/pairing/contract.ts +24 -0
- package/src/pairing/copy-machine.ts +107 -0
- package/src/pairing/dialog.stories.tsx +69 -0
- package/src/pairing/dispatch.ts +42 -0
- package/src/pairing/i18n/en.ts +28 -0
- package/src/pairing/icons/pair.svg +4 -0
- package/src/pairing/index.ts +5 -0
- package/src/pairing/machine.ts +869 -0
- package/src/pairing/main-machine.ts +239 -0
- package/src/pairing/main.ts +130 -0
- package/src/pairing/page.stories.tsx +108 -0
- package/src/pairing/page.tsx +486 -0
- package/src/pairing/remote.ts +7 -0
- package/src/pairing/renderer.tsx +66 -0
- package/src/renderer.ts +55 -0
- package/src/review/contract.ts +31 -0
- package/src/review/detail-machine.ts +250 -0
- package/src/review/folder-machine.ts +404 -0
- package/src/review/i18n/am.ts +23 -0
- package/src/review/i18n/ar.ts +35 -0
- package/src/review/i18n/az.ts +23 -0
- package/src/review/i18n/bg.ts +23 -0
- package/src/review/i18n/bn.ts +23 -0
- package/src/review/i18n/br.ts +27 -0
- package/src/review/i18n/bs.ts +26 -0
- package/src/review/i18n/ca.ts +27 -0
- package/src/review/i18n/cs.ts +29 -0
- package/src/review/i18n/da.ts +23 -0
- package/src/review/i18n/de.ts +23 -0
- package/src/review/i18n/dv.ts +24 -0
- package/src/review/i18n/dz.ts +24 -0
- package/src/review/i18n/el.ts +23 -0
- package/src/review/i18n/en.ts +28 -0
- package/src/review/i18n/es.ts +27 -0
- package/src/review/i18n/et.ts +23 -0
- package/src/review/i18n/fa.ts +23 -0
- package/src/review/i18n/fi.ts +23 -0
- package/src/review/i18n/fo.ts +23 -0
- package/src/review/i18n/fr.ts +27 -0
- package/src/review/i18n/he.ts +26 -0
- package/src/review/i18n/hi.ts +23 -0
- package/src/review/i18n/hr.ts +26 -0
- package/src/review/i18n/hu.ts +23 -0
- package/src/review/i18n/hy.ts +23 -0
- package/src/review/i18n/id.ts +24 -0
- package/src/review/i18n/is.ts +23 -0
- package/src/review/i18n/it.ts +27 -0
- package/src/review/i18n/ja.ts +23 -0
- package/src/review/i18n/ka.ts +23 -0
- package/src/review/i18n/km.ts +23 -0
- package/src/review/i18n/ko.ts +23 -0
- package/src/review/i18n/lo.ts +23 -0
- package/src/review/i18n/lt.ts +29 -0
- package/src/review/i18n/lv.ts +26 -0
- package/src/review/i18n/mk.ts +23 -0
- package/src/review/i18n/mn.ts +23 -0
- package/src/review/i18n/ms.ts +24 -0
- package/src/review/i18n/my.ts +24 -0
- package/src/review/i18n/ne.ts +23 -0
- package/src/review/i18n/nl.ts +23 -0
- package/src/review/i18n/no.ts +23 -0
- package/src/review/i18n/pa.ts +23 -0
- package/src/review/i18n/pl.ts +29 -0
- package/src/review/i18n/ro.ts +26 -0
- package/src/review/i18n/ru.ts +29 -0
- package/src/review/i18n/si.ts +23 -0
- package/src/review/i18n/sk.ts +29 -0
- package/src/review/i18n/sl.ts +29 -0
- package/src/review/i18n/sq.ts +24 -0
- package/src/review/i18n/sr.ts +27 -0
- package/src/review/i18n/sv.ts +23 -0
- package/src/review/i18n/tg.ts +23 -0
- package/src/review/i18n/th.ts +23 -0
- package/src/review/i18n/tk.ts +23 -0
- package/src/review/i18n/tr.ts +23 -0
- package/src/review/i18n/uk.ts +30 -0
- package/src/review/i18n/ur.ts +23 -0
- package/src/review/i18n/uz.ts +23 -0
- package/src/review/i18n/vi.ts +24 -0
- package/src/review/i18n/zh.ts +23 -0
- package/src/review/i18n/zht.ts +23 -0
- package/src/review/index.ts +138 -0
- package/src/review/init-git-machine.ts +152 -0
- package/src/review/kinds.ts +191 -0
- package/src/review/machine.ts +274 -0
- package/src/review/mobile.tsx +91 -0
- package/src/review/model.ts +1123 -0
- package/src/review/panel.stories.tsx +50 -0
- package/src/review/panel.tsx +516 -0
- package/src/review/parts.tsx +141 -0
- package/src/review/render-machine.ts +74 -0
- package/src/review/renderer.tsx +403 -0
- package/src/review/screen-machine.ts +199 -0
- package/src/review/scroll-machine.ts +265 -0
- package/src/review/settings.tsx +28 -0
- package/src/schemes.ts +9 -0
- package/src/sources/i18n/en.ts +3 -0
- package/src/sources/index.ts +4 -0
- package/src/sources/panel.tsx +36 -0
- package/src/sources/renderer.tsx +95 -0
- package/src/ssh/add-machine.ts +63 -0
- package/src/ssh/askpass.ts +94 -0
- package/src/ssh/bootstrap.ts +160 -0
- package/src/ssh/command.ts +243 -0
- package/src/ssh/contract.ts +89 -0
- package/src/ssh/controller.ts +345 -0
- package/src/ssh/cover.tsx +66 -0
- package/src/ssh/dialog-machine.ts +249 -0
- package/src/ssh/dialog.stories.tsx +348 -0
- package/src/ssh/dialog.tsx +236 -0
- package/src/ssh/i18n/am.ts +37 -0
- package/src/ssh/i18n/ar.ts +38 -0
- package/src/ssh/i18n/az.ts +43 -0
- package/src/ssh/i18n/bg.ts +42 -0
- package/src/ssh/i18n/bn.ts +41 -0
- package/src/ssh/i18n/br.ts +43 -0
- package/src/ssh/i18n/bs.ts +43 -0
- package/src/ssh/i18n/ca.ts +43 -0
- package/src/ssh/i18n/cs.ts +43 -0
- package/src/ssh/i18n/da.ts +43 -0
- package/src/ssh/i18n/de.ts +44 -0
- package/src/ssh/i18n/dv.ts +43 -0
- package/src/ssh/i18n/dz.ts +43 -0
- package/src/ssh/i18n/el.ts +45 -0
- package/src/ssh/i18n/en.ts +40 -0
- package/src/ssh/i18n/es.ts +43 -0
- package/src/ssh/i18n/et.ts +41 -0
- package/src/ssh/i18n/fa.ts +39 -0
- package/src/ssh/i18n/fi.ts +40 -0
- package/src/ssh/i18n/fo.ts +41 -0
- package/src/ssh/i18n/fr.ts +43 -0
- package/src/ssh/i18n/he.ts +37 -0
- package/src/ssh/i18n/hi.ts +40 -0
- package/src/ssh/i18n/hr.ts +43 -0
- package/src/ssh/i18n/hu.ts +43 -0
- package/src/ssh/i18n/hy.ts +41 -0
- package/src/ssh/i18n/id.ts +42 -0
- package/src/ssh/i18n/is.ts +40 -0
- package/src/ssh/i18n/it.ts +43 -0
- package/src/ssh/i18n/ja.ts +43 -0
- package/src/ssh/i18n/ka.ts +43 -0
- package/src/ssh/i18n/km.ts +41 -0
- package/src/ssh/i18n/ko.ts +40 -0
- package/src/ssh/i18n/lo.ts +39 -0
- package/src/ssh/i18n/lt.ts +41 -0
- package/src/ssh/i18n/lv.ts +42 -0
- package/src/ssh/i18n/mk.ts +43 -0
- package/src/ssh/i18n/mn.ts +41 -0
- package/src/ssh/i18n/ms.ts +40 -0
- package/src/ssh/i18n/my.ts +41 -0
- package/src/ssh/i18n/ne.ts +39 -0
- package/src/ssh/i18n/nl.ts +43 -0
- package/src/ssh/i18n/no.ts +42 -0
- package/src/ssh/i18n/pa.ts +40 -0
- package/src/ssh/i18n/pl.ts +42 -0
- package/src/ssh/i18n/ro.ts +44 -0
- package/src/ssh/i18n/ru.ts +42 -0
- package/src/ssh/i18n/si.ts +41 -0
- package/src/ssh/i18n/sk.ts +42 -0
- package/src/ssh/i18n/sl.ts +41 -0
- package/src/ssh/i18n/sq.ts +43 -0
- package/src/ssh/i18n/sr.ts +41 -0
- package/src/ssh/i18n/sv.ts +43 -0
- package/src/ssh/i18n/tg.ts +43 -0
- package/src/ssh/i18n/th.ts +38 -0
- package/src/ssh/i18n/tk.ts +41 -0
- package/src/ssh/i18n/tr.ts +42 -0
- package/src/ssh/i18n/uk.ts +40 -0
- package/src/ssh/i18n/ur.ts +40 -0
- package/src/ssh/i18n/uz.ts +43 -0
- package/src/ssh/i18n/vi.ts +42 -0
- package/src/ssh/i18n/zh.ts +36 -0
- package/src/ssh/i18n/zht.ts +36 -0
- package/src/ssh/index.ts +71 -0
- package/src/ssh/main-machine.ts +532 -0
- package/src/ssh/main.ts +75 -0
- package/src/ssh/name.ts +28 -0
- package/src/ssh/remote-cli.ts +137 -0
- package/src/ssh/renderer.tsx +254 -0
- package/src/ssh/row.tsx +97 -0
- package/src/ssh/ssh.css +35 -0
- package/src/ssh/state.ts +217 -0
- package/src/ssh/window-machine.ts +533 -0
- package/src/terminal/connection-machine.ts +285 -0
- package/src/terminal/connection.ts +112 -0
- package/src/terminal/dispatch.ts +44 -0
- package/src/terminal/focus-machine.ts +112 -0
- package/src/terminal/focus.ts +23 -0
- package/src/terminal/hover-label.ts +20 -0
- package/src/terminal/i18n/am.ts +28 -0
- package/src/terminal/i18n/ar.ts +28 -0
- package/src/terminal/i18n/az.ts +29 -0
- package/src/terminal/i18n/bg.ts +29 -0
- package/src/terminal/i18n/bn.ts +28 -0
- package/src/terminal/i18n/br.ts +29 -0
- package/src/terminal/i18n/bs.ts +29 -0
- package/src/terminal/i18n/ca.ts +28 -0
- package/src/terminal/i18n/cs.ts +28 -0
- package/src/terminal/i18n/da.ts +28 -0
- package/src/terminal/i18n/de.ts +29 -0
- package/src/terminal/i18n/dv.ts +28 -0
- package/src/terminal/i18n/dz.ts +28 -0
- package/src/terminal/i18n/el.ts +30 -0
- package/src/terminal/i18n/en.ts +30 -0
- package/src/terminal/i18n/es.ts +28 -0
- package/src/terminal/i18n/et.ts +28 -0
- package/src/terminal/i18n/fa.ts +28 -0
- package/src/terminal/i18n/fi.ts +29 -0
- package/src/terminal/i18n/fo.ts +28 -0
- package/src/terminal/i18n/fr.ts +29 -0
- package/src/terminal/i18n/he.ts +28 -0
- package/src/terminal/i18n/hi.ts +28 -0
- package/src/terminal/i18n/hr.ts +28 -0
- package/src/terminal/i18n/hu.ts +28 -0
- package/src/terminal/i18n/hy.ts +29 -0
- package/src/terminal/i18n/id.ts +28 -0
- package/src/terminal/i18n/is.ts +28 -0
- package/src/terminal/i18n/it.ts +28 -0
- package/src/terminal/i18n/ja.ts +29 -0
- package/src/terminal/i18n/ka.ts +29 -0
- package/src/terminal/i18n/km.ts +28 -0
- package/src/terminal/i18n/ko.ts +28 -0
- package/src/terminal/i18n/lo.ts +28 -0
- package/src/terminal/i18n/lt.ts +29 -0
- package/src/terminal/i18n/lv.ts +28 -0
- package/src/terminal/i18n/mk.ts +29 -0
- package/src/terminal/i18n/mn.ts +30 -0
- package/src/terminal/i18n/ms.ts +28 -0
- package/src/terminal/i18n/my.ts +29 -0
- package/src/terminal/i18n/ne.ts +28 -0
- package/src/terminal/i18n/nl.ts +28 -0
- package/src/terminal/i18n/no.ts +28 -0
- package/src/terminal/i18n/pa.ts +28 -0
- package/src/terminal/i18n/pl.ts +28 -0
- package/src/terminal/i18n/ro.ts +28 -0
- package/src/terminal/i18n/ru.ts +28 -0
- package/src/terminal/i18n/si.ts +28 -0
- package/src/terminal/i18n/sk.ts +28 -0
- package/src/terminal/i18n/sl.ts +28 -0
- package/src/terminal/i18n/sq.ts +29 -0
- package/src/terminal/i18n/sr.ts +28 -0
- package/src/terminal/i18n/sv.ts +28 -0
- package/src/terminal/i18n/tg.ts +29 -0
- package/src/terminal/i18n/th.ts +28 -0
- package/src/terminal/i18n/tk.ts +29 -0
- package/src/terminal/i18n/tr.ts +29 -0
- package/src/terminal/i18n/uk.ts +28 -0
- package/src/terminal/i18n/ur.ts +28 -0
- package/src/terminal/i18n/uz.ts +29 -0
- package/src/terminal/i18n/vi.ts +28 -0
- package/src/terminal/i18n/zh.ts +28 -0
- package/src/terminal/i18n/zht.ts +28 -0
- package/src/terminal/index.ts +74 -0
- package/src/terminal/inline-rename.ts +93 -0
- package/src/terminal/label.tsx +71 -0
- package/src/terminal/machine.ts +767 -0
- package/src/terminal/model.ts +661 -0
- package/src/terminal/pane-machine.ts +260 -0
- package/src/terminal/panel.tsx +280 -0
- package/src/terminal/props.ts +16 -0
- package/src/terminal/quote-machine.ts +381 -0
- package/src/terminal/quote.css +7 -0
- package/src/terminal/quote.tsx +218 -0
- package/src/terminal/rename-machine.ts +98 -0
- package/src/terminal/renderer.tsx +298 -0
- package/src/terminal/runtime-adapters.ts +34 -0
- package/src/terminal/surface-machine.ts +186 -0
- package/src/terminal/tab.tsx +112 -0
- package/src/terminal/terminal-key-event.ts +58 -0
- package/src/terminal/terminal.fixture.tsx +71 -0
- package/src/terminal/terminal.tsx +652 -0
- package/src/terminal/title.ts +41 -0
- package/src/terminal/writer.ts +87 -0
- package/src/updater/action.ts +37 -0
- package/src/updater/actions.tsx +110 -0
- package/src/updater/i18n/am.ts +40 -0
- package/src/updater/i18n/ar.ts +40 -0
- package/src/updater/i18n/az.ts +41 -0
- package/src/updater/i18n/bg.ts +40 -0
- package/src/updater/i18n/bn.ts +41 -0
- package/src/updater/i18n/br.ts +40 -0
- package/src/updater/i18n/bs.ts +41 -0
- package/src/updater/i18n/ca.ts +41 -0
- package/src/updater/i18n/cs.ts +41 -0
- package/src/updater/i18n/da.ts +40 -0
- package/src/updater/i18n/de.ts +41 -0
- package/src/updater/i18n/dv.ts +41 -0
- package/src/updater/i18n/dz.ts +42 -0
- package/src/updater/i18n/el.ts +42 -0
- package/src/updater/i18n/en.ts +42 -0
- package/src/updater/i18n/es.ts +40 -0
- package/src/updater/i18n/et.ts +40 -0
- package/src/updater/i18n/fa.ts +40 -0
- package/src/updater/i18n/fi.ts +41 -0
- package/src/updater/i18n/fo.ts +40 -0
- package/src/updater/i18n/fr.ts +41 -0
- package/src/updater/i18n/he.ts +40 -0
- package/src/updater/i18n/hi.ts +40 -0
- package/src/updater/i18n/hr.ts +41 -0
- package/src/updater/i18n/hu.ts +40 -0
- package/src/updater/i18n/hy.ts +41 -0
- package/src/updater/i18n/id.ts +41 -0
- package/src/updater/i18n/is.ts +40 -0
- package/src/updater/i18n/it.ts +40 -0
- package/src/updater/i18n/ja.ts +41 -0
- package/src/updater/i18n/ka.ts +40 -0
- package/src/updater/i18n/km.ts +40 -0
- package/src/updater/i18n/ko.ts +40 -0
- package/src/updater/i18n/lo.ts +40 -0
- package/src/updater/i18n/lt.ts +41 -0
- package/src/updater/i18n/lv.ts +40 -0
- package/src/updater/i18n/mk.ts +41 -0
- package/src/updater/i18n/mn.ts +40 -0
- package/src/updater/i18n/ms.ts +41 -0
- package/src/updater/i18n/my.ts +40 -0
- package/src/updater/i18n/ne.ts +40 -0
- package/src/updater/i18n/nl.ts +41 -0
- package/src/updater/i18n/no.ts +40 -0
- package/src/updater/i18n/pa.ts +40 -0
- package/src/updater/i18n/pl.ts +41 -0
- package/src/updater/i18n/ro.ts +41 -0
- package/src/updater/i18n/ru.ts +40 -0
- package/src/updater/i18n/si.ts +40 -0
- package/src/updater/i18n/sk.ts +41 -0
- package/src/updater/i18n/sl.ts +40 -0
- package/src/updater/i18n/sq.ts +40 -0
- package/src/updater/i18n/sr.ts +41 -0
- package/src/updater/i18n/sv.ts +40 -0
- package/src/updater/i18n/tg.ts +41 -0
- package/src/updater/i18n/th.ts +40 -0
- package/src/updater/i18n/tk.ts +40 -0
- package/src/updater/i18n/tr.ts +40 -0
- package/src/updater/i18n/uk.ts +40 -0
- package/src/updater/i18n/ur.ts +40 -0
- package/src/updater/i18n/uz.ts +41 -0
- package/src/updater/i18n/vi.ts +41 -0
- package/src/updater/i18n/zh.ts +40 -0
- package/src/updater/i18n/zht.ts +40 -0
- package/src/updater/index.ts +94 -0
- package/src/updater/log.ts +41 -0
- package/src/updater/machine.ts +919 -0
- package/src/updater/main.ts +138 -0
- package/src/updater/platform.ts +160 -0
- package/src/updater/renderer.tsx +203 -0
- package/src/updater/section.tsx +65 -0
- package/src/updater/web-driver.ts +200 -0
- package/src/updater/web-machine.ts +222 -0
- package/src/updater/web.tsx +103 -0
- package/src/updater/whats-new-machine.ts +97 -0
- package/src/updater/whats-new.stories.tsx +38 -0
- package/src/updater/whats-new.tsx +304 -0
- package/src/updater/window-machine.ts +73 -0
- package/src/wsl/add-machine.ts +56 -0
- package/src/wsl/contract.ts +104 -0
- package/src/wsl/dialog-machine.ts +322 -0
- package/src/wsl/dialog.css +372 -0
- package/src/wsl/dialog.tsx +492 -0
- package/src/wsl/i18n/am.ts +53 -0
- package/src/wsl/i18n/ar.ts +55 -0
- package/src/wsl/i18n/az.ts +57 -0
- package/src/wsl/i18n/bg.ts +58 -0
- package/src/wsl/i18n/bn.ts +56 -0
- package/src/wsl/i18n/br.ts +58 -0
- package/src/wsl/i18n/bs.ts +58 -0
- package/src/wsl/i18n/ca.ts +58 -0
- package/src/wsl/i18n/cs.ts +57 -0
- package/src/wsl/i18n/da.ts +57 -0
- package/src/wsl/i18n/de.ts +59 -0
- package/src/wsl/i18n/dv.ts +58 -0
- package/src/wsl/i18n/dz.ts +59 -0
- package/src/wsl/i18n/el.ts +57 -0
- package/src/wsl/i18n/en.ts +55 -0
- package/src/wsl/i18n/es.ts +58 -0
- package/src/wsl/i18n/et.ts +55 -0
- package/src/wsl/i18n/fa.ts +56 -0
- package/src/wsl/i18n/fi.ts +57 -0
- package/src/wsl/i18n/fo.ts +56 -0
- package/src/wsl/i18n/fr.ts +57 -0
- package/src/wsl/i18n/he.ts +54 -0
- package/src/wsl/i18n/hi.ts +57 -0
- package/src/wsl/i18n/hr.ts +58 -0
- package/src/wsl/i18n/hu.ts +58 -0
- package/src/wsl/i18n/hy.ts +57 -0
- package/src/wsl/i18n/id.ts +56 -0
- package/src/wsl/i18n/is.ts +55 -0
- package/src/wsl/i18n/it.ts +57 -0
- package/src/wsl/i18n/ja.ts +57 -0
- package/src/wsl/i18n/ka.ts +56 -0
- package/src/wsl/i18n/km.ts +57 -0
- package/src/wsl/i18n/ko.ts +56 -0
- package/src/wsl/i18n/lo.ts +54 -0
- package/src/wsl/i18n/lt.ts +57 -0
- package/src/wsl/i18n/lv.ts +57 -0
- package/src/wsl/i18n/mk.ts +57 -0
- package/src/wsl/i18n/mn.ts +58 -0
- package/src/wsl/i18n/ms.ts +57 -0
- package/src/wsl/i18n/my.ts +57 -0
- package/src/wsl/i18n/ne.ts +57 -0
- package/src/wsl/i18n/nl.ts +57 -0
- package/src/wsl/i18n/no.ts +57 -0
- package/src/wsl/i18n/pa.ts +57 -0
- package/src/wsl/i18n/pl.ts +58 -0
- package/src/wsl/i18n/ro.ts +56 -0
- package/src/wsl/i18n/ru.ts +57 -0
- package/src/wsl/i18n/si.ts +56 -0
- package/src/wsl/i18n/sk.ts +57 -0
- package/src/wsl/i18n/sl.ts +57 -0
- package/src/wsl/i18n/sq.ts +56 -0
- package/src/wsl/i18n/sr.ts +57 -0
- package/src/wsl/i18n/sv.ts +58 -0
- package/src/wsl/i18n/tg.ts +57 -0
- package/src/wsl/i18n/th.ts +57 -0
- package/src/wsl/i18n/tk.ts +56 -0
- package/src/wsl/i18n/tr.ts +57 -0
- package/src/wsl/i18n/uk.ts +57 -0
- package/src/wsl/i18n/ur.ts +57 -0
- package/src/wsl/i18n/uz.ts +57 -0
- package/src/wsl/i18n/vi.ts +56 -0
- package/src/wsl/i18n/zh.ts +53 -0
- package/src/wsl/i18n/zht.ts +53 -0
- package/src/wsl/index.ts +72 -0
- package/src/wsl/local.ts +41 -0
- package/src/wsl/machine.ts +652 -0
- package/src/wsl/main.ts +95 -0
- package/src/wsl/model.ts +369 -0
- package/src/wsl/probe-machine.ts +143 -0
- package/src/wsl/probes.ts +107 -0
- package/src/wsl/remote-cli.ts +49 -0
- package/src/wsl/renderer.tsx +164 -0
- package/src/wsl/row-view.ts +25 -0
- package/src/wsl/row.tsx +76 -0
- package/src/wsl/runtime.ts +441 -0
- package/src/wsl/servers.ts +330 -0
- package/src/wsl/sidecar.ts +186 -0
- package/tsconfig.json +21 -0
|
@@ -0,0 +1,1335 @@
|
|
|
1
|
+
import { NodeHttpClient } from "@effect/platform-node"
|
|
2
|
+
import { homedir } from "node:os"
|
|
3
|
+
import { Browser } from "@zyro-sec/plugin-browser/rpc"
|
|
4
|
+
import { OpenCode } from "@zyro-sec/client/effect"
|
|
5
|
+
import { SessionID } from "@zyro-sec/schema/session-id"
|
|
6
|
+
import electron, { type BrowserWindow } from "electron"
|
|
7
|
+
import { Cause, Deferred, Effect, ManagedRuntime, Option, Queue, Schedule, Schema, Stream } from "effect"
|
|
8
|
+
import { HttpClient, HttpClientRequest } from "effect/http"
|
|
9
|
+
import type { BuiltinMainStorage } from "@zyro-sec/plugin/gui/builtin"
|
|
10
|
+
import type { Embeds, Log, Persisted, ServerEndpoints, Windows } from "@zyro-sec/plugin/gui/main"
|
|
11
|
+
import { createBrowserPage, type BrowserPage, type Shared } from "./chromium"
|
|
12
|
+
import { browserFailure, CodedError, keepsOpenedTab, missingArtifact, PageEndedError, pageReports } from "./errors"
|
|
13
|
+
import { createBrowserNetwork, createDirectNetwork, type BrowserNetwork } from "./network"
|
|
14
|
+
import { activityOwner, agentDriven, agentTabShow, agentRefusal, childActivity, createdActivity, destinationOrigin, normalizeURL, recordPageInput, recordTabFocus, refusal, restoreRefusal, type TabActivity } from "./policy"
|
|
15
|
+
import type { Profile } from "./profile"
|
|
16
|
+
import { createRefs } from "./refs"
|
|
17
|
+
import type { FindAction, PaneEvent, PromptAnswer, Viewport } from "./ipc"
|
|
18
|
+
import { createPageFind } from "./page-find"
|
|
19
|
+
import { exitCodeFields, type PageEnd } from "./page-log"
|
|
20
|
+
import {
|
|
21
|
+
attachmentFailure,
|
|
22
|
+
createPaneState,
|
|
23
|
+
decodeControl,
|
|
24
|
+
decodeControlHeader,
|
|
25
|
+
isCurrentPage,
|
|
26
|
+
isFocusedPage,
|
|
27
|
+
isPaneDisposed,
|
|
28
|
+
resolveControlFrame,
|
|
29
|
+
selectBinding,
|
|
30
|
+
selectFileRoots,
|
|
31
|
+
selectInventory,
|
|
32
|
+
selectOwnedBinding,
|
|
33
|
+
selectPageAttempt,
|
|
34
|
+
selectTabSlot,
|
|
35
|
+
transitionPane,
|
|
36
|
+
type AttachmentOutcome,
|
|
37
|
+
type BindingEvent,
|
|
38
|
+
type PaneEffect,
|
|
39
|
+
type PaneMachineEvent,
|
|
40
|
+
type PaneState,
|
|
41
|
+
} from "./pane-machine"
|
|
42
|
+
import { createBrowserRestoreStore, restoredActivity } from "./restore"
|
|
43
|
+
import { createPasskeyGroups } from "./passkey-groups"
|
|
44
|
+
import { guardSession } from "./session-guard"
|
|
45
|
+
import { extensionResource } from "./profile/extension-api/resource"
|
|
46
|
+
import type { SitePermissions } from "./site-permissions"
|
|
47
|
+
import type { SystemMedia } from "./system-media"
|
|
48
|
+
import { workspaceFile, type WorkspaceSource } from "./workspace-file"
|
|
49
|
+
import { workspacePages } from "./workspace-pages"
|
|
50
|
+
import { FileVerificationError } from "./file-verification"
|
|
51
|
+
import type { HandlePath } from "./disk"
|
|
52
|
+
import { artifactKind } from "@zyro-sec/util/artifact"
|
|
53
|
+
import { fileTab, reusableFile, workspaceFileURL } from "./link"
|
|
54
|
+
import { createPreviews } from "./profile/previews"
|
|
55
|
+
import { pluginTabs } from "./plugin-tabs"
|
|
56
|
+
import { remotePreview } from "./remote-preview"
|
|
57
|
+
import { artifactPages } from "./artifact-preview"
|
|
58
|
+
import { invalidReply, wireOutcome, wireState } from "./wire"
|
|
59
|
+
|
|
60
|
+
type Target = { readonly server: string; readonly session: string; readonly restore?: Browser.State }
|
|
61
|
+
|
|
62
|
+
/** The Electron and Effect handles of one binding; its phase lives in the pane machine. */
|
|
63
|
+
type Handle = {
|
|
64
|
+
window: number
|
|
65
|
+
win: BrowserWindow
|
|
66
|
+
/** The session the binding shows, which the desktop log names beside a page that ended. */
|
|
67
|
+
session: string
|
|
68
|
+
partition: string
|
|
69
|
+
/** The pages browse in the desktop profile itself, with this machine's network; else in a linked partition. */
|
|
70
|
+
shared: boolean
|
|
71
|
+
workspace?: () => ReturnType<typeof workspacePages>
|
|
72
|
+
previewFailure: ReturnType<typeof createPreviews>["failure"]
|
|
73
|
+
artifacts?: () => ReturnType<typeof artifactPages>
|
|
74
|
+
source?: WorkspaceSource
|
|
75
|
+
abort: AbortController
|
|
76
|
+
registered: ReturnType<typeof Promise.withResolvers<void>>
|
|
77
|
+
cleanup: () => void
|
|
78
|
+
timer?: ReturnType<typeof setTimeout>
|
|
79
|
+
network?: BrowserNetwork
|
|
80
|
+
/** A remote server's partition: what a page waits for before it loads, while the sign-ins are first copied into it. */
|
|
81
|
+
signedIn?: (signal: AbortSignal) => Promise<void> | undefined
|
|
82
|
+
sendState?: (state: Browser.State) => void
|
|
83
|
+
/** Pages by attempt. */
|
|
84
|
+
pages: Map<number, BrowserPage>
|
|
85
|
+
/**
|
|
86
|
+
* Survives unloading the page, but not closing its tab or releasing the binding. A tab the agent drove is saved as
|
|
87
|
+
* such, so it comes back agent-driven after a restart or a window reload.
|
|
88
|
+
*/
|
|
89
|
+
activity: Map<Browser.TabID, TabActivity>
|
|
90
|
+
background: Set<Browser.TabID>
|
|
91
|
+
pluginTabs: ReturnType<typeof pluginTabs>
|
|
92
|
+
/** Which tabs refuse passkeys together, by pop-up group; see `createPasskeyGroups`. */
|
|
93
|
+
passkeys: ReturnType<typeof createPasskeyGroups>
|
|
94
|
+
readonly storageKey: string
|
|
95
|
+
/** Agent requests in flight by request ID. */
|
|
96
|
+
requests: Map<string, AbortController>
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** The pane machine's current state; only `dispatch` replaces it. */
|
|
100
|
+
type PaneMachine = { state: PaneState }
|
|
101
|
+
|
|
102
|
+
/** How often the pane notes each live page's process memory. */
|
|
103
|
+
const MEMORY_SAMPLE_MS = 30_000
|
|
104
|
+
|
|
105
|
+
export type Pane = ReturnType<typeof createBrowserPane>
|
|
106
|
+
|
|
107
|
+
export function createBrowserPane(input: {
|
|
108
|
+
readonly windows: Windows
|
|
109
|
+
readonly t: (key: string) => string
|
|
110
|
+
readonly serverEndpoints: ServerEndpoints
|
|
111
|
+
readonly storage: BuiltinMainStorage
|
|
112
|
+
/** The declared store of reserved element refs. */
|
|
113
|
+
readonly refs: Persisted<number, number>
|
|
114
|
+
readonly embeds: Embeds
|
|
115
|
+
/** The desktop browser's one profile: cookies, site data and extensions for every session. */
|
|
116
|
+
readonly profile: Profile
|
|
117
|
+
/** The permission decisions the user kept for sites. */
|
|
118
|
+
readonly sites: SitePermissions
|
|
119
|
+
/** The system's camera and microphone setting, and its prompt. */
|
|
120
|
+
readonly system: SystemMedia
|
|
121
|
+
/** Whether the build offers the device toolbar. */
|
|
122
|
+
readonly toolbar: boolean
|
|
123
|
+
/** How long a page's `navigate` command waits for its load; `NAVIGATION_DEADLINE_MS` unless given. */
|
|
124
|
+
readonly navigationDeadlineMs?: number
|
|
125
|
+
/** The plugin instance's file verifier, for workspace files. */
|
|
126
|
+
readonly verifier: HandlePath
|
|
127
|
+
/** The desktop log, which hears why a page ended or stalled (page-log.ts). */
|
|
128
|
+
readonly log: Log
|
|
129
|
+
readonly emit: (window: number, value: { readonly binding: string; readonly event: PaneEvent }) => void
|
|
130
|
+
}) {
|
|
131
|
+
const machine: PaneMachine = { state: createPaneState() }
|
|
132
|
+
const handles = new Map<string, Handle>()
|
|
133
|
+
// Rebind may restore the same tabs. Close rights stay in memory and never move to another window or session.
|
|
134
|
+
const owners = new WeakMap<BrowserWindow, Map<string, Pick<Handle, "pluginTabs" | "background">>>()
|
|
135
|
+
// Release each tab's registration with the profile's extensions.
|
|
136
|
+
const grants = new WeakMap<BrowserPage, () => void>()
|
|
137
|
+
const searches = new WeakMap<BrowserPage, ReturnType<typeof createPageFind>>()
|
|
138
|
+
// A second click can arrive before even about:blank has committed in the first click's new tab.
|
|
139
|
+
const openingFiles = new WeakMap<BrowserPage, string>()
|
|
140
|
+
const restore = createBrowserRestoreStore(input.storage)
|
|
141
|
+
const shared: Shared = { ref: createRefs(input.refs) }
|
|
142
|
+
// Page disposals in flight. Finishing a trace or CPU profile can hold a page open, and the pane's own disposal waits
|
|
143
|
+
// for them so a replacement never starts beside old pages still recording.
|
|
144
|
+
const releasing = new Set<Promise<void>>()
|
|
145
|
+
const disposals = new WeakMap<BrowserPage, Promise<void>>()
|
|
146
|
+
// Keep long-lived RPC requests off Chromium's shared HTTP connection pool.
|
|
147
|
+
const runtime = ManagedRuntime.make(NodeHttpClient.layerNodeHttp)
|
|
148
|
+
// Each page's download handler by its web contents ID. The profile guards its own session and owns this map; a remote
|
|
149
|
+
// server's partition gets its own guard at registration, handing downloads to the same map.
|
|
150
|
+
const downloads = input.profile.downloads
|
|
151
|
+
// Warnings about Electron internals a page relies on, each logged once for the pane.
|
|
152
|
+
const warned = new Set<string>()
|
|
153
|
+
|
|
154
|
+
const livePages = () => Array.from(handles.values()).flatMap((handle) => Array.from(handle.pages.values()))
|
|
155
|
+
|
|
156
|
+
// The GPU, network and utility processes take pages down without a renderer of theirs ending. A clean exit is a
|
|
157
|
+
// helper that finished.
|
|
158
|
+
const childGone = (_event: Electron.Event, details: Electron.Details) => {
|
|
159
|
+
if (details.reason === "clean-exit") return
|
|
160
|
+
input.log.write("error", "browser child process gone", {
|
|
161
|
+
type: details.type,
|
|
162
|
+
name: details.name,
|
|
163
|
+
service: details.serviceName,
|
|
164
|
+
reason: details.reason,
|
|
165
|
+
...exitCodeFields(details.exitCode),
|
|
166
|
+
pages: livePages().length,
|
|
167
|
+
})
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
electron.app.on("child-process-gone", childGone)
|
|
171
|
+
|
|
172
|
+
// Electron lists a process's memory only while it runs, so a page that ends reports what was last seen here.
|
|
173
|
+
const sampling = setInterval(() => {
|
|
174
|
+
const pages = livePages()
|
|
175
|
+
|
|
176
|
+
if (!pages.length) return
|
|
177
|
+
const metrics = electron.app.getAppMetrics()
|
|
178
|
+
pages.forEach((page) => page.sampleMemory(metrics))
|
|
179
|
+
}, MEMORY_SAMPLE_MS)
|
|
180
|
+
|
|
181
|
+
sampling.unref()
|
|
182
|
+
|
|
183
|
+
return {
|
|
184
|
+
/**
|
|
185
|
+
* The app menu's hard reload, offered while a pane of the window has a tab in front. It goes to the window, which
|
|
186
|
+
* runs it on the pane it shows through `command`, so it is the person's command there and reaches a failed page.
|
|
187
|
+
*/
|
|
188
|
+
menuReload(window: number | undefined) {
|
|
189
|
+
const bindings = Array.from(handles).flatMap(([binding, handle]) =>
|
|
190
|
+
handle.window === window && inventory(binding).focusedTabID ? [binding] : [],
|
|
191
|
+
)
|
|
192
|
+
|
|
193
|
+
return bindings.length ? () => bindings.forEach((binding) => emit(binding, { type: "hardReload" })) : undefined
|
|
194
|
+
},
|
|
195
|
+
async register(window: number, binding: string, target: Target) {
|
|
196
|
+
const server = input.serverEndpoints.get(target.server)
|
|
197
|
+
|
|
198
|
+
if (isPaneDisposed(machine.state) || !server || !destinationOrigin(server.url))
|
|
199
|
+
throw new Error("browser.pane.registration.invalid")
|
|
200
|
+
|
|
201
|
+
const win = input.windows.get(window)
|
|
202
|
+
|
|
203
|
+
if (!win || selectBinding(machine.state, binding) || handles.has(binding))
|
|
204
|
+
throw new Error("browser.pane.owner.invalid")
|
|
205
|
+
|
|
206
|
+
if (win.isDestroyed() || win.webContents.isDestroyed()) throw new Error("browser.pane.owner.unavailable")
|
|
207
|
+
const sessionID = SessionID.make(target.session)
|
|
208
|
+
const storageKey = `${target.server}\n${sessionID}`
|
|
209
|
+
const saved = restore.load(storageKey)
|
|
210
|
+
// A server on this machine reaches the same network as this desktop, so its pages browse in the profile. Another
|
|
211
|
+
// server's pages need its network through a proxy, which Chromium sets per partition.
|
|
212
|
+
const shared = server.sameMachine
|
|
213
|
+
const partition = shared ? input.profile.partition : `opencode-browser-${crypto.randomUUID()}`
|
|
214
|
+
|
|
215
|
+
const remote = shared ? undefined : electron.session.fromPartition(partition)
|
|
216
|
+
const abort = new AbortController()
|
|
217
|
+
const previews = remote ? createPreviews(remote, abort.signal, input.verifier) : input.profile.previews
|
|
218
|
+
const unguard = remote ? guardSession(remote, downloads, input.profile.permissions) : () => undefined
|
|
219
|
+
|
|
220
|
+
const closed = () => dispatchBinding(binding, { type: "owner.closed" })
|
|
221
|
+
|
|
222
|
+
const navigate = (event: Electron.Event<{ isMainFrame: boolean; isSameDocument: boolean }>) => {
|
|
223
|
+
if (event.isMainFrame && !event.isSameDocument) closed()
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
win.webContents.once("destroyed", closed)
|
|
227
|
+
win.webContents.on("did-start-navigation", navigate)
|
|
228
|
+
|
|
229
|
+
const scopes = owners.get(win) ?? new Map<string, Pick<Handle, "pluginTabs" | "background">>()
|
|
230
|
+
const rights = scopes.get(storageKey) ?? { pluginTabs: pluginTabs(), background: new Set<Browser.TabID>() }
|
|
231
|
+
scopes.set(storageKey, rights)
|
|
232
|
+
owners.set(win, scopes)
|
|
233
|
+
|
|
234
|
+
const handle: Handle = {
|
|
235
|
+
previewFailure: previews.failure,
|
|
236
|
+
window,
|
|
237
|
+
win,
|
|
238
|
+
session: sessionID,
|
|
239
|
+
partition,
|
|
240
|
+
shared,
|
|
241
|
+
abort,
|
|
242
|
+
registered: Promise.withResolvers(),
|
|
243
|
+
cleanup: () => {
|
|
244
|
+
unguard()
|
|
245
|
+
|
|
246
|
+
if (win.isDestroyed()) return
|
|
247
|
+
win.webContents.off("destroyed", closed)
|
|
248
|
+
win.webContents.off("did-start-navigation", navigate)
|
|
249
|
+
},
|
|
250
|
+
pages: new Map(),
|
|
251
|
+
activity: restoredActivity(saved),
|
|
252
|
+
...rights,
|
|
253
|
+
passkeys: createPasskeyGroups(),
|
|
254
|
+
storageKey,
|
|
255
|
+
requests: new Map(),
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
handles.set(binding, handle)
|
|
259
|
+
dispatch({
|
|
260
|
+
type: "registered",
|
|
261
|
+
binding,
|
|
262
|
+
window,
|
|
263
|
+
storageKey,
|
|
264
|
+
restore: target.restore,
|
|
265
|
+
saved,
|
|
266
|
+
})
|
|
267
|
+
void runtime
|
|
268
|
+
.runPromise(
|
|
269
|
+
Effect.gen(function* () {
|
|
270
|
+
const http = yield* HttpClient.HttpClient
|
|
271
|
+
|
|
272
|
+
// The renderer never holds the managed sidecar's password; Node requests bypass
|
|
273
|
+
// the webRequest header injection, so the host resolves the credential here in main.
|
|
274
|
+
const client = yield* OpenCode.make({ baseUrl: server.url }).pipe(
|
|
275
|
+
Effect.provideService(
|
|
276
|
+
HttpClient.HttpClient,
|
|
277
|
+
Object.keys(server.headers).length
|
|
278
|
+
? HttpClient.mapRequest(http, HttpClientRequest.setHeaders(server.headers))
|
|
279
|
+
: http,
|
|
280
|
+
),
|
|
281
|
+
)
|
|
282
|
+
|
|
283
|
+
const session = yield* client.session.get({ sessionID })
|
|
284
|
+
|
|
285
|
+
// The agent can already read this workspace, so showing its files adds no access. A forwarded or explicit
|
|
286
|
+
// loopback server does not share this machine's disk.
|
|
287
|
+
const builtin = server.id === "sidecar"
|
|
288
|
+
const fileRoots = builtin ? [session.location.directory] : []
|
|
289
|
+
|
|
290
|
+
const options = {
|
|
291
|
+
location: { directory: session.location.directory, workspace: session.location.workspaceID },
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
const attachment = { sessionID, connectionID: crypto.randomUUID() }
|
|
295
|
+
const rpc = client.rpc(Browser.Definition)
|
|
296
|
+
|
|
297
|
+
const source: WorkspaceSource = builtin
|
|
298
|
+
? { type: "local", roots: () => selectFileRoots(machine.state, binding) }
|
|
299
|
+
: remotePreview(server, sessionID, options.location, abort.signal)
|
|
300
|
+
|
|
301
|
+
handle.source = source
|
|
302
|
+
handle.artifacts = () => artifactPages(previews, server, session.location.directory, abort.signal)
|
|
303
|
+
handle.workspace = () => workspacePages(previews, input.verifier, session.location.directory, source, abort.signal)
|
|
304
|
+
|
|
305
|
+
if (shared) handle.network = createDirectNetwork(input.profile.session)
|
|
306
|
+
|
|
307
|
+
if (!shared) {
|
|
308
|
+
handle.network = yield* createBrowserNetwork({ rpc, attachment, location: options.location, partition })
|
|
309
|
+
|
|
310
|
+
// Only when the user chose to share sign-ins with remote servers do they carry over, both ways, so a page
|
|
311
|
+
// of a remote server is signed in where the profile is; otherwise `link` leaves the partition apart.
|
|
312
|
+
// The attachment does not wait for the first copy of the sign-ins: only a page that is about to load
|
|
313
|
+
// does (`signedIn`). A registration that ends, for any reason, ends its copy with the scope.
|
|
314
|
+
const linked = yield* Effect.acquireRelease(
|
|
315
|
+
Effect.sync(() => input.profile.link(electron.session.fromPartition(partition))),
|
|
316
|
+
(link) => Effect.sync(link.unlink),
|
|
317
|
+
)
|
|
318
|
+
|
|
319
|
+
handle.signedIn = linked.signedIn
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
const connected = yield* Deferred.make<void>()
|
|
323
|
+
const outbound = yield* Queue.unbounded<Effect.Effect<void>>()
|
|
324
|
+
|
|
325
|
+
// A send that fails because the server already replaced or closed this attachment must
|
|
326
|
+
// not decide the close reason; only the attach call's outcome does.
|
|
327
|
+
const send = (effect: Effect.Effect<unknown, unknown>) =>
|
|
328
|
+
Queue.offerUnsafe(
|
|
329
|
+
outbound,
|
|
330
|
+
effect.pipe(Effect.catchCause((cause) => Effect.logWarning("Browser send failed", cause))),
|
|
331
|
+
)
|
|
332
|
+
|
|
333
|
+
const reply = (requestID: string, outcome: Browser.Outcome) =>
|
|
334
|
+
send(
|
|
335
|
+
rpc.result({ ...attachment, requestID, outcome: wireOutcome(outcome) }, options).pipe(
|
|
336
|
+
// An older server can reject a locally valid result. Settle the same request, never rerun it.
|
|
337
|
+
Effect.catchIf(error => Schema.isSchemaError(error) || ("type" in error && error.type === "rpc.invalid_input"),
|
|
338
|
+
() => rpc.result({ ...attachment, requestID, outcome: invalidReply }, options)),
|
|
339
|
+
),
|
|
340
|
+
)
|
|
341
|
+
|
|
342
|
+
// The window hears every event at once; it never waits on the server, which can stall for
|
|
343
|
+
// hundreds of milliseconds while it serves the page's own traffic. The server's copy of the
|
|
344
|
+
// inventory resolves every tab ID, so a state is retried until it arrives or the attachment
|
|
345
|
+
// ends; the results queued behind it then never name a tab the server lacks. "unavailable"
|
|
346
|
+
// means the server already dropped this attachment, which attach reports.
|
|
347
|
+
handle.sendState = (inventory) => {
|
|
348
|
+
const state = wireState(inventory)
|
|
349
|
+
|
|
350
|
+
if (!state) return send(Effect.logWarning("Browser state is not a valid wire inventory"))
|
|
351
|
+
send(
|
|
352
|
+
rpc.state({ ...attachment, state }, options).pipe(
|
|
353
|
+
Effect.retry({
|
|
354
|
+
while: (error) => !Schema.isSchemaError(error) && !("type" in error && ["unavailable", "rpc.invalid_input"].includes(error.type)),
|
|
355
|
+
schedule: Schedule.min([Schedule.exponential("250 millis"), Schedule.spaced("10 seconds")]),
|
|
356
|
+
}),
|
|
357
|
+
),
|
|
358
|
+
)
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
const run = (requestID: string, abort: AbortController) =>
|
|
362
|
+
rpc.command({ ...attachment, requestID }, options).pipe(
|
|
363
|
+
Effect.flatMap((command) =>
|
|
364
|
+
Effect.promise(async () => {
|
|
365
|
+
if ("tabID" in command.action)
|
|
366
|
+
dispatchBinding(binding, { type: "request.targeted", requestID, tabID: command.action.tabID })
|
|
367
|
+
reply(
|
|
368
|
+
requestID,
|
|
369
|
+
await execute(binding, command, abort.signal, "agent").then(
|
|
370
|
+
(result) => ({ type: "success" as const, result }),
|
|
371
|
+
// A command stopped because its tab's page ended hears why, not that it was cancelled.
|
|
372
|
+
(cause: unknown) => browserFailure(command.action, abort.signal.reason instanceof PageEndedError ? abort.signal.reason : cause),
|
|
373
|
+
),
|
|
374
|
+
)
|
|
375
|
+
}),
|
|
376
|
+
),
|
|
377
|
+
Effect.ensuring(
|
|
378
|
+
Effect.sync(() => {
|
|
379
|
+
handle.requests.delete(requestID)
|
|
380
|
+
dispatchBinding(binding, { type: "request.finished", requestID })
|
|
381
|
+
}),
|
|
382
|
+
),
|
|
383
|
+
// An operation this desktop cannot decode comes from a newer plugin; answer it so
|
|
384
|
+
// the agent does not wait out the server's timeout.
|
|
385
|
+
Effect.catchCause((cause) =>
|
|
386
|
+
Effect.sync(() => {
|
|
387
|
+
if (abort.signal.aborted) return
|
|
388
|
+
const error = Option.getOrUndefined(Cause.findErrorOption(cause))
|
|
389
|
+
reply(requestID, Schema.isSchemaError(error) ? {
|
|
390
|
+
type: "failure", code: "unsupported", message: "This desktop cannot decode the requested browser operation. Check the desktop and server versions.",
|
|
391
|
+
} : invalidReply)
|
|
392
|
+
}),
|
|
393
|
+
),
|
|
394
|
+
Effect.forkScoped,
|
|
395
|
+
)
|
|
396
|
+
|
|
397
|
+
const receive = client.event.subscribe().pipe(
|
|
398
|
+
Stream.runForEach((event) =>
|
|
399
|
+
Effect.gen(function* () {
|
|
400
|
+
if (event.type === "server.connected") {
|
|
401
|
+
yield* Deferred.succeed(connected, undefined)
|
|
402
|
+
|
|
403
|
+
return
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
if (event.type !== "rpc.experimental.browser.control") return
|
|
407
|
+
|
|
408
|
+
const frame = resolveControlFrame(
|
|
409
|
+
attachment.connectionID,
|
|
410
|
+
decodeControlHeader(event.data),
|
|
411
|
+
decodeControl(event.data),
|
|
412
|
+
)
|
|
413
|
+
|
|
414
|
+
if (frame.kind === "foreign") return
|
|
415
|
+
|
|
416
|
+
if (frame.kind === "attached") return dispatchBinding(binding, { type: "server.attached", fileRoots })
|
|
417
|
+
|
|
418
|
+
if (frame.kind === "incompatible") return dispatchBinding(binding, { type: "handshake.unsupported" })
|
|
419
|
+
|
|
420
|
+
// A newer server may add control events; this attachment keeps working without them.
|
|
421
|
+
if (frame.kind === "unrecognized")
|
|
422
|
+
return dispatchBinding(binding, { type: "control.unrecognized", controlType: frame.controlType })
|
|
423
|
+
|
|
424
|
+
if (frame.kind === "cancel")
|
|
425
|
+
return dispatchBinding(binding, { type: "request.cancelled", requestID: frame.requestID })
|
|
426
|
+
const abort = new AbortController()
|
|
427
|
+
handle.requests.set(frame.requestID, abort)
|
|
428
|
+
dispatchBinding(binding, { type: "request.started", requestID: frame.requestID })
|
|
429
|
+
yield* run(frame.requestID, abort)
|
|
430
|
+
}),
|
|
431
|
+
),
|
|
432
|
+
)
|
|
433
|
+
|
|
434
|
+
const attach = rpc.attach({ ...attachment, version: 4 }, options)
|
|
435
|
+
|
|
436
|
+
// A Location the server has only just started lists no plugin until its plugins have loaded, the browser's
|
|
437
|
+
// among them. Ten seconds outlasts a server that starts every open project at once, as after an update.
|
|
438
|
+
const loaded = client.plugin.list({ location: { directory: session.location.directory } }).pipe(
|
|
439
|
+
Effect.repeat({
|
|
440
|
+
until: (plugins) => plugins.data.length > 0,
|
|
441
|
+
schedule: Schedule.spaced("100 millis").pipe(Schedule.upTo({ duration: "10 seconds" })),
|
|
442
|
+
}),
|
|
443
|
+
Effect.ignore,
|
|
444
|
+
)
|
|
445
|
+
|
|
446
|
+
return yield* Effect.raceAllFirst([
|
|
447
|
+
receive,
|
|
448
|
+
Stream.fromQueue(outbound).pipe(Stream.runForEach((send) => send)),
|
|
449
|
+
Deferred.await(connected).pipe(
|
|
450
|
+
Effect.andThen(attach),
|
|
451
|
+
// A Location still loading its plugins has no browser RPC to call yet, so only one that lists its
|
|
452
|
+
// plugins and still refuses has no browser. An attachment the server accepted and then dropped stays
|
|
453
|
+
// dropped: the server evicted its idle Location, which another call would start again.
|
|
454
|
+
Effect.catchIf(
|
|
455
|
+
(error) => attachmentFailure(error) === "unavailable" && selectBinding(machine.state, binding)?.status === "connecting",
|
|
456
|
+
() => loaded.pipe(Effect.andThen(attach)),
|
|
457
|
+
),
|
|
458
|
+
),
|
|
459
|
+
])
|
|
460
|
+
}).pipe(
|
|
461
|
+
Effect.matchCause({
|
|
462
|
+
onSuccess: (result): AttachmentOutcome => (result === "replaced" ? "replaced" : "closed"),
|
|
463
|
+
onFailure: (cause) =>
|
|
464
|
+
Option.match(Cause.findErrorOption(cause), {
|
|
465
|
+
onNone: (): AttachmentOutcome => "closed",
|
|
466
|
+
onSome: attachmentFailure,
|
|
467
|
+
}),
|
|
468
|
+
}),
|
|
469
|
+
// Inside the scope: closing the tunnels, the proxy and the partition's connections can take seconds, and
|
|
470
|
+
// nothing that happens meanwhile changes why the attachment ended.
|
|
471
|
+
Effect.tap((outcome) => Effect.sync(() => dispatchBinding(binding, { type: "attachment.ended", outcome }))),
|
|
472
|
+
Effect.scoped,
|
|
473
|
+
),
|
|
474
|
+
{ signal: handle.abort.signal },
|
|
475
|
+
)
|
|
476
|
+
.catch(() => dispatchBinding(binding, { type: "attachment.ended", outcome: "closed" }))
|
|
477
|
+
await handle.registered.promise
|
|
478
|
+
|
|
479
|
+
if (!selectBinding(machine.state, binding)) throw new Error("browser.pane.registration.closed")
|
|
480
|
+
},
|
|
481
|
+
load(window: number, binding: string, tabID: Browser.TabID) {
|
|
482
|
+
owned(window, binding)
|
|
483
|
+
load(binding, tabID)
|
|
484
|
+
},
|
|
485
|
+
toolbarTab(window: number, binding: string, tabID: Browser.TabID) {
|
|
486
|
+
owned(window, binding)
|
|
487
|
+
const target = page(binding, tabID)
|
|
488
|
+
|
|
489
|
+
// The visible toolbar's menu temporarily covers its native view. Resolve the clicked binding and
|
|
490
|
+
// selection, not view visibility or the window's last activation (which can be in another session).
|
|
491
|
+
if (!target || !handles.get(binding)?.shared || inventory(binding).focusedTabID !== tabID) return
|
|
492
|
+
|
|
493
|
+
return { id: target.nativeID, pageTop: target.areaTop() }
|
|
494
|
+
},
|
|
495
|
+
notice(window: number, binding: string, tabID: Browser.TabID, token: string, dismiss: boolean, copy?: boolean) {
|
|
496
|
+
owned(window, binding)
|
|
497
|
+
|
|
498
|
+
return page(binding, tabID)?.answerNotice(token, dismiss, copy)
|
|
499
|
+
},
|
|
500
|
+
async reviewLink(window: number, binding: string, url: string) {
|
|
501
|
+
owned(window, binding)
|
|
502
|
+
const focused = selectBinding(machine.state, binding)?.focusedTabID
|
|
503
|
+
const tab = (focused && page(binding, focused)) || create(binding)
|
|
504
|
+
const id = tab.state().id
|
|
505
|
+
await tab.ready
|
|
506
|
+
|
|
507
|
+
if (page(binding, id) !== tab) throw new Error("browser.pane.unavailable")
|
|
508
|
+
dispatchBinding(binding, { type: "tab.focused", tabID: id })
|
|
509
|
+
tab.reviewLink(url)
|
|
510
|
+
|
|
511
|
+
return id
|
|
512
|
+
},
|
|
513
|
+
find(window: number, binding: string, tabID: Browser.TabID, action: FindAction) {
|
|
514
|
+
owned(window, binding)
|
|
515
|
+
const target = page(binding, tabID)
|
|
516
|
+
|
|
517
|
+
if (!target) throw new Error("browser.pane.unavailable")
|
|
518
|
+
searches.get(target)?.run(action)
|
|
519
|
+
},
|
|
520
|
+
async answer(window: number, binding: string, tabID: Browser.TabID, id: number, answer: PromptAnswer) {
|
|
521
|
+
owned(window, binding)
|
|
522
|
+
await page(binding, tabID)?.answer(id, answer)
|
|
523
|
+
},
|
|
524
|
+
async inspect(window: number, binding: string, tabID: Browser.TabID, enabled: boolean) {
|
|
525
|
+
owned(window, binding)
|
|
526
|
+
await page(binding, tabID)?.inspect(enabled)
|
|
527
|
+
},
|
|
528
|
+
async highlight(window: number, binding: string, tabID: Browser.TabID, ref?: Browser.Ref) {
|
|
529
|
+
owned(window, binding)
|
|
530
|
+
await page(binding, tabID)?.highlight(ref)
|
|
531
|
+
},
|
|
532
|
+
zoom(window: number, binding: string, tabID: Browser.TabID, direction: "in" | "out" | "reset") {
|
|
533
|
+
owned(window, binding)
|
|
534
|
+
page(binding, tabID)?.zoom(direction)
|
|
535
|
+
},
|
|
536
|
+
async setViewport(window: number, binding: string, tabID: Browser.TabID, viewport: Viewport) {
|
|
537
|
+
owned(window, binding)
|
|
538
|
+
const target = load(binding, tabID)
|
|
539
|
+
|
|
540
|
+
if (!target) throw new Error("browser.pane.unavailable")
|
|
541
|
+
await target.setViewport(viewport)
|
|
542
|
+
},
|
|
543
|
+
async site(window: number, binding: string, tabID: Browser.TabID) {
|
|
544
|
+
owned(window, binding)
|
|
545
|
+
|
|
546
|
+
return (await page(binding, tabID)?.site()) ?? { cookies: 0 }
|
|
547
|
+
},
|
|
548
|
+
async clearCache(window: number, binding: string, tabID: Browser.TabID, address: string) {
|
|
549
|
+
owned(window, binding)
|
|
550
|
+
const handle = handles.get(binding)
|
|
551
|
+
const origin = destinationOrigin(address)
|
|
552
|
+
const current = () => page(binding, tabID)?.contents.getURL() ?? selectTabSlot(machine.state, binding, tabID)?.tab.url
|
|
553
|
+
|
|
554
|
+
if (!handle || !origin || destinationOrigin(current() ?? "") !== origin) throw new Error("browser.site.changed")
|
|
555
|
+
page(binding, tabID)?.personCommand()
|
|
556
|
+
const session = electron.session.fromPartition(handle.partition)
|
|
557
|
+
await session.clearData({ origins: [origin], originMatchingMode: "origin-in-all-contexts", dataTypes: ["cache", "serviceWorkers"] })
|
|
558
|
+
|
|
559
|
+
if (handle.abort.signal.aborted || destinationOrigin(current() ?? "") !== origin) return
|
|
560
|
+
await execute(binding, { action: { type: "reload", tabID, ignoreCache: true }, files: [] }, handle.abort.signal, "user")
|
|
561
|
+
},
|
|
562
|
+
async clearSite(window: number, binding: string, tabID: Browser.TabID) {
|
|
563
|
+
owned(window, binding)
|
|
564
|
+
await page(binding, tabID)?.clearSite()
|
|
565
|
+
},
|
|
566
|
+
async reveal(window: number, binding: string, tabID: Browser.TabID) {
|
|
567
|
+
owned(window, binding)
|
|
568
|
+
const tab = page(binding, tabID)
|
|
569
|
+
const url = tab?.state().url
|
|
570
|
+
const file = url && await workspaceFile(input.verifier, url, selectFileRoots(machine.state, binding))
|
|
571
|
+
|
|
572
|
+
if (!file || !tab || page(binding, tabID) !== tab || tab.state().url !== url) throw new Error("browser.address.workspace")
|
|
573
|
+
// Reveal a regular file in its folder; never hand even a validated file to its executable association.
|
|
574
|
+
electron.shell.showItemInFolder(file.path)
|
|
575
|
+
},
|
|
576
|
+
async openPage(window: number, binding: string, tabID: Browser.TabID, expected: string) {
|
|
577
|
+
owned(window, binding)
|
|
578
|
+
const tab = page(binding, tabID)
|
|
579
|
+
|
|
580
|
+
if (!tab) throw new Error("browser.pane.unavailable")
|
|
581
|
+
await tab.openPage(expected)
|
|
582
|
+
},
|
|
583
|
+
async command(window: number, binding: string, command: Browser.Action) {
|
|
584
|
+
owned(window, binding)
|
|
585
|
+
const url = command.type === "navigate" || command.type === "tabs.open" ? command.url : undefined
|
|
586
|
+
|
|
587
|
+
// The window explains a refused address by its code; the agent's commands get main's own message instead.
|
|
588
|
+
const reason =
|
|
589
|
+
url === undefined
|
|
590
|
+
? undefined
|
|
591
|
+
: refusal(url, pagePolicy(binding))
|
|
592
|
+
|
|
593
|
+
if (reason) throw new Error(reason)
|
|
594
|
+
|
|
595
|
+
if (command.type === "navigate") dispatchBinding(binding, { type: "tab.addressed", tabID: command.tabID })
|
|
596
|
+
|
|
597
|
+
if ("tabID" in command && command.type !== "tabs.focus") page(binding, command.tabID)?.personCommand()
|
|
598
|
+
const closing = command.type === "tabs.close" ? page(binding, command.tabID) : undefined
|
|
599
|
+
|
|
600
|
+
// A page that asks to confirm keeps its tab; its "Leave site?" closes it.
|
|
601
|
+
if (closing && !(await closing.leave())) return
|
|
602
|
+
// A navigation that the next one replaced, such as a second submit or a redirect, rejects with ERR_ABORTED while
|
|
603
|
+
// the tab goes on loading; one the person stopped, or that became a download, commits no page; a slow one
|
|
604
|
+
// outlives the command's deadline. None is a failed command, and a page that fails to load reports its own
|
|
605
|
+
// error, which the window shows where the page would be.
|
|
606
|
+
await execute(binding, { action: command, files: [] }, new AbortController().signal, "user", "present").catch(
|
|
607
|
+
(error: Error) => {
|
|
608
|
+
if (error instanceof FileVerificationError) throw new Error(error._tag)
|
|
609
|
+
|
|
610
|
+
if (!pageReports(error)) throw error
|
|
611
|
+
},
|
|
612
|
+
)
|
|
613
|
+
},
|
|
614
|
+
async close(window: number, binding: string) {
|
|
615
|
+
owned(window, binding)
|
|
616
|
+
dispatchBinding(binding, { type: "owner.closed" })
|
|
617
|
+
},
|
|
618
|
+
async createTab(window: number, binding: string, owner: string, url: string) {
|
|
619
|
+
owned(window, binding)
|
|
620
|
+
const handle = handles.get(binding)
|
|
621
|
+
|
|
622
|
+
if (!handle) throw new Error("browser.pane.unavailable")
|
|
623
|
+
const grant = handle.pluginTabs.reserve(owner)
|
|
624
|
+
// Never adopt an existing file tab, even when this plugin opens the same URL as the user.
|
|
625
|
+
await execute(binding, { action: { type: "tabs.open", url }, files: [] }, handle.abort.signal, "user", "new", undefined, grant.created)
|
|
626
|
+
grant.settled()
|
|
627
|
+
|
|
628
|
+
return grant.id
|
|
629
|
+
},
|
|
630
|
+
async closeTab(window: number, binding: string, owner: string, id: string) {
|
|
631
|
+
owned(window, binding)
|
|
632
|
+
const tabID = handles.get(binding)?.pluginTabs.resolve(owner, id)
|
|
633
|
+
|
|
634
|
+
if (!tabID || !selectTabSlot(machine.state, binding, tabID)) return false
|
|
635
|
+
const closing = page(binding, tabID)
|
|
636
|
+
|
|
637
|
+
if (closing && !(await closing.leave())) return false
|
|
638
|
+
|
|
639
|
+
if (handles.get(binding)?.pluginTabs.resolve(owner, id) !== tabID) return false
|
|
640
|
+
dispatchBinding(binding, { type: "tab.closed", tabID })
|
|
641
|
+
|
|
642
|
+
return true
|
|
643
|
+
},
|
|
644
|
+
forget(server: string, session: string) {
|
|
645
|
+
const storageKey = `${server}\n${session}`
|
|
646
|
+
|
|
647
|
+
for (const binding of handles.keys()) {
|
|
648
|
+
if (selectBinding(machine.state,binding)?.storageKey === storageKey) dispatchBinding(binding,{type:"client.closed"})
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
restore.remove(storageKey)
|
|
652
|
+
},
|
|
653
|
+
/**
|
|
654
|
+
* The plugin is going away (reload, disable, or quit). Windows keep each pane's tabs as a
|
|
655
|
+
* suspended attachment, like an idle server eviction, and register again once the pane is back.
|
|
656
|
+
*/
|
|
657
|
+
async dispose() {
|
|
658
|
+
clearInterval(sampling)
|
|
659
|
+
electron.app.off("child-process-gone", childGone)
|
|
660
|
+
dispatch({ type: "disposed" })
|
|
661
|
+
await Promise.all(releasing)
|
|
662
|
+
await runtime.dispose()
|
|
663
|
+
},
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
function dispatch(event: PaneMachineEvent) {
|
|
667
|
+
const next = transitionPane(machine.state, event)
|
|
668
|
+
machine.state = next.state
|
|
669
|
+
next.effects.forEach(perform)
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
function dispatchBinding(binding: string, event: BindingEvent) {
|
|
673
|
+
if (event.type === "tab.closed") {
|
|
674
|
+
handles.get(binding)?.activity.delete(event.tabID)
|
|
675
|
+
handles.get(binding)?.background.delete(event.tabID)
|
|
676
|
+
handles.get(binding)?.pluginTabs.forget(event.tabID)
|
|
677
|
+
handles.get(binding)?.passkeys.remove(event.tabID)
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
dispatch({ type: "binding", binding, event })
|
|
681
|
+
|
|
682
|
+
// Extensions hear which tab is active in a window.
|
|
683
|
+
if (event.type === "tab.focused" && handles.get(binding)?.shared) {
|
|
684
|
+
const focused = page(binding, event.tabID)
|
|
685
|
+
|
|
686
|
+
if (focused) input.profile.extensionTabs.activated(focused.contents.id)
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
function perform(effect: PaneEffect) {
|
|
691
|
+
if (effect.type === "save-restore") {
|
|
692
|
+
const activities = Array.from(handles.values()).flatMap((handle) => (handle.storageKey === effect.storageKey ? [handle.activity] : []))
|
|
693
|
+
|
|
694
|
+
return restore.save(effect.storageKey, effect.snapshot, (tabID) =>
|
|
695
|
+
activities.map((activity) => activity.get(tabID)).find((tab) => !!tab && agentDriven(tab)),
|
|
696
|
+
)
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
if (effect.type === "remove-restore") return restore.remove(effect.storageKey)
|
|
700
|
+
|
|
701
|
+
if (effect.type === "warn") return void runtime.runFork(Effect.logWarning(effect.message, effect.detail))
|
|
702
|
+
const handle = handles.get(effect.binding)
|
|
703
|
+
|
|
704
|
+
if (!handle) return
|
|
705
|
+
|
|
706
|
+
if (effect.type === "start-timer") {
|
|
707
|
+
handle.timer = setTimeout(() => dispatchBinding(effect.binding, { type: "register.timed-out" }), effect.ms)
|
|
708
|
+
|
|
709
|
+
return
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
if (effect.type === "resolve-register") {
|
|
713
|
+
clearTimeout(handle.timer)
|
|
714
|
+
|
|
715
|
+
return handle.registered.resolve()
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
if (effect.type === "emit") {
|
|
719
|
+
// A binding's last state says why it closed. The window lists no tab of a session another window took or the
|
|
720
|
+
// server lacks, so the log names the reason, and how many tabs the window keeps for its next registration.
|
|
721
|
+
if (effect.event.type === "state")
|
|
722
|
+
input.log.write("info", "browser pane closed", { session: handle.session, reason: effect.event.error, kept: effect.event.state?.tabs.length ?? 0 })
|
|
723
|
+
|
|
724
|
+
return emit(effect.binding, effect.event)
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
if (effect.type === "report") {
|
|
728
|
+
emit(effect.binding, effect.event)
|
|
729
|
+
|
|
730
|
+
return handle.sendState?.(inventory(effect.binding, "agent"))
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
if (effect.type === "abort-requests")
|
|
734
|
+
return effect.requestIDs.forEach((requestID) => handle.requests.get(requestID)?.abort(effect.ended && new PageEndedError(effect.ended)))
|
|
735
|
+
|
|
736
|
+
if (effect.type === "release-pages")
|
|
737
|
+
return effect.attempts.forEach((attempt) => {
|
|
738
|
+
const page = handle.pages.get(attempt)
|
|
739
|
+
handle.pages.delete(attempt)
|
|
740
|
+
|
|
741
|
+
if (page) release(page)
|
|
742
|
+
})
|
|
743
|
+
handles.delete(effect.binding)
|
|
744
|
+
clearTimeout(handle.timer)
|
|
745
|
+
handle.registered.reject(new Error("browser.pane.registration.closed"))
|
|
746
|
+
handle.cleanup()
|
|
747
|
+
handle.abort.abort()
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
function owned(window: number, binding: string) {
|
|
751
|
+
if (!selectOwnedBinding(machine.state, window, binding)) throw new Error("browser.pane.unavailable")
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
/** To the window only, while the binding's handle exists; a close event goes out before its teardown. */
|
|
755
|
+
function emit(binding: string, event: PaneEvent) {
|
|
756
|
+
const handle = handles.get(binding)
|
|
757
|
+
|
|
758
|
+
if (!handle || handle.win.isDestroyed() || handle.win.webContents.isDestroyed()) return
|
|
759
|
+
input.emit(handle.window, { binding, event })
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
/** Extensions whose pages may open in the binding's tabs: the profile's, which only the profile partition loads. */
|
|
763
|
+
function extensions(binding: string) {
|
|
764
|
+
return handles.get(binding)?.shared ? input.profile.extensionIDs() : []
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
function release(page: BrowserPage) {
|
|
768
|
+
try {
|
|
769
|
+
searches.get(page)?.dispose()
|
|
770
|
+
input.profile.permissions.delete(page.nativeID)
|
|
771
|
+
grants.get(page)?.()
|
|
772
|
+
downloads.delete(page.nativeID)
|
|
773
|
+
} finally {
|
|
774
|
+
const done = page.dispose()
|
|
775
|
+
const settled = done.catch(() => undefined)
|
|
776
|
+
disposals.set(page, done)
|
|
777
|
+
releasing.add(settled)
|
|
778
|
+
void settled.finally(() => releasing.delete(settled))
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
function inventory(binding: string, audience: "window" | "agent" = "window"): Browser.State {
|
|
783
|
+
const entry = selectBinding(machine.state, binding)
|
|
784
|
+
|
|
785
|
+
return entry ? selectInventory(entry, audience) : { tabs: [], focusedTabID: null }
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
function remoteSource(binding: string) {
|
|
789
|
+
const source = handles.get(binding)?.source
|
|
790
|
+
|
|
791
|
+
return source?.type === "remote" ? source : undefined
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
function pagePolicy(binding: string) {
|
|
795
|
+
return { fileRoots: selectFileRoots(machine.state, binding), extensions: extensions(binding), home: homedir(), remote: remoteSource(binding)?.prefix, artifacts: true }
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
/** The tab's current page. */
|
|
799
|
+
function page(binding: string, tabID: Browser.TabID) {
|
|
800
|
+
const attempt = selectPageAttempt(machine.state, binding, tabID)
|
|
801
|
+
|
|
802
|
+
return attempt === undefined ? undefined : handles.get(binding)?.pages.get(attempt)
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
/** The tab's page, created the first time the pane shows a restored or crashed tab or a command names it. */
|
|
806
|
+
function load(binding: string, tabID: Browser.TabID, navigateTo?: string) {
|
|
807
|
+
const existing = page(binding, tabID)
|
|
808
|
+
|
|
809
|
+
if (existing) return existing
|
|
810
|
+
const slot = selectTabSlot(machine.state, binding, tabID)
|
|
811
|
+
|
|
812
|
+
if (slot?.status !== "unloaded") return undefined
|
|
813
|
+
const tab = slot.tab
|
|
814
|
+
const denied = restoreRefusal(tab.url, pagePolicy(binding))
|
|
815
|
+
|
|
816
|
+
if (denied && navigateTo === undefined) {
|
|
817
|
+
dispatchBinding(binding, { type: "restore.refused", tabID, reason: denied })
|
|
818
|
+
throw new CodedError(Browser.FailureCode.previewUnavailable, denied === "browser.restore.outside" ? "This file is now outside the session’s workspace. Open a file in the current workspace instead." : "This saved address is no longer allowed in this session.")
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
// The user can replace the refused address. Check the replacement before allocating even a blank page.
|
|
822
|
+
if (denied && navigateTo !== undefined) normalizeURL(navigateTo, pagePolicy(binding))
|
|
823
|
+
|
|
824
|
+
// A crashed tab's error belongs to its last page; the new page reports its own.
|
|
825
|
+
return create(binding, {
|
|
826
|
+
restore: {
|
|
827
|
+
id: tab.id,
|
|
828
|
+
url: denied ? "about:blank" : tab.url,
|
|
829
|
+
title: tab.title,
|
|
830
|
+
loading: false,
|
|
831
|
+
canGoBack: false,
|
|
832
|
+
canGoForward: false,
|
|
833
|
+
generation: tab.generation,
|
|
834
|
+
},
|
|
835
|
+
})
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
function create(
|
|
839
|
+
binding: string,
|
|
840
|
+
options: {
|
|
841
|
+
readonly restore?: Browser.Tab
|
|
842
|
+
readonly initialize?: boolean
|
|
843
|
+
readonly popupOptions?: Electron.BrowserWindowConstructorOptions
|
|
844
|
+
readonly activity?: TabActivity
|
|
845
|
+
/** The tab whose page opened this one, which joins its pop-up group. */
|
|
846
|
+
readonly opener?: Browser.TabID
|
|
847
|
+
/** Shows the opener's tab why an address this tab was opened for could not open. */
|
|
848
|
+
readonly refused?: (url: string) => void
|
|
849
|
+
/** The tab whose page or link opened this one, which it stands next to, and whether it takes the pane. */
|
|
850
|
+
readonly beside?: { readonly tabID: Browser.TabID; readonly front: boolean }
|
|
851
|
+
} = {},
|
|
852
|
+
) {
|
|
853
|
+
const entry = selectBinding(machine.state, binding)
|
|
854
|
+
const handle = handles.get(binding)
|
|
855
|
+
|
|
856
|
+
if (entry?.status !== "attached" || !handle?.network)
|
|
857
|
+
throw new Error("Browser network is not ready; no tab was opened.")
|
|
858
|
+
const id = options.restore?.id ?? Browser.TabID.make(`tab_${crypto.randomUUID()}`)
|
|
859
|
+
// Whoever makes the tab says whose it is (`createdActivity`). An agent command running in another tab does not.
|
|
860
|
+
const activity = handle.activity.get(id) ?? options.activity ?? { agentRuns: 0 }
|
|
861
|
+
handle.activity.set(id, activity)
|
|
862
|
+
handle.passkeys.join(id, options.opener)
|
|
863
|
+
const attempt = entry.nextAttempt
|
|
864
|
+
const win = handle.win
|
|
865
|
+
// Every callback is fenced to this page: a later page of the same tab has another attempt.
|
|
866
|
+
const current = () => isCurrentPage(machine.state, binding, id, attempt)
|
|
867
|
+
const focused = () => isFocusedPage(machine.state, binding, id, attempt)
|
|
868
|
+
|
|
869
|
+
const fail = (ended: PageEnd) => {
|
|
870
|
+
if (current())
|
|
871
|
+
dispatchBinding(binding, {
|
|
872
|
+
type: "tab.crashed",
|
|
873
|
+
tabID: id,
|
|
874
|
+
attempt,
|
|
875
|
+
tab: page.contents.isDestroyed() ? undefined : page.state(),
|
|
876
|
+
ended,
|
|
877
|
+
})
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
const page = createBrowserPage(win, {
|
|
881
|
+
id,
|
|
882
|
+
activity,
|
|
883
|
+
userInput: () => { if (current()) handle.pluginTabs.forget(id) },
|
|
884
|
+
passkeysRestricted: () => handle.passkeys.restricted(id),
|
|
885
|
+
// Every page of the group refuses from now on, or fails where it cannot; one created later refuses from its first
|
|
886
|
+
// document.
|
|
887
|
+
restrictPasskeys: () =>
|
|
888
|
+
handle.passkeys.restrict(id).forEach((tabID) => {
|
|
889
|
+
const attempt = selectPageAttempt(machine.state, binding, tabID)
|
|
890
|
+
|
|
891
|
+
if (attempt !== undefined) void handle.pages.get(attempt)?.restrictPasskeys().catch(() => undefined)
|
|
892
|
+
}),
|
|
893
|
+
partition: handle.partition,
|
|
894
|
+
network: handle.network,
|
|
895
|
+
initialize: options.initialize,
|
|
896
|
+
restore: options.restore,
|
|
897
|
+
popupOptions: options.popupOptions,
|
|
898
|
+
opened: options.refused && {
|
|
899
|
+
close: () => {
|
|
900
|
+
if (current()) dispatchBinding(binding, { type: "tab.closed", tabID: id, opener: options.opener })
|
|
901
|
+
},
|
|
902
|
+
refused: options.refused,
|
|
903
|
+
},
|
|
904
|
+
fileRoots: () => selectFileRoots(machine.state, binding),
|
|
905
|
+
workspace: handle.workspace?.(),
|
|
906
|
+
previewFailure: handle.previewFailure,
|
|
907
|
+
artifacts: handle.artifacts?.(),
|
|
908
|
+
remote: remoteSource(binding),
|
|
909
|
+
local: handle.shared,
|
|
910
|
+
// What a web page waits for before its load is issued: in the profile its content filters, in a remote server's
|
|
911
|
+
// partition the first copy of the sign-ins, so a restored tab opens signed in.
|
|
912
|
+
waitForFilters: handle.shared ? input.profile.waitForFilters : (url, signal) => (/^https?:\/\//i.test(url) ? handle.signedIn?.(signal) : undefined),
|
|
913
|
+
signal: handle.abort.signal,
|
|
914
|
+
extensions: () => extensions(binding),
|
|
915
|
+
shared,
|
|
916
|
+
menu: {
|
|
917
|
+
t: input.t,
|
|
918
|
+
extensions: (contents, params) => handle.shared ? input.profile.extensionMenu(contents, params) : [],
|
|
919
|
+
navigate: async (type) => {
|
|
920
|
+
const action = type === "hardReload" ? { type: "reload", tabID: id, ignoreCache: true } as const : { type, tabID: id }
|
|
921
|
+
|
|
922
|
+
if (current()) await execute(binding, { action, files: [] }, handle.abort.signal, "user")
|
|
923
|
+
},
|
|
924
|
+
open: async (url, background) => { if (current()) await execute(binding, { action: { type: "tabs.open", url, ...(background && { focus: false }) }, files: [] }, handle.abort.signal, "user", "new", { activity: childActivity(activity), beside: id }) },
|
|
925
|
+
verifier: input.verifier,
|
|
926
|
+
},
|
|
927
|
+
embeds: input.embeds,
|
|
928
|
+
sites: input.sites,
|
|
929
|
+
serverPartition: !handle.shared,
|
|
930
|
+
prompt: (view) => {
|
|
931
|
+
if (!current()) return
|
|
932
|
+
|
|
933
|
+
// The page held the keyboard; the window's document takes it, so the prompt can.
|
|
934
|
+
if (view?.focus && focused() && win.isFocused()) win.webContents.focus()
|
|
935
|
+
emit(binding, { type: "prompt", tabID: id, prompt: view })
|
|
936
|
+
},
|
|
937
|
+
closeTab: () => {
|
|
938
|
+
if (current()) dispatchBinding(binding, { type: "tab.closed", tabID: id })
|
|
939
|
+
},
|
|
940
|
+
focusPage: () => {
|
|
941
|
+
if (focused() && win.isFocused() && page.view.getVisible()) page.contents.focus()
|
|
942
|
+
},
|
|
943
|
+
front: () => focused() && win.isFocused(),
|
|
944
|
+
system: input.system,
|
|
945
|
+
warn: (message) => {
|
|
946
|
+
if (warned.has(message)) return
|
|
947
|
+
warned.add(message)
|
|
948
|
+
void runtime.runFork(Effect.logWarning(message))
|
|
949
|
+
},
|
|
950
|
+
fail,
|
|
951
|
+
log: (level, message, data) => input.log.write(level, message, { session: handle.session, ...data }),
|
|
952
|
+
refused: (notice, token, site) => {
|
|
953
|
+
if (current()) emit(binding, { type: "refusal", tabID: id, notice, token, site })
|
|
954
|
+
},
|
|
955
|
+
publish: (error) => {
|
|
956
|
+
if (current()) dispatchBinding(binding, { type: "tab.published", tabID: id, attempt, tab: page.state(), error })
|
|
957
|
+
},
|
|
958
|
+
inspect: (event) => {
|
|
959
|
+
if (current()) emit(binding, { type: "inspect", tabID: id, ...event })
|
|
960
|
+
},
|
|
961
|
+
// The window files the icon under the URL from the preceding inventory update.
|
|
962
|
+
detail: (value) => {
|
|
963
|
+
if (current()) emit(binding, { type: "page", tabID: id, ...value })
|
|
964
|
+
},
|
|
965
|
+
zoomed: () => handles.get(binding)?.pages.forEach((page) => page.detail()),
|
|
966
|
+
toolbar: input.toolbar,
|
|
967
|
+
navigationDeadlineMs: input.navigationDeadlineMs,
|
|
968
|
+
shortcut: (shortcut) => {
|
|
969
|
+
if (!focused() || win.isDestroyed()) return
|
|
970
|
+
page.focusHost()
|
|
971
|
+
emit(binding, { type: "shortcut", ...shortcut })
|
|
972
|
+
},
|
|
973
|
+
focused: () => {
|
|
974
|
+
if (focused()) emit(binding, { type: "focused", tabID: id })
|
|
975
|
+
},
|
|
976
|
+
hidden: () => {
|
|
977
|
+
if (handle.shared) input.profile.extensionTabs.hidden(page.contents.id)
|
|
978
|
+
},
|
|
979
|
+
popup: (popupOptions, background, activity, refused) => {
|
|
980
|
+
const agent = activityOwner(activity) === "agent"
|
|
981
|
+
// The person's tab stands beside this one. The agent's goes to the end, as its own tabs do.
|
|
982
|
+
const popup = create(binding, { initialize: false, popupOptions, activity, opener: id, refused, beside: agent ? undefined : { tabID: id, front: !background } })
|
|
983
|
+
|
|
984
|
+
if (agent) {
|
|
985
|
+
announce(binding, popup.state().id, "none", !background)
|
|
986
|
+
|
|
987
|
+
return popup.contents
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
if (!background) dispatchBinding(binding, { type: "tab.focused", tabID: popup.state().id })
|
|
991
|
+
|
|
992
|
+
return popup.contents
|
|
993
|
+
},
|
|
994
|
+
})
|
|
995
|
+
|
|
996
|
+
// Construction succeeded; take ownership before registering with the profile, machine or window.
|
|
997
|
+
using registering = new DisposableStack()
|
|
998
|
+
registering.defer(() => {
|
|
999
|
+
if (current()) return dispatchBinding(binding, { type: "tab.crashed", tabID: id, attempt })
|
|
1000
|
+
handle.pages.delete(attempt)
|
|
1001
|
+
release(page)
|
|
1002
|
+
})
|
|
1003
|
+
void page.ready.catch(() => undefined)
|
|
1004
|
+
|
|
1005
|
+
if (handle.shared) {
|
|
1006
|
+
grants.set(page, input.profile.extensionTabs.register(extensionTab(binding, id, page, win, focused)))
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
handle.pages.set(attempt, page)
|
|
1010
|
+
searches.set(page, createPageFind(page.contents, (view) => {
|
|
1011
|
+
if (current()) emit(binding, { type: "find", tabID: id, view })
|
|
1012
|
+
}, () => {
|
|
1013
|
+
if (focused() && win.isFocused() && page.view.getVisible()) page.contents.focus()
|
|
1014
|
+
}))
|
|
1015
|
+
downloads.set(page.contents.id, page.download)
|
|
1016
|
+
input.profile.permissions.set(page.contents.id, page.permissions)
|
|
1017
|
+
dispatchBinding(binding, { type: "tab.opened", tabID: id, attempt, tab: options.restore ?? page.state(), beside: options.beside })
|
|
1018
|
+
// Straight to the window, not through the server report: the embed is local to this desktop.
|
|
1019
|
+
emit(binding, { type: "embed", tabID: id, embed: page.embed })
|
|
1020
|
+
// A page that does not become ready reports that itself, through `fail`.
|
|
1021
|
+
void page.ready.then(() => {
|
|
1022
|
+
if (current()) dispatchBinding(binding, { type: "tab.published", tabID: id, attempt, tab: page.state() })
|
|
1023
|
+
}, () => undefined)
|
|
1024
|
+
|
|
1025
|
+
registering.move()
|
|
1026
|
+
|
|
1027
|
+
return page
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
/**
|
|
1031
|
+
* A tab as extensions drive it, through the same paths and address policy as the window's and the agent's commands:
|
|
1032
|
+
* `chrome.tabs.create` opens a tab in this pane, `update` navigates or focuses it, `remove` closes it.
|
|
1033
|
+
*/
|
|
1034
|
+
function extensionTab(
|
|
1035
|
+
binding: string,
|
|
1036
|
+
tabID: Browser.TabID,
|
|
1037
|
+
page: BrowserPage,
|
|
1038
|
+
win: BrowserWindow,
|
|
1039
|
+
focused: () => boolean,
|
|
1040
|
+
) {
|
|
1041
|
+
const guarded = (url: string, caller: string) => {
|
|
1042
|
+
if (URL.parse(url)?.protocol === "chrome-extension:" && !extensionResource(url, `chrome-extension://${caller}`, (id) => page.contents.session.extensions.getExtension(id)))
|
|
1043
|
+
throw new Error("Extensions can open only their own extension pages.")
|
|
1044
|
+
|
|
1045
|
+
if (/^file:/i.test(url)) throw new Error("Extensions do not have file access.")
|
|
1046
|
+
const reason = refusal(url, { fileRoots: selectFileRoots(machine.state, binding), extensions: extensions(binding) })
|
|
1047
|
+
|
|
1048
|
+
if (reason) throw new Error(`This browser does not open ${url}.`)
|
|
1049
|
+
|
|
1050
|
+
return url
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
return {
|
|
1054
|
+
contents: page.contents,
|
|
1055
|
+
window: win,
|
|
1056
|
+
focused,
|
|
1057
|
+
open: async (url: string, active: boolean, caller: string) => {
|
|
1058
|
+
const opened = await execute(
|
|
1059
|
+
binding,
|
|
1060
|
+
{ action: { type: "tabs.open", url: guarded(url, caller), focus: active }, files: [] },
|
|
1061
|
+
new AbortController().signal,
|
|
1062
|
+
"user",
|
|
1063
|
+
"new",
|
|
1064
|
+
{ activity: page.childActivity() },
|
|
1065
|
+
)
|
|
1066
|
+
|
|
1067
|
+
const created = Option.getOrUndefined(Schema.decodeUnknownOption(Schema.Struct({ id: Browser.TabID }))(opened.value))
|
|
1068
|
+
const contents = created ? load(binding, created.id)?.contents : undefined
|
|
1069
|
+
|
|
1070
|
+
if (!contents) throw new Error("The tab did not open.")
|
|
1071
|
+
|
|
1072
|
+
return contents
|
|
1073
|
+
},
|
|
1074
|
+
focus: () => dispatchBinding(binding, { type: "tab.focused", tabID }),
|
|
1075
|
+
close: () => dispatchBinding(binding, { type: "tab.closed", tabID }),
|
|
1076
|
+
navigate: async (url: string, caller: string) => {
|
|
1077
|
+
await execute(
|
|
1078
|
+
binding,
|
|
1079
|
+
{ action: { type: "navigate", tabID, url: guarded(url, caller) }, files: [] },
|
|
1080
|
+
new AbortController().signal,
|
|
1081
|
+
"user",
|
|
1082
|
+
)
|
|
1083
|
+
},
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
/** Reports the page's state after a command, which may have changed it without a page event yet. */
|
|
1088
|
+
function announce(binding: string, tabID: Browser.TabID, reveal: "none" | "tab", active: boolean) {
|
|
1089
|
+
if (active) dispatchBinding(binding, { type: "tab.active", tabID })
|
|
1090
|
+
const handle = handles.get(binding)
|
|
1091
|
+
|
|
1092
|
+
// A hidden or minimized window hears it too: its model selects the tab, so the page shows when the person returns.
|
|
1093
|
+
if (handle) emit(binding, { type: "activity", tabID, reveal: handle.background.has(tabID) ? "none" : reveal })
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
function refresh(binding: string, tabID: Browser.TabID, page: BrowserPage) {
|
|
1097
|
+
const attempt = selectPageAttempt(machine.state, binding, tabID)
|
|
1098
|
+
|
|
1099
|
+
if (attempt === undefined || handles.get(binding)?.pages.get(attempt) !== page) return
|
|
1100
|
+
dispatchBinding(binding, { type: "tab.published", tabID, attempt, tab: page.state() })
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
async function execute(binding: string, command: Browser.Command, signal: AbortSignal, origin: "agent" | "user", intent: "present" | "new" = "new", from?: { readonly activity: TabActivity; readonly beside?: Browser.TabID }, created?: (id: Browser.TabID) => void): Promise<Browser.Result> {
|
|
1104
|
+
const action = command.action
|
|
1105
|
+
|
|
1106
|
+
const present = (tabID: Browser.TabID, reveal: "none" | "tab" = "none", active = true) => {
|
|
1107
|
+
if (origin === "user") return dispatchBinding(binding, { type: "tab.focused", tabID })
|
|
1108
|
+
announce(binding, tabID, reveal, active)
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
// The first load of a tab this command made or shows a file in. A tab that stays (`keepsOpenedTab`) is an ordinary
|
|
1112
|
+
// tab from here on, whatever its load came to: its command goes on as for one that loaded, so the tab is reported,
|
|
1113
|
+
// shown as asked, and held by whoever opened it. Returns why the load did not finish, if it did not. Any other
|
|
1114
|
+
// failure is thrown, and undoes a tab the command made.
|
|
1115
|
+
const firstLoad = (tab: BrowserPage, tabID: Browser.TabID, url: string) =>
|
|
1116
|
+
tab.execute({ action: { type: "navigate", tabID, url }, files: [] }, signal, origin).then(
|
|
1117
|
+
() => undefined,
|
|
1118
|
+
(error: Error) => {
|
|
1119
|
+
if (!keepsOpenedTab(error, origin)) throw error
|
|
1120
|
+
|
|
1121
|
+
return error
|
|
1122
|
+
},
|
|
1123
|
+
)
|
|
1124
|
+
|
|
1125
|
+
// The person's tab says by itself that its page still loads or failed. The agent is told, with the tab to go on
|
|
1126
|
+
// with: its open made a tab, though it has no page to answer with yet.
|
|
1127
|
+
const stillLoading = (unfinished: Error | undefined, tabID: Browser.TabID) => {
|
|
1128
|
+
if (unfinished && origin === "agent")
|
|
1129
|
+
throw new Error(`${unfinished.message} The tab stays open as ${tabID}: use that tabID with browser.wait, browser.reload or browser.tabs.close, and do not open the address again.`, { cause: unfinished })
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
// Undoes a tab this command made and could show no page in. The log names it: no person and no close tool did.
|
|
1133
|
+
const rollback = (tabID: Browser.TabID, opened: BrowserPage) => {
|
|
1134
|
+
if (page(binding, tabID) !== opened) return
|
|
1135
|
+
input.log.write("warn", "browser tab closed: its open failed", { session: handles.get(binding)?.session, action: action.type, origin })
|
|
1136
|
+
dispatchBinding(binding, { type: "tab.closed", tabID })
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
const acquire = (id: Browser.TabID) => {
|
|
1140
|
+
if (origin !== "agent") return load(binding, id, action.type === "navigate" ? action.url : undefined)
|
|
1141
|
+
const handle = handles.get(binding)
|
|
1142
|
+
const activity = handle?.activity.get(id) ?? { agentRuns: 0 }
|
|
1143
|
+
const current = page(binding, id)
|
|
1144
|
+
handle?.pluginTabs.forget(id)
|
|
1145
|
+
recordPageInput(activity, "agent")
|
|
1146
|
+
handle?.activity.set(id, activity)
|
|
1147
|
+
|
|
1148
|
+
// The agent may only focus the tab, which runs no command on its page: the refusal starts now all the same, and
|
|
1149
|
+
// where it cannot, the page fails.
|
|
1150
|
+
void current?.restrictPasskeys().catch(() => undefined)
|
|
1151
|
+
|
|
1152
|
+
return load(binding, id)
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
if (signal.aborted)
|
|
1156
|
+
throw new Error(
|
|
1157
|
+
"Browser request was cancelled. Do not repeat a mutating action until you have inspected its outcome.",
|
|
1158
|
+
)
|
|
1159
|
+
|
|
1160
|
+
if (action.type === "tabs.list") return { value: inventory(binding, origin === "agent" ? "agent" : "window"), files: [] }
|
|
1161
|
+
|
|
1162
|
+
// The address a tab loads this workspace file from, once the session is known to read it still.
|
|
1163
|
+
const fileURL = async (path: string) => {
|
|
1164
|
+
const roots = selectFileRoots(machine.state, binding)
|
|
1165
|
+
const remote = remoteSource(binding)
|
|
1166
|
+
const url = remote ? `${remote.prefix}${path.split("/").map(encodeURIComponent).join("/")}` : roots[0] && workspaceFileURL(roots[0], path)
|
|
1167
|
+
|
|
1168
|
+
if (!url || !(remote ? Number.isSafeInteger(await remote.stat(path, signal)) : await workspaceFile(input.verifier, url, roots)))
|
|
1169
|
+
throw new CodedError(Browser.FailureCode.previewUnavailable, "The workspace file no longer exists or cannot be read by this session.")
|
|
1170
|
+
signal.throwIfAborted()
|
|
1171
|
+
normalizeURL(url, pagePolicy(binding))
|
|
1172
|
+
|
|
1173
|
+
return url
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
if (action.type === "preview") {
|
|
1177
|
+
if (artifactKind(action.path) === "html") {
|
|
1178
|
+
const url = await fileURL(action.path)
|
|
1179
|
+
const existing = fileTab(inventory(binding).tabs, url)
|
|
1180
|
+
|
|
1181
|
+
if (existing) handles.get(binding)?.pluginTabs.forget(existing.id)
|
|
1182
|
+
const tab = existing ? acquire(existing.id) : create(binding, { activity: createdActivity(origin) })
|
|
1183
|
+
|
|
1184
|
+
if (!tab) throw new Error("Workspace preview tab is unavailable.")
|
|
1185
|
+
using opening = new DisposableStack()
|
|
1186
|
+
const tabID = tab.state().id
|
|
1187
|
+
|
|
1188
|
+
if (!existing) opening.defer(() => rollback(tabID, tab))
|
|
1189
|
+
const unfinished = await firstLoad(tab, tabID, url)
|
|
1190
|
+
refresh(binding, tabID, tab)
|
|
1191
|
+
// A workspace file is opened to show it to the person: it takes the pane even when another tab is selected there.
|
|
1192
|
+
present(tabID, "tab")
|
|
1193
|
+
opening.move()
|
|
1194
|
+
stillLoading(unfinished, tabID)
|
|
1195
|
+
|
|
1196
|
+
return { value: { path: action.path, tabID, url: tab.state().url, tab: tab.state() }, files: [] }
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
// The window owns file tabs. A session that is not on screen does not open the file, now or later.
|
|
1200
|
+
const win = handles.get(binding)?.win
|
|
1201
|
+
|
|
1202
|
+
if (win && !win.isDestroyed() && win.isVisible() && !win.isMinimized()) emit(binding, { type: "preview", path: action.path })
|
|
1203
|
+
|
|
1204
|
+
return { value: { path: action.path }, files: [] }
|
|
1205
|
+
}
|
|
1206
|
+
|
|
1207
|
+
if (action.type === "tabs.open") {
|
|
1208
|
+
// The page refuses the agent's navigation to an extension page too; refusing first leaves no blank tab behind.
|
|
1209
|
+
const refused = origin === "agent" ? agentRefusal(action, { url: "about:blank", origin: "null" }) : undefined
|
|
1210
|
+
|
|
1211
|
+
if (refused) throw new Error(refused)
|
|
1212
|
+
|
|
1213
|
+
if (action.url !== undefined) normalizeURL(action.url, pagePolicy(binding))
|
|
1214
|
+
|
|
1215
|
+
if (action.url?.startsWith("artifact:")) {
|
|
1216
|
+
const available = await handles.get(binding)?.artifacts?.().exists(action.url)
|
|
1217
|
+
signal.throwIfAborted()
|
|
1218
|
+
|
|
1219
|
+
if (!available) throw origin === "agent" ? missingArtifact() : new Error("browser.artifact.missing")
|
|
1220
|
+
}
|
|
1221
|
+
|
|
1222
|
+
const file = reusableFile(action.url, intent)
|
|
1223
|
+
|
|
1224
|
+
if (file) {
|
|
1225
|
+
const existing = inventory(binding).tabs.find((tab) => {
|
|
1226
|
+
const live = page(binding, tab.id)
|
|
1227
|
+
|
|
1228
|
+
return tab.url.split(/[?#]/, 1)[0] === file || (!!live && openingFiles.get(live) === file)
|
|
1229
|
+
})
|
|
1230
|
+
|
|
1231
|
+
if (existing) {
|
|
1232
|
+
dispatchBinding(binding, { type: "tab.focused", tabID: existing.id })
|
|
1233
|
+
|
|
1234
|
+
return { value: existing, files: [] }
|
|
1235
|
+
}
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
// A tab a page's own link or menu opened stands next to that page's tab; any other goes to the end.
|
|
1239
|
+
const opened = create(binding, {
|
|
1240
|
+
activity: createdActivity(origin, from?.activity),
|
|
1241
|
+
beside: from?.beside === undefined ? undefined : { tabID: from.beside, front: action.focus !== false },
|
|
1242
|
+
})
|
|
1243
|
+
|
|
1244
|
+
const tabID = opened.state().id
|
|
1245
|
+
const shown = agentTabShow(action)
|
|
1246
|
+
|
|
1247
|
+
if (origin === "agent" && shown.background) handles.get(binding)?.background.add(tabID)
|
|
1248
|
+
created?.(tabID)
|
|
1249
|
+
using opening = new DisposableStack()
|
|
1250
|
+
opening.defer(() => rollback(tabID, opened))
|
|
1251
|
+
|
|
1252
|
+
if (file) openingFiles.set(opened, file)
|
|
1253
|
+
|
|
1254
|
+
if (origin === "user" && action.focus !== false) present(tabID)
|
|
1255
|
+
|
|
1256
|
+
try {
|
|
1257
|
+
await opened.ready
|
|
1258
|
+
|
|
1259
|
+
// A new page already loads about:blank, so only another address needs a navigation.
|
|
1260
|
+
const unfinished = action.url === undefined ? undefined : await firstLoad(opened, tabID, action.url)
|
|
1261
|
+
refresh(binding, tabID, opened)
|
|
1262
|
+
|
|
1263
|
+
if (origin === "agent") present(tabID, shown.reveal, action.focus !== false)
|
|
1264
|
+
opening.move()
|
|
1265
|
+
stillLoading(unfinished, tabID)
|
|
1266
|
+
|
|
1267
|
+
return { value: opened.state(), files: [] }
|
|
1268
|
+
} finally {
|
|
1269
|
+
openingFiles.delete(opened)
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1273
|
+
const slot = selectTabSlot(machine.state, binding, action.tabID)
|
|
1274
|
+
|
|
1275
|
+
if (!slot)
|
|
1276
|
+
throw new Error(
|
|
1277
|
+
"Browser tab is unavailable. Call browser.tabs.list({}) and use an existing tabID from this session; a closed tab is not replaced automatically.",
|
|
1278
|
+
)
|
|
1279
|
+
|
|
1280
|
+
if (action.type === "tabs.focus") {
|
|
1281
|
+
const restricted = origin === "agent" ? acquire(action.tabID) : undefined
|
|
1282
|
+
await restricted?.ready
|
|
1283
|
+
const activities = handles.get(binding)?.activity
|
|
1284
|
+
const activity = activities?.get(action.tabID) ?? { agentRuns: 0 }
|
|
1285
|
+
|
|
1286
|
+
recordTabFocus(activity, origin)
|
|
1287
|
+
activities?.set(action.tabID, activity)
|
|
1288
|
+
|
|
1289
|
+
if (origin === "user") {
|
|
1290
|
+
handles.get(binding)?.background.delete(action.tabID)
|
|
1291
|
+
dispatchBinding(binding, { type: "tab.focused", tabID: action.tabID, fromStrip: true })
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1294
|
+
if (origin === "agent") {
|
|
1295
|
+
handles.get(binding)?.background.delete(action.tabID)
|
|
1296
|
+
present(action.tabID, agentTabShow(action).reveal)
|
|
1297
|
+
}
|
|
1298
|
+
|
|
1299
|
+
return { value: restricted?.state() ?? slot.tab, files: [] }
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
if (action.type === "tabs.close") {
|
|
1303
|
+
const closing = page(binding, action.tabID)
|
|
1304
|
+
dispatchBinding(binding, { type: "tab.closed", tabID: action.tabID })
|
|
1305
|
+
|
|
1306
|
+
if (closing) await disposals.get(closing)
|
|
1307
|
+
|
|
1308
|
+
return { value: inventory(binding, origin === "agent" ? "agent" : "window"), files: [] }
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
const url = action.type === "navigate.path" ? await fileURL(action.path) : undefined
|
|
1312
|
+
|
|
1313
|
+
if (action.type === "navigate" || action.type === "navigate.path" || action.type === "back" || action.type === "forward" || action.type === "reload")
|
|
1314
|
+
handles.get(binding)?.pluginTabs.forget(action.tabID)
|
|
1315
|
+
const target = acquire(action.tabID)
|
|
1316
|
+
|
|
1317
|
+
if (!target) throw new Error("Browser tab is unavailable. Call browser.tabs.list({}) and use an existing tabID.")
|
|
1318
|
+
|
|
1319
|
+
// The same navigation as a web address, checks on the tab's generation and site included, and shown as a file is.
|
|
1320
|
+
if (action.type === "navigate.path" && url) {
|
|
1321
|
+
await target.execute({ ...command, action: { type: "navigate", tabID: action.tabID, url } }, signal, origin)
|
|
1322
|
+
refresh(binding, action.tabID, target)
|
|
1323
|
+
present(action.tabID, "tab")
|
|
1324
|
+
|
|
1325
|
+
return { value: { path: action.path, tabID: action.tabID, url: target.state().url, tab: target.state() }, files: [] }
|
|
1326
|
+
}
|
|
1327
|
+
|
|
1328
|
+
const result = await target.execute(command, signal, origin)
|
|
1329
|
+
refresh(binding, action.tabID, target)
|
|
1330
|
+
|
|
1331
|
+
if (origin === "agent" && action.type === "navigate") present(action.tabID, "none", false)
|
|
1332
|
+
|
|
1333
|
+
return result
|
|
1334
|
+
}
|
|
1335
|
+
}
|