@kaitranntt/ccs 7.56.0 → 7.57.0

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 (203) hide show
  1. package/README.md +54 -30
  2. package/dist/api/services/profile-lifecycle-service.d.ts.map +1 -1
  3. package/dist/api/services/profile-lifecycle-service.js +10 -10
  4. package/dist/api/services/profile-lifecycle-service.js.map +1 -1
  5. package/dist/api/services/profile-writer.d.ts.map +1 -1
  6. package/dist/api/services/profile-writer.js +33 -36
  7. package/dist/api/services/profile-writer.js.map +1 -1
  8. package/dist/auth/profile-registry.d.ts.map +1 -1
  9. package/dist/auth/profile-registry.js +46 -48
  10. package/dist/auth/profile-registry.js.map +1 -1
  11. package/dist/bin/droid-runtime.d.ts +1 -0
  12. package/dist/bin/droid-runtime.d.ts.map +1 -0
  13. package/dist/bin/droid-runtime.js +5 -0
  14. package/dist/bin/droid-runtime.js.map +1 -0
  15. package/dist/cliproxy/account-manager.d.ts +1 -1
  16. package/dist/cliproxy/account-manager.d.ts.map +1 -1
  17. package/dist/cliproxy/account-manager.js +4 -1
  18. package/dist/cliproxy/account-manager.js.map +1 -1
  19. package/dist/cliproxy/accounts/index.d.ts +1 -1
  20. package/dist/cliproxy/accounts/index.d.ts.map +1 -1
  21. package/dist/cliproxy/accounts/index.js +4 -1
  22. package/dist/cliproxy/accounts/index.js.map +1 -1
  23. package/dist/cliproxy/accounts/query.d.ts.map +1 -1
  24. package/dist/cliproxy/accounts/query.js +4 -6
  25. package/dist/cliproxy/accounts/query.js.map +1 -1
  26. package/dist/cliproxy/accounts/registry.d.ts +2 -2
  27. package/dist/cliproxy/accounts/registry.d.ts.map +1 -1
  28. package/dist/cliproxy/accounts/registry.js +292 -320
  29. package/dist/cliproxy/accounts/registry.js.map +1 -1
  30. package/dist/cliproxy/accounts/token-file-ops.d.ts +16 -1
  31. package/dist/cliproxy/accounts/token-file-ops.d.ts.map +1 -1
  32. package/dist/cliproxy/accounts/token-file-ops.js +55 -3
  33. package/dist/cliproxy/accounts/token-file-ops.js.map +1 -1
  34. package/dist/cliproxy/ai-providers/config-store.d.ts.map +1 -1
  35. package/dist/cliproxy/ai-providers/config-store.js +37 -4
  36. package/dist/cliproxy/ai-providers/config-store.js.map +1 -1
  37. package/dist/cliproxy/ai-providers/service.d.ts +2 -2
  38. package/dist/cliproxy/ai-providers/service.d.ts.map +1 -1
  39. package/dist/cliproxy/ai-providers/service.js +39 -10
  40. package/dist/cliproxy/ai-providers/service.js.map +1 -1
  41. package/dist/cliproxy/ai-providers/types.d.ts +2 -0
  42. package/dist/cliproxy/ai-providers/types.d.ts.map +1 -1
  43. package/dist/cliproxy/ai-providers/types.js.map +1 -1
  44. package/dist/cliproxy/auth/oauth-handler.d.ts +1 -0
  45. package/dist/cliproxy/auth/oauth-handler.d.ts.map +1 -1
  46. package/dist/cliproxy/auth/oauth-handler.js +31 -69
  47. package/dist/cliproxy/auth/oauth-handler.js.map +1 -1
  48. package/dist/cliproxy/auth/oauth-process.d.ts +1 -0
  49. package/dist/cliproxy/auth/oauth-process.d.ts.map +1 -1
  50. package/dist/cliproxy/auth/oauth-process.js +5 -5
  51. package/dist/cliproxy/auth/oauth-process.js.map +1 -1
  52. package/dist/cliproxy/auth/token-manager.d.ts +1 -1
  53. package/dist/cliproxy/auth/token-manager.d.ts.map +1 -1
  54. package/dist/cliproxy/auth/token-manager.js +53 -20
  55. package/dist/cliproxy/auth/token-manager.js.map +1 -1
  56. package/dist/cliproxy/auth-token-manager.d.ts.map +1 -1
  57. package/dist/cliproxy/auth-token-manager.js +47 -50
  58. package/dist/cliproxy/auth-token-manager.js.map +1 -1
  59. package/dist/cliproxy/executor/index.js +1 -1
  60. package/dist/cliproxy/executor/index.js.map +1 -1
  61. package/dist/cliproxy/services/variant-config-adapter.d.ts.map +1 -1
  62. package/dist/cliproxy/services/variant-config-adapter.js +43 -39
  63. package/dist/cliproxy/services/variant-config-adapter.js.map +1 -1
  64. package/dist/commands/api-command/create-command.d.ts.map +1 -1
  65. package/dist/commands/api-command/create-command.js +8 -4
  66. package/dist/commands/api-command/create-command.js.map +1 -1
  67. package/dist/commands/cliproxy/proxy-lifecycle-subcommand.d.ts +0 -5
  68. package/dist/commands/cliproxy/proxy-lifecycle-subcommand.d.ts.map +1 -1
  69. package/dist/commands/cliproxy/proxy-lifecycle-subcommand.js +6 -16
  70. package/dist/commands/cliproxy/proxy-lifecycle-subcommand.js.map +1 -1
  71. package/dist/commands/cliproxy/resolve-lifecycle-port.d.ts +6 -0
  72. package/dist/commands/cliproxy/resolve-lifecycle-port.d.ts.map +1 -0
  73. package/dist/commands/cliproxy/resolve-lifecycle-port.js +15 -0
  74. package/dist/commands/cliproxy/resolve-lifecycle-port.js.map +1 -0
  75. package/dist/commands/cliproxy/variant-subcommand.d.ts.map +1 -1
  76. package/dist/commands/cliproxy/variant-subcommand.js +12 -6
  77. package/dist/commands/cliproxy/variant-subcommand.js.map +1 -1
  78. package/dist/commands/config-auth/disable-command.d.ts.map +1 -1
  79. package/dist/commands/config-auth/disable-command.js +8 -8
  80. package/dist/commands/config-auth/disable-command.js.map +1 -1
  81. package/dist/commands/config-auth/setup-command.d.ts.map +1 -1
  82. package/dist/commands/config-auth/setup-command.js +9 -11
  83. package/dist/commands/config-auth/setup-command.js.map +1 -1
  84. package/dist/commands/copilot-command.js +11 -11
  85. package/dist/commands/copilot-command.js.map +1 -1
  86. package/dist/commands/cursor-command.d.ts.map +1 -1
  87. package/dist/commands/cursor-command.js +11 -11
  88. package/dist/commands/cursor-command.js.map +1 -1
  89. package/dist/commands/help-command.d.ts.map +1 -1
  90. package/dist/commands/help-command.js +10 -8
  91. package/dist/commands/help-command.js.map +1 -1
  92. package/dist/commands/setup-command.d.ts.map +1 -1
  93. package/dist/commands/setup-command.js +4 -3
  94. package/dist/commands/setup-command.js.map +1 -1
  95. package/dist/config/unified-config-loader.d.ts +17 -1
  96. package/dist/config/unified-config-loader.d.ts.map +1 -1
  97. package/dist/config/unified-config-loader.js +95 -44
  98. package/dist/config/unified-config-loader.js.map +1 -1
  99. package/dist/config/unified-config-types.d.ts +56 -10
  100. package/dist/config/unified-config-types.d.ts.map +1 -1
  101. package/dist/config/unified-config-types.js +20 -2
  102. package/dist/config/unified-config-types.js.map +1 -1
  103. package/dist/targets/target-resolver.d.ts +2 -2
  104. package/dist/targets/target-resolver.d.ts.map +1 -1
  105. package/dist/targets/target-resolver.js +68 -18
  106. package/dist/targets/target-resolver.js.map +1 -1
  107. package/dist/ui/assets/{accounts-CccaoV-N.js → accounts-DD2Lodv2.js} +1 -1
  108. package/dist/ui/assets/{alert-dialog-D838sIju.js → alert-dialog-D21M1jKW.js} +1 -1
  109. package/dist/ui/assets/api-0PqftiRh.js +4 -0
  110. package/dist/ui/assets/{auth-section-BGCaHAcN.js → auth-section-DEfVaTF2.js} +1 -1
  111. package/dist/ui/assets/{backups-section-CqZN-2Qq.js → backups-section-7CMRUK1w.js} +1 -1
  112. package/dist/ui/assets/{checkbox-BgLi38k2.js → checkbox-qsMNLxyT.js} +1 -1
  113. package/dist/ui/assets/claude-extension-QCVnlD5g.js +1 -0
  114. package/dist/ui/assets/cliproxy-B4Ndh1vO.js +3 -0
  115. package/dist/ui/assets/{cliproxy-ai-providers-EhHqrkRr.js → cliproxy-ai-providers-D09jj99_.js} +12 -12
  116. package/dist/ui/assets/{cliproxy-control-panel-lRQBQhPS.js → cliproxy-control-panel-CJZ3OH7x.js} +1 -1
  117. package/dist/ui/assets/{confirm-dialog-t6i94F2B.js → confirm-dialog-DDPaIGt-.js} +1 -1
  118. package/dist/ui/assets/{copilot-DlSkTZ2q.js → copilot-CZ5-TuDW.js} +2 -2
  119. package/dist/ui/assets/cursor-CLCJ8JwP.js +1 -0
  120. package/dist/ui/assets/{droid-wevxXBVG.js → droid-C4ndg4ND.js} +2 -2
  121. package/dist/ui/assets/{globalenv-section-De072K_j.js → globalenv-section-u25Fhfko.js} +1 -1
  122. package/dist/ui/assets/{health-Wv80MRCF.js → health-S3_uVEZI.js} +1 -1
  123. package/dist/ui/assets/{icons-DMeZET56.js → icons-BwsSbo2z.js} +1 -1
  124. package/dist/ui/assets/index-BIWNdVva.js +47 -0
  125. package/dist/ui/assets/index-Bp4s-Led.css +1 -0
  126. package/dist/ui/assets/{index-BmB4ckDm.js → index-DW1sWpmn.js} +1 -1
  127. package/dist/ui/assets/index-DgtKMxaq.js +1 -0
  128. package/dist/ui/assets/{index-C9TiCNLM.js → index-DjUsD3ce.js} +1 -1
  129. package/dist/ui/assets/{index-CxPqnEpn.js → index-ainA13O4.js} +1 -1
  130. package/dist/ui/assets/{proxy-status-widget-DMe8konR.js → proxy-status-widget-D65cBYFv.js} +1 -1
  131. package/dist/ui/assets/{searchable-select-C-dUgzQ_.js → searchable-select-C2HgCDJL.js} +1 -1
  132. package/dist/ui/assets/{separator-TnQMGoEt.js → separator-BlhCtc9l.js} +1 -1
  133. package/dist/ui/assets/{shared-Cbcz8ZIu.js → shared-DZkW1mRU.js} +1 -1
  134. package/dist/ui/assets/{switch-Df15Gmz9.js → switch-JdcUdtbh.js} +1 -1
  135. package/dist/ui/assets/{updates-WOEYNHTJ.js → updates-DtnC6jcH.js} +1 -1
  136. package/dist/ui/index.html +3 -3
  137. package/dist/utils/websearch/hook-env.d.ts.map +1 -1
  138. package/dist/utils/websearch/hook-env.js +17 -1
  139. package/dist/utils/websearch/hook-env.js.map +1 -1
  140. package/dist/utils/websearch/status.d.ts +5 -12
  141. package/dist/utils/websearch/status.d.ts.map +1 -1
  142. package/dist/utils/websearch/status.js +128 -87
  143. package/dist/utils/websearch/status.js.map +1 -1
  144. package/dist/utils/websearch/types.d.ts +37 -23
  145. package/dist/utils/websearch/types.d.ts.map +1 -1
  146. package/dist/utils/websearch/types.js +1 -1
  147. package/dist/utils/websearch-manager.d.ts +5 -4
  148. package/dist/utils/websearch-manager.d.ts.map +1 -1
  149. package/dist/utils/websearch-manager.js +5 -4
  150. package/dist/utils/websearch-manager.js.map +1 -1
  151. package/dist/web-server/health/websearch-checks.d.ts +2 -2
  152. package/dist/web-server/health/websearch-checks.d.ts.map +1 -1
  153. package/dist/web-server/health/websearch-checks.js +9 -11
  154. package/dist/web-server/health/websearch-checks.js.map +1 -1
  155. package/dist/web-server/health-service.d.ts.map +1 -1
  156. package/dist/web-server/health-service.js +2 -3
  157. package/dist/web-server/health-service.js.map +1 -1
  158. package/dist/web-server/middleware/auth-middleware.d.ts +2 -0
  159. package/dist/web-server/middleware/auth-middleware.d.ts.map +1 -1
  160. package/dist/web-server/middleware/auth-middleware.js +23 -1
  161. package/dist/web-server/middleware/auth-middleware.js.map +1 -1
  162. package/dist/web-server/routes/ai-provider-routes.d.ts.map +1 -1
  163. package/dist/web-server/routes/ai-provider-routes.js +19 -13
  164. package/dist/web-server/routes/ai-provider-routes.js.map +1 -1
  165. package/dist/web-server/routes/cliproxy-auth-routes.d.ts +7 -0
  166. package/dist/web-server/routes/cliproxy-auth-routes.d.ts.map +1 -1
  167. package/dist/web-server/routes/cliproxy-auth-routes.js +225 -32
  168. package/dist/web-server/routes/cliproxy-auth-routes.js.map +1 -1
  169. package/dist/web-server/routes/cliproxy-stats-routes.d.ts.map +1 -1
  170. package/dist/web-server/routes/cliproxy-stats-routes.js +6 -0
  171. package/dist/web-server/routes/cliproxy-stats-routes.js.map +1 -1
  172. package/dist/web-server/routes/cliproxy-sync-routes.d.ts.map +1 -1
  173. package/dist/web-server/routes/cliproxy-sync-routes.js +6 -11
  174. package/dist/web-server/routes/cliproxy-sync-routes.js.map +1 -1
  175. package/dist/web-server/routes/cursor-settings-routes.d.ts.map +1 -1
  176. package/dist/web-server/routes/cursor-settings-routes.js +36 -33
  177. package/dist/web-server/routes/cursor-settings-routes.js.map +1 -1
  178. package/dist/web-server/routes/misc-routes.d.ts.map +1 -1
  179. package/dist/web-server/routes/misc-routes.js +26 -19
  180. package/dist/web-server/routes/misc-routes.js.map +1 -1
  181. package/dist/web-server/routes/proxy-routes.d.ts.map +1 -1
  182. package/dist/web-server/routes/proxy-routes.js +6 -0
  183. package/dist/web-server/routes/proxy-routes.js.map +1 -1
  184. package/dist/web-server/routes/settings-routes.d.ts.map +1 -1
  185. package/dist/web-server/routes/settings-routes.js +143 -109
  186. package/dist/web-server/routes/settings-routes.js.map +1 -1
  187. package/dist/web-server/routes/websearch-routes.d.ts.map +1 -1
  188. package/dist/web-server/routes/websearch-routes.js +63 -64
  189. package/dist/web-server/routes/websearch-routes.js.map +1 -1
  190. package/dist/web-server/shared-routes.d.ts.map +1 -1
  191. package/dist/web-server/shared-routes.js +6 -0
  192. package/dist/web-server/shared-routes.js.map +1 -1
  193. package/lib/hooks/websearch-transformer.cjs +488 -462
  194. package/package.json +3 -2
  195. package/scripts/add-shebang.js +33 -20
  196. package/scripts/dev-release.sh +103 -51
  197. package/dist/ui/assets/api-IXigV-A_.js +0 -4
  198. package/dist/ui/assets/claude-extension-ClHnH_4i.js +0 -1
  199. package/dist/ui/assets/cliproxy-qX23viWV.js +0 -3
  200. package/dist/ui/assets/cursor-DJvTEVHh.js +0 -1
  201. package/dist/ui/assets/index-BqdBnk5l.js +0 -1
  202. package/dist/ui/assets/index-DRmZP4OP.css +0 -1
  203. package/dist/ui/assets/index-N_jd9sKU.js +0 -47
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kaitranntt/ccs",
3
- "version": "7.56.0",
3
+ "version": "7.57.0",
4
4
  "description": "Claude Code Switch - Instant profile switching between Claude, GLM, Kimi, and more",
5
5
  "keywords": [
6
6
  "cli",
@@ -27,7 +27,8 @@
27
27
  "types": "dist/ccs.d.ts",
28
28
  "bin": {
29
29
  "ccs": "dist/ccs.js",
30
- "ccsd": "dist/ccs.js"
30
+ "ccs-droid": "dist/bin/droid-runtime.js",
31
+ "ccsd": "dist/bin/droid-runtime.js"
31
32
  },
32
33
  "files": [
33
34
  "dist/",
@@ -4,36 +4,49 @@
4
4
  const fs = require('fs');
5
5
  const path = require('path');
6
6
 
7
+ function getExecutablePaths() {
8
+ const packageJsonPath = path.join(__dirname, '../package.json');
9
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
10
+ const binEntries = packageJson.bin || {};
11
+ const uniqueRelativePaths = [...new Set(Object.values(binEntries))];
12
+
13
+ return uniqueRelativePaths.map((relativePath) => path.join(__dirname, '..', relativePath));
14
+ }
15
+
7
16
  /**
8
- * Add shebang to dist/ccs.js and make executable
17
+ * Add shebangs to all published bin entrypoints and make them executable.
9
18
  * Run after: tsc
10
19
  */
11
20
  function addShebang() {
12
- const ccsPath = path.join(__dirname, '../dist/ccs.js');
13
-
14
- if (!fs.existsSync(ccsPath)) {
15
- console.error('[X] dist/ccs.js not found. Run tsc first.');
21
+ const executablePaths = getExecutablePaths();
22
+ const missingPaths = executablePaths.filter((executablePath) => !fs.existsSync(executablePath));
23
+ if (missingPaths.length > 0) {
24
+ console.error(`[X] Missing built executable(s): ${missingPaths.join(', ')}. Run tsc first.`);
16
25
  process.exit(1);
17
26
  }
18
27
 
19
- let content = fs.readFileSync(ccsPath, 'utf8');
28
+ for (const executablePath of executablePaths) {
29
+ let content = fs.readFileSync(executablePath, 'utf8');
20
30
 
21
- // Add shebang if missing
22
- if (!content.startsWith('#!/usr/bin/env node')) {
23
- content = '#!/usr/bin/env node\n' + content;
24
- fs.writeFileSync(ccsPath, content);
25
- console.log('[OK] Shebang added to dist/ccs.js');
26
- }
31
+ if (!content.startsWith('#!/usr/bin/env node')) {
32
+ content = '#!/usr/bin/env node\n' + content;
33
+ fs.writeFileSync(executablePath, content);
34
+ console.log(`[OK] Shebang added to ${path.relative(path.join(__dirname, '..'), executablePath)}`);
35
+ }
27
36
 
28
- // Make executable (Unix-like systems)
29
- if (process.platform !== 'win32') {
30
- try {
31
- fs.chmodSync(ccsPath, 0o755);
32
- console.log('[OK] dist/ccs.js is now executable');
33
- } catch (err) {
34
- console.warn('[!] Could not chmod dist/ccs.js:', err.message);
37
+ if (process.platform !== 'win32') {
38
+ try {
39
+ fs.chmodSync(executablePath, 0o755);
40
+ console.log(
41
+ `[OK] ${path.relative(path.join(__dirname, '..'), executablePath)} is now executable`
42
+ );
43
+ } catch (err) {
44
+ console.warn(
45
+ `[!] Could not chmod ${path.relative(path.join(__dirname, '..'), executablePath)}: ${err.message}`
46
+ );
47
+ }
35
48
  }
36
49
  }
37
50
  }
38
51
 
39
- addShebang();
52
+ addShebang();
@@ -26,8 +26,8 @@ log_info() { echo -e "${GREEN}[i]${NC} $1"; }
26
26
  log_warn() { echo -e "${YELLOW}[!]${NC} $1"; }
27
27
  log_error() { echo -e "${RED}[X]${NC} $1"; }
28
28
 
29
- # Ensure we have the latest tags
30
- git fetch --tags origin main
29
+ # Ensure we have the latest tags and branch refs
30
+ git fetch --tags origin main dev
31
31
 
32
32
  # Get latest stable tag from main (exclude prereleases like -dev, -beta, -rc)
33
33
  # Match only clean semver tags: vX.Y.Z
@@ -39,58 +39,100 @@ if [ -z "$STABLE_TAG" ]; then
39
39
  fi
40
40
 
41
41
  STABLE=${STABLE_TAG#v}
42
- log_info "Current stable version: ${STABLE}"
42
+ CURRENT_VERSION=$(jq -r '.version' package.json)
43
+ HEAD_SUBJECT=$(git log -1 --pretty=%s 2>/dev/null || echo "")
44
+ DEV_VERSION_REGEX="^${STABLE//./\\.}-dev\\.[0-9]+$"
45
+ PREVIOUS_DEV_TAG=""
46
+ RECOVERY_MODE=false
43
47
 
44
- # Find latest dev tag for this stable version
45
- LATEST_DEV=$(git tag -l "v${STABLE}-dev.*" --sort=-v:refname | head -1 || echo "")
48
+ log_info "Current stable version: ${STABLE}"
46
49
 
47
- # Calculate next dev number
48
- if [ -z "$LATEST_DEV" ]; then
49
- DEV_NUM=1
50
- log_info "No existing dev tags for ${STABLE}, starting at dev.1"
50
+ if [[ "$CURRENT_VERSION" =~ $DEV_VERSION_REGEX ]] && [[ "$HEAD_SUBJECT" == "chore(release): ${CURRENT_VERSION} [skip ci]" ]]; then
51
+ VERSION="$CURRENT_VERSION"
52
+ CURRENT_TAG="v${VERSION}"
53
+ PREVIOUS_DEV_TAG=$(git tag -l "v${STABLE}-dev.*" --sort=-v:refname | grep -vx "$CURRENT_TAG" | head -1 || echo "")
54
+ RECOVERY_MODE=true
55
+ log_warn "Recovery mode for ${VERSION}"
56
+
57
+ if git rev-parse "${CURRENT_TAG}" >/dev/null 2>&1; then
58
+ TAG_COMMIT=$(git rev-parse "${CURRENT_TAG}^{commit}")
59
+ HEAD_COMMIT=$(git rev-parse HEAD)
60
+ if [[ "$TAG_COMMIT" != "$HEAD_COMMIT" ]]; then
61
+ log_error "Tag ${CURRENT_TAG} exists but does not point to HEAD"
62
+ exit 1
63
+ fi
64
+ log_info "Reusing existing tag ${CURRENT_TAG}"
65
+ else
66
+ git tag "${CURRENT_TAG}"
67
+ log_warn "Recreated missing tag ${CURRENT_TAG} on release commit"
68
+ fi
51
69
  else
52
- DEV_NUM=$(echo "$LATEST_DEV" | sed 's/.*dev\.\([0-9]*\)/\1/')
53
- DEV_NUM=$((DEV_NUM + 1))
54
- log_info "Latest dev tag: ${LATEST_DEV}, incrementing to dev.${DEV_NUM}"
70
+ # Find latest dev tag for this stable version
71
+ LATEST_DEV=$(git tag -l "v${STABLE}-dev.*" --sort=-v:refname | head -1 || echo "")
72
+ PREVIOUS_DEV_TAG="$LATEST_DEV"
73
+
74
+ # Calculate next dev number
75
+ if [ -z "$LATEST_DEV" ]; then
76
+ DEV_NUM=1
77
+ log_info "No existing dev tags for ${STABLE}, starting at dev.1"
78
+ else
79
+ DEV_NUM=$(echo "$LATEST_DEV" | sed 's/.*dev\.\([0-9]*\)/\1/')
80
+ DEV_NUM=$((DEV_NUM + 1))
81
+ log_info "Latest dev tag: ${LATEST_DEV}, incrementing to dev.${DEV_NUM}"
82
+ fi
83
+
84
+ VERSION="${STABLE}-dev.${DEV_NUM}"
85
+ CURRENT_TAG="v${VERSION}"
86
+ log_info "New version: ${VERSION}"
87
+
88
+ # Check if tag already exists (safety check)
89
+ if git rev-parse "${CURRENT_TAG}" >/dev/null 2>&1; then
90
+ log_error "Tag ${CURRENT_TAG} already exists!"
91
+ exit 1
92
+ fi
93
+
94
+ # Update package.json
95
+ npm version "$VERSION" --no-git-tag-version
96
+ log_info "Updated package.json to ${VERSION}"
97
+
98
+ # Configure git for GitHub Actions
99
+ git config user.name "github-actions[bot]"
100
+ git config user.email "github-actions[bot]@users.noreply.github.com"
101
+
102
+ # Commit version change
103
+ git add package.json
104
+ git commit -m "chore(release): ${VERSION} [skip ci]"
105
+ log_info "Created release commit"
106
+
107
+ # Create tag
108
+ git tag "${CURRENT_TAG}"
109
+ log_info "Created tag ${CURRENT_TAG}"
55
110
  fi
56
111
 
57
- VERSION="${STABLE}-dev.${DEV_NUM}"
58
- log_info "New version: ${VERSION}"
59
-
60
- # Check if tag already exists (safety check)
61
- if git rev-parse "v${VERSION}" >/dev/null 2>&1; then
62
- log_error "Tag v${VERSION} already exists!"
63
- exit 1
112
+ PACKAGE_NAME=$(jq -r '.name' package.json)
113
+ if npm view "${PACKAGE_NAME}@${VERSION}" version >/dev/null 2>&1; then
114
+ log_info "npm already has ${PACKAGE_NAME}@${VERSION}, skipping publish"
115
+ else
116
+ npm publish --tag dev
117
+ log_info "Published to npm with @dev tag"
64
118
  fi
65
119
 
66
- # Update package.json
67
- npm version "$VERSION" --no-git-tag-version
68
- log_info "Updated package.json to ${VERSION}"
69
-
70
- # Configure git for GitHub Actions
71
- git config user.name "github-actions[bot]"
72
- git config user.email "github-actions[bot]@users.noreply.github.com"
73
-
74
- # Commit version change
75
- git add package.json
76
- git commit -m "chore(release): ${VERSION} [skip ci]"
77
- log_info "Created release commit"
78
-
79
- # Create tag
80
- git tag "v${VERSION}"
81
- log_info "Created tag v${VERSION}"
82
-
83
- # Push commit and tag
84
- git push origin dev
85
- git push origin "v${VERSION}"
86
- log_info "Pushed to origin"
120
+ if git merge-base --is-ancestor HEAD origin/dev >/dev/null 2>&1; then
121
+ log_info "origin/dev already contains release commit"
122
+ else
123
+ git push origin HEAD:dev
124
+ log_info "Pushed release commit to origin/dev"
125
+ fi
87
126
 
88
- # Publish to npm with dev tag
89
- npm publish --tag dev
90
- log_info "Published to npm with @dev tag"
127
+ if git ls-remote --exit-code --tags origin "refs/tags/${CURRENT_TAG}" >/dev/null 2>&1; then
128
+ log_info "Remote tag ${CURRENT_TAG} already exists"
129
+ else
130
+ git push origin "${CURRENT_TAG}"
131
+ log_info "Pushed tag ${CURRENT_TAG}"
132
+ fi
91
133
 
92
134
  # Generate release notes from commits since last tag
93
- PREV_TAG=$(git tag -l "v*" --sort=-v:refname | sed -n '2p' || echo "")
135
+ PREV_TAG="${PREVIOUS_DEV_TAG:-$STABLE_TAG}"
94
136
  if [ -n "$PREV_TAG" ]; then
95
137
  # Get commits between previous tag and the one before our release commit
96
138
  NOTES=$(git log --pretty=format:"- %s" "${PREV_TAG}..HEAD~1" 2>/dev/null | grep -v "chore(release):" | head -15 || echo "- Dev release")
@@ -99,12 +141,16 @@ else
99
141
  fi
100
142
 
101
143
  # Create GitHub prerelease
102
- gh release create "v${VERSION}" \
103
- --title "v${VERSION}" \
104
- --notes "${NOTES}" \
105
- --prerelease
144
+ if gh release view "${CURRENT_TAG}" >/dev/null 2>&1; then
145
+ log_info "GitHub prerelease ${CURRENT_TAG} already exists"
146
+ else
147
+ gh release create "${CURRENT_TAG}" \
148
+ --title "${CURRENT_TAG}" \
149
+ --notes "${NOTES}" \
150
+ --prerelease
106
151
 
107
- log_info "Created GitHub prerelease"
152
+ log_info "Created GitHub prerelease"
153
+ fi
108
154
 
109
155
  # Save release info for Discord notification
110
156
  # This file is read by send-discord-release.cjs for dev releases
@@ -117,7 +163,13 @@ EOF
117
163
  log_info "Saved release info for Discord notification"
118
164
 
119
165
  # Output for GitHub Actions
120
- echo "version=${VERSION}" >> "${GITHUB_OUTPUT:-/dev/null}"
121
- echo "released=true" >> "${GITHUB_OUTPUT:-/dev/null}"
166
+ {
167
+ echo "current_tag=${CURRENT_TAG}"
168
+ echo "previous_dev_tag=${PREVIOUS_DEV_TAG}"
169
+ echo "recovery_mode=${RECOVERY_MODE}"
170
+ echo "released=true"
171
+ echo "stable_tag=${STABLE_TAG}"
172
+ echo "version=${VERSION}"
173
+ } >> "${GITHUB_OUTPUT:-/dev/null}"
122
174
 
123
175
  log_info "Dev release ${VERSION} complete!"
@@ -1,4 +0,0 @@
1
- import{j as e}from"./radix-ui-Dt3edmE5.js";import{r as m,h as Qe}from"./react-vendor-CNOkPC89.js";import{B as A,c as D,T as Je,p as Be,q as qe,r as Ve,s as Ye,t as Ge,v as We,w as fe,d as p,I as _,a as q,n as ne,L as E,x as B,y as Ee,z as Xe,A as Ze,D as es,E as ss,S as je,F as se,G as xe,H as Te,J as ts,K as as,M as Se,N as Ae,O as _e,Q as rs,R as ns,U as Ne,V as ve,W as te,X as is,Y as ls,Z as pe,C as ie,j as le,k as oe,_ as ce,b as de,$ as os,a0 as cs,a1 as ds,a2 as ms,a3 as xs,a4 as us,a5 as hs,a6 as ps,a7 as gs}from"./index-N_jd9sKU.js";import{a as fs,u as js,b as be}from"./tanstack-B8i0evp-.js";import{C as ue}from"./confirm-dialog-t6i94F2B.js";import{t as P}from"./notifications-B2HqRBj7.js";import{L as ae,R as X,ai as Re,aj as Ns,E as vs,f as bs,a3 as re,O as ws,ak as Me,a4 as ge,C as De,al as Cs,a2 as ys,am as ks,o as he,X as Ps,Z as Le,an as me,ao as Ie,m as we,ap as Ce,a6 as Os,aq as Es,x as Ue,ar as Ts,v as Fe,n as Ss,as as As}from"./icons-DMeZET56.js";import{S as ye}from"./separator-TnQMGoEt.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";import"./alert-dialog-D838sIju.js";function _s({className:s,showTooltip:a=!0}){const n=e.jsxs(A,{variant:"outline",className:D("bg-accent/10 border-accent/30 text-accent","dark:bg-accent/20 dark:border-accent/40 dark:text-accent-foreground",s),children:[e.jsx("img",{src:"/icons/openrouter.svg",alt:"OpenRouter",className:"mr-1 h-3 w-3"}),"OpenRouter"]});return a?e.jsxs(Je,{children:[e.jsx(Be,{asChild:!0,children:n}),e.jsx(qe,{children:e.jsx("p",{children:"Access 349+ models via OpenRouter"})})]}):n}function ke(s){return[/^ANTHROPIC_AUTH_TOKEN$/,/_API_KEY$/,/_AUTH_TOKEN$/,/^API_KEY$/,/^AUTH_TOKEN$/,/_SECRET$/,/^SECRET$/].some(n=>n.test(s))}function He(s){return s?.env?(s.env.ANTHROPIC_BASE_URL||"").toLowerCase().includes("openrouter.ai"):!1}function Rs(s){return{opus:s.ANTHROPIC_DEFAULT_OPUS_MODEL||void 0,sonnet:s.ANTHROPIC_DEFAULT_SONNET_MODEL||void 0,haiku:s.ANTHROPIC_DEFAULT_HAIKU_MODEL||void 0}}function Ms(s,a){const n={...s};return a.opus?n.ANTHROPIC_DEFAULT_OPUS_MODEL=a.opus:delete n.ANTHROPIC_DEFAULT_OPUS_MODEL,a.sonnet?n.ANTHROPIC_DEFAULT_SONNET_MODEL=a.sonnet:delete n.ANTHROPIC_DEFAULT_SONNET_MODEL,a.haiku?n.ANTHROPIC_DEFAULT_HAIKU_MODEL=a.haiku:delete n.ANTHROPIC_DEFAULT_HAIKU_MODEL,n}function Ds({profileName:s,target:a,data:n,settings:c,isLoading:t,isSaving:g,isTargetSaving:h,hasChanges:f,isRawJsonValid:r,onTargetChange:j,onRefresh:u,onDelete:y,onSave:v}){const k=g||h,N=t||k;return e.jsxs("div",{className:"px-6 py-4 border-b bg-background flex items-center justify-between shrink-0",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold",children:s}),n?.path&&e.jsx(A,{variant:"outline",className:"text-xs",children:n.path.replace(/^.*\//,"")}),He(c)&&e.jsx(_s,{className:"ml-1"})]}),n&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-0.5",children:["Last modified: ",new Date(n.mtime).toLocaleString()]}),e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"Default target:"}),e.jsxs(Ve,{value:a,onValueChange:O=>{N||j(O)},disabled:N,children:[e.jsx(Ye,{className:"h-7 w-[170px] text-xs",disabled:N,children:e.jsx(Ge,{})}),e.jsxs(We,{children:[e.jsx(fe,{value:"claude",children:"Claude Code"}),e.jsx(fe,{value:"droid",children:"Factory Droid"})]})]}),h&&e.jsx(ae,{className:"w-3.5 h-3.5 animate-spin text-muted-foreground"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(p,{variant:"ghost",size:"sm",onClick:u,disabled:N,children:e.jsx(X,{className:`w-4 h-4 ${t?"animate-spin":""}`})}),y&&e.jsx(p,{variant:"ghost",size:"sm",onClick:y,disabled:k,children:e.jsx(Re,{className:"w-4 h-4 text-destructive"})}),e.jsx(p,{size:"sm",onClick:v,disabled:k||!f||!r,children:g?e.jsxs(e.Fragment,{children:[e.jsx(ae,{className:"w-4 h-4 mr-1 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Ns,{className:"w-4 h-4 mr-1"}),"Save"]})})]})]})}function ze({label:s,...a}){const[n,c]=m.useState(!1);return e.jsxs("div",{className:"space-y-1",children:[s&&e.jsx("label",{className:"text-sm font-medium",children:s}),e.jsxs("div",{className:"relative",children:[e.jsx(_,{type:n?"text":"password",className:"pr-10 font-mono",...a}),e.jsx(p,{type:"button",variant:"ghost",size:"sm",className:"absolute right-0 top-0 h-full px-3",onClick:()=>c(!n),tabIndex:-1,children:n?e.jsx(vs,{className:"w-4 h-4"}):e.jsx(bs,{className:"w-4 h-4"})})]})]})}function Ls({currentSettings:s,newEnvKey:a,newEnvValue:n,onNewEnvKeyChange:c,onNewEnvValueChange:t,onEnvValueChange:g,onAddEnvVar:h}){const{t:f}=q();return e.jsxs(e.Fragment,{children:[e.jsx(ne,{className:"flex-1",children:e.jsx("div",{className:"p-4 space-y-4",children:s?.env&&Object.keys(s.env).length>0?e.jsx(e.Fragment,{children:Object.entries(s.env).map(([r,j])=>e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(E,{className:"text-xs font-medium flex items-center gap-2 text-muted-foreground",children:[r,ke(r)&&e.jsx(A,{variant:"secondary",className:"text-[10px] px-1 py-0 h-4",children:f("envEditor.sensitive")})]}),ke(r)?e.jsx(ze,{value:j,onChange:u=>g(r,u.target.value),className:"font-mono text-sm h-8"}):e.jsx(_,{value:j,onChange:u=>g(r,u.target.value),className:"font-mono text-sm h-8"})]},r))}):e.jsxs("div",{className:"py-8 text-center text-muted-foreground bg-muted/30 rounded-lg border border-dashed text-sm",children:[e.jsx("p",{children:f("envEditor.none")}),e.jsx("p",{className:"text-xs mt-1 opacity-70",children:f("envEditor.noneHint")})]})})}),e.jsxs("div",{className:"p-4 border-t bg-background shrink-0",children:[e.jsx(E,{className:"text-xs font-medium text-muted-foreground",children:f("envEditor.addVariable")}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(_,{placeholder:f("envEditor.keyPlaceholder"),value:a,onChange:r=>c(r.target.value.toUpperCase()),className:"font-mono text-sm h-8 w-2/5",onKeyDown:r=>r.key==="Enter"&&a.trim()&&h()}),e.jsx(_,{placeholder:f("envEditor.valuePlaceholder"),value:n,onChange:r=>t(r.target.value),className:"font-mono text-sm h-8 flex-1",onKeyDown:r=>r.key==="Enter"&&a.trim()&&h()}),e.jsx(p,{variant:"outline",size:"sm",className:"h-8",onClick:h,disabled:!a.trim(),children:e.jsx(re,{className:"w-4 h-4"})})]})]})]})}function Is({profileName:s,target:a,data:n}){const{t:c}=q(),t=a==="droid";return e.jsx(ne,{className:"h-full",children:e.jsxs("div",{className:"p-4 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"text-sm font-medium flex items-center gap-2 mb-3",children:[e.jsx(ws,{className:"w-4 h-4"}),c("profileEditor.profileInfo")]}),e.jsx("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:n&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:c("profileEditor.profileName")}),e.jsx("span",{className:"font-mono",children:n.profile})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:c("profileEditor.filePath")}),e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("code",{className:"bg-muted px-1.5 py-0.5 rounded text-xs break-all",children:n.path}),e.jsx(B,{value:n.path,size:"icon",className:"h-5 w-5"})]})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:c("profileEditor.lastModified")}),e.jsx("span",{className:"text-xs",children:new Date(n.mtime).toLocaleString()})]}),e.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2 text-sm items-center",children:[e.jsx("span",{className:"font-medium text-muted-foreground",children:c("profileEditor.defaultTarget")}),e.jsx("span",{className:"font-mono",children:a})]})]})})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-sm font-medium mb-3",children:c("profileEditor.quickUsage")}),e.jsxs("div",{className:"space-y-3 bg-card rounded-lg border p-4 shadow-sm",children:[e.jsxs("div",{children:[e.jsx(E,{className:"text-xs text-muted-foreground",children:c("profileEditor.runWithProfile")}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsxs("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:["ccs ",s,' "prompt"']}),e.jsx(B,{value:`ccs ${s} "prompt"`,size:"icon",className:"h-6 w-6"})]})]}),e.jsxs("div",{children:[e.jsx(E,{className:"text-xs text-muted-foreground",children:c(t?"profileEditor.droidAliasExplicit":"profileEditor.runOnDroid")}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsx("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:t?`ccsd ${s} "prompt"`:`ccs ${s} --target droid "prompt"`}),e.jsx(B,{value:t?`ccsd ${s} "prompt"`:`ccs ${s} --target droid "prompt"`,size:"icon",className:"h-6 w-6"})]})]}),e.jsxs("div",{children:[e.jsx(E,{className:"text-xs text-muted-foreground",children:c(t?"profileEditor.overrideToClaude":"profileEditor.overrideToClaudeExplicit")}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsxs("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:["ccs ",s,' --target claude "prompt"']}),e.jsx(B,{value:`ccs ${s} --target claude "prompt"`,size:"icon",className:"h-6 w-6"})]})]}),e.jsxs("div",{children:[e.jsx(E,{className:"text-xs text-muted-foreground",children:c("profileEditor.setAsDefault")}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsxs("code",{className:"flex-1 px-2 py-1.5 bg-muted rounded text-xs font-mono truncate",children:["ccs default ",s]}),e.jsx(B,{value:`ccs default ${s}`,size:"icon",className:"h-6 w-6"})]})]})]})]})]})})}function Us({value:s,onChange:a,placeholder:n="Search models...",className:c}){const[t,g]=m.useState(""),[h,f]=m.useState(null),{models:r,isLoading:j,isError:u,isFetching:y}=Ee(),v=Xe(),k=m.useMemo(()=>Ze(r,t,{category:h??void 0}),[r,t,h]),N=m.useMemo(()=>es(r,2),[r]),O=!t.trim()&&!h,U=m.useMemo(()=>{const o={anthropic:[],openai:[],google:[],meta:[],mistral:[],opensource:[],other:[]};k.forEach(x=>{o[x.category].push(x)});for(const x of Object.keys(o))o[x]=ss(o[x]);return o},[k]),b=m.useCallback(()=>{v()},[v]),T=r.find(o=>o.id===s);return j&&r.length===0?e.jsxs("div",{className:D("space-y-2",c),children:[e.jsx(je,{className:"h-10 w-full"}),e.jsx(je,{className:"h-32 w-full"})]}):e.jsxs("div",{className:D("space-y-2 w-full min-w-0 overflow-hidden",c),children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(Me,{className:"text-muted-foreground absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2"}),e.jsx(_,{value:t,onChange:o=>g(o.target.value),placeholder:n,className:"pl-9"})]}),e.jsx(p,{variant:"outline",size:"icon",onClick:b,disabled:y,title:"Refresh models",children:y?e.jsx(ae,{className:"h-4 w-4 animate-spin"}):e.jsx(X,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex flex-wrap gap-1",children:[e.jsxs(A,{variant:h===null?"default":"outline",className:"cursor-pointer",onClick:()=>f(null),children:["All (",r.length,")"]}),Object.keys(se).map(o=>{const x=U[o].length;return x===0?null:e.jsxs(A,{variant:h===o?"default":"outline",className:"cursor-pointer",onClick:()=>f(o),children:[se[o]," (",x,")"]},o)})]}),T&&e.jsxs("div",{className:"bg-muted rounded-md p-2 text-sm",children:[e.jsx("span",{className:"font-medium",children:T.name}),e.jsxs("span",{className:"text-muted-foreground ml-2",children:[xe(T.pricing)," |"," ",Te(T.context_length)]})]}),e.jsx(ne,{className:"h-72 w-full rounded-md border",children:u?e.jsxs("div",{className:"text-destructive p-4 text-center",children:["Failed to load models."," ",e.jsx(p,{variant:"link",onClick:b,children:"Retry"})]}):k.length===0?e.jsxs("div",{className:"text-muted-foreground p-4 text-center",children:['No models found matching "',t,'"']}):e.jsxs("div",{className:"space-y-6 p-3",children:[O&&N.length>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"text-muted-foreground bg-background sticky top-0 mb-2 flex items-center gap-1.5 py-1.5 text-xs font-semibold border-b pb-2",children:[e.jsx(ge,{className:"h-3 w-3 text-accent"}),e.jsx("span",{children:"Newest Models"})]}),e.jsx("div",{className:"space-y-1",children:N.map(o=>e.jsx(Pe,{model:o,isSelected:o.id===s,onClick:()=>a(o.id),showAge:!0},o.id))})]}),Object.keys(se).map(o=>{const x=U[o];return x.length===0?null:e.jsxs("div",{children:[e.jsx("div",{className:"text-muted-foreground bg-background sticky top-0 mb-2 py-1.5 text-xs font-semibold border-b pb-2",children:se[o]}),e.jsx("div",{className:"space-y-1",children:x.map(i=>e.jsx(Pe,{model:i,isSelected:i.id===s,onClick:()=>a(i.id)},i.id))})]},o)})]})})]})}function Pe({model:s,isSelected:a,onClick:n,showAge:c=!1}){return e.jsxs("button",{type:"button",onClick:n,className:D("group flex w-full items-center gap-2 rounded-md px-3 py-2 text-left text-sm transition-colors","hover:bg-accent hover:text-accent-foreground",a&&"bg-accent text-accent-foreground"),children:[e.jsx("span",{className:"flex-1 min-w-0 truncate font-medium",children:s.name}),e.jsxs("span",{className:D("flex shrink-0 items-center gap-1 text-xs whitespace-nowrap",a?"text-accent-foreground/80":"text-muted-foreground group-hover:text-accent-foreground/80"),children:[c&&s.created&&e.jsx(A,{variant:"outline",className:D("text-[10px] px-1",a?"border-accent-foreground/30 text-accent-foreground/80":"text-accent border-accent/30 group-hover:text-accent-foreground/80 group-hover:border-accent-foreground/30"),children:ts(s.created)}),s.isFree?e.jsx(A,{variant:"secondary",className:D("text-[10px] px-1",a?"bg-accent-foreground/20 text-accent-foreground":"group-hover:bg-accent-foreground/20 group-hover:text-accent-foreground"),children:"Free"}):s.isExacto?e.jsxs(e.Fragment,{children:[e.jsx(A,{variant:"outline",className:D("text-[10px] px-1 border-emerald-500/50 text-emerald-600",a?"border-accent-foreground/30 text-accent-foreground/80":"group-hover:border-accent-foreground/30 group-hover:text-accent-foreground/80"),children:"Exacto"}),e.jsx("span",{className:"tabular-nums",children:xe(s.pricing)})]}):e.jsx("span",{className:"tabular-nums",children:xe(s.pricing)}),e.jsx("span",{className:"tabular-nums",children:Te(s.context_length)})]})]})}function Fs({selectedModel:s,value:a,onChange:n,className:c}){const{t}=q(),{models:g}=Ee(),h=m.useMemo(()=>s?as(s,g):{},[s,g]),f=()=>{n(h)},r=(u,y)=>{n({...a,[u]:y||void 0})},j=s&&Object.keys(h).length>0;return e.jsxs(Se,{className:D("group",c),children:[e.jsxs(Ae,{className:"flex items-center gap-2 text-sm font-medium hover:underline",children:[e.jsx(De,{className:"h-4 w-4 transition-transform group-data-[state=open]:rotate-90"}),t("modelTierMapping.title"),e.jsxs("span",{className:"text-muted-foreground font-normal",children:["(",t("modelTierMapping.advanced"),")"]})]}),e.jsxs(_e,{className:"space-y-3 pt-3",children:[e.jsx("p",{className:"text-muted-foreground text-sm",children:t("modelTierMapping.description")}),j&&e.jsxs(p,{type:"button",variant:"outline",size:"sm",onClick:f,children:[e.jsx(Cs,{className:"mr-1 h-4 w-4"}),t("modelTierMapping.autoSuggest",{provider:s?.split("/")[0]})]}),e.jsxs("div",{className:"grid gap-3",children:[e.jsxs("div",{className:"grid grid-cols-[80px_1fr] items-center gap-2",children:[e.jsx(E,{htmlFor:"tier-opus",className:"text-right",children:"Opus"}),e.jsx(_,{id:"tier-opus",value:a.opus??"",onChange:u=>r("opus",u.target.value),placeholder:t("modelTierMapping.opusPlaceholder")})]}),e.jsxs("div",{className:"grid grid-cols-[80px_1fr] items-center gap-2",children:[e.jsx(E,{htmlFor:"tier-sonnet",className:"text-right",children:"Sonnet"}),e.jsx(_,{id:"tier-sonnet",value:a.sonnet??"",onChange:u=>r("sonnet",u.target.value),placeholder:t("modelTierMapping.sonnetPlaceholder")})]}),e.jsxs("div",{className:"grid grid-cols-[80px_1fr] items-center gap-2",children:[e.jsx(E,{htmlFor:"tier-haiku",className:"text-right",children:"Haiku"}),e.jsx(_,{id:"tier-haiku",value:a.haiku??"",onChange:u=>r("haiku",u.target.value),placeholder:t("modelTierMapping.haikuPlaceholder")})]})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:t("modelTierMapping.footer")})]})]})}function Hs({profileName:s,target:a,data:n,currentSettings:c,newEnvKey:t,newEnvValue:g,onNewEnvKeyChange:h,onNewEnvValueChange:f,onEnvValueChange:r,onAddEnvVar:j,onEnvBulkChange:u}){const y=He(c),v=c?.env,k=m.useMemo(()=>Rs(v??{}),[v]),N=v??{},O=i=>{if(u){const F={...N,ANTHROPIC_MODEL:i,ANTHROPIC_DEFAULT_OPUS_MODEL:i,ANTHROPIC_DEFAULT_SONNET_MODEL:i,ANTHROPIC_DEFAULT_HAIKU_MODEL:i};u(F)}else r("ANTHROPIC_MODEL",i),r("ANTHROPIC_DEFAULT_OPUS_MODEL",i),r("ANTHROPIC_DEFAULT_SONNET_MODEL",i),r("ANTHROPIC_DEFAULT_HAIKU_MODEL",i);P.success(te.t("commonToast.appliedModelAllTiers"),{duration:2e3})},U=i=>{if(u){const F=Ms(N,i);u(F)}else i.opus!==void 0&&r("ANTHROPIC_DEFAULT_OPUS_MODEL",i.opus||""),i.sonnet!==void 0&&r("ANTHROPIC_DEFAULT_SONNET_MODEL",i.sonnet||""),i.haiku!==void 0&&r("ANTHROPIC_DEFAULT_HAIKU_MODEL",i.haiku||"")},[b,T]=m.useState(!1),o=new Set(["ANTHROPIC_AUTH_TOKEN"]),x=Object.entries(N).filter(([i])=>!o.has(i));return e.jsx("div",{className:"h-full w-full min-w-0 flex flex-col",children:e.jsxs(rs,{defaultValue:"env",className:"h-full w-full min-w-0 flex flex-col",children:[e.jsx("div",{className:"px-4 pt-4 shrink-0",children:e.jsxs(ns,{className:"w-full",children:[e.jsx(Ne,{value:"env",className:"flex-1",children:y?"Configuration":"Environment Variables"}),e.jsx(Ne,{value:"info",className:"flex-1",children:"Info & Usage"})]})}),e.jsxs("div",{className:"flex-1 overflow-hidden flex flex-col min-w-0",children:[e.jsx(ve,{value:"env",className:"flex-1 mt-0 border-0 p-0 data-[state=inactive]:hidden flex flex-col overflow-hidden min-w-0",children:y?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex-1 overflow-hidden",children:e.jsxs("div",{className:"h-full overflow-y-auto overflow-x-hidden p-4 space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(E,{className:"text-sm font-medium",children:"Model Selection"}),e.jsx(Us,{value:N.ANTHROPIC_MODEL,onChange:O,placeholder:"Search OpenRouter models..."})]}),e.jsx(Fs,{selectedModel:N.ANTHROPIC_MODEL,value:k,onChange:U}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(E,{className:"text-sm font-medium",children:"API Key"}),e.jsx(ze,{value:N.ANTHROPIC_AUTH_TOKEN||"",onChange:i=>r("ANTHROPIC_AUTH_TOKEN",i.target.value),placeholder:"sk-or-v1-...",className:"font-mono text-sm"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Get your API key from"," ",e.jsx("a",{href:"https://openrouter.ai/keys",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"openrouter.ai/keys"})]})]}),x.length>0&&e.jsxs(Se,{open:b,onOpenChange:T,children:[e.jsxs(Ae,{className:"flex items-center gap-2 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors group",children:[e.jsx(De,{className:D("h-4 w-4 transition-transform",b&&"rotate-90")}),e.jsx(ys,{className:"h-4 w-4"}),e.jsx("span",{children:"Additional Variables"}),e.jsxs("span",{className:"text-xs font-normal opacity-70",children:["(",x.length,")"]})]}),e.jsx(_e,{className:"pt-4",children:e.jsx("div",{className:"space-y-3 border rounded-lg p-3 bg-muted/30",children:x.map(([i,F])=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(E,{className:"text-xs text-muted-foreground",children:i}),e.jsx(_,{value:F,onChange:z=>r(i,z.target.value),className:"font-mono text-xs h-8"})]},i))})})]})]})}),e.jsxs("div",{className:"p-4 border-t bg-background shrink-0",children:[e.jsx(E,{className:"text-xs font-medium text-muted-foreground",children:"Add Environment Variable"}),e.jsxs("div",{className:"flex gap-2 mt-2",children:[e.jsx(_,{placeholder:"VARIABLE_NAME",value:t,onChange:i=>h(i.target.value.toUpperCase()),className:"font-mono text-sm h-8 w-2/5",onKeyDown:i=>i.key==="Enter"&&t.trim()&&j()}),e.jsx(_,{placeholder:"value",value:g,onChange:i=>f(i.target.value),className:"font-mono text-sm h-8 flex-1",onKeyDown:i=>i.key==="Enter"&&t.trim()&&j()}),e.jsx(p,{variant:"outline",size:"sm",className:"h-8",onClick:j,disabled:!t.trim(),children:e.jsx(re,{className:"w-4 h-4"})})]})]})]}):e.jsx(Ls,{currentSettings:c,newEnvKey:t,newEnvValue:g,onNewEnvKeyChange:h,onNewEnvValueChange:f,onEnvValueChange:r,onAddEnvVar:j})}),e.jsx(ve,{value:"info",className:"h-full mt-0 border-0 p-0 data-[state=inactive]:hidden",children:e.jsx(Is,{profileName:s,target:a,data:n})})]})]})})}function zs({profileName:s,profileTarget:a,onDelete:n,onHasChangesUpdate:c}){const[t,g]=m.useState({}),[h,f]=m.useState(!1),[r,j]=m.useState(null),[u,y]=m.useState(""),[v,k]=m.useState(""),N=fs(),{data:O,isLoading:U,isError:b,refetch:T}=js({queryKey:["settings",s],queryFn:async()=>{const d=await fetch(`/api/settings/${s}/raw`);if(!d.ok)throw new Error(`Failed to load settings: ${d.status}`);return d.json()}}),o=O?.settings,x=m.useMemo(()=>{if(r!==null)try{return JSON.parse(r)}catch{}if(o)return{...o,env:{...o.env,...t}}},[o,t,r]),i=m.useMemo(()=>r!==null?r:o?JSON.stringify(o,null,2):"",[r,o]),F=m.useCallback(d=>{j(d)},[]),z=(d,C)=>{const M={...x?.env||{},[d]:C};g($=>({...$,[d]:C})),j(JSON.stringify({...x,env:M},null,2))},V=d=>{const C={...x?.env||{},...d};g(M=>({...M,...d})),j(JSON.stringify({...x,env:C},null,2))},J=()=>{if(!u.trim())return;const d=u.trim(),C=v,M={...x?.env||{},[d]:C};g($=>({...$,[d]:C})),j(JSON.stringify({...x,env:M},null,2)),y(""),k("")},Y=m.useMemo(()=>{try{return JSON.parse(i),!0}catch{return!1}},[i]),R=m.useMemo(()=>r!==null?r!==JSON.stringify(o,null,2):Object.keys(t).length>0,[r,t,o]),Z=m.useMemo(()=>{const d=["ANTHROPIC_BASE_URL","ANTHROPIC_AUTH_TOKEN"],C=x?.env||{};return d.filter(M=>!C[M]?.trim())},[x]);m.useEffect(()=>{c?.(R)},[R,c]);const w=be({mutationFn:async()=>{let d;try{d=JSON.parse(i)}catch{d={...O?.settings,env:{...O?.settings?.env,...t}}}const C=await fetch(`/api/settings/${s}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({settings:d,expectedMtime:O?.mtime})});if(C.status===409)throw new Error("CONFLICT");if(!C.ok)throw new Error("Failed to save");return C.json()},onSuccess:()=>{N.invalidateQueries({queryKey:["settings",s]}),N.invalidateQueries({queryKey:["profiles"]}),g({}),j(null),P.success(te.t("commonToast.settingsSaved"))},onError:d=>{d.message==="CONFLICT"?f(!0):P.error(d.message)}}),H=be({mutationFn:async d=>(await ls.profiles.update(s,{target:d}),d),onSuccess:()=>{N.invalidateQueries({queryKey:["profiles"]}),P.success(te.t("commonToast.defaultTargetUpdated"))},onError:(d,C)=>{const M=C==="droid"?"Factory Droid":"Claude Code",$=d.message.trim()?`: ${d.message}`:"";P.error(te.t("commonToast.failedUpdateDefaultTarget",{target:M,suffix:$}))}}),G=a||"claude",W=w.isPending||H.isPending,ee=async d=>{f(!1),d?(await T(),w.mutate()):(g({}),j(null))};return e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsx(Ds,{profileName:s,target:G,data:O,settings:x,isLoading:U,isSaving:w.isPending,isTargetSaving:H.isPending,hasChanges:R,isRawJsonValid:Y,onTargetChange:d=>{W||d!==G&&H.mutate(d)},onRefresh:()=>{W||T()},onDelete:n,onSave:()=>{W||w.mutate()}}),U?e.jsxs("div",{className:"flex-1 flex items-center justify-center",children:[e.jsx(ae,{className:"w-8 h-8 animate-spin text-muted-foreground"}),e.jsx("span",{className:"ml-3 text-muted-foreground",children:"Loading settings..."})]}):b?e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center space-y-3",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Failed to load settings."}),e.jsxs(p,{variant:"outline",size:"sm",onClick:()=>T(),children:[e.jsx(X,{className:"w-4 h-4 mr-1"}),"Retry"]})]})}):e.jsxs("div",{className:"flex-1 grid grid-cols-[40%_60%] divide-x overflow-hidden",children:[e.jsx("div",{className:"flex flex-col overflow-hidden bg-muted/5 min-w-0",children:e.jsx(Hs,{profileName:s,target:G,data:O,currentSettings:x,newEnvKey:u,newEnvValue:v,onNewEnvKeyChange:y,onNewEnvValueChange:k,onEnvValueChange:z,onEnvBulkChange:V,onAddEnvVar:J})}),e.jsxs("div",{className:"flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-6 py-2 bg-muted/30 border-b flex items-center gap-2 shrink-0 h-[45px]",children:[e.jsx(ks,{className:"w-4 h-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Raw Configuration (JSON)"})]}),e.jsx(is,{rawJsonContent:i,isRawJsonValid:Y,rawJsonEdits:r,settings:o,onChange:F,missingRequiredFields:Z})]})]}),e.jsx(ue,{open:h,title:"File Modified Externally",description:"Overwrite with your changes or discard?",confirmText:"Overwrite",variant:"destructive",onConfirm:()=>ee(!0),onCancel:()=>ee(!1)})]},s)}const Oe="ccs:openrouter-banner-dismissed";function $s({onCreateClick:s}){const[a,n]=m.useState(!0),{modelCount:c,isLoading:t}=pe();m.useEffect(()=>{const h=localStorage.getItem(Oe)==="true";n(h)},[]);const g=()=>{localStorage.setItem(Oe,"true"),n(!0)};return a?null:e.jsx("div",{className:"bg-gradient-to-r from-accent to-accent/90 text-white px-4 py-3 relative shrink-0",children:e.jsxs("div",{className:"flex items-center justify-between gap-4 max-w-screen-xl mx-auto",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[e.jsx("div",{className:"p-1.5 bg-white/20 rounded-md shrink-0",children:e.jsx(ge,{className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm",children:"NEW: OpenRouter Integration"}),e.jsxs("p",{className:"text-xs text-white/80 truncate",children:["Browse ",t?"300+":`${c}+`," models from OpenAI, Anthropic, Google, Meta and more."]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s&&e.jsx(p,{size:"sm",variant:"secondary",onClick:s,className:"bg-white text-accent hover:bg-white/90 h-8",children:"Try it now"}),e.jsxs("a",{href:"https://openrouter.ai",target:"_blank",rel:"noopener noreferrer",className:"text-xs text-white/80 hover:text-white hidden sm:flex items-center gap-1",children:["Learn more",e.jsx(he,{className:"w-3 h-3"})]}),e.jsxs(p,{size:"icon",variant:"ghost",onClick:g,className:"h-7 w-7 text-white/70 hover:text-white hover:bg-white/20",children:[e.jsx(Ps,{className:"w-4 h-4"}),e.jsx("span",{className:"sr-only",children:"Dismiss"})]})]})]})})}function Ks({onOpenRouterClick:s,onAlibabaCodingPlanClick:a,onCliproxyClick:n,onCustomClick:c}){const{t}=q(),{modelCount:g,isLoading:h}=pe();return e.jsx("div",{className:"flex-1 flex items-center justify-center bg-muted/20 p-8",children:e.jsxs("div",{className:"max-w-lg w-full space-y-6",children:[e.jsxs(ie,{className:"border-accent/30 dark:border-accent/40 bg-gradient-to-br from-accent/5 to-background dark:from-accent/10",children:[e.jsxs(le,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("div",{className:"p-2 rounded-lg bg-accent/10 dark:bg-accent/20",children:e.jsx("img",{src:"/icons/openrouter.svg",alt:"OpenRouter",className:"w-6 h-6"})}),e.jsx(A,{variant:"secondary",className:"bg-accent/10 text-accent dark:bg-accent/20 dark:text-accent-foreground",children:t("openrouterQuickStart.recommended")})]}),e.jsx(oe,{className:"text-xl",children:t("openrouterQuickStart.title")}),e.jsx(ce,{className:"text-base",children:t("openrouterQuickStart.description",{modelCountLabel:h?"300+":`${g}+`})})]}),e.jsxs(de,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Le,{className:"w-4 h-4 text-accent"}),e.jsx("span",{children:t("openrouterQuickStart.featureOneApi")})]}),e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(ge,{className:"w-4 h-4 text-accent"}),e.jsx("span",{children:t("openrouterQuickStart.featureTierMapping")})]})]}),e.jsxs(p,{onClick:s,className:"w-full bg-accent hover:bg-accent/90 text-white",size:"lg",children:[t("openrouterQuickStart.createOpenRouterProfile"),e.jsx(me,{className:"w-4 h-4 ml-2"})]}),e.jsxs("p",{className:"text-xs text-center text-muted-foreground",children:[t("openrouterQuickStart.getApiKeyAt")," ",e.jsxs("a",{href:"https://openrouter.ai/keys",target:"_blank",rel:"noopener noreferrer",className:"text-accent hover:underline inline-flex items-center gap-1",children:["openrouter.ai/keys",e.jsx(he,{className:"w-3 h-3"})]})]})]})]}),e.jsxs(ie,{className:"border-orange-500/30 dark:border-orange-500/40 bg-gradient-to-br from-orange-500/5 to-background dark:from-orange-500/10",children:[e.jsxs(le,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("div",{className:"p-2 rounded-lg bg-orange-500/10 dark:bg-orange-500/20",children:e.jsx("img",{src:"/assets/providers/alibabacloud-color.svg",alt:"Alibaba Coding Plan",className:"w-6 h-6"})}),e.jsx(A,{variant:"secondary",className:"bg-orange-500/10 text-orange-700 dark:bg-orange-500/20 dark:text-orange-200",children:t("alibabaCodingPlanQuickStart.recommended")})]}),e.jsx(oe,{className:"text-xl",children:t("alibabaCodingPlanQuickStart.title")}),e.jsx(ce,{className:"text-base",children:t("alibabaCodingPlanQuickStart.description")})]}),e.jsxs(de,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Ie,{className:"w-4 h-4 text-orange-600"}),e.jsx("span",{children:t("alibabaCodingPlanQuickStart.featureEndpoint")})]}),e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(we,{className:"w-4 h-4 text-orange-600"}),e.jsx("span",{children:t("alibabaCodingPlanQuickStart.featureKeyFormat")})]})]}),e.jsxs(p,{onClick:a,className:"w-full bg-orange-600 hover:bg-orange-600/90 text-white",size:"lg",children:[t("alibabaCodingPlanQuickStart.createAlibabaProfile"),e.jsx(me,{className:"w-4 h-4 ml-2"})]}),e.jsxs("p",{className:"text-xs text-center text-muted-foreground",children:[t("alibabaCodingPlanQuickStart.readGuideAt")," ",e.jsxs("a",{href:"https://www.alibabacloud.com/help/en/model-studio/coding-plan",target:"_blank",rel:"noopener noreferrer",className:"text-orange-700 dark:text-orange-400 hover:underline inline-flex items-center gap-1",children:["Alibaba Cloud Model Studio",e.jsx(he,{className:"w-3 h-3"})]})]})]})]}),e.jsxs(ie,{className:"border-emerald-500/30 dark:border-emerald-500/40 bg-gradient-to-br from-emerald-500/5 to-background dark:from-emerald-500/10",children:[e.jsxs(le,{className:"pb-3",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("div",{className:"p-2 rounded-lg bg-emerald-500/10 dark:bg-emerald-500/20",children:e.jsx(Ce,{className:"w-6 h-6 text-emerald-700 dark:text-emerald-300"})}),e.jsx(A,{variant:"secondary",className:"bg-emerald-500/10 text-emerald-700 dark:bg-emerald-500/20 dark:text-emerald-200",children:"Configure in AI Providers"})]}),e.jsx(oe,{className:"text-xl",children:"Manage CLIProxy AI providers"}),e.jsx(ce,{className:"text-base",children:"Configure Gemini, Codex, Claude, Vertex, and OpenAI-compatible connectors directly in the dedicated CLIProxy AI Providers page."})]}),e.jsxs(de,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(Ce,{className:"w-4 h-4 text-emerald-600"}),e.jsx("span",{children:"Dedicated /cliproxy/ai-providers workspace"})]}),e.jsxs("div",{className:"flex items-center gap-2 text-muted-foreground",children:[e.jsx(we,{className:"w-4 h-4 text-emerald-600"}),e.jsx("span",{children:"Manage provider secrets outside API Profiles"})]})]}),e.jsxs(p,{onClick:n,className:"w-full bg-emerald-600 hover:bg-emerald-600/90 text-white",size:"lg",children:["Open AI Providers",e.jsx(me,{className:"w-4 h-4 ml-2"})]}),e.jsx("p",{className:"text-xs text-center text-muted-foreground",children:"Keep runtime provider configuration in CLIProxy, then create API Profiles only when you need standalone Anthropic-compatible endpoints."})]})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(ye,{className:"flex-1"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:t("openrouterQuickStart.or")}),e.jsx(ye,{className:"flex-1"})]}),e.jsx(p,{variant:"outline",onClick:c,className:"w-full",children:t("openrouterQuickStart.createCustomProfile")})]})})}function Qs({onCreateClick:s}){const{modelCount:a,isLoading:n}=pe();return e.jsx("div",{className:"p-3 border-t bg-gradient-to-r from-accent/5 to-accent/10 dark:from-accent/10 dark:to-accent/15",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 bg-accent/10 dark:bg-accent/20 rounded shrink-0",children:e.jsx("img",{src:"/icons/openrouter.svg",alt:"",className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-accent dark:text-accent-foreground",children:"OpenRouter"}),e.jsxs("p",{className:"text-[10px] text-muted-foreground truncate",children:[n?"300+":`${a}+`," models available"]})]}),e.jsxs(p,{size:"sm",variant:"ghost",onClick:s,className:"h-7 px-2 text-accent hover:text-accent hover:bg-accent/10 dark:hover:bg-accent/20",children:[e.jsx(Le,{className:"w-3 h-3 mr-1"}),e.jsx("span",{className:"text-xs",children:"Add"})]})]})})}function Js({onCreateClick:s}){const{t:a}=q();return e.jsx("div",{className:"p-3 border-t bg-gradient-to-r from-orange-500/5 to-orange-500/10 dark:from-orange-500/10 dark:to-orange-500/15",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"p-1.5 bg-orange-500/10 dark:bg-orange-500/20 rounded shrink-0",children:e.jsx("img",{src:"/assets/providers/alibabacloud-color.svg",alt:"",className:"w-4 h-4"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-orange-700 dark:text-orange-300",children:a("alibabaCodingPlanPromo.title")}),e.jsx("p",{className:"text-[10px] text-muted-foreground truncate",children:a("alibabaCodingPlanPromo.subtitle")})]}),e.jsxs(p,{size:"sm",variant:"ghost",onClick:s,className:"h-7 px-2 text-orange-700 dark:text-orange-300 hover:text-orange-700 hover:bg-orange-500/10 dark:hover:bg-orange-500/20",children:[e.jsx(Ie,{className:"w-3 h-3 mr-1"}),e.jsx("span",{className:"text-xs",children:a("alibabaCodingPlanPromo.add")})]})]})})}function nt(){const{t:s}=q(),a=Qe(),{data:n,isLoading:c,isError:t,refetch:g}=os(),h=cs(),f=ds(),r=ms(),j=xs(),u=us(),y=hs(),[v,k]=m.useState(null),[N,O]=m.useState(""),[U,b]=m.useState(!1),[T,o]=m.useState("normal"),[x,i]=m.useState(null),[F,z]=m.useState(!1),[V,J]=m.useState(null),Y=m.useRef(null);ps();const R=m.useMemo(()=>n?.profiles||[],[n?.profiles]),Z=m.useMemo(()=>R.filter(l=>l.name.toLowerCase().includes(N.toLowerCase())),[R,N]),w=v?R.find(l=>l.name===v):null,H=l=>{F&&v!==l?J(l):k(l)},G=l=>{h.mutate(l,{onSuccess:()=>{v===l&&(k(null),z(!1),J(null)),i(null)}})},W=l=>{b(!1),H(l)},ee=l=>{H(l)},d=(l,L)=>{const S=JSON.stringify(L,null,2)+`
2
- `,K=new Blob([S],{type:"application/json"}),I=URL.createObjectURL(K),Q=document.createElement("a");Q.href=I,Q.download=l,document.body.appendChild(Q),Q.click(),Q.remove(),URL.revokeObjectURL(I)},C=async()=>{try{const l=await f.mutateAsync();if(l.orphans.length===0){P.success("No orphan profile settings found");return}const L=l.orphans.filter(Q=>Q.validation.valid).length;if(!window.confirm(`Found ${l.orphans.length} orphan settings file(s). Register ${L} valid profile(s) now?`))return;const K=await r.mutateAsync({}),I=K.skipped.length>0?`, skipped ${K.skipped.length}`:"";P.success(`Registered ${K.registered.length} profile(s)${I}`)}catch(l){P.error(l.message)}},M=async()=>{if(!w)return;const l=window.prompt(`Copy profile "${w.name}" to new profile name:`,`${w.name}-copy`);if(!l)return;const L=l.trim();if(!L){P.error("Destination profile name cannot be empty");return}try{const S=await j.mutateAsync({name:w.name,data:{destination:L}});H(L),S.warnings&&S.warnings.length>0&&P.info(S.warnings.join(`
3
- `))}catch(S){P.error(S.message)}},$=async()=>{if(w)try{const l=await u.mutateAsync({name:w.name});d(`${w.name}.ccs-profile.json`,l.bundle),l.redacted?P.info("Export created with redacted token. Use include-secrets flow in CLI if needed."):P.success("Profile export downloaded")}catch(l){P.error(l.message)}},$e=()=>{Y.current?.click()},Ke=async l=>{const L=l.target.files?.[0];if(l.target.value="",!!L)try{const S=await L.text(),K=JSON.parse(S),I=await y.mutateAsync({bundle:K});I.name&&H(I.name),I.warnings&&I.warnings.length>0&&P.info(I.warnings.join(`
4
- `))}catch(S){P.error(S.message||"Failed to import profile bundle")}};return e.jsxs("div",{className:"h-[calc(100vh-100px)] flex flex-col",children:[e.jsx($s,{onCreateClick:()=>b(!0)}),e.jsxs("div",{className:"flex-1 flex min-h-0",children:[e.jsxs("div",{className:"w-80 border-r flex flex-col bg-muted/30",children:[e.jsxs("div",{className:"p-4 border-b bg-background",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Os,{className:"w-5 h-5 text-primary"}),e.jsx("h1",{className:"font-semibold",children:s("apiProfiles.title")})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(p,{size:"sm",variant:"outline",onClick:()=>void C(),disabled:f.isPending||r.isPending,"aria-label":"Discover orphan profiles",title:"Discover orphan profiles",children:e.jsx(X,{className:`w-4 h-4 ${f.isPending?"animate-spin":""}`})}),e.jsx(p,{size:"sm",variant:"outline",onClick:$e,disabled:y.isPending,"aria-label":"Import profile bundle",title:"Import profile bundle",children:e.jsx(Es,{className:"w-4 h-4"})}),e.jsxs(p,{size:"sm",onClick:()=>{b(!0)},children:[e.jsx(re,{className:"w-4 h-4 mr-1"}),s("apiProfiles.new")]})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx(Me,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground"}),e.jsx(_,{placeholder:s("apiProfiles.searchPlaceholder"),className:"pl-8 h-9",value:N,onChange:l=>O(l.target.value)})]})]}),e.jsx(ne,{className:"flex-1",children:c?e.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:s("apiProfiles.loadingProfiles")}):t?e.jsx("div",{className:"p-4 text-center",children:e.jsxs("div",{className:"space-y-3 py-8",children:[e.jsx(Ue,{className:"w-12 h-12 mx-auto text-destructive/50"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:s("apiProfiles.failedLoadTitle")}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:s("apiProfiles.failedLoadDesc")})]}),e.jsxs(p,{size:"sm",variant:"outline",onClick:()=>g(),children:[e.jsx(X,{className:"w-4 h-4 mr-1"}),s("apiProfiles.retry")]})]})}):Z.length===0?e.jsx("div",{className:"p-4 text-center",children:R.length===0?e.jsxs("div",{className:"space-y-3 py-8",children:[e.jsx(Ts,{className:"w-12 h-12 mx-auto text-muted-foreground/50"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:s("apiProfiles.noProfilesYet")}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:s("apiProfiles.noProfilesDesc")})]}),e.jsxs(p,{size:"sm",variant:"outline",onClick:()=>{b(!0)},children:[e.jsx(re,{className:"w-4 h-4 mr-1"}),s("apiProfiles.createProfile")]})]}):e.jsx("p",{className:"text-sm text-muted-foreground py-4",children:s("apiProfiles.noProfileMatch",{query:N})})}):e.jsx("div",{className:"p-2 space-y-1",children:Z.map(l=>e.jsx(Bs,{profile:l,isSelected:v===l.name,onSelect:()=>ee(l.name),onDelete:()=>i(l.name)},l.name))})}),R.length>0&&e.jsx("div",{className:"p-3 border-t bg-background text-xs text-muted-foreground",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{children:s("apiProfiles.profileCount",{count:R.length})}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Fe,{className:"w-3 h-3 text-green-600"}),s("apiProfiles.configuredCount",{count:R.filter(l=>l.configured).length})]})]})}),e.jsx(Qs,{onCreateClick:()=>{o("openrouter"),b(!0)}}),e.jsx(Js,{onCreateClick:()=>{o("alibaba-coding-plan"),b(!0)}})]}),e.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:w?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"px-4 py-2 border-b bg-background flex items-center justify-end gap-2",children:[e.jsxs(p,{size:"sm",variant:"outline",onClick:()=>void M(),disabled:j.isPending,children:[e.jsx(Ss,{className:"w-4 h-4 mr-1"}),"Copy"]}),e.jsxs(p,{size:"sm",variant:"outline",onClick:()=>void $(),disabled:u.isPending,children:[e.jsx(As,{className:"w-4 h-4 mr-1"}),"Export"]})]}),e.jsx(zs,{profileName:w.name,profileTarget:w.target,onDelete:()=>i(w.name),onHasChangesUpdate:z},w.name)]}):e.jsx(Ks,{onCliproxyClick:()=>{a("/cliproxy/ai-providers")},onOpenRouterClick:()=>{o("openrouter"),b(!0)},onAlibabaCodingPlanClick:()=>{o("alibaba-coding-plan"),b(!0)},onCustomClick:()=>{o("normal"),b(!0)}})})]}),e.jsx("input",{ref:Y,type:"file",accept:".json,application/json",className:"hidden",onChange:l=>void Ke(l)}),e.jsx(gs,{open:U,onOpenChange:b,onSuccess:W,initialMode:T}),e.jsx(ue,{open:!!x,title:s("apiProfiles.deleteProfileTitle"),description:s("apiProfiles.deleteProfileDesc",{name:x??""}),confirmText:s("apiProfiles.delete"),variant:"destructive",onConfirm:()=>x&&G(x),onCancel:()=>i(null)}),e.jsx(ue,{open:!!V,title:s("apiProfiles.unsavedChangesTitle"),description:s("apiProfiles.unsavedChangesDesc",{current:v??"",next:V??""}),confirmText:s("apiProfiles.discardSwitch"),variant:"destructive",onConfirm:()=>{z(!1),k(V),J(null)},onCancel:()=>J(null)})]})}function Bs({profile:s,isSelected:a,onSelect:n,onDelete:c}){return e.jsxs("div",{className:D("group flex items-center gap-2 px-3 py-2.5 rounded-md cursor-pointer transition-colors",a?"bg-primary/10 border border-primary/20":"hover:bg-muted border border-transparent"),onClick:n,children:[s.configured?e.jsx(Fe,{className:"w-4 h-4 text-green-600 shrink-0"}):e.jsx(Ue,{className:"w-4 h-4 text-yellow-600 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("div",{className:"font-medium text-sm truncate",children:s.name}),e.jsx(A,{variant:"outline",className:"text-[10px] h-4 px-1.5 uppercase",children:s.target||"claude"})]}),e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx("div",{className:"text-xs text-muted-foreground truncate flex-1",children:s.settingsPath}),e.jsx(B,{value:s.settingsPath,size:"icon",className:"h-5 w-5 opacity-0 group-hover:opacity-100 transition-opacity"})]})]}),e.jsx(p,{variant:"ghost",size:"icon",className:"h-7 w-7 opacity-0 group-hover:opacity-100 transition-opacity",onClick:t=>{t.stopPropagation(),c()},children:e.jsx(Re,{className:"w-3.5 h-3.5 text-destructive"})})]})}export{nt as ApiPage};
@@ -1 +0,0 @@
1
- import{j as e}from"./radix-ui-Dt3edmE5.js";import{r as W}from"./react-vendor-CNOkPC89.js";import{b1 as Ce,B as p,d as y,n as se,C as u,j as f,k as j,_ as v,b as x,I as H,r as te,s as ae,t as ne,v as ie,w as re,x as F,Q as we,R as Ee,U as le,V as de,c as he}from"./index-N_jd9sKU.js";import{u as K,a as J,b as V}from"./tanstack-B8i0evp-.js";import{t as E}from"./notifications-B2HqRBj7.js";import{a4 as Pe,a3 as ke,L as U,aj as De,ai as Be,R as Ie,T as ce,aE as Te,a2 as Re}from"./icons-DMeZET56.js";import"./utils-CzKF5WmX.js";import"./form-utils-Bcoyqxpq.js";import"./code-highlight-BRUf_pqB.js";const L=["claude-extension-bindings"];async function P(s,a){const n=await fetch(Ce(s),{headers:{"Content-Type":"application/json"},...a});if(!n.ok){const l=await n.json().catch(()=>null);throw new Error(l?.error||`Request failed (${n.status})`)}return n.status===204?void 0:await n.json()}function qe(){return K({queryKey:["claude-extension-options"],queryFn:()=>P("/claude-extension/profiles")})}function Ae(s,a="vscode"){return K({queryKey:["claude-extension-setup",s,a],enabled:!!s,queryFn:()=>P(`/claude-extension/setup?profile=${encodeURIComponent(s||"")}&host=${encodeURIComponent(a)}`)})}function $e(){return K({queryKey:L,queryFn:()=>P("/claude-extension/bindings")})}function Le(s){return K({queryKey:["claude-extension-binding-status",s],enabled:!!s,queryFn:()=>P(`/claude-extension/bindings/${encodeURIComponent(s||"")}/verify`)})}function Oe(){const s=J();return V({mutationFn:a=>P("/claude-extension/bindings",{method:"POST",body:JSON.stringify(a)}),onSuccess:()=>{s.invalidateQueries({queryKey:L}),E.success("Binding created")},onError:a=>E.error(a.message)})}function Qe(){const s=J();return V({mutationFn:({id:a,binding:n})=>P(`/claude-extension/bindings/${encodeURIComponent(a)}`,{method:"PUT",body:JSON.stringify(n)}),onSuccess:(a,n)=>{s.invalidateQueries({queryKey:L}),s.invalidateQueries({queryKey:["claude-extension-binding-status",n.id]}),E.success("Binding saved")},onError:a=>E.error(a.message)})}function Ue(){const s=J();return V({mutationFn:a=>P(`/claude-extension/bindings/${encodeURIComponent(a)}`,{method:"DELETE"}),onSuccess:()=>{s.invalidateQueries({queryKey:L}),E.success("Binding deleted")},onError:a=>E.error(a.message)})}function ge(s,a){const n=J();return V({mutationFn:({id:l,target:S})=>P(`/claude-extension/bindings/${encodeURIComponent(l)}/${s}`,{method:"POST",body:JSON.stringify({target:S})}),onSuccess:l=>{n.invalidateQueries({queryKey:L}),n.setQueryData(["claude-extension-binding-status",l.bindingId],l),E.success(a)},onError:l=>E.error(l.message)})}function Fe(){return ge("apply","Binding applied")}function Ke(){return ge("reset","Managed values removed")}const Je=[];function oe(s){return{name:"",profile:s,host:"vscode",ideSettingsPath:"",notes:""}}function q(s){return{name:s.name,profile:s.profile,host:s.host,ideSettingsPath:s.ideSettingsPath||"",notes:s.notes||""}}function Ve(s){return{name:s.name.trim(),profile:s.profile.trim(),host:s.host,ideSettingsPath:s.ideSettingsPath.trim()||void 0,notes:s.notes.trim()||void 0}}function me(s){return s?.state==="applied"}function Me({state:s}){const a=s==="applied"?"border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300":s==="drifted"?"border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300":s==="missing"?"border-destructive/30 bg-destructive/10 text-destructive":"border-border bg-muted text-muted-foreground";return e.jsx(p,{variant:"outline",className:a,children:s})}function _e(s){return s.replace(/[\\/]/g,"$&​")}function c({label:s,value:a,mono:n=!1,copyValue:l}){const S=typeof l=="string"&&l.trim().length>0;return e.jsxs("div",{className:"grid gap-2 text-sm sm:grid-cols-[112px_minmax(0,1fr)] sm:items-start",children:[e.jsx("span",{className:"text-muted-foreground",children:s}),S?e.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[e.jsx("div",{className:"min-w-0 flex-1 rounded-md border bg-muted/25 px-3 py-2",children:e.jsx("span",{className:"block text-left font-mono text-xs leading-5 [overflow-wrap:anywhere]",children:_e(a)})}),e.jsx(F,{value:l,label:`Copy ${s.toLowerCase()}`,className:"shrink-0"})]}):e.jsx("span",{className:he("text-left sm:text-right",n&&"font-mono text-xs leading-5 [overflow-wrap:anywhere]"),children:a})]})}function ue({title:s,description:a,value:n}){return e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsx(f,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(j,{className:"text-base",children:s}),e.jsx(v,{className:"mt-1",children:a})]}),e.jsx(F,{value:n,label:`Copy ${s}`})]})}),e.jsx(x,{children:e.jsx("pre",{className:"max-h-[360px] overflow-auto rounded-lg border bg-muted/30 p-4 text-xs leading-6",children:n})})]})}function xe({title:s,description:a,status:n,applyLabel:l,resetLabel:S,onApply:h,onReset:C,disabled:D,busy:B}){return e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsx(f,{className:"pb-3",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(j,{className:"text-base",children:s}),e.jsx(v,{className:"mt-1",children:a})]}),n?e.jsx(Me,{state:n.state}):null]})}),e.jsxs(x,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{label:"Path",value:n?.path||"Save a binding first",mono:!0,copyValue:n?.path}),e.jsx(c,{label:"File",value:n?n.exists?"Present":"Not created yet":"Unavailable"})]}),e.jsx("div",{className:"rounded-lg border bg-muted/25 p-3 text-sm text-muted-foreground",children:n?.message||"Verify the binding after saving to inspect the current file state."}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(y,{size:"sm",className:"flex-1",onClick:h,disabled:D||B,children:[B?e.jsx(U,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):null,l]}),e.jsx(y,{size:"sm",variant:"outline",className:"flex-1",onClick:C,disabled:D||B,children:S})]})]})]})}function ze({binding:s,isSelected:a,onSelect:n}){return e.jsx("button",{onClick:n,className:he("w-full rounded-lg border px-3 py-3 text-left transition-colors",a?"border-primary/40 bg-primary/10":"border-border/60 bg-card hover:bg-muted/40"),children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate text-sm font-medium",children:s.name}),e.jsxs("div",{className:"mt-1 text-xs text-muted-foreground",children:[s.profile," · ",s.host]})]}),e.jsx(p,{variant:"outline",className:"shrink-0",children:s.usesDefaultIdeSettingsPath?"Default path":"Custom path"})]})})}function as(){const s=qe(),a=$e(),n=Oe(),l=Qe(),S=Ue(),h=Fe(),C=Ke(),D=s.data?.profiles??[],B=s.data?.hosts??[],w=a.data?.bindings??Je,pe=D[0]?.name??"default",[fe,I]=W.useState(!1),[O,T]=W.useState(null),[G,k]=W.useState(()=>oe("default")),o=fe||w.length===0,b=!o&&w.length>0?w.find(t=>t.id===O)??(O?null:w[0]):null,g=b?.id??null,r=o||!b||O?G:q(b),Y=Ae(r.profile,r.host),A=Le(o?void 0:g||void 0),d=B.find(t=>t.id===r.host),M=D.find(t=>t.name===r.profile),_=s.error||a.error||Y.error||A.error,je=`${w.length} saved`,X=n.isPending||l.isPending,ve=h.isPending&&h.variables?.target==="shared"||C.isPending&&C.variables?.target==="shared",be=h.isPending&&h.variables?.target==="ide"||C.isPending&&C.variables?.target==="ide",Z=r.name.trim().length>0&&r.profile.trim().length>0,i=Y.data,m=A.data,ee=Math.max((i?.env.length??0)-6,0),Ne=i?.env.slice(0,6)??[];function z(){I(!0),T(null),k(oe(pe))}async function ye(){if(!Z)return;const t=Ve(r);if(!o&&g){const Q=await l.mutateAsync({id:g,binding:t});I(!1),T(Q.binding.id),k(q(Q.binding));return}const N=await n.mutateAsync(t);I(!1),T(N.binding.id),k(q(N.binding))}async function Se(){if(!g||!b||!window.confirm(`Delete binding "${b.name}"?`))return;await S.mutateAsync(g);const t=w.filter(N=>N.id!==g);t.length>0?(T(t[0].id),I(!1),k(q(t[0]))):z()}function $(t,N){if(!o&&b&&!O){T(b.id),k({...q(b),[t]:N}),I(!1);return}k(Q=>({...Q,[t]:N}))}function R(t,N){if(g){if(N==="apply"){h.mutate({id:g,target:t});return}C.mutate({id:g,target:t})}}return e.jsxs("div",{className:"flex h-[calc(100vh-100px)] min-h-0",children:[e.jsxs("div",{className:"flex w-[348px] shrink-0 flex-col border-r bg-muted/30 xl:w-[372px]",children:[e.jsx("div",{className:"border-b bg-background p-4",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"rounded-lg border bg-muted/40 p-2",children:e.jsx(Pe,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"font-semibold",children:"Claude Extension"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Saved IDE bindings for CCS profiles"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(p,{variant:"secondary",children:je}),d?e.jsx(p,{variant:"outline",children:d.label}):null]})]}),e.jsxs(y,{size:"sm",onClick:z,className:"gap-1.5",children:[e.jsx(ke,{className:"h-3.5 w-3.5"}),"New"]})]})}),e.jsx(se,{className:"flex-1",children:e.jsxs("div",{className:"space-y-4 p-5",children:[e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:o?"Create binding":"Binding editor"}),e.jsx(v,{children:"Save a profile + IDE path once, then apply or reset it from the dashboard."})]}),e.jsxs(x,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:"Binding name"}),e.jsx(H,{value:r.name,onChange:t=>$("name",t.target.value),placeholder:"VS Code · work profile"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:"CCS profile"}),e.jsxs(te,{value:r.profile,onValueChange:t=>$("profile",t),children:[e.jsx(ae,{children:e.jsx(ne,{placeholder:"Select a profile"})}),e.jsx(ie,{children:D.map(t=>e.jsxs(re,{value:t.name,children:[t.label," (",t.profileType,")"]},t.name))})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:M?.description||"Choose which CCS profile the IDE should inherit."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:"IDE host"}),e.jsxs(te,{value:r.host,onValueChange:t=>$("host",t),children:[e.jsx(ae,{children:e.jsx(ne,{placeholder:"Select a host"})}),e.jsx(ie,{children:B.map(t=>e.jsx(re,{value:t.id,children:t.label},t.id))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:"IDE settings path"}),e.jsx(H,{value:r.ideSettingsPath,onChange:t=>$("ideSettingsPath",t.target.value),placeholder:d?.defaultSettingsPath||"Leave blank for the default user settings path"}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Leave blank to use the default user settings path for"," ",d?.label||"this IDE","."]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-sm font-medium",children:"Notes"}),e.jsx(H,{value:r.notes,onChange:t=>$("notes",t.target.value),placeholder:"Optional reminder for this machine or workspace"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(y,{className:"flex-1 gap-1.5",onClick:()=>void ye(),disabled:!Z||X,children:[X?e.jsx(U,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(De,{className:"h-3.5 w-3.5"}),o?"Create":"Save"]}),e.jsx(y,{variant:"outline",onClick:z,children:"Reset form"})]}),o?null:e.jsxs(y,{variant:"outline",className:"w-full gap-1.5 text-destructive hover:text-destructive",onClick:()=>void Se(),disabled:S.isPending,children:[e.jsx(Be,{className:"h-3.5 w-3.5"}),"Delete binding"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"px-1 text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Saved bindings"}),e.jsx("div",{className:"space-y-2",children:w.length>0?w.map(t=>e.jsx(ze,{binding:t,isSelected:t.id===g&&!o,onSelect:()=>{I(!1),T(t.id),k(q(t))}},t.id)):e.jsx(u,{className:"border-dashed border-border/60 bg-card/60",children:e.jsx(x,{className:"pt-6 text-sm text-muted-foreground",children:"No saved bindings yet. Create one to manage apply, reset, and drift checks from the dashboard."})})})]})]})})]}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx(se,{className:"h-full",children:e.jsxs("div",{className:"w-full space-y-6 p-6 xl:p-7 2xl:p-8",children:[e.jsxs("div",{className:"flex flex-col gap-3 lg:flex-row lg:items-end lg:justify-between",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[M?e.jsx(p,{variant:"outline",children:M.label}):null,d?e.jsx(p,{variant:"outline",children:d.label}):null,o?e.jsx(p,{variant:"secondary",children:"Draft"}):null,m?.sharedSettings&&me(m.sharedSettings)&&me(m.ideSettings)?e.jsx(p,{className:"bg-emerald-600 hover:bg-emerald-600",children:"In sync"}):null]}),e.jsxs("div",{className:"max-w-5xl",children:[e.jsx("h2",{className:"text-2xl font-semibold tracking-tight",children:b?.name||"Claude extension binding"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Manage the shared Claude settings file and the IDE-local settings file as two scoped targets."})]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(y,{variant:"outline",onClick:()=>void A.refetch(),disabled:o||A.isFetching,children:[A.isFetching?e.jsx(U,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):e.jsx(Ie,{className:"mr-1.5 h-3.5 w-3.5"}),"Verify"]}),i?e.jsx(F,{value:i.sharedSettings.command,label:"Copy persist command"}):null]})]}),_?e.jsx(u,{className:"border-destructive/40 bg-destructive/5",children:e.jsxs(x,{className:"flex items-start gap-3 pt-6 text-sm text-destructive",children:[e.jsx(ce,{className:"mt-0.5 h-4 w-4 shrink-0"}),e.jsx("div",{children:_.message})]})}):null,_?null:e.jsxs(we,{defaultValue:"overview",className:"flex flex-col gap-6",children:[e.jsxs(Ee,{className:"w-full justify-start",children:[e.jsx(le,{value:"overview",children:"Overview"}),e.jsx(le,{value:"advanced",children:"Advanced"})]}),e.jsxs(de,{value:"overview",className:"mt-0 space-y-6",children:[e.jsxs("div",{className:"grid gap-6 xl:grid-cols-2",children:[e.jsx(xe,{title:"Shared Claude settings",description:"Writes the managed env block inside ~/.claude/settings.json so CLI and IDE behavior stay aligned.",status:m?.sharedSettings,applyLabel:"Apply shared",resetLabel:"Reset shared",onApply:()=>R("shared","apply"),onReset:()=>R("shared","reset"),disabled:o,busy:ve}),e.jsx(xe,{title:`${d?.label||"IDE"} settings.json`,description:"Writes only the Anthropic extension keys so unrelated editor preferences stay untouched.",status:m?.ideSettings,applyLabel:"Apply IDE",resetLabel:"Reset IDE",onApply:()=>R("ide","apply"),onReset:()=>R("ide","reset"),disabled:o,busy:be})]}),e.jsxs("div",{className:"grid gap-6 xl:grid-cols-[minmax(0,1.15fr)_minmax(320px,0.85fr)]",children:[e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:"Resolved binding"}),e.jsx(v,{children:"The binding uses the same profile resolution as `ccs persist` and `ccs env`."})]}),e.jsxs(x,{className:"space-y-3",children:[e.jsx(c,{label:"Profile",value:i?.profile.label||r.profile||"Not selected"}),e.jsx(c,{label:"Profile type",value:i?.profile.profileType||"Unknown"}),e.jsx(c,{label:"IDE host",value:d?.label||"Not selected"}),e.jsx(c,{label:"IDE path mode",value:r.ideSettingsPath.trim()?"Custom path":"Default user path"}),e.jsx(c,{label:"Effective IDE path",value:m?.ideSettings.path||r.ideSettingsPath.trim()||d?.defaultSettingsPath||"Unavailable",mono:!0,copyValue:m?.ideSettings.path||r.ideSettingsPath.trim()||d?.defaultSettingsPath}),e.jsx(c,{label:"Persist command",value:i?.sharedSettings.command||"Save a valid binding first",mono:!0}),r.notes.trim()?e.jsx(c,{label:"Notes",value:r.notes.trim()}):null]})]}),e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:"Managed payload"}),e.jsx(v,{children:"Keep the main view short. The full JSON stays in the Advanced tab."})]}),e.jsxs(x,{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[Ne.map(t=>e.jsx(p,{variant:"secondary",className:"font-mono text-[10px]",children:t.name},t.name)),ee>0?e.jsxs(p,{variant:"outline",children:["+",ee," more"]}):null]}),e.jsx("div",{className:"rounded-lg border bg-muted/25 p-4 text-sm",children:i?.env.length?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"font-medium",children:["CCS will inject ",i.env.length," environment values."]}),e.jsx("div",{className:"text-muted-foreground",children:"The IDE-local target receives the extension schema. The shared target receives the same env block through Claude settings."})]}):e.jsx("div",{className:"text-muted-foreground",children:"This profile resolves to native Claude defaults, so apply/reset mainly clears existing CCS-managed overrides."})}),o?e.jsx("div",{className:"rounded-lg border border-dashed bg-muted/15 p-4 text-sm text-muted-foreground",children:"Save this draft to unlock apply, reset, and verify actions."}):e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(y,{className:"flex-1",onClick:()=>R("all","apply"),disabled:h.isPending,children:[h.isPending&&h.variables?.target==="all"?e.jsx(U,{className:"mr-1.5 h-3.5 w-3.5 animate-spin"}):null,"Apply both targets"]}),e.jsx(y,{variant:"outline",className:"flex-1",onClick:()=>R("all","reset"),disabled:C.isPending,children:"Reset both targets"})]})]})]})]}),i&&(i.warnings.length>0||i.notes.length>0)?e.jsxs("div",{className:"grid gap-6 xl:grid-cols-2",children:[e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:"Warnings"}),e.jsx(v,{children:"Operational details that can break the binding even when JSON is correct."})]}),e.jsx(x,{className:"space-y-3",children:i.warnings.length>0?i.warnings.map(t=>e.jsxs("div",{className:"flex items-start gap-3 rounded-lg border border-amber-400/40 bg-amber-50/60 p-3 text-sm dark:bg-amber-950/10",children:[e.jsx(ce,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-600"}),e.jsx("span",{children:t})]},t)):e.jsx("div",{className:"rounded-lg border bg-muted/20 p-3 text-sm text-muted-foreground",children:"No runtime warnings for this binding."})})]}),e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:"Notes"}),e.jsx(v,{children:"Short context from CCS about account continuity and host-specific behavior."})]}),e.jsx(x,{className:"space-y-3",children:i.notes.length>0?i.notes.map(t=>e.jsxs("div",{className:"flex items-start gap-3 rounded-lg border bg-muted/30 p-3 text-sm",children:[e.jsx(Te,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),e.jsx("span",{children:t})]},t)):e.jsx("div",{className:"rounded-lg border bg-muted/20 p-3 text-sm text-muted-foreground",children:"No extra notes for this binding."})})]})]}):null]}),e.jsx(de,{value:"advanced",className:"mt-0 space-y-6",children:i?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-6 xl:grid-cols-2",children:[e.jsx(ue,{title:"Shared Claude settings JSON",description:"Managed env block for ~/.claude/settings.json.",value:i.sharedSettings.json}),e.jsx(ue,{title:`${d?.label||"IDE"} settings JSON`,description:`Anthropic extension snippet for ${d?.settingsTargetLabel||"settings.json"}.`,value:i.ideSettings.json})]}),e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsx(f,{children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx(j,{className:"text-base",children:"Resolved environment payload"}),e.jsx(v,{children:"Exact environment values that the extension receives after CCS expands this profile."})]}),e.jsx(F,{value:JSON.stringify(i.env,null,2),label:"Copy environment payload"})]})}),e.jsx(x,{children:i.env.length>0?e.jsx("pre",{className:"max-h-[420px] overflow-auto rounded-lg border bg-muted/30 p-4 text-xs leading-6",children:JSON.stringify(i.env,null,2)}):e.jsx("div",{className:"rounded-lg border bg-muted/20 p-4 text-sm text-muted-foreground",children:"No env payload. This binding resolves to native Claude defaults."})})]}),e.jsxs("div",{className:"grid gap-6 xl:grid-cols-2",children:[e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:"Shared target metadata"}),e.jsx(v,{children:"Useful when debugging drift or comparing with manual edits."})]}),e.jsxs(x,{className:"space-y-3",children:[e.jsx(c,{label:"Target path",value:m?.sharedSettings.path||i.sharedSettings.path,mono:!0,copyValue:m?.sharedSettings.path||i.sharedSettings.path}),e.jsx(c,{label:"Command",value:i.sharedSettings.command,mono:!0}),e.jsx(c,{label:"Current state",value:m?.sharedSettings.state||"Not verified"})]})]}),e.jsxs(u,{className:"border-border/60 bg-card/80",children:[e.jsxs(f,{children:[e.jsx(j,{className:"text-base",children:"IDE target metadata"}),e.jsx(v,{children:"Current file path plus the extension setting key used for this host."})]}),e.jsxs(x,{className:"space-y-3",children:[e.jsx(c,{label:"Target path",value:m?.ideSettings.path||r.ideSettingsPath.trim()||d?.defaultSettingsPath||i.ideSettings.path,mono:!0,copyValue:m?.ideSettings.path||r.ideSettingsPath.trim()||d?.defaultSettingsPath||i.ideSettings.path}),e.jsx(c,{label:"Settings key",value:d?.settingsKey||"Unknown",mono:!0}),e.jsx(c,{label:"Current state",value:m?.ideSettings.state||"Not verified"})]})]})]})]}):e.jsx(u,{className:"border-border/60 bg-card/80",children:e.jsxs(x,{className:"flex min-h-[240px] items-center justify-center gap-3 text-sm text-muted-foreground",children:[e.jsx(Re,{className:"h-5 w-5"}),"Choose a profile and IDE host to preview the generated payload."]})})})]})]})})})]})}export{as as ClaudeExtensionPage};