@kaitranntt/ccs 6.7.0 → 6.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -23
- package/dist/api/index.d.ts +7 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +24 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/services/index.d.ts +10 -0
- package/dist/api/services/index.d.ts.map +1 -0
- package/dist/api/services/index.js +26 -0
- package/dist/api/services/index.js.map +1 -0
- package/dist/api/services/profile-reader.d.ts +28 -0
- package/dist/api/services/profile-reader.d.ts.map +1 -0
- package/dist/api/services/profile-reader.js +148 -0
- package/dist/api/services/profile-reader.js.map +1 -0
- package/dist/api/services/profile-types.d.ts +42 -0
- package/dist/api/services/profile-types.d.ts.map +1 -0
- package/dist/api/services/profile-types.js +8 -0
- package/dist/api/services/profile-types.js.map +1 -0
- package/dist/api/services/profile-writer.d.ts +6 -0
- package/dist/api/services/profile-writer.d.ts.map +1 -0
- package/dist/api/services/profile-writer.js +176 -0
- package/dist/api/services/profile-writer.js.map +1 -0
- package/dist/api/services/validation-service.d.ts +26 -0
- package/dist/api/services/validation-service.d.ts.map +1 -0
- package/dist/api/services/validation-service.js +77 -0
- package/dist/api/services/validation-service.js.map +1 -0
- package/dist/auth/auth-commands.d.ts +16 -22
- package/dist/auth/auth-commands.d.ts.map +1 -1
- package/dist/auth/auth-commands.js +29 -467
- package/dist/auth/auth-commands.js.map +1 -1
- package/dist/auth/commands/create-command.d.ts +11 -0
- package/dist/auth/commands/create-command.d.ts.map +1 -0
- package/dist/auth/commands/create-command.js +137 -0
- package/dist/auth/commands/create-command.js.map +1 -0
- package/dist/auth/commands/default-command.d.ts +15 -0
- package/dist/auth/commands/default-command.d.ts.map +1 -0
- package/dist/auth/commands/default-command.js +71 -0
- package/dist/auth/commands/default-command.js.map +1 -0
- package/dist/auth/commands/index.d.ts +12 -0
- package/dist/auth/commands/index.d.ts.map +1 -0
- package/dist/auth/commands/index.js +25 -0
- package/dist/auth/commands/index.js.map +1 -0
- package/dist/auth/commands/list-command.d.ts +11 -0
- package/dist/auth/commands/list-command.d.ts.map +1 -0
- package/dist/auth/commands/list-command.js +124 -0
- package/dist/auth/commands/list-command.js.map +1 -0
- package/dist/auth/commands/remove-command.d.ts +11 -0
- package/dist/auth/commands/remove-command.d.ts.map +1 -0
- package/dist/auth/commands/remove-command.js +102 -0
- package/dist/auth/commands/remove-command.js.map +1 -0
- package/dist/auth/commands/show-command.d.ts +11 -0
- package/dist/auth/commands/show-command.d.ts.map +1 -0
- package/dist/auth/commands/show-command.js +103 -0
- package/dist/auth/commands/show-command.js.map +1 -0
- package/dist/auth/commands/types.d.ts +50 -0
- package/dist/auth/commands/types.d.ts.map +1 -0
- package/dist/auth/commands/types.js +26 -0
- package/dist/auth/commands/types.js.map +1 -0
- package/dist/auth/index.d.ts +8 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +16 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/profile-detector.d.ts +0 -5
- package/dist/auth/profile-detector.d.ts.map +1 -1
- package/dist/auth/profile-detector.js +1 -9
- package/dist/auth/profile-detector.js.map +1 -1
- package/dist/auth/profile-registry.d.ts +0 -4
- package/dist/auth/profile-registry.d.ts.map +1 -1
- package/dist/auth/profile-registry.js +3 -10
- package/dist/auth/profile-registry.js.map +1 -1
- package/dist/ccs.js +21 -4
- package/dist/ccs.js.map +1 -1
- package/dist/cliproxy/auth/auth-types.d.ts +85 -0
- package/dist/cliproxy/auth/auth-types.d.ts.map +1 -0
- package/dist/cliproxy/auth/auth-types.js +100 -0
- package/dist/cliproxy/auth/auth-types.js.map +1 -0
- package/dist/cliproxy/auth/environment-detector.d.ts +30 -0
- package/dist/cliproxy/auth/environment-detector.d.ts.map +1 -0
- package/dist/cliproxy/auth/environment-detector.js +124 -0
- package/dist/cliproxy/auth/environment-detector.js.map +1 -0
- package/dist/cliproxy/auth/index.d.ts +11 -0
- package/dist/cliproxy/auth/index.d.ts.map +1 -0
- package/dist/cliproxy/auth/index.js +35 -0
- package/dist/cliproxy/auth/index.js.map +1 -0
- package/dist/cliproxy/auth/oauth-handler.d.ts +29 -0
- package/dist/cliproxy/auth/oauth-handler.d.ts.map +1 -0
- package/dist/cliproxy/auth/oauth-handler.js +205 -0
- package/dist/cliproxy/auth/oauth-handler.js.map +1 -0
- package/dist/cliproxy/auth/oauth-process.d.ts +27 -0
- package/dist/cliproxy/auth/oauth-process.d.ts.map +1 -0
- package/dist/cliproxy/auth/oauth-process.js +209 -0
- package/dist/cliproxy/auth/oauth-process.js.map +1 -0
- package/dist/cliproxy/auth/token-manager.d.ts +53 -0
- package/dist/cliproxy/auth/token-manager.d.ts.map +1 -0
- package/dist/cliproxy/auth/token-manager.js +250 -0
- package/dist/cliproxy/auth/token-manager.js.map +1 -0
- package/dist/cliproxy/auth-handler.d.ts +13 -103
- package/dist/cliproxy/auth-handler.d.ts.map +1 -1
- package/dist/cliproxy/auth-handler.js +35 -766
- package/dist/cliproxy/auth-handler.js.map +1 -1
- package/dist/cliproxy/binary/downloader.d.ts +29 -0
- package/dist/cliproxy/binary/downloader.d.ts.map +1 -0
- package/dist/cliproxy/binary/downloader.js +218 -0
- package/dist/cliproxy/binary/downloader.js.map +1 -0
- package/dist/cliproxy/binary/extractor.d.ts +12 -0
- package/dist/cliproxy/binary/extractor.d.ts.map +1 -0
- package/dist/cliproxy/binary/extractor.js +27 -0
- package/dist/cliproxy/binary/extractor.js.map +1 -0
- package/dist/cliproxy/binary/index.d.ts +13 -0
- package/dist/cliproxy/binary/index.d.ts.map +1 -0
- package/dist/cliproxy/binary/index.js +53 -0
- package/dist/cliproxy/binary/index.js.map +1 -0
- package/dist/cliproxy/binary/installer.d.ts +24 -0
- package/dist/cliproxy/binary/installer.d.ts.map +1 -0
- package/dist/cliproxy/binary/installer.js +117 -0
- package/dist/cliproxy/binary/installer.js.map +1 -0
- package/dist/cliproxy/binary/lifecycle.d.ts +11 -0
- package/dist/cliproxy/binary/lifecycle.d.ts.map +1 -0
- package/dist/cliproxy/binary/lifecycle.js +106 -0
- package/dist/cliproxy/binary/lifecycle.js.map +1 -0
- package/dist/cliproxy/binary/tar-extractor.d.ts +9 -0
- package/dist/cliproxy/binary/tar-extractor.d.ts.map +1 -0
- package/dist/cliproxy/binary/tar-extractor.js +118 -0
- package/dist/cliproxy/binary/tar-extractor.js.map +1 -0
- package/dist/cliproxy/binary/types.d.ts +24 -0
- package/dist/cliproxy/binary/types.d.ts.map +1 -0
- package/dist/cliproxy/binary/types.js +14 -0
- package/dist/cliproxy/binary/types.js.map +1 -0
- package/dist/cliproxy/binary/updater.d.ts +7 -0
- package/dist/cliproxy/binary/updater.d.ts.map +1 -0
- package/dist/cliproxy/binary/updater.js +18 -0
- package/dist/cliproxy/binary/updater.js.map +1 -0
- package/dist/cliproxy/binary/verifier.d.ts +18 -0
- package/dist/cliproxy/binary/verifier.d.ts.map +1 -0
- package/dist/cliproxy/binary/verifier.js +82 -0
- package/dist/cliproxy/binary/verifier.js.map +1 -0
- package/dist/cliproxy/binary/version-cache.d.ts +46 -0
- package/dist/cliproxy/binary/version-cache.d.ts.map +1 -0
- package/dist/cliproxy/binary/version-cache.js +171 -0
- package/dist/cliproxy/binary/version-cache.js.map +1 -0
- package/dist/cliproxy/binary/version-checker.d.ts +19 -0
- package/dist/cliproxy/binary/version-checker.d.ts.map +1 -0
- package/dist/cliproxy/binary/version-checker.js +77 -0
- package/dist/cliproxy/binary/version-checker.js.map +1 -0
- package/dist/cliproxy/binary/zip-extractor.d.ts +9 -0
- package/dist/cliproxy/binary/zip-extractor.d.ts.map +1 -0
- package/dist/cliproxy/binary/zip-extractor.js +110 -0
- package/dist/cliproxy/binary/zip-extractor.js.map +1 -0
- package/dist/cliproxy/binary-manager.d.ts +16 -170
- package/dist/cliproxy/binary-manager.d.ts.map +1 -1
- package/dist/cliproxy/binary-manager.js +38 -865
- package/dist/cliproxy/binary-manager.js.map +1 -1
- package/dist/cliproxy/services/binary-service.d.ts +65 -0
- package/dist/cliproxy/services/binary-service.d.ts.map +1 -0
- package/dist/cliproxy/services/binary-service.js +140 -0
- package/dist/cliproxy/services/binary-service.js.map +1 -0
- package/dist/cliproxy/services/index.d.ts +8 -0
- package/dist/cliproxy/services/index.d.ts.map +1 -0
- package/dist/cliproxy/services/index.js +31 -0
- package/dist/cliproxy/services/index.js.map +1 -0
- package/dist/cliproxy/services/proxy-lifecycle-service.d.ts +38 -0
- package/dist/cliproxy/services/proxy-lifecycle-service.d.ts.map +1 -0
- package/dist/cliproxy/services/proxy-lifecycle-service.js +41 -0
- package/dist/cliproxy/services/proxy-lifecycle-service.js.map +1 -0
- package/dist/cliproxy/services/variant-config-adapter.d.ts +38 -0
- package/dist/cliproxy/services/variant-config-adapter.d.ts.map +1 -0
- package/dist/cliproxy/services/variant-config-adapter.js +172 -0
- package/dist/cliproxy/services/variant-config-adapter.js.map +1 -0
- package/dist/cliproxy/services/variant-service.d.ts +37 -0
- package/dist/cliproxy/services/variant-service.d.ts.map +1 -0
- package/dist/cliproxy/services/variant-service.js +128 -0
- package/dist/cliproxy/services/variant-service.js.map +1 -0
- package/dist/cliproxy/services/variant-settings.d.ts +32 -0
- package/dist/cliproxy/services/variant-settings.d.ts.map +1 -0
- package/dist/cliproxy/services/variant-settings.js +128 -0
- package/dist/cliproxy/services/variant-settings.js.map +1 -0
- package/dist/commands/api-command.d.ts +3 -6
- package/dist/commands/api-command.d.ts.map +1 -1
- package/dist/commands/api-command.js +84 -445
- package/dist/commands/api-command.js.map +1 -1
- package/dist/commands/cliproxy-command.d.ts +0 -3
- package/dist/commands/cliproxy-command.d.ts.map +1 -1
- package/dist/commands/cliproxy-command.js +182 -621
- package/dist/commands/cliproxy-command.js.map +1 -1
- package/dist/commands/index.d.ts +17 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +33 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/config/unified-config-loader.d.ts +7 -0
- package/dist/config/unified-config-loader.d.ts.map +1 -1
- package/dist/config/unified-config-loader.js +11 -1
- package/dist/config/unified-config-loader.js.map +1 -1
- package/dist/delegation/executor/index.d.ts +7 -0
- package/dist/delegation/executor/index.d.ts.map +1 -0
- package/dist/delegation/executor/index.js +28 -0
- package/dist/delegation/executor/index.js.map +1 -0
- package/dist/delegation/executor/result-aggregator.d.ts +30 -0
- package/dist/delegation/executor/result-aggregator.d.ts.map +1 -0
- package/dist/delegation/executor/result-aggregator.js +66 -0
- package/dist/delegation/executor/result-aggregator.js.map +1 -0
- package/dist/delegation/executor/stream-parser.d.ts +28 -0
- package/dist/delegation/executor/stream-parser.d.ts.map +1 -0
- package/dist/delegation/executor/stream-parser.js +140 -0
- package/dist/delegation/executor/stream-parser.js.map +1 -0
- package/dist/delegation/executor/types.d.ts +121 -0
- package/dist/delegation/executor/types.d.ts.map +1 -0
- package/dist/delegation/executor/types.js +6 -0
- package/dist/delegation/executor/types.js.map +1 -0
- package/dist/delegation/headless-executor.d.ts +13 -91
- package/dist/delegation/headless-executor.d.ts.map +1 -1
- package/dist/delegation/headless-executor.js +84 -291
- package/dist/delegation/headless-executor.js.map +1 -1
- package/dist/delegation/index.d.ts +11 -0
- package/dist/delegation/index.d.ts.map +1 -0
- package/dist/delegation/index.js +33 -0
- package/dist/delegation/index.js.map +1 -0
- package/dist/delegation/result-formatter.d.ts +1 -30
- package/dist/delegation/result-formatter.d.ts.map +1 -1
- package/dist/delegation/result-formatter.js.map +1 -1
- package/dist/errors/cleanup-registry.d.ts +64 -0
- package/dist/errors/cleanup-registry.d.ts.map +1 -0
- package/dist/errors/cleanup-registry.js +141 -0
- package/dist/errors/cleanup-registry.js.map +1 -0
- package/dist/errors/error-handler.d.ts +45 -0
- package/dist/errors/error-handler.d.ts.map +1 -0
- package/dist/errors/error-handler.js +150 -0
- package/dist/errors/error-handler.js.map +1 -0
- package/dist/errors/error-types.d.ts +102 -0
- package/dist/errors/error-types.d.ts.map +1 -0
- package/dist/errors/error-types.js +158 -0
- package/dist/errors/error-types.js.map +1 -0
- package/dist/errors/exit-codes.d.ts +49 -0
- package/dist/errors/exit-codes.d.ts.map +1 -0
- package/dist/errors/exit-codes.js +72 -0
- package/dist/errors/exit-codes.js.map +1 -0
- package/dist/errors/index.d.ts +29 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +62 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/glmt/glmt-transformer.d.ts +29 -248
- package/dist/glmt/glmt-transformer.d.ts.map +1 -1
- package/dist/glmt/glmt-transformer.js +63 -718
- package/dist/glmt/glmt-transformer.js.map +1 -1
- package/dist/glmt/index.d.ts +14 -0
- package/dist/glmt/index.d.ts.map +1 -0
- package/dist/glmt/index.js +41 -0
- package/dist/glmt/index.js.map +1 -0
- package/dist/glmt/pipeline/content-transformer.d.ts +39 -0
- package/dist/glmt/pipeline/content-transformer.d.ts.map +1 -0
- package/dist/glmt/pipeline/content-transformer.js +162 -0
- package/dist/glmt/pipeline/content-transformer.js.map +1 -0
- package/dist/glmt/pipeline/index.d.ts +12 -0
- package/dist/glmt/pipeline/index.d.ts.map +1 -0
- package/dist/glmt/pipeline/index.js +20 -0
- package/dist/glmt/pipeline/index.js.map +1 -0
- package/dist/glmt/pipeline/request-transformer.d.ts +31 -0
- package/dist/glmt/pipeline/request-transformer.d.ts.map +1 -0
- package/dist/glmt/pipeline/request-transformer.js +116 -0
- package/dist/glmt/pipeline/request-transformer.js.map +1 -0
- package/dist/glmt/pipeline/response-builder.d.ts +52 -0
- package/dist/glmt/pipeline/response-builder.d.ts.map +1 -0
- package/dist/glmt/pipeline/response-builder.js +205 -0
- package/dist/glmt/pipeline/response-builder.js.map +1 -0
- package/dist/glmt/pipeline/stream-parser.d.ts +59 -0
- package/dist/glmt/pipeline/stream-parser.d.ts.map +1 -0
- package/dist/glmt/pipeline/stream-parser.js +241 -0
- package/dist/glmt/pipeline/stream-parser.js.map +1 -0
- package/dist/glmt/pipeline/tool-call-handler.d.ts +22 -0
- package/dist/glmt/pipeline/tool-call-handler.d.ts.map +1 -0
- package/dist/glmt/pipeline/tool-call-handler.js +87 -0
- package/dist/glmt/pipeline/tool-call-handler.js.map +1 -0
- package/dist/glmt/pipeline/types.d.ts +159 -0
- package/dist/glmt/pipeline/types.d.ts.map +1 -0
- package/dist/glmt/pipeline/types.js +6 -0
- package/dist/glmt/pipeline/types.js.map +1 -0
- package/dist/management/checks/cliproxy-check.d.ts +37 -0
- package/dist/management/checks/cliproxy-check.d.ts.map +1 -0
- package/dist/management/checks/cliproxy-check.js +187 -0
- package/dist/management/checks/cliproxy-check.js.map +1 -0
- package/dist/management/checks/config-check.d.ts +27 -0
- package/dist/management/checks/config-check.d.ts.map +1 -0
- package/dist/management/checks/config-check.js +158 -0
- package/dist/management/checks/config-check.js.map +1 -0
- package/dist/management/checks/env-check.d.ts +17 -0
- package/dist/management/checks/env-check.d.ts.map +1 -0
- package/dist/management/checks/env-check.js +71 -0
- package/dist/management/checks/env-check.js.map +1 -0
- package/dist/management/checks/index.d.ts +12 -0
- package/dist/management/checks/index.d.ts.map +1 -0
- package/dist/management/checks/index.js +48 -0
- package/dist/management/checks/index.js.map +1 -0
- package/dist/management/checks/oauth-check.d.ts +16 -0
- package/dist/management/checks/oauth-check.d.ts.map +1 -0
- package/dist/management/checks/oauth-check.js +68 -0
- package/dist/management/checks/oauth-check.js.map +1 -0
- package/dist/management/checks/profile-check.d.ts +36 -0
- package/dist/management/checks/profile-check.d.ts.map +1 -0
- package/dist/management/checks/profile-check.js +165 -0
- package/dist/management/checks/profile-check.js.map +1 -0
- package/dist/management/checks/symlink-check.d.ts +30 -0
- package/dist/management/checks/symlink-check.d.ts.map +1 -0
- package/dist/management/checks/symlink-check.js +204 -0
- package/dist/management/checks/symlink-check.js.map +1 -0
- package/dist/management/checks/system-check.d.ts +25 -0
- package/dist/management/checks/system-check.d.ts.map +1 -0
- package/dist/management/checks/system-check.js +136 -0
- package/dist/management/checks/system-check.js.map +1 -0
- package/dist/management/checks/types.d.ts +64 -0
- package/dist/management/checks/types.d.ts.map +1 -0
- package/dist/management/checks/types.js +63 -0
- package/dist/management/checks/types.js.map +1 -0
- package/dist/management/doctor.d.ts +3 -92
- package/dist/management/doctor.d.ts.map +1 -1
- package/dist/management/doctor.js +15 -831
- package/dist/management/doctor.js.map +1 -1
- package/dist/management/index.d.ts +15 -0
- package/dist/management/index.d.ts.map +1 -0
- package/dist/management/index.js +56 -0
- package/dist/management/index.js.map +1 -0
- package/dist/management/repair/auto-repair.d.ts +13 -0
- package/dist/management/repair/auto-repair.d.ts.map +1 -0
- package/dist/management/repair/auto-repair.js +170 -0
- package/dist/management/repair/auto-repair.js.map +1 -0
- package/dist/management/repair/index.d.ts +5 -0
- package/dist/management/repair/index.d.ts.map +1 -0
- package/dist/management/repair/index.js +9 -0
- package/dist/management/repair/index.js.map +1 -0
- package/dist/types/delegation.d.ts +1 -13
- package/dist/types/delegation.d.ts.map +1 -1
- package/dist/types/utils.d.ts +27 -0
- package/dist/types/utils.d.ts.map +1 -1
- package/dist/ui/assets/{accounts-p1_nf0Jy.js → accounts-BqDNXZu4.js} +1 -1
- package/dist/ui/assets/analytics-DQMyOsqI.js +1 -0
- package/dist/ui/assets/api-Bzyq4XP7.js +1 -0
- package/dist/ui/assets/{card-CCDc-Mx9.js → card-CIN0KDsX.js} +1 -1
- package/dist/ui/assets/cliproxy-5iKdPrEG.js +3 -0
- package/dist/ui/assets/cliproxy-control-panel-CJ2CfYod.js +1 -0
- package/dist/ui/assets/{code-editor-Br9x-r-E.js → code-editor-CDmNFLQ6.js} +1 -1
- package/dist/ui/assets/confirm-dialog-CaiDQikc.js +1 -0
- package/dist/ui/assets/copilot-nS6iAyk2.js +4 -0
- package/dist/ui/assets/form-utils-DP6ILe7Z.js +20 -0
- package/dist/ui/assets/health-DYOQfC7u.js +1 -0
- package/dist/ui/assets/{icons-BOsxPbiD.js → icons-ZmwVoUeR.js} +1 -1
- package/dist/ui/assets/index-C6Dah-xh.js +46 -0
- package/dist/ui/assets/index-It66SkKf.css +1 -0
- package/dist/ui/assets/{radix-ui-DFHQr9A5.js → radix-ui-CV3R9pD6.js} +3 -3
- package/dist/ui/assets/settings-DABC9b5G.js +1 -0
- package/dist/ui/assets/{shared-BfYhSN4-.js → shared-BwU4OKQc.js} +1 -1
- package/dist/ui/assets/{switch-CMk95lwf.js → switch-BQ6sBBUv.js} +1 -1
- package/dist/ui/assets/{tanstack-C4gT2P7V.js → tanstack-Df9bCj5R.js} +1 -1
- package/dist/ui/index.html +6 -6
- package/dist/utils/claude-spawner.d.ts +54 -0
- package/dist/utils/claude-spawner.d.ts.map +1 -0
- package/dist/utils/claude-spawner.js +118 -0
- package/dist/utils/claude-spawner.js.map +1 -0
- package/dist/utils/delegation-validator.d.ts +8 -4
- package/dist/utils/delegation-validator.d.ts.map +1 -1
- package/dist/utils/delegation-validator.js.map +1 -1
- package/dist/utils/helpers.d.ts +0 -11
- package/dist/utils/helpers.d.ts.map +1 -1
- package/dist/utils/helpers.js +1 -57
- package/dist/utils/helpers.js.map +1 -1
- package/dist/utils/index.d.ts +15 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +50 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/time.d.ts +10 -0
- package/dist/utils/time.d.ts.map +1 -0
- package/dist/utils/time.js +27 -0
- package/dist/utils/time.js.map +1 -0
- package/dist/utils/ui/boxes.d.ts +24 -0
- package/dist/utils/ui/boxes.d.ts.map +1 -0
- package/dist/utils/ui/boxes.js +108 -0
- package/dist/utils/ui/boxes.js.map +1 -0
- package/dist/utils/ui/colors.d.ts +25 -0
- package/dist/utils/ui/colors.d.ts.map +1 -0
- package/dist/utils/ui/colors.js +70 -0
- package/dist/utils/ui/colors.js.map +1 -0
- package/dist/utils/ui/index.d.ts +51 -0
- package/dist/utils/ui/index.d.ts.map +1 -0
- package/dist/utils/ui/index.js +96 -0
- package/dist/utils/ui/index.js.map +1 -0
- package/dist/utils/ui/indicators.d.ts +23 -0
- package/dist/utils/ui/indicators.d.ts.map +1 -0
- package/dist/utils/ui/indicators.js +39 -0
- package/dist/utils/ui/indicators.js.map +1 -0
- package/dist/utils/ui/init.d.ts +30 -0
- package/dist/utils/ui/init.d.ts.map +1 -0
- package/dist/utils/ui/init.js +102 -0
- package/dist/utils/ui/init.js.map +1 -0
- package/dist/utils/ui/spinner.d.ts +13 -0
- package/dist/utils/ui/spinner.d.ts.map +1 -0
- package/dist/utils/ui/spinner.js +89 -0
- package/dist/utils/ui/spinner.js.map +1 -0
- package/dist/utils/ui/tables.d.ts +12 -0
- package/dist/utils/ui/tables.d.ts.map +1 -0
- package/dist/utils/ui/tables.js +69 -0
- package/dist/utils/ui/tables.js.map +1 -0
- package/dist/utils/ui/tasks.d.ts +26 -0
- package/dist/utils/ui/tasks.d.ts.map +1 -0
- package/dist/utils/ui/tasks.js +102 -0
- package/dist/utils/ui/tasks.js.map +1 -0
- package/dist/utils/ui/text.d.ts +24 -0
- package/dist/utils/ui/text.d.ts.map +1 -0
- package/dist/utils/ui/text.js +60 -0
- package/dist/utils/ui/text.js.map +1 -0
- package/dist/utils/ui/types.d.ts +36 -0
- package/dist/utils/ui/types.d.ts.map +1 -0
- package/dist/utils/ui/types.js +33 -0
- package/dist/utils/ui/types.js.map +1 -0
- package/dist/utils/ui.d.ts +3 -138
- package/dist/utils/ui.d.ts.map +1 -1
- package/dist/utils/ui.js +40 -567
- package/dist/utils/ui.js.map +1 -1
- package/dist/utils/websearch/gemini-cli.d.ts +36 -0
- package/dist/utils/websearch/gemini-cli.d.ts.map +1 -0
- package/dist/utils/websearch/gemini-cli.js +132 -0
- package/dist/utils/websearch/gemini-cli.js.map +1 -0
- package/dist/utils/websearch/grok-cli.d.ts +26 -0
- package/dist/utils/websearch/grok-cli.d.ts.map +1 -0
- package/dist/utils/websearch/grok-cli.js +81 -0
- package/dist/utils/websearch/grok-cli.js.map +1 -0
- package/dist/utils/websearch/hook-config.d.ts +21 -0
- package/dist/utils/websearch/hook-config.d.ts.map +1 -0
- package/dist/utils/websearch/hook-config.js +183 -0
- package/dist/utils/websearch/hook-config.js.map +1 -0
- package/dist/utils/websearch/hook-env.d.ts +16 -0
- package/dist/utils/websearch/hook-env.d.ts.map +1 -0
- package/dist/utils/websearch/hook-env.js +62 -0
- package/dist/utils/websearch/hook-env.js.map +1 -0
- package/dist/utils/websearch/hook-installer.d.ts +27 -0
- package/dist/utils/websearch/hook-installer.d.ts.map +1 -0
- package/dist/utils/websearch/hook-installer.js +141 -0
- package/dist/utils/websearch/hook-installer.js.map +1 -0
- package/dist/utils/websearch/index.d.ts +15 -0
- package/dist/utils/websearch/index.d.ts.map +1 -0
- package/dist/utils/websearch/index.js +44 -0
- package/dist/utils/websearch/index.js.map +1 -0
- package/dist/utils/websearch/opencode-cli.d.ts +26 -0
- package/dist/utils/websearch/opencode-cli.d.ts.map +1 -0
- package/dist/utils/websearch/opencode-cli.js +81 -0
- package/dist/utils/websearch/opencode-cli.js.map +1 -0
- package/dist/utils/websearch/status.d.ts +35 -0
- package/dist/utils/websearch/status.d.ts.map +1 -0
- package/dist/utils/websearch/status.js +185 -0
- package/dist/utils/websearch/status.js.map +1 -0
- package/dist/utils/websearch/types.d.ts +85 -0
- package/dist/utils/websearch/types.d.ts.map +1 -0
- package/dist/utils/websearch/types.js +10 -0
- package/dist/utils/websearch/types.js.map +1 -0
- package/dist/utils/websearch-manager.d.ts +7 -186
- package/dist/utils/websearch-manager.d.ts.map +1 -1
- package/dist/utils/websearch-manager.js +37 -710
- package/dist/utils/websearch-manager.js.map +1 -1
- package/dist/web-server/data-aggregator.d.ts +3 -51
- package/dist/web-server/data-aggregator.d.ts.map +1 -1
- package/dist/web-server/data-aggregator.js +18 -386
- package/dist/web-server/data-aggregator.js.map +1 -1
- package/dist/web-server/health/cliproxy-checks.d.ts +23 -0
- package/dist/web-server/health/cliproxy-checks.d.ts.map +1 -0
- package/dist/web-server/health/cliproxy-checks.js +145 -0
- package/dist/web-server/health/cliproxy-checks.js.map +1 -0
- package/dist/web-server/health/config-checks.d.ts +19 -0
- package/dist/web-server/health/config-checks.d.ts.map +1 -0
- package/dist/web-server/health/config-checks.js +174 -0
- package/dist/web-server/health/config-checks.js.map +1 -0
- package/dist/web-server/health/environment-checks.d.ts +11 -0
- package/dist/web-server/health/environment-checks.d.ts.map +1 -0
- package/dist/web-server/health/environment-checks.js +40 -0
- package/dist/web-server/health/environment-checks.js.map +1 -0
- package/dist/web-server/health/index.d.ts +13 -0
- package/dist/web-server/health/index.d.ts.map +1 -0
- package/dist/web-server/health/index.js +41 -0
- package/dist/web-server/health/index.js.map +1 -0
- package/dist/web-server/health/oauth-checks.d.ts +11 -0
- package/dist/web-server/health/oauth-checks.d.ts.map +1 -0
- package/dist/web-server/health/oauth-checks.js +34 -0
- package/dist/web-server/health/oauth-checks.js.map +1 -0
- package/dist/web-server/health/profile-checks.d.ts +19 -0
- package/dist/web-server/health/profile-checks.d.ts.map +1 -0
- package/dist/web-server/health/profile-checks.js +152 -0
- package/dist/web-server/health/profile-checks.js.map +1 -0
- package/dist/web-server/health/symlink-checks.d.ts +15 -0
- package/dist/web-server/health/symlink-checks.d.ts.map +1 -0
- package/dist/web-server/health/symlink-checks.js +173 -0
- package/dist/web-server/health/symlink-checks.js.map +1 -0
- package/dist/web-server/health/system-checks.d.ts +19 -0
- package/dist/web-server/health/system-checks.d.ts.map +1 -0
- package/dist/web-server/health/system-checks.js +127 -0
- package/dist/web-server/health/system-checks.js.map +1 -0
- package/dist/web-server/health/types.d.ts +34 -0
- package/dist/web-server/health/types.d.ts.map +1 -0
- package/dist/web-server/health/types.js +8 -0
- package/dist/web-server/health/types.js.map +1 -0
- package/dist/web-server/health/websearch-checks.d.ts +11 -0
- package/dist/web-server/health/websearch-checks.d.ts.map +1 -0
- package/dist/web-server/health/websearch-checks.js +53 -0
- package/dist/web-server/health/websearch-checks.js.map +1 -0
- package/dist/web-server/health-service.d.ts +4 -30
- package/dist/web-server/health-service.d.ts.map +1 -1
- package/dist/web-server/health-service.js +28 -695
- package/dist/web-server/health-service.js.map +1 -1
- package/dist/web-server/index.d.ts.map +1 -1
- package/dist/web-server/index.js +2 -5
- package/dist/web-server/index.js.map +1 -1
- package/dist/web-server/routes/cliproxy-auth-routes.d.ts +6 -0
- package/dist/web-server/routes/cliproxy-auth-routes.d.ts.map +1 -0
- package/dist/web-server/routes/cliproxy-auth-routes.js +202 -0
- package/dist/web-server/routes/cliproxy-auth-routes.js.map +1 -0
- package/dist/web-server/routes/cliproxy-stats-routes.d.ts +6 -0
- package/dist/web-server/routes/cliproxy-stats-routes.d.ts.map +1 -0
- package/dist/web-server/routes/cliproxy-stats-routes.js +253 -0
- package/dist/web-server/routes/cliproxy-stats-routes.js.map +1 -0
- package/dist/web-server/routes/config-routes.d.ts +6 -0
- package/dist/web-server/routes/config-routes.d.ts.map +1 -0
- package/dist/web-server/routes/config-routes.js +145 -0
- package/dist/web-server/routes/config-routes.js.map +1 -0
- package/dist/web-server/routes/copilot-routes.d.ts +6 -0
- package/dist/web-server/routes/copilot-routes.d.ts.map +1 -0
- package/dist/web-server/routes/copilot-routes.js +195 -0
- package/dist/web-server/routes/copilot-routes.js.map +1 -0
- package/dist/web-server/routes/copilot-settings-routes.d.ts +6 -0
- package/dist/web-server/routes/copilot-settings-routes.d.ts.map +1 -0
- package/dist/web-server/routes/copilot-settings-routes.js +122 -0
- package/dist/web-server/routes/copilot-settings-routes.js.map +1 -0
- package/dist/web-server/routes/health-routes.d.ts +6 -0
- package/dist/web-server/routes/health-routes.d.ts.map +1 -0
- package/dist/web-server/routes/health-routes.js +30 -0
- package/dist/web-server/routes/health-routes.js.map +1 -0
- package/dist/web-server/routes/index.d.ts +8 -0
- package/dist/web-server/routes/index.d.ts.map +1 -0
- package/dist/web-server/routes/index.js +54 -0
- package/dist/web-server/routes/index.js.map +1 -0
- package/dist/web-server/routes/misc-routes.d.ts +6 -0
- package/dist/web-server/routes/misc-routes.d.ts.map +1 -0
- package/dist/web-server/routes/misc-routes.js +219 -0
- package/dist/web-server/routes/misc-routes.js.map +1 -0
- package/dist/web-server/routes/profile-routes.d.ts +6 -0
- package/dist/web-server/routes/profile-routes.d.ts.map +1 -0
- package/dist/web-server/routes/profile-routes.js +164 -0
- package/dist/web-server/routes/profile-routes.js.map +1 -0
- package/dist/web-server/routes/provider-routes.d.ts +6 -0
- package/dist/web-server/routes/provider-routes.d.ts.map +1 -0
- package/dist/web-server/routes/provider-routes.js +146 -0
- package/dist/web-server/routes/provider-routes.js.map +1 -0
- package/dist/web-server/routes/route-helpers.d.ts +55 -0
- package/dist/web-server/routes/route-helpers.d.ts.map +1 -0
- package/dist/web-server/routes/route-helpers.js +201 -0
- package/dist/web-server/routes/route-helpers.js.map +1 -0
- package/dist/web-server/routes/settings-routes.d.ts +6 -0
- package/dist/web-server/routes/settings-routes.d.ts.map +1 -0
- package/dist/web-server/routes/settings-routes.js +207 -0
- package/dist/web-server/routes/settings-routes.js.map +1 -0
- package/dist/web-server/routes/variant-routes.d.ts +6 -0
- package/dist/web-server/routes/variant-routes.d.ts.map +1 -0
- package/dist/web-server/routes/variant-routes.js +158 -0
- package/dist/web-server/routes/variant-routes.js.map +1 -0
- package/dist/web-server/routes/websearch-routes.d.ts +6 -0
- package/dist/web-server/routes/websearch-routes.d.ts.map +1 -0
- package/dist/web-server/routes/websearch-routes.js +130 -0
- package/dist/web-server/routes/websearch-routes.js.map +1 -0
- package/dist/web-server/services/index.d.ts +7 -0
- package/dist/web-server/services/index.d.ts.map +1 -0
- package/dist/web-server/services/index.js +21 -0
- package/dist/web-server/services/index.js.map +1 -0
- package/dist/web-server/services/usage-aggregator.d.ts +7 -0
- package/dist/web-server/services/usage-aggregator.d.ts.map +1 -0
- package/dist/web-server/services/usage-aggregator.js +23 -0
- package/dist/web-server/services/usage-aggregator.js.map +1 -0
- package/dist/web-server/usage/aggregator.d.ts +54 -0
- package/dist/web-server/usage/aggregator.d.ts.map +1 -0
- package/dist/web-server/usage/aggregator.js +470 -0
- package/dist/web-server/usage/aggregator.js.map +1 -0
- package/dist/web-server/usage/data-aggregator.d.ts +55 -0
- package/dist/web-server/usage/data-aggregator.d.ts.map +1 -0
- package/dist/web-server/usage/data-aggregator.js +391 -0
- package/dist/web-server/usage/data-aggregator.js.map +1 -0
- package/dist/web-server/usage/disk-cache.d.ts +46 -0
- package/dist/web-server/usage/disk-cache.d.ts.map +1 -0
- package/dist/web-server/usage/disk-cache.js +162 -0
- package/dist/web-server/usage/disk-cache.js.map +1 -0
- package/dist/web-server/usage/handlers.d.ts +50 -0
- package/dist/web-server/usage/handlers.d.ts.map +1 -0
- package/dist/web-server/usage/handlers.js +524 -0
- package/dist/web-server/usage/handlers.js.map +1 -0
- package/dist/web-server/usage/index.d.ts +12 -0
- package/dist/web-server/usage/index.d.ts.map +1 -0
- package/dist/web-server/usage/index.js +54 -0
- package/dist/web-server/usage/index.js.map +1 -0
- package/dist/web-server/usage/routes.d.ts +11 -0
- package/dist/web-server/usage/routes.d.ts.map +1 -0
- package/dist/web-server/usage/routes.js +37 -0
- package/dist/web-server/usage/routes.js.map +1 -0
- package/dist/web-server/usage/types.d.ts +119 -0
- package/dist/web-server/usage/types.d.ts.map +1 -0
- package/dist/web-server/usage/types.js +9 -0
- package/dist/web-server/usage/types.js.map +1 -0
- package/dist/web-server/usage-disk-cache.d.ts +3 -42
- package/dist/web-server/usage-disk-cache.d.ts.map +1 -1
- package/dist/web-server/usage-disk-cache.js +5 -144
- package/dist/web-server/usage-disk-cache.js.map +1 -1
- package/dist/web-server/usage-routes.d.ts +3 -31
- package/dist/web-server/usage-routes.d.ts.map +1 -1
- package/dist/web-server/usage-routes.js +8 -1139
- package/dist/web-server/usage-routes.js.map +1 -1
- package/dist/web-server/usage-types.d.ts +3 -115
- package/dist/web-server/usage-types.d.ts.map +1 -1
- package/dist/web-server/usage-types.js +17 -3
- package/dist/web-server/usage-types.js.map +1 -1
- package/package.json +1 -1
- package/dist/ui/assets/analytics-D1k2nYcF.js +0 -1
- package/dist/ui/assets/api-D9VVmZ1j.js +0 -1
- package/dist/ui/assets/cliproxy-CTt_Nsft.js +0 -1
- package/dist/ui/assets/cliproxy-control-panel-DKMAi4_4.js +0 -1
- package/dist/ui/assets/copilot-C6F8PT_L.js +0 -4
- package/dist/ui/assets/form-utils-BuXDJb0w.js +0 -20
- package/dist/ui/assets/health-DiAvJaSn.js +0 -1
- package/dist/ui/assets/index-Brq6EBKZ.css +0 -1
- package/dist/ui/assets/index-ByU8ZhED.js +0 -48
- package/dist/ui/assets/settings-CEomZLGl.js +0 -1
- package/dist/web-server/routes.d.ts +0 -7
- package/dist/web-server/routes.d.ts.map +0 -1
- package/dist/web-server/routes.js +0 -1891
- package/dist/web-server/routes.js.map +0 -1
|
@@ -2,57 +2,20 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Binary Manager for CLIProxyAPI
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
* - Downloads platform-specific binary from GitHub releases
|
|
7
|
-
* - Verifies SHA256 checksum
|
|
8
|
-
* - Extracts and caches binary locally
|
|
9
|
-
* - Supports retry logic with exponential backoff
|
|
10
|
-
* - Auto-checks for updates on startup (fetches latest from GitHub API)
|
|
11
|
-
*
|
|
5
|
+
* Facade pattern wrapper for modular binary management.
|
|
12
6
|
* Pattern: Mirrors npm install behavior (fast check, download only when needed)
|
|
13
7
|
*/
|
|
14
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
15
|
-
if (k2 === undefined) k2 = k;
|
|
16
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
17
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
18
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
19
|
-
}
|
|
20
|
-
Object.defineProperty(o, k2, desc);
|
|
21
|
-
}) : (function(o, m, k, k2) {
|
|
22
|
-
if (k2 === undefined) k2 = k;
|
|
23
|
-
o[k2] = m[k];
|
|
24
|
-
}));
|
|
25
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
26
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
27
|
-
}) : function(o, v) {
|
|
28
|
-
o["default"] = v;
|
|
29
|
-
});
|
|
30
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
31
|
-
if (mod && mod.__esModule) return mod;
|
|
32
|
-
var result = {};
|
|
33
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
34
|
-
__setModuleDefault(result, mod);
|
|
35
|
-
return result;
|
|
36
|
-
};
|
|
37
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
9
|
exports.isVersionPinned = exports.clearPinnedVersion = exports.savePinnedVersion = exports.getPinnedVersion = exports.getVersionPinPath = exports.checkCliproxyUpdate = exports.fetchLatestCliproxyVersion = exports.installCliproxyVersion = exports.getInstalledCliproxyVersion = exports.getCLIProxyPath = exports.isCLIProxyInstalled = exports.ensureCLIProxyBinary = exports.BinaryManager = void 0;
|
|
39
|
-
const fs = __importStar(require("fs"));
|
|
40
|
-
const path = __importStar(require("path"));
|
|
41
|
-
const https = __importStar(require("https"));
|
|
42
|
-
const http = __importStar(require("http"));
|
|
43
|
-
const crypto = __importStar(require("crypto"));
|
|
44
|
-
const zlib = __importStar(require("zlib"));
|
|
45
|
-
const progress_indicator_1 = require("../utils/progress-indicator");
|
|
46
10
|
const ui_1 = require("../utils/ui");
|
|
47
11
|
const config_generator_1 = require("./config-generator");
|
|
48
|
-
const stats_fetcher_1 = require("./stats-fetcher");
|
|
49
12
|
const platform_detector_1 = require("./platform-detector");
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
13
|
+
const binary_1 = require("./binary");
|
|
14
|
+
Object.defineProperty(exports, "getPinnedVersion", { enumerable: true, get: function () { return binary_1.getPinnedVersion; } });
|
|
15
|
+
Object.defineProperty(exports, "savePinnedVersion", { enumerable: true, get: function () { return binary_1.savePinnedVersion; } });
|
|
16
|
+
Object.defineProperty(exports, "clearPinnedVersion", { enumerable: true, get: function () { return binary_1.clearPinnedVersion; } });
|
|
17
|
+
Object.defineProperty(exports, "isVersionPinned", { enumerable: true, get: function () { return binary_1.isVersionPinned; } });
|
|
18
|
+
Object.defineProperty(exports, "getVersionPinPath", { enumerable: true, get: function () { return binary_1.getVersionPinPath; } });
|
|
56
19
|
/** Default configuration */
|
|
57
20
|
const DEFAULT_CONFIG = {
|
|
58
21
|
version: platform_detector_1.CLIPROXY_FALLBACK_VERSION,
|
|
@@ -68,874 +31,84 @@ const DEFAULT_CONFIG = {
|
|
|
68
31
|
class BinaryManager {
|
|
69
32
|
constructor(config = {}) {
|
|
70
33
|
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
71
|
-
this.verbose = this.config.verbose;
|
|
72
34
|
}
|
|
73
|
-
/**
|
|
74
|
-
* Ensure binary is available (download if missing, update if outdated)
|
|
75
|
-
* @returns Path to executable binary
|
|
76
|
-
*/
|
|
35
|
+
/** Ensure binary is available (download if missing, update if outdated) */
|
|
77
36
|
async ensureBinary() {
|
|
78
|
-
|
|
79
|
-
// Check if binary already exists
|
|
80
|
-
if (fs.existsSync(binaryPath)) {
|
|
81
|
-
this.log(`Binary exists: ${binaryPath}`);
|
|
82
|
-
// Skip auto-update if forceVersion is set (user requested specific version)
|
|
83
|
-
if (this.config.forceVersion) {
|
|
84
|
-
this.log(`Force version mode: skipping auto-update`);
|
|
85
|
-
return this.getBinaryPath();
|
|
86
|
-
}
|
|
87
|
-
// Check for updates in background (non-blocking for UX)
|
|
88
|
-
try {
|
|
89
|
-
const updateResult = await this.checkForUpdates();
|
|
90
|
-
if (updateResult.hasUpdate) {
|
|
91
|
-
// Check if CLIProxyAPI is currently running - can't update while running
|
|
92
|
-
const proxyRunning = await (0, stats_fetcher_1.isCliproxyRunning)(config_generator_1.CLIPROXY_DEFAULT_PORT);
|
|
93
|
-
if (proxyRunning) {
|
|
94
|
-
// Proxy is running - can't update, just notify user
|
|
95
|
-
console.log((0, ui_1.info)(`CLIProxyAPI update available: v${updateResult.currentVersion} -> v${updateResult.latestVersion}`));
|
|
96
|
-
console.log((0, ui_1.info)('Run "ccs cliproxy stop" then restart to apply update'));
|
|
97
|
-
this.log('Skipping update: CLIProxyAPI is currently running');
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
// Proxy not running - safe to update
|
|
101
|
-
console.log((0, ui_1.info)(`CLIProxyAPI update available: v${updateResult.currentVersion} -> v${updateResult.latestVersion}`));
|
|
102
|
-
console.log((0, ui_1.info)('Updating CLIProxyAPI...'));
|
|
103
|
-
// Delete old binary and download new version
|
|
104
|
-
this.deleteBinary();
|
|
105
|
-
this.config.version = updateResult.latestVersion;
|
|
106
|
-
await this.downloadAndInstall();
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
catch (error) {
|
|
111
|
-
// Silent fail - don't block startup if update check fails
|
|
112
|
-
const err = error;
|
|
113
|
-
this.log(`Update check failed (non-blocking): ${err.message}`);
|
|
114
|
-
}
|
|
115
|
-
return this.getBinaryPath();
|
|
116
|
-
}
|
|
117
|
-
// Download, verify, extract
|
|
118
|
-
this.log('Binary not found, downloading...');
|
|
119
|
-
// Skip auto-upgrade to latest if forceVersion is set
|
|
120
|
-
if (!this.config.forceVersion) {
|
|
121
|
-
// Check latest version before first download
|
|
122
|
-
try {
|
|
123
|
-
const latestVersion = await this.fetchLatestVersion();
|
|
124
|
-
if (latestVersion && this.isNewerVersion(latestVersion, this.config.version)) {
|
|
125
|
-
this.log(`Using latest version: ${latestVersion} (instead of ${this.config.version})`);
|
|
126
|
-
this.config.version = latestVersion;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
catch {
|
|
130
|
-
// Use pinned version if API fails
|
|
131
|
-
this.log(`Using pinned version: ${this.config.version}`);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
this.log(`Force version mode: using specified version ${this.config.version}`);
|
|
136
|
-
}
|
|
137
|
-
await this.downloadAndInstall();
|
|
138
|
-
return binaryPath;
|
|
37
|
+
return (0, binary_1.ensureBinary)(this.config);
|
|
139
38
|
}
|
|
140
|
-
/**
|
|
141
|
-
* Check for updates by comparing installed version with latest release
|
|
142
|
-
* Uses cache to avoid hitting GitHub API on every run
|
|
143
|
-
*/
|
|
39
|
+
/** Check for updates by comparing installed version with latest release */
|
|
144
40
|
async checkForUpdates() {
|
|
145
|
-
|
|
146
|
-
// Try cache first
|
|
147
|
-
const cache = this.getVersionCache();
|
|
148
|
-
if (cache) {
|
|
149
|
-
this.log(`Using cached version: ${cache.latestVersion}`);
|
|
150
|
-
return {
|
|
151
|
-
hasUpdate: this.isNewerVersion(cache.latestVersion, currentVersion),
|
|
152
|
-
currentVersion,
|
|
153
|
-
latestVersion: cache.latestVersion,
|
|
154
|
-
fromCache: true,
|
|
155
|
-
checkedAt: cache.checkedAt,
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
// Fetch from GitHub API
|
|
159
|
-
const latestVersion = await this.fetchLatestVersion();
|
|
160
|
-
const now = Date.now();
|
|
161
|
-
this.cacheLatestVersion(latestVersion);
|
|
162
|
-
return {
|
|
163
|
-
hasUpdate: this.isNewerVersion(latestVersion, currentVersion),
|
|
164
|
-
currentVersion,
|
|
165
|
-
latestVersion,
|
|
166
|
-
fromCache: false,
|
|
167
|
-
checkedAt: now,
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Fetch latest version from GitHub API
|
|
172
|
-
*/
|
|
173
|
-
async fetchLatestVersion() {
|
|
174
|
-
const response = await this.fetchJson(GITHUB_API_LATEST_RELEASE);
|
|
175
|
-
// Extract version from tag_name (format: "v6.5.27" or "6.5.27")
|
|
176
|
-
const tagName = response.tag_name;
|
|
177
|
-
if (!tagName) {
|
|
178
|
-
throw new Error('No tag_name in GitHub API response');
|
|
179
|
-
}
|
|
180
|
-
return tagName.replace(/^v/, '');
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* Fetch JSON from URL (for GitHub API)
|
|
184
|
-
*/
|
|
185
|
-
fetchJson(url) {
|
|
186
|
-
return new Promise((resolve, reject) => {
|
|
187
|
-
const options = {
|
|
188
|
-
headers: {
|
|
189
|
-
'User-Agent': 'CCS-CLIProxyAPI-Updater/1.0',
|
|
190
|
-
Accept: 'application/vnd.github.v3+json',
|
|
191
|
-
},
|
|
192
|
-
};
|
|
193
|
-
const handleResponse = (res) => {
|
|
194
|
-
if (res.statusCode === 301 || res.statusCode === 302) {
|
|
195
|
-
const redirectUrl = res.headers.location;
|
|
196
|
-
if (!redirectUrl) {
|
|
197
|
-
reject(new Error('Redirect without location header'));
|
|
198
|
-
return;
|
|
199
|
-
}
|
|
200
|
-
this.fetchJson(redirectUrl).then(resolve).catch(reject);
|
|
201
|
-
return;
|
|
202
|
-
}
|
|
203
|
-
if (res.statusCode !== 200) {
|
|
204
|
-
reject(new Error(`GitHub API error: HTTP ${res.statusCode}`));
|
|
205
|
-
return;
|
|
206
|
-
}
|
|
207
|
-
let data = '';
|
|
208
|
-
res.on('data', (chunk) => (data += chunk));
|
|
209
|
-
res.on('end', () => {
|
|
210
|
-
try {
|
|
211
|
-
resolve(JSON.parse(data));
|
|
212
|
-
}
|
|
213
|
-
catch {
|
|
214
|
-
reject(new Error('Invalid JSON from GitHub API'));
|
|
215
|
-
}
|
|
216
|
-
});
|
|
217
|
-
res.on('error', reject);
|
|
218
|
-
};
|
|
219
|
-
const req = https.get(url, options, handleResponse);
|
|
220
|
-
req.on('error', reject);
|
|
221
|
-
req.setTimeout(10000, () => {
|
|
222
|
-
req.destroy();
|
|
223
|
-
reject(new Error('GitHub API timeout (10s)'));
|
|
224
|
-
});
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
/**
|
|
228
|
-
* Get installed version from version file or fallback to pinned
|
|
229
|
-
*/
|
|
230
|
-
getInstalledVersion() {
|
|
231
|
-
const versionFile = path.join(this.config.binPath, '.version');
|
|
232
|
-
if (fs.existsSync(versionFile)) {
|
|
233
|
-
try {
|
|
234
|
-
return fs.readFileSync(versionFile, 'utf8').trim();
|
|
235
|
-
}
|
|
236
|
-
catch {
|
|
237
|
-
return this.config.version;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
return this.config.version;
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* Save installed version to file
|
|
244
|
-
*/
|
|
245
|
-
saveInstalledVersion(version) {
|
|
246
|
-
const versionFile = path.join(this.config.binPath, '.version');
|
|
247
|
-
try {
|
|
248
|
-
fs.writeFileSync(versionFile, version, 'utf8');
|
|
249
|
-
}
|
|
250
|
-
catch {
|
|
251
|
-
// Silent fail - not critical
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
/**
|
|
255
|
-
* Get version cache data if still valid
|
|
256
|
-
*/
|
|
257
|
-
getVersionCache() {
|
|
258
|
-
const cachePath = this.getVersionCachePath();
|
|
259
|
-
if (!fs.existsSync(cachePath)) {
|
|
260
|
-
return null;
|
|
261
|
-
}
|
|
262
|
-
try {
|
|
263
|
-
const content = fs.readFileSync(cachePath, 'utf8');
|
|
264
|
-
const cache = JSON.parse(content);
|
|
265
|
-
// Check if cache is still valid
|
|
266
|
-
if (Date.now() - cache.checkedAt < VERSION_CACHE_DURATION_MS) {
|
|
267
|
-
return cache;
|
|
268
|
-
}
|
|
269
|
-
// Cache expired
|
|
270
|
-
return null;
|
|
271
|
-
}
|
|
272
|
-
catch {
|
|
273
|
-
return null;
|
|
274
|
-
}
|
|
41
|
+
return (0, binary_1.checkForUpdates)(this.config.binPath, this.config.version, this.config.verbose);
|
|
275
42
|
}
|
|
276
|
-
/**
|
|
277
|
-
* Cache latest version for future checks
|
|
278
|
-
*/
|
|
279
|
-
cacheLatestVersion(version) {
|
|
280
|
-
const cachePath = this.getVersionCachePath();
|
|
281
|
-
const cache = {
|
|
282
|
-
latestVersion: version,
|
|
283
|
-
checkedAt: Date.now(),
|
|
284
|
-
};
|
|
285
|
-
try {
|
|
286
|
-
fs.mkdirSync(path.dirname(cachePath), { recursive: true });
|
|
287
|
-
fs.writeFileSync(cachePath, JSON.stringify(cache), 'utf8');
|
|
288
|
-
}
|
|
289
|
-
catch {
|
|
290
|
-
// Silent fail - caching is optional
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
/**
|
|
294
|
-
* Get path to version cache file
|
|
295
|
-
*/
|
|
296
|
-
getVersionCachePath() {
|
|
297
|
-
return path.join((0, config_generator_1.getCliproxyDir)(), '.version-cache.json');
|
|
298
|
-
}
|
|
299
|
-
/**
|
|
300
|
-
* Compare semver versions (true if latest > current)
|
|
301
|
-
*/
|
|
302
|
-
isNewerVersion(latest, current) {
|
|
303
|
-
const latestParts = latest.split('.').map((p) => parseInt(p, 10) || 0);
|
|
304
|
-
const currentParts = current.split('.').map((p) => parseInt(p, 10) || 0);
|
|
305
|
-
// Pad arrays to same length
|
|
306
|
-
while (latestParts.length < 3)
|
|
307
|
-
latestParts.push(0);
|
|
308
|
-
while (currentParts.length < 3)
|
|
309
|
-
currentParts.push(0);
|
|
310
|
-
for (let i = 0; i < 3; i++) {
|
|
311
|
-
if (latestParts[i] > currentParts[i])
|
|
312
|
-
return true;
|
|
313
|
-
if (latestParts[i] < currentParts[i])
|
|
314
|
-
return false;
|
|
315
|
-
}
|
|
316
|
-
return false; // Equal versions
|
|
317
|
-
}
|
|
318
|
-
/**
|
|
319
|
-
* Get full path to binary executable
|
|
320
|
-
*/
|
|
43
|
+
/** Get full path to binary executable */
|
|
321
44
|
getBinaryPath() {
|
|
322
|
-
|
|
323
|
-
return path.join(this.config.binPath, execName);
|
|
45
|
+
return (0, binary_1.getBinaryPath)(this.config.binPath);
|
|
324
46
|
}
|
|
325
|
-
/**
|
|
326
|
-
* Check if binary exists
|
|
327
|
-
*/
|
|
47
|
+
/** Check if binary exists */
|
|
328
48
|
isBinaryInstalled() {
|
|
329
|
-
return
|
|
49
|
+
return (0, binary_1.isBinaryInstalled)(this.config.binPath);
|
|
330
50
|
}
|
|
331
|
-
/**
|
|
332
|
-
* Get binary info if installed
|
|
333
|
-
*/
|
|
51
|
+
/** Get binary info if installed */
|
|
334
52
|
async getBinaryInfo() {
|
|
335
|
-
|
|
336
|
-
if (!fs.existsSync(binaryPath)) {
|
|
337
|
-
return null;
|
|
338
|
-
}
|
|
339
|
-
const platform = (0, platform_detector_1.detectPlatform)();
|
|
340
|
-
const checksum = await this.computeChecksum(binaryPath);
|
|
341
|
-
return {
|
|
342
|
-
path: binaryPath,
|
|
343
|
-
version: this.config.version,
|
|
344
|
-
platform,
|
|
345
|
-
checksum,
|
|
346
|
-
};
|
|
347
|
-
}
|
|
348
|
-
/**
|
|
349
|
-
* Download and install binary
|
|
350
|
-
*/
|
|
351
|
-
async downloadAndInstall() {
|
|
352
|
-
const platform = (0, platform_detector_1.detectPlatform)(this.config.version);
|
|
353
|
-
const downloadUrl = (0, platform_detector_1.getDownloadUrl)(this.config.version);
|
|
354
|
-
const checksumsUrl = (0, platform_detector_1.getChecksumsUrl)(this.config.version);
|
|
355
|
-
// Ensure bin directory exists
|
|
356
|
-
fs.mkdirSync(this.config.binPath, { recursive: true });
|
|
357
|
-
// Download archive
|
|
358
|
-
const archivePath = path.join(this.config.binPath, `cliproxy-archive.${platform.extension}`);
|
|
359
|
-
// Use single spinner and update text as we progress (avoids UI jumping)
|
|
360
|
-
const spinner = new progress_indicator_1.ProgressIndicator(`Downloading CLIProxyAPI v${this.config.version}`);
|
|
361
|
-
spinner.start();
|
|
362
|
-
try {
|
|
363
|
-
// Download with retry
|
|
364
|
-
const result = await this.downloadWithRetry(downloadUrl, archivePath);
|
|
365
|
-
if (!result.success) {
|
|
366
|
-
spinner.fail('Download failed');
|
|
367
|
-
throw new Error(result.error || 'Download failed after retries');
|
|
368
|
-
}
|
|
369
|
-
// Verify checksum (update spinner text instead of creating new one)
|
|
370
|
-
spinner.update('Verifying checksum');
|
|
371
|
-
const checksumResult = await this.verifyChecksum(archivePath, platform.binaryName, checksumsUrl);
|
|
372
|
-
if (!checksumResult.valid) {
|
|
373
|
-
spinner.fail('Checksum mismatch');
|
|
374
|
-
fs.unlinkSync(archivePath);
|
|
375
|
-
throw new Error(`Checksum mismatch for ${platform.binaryName}\n` +
|
|
376
|
-
`Expected: ${checksumResult.expected}\n` +
|
|
377
|
-
`Actual: ${checksumResult.actual}\n\n` +
|
|
378
|
-
`Manual download: ${downloadUrl}`);
|
|
379
|
-
}
|
|
380
|
-
// Extract archive (update spinner text)
|
|
381
|
-
spinner.update('Extracting binary');
|
|
382
|
-
await this.extractArchive(archivePath, platform.extension);
|
|
383
|
-
spinner.succeed('CLIProxyAPI ready');
|
|
384
|
-
// Cleanup archive
|
|
385
|
-
fs.unlinkSync(archivePath);
|
|
386
|
-
// Make executable (Unix only)
|
|
387
|
-
const binaryPath = this.getBinaryPath();
|
|
388
|
-
if (platform.os !== 'windows' && fs.existsSync(binaryPath)) {
|
|
389
|
-
fs.chmodSync(binaryPath, 0o755);
|
|
390
|
-
this.log(`Set executable permissions: ${binaryPath}`);
|
|
391
|
-
}
|
|
392
|
-
// Save installed version for future update checks
|
|
393
|
-
this.saveInstalledVersion(this.config.version);
|
|
394
|
-
console.log((0, ui_1.ok)(`CLIProxyAPI v${this.config.version} installed successfully`));
|
|
395
|
-
}
|
|
396
|
-
catch (error) {
|
|
397
|
-
spinner.fail('Installation failed');
|
|
398
|
-
throw error;
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
/**
|
|
402
|
-
* Download file with retry logic and exponential backoff
|
|
403
|
-
*/
|
|
404
|
-
async downloadWithRetry(url, destPath) {
|
|
405
|
-
let lastError = '';
|
|
406
|
-
let retries = 0;
|
|
407
|
-
while (retries < this.config.maxRetries) {
|
|
408
|
-
try {
|
|
409
|
-
await this.downloadFile(url, destPath);
|
|
410
|
-
return { success: true, filePath: destPath, retries };
|
|
411
|
-
}
|
|
412
|
-
catch (error) {
|
|
413
|
-
const err = error;
|
|
414
|
-
lastError = err.message;
|
|
415
|
-
retries++;
|
|
416
|
-
if (retries < this.config.maxRetries) {
|
|
417
|
-
// Exponential backoff: 1s, 2s, 4s
|
|
418
|
-
const delay = Math.pow(2, retries - 1) * 1000;
|
|
419
|
-
this.log(`Retry ${retries}/${this.config.maxRetries} after ${delay}ms: ${lastError}`);
|
|
420
|
-
await this.sleep(delay);
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
return {
|
|
425
|
-
success: false,
|
|
426
|
-
error: `Download failed after ${retries} attempts: ${lastError}`,
|
|
427
|
-
retries,
|
|
428
|
-
};
|
|
429
|
-
}
|
|
430
|
-
/**
|
|
431
|
-
* Download file from URL with progress tracking
|
|
432
|
-
*/
|
|
433
|
-
downloadFile(url, destPath, onProgress) {
|
|
434
|
-
return new Promise((resolve, reject) => {
|
|
435
|
-
const handleResponse = (res) => {
|
|
436
|
-
// Handle redirects (GitHub releases use 302)
|
|
437
|
-
if (res.statusCode === 301 || res.statusCode === 302) {
|
|
438
|
-
const redirectUrl = res.headers.location;
|
|
439
|
-
if (!redirectUrl) {
|
|
440
|
-
reject(new Error('Redirect without location header'));
|
|
441
|
-
return;
|
|
442
|
-
}
|
|
443
|
-
this.log(`Following redirect: ${redirectUrl}`);
|
|
444
|
-
this.downloadFile(redirectUrl, destPath, onProgress).then(resolve).catch(reject);
|
|
445
|
-
return;
|
|
446
|
-
}
|
|
447
|
-
if (res.statusCode !== 200) {
|
|
448
|
-
reject(new Error(`HTTP ${res.statusCode}: ${res.statusMessage}`));
|
|
449
|
-
return;
|
|
450
|
-
}
|
|
451
|
-
const totalBytes = parseInt(res.headers['content-length'] || '0', 10);
|
|
452
|
-
let downloadedBytes = 0;
|
|
453
|
-
const fileStream = fs.createWriteStream(destPath);
|
|
454
|
-
res.on('data', (chunk) => {
|
|
455
|
-
downloadedBytes += chunk.length;
|
|
456
|
-
if (onProgress && totalBytes > 0) {
|
|
457
|
-
onProgress({
|
|
458
|
-
total: totalBytes,
|
|
459
|
-
downloaded: downloadedBytes,
|
|
460
|
-
percentage: Math.round((downloadedBytes / totalBytes) * 100),
|
|
461
|
-
});
|
|
462
|
-
}
|
|
463
|
-
});
|
|
464
|
-
res.pipe(fileStream);
|
|
465
|
-
fileStream.on('finish', () => {
|
|
466
|
-
fileStream.close();
|
|
467
|
-
resolve();
|
|
468
|
-
});
|
|
469
|
-
fileStream.on('error', (err) => {
|
|
470
|
-
fs.unlink(destPath, () => { }); // Cleanup partial file
|
|
471
|
-
reject(err);
|
|
472
|
-
});
|
|
473
|
-
res.on('error', (err) => {
|
|
474
|
-
fs.unlink(destPath, () => { });
|
|
475
|
-
reject(err);
|
|
476
|
-
});
|
|
477
|
-
};
|
|
478
|
-
const protocol = url.startsWith('https') ? https : http;
|
|
479
|
-
const req = protocol.get(url, handleResponse);
|
|
480
|
-
req.on('error', reject);
|
|
481
|
-
req.setTimeout(60000, () => {
|
|
482
|
-
req.destroy();
|
|
483
|
-
reject(new Error('Download timeout (60s)'));
|
|
484
|
-
});
|
|
485
|
-
});
|
|
486
|
-
}
|
|
487
|
-
/**
|
|
488
|
-
* Verify file checksum against checksums.txt
|
|
489
|
-
*/
|
|
490
|
-
async verifyChecksum(filePath, binaryName, checksumsUrl) {
|
|
491
|
-
// Download checksums.txt
|
|
492
|
-
const checksumsContent = await this.fetchText(checksumsUrl);
|
|
493
|
-
// Parse expected checksum
|
|
494
|
-
const expectedHash = this.parseChecksum(checksumsContent, binaryName);
|
|
495
|
-
if (!expectedHash) {
|
|
496
|
-
throw new Error(`Checksum not found for ${binaryName} in checksums.txt`);
|
|
497
|
-
}
|
|
498
|
-
// Compute actual checksum
|
|
499
|
-
const actualHash = await this.computeChecksum(filePath);
|
|
500
|
-
return {
|
|
501
|
-
valid: actualHash === expectedHash,
|
|
502
|
-
expected: expectedHash,
|
|
503
|
-
actual: actualHash,
|
|
504
|
-
};
|
|
53
|
+
return (0, binary_1.getBinaryInfo)(this.config.binPath, this.config.version);
|
|
505
54
|
}
|
|
506
|
-
/**
|
|
507
|
-
* Parse checksum from checksums.txt content
|
|
508
|
-
*/
|
|
509
|
-
parseChecksum(content, binaryName) {
|
|
510
|
-
const lines = content.split('\n');
|
|
511
|
-
for (const line of lines) {
|
|
512
|
-
// Format: "hash filename" or "hash filename"
|
|
513
|
-
const parts = line.trim().split(/\s+/);
|
|
514
|
-
if (parts.length >= 2 && parts[1] === binaryName) {
|
|
515
|
-
return parts[0].toLowerCase();
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
return null;
|
|
519
|
-
}
|
|
520
|
-
/**
|
|
521
|
-
* Compute SHA256 checksum of file
|
|
522
|
-
*/
|
|
523
|
-
computeChecksum(filePath) {
|
|
524
|
-
return new Promise((resolve, reject) => {
|
|
525
|
-
const hash = crypto.createHash('sha256');
|
|
526
|
-
const stream = fs.createReadStream(filePath);
|
|
527
|
-
stream.on('data', (data) => hash.update(data));
|
|
528
|
-
stream.on('end', () => resolve(hash.digest('hex')));
|
|
529
|
-
stream.on('error', reject);
|
|
530
|
-
});
|
|
531
|
-
}
|
|
532
|
-
/**
|
|
533
|
-
* Fetch text content from URL
|
|
534
|
-
*/
|
|
535
|
-
fetchText(url) {
|
|
536
|
-
return new Promise((resolve, reject) => {
|
|
537
|
-
const handleResponse = (res) => {
|
|
538
|
-
// Handle redirects
|
|
539
|
-
if (res.statusCode === 301 || res.statusCode === 302) {
|
|
540
|
-
const redirectUrl = res.headers.location;
|
|
541
|
-
if (!redirectUrl) {
|
|
542
|
-
reject(new Error('Redirect without location header'));
|
|
543
|
-
return;
|
|
544
|
-
}
|
|
545
|
-
this.fetchText(redirectUrl).then(resolve).catch(reject);
|
|
546
|
-
return;
|
|
547
|
-
}
|
|
548
|
-
if (res.statusCode !== 200) {
|
|
549
|
-
reject(new Error(`HTTP ${res.statusCode}: ${res.statusMessage}`));
|
|
550
|
-
return;
|
|
551
|
-
}
|
|
552
|
-
let data = '';
|
|
553
|
-
res.on('data', (chunk) => (data += chunk));
|
|
554
|
-
res.on('end', () => resolve(data));
|
|
555
|
-
res.on('error', reject);
|
|
556
|
-
};
|
|
557
|
-
const protocol = url.startsWith('https') ? https : http;
|
|
558
|
-
const req = protocol.get(url, handleResponse);
|
|
559
|
-
req.on('error', reject);
|
|
560
|
-
req.setTimeout(30000, () => {
|
|
561
|
-
req.destroy();
|
|
562
|
-
reject(new Error('Request timeout (30s)'));
|
|
563
|
-
});
|
|
564
|
-
});
|
|
565
|
-
}
|
|
566
|
-
/**
|
|
567
|
-
* Extract archive (tar.gz or zip)
|
|
568
|
-
*/
|
|
569
|
-
async extractArchive(archivePath, extension) {
|
|
570
|
-
if (extension === 'tar.gz') {
|
|
571
|
-
await this.extractTarGz(archivePath);
|
|
572
|
-
}
|
|
573
|
-
else {
|
|
574
|
-
await this.extractZip(archivePath);
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
/**
|
|
578
|
-
* Extract tar.gz archive using Node.js built-in modules
|
|
579
|
-
*/
|
|
580
|
-
extractTarGz(archivePath) {
|
|
581
|
-
return new Promise((resolve, reject) => {
|
|
582
|
-
const destDir = this.config.binPath;
|
|
583
|
-
const execName = (0, platform_detector_1.getExecutableName)();
|
|
584
|
-
const archiveBinaryName = (0, platform_detector_1.getArchiveBinaryName)();
|
|
585
|
-
// Read and decompress
|
|
586
|
-
const gunzip = zlib.createGunzip();
|
|
587
|
-
const input = fs.createReadStream(archivePath);
|
|
588
|
-
let headerBuffer = Buffer.alloc(0);
|
|
589
|
-
let currentFile = null;
|
|
590
|
-
let bytesRead = 0;
|
|
591
|
-
let fileBuffer = Buffer.alloc(0);
|
|
592
|
-
const processData = (data) => {
|
|
593
|
-
headerBuffer = Buffer.concat([headerBuffer, data]);
|
|
594
|
-
while (headerBuffer.length >= 512) {
|
|
595
|
-
if (!currentFile) {
|
|
596
|
-
// Parse tar header
|
|
597
|
-
const header = headerBuffer.subarray(0, 512);
|
|
598
|
-
headerBuffer = headerBuffer.subarray(512);
|
|
599
|
-
// Check for empty header (end of archive)
|
|
600
|
-
if (header.every((b) => b === 0)) {
|
|
601
|
-
return;
|
|
602
|
-
}
|
|
603
|
-
// Extract filename (bytes 0-99)
|
|
604
|
-
let name = '';
|
|
605
|
-
for (let i = 0; i < 100 && header[i] !== 0; i++) {
|
|
606
|
-
name += String.fromCharCode(header[i]);
|
|
607
|
-
}
|
|
608
|
-
// Extract size (bytes 124-135, octal)
|
|
609
|
-
let sizeStr = '';
|
|
610
|
-
for (let i = 124; i < 136 && header[i] !== 0; i++) {
|
|
611
|
-
sizeStr += String.fromCharCode(header[i]);
|
|
612
|
-
}
|
|
613
|
-
const size = parseInt(sizeStr.trim(), 8) || 0;
|
|
614
|
-
if (name && size > 0) {
|
|
615
|
-
// Extract just the filename (handle directories)
|
|
616
|
-
const baseName = path.basename(name);
|
|
617
|
-
if (baseName === execName ||
|
|
618
|
-
baseName === archiveBinaryName ||
|
|
619
|
-
baseName === 'cli-proxy-api') {
|
|
620
|
-
currentFile = { name: baseName, size };
|
|
621
|
-
fileBuffer = Buffer.alloc(0);
|
|
622
|
-
bytesRead = 0;
|
|
623
|
-
}
|
|
624
|
-
else {
|
|
625
|
-
// Skip this file's data
|
|
626
|
-
const paddedSize = Math.ceil(size / 512) * 512;
|
|
627
|
-
if (headerBuffer.length >= paddedSize) {
|
|
628
|
-
headerBuffer = headerBuffer.subarray(paddedSize);
|
|
629
|
-
}
|
|
630
|
-
else {
|
|
631
|
-
// Need to skip data in chunks
|
|
632
|
-
currentFile = { name: '', size: paddedSize };
|
|
633
|
-
bytesRead = 0;
|
|
634
|
-
}
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
}
|
|
638
|
-
else {
|
|
639
|
-
// Read file data
|
|
640
|
-
const remaining = currentFile.size - bytesRead;
|
|
641
|
-
const chunk = headerBuffer.subarray(0, Math.min(remaining, headerBuffer.length));
|
|
642
|
-
headerBuffer = headerBuffer.subarray(chunk.length);
|
|
643
|
-
if (currentFile.name) {
|
|
644
|
-
fileBuffer = Buffer.concat([fileBuffer, chunk]);
|
|
645
|
-
}
|
|
646
|
-
bytesRead += chunk.length;
|
|
647
|
-
if (bytesRead >= currentFile.size) {
|
|
648
|
-
// File complete
|
|
649
|
-
if (currentFile.name) {
|
|
650
|
-
const destPath = path.join(destDir, execName);
|
|
651
|
-
fs.writeFileSync(destPath, fileBuffer);
|
|
652
|
-
this.log(`Extracted: ${currentFile.name} -> ${destPath}`);
|
|
653
|
-
}
|
|
654
|
-
// Skip padding to 512-byte boundary
|
|
655
|
-
const paddedSize = Math.ceil(currentFile.size / 512) * 512;
|
|
656
|
-
const padding = paddedSize - currentFile.size;
|
|
657
|
-
if (headerBuffer.length >= padding) {
|
|
658
|
-
headerBuffer = headerBuffer.subarray(padding);
|
|
659
|
-
}
|
|
660
|
-
currentFile = null;
|
|
661
|
-
fileBuffer = Buffer.alloc(0);
|
|
662
|
-
}
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
};
|
|
666
|
-
input.pipe(gunzip);
|
|
667
|
-
gunzip.on('data', processData);
|
|
668
|
-
gunzip.on('end', resolve);
|
|
669
|
-
gunzip.on('error', reject);
|
|
670
|
-
input.on('error', reject);
|
|
671
|
-
});
|
|
672
|
-
}
|
|
673
|
-
/**
|
|
674
|
-
* Extract zip archive using Node.js (simple implementation)
|
|
675
|
-
*/
|
|
676
|
-
extractZip(archivePath) {
|
|
677
|
-
return new Promise((resolve, reject) => {
|
|
678
|
-
const destDir = this.config.binPath;
|
|
679
|
-
const execName = (0, platform_detector_1.getExecutableName)();
|
|
680
|
-
const archiveBinaryName = (0, platform_detector_1.getArchiveBinaryName)();
|
|
681
|
-
const buffer = fs.readFileSync(archivePath);
|
|
682
|
-
// Find End of Central Directory record (EOCD)
|
|
683
|
-
let eocdOffset = buffer.length - 22;
|
|
684
|
-
while (eocdOffset >= 0) {
|
|
685
|
-
if (buffer.readUInt32LE(eocdOffset) === 0x06054b50) {
|
|
686
|
-
break;
|
|
687
|
-
}
|
|
688
|
-
eocdOffset--;
|
|
689
|
-
}
|
|
690
|
-
if (eocdOffset < 0) {
|
|
691
|
-
reject(new Error('Invalid ZIP file: EOCD not found'));
|
|
692
|
-
return;
|
|
693
|
-
}
|
|
694
|
-
const centralDirOffset = buffer.readUInt32LE(eocdOffset + 16);
|
|
695
|
-
let offset = centralDirOffset;
|
|
696
|
-
// Parse central directory
|
|
697
|
-
while (offset < eocdOffset) {
|
|
698
|
-
const sig = buffer.readUInt32LE(offset);
|
|
699
|
-
if (sig !== 0x02014b50)
|
|
700
|
-
break;
|
|
701
|
-
const compressionMethod = buffer.readUInt16LE(offset + 10);
|
|
702
|
-
const compressedSize = buffer.readUInt32LE(offset + 20);
|
|
703
|
-
const uncompressedSize = buffer.readUInt32LE(offset + 24);
|
|
704
|
-
const fileNameLength = buffer.readUInt16LE(offset + 28);
|
|
705
|
-
const extraFieldLength = buffer.readUInt16LE(offset + 30);
|
|
706
|
-
const commentLength = buffer.readUInt16LE(offset + 32);
|
|
707
|
-
const localHeaderOffset = buffer.readUInt32LE(offset + 42);
|
|
708
|
-
const fileName = buffer.toString('utf8', offset + 46, offset + 46 + fileNameLength);
|
|
709
|
-
const baseName = path.basename(fileName);
|
|
710
|
-
// Check if this is the executable we want
|
|
711
|
-
if (baseName === execName ||
|
|
712
|
-
baseName === archiveBinaryName ||
|
|
713
|
-
baseName === 'cli-proxy-api.exe') {
|
|
714
|
-
// Read from local file header
|
|
715
|
-
const localOffset = localHeaderOffset;
|
|
716
|
-
const localSig = buffer.readUInt32LE(localOffset);
|
|
717
|
-
if (localSig !== 0x04034b50) {
|
|
718
|
-
reject(new Error('Invalid local file header'));
|
|
719
|
-
return;
|
|
720
|
-
}
|
|
721
|
-
const localFileNameLength = buffer.readUInt16LE(localOffset + 26);
|
|
722
|
-
const localExtraLength = buffer.readUInt16LE(localOffset + 28);
|
|
723
|
-
const dataOffset = localOffset + 30 + localFileNameLength + localExtraLength;
|
|
724
|
-
let fileData;
|
|
725
|
-
if (compressionMethod === 0) {
|
|
726
|
-
// Stored (no compression)
|
|
727
|
-
fileData = buffer.subarray(dataOffset, dataOffset + compressedSize);
|
|
728
|
-
}
|
|
729
|
-
else if (compressionMethod === 8) {
|
|
730
|
-
// Deflate
|
|
731
|
-
const compressed = buffer.subarray(dataOffset, dataOffset + compressedSize);
|
|
732
|
-
fileData = zlib.inflateRawSync(compressed);
|
|
733
|
-
}
|
|
734
|
-
else {
|
|
735
|
-
reject(new Error(`Unsupported compression method: ${compressionMethod}`));
|
|
736
|
-
return;
|
|
737
|
-
}
|
|
738
|
-
if (fileData.length !== uncompressedSize) {
|
|
739
|
-
reject(new Error('Decompression size mismatch'));
|
|
740
|
-
return;
|
|
741
|
-
}
|
|
742
|
-
const destPath = path.join(destDir, execName);
|
|
743
|
-
fs.writeFileSync(destPath, fileData);
|
|
744
|
-
this.log(`Extracted: ${fileName} -> ${destPath}`);
|
|
745
|
-
resolve();
|
|
746
|
-
return;
|
|
747
|
-
}
|
|
748
|
-
offset += 46 + fileNameLength + extraFieldLength + commentLength;
|
|
749
|
-
}
|
|
750
|
-
reject(new Error(`Executable not found in archive: ${execName}`));
|
|
751
|
-
});
|
|
752
|
-
}
|
|
753
|
-
/**
|
|
754
|
-
* Delete binary (for cleanup or reinstall)
|
|
755
|
-
*/
|
|
55
|
+
/** Delete binary (for cleanup or reinstall) */
|
|
756
56
|
deleteBinary() {
|
|
757
|
-
|
|
758
|
-
if (fs.existsSync(binaryPath)) {
|
|
759
|
-
fs.unlinkSync(binaryPath);
|
|
760
|
-
this.log(`Deleted: ${binaryPath}`);
|
|
761
|
-
}
|
|
762
|
-
}
|
|
763
|
-
/**
|
|
764
|
-
* Sleep helper
|
|
765
|
-
*/
|
|
766
|
-
sleep(ms) {
|
|
767
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
768
|
-
}
|
|
769
|
-
/**
|
|
770
|
-
* Log message if verbose
|
|
771
|
-
*/
|
|
772
|
-
log(message) {
|
|
773
|
-
if (this.verbose) {
|
|
774
|
-
console.error(`[cliproxy] ${message}`);
|
|
775
|
-
}
|
|
57
|
+
(0, binary_1.deleteBinary)(this.config.binPath, this.config.verbose);
|
|
776
58
|
}
|
|
777
59
|
}
|
|
778
60
|
exports.BinaryManager = BinaryManager;
|
|
779
|
-
/**
|
|
780
|
-
* Convenience function to ensure binary is available
|
|
781
|
-
* Respects version pin if set by user via 'ccs cliproxy --install <version>'
|
|
782
|
-
* @returns Path to CLIProxyAPI executable
|
|
783
|
-
*/
|
|
61
|
+
/** Convenience function respecting version pin */
|
|
784
62
|
async function ensureCLIProxyBinary(verbose = false) {
|
|
785
|
-
const pinnedVersion = getPinnedVersion();
|
|
63
|
+
const pinnedVersion = (0, binary_1.getPinnedVersion)();
|
|
786
64
|
if (pinnedVersion) {
|
|
787
|
-
|
|
788
|
-
if (verbose) {
|
|
65
|
+
if (verbose)
|
|
789
66
|
console.error(`[cliproxy] Using pinned version: ${pinnedVersion}`);
|
|
790
|
-
|
|
791
|
-
const manager = new BinaryManager({
|
|
67
|
+
return new BinaryManager({
|
|
792
68
|
version: pinnedVersion,
|
|
793
69
|
verbose,
|
|
794
70
|
forceVersion: true,
|
|
795
|
-
});
|
|
796
|
-
return manager.ensureBinary();
|
|
71
|
+
}).ensureBinary();
|
|
797
72
|
}
|
|
798
|
-
|
|
799
|
-
const manager = new BinaryManager({ verbose });
|
|
800
|
-
return manager.ensureBinary();
|
|
73
|
+
return new BinaryManager({ verbose }).ensureBinary();
|
|
801
74
|
}
|
|
802
75
|
exports.ensureCLIProxyBinary = ensureCLIProxyBinary;
|
|
803
|
-
/**
|
|
804
|
-
* Check if CLIProxyAPI binary is installed
|
|
805
|
-
*/
|
|
76
|
+
/** Check if CLIProxyAPI binary is installed */
|
|
806
77
|
function isCLIProxyInstalled() {
|
|
807
|
-
|
|
808
|
-
return manager.isBinaryInstalled();
|
|
78
|
+
return new BinaryManager().isBinaryInstalled();
|
|
809
79
|
}
|
|
810
80
|
exports.isCLIProxyInstalled = isCLIProxyInstalled;
|
|
811
|
-
/**
|
|
812
|
-
* Get CLIProxyAPI binary path (may not exist)
|
|
813
|
-
*/
|
|
81
|
+
/** Get CLIProxyAPI binary path (may not exist) */
|
|
814
82
|
function getCLIProxyPath() {
|
|
815
|
-
|
|
816
|
-
return manager.getBinaryPath();
|
|
83
|
+
return new BinaryManager().getBinaryPath();
|
|
817
84
|
}
|
|
818
85
|
exports.getCLIProxyPath = getCLIProxyPath;
|
|
819
|
-
/**
|
|
820
|
-
* Get installed CLIProxyAPI version from .version file
|
|
821
|
-
* Returns the fallback version if not installed or version file missing
|
|
822
|
-
*/
|
|
86
|
+
/** Get installed CLIProxyAPI version from .version file */
|
|
823
87
|
function getInstalledCliproxyVersion() {
|
|
824
|
-
|
|
825
|
-
if (fs.existsSync(versionFile)) {
|
|
826
|
-
try {
|
|
827
|
-
return fs.readFileSync(versionFile, 'utf8').trim();
|
|
828
|
-
}
|
|
829
|
-
catch {
|
|
830
|
-
return platform_detector_1.CLIPROXY_FALLBACK_VERSION;
|
|
831
|
-
}
|
|
832
|
-
}
|
|
833
|
-
return platform_detector_1.CLIPROXY_FALLBACK_VERSION;
|
|
88
|
+
return (0, binary_1.readInstalledVersion)((0, config_generator_1.getBinDir)(), platform_detector_1.CLIPROXY_FALLBACK_VERSION);
|
|
834
89
|
}
|
|
835
90
|
exports.getInstalledCliproxyVersion = getInstalledCliproxyVersion;
|
|
836
|
-
/**
|
|
837
|
-
* Install a specific version of CLIProxyAPI
|
|
838
|
-
* Deletes existing binary and downloads the specified version
|
|
839
|
-
*
|
|
840
|
-
* @param version Version to install (e.g., "6.5.53")
|
|
841
|
-
* @param verbose Enable verbose logging
|
|
842
|
-
*/
|
|
91
|
+
/** Install a specific version of CLIProxyAPI */
|
|
843
92
|
async function installCliproxyVersion(version, verbose = false) {
|
|
844
|
-
// Use forceVersion to prevent auto-upgrade to latest
|
|
845
93
|
const manager = new BinaryManager({ version, verbose, forceVersion: true });
|
|
846
|
-
// Delete existing binary if present
|
|
847
94
|
if (manager.isBinaryInstalled()) {
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
console.log((0, ui_1.info)(`Removing existing CLIProxyAPI v${currentVersion}`));
|
|
851
|
-
}
|
|
95
|
+
if (verbose)
|
|
96
|
+
console.log((0, ui_1.info)(`Removing existing CLIProxyAPI v${getInstalledCliproxyVersion()}`));
|
|
852
97
|
manager.deleteBinary();
|
|
853
98
|
}
|
|
854
|
-
// Install specified version (forceVersion prevents auto-upgrade)
|
|
855
99
|
await manager.ensureBinary();
|
|
856
100
|
}
|
|
857
101
|
exports.installCliproxyVersion = installCliproxyVersion;
|
|
858
|
-
/**
|
|
859
|
-
* Fetch the latest CLIProxyAPI version from GitHub API
|
|
860
|
-
* @returns Latest version string (e.g., "6.5.53")
|
|
861
|
-
*/
|
|
102
|
+
/** Fetch the latest CLIProxyAPI version from GitHub API */
|
|
862
103
|
async function fetchLatestCliproxyVersion() {
|
|
863
|
-
const
|
|
864
|
-
const result = await manager.checkForUpdates();
|
|
104
|
+
const result = await new BinaryManager().checkForUpdates();
|
|
865
105
|
return result.latestVersion;
|
|
866
106
|
}
|
|
867
107
|
exports.fetchLatestCliproxyVersion = fetchLatestCliproxyVersion;
|
|
868
|
-
/**
|
|
869
|
-
* Check for CLIProxyAPI binary updates
|
|
870
|
-
* @returns Update check result with version info
|
|
871
|
-
*/
|
|
108
|
+
/** Check for CLIProxyAPI binary updates */
|
|
872
109
|
async function checkCliproxyUpdate() {
|
|
873
|
-
|
|
874
|
-
return manager.checkForUpdates();
|
|
110
|
+
return new BinaryManager().checkForUpdates();
|
|
875
111
|
}
|
|
876
112
|
exports.checkCliproxyUpdate = checkCliproxyUpdate;
|
|
877
|
-
/**
|
|
878
|
-
* Get path to version pin file
|
|
879
|
-
* @returns Absolute path to .version-pin file
|
|
880
|
-
*/
|
|
881
|
-
function getVersionPinPath() {
|
|
882
|
-
return path.join((0, config_generator_1.getBinDir)(), VERSION_PIN_FILE);
|
|
883
|
-
}
|
|
884
|
-
exports.getVersionPinPath = getVersionPinPath;
|
|
885
|
-
/**
|
|
886
|
-
* Get pinned version if one exists
|
|
887
|
-
* @returns Pinned version string, or null if not pinned
|
|
888
|
-
*/
|
|
889
|
-
function getPinnedVersion() {
|
|
890
|
-
const pinPath = getVersionPinPath();
|
|
891
|
-
if (!fs.existsSync(pinPath)) {
|
|
892
|
-
return null;
|
|
893
|
-
}
|
|
894
|
-
try {
|
|
895
|
-
return fs.readFileSync(pinPath, 'utf8').trim();
|
|
896
|
-
}
|
|
897
|
-
catch {
|
|
898
|
-
return null;
|
|
899
|
-
}
|
|
900
|
-
}
|
|
901
|
-
exports.getPinnedVersion = getPinnedVersion;
|
|
902
|
-
/**
|
|
903
|
-
* Save pinned version to persist user's explicit choice
|
|
904
|
-
* @param version Version to pin (e.g., "6.5.50")
|
|
905
|
-
*/
|
|
906
|
-
function savePinnedVersion(version) {
|
|
907
|
-
const pinPath = getVersionPinPath();
|
|
908
|
-
try {
|
|
909
|
-
fs.mkdirSync(path.dirname(pinPath), { recursive: true });
|
|
910
|
-
fs.writeFileSync(pinPath, version, 'utf8');
|
|
911
|
-
}
|
|
912
|
-
catch {
|
|
913
|
-
// Silent fail - not critical but log if verbose
|
|
914
|
-
}
|
|
915
|
-
}
|
|
916
|
-
exports.savePinnedVersion = savePinnedVersion;
|
|
917
|
-
/**
|
|
918
|
-
* Clear pinned version (unpin)
|
|
919
|
-
*/
|
|
920
|
-
function clearPinnedVersion() {
|
|
921
|
-
const pinPath = getVersionPinPath();
|
|
922
|
-
if (fs.existsSync(pinPath)) {
|
|
923
|
-
try {
|
|
924
|
-
fs.unlinkSync(pinPath);
|
|
925
|
-
}
|
|
926
|
-
catch {
|
|
927
|
-
// Silent fail
|
|
928
|
-
}
|
|
929
|
-
}
|
|
930
|
-
}
|
|
931
|
-
exports.clearPinnedVersion = clearPinnedVersion;
|
|
932
|
-
/**
|
|
933
|
-
* Check if a version is currently pinned
|
|
934
|
-
* @returns true if a version is pinned
|
|
935
|
-
*/
|
|
936
|
-
function isVersionPinned() {
|
|
937
|
-
return getPinnedVersion() !== null;
|
|
938
|
-
}
|
|
939
|
-
exports.isVersionPinned = isVersionPinned;
|
|
940
113
|
exports.default = BinaryManager;
|
|
941
114
|
//# sourceMappingURL=binary-manager.js.map
|