@wirecat/attio-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 (242) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/LICENSE +204 -0
  3. package/README.md +248 -2
  4. package/contracts/wirecat.json +2321 -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-KLBL3FYD.js +37 -0
  10. package/dist/bundle/all-profiles-C2NMRQPE.js +320 -0
  11. package/dist/bundle/anthropic-KOU2ILDK.js +91 -0
  12. package/dist/bundle/app-server-TINV4NNY.js +249 -0
  13. package/dist/bundle/attio.js +183 -0
  14. package/dist/bundle/bun-GVNM6IWY.js +169 -0
  15. package/dist/bundle/bun-sqlite-IF6B3EQI.js +76 -0
  16. package/dist/bundle/chunk-2343HKEW.js +362 -0
  17. package/dist/bundle/chunk-2H2MWGBD.js +988 -0
  18. package/dist/bundle/chunk-2P7ENEQ7.js +288 -0
  19. package/dist/bundle/chunk-4EYKJLWI.js +771 -0
  20. package/dist/bundle/chunk-4HQDT5PF.js +338 -0
  21. package/dist/bundle/chunk-4QE4L7UL.js +142 -0
  22. package/dist/bundle/chunk-4XHWGJXT.js +6848 -0
  23. package/dist/bundle/chunk-5DCRHSBI.js +72 -0
  24. package/dist/bundle/chunk-5ETXE5KF.js +372 -0
  25. package/dist/bundle/chunk-5WAGTWCS.js +156 -0
  26. package/dist/bundle/chunk-6B5PSQQ7.js +319 -0
  27. package/dist/bundle/chunk-6BVPS2YY.js +230 -0
  28. package/dist/bundle/chunk-6L5EUGLP.js +188 -0
  29. package/dist/bundle/chunk-7NFEMS4A.js +1028 -0
  30. package/dist/bundle/chunk-A7YQTQ5U.js +733 -0
  31. package/dist/bundle/chunk-AEPOHR4Z.js +82 -0
  32. package/dist/bundle/chunk-ARRQVUJ2.js +334 -0
  33. package/dist/bundle/chunk-BHNFRL3H.js +95 -0
  34. package/dist/bundle/chunk-CBPL3GID.js +23 -0
  35. package/dist/bundle/chunk-D72URWJE.js +532 -0
  36. package/dist/bundle/chunk-DFDN6AUB.js +21 -0
  37. package/dist/bundle/chunk-DVN54VPI.js +16 -0
  38. package/dist/bundle/chunk-DW3V7GTY.js +388 -0
  39. package/dist/bundle/chunk-EH6ZEJGT.js +932 -0
  40. package/dist/bundle/chunk-ETSOG6TZ.js +65288 -0
  41. package/dist/bundle/chunk-FJV3MO57.js +29 -0
  42. package/dist/bundle/chunk-HLLRNP2G.js +170 -0
  43. package/dist/bundle/chunk-HQJ2TABD.js +18 -0
  44. package/dist/bundle/chunk-ICUXAOEM.js +42063 -0
  45. package/dist/bundle/chunk-IGALQ74S.js +358 -0
  46. package/dist/bundle/chunk-IPHUAWFG.js +100 -0
  47. package/dist/bundle/chunk-IYMWUL6E.js +633 -0
  48. package/dist/bundle/chunk-JKCXDIGC.js +52 -0
  49. package/dist/bundle/chunk-JTOKDROB.js +95 -0
  50. package/dist/bundle/chunk-JZMGOVCZ.js +80 -0
  51. package/dist/bundle/chunk-KB3YJJPN.js +794 -0
  52. package/dist/bundle/chunk-KD4EUUER.js +37 -0
  53. package/dist/bundle/chunk-LB6D4QF2.js +2333 -0
  54. package/dist/bundle/chunk-LWUJZ2E3.js +108 -0
  55. package/dist/bundle/chunk-MCQOXTAL.js +53 -0
  56. package/dist/bundle/chunk-MMGCGPKM.js +3571 -0
  57. package/dist/bundle/chunk-MXDIXBIV.js +24 -0
  58. package/dist/bundle/chunk-MYVWV5L5.js +407 -0
  59. package/dist/bundle/chunk-MZNRIH3T.js +1233 -0
  60. package/dist/bundle/chunk-NEFILPPV.js +353 -0
  61. package/dist/bundle/chunk-O6CVJGGL.js +131 -0
  62. package/dist/bundle/chunk-OPXCRQTV.js +161 -0
  63. package/dist/bundle/chunk-PKNFA5TU.js +38 -0
  64. package/dist/bundle/chunk-PL5P7UKW.js +25216 -0
  65. package/dist/bundle/chunk-PO6PLQYL.js +50 -0
  66. package/dist/bundle/chunk-PWUQC2GI.js +218 -0
  67. package/dist/bundle/chunk-QCEEPJNN.js +185 -0
  68. package/dist/bundle/chunk-QG4WCLGB.js +1332 -0
  69. package/dist/bundle/chunk-QNQ2OF24.js +9578 -0
  70. package/dist/bundle/chunk-RCKRXBJF.js +1392 -0
  71. package/dist/bundle/chunk-RK4GN2II.js +2000 -0
  72. package/dist/bundle/chunk-RRH7UK7L.js +106 -0
  73. package/dist/bundle/chunk-S4UUN6LD.js +1410 -0
  74. package/dist/bundle/chunk-S7WJXELM.js +58 -0
  75. package/dist/bundle/chunk-SBRFKB77.js +1197 -0
  76. package/dist/bundle/chunk-SP6DPFZ4.js +4072 -0
  77. package/dist/bundle/chunk-SWJDLFDM.js +557 -0
  78. package/dist/bundle/chunk-TWCVCW5T.js +66 -0
  79. package/dist/bundle/chunk-V2R2BJJU.js +63 -0
  80. package/dist/bundle/chunk-V5K3M7FE.js +78 -0
  81. package/dist/bundle/chunk-V6ALLFEE.js +1068 -0
  82. package/dist/bundle/chunk-V6EVJXLO.js +259 -0
  83. package/dist/bundle/chunk-VJ4CPL6F.js +54 -0
  84. package/dist/bundle/chunk-VL25A6V2.js +41 -0
  85. package/dist/bundle/chunk-WBEZZGZE.js +12645 -0
  86. package/dist/bundle/chunk-WIYAMDPP.js +73 -0
  87. package/dist/bundle/chunk-WRJGITBX.js +76 -0
  88. package/dist/bundle/chunk-XHIVZPQ2.js +7 -0
  89. package/dist/bundle/chunk-XQUUANA2.js +24600 -0
  90. package/dist/bundle/chunk-XTQIXZVM.js +2788 -0
  91. package/dist/bundle/chunk-Y5E2WNWB.js +35 -0
  92. package/dist/bundle/chunk-YKN4Y35P.js +206 -0
  93. package/dist/bundle/chunk-ZMJZQGCN.js +46 -0
  94. package/dist/bundle/chunk-ZPSH27BB.js +274 -0
  95. package/dist/bundle/chunk-ZVVMGPBJ.js +50 -0
  96. package/dist/bundle/command-contract-3FR7BK72.js +37 -0
  97. package/dist/bundle/command-server-entry-4XR4GDS7.js +166 -0
  98. package/dist/bundle/decode-24EITKP4.js +297 -0
  99. package/dist/bundle/definitions-HU62PG4L.js +43364 -0
  100. package/dist/bundle/dispatch-VE6CXCJW.js +411 -0
  101. package/dist/bundle/dist-PAKDDIBT.js +191 -0
  102. package/dist/bundle/dist-ZSNEZYVF.js +7577 -0
  103. package/dist/bundle/echarts-LEVLEF7L.js +42501 -0
  104. package/dist/bundle/embed-G6FGY3VZ.js +38 -0
  105. package/dist/bundle/embedder-B6LNMXZZ.js +111 -0
  106. package/dist/bundle/failure-ASVFQXMF.js +25 -0
  107. package/dist/bundle/first-run-NVXVVALW.js +29 -0
  108. package/dist/bundle/first-screen-N3IPK5AT.js +37 -0
  109. package/dist/bundle/instructions-F3KPYMJK.js +11 -0
  110. package/dist/bundle/mcp-BUCB5ZPE.js +167 -0
  111. package/dist/bundle/meeting-combined-7FREWXMB.js +24 -0
  112. package/dist/bundle/meeting-model-GJPAIUQL.js +25 -0
  113. package/dist/bundle/meeting-semantic-YWY645AH.js +22 -0
  114. package/dist/bundle/node-KM3CUABH.js +2340 -0
  115. package/dist/bundle/node-TLZSIHIJ.js +21 -0
  116. package/dist/bundle/node-WVUZSDLD.js +176 -0
  117. package/dist/bundle/node-sqlite-V4NNKABG.js +74 -0
  118. package/dist/bundle/oauth-7CENTQIN.js +20 -0
  119. package/dist/bundle/open-OLTONZBG.js +23 -0
  120. package/dist/bundle/openai-M6ES74YN.js +238 -0
  121. package/dist/bundle/process-VFIFK5KO.js +91 -0
  122. package/dist/bundle/program-N72VUDXM.js +33418 -0
  123. package/dist/bundle/prompt-TNWPBEBB.js +17 -0
  124. package/dist/bundle/recognize-PV2WOUWS.js +26 -0
  125. package/dist/bundle/remote-3F6JACS5.js +31 -0
  126. package/dist/bundle/rerank-33C67PIV.js +52 -0
  127. package/dist/bundle/schemas-RLDEALIJ.js +21410 -0
  128. package/dist/bundle/serve-3DEMACSQ.js +199 -0
  129. package/dist/bundle/server-AAK2HWQM.js +79 -0
  130. package/dist/bundle/server-LIBRGMUZ.js +212 -0
  131. package/dist/bundle/sqlite-runtime-SMAREHYG.js +20 -0
  132. package/dist/bundle/state-WPHAVJIU.js +36 -0
  133. package/dist/bundle/store-A7V4FEXE.js +177 -0
  134. package/dist/bundle/store-PMAPJNXT.js +291 -0
  135. package/dist/bundle/store-maintenance-command-QHRHAEYN.js +66 -0
  136. package/dist/bundle/surface-MN4RTNYW.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/comments.d.ts +3 -0
  142. package/dist/commands/comments.d.ts.map +1 -0
  143. package/dist/commands/comments.js +114 -0
  144. package/dist/commands/comments.js.map +1 -0
  145. package/dist/commands/crm.d.ts +4 -0
  146. package/dist/commands/crm.d.ts.map +1 -0
  147. package/dist/commands/crm.js +66 -0
  148. package/dist/commands/crm.js.map +1 -0
  149. package/dist/commands/session.d.ts +7 -0
  150. package/dist/commands/session.d.ts.map +1 -0
  151. package/dist/commands/session.js +22 -0
  152. package/dist/commands/session.js.map +1 -0
  153. package/dist/config.d.ts +14 -0
  154. package/dist/config.d.ts.map +1 -0
  155. package/dist/config.js +14 -0
  156. package/dist/config.js.map +1 -0
  157. package/dist/context.d.ts +37 -0
  158. package/dist/context.d.ts.map +1 -0
  159. package/dist/context.js +31 -0
  160. package/dist/context.js.map +1 -0
  161. package/dist/generated/definitions.d.ts +3 -0
  162. package/dist/generated/definitions.d.ts.map +1 -0
  163. package/dist/generated/definitions.js +43360 -0
  164. package/dist/generated/definitions.js.map +1 -0
  165. package/dist/generated/manifest.d.ts +6 -0
  166. package/dist/generated/manifest.d.ts.map +1 -0
  167. package/dist/generated/manifest.js +5158 -0
  168. package/dist/generated/manifest.js.map +1 -0
  169. package/dist/generated/schemas.d.ts +383 -0
  170. package/dist/generated/schemas.d.ts.map +1 -0
  171. package/dist/generated/schemas.js +21196 -0
  172. package/dist/generated/schemas.js.map +1 -0
  173. package/dist/generated/types.d.ts +10156 -0
  174. package/dist/generated/types.d.ts.map +1 -0
  175. package/dist/generated/types.js +5 -0
  176. package/dist/generated/types.js.map +1 -0
  177. package/dist/generated/wirecat-config.d.ts +15 -0
  178. package/dist/generated/wirecat-config.d.ts.map +1 -0
  179. package/dist/generated/wirecat-config.js +328 -0
  180. package/dist/generated/wirecat-config.js.map +1 -0
  181. package/dist/hooks.d.ts +3 -0
  182. package/dist/hooks.d.ts.map +1 -0
  183. package/dist/hooks.js +7 -0
  184. package/dist/hooks.js.map +1 -0
  185. package/dist/identity.d.ts +33 -0
  186. package/dist/identity.d.ts.map +1 -0
  187. package/dist/identity.js +31 -0
  188. package/dist/identity.js.map +1 -0
  189. package/dist/index.d.ts +3 -0
  190. package/dist/index.d.ts.map +1 -0
  191. package/dist/index.js +3 -0
  192. package/dist/index.js.map +1 -0
  193. package/dist/program.d.ts +6 -0
  194. package/dist/program.d.ts.map +1 -0
  195. package/dist/program.js +54 -0
  196. package/dist/program.js.map +1 -0
  197. package/dist/sample/comments.d.ts +61 -0
  198. package/dist/sample/comments.d.ts.map +1 -0
  199. package/dist/sample/comments.js +39 -0
  200. package/dist/sample/comments.js.map +1 -0
  201. package/dist/sample/records.d.ts +16 -0
  202. package/dist/sample/records.d.ts.map +1 -0
  203. package/dist/sample/records.js +22 -0
  204. package/dist/sample/records.js.map +1 -0
  205. package/dist/sample/transport.d.ts +42 -0
  206. package/dist/sample/transport.d.ts.map +1 -0
  207. package/dist/sample/transport.js +153 -0
  208. package/dist/sample/transport.js.map +1 -0
  209. package/dist/version.d.ts +2 -0
  210. package/dist/version.d.ts.map +1 -0
  211. package/dist/version.js +2 -0
  212. package/dist/version.js.map +1 -0
  213. package/dist/wcat.d.ts +3 -0
  214. package/dist/wcat.d.ts.map +1 -0
  215. package/dist/wcat.js +4 -0
  216. package/dist/wcat.js.map +1 -0
  217. package/package.json +87 -4
  218. package/skills/attio-cli/SKILL.md +58 -0
  219. package/skills/attio-cli/references/api/api-activities.md +62 -0
  220. package/skills/attio-cli/references/api/api-activity-records.md +96 -0
  221. package/skills/attio-cli/references/api/api-attributes.md +148 -0
  222. package/skills/attio-cli/references/api/api-call-recordings.md +53 -0
  223. package/skills/attio-cli/references/api/api-comments.md +36 -0
  224. package/skills/attio-cli/references/api/api-emails.md +23 -0
  225. package/skills/attio-cli/references/api/api-entries.md +127 -0
  226. package/skills/attio-cli/references/api/api-files.md +63 -0
  227. package/skills/attio-cli/references/api/api-lists.md +44 -0
  228. package/skills/attio-cli/references/api/api-meetings.md +82 -0
  229. package/skills/attio-cli/references/api/api-meta.md +8 -0
  230. package/skills/attio-cli/references/api/api-notes.md +64 -0
  231. package/skills/attio-cli/references/api/api-objects.md +55 -0
  232. package/skills/attio-cli/references/api/api-records.md +168 -0
  233. package/skills/attio-cli/references/api/api-sequences.md +15 -0
  234. package/skills/attio-cli/references/api/api-sql.md +15 -0
  235. package/skills/attio-cli/references/api/api-tasks.md +67 -0
  236. package/skills/attio-cli/references/api/api-threads.md +35 -0
  237. package/skills/attio-cli/references/api/api-transcripts.md +17 -0
  238. package/skills/attio-cli/references/api/api-views.md +133 -0
  239. package/skills/attio-cli/references/api/api-webhooks.md +62 -0
  240. package/skills/attio-cli/references/api/api-workspace-blocklist.md +39 -0
  241. package/skills/attio-cli/references/api/api-workspace-members.md +19 -0
  242. 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-V5K3M7FE.js";
6
+ import {
7
+ ownerLogin
8
+ } from "./chunk-2P7ENEQ7.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-OPXCRQTV.js";
24
+ import "./chunk-WIYAMDPP.js";
25
+ import "./chunk-V2R2BJJU.js";
26
+ import "./chunk-XTQIXZVM.js";
27
+ import "./chunk-MZNRIH3T.js";
28
+ import "./chunk-S4UUN6LD.js";
29
+ import "./chunk-Y5E2WNWB.js";
30
+ import {
31
+ CliError
32
+ } from "./chunk-5DCRHSBI.js";
33
+ import {
34
+ __name
35
+ } from "./chunk-ZVVMGPBJ.js";
36
+
37
+ // node_modules/.pnpm/@wirecat+cli-core@0.700.0_@wirecat+cli-base@0.118.0_commander@15.0.0_esbuild@0.28.2_typ_365b7216b918b4ff8396dc0e09311081/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,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-KB3YJJPN.js";
10
+ import "./chunk-QG4WCLGB.js";
11
+ import "./chunk-DW3V7GTY.js";
12
+ import "./chunk-IYMWUL6E.js";
13
+ import "./chunk-HQJ2TABD.js";
14
+ import "./chunk-RCKRXBJF.js";
15
+ import "./chunk-NEFILPPV.js";
16
+ import "./chunk-MMGCGPKM.js";
17
+ import "./chunk-PO6PLQYL.js";
18
+ import "./chunk-4HQDT5PF.js";
19
+ import "./chunk-MCQOXTAL.js";
20
+ import "./chunk-SWJDLFDM.js";
21
+ import "./chunk-2H2MWGBD.js";
22
+ import "./chunk-ICUXAOEM.js";
23
+ import "./chunk-MYVWV5L5.js";
24
+ import "./chunk-KD4EUUER.js";
25
+ import "./chunk-BHNFRL3H.js";
26
+ import "./chunk-4QE4L7UL.js";
27
+ import "./chunk-ZMJZQGCN.js";
28
+ import "./chunk-LWUJZ2E3.js";
29
+ import "./chunk-A7YQTQ5U.js";
30
+ import "./chunk-PL5P7UKW.js";
31
+ import "./chunk-WRJGITBX.js";
32
+ import "./chunk-V6EVJXLO.js";
33
+ import "./chunk-IGALQ74S.js";
34
+ import "./chunk-HLLRNP2G.js";
35
+ import "./chunk-OPXCRQTV.js";
36
+ import "./chunk-WIYAMDPP.js";
37
+ import "./chunk-O6CVJGGL.js";
38
+ import "./chunk-WBEZZGZE.js";
39
+ import "./chunk-2343HKEW.js";
40
+ import "./chunk-JKCXDIGC.js";
41
+ import "./chunk-ARRQVUJ2.js";
42
+ import "./chunk-V2R2BJJU.js";
43
+ import "./chunk-AEPOHR4Z.js";
44
+ import "./chunk-V6ALLFEE.js";
45
+ import "./chunk-TWCVCW5T.js";
46
+ import "./chunk-ETSOG6TZ.js";
47
+ import "./chunk-LB6D4QF2.js";
48
+ import "./chunk-JZMGOVCZ.js";
49
+ import "./chunk-4EYKJLWI.js";
50
+ import "./chunk-DVN54VPI.js";
51
+ import "./chunk-RK4GN2II.js";
52
+ import "./chunk-5WAGTWCS.js";
53
+ import "./chunk-FJV3MO57.js";
54
+ import "./chunk-SP6DPFZ4.js";
55
+ import "./chunk-XHIVZPQ2.js";
56
+ import "./chunk-QCEEPJNN.js";
57
+ import "./chunk-5ETXE5KF.js";
58
+ import "./chunk-SBRFKB77.js";
59
+ import "./chunk-7NFEMS4A.js";
60
+ import "./chunk-ZPSH27BB.js";
61
+ import "./chunk-CBPL3GID.js";
62
+ import "./chunk-D72URWJE.js";
63
+ import "./chunk-VJ4CPL6F.js";
64
+ import "./chunk-JTOKDROB.js";
65
+ import "./chunk-PKNFA5TU.js";
66
+ import "./chunk-XTQIXZVM.js";
67
+ import "./chunk-MZNRIH3T.js";
68
+ import "./chunk-S4UUN6LD.js";
69
+ import "./chunk-Y5E2WNWB.js";
70
+ import "./chunk-5DCRHSBI.js";
71
+ import "./chunk-4XHWGJXT.js";
72
+ import "./chunk-ZVVMGPBJ.js";
73
+ export {
74
+ PER_RUN,
75
+ createServer,
76
+ envelope,
77
+ serveOverHttpUntilStopped,
78
+ serveOverStdio
79
+ };
@@ -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-MXDIXBIV.js";
6
+ import {
7
+ skillResources
8
+ } from "./chunk-DW3V7GTY.js";
9
+ import {
10
+ StdioServerTransport,
11
+ answeredWire,
12
+ serveStdio
13
+ } from "./chunk-IYMWUL6E.js";
14
+ import {
15
+ wholeList
16
+ } from "./chunk-NEFILPPV.js";
17
+ import {
18
+ runCommandForAgent,
19
+ toolsFromCommands
20
+ } from "./chunk-MMGCGPKM.js";
21
+ import "./chunk-PO6PLQYL.js";
22
+ import "./chunk-4HQDT5PF.js";
23
+ import {
24
+ answered,
25
+ normal,
26
+ registerCommands
27
+ } from "./chunk-SWJDLFDM.js";
28
+ import {
29
+ agentJson
30
+ } from "./chunk-2H2MWGBD.js";
31
+ import "./chunk-ICUXAOEM.js";
32
+ import "./chunk-MYVWV5L5.js";
33
+ import "./chunk-KD4EUUER.js";
34
+ import "./chunk-BHNFRL3H.js";
35
+ import "./chunk-4QE4L7UL.js";
36
+ import "./chunk-ZMJZQGCN.js";
37
+ import {
38
+ callerOf
39
+ } from "./chunk-LWUJZ2E3.js";
40
+ import "./chunk-A7YQTQ5U.js";
41
+ import {
42
+ McpServer
43
+ } from "./chunk-PL5P7UKW.js";
44
+ import "./chunk-WRJGITBX.js";
45
+ import "./chunk-V6EVJXLO.js";
46
+ import "./chunk-IGALQ74S.js";
47
+ import "./chunk-HLLRNP2G.js";
48
+ import {
49
+ MESSENGER_CHANGE_REFUSAL,
50
+ changesMessenger,
51
+ flatten,
52
+ itemOf,
53
+ readOnlyLockOf,
54
+ readOnlyRefusal
55
+ } from "./chunk-WBEZZGZE.js";
56
+ import "./chunk-2343HKEW.js";
57
+ import "./chunk-JKCXDIGC.js";
58
+ import "./chunk-ARRQVUJ2.js";
59
+ import "./chunk-V2R2BJJU.js";
60
+ import "./chunk-AEPOHR4Z.js";
61
+ import "./chunk-V6ALLFEE.js";
62
+ import "./chunk-TWCVCW5T.js";
63
+ import "./chunk-ETSOG6TZ.js";
64
+ import "./chunk-LB6D4QF2.js";
65
+ import "./chunk-JZMGOVCZ.js";
66
+ import "./chunk-4EYKJLWI.js";
67
+ import "./chunk-DVN54VPI.js";
68
+ import "./chunk-RK4GN2II.js";
69
+ import "./chunk-5WAGTWCS.js";
70
+ import "./chunk-FJV3MO57.js";
71
+ import "./chunk-SP6DPFZ4.js";
72
+ import "./chunk-XHIVZPQ2.js";
73
+ import "./chunk-QCEEPJNN.js";
74
+ import "./chunk-5ETXE5KF.js";
75
+ import "./chunk-SBRFKB77.js";
76
+ import "./chunk-7NFEMS4A.js";
77
+ import "./chunk-ZPSH27BB.js";
78
+ import "./chunk-CBPL3GID.js";
79
+ import "./chunk-D72URWJE.js";
80
+ import "./chunk-VJ4CPL6F.js";
81
+ import "./chunk-JTOKDROB.js";
82
+ import "./chunk-PKNFA5TU.js";
83
+ import "./chunk-XTQIXZVM.js";
84
+ import {
85
+ mcpErrorResult
86
+ } from "./chunk-MZNRIH3T.js";
87
+ import {
88
+ object
89
+ } from "./chunk-S4UUN6LD.js";
90
+ import "./chunk-Y5E2WNWB.js";
91
+ import "./chunk-5DCRHSBI.js";
92
+ import "./chunk-4XHWGJXT.js";
93
+ import {
94
+ __name
95
+ } from "./chunk-ZVVMGPBJ.js";
96
+
97
+ // node_modules/.pnpm/@wirecat+cli-core@0.700.0_@wirecat+cli-base@0.118.0_commander@15.0.0_esbuild@0.28.2_typ_365b7216b918b4ff8396dc0e09311081/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,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-RRH7UK7L.js";
8
+ import "./chunk-JTOKDROB.js";
9
+ import "./chunk-PKNFA5TU.js";
10
+ import "./chunk-XTQIXZVM.js";
11
+ import "./chunk-MZNRIH3T.js";
12
+ import "./chunk-S4UUN6LD.js";
13
+ import "./chunk-Y5E2WNWB.js";
14
+ import "./chunk-5DCRHSBI.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-OPXCRQTV.js";
16
+ import "./chunk-WIYAMDPP.js";
17
+ import "./chunk-V2R2BJJU.js";
18
+ import "./chunk-XTQIXZVM.js";
19
+ import "./chunk-MZNRIH3T.js";
20
+ import "./chunk-S4UUN6LD.js";
21
+ import "./chunk-Y5E2WNWB.js";
22
+ import "./chunk-5DCRHSBI.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
+ };