@wirecat/wordpress-cli 0.0.0-stage → 0.1.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 (256) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/LICENSE +204 -0
  3. package/README.md +248 -2
  4. package/contracts/wirecat.json +2535 -0
  5. package/dist/bin/wordpress.d.ts +3 -0
  6. package/dist/bin/wordpress.d.ts.map +1 -0
  7. package/dist/bin/wordpress.js +40 -0
  8. package/dist/bin/wordpress.js.map +1 -0
  9. package/dist/bundle/agent-LKBRYKNB.js +37 -0
  10. package/dist/bundle/all-profiles-OEV7VFQG.js +320 -0
  11. package/dist/bundle/anthropic-JKTZP2DW.js +91 -0
  12. package/dist/bundle/app-server-7LWLDDE2.js +249 -0
  13. package/dist/bundle/bun-2FLR4IV4.js +169 -0
  14. package/dist/bundle/bun-sqlite-GRSRX5P4.js +76 -0
  15. package/dist/bundle/chunk-2BI25SEE.js +259 -0
  16. package/dist/bundle/chunk-2UEGJ5AJ.js +52 -0
  17. package/dist/bundle/chunk-2XUV7HNE.js +58 -0
  18. package/dist/bundle/chunk-2Z7UOXFC.js +16 -0
  19. package/dist/bundle/chunk-3BM6KBWP.js +2788 -0
  20. package/dist/bundle/chunk-3BRAZVHR.js +1010 -0
  21. package/dist/bundle/chunk-3LMW7U7F.js +1233 -0
  22. package/dist/bundle/chunk-3LVTQFGB.js +2000 -0
  23. package/dist/bundle/chunk-3TKFFSFU.js +106 -0
  24. package/dist/bundle/chunk-3UX4VJWD.js +78 -0
  25. package/dist/bundle/chunk-4HEXAGKT.js +334 -0
  26. package/dist/bundle/chunk-4HP6KGBI.js +32 -0
  27. package/dist/bundle/chunk-4ZAQMDLD.js +1308 -0
  28. package/dist/bundle/chunk-4ZTB7LS3.js +87 -0
  29. package/dist/bundle/chunk-5XPHFV7H.js +2333 -0
  30. package/dist/bundle/chunk-5Z3P543G.js +80 -0
  31. package/dist/bundle/chunk-6UYDKCV6.js +794 -0
  32. package/dist/bundle/chunk-7GNB4LBX.js +50 -0
  33. package/dist/bundle/chunk-7HJFBOAT.js +161 -0
  34. package/dist/bundle/chunk-7JVKQ6NM.js +206 -0
  35. package/dist/bundle/chunk-7QH5BZUG.js +142 -0
  36. package/dist/bundle/chunk-A474OVIW.js +1392 -0
  37. package/dist/bundle/chunk-AENEMQL3.js +1068 -0
  38. package/dist/bundle/chunk-AL7I4DT4.js +65718 -0
  39. package/dist/bundle/chunk-ARGRGTPX.js +108 -0
  40. package/dist/bundle/chunk-AV2ZJ4WX.js +7 -0
  41. package/dist/bundle/chunk-BAXNAOOL.js +76 -0
  42. package/dist/bundle/chunk-BH63B66W.js +407 -0
  43. package/dist/bundle/chunk-CCOSG3F2.js +24616 -0
  44. package/dist/bundle/chunk-CFQQTDSA.js +46 -0
  45. package/dist/bundle/chunk-CGCUOT67.js +388 -0
  46. package/dist/bundle/chunk-CHPWBQUK.js +39 -0
  47. package/dist/bundle/chunk-D72URWJE.js +532 -0
  48. package/dist/bundle/chunk-DFDN6AUB.js +21 -0
  49. package/dist/bundle/chunk-DQSOYH6N.js +20 -0
  50. package/dist/bundle/chunk-ECYOTDJM.js +14 -0
  51. package/dist/bundle/chunk-EH6ZEJGT.js +932 -0
  52. package/dist/bundle/chunk-EHW45LLT.js +100 -0
  53. package/dist/bundle/chunk-F3AV5ZSL.js +338 -0
  54. package/dist/bundle/chunk-F4BX7TH2.js +15 -0
  55. package/dist/bundle/chunk-F5ZAN7OC.js +6848 -0
  56. package/dist/bundle/chunk-FMMYBVCH.js +38 -0
  57. package/dist/bundle/chunk-FNB4SWTY.js +66 -0
  58. package/dist/bundle/chunk-FQROWBKV.js +12660 -0
  59. package/dist/bundle/chunk-FV2HJOSC.js +771 -0
  60. package/dist/bundle/chunk-GCAJW4SR.js +53 -0
  61. package/dist/bundle/chunk-GPRJXJC7.js +102 -0
  62. package/dist/bundle/chunk-HCOZUOSN.js +54 -0
  63. package/dist/bundle/chunk-HM6AMYHR.js +72 -0
  64. package/dist/bundle/chunk-HVXOA4FO.js +23 -0
  65. package/dist/bundle/chunk-HWQ7572G.js +95 -0
  66. package/dist/bundle/chunk-IJVTN5L3.js +82 -0
  67. package/dist/bundle/chunk-IZDDBOHU.js +3610 -0
  68. package/dist/bundle/chunk-JAE5B4G7.js +388 -0
  69. package/dist/bundle/chunk-K2Y5K37O.js +218 -0
  70. package/dist/bundle/chunk-KCH224US.js +9581 -0
  71. package/dist/bundle/chunk-KZJQPJK5.js +230 -0
  72. package/dist/bundle/chunk-L7P3LUDQ.js +286 -0
  73. package/dist/bundle/chunk-LECMHK2F.js +18 -0
  74. package/dist/bundle/chunk-LWEMZJLG.js +1332 -0
  75. package/dist/bundle/chunk-LWTETL2O.js +185 -0
  76. package/dist/bundle/chunk-MEYYH47C.js +25 -0
  77. package/dist/bundle/chunk-MJ6LTG4L.js +170 -0
  78. package/dist/bundle/chunk-NMQRSEZM.js +37 -0
  79. package/dist/bundle/chunk-ODVGFCBE.js +557 -0
  80. package/dist/bundle/chunk-OEQNP56V.js +633 -0
  81. package/dist/bundle/chunk-OV6WQY3L.js +39 -0
  82. package/dist/bundle/chunk-PL5P7UKW.js +25216 -0
  83. package/dist/bundle/chunk-PPNTY7LD.js +733 -0
  84. package/dist/bundle/chunk-PRZYRA66.js +358 -0
  85. package/dist/bundle/chunk-PV5UYGRJ.js +41594 -0
  86. package/dist/bundle/chunk-QYTOLPNI.js +52 -0
  87. package/dist/bundle/chunk-R7Y3XU66.js +362 -0
  88. package/dist/bundle/chunk-S4UUN6LD.js +1410 -0
  89. package/dist/bundle/chunk-SD5CXGIG.js +188 -0
  90. package/dist/bundle/chunk-SXY5G62I.js +288 -0
  91. package/dist/bundle/chunk-T37TAXVL.js +29 -0
  92. package/dist/bundle/chunk-T5SOY3AE.js +1197 -0
  93. package/dist/bundle/chunk-TJ7OORSO.js +1876 -0
  94. package/dist/bundle/chunk-TRYYWV7J.js +291 -0
  95. package/dist/bundle/chunk-U6VLNYCO.js +73 -0
  96. package/dist/bundle/chunk-UC7JLE6J.js +58 -0
  97. package/dist/bundle/chunk-UUIOAZPH.js +156 -0
  98. package/dist/bundle/chunk-UXQ24OY6.js +4072 -0
  99. package/dist/bundle/chunk-VBRRMGON.js +1007 -0
  100. package/dist/bundle/chunk-VRIBES2C.js +319 -0
  101. package/dist/bundle/chunk-XFLCVHSQ.js +50 -0
  102. package/dist/bundle/chunk-XT5XYQEZ.js +3414 -0
  103. package/dist/bundle/chunk-XTAS5Z3G.js +2231 -0
  104. package/dist/bundle/chunk-XYQVVW4R.js +24 -0
  105. package/dist/bundle/chunk-Y5E2WNWB.js +35 -0
  106. package/dist/bundle/chunk-YHWFF6DN.js +39 -0
  107. package/dist/bundle/chunk-YUDVRFXN.js +63 -0
  108. package/dist/bundle/chunk-Z3I2MCUT.js +131 -0
  109. package/dist/bundle/chunk-ZDI3WC7V.js +353 -0
  110. package/dist/bundle/chunk-ZVQ7KFMT.js +274 -0
  111. package/dist/bundle/chunk-ZVVMGPBJ.js +50 -0
  112. package/dist/bundle/command-contract-P7YE4EKS.js +37 -0
  113. package/dist/bundle/command-server-entry-XIMCBWMV.js +166 -0
  114. package/dist/bundle/decode-6XK55WYV.js +297 -0
  115. package/dist/bundle/definitions-GIQCGYPR.js +7986 -0
  116. package/dist/bundle/dispatch-JQBAZWCL.js +411 -0
  117. package/dist/bundle/dist-2TV3NVE5.js +7577 -0
  118. package/dist/bundle/dist-PAKDDIBT.js +191 -0
  119. package/dist/bundle/echarts-YRRVLEX3.js +42501 -0
  120. package/dist/bundle/embed-L3EEQSGX.js +38 -0
  121. package/dist/bundle/embedder-BIKLBV3J.js +111 -0
  122. package/dist/bundle/failure-I6AAF5R5.js +25 -0
  123. package/dist/bundle/first-run-W6G6TYZ2.js +29 -0
  124. package/dist/bundle/first-screen-ITIAJIBU.js +37 -0
  125. package/dist/bundle/hast-util-from-html-ZHU6HGIE.js +10531 -0
  126. package/dist/bundle/hast-util-to-html-IIFHILP5.js +998 -0
  127. package/dist/bundle/hast-util-to-mdast-D62XX3NR.js +2272 -0
  128. package/dist/bundle/instructions-AG7SRWTR.js +11 -0
  129. package/dist/bundle/mcp-YGOAUNC3.js +167 -0
  130. package/dist/bundle/mdast-util-from-markdown-WVUJDSUO.js +1900 -0
  131. package/dist/bundle/mdast-util-gfm-KN2D32QS.js +1040 -0
  132. package/dist/bundle/mdast-util-to-hast-AYJV7KAE.js +879 -0
  133. package/dist/bundle/mdast-util-to-markdown-UCAJNHJO.js +18 -0
  134. package/dist/bundle/meeting-combined-CQJ3JHHU.js +24 -0
  135. package/dist/bundle/meeting-model-MZ7VVBNK.js +25 -0
  136. package/dist/bundle/meeting-semantic-DADWRRHP.js +22 -0
  137. package/dist/bundle/micromark-extension-gfm-EEJRRJ36.js +1771 -0
  138. package/dist/bundle/node-GJQYN4FT.js +176 -0
  139. package/dist/bundle/node-JJ3WDCNJ.js +2340 -0
  140. package/dist/bundle/node-TLZSIHIJ.js +21 -0
  141. package/dist/bundle/node-sqlite-TPR62DT2.js +74 -0
  142. package/dist/bundle/oauth-WGY7JQVW.js +20 -0
  143. package/dist/bundle/open-DE7QZNAN.js +23 -0
  144. package/dist/bundle/openai-NHEFT3HS.js +238 -0
  145. package/dist/bundle/process-MEKCZMX3.js +91 -0
  146. package/dist/bundle/program-EP2S5BTM.js +38857 -0
  147. package/dist/bundle/prompt-PWY53BYH.js +17 -0
  148. package/dist/bundle/recognize-74TXHKMQ.js +26 -0
  149. package/dist/bundle/remote-F5TJZ5ER.js +31 -0
  150. package/dist/bundle/rerank-HWUO52UF.js +52 -0
  151. package/dist/bundle/schemas-4K6WWS5N.js +2157 -0
  152. package/dist/bundle/serve-I2USUY4X.js +199 -0
  153. package/dist/bundle/server-GDYDNO6K.js +79 -0
  154. package/dist/bundle/server-KYUW2AHB.js +212 -0
  155. package/dist/bundle/sqlite-runtime-N6VFGBJK.js +20 -0
  156. package/dist/bundle/state-L6JSCN77.js +36 -0
  157. package/dist/bundle/store-EPG2YPN3.js +291 -0
  158. package/dist/bundle/store-SQWQJE32.js +181 -0
  159. package/dist/bundle/store-maintenance-command-FTGSICVA.js +66 -0
  160. package/dist/bundle/surface-SNMHY6GP.js +65 -0
  161. package/dist/bundle/wordpress.js +183 -0
  162. package/dist/commands/api.d.ts +22 -0
  163. package/dist/commands/api.d.ts.map +1 -0
  164. package/dist/commands/api.js +37 -0
  165. package/dist/commands/api.js.map +1 -0
  166. package/dist/commands/content.d.ts +4 -0
  167. package/dist/commands/content.d.ts.map +1 -0
  168. package/dist/commands/content.js +94 -0
  169. package/dist/commands/content.js.map +1 -0
  170. package/dist/commands/session.d.ts +8 -0
  171. package/dist/commands/session.d.ts.map +1 -0
  172. package/dist/commands/session.js +28 -0
  173. package/dist/commands/session.js.map +1 -0
  174. package/dist/config.d.ts +13 -0
  175. package/dist/config.d.ts.map +1 -0
  176. package/dist/config.js +69 -0
  177. package/dist/config.js.map +1 -0
  178. package/dist/context.d.ts +37 -0
  179. package/dist/context.d.ts.map +1 -0
  180. package/dist/context.js +31 -0
  181. package/dist/context.js.map +1 -0
  182. package/dist/generated/definitions.d.ts +3 -0
  183. package/dist/generated/definitions.d.ts.map +1 -0
  184. package/dist/generated/definitions.js +7982 -0
  185. package/dist/generated/definitions.js.map +1 -0
  186. package/dist/generated/manifest.d.ts +6 -0
  187. package/dist/generated/manifest.d.ts.map +1 -0
  188. package/dist/generated/manifest.js +8830 -0
  189. package/dist/generated/manifest.js.map +1 -0
  190. package/dist/generated/schemas.d.ts +229 -0
  191. package/dist/generated/schemas.d.ts.map +1 -0
  192. package/dist/generated/schemas.js +2019 -0
  193. package/dist/generated/schemas.js.map +1 -0
  194. package/dist/generated/types.d.ts +3365 -0
  195. package/dist/generated/types.d.ts.map +1 -0
  196. package/dist/generated/types.js +5 -0
  197. package/dist/generated/types.js.map +1 -0
  198. package/dist/generated/wirecat-config.d.ts +11 -0
  199. package/dist/generated/wirecat-config.d.ts.map +1 -0
  200. package/dist/generated/wirecat-config.js +337 -0
  201. package/dist/generated/wirecat-config.js.map +1 -0
  202. package/dist/identity.d.ts +28 -0
  203. package/dist/identity.d.ts.map +1 -0
  204. package/dist/identity.js +29 -0
  205. package/dist/identity.js.map +1 -0
  206. package/dist/index.d.ts +3 -0
  207. package/dist/index.d.ts.map +1 -0
  208. package/dist/index.js +3 -0
  209. package/dist/index.js.map +1 -0
  210. package/dist/program.d.ts +6 -0
  211. package/dist/program.d.ts.map +1 -0
  212. package/dist/program.js +53 -0
  213. package/dist/program.js.map +1 -0
  214. package/dist/version.d.ts +2 -0
  215. package/dist/version.d.ts.map +1 -0
  216. package/dist/version.js +2 -0
  217. package/dist/version.js.map +1 -0
  218. package/dist/wcat.d.ts +3 -0
  219. package/dist/wcat.d.ts.map +1 -0
  220. package/dist/wcat.js +4 -0
  221. package/dist/wcat.js.map +1 -0
  222. package/package.json +87 -4
  223. package/skills/wordpress-cli/SKILL.md +88 -0
  224. package/skills/wordpress-cli/references/api/api-block-directory.md +17 -0
  225. package/skills/wordpress-cli/references/api/api-block-patterns.md +13 -0
  226. package/skills/wordpress-cli/references/api/api-block-types.md +34 -0
  227. package/skills/wordpress-cli/references/api/api-blocks.md +159 -0
  228. package/skills/wordpress-cli/references/api/api-categories.md +69 -0
  229. package/skills/wordpress-cli/references/api/api-comments.md +79 -0
  230. package/skills/wordpress-cli/references/api/api-font-collections.md +16 -0
  231. package/skills/wordpress-cli/references/api/api-font-families.md +122 -0
  232. package/skills/wordpress-cli/references/api/api-global-styles.md +29 -0
  233. package/skills/wordpress-cli/references/api/api-media.md +106 -0
  234. package/skills/wordpress-cli/references/api/api-menu-items.md +115 -0
  235. package/skills/wordpress-cli/references/api/api-menu-locations.md +22 -0
  236. package/skills/wordpress-cli/references/api/api-menus.md +69 -0
  237. package/skills/wordpress-cli/references/api/api-navigation.md +155 -0
  238. package/skills/wordpress-cli/references/api/api-pages.md +161 -0
  239. package/skills/wordpress-cli/references/api/api-pattern-directory.md +23 -0
  240. package/skills/wordpress-cli/references/api/api-plugins.md +25 -0
  241. package/skills/wordpress-cli/references/api/api-posts.md +166 -0
  242. package/skills/wordpress-cli/references/api/api-search.md +21 -0
  243. package/skills/wordpress-cli/references/api/api-settings.md +19 -0
  244. package/skills/wordpress-cli/references/api/api-sidebars.md +34 -0
  245. package/skills/wordpress-cli/references/api/api-statuses.md +22 -0
  246. package/skills/wordpress-cli/references/api/api-tags.md +69 -0
  247. package/skills/wordpress-cli/references/api/api-taxonomies.md +23 -0
  248. package/skills/wordpress-cli/references/api/api-template-parts.md +38 -0
  249. package/skills/wordpress-cli/references/api/api-templates.md +38 -0
  250. package/skills/wordpress-cli/references/api/api-themes.md +12 -0
  251. package/skills/wordpress-cli/references/api/api-types.md +22 -0
  252. package/skills/wordpress-cli/references/api/api-users.md +149 -0
  253. package/skills/wordpress-cli/references/api/api-widget-types.md +46 -0
  254. package/skills/wordpress-cli/references/api/api-widgets.md +57 -0
  255. package/skills/wordpress-cli/references/api/api-wp-pattern-category.md +69 -0
  256. package/skills/wordpress-cli/references/api.md +44 -0
@@ -0,0 +1,199 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ listen
5
+ } from "./chunk-3UX4VJWD.js";
6
+ import {
7
+ ownerLogin
8
+ } from "./chunk-SXY5G62I.js";
9
+ import {
10
+ WebStandardStreamableHTTPServerTransport,
11
+ createMcpHandler,
12
+ getOAuthProtectedResourceMetadataUrl,
13
+ hostHeaderValidationResponse,
14
+ isLegacyRequest,
15
+ oauthMetadataResponse,
16
+ requireBearerAuth
17
+ } from "./chunk-PL5P7UKW.js";
18
+ import {
19
+ activityRecorder,
20
+ calledTools,
21
+ httpActivityFile,
22
+ httpLock
23
+ } from "./chunk-7HJFBOAT.js";
24
+ import "./chunk-U6VLNYCO.js";
25
+ import "./chunk-YUDVRFXN.js";
26
+ import "./chunk-3BM6KBWP.js";
27
+ import "./chunk-3LMW7U7F.js";
28
+ import "./chunk-S4UUN6LD.js";
29
+ import "./chunk-Y5E2WNWB.js";
30
+ import {
31
+ CliError
32
+ } from "./chunk-HM6AMYHR.js";
33
+ import {
34
+ __name
35
+ } from "./chunk-ZVVMGPBJ.js";
36
+
37
+ // node_modules/.pnpm/@wirecat+cli-core@0.707.0_@wirecat+cli-base@0.124.0_commander@15.0.0_esbuild@0.28.2_typ_1ab7200af0919d16d129ae0ece32d37f/node_modules/@wirecat/cli-core/dist/mcp/http/serve.js
38
+ import { randomUUID } from "node:crypto";
39
+ var MCP_PATH = "/mcp";
40
+ var AS_METADATA = "/.well-known/oauth-authorization-server";
41
+ var LOCAL = ["localhost", "127.0.0.1"];
42
+ var MAX_SESSIONS = 20;
43
+ var MAX_LOGIN_BODY = 64 * 1024;
44
+ var SESSION_IDLE_MS = 60 * 60 * 1e3;
45
+ var sessionMissing = /* @__PURE__ */ __name(() => new Response(JSON.stringify({ jsonrpc: "2.0", error: { code: -32001, message: "Session not found" }, id: null }), {
46
+ status: 404,
47
+ headers: { "content-type": "application/json" }
48
+ }), "sessionMissing");
49
+ var legacySessions = /* @__PURE__ */ __name((build, now) => {
50
+ const sessions = /* @__PURE__ */ new Map();
51
+ const drop = /* @__PURE__ */ __name(async (id) => {
52
+ const one = sessions.get(id);
53
+ sessions.delete(id);
54
+ await one?.close();
55
+ }, "drop");
56
+ const handle = /* @__PURE__ */ __name(async (request, auth) => {
57
+ for (const [id2, one] of sessions)
58
+ if (now() - one.seen > SESSION_IDLE_MS)
59
+ await drop(id2);
60
+ const id = request.headers.get("mcp-session-id");
61
+ if (id) {
62
+ const known = sessions.get(id);
63
+ if (!known || known.clientId !== auth.clientId)
64
+ return sessionMissing();
65
+ known.seen = now();
66
+ return known.transport.handleRequest(request, { authInfo: auth });
67
+ }
68
+ const server = build();
69
+ const transport = new WebStandardStreamableHTTPServerTransport({
70
+ sessionIdGenerator: /* @__PURE__ */ __name(() => randomUUID(), "sessionIdGenerator"),
71
+ onsessionclosed: /* @__PURE__ */ __name((closed) => void sessions.delete(closed), "onsessionclosed")
72
+ });
73
+ await server.connect(transport);
74
+ const response = await transport.handleRequest(request, { authInfo: auth });
75
+ if (!transport.sessionId) {
76
+ await server.close();
77
+ return response;
78
+ }
79
+ sessions.set(transport.sessionId, { transport, close: /* @__PURE__ */ __name(() => server.close(), "close"), clientId: auth.clientId, seen: now() });
80
+ while (sessions.size > MAX_SESSIONS)
81
+ await drop(sessions.keys().next().value);
82
+ return response;
83
+ }, "handle");
84
+ return {
85
+ handle,
86
+ close: /* @__PURE__ */ __name(async () => {
87
+ for (const id of [...sessions.keys()])
88
+ await drop(id);
89
+ }, "close")
90
+ };
91
+ }, "legacySessions");
92
+ var metadataRequest = /* @__PURE__ */ __name((request, path, base) => {
93
+ const url = new URL(request.url);
94
+ const inserted = base && path === `${AS_METADATA}${base}`;
95
+ if (!inserted && url.pathname === path)
96
+ return request;
97
+ url.pathname = inserted ? AS_METADATA : path;
98
+ return new Request(url, { method: request.method, headers: request.headers });
99
+ }, "metadataRequest");
100
+ var toolsIn = /* @__PURE__ */ __name(async (request) => {
101
+ if (request.method !== "POST")
102
+ return [];
103
+ try {
104
+ return calledTools(await request.clone().json());
105
+ } catch {
106
+ return [];
107
+ }
108
+ }, "toolsIn");
109
+ var serveOverHttp = /* @__PURE__ */ __name(async (build, options) => {
110
+ const { publicUrl, port, tokenFile, appName, reaches, onCode, onError, now, lockFile, version } = options;
111
+ const lock = lockFile ? httpLock(lockFile, {
112
+ pid: process.pid,
113
+ startedAt: (/* @__PURE__ */ new Date()).toISOString(),
114
+ port,
115
+ publicUrl: publicUrl.href,
116
+ ...version ? { version } : {}
117
+ }) : void 0;
118
+ if (lock?.held)
119
+ 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})`);
120
+ const base = publicUrl.pathname === "/" ? "" : publicUrl.pathname.replace(/\/+$/, "");
121
+ const issuer = new URL(`${publicUrl.origin}${base}`);
122
+ const resource = new URL(`${base}${MCP_PATH}`, publicUrl.origin);
123
+ const mcpPath = resource.pathname;
124
+ const publicPath = /* @__PURE__ */ __name((path) => base && path !== base && !path.startsWith(`${base}/`) && !path.startsWith("/.well-known/") ? `${base}${path}` : path, "publicPath");
125
+ const login = ownerLogin({
126
+ issuer,
127
+ resource,
128
+ file: tokenFile,
129
+ appName,
130
+ ...reaches ? { reaches } : {},
131
+ onCode: /* @__PURE__ */ __name((code, expires) => {
132
+ lock?.update({ loginCode: code, loginCodeExpiresAt: expires.toISOString() });
133
+ onCode(code, expires);
134
+ }, "onCode"),
135
+ ...now ? { now } : {}
136
+ });
137
+ const insecure = issuer.protocol === "http:" && LOCAL.includes(issuer.hostname);
138
+ const mcp = createMcpHandler(build, { legacy: "reject", ...onError ? { onerror: onError } : {} });
139
+ const legacy = legacySessions(build, now ?? Date.now);
140
+ const bearer = requireBearerAuth({
141
+ verifier: login.verifier,
142
+ resourceMetadataUrl: getOAuthProtectedResourceMetadataUrl(resource)
143
+ });
144
+ const activity = activityRecorder(httpActivityFile(tokenFile), now);
145
+ const allowedHosts = [.../* @__PURE__ */ new Set([publicUrl.hostname, ...LOCAL])];
146
+ const allowedOrigins = [publicUrl.origin];
147
+ const listening = await listen(async (request) => {
148
+ const refused = hostHeaderValidationResponse(request, allowedHosts);
149
+ if (refused)
150
+ return refused;
151
+ const path = publicPath(new URL(request.url).pathname);
152
+ const discovery = oauthMetadataResponse(metadataRequest(request, path, base), {
153
+ oauthMetadata: login.metadata,
154
+ resourceServerUrl: resource,
155
+ resourceName: appName,
156
+ ...insecure ? { dangerouslyAllowInsecureIssuerUrl: true } : {}
157
+ });
158
+ if (discovery)
159
+ return discovery;
160
+ if (Number(request.headers.get("content-length") ?? 0) > MAX_LOGIN_BODY && path !== mcpPath)
161
+ return new Response("Request too large", { status: 413 });
162
+ const origin = request.headers.get("origin");
163
+ if (origin && !allowedOrigins.includes(origin))
164
+ return new Response("Origin not allowed", { status: 403 });
165
+ const answered = await login.handle(request, path);
166
+ if (answered)
167
+ return answered;
168
+ if (path !== mcpPath)
169
+ return new Response("Not found", { status: 404 });
170
+ const auth = await bearer(request);
171
+ if (auth instanceof Response)
172
+ return auth;
173
+ activity.record(auth.clientId, await toolsIn(request));
174
+ return await isLegacyRequest(request) ? legacy.handle(request, auth) : mcp.fetch(request, { authInfo: auth });
175
+ }, { host: "127.0.0.1", port }).catch((error) => {
176
+ login.close();
177
+ lock?.release();
178
+ throw error;
179
+ });
180
+ lock?.update({ listeningAt: (/* @__PURE__ */ new Date()).toISOString() });
181
+ return {
182
+ url: listening.url,
183
+ close: /* @__PURE__ */ __name(async () => {
184
+ login.close();
185
+ activity.flush();
186
+ try {
187
+ await listening.close();
188
+ await legacy.close();
189
+ await mcp.close();
190
+ } finally {
191
+ lock?.release();
192
+ }
193
+ }, "close")
194
+ };
195
+ }, "serveOverHttp");
196
+ export {
197
+ MCP_PATH,
198
+ serveOverHttp
199
+ };
@@ -0,0 +1,79 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ PER_RUN,
5
+ createServer,
6
+ envelope,
7
+ serveOverHttpUntilStopped,
8
+ serveOverStdio
9
+ } from "./chunk-6UYDKCV6.js";
10
+ import "./chunk-LWEMZJLG.js";
11
+ import "./chunk-CGCUOT67.js";
12
+ import "./chunk-OEQNP56V.js";
13
+ import "./chunk-LECMHK2F.js";
14
+ import "./chunk-A474OVIW.js";
15
+ import "./chunk-ZDI3WC7V.js";
16
+ import "./chunk-IZDDBOHU.js";
17
+ import "./chunk-7GNB4LBX.js";
18
+ import "./chunk-F3AV5ZSL.js";
19
+ import "./chunk-GCAJW4SR.js";
20
+ import "./chunk-ODVGFCBE.js";
21
+ import "./chunk-3BRAZVHR.js";
22
+ import "./chunk-PV5UYGRJ.js";
23
+ import "./chunk-CHPWBQUK.js";
24
+ import "./chunk-BH63B66W.js";
25
+ import "./chunk-GPRJXJC7.js";
26
+ import "./chunk-7QH5BZUG.js";
27
+ import "./chunk-CFQQTDSA.js";
28
+ import "./chunk-ARGRGTPX.js";
29
+ import "./chunk-PPNTY7LD.js";
30
+ import "./chunk-PL5P7UKW.js";
31
+ import "./chunk-BAXNAOOL.js";
32
+ import "./chunk-2BI25SEE.js";
33
+ import "./chunk-PRZYRA66.js";
34
+ import "./chunk-MJ6LTG4L.js";
35
+ import "./chunk-7HJFBOAT.js";
36
+ import "./chunk-U6VLNYCO.js";
37
+ import "./chunk-Z3I2MCUT.js";
38
+ import "./chunk-FQROWBKV.js";
39
+ import "./chunk-R7Y3XU66.js";
40
+ import "./chunk-2UEGJ5AJ.js";
41
+ import "./chunk-4HEXAGKT.js";
42
+ import "./chunk-YUDVRFXN.js";
43
+ import "./chunk-IJVTN5L3.js";
44
+ import "./chunk-AENEMQL3.js";
45
+ import "./chunk-FNB4SWTY.js";
46
+ import "./chunk-AL7I4DT4.js";
47
+ import "./chunk-5XPHFV7H.js";
48
+ import "./chunk-5Z3P543G.js";
49
+ import "./chunk-FV2HJOSC.js";
50
+ import "./chunk-2Z7UOXFC.js";
51
+ import "./chunk-3LVTQFGB.js";
52
+ import "./chunk-UUIOAZPH.js";
53
+ import "./chunk-T37TAXVL.js";
54
+ import "./chunk-UXQ24OY6.js";
55
+ import "./chunk-AV2ZJ4WX.js";
56
+ import "./chunk-LWTETL2O.js";
57
+ import "./chunk-JAE5B4G7.js";
58
+ import "./chunk-T5SOY3AE.js";
59
+ import "./chunk-VBRRMGON.js";
60
+ import "./chunk-ZVQ7KFMT.js";
61
+ import "./chunk-HVXOA4FO.js";
62
+ import "./chunk-D72URWJE.js";
63
+ import "./chunk-HCOZUOSN.js";
64
+ import "./chunk-HWQ7572G.js";
65
+ import "./chunk-FMMYBVCH.js";
66
+ import "./chunk-3BM6KBWP.js";
67
+ import "./chunk-3LMW7U7F.js";
68
+ import "./chunk-S4UUN6LD.js";
69
+ import "./chunk-Y5E2WNWB.js";
70
+ import "./chunk-HM6AMYHR.js";
71
+ import "./chunk-F5ZAN7OC.js";
72
+ import "./chunk-ZVVMGPBJ.js";
73
+ export {
74
+ PER_RUN,
75
+ createServer,
76
+ envelope,
77
+ serveOverHttpUntilStopped,
78
+ serveOverStdio
79
+ };
@@ -0,0 +1,212 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ botInstructions
5
+ } from "./chunk-XYQVVW4R.js";
6
+ import {
7
+ skillResources
8
+ } from "./chunk-CGCUOT67.js";
9
+ import {
10
+ StdioServerTransport,
11
+ answeredWire,
12
+ serveStdio
13
+ } from "./chunk-OEQNP56V.js";
14
+ import {
15
+ wholeList
16
+ } from "./chunk-ZDI3WC7V.js";
17
+ import {
18
+ runCommandForAgent,
19
+ toolsFromCommands
20
+ } from "./chunk-IZDDBOHU.js";
21
+ import "./chunk-7GNB4LBX.js";
22
+ import "./chunk-F3AV5ZSL.js";
23
+ import {
24
+ answered,
25
+ normal,
26
+ registerCommands
27
+ } from "./chunk-ODVGFCBE.js";
28
+ import {
29
+ agentJson
30
+ } from "./chunk-3BRAZVHR.js";
31
+ import "./chunk-PV5UYGRJ.js";
32
+ import "./chunk-CHPWBQUK.js";
33
+ import "./chunk-BH63B66W.js";
34
+ import "./chunk-GPRJXJC7.js";
35
+ import "./chunk-7QH5BZUG.js";
36
+ import "./chunk-CFQQTDSA.js";
37
+ import {
38
+ callerOf
39
+ } from "./chunk-ARGRGTPX.js";
40
+ import "./chunk-PPNTY7LD.js";
41
+ import {
42
+ McpServer
43
+ } from "./chunk-PL5P7UKW.js";
44
+ import "./chunk-BAXNAOOL.js";
45
+ import "./chunk-2BI25SEE.js";
46
+ import "./chunk-PRZYRA66.js";
47
+ import "./chunk-MJ6LTG4L.js";
48
+ import {
49
+ MESSENGER_CHANGE_REFUSAL,
50
+ changesMessenger,
51
+ flatten,
52
+ itemOf,
53
+ readOnlyLockOf,
54
+ readOnlyRefusal
55
+ } from "./chunk-FQROWBKV.js";
56
+ import "./chunk-R7Y3XU66.js";
57
+ import "./chunk-2UEGJ5AJ.js";
58
+ import "./chunk-4HEXAGKT.js";
59
+ import "./chunk-YUDVRFXN.js";
60
+ import "./chunk-IJVTN5L3.js";
61
+ import "./chunk-AENEMQL3.js";
62
+ import "./chunk-FNB4SWTY.js";
63
+ import "./chunk-AL7I4DT4.js";
64
+ import "./chunk-5XPHFV7H.js";
65
+ import "./chunk-5Z3P543G.js";
66
+ import "./chunk-FV2HJOSC.js";
67
+ import "./chunk-2Z7UOXFC.js";
68
+ import "./chunk-3LVTQFGB.js";
69
+ import "./chunk-UUIOAZPH.js";
70
+ import "./chunk-T37TAXVL.js";
71
+ import "./chunk-UXQ24OY6.js";
72
+ import "./chunk-AV2ZJ4WX.js";
73
+ import "./chunk-LWTETL2O.js";
74
+ import "./chunk-JAE5B4G7.js";
75
+ import "./chunk-T5SOY3AE.js";
76
+ import "./chunk-VBRRMGON.js";
77
+ import "./chunk-ZVQ7KFMT.js";
78
+ import "./chunk-HVXOA4FO.js";
79
+ import "./chunk-D72URWJE.js";
80
+ import "./chunk-HCOZUOSN.js";
81
+ import "./chunk-HWQ7572G.js";
82
+ import "./chunk-FMMYBVCH.js";
83
+ import "./chunk-3BM6KBWP.js";
84
+ import {
85
+ mcpErrorResult
86
+ } from "./chunk-3LMW7U7F.js";
87
+ import {
88
+ object
89
+ } from "./chunk-S4UUN6LD.js";
90
+ import "./chunk-Y5E2WNWB.js";
91
+ import "./chunk-HM6AMYHR.js";
92
+ import "./chunk-F5ZAN7OC.js";
93
+ import {
94
+ __name
95
+ } from "./chunk-ZVVMGPBJ.js";
96
+
97
+ // node_modules/.pnpm/@wirecat+cli-core@0.707.0_@wirecat+cli-base@0.124.0_commander@15.0.0_esbuild@0.28.2_typ_1ab7200af0919d16d129ae0ece32d37f/node_modules/@wirecat/cli-core/dist/mcp/bot/server.js
98
+ import { randomUUID } from "node:crypto";
99
+ var body = /* @__PURE__ */ __name((command, value) => Array.isArray(value) ? wholeList(`bot ${command}`, value) : value !== null && typeof value === "object" && ("item" in value || "items" in value) ? value : itemOf(value !== null && typeof value === "object" ? value : { value }), "body");
100
+ var createBotServer = /* @__PURE__ */ __name((options) => {
101
+ const { bot, program, settings, env } = options;
102
+ const command = bot.app.command;
103
+ const levels = options.levels ?? (() => settings.permissions);
104
+ const authority = /* @__PURE__ */ __name((path) => options.authority?.(path) === true || path[0] === "config" && (path[1] === "set" || path[1] === "unset"), "authority");
105
+ const catalogue = {
106
+ includeUnavailable: true,
107
+ levels: settings.permissions,
108
+ currentLevels: levels,
109
+ readOnly: readOnlyLockOf(bot.app, env) !== void 0,
110
+ ...options.keyOf ? { keyOf: options.keyOf } : {},
111
+ authority,
112
+ ...options.fetchOnly ? { fetchOnly: options.fetchOnly } : {},
113
+ ...options.fetches ? { fetches: options.fetches } : {},
114
+ offline: true,
115
+ // Another bot's copy is this bot's to read only where `read_other_bots` says so.
116
+ ...settings.readOtherBots ? {} : { omit: ["all_bots", "bots"] }
117
+ };
118
+ const tools = [
119
+ ...toolsFromCommands(program.commands, { ...catalogue, root: ["bot"] }),
120
+ ...toolsFromCommands(program.commands.filter((one) => one.path[0] === "config"), {
121
+ ...catalogue,
122
+ omit: ["bot", "personal", "defaults"]
123
+ })
124
+ ];
125
+ const writes = tools.filter((tool) => tool.writes && tool.availability?.().available !== false).map((tool) => tool.command);
126
+ const skills = options.skill ? skillResources(bot.app, options.skill) : [];
127
+ const skill = skills[0];
128
+ let queue = Promise.resolve();
129
+ const invoke = /* @__PURE__ */ __name((path, input, caller) => {
130
+ const next = queue.then(() => runCommandForAgent(program, path, path[0] === "config" ? { ...input, bot: true } : input, {
131
+ profile: settings.profile,
132
+ readOnly: readOnlyLockOf(bot.app, env) !== void 0,
133
+ env,
134
+ levels,
135
+ ...options.keyOf ? { keyOf: options.keyOf } : {},
136
+ authority,
137
+ ...options.fetches ? { fetches: options.fetches } : {},
138
+ ...caller ? { caller } : {}
139
+ }));
140
+ queue = next.catch(() => void 0);
141
+ return next;
142
+ }, "invoke");
143
+ const build = /* @__PURE__ */ __name(() => {
144
+ const callers = { env, client: /* @__PURE__ */ __name(() => server.server.getClientVersion(), "client"), connectionId: randomUUID() };
145
+ const server = new McpServer({ name: `${command}-bot-${settings.profile}`, version: bot.app.version }, {
146
+ instructions: botInstructions({
147
+ command,
148
+ name: bot.name ?? command,
149
+ profile: settings.profile,
150
+ writes,
151
+ ...skill ? { skill: skill.instruction } : {}
152
+ })
153
+ });
154
+ for (const { uri, name, title, description, mimeType, read } of skills)
155
+ server.registerResource(name, uri, { title, description, mimeType }, read);
156
+ const commands = Object.fromEntries(tools.map((tool) => [
157
+ tool.command,
158
+ {
159
+ title: tool.title,
160
+ description: tool.description,
161
+ writes: tool.writes,
162
+ availability: tool.availability,
163
+ input: tool.input,
164
+ run: /* @__PURE__ */ __name(async (args, ctx) => {
165
+ const caller = callerOf(ctx, `${command}_${tool.command.replaceAll(" ", "_")}`, callers);
166
+ const answer = await invoke(tool.path, args, caller);
167
+ return "error" in answer ? mcpErrorResult(JSON.parse(agentJson(answer.error))) : answered(body(tool.command, answer.result));
168
+ }, "run")
169
+ }
170
+ ]));
171
+ commands.status = {
172
+ title: "This server's bot and profile",
173
+ description: "Which profile this server speaks for, where its bot token comes from, which bot it is, and which writing commands are on. Sends nothing.",
174
+ writes: false,
175
+ input: object({}),
176
+ run: /* @__PURE__ */ __name(async () => {
177
+ const auth = await invoke(["bot", "auth", "show"], {});
178
+ const shown = "error" in auth ? auth.error : auth.result?.item ?? auth.result;
179
+ return answered(itemOf({
180
+ profile: settings.profile,
181
+ kind: "bot",
182
+ auth: shown,
183
+ writes: tools.filter((tool) => tool.writes && tool.availability?.().available !== false).map((tool) => tool.command),
184
+ permissions: levels()
185
+ }));
186
+ }, "run")
187
+ };
188
+ registerCommands(server, `${command}_bot`, commands, void 0, (asked) => {
189
+ const lock = readOnlyLockOf(bot.app, env);
190
+ const one = flatten(program.commands).find((info) => info.path[0] === "bot" && normal(info.path.slice(1).join(" ")) === asked);
191
+ if (lock && one && changesMessenger(one))
192
+ throw readOnlyRefusal(lock, MESSENGER_CHANGE_REFUSAL);
193
+ }, bot.app.messenger);
194
+ return server;
195
+ }, "build");
196
+ return { build, tools, offered: tools.map((tool) => tool.command) };
197
+ }, "createBotServer");
198
+ var serveBotOverStdio = /* @__PURE__ */ __name(async (options, note) => {
199
+ const { build } = createBotServer(options);
200
+ const wire = answeredWire(process.stdin, process.stdout);
201
+ const handle = serveStdio(build, {
202
+ transport: new StdioServerTransport(wire.input, wire.output),
203
+ onerror: /* @__PURE__ */ __name((error) => note(`mcp: ${error.message}`), "onerror")
204
+ });
205
+ await wire.finished();
206
+ wire.release();
207
+ await handle.close();
208
+ }, "serveBotOverStdio");
209
+ export {
210
+ createBotServer,
211
+ serveBotOverStdio
212
+ };
@@ -0,0 +1,20 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ ensureSqlite,
5
+ nodeRuntime,
6
+ relay
7
+ } from "./chunk-3TKFFSFU.js";
8
+ import "./chunk-HWQ7572G.js";
9
+ import "./chunk-FMMYBVCH.js";
10
+ import "./chunk-3BM6KBWP.js";
11
+ import "./chunk-3LMW7U7F.js";
12
+ import "./chunk-S4UUN6LD.js";
13
+ import "./chunk-Y5E2WNWB.js";
14
+ import "./chunk-HM6AMYHR.js";
15
+ import "./chunk-ZVVMGPBJ.js";
16
+ export {
17
+ ensureSqlite,
18
+ nodeRuntime,
19
+ relay
20
+ };
@@ -0,0 +1,36 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ ACCESS_SECONDS,
5
+ REFRESH_SECONDS,
6
+ httpLaunchFile,
7
+ httpLock,
8
+ httpLockFile,
9
+ httpLogFile,
10
+ mcpHttpMarker,
11
+ readHttpLaunch,
12
+ readHttpLock,
13
+ readStored,
14
+ signedInClients
15
+ } from "./chunk-7HJFBOAT.js";
16
+ import "./chunk-U6VLNYCO.js";
17
+ import "./chunk-YUDVRFXN.js";
18
+ import "./chunk-3BM6KBWP.js";
19
+ import "./chunk-3LMW7U7F.js";
20
+ import "./chunk-S4UUN6LD.js";
21
+ import "./chunk-Y5E2WNWB.js";
22
+ import "./chunk-HM6AMYHR.js";
23
+ import "./chunk-ZVVMGPBJ.js";
24
+ export {
25
+ ACCESS_SECONDS,
26
+ REFRESH_SECONDS,
27
+ httpLaunchFile,
28
+ httpLock,
29
+ httpLockFile,
30
+ httpLogFile,
31
+ mcpHttpMarker,
32
+ readHttpLaunch,
33
+ readHttpLock,
34
+ readStored,
35
+ signedInClients
36
+ };