lotus-wisdom-mcp 0.3.2 → 0.5.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.
- package/README.md +160 -43
- package/dist/bundle.js +89 -55
- package/dist/index.js +95 -59
- package/dist/journey.html +247 -0
- package/package.json +7 -3
package/README.md
CHANGED
|
@@ -4,8 +4,6 @@
|
|
|
4
4
|
<img src="assets/lotus-flower.png" alt="Lotus Flower" width="400"/>
|
|
5
5
|
</p>
|
|
6
6
|
|
|
7
|
-
[](https://smithery.ai/server/@linxule/lotus-wisdom-mcp)
|
|
8
|
-
|
|
9
7
|
An MCP server implementation that provides a tool for problem-solving using the Lotus Sutra's wisdom framework, combining analytical thinking with intuitive wisdom.
|
|
10
8
|
|
|
11
9
|
## Features
|
|
@@ -13,6 +11,7 @@ An MCP server implementation that provides a tool for problem-solving using the
|
|
|
13
11
|
* Multi-faceted problem-solving approach inspired by the Lotus Sutra
|
|
14
12
|
* Step-by-step thought process with different thinking techniques
|
|
15
13
|
* Meditation pauses to allow insights to emerge naturally
|
|
14
|
+
* **Interactive visualization** via MCP ext-apps (Claude Desktop, Cursor, ChatGPT)
|
|
16
15
|
* Beautifully formatted thought process visualization with colors and symbols
|
|
17
16
|
* Tracks both tag journey and wisdom domain movements
|
|
18
17
|
* Final integration of insights into a clear response
|
|
@@ -195,110 +194,222 @@ Here's how a conversation with Claude might flow when using the Lotus Wisdom MCP
|
|
|
195
194
|
|
|
196
195
|
When the tool returns `status: 'WISDOM_READY'`, Claude then speaks the final wisdom naturally, integrating all the insights from the contemplative journey.
|
|
197
196
|
|
|
198
|
-
##
|
|
197
|
+
## Installation
|
|
198
|
+
|
|
199
|
+
[](https://smithery.ai/server/lotus-wisdom-mcp)
|
|
200
|
+
|
|
201
|
+
Install via [Smithery](https://smithery.ai/server/lotus-wisdom-mcp) for one-click setup, or follow the manual instructions below.
|
|
202
|
+
|
|
203
|
+
Requires [Node.js](https://nodejs.org/) 18+. The server runs locally via `npx`.
|
|
204
|
+
|
|
205
|
+
### CLI Install (one-liner)
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
# Claude Code
|
|
209
|
+
claude mcp add lotus-wisdom -- npx -y lotus-wisdom-mcp
|
|
210
|
+
|
|
211
|
+
# Codex CLI (OpenAI)
|
|
212
|
+
codex mcp add lotus-wisdom -- npx -y lotus-wisdom-mcp
|
|
213
|
+
|
|
214
|
+
# Gemini CLI (Google)
|
|
215
|
+
gemini mcp add lotus-wisdom npx -y lotus-wisdom-mcp
|
|
216
|
+
```
|
|
199
217
|
|
|
200
|
-
###
|
|
218
|
+
### Claude Desktop
|
|
201
219
|
|
|
202
|
-
Add
|
|
220
|
+
Add to your `claude_desktop_config.json`:
|
|
203
221
|
|
|
204
|
-
|
|
222
|
+
| OS | Config path |
|
|
223
|
+
|----|-------------|
|
|
224
|
+
| macOS | `~/Library/Application Support/Claude/claude_desktop_config.json` |
|
|
225
|
+
| Windows | `%APPDATA%\Claude\claude_desktop_config.json` |
|
|
226
|
+
| Linux | `~/.config/Claude/claude_desktop_config.json` |
|
|
205
227
|
|
|
206
228
|
```json
|
|
207
229
|
{
|
|
208
230
|
"mcpServers": {
|
|
209
231
|
"lotus-wisdom": {
|
|
210
232
|
"command": "npx",
|
|
211
|
-
"args": [
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
233
|
+
"args": ["-y", "lotus-wisdom-mcp"]
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
### VS Code
|
|
240
|
+
|
|
241
|
+
Add to `.vscode/mcp.json` (workspace) or open Command Palette > `MCP: Open User Configuration` (global):
|
|
242
|
+
|
|
243
|
+
```json
|
|
244
|
+
{
|
|
245
|
+
"servers": {
|
|
246
|
+
"lotus-wisdom": {
|
|
247
|
+
"command": "npx",
|
|
248
|
+
"args": ["-y", "lotus-wisdom-mcp"]
|
|
215
249
|
}
|
|
216
250
|
}
|
|
217
251
|
}
|
|
218
252
|
```
|
|
219
253
|
|
|
220
|
-
|
|
254
|
+
> **Note**: VS Code uses `"servers"` as the top-level key, not `"mcpServers"`. Other VS Code forks (Trae, Void, PearAI, etc.) typically use this same format.
|
|
255
|
+
|
|
256
|
+
### Cursor
|
|
221
257
|
|
|
222
|
-
|
|
258
|
+
Add to `~/.cursor/mcp.json` (global) or `.cursor/mcp.json` (project):
|
|
223
259
|
|
|
224
260
|
```json
|
|
225
261
|
{
|
|
226
262
|
"mcpServers": {
|
|
227
263
|
"lotus-wisdom": {
|
|
228
264
|
"command": "npx",
|
|
229
|
-
"args": [
|
|
230
|
-
"-y",
|
|
231
|
-
"lotus-wisdom-mcp"
|
|
232
|
-
]
|
|
265
|
+
"args": ["-y", "lotus-wisdom-mcp"]
|
|
233
266
|
}
|
|
234
267
|
}
|
|
235
268
|
}
|
|
236
269
|
```
|
|
237
270
|
|
|
238
|
-
|
|
271
|
+
### Windsurf
|
|
272
|
+
|
|
273
|
+
Add to `~/.codeium/windsurf/mcp_config.json` (Windows: `%USERPROFILE%\.codeium\windsurf\mcp_config.json`):
|
|
239
274
|
|
|
240
275
|
```json
|
|
241
276
|
{
|
|
242
277
|
"mcpServers": {
|
|
243
278
|
"lotus-wisdom": {
|
|
244
279
|
"command": "npx",
|
|
245
|
-
"args": [
|
|
246
|
-
"-y",
|
|
247
|
-
"git+https://github.com/linxule/lotus-wisdom-mcp.git"
|
|
248
|
-
]
|
|
280
|
+
"args": ["-y", "lotus-wisdom-mcp"]
|
|
249
281
|
}
|
|
250
282
|
}
|
|
251
283
|
}
|
|
252
284
|
```
|
|
253
285
|
|
|
254
|
-
|
|
286
|
+
### Cline
|
|
287
|
+
|
|
288
|
+
Open MCP Servers icon in Cline panel > Configure > Advanced MCP Settings, then add:
|
|
255
289
|
|
|
256
290
|
```json
|
|
257
291
|
{
|
|
258
292
|
"mcpServers": {
|
|
259
293
|
"lotus-wisdom": {
|
|
260
|
-
"command": "
|
|
261
|
-
"args": [
|
|
262
|
-
"run",
|
|
263
|
-
"--rm",
|
|
264
|
-
"-i",
|
|
265
|
-
"lotus-wisdom-mcp"
|
|
266
|
-
]
|
|
294
|
+
"command": "npx",
|
|
295
|
+
"args": ["-y", "lotus-wisdom-mcp"]
|
|
267
296
|
}
|
|
268
297
|
}
|
|
269
298
|
}
|
|
270
299
|
```
|
|
271
300
|
|
|
272
|
-
###
|
|
301
|
+
### Cherry Studio
|
|
273
302
|
|
|
274
|
-
|
|
303
|
+
In Settings > MCP Servers > Add Server, set Type to `STDIO`, Command to `npx`, Args to `-y lotus-wisdom-mcp`. Or paste in JSON/Code mode:
|
|
275
304
|
|
|
276
|
-
```
|
|
277
|
-
|
|
278
|
-
|
|
305
|
+
```json
|
|
306
|
+
{
|
|
307
|
+
"lotus-wisdom": {
|
|
308
|
+
"name": "Lotus Wisdom",
|
|
309
|
+
"command": "npx",
|
|
310
|
+
"args": ["-y", "lotus-wisdom-mcp"],
|
|
311
|
+
"isActive": true
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
### Witsy
|
|
317
|
+
|
|
318
|
+
In Settings > MCP Servers, add a new server with Type: `stdio`, Command: `npx`, Args: `-y lotus-wisdom-mcp`.
|
|
319
|
+
|
|
320
|
+
### Codex CLI (TOML config)
|
|
321
|
+
|
|
322
|
+
Alternatively, edit `~/.codex/config.toml` directly:
|
|
323
|
+
|
|
324
|
+
```toml
|
|
325
|
+
[mcp_servers.lotus-wisdom]
|
|
326
|
+
command = "npx"
|
|
327
|
+
args = ["-y", "lotus-wisdom-mcp"]
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
### Gemini CLI (JSON config)
|
|
331
|
+
|
|
332
|
+
Alternatively, edit `~/.gemini/settings.json` directly:
|
|
333
|
+
|
|
334
|
+
```json
|
|
335
|
+
{
|
|
336
|
+
"mcpServers": {
|
|
337
|
+
"lotus-wisdom": {
|
|
338
|
+
"command": "npx",
|
|
339
|
+
"args": ["-y", "lotus-wisdom-mcp"]
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
}
|
|
279
343
|
```
|
|
280
344
|
|
|
281
|
-
|
|
345
|
+
### Windows
|
|
346
|
+
|
|
347
|
+
On Windows, `npx` requires a shell wrapper. Replace `"command": "npx"` with:
|
|
348
|
+
|
|
349
|
+
```json
|
|
350
|
+
{
|
|
351
|
+
"command": "cmd",
|
|
352
|
+
"args": ["/c", "npx", "-y", "lotus-wisdom-mcp"]
|
|
353
|
+
}
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
For CLI tools on Windows:
|
|
282
357
|
|
|
283
358
|
```bash
|
|
284
|
-
|
|
359
|
+
claude mcp add lotus-wisdom -- cmd /c npx -y lotus-wisdom-mcp
|
|
360
|
+
codex mcp add lotus-wisdom -- cmd /c npx -y lotus-wisdom-mcp
|
|
361
|
+
```
|
|
362
|
+
|
|
363
|
+
### ChatGPT
|
|
364
|
+
|
|
365
|
+
ChatGPT only supports remote MCP servers over HTTPS. Use [Smithery](https://smithery.ai/server/lotus-wisdom-mcp) or connect directly to the hosted instance below via ChatGPT Settings > Connectors.
|
|
366
|
+
|
|
367
|
+
### Remote (hosted)
|
|
368
|
+
|
|
369
|
+
A public instance is available at `https://lotus-wisdom-mcp.linxule.workers.dev/mcp`. No API key needed.
|
|
370
|
+
|
|
371
|
+
For clients supporting Streamable HTTP, connect directly to the URL. For stdio-only clients, use `mcp-remote`:
|
|
372
|
+
|
|
373
|
+
```json
|
|
374
|
+
{
|
|
375
|
+
"mcpServers": {
|
|
376
|
+
"lotus-wisdom": {
|
|
377
|
+
"command": "npx",
|
|
378
|
+
"args": ["-y", "mcp-remote", "https://lotus-wisdom-mcp.linxule.workers.dev/mcp"]
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
}
|
|
285
382
|
```
|
|
286
383
|
|
|
287
|
-
|
|
384
|
+
To self-host your own instance, see [`worker/README.md`](worker/README.md).
|
|
288
385
|
|
|
289
|
-
|
|
386
|
+
### Building from source
|
|
290
387
|
|
|
291
388
|
```bash
|
|
292
|
-
|
|
293
|
-
|
|
389
|
+
bun install
|
|
390
|
+
bun run build
|
|
391
|
+
bun run start
|
|
294
392
|
```
|
|
295
393
|
|
|
296
|
-
Enable debug mode
|
|
394
|
+
Enable debug mode:
|
|
297
395
|
|
|
298
396
|
```bash
|
|
299
|
-
LOTUS_DEBUG=true
|
|
397
|
+
LOTUS_DEBUG=true bun run start
|
|
300
398
|
```
|
|
301
399
|
|
|
400
|
+
## Interactive Visualization (ext-apps)
|
|
401
|
+
|
|
402
|
+
In MCP clients that support ext-apps (Claude Desktop, Cursor, ChatGPT), the tool renders an interactive "Living Trace" visualization inline in the chat:
|
|
403
|
+
|
|
404
|
+
* **Journey trace**: SVG circles colored by wisdom domain appear as steps arrive
|
|
405
|
+
* **Domain colors**: Process (gold), Skillful Means (amber), Non-Dual (green), Meta-Cognitive (blue), Meditation (teal)
|
|
406
|
+
* **Meditation breathing**: Hollow circles with gentle inhale/exhale animation
|
|
407
|
+
* **Completion**: Journey resolves into a gradient path showing the full domain arc
|
|
408
|
+
* **Click to explore**: Pin any step to read its contemplation text
|
|
409
|
+
* **Collapse for long journeys**: Shows last 8 steps with a "+N" cluster for earlier ones
|
|
410
|
+
|
|
411
|
+
Clients without ext-apps support are unaffected — they receive the same JSON tool responses as before.
|
|
412
|
+
|
|
302
413
|
## How It Works
|
|
303
414
|
|
|
304
415
|
The Lotus Wisdom framework recognizes that wisdom often emerges not through linear thinking but through a dance between different modes of understanding. The tool facilitates this by:
|
|
@@ -338,7 +449,13 @@ Contributions are welcome! Please feel free to submit issues or pull requests on
|
|
|
338
449
|
|
|
339
450
|
## Version
|
|
340
451
|
|
|
341
|
-
Current version: 0.
|
|
452
|
+
Current version: 0.4.0
|
|
453
|
+
|
|
454
|
+
### What's New in 0.4.0
|
|
455
|
+
|
|
456
|
+
- **Interactive Visualization**: MCP ext-apps UI renders a "Living Trace" journey inline in supporting clients (Claude Desktop, Cursor, ChatGPT)
|
|
457
|
+
- **Completion Fix**: Any tag with `nextStepNeeded=false` now correctly returns `WISDOM_READY` (previously only `express` and `complete` could complete)
|
|
458
|
+
- **Cloudflare Worker**: Worker deployment updated with ext-apps resource serving
|
|
342
459
|
|
|
343
460
|
### What's New in 0.3.2
|
|
344
461
|
|
package/dist/bundle.js
CHANGED
|
@@ -12436,6 +12436,19 @@ var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
|
|
|
12436
12436
|
var source_default = chalk;
|
|
12437
12437
|
|
|
12438
12438
|
// index.ts
|
|
12439
|
+
import { readFileSync } from "fs";
|
|
12440
|
+
import { dirname, join } from "path";
|
|
12441
|
+
import { fileURLToPath } from "url";
|
|
12442
|
+
var __dirname = dirname(fileURLToPath(import.meta.url));
|
|
12443
|
+
var journeyHtml = "";
|
|
12444
|
+
try {
|
|
12445
|
+
journeyHtml = readFileSync(join(__dirname, "journey.html"), "utf-8");
|
|
12446
|
+
} catch {
|
|
12447
|
+
}
|
|
12448
|
+
try {
|
|
12449
|
+
if (!journeyHtml) journeyHtml = readFileSync(join(__dirname, "app", "journey.html"), "utf-8");
|
|
12450
|
+
} catch {
|
|
12451
|
+
}
|
|
12439
12452
|
var WISDOM_DOMAINS = {
|
|
12440
12453
|
"entry": ["begin"],
|
|
12441
12454
|
// Always call first to receive framework
|
|
@@ -12570,6 +12583,7 @@ var LotusWisdomServer = class {
|
|
|
12570
12583
|
type: "text",
|
|
12571
12584
|
text: JSON.stringify({
|
|
12572
12585
|
status: "FRAMEWORK_RECEIVED",
|
|
12586
|
+
contemplation: validatedInput.content,
|
|
12573
12587
|
welcome: "Welcome to the Lotus Wisdom framework. Read this before continuing your contemplative journey.",
|
|
12574
12588
|
philosophy: {
|
|
12575
12589
|
core: "The Lotus Sutra teaches that there are many skillful means to reach the same truth. These tags are not rigid steps but different aspects of wisdom that interpenetrate and respond to what each moment needs.",
|
|
@@ -12655,6 +12669,7 @@ var LotusWisdomServer = class {
|
|
|
12655
12669
|
type: "text",
|
|
12656
12670
|
text: JSON.stringify({
|
|
12657
12671
|
status: "MEDITATION_COMPLETE",
|
|
12672
|
+
contemplation: validatedInput.content,
|
|
12658
12673
|
duration: validatedInput.meditationDuration || 3,
|
|
12659
12674
|
prompt: "What insights emerged during the pause?",
|
|
12660
12675
|
instruction: "Continue with what arose from stillness",
|
|
@@ -12665,7 +12680,7 @@ var LotusWisdomServer = class {
|
|
|
12665
12680
|
}]
|
|
12666
12681
|
};
|
|
12667
12682
|
}
|
|
12668
|
-
if (
|
|
12683
|
+
if (!validatedInput.nextStepNeeded) {
|
|
12669
12684
|
const finalJourney = this.thoughtProcess.map((step) => step.tag).join(" \u2192 ");
|
|
12670
12685
|
const finalDomainJourney = this.thoughtProcess.map((step) => step.wisdomDomain).filter((domain, index, array) => index === 0 || domain !== array[index - 1]).join(" \u2192 ");
|
|
12671
12686
|
return {
|
|
@@ -12673,28 +12688,10 @@ var LotusWisdomServer = class {
|
|
|
12673
12688
|
type: "text",
|
|
12674
12689
|
text: JSON.stringify({
|
|
12675
12690
|
status: "WISDOM_READY",
|
|
12691
|
+
contemplation: validatedInput.content,
|
|
12676
12692
|
processComplete: true,
|
|
12677
12693
|
finalStep: validatedInput.tag,
|
|
12678
|
-
instruction: "NOW_SPEAK_THE_WISDOM_NATURALLY",
|
|
12679
|
-
totalSteps: validatedInput.stepNumber,
|
|
12680
|
-
journeyLength: this.thoughtProcess.length,
|
|
12681
|
-
finalJourney,
|
|
12682
|
-
domainJourney: finalDomainJourney
|
|
12683
|
-
}, null, 2)
|
|
12684
|
-
}]
|
|
12685
|
-
};
|
|
12686
|
-
}
|
|
12687
|
-
if (validatedInput.tag === "complete" && !validatedInput.nextStepNeeded) {
|
|
12688
|
-
const finalJourney = this.thoughtProcess.map((step) => step.tag).join(" \u2192 ");
|
|
12689
|
-
const finalDomainJourney = this.thoughtProcess.map((step) => step.wisdomDomain).filter((domain, index, array) => index === 0 || domain !== array[index - 1]).join(" \u2192 ");
|
|
12690
|
-
return {
|
|
12691
|
-
content: [{
|
|
12692
|
-
type: "text",
|
|
12693
|
-
text: JSON.stringify({
|
|
12694
|
-
status: "WISDOM_READY",
|
|
12695
|
-
processComplete: true,
|
|
12696
|
-
finalStep: validatedInput.tag,
|
|
12697
|
-
instruction: "PROCESS_COMPLETE_SPEAK_WISDOM",
|
|
12694
|
+
instruction: validatedInput.tag === "express" ? "NOW_SPEAK_THE_WISDOM_NATURALLY" : "PROCESS_COMPLETE_SPEAK_WISDOM",
|
|
12698
12695
|
totalSteps: validatedInput.stepNumber,
|
|
12699
12696
|
journeyLength: this.thoughtProcess.length,
|
|
12700
12697
|
finalJourney,
|
|
@@ -12708,6 +12705,7 @@ var LotusWisdomServer = class {
|
|
|
12708
12705
|
const currentDomain = getWisdomDomain(validatedInput.tag);
|
|
12709
12706
|
const response = {
|
|
12710
12707
|
status: "processing",
|
|
12708
|
+
contemplation: validatedInput.content,
|
|
12711
12709
|
currentStep: validatedInput.tag,
|
|
12712
12710
|
wisdomDomain: currentDomain,
|
|
12713
12711
|
journey: journeyResonance,
|
|
@@ -12763,6 +12761,7 @@ var LOTUS_WISDOM_TOOL = {
|
|
|
12763
12761
|
**Workflow:** Always start with tag='begin' (returns framework). Then continue with contemplation tags. Do NOT output wisdom until status='WISDOM_READY'.
|
|
12764
12762
|
|
|
12765
12763
|
**Tags:** begin (FIRST - receives framework), then: open/engage/express (process), examine/reflect/verify/refine/complete (meta-cognitive), recognize/transform/integrate/transcend/embody (non-dual), upaya/expedient/direct/gradual/sudden (skillful-means), meditate (pause).`,
|
|
12764
|
+
_meta: journeyHtml ? { ui: { resourceUri: "ui://lotuswisdom/journey.html" }, "ui/resourceUri": "ui://lotuswisdom/journey.html" } : void 0,
|
|
12766
12765
|
inputSchema: {
|
|
12767
12766
|
type: "object",
|
|
12768
12767
|
properties: {
|
|
@@ -12812,44 +12811,79 @@ var JOURNEY_SUMMARY_TOOL = {
|
|
|
12812
12811
|
required: []
|
|
12813
12812
|
}
|
|
12814
12813
|
};
|
|
12815
|
-
|
|
12816
|
-
|
|
12817
|
-
|
|
12818
|
-
|
|
12819
|
-
|
|
12820
|
-
|
|
12821
|
-
|
|
12822
|
-
|
|
12823
|
-
|
|
12824
|
-
|
|
12825
|
-
|
|
12826
|
-
|
|
12827
|
-
|
|
12828
|
-
|
|
12829
|
-
|
|
12830
|
-
|
|
12831
|
-
|
|
12832
|
-
|
|
12833
|
-
|
|
12834
|
-
|
|
12814
|
+
function createServer() {
|
|
12815
|
+
const server = new Server(
|
|
12816
|
+
{
|
|
12817
|
+
name: "lotus-wisdom-server",
|
|
12818
|
+
version: "0.5.0"
|
|
12819
|
+
},
|
|
12820
|
+
{
|
|
12821
|
+
capabilities: {
|
|
12822
|
+
tools: {},
|
|
12823
|
+
...journeyHtml ? { resources: {} } : {}
|
|
12824
|
+
}
|
|
12825
|
+
}
|
|
12826
|
+
);
|
|
12827
|
+
const wisdomServer = new LotusWisdomServer();
|
|
12828
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
12829
|
+
tools: [LOTUS_WISDOM_TOOL, JOURNEY_SUMMARY_TOOL]
|
|
12830
|
+
}));
|
|
12831
|
+
if (journeyHtml) {
|
|
12832
|
+
server.setRequestHandler(ListResourcesRequestSchema, async () => ({
|
|
12833
|
+
resources: [{
|
|
12834
|
+
uri: "ui://lotuswisdom/journey.html",
|
|
12835
|
+
name: "Lotus Wisdom Journey",
|
|
12836
|
+
mimeType: "text/html;profile=mcp-app",
|
|
12837
|
+
description: "Interactive visualization of the contemplative journey"
|
|
12838
|
+
}]
|
|
12839
|
+
}));
|
|
12840
|
+
server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
|
|
12841
|
+
if (request.params.uri === "ui://lotuswisdom/journey.html") {
|
|
12842
|
+
return {
|
|
12843
|
+
contents: [{
|
|
12844
|
+
uri: "ui://lotuswisdom/journey.html",
|
|
12845
|
+
mimeType: "text/html;profile=mcp-app",
|
|
12846
|
+
text: journeyHtml
|
|
12847
|
+
}]
|
|
12848
|
+
};
|
|
12849
|
+
}
|
|
12850
|
+
return { contents: [] };
|
|
12851
|
+
});
|
|
12835
12852
|
}
|
|
12836
|
-
|
|
12837
|
-
|
|
12838
|
-
|
|
12839
|
-
|
|
12840
|
-
|
|
12841
|
-
|
|
12842
|
-
|
|
12843
|
-
}
|
|
12844
|
-
|
|
12853
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
12854
|
+
if (request.params.name === "lotuswisdom") {
|
|
12855
|
+
const result = wisdomServer.processThought(request.params.arguments);
|
|
12856
|
+
if (journeyHtml) result._meta = { ui: { resourceUri: "ui://lotuswisdom/journey.html" }, "ui/resourceUri": "ui://lotuswisdom/journey.html" };
|
|
12857
|
+
return result;
|
|
12858
|
+
} else if (request.params.name === "lotuswisdom_summary") {
|
|
12859
|
+
return wisdomServer.getJourneySummary();
|
|
12860
|
+
}
|
|
12861
|
+
return {
|
|
12862
|
+
content: [{
|
|
12863
|
+
type: "text",
|
|
12864
|
+
text: `Unknown tool: ${request.params.name}`
|
|
12865
|
+
}],
|
|
12866
|
+
isError: true
|
|
12867
|
+
};
|
|
12868
|
+
});
|
|
12869
|
+
return server;
|
|
12870
|
+
}
|
|
12871
|
+
async function main() {
|
|
12872
|
+
const server = createServer();
|
|
12845
12873
|
const transport = new StdioServerTransport();
|
|
12846
12874
|
await server.connect(transport);
|
|
12847
|
-
console.error("Lotus Wisdom MCP Server v0.
|
|
12875
|
+
console.error("Lotus Wisdom MCP Server v0.5.0 running");
|
|
12848
12876
|
}
|
|
12849
|
-
|
|
12850
|
-
|
|
12851
|
-
|
|
12852
|
-
|
|
12877
|
+
var isDirectRun = process.argv[1] && (process.argv[1].endsWith("bundle.js") || process.argv[1].endsWith("index.js") || process.argv[1].endsWith("index.ts"));
|
|
12878
|
+
if (isDirectRun) {
|
|
12879
|
+
main().catch((error) => {
|
|
12880
|
+
console.error("Fatal error running server:", error);
|
|
12881
|
+
process.exit(1);
|
|
12882
|
+
});
|
|
12883
|
+
}
|
|
12884
|
+
export {
|
|
12885
|
+
createServer as default
|
|
12886
|
+
};
|
|
12853
12887
|
/*! Bundled license information:
|
|
12854
12888
|
|
|
12855
12889
|
uri-js/dist/es5/uri.all.js:
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,23 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
3
3
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
|
-
import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
4
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, ListResourcesRequestSchema, ReadResourceRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
5
5
|
import chalk from 'chalk';
|
|
6
|
+
import { readFileSync } from 'fs';
|
|
7
|
+
import { dirname, join } from 'path';
|
|
8
|
+
import { fileURLToPath } from 'url';
|
|
9
|
+
// Load journey visualization HTML for ext-apps UI
|
|
10
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
11
|
+
let journeyHtml = '';
|
|
12
|
+
try {
|
|
13
|
+
journeyHtml = readFileSync(join(__dirname, 'journey.html'), 'utf-8');
|
|
14
|
+
}
|
|
15
|
+
catch { }
|
|
16
|
+
try {
|
|
17
|
+
if (!journeyHtml)
|
|
18
|
+
journeyHtml = readFileSync(join(__dirname, 'app', 'journey.html'), 'utf-8');
|
|
19
|
+
}
|
|
20
|
+
catch { }
|
|
6
21
|
// Lotus Sutra framework tags - organized by wisdom domains
|
|
7
22
|
const WISDOM_DOMAINS = {
|
|
8
23
|
'entry': ['begin'], // Always call first to receive framework
|
|
@@ -153,6 +168,7 @@ class LotusWisdomServer {
|
|
|
153
168
|
type: "text",
|
|
154
169
|
text: JSON.stringify({
|
|
155
170
|
status: 'FRAMEWORK_RECEIVED',
|
|
171
|
+
contemplation: validatedInput.content,
|
|
156
172
|
welcome: 'Welcome to the Lotus Wisdom framework. Read this before continuing your contemplative journey.',
|
|
157
173
|
philosophy: {
|
|
158
174
|
core: 'The Lotus Sutra teaches that there are many skillful means to reach the same truth. These tags are not rigid steps but different aspects of wisdom that interpenetrate and respond to what each moment needs.',
|
|
@@ -241,6 +257,7 @@ class LotusWisdomServer {
|
|
|
241
257
|
type: "text",
|
|
242
258
|
text: JSON.stringify({
|
|
243
259
|
status: 'MEDITATION_COMPLETE',
|
|
260
|
+
contemplation: validatedInput.content,
|
|
244
261
|
duration: validatedInput.meditationDuration || 3,
|
|
245
262
|
prompt: 'What insights emerged during the pause?',
|
|
246
263
|
instruction: 'Continue with what arose from stillness',
|
|
@@ -251,8 +268,8 @@ class LotusWisdomServer {
|
|
|
251
268
|
}]
|
|
252
269
|
};
|
|
253
270
|
}
|
|
254
|
-
//
|
|
255
|
-
if (
|
|
271
|
+
// Any tag with nextStepNeeded=false completes the journey
|
|
272
|
+
if (!validatedInput.nextStepNeeded) {
|
|
256
273
|
const finalJourney = this.thoughtProcess.map(step => step.tag).join(' → ');
|
|
257
274
|
const finalDomainJourney = this.thoughtProcess
|
|
258
275
|
.map(step => step.wisdomDomain)
|
|
@@ -263,32 +280,10 @@ class LotusWisdomServer {
|
|
|
263
280
|
type: "text",
|
|
264
281
|
text: JSON.stringify({
|
|
265
282
|
status: 'WISDOM_READY',
|
|
283
|
+
contemplation: validatedInput.content,
|
|
266
284
|
processComplete: true,
|
|
267
285
|
finalStep: validatedInput.tag,
|
|
268
|
-
instruction: 'NOW_SPEAK_THE_WISDOM_NATURALLY',
|
|
269
|
-
totalSteps: validatedInput.stepNumber,
|
|
270
|
-
journeyLength: this.thoughtProcess.length,
|
|
271
|
-
finalJourney: finalJourney,
|
|
272
|
-
domainJourney: finalDomainJourney
|
|
273
|
-
}, null, 2)
|
|
274
|
-
}]
|
|
275
|
-
};
|
|
276
|
-
}
|
|
277
|
-
// Check if this is complete step
|
|
278
|
-
if (validatedInput.tag === 'complete' && !validatedInput.nextStepNeeded) {
|
|
279
|
-
const finalJourney = this.thoughtProcess.map(step => step.tag).join(' → ');
|
|
280
|
-
const finalDomainJourney = this.thoughtProcess
|
|
281
|
-
.map(step => step.wisdomDomain)
|
|
282
|
-
.filter((domain, index, array) => index === 0 || domain !== array[index - 1])
|
|
283
|
-
.join(' → ');
|
|
284
|
-
return {
|
|
285
|
-
content: [{
|
|
286
|
-
type: "text",
|
|
287
|
-
text: JSON.stringify({
|
|
288
|
-
status: 'WISDOM_READY',
|
|
289
|
-
processComplete: true,
|
|
290
|
-
finalStep: validatedInput.tag,
|
|
291
|
-
instruction: 'PROCESS_COMPLETE_SPEAK_WISDOM',
|
|
286
|
+
instruction: validatedInput.tag === 'express' ? 'NOW_SPEAK_THE_WISDOM_NATURALLY' : 'PROCESS_COMPLETE_SPEAK_WISDOM',
|
|
292
287
|
totalSteps: validatedInput.stepNumber,
|
|
293
288
|
journeyLength: this.thoughtProcess.length,
|
|
294
289
|
finalJourney: finalJourney,
|
|
@@ -311,6 +306,7 @@ class LotusWisdomServer {
|
|
|
311
306
|
// Build response object
|
|
312
307
|
const response = {
|
|
313
308
|
status: 'processing',
|
|
309
|
+
contemplation: validatedInput.content,
|
|
314
310
|
currentStep: validatedInput.tag,
|
|
315
311
|
wisdomDomain: currentDomain,
|
|
316
312
|
journey: journeyResonance,
|
|
@@ -371,6 +367,7 @@ const LOTUS_WISDOM_TOOL = {
|
|
|
371
367
|
**Workflow:** Always start with tag='begin' (returns framework). Then continue with contemplation tags. Do NOT output wisdom until status='WISDOM_READY'.
|
|
372
368
|
|
|
373
369
|
**Tags:** begin (FIRST - receives framework), then: open/engage/express (process), examine/reflect/verify/refine/complete (meta-cognitive), recognize/transform/integrate/transcend/embody (non-dual), upaya/expedient/direct/gradual/sudden (skillful-means), meditate (pause).`,
|
|
370
|
+
_meta: journeyHtml ? { ui: { resourceUri: "ui://lotuswisdom/journey.html" }, "ui/resourceUri": "ui://lotuswisdom/journey.html" } : undefined,
|
|
374
371
|
inputSchema: {
|
|
375
372
|
type: "object",
|
|
376
373
|
properties: {
|
|
@@ -421,39 +418,78 @@ const JOURNEY_SUMMARY_TOOL = {
|
|
|
421
418
|
required: []
|
|
422
419
|
}
|
|
423
420
|
};
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
server.setRequestHandler(
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
421
|
+
// Factory function for Smithery deployment
|
|
422
|
+
export default function createServer() {
|
|
423
|
+
const server = new Server({
|
|
424
|
+
name: "lotus-wisdom-server",
|
|
425
|
+
version: "0.5.0",
|
|
426
|
+
}, {
|
|
427
|
+
capabilities: {
|
|
428
|
+
tools: {},
|
|
429
|
+
...(journeyHtml ? { resources: {} } : {}),
|
|
430
|
+
},
|
|
431
|
+
});
|
|
432
|
+
const wisdomServer = new LotusWisdomServer();
|
|
433
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
434
|
+
tools: [LOTUS_WISDOM_TOOL, JOURNEY_SUMMARY_TOOL],
|
|
435
|
+
}));
|
|
436
|
+
// Ext-apps: serve journey visualization as a resource
|
|
437
|
+
if (journeyHtml) {
|
|
438
|
+
server.setRequestHandler(ListResourcesRequestSchema, async () => ({
|
|
439
|
+
resources: [{
|
|
440
|
+
uri: "ui://lotuswisdom/journey.html",
|
|
441
|
+
name: "Lotus Wisdom Journey",
|
|
442
|
+
mimeType: "text/html;profile=mcp-app",
|
|
443
|
+
description: "Interactive visualization of the contemplative journey"
|
|
444
|
+
}]
|
|
445
|
+
}));
|
|
446
|
+
server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
|
|
447
|
+
if (request.params.uri === "ui://lotuswisdom/journey.html") {
|
|
448
|
+
return {
|
|
449
|
+
contents: [{
|
|
450
|
+
uri: "ui://lotuswisdom/journey.html",
|
|
451
|
+
mimeType: "text/html;profile=mcp-app",
|
|
452
|
+
text: journeyHtml
|
|
453
|
+
}]
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
return { contents: [] };
|
|
457
|
+
});
|
|
442
458
|
}
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
459
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
460
|
+
if (request.params.name === "lotuswisdom") {
|
|
461
|
+
const result = wisdomServer.processThought(request.params.arguments);
|
|
462
|
+
if (journeyHtml)
|
|
463
|
+
result._meta = { ui: { resourceUri: "ui://lotuswisdom/journey.html" }, "ui/resourceUri": "ui://lotuswisdom/journey.html" };
|
|
464
|
+
return result;
|
|
465
|
+
}
|
|
466
|
+
else if (request.params.name === "lotuswisdom_summary") {
|
|
467
|
+
return wisdomServer.getJourneySummary();
|
|
468
|
+
}
|
|
469
|
+
return {
|
|
470
|
+
content: [{
|
|
471
|
+
type: "text",
|
|
472
|
+
text: `Unknown tool: ${request.params.name}`
|
|
473
|
+
}],
|
|
474
|
+
isError: true
|
|
475
|
+
};
|
|
476
|
+
});
|
|
477
|
+
return server;
|
|
478
|
+
}
|
|
479
|
+
// STDIO mode (npx, local dev, Claude Code)
|
|
480
|
+
async function main() {
|
|
481
|
+
const server = createServer();
|
|
452
482
|
const transport = new StdioServerTransport();
|
|
453
483
|
await server.connect(transport);
|
|
454
|
-
console.error("Lotus Wisdom MCP Server v0.
|
|
484
|
+
console.error("Lotus Wisdom MCP Server v0.5.0 running");
|
|
485
|
+
}
|
|
486
|
+
// Only run stdio when executed directly (not when imported by Smithery CLI)
|
|
487
|
+
const isDirectRun = process.argv[1] && (process.argv[1].endsWith('bundle.js') ||
|
|
488
|
+
process.argv[1].endsWith('index.js') ||
|
|
489
|
+
process.argv[1].endsWith('index.ts'));
|
|
490
|
+
if (isDirectRun) {
|
|
491
|
+
main().catch((error) => {
|
|
492
|
+
console.error("Fatal error running server:", error);
|
|
493
|
+
process.exit(1);
|
|
494
|
+
});
|
|
455
495
|
}
|
|
456
|
-
runServer().catch((error) => {
|
|
457
|
-
console.error("Fatal error running server:", error);
|
|
458
|
-
process.exit(1);
|
|
459
|
-
});
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
6
|
+
<title>Lotus Wisdom</title>
|
|
7
|
+
<style>
|
|
8
|
+
*,*::before,*::after{margin:0;padding:0;box-sizing:border-box}
|
|
9
|
+
|
|
10
|
+
:root {
|
|
11
|
+
--bg: #07070c;
|
|
12
|
+
--bg-c: #0c0c15;
|
|
13
|
+
--hz: #0e0e1a;
|
|
14
|
+
--conn: #14141e;
|
|
15
|
+
--dim: #2a2a3a;
|
|
16
|
+
--mid: #555568;
|
|
17
|
+
--hi: #8888a0;
|
|
18
|
+
--bright: #a0a0b8;
|
|
19
|
+
--entry: #6b6b7b;
|
|
20
|
+
--process: #c4a35a;
|
|
21
|
+
--skillful: #d4a843;
|
|
22
|
+
--nondual: #4a9a5c;
|
|
23
|
+
--meta: #5b8def;
|
|
24
|
+
--med: #7ecfc0;
|
|
25
|
+
--mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;
|
|
26
|
+
--sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
html, body {
|
|
30
|
+
width: 100%;
|
|
31
|
+
background: radial-gradient(ellipse at 50% 28%, var(--bg-c), var(--bg) 72%);
|
|
32
|
+
color: var(--mid);
|
|
33
|
+
font-family: var(--sans);
|
|
34
|
+
-webkit-font-smoothing: antialiased;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
#root {
|
|
38
|
+
width: 100%;
|
|
39
|
+
display: flex; flex-direction: column;
|
|
40
|
+
align-items: center;
|
|
41
|
+
padding: 10px 16px 6px;
|
|
42
|
+
position: relative;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
#void {
|
|
46
|
+
position: absolute; inset: 0;
|
|
47
|
+
display: flex; align-items: center; justify-content: center;
|
|
48
|
+
transition: opacity 1.4s cubic-bezier(.4,0,.2,1);
|
|
49
|
+
pointer-events: none; z-index: 1;
|
|
50
|
+
}
|
|
51
|
+
#void span { font-size: 20px; opacity: .055; animation: drift 80s linear infinite }
|
|
52
|
+
@keyframes drift { to { transform: rotate(360deg) } }
|
|
53
|
+
|
|
54
|
+
#tw {
|
|
55
|
+
width: 100%; flex-shrink: 0;
|
|
56
|
+
display: flex; align-items: center; justify-content: center;
|
|
57
|
+
height: 52px;
|
|
58
|
+
}
|
|
59
|
+
#tr { overflow: visible; width: 100%; max-height: 52px }
|
|
60
|
+
|
|
61
|
+
#ct {
|
|
62
|
+
width: 100%; overflow-x: hidden;
|
|
63
|
+
display: flex; justify-content: center;
|
|
64
|
+
padding: 6px 8px 0;
|
|
65
|
+
opacity: 0; transition: opacity .5s ease;
|
|
66
|
+
}
|
|
67
|
+
#ct.on { opacity: 1 }
|
|
68
|
+
#ct::-webkit-scrollbar { width: 2px }
|
|
69
|
+
#ct::-webkit-scrollbar-thumb { background: #1a1a28; border-radius: 2px }
|
|
70
|
+
#ct::-webkit-scrollbar-track { background: transparent }
|
|
71
|
+
|
|
72
|
+
#ci {
|
|
73
|
+
max-width: 560px; width: 100%;
|
|
74
|
+
border-left: 2px solid var(--dim);
|
|
75
|
+
padding-left: 14px;
|
|
76
|
+
transition: opacity .22s ease, border-color .4s ease;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.ch {
|
|
80
|
+
display: flex; align-items: baseline; gap: 8px;
|
|
81
|
+
margin-bottom: 6px; flex-wrap: wrap;
|
|
82
|
+
}
|
|
83
|
+
#ch { font-family: var(--mono); font-size: 10px; letter-spacing: .05em }
|
|
84
|
+
#cd { font-size: 7px; text-transform: uppercase; letter-spacing: .22em; opacity: .45 }
|
|
85
|
+
#cn { font-size: 9px; opacity: .25; font-variant-numeric: tabular-nums; margin-left: auto }
|
|
86
|
+
|
|
87
|
+
#cx {
|
|
88
|
+
font-size: 13.5px; line-height: 1.72;
|
|
89
|
+
color: var(--bright);
|
|
90
|
+
white-space: pre-wrap; word-wrap: break-word;
|
|
91
|
+
}
|
|
92
|
+
#cx.med-text { font-style: italic; opacity: .6 }
|
|
93
|
+
|
|
94
|
+
#jt {
|
|
95
|
+
flex-shrink: 0; height: 14px; min-height: 14px;
|
|
96
|
+
font-size: 8px; letter-spacing: .12em; text-transform: uppercase;
|
|
97
|
+
color: var(--dim); text-align: center;
|
|
98
|
+
opacity: 0; transition: opacity 1.8s cubic-bezier(.4,0,.2,1) .6s;
|
|
99
|
+
}
|
|
100
|
+
#jt.on { opacity: 1 }
|
|
101
|
+
|
|
102
|
+
.sn circle { transform-box: fill-box; transform-origin: center; cursor: pointer }
|
|
103
|
+
.sn.now circle {
|
|
104
|
+
animation: emerge .55s cubic-bezier(.175,.885,.32,1.275) forwards,
|
|
105
|
+
glow 3.2s ease-in-out .6s infinite;
|
|
106
|
+
}
|
|
107
|
+
.sn.hol circle {
|
|
108
|
+
animation: emerge .55s cubic-bezier(.175,.885,.32,1.275) forwards,
|
|
109
|
+
inhale 4.4s ease-in-out .6s infinite;
|
|
110
|
+
}
|
|
111
|
+
.sn.past circle { transition: opacity .35s ease }
|
|
112
|
+
.sn.past:hover circle { opacity: .72 !important }
|
|
113
|
+
.sn.end circle { opacity: .88 }
|
|
114
|
+
.rp {
|
|
115
|
+
transform-box: fill-box; transform-origin: center;
|
|
116
|
+
animation: ripple .9s ease-out forwards; pointer-events: none;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
@keyframes emerge {
|
|
120
|
+
from { transform: scale(0); opacity: 0 }
|
|
121
|
+
to { transform: scale(1); opacity: 1 }
|
|
122
|
+
}
|
|
123
|
+
@keyframes glow { 0%,100% { opacity: .72 } 50% { opacity: 1 } }
|
|
124
|
+
@keyframes inhale {
|
|
125
|
+
0%,100% { transform: scale(1); opacity: .28 }
|
|
126
|
+
50% { transform: scale(1.45); opacity: .82 }
|
|
127
|
+
}
|
|
128
|
+
@keyframes ripple {
|
|
129
|
+
from { transform: scale(1); opacity: .35 }
|
|
130
|
+
to { transform: scale(5.5); opacity: 0 }
|
|
131
|
+
}
|
|
132
|
+
@keyframes draw {
|
|
133
|
+
from { stroke-dashoffset: var(--len) }
|
|
134
|
+
to { stroke-dashoffset: 0 }
|
|
135
|
+
}
|
|
136
|
+
@keyframes ambient { 0%,100% { opacity: .03 } 50% { opacity: .07 } }
|
|
137
|
+
</style>
|
|
138
|
+
<script type="module" crossorigin>(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})(),Object.freeze({status:`aborted`});function e(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,`_zod`,{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,`name`,{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,`init`,{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,`name`,{value:e}),o}var t=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},n=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}},r={};function i(e){return e&&Object.assign(r,e),r}function a(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function o(e,t){return typeof t==`bigint`?t.toString():t}function s(e){return{get value(){{let t=e();return Object.defineProperty(this,`value`,{value:t}),t}throw Error(`cached value already set`)}}}function c(e){return e==null}function l(e){let t=e.startsWith(`^`)?1:0,n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function u(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=t.toString(),i=(r.split(`.`)[1]||``).length;if(i===0&&/\d?e-\d?/.test(r)){let e=r.match(/\d?e-(\d?)/);e?.[1]&&(i=Number.parseInt(e[1]))}let a=n>i?n:i;return Number.parseInt(e.toFixed(a).replace(`.`,``))%Number.parseInt(t.toFixed(a).replace(`.`,``))/10**a}var d=Symbol(`evaluating`);function f(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==d)return r===void 0&&(r=d,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function p(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function m(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function ee(e){return JSON.stringify(e)}function te(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var ne=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function re(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var ie=s(()=>{if(typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function ae(e){if(re(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(re(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function oe(e){return ae(e)?{...e}:Array.isArray(e)?[...e]:e}var se=new Set([`string`,`number`,`symbol`]);function ce(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function h(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function g(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function le(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var ue={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function de(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return h(e,m(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return p(this,`shape`,e),e},checks:[]}))}function fe(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return h(e,m(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return p(this,`shape`,r),r},checks:[]}))}function pe(e,t){if(!ae(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return h(e,m(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return p(this,`shape`,n),n}}))}function me(e,t){if(!ae(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return h(e,m(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return p(this,`shape`,n),n}}))}function he(e,t){return h(e,m(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return p(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:[]}))}function ge(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return h(t,m(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return p(this,`shape`,i),i},checks:[]}))}function _e(e,t,n){return h(t,m(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return p(this,`shape`,i),i}}))}function ve(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function ye(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function be(e){return typeof e==`string`?e:e?.message}function _(e,t,n){let r={...e,path:e.path??[]};return e.message||(r.message=be(e.inst?._zod.def?.error?.(e))??be(t?.error?.(e))??be(n.customError?.(e))??be(n.localeError?.(e))??`Invalid input`),delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function xe(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Se(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var Ce=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,`_zod`,{value:e._zod,enumerable:!1}),Object.defineProperty(e,`issues`,{value:t,enumerable:!1}),e.message=JSON.stringify(t,o,2),Object.defineProperty(e,`toString`,{value:()=>e.message,enumerable:!1})},we=e(`$ZodError`,Ce),Te=e(`$ZodError`,Ce,{Parent:Error});function Ee(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function De(e,t=e=>e.message){let n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`&&i.errors.length)i.errors.map(e=>r({issues:e}));else if(i.code===`invalid_key`)r({issues:i.issues});else if(i.code===`invalid_element`)r({issues:i.issues});else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(e),n}var Oe=e=>(n,r,a,o)=>{let s=a?Object.assign(a,{async:!1}):{async:!1},c=n._zod.run({value:r,issues:[]},s);if(c instanceof Promise)throw new t;if(c.issues.length){let t=new(o?.Err??e)(c.issues.map(e=>_(e,s,i())));throw ne(t,o?.callee),t}return c.value},ke=e=>async(t,n,r,a)=>{let o=r?Object.assign(r,{async:!0}):{async:!0},s=t._zod.run({value:n,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let t=new(a?.Err??e)(s.issues.map(e=>_(e,o,i())));throw ne(t,a?.callee),t}return s.value},Ae=e=>(n,r,a)=>{let o=a?{...a,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new t;return s.issues.length?{success:!1,error:new(e??we)(s.issues.map(e=>_(e,o,i())))}:{success:!0,data:s.value}},je=Ae(Te),Me=e=>async(t,n,r)=>{let a=r?Object.assign(r,{async:!0}):{async:!0},o=t._zod.run({value:n,issues:[]},a);return o instanceof Promise&&(o=await o),o.issues.length?{success:!1,error:new e(o.issues.map(e=>_(e,a,i())))}:{success:!0,data:o.value}},Ne=Me(Te),Pe=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return Oe(e)(t,n,i)},Fe=e=>(t,n,r)=>Oe(e)(t,n,r),Ie=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return ke(e)(t,n,i)},Le=e=>async(t,n,r)=>ke(e)(t,n,r),Re=e=>(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return Ae(e)(t,n,i)},ze=e=>(t,n,r)=>Ae(e)(t,n,r),Be=e=>async(t,n,r)=>{let i=r?Object.assign(r,{direction:`backward`}):{direction:`backward`};return Me(e)(t,n,i)},Ve=e=>async(t,n,r)=>Me(e)(t,n,r),He=/^[cC][^\s-]{8,}$/,Ue=/^[0-9a-z]+$/,We=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Ge=/^[0-9a-vA-V]{20}$/,Ke=/^[A-Za-z0-9]{27}$/,qe=/^[a-zA-Z0-9_-]{21}$/,Je=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Ye=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Xe=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Ze=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Qe=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function $e(){return new RegExp(Qe,`u`)}var et=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,tt=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,nt=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,rt=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,it=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,at=/^[A-Za-z0-9_-]*$/,ot=/^\+[1-9]\d{6,14}$/,st=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`,ct=RegExp(`^${st}$`);function lt(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function ut(e){return RegExp(`^${lt(e)}$`)}function dt(e){let t=lt({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${st}T(?:${r})$`)}var ft=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},pt=/^-?\d+$/,mt=/^-?\d+(?:\.\d+)?$/,ht=/^(?:true|false)$/i,gt=/^null$/i,_t=/^undefined$/i,vt=/^[^A-Z]*$/,yt=/^[^a-z]*$/,v=e(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),bt={number:`number`,bigint:`bigint`,object:`date`},xt=e(`$ZodCheckLessThan`,(e,t)=>{v.init(e,t);let n=bt[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),St=e(`$ZodCheckGreaterThan`,(e,t)=>{v.init(e,t);let n=bt[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ct=e(`$ZodCheckMultipleOf`,(e,t)=>{v.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):u(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),wt=e(`$ZodCheckNumberFormat`,(e,t)=>{v.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=ue[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=pt)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),Tt=e(`$ZodCheckMaxLength`,(e,t)=>{var n;v.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!c(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=xe(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Et=e(`$ZodCheckMinLength`,(e,t)=>{var n;v.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!c(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=xe(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Dt=e(`$ZodCheckLengthEquals`,(e,t)=>{var n;v.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!c(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=xe(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Ot=e(`$ZodCheckStringFormat`,(e,t)=>{var n,r;v.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),kt=e(`$ZodCheckRegex`,(e,t)=>{Ot.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),At=e(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=vt,Ot.init(e,t)}),jt=e(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=yt,Ot.init(e,t)}),Mt=e(`$ZodCheckIncludes`,(e,t)=>{v.init(e,t);let n=ce(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Nt=e(`$ZodCheckStartsWith`,(e,t)=>{v.init(e,t);let n=RegExp(`^${ce(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Pt=e(`$ZodCheckEndsWith`,(e,t)=>{v.init(e,t);let n=RegExp(`.*${ce(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Ft=e(`$ZodCheckOverwrite`,(e,t)=>{v.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),It=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
139
|
+
`).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[``]).map(e=>` ${e}`)];return new e(...t,n.join(`
|
|
140
|
+
`))}},Lt={major:4,minor:3,patch:6},y=e(`$ZodType`,(e,n)=>{var r;e??={},e._zod.def=n,e._zod.bag=e._zod.bag||{},e._zod.version=Lt;let i=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&i.unshift(e);for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let n=(e,n,r)=>{let i=ve(e),a;for(let o of n){if(o._zod.def.when){if(!o._zod.def.when(e))continue}else if(i)continue;let n=e.issues.length,s=o._zod.check(e);if(s instanceof Promise&&r?.async===!1)throw new t;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,e.issues.length!==n&&(i||=ve(e,n))});else{if(e.issues.length===n)continue;i||=ve(e,n)}}return a?a.then(()=>e):e},r=(r,a,o)=>{if(ve(r))return r.aborted=!0,r;let s=n(a,i,o);if(s instanceof Promise){if(o.async===!1)throw new t;return s.then(t=>e._zod.parse(t,o))}return e._zod.parse(s,o)};e._zod.run=(a,o)=>{if(o.skipChecks)return e._zod.parse(a,o);if(o.direction===`backward`){let t=e._zod.parse({value:a.value,issues:[]},{...o,skipChecks:!0});return t instanceof Promise?t.then(e=>r(e,a,o)):r(t,a,o)}let s=e._zod.parse(a,o);if(s instanceof Promise){if(o.async===!1)throw new t;return s.then(e=>n(e,i,o))}return n(s,i,o)}}f(e,`~standard`,()=>({validate:t=>{try{let n=je(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return Ne(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),Rt=e(`$ZodString`,(e,t)=>{y.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??ft(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),b=e(`$ZodStringFormat`,(e,t)=>{Ot.init(e,t),Rt.init(e,t)}),zt=e(`$ZodGUID`,(e,t)=>{t.pattern??=Ye,b.init(e,t)}),Bt=e(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=Xe(e)}else t.pattern??=Xe();b.init(e,t)}),Vt=e(`$ZodEmail`,(e,t)=>{t.pattern??=Ze,b.init(e,t)}),Ht=e(`$ZodURL`,(e,t)=>{b.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=i.href:n.value=r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Ut=e(`$ZodEmoji`,(e,t)=>{t.pattern??=$e(),b.init(e,t)}),Wt=e(`$ZodNanoID`,(e,t)=>{t.pattern??=qe,b.init(e,t)}),Gt=e(`$ZodCUID`,(e,t)=>{t.pattern??=He,b.init(e,t)}),Kt=e(`$ZodCUID2`,(e,t)=>{t.pattern??=Ue,b.init(e,t)}),qt=e(`$ZodULID`,(e,t)=>{t.pattern??=We,b.init(e,t)}),Jt=e(`$ZodXID`,(e,t)=>{t.pattern??=Ge,b.init(e,t)}),Yt=e(`$ZodKSUID`,(e,t)=>{t.pattern??=Ke,b.init(e,t)}),Xt=e(`$ZodISODateTime`,(e,t)=>{t.pattern??=dt(t),b.init(e,t)}),Zt=e(`$ZodISODate`,(e,t)=>{t.pattern??=ct,b.init(e,t)}),Qt=e(`$ZodISOTime`,(e,t)=>{t.pattern??=ut(t),b.init(e,t)}),$t=e(`$ZodISODuration`,(e,t)=>{t.pattern??=Je,b.init(e,t)}),en=e(`$ZodIPv4`,(e,t)=>{t.pattern??=et,b.init(e,t),e._zod.bag.format=`ipv4`}),tn=e(`$ZodIPv6`,(e,t)=>{t.pattern??=tt,b.init(e,t),e._zod.bag.format=`ipv6`,e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),nn=e(`$ZodCIDRv4`,(e,t)=>{t.pattern??=nt,b.init(e,t)}),rn=e(`$ZodCIDRv6`,(e,t)=>{t.pattern??=rt,b.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function an(e){if(e===``)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var on=e(`$ZodBase64`,(e,t)=>{t.pattern??=it,b.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{an(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function sn(e){if(!at.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return an(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var cn=e(`$ZodBase64URL`,(e,t)=>{t.pattern??=at,b.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{sn(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),ln=e(`$ZodE164`,(e,t)=>{t.pattern??=ot,b.init(e,t)});function un(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var dn=e(`$ZodJWT`,(e,t)=>{b.init(e,t),e._zod.check=n=>{un(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),fn=e(`$ZodNumber`,(e,t)=>{y.init(e,t),e._zod.pattern=e._zod.bag.pattern??mt,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),pn=e(`$ZodNumberFormat`,(e,t)=>{wt.init(e,t),fn.init(e,t)}),mn=e(`$ZodBoolean`,(e,t)=>{y.init(e,t),e._zod.pattern=ht,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),hn=e(`$ZodUndefined`,(e,t)=>{y.init(e,t),e._zod.pattern=_t,e._zod.values=new Set([void 0]),e._zod.optin=`optional`,e._zod.optout=`optional`,e._zod.parse=(t,n)=>{let r=t.value;return r===void 0||t.issues.push({expected:`undefined`,code:`invalid_type`,input:r,inst:e}),t}}),gn=e(`$ZodNull`,(e,t)=>{y.init(e,t),e._zod.pattern=gt,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),_n=e(`$ZodUnknown`,(e,t)=>{y.init(e,t),e._zod.parse=e=>e}),vn=e(`$ZodNever`,(e,t)=>{y.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function yn(e,t,n){e.issues.length&&t.issues.push(...ye(n,e.issues)),t.value[n]=e.value}var bn=e(`$ZodArray`,(e,t)=>{y.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>yn(t,n,e))):yn(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function xn(e,t,n,r,i){if(e.issues.length){if(i&&!(n in r))return;t.issues.push(...ye(n,e.issues))}e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function Sn(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=le(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Cn(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optout===`optional`;for(let i in t){if(s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>xn(e,n,i,t,u))):xn(a,n,i,t,u)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}var wn=e(`$ZodObject`,(e,t)=>{if(y.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,`shape`,{get:()=>{let n={...e};return Object.defineProperty(t,`shape`,{value:n}),n}})}let n=s(()=>Sn(t));f(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=re,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e],r=n._zod.optout===`optional`,i=n._zod.run({value:s[e],issues:[]},o);i instanceof Promise?c.push(i.then(n=>xn(n,t,e,s,r))):xn(i,t,e,s,r)}return i?Cn(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),Tn=e(`$ZodObjectJIT`,(e,t)=>{wn.init(e,t);let n=e._zod.parse,i=s(()=>Sn(t)),a=e=>{let t=new It([`shape`,`payload`,`ctx`]),n=i.value,r=e=>{let t=ee(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let i of n.keys){let n=a[i],o=ee(i),s=e[i]?._zod?.optout===`optional`;t.write(`const ${n} = ${r(i)};`),s?t.write(`
|
|
141
|
+
if (${n}.issues.length) {
|
|
142
|
+
if (${o} in input) {
|
|
143
|
+
payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
|
|
144
|
+
...iss,
|
|
145
|
+
path: iss.path ? [${o}, ...iss.path] : [${o}]
|
|
146
|
+
})));
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (${n}.value === undefined) {
|
|
151
|
+
if (${o} in input) {
|
|
152
|
+
newResult[${o}] = undefined;
|
|
153
|
+
}
|
|
154
|
+
} else {
|
|
155
|
+
newResult[${o}] = ${n}.value;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
`):t.write(`
|
|
159
|
+
if (${n}.issues.length) {
|
|
160
|
+
payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
|
|
161
|
+
...iss,
|
|
162
|
+
path: iss.path ? [${o}, ...iss.path] : [${o}]
|
|
163
|
+
})));
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (${n}.value === undefined) {
|
|
167
|
+
if (${o} in input) {
|
|
168
|
+
newResult[${o}] = undefined;
|
|
169
|
+
}
|
|
170
|
+
} else {
|
|
171
|
+
newResult[${o}] = ${n}.value;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
`)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},o,c=re,l=!r.jitless,u=l&&ie.value,d=t.catchall,f;e._zod.parse=(r,s)=>{f??=i.value;let p=r.value;return c(p)?l&&u&&s?.async===!1&&s.jitless!==!0?(o||=a(t.shape),r=o(r,s),d?Cn([],p,r,s,f,e):r):n(r,s):(r.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),r)}});function En(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let a=e.filter(e=>!ve(e));return a.length===1?(t.value=a[0].value,a[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>_(e,r,i())))}),t)}var Dn=e(`$ZodUnion`,(e,t)=>{y.init(e,t),f(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),f(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),f(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),f(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>l(e.source)).join(`|`)})$`)}});let n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(i,a)=>{if(n)return r(i,a);let o=!1,s=[];for(let e of t.options){let t=e._zod.run({value:i.value,issues:[]},a);if(t instanceof Promise)s.push(t),o=!0;else{if(t.issues.length===0)return t;s.push(t)}}return o?Promise.all(s).then(t=>En(t,i,e,a)):En(s,i,e,a)}}),On=e(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,Dn.init(e,t);let n=e._zod.parse;f(e._zod,`propValues`,()=>{let e={};for(let n of t.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(let[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(let r of n)e[t].add(r)}}return e});let r=s(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!re(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,input:o,path:[t.discriminator],inst:e}),i)}}),kn=e(`$ZodIntersection`,(e,t)=>{y.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>jn(e,t,n)):jn(e,i,a)}});function An(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(ae(e)&&ae(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=An(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=An(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function jn(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),ve(e))return e;let o=An(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var Mn=e(`$ZodRecord`,(e,t)=>{y.init(e,t),e._zod.parse=(n,r)=>{let a=n.value;if(!ae(a))return n.issues.push({expected:`record`,code:`invalid_type`,input:a,inst:e}),n;let o=[],s=t.keyType._zod.values;if(s){n.value={};let i=new Set;for(let e of s)if(typeof e==`string`||typeof e==`number`||typeof e==`symbol`){i.add(typeof e==`number`?e.toString():e);let s=t.valueType._zod.run({value:a[e],issues:[]},r);s instanceof Promise?o.push(s.then(t=>{t.issues.length&&n.issues.push(...ye(e,t.issues)),n.value[e]=t.value})):(s.issues.length&&n.issues.push(...ye(e,s.issues)),n.value[e]=s.value)}let c;for(let e in a)i.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:c})}else{n.value={};for(let s of Reflect.ownKeys(a)){if(s===`__proto__`)continue;let c=t.keyType._zod.run({value:s,issues:[]},r);if(c instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof s==`string`&&mt.test(s)&&c.issues.length){let e=t.keyType._zod.run({value:Number(s),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(c=e)}if(c.issues.length){t.mode===`loose`?n.value[s]=a[s]:n.issues.push({code:`invalid_key`,origin:`record`,issues:c.issues.map(e=>_(e,r,i())),input:s,path:[s],inst:e});continue}let l=t.valueType._zod.run({value:a[s],issues:[]},r);l instanceof Promise?o.push(l.then(e=>{e.issues.length&&n.issues.push(...ye(s,e.issues)),n.value[c.value]=e.value})):(l.issues.length&&n.issues.push(...ye(s,l.issues)),n.value[c.value]=l.value)}}return o.length?Promise.all(o).then(()=>n):n}}),Nn=e(`$ZodEnum`,(e,t)=>{y.init(e,t);let n=a(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>se.has(typeof e)).map(e=>typeof e==`string`?ce(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Pn=e(`$ZodLiteral`,(e,t)=>{if(y.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?ce(e):e?ce(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),Fn=e(`$ZodTransform`,(e,r)=>{y.init(e,r),e._zod.parse=(i,a)=>{if(a.direction===`backward`)throw new n(e.constructor.name);let o=r.transform(i.value,i);if(a.async)return(o instanceof Promise?o:Promise.resolve(o)).then(e=>(i.value=e,i));if(o instanceof Promise)throw new t;return i.value=o,i}});function In(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}var Ln=e(`$ZodOptional`,(e,t)=>{y.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,f(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),f(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${l(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(t=>In(t,e.value)):In(r,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),Rn=e(`$ZodExactOptional`,(e,t)=>{Ln.init(e,t),f(e._zod,`values`,()=>t.innerType._zod.values),f(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),zn=e(`$ZodNullable`,(e,t)=>{y.init(e,t),f(e._zod,`optin`,()=>t.innerType._zod.optin),f(e._zod,`optout`,()=>t.innerType._zod.optout),f(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${l(e.source)}|null)$`):void 0}),f(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Bn=e(`$ZodDefault`,(e,t)=>{y.init(e,t),e._zod.optin=`optional`,f(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Vn(e,t)):Vn(r,t)}});function Vn(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Hn=e(`$ZodPrefault`,(e,t)=>{y.init(e,t),e._zod.optin=`optional`,f(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Un=e(`$ZodNonOptional`,(e,t)=>{y.init(e,t),f(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Wn(t,e)):Wn(i,e)}});function Wn(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}var Gn=e(`$ZodCatch`,(e,t)=>{y.init(e,t),f(e._zod,`optin`,()=>t.innerType._zod.optin),f(e._zod,`optout`,()=>t.innerType._zod.optout),f(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>_(e,n,i()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>_(e,n,i()))},input:e.value}),e.issues=[]),e)}}),Kn=e(`$ZodPipe`,(e,t)=>{y.init(e,t),f(e._zod,`values`,()=>t.in._zod.values),f(e._zod,`optin`,()=>t.in._zod.optin),f(e._zod,`optout`,()=>t.out._zod.optout),f(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>qn(e,t.in,n)):qn(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>qn(e,t.out,n)):qn(r,t.out,n)}});function qn(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}var Jn=e(`$ZodReadonly`,(e,t)=>{y.init(e,t),f(e._zod,`propValues`,()=>t.innerType._zod.propValues),f(e._zod,`values`,()=>t.innerType._zod.values),f(e._zod,`optin`,()=>t.innerType?._zod?.optin),f(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Yn):Yn(r)}});function Yn(e){return e.value=Object.freeze(e.value),e}var Xn=e(`$ZodCustom`,(e,t)=>{v.init(e,t),y.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Zn(t,n,r,e));Zn(i,n,r,e)}});function Zn(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(Se(e))}}var Qn,$n=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function er(){return new $n}(Qn=globalThis).__zod_globalRegistry??(Qn.__zod_globalRegistry=er());var tr=globalThis.__zod_globalRegistry;function nr(e,t){return new e({type:`string`,...g(t)})}function rr(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...g(t)})}function ir(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...g(t)})}function ar(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...g(t)})}function or(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...g(t)})}function sr(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...g(t)})}function cr(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...g(t)})}function lr(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...g(t)})}function ur(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...g(t)})}function dr(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...g(t)})}function fr(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...g(t)})}function pr(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...g(t)})}function mr(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...g(t)})}function hr(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...g(t)})}function gr(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...g(t)})}function _r(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...g(t)})}function vr(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...g(t)})}function yr(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...g(t)})}function br(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...g(t)})}function xr(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...g(t)})}function Sr(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...g(t)})}function Cr(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...g(t)})}function wr(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...g(t)})}function Tr(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...g(t)})}function Er(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...g(t)})}function Dr(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...g(t)})}function Or(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...g(t)})}function kr(e,t){return new e({type:`number`,checks:[],...g(t)})}function Ar(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...g(t)})}function jr(e,t){return new e({type:`boolean`,...g(t)})}function Mr(e,t){return new e({type:`undefined`,...g(t)})}function Nr(e,t){return new e({type:`null`,...g(t)})}function Pr(e){return new e({type:`unknown`})}function Fr(e,t){return new e({type:`never`,...g(t)})}function Ir(e,t){return new xt({check:`less_than`,...g(t),value:e,inclusive:!1})}function Lr(e,t){return new xt({check:`less_than`,...g(t),value:e,inclusive:!0})}function Rr(e,t){return new St({check:`greater_than`,...g(t),value:e,inclusive:!1})}function zr(e,t){return new St({check:`greater_than`,...g(t),value:e,inclusive:!0})}function Br(e,t){return new Ct({check:`multiple_of`,...g(t),value:e})}function Vr(e,t){return new Tt({check:`max_length`,...g(t),maximum:e})}function Hr(e,t){return new Et({check:`min_length`,...g(t),minimum:e})}function Ur(e,t){return new Dt({check:`length_equals`,...g(t),length:e})}function Wr(e,t){return new kt({check:`string_format`,format:`regex`,...g(t),pattern:e})}function Gr(e){return new At({check:`string_format`,format:`lowercase`,...g(e)})}function Kr(e){return new jt({check:`string_format`,format:`uppercase`,...g(e)})}function qr(e,t){return new Mt({check:`string_format`,format:`includes`,...g(t),includes:e})}function Jr(e,t){return new Nt({check:`string_format`,format:`starts_with`,...g(t),prefix:e})}function Yr(e,t){return new Pt({check:`string_format`,format:`ends_with`,...g(t),suffix:e})}function Xr(e){return new Ft({check:`overwrite`,tx:e})}function Zr(e){return Xr(t=>t.normalize(e))}function Qr(){return Xr(e=>e.trim())}function $r(){return Xr(e=>e.toLowerCase())}function ei(){return Xr(e=>e.toUpperCase())}function ti(){return Xr(e=>te(e))}function ni(e,t,n){return new e({type:`array`,element:t,...g(n)})}function ri(e,t,n){let r=g(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}function ii(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...g(n)})}function ai(e){let t=oi(n=>(n.addIssue=e=>{if(typeof e==`string`)n.issues.push(Se(e,n.value,t._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=n.value,r.inst??=t,r.continue??=!t._zod.def.abort,n.issues.push(Se(r))}},e(n.value,n)));return t}function oi(e,t){let n=new v({check:`custom`,...g(t)});return n._zod.check=e,n}function si(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??tr,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function x(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,x(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&S(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&o.schema._prefault&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function ci(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
|
|
175
|
+
|
|
176
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function li(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(a[e.defId]=e.def)}e.external||Object.keys(a).length>0&&(e.target===`draft-2020-12`?i.$defs=a:i.definitions=a);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,`~standard`,{value:{...t[`~standard`],jsonSchema:{input:di(t,`input`,e.processors),output:di(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function S(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return S(r.element,n);if(r.type===`set`)return S(r.valueType,n);if(r.type===`lazy`)return S(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type===`default`||r.type===`prefault`)return S(r.innerType,n);if(r.type===`intersection`)return S(r.left,n)||S(r.right,n);if(r.type===`record`||r.type===`map`)return S(r.keyType,n)||S(r.valueType,n);if(r.type===`pipe`)return S(r.in,n)||S(r.out,n);if(r.type===`object`){for(let e in r.shape)if(S(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(S(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(S(e,n))return!0;return!!(r.rest&&S(r.rest,n))}return!1}var ui=(e,t={})=>n=>{let r=si({...n,processors:t});return x(e,r),ci(r,e),li(r,e)},di=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=si({...i??{},target:a,io:t,processors:n});return x(e,o),ci(o,e),li(o,e)},fi={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},pi=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=fi[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},mi=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`,typeof u==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u),typeof a==`number`&&(i.minimum=a,typeof u==`number`&&t.target!==`draft-04`&&(u>=a?delete i.minimum:delete i.exclusiveMinimum)),typeof l==`number`&&(t.target===`draft-04`||t.target===`openapi-3.0`?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l),typeof o==`number`&&(i.maximum=o,typeof l==`number`&&t.target!==`draft-04`&&(l<=o?delete i.maximum:delete i.exclusiveMaximum)),typeof c==`number`&&(i.multipleOf=c)},hi=(e,t,n,r)=>{n.type=`boolean`},gi=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},_i=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Undefined cannot be represented in JSON Schema`)},vi=(e,t,n,r)=>{n.not={}},yi=(e,t,n,r)=>{let i=e._zod.def,o=a(i.entries);o.every(e=>typeof e==`number`)&&(n.type=`number`),o.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=o},bi=(e,t,n,r)=>{let i=e._zod.def,a=[];for(let e of i.values)if(e===void 0){if(t.unrepresentable===`throw`)throw Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof e==`bigint`){if(t.unrepresentable===`throw`)throw Error(`BigInt literals cannot be represented in JSON Schema`);a.push(Number(e))}else a.push(e);if(a.length!==0)if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a},xi=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},Si=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},Ci=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=x(a.element,t,{...r,path:[...r.path,`items`]})},wi=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=x(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=x(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},Ti=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>x(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Ei=(e,t,n,r)=>{let i=e._zod.def,a=x(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=x(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},Di=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=x(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else (t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=x(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=x(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},Oi=(e,t,n,r)=>{let i=e._zod.def,a=x(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},ki=(e,t,n,r)=>{let i=e._zod.def;x(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Ai=(e,t,n,r)=>{let i=e._zod.def;x(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},ji=(e,t,n,r)=>{let i=e._zod.def;x(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},Mi=(e,t,n,r)=>{let i=e._zod.def;x(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},Ni=(e,t,n,r)=>{let i=e._zod.def,a=t.io===`input`?i.in._zod.def.type===`transform`?i.out:i.in:i.out;x(a,t,r);let o=t.seen.get(e);o.ref=a},Pi=(e,t,n,r)=>{let i=e._zod.def;x(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Fi=(e,t,n,r)=>{let i=e._zod.def;x(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType};function Ii(e){return!!e._zod}function Li(e,t){return Ii(e)?je(e,t):e.safeParse(t)}function Ri(e){if(!e)return;let t;if(t=Ii(e)?e._zod?.def?.shape:e.shape,t){if(typeof t==`function`)try{return t()}catch{return}return t}}function zi(e){if(Ii(e)){let t=e._zod?.def;if(t){if(t.value!==void 0)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}}let t=e._def;if(t){if(t.value!==void 0)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}let n=e.value;if(n!==void 0)return n}var Bi=e(`ZodISODateTime`,(e,t)=>{Xt.init(e,t),E.init(e,t)});function Vi(e){return Tr(Bi,e)}var Hi=e(`ZodISODate`,(e,t)=>{Zt.init(e,t),E.init(e,t)});function Ui(e){return Er(Hi,e)}var Wi=e(`ZodISOTime`,(e,t)=>{Qt.init(e,t),E.init(e,t)});function Gi(e){return Dr(Wi,e)}var Ki=e(`ZodISODuration`,(e,t)=>{$t.init(e,t),E.init(e,t)});function qi(e){return Or(Ki,e)}var Ji=(e,t)=>{we.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>De(e,t)},flatten:{value:t=>Ee(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,o,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,o,2)}},isEmpty:{get(){return e.issues.length===0}}})};e(`ZodError`,Ji);var C=e(`ZodError`,Ji,{Parent:Error}),Yi=Oe(C),Xi=ke(C),Zi=Ae(C),Qi=Me(C),$i=Pe(C),ea=Fe(C),ta=Ie(C),na=Le(C),ra=Re(C),ia=ze(C),aa=Be(C),oa=Ve(C),w=e(`ZodType`,(e,t)=>(y.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:di(e,`input`),output:di(e,`output`)}}),e.toJSONSchema=ui(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,`_def`,{value:t}),e.check=(...n)=>e.clone(m(t,{checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0}),e.with=e.check,e.clone=(t,n)=>h(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.parse=(t,n)=>Yi(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Zi(e,t,n),e.parseAsync=async(t,n)=>Xi(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Qi(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>$i(e,t,n),e.decode=(t,n)=>ea(e,t,n),e.encodeAsync=async(t,n)=>ta(e,t,n),e.decodeAsync=async(t,n)=>na(e,t,n),e.safeEncode=(t,n)=>ra(e,t,n),e.safeDecode=(t,n)=>ia(e,t,n),e.safeEncodeAsync=async(t,n)=>aa(e,t,n),e.safeDecodeAsync=async(t,n)=>oa(e,t,n),e.refine=(t,n)=>e.check(_o(t,n)),e.superRefine=t=>e.check(vo(t)),e.overwrite=t=>e.check(Xr(t)),e.optional=()=>L(e),e.exactOptional=()=>$a(e),e.nullable=()=>to(e),e.nullish=()=>L(to(e)),e.nonoptional=t=>so(e,t),e.array=()=>A(e),e.or=t=>N([e,t]),e.and=t=>Ga(e,t),e.transform=t=>fo(e,Xa(t)),e.default=t=>ro(e,t),e.prefault=t=>ao(e,t),e.catch=t=>lo(e,t),e.pipe=t=>fo(e,t),e.readonly=()=>mo(e),e.describe=t=>{let n=e.clone();return tr.add(n,{description:t}),n},Object.defineProperty(e,`description`,{get(){return tr.get(e)?.description},configurable:!0}),e.meta=(...t)=>{if(t.length===0)return tr.get(e);let n=e.clone();return tr.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e.apply=t=>t(e),e)),sa=e(`_ZodString`,(e,t)=>{Rt.init(e,t),w.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pi(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(Wr(...t)),e.includes=(...t)=>e.check(qr(...t)),e.startsWith=(...t)=>e.check(Jr(...t)),e.endsWith=(...t)=>e.check(Yr(...t)),e.min=(...t)=>e.check(Hr(...t)),e.max=(...t)=>e.check(Vr(...t)),e.length=(...t)=>e.check(Ur(...t)),e.nonempty=(...t)=>e.check(Hr(1,...t)),e.lowercase=t=>e.check(Gr(t)),e.uppercase=t=>e.check(Kr(t)),e.trim=()=>e.check(Qr()),e.normalize=(...t)=>e.check(Zr(...t)),e.toLowerCase=()=>e.check($r()),e.toUpperCase=()=>e.check(ei()),e.slugify=()=>e.check(ti())}),ca=e(`ZodString`,(e,t)=>{Rt.init(e,t),sa.init(e,t),e.email=t=>e.check(rr(la,t)),e.url=t=>e.check(lr(fa,t)),e.jwt=t=>e.check(wr(Da,t)),e.emoji=t=>e.check(ur(pa,t)),e.guid=t=>e.check(ir(ua,t)),e.uuid=t=>e.check(ar(da,t)),e.uuidv4=t=>e.check(or(da,t)),e.uuidv6=t=>e.check(sr(da,t)),e.uuidv7=t=>e.check(cr(da,t)),e.nanoid=t=>e.check(dr(ma,t)),e.guid=t=>e.check(ir(ua,t)),e.cuid=t=>e.check(fr(ha,t)),e.cuid2=t=>e.check(pr(ga,t)),e.ulid=t=>e.check(mr(_a,t)),e.base64=t=>e.check(xr(wa,t)),e.base64url=t=>e.check(Sr(Ta,t)),e.xid=t=>e.check(hr(va,t)),e.ksuid=t=>e.check(gr(ya,t)),e.ipv4=t=>e.check(_r(ba,t)),e.ipv6=t=>e.check(vr(xa,t)),e.cidrv4=t=>e.check(yr(Sa,t)),e.cidrv6=t=>e.check(br(Ca,t)),e.e164=t=>e.check(Cr(Ea,t)),e.datetime=t=>e.check(Vi(t)),e.date=t=>e.check(Ui(t)),e.time=t=>e.check(Gi(t)),e.duration=t=>e.check(qi(t))});function T(e){return nr(ca,e)}var E=e(`ZodStringFormat`,(e,t)=>{b.init(e,t),sa.init(e,t)}),la=e(`ZodEmail`,(e,t)=>{Vt.init(e,t),E.init(e,t)}),ua=e(`ZodGUID`,(e,t)=>{zt.init(e,t),E.init(e,t)}),da=e(`ZodUUID`,(e,t)=>{Bt.init(e,t),E.init(e,t)}),fa=e(`ZodURL`,(e,t)=>{Ht.init(e,t),E.init(e,t)}),pa=e(`ZodEmoji`,(e,t)=>{Ut.init(e,t),E.init(e,t)}),ma=e(`ZodNanoID`,(e,t)=>{Wt.init(e,t),E.init(e,t)}),ha=e(`ZodCUID`,(e,t)=>{Gt.init(e,t),E.init(e,t)}),ga=e(`ZodCUID2`,(e,t)=>{Kt.init(e,t),E.init(e,t)}),_a=e(`ZodULID`,(e,t)=>{qt.init(e,t),E.init(e,t)}),va=e(`ZodXID`,(e,t)=>{Jt.init(e,t),E.init(e,t)}),ya=e(`ZodKSUID`,(e,t)=>{Yt.init(e,t),E.init(e,t)}),ba=e(`ZodIPv4`,(e,t)=>{en.init(e,t),E.init(e,t)}),xa=e(`ZodIPv6`,(e,t)=>{tn.init(e,t),E.init(e,t)}),Sa=e(`ZodCIDRv4`,(e,t)=>{nn.init(e,t),E.init(e,t)}),Ca=e(`ZodCIDRv6`,(e,t)=>{rn.init(e,t),E.init(e,t)}),wa=e(`ZodBase64`,(e,t)=>{on.init(e,t),E.init(e,t)}),Ta=e(`ZodBase64URL`,(e,t)=>{cn.init(e,t),E.init(e,t)}),Ea=e(`ZodE164`,(e,t)=>{ln.init(e,t),E.init(e,t)}),Da=e(`ZodJWT`,(e,t)=>{dn.init(e,t),E.init(e,t)}),Oa=e(`ZodNumber`,(e,t)=>{fn.init(e,t),w.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mi(e,t,n,r),e.gt=(t,n)=>e.check(Rr(t,n)),e.gte=(t,n)=>e.check(zr(t,n)),e.min=(t,n)=>e.check(zr(t,n)),e.lt=(t,n)=>e.check(Ir(t,n)),e.lte=(t,n)=>e.check(Lr(t,n)),e.max=(t,n)=>e.check(Lr(t,n)),e.int=t=>e.check(Aa(t)),e.safe=t=>e.check(Aa(t)),e.positive=t=>e.check(Rr(0,t)),e.nonnegative=t=>e.check(zr(0,t)),e.negative=t=>e.check(Ir(0,t)),e.nonpositive=t=>e.check(Lr(0,t)),e.multipleOf=(t,n)=>e.check(Br(t,n)),e.step=(t,n)=>e.check(Br(t,n)),e.finite=()=>e;let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function D(e){return kr(Oa,e)}var ka=e(`ZodNumberFormat`,(e,t)=>{pn.init(e,t),Oa.init(e,t)});function Aa(e){return Ar(ka,e)}var ja=e(`ZodBoolean`,(e,t)=>{mn.init(e,t),w.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hi(e,t,n,r)});function O(e){return jr(ja,e)}var Ma=e(`ZodUndefined`,(e,t)=>{hn.init(e,t),w.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_i(e,t,n,r)});function Na(e){return Mr(Ma,e)}var Pa=e(`ZodNull`,(e,t)=>{gn.init(e,t),w.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gi(e,t,n,r)});function Fa(e){return Nr(Pa,e)}var Ia=e(`ZodUnknown`,(e,t)=>{_n.init(e,t),w.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function k(){return Pr(Ia)}var La=e(`ZodNever`,(e,t)=>{vn.init(e,t),w.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vi(e,t,n,r)});function Ra(e){return Fr(La,e)}var za=e(`ZodArray`,(e,t)=>{bn.init(e,t),w.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ci(e,t,n,r),e.element=t.element,e.min=(t,n)=>e.check(Hr(t,n)),e.nonempty=t=>e.check(Hr(1,t)),e.max=(t,n)=>e.check(Vr(t,n)),e.length=(t,n)=>e.check(Ur(t,n)),e.unwrap=()=>e.element});function A(e,t){return ni(za,e,t)}var Ba=e(`ZodObject`,(e,t)=>{Tn.init(e,t),w.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wi(e,t,n,r),f(e,`shape`,()=>t.shape),e.keyof=()=>F(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:k()}),e.loose=()=>e.clone({...e._zod.def,catchall:k()}),e.strict=()=>e.clone({...e._zod.def,catchall:Ra()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>pe(e,t),e.safeExtend=t=>me(e,t),e.merge=t=>he(e,t),e.pick=t=>de(e,t),e.omit=t=>fe(e,t),e.partial=(...t)=>ge(Za,e,t[0]),e.required=(...t)=>_e(oo,e,t[0])});function j(e,t){return new Ba({type:`object`,shape:e??{},...g(t)})}function M(e,t){return new Ba({type:`object`,shape:e,catchall:k(),...g(t)})}var Va=e(`ZodUnion`,(e,t)=>{Dn.init(e,t),w.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ti(e,t,n,r),e.options=t.options});function N(e,t){return new Va({type:`union`,options:e,...g(t)})}var Ha=e(`ZodDiscriminatedUnion`,(e,t)=>{Va.init(e,t),On.init(e,t)});function Ua(e,t,n){return new Ha({type:`union`,options:t,discriminator:e,...g(n)})}var Wa=e(`ZodIntersection`,(e,t)=>{kn.init(e,t),w.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ei(e,t,n,r)});function Ga(e,t){return new Wa({type:`intersection`,left:e,right:t})}var Ka=e(`ZodRecord`,(e,t)=>{Mn.init(e,t),w.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Di(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function P(e,t,n){return new Ka({type:`record`,keyType:e,valueType:t,...g(n)})}var qa=e(`ZodEnum`,(e,t)=>{Nn.init(e,t),w.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yi(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new qa({...t,checks:[],...g(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new qa({...t,checks:[],...g(r),entries:i})}});function F(e,t){return new qa({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...g(t)})}var Ja=e(`ZodLiteral`,(e,t)=>{Pn.init(e,t),w.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bi(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,`value`,{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function I(e,t){return new Ja({type:`literal`,values:Array.isArray(e)?e:[e],...g(t)})}var Ya=e(`ZodTransform`,(e,t)=>{Fn.init(e,t),w.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Si(e,t,n,r),e._zod.parse=(r,i)=>{if(i.direction===`backward`)throw new n(e.constructor.name);r.addIssue=n=>{if(typeof n==`string`)r.issues.push(Se(n,r.value,t));else{let t=n;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=r.value,t.inst??=e,r.issues.push(Se(t))}};let a=t.transform(r.value,r);return a instanceof Promise?a.then(e=>(r.value=e,r)):(r.value=a,r)}});function Xa(e){return new Ya({type:`transform`,transform:e})}var Za=e(`ZodOptional`,(e,t)=>{Ln.init(e,t),w.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function L(e){return new Za({type:`optional`,innerType:e})}var Qa=e(`ZodExactOptional`,(e,t)=>{Rn.init(e,t),w.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Fi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function $a(e){return new Qa({type:`optional`,innerType:e})}var eo=e(`ZodNullable`,(e,t)=>{zn.init(e,t),w.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Oi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function to(e){return new eo({type:`nullable`,innerType:e})}var no=e(`ZodDefault`,(e,t)=>{Bn.init(e,t),w.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ai(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function ro(e,t){return new no({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():oe(t)}})}var io=e(`ZodPrefault`,(e,t)=>{Hn.init(e,t),w.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ji(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ao(e,t){return new io({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():oe(t)}})}var oo=e(`ZodNonOptional`,(e,t)=>{Un.init(e,t),w.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ki(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function so(e,t){return new oo({type:`nonoptional`,innerType:e,...g(t)})}var co=e(`ZodCatch`,(e,t)=>{Gn.init(e,t),w.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Mi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function lo(e,t){return new co({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var uo=e(`ZodPipe`,(e,t)=>{Kn.init(e,t),w.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ni(e,t,n,r),e.in=t.in,e.out=t.out});function fo(e,t){return new uo({type:`pipe`,in:e,out:t})}var po=e(`ZodReadonly`,(e,t)=>{Jn.init(e,t),w.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Pi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function mo(e){return new po({type:`readonly`,innerType:e})}var ho=e(`ZodCustom`,(e,t)=>{Xn.init(e,t),w.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xi(e,t,n,r)});function go(e,t){return ri(ho,e??(()=>!0),t)}function _o(e,t={}){return ii(ho,e,t)}function vo(e){return ai(e)}function yo(e,t){return fo(Xa(e),t)}var bo=`io.modelcontextprotocol/related-task`,R=go(e=>e!==null&&(typeof e==`object`||typeof e==`function`)),xo=N([T(),D().int()]),So=T();M({ttl:N([D(),Fa()]).optional(),pollInterval:D().optional()});var Co=j({ttl:D().optional()}),wo=j({taskId:T()}),To=M({progressToken:xo.optional(),[bo]:wo.optional()}),z=j({_meta:To.optional()}),Eo=z.extend({task:Co.optional()}),Do=e=>Eo.safeParse(e).success,B=j({method:T(),params:z.loose().optional()}),V=j({_meta:To.optional()}),H=j({method:T(),params:V.loose().optional()}),U=M({_meta:To.optional()}),Oo=N([T(),D().int()]),ko=j({jsonrpc:I(`2.0`),id:Oo,...B.shape}).strict(),Ao=e=>ko.safeParse(e).success,jo=j({jsonrpc:I(`2.0`),...H.shape}).strict(),Mo=e=>jo.safeParse(e).success,No=j({jsonrpc:I(`2.0`),id:Oo,result:U}).strict(),Po=e=>No.safeParse(e).success,W;(function(e){e[e.ConnectionClosed=-32e3]=`ConnectionClosed`,e[e.RequestTimeout=-32001]=`RequestTimeout`,e[e.ParseError=-32700]=`ParseError`,e[e.InvalidRequest=-32600]=`InvalidRequest`,e[e.MethodNotFound=-32601]=`MethodNotFound`,e[e.InvalidParams=-32602]=`InvalidParams`,e[e.InternalError=-32603]=`InternalError`,e[e.UrlElicitationRequired=-32042]=`UrlElicitationRequired`})(W||={});var Fo=j({jsonrpc:I(`2.0`),id:Oo.optional(),error:j({code:D().int(),message:T(),data:k().optional()})}).strict(),Io=e=>Fo.safeParse(e).success,Lo=N([ko,jo,No,Fo]);N([No,Fo]);var Ro=U.strict(),zo=V.extend({requestId:Oo.optional(),reason:T().optional()}),Bo=H.extend({method:I(`notifications/cancelled`),params:zo}),Vo=j({icons:A(j({src:T(),mimeType:T().optional(),sizes:A(T()).optional(),theme:F([`light`,`dark`]).optional()})).optional()}),Ho=j({name:T(),title:T().optional()}),Uo=Ho.extend({...Ho.shape,...Vo.shape,version:T(),websiteUrl:T().optional(),description:T().optional()}),Wo=yo(e=>e&&typeof e==`object`&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,Ga(j({form:Ga(j({applyDefaults:O().optional()}),P(T(),k())).optional(),url:R.optional()}),P(T(),k()).optional())),Go=M({list:R.optional(),cancel:R.optional(),requests:M({sampling:M({createMessage:R.optional()}).optional(),elicitation:M({create:R.optional()}).optional()}).optional()}),Ko=M({list:R.optional(),cancel:R.optional(),requests:M({tools:M({call:R.optional()}).optional()}).optional()}),qo=j({experimental:P(T(),R).optional(),sampling:j({context:R.optional(),tools:R.optional()}).optional(),elicitation:Wo.optional(),roots:j({listChanged:O().optional()}).optional(),tasks:Go.optional()}),Jo=z.extend({protocolVersion:T(),capabilities:qo,clientInfo:Uo}),Yo=B.extend({method:I(`initialize`),params:Jo}),Xo=j({experimental:P(T(),R).optional(),logging:R.optional(),completions:R.optional(),prompts:j({listChanged:O().optional()}).optional(),resources:j({subscribe:O().optional(),listChanged:O().optional()}).optional(),tools:j({listChanged:O().optional()}).optional(),tasks:Ko.optional()}),Zo=U.extend({protocolVersion:T(),capabilities:Xo,serverInfo:Uo,instructions:T().optional()}),Qo=H.extend({method:I(`notifications/initialized`),params:V.optional()}),$o=B.extend({method:I(`ping`),params:z.optional()}),es=j({progress:D(),total:L(D()),message:L(T())}),ts=j({...V.shape,...es.shape,progressToken:xo}),ns=H.extend({method:I(`notifications/progress`),params:ts}),rs=z.extend({cursor:So.optional()}),is=B.extend({params:rs.optional()}),as=U.extend({nextCursor:So.optional()}),os=F([`working`,`input_required`,`completed`,`failed`,`cancelled`]),ss=j({taskId:T(),status:os,ttl:N([D(),Fa()]),createdAt:T(),lastUpdatedAt:T(),pollInterval:L(D()),statusMessage:L(T())}),cs=U.extend({task:ss}),ls=V.merge(ss),us=H.extend({method:I(`notifications/tasks/status`),params:ls}),ds=B.extend({method:I(`tasks/get`),params:z.extend({taskId:T()})}),fs=U.merge(ss),ps=B.extend({method:I(`tasks/result`),params:z.extend({taskId:T()})});U.loose();var ms=is.extend({method:I(`tasks/list`)}),hs=as.extend({tasks:A(ss)}),gs=B.extend({method:I(`tasks/cancel`),params:z.extend({taskId:T()})}),_s=U.merge(ss),vs=j({uri:T(),mimeType:L(T()),_meta:P(T(),k()).optional()}),ys=vs.extend({text:T()}),bs=T().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:`Invalid Base64 string`}),xs=vs.extend({blob:bs}),Ss=F([`user`,`assistant`]),Cs=j({audience:A(Ss).optional(),priority:D().min(0).max(1).optional(),lastModified:Vi({offset:!0}).optional()}),ws=j({...Ho.shape,...Vo.shape,uri:T(),description:L(T()),mimeType:L(T()),annotations:Cs.optional(),_meta:L(M({}))}),Ts=j({...Ho.shape,...Vo.shape,uriTemplate:T(),description:L(T()),mimeType:L(T()),annotations:Cs.optional(),_meta:L(M({}))}),Es=is.extend({method:I(`resources/list`)}),Ds=as.extend({resources:A(ws)}),Os=is.extend({method:I(`resources/templates/list`)}),ks=as.extend({resourceTemplates:A(Ts)}),As=z.extend({uri:T()}),js=As,Ms=B.extend({method:I(`resources/read`),params:js}),Ns=U.extend({contents:A(N([ys,xs]))}),Ps=H.extend({method:I(`notifications/resources/list_changed`),params:V.optional()}),Fs=As,Is=B.extend({method:I(`resources/subscribe`),params:Fs}),Ls=As,Rs=B.extend({method:I(`resources/unsubscribe`),params:Ls}),zs=V.extend({uri:T()}),Bs=H.extend({method:I(`notifications/resources/updated`),params:zs}),Vs=j({name:T(),description:L(T()),required:L(O())}),Hs=j({...Ho.shape,...Vo.shape,description:L(T()),arguments:L(A(Vs)),_meta:L(M({}))}),Us=is.extend({method:I(`prompts/list`)}),Ws=as.extend({prompts:A(Hs)}),Gs=z.extend({name:T(),arguments:P(T(),T()).optional()}),Ks=B.extend({method:I(`prompts/get`),params:Gs}),qs=j({type:I(`text`),text:T(),annotations:Cs.optional(),_meta:P(T(),k()).optional()}),Js=j({type:I(`image`),data:bs,mimeType:T(),annotations:Cs.optional(),_meta:P(T(),k()).optional()}),Ys=j({type:I(`audio`),data:bs,mimeType:T(),annotations:Cs.optional(),_meta:P(T(),k()).optional()}),Xs=j({type:I(`tool_use`),name:T(),id:T(),input:P(T(),k()),_meta:P(T(),k()).optional()}),Zs=j({type:I(`resource`),resource:N([ys,xs]),annotations:Cs.optional(),_meta:P(T(),k()).optional()}),Qs=ws.extend({type:I(`resource_link`)}),$s=N([qs,Js,Ys,Qs,Zs]),ec=j({role:Ss,content:$s}),tc=U.extend({description:T().optional(),messages:A(ec)}),nc=H.extend({method:I(`notifications/prompts/list_changed`),params:V.optional()}),rc=j({title:T().optional(),readOnlyHint:O().optional(),destructiveHint:O().optional(),idempotentHint:O().optional(),openWorldHint:O().optional()}),ic=j({taskSupport:F([`required`,`optional`,`forbidden`]).optional()}),ac=j({...Ho.shape,...Vo.shape,description:T().optional(),inputSchema:j({type:I(`object`),properties:P(T(),R).optional(),required:A(T()).optional()}).catchall(k()),outputSchema:j({type:I(`object`),properties:P(T(),R).optional(),required:A(T()).optional()}).catchall(k()).optional(),annotations:rc.optional(),execution:ic.optional(),_meta:P(T(),k()).optional()}),oc=is.extend({method:I(`tools/list`)}),sc=as.extend({tools:A(ac)}),cc=U.extend({content:A($s).default([]),structuredContent:P(T(),k()).optional(),isError:O().optional()});cc.or(U.extend({toolResult:k()}));var lc=Eo.extend({name:T(),arguments:P(T(),k()).optional()}),uc=B.extend({method:I(`tools/call`),params:lc}),dc=H.extend({method:I(`notifications/tools/list_changed`),params:V.optional()});j({autoRefresh:O().default(!0),debounceMs:D().int().nonnegative().default(300)});var fc=F([`debug`,`info`,`notice`,`warning`,`error`,`critical`,`alert`,`emergency`]),pc=z.extend({level:fc}),mc=B.extend({method:I(`logging/setLevel`),params:pc}),hc=V.extend({level:fc,logger:T().optional(),data:k()}),gc=H.extend({method:I(`notifications/message`),params:hc}),_c=j({hints:A(j({name:T().optional()})).optional(),costPriority:D().min(0).max(1).optional(),speedPriority:D().min(0).max(1).optional(),intelligencePriority:D().min(0).max(1).optional()}),vc=j({mode:F([`auto`,`required`,`none`]).optional()}),yc=j({type:I(`tool_result`),toolUseId:T().describe(`The unique identifier for the corresponding tool call.`),content:A($s).default([]),structuredContent:j({}).loose().optional(),isError:O().optional(),_meta:P(T(),k()).optional()}),bc=Ua(`type`,[qs,Js,Ys]),xc=Ua(`type`,[qs,Js,Ys,Xs,yc]),Sc=j({role:Ss,content:N([xc,A(xc)]),_meta:P(T(),k()).optional()}),Cc=Eo.extend({messages:A(Sc),modelPreferences:_c.optional(),systemPrompt:T().optional(),includeContext:F([`none`,`thisServer`,`allServers`]).optional(),temperature:D().optional(),maxTokens:D().int(),stopSequences:A(T()).optional(),metadata:R.optional(),tools:A(ac).optional(),toolChoice:vc.optional()}),wc=B.extend({method:I(`sampling/createMessage`),params:Cc}),Tc=U.extend({model:T(),stopReason:L(F([`endTurn`,`stopSequence`,`maxTokens`]).or(T())),role:Ss,content:bc}),Ec=U.extend({model:T(),stopReason:L(F([`endTurn`,`stopSequence`,`maxTokens`,`toolUse`]).or(T())),role:Ss,content:N([xc,A(xc)])}),Dc=j({type:I(`boolean`),title:T().optional(),description:T().optional(),default:O().optional()}),Oc=j({type:I(`string`),title:T().optional(),description:T().optional(),minLength:D().optional(),maxLength:D().optional(),format:F([`email`,`uri`,`date`,`date-time`]).optional(),default:T().optional()}),kc=j({type:F([`number`,`integer`]),title:T().optional(),description:T().optional(),minimum:D().optional(),maximum:D().optional(),default:D().optional()}),Ac=j({type:I(`string`),title:T().optional(),description:T().optional(),enum:A(T()),default:T().optional()}),jc=j({type:I(`string`),title:T().optional(),description:T().optional(),oneOf:A(j({const:T(),title:T()})),default:T().optional()}),Mc=N([N([j({type:I(`string`),title:T().optional(),description:T().optional(),enum:A(T()),enumNames:A(T()).optional(),default:T().optional()}),N([Ac,jc]),N([j({type:I(`array`),title:T().optional(),description:T().optional(),minItems:D().optional(),maxItems:D().optional(),items:j({type:I(`string`),enum:A(T())}),default:A(T()).optional()}),j({type:I(`array`),title:T().optional(),description:T().optional(),minItems:D().optional(),maxItems:D().optional(),items:j({anyOf:A(j({const:T(),title:T()}))}),default:A(T()).optional()})])]),Dc,Oc,kc]),Nc=N([Eo.extend({mode:I(`form`).optional(),message:T(),requestedSchema:j({type:I(`object`),properties:P(T(),Mc),required:A(T()).optional()})}),Eo.extend({mode:I(`url`),message:T(),elicitationId:T(),url:T().url()})]),Pc=B.extend({method:I(`elicitation/create`),params:Nc}),Fc=V.extend({elicitationId:T()}),Ic=H.extend({method:I(`notifications/elicitation/complete`),params:Fc}),Lc=U.extend({action:F([`accept`,`decline`,`cancel`]),content:yo(e=>e===null?void 0:e,P(T(),N([T(),D(),O(),A(T())])).optional())}),Rc=j({type:I(`ref/resource`),uri:T()}),zc=j({type:I(`ref/prompt`),name:T()}),Bc=z.extend({ref:N([zc,Rc]),argument:j({name:T(),value:T()}),context:j({arguments:P(T(),T()).optional()}).optional()}),Vc=B.extend({method:I(`completion/complete`),params:Bc}),Hc=U.extend({completion:M({values:A(T()).max(100),total:L(D().int()),hasMore:L(O())})}),Uc=j({uri:T().startsWith(`file://`),name:T().optional(),_meta:P(T(),k()).optional()}),Wc=B.extend({method:I(`roots/list`),params:z.optional()}),Gc=U.extend({roots:A(Uc)}),Kc=H.extend({method:I(`notifications/roots/list_changed`),params:V.optional()});N([$o,Yo,Vc,mc,Ks,Us,Es,Os,Ms,Is,Rs,uc,oc,ds,ps,ms,gs]),N([Bo,ns,Qo,Kc,us]),N([Ro,Tc,Ec,Lc,Gc,fs,hs,cs]),N([$o,wc,Pc,Wc,ds,ps,ms,gs]),N([Bo,ns,gc,Bs,Ps,dc,nc,us,Ic]),N([Ro,Zo,Hc,tc,Ws,Ds,ks,Ns,cc,sc,fs,hs,cs]);var G=class e extends Error{constructor(e,t,n){super(`MCP error ${e}: ${t}`),this.code=e,this.data=n,this.name=`McpError`}static fromError(t,n,r){if(t===W.UrlElicitationRequired&&r){let e=r;if(e.elicitations)return new qc(e.elicitations,n)}return new e(t,n,r)}},qc=class extends G{constructor(e,t=`URL elicitation${e.length>1?`s`:``} required`){super(W.UrlElicitationRequired,t,{elicitations:e})}get elicitations(){return this.data?.elicitations??[]}};function Jc(e){return e===`completed`||e===`failed`||e===`cancelled`}function Yc(e){let t=Ri(e)?.method;if(!t)throw Error(`Schema is missing a method literal`);let n=zi(t);if(typeof n!=`string`)throw Error(`Schema method literal must be a string`);return n}function Xc(e,t){let n=Li(e,t);if(!n.success)throw n.error;return n.data}var Zc=class{constructor(e){this._options=e,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(Bo,e=>{this._oncancel(e)}),this.setNotificationHandler(ns,e=>{this._onprogress(e)}),this.setRequestHandler($o,e=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(ds,async(e,t)=>{let n=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!n)throw new G(W.InvalidParams,`Failed to retrieve task: Task not found`);return{...n}}),this.setRequestHandler(ps,async(e,t)=>{let n=async()=>{let r=e.params.taskId;if(this._taskMessageQueue){let e;for(;e=await this._taskMessageQueue.dequeue(r,t.sessionId);){if(e.type===`response`||e.type===`error`){let t=e.message,n=t.id,r=this._requestResolvers.get(n);if(r)if(this._requestResolvers.delete(n),e.type===`response`)r(t);else{let e=t;r(new G(e.error.code,e.error.message,e.error.data))}else{let t=e.type===`response`?`Response`:`Error`;this._onerror(Error(`${t} handler missing for request ${n}`))}continue}await this._transport?.send(e.message,{relatedRequestId:t.requestId})}}let i=await this._taskStore.getTask(r,t.sessionId);if(!i)throw new G(W.InvalidParams,`Task not found: ${r}`);if(!Jc(i.status))return await this._waitForTaskUpdate(r,t.signal),await n();if(Jc(i.status)){let e=await this._taskStore.getTaskResult(r,t.sessionId);return this._clearTaskQueue(r),{...e,_meta:{...e._meta,[bo]:{taskId:r}}}}return await n()};return await n()}),this.setRequestHandler(ms,async(e,t)=>{try{let{tasks:n,nextCursor:r}=await this._taskStore.listTasks(e.params?.cursor,t.sessionId);return{tasks:n,nextCursor:r,_meta:{}}}catch(e){throw new G(W.InvalidParams,`Failed to list tasks: ${e instanceof Error?e.message:String(e)}`)}}),this.setRequestHandler(gs,async(e,t)=>{try{let n=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!n)throw new G(W.InvalidParams,`Task not found: ${e.params.taskId}`);if(Jc(n.status))throw new G(W.InvalidParams,`Cannot cancel task in terminal status: ${n.status}`);await this._taskStore.updateTaskStatus(e.params.taskId,`cancelled`,`Client cancelled task execution.`,t.sessionId),this._clearTaskQueue(e.params.taskId);let r=await this._taskStore.getTask(e.params.taskId,t.sessionId);if(!r)throw new G(W.InvalidParams,`Task not found after cancellation: ${e.params.taskId}`);return{_meta:{},...r}}catch(e){throw e instanceof G?e:new G(W.InvalidRequest,`Failed to cancel task: ${e instanceof Error?e.message:String(e)}`)}}))}async _oncancel(e){e.params.requestId&&this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason)}_setupTimeout(e,t,n,r,i=!1){this._timeoutInfo.set(e,{timeoutId:setTimeout(r,t),startTime:Date.now(),timeout:t,maxTotalTimeout:n,resetTimeoutOnProgress:i,onTimeout:r})}_resetTimeout(e){let t=this._timeoutInfo.get(e);if(!t)return!1;let n=Date.now()-t.startTime;if(t.maxTotalTimeout&&n>=t.maxTotalTimeout)throw this._timeoutInfo.delete(e),G.fromError(W.RequestTimeout,`Maximum total timeout exceeded`,{maxTotalTimeout:t.maxTotalTimeout,totalElapsed:n});return clearTimeout(t.timeoutId),t.timeoutId=setTimeout(t.onTimeout,t.timeout),!0}_cleanupTimeout(e){let t=this._timeoutInfo.get(e);t&&(clearTimeout(t.timeoutId),this._timeoutInfo.delete(e))}async connect(e){if(this._transport)throw Error(`Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.`);this._transport=e;let t=this.transport?.onclose;this._transport.onclose=()=>{t?.(),this._onclose()};let n=this.transport?.onerror;this._transport.onerror=e=>{n?.(e),this._onerror(e)};let r=this._transport?.onmessage;this._transport.onmessage=(e,t)=>{r?.(e,t),Po(e)||Io(e)?this._onresponse(e):Ao(e)?this._onrequest(e,t):Mo(e)?this._onnotification(e):this._onerror(Error(`Unknown message type: ${JSON.stringify(e)}`))},await this._transport.start()}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let e of this._requestHandlerAbortControllers.values())e.abort();this._requestHandlerAbortControllers.clear();let t=G.fromError(W.ConnectionClosed,`Connection closed`);this._transport=void 0,this.onclose?.();for(let n of e.values())n(t)}_onerror(e){this.onerror?.(e)}_onnotification(e){let t=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;t!==void 0&&Promise.resolve().then(()=>t(e)).catch(e=>this._onerror(Error(`Uncaught error in notification handler: ${e}`)))}_onrequest(e,t){let n=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,r=this._transport,i=e.params?._meta?.[bo]?.taskId;if(n===void 0){let t={jsonrpc:`2.0`,id:e.id,error:{code:W.MethodNotFound,message:`Method not found`}};i&&this._taskMessageQueue?this._enqueueTaskMessage(i,{type:`error`,message:t,timestamp:Date.now()},r?.sessionId).catch(e=>this._onerror(Error(`Failed to enqueue error response: ${e}`))):r?.send(t).catch(e=>this._onerror(Error(`Failed to send an error response: ${e}`)));return}let a=new AbortController;this._requestHandlerAbortControllers.set(e.id,a);let o=Do(e.params)?e.params.task:void 0,s=this._taskStore?this.requestTaskStore(e,r?.sessionId):void 0,c={signal:a.signal,sessionId:r?.sessionId,_meta:e.params?._meta,sendNotification:async t=>{if(a.signal.aborted)return;let n={relatedRequestId:e.id};i&&(n.relatedTask={taskId:i}),await this.notification(t,n)},sendRequest:async(t,n,r)=>{if(a.signal.aborted)throw new G(W.ConnectionClosed,`Request was cancelled`);let o={...r,relatedRequestId:e.id};i&&!o.relatedTask&&(o.relatedTask={taskId:i});let c=o.relatedTask?.taskId??i;return c&&s&&await s.updateTaskStatus(c,`input_required`),await this.request(t,n,o)},authInfo:t?.authInfo,requestId:e.id,requestInfo:t?.requestInfo,taskId:i,taskStore:s,taskRequestedTtl:o?.ttl,closeSSEStream:t?.closeSSEStream,closeStandaloneSSEStream:t?.closeStandaloneSSEStream};Promise.resolve().then(()=>{o&&this.assertTaskHandlerCapability(e.method)}).then(()=>n(e,c)).then(async t=>{if(a.signal.aborted)return;let n={result:t,jsonrpc:`2.0`,id:e.id};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:`response`,message:n,timestamp:Date.now()},r?.sessionId):await r?.send(n)},async t=>{if(a.signal.aborted)return;let n={jsonrpc:`2.0`,id:e.id,error:{code:Number.isSafeInteger(t.code)?t.code:W.InternalError,message:t.message??`Internal error`,...t.data!==void 0&&{data:t.data}}};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:`error`,message:n,timestamp:Date.now()},r?.sessionId):await r?.send(n)}).catch(e=>this._onerror(Error(`Failed to send response: ${e}`))).finally(()=>{this._requestHandlerAbortControllers.delete(e.id)})}_onprogress(e){let{progressToken:t,...n}=e.params,r=Number(t),i=this._progressHandlers.get(r);if(!i){this._onerror(Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let a=this._responseHandlers.get(r),o=this._timeoutInfo.get(r);if(o&&a&&o.resetTimeoutOnProgress)try{this._resetTimeout(r)}catch(e){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),a(e);return}i(n)}_onresponse(e){let t=Number(e.id),n=this._requestResolvers.get(t);if(n){this._requestResolvers.delete(t),Po(e)?n(e):n(new G(e.error.code,e.error.message,e.error.data));return}let r=this._responseHandlers.get(t);if(r===void 0){this._onerror(Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(t),this._cleanupTimeout(t);let i=!1;if(Po(e)&&e.result&&typeof e.result==`object`){let n=e.result;if(n.task&&typeof n.task==`object`){let e=n.task;typeof e.taskId==`string`&&(i=!0,this._taskProgressTokens.set(e.taskId,t))}}i||this._progressHandlers.delete(t),Po(e)?r(e):r(G.fromError(e.error.code,e.error.message,e.error.data))}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(e,t,n){let{task:r}=n??{};if(!r){try{yield{type:`result`,result:await this.request(e,t,n)}}catch(e){yield{type:`error`,error:e instanceof G?e:new G(W.InternalError,String(e))}}return}let i;try{let r=await this.request(e,cs,n);if(r.task)i=r.task.taskId,yield{type:`taskCreated`,task:r.task};else throw new G(W.InternalError,`Task creation did not return a task`);for(;;){let e=await this.getTask({taskId:i},n);if(yield{type:`taskStatus`,task:e},Jc(e.status)){e.status===`completed`?yield{type:`result`,result:await this.getTaskResult({taskId:i},t,n)}:e.status===`failed`?yield{type:`error`,error:new G(W.InternalError,`Task ${i} failed`)}:e.status===`cancelled`&&(yield{type:`error`,error:new G(W.InternalError,`Task ${i} was cancelled`)});return}if(e.status===`input_required`){yield{type:`result`,result:await this.getTaskResult({taskId:i},t,n)};return}let r=e.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(e=>setTimeout(e,r)),n?.signal?.throwIfAborted()}}catch(e){yield{type:`error`,error:e instanceof G?e:new G(W.InternalError,String(e))}}}request(e,t,n){let{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a,task:o,relatedTask:s}=n??{};return new Promise((c,l)=>{let u=e=>{l(e)};if(!this._transport){u(Error(`Not connected`));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(e.method),o&&this.assertTaskCapability(e.method)}catch(e){u(e);return}n?.signal?.throwIfAborted();let d=this._requestMessageId++,f={...e,jsonrpc:`2.0`,id:d};n?.onprogress&&(this._progressHandlers.set(d,n.onprogress),f.params={...e.params,_meta:{...e.params?._meta||{},progressToken:d}}),o&&(f.params={...f.params,task:o}),s&&(f.params={...f.params,_meta:{...f.params?._meta||{},[bo]:s}});let p=e=>{this._responseHandlers.delete(d),this._progressHandlers.delete(d),this._cleanupTimeout(d),this._transport?.send({jsonrpc:`2.0`,method:`notifications/cancelled`,params:{requestId:d,reason:String(e)}},{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a}).catch(e=>this._onerror(Error(`Failed to send cancellation: ${e}`))),l(e instanceof G?e:new G(W.RequestTimeout,String(e)))};this._responseHandlers.set(d,e=>{if(!n?.signal?.aborted){if(e instanceof Error)return l(e);try{let n=Li(t,e.result);n.success?c(n.data):l(n.error)}catch(e){l(e)}}}),n?.signal?.addEventListener(`abort`,()=>{p(n?.signal?.reason)});let m=n?.timeout??6e4;this._setupTimeout(d,m,n?.maxTotalTimeout,()=>p(G.fromError(W.RequestTimeout,`Request timed out`,{timeout:m})),n?.resetTimeoutOnProgress??!1);let ee=s?.taskId;ee?(this._requestResolvers.set(d,e=>{let t=this._responseHandlers.get(d);t?t(e):this._onerror(Error(`Response handler missing for side-channeled request ${d}`))}),this._enqueueTaskMessage(ee,{type:`request`,message:f,timestamp:Date.now()}).catch(e=>{this._cleanupTimeout(d),l(e)})):this._transport.send(f,{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a}).catch(e=>{this._cleanupTimeout(d),l(e)})})}async getTask(e,t){return this.request({method:`tasks/get`,params:e},fs,t)}async getTaskResult(e,t,n){return this.request({method:`tasks/result`,params:e},t,n)}async listTasks(e,t){return this.request({method:`tasks/list`,params:e},hs,t)}async cancelTask(e,t){return this.request({method:`tasks/cancel`,params:e},_s,t)}async notification(e,t){if(!this._transport)throw Error(`Not connected`);this.assertNotificationCapability(e.method);let n=t?.relatedTask?.taskId;if(n){let r={...e,jsonrpc:`2.0`,params:{...e.params,_meta:{...e.params?._meta||{},[bo]:t.relatedTask}}};await this._enqueueTaskMessage(n,{type:`notification`,message:r,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!t?.relatedRequestId&&!t?.relatedTask){if(this._pendingDebouncedNotifications.has(e.method))return;this._pendingDebouncedNotifications.add(e.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(e.method),!this._transport)return;let n={...e,jsonrpc:`2.0`};t?.relatedTask&&(n={...n,params:{...n.params,_meta:{...n.params?._meta||{},[bo]:t.relatedTask}}}),this._transport?.send(n,t).catch(e=>this._onerror(e))});return}let r={...e,jsonrpc:`2.0`};t?.relatedTask&&(r={...r,params:{...r.params,_meta:{...r.params?._meta||{},[bo]:t.relatedTask}}}),await this._transport.send(r,t)}setRequestHandler(e,t){let n=Yc(e);this.assertRequestHandlerCapability(n),this._requestHandlers.set(n,(n,r)=>{let i=Xc(e,n);return Promise.resolve(t(i,r))})}removeRequestHandler(e){this._requestHandlers.delete(e)}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,t){let n=Yc(e);this._notificationHandlers.set(n,n=>{let r=Xc(e,n);return Promise.resolve(t(r))})}removeNotificationHandler(e){this._notificationHandlers.delete(e)}_cleanupTaskProgressHandler(e){let t=this._taskProgressTokens.get(e);t!==void 0&&(this._progressHandlers.delete(t),this._taskProgressTokens.delete(e))}async _enqueueTaskMessage(e,t,n){if(!this._taskStore||!this._taskMessageQueue)throw Error(`Cannot enqueue task message: taskStore and taskMessageQueue are not configured`);let r=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,t,n,r)}async _clearTaskQueue(e,t){if(this._taskMessageQueue){let n=await this._taskMessageQueue.dequeueAll(e,t);for(let t of n)if(t.type===`request`&&Ao(t.message)){let n=t.message.id,r=this._requestResolvers.get(n);r?(r(new G(W.InternalError,`Task cancelled or completed`)),this._requestResolvers.delete(n)):this._onerror(Error(`Resolver missing for request ${n} during task ${e} cleanup`))}}}async _waitForTaskUpdate(e,t){let n=this._options?.defaultTaskPollInterval??1e3;try{let t=await this._taskStore?.getTask(e);t?.pollInterval&&(n=t.pollInterval)}catch{}return new Promise((e,r)=>{if(t.aborted){r(new G(W.InvalidRequest,`Request cancelled`));return}let i=setTimeout(e,n);t.addEventListener(`abort`,()=>{clearTimeout(i),r(new G(W.InvalidRequest,`Request cancelled`))},{once:!0})})}requestTaskStore(e,t){let n=this._taskStore;if(!n)throw Error(`No task store configured`);return{createTask:async r=>{if(!e)throw Error(`No request provided`);return await n.createTask(r,e.id,{method:e.method,params:e.params},t)},getTask:async e=>{let r=await n.getTask(e,t);if(!r)throw new G(W.InvalidParams,`Failed to retrieve task: Task not found`);return r},storeTaskResult:async(e,r,i)=>{await n.storeTaskResult(e,r,i,t);let a=await n.getTask(e,t);if(a){let t=us.parse({method:`notifications/tasks/status`,params:a});await this.notification(t),Jc(a.status)&&this._cleanupTaskProgressHandler(e)}},getTaskResult:e=>n.getTaskResult(e,t),updateTaskStatus:async(e,r,i)=>{let a=await n.getTask(e,t);if(!a)throw new G(W.InvalidParams,`Task "${e}" not found - it may have been cleaned up`);if(Jc(a.status))throw new G(W.InvalidParams,`Cannot update task "${e}" from terminal status "${a.status}" to "${r}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await n.updateTaskStatus(e,r,i,t);let o=await n.getTask(e,t);if(o){let t=us.parse({method:`notifications/tasks/status`,params:o});await this.notification(t),Jc(o.status)&&this._cleanupTaskProgressHandler(e)}},listTasks:e=>n.listTasks(e,t)}}},Qc=`2026-01-26`,$c=class{eventTarget;eventSource;messageListener;constructor(e=window.parent,t){this.eventTarget=e,this.eventSource=t,this.messageListener=e=>{if(t&&e.source!==this.eventSource){console.debug(`Ignoring message from unknown source`,e);return}let n=Lo.safeParse(e.data);n.success?(console.debug(`Parsed message`,n.data),this.onmessage?.(n.data)):e.data?.jsonrpc===`2.0`?(console.error(`Failed to parse message`,n.error.message,e),this.onerror?.(Error(`Invalid JSON-RPC message received: `+n.error.message))):console.debug(`Ignoring non-JSON-RPC message`,n.error.message,e)}}async start(){window.addEventListener(`message`,this.messageListener)}async send(e,t){e.method!==`ui/notifications/tool-input-partial`&&console.debug(`Sending message`,e),this.eventTarget.postMessage(e,`*`)}async close(){window.removeEventListener(`message`,this.messageListener),this.onclose?.()}onclose;onerror;onmessage;sessionId;setProtocolVersion},el=N([I(`light`),I(`dark`)]).describe(`Color theme preference for the host environment.`),tl=N([I(`inline`),I(`fullscreen`),I(`pip`)]).describe(`Display mode for UI presentation.`),nl=P(N([I(`--color-background-primary`),I(`--color-background-secondary`),I(`--color-background-tertiary`),I(`--color-background-inverse`),I(`--color-background-ghost`),I(`--color-background-info`),I(`--color-background-danger`),I(`--color-background-success`),I(`--color-background-warning`),I(`--color-background-disabled`),I(`--color-text-primary`),I(`--color-text-secondary`),I(`--color-text-tertiary`),I(`--color-text-inverse`),I(`--color-text-ghost`),I(`--color-text-info`),I(`--color-text-danger`),I(`--color-text-success`),I(`--color-text-warning`),I(`--color-text-disabled`),I(`--color-border-primary`),I(`--color-border-secondary`),I(`--color-border-tertiary`),I(`--color-border-inverse`),I(`--color-border-ghost`),I(`--color-border-info`),I(`--color-border-danger`),I(`--color-border-success`),I(`--color-border-warning`),I(`--color-border-disabled`),I(`--color-ring-primary`),I(`--color-ring-secondary`),I(`--color-ring-inverse`),I(`--color-ring-info`),I(`--color-ring-danger`),I(`--color-ring-success`),I(`--color-ring-warning`),I(`--font-sans`),I(`--font-mono`),I(`--font-weight-normal`),I(`--font-weight-medium`),I(`--font-weight-semibold`),I(`--font-weight-bold`),I(`--font-text-xs-size`),I(`--font-text-sm-size`),I(`--font-text-md-size`),I(`--font-text-lg-size`),I(`--font-heading-xs-size`),I(`--font-heading-sm-size`),I(`--font-heading-md-size`),I(`--font-heading-lg-size`),I(`--font-heading-xl-size`),I(`--font-heading-2xl-size`),I(`--font-heading-3xl-size`),I(`--font-text-xs-line-height`),I(`--font-text-sm-line-height`),I(`--font-text-md-line-height`),I(`--font-text-lg-line-height`),I(`--font-heading-xs-line-height`),I(`--font-heading-sm-line-height`),I(`--font-heading-md-line-height`),I(`--font-heading-lg-line-height`),I(`--font-heading-xl-line-height`),I(`--font-heading-2xl-line-height`),I(`--font-heading-3xl-line-height`),I(`--border-radius-xs`),I(`--border-radius-sm`),I(`--border-radius-md`),I(`--border-radius-lg`),I(`--border-radius-xl`),I(`--border-radius-full`),I(`--border-width-regular`),I(`--shadow-hairline`),I(`--shadow-sm`),I(`--shadow-md`),I(`--shadow-lg`)]).describe(`CSS variable keys available to MCP apps for theming.`).describe(`Style variables for theming MCP apps.
|
|
177
|
+
|
|
178
|
+
Individual style keys are optional - hosts may provide any subset of these values.
|
|
179
|
+
Values are strings containing CSS values (colors, sizes, font stacks, etc.).
|
|
180
|
+
|
|
181
|
+
Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
|
|
182
|
+
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),N([T(),Na()]).describe(`Style variables for theming MCP apps.
|
|
183
|
+
|
|
184
|
+
Individual style keys are optional - hosts may provide any subset of these values.
|
|
185
|
+
Values are strings containing CSS values (colors, sizes, font stacks, etc.).
|
|
186
|
+
|
|
187
|
+
Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
|
|
188
|
+
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`)).describe(`Style variables for theming MCP apps.
|
|
189
|
+
|
|
190
|
+
Individual style keys are optional - hosts may provide any subset of these values.
|
|
191
|
+
Values are strings containing CSS values (colors, sizes, font stacks, etc.).
|
|
192
|
+
|
|
193
|
+
Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
|
|
194
|
+
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`);j({method:I(`ui/open-link`),params:j({url:T().describe(`URL to open in the host's browser`)})});var rl=j({isError:O().optional().describe(`True if the host failed to open the URL (e.g., due to security policy).`)}).passthrough(),il=j({isError:O().optional().describe(`True if the download failed (e.g., user cancelled or host denied).`)}).passthrough(),al=j({isError:O().optional().describe(`True if the host rejected or failed to deliver the message.`)}).passthrough();j({method:I(`ui/notifications/sandbox-proxy-ready`),params:j({})});var ol=j({connectDomains:A(T()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket).
|
|
195
|
+
|
|
196
|
+
- Maps to CSP \`connect-src\` directive
|
|
197
|
+
- Empty or omitted → no network connections (secure default)`),resourceDomains:A(T()).optional().describe("Origins for static resources (images, scripts, stylesheets, fonts, media).\n\n- Maps to CSP `img-src`, `script-src`, `style-src`, `font-src`, `media-src` directives\n- Wildcard subdomains supported: `https://*.example.com`\n- Empty or omitted → no network resources (secure default)"),frameDomains:A(T()).optional().describe("Origins for nested iframes.\n\n- Maps to CSP `frame-src` directive\n- Empty or omitted → no nested iframes allowed (`frame-src 'none'`)"),baseUriDomains:A(T()).optional().describe("Allowed base URIs for the document.\n\n- Maps to CSP `base-uri` directive\n- Empty or omitted → only same origin allowed (`base-uri 'self'`)")}),sl=j({camera:j({}).optional().describe(`Request camera access.
|
|
198
|
+
|
|
199
|
+
Maps to Permission Policy \`camera\` feature.`),microphone:j({}).optional().describe(`Request microphone access.
|
|
200
|
+
|
|
201
|
+
Maps to Permission Policy \`microphone\` feature.`),geolocation:j({}).optional().describe(`Request geolocation access.
|
|
202
|
+
|
|
203
|
+
Maps to Permission Policy \`geolocation\` feature.`),clipboardWrite:j({}).optional().describe(`Request clipboard write access.
|
|
204
|
+
|
|
205
|
+
Maps to Permission Policy \`clipboard-write\` feature.`)});j({method:I(`ui/notifications/size-changed`),params:j({width:D().optional().describe(`New width in pixels.`),height:D().optional().describe(`New height in pixels.`)})});var cl=j({method:I(`ui/notifications/tool-input`),params:j({arguments:P(T(),k().describe(`Complete tool call arguments as key-value pairs.`)).optional().describe(`Complete tool call arguments as key-value pairs.`)})}),ll=j({method:I(`ui/notifications/tool-input-partial`),params:j({arguments:P(T(),k().describe(`Partial tool call arguments (incomplete, may change).`)).optional().describe(`Partial tool call arguments (incomplete, may change).`)})}),ul=j({method:I(`ui/notifications/tool-cancelled`),params:j({reason:T().optional().describe(`Optional reason for the cancellation (e.g., "user action", "timeout").`)})}),dl=j({fonts:T().optional()}),fl=j({variables:nl.optional().describe(`CSS variables for theming the app.`),css:dl.optional().describe(`CSS blocks that apps can inject.`)}),pl=j({method:I(`ui/resource-teardown`),params:j({})});P(T(),k());var ml=j({text:j({}).optional().describe(`Host supports text content blocks.`),image:j({}).optional().describe(`Host supports image content blocks.`),audio:j({}).optional().describe(`Host supports audio content blocks.`),resource:j({}).optional().describe(`Host supports resource content blocks.`),resourceLink:j({}).optional().describe(`Host supports resource link content blocks.`),structuredContent:j({}).optional().describe(`Host supports structured content.`)}),hl=j({experimental:j({}).optional().describe(`Experimental features (structure TBD).`),openLinks:j({}).optional().describe(`Host supports opening external URLs.`),downloadFile:j({}).optional().describe(`Host supports file downloads via ui/download-file.`),serverTools:j({listChanged:O().optional().describe(`Host supports tools/list_changed notifications.`)}).optional().describe(`Host can proxy tool calls to the MCP server.`),serverResources:j({listChanged:O().optional().describe(`Host supports resources/list_changed notifications.`)}).optional().describe(`Host can proxy resource reads to the MCP server.`),logging:j({}).optional().describe(`Host accepts log messages.`),sandbox:j({permissions:sl.optional().describe(`Permissions granted by the host (camera, microphone, geolocation).`),csp:ol.optional().describe(`CSP domains approved by the host.`)}).optional().describe(`Sandbox configuration applied by the host.`),updateModelContext:ml.optional().describe(`Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns.`),message:ml.optional().describe(`Host supports receiving content messages (ui/message) from the view.`)}),gl=j({experimental:j({}).optional().describe(`Experimental features (structure TBD).`),tools:j({listChanged:O().optional().describe(`App supports tools/list_changed notifications.`)}).optional().describe(`App exposes MCP-style tools that the host can call.`),availableDisplayModes:A(tl).optional().describe(`Display modes the app supports.`)});j({method:I(`ui/notifications/initialized`),params:j({}).optional()}),j({csp:ol.optional().describe(`Content Security Policy configuration for UI resources.`),permissions:sl.optional().describe(`Sandbox permissions requested by the UI resource.`),domain:T().optional().describe(`Dedicated origin for view sandbox.
|
|
206
|
+
|
|
207
|
+
Useful when views need stable, dedicated origins for OAuth callbacks, CORS policies, or API key allowlists.
|
|
208
|
+
|
|
209
|
+
**Host-dependent:** The format and validation rules for this field are determined by each host. Servers MUST consult host-specific documentation for the expected domain format. Common patterns include:
|
|
210
|
+
- Hash-based subdomains (e.g., \`{hash}.claudemcpcontent.com\`)
|
|
211
|
+
- URL-derived subdomains (e.g., \`www-example-com.oaiusercontent.com\`)
|
|
212
|
+
|
|
213
|
+
If omitted, host uses default sandbox origin (typically per-conversation).`),prefersBorder:O().optional().describe(`Visual boundary preference - true if view prefers a visible border.
|
|
214
|
+
|
|
215
|
+
Boolean requesting whether a visible border and background is provided by the host. Specifying an explicit value for this is recommended because hosts' defaults may vary.
|
|
216
|
+
|
|
217
|
+
- \`true\`: request visible border + background
|
|
218
|
+
- \`false\`: request no visible border + background
|
|
219
|
+
- omitted: host decides border`)}),j({method:I(`ui/request-display-mode`),params:j({mode:tl.describe(`The display mode being requested.`)})});var _l=j({mode:tl.describe(`The display mode that was actually set. May differ from requested if not supported.`)}).passthrough(),vl=N([I(`model`),I(`app`)]).describe(`Tool visibility scope - who can access the tool.`);j({resourceUri:T().optional(),visibility:A(vl).optional().describe(`Who can access this tool. Default: ["model", "app"]
|
|
220
|
+
- "model": Tool visible to and callable by the agent
|
|
221
|
+
- "app": Tool callable by the app from this server only`)}),j({mimeTypes:A(T()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')}),j({method:I(`ui/download-file`),params:j({contents:A(N([Zs,Qs])).describe(`Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.`)})}),j({method:I(`ui/message`),params:j({role:I(`user`).describe(`Message role, currently only "user" is supported.`),content:A($s).describe(`Message content blocks (text, image, etc.).`)})}),j({method:I(`ui/notifications/sandbox-resource-ready`),params:j({html:T().describe(`HTML content to load into the inner iframe.`),sandbox:T().optional().describe(`Optional override for the inner iframe's sandbox attribute.`),csp:ol.optional().describe(`CSP configuration from resource metadata.`),permissions:sl.optional().describe(`Sandbox permissions from resource metadata.`)})});var yl=j({method:I(`ui/notifications/tool-result`),params:cc.describe(`Standard MCP tool execution result.`)}),bl=j({toolInfo:j({id:Oo.optional().describe(`JSON-RPC id of the tools/call request.`),tool:ac.describe(`Tool definition including name, inputSchema, etc.`)}).optional().describe(`Metadata of the tool call that instantiated this App.`),theme:el.optional().describe(`Current color theme preference.`),styles:fl.optional().describe(`Style configuration for theming the app.`),displayMode:tl.optional().describe(`How the UI is currently displayed.`),availableDisplayModes:A(tl).optional().describe(`Display modes the host supports.`),containerDimensions:N([j({height:D().describe(`Fixed container height in pixels.`)}),j({maxHeight:N([D(),Na()]).optional().describe(`Maximum container height in pixels.`)})]).and(N([j({width:D().describe(`Fixed container width in pixels.`)}),j({maxWidth:N([D(),Na()]).optional().describe(`Maximum container width in pixels.`)})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
|
|
222
|
+
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:T().optional().describe(`User's language and region preference in BCP 47 format.`),timeZone:T().optional().describe(`User's timezone in IANA format.`),userAgent:T().optional().describe(`Host application identifier.`),platform:N([I(`web`),I(`desktop`),I(`mobile`)]).optional().describe(`Platform type for responsive design decisions.`),deviceCapabilities:j({touch:O().optional().describe(`Whether the device supports touch input.`),hover:O().optional().describe(`Whether the device supports hover interactions.`)}).optional().describe(`Device input capabilities.`),safeAreaInsets:j({top:D().describe(`Top safe area inset in pixels.`),right:D().describe(`Right safe area inset in pixels.`),bottom:D().describe(`Bottom safe area inset in pixels.`),left:D().describe(`Left safe area inset in pixels.`)}).optional().describe(`Mobile safe area boundaries in pixels.`)}).passthrough(),xl=j({method:I(`ui/notifications/host-context-changed`),params:bl.describe(`Partial context update containing only changed fields.`)});j({method:I(`ui/update-model-context`),params:j({content:A($s).optional().describe(`Context content blocks (text, image, etc.).`),structuredContent:P(T(),k().describe(`Structured content for machine-readable context data.`)).optional().describe(`Structured content for machine-readable context data.`)})}),j({method:I(`ui/initialize`),params:j({appInfo:Uo.describe(`App identification (name and version).`),appCapabilities:gl.describe(`Features and capabilities this app provides.`),protocolVersion:T().describe(`Protocol version this app supports.`)})});var Sl=j({protocolVersion:T().describe(`Negotiated protocol version string (e.g., "2025-11-21").`),hostInfo:Uo.describe(`Host application identification and version.`),hostCapabilities:hl.describe(`Features and capabilities provided by the host.`),hostContext:bl.describe(`Rich context about the host environment.`)}).passthrough(),Cl=class extends Zc{_appInfo;_capabilities;options;_hostCapabilities;_hostInfo;_hostContext;constructor(e,t={},n={autoResize:!0}){super(n),this._appInfo=e,this._capabilities=t,this.options=n,this.setRequestHandler($o,e=>(console.log(`Received ping:`,e.params),{})),this.onhostcontextchanged=()=>{}}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}set ontoolinput(e){this.setNotificationHandler(cl,t=>e(t.params))}set ontoolinputpartial(e){this.setNotificationHandler(ll,t=>e(t.params))}set ontoolresult(e){this.setNotificationHandler(yl,t=>e(t.params))}set ontoolcancelled(e){this.setNotificationHandler(ul,t=>e(t.params))}set onhostcontextchanged(e){this.setNotificationHandler(xl,t=>{this._hostContext={...this._hostContext,...t.params},e(t.params)})}set onteardown(e){this.setRequestHandler(pl,(t,n)=>e(t.params,n))}set oncalltool(e){this.setRequestHandler(uc,(t,n)=>e(t.params,n))}set onlisttools(e){this.setRequestHandler(oc,(t,n)=>e(t.params,n))}assertCapabilityForMethod(e){}assertRequestHandlerCapability(e){switch(e){case`tools/call`:case`tools/list`:if(!this._capabilities.tools)throw Error(`Client does not support tool capability (required for ${e})`);return;case`ping`:case`ui/resource-teardown`:return;default:throw Error(`No handler for method ${e} registered`)}}assertNotificationCapability(e){}assertTaskCapability(e){throw Error(`Tasks are not supported in MCP Apps`)}assertTaskHandlerCapability(e){throw Error(`Task handlers are not supported in MCP Apps`)}async callServerTool(e,t){if(typeof e==`string`)throw Error(`callServerTool() expects an object as its first argument, but received a string ("${e}"). Did you mean: callServerTool({ name: "${e}", arguments: { ... } })?`);return await this.request({method:`tools/call`,params:e},cc,t)}async readServerResource(e,t){return await this.request({method:`resources/read`,params:e},Ns,t)}async listServerResources(e,t){return await this.request({method:`resources/list`,params:e},Ds,t)}sendMessage(e,t){return this.request({method:`ui/message`,params:e},al,t)}sendLog(e){return this.notification({method:`notifications/message`,params:e})}updateModelContext(e,t){return this.request({method:`ui/update-model-context`,params:e},Ro,t)}openLink(e,t){return this.request({method:`ui/open-link`,params:e},rl,t)}sendOpenLink=this.openLink;downloadFile(e,t){return this.request({method:`ui/download-file`,params:e},il,t)}requestDisplayMode(e,t){return this.request({method:`ui/request-display-mode`,params:e},_l,t)}sendSizeChanged(e){return this.notification({method:`ui/notifications/size-changed`,params:e})}setupSizeChangedNotifications(){let e=!1,t=0,n=0,r=()=>{e||(e=!0,requestAnimationFrame(()=>{e=!1;let r=document.documentElement,i=r.style.width,a=r.style.height;r.style.width=`fit-content`,r.style.height=`max-content`;let o=r.getBoundingClientRect();r.style.width=i,r.style.height=a;let s=window.innerWidth-r.clientWidth,c=Math.ceil(o.width+s),l=Math.ceil(o.height);(c!==t||l!==n)&&(t=c,n=l,this.sendSizeChanged({width:c,height:l}))}))};r();let i=new ResizeObserver(r);return i.observe(document.documentElement),i.observe(document.body),()=>i.disconnect()}async connect(e=new $c(window.parent,window.parent),t){if(this.transport)throw Error(`App is already connected. Call close() before connecting again.`);await super.connect(e);try{let e=await this.request({method:`ui/initialize`,params:{appCapabilities:this._capabilities,appInfo:this._appInfo,protocolVersion:Qc}},Sl,t);if(e===void 0)throw Error(`Server sent invalid initialize result: ${e}`);this._hostCapabilities=e.hostCapabilities,this._hostInfo=e.hostInfo,this._hostContext=e.hostContext,await this.notification({method:`ui/notifications/initialized`}),this.options?.autoResize&&this.setupSizeChangedNotifications()}catch(e){throw this.close(),e}}},wl=`http://www.w3.org/2000/svg`,K=26,Tl=4.5,El=30,Dl=400,Ol=8,kl=22,Al={entry:`#6b6b7b`,process_flow:`#c4a35a`,skillful_means:`#d4a843`,non_dual_recognition:`#4a9a5c`,meta_cognitive:`#5b8def`,meditation:`#7ecfc0`},jl={entry:`Entry`,process_flow:`Process`,skillful_means:`Skillful Means`,non_dual_recognition:`Non-Dual`,meta_cognitive:`Meta-Cognitive`,meditation:`Meditation`},Ml={begin:`entry`,open:`process_flow`,engage:`process_flow`,express:`process_flow`,upaya:`skillful_means`,expedient:`skillful_means`,direct:`skillful_means`,gradual:`skillful_means`,sudden:`skillful_means`,recognize:`non_dual_recognition`,transform:`non_dual_recognition`,integrate:`non_dual_recognition`,transcend:`non_dual_recognition`,embody:`non_dual_recognition`,examine:`meta_cognitive`,reflect:`meta_cognitive`,verify:`meta_cognitive`,refine:`meta_cognitive`,complete:`meta_cognitive`,meditate:`meditation`},q=[],Nl=!1,J=null,Pl=-1,Y=-1,Fl=null,Il=null,Ll=``,X=0,Z=null;function Rl(e){return Al[e]??`#6b6b7b`}function zl(e){return jl[e]??e}function Bl(e){return Ml[e]??`entry`}function Q(e){let t=document.getElementById(e);if(!t)throw Error(`Element #${e} not found`);return t}function $(e,t){let n=document.createElementNS(wl,e);if(t)for(let e in t){let r=t[e];r!=null&&n.setAttribute(e,String(r))}return n}function Vl(){let e=q.length-X;if(!e)return[];let t=X>0?El+kl:El,n=Dl-El;if(e===1)return[(t+n)/2];let r=(n-t)/(e-1);return Array.from({length:e},(e,n)=>t+n*r)}function Hl(e){let t=Vl(),n=q.slice(X);Q(`gc`).innerHTML=``,X>0&&t.length>0&&Q(`gc`).appendChild($(`path`,{d:`M${El} ${K} L${t[0]} ${K}`,fill:`none`,stroke:`var(--conn)`,"stroke-width":.4,"stroke-dasharray":`3 3`,opacity:.15}));for(let r=0;r<n.length-1;r++){let i=t[r],a=t[r+1],o=(i+a)/2,s=K-2-Math.random()*1.2,c=Nl?Rl(n[r].dom):`var(--conn)`,l=Nl?1.4:.6,u=Nl?.45:.18,d={d:`M${i} ${K} Q${o} ${s} ${a} ${K}`,fill:`none`,stroke:c,"stroke-width":l,opacity:u};if(r===e-1&&!Nl){let e=Math.hypot(a-i,K-s)*1.08;d[`stroke-dasharray`]=e,d[`stroke-dashoffset`]=e,d.style=`--len:${e};animation:draw .55s ease-out forwards`}Q(`gc`).appendChild($(`path`,d))}return t}function Ul(e){let t=Q(`gn`).children;for(let n=0;n<e.length&&n<t.length;n++)t[n].setAttribute(`transform`,`translate(${e[n]},${K})`);J&&e.length&&J.setAttribute(`cx`,String(e[e.length-1]))}function Wl(e,t=!0){let{tag:n,dom:r}=e,i=Rl(r),a=n===`meditate`,o=Q(`gn`).querySelector(`.now, .hol`);if(o){o.className.baseVal=`sn past`;let e=o.querySelector(`circle:last-of-type`);e&&(e.style.animation=`none`,e.setAttribute(`opacity`,`.35`))}if(q.push({tag:n,dom:r,sn:e.sn,st:e.st,med:a,text:e.text||``}),q.length-X>Ol){let e=Q(`gn`).firstChild;e&&e.remove(),X++,Y>=0&&Y<X&&(Y=-1,ql()),Jl()}let s=Hl(t?q.length-X-1:-1);Ul(s);let c=s[s.length-1]??Dl/2;J&&J.remove(),J=$(`circle`,{cx:c,cy:K,r:20,fill:i,opacity:t?.04:0}),Q(`gg`).appendChild(J);let l=t?a?`sn hol`:`sn now`:`sn end`,u=$(`g`,{transform:`translate(${c},${K})`,class:l});u.dataset.i=String(q.length-1);let d=a?$(`circle`,{cx:0,cy:0,r:Tl,fill:`none`,stroke:i,"stroke-width":1.2}):$(`circle`,{cx:0,cy:0,r:Tl,fill:i});if(t||d.setAttribute(`opacity`,`.88`),u.appendChild($(`circle`,{cx:0,cy:0,r:Tl*3,fill:`transparent`})),u.appendChild(d),u.addEventListener(`mouseenter`,()=>Gl(+(u.dataset.i??`0`))),u.addEventListener(`mouseleave`,()=>Gl(Y>=0?Y:q.length-1)),u.addEventListener(`click`,e=>{e.stopPropagation(),Kl(+(u.dataset.i??`0`))}),Q(`gn`).appendChild(u),t){let e=$(`g`,{transform:`translate(${c},${K})`});e.appendChild($(`circle`,{cx:0,cy:0,r:Tl,fill:`none`,stroke:i,"stroke-width":.6,class:`rp`})),Q(`ge`).appendChild(e),setTimeout(()=>e.remove(),1e3)}Q(`void`).style.opacity=`0`,Q(`tr`).setAttribute(`aria-label`,`Journey: `+q.map(e=>e.tag).join(` → `)),Y=-1,ql(),Gl(q.length-1),Q(`ct`).classList.add(`on`),e.status===`WISDOM_READY`&&(Nl=!0,setTimeout(Yl,600))}function Gl(e){if(e<0||e>=q.length)return;Il&&=(clearTimeout(Il),null);let t=q[e],n=Rl(t.dom);if(e===Pl){Q(`ch`).style.color=n,Q(`cd`).style.color=n,Q(`ci`).style.borderLeftColor=n+`28`;return}let r=Q(`ci`);r.style.opacity=`0`,Il=setTimeout(()=>{Q(`ch`).textContent=t.tag,Q(`ch`).style.color=n,Q(`cd`).textContent=zl(t.dom),Q(`cd`).style.color=n,Q(`cn`).textContent=`step ${t.sn}`,r.style.borderLeftColor=n+`28`;let i=Q(`cx`);i.textContent=t.text,i.className=t.med?`med-text`:``,r.style.opacity=`1`,Q(`ct`).scrollTop=0,Pl=e},160)}function Kl(e){Y===e?(Y=-1,Gl(q.length-1)):(Y=e,Gl(e)),ql()}function ql(){if(Fl&&=(Fl.remove(),null),Y<0||Y>=q.length)return;let e=q[Y],t=Rl(e.dom);Fl=$(`circle`,{cx:0,cy:0,r:Tl+3.5,fill:`none`,stroke:t,"stroke-width":.5,opacity:.4,style:`pointer-events:none`});let n=Y-X,r=n>=0?Q(`gn`).children[n]:void 0;r&&r.appendChild(Fl)}function Jl(){if(X===0){Z&&=(Z.remove(),null);return}Z||(Z=$(`g`),Q(`tr`).insertBefore(Z,Q(`gc`))),Z.innerHTML=``;for(let e of[{x:10,r:1.5,o:.1},{x:17,r:1.5,o:.18},{x:24,r:2,o:.28}])Z.appendChild($(`circle`,{cx:e.x,cy:K,r:e.r,fill:`var(--dim)`,opacity:e.o}));let e=document.createElementNS(wl,`text`);e.setAttribute(`x`,`17`),e.setAttribute(`y`,String(K+12)),e.setAttribute(`text-anchor`,`middle`),e.setAttribute(`font-size`,`7`),e.setAttribute(`fill`,`var(--dim)`),e.setAttribute(`opacity`,`0.35`),e.textContent=`+${X}`,Z.appendChild(e)}function Yl(){Y=-1,Fl&&=(Fl.remove(),null);let e=Q(`gn`).children;for(let t=0;t<e.length;t++){e[t].className.baseVal=`sn end`;let n=e[t].querySelector(`circle:last-of-type`);n&&(n.style.animation=`none`,n.setAttribute(`opacity`,`.88`))}J&&=(J.remove(),null),Hl(-1);let t=[],n=``;for(let e of q)e.dom!==n&&(t.push(zl(e.dom).toLowerCase()),n=e.dom);Q(`jt`).textContent=t.join(` → `),Q(`jt`).classList.add(`on`);let r=$(`defs`),i=$(`linearGradient`,{id:`ag`}),a=[],o=``;for(let e of q)e.dom!==o&&(a.push(e),o=e.dom);a.forEach((e,t)=>{i.appendChild($(`stop`,{offset:`${t/Math.max(a.length-1,1)*100}%`,"stop-color":Rl(e.dom)}))}),r.appendChild(i),Q(`tr`).insertBefore(r,Q(`tr`).firstChild);let s=X>0?El+kl:El,c=$(`rect`,{x:s,y:8,width:Dl-El-s,height:36,fill:`url(#ag)`,rx:18,opacity:0});c.style.animation=`ambient 7s ease-in-out 1s infinite`,Q(`ge`).appendChild(c)}function Xl(e,t){if(!e||q.length>0)return;let n=e.split(` → `);for(let e=0;e<n.length-1;e++){let r=n[e].trim();Wl({tag:r,dom:Bl(r),sn:e+1,st:t,status:`processing`,text:``},!1)}}function Zl(e){if(e.structuredContent&&typeof e.structuredContent==`object`){let t=e.structuredContent;if(t.status)return t}let t=e.content;if(Array.isArray(t)){for(let e of t)if(e&&typeof e==`object`&&e.type===`text`)try{return JSON.parse(e.text)}catch{}}return null}function Ql(e){if(!e||!e.status)return;let t=Ll||e.contemplation||``;Ll=``;let n=e.totalSteps||e.stepNumber||8;if(e.status===`FRAMEWORK_RECEIVED`)Wl({tag:`begin`,dom:`entry`,sn:1,st:n,status:e.status,text:t});else if(e.status===`MEDITATION_COMPLETE`)Xl(e.journey,n),Wl({tag:`meditate`,dom:`meditation`,sn:e.stepNumber,st:n,status:e.status,text:t});else if(e.status===`WISDOM_READY`){Xl(e.finalJourney,n);let r=e.finalStep||`complete`;Wl({tag:r,dom:Bl(r),sn:n,st:n,status:e.status,text:t})}else e.status===`processing`&&(Xl(e.journey,n),Wl({tag:e.currentStep,dom:e.wisdomDomain,sn:e.stepNumber,st:n,status:e.status,text:t}))}document.addEventListener(`click`,()=>{Y>=0&&(Y=-1,ql(),Gl(q.length-1))});var $l=new Cl({name:`Lotus Wisdom Journey`,version:`1.0.0`});if($l.ontoolinput=e=>{let t=e.arguments;t?.content&&(Ll=t.content)},$l.ontoolresult=e=>{let t=Zl(e);t&&Ql(t)},$l.onerror=e=>console.error(`Lotus Wisdom ext-apps error:`,e),window!==window.parent)$l.connect().then(()=>{console.info(`Lotus Wisdom: ext-apps connected`)}).catch(e=>{console.error(`Lotus Wisdom: ext-apps connection failed:`,e)});else{let e=[{status:`FRAMEWORK_RECEIVED`,totalSteps:8,contemplation:`Beginning contemplative journey to design the visual form of lotus wisdom.`,_d:1e3},{status:`processing`,currentStep:`open`,wisdomDomain:`process_flow`,stepNumber:2,totalSteps:8,contemplation:`The core tension: lotus wisdom is a contemplative process that unfolds in time — a journey through domains.`,_d:1800},{status:`processing`,currentStep:`recognize`,wisdomDomain:`non_dual_recognition`,stepNumber:3,totalSteps:8,contemplation:`I recognize the visual should NOT be busy. The UI should breathe.`,_d:2200},{status:`processing`,currentStep:`examine`,wisdomDomain:`meta_cognitive`,stepNumber:4,totalSteps:8,contemplation:`The ext-apps iframe receives tool results via postMessage.`,_d:1600},{status:`MEDITATION_COMPLETE`,stepNumber:5,totalSteps:8,journey:`begin → open → recognize → examine → meditate`,contemplation:`Pausing to let the visual form emerge.`,_d:3200},{status:`processing`,currentStep:`integrate`,wisdomDomain:`non_dual_recognition`,stepNumber:6,totalSteps:8,journey:`begin → open → recognize → examine → meditate → integrate`,contemplation:`The visual form should mirror the journey’s own structure.`,_d:2400},{status:`processing`,currentStep:`refine`,wisdomDomain:`meta_cognitive`,stepNumber:7,totalSteps:8,journey:`begin → open → recognize → examine → meditate → integrate → refine`,contemplation:`Three visual layers: trace, content, completion.`,_d:1800},{status:`WISDOM_READY`,totalSteps:8,finalStep:`express`,finalJourney:`begin → open → recognize → examine → meditate → integrate → refine → express`,contemplation:`The visual design emerges as a living journey trace.`,_d:2e3}],t=1200;for(let n of e){let e=t;setTimeout(()=>Ql(n),e),t+=n._d}}</script>
|
|
223
|
+
</head>
|
|
224
|
+
<body>
|
|
225
|
+
<div id="root">
|
|
226
|
+
<div id="void"><span>☸</span></div>
|
|
227
|
+
<div id="tw">
|
|
228
|
+
<svg id="tr" viewBox="0 0 400 52" preserveAspectRatio="xMidYMid meet"
|
|
229
|
+
role="img" aria-label="Contemplative journey">
|
|
230
|
+
<line x1="0" y1="26" x2="400" y2="26" stroke="var(--hz)" stroke-width=".5"/>
|
|
231
|
+
<g id="gc"></g><g id="gg"></g><g id="gn"></g><g id="ge"></g>
|
|
232
|
+
</svg>
|
|
233
|
+
</div>
|
|
234
|
+
<div id="ct">
|
|
235
|
+
<div id="ci">
|
|
236
|
+
<div class="ch">
|
|
237
|
+
<span id="ch"></span>
|
|
238
|
+
<span id="cd"></span>
|
|
239
|
+
<span id="cn"></span>
|
|
240
|
+
</div>
|
|
241
|
+
<p id="cx"></p>
|
|
242
|
+
</div>
|
|
243
|
+
</div>
|
|
244
|
+
<div id="jt"></div>
|
|
245
|
+
</div>
|
|
246
|
+
</body>
|
|
247
|
+
</html>
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lotus-wisdom-mcp",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.5.0",
|
|
4
|
+
"description": "Contemplative reasoning MCP server — Lotus Sutra wisdom framework with interactive ext-apps journey visualization.",
|
|
5
5
|
"main": "dist/bundle.js",
|
|
6
|
+
"module": "index.ts",
|
|
6
7
|
"type": "module",
|
|
7
8
|
"bin": {
|
|
8
9
|
"lotus-wisdom": "cli.js"
|
|
@@ -14,7 +15,8 @@
|
|
|
14
15
|
"LICENSE"
|
|
15
16
|
],
|
|
16
17
|
"scripts": {
|
|
17
|
-
"build": "
|
|
18
|
+
"build:app": "cd app && bun install --frozen-lockfile && bunx vite build",
|
|
19
|
+
"build": "npm run build:app && tsc && cp app/dist/mcp-app.html dist/journey.html && npx esbuild index.ts --bundle --platform=node --format=esm --outfile=dist/bundle.js",
|
|
18
20
|
"start": "node dist/bundle.js",
|
|
19
21
|
"dev": "tsc && node dist/index.js",
|
|
20
22
|
"prepublishOnly": "npm run build"
|
|
@@ -28,6 +30,8 @@
|
|
|
28
30
|
"model-context-protocol",
|
|
29
31
|
"lotus-sutra",
|
|
30
32
|
"wisdom",
|
|
33
|
+
"contemplative-reasoning",
|
|
34
|
+
"ext-apps",
|
|
31
35
|
"claude",
|
|
32
36
|
"ai-tools"
|
|
33
37
|
],
|