@wirecat/notion-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 (262) hide show
  1. package/CHANGELOG.md +73 -0
  2. package/LICENSE +204 -0
  3. package/README.md +42 -2
  4. package/contracts/wirecat.json +1964 -0
  5. package/dist/bin/notion.d.ts +3 -0
  6. package/dist/bin/notion.d.ts.map +1 -0
  7. package/dist/bin/notion.js +40 -0
  8. package/dist/bin/notion.js.map +1 -0
  9. package/dist/bundle/all-profiles-JGYLQZ5C.js +278 -0
  10. package/dist/bundle/anthropic-S2VSMIKQ.js +91 -0
  11. package/dist/bundle/app-server-SASYDBCA.js +240 -0
  12. package/dist/bundle/bun-LU5LP3JI.js +169 -0
  13. package/dist/bundle/bun-sqlite-JBSINB4O.js +76 -0
  14. package/dist/bundle/chunk-22QQUKWA.js +53 -0
  15. package/dist/bundle/chunk-2F4QQ7WB.js +73 -0
  16. package/dist/bundle/chunk-2F6VO5HA.js +73 -0
  17. package/dist/bundle/chunk-2LWO3PDX.js +726 -0
  18. package/dist/bundle/chunk-3AL7QUS3.js +2778 -0
  19. package/dist/bundle/chunk-3Z4YTSRY.js +731 -0
  20. package/dist/bundle/chunk-4HWJOU7N.js +38 -0
  21. package/dist/bundle/chunk-4IPURN72.js +1221 -0
  22. package/dist/bundle/chunk-4ZTVJHWU.js +206 -0
  23. package/dist/bundle/chunk-5D4AEUVA.js +24783 -0
  24. package/dist/bundle/chunk-5IYKVRH2.js +44811 -0
  25. package/dist/bundle/chunk-5NFK5EM2.js +362 -0
  26. package/dist/bundle/chunk-5QIQEUOG.js +188 -0
  27. package/dist/bundle/chunk-5RDNBG7D.js +72 -0
  28. package/dist/bundle/chunk-5RSC54NA.js +1328 -0
  29. package/dist/bundle/chunk-6EVKHZKN.js +158 -0
  30. package/dist/bundle/chunk-6RA3EABS.js +4012 -0
  31. package/dist/bundle/chunk-AOCUKEAX.js +131 -0
  32. package/dist/bundle/chunk-B26TQZKZ.js +217 -0
  33. package/dist/bundle/chunk-B7ON6KPT.js +1197 -0
  34. package/dist/bundle/chunk-BNPTZ5ZB.js +161 -0
  35. package/dist/bundle/chunk-D72URWJE.js +532 -0
  36. package/dist/bundle/chunk-D7QSEEYW.js +274 -0
  37. package/dist/bundle/chunk-DFDN6AUB.js +21 -0
  38. package/dist/bundle/chunk-DH5PRHT4.js +392 -0
  39. package/dist/bundle/chunk-EH6ZEJGT.js +932 -0
  40. package/dist/bundle/chunk-EUIVXFLJ.js +259 -0
  41. package/dist/bundle/chunk-FPY6EJ7B.js +9568 -0
  42. package/dist/bundle/chunk-FT3LN3HP.js +6848 -0
  43. package/dist/bundle/chunk-FWVBPRL4.js +4436 -0
  44. package/dist/bundle/chunk-FXEJY4OL.js +12538 -0
  45. package/dist/bundle/chunk-G3EZFRSS.js +1297 -0
  46. package/dist/bundle/chunk-GZOUFX3C.js +230 -0
  47. package/dist/bundle/chunk-HL52XXZX.js +78 -0
  48. package/dist/bundle/chunk-KCLOUUYF.js +100 -0
  49. package/dist/bundle/chunk-KFVDL2QS.js +146 -0
  50. package/dist/bundle/chunk-KGERXYTV.js +24 -0
  51. package/dist/bundle/chunk-KM6WHPHI.js +288 -0
  52. package/dist/bundle/chunk-LAYPFBOM.js +95 -0
  53. package/dist/bundle/chunk-LLG2POQ7.js +170 -0
  54. package/dist/bundle/chunk-M3KB25D3.js +1392 -0
  55. package/dist/bundle/chunk-M7S2NDWB.js +76 -0
  56. package/dist/bundle/chunk-MGUEZYFA.js +5546 -0
  57. package/dist/bundle/chunk-MY742GAD.js +1977 -0
  58. package/dist/bundle/chunk-MZU2YFBZ.js +823 -0
  59. package/dist/bundle/chunk-NOQ7B5N7.js +58 -0
  60. package/dist/bundle/chunk-NQWV4WQO.js +300 -0
  61. package/dist/bundle/chunk-ODBZNSZ6.js +1028 -0
  62. package/dist/bundle/chunk-OTV53F34.js +370 -0
  63. package/dist/bundle/chunk-P7CUM5IB.js +18 -0
  64. package/dist/bundle/chunk-RV64YUQX.js +185 -0
  65. package/dist/bundle/chunk-SHJQ6JKG.js +106 -0
  66. package/dist/bundle/chunk-SWAOWNKW.js +52 -0
  67. package/dist/bundle/chunk-SZOVLP44.js +29 -0
  68. package/dist/bundle/chunk-TPX2M45D.js +385 -0
  69. package/dist/bundle/chunk-TSDBSIFM.js +66 -0
  70. package/dist/bundle/chunk-VBHETQVV.js +64146 -0
  71. package/dist/bundle/chunk-VCIALTEM.js +3139 -0
  72. package/dist/bundle/chunk-VKE77B3F.js +2 -0
  73. package/dist/bundle/chunk-WCSOH4JS.js +142 -0
  74. package/dist/bundle/chunk-WF4D56CA.js +54 -0
  75. package/dist/bundle/chunk-WJHZMR2W.js +335 -0
  76. package/dist/bundle/chunk-X4TIMMKJ.js +16 -0
  77. package/dist/bundle/chunk-XF26XKTS.js +82 -0
  78. package/dist/bundle/chunk-XFLCVHSQ.js +50 -0
  79. package/dist/bundle/chunk-XQUUANA2.js +24600 -0
  80. package/dist/bundle/chunk-XYIT2XB3.js +1372 -0
  81. package/dist/bundle/chunk-Y5E2WNWB.js +35 -0
  82. package/dist/bundle/chunk-YMYUBZWT.js +1068 -0
  83. package/dist/bundle/chunk-YNTLT3Z3.js +2310 -0
  84. package/dist/bundle/chunk-YVI5SQPY.js +46 -0
  85. package/dist/bundle/chunk-Z56QFOBR.js +63 -0
  86. package/dist/bundle/chunk-ZKAEZXUP.js +787 -0
  87. package/dist/bundle/chunk-ZVVMGPBJ.js +50 -0
  88. package/dist/bundle/chunk-ZZ32DXTH.js +23 -0
  89. package/dist/bundle/command-contract-JS5V27NX.js +38 -0
  90. package/dist/bundle/command-server-entry-UFSG7KRO.js +167 -0
  91. package/dist/bundle/decode-7LLWTSPT.js +297 -0
  92. package/dist/bundle/definitions-M3U4UYHN.js +45607 -0
  93. package/dist/bundle/dispatch-2GY6JIJH.js +411 -0
  94. package/dist/bundle/dist-ILNOLGYN.js +7577 -0
  95. package/dist/bundle/echarts-BXX4OQWC.js +42501 -0
  96. package/dist/bundle/embed-JXFNBTKH.js +38 -0
  97. package/dist/bundle/embedder-57YZ44KO.js +111 -0
  98. package/dist/bundle/failure-MYT4HPE3.js +25 -0
  99. package/dist/bundle/first-run-3PF7T74J.js +29 -0
  100. package/dist/bundle/first-screen-7BEROEQR.js +36 -0
  101. package/dist/bundle/instructions-2VECIDXF.js +11 -0
  102. package/dist/bundle/mcp-O6ACR2DX.js +167 -0
  103. package/dist/bundle/mdast-util-from-markdown-R66F4HZA.js +1958 -0
  104. package/dist/bundle/mdast-util-gfm-LN2ELINH.js +2699 -0
  105. package/dist/bundle/meeting-combined-PPUQ3KBR.js +24 -0
  106. package/dist/bundle/meeting-model-ZNMYKMCD.js +26 -0
  107. package/dist/bundle/meeting-semantic-ETN3A4BJ.js +22 -0
  108. package/dist/bundle/micromark-extension-gfm-5X7YT43T.js +1838 -0
  109. package/dist/bundle/node-KM3CUABH.js +2340 -0
  110. package/dist/bundle/node-MPEQSFI3.js +176 -0
  111. package/dist/bundle/node-TLZSIHIJ.js +21 -0
  112. package/dist/bundle/node-sqlite-WA32MYSJ.js +74 -0
  113. package/dist/bundle/notion.js +185 -0
  114. package/dist/bundle/oauth-IAFZG3IR.js +20 -0
  115. package/dist/bundle/open-M3JQUC5G.js +23 -0
  116. package/dist/bundle/openai-HXUEHUSD.js +240 -0
  117. package/dist/bundle/process-F6TKXWWA.js +91 -0
  118. package/dist/bundle/program-Y7JAB6TG.js +33219 -0
  119. package/dist/bundle/prompt-IMUQLZD2.js +17 -0
  120. package/dist/bundle/recognize-2MZAYHAA.js +26 -0
  121. package/dist/bundle/remote-OV4LB6VR.js +32 -0
  122. package/dist/bundle/rerank-ZIULUS34.js +52 -0
  123. package/dist/bundle/schemas-DIVZS6TU.js +12214 -0
  124. package/dist/bundle/serve-YU7QBP6L.js +199 -0
  125. package/dist/bundle/server-FKQET4ZO.js +71 -0
  126. package/dist/bundle/server-LGMNONSB.js +202 -0
  127. package/dist/bundle/services-5WY4DCPJ.js +581 -0
  128. package/dist/bundle/sqlite-runtime-5MXZDETH.js +20 -0
  129. package/dist/bundle/state-LWMZH2KI.js +36 -0
  130. package/dist/bundle/store-EPZYV4VW.js +168 -0
  131. package/dist/bundle/store-QE6FEIZD.js +286 -0
  132. package/dist/bundle/store-maintenance-command-ZUUUFCHL.js +62 -0
  133. package/dist/commands/api.d.ts +4 -0
  134. package/dist/commands/api.d.ts.map +1 -0
  135. package/dist/commands/api.js +140 -0
  136. package/dist/commands/api.js.map +1 -0
  137. package/dist/commands/databases.d.ts +3 -0
  138. package/dist/commands/databases.d.ts.map +1 -0
  139. package/dist/commands/databases.js +65 -0
  140. package/dist/commands/databases.js.map +1 -0
  141. package/dist/commands/documents.d.ts +4 -0
  142. package/dist/commands/documents.d.ts.map +1 -0
  143. package/dist/commands/documents.js +41 -0
  144. package/dist/commands/documents.js.map +1 -0
  145. package/dist/commands/library.d.ts +10 -0
  146. package/dist/commands/library.d.ts.map +1 -0
  147. package/dist/commands/library.js +468 -0
  148. package/dist/commands/library.js.map +1 -0
  149. package/dist/commands/session.d.ts +3 -0
  150. package/dist/commands/session.d.ts.map +1 -0
  151. package/dist/commands/session.js +105 -0
  152. package/dist/commands/session.js.map +1 -0
  153. package/dist/config.d.ts +5 -0
  154. package/dist/config.d.ts.map +1 -0
  155. package/dist/config.js +13 -0
  156. package/dist/config.js.map +1 -0
  157. package/dist/context.d.ts +51 -0
  158. package/dist/context.d.ts.map +1 -0
  159. package/dist/context.js +67 -0
  160. package/dist/context.js.map +1 -0
  161. package/dist/generated/definitions.d.ts +3 -0
  162. package/dist/generated/definitions.d.ts.map +1 -0
  163. package/dist/generated/definitions.js +45603 -0
  164. package/dist/generated/definitions.js.map +1 -0
  165. package/dist/generated/manifest.d.ts +3 -0
  166. package/dist/generated/manifest.d.ts.map +1 -0
  167. package/dist/generated/manifest.js +2089 -0
  168. package/dist/generated/manifest.js.map +1 -0
  169. package/dist/generated/metadata.d.ts +6 -0
  170. package/dist/generated/metadata.d.ts.map +1 -0
  171. package/dist/generated/metadata.js +24 -0
  172. package/dist/generated/metadata.js.map +1 -0
  173. package/dist/generated/schemas.d.ts +1223 -0
  174. package/dist/generated/schemas.d.ts.map +1 -0
  175. package/dist/generated/schemas.js +11557 -0
  176. package/dist/generated/schemas.js.map +1 -0
  177. package/dist/generated/types.d.ts +11120 -0
  178. package/dist/generated/types.d.ts.map +1 -0
  179. package/dist/generated/types.js +5 -0
  180. package/dist/generated/types.js.map +1 -0
  181. package/dist/identity.d.ts +7 -0
  182. package/dist/identity.d.ts.map +1 -0
  183. package/dist/identity.js +30 -0
  184. package/dist/identity.js.map +1 -0
  185. package/dist/index.d.ts +3 -0
  186. package/dist/index.d.ts.map +1 -0
  187. package/dist/index.js +3 -0
  188. package/dist/index.js.map +1 -0
  189. package/dist/knowledge.d.ts +27 -0
  190. package/dist/knowledge.d.ts.map +1 -0
  191. package/dist/knowledge.js +87 -0
  192. package/dist/knowledge.js.map +1 -0
  193. package/dist/library.d.ts +44 -0
  194. package/dist/library.d.ts.map +1 -0
  195. package/dist/library.js +149 -0
  196. package/dist/library.js.map +1 -0
  197. package/dist/notion/client.d.ts +45 -0
  198. package/dist/notion/client.d.ts.map +1 -0
  199. package/dist/notion/client.js +121 -0
  200. package/dist/notion/client.js.map +1 -0
  201. package/dist/notion/errors.d.ts +24 -0
  202. package/dist/notion/errors.d.ts.map +1 -0
  203. package/dist/notion/errors.js +127 -0
  204. package/dist/notion/errors.js.map +1 -0
  205. package/dist/notion/ids.d.ts +7 -0
  206. package/dist/notion/ids.d.ts.map +1 -0
  207. package/dist/notion/ids.js +37 -0
  208. package/dist/notion/ids.js.map +1 -0
  209. package/dist/notion/links.d.ts +6 -0
  210. package/dist/notion/links.d.ts.map +1 -0
  211. package/dist/notion/links.js +22 -0
  212. package/dist/notion/links.js.map +1 -0
  213. package/dist/notion/notion.d.ts +95 -0
  214. package/dist/notion/notion.d.ts.map +1 -0
  215. package/dist/notion/notion.js +269 -0
  216. package/dist/notion/notion.js.map +1 -0
  217. package/dist/notion/port.d.ts +13 -0
  218. package/dist/notion/port.d.ts.map +1 -0
  219. package/dist/notion/port.js +60 -0
  220. package/dist/notion/port.js.map +1 -0
  221. package/dist/notion/read-posts.d.ts +36 -0
  222. package/dist/notion/read-posts.d.ts.map +1 -0
  223. package/dist/notion/read-posts.js +24 -0
  224. package/dist/notion/read-posts.js.map +1 -0
  225. package/dist/notion/reads.d.ts +331 -0
  226. package/dist/notion/reads.d.ts.map +1 -0
  227. package/dist/notion/reads.js +18 -0
  228. package/dist/notion/reads.js.map +1 -0
  229. package/dist/program.d.ts +6 -0
  230. package/dist/program.d.ts.map +1 -0
  231. package/dist/program.js +62 -0
  232. package/dist/program.js.map +1 -0
  233. package/dist/sync/cursor.d.ts +135 -0
  234. package/dist/sync/cursor.d.ts.map +1 -0
  235. package/dist/sync/cursor.js +113 -0
  236. package/dist/sync/cursor.js.map +1 -0
  237. package/dist/sync/files.d.ts +77 -0
  238. package/dist/sync/files.d.ts.map +1 -0
  239. package/dist/sync/files.js +12 -0
  240. package/dist/sync/files.js.map +1 -0
  241. package/dist/sync/front-matter.d.ts +10 -0
  242. package/dist/sync/front-matter.d.ts.map +1 -0
  243. package/dist/sync/front-matter.js +114 -0
  244. package/dist/sync/front-matter.js.map +1 -0
  245. package/dist/sync/markdown.d.ts +11 -0
  246. package/dist/sync/markdown.d.ts.map +1 -0
  247. package/dist/sync/markdown.js +42 -0
  248. package/dist/sync/markdown.js.map +1 -0
  249. package/dist/sync/source.d.ts +11 -0
  250. package/dist/sync/source.d.ts.map +1 -0
  251. package/dist/sync/source.js +995 -0
  252. package/dist/sync/source.js.map +1 -0
  253. package/dist/version.d.ts +2 -0
  254. package/dist/version.d.ts.map +1 -0
  255. package/dist/version.js +2 -0
  256. package/dist/version.js.map +1 -0
  257. package/dist/wcat.d.ts +3 -0
  258. package/dist/wcat.d.ts.map +1 -0
  259. package/dist/wcat.js +4 -0
  260. package/dist/wcat.js.map +1 -0
  261. package/package.json +85 -4
  262. package/skills/notion-cli/SKILL.md +45 -0
@@ -0,0 +1,50 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
10
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
11
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
12
+ }) : x)(function(x) {
13
+ if (typeof require !== "undefined") return require.apply(this, arguments);
14
+ throw Error('Dynamic require of "' + x + '" is not supported');
15
+ });
16
+ var __commonJS = (cb, mod) => function __require2() {
17
+ try {
18
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
19
+ } catch (e) {
20
+ throw mod = 0, e;
21
+ }
22
+ };
23
+ var __export = (target, all) => {
24
+ for (var name in all)
25
+ __defProp(target, name, { get: all[name], enumerable: true });
26
+ };
27
+ var __copyProps = (to, from, except, desc) => {
28
+ if (from && typeof from === "object" || typeof from === "function") {
29
+ for (let key of __getOwnPropNames(from))
30
+ if (!__hasOwnProp.call(to, key) && key !== except)
31
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
32
+ }
33
+ return to;
34
+ };
35
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
36
+ // If the importer is in node compatibility mode or this is not an ESM
37
+ // file that has been converted to a CommonJS file using a Babel-
38
+ // compatible transform (i.e. "__esModule" has not been set), then set
39
+ // "default" to the CommonJS "module.exports" for node compatibility.
40
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
41
+ mod
42
+ ));
43
+
44
+ export {
45
+ __name,
46
+ __require,
47
+ __commonJS,
48
+ __export,
49
+ __toESM
50
+ };
@@ -0,0 +1,23 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ __name
5
+ } from "./chunk-ZVVMGPBJ.js";
6
+
7
+ // node_modules/.pnpm/@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/installer.js
8
+ var installerOf = /* @__PURE__ */ __name((scriptPath) => {
9
+ const path = scriptPath.replaceAll("\\", "/");
10
+ if (path.includes("/_npx/"))
11
+ return "npx";
12
+ if (path.includes("/install/global/node_modules/"))
13
+ return "bun";
14
+ if (/\/\.?pnpm\//.test(path))
15
+ return "pnpm";
16
+ if (path.includes("/node_modules/"))
17
+ return "npm";
18
+ return path.includes("/dist/") ? "checkout" : "unknown";
19
+ }, "installerOf");
20
+
21
+ export {
22
+ installerOf
23
+ };
@@ -0,0 +1,38 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ SCHEMA_DIALECT,
5
+ commandContract,
6
+ commandPathOf,
7
+ findCommand,
8
+ outputOf
9
+ } from "./chunk-AOCUKEAX.js";
10
+ import "./chunk-FXEJY4OL.js";
11
+ import "./chunk-5NFK5EM2.js";
12
+ import "./chunk-SWAOWNKW.js";
13
+ import "./chunk-WJHZMR2W.js";
14
+ import "./chunk-Z56QFOBR.js";
15
+ import "./chunk-TSDBSIFM.js";
16
+ import "./chunk-MY742GAD.js";
17
+ import "./chunk-6EVKHZKN.js";
18
+ import "./chunk-SZOVLP44.js";
19
+ import "./chunk-FWVBPRL4.js";
20
+ import "./chunk-2F6VO5HA.js";
21
+ import "./chunk-B7ON6KPT.js";
22
+ import "./chunk-D7QSEEYW.js";
23
+ import "./chunk-VKE77B3F.js";
24
+ import "./chunk-NQWV4WQO.js";
25
+ import "./chunk-WF4D56CA.js";
26
+ import "./chunk-3AL7QUS3.js";
27
+ import "./chunk-4IPURN72.js";
28
+ import "./chunk-XYIT2XB3.js";
29
+ import "./chunk-Y5E2WNWB.js";
30
+ import "./chunk-5RDNBG7D.js";
31
+ import "./chunk-ZVVMGPBJ.js";
32
+ export {
33
+ SCHEMA_DIALECT,
34
+ commandContract,
35
+ commandPathOf,
36
+ findCommand,
37
+ outputOf
38
+ };
@@ -0,0 +1,167 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ COMMAND_SERVER_CONCURRENT,
5
+ enterCommandServer,
6
+ serveCommands
7
+ } from "./chunk-5QIQEUOG.js";
8
+ import "./chunk-P7CUM5IB.js";
9
+ import {
10
+ ensureSqlite
11
+ } from "./chunk-SHJQ6JKG.js";
12
+ import "./chunk-AOCUKEAX.js";
13
+ import {
14
+ commandServerRequest,
15
+ exitCodeSet,
16
+ inCommandServerRequest
17
+ } from "./chunk-FXEJY4OL.js";
18
+ import "./chunk-5NFK5EM2.js";
19
+ import "./chunk-SWAOWNKW.js";
20
+ import "./chunk-WJHZMR2W.js";
21
+ import "./chunk-Z56QFOBR.js";
22
+ import "./chunk-TSDBSIFM.js";
23
+ import {
24
+ asOwnProcess
25
+ } from "./chunk-MY742GAD.js";
26
+ import "./chunk-6EVKHZKN.js";
27
+ import "./chunk-SZOVLP44.js";
28
+ import "./chunk-FWVBPRL4.js";
29
+ import "./chunk-2F6VO5HA.js";
30
+ import "./chunk-B7ON6KPT.js";
31
+ import "./chunk-D7QSEEYW.js";
32
+ import "./chunk-VKE77B3F.js";
33
+ import "./chunk-NQWV4WQO.js";
34
+ import "./chunk-WF4D56CA.js";
35
+ import "./chunk-LAYPFBOM.js";
36
+ import "./chunk-4HWJOU7N.js";
37
+ import "./chunk-3AL7QUS3.js";
38
+ import {
39
+ catchCrashes
40
+ } from "./chunk-4IPURN72.js";
41
+ import "./chunk-XYIT2XB3.js";
42
+ import "./chunk-Y5E2WNWB.js";
43
+ import {
44
+ CliError
45
+ } from "./chunk-5RDNBG7D.js";
46
+ import {
47
+ __name
48
+ } from "./chunk-ZVVMGPBJ.js";
49
+
50
+ // node_modules/.pnpm/@wirecat+cli-core@0.673.0_@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typ_d24fa0f4f3b37e009a0e8224eb6a2687/node_modules/@wirecat/cli-core/dist/cli/command-server-entry.js
51
+ import { PassThrough } from "node:stream";
52
+ var route = /* @__PURE__ */ __name((stream, sink) => {
53
+ const original = stream.write;
54
+ stream.write = ((chunk, encoding, callback) => {
55
+ sink()(typeof chunk === "string" ? Buffer.from(chunk, typeof encoding === "string" ? encoding : "utf8") : Buffer.from(chunk));
56
+ const done = typeof encoding === "function" ? encoding : callback;
57
+ if (done)
58
+ process.nextTick(done);
59
+ return true;
60
+ });
61
+ return () => {
62
+ stream.write = original;
63
+ };
64
+ }, "route");
65
+ var closedStdin = /* @__PURE__ */ __name(() => {
66
+ const stdin = new PassThrough();
67
+ stdin.end();
68
+ return stdin;
69
+ }, "closedStdin");
70
+ var useStdin = /* @__PURE__ */ __name((outside) => Object.defineProperty(process, "stdin", {
71
+ get: /* @__PURE__ */ __name(() => commandServerRequest()?.stdin ?? outside, "get"),
72
+ configurable: true,
73
+ enumerable: true
74
+ }), "useStdin");
75
+ var roomFor = /* @__PURE__ */ __name((runs) => {
76
+ const emitters = [process, process.stdout, process.stderr];
77
+ const before = emitters.map((emitter) => emitter.getMaxListeners());
78
+ for (const emitter of emitters)
79
+ emitter.setMaxListeners(emitter.getMaxListeners() + 2 * runs);
80
+ return () => {
81
+ for (const [at, emitter] of emitters.entries())
82
+ emitter.setMaxListeners(before[at]);
83
+ };
84
+ }, "roomFor");
85
+ var serveEntry = /* @__PURE__ */ __name(async (entry, io, { firstRunAt, commanderExit }) => {
86
+ const release = catchCrashes({
87
+ cli: entry.app.command,
88
+ interactive: false,
89
+ ...entry.reasons ? { reasons: entry.reasons } : {},
90
+ target: io.signals
91
+ });
92
+ const stopper = new AbortController();
93
+ const stop = /* @__PURE__ */ __name(() => stopper.abort(new CliError("cancelled", "the command server was stopped", { retryable: false })), "stop");
94
+ const protocol = io.stdout.write.bind(io.stdout);
95
+ const ownStderr = io.stderr.write.bind(io.stderr);
96
+ const toStderr = /* @__PURE__ */ __name((chunk) => {
97
+ ownStderr(chunk);
98
+ }, "toStderr");
99
+ const sink = /* @__PURE__ */ __name((pick) => () => {
100
+ const request = commandServerRequest();
101
+ return request ? (chunk) => pick(request).push(chunk) : toStderr;
102
+ }, "sink");
103
+ const unrouteOut = route(process.stdout, sink((request) => request.stdout));
104
+ const unrouteErr = route(process.stderr, sink((request) => request.stderr));
105
+ const stdin = Object.getOwnPropertyDescriptor(process, "stdin");
106
+ const requests = io.stdin;
107
+ useStdin(closedStdin());
108
+ const unroom = roomFor(COMMAND_SERVER_CONCURRENT);
109
+ io.signals.on("SIGINT", stop).on("SIGTERM", stop);
110
+ io.stdout.on("error", stop);
111
+ const run = /* @__PURE__ */ __name(async (argv, alone) => {
112
+ const request = { stdout: [], stderr: [], stdin: closedStdin(), alone };
113
+ const requestIo = { ...io, argv: [...io.argv.slice(0, 2), ...argv], stdin: request.stdin };
114
+ const context = {
115
+ args: argv,
116
+ env: io.env,
117
+ tty: false,
118
+ signal: stopper.signal,
119
+ atStart: /* @__PURE__ */ __name(async (command) => {
120
+ await enterCommandServer(command, entry.app.command);
121
+ await firstRunAt(entry, requestIo, () => true)(command);
122
+ }, "atStart"),
123
+ ask: /* @__PURE__ */ __name(async () => false, "ask"),
124
+ openBrowser: /* @__PURE__ */ __name(async () => void 0, "openBrowser"),
125
+ outputClosed: /* @__PURE__ */ __name(() => false, "outputClosed"),
126
+ setExitCode: /* @__PURE__ */ __name((code2) => {
127
+ request.exitCode = code2;
128
+ }, "setExitCode")
129
+ };
130
+ const code = await inCommandServerRequest(request, () => asOwnProcess(async () => {
131
+ try {
132
+ const returned = await entry.run(context);
133
+ return typeof returned === "number" ? returned : exitCodeSet() ?? 0;
134
+ } catch (error) {
135
+ return commanderExit(error) ?? entry.fail(error, context);
136
+ }
137
+ }));
138
+ const text = /* @__PURE__ */ __name((chunks) => Buffer.concat(chunks).toString("utf8"), "text");
139
+ return { code, stdout: text(request.stdout), stderr: text(request.stderr) };
140
+ }, "run");
141
+ try {
142
+ if (entry.sqlite)
143
+ await ensureSqlite();
144
+ await serveCommands({
145
+ input: requests,
146
+ write: /* @__PURE__ */ __name((line) => new Promise((resolve) => protocol(line) ? resolve() : io.stdout.once("drain", resolve)), "write"),
147
+ run,
148
+ cli: entry.app.command,
149
+ concurrent: COMMAND_SERVER_CONCURRENT,
150
+ version: entry.app.version,
151
+ signal: stopper.signal
152
+ });
153
+ io.setExitCode(0);
154
+ } finally {
155
+ io.signals.off("SIGINT", stop).off("SIGTERM", stop);
156
+ unroom();
157
+ unrouteOut();
158
+ unrouteErr();
159
+ if (stdin)
160
+ Object.defineProperty(process, "stdin", stdin);
161
+ requests.destroy?.();
162
+ release();
163
+ }
164
+ }, "serveEntry");
165
+ export {
166
+ serveEntry
167
+ };
@@ -0,0 +1,297 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ SAMPLE_RATE,
5
+ decodeOgg
6
+ } from "./chunk-GZOUFX3C.js";
7
+ import "./chunk-3AL7QUS3.js";
8
+ import "./chunk-4IPURN72.js";
9
+ import "./chunk-XYIT2XB3.js";
10
+ import {
11
+ importFrom
12
+ } from "./chunk-Y5E2WNWB.js";
13
+ import {
14
+ CliError
15
+ } from "./chunk-5RDNBG7D.js";
16
+ import {
17
+ __name
18
+ } from "./chunk-ZVVMGPBJ.js";
19
+
20
+ // node_modules/.pnpm/@wirecat+cli-core@0.673.0_@wirecat+cli-base@0.102.1_commander@15.0.0_esbuild@0.28.2_typ_d24fa0f4f3b37e009a0e8224eb6a2687/node_modules/@wirecat/cli-core/dist/speech/decode.js
21
+ import { spawn } from "node:child_process";
22
+ import { mkdtemp, open, readFile, rm, writeFile } from "node:fs/promises";
23
+ import { createRequire } from "node:module";
24
+ import { tmpdir } from "node:os";
25
+ import { join } from "node:path";
26
+ import { pathToFileURL } from "node:url";
27
+ var LONGEST_AUDIO_SECONDS = 3600;
28
+ var FFMPEG_TIMEOUT_MS = 12e4;
29
+ var FFMPEG_FORMATS = "mov,mp4,m4a,3gp,3g2,mj2,aac,mp3,wav,amr,caf,aiff,flac,ogg,matroska,webm,asf";
30
+ var text = /* @__PURE__ */ __name((bytes, from, length) => String.fromCharCode(...bytes.subarray(from, from + length)), "text");
31
+ var contains = /* @__PURE__ */ __name((bytes, needle, within) => Buffer.from(bytes.buffer, bytes.byteOffset, Math.min(bytes.length, within)).includes(needle, 0, "latin1"), "contains");
32
+ var formatOf = /* @__PURE__ */ __name((bytes) => {
33
+ if (text(bytes, 0, 4) === "OggS") {
34
+ if (contains(bytes, "OpusHead", 128))
35
+ return "opus";
36
+ if (contains(bytes, "vorbis", 128))
37
+ return "vorbis";
38
+ return "other";
39
+ }
40
+ if (text(bytes, 0, 4) === "fLaC")
41
+ return "flac";
42
+ const frame = bytes[0] === 255 && ((bytes[1] ?? 0) & 224) === 224 && ((bytes[1] ?? 0) >> 1 & 3) !== 0;
43
+ if (text(bytes, 0, 3) === "ID3" || frame)
44
+ return "mp3";
45
+ return "other";
46
+ }, "formatOf");
47
+ var everyChannel = /* @__PURE__ */ __name((decoded) => {
48
+ if (!decoded.channelData[0] || decoded.samplesDecoded === 0)
49
+ throw new CliError("validation_error", "no audio in that file");
50
+ return decoded.channelData.map((samples) => ({ samples, rate: decoded.sampleRate }));
51
+ }, "everyChannel");
52
+ var load = /* @__PURE__ */ __name((name) => importFrom(new URL("speech/decode.js", import.meta.resolve("@wirecat/cli-core")).href, pathToFileURL(createRequire(new URL("speech/decode.js", import.meta.resolve("@wirecat/cli-core")).href).resolve(name)).href), "load");
53
+ var decodeVorbis = /* @__PURE__ */ __name(async (bytes) => {
54
+ const { OggVorbisDecoder } = await load("@wasm-audio-decoders/ogg-vorbis");
55
+ const decoder = new OggVorbisDecoder();
56
+ await decoder.ready;
57
+ try {
58
+ return everyChannel(await decoder.decodeFile(bytes));
59
+ } finally {
60
+ decoder.free();
61
+ }
62
+ }, "decodeVorbis");
63
+ var decodeFlac = /* @__PURE__ */ __name(async (bytes) => {
64
+ const { FLACDecoder } = await load("@wasm-audio-decoders/flac");
65
+ const decoder = new FLACDecoder();
66
+ await decoder.ready;
67
+ try {
68
+ return everyChannel(await decoder.decodeFile(bytes));
69
+ } finally {
70
+ decoder.free();
71
+ }
72
+ }, "decodeFlac");
73
+ var decodeMp3 = /* @__PURE__ */ __name(async (bytes) => {
74
+ const { MPEGDecoder } = await load("mpg123-decoder");
75
+ const decoder = new MPEGDecoder();
76
+ await decoder.ready;
77
+ try {
78
+ return everyChannel(decoder.decode(bytes));
79
+ } finally {
80
+ decoder.free();
81
+ }
82
+ }, "decodeMp3");
83
+ var tooLongError = /* @__PURE__ */ __name(() => new CliError("validation_error", `the audio is longer than ${LONGEST_AUDIO_SECONDS / 60} minutes`), "tooLongError");
84
+ var FLOAT = 3;
85
+ var LONGEST_HEADER = 64 * 1024;
86
+ var EXTENSIBLE = 65534;
87
+ var wavStream = /* @__PURE__ */ __name((most) => {
88
+ let head = Buffer.alloc(0);
89
+ let channels = 0;
90
+ let rate = 0;
91
+ let rest = Buffer.alloc(0);
92
+ let length = 0;
93
+ let parts = [];
94
+ const header = /* @__PURE__ */ __name(() => {
95
+ if (head.length < 12)
96
+ return false;
97
+ if (head.toString("latin1", 0, 4) !== "RIFF" || head.toString("latin1", 8, 12) !== "WAVE")
98
+ throw new CliError("validation_error", "ffmpeg did not answer with WAV audio");
99
+ for (let at = 12; at + 8 <= head.length; ) {
100
+ const id = head.toString("latin1", at, at + 4);
101
+ const size = head.readUInt32LE(at + 4);
102
+ if (id === "data") {
103
+ rest = head.subarray(at + 8);
104
+ head = Buffer.alloc(0);
105
+ return true;
106
+ }
107
+ if (at + 8 + size > head.length)
108
+ return false;
109
+ if (id === "fmt ") {
110
+ const tag = head.readUInt16LE(at + 8);
111
+ channels = head.readUInt16LE(at + 10);
112
+ rate = head.readUInt32LE(at + 12);
113
+ if (tag !== FLOAT && tag !== EXTENSIBLE || head.readUInt16LE(at + 22) !== 32 || channels < 1)
114
+ throw new CliError("validation_error", "ffmpeg did not answer with 32-bit float samples");
115
+ parts = Array.from({ length: channels }, () => []);
116
+ }
117
+ at += 8 + size + size % 2;
118
+ }
119
+ return false;
120
+ }, "header");
121
+ return {
122
+ push: /* @__PURE__ */ __name((chunk) => {
123
+ if (channels === 0 || head.length > 0) {
124
+ head = Buffer.concat([head, chunk]);
125
+ if (head.length > LONGEST_HEADER)
126
+ throw new CliError("validation_error", "ffmpeg's WAV header never ended");
127
+ if (!header())
128
+ return true;
129
+ chunk = Buffer.alloc(0);
130
+ }
131
+ const bytes = rest.length ? Buffer.concat([rest, chunk]) : chunk;
132
+ const frame = channels * 4;
133
+ const frames = Math.floor(bytes.length / frame);
134
+ rest = Buffer.from(bytes.subarray(frames * frame));
135
+ if (frames === 0)
136
+ return length <= most;
137
+ const view = new DataView(bytes.buffer, bytes.byteOffset, frames * frame);
138
+ for (let channel = 0; channel < channels; channel++) {
139
+ const samples = new Float32Array(frames);
140
+ for (let index = 0; index < frames; index++)
141
+ samples[index] = view.getFloat32(index * frame + channel * 4, true);
142
+ parts[channel]?.push(samples);
143
+ }
144
+ length += frames;
145
+ return length <= most;
146
+ }, "push"),
147
+ end: /* @__PURE__ */ __name(() => {
148
+ if (channels === 0)
149
+ throw new CliError("validation_error", "no audio in that file");
150
+ return parts.map((pieces, channel) => {
151
+ const samples = new Float32Array(length);
152
+ let at = 0;
153
+ for (const piece of pieces) {
154
+ samples.set(piece, at);
155
+ at += piece.length;
156
+ }
157
+ parts[channel] = [];
158
+ return { samples, rate };
159
+ });
160
+ }, "end")
161
+ };
162
+ }, "wavStream");
163
+ var runFfmpegFile = /* @__PURE__ */ __name((path) => new Promise((resolve, reject) => {
164
+ const child = spawn("ffmpeg", [
165
+ "-nostdin",
166
+ "-hide_banner",
167
+ "-loglevel",
168
+ "error",
169
+ "-protocol_whitelist",
170
+ "file",
171
+ "-format_whitelist",
172
+ FFMPEG_FORMATS,
173
+ "-i",
174
+ path,
175
+ "-vn",
176
+ "-af",
177
+ "aformat=channel_layouts=mono|stereo",
178
+ "-ar",
179
+ String(SAMPLE_RATE),
180
+ "-c:a",
181
+ "pcm_f32le",
182
+ "-bitexact",
183
+ "-f",
184
+ "wav",
185
+ "pipe:1"
186
+ ], { stdio: ["ignore", "pipe", "pipe"], timeout: FFMPEG_TIMEOUT_MS });
187
+ const wav = wavStream(LONGEST_AUDIO_SECONDS * SAMPLE_RATE);
188
+ let long = false;
189
+ let broken;
190
+ let errors = "";
191
+ child.stdout.on("data", (chunk) => {
192
+ if (long || broken)
193
+ return;
194
+ try {
195
+ long = !wav.push(chunk);
196
+ } catch (error) {
197
+ broken = error;
198
+ }
199
+ if (long || broken)
200
+ child.kill();
201
+ });
202
+ child.stderr.on("data", (chunk) => {
203
+ errors = (errors + chunk.toString()).slice(-500);
204
+ });
205
+ child.on("error", (error) => reject(error.code === "ENOENT" ? new CliError("validation_error", "only ffmpeg reads this audio format, and ffmpeg is not installed") : error));
206
+ child.on("close", (code) => {
207
+ if (long)
208
+ return reject(tooLongError());
209
+ if (broken)
210
+ return reject(broken);
211
+ if (code !== 0)
212
+ return reject(new CliError("validation_error", `ffmpeg could not read the audio: ${errors.trim() || code}`));
213
+ try {
214
+ resolve(wav.end());
215
+ } catch (error) {
216
+ reject(error);
217
+ }
218
+ });
219
+ }), "runFfmpegFile");
220
+ var runFfmpeg = /* @__PURE__ */ __name(async (bytes) => {
221
+ const directory = await mkdtemp(join(tmpdir(), "wirecat-audio-"));
222
+ try {
223
+ const input = join(directory, "audio");
224
+ await writeFile(input, bytes, { mode: 384 });
225
+ return await runFfmpegFile(input);
226
+ } finally {
227
+ await rm(directory, { recursive: true, force: true });
228
+ }
229
+ }, "runFfmpeg");
230
+ var BUNDLED = {
231
+ opus: decodeOgg,
232
+ vorbis: decodeVorbis,
233
+ flac: decodeFlac,
234
+ mp3: decodeMp3
235
+ };
236
+ var tooLong = /* @__PURE__ */ __name((pcm) => pcm.samples.length / pcm.rate > LONGEST_AUDIO_SECONDS, "tooLong");
237
+ var fromFfmpeg = /* @__PURE__ */ __name((answer) => Array.isArray(answer) ? { channels: answer, mixed: false } : { channels: [answer], mixed: true }, "fromFfmpeg");
238
+ var decodeChannels = /* @__PURE__ */ __name(async (bytes, ffmpeg = runFfmpeg) => {
239
+ const format = formatOf(bytes);
240
+ const decoded = format === "other" ? fromFfmpeg(await ffmpeg(bytes)) : await BUNDLED[format](bytes).then((channels) => ({ channels, mixed: false }), (error) => ffmpeg(bytes).then(fromFfmpeg, () => {
241
+ throw error;
242
+ }));
243
+ if (decoded.channels.length === 0)
244
+ throw new CliError("validation_error", "no audio in that file");
245
+ if (decoded.channels.some(tooLong))
246
+ throw tooLongError();
247
+ return decoded;
248
+ }, "decodeChannels");
249
+ var decodeChannelsFile = /* @__PURE__ */ __name(async (path, { maxBytes = 64 * 1024 * 1024, ffmpegFile = runFfmpegFile } = {}) => {
250
+ const file = await open(path, "r");
251
+ let start;
252
+ let size;
253
+ try {
254
+ size = (await file.stat()).size;
255
+ const head = Buffer.alloc(Math.min(size, 128));
256
+ await file.read(head, 0, head.length, 0);
257
+ start = head;
258
+ } finally {
259
+ await file.close();
260
+ }
261
+ if (formatOf(start) === "other") {
262
+ const channels = await ffmpegFile(path);
263
+ if (channels.some(tooLong))
264
+ throw tooLongError();
265
+ return { channels, mixed: false };
266
+ }
267
+ if (size > maxBytes)
268
+ throw new CliError("validation_error", `the audio file is larger than ${Math.round(maxBytes / 1024 / 1024)} MB`, {
269
+ reason: "file.too-large"
270
+ });
271
+ return decodeChannels(new Uint8Array(await readFile(path)), () => ffmpegFile(path));
272
+ }, "decodeChannelsFile");
273
+ var mixDown = /* @__PURE__ */ __name((channels) => {
274
+ const [first] = channels;
275
+ if (!first)
276
+ throw new CliError("validation_error", "no audio in that file");
277
+ if (channels.length === 1)
278
+ return first;
279
+ const length = channels.reduce((longest, { samples: samples2 }) => Math.max(longest, samples2.length), 0);
280
+ const samples = new Float32Array(length);
281
+ for (const channel of channels)
282
+ for (let index = 0; index < channel.samples.length; index++)
283
+ samples[index] = (samples[index] ?? 0) + (channel.samples[index] ?? 0) / channels.length;
284
+ return { samples, rate: first.rate };
285
+ }, "mixDown");
286
+ var decodeAudio = /* @__PURE__ */ __name(async (bytes, ffmpeg = runFfmpeg) => mixDown((await decodeChannels(bytes, ffmpeg)).channels), "decodeAudio");
287
+ export {
288
+ LONGEST_AUDIO_SECONDS,
289
+ decodeAudio,
290
+ decodeChannels,
291
+ decodeChannelsFile,
292
+ formatOf,
293
+ mixDown,
294
+ runFfmpeg,
295
+ runFfmpegFile,
296
+ wavStream
297
+ };