ccjk 12.0.7 → 12.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (299) hide show
  1. package/package.json +1 -1
  2. package/dist/chunks/agent-teams.mjs +0 -136
  3. package/dist/chunks/agent.mjs +0 -1439
  4. package/dist/chunks/agents.mjs +0 -3778
  5. package/dist/chunks/api-cli.mjs +0 -132
  6. package/dist/chunks/api-providers.mjs +0 -129
  7. package/dist/chunks/api.mjs +0 -112
  8. package/dist/chunks/auto-bootstrap.mjs +0 -358
  9. package/dist/chunks/auto-init.mjs +0 -7584
  10. package/dist/chunks/auto-updater.mjs +0 -410
  11. package/dist/chunks/banner.mjs +0 -188
  12. package/dist/chunks/bash.mjs +0 -187
  13. package/dist/chunks/boost.mjs +0 -397
  14. package/dist/chunks/ccjk-agents.mjs +0 -414
  15. package/dist/chunks/ccjk-all.mjs +0 -1028
  16. package/dist/chunks/ccjk-config.mjs +0 -261
  17. package/dist/chunks/ccjk-hooks.mjs +0 -1074
  18. package/dist/chunks/ccjk-mcp.mjs +0 -761
  19. package/dist/chunks/ccjk-setup.mjs +0 -763
  20. package/dist/chunks/ccjk-skills.mjs +0 -514
  21. package/dist/chunks/ccr.mjs +0 -98
  22. package/dist/chunks/ccu.mjs +0 -40
  23. package/dist/chunks/check-updates.mjs +0 -108
  24. package/dist/chunks/claude-code-config-manager.mjs +0 -750
  25. package/dist/chunks/claude-code-incremental-manager.mjs +0 -623
  26. package/dist/chunks/claude-config.mjs +0 -236
  27. package/dist/chunks/claude-wrapper.mjs +0 -85
  28. package/dist/chunks/cleanup-migration.mjs +0 -20
  29. package/dist/chunks/cli-hook.mjs +0 -2285
  30. package/dist/chunks/cloud-sync.mjs +0 -29
  31. package/dist/chunks/codex-config-switch.mjs +0 -451
  32. package/dist/chunks/codex-provider-manager.mjs +0 -236
  33. package/dist/chunks/codex-uninstaller.mjs +0 -404
  34. package/dist/chunks/codex.mjs +0 -2077
  35. package/dist/chunks/commands.mjs +0 -108
  36. package/dist/chunks/commands2.mjs +0 -413
  37. package/dist/chunks/commit.mjs +0 -138
  38. package/dist/chunks/completion.mjs +0 -515
  39. package/dist/chunks/config-consolidator.mjs +0 -172
  40. package/dist/chunks/config-switch.mjs +0 -317
  41. package/dist/chunks/config.mjs +0 -379
  42. package/dist/chunks/config2.mjs +0 -477
  43. package/dist/chunks/config3.mjs +0 -470
  44. package/dist/chunks/constants.mjs +0 -133
  45. package/dist/chunks/context-loader.mjs +0 -343
  46. package/dist/chunks/context.mjs +0 -372
  47. package/dist/chunks/convoy-manager.mjs +0 -880
  48. package/dist/chunks/dashboard.mjs +0 -476
  49. package/dist/chunks/doctor.mjs +0 -964
  50. package/dist/chunks/evolution.mjs +0 -382
  51. package/dist/chunks/features.mjs +0 -698
  52. package/dist/chunks/fish.mjs +0 -181
  53. package/dist/chunks/fs-operations.mjs +0 -192
  54. package/dist/chunks/health-alerts.mjs +0 -304
  55. package/dist/chunks/health-check.mjs +0 -532
  56. package/dist/chunks/help.mjs +0 -340
  57. package/dist/chunks/hook-installer.mjs +0 -45
  58. package/dist/chunks/index.mjs +0 -24
  59. package/dist/chunks/index10.mjs +0 -1171
  60. package/dist/chunks/index11.mjs +0 -1008
  61. package/dist/chunks/index12.mjs +0 -193
  62. package/dist/chunks/index13.mjs +0 -218
  63. package/dist/chunks/index14.mjs +0 -663
  64. package/dist/chunks/index2.mjs +0 -19
  65. package/dist/chunks/index3.mjs +0 -19092
  66. package/dist/chunks/index4.mjs +0 -8
  67. package/dist/chunks/index5.mjs +0 -7600
  68. package/dist/chunks/index6.mjs +0 -171
  69. package/dist/chunks/index7.mjs +0 -3583
  70. package/dist/chunks/index8.mjs +0 -19
  71. package/dist/chunks/index9.mjs +0 -616
  72. package/dist/chunks/init.mjs +0 -1606
  73. package/dist/chunks/installer.mjs +0 -690
  74. package/dist/chunks/installer2.mjs +0 -179
  75. package/dist/chunks/interview.mjs +0 -2927
  76. package/dist/chunks/json-config.mjs +0 -60
  77. package/dist/chunks/linux.mjs +0 -3863
  78. package/dist/chunks/macos.mjs +0 -69
  79. package/dist/chunks/main.mjs +0 -635
  80. package/dist/chunks/manager.mjs +0 -1048
  81. package/dist/chunks/marketplace.mjs +0 -949
  82. package/dist/chunks/mcp-cli.mjs +0 -204
  83. package/dist/chunks/mcp-performance.mjs +0 -187
  84. package/dist/chunks/mcp.mjs +0 -1231
  85. package/dist/chunks/menu.mjs +0 -652
  86. package/dist/chunks/metrics-display.mjs +0 -153
  87. package/dist/chunks/migrator.mjs +0 -178
  88. package/dist/chunks/monitor.mjs +0 -1856
  89. package/dist/chunks/notification.mjs +0 -1864
  90. package/dist/chunks/onboarding.mjs +0 -385
  91. package/dist/chunks/package.mjs +0 -3
  92. package/dist/chunks/paradigm.mjs +0 -74
  93. package/dist/chunks/permission-manager.mjs +0 -132
  94. package/dist/chunks/permissions.mjs +0 -265
  95. package/dist/chunks/persistence-manager.mjs +0 -794
  96. package/dist/chunks/persistence.mjs +0 -667
  97. package/dist/chunks/platform.mjs +0 -391
  98. package/dist/chunks/plugin.mjs +0 -1936
  99. package/dist/chunks/powershell.mjs +0 -213
  100. package/dist/chunks/prompts.mjs +0 -241
  101. package/dist/chunks/providers.mjs +0 -260
  102. package/dist/chunks/quick-actions.mjs +0 -320
  103. package/dist/chunks/quick-provider.mjs +0 -682
  104. package/dist/chunks/quick-setup.mjs +0 -412
  105. package/dist/chunks/remote.mjs +0 -497
  106. package/dist/chunks/session.mjs +0 -878
  107. package/dist/chunks/sessions.mjs +0 -106
  108. package/dist/chunks/silent-updater.mjs +0 -396
  109. package/dist/chunks/simple-config.mjs +0 -98
  110. package/dist/chunks/skill.mjs +0 -117
  111. package/dist/chunks/skill2.mjs +0 -9003
  112. package/dist/chunks/skills-sync.mjs +0 -6460
  113. package/dist/chunks/skills.mjs +0 -567
  114. package/dist/chunks/slash-commands.mjs +0 -207
  115. package/dist/chunks/smart-defaults.mjs +0 -412
  116. package/dist/chunks/smart-guide.mjs +0 -194
  117. package/dist/chunks/startup.mjs +0 -487
  118. package/dist/chunks/stats.mjs +0 -410
  119. package/dist/chunks/status.mjs +0 -289
  120. package/dist/chunks/team.mjs +0 -63
  121. package/dist/chunks/thinking.mjs +0 -626
  122. package/dist/chunks/trace.mjs +0 -57
  123. package/dist/chunks/uninstall.mjs +0 -849
  124. package/dist/chunks/update.mjs +0 -167
  125. package/dist/chunks/upgrade-manager.mjs +0 -204
  126. package/dist/chunks/version-checker.mjs +0 -881
  127. package/dist/chunks/vim.mjs +0 -903
  128. package/dist/chunks/windows.mjs +0 -14
  129. package/dist/chunks/workflows.mjs +0 -633
  130. package/dist/chunks/wsl.mjs +0 -129
  131. package/dist/chunks/zero-config.mjs +0 -374
  132. package/dist/chunks/zsh.mjs +0 -182
  133. package/dist/cli.d.mts +0 -1
  134. package/dist/cli.d.ts +0 -1
  135. package/dist/cli.mjs +0 -2199
  136. package/dist/i18n/locales/en/agent-teams.json +0 -18
  137. package/dist/i18n/locales/en/agentBrowser.json +0 -79
  138. package/dist/i18n/locales/en/agents.json +0 -135
  139. package/dist/i18n/locales/en/api.json +0 -63
  140. package/dist/i18n/locales/en/ccjk-agents.json +0 -33
  141. package/dist/i18n/locales/en/ccjk-all.json +0 -23
  142. package/dist/i18n/locales/en/ccjk-skills.json +0 -22
  143. package/dist/i18n/locales/en/ccjk.json +0 -276
  144. package/dist/i18n/locales/en/ccr.json +0 -65
  145. package/dist/i18n/locales/en/claude-md.json +0 -73
  146. package/dist/i18n/locales/en/cli.json +0 -152
  147. package/dist/i18n/locales/en/cloud-setup.json +0 -31
  148. package/dist/i18n/locales/en/cloud-sync.json +0 -147
  149. package/dist/i18n/locales/en/cloud.json +0 -40
  150. package/dist/i18n/locales/en/cloudPlugins.json +0 -118
  151. package/dist/i18n/locales/en/codex.json +0 -127
  152. package/dist/i18n/locales/en/cometix.json +0 -29
  153. package/dist/i18n/locales/en/common.json +0 -68
  154. package/dist/i18n/locales/en/config.json +0 -108
  155. package/dist/i18n/locales/en/configuration.json +0 -226
  156. package/dist/i18n/locales/en/context.json +0 -85
  157. package/dist/i18n/locales/en/dashboard.json +0 -78
  158. package/dist/i18n/locales/en/errors.json +0 -26
  159. package/dist/i18n/locales/en/evolution.json +0 -54
  160. package/dist/i18n/locales/en/hooks.json +0 -74
  161. package/dist/i18n/locales/en/hooksSync.json +0 -133
  162. package/dist/i18n/locales/en/installation.json +0 -83
  163. package/dist/i18n/locales/en/interview.json +0 -104
  164. package/dist/i18n/locales/en/language.json +0 -19
  165. package/dist/i18n/locales/en/lsp.json +0 -78
  166. package/dist/i18n/locales/en/marketplace.json +0 -116
  167. package/dist/i18n/locales/en/mcp.json +0 -178
  168. package/dist/i18n/locales/en/memory.json +0 -92
  169. package/dist/i18n/locales/en/menu.json +0 -143
  170. package/dist/i18n/locales/en/multi-config.json +0 -79
  171. package/dist/i18n/locales/en/notification.json +0 -307
  172. package/dist/i18n/locales/en/permissions.json +0 -95
  173. package/dist/i18n/locales/en/persistence.json +0 -127
  174. package/dist/i18n/locales/en/plugins.json +0 -146
  175. package/dist/i18n/locales/en/quick-actions.json +0 -78
  176. package/dist/i18n/locales/en/registry.json +0 -54
  177. package/dist/i18n/locales/en/remote.json +0 -93
  178. package/dist/i18n/locales/en/sandbox.json +0 -44
  179. package/dist/i18n/locales/en/setup.json +0 -44
  180. package/dist/i18n/locales/en/shencha.json +0 -14
  181. package/dist/i18n/locales/en/skills.json +0 -100
  182. package/dist/i18n/locales/en/skillsSync.json +0 -74
  183. package/dist/i18n/locales/en/smartGuide.json +0 -49
  184. package/dist/i18n/locales/en/stats.json +0 -20
  185. package/dist/i18n/locales/en/subagent.json +0 -69
  186. package/dist/i18n/locales/en/superpowers.json +0 -117
  187. package/dist/i18n/locales/en/team.json +0 -7
  188. package/dist/i18n/locales/en/thinking.json +0 -65
  189. package/dist/i18n/locales/en/tools.json +0 -42
  190. package/dist/i18n/locales/en/uninstall.json +0 -56
  191. package/dist/i18n/locales/en/updater.json +0 -29
  192. package/dist/i18n/locales/en/vim.json +0 -169
  193. package/dist/i18n/locales/en/workflow.json +0 -55
  194. package/dist/i18n/locales/en/workspace.json +0 -108
  195. package/dist/i18n/locales/zh-CN/agent-teams.json +0 -18
  196. package/dist/i18n/locales/zh-CN/agentBrowser.json +0 -79
  197. package/dist/i18n/locales/zh-CN/agents.json +0 -135
  198. package/dist/i18n/locales/zh-CN/api.json +0 -63
  199. package/dist/i18n/locales/zh-CN/ccjk-agents.json +0 -33
  200. package/dist/i18n/locales/zh-CN/ccjk-all.json +0 -23
  201. package/dist/i18n/locales/zh-CN/ccjk-skills.json +0 -22
  202. package/dist/i18n/locales/zh-CN/ccjk.json +0 -276
  203. package/dist/i18n/locales/zh-CN/ccr.json +0 -65
  204. package/dist/i18n/locales/zh-CN/claude-md.json +0 -73
  205. package/dist/i18n/locales/zh-CN/cli.json +0 -152
  206. package/dist/i18n/locales/zh-CN/cloud-setup.json +0 -31
  207. package/dist/i18n/locales/zh-CN/cloud-sync.json +0 -147
  208. package/dist/i18n/locales/zh-CN/cloud.json +0 -40
  209. package/dist/i18n/locales/zh-CN/cloudPlugins.json +0 -118
  210. package/dist/i18n/locales/zh-CN/codex.json +0 -127
  211. package/dist/i18n/locales/zh-CN/cometix.json +0 -29
  212. package/dist/i18n/locales/zh-CN/common.json +0 -68
  213. package/dist/i18n/locales/zh-CN/config.json +0 -108
  214. package/dist/i18n/locales/zh-CN/configuration.json +0 -224
  215. package/dist/i18n/locales/zh-CN/context.json +0 -85
  216. package/dist/i18n/locales/zh-CN/dashboard.json +0 -78
  217. package/dist/i18n/locales/zh-CN/errors.json +0 -26
  218. package/dist/i18n/locales/zh-CN/evolution.json +0 -54
  219. package/dist/i18n/locales/zh-CN/hooks.json +0 -74
  220. package/dist/i18n/locales/zh-CN/hooksSync.json +0 -133
  221. package/dist/i18n/locales/zh-CN/installation.json +0 -83
  222. package/dist/i18n/locales/zh-CN/interview.json +0 -104
  223. package/dist/i18n/locales/zh-CN/language.json +0 -19
  224. package/dist/i18n/locales/zh-CN/lsp.json +0 -78
  225. package/dist/i18n/locales/zh-CN/marketplace.json +0 -116
  226. package/dist/i18n/locales/zh-CN/mcp.json +0 -178
  227. package/dist/i18n/locales/zh-CN/memory.json +0 -92
  228. package/dist/i18n/locales/zh-CN/menu.json +0 -143
  229. package/dist/i18n/locales/zh-CN/multi-config.json +0 -79
  230. package/dist/i18n/locales/zh-CN/notification.json +0 -307
  231. package/dist/i18n/locales/zh-CN/permissions.json +0 -95
  232. package/dist/i18n/locales/zh-CN/persistence.json +0 -127
  233. package/dist/i18n/locales/zh-CN/plugins.json +0 -146
  234. package/dist/i18n/locales/zh-CN/quick-actions.json +0 -78
  235. package/dist/i18n/locales/zh-CN/registry.json +0 -54
  236. package/dist/i18n/locales/zh-CN/remote.json +0 -93
  237. package/dist/i18n/locales/zh-CN/sandbox.json +0 -44
  238. package/dist/i18n/locales/zh-CN/setup.json +0 -44
  239. package/dist/i18n/locales/zh-CN/shencha.json +0 -14
  240. package/dist/i18n/locales/zh-CN/skills.json +0 -100
  241. package/dist/i18n/locales/zh-CN/skillsSync.json +0 -74
  242. package/dist/i18n/locales/zh-CN/smartGuide.json +0 -49
  243. package/dist/i18n/locales/zh-CN/stats.json +0 -20
  244. package/dist/i18n/locales/zh-CN/subagent.json +0 -69
  245. package/dist/i18n/locales/zh-CN/superpowers.json +0 -117
  246. package/dist/i18n/locales/zh-CN/team.json +0 -7
  247. package/dist/i18n/locales/zh-CN/thinking.json +0 -65
  248. package/dist/i18n/locales/zh-CN/tools.json +0 -42
  249. package/dist/i18n/locales/zh-CN/uninstall.json +0 -56
  250. package/dist/i18n/locales/zh-CN/updater.json +0 -29
  251. package/dist/i18n/locales/zh-CN/vim.json +0 -169
  252. package/dist/i18n/locales/zh-CN/workflow.json +0 -55
  253. package/dist/i18n/locales/zh-CN/workspace.json +0 -108
  254. package/dist/index.d.mts +0 -5295
  255. package/dist/index.d.ts +0 -5295
  256. package/dist/index.mjs +0 -4941
  257. package/dist/shared/ccjk.B364Fu0N.mjs +0 -1819
  258. package/dist/shared/ccjk.BAGoDD49.mjs +0 -36
  259. package/dist/shared/ccjk.BBtCGd_g.mjs +0 -899
  260. package/dist/shared/ccjk.BFQ7yr5S.mjs +0 -16
  261. package/dist/shared/ccjk.BFxsJM0k.mjs +0 -599
  262. package/dist/shared/ccjk.BIxuVL3_.mjs +0 -25
  263. package/dist/shared/ccjk.BRZ9ww8S.mjs +0 -142
  264. package/dist/shared/ccjk.BoApaI4j.mjs +0 -28
  265. package/dist/shared/ccjk.BrPUmTqm.mjs +0 -266
  266. package/dist/shared/ccjk.BtB1e5jm.mjs +0 -171
  267. package/dist/shared/ccjk.BwfbSKN2.mjs +0 -1051
  268. package/dist/shared/ccjk.BxSmJ8B7.mjs +0 -243
  269. package/dist/shared/ccjk.Bx_rmYfN.mjs +0 -69
  270. package/dist/shared/ccjk.C2jHOZVP.mjs +0 -52
  271. package/dist/shared/ccjk.CL4Yat0G.mjs +0 -303
  272. package/dist/shared/ccjk.COweQ1RR.mjs +0 -5
  273. package/dist/shared/ccjk.CePkJq2S.mjs +0 -223
  274. package/dist/shared/ccjk.CfKKcvWy.mjs +0 -126
  275. package/dist/shared/ccjk.Cjgrln_h.mjs +0 -297
  276. package/dist/shared/ccjk.Cjj8SVrn.mjs +0 -54
  277. package/dist/shared/ccjk.CxpGa6MC.mjs +0 -2724
  278. package/dist/shared/ccjk.D5MFQT7w.mjs +0 -400
  279. package/dist/shared/ccjk.D6ycHbak.mjs +0 -270
  280. package/dist/shared/ccjk.D8ZLYSZZ.mjs +0 -299
  281. package/dist/shared/ccjk.DG_o24cZ.mjs +0 -88
  282. package/dist/shared/ccjk.DLLw-h4Y.mjs +0 -460
  283. package/dist/shared/ccjk.DOwtZMk8.mjs +0 -4019
  284. package/dist/shared/ccjk.DS7UESmF.mjs +0 -2451
  285. package/dist/shared/ccjk.DTdjs-qK.mjs +0 -1447
  286. package/dist/shared/ccjk.DXRAZcix.mjs +0 -66
  287. package/dist/shared/ccjk.DsYaCCx4.mjs +0 -317
  288. package/dist/shared/ccjk.J8YiPsOw.mjs +0 -259
  289. package/dist/shared/ccjk.KfSWcGlE.mjs +0 -38
  290. package/dist/shared/ccjk.RyizuzOI.mjs +0 -21
  291. package/dist/shared/ccjk.SPoXMvZD.mjs +0 -1242
  292. package/dist/shared/ccjk.T_cX87dY.mjs +0 -15
  293. package/dist/shared/ccjk.UIvifqNE.mjs +0 -1486
  294. package/dist/shared/ccjk._dESH4Rk.mjs +0 -111
  295. package/dist/shared/ccjk.bQ7Dh1g4.mjs +0 -249
  296. package/dist/shared/ccjk.c-ETfBZ_.mjs +0 -617
  297. package/dist/shared/ccjk.gDEDGD_t.mjs +0 -38
  298. package/dist/shared/ccjk.hoqrwWdN.mjs +0 -333
  299. package/dist/shared/ccjk.waa2ikKJ.mjs +0 -351
@@ -1,617 +0,0 @@
1
- import { existsSync, readFileSync, mkdirSync, unlinkSync } from 'node:fs';
2
- import os__default, { homedir } from 'node:os';
3
- import { writeFileAtomic } from '../chunks/fs-operations.mjs';
4
- import { Buffer } from 'node:buffer';
5
- import crypto from 'node:crypto';
6
- import { c as createDefaultGateway } from './ccjk.BtB1e5jm.mjs';
7
- import { j as join } from './ccjk.bQ7Dh1g4.mjs';
8
-
9
- const TOKEN_PREFIX = "ccjk_";
10
- const TOKEN_LENGTH = 64;
11
- const TOKEN_VERSION = 1;
12
- function generateDeviceToken() {
13
- const randomBytes = crypto.randomBytes(TOKEN_LENGTH / 2);
14
- const randomHex = randomBytes.toString("hex");
15
- return `${TOKEN_PREFIX}${TOKEN_VERSION}${randomHex}`;
16
- }
17
- function isValidTokenFormat(token) {
18
- if (!token || typeof token !== "string") {
19
- return false;
20
- }
21
- if (!token.startsWith(TOKEN_PREFIX)) {
22
- return false;
23
- }
24
- const expectedLength = TOKEN_PREFIX.length + 1 + TOKEN_LENGTH;
25
- if (token.length !== expectedLength) {
26
- return false;
27
- }
28
- const version = token[TOKEN_PREFIX.length];
29
- if (!/^\d$/.test(version)) {
30
- return false;
31
- }
32
- const hexPart = token.slice(TOKEN_PREFIX.length + 1);
33
- if (!/^[a-f0-9]+$/i.test(hexPart)) {
34
- return false;
35
- }
36
- return true;
37
- }
38
- function getDeviceInfo() {
39
- return {
40
- name: os__default.hostname(),
41
- platform: os__default.platform(),
42
- osVersion: os__default.release(),
43
- arch: os__default.arch(),
44
- username: os__default.userInfo().username,
45
- machineId: generateMachineId()
46
- };
47
- }
48
- function generateMachineId() {
49
- const components = [
50
- os__default.hostname(),
51
- os__default.platform(),
52
- os__default.arch(),
53
- os__default.cpus()[0]?.model || "unknown",
54
- os__default.userInfo().username,
55
- // Add network interface MAC addresses for uniqueness
56
- ...Object.values(os__default.networkInterfaces()).flat().filter((iface) => iface && !iface.internal && iface.mac !== "00:00:00:00:00:00").map((iface) => iface?.mac).filter(Boolean).slice(0, 3)
57
- // Limit to first 3 MACs
58
- ];
59
- const combined = components.join("|");
60
- return crypto.createHash("sha256").update(combined).digest("hex").slice(0, 32);
61
- }
62
- function deriveEncryptionKey() {
63
- const machineId = generateMachineId();
64
- const salt = "ccjk-notification-token-v1";
65
- return crypto.pbkdf2Sync(machineId, salt, 1e5, 32, "sha256");
66
- }
67
- function encryptToken(token) {
68
- const key = deriveEncryptionKey();
69
- const iv = crypto.randomBytes(16);
70
- const cipher = crypto.createCipheriv("aes-256-gcm", key, iv);
71
- let encrypted = cipher.update(token, "utf8", "hex");
72
- encrypted += cipher.final("hex");
73
- const authTag = cipher.getAuthTag();
74
- return `${iv.toString("hex")}:${authTag.toString("hex")}:${encrypted}`;
75
- }
76
- function decryptToken(encryptedToken) {
77
- try {
78
- const parts = encryptedToken.split(":");
79
- if (parts.length !== 3) {
80
- return null;
81
- }
82
- const [ivHex, authTagHex, encrypted] = parts;
83
- const key = deriveEncryptionKey();
84
- const iv = Buffer.from(ivHex, "hex");
85
- const authTag = Buffer.from(authTagHex, "hex");
86
- const decipher = crypto.createDecipheriv("aes-256-gcm", key, iv);
87
- decipher.setAuthTag(authTag);
88
- let decrypted = decipher.update(encrypted, "hex", "utf8");
89
- decrypted += decipher.final("utf8");
90
- return decrypted;
91
- } catch {
92
- return null;
93
- }
94
- }
95
- function maskToken(token) {
96
- if (!token || token.length < 12) {
97
- return "***";
98
- }
99
- const prefix = token.slice(0, TOKEN_PREFIX.length + 1);
100
- const suffix = token.slice(-4);
101
- return `${prefix}***...***${suffix}`;
102
- }
103
-
104
- function validateBindRequest(request) {
105
- const errors = [];
106
- if (!request.code || typeof request.code !== "string") {
107
- errors.push("code is required and must be a string");
108
- } else if (request.code.length < 4) {
109
- errors.push("code must be at least 4 characters");
110
- }
111
- if (!request.deviceInfo || typeof request.deviceInfo !== "object") {
112
- errors.push("deviceInfo is required and must be an object");
113
- } else {
114
- if (!request.deviceInfo.name || typeof request.deviceInfo.name !== "string") {
115
- errors.push("deviceInfo.name is required and must be a string");
116
- }
117
- if (!request.deviceInfo.platform || typeof request.deviceInfo.platform !== "string") {
118
- errors.push("deviceInfo.platform is required and must be a string");
119
- }
120
- }
121
- return {
122
- valid: errors.length === 0,
123
- errors
124
- };
125
- }
126
- function validateNotifyRequest(request) {
127
- const errors = [];
128
- if (!request.title || typeof request.title !== "string") {
129
- errors.push("title is required and must be a string");
130
- } else if (request.title.length > 200) {
131
- errors.push("title must be 200 characters or less");
132
- }
133
- if (!request.body || typeof request.body !== "string") {
134
- errors.push("body is required and must be a string");
135
- } else if (request.body.length > 4e3) {
136
- errors.push("body must be 4000 characters or less");
137
- }
138
- if (request.type && !["info", "success", "warning", "error"].includes(request.type)) {
139
- errors.push("type must be one of: info, success, warning, error");
140
- }
141
- if (request.actions) {
142
- if (!Array.isArray(request.actions)) {
143
- errors.push("actions must be an array");
144
- } else {
145
- request.actions.forEach((action, index) => {
146
- if (!action.id || typeof action.id !== "string") {
147
- errors.push(`actions[${index}].id is required and must be a string`);
148
- }
149
- if (!action.label || typeof action.label !== "string") {
150
- errors.push(`actions[${index}].label is required and must be a string`);
151
- }
152
- if (!action.value || typeof action.value !== "string") {
153
- errors.push(`actions[${index}].value is required and must be a string`);
154
- }
155
- });
156
- }
157
- }
158
- return {
159
- valid: errors.length === 0,
160
- errors
161
- };
162
- }
163
- function validateBindResponse(response) {
164
- const errors = [];
165
- if (typeof response.success !== "boolean") {
166
- errors.push("success is required and must be a boolean");
167
- }
168
- if (response.success) {
169
- if (!response.data) {
170
- errors.push("data is required when success is true");
171
- } else {
172
- if (!response.data.deviceToken || typeof response.data.deviceToken !== "string") {
173
- errors.push("data.deviceToken is required and must be a string");
174
- }
175
- if (!response.data.deviceId || typeof response.data.deviceId !== "string") {
176
- errors.push("data.deviceId is required and must be a string");
177
- }
178
- }
179
- } else {
180
- if (!response.error || typeof response.error !== "string") {
181
- errors.push("error is required when success is false");
182
- }
183
- }
184
- return {
185
- valid: errors.length === 0,
186
- errors
187
- };
188
- }
189
- function validateNotifyResponse(response) {
190
- const errors = [];
191
- if (typeof response.success !== "boolean") {
192
- errors.push("success is required and must be a boolean");
193
- }
194
- if (response.success) {
195
- if (!response.data) {
196
- errors.push("data is required when success is true");
197
- } else {
198
- if (!response.data.notificationId || typeof response.data.notificationId !== "string") {
199
- errors.push("data.notificationId is required and must be a string");
200
- }
201
- }
202
- } else {
203
- if (!response.error || typeof response.error !== "string") {
204
- errors.push("error is required when success is false");
205
- }
206
- }
207
- return {
208
- valid: errors.length === 0,
209
- errors
210
- };
211
- }
212
- function validatePollResponse(response) {
213
- const errors = [];
214
- if (typeof response.success !== "boolean") {
215
- errors.push("success is required and must be a boolean");
216
- }
217
- if (response.success) {
218
- if (!response.data) {
219
- errors.push("data is required when success is true");
220
- } else if (response.data.reply !== null) {
221
- const reply = response.data.reply;
222
- if (!reply.content || typeof reply.content !== "string") {
223
- errors.push("data.reply.content is required and must be a string");
224
- }
225
- if (!reply.timestamp || typeof reply.timestamp !== "string") {
226
- errors.push("data.reply.timestamp is required and must be a string");
227
- }
228
- }
229
- } else {
230
- if (!response.error || typeof response.error !== "string") {
231
- errors.push("error is required when success is false");
232
- }
233
- }
234
- return {
235
- valid: errors.length === 0,
236
- errors
237
- };
238
- }
239
-
240
- const CLOUD_API_BASE_URL = "https://api.claudehome.cn";
241
- const POLL_TIMEOUT = 6e4;
242
- const TOKEN_FILE_PATH = join(homedir(), ".ccjk", "cloud-token.json");
243
- class CCJKCloudClient {
244
- baseUrl;
245
- deviceToken = null;
246
- deviceId = null;
247
- gateway = createDefaultGateway();
248
- /**
249
- * Create a new CCJKCloudClient instance
250
- *
251
- * @param baseUrl - Cloud API base URL (default: https://api.claudehome.cn)
252
- */
253
- constructor(baseUrl = CLOUD_API_BASE_URL) {
254
- this.baseUrl = baseUrl;
255
- this.loadToken();
256
- }
257
- // ==========================================================================
258
- // Token Management
259
- // ==========================================================================
260
- /**
261
- * Load token from storage file
262
- */
263
- loadToken() {
264
- try {
265
- if (existsSync(TOKEN_FILE_PATH)) {
266
- const data = readFileSync(TOKEN_FILE_PATH, "utf-8");
267
- const storage = JSON.parse(data);
268
- this.deviceToken = storage.deviceToken;
269
- this.deviceId = storage.deviceId || null;
270
- }
271
- } catch {
272
- this.deviceToken = null;
273
- this.deviceId = null;
274
- }
275
- }
276
- /**
277
- * Save token to storage file
278
- */
279
- saveToken(storage) {
280
- try {
281
- const dir = join(homedir(), ".ccjk");
282
- if (!existsSync(dir)) {
283
- mkdirSync(dir, { recursive: true });
284
- }
285
- writeFileAtomic(TOKEN_FILE_PATH, JSON.stringify(storage, null, 2));
286
- } catch (error) {
287
- throw new Error(`Failed to save token: ${error instanceof Error ? error.message : String(error)}`);
288
- }
289
- }
290
- /**
291
- * Check if device is bound
292
- */
293
- isBound() {
294
- return this.deviceToken !== null && this.deviceToken.length > 0;
295
- }
296
- /**
297
- * Get current device token
298
- */
299
- getDeviceToken() {
300
- return this.deviceToken;
301
- }
302
- /**
303
- * Get current device ID
304
- */
305
- getDeviceId() {
306
- return this.deviceId;
307
- }
308
- /**
309
- * Clear stored token (unbind device)
310
- */
311
- clearToken() {
312
- this.deviceToken = null;
313
- this.deviceId = null;
314
- try {
315
- if (existsSync(TOKEN_FILE_PATH)) {
316
- unlinkSync(TOKEN_FILE_PATH);
317
- }
318
- } catch {
319
- }
320
- }
321
- // ==========================================================================
322
- // Device Binding
323
- // ==========================================================================
324
- /**
325
- * Bind device using a binding code
326
- *
327
- * The binding code is obtained from the CCJK mobile app or web dashboard.
328
- * Once bound, the device can send and receive notifications.
329
- *
330
- * @param code - Binding code from mobile app
331
- * @param deviceInfo - Optional device information (auto-detected if not provided)
332
- * @returns Bind response with device token
333
- *
334
- * @example
335
- * ```typescript
336
- * const client = new CCJKCloudClient()
337
- * const result = await client.bind('ABC123')
338
- * if (result.success) {
339
- * console.log('Device bound successfully!')
340
- * }
341
- * ```
342
- */
343
- async bind(code, deviceInfo) {
344
- const info = deviceInfo ? { ...getDeviceInfo(), ...deviceInfo } : getDeviceInfo();
345
- const requestPayload = {
346
- code,
347
- deviceInfo: info
348
- };
349
- const requestValidation = validateBindRequest(requestPayload);
350
- if (!requestValidation.valid) {
351
- return {
352
- success: false,
353
- error: `Invalid bind request: ${requestValidation.errors.join(", ")}`,
354
- code: "VALIDATION_ERROR"
355
- };
356
- }
357
- const response = await this.gateway.request("notifications.bind", {
358
- method: "POST",
359
- body: requestPayload,
360
- authToken: this.deviceToken || void 0
361
- });
362
- const responseValidation = validateBindResponse(response);
363
- if (!responseValidation.valid) {
364
- return {
365
- success: false,
366
- error: `Invalid bind response: ${responseValidation.errors.join(", ")}`,
367
- code: "RESPONSE_VALIDATION_ERROR"
368
- };
369
- }
370
- if (response.success && response.data) {
371
- this.deviceToken = response.data.deviceToken;
372
- this.deviceId = response.data.deviceId;
373
- this.gateway.setAuthToken(response.data.deviceToken);
374
- this.saveToken({
375
- deviceToken: response.data.deviceToken,
376
- deviceId: response.data.deviceId,
377
- bindingCode: code,
378
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
379
- deviceInfo: info
380
- });
381
- return {
382
- success: true,
383
- data: {
384
- deviceToken: response.data.deviceToken,
385
- deviceId: response.data.deviceId
386
- }
387
- };
388
- }
389
- return {
390
- success: false,
391
- error: response.error || "Failed to bind device",
392
- code: response.code
393
- };
394
- }
395
- // ==========================================================================
396
- // Notification Sending
397
- // ==========================================================================
398
- /**
399
- * Send a notification to the user
400
- *
401
- * @param options - Notification options
402
- * @returns Notification response
403
- *
404
- * @example
405
- * ```typescript
406
- * const client = new CCJKCloudClient()
407
- * await client.notify({
408
- * title: 'Build Complete',
409
- * body: 'Your project has been built successfully!',
410
- * type: 'success'
411
- * })
412
- * ```
413
- */
414
- async notify(options) {
415
- if (!this.deviceToken) {
416
- return {
417
- success: false,
418
- error: 'Device not bound. Please run "ccjk notification bind <code>" first.',
419
- code: "NOT_BOUND"
420
- };
421
- }
422
- const requestPayload = {
423
- title: options.title,
424
- body: options.body,
425
- type: options.type || "info",
426
- taskId: options.taskId,
427
- metadata: options.metadata,
428
- actions: options.actions
429
- };
430
- const requestValidation = validateNotifyRequest(requestPayload);
431
- if (!requestValidation.valid) {
432
- return {
433
- success: false,
434
- error: `Invalid notify request: ${requestValidation.errors.join(", ")}`,
435
- code: "VALIDATION_ERROR"
436
- };
437
- }
438
- const response = await this.gateway.request("notifications.send", {
439
- method: "POST",
440
- body: requestPayload,
441
- authToken: this.deviceToken
442
- });
443
- const responseValidation = validateNotifyResponse(response);
444
- if (!responseValidation.valid) {
445
- return {
446
- success: false,
447
- error: `Invalid notify response: ${responseValidation.errors.join(", ")}`,
448
- code: "RESPONSE_VALIDATION_ERROR"
449
- };
450
- }
451
- if (response.success && response.data) {
452
- return {
453
- success: true,
454
- data: {
455
- notificationId: response.data.notificationId
456
- }
457
- };
458
- }
459
- return {
460
- success: false,
461
- error: response.error || "Failed to send notification",
462
- code: response.code
463
- };
464
- }
465
- // ==========================================================================
466
- // Reply Polling
467
- // ==========================================================================
468
- /**
469
- * Wait for a reply from the user
470
- *
471
- * Uses long-polling to wait for a user reply. The timeout parameter
472
- * controls how long to wait before returning null.
473
- *
474
- * @param timeout - Timeout in milliseconds (default: 30000)
475
- * @returns User reply or null if timeout
476
- *
477
- * @example
478
- * ```typescript
479
- * const client = new CCJKCloudClient()
480
- * const reply = await client.waitForReply(60000) // Wait up to 60 seconds
481
- * if (reply) {
482
- * console.log('User replied:', reply.content)
483
- * }
484
- * ```
485
- */
486
- async waitForReply(timeout = POLL_TIMEOUT) {
487
- if (!this.deviceToken) {
488
- throw new Error('Device not bound. Please run "ccjk notification bind <code>" first.');
489
- }
490
- const response = await this.gateway.request("notifications.poll", {
491
- method: "GET",
492
- query: { timeout },
493
- authToken: this.deviceToken,
494
- timeout
495
- });
496
- const responseValidation = validatePollResponse(response);
497
- if (!responseValidation.valid) {
498
- throw new Error(`Invalid poll response: ${responseValidation.errors.join(", ")}`);
499
- }
500
- if (!response.success) {
501
- throw new Error(response.error || "Failed to poll for reply");
502
- }
503
- if (response.data?.reply) {
504
- return {
505
- content: response.data.reply.content,
506
- timestamp: new Date(response.data.reply.timestamp),
507
- notificationId: response.data.reply.notificationId,
508
- actionId: response.data.reply.actionId
509
- };
510
- }
511
- return null;
512
- }
513
- // ==========================================================================
514
- // Ask and Wait
515
- // ==========================================================================
516
- /**
517
- * Ask the user a question and wait for their reply
518
- *
519
- * This is a convenience method that combines notify() and waitForReply().
520
- * It sends a notification with the question and waits for the user to respond.
521
- *
522
- * @param question - Question to ask the user
523
- * @param options - Additional notification options
524
- * @param timeout - Timeout in milliseconds (default: 60000)
525
- * @returns User reply
526
- *
527
- * @example
528
- * ```typescript
529
- * const client = new CCJKCloudClient()
530
- * const reply = await client.ask('Deploy to production?', {
531
- * actions: [
532
- * { id: 'yes', label: 'Yes', value: 'yes' },
533
- * { id: 'no', label: 'No', value: 'no' }
534
- * ]
535
- * })
536
- * if (reply.actionId === 'yes') {
537
- * // Proceed with deployment
538
- * }
539
- * ```
540
- */
541
- async ask(question, options, timeout = POLL_TIMEOUT) {
542
- const notifyResult = await this.notify({
543
- title: options?.title || "CCJK Question",
544
- body: question,
545
- type: "info",
546
- ...options
547
- });
548
- if (!notifyResult.success) {
549
- throw new Error(notifyResult.error || "Failed to send question");
550
- }
551
- const reply = await this.waitForReply(timeout);
552
- if (!reply) {
553
- throw new Error("No reply received within timeout");
554
- }
555
- return reply;
556
- }
557
- // ==========================================================================
558
- // Status Check
559
- // ==========================================================================
560
- /**
561
- * Get binding status and device information
562
- *
563
- * @returns Binding status information
564
- */
565
- async getStatus() {
566
- if (!this.deviceToken) {
567
- return { bound: false };
568
- }
569
- try {
570
- if (existsSync(TOKEN_FILE_PATH)) {
571
- const data = readFileSync(TOKEN_FILE_PATH, "utf-8");
572
- const storage = JSON.parse(data);
573
- return {
574
- bound: true,
575
- deviceId: storage.deviceId,
576
- deviceInfo: storage.deviceInfo,
577
- lastUsed: storage.lastUsedAt
578
- };
579
- }
580
- } catch {
581
- }
582
- return {
583
- bound: true,
584
- deviceId: this.deviceId || void 0
585
- };
586
- }
587
- // Note: HTTP requests now handled by CloudApiGateway
588
- }
589
- let cloudClientInstance = null;
590
- function getCloudNotificationClient() {
591
- if (!cloudClientInstance) {
592
- cloudClientInstance = new CCJKCloudClient();
593
- }
594
- return cloudClientInstance;
595
- }
596
- async function bindDevice(code, deviceInfo) {
597
- const client = getCloudNotificationClient();
598
- return client.bind(code, deviceInfo);
599
- }
600
- async function sendNotification(options) {
601
- const client = getCloudNotificationClient();
602
- return client.notify(options);
603
- }
604
- function isDeviceBound() {
605
- const client = getCloudNotificationClient();
606
- return client.isBound();
607
- }
608
- async function getBindingStatus() {
609
- const client = getCloudNotificationClient();
610
- return client.getStatus();
611
- }
612
- function unbindDevice() {
613
- const client = getCloudNotificationClient();
614
- client.clearToken();
615
- }
616
-
617
- export { isValidTokenFormat as a, bindDevice as b, generateDeviceToken as c, decryptToken as d, encryptToken as e, getDeviceInfo as f, getBindingStatus as g, isDeviceBound as i, maskToken as m, sendNotification as s, unbindDevice as u };
@@ -1,38 +0,0 @@
1
- import { existsSync, readFileSync } from 'node:fs';
2
- import process__default from 'node:process';
3
- import { fileURLToPath } from 'node:url';
4
- import { d as dirname, j as join } from './ccjk.bQ7Dh1g4.mjs';
5
-
6
- let cachedMetadata = null;
7
- function readRuntimePackageMetadata() {
8
- if (cachedMetadata) {
9
- return cachedMetadata;
10
- }
11
- const currentDir = dirname(fileURLToPath(import.meta.url));
12
- const candidatePaths = [
13
- join(currentDir, "../../package.json"),
14
- join(currentDir, "../package.json"),
15
- join(process__default.cwd(), "package.json")
16
- ];
17
- for (const packagePath of candidatePaths) {
18
- if (!existsSync(packagePath)) {
19
- continue;
20
- }
21
- try {
22
- const parsed = JSON.parse(readFileSync(packagePath, "utf-8"));
23
- cachedMetadata = parsed;
24
- return parsed;
25
- } catch {
26
- }
27
- }
28
- cachedMetadata = {};
29
- return cachedMetadata;
30
- }
31
- function getRuntimeVersion() {
32
- return readRuntimePackageMetadata().version || "0.0.0";
33
- }
34
- function getRuntimeHomepage() {
35
- return readRuntimePackageMetadata().homepage || "https://github.com/miounet11/ccjk";
36
- }
37
-
38
- export { getRuntimeHomepage as a, getRuntimeVersion as g };