@wirecat/notion-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 (243) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/LICENSE +204 -0
  3. package/README.md +36 -2
  4. package/contracts/wirecat.json +1315 -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-OETMCOLN.js +278 -0
  10. package/dist/bundle/anthropic-5Y3O2TYM.js +91 -0
  11. package/dist/bundle/app-server-IVWBIVHC.js +231 -0
  12. package/dist/bundle/bun-EO636SAD.js +169 -0
  13. package/dist/bundle/bun-sqlite-C2T7QJ2M.js +76 -0
  14. package/dist/bundle/chunk-24FAYAML.js +52 -0
  15. package/dist/bundle/chunk-2YR3RYT4.js +73 -0
  16. package/dist/bundle/chunk-35K5T6WV.js +24 -0
  17. package/dist/bundle/chunk-3D3PFXBP.js +2315 -0
  18. package/dist/bundle/chunk-47R43UVJ.js +1068 -0
  19. package/dist/bundle/chunk-4GC5DBHW.js +100 -0
  20. package/dist/bundle/chunk-5D4AEUVA.js +24783 -0
  21. package/dist/bundle/chunk-64D5VUZ4.js +9564 -0
  22. package/dist/bundle/chunk-66PL7P4C.js +23 -0
  23. package/dist/bundle/chunk-7FII4DCE.js +362 -0
  24. package/dist/bundle/chunk-7N5QB6NL.js +156 -0
  25. package/dist/bundle/chunk-AE2KQ37N.js +95 -0
  26. package/dist/bundle/chunk-AQZO3ITW.js +58 -0
  27. package/dist/bundle/chunk-B2WFKFYL.js +1488 -0
  28. package/dist/bundle/chunk-B2XKEEFX.js +230 -0
  29. package/dist/bundle/chunk-B4B65XIO.js +73 -0
  30. package/dist/bundle/chunk-BWICUW7W.js +288 -0
  31. package/dist/bundle/chunk-CLG2ISQH.js +206 -0
  32. package/dist/bundle/chunk-CWVAYQXI.js +185 -0
  33. package/dist/bundle/chunk-D72URWJE.js +532 -0
  34. package/dist/bundle/chunk-DFDN6AUB.js +21 -0
  35. package/dist/bundle/chunk-DIM5YWBU.js +53 -0
  36. package/dist/bundle/chunk-EGTBL3MJ.js +6848 -0
  37. package/dist/bundle/chunk-EH6ZEJGT.js +932 -0
  38. package/dist/bundle/chunk-EPAZ7DJB.js +783 -0
  39. package/dist/bundle/chunk-ESZT4WW3.js +142 -0
  40. package/dist/bundle/chunk-EU5WCOMQ.js +4001 -0
  41. package/dist/bundle/chunk-F6MLJ3V5.js +72 -0
  42. package/dist/bundle/chunk-FF4DDBCB.js +1028 -0
  43. package/dist/bundle/chunk-GA3URWIF.js +46 -0
  44. package/dist/bundle/chunk-HRTIRRXR.js +3112 -0
  45. package/dist/bundle/chunk-HWRKURQH.js +54 -0
  46. package/dist/bundle/chunk-IQWEJEB5.js +39724 -0
  47. package/dist/bundle/chunk-JK44XO2S.js +392 -0
  48. package/dist/bundle/chunk-JKIN5TOU.js +131 -0
  49. package/dist/bundle/chunk-K5TWMQSY.js +188 -0
  50. package/dist/bundle/chunk-KHOVVPLC.js +18 -0
  51. package/dist/bundle/chunk-NLDYZBTC.js +5862 -0
  52. package/dist/bundle/chunk-OWJDC4CB.js +217 -0
  53. package/dist/bundle/chunk-QBC23NHD.js +38 -0
  54. package/dist/bundle/chunk-QC3KOJT4.js +300 -0
  55. package/dist/bundle/chunk-R6ZM45NF.js +1239 -0
  56. package/dist/bundle/chunk-RAZKIHGH.js +76 -0
  57. package/dist/bundle/chunk-RDZ7SVBZ.js +731 -0
  58. package/dist/bundle/chunk-RLSFOR2D.js +161 -0
  59. package/dist/bundle/chunk-RSIS7BR7.js +2778 -0
  60. package/dist/bundle/chunk-ST2UC7FS.js +1324 -0
  61. package/dist/bundle/chunk-TR7R5DL4.js +370 -0
  62. package/dist/bundle/chunk-TSCIIXN3.js +106 -0
  63. package/dist/bundle/chunk-UWIA2G6Q.js +12737 -0
  64. package/dist/bundle/chunk-UWW24JQF.js +66 -0
  65. package/dist/bundle/chunk-WK3OSDNV.js +1197 -0
  66. package/dist/bundle/chunk-WM7663C2.js +1221 -0
  67. package/dist/bundle/chunk-WVZFXI36.js +274 -0
  68. package/dist/bundle/chunk-WWMB4UHF.js +78 -0
  69. package/dist/bundle/chunk-XC5CKHX2.js +63 -0
  70. package/dist/bundle/chunk-XL2HXHP3.js +82 -0
  71. package/dist/bundle/chunk-XQUUANA2.js +24600 -0
  72. package/dist/bundle/chunk-XYIT2XB3.js +1372 -0
  73. package/dist/bundle/chunk-Y5E2WNWB.js +35 -0
  74. package/dist/bundle/chunk-YA4LSSDZ.js +64499 -0
  75. package/dist/bundle/chunk-ZI3YTXSF.js +2 -0
  76. package/dist/bundle/chunk-ZVVMGPBJ.js +50 -0
  77. package/dist/bundle/command-contract-6G5DC2FN.js +35 -0
  78. package/dist/bundle/command-server-entry-A66DJ3MH.js +164 -0
  79. package/dist/bundle/decode-7XOFRAAT.js +163 -0
  80. package/dist/bundle/definitions-M3U4UYHN.js +45607 -0
  81. package/dist/bundle/dispatch-FEKU5UXC.js +411 -0
  82. package/dist/bundle/dist-YFKABFFF.js +7577 -0
  83. package/dist/bundle/echarts-XD2JSWU4.js +42501 -0
  84. package/dist/bundle/embed-F3HYGAF7.js +38 -0
  85. package/dist/bundle/embedder-GSEDDUH7.js +111 -0
  86. package/dist/bundle/failure-HDJLR2YJ.js +25 -0
  87. package/dist/bundle/first-run-TXNTIUSP.js +28 -0
  88. package/dist/bundle/first-screen-JZPJND7J.js +33 -0
  89. package/dist/bundle/instructions-NZGJ4FW5.js +11 -0
  90. package/dist/bundle/mcp-VFIOZDVY.js +167 -0
  91. package/dist/bundle/node-KM3CUABH.js +2340 -0
  92. package/dist/bundle/node-RPKPDYQS.js +176 -0
  93. package/dist/bundle/node-TLZSIHIJ.js +21 -0
  94. package/dist/bundle/node-sqlite-KH2UUYVO.js +74 -0
  95. package/dist/bundle/notion.js +185 -0
  96. package/dist/bundle/oauth-NKAI7TQD.js +20 -0
  97. package/dist/bundle/open-WSAEAA2V.js +23 -0
  98. package/dist/bundle/openai-JPVDGHG5.js +238 -0
  99. package/dist/bundle/process-5ZFVKOQX.js +91 -0
  100. package/dist/bundle/program-M3D56D6T.js +28854 -0
  101. package/dist/bundle/prompt-FROYQ5LV.js +17 -0
  102. package/dist/bundle/recognize-NYCHQMCX.js +26 -0
  103. package/dist/bundle/remote-4OERF3Z4.js +32 -0
  104. package/dist/bundle/rerank-TEGXFUWY.js +52 -0
  105. package/dist/bundle/schemas-MZNNOEYN.js +12214 -0
  106. package/dist/bundle/serve-HLYYBAXY.js +199 -0
  107. package/dist/bundle/server-D5OYNEUW.js +193 -0
  108. package/dist/bundle/server-LWZGVMNW.js +62 -0
  109. package/dist/bundle/sqlite-runtime-H2S5RR2F.js +20 -0
  110. package/dist/bundle/state-OPOXCDZL.js +36 -0
  111. package/dist/bundle/store-NHMXEJPD.js +164 -0
  112. package/dist/bundle/store-Y3KRLCJ7.js +281 -0
  113. package/dist/bundle/store-maintenance-command-D4W7WSLQ.js +53 -0
  114. package/dist/commands/api.d.ts +4 -0
  115. package/dist/commands/api.d.ts.map +1 -0
  116. package/dist/commands/api.js +140 -0
  117. package/dist/commands/api.js.map +1 -0
  118. package/dist/commands/comments.d.ts +3 -0
  119. package/dist/commands/comments.d.ts.map +1 -0
  120. package/dist/commands/comments.js +114 -0
  121. package/dist/commands/comments.js.map +1 -0
  122. package/dist/commands/databases.d.ts +3 -0
  123. package/dist/commands/databases.d.ts.map +1 -0
  124. package/dist/commands/databases.js +65 -0
  125. package/dist/commands/databases.js.map +1 -0
  126. package/dist/commands/documents.d.ts +3 -0
  127. package/dist/commands/documents.d.ts.map +1 -0
  128. package/dist/commands/documents.js +41 -0
  129. package/dist/commands/documents.js.map +1 -0
  130. package/dist/commands/session.d.ts +3 -0
  131. package/dist/commands/session.d.ts.map +1 -0
  132. package/dist/commands/session.js +104 -0
  133. package/dist/commands/session.js.map +1 -0
  134. package/dist/config.d.ts +5 -0
  135. package/dist/config.d.ts.map +1 -0
  136. package/dist/config.js +13 -0
  137. package/dist/config.js.map +1 -0
  138. package/dist/context.d.ts +46 -0
  139. package/dist/context.d.ts.map +1 -0
  140. package/dist/context.js +58 -0
  141. package/dist/context.js.map +1 -0
  142. package/dist/generated/definitions.d.ts +3 -0
  143. package/dist/generated/definitions.d.ts.map +1 -0
  144. package/dist/generated/definitions.js +45603 -0
  145. package/dist/generated/definitions.js.map +1 -0
  146. package/dist/generated/manifest.d.ts +3 -0
  147. package/dist/generated/manifest.d.ts.map +1 -0
  148. package/dist/generated/manifest.js +2089 -0
  149. package/dist/generated/manifest.js.map +1 -0
  150. package/dist/generated/metadata.d.ts +6 -0
  151. package/dist/generated/metadata.d.ts.map +1 -0
  152. package/dist/generated/metadata.js +24 -0
  153. package/dist/generated/metadata.js.map +1 -0
  154. package/dist/generated/schemas.d.ts +1223 -0
  155. package/dist/generated/schemas.d.ts.map +1 -0
  156. package/dist/generated/schemas.js +11557 -0
  157. package/dist/generated/schemas.js.map +1 -0
  158. package/dist/generated/types.d.ts +11120 -0
  159. package/dist/generated/types.d.ts.map +1 -0
  160. package/dist/generated/types.js +5 -0
  161. package/dist/generated/types.js.map +1 -0
  162. package/dist/identity.d.ts +7 -0
  163. package/dist/identity.d.ts.map +1 -0
  164. package/dist/identity.js +29 -0
  165. package/dist/identity.js.map +1 -0
  166. package/dist/index.d.ts +3 -0
  167. package/dist/index.d.ts.map +1 -0
  168. package/dist/index.js +3 -0
  169. package/dist/index.js.map +1 -0
  170. package/dist/notion/client.d.ts +42 -0
  171. package/dist/notion/client.d.ts.map +1 -0
  172. package/dist/notion/client.js +118 -0
  173. package/dist/notion/client.js.map +1 -0
  174. package/dist/notion/errors.d.ts +24 -0
  175. package/dist/notion/errors.d.ts.map +1 -0
  176. package/dist/notion/errors.js +102 -0
  177. package/dist/notion/errors.js.map +1 -0
  178. package/dist/notion/ids.d.ts +7 -0
  179. package/dist/notion/ids.d.ts.map +1 -0
  180. package/dist/notion/ids.js +37 -0
  181. package/dist/notion/ids.js.map +1 -0
  182. package/dist/notion/links.d.ts +6 -0
  183. package/dist/notion/links.d.ts.map +1 -0
  184. package/dist/notion/links.js +22 -0
  185. package/dist/notion/links.js.map +1 -0
  186. package/dist/notion/notion.d.ts +95 -0
  187. package/dist/notion/notion.d.ts.map +1 -0
  188. package/dist/notion/notion.js +269 -0
  189. package/dist/notion/notion.js.map +1 -0
  190. package/dist/notion/port.d.ts +13 -0
  191. package/dist/notion/port.d.ts.map +1 -0
  192. package/dist/notion/port.js +60 -0
  193. package/dist/notion/port.js.map +1 -0
  194. package/dist/notion/read-posts.d.ts +36 -0
  195. package/dist/notion/read-posts.d.ts.map +1 -0
  196. package/dist/notion/read-posts.js +24 -0
  197. package/dist/notion/read-posts.js.map +1 -0
  198. package/dist/notion/reads.d.ts +327 -0
  199. package/dist/notion/reads.d.ts.map +1 -0
  200. package/dist/notion/reads.js +18 -0
  201. package/dist/notion/reads.js.map +1 -0
  202. package/dist/program.d.ts +6 -0
  203. package/dist/program.d.ts.map +1 -0
  204. package/dist/program.js +62 -0
  205. package/dist/program.js.map +1 -0
  206. package/dist/sample/comments.d.ts +61 -0
  207. package/dist/sample/comments.d.ts.map +1 -0
  208. package/dist/sample/comments.js +39 -0
  209. package/dist/sample/comments.js.map +1 -0
  210. package/dist/sample/records.d.ts +16 -0
  211. package/dist/sample/records.d.ts.map +1 -0
  212. package/dist/sample/records.js +22 -0
  213. package/dist/sample/records.js.map +1 -0
  214. package/dist/sample/transport.d.ts +42 -0
  215. package/dist/sample/transport.d.ts.map +1 -0
  216. package/dist/sample/transport.js +153 -0
  217. package/dist/sample/transport.js.map +1 -0
  218. package/dist/sync/cursor.d.ts +54 -0
  219. package/dist/sync/cursor.d.ts.map +1 -0
  220. package/dist/sync/cursor.js +52 -0
  221. package/dist/sync/cursor.js.map +1 -0
  222. package/dist/sync/front-matter.d.ts +10 -0
  223. package/dist/sync/front-matter.d.ts.map +1 -0
  224. package/dist/sync/front-matter.js +114 -0
  225. package/dist/sync/front-matter.js.map +1 -0
  226. package/dist/sync/markdown.d.ts +8 -0
  227. package/dist/sync/markdown.d.ts.map +1 -0
  228. package/dist/sync/markdown.js +40 -0
  229. package/dist/sync/markdown.js.map +1 -0
  230. package/dist/sync/source.d.ts +64 -0
  231. package/dist/sync/source.d.ts.map +1 -0
  232. package/dist/sync/source.js +634 -0
  233. package/dist/sync/source.js.map +1 -0
  234. package/dist/version.d.ts +2 -0
  235. package/dist/version.d.ts.map +1 -0
  236. package/dist/version.js +2 -0
  237. package/dist/version.js.map +1 -0
  238. package/dist/wcat.d.ts +3 -0
  239. package/dist/wcat.d.ts.map +1 -0
  240. package/dist/wcat.js +4 -0
  241. package/dist/wcat.js.map +1 -0
  242. package/package.json +85 -4
  243. package/skills/notion-cli/SKILL.md +34 -0
@@ -0,0 +1,206 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ singleLine
5
+ } from "./chunk-F6MLJ3V5.js";
6
+ import {
7
+ __name
8
+ } from "./chunk-ZVVMGPBJ.js";
9
+
10
+ // node_modules/.pnpm/@wirecat+cli-base@0.101.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/wcat/names.js
11
+ var FIRST_PARTY_TOOLS = [
12
+ { name: "tg", package: "@wirecat/tg-cli" },
13
+ { name: "max", package: "@wirecat/max-cli" },
14
+ { name: "wa", package: "@wirecat/whatsapp-cli" },
15
+ { name: "zm", package: "@wirecat/zoom-cli" },
16
+ { name: "drive", package: "@wirecat/drive-cli" },
17
+ { name: "memo", package: "@wirecat/cli-memo" },
18
+ { name: "mail", package: "@wirecat/mail-cli" },
19
+ // memo reads email today; the name is held for a tool of its own.
20
+ { name: "email" }
21
+ ];
22
+ var BUILT_IN_COMMANDS = ["help", "version", "shortcuts", "doctor", "update", "upgrade", "app"];
23
+ var RESERVED_NAMES = [
24
+ ...FIRST_PARTY_TOOLS.map((tool) => tool.name),
25
+ ...BUILT_IN_COMMANDS,
26
+ "wcat"
27
+ ];
28
+ var TOOL_NAME = /^[a-z][a-z0-9-]{0,39}$/;
29
+ var PROGRAM_PREFIX = "wcat-";
30
+ var DESCRIBE_FLAG = "--wcat-describe";
31
+ var DESCRIBE_MAX_BYTES = 64 * 1024;
32
+ var DISPATCH_FLAG = "--wcat-dispatch";
33
+
34
+ // node_modules/.pnpm/@wirecat+cli-base@0.101.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/wcat/describe.js
35
+ var DESCRIBE_FORMAT = 1;
36
+ var DESCRIBE_MANIFEST_FORMAT = 2;
37
+ var describeAnswer = /* @__PURE__ */ __name((tool, manifest) => {
38
+ const answer = {
39
+ wcat_describe: DESCRIBE_FORMAT,
40
+ name: tool.command,
41
+ version: tool.version,
42
+ description: tool.description,
43
+ ...tool.docs ? { docs_url: tool.docs } : {}
44
+ };
45
+ if (!manifest)
46
+ return answer;
47
+ const full = {
48
+ ...answer,
49
+ wcat_describe: DESCRIBE_MANIFEST_FORMAT,
50
+ desktop: manifest.desktop,
51
+ manifest_sha256: manifest.sha256
52
+ };
53
+ return Buffer.byteLength(`${JSON.stringify(full)}
54
+ `) > DESCRIBE_MAX_BYTES ? answer : full;
55
+ }, "describeAnswer");
56
+ var MAX_TEXT = 200;
57
+ var clean = /* @__PURE__ */ __name((value) => typeof value === "string" && value.trim() !== "" ? singleLine(value.trim()).slice(0, MAX_TEXT) : void 0, "clean");
58
+ var parseDescribe = /* @__PURE__ */ __name((text) => {
59
+ let answer;
60
+ try {
61
+ answer = JSON.parse(text);
62
+ } catch {
63
+ return void 0;
64
+ }
65
+ if (typeof answer !== "object" || answer === null || !("wcat_describe" in answer))
66
+ return void 0;
67
+ const { version, description, docs_url: docs, manifest_sha256: sha } = answer;
68
+ const url = clean(docs);
69
+ return {
70
+ version: clean(version) ?? "",
71
+ description: clean(description) ?? "",
72
+ ...url && /^https?:\/\//.test(url) ? { docs: url } : {},
73
+ ...typeof sha === "string" && /^[0-9a-f]{64}$/.test(sha) ? { manifestSha256: sha } : {}
74
+ };
75
+ }, "parseDescribe");
76
+
77
+ // node_modules/.pnpm/@wirecat+cli-base@0.101.0_commander@15.0.0_esbuild@0.28.2_typescript@7.0.2_vitest@5.0.5/node_modules/@wirecat/cli-base/dist/wcat/shim.js
78
+ import { lstatSync, readFileSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
79
+ import { join } from "node:path";
80
+ var SHIM_FORMAT = 2;
81
+ var MARK = /^(?:#|REM) wirecat-shim (\d+) (launcher|shortcut) (\S+)\r?$/m;
82
+ var NOTE = {
83
+ launcher: "Written by @wirecat/cli-base. Any WireCat tool rewrites it when it breaks; it is safe to delete.",
84
+ shortcut: "Made by `wcat shortcuts add`; `wcat shortcuts remove` takes it out."
85
+ };
86
+ var shellQuote = /* @__PURE__ */ __name((text) => `'${text.replaceAll("'", `'\\''`)}'`, "shellQuote");
87
+ var launcherBody = /* @__PURE__ */ __name((dir, target, name) => [
88
+ 'ok() { [ -f "$1" ] && [ -x "$1" ]; }',
89
+ `dir=${shellQuote(dir)}`,
90
+ `target=${shellQuote(join(dir, target))}`,
91
+ 'if ! ok "$target"; then',
92
+ ' for t in "$dir"/wcat-*; do',
93
+ ' if ok "$t"; then target=$t; break; fi',
94
+ " done",
95
+ "fi",
96
+ `if ok "$target"; then exec "$target" ${DISPATCH_FLAG} "$@"; fi`,
97
+ 'if [ -z "$WIRECAT_LAUNCHER_SKIP" ]; then',
98
+ " WIRECAT_LAUNCHER_SKIP=1; export WIRECAT_LAUNCHER_SKIP",
99
+ " set -f; oldifs=$IFS; IFS=:",
100
+ " for d in $PATH; do",
101
+ ` if [ -n "$d" ] && [ "$d" != "$dir" ] && ok "$d/${name}"; then IFS=$oldifs; exec "$d/${name}" "$@"; fi`,
102
+ " done",
103
+ " IFS=$oldifs; set +f",
104
+ "fi",
105
+ `printf '%s\\n' "${name}: $target is missing and no other ${name}-* program was found in $dir or on PATH." \\`,
106
+ ` "This launcher is safe to delete: $dir/${name}" >&2`,
107
+ "exit 127"
108
+ ], "launcherBody");
109
+ var shimFiles = /* @__PURE__ */ __name((kind, { dir, name, target, platform }) => {
110
+ const mark = `wirecat-shim ${SHIM_FORMAT} ${kind} ${target}`;
111
+ const extra = kind === "launcher" ? ` ${DISPATCH_FLAG}` : "";
112
+ if (platform !== "win32")
113
+ return [
114
+ {
115
+ path: join(dir, name),
116
+ text: [
117
+ "#!/bin/sh",
118
+ `# ${mark}`,
119
+ `# ${NOTE[kind]}`,
120
+ ...kind === "launcher" ? launcherBody(dir, target, name) : [`exec ${shellQuote(join(dir, target))} "$@"`],
121
+ ""
122
+ ].join("\n")
123
+ }
124
+ ];
125
+ return [
126
+ {
127
+ path: join(dir, `${name}.cmd`),
128
+ text: ["@ECHO off", `REM ${mark}`, `REM ${NOTE[kind]}`, `"%~dp0${target}"${extra} %*`, ""].join("\r\n")
129
+ },
130
+ {
131
+ path: join(dir, `${name}.ps1`),
132
+ text: [
133
+ `# ${mark}`,
134
+ `# ${NOTE[kind]}`,
135
+ // PowerShell hands a .cmd its arguments unquoted, so `a&b` would run `b`; npm and pnpm write a .ps1 beside
136
+ // their .cmd, and it is started instead whenever it is there.
137
+ `$stem = Join-Path $PSScriptRoot "${target.replace(/\.(cmd|exe|bat)$/i, "")}"`,
138
+ `$target = if (Test-Path -LiteralPath "$stem.ps1") { "$stem.ps1" } else { Join-Path $PSScriptRoot "${target}" }`,
139
+ "if ($MyInvocation.ExpectingInput) {",
140
+ ` $input | & $target${extra} @args`,
141
+ "} else {",
142
+ ` & $target${extra} @args`,
143
+ "}",
144
+ "exit $LASTEXITCODE",
145
+ ""
146
+ ].join("\r\n")
147
+ }
148
+ ];
149
+ }, "shimFiles");
150
+ var parseShim = /* @__PURE__ */ __name((text) => {
151
+ const found = MARK.exec(text.split("\n", 3).join("\n"));
152
+ if (!found)
153
+ return void 0;
154
+ return { format: Number(found[1]), kind: found[2], target: found[3] };
155
+ }, "parseShim");
156
+ var MAX_SHIM_BYTES = 4096;
157
+ var fileState = /* @__PURE__ */ __name((path) => {
158
+ let stat;
159
+ try {
160
+ stat = lstatSync(path);
161
+ } catch (error) {
162
+ return error.code === "ENOENT" ? { state: "missing" } : { state: "foreign" };
163
+ }
164
+ if (!stat.isFile() || stat.size > MAX_SHIM_BYTES)
165
+ return { state: "foreign" };
166
+ try {
167
+ const text = readFileSync(path, "utf8");
168
+ const mark = parseShim(text);
169
+ return mark ? { state: "ours", mark, text } : { state: "foreign" };
170
+ } catch {
171
+ return { state: "foreign" };
172
+ }
173
+ }, "fileState");
174
+ var exists = /* @__PURE__ */ __name((path) => {
175
+ try {
176
+ return statSync(path).isFile();
177
+ } catch {
178
+ return false;
179
+ }
180
+ }, "exists");
181
+ var writeShim = /* @__PURE__ */ __name(({ path, text }) => {
182
+ const temporary = `${path}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;
183
+ try {
184
+ writeFileSync(temporary, text, { mode: 493 });
185
+ renameSync(temporary, path);
186
+ } finally {
187
+ rmSync(temporary, { force: true });
188
+ }
189
+ }, "writeShim");
190
+
191
+ export {
192
+ FIRST_PARTY_TOOLS,
193
+ BUILT_IN_COMMANDS,
194
+ TOOL_NAME,
195
+ PROGRAM_PREFIX,
196
+ DESCRIBE_FLAG,
197
+ DESCRIBE_MAX_BYTES,
198
+ DISPATCH_FLAG,
199
+ describeAnswer,
200
+ parseDescribe,
201
+ SHIM_FORMAT,
202
+ shimFiles,
203
+ fileState,
204
+ exists,
205
+ writeShim
206
+ };
@@ -0,0 +1,185 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ PLAIN_HTTP_REFUSED,
5
+ modelAddressAllowed,
6
+ onThisComputer
7
+ } from "./chunk-2YR3RYT4.js";
8
+ import {
9
+ readSharedSection,
10
+ sharedConfigPath,
11
+ writeSharedSection
12
+ } from "./chunk-WK3OSDNV.js";
13
+ import {
14
+ unit
15
+ } from "./chunk-FF4DDBCB.js";
16
+ import {
17
+ storePath
18
+ } from "./chunk-HWRKURQH.js";
19
+ import {
20
+ boolean,
21
+ isoTimestamp,
22
+ pipe,
23
+ safeParse,
24
+ strictObject,
25
+ string
26
+ } from "./chunk-XYIT2XB3.js";
27
+ import {
28
+ CliError
29
+ } from "./chunk-F6MLJ3V5.js";
30
+ import {
31
+ __name
32
+ } from "./chunk-ZVVMGPBJ.js";
33
+
34
+ // node_modules/.pnpm/@wirecat+cli-core@0.663.0_@wirecat+cli-base@0.101.0_commander@15.0.0_esbuild@0.28.2_typ_8be6aa3a41727a76ce87cf0d5a7bd659/node_modules/@wirecat/cli-core/dist/embeddings/remote.js
35
+ import { setTimeout } from "node:timers/promises";
36
+
37
+ // node_modules/.pnpm/@wirecat+cli-core@0.663.0_@wirecat+cli-base@0.101.0_commander@15.0.0_esbuild@0.28.2_typ_8be6aa3a41727a76ce87cf0d5a7bd659/node_modules/@wirecat/cli-core/dist/models/local-only.js
38
+ var SECTION = "local_only";
39
+ var Setting = strictObject({
40
+ on: boolean(),
41
+ at: pipe(string(), isoTimestamp())
42
+ });
43
+ var pathOf = /* @__PURE__ */ __name((env) => sharedConfigPath(storePath(env), env), "pathOf");
44
+ var readLocalOnly = /* @__PURE__ */ __name((env) => {
45
+ const section = readSharedSection(pathOf(env), SECTION);
46
+ if (section === void 0 || section === null)
47
+ return void 0;
48
+ const checked = safeParse(Setting, section);
49
+ return checked.success ? checked.output : { on: true, at: (/* @__PURE__ */ new Date(0)).toISOString() };
50
+ }, "readLocalOnly");
51
+ var localOnly = /* @__PURE__ */ __name((env) => readLocalOnly(env)?.on === true, "localOnly");
52
+ var writeLocalOnly = /* @__PURE__ */ __name((env, on) => writeSharedSection(pathOf(env), SECTION, on ? { on: true, at: (/* @__PURE__ */ new Date()).toISOString() } : void 0), "writeLocalOnly");
53
+ var localOnlyRefusal = /* @__PURE__ */ __name((what, where) => new CliError("permission_error", `local only is on: ${what} would go to ${where}, which is not this computer; nothing was sent. Choose a model on this computer, or turn local only off with \`models local-only set off\``, { reason: "local-only.refused" }), "localOnlyRefusal");
54
+ var refuseOffComputer = /* @__PURE__ */ __name((env, address, what) => {
55
+ if (!onThisComputer(address) && localOnly(env))
56
+ throw localOnlyRefusal(what, hostOf(address));
57
+ }, "refuseOffComputer");
58
+ var hostOf = /* @__PURE__ */ __name((address) => {
59
+ try {
60
+ return new URL(address).host;
61
+ } catch {
62
+ return address;
63
+ }
64
+ }, "hostOf");
65
+ var refuseModelAddress = /* @__PURE__ */ __name((env, address, what) => {
66
+ if (!modelAddressAllowed(address))
67
+ throw new CliError("validation_error", PLAIN_HTTP_REFUSED, { reason: "model.address-refused" });
68
+ refuseOffComputer(env, address, what);
69
+ }, "refuseModelAddress");
70
+
71
+ // node_modules/.pnpm/@wirecat+cli-core@0.663.0_@wirecat+cli-base@0.101.0_commander@15.0.0_esbuild@0.28.2_typ_8be6aa3a41727a76ce87cf0d5a7bd659/node_modules/@wirecat/cli-core/dist/embeddings/remote.js
72
+ var OPENAI_URL = "https://api.openai.com/v1";
73
+ var OPENAI_MODELS = {
74
+ "text-embedding-3-small": { dims: 1536, perMillion: 0.02 },
75
+ "text-embedding-3-large": { dims: 3072, perMillion: 0.13 }
76
+ };
77
+ var DEFAULT_OPENAI_MODEL = "text-embedding-3-small";
78
+ var PER_REQUEST = 256;
79
+ var isLocal = /* @__PURE__ */ __name((baseUrl) => onThisComputer(baseUrl), "isLocal");
80
+ var remoteModel = /* @__PURE__ */ __name(({ model = DEFAULT_OPENAI_MODEL, baseUrl, dims }) => {
81
+ const known = baseUrl === void 0 ? OPENAI_MODELS[model] : void 0;
82
+ if (baseUrl === void 0 && !known) {
83
+ throw new CliError("validation_error", `OpenAI has no embedding model ${model} here \u2014 one of: ${Object.keys(OPENAI_MODELS).join(", ")}; another server takes --base-url`);
84
+ }
85
+ const size = dims ?? known?.dims;
86
+ if (size === void 0)
87
+ throw new CliError("validation_error", "with --base-url, say the vector size with --dims");
88
+ return {
89
+ provider: baseUrl === void 0 ? "openai" : `url:${new URL(baseUrl).host}`,
90
+ model,
91
+ dims: size,
92
+ baseUrl: baseUrl ?? OPENAI_URL,
93
+ shorten: known !== void 0 && size !== known.dims,
94
+ ...known ? { price: { perMillion: known.perMillion, read: "2026-10-02" } } : {}
95
+ };
96
+ }, "remoteModel");
97
+ var remoteKey = /* @__PURE__ */ __name(({ provider, model, dims }) => `${provider}:${model}:${dims}`, "remoteKey");
98
+ var openRemote = /* @__PURE__ */ __name((remote, apiKey, { concurrency = 4, fetch: post = fetch, tries = 5, env }) => {
99
+ refuseModelAddress(env ?? process.env, remote.baseUrl, "text to embed");
100
+ const request = /* @__PURE__ */ __name(async (input) => {
101
+ for (let attempt = 1; ; attempt++) {
102
+ let response;
103
+ try {
104
+ response = await post(`${remote.baseUrl.replace(/\/$/, "")}/embeddings`, {
105
+ method: "POST",
106
+ headers: {
107
+ "content-type": "application/json",
108
+ ...apiKey ? { authorization: `Bearer ${apiKey}` } : {}
109
+ },
110
+ body: JSON.stringify({
111
+ model: remote.model,
112
+ input,
113
+ encoding_format: "float",
114
+ ...remote.shorten ? { dimensions: remote.dims } : {}
115
+ })
116
+ });
117
+ } catch {
118
+ if (attempt >= tries)
119
+ throw new CliError("network_error", `${remote.provider} could not be reached`);
120
+ await setTimeout(1e3 * attempt);
121
+ continue;
122
+ }
123
+ if (response.ok) {
124
+ const body = await response.json();
125
+ const data = [...body.data ?? []].sort((a, b) => a.index - b.index);
126
+ if (data.length !== input.length || data.some(({ embedding }) => embedding.length !== remote.dims)) {
127
+ throw new CliError("invalid_response", `${remote.provider} answered with vectors of another number or size than ${input.length} \xD7 ${remote.dims}`);
128
+ }
129
+ return data.map(({ embedding }) => unit(Float32Array.from(embedding)));
130
+ }
131
+ const code = await errorCode(response);
132
+ if (response.status === 401 || response.status === 403) {
133
+ throw new CliError("authentication_error", `${remote.provider} refused the key (HTTP ${response.status}${code}) \u2014 set it again with \`models keys set\``);
134
+ }
135
+ const again = response.status === 429 || response.status >= 500;
136
+ if (!again || attempt >= tries) {
137
+ throw new CliError(response.status === 429 ? "rate_limited" : "provider_error", `${remote.provider} answered HTTP ${response.status}${code}`);
138
+ }
139
+ const wait = Number(response.headers.get("retry-after"));
140
+ await setTimeout(Number.isFinite(wait) && wait > 0 ? wait * 1e3 : 1e3 * 2 ** attempt);
141
+ }
142
+ }, "request");
143
+ return {
144
+ model: { id: remote.model, dims: remote.dims },
145
+ embed: /* @__PURE__ */ __name(async (texts) => {
146
+ const parts = [];
147
+ for (let start = 0; start < texts.length; start += PER_REQUEST)
148
+ parts.push(texts.slice(start, start + PER_REQUEST));
149
+ const results = new Array(parts.length);
150
+ let next = 0;
151
+ await Promise.all(Array.from({ length: Math.min(concurrency, parts.length) }, async () => {
152
+ for (let index = next++; index < parts.length; index = next++)
153
+ results[index] = await request(parts[index]);
154
+ }));
155
+ return results.flat();
156
+ }, "embed"),
157
+ close: /* @__PURE__ */ __name(async () => {
158
+ }, "close")
159
+ };
160
+ }, "openRemote");
161
+ var errorCode = /* @__PURE__ */ __name(async (response) => {
162
+ try {
163
+ const body = await response.json();
164
+ const code = body.error?.code ?? body.error?.type;
165
+ return typeof code === "string" && /^[\w.-]{1,64}$/.test(code) ? `, ${code}` : "";
166
+ } catch {
167
+ return "";
168
+ }
169
+ }, "errorCode");
170
+
171
+ export {
172
+ readLocalOnly,
173
+ localOnly,
174
+ writeLocalOnly,
175
+ localOnlyRefusal,
176
+ refuseOffComputer,
177
+ refuseModelAddress,
178
+ OPENAI_URL,
179
+ OPENAI_MODELS,
180
+ DEFAULT_OPENAI_MODEL,
181
+ isLocal,
182
+ remoteModel,
183
+ remoteKey,
184
+ openRemote
185
+ };