dsh-cliworker-now 0.7.6 → 0.7.8

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 (181) hide show
  1. package/README.en.md +53 -11
  2. package/README.md +56 -11
  3. package/lib/account-models.mjs +49 -18
  4. package/lib/client.js +1221 -151
  5. package/lib/client.js.map +1 -1
  6. package/lib/grok-catalog.mjs +2 -2
  7. package/lib/hermes-native-entry.py +48 -13
  8. package/lib/hermes-nous-refresh.py +331 -0
  9. package/lib/index.js +9469 -6030
  10. package/lib/index.js.map +1 -1
  11. package/lib/native-launch.mjs +62 -7
  12. package/lib/native-spawn.mjs +32 -0
  13. package/lib/pi-installation.mjs +27 -3
  14. package/lib/pi-native-catalog.mjs +17 -7
  15. package/lib/pi-omp-bridge.mjs +2 -2
  16. package/lib/pi-omp-refresh.mjs +3 -3
  17. package/lib/private-launch.mjs +6 -2
  18. package/lib/terminal-bridge.mjs +2 -2
  19. package/lib/typert.host.js +265 -25
  20. package/lib/typert.remote-client.d.ts +8 -0
  21. package/lib/typert.remote-client.d.ts.map +1 -1
  22. package/lib/typert.remote-client.js +241 -25
  23. package/lib/types/client/account-query-queue.d.ts +16 -0
  24. package/lib/types/client/account-query-queue.js +61 -0
  25. package/lib/types/client/account-query-queue.js.map +1 -0
  26. package/lib/types/client/account-terminal.d.ts +6 -2
  27. package/lib/types/client/account-terminal.js +260 -31
  28. package/lib/types/client/account-terminal.js.map +1 -1
  29. package/lib/types/client/cli-executable-settings.d.ts +13 -0
  30. package/lib/types/client/cli-executable-settings.js +128 -0
  31. package/lib/types/client/cli-executable-settings.js.map +1 -0
  32. package/lib/types/client/management-styles.d.ts +1 -1
  33. package/lib/types/client/management-styles.js +4 -0
  34. package/lib/types/client/management-styles.js.map +1 -1
  35. package/lib/types/client/settings-dialog.js +196 -80
  36. package/lib/types/client/settings-dialog.js.map +1 -1
  37. package/lib/types/client/styles.d.ts +1 -1
  38. package/lib/types/client/styles.js +18 -16
  39. package/lib/types/client/styles.js.map +1 -1
  40. package/lib/types/client/zcode-login-link-provider.d.ts +9 -0
  41. package/lib/types/client/zcode-login-link-provider.js +105 -0
  42. package/lib/types/client/zcode-login-link-provider.js.map +1 -0
  43. package/lib/types/client/zcode-login-link.d.ts +16 -0
  44. package/lib/types/client/zcode-login-link.js +194 -0
  45. package/lib/types/client/zcode-login-link.js.map +1 -0
  46. package/lib/types/host/account-models.d.mts +10 -2
  47. package/lib/types/host/account-models.mjs +49 -18
  48. package/lib/types/host/accounts.d.ts +3 -2
  49. package/lib/types/host/accounts.js +168 -29
  50. package/lib/types/host/accounts.js.map +1 -1
  51. package/lib/types/host/adapters.d.ts +3 -1
  52. package/lib/types/host/adapters.js +138 -11
  53. package/lib/types/host/adapters.js.map +1 -1
  54. package/lib/types/host/agy-background-environment.d.ts +2 -0
  55. package/lib/types/host/agy-background-environment.js +7 -0
  56. package/lib/types/host/agy-background-environment.js.map +1 -0
  57. package/lib/types/host/agy-models.d.ts +2 -1
  58. package/lib/types/host/agy-models.js +6 -6
  59. package/lib/types/host/agy-models.js.map +1 -1
  60. package/lib/types/host/agy-windows-account.d.ts +14 -0
  61. package/lib/types/host/agy-windows-account.js +104 -0
  62. package/lib/types/host/agy-windows-account.js.map +1 -0
  63. package/lib/types/host/authorized-catalog.js +13 -4
  64. package/lib/types/host/authorized-catalog.js.map +1 -1
  65. package/lib/types/host/claude-native-oauth.d.ts +17 -0
  66. package/lib/types/host/claude-native-oauth.js +274 -0
  67. package/lib/types/host/claude-native-oauth.js.map +1 -0
  68. package/lib/types/host/claude-own-route.d.ts +45 -0
  69. package/lib/types/host/claude-own-route.js +375 -0
  70. package/lib/types/host/claude-own-route.js.map +1 -0
  71. package/lib/types/host/cli-account-binding.d.ts +2 -1
  72. package/lib/types/host/cli-account-binding.js +64 -21
  73. package/lib/types/host/cli-account-binding.js.map +1 -1
  74. package/lib/types/host/cli-executable-paths.d.ts +30 -0
  75. package/lib/types/host/cli-executable-paths.js +272 -0
  76. package/lib/types/host/cli-executable-paths.js.map +1 -0
  77. package/lib/types/host/codex-models.d.ts +3 -1
  78. package/lib/types/host/codex-models.js +41 -4
  79. package/lib/types/host/codex-models.js.map +1 -1
  80. package/lib/types/host/extended-adapters.d.ts +3 -2
  81. package/lib/types/host/extended-adapters.js +9 -7
  82. package/lib/types/host/extended-adapters.js.map +1 -1
  83. package/lib/types/host/first-party-models.d.ts +5 -0
  84. package/lib/types/host/first-party-models.js +173 -50
  85. package/lib/types/host/first-party-models.js.map +1 -1
  86. package/lib/types/host/hermes-accounts.js +68 -9
  87. package/lib/types/host/hermes-accounts.js.map +1 -1
  88. package/lib/types/host/hermes-adapter.d.ts +3 -0
  89. package/lib/types/host/hermes-adapter.js +13 -4
  90. package/lib/types/host/hermes-adapter.js.map +1 -1
  91. package/lib/types/host/hermes-installation.js +54 -35
  92. package/lib/types/host/hermes-installation.js.map +1 -1
  93. package/lib/types/host/hermes-models.js +21 -2
  94. package/lib/types/host/hermes-models.js.map +1 -1
  95. package/lib/types/host/hermes-native-entry.py +48 -13
  96. package/lib/types/host/hermes-nous-refresh.py +331 -0
  97. package/lib/types/host/hermes-nous.d.ts +5 -1
  98. package/lib/types/host/hermes-nous.js +5 -5
  99. package/lib/types/host/hermes-nous.js.map +1 -1
  100. package/lib/types/host/hermes-renewal.d.ts +27 -0
  101. package/lib/types/host/hermes-renewal.js +292 -0
  102. package/lib/types/host/hermes-renewal.js.map +1 -0
  103. package/lib/types/host/hermes-windows-installation.d.ts +5 -0
  104. package/lib/types/host/hermes-windows-installation.js +91 -0
  105. package/lib/types/host/hermes-windows-installation.js.map +1 -0
  106. package/lib/types/host/index.d.ts +12 -0
  107. package/lib/types/host/index.js +138 -8
  108. package/lib/types/host/index.js.map +1 -1
  109. package/lib/types/host/kimi-accounts.d.ts +2 -0
  110. package/lib/types/host/kimi-accounts.js +4 -2
  111. package/lib/types/host/kimi-accounts.js.map +1 -1
  112. package/lib/types/host/kimi-oauth-models.d.ts +14 -0
  113. package/lib/types/host/kimi-oauth-models.js +246 -0
  114. package/lib/types/host/kimi-oauth-models.js.map +1 -0
  115. package/lib/types/host/mimo-metadata-cache.d.ts +22 -0
  116. package/lib/types/host/mimo-metadata-cache.js +121 -0
  117. package/lib/types/host/mimo-metadata-cache.js.map +1 -0
  118. package/lib/types/host/native-capability-cache.d.ts +11 -0
  119. package/lib/types/host/native-capability-cache.js +94 -0
  120. package/lib/types/host/native-capability-cache.js.map +1 -0
  121. package/lib/types/host/native-launch.mjs +62 -7
  122. package/lib/types/host/native-process.d.ts +3 -1
  123. package/lib/types/host/native-process.js +30 -5
  124. package/lib/types/host/native-process.js.map +1 -1
  125. package/lib/types/host/native-spawn.mjs +32 -0
  126. package/lib/types/host/opencode-native.js +13 -0
  127. package/lib/types/host/opencode-native.js.map +1 -1
  128. package/lib/types/host/pi-installation.d.mts +1 -1
  129. package/lib/types/host/pi-installation.mjs +27 -3
  130. package/lib/types/host/pi-omp-adapter.js +17 -3
  131. package/lib/types/host/pi-omp-adapter.js.map +1 -1
  132. package/lib/types/host/pi-omp-native.js +5 -3
  133. package/lib/types/host/pi-omp-native.js.map +1 -1
  134. package/lib/types/host/pi-omp-refresh.mjs +3 -3
  135. package/lib/types/host/private-launch.mjs +23 -0
  136. package/lib/types/host/process.d.ts +3 -0
  137. package/lib/types/host/process.js +3 -1
  138. package/lib/types/host/process.js.map +1 -1
  139. package/lib/types/host/routing.js +25 -2
  140. package/lib/types/host/routing.js.map +1 -1
  141. package/lib/types/host/runtime.js +21 -5
  142. package/lib/types/host/runtime.js.map +1 -1
  143. package/lib/types/host/settings-catalog-cache.d.ts +28 -0
  144. package/lib/types/host/settings-catalog-cache.js +189 -0
  145. package/lib/types/host/settings-catalog-cache.js.map +1 -0
  146. package/lib/types/host/windows-account-bootstrap.ps1 +44 -0
  147. package/lib/types/host/windows-account-launch.mjs +47 -0
  148. package/lib/types/host/windows-account-owner.ps1 +137 -0
  149. package/lib/types/host/windows-account-stdio.mjs +19 -0
  150. package/lib/types/host/windows-account-terminal.d.ts +17 -0
  151. package/lib/types/host/windows-account-terminal.js +208 -0
  152. package/lib/types/host/windows-account-terminal.js.map +1 -0
  153. package/lib/types/host/windows-agy-account.ps1 +81 -0
  154. package/lib/types/host/windows-cli-installation.d.ts +35 -0
  155. package/lib/types/host/windows-cli-installation.js +164 -0
  156. package/lib/types/host/windows-cli-installation.js.map +1 -0
  157. package/lib/types/host/windows-codex-launch.d.ts +9 -0
  158. package/lib/types/host/windows-codex-launch.js +216 -0
  159. package/lib/types/host/windows-codex-launch.js.map +1 -0
  160. package/lib/types/host/windows-desktop-cli-installation.d.ts +20 -0
  161. package/lib/types/host/windows-desktop-cli-installation.js +420 -0
  162. package/lib/types/host/windows-desktop-cli-installation.js.map +1 -0
  163. package/lib/types/host/windows-hidden-launch.mjs +51 -0
  164. package/lib/types/host/windows-hidden-process.d.ts +12 -0
  165. package/lib/types/host/windows-hidden-process.js +116 -0
  166. package/lib/types/host/windows-hidden-process.js.map +1 -0
  167. package/lib/types/host/zcode-adapter.js +5 -1
  168. package/lib/types/host/zcode-adapter.js.map +1 -1
  169. package/lib/types/host/zcode-grok-accounts.d.ts +3 -1
  170. package/lib/types/host/zcode-grok-accounts.js +60 -11
  171. package/lib/types/host/zcode-grok-accounts.js.map +1 -1
  172. package/lib/types/shared/accounts.d.ts +4 -0
  173. package/lib/types/shared/cli-settings.d.ts +8 -0
  174. package/lib/windows-account-bootstrap.ps1 +44 -0
  175. package/lib/windows-account-launch.mjs +47 -0
  176. package/lib/windows-account-owner.ps1 +137 -0
  177. package/lib/windows-account-stdio.mjs +19 -0
  178. package/lib/windows-agy-account.ps1 +81 -0
  179. package/lib/windows-hidden-launch.mjs +51 -0
  180. package/lib/zcode-resume.mjs +2 -2
  181. package/package.json +2 -2
package/lib/client.js CHANGED
@@ -3397,6 +3397,16 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
3397
3397
  const dsh_cliworker_now_cliworker_accountStart_parameter_2$schema = () => dsh_cliworker_now_cliworker_accountStart_parameter_2$schema$value ??= string();
3398
3398
  let dsh_cliworker_now_cliworker_accountStart_result$schema$value;
3399
3399
  const dsh_cliworker_now_cliworker_accountStart_result$schema = () => dsh_cliworker_now_cliworker_accountStart_result$schema$value ??= string();
3400
+ let dsh_cliworker_now_cliworker_accountStartForProvider_parameter_0$schema$value;
3401
+ const dsh_cliworker_now_cliworker_accountStartForProvider_parameter_0$schema = () => dsh_cliworker_now_cliworker_accountStartForProvider_parameter_0$schema$value ??= string();
3402
+ let dsh_cliworker_now_cliworker_accountStartForProvider_parameter_1$schema$value;
3403
+ const dsh_cliworker_now_cliworker_accountStartForProvider_parameter_1$schema = () => dsh_cliworker_now_cliworker_accountStartForProvider_parameter_1$schema$value ??= string();
3404
+ let dsh_cliworker_now_cliworker_accountStartForProvider_parameter_2$schema$value;
3405
+ const dsh_cliworker_now_cliworker_accountStartForProvider_parameter_2$schema = () => dsh_cliworker_now_cliworker_accountStartForProvider_parameter_2$schema$value ??= string();
3406
+ let dsh_cliworker_now_cliworker_accountStartForProvider_parameter_3$schema$value;
3407
+ const dsh_cliworker_now_cliworker_accountStartForProvider_parameter_3$schema = () => dsh_cliworker_now_cliworker_accountStartForProvider_parameter_3$schema$value ??= string();
3408
+ let dsh_cliworker_now_cliworker_accountStartForProvider_result$schema$value;
3409
+ const dsh_cliworker_now_cliworker_accountStartForProvider_result$schema = () => dsh_cliworker_now_cliworker_accountStartForProvider_result$schema$value ??= string();
3400
3410
  let dsh_cliworker_now_cliworker_accountStartForSource_parameter_0$schema$value;
3401
3411
  const dsh_cliworker_now_cliworker_accountStartForSource_parameter_0$schema = () => dsh_cliworker_now_cliworker_accountStartForSource_parameter_0$schema$value ??= string();
3402
3412
  let dsh_cliworker_now_cliworker_accountStartForSource_parameter_1$schema$value;
@@ -3443,6 +3453,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
3443
3453
  const dsh_cliworker_now_cliworker_catalogForCli_parameter_1$schema = () => dsh_cliworker_now_cliworker_catalogForCli_parameter_1$schema$value ??= string();
3444
3454
  let dsh_cliworker_now_cliworker_catalogForCli_result$schema$value;
3445
3455
  const dsh_cliworker_now_cliworker_catalogForCli_result$schema = () => dsh_cliworker_now_cliworker_catalogForCli_result$schema$value ??= string();
3456
+ let dsh_cliworker_now_cliworker_cliExecutablePath_parameter_0$schema$value;
3457
+ const dsh_cliworker_now_cliworker_cliExecutablePath_parameter_0$schema = () => dsh_cliworker_now_cliworker_cliExecutablePath_parameter_0$schema$value ??= string();
3458
+ let dsh_cliworker_now_cliworker_cliExecutablePath_parameter_1$schema$value;
3459
+ const dsh_cliworker_now_cliworker_cliExecutablePath_parameter_1$schema = () => dsh_cliworker_now_cliworker_cliExecutablePath_parameter_1$schema$value ??= string();
3460
+ let dsh_cliworker_now_cliworker_cliExecutablePath_result$schema$value;
3461
+ const dsh_cliworker_now_cliworker_cliExecutablePath_result$schema = () => dsh_cliworker_now_cliworker_cliExecutablePath_result$schema$value ??= string();
3446
3462
  let dsh_cliworker_now_cliworker_cliSettings_parameter_0$schema$value;
3447
3463
  const dsh_cliworker_now_cliworker_cliSettings_parameter_0$schema = () => dsh_cliworker_now_cliworker_cliSettings_parameter_0$schema$value ??= string();
3448
3464
  let dsh_cliworker_now_cliworker_cliSettings_result$schema$value;
@@ -3491,6 +3507,22 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
3491
3507
  const dsh_cliworker_now_cliworker_history_parameter_3$schema = () => dsh_cliworker_now_cliworker_history_parameter_3$schema$value ??= string();
3492
3508
  let dsh_cliworker_now_cliworker_history_result$schema$value;
3493
3509
  const dsh_cliworker_now_cliworker_history_result$schema = () => dsh_cliworker_now_cliworker_history_result$schema$value ??= string();
3510
+ let dsh_cliworker_now_cliworker_refreshCatalogForCli_parameter_0$schema$value;
3511
+ const dsh_cliworker_now_cliworker_refreshCatalogForCli_parameter_0$schema = () => dsh_cliworker_now_cliworker_refreshCatalogForCli_parameter_0$schema$value ??= string();
3512
+ let dsh_cliworker_now_cliworker_refreshCatalogForCli_parameter_1$schema$value;
3513
+ const dsh_cliworker_now_cliworker_refreshCatalogForCli_parameter_1$schema = () => dsh_cliworker_now_cliworker_refreshCatalogForCli_parameter_1$schema$value ??= string();
3514
+ let dsh_cliworker_now_cliworker_refreshCatalogForCli_result$schema$value;
3515
+ const dsh_cliworker_now_cliworker_refreshCatalogForCli_result$schema = () => dsh_cliworker_now_cliworker_refreshCatalogForCli_result$schema$value ??= string();
3516
+ let dsh_cliworker_now_cliworker_refreshCliExecutablePath_parameter_0$schema$value;
3517
+ const dsh_cliworker_now_cliworker_refreshCliExecutablePath_parameter_0$schema = () => dsh_cliworker_now_cliworker_refreshCliExecutablePath_parameter_0$schema$value ??= string();
3518
+ let dsh_cliworker_now_cliworker_refreshCliExecutablePath_parameter_1$schema$value;
3519
+ const dsh_cliworker_now_cliworker_refreshCliExecutablePath_parameter_1$schema = () => dsh_cliworker_now_cliworker_refreshCliExecutablePath_parameter_1$schema$value ??= string();
3520
+ let dsh_cliworker_now_cliworker_refreshCliExecutablePath_parameter_2$schema$value;
3521
+ const dsh_cliworker_now_cliworker_refreshCliExecutablePath_parameter_2$schema = () => dsh_cliworker_now_cliworker_refreshCliExecutablePath_parameter_2$schema$value ??= string();
3522
+ let dsh_cliworker_now_cliworker_refreshCliExecutablePath_parameter_3$schema$value;
3523
+ const dsh_cliworker_now_cliworker_refreshCliExecutablePath_parameter_3$schema = () => dsh_cliworker_now_cliworker_refreshCliExecutablePath_parameter_3$schema$value ??= string();
3524
+ let dsh_cliworker_now_cliworker_refreshCliExecutablePath_result$schema$value;
3525
+ const dsh_cliworker_now_cliworker_refreshCliExecutablePath_result$schema = () => dsh_cliworker_now_cliworker_refreshCliExecutablePath_result$schema$value ??= string();
3494
3526
  let dsh_cliworker_now_cliworker_renameWorker_parameter_0$schema$value;
3495
3527
  const dsh_cliworker_now_cliworker_renameWorker_parameter_0$schema = () => dsh_cliworker_now_cliworker_renameWorker_parameter_0$schema$value ??= string();
3496
3528
  let dsh_cliworker_now_cliworker_renameWorker_parameter_1$schema$value;
@@ -3609,7 +3641,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
3609
3641
  },
3610
3642
  sourceLocation: {
3611
3643
  "file": "packages/cliworker/src/host/index.ts",
3612
- "line": 923,
3644
+ "line": 1035,
3613
3645
  "column": 9
3614
3646
  }
3615
3647
  },
@@ -3659,7 +3691,67 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
3659
3691
  },
3660
3692
  sourceLocation: {
3661
3693
  "file": "packages/cliworker/src/host/index.ts",
3662
- "line": 838,
3694
+ "line": 930,
3695
+ "column": 9
3696
+ }
3697
+ },
3698
+ {
3699
+ id: "dsh-cliworker-now#cliworker/accountStartForProvider",
3700
+ service: "cliworker",
3701
+ namespace: "cliworker",
3702
+ method: "accountStartForProvider",
3703
+ invocation: { kind: "direct" },
3704
+ parameters: [
3705
+ {
3706
+ name: "parentSessionId",
3707
+ wire: "parentSessionId",
3708
+ source: "json",
3709
+ codec: {
3710
+ mode: "strict",
3711
+ typeSymbol: "dsh-cliworker-now#cliworker/accountStartForProvider:parentSessionId",
3712
+ create: dsh_cliworker_now_cliworker_accountStartForProvider_parameter_0$schema
3713
+ }
3714
+ },
3715
+ {
3716
+ name: "cli",
3717
+ wire: "cli",
3718
+ source: "json",
3719
+ codec: {
3720
+ mode: "strict",
3721
+ typeSymbol: "dsh-cliworker-now#cliworker/accountStartForProvider:cli",
3722
+ create: dsh_cliworker_now_cliworker_accountStartForProvider_parameter_1$schema
3723
+ }
3724
+ },
3725
+ {
3726
+ name: "action",
3727
+ wire: "action",
3728
+ source: "json",
3729
+ codec: {
3730
+ mode: "strict",
3731
+ typeSymbol: "dsh-cliworker-now#cliworker/accountStartForProvider:action",
3732
+ create: dsh_cliworker_now_cliworker_accountStartForProvider_parameter_2$schema
3733
+ }
3734
+ },
3735
+ {
3736
+ name: "provider",
3737
+ wire: "provider",
3738
+ source: "json",
3739
+ codec: {
3740
+ mode: "strict",
3741
+ typeSymbol: "dsh-cliworker-now#cliworker/accountStartForProvider:provider",
3742
+ create: dsh_cliworker_now_cliworker_accountStartForProvider_parameter_3$schema
3743
+ }
3744
+ }
3745
+ ],
3746
+ cancellation: { parameter: "signal" },
3747
+ result: {
3748
+ mode: "strict",
3749
+ typeSymbol: "dsh-cliworker-now#cliworker/accountStartForProvider:result",
3750
+ create: dsh_cliworker_now_cliworker_accountStartForProvider_result$schema
3751
+ },
3752
+ sourceLocation: {
3753
+ "file": "packages/cliworker/src/host/index.ts",
3754
+ "line": 958,
3663
3755
  "column": 9
3664
3756
  }
3665
3757
  },
@@ -3719,7 +3811,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
3719
3811
  },
3720
3812
  sourceLocation: {
3721
3813
  "file": "packages/cliworker/src/host/index.ts",
3722
- "line": 849,
3814
+ "line": 941,
3723
3815
  "column": 9
3724
3816
  }
3725
3817
  },
@@ -3756,7 +3848,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
3756
3848
  },
3757
3849
  sourceLocation: {
3758
3850
  "file": "packages/cliworker/src/host/index.ts",
3759
- "line": 822,
3851
+ "line": 831,
3760
3852
  "column": 9
3761
3853
  }
3762
3854
  },
@@ -3792,7 +3884,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
3792
3884
  },
3793
3885
  sourceLocation: {
3794
3886
  "file": "packages/cliworker/src/host/index.ts",
3795
- "line": 939,
3887
+ "line": 1051,
3796
3888
  "column": 9
3797
3889
  }
3798
3890
  },
@@ -3830,7 +3922,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
3830
3922
  },
3831
3923
  sourceLocation: {
3832
3924
  "file": "packages/cliworker/src/host/index.ts",
3833
- "line": 897,
3925
+ "line": 1009,
3834
3926
  "column": 10
3835
3927
  }
3836
3928
  },
@@ -3879,7 +3971,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
3879
3971
  },
3880
3972
  sourceLocation: {
3881
3973
  "file": "packages/cliworker/src/host/index.ts",
3882
- "line": 912,
3974
+ "line": 1024,
3883
3975
  "column": 9
3884
3976
  }
3885
3977
  },
@@ -3907,7 +3999,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
3907
3999
  },
3908
4000
  sourceLocation: {
3909
4001
  "file": "packages/cliworker/src/host/index.ts",
3910
- "line": 949,
4002
+ "line": 1061,
3911
4003
  "column": 9
3912
4004
  }
3913
4005
  },
@@ -3944,7 +4036,44 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
3944
4036
  },
3945
4037
  sourceLocation: {
3946
4038
  "file": "packages/cliworker/src/host/index.ts",
3947
- "line": 954,
4039
+ "line": 1066,
4040
+ "column": 9
4041
+ }
4042
+ },
4043
+ {
4044
+ id: "dsh-cliworker-now#cliworker/cliExecutablePath",
4045
+ service: "cliworker",
4046
+ namespace: "cliworker",
4047
+ method: "cliExecutablePath",
4048
+ invocation: { kind: "direct" },
4049
+ parameters: [{
4050
+ name: "parentSessionId",
4051
+ wire: "parentSessionId",
4052
+ source: "json",
4053
+ codec: {
4054
+ mode: "strict",
4055
+ typeSymbol: "dsh-cliworker-now#cliworker/cliExecutablePath:parentSessionId",
4056
+ create: dsh_cliworker_now_cliworker_cliExecutablePath_parameter_0$schema
4057
+ }
4058
+ }, {
4059
+ name: "cli",
4060
+ wire: "cli",
4061
+ source: "json",
4062
+ codec: {
4063
+ mode: "strict",
4064
+ typeSymbol: "dsh-cliworker-now#cliworker/cliExecutablePath:cli",
4065
+ create: dsh_cliworker_now_cliworker_cliExecutablePath_parameter_1$schema
4066
+ }
4067
+ }],
4068
+ cancellation: { parameter: "signal" },
4069
+ result: {
4070
+ mode: "strict",
4071
+ typeSymbol: "dsh-cliworker-now#cliworker/cliExecutablePath:result",
4072
+ create: dsh_cliworker_now_cliworker_cliExecutablePath_result$schema
4073
+ },
4074
+ sourceLocation: {
4075
+ "file": "packages/cliworker/src/host/index.ts",
4076
+ "line": 880,
3948
4077
  "column": 9
3949
4078
  }
3950
4079
  },
@@ -3972,7 +4101,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
3972
4101
  },
3973
4102
  sourceLocation: {
3974
4103
  "file": "packages/cliworker/src/host/index.ts",
3975
- "line": 698,
4104
+ "line": 707,
3976
4105
  "column": 9
3977
4106
  }
3978
4107
  },
@@ -4009,7 +4138,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4009
4138
  },
4010
4139
  sourceLocation: {
4011
4140
  "file": "packages/cliworker/src/host/index.ts",
4012
- "line": 972,
4141
+ "line": 1105,
4013
4142
  "column": 9
4014
4143
  }
4015
4144
  },
@@ -4059,7 +4188,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4059
4188
  },
4060
4189
  sourceLocation: {
4061
4190
  "file": "packages/cliworker/src/host/index.ts",
4062
- "line": 999,
4191
+ "line": 1132,
4063
4192
  "column": 9
4064
4193
  }
4065
4194
  },
@@ -4096,7 +4225,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4096
4225
  },
4097
4226
  sourceLocation: {
4098
4227
  "file": "packages/cliworker/src/host/index.ts",
4099
- "line": 733,
4228
+ "line": 742,
4100
4229
  "column": 9
4101
4230
  }
4102
4231
  },
@@ -4133,7 +4262,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4133
4262
  },
4134
4263
  sourceLocation: {
4135
4264
  "file": "packages/cliworker/src/host/index.ts",
4136
- "line": 777,
4265
+ "line": 786,
4137
4266
  "column": 9
4138
4267
  }
4139
4268
  },
@@ -4183,7 +4312,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4183
4312
  },
4184
4313
  sourceLocation: {
4185
4314
  "file": "packages/cliworker/src/host/index.ts",
4186
- "line": 1033,
4315
+ "line": 1166,
4187
4316
  "column": 9
4188
4317
  }
4189
4318
  },
@@ -4242,7 +4371,104 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4242
4371
  },
4243
4372
  sourceLocation: {
4244
4373
  "file": "packages/cliworker/src/host/index.ts",
4245
- "line": 684,
4374
+ "line": 693,
4375
+ "column": 9
4376
+ }
4377
+ },
4378
+ {
4379
+ id: "dsh-cliworker-now#cliworker/refreshCatalogForCli",
4380
+ service: "cliworker",
4381
+ namespace: "cliworker",
4382
+ method: "refreshCatalogForCli",
4383
+ invocation: { kind: "direct" },
4384
+ parameters: [{
4385
+ name: "parentSessionId",
4386
+ wire: "parentSessionId",
4387
+ source: "json",
4388
+ codec: {
4389
+ mode: "strict",
4390
+ typeSymbol: "dsh-cliworker-now#cliworker/refreshCatalogForCli:parentSessionId",
4391
+ create: dsh_cliworker_now_cliworker_refreshCatalogForCli_parameter_0$schema
4392
+ }
4393
+ }, {
4394
+ name: "cli",
4395
+ wire: "cli",
4396
+ source: "json",
4397
+ codec: {
4398
+ mode: "strict",
4399
+ typeSymbol: "dsh-cliworker-now#cliworker/refreshCatalogForCli:cli",
4400
+ create: dsh_cliworker_now_cliworker_refreshCatalogForCli_parameter_1$schema
4401
+ }
4402
+ }],
4403
+ cancellation: { parameter: "signal" },
4404
+ result: {
4405
+ mode: "strict",
4406
+ typeSymbol: "dsh-cliworker-now#cliworker/refreshCatalogForCli:result",
4407
+ create: dsh_cliworker_now_cliworker_refreshCatalogForCli_result$schema
4408
+ },
4409
+ sourceLocation: {
4410
+ "file": "packages/cliworker/src/host/index.ts",
4411
+ "line": 1071,
4412
+ "column": 9
4413
+ }
4414
+ },
4415
+ {
4416
+ id: "dsh-cliworker-now#cliworker/refreshCliExecutablePath",
4417
+ service: "cliworker",
4418
+ namespace: "cliworker",
4419
+ method: "refreshCliExecutablePath",
4420
+ invocation: { kind: "direct" },
4421
+ parameters: [
4422
+ {
4423
+ name: "parentSessionId",
4424
+ wire: "parentSessionId",
4425
+ source: "json",
4426
+ codec: {
4427
+ mode: "strict",
4428
+ typeSymbol: "dsh-cliworker-now#cliworker/refreshCliExecutablePath:parentSessionId",
4429
+ create: dsh_cliworker_now_cliworker_refreshCliExecutablePath_parameter_0$schema
4430
+ }
4431
+ },
4432
+ {
4433
+ name: "cli",
4434
+ wire: "cli",
4435
+ source: "json",
4436
+ codec: {
4437
+ mode: "strict",
4438
+ typeSymbol: "dsh-cliworker-now#cliworker/refreshCliExecutablePath:cli",
4439
+ create: dsh_cliworker_now_cliworker_refreshCliExecutablePath_parameter_1$schema
4440
+ }
4441
+ },
4442
+ {
4443
+ name: "path",
4444
+ wire: "path",
4445
+ source: "json",
4446
+ codec: {
4447
+ mode: "strict",
4448
+ typeSymbol: "dsh-cliworker-now#cliworker/refreshCliExecutablePath:path",
4449
+ create: dsh_cliworker_now_cliworker_refreshCliExecutablePath_parameter_2$schema
4450
+ }
4451
+ },
4452
+ {
4453
+ name: "action",
4454
+ wire: "action",
4455
+ source: "json",
4456
+ codec: {
4457
+ mode: "strict",
4458
+ typeSymbol: "dsh-cliworker-now#cliworker/refreshCliExecutablePath:action",
4459
+ create: dsh_cliworker_now_cliworker_refreshCliExecutablePath_parameter_3$schema
4460
+ }
4461
+ }
4462
+ ],
4463
+ cancellation: { parameter: "signal" },
4464
+ result: {
4465
+ mode: "strict",
4466
+ typeSymbol: "dsh-cliworker-now#cliworker/refreshCliExecutablePath:result",
4467
+ create: dsh_cliworker_now_cliworker_refreshCliExecutablePath_result$schema
4468
+ },
4469
+ sourceLocation: {
4470
+ "file": "packages/cliworker/src/host/index.ts",
4471
+ "line": 901,
4246
4472
  "column": 9
4247
4473
  }
4248
4474
  },
@@ -4292,7 +4518,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4292
4518
  },
4293
4519
  sourceLocation: {
4294
4520
  "file": "packages/cliworker/src/host/index.ts",
4295
- "line": 745,
4521
+ "line": 754,
4296
4522
  "column": 9
4297
4523
  }
4298
4524
  },
@@ -4342,7 +4568,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4342
4568
  },
4343
4569
  sourceLocation: {
4344
4570
  "file": "packages/cliworker/src/host/index.ts",
4345
- "line": 761,
4571
+ "line": 770,
4346
4572
  "column": 9
4347
4573
  }
4348
4574
  },
@@ -4392,7 +4618,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4392
4618
  },
4393
4619
  sourceLocation: {
4394
4620
  "file": "packages/cliworker/src/host/index.ts",
4395
- "line": 1061,
4621
+ "line": 1194,
4396
4622
  "column": 9
4397
4623
  }
4398
4624
  },
@@ -4429,7 +4655,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4429
4655
  },
4430
4656
  sourceLocation: {
4431
4657
  "file": "packages/cliworker/src/host/index.ts",
4432
- "line": 788,
4658
+ "line": 797,
4433
4659
  "column": 9
4434
4660
  }
4435
4661
  },
@@ -4457,7 +4683,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4457
4683
  },
4458
4684
  sourceLocation: {
4459
4685
  "file": "packages/cliworker/src/host/index.ts",
4460
- "line": 709,
4686
+ "line": 718,
4461
4687
  "column": 9
4462
4688
  }
4463
4689
  },
@@ -4494,7 +4720,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4494
4720
  },
4495
4721
  sourceLocation: {
4496
4722
  "file": "packages/cliworker/src/host/index.ts",
4497
- "line": 720,
4723
+ "line": 729,
4498
4724
  "column": 9
4499
4725
  }
4500
4726
  },
@@ -4544,7 +4770,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4544
4770
  },
4545
4771
  sourceLocation: {
4546
4772
  "file": "packages/cliworker/src/host/index.ts",
4547
- "line": 799,
4773
+ "line": 808,
4548
4774
  "column": 9
4549
4775
  }
4550
4776
  },
@@ -4580,7 +4806,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4580
4806
  },
4581
4807
  sourceLocation: {
4582
4808
  "file": "packages/cliworker/src/host/index.ts",
4583
- "line": 1090,
4809
+ "line": 1223,
4584
4810
  "column": 9
4585
4811
  }
4586
4812
  },
@@ -4618,7 +4844,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
4618
4844
  },
4619
4845
  sourceLocation: {
4620
4846
  "file": "packages/cliworker/src/host/index.ts",
4621
- "line": 653,
4847
+ "line": 662,
4622
4848
  "column": 10
4623
4849
  }
4624
4850
  }
@@ -18670,9 +18896,302 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18670
18896
  var import_addon_fit = require_addon_fit();
18671
18897
  const accountTerminalCSS = "/**\n * Copyright (c) 2014 The xterm.js authors. All rights reserved.\n * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)\n * https://github.com/chjj/term.js\n * @license MIT\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n *\n * Originally forked from (with the author's permission):\n * Fabrice Bellard's javascript vt100 for jslinux:\n * http://bellard.org/jslinux/\n * Copyright (c) 2011 Fabrice Bellard\n * The original design remains. The terminal itself\n * has been extended to include xterm CSI codes, among\n * other features.\n */\n\n/**\n * Default styles for xterm.js\n */\n\n.xterm {\n cursor: text;\n position: relative;\n user-select: none;\n -ms-user-select: none;\n -webkit-user-select: none;\n}\n\n.xterm.focus,\n.xterm:focus {\n outline: none;\n}\n\n.xterm .xterm-helpers {\n position: absolute;\n top: 0;\n /**\n * The z-index of the helpers must be higher than the canvases in order for\n * IMEs to appear on top.\n */\n z-index: 5;\n}\n\n.xterm .xterm-helper-textarea {\n padding: 0;\n border: 0;\n margin: 0;\n /* Move textarea out of the screen to the far left, so that the cursor is not visible */\n position: absolute;\n opacity: 0;\n left: -9999em;\n top: 0;\n width: 0;\n height: 0;\n z-index: -5;\n /** Prevent wrapping so the IME appears against the textarea at the correct position */\n white-space: nowrap;\n overflow: hidden;\n resize: none;\n}\n\n.xterm .composition-view {\n /* TODO: Composition position got messed up somewhere */\n background: #000;\n color: #FFF;\n display: none;\n position: absolute;\n white-space: nowrap;\n z-index: 1;\n}\n\n.xterm .composition-view.active {\n display: block;\n}\n\n.xterm .xterm-viewport {\n /* On OS X this is required in order for the scroll bar to appear fully opaque */\n background-color: #000;\n overflow-y: scroll;\n cursor: default;\n position: absolute;\n right: 0;\n left: 0;\n top: 0;\n bottom: 0;\n}\n\n.xterm .xterm-screen {\n position: relative;\n}\n\n.xterm .xterm-screen canvas {\n position: absolute;\n left: 0;\n top: 0;\n}\n\n.xterm-char-measure-element {\n display: inline-block;\n visibility: hidden;\n position: absolute;\n top: 0;\n left: -9999em;\n line-height: normal;\n}\n\n.xterm.enable-mouse-events {\n /* When mouse events are enabled (eg. tmux), revert to the standard pointer cursor */\n cursor: default;\n}\n\n.xterm.xterm-cursor-pointer,\n.xterm .xterm-cursor-pointer {\n cursor: pointer;\n}\n\n.xterm.column-select.focus {\n /* Column selection mode */\n cursor: crosshair;\n}\n\n.xterm .xterm-accessibility:not(.debug),\n.xterm .xterm-message {\n position: absolute;\n left: 0;\n top: 0;\n bottom: 0;\n right: 0;\n z-index: 10;\n color: transparent;\n pointer-events: none;\n}\n\n.xterm .xterm-accessibility-tree:not(.debug) *::selection {\n color: transparent;\n}\n\n.xterm .xterm-accessibility-tree {\n font-family: monospace;\n user-select: text;\n white-space: pre;\n}\n\n.xterm .xterm-accessibility-tree > div {\n transform-origin: left;\n width: fit-content;\n}\n\n.xterm .live-region {\n position: absolute;\n left: -9999px;\n width: 1px;\n height: 1px;\n overflow: hidden;\n}\n\n.xterm-dim {\n /* Dim should not apply to background, so the opacity of the foreground color is applied\n * explicitly in the generated class and reset to 1 here */\n opacity: 1 !important;\n}\n\n.xterm-underline-1 { text-decoration: underline; }\n.xterm-underline-2 { text-decoration: double underline; }\n.xterm-underline-3 { text-decoration: wavy underline; }\n.xterm-underline-4 { text-decoration: dotted underline; }\n.xterm-underline-5 { text-decoration: dashed underline; }\n\n.xterm-overline {\n text-decoration: overline;\n}\n\n.xterm-overline.xterm-underline-1 { text-decoration: overline underline; }\n.xterm-overline.xterm-underline-2 { text-decoration: overline double underline; }\n.xterm-overline.xterm-underline-3 { text-decoration: overline wavy underline; }\n.xterm-overline.xterm-underline-4 { text-decoration: overline dotted underline; }\n.xterm-overline.xterm-underline-5 { text-decoration: overline dashed underline; }\n\n.xterm-strikethrough {\n text-decoration: line-through;\n}\n\n.xterm-screen .xterm-decoration-container .xterm-decoration {\n z-index: 6;\n position: absolute;\n}\n\n.xterm-screen .xterm-decoration-container .xterm-decoration.xterm-decoration-top-layer {\n z-index: 7;\n}\n\n.xterm-decoration-overview-ruler {\n z-index: 8;\n position: absolute;\n top: 0;\n right: 0;\n pointer-events: none;\n}\n\n.xterm-decoration-top {\n z-index: 2;\n position: relative;\n}\n\n\n\n/* Derived from vs/base/browser/ui/scrollbar/media/scrollbar.css */\n\n/* xterm.js customization: Override xterm's cursor style */\n.xterm .xterm-scrollable-element > .scrollbar {\n cursor: default;\n}\n\n/* Arrows */\n.xterm .xterm-scrollable-element > .scrollbar > .scra {\n cursor: pointer;\n font-size: 11px !important;\n}\n\n.xterm .xterm-scrollable-element > .visible {\n opacity: 1;\n\n /* Background rule added for IE9 - to allow clicks on dom node */\n background:rgba(0,0,0,0);\n\n transition: opacity 100ms linear;\n /* In front of peek view */\n z-index: 11;\n}\n.xterm .xterm-scrollable-element > .invisible {\n opacity: 0;\n pointer-events: none;\n}\n.xterm .xterm-scrollable-element > .invisible.fade {\n transition: opacity 800ms linear;\n}\n\n/* Scrollable Content Inset Shadow */\n.xterm .xterm-scrollable-element > .shadow {\n position: absolute;\n display: none;\n}\n.xterm .xterm-scrollable-element > .shadow.top {\n display: block;\n top: 0;\n left: 3px;\n height: 3px;\n width: 100%;\n box-shadow: var(--vscode-scrollbar-shadow, #000) 0 6px 6px -6px inset;\n}\n.xterm .xterm-scrollable-element > .shadow.left {\n display: block;\n top: 3px;\n left: 0;\n height: 100%;\n width: 3px;\n box-shadow: var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset;\n}\n.xterm .xterm-scrollable-element > .shadow.top-left-corner {\n display: block;\n top: 0;\n left: 0;\n height: 3px;\n width: 3px;\n}\n.xterm .xterm-scrollable-element > .shadow.top.left {\n box-shadow: var(--vscode-scrollbar-shadow, #000) 6px 0 6px -6px inset;\n}\n";
18672
18898
  //#endregion
18899
+ //#region lib/types/client/zcode-login-link.js
18900
+ const nativePrompt = "Open this URL to sign in:";
18901
+ const maxLineLength = 8192;
18902
+ const nativeEndpoints = {
18903
+ zai: {
18904
+ prefix: /^https:\/\/chat\.z\.ai(?::443)?\/api\/oauth\/authorize\?/,
18905
+ origin: "https://chat.z.ai",
18906
+ path: "/api/oauth/authorize",
18907
+ parameters: [
18908
+ "client_id",
18909
+ "redirect_uri",
18910
+ "state",
18911
+ "response_type"
18912
+ ]
18913
+ },
18914
+ bigmodel: {
18915
+ prefix: /^https:\/\/bigmodel\.cn(?::443)?\/login\?/,
18916
+ origin: "https://bigmodel.cn",
18917
+ path: "/login",
18918
+ parameters: [
18919
+ "appId",
18920
+ "redirect",
18921
+ "state"
18922
+ ]
18923
+ }
18924
+ };
18925
+ /** Validate only the observed native authorization endpoint; return the original bytes. */
18926
+ function nativeLoginUrl(line, provider) {
18927
+ const selected = provider === void 0 ? "zai" : provider;
18928
+ if (selected !== "zai" && selected !== "bigmodel") return void 0;
18929
+ const endpoint = nativeEndpoints[selected];
18930
+ if (line.length > maxLineLength || !endpoint.prefix.test(line) || /[\s\p{C}<>"'\\#]/u.test(line)) return void 0;
18931
+ try {
18932
+ const url = new URL(line);
18933
+ if (url.protocol !== "https:" || url.origin !== endpoint.origin || url.pathname !== endpoint.path || url.username || url.password || url.hash || url.port && url.port !== "443") return void 0;
18934
+ for (const parameter of endpoint.parameters) {
18935
+ const values = url.searchParams.getAll(parameter);
18936
+ if (values.length !== 1 || !values[0]?.trim()) return void 0;
18937
+ }
18938
+ return line;
18939
+ } catch {
18940
+ return;
18941
+ }
18942
+ }
18943
+ /**
18944
+ * The caller must enable this only for a ZCode login session and pass the selected
18945
+ * provider so one region cannot open the other region's URL. URLs stay in memory.
18946
+ * Accept a single complete line immediately after the fixed native --no-browser
18947
+ * prompt. SGR/cursor visibility do not affect text. The observed ConPTY blank
18948
+ * screen initialization is accepted only before any prompt/URL text; arbitrary
18949
+ * cursor edits do not become trusted text. OSC payloads are never stored.
18950
+ */
18951
+ function createZcodeLoginLinkParser(provider) {
18952
+ let mode = "text";
18953
+ let line = "";
18954
+ let invalidLine = false;
18955
+ let carriageReturn = false;
18956
+ let csiParameters = true;
18957
+ let csiLength = 0;
18958
+ let csiSequence = "";
18959
+ let oscCommand = "";
18960
+ let oscCommandComplete = false;
18961
+ let oscInitialization = false;
18962
+ let awaitingUrl = false;
18963
+ let previousUrl;
18964
+ const reset = () => {
18965
+ mode = "text";
18966
+ line = "";
18967
+ invalidLine = false;
18968
+ carriageReturn = false;
18969
+ csiParameters = true;
18970
+ csiLength = 0;
18971
+ csiSequence = "";
18972
+ oscCommand = "";
18973
+ oscCommandComplete = false;
18974
+ oscInitialization = false;
18975
+ awaitingUrl = false;
18976
+ previousUrl = void 0;
18977
+ };
18978
+ const finishLine = () => {
18979
+ const complete = invalidLine ? "" : line.trim();
18980
+ line = "";
18981
+ invalidLine = false;
18982
+ carriageReturn = false;
18983
+ if (complete === nativePrompt) {
18984
+ awaitingUrl = true;
18985
+ return;
18986
+ }
18987
+ const candidate = awaitingUrl ? nativeLoginUrl(complete, provider) : void 0;
18988
+ awaitingUrl = false;
18989
+ if (!candidate || candidate === previousUrl) return void 0;
18990
+ previousUrl = candidate;
18991
+ return candidate;
18992
+ };
18993
+ return {
18994
+ reset,
18995
+ write(chunk) {
18996
+ let result;
18997
+ for (const character of chunk) {
18998
+ if (mode === "osc" || mode === "osc-escape") {
18999
+ if (character === "\x07" || mode === "osc-escape" && character === "\\") {
19000
+ if (!oscInitialization || !oscCommandComplete || !["0", "2"].includes(oscCommand)) invalidLine = true;
19001
+ mode = "text";
19002
+ } else {
19003
+ if (!oscCommandComplete) if (character === ";") oscCommandComplete = true;
19004
+ else if (oscCommand.length < 2) oscCommand += character;
19005
+ else oscInitialization = false;
19006
+ mode = character === "\x1B" ? "osc-escape" : "osc";
19007
+ }
19008
+ continue;
19009
+ }
19010
+ if (mode === "escape") {
19011
+ if (character === "[") {
19012
+ mode = "csi";
19013
+ csiParameters = true;
19014
+ csiLength = 0;
19015
+ csiSequence = "";
19016
+ continue;
19017
+ }
19018
+ if (character === "]") {
19019
+ oscInitialization = !line && !awaitingUrl && !invalidLine;
19020
+ oscCommand = "";
19021
+ oscCommandComplete = false;
19022
+ mode = "osc";
19023
+ } else {
19024
+ invalidLine = true;
19025
+ mode = "text";
19026
+ }
19027
+ if (character !== "\n") continue;
19028
+ } else if (mode === "csi") {
19029
+ csiLength++;
19030
+ if (character >= "@" && character <= "~") {
19031
+ const sequence = csiSequence + character;
19032
+ const decoration = character === "m" && csiParameters;
19033
+ const visibility = /^\?25[hl]$/.test(sequence);
19034
+ const initialization = !line && !awaitingUrl && !invalidLine && /^(?:2J|0?K|(?:1;1)?H)$/.test(sequence);
19035
+ if (csiLength > 64 || !decoration && !visibility && !initialization) invalidLine = true;
19036
+ mode = "text";
19037
+ continue;
19038
+ }
19039
+ csiParameters &&= /^[0-9;:]$/.test(character);
19040
+ if (csiLength <= 64) csiSequence += character;
19041
+ if (character !== "\n") continue;
19042
+ invalidLine = true;
19043
+ mode = "text";
19044
+ }
19045
+ if (character === "\n") {
19046
+ const found = finishLine();
19047
+ if (found) result = found;
19048
+ continue;
19049
+ }
19050
+ if (carriageReturn) invalidLine = true;
19051
+ carriageReturn = character === "\r";
19052
+ if (carriageReturn) continue;
19053
+ if (character === "\x1B") {
19054
+ mode = "escape";
19055
+ continue;
19056
+ }
19057
+ if (/[\p{C}]/u.test(character)) invalidLine = true;
19058
+ if (line.length + character.length > maxLineLength) invalidLine = true;
19059
+ if (!invalidLine) line += character;
19060
+ }
19061
+ return result;
19062
+ }
19063
+ };
19064
+ }
19065
+ //#endregion
19066
+ //#region lib/types/client/zcode-login-link-provider.js
19067
+ const maxUrlLength = 8192;
19068
+ const maxCells = 16384;
19069
+ const maxWrappedLines = 512;
19070
+ /** Resolve only a complete displayed copy of an already approved native URL. */
19071
+ function displayedUrlRange(terminal, bufferLineNumber, url) {
19072
+ if (!url || url.length > maxUrlLength || !Number.isInteger(bufferLineNumber)) return void 0;
19073
+ const buffer = terminal.buffer.active;
19074
+ const index = bufferLineNumber - 1;
19075
+ if (index < 0 || index >= buffer.length || terminal.cols < 1) return void 0;
19076
+ let first = index;
19077
+ while (buffer.getLine(first)?.isWrapped) {
19078
+ if (first === 0 || index - first >= maxWrappedLines) return void 0;
19079
+ first--;
19080
+ }
19081
+ let text = "";
19082
+ let cellCount = 0;
19083
+ const positions = [];
19084
+ for (let row = first; row < buffer.length; row++) {
19085
+ if (row - first >= maxWrappedLines) return void 0;
19086
+ const line = buffer.getLine(row);
19087
+ if (!line) return void 0;
19088
+ if (row !== first && !line.isWrapped) break;
19089
+ const columns = Math.min(terminal.cols, line.length);
19090
+ if (!Number.isInteger(columns) || columns < 0 || cellCount + columns > maxCells) return void 0;
19091
+ cellCount += columns;
19092
+ for (let column = 0; column < columns; column++) {
19093
+ const cell = line.getCell(column);
19094
+ if (!cell) return void 0;
19095
+ const width = cell.getWidth();
19096
+ if (width === 0) continue;
19097
+ if (width !== 1 && width !== 2) return void 0;
19098
+ const chars = cell.getChars() || " ";
19099
+ if (text.length + chars.length > maxCells) return void 0;
19100
+ const position = {
19101
+ start: {
19102
+ x: column + 1,
19103
+ y: row + 1
19104
+ },
19105
+ end: {
19106
+ x: column + width,
19107
+ y: row + 1
19108
+ }
19109
+ };
19110
+ for (let character = 0; character < chars.length; character++) positions.push(position);
19111
+ text += chars;
19112
+ }
19113
+ }
19114
+ if (text.trim() !== url) return void 0;
19115
+ const offset = text.length - text.trimStart().length;
19116
+ const start = positions[offset]?.start;
19117
+ const end = positions[offset + url.length - 1]?.end;
19118
+ if (!start || !end || bufferLineNumber < start.y || bufferLineNumber > end.y) return void 0;
19119
+ return {
19120
+ start,
19121
+ end
19122
+ };
19123
+ }
19124
+ /**
19125
+ * The caller supplies only the active ZCode login parser's approved URL and
19126
+ * disposes its registerLinkProvider handle on close. No URL discovery, browser
19127
+ * opening, output logging, or persistence happens while links are requested.
19128
+ */
19129
+ function createZcodeLoginLinkProvider(terminal, currentUrl, open) {
19130
+ return { provideLinks(bufferLineNumber, callback) {
19131
+ const url = currentUrl();
19132
+ const range = url ? displayedUrlRange(terminal, bufferLineNumber, url) : void 0;
19133
+ if (!url || !range) {
19134
+ callback(void 0);
19135
+ return;
19136
+ }
19137
+ let disposed = false;
19138
+ callback([{
19139
+ range,
19140
+ text: url,
19141
+ activate() {
19142
+ if (disposed || currentUrl() !== url) return;
19143
+ const current = displayedUrlRange(terminal, bufferLineNumber, url);
19144
+ if (!current || current.start.x !== range.start.x || current.start.y !== range.start.y || current.end.x !== range.end.x || current.end.y !== range.end.y) return;
19145
+ open(url);
19146
+ },
19147
+ dispose() {
19148
+ disposed = true;
19149
+ }
19150
+ }]);
19151
+ } };
19152
+ }
19153
+ //#endregion
18673
19154
  //#region lib/types/client/account-terminal.js
18674
19155
  const STARTUP_TIMEOUT_MS = 2e4;
18675
19156
  const CLEANUP_TIMEOUT_MS = 12e3;
19157
+ const MAX_INPUT_BYTES = 16384;
19158
+ function isPasteShortcut(event) {
19159
+ if (event.altKey || event.isComposing) return false;
19160
+ return (event.key.toLowerCase() === "v" || event.code === "KeyV") && event.ctrlKey !== event.metaKey || event.key === "Insert" && event.shiftKey && !event.ctrlKey && !event.metaKey;
19161
+ }
19162
+ function isCopyShortcut(event) {
19163
+ return !event.altKey && !event.isComposing && (event.key.toLowerCase() === "c" || event.code === "KeyC") && event.ctrlKey !== event.metaKey;
19164
+ }
19165
+ function startupMessage(error) {
19166
+ const message = error instanceof Error ? error.message : "";
19167
+ return [
19168
+ "此 CLI 已有账号终端,请先关闭后重试",
19169
+ "当前宿主不支持交互终端",
19170
+ "账号终端尚未确认完全退出,请重启应用",
19171
+ "Windows 账号终端托管不可用,请检查 PowerShell 后重试",
19172
+ "账号终端启动超时,正在回收启动过程;请稍后重试",
19173
+ "无法启动账号终端,请检查 CLI 安装",
19174
+ "CLI 启动入口无法确认,请配置原生程序或固定 Node/Bun 入口",
19175
+ "无法确认 ZCode 账号功能,请检查完整 CLI 安装后重试",
19176
+ "当前 ZCode 未声明原生登录能力,请检查 CLI 安装",
19177
+ "当前 ZCode 未声明原生终端界面,请检查 CLI 安装",
19178
+ "当前 ZCode 未声明原生退出登录能力,请检查 CLI 安装",
19179
+ "ZCode 配套资源不可用,请检查 CLI 安装或配置 zcodeBuiltinConfig",
19180
+ "当前插件 Host 不支持 ZCode 授权来源选择,请更新插件后重试",
19181
+ "不支持的 ZCode 授权来源",
19182
+ "授权来源只支持 ZCode 登录时选择智谱 BigModel 或 Z.AI",
19183
+ "当前 ZCode CLI 不支持智谱 BigModel 授权,请更新为支持 login bigmodel 的官方完整 CLI 后重试;不会改用 Z.AI 登录。",
19184
+ "OMP 执行入口身份不匹配,请检查该 CLI 的安装和路径",
19185
+ "Pi 执行入口身份不匹配,请检查该 CLI 的安装和路径",
19186
+ "Codex Windows 应用包入口无法确认,请检查安装",
19187
+ "Codex npm 安装入口无法确认,请检查安装",
19188
+ "Hermes Windows 安装入口无法确认,请检查安装",
19189
+ "检测到 Hermes 安装目录,但未找到可用 CLI 入口,请完成安装或配置已有入口",
19190
+ "Windows CLI 安装入口无法读取,请检查安装",
19191
+ "Windows CLI 安装目录配置无效",
19192
+ "Windows 系统目录配置无效"
19193
+ ].find((item) => message === item || message === `Error: ${item}`) ?? "账号终端暂不可用,请确认此 CLI 没有运行任务且当前项目允许执行,再重试";
19194
+ }
18676
19195
  async function waitForCleanup(cleanup) {
18677
19196
  let timer;
18678
19197
  try {
@@ -18684,7 +19203,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18684
19203
  }
18685
19204
  }
18686
19205
  /** Only mounted after a human selects an account action. No prompt is auto-entered. */
18687
- function AccountTerminal({ api, sessionId, cli, action, source, onClose, onFinished }) {
19206
+ function AccountTerminal({ api, sessionId, cli, action, source, provider, onClose, onFinished, closeControl }) {
18688
19207
  const element = (0, react.useRef)(null);
18689
19208
  const callbacks = (0, react.useRef)({
18690
19209
  onClose,
@@ -18695,7 +19214,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18695
19214
  onFinished
18696
19215
  };
18697
19216
  const stop = (0, react.useRef)(async () => {});
19217
+ const focus = (0, react.useRef)(() => {});
19218
+ const contextClipboard = (0, react.useRef)(async () => {});
18698
19219
  const generation = (0, react.useRef)(0);
19220
+ const closing = (0, react.useRef)();
18699
19221
  const [attempt, setAttempt] = (0, react.useState)(0);
18700
19222
  const [phase, setPhase] = (0, react.useState)("loading");
18701
19223
  const [instruction, setInstruction] = (0, react.useState)("");
@@ -18705,7 +19227,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18705
19227
  setPhase("loading");
18706
19228
  setInstruction("");
18707
19229
  setNotice("");
18708
- let alive = true, id = "", ended = false, lastSeq = 0, queuedBytes = 0, resizeFrame = 0, viewDisposed = false;
19230
+ let alive = true, id = "", ended = false, cleanupConfirmed = false, lastSeq = 0, queuedBytes = 0, resizeFrame = 0, viewDisposed = false;
18709
19231
  const startup = new AbortController();
18710
19232
  let startupTimer;
18711
19233
  let stream;
@@ -18714,6 +19236,17 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18714
19236
  let observer;
18715
19237
  let themeObserver;
18716
19238
  let input;
19239
+ let loginLinks;
19240
+ let removePasteListener;
19241
+ let readingClipboard = false;
19242
+ const loginLinkParser = cli === "zcode" && action === "login" ? createZcodeLoginLinkParser(provider) : void 0;
19243
+ let loginUrl;
19244
+ const openedLoginUrls = /* @__PURE__ */ new Set();
19245
+ const clearLoginLink = () => {
19246
+ loginUrl = void 0;
19247
+ loginLinkParser?.reset();
19248
+ openedLoginUrls.clear();
19249
+ };
18717
19250
  let inputQueue = Promise.resolve();
18718
19251
  let stopping;
18719
19252
  const disposeStream = () => {
@@ -18726,6 +19259,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18726
19259
  };
18727
19260
  const finish = (failed = false) => {
18728
19261
  disableInput();
19262
+ clearLoginLink();
18729
19263
  if (alive) setPhase(failed ? "failed" : "closed");
18730
19264
  if (!ended) {
18731
19265
  ended = true;
@@ -18736,7 +19270,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18736
19270
  clearTimeout(startupTimer);
18737
19271
  startup.abort();
18738
19272
  disableInput();
18739
- if (!id) return Promise.resolve();
19273
+ clearLoginLink();
19274
+ if (!id || cleanupConfirmed) return Promise.resolve();
18740
19275
  return stopping ??= (async () => {
18741
19276
  value(await api.cliworker.accountStop(sessionId, id));
18742
19277
  if (!ended) finish();
@@ -18765,6 +19300,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18765
19300
  () => themeObserver?.disconnect(),
18766
19301
  () => cancelAnimationFrame(resizeFrame),
18767
19302
  () => input?.dispose(),
19303
+ () => loginLinks?.dispose(),
19304
+ () => removePasteListener?.(),
18768
19305
  () => terminal?.dispose()
18769
19306
  ]) try {
18770
19307
  dispose();
@@ -18776,15 +19313,97 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18776
19313
  fontSize: 12,
18777
19314
  fontFamily: "ui-monospace, SFMono-Regular, Menlo, monospace",
18778
19315
  cursorBlink: true,
19316
+ cursorStyle: "block",
19317
+ cursorInactiveStyle: "outline",
18779
19318
  scrollback: 1e3,
18780
19319
  disableStdin: true,
18781
19320
  linkHandler: { activate: () => {} },
18782
19321
  allowProposedApi: false
18783
19322
  });
18784
19323
  const view = terminal;
19324
+ focus.current = () => {
19325
+ if (alive && !ended && !startup.signal.aborted) view.focus();
19326
+ };
18785
19327
  const fit = new import_addon_fit.FitAddon();
18786
19328
  view.loadAddon(fit);
18787
19329
  view.open(element.current);
19330
+ const canWrite = () => alive && !!id && !ended && !startup.signal.aborted && !viewDisposed;
19331
+ const canCopy = () => alive && !viewDisposed && !startup.signal.aborted;
19332
+ const openLoginUrl = (url) => {
19333
+ if (!canWrite() || url !== loginUrl) return;
19334
+ try {
19335
+ window.open(url, "_blank", "noopener,noreferrer");
19336
+ } catch {
19337
+ setNotice("无法打开登录网页,请在终端中查看原生登录提示");
19338
+ }
19339
+ };
19340
+ if (loginLinkParser) loginLinks = view.registerLinkProvider(createZcodeLoginLinkProvider(view, () => canWrite() ? loginUrl : void 0, openLoginUrl));
19341
+ const pasteText = (text) => {
19342
+ if (!canWrite()) return;
19343
+ if (!text) {
19344
+ setNotice("剪贴板中没有可粘贴的文本");
19345
+ return;
19346
+ }
19347
+ setNotice("");
19348
+ view.focus();
19349
+ view.paste(text);
19350
+ };
19351
+ contextClipboard.current = async () => {
19352
+ if (!canCopy() || readingClipboard) return;
19353
+ if (view.hasSelection()) {
19354
+ const text = view.getSelection();
19355
+ if (!text) return;
19356
+ readingClipboard = true;
19357
+ try {
19358
+ const copied = await (0, _deepseek_ai_dsh_client_ui_primitives.writeClipboard)(text);
19359
+ if (!canCopy()) return;
19360
+ if (!copied) setNotice("复制失败,请重新选择文本后重试");
19361
+ else {
19362
+ setNotice("");
19363
+ view.clearSelection();
19364
+ view.focus();
19365
+ }
19366
+ } catch {
19367
+ if (canCopy()) setNotice("复制失败,请重新选择文本后重试");
19368
+ } finally {
19369
+ readingClipboard = false;
19370
+ }
19371
+ return;
19372
+ }
19373
+ if (!canWrite()) return;
19374
+ readingClipboard = true;
19375
+ try {
19376
+ if (!navigator.clipboard?.readText) throw new Error("clipboard unavailable");
19377
+ const text = await navigator.clipboard.readText();
19378
+ pasteText(text);
19379
+ } catch {
19380
+ if (canWrite()) setNotice("无法读取剪贴板,请聚焦终端后按 Ctrl+V(Mac 为 ⌘V)粘贴");
19381
+ } finally {
19382
+ readingClipboard = false;
19383
+ }
19384
+ };
19385
+ view.attachCustomKeyEventHandler((event) => {
19386
+ if (isCopyShortcut(event) && view.hasSelection()) {
19387
+ event.stopPropagation();
19388
+ return false;
19389
+ }
19390
+ if (!isPasteShortcut(event)) return true;
19391
+ event.stopPropagation();
19392
+ return false;
19393
+ });
19394
+ const container = element.current;
19395
+ const onPaste = (event) => {
19396
+ event.preventDefault();
19397
+ event.stopPropagation();
19398
+ if (!canWrite()) return;
19399
+ if (!event.clipboardData) {
19400
+ setNotice("无法读取粘贴内容,请右键重试");
19401
+ return;
19402
+ }
19403
+ pasteText(event.clipboardData.getData("text/plain"));
19404
+ };
19405
+ container.addEventListener("paste", onPaste, { capture: true });
19406
+ removePasteListener = () => container.removeEventListener("paste", onPaste, { capture: true });
18788
19407
  const theme = () => {
18789
19408
  if (!alive || viewDisposed) return;
18790
19409
  try {
@@ -18792,7 +19411,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18792
19411
  view.options.theme = {
18793
19412
  background: css.getPropertyValue("--dsw-alias-bg-layer-2").trim() || "#ffffff",
18794
19413
  foreground: css.getPropertyValue("--dsw-alias-label-primary").trim() || "#222222",
18795
- cursor: css.getPropertyValue("--dsw-alias-label-primary").trim() || "#222222"
19414
+ cursor: css.getPropertyValue("--dsw-alias-label-primary").trim() || "#222222",
19415
+ cursorAccent: css.getPropertyValue("--dsw-alias-bg-layer-2").trim() || "#ffffff"
18796
19416
  };
18797
19417
  } catch {
18798
19418
  fail("账号终端显示未能初始化,请重试");
@@ -18825,14 +19445,19 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18825
19445
  observer.observe(element.current);
18826
19446
  resize();
18827
19447
  input = view.onData((data) => {
18828
- if (!alive || !id || ended || startup.signal.aborted || queuedBytes + data.length > 16384) return;
18829
- queuedBytes += data.length;
19448
+ if (!canWrite()) return;
19449
+ const bytes = new TextEncoder().encode(data).byteLength;
19450
+ if (queuedBytes + bytes > MAX_INPUT_BYTES) {
19451
+ setNotice("输入过长或仍在发送,请缩短内容后重试");
19452
+ return;
19453
+ }
19454
+ queuedBytes += bytes;
18830
19455
  inputQueue = inputQueue.then(async () => {
18831
19456
  if (alive && !ended && !startup.signal.aborted) value(await api.cliworker.accountWrite(sessionId, id, data));
18832
19457
  }).catch(() => {
18833
19458
  if (alive) setNotice("输入未能送达,请关闭终端后重试");
18834
19459
  }).finally(() => {
18835
- queuedBytes -= data.length;
19460
+ queuedBytes -= bytes;
18836
19461
  });
18837
19462
  });
18838
19463
  startupTimer = setTimeout(() => {
@@ -18840,7 +19465,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18840
19465
  }, STARTUP_TIMEOUT_MS);
18841
19466
  (async () => {
18842
19467
  try {
18843
- const result = JSON.parse(value(await (source ? api.cliworker.accountStartForSource(sessionId, cli, action, source, startup.signal) : api.cliworker.accountStart(sessionId, cli, action, startup.signal))));
19468
+ if (provider && typeof api.cliworker.accountStartForProvider !== "function") throw new Error("当前插件 Host 不支持 ZCode 授权来源选择,请更新插件后重试");
19469
+ const result = JSON.parse(value(await (provider ? api.cliworker.accountStartForProvider(sessionId, cli, action, provider, startup.signal) : source ? api.cliworker.accountStartForSource(sessionId, cli, action, source, startup.signal) : api.cliworker.accountStart(sessionId, cli, action, startup.signal))));
18844
19470
  clearTimeout(startupTimer);
18845
19471
  id = result.id;
18846
19472
  if (!alive || startup.signal.aborted) {
@@ -18862,11 +19488,22 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18862
19488
  const frame = JSON.parse(item.value);
18863
19489
  if (alive && !ended && frame.seq > lastSeq) {
18864
19490
  lastSeq = frame.seq;
18865
- if (frame.data) view.write(frame.data);
19491
+ if (frame.data) {
19492
+ view.write(frame.data);
19493
+ const link = canWrite() ? loginLinkParser?.write(frame.data) : void 0;
19494
+ if (link) {
19495
+ loginUrl = link;
19496
+ if (!openedLoginUrls.has(link)) {
19497
+ openedLoginUrls.add(link);
19498
+ openLoginUrl(link);
19499
+ }
19500
+ }
19501
+ }
18866
19502
  if (frame.message) setNotice(frame.message);
18867
19503
  }
18868
19504
  item.accept();
18869
19505
  if (frame.status === "closed" || frame.status === "failed") {
19506
+ cleanupConfirmed = frame.cleanupConfirmed === true;
18870
19507
  if (!ended) finish(frame.status === "failed");
18871
19508
  break;
18872
19509
  }
@@ -18876,10 +19513,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18876
19513
  finish(true);
18877
19514
  stopSession().catch(() => void 0);
18878
19515
  }
18879
- } catch {
19516
+ } catch (error) {
18880
19517
  clearTimeout(startupTimer);
18881
19518
  if (alive && !startup.signal.aborted) {
18882
- setNotice("账号终端暂不可用,请确认此 CLI 没有运行任务且当前项目允许执行,再重试");
19519
+ setNotice(startupMessage(error));
18883
19520
  finish(true);
18884
19521
  }
18885
19522
  if (id) stopSession().catch(() => void 0);
@@ -18890,9 +19527,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18890
19527
  } catch {
18891
19528
  fail("账号终端显示未能初始化,请重试");
18892
19529
  disposeView();
19530
+ focus.current = () => {};
19531
+ contextClipboard.current = async () => {};
18893
19532
  }
18894
19533
  return () => {
18895
19534
  alive = false;
19535
+ clearLoginLink();
18896
19536
  if (generation.current === ownGeneration) generation.current++;
18897
19537
  clearTimeout(startupTimer);
18898
19538
  startup.abort();
@@ -18906,27 +19546,47 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18906
19546
  cli,
18907
19547
  action,
18908
19548
  source,
19549
+ provider,
18909
19550
  attempt
18910
19551
  ]);
18911
- const close = async (retry = false) => {
19552
+ const close = (retry = false) => {
19553
+ if (closing.current) return closing.current;
18912
19554
  const ownGeneration = generation.current;
18913
19555
  setPhase("stopping");
18914
- try {
18915
- await waitForCleanup(stop.current());
18916
- if (generation.current !== ownGeneration) return;
18917
- if (retry) setAttempt((value) => value + 1);
18918
- else callbacks.current.onClose();
18919
- } catch {
18920
- if (generation.current !== ownGeneration) return;
18921
- setPhase("failed");
18922
- setNotice("终端关闭失败,请重试");
18923
- }
19556
+ const operation = (async () => {
19557
+ try {
19558
+ await waitForCleanup(stop.current());
19559
+ if (generation.current !== ownGeneration) return false;
19560
+ if (retry) setAttempt((value) => value + 1);
19561
+ else callbacks.current.onClose();
19562
+ return true;
19563
+ } catch {
19564
+ if (generation.current !== ownGeneration) return false;
19565
+ setPhase("failed");
19566
+ setNotice("终端关闭失败,请重试");
19567
+ return false;
19568
+ }
19569
+ })();
19570
+ closing.current = operation;
19571
+ operation.finally(() => {
19572
+ if (closing.current === operation) closing.current = void 0;
19573
+ });
19574
+ return operation;
18924
19575
  };
19576
+ (0, react.useEffect)(() => {
19577
+ if (!closeControl) return;
19578
+ const request = () => close();
19579
+ closeControl.current = request;
19580
+ return () => {
19581
+ if (closeControl.current === request) closeControl.current = void 0;
19582
+ };
19583
+ });
18925
19584
  return (0, react_jsx_runtime.jsxs)("section", {
18926
19585
  className: "cwn-account-terminal",
18927
19586
  "data-cli": cli,
18928
19587
  children: [
18929
19588
  (0, react_jsx_runtime.jsx)("style", { children: accountTerminalCSS }),
19589
+ (0, react_jsx_runtime.jsx)("style", { children: `.cwn-account-terminal-view:focus-within { outline: none; }` }),
18930
19590
  (0, react_jsx_runtime.jsxs)("div", {
18931
19591
  className: "cwn-account-terminal-head",
18932
19592
  children: [(0, react_jsx_runtime.jsxs)("strong", { children: [CLI_LABELS[cli], " 账号终端"] }), (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
@@ -18952,7 +19612,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
18952
19612
  (0, react_jsx_runtime.jsx)("div", {
18953
19613
  className: "cwn-account-terminal-view",
18954
19614
  ref: element,
18955
- "aria-label": `${CLI_LABELS[cli]} 原生账号终端`
19615
+ "aria-label": `${CLI_LABELS[cli]} 原生账号终端`,
19616
+ onClick: () => focus.current(),
19617
+ onContextMenuCapture: (event) => {
19618
+ event.preventDefault();
19619
+ event.stopPropagation();
19620
+ contextClipboard.current();
19621
+ }
18956
19622
  }),
18957
19623
  (phase === "failed" || phase === "closed") && (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
18958
19624
  variant: "ghost",
@@ -19251,6 +19917,273 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19251
19917
  });
19252
19918
  }
19253
19919
  //#endregion
19920
+ //#region lib/types/client/account-query-queue.js
19921
+ /** Bounds dialog requests. Host owns process cleanup, including after RPC cancellation. */
19922
+ var AccountQueryQueue = class {
19923
+ limit;
19924
+ waiting = /* @__PURE__ */ new Map();
19925
+ running = /* @__PURE__ */ new Map();
19926
+ priority;
19927
+ constructor(limit = 2) {
19928
+ this.limit = limit;
19929
+ }
19930
+ has(key) {
19931
+ const current = this.running.get(key);
19932
+ return this.waiting.has(key) || !!(current && !current.controller.signal.aborted);
19933
+ }
19934
+ enqueue(key, query, replace = false) {
19935
+ if (this.has(key) && !replace) return false;
19936
+ if (replace) this.running.get(key)?.controller.abort();
19937
+ this.waiting.set(key, query);
19938
+ this.drain();
19939
+ return true;
19940
+ }
19941
+ prioritize(key) {
19942
+ this.priority = key;
19943
+ this.drain();
19944
+ }
19945
+ cancel(key) {
19946
+ this.waiting.delete(key);
19947
+ this.running.get(key)?.controller.abort();
19948
+ }
19949
+ clear() {
19950
+ this.waiting.clear();
19951
+ for (const current of this.running.values()) current.controller.abort();
19952
+ }
19953
+ drain() {
19954
+ while (this.running.size < this.limit) {
19955
+ const key = this.priority !== void 0 && this.waiting.has(this.priority) && !this.running.has(this.priority) ? this.priority : [...this.waiting.keys()].find((candidate) => !this.running.has(candidate));
19956
+ if (key === void 0) return;
19957
+ const query = this.waiting.get(key);
19958
+ this.waiting.delete(key);
19959
+ const current = {
19960
+ query,
19961
+ controller: new AbortController()
19962
+ };
19963
+ this.running.set(key, current);
19964
+ Promise.resolve().then(() => current.controller.signal.aborted ? void 0 : query(current.controller.signal)).catch(() => void 0).finally(() => {
19965
+ if (this.running.get(key) === current) this.running.delete(key);
19966
+ this.drain();
19967
+ });
19968
+ }
19969
+ }
19970
+ };
19971
+ //#endregion
19972
+ //#region lib/types/client/cli-executable-settings.js
19973
+ function readPath(raw, cli) {
19974
+ const next = JSON.parse(raw);
19975
+ if (next?.cli !== cli || typeof next.path !== "string" || typeof next.available !== "boolean" || ![
19976
+ "auto",
19977
+ "manual",
19978
+ "configured",
19979
+ "none"
19980
+ ].includes(next.source) || next.error !== void 0 && typeof next.error !== "string") throw new Error("收到不匹配的 CLI 路径信息,请刷新重试");
19981
+ return next;
19982
+ }
19983
+ /** Path management remains usable for a disabled CLI and never saves model defaults. */
19984
+ function CliExecutableSettings({ api, sessionId, cli, blocked, accountLoading, accountRevision, onApplied, onBusyChange }) {
19985
+ const [expanded, setExpanded] = (0, react.useState)(false);
19986
+ const [hasExpanded, setHasExpanded] = (0, react.useState)(false);
19987
+ const [draft, setDraft] = (0, react.useState)("");
19988
+ const [loading, setLoading] = (0, react.useState)(false);
19989
+ const [saving, setSaving] = (0, react.useState)(false);
19990
+ const [error, setError] = (0, react.useState)("");
19991
+ const [feedback, setFeedback] = (0, react.useState)("");
19992
+ const contentId = (0, react.useId)();
19993
+ const inputId = (0, react.useId)();
19994
+ const hintId = (0, react.useId)();
19995
+ const draftRef = (0, react.useRef)(draft);
19996
+ const baseline = (0, react.useRef)("");
19997
+ const revision = (0, react.useRef)(0);
19998
+ const request = (0, react.useRef)();
19999
+ const callbacks = (0, react.useRef)({
20000
+ onApplied,
20001
+ onBusyChange
20002
+ });
20003
+ callbacks.current = {
20004
+ onApplied,
20005
+ onBusyChange
20006
+ };
20007
+ const service = api.cliworker;
20008
+ (0, react.useEffect)(() => () => {
20009
+ request.current?.controller.abort();
20010
+ request.current = void 0;
20011
+ }, []);
20012
+ (0, react.useEffect)(() => {
20013
+ if (request.current?.kind === "write") return;
20014
+ request.current?.controller.abort();
20015
+ request.current = void 0;
20016
+ setLoading(false);
20017
+ if (!expanded || blocked || accountLoading) return;
20018
+ const controller = new AbortController();
20019
+ const editRevision = revision.current;
20020
+ const dirty = draftRef.current.trim() !== baseline.current;
20021
+ request.current = {
20022
+ controller,
20023
+ kind: "read"
20024
+ };
20025
+ setLoading(true);
20026
+ (async () => {
20027
+ try {
20028
+ const next = readPath(value(await service.cliExecutablePath(sessionId, cli, controller.signal)), cli);
20029
+ if (controller.signal.aborted || revision.current !== editRevision) return;
20030
+ baseline.current = next.path;
20031
+ if (!dirty) {
20032
+ draftRef.current = next.path;
20033
+ setDraft(next.path);
20034
+ setError(next.error || "");
20035
+ }
20036
+ } catch (error) {
20037
+ if (!controller.signal.aborted && revision.current === editRevision) setError(operationMessage(error));
20038
+ } finally {
20039
+ if (request.current?.controller === controller) {
20040
+ request.current = void 0;
20041
+ setLoading(false);
20042
+ }
20043
+ }
20044
+ })();
20045
+ }, [
20046
+ service,
20047
+ sessionId,
20048
+ cli,
20049
+ expanded,
20050
+ blocked,
20051
+ accountLoading,
20052
+ accountRevision
20053
+ ]);
20054
+ async function refresh(action) {
20055
+ if (blocked || request.current?.kind === "write") return;
20056
+ request.current?.controller.abort();
20057
+ const controller = new AbortController();
20058
+ const submitted = draftRef.current.trim();
20059
+ request.current = {
20060
+ controller,
20061
+ kind: "write"
20062
+ };
20063
+ setLoading(false);
20064
+ setSaving(true);
20065
+ setError("");
20066
+ setFeedback("");
20067
+ callbacks.current.onBusyChange(true);
20068
+ try {
20069
+ const next = readPath(value(await service.refreshCliExecutablePath(sessionId, cli, submitted, action, controller.signal)), cli);
20070
+ if (controller.signal.aborted) return;
20071
+ baseline.current = next.path;
20072
+ if (action === "auto" || next.available) {
20073
+ draftRef.current = next.path;
20074
+ setDraft(next.path);
20075
+ }
20076
+ setError(next.error || (!next.available ? "未找到可用 CLI,请检查路径后重试" : ""));
20077
+ setFeedback(next.available ? action === "auto" ? "已恢复自动识别" : "CLI 路径已刷新" : "");
20078
+ callbacks.current.onApplied();
20079
+ } catch (error) {
20080
+ if (!controller.signal.aborted) setError(operationMessage(error));
20081
+ } finally {
20082
+ if (request.current?.controller === controller) {
20083
+ request.current = void 0;
20084
+ setSaving(false);
20085
+ callbacks.current.onBusyChange(false);
20086
+ }
20087
+ }
20088
+ }
20089
+ return (0, react_jsx_runtime.jsxs)("section", {
20090
+ className: "cwn-settings-section",
20091
+ "aria-label": "高级设置",
20092
+ children: [(0, react_jsx_runtime.jsxs)("div", {
20093
+ className: "cwn-settings-section-head",
20094
+ children: [(0, react_jsx_runtime.jsx)("h3", {
20095
+ className: "cwn-settings-advanced-heading",
20096
+ children: "高级设置"
20097
+ }), (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
20098
+ type: "button",
20099
+ variant: "ghost",
20100
+ size: "md",
20101
+ className: "cwn-settings-advanced-toggle",
20102
+ "aria-label": "高级设置",
20103
+ "aria-expanded": expanded,
20104
+ "aria-controls": contentId,
20105
+ onClick: () => {
20106
+ setHasExpanded(true);
20107
+ setExpanded((old) => !old);
20108
+ },
20109
+ children: (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconChevronDownOutlineRegular, { size: 14 })
20110
+ })]
20111
+ }), (0, react_jsx_runtime.jsx)("div", {
20112
+ id: contentId,
20113
+ className: "cwn-settings-advanced-body",
20114
+ "data-expanded": expanded,
20115
+ "aria-hidden": !expanded,
20116
+ ...!expanded ? { inert: "" } : {},
20117
+ children: (0, react_jsx_runtime.jsx)("div", {
20118
+ className: "cwn-settings-advanced-body-inner",
20119
+ children: hasExpanded && (0, react_jsx_runtime.jsxs)("div", {
20120
+ className: "cwn-cli-path-settings",
20121
+ children: [(0, react_jsx_runtime.jsxs)("label", {
20122
+ className: "cwn-setting-row-text",
20123
+ htmlFor: inputId,
20124
+ children: [(0, react_jsx_runtime.jsx)("span", { children: "CLI 路径管理" }), (0, react_jsx_runtime.jsx)("span", {
20125
+ className: "cwn-setting-description",
20126
+ id: hintId,
20127
+ children: "自动识别安装位置,也可输入 CLI 可执行文件的完整路径。"
20128
+ })]
20129
+ }), (0, react_jsx_runtime.jsxs)("form", {
20130
+ onSubmit: (event) => {
20131
+ event.preventDefault();
20132
+ refresh(draftRef.current.trim() === baseline.current ? "refresh" : "manual");
20133
+ },
20134
+ children: [
20135
+ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Input, {
20136
+ id: inputId,
20137
+ className: "cwn-control-input cwn-cli-path-input",
20138
+ "aria-label": `${CLI_LABELS[cli]} CLI 路径`,
20139
+ "aria-describedby": hintId,
20140
+ value: draft,
20141
+ disabled: blocked || saving,
20142
+ spellCheck: false,
20143
+ autoComplete: "off",
20144
+ placeholder: "输入 CLI 可执行文件的完整路径",
20145
+ onChange: (event) => {
20146
+ revision.current++;
20147
+ draftRef.current = event.target.value;
20148
+ setDraft(event.target.value);
20149
+ setError("");
20150
+ setFeedback("");
20151
+ }
20152
+ }),
20153
+ (0, react_jsx_runtime.jsxs)("div", {
20154
+ className: "cwn-cli-path-actions",
20155
+ children: [(0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
20156
+ type: "button",
20157
+ variant: "ghost",
20158
+ size: "md",
20159
+ disabled: blocked || saving,
20160
+ onClick: () => void refresh("auto"),
20161
+ children: "恢复自动识别"
20162
+ }), (0, react_jsx_runtime.jsxs)(_deepseek_ai_dsh_client_ui_primitives.Button, {
20163
+ type: "submit",
20164
+ variant: "outline",
20165
+ size: "md",
20166
+ "aria-label": "刷新 CLI 路径",
20167
+ disabled: blocked || saving,
20168
+ children: [(loading || saving) && (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.StateDot, {
20169
+ state: "ongoing",
20170
+ size: 14
20171
+ }), "刷新"]
20172
+ })]
20173
+ }),
20174
+ (0, react_jsx_runtime.jsx)("p", {
20175
+ className: "cwn-cli-path-feedback",
20176
+ role: "status",
20177
+ children: blocked ? "请先结束当前账号操作或设置保存" : error || feedback || (loading ? "正在检查 CLI 路径…" : "")
20178
+ })
20179
+ ]
20180
+ })]
20181
+ })
20182
+ })
20183
+ })]
20184
+ });
20185
+ }
20186
+ //#endregion
19254
20187
  //#region lib/types/client/settings-dialog.js
19255
20188
  function readEnabled(raw) {
19256
20189
  const parsed = JSON.parse(raw);
@@ -19299,7 +20232,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19299
20232
  };
19300
20233
  if (!account.error && account.data?.state === "unconfigured") return {
19301
20234
  state: "unconfigured",
19302
- label: account.data.installed ? "未登录" : "未安装"
20235
+ label: account.data.installed ? account.data.cli === "claude" ? account.data.summary : "未登录" : "未安装"
19303
20236
  };
19304
20237
  if (account.error || !account.data || ["unavailable", "unauthenticated"].includes(account.data.state)) return {
19305
20238
  state: "failed",
@@ -19335,27 +20268,35 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19335
20268
  const [accounts, setAccounts] = (0, react.useState)({});
19336
20269
  const enabledRef = (0, react.useRef)(enabled);
19337
20270
  enabledRef.current = enabled;
19338
- const probes = (0, react.useRef)(/* @__PURE__ */ new Map());
20271
+ const probes = (0, react.useRef)(new AccountQueryQueue());
19339
20272
  const toggleController = (0, react.useRef)();
19340
- const refreshAccount = (0, react.useCallback)((id, replace = false) => {
20273
+ const accountClose = (0, react.useRef)();
20274
+ const leaving = (0, react.useRef)(false);
20275
+ const leave = async (transition) => {
20276
+ if (leaving.current) return;
20277
+ leaving.current = true;
20278
+ try {
20279
+ if (accountClose.current && !await accountClose.current()) return;
20280
+ transition();
20281
+ } finally {
20282
+ leaving.current = false;
20283
+ }
20284
+ };
20285
+ const refreshAccount = (0, react.useCallback)((id, replace = false, clearPrevious = false) => {
19341
20286
  if (!enabledRef.current?.[id]) return;
19342
- const previous = probes.current.get(id);
19343
- if (previous && !replace) return;
19344
- previous?.abort();
19345
- const controller = new AbortController();
19346
- probes.current.set(id, controller);
20287
+ if (probes.current.has(id) && !replace) return;
19347
20288
  setAccounts((old) => ({
19348
20289
  ...old,
19349
20290
  [id]: {
19350
- data: old[id]?.data,
20291
+ data: clearPrevious ? void 0 : old[id]?.data,
19351
20292
  loading: true
19352
20293
  }
19353
20294
  }));
19354
- (async () => {
20295
+ probes.current.enqueue(id, async (signal) => {
19355
20296
  try {
19356
- const next = JSON.parse(value(await api.cliworker.accountStatus(sessionId, id, controller.signal)));
20297
+ const next = JSON.parse(value(await api.cliworker.accountStatus(sessionId, id, signal)));
19357
20298
  if (next.cli !== id) throw new Error("收到不匹配的 CLI 账号状态,请重试");
19358
- if (!controller.signal.aborted) setAccounts((old) => ({
20299
+ if (!signal.aborted) setAccounts((old) => ({
19359
20300
  ...old,
19360
20301
  [id]: {
19361
20302
  data: next,
@@ -19363,17 +20304,15 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19363
20304
  }
19364
20305
  }));
19365
20306
  } catch (error) {
19366
- if (!controller.signal.aborted) setAccounts((old) => ({
20307
+ if (!signal.aborted) setAccounts((old) => ({
19367
20308
  ...old,
19368
20309
  [id]: {
19369
20310
  loading: false,
19370
20311
  error: operationMessage(error)
19371
20312
  }
19372
20313
  }));
19373
- } finally {
19374
- if (probes.current.get(id) === controller) probes.current.delete(id);
19375
20314
  }
19376
- })();
20315
+ }, replace);
19377
20316
  }, [api, sessionId]);
19378
20317
  (0, react.useEffect)(() => {
19379
20318
  const controller = new AbortController();
@@ -19391,24 +20330,27 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19391
20330
  return () => {
19392
20331
  controller.abort();
19393
20332
  toggleController.current?.abort();
19394
- for (const probe of probes.current.values()) probe.abort();
19395
20333
  probes.current.clear();
19396
20334
  };
19397
20335
  }, [api, sessionId]);
19398
20336
  (0, react.useEffect)(() => {
19399
20337
  if (!enabled) return;
19400
- for (const id of CLI_IDS) if (enabled[id]) {
20338
+ probes.current.prioritize(cli);
20339
+ for (const id of [cli, ...CLI_IDS.filter((id) => id !== cli)]) if (enabled[id]) {
19401
20340
  if (!accounts[id]) refreshAccount(id);
19402
20341
  } else {
19403
- probes.current.get(id)?.abort();
19404
- probes.current.delete(id);
20342
+ probes.current.cancel(id);
19405
20343
  if (accounts[id]) setAccounts((old) => {
19406
20344
  const next = { ...old };
19407
20345
  delete next[id];
19408
20346
  return next;
19409
20347
  });
19410
20348
  }
19411
- }, [enabled, refreshAccount]);
20349
+ }, [
20350
+ enabled,
20351
+ cli,
20352
+ refreshAccount
20353
+ ]);
19412
20354
  async function toggleCli(id, nextValue) {
19413
20355
  if (!enabled || toggleController.current) return;
19414
20356
  const controller = new AbortController();
@@ -19438,7 +20380,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19438
20380
  }
19439
20381
  return (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Modal, {
19440
20382
  open: true,
19441
- onClose,
20383
+ onClose: () => void leave(onClose),
19442
20384
  title: "CLI Worker 设置",
19443
20385
  closeLabel: "关闭设置",
19444
20386
  className: "cwn-settings-dialog",
@@ -19456,7 +20398,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19456
20398
  className: "cwn-settings-nav-primary",
19457
20399
  "aria-label": "智能体设置",
19458
20400
  "aria-pressed": page === "roles",
19459
- onClick: () => setPage("roles"),
20401
+ onClick: () => void leave(() => setPage("roles")),
19460
20402
  children: [(0, react_jsx_runtime.jsx)("span", {
19461
20403
  className: "cwn-settings-nav-icon",
19462
20404
  "aria-hidden": "true",
@@ -19510,10 +20452,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19510
20452
  "aria-pressed": page === "cli" && cli === id,
19511
20453
  tabIndex: cliExpanded ? void 0 : -1,
19512
20454
  "data-enabled": enabled?.[id] !== false,
19513
- onClick: () => {
20455
+ onClick: () => void leave(() => {
19514
20456
  setCli(id);
19515
20457
  setPage("cli");
19516
- },
20458
+ }),
19517
20459
  children: [
19518
20460
  (0, react_jsx_runtime.jsx)(BrandIcon, {
19519
20461
  cli: id,
@@ -19550,6 +20492,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19550
20492
  api,
19551
20493
  sessionId
19552
20494
  }) : (0, react_jsx_runtime.jsx)(CliSettings, {
20495
+ accountClose,
19553
20496
  openNativeSettings,
19554
20497
  api,
19555
20498
  sessionId,
@@ -19557,7 +20500,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19557
20500
  enabled: enabled?.[cli],
19558
20501
  account: accounts[cli],
19559
20502
  connection: connectionStatus(enabled?.[cli], accounts[cli], settingsError),
19560
- onRefreshAccount: (replace) => refreshAccount(cli, replace),
20503
+ onRefreshAccount: (replace, clearPrevious) => refreshAccount(cli, replace, clearPrevious),
19561
20504
  onToggle: (next) => void toggleCli(cli, next),
19562
20505
  toggleBusy: !!togglingCli,
19563
20506
  toggling: togglingCli === cli,
@@ -19569,16 +20512,31 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19569
20512
  }
19570
20513
  function NativeChoice({ label, selected, choices, disabled, onChange }) {
19571
20514
  const [open, setOpen] = (0, react.useState)(false);
20515
+ const anchor = (0, react.useRef)(null);
20516
+ const [anchorWidth, setAnchorWidth] = (0, react.useState)();
20517
+ const menuClass = `cwn-settings-choice-menu-${(0, react.useId)().replace(/[^a-zA-Z0-9_-]/g, "")}`;
19572
20518
  (0, react.useEffect)(() => {
19573
20519
  if (disabled) setOpen(false);
19574
20520
  }, [disabled]);
19575
- return (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Menu, {
20521
+ (0, react.useEffect)(() => {
20522
+ const button = anchor.current;
20523
+ if (!open || !button) return;
20524
+ const measure = () => {
20525
+ const width = button.getBoundingClientRect().width;
20526
+ if (width > 0) setAnchorWidth(width);
20527
+ };
20528
+ measure();
20529
+ const observer = new ResizeObserver(measure);
20530
+ observer.observe(button);
20531
+ return () => observer.disconnect();
20532
+ }, [open]);
20533
+ return (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [(0, react_jsx_runtime.jsx)("style", { children: anchorWidth === void 0 ? "" : `.${menuClass}{--cwn-settings-choice-width:${anchorWidth}px}` }), (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Menu, {
19576
20534
  open: open && !disabled,
19577
20535
  onClose: () => setOpen(false),
19578
20536
  portal: true,
19579
20537
  align: "start",
19580
20538
  className: "cwn-settings-choice",
19581
- listClassName: "cwn-settings-choice-menu",
20539
+ listClassName: `cwn-settings-choice-menu ${menuClass}`,
19582
20540
  selectedId: selected,
19583
20541
  items: choices,
19584
20542
  onSelect: (id) => {
@@ -19586,6 +20544,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19586
20544
  setOpen(false);
19587
20545
  },
19588
20546
  anchor: (0, react_jsx_runtime.jsxs)(_deepseek_ai_dsh_client_ui_primitives.Button, {
20547
+ ref: anchor,
19589
20548
  type: "button",
19590
20549
  variant: "outline",
19591
20550
  size: "md",
@@ -19593,10 +20552,16 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19593
20552
  "aria-haspopup": "menu",
19594
20553
  "aria-expanded": open && !disabled,
19595
20554
  disabled,
19596
- onClick: () => setOpen((old) => !old),
20555
+ onClick: () => {
20556
+ if (!open) {
20557
+ const width = anchor.current?.getBoundingClientRect().width;
20558
+ if (width && width > 0) setAnchorWidth(width);
20559
+ }
20560
+ setOpen((old) => !old);
20561
+ },
19597
20562
  children: [(0, react_jsx_runtime.jsx)("span", { children: choices.find((choice) => choice.id === selected)?.label ?? (label === "默认思考强度" ? "选择强度" : "选择模型") }), (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconChevronDownOutlineRegular, { size: 14 })]
19598
20563
  })
19599
- });
20564
+ })] });
19600
20565
  }
19601
20566
  function SectionProgress({ loading, label }) {
19602
20567
  return (0, react_jsx_runtime.jsx)("span", {
@@ -19617,7 +20582,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19617
20582
  const apiLogin = authenticated && data.authMethod === "api";
19618
20583
  const providerLogins = authenticated ? providerLoginSummary(data) : void 0;
19619
20584
  const state = connection.state;
19620
- const label = enabled === false ? "已关闭" : settingsError ? "设置读取失败,请重新打开" : loading && !data ? "正在读取登录信息…" : account?.error ? account.error : connection.state === "failed" ? connection.label : connection.state === "pending" ? "正在检查连接…" : authenticated ? authenticatedLabel(data) : data?.state === "unconfigured" ? data.installed ? "未登录" : "未安装" : data?.state === "configured" ? "已配置" : data?.summary || "状态待确认";
20585
+ const label = enabled === false ? "已关闭" : settingsError ? "设置读取失败,请重新打开" : loading && !data ? "正在读取登录信息…" : account?.error ? account.error : connection.state === "failed" ? connection.label : connection.state === "pending" ? "正在检查连接…" : authenticated ? authenticatedLabel(data) : data?.state === "unconfigured" ? data.installed ? data.cli === "claude" ? data.summary : "未登录" : "未安装" : data?.state === "configured" ? "已配置" : data?.summary || "状态待确认";
19621
20586
  return (0, react_jsx_runtime.jsx)("div", {
19622
20587
  className: "cwn-account-summary",
19623
20588
  "data-account-state": current ? data?.state : void 0,
@@ -19650,7 +20615,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19650
20615
  })
19651
20616
  });
19652
20617
  }
19653
- function CliSettings({ openNativeSettings, api, sessionId, cli, enabled, account, connection, onRefreshAccount, onToggle, toggleBusy, toggling, settingsError, toggleError }) {
20618
+ function CliSettings({ accountClose, openNativeSettings, api, sessionId, cli, enabled, account, connection, onRefreshAccount, onToggle, toggleBusy, toggling, settingsError, toggleError }) {
19654
20619
  const [catalog, setCatalog] = (0, react.useState)();
19655
20620
  const [modelLoading, setModelLoading] = (0, react.useState)(true);
19656
20621
  const [saving, setSaving] = (0, react.useState)(false);
@@ -19658,14 +20623,41 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19658
20623
  const [saveError, setSaveError] = (0, react.useState)("");
19659
20624
  const [saved, setSaved] = (0, react.useState)(false);
19660
20625
  const [modelRevision, refreshModels] = (0, react.useState)(0);
20626
+ const forceCatalogRefresh = (0, react.useRef)(false);
19661
20627
  const [model, setModel] = (0, react.useState)("");
19662
20628
  const [effort, setEffort] = (0, react.useState)("default");
19663
20629
  const [action, setAction] = (0, react.useState)();
19664
20630
  const [chosenAction, setChosenAction] = (0, react.useState)();
19665
20631
  const [accountSource, setAccountSource] = (0, react.useState)();
19666
- const saveController = (0, react.useRef)();
19667
- (0, react.useEffect)(() => () => saveController.current?.abort(), []);
20632
+ const [loginProvider, setLoginProvider] = (0, react.useState)();
20633
+ const [pathChanging, setPathChanging] = (0, react.useState)(false);
20634
+ const saves = (0, react.useRef)(new AccountQueryQueue(1));
20635
+ const saveRevision = (0, react.useRef)(0);
20636
+ const latestSave = (0, react.useRef)();
20637
+ const selection = (0, react.useRef)({
20638
+ model: "",
20639
+ effort: "default"
20640
+ });
20641
+ const mounted = (0, react.useRef)(true);
20642
+ const cancelSaves = (0, react.useCallback)((updateState = true) => {
20643
+ saveRevision.current++;
20644
+ latestSave.current = void 0;
20645
+ saves.current.clear();
20646
+ if (updateState) setSaving(false);
20647
+ }, []);
20648
+ (0, react.useEffect)(() => {
20649
+ mounted.current = true;
20650
+ return () => {
20651
+ mounted.current = false;
20652
+ cancelSaves(false);
20653
+ };
20654
+ }, [cancelSaves]);
19668
20655
  (0, react.useEffect)(() => {
20656
+ cancelSaves();
20657
+ selection.current = {
20658
+ model: "",
20659
+ effort: "default"
20660
+ };
19669
20661
  setCatalog(void 0);
19670
20662
  setModel("");
19671
20663
  setEffort("default");
@@ -19681,7 +20673,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19681
20673
  const controller = new AbortController();
19682
20674
  (async () => {
19683
20675
  try {
19684
- const next = JSON.parse(value(await api.cliworker.catalogForCli(sessionId, cli, controller.signal)));
20676
+ const force = forceCatalogRefresh.current;
20677
+ forceCatalogRefresh.current = false;
20678
+ const next = JSON.parse(value(await (force ? api.cliworker.refreshCatalogForCli(sessionId, cli, controller.signal) : api.cliworker.catalogForCli(sessionId, cli, controller.signal))));
19685
20679
  if (next.cli !== cli) throw new Error("收到不匹配的 CLI 模型目录,请重试");
19686
20680
  if (controller.signal.aborted) return;
19687
20681
  setCatalog(next);
@@ -19690,8 +20684,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19690
20684
  const saved = next.models.find((item) => item.id === preferred || Object.values(item.variants ?? {}).includes(next.preference?.model ?? ""));
19691
20685
  const chosen = next.preference ? saved : visibleModelChoices(next.models)[0];
19692
20686
  if (next.preference && !saved && next.models.length) setModelError("原默认模型已不可用,请重新选择模型");
19693
- setModel(chosen?.id ?? "");
19694
- setEffort(next.preference && chosen?.efforts?.includes(next.preference.effort) ? next.preference.effort : chosen?.efforts?.[0] ?? "default");
20687
+ const effort = next.preference && chosen?.efforts?.includes(next.preference.effort) ? next.preference.effort : chosen?.efforts?.[0] ?? "default";
20688
+ selection.current = {
20689
+ model: chosen?.id ?? "",
20690
+ effort
20691
+ };
20692
+ setModel(selection.current.model);
20693
+ setEffort(effort);
19695
20694
  } catch (error) {
19696
20695
  if (!controller.signal.aborted) {
19697
20696
  setCatalog(void 0);
@@ -19711,41 +20710,77 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19711
20710
  cli,
19712
20711
  enabled,
19713
20712
  account,
19714
- modelRevision
20713
+ modelRevision,
20714
+ cancelSaves
19715
20715
  ]);
19716
20716
  const inactive = !enabled || toggling;
19717
20717
  const settingsPending = enabled === void 0 && !settingsError;
19718
20718
  const accountLoading = !settingsError && enabled !== false && (!account || account.loading);
19719
20719
  const supportedEfforts = catalog?.models.find((item) => item.id === model)?.efforts ?? [];
19720
- const validPreference = !!catalog && !!model && supportedEfforts.includes(effort);
19721
- async function save() {
19722
- if (inactive || saving || modelLoading || !validPreference || saveController.current) return;
19723
- const controller = new AbortController();
19724
- saveController.current = controller;
20720
+ const choiceDisabled = inactive || pathChanging || modelLoading || accountLoading || !!action || !catalog;
20721
+ function savePreference(preference) {
20722
+ const key = JSON.stringify(preference);
20723
+ if (latestSave.current?.key === key && latestSave.current.state === "pending") return;
20724
+ const revision = ++saveRevision.current;
20725
+ latestSave.current = {
20726
+ key,
20727
+ revision,
20728
+ state: "pending"
20729
+ };
19725
20730
  setSaving(true);
19726
20731
  setSaveError("");
19727
20732
  setSaved(false);
19728
- try {
19729
- value(await api.cliworker.configure(sessionId, JSON.stringify({
19730
- cli,
19731
- model,
19732
- effort
19733
- }), controller.signal));
19734
- if (!controller.signal.aborted) setSaved(true);
19735
- } catch (error) {
19736
- if (!controller.signal.aborted) setSaveError(operationMessage(error));
19737
- } finally {
19738
- if (!controller.signal.aborted) {
19739
- saveController.current = void 0;
19740
- setSaving(false);
20733
+ saves.current.enqueue("preference", async (signal) => {
20734
+ const current = () => mounted.current && !signal.aborted && latestSave.current?.revision === revision;
20735
+ try {
20736
+ value(await api.cliworker.configure(sessionId, JSON.stringify(preference), signal));
20737
+ if (current()) {
20738
+ latestSave.current.state = "saved";
20739
+ setSaved(true);
20740
+ }
20741
+ } catch (error) {
20742
+ if (current()) {
20743
+ latestSave.current.state = "failed";
20744
+ setSaveError(`${operationMessage(error)};请重新选择模型或思考强度重试`);
20745
+ }
20746
+ } finally {
20747
+ if (current()) setSaving(false);
19741
20748
  }
19742
- }
20749
+ }, true);
19743
20750
  }
19744
20751
  const changeModel = (id) => {
20752
+ if (choiceDisabled) return;
20753
+ const chosen = catalog?.models.find((item) => item.id === id);
20754
+ if (!chosen?.efforts?.length) return;
20755
+ const effort = chosen.efforts.includes(selection.current.effort) ? selection.current.effort : chosen.efforts[0];
20756
+ selection.current = {
20757
+ model: id,
20758
+ effort
20759
+ };
19745
20760
  setModel(id);
19746
- setSaved(false);
19747
- const efforts = catalog?.models.find((item) => item.id === id)?.efforts ?? ["default"];
19748
- if (!efforts.includes(effort)) setEffort(efforts[0] ?? "default");
20761
+ setEffort(effort);
20762
+ setModelError("");
20763
+ savePreference({
20764
+ cli,
20765
+ model: id,
20766
+ effort
20767
+ });
20768
+ };
20769
+ const changeEffort = (id) => {
20770
+ if (choiceDisabled) return;
20771
+ const chosen = catalog?.models.find((item) => item.id === selection.current.model);
20772
+ const effort = chosen?.efforts?.find((effort) => effort === id);
20773
+ if (!chosen || !effort) return;
20774
+ selection.current = {
20775
+ model: chosen.id,
20776
+ effort
20777
+ };
20778
+ setEffort(effort);
20779
+ savePreference({
20780
+ cli,
20781
+ model: chosen.id,
20782
+ effort
20783
+ });
19749
20784
  };
19750
20785
  const finishedAccountAction = () => {
19751
20786
  onRefreshAccount(true);
@@ -19753,10 +20788,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19753
20788
  const closeAccount = () => {
19754
20789
  setAction(void 0);
19755
20790
  setAccountSource(void 0);
20791
+ setLoginProvider(void 0);
19756
20792
  onRefreshAccount(true);
19757
20793
  };
19758
20794
  const sources = chosenAction?.sources?.filter((source, index, all) => ["native", "plugin"].includes(source.id) && all.findIndex((item) => item.id === source.id) === index);
19759
20795
  const choosingSource = action === "logout" && chosenAction?.sources !== void 0 && !accountSource;
20796
+ const choosingLoginProvider = cli === "zcode" && action === "login" && !loginProvider;
19760
20797
  const accountAction = (id) => {
19761
20798
  const item = account?.data?.actions.find((candidate) => candidate.id === id);
19762
20799
  const label = item?.target === "models" ? id === "login" ? "登录设置" : "打开原生设置" : item?.label ?? (id === "logout" ? "退出登录" : id === "manage" ? "账号终端" : [
@@ -19771,7 +20808,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19771
20808
  size: "md",
19772
20809
  className: id === "logout" ? "cwn-account-logout" : id === "manage" ? "cwn-account-manage" : "cwn-account-login-action",
19773
20810
  "aria-label": label,
19774
- disabled: inactive || accountLoading || !!account?.error || !!action || !item || item.target === "models" && !openNativeSettings,
20811
+ disabled: inactive || accountLoading || !!account?.error || !!action || saving || pathChanging || !item || item.target === "models" && !openNativeSettings,
19775
20812
  onClick: () => {
19776
20813
  if (!inactive && item) {
19777
20814
  if (item.target === "models") {
@@ -19779,6 +20816,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19779
20816
  return;
19780
20817
  }
19781
20818
  setChosenAction(item);
20819
+ setLoginProvider(void 0);
19782
20820
  setAccountSource(id === "logout" && item.sources?.length === 1 && ["native", "plugin"].includes(item.sources[0].id) ? item.sources[0].id : void 0);
19783
20821
  setAction(item.id);
19784
20822
  }
@@ -19811,7 +20849,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19811
20849
  checked: enabled ?? false,
19812
20850
  onChange: onToggle,
19813
20851
  label: `启用 ${CLI_LABELS[cli]}`,
19814
- disabled: enabled === void 0 || toggleBusy || saving || !!action,
20852
+ disabled: enabled === void 0 || toggleBusy || saving || !!action || pathChanging,
19815
20853
  title: action ? "请先关闭账号终端" : void 0
19816
20854
  })]
19817
20855
  })]
@@ -19842,7 +20880,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19842
20880
  size: "md",
19843
20881
  className: "cwn-refresh",
19844
20882
  "aria-label": "刷新状态",
19845
- disabled: inactive || accountLoading || saving,
20883
+ disabled: inactive || accountLoading || saving || pathChanging,
19846
20884
  onClick: () => onRefreshAccount(),
19847
20885
  children: (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconRefreshOutlineRegular, { size: 16 })
19848
20886
  })
@@ -19865,12 +20903,31 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19865
20903
  }),
19866
20904
  action && enabled && (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Modal, {
19867
20905
  open: true,
19868
- onClose: closeAccount,
20906
+ onClose: () => {
20907
+ if (accountClose.current) accountClose.current();
20908
+ else closeAccount();
20909
+ },
19869
20910
  title: `${CLI_LABELS[cli]} · ${chosenAction?.label ?? "账号终端"}`,
19870
20911
  closeLabel: "关闭账号操作",
19871
20912
  className: "cwn-account-dialog",
19872
20913
  contentClassName: "cwn-account-dialog-content",
19873
- children: choosingSource ? (0, react_jsx_runtime.jsxs)("section", {
20914
+ children: choosingLoginProvider ? (0, react_jsx_runtime.jsxs)("section", {
20915
+ "aria-label": "选择 ZCode 授权来源",
20916
+ children: [(0, react_jsx_runtime.jsx)("p", { children: "选择账号所属的服务商" }), (0, react_jsx_runtime.jsxs)("div", {
20917
+ className: "cwn-account-actions",
20918
+ children: [(0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
20919
+ variant: "outline",
20920
+ size: "md",
20921
+ onClick: () => setLoginProvider("bigmodel"),
20922
+ children: "中国智谱 BigModel"
20923
+ }), (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
20924
+ variant: "outline",
20925
+ size: "md",
20926
+ onClick: () => setLoginProvider("zai"),
20927
+ children: "海外 Z.AI"
20928
+ })]
20929
+ })]
20930
+ }) : choosingSource ? (0, react_jsx_runtime.jsxs)("section", {
19874
20931
  "aria-label": "选择退出账号来源",
19875
20932
  children: [(0, react_jsx_runtime.jsx)("p", { children: sources?.length ? "选择要退出的账号来源" : "账号来源不可用,请关闭后刷新状态" }), (0, react_jsx_runtime.jsx)("div", {
19876
20933
  className: "cwn-account-actions",
@@ -19882,11 +20939,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19882
20939
  }, source.id))
19883
20940
  })]
19884
20941
  }) : (0, react_jsx_runtime.jsx)(AccountTerminal, {
20942
+ closeControl: accountClose,
19885
20943
  api,
19886
20944
  sessionId,
19887
20945
  cli,
19888
20946
  action,
19889
20947
  source: accountSource,
20948
+ provider: loginProvider,
19890
20949
  onClose: closeAccount,
19891
20950
  onFinished: finishedAccountAction
19892
20951
  })
@@ -19913,8 +20972,11 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19913
20972
  size: "md",
19914
20973
  className: "cwn-refresh",
19915
20974
  "aria-label": "刷新模型",
19916
- disabled: inactive || modelLoading || saving,
19917
- onClick: () => refreshModels((n) => n + 1),
20975
+ disabled: inactive || modelLoading || saving || pathChanging,
20976
+ onClick: () => {
20977
+ forceCatalogRefresh.current = true;
20978
+ refreshModels((n) => n + 1);
20979
+ },
19918
20980
  children: (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconRefreshOutlineRegular, { size: 16 })
19919
20981
  })
19920
20982
  })]
@@ -19923,7 +20985,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19923
20985
  className: "cwn-settings-form",
19924
20986
  onSubmit: (event) => {
19925
20987
  event.preventDefault();
19926
- save();
19927
20988
  },
19928
20989
  children: [
19929
20990
  (0, react_jsx_runtime.jsxs)("label", {
@@ -19941,7 +21002,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19941
21002
  id: item.id,
19942
21003
  label: item.label
19943
21004
  })),
19944
- disabled: inactive || modelLoading || saving || !catalog,
21005
+ disabled: choiceDisabled,
19945
21006
  onChange: changeModel
19946
21007
  })]
19947
21008
  }),
@@ -19960,37 +21021,40 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
19960
21021
  id,
19961
21022
  label: effortLabel(id)
19962
21023
  })),
19963
- disabled: inactive || modelLoading || saving || !catalog,
19964
- onChange: (id) => {
19965
- setEffort(id);
19966
- setSaved(false);
19967
- }
21024
+ disabled: choiceDisabled || !supportedEfforts.length,
21025
+ onChange: changeEffort
19968
21026
  })]
19969
21027
  }),
19970
21028
  (0, react_jsx_runtime.jsx)("p", {
19971
21029
  className: "cwn-settings-notice cwn-settings-hint",
19972
21030
  role: "status",
19973
- children: modelError || ""
21031
+ children: modelError || (cli === "claude" && catalog?.notice?.includes("路由") ? catalog.notice : "")
19974
21032
  }),
19975
- (0, react_jsx_runtime.jsxs)("div", {
21033
+ (saving || saved || saveError) && (0, react_jsx_runtime.jsx)("div", {
19976
21034
  className: "cwn-settings-save",
19977
- children: [(0, react_jsx_runtime.jsxs)(_deepseek_ai_dsh_client_ui_primitives.Button, {
19978
- type: "submit",
19979
- variant: "primary",
19980
- size: "md",
19981
- disabled: inactive || modelLoading || saving || !validPreference,
21035
+ children: (0, react_jsx_runtime.jsxs)("span", {
21036
+ className: "cwn-settings-feedback-slot",
21037
+ role: "status",
19982
21038
  children: [saving && (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.StateDot, {
19983
21039
  state: "ongoing",
19984
21040
  size: 14
19985
- }), "保存默认值"]
19986
- }), (0, react_jsx_runtime.jsx)("span", {
19987
- className: "cwn-settings-feedback-slot",
19988
- role: "status",
19989
- children: saveError || (saved ? "默认设置已保存" : "")
19990
- })]
21041
+ }), saveError || (saving ? "正在保存默认设置…" : "默认设置已保存")]
21042
+ })
19991
21043
  })
19992
21044
  ]
19993
21045
  })]
21046
+ }),
21047
+ (0, react_jsx_runtime.jsx)(CliExecutableSettings, {
21048
+ api,
21049
+ sessionId,
21050
+ cli,
21051
+ blocked: !!action || saving || toggling,
21052
+ accountLoading,
21053
+ accountRevision: account,
21054
+ onApplied: () => {
21055
+ if (enabled) onRefreshAccount(true, true);
21056
+ },
21057
+ onBusyChange: setPathChanging
19994
21058
  })
19995
21059
  ]
19996
21060
  });
@@ -21188,7 +22252,7 @@ body:not([data-ds-dark-theme]) .cwn button:disabled:not(.cwn-send):hover{backgro
21188
22252
  .cwn-settings-dialog{width:min(800px,90vw);max-width:90vw;height:700px;max-height:100%}
21189
22253
  .cwn-settings-content{padding-top:4px!important;min-height:0;flex:1;overflow:hidden}
21190
22254
  .cwn-settings-content>div:last-child{flex:1;min-height:0}.cwn-settings-content>div:first-child{flex-shrink:0}
21191
- .cwn-settings-layout{display:grid;grid-template-columns:188px minmax(0,1fr);gap:24px;height:100%;min-height:0;font-family:var(--dsw-font-family);font-size:var(--dsw-font-s-14-font-size);line-height:var(--dsw-font-s-14-line-height);color:var(--dsw-alias-label-primary)}
22255
+ .cwn-settings-layout{--cwn-settings-label-size:var(--dsw-font-s-14-font-size);--cwn-settings-label-line:22px;--cwn-settings-label-weight:400;--cwn-settings-heading-weight:500;--cwn-settings-description-size:var(--dsw-font-xxs-12-font-size);--cwn-settings-description-line:18px;--cwn-settings-description-gap:4px;--cwn-settings-control-height:36px;--cwn-settings-header-gap:8px;--cwn-settings-row-padding:16px;--cwn-settings-column-gap:24px;--cwn-settings-field-gap:16px;--cwn-settings-action-gap:8px;--cwn-settings-feedback-line:20px;--cwn-settings-border:.5px solid var(--dsw-alias-border-l2);display:grid;grid-template-columns:188px minmax(0,1fr);gap:24px;height:100%;min-height:0;font-family:var(--dsw-font-family);font-size:var(--cwn-settings-label-size);line-height:var(--cwn-settings-label-line);font-weight:var(--cwn-settings-label-weight);color:var(--dsw-alias-label-primary)}
21192
22256
  .cwn-settings-layout *{box-sizing:border-box}
21193
22257
  .cwn-settings-nav{display:flex;flex-direction:column;gap:6px;align-self:stretch;min-height:0;overflow:auto;overscroll-behavior:contain}.cwn-settings-nav>button{flex-shrink:0}
21194
22258
  .cwn-settings-nav button{justify-content:flex-start;gap:10px;width:100%;font-weight:400}
@@ -21215,21 +22279,23 @@ body:not([data-ds-dark-theme]) .cwn button:disabled:not(.cwn-send):hover{backgro
21215
22279
  .cwn-settings-cli-name{gap:14px}.cwn-settings-cli-name h2{margin:0;font-size:24px;line-height:32px;font-weight:600;letter-spacing:-.02em}.cwn-cli-subtitle{margin:4px 0 0;font-size:var(--dsw-font-xxs-12-font-size);line-height:18px;color:var(--dsw-alias-label-tertiary)}
21216
22280
  .cwn-cli-toggle-status{height:20px;overflow:auto;margin:4px 0 4px;font-size:var(--dsw-font-xxs-12-font-size);line-height:18px;color:var(--dsw-alias-label-tertiary)}
21217
22281
  .cwn-section-progress{display:inline-flex;align-items:center;justify-content:center;width:14px;height:14px;flex:none}
21218
- .cwn-settings-section{min-width:0}.cwn-settings-section+.cwn-settings-section{margin-top:20px;padding-top:16px;border-top:.5px solid var(--dsw-alias-border-l2)}
21219
- .cwn-settings-section-head,.cwn-account-terminal-head{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:8px;min-height:36px}
21220
- .cwn-settings-section-head h3{font-size:inherit;font-weight:500;margin:0}
21221
- .cwn-settings-form{display:flex;flex-direction:column;gap:0}.cwn-settings-form label{display:flex;flex-direction:column;gap:8px;color:var(--dsw-alias-label-secondary)}
22282
+ .cwn-settings-section{min-width:0}.cwn-settings-section+.cwn-settings-section{margin-top:0;padding-top:var(--cwn-settings-row-padding);border-top:var(--cwn-settings-border)}
22283
+ .cwn-settings-section-head,.cwn-account-terminal-head{display:flex;align-items:center;justify-content:space-between;gap:12px}.cwn-settings-section-head{margin-bottom:var(--cwn-settings-header-gap);min-height:var(--cwn-settings-control-height)}
22284
+ .cwn-settings-section-head h3{font-size:var(--cwn-settings-label-size);line-height:var(--cwn-settings-label-line);font-weight:var(--cwn-settings-heading-weight);margin:0}
22285
+ .cwn-settings-form{display:flex;flex-direction:column;gap:0}.cwn-settings-form label{display:flex;flex-direction:column;gap:var(--cwn-settings-action-gap);color:var(--dsw-alias-label-secondary)}
22286
+ .cwn-settings-form .cwn-setting-row,.cwn-account-row,.cwn-cli-path-settings{padding:var(--cwn-settings-row-padding) 0}.cwn-settings-form .cwn-setting-row+.cwn-setting-row{border-top:var(--cwn-settings-border)}
21222
22287
  .cwn-settings-choice{display:block;width:min(240px,48%);min-width:0;flex-shrink:0}.cwn-settings-choice>button{width:100%;justify-content:space-between;gap:12px;background:var(--dsw-alias-interactive-bg-hover)}.cwn-settings-choice>button>span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
21223
- .cwn-settings-choice-menu{width:min(300px,85vw);min-width:min(220px,85vw);max-width:min(300px,85vw);max-height:300px;overflow:auto}
21224
- .cwn-settings-hint,.cwn-settings-feedback,.cwn-account-summary,.cwn-account-instruction{margin:0;font-size:var(--dsw-font-xxs-12-font-size);line-height:20px;color:var(--dsw-alias-label-tertiary);overflow-wrap:anywhere}
21225
- .cwn-account-row{display:flex;align-items:center;gap:12px;min-height:56px}.cwn-account-summary{display:flex;align-items:center;flex:1;min-width:0;min-height:52px;margin:0;color:var(--dsw-alias-label-secondary)}
21226
- .cwn-account-status-line{display:flex;align-items:center;min-width:0;gap:8px;min-height:24px;font-size:var(--dsw-font-s-14-font-size);line-height:22px}.cwn-account-login{display:inline-flex;align-items:center;gap:6px;min-width:0}.cwn-account-login:not([data-state=failed]){flex-shrink:0;white-space:nowrap}.cwn-account-login[data-state=connected]{color:var(--dsw-alias-state-success-primary)}.cwn-account-login[data-state=failed]{color:var(--dsw-alias-state-error-primary)}.cwn-account-login[data-state=disabled]{color:var(--dsw-alias-label-caption)}.cwn-account-status-dot{display:inline-block;flex-shrink:0;width:6px;height:6px;border-radius:50%;background:var(--dsw-alias-label-caption)}.cwn-account-status-dot[data-state=connected]{background:var(--dsw-alias-state-success-primary)}.cwn-account-status-dot[data-state=failed]{background:var(--dsw-alias-state-error-primary)}.cwn-account-label{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--dsw-alias-label-secondary)}
21227
- .cwn-settings-notice{min-height:20px;max-height:56px;overflow:auto;margin:8px 0 0}.cwn-settings-notice:empty{min-height:0;height:0;margin:0}
21228
- .cwn-settings-form .cwn-setting-row{display:flex;flex-direction:row;align-items:center;justify-content:space-between;gap:24px;padding:16px 0;border-bottom:.5px solid var(--dsw-alias-border-l2);color:var(--dsw-alias-label-primary)}.cwn-setting-row-text{display:flex;flex-direction:column;gap:4px;flex:1;min-width:0;font-size:var(--dsw-font-s-14-font-size);line-height:22px}.cwn-setting-description{font-size:var(--dsw-font-xxs-12-font-size);line-height:18px;color:var(--dsw-alias-label-tertiary)}.cwn-settings-save{margin-top:16px;justify-content:flex-end}
21229
- .cwn-settings-feedback-slot{min-height:20px;font-size:12px;line-height:20px;color:var(--dsw-alias-label-tertiary)}
22288
+ .cwn-settings-choice-menu{width:var(--cwn-settings-choice-width,auto);min-width:0;max-width:none;max-height:300px;overflow:auto}
22289
+ .cwn-settings-hint,.cwn-settings-feedback,.cwn-account-summary,.cwn-account-instruction{margin:0;font-size:var(--cwn-settings-description-size,var(--dsw-font-xxs-12-font-size));line-height:var(--cwn-settings-feedback-line,20px);font-weight:var(--cwn-settings-label-weight,400);color:var(--dsw-alias-label-tertiary);overflow-wrap:anywhere}
22290
+ .cwn-account-row{display:flex;align-items:center;gap:12px}.cwn-account-summary{display:flex;align-items:center;flex:1;min-width:0;min-height:var(--cwn-settings-control-height);margin:0;color:var(--dsw-alias-label-secondary)}
22291
+ .cwn-account-status-line{display:flex;align-items:center;min-width:0;gap:var(--cwn-settings-action-gap);min-height:24px;font-size:var(--cwn-settings-label-size);line-height:var(--cwn-settings-label-line);font-weight:var(--cwn-settings-label-weight)}.cwn-account-login{display:inline-flex;align-items:center;gap:6px;min-width:0}.cwn-account-login:not([data-state=failed]){flex-shrink:0;white-space:nowrap}.cwn-account-login[data-state=connected]{color:var(--dsw-alias-state-success-primary)}.cwn-account-login[data-state=failed]{color:var(--dsw-alias-state-error-primary)}.cwn-account-login[data-state=disabled]{color:var(--dsw-alias-label-caption)}.cwn-account-status-dot{display:inline-block;flex-shrink:0;width:6px;height:6px;border-radius:50%;background:var(--dsw-alias-label-caption)}.cwn-account-status-dot[data-state=connected]{background:var(--dsw-alias-state-success-primary)}.cwn-account-status-dot[data-state=failed]{background:var(--dsw-alias-state-error-primary)}.cwn-account-label{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--dsw-alias-label-secondary)}
22292
+ .cwn-settings-notice{min-height:var(--cwn-settings-feedback-line);max-height:56px;overflow:auto;margin:0;padding-bottom:var(--cwn-settings-row-padding)}
22293
+ .cwn-settings-form .cwn-setting-row{display:flex;flex-direction:row;align-items:center;justify-content:space-between;gap:var(--cwn-settings-column-gap);color:var(--dsw-alias-label-primary)}.cwn-setting-row-text{display:flex;flex-direction:column;gap:var(--cwn-settings-description-gap);flex:1;min-width:0;font-size:var(--cwn-settings-label-size);line-height:var(--cwn-settings-label-line);font-weight:var(--cwn-settings-label-weight)}.cwn-setting-description{font-size:var(--cwn-settings-description-size);line-height:var(--cwn-settings-description-line);font-weight:var(--cwn-settings-label-weight);color:var(--dsw-alias-label-tertiary)}.cwn-settings-save{margin-top:0;padding-bottom:var(--cwn-settings-row-padding);justify-content:flex-end}
22294
+ .cwn-settings-feedback-slot,.cwn-cli-path-feedback{min-height:var(--cwn-settings-feedback-line);margin:0;font-size:var(--cwn-settings-description-size);line-height:var(--cwn-settings-feedback-line);font-weight:var(--cwn-settings-label-weight);color:var(--dsw-alias-label-tertiary);overflow-wrap:anywhere}
22295
+ .cwn-settings-hint:empty,.cwn-settings-feedback-slot:empty,.cwn-cli-path-feedback:empty{display:none}
21230
22296
  .cwn-account-summary[data-provider-logins=true] .cwn-account-status-line{width:100%}.cwn-account-summary[data-provider-logins=true] .cwn-account-login{flex-shrink:1}.cwn-account-logins{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
21231
- .cwn-settings-feedback,.cwn-settings-save,.cwn-account-actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
21232
- .cwn-account-actions{min-height:36px;flex-shrink:0;justify-content:flex-end;gap:8px}.cwn-account-actions button{background:transparent}.cwn-account-logout{flex-shrink:0;gap:5px!important;padding:0 8px!important;color:var(--dsw-alias-state-error-primary)!important}.cwn-account-logout:hover:not(:disabled){background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 9%,transparent)!important}.cwn-refresh{width:36px!important;padding:0!important}.cwn-account-login-action,.cwn-account-manage{padding:0 10px!important}
22297
+ .cwn-settings-feedback,.cwn-settings-save,.cwn-account-actions{display:flex;align-items:center;gap:var(--cwn-settings-action-gap,8px);flex-wrap:wrap}
22298
+ .cwn-account-actions{min-height:var(--cwn-settings-control-height,36px);flex-shrink:0;justify-content:flex-end}.cwn-account-actions button{background:transparent}.cwn-account-logout{flex-shrink:0;gap:5px!important;padding:0 8px!important;color:var(--dsw-alias-state-error-primary)!important}.cwn-account-logout:hover:not(:disabled){background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 9%,transparent)!important}.cwn-refresh{width:var(--cwn-settings-control-height,36px)!important;padding:0!important}.cwn-account-login-action,.cwn-account-manage{padding:0 10px!important}
21233
22299
  .cwn-local-loading,.cwn-loading{display:flex;align-items:center;gap:8px;color:var(--dsw-alias-label-tertiary);font-size:var(--dsw-font-xxs-12-font-size);line-height:20px}
21234
22300
  /* Native md Button owns the 36px height; native Switch keeps its own 36x20px geometry. */
21235
22301
  .cwn-settings-choice-menu button{border:0;box-shadow:none;--dsw-elevation-stroke-color:transparent}.cwn-settings-layout button:not([role=switch]),.cwn-settings-choice-menu button{transition:background-color 180ms ease,color 180ms ease,opacity 180ms ease}
@@ -21239,11 +22305,11 @@ body:not([data-ds-dark-theme]) .cwn button:disabled:not(.cwn-send):hover{backgro
21239
22305
  .cwn-settings-layout button:not([role=switch]):disabled:hover{background:var(--dsw-alias-interactive-bg-active);color:var(--dsw-alias-label-secondary)}
21240
22306
  .cwn-settings-layout button:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary);outline-offset:2px}
21241
22307
  .cwn-account-terminal{margin-top:16px;padding:12px;border-radius:var(--dsw-radius-lg);background:var(--dsw-alias-bg-layer-2);border:.5px solid var(--dsw-alias-border-l2);min-width:0}
21242
- .cwn-account-terminal-head{margin-bottom:8px}.cwn-account-terminal-head strong{font-size:12px;font-weight:500}.cwn-account-terminal-view{height:300px;min-height:200px;margin:12px 0;overflow:hidden}.cwn-account-terminal-view .xterm{height:100%}.cwn-account-terminal-view .xterm-viewport{background-color:var(--dsw-alias-bg-layer-2)!important}.cwn-account-terminal-view .xterm-helper-textarea{resize:none!important;min-height:0!important;max-height:0!important}
22308
+ .cwn-account-terminal-head{margin-bottom:8px;min-height:36px}.cwn-account-terminal-head strong{font-size:12px;font-weight:500}.cwn-account-terminal-view{height:300px;min-height:200px;margin:12px 0;overflow:hidden}.cwn-account-terminal-view .xterm{height:100%}.cwn-account-terminal-view .xterm-viewport{background-color:var(--dsw-alias-bg-layer-2)!important}.cwn-account-terminal-view .xterm-helper-textarea{resize:none!important;min-height:0!important;max-height:0!important}
21243
22309
  .cwn-native-model-settings>p{margin:0 0 16px;color:var(--dsw-alias-label-secondary);font-size:var(--cwn-font-sm);line-height:1.6}.cwn-account-dialog{width:min(720px,90vw);max-width:90vw}.cwn-account-dialog-content{min-height:0;overflow:auto}.cwn-account-dialog .cwn-account-terminal{margin:0;padding:0;border:0;background:transparent}.cwn-account-dialog .cwn-account-terminal-view{height:300px;max-height:48vh}.cwn-account-dialog .cwn-account-terminal button{border:0!important;transition:background-color 180ms ease,color 180ms ease}.cwn-account-dialog .cwn-account-terminal button:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-active)}
21244
22310
  /* OMP onboarding needs room for its native header and provider list. Small screens scroll the modal body. */
21245
22311
  .cwn-account-dialog .cwn-account-terminal[data-cli="omp"] .cwn-account-terminal-view{height:520px;max-height:none}
21246
- @media(max-width:640px){.cwn-account-row{flex-wrap:wrap}.cwn-account-actions{margin-left:auto}.cwn-settings-content{overflow:auto}.cwn-settings-layout{grid-template-columns:1fr;grid-template-rows:auto minmax(0,1fr);gap:16px}.cwn-settings-nav{max-height:190px}.cwn-settings-cli-group-inner{display:grid;grid-template-columns:repeat(2,minmax(0,1fr))}.cwn-settings-nav button{min-width:0}.cwn-settings-pane{overflow:auto}.cwn-settings-form .cwn-setting-row{gap:12px}.cwn-setting-description{max-width:180px}.cwn-account-terminal-view{height:240px}}
22312
+ @media(max-width:640px){.cwn-account-row{flex-wrap:wrap}.cwn-account-actions{margin-left:auto}.cwn-settings-content{overflow:auto}.cwn-settings-layout{--cwn-settings-column-gap:12px;grid-template-columns:1fr;grid-template-rows:auto minmax(0,1fr);gap:16px}.cwn-settings-nav{max-height:190px}.cwn-settings-cli-group-inner{display:grid;grid-template-columns:repeat(2,minmax(0,1fr))}.cwn-settings-nav button{min-width:0}.cwn-settings-pane{overflow:auto}.cwn-setting-description{max-width:180px}.cwn-account-terminal-view{height:240px}}
21247
22313
  @media(prefers-reduced-motion:reduce){.cwn-settings-layout button,.cwn-settings-choice-menu button,.cwn-settings-nav-chevron,.cwn-settings-cli-group{transition:none}}
21248
22314
  `;
21249
22315
  const rolePresetStyles = `
@@ -21388,6 +22454,10 @@ body:not([data-ds-dark-theme]) .cwn button:disabled:not(.cwn-send):hover{backgro
21388
22454
  //#endregion
21389
22455
  //#region lib/types/client/management-styles.js
21390
22456
  const workerManagementStyles = `
22457
+ .cwn-settings-advanced-heading{flex:1;min-width:0}.cwn-settings-section-head>.cwn-settings-advanced-toggle{flex:none;width:var(--cwn-settings-control-height);min-width:var(--cwn-settings-control-height);padding:0;color:inherit}.cwn-settings-advanced-toggle>svg{transition:transform 220ms cubic-bezier(.2,0,0,1)}.cwn-settings-advanced-toggle[aria-expanded=true]>svg{transform:rotate(180deg)}
22458
+ .cwn-settings-advanced-body{display:grid;grid-template-rows:1fr;opacity:1;transition:grid-template-rows 220ms cubic-bezier(.2,0,0,1),opacity 180ms ease,visibility 220ms}.cwn-settings-advanced-body[data-expanded=false]{grid-template-rows:0fr;opacity:0;visibility:hidden}.cwn-settings-advanced-body-inner{min-height:0;overflow:hidden}
22459
+ .cwn-cli-path-settings{display:flex;flex-direction:column;gap:var(--cwn-settings-field-gap);min-width:0}.cwn-cli-path-settings>.cwn-setting-row-text{flex:none;color:var(--dsw-alias-label-primary)}.cwn-cli-path-settings form{display:flex;flex-direction:column;gap:var(--cwn-settings-action-gap);min-width:0}.cwn-cli-path-settings .cwn-cli-path-input{width:100%;min-width:0}.cwn-cli-path-actions{display:flex;align-items:center;justify-content:flex-end;flex-wrap:wrap;gap:var(--cwn-settings-action-gap)}
22460
+ @media(prefers-reduced-motion:reduce){.cwn-settings-advanced-body,.cwn-settings-advanced-toggle>svg{transition:none}}
21391
22461
  .cwn-worker{display:block;padding:12px;min-height:62px}
21392
22462
  .cwn .cwn-worker-menu-anchor{display:block;width:100%}
21393
22463
  .cwn-worker-layout{display:grid;grid-template-columns:minmax(0,1fr) 14px;column-gap:10px;align-items:center;min-width:0}