@mduan/paseo-cli 0.11.0-fork.36 → 0.11.0-fork.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (23) hide show
  1. package/node_modules/@getpaseo/client/package.json +3 -3
  2. package/node_modules/@getpaseo/highlight/package.json +1 -1
  3. package/node_modules/@getpaseo/plugin/package.json +3 -3
  4. package/node_modules/@getpaseo/protocol/package.json +1 -1
  5. package/node_modules/@getpaseo/relay/package.json +1 -1
  6. package/node_modules/@getpaseo/server/dist/server/builtin-plugins/package.json +1 -1
  7. package/node_modules/@getpaseo/server/dist/server/server/session/daemon/npm-global-cli.js +7 -0
  8. package/node_modules/@getpaseo/server/dist/server/web-ui/_expo/static/css/xterm-3bb1704bf6cb0876640973dc0244b4cb.css.gz +0 -0
  9. package/node_modules/@getpaseo/server/dist/server/web-ui/_expo/static/js/web/desktop-attachment-bridge-e52f9cb2de89e698c51c18241d12cb99.js.gz +0 -0
  10. package/node_modules/@getpaseo/server/dist/server/web-ui/_expo/static/js/web/desktop-attachment-store-8cb998792f7a176d7612229dafb2c2d3.js.gz +0 -0
  11. package/node_modules/@getpaseo/server/dist/server/web-ui/_expo/static/js/web/{index-906d2f4f5f6cb670ae516f04dd636fc3.js → index-b8c45270998cdd560e3a40ec00a172ff.js} +1 -1
  12. package/node_modules/@getpaseo/server/dist/server/web-ui/_expo/static/js/web/{index-906d2f4f5f6cb670ae516f04dd636fc3.js.br → index-b8c45270998cdd560e3a40ec00a172ff.js.br} +0 -0
  13. package/node_modules/@getpaseo/server/dist/server/web-ui/_expo/static/js/web/index-b8c45270998cdd560e3a40ec00a172ff.js.gz +0 -0
  14. package/node_modules/@getpaseo/server/dist/server/web-ui/_expo/static/js/web/indexeddb-attachment-store-cf65163fc7d8cd4c646c36e83771e937.js.gz +0 -0
  15. package/node_modules/@getpaseo/server/dist/server/web-ui/_expo/static/js/web/native-file-attachment-store-da2a50627d6e788990a7f324838c24d2.js.gz +0 -0
  16. package/node_modules/@getpaseo/server/dist/server/web-ui/index.html +1 -1
  17. package/node_modules/@getpaseo/server/dist/server/web-ui/index.html.br +0 -0
  18. package/node_modules/@getpaseo/server/dist/server/web-ui/index.html.gz +0 -0
  19. package/node_modules/@getpaseo/server/dist/server/web-ui/manifest.json.gz +0 -0
  20. package/node_modules/@getpaseo/server/dist/src/server/session/daemon/npm-global-cli.js +7 -0
  21. package/node_modules/@getpaseo/server/package.json +6 -6
  22. package/package.json +7 -7
  23. package/node_modules/@getpaseo/server/dist/server/web-ui/_expo/static/js/web/index-906d2f4f5f6cb670ae516f04dd636fc3.js.gz +0 -0
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getpaseo/client",
3
- "version": "0.11.0-fork.36",
3
+ "version": "0.11.0-fork.37",
4
4
  "description": "Paseo client SDK package",
5
5
  "files": [
6
6
  "dist",
@@ -44,7 +44,7 @@
44
44
  "vitest": "^4.1.6"
45
45
  },
46
46
  "dependencies": {
47
- "@getpaseo/protocol": "0.11.0-fork.36",
48
- "@getpaseo/relay": "0.11.0-fork.36"
47
+ "@getpaseo/protocol": "0.11.0-fork.37",
48
+ "@getpaseo/relay": "0.11.0-fork.37"
49
49
  }
50
50
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getpaseo/highlight",
3
- "version": "0.11.0-fork.36",
3
+ "version": "0.11.0-fork.37",
4
4
  "files": [
5
5
  "dist",
6
6
  "!dist/**/*.map",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getpaseo/plugin",
3
- "version": "0.11.0-fork.36",
3
+ "version": "0.11.0-fork.37",
4
4
  "description": "Paseo plugin SDK package",
5
5
  "files": [
6
6
  "dist",
@@ -66,8 +66,8 @@
66
66
  "test": "vitest run"
67
67
  },
68
68
  "devDependencies": {
69
- "@getpaseo/client": "0.11.0-fork.36",
70
- "@getpaseo/protocol": "0.11.0-fork.36",
69
+ "@getpaseo/client": "0.11.0-fork.37",
70
+ "@getpaseo/protocol": "0.11.0-fork.37",
71
71
  "@types/node": "^20.9.0",
72
72
  "@types/react": "~19.2.0",
73
73
  "react": "19.1.0",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getpaseo/protocol",
3
- "version": "0.11.0-fork.36",
3
+ "version": "0.11.0-fork.37",
4
4
  "description": "Paseo shared protocol schemas and wire types",
5
5
  "files": [
6
6
  "dist",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getpaseo/relay",
3
- "version": "0.11.0-fork.36",
3
+ "version": "0.11.0-fork.37",
4
4
  "description": "Paseo relay for bridging daemon and client connections",
5
5
  "files": [
6
6
  "dist",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getpaseo/builtin-plugins",
3
- "version": "0.11.0-fork.36",
3
+ "version": "0.11.0-fork.37",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "scripts": {
@@ -1,3 +1,4 @@
1
+ import path from "node:path";
1
2
  import { getErrorMessage } from "@getpaseo/protocol/error-utils";
2
3
  import { z } from "zod";
3
4
  import { execCommand } from "../../../utils/spawn.js";
@@ -31,6 +32,12 @@ async function runExternalCommand(command, args, options) {
31
32
  const { stdout, stderr } = await execCommand(command, args, {
32
33
  timeout: options?.timeout,
33
34
  maxBuffer: options?.maxBuffer,
35
+ // Version-manager PATH shims can switch Node installations while the daemon is running.
36
+ envOverlay: {
37
+ PATH: [path.dirname(process.execPath), process.env.PATH]
38
+ .filter(Boolean)
39
+ .join(path.delimiter),
40
+ },
34
41
  });
35
42
  return { exitCode: 0, stdout, stderr };
36
43
  }
@@ -15169,7 +15169,7 @@ __d(function(g,r,i,_a,m,e,d){'use strict';const t=r(d[0]);m.exports=(s,c,n)=>t(s
15169
15169
  __d(function(g,r,i,_a,m,e,d){'use strict';const t=r(d[0]);m.exports=(s,c,n)=>t(s,c,n)<=0},3524,[2992]);
15170
15170
  __d(function(g,r,i,a,m,e,d){'use strict';const t=r(d[0]);m.exports=(n,c,s)=>{try{c=new t(c,s)}catch(t){return!1}return c.test(n)}},3525,[3516]);
15171
15171
  __d(function(g,r,i,a,m,_e,d){"use strict";function e(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.resolveAppVersion=function(){const e=u(t.default?.version);if(e)return e;const o=u(n.default.expoConfig?.version);if(o)return o;const f=u(n.default.manifest?.version);if(f)return f;return null};var n=e(r(d[0])),t=e(r(d[1]));function u(e){if("string"!=typeof e)return null;const n=e.trim();return 0===n.length?null:n}},3526,[702,3527]);
15172
- __d(function(e,t,r,o,i,a,n){i.exports={name:"@getpaseo/app",version:"0.11.0-fork.36",private:!0,main:"index.ts",scripts:{start:"npm run start:expo","start:expo":"cross-env APP_VARIANT=development expo start","reset-project":"node ./scripts/reset-project.js","eas-build-post-install":"npm --prefix ../.. run build:app-deps && npm run build:terminal-webview",android:"npm run android:development","android:development":"npm --prefix ../.. run build:client && cross-env APP_VARIANT=development expo prebuild --platform android --clean --non-interactive && cross-env APP_VARIANT=development expo run:android --variant=debug","android:production":"npm --prefix ../.. run build:client && cross-env APP_VARIANT=production expo prebuild --platform android --clean --non-interactive && cross-env APP_VARIANT=production expo run:android --variant=release","android:release":"npm run android:production","android:clear":"node -e \"require('node:fs').rmSync('android', { recursive: true, force: true })\"",ios:"npm --prefix ../.. run build:client && expo run:ios","ios:release":"npm --prefix ../.. run build:client && expo run:ios --configuration Release",web:"npm --prefix ../.. run build:client && concurrently --kill-others --names protocol,client,expo --prefix-colors yellow,blue,magenta \"npm --prefix ../.. run watch:protocol\" \"npm --prefix ../.. run watch:client\" \"npm run web:expo\"","web:expo":"expo start --web",lint:"expo lint",typecheck:"tsgo --noEmit",test:"vitest run","test:browser":"vitest run --project browser","test:e2e":"playwright test --project=browser","test:e2e:diff-performance":"cross-env PASEO_DIFF_PERF_E2E=1 playwright test --project=browser e2e/browser/diff-performance.spec.ts","test:e2e:stream-smoothness":"cross-env PASEO_AGENT_STREAM_PERF_E2E=1 playwright test --project=browser e2e/browser/agent-stream-smoothness.spec.ts","test:e2e:real":"cross-env E2E_FORK_PASEO_HOME_FROM=../../.dev/paseo-home playwright test --project=real-provider","test:e2e:relay-deployment":"npm --prefix ../.. run build:server && npm --prefix ../.. run build:daemon-web-ui && cross-env E2E_FORK_PASEO_HOME_FROM=../../.dev/paseo-home playwright test --project=relay-deployment e2e/browser/relay-deployment-reconnect.real.spec.ts","test:e2e:ui":"playwright test --ui",build:"npm run build:web","build:web":"npm --prefix ../.. run build:app-deps && expo export --platform web","profile:composer-typing":"node ./scripts/profile-composer-typing.mjs","profile:explorer-toggle":"node ./scripts/profile-explorer-toggle.mjs","profile:side-pane":"playwright test --config playwright.profile.config.ts side-pane-performance.spec.ts","profile:workspace-switching":"node ./scripts/profile-workspace-switching.mjs","profile:workspace-tabs":"node ./scripts/profile-workspace-tabs.mjs","deploy:web":"npm run build:web && wrangler pages deploy dist --project-name paseo-app --branch main","build:terminal-webview":"node ./scripts/build-terminal-webview-html.mjs","build:mermaid-runtime":"node ./src/components/markdown/fence/mermaid/build-runtime.mjs"},dependencies:{"@codemirror/commands":"6.10.4","@codemirror/language":"6.12.4","@codemirror/search":"6.7.1","@codemirror/state":"6.7.1","@codemirror/view":"6.43.6","@dnd-kit/core":"^6.3.1","@dnd-kit/sortable":"^10.0.0","@dnd-kit/utilities":"^3.2.2","@floating-ui/react-native":"^0.10.7","@getpaseo/client":"*","@getpaseo/expo-two-way-audio":"*","@getpaseo/highlight":"*","@getpaseo/plugin":"*","@getpaseo/protocol":"*","@gorhom/bottom-sheet":"^5.2.14","@gorhom/portal":"^1.0.14","@marijn/find-cluster-break":"^1.0.2","@mattermost/react-native-paste-input":"2.0.1","@react-native-async-storage/async-storage":"2.2.0","@react-native-masked-view/masked-view":"^0.3.2","@react-native/normalize-colors":"^0.81.5","@react-navigation/native":"^7.1.8","@replit/codemirror-vim":"6.3.0","@shopify/react-native-skia":"2.2.12","@tanstack/react-query":"^5.90.11","@tanstack/react-virtual":"^3.13.21","@xterm/addon-clipboard":"^0.3.0-beta.213","@xterm/addon-fit":"^0.12.0-beta.213","@xterm/addon-image":"^0.10.0-beta.213","@xterm/addon-ligatures":"^0.11.0-beta.213","@xterm/addon-search":"^0.17.0-beta.213","@xterm/addon-unicode11":"^0.10.0-beta.213","@xterm/addon-web-links":"^0.13.0-beta.213","@xterm/addon-webgl":"^0.20.0-beta.212","@xterm/xterm":"^6.1.0-beta.213",buffer:"^6.0.3",expo:"^54.0.18","expo-asset":"~12.0.12","expo-audio":"~1.0.13","expo-build-properties":"^1.0.9","expo-camera":"~17.0.10","expo-clipboard":"~8.0.7","expo-constants":"~18.0.9","expo-crypto":"^15.0.8","expo-dev-client":"^6.0.15","expo-document-picker":"~14.0.8","expo-file-system":"~19.0.17","expo-haptics":"~15.0.7","expo-image":"~3.0.10","expo-image-manipulator":"~14.0.8","expo-image-picker":"^17.0.8","expo-keep-awake":"^15.0.7","expo-linking":"~8.0.8","expo-localization":"~17.0.9","expo-notifications":"^0.32.16","expo-router":"~6.0.13","expo-sharing":"^14.0.8","expo-splash-screen":"~31.0.10","expo-sqlite":"~16.0.10","expo-system-ui":"~6.0.7","fast-deep-equal":"^3.1.3",htmlparser2:"^12.0.0",i18next:"^26.3.0","lucide-react-native":"^0.546.0","markdown-it":"^10.0.0",mermaid:"^11.16.0","mnemonic-id":"^3.2.7",qrcode:"^1.5.4",react:"19.1.0","react-dom":"19.1.0","react-freeze":"1.0.4","react-i18next":"^17.0.8","react-native":"0.81.5","react-native-draggable-flatlist":"^4.0.3","react-native-edge-to-edge":"^1.7.0","react-native-gesture-handler":"~2.28.0","react-native-keyboard-controller":"1.21.12","react-native-markdown-display":"^7.0.2","react-native-nitro-modules":"0.35.5","react-native-reanimated":"~4.3.1","react-native-safe-area-context":"~5.6.0","react-native-screens":"~4.16.0","react-native-svg":"^15.14.0","react-native-uitextview":"^2.2.0","react-native-unistyles":"^3.2.4","react-native-web":"~0.21.0","react-native-webview":"^13.16.0","react-native-worklets":"~0.8.3","tiny-invariant":"^1.3.3",turndown:"^7.2.4","turndown-plugin-gfm":"^1.0.2","use-sync-external-store":"^1.6.0",yaml:"^2.8.4",zod:"^4.4.3",zustand:"^5.0.9"},devDependencies:{"@playwright/test":"^1.56.1","@testing-library/dom":"^10.4.1","@testing-library/react":"^16.3.2","@types/markdown-it":"^14.1.2","@types/node":"~22.19.0","@types/qrcode":"^1.5.6","@types/react":"~19.2.0","@types/turndown":"^5.0.6","@types/ws":"^8.18.1","@vitest/browser":"^4.1.7","@vitest/browser-playwright":"^4.1.7","@xterm/headless":"^6.1.0-beta.213",dotenv:"^17.2.3","eas-cli":"^16.24.1",esbuild:"0.28.1",eslint:"^9.25.0","eslint-config-expo":"~10.0.0","expo-gradle-jvmargs":"^1.1.2","fake-indexeddb":"^6.2.5",jsdom:"^20.0.3","material-icon-theme":"^5.32.0",playwright:"^1.56.1","serve-sim":"^0.1.40",typescript:"~5.9.2",vitest:"^4.1.6",wrangler:"^4.105.0",ws:"^8.20.0"},reanimated:{staticFeatureFlags:{FORCE_REACT_RENDER_FOR_SETTLED_ANIMATIONS:!1}}}},3527,[]);
15172
+ __d(function(e,t,r,o,i,a,n){i.exports={name:"@getpaseo/app",version:"0.11.0-fork.37",private:!0,main:"index.ts",scripts:{start:"npm run start:expo","start:expo":"cross-env APP_VARIANT=development expo start","reset-project":"node ./scripts/reset-project.js","eas-build-post-install":"npm --prefix ../.. run build:app-deps && npm run build:terminal-webview",android:"npm run android:development","android:development":"npm --prefix ../.. run build:client && cross-env APP_VARIANT=development expo prebuild --platform android --clean --non-interactive && cross-env APP_VARIANT=development expo run:android --variant=debug","android:production":"npm --prefix ../.. run build:client && cross-env APP_VARIANT=production expo prebuild --platform android --clean --non-interactive && cross-env APP_VARIANT=production expo run:android --variant=release","android:release":"npm run android:production","android:clear":"node -e \"require('node:fs').rmSync('android', { recursive: true, force: true })\"",ios:"npm --prefix ../.. run build:client && expo run:ios","ios:release":"npm --prefix ../.. run build:client && expo run:ios --configuration Release",web:"npm --prefix ../.. run build:client && concurrently --kill-others --names protocol,client,expo --prefix-colors yellow,blue,magenta \"npm --prefix ../.. run watch:protocol\" \"npm --prefix ../.. run watch:client\" \"npm run web:expo\"","web:expo":"expo start --web",lint:"expo lint",typecheck:"tsgo --noEmit",test:"vitest run","test:browser":"vitest run --project browser","test:e2e":"playwright test --project=browser","test:e2e:diff-performance":"cross-env PASEO_DIFF_PERF_E2E=1 playwright test --project=browser e2e/browser/diff-performance.spec.ts","test:e2e:stream-smoothness":"cross-env PASEO_AGENT_STREAM_PERF_E2E=1 playwright test --project=browser e2e/browser/agent-stream-smoothness.spec.ts","test:e2e:real":"cross-env E2E_FORK_PASEO_HOME_FROM=../../.dev/paseo-home playwright test --project=real-provider","test:e2e:relay-deployment":"npm --prefix ../.. run build:server && npm --prefix ../.. run build:daemon-web-ui && cross-env E2E_FORK_PASEO_HOME_FROM=../../.dev/paseo-home playwright test --project=relay-deployment e2e/browser/relay-deployment-reconnect.real.spec.ts","test:e2e:ui":"playwright test --ui",build:"npm run build:web","build:web":"npm --prefix ../.. run build:app-deps && expo export --platform web","profile:composer-typing":"node ./scripts/profile-composer-typing.mjs","profile:explorer-toggle":"node ./scripts/profile-explorer-toggle.mjs","profile:side-pane":"playwright test --config playwright.profile.config.ts side-pane-performance.spec.ts","profile:workspace-switching":"node ./scripts/profile-workspace-switching.mjs","profile:workspace-tabs":"node ./scripts/profile-workspace-tabs.mjs","deploy:web":"npm run build:web && wrangler pages deploy dist --project-name paseo-app --branch main","build:terminal-webview":"node ./scripts/build-terminal-webview-html.mjs","build:mermaid-runtime":"node ./src/components/markdown/fence/mermaid/build-runtime.mjs"},dependencies:{"@codemirror/commands":"6.10.4","@codemirror/language":"6.12.4","@codemirror/search":"6.7.1","@codemirror/state":"6.7.1","@codemirror/view":"6.43.6","@dnd-kit/core":"^6.3.1","@dnd-kit/sortable":"^10.0.0","@dnd-kit/utilities":"^3.2.2","@floating-ui/react-native":"^0.10.7","@getpaseo/client":"*","@getpaseo/expo-two-way-audio":"*","@getpaseo/highlight":"*","@getpaseo/plugin":"*","@getpaseo/protocol":"*","@gorhom/bottom-sheet":"^5.2.14","@gorhom/portal":"^1.0.14","@marijn/find-cluster-break":"^1.0.2","@mattermost/react-native-paste-input":"2.0.1","@react-native-async-storage/async-storage":"2.2.0","@react-native-masked-view/masked-view":"^0.3.2","@react-native/normalize-colors":"^0.81.5","@react-navigation/native":"^7.1.8","@replit/codemirror-vim":"6.3.0","@shopify/react-native-skia":"2.2.12","@tanstack/react-query":"^5.90.11","@tanstack/react-virtual":"^3.13.21","@xterm/addon-clipboard":"^0.3.0-beta.213","@xterm/addon-fit":"^0.12.0-beta.213","@xterm/addon-image":"^0.10.0-beta.213","@xterm/addon-ligatures":"^0.11.0-beta.213","@xterm/addon-search":"^0.17.0-beta.213","@xterm/addon-unicode11":"^0.10.0-beta.213","@xterm/addon-web-links":"^0.13.0-beta.213","@xterm/addon-webgl":"^0.20.0-beta.212","@xterm/xterm":"^6.1.0-beta.213",buffer:"^6.0.3",expo:"^54.0.18","expo-asset":"~12.0.12","expo-audio":"~1.0.13","expo-build-properties":"^1.0.9","expo-camera":"~17.0.10","expo-clipboard":"~8.0.7","expo-constants":"~18.0.9","expo-crypto":"^15.0.8","expo-dev-client":"^6.0.15","expo-document-picker":"~14.0.8","expo-file-system":"~19.0.17","expo-haptics":"~15.0.7","expo-image":"~3.0.10","expo-image-manipulator":"~14.0.8","expo-image-picker":"^17.0.8","expo-keep-awake":"^15.0.7","expo-linking":"~8.0.8","expo-localization":"~17.0.9","expo-notifications":"^0.32.16","expo-router":"~6.0.13","expo-sharing":"^14.0.8","expo-splash-screen":"~31.0.10","expo-sqlite":"~16.0.10","expo-system-ui":"~6.0.7","fast-deep-equal":"^3.1.3",htmlparser2:"^12.0.0",i18next:"^26.3.0","lucide-react-native":"^0.546.0","markdown-it":"^10.0.0",mermaid:"^11.16.0","mnemonic-id":"^3.2.7",qrcode:"^1.5.4",react:"19.1.0","react-dom":"19.1.0","react-freeze":"1.0.4","react-i18next":"^17.0.8","react-native":"0.81.5","react-native-draggable-flatlist":"^4.0.3","react-native-edge-to-edge":"^1.7.0","react-native-gesture-handler":"~2.28.0","react-native-keyboard-controller":"1.21.12","react-native-markdown-display":"^7.0.2","react-native-nitro-modules":"0.35.5","react-native-reanimated":"~4.3.1","react-native-safe-area-context":"~5.6.0","react-native-screens":"~4.16.0","react-native-svg":"^15.14.0","react-native-uitextview":"^2.2.0","react-native-unistyles":"^3.2.4","react-native-web":"~0.21.0","react-native-webview":"^13.16.0","react-native-worklets":"~0.8.3","tiny-invariant":"^1.3.3",turndown:"^7.2.4","turndown-plugin-gfm":"^1.0.2","use-sync-external-store":"^1.6.0",yaml:"^2.8.4",zod:"^4.4.3",zustand:"^5.0.9"},devDependencies:{"@playwright/test":"^1.56.1","@testing-library/dom":"^10.4.1","@testing-library/react":"^16.3.2","@types/markdown-it":"^14.1.2","@types/node":"~22.19.0","@types/qrcode":"^1.5.6","@types/react":"~19.2.0","@types/turndown":"^5.0.6","@types/ws":"^8.18.1","@vitest/browser":"^4.1.7","@vitest/browser-playwright":"^4.1.7","@xterm/headless":"^6.1.0-beta.213",dotenv:"^17.2.3","eas-cli":"^16.24.1",esbuild:"0.28.1",eslint:"^9.25.0","eslint-config-expo":"~10.0.0","expo-gradle-jvmargs":"^1.1.2","fake-indexeddb":"^6.2.5",jsdom:"^20.0.3","material-icon-theme":"^5.32.0",playwright:"^1.56.1","serve-sim":"^0.1.40",typescript:"~5.9.2",vitest:"^4.1.6",wrangler:"^4.105.0",ws:"^8.20.0"},reanimated:{staticFeatureFlags:{FORCE_REACT_RENDER_FOR_SETTLED_ANIMATIONS:!1}}}},3527,[]);
15173
15173
  __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.createPluginClientRuntime=function(p){const I=(0,l.createPluginClientStateSource)(p.serverId),P=(0,o.createPluginCapabilities)(p,(0,s.createPluginNavigation)({serverId:p.serverId,workspaceId:null}));return Object.assign({},P,{hosts:(0,n.createPluginHosts)((0,t.getHostRuntimeStore)(),p.lifetime.signal),addComposerPill:t=>u.pluginButtonStore.addComposerPill(p,t),addHeaderButton:t=>u.pluginButtonStore.addHeaderButton(p,t),openPanel(t,n){c({installation:p,state:I,panelId:t,options:n})}})};var t=r(d[0]),n=r(d[1]),o=r(d[2]),l=r(d[3]),s=r(d[4]),u=r(d[5]);function c(t){const{installation:n,state:l,panelId:u,options:c}=t,p=c.workspaceId.trim(),I=c.agentId?.trim(),P=(0,s.createPluginNavigation)({serverId:n.serverId,workspaceId:p}),v=I?(0,o.createPluginAgentActionContext)({plugin:n,navigation:P,state:l,workspaceId:p,agentId:I}):(0,o.createPluginWorkspaceActionContext)({plugin:n,navigation:P,state:l,workspaceId:p});if(!v)throw new Error("Plugin panel context is unavailable");v.openPanel(u,{location:c.location})}},3528,[3529,3652,3653,3664,3670,3681]);
15174
15174
  __d(function(g,r,i,a,m,_e,d){"use strict";const e=["password"];function t(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(_e,'__esModule',{value:!0}),_e.isHostRuntimeConnected=te,_e.isHostRuntimeDirectoryLoading=ne,Object.defineProperty(_e,"HostRuntimeController",{enumerable:!0,get:function(){return ye}}),_e.readInitialDaemonConnectionHint=be,_e.hasConfiguredLocalDaemonOverride=function(){return null!==we()},Object.defineProperty(_e,"HostRuntimeStore",{enumerable:!0,get:function(){return De}}),_e.getHostRuntimeStore=Pe,_e.getHostRuntimeConnectionStatusSince=function(e){return Pe().getConnectionStatusSince(e)},_e.useHostRuntimeSnapshot=function(e){const t=(0,s.c)(5);let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=Pe(),t[0]=n):n=t[0];const o=n;let c,h,u;t[1]!==e?(c=t=>o.subscribe(e,t),h=()=>o.getSnapshot(e),u=()=>o.getSnapshot(e),t[1]=e,t[2]=c,t[3]=h,t[4]=u):(c=t[2],h=t[3],u=t[4]);return(0,l.useSyncExternalStore)(c,h,u)},_e.useHostRuntimeClient=function(e){const t=(0,s.c)(5);let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=Pe(),t[0]=n):n=t[0];const o=n;let c,h,u;t[1]!==e?(c=t=>o.subscribe(e,t),h=()=>o.getSnapshot(e)?.client??null,u=()=>o.getSnapshot(e)?.client??null,t[1]=e,t[2]=c,t[3]=h,t[4]=u):(c=t[2],h=t[3],u=t[4]);return(0,l.useSyncExternalStore)(c,h,u)},_e.useHostRuntimeIsConnected=function(e){const t=(0,s.c)(5);let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=Pe(),t[0]=n):n=t[0];const o=n;let c,h,u;t[1]!==e?(c=t=>o.subscribe(e,t),h=()=>te(o.getSnapshot(e)),u=()=>te(o.getSnapshot(e)),t[1]=e,t[2]=c,t[3]=h,t[4]=u):(c=t[2],h=t[3],u=t[4]);return(0,l.useSyncExternalStore)(c,h,u)},_e.useHostRuntimeConnectionStatus=function(e){const t=(0,s.c)(5);let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=Pe(),t[0]=n):n=t[0];const o=n;let c,h,u;t[1]!==e?(c=t=>o.subscribe(e,t),h=()=>o.getSnapshot(e)?.connectionStatus??"connecting",u=()=>o.getSnapshot(e)?.connectionStatus??"connecting",t[1]=e,t[2]=c,t[3]=h,t[4]=u):(c=t[2],h=t[3],u=t[4]);return(0,l.useSyncExternalStore)(c,h,u)},_e.useHostRuntimeConnectionStatuses=function(e){const t=(0,s.c)(7);let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=Pe(),t[0]=n):n=t[0];const o=n;let c;t[1]!==e?(c=()=>e.map(e=>o.getSnapshot(e)?.connectionStatus??"connecting").join("\n"),t[1]=e,t[2]=c):c=t[2];const h=c;let u;t[3]===Symbol.for("react.memo_cache_sentinel")?(u=e=>o.subscribeAll(e),t[3]=u):u=t[3];const p=(0,l.useSyncExternalStore)(u,h,h);let y;if(t[4]!==e||t[5]!==p){const n=p.split("\n");y=new Map(e.map((e,t)=>[e,n[t]])),t[4]=e,t[5]=p,t[6]=y}else y=t[6];return y},_e.useHostRuntimeLastError=function(e){const t=(0,s.c)(5);let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=Pe(),t[0]=n):n=t[0];const o=n;let c,h,u;t[1]!==e?(c=t=>o.subscribe(e,t),h=()=>o.getSnapshot(e)?.lastError??null,u=()=>o.getSnapshot(e)?.lastError??null,t[1]=e,t[2]=c,t[3]=h,t[4]=u):(c=t[2],h=t[3],u=t[4]);return(0,l.useSyncExternalStore)(c,h,u)},_e.useHostRuntimeAgentDirectoryStatus=function(e){const t=(0,s.c)(5);let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=Pe(),t[0]=n):n=t[0];const o=n;let c,h,u;t[1]!==e?(c=t=>o.subscribe(e,t),h=()=>o.getSnapshot(e)?.agentDirectoryStatus??"idle",u=()=>o.getSnapshot(e)?.agentDirectoryStatus??"idle",t[1]=e,t[2]=c,t[3]=h,t[4]=u):(c=t[2],h=t[3],u=t[4]);return(0,l.useSyncExternalStore)(c,h,u)},_e.useHostRuntimeIsDirectoryLoading=function(e){const t=(0,s.c)(5);let n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n=Pe(),t[0]=n):n=t[0];const o=n;let c,h,u;t[1]!==e?(c=t=>o.subscribe(e,t),h=()=>ne(o.getSnapshot(e)),u=()=>ne(o.getSnapshot(e)),t[1]=e,t[2]=c,t[3]=h,t[4]=u):(c=t[2],h=t[3],u=t[4]);return(0,l.useSyncExternalStore)(c,h,u)},_e.useHosts=function(){const e=(0,s.c)(4);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=Pe(),e[0]=t):t=e[0];const n=t;let o,c,h;e[1]===Symbol.for("react.memo_cache_sentinel")?(o=e=>n.subscribeHostList(e),c=()=>n.getHosts(),h=()=>n.getHosts(),e[1]=o,e[2]=c,e[3]=h):(o=e[1],c=e[2],h=e[3]);return(0,l.useSyncExternalStore)(o,c,h)},_e.useHostRegistryStatus=function(){const e=(0,s.c)(4);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=Pe(),e[0]=t):t=e[0];const n=t;let o,c,h;e[1]===Symbol.for("react.memo_cache_sentinel")?(o=e=>n.subscribeHostList(e),c=()=>n.getHostRegistryStatus(),h=()=>n.getHostRegistryStatus(),e[1]=o,e[2]=c,e[3]=h):(o=e[1],c=e[2],h=e[3]);return(0,l.useSyncExternalStore)(o,c,h)},_e.useHostRegistryLoaded=function(){const e=(0,s.c)(4);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=Pe(),e[0]=t):t=e[0];const n=t;let o,c,h;e[1]===Symbol.for("react.memo_cache_sentinel")?(o=e=>n.subscribeHostList(e),c=()=>n.isHostRegistryLoaded(),h=()=>n.isHostRegistryLoaded(),e[1]=o,e[2]=c,e[3]=h):(o=e[1],c=e[2],h=e[3]);return(0,l.useSyncExternalStore)(o,c,h)},_e.useHostConfirmation=function(){const e=(0,s.c)(9);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=Pe(),e[0]=t):t=e[0];const n=t;let o,c,h;e[1]===Symbol.for("react.memo_cache_sentinel")?(o=e=>n.subscribeHostConfirmation(e),c=()=>n.getPendingHostConfirmation(),h=()=>n.getPendingHostConfirmation(),e[1]=o,e[2]=c,e[3]=h):(o=e[1],c=e[2],h=e[3]);const u=(0,l.useSyncExternalStore)(o,c,h);let p,y;e[4]!==u?(p=e=>{u&&n.answerHostConfirmation(u.id,e)},e[4]=u,e[5]=p):p=e[5];e[6]!==u||e[7]!==p?(y={pending:u,answer:p},e[6]=u,e[7]=p,e[8]=y):y=e[8];return y},_e.useHostMutations=function(){const e=(0,s.c)(2);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=Pe(),e[0]=t):t=e[0];const n=t;let o;e[1]===Symbol.for("react.memo_cache_sentinel")?(o={upsertDirectConnection:e=>n.upsertDirectConnection(e),probeAndUpsertDirectConnection:e=>n.probeAndUpsertDirectConnection(e),probeAndUpsertRemoteSshConnection:e=>n.probeAndUpsertRemoteSshConnection(e),beginLinkPairing:()=>n.beginLinkPairing(),renameHost:(e,t)=>n.renameHost(e,t),setHostColor:(e,t)=>n.setHostColor(e,t),setHostBadgeDisplay:(e,t)=>n.setHostBadgeDisplay(e,t),removeHost:e=>n.removeHost(e),removeConnection:(e,t)=>n.removeConnection(e,t)},e[1]=o):o=e[1];return o};var n=t(r(d[0])),s=r(d[1]),o=r(d[2]),c=r(d[3]),l=r(d[4]),h=t(r(d[5])),u=t(r(d[6])),p=r(d[7]),y=r(d[8]),S=r(d[9]),f=r(d[10]),C=r(d[11]),v=r(d[12]),b=r(d[13]),w=r(d[14]),I=r(d[15]),A=r(d[16]),H=r(d[17]),R=r(d[18]),D=r(d[19]),E=r(d[20]),L=r(d[21]),P=r(d[22]),O=r(d[23]),_=r(d[24]),M=r(d[25]),k=r(d[26]),T=r(d[27]),B=r(d[28]),F=r(d[29]),j=r(d[30]),q=r(d[31]),x=r(d[32]),U=r(d[33]),V=r(d[34]),W=r(d[35]),N=r(d[36]),$=r(d[37]),G=r(d[38]),z=r(d[39]),K=r(d[40]),Q=r(d[41]),J=r(d[42]),X=r(d[43]),Y=r(d[44]),Z=r(d[45]);function ee(e,t,n){e[t]=n}function te(e){return"online"===e?.connectionStatus}function ne(e){return!e||("initial_loading"===e.agentDirectoryStatus||"revalidating"===e.agentDirectoryStatus||!e.hasEverLoadedAgentDirectory&&("connecting"===e.connectionStatus||"online"===e.connectionStatus))}function se(e){return e instanceof Error?e.message:String(e)}function ie(e){let t=0;for(let n=0;n<e.length;n+=1)t=31*t+e.charCodeAt(n)|0;return`h_${Math.abs(t).toString(16)}`}function oe(e){return"directSocket"===e.type?{type:"directSocket",endpoint:e.path,display:"socket"}:"directPipe"===e.type?{type:"directPipe",endpoint:e.path,display:"pipe"}:"remoteSsh"===e.type?{type:"remoteSsh",endpoint:e.host,display:e.host}:"directTcp"===e.type?{type:"directTcp",endpoint:e.endpoint,display:e.endpoint}:{type:"relay",endpoint:e.relayEndpoint,display:"relay"}}function re(e){return"connecting"===e.tag||"online"===e.tag||"offline"===e.tag||"error"===e.tag?{id:e.activeConnectionId,connection:e.activeConnection}:{id:null,connection:null}}function ce(e,t,n){const s=n.state.status;return"connected"===s?{tag:"online",activeConnectionId:e,activeConnection:t,lastOnlineAt:(new Date).toISOString()}:"connecting"===s||"idle"===s?{tag:"connecting",activeConnectionId:e,activeConnection:t}:"disposed"===s?{tag:"offline",activeConnectionId:e,activeConnection:t}:null}function ae(e,t,n){const s=ce(e,t,n);if(s)return s;const o=("disconnected"===n.state.status?n.state.reason??null:null)??n.lastError??null;return o&&"client_closed"!==o?{tag:"error",activeConnectionId:e,activeConnection:t,message:o}:{tag:"offline",activeConnectionId:e,activeConnection:t}}function le(e){const{state:t,event:n}=e;if("select_connection"===n.type)return{tag:"connecting",activeConnectionId:n.connectionId,activeConnection:n.connection};if("connect_failed"===n.type){const e=re(t);return{tag:"error",activeConnectionId:e.id,activeConnection:e.connection,message:n.message}}if("no_connections"===n.type||"stopped"===n.type)return{tag:"offline",activeConnectionId:null,activeConnection:null};const s=re(t);return s.id&&s.connection?ae(s.id,s.connection,n):"booting"===t.tag?t:{tag:"offline",activeConnectionId:null,activeConnection:null}}function he(e,t){return"booting"===e.tag?{activeConnectionId:null,activeConnection:null,connectionStatus:"connecting",lastError:null,lastOnlineAt:null,connectionEpoch:t}:"connecting"===e.tag?{activeConnectionId:e.activeConnectionId,activeConnection:e.activeConnection,connectionStatus:"connecting",lastError:null,lastOnlineAt:null,connectionEpoch:t}:"online"===e.tag?{activeConnectionId:e.activeConnectionId,activeConnection:e.activeConnection,connectionStatus:"online",lastError:null,lastOnlineAt:e.lastOnlineAt,connectionEpoch:t}:"offline"===e.tag?{activeConnectionId:e.activeConnectionId,activeConnection:e.activeConnection,connectionStatus:"offline",lastError:null,lastOnlineAt:null,connectionEpoch:t}:{activeConnectionId:e.activeConnectionId,activeConnection:e.activeConnection,connectionStatus:"error",lastError:e.message,lastOnlineAt:null,connectionEpoch:t}}function de(e){return e.connections.map(e=>({connectionId:e.id,connection:e}))}function ue(e,t){return t?e.connections.find(e=>e.id===t)??null:null}function pe(e,t,n,s){if(t)return 1e4;if(n)return 12e4;const o=s-e;return o<1e4?2e3:o<3e4?5e3:o<6e4?1e4:3e4}function ge(){const e="function"==typeof(0,P.getDesktopHost)()?.browser?.executeAutomationCommand?{[_.CLIENT_CAPS.browserHost]:{supportedCommands:[...M.BROWSER_AUTOMATION_COMMAND_NAMES],hostKind:"desktop app"}}:void 0,t=Object.assign({},e);return{createClient:({host:e,connection:n,clientId:s,runtimeGeneration:l})=>{const h=(0,L.createDesktopDaemonTransportFactory)(),u={webSocketFactory:(0,Z.createAppWebSocketFactory)()},y=Object.assign({suppressSendErrors:!0,clientId:s,clientType:"mobile",appVersion:(0,C.resolveAppVersion)()??void 0,deviceLabel:o.getAppDeviceLabel,deviceKind:(0,o.getAppDeviceKind)(),connectionTransport:"remoteSsh"===n.type?c.ConnectionTransport.SshTunnel:void 0,runtimeGeneration:l,capabilities:t,trace:X.nativePerformanceTrace,providerSnapshots:"wire"},e.password?{password:e.password}:{},{localCredential:()=>(0,O.readDesktopManagedLocalCredential)(n)});if("directSocket"===n.type||"directPipe"===n.type)return new p.DaemonClient(Object.assign({},y,h?{transportFactory:h}:{},{url:(0,L.buildDesktopDaemonTransportUrl)({transportType:"directSocket"===n.type?"socket":"pipe",transportPath:n.path})}));if("remoteSsh"===n.type){if(!h)throw new Error("Remote SSH is only available in the desktop app.");return new p.DaemonClient(Object.assign({},y,{transportFactory:h,url:(0,L.buildDesktopDaemonTransportUrl)(Object.assign({transportType:"ssh",host:n.host},void 0!==n.sshPort?{sshPort:n.sshPort}:{},void 0!==n.daemonPort?{daemonPort:n.daemonPort}:{}))}))}return"directTcp"===n.type?new p.DaemonClient(Object.assign({},y,u,{url:(0,f.buildDaemonWebSocketUrl)(n.endpoint,{useTls:n.useTls??!1})})):new p.DaemonClient(Object.assign({},y,u,{url:(0,f.buildRelayWebSocketUrl)({endpoint:n.relayEndpoint,useTls:n.useTls??(0,f.shouldUseTlsForDefaultHostedRelay)(n.relayEndpoint),serverId:e.serverId}),e2ee:{enabled:!0,daemonPublicKeyB64:n.daemonPublicKeyB64}}))},connectToDaemon:({host:e,connection:n,timeoutMs:s})=>(0,A.connectToDaemon)(n,Object.assign({},e.serverId?{serverId:e.serverId}:{},e.password?{password:e.password}:{},{localCredential:()=>(0,O.readDesktopManagedLocalCredential)(n)},void 0!==s?{timeoutMs:s}:{},{capabilities:t,trace:X.nativePerformanceTrace})),getClientId:()=>(0,H.getOrCreateClientId)(),mountClientHandlers:({client:t,host:n})=>{const s=(0,j.mountServerDataPushRouter)({client:t,queryClient:F.queryClient,serverId:n.serverId});if(!e)return s;const o=(0,q.mountBrowserAutomationDaemonClientHandler)(t,{serverId:n.serverId});return()=>{o(),s()}}}}class ye{connectionEpoch=0;listeners=new Set;activeClient=null;unsubscribeClientStatus=null;unsubscribeClientHandlers=null;probeIntervalHandle=null;started=!1;connectionFirstSeenAt=new Map;connectionLastProbedAt=new Map;switchCandidateConnectionId=null;switchCandidateHitCount=0;clientIdPromise=null;clientIdHash=null;switchRequestVersion=0;probeRequestVersion=0;probeCycleInFlight=null;authRejectedConnectionIds=new Set;constructor(e){this.host=e.host,this.deps=e.deps??ge(),this.onReconcileServerId=e.onReconcileServerId??null,this.connectionMachineState={tag:"booting"},this.snapshot=Object.assign({serverId:this.host.serverId},he(this.connectionMachineState,this.connectionEpoch),{client:null,agentDirectoryStatus:"idle",agentDirectoryError:null,hasEverLoadedAgentDirectory:!1,probeByConnectionId:new Map,clientGeneration:0})}getSnapshot(){return this.snapshot}getClient(){return this.snapshot.client}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}async start(e){this.started||(this.started=!0,this.trackConnectionFirstSeen(),e?.initialConnection&&(await this.switchToConnection({connectionId:e.initialConnection.connectionId,existingClient:e.initialConnection.existingClient}),!this.started)||(await this.runProbeCycleNow(),this.started&&!1!==e?.autoProbe&&(this.probeIntervalHandle=setInterval(()=>{this.runProbeCycleNow()},2e3))))}async stop(){if(this.switchRequestVersion+=1,this.probeRequestVersion+=1,this.started=!1,this.probeIntervalHandle&&(clearInterval(this.probeIntervalHandle),this.probeIntervalHandle=null),this.unsubscribeClientStatus&&(this.unsubscribeClientStatus(),this.unsubscribeClientStatus=null),this.unsubscribeClientHandlers&&(this.unsubscribeClientHandlers(),this.unsubscribeClientHandlers=null),this.activeClient){const e=this.activeClient;this.activeClient=null,await e.close().catch(()=>{})}this.applyConnectionEvent({type:"stopped"}),this.updateSnapshot(Object.assign({},he(this.connectionMachineState,this.connectionEpoch),{client:null}))}async updateHost(e){const t=this.host.password!==e.password;t&&(this.probeRequestVersion+=1,this.authRejectedConnectionIds.clear(),this.updateSnapshot({authFailureReason:null}));const n=this.snapshot.activeConnectionId,s=ue(this.host,n);this.host=e,this.trackConnectionFirstSeen();const o=ue(this.host,n);n&&s&&o&&(!(0,u.default)(s,o)||t)&&(this.connectionLastProbedAt.delete(n),await this.switchToConnection({connectionId:n})),t&&this.connectionLastProbedAt.clear(),t&&await this.probeCycleInFlight,await this.runProbeCycleNow()}ensureConnected(e){this.activeClient?.ensureConnected(e)}markAgentDirectorySyncLoading(){const e=this.snapshot.hasEverLoadedAgentDirectory?"revalidating":"initial_loading";this.updateSnapshot({agentDirectoryStatus:e,agentDirectoryError:null})}markAgentDirectorySyncReady(){this.updateSnapshot({agentDirectoryStatus:"ready",agentDirectoryError:null,hasEverLoadedAgentDirectory:!0})}markAgentDirectorySyncError(e){const t=this.snapshot.hasEverLoadedAgentDirectory;this.updateSnapshot({agentDirectoryStatus:t?"error_after_ready":"error_before_first_success",agentDirectoryError:e,hasEverLoadedAgentDirectory:t})}markAgentDirectorySyncIdle(){this.updateSnapshot({agentDirectoryStatus:this.snapshot.hasEverLoadedAgentDirectory?"ready":"idle",agentDirectoryError:null})}markStartupError(e){this.applyConnectionEvent({type:"connect_failed",message:e}),this.updateSnapshot(Object.assign({},he(this.connectionMachineState,this.connectionEpoch)))}async activateConnection(e){await this.switchToConnection(e)}async runProbeCycleNow(){if(this.probeCycleInFlight)return this.probeCycleInFlight;const e=this.runProbeCycle().finally(()=>{this.probeCycleInFlight===e&&(this.probeCycleInFlight=null)});return this.probeCycleInFlight=e,e}async runProbeCycle(){const e=++this.probeRequestVersion;if(0===this.host.connections.length){if(!this.isCurrentProbeRequest(e))return;return this.applyConnectionEvent({type:"no_connections"}),void this.updateSnapshot(Object.assign({},he(this.connectionMachineState,this.connectionEpoch),{probeByConnectionId:new Map}))}const t=performance.now(),n="online"===this.snapshot.connectionStatus,s=this.snapshot.activeConnectionId,o=n&&null!==s,c=this.host.connections.filter(e=>{if(this.authRejectedConnectionIds.has(e.id))return!1;const c=this.connectionLastProbedAt.get(e.id);if(null==c)return!0;const l=pe(this.connectionFirstSeenAt.get(e.id)??t,n&&e.id===s,o,t);return t-c>=l});if(0===c.length)return;const l=new Map(this.snapshot.probeByConnectionId);for(const e of c){this.connectionLastProbedAt.set(e.id,performance.now());const t=l.get(e.id);n&&e.id===s&&"available"===t?.status||l.set(e.id,{status:"pending",latencyMs:null})}this.updateSnapshot({probeByConnectionId:new Map(l)});let h=c.length,u=null,y=null;const S=()=>{this.isCurrentProbeRequest(e)&&this.updateSnapshot({probeByConnectionId:new Map(l)})},f=async(t,n)=>{for(;!this.snapshot.activeConnectionId;){if(!y)return y=this.switchToConnection({connectionId:t,expectedProbeVersion:e,existingClient:n}).finally(()=>{y=null}),await y,this.snapshot.activeConnectionId===t;await y}return!1},C=async()=>{if(h>0||!this.isCurrentProbeRequest(e))return;const t=this.snapshot.activeConnectionId,n=t?l.get(t):null;if(!t||!ue(this.host,t)){const t=(0,E.selectBestConnection)({candidates:de(this.host),probeByConnectionId:l});if(t)await this.switchToConnection({connectionId:t,expectedProbeVersion:e});else if(u){const e=new p.DaemonAuthenticationError(u).message;this.applyConnectionEvent({type:"connect_failed",message:e}),this.updateSnapshot(Object.assign({},he(this.connectionMachineState,this.connectionEpoch),{authFailureReason:u}))}return}if(this.isConnectionUnavailable(t,n)){const n=(0,E.selectBestConnection)({candidates:de(this.host),probeByConnectionId:l});return n&&n!==t&&await this.switchToConnection({connectionId:n,expectedProbeVersion:e}),this.switchCandidateConnectionId=null,void(this.switchCandidateHitCount=0)}if(!n||"available"!==n.status)return;const s=Array.from(l.entries()).filter(e=>"available"===e[1].status).map(([e,t])=>({connectionId:e,latencyMs:t.latencyMs})).sort((e,t)=>e.latencyMs-t.latencyMs)[0]??null;if(!s||s.connectionId===t)return this.switchCandidateConnectionId=null,void(this.switchCandidateHitCount=0);if(n.latencyMs-s.latencyMs<40)return this.switchCandidateConnectionId=null,void(this.switchCandidateHitCount=0);this.switchCandidateConnectionId===s.connectionId?this.switchCandidateHitCount+=1:(this.switchCandidateConnectionId=s.connectionId,this.switchCandidateHitCount=1),this.switchCandidateHitCount>=3&&(this.switchCandidateConnectionId=null,this.switchCandidateHitCount=0,await this.switchToConnection({connectionId:s.connectionId,expectedProbeVersion:e}))};await new Promise(t=>{for(const n of c)(async()=>{let s=null,o=!1;try{const t=this.snapshot.activeConnectionId===n.id?this.snapshot.client:null;if(t)s=t;else{const{client:e,serverId:t}=await this.deps.connectToDaemon({host:this.host,connection:n});if(t!==this.host.serverId){if(!Ae(this.host.serverId)||!this.onReconcileServerId)throw await e.close().catch(()=>{}),new Error(`Connection resolved to ${t}, expected ${this.host.serverId}.`);this.onReconcileServerId(this.host.serverId,t)}s=e,o=!0}if(!this.isCurrentProbeRequest(e))return;const c=await f(n.id,s);if(o=o&&!c,t){const s=t.getLastLivenessRttMs();if(!this.isCurrentProbeRequest(e))return;return void(null!==s&&(l.set(n.id,{status:"available",latencyMs:s}),S()))}const h=await s.measureLatency({timeoutMs:5e3});if(!this.isCurrentProbeRequest(e))return;l.set(n.id,{status:"available",latencyMs:h}),S()}catch(t){if(this.isCurrentProbeRequest(e)){const e=(0,A.getConnectionAuthFailureReason)(t);e&&(this.authRejectedConnectionIds.add(n.id),u=e),l.set(n.id,{status:"unavailable",latencyMs:null}),S()}}finally{s&&o&&await s.close().catch(()=>{}),h-=1,C().finally(()=>{0===h&&t()})}})()})}isConnectionUnavailable(e,t){return"unavailable"===t?.status||this.authRejectedConnectionIds.has(e)}updateSnapshot(e){const t=Object.assign({},e);let n=this.host.serverId!==this.snapshot.serverId;for(const s of Object.keys(e)){const o=e[s];(0,u.default)(this.snapshot[s],o)?ee(t,s,this.snapshot[s]):n=!0}if(n){this.snapshot=Object.assign({},this.snapshot,t,{serverId:this.host.serverId});for(const e of this.listeners)e()}}applyConnectionEvent(e){const t=this.connectionMachineState,n=le({state:t,event:e});"online"!==t.tag&&"online"===n.tag&&(this.connectionEpoch+=1),this.connectionMachineState=n,this.logConnectionTransition({from:t.tag,to:n.tag,event:e})}logConnectionTransition(e){}trackConnectionFirstSeen(){const e=performance.now(),t=new Set(this.host.connections.map(e=>e.id));for(const e of this.connectionFirstSeenAt.keys())t.has(e)||(this.connectionFirstSeenAt.delete(e),this.connectionLastProbedAt.delete(e));for(const t of this.host.connections)this.connectionFirstSeenAt.has(t.id)||this.connectionFirstSeenAt.set(t.id,e)}isCurrentSwitchRequest(e){return e===this.switchRequestVersion}isCurrentProbeRequest(e){return e===this.probeRequestVersion}canProceedForProbe(e){return void 0===e||this.isCurrentProbeRequest(e)}async abortSwitchWithClient(e){e&&await e.close().catch(()=>{})}isSwitchStillValid(e,t){return this.isCurrentSwitchRequest(e)&&this.canProceedForProbe(t)}async resolveClientIdForSwitch(e){try{return await this.resolveClientId()}catch(t){if(await this.abortSwitchWithClient(e.existingClient),!this.isCurrentSwitchRequest(e.requestVersion))return null;const n=se(t);return this.applyConnectionEvent({type:"connect_failed",message:`Failed to resolve client id: ${n}`}),this.updateSnapshot(Object.assign({},he(this.connectionMachineState,this.connectionEpoch))),null}}async disposePreviousActiveClient(){if(this.unsubscribeClientStatus&&(this.unsubscribeClientStatus(),this.unsubscribeClientStatus=null),this.unsubscribeClientHandlers&&(this.unsubscribeClientHandlers(),this.unsubscribeClientHandlers=null),this.activeClient){const e=this.activeClient;this.activeClient=null,await e.close().catch(()=>{})}}buildAgentDirectoryStatusPatch(){if(this.snapshot.hasEverLoadedAgentDirectory)return{};const e=this.connectionMachineState.tag;return"connecting"===e||"online"===e?{agentDirectoryStatus:"initial_loading",agentDirectoryError:null}:"error"===e?{agentDirectoryStatus:"error_before_first_success",agentDirectoryError:this.connectionMachineState.message}:{agentDirectoryStatus:"idle",agentDirectoryError:null}}async switchToConnection(e){const{connectionId:t,expectedProbeVersion:n,existingClient:s}=e;if(!this.canProceedForProbe(n))return void await this.abortSwitchWithClient(s);const o=ue(this.host,t);if(!o)return void await this.abortSwitchWithClient(s);const c=++this.switchRequestVersion,l=await this.resolveClientIdForSwitch({existingClient:s,requestVersion:c});if(null===l)return;if(!this.isSwitchStillValid(c,n))return void await this.abortSwitchWithClient(s);if(await this.disposePreviousActiveClient(),!this.isSwitchStillValid(c,n))return void await this.abortSwitchWithClient(s);const h=this.snapshot.clientGeneration+1,u=s??this.deps.createClient({host:this.host,connection:o,clientId:l,runtimeGeneration:h});if(u.setReconnectEnabled(!0),!this.isSwitchStillValid(c,n))return void await u.close().catch(()=>{});this.activeClient=u,this.applyConnectionEvent({type:"select_connection",connectionId:o.id,connection:oe(o)}),this.snapshot=Object.assign({},this.snapshot,{clientGeneration:h}),this.updateSnapshot(Object.assign({},he(this.connectionMachineState,this.connectionEpoch),{client:null}));const y=async e=>{if(!this.isCurrentSwitchRequest(c)||this.activeClient!==u)return;const t=(0,A.getConnectionAuthFailureReason)(e);if(t&&this.authRejectedConnectionIds.add(o.id),this.unsubscribeClientStatus?.(),this.unsubscribeClientStatus=null,this.unsubscribeClientHandlers?.(),this.unsubscribeClientHandlers=null,u.setReconnectEnabled(!1),this.applyConnectionEvent({type:"connect_failed",message:se(e)}),this.updateSnapshot(Object.assign({},he(this.connectionMachineState,this.connectionEpoch),{client:null,authFailureReason:t})),t){const e=new Map(this.snapshot.probeByConnectionId);e.set(o.id,{status:"unavailable",latencyMs:null}),this.updateSnapshot({probeByConnectionId:e});for(const e of this.host.connections)this.authRejectedConnectionIds.has(e.id)||this.connectionLastProbedAt.delete(e.id)}try{await u.close()}catch{}t&&this.host.connections.some(e=>!this.authRejectedConnectionIds.has(e.id))&&this.runProbeCycleNow()};try{if(s||await u.connect(),!this.isCurrentSwitchRequest(c)||this.activeClient!==u)return;this.unsubscribeClientHandlers=this.deps.mountClientHandlers?.({client:u,host:this.host,connection:o})??null,this.unsubscribeClientStatus=u.subscribeConnectionStatus(e=>{this.isCurrentSwitchRequest(c)&&this.activeClient===u&&(u.authFailureReason?y(new p.DaemonAuthenticationError(u.authFailureReason)):(this.applyConnectionEvent({type:"client_state",state:e,lastError:u.lastError}),this.updateSnapshot(Object.assign({},he(this.connectionMachineState,this.connectionEpoch),this.buildAgentDirectoryStatusPatch(),{client:u,authFailureReason:null}))))})}catch(e){await y(e)}}adoptReconciledServerId(e){this.host=Object.assign({},this.host,{serverId:e}),this.snapshot=Object.assign({},this.snapshot,{serverId:e});for(const e of this.listeners)e()}resolveClientId(){return this.clientIdPromise||(this.clientIdPromise=this.deps.getClientId().then(e=>(this.clientIdHash=ie(e),e))),this.clientIdPromise}}const Se="@paseo:daemon-registry",fe="localhost:6767",Ce=2500,ve="__PASEO_INITIAL_DAEMON_CONNECTION__",me=R.z.object({listen:R.z.string().trim().min(1),useTls:R.z.boolean().optional().default(!1)});function be(e){if(!(e?.isWebRuntime??I.isWeb)||"undefined"==typeof globalThis)return null;const t=me.safeParse(Reflect.get(globalThis,ve));return t.success?t.data:null}function we(){return null}function Ie(e){if(e.trim().startsWith("relay://")||e.includes("#connect="))return(0,f.parseRelayConnectionUri)(e);const t="#offer=",n=e.indexOf(t);if(-1===n)throw new Error("Missing #offer= fragment");const s=e.slice(n+7).trim();if(!s)throw new Error("Offer payload is empty");const o=(0,f.decodeOfferFragmentPayload)(s);return{offer:v.ConnectionOfferSchema.parse(o)}}function Ae(e){return e.startsWith("local:")}function He(e){return new Promise(t=>setTimeout(t,e))}function Re(e,t,n){const s=e.get(t);void 0!==s&&(e.delete(t),e.set(n,s))}class De{controllers=new Map;serverListeners=new Map;globalListeners=new Set;hostListListeners=new Set;version=0;hostListVersion=0;hostRegistryLoaded=!1;hosts=[];hostAppearanceMutationTail=Promise.resolve();hostRegistryStatus="loading";lastConnectionStatusByServer=new Map;connectionStatusStartedAtByServer=new Map;queuedAgentDrainInFlight=new Set;directorySyncByServer=new Map;nextCancellationRequestId=0;timelineReplicaByServer=new Map;configuredOverrideBootstrapInFlight=null;bootPromise=null;registryLoad=null;hostConfirmations=new b.HostConfirmations;constructor(e){this.deps=e?.deps??ge(),this.storage=e?.storage??h.default,this.replicaCache=new z.ReplicaCache(e?.replicaRowStore??(0,K.createReplicaRowStore)()),this.revokePushNotifications=e?.revokePushNotifications??Y.revokePushNotifications}getHosts(){return this.hosts}getHostRegistryStatus(){return this.hostRegistryStatus}subscribeHostList(e){return this.hostListListeners.add(e),()=>{this.hostListListeners.delete(e)}}getHostListVersion(){return this.hostListVersion}isHostRegistryLoaded(){return this.hostRegistryLoaded}boot(){return this.bootPromise||(this.bootPromise=this.runBoot()),this.bootPromise}async runBoot(){await this.loadRegistry();let e=null;try{e=await(0,D.readValidatedString)(this.storage,"@paseo:e2e",R.z.string().min(1))}catch{return}if(e)return;if((0,w.shouldUseDesktopDaemon)())return;const t=this.deps.readInitialConnectionHint?this.deps.readInitialConnectionHint():be();if(t){if(await this.bootstrapInitialConnectionHint(t))return}await this.bootstrapDefaultLocalhost()}loadRegistry(){return this.registryLoad||(this.registryLoad=this.loadFromStorage().then(()=>this.markHostRegistryLoaded())),this.registryLoad}async loadFromStorage(){let e=!1,t=[];try{const n=await(0,D.readValidatedJson)(this.storage,Se,y.StoredHostRegistrySchema);if(n){const s=[];for(const t of n){const n=(0,y.normalizeStoredHostProfile)(t);if(!n){await this.storage.removeItem(Se),s.length=0;break}t.connections.some(e=>"directTcp"===e.type&&e.password)&&(e=!0),s.push(n)}t=s.filter(e=>!Ae(e.serverId)),t.length!==s.length&&(e=!0)}this.hosts=t,this.replicaCache.setHosts(t.map(e=>e.serverId)),J.projectIconCache.setHosts(t.map(e=>e.serverId)),await J.projectIconCache.restore(),this.syncHosts(t);for(const e of t)this.directorySyncByServer.get(e.serverId)?.restoreCachedDirectory().catch(()=>{})}catch(e){console.error("[HostRuntime] Failed to load host registry from storage",e)}finally{this.hostRegistryStatus="ready",this.emitHostList(),e&&this.persistHosts().catch(e=>console.error("[HostRuntime] Failed to persist host registry",e))}}markHostRegistryLoaded(){this.hostRegistryLoaded||(this.hostRegistryLoaded=!0,this.emitHostList())}async bootstrapDefaultLocalhost(){const e=(0,y.connectionFromListen)(fe);if(e&&!(0,y.registryHasConnection)(this.hosts,e))try{await this.probeAndUpsertConnection({connection:e,timeoutMs:Ce})}catch(e){console.warn("[HostRuntime] bootstrap probe failed",{endpoint:fe,error:e})}}bootstrapConfiguredOverride(e){const t=(0,y.connectionFromListen)(e);if(!t)return;if((0,y.registryHasConnection)(this.hosts,t))return;if(this.configuredOverrideBootstrapInFlight)return;const n=this.runConfiguredOverrideBootstrap(e,t).finally(()=>{this.configuredOverrideBootstrapInFlight===n&&(this.configuredOverrideBootstrapInFlight=null)});this.configuredOverrideBootstrapInFlight=n}async runConfiguredOverrideBootstrap(e,t){let n=0;for(;!(0,y.registryHasConnection)(this.hosts,t);){n+=1;try{return void await this.probeAndUpsertConnection({connection:t,timeoutMs:Ce})}catch(t){1!==n&&n%10!=0||console.warn("[HostRuntime] configured bootstrap probe failed",{endpoint:e,attempt:n,error:t}),await He(1e3)}}}async bootstrapInitialConnectionHint(e){const t=(0,y.connectionFromListen)(e.listen);if(!t)return!1;const n="directTcp"===t.type?Object.assign({},t,{useTls:e.useTls??t.useTls??!1}):t;if((0,y.registryHasConnection)(this.hosts,n))return!0;try{return await this.probeAndUpsertConnection({connection:n,timeoutMs:Ce}),!0}catch(t){return console.warn("[HostRuntime] initial connection hint probe failed",{listen:e.listen,useTls:e.useTls,error:t}),!1}}reconcileServerId(e,t){if(e===t)return;const n=this.controllers.get(e);if(!n)return;if(this.controllers.has(t))return;Re(this.controllers,e,t),Re(this.lastConnectionStatusByServer,e,t),Re(this.connectionStatusStartedAtByServer,e,t),this.replicaCache.reconcileServerId(e,t),J.projectIconCache.reconcileServerId(e,t),this.directorySyncByServer.get(e)?.dispose(),this.directorySyncByServer.delete(e),this.timelineReplicaByServer.delete(e);const s=new G.DirectorySync(t,{onAgentStoppedRunning:e=>this.drainQueuedAgentMessage(t,e),markAgentLoading:()=>n.markAgentDirectorySyncLoading(),markAgentReady:()=>n.markAgentDirectorySyncReady(),markAgentError:e=>n.markAgentDirectorySyncError(e)},this.replicaCache);this.directorySyncByServer.set(t,s),this.timelineReplicaByServer.set(t,(0,Q.createTimelineReplica)({serverId:t,storage:this.replicaCache,prepareAgent:e=>s.prepareAgentRoute(e)})),n.adoptReconciledServerId(t);const o=n.getSnapshot();this.clearHostReplica(e),this.syncSessionReplica(t,o),s.connectionChanged({client:o.client,status:"online"===o.connectionStatus?"online":"offline",source:{clientGeneration:o.clientGeneration,connectionEpoch:o.connectionEpoch}});const c=this.serverListeners.get(e);if(c){this.serverListeners.delete(e);const n=this.serverListeners.get(t)??new Set;for(const e of c)n.add(e);this.serverListeners.set(t,n)}this.hosts=this.hosts.map(n=>n.serverId===e?Object.assign({},n,{serverId:t,updatedAt:(new Date).toISOString()}):n),this.emitHostList(),this.emit(t),this.persistHosts().catch(e=>console.error("[HostRuntime] Failed to persist host registry",e))}async upsertDirectConnection(e){const t=(0,f.normalizeHostPort)(e.endpoint),n=e.password?.trim();return this.upsertHostConnection({serverId:e.serverId,label:e.label,password:n,connection:{id:`direct:${t}`,type:"directTcp",endpoint:t,useTls:e.useTls??!1},existingClient:e.existingClient})}async probeAndUpsertConnection(e){if("relay"===e.connection.type)throw new Error("Cannot probe a relay connection without a server id.");const t=Object.assign({serverId:""},e.password?{password:e.password}:{},{label:e.label??e.connection.id,appearance:(0,S.defaultHostAppearance)(),lifecycle:{},connections:[e.connection],preferredConnectionId:e.connection.id,createdAt:new Date(0).toISOString(),updatedAt:new Date(0).toISOString()}),{client:n,serverId:s,hostname:o}=await this.deps.connectToDaemon(Object.assign({host:t,connection:e.connection},void 0!==e.timeoutMs?{timeoutMs:e.timeoutMs}:{}));return{profile:await this.upsertHostConnection({serverId:s,label:e.label??o??void 0,password:e.password,connection:e.connection,existingClient:n}),serverId:s,hostname:o}}async probeAndUpsertDirectConnection(e){const t=(0,f.normalizeHostPort)(e.endpoint),n=e.password?.trim();return this.probeAndUpsertConnection({label:e.label,password:n,connection:{id:`direct:${t}`,type:"directTcp",endpoint:t,useTls:e.useTls??!1}})}async probeAndUpsertRemoteSshConnection(e){return this.probeAndUpsertConnection({label:e.label,connection:(0,y.createRemoteSshHostConnection)(e)})}async upsertRelayConnection(e){const t=(0,f.normalizeHostPort)(e.relayEndpoint),n=e.useTls??!1,s=e.daemonPublicKeyB64.trim();if(!s)throw new Error("daemonPublicKeyB64 is required");const o=void 0!==e.useTls,c=await this.upsertHostConnection({serverId:e.serverId,label:e.label,connection:Object.assign({id:n?`relay:wss:${t}`:`relay:${t}`,type:"relay",relayEndpoint:t},o?{useTls:n}:{},{daemonPublicKeyB64:s})});return e.password?(await this.setHostPassword(c.serverId,e.password),this.hosts.find(e=>e.serverId===c.serverId)??c):c}async confirmLink(e){return await this.loadRegistry(),this.hostConfirmations.confirmLink(e,this.hosts)}getPendingHostConfirmation(){return this.hostConfirmations.getPending()}subscribeHostConfirmation(e){return this.hostConfirmations.subscribe(e)}answerHostConfirmation(e,t){this.hostConfirmations.answer(e,t)}beginLinkPairing(){let e=null;return{submit:async(t,n)=>{const{offer:s,password:o}=Ie(t);if(!e||(l=s,(c=e).serverId!==l.serverId||!(0,u.default)((0,y.relayConnectionFromOffer)(c),(0,y.relayConnectionFromOffer)(l)))){if(!await this.confirmLink(s))return{status:"cancelled"};e=s}var c,l;const h=await this.probeAndUpsertOffer(s,n??o);return Object.assign({status:"connected"},h)}}}async importConnectionLink(e,t){if("openProject"===t){const{offer:t,password:n}=Ie(e);if(!await this.confirmLink(t))return{status:"cancelled"};return{status:"connected",serverId:(await this.upsertConnectionFromOffer(t,void 0,n)).serverId}}const n=this.beginLinkPairing();try{const t=await n.submit(e);return"cancelled"===t.status?t:{status:"connected",serverId:t.serverId}}catch(t){if(!(0,A.getConnectionAuthFailureReason)(t))throw t;return{status:"password_required",link:e,pairing:n}}}async upsertConnectionFromOffer(e,t,n){const s=(0,y.relayConnectionFromOffer)(e);return this.upsertRelayConnection({serverId:e.serverId,relayEndpoint:s.relayEndpoint,useTls:s.useTls,daemonPublicKeyB64:s.daemonPublicKeyB64,label:t,password:n})}async probeAndUpsertOffer(e,t){const n=(0,y.relayConnectionFromOffer)(e),s=Object.assign({serverId:e.serverId},t?{password:t}:{},{label:e.serverId,appearance:(0,S.defaultHostAppearance)(),lifecycle:{},connections:[n],preferredConnectionId:n.id,createdAt:new Date(0).toISOString(),updatedAt:new Date(0).toISOString()}),{client:o,hostname:c}=await this.deps.connectToDaemon({host:s,connection:n});await o.close().catch(()=>{});return{profile:await this.upsertConnectionFromOffer(e,c??void 0,t),serverId:e.serverId,hostname:c}}async upsertConnectionFromListen(e){const t=e.listenAddress.trim(),n=e.serverId.trim(),s=(0,y.connectionFromListen)(t);if(!s)throw new Error(`Unsupported listen address: ${e.listenAddress}`);if(!n)throw new Error("Desktop daemon did not return a server id.");return this.upsertHostConnection({serverId:n,label:e.hostname??void 0,connection:s})}async updateHost(e,t){const n=(new Date).toISOString(),s=this.hosts.map(s=>s.serverId===e?Object.assign({},t(s),{updatedAt:n}):s);this.setHostsAndSync(s),await this.persistHosts()}async renameHost(e,t){await this.updateHost(e,e=>Object.assign({},e,{label:t}))}async setHostPassword(t,s){await this.updateHost(t,t=>{const o=(0,n.default)(t,e);return s?Object.assign({},o,{password:s}):o})}async setHostColor(e,t){await this.updateHostAppearance(e,e=>Object.assign({},e,{appearance:Object.assign({},e.appearance,{color:t})}))}async setHostBadgeDisplay(e,t){await this.updateHostAppearance(e,e=>Object.assign({},e,{appearance:Object.assign({},e.appearance,{badgeDisplay:t})}))}updateHostAppearance(e,t){const n=this.hostAppearanceMutationTail.then(()=>this.applyHostAppearance(e,t));return this.hostAppearanceMutationTail=n.catch(()=>{}),n}async applyHostAppearance(e,t){const n=(new Date).toISOString(),s=this.hosts.map(s=>s.serverId===e?Object.assign({},t(s),{updatedAt:n}):s);await this.persistHosts(s),this.setHostsAndSync(s)}async removeHost(e){await this.revokePushNotifications({client:this.getClient(e),serverId:e});const t=this.hosts.filter(t=>t.serverId!==e);this.setHostsAndSync(t),await this.persistHosts()}async removeConnection(e,t){const n=this.hosts.find(t=>t.serverId===e);if(1===n?.connections.length&&n.connections[0]?.id===t)return void await this.removeHost(e);const s=(new Date).toISOString(),o=this.hosts.map(n=>{if(n.serverId!==e)return n;const o=n.connections.filter(e=>e.id!==t);if(0===o.length)return null;const c=n.preferredConnectionId===t?o[0]?.id??null:n.preferredConnectionId;return Object.assign({},n,{connections:o,preferredConnectionId:c,updatedAt:s})}).filter(e=>null!==e);this.setHostsAndSync(o),await this.persistHosts()}async upsertHostConnection(e){const t=(new Date).toISOString(),n=(0,y.upsertHostConnectionInProfiles)({profiles:this.hosts,serverId:e.serverId,label:e.label,connection:e.connection,password:e.password,now:t});this.setHostsAndSync(n,{initialConnectionByServerId:e.existingClient?new Map([[e.serverId,{connectionId:e.connection.id,existingClient:e.existingClient}]]):void 0}),this.persistHosts().catch(e=>console.error("[HostRuntime] Failed to persist host registry",e));const s=n.find(t=>t.serverId===e.serverId);if(!s)throw new Error(`Host ${e.serverId} was not inserted`);return s}setHostsAndSync(e,t){this.hosts=e,this.syncHosts(e,t),this.emitHostList()}async persistHosts(e=this.hosts){await this.storage.setItem(Se,JSON.stringify(e))}emitHostList(){this.hostListVersion+=1;for(const e of this.hostListListeners)e()}syncHosts(e,t){this.replicaCache.setHosts(e.map(e=>e.serverId)),J.projectIconCache.setHosts(e.map(e=>e.serverId));const n=new Set(e.map(e=>e.serverId));for(const[e,t]of this.controllers)n.has(e)||(this.controllers.delete(e),this.lastConnectionStatusByServer.delete(e),this.connectionStatusStartedAtByServer.delete(e),this.directorySyncByServer.get(e)?.dispose(),this.directorySyncByServer.delete(e),this.timelineReplicaByServer.delete(e),this.clearHostReplica(e),t.stop(),this.emit(e));for(const n of e){const e=t?.initialConnectionByServerId?.get(n.serverId),s=this.controllers.get(n.serverId);if(s){s.updateHost(n),e&&s.activateConnection(e).catch(()=>{e.existingClient.close().catch(()=>{})});continue}const o=new ye({host:n,deps:this.deps,onReconcileServerId:(e,t)=>this.reconcileServerId(e,t)});this.controllers.set(n.serverId,o),k.useSessionStore.getState().initializeSession(n.serverId,null);const c=new G.DirectorySync(n.serverId,{onAgentStoppedRunning:e=>this.drainQueuedAgentMessage(n.serverId,e),markAgentLoading:()=>o.markAgentDirectorySyncLoading(),markAgentReady:()=>o.markAgentDirectorySyncReady(),markAgentError:e=>o.markAgentDirectorySyncError(e)},this.replicaCache);this.directorySyncByServer.set(n.serverId,c),this.timelineReplicaByServer.set(n.serverId,(0,Q.createTimelineReplica)({serverId:n.serverId,storage:this.replicaCache,prepareAgent:e=>c.prepareAgentRoute(e)}));const l=o.getSnapshot();this.lastConnectionStatusByServer.set(n.serverId,l.connectionStatus),this.connectionStatusStartedAtByServer.set(n.serverId,Date.now()),o.subscribe(()=>{const e=o.getSnapshot();this.syncSessionReplica(e.serverId,e),this.syncDirectoryConnection(e.serverId),this.emit(e.serverId)}),o.start(e?{initialConnection:e}:{}).catch(e=>{const t=e instanceof Error?e.message:String(e);o.markStartupError(t)}),this.emit(n.serverId)}}syncSessionReplica(e,t){if(!t.client)return;const n=k.useSessionStore.getState();n.initializeSession(e,t.client,t.clientGeneration),n.updateSessionClient(e,t.client,t.clientGeneration);const s=t.client.getLastServerInfoMessage();s&&n.updateSessionServerInfo(e,(0,k.toDaemonServerInfo)(s))}clearHostReplica(e){k.useSessionStore.getState().clearSession(e),T.useWorkspaceSetupStore.getState().clearServer(e)}syncDirectoryConnection(e){const t=this.controllers.get(e);if(!t)return this.lastConnectionStatusByServer.delete(e),void this.connectionStatusStartedAtByServer.delete(e);const n=t.getSnapshot(),s=this.directorySyncByServer.get(e);s?.connectionChanged({client:n.client,status:"online"===n.connectionStatus?"online":"offline",source:{clientGeneration:n.clientGeneration,connectionEpoch:n.connectionEpoch}});const o=this.lastConnectionStatusByServer.get(e),c=o!==n.connectionStatus,l="online"!==n.connectionStatus&&"idle"!==n.connectionStatus;!c||void 0!==o&&"online"!==o&&"idle"!==o&&l||this.connectionStatusStartedAtByServer.set(e,Date.now()),this.lastConnectionStatusByServer.set(e,n.connectionStatus);"online"===n.connectionStatus&&"online"!==o&&(k.useSessionStore.getState().bumpHistorySyncGeneration(e),(0,B.invalidateCheckoutGitQueriesForServer)(F.queryClient,e),(0,j.invalidateServerDataQueriesAfterReconnect)({queryClient:F.queryClient,serverId:e}),F.queryClient.invalidateQueries({queryKey:x.schedulesQueryBaseKey}))}drainQueuedAgentMessage(e,t){const n=`${e}:${t}`;if(this.queuedAgentDrainInFlight.has(n))return;const s=k.useSessionStore.getState().sessions[e],o=s?.queuedMessages.get(t),c=s?.client;if(!c||!o?.length||!0===s.initializingAgents.get(t))return;if((0,W.getActiveMessageSubmissions)(s.messageSubmissions.get(t)).length>0)return;this.queuedAgentDrainInFlight.add(n);const l=o[0];(0,U.sendQueuedComposerMessageNow)({agentId:t,messageId:l.id,queue:{read:t=>k.useSessionStore.getState().sessions[e]?.queuedMessages.get(t)??[],write:t=>k.useSessionStore.getState().setQueuedMessages(e,t)},submitMessage:async({text:n,attachments:s})=>{const o=!0===k.useSessionStore.getState().sessions[e]?.serverInfo?.features?.forgeSearch;await(0,U.dispatchComposerAgentMessage)({client:c,agentId:t,text:n,attachments:s,attachmentSubmitFormat:(0,N.resolveComposerAttachmentSubmitFormat)({supportsForgeAttachments:o}),encodeImages:$.encodeImages,submission:(0,V.createMessageSubmissionWriter)(e)})}}).then(n=>("failed"===n.status&&console.error("[HostRuntime] failed to drain queued agent message",{serverId:e,agentId:t,error:n.errorMessage}),n)).finally(()=>{this.queuedAgentDrainInFlight.delete(n)})}applyAgentTurnLiveness(e,t,n){this.directorySyncByServer.get(e)?.applyAgentTurnLiveness(t,n)}beginAgentCancellation(e,t){const n=++this.nextCancellationRequestId;return this.applyAgentTurnLiveness(e,t,{type:"cancellation_started",requestId:n}),n}settleAgentCancellation(e,t,n){this.applyAgentTurnLiveness(e,t,{type:"cancellation_settled",requestId:n})}acceptAgentSnapshot(e,t){return this.requireDirectory(e).acceptAgent(t)}archiveAgentSnapshot(e,t,n){this.requireDirectory(e).archiveAgent(t,n)}restoreAgentSnapshot(e,t,n){const s=this.requireDirectory(e);n?s.acceptAgent(n):s.removeAgent(t)}acceptWorkspaceSnapshots(e,t){this.requireDirectory(e).acceptWorkspaces(t)}acceptProjectSnapshot(e,t){this.requireDirectory(e).acceptProject(t)}removeWorkspaceSnapshot(e,t){this.requireDirectory(e).removeWorkspace(t)}requireDirectory(e){const t=this.directorySyncByServer.get(e);if(!t)throw new Error(`Unknown host runtime for serverId ${e}`);return t}getSnapshot(e){return this.controllers.get(e)?.getSnapshot()??null}getConnectionStatusSince(e){return this.connectionStatusStartedAtByServer.get(e)??null}getVersion(){return this.version}getClient(e){return this.controllers.get(e)?.getClient()??null}subscribe(e,t){const n=this.serverListeners.get(e)??new Set;return n.add(t),this.serverListeners.set(e,n),()=>{const n=this.serverListeners.get(e);n&&(n.delete(t),0===n.size&&this.serverListeners.delete(e))}}subscribeAll(e){return this.globalListeners.add(e),()=>{this.globalListeners.delete(e)}}getEarliestOnlineHostServerId(){let e=null,t=null;for(const n of this.hosts){const s=this.getSnapshot(n.serverId);te(s)&&s?.lastOnlineAt&&((!t||s.lastOnlineAt<t)&&(t=s.lastOnlineAt,e=n.serverId))}return e}ensureConnectedAll(e){for(const t of this.controllers.values())t.ensureConnected(e)}setAppVisible(e){e?this.ensureConnectedAll({verify:!0}):this.replicaCache.flush()}runProbeCycleNow(e){return e?this.controllers.get(e)?.runProbeCycleNow()??Promise.resolve():Promise.all(Array.from(this.controllers.values(),e=>e.runProbeCycleNow())).then(()=>{})}async refreshAgentDirectory(e){const t=this.directorySyncByServer.get(e.serverId);if(!t)throw new Error(`Unknown host runtime for serverId ${e.serverId}`);return t.refreshAgents(e)}async refreshWorkspaceDirectory(e){const t=this.directorySyncByServer.get(e.serverId);if(!t)throw new Error(`Unknown host runtime for serverId ${e.serverId}`);await t.refreshWorkspaces({subscribe:e.subscribe})}async refreshDirectories(e){const t=this.directorySyncByServer.get(e);if(!t)throw new Error(`Unknown host runtime for serverId ${e}`);await t.refreshDemand()}acquireDirectoryDemand(e){const t=this.directorySyncByServer.get(e);if(!t)return()=>{};const n={};return t.setDemand(n,!0),()=>t.setDemand(n,!1)}async prepareAgentRoute(e,t){const n=this.directorySyncByServer.get(e);if(!n)throw new Error(`Unknown host runtime for serverId ${e}`);await n.prepareAgentRoute(t)}async prepareWorkspaceRoute(e,t){const n=this.directorySyncByServer.get(e);if(!n)throw new Error(`Unknown host runtime for serverId ${e}`);await n.prepareWorkspaceRoute(t)}async prepareAgentTimeline(e,t){const n=this.timelineReplicaByServer.get(e);if(!n)throw new Error(`Unknown host runtime for serverId ${e}`);await n.prepare(t)}async fetchAgentTimeline(e,t,n){const s=this.directorySyncByServer.get(e);if(!s)throw new Error(`Unknown host runtime for serverId ${e}`);const o=k.useSessionStore.getState().sessions[e]?.viewedTimelineSync,c=await s.fetchTimeline(t,n);return o&&k.useSessionStore.getState().sessions[e]?.viewedTimelineSync===o&&(o.flushStreamAgent(t),o.applyTimelineResponse(c)),c}createViewedTimelineOwner(e,t){const n=this.directorySyncByServer.get(e);if(!n)throw new Error(`Unknown host runtime for serverId ${e}`);const s=this.timelineReplicaByServer.get(e);if(!s)throw new Error(`Unknown host runtime for serverId ${e}`);return(0,Q.createViewedTimelineOwner)({serverId:e,replica:s,replaceDemandedAgentIds:e=>n.setAgentRouteDemand(e),drainQueuedAgentMessage:t=>this.drainQueuedAgentMessage(e,t),ports:t})}emit(e){this.version+=1;const t=this.serverListeners.get(e);if(t){for(const e of t)e();for(const e of this.globalListeners)e()}else for(const e of this.globalListeners)e()}}let Ee=null;const Le="__paseoHostRuntimeStore";function Pe(){if(Ee)return Ee;const e=Reflect.get(globalThis,Le);return e instanceof De?(Ee=e,e):(Ee=new De,Reflect.set(globalThis,Le,Ee),Ee)}},3529,[36,454,3530,2982,37,885,3531,3482,3532,3535,3537,3526,3538,3539,3540,881,3542,3543,2898,3018,3546,3544,882,3547,2994,3007,3459,3548,3555,849,3557,3567,3585,3587,3600,3467,3591,3601,3607,3637,3641,3642,3646,3648,3650,3651]);
15175
15175
  __d(function(g,r,i,a,m,_e,d){"use strict";Object.defineProperty(_e,'__esModule',{value:!0}),_e.getAppDeviceKind=function(){return(0,n.getIsElectron)()?o.DeviceKind.Desktop:n.isWeb?o.DeviceKind.Browser:o.DeviceKind.Mobile},_e.getAppDeviceLabel=async function(){if((0,n.getIsElectron)()){const e=await((0,s.getDesktopHost)()?.invoke?.("desktop_get_computer_name").catch(()=>{}));return"string"==typeof e?`Paseo Desktop \xb7 ${e}`:"Paseo Desktop"}if(n.isWeb){let e="Web";return/Safari\//.test(navigator.userAgent)&&(e="Safari"),/Chrome\//.test(navigator.userAgent)&&(e="Chrome"),/Firefox\//.test(navigator.userAgent)&&(e="Firefox"),/Edg\//.test(navigator.userAgent)&&(e="Edge"),`Browser \xb7 ${e}`}return"Android"};var e,t=r(d[0]),o=((e=t)&&e.__esModule,r(d[1])),n=r(d[2]),s=r(d[3])},3530,[26,2982,881,882]);
@@ -92,6 +92,6 @@
92
92
  <body>
93
93
  <noscript>You need to enable JavaScript to run this app.</noscript>
94
94
  <div id="root"></div>
95
- <script src="/_expo/static/js/web/index-906d2f4f5f6cb670ae516f04dd636fc3.js" defer></script>
95
+ <script src="/_expo/static/js/web/index-b8c45270998cdd560e3a40ec00a172ff.js" defer></script>
96
96
  </body>
97
97
  </html>
@@ -1,3 +1,4 @@
1
+ import path from "node:path";
1
2
  import { getErrorMessage } from "@getpaseo/protocol/error-utils";
2
3
  import { z } from "zod";
3
4
  import { execCommand } from "../../../utils/spawn.js";
@@ -31,6 +32,12 @@ async function runExternalCommand(command, args, options) {
31
32
  const { stdout, stderr } = await execCommand(command, args, {
32
33
  timeout: options?.timeout,
33
34
  maxBuffer: options?.maxBuffer,
35
+ // Version-manager PATH shims can switch Node installations while the daemon is running.
36
+ envOverlay: {
37
+ PATH: [path.dirname(process.execPath), process.env.PATH]
38
+ .filter(Boolean)
39
+ .join(path.delimiter),
40
+ },
34
41
  });
35
42
  return { exitCode: 0, stdout, stderr };
36
43
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getpaseo/server",
3
- "version": "0.11.0-fork.36",
3
+ "version": "0.11.0-fork.37",
4
4
  "description": "Paseo backend server",
5
5
  "files": [
6
6
  "dist/server",
@@ -125,10 +125,10 @@
125
125
  "lightningcss": "1.30.1"
126
126
  },
127
127
  "dependencies": {
128
- "@getpaseo/client": "0.11.0-fork.36",
129
- "@getpaseo/highlight": "0.11.0-fork.36",
130
- "@getpaseo/plugin": "0.11.0-fork.36",
131
- "@getpaseo/protocol": "0.11.0-fork.36",
132
- "@getpaseo/relay": "0.11.0-fork.36"
128
+ "@getpaseo/client": "0.11.0-fork.37",
129
+ "@getpaseo/highlight": "0.11.0-fork.37",
130
+ "@getpaseo/plugin": "0.11.0-fork.37",
131
+ "@getpaseo/protocol": "0.11.0-fork.37",
132
+ "@getpaseo/relay": "0.11.0-fork.37"
133
133
  }
134
134
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mduan/paseo-cli",
3
- "version": "0.11.0-fork.36",
3
+ "version": "0.11.0-fork.37",
4
4
  "description": "Paseo CLI - control your AI coding agents from the command line (mduan fork)",
5
5
  "bin": {
6
6
  "paseo": "bin/paseo"
@@ -21,12 +21,12 @@
21
21
  "@clack/prompts": "^1.0.0",
22
22
  "@codemirror/language": "6.12.4",
23
23
  "@codemirror/legacy-modes": "^6.5.3",
24
- "@getpaseo/client": "0.11.0-fork.36",
25
- "@getpaseo/highlight": "0.11.0-fork.36",
26
- "@getpaseo/plugin": "0.11.0-fork.36",
27
- "@getpaseo/protocol": "0.11.0-fork.36",
28
- "@getpaseo/relay": "0.11.0-fork.36",
29
- "@getpaseo/server": "0.11.0-fork.36",
24
+ "@getpaseo/client": "0.11.0-fork.37",
25
+ "@getpaseo/highlight": "0.11.0-fork.37",
26
+ "@getpaseo/plugin": "0.11.0-fork.37",
27
+ "@getpaseo/protocol": "0.11.0-fork.37",
28
+ "@getpaseo/relay": "0.11.0-fork.37",
29
+ "@getpaseo/server": "0.11.0-fork.37",
30
30
  "@isaacs/ttlcache": "^2.1.4",
31
31
  "@lezer/common": "^1.5.0",
32
32
  "@lezer/cpp": "^1.1.5",