@wirecat/attio-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 (226) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/LICENSE +204 -0
  3. package/README.md +249 -2
  4. package/contracts/wirecat.json +2339 -0
  5. package/dist/bin/attio.d.ts +3 -0
  6. package/dist/bin/attio.d.ts.map +1 -0
  7. package/dist/bin/attio.js +40 -0
  8. package/dist/bin/attio.js.map +1 -0
  9. package/dist/bundle/agent-DYTWDBTT.js +37 -0
  10. package/dist/bundle/all-profiles-LZDKPHN2.js +320 -0
  11. package/dist/bundle/anthropic-BF72H77D.js +91 -0
  12. package/dist/bundle/app-server-H57FZJX5.js +249 -0
  13. package/dist/bundle/attio.js +183 -0
  14. package/dist/bundle/bun-WO77T4LG.js +169 -0
  15. package/dist/bundle/bun-sqlite-2BP7JDVO.js +76 -0
  16. package/dist/bundle/chunk-2E6JGBM5.js +1392 -0
  17. package/dist/bundle/chunk-34FJ26K2.js +54 -0
  18. package/dist/bundle/chunk-3I2FGNWO.js +23 -0
  19. package/dist/bundle/chunk-3NVOKVRY.js +42148 -0
  20. package/dist/bundle/chunk-3YFDZSM3.js +37 -0
  21. package/dist/bundle/chunk-4SMGM2Q6.js +274 -0
  22. package/dist/bundle/chunk-4STBJZR4.js +3571 -0
  23. package/dist/bundle/chunk-5K3FGXZH.js +46 -0
  24. package/dist/bundle/chunk-6ALPRBNV.js +100 -0
  25. package/dist/bundle/chunk-6NDJDDSQ.js +2000 -0
  26. package/dist/bundle/chunk-6SK3YB2B.js +218 -0
  27. package/dist/bundle/chunk-76RRELCU.js +65310 -0
  28. package/dist/bundle/chunk-7MXCUMHG.js +18 -0
  29. package/dist/bundle/chunk-7ZUOI3HY.js +73 -0
  30. package/dist/bundle/chunk-AMUONYQR.js +106 -0
  31. package/dist/bundle/chunk-ASCUOOLO.js +53 -0
  32. package/dist/bundle/chunk-BUGROVF3.js +72 -0
  33. package/dist/bundle/chunk-CHZ26CW5.js +9578 -0
  34. package/dist/bundle/chunk-CMO5ND3Y.js +794 -0
  35. package/dist/bundle/chunk-D72URWJE.js +532 -0
  36. package/dist/bundle/chunk-DF2IIO32.js +12645 -0
  37. package/dist/bundle/chunk-DFDN6AUB.js +21 -0
  38. package/dist/bundle/chunk-DQ6P3R4B.js +170 -0
  39. package/dist/bundle/chunk-DSRXCLPO.js +7 -0
  40. package/dist/bundle/chunk-EEPE3SOW.js +338 -0
  41. package/dist/bundle/chunk-EH6ZEJGT.js +932 -0
  42. package/dist/bundle/chunk-EQGXEKSV.js +1197 -0
  43. package/dist/bundle/chunk-EQXT7KO4.js +388 -0
  44. package/dist/bundle/chunk-ERW2WOJT.js +24 -0
  45. package/dist/bundle/chunk-ESH2QGCA.js +372 -0
  46. package/dist/bundle/chunk-G3JTLVVL.js +771 -0
  47. package/dist/bundle/chunk-G6FQMVKW.js +52 -0
  48. package/dist/bundle/chunk-GBZ6JUXU.js +108 -0
  49. package/dist/bundle/chunk-GLHFJPYS.js +156 -0
  50. package/dist/bundle/chunk-GW4G5KLS.js +2333 -0
  51. package/dist/bundle/chunk-H7QDPW3D.js +78 -0
  52. package/dist/bundle/chunk-HG7FT3H3.js +319 -0
  53. package/dist/bundle/chunk-I3WS6V5H.js +188 -0
  54. package/dist/bundle/chunk-IDU4ESRZ.js +95 -0
  55. package/dist/bundle/chunk-IXCIQ7FZ.js +161 -0
  56. package/dist/bundle/chunk-J5P5VSRG.js +1233 -0
  57. package/dist/bundle/chunk-JA26HG7T.js +353 -0
  58. package/dist/bundle/chunk-JSTBW7F4.js +259 -0
  59. package/dist/bundle/chunk-KHDXRFJZ.js +185 -0
  60. package/dist/bundle/chunk-L5WS6CYZ.js +288 -0
  61. package/dist/bundle/chunk-LWJ4ZGUM.js +407 -0
  62. package/dist/bundle/chunk-MC2RQ2OB.js +38 -0
  63. package/dist/bundle/chunk-MNQACPXG.js +1332 -0
  64. package/dist/bundle/chunk-MOSH2KPD.js +358 -0
  65. package/dist/bundle/chunk-MRREDVPY.js +733 -0
  66. package/dist/bundle/chunk-MT2ZUZRA.js +1028 -0
  67. package/dist/bundle/chunk-O4A33Y54.js +29 -0
  68. package/dist/bundle/chunk-OBXDRUO4.js +63 -0
  69. package/dist/bundle/chunk-OFR3YYT6.js +6848 -0
  70. package/dist/bundle/chunk-P4U6AGWD.js +41 -0
  71. package/dist/bundle/chunk-PL5P7UKW.js +25216 -0
  72. package/dist/bundle/chunk-PMP37KLR.js +142 -0
  73. package/dist/bundle/chunk-Q3JCUUOR.js +80 -0
  74. package/dist/bundle/chunk-Q7BSTQ3T.js +633 -0
  75. package/dist/bundle/chunk-QLHDUYGE.js +16 -0
  76. package/dist/bundle/chunk-RU5J7DWY.js +988 -0
  77. package/dist/bundle/chunk-S4UUN6LD.js +1410 -0
  78. package/dist/bundle/chunk-S7K2XFQB.js +95 -0
  79. package/dist/bundle/chunk-SQHDE3TC.js +230 -0
  80. package/dist/bundle/chunk-TF7ZGCOK.js +76 -0
  81. package/dist/bundle/chunk-V6BTAILB.js +4072 -0
  82. package/dist/bundle/chunk-VDMIJ3JW.js +50 -0
  83. package/dist/bundle/chunk-VW5F6FK3.js +206 -0
  84. package/dist/bundle/chunk-W6F2CQZ6.js +1068 -0
  85. package/dist/bundle/chunk-WARIIYSW.js +58 -0
  86. package/dist/bundle/chunk-WK7GLHHL.js +334 -0
  87. package/dist/bundle/chunk-X5S5KUSU.js +2788 -0
  88. package/dist/bundle/chunk-X6R74TWX.js +131 -0
  89. package/dist/bundle/chunk-XQUUANA2.js +24600 -0
  90. package/dist/bundle/chunk-XXLQNHKF.js +82 -0
  91. package/dist/bundle/chunk-XXOTX4M3.js +362 -0
  92. package/dist/bundle/chunk-Y5E2WNWB.js +35 -0
  93. package/dist/bundle/chunk-ZDBTYBFR.js +66 -0
  94. package/dist/bundle/chunk-ZGADZ4CH.js +557 -0
  95. package/dist/bundle/chunk-ZVVMGPBJ.js +50 -0
  96. package/dist/bundle/command-contract-7M6EPH3D.js +37 -0
  97. package/dist/bundle/command-server-entry-MNVPYQZ3.js +166 -0
  98. package/dist/bundle/decode-MQNKNXLK.js +297 -0
  99. package/dist/bundle/definitions-FODOIPM2.js +43379 -0
  100. package/dist/bundle/dispatch-TAQ7635E.js +411 -0
  101. package/dist/bundle/dist-EM7KLEG4.js +7577 -0
  102. package/dist/bundle/dist-PAKDDIBT.js +191 -0
  103. package/dist/bundle/echarts-6ZSUNO4L.js +42501 -0
  104. package/dist/bundle/embed-PHCCJJ5Z.js +38 -0
  105. package/dist/bundle/embedder-WLZZQTKZ.js +111 -0
  106. package/dist/bundle/failure-MR2XVHFP.js +25 -0
  107. package/dist/bundle/first-run-64LREHSV.js +29 -0
  108. package/dist/bundle/first-screen-YSCAZIYJ.js +37 -0
  109. package/dist/bundle/instructions-22GCKNR5.js +11 -0
  110. package/dist/bundle/mcp-CNV7F2XZ.js +167 -0
  111. package/dist/bundle/meeting-combined-YX3T5WJD.js +24 -0
  112. package/dist/bundle/meeting-model-JWDTCGLZ.js +25 -0
  113. package/dist/bundle/meeting-semantic-375GYPZQ.js +22 -0
  114. package/dist/bundle/node-ITDTNRRZ.js +176 -0
  115. package/dist/bundle/node-KM3CUABH.js +2340 -0
  116. package/dist/bundle/node-TLZSIHIJ.js +21 -0
  117. package/dist/bundle/node-sqlite-IRAGRMEZ.js +74 -0
  118. package/dist/bundle/oauth-CACOQJEL.js +20 -0
  119. package/dist/bundle/open-HU4KHKDR.js +23 -0
  120. package/dist/bundle/openai-JQUPAVKX.js +238 -0
  121. package/dist/bundle/process-QS5OHEUK.js +91 -0
  122. package/dist/bundle/program-QLCUCR76.js +33428 -0
  123. package/dist/bundle/prompt-VA5MKXJU.js +17 -0
  124. package/dist/bundle/recognize-JGA5IVKC.js +26 -0
  125. package/dist/bundle/remote-NPY2KZQ4.js +31 -0
  126. package/dist/bundle/rerank-4H2QR4XU.js +52 -0
  127. package/dist/bundle/schemas-THAI3G5S.js +21410 -0
  128. package/dist/bundle/serve-UH46SZQG.js +199 -0
  129. package/dist/bundle/server-6H7JS6SU.js +212 -0
  130. package/dist/bundle/server-SR52KBL3.js +79 -0
  131. package/dist/bundle/sqlite-runtime-EJWEUTBR.js +20 -0
  132. package/dist/bundle/state-34B6AUQZ.js +36 -0
  133. package/dist/bundle/store-3R4ILTCJ.js +177 -0
  134. package/dist/bundle/store-XSE35P3U.js +291 -0
  135. package/dist/bundle/store-maintenance-command-ABJARLI4.js +66 -0
  136. package/dist/bundle/surface-NOTIEJB5.js +65 -0
  137. package/dist/commands/api.d.ts +12 -0
  138. package/dist/commands/api.d.ts.map +1 -0
  139. package/dist/commands/api.js +27 -0
  140. package/dist/commands/api.js.map +1 -0
  141. package/dist/commands/crm.d.ts +4 -0
  142. package/dist/commands/crm.d.ts.map +1 -0
  143. package/dist/commands/crm.js +66 -0
  144. package/dist/commands/crm.js.map +1 -0
  145. package/dist/commands/session.d.ts +7 -0
  146. package/dist/commands/session.d.ts.map +1 -0
  147. package/dist/commands/session.js +22 -0
  148. package/dist/commands/session.js.map +1 -0
  149. package/dist/config.d.ts +14 -0
  150. package/dist/config.d.ts.map +1 -0
  151. package/dist/config.js +14 -0
  152. package/dist/config.js.map +1 -0
  153. package/dist/context.d.ts +37 -0
  154. package/dist/context.d.ts.map +1 -0
  155. package/dist/context.js +31 -0
  156. package/dist/context.js.map +1 -0
  157. package/dist/generated/definitions.d.ts +3 -0
  158. package/dist/generated/definitions.d.ts.map +1 -0
  159. package/dist/generated/definitions.js +43375 -0
  160. package/dist/generated/definitions.js.map +1 -0
  161. package/dist/generated/manifest.d.ts +6 -0
  162. package/dist/generated/manifest.d.ts.map +1 -0
  163. package/dist/generated/manifest.js +5158 -0
  164. package/dist/generated/manifest.js.map +1 -0
  165. package/dist/generated/schemas.d.ts +383 -0
  166. package/dist/generated/schemas.d.ts.map +1 -0
  167. package/dist/generated/schemas.js +21196 -0
  168. package/dist/generated/schemas.js.map +1 -0
  169. package/dist/generated/types.d.ts +10166 -0
  170. package/dist/generated/types.d.ts.map +1 -0
  171. package/dist/generated/types.js +5 -0
  172. package/dist/generated/types.js.map +1 -0
  173. package/dist/generated/wirecat-config.d.ts +15 -0
  174. package/dist/generated/wirecat-config.d.ts.map +1 -0
  175. package/dist/generated/wirecat-config.js +333 -0
  176. package/dist/generated/wirecat-config.js.map +1 -0
  177. package/dist/hooks.d.ts +3 -0
  178. package/dist/hooks.d.ts.map +1 -0
  179. package/dist/hooks.js +7 -0
  180. package/dist/hooks.js.map +1 -0
  181. package/dist/identity.d.ts +33 -0
  182. package/dist/identity.d.ts.map +1 -0
  183. package/dist/identity.js +31 -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/program.d.ts +6 -0
  190. package/dist/program.d.ts.map +1 -0
  191. package/dist/program.js +54 -0
  192. package/dist/program.js.map +1 -0
  193. package/dist/version.d.ts +2 -0
  194. package/dist/version.d.ts.map +1 -0
  195. package/dist/version.js +2 -0
  196. package/dist/version.js.map +1 -0
  197. package/dist/wcat.d.ts +3 -0
  198. package/dist/wcat.d.ts.map +1 -0
  199. package/dist/wcat.js +4 -0
  200. package/dist/wcat.js.map +1 -0
  201. package/package.json +87 -4
  202. package/skills/attio-cli/SKILL.md +58 -0
  203. package/skills/attio-cli/references/api/api-activities.md +62 -0
  204. package/skills/attio-cli/references/api/api-activity-records.md +96 -0
  205. package/skills/attio-cli/references/api/api-attributes.md +148 -0
  206. package/skills/attio-cli/references/api/api-call-recordings.md +53 -0
  207. package/skills/attio-cli/references/api/api-comments.md +36 -0
  208. package/skills/attio-cli/references/api/api-emails.md +23 -0
  209. package/skills/attio-cli/references/api/api-entries.md +127 -0
  210. package/skills/attio-cli/references/api/api-files.md +63 -0
  211. package/skills/attio-cli/references/api/api-lists.md +44 -0
  212. package/skills/attio-cli/references/api/api-meetings.md +82 -0
  213. package/skills/attio-cli/references/api/api-meta.md +8 -0
  214. package/skills/attio-cli/references/api/api-notes.md +64 -0
  215. package/skills/attio-cli/references/api/api-objects.md +55 -0
  216. package/skills/attio-cli/references/api/api-records.md +168 -0
  217. package/skills/attio-cli/references/api/api-sequences.md +15 -0
  218. package/skills/attio-cli/references/api/api-sql.md +15 -0
  219. package/skills/attio-cli/references/api/api-tasks.md +67 -0
  220. package/skills/attio-cli/references/api/api-threads.md +35 -0
  221. package/skills/attio-cli/references/api/api-transcripts.md +17 -0
  222. package/skills/attio-cli/references/api/api-views.md +133 -0
  223. package/skills/attio-cli/references/api/api-webhooks.md +62 -0
  224. package/skills/attio-cli/references/api/api-workspace-blocklist.md +39 -0
  225. package/skills/attio-cli/references/api/api-workspace-members.md +19 -0
  226. package/skills/attio-cli/references/api.md +35 -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-H7QDPW3D.js";
6
+ import {
7
+ ownerLogin
8
+ } from "./chunk-L5WS6CYZ.js";
9
+ import {
10
+ WebStandardStreamableHTTPServerTransport,
11
+ createMcpHandler,
12
+ getOAuthProtectedResourceMetadataUrl,
13
+ hostHeaderValidationResponse,
14
+ isLegacyRequest,
15
+ oauthMetadataResponse,
16
+ requireBearerAuth
17
+ } from "./chunk-PL5P7UKW.js";
18
+ import {
19
+ activityRecorder,
20
+ calledTools,
21
+ httpActivityFile,
22
+ httpLock
23
+ } from "./chunk-IXCIQ7FZ.js";
24
+ import "./chunk-7ZUOI3HY.js";
25
+ import "./chunk-OBXDRUO4.js";
26
+ import "./chunk-X5S5KUSU.js";
27
+ import "./chunk-J5P5VSRG.js";
28
+ import "./chunk-S4UUN6LD.js";
29
+ import "./chunk-Y5E2WNWB.js";
30
+ import {
31
+ CliError
32
+ } from "./chunk-BUGROVF3.js";
33
+ import {
34
+ __name
35
+ } from "./chunk-ZVVMGPBJ.js";
36
+
37
+ // node_modules/.pnpm/@wirecat+cli-core@0.703.0_@wirecat+cli-base@0.119.0_commander@15.0.0_esbuild@0.28.2_typ_5630bd43f49d4f78ecc9c491970e88a0/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,212 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ botInstructions
5
+ } from "./chunk-ERW2WOJT.js";
6
+ import {
7
+ skillResources
8
+ } from "./chunk-EQXT7KO4.js";
9
+ import {
10
+ StdioServerTransport,
11
+ answeredWire,
12
+ serveStdio
13
+ } from "./chunk-Q7BSTQ3T.js";
14
+ import {
15
+ wholeList
16
+ } from "./chunk-JA26HG7T.js";
17
+ import {
18
+ runCommandForAgent,
19
+ toolsFromCommands
20
+ } from "./chunk-4STBJZR4.js";
21
+ import "./chunk-VDMIJ3JW.js";
22
+ import "./chunk-EEPE3SOW.js";
23
+ import {
24
+ answered,
25
+ normal,
26
+ registerCommands
27
+ } from "./chunk-ZGADZ4CH.js";
28
+ import {
29
+ agentJson
30
+ } from "./chunk-RU5J7DWY.js";
31
+ import "./chunk-3NVOKVRY.js";
32
+ import "./chunk-LWJ4ZGUM.js";
33
+ import "./chunk-3YFDZSM3.js";
34
+ import "./chunk-IDU4ESRZ.js";
35
+ import "./chunk-PMP37KLR.js";
36
+ import "./chunk-5K3FGXZH.js";
37
+ import {
38
+ callerOf
39
+ } from "./chunk-GBZ6JUXU.js";
40
+ import "./chunk-MRREDVPY.js";
41
+ import {
42
+ McpServer
43
+ } from "./chunk-PL5P7UKW.js";
44
+ import "./chunk-TF7ZGCOK.js";
45
+ import "./chunk-JSTBW7F4.js";
46
+ import "./chunk-MOSH2KPD.js";
47
+ import "./chunk-DQ6P3R4B.js";
48
+ import {
49
+ MESSENGER_CHANGE_REFUSAL,
50
+ changesMessenger,
51
+ flatten,
52
+ itemOf,
53
+ readOnlyLockOf,
54
+ readOnlyRefusal
55
+ } from "./chunk-DF2IIO32.js";
56
+ import "./chunk-XXOTX4M3.js";
57
+ import "./chunk-G6FQMVKW.js";
58
+ import "./chunk-WK7GLHHL.js";
59
+ import "./chunk-OBXDRUO4.js";
60
+ import "./chunk-XXLQNHKF.js";
61
+ import "./chunk-W6F2CQZ6.js";
62
+ import "./chunk-ZDBTYBFR.js";
63
+ import "./chunk-76RRELCU.js";
64
+ import "./chunk-GW4G5KLS.js";
65
+ import "./chunk-Q3JCUUOR.js";
66
+ import "./chunk-G3JTLVVL.js";
67
+ import "./chunk-QLHDUYGE.js";
68
+ import "./chunk-6NDJDDSQ.js";
69
+ import "./chunk-GLHFJPYS.js";
70
+ import "./chunk-O4A33Y54.js";
71
+ import "./chunk-V6BTAILB.js";
72
+ import "./chunk-DSRXCLPO.js";
73
+ import "./chunk-KHDXRFJZ.js";
74
+ import "./chunk-ESH2QGCA.js";
75
+ import "./chunk-EQGXEKSV.js";
76
+ import "./chunk-MT2ZUZRA.js";
77
+ import "./chunk-4SMGM2Q6.js";
78
+ import "./chunk-3I2FGNWO.js";
79
+ import "./chunk-D72URWJE.js";
80
+ import "./chunk-34FJ26K2.js";
81
+ import "./chunk-S7K2XFQB.js";
82
+ import "./chunk-MC2RQ2OB.js";
83
+ import "./chunk-X5S5KUSU.js";
84
+ import {
85
+ mcpErrorResult
86
+ } from "./chunk-J5P5VSRG.js";
87
+ import {
88
+ object
89
+ } from "./chunk-S4UUN6LD.js";
90
+ import "./chunk-Y5E2WNWB.js";
91
+ import "./chunk-BUGROVF3.js";
92
+ import "./chunk-OFR3YYT6.js";
93
+ import {
94
+ __name
95
+ } from "./chunk-ZVVMGPBJ.js";
96
+
97
+ // node_modules/.pnpm/@wirecat+cli-core@0.703.0_@wirecat+cli-base@0.119.0_commander@15.0.0_esbuild@0.28.2_typ_5630bd43f49d4f78ecc9c491970e88a0/node_modules/@wirecat/cli-core/dist/mcp/bot/server.js
98
+ import { randomUUID } from "node:crypto";
99
+ var body = /* @__PURE__ */ __name((command, value) => Array.isArray(value) ? wholeList(`bot ${command}`, value) : value !== null && typeof value === "object" && ("item" in value || "items" in value) ? value : itemOf(value !== null && typeof value === "object" ? value : { value }), "body");
100
+ var createBotServer = /* @__PURE__ */ __name((options) => {
101
+ const { bot, program, settings, env } = options;
102
+ const command = bot.app.command;
103
+ const levels = options.levels ?? (() => settings.permissions);
104
+ const authority = /* @__PURE__ */ __name((path) => options.authority?.(path) === true || path[0] === "config" && (path[1] === "set" || path[1] === "unset"), "authority");
105
+ const catalogue = {
106
+ includeUnavailable: true,
107
+ levels: settings.permissions,
108
+ currentLevels: levels,
109
+ readOnly: readOnlyLockOf(bot.app, env) !== void 0,
110
+ ...options.keyOf ? { keyOf: options.keyOf } : {},
111
+ authority,
112
+ ...options.fetchOnly ? { fetchOnly: options.fetchOnly } : {},
113
+ ...options.fetches ? { fetches: options.fetches } : {},
114
+ offline: true,
115
+ // Another bot's copy is this bot's to read only where `read_other_bots` says so.
116
+ ...settings.readOtherBots ? {} : { omit: ["all_bots", "bots"] }
117
+ };
118
+ const tools = [
119
+ ...toolsFromCommands(program.commands, { ...catalogue, root: ["bot"] }),
120
+ ...toolsFromCommands(program.commands.filter((one) => one.path[0] === "config"), {
121
+ ...catalogue,
122
+ omit: ["bot", "personal", "defaults"]
123
+ })
124
+ ];
125
+ const writes = tools.filter((tool) => tool.writes && tool.availability?.().available !== false).map((tool) => tool.command);
126
+ const skills = options.skill ? skillResources(bot.app, options.skill) : [];
127
+ const skill = skills[0];
128
+ let queue = Promise.resolve();
129
+ const invoke = /* @__PURE__ */ __name((path, input, caller) => {
130
+ const next = queue.then(() => runCommandForAgent(program, path, path[0] === "config" ? { ...input, bot: true } : input, {
131
+ profile: settings.profile,
132
+ readOnly: readOnlyLockOf(bot.app, env) !== void 0,
133
+ env,
134
+ levels,
135
+ ...options.keyOf ? { keyOf: options.keyOf } : {},
136
+ authority,
137
+ ...options.fetches ? { fetches: options.fetches } : {},
138
+ ...caller ? { caller } : {}
139
+ }));
140
+ queue = next.catch(() => void 0);
141
+ return next;
142
+ }, "invoke");
143
+ const build = /* @__PURE__ */ __name(() => {
144
+ const callers = { env, client: /* @__PURE__ */ __name(() => server.server.getClientVersion(), "client"), connectionId: randomUUID() };
145
+ const server = new McpServer({ name: `${command}-bot-${settings.profile}`, version: bot.app.version }, {
146
+ instructions: botInstructions({
147
+ command,
148
+ name: bot.name ?? command,
149
+ profile: settings.profile,
150
+ writes,
151
+ ...skill ? { skill: skill.instruction } : {}
152
+ })
153
+ });
154
+ for (const { uri, name, title, description, mimeType, read } of skills)
155
+ server.registerResource(name, uri, { title, description, mimeType }, read);
156
+ const commands = Object.fromEntries(tools.map((tool) => [
157
+ tool.command,
158
+ {
159
+ title: tool.title,
160
+ description: tool.description,
161
+ writes: tool.writes,
162
+ availability: tool.availability,
163
+ input: tool.input,
164
+ run: /* @__PURE__ */ __name(async (args, ctx) => {
165
+ const caller = callerOf(ctx, `${command}_${tool.command.replaceAll(" ", "_")}`, callers);
166
+ const answer = await invoke(tool.path, args, caller);
167
+ return "error" in answer ? mcpErrorResult(JSON.parse(agentJson(answer.error))) : answered(body(tool.command, answer.result));
168
+ }, "run")
169
+ }
170
+ ]));
171
+ commands.status = {
172
+ title: "This server's bot and profile",
173
+ description: "Which profile this server speaks for, where its bot token comes from, which bot it is, and which writing commands are on. Sends nothing.",
174
+ writes: false,
175
+ input: object({}),
176
+ run: /* @__PURE__ */ __name(async () => {
177
+ const auth = await invoke(["bot", "auth", "show"], {});
178
+ const shown = "error" in auth ? auth.error : auth.result?.item ?? auth.result;
179
+ return answered(itemOf({
180
+ profile: settings.profile,
181
+ kind: "bot",
182
+ auth: shown,
183
+ writes: tools.filter((tool) => tool.writes && tool.availability?.().available !== false).map((tool) => tool.command),
184
+ permissions: levels()
185
+ }));
186
+ }, "run")
187
+ };
188
+ registerCommands(server, `${command}_bot`, commands, void 0, (asked) => {
189
+ const lock = readOnlyLockOf(bot.app, env);
190
+ const one = flatten(program.commands).find((info) => info.path[0] === "bot" && normal(info.path.slice(1).join(" ")) === asked);
191
+ if (lock && one && changesMessenger(one))
192
+ throw readOnlyRefusal(lock, MESSENGER_CHANGE_REFUSAL);
193
+ }, bot.app.messenger);
194
+ return server;
195
+ }, "build");
196
+ return { build, tools, offered: tools.map((tool) => tool.command) };
197
+ }, "createBotServer");
198
+ var serveBotOverStdio = /* @__PURE__ */ __name(async (options, note) => {
199
+ const { build } = createBotServer(options);
200
+ const wire = answeredWire(process.stdin, process.stdout);
201
+ const handle = serveStdio(build, {
202
+ transport: new StdioServerTransport(wire.input, wire.output),
203
+ onerror: /* @__PURE__ */ __name((error) => note(`mcp: ${error.message}`), "onerror")
204
+ });
205
+ await wire.finished();
206
+ wire.release();
207
+ await handle.close();
208
+ }, "serveBotOverStdio");
209
+ export {
210
+ createBotServer,
211
+ serveBotOverStdio
212
+ };
@@ -0,0 +1,79 @@
1
+ import { createRequire as __bundleRequire } from "node:module";
2
+ const require = __bundleRequire(import.meta.url);
3
+ import {
4
+ PER_RUN,
5
+ createServer,
6
+ envelope,
7
+ serveOverHttpUntilStopped,
8
+ serveOverStdio
9
+ } from "./chunk-CMO5ND3Y.js";
10
+ import "./chunk-MNQACPXG.js";
11
+ import "./chunk-EQXT7KO4.js";
12
+ import "./chunk-Q7BSTQ3T.js";
13
+ import "./chunk-7MXCUMHG.js";
14
+ import "./chunk-2E6JGBM5.js";
15
+ import "./chunk-JA26HG7T.js";
16
+ import "./chunk-4STBJZR4.js";
17
+ import "./chunk-VDMIJ3JW.js";
18
+ import "./chunk-EEPE3SOW.js";
19
+ import "./chunk-ASCUOOLO.js";
20
+ import "./chunk-ZGADZ4CH.js";
21
+ import "./chunk-RU5J7DWY.js";
22
+ import "./chunk-3NVOKVRY.js";
23
+ import "./chunk-LWJ4ZGUM.js";
24
+ import "./chunk-3YFDZSM3.js";
25
+ import "./chunk-IDU4ESRZ.js";
26
+ import "./chunk-PMP37KLR.js";
27
+ import "./chunk-5K3FGXZH.js";
28
+ import "./chunk-GBZ6JUXU.js";
29
+ import "./chunk-MRREDVPY.js";
30
+ import "./chunk-PL5P7UKW.js";
31
+ import "./chunk-TF7ZGCOK.js";
32
+ import "./chunk-JSTBW7F4.js";
33
+ import "./chunk-MOSH2KPD.js";
34
+ import "./chunk-DQ6P3R4B.js";
35
+ import "./chunk-IXCIQ7FZ.js";
36
+ import "./chunk-7ZUOI3HY.js";
37
+ import "./chunk-X6R74TWX.js";
38
+ import "./chunk-DF2IIO32.js";
39
+ import "./chunk-XXOTX4M3.js";
40
+ import "./chunk-G6FQMVKW.js";
41
+ import "./chunk-WK7GLHHL.js";
42
+ import "./chunk-OBXDRUO4.js";
43
+ import "./chunk-XXLQNHKF.js";
44
+ import "./chunk-W6F2CQZ6.js";
45
+ import "./chunk-ZDBTYBFR.js";
46
+ import "./chunk-76RRELCU.js";
47
+ import "./chunk-GW4G5KLS.js";
48
+ import "./chunk-Q3JCUUOR.js";
49
+ import "./chunk-G3JTLVVL.js";
50
+ import "./chunk-QLHDUYGE.js";
51
+ import "./chunk-6NDJDDSQ.js";
52
+ import "./chunk-GLHFJPYS.js";
53
+ import "./chunk-O4A33Y54.js";
54
+ import "./chunk-V6BTAILB.js";
55
+ import "./chunk-DSRXCLPO.js";
56
+ import "./chunk-KHDXRFJZ.js";
57
+ import "./chunk-ESH2QGCA.js";
58
+ import "./chunk-EQGXEKSV.js";
59
+ import "./chunk-MT2ZUZRA.js";
60
+ import "./chunk-4SMGM2Q6.js";
61
+ import "./chunk-3I2FGNWO.js";
62
+ import "./chunk-D72URWJE.js";
63
+ import "./chunk-34FJ26K2.js";
64
+ import "./chunk-S7K2XFQB.js";
65
+ import "./chunk-MC2RQ2OB.js";
66
+ import "./chunk-X5S5KUSU.js";
67
+ import "./chunk-J5P5VSRG.js";
68
+ import "./chunk-S4UUN6LD.js";
69
+ import "./chunk-Y5E2WNWB.js";
70
+ import "./chunk-BUGROVF3.js";
71
+ import "./chunk-OFR3YYT6.js";
72
+ import "./chunk-ZVVMGPBJ.js";
73
+ export {
74
+ PER_RUN,
75
+ createServer,
76
+ envelope,
77
+ serveOverHttpUntilStopped,
78
+ serveOverStdio
79
+ };
@@ -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-AMUONYQR.js";
8
+ import "./chunk-S7K2XFQB.js";
9
+ import "./chunk-MC2RQ2OB.js";
10
+ import "./chunk-X5S5KUSU.js";
11
+ import "./chunk-J5P5VSRG.js";
12
+ import "./chunk-S4UUN6LD.js";
13
+ import "./chunk-Y5E2WNWB.js";
14
+ import "./chunk-BUGROVF3.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-IXCIQ7FZ.js";
16
+ import "./chunk-7ZUOI3HY.js";
17
+ import "./chunk-OBXDRUO4.js";
18
+ import "./chunk-X5S5KUSU.js";
19
+ import "./chunk-J5P5VSRG.js";
20
+ import "./chunk-S4UUN6LD.js";
21
+ import "./chunk-Y5E2WNWB.js";
22
+ import "./chunk-BUGROVF3.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
+ };