lurqrun 0.1.6 → 0.1.8

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 (239) hide show
  1. package/README.md +311 -139
  2. package/dist/auditHandler-VWCXSDVO.js +24 -0
  3. package/dist/autopilotInit-Q62MX5M6.js +178 -0
  4. package/dist/bin/lurq.js +3255 -23319
  5. package/dist/browserAuth-J7APSD4P.js +96 -0
  6. package/dist/cache-AEAKCV4I.js +12 -0
  7. package/dist/check-2JTQDQA6.js +2613 -0
  8. package/dist/check-PQSQ2MMA.js +192 -0
  9. package/dist/checkUpgrade-5YW77OBL.js +24 -0
  10. package/dist/chunk-2GAYNIHG.js +40 -0
  11. package/dist/chunk-2O6Z37IT.js +423 -0
  12. package/dist/chunk-2WD4QAH4.js +116 -0
  13. package/dist/chunk-3676XOBU.js +2235 -0
  14. package/dist/chunk-3D2MPGOQ.js +181 -0
  15. package/dist/chunk-3GHJR7XR.js +2049 -0
  16. package/dist/chunk-4ESO33J6.js +34 -0
  17. package/dist/chunk-4JHDSVIN.js +1229 -0
  18. package/dist/chunk-4KCPOMG6.js +68 -0
  19. package/dist/chunk-53SG6XWA.js +141 -0
  20. package/dist/chunk-5ABNDB3I.js +37 -0
  21. package/dist/chunk-5ALIJFDA.js +114 -0
  22. package/dist/chunk-63MUJNZL.js +318 -0
  23. package/dist/chunk-64ZF7KO4.js +1571 -0
  24. package/dist/chunk-6DM6UQFD.js +318 -0
  25. package/dist/chunk-6EQ3ARXA.js +304 -0
  26. package/dist/chunk-6L67QMCP.js +92 -0
  27. package/dist/chunk-72Y2FDVS.js +172 -0
  28. package/dist/chunk-A3TYI2TF.js +288 -0
  29. package/dist/chunk-B2UUYRBX.js +536 -0
  30. package/dist/chunk-BJT2LHAR.js +320 -0
  31. package/dist/chunk-BM3LF5T6.js +132 -0
  32. package/dist/chunk-BN3NM47Q.js +214 -0
  33. package/dist/chunk-BUALU27S.js +123 -0
  34. package/dist/chunk-C6GLE626.js +160 -0
  35. package/dist/chunk-D3K6IZVR.js +12845 -0
  36. package/dist/chunk-D3VTZS7V.js +222 -0
  37. package/dist/chunk-DM37MTOO.js +636 -0
  38. package/dist/chunk-DONTW3NE.js +171 -0
  39. package/dist/chunk-DSROTZ3Z.js +38 -0
  40. package/dist/chunk-ELGCAM7P.js +184 -0
  41. package/dist/chunk-EQCXENKZ.js +130 -0
  42. package/dist/chunk-EYAKM6YN.js +96 -0
  43. package/dist/chunk-FDFPMBCA.js +112 -0
  44. package/dist/chunk-FVYFV5HA.js +154 -0
  45. package/dist/chunk-GE37NVLN.js +15 -0
  46. package/dist/chunk-GM5Y555O.js +143 -0
  47. package/dist/chunk-GRJXQBQZ.js +793 -0
  48. package/dist/chunk-HWFX4BC4.js +177 -0
  49. package/dist/chunk-I3M2KJXB.js +56 -0
  50. package/dist/chunk-IFNONGRQ.js +603 -0
  51. package/dist/chunk-J3U2CPSK.js +136 -0
  52. package/dist/chunk-J6XQ7OPZ.js +74 -0
  53. package/dist/chunk-KMV4Y6R3.js +127 -0
  54. package/dist/chunk-KP5ZDDPE.js +340 -0
  55. package/dist/chunk-KYKSZ3XZ.js +202 -0
  56. package/dist/chunk-LEGPB7DO.js +81 -0
  57. package/dist/chunk-LUAKDHLZ.js +40 -0
  58. package/dist/chunk-MHUEVBVO.js +35 -0
  59. package/dist/chunk-MYGSLK44.js +37 -0
  60. package/dist/chunk-NEZNAPPN.js +41 -0
  61. package/dist/chunk-NPVN2THM.js +197 -0
  62. package/dist/chunk-NYZU5NCW.js +23 -0
  63. package/dist/chunk-O4KHCV6I.js +320 -0
  64. package/dist/chunk-ONDVTXUO.js +240 -0
  65. package/dist/chunk-OTJFHESY.js +176 -0
  66. package/dist/chunk-P6MIKSPY.js +243 -0
  67. package/dist/chunk-Q5VPF4WI.js +26 -0
  68. package/dist/chunk-QCRBX3LV.js +165 -0
  69. package/dist/chunk-QKGYDMWB.js +7409 -0
  70. package/dist/chunk-QSL6QN5X.js +115 -0
  71. package/dist/chunk-QUIMQ7YL.js +73 -0
  72. package/dist/chunk-RG3YLU6E.js +49 -0
  73. package/dist/chunk-SHCEBP3J.js +107 -0
  74. package/dist/chunk-SHZFOSXC.js +462 -0
  75. package/dist/chunk-SOXFMMXC.js +151 -0
  76. package/dist/chunk-TDTYV6QI.js +119 -0
  77. package/dist/chunk-TNTXWSYA.js +19 -0
  78. package/dist/chunk-TUXQ32WE.js +2251 -0
  79. package/dist/chunk-VGCDRK3S.js +37 -0
  80. package/dist/chunk-VLRHFMGJ.js +58 -0
  81. package/dist/chunk-WHX2ZFCG.js +4048 -0
  82. package/dist/chunk-X4W64MHU.js +2005 -0
  83. package/dist/chunk-XBQA4I36.js +92 -0
  84. package/dist/chunk-XGOV6KV4.js +413 -0
  85. package/dist/chunk-XIFQIFSZ.js +940 -0
  86. package/dist/chunk-XLXPVN3Y.js +15393 -0
  87. package/dist/chunk-ZJMLQ37G.js +90 -0
  88. package/dist/client-MU4EUDZV.js +15 -0
  89. package/dist/commands-UOOTMBKA.js +1023 -0
  90. package/dist/compat-Q5DVPITN.js +201 -0
  91. package/dist/constants-DJFOFZ44.js +24 -0
  92. package/dist/dashboardIssue-KBKLQMGC.js +274 -0
  93. package/dist/diff-I4SNUHU3.js +13 -0
  94. package/dist/dist-4XXIXHHZ.js +12945 -0
  95. package/dist/domains-VRT4BRVZ.js +14 -0
  96. package/dist/e2b-FVPHDULZ.js +172 -0
  97. package/dist/env-UN6KGZ7S.js +15 -0
  98. package/dist/envCheck-KUPTORFQ.js +71 -0
  99. package/dist/extract-6WG265BL.js +455 -0
  100. package/dist/fetch-PJ3SC32M.js +22 -0
  101. package/dist/firstTouch-COJCMOB3.js +55 -0
  102. package/dist/fix-3EDWNKW3.js +220 -0
  103. package/dist/handlers-4Q37WIFT.js +55 -0
  104. package/dist/hook-NA66XJLC.js +412 -0
  105. package/dist/http-25GJ6SKK.js +6928 -0
  106. package/dist/ingestQueue-FSVJC3AA.js +37 -0
  107. package/dist/install-G2HHXYJ2.js +20 -0
  108. package/dist/installSkill-5TIMYIJZ.js +70 -0
  109. package/dist/inventory-5AWSLJYU.js +31 -0
  110. package/dist/local-XPZMRH5R.js +13 -0
  111. package/dist/manifest-ENMIC54B.js +13 -0
  112. package/dist/mcp-PENLL2PK.js +500 -0
  113. package/dist/mcpConfig-3LYPRY5Q.js +80 -0
  114. package/dist/mcpHandlers-PO7GENA7.js +22 -0
  115. package/dist/mcpScan-ULP626TQ.js +1735 -0
  116. package/dist/mcpScanWorkflow-27O44FOE.js +98 -0
  117. package/dist/mcpStack-ZNYIFXZ5.js +20 -0
  118. package/dist/model-ASMZWLM7.js +214 -0
  119. package/dist/packages-RWF2LXST.js +40 -0
  120. package/dist/plan-SDILIDZT.js +465 -0
  121. package/dist/planView-ZAKRTGVS.js +82 -0
  122. package/dist/policy-JAGNMQJI.js +115 -0
  123. package/dist/probe-3IK646WN.js +610 -0
  124. package/dist/publicUpgrades-WTBGLDIK.js +42 -0
  125. package/dist/references-I6Y4BSRR.js +16 -0
  126. package/dist/release-7IU2R4YG.js +128 -0
  127. package/dist/remote-FN6225AH.js +42 -0
  128. package/dist/rename-OS6JYBZQ.js +204 -0
  129. package/dist/reportRuns-O4X7ZFTX.js +77 -0
  130. package/dist/safeFetch-COERXGFN.js +19 -0
  131. package/dist/sandbox-SAPSRKEI.js +39 -0
  132. package/dist/sarif-WLVJFJ7U.js +125 -0
  133. package/dist/server-OLTY3NYT.js +59 -0
  134. package/dist/surface-7MHE3RL7.js +143 -0
  135. package/dist/surface-JS2XU3U3.js +38 -0
  136. package/dist/surfaceHandlers-4B6TMZ34.js +20 -0
  137. package/dist/typecheck-NGOKNAJY.js +282 -0
  138. package/dist/types-M5JP2W3D.js +10 -0
  139. package/dist/uninstall-I2IJP5JZ.js +200 -0
  140. package/dist/upgrade-FS26DJGG.js +650 -0
  141. package/dist/upgradePlan-ZS5IOVMZ.js +181 -0
  142. package/dist/upkeepHandler-VFGYXJKB.js +13 -0
  143. package/dist/userConfig-ICASHI47.js +20 -0
  144. package/dist/watch-OCNEUXG6.js +204 -0
  145. package/package.json +26 -20
  146. package/templates/agent-rules.md +4 -4
  147. package/templates/skill-instructions.md +35 -17
  148. package/dist/bin/lurq.js.map +0 -1
  149. package/dist/index.d.ts +0 -805
  150. package/dist/index.js +0 -23570
  151. package/dist/index.js.map +0 -1
  152. package/drizzle/0000_confused_fabian_cortez.sql +0 -54
  153. package/drizzle/0001_aspiring_timeslip.sql +0 -15
  154. package/drizzle/0002_lyrical_lila_cheney.sql +0 -14
  155. package/drizzle/0003_violet_giant_girl.sql +0 -14
  156. package/drizzle/0004_slim_valeria_richards.sql +0 -15
  157. package/drizzle/0005_petite_luke_cage.sql +0 -12
  158. package/drizzle/0006_calm_nighthawk.sql +0 -3
  159. package/drizzle/0007_slimy_naoko.sql +0 -1
  160. package/drizzle/0008_peaceful_tigra.sql +0 -1
  161. package/drizzle/0009_smooth_harrier.sql +0 -10
  162. package/drizzle/0010_curved_amphibian.sql +0 -2
  163. package/drizzle/0011_compat_provenance_closures.sql +0 -11
  164. package/drizzle/0012_api_surfaces.sql +0 -9
  165. package/drizzle/0013_nice_thanos.sql +0 -1
  166. package/drizzle/0014_luxuriant_malcolm_colcord.sql +0 -10
  167. package/drizzle/0015_past_fat_cobra.sql +0 -11
  168. package/drizzle/0016_futuristic_junta.sql +0 -50
  169. package/drizzle/0017_absent_grandmaster.sql +0 -20
  170. package/drizzle/0018_rainy_proemial_gods.sql +0 -1
  171. package/drizzle/0019_dashing_korvac.sql +0 -11
  172. package/drizzle/0020_normal_vulture.sql +0 -3
  173. package/drizzle/0021_dazzling_blue_shield.sql +0 -17
  174. package/drizzle/0022_massive_ghost_rider.sql +0 -24
  175. package/drizzle/0023_next_shatterstar.sql +0 -1
  176. package/drizzle/0024_dusty_maelstrom.sql +0 -15
  177. package/drizzle/0025_gifted_harpoon.sql +0 -5
  178. package/drizzle/0026_awesome_mordo.sql +0 -1
  179. package/drizzle/0027_charming_ulik.sql +0 -2
  180. package/drizzle/0028_romantic_loners.sql +0 -2
  181. package/drizzle/0029_busy_korvac.sql +0 -16
  182. package/drizzle/0030_steady_mathemanic.sql +0 -6
  183. package/drizzle/0031_redundant_maginty.sql +0 -2
  184. package/drizzle/0032_stack_resolutions.sql +0 -14
  185. package/drizzle/0033_graceful_tyger_tiger.sql +0 -3
  186. package/drizzle/0034_uneven_thunderbird.sql +0 -1
  187. package/drizzle/0035_api_key_scopes.sql +0 -1
  188. package/drizzle/0036_policy_audit.sql +0 -21
  189. package/drizzle/0037_subscription_seats.sql +0 -1
  190. package/drizzle/0038_symbol_offsets.sql +0 -2
  191. package/drizzle/0039_mcp_runtime_scans.sql +0 -80
  192. package/drizzle/0040_subscription_overage_and_interval.sql +0 -4
  193. package/drizzle/0041_account_email.sql +0 -38
  194. package/drizzle/0042_alert_channels.sql +0 -21
  195. package/drizzle/meta/0000_snapshot.json +0 -370
  196. package/drizzle/meta/0001_snapshot.json +0 -482
  197. package/drizzle/meta/0002_snapshot.json +0 -575
  198. package/drizzle/meta/0003_snapshot.json +0 -667
  199. package/drizzle/meta/0004_snapshot.json +0 -769
  200. package/drizzle/meta/0005_snapshot.json +0 -864
  201. package/drizzle/meta/0006_snapshot.json +0 -882
  202. package/drizzle/meta/0007_snapshot.json +0 -876
  203. package/drizzle/meta/0008_snapshot.json +0 -882
  204. package/drizzle/meta/0009_snapshot.json +0 -948
  205. package/drizzle/meta/0010_snapshot.json +0 -969
  206. package/drizzle/meta/0011_snapshot.json +0 -1049
  207. package/drizzle/meta/0012_snapshot.json +0 -1115
  208. package/drizzle/meta/0013_snapshot.json +0 -1121
  209. package/drizzle/meta/0014_snapshot.json +0 -1190
  210. package/drizzle/meta/0015_snapshot.json +0 -1280
  211. package/drizzle/meta/0016_snapshot.json +0 -1683
  212. package/drizzle/meta/0017_snapshot.json +0 -1834
  213. package/drizzle/meta/0018_snapshot.json +0 -1834
  214. package/drizzle/meta/0019_snapshot.json +0 -1909
  215. package/drizzle/meta/0020_snapshot.json +0 -1921
  216. package/drizzle/meta/0021_snapshot.json +0 -2045
  217. package/drizzle/meta/0022_snapshot.json +0 -2246
  218. package/drizzle/meta/0023_snapshot.json +0 -2252
  219. package/drizzle/meta/0024_snapshot.json +0 -2375
  220. package/drizzle/meta/0025_snapshot.json +0 -2407
  221. package/drizzle/meta/0026_snapshot.json +0 -2413
  222. package/drizzle/meta/0027_snapshot.json +0 -2425
  223. package/drizzle/meta/0028_snapshot.json +0 -2438
  224. package/drizzle/meta/0029_snapshot.json +0 -2546
  225. package/drizzle/meta/0030_snapshot.json +0 -2586
  226. package/drizzle/meta/0031_snapshot.json +0 -2598
  227. package/drizzle/meta/0032_snapshot.json +0 -2699
  228. package/drizzle/meta/0033_snapshot.json +0 -2712
  229. package/drizzle/meta/0034_snapshot.json +0 -2719
  230. package/drizzle/meta/0035_snapshot.json +0 -2726
  231. package/drizzle/meta/0036_snapshot.json +0 -2876
  232. package/drizzle/meta/0037_snapshot.json +0 -2883
  233. package/drizzle/meta/0038_snapshot.json +0 -2895
  234. package/drizzle/meta/0039_snapshot.json +0 -3501
  235. package/drizzle/meta/0040_snapshot.json +0 -3527
  236. package/drizzle/meta/0041_snapshot.json +0 -3824
  237. package/drizzle/meta/0042_snapshot.json +0 -3960
  238. package/drizzle/meta/_journal.json +0 -307
  239. package/src/data/seed.json +0 -253
@@ -0,0 +1,940 @@
1
+ import { createRequire as __lurqCreateRequire } from 'node:module'; const require = __lurqCreateRequire(import.meta.url);
2
+ import {
3
+ AjvJsonSchemaValidator,
4
+ Protocol,
5
+ assertClientRequestTaskCapability,
6
+ assertToolsCallTaskCapability,
7
+ getObjectShape,
8
+ isZ4Schema,
9
+ mergeCapabilities,
10
+ safeParse
11
+ } from "./chunk-XLXPVN3Y.js";
12
+ import {
13
+ CallToolResultSchema,
14
+ CompleteResultSchema,
15
+ CreateMessageRequestSchema,
16
+ CreateMessageResultSchema,
17
+ CreateMessageResultWithToolsSchema,
18
+ CreateTaskResultSchema,
19
+ ElicitRequestSchema,
20
+ ElicitResultSchema,
21
+ EmptyResultSchema,
22
+ ErrorCode,
23
+ GetPromptResultSchema,
24
+ InitializeResultSchema,
25
+ LATEST_PROTOCOL_VERSION,
26
+ ListChangedOptionsBaseSchema,
27
+ ListPromptsResultSchema,
28
+ ListResourceTemplatesResultSchema,
29
+ ListResourcesResultSchema,
30
+ ListToolsResultSchema,
31
+ McpError,
32
+ PromptListChangedNotificationSchema,
33
+ ReadResourceResultSchema,
34
+ ResourceListChangedNotificationSchema,
35
+ SUPPORTED_PROTOCOL_VERSIONS,
36
+ ToolListChangedNotificationSchema
37
+ } from "./chunk-D3K6IZVR.js";
38
+ import {
39
+ surfaceHash
40
+ } from "./chunk-6EQ3ARXA.js";
41
+ import {
42
+ init_esm_shims
43
+ } from "./chunk-I3M2KJXB.js";
44
+
45
+ // node_modules/@modelcontextprotocol/sdk/dist/esm/client/index.js
46
+ init_esm_shims();
47
+
48
+ // node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/client.js
49
+ init_esm_shims();
50
+ var ExperimentalClientTasks = class {
51
+ constructor(_client) {
52
+ this._client = _client;
53
+ }
54
+ /**
55
+ * Calls a tool and returns an AsyncGenerator that yields response messages.
56
+ * The generator is guaranteed to end with either a 'result' or 'error' message.
57
+ *
58
+ * This method provides streaming access to tool execution, allowing you to
59
+ * observe intermediate task status updates for long-running tool calls.
60
+ * Automatically validates structured output if the tool has an outputSchema.
61
+ *
62
+ * @example
63
+ * ```typescript
64
+ * const stream = client.experimental.tasks.callToolStream({ name: 'myTool', arguments: {} });
65
+ * for await (const message of stream) {
66
+ * switch (message.type) {
67
+ * case 'taskCreated':
68
+ * console.log('Tool execution started:', message.task.taskId);
69
+ * break;
70
+ * case 'taskStatus':
71
+ * console.log('Tool status:', message.task.status);
72
+ * break;
73
+ * case 'result':
74
+ * console.log('Tool result:', message.result);
75
+ * break;
76
+ * case 'error':
77
+ * console.error('Tool error:', message.error);
78
+ * break;
79
+ * }
80
+ * }
81
+ * ```
82
+ *
83
+ * @param params - Tool call parameters (name and arguments)
84
+ * @param resultSchema - Zod schema for validating the result (defaults to CallToolResultSchema)
85
+ * @param options - Optional request options (timeout, signal, task creation params, etc.)
86
+ * @returns AsyncGenerator that yields ResponseMessage objects
87
+ *
88
+ * @experimental
89
+ */
90
+ async *callToolStream(params, resultSchema = CallToolResultSchema, options) {
91
+ const clientInternal = this._client;
92
+ const optionsWithTask = {
93
+ ...options,
94
+ // We check if the tool is known to be a task during auto-configuration, but assume
95
+ // the caller knows what they're doing if they pass this explicitly
96
+ task: options?.task ?? (clientInternal.isToolTask(params.name) ? {} : void 0)
97
+ };
98
+ const stream = clientInternal.requestStream({ method: "tools/call", params }, resultSchema, optionsWithTask);
99
+ const validator = clientInternal.getToolOutputValidator(params.name);
100
+ for await (const message of stream) {
101
+ if (message.type === "result" && validator) {
102
+ const result = message.result;
103
+ if (!result.structuredContent && !result.isError) {
104
+ yield {
105
+ type: "error",
106
+ error: new McpError(ErrorCode.InvalidRequest, `Tool ${params.name} has an output schema but did not return structured content`)
107
+ };
108
+ return;
109
+ }
110
+ if (result.structuredContent) {
111
+ try {
112
+ const validationResult = validator(result.structuredContent);
113
+ if (!validationResult.valid) {
114
+ yield {
115
+ type: "error",
116
+ error: new McpError(ErrorCode.InvalidParams, `Structured content does not match the tool's output schema: ${validationResult.errorMessage}`)
117
+ };
118
+ return;
119
+ }
120
+ } catch (error) {
121
+ if (error instanceof McpError) {
122
+ yield { type: "error", error };
123
+ return;
124
+ }
125
+ yield {
126
+ type: "error",
127
+ error: new McpError(ErrorCode.InvalidParams, `Failed to validate structured content: ${error instanceof Error ? error.message : String(error)}`)
128
+ };
129
+ return;
130
+ }
131
+ }
132
+ }
133
+ yield message;
134
+ }
135
+ }
136
+ /**
137
+ * Gets the current status of a task.
138
+ *
139
+ * @param taskId - The task identifier
140
+ * @param options - Optional request options
141
+ * @returns The task status
142
+ *
143
+ * @experimental
144
+ */
145
+ async getTask(taskId, options) {
146
+ return this._client.getTask({ taskId }, options);
147
+ }
148
+ /**
149
+ * Retrieves the result of a completed task.
150
+ *
151
+ * @param taskId - The task identifier
152
+ * @param resultSchema - Zod schema for validating the result
153
+ * @param options - Optional request options
154
+ * @returns The task result
155
+ *
156
+ * @experimental
157
+ */
158
+ async getTaskResult(taskId, resultSchema, options) {
159
+ return this._client.getTaskResult({ taskId }, resultSchema, options);
160
+ }
161
+ /**
162
+ * Lists tasks with optional pagination.
163
+ *
164
+ * @param cursor - Optional pagination cursor
165
+ * @param options - Optional request options
166
+ * @returns List of tasks with optional next cursor
167
+ *
168
+ * @experimental
169
+ */
170
+ async listTasks(cursor, options) {
171
+ return this._client.listTasks(cursor ? { cursor } : void 0, options);
172
+ }
173
+ /**
174
+ * Cancels a running task.
175
+ *
176
+ * @param taskId - The task identifier
177
+ * @param options - Optional request options
178
+ *
179
+ * @experimental
180
+ */
181
+ async cancelTask(taskId, options) {
182
+ return this._client.cancelTask({ taskId }, options);
183
+ }
184
+ /**
185
+ * Sends a request and returns an AsyncGenerator that yields response messages.
186
+ * The generator is guaranteed to end with either a 'result' or 'error' message.
187
+ *
188
+ * This method provides streaming access to request processing, allowing you to
189
+ * observe intermediate task status updates for task-augmented requests.
190
+ *
191
+ * @param request - The request to send
192
+ * @param resultSchema - Zod schema for validating the result
193
+ * @param options - Optional request options (timeout, signal, task creation params, etc.)
194
+ * @returns AsyncGenerator that yields ResponseMessage objects
195
+ *
196
+ * @experimental
197
+ */
198
+ requestStream(request, resultSchema, options) {
199
+ return this._client.requestStream(request, resultSchema, options);
200
+ }
201
+ };
202
+
203
+ // node_modules/@modelcontextprotocol/sdk/dist/esm/client/index.js
204
+ function applyElicitationDefaults(schema2, data) {
205
+ if (!schema2 || data === null || typeof data !== "object")
206
+ return;
207
+ if (schema2.type === "object" && schema2.properties && typeof schema2.properties === "object") {
208
+ const obj = data;
209
+ const props = schema2.properties;
210
+ for (const key of Object.keys(props)) {
211
+ const propSchema = props[key];
212
+ if (obj[key] === void 0 && Object.prototype.hasOwnProperty.call(propSchema, "default")) {
213
+ obj[key] = propSchema.default;
214
+ }
215
+ if (obj[key] !== void 0) {
216
+ applyElicitationDefaults(propSchema, obj[key]);
217
+ }
218
+ }
219
+ }
220
+ if (Array.isArray(schema2.anyOf)) {
221
+ for (const sub of schema2.anyOf) {
222
+ if (typeof sub !== "boolean") {
223
+ applyElicitationDefaults(sub, data);
224
+ }
225
+ }
226
+ }
227
+ if (Array.isArray(schema2.oneOf)) {
228
+ for (const sub of schema2.oneOf) {
229
+ if (typeof sub !== "boolean") {
230
+ applyElicitationDefaults(sub, data);
231
+ }
232
+ }
233
+ }
234
+ }
235
+ function getSupportedElicitationModes(capabilities) {
236
+ if (!capabilities) {
237
+ return { supportsFormMode: false, supportsUrlMode: false };
238
+ }
239
+ const hasFormCapability = capabilities.form !== void 0;
240
+ const hasUrlCapability = capabilities.url !== void 0;
241
+ const supportsFormMode = hasFormCapability || !hasFormCapability && !hasUrlCapability;
242
+ const supportsUrlMode = hasUrlCapability;
243
+ return { supportsFormMode, supportsUrlMode };
244
+ }
245
+ var Client = class extends Protocol {
246
+ /**
247
+ * Initializes this client with the given name and version information.
248
+ */
249
+ constructor(_clientInfo, options) {
250
+ super(options);
251
+ this._clientInfo = _clientInfo;
252
+ this._cachedToolOutputValidators = /* @__PURE__ */ new Map();
253
+ this._cachedKnownTaskTools = /* @__PURE__ */ new Set();
254
+ this._cachedRequiredTaskTools = /* @__PURE__ */ new Set();
255
+ this._listChangedDebounceTimers = /* @__PURE__ */ new Map();
256
+ this._capabilities = options?.capabilities ?? {};
257
+ this._jsonSchemaValidator = options?.jsonSchemaValidator ?? new AjvJsonSchemaValidator();
258
+ if (options?.listChanged) {
259
+ this._pendingListChangedConfig = options.listChanged;
260
+ }
261
+ }
262
+ /**
263
+ * Set up handlers for list changed notifications based on config and server capabilities.
264
+ * This should only be called after initialization when server capabilities are known.
265
+ * Handlers are silently skipped if the server doesn't advertise the corresponding listChanged capability.
266
+ * @internal
267
+ */
268
+ _setupListChangedHandlers(config) {
269
+ if (config.tools && this._serverCapabilities?.tools?.listChanged) {
270
+ this._setupListChangedHandler("tools", ToolListChangedNotificationSchema, config.tools, async () => {
271
+ const result = await this.listTools();
272
+ return result.tools;
273
+ });
274
+ }
275
+ if (config.prompts && this._serverCapabilities?.prompts?.listChanged) {
276
+ this._setupListChangedHandler("prompts", PromptListChangedNotificationSchema, config.prompts, async () => {
277
+ const result = await this.listPrompts();
278
+ return result.prompts;
279
+ });
280
+ }
281
+ if (config.resources && this._serverCapabilities?.resources?.listChanged) {
282
+ this._setupListChangedHandler("resources", ResourceListChangedNotificationSchema, config.resources, async () => {
283
+ const result = await this.listResources();
284
+ return result.resources;
285
+ });
286
+ }
287
+ }
288
+ /**
289
+ * Access experimental features.
290
+ *
291
+ * WARNING: These APIs are experimental and may change without notice.
292
+ *
293
+ * @experimental
294
+ */
295
+ get experimental() {
296
+ if (!this._experimental) {
297
+ this._experimental = {
298
+ tasks: new ExperimentalClientTasks(this)
299
+ };
300
+ }
301
+ return this._experimental;
302
+ }
303
+ /**
304
+ * Registers new capabilities. This can only be called before connecting to a transport.
305
+ *
306
+ * The new capabilities will be merged with any existing capabilities previously given (e.g., at initialization).
307
+ */
308
+ registerCapabilities(capabilities) {
309
+ if (this.transport) {
310
+ throw new Error("Cannot register capabilities after connecting to transport");
311
+ }
312
+ this._capabilities = mergeCapabilities(this._capabilities, capabilities);
313
+ }
314
+ /**
315
+ * Override request handler registration to enforce client-side validation for elicitation.
316
+ */
317
+ setRequestHandler(requestSchema, handler) {
318
+ const shape = getObjectShape(requestSchema);
319
+ const methodSchema = shape?.method;
320
+ if (!methodSchema) {
321
+ throw new Error("Schema is missing a method literal");
322
+ }
323
+ let methodValue;
324
+ if (isZ4Schema(methodSchema)) {
325
+ const v4Schema = methodSchema;
326
+ const v4Def = v4Schema._zod?.def;
327
+ methodValue = v4Def?.value ?? v4Schema.value;
328
+ } else {
329
+ const v3Schema = methodSchema;
330
+ const legacyDef = v3Schema._def;
331
+ methodValue = legacyDef?.value ?? v3Schema.value;
332
+ }
333
+ if (typeof methodValue !== "string") {
334
+ throw new Error("Schema method literal must be a string");
335
+ }
336
+ const method = methodValue;
337
+ if (method === "elicitation/create") {
338
+ const wrappedHandler = async (request, extra) => {
339
+ const validatedRequest = safeParse(ElicitRequestSchema, request);
340
+ if (!validatedRequest.success) {
341
+ const errorMessage = validatedRequest.error instanceof Error ? validatedRequest.error.message : String(validatedRequest.error);
342
+ throw new McpError(ErrorCode.InvalidParams, `Invalid elicitation request: ${errorMessage}`);
343
+ }
344
+ const { params } = validatedRequest.data;
345
+ params.mode = params.mode ?? "form";
346
+ const { supportsFormMode, supportsUrlMode } = getSupportedElicitationModes(this._capabilities.elicitation);
347
+ if (params.mode === "form" && !supportsFormMode) {
348
+ throw new McpError(ErrorCode.InvalidParams, "Client does not support form-mode elicitation requests");
349
+ }
350
+ if (params.mode === "url" && !supportsUrlMode) {
351
+ throw new McpError(ErrorCode.InvalidParams, "Client does not support URL-mode elicitation requests");
352
+ }
353
+ const result = await Promise.resolve(handler(request, extra));
354
+ if (params.task) {
355
+ const taskValidationResult = safeParse(CreateTaskResultSchema, result);
356
+ if (!taskValidationResult.success) {
357
+ const errorMessage = taskValidationResult.error instanceof Error ? taskValidationResult.error.message : String(taskValidationResult.error);
358
+ throw new McpError(ErrorCode.InvalidParams, `Invalid task creation result: ${errorMessage}`);
359
+ }
360
+ return taskValidationResult.data;
361
+ }
362
+ const validationResult = safeParse(ElicitResultSchema, result);
363
+ if (!validationResult.success) {
364
+ const errorMessage = validationResult.error instanceof Error ? validationResult.error.message : String(validationResult.error);
365
+ throw new McpError(ErrorCode.InvalidParams, `Invalid elicitation result: ${errorMessage}`);
366
+ }
367
+ const validatedResult = validationResult.data;
368
+ const requestedSchema = params.mode === "form" ? params.requestedSchema : void 0;
369
+ if (params.mode === "form" && validatedResult.action === "accept" && validatedResult.content && requestedSchema) {
370
+ if (this._capabilities.elicitation?.form?.applyDefaults) {
371
+ try {
372
+ applyElicitationDefaults(requestedSchema, validatedResult.content);
373
+ } catch {
374
+ }
375
+ }
376
+ }
377
+ return validatedResult;
378
+ };
379
+ return super.setRequestHandler(requestSchema, wrappedHandler);
380
+ }
381
+ if (method === "sampling/createMessage") {
382
+ const wrappedHandler = async (request, extra) => {
383
+ const validatedRequest = safeParse(CreateMessageRequestSchema, request);
384
+ if (!validatedRequest.success) {
385
+ const errorMessage = validatedRequest.error instanceof Error ? validatedRequest.error.message : String(validatedRequest.error);
386
+ throw new McpError(ErrorCode.InvalidParams, `Invalid sampling request: ${errorMessage}`);
387
+ }
388
+ const { params } = validatedRequest.data;
389
+ const result = await Promise.resolve(handler(request, extra));
390
+ if (params.task) {
391
+ const taskValidationResult = safeParse(CreateTaskResultSchema, result);
392
+ if (!taskValidationResult.success) {
393
+ const errorMessage = taskValidationResult.error instanceof Error ? taskValidationResult.error.message : String(taskValidationResult.error);
394
+ throw new McpError(ErrorCode.InvalidParams, `Invalid task creation result: ${errorMessage}`);
395
+ }
396
+ return taskValidationResult.data;
397
+ }
398
+ const hasTools = params.tools || params.toolChoice;
399
+ const resultSchema = hasTools ? CreateMessageResultWithToolsSchema : CreateMessageResultSchema;
400
+ const validationResult = safeParse(resultSchema, result);
401
+ if (!validationResult.success) {
402
+ const errorMessage = validationResult.error instanceof Error ? validationResult.error.message : String(validationResult.error);
403
+ throw new McpError(ErrorCode.InvalidParams, `Invalid sampling result: ${errorMessage}`);
404
+ }
405
+ return validationResult.data;
406
+ };
407
+ return super.setRequestHandler(requestSchema, wrappedHandler);
408
+ }
409
+ return super.setRequestHandler(requestSchema, handler);
410
+ }
411
+ assertCapability(capability, method) {
412
+ if (!this._serverCapabilities?.[capability]) {
413
+ throw new Error(`Server does not support ${capability} (required for ${method})`);
414
+ }
415
+ }
416
+ async connect(transport, options) {
417
+ await super.connect(transport);
418
+ if (transport.sessionId !== void 0) {
419
+ return;
420
+ }
421
+ try {
422
+ const result = await this.request({
423
+ method: "initialize",
424
+ params: {
425
+ protocolVersion: LATEST_PROTOCOL_VERSION,
426
+ capabilities: this._capabilities,
427
+ clientInfo: this._clientInfo
428
+ }
429
+ }, InitializeResultSchema, options);
430
+ if (result === void 0) {
431
+ throw new Error(`Server sent invalid initialize result: ${result}`);
432
+ }
433
+ if (!SUPPORTED_PROTOCOL_VERSIONS.includes(result.protocolVersion)) {
434
+ throw new Error(`Server's protocol version is not supported: ${result.protocolVersion}`);
435
+ }
436
+ this._serverCapabilities = result.capabilities;
437
+ this._serverVersion = result.serverInfo;
438
+ if (transport.setProtocolVersion) {
439
+ transport.setProtocolVersion(result.protocolVersion);
440
+ }
441
+ this._instructions = result.instructions;
442
+ await this.notification({
443
+ method: "notifications/initialized"
444
+ });
445
+ if (this._pendingListChangedConfig) {
446
+ this._setupListChangedHandlers(this._pendingListChangedConfig);
447
+ this._pendingListChangedConfig = void 0;
448
+ }
449
+ } catch (error) {
450
+ void this.close();
451
+ throw error;
452
+ }
453
+ }
454
+ /**
455
+ * After initialization has completed, this will be populated with the server's reported capabilities.
456
+ */
457
+ getServerCapabilities() {
458
+ return this._serverCapabilities;
459
+ }
460
+ /**
461
+ * After initialization has completed, this will be populated with information about the server's name and version.
462
+ */
463
+ getServerVersion() {
464
+ return this._serverVersion;
465
+ }
466
+ /**
467
+ * After initialization has completed, this may be populated with information about the server's instructions.
468
+ */
469
+ getInstructions() {
470
+ return this._instructions;
471
+ }
472
+ assertCapabilityForMethod(method) {
473
+ switch (method) {
474
+ case "logging/setLevel":
475
+ if (!this._serverCapabilities?.logging) {
476
+ throw new Error(`Server does not support logging (required for ${method})`);
477
+ }
478
+ break;
479
+ case "prompts/get":
480
+ case "prompts/list":
481
+ if (!this._serverCapabilities?.prompts) {
482
+ throw new Error(`Server does not support prompts (required for ${method})`);
483
+ }
484
+ break;
485
+ case "resources/list":
486
+ case "resources/templates/list":
487
+ case "resources/read":
488
+ case "resources/subscribe":
489
+ case "resources/unsubscribe":
490
+ if (!this._serverCapabilities?.resources) {
491
+ throw new Error(`Server does not support resources (required for ${method})`);
492
+ }
493
+ if (method === "resources/subscribe" && !this._serverCapabilities.resources.subscribe) {
494
+ throw new Error(`Server does not support resource subscriptions (required for ${method})`);
495
+ }
496
+ break;
497
+ case "tools/call":
498
+ case "tools/list":
499
+ if (!this._serverCapabilities?.tools) {
500
+ throw new Error(`Server does not support tools (required for ${method})`);
501
+ }
502
+ break;
503
+ case "completion/complete":
504
+ if (!this._serverCapabilities?.completions) {
505
+ throw new Error(`Server does not support completions (required for ${method})`);
506
+ }
507
+ break;
508
+ case "initialize":
509
+ break;
510
+ case "ping":
511
+ break;
512
+ }
513
+ }
514
+ assertNotificationCapability(method) {
515
+ switch (method) {
516
+ case "notifications/roots/list_changed":
517
+ if (!this._capabilities.roots?.listChanged) {
518
+ throw new Error(`Client does not support roots list changed notifications (required for ${method})`);
519
+ }
520
+ break;
521
+ case "notifications/initialized":
522
+ break;
523
+ case "notifications/cancelled":
524
+ break;
525
+ case "notifications/progress":
526
+ break;
527
+ }
528
+ }
529
+ assertRequestHandlerCapability(method) {
530
+ if (!this._capabilities) {
531
+ return;
532
+ }
533
+ switch (method) {
534
+ case "sampling/createMessage":
535
+ if (!this._capabilities.sampling) {
536
+ throw new Error(`Client does not support sampling capability (required for ${method})`);
537
+ }
538
+ break;
539
+ case "elicitation/create":
540
+ if (!this._capabilities.elicitation) {
541
+ throw new Error(`Client does not support elicitation capability (required for ${method})`);
542
+ }
543
+ break;
544
+ case "roots/list":
545
+ if (!this._capabilities.roots) {
546
+ throw new Error(`Client does not support roots capability (required for ${method})`);
547
+ }
548
+ break;
549
+ case "tasks/get":
550
+ case "tasks/list":
551
+ case "tasks/result":
552
+ case "tasks/cancel":
553
+ if (!this._capabilities.tasks) {
554
+ throw new Error(`Client does not support tasks capability (required for ${method})`);
555
+ }
556
+ break;
557
+ case "ping":
558
+ break;
559
+ }
560
+ }
561
+ assertTaskCapability(method) {
562
+ assertToolsCallTaskCapability(this._serverCapabilities?.tasks?.requests, method, "Server");
563
+ }
564
+ assertTaskHandlerCapability(method) {
565
+ if (!this._capabilities) {
566
+ return;
567
+ }
568
+ assertClientRequestTaskCapability(this._capabilities.tasks?.requests, method, "Client");
569
+ }
570
+ async ping(options) {
571
+ return this.request({ method: "ping" }, EmptyResultSchema, options);
572
+ }
573
+ async complete(params, options) {
574
+ return this.request({ method: "completion/complete", params }, CompleteResultSchema, options);
575
+ }
576
+ async setLoggingLevel(level, options) {
577
+ return this.request({ method: "logging/setLevel", params: { level } }, EmptyResultSchema, options);
578
+ }
579
+ async getPrompt(params, options) {
580
+ return this.request({ method: "prompts/get", params }, GetPromptResultSchema, options);
581
+ }
582
+ async listPrompts(params, options) {
583
+ return this.request({ method: "prompts/list", params }, ListPromptsResultSchema, options);
584
+ }
585
+ async listResources(params, options) {
586
+ return this.request({ method: "resources/list", params }, ListResourcesResultSchema, options);
587
+ }
588
+ async listResourceTemplates(params, options) {
589
+ return this.request({ method: "resources/templates/list", params }, ListResourceTemplatesResultSchema, options);
590
+ }
591
+ async readResource(params, options) {
592
+ return this.request({ method: "resources/read", params }, ReadResourceResultSchema, options);
593
+ }
594
+ async subscribeResource(params, options) {
595
+ return this.request({ method: "resources/subscribe", params }, EmptyResultSchema, options);
596
+ }
597
+ async unsubscribeResource(params, options) {
598
+ return this.request({ method: "resources/unsubscribe", params }, EmptyResultSchema, options);
599
+ }
600
+ /**
601
+ * Calls a tool and waits for the result. Automatically validates structured output if the tool has an outputSchema.
602
+ *
603
+ * For task-based execution with streaming behavior, use client.experimental.tasks.callToolStream() instead.
604
+ */
605
+ async callTool(params, resultSchema = CallToolResultSchema, options) {
606
+ if (this.isToolTaskRequired(params.name)) {
607
+ throw new McpError(ErrorCode.InvalidRequest, `Tool "${params.name}" requires task-based execution. Use client.experimental.tasks.callToolStream() instead.`);
608
+ }
609
+ const result = await this.request({ method: "tools/call", params }, resultSchema, options);
610
+ const validator = this.getToolOutputValidator(params.name);
611
+ if (validator) {
612
+ if (!result.structuredContent && !result.isError) {
613
+ throw new McpError(ErrorCode.InvalidRequest, `Tool ${params.name} has an output schema but did not return structured content`);
614
+ }
615
+ if (result.structuredContent) {
616
+ try {
617
+ const validationResult = validator(result.structuredContent);
618
+ if (!validationResult.valid) {
619
+ throw new McpError(ErrorCode.InvalidParams, `Structured content does not match the tool's output schema: ${validationResult.errorMessage}`);
620
+ }
621
+ } catch (error) {
622
+ if (error instanceof McpError) {
623
+ throw error;
624
+ }
625
+ throw new McpError(ErrorCode.InvalidParams, `Failed to validate structured content: ${error instanceof Error ? error.message : String(error)}`);
626
+ }
627
+ }
628
+ }
629
+ return result;
630
+ }
631
+ isToolTask(toolName) {
632
+ if (!this._serverCapabilities?.tasks?.requests?.tools?.call) {
633
+ return false;
634
+ }
635
+ return this._cachedKnownTaskTools.has(toolName);
636
+ }
637
+ /**
638
+ * Check if a tool requires task-based execution.
639
+ * Unlike isToolTask which includes 'optional' tools, this only checks for 'required'.
640
+ */
641
+ isToolTaskRequired(toolName) {
642
+ return this._cachedRequiredTaskTools.has(toolName);
643
+ }
644
+ /**
645
+ * Cache validators for tool output schemas.
646
+ * Called after listTools() to pre-compile validators for better performance.
647
+ */
648
+ cacheToolMetadata(tools) {
649
+ this._cachedToolOutputValidators.clear();
650
+ this._cachedKnownTaskTools.clear();
651
+ this._cachedRequiredTaskTools.clear();
652
+ for (const tool of tools) {
653
+ if (tool.outputSchema) {
654
+ const toolValidator = this._jsonSchemaValidator.getValidator(tool.outputSchema);
655
+ this._cachedToolOutputValidators.set(tool.name, toolValidator);
656
+ }
657
+ const taskSupport = tool.execution?.taskSupport;
658
+ if (taskSupport === "required" || taskSupport === "optional") {
659
+ this._cachedKnownTaskTools.add(tool.name);
660
+ }
661
+ if (taskSupport === "required") {
662
+ this._cachedRequiredTaskTools.add(tool.name);
663
+ }
664
+ }
665
+ }
666
+ /**
667
+ * Get cached validator for a tool
668
+ */
669
+ getToolOutputValidator(toolName) {
670
+ return this._cachedToolOutputValidators.get(toolName);
671
+ }
672
+ async listTools(params, options) {
673
+ const result = await this.request({ method: "tools/list", params }, ListToolsResultSchema, options);
674
+ this.cacheToolMetadata(result.tools);
675
+ return result;
676
+ }
677
+ /**
678
+ * Set up a single list changed handler.
679
+ * @internal
680
+ */
681
+ _setupListChangedHandler(listType, notificationSchema, options, fetcher) {
682
+ const parseResult = ListChangedOptionsBaseSchema.safeParse(options);
683
+ if (!parseResult.success) {
684
+ throw new Error(`Invalid ${listType} listChanged options: ${parseResult.error.message}`);
685
+ }
686
+ if (typeof options.onChanged !== "function") {
687
+ throw new Error(`Invalid ${listType} listChanged options: onChanged must be a function`);
688
+ }
689
+ const { autoRefresh, debounceMs } = parseResult.data;
690
+ const { onChanged } = options;
691
+ const refresh = async () => {
692
+ if (!autoRefresh) {
693
+ onChanged(null, null);
694
+ return;
695
+ }
696
+ try {
697
+ const items = await fetcher();
698
+ onChanged(null, items);
699
+ } catch (e) {
700
+ const error = e instanceof Error ? e : new Error(String(e));
701
+ onChanged(error, null);
702
+ }
703
+ };
704
+ const handler = () => {
705
+ if (debounceMs) {
706
+ const existingTimer = this._listChangedDebounceTimers.get(listType);
707
+ if (existingTimer) {
708
+ clearTimeout(existingTimer);
709
+ }
710
+ const timer = setTimeout(refresh, debounceMs);
711
+ this._listChangedDebounceTimers.set(listType, timer);
712
+ } else {
713
+ refresh();
714
+ }
715
+ };
716
+ this.setNotificationHandler(notificationSchema, handler);
717
+ }
718
+ async sendRootsListChanged() {
719
+ return this.notification({ method: "notifications/roots/list_changed" });
720
+ }
721
+ };
722
+
723
+ // src/mcpScan/snapshot.ts
724
+ init_esm_shims();
725
+ import { createHash } from "crypto";
726
+ var LIMITS = {
727
+ tools: 2e3,
728
+ prompts: 1e3,
729
+ resourceTemplates: 1e3,
730
+ /** `resources/list` is paged only to count; URIs are the user's data, never kept. */
731
+ resourcePages: 50,
732
+ pages: 100,
733
+ name: 256,
734
+ text: 32e3,
735
+ instructions: 32e3,
736
+ schemaBytes: 2e5,
737
+ schemaDepth: 64
738
+ };
739
+ var isObj = (v) => !!v && typeof v === "object" && !Array.isArray(v);
740
+ function text(v, max, issues, list, where) {
741
+ if (typeof v !== "string") return void 0;
742
+ if (v.length <= max) return v;
743
+ issues.push({
744
+ list,
745
+ kind: "oversized",
746
+ detail: `${where}: ${v.length} chars, kept the first ${max}`
747
+ });
748
+ return v.slice(0, max);
749
+ }
750
+ function depthOf(value, limit) {
751
+ let max = 0;
752
+ const stack = [[value, 1]];
753
+ while (stack.length) {
754
+ const [v, d] = stack.pop();
755
+ if (d > max) max = d;
756
+ if (max > limit) return max;
757
+ if (v && typeof v === "object") {
758
+ for (const child of Array.isArray(v) ? v : Object.values(v)) {
759
+ if (child && typeof child === "object") stack.push([child, d + 1]);
760
+ }
761
+ }
762
+ }
763
+ return max;
764
+ }
765
+ function schema(v, issues, list, where) {
766
+ if (v === void 0 || v === null) return void 0;
767
+ const depth = depthOf(v, LIMITS.schemaDepth);
768
+ if (depth > LIMITS.schemaDepth) {
769
+ issues.push({
770
+ list,
771
+ kind: "oversized",
772
+ detail: `${where}: nested deeper than ${LIMITS.schemaDepth} levels`
773
+ });
774
+ return { "x-lurq-omitted": `schema deeper than ${LIMITS.schemaDepth} levels` };
775
+ }
776
+ const bytes = JSON.stringify(v).length;
777
+ if (bytes > LIMITS.schemaBytes) {
778
+ issues.push({ list, kind: "oversized", detail: `${where}: ${bytes} bytes` });
779
+ return { "x-lurq-omitted": `schema larger than ${LIMITS.schemaBytes} bytes` };
780
+ }
781
+ return v;
782
+ }
783
+ var HINTS = ["readOnlyHint", "destructiveHint", "idempotentHint", "openWorldHint"];
784
+ function annotations(v) {
785
+ if (!isObj(v)) return void 0;
786
+ const out = {};
787
+ for (const h of HINTS) if (typeof v[h] === "boolean") out[h] = v[h];
788
+ if (typeof v.title === "string") out.title = v.title.slice(0, LIMITS.name);
789
+ return Object.keys(out).length ? out : void 0;
790
+ }
791
+ function each(raw, list, seen, issues, cap, build) {
792
+ for (let i = 0; i < raw.length; i++) {
793
+ const entry = raw[i];
794
+ if (!isObj(entry) || typeof entry.name !== "string" || !entry.name.trim()) {
795
+ issues.push({ list, kind: "malformed", detail: `entry ${i} has no string name` });
796
+ continue;
797
+ }
798
+ const name = entry.name.trim();
799
+ if (name.length > LIMITS.name) {
800
+ issues.push({
801
+ list,
802
+ kind: "malformed",
803
+ detail: `a name is ${name.length} chars (limit ${LIMITS.name})`
804
+ });
805
+ continue;
806
+ }
807
+ if (seen.has(name)) {
808
+ issues.push({ list, kind: "duplicate", detail: `"${name}" is listed more than once` });
809
+ continue;
810
+ }
811
+ if (seen.size >= cap) {
812
+ issues.push({
813
+ list,
814
+ kind: "truncated",
815
+ detail: `more than ${cap} entries; the rest were not recorded`
816
+ });
817
+ return false;
818
+ }
819
+ const built = build(entry, name);
820
+ if (built) seen.set(name, built);
821
+ }
822
+ return true;
823
+ }
824
+ function addTools(raw, seen, issues) {
825
+ return each(raw, "tools", seen, issues, LIMITS.tools, (e, name) => {
826
+ const tool = { name };
827
+ const title = text(e.title, LIMITS.name, issues, "tools", `${name}.title`);
828
+ const description = text(e.description, LIMITS.text, issues, "tools", `${name}.description`);
829
+ const input = schema(e.inputSchema, issues, "tools", `${name}.inputSchema`);
830
+ const output = schema(e.outputSchema, issues, "tools", `${name}.outputSchema`);
831
+ const ann = annotations(e.annotations);
832
+ if (title !== void 0) tool.title = title;
833
+ if (description !== void 0) tool.description = description;
834
+ if (input !== void 0) tool.inputSchema = input;
835
+ if (output !== void 0) tool.outputSchema = output;
836
+ if (ann) tool.annotations = ann;
837
+ return tool;
838
+ });
839
+ }
840
+ function addPrompts(raw, seen, issues) {
841
+ return each(raw, "prompts", seen, issues, LIMITS.prompts, (e, name) => {
842
+ const args = Array.isArray(e.arguments) ? e.arguments : [];
843
+ const prompt = {
844
+ name,
845
+ arguments: args.filter(isObj).flatMap(
846
+ (a) => typeof a.name === "string" ? [
847
+ {
848
+ name: a.name.slice(0, LIMITS.name),
849
+ ...typeof a.description === "string" ? { description: a.description.slice(0, LIMITS.text) } : {},
850
+ required: a.required === true
851
+ }
852
+ ] : []
853
+ )
854
+ };
855
+ const title = text(e.title, LIMITS.name, issues, "prompts", `${name}.title`);
856
+ const description = text(e.description, LIMITS.text, issues, "prompts", `${name}.description`);
857
+ if (title !== void 0) prompt.title = title;
858
+ if (description !== void 0) prompt.description = description;
859
+ return prompt;
860
+ });
861
+ }
862
+ function addTemplates(raw, seen, issues) {
863
+ return each(raw, "resourceTemplates", seen, issues, LIMITS.resourceTemplates, (e, name) => {
864
+ if (typeof e.uriTemplate !== "string") {
865
+ issues.push({
866
+ list: "resourceTemplates",
867
+ kind: "malformed",
868
+ detail: `"${name}" has no uriTemplate`
869
+ });
870
+ return null;
871
+ }
872
+ const t = { name, uriTemplate: e.uriTemplate.slice(0, 2048) };
873
+ const title = text(e.title, LIMITS.name, issues, "resourceTemplates", `${name}.title`);
874
+ const description = text(
875
+ e.description,
876
+ LIMITS.text,
877
+ issues,
878
+ "resourceTemplates",
879
+ `${name}.description`
880
+ );
881
+ if (title !== void 0) t.title = title;
882
+ if (description !== void 0) t.description = description;
883
+ if (typeof e.mimeType === "string") t.mimeType = e.mimeType.slice(0, 200);
884
+ return t;
885
+ });
886
+ }
887
+ var sha = (s) => createHash("sha256").update(s).digest("hex");
888
+ var byName = (xs) => [...xs].sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
889
+ function canonicalJson(value) {
890
+ return JSON.stringify(
891
+ value,
892
+ (_k, v) => v && typeof v === "object" && !Array.isArray(v) ? Object.fromEntries(
893
+ Object.keys(v).sort().map((k) => [k, v[k]])
894
+ ) : v
895
+ );
896
+ }
897
+ function contractHash(s) {
898
+ return surfaceHash(s.tools);
899
+ }
900
+ function contentHash(s) {
901
+ return sha(
902
+ canonicalJson({
903
+ tools: byName(s.tools),
904
+ prompts: byName(s.prompts),
905
+ resourceTemplates: byName(s.resourceTemplates),
906
+ instructions: s.instructions ?? null
907
+ })
908
+ );
909
+ }
910
+ function emptySnapshot() {
911
+ return {
912
+ serverInfo: { name: null, version: null, title: null },
913
+ protocolVersion: null,
914
+ capabilities: {
915
+ tools: false,
916
+ prompts: false,
917
+ resources: false,
918
+ logging: false,
919
+ completions: false,
920
+ toolsListChanged: false
921
+ },
922
+ instructions: null,
923
+ tools: [],
924
+ prompts: [],
925
+ resourceTemplates: [],
926
+ resourceCount: null,
927
+ issues: []
928
+ };
929
+ }
930
+
931
+ export {
932
+ Client,
933
+ LIMITS,
934
+ addTools,
935
+ addPrompts,
936
+ addTemplates,
937
+ contractHash,
938
+ contentHash,
939
+ emptySnapshot
940
+ };