@wirecat/bitrix24-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 (245) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/LICENSE +204 -0
  3. package/README.md +17 -2
  4. package/dist/api-keys.d.ts +21 -0
  5. package/dist/api-keys.d.ts.map +1 -0
  6. package/dist/api-keys.js +58 -0
  7. package/dist/api-keys.js.map +1 -0
  8. package/dist/bin/b24.d.ts +3 -0
  9. package/dist/bin/b24.d.ts.map +1 -0
  10. package/dist/bin/b24.js +40 -0
  11. package/dist/bin/b24.js.map +1 -0
  12. package/dist/bitrix/errors.d.ts +22 -0
  13. package/dist/bitrix/errors.d.ts.map +1 -0
  14. package/dist/bitrix/errors.js +76 -0
  15. package/dist/bitrix/errors.js.map +1 -0
  16. package/dist/bitrix/methods.d.ts +13 -0
  17. package/dist/bitrix/methods.d.ts.map +1 -0
  18. package/dist/bitrix/methods.js +33 -0
  19. package/dist/bitrix/methods.js.map +1 -0
  20. package/dist/bitrix/transport.d.ts +50 -0
  21. package/dist/bitrix/transport.d.ts.map +1 -0
  22. package/dist/bitrix/transport.js +189 -0
  23. package/dist/bitrix/transport.js.map +1 -0
  24. package/dist/bitrix/webhook.d.ts +14 -0
  25. package/dist/bitrix/webhook.d.ts.map +1 -0
  26. package/dist/bitrix/webhook.js +29 -0
  27. package/dist/bitrix/webhook.js.map +1 -0
  28. package/dist/bundle/all-profiles-QJ444GSX.js +24 -0
  29. package/dist/bundle/anthropic-RHRAVHC2.js +70 -0
  30. package/dist/bundle/app-server-QIT6S7AZ.js +224 -0
  31. package/dist/bundle/b24.js +32 -0
  32. package/dist/bundle/bun-H6RSODZ3.js +169 -0
  33. package/dist/bundle/bun-sqlite-BO4LTQHX.js +69 -0
  34. package/dist/bundle/chunk-2KCZ7BKW.js +215 -0
  35. package/dist/bundle/chunk-2SNUMZ7S.js +1028 -0
  36. package/dist/bundle/chunk-45AKJVKV.js +24 -0
  37. package/dist/bundle/chunk-4PDYYS5K.js +2 -0
  38. package/dist/bundle/chunk-5D4AEUVA.js +24783 -0
  39. package/dist/bundle/chunk-6WY72XVQ.js +216 -0
  40. package/dist/bundle/chunk-7GRZAKBB.js +639 -0
  41. package/dist/bundle/chunk-ADLS6FVG.js +24600 -0
  42. package/dist/bundle/chunk-BCF7P4FZ.js +558 -0
  43. package/dist/bundle/chunk-CNNEA2M4.js +54 -0
  44. package/dist/bundle/chunk-CXL33BFL.js +570 -0
  45. package/dist/bundle/chunk-D5S6QV6R.js +95 -0
  46. package/dist/bundle/chunk-DFDN6AUB.js +21 -0
  47. package/dist/bundle/chunk-DTXERR44.js +35 -0
  48. package/dist/bundle/chunk-EVYSBZ3I.js +153 -0
  49. package/dist/bundle/chunk-EXOOKUEA.js +82 -0
  50. package/dist/bundle/chunk-FLUEXJ4X.js +53 -0
  51. package/dist/bundle/chunk-FOTREPNS.js +366 -0
  52. package/dist/bundle/chunk-FZL7F5NR.js +2022 -0
  53. package/dist/bundle/chunk-GDFNH33E.js +1691 -0
  54. package/dist/bundle/chunk-H2ADPPSH.js +50910 -0
  55. package/dist/bundle/chunk-HAXNUIGQ.js +1245 -0
  56. package/dist/bundle/chunk-HGL63O5V.js +288 -0
  57. package/dist/bundle/chunk-INFYLWUA.js +929 -0
  58. package/dist/bundle/chunk-IRV2PCQ2.js +5213 -0
  59. package/dist/bundle/chunk-K3UIB6ZF.js +45 -0
  60. package/dist/bundle/chunk-LRGYKOCP.js +91 -0
  61. package/dist/bundle/chunk-LSPIOT6Z.js +459 -0
  62. package/dist/bundle/chunk-MBDK4YXG.js +34 -0
  63. package/dist/bundle/chunk-N6FLBXZS.js +73 -0
  64. package/dist/bundle/chunk-OTD2ZRXD.js +161 -0
  65. package/dist/bundle/chunk-P33NDCDI.js +78 -0
  66. package/dist/bundle/chunk-P364PLIK.js +257 -0
  67. package/dist/bundle/chunk-PH5FZX6E.js +193 -0
  68. package/dist/bundle/chunk-POC3V3AO.js +36616 -0
  69. package/dist/bundle/chunk-QC53QBNC.js +143 -0
  70. package/dist/bundle/chunk-QGMDQ2PM.js +122 -0
  71. package/dist/bundle/chunk-QIPTIUMJ.js +281 -0
  72. package/dist/bundle/chunk-QMPN6WKD.js +3512 -0
  73. package/dist/bundle/chunk-QQXH2OPB.js +594 -0
  74. package/dist/bundle/chunk-QSNROIJL.js +413 -0
  75. package/dist/bundle/chunk-RRJNNPR4.js +76 -0
  76. package/dist/bundle/chunk-SFRNX2TI.js +6848 -0
  77. package/dist/bundle/chunk-SGRYYE4X.js +266 -0
  78. package/dist/bundle/chunk-TE3FR6MI.js +884 -0
  79. package/dist/bundle/chunk-U5ACMCAQ.js +12049 -0
  80. package/dist/bundle/chunk-VEWWAGTD.js +2315 -0
  81. package/dist/bundle/chunk-VL6SPMZV.js +194 -0
  82. package/dist/bundle/chunk-WII44RXN.js +58 -0
  83. package/dist/bundle/chunk-WKRQ44EH.js +528 -0
  84. package/dist/bundle/chunk-WTPMJYMD.js +8308 -0
  85. package/dist/bundle/chunk-XD4FRDSL.js +565 -0
  86. package/dist/bundle/chunk-XJXONOB5.js +63 -0
  87. package/dist/bundle/chunk-XNHSPHUN.js +48 -0
  88. package/dist/bundle/chunk-XRFJWHY5.js +131 -0
  89. package/dist/bundle/chunk-Y5E2WNWB.js +35 -0
  90. package/dist/bundle/chunk-YYO7D2MO.js +783 -0
  91. package/dist/bundle/chunk-YZ5LHE5Q.js +31 -0
  92. package/dist/bundle/chunk-ZDQQCXFG.js +392 -0
  93. package/dist/bundle/chunk-ZEW4P6AH.js +158 -0
  94. package/dist/bundle/chunk-ZGZT5S6B.js +3480 -0
  95. package/dist/bundle/chunk-ZIAQPTUS.js +82 -0
  96. package/dist/bundle/chunk-ZVVMGPBJ.js +50 -0
  97. package/dist/bundle/command-contract-OKQOE6G4.js +30 -0
  98. package/dist/bundle/decode-5ZPLTYV6.js +160 -0
  99. package/dist/bundle/dist-6Y64DTOE.js +7577 -0
  100. package/dist/bundle/echarts-J6LAPIX7.js +42501 -0
  101. package/dist/bundle/embed-YG5LDHME.js +35 -0
  102. package/dist/bundle/embedder-7FNUA5OZ.js +108 -0
  103. package/dist/bundle/first-run-JPZNWIJN.js +23 -0
  104. package/dist/bundle/first-screen-VQM4MTS7.js +28 -0
  105. package/dist/bundle/instructions-AXWTQHMR.js +11 -0
  106. package/dist/bundle/mcp-7F46P6AM.js +165 -0
  107. package/dist/bundle/mcp-HUD6UH5X.js +160 -0
  108. package/dist/bundle/mcp-J5R5A65I.js +87 -0
  109. package/dist/bundle/node-CWKAIOEM.js +176 -0
  110. package/dist/bundle/node-P4E63KXA.js +2340 -0
  111. package/dist/bundle/node-TLZSIHIJ.js +21 -0
  112. package/dist/bundle/node-sqlite-LSEKVRDA.js +67 -0
  113. package/dist/bundle/oauth-THYNLRLD.js +17 -0
  114. package/dist/bundle/open-E47QYKFC.js +20 -0
  115. package/dist/bundle/openai-EWSGC3BC.js +227 -0
  116. package/dist/bundle/process-WKTEA3WE.js +91 -0
  117. package/dist/bundle/program-UYX5362I.js +20851 -0
  118. package/dist/bundle/prompt-CAQ7QR3U.js +12 -0
  119. package/dist/bundle/recognize-6KGHNZC3.js +23 -0
  120. package/dist/bundle/remote-3UO2WDC3.js +26 -0
  121. package/dist/bundle/rerank-2JVDPZBX.js +49 -0
  122. package/dist/bundle/serve-ES7AG5IK.js +19 -0
  123. package/dist/bundle/server-5LE5LNUQ.js +45 -0
  124. package/dist/bundle/server-BU4VBM6S.js +58 -0
  125. package/dist/bundle/state-7NH5G4XJ.js +33 -0
  126. package/dist/bundle/store-7O4JQD2Z.js +127 -0
  127. package/dist/bundle/store-maintenance-command-UDVGEY2D.js +47 -0
  128. package/dist/commands/api.d.ts +3 -0
  129. package/dist/commands/api.d.ts.map +1 -0
  130. package/dist/commands/api.js +131 -0
  131. package/dist/commands/api.js.map +1 -0
  132. package/dist/commands/crm-writes.d.ts +4 -0
  133. package/dist/commands/crm-writes.d.ts.map +1 -0
  134. package/dist/commands/crm-writes.js +182 -0
  135. package/dist/commands/crm-writes.js.map +1 -0
  136. package/dist/commands/crm.d.ts +3 -0
  137. package/dist/commands/crm.d.ts.map +1 -0
  138. package/dist/commands/crm.js +144 -0
  139. package/dist/commands/crm.js.map +1 -0
  140. package/dist/commands/doctor.d.ts +77 -0
  141. package/dist/commands/doctor.d.ts.map +1 -0
  142. package/dist/commands/doctor.js +74 -0
  143. package/dist/commands/doctor.js.map +1 -0
  144. package/dist/commands/mcp.d.ts +3 -0
  145. package/dist/commands/mcp.d.ts.map +1 -0
  146. package/dist/commands/mcp.js +97 -0
  147. package/dist/commands/mcp.js.map +1 -0
  148. package/dist/commands/session.d.ts +3 -0
  149. package/dist/commands/session.d.ts.map +1 -0
  150. package/dist/commands/session.js +101 -0
  151. package/dist/commands/session.js.map +1 -0
  152. package/dist/commands/write.d.ts +21 -0
  153. package/dist/commands/write.d.ts.map +1 -0
  154. package/dist/commands/write.js +47 -0
  155. package/dist/commands/write.js.map +1 -0
  156. package/dist/config.d.ts +9 -0
  157. package/dist/config.d.ts.map +1 -0
  158. package/dist/config.js +17 -0
  159. package/dist/config.js.map +1 -0
  160. package/dist/crm/conditions.d.ts +25 -0
  161. package/dist/crm/conditions.d.ts.map +1 -0
  162. package/dist/crm/conditions.js +78 -0
  163. package/dist/crm/conditions.js.map +1 -0
  164. package/dist/crm/deal.d.ts +27 -0
  165. package/dist/crm/deal.d.ts.map +1 -0
  166. package/dist/crm/deal.js +74 -0
  167. package/dist/crm/deal.js.map +1 -0
  168. package/dist/crm/items.d.ts +30 -0
  169. package/dist/crm/items.d.ts.map +1 -0
  170. package/dist/crm/items.js +76 -0
  171. package/dist/crm/items.js.map +1 -0
  172. package/dist/crm/lead.d.ts +36 -0
  173. package/dist/crm/lead.d.ts.map +1 -0
  174. package/dist/crm/lead.js +85 -0
  175. package/dist/crm/lead.js.map +1 -0
  176. package/dist/crm/organization.d.ts +32 -0
  177. package/dist/crm/organization.d.ts.map +1 -0
  178. package/dist/crm/organization.js +67 -0
  179. package/dist/crm/organization.js.map +1 -0
  180. package/dist/crm/person.d.ts +31 -0
  181. package/dist/crm/person.d.ts.map +1 -0
  182. package/dist/crm/person.js +67 -0
  183. package/dist/crm/person.js.map +1 -0
  184. package/dist/crm/pipeline.d.ts +17 -0
  185. package/dist/crm/pipeline.d.ts.map +1 -0
  186. package/dist/crm/pipeline.js +42 -0
  187. package/dist/crm/pipeline.js.map +1 -0
  188. package/dist/crm/product.d.ts +43 -0
  189. package/dist/crm/product.d.ts.map +1 -0
  190. package/dist/crm/product.js +42 -0
  191. package/dist/crm/product.js.map +1 -0
  192. package/dist/crm/stage.d.ts +20 -0
  193. package/dist/crm/stage.d.ts.map +1 -0
  194. package/dist/crm/stage.js +65 -0
  195. package/dist/crm/stage.js.map +1 -0
  196. package/dist/crm/user.d.ts +39 -0
  197. package/dist/crm/user.d.ts.map +1 -0
  198. package/dist/crm/user.js +54 -0
  199. package/dist/crm/user.js.map +1 -0
  200. package/dist/crm/values.d.ts +33 -0
  201. package/dist/crm/values.d.ts.map +1 -0
  202. package/dist/crm/values.js +54 -0
  203. package/dist/crm/values.js.map +1 -0
  204. package/dist/crm/walk.d.ts +19 -0
  205. package/dist/crm/walk.d.ts.map +1 -0
  206. package/dist/crm/walk.js +22 -0
  207. package/dist/crm/walk.js.map +1 -0
  208. package/dist/identity.d.ts +5 -0
  209. package/dist/identity.d.ts.map +1 -0
  210. package/dist/identity.js +18 -0
  211. package/dist/identity.js.map +1 -0
  212. package/dist/index.d.ts +3 -0
  213. package/dist/index.d.ts.map +1 -0
  214. package/dist/index.js +3 -0
  215. package/dist/index.js.map +1 -0
  216. package/dist/mcp.d.ts +29 -0
  217. package/dist/mcp.d.ts.map +1 -0
  218. package/dist/mcp.js +99 -0
  219. package/dist/mcp.js.map +1 -0
  220. package/dist/portal.d.ts +47 -0
  221. package/dist/portal.d.ts.map +1 -0
  222. package/dist/portal.js +52 -0
  223. package/dist/portal.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 +45 -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 +28 -0
  231. package/dist/reasons.js.map +1 -0
  232. package/dist/token.d.ts +12 -0
  233. package/dist/token.d.ts.map +1 -0
  234. package/dist/token.js +41 -0
  235. package/dist/token.js.map +1 -0
  236. package/dist/version.d.ts +2 -0
  237. package/dist/version.d.ts.map +1 -0
  238. package/dist/version.js +2 -0
  239. package/dist/version.js.map +1 -0
  240. package/dist/whoami.d.ts +8 -0
  241. package/dist/whoami.d.ts.map +1 -0
  242. package/dist/whoami.js +9 -0
  243. package/dist/whoami.js.map +1 -0
  244. package/package.json +83 -4
  245. package/skills/bitrix24-cli/SKILL.md +41 -0
@@ -0,0 +1,73 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ alive
5
+ } from "./chunk-XJXONOB5.js";
6
+ import {
7
+ resolvePaths,
8
+ writeSecurely
9
+ } from "./chunk-IRV2PCQ2.js";
10
+ import {
11
+ __name
12
+ } from "./chunk-ZVVMGPBJ.js";
13
+
14
+ // node_modules/.pnpm/@wirecat+cli-core@0.586.0_@wirecat+cli-base@0.79.0_commander@15.0.0_esbuild@0.28.2_type_bdecddef0ae5a50ae90cab8b9e35c13b/node_modules/@wirecat/cli-core/dist/background/lock.js
15
+ import { existsSync, linkSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
16
+ import { dirname, join } from "node:path";
17
+ var lockPath = /* @__PURE__ */ __name((app, profile, env) => join(resolvePaths({ appName: app.appName, prefix: app.envPrefix, env }).state, "serve", `${profile}.lock`), "lockPath");
18
+ var readLock = /* @__PURE__ */ __name((path) => {
19
+ try {
20
+ const lock = JSON.parse(readFileSync(path, "utf8"));
21
+ return typeof lock.pid === "number" && typeof lock.startedAt === "string" ? lock : void 0;
22
+ } catch {
23
+ return void 0;
24
+ }
25
+ }, "readLock");
26
+ var holdLock = /* @__PURE__ */ __name((path, lock) => writeSecurely(path, `${JSON.stringify(lock)}
27
+ `, 384), "holdLock");
28
+ var takeLock = /* @__PURE__ */ __name((path, lock) => {
29
+ mkdirSync(dirname(path), { recursive: true, mode: 448 });
30
+ const draft = `${path}.${lock.pid}.tmp`;
31
+ writeFileSync(draft, `${JSON.stringify(lock)}
32
+ `, { mode: 384 });
33
+ try {
34
+ for (let attempt = 0; attempt < 5; attempt++) {
35
+ try {
36
+ linkSync(draft, path);
37
+ return void 0;
38
+ } catch (error) {
39
+ if (error.code !== "EEXIST")
40
+ throw error;
41
+ }
42
+ const held = readLock(path);
43
+ if (held && held.pid !== lock.pid && alive(held.pid))
44
+ return held;
45
+ rmSync(path, { force: true });
46
+ }
47
+ throw new Error(`could not take the lock ${path}: it keeps changing`);
48
+ } finally {
49
+ rmSync(draft, { force: true });
50
+ }
51
+ }, "takeLock");
52
+ var releaseLock = /* @__PURE__ */ __name((path, pid = process.pid) => {
53
+ if (readLock(path)?.pid === pid)
54
+ rmSync(path, { force: true });
55
+ }, "releaseLock");
56
+ var servingProfiles = /* @__PURE__ */ __name((app, env) => {
57
+ const dir = dirname(lockPath(app, "default", env));
58
+ if (!existsSync(dir))
59
+ return [];
60
+ return readdirSync(dir).filter((name) => name.endsWith(".lock")).map((name) => name.slice(0, -".lock".length)).filter((profile) => {
61
+ const lock = readLock(lockPath(app, profile, env));
62
+ return lock !== void 0 && alive(lock.pid);
63
+ });
64
+ }, "servingProfiles");
65
+
66
+ export {
67
+ lockPath,
68
+ readLock,
69
+ holdLock,
70
+ takeLock,
71
+ releaseLock,
72
+ servingProfiles
73
+ };
@@ -0,0 +1,161 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ holdLock,
5
+ readLock,
6
+ releaseLock,
7
+ takeLock
8
+ } from "./chunk-N6FLBXZS.js";
9
+ import {
10
+ __name
11
+ } from "./chunk-ZVVMGPBJ.js";
12
+
13
+ // node_modules/.pnpm/@wirecat+cli-core@0.586.0_@wirecat+cli-base@0.79.0_commander@15.0.0_esbuild@0.28.2_type_bdecddef0ae5a50ae90cab8b9e35c13b/node_modules/@wirecat/cli-core/dist/mcp/http/state.js
14
+ import { existsSync as existsSync2, readFileSync as readFileSync2 } from "node:fs";
15
+
16
+ // node_modules/.pnpm/@wirecat+cli-core@0.586.0_@wirecat+cli-base@0.79.0_commander@15.0.0_esbuild@0.28.2_type_bdecddef0ae5a50ae90cab8b9e35c13b/node_modules/@wirecat/cli-core/dist/mcp/http/activity.js
17
+ import { randomBytes } from "node:crypto";
18
+ import { chmodSync, existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
19
+ import { dirname } from "node:path";
20
+ var WRITE_EVERY_MS = 2e3;
21
+ var TOOL_NAME = /^[A-Za-z0-9_.-]{1,64}$/;
22
+ var httpActivityFile = /* @__PURE__ */ __name((tokenFile) => `${tokenFile.replace(/\.json$/, "")}.activity.json`, "httpActivityFile");
23
+ var localDay = /* @__PURE__ */ __name((ms) => {
24
+ const d = new Date(ms);
25
+ return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`;
26
+ }, "localDay");
27
+ var readActivity = /* @__PURE__ */ __name((path) => {
28
+ if (!existsSync(path))
29
+ return {};
30
+ try {
31
+ const parsed = JSON.parse(readFileSync(path, "utf8"));
32
+ return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {};
33
+ } catch {
34
+ return {};
35
+ }
36
+ }, "readActivity");
37
+ var calledTools = /* @__PURE__ */ __name((body) => (Array.isArray(body) ? body : [body]).flatMap((message) => {
38
+ if (!message || typeof message !== "object")
39
+ return [];
40
+ const { method, params } = message;
41
+ const name = params?.name;
42
+ return method === "tools/call" && typeof name === "string" && TOOL_NAME.test(name) ? [name] : [];
43
+ }), "calledTools");
44
+ var activityRecorder = /* @__PURE__ */ __name((path, now = Date.now) => {
45
+ const activity = readActivity(path);
46
+ let timer;
47
+ const write = /* @__PURE__ */ __name(() => {
48
+ timer = void 0;
49
+ try {
50
+ mkdirSync(dirname(path), { recursive: true, mode: 448 });
51
+ const temporary = `${path}.${randomBytes(8).toString("hex")}.tmp`;
52
+ writeFileSync(temporary, JSON.stringify(activity), { mode: 384, flag: "wx" });
53
+ chmodSync(temporary, 384);
54
+ renameSync(temporary, path);
55
+ } catch {
56
+ }
57
+ }, "write");
58
+ return {
59
+ record: /* @__PURE__ */ __name((clientId, tools) => {
60
+ const at = now();
61
+ const iso = new Date(at).toISOString();
62
+ const day = localDay(at);
63
+ const before = activity[clientId];
64
+ const counted = before?.day === day ? before.toolCalls : 0;
65
+ const last = tools.at(-1);
66
+ activity[clientId] = {
67
+ lastRequestAt: iso,
68
+ day,
69
+ toolCalls: counted + tools.length,
70
+ ...last ? { lastTool: last, lastToolAt: iso } : before?.lastTool ? { lastTool: before.lastTool, ...before.lastToolAt ? { lastToolAt: before.lastToolAt } : {} } : {}
71
+ };
72
+ if (last) {
73
+ clearTimeout(timer);
74
+ write();
75
+ } else if (!timer) {
76
+ timer = setTimeout(write, WRITE_EVERY_MS);
77
+ timer.unref();
78
+ }
79
+ }, "record"),
80
+ flush: /* @__PURE__ */ __name(() => {
81
+ if (!timer)
82
+ return;
83
+ clearTimeout(timer);
84
+ write();
85
+ }, "flush")
86
+ };
87
+ }, "activityRecorder");
88
+
89
+ // node_modules/.pnpm/@wirecat+cli-core@0.586.0_@wirecat+cli-base@0.79.0_commander@15.0.0_esbuild@0.28.2_type_bdecddef0ae5a50ae90cab8b9e35c13b/node_modules/@wirecat/cli-core/dist/mcp/http/state.js
90
+ var ACCESS_SECONDS = 60 * 60;
91
+ var REFRESH_SECONDS = 30 * 24 * 60 * 60;
92
+ var readStored = /* @__PURE__ */ __name((path) => existsSync2(path) ? JSON.parse(readFileSync2(path, "utf8")) : { clients: [], tokens: [] }, "readStored");
93
+ var mcpHttpMarker = /* @__PURE__ */ __name((envPrefix) => `${envPrefix}_MCP_HTTP`, "mcpHttpMarker");
94
+ var httpLogFile = /* @__PURE__ */ __name((tokenFile) => `${tokenFile.replace(/\.json$/, "")}.log`, "httpLogFile");
95
+ var httpLockFile = /* @__PURE__ */ __name((tokenFile) => `${tokenFile.replace(/\.json$/, "")}.lock`, "httpLockFile");
96
+ var httpLaunchFile = /* @__PURE__ */ __name((lockFile) => `${lockFile.replace(/\.lock$/, "")}.launch.json`, "httpLaunchFile");
97
+ var readHttpLaunch = /* @__PURE__ */ __name((path) => {
98
+ try {
99
+ const launch = JSON.parse(readFileSync2(path, "utf8"));
100
+ return typeof launch.invocation === "string" && Array.isArray(launch.argv) && launch.argv.every((word) => typeof word === "string") && typeof launch.env === "object" && launch.env !== null ? launch : void 0;
101
+ } catch {
102
+ return void 0;
103
+ }
104
+ }, "readHttpLaunch");
105
+ var readHttpLock = /* @__PURE__ */ __name((path) => {
106
+ const lock = readLock(path);
107
+ return lock && typeof lock.port === "number" && typeof lock.publicUrl === "string" ? lock : void 0;
108
+ }, "readHttpLock");
109
+ var httpLock = /* @__PURE__ */ __name((path, first) => {
110
+ let current = first;
111
+ const held = takeLock(path, current);
112
+ return {
113
+ held,
114
+ update: /* @__PURE__ */ __name((change) => {
115
+ current = { ...current, ...change };
116
+ holdLock(path, current);
117
+ }, "update"),
118
+ release: /* @__PURE__ */ __name(() => releaseLock(path), "release")
119
+ };
120
+ }, "httpLock");
121
+ var signedInClients = /* @__PURE__ */ __name((tokenFile, now = Date.now()) => {
122
+ const seconds = Math.floor(now / 1e3);
123
+ const { clients, tokens } = readStored(tokenFile);
124
+ const activity = readActivity(httpActivityFile(tokenFile));
125
+ const today = localDay(now);
126
+ const last = /* @__PURE__ */ new Map();
127
+ for (const token of tokens) {
128
+ if (token.expiresAt <= seconds)
129
+ continue;
130
+ const issued = token.expiresAt - (token.kind === "access" ? ACCESS_SECONDS : REFRESH_SECONDS);
131
+ last.set(token.clientId, Math.max(last.get(token.clientId) ?? 0, issued));
132
+ }
133
+ return clients.filter((client) => last.has(client.id)).map((client) => {
134
+ const did = activity[client.id];
135
+ return {
136
+ claimedName: client.name ?? null,
137
+ lastLoginAt: new Date((last.get(client.id) ?? 0) * 1e3).toISOString(),
138
+ lastRequestAt: did?.lastRequestAt ?? null,
139
+ lastTool: did?.lastTool ?? null,
140
+ lastToolAt: did?.lastToolAt ?? null,
141
+ toolCallsToday: did?.day === today ? did.toolCalls : 0
142
+ };
143
+ }).sort((a, b) => b.lastLoginAt.localeCompare(a.lastLoginAt));
144
+ }, "signedInClients");
145
+
146
+ export {
147
+ httpActivityFile,
148
+ calledTools,
149
+ activityRecorder,
150
+ ACCESS_SECONDS,
151
+ REFRESH_SECONDS,
152
+ readStored,
153
+ mcpHttpMarker,
154
+ httpLogFile,
155
+ httpLockFile,
156
+ httpLaunchFile,
157
+ readHttpLaunch,
158
+ readHttpLock,
159
+ httpLock,
160
+ signedInClients
161
+ };
@@ -0,0 +1,78 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ __name
5
+ } from "./chunk-ZVVMGPBJ.js";
6
+
7
+ // node_modules/.pnpm/@wirecat+cli-core@0.586.0_@wirecat+cli-base@0.79.0_commander@15.0.0_esbuild@0.28.2_type_bdecddef0ae5a50ae90cab8b9e35c13b/node_modules/@wirecat/cli-core/dist/http/listen.js
8
+ import { createServer } from "node:http";
9
+ import { Readable } from "node:stream";
10
+ var MAX_BODY = 4 * 1024 * 1024;
11
+ var TooLarge = class extends Error {
12
+ static {
13
+ __name(this, "TooLarge");
14
+ }
15
+ };
16
+ var readBody = /* @__PURE__ */ __name((incoming, limit) => new Promise((resolve, reject) => {
17
+ if (Number(incoming.headers["content-length"] ?? 0) > limit)
18
+ return reject(new TooLarge());
19
+ const chunks = [];
20
+ let size = 0;
21
+ incoming.on("data", (chunk) => {
22
+ size += chunk.length;
23
+ if (size > limit) {
24
+ incoming.destroy();
25
+ reject(new TooLarge());
26
+ } else
27
+ chunks.push(chunk);
28
+ });
29
+ incoming.once("end", () => resolve(Buffer.concat(chunks)));
30
+ incoming.once("error", reject);
31
+ }), "readBody");
32
+ var toRequest = /* @__PURE__ */ __name(async (incoming, origin, maxBody) => {
33
+ const headers = new Headers();
34
+ for (const [name, value] of Object.entries(incoming.headers)) {
35
+ if (Array.isArray(value))
36
+ for (const one of value)
37
+ headers.append(name, one);
38
+ else if (value !== void 0)
39
+ headers.set(name, value);
40
+ }
41
+ const method = incoming.method ?? "GET";
42
+ const body = method === "GET" || method === "HEAD" ? void 0 : await readBody(incoming, maxBody);
43
+ if (body)
44
+ headers.set("content-length", String(body.length));
45
+ return new Request(new URL(incoming.url ?? "/", origin), { method, headers, ...body ? { body } : {} });
46
+ }, "toRequest");
47
+ var send = /* @__PURE__ */ __name(async (response, outgoing) => {
48
+ outgoing.writeHead(response.status, Object.fromEntries(response.headers));
49
+ if (!response.body)
50
+ return void outgoing.end();
51
+ const body = Readable.fromWeb(response.body);
52
+ outgoing.once("close", () => body.destroy());
53
+ body.pipe(outgoing);
54
+ }, "send");
55
+ var listen = /* @__PURE__ */ __name((handle, { host, port, maxBody = MAX_BODY }) => new Promise((resolve, reject) => {
56
+ const server = createServer((incoming, outgoing) => {
57
+ toRequest(incoming, `http://${host}`, maxBody).then(handle).then((response) => send(response, outgoing)).catch((error) => {
58
+ if (!outgoing.headersSent)
59
+ outgoing.writeHead(error instanceof TooLarge ? 413 : 500, { connection: "close" });
60
+ outgoing.end();
61
+ });
62
+ });
63
+ server.once("error", reject);
64
+ server.listen(port, host, () => {
65
+ const { port: bound } = server.address();
66
+ resolve({
67
+ url: new URL(`http://${host}:${bound}`),
68
+ close: /* @__PURE__ */ __name(() => new Promise((done) => {
69
+ server.close(() => done());
70
+ server.closeAllConnections();
71
+ }), "close")
72
+ });
73
+ });
74
+ }), "listen");
75
+
76
+ export {
77
+ listen
78
+ };
@@ -0,0 +1,257 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ CliError,
5
+ array,
6
+ boolean,
7
+ integer,
8
+ isoTime,
9
+ isoTimestamp,
10
+ minLength,
11
+ minValue,
12
+ nullable,
13
+ number,
14
+ optional,
15
+ picklist,
16
+ pipe,
17
+ record,
18
+ reference,
19
+ strictObject,
20
+ string,
21
+ unknown
22
+ } from "./chunk-IRV2PCQ2.js";
23
+ import {
24
+ __name
25
+ } from "./chunk-ZVVMGPBJ.js";
26
+
27
+ // node_modules/.pnpm/@wirecat+cli-core@0.586.0_@wirecat+cli-base@0.79.0_commander@15.0.0_esbuild@0.28.2_type_bdecddef0ae5a50ae90cab8b9e35c13b/node_modules/@wirecat/cli-core/dist/tasks/model.js
28
+ var TASK_KINDS = ["question", "request", "mention", "promise"];
29
+ var TASK_STATES = ["open", "todo", "in_progress", "done", "dismissed"];
30
+ var CLOSED_STATES = ["done", "dismissed"];
31
+ var TASK_ORIGINS = ["rule", "agent", "owner"];
32
+ var TASK_VERDICTS = ["useful", "not_useful"];
33
+ var isClosedState = /* @__PURE__ */ __name((state) => CLOSED_STATES.includes(state), "isClosedState");
34
+ function closeTask(task, state, by, at, reason) {
35
+ if (isClosedState(task.state))
36
+ throw new CliError("validation_error", `task ${task.id} is already ${task.state}`, { reason: "task.closed" });
37
+ const { claimedBy: _by, claimedUntil: _until, ...unclaimed } = task;
38
+ return { ...unclaimed, state, closedAt: at, closedBy: by, ...reason === void 0 ? {} : { reason } };
39
+ }
40
+ __name(closeTask, "closeTask");
41
+
42
+ // node_modules/.pnpm/@wirecat+cli-core@0.586.0_@wirecat+cli-base@0.79.0_commander@15.0.0_esbuild@0.28.2_type_bdecddef0ae5a50ae90cab8b9e35c13b/node_modules/@wirecat/cli-core/dist/tasks/store.js
43
+ function matches(task, filter) {
44
+ return (filter.account === void 0 || task.account === filter.account) && (filter.state === void 0 || task.state === filter.state) && (filter.group === void 0 || task.group === filter.group) && (filter.kind === void 0 || task.kind === filter.kind) && (filter.createdBefore === void 0 || task.createdAt < filter.createdBefore);
45
+ }
46
+ __name(matches, "matches");
47
+
48
+ // node_modules/.pnpm/@wirecat+cli-core@0.586.0_@wirecat+cli-base@0.79.0_commander@15.0.0_esbuild@0.28.2_type_bdecddef0ae5a50ae90cab8b9e35c13b/node_modules/@wirecat/cli-core/dist/tasks/priority.js
49
+ var PRIORITY_LABELS = ["low", "medium", "high", "critical"];
50
+ var MIDDLE = { low: 0.125, medium: 0.375, high: 0.625, critical: 0.875 };
51
+ var LEGACY_PRIORITY_SCORES = [0.875, 0.625, 0.375, 0.1875, 0.0625];
52
+ var priorityLabel = /* @__PURE__ */ __name((score) => score === null ? null : PRIORITY_LABELS[Math.min(3, Math.max(0, Math.floor(score * 4)))], "priorityLabel");
53
+ var priorityBand = /* @__PURE__ */ __name((label) => {
54
+ const at = PRIORITY_LABELS.indexOf(label);
55
+ return { from: at / 4, to: (at + 1) / 4 };
56
+ }, "priorityBand");
57
+ var legacyPriority = /* @__PURE__ */ __name((score) => score === null ? null : score < 0.125 ? 4 : 3 - PRIORITY_LABELS.indexOf(priorityLabel(score)), "legacyPriority");
58
+ var checkedScore = /* @__PURE__ */ __name((score) => {
59
+ if (!Number.isFinite(score) || score < 0 || score > 1)
60
+ throw new CliError("validation_error", "a priority score is 0 to 1");
61
+ return score;
62
+ }, "checkedScore");
63
+ var priorityOf = /* @__PURE__ */ __name((value) => {
64
+ const word = value.trim().toLowerCase();
65
+ if (word === "none")
66
+ return null;
67
+ if (PRIORITY_LABELS.includes(word))
68
+ return MIDDLE[word];
69
+ if (/^[0-4]$/.test(word))
70
+ return LEGACY_PRIORITY_SCORES[Number(word)];
71
+ if (/^(0?\.\d+|[01]\.\d*)$/.test(word) && Number(word) <= 1)
72
+ return Number(word);
73
+ throw new CliError("validation_error", `a priority is ${PRIORITY_LABELS.join(", ")}, none, or a score from 0.0 to 1.0 with its decimal point; 0 (urgent) \u2026 4 (low) still work as critical, high, medium, low, low`);
74
+ }, "priorityOf");
75
+ var priorityOption = /* @__PURE__ */ __name((value) => priorityOf(value) ?? "none", "priorityOption");
76
+
77
+ // node_modules/.pnpm/@wirecat+cli-core@0.586.0_@wirecat+cli-base@0.79.0_commander@15.0.0_esbuild@0.28.2_type_bdecddef0ae5a50ae90cab8b9e35c13b/node_modules/@wirecat/cli-core/dist/tasks/service.js
78
+ function createTaskService({ store, now = /* @__PURE__ */ __name(() => /* @__PURE__ */ new Date(), "now"), newId = /* @__PURE__ */ __name(() => crypto.randomUUID(), "newId") }) {
79
+ async function find(id2) {
80
+ const task = await store.get(id2);
81
+ if (!task)
82
+ throw new CliError("not_found", `no task ${id2}`);
83
+ return task;
84
+ }
85
+ __name(find, "find");
86
+ return {
87
+ /**
88
+ * A rule never makes a second task from a source it has seen, whatever that task's state, so a
89
+ * dismissed one stays dismissed — nor from a message attached or merged into a task. A person or an agent may
90
+ * add a task of another kind to it. A task a rule opens goes through the host's duplicate check.
91
+ */
92
+ async add(input) {
93
+ const rule = input.origin === "rule";
94
+ const existing = await store.findBySource(input.account, input.source, rule ? { linked: true } : void 0);
95
+ const same = rule ? existing[0] : existing.find((task2) => task2.kind === input.kind);
96
+ if (same)
97
+ return { task: same, created: false };
98
+ const task = { ...input, id: newId(), state: "open", createdAt: now() };
99
+ await store.insert(task);
100
+ if (!rule || !store.reviewDuplicates)
101
+ return { task, created: true };
102
+ return { task, created: true, review: await store.reviewDuplicates(task.id) };
103
+ },
104
+ async close(id2, { as, by, reason }) {
105
+ const task = closeTask(await find(id2), as, by, now(), reason);
106
+ await store.update(task);
107
+ return task;
108
+ },
109
+ list: /* @__PURE__ */ __name((filter = {}) => store.list(filter), "list"),
110
+ async stats(filter = {}) {
111
+ const byGroup = /* @__PURE__ */ new Map();
112
+ for (const task of await store.list(filter))
113
+ byGroup.set(task.group, [...byGroup.get(task.group) ?? [], task]);
114
+ return [...byGroup].map(([group, tasks]) => {
115
+ const open = tasks.filter((task) => !isClosedState(task.state));
116
+ const closeMs = tasks.flatMap((task) => task.closedAt ? [task.closedAt.getTime() - task.createdAt.getTime()] : []);
117
+ const oldestOpenAt = open.map((task) => task.createdAt).sort((a, b) => a.getTime() - b.getTime())[0];
118
+ return {
119
+ group,
120
+ open: open.length,
121
+ ...oldestOpenAt ? { oldestOpenAt } : {},
122
+ ...closeMs.length > 0 ? { medianCloseMs: median(closeMs) } : {}
123
+ };
124
+ });
125
+ }
126
+ };
127
+ }
128
+ __name(createTaskService, "createTaskService");
129
+ function median(values) {
130
+ const sorted = [...values].sort((a, b) => a - b);
131
+ const middle = Math.floor(sorted.length / 2);
132
+ const upper = sorted[middle] ?? 0;
133
+ return sorted.length % 2 === 1 ? upper : ((sorted[middle - 1] ?? 0) + upper) / 2;
134
+ }
135
+ __name(median, "median");
136
+
137
+ // node_modules/.pnpm/@wirecat+cli-core@0.586.0_@wirecat+cli-base@0.79.0_commander@15.0.0_esbuild@0.28.2_type_bdecddef0ae5a50ae90cab8b9e35c13b/node_modules/@wirecat/cli-core/dist/domain/knowledge.js
138
+ var FACT_STATUSES = ["proposed", "accepted", "superseded", "reversed", "rejected"];
139
+ var MEMORY_KINDS = ["summary", "digest", "preference"];
140
+ var MEMORY_STATUSES = ["proposed", "confirmed", "stale", "superseded"];
141
+ var MEMORY_SCOPES = ["personal", "work"];
142
+ var WORK_TASK_TYPES = ["bug", "feature", "chore"];
143
+ var TASK_TYPES = [...WORK_TASK_TYPES, ...TASK_KINDS];
144
+
145
+ // node_modules/.pnpm/@wirecat+cli-core@0.586.0_@wirecat+cli-base@0.79.0_commander@15.0.0_esbuild@0.28.2_type_bdecddef0ae5a50ae90cab8b9e35c13b/node_modules/@wirecat/cli-core/dist/store/sqlite/link-kinds.js
146
+ var LINK_KINDS = [
147
+ "links-to",
148
+ "blocked-by",
149
+ "follow-up-of",
150
+ "about",
151
+ "member-of",
152
+ "labelled",
153
+ "answered-by",
154
+ "evidence",
155
+ "created-from",
156
+ "duplicate-of",
157
+ "related-to",
158
+ "assigned-to",
159
+ "attached"
160
+ ];
161
+ var LINK_ORIGINS = ["file", "owner", "suggested", "message"];
162
+ var LINK_SOURCES = [...LINK_ORIGINS, "calendar"];
163
+ var RELATION_KINDS = ["member-of", "related-to"];
164
+ var linkKind = /* @__PURE__ */ __name((kind) => `'${kind}'`, "linkKind");
165
+
166
+ // node_modules/.pnpm/@wirecat+cli-core@0.586.0_@wirecat+cli-base@0.79.0_commander@15.0.0_esbuild@0.28.2_type_bdecddef0ae5a50ae90cab8b9e35c13b/node_modules/@wirecat/cli-core/dist/entities/fields.js
167
+ var text = string();
168
+ var id = pipe(string(), minLength(1));
169
+ var time = isoTime;
170
+ var zonedTime = pipe(string(), isoTimestamp("an ISO 8601 time with a zone"));
171
+ var count = pipe(number(), integer(), minValue(0));
172
+ var untrusted = optional(array(text));
173
+ var providerMetadata = optional(record(string(), unknown()));
174
+ var evidenceSource = strictObject({
175
+ ref: nullable(reference),
176
+ kind: text,
177
+ title: nullable(text),
178
+ sender: nullable(text),
179
+ at: nullable(time),
180
+ excerpt: nullable(text),
181
+ tool: nullable(text),
182
+ missing: boolean()
183
+ });
184
+ var author = strictObject({
185
+ type: picklist(["person", "bot"]),
186
+ id,
187
+ name: nullable(text)
188
+ });
189
+
190
+ // node_modules/.pnpm/@wirecat+cli-core@0.586.0_@wirecat+cli-base@0.79.0_commander@15.0.0_esbuild@0.28.2_type_bdecddef0ae5a50ae90cab8b9e35c13b/node_modules/@wirecat/cli-core/dist/entities/knowledge-lists.js
191
+ var organization = strictObject({
192
+ id,
193
+ ref: reference,
194
+ kind: picklist(["company", "team", "family", "community"]),
195
+ name: text,
196
+ scope: picklist(["personal", "work"]),
197
+ created_at: time
198
+ });
199
+ var project = strictObject({
200
+ id,
201
+ ref: reference,
202
+ key: text,
203
+ name: text,
204
+ kind: picklist(["project", "inbox"]),
205
+ type: picklist(["work", "client", "personal", "oss", "other"]),
206
+ organization_id: nullable(id),
207
+ scope: picklist(["personal", "work"]),
208
+ created_at: time
209
+ });
210
+ var reminder = strictObject({
211
+ id,
212
+ task: text,
213
+ due_at: time,
214
+ timezone: text,
215
+ state: picklist(["pending", "leased", "delivered", "cancelled"]),
216
+ revision: number(),
217
+ receipt: nullable(text)
218
+ });
219
+
220
+ export {
221
+ text,
222
+ id,
223
+ time,
224
+ zonedTime,
225
+ count,
226
+ untrusted,
227
+ providerMetadata,
228
+ evidenceSource,
229
+ author,
230
+ TASK_KINDS,
231
+ TASK_STATES,
232
+ TASK_ORIGINS,
233
+ TASK_VERDICTS,
234
+ isClosedState,
235
+ PRIORITY_LABELS,
236
+ priorityLabel,
237
+ priorityBand,
238
+ legacyPriority,
239
+ checkedScore,
240
+ priorityOption,
241
+ createTaskService,
242
+ matches,
243
+ FACT_STATUSES,
244
+ MEMORY_KINDS,
245
+ MEMORY_STATUSES,
246
+ MEMORY_SCOPES,
247
+ WORK_TASK_TYPES,
248
+ TASK_TYPES,
249
+ organization,
250
+ project,
251
+ reminder,
252
+ LINK_KINDS,
253
+ LINK_ORIGINS,
254
+ LINK_SOURCES,
255
+ RELATION_KINDS,
256
+ linkKind
257
+ };