@myrialabs/clopen 0.3.8 → 0.3.10

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 (146) hide show
  1. package/README.md +22 -19
  2. package/backend/auth/auth-service.ts +56 -1
  3. package/backend/auth/permissions.ts +66 -2
  4. package/backend/auth/session-cleanup.ts +58 -0
  5. package/backend/chat/stream-manager.ts +143 -13
  6. package/backend/database/migrations/032_seed_copilot_provider.ts +19 -0
  7. package/backend/database/migrations/033_seed_codex_provider.ts +19 -0
  8. package/backend/database/migrations/034_seed_qwen_provider.ts +119 -0
  9. package/backend/database/migrations/035_add_owner_to_db_client_connections.ts +34 -0
  10. package/backend/database/migrations/index.ts +29 -1
  11. package/backend/database/queries/db-client-connection-queries.ts +160 -54
  12. package/backend/database/queries/engine-queries.ts +12 -0
  13. package/backend/database/queries/project-queries.ts +10 -5
  14. package/backend/db-client/connection-manager.ts +9 -3
  15. package/backend/engine/README.md +1702 -0
  16. package/backend/engine/adapters/claude/models.ts +141 -0
  17. package/backend/engine/adapters/claude/stream.ts +1 -1
  18. package/backend/engine/adapters/codex/credential.ts +179 -0
  19. package/backend/engine/adapters/codex/error-handler.ts +65 -0
  20. package/backend/engine/adapters/codex/index.ts +1 -0
  21. package/backend/engine/adapters/codex/message-converter.ts +646 -0
  22. package/backend/engine/adapters/codex/models.ts +105 -0
  23. package/backend/engine/adapters/codex/patch-rollout.ts +169 -0
  24. package/backend/engine/adapters/codex/session-fork.ts +149 -0
  25. package/backend/engine/adapters/codex/stream.ts +310 -0
  26. package/backend/engine/adapters/codex/usage-rollout.ts +145 -0
  27. package/backend/engine/adapters/copilot/error-handler.ts +94 -0
  28. package/backend/engine/adapters/copilot/index.ts +1 -0
  29. package/backend/engine/adapters/copilot/message-converter.ts +973 -0
  30. package/backend/engine/adapters/copilot/models.ts +92 -0
  31. package/backend/engine/adapters/copilot/session-fork.ts +111 -0
  32. package/backend/engine/adapters/copilot/stream.ts +570 -0
  33. package/backend/engine/adapters/opencode/config.ts +56 -104
  34. package/backend/engine/adapters/opencode/error-handler.ts +71 -0
  35. package/backend/engine/adapters/opencode/models.ts +79 -0
  36. package/backend/engine/adapters/opencode/presets.ts +91 -0
  37. package/backend/engine/adapters/opencode/stream.ts +8 -114
  38. package/backend/engine/adapters/qwen/credential.ts +78 -0
  39. package/backend/engine/adapters/qwen/environment.ts +84 -0
  40. package/backend/engine/adapters/qwen/error-handler.ts +71 -0
  41. package/backend/engine/adapters/qwen/index.ts +1 -0
  42. package/backend/engine/adapters/qwen/message-converter.ts +1055 -0
  43. package/backend/engine/adapters/qwen/models.ts +81 -0
  44. package/backend/engine/adapters/qwen/presets.ts +51 -0
  45. package/backend/engine/adapters/qwen/session-fork.ts +97 -0
  46. package/backend/engine/adapters/qwen/stream.ts +379 -0
  47. package/backend/engine/index.ts +35 -0
  48. package/backend/engine/install-recipes.ts +80 -1
  49. package/backend/engine/install-runner.ts +4 -0
  50. package/backend/files/path-browsing.ts +20 -0
  51. package/backend/git/git-service.ts +81 -11
  52. package/backend/git/git-spawn-validation.test.ts +75 -0
  53. package/backend/git/git-spawn-validation.ts +77 -0
  54. package/backend/index.ts +5 -0
  55. package/backend/mcp/README.md +84 -14
  56. package/backend/mcp/config.ts +218 -17
  57. package/backend/mcp/index.ts +2 -0
  58. package/backend/mcp/project-context.ts +55 -0
  59. package/backend/mcp/servers/browser-automation/actions.ts +6 -1
  60. package/backend/mcp/servers/helper.ts +13 -0
  61. package/backend/middleware/error-handler.ts +16 -2
  62. package/backend/preview/browser/browser-preview-service.ts +4 -4
  63. package/backend/preview/browser/browser-tab-manager.ts +23 -3
  64. package/backend/snapshot/gitignore.ts +4 -9
  65. package/backend/tunnel/cloudflared/binary.ts +2 -2
  66. package/backend/tunnel/global-tunnel-manager.ts +9 -3
  67. package/backend/utils/ws.ts +5 -1
  68. package/backend/ws/README.md +128 -3
  69. package/backend/ws/access.ts +56 -0
  70. package/backend/ws/auth/index.ts +14 -0
  71. package/backend/ws/auth/login.ts +3 -0
  72. package/backend/ws/auth/users.ts +61 -1
  73. package/backend/ws/chat/stream.ts +139 -22
  74. package/backend/ws/db-client/access.ts +19 -0
  75. package/backend/ws/db-client/connections.ts +31 -17
  76. package/backend/ws/db-client/io.ts +7 -9
  77. package/backend/ws/db-client/query.ts +86 -32
  78. package/backend/ws/db-client/schema.ts +9 -4
  79. package/backend/ws/db-client/structure.ts +22 -10
  80. package/backend/ws/engine/access.ts +39 -0
  81. package/backend/ws/engine/claude/accounts.ts +15 -10
  82. package/backend/ws/engine/codex/accounts.ts +516 -0
  83. package/backend/ws/engine/codex/index.ts +14 -0
  84. package/backend/ws/engine/codex/status.ts +87 -0
  85. package/backend/ws/engine/copilot/accounts.ts +122 -0
  86. package/backend/ws/engine/copilot/index.ts +13 -0
  87. package/backend/ws/engine/copilot/status.ts +54 -0
  88. package/backend/ws/engine/index.ts +7 -1
  89. package/backend/ws/engine/opencode/providers.ts +1 -1
  90. package/backend/ws/engine/qwen/accounts.ts +137 -0
  91. package/backend/ws/engine/qwen/index.ts +15 -0
  92. package/backend/ws/engine/qwen/presets.ts +40 -0
  93. package/backend/ws/engine/qwen/status.ts +54 -0
  94. package/backend/ws/files/path-access.ts +101 -0
  95. package/backend/ws/files/read.ts +26 -11
  96. package/backend/ws/files/search.ts +10 -6
  97. package/backend/ws/files/state.ts +3 -0
  98. package/backend/ws/files/watch.ts +7 -1
  99. package/backend/ws/files/write.ts +109 -15
  100. package/backend/ws/git/branch.ts +13 -19
  101. package/backend/ws/git/commit-message.ts +3 -4
  102. package/backend/ws/git/commit.ts +5 -7
  103. package/backend/ws/git/conflict.ts +7 -10
  104. package/backend/ws/git/diff.ts +7 -10
  105. package/backend/ws/git/log.ts +3 -4
  106. package/backend/ws/git/remote.ts +30 -43
  107. package/backend/ws/git/staging.ts +13 -19
  108. package/backend/ws/git/status.ts +7 -11
  109. package/backend/ws/messages/crud.ts +7 -13
  110. package/backend/ws/preview/access.ts +45 -0
  111. package/backend/ws/preview/browser/cleanup.ts +3 -11
  112. package/backend/ws/preview/browser/console.ts +7 -42
  113. package/backend/ws/preview/browser/interact.ts +2 -6
  114. package/backend/ws/preview/browser/native-ui.ts +5 -18
  115. package/backend/ws/preview/browser/stats.ts +2 -12
  116. package/backend/ws/preview/browser/tab-info.ts +4 -20
  117. package/backend/ws/preview/browser/tab.ts +4 -27
  118. package/backend/ws/preview/browser/webcodecs.ts +6 -47
  119. package/backend/ws/projects/crud.ts +15 -16
  120. package/backend/ws/projects/status.ts +5 -1
  121. package/backend/ws/sessions/crud.ts +31 -36
  122. package/backend/ws/settings/crud.ts +13 -13
  123. package/backend/ws/snapshot/restore.ts +5 -2
  124. package/backend/ws/snapshot/timeline.ts +3 -1
  125. package/backend/ws/system-tools/access.ts +28 -0
  126. package/backend/ws/system-tools/install.ts +13 -4
  127. package/backend/ws/system-tools/status.ts +5 -2
  128. package/backend/ws/terminal/access.ts +56 -0
  129. package/backend/ws/terminal/persistence.ts +13 -7
  130. package/backend/ws/terminal/session.ts +35 -14
  131. package/backend/ws/terminal/stream.ts +4 -1
  132. package/dist/assets/{index-DqAGCTFT.js → index-C1afGwHY.js} +2 -2
  133. package/dist/assets/main-CZb3Y_Z_.js +315 -0
  134. package/dist/assets/main-Cn8cX2DY.css +1 -0
  135. package/dist/index.html +2 -2
  136. package/package.json +5 -1
  137. package/shared/constants/engines.ts +45 -140
  138. package/shared/types/database/schema.ts +1 -0
  139. package/shared/types/unified/common.ts +1 -1
  140. package/shared/types/unified/engine.ts +29 -1
  141. package/shared/types/unified/index.ts +2 -0
  142. package/shared/types/unified/message.ts +1 -1
  143. package/shared/types/unified/tool.ts +17 -2
  144. package/shared/utils/ws-server.ts +14 -0
  145. package/dist/assets/main-DsED0rLr.js +0 -304
  146. package/dist/assets/main-eWY9R8g9.css +0 -1
@@ -25,6 +25,33 @@ export const ENGINES: EngineInfo[] = [
25
25
  light: '<svg width="240" height="300" viewBox="0 0 240 300" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#clip0_1401_86274)"><mask id="mask0_1401_86274" style="mask-type:luminance" maskUnits="userSpaceOnUse" x="0" y="0" width="240" height="300"><path d="M240 0H0V300H240V0Z" fill="white"/></mask><g mask="url(#mask0_1401_86274)"><path d="M180 240H60V120H180V240Z" fill="#CFCECD"/><path d="M180 60H60V240H180V60ZM240 300H0V0H240V300Z" fill="#211E1E"/></g></g><defs><clipPath id="clip0_1401_86274"><rect width="240" height="300" fill="white"/></clipPath></defs></svg>',
26
26
  dark: '<svg width="240" height="300" viewBox="0 0 240 300" fill="none" xmlns="http://www.w3.org/2000/svg"><g clip-path="url(#clip0_1401_86283)"><mask id="mask0_1401_86283" style="mask-type:luminance" maskUnits="userSpaceOnUse" x="0" y="0" width="240" height="300"><path d="M240 0H0V300H240V0Z" fill="white"/></mask><g mask="url(#mask0_1401_86283)"><path d="M180 240H60V120H180V240Z" fill="#4B4646"/><path d="M180 60H60V240H180V60ZM240 300H0V0H240V300Z" fill="#F1ECEC"/></g></g><defs><clipPath id="clip0_1401_86283"><rect width="240" height="300" fill="white"/></clipPath></defs></svg>'
27
27
  }
28
+ },
29
+ {
30
+ type: 'copilot',
31
+ name: 'Copilot',
32
+ description: 'GitHub Copilot models',
33
+ icon: {
34
+ light: '<svg width="98" height="96" viewBox="0 0 98 96" xmlns="http://www.w3.org/2000/svg"><path fill="#24292f" fill-rule="evenodd" clip-rule="evenodd" d="M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z"/></svg>',
35
+ dark: '<svg width="98" height="96" viewBox="0 0 98 96" xmlns="http://www.w3.org/2000/svg"><path fill="#ffffff" fill-rule="evenodd" clip-rule="evenodd" d="M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z"/></svg>'
36
+ }
37
+ },
38
+ {
39
+ type: 'codex',
40
+ name: 'Codex',
41
+ description: 'OpenAI Codex models',
42
+ icon: {
43
+ light: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill="#000000" d="M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9 6.0651 6.0651 0 0 0-4.5837-2.083 6.0469 6.0469 0 0 0-5.7669 4.1843 5.9854 5.9854 0 0 0-3.9982 2.9001 6.0461 6.0461 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2056 5.9894 5.9894 0 0 0 3.9981-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.5093-2.6067-1.4997z"/></svg>',
44
+ dark: '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill="#ffffff" d="M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9 6.0651 6.0651 0 0 0-4.5837-2.083 6.0469 6.0469 0 0 0-5.7669 4.1843 5.9854 5.9854 0 0 0-3.9982 2.9001 6.0461 6.0461 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2056 5.9894 5.9894 0 0 0 3.9981-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.5093-2.6067-1.4997z"/></svg>'
45
+ }
46
+ },
47
+ {
48
+ type: 'qwen',
49
+ name: 'Qwen Code',
50
+ description: 'Alibaba Qwen models',
51
+ icon: {
52
+ light: '<svg width="24" height="24" viewBox="0 0 200 200" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M174.82 108.75L155.38 75L165.64 57.75C166.46 56.31 166.46 54.53 165.64 53.09L155.38 35.84C154.86 34.91 153.87 34.33 152.78 34.33H114.88L106.14 19.03C105.62 18.1 104.63 17.52 103.54 17.52H83.3C82.21 17.52 81.22 18.1 80.7 19.03L61.26 52.77H41.02C39.93 52.77 38.94 53.35 38.42 54.28L28.16 71.53C27.34 72.97 27.34 74.75 28.16 76.19L45.52 107.5L36.78 122.8C35.96 124.24 35.96 126.02 36.78 127.46L47.04 144.71C47.56 145.64 48.55 146.22 49.64 146.22H87.54L96.28 161.52C96.8 162.45 97.79 163.03 98.88 163.03H119.12C120.21 163.03 121.2 162.45 121.72 161.52L141.16 127.78H158.52C159.61 127.78 160.6 127.2 161.12 126.27L171.38 109.02C172.2 107.58 172.2 105.8 171.38 104.36L174.82 108.75Z" fill="url(#qwen-grad-light-a)"/><path d="M119.12 163.03H98.88L87.54 144.71H49.64L61.26 126.39H80.7L38.42 55.29H61.26L83.3 19.03L93.56 37.35L83.3 55.29H161.58L151.32 72.54L170.76 106.28H151.32L141.16 88.34L101.18 163.03H119.12Z" fill="#ffffff"/><path d="M127.86 79.83H76.14L101.18 122.11L127.86 79.83Z" fill="url(#qwen-grad-light-b)"/><defs><radialGradient id="qwen-grad-light-a" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(100 100) rotate(90) scale(100)"><stop stop-color="#665CEE"/><stop offset="1" stop-color="#332E91"/></radialGradient><radialGradient id="qwen-grad-light-b" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(100 100) rotate(90) scale(100)"><stop stop-color="#665CEE"/><stop offset="1" stop-color="#332E91"/></radialGradient></defs></svg>',
53
+ dark: '<svg width="24" height="24" viewBox="0 0 200 200" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M174.82 108.75L155.38 75L165.64 57.75C166.46 56.31 166.46 54.53 165.64 53.09L155.38 35.84C154.86 34.91 153.87 34.33 152.78 34.33H114.88L106.14 19.03C105.62 18.1 104.63 17.52 103.54 17.52H83.3C82.21 17.52 81.22 18.1 80.7 19.03L61.26 52.77H41.02C39.93 52.77 38.94 53.35 38.42 54.28L28.16 71.53C27.34 72.97 27.34 74.75 28.16 76.19L45.52 107.5L36.78 122.8C35.96 124.24 35.96 126.02 36.78 127.46L47.04 144.71C47.56 145.64 48.55 146.22 49.64 146.22H87.54L96.28 161.52C96.8 162.45 97.79 163.03 98.88 163.03H119.12C120.21 163.03 121.2 162.45 121.72 161.52L141.16 127.78H158.52C159.61 127.78 160.6 127.2 161.12 126.27L171.38 109.02C172.2 107.58 172.2 105.8 171.38 104.36L174.82 108.75Z" fill="url(#qwen-grad-dark-a)"/><path d="M119.12 163.03H98.88L87.54 144.71H49.64L61.26 126.39H80.7L38.42 55.29H61.26L83.3 19.03L93.56 37.35L83.3 55.29H161.58L151.32 72.54L170.76 106.28H151.32L141.16 88.34L101.18 163.03H119.12Z" fill="#ffffff"/><path d="M127.86 79.83H76.14L101.18 122.11L127.86 79.83Z" fill="url(#qwen-grad-dark-b)"/><defs><radialGradient id="qwen-grad-dark-a" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(100 100) rotate(90) scale(100)"><stop stop-color="#a39afa"/><stop offset="1" stop-color="#615ced"/></radialGradient><radialGradient id="qwen-grad-dark-b" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(100 100) rotate(90) scale(100)"><stop stop-color="#a39afa"/><stop offset="1" stop-color="#615ced"/></radialGradient></defs></svg>'
54
+ }
28
55
  }
29
56
  ];
30
57
 
@@ -33,147 +60,21 @@ export const getEngineInfo = (engineType: EngineType): EngineInfo | undefined =>
33
60
  };
34
61
 
35
62
  // ============================================================================
36
- // Claude Code Models (static)
63
+ // Engine-specific catalogs & presets
64
+ //
65
+ // Per-engine data (model lists, provider presets, etc.) lives with the adapter
66
+ // in `backend/engine/adapters/<engine>/`. The frontend never imports those
67
+ // modules directly — it loads what it needs at runtime via WS endpoints
68
+ // (`models:list`, `engine:qwen-presets-list`, …).
37
69
  // ============================================================================
38
70
 
39
- export const CLAUDE_CODE_MODELS: EngineModel[] = [
40
- {
41
- engine: {
42
- type: 'claude-code',
43
- provider: 'anthropic',
44
- model: {
45
- id: 'claude-opus-4-7',
46
- name: 'Claude Opus 4.7',
47
- },
48
- account: {
49
- id: 0,
50
- name: '',
51
- },
52
- },
53
- limit: {
54
- input: 200_000,
55
- output: 128_000,
56
- },
57
- modalities: {
58
- input: {
59
- text: true,
60
- image: true,
61
- audio: false,
62
- video: false,
63
- pdf: true,
64
- },
65
- output: {
66
- text: true,
67
- image: false,
68
- audio: false,
69
- video: false,
70
- pdf: false,
71
- },
72
- },
73
- capabilities: {
74
- reasoning: true,
75
- tools: true,
76
- structuredOutput: true,
77
- },
78
- cost: {
79
- input: 5,
80
- output: 25,
81
- },
82
- },
83
- {
84
- engine: {
85
- type: 'claude-code',
86
- provider: 'anthropic',
87
- model: {
88
- id: 'claude-sonnet-4-6',
89
- name: 'Claude Sonnet 4.6',
90
- },
91
- account: {
92
- id: 0,
93
- name: '',
94
- },
95
- },
96
- limit: {
97
- input: 200_000,
98
- output: 64_000,
99
- },
100
- modalities: {
101
- input: {
102
- text: true,
103
- image: true,
104
- audio: false,
105
- video: false,
106
- pdf: true,
107
- },
108
- output: {
109
- text: true,
110
- image: false,
111
- audio: false,
112
- video: false,
113
- pdf: false,
114
- },
115
- },
116
- capabilities: {
117
- reasoning: true,
118
- tools: true,
119
- structuredOutput: true,
120
- },
121
- cost: {
122
- input: 3,
123
- output: 15,
124
- },
125
- },
126
- {
127
- engine: {
128
- type: 'claude-code',
129
- provider: 'anthropic',
130
- model: {
131
- id: 'claude-haiku-4-5',
132
- name: 'Claude Haiku 4.5',
133
- },
134
- account: {
135
- id: 0,
136
- name: '',
137
- },
138
- },
139
- limit: {
140
- input: 200_000,
141
- output: 64_000,
142
- },
143
- modalities: {
144
- input: {
145
- text: true,
146
- image: true,
147
- audio: false,
148
- video: false,
149
- pdf: true,
150
- },
151
- output: {
152
- text: true,
153
- image: false,
154
- audio: false,
155
- video: false,
156
- pdf: false,
157
- },
158
- },
159
- capabilities: {
160
- reasoning: true,
161
- tools: true,
162
- structuredOutput: true,
163
- },
164
- cost: {
165
- input: 1,
166
- output: 5,
167
- },
168
- },
169
- ];
170
-
171
71
  // ============================================================================
172
- // Model Registry (mutable — dynamic engines can register models at runtime)
72
+ // Model Registry (mutable — engines register their catalog at runtime via
73
+ // the `models:list` WS endpoint, which calls each adapter's getAvailableModels()
74
+ // and replaces the engine's slice of the registry).
173
75
  // ============================================================================
174
76
 
175
- /** All registered models. Claude Code models are static; Open Code models are fetched dynamically. */
176
- const modelRegistry: EngineModel[] = [...CLAUDE_CODE_MODELS];
77
+ const modelRegistry: EngineModel[] = [];
177
78
 
178
79
  /** Register models for a specific engine (replaces any existing models for that engine) */
179
80
  export const registerModels = (engine: EngineType, models: EngineModel[]): void => {
@@ -189,11 +90,15 @@ export const getAllModels = (): EngineModel[] => [...modelRegistry];
189
90
 
190
91
  // ============================================================================
191
92
  // Defaults
93
+ //
94
+ // Hardcoded so the shared module has no dependency on the per-adapter model
95
+ // catalogs. The chosen default (`claude-sonnet-4-6`) is the same model that
96
+ // previously lived at `CLAUDE_CODE_MODELS[1]`.
192
97
  // ============================================================================
193
98
 
194
- export const DEFAULT_ENGINE = CLAUDE_CODE_MODELS[1].engine.type;
195
- export const DEFAULT_MODEL_ID = CLAUDE_CODE_MODELS[1].engine.model.id;
196
- export const DEFAULT_MODEL_NAME = CLAUDE_CODE_MODELS[1].engine.model.name;
99
+ export const DEFAULT_ENGINE: EngineType = 'claude-code';
100
+ export const DEFAULT_MODEL_ID = 'claude-sonnet-4-6';
101
+ export const DEFAULT_MODEL_NAME = 'Claude Sonnet 4.6';
197
102
 
198
103
  // ============================================================================
199
104
  // Lookup Helpers
@@ -216,4 +121,4 @@ export function getModelTags(model: EngineModel): string[] {
216
121
  if (model.modalities.input.audio) tags.push('Audio');
217
122
  if (model.modalities.input.video) tags.push('Video');
218
123
  return tags;
219
- }
124
+ }
@@ -199,6 +199,7 @@ export interface DBDbClientConnectionRow {
199
199
  ssh_passphrase: string | null;
200
200
  options_json: string | null;
201
201
  color: string | null;
202
+ owner_user_id: string | null;
202
203
  created_at: string;
203
204
  updated_at: string;
204
205
  last_used_at: string | null;
@@ -18,4 +18,4 @@ export type StopReason =
18
18
  | 'interrupted';
19
19
 
20
20
  /** Supported AI engine backends */
21
- export type EngineType = 'claude-code' | 'opencode';
21
+ export type EngineType = 'claude-code' | 'opencode' | 'copilot' | 'codex' | 'qwen';
@@ -41,6 +41,16 @@ export interface EngineModel {
41
41
  reasoning: boolean;
42
42
  tools: boolean;
43
43
  structuredOutput: boolean;
44
+ /**
45
+ * Auth modes the model is compatible with. Models that require a
46
+ * ChatGPT (OAuth) login are flagged `'chatgpt'`; models that only
47
+ * accept API keys are flagged `'api_key'`. Models compatible with
48
+ * either mode leave this `undefined`.
49
+ *
50
+ * The chat input's account picker uses this to grey out models that
51
+ * the active Codex account can't reach.
52
+ */
53
+ requiresAuthMode?: 'chatgpt' | 'api_key';
44
54
  };
45
55
 
46
56
  cost: {
@@ -51,7 +61,7 @@ export interface EngineModel {
51
61
 
52
62
  // Engine metadata for UI display
53
63
  export interface EngineInfo {
54
- type: 'claude-code' | 'opencode';
64
+ type: 'claude-code' | 'opencode' | 'copilot' | 'codex' | 'qwen';
55
65
  name: string;
56
66
  description: string;
57
67
  icon: {
@@ -59,3 +69,21 @@ export interface EngineInfo {
59
69
  dark: string;
60
70
  }
61
71
  }
72
+
73
+ // ── Qwen provider presets (wire format for `engine:qwen-presets-list`) ──
74
+ //
75
+ // Defined here so the frontend can stay typed without importing from
76
+ // `$backend`. The runtime values live in `backend/engine/adapters/qwen/presets.ts`.
77
+
78
+ export type QwenProviderPresetId =
79
+ | 'dashscope-cn'
80
+ | 'dashscope-intl'
81
+ | 'openrouter'
82
+ | 'fireworks';
83
+
84
+ export interface QwenProviderPreset {
85
+ id: QwenProviderPresetId;
86
+ name: string;
87
+ defaultBaseUrl: string;
88
+ docsUrl?: string;
89
+ }
@@ -21,6 +21,8 @@ export type {
21
21
  export type {
22
22
  EngineModel,
23
23
  EngineInfo,
24
+ QwenProviderPresetId,
25
+ QwenProviderPreset,
24
26
  } from './engine';
25
27
 
26
28
  // ── Tools ────────────────────────────────────────────────────
@@ -39,7 +39,7 @@ export interface MessageModel {
39
39
 
40
40
  /** Engine context attached to every message */
41
41
  export interface MessageEngine {
42
- type: 'claude-code' | 'opencode';
42
+ type: 'claude-code' | 'opencode' | 'copilot' | 'codex' | 'qwen';
43
43
  provider: string;
44
44
  model: MessageModel;
45
45
  account: MessageAccount;
@@ -307,16 +307,31 @@ export const CANONICAL_TOOL_NAMES = new Set<KnownToolName>([
307
307
  'CronCreate', 'CronDelete', 'CronList',
308
308
  ]);
309
309
 
310
+ /**
311
+ * MCP tools that the UI renders via a canonical (non-`mcp__*`) component.
312
+ *
313
+ * Currently empty — kept as a hook so a future engine that surfaces a
314
+ * canonical-equivalent tool through MCP (rather than its native SDK) can
315
+ * collapse it without re-introducing the registry plumbing.
316
+ */
317
+ const MCP_CANONICAL_OVERRIDES: Record<string, KnownToolName> = {};
318
+
310
319
  /**
311
320
  * Normalize an arbitrary tool name emitted by an engine into a shape the UI
312
321
  * is guaranteed to handle:
313
322
  * - canonical names pass through unchanged;
314
- * - `mcp__*` names pass through unchanged;
323
+ * - whitelisted `mcp__*` overrides collapse to their canonical equivalent
324
+ * (see MCP_CANONICAL_OVERRIDES);
325
+ * - other `mcp__*` names pass through unchanged;
315
326
  * - anything else is wrapped as `Unknown:<original>` so the UI renders a
316
327
  * visible error with a pointer to the fix (add to the registry).
317
328
  */
318
329
  export function toCanonicalToolName(rawName: string): KnownToolName | McpToolName | UnknownToolName {
319
- if (rawName.startsWith('mcp__')) return rawName as McpToolName;
330
+ if (rawName.startsWith('mcp__')) {
331
+ const override = MCP_CANONICAL_OVERRIDES[rawName];
332
+ if (override) return override;
333
+ return rawName as McpToolName;
334
+ }
320
335
  if (CANONICAL_TOOL_NAMES.has(rawName as KnownToolName)) return rawName as KnownToolName;
321
336
  return `Unknown:${rawName}` as UnknownToolName;
322
337
  }
@@ -313,10 +313,24 @@ export class WSRouter<
313
313
  handler: async ({ conn, data }) => {
314
314
  // Import ws server to update context
315
315
  const { ws: wsServer } = await import('$backend/utils/ws');
316
+ const { projectQueries } = await import('$backend/database/queries');
316
317
 
317
318
  // userId is set exclusively by auth handlers (auth:login, auth:setup, auth:accept-invite)
318
319
  // ws:set-context only handles projectId
319
320
  if (data.projectId !== undefined) {
321
+ if (data.projectId !== null) {
322
+ const state = wsServer.getConnectionState(conn);
323
+ const userId = state?.userId;
324
+ if (!userId) {
325
+ throw new Error('Authentication required');
326
+ }
327
+
328
+ const hasProjectAccess = projectQueries.userHasProject(userId, data.projectId);
329
+ if (!hasProjectAccess) {
330
+ throw new Error('Project not found');
331
+ }
332
+ }
333
+
320
334
  wsServer.setProject(conn, data.projectId);
321
335
  }
322
336