@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,194 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ listen
5
+ } from "./chunk-P33NDCDI.js";
6
+ import {
7
+ ownerLogin
8
+ } from "./chunk-HGL63O5V.js";
9
+ import {
10
+ WebStandardStreamableHTTPServerTransport,
11
+ createMcpHandler,
12
+ getOAuthProtectedResourceMetadataUrl,
13
+ hostHeaderValidationResponse,
14
+ isLegacyRequest,
15
+ oauthMetadataResponse,
16
+ requireBearerAuth
17
+ } from "./chunk-5D4AEUVA.js";
18
+ import {
19
+ activityRecorder,
20
+ calledTools,
21
+ httpActivityFile,
22
+ httpLock
23
+ } from "./chunk-OTD2ZRXD.js";
24
+ import {
25
+ CliError
26
+ } from "./chunk-IRV2PCQ2.js";
27
+ import {
28
+ __name
29
+ } from "./chunk-ZVVMGPBJ.js";
30
+
31
+ // 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/serve.js
32
+ import { randomUUID } from "node:crypto";
33
+ var MCP_PATH = "/mcp";
34
+ var AS_METADATA = "/.well-known/oauth-authorization-server";
35
+ var LOCAL = ["localhost", "127.0.0.1"];
36
+ var MAX_SESSIONS = 20;
37
+ var MAX_LOGIN_BODY = 64 * 1024;
38
+ var SESSION_IDLE_MS = 60 * 60 * 1e3;
39
+ var sessionMissing = /* @__PURE__ */ __name(() => new Response(JSON.stringify({ jsonrpc: "2.0", error: { code: -32001, message: "Session not found" }, id: null }), {
40
+ status: 404,
41
+ headers: { "content-type": "application/json" }
42
+ }), "sessionMissing");
43
+ var legacySessions = /* @__PURE__ */ __name((build, now) => {
44
+ const sessions = /* @__PURE__ */ new Map();
45
+ const drop = /* @__PURE__ */ __name(async (id) => {
46
+ const one = sessions.get(id);
47
+ sessions.delete(id);
48
+ await one?.close();
49
+ }, "drop");
50
+ const handle = /* @__PURE__ */ __name(async (request, auth) => {
51
+ for (const [id2, one] of sessions)
52
+ if (now() - one.seen > SESSION_IDLE_MS)
53
+ await drop(id2);
54
+ const id = request.headers.get("mcp-session-id");
55
+ if (id) {
56
+ const known = sessions.get(id);
57
+ if (!known || known.clientId !== auth.clientId)
58
+ return sessionMissing();
59
+ known.seen = now();
60
+ return known.transport.handleRequest(request, { authInfo: auth });
61
+ }
62
+ const server = build();
63
+ const transport = new WebStandardStreamableHTTPServerTransport({
64
+ sessionIdGenerator: /* @__PURE__ */ __name(() => randomUUID(), "sessionIdGenerator"),
65
+ onsessionclosed: /* @__PURE__ */ __name((closed) => void sessions.delete(closed), "onsessionclosed")
66
+ });
67
+ await server.connect(transport);
68
+ const response = await transport.handleRequest(request, { authInfo: auth });
69
+ if (!transport.sessionId) {
70
+ await server.close();
71
+ return response;
72
+ }
73
+ sessions.set(transport.sessionId, { transport, close: /* @__PURE__ */ __name(() => server.close(), "close"), clientId: auth.clientId, seen: now() });
74
+ while (sessions.size > MAX_SESSIONS)
75
+ await drop(sessions.keys().next().value);
76
+ return response;
77
+ }, "handle");
78
+ return {
79
+ handle,
80
+ close: /* @__PURE__ */ __name(async () => {
81
+ for (const id of [...sessions.keys()])
82
+ await drop(id);
83
+ }, "close")
84
+ };
85
+ }, "legacySessions");
86
+ var metadataRequest = /* @__PURE__ */ __name((request, path, base) => {
87
+ const url = new URL(request.url);
88
+ const inserted = base && path === `${AS_METADATA}${base}`;
89
+ if (!inserted && url.pathname === path)
90
+ return request;
91
+ url.pathname = inserted ? AS_METADATA : path;
92
+ return new Request(url, { method: request.method, headers: request.headers });
93
+ }, "metadataRequest");
94
+ var toolsIn = /* @__PURE__ */ __name(async (request) => {
95
+ if (request.method !== "POST")
96
+ return [];
97
+ try {
98
+ return calledTools(await request.clone().json());
99
+ } catch {
100
+ return [];
101
+ }
102
+ }, "toolsIn");
103
+ var serveOverHttp = /* @__PURE__ */ __name(async (build, options) => {
104
+ const { publicUrl, port, tokenFile, appName, reaches, onCode, onError, now, lockFile, version } = options;
105
+ const lock = lockFile ? httpLock(lockFile, {
106
+ pid: process.pid,
107
+ startedAt: (/* @__PURE__ */ new Date()).toISOString(),
108
+ port,
109
+ publicUrl: publicUrl.href,
110
+ ...version ? { version } : {}
111
+ }) : void 0;
112
+ if (lock?.held)
113
+ throw new CliError("validation_error", `${appName} already serves MCP over HTTP for this profile on port ${lock.held.port} (PID ${lock.held.pid}, since ${lock.held.startedAt})`);
114
+ const base = publicUrl.pathname === "/" ? "" : publicUrl.pathname.replace(/\/+$/, "");
115
+ const issuer = new URL(`${publicUrl.origin}${base}`);
116
+ const resource = new URL(`${base}${MCP_PATH}`, publicUrl.origin);
117
+ const mcpPath = resource.pathname;
118
+ const publicPath = /* @__PURE__ */ __name((path) => base && path !== base && !path.startsWith(`${base}/`) && !path.startsWith("/.well-known/") ? `${base}${path}` : path, "publicPath");
119
+ const login = ownerLogin({
120
+ issuer,
121
+ resource,
122
+ file: tokenFile,
123
+ appName,
124
+ ...reaches ? { reaches } : {},
125
+ onCode: /* @__PURE__ */ __name((code, expires) => {
126
+ lock?.update({ loginCode: code, loginCodeExpiresAt: expires.toISOString() });
127
+ onCode(code, expires);
128
+ }, "onCode"),
129
+ ...now ? { now } : {}
130
+ });
131
+ const insecure = issuer.protocol === "http:" && LOCAL.includes(issuer.hostname);
132
+ const mcp = createMcpHandler(build, { legacy: "reject", ...onError ? { onerror: onError } : {} });
133
+ const legacy = legacySessions(build, now ?? Date.now);
134
+ const bearer = requireBearerAuth({
135
+ verifier: login.verifier,
136
+ resourceMetadataUrl: getOAuthProtectedResourceMetadataUrl(resource)
137
+ });
138
+ const activity = activityRecorder(httpActivityFile(tokenFile), now);
139
+ const allowedHosts = [.../* @__PURE__ */ new Set([publicUrl.hostname, ...LOCAL])];
140
+ const allowedOrigins = [publicUrl.origin];
141
+ const listening = await listen(async (request) => {
142
+ const refused = hostHeaderValidationResponse(request, allowedHosts);
143
+ if (refused)
144
+ return refused;
145
+ const path = publicPath(new URL(request.url).pathname);
146
+ const discovery = oauthMetadataResponse(metadataRequest(request, path, base), {
147
+ oauthMetadata: login.metadata,
148
+ resourceServerUrl: resource,
149
+ resourceName: appName,
150
+ ...insecure ? { dangerouslyAllowInsecureIssuerUrl: true } : {}
151
+ });
152
+ if (discovery)
153
+ return discovery;
154
+ if (Number(request.headers.get("content-length") ?? 0) > MAX_LOGIN_BODY && path !== mcpPath)
155
+ return new Response("Request too large", { status: 413 });
156
+ const origin = request.headers.get("origin");
157
+ if (origin && !allowedOrigins.includes(origin))
158
+ return new Response("Origin not allowed", { status: 403 });
159
+ const answered = await login.handle(request, path);
160
+ if (answered)
161
+ return answered;
162
+ if (path !== mcpPath)
163
+ return new Response("Not found", { status: 404 });
164
+ const auth = await bearer(request);
165
+ if (auth instanceof Response)
166
+ return auth;
167
+ activity.record(auth.clientId, await toolsIn(request));
168
+ return await isLegacyRequest(request) ? legacy.handle(request, auth) : mcp.fetch(request, { authInfo: auth });
169
+ }, { host: "127.0.0.1", port }).catch((error) => {
170
+ login.close();
171
+ lock?.release();
172
+ throw error;
173
+ });
174
+ lock?.update({ listeningAt: (/* @__PURE__ */ new Date()).toISOString() });
175
+ return {
176
+ url: listening.url,
177
+ close: /* @__PURE__ */ __name(async () => {
178
+ login.close();
179
+ activity.flush();
180
+ try {
181
+ await listening.close();
182
+ await legacy.close();
183
+ await mcp.close();
184
+ } finally {
185
+ lock?.release();
186
+ }
187
+ }, "close")
188
+ };
189
+ }, "serveOverHttp");
190
+
191
+ export {
192
+ MCP_PATH,
193
+ serveOverHttp
194
+ };
@@ -0,0 +1,58 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ CliError
5
+ } from "./chunk-IRV2PCQ2.js";
6
+ import {
7
+ importFrom
8
+ } from "./chunk-Y5E2WNWB.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/store/vector-extension.js
14
+ import { readFileSync } from "node:fs";
15
+ var musl = /* @__PURE__ */ __name(() => {
16
+ if (process.platform !== "linux")
17
+ return false;
18
+ try {
19
+ return readFileSync("/proc/self/maps", "utf8").includes("ld-musl");
20
+ } catch {
21
+ return false;
22
+ }
23
+ }, "musl");
24
+ var found;
25
+ var vectorExtension = /* @__PURE__ */ __name(() => {
26
+ found ??= locate();
27
+ return found;
28
+ }, "vectorExtension");
29
+ var locate = /* @__PURE__ */ __name(async () => {
30
+ const onMusl = musl();
31
+ const target = `${process.platform}-${process.arch}${onMusl ? "-musl" : ""}`;
32
+ let path;
33
+ try {
34
+ const { extensionFor } = await importFrom(new URL("store/vector-extension.js", import.meta.resolve("@wirecat/cli-core")).href, "@wirecat/cli-core-sqlite");
35
+ path = extensionFor({ musl: onMusl });
36
+ } catch {
37
+ path = void 0;
38
+ }
39
+ if (path === void 0) {
40
+ found = void 0;
41
+ throw new CliError("configuration_error", `the message store needs the sqlite-vec extension, and @wirecat/cli-core-sqlite has none for ${target} \u2014 reinstall the CLI so its dependencies install with it (an install that skips optional or native packages leaves it out)`, { reason: "store.vector-extension-missing", target });
42
+ }
43
+ return path;
44
+ }, "locate");
45
+ var loadVectorExtension = /* @__PURE__ */ __name((database, path) => {
46
+ try {
47
+ database.loadExtension(path);
48
+ } catch (error) {
49
+ throw new CliError("configuration_error", `the sqlite-vec extension did not load on ${process.platform}-${process.arch} \u2014 reinstall the CLI; on macOS under Bun, @wirecat/cli-core-sqlite's SQLite must be installed, since the system's cannot load extensions`, { reason: "store.vector-extension-failed", cause: error instanceof Error ? error.message : String(error) });
50
+ } finally {
51
+ database.enableLoadExtension?.(false);
52
+ }
53
+ }, "loadVectorExtension");
54
+
55
+ export {
56
+ vectorExtension,
57
+ loadVectorExtension
58
+ };