@wirecat/hubspot-cli 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (261) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/LICENSE +204 -0
  3. package/README.md +280 -2
  4. package/contracts/wirecat.json +3270 -0
  5. package/dist/bin/hubspot.d.ts +3 -0
  6. package/dist/bin/hubspot.d.ts.map +1 -0
  7. package/dist/bin/hubspot.js +40 -0
  8. package/dist/bin/hubspot.js.map +1 -0
  9. package/dist/bundle/all-profiles-64JAUYW4.js +279 -0
  10. package/dist/bundle/anthropic-VJOS4OUM.js +91 -0
  11. package/dist/bundle/app-server-GXV2OFML.js +245 -0
  12. package/dist/bundle/bun-M3J2QTR3.js +169 -0
  13. package/dist/bundle/bun-sqlite-IX3XYA5F.js +76 -0
  14. package/dist/bundle/chunk-24ERVFJP.js +73 -0
  15. package/dist/bundle/chunk-2QZK5BEP.js +392 -0
  16. package/dist/bundle/chunk-2UOJ7DLZ.js +46 -0
  17. package/dist/bundle/chunk-2VGD63G6.js +604 -0
  18. package/dist/bundle/chunk-2VGZRYEH.js +334 -0
  19. package/dist/bundle/chunk-36ITRDYY.js +63116 -0
  20. package/dist/bundle/chunk-3WLYWRGG.js +1395 -0
  21. package/dist/bundle/chunk-43EKCUBJ.js +72 -0
  22. package/dist/bundle/chunk-4W6BMH45.js +731 -0
  23. package/dist/bundle/chunk-5A6ZYNAQ.js +2003 -0
  24. package/dist/bundle/chunk-5D4AEUVA.js +24783 -0
  25. package/dist/bundle/chunk-5GBUCHRU.js +274 -0
  26. package/dist/bundle/chunk-5K7QLJMM.js +4072 -0
  27. package/dist/bundle/chunk-65TWQ7BV.js +54 -0
  28. package/dist/bundle/chunk-7ELMWE3P.js +12066 -0
  29. package/dist/bundle/chunk-ADLS6FVG.js +24600 -0
  30. package/dist/bundle/chunk-B3MANLNK.js +602 -0
  31. package/dist/bundle/chunk-C32AKHTY.js +2310 -0
  32. package/dist/bundle/chunk-CLAN3FES.js +1246 -0
  33. package/dist/bundle/chunk-CWXOXIWS.js +46 -0
  34. package/dist/bundle/chunk-D72URWJE.js +532 -0
  35. package/dist/bundle/chunk-DB2XKHI4.js +72 -0
  36. package/dist/bundle/chunk-DBEQI5YM.js +100 -0
  37. package/dist/bundle/chunk-DFCHHR5M.js +38 -0
  38. package/dist/bundle/chunk-DFDN6AUB.js +21 -0
  39. package/dist/bundle/chunk-DRWWJLI6.js +188 -0
  40. package/dist/bundle/chunk-DSP36YHQ.js +29 -0
  41. package/dist/bundle/chunk-E52JAS35.js +1028 -0
  42. package/dist/bundle/chunk-E5WLE7BM.js +78 -0
  43. package/dist/bundle/chunk-ECEZOLOD.js +230 -0
  44. package/dist/bundle/chunk-EH6ZEJGT.js +932 -0
  45. package/dist/bundle/chunk-FBCCBCFH.js +288 -0
  46. package/dist/bundle/chunk-FKA7DOCK.js +53 -0
  47. package/dist/bundle/chunk-FOZYMDRL.js +259 -0
  48. package/dist/bundle/chunk-FPUGMDJV.js +7 -0
  49. package/dist/bundle/chunk-FTFV3HFW.js +721 -0
  50. package/dist/bundle/chunk-GPYCBYX5.js +218 -0
  51. package/dist/bundle/chunk-H3TNVEQX.js +782 -0
  52. package/dist/bundle/chunk-HC5ZWE5X.js +193 -0
  53. package/dist/bundle/chunk-HCAZV5NP.js +95 -0
  54. package/dist/bundle/chunk-HZRQLAHO.js +16 -0
  55. package/dist/bundle/chunk-IJADZW42.js +195 -0
  56. package/dist/bundle/chunk-IMJQRPLN.js +92 -0
  57. package/dist/bundle/chunk-JLDBMEKZ.js +106 -0
  58. package/dist/bundle/chunk-LOBVOGOE.js +66 -0
  59. package/dist/bundle/chunk-LXZ66MCH.js +1328 -0
  60. package/dist/bundle/chunk-MFNMKHML.js +26462 -0
  61. package/dist/bundle/chunk-MVA5HVKL.js +1392 -0
  62. package/dist/bundle/chunk-N2XADGL4.js +76 -0
  63. package/dist/bundle/chunk-NHHJHXMQ.js +58 -0
  64. package/dist/bundle/chunk-NUU4WZVL.js +52 -0
  65. package/dist/bundle/chunk-NWHEHV3K.js +133 -0
  66. package/dist/bundle/chunk-NXERIDPJ.js +319 -0
  67. package/dist/bundle/chunk-O3DYRCIT.js +23 -0
  68. package/dist/bundle/chunk-O55RWNSH.js +161 -0
  69. package/dist/bundle/chunk-P5BHKKBI.js +206 -0
  70. package/dist/bundle/chunk-PPHBRESD.js +82 -0
  71. package/dist/bundle/chunk-PVKF24ZW.js +364 -0
  72. package/dist/bundle/chunk-Q2OLOMHL.js +4045 -0
  73. package/dist/bundle/chunk-QGFX5MXL.js +460 -0
  74. package/dist/bundle/chunk-QJW35N5V.js +761 -0
  75. package/dist/bundle/chunk-QU25DA5N.js +360 -0
  76. package/dist/bundle/chunk-RMIYKDUL.js +1068 -0
  77. package/dist/bundle/chunk-RR5MX5TM.js +142 -0
  78. package/dist/bundle/chunk-SDQGB4KB.js +185 -0
  79. package/dist/bundle/chunk-TBJYLC5K.js +2788 -0
  80. package/dist/bundle/chunk-TI46WQXQ.js +1197 -0
  81. package/dist/bundle/chunk-TKVL2C3B.js +170 -0
  82. package/dist/bundle/chunk-TLKEPUAV.js +786 -0
  83. package/dist/bundle/chunk-TOSCB4SO.js +1227 -0
  84. package/dist/bundle/chunk-TP7GDWVF.js +6848 -0
  85. package/dist/bundle/chunk-URX6YDUL.js +9393 -0
  86. package/dist/bundle/chunk-UUMUL4L3.js +72 -0
  87. package/dist/bundle/chunk-VOH7S5M4.js +40963 -0
  88. package/dist/bundle/chunk-W53EJOFQ.js +63 -0
  89. package/dist/bundle/chunk-W7HM2VGO.js +24 -0
  90. package/dist/bundle/chunk-WE4UFASG.js +88 -0
  91. package/dist/bundle/chunk-X2M6NIQG.js +18 -0
  92. package/dist/bundle/chunk-XRREFEIW.js +372 -0
  93. package/dist/bundle/chunk-Y5E2WNWB.js +35 -0
  94. package/dist/bundle/chunk-YMCY7VRE.js +1846 -0
  95. package/dist/bundle/chunk-Z73OL5HV.js +41 -0
  96. package/dist/bundle/chunk-ZVVMGPBJ.js +50 -0
  97. package/dist/bundle/command-contract-C6CBFXZF.js +40 -0
  98. package/dist/bundle/command-server-entry-DJKVVZCQ.js +169 -0
  99. package/dist/bundle/decode-FC65Y4IV.js +297 -0
  100. package/dist/bundle/definitions-MVPICAWV.js +2991 -0
  101. package/dist/bundle/dispatch-KOISQ5QJ.js +411 -0
  102. package/dist/bundle/dist-7TGU56B2.js +7577 -0
  103. package/dist/bundle/echarts-FVTUDXDU.js +42501 -0
  104. package/dist/bundle/embed-VNBZFPYH.js +38 -0
  105. package/dist/bundle/embedder-6U4NOFRO.js +111 -0
  106. package/dist/bundle/failure-FZ6VYKEQ.js +25 -0
  107. package/dist/bundle/first-run-UWAFSINQ.js +29 -0
  108. package/dist/bundle/first-screen-RTVMGHAE.js +40 -0
  109. package/dist/bundle/hubspot.js +198 -0
  110. package/dist/bundle/instructions-HET7BCYK.js +11 -0
  111. package/dist/bundle/mcp-RGNRW77S.js +167 -0
  112. package/dist/bundle/meeting-combined-L5AGBPYX.js +25 -0
  113. package/dist/bundle/meeting-model-NTB4RK3F.js +25 -0
  114. package/dist/bundle/meeting-semantic-JY3OGCBS.js +22 -0
  115. package/dist/bundle/node-CXZIFHZC.js +176 -0
  116. package/dist/bundle/node-P4E63KXA.js +2340 -0
  117. package/dist/bundle/node-TLZSIHIJ.js +21 -0
  118. package/dist/bundle/node-sqlite-P3O7XN7Q.js +74 -0
  119. package/dist/bundle/oauth-HNCY4B2S.js +20 -0
  120. package/dist/bundle/open-F4P6YV54.js +23 -0
  121. package/dist/bundle/openai-4AICLIK3.js +238 -0
  122. package/dist/bundle/process-5RUXWGYS.js +91 -0
  123. package/dist/bundle/program-XA4C44Z4.js +9374 -0
  124. package/dist/bundle/prompt-NFMDVBZ4.js +17 -0
  125. package/dist/bundle/recognize-DKN3RY4V.js +26 -0
  126. package/dist/bundle/remote-6QHAGQWY.js +31 -0
  127. package/dist/bundle/rerank-M4KHEHUZ.js +52 -0
  128. package/dist/bundle/schemas-JRL3DLMP.js +952 -0
  129. package/dist/bundle/serve-DNU43ND6.js +199 -0
  130. package/dist/bundle/server-ATG5KY7K.js +207 -0
  131. package/dist/bundle/server-VNWVVH7A.js +77 -0
  132. package/dist/bundle/source-54HR4IWG.js +661 -0
  133. package/dist/bundle/sqlite-runtime-EMQAC63N.js +20 -0
  134. package/dist/bundle/state-T45CX7VY.js +36 -0
  135. package/dist/bundle/store-6LCEVBAZ.js +176 -0
  136. package/dist/bundle/store-6TZ2FCVA.js +295 -0
  137. package/dist/bundle/store-DXWYNVVB.js +32 -0
  138. package/dist/bundle/store-maintenance-command-J57HCJYY.js +68 -0
  139. package/dist/bundle/writer-NLLI5YRM.js +79 -0
  140. package/dist/commands/account.d.ts +3 -0
  141. package/dist/commands/account.d.ts.map +1 -0
  142. package/dist/commands/account.js +87 -0
  143. package/dist/commands/account.js.map +1 -0
  144. package/dist/commands/api.d.ts +9 -0
  145. package/dist/commands/api.d.ts.map +1 -0
  146. package/dist/commands/api.js +70 -0
  147. package/dist/commands/api.js.map +1 -0
  148. package/dist/commands/crm-shared.d.ts +8 -0
  149. package/dist/commands/crm-shared.d.ts.map +1 -0
  150. package/dist/commands/crm-shared.js +109 -0
  151. package/dist/commands/crm-shared.js.map +1 -0
  152. package/dist/commands/schedule.d.ts +3 -0
  153. package/dist/commands/schedule.d.ts.map +1 -0
  154. package/dist/commands/schedule.js +9 -0
  155. package/dist/commands/schedule.js.map +1 -0
  156. package/dist/commands/session.d.ts +14 -0
  157. package/dist/commands/session.d.ts.map +1 -0
  158. package/dist/commands/session.js +164 -0
  159. package/dist/commands/session.js.map +1 -0
  160. package/dist/config.d.ts +60 -0
  161. package/dist/config.d.ts.map +1 -0
  162. package/dist/config.js +153 -0
  163. package/dist/config.js.map +1 -0
  164. package/dist/context.d.ts +88 -0
  165. package/dist/context.d.ts.map +1 -0
  166. package/dist/context.js +137 -0
  167. package/dist/context.js.map +1 -0
  168. package/dist/crm/activities.d.ts +24 -0
  169. package/dist/crm/activities.d.ts.map +1 -0
  170. package/dist/crm/activities.js +214 -0
  171. package/dist/crm/activities.js.map +1 -0
  172. package/dist/crm/associations.d.ts +20 -0
  173. package/dist/crm/associations.d.ts.map +1 -0
  174. package/dist/crm/associations.js +47 -0
  175. package/dist/crm/associations.js.map +1 -0
  176. package/dist/crm/records.d.ts +63 -0
  177. package/dist/crm/records.d.ts.map +1 -0
  178. package/dist/crm/records.js +333 -0
  179. package/dist/crm/records.js.map +1 -0
  180. package/dist/crm/search.d.ts +57 -0
  181. package/dist/crm/search.d.ts.map +1 -0
  182. package/dist/crm/search.js +47 -0
  183. package/dist/crm/search.js.map +1 -0
  184. package/dist/crm/source.d.ts +37 -0
  185. package/dist/crm/source.d.ts.map +1 -0
  186. package/dist/crm/source.js +366 -0
  187. package/dist/crm/source.js.map +1 -0
  188. package/dist/crm/writer.d.ts +15 -0
  189. package/dist/crm/writer.d.ts.map +1 -0
  190. package/dist/crm/writer.js +199 -0
  191. package/dist/crm/writer.js.map +1 -0
  192. package/dist/generated/definitions.d.ts +3 -0
  193. package/dist/generated/definitions.d.ts.map +1 -0
  194. package/dist/generated/definitions.js +2987 -0
  195. package/dist/generated/definitions.js.map +1 -0
  196. package/dist/generated/manifest.d.ts +6 -0
  197. package/dist/generated/manifest.d.ts.map +1 -0
  198. package/dist/generated/manifest.js +6504 -0
  199. package/dist/generated/manifest.js.map +1 -0
  200. package/dist/generated/schemas.d.ts +205 -0
  201. package/dist/generated/schemas.d.ts.map +1 -0
  202. package/dist/generated/schemas.js +810 -0
  203. package/dist/generated/schemas.js.map +1 -0
  204. package/dist/generated/types.d.ts +1114 -0
  205. package/dist/generated/types.d.ts.map +1 -0
  206. package/dist/generated/types.js +5 -0
  207. package/dist/generated/types.js.map +1 -0
  208. package/dist/hubspot/account.d.ts +12 -0
  209. package/dist/hubspot/account.d.ts.map +1 -0
  210. package/dist/hubspot/account.js +23 -0
  211. package/dist/hubspot/account.js.map +1 -0
  212. package/dist/hubspot/transport.d.ts +81 -0
  213. package/dist/hubspot/transport.d.ts.map +1 -0
  214. package/dist/hubspot/transport.js +354 -0
  215. package/dist/hubspot/transport.js.map +1 -0
  216. package/dist/identity.d.ts +7 -0
  217. package/dist/identity.d.ts.map +1 -0
  218. package/dist/identity.js +32 -0
  219. package/dist/identity.js.map +1 -0
  220. package/dist/index.d.ts +3 -0
  221. package/dist/index.d.ts.map +1 -0
  222. package/dist/index.js +3 -0
  223. package/dist/index.js.map +1 -0
  224. package/dist/program.d.ts +6 -0
  225. package/dist/program.d.ts.map +1 -0
  226. package/dist/program.js +78 -0
  227. package/dist/program.js.map +1 -0
  228. package/dist/reasons.d.ts +10 -0
  229. package/dist/reasons.d.ts.map +1 -0
  230. package/dist/reasons.js +33 -0
  231. package/dist/reasons.js.map +1 -0
  232. package/dist/setup/flow.d.ts +2 -0
  233. package/dist/setup/flow.d.ts.map +1 -0
  234. package/dist/setup/flow.js +97 -0
  235. package/dist/setup/flow.js.map +1 -0
  236. package/dist/setup/texts.en.json +19 -0
  237. package/dist/setup/texts.es.json +19 -0
  238. package/dist/setup/texts.ru.json +19 -0
  239. package/dist/store.d.ts +16 -0
  240. package/dist/store.d.ts.map +1 -0
  241. package/dist/store.js +34 -0
  242. package/dist/store.js.map +1 -0
  243. package/dist/version.d.ts +2 -0
  244. package/dist/version.d.ts.map +1 -0
  245. package/dist/version.js +2 -0
  246. package/dist/version.js.map +1 -0
  247. package/dist/wcat.d.ts +3 -0
  248. package/dist/wcat.d.ts.map +1 -0
  249. package/dist/wcat.js +4 -0
  250. package/dist/wcat.js.map +1 -0
  251. package/dist/whoami.d.ts +19 -0
  252. package/dist/whoami.d.ts.map +1 -0
  253. package/dist/whoami.js +15 -0
  254. package/dist/whoami.js.map +1 -0
  255. package/package.json +98 -4
  256. package/skills/hubspot-cli/SKILL.md +102 -0
  257. package/skills/hubspot-cli/references/api/api-advanced.md +51 -0
  258. package/skills/hubspot-cli/references/api/api-basic.md +1064 -0
  259. package/skills/hubspot-cli/references/api/api-batch.md +724 -0
  260. package/skills/hubspot-cli/references/api/api-search.md +147 -0
  261. package/skills/hubspot-cli/references/api.md +16 -0
@@ -0,0 +1,142 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ executableEnvironment,
5
+ executableOnPath
6
+ } from "./chunk-CWXOXIWS.js";
7
+ import {
8
+ require_cross_spawn
9
+ } from "./chunk-D72URWJE.js";
10
+ import {
11
+ loadConfigFile,
12
+ saveConfigFile
13
+ } from "./chunk-TBJYLC5K.js";
14
+ import {
15
+ number,
16
+ object,
17
+ optional,
18
+ string
19
+ } from "./chunk-MVA5HVKL.js";
20
+ import {
21
+ __name,
22
+ __toESM
23
+ } from "./chunk-ZVVMGPBJ.js";
24
+
25
+ // node_modules/.pnpm/@wirecat+cli-base@0.109.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/update/index.js
26
+ var import_cross_spawn = __toESM(require_cross_spawn(), 1);
27
+ import { existsSync } from "node:fs";
28
+ var updateCommand = /* @__PURE__ */ __name((installer, packageName) => {
29
+ const target = `${packageName}@latest`;
30
+ switch (installer) {
31
+ // pnpm 11 installs only versions a day old (minimumReleaseAge 1440); a fix must reach users the day it ships.
32
+ // Only the package's own scope is exempt — every other dependency keeps the wait.
33
+ case "pnpm":
34
+ return ["pnpm", "add", "-g", target, `--config.minimumReleaseAgeExclude=${ownScope(packageName)}`];
35
+ case "npm":
36
+ return ["npm", "install", "-g", target];
37
+ case "bun":
38
+ return ["bun", "add", "-g", target];
39
+ default:
40
+ return void 0;
41
+ }
42
+ }, "updateCommand");
43
+ var ownScope = /* @__PURE__ */ __name((packageName) => packageName.startsWith("@") ? `${packageName.split("/", 1)[0]}/*` : packageName, "ownScope");
44
+ var isNewer = /* @__PURE__ */ __name((candidate, current) => {
45
+ const parse = /* @__PURE__ */ __name((version) => /^\d+\.\d+\.\d+$/.test(version) ? version.split(".").map(Number) : void 0, "parse");
46
+ const a = parse(candidate);
47
+ const b = parse(current);
48
+ if (!a || !b)
49
+ return false;
50
+ for (let i = 0; i < 3; i++) {
51
+ if (a[i] !== b[i])
52
+ return a[i] > b[i];
53
+ }
54
+ return false;
55
+ }, "isNewer");
56
+ var latestVersion = /* @__PURE__ */ __name(async (packageName, fetch, { timeoutMs = 1e3 } = {}) => {
57
+ try {
58
+ const response = await fetch(`https://registry.npmjs.org/${packageName}/latest`, {
59
+ signal: AbortSignal.timeout(timeoutMs),
60
+ headers: { accept: "application/json" }
61
+ });
62
+ if (!response.ok)
63
+ return void 0;
64
+ const { version } = await response.json();
65
+ return typeof version === "string" ? version : void 0;
66
+ } catch {
67
+ return void 0;
68
+ }
69
+ }, "latestVersion");
70
+ var CHECK_EVERY_MS = 24 * 60 * 60 * 1e3;
71
+ var mayNotify = /* @__PURE__ */ __name(({ format, stderrIsTTY, quiet, enabled, installer, env, offVariables = [] }) => enabled && format === "pretty" && stderrIsTTY && !quiet && updateCommand(installer, "any") !== void 0 && !env.CI && !env.NO_UPDATE_NOTIFIER && offVariables.every((name) => !env[name]), "mayNotify");
72
+ var updateState = object({
73
+ checkedAt: number(),
74
+ latest: optional(string()),
75
+ /** When the skill hint (`cli-base/skill`) was last shown — the other daily notice kept in this file. */
76
+ skillHintAt: optional(number())
77
+ });
78
+ var readNoticeState = /* @__PURE__ */ __name((path) => {
79
+ try {
80
+ return loadConfigFile(path, updateState, () => ({ checkedAt: 0 }));
81
+ } catch {
82
+ return { checkedAt: 0 };
83
+ }
84
+ }, "readNoticeState");
85
+ var readUpdateState = /* @__PURE__ */ __name((path) => {
86
+ const state = readNoticeState(path);
87
+ return state.checkedAt > 0 ? state : void 0;
88
+ }, "readUpdateState");
89
+ var writeUpdateState = /* @__PURE__ */ __name((path, state) => {
90
+ try {
91
+ saveConfigFile(path, { ...readNoticeState(path), ...state });
92
+ } catch {
93
+ }
94
+ }, "writeUpdateState");
95
+ var checkIsDue = /* @__PURE__ */ __name((state, now) => state === void 0 || now - state.checkedAt >= CHECK_EVERY_MS, "checkIsDue");
96
+ var spawnPlan = /* @__PURE__ */ __name(([command, ...args], platform = process.platform, env = process.env, exists = existsSync) => ({ file: executableOnPath(command, env, platform, exists), args, shell: false }), "spawnPlan");
97
+ var runUpdate = /* @__PURE__ */ __name((argv) => {
98
+ const { file, args, shell } = spawnPlan(argv);
99
+ const { status, error } = import_cross_spawn.default.sync(file, args, {
100
+ stdio: ["inherit", 2, 2],
101
+ shell,
102
+ env: executableEnvironment(process.env)
103
+ });
104
+ if (error)
105
+ throw new Error(`could not start ${argv[0]}: ${error.message}`);
106
+ return status ?? 1;
107
+ }, "runUpdate");
108
+ var updateNotice = /* @__PURE__ */ __name(async ({ argv, packageName, command, upgradeCommand = "upgrade", version, statePath, fetch, now = Date.now, ...context }) => {
109
+ try {
110
+ const path = commandWords(argv).slice(0, 2);
111
+ if (path.includes("complete") || path.includes(upgradeCommand))
112
+ return void 0;
113
+ if (!mayNotify(context))
114
+ return void 0;
115
+ const at = now();
116
+ let state = readUpdateState(statePath);
117
+ if (checkIsDue(state, at)) {
118
+ const found = await latestVersion(packageName, fetch, { timeoutMs: 1e3 });
119
+ const seen = found ?? state?.latest;
120
+ state = seen ? { checkedAt: at, latest: seen } : { checkedAt: at };
121
+ writeUpdateState(statePath, state);
122
+ }
123
+ return state?.latest && isNewer(state.latest, version) ? `${command} ${state.latest} is out \u2014 you have ${version}. \`${command} ${upgradeCommand}\` installs it.` : void 0;
124
+ } catch {
125
+ return void 0;
126
+ }
127
+ }, "updateNotice");
128
+ var commandWords = /* @__PURE__ */ __name((argv) => {
129
+ const end = argv.indexOf("--");
130
+ return argv.slice(0, end < 0 ? void 0 : end).filter((word) => !word.startsWith("-"));
131
+ }, "commandWords");
132
+
133
+ export {
134
+ updateCommand,
135
+ isNewer,
136
+ latestVersion,
137
+ CHECK_EVERY_MS,
138
+ readNoticeState,
139
+ writeUpdateState,
140
+ runUpdate,
141
+ updateNotice
142
+ };
@@ -0,0 +1,185 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ PLAIN_HTTP_REFUSED,
5
+ modelAddressAllowed,
6
+ onThisComputer
7
+ } from "./chunk-XRREFEIW.js";
8
+ import {
9
+ readSharedSection,
10
+ sharedConfigPath,
11
+ writeSharedSection
12
+ } from "./chunk-TI46WQXQ.js";
13
+ import {
14
+ unit
15
+ } from "./chunk-E52JAS35.js";
16
+ import {
17
+ storePath
18
+ } from "./chunk-65TWQ7BV.js";
19
+ import {
20
+ boolean,
21
+ isoTimestamp,
22
+ pipe,
23
+ safeParse,
24
+ strictObject,
25
+ string
26
+ } from "./chunk-MVA5HVKL.js";
27
+ import {
28
+ CliError
29
+ } from "./chunk-DB2XKHI4.js";
30
+ import {
31
+ __name
32
+ } from "./chunk-ZVVMGPBJ.js";
33
+
34
+ // node_modules/.pnpm/@wirecat+cli-core@0.687.0_@wirecat+cli-base@0.109.0_commander@15.0.0_esbuild@0.28.2_typ_3e6248e31e5b79d53006284373ddef70/node_modules/@wirecat/cli-core/dist/embeddings/remote.js
35
+ import { setTimeout } from "node:timers/promises";
36
+
37
+ // node_modules/.pnpm/@wirecat+cli-core@0.687.0_@wirecat+cli-base@0.109.0_commander@15.0.0_esbuild@0.28.2_typ_3e6248e31e5b79d53006284373ddef70/node_modules/@wirecat/cli-core/dist/models/local-only.js
38
+ var SECTION = "local_only";
39
+ var Setting = strictObject({
40
+ on: boolean(),
41
+ at: pipe(string(), isoTimestamp())
42
+ });
43
+ var pathOf = /* @__PURE__ */ __name((env) => sharedConfigPath(storePath(env), env), "pathOf");
44
+ var readLocalOnly = /* @__PURE__ */ __name((env) => {
45
+ const section = readSharedSection(pathOf(env), SECTION);
46
+ if (section === void 0 || section === null)
47
+ return void 0;
48
+ const checked = safeParse(Setting, section);
49
+ return checked.success ? checked.output : { on: true, at: (/* @__PURE__ */ new Date(0)).toISOString() };
50
+ }, "readLocalOnly");
51
+ var localOnly = /* @__PURE__ */ __name((env) => readLocalOnly(env)?.on === true, "localOnly");
52
+ var writeLocalOnly = /* @__PURE__ */ __name((env, on) => writeSharedSection(pathOf(env), SECTION, on ? { on: true, at: (/* @__PURE__ */ new Date()).toISOString() } : void 0), "writeLocalOnly");
53
+ var localOnlyRefusal = /* @__PURE__ */ __name((what, where) => new CliError("permission_error", `local only is on: ${what} would go to ${where}, which is not this computer; nothing was sent. Choose a model on this computer, or turn local only off with \`models local-only set off\``, { reason: "local-only.refused" }), "localOnlyRefusal");
54
+ var refuseOffComputer = /* @__PURE__ */ __name((env, address, what) => {
55
+ if (!onThisComputer(address) && localOnly(env))
56
+ throw localOnlyRefusal(what, hostOf(address));
57
+ }, "refuseOffComputer");
58
+ var hostOf = /* @__PURE__ */ __name((address) => {
59
+ try {
60
+ return new URL(address).host;
61
+ } catch {
62
+ return address;
63
+ }
64
+ }, "hostOf");
65
+ var refuseModelAddress = /* @__PURE__ */ __name((env, address, what) => {
66
+ if (!modelAddressAllowed(address))
67
+ throw new CliError("validation_error", PLAIN_HTTP_REFUSED, { reason: "model.address-refused" });
68
+ refuseOffComputer(env, address, what);
69
+ }, "refuseModelAddress");
70
+
71
+ // node_modules/.pnpm/@wirecat+cli-core@0.687.0_@wirecat+cli-base@0.109.0_commander@15.0.0_esbuild@0.28.2_typ_3e6248e31e5b79d53006284373ddef70/node_modules/@wirecat/cli-core/dist/embeddings/remote.js
72
+ var OPENAI_URL = "https://api.openai.com/v1";
73
+ var OPENAI_MODELS = {
74
+ "text-embedding-3-small": { dims: 1536, perMillion: 0.02 },
75
+ "text-embedding-3-large": { dims: 3072, perMillion: 0.13 }
76
+ };
77
+ var DEFAULT_OPENAI_MODEL = "text-embedding-3-small";
78
+ var PER_REQUEST = 256;
79
+ var isLocal = /* @__PURE__ */ __name((baseUrl) => onThisComputer(baseUrl), "isLocal");
80
+ var remoteModel = /* @__PURE__ */ __name(({ model = DEFAULT_OPENAI_MODEL, baseUrl, dims }) => {
81
+ const known = baseUrl === void 0 ? OPENAI_MODELS[model] : void 0;
82
+ if (baseUrl === void 0 && !known) {
83
+ throw new CliError("validation_error", `OpenAI has no embedding model ${model} here \u2014 one of: ${Object.keys(OPENAI_MODELS).join(", ")}; another server takes --base-url`);
84
+ }
85
+ const size = dims ?? known?.dims;
86
+ if (size === void 0)
87
+ throw new CliError("validation_error", "with --base-url, say the vector size with --dims");
88
+ return {
89
+ provider: baseUrl === void 0 ? "openai" : `url:${new URL(baseUrl).host}`,
90
+ model,
91
+ dims: size,
92
+ baseUrl: baseUrl ?? OPENAI_URL,
93
+ shorten: known !== void 0 && size !== known.dims,
94
+ ...known ? { price: { perMillion: known.perMillion, read: "2026-10-02" } } : {}
95
+ };
96
+ }, "remoteModel");
97
+ var remoteKey = /* @__PURE__ */ __name(({ provider, model, dims }) => `${provider}:${model}:${dims}`, "remoteKey");
98
+ var openRemote = /* @__PURE__ */ __name((remote, apiKey, { concurrency = 4, fetch: post = fetch, tries = 5, env }) => {
99
+ refuseModelAddress(env ?? process.env, remote.baseUrl, "text to embed");
100
+ const request = /* @__PURE__ */ __name(async (input) => {
101
+ for (let attempt = 1; ; attempt++) {
102
+ let response;
103
+ try {
104
+ response = await post(`${remote.baseUrl.replace(/\/$/, "")}/embeddings`, {
105
+ method: "POST",
106
+ headers: {
107
+ "content-type": "application/json",
108
+ ...apiKey ? { authorization: `Bearer ${apiKey}` } : {}
109
+ },
110
+ body: JSON.stringify({
111
+ model: remote.model,
112
+ input,
113
+ encoding_format: "float",
114
+ ...remote.shorten ? { dimensions: remote.dims } : {}
115
+ })
116
+ });
117
+ } catch {
118
+ if (attempt >= tries)
119
+ throw new CliError("network_error", `${remote.provider} could not be reached`);
120
+ await setTimeout(1e3 * attempt);
121
+ continue;
122
+ }
123
+ if (response.ok) {
124
+ const body = await response.json();
125
+ const data = [...body.data ?? []].sort((a, b) => a.index - b.index);
126
+ if (data.length !== input.length || data.some(({ embedding }) => embedding.length !== remote.dims)) {
127
+ throw new CliError("invalid_response", `${remote.provider} answered with vectors of another number or size than ${input.length} \xD7 ${remote.dims}`);
128
+ }
129
+ return data.map(({ embedding }) => unit(Float32Array.from(embedding)));
130
+ }
131
+ const code = await errorCode(response);
132
+ if (response.status === 401 || response.status === 403) {
133
+ throw new CliError("authentication_error", `${remote.provider} refused the key (HTTP ${response.status}${code}) \u2014 set it again with \`models keys set\``);
134
+ }
135
+ const again = response.status === 429 || response.status >= 500;
136
+ if (!again || attempt >= tries) {
137
+ throw new CliError(response.status === 429 ? "rate_limited" : "provider_error", `${remote.provider} answered HTTP ${response.status}${code}`);
138
+ }
139
+ const wait = Number(response.headers.get("retry-after"));
140
+ await setTimeout(Number.isFinite(wait) && wait > 0 ? wait * 1e3 : 1e3 * 2 ** attempt);
141
+ }
142
+ }, "request");
143
+ return {
144
+ model: { id: remote.model, dims: remote.dims },
145
+ embed: /* @__PURE__ */ __name(async (texts) => {
146
+ const parts = [];
147
+ for (let start = 0; start < texts.length; start += PER_REQUEST)
148
+ parts.push(texts.slice(start, start + PER_REQUEST));
149
+ const results = new Array(parts.length);
150
+ let next = 0;
151
+ await Promise.all(Array.from({ length: Math.min(concurrency, parts.length) }, async () => {
152
+ for (let index = next++; index < parts.length; index = next++)
153
+ results[index] = await request(parts[index]);
154
+ }));
155
+ return results.flat();
156
+ }, "embed"),
157
+ close: /* @__PURE__ */ __name(async () => {
158
+ }, "close")
159
+ };
160
+ }, "openRemote");
161
+ var errorCode = /* @__PURE__ */ __name(async (response) => {
162
+ try {
163
+ const body = await response.json();
164
+ const code = body.error?.code ?? body.error?.type;
165
+ return typeof code === "string" && /^[\w.-]{1,64}$/.test(code) ? `, ${code}` : "";
166
+ } catch {
167
+ return "";
168
+ }
169
+ }, "errorCode");
170
+
171
+ export {
172
+ readLocalOnly,
173
+ localOnly,
174
+ writeLocalOnly,
175
+ localOnlyRefusal,
176
+ refuseOffComputer,
177
+ refuseModelAddress,
178
+ OPENAI_URL,
179
+ OPENAI_MODELS,
180
+ DEFAULT_OPENAI_MODEL,
181
+ isLocal,
182
+ remoteModel,
183
+ remoteKey,
184
+ openRemote
185
+ };