@wirecat/yandex-disk-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 (235) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/LICENSE +204 -0
  3. package/README.md +243 -2
  4. package/contracts/wirecat.json +1554 -0
  5. package/dist/bin/ydisk.d.ts +3 -0
  6. package/dist/bin/ydisk.d.ts.map +1 -0
  7. package/dist/bin/ydisk.js +40 -0
  8. package/dist/bin/ydisk.js.map +1 -0
  9. package/dist/bundle/all-profiles-4OLZF3RT.js +279 -0
  10. package/dist/bundle/anthropic-DKB4OJXZ.js +91 -0
  11. package/dist/bundle/app-server-G4545SSV.js +247 -0
  12. package/dist/bundle/bun-RXEQKFED.js +169 -0
  13. package/dist/bundle/bun-sqlite-VHT5LN7U.js +76 -0
  14. package/dist/bundle/chunk-2BITUXGC.js +12289 -0
  15. package/dist/bundle/chunk-2CLWDQKA.js +39330 -0
  16. package/dist/bundle/chunk-2JFDOPKA.js +9575 -0
  17. package/dist/bundle/chunk-3GVI2MAO.js +106 -0
  18. package/dist/bundle/chunk-3SZBWBMI.js +131 -0
  19. package/dist/bundle/chunk-44VSEXW6.js +4054 -0
  20. package/dist/bundle/chunk-4YPRRQBE.js +95 -0
  21. package/dist/bundle/chunk-5COYRL5B.js +379 -0
  22. package/dist/bundle/chunk-5D4AEUVA.js +24783 -0
  23. package/dist/bundle/chunk-5DM7DIZL.js +1402 -0
  24. package/dist/bundle/chunk-6R2DVTVZ.js +24 -0
  25. package/dist/bundle/chunk-762BS35H.js +2787 -0
  26. package/dist/bundle/chunk-AG64V7AB.js +1233 -0
  27. package/dist/bundle/chunk-BC5HGIXB.js +334 -0
  28. package/dist/bundle/chunk-BH7LFEX7.js +36 -0
  29. package/dist/bundle/chunk-BLNPGY7N.js +53 -0
  30. package/dist/bundle/chunk-CNIA2LJF.js +372 -0
  31. package/dist/bundle/chunk-COSXMDC7.js +230 -0
  32. package/dist/bundle/chunk-D72URWJE.js +532 -0
  33. package/dist/bundle/chunk-D7FO33KU.js +785 -0
  34. package/dist/bundle/chunk-DFDN6AUB.js +21 -0
  35. package/dist/bundle/chunk-DJH26PQ3.js +1396 -0
  36. package/dist/bundle/chunk-DJPT7IUC.js +64567 -0
  37. package/dist/bundle/chunk-DTMSCZDW.js +209 -0
  38. package/dist/bundle/chunk-E6LGZ5LX.js +16 -0
  39. package/dist/bundle/chunk-E6YRIHS5.js +92 -0
  40. package/dist/bundle/chunk-EH6ZEJGT.js +932 -0
  41. package/dist/bundle/chunk-F3DDSZTF.js +78 -0
  42. package/dist/bundle/chunk-F4WWTQNL.js +188 -0
  43. package/dist/bundle/chunk-FDDAUASC.js +1028 -0
  44. package/dist/bundle/chunk-FMNPG6N2.js +170 -0
  45. package/dist/bundle/chunk-FOKJ4POB.js +274 -0
  46. package/dist/bundle/chunk-G22C7JG6.js +731 -0
  47. package/dist/bundle/chunk-GA442SYZ.js +161 -0
  48. package/dist/bundle/chunk-GEBSW7UK.js +6848 -0
  49. package/dist/bundle/chunk-GGRKWAOK.js +594 -0
  50. package/dist/bundle/chunk-HHINRNZA.js +788 -0
  51. package/dist/bundle/chunk-HUZCL33L.js +128 -0
  52. package/dist/bundle/chunk-IALSIQVT.js +142 -0
  53. package/dist/bundle/chunk-IOXR2QBX.js +398 -0
  54. package/dist/bundle/chunk-J5CXR6VX.js +63 -0
  55. package/dist/bundle/chunk-J5PWSTOX.js +82 -0
  56. package/dist/bundle/chunk-J7BVAEHR.js +364 -0
  57. package/dist/bundle/chunk-JH46HMZW.js +1334 -0
  58. package/dist/bundle/chunk-JOBO7F6W.js +52 -0
  59. package/dist/bundle/chunk-JXZ5B3L5.js +2333 -0
  60. package/dist/bundle/chunk-KBIAMDZN.js +66 -0
  61. package/dist/bundle/chunk-KFVDL2QS.js +146 -0
  62. package/dist/bundle/chunk-LNHTLSR5.js +288 -0
  63. package/dist/bundle/chunk-M24RAKMJ.js +58 -0
  64. package/dist/bundle/chunk-MDQ57Q3H.js +1197 -0
  65. package/dist/bundle/chunk-MGUEZYFA.js +5546 -0
  66. package/dist/bundle/chunk-MLXQ4X5L.js +206 -0
  67. package/dist/bundle/chunk-NQAKARHE.js +54 -0
  68. package/dist/bundle/chunk-OF7VVUDQ.js +23 -0
  69. package/dist/bundle/chunk-OQVPE3XK.js +324 -0
  70. package/dist/bundle/chunk-OR3QG7UR.js +259 -0
  71. package/dist/bundle/chunk-OUUYVROP.js +76 -0
  72. package/dist/bundle/chunk-PQBAM64O.js +168 -0
  73. package/dist/bundle/chunk-PYVIA7WF.js +88 -0
  74. package/dist/bundle/chunk-Q6HK3PHE.js +72 -0
  75. package/dist/bundle/chunk-QB3KECV2.js +218 -0
  76. package/dist/bundle/chunk-QGWXSFYN.js +73 -0
  77. package/dist/bundle/chunk-RC5QAAAE.js +29 -0
  78. package/dist/bundle/chunk-RMJ26HLB.js +18 -0
  79. package/dist/bundle/chunk-S4UUN6LD.js +1410 -0
  80. package/dist/bundle/chunk-T7ZUDA4C.js +72 -0
  81. package/dist/bundle/chunk-TRCSMVV5.js +72 -0
  82. package/dist/bundle/chunk-UD2BQEKA.js +46 -0
  83. package/dist/bundle/chunk-V4TL55GS.js +1068 -0
  84. package/dist/bundle/chunk-VJNWN5VU.js +4072 -0
  85. package/dist/bundle/chunk-VRRNBLMA.js +1227 -0
  86. package/dist/bundle/chunk-WUCMMNFJ.js +771 -0
  87. package/dist/bundle/chunk-XDESE3NY.js +44 -0
  88. package/dist/bundle/chunk-XFLCVHSQ.js +50 -0
  89. package/dist/bundle/chunk-XQUUANA2.js +24600 -0
  90. package/dist/bundle/chunk-Y5E2WNWB.js +35 -0
  91. package/dist/bundle/chunk-Z2QEON7B.js +2275 -0
  92. package/dist/bundle/chunk-ZMJ56GME.js +7 -0
  93. package/dist/bundle/chunk-ZTSB3D7Q.js +100 -0
  94. package/dist/bundle/chunk-ZVJWD3FK.js +38 -0
  95. package/dist/bundle/chunk-ZVVMGPBJ.js +50 -0
  96. package/dist/bundle/command-contract-YIOYGPJA.js +40 -0
  97. package/dist/bundle/command-server-entry-MHBQDXS4.js +169 -0
  98. package/dist/bundle/decode-NUGJIOUW.js +297 -0
  99. package/dist/bundle/definitions-AILHKEQT.js +2005 -0
  100. package/dist/bundle/dispatch-5LC4UEGY.js +411 -0
  101. package/dist/bundle/dist-4I2W6X2I.js +7577 -0
  102. package/dist/bundle/echarts-MHSH6PGC.js +42501 -0
  103. package/dist/bundle/embed-ZDXTHHYS.js +38 -0
  104. package/dist/bundle/embedder-XFEELFUL.js +111 -0
  105. package/dist/bundle/failure-5S7VPBYK.js +25 -0
  106. package/dist/bundle/first-run-JHCHT3RJ.js +29 -0
  107. package/dist/bundle/first-screen-FHGQ6QRV.js +40 -0
  108. package/dist/bundle/instructions-WKSMBUFX.js +11 -0
  109. package/dist/bundle/mcp-HS2ZDUVR.js +167 -0
  110. package/dist/bundle/mdast-util-from-markdown-R66F4HZA.js +1958 -0
  111. package/dist/bundle/mdast-util-gfm-LN2ELINH.js +2699 -0
  112. package/dist/bundle/meeting-combined-K4U4NYRZ.js +25 -0
  113. package/dist/bundle/meeting-model-KCEG6Y5O.js +26 -0
  114. package/dist/bundle/meeting-semantic-VYGSV3H6.js +22 -0
  115. package/dist/bundle/micromark-extension-gfm-5X7YT43T.js +1838 -0
  116. package/dist/bundle/node-CM6NC6UE.js +176 -0
  117. package/dist/bundle/node-KM3CUABH.js +2340 -0
  118. package/dist/bundle/node-TLZSIHIJ.js +21 -0
  119. package/dist/bundle/node-sqlite-5YDQ3LIJ.js +74 -0
  120. package/dist/bundle/notes-search-PGO7KM2U.js +62 -0
  121. package/dist/bundle/oauth-NY4C5UCK.js +20 -0
  122. package/dist/bundle/open-YNUTA6ZE.js +23 -0
  123. package/dist/bundle/openai-4CVT5PHH.js +241 -0
  124. package/dist/bundle/process-2XT3TL27.js +91 -0
  125. package/dist/bundle/program-FMIVF5T6.js +31904 -0
  126. package/dist/bundle/prompt-VNWY3H6S.js +17 -0
  127. package/dist/bundle/recognize-JS4PBPSZ.js +26 -0
  128. package/dist/bundle/remote-RCLFH4V2.js +32 -0
  129. package/dist/bundle/rerank-EG6VKYGO.js +52 -0
  130. package/dist/bundle/schemas-ED2LHKXK.js +645 -0
  131. package/dist/bundle/serve-AHG25QXB.js +199 -0
  132. package/dist/bundle/server-5FTB7WM3.js +78 -0
  133. package/dist/bundle/server-JNZVSAZE.js +209 -0
  134. package/dist/bundle/sqlite-runtime-XSZOAQPF.js +20 -0
  135. package/dist/bundle/state-XGVAJFF7.js +36 -0
  136. package/dist/bundle/store-OHSCWZEV.js +177 -0
  137. package/dist/bundle/store-PKSPKJXL.js +293 -0
  138. package/dist/bundle/store-maintenance-command-KAWGBSWK.js +69 -0
  139. package/dist/bundle/ydisk.js +183 -0
  140. package/dist/commands/api.d.ts +9 -0
  141. package/dist/commands/api.d.ts.map +1 -0
  142. package/dist/commands/api.js +59 -0
  143. package/dist/commands/api.js.map +1 -0
  144. package/dist/commands/comments.d.ts +3 -0
  145. package/dist/commands/comments.d.ts.map +1 -0
  146. package/dist/commands/comments.js +114 -0
  147. package/dist/commands/comments.js.map +1 -0
  148. package/dist/commands/files.d.ts +3 -0
  149. package/dist/commands/files.d.ts.map +1 -0
  150. package/dist/commands/files.js +272 -0
  151. package/dist/commands/files.js.map +1 -0
  152. package/dist/commands/library.d.ts +13 -0
  153. package/dist/commands/library.d.ts.map +1 -0
  154. package/dist/commands/library.js +118 -0
  155. package/dist/commands/library.js.map +1 -0
  156. package/dist/commands/session.d.ts +3 -0
  157. package/dist/commands/session.d.ts.map +1 -0
  158. package/dist/commands/session.js +99 -0
  159. package/dist/commands/session.js.map +1 -0
  160. package/dist/config.d.ts +18 -0
  161. package/dist/config.d.ts.map +1 -0
  162. package/dist/config.js +62 -0
  163. package/dist/config.js.map +1 -0
  164. package/dist/context.d.ts +80 -0
  165. package/dist/context.d.ts.map +1 -0
  166. package/dist/context.js +77 -0
  167. package/dist/context.js.map +1 -0
  168. package/dist/generated/definitions.d.ts +3 -0
  169. package/dist/generated/definitions.d.ts.map +1 -0
  170. package/dist/generated/definitions.js +2001 -0
  171. package/dist/generated/definitions.js.map +1 -0
  172. package/dist/generated/manifest.d.ts +6 -0
  173. package/dist/generated/manifest.d.ts.map +1 -0
  174. package/dist/generated/manifest.js +1473 -0
  175. package/dist/generated/manifest.js.map +1 -0
  176. package/dist/generated/schemas.d.ts +127 -0
  177. package/dist/generated/schemas.d.ts.map +1 -0
  178. package/dist/generated/schemas.js +545 -0
  179. package/dist/generated/schemas.js.map +1 -0
  180. package/dist/generated/types.d.ts +829 -0
  181. package/dist/generated/types.d.ts.map +1 -0
  182. package/dist/generated/types.js +5 -0
  183. package/dist/generated/types.js.map +1 -0
  184. package/dist/identity.d.ts +10 -0
  185. package/dist/identity.d.ts.map +1 -0
  186. package/dist/identity.js +33 -0
  187. package/dist/identity.js.map +1 -0
  188. package/dist/index.d.ts +3 -0
  189. package/dist/index.d.ts.map +1 -0
  190. package/dist/index.js +3 -0
  191. package/dist/index.js.map +1 -0
  192. package/dist/program.d.ts +6 -0
  193. package/dist/program.d.ts.map +1 -0
  194. package/dist/program.js +65 -0
  195. package/dist/program.js.map +1 -0
  196. package/dist/sample/comments.d.ts +61 -0
  197. package/dist/sample/comments.d.ts.map +1 -0
  198. package/dist/sample/comments.js +39 -0
  199. package/dist/sample/comments.js.map +1 -0
  200. package/dist/sample/records.d.ts +16 -0
  201. package/dist/sample/records.d.ts.map +1 -0
  202. package/dist/sample/records.js +22 -0
  203. package/dist/sample/records.js.map +1 -0
  204. package/dist/sample/transport.d.ts +42 -0
  205. package/dist/sample/transport.d.ts.map +1 -0
  206. package/dist/sample/transport.js +153 -0
  207. package/dist/sample/transport.js.map +1 -0
  208. package/dist/version.d.ts +2 -0
  209. package/dist/version.d.ts.map +1 -0
  210. package/dist/version.js +2 -0
  211. package/dist/version.js.map +1 -0
  212. package/dist/wcat.d.ts +3 -0
  213. package/dist/wcat.d.ts.map +1 -0
  214. package/dist/wcat.js +4 -0
  215. package/dist/wcat.js.map +1 -0
  216. package/dist/yandex/source.d.ts +39 -0
  217. package/dist/yandex/source.d.ts.map +1 -0
  218. package/dist/yandex/source.js +189 -0
  219. package/dist/yandex/source.js.map +1 -0
  220. package/dist/yandex/transport.d.ts +41 -0
  221. package/dist/yandex/transport.d.ts.map +1 -0
  222. package/dist/yandex/transport.js +152 -0
  223. package/dist/yandex/transport.js.map +1 -0
  224. package/dist/yandex/writes.d.ts +27 -0
  225. package/dist/yandex/writes.d.ts.map +1 -0
  226. package/dist/yandex/writes.js +61 -0
  227. package/dist/yandex/writes.js.map +1 -0
  228. package/package.json +88 -4
  229. package/skills/yandex-disk-cli/SKILL.md +46 -0
  230. package/skills/yandex-disk-cli/references/api/api-disk-operations-operation-id.md +13 -0
  231. package/skills/yandex-disk-cli/references/api/api-disk-public-resources.md +50 -0
  232. package/skills/yandex-disk-cli/references/api/api-disk-resources.md +171 -0
  233. package/skills/yandex-disk-cli/references/api/api-disk-trash-resources.md +48 -0
  234. package/skills/yandex-disk-cli/references/api/api-disk.md +13 -0
  235. package/skills/yandex-disk-cli/references/api.md +17 -0
@@ -0,0 +1,199 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ listen
5
+ } from "./chunk-F3DDSZTF.js";
6
+ import {
7
+ ownerLogin
8
+ } from "./chunk-LNHTLSR5.js";
9
+ import {
10
+ WebStandardStreamableHTTPServerTransport,
11
+ createMcpHandler,
12
+ getOAuthProtectedResourceMetadataUrl,
13
+ hostHeaderValidationResponse,
14
+ isLegacyRequest,
15
+ oauthMetadataResponse,
16
+ requireBearerAuth
17
+ } from "./chunk-5D4AEUVA.js";
18
+ import {
19
+ activityRecorder,
20
+ calledTools,
21
+ httpActivityFile,
22
+ httpLock
23
+ } from "./chunk-GA442SYZ.js";
24
+ import "./chunk-QGWXSFYN.js";
25
+ import "./chunk-J5CXR6VX.js";
26
+ import "./chunk-762BS35H.js";
27
+ import "./chunk-AG64V7AB.js";
28
+ import "./chunk-S4UUN6LD.js";
29
+ import "./chunk-Y5E2WNWB.js";
30
+ import {
31
+ CliError
32
+ } from "./chunk-T7ZUDA4C.js";
33
+ import {
34
+ __name
35
+ } from "./chunk-ZVVMGPBJ.js";
36
+
37
+ // node_modules/.pnpm/@wirecat+cli-core@0.692.0_@wirecat+cli-base@0.110.0_@scalar+openapi-upgrader@0.4.6_comm_daa46dda8170ab81fe68d59b38277e40/node_modules/@wirecat/cli-core/dist/mcp/http/serve.js
38
+ import { randomUUID } from "node:crypto";
39
+ var MCP_PATH = "/mcp";
40
+ var AS_METADATA = "/.well-known/oauth-authorization-server";
41
+ var LOCAL = ["localhost", "127.0.0.1"];
42
+ var MAX_SESSIONS = 20;
43
+ var MAX_LOGIN_BODY = 64 * 1024;
44
+ var SESSION_IDLE_MS = 60 * 60 * 1e3;
45
+ var sessionMissing = /* @__PURE__ */ __name(() => new Response(JSON.stringify({ jsonrpc: "2.0", error: { code: -32001, message: "Session not found" }, id: null }), {
46
+ status: 404,
47
+ headers: { "content-type": "application/json" }
48
+ }), "sessionMissing");
49
+ var legacySessions = /* @__PURE__ */ __name((build, now) => {
50
+ const sessions = /* @__PURE__ */ new Map();
51
+ const drop = /* @__PURE__ */ __name(async (id) => {
52
+ const one = sessions.get(id);
53
+ sessions.delete(id);
54
+ await one?.close();
55
+ }, "drop");
56
+ const handle = /* @__PURE__ */ __name(async (request, auth) => {
57
+ for (const [id2, one] of sessions)
58
+ if (now() - one.seen > SESSION_IDLE_MS)
59
+ await drop(id2);
60
+ const id = request.headers.get("mcp-session-id");
61
+ if (id) {
62
+ const known = sessions.get(id);
63
+ if (!known || known.clientId !== auth.clientId)
64
+ return sessionMissing();
65
+ known.seen = now();
66
+ return known.transport.handleRequest(request, { authInfo: auth });
67
+ }
68
+ const server = build();
69
+ const transport = new WebStandardStreamableHTTPServerTransport({
70
+ sessionIdGenerator: /* @__PURE__ */ __name(() => randomUUID(), "sessionIdGenerator"),
71
+ onsessionclosed: /* @__PURE__ */ __name((closed) => void sessions.delete(closed), "onsessionclosed")
72
+ });
73
+ await server.connect(transport);
74
+ const response = await transport.handleRequest(request, { authInfo: auth });
75
+ if (!transport.sessionId) {
76
+ await server.close();
77
+ return response;
78
+ }
79
+ sessions.set(transport.sessionId, { transport, close: /* @__PURE__ */ __name(() => server.close(), "close"), clientId: auth.clientId, seen: now() });
80
+ while (sessions.size > MAX_SESSIONS)
81
+ await drop(sessions.keys().next().value);
82
+ return response;
83
+ }, "handle");
84
+ return {
85
+ handle,
86
+ close: /* @__PURE__ */ __name(async () => {
87
+ for (const id of [...sessions.keys()])
88
+ await drop(id);
89
+ }, "close")
90
+ };
91
+ }, "legacySessions");
92
+ var metadataRequest = /* @__PURE__ */ __name((request, path, base) => {
93
+ const url = new URL(request.url);
94
+ const inserted = base && path === `${AS_METADATA}${base}`;
95
+ if (!inserted && url.pathname === path)
96
+ return request;
97
+ url.pathname = inserted ? AS_METADATA : path;
98
+ return new Request(url, { method: request.method, headers: request.headers });
99
+ }, "metadataRequest");
100
+ var toolsIn = /* @__PURE__ */ __name(async (request) => {
101
+ if (request.method !== "POST")
102
+ return [];
103
+ try {
104
+ return calledTools(await request.clone().json());
105
+ } catch {
106
+ return [];
107
+ }
108
+ }, "toolsIn");
109
+ var serveOverHttp = /* @__PURE__ */ __name(async (build, options) => {
110
+ const { publicUrl, port, tokenFile, appName, reaches, onCode, onError, now, lockFile, version } = options;
111
+ const lock = lockFile ? httpLock(lockFile, {
112
+ pid: process.pid,
113
+ startedAt: (/* @__PURE__ */ new Date()).toISOString(),
114
+ port,
115
+ publicUrl: publicUrl.href,
116
+ ...version ? { version } : {}
117
+ }) : void 0;
118
+ if (lock?.held)
119
+ throw new CliError("validation_error", `${appName} already serves MCP over HTTP for this profile on port ${lock.held.port} (PID ${lock.held.pid}, since ${lock.held.startedAt})`);
120
+ const base = publicUrl.pathname === "/" ? "" : publicUrl.pathname.replace(/\/+$/, "");
121
+ const issuer = new URL(`${publicUrl.origin}${base}`);
122
+ const resource = new URL(`${base}${MCP_PATH}`, publicUrl.origin);
123
+ const mcpPath = resource.pathname;
124
+ const publicPath = /* @__PURE__ */ __name((path) => base && path !== base && !path.startsWith(`${base}/`) && !path.startsWith("/.well-known/") ? `${base}${path}` : path, "publicPath");
125
+ const login = ownerLogin({
126
+ issuer,
127
+ resource,
128
+ file: tokenFile,
129
+ appName,
130
+ ...reaches ? { reaches } : {},
131
+ onCode: /* @__PURE__ */ __name((code, expires) => {
132
+ lock?.update({ loginCode: code, loginCodeExpiresAt: expires.toISOString() });
133
+ onCode(code, expires);
134
+ }, "onCode"),
135
+ ...now ? { now } : {}
136
+ });
137
+ const insecure = issuer.protocol === "http:" && LOCAL.includes(issuer.hostname);
138
+ const mcp = createMcpHandler(build, { legacy: "reject", ...onError ? { onerror: onError } : {} });
139
+ const legacy = legacySessions(build, now ?? Date.now);
140
+ const bearer = requireBearerAuth({
141
+ verifier: login.verifier,
142
+ resourceMetadataUrl: getOAuthProtectedResourceMetadataUrl(resource)
143
+ });
144
+ const activity = activityRecorder(httpActivityFile(tokenFile), now);
145
+ const allowedHosts = [.../* @__PURE__ */ new Set([publicUrl.hostname, ...LOCAL])];
146
+ const allowedOrigins = [publicUrl.origin];
147
+ const listening = await listen(async (request) => {
148
+ const refused = hostHeaderValidationResponse(request, allowedHosts);
149
+ if (refused)
150
+ return refused;
151
+ const path = publicPath(new URL(request.url).pathname);
152
+ const discovery = oauthMetadataResponse(metadataRequest(request, path, base), {
153
+ oauthMetadata: login.metadata,
154
+ resourceServerUrl: resource,
155
+ resourceName: appName,
156
+ ...insecure ? { dangerouslyAllowInsecureIssuerUrl: true } : {}
157
+ });
158
+ if (discovery)
159
+ return discovery;
160
+ if (Number(request.headers.get("content-length") ?? 0) > MAX_LOGIN_BODY && path !== mcpPath)
161
+ return new Response("Request too large", { status: 413 });
162
+ const origin = request.headers.get("origin");
163
+ if (origin && !allowedOrigins.includes(origin))
164
+ return new Response("Origin not allowed", { status: 403 });
165
+ const answered = await login.handle(request, path);
166
+ if (answered)
167
+ return answered;
168
+ if (path !== mcpPath)
169
+ return new Response("Not found", { status: 404 });
170
+ const auth = await bearer(request);
171
+ if (auth instanceof Response)
172
+ return auth;
173
+ activity.record(auth.clientId, await toolsIn(request));
174
+ return await isLegacyRequest(request) ? legacy.handle(request, auth) : mcp.fetch(request, { authInfo: auth });
175
+ }, { host: "127.0.0.1", port }).catch((error) => {
176
+ login.close();
177
+ lock?.release();
178
+ throw error;
179
+ });
180
+ lock?.update({ listeningAt: (/* @__PURE__ */ new Date()).toISOString() });
181
+ return {
182
+ url: listening.url,
183
+ close: /* @__PURE__ */ __name(async () => {
184
+ login.close();
185
+ activity.flush();
186
+ try {
187
+ await listening.close();
188
+ await legacy.close();
189
+ await mcp.close();
190
+ } finally {
191
+ lock?.release();
192
+ }
193
+ }, "close")
194
+ };
195
+ }, "serveOverHttp");
196
+ export {
197
+ MCP_PATH,
198
+ serveOverHttp
199
+ };
@@ -0,0 +1,78 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ PER_RUN,
5
+ createServer,
6
+ envelope,
7
+ serveOverHttpUntilStopped,
8
+ serveOverStdio
9
+ } from "./chunk-HHINRNZA.js";
10
+ import "./chunk-JH46HMZW.js";
11
+ import "./chunk-RMJ26HLB.js";
12
+ import "./chunk-44VSEXW6.js";
13
+ import "./chunk-5DM7DIZL.js";
14
+ import "./chunk-G22C7JG6.js";
15
+ import "./chunk-DJH26PQ3.js";
16
+ import "./chunk-2CLWDQKA.js";
17
+ import "./chunk-5COYRL5B.js";
18
+ import "./chunk-J5PWSTOX.js";
19
+ import "./chunk-PYVIA7WF.js";
20
+ import "./chunk-IALSIQVT.js";
21
+ import "./chunk-UD2BQEKA.js";
22
+ import "./chunk-BLNPGY7N.js";
23
+ import "./chunk-5D4AEUVA.js";
24
+ import "./chunk-Z2QEON7B.js";
25
+ import "./chunk-BH7LFEX7.js";
26
+ import "./chunk-OUUYVROP.js";
27
+ import "./chunk-OR3QG7UR.js";
28
+ import "./chunk-DTMSCZDW.js";
29
+ import "./chunk-PQBAM64O.js";
30
+ import "./chunk-FMNPG6N2.js";
31
+ import "./chunk-GA442SYZ.js";
32
+ import "./chunk-QGWXSFYN.js";
33
+ import "./chunk-3SZBWBMI.js";
34
+ import "./chunk-2BITUXGC.js";
35
+ import "./chunk-J7BVAEHR.js";
36
+ import "./chunk-JOBO7F6W.js";
37
+ import "./chunk-IOXR2QBX.js";
38
+ import "./chunk-BC5HGIXB.js";
39
+ import "./chunk-J5CXR6VX.js";
40
+ import "./chunk-V4TL55GS.js";
41
+ import "./chunk-KBIAMDZN.js";
42
+ import "./chunk-DJPT7IUC.js";
43
+ import "./chunk-GGRKWAOK.js";
44
+ import "./chunk-JXZ5B3L5.js";
45
+ import "./chunk-WUCMMNFJ.js";
46
+ import "./chunk-E6LGZ5LX.js";
47
+ import "./chunk-D7FO33KU.js";
48
+ import "./chunk-E6YRIHS5.js";
49
+ import "./chunk-VRRNBLMA.js";
50
+ import "./chunk-TRCSMVV5.js";
51
+ import "./chunk-RC5QAAAE.js";
52
+ import "./chunk-VJNWN5VU.js";
53
+ import "./chunk-ZMJ56GME.js";
54
+ import "./chunk-HUZCL33L.js";
55
+ import "./chunk-Q6HK3PHE.js";
56
+ import "./chunk-CNIA2LJF.js";
57
+ import "./chunk-MDQ57Q3H.js";
58
+ import "./chunk-FDDAUASC.js";
59
+ import "./chunk-FOKJ4POB.js";
60
+ import "./chunk-OF7VVUDQ.js";
61
+ import "./chunk-D72URWJE.js";
62
+ import "./chunk-NQAKARHE.js";
63
+ import "./chunk-4YPRRQBE.js";
64
+ import "./chunk-ZVJWD3FK.js";
65
+ import "./chunk-762BS35H.js";
66
+ import "./chunk-AG64V7AB.js";
67
+ import "./chunk-S4UUN6LD.js";
68
+ import "./chunk-Y5E2WNWB.js";
69
+ import "./chunk-T7ZUDA4C.js";
70
+ import "./chunk-GEBSW7UK.js";
71
+ import "./chunk-ZVVMGPBJ.js";
72
+ export {
73
+ PER_RUN,
74
+ createServer,
75
+ envelope,
76
+ serveOverHttpUntilStopped,
77
+ serveOverStdio
78
+ };
@@ -0,0 +1,209 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ botInstructions
5
+ } from "./chunk-6R2DVTVZ.js";
6
+ import {
7
+ answered,
8
+ normal,
9
+ registerCommands,
10
+ runCommandForAgent,
11
+ toolsFromCommands
12
+ } from "./chunk-44VSEXW6.js";
13
+ import {
14
+ agentJson,
15
+ skillResources
16
+ } from "./chunk-5DM7DIZL.js";
17
+ import {
18
+ StdioServerTransport,
19
+ answeredWire,
20
+ callerOf,
21
+ serveStdio
22
+ } from "./chunk-G22C7JG6.js";
23
+ import {
24
+ wholeList
25
+ } from "./chunk-2CLWDQKA.js";
26
+ import "./chunk-5COYRL5B.js";
27
+ import "./chunk-J5PWSTOX.js";
28
+ import "./chunk-PYVIA7WF.js";
29
+ import "./chunk-IALSIQVT.js";
30
+ import "./chunk-UD2BQEKA.js";
31
+ import {
32
+ McpServer
33
+ } from "./chunk-5D4AEUVA.js";
34
+ import "./chunk-Z2QEON7B.js";
35
+ import "./chunk-BH7LFEX7.js";
36
+ import "./chunk-OUUYVROP.js";
37
+ import "./chunk-OR3QG7UR.js";
38
+ import "./chunk-DTMSCZDW.js";
39
+ import "./chunk-PQBAM64O.js";
40
+ import "./chunk-FMNPG6N2.js";
41
+ import {
42
+ changesMessenger,
43
+ flatten,
44
+ itemOf
45
+ } from "./chunk-2BITUXGC.js";
46
+ import "./chunk-J7BVAEHR.js";
47
+ import "./chunk-JOBO7F6W.js";
48
+ import {
49
+ MESSENGER_CHANGE_REFUSAL,
50
+ readOnlyLockOf,
51
+ readOnlyRefusal
52
+ } from "./chunk-IOXR2QBX.js";
53
+ import "./chunk-BC5HGIXB.js";
54
+ import "./chunk-J5CXR6VX.js";
55
+ import "./chunk-V4TL55GS.js";
56
+ import "./chunk-KBIAMDZN.js";
57
+ import "./chunk-DJPT7IUC.js";
58
+ import "./chunk-GGRKWAOK.js";
59
+ import "./chunk-JXZ5B3L5.js";
60
+ import "./chunk-WUCMMNFJ.js";
61
+ import "./chunk-E6LGZ5LX.js";
62
+ import "./chunk-D7FO33KU.js";
63
+ import "./chunk-E6YRIHS5.js";
64
+ import "./chunk-VRRNBLMA.js";
65
+ import "./chunk-TRCSMVV5.js";
66
+ import "./chunk-RC5QAAAE.js";
67
+ import "./chunk-VJNWN5VU.js";
68
+ import "./chunk-ZMJ56GME.js";
69
+ import "./chunk-HUZCL33L.js";
70
+ import "./chunk-Q6HK3PHE.js";
71
+ import "./chunk-CNIA2LJF.js";
72
+ import "./chunk-MDQ57Q3H.js";
73
+ import "./chunk-FDDAUASC.js";
74
+ import "./chunk-FOKJ4POB.js";
75
+ import "./chunk-OF7VVUDQ.js";
76
+ import "./chunk-D72URWJE.js";
77
+ import "./chunk-NQAKARHE.js";
78
+ import "./chunk-4YPRRQBE.js";
79
+ import "./chunk-ZVJWD3FK.js";
80
+ import "./chunk-762BS35H.js";
81
+ import {
82
+ mcpErrorResult
83
+ } from "./chunk-AG64V7AB.js";
84
+ import {
85
+ object
86
+ } from "./chunk-S4UUN6LD.js";
87
+ import "./chunk-Y5E2WNWB.js";
88
+ import "./chunk-T7ZUDA4C.js";
89
+ import "./chunk-GEBSW7UK.js";
90
+ import {
91
+ __name
92
+ } from "./chunk-ZVVMGPBJ.js";
93
+
94
+ // node_modules/.pnpm/@wirecat+cli-core@0.692.0_@wirecat+cli-base@0.110.0_@scalar+openapi-upgrader@0.4.6_comm_daa46dda8170ab81fe68d59b38277e40/node_modules/@wirecat/cli-core/dist/mcp/bot/server.js
95
+ import { randomUUID } from "node:crypto";
96
+ var body = /* @__PURE__ */ __name((command, value) => Array.isArray(value) ? wholeList(`bot ${command}`, value) : value !== null && typeof value === "object" && ("item" in value || "items" in value) ? value : itemOf(value !== null && typeof value === "object" ? value : { value }), "body");
97
+ var createBotServer = /* @__PURE__ */ __name((options) => {
98
+ const { bot, program, settings, env } = options;
99
+ const command = bot.app.command;
100
+ const levels = options.levels ?? (() => settings.permissions);
101
+ const authority = /* @__PURE__ */ __name((path) => options.authority?.(path) === true || path[0] === "config" && (path[1] === "set" || path[1] === "unset"), "authority");
102
+ const catalogue = {
103
+ includeUnavailable: true,
104
+ levels: settings.permissions,
105
+ currentLevels: levels,
106
+ readOnly: readOnlyLockOf(bot.app, env) !== void 0,
107
+ ...options.keyOf ? { keyOf: options.keyOf } : {},
108
+ authority,
109
+ ...options.fetchOnly ? { fetchOnly: options.fetchOnly } : {},
110
+ ...options.fetches ? { fetches: options.fetches } : {},
111
+ offline: true,
112
+ // Another bot's copy is this bot's to read only where `read_other_bots` says so.
113
+ ...settings.readOtherBots ? {} : { omit: ["all_bots", "bots"] }
114
+ };
115
+ const tools = [
116
+ ...toolsFromCommands(program.commands, { ...catalogue, root: ["bot"] }),
117
+ ...toolsFromCommands(program.commands.filter((one) => one.path[0] === "config"), {
118
+ ...catalogue,
119
+ omit: ["bot", "personal", "defaults"]
120
+ })
121
+ ];
122
+ const writes = tools.filter((tool) => tool.writes && tool.availability?.().available !== false).map((tool) => tool.command);
123
+ const skills = options.skill ? skillResources(bot.app, options.skill) : [];
124
+ const skill = skills[0];
125
+ let queue = Promise.resolve();
126
+ const invoke = /* @__PURE__ */ __name((path, input, caller) => {
127
+ const next = queue.then(() => runCommandForAgent(program, path, path[0] === "config" ? { ...input, bot: true } : input, {
128
+ profile: settings.profile,
129
+ readOnly: readOnlyLockOf(bot.app, env) !== void 0,
130
+ env,
131
+ levels,
132
+ ...options.keyOf ? { keyOf: options.keyOf } : {},
133
+ authority,
134
+ ...options.fetches ? { fetches: options.fetches } : {},
135
+ ...caller ? { caller } : {}
136
+ }));
137
+ queue = next.catch(() => void 0);
138
+ return next;
139
+ }, "invoke");
140
+ const build = /* @__PURE__ */ __name(() => {
141
+ const callers = { env, client: /* @__PURE__ */ __name(() => server.server.getClientVersion(), "client"), connectionId: randomUUID() };
142
+ const server = new McpServer({ name: `${command}-bot-${settings.profile}`, version: bot.app.version }, {
143
+ instructions: botInstructions({
144
+ command,
145
+ name: bot.name ?? command,
146
+ profile: settings.profile,
147
+ writes,
148
+ ...skill ? { skill: skill.instruction } : {}
149
+ })
150
+ });
151
+ for (const { uri, name, title, description, mimeType, read } of skills)
152
+ server.registerResource(name, uri, { title, description, mimeType }, read);
153
+ const commands = Object.fromEntries(tools.map((tool) => [
154
+ tool.command,
155
+ {
156
+ title: tool.title,
157
+ description: tool.description,
158
+ writes: tool.writes,
159
+ availability: tool.availability,
160
+ input: tool.input,
161
+ run: /* @__PURE__ */ __name(async (args, ctx) => {
162
+ const caller = callerOf(ctx, `${command}_${tool.command.replaceAll(" ", "_")}`, callers);
163
+ const answer = await invoke(tool.path, args, caller);
164
+ return "error" in answer ? mcpErrorResult(JSON.parse(agentJson(answer.error))) : answered(body(tool.command, answer.result));
165
+ }, "run")
166
+ }
167
+ ]));
168
+ commands.status = {
169
+ title: "This server's bot and profile",
170
+ description: "Which profile this server speaks for, where its bot token comes from, which bot it is, and which writing commands are on. Sends nothing.",
171
+ writes: false,
172
+ input: object({}),
173
+ run: /* @__PURE__ */ __name(async () => {
174
+ const auth = await invoke(["bot", "auth", "show"], {});
175
+ const shown = "error" in auth ? auth.error : auth.result?.item ?? auth.result;
176
+ return answered(itemOf({
177
+ profile: settings.profile,
178
+ kind: "bot",
179
+ auth: shown,
180
+ writes: tools.filter((tool) => tool.writes && tool.availability?.().available !== false).map((tool) => tool.command),
181
+ permissions: levels()
182
+ }));
183
+ }, "run")
184
+ };
185
+ registerCommands(server, `${command}_bot`, commands, void 0, (asked) => {
186
+ const lock = readOnlyLockOf(bot.app, env);
187
+ const one = flatten(program.commands).find((info) => info.path[0] === "bot" && normal(info.path.slice(1).join(" ")) === asked);
188
+ if (lock && one && changesMessenger(one))
189
+ throw readOnlyRefusal(lock, MESSENGER_CHANGE_REFUSAL);
190
+ }, bot.app.messenger);
191
+ return server;
192
+ }, "build");
193
+ return { build, tools, offered: tools.map((tool) => tool.command) };
194
+ }, "createBotServer");
195
+ var serveBotOverStdio = /* @__PURE__ */ __name(async (options, note) => {
196
+ const { build } = createBotServer(options);
197
+ const wire = answeredWire(process.stdin, process.stdout);
198
+ const handle = serveStdio(build, {
199
+ transport: new StdioServerTransport(wire.input, wire.output),
200
+ onerror: /* @__PURE__ */ __name((error) => note(`mcp: ${error.message}`), "onerror")
201
+ });
202
+ await wire.finished();
203
+ wire.release();
204
+ await handle.close();
205
+ }, "serveBotOverStdio");
206
+ export {
207
+ createBotServer,
208
+ serveBotOverStdio
209
+ };
@@ -0,0 +1,20 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ ensureSqlite,
5
+ nodeRuntime,
6
+ relay
7
+ } from "./chunk-3GVI2MAO.js";
8
+ import "./chunk-4YPRRQBE.js";
9
+ import "./chunk-ZVJWD3FK.js";
10
+ import "./chunk-762BS35H.js";
11
+ import "./chunk-AG64V7AB.js";
12
+ import "./chunk-S4UUN6LD.js";
13
+ import "./chunk-Y5E2WNWB.js";
14
+ import "./chunk-T7ZUDA4C.js";
15
+ import "./chunk-ZVVMGPBJ.js";
16
+ export {
17
+ ensureSqlite,
18
+ nodeRuntime,
19
+ relay
20
+ };
@@ -0,0 +1,36 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ ACCESS_SECONDS,
5
+ REFRESH_SECONDS,
6
+ httpLaunchFile,
7
+ httpLock,
8
+ httpLockFile,
9
+ httpLogFile,
10
+ mcpHttpMarker,
11
+ readHttpLaunch,
12
+ readHttpLock,
13
+ readStored,
14
+ signedInClients
15
+ } from "./chunk-GA442SYZ.js";
16
+ import "./chunk-QGWXSFYN.js";
17
+ import "./chunk-J5CXR6VX.js";
18
+ import "./chunk-762BS35H.js";
19
+ import "./chunk-AG64V7AB.js";
20
+ import "./chunk-S4UUN6LD.js";
21
+ import "./chunk-Y5E2WNWB.js";
22
+ import "./chunk-T7ZUDA4C.js";
23
+ import "./chunk-ZVVMGPBJ.js";
24
+ export {
25
+ ACCESS_SECONDS,
26
+ REFRESH_SECONDS,
27
+ httpLaunchFile,
28
+ httpLock,
29
+ httpLockFile,
30
+ httpLogFile,
31
+ mcpHttpMarker,
32
+ readHttpLaunch,
33
+ readHttpLock,
34
+ readStored,
35
+ signedInClients
36
+ };