@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,188 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ stdinFieldOf
5
+ } from "./chunk-LECMHK2F.js";
6
+ import {
7
+ commandPathOf
8
+ } from "./chunk-Z3I2MCUT.js";
9
+ import {
10
+ commandServerRequest,
11
+ metaOf
12
+ } from "./chunk-FQROWBKV.js";
13
+ import {
14
+ errorObjectOf,
15
+ renderError
16
+ } from "./chunk-3LMW7U7F.js";
17
+ import {
18
+ CliError
19
+ } from "./chunk-HM6AMYHR.js";
20
+ import {
21
+ __name
22
+ } from "./chunk-ZVVMGPBJ.js";
23
+
24
+ // 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/cli/command-server.js
25
+ import { createInterface } from "node:readline";
26
+
27
+ // 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/cli/command-server-argv.js
28
+ var COMMAND_SERVER_ARGV = ["commands", "--serve"];
29
+ var isCommandServer = /* @__PURE__ */ __name((args) => args.length === COMMAND_SERVER_ARGV.length && COMMAND_SERVER_ARGV.every((word, at) => args[at] === word), "isCommandServer");
30
+
31
+ // 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/cli/command-server.js
32
+ var COMMAND_SERVER_PROTOCOL = 1;
33
+ var COMMAND_SERVER_IDLE_MS = 10 * 6e4;
34
+ var COMMAND_SERVER_CONCURRENT = 8;
35
+ var runsAlone = /* @__PURE__ */ __name((command) => commandPathOf(command)[0] === "store", "runsAlone");
36
+ var enterCommandServer = /* @__PURE__ */ __name(async (command, cli) => {
37
+ const request = commandServerRequest();
38
+ if (!request)
39
+ return;
40
+ refuseInCommandServer(command, cli);
41
+ if (runsAlone(command))
42
+ await request.alone();
43
+ }, "enterCommandServer");
44
+ var refuseInCommandServer = /* @__PURE__ */ __name((command, cli) => {
45
+ if (!commandServerRequest())
46
+ return;
47
+ const typed = [cli, ...commandPathOf(command)].join(" ");
48
+ const { lifetime } = metaOf(command);
49
+ if (lifetime)
50
+ throw new CliError("validation_error", `\`${typed}\` ${lifetime === "persistent" ? "runs until it is stopped" : "waits on a person"}; the command server runs only commands that return \u2014 start it as a process of its own`);
51
+ if (stdinFieldOf(command))
52
+ throw new CliError("validation_error", `\`${typed}\` reads its input on stdin, which the command server does not pass on \u2014 start it as a process of its own`);
53
+ }, "refuseInCommandServer");
54
+ var refusal = /* @__PURE__ */ __name((cli, message) => `${renderError(errorObjectOf(new CliError("validation_error", message)), { cli, interactive: false })}
55
+ `, "refusal");
56
+ var requestOf = /* @__PURE__ */ __name((line, cli) => {
57
+ let parsed;
58
+ try {
59
+ parsed = JSON.parse(line);
60
+ } catch {
61
+ return { id: null, error: "a request is one JSON object per line" };
62
+ }
63
+ const { id, argv } = parsed ?? {};
64
+ const known = typeof id === "number" && Number.isFinite(id) ? id : null;
65
+ if (known === null)
66
+ return { id: null, error: 'a request needs a numeric "id"' };
67
+ if (!Array.isArray(argv) || !argv.every((word) => typeof word === "string"))
68
+ return { id: known, error: '"argv" is a list of strings' };
69
+ if (isCommandServer(argv))
70
+ return { id: known, error: `\`${cli} commands --serve\` cannot run inside itself` };
71
+ return { id: known, argv };
72
+ }, "requestOf");
73
+ var serveCommands = /* @__PURE__ */ __name(async ({ input, write, run, cli, version, idleMs = COMMAND_SERVER_IDLE_MS, concurrent = COMMAND_SERVER_CONCURRENT, signal }) => {
74
+ const send = /* @__PURE__ */ __name((value) => write(`${JSON.stringify(value)}
75
+ `), "send");
76
+ await send({ ready: true, protocol: COMMAND_SERVER_PROTOCOL, version, concurrent });
77
+ const lines = createInterface({ input, crlfDelay: Number.POSITIVE_INFINITY });
78
+ return new Promise((resolve) => {
79
+ const waiting = [];
80
+ let active = 0;
81
+ let running = 0;
82
+ let gated = false;
83
+ let drained;
84
+ let turns = Promise.resolve();
85
+ let timer;
86
+ let ending = false;
87
+ let done = false;
88
+ const finish = /* @__PURE__ */ __name(() => {
89
+ if (done)
90
+ return;
91
+ done = true;
92
+ clearTimeout(timer);
93
+ lines.close();
94
+ resolve(0);
95
+ }, "finish");
96
+ const settle = /* @__PURE__ */ __name(() => {
97
+ if (running === 0 && drained) {
98
+ const go = drained;
99
+ drained = void 0;
100
+ go();
101
+ }
102
+ pump();
103
+ if (active > 0 || waiting.length > 0 || done)
104
+ return;
105
+ if (ending)
106
+ finish();
107
+ else {
108
+ clearTimeout(timer);
109
+ timer = setTimeout(finish, idleMs);
110
+ }
111
+ }, "settle");
112
+ const start = /* @__PURE__ */ __name((line) => {
113
+ active += 1;
114
+ running += 1;
115
+ let holdsPlace = true;
116
+ let ended = false;
117
+ let turn;
118
+ let release;
119
+ const alone = /* @__PURE__ */ __name(() => {
120
+ if (turn)
121
+ return turn;
122
+ holdsPlace = false;
123
+ running -= 1;
124
+ turn = turns.then(() => new Promise((go) => {
125
+ if (ended)
126
+ return go();
127
+ gated = true;
128
+ drained = /* @__PURE__ */ __name(() => {
129
+ if (ended)
130
+ gated = false;
131
+ else {
132
+ holdsPlace = true;
133
+ running += 1;
134
+ }
135
+ go();
136
+ }, "drained");
137
+ settle();
138
+ }));
139
+ turns = turn.then(() => ended && !holdsPlace ? void 0 : new Promise((free) => release = free));
140
+ return turn;
141
+ }, "alone");
142
+ const answer = /* @__PURE__ */ __name(async () => {
143
+ const request = requestOf(line, cli);
144
+ if ("error" in request)
145
+ return send({ id: request.id, code: 2, stdout: "", stderr: refusal(cli, request.error) });
146
+ const answered = await run(request.argv, alone);
147
+ return send({ id: request.id, ...answered });
148
+ }, "answer");
149
+ answer().catch(finish).finally(() => {
150
+ ended = true;
151
+ active -= 1;
152
+ if (holdsPlace)
153
+ running -= 1;
154
+ if (release) {
155
+ gated = false;
156
+ release();
157
+ }
158
+ settle();
159
+ });
160
+ }, "start");
161
+ const pump = /* @__PURE__ */ __name(() => {
162
+ while (!done && !gated && running < concurrent && waiting.length > 0)
163
+ start(waiting.shift());
164
+ }, "pump");
165
+ lines.on("line", (line) => {
166
+ if (done || ending || line.trim() === "")
167
+ return;
168
+ clearTimeout(timer);
169
+ waiting.push(line);
170
+ pump();
171
+ });
172
+ const end = /* @__PURE__ */ __name(() => {
173
+ ending = true;
174
+ settle();
175
+ }, "end");
176
+ lines.on("close", end);
177
+ if (signal?.aborted)
178
+ end();
179
+ signal?.addEventListener("abort", end, { once: true });
180
+ settle();
181
+ });
182
+ }, "serveCommands");
183
+
184
+ export {
185
+ COMMAND_SERVER_CONCURRENT,
186
+ enterCommandServer,
187
+ serveCommands
188
+ };
@@ -0,0 +1,288 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ OAuthError,
5
+ OAuthErrorCode
6
+ } from "./chunk-PL5P7UKW.js";
7
+ import {
8
+ ACCESS_SECONDS,
9
+ REFRESH_SECONDS,
10
+ readStored
11
+ } from "./chunk-7HJFBOAT.js";
12
+ import {
13
+ __name
14
+ } from "./chunk-ZVVMGPBJ.js";
15
+
16
+ // 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/oauth.js
17
+ import { createHash, randomBytes, randomInt, timingSafeEqual } from "node:crypto";
18
+ import { chmodSync, mkdirSync, renameSync, rmSync, writeFileSync } from "node:fs";
19
+ import { dirname } from "node:path";
20
+ var AUTH_CODE_MS = 60 * 1e3;
21
+ var LOGIN_CODE_MS = 10 * 60 * 1e3;
22
+ var WRONG_TRIES = 5;
23
+ var WRONG_CODE_WAIT_MS = 3e4;
24
+ var MAX_CLIENTS = 10;
25
+ var CODE_ALPHABET = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789";
26
+ var hash = /* @__PURE__ */ __name((value) => createHash("sha256").update(value).digest("base64url"), "hash");
27
+ var secret = /* @__PURE__ */ __name(() => randomBytes(32).toString("base64url"), "secret");
28
+ var same = /* @__PURE__ */ __name((given, expected) => {
29
+ const left = Buffer.from(given);
30
+ const right = Buffer.from(expected);
31
+ return left.byteLength === right.byteLength && timingSafeEqual(left, right);
32
+ }, "same");
33
+ var tokenFile = /* @__PURE__ */ __name((path) => ({
34
+ read: /* @__PURE__ */ __name(() => readStored(path), "read"),
35
+ write: /* @__PURE__ */ __name((stored) => {
36
+ mkdirSync(dirname(path), { recursive: true, mode: 448 });
37
+ const temporary = `${path}.${randomBytes(16).toString("hex")}.tmp`;
38
+ writeFileSync(temporary, JSON.stringify(stored), { mode: 384, flag: "wx" });
39
+ chmodSync(temporary, 384);
40
+ renameSync(temporary, path);
41
+ }, "write")
42
+ }), "tokenFile");
43
+ var revokeAll = /* @__PURE__ */ __name((path) => rmSync(path, { force: true }), "revokeAll");
44
+ var json = /* @__PURE__ */ __name((body, status = 200) => new Response(JSON.stringify(body), {
45
+ status,
46
+ headers: { "content-type": "application/json", "cache-control": "no-store" }
47
+ }), "json");
48
+ var oauthError = /* @__PURE__ */ __name((error, description, status = 400) => json({ error, error_description: description }, status), "oauthError");
49
+ var escapeHtml = /* @__PURE__ */ __name((value) => value.replace(/[&<>"']/g, (character) => `&#${character.charCodeAt(0)};`), "escapeHtml");
50
+ var redirectAllowed = /* @__PURE__ */ __name((uri) => {
51
+ try {
52
+ const url = new URL(uri);
53
+ if (url.hash)
54
+ return false;
55
+ return url.protocol === "https:" || url.protocol === "http:" && ["localhost", "127.0.0.1"].includes(url.hostname);
56
+ } catch {
57
+ return false;
58
+ }
59
+ }, "redirectAllowed");
60
+ var ownerLogin = /* @__PURE__ */ __name(({ issuer, resource, file, appName, reaches = `your ${appName} data`, onCode, now = /* @__PURE__ */ __name(() => Date.now(), "now") }) => {
61
+ const store = tokenFile(file);
62
+ const codes = /* @__PURE__ */ new Map();
63
+ let login = { value: "", expires: 0 };
64
+ let wrong = 0;
65
+ let retryAt = 0;
66
+ let renewal;
67
+ const freshCode = /* @__PURE__ */ __name(() => {
68
+ const part = /* @__PURE__ */ __name(() => Array.from({ length: 4 }, () => CODE_ALPHABET[randomInt(CODE_ALPHABET.length)]).join(""), "part");
69
+ login = { value: `${part()}-${part()}`, expires: now() + LOGIN_CODE_MS };
70
+ clearTimeout(renewal);
71
+ renewal = setTimeout(freshCode, LOGIN_CODE_MS);
72
+ renewal.unref();
73
+ onCode(login.value, new Date(login.expires));
74
+ }, "freshCode");
75
+ freshCode();
76
+ const base = issuer.pathname.replace(/\/+$/, "");
77
+ const endpoint = /* @__PURE__ */ __name((path) => new URL(`${base}${path}`, issuer.origin).href, "endpoint");
78
+ const metadata = {
79
+ issuer: issuer.href,
80
+ authorization_endpoint: endpoint("/authorize"),
81
+ token_endpoint: endpoint("/token"),
82
+ registration_endpoint: endpoint("/register"),
83
+ response_types_supported: ["code"],
84
+ grant_types_supported: ["authorization_code", "refresh_token"],
85
+ code_challenge_methods_supported: ["S256"],
86
+ token_endpoint_auth_methods_supported: ["none", "client_secret_post", "client_secret_basic"]
87
+ };
88
+ const issue = /* @__PURE__ */ __name((stored, clientId) => {
89
+ const access = secret();
90
+ const refresh = secret();
91
+ const seconds = Math.floor(now() / 1e3);
92
+ stored.tokens = stored.tokens.filter((one) => one.expiresAt > seconds);
93
+ stored.tokens.push({ hash: hash(access), kind: "access", clientId, expiresAt: seconds + ACCESS_SECONDS }, { hash: hash(refresh), kind: "refresh", clientId, expiresAt: seconds + REFRESH_SECONDS });
94
+ store.write(stored);
95
+ return json({ access_token: access, token_type: "Bearer", expires_in: ACCESS_SECONDS, refresh_token: refresh });
96
+ }, "issue");
97
+ const clientOf = /* @__PURE__ */ __name((stored, request, form) => {
98
+ let id = form.get("client_id") ?? "";
99
+ let given = form.get("client_secret") ?? void 0;
100
+ const basic = request.headers.get("authorization");
101
+ if (basic?.startsWith("Basic ")) {
102
+ const [user = "", password = ""] = Buffer.from(basic.slice(6), "base64").toString().split(":");
103
+ id = decodeURIComponent(user);
104
+ given = decodeURIComponent(password);
105
+ }
106
+ const client = stored.clients.find((one) => one.id === id);
107
+ if (!client)
108
+ return void 0;
109
+ if (client.authMethod === "none")
110
+ return client;
111
+ return given !== void 0 && client.secretHash && same(hash(given), client.secretHash) ? client : void 0;
112
+ }, "clientOf");
113
+ const register = /* @__PURE__ */ __name(async (request) => {
114
+ const body = await request.json().catch(() => null);
115
+ const uris = Array.isArray(body?.redirect_uris) ? body.redirect_uris.filter((one) => typeof one === "string") : [];
116
+ if (uris.length === 0 || !uris.every(redirectAllowed))
117
+ return oauthError("invalid_redirect_uri", "redirect_uris must be https URLs");
118
+ const requested = body?.token_endpoint_auth_method;
119
+ const authMethod = requested === "client_secret_post" || requested === "client_secret_basic" ? requested : "none";
120
+ const clientSecret = authMethod === "none" ? void 0 : secret();
121
+ const name = typeof body?.client_name === "string" ? body.client_name.slice(0, 100) : void 0;
122
+ const client = {
123
+ id: secret(),
124
+ redirectUris: uris,
125
+ authMethod,
126
+ issuedAt: Math.floor(now() / 1e3),
127
+ ...name ? { name } : {},
128
+ ...clientSecret ? { secretHash: hash(clientSecret) } : {}
129
+ };
130
+ const stored = store.read();
131
+ const seconds = Math.floor(now() / 1e3);
132
+ const holding = new Set(stored.tokens.filter((one) => one.expiresAt > seconds).map((one) => one.clientId));
133
+ stored.clients.push(client);
134
+ while (stored.clients.length > MAX_CLIENTS) {
135
+ const idle = stored.clients.findIndex((one) => !holding.has(one.id));
136
+ if (idle === -1)
137
+ return oauthError("invalid_client_metadata", "too many logged-in apps \u2014 run mcp revoke first");
138
+ stored.clients.splice(idle, 1);
139
+ }
140
+ store.write(stored);
141
+ return json({
142
+ client_id: client.id,
143
+ client_id_issued_at: client.issuedAt,
144
+ redirect_uris: uris,
145
+ token_endpoint_auth_method: authMethod,
146
+ grant_types: ["authorization_code", "refresh_token"],
147
+ response_types: ["code"],
148
+ ...name ? { client_name: name } : {},
149
+ ...clientSecret ? { client_secret: clientSecret, client_secret_expires_at: 0 } : {}
150
+ }, 201);
151
+ }, "register");
152
+ const page = /* @__PURE__ */ __name((params, client, message) => {
153
+ const hidden = ["response_type", "client_id", "redirect_uri", "code_challenge", "code_challenge_method", "state"].map((name) => `<input type="hidden" name="${name}" value="${escapeHtml(params.get(name) ?? "")}">`).join("");
154
+ const who = escapeHtml(client.name ?? "an application");
155
+ const target = new URL(params.get("redirect_uri") ?? "");
156
+ const html = `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>${escapeHtml(appName)} login</title><style>body{font:16px system-ui,sans-serif;max-width:28rem;margin:3rem auto;padding:0 1rem;color:#1d2430}input[type=text]{font:20px ui-monospace,monospace;letter-spacing:.1em;width:100%;padding:.5rem;margin:.5rem 0 1rem;box-sizing:border-box}button{font:inherit;padding:.5rem 1rem}.error{color:#b42318}</style></head><body><h1>${escapeHtml(appName)}</h1><p>An app that calls itself <strong>${who}</strong> asks to reach ${escapeHtml(reaches)} through <code>${escapeHtml(appName)} mcp serve --http</code>.</p><p>After you allow it, the login goes to <strong>${escapeHtml(target.host)}</strong>. Allow only if that is the app you are connecting, such as chatgpt.com or claude.ai.</p><p>Type the code shown in WireCat Desktop, or in the terminal where the server runs. If you did not start this login, close this page.</p>${message ? `<p class="error">${escapeHtml(message)}</p>` : ""}<form method="post" action="${escapeHtml(`${base}/authorize`)}">${hidden}<label>Login code<input type="text" name="login_code" autocomplete="off" autofocus required></label><button type="submit">Allow</button></form></body></html>`;
157
+ return new Response(html, {
158
+ status: message ? 400 : 200,
159
+ headers: {
160
+ "content-type": "text/html; charset=utf-8",
161
+ "cache-control": "no-store",
162
+ "x-frame-options": "DENY",
163
+ "content-security-policy": `default-src 'none'; style-src 'unsafe-inline'; form-action 'self' ${target.origin}; frame-ancestors 'none'`,
164
+ // no-referrer makes the browser post this form with `Origin: null`, which the Origin check refuses.
165
+ "referrer-policy": "same-origin"
166
+ }
167
+ });
168
+ }, "page");
169
+ const authorize = /* @__PURE__ */ __name(async (request) => {
170
+ const params = request.method === "POST" ? new URLSearchParams(await request.text()) : new URL(request.url).searchParams;
171
+ const stored = store.read();
172
+ const client = stored.clients.find((one) => one.id === params.get("client_id"));
173
+ const redirectUri = params.get("redirect_uri") ?? "";
174
+ if (!client?.redirectUris.includes(redirectUri))
175
+ return new Response("Unknown client or redirect address.", { status: 400 });
176
+ if (params.get("response_type") !== "code" || params.get("code_challenge_method") !== "S256" || !params.get("code_challenge"))
177
+ return new Response("This server needs response_type=code and PKCE with S256.", { status: 400 });
178
+ if (request.method !== "POST")
179
+ return page(params, client);
180
+ const throttled = /* @__PURE__ */ __name(() => new Response("Too many wrong codes. Wait, then try the new code.", {
181
+ status: 429,
182
+ headers: { "retry-after": String(Math.ceil((retryAt - now()) / 1e3)) }
183
+ }), "throttled");
184
+ if (wrong >= WRONG_TRIES) {
185
+ if (now() < retryAt)
186
+ return throttled();
187
+ wrong = 0;
188
+ freshCode();
189
+ }
190
+ const typed = (params.get("login_code") ?? "").trim().toUpperCase();
191
+ if (login.expires < now()) {
192
+ freshCode();
193
+ return page(params, client, "The code expired. A new one is shown in WireCat Desktop and in the terminal.");
194
+ }
195
+ if (!same(typed, login.value)) {
196
+ wrong += 1;
197
+ if (wrong >= WRONG_TRIES) {
198
+ retryAt = now() + WRONG_CODE_WAIT_MS;
199
+ return throttled();
200
+ }
201
+ return page(params, client, `Wrong code. Each code works for one login: after an app logs in, a new one appears in WireCat Desktop and in "${appName} mcp server status". ${WRONG_TRIES - wrong} tries left.`);
202
+ }
203
+ wrong = 0;
204
+ freshCode();
205
+ const code = secret();
206
+ codes.set(hash(code), {
207
+ clientId: client.id,
208
+ redirectUri,
209
+ challenge: params.get("code_challenge") ?? "",
210
+ expires: now() + AUTH_CODE_MS
211
+ });
212
+ const target = new URL(redirectUri);
213
+ target.searchParams.set("code", code);
214
+ const state = params.get("state");
215
+ if (state)
216
+ target.searchParams.set("state", state);
217
+ target.searchParams.set("iss", issuer.href);
218
+ return new Response(null, { status: 302, headers: { location: target.href, "cache-control": "no-store" } });
219
+ }, "authorize");
220
+ const token = /* @__PURE__ */ __name(async (request) => {
221
+ const form = new URLSearchParams(await request.text());
222
+ const stored = store.read();
223
+ const client = clientOf(stored, request, form);
224
+ if (!client)
225
+ return oauthError("invalid_client", "unknown client or wrong secret", 401);
226
+ const requestedResource = form.get("resource");
227
+ if (requestedResource && requestedResource !== resource.href)
228
+ return oauthError("invalid_target", "this server issues tokens only for its own MCP endpoint");
229
+ if (form.get("grant_type") === "authorization_code") {
230
+ const key = hash(form.get("code") ?? "");
231
+ const entry = codes.get(key);
232
+ codes.delete(key);
233
+ const verifier2 = form.get("code_verifier") ?? "";
234
+ const challenge = createHash("sha256").update(verifier2).digest("base64url");
235
+ if (!entry || entry.expires < now() || entry.clientId !== client.id || entry.redirectUri !== form.get("redirect_uri") || !same(challenge, entry.challenge))
236
+ return oauthError("invalid_grant", "the code is wrong, used or expired");
237
+ return issue(stored, client.id);
238
+ }
239
+ if (form.get("grant_type") === "refresh_token") {
240
+ const key = hash(form.get("refresh_token") ?? "");
241
+ const seconds = Math.floor(now() / 1e3);
242
+ const found = stored.tokens.find((one) => one.kind === "refresh" && one.hash === key);
243
+ if (!found || found.clientId !== client.id || found.expiresAt <= seconds)
244
+ return oauthError("invalid_grant", "the refresh token is wrong, used or expired");
245
+ stored.tokens = stored.tokens.filter((one) => one !== found);
246
+ return issue(stored, client.id);
247
+ }
248
+ return oauthError("unsupported_grant_type", "use authorization_code or refresh_token");
249
+ }, "token");
250
+ const verifier = {
251
+ verifyAccessToken: /* @__PURE__ */ __name(async (presented) => {
252
+ const seconds = Math.floor(now() / 1e3);
253
+ const stored = store.read();
254
+ const found = stored.tokens.find((one) => one.kind === "access" && one.hash === hash(presented));
255
+ if (!found || found.expiresAt <= seconds)
256
+ throw new OAuthError(OAuthErrorCode.InvalidToken, "the token is unknown or expired");
257
+ const clientName = stored.clients.find((one) => one.id === found.clientId)?.name;
258
+ return {
259
+ token: presented,
260
+ clientId: found.clientId,
261
+ scopes: [],
262
+ expiresAt: found.expiresAt,
263
+ resource,
264
+ ...clientName ? { extra: { clientName } } : {}
265
+ };
266
+ }, "verifyAccessToken")
267
+ };
268
+ return {
269
+ code: /* @__PURE__ */ __name(() => login.value, "code"),
270
+ close: /* @__PURE__ */ __name(() => clearTimeout(renewal), "close"),
271
+ metadata,
272
+ verifier,
273
+ handle: /* @__PURE__ */ __name(async (request, path = new URL(request.url).pathname) => {
274
+ if (path === `${base}/register` && request.method === "POST")
275
+ return register(request);
276
+ if (path === `${base}/authorize` && (request.method === "GET" || request.method === "POST"))
277
+ return authorize(request);
278
+ if (path === `${base}/token` && request.method === "POST")
279
+ return token(request);
280
+ return void 0;
281
+ }, "handle")
282
+ };
283
+ }, "ownerLogin");
284
+
285
+ export {
286
+ revokeAll,
287
+ ownerLogin
288
+ };
@@ -0,0 +1,29 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ CliError,
5
+ singleLine
6
+ } from "./chunk-HM6AMYHR.js";
7
+ import {
8
+ __name
9
+ } from "./chunk-ZVVMGPBJ.js";
10
+
11
+ // 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/domain/tags.js
12
+ var TAG_TYPES = ["chat", "contact", "message", "task"];
13
+ var TAG = /^[a-z0-9-]{1,32}$/;
14
+ var tagOf = /* @__PURE__ */ __name((value) => {
15
+ const tag = value.trim().toLowerCase();
16
+ return TAG.test(tag) ? tag : void 0;
17
+ }, "tagOf");
18
+ var normalizeTag = /* @__PURE__ */ __name((value) => {
19
+ const tag = tagOf(value);
20
+ if (tag === void 0)
21
+ throw new CliError("validation_error", `"${singleLine(value)}" is not a tag \u2014 use 1\u201332 letters a\u2013z, digits and hyphens`, { reason: "tag.invalid" });
22
+ return tag;
23
+ }, "normalizeTag");
24
+
25
+ export {
26
+ TAG_TYPES,
27
+ tagOf,
28
+ normalizeTag
29
+ };