@softspark/jira-mcp 1.14.2 → 1.14.4
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/CHANGELOG.md +548 -0
- package/README.md +5 -4
- package/dist/cli.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,548 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@softspark/jira-mcp` are documented here.
|
|
4
|
+
|
|
5
|
+
Format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
6
|
+
Versioning follows [Semantic Versioning](https://semver.org/).
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## v1.14.4 -- The changelog actually ships (2026-09-09)
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- **Both packages now contain the `CHANGELOG.md` their `files` list has promised
|
|
15
|
+
since 1.12.0.** npm resolves `files` patterns inside the package directory,
|
|
16
|
+
the changelog lives at the repository root, and a pattern matching nothing is
|
|
17
|
+
dropped without a warning. Every release since the workspace split shipped
|
|
18
|
+
without it, and the README version badge linked to a file the tarball did not
|
|
19
|
+
contain. A symlink does not help, because `npm pack` skips it; each package's
|
|
20
|
+
tsup config copies the root file in instead, so the root stays the one place
|
|
21
|
+
anybody edits.
|
|
22
|
+
- **Changelog links in both READMEs pointed outside the package.**
|
|
23
|
+
`../../CHANGELOG.md` resolves within the repository but not within a published
|
|
24
|
+
tarball, so on npmjs.com those links were dead for the same reason.
|
|
25
|
+
|
|
26
|
+
### Added
|
|
27
|
+
|
|
28
|
+
- **A packaging test over both published packages.** It asserts that every
|
|
29
|
+
`files` entry matches at least one real file, and that each package's copied
|
|
30
|
+
changelog is identical to the root one. The first catches a manifest promising
|
|
31
|
+
what it does not deliver; the second catches a release built before the
|
|
32
|
+
changelog was edited, which would ship stale history.
|
|
33
|
+
|
|
34
|
+
## v1.14.3 -- Knowledge base only (2026-09-09)
|
|
35
|
+
|
|
36
|
+
**Behaviourally identical to 1.14.2.** Everything below lives in `kb/`, which no
|
|
37
|
+
tarball carries, so upgrading from 1.14.2 gains nothing at runtime. The version
|
|
38
|
+
exists to give the documentation below a release to sit against.
|
|
39
|
+
|
|
40
|
+
Diffing the two published tarballs, what actually differs is the version and
|
|
41
|
+
nothing else: the `version` field in package.json, the version string tsup bakes
|
|
42
|
+
into `dist/cli.js` and `dist/index.js`, and the badge and "What's New" heading in
|
|
43
|
+
README. `templates-system/` and `hooks/` are byte-identical.
|
|
44
|
+
|
|
45
|
+
### Added
|
|
46
|
+
|
|
47
|
+
- **A troubleshooting entry for an npm 404 on a version that was just
|
|
48
|
+
published.** 1.14.2 was discoverable and uninstallable for about seven minutes:
|
|
49
|
+
`npm view` reported the version with a correct `fileCount`, `shasum`,
|
|
50
|
+
`integrity`, registry signature and SLSA provenance, `dist-tags.latest` already
|
|
51
|
+
pointed at it, and the tarball URL from that same metadata returned
|
|
52
|
+
`{"error":"Not found"}`. Both packages. It is CDN propagation, and the entry
|
|
53
|
+
says to poll rather than deprecate and re-release, which is the instinctive and
|
|
54
|
+
wrong response. It also records that a `curl` of the tarball returns a JSON
|
|
55
|
+
error body, which `tar` reports as `Unrecognized archive format`, looking like
|
|
56
|
+
a corrupt package when nothing is corrupt.
|
|
57
|
+
- **The executed record of the 1.14.0, 1.14.1 and 1.14.2 releases**, including
|
|
58
|
+
the post-release runs against KAN and the DevOps space.
|
|
59
|
+
|
|
60
|
+
### Fixed
|
|
61
|
+
|
|
62
|
+
- **Closed a stale note.** The 1.12.0/1.13.0 verification record still listed
|
|
63
|
+
localised comment templates as unstarted with no decision taken. They shipped
|
|
64
|
+
in 1.14.0, and by a different design than that note guessed at.
|
|
65
|
+
|
|
66
|
+
## v1.14.2 -- Drift guard on the Confluence help listing (2026-09-09)
|
|
67
|
+
|
|
68
|
+
No behaviour change in either package. It ships the guard that the 1.14.1 fix
|
|
69
|
+
left missing on the other half of the workspace.
|
|
70
|
+
|
|
71
|
+
### Added
|
|
72
|
+
|
|
73
|
+
- **A test that fails when `confluence-mcp --help` stops naming a registered
|
|
74
|
+
command.** The listing under "All commands" is a hand-written epilogue in
|
|
75
|
+
`packages/confluence-mcp/src/cli/program.ts`, the same construction that let
|
|
76
|
+
1.14.0 ship with two Jira commands missing from the help. The test walks the
|
|
77
|
+
registered command tree, renders the help through Commander and fails on
|
|
78
|
+
anything absent. Unlike the Jira one it needs no exclusion list: every command
|
|
79
|
+
the Confluence CLI registers is meant to be listed.
|
|
80
|
+
|
|
81
|
+
### Fixed
|
|
82
|
+
|
|
83
|
+
- **Corrected the Confluence tool count in the docs.** `CLAUDE.md` and the
|
|
84
|
+
package README said 30 while the server registers 31; the count went stale when
|
|
85
|
+
`list_page_templates` landed in 1.13.0.
|
|
86
|
+
|
|
87
|
+
## v1.14.1 -- Help text lists the new commands (2026-09-09)
|
|
88
|
+
|
|
89
|
+
### Fixed
|
|
90
|
+
|
|
91
|
+
- **`jira-mcp --help` did not list `template list-locales` or
|
|
92
|
+
`template install-locale`.** The command listing under "All commands" is
|
|
93
|
+
hand-written, so the two commands added in 1.14.0 were invisible to anyone
|
|
94
|
+
reading the help. A test now walks the registered command tree and fails when
|
|
95
|
+
the listing misses one, which is what should have caught this.
|
|
96
|
+
|
|
97
|
+
## v1.14.0 -- Translated comment templates (2026-09-09)
|
|
98
|
+
|
|
99
|
+
Both packages are released together under one version.
|
|
100
|
+
`@softspark/confluence-mcp` has no behaviour change in this release.
|
|
101
|
+
|
|
102
|
+
### Added
|
|
103
|
+
|
|
104
|
+
- **Translated comment templates** -- the package now ships Polish versions of all
|
|
105
|
+
eight built-in comment templates under `templates-system/locales/pl/comments/`,
|
|
106
|
+
installed with `jira-mcp template install-locale pl`. A template cannot pick a
|
|
107
|
+
language at render time, because its headings are fixed text in the body, so on
|
|
108
|
+
a project configured for another language `add_templated_comment` posted English
|
|
109
|
+
and broke the language-first rule.
|
|
110
|
+
- **`jira-mcp template list-locales`** -- lists the languages with shipped
|
|
111
|
+
translations.
|
|
112
|
+
- **`jira-mcp template install-locale <lang> [--keep-english]`** -- installs them as
|
|
113
|
+
overrides. Each translation keeps the English `id` and variable names of the
|
|
114
|
+
template it replaces, so nothing that calls `add_templated_comment` breaks.
|
|
115
|
+
`--keep-english` also installs the originals as `<id>-en`, for an install whose
|
|
116
|
+
projects are not all in one language.
|
|
117
|
+
|
|
118
|
+
### Fixed
|
|
119
|
+
|
|
120
|
+
- **Documented that the template catalog is read once, at server startup.**
|
|
121
|
+
`template add` and `install-locale` change what the CLI reports immediately, but
|
|
122
|
+
a running MCP server keeps serving the catalog it loaded, and the next templated
|
|
123
|
+
comment silently renders the old version. Both commands now say to restart the
|
|
124
|
+
client, and it is stated in the rules and the templates reference.
|
|
125
|
+
|
|
126
|
+
## v1.13.0 -- Page templates and real space keys (2026-09-09)
|
|
127
|
+
|
|
128
|
+
Both packages are released together under one version. `@softspark/jira-mcp` has
|
|
129
|
+
no behaviour change in this release; it ships because the shared template engine
|
|
130
|
+
moved into the package both servers bundle.
|
|
131
|
+
|
|
132
|
+
### Added
|
|
133
|
+
|
|
134
|
+
- **Confluence page templates** -- `list_page_templates` lists what is usable in a
|
|
135
|
+
space, filtered to its body format, and `create_page` accepts `template_id` plus
|
|
136
|
+
`variables`. Three ship with the package: `runbook` and `incident-review` in
|
|
137
|
+
markdown, `decision-record` in storage using Confluence status and info macros.
|
|
138
|
+
User templates in `~/.softspark/jira-mcp/templates/pages/*.md` override a shipped
|
|
139
|
+
one by id; a malformed file is skipped rather than breaking startup.
|
|
140
|
+
- **`rules/confluence-mcp.md`** -- agent rules for the Confluence server, registrable
|
|
141
|
+
with `ai-toolkit add-rule`, matching how `rules/jira-mcp.md` works.
|
|
142
|
+
|
|
143
|
+
### Changed
|
|
144
|
+
|
|
145
|
+
- **`renderTemplate` moved to the shared core package** -- the `{{variable}}` engine is
|
|
146
|
+
plain text substitution and is now used by Jira comment and task templates and by
|
|
147
|
+
Confluence page templates alike.
|
|
148
|
+
|
|
149
|
+
### Fixed
|
|
150
|
+
|
|
151
|
+
- **Confluence space keys are no longer forced to uppercase** -- the validator applied
|
|
152
|
+
Jira's project-key rule, which rejected real spaces: Confluence keeps the case a
|
|
153
|
+
space was created with (`DevOps`, `Puccini`, `MTPapp`) and personal space keys start
|
|
154
|
+
with `~`. Every one of those was rejected by `space add`.
|
|
155
|
+
|
|
156
|
+
## v1.12.0 -- Confluence support, split into two packages (2026-09-09)
|
|
157
|
+
|
|
158
|
+
This release turns the repository into an npm workspace. `@softspark/jira-mcp`
|
|
159
|
+
keeps its name, contents and CLI; Confluence ships as its own package. Both are
|
|
160
|
+
released together under one version.
|
|
161
|
+
|
|
162
|
+
### Added
|
|
163
|
+
|
|
164
|
+
- **`@softspark/confluence-mcp`** -- a second published package and stdio MCP server
|
|
165
|
+
covering Confluence Cloud. It reads the same `config.json` and `credentials.json`
|
|
166
|
+
as the Jira server, because one Atlassian site serves both products from the same
|
|
167
|
+
host with the same API token. The tool lists stay separate: merging them would put
|
|
168
|
+
`search_tasks` beside `search_pages` and `get_task_details` beside `get_page`, and
|
|
169
|
+
near-homonyms in one list make tool selection worse. A workspace test asserts the
|
|
170
|
+
two lists never share a name.
|
|
171
|
+
- **`@softspark/atlassian-mcp-core`** -- private, unpublished workspace package holding
|
|
172
|
+
the configuration loader, ADF conversion, HTTP transport, error hierarchy and MCP
|
|
173
|
+
response envelope. Both servers bundle it at build time, so it never reaches a
|
|
174
|
+
consumer as a separate dependency.
|
|
175
|
+
- **Per-space body format** -- `format: "markdown" | "storage"` on a space in config.json,
|
|
176
|
+
with `default_format` as the global fallback and
|
|
177
|
+
`confluence-mcp space set-format <KEY> <format>` to set it. A `storage` space reads and
|
|
178
|
+
writes Confluence XHTML and refuses markdown writes; a `markdown` space accepts both,
|
|
179
|
+
because storage never loses anything. `get_space_language` reports the format alongside
|
|
180
|
+
the language, and `list_spaces` reports it per configured space.
|
|
181
|
+
- **Storage-format support for Confluence pages** -- `get_page` accepts
|
|
182
|
+
`body_format: "storage"` and reports `has_storage_markup`; `create_page` and
|
|
183
|
+
`update_page` accept a `storage` body. Confluence stores macros, page links and
|
|
184
|
+
attachment references as XHTML that markdown cannot express, and a markdown round-trip
|
|
185
|
+
would keep the prose and silently delete the rest.
|
|
186
|
+
- **`spaces` section in config.json** -- maps a Confluence space key to a site URL and
|
|
187
|
+
an optional content language, mirroring how `projects` maps Jira. Both keys are
|
|
188
|
+
optional, so a config written before this release still validates.
|
|
189
|
+
- **`confluence-mcp space` commands** -- `add`, `remove`, `list`, `set-default`,
|
|
190
|
+
`set-language`, `set-format`. Credentials stay on `jira-mcp config set-credentials`.
|
|
191
|
+
- **Pages** -- `search_pages` (plain text or raw CQL), `get_page`, `list_space_pages`,
|
|
192
|
+
`get_page_children`, `create_page`, `update_page`, `move_page`, `delete_page`.
|
|
193
|
+
- **Comments** -- `get_page_comments`, `add_page_comment`, `delete_page_comment`,
|
|
194
|
+
plus `get_page_inline_comments` and `add_page_inline_comment` for anchored review
|
|
195
|
+
threads. An inline comment verifies its anchor text exists in the page before
|
|
196
|
+
writing, because a wrong occurrence count silently anchors to the wrong passage.
|
|
197
|
+
- **Blog posts** -- `list_blog_posts`, `get_blog_post`, `create_blog_post`,
|
|
198
|
+
`update_blog_post`, `delete_blog_post`.
|
|
199
|
+
- **Restrictions** -- `get_page_restrictions` and `set_page_restrictions`. Reads report
|
|
200
|
+
`inherits_space_permissions` so an empty result is not misread as "nobody has
|
|
201
|
+
access". Writes replace rather than merge and require `user_approved`, because
|
|
202
|
+
clearing restrictions exposes a page that was deliberately private.
|
|
203
|
+
- **Whiteboards** -- `get_whiteboard`, `create_whiteboard`, `delete_whiteboard`.
|
|
204
|
+
Metadata only: whiteboard drawing content has no REST representation, and the tool
|
|
205
|
+
descriptions and results say so.
|
|
206
|
+
- **Labels and attachments** -- `get_page_labels`, `add_page_labels`,
|
|
207
|
+
`remove_page_label`, `list_attachments`, `upload_attachment` (25 MB cap).
|
|
208
|
+
- **Confluence error classes** -- `ConfluenceConnectionError`,
|
|
209
|
+
`ConfluenceAuthenticationError`, `ConfluencePermissionError`, `PageNotFoundError`,
|
|
210
|
+
`VersionConflictError` and `MarkupLossError`, each with its own code.
|
|
211
|
+
|
|
212
|
+
### Changed
|
|
213
|
+
|
|
214
|
+
- **Repository is an npm workspace** -- sources moved to `packages/core`,
|
|
215
|
+
`packages/jira-mcp` and `packages/confluence-mcp`. Typecheck, lint, tests and
|
|
216
|
+
coverage run once across all three; each published package builds its own bundle.
|
|
217
|
+
Nothing changes for consumers of `@softspark/jira-mcp`: same name, same binary,
|
|
218
|
+
same config path.
|
|
219
|
+
- **Shared HTTP transport** -- auth, retry, exponential backoff, `Retry-After` and
|
|
220
|
+
empty-body handling now live in one client used by both products. Connectors inject
|
|
221
|
+
only a status-to-error mapper, removing a duplicated fetch loop.
|
|
222
|
+
- **`update_page` no longer rewrites a body it was not asked to change** -- a
|
|
223
|
+
title-only rename or a re-parent writes the existing body back verbatim instead of
|
|
224
|
+
round-tripping it through markdown.
|
|
225
|
+
- **`update_page` refuses a markdown body that would destroy markup** -- when the page
|
|
226
|
+
contains Confluence macros, page links or attachment references, the call fails with
|
|
227
|
+
`MARKUP_LOSS_REFUSED` and says to send `storage` instead. `allow_markup_loss: true`
|
|
228
|
+
overrides it after the user agrees.
|
|
229
|
+
|
|
230
|
+
### Fixed
|
|
231
|
+
|
|
232
|
+
- **`config add-project` and `config remove-project` no longer drop config fields** --
|
|
233
|
+
both rebuilt config.json from the fields they knew about, which already discarded
|
|
234
|
+
`default_language` and would have deleted the entire Confluence `spaces` section.
|
|
235
|
+
Both now spread the loaded object.
|
|
236
|
+
- **Confluence links resolve against the `/wiki` context path** -- page, search-result
|
|
237
|
+
and attachment URLs are returned relative to `/wiki`, and resolving them against the
|
|
238
|
+
site origin dropped that segment and produced links that 404.
|
|
239
|
+
|
|
240
|
+
## v1.11.0 -- Local audits and private configuration (2026-09-06)
|
|
241
|
+
|
|
242
|
+
- Add text, JSON and SARIF audits for local filesystem permissions and shipped hook ownership.
|
|
243
|
+
- Create new configuration/cache directories with mode 0700 and state files with mode 0600.
|
|
244
|
+
- Complete third-party attribution in NOTICE and require the full applicable module and SOP artifact set in CI.
|
|
245
|
+
- Require behavior, tests and documentation in the same pull request; correct the lockfile-based signature verification procedure.
|
|
246
|
+
|
|
247
|
+
## v1.10.0 -- Remaining Estimate (2026-09-01)
|
|
248
|
+
|
|
249
|
+
### Added
|
|
250
|
+
|
|
251
|
+
- **`remaining_estimate` in `update_task`** -- writes `timetracking.remainingEstimate`.
|
|
252
|
+
Jira keeps the two estimates independent: setting `original_estimate` on a parent
|
|
253
|
+
issue leaves its remaining estimate at the old value, so a report that sums
|
|
254
|
+
remaining still showed the pre-edit total. Setting one field does not disturb
|
|
255
|
+
the other, and both can be sent in a single call. Same format and day rejection
|
|
256
|
+
as `original_estimate`.
|
|
257
|
+
|
|
258
|
+
## v1.9.0 -- Sub-tasks and Estimates (2026-09-01)
|
|
259
|
+
|
|
260
|
+
### Added
|
|
261
|
+
|
|
262
|
+
- **`parent_key` in `create_task`** -- sets the Jira `parent` field so sub-tasks can be
|
|
263
|
+
created at all. `epic_key` resolves the Epic Link custom field, which is a different
|
|
264
|
+
field, so passing it for a sub-task made Jira answer with
|
|
265
|
+
`Issue type is a sub-task but parent issue key or id not specified`.
|
|
266
|
+
- **`original_estimate` in `create_task` and `update_task`** -- writes
|
|
267
|
+
`timetracking.originalEstimate`. Estimates could only be set by hand in the Jira UI
|
|
268
|
+
before; `log_task_time` logs work already done, which is a different field.
|
|
269
|
+
Accepts the same `"2h"` / `"30m"` / `"2h 30m"` format as `log_task_time` and rejects
|
|
270
|
+
days through the same parser.
|
|
271
|
+
|
|
272
|
+
## v1.8.1 -- Duplicate Detection (2026-08-03)
|
|
273
|
+
|
|
274
|
+
### Fixed
|
|
275
|
+
|
|
276
|
+
- **Duplicate detection never matched anything.** `findExistingTask` searched with
|
|
277
|
+
`summary = "..."`, but `summary` is a text field and JQL only supports `~` on it.
|
|
278
|
+
Jira answers `=` with an empty result set instead of an error, so every lookup
|
|
279
|
+
reported "not found": `update_existing` never updated, and re-running a bulk config
|
|
280
|
+
created a second copy of every task. The lookup now uses a quoted `~` phrase and
|
|
281
|
+
compares the returned summary exactly, since `~` is a fuzzy match. Found by running
|
|
282
|
+
a config twice against a live instance and getting a duplicate issue.
|
|
283
|
+
|
|
284
|
+
## v1.8.0 -- Status Paths (2026-08-03)
|
|
285
|
+
|
|
286
|
+
### Added
|
|
287
|
+
|
|
288
|
+
- **`status` accepts an ordered path** in bulk task configs -- `"status": ["On hold", "Open"]`
|
|
289
|
+
walks the transitions one at a time. Jira only exposes the transitions available from an
|
|
290
|
+
issue's *current* status, so a target that is not directly reachable from the initial
|
|
291
|
+
status could not be set at all before. A plain string still means a single transition.
|
|
292
|
+
- **`warnings` in `create_monthly_tasks` output** -- per-task problems that did not stop the
|
|
293
|
+
issue from being written now surface in the tool response instead of being dropped by the
|
|
294
|
+
counters-only summary.
|
|
295
|
+
|
|
296
|
+
### Fixed
|
|
297
|
+
|
|
298
|
+
- **A rejected status transition is no longer silent.** `setStatus` swallowed every failure,
|
|
299
|
+
including the ordinary case of the requested status simply not being reachable: the issue
|
|
300
|
+
was created, the status was ignored, and the run reported `failed: 0`. Eleven monthly admin
|
|
301
|
+
tasks sat in the wrong status for months because of this. The transition is now reported as
|
|
302
|
+
a `warning` on the task result, naming the status that failed and listing the ones that were
|
|
303
|
+
reachable at that point. The issue itself is still created -- the transition stays non-fatal.
|
|
304
|
+
|
|
305
|
+
### Changed
|
|
306
|
+
|
|
307
|
+
- **`TaskResult` gains a `warning` field** (`string | null`). `formatBulkResult` prints it
|
|
308
|
+
indented under the task line. Consumers destructuring `TaskResult` are unaffected; anyone
|
|
309
|
+
constructing one now has to supply the field.
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
### Changed -- licence: MIT to Apache-2.0
|
|
314
|
+
|
|
315
|
+
The project is now licensed under the Apache License 2.0. It stays permissive:
|
|
316
|
+
fork it, modify it, ship it commercially. What changes is what a redistributor
|
|
317
|
+
owes back.
|
|
318
|
+
|
|
319
|
+
- **`NOTICE` is the point.** MIT already required keeping the copyright notice, so
|
|
320
|
+
attribution is not new. Apache-2.0 adds section 4(d): a redistributor must carry
|
|
321
|
+
the contents of `NOTICE` -- project name, copyright, source URL -- into their
|
|
322
|
+
distribution. `NOTICE` is in `package.json` `files`, so it ships with the package.
|
|
323
|
+
- **Modified files must say so** (section 4b), an express patent grant with
|
|
324
|
+
retaliation (section 3), and no rights to the project or company names
|
|
325
|
+
(section 6). None of these existed under MIT.
|
|
326
|
+
- **Attribution reaches the published bundles through a build banner.** This is
|
|
327
|
+
the part specific to this package: npm ships `dist/`, not `src/`, and the build
|
|
328
|
+
runs with `minify: true`, which strips every comment. SPDX headers in `src/`
|
|
329
|
+
are for whoever clones the repository; consumers see the tsup `banner`, now
|
|
330
|
+
present in both `dist/index.js` and `dist/cli.js`.
|
|
331
|
+
- **SPDX headers on 165 source files**, placed after any shebang.
|
|
332
|
+
- **Nothing is revoked.** Releases up to and including v1.6.0 were published under
|
|
333
|
+
MIT and remain available under MIT. All contributions were made by the
|
|
334
|
+
copyright holder, so no third-party permission was required.
|
|
335
|
+
|
|
336
|
+
`LICENSE` holds the verbatim Apache-2.0 text, cross-verified against two
|
|
337
|
+
independent published copies before being written.
|
|
338
|
+
|
|
339
|
+
### Tests
|
|
340
|
+
|
|
341
|
+
- `tests/licensing.test.ts`, 8 assertions run by `npm test`: SPDX headers present
|
|
342
|
+
and naming Apache-2.0, `LICENSE` complete, `NOTICE` carrying attribution and
|
|
343
|
+
section 4(d), both files in `package.json` `files`, `package.json` declaring
|
|
344
|
+
Apache-2.0, and **both build entries carrying the licence banner**. The banner
|
|
345
|
+
assertion exists because losing it would strip attribution from the published
|
|
346
|
+
artifact while every other check stayed green.
|
|
347
|
+
|
|
348
|
+
---
|
|
349
|
+
|
|
350
|
+
## v1.6.0 -- ADF Nested Lists, Task Lists & Doc-Parity Gates (2026-06-10)
|
|
351
|
+
|
|
352
|
+
### Added
|
|
353
|
+
- **Nested list support in ADF conversion** -- indented markdown lists (2 spaces or tab) now produce properly nested `bulletList`/`orderedList` ADF nodes instead of being flattened, in both write and read directions. Read direction renders nesting with 2-space indentation.
|
|
354
|
+
- **Task list (checkbox) support** -- `- [ ]` / `- [x]` markdown converts to ADF `taskList`/`taskItem` nodes (Jira checkboxes) with document-unique `localId`s, and renders back to markdown checkboxes including nesting. Nested bullet/ordered lists under a task item are lifted to siblings after the task list to keep the ADF valid.
|
|
355
|
+
- **Image degradation** -- `` markdown converts to a link (alt text as label, URL as fallback) instead of leaking a stray `!` into the text. ADF media nodes require uploaded attachments, so a link is the lossless-enough fallback.
|
|
356
|
+
- **`date` node rendering on read** -- ADF date nodes now render as `YYYY-MM-DD` instead of disappearing from task descriptions and comments.
|
|
357
|
+
- **Doc-parity checks in `validate_counts.py`** -- the validator now also verifies the README version badge against `package.json`, and that every MCP tool from `definitions.ts` is documented in `kb/reference/api.md` and named in `rules/jira-mcp.md`.
|
|
358
|
+
|
|
359
|
+
### Changed
|
|
360
|
+
- **CI enforces the coverage gate** -- the test job runs `npm run test:coverage`, so the 70% thresholds (lines, branches, functions) actually block merges. Branch coverage raised from 64.5% to above the threshold with new CLI and ADF edge-case tests.
|
|
361
|
+
|
|
362
|
+
### Fixed
|
|
363
|
+
- **README version badge drift** (1.4.3 -> 1.5.0) and stale test counts.
|
|
364
|
+
- **`kb/reference/api.md`** now documents `search_tasks`, `delete_task`, and `delete_comment`, which were missing despite the "complete reference" claim.
|
|
365
|
+
- **`rules/jira-mcp.md` / `AGENTS.md`** tool list extended to all 19 tools (was 17) and the CLI table extended to all 20 commands (was 14).
|
|
366
|
+
- **Dev dependency vulnerabilities** -- `npm audit fix` applied (7 advisories: fast-uri, brace-expansion, hono, ip-address chains). Runtime dependencies were and remain clean.
|
|
367
|
+
|
|
368
|
+
---
|
|
369
|
+
|
|
370
|
+
## v1.5.0 -- Bulk Template Management & Monthly Tasks Tool (2026-05-04)
|
|
371
|
+
|
|
372
|
+
### Added
|
|
373
|
+
- **`template add bulk` CLI command** -- new third template kind alongside `comment` and `task`. Validates the source JSON against `BulkConfigSchema` and installs it under `~/.softspark/jira-mcp/templates/tasks/<KEY>/monthly_admin.json`. `template list/show/remove` also support the `bulk` kind, keyed by project. Prunes the empty project subdirectory on remove.
|
|
374
|
+
- **`create_monthly_tasks` MCP tool** -- exposes the existing `create-monthly` CLI handler over the protocol. Inputs: `{ execute?: boolean, project?: string }`. Returns a structured result with per-project status (success/error), summary counts, and the resolved config path. Lets MCP clients run monthly bulk task creation without dropping to the CLI.
|
|
375
|
+
|
|
376
|
+
## v1.4.3 -- JQL Escape & Cache Recovery (2026-04-18)
|
|
377
|
+
|
|
378
|
+
### Fixed
|
|
379
|
+
- **`sync_tasks` default JQL parse error** -- `escapeJql` was over-escaping JQL operators (`-`, `+`, `&`, `|`, etc.) inside double-quoted string literals. Jira rejected the resulting query with `'\-' jest niedozwoloną sekwencją modyfikacji JQL`. The escape now only handles `\` and `"` (the only sequences valid inside a quoted JQL string), so `sync_tasks` works without an explicit `jql` argument when the username contains a hyphen.
|
|
380
|
+
- **`reassign_task` / `update_task_status` cache miss after Jira mutation** -- both operations now recover from a cache miss by fetching the task from Jira via `connector.getIssue` and upserting it into the local cache. Previously, calling either tool right after `create_task` (cache not populated) or `log_task_time` (cache invalidated) failed with `TASK_NOT_FOUND` even though the Jira mutation succeeded.
|
|
381
|
+
|
|
382
|
+
### Added
|
|
383
|
+
- **`CacheManager.upsertTask(task)`** -- inserts a task or replaces it by key, tolerating a missing cache file. Used by the new mutation-recovery path.
|
|
384
|
+
|
|
385
|
+
## v1.4.2 -- Supply-Chain Hardening (2026-04-18)
|
|
386
|
+
|
|
387
|
+
### Added
|
|
388
|
+
- **npm provenance attestation** -- `publish.yml` now publishes with `--provenance` and `id-token: write`, producing a SLSA v1 attestation on every release. Consumers can verify via `npm audit signatures` or the Provenance badge on npmjs.com.
|
|
389
|
+
- **Supply-chain gates in release SOP** -- `kb/procedures/sop-release.md` adds a pre-tag check for `--provenance` and `id-token: write` in `publish.yml`, plus a post-publish step that asserts `predicateType == https://slsa.dev/provenance/v1`.
|
|
390
|
+
- **Provenance verification in post-release SOP** -- `kb/procedures/sop-post-release-testing.md` adds Phase 5 covering the SLSA attestation check, `npm audit signatures`, and the npmjs.com Provenance badge.
|
|
391
|
+
- **Version-sync step in pre-commit SOP** -- `kb/procedures/sop-pre-commit.md` adds Step 6 verifying `package.json` and `package-lock.json` agree on the `version` field.
|
|
392
|
+
|
|
393
|
+
### Changed
|
|
394
|
+
- **Release workflow permissions** -- `packages: write` and `id-token: write` added to `.github/workflows/publish.yml` for OIDC attestation.
|
|
395
|
+
- **Release commit now stages the lockfile** -- SOP Phase 5 stages `package.json`, `package-lock.json`, `CHANGELOG.md`, and `README.md`. Prevents lockfile drift between tags.
|
|
396
|
+
|
|
397
|
+
### Fixed
|
|
398
|
+
- **`package-lock.json` top-level version drift** -- lockfile root `version` was stuck at `1.0.0` across prior releases. Regenerated via `npm install --package-lock-only` and now matches `package.json` on every release commit.
|
|
399
|
+
|
|
400
|
+
## v1.4.1 -- Template Loading Fix (2026-04-15)
|
|
401
|
+
|
|
402
|
+
### Fixed
|
|
403
|
+
- **File-backed templates missing after install** -- `PACKAGE_ROOT_DIR` used a hardcoded `../..` relative depth that resolved correctly in the source layout but overshot by one level after tsup bundling. Replaced with `findPackageRoot()` that walks up looking for `package.json`. All 8 built-in comment templates now load correctly from global installs.
|
|
404
|
+
|
|
405
|
+
## v1.4.0 -- Delete Tools & Error Hardening (2026-04-15)
|
|
406
|
+
|
|
407
|
+
### Added
|
|
408
|
+
- **`delete_task` tool** -- delete a Jira issue with ownership enforcement (creator only) and explicit user approval guard.
|
|
409
|
+
- **`delete_comment` tool** -- delete a comment with ownership enforcement (author only) and explicit user approval guard.
|
|
410
|
+
- **Markdown table support in ADF** -- `markdownToAdf()` now converts markdown tables to ADF table nodes.
|
|
411
|
+
|
|
412
|
+
### Changed
|
|
413
|
+
- **Narrowed cache cleanup catch blocks** -- `deleteTask()` and `logTime()` now catch only `TaskNotFoundError` and `CacheNotFoundError` instead of swallowing all exceptions. Unexpected I/O or corruption errors propagate.
|
|
414
|
+
|
|
415
|
+
### Fixed
|
|
416
|
+
- **Silent cache errors** -- cache I/O failures during post-delete and post-worklog cleanup were silently ignored, leaving stale entries without any signal.
|
|
417
|
+
|
|
418
|
+
## v1.3.0 -- File-Backed Templates & Approval Hooks (2026-04-15)
|
|
419
|
+
|
|
420
|
+
### Added
|
|
421
|
+
- **File-backed template catalog** -- ship built-in comment and single-task templates as physical markdown files under `templates-system/`.
|
|
422
|
+
- **Template management CLI** -- add `jira-mcp template add/list/show/remove` for global user overrides in `~/.softspark/jira-mcp/templates/`.
|
|
423
|
+
- **Task templates for `create_task`** -- add `list_task_templates` and template-based issue creation with variable rendering.
|
|
424
|
+
- **Comment approval hook manifest** -- ship `hooks/jira-mcp-hooks.json` for ai-toolkit `inject-hook` flows that preview and gate Jira comment writes.
|
|
425
|
+
|
|
426
|
+
### Changed
|
|
427
|
+
- **Template loading model** -- resolve active templates from system files plus global user overrides, with user files winning on `id` collisions.
|
|
428
|
+
- **Configuration init** -- create dedicated template directories for comments, single-task templates, and bulk task configs.
|
|
429
|
+
- **README validation** -- exclude internal tool helpers from MCP tool counts and refresh counts to match the current source tree.
|
|
430
|
+
|
|
431
|
+
### Fixed
|
|
432
|
+
- **Comment write safety** -- require explicit `user_approved=true` before `add_task_comment` and `add_templated_comment` can mutate Jira.
|
|
433
|
+
- **Comment preview flow** -- render templated comment previews before execution so approval can target the exact outgoing markdown.
|
|
434
|
+
|
|
435
|
+
## v1.2.0 -- Per-Instance Credentials & Jira API Migration (2026-04-14)
|
|
436
|
+
|
|
437
|
+
### Added
|
|
438
|
+
- **Per-instance credentials** -- `set-credentials --url` flag allows different API tokens per Jira instance. Auto-migrates legacy Format A to Format B on first use.
|
|
439
|
+
- **Live Jira API smoke tests** -- post-release SOP now includes Phase 4 with 15 steps testing all MCP tools against the KAN sandbox project.
|
|
440
|
+
- **`validate_counts.py` in pre-commit SOP** -- added as Step 5 to catch README count drift before commit.
|
|
441
|
+
|
|
442
|
+
### Changed
|
|
443
|
+
- **Search endpoint migrated** -- `/rest/api/3/search` → `/rest/api/3/search/jql` (Jira Cloud deprecated the old endpoint with HTTP 410).
|
|
444
|
+
- **`set-credentials` CLI** -- read-modify-write instead of overwrite. Preserves existing credentials when adding instance overrides.
|
|
445
|
+
|
|
446
|
+
### Fixed
|
|
447
|
+
- **Jira Cloud 410 on sync/search** -- `sync_tasks` and `search_tasks` failed on instances where Jira had removed the legacy search endpoint.
|
|
448
|
+
|
|
449
|
+
---
|
|
450
|
+
|
|
451
|
+
## v1.1.0 -- Hardening & Market Readiness (2026-04-14)
|
|
452
|
+
|
|
453
|
+
### Added
|
|
454
|
+
- **Boundary test suite** -- 96 new tests covering `server.ts` (25), `cli/index.ts` (27), and `JiraConnector` (44). Total: 509 tests across 51 files.
|
|
455
|
+
- **Retry/backoff for transient failures** -- `JiraConnector` retries 429 and 503 responses up to 3 times with exponential backoff (1s/2s/4s). Respects `Retry-After` header.
|
|
456
|
+
- **Count validation script** -- `scripts/validate_counts.py` verifies README counts match source code. Enforced in CI via `validate-counts` job.
|
|
457
|
+
- **Count validation in CI** -- new `validate-counts` job in `ci.yml` catches README drift before merge.
|
|
458
|
+
- **ADR-0001** -- documented "hardening before refactor" decision with alternatives and guardrails.
|
|
459
|
+
- **Hardening plan** -- full plan with success criteria and pre-mortem in `kb/planning/`.
|
|
460
|
+
|
|
461
|
+
### Changed
|
|
462
|
+
- **server.ts refactored** -- 719 → 324 lines (-55%). Tool definitions extracted to `src/tools/definitions.ts`, argument helpers to `src/tools/args.ts`.
|
|
463
|
+
- **Major dependency upgrades** -- TypeScript 5 → 6, ESLint 9 → 10, zod 3 → 4, vitest 3 → 4, @types/node 22 → 25.
|
|
464
|
+
- **TypeScript 6 migration** -- added `types: ["node"]` and `ignoreDeprecations: "6.0"` to tsconfig.
|
|
465
|
+
- **zod 4 migration** -- `.default({})` replaced with factory function in `BulkOptionsSchema`.
|
|
466
|
+
- **vitest 4 migration** -- arrow function mocks replaced with regular function syntax for constructor compatibility.
|
|
467
|
+
- **Bundle size** -- 325KB → 520KB (due to zod 4, which is significantly larger).
|
|
468
|
+
- **README** -- "Zero runtime dependencies" corrected to "Minimal runtime dependencies". Test counts updated.
|
|
469
|
+
- **CONTRIBUTING.md** -- full CI workflow documented, `validate:counts` noted as maintainer-managed.
|
|
470
|
+
- **Coverage exclusions reduced** -- `server.ts` and `jira-connector.ts` removed from vitest exclusion list.
|
|
471
|
+
|
|
472
|
+
### Security
|
|
473
|
+
- **Cache file permissions** -- all cache writes use `mode: 0o600` (owner-only). Prevents local privilege escalation on shared machines.
|
|
474
|
+
- **CWD config loading warning** -- stderr warning when `config.json` or `credentials.json` loaded from working directory instead of global config.
|
|
475
|
+
- **Error message truncation** -- Jira API error responses truncated to 200 characters to prevent information leakage.
|
|
476
|
+
- **`saveJsonFile` JSDoc** -- `@security` annotation warns against use for sensitive data.
|
|
477
|
+
|
|
478
|
+
### Documentation
|
|
479
|
+
- **Hardcoded counts removed** from secondary docs (CLAUDE.md, kb/, rules/, copilot-instructions). Counts live only in README (single source of truth pattern from ai-toolkit).
|
|
480
|
+
- **KB docs updated** -- caching.md, architecture.md, configuration.md, troubleshooting/common-issues.md reflect security changes.
|
|
481
|
+
- **Release SOP updated** -- Step 4.5 (validate counts) and Step 3.2 (README "What's New" update) added.
|
|
482
|
+
|
|
483
|
+
---
|
|
484
|
+
|
|
485
|
+
## v1.0.0 -- Initial Public Release (2026-04-14)
|
|
486
|
+
|
|
487
|
+
### MCP Tools (15)
|
|
488
|
+
|
|
489
|
+
- **`sync_tasks`** -- sync Jira tasks to local cache with optional JQL filter
|
|
490
|
+
- **`read_cached_tasks`** -- read tasks from local cache without hitting Jira
|
|
491
|
+
- **`update_task_status`** -- change task status via workflow transition
|
|
492
|
+
- **`update_task`** -- update existing issue fields (summary, description, priority, labels) with ADF conversion
|
|
493
|
+
- **`add_task_comment`** -- add markdown comment (auto-converted to ADF)
|
|
494
|
+
- **`reassign_task`** -- reassign or unassign a task by email
|
|
495
|
+
- **`get_task_statuses`** -- get valid workflow transitions for a task
|
|
496
|
+
- **`get_task_details`** -- get full details with description, comments, and project language
|
|
497
|
+
- **`get_project_language`** -- get configured language for a project (for AI assistants)
|
|
498
|
+
- **`log_task_time`** -- log work time in `"2h 30m"` format
|
|
499
|
+
- **`get_task_time_tracking`** -- get time tracking info (estimate, spent, remaining)
|
|
500
|
+
- **`list_comment_templates`** -- list available comment templates by category
|
|
501
|
+
- **`add_templated_comment`** -- add comment using a template with variable interpolation
|
|
502
|
+
- **`create_task`** -- create a new Jira issue with ADF description, assignee, labels, epic link
|
|
503
|
+
- **`search_tasks`** -- search Jira issues with raw JQL (no caching)
|
|
504
|
+
|
|
505
|
+
### CLI Commands (16)
|
|
506
|
+
|
|
507
|
+
- **`jira-mcp`** / **`jira-mcp serve`** -- start MCP server (stdio transport)
|
|
508
|
+
- **`jira-mcp config init`** -- initialize global config at `~/.softspark/jira-mcp/`
|
|
509
|
+
- **`jira-mcp config add-project <key> <url>`** -- add a Jira project mapping
|
|
510
|
+
- **`jira-mcp config remove-project <key>`** -- remove a project
|
|
511
|
+
- **`jira-mcp config list-projects`** -- show configured projects with language column
|
|
512
|
+
- **`jira-mcp config set-credentials`** -- set API credentials
|
|
513
|
+
- **`jira-mcp config set-default <key>`** -- set default project
|
|
514
|
+
- **`jira-mcp config set-language <lang>`** -- set global default language
|
|
515
|
+
- **`jira-mcp config set-project-language <key> <lang>`** -- set language for a specific project
|
|
516
|
+
- **`jira-mcp create <path>`** -- create tasks from bulk config file (dry-run by default)
|
|
517
|
+
- **`jira-mcp create-monthly`** -- run monthly admin task templates
|
|
518
|
+
- **`jira-mcp cache sync-workflows`** -- sync workflow status transitions
|
|
519
|
+
- **`jira-mcp cache sync-users`** -- sync user list for reassignment
|
|
520
|
+
- **`jira-mcp cache list-workflows`** -- show cached workflows
|
|
521
|
+
- **`jira-mcp cache list-users`** -- show cached users
|
|
522
|
+
|
|
523
|
+
### Features
|
|
524
|
+
|
|
525
|
+
- **Multi-instance routing** -- single server manages multiple Jira Cloud/Server instances. Project key determines routing. Connectors deduplicated by URL via InstancePool.
|
|
526
|
+
- **Language configuration** -- global `default_language` with per-project override. Supports: pl, en, de, es, fr, pt, it, nl. AI assistants check language before writing content.
|
|
527
|
+
- **ADF round-trip** -- bidirectional Markdown ↔ Atlassian Document Format conversion. Zero-dependency built-in parsers (~330 lines each). Literal `\n` normalization for MCP tool parameters.
|
|
528
|
+
- **Local caching** -- tasks synced to `~/.softspark/jira-mcp/cache/` with atomic writes. Workflow and user caches for offline status validation and assignee resolution.
|
|
529
|
+
- **Comment templates** -- 8 built-in templates with `{{variable}}` interpolation and `{{#var}}...{{/var}}` conditional blocks.
|
|
530
|
+
- **Bulk task creation** -- JSON config templates with dry-run default, rate limiting, epic link discovery, bilingual support (8 languages), idempotent updates.
|
|
531
|
+
- **Per-instance credentials** -- Format A (single credential) and Format B (per-URL credentials with default fallback). Backward compatible.
|
|
532
|
+
- **Supply chain protection** -- `ignore-scripts=true`, no axios, no dynamic requires. Self-contained 325KB bundle, 1 runtime dep (commander).
|
|
533
|
+
- **Strict TypeScript** -- `strict: true`, no `any`, `readonly` interfaces, Zod validation at all boundaries. 413 tests across 47 test files.
|
|
534
|
+
- **Typed error hierarchy** -- 15 error classes with machine-readable codes. Structured `{ success, error, code }` responses.
|
|
535
|
+
|
|
536
|
+
### Architecture
|
|
537
|
+
|
|
538
|
+
Four layers -- each depends only on layers below:
|
|
539
|
+
|
|
540
|
+
1. **Types & Config** (`config/`, `errors/`, `*/types.ts`) -- pure data, zero runtime deps
|
|
541
|
+
2. **Infrastructure** (`connector/`, `cache/`, `adf/`, `templates/`) -- I/O and external APIs
|
|
542
|
+
3. **Business Logic** (`operations/`, `bulk/`) -- orchestrates infrastructure
|
|
543
|
+
4. **Entry Points** (`tools/`, `cli/`, `server.ts`) -- thin dispatchers
|
|
544
|
+
|
|
545
|
+
### AI Toolkit Integration
|
|
546
|
+
|
|
547
|
+
- **Rules file** (`rules/jira-mcp.md`) -- register with `ai-toolkit add-rule` for automatic language checks, sync-first workflow, and tool reference injection.
|
|
548
|
+
- **GitHub Copilot** (`.github/copilot-instructions.md`) -- full project context for Copilot-assisted development.
|
package/README.md
CHANGED
|
@@ -4,17 +4,18 @@
|
|
|
4
4
|
|
|
5
5
|
[](https://github.com/softspark/jira-mcp/actions/workflows/ci.yml)
|
|
6
6
|
[](https://www.npmjs.com/package/@softspark/jira-mcp)
|
|
7
|
-
[](CHANGELOG.md)
|
|
8
8
|
[](LICENSE)
|
|
9
9
|
|
|
10
10
|
---
|
|
11
11
|
|
|
12
|
-
## What's New in v1.14.
|
|
12
|
+
## What's New in v1.14.4
|
|
13
13
|
|
|
14
|
+
- This package finally contains the `CHANGELOG.md` it has been listing in `files` since 1.12.0. The pattern resolved inside the package directory while the changelog sat at the repository root, so npm dropped it without a word.
|
|
14
15
|
- Polish versions of all eight built-in comment templates ship with the package. Until now a templated comment was English on every project, including one configured for another language.
|
|
15
16
|
- `jira-mcp template list-locales` shows which languages are available, and `jira-mcp template install-locale pl` installs them. Add `--keep-english` to keep the originals reachable as `<id>-en`.
|
|
16
17
|
- Fixed in 1.14.1: `jira-mcp --help` now lists both new commands. 1.14.2 adds the test that would have caught it, on both binaries.
|
|
17
|
-
- Released together with `@softspark/confluence-mcp` under one version. See the [changelog](
|
|
18
|
+
- Released together with `@softspark/confluence-mcp` under one version. See the [changelog](CHANGELOG.md).
|
|
18
19
|
|
|
19
20
|
## Table of Contents
|
|
20
21
|
|
|
@@ -274,7 +275,7 @@ src/
|
|
|
274
275
|
|
|
275
276
|
**Typed error hierarchy** -- 26 error classes with machine-readable codes. Every tool returns structured `{ success, error, code }` responses. No stack traces leak to MCP clients.
|
|
276
277
|
|
|
277
|
-
**Strict TypeScript** -- `strict: true`, no `any`, `readonly` interfaces, Zod validation at all boundaries,
|
|
278
|
+
**Strict TypeScript** -- `strict: true`, no `any`, `readonly` interfaces, Zod validation at all boundaries, 991 tests across 80 test files.
|
|
278
279
|
|
|
279
280
|
## Documentation
|
|
280
281
|
|
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {readFile,mkdir,writeFile,unlink,readdir,rm as rm$1,stat,access,lstat,rename,open}from'fs/promises';import {homedir}from'os';import {join,dirname,resolve}from'path';import {readdirSync,existsSync,readFileSync,constants}from'fs';import {pathToFileURL,fileURLToPath}from'url';import Lh from'process';import {Command}from'commander';/*! jira-mcp | Apache-2.0 | Copyright 2024-2026 Lukasz Krzemien (biuro@softspark.eu) | https://github.com/softspark/jira-mcp */
|
|
3
|
-
var vP=Object.create;var am=Object.defineProperty;var _P=Object.getOwnPropertyDescriptor;var kP=Object.getOwnPropertyNames;var $P=Object.getPrototypeOf,bP=Object.prototype.hasOwnProperty;var f=(t,e)=>()=>(t&&(e=t(t=0)),e);var j=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Jt=(t,e)=>{for(var n in e)am(t,n,{get:e[n],enumerable:true});},xP=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of kP(e))!bP.call(t,r)&&r!==n&&am(t,r,{get:()=>e[r],enumerable:!(o=_P(e,r))||o.enumerable});return t};var gk=(t,e,n)=>(n=t!=null?vP($P(t)):{},xP(am(n,"default",{value:t,enumerable:true}),t));var ac,sm=f(()=>{ac="1.14.2";});function g(t,e,n){function o(s,c){if(s._zod||Object.defineProperty(s,"_zod",{value:{def:c,constr:a,traits:new Set},enumerable:false}),s._zod.traits.has(t))return;s._zod.traits.add(t),e(s,c);let u=a.prototype,l=Object.keys(u);for(let d=0;d<l.length;d++){let p=l[d];p in s||(s[p]=u[p].bind(s));}}let r=n?.Parent??Object;class i extends r{}Object.defineProperty(i,"name",{value:t});function a(s){var c;let u=n?.Parent?new i:this;o(u,s),(c=u._zod).deferred??(c.deferred=[]);for(let l of u._zod.deferred)l();return u}return Object.defineProperty(a,"init",{value:o}),Object.defineProperty(a,Symbol.hasInstance,{value:s=>n?.Parent&&s instanceof n.Parent?true:s?._zod?.traits?.has(t)}),Object.defineProperty(a,"name",{value:t}),a}function ze(t){return t&&Object.assign(ji,t),ji}var sc,Ei,Vt,Cr,ji,Vn=f(()=>{sc=Object.freeze({status:"aborted"});Ei=Symbol("zod_brand"),Vt=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.");}},Cr=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError";}},ji={};});var b={};Jt(b,{BIGINT_FORMAT_RANGES:()=>hm,Class:()=>um,NUMBER_FORMAT_RANGES:()=>gm,aborted:()=>Dr,allowsEval:()=>pm,assert:()=>zP,assertEqual:()=>wP,assertIs:()=>TP,assertNever:()=>IP,assertNotEqual:()=>SP,assignProp:()=>Rr,base64ToUint8Array:()=>xk,base64urlToUint8Array:()=>ZP,cached:()=>Gn,captureStackTrace:()=>uc,cleanEnum:()=>UP,cleanRegex:()=>Ri,clone:()=>Me,cloneDef:()=>jP,createTransparentProxy:()=>DP,defineLazy:()=>X,esc:()=>cc,escapeRegex:()=>It,extend:()=>_k,finalizeIssue:()=>lt,floatSafeRemainder:()=>lm,getElementAtPath:()=>EP,getEnumValues:()=>Oi,getLengthableOrigin:()=>Ai,getParsedType:()=>NP,getSizableOrigin:()=>Di,hexToUint8Array:()=>LP,isObject:()=>ln,isPlainObject:()=>Nr,issue:()=>Kn,joinValues:()=>v,jsonStringifyReplacer:()=>Bn,merge:()=>AP,mergeDefs:()=>yr,normalizeParams:()=>S,nullish:()=>Or,numKeys:()=>RP,objectClone:()=>PP,omit:()=>vk,optionalKeys:()=>fm,parsedType:()=>w,partial:()=>$k,pick:()=>yk,prefixIssues:()=>$t,primitiveTypes:()=>mm,promiseAllObject:()=>CP,propertyKeyTypes:()=>Ni,randomString:()=>OP,required:()=>bk,safeExtend:()=>kk,shallowClone:()=>lc,slugify:()=>dm,stringifyPrimitive:()=>$,uint8ArrayToBase64:()=>wk,uint8ArrayToBase64url:()=>MP,uint8ArrayToHex:()=>FP,unwrapMessage:()=>Ci});function wP(t){return t}function SP(t){return t}function TP(t){}function IP(t){throw new Error("Unexpected value in exhaustive check")}function zP(t){}function Oi(t){let e=Object.values(t).filter(o=>typeof o=="number");return Object.entries(t).filter(([o,r])=>e.indexOf(+o)===-1).map(([o,r])=>r)}function v(t,e="|"){return t.map(n=>$(n)).join(e)}function Bn(t,e){return typeof e=="bigint"?e.toString():e}function Gn(t){return {get value(){{let n=t();return Object.defineProperty(this,"value",{value:n}),n}}}}function Or(t){return t==null}function Ri(t){let e=t.startsWith("^")?1:0,n=t.endsWith("$")?t.length-1:t.length;return t.slice(e,n)}function lm(t,e){let n=(t.toString().split(".")[1]||"").length,o=e.toString(),r=(o.split(".")[1]||"").length;if(r===0&&/\d?e-\d?/.test(o)){let c=o.match(/\d?e-(\d?)/);c?.[1]&&(r=Number.parseInt(c[1]));}let i=n>r?n:r,a=Number.parseInt(t.toFixed(i).replace(".","")),s=Number.parseInt(e.toFixed(i).replace(".",""));return a%s/10**i}function X(t,e,n){let o;Object.defineProperty(t,e,{get(){if(o!==hk)return o===void 0&&(o=hk,o=n()),o},set(r){Object.defineProperty(t,e,{value:r});},configurable:true});}function PP(t){return Object.create(Object.getPrototypeOf(t),Object.getOwnPropertyDescriptors(t))}function Rr(t,e,n){Object.defineProperty(t,e,{value:n,writable:true,enumerable:true,configurable:true});}function yr(...t){let e={};for(let n of t){let o=Object.getOwnPropertyDescriptors(n);Object.assign(e,o);}return Object.defineProperties({},e)}function jP(t){return yr(t._zod.def)}function EP(t,e){return e?e.reduce((n,o)=>n?.[o],t):t}function CP(t){let e=Object.keys(t),n=e.map(o=>t[o]);return Promise.all(n).then(o=>{let r={};for(let i=0;i<e.length;i++)r[e[i]]=o[i];return r})}function OP(t=10){let e="abcdefghijklmnopqrstuvwxyz",n="";for(let o=0;o<t;o++)n+=e[Math.floor(Math.random()*e.length)];return n}function cc(t){return JSON.stringify(t)}function dm(t){return t.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}function ln(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Nr(t){if(ln(t)===false)return false;let e=t.constructor;if(e===void 0||typeof e!="function")return true;let n=e.prototype;return !(ln(n)===false||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===false)}function lc(t){return Nr(t)?{...t}:Array.isArray(t)?[...t]:t}function RP(t){let e=0;for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&e++;return e}function It(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Me(t,e,n){let o=new t._zod.constr(e??t._zod.def);return (!e||n?.parent)&&(o._zod.parent=t),o}function S(t){let e=t;if(!e)return {};if(typeof e=="string")return {error:()=>e};if(e?.message!==void 0){if(e?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message;}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function DP(t){let e;return new Proxy({},{get(n,o,r){return e??(e=t()),Reflect.get(e,o,r)},set(n,o,r,i){return e??(e=t()),Reflect.set(e,o,r,i)},has(n,o){return e??(e=t()),Reflect.has(e,o)},deleteProperty(n,o){return e??(e=t()),Reflect.deleteProperty(e,o)},ownKeys(n){return e??(e=t()),Reflect.ownKeys(e)},getOwnPropertyDescriptor(n,o){return e??(e=t()),Reflect.getOwnPropertyDescriptor(e,o)},defineProperty(n,o,r){return e??(e=t()),Reflect.defineProperty(e,o,r)}})}function $(t){return typeof t=="bigint"?t.toString()+"n":typeof t=="string"?`"${t}"`:`${t}`}function fm(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}function yk(t,e){let n=t._zod.def,o=n.checks;if(o&&o.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let i=yr(t._zod.def,{get shape(){let a={};for(let s in e){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);e[s]&&(a[s]=n.shape[s]);}return Rr(this,"shape",a),a},checks:[]});return Me(t,i)}function vk(t,e){let n=t._zod.def,o=n.checks;if(o&&o.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let i=yr(t._zod.def,{get shape(){let a={...t._zod.def.shape};for(let s in e){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);e[s]&&delete a[s];}return Rr(this,"shape",a),a},checks:[]});return Me(t,i)}function _k(t,e){if(!Nr(e))throw new Error("Invalid input to extend: expected a plain object");let n=t._zod.def.checks;if(n&&n.length>0){let i=t._zod.def.shape;for(let a in e)if(Object.getOwnPropertyDescriptor(i,a)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let r=yr(t._zod.def,{get shape(){let i={...t._zod.def.shape,...e};return Rr(this,"shape",i),i}});return Me(t,r)}function kk(t,e){if(!Nr(e))throw new Error("Invalid input to safeExtend: expected a plain object");let n=yr(t._zod.def,{get shape(){let o={...t._zod.def.shape,...e};return Rr(this,"shape",o),o}});return Me(t,n)}function AP(t,e){let n=yr(t._zod.def,{get shape(){let o={...t._zod.def.shape,...e._zod.def.shape};return Rr(this,"shape",o),o},get catchall(){return e._zod.def.catchall},checks:[]});return Me(t,n)}function $k(t,e,n){let r=e._zod.def.checks;if(r&&r.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");let a=yr(e._zod.def,{get shape(){let s=e._zod.def.shape,c={...s};if(n)for(let u in n){if(!(u in s))throw new Error(`Unrecognized key: "${u}"`);n[u]&&(c[u]=t?new t({type:"optional",innerType:s[u]}):s[u]);}else for(let u in s)c[u]=t?new t({type:"optional",innerType:s[u]}):s[u];return Rr(this,"shape",c),c},checks:[]});return Me(e,a)}function bk(t,e,n){let o=yr(e._zod.def,{get shape(){let r=e._zod.def.shape,i={...r};if(n)for(let a in n){if(!(a in i))throw new Error(`Unrecognized key: "${a}"`);n[a]&&(i[a]=new t({type:"nonoptional",innerType:r[a]}));}else for(let a in r)i[a]=new t({type:"nonoptional",innerType:r[a]});return Rr(this,"shape",i),i}});return Me(e,o)}function Dr(t,e=0){if(t.aborted===true)return true;for(let n=e;n<t.issues.length;n++)if(t.issues[n]?.continue!==true)return true;return false}function $t(t,e){return e.map(n=>{var o;return (o=n).path??(o.path=[]),n.path.unshift(t),n})}function Ci(t){return typeof t=="string"?t:t?.message}function lt(t,e,n){let o={...t,path:t.path??[]};if(!t.message){let r=Ci(t.inst?._zod.def?.error?.(t))??Ci(e?.error?.(t))??Ci(n.customError?.(t))??Ci(n.localeError?.(t))??"Invalid input";o.message=r;}return delete o.inst,delete o.continue,e?.reportInput||delete o.input,o}function Di(t){return t instanceof Set?"set":t instanceof Map?"map":t instanceof File?"file":"unknown"}function Ai(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function w(t){let e=typeof t;switch(e){case "number":return Number.isNaN(t)?"nan":"number";case "object":{if(t===null)return "null";if(Array.isArray(t))return "array";let n=t;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return e}function Kn(...t){let[e,n,o]=t;return typeof e=="string"?{message:e,code:"custom",input:n,inst:o}:{...e}}function UP(t){return Object.entries(t).filter(([e,n])=>Number.isNaN(Number.parseInt(e,10))).map(e=>e[1])}function xk(t){let e=atob(t),n=new Uint8Array(e.length);for(let o=0;o<e.length;o++)n[o]=e.charCodeAt(o);return n}function wk(t){let e="";for(let n=0;n<t.length;n++)e+=String.fromCharCode(t[n]);return btoa(e)}function ZP(t){let e=t.replace(/-/g,"+").replace(/_/g,"/"),n="=".repeat((4-e.length%4)%4);return xk(e+n)}function MP(t){return wk(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function LP(t){let e=t.replace(/^0x/,"");if(e.length%2!==0)throw new Error("Invalid hex string length");let n=new Uint8Array(e.length/2);for(let o=0;o<e.length;o+=2)n[o/2]=Number.parseInt(e.slice(o,o+2),16);return n}function FP(t){return Array.from(t).map(e=>e.toString(16).padStart(2,"0")).join("")}var hk,uc,pm,NP,Ni,mm,gm,hm,um,U=f(()=>{hk=Symbol("evaluating");uc="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};pm=Gn(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return false;try{let t=Function;return new t(""),!0}catch{return false}});NP=t=>{let e=typeof t;switch(e){case "undefined":return "undefined";case "string":return "string";case "number":return Number.isNaN(t)?"nan":"number";case "boolean":return "boolean";case "function":return "function";case "bigint":return "bigint";case "symbol":return "symbol";case "object":return Array.isArray(t)?"array":t===null?"null":t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?"promise":typeof Map<"u"&&t instanceof Map?"map":typeof Set<"u"&&t instanceof Set?"set":typeof Date<"u"&&t instanceof Date?"date":typeof File<"u"&&t instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${e}`)}},Ni=new Set(["string","number","symbol"]),mm=new Set(["string","number","bigint","boolean","symbol","undefined"]);gm={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},hm={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};um=class{constructor(...e){}};});function Wn(t,e=n=>n.message){let n={},o=[];for(let r of t.issues)r.path.length>0?(n[r.path[0]]=n[r.path[0]]||[],n[r.path[0]].push(e(r))):o.push(e(r));return {formErrors:o,fieldErrors:n}}function Hn(t,e=n=>n.message){let n={_errors:[]},o=r=>{for(let i of r.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>o({issues:a}));else if(i.code==="invalid_key")o({issues:i.issues});else if(i.code==="invalid_element")o({issues:i.issues});else if(i.path.length===0)n._errors.push(e(i));else {let a=n,s=0;for(;s<i.path.length;){let c=i.path[s];s===i.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(e(i))):a[c]=a[c]||{_errors:[]},a=a[c],s++;}}};return o(t),n}function dc(t,e=n=>n.message){let n={errors:[]},o=(r,i=[])=>{var a,s;for(let c of r.issues)if(c.code==="invalid_union"&&c.errors.length)c.errors.map(u=>o({issues:u},c.path));else if(c.code==="invalid_key")o({issues:c.issues},c.path);else if(c.code==="invalid_element")o({issues:c.issues},c.path);else {let u=[...i,...c.path];if(u.length===0){n.errors.push(e(c));continue}let l=n,d=0;for(;d<u.length;){let p=u[d],m=d===u.length-1;typeof p=="string"?(l.properties??(l.properties={}),(a=l.properties)[p]??(a[p]={errors:[]}),l=l.properties[p]):(l.items??(l.items=[]),(s=l.items)[p]??(s[p]={errors:[]}),l=l.items[p]),m&&l.errors.push(e(c)),d++;}}};return o(t),n}function Tk(t){let e=[],n=t.map(o=>typeof o=="object"?o.key:o);for(let o of n)typeof o=="number"?e.push(`[${o}]`):typeof o=="symbol"?e.push(`[${JSON.stringify(String(o))}]`):/[^\w$]/.test(o)?e.push(`[${JSON.stringify(o)}]`):(e.length&&e.push("."),e.push(o));return e.join("")}function pc(t){let e=[],n=[...t.issues].sort((o,r)=>(o.path??[]).length-(r.path??[]).length);for(let o of n)e.push(`\u2716 ${o.message}`),o.path?.length&&e.push(` \u2192 at ${Tk(o.path)}`);return e.join(`
|
|
3
|
+
var vP=Object.create;var am=Object.defineProperty;var _P=Object.getOwnPropertyDescriptor;var kP=Object.getOwnPropertyNames;var $P=Object.getPrototypeOf,bP=Object.prototype.hasOwnProperty;var f=(t,e)=>()=>(t&&(e=t(t=0)),e);var j=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Jt=(t,e)=>{for(var n in e)am(t,n,{get:e[n],enumerable:true});},xP=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of kP(e))!bP.call(t,r)&&r!==n&&am(t,r,{get:()=>e[r],enumerable:!(o=_P(e,r))||o.enumerable});return t};var gk=(t,e,n)=>(n=t!=null?vP($P(t)):{},xP(am(n,"default",{value:t,enumerable:true}),t));var ac,sm=f(()=>{ac="1.14.4";});function g(t,e,n){function o(s,c){if(s._zod||Object.defineProperty(s,"_zod",{value:{def:c,constr:a,traits:new Set},enumerable:false}),s._zod.traits.has(t))return;s._zod.traits.add(t),e(s,c);let u=a.prototype,l=Object.keys(u);for(let d=0;d<l.length;d++){let p=l[d];p in s||(s[p]=u[p].bind(s));}}let r=n?.Parent??Object;class i extends r{}Object.defineProperty(i,"name",{value:t});function a(s){var c;let u=n?.Parent?new i:this;o(u,s),(c=u._zod).deferred??(c.deferred=[]);for(let l of u._zod.deferred)l();return u}return Object.defineProperty(a,"init",{value:o}),Object.defineProperty(a,Symbol.hasInstance,{value:s=>n?.Parent&&s instanceof n.Parent?true:s?._zod?.traits?.has(t)}),Object.defineProperty(a,"name",{value:t}),a}function ze(t){return t&&Object.assign(ji,t),ji}var sc,Ei,Vt,Cr,ji,Vn=f(()=>{sc=Object.freeze({status:"aborted"});Ei=Symbol("zod_brand"),Vt=class extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.");}},Cr=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError";}},ji={};});var b={};Jt(b,{BIGINT_FORMAT_RANGES:()=>hm,Class:()=>um,NUMBER_FORMAT_RANGES:()=>gm,aborted:()=>Dr,allowsEval:()=>pm,assert:()=>zP,assertEqual:()=>wP,assertIs:()=>TP,assertNever:()=>IP,assertNotEqual:()=>SP,assignProp:()=>Rr,base64ToUint8Array:()=>xk,base64urlToUint8Array:()=>ZP,cached:()=>Gn,captureStackTrace:()=>uc,cleanEnum:()=>UP,cleanRegex:()=>Ri,clone:()=>Me,cloneDef:()=>jP,createTransparentProxy:()=>DP,defineLazy:()=>X,esc:()=>cc,escapeRegex:()=>It,extend:()=>_k,finalizeIssue:()=>lt,floatSafeRemainder:()=>lm,getElementAtPath:()=>EP,getEnumValues:()=>Oi,getLengthableOrigin:()=>Ai,getParsedType:()=>NP,getSizableOrigin:()=>Di,hexToUint8Array:()=>LP,isObject:()=>ln,isPlainObject:()=>Nr,issue:()=>Kn,joinValues:()=>v,jsonStringifyReplacer:()=>Bn,merge:()=>AP,mergeDefs:()=>yr,normalizeParams:()=>S,nullish:()=>Or,numKeys:()=>RP,objectClone:()=>PP,omit:()=>vk,optionalKeys:()=>fm,parsedType:()=>w,partial:()=>$k,pick:()=>yk,prefixIssues:()=>$t,primitiveTypes:()=>mm,promiseAllObject:()=>CP,propertyKeyTypes:()=>Ni,randomString:()=>OP,required:()=>bk,safeExtend:()=>kk,shallowClone:()=>lc,slugify:()=>dm,stringifyPrimitive:()=>$,uint8ArrayToBase64:()=>wk,uint8ArrayToBase64url:()=>MP,uint8ArrayToHex:()=>FP,unwrapMessage:()=>Ci});function wP(t){return t}function SP(t){return t}function TP(t){}function IP(t){throw new Error("Unexpected value in exhaustive check")}function zP(t){}function Oi(t){let e=Object.values(t).filter(o=>typeof o=="number");return Object.entries(t).filter(([o,r])=>e.indexOf(+o)===-1).map(([o,r])=>r)}function v(t,e="|"){return t.map(n=>$(n)).join(e)}function Bn(t,e){return typeof e=="bigint"?e.toString():e}function Gn(t){return {get value(){{let n=t();return Object.defineProperty(this,"value",{value:n}),n}}}}function Or(t){return t==null}function Ri(t){let e=t.startsWith("^")?1:0,n=t.endsWith("$")?t.length-1:t.length;return t.slice(e,n)}function lm(t,e){let n=(t.toString().split(".")[1]||"").length,o=e.toString(),r=(o.split(".")[1]||"").length;if(r===0&&/\d?e-\d?/.test(o)){let c=o.match(/\d?e-(\d?)/);c?.[1]&&(r=Number.parseInt(c[1]));}let i=n>r?n:r,a=Number.parseInt(t.toFixed(i).replace(".","")),s=Number.parseInt(e.toFixed(i).replace(".",""));return a%s/10**i}function X(t,e,n){let o;Object.defineProperty(t,e,{get(){if(o!==hk)return o===void 0&&(o=hk,o=n()),o},set(r){Object.defineProperty(t,e,{value:r});},configurable:true});}function PP(t){return Object.create(Object.getPrototypeOf(t),Object.getOwnPropertyDescriptors(t))}function Rr(t,e,n){Object.defineProperty(t,e,{value:n,writable:true,enumerable:true,configurable:true});}function yr(...t){let e={};for(let n of t){let o=Object.getOwnPropertyDescriptors(n);Object.assign(e,o);}return Object.defineProperties({},e)}function jP(t){return yr(t._zod.def)}function EP(t,e){return e?e.reduce((n,o)=>n?.[o],t):t}function CP(t){let e=Object.keys(t),n=e.map(o=>t[o]);return Promise.all(n).then(o=>{let r={};for(let i=0;i<e.length;i++)r[e[i]]=o[i];return r})}function OP(t=10){let e="abcdefghijklmnopqrstuvwxyz",n="";for(let o=0;o<t;o++)n+=e[Math.floor(Math.random()*e.length)];return n}function cc(t){return JSON.stringify(t)}function dm(t){return t.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}function ln(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Nr(t){if(ln(t)===false)return false;let e=t.constructor;if(e===void 0||typeof e!="function")return true;let n=e.prototype;return !(ln(n)===false||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===false)}function lc(t){return Nr(t)?{...t}:Array.isArray(t)?[...t]:t}function RP(t){let e=0;for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&e++;return e}function It(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Me(t,e,n){let o=new t._zod.constr(e??t._zod.def);return (!e||n?.parent)&&(o._zod.parent=t),o}function S(t){let e=t;if(!e)return {};if(typeof e=="string")return {error:()=>e};if(e?.message!==void 0){if(e?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");e.error=e.message;}return delete e.message,typeof e.error=="string"?{...e,error:()=>e.error}:e}function DP(t){let e;return new Proxy({},{get(n,o,r){return e??(e=t()),Reflect.get(e,o,r)},set(n,o,r,i){return e??(e=t()),Reflect.set(e,o,r,i)},has(n,o){return e??(e=t()),Reflect.has(e,o)},deleteProperty(n,o){return e??(e=t()),Reflect.deleteProperty(e,o)},ownKeys(n){return e??(e=t()),Reflect.ownKeys(e)},getOwnPropertyDescriptor(n,o){return e??(e=t()),Reflect.getOwnPropertyDescriptor(e,o)},defineProperty(n,o,r){return e??(e=t()),Reflect.defineProperty(e,o,r)}})}function $(t){return typeof t=="bigint"?t.toString()+"n":typeof t=="string"?`"${t}"`:`${t}`}function fm(t){return Object.keys(t).filter(e=>t[e]._zod.optin==="optional"&&t[e]._zod.optout==="optional")}function yk(t,e){let n=t._zod.def,o=n.checks;if(o&&o.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");let i=yr(t._zod.def,{get shape(){let a={};for(let s in e){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);e[s]&&(a[s]=n.shape[s]);}return Rr(this,"shape",a),a},checks:[]});return Me(t,i)}function vk(t,e){let n=t._zod.def,o=n.checks;if(o&&o.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");let i=yr(t._zod.def,{get shape(){let a={...t._zod.def.shape};for(let s in e){if(!(s in n.shape))throw new Error(`Unrecognized key: "${s}"`);e[s]&&delete a[s];}return Rr(this,"shape",a),a},checks:[]});return Me(t,i)}function _k(t,e){if(!Nr(e))throw new Error("Invalid input to extend: expected a plain object");let n=t._zod.def.checks;if(n&&n.length>0){let i=t._zod.def.shape;for(let a in e)if(Object.getOwnPropertyDescriptor(i,a)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let r=yr(t._zod.def,{get shape(){let i={...t._zod.def.shape,...e};return Rr(this,"shape",i),i}});return Me(t,r)}function kk(t,e){if(!Nr(e))throw new Error("Invalid input to safeExtend: expected a plain object");let n=yr(t._zod.def,{get shape(){let o={...t._zod.def.shape,...e};return Rr(this,"shape",o),o}});return Me(t,n)}function AP(t,e){let n=yr(t._zod.def,{get shape(){let o={...t._zod.def.shape,...e._zod.def.shape};return Rr(this,"shape",o),o},get catchall(){return e._zod.def.catchall},checks:[]});return Me(t,n)}function $k(t,e,n){let r=e._zod.def.checks;if(r&&r.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");let a=yr(e._zod.def,{get shape(){let s=e._zod.def.shape,c={...s};if(n)for(let u in n){if(!(u in s))throw new Error(`Unrecognized key: "${u}"`);n[u]&&(c[u]=t?new t({type:"optional",innerType:s[u]}):s[u]);}else for(let u in s)c[u]=t?new t({type:"optional",innerType:s[u]}):s[u];return Rr(this,"shape",c),c},checks:[]});return Me(e,a)}function bk(t,e,n){let o=yr(e._zod.def,{get shape(){let r=e._zod.def.shape,i={...r};if(n)for(let a in n){if(!(a in i))throw new Error(`Unrecognized key: "${a}"`);n[a]&&(i[a]=new t({type:"nonoptional",innerType:r[a]}));}else for(let a in r)i[a]=new t({type:"nonoptional",innerType:r[a]});return Rr(this,"shape",i),i}});return Me(e,o)}function Dr(t,e=0){if(t.aborted===true)return true;for(let n=e;n<t.issues.length;n++)if(t.issues[n]?.continue!==true)return true;return false}function $t(t,e){return e.map(n=>{var o;return (o=n).path??(o.path=[]),n.path.unshift(t),n})}function Ci(t){return typeof t=="string"?t:t?.message}function lt(t,e,n){let o={...t,path:t.path??[]};if(!t.message){let r=Ci(t.inst?._zod.def?.error?.(t))??Ci(e?.error?.(t))??Ci(n.customError?.(t))??Ci(n.localeError?.(t))??"Invalid input";o.message=r;}return delete o.inst,delete o.continue,e?.reportInput||delete o.input,o}function Di(t){return t instanceof Set?"set":t instanceof Map?"map":t instanceof File?"file":"unknown"}function Ai(t){return Array.isArray(t)?"array":typeof t=="string"?"string":"unknown"}function w(t){let e=typeof t;switch(e){case "number":return Number.isNaN(t)?"nan":"number";case "object":{if(t===null)return "null";if(Array.isArray(t))return "array";let n=t;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return e}function Kn(...t){let[e,n,o]=t;return typeof e=="string"?{message:e,code:"custom",input:n,inst:o}:{...e}}function UP(t){return Object.entries(t).filter(([e,n])=>Number.isNaN(Number.parseInt(e,10))).map(e=>e[1])}function xk(t){let e=atob(t),n=new Uint8Array(e.length);for(let o=0;o<e.length;o++)n[o]=e.charCodeAt(o);return n}function wk(t){let e="";for(let n=0;n<t.length;n++)e+=String.fromCharCode(t[n]);return btoa(e)}function ZP(t){let e=t.replace(/-/g,"+").replace(/_/g,"/"),n="=".repeat((4-e.length%4)%4);return xk(e+n)}function MP(t){return wk(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function LP(t){let e=t.replace(/^0x/,"");if(e.length%2!==0)throw new Error("Invalid hex string length");let n=new Uint8Array(e.length/2);for(let o=0;o<e.length;o+=2)n[o/2]=Number.parseInt(e.slice(o,o+2),16);return n}function FP(t){return Array.from(t).map(e=>e.toString(16).padStart(2,"0")).join("")}var hk,uc,pm,NP,Ni,mm,gm,hm,um,U=f(()=>{hk=Symbol("evaluating");uc="captureStackTrace"in Error?Error.captureStackTrace:(...t)=>{};pm=Gn(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return false;try{let t=Function;return new t(""),!0}catch{return false}});NP=t=>{let e=typeof t;switch(e){case "undefined":return "undefined";case "string":return "string";case "number":return Number.isNaN(t)?"nan":"number";case "boolean":return "boolean";case "function":return "function";case "bigint":return "bigint";case "symbol":return "symbol";case "object":return Array.isArray(t)?"array":t===null?"null":t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?"promise":typeof Map<"u"&&t instanceof Map?"map":typeof Set<"u"&&t instanceof Set?"set":typeof Date<"u"&&t instanceof Date?"date":typeof File<"u"&&t instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${e}`)}},Ni=new Set(["string","number","symbol"]),mm=new Set(["string","number","bigint","boolean","symbol","undefined"]);gm={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},hm={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};um=class{constructor(...e){}};});function Wn(t,e=n=>n.message){let n={},o=[];for(let r of t.issues)r.path.length>0?(n[r.path[0]]=n[r.path[0]]||[],n[r.path[0]].push(e(r))):o.push(e(r));return {formErrors:o,fieldErrors:n}}function Hn(t,e=n=>n.message){let n={_errors:[]},o=r=>{for(let i of r.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>o({issues:a}));else if(i.code==="invalid_key")o({issues:i.issues});else if(i.code==="invalid_element")o({issues:i.issues});else if(i.path.length===0)n._errors.push(e(i));else {let a=n,s=0;for(;s<i.path.length;){let c=i.path[s];s===i.path.length-1?(a[c]=a[c]||{_errors:[]},a[c]._errors.push(e(i))):a[c]=a[c]||{_errors:[]},a=a[c],s++;}}};return o(t),n}function dc(t,e=n=>n.message){let n={errors:[]},o=(r,i=[])=>{var a,s;for(let c of r.issues)if(c.code==="invalid_union"&&c.errors.length)c.errors.map(u=>o({issues:u},c.path));else if(c.code==="invalid_key")o({issues:c.issues},c.path);else if(c.code==="invalid_element")o({issues:c.issues},c.path);else {let u=[...i,...c.path];if(u.length===0){n.errors.push(e(c));continue}let l=n,d=0;for(;d<u.length;){let p=u[d],m=d===u.length-1;typeof p=="string"?(l.properties??(l.properties={}),(a=l.properties)[p]??(a[p]={errors:[]}),l=l.properties[p]):(l.items??(l.items=[]),(s=l.items)[p]??(s[p]={errors:[]}),l=l.items[p]),m&&l.errors.push(e(c)),d++;}}};return o(t),n}function Tk(t){let e=[],n=t.map(o=>typeof o=="object"?o.key:o);for(let o of n)typeof o=="number"?e.push(`[${o}]`):typeof o=="symbol"?e.push(`[${JSON.stringify(String(o))}]`):/[^\w$]/.test(o)?e.push(`[${JSON.stringify(o)}]`):(e.length&&e.push("."),e.push(o));return e.join("")}function pc(t){let e=[],n=[...t.issues].sort((o,r)=>(o.path??[]).length-(r.path??[]).length);for(let o of n)e.push(`\u2716 ${o.message}`),o.path?.length&&e.push(` \u2192 at ${Tk(o.path)}`);return e.join(`
|
|
4
4
|
`)}var Sk,Ui,dt,ym=f(()=>{Vn();U();Sk=(t,e)=>{t.name="$ZodError",Object.defineProperty(t,"_zod",{value:t._zod,enumerable:false}),Object.defineProperty(t,"issues",{value:e,enumerable:false}),t.message=JSON.stringify(e,Bn,2),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:false});},Ui=g("$ZodError",Sk),dt=g("$ZodError",Sk,{Parent:Error});});var Xn,Yn,Qn,eo,to,dn,ro,no,mc,Ik,fc,zk,gc,Pk,hc,jk,yc,Ek,vc,Ck,_c,Ok,kc,Rk,vm=f(()=>{Vn();ym();U();Xn=t=>(e,n,o,r)=>{let i=o?Object.assign(o,{async:false}):{async:false},a=e._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Vt;if(a.issues.length){let s=new(r?.Err??t)(a.issues.map(c=>lt(c,i,ze())));throw uc(s,r?.callee),s}return a.value},Yn=Xn(dt),Qn=t=>async(e,n,o,r)=>{let i=o?Object.assign(o,{async:true}):{async:true},a=e._zod.run({value:n,issues:[]},i);if(a instanceof Promise&&(a=await a),a.issues.length){let s=new(r?.Err??t)(a.issues.map(c=>lt(c,i,ze())));throw uc(s,r?.callee),s}return a.value},eo=Qn(dt),to=t=>(e,n,o)=>{let r=o?{...o,async:false}:{async:false},i=e._zod.run({value:n,issues:[]},r);if(i instanceof Promise)throw new Vt;return i.issues.length?{success:false,error:new(t??Ui)(i.issues.map(a=>lt(a,r,ze())))}:{success:true,data:i.value}},dn=to(dt),ro=t=>async(e,n,o)=>{let r=o?Object.assign(o,{async:true}):{async:true},i=e._zod.run({value:n,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length?{success:false,error:new t(i.issues.map(a=>lt(a,r,ze())))}:{success:true,data:i.value}},no=ro(dt),mc=t=>(e,n,o)=>{let r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return Xn(t)(e,n,r)},Ik=mc(dt),fc=t=>(e,n,o)=>Xn(t)(e,n,o),zk=fc(dt),gc=t=>async(e,n,o)=>{let r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return Qn(t)(e,n,r)},Pk=gc(dt),hc=t=>async(e,n,o)=>Qn(t)(e,n,o),jk=hc(dt),yc=t=>(e,n,o)=>{let r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return to(t)(e,n,r)},Ek=yc(dt),vc=t=>(e,n,o)=>to(t)(e,n,o),Ck=vc(dt),_c=t=>async(e,n,o)=>{let r=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return ro(t)(e,n,r)},Ok=_c(dt),kc=t=>async(e,n,o)=>ro(t)(e,n,o),Rk=kc(dt);});var pt={};Jt(pt,{base64:()=>Rm,base64url:()=>$c,bigint:()=>Mm,boolean:()=>Fm,browserEmail:()=>XP,cidrv4:()=>Cm,cidrv6:()=>Om,cuid:()=>_m,cuid2:()=>km,date:()=>Dm,datetime:()=>Um,domain:()=>ej,duration:()=>Sm,e164:()=>Nm,email:()=>Im,emoji:()=>zm,extendedDuration:()=>JP,guid:()=>Tm,hex:()=>tj,hostname:()=>QP,html5Email:()=>KP,idnEmail:()=>HP,integer:()=>Lm,ipv4:()=>Pm,ipv6:()=>jm,ksuid:()=>xm,lowercase:()=>Vm,mac:()=>Em,md5_base64:()=>nj,md5_base64url:()=>oj,md5_hex:()=>rj,nanoid:()=>wm,null:()=>qm,number:()=>bc,rfc5322Email:()=>WP,sha1_base64:()=>aj,sha1_base64url:()=>sj,sha1_hex:()=>ij,sha256_base64:()=>uj,sha256_base64url:()=>lj,sha256_hex:()=>cj,sha384_base64:()=>pj,sha384_base64url:()=>mj,sha384_hex:()=>dj,sha512_base64:()=>gj,sha512_base64url:()=>hj,sha512_hex:()=>fj,string:()=>Zm,time:()=>Am,ulid:()=>$m,undefined:()=>Jm,unicodeEmail:()=>Nk,uppercase:()=>Bm,uuid:()=>pn,uuid4:()=>VP,uuid6:()=>BP,uuid7:()=>GP,xid:()=>bm});function zm(){return new RegExp(YP,"u")}function Ak(t){let e="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof t.precision=="number"?t.precision===-1?`${e}`:t.precision===0?`${e}:[0-5]\\d`:`${e}:[0-5]\\d\\.\\d{${t.precision}}`:`${e}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Am(t){return new RegExp(`^${Ak(t)}$`)}function Um(t){let e=Ak({precision:t.precision}),n=["Z"];t.local&&n.push(""),t.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let o=`${e}(?:${n.join("|")})`;return new RegExp(`^${Dk}T(?:${o})$`)}function Zi(t,e){return new RegExp(`^[A-Za-z0-9+/]{${t}}${e}$`)}function Mi(t){return new RegExp(`^[A-Za-z0-9_-]{${t}}$`)}var _m,km,$m,bm,xm,wm,Sm,JP,Tm,pn,VP,BP,GP,Im,KP,WP,Nk,HP,XP,YP,Pm,jm,Em,Cm,Om,Rm,$c,QP,ej,Nm,Dk,Dm,Zm,Mm,Lm,bc,Fm,qm,Jm,Vm,Bm,tj,rj,nj,oj,ij,aj,sj,cj,uj,lj,dj,pj,mj,fj,gj,hj,xc=f(()=>{U();_m=/^[cC][^\s-]{8,}$/,km=/^[0-9a-z]+$/,$m=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,bm=/^[0-9a-vA-V]{20}$/,xm=/^[A-Za-z0-9]{27}$/,wm=/^[a-zA-Z0-9_-]{21}$/,Sm=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,JP=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Tm=/^([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})$/,pn=t=>t?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${t}[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)$/,VP=pn(4),BP=pn(6),GP=pn(7),Im=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,KP=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,WP=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,Nk=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,HP=Nk,XP=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,YP="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";Pm=/^(?:(?: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])$/,jm=/^(([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}|:))$/,Em=t=>{let e=It(t??":");return new RegExp(`^(?:[0-9A-F]{2}${e}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${e}){5}[0-9a-f]{2}$`)},Cm=/^((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])$/,Om=/^(([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])$/,Rm=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,$c=/^[A-Za-z0-9_-]*$/,QP=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,ej=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,Nm=/^\+[1-9]\d{6,14}$/,Dk="(?:(?:\\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])))",Dm=new RegExp(`^${Dk}$`);Zm=t=>{let e=t?`[\\s\\S]{${t?.minimum??0},${t?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${e}$`)},Mm=/^-?\d+n?$/,Lm=/^-?\d+$/,bc=/^-?\d+(?:\.\d+)?$/,Fm=/^(?:true|false)$/i,qm=/^null$/i,Jm=/^undefined$/i,Vm=/^[^A-Z]*$/,Bm=/^[^a-z]*$/,tj=/^[0-9a-fA-F]*$/;rj=/^[0-9a-fA-F]{32}$/,nj=Zi(22,"=="),oj=Mi(22),ij=/^[0-9a-fA-F]{40}$/,aj=Zi(27,"="),sj=Mi(27),cj=/^[0-9a-fA-F]{64}$/,uj=Zi(43,"="),lj=Mi(43),dj=/^[0-9a-fA-F]{96}$/,pj=Zi(64,""),mj=Mi(64),fj=/^[0-9a-fA-F]{128}$/,gj=Zi(86,"=="),hj=Mi(86);});function Uk(t,e,n){t.issues.length&&e.issues.push(...$t(n,t.issues));}var ve,Zk,wc,Sc,Gm,Km,Wm,Hm,Xm,Ym,Qm,ef,tf,oo,rf,nf,of,af,sf,cf,uf,lf,df,Tc=f(()=>{Vn();xc();U();ve=g("$ZodCheck",(t,e)=>{var n;t._zod??(t._zod={}),t._zod.def=e,(n=t._zod).onattach??(n.onattach=[]);}),Zk={number:"number",bigint:"bigint",object:"date"},wc=g("$ZodCheckLessThan",(t,e)=>{ve.init(t,e);let n=Zk[typeof e.value];t._zod.onattach.push(o=>{let r=o._zod.bag,i=(e.inclusive?r.maximum:r.exclusiveMaximum)??Number.POSITIVE_INFINITY;e.value<i&&(e.inclusive?r.maximum=e.value:r.exclusiveMaximum=e.value);}),t._zod.check=o=>{(e.inclusive?o.value<=e.value:o.value<e.value)||o.issues.push({origin:n,code:"too_big",maximum:typeof e.value=="object"?e.value.getTime():e.value,input:o.value,inclusive:e.inclusive,inst:t,continue:!e.abort});};}),Sc=g("$ZodCheckGreaterThan",(t,e)=>{ve.init(t,e);let n=Zk[typeof e.value];t._zod.onattach.push(o=>{let r=o._zod.bag,i=(e.inclusive?r.minimum:r.exclusiveMinimum)??Number.NEGATIVE_INFINITY;e.value>i&&(e.inclusive?r.minimum=e.value:r.exclusiveMinimum=e.value);}),t._zod.check=o=>{(e.inclusive?o.value>=e.value:o.value>e.value)||o.issues.push({origin:n,code:"too_small",minimum:typeof e.value=="object"?e.value.getTime():e.value,input:o.value,inclusive:e.inclusive,inst:t,continue:!e.abort});};}),Gm=g("$ZodCheckMultipleOf",(t,e)=>{ve.init(t,e),t._zod.onattach.push(n=>{var o;(o=n._zod.bag).multipleOf??(o.multipleOf=e.value);}),t._zod.check=n=>{if(typeof n.value!=typeof e.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%e.value===BigInt(0):lm(n.value,e.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:e.value,input:n.value,inst:t,continue:!e.abort});};}),Km=g("$ZodCheckNumberFormat",(t,e)=>{ve.init(t,e),e.format=e.format||"float64";let n=e.format?.includes("int"),o=n?"int":"number",[r,i]=gm[e.format];t._zod.onattach.push(a=>{let s=a._zod.bag;s.format=e.format,s.minimum=r,s.maximum=i,n&&(s.pattern=Lm);}),t._zod.check=a=>{let s=a.value;if(n){if(!Number.isInteger(s)){a.issues.push({expected:o,format:e.format,code:"invalid_type",continue:false,input:s,inst:t});return}if(!Number.isSafeInteger(s)){s>0?a.issues.push({input:s,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:o,inclusive:true,continue:!e.abort}):a.issues.push({input:s,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:t,origin:o,inclusive:true,continue:!e.abort});return}}s<r&&a.issues.push({origin:"number",input:s,code:"too_small",minimum:r,inclusive:true,inst:t,continue:!e.abort}),s>i&&a.issues.push({origin:"number",input:s,code:"too_big",maximum:i,inclusive:true,inst:t,continue:!e.abort});};}),Wm=g("$ZodCheckBigIntFormat",(t,e)=>{ve.init(t,e);let[n,o]=hm[e.format];t._zod.onattach.push(r=>{let i=r._zod.bag;i.format=e.format,i.minimum=n,i.maximum=o;}),t._zod.check=r=>{let i=r.value;i<n&&r.issues.push({origin:"bigint",input:i,code:"too_small",minimum:n,inclusive:true,inst:t,continue:!e.abort}),i>o&&r.issues.push({origin:"bigint",input:i,code:"too_big",maximum:o,inclusive:true,inst:t,continue:!e.abort});};}),Hm=g("$ZodCheckMaxSize",(t,e)=>{var n;ve.init(t,e),(n=t._zod.def).when??(n.when=o=>{let r=o.value;return !Or(r)&&r.size!==void 0}),t._zod.onattach.push(o=>{let r=o._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<r&&(o._zod.bag.maximum=e.maximum);}),t._zod.check=o=>{let r=o.value;r.size<=e.maximum||o.issues.push({origin:Di(r),code:"too_big",maximum:e.maximum,inclusive:true,input:r,inst:t,continue:!e.abort});};}),Xm=g("$ZodCheckMinSize",(t,e)=>{var n;ve.init(t,e),(n=t._zod.def).when??(n.when=o=>{let r=o.value;return !Or(r)&&r.size!==void 0}),t._zod.onattach.push(o=>{let r=o._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>r&&(o._zod.bag.minimum=e.minimum);}),t._zod.check=o=>{let r=o.value;r.size>=e.minimum||o.issues.push({origin:Di(r),code:"too_small",minimum:e.minimum,inclusive:true,input:r,inst:t,continue:!e.abort});};}),Ym=g("$ZodCheckSizeEquals",(t,e)=>{var n;ve.init(t,e),(n=t._zod.def).when??(n.when=o=>{let r=o.value;return !Or(r)&&r.size!==void 0}),t._zod.onattach.push(o=>{let r=o._zod.bag;r.minimum=e.size,r.maximum=e.size,r.size=e.size;}),t._zod.check=o=>{let r=o.value,i=r.size;if(i===e.size)return;let a=i>e.size;o.issues.push({origin:Di(r),...a?{code:"too_big",maximum:e.size}:{code:"too_small",minimum:e.size},inclusive:true,exact:true,input:o.value,inst:t,continue:!e.abort});};}),Qm=g("$ZodCheckMaxLength",(t,e)=>{var n;ve.init(t,e),(n=t._zod.def).when??(n.when=o=>{let r=o.value;return !Or(r)&&r.length!==void 0}),t._zod.onattach.push(o=>{let r=o._zod.bag.maximum??Number.POSITIVE_INFINITY;e.maximum<r&&(o._zod.bag.maximum=e.maximum);}),t._zod.check=o=>{let r=o.value;if(r.length<=e.maximum)return;let a=Ai(r);o.issues.push({origin:a,code:"too_big",maximum:e.maximum,inclusive:true,input:r,inst:t,continue:!e.abort});};}),ef=g("$ZodCheckMinLength",(t,e)=>{var n;ve.init(t,e),(n=t._zod.def).when??(n.when=o=>{let r=o.value;return !Or(r)&&r.length!==void 0}),t._zod.onattach.push(o=>{let r=o._zod.bag.minimum??Number.NEGATIVE_INFINITY;e.minimum>r&&(o._zod.bag.minimum=e.minimum);}),t._zod.check=o=>{let r=o.value;if(r.length>=e.minimum)return;let a=Ai(r);o.issues.push({origin:a,code:"too_small",minimum:e.minimum,inclusive:true,input:r,inst:t,continue:!e.abort});};}),tf=g("$ZodCheckLengthEquals",(t,e)=>{var n;ve.init(t,e),(n=t._zod.def).when??(n.when=o=>{let r=o.value;return !Or(r)&&r.length!==void 0}),t._zod.onattach.push(o=>{let r=o._zod.bag;r.minimum=e.length,r.maximum=e.length,r.length=e.length;}),t._zod.check=o=>{let r=o.value,i=r.length;if(i===e.length)return;let a=Ai(r),s=i>e.length;o.issues.push({origin:a,...s?{code:"too_big",maximum:e.length}:{code:"too_small",minimum:e.length},inclusive:true,exact:true,input:o.value,inst:t,continue:!e.abort});};}),oo=g("$ZodCheckStringFormat",(t,e)=>{var n,o;ve.init(t,e),t._zod.onattach.push(r=>{let i=r._zod.bag;i.format=e.format,e.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(e.pattern));}),e.pattern?(n=t._zod).check??(n.check=r=>{e.pattern.lastIndex=0,!e.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:e.format,input:r.value,...e.pattern?{pattern:e.pattern.toString()}:{},inst:t,continue:!e.abort});}):(o=t._zod).check??(o.check=()=>{});}),rf=g("$ZodCheckRegex",(t,e)=>{oo.init(t,e),t._zod.check=n=>{e.pattern.lastIndex=0,!e.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:e.pattern.toString(),inst:t,continue:!e.abort});};}),nf=g("$ZodCheckLowerCase",(t,e)=>{e.pattern??(e.pattern=Vm),oo.init(t,e);}),of=g("$ZodCheckUpperCase",(t,e)=>{e.pattern??(e.pattern=Bm),oo.init(t,e);}),af=g("$ZodCheckIncludes",(t,e)=>{ve.init(t,e);let n=It(e.includes),o=new RegExp(typeof e.position=="number"?`^.{${e.position}}${n}`:n);e.pattern=o,t._zod.onattach.push(r=>{let i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(o);}),t._zod.check=r=>{r.value.includes(e.includes,e.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:e.includes,input:r.value,inst:t,continue:!e.abort});};}),sf=g("$ZodCheckStartsWith",(t,e)=>{ve.init(t,e);let n=new RegExp(`^${It(e.prefix)}.*`);e.pattern??(e.pattern=n),t._zod.onattach.push(o=>{let r=o._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n);}),t._zod.check=o=>{o.value.startsWith(e.prefix)||o.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:e.prefix,input:o.value,inst:t,continue:!e.abort});};}),cf=g("$ZodCheckEndsWith",(t,e)=>{ve.init(t,e);let n=new RegExp(`.*${It(e.suffix)}$`);e.pattern??(e.pattern=n),t._zod.onattach.push(o=>{let r=o._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n);}),t._zod.check=o=>{o.value.endsWith(e.suffix)||o.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:e.suffix,input:o.value,inst:t,continue:!e.abort});};});uf=g("$ZodCheckProperty",(t,e)=>{ve.init(t,e),t._zod.check=n=>{let o=e.schema._zod.run({value:n.value[e.property],issues:[]},{});if(o instanceof Promise)return o.then(r=>Uk(r,n,e.property));Uk(o,n,e.property);};}),lf=g("$ZodCheckMimeType",(t,e)=>{ve.init(t,e);let n=new Set(e.mime);t._zod.onattach.push(o=>{o._zod.bag.mime=e.mime;}),t._zod.check=o=>{n.has(o.value.type)||o.issues.push({code:"invalid_value",values:e.mime,input:o.value.type,inst:t,continue:!e.abort});};}),df=g("$ZodCheckOverwrite",(t,e)=>{ve.init(t,e),t._zod.check=n=>{n.value=e.tx(n.value);};});});var Li,pf=f(()=>{Li=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e);}indented(e){this.indent+=1,e(this),this.indent-=1;}write(e){if(typeof e=="function"){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let o=e.split(`
|
|
5
5
|
`).filter(a=>a),r=Math.min(...o.map(a=>a.length-a.trimStart().length)),i=o.map(a=>a.slice(r)).map(a=>" ".repeat(this.indent*2)+a);for(let a of i)this.content.push(a);}compile(){let e=Function,n=this?.args,r=[...(this?.content??[""]).map(i=>` ${i}`)];return new e(...n,r.join(`
|
|
6
6
|
`))}};});var mf,ff=f(()=>{mf={major:4,minor:3,patch:6};});function hf(t){if(t==="")return true;if(t.length%4!==0)return false;try{return atob(t),!0}catch{return false}}function Yk(t){if(!$c.test(t))return false;let e=t.replace(/[-_]/g,o=>o==="-"?"+":"/"),n=e.padEnd(Math.ceil(e.length/4)*4,"=");return hf(n)}function Qk(t,e=null){try{let n=t.split(".");if(n.length!==3)return !1;let[o]=n;if(!o)return !1;let r=JSON.parse(atob(o));return !("typ"in r&&r?.typ!=="JWT"||!r.alg||e&&(!("alg"in r)||r.alg!==e))}catch{return false}}function Lk(t,e,n){t.issues.length&&e.issues.push(...$t(n,t.issues)),e.value[n]=t.value;}function Ec(t,e,n,o,r){if(t.issues.length){if(r&&!(n in o))return;e.issues.push(...$t(n,t.issues));}t.value===void 0?n in o&&(e.value[n]=void 0):e.value[n]=t.value;}function e$(t){let e=Object.keys(t.shape);for(let o of e)if(!t.shape?.[o]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${o}": expected a Zod schema`);let n=fm(t.shape);return {...t,keys:e,keySet:new Set(e),numKeys:e.length,optionalKeys:new Set(n)}}function t$(t,e,n,o,r,i){let a=[],s=r.keySet,c=r.catchall._zod,u=c.def.type,l=c.optout==="optional";for(let d in e){if(s.has(d))continue;if(u==="never"){a.push(d);continue}let p=c.run({value:e[d],issues:[]},o);p instanceof Promise?t.push(p.then(m=>Ec(m,n,d,e,l))):Ec(p,n,d,e,l);}return a.length&&n.issues.push({code:"unrecognized_keys",keys:a,input:e,inst:i}),t.length?Promise.all(t).then(()=>n):n}function Fk(t,e,n,o){for(let i of t)if(i.issues.length===0)return e.value=i.value,e;let r=t.filter(i=>!Dr(i));return r.length===1?(e.value=r[0].value,r[0]):(e.issues.push({code:"invalid_union",input:e.value,inst:n,errors:t.map(i=>i.issues.map(a=>lt(a,o,ze())))}),e)}function qk(t,e,n,o){let r=t.filter(i=>i.issues.length===0);return r.length===1?(e.value=r[0].value,e):(r.length===0?e.issues.push({code:"invalid_union",input:e.value,inst:n,errors:t.map(i=>i.issues.map(a=>lt(a,o,ze())))}):e.issues.push({code:"invalid_union",input:e.value,inst:n,errors:[],inclusive:false}),e)}function gf(t,e){if(t===e)return {valid:true,data:t};if(t instanceof Date&&e instanceof Date&&+t==+e)return {valid:true,data:t};if(Nr(t)&&Nr(e)){let n=Object.keys(e),o=Object.keys(t).filter(i=>n.indexOf(i)!==-1),r={...t,...e};for(let i of o){let a=gf(t[i],e[i]);if(!a.valid)return {valid:false,mergeErrorPath:[i,...a.mergeErrorPath]};r[i]=a.data;}return {valid:true,data:r}}if(Array.isArray(t)&&Array.isArray(e)){if(t.length!==e.length)return {valid:false,mergeErrorPath:[]};let n=[];for(let o=0;o<t.length;o++){let r=t[o],i=e[o],a=gf(r,i);if(!a.valid)return {valid:false,mergeErrorPath:[o,...a.mergeErrorPath]};n.push(a.data);}return {valid:true,data:n}}return {valid:false,mergeErrorPath:[]}}function Jk(t,e,n){let o=new Map,r;for(let s of e.issues)if(s.code==="unrecognized_keys"){r??(r=s);for(let c of s.keys)o.has(c)||o.set(c,{}),o.get(c).l=true;}else t.issues.push(s);for(let s of n.issues)if(s.code==="unrecognized_keys")for(let c of s.keys)o.has(c)||o.set(c,{}),o.get(c).r=true;else t.issues.push(s);let i=[...o].filter(([,s])=>s.l&&s.r).map(([s])=>s);if(i.length&&r&&t.issues.push({...r,keys:i}),Dr(t))return t;let a=gf(e.value,n.value);if(!a.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(a.mergeErrorPath)}`);return t.value=a.data,t}function Ic(t,e,n){t.issues.length&&e.issues.push(...$t(n,t.issues)),e.value[n]=t.value;}function Vk(t,e,n,o,r,i,a){t.issues.length&&(Ni.has(typeof o)?n.issues.push(...$t(o,t.issues)):n.issues.push({code:"invalid_key",origin:"map",input:r,inst:i,issues:t.issues.map(s=>lt(s,a,ze()))})),e.issues.length&&(Ni.has(typeof o)?n.issues.push(...$t(o,e.issues)):n.issues.push({origin:"map",code:"invalid_element",input:r,inst:i,key:o,issues:e.issues.map(s=>lt(s,a,ze()))})),n.value.set(t.value,e.value);}function Bk(t,e){t.issues.length&&e.issues.push(...t.issues),e.value.add(t.value);}function Gk(t,e){return t.issues.length&&e===void 0?{issues:[],value:void 0}:t}function Kk(t,e){return t.value===void 0&&(t.value=e.defaultValue),t}function Wk(t,e){return !t.issues.length&&t.value===void 0&&t.issues.push({code:"invalid_type",expected:"nonoptional",input:t.value,inst:e}),t}function zc(t,e,n){return t.issues.length?(t.aborted=true,t):e._zod.run({value:t.value,issues:t.issues},n)}function Pc(t,e,n){if(t.issues.length)return t.aborted=true,t;if((n.direction||"forward")==="forward"){let r=e.transform(t.value,t);return r instanceof Promise?r.then(i=>jc(t,i,e.out,n)):jc(t,r,e.out,n)}else {let r=e.reverseTransform(t.value,t);return r instanceof Promise?r.then(i=>jc(t,i,e.in,n)):jc(t,r,e.in,n)}}function jc(t,e,n,o){return t.issues.length?(t.aborted=true,t):n._zod.run({value:e,issues:t.issues},o)}function Hk(t){return t.value=Object.freeze(t.value),t}function Xk(t,e,n,o){if(!t){let r={code:"custom",input:n,inst:o,path:[...o._zod.def.path??[]],continue:!o._zod.def.abort};o._zod.def.params&&(r.params=o._zod.def.params),e.issues.push(Kn(r));}}var B,Ar,he,Cc,Oc,Rc,Nc,Dc,Ac,Uc,Zc,Mc,Lc,Fc,qc,Jc,Vc,Bc,Gc,Kc,Wc,Hc,Xc,Yc,Qc,eu,tu,ru,Fi,nu,io,qi,ou,iu,au,su,cu,uu,lu,du,pu,mu,yf,vf,ao,fu,gu,hu,Ji,yu,vu,_u,ku,$u,bu,xu,Vi,wu,Su,Tu,Iu,zu,Pu,ju,Eu,Cu,so,Ou,Ru,Nu,Du,Au,Uu,_f=f(()=>{Tc();Vn();pf();vm();xc();U();ff();U();B=g("$ZodType",(t,e)=>{var n;t??(t={}),t._zod.def=e,t._zod.bag=t._zod.bag||{},t._zod.version=mf;let o=[...t._zod.def.checks??[]];t._zod.traits.has("$ZodCheck")&&o.unshift(t);for(let r of o)for(let i of r._zod.onattach)i(t);if(o.length===0)(n=t._zod).deferred??(n.deferred=[]),t._zod.deferred?.push(()=>{t._zod.run=t._zod.parse;});else {let r=(a,s,c)=>{let u=Dr(a),l;for(let d of s){if(d._zod.def.when){if(!d._zod.def.when(a))continue}else if(u)continue;let p=a.issues.length,m=d._zod.check(a);if(m instanceof Promise&&c?.async===false)throw new Vt;if(l||m instanceof Promise)l=(l??Promise.resolve()).then(async()=>{await m,a.issues.length!==p&&(u||(u=Dr(a,p)));});else {if(a.issues.length===p)continue;u||(u=Dr(a,p));}}return l?l.then(()=>a):a},i=(a,s,c)=>{if(Dr(a))return a.aborted=true,a;let u=r(s,o,c);if(u instanceof Promise){if(c.async===false)throw new Vt;return u.then(l=>t._zod.parse(l,c))}return t._zod.parse(u,c)};t._zod.run=(a,s)=>{if(s.skipChecks)return t._zod.parse(a,s);if(s.direction==="backward"){let u=t._zod.parse({value:a.value,issues:[]},{...s,skipChecks:true});return u instanceof Promise?u.then(l=>i(l,a,s)):i(u,a,s)}let c=t._zod.parse(a,s);if(c instanceof Promise){if(s.async===false)throw new Vt;return c.then(u=>r(u,o,s))}return r(c,o,s)};}X(t,"~standard",()=>({validate:r=>{try{let i=dn(t,r);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return no(t,r).then(a=>a.success?{value:a.data}:{issues:a.error?.issues})}},vendor:"zod",version:1}));}),Ar=g("$ZodString",(t,e)=>{B.init(t,e),t._zod.pattern=[...t?._zod.bag?.patterns??[]].pop()??Zm(t._zod.bag),t._zod.parse=(n,o)=>{if(e.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:t}),n};}),he=g("$ZodStringFormat",(t,e)=>{oo.init(t,e),Ar.init(t,e);}),Cc=g("$ZodGUID",(t,e)=>{e.pattern??(e.pattern=Tm),he.init(t,e);}),Oc=g("$ZodUUID",(t,e)=>{if(e.version){let o={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[e.version];if(o===void 0)throw new Error(`Invalid UUID version: "${e.version}"`);e.pattern??(e.pattern=pn(o));}else e.pattern??(e.pattern=pn());he.init(t,e);}),Rc=g("$ZodEmail",(t,e)=>{e.pattern??(e.pattern=Im),he.init(t,e);}),Nc=g("$ZodURL",(t,e)=>{he.init(t,e),t._zod.check=n=>{try{let o=n.value.trim(),r=new URL(o);e.hostname&&(e.hostname.lastIndex=0,e.hostname.test(r.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:e.hostname.source,input:n.value,inst:t,continue:!e.abort})),e.protocol&&(e.protocol.lastIndex=0,e.protocol.test(r.protocol.endsWith(":")?r.protocol.slice(0,-1):r.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:e.protocol.source,input:n.value,inst:t,continue:!e.abort})),e.normalize?n.value=r.href:n.value=o;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:t,continue:!e.abort});}};}),Dc=g("$ZodEmoji",(t,e)=>{e.pattern??(e.pattern=zm()),he.init(t,e);}),Ac=g("$ZodNanoID",(t,e)=>{e.pattern??(e.pattern=wm),he.init(t,e);}),Uc=g("$ZodCUID",(t,e)=>{e.pattern??(e.pattern=_m),he.init(t,e);}),Zc=g("$ZodCUID2",(t,e)=>{e.pattern??(e.pattern=km),he.init(t,e);}),Mc=g("$ZodULID",(t,e)=>{e.pattern??(e.pattern=$m),he.init(t,e);}),Lc=g("$ZodXID",(t,e)=>{e.pattern??(e.pattern=bm),he.init(t,e);}),Fc=g("$ZodKSUID",(t,e)=>{e.pattern??(e.pattern=xm),he.init(t,e);}),qc=g("$ZodISODateTime",(t,e)=>{e.pattern??(e.pattern=Um(e)),he.init(t,e);}),Jc=g("$ZodISODate",(t,e)=>{e.pattern??(e.pattern=Dm),he.init(t,e);}),Vc=g("$ZodISOTime",(t,e)=>{e.pattern??(e.pattern=Am(e)),he.init(t,e);}),Bc=g("$ZodISODuration",(t,e)=>{e.pattern??(e.pattern=Sm),he.init(t,e);}),Gc=g("$ZodIPv4",(t,e)=>{e.pattern??(e.pattern=Pm),he.init(t,e),t._zod.bag.format="ipv4";}),Kc=g("$ZodIPv6",(t,e)=>{e.pattern??(e.pattern=jm),he.init(t,e),t._zod.bag.format="ipv6",t._zod.check=n=>{try{new URL(`http://[${n.value}]`);}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:t,continue:!e.abort});}};}),Wc=g("$ZodMAC",(t,e)=>{e.pattern??(e.pattern=Em(e.delimiter)),he.init(t,e),t._zod.bag.format="mac";}),Hc=g("$ZodCIDRv4",(t,e)=>{e.pattern??(e.pattern=Cm),he.init(t,e);}),Xc=g("$ZodCIDRv6",(t,e)=>{e.pattern??(e.pattern=Om),he.init(t,e),t._zod.check=n=>{let o=n.value.split("/");try{if(o.length!==2)throw new Error;let[r,i]=o;if(!i)throw new Error;let a=Number(i);if(`${a}`!==i)throw new Error;if(a<0||a>128)throw new Error;new URL(`http://[${r}]`);}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:t,continue:!e.abort});}};});Yc=g("$ZodBase64",(t,e)=>{e.pattern??(e.pattern=Rm),he.init(t,e),t._zod.bag.contentEncoding="base64",t._zod.check=n=>{hf(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:t,continue:!e.abort});};});Qc=g("$ZodBase64URL",(t,e)=>{e.pattern??(e.pattern=$c),he.init(t,e),t._zod.bag.contentEncoding="base64url",t._zod.check=n=>{Yk(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:t,continue:!e.abort});};}),eu=g("$ZodE164",(t,e)=>{e.pattern??(e.pattern=Nm),he.init(t,e);});tu=g("$ZodJWT",(t,e)=>{he.init(t,e),t._zod.check=n=>{Qk(n.value,e.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:t,continue:!e.abort});};}),ru=g("$ZodCustomStringFormat",(t,e)=>{he.init(t,e),t._zod.check=n=>{e.fn(n.value)||n.issues.push({code:"invalid_format",format:e.format,input:n.value,inst:t,continue:!e.abort});};}),Fi=g("$ZodNumber",(t,e)=>{B.init(t,e),t._zod.pattern=t._zod.bag.pattern??bc,t._zod.parse=(n,o)=>{if(e.coerce)try{n.value=Number(n.value);}catch{}let r=n.value;if(typeof r=="number"&&!Number.isNaN(r)&&Number.isFinite(r))return n;let i=typeof r=="number"?Number.isNaN(r)?"NaN":Number.isFinite(r)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:r,inst:t,...i?{received:i}:{}}),n};}),nu=g("$ZodNumberFormat",(t,e)=>{Km.init(t,e),Fi.init(t,e);}),io=g("$ZodBoolean",(t,e)=>{B.init(t,e),t._zod.pattern=Fm,t._zod.parse=(n,o)=>{if(e.coerce)try{n.value=!!n.value;}catch{}let r=n.value;return typeof r=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:t}),n};}),qi=g("$ZodBigInt",(t,e)=>{B.init(t,e),t._zod.pattern=Mm,t._zod.parse=(n,o)=>{if(e.coerce)try{n.value=BigInt(n.value);}catch{}return typeof n.value=="bigint"||n.issues.push({expected:"bigint",code:"invalid_type",input:n.value,inst:t}),n};}),ou=g("$ZodBigIntFormat",(t,e)=>{Wm.init(t,e),qi.init(t,e);}),iu=g("$ZodSymbol",(t,e)=>{B.init(t,e),t._zod.parse=(n,o)=>{let r=n.value;return typeof r=="symbol"||n.issues.push({expected:"symbol",code:"invalid_type",input:r,inst:t}),n};}),au=g("$ZodUndefined",(t,e)=>{B.init(t,e),t._zod.pattern=Jm,t._zod.values=new Set([void 0]),t._zod.optin="optional",t._zod.optout="optional",t._zod.parse=(n,o)=>{let r=n.value;return typeof r>"u"||n.issues.push({expected:"undefined",code:"invalid_type",input:r,inst:t}),n};}),su=g("$ZodNull",(t,e)=>{B.init(t,e),t._zod.pattern=qm,t._zod.values=new Set([null]),t._zod.parse=(n,o)=>{let r=n.value;return r===null||n.issues.push({expected:"null",code:"invalid_type",input:r,inst:t}),n};}),cu=g("$ZodAny",(t,e)=>{B.init(t,e),t._zod.parse=n=>n;}),uu=g("$ZodUnknown",(t,e)=>{B.init(t,e),t._zod.parse=n=>n;}),lu=g("$ZodNever",(t,e)=>{B.init(t,e),t._zod.parse=(n,o)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:t}),n);}),du=g("$ZodVoid",(t,e)=>{B.init(t,e),t._zod.parse=(n,o)=>{let r=n.value;return typeof r>"u"||n.issues.push({expected:"void",code:"invalid_type",input:r,inst:t}),n};}),pu=g("$ZodDate",(t,e)=>{B.init(t,e),t._zod.parse=(n,o)=>{if(e.coerce)try{n.value=new Date(n.value);}catch{}let r=n.value,i=r instanceof Date;return i&&!Number.isNaN(r.getTime())||n.issues.push({expected:"date",code:"invalid_type",input:r,...i?{received:"Invalid Date"}:{},inst:t}),n};});mu=g("$ZodArray",(t,e)=>{B.init(t,e),t._zod.parse=(n,o)=>{let r=n.value;if(!Array.isArray(r))return n.issues.push({expected:"array",code:"invalid_type",input:r,inst:t}),n;n.value=Array(r.length);let i=[];for(let a=0;a<r.length;a++){let s=r[a],c=e.element._zod.run({value:s,issues:[]},o);c instanceof Promise?i.push(c.then(u=>Lk(u,n,a))):Lk(c,n,a);}return i.length?Promise.all(i).then(()=>n):n};});yf=g("$ZodObject",(t,e)=>{if(B.init(t,e),!Object.getOwnPropertyDescriptor(e,"shape")?.get){let s=e.shape;Object.defineProperty(e,"shape",{get:()=>{let c={...s};return Object.defineProperty(e,"shape",{value:c}),c}});}let o=Gn(()=>e$(e));X(t._zod,"propValues",()=>{let s=e.shape,c={};for(let u in s){let l=s[u]._zod;if(l.values){c[u]??(c[u]=new Set);for(let d of l.values)c[u].add(d);}}return c});let r=ln,i=e.catchall,a;t._zod.parse=(s,c)=>{a??(a=o.value);let u=s.value;if(!r(u))return s.issues.push({expected:"object",code:"invalid_type",input:u,inst:t}),s;s.value={};let l=[],d=a.shape;for(let p of a.keys){let m=d[p],y=m._zod.optout==="optional",k=m._zod.run({value:u[p],issues:[]},c);k instanceof Promise?l.push(k.then(T=>Ec(T,s,p,u,y))):Ec(k,s,p,u,y);}return i?t$(l,u,s,c,o.value,t):l.length?Promise.all(l).then(()=>s):s};}),vf=g("$ZodObjectJIT",(t,e)=>{yf.init(t,e);let n=t._zod.parse,o=Gn(()=>e$(e)),r=p=>{let m=new Li(["shape","payload","ctx"]),y=o.value,k=O=>{let q=cc(O);return `shape[${q}]._zod.run({ value: input[${q}], issues: [] }, ctx)`};m.write("const input = payload.value;");let T=Object.create(null),I=0;for(let O of y.keys)T[O]=`key_${I++}`;m.write("const newResult = {};");for(let O of y.keys){let q=T[O],Z=cc(O),Xe=p[O]?._zod?.optout==="optional";m.write(`const ${q} = ${k(O)};`),Xe?m.write(`
|
package/dist/index.js
CHANGED
|
@@ -85,5 +85,5 @@ ${n}
|
|
|
85
85
|
|
|
86
86
|
`)}function bn(t,e){let n=O1(t,e);if(n.length>0)return {success:false,error:`Missing required variables: ${n.join(", ")}`,missingVariables:n};let o=E1(t),r=t.body;return r=r.replace(P1,(i,a,s)=>{let c=e[a];return c!==void 0&&c!==""?s:""}),r=r.replace(j1,(i,a)=>a in e?e[a]??"":o.get(a)??""),{success:true,markdown:R1(r).trim(),usedVariables:Object.keys(e)}}var P1,j1,g0=w(()=>{P1=/\{\{#(\w+)\}\}([\s\S]*?)\{\{\/\1\}\}/g,j1=/\{\{(\w+)\}\}/g;});function tv(t){console.log(t);}function rv(t){console.warn(`Warning: ${t}`);}function nv(t){console.error(`Error: ${t}`);}function y0(t,e){let n=t.map((i,a)=>Math.max(i.length,...e.map(s=>(s[a]??"").length))),o=t.map((i,a)=>i.padEnd(n[a]??0)).join(" "),r=n.map(i=>"-".repeat(i)).join(" ");console.log(o),console.log(r);for(let i of e)console.log(i.map((a,s)=>(a??"").padEnd(n[s]??0)).join(" "));}var v0=w(()=>{});var _0={};qt(_0,{AdfConversionError:()=>qy,AdfDocumentSchema:()=>s0,ApprovalError:()=>gs,AtlassianHttpClient:()=>Xo,BODY_FORMATS:()=>Ry,BodyFormatSchema:()=>Lo,CacheCorruptionError:()=>pr,CacheError:()=>Fo,CacheNotFoundError:()=>St,CommentApprovalRequiredError:()=>ys,CommentNotFoundError:()=>_s,ConfigError:()=>ps,ConfigFileSchema:()=>Zd,ConfigNotFoundError:()=>qo,ConfigValidationError:()=>qe,ConfluenceAuthenticationError:()=>Dy,ConfluenceConfigSchema:()=>CS,ConfluenceConnectionError:()=>hs,ConfluencePermissionError:()=>Ay,ConfluenceSpaceInstanceConfigSchema:()=>ds,CredentialsFileSchema:()=>Md,DEFAULT_BODY_FORMAT:()=>Ud,DEFAULT_LANGUAGE:()=>Yt,DeletionApprovalRequiredError:()=>vs,GLOBAL_CACHE_DIR:()=>xs,GLOBAL_CONFIG_DIR:()=>Lr,GLOBAL_CONFIG_PATH:()=>ks,GLOBAL_CREDENTIALS_PATH:()=>bs,GLOBAL_STATE_PATH:()=>Fy,JiraAuthenticationError:()=>ms,JiraConfigSchema:()=>RS,JiraConnectionError:()=>wt,JiraInstanceConfigSchema:()=>ls,JiraMcpError:()=>Pe,JiraPermissionError:()=>fs,LanguageCodeSchema:()=>Zt,MarkupLossError:()=>Uy,MultiCredentialsSchema:()=>us,OwnershipError:()=>Vo,PageNotFoundError:()=>Zy,ProjectConfigSchema:()=>Oy,SUPPORTED_LANGUAGES:()=>Ey,SingleCredentialsSchema:()=>dr,SpaceConfigSchema:()=>Cy,TaskNotFoundError:()=>Tt,TemplateError:()=>mr,TemplateMissingVariableError:()=>Ly,TemplateNotFoundError:()=>kn,VersionConflictError:()=>My,adfToMarkdown:()=>Wo,asOptionalBoolean:()=>qr,asOptionalNumber:()=>Jd,asOptionalRecord:()=>Ts,asOptionalString:()=>ke,asOptionalStringArray:()=>Ss,assertCommentApproved:()=>Yo,assertDeletionApproved:()=>Qo,createEmptyDoc:()=>e0,createHeading:()=>n0,createParagraph:()=>o0,createTextDoc:()=>t0,error:()=>nv,failure:()=>M,getProjectConfig:()=>MS,getSpaceConfig:()=>ZS,getUniqueInstances:()=>Ld,info:()=>tv,loadConfig:()=>Go,loadConfluenceConfig:()=>US,loadJsonFile:()=>ES,markdownToAdf:()=>zt,pathExists:()=>Xt,renderTemplate:()=>bn,requireString:()=>Ie,saveJsonFile:()=>OS,success:()=>K,table:()=>y0,warn:()=>rv,wrapInPanel:()=>r0,writeSecureFile:()=>jS});var le=w(()=>{LS();Ny();Vy();Jo();WS();QS();i0();c0();d0();p0();m0();f0();h0();g0();v0();jy();});var ne;(function(t){t.assertEqual=r=>{};function e(r){}t.assertIs=e;function n(r){throw new Error}t.assertNever=n,t.arrayToEnum=r=>{let i={};for(let a of r)i[a]=a;return i},t.getValidEnumValues=r=>{let i=t.objectKeys(r).filter(s=>typeof r[r[s]]!="number"),a={};for(let s of i)a[s]=r[s];return t.objectValues(a)},t.objectValues=r=>t.objectKeys(r).map(function(i){return r[i]}),t.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{let i=[];for(let a in r)Object.prototype.hasOwnProperty.call(r,a)&&i.push(a);return i},t.find=(r,i)=>{for(let a of r)if(i(a))return a},t.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&Number.isFinite(r)&&Math.floor(r)===r;function o(r,i=" | "){return r.map(a=>typeof a=="string"?`'${a}'`:a).join(i)}t.joinValues=o,t.jsonStringifyReplacer=(r,i)=>typeof i=="bigint"?i.toString():i;})(ne||(ne={}));var pv;(function(t){t.mergeShapes=(e,n)=>({...e,...n});})(pv||(pv={}));ne.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);ne.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);var ct=class t extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=o=>{this.issues=[...this.issues,o];},this.addIssues=(o=[])=>{this.issues=[...this.issues,...o];};let n=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,n):this.__proto__=n,this.name="ZodError",this.issues=e;}format(e){let n=e||function(i){return i.message},o={_errors:[]},r=i=>{for(let a of i.issues)if(a.code==="invalid_union")a.unionErrors.map(r);else if(a.code==="invalid_return_type")r(a.returnTypeError);else if(a.code==="invalid_arguments")r(a.argumentsError);else if(a.path.length===0)o._errors.push(n(a));else {let s=o,c=0;for(;c<a.path.length;){let u=a.path[c];c===a.path.length-1?(s[u]=s[u]||{_errors:[]},s[u]._errors.push(n(a))):s[u]=s[u]||{_errors:[]},s=s[u],c++;}}};return r(this),o}static assert(e){if(!(e instanceof t))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,ne.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=n=>n.message){let n=Object.create(null),o=[];for(let r of this.issues)if(r.path.length>0){let i=r.path[0];n[i]=n[i]||[],n[i].push(e(r));}else o.push(e(r));return {formErrors:o,fieldErrors:n}}get formErrors(){return this.flatten()}};ct.create=t=>new ct(t);var C;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message;})(C||(C={}));var L;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly";})(L||(L={}));Se();Se();Se();D();Se();Se();co();mu();Se();Se();function uo(t){return !!t._zod}function Pr(t,e){return uo(t)?Kr(t,e):t.safeParse(e)}function il(t){if(!t)return;let e;if(uo(t)?e=t._zod?.def?.shape:e=t.shape,!!e){if(typeof e=="function")try{return e()}catch{return}return e}}function Q$(t){if(uo(t)){let i=t._zod?.def;if(i){if(i.value!==void 0)return i.value;if(Array.isArray(i.values)&&i.values.length>0)return i.values[0]}}let n=t._def;if(n){if(n.value!==void 0)return n.value;if(Array.isArray(n.values)&&n.values.length>0)return n.values[0]}let o=t.value;if(o!==void 0)return o}ka();ka();var vh="2025-11-25";var fb=[vh,"2025-06-18","2025-03-26","2024-11-05","2024-10-07"],Er="io.modelcontextprotocol/related-task",Zl="2.0",Ee=Al(t=>t!==null&&(typeof t=="object"||typeof t=="function")),hb=ye([y(),ce().int()]),gb=y();Ne({ttl:ce().optional(),pollInterval:ce().optional()});var vP=E({ttl:ce().optional()}),_P=E({taskId:y()}),_h=Ne({progressToken:hb.optional(),[Er]:_P.optional()}),pt=E({_meta:_h.optional()}),ba=pt.extend({task:vP.optional()}),yb=t=>ba.safeParse(t).success,Ae=E({method:y(),params:pt.loose().optional()}),vt=E({_meta:_h.optional()}),_t=E({method:y(),params:vt.loose().optional()}),Ue=Ne({_meta:_h.optional()}),Ml=ye([y(),ce().int()]),vb=E({jsonrpc:N(Zl),id:Ml,...Ae.shape}).strict(),$h=t=>vb.safeParse(t).success,_b=E({jsonrpc:N(Zl),..._t.shape}).strict(),$b=t=>_b.safeParse(t).success,kh=E({jsonrpc:N(Zl),id:Ml,result:Ue}).strict(),xa=t=>kh.safeParse(t).success;var oe;(function(t){t[t.ConnectionClosed=-32e3]="ConnectionClosed",t[t.RequestTimeout=-32001]="RequestTimeout",t[t.ParseError=-32700]="ParseError",t[t.InvalidRequest=-32600]="InvalidRequest",t[t.MethodNotFound=-32601]="MethodNotFound",t[t.InvalidParams=-32602]="InvalidParams",t[t.InternalError=-32603]="InternalError",t[t.UrlElicitationRequired=-32042]="UrlElicitationRequired";})(oe||(oe={}));var bh=E({jsonrpc:N(Zl),id:Ml.optional(),error:E({code:ce().int(),message:y(),data:ge().optional()})}).strict();var kb=t=>bh.safeParse(t).success;var bb=ye([vb,_b,kh,bh]);ye([kh,bh]);var Ll=Ue.strict(),$P=vt.extend({requestId:Ml.optional(),reason:y().optional()}),ql=_t.extend({method:N("notifications/cancelled"),params:$P}),kP=E({src:y(),mimeType:y().optional(),sizes:ee(y()).optional(),theme:De(["light","dark"]).optional()}),wa=E({icons:ee(kP).optional()}),vo=E({name:y(),title:y().optional()}),xb=vo.extend({...vo.shape,...wa.shape,version:y(),websiteUrl:y().optional(),description:y().optional()}),bP=yo(E({applyDefaults:Te().optional()}),me(y(),ge())),xP=$a(t=>t&&typeof t=="object"&&!Array.isArray(t)&&Object.keys(t).length===0?{form:{}}:t,yo(E({form:bP.optional(),url:Ee.optional()}),me(y(),ge()).optional())),wP=Ne({list:Ee.optional(),cancel:Ee.optional(),requests:Ne({sampling:Ne({createMessage:Ee.optional()}).optional(),elicitation:Ne({create:Ee.optional()}).optional()}).optional()}),SP=Ne({list:Ee.optional(),cancel:Ee.optional(),requests:Ne({tools:Ne({call:Ee.optional()}).optional()}).optional()}),TP=E({experimental:me(y(),Ee).optional(),sampling:E({context:Ee.optional(),tools:Ee.optional()}).optional(),elicitation:xP.optional(),roots:E({listChanged:Te().optional()}).optional(),tasks:wP.optional(),extensions:me(y(),Ee).optional()}),zP=pt.extend({protocolVersion:y(),capabilities:TP,clientInfo:xb}),xh=Ae.extend({method:N("initialize"),params:zP});var IP=E({experimental:me(y(),Ee).optional(),logging:Ee.optional(),completions:Ee.optional(),prompts:E({listChanged:Te().optional()}).optional(),resources:E({subscribe:Te().optional(),listChanged:Te().optional()}).optional(),tools:E({listChanged:Te().optional()}).optional(),tasks:SP.optional(),extensions:me(y(),Ee).optional()}),PP=Ue.extend({protocolVersion:y(),capabilities:IP,serverInfo:xb,instructions:y().optional()}),wh=_t.extend({method:N("notifications/initialized"),params:vt.optional()});var Fl=Ae.extend({method:N("ping"),params:pt.optional()}),jP=E({progress:ce(),total:_e(ce()),message:_e(y())}),EP=E({...vt.shape,...jP.shape,progressToken:hb}),Vl=_t.extend({method:N("notifications/progress"),params:EP}),OP=pt.extend({cursor:gb.optional()}),Sa=Ae.extend({params:OP.optional()}),Ta=Ue.extend({nextCursor:gb.optional()}),RP=De(["working","input_required","completed","failed","cancelled"]),za=E({taskId:y(),status:RP,ttl:ye([ce(),ma()]),createdAt:y(),lastUpdatedAt:y(),pollInterval:_e(ce()),statusMessage:_e(y())}),_o=Ue.extend({task:za}),CP=vt.merge(za),Ia=_t.extend({method:N("notifications/tasks/status"),params:CP}),Jl=Ae.extend({method:N("tasks/get"),params:pt.extend({taskId:y()})}),Bl=Ue.merge(za),Gl=Ae.extend({method:N("tasks/result"),params:pt.extend({taskId:y()})});Ue.loose();var Kl=Sa.extend({method:N("tasks/list")}),Hl=Ta.extend({tasks:ee(za)}),Wl=Ae.extend({method:N("tasks/cancel"),params:pt.extend({taskId:y()})}),wb=Ue.merge(za),Sb=E({uri:y(),mimeType:_e(y()),_meta:me(y(),ge()).optional()}),Tb=Sb.extend({text:y()}),Sh=y().refine(t=>{try{return atob(t),!0}catch{return false}},{message:"Invalid Base64 string"}),zb=Sb.extend({blob:Sh}),Pa=De(["user","assistant"]),$o=E({audience:ee(Pa).optional(),priority:ce().min(0).max(1).optional(),lastModified:jr.datetime({offset:true}).optional()}),Ib=E({...vo.shape,...wa.shape,uri:y(),description:_e(y()),mimeType:_e(y()),size:_e(ce()),annotations:$o.optional(),_meta:_e(Ne({}))}),NP=E({...vo.shape,...wa.shape,uriTemplate:y(),description:_e(y()),mimeType:_e(y()),annotations:$o.optional(),_meta:_e(Ne({}))}),DP=Sa.extend({method:N("resources/list")}),AP=Ta.extend({resources:ee(Ib)}),UP=Sa.extend({method:N("resources/templates/list")}),ZP=Ta.extend({resourceTemplates:ee(NP)}),Th=pt.extend({uri:y()}),MP=Th,LP=Ae.extend({method:N("resources/read"),params:MP}),qP=Ue.extend({contents:ee(ye([Tb,zb]))}),FP=_t.extend({method:N("notifications/resources/list_changed"),params:vt.optional()}),VP=Th,JP=Ae.extend({method:N("resources/subscribe"),params:VP}),BP=Th,GP=Ae.extend({method:N("resources/unsubscribe"),params:BP}),KP=vt.extend({uri:y()}),HP=_t.extend({method:N("notifications/resources/updated"),params:KP}),WP=E({name:y(),description:_e(y()),required:_e(Te())}),XP=E({...vo.shape,...wa.shape,description:_e(y()),arguments:_e(ee(WP)),_meta:_e(Ne({}))}),YP=Sa.extend({method:N("prompts/list")}),QP=Ta.extend({prompts:ee(XP)}),ej=pt.extend({name:y(),arguments:me(y(),y()).optional()}),tj=Ae.extend({method:N("prompts/get"),params:ej}),zh=E({type:N("text"),text:y(),annotations:$o.optional(),_meta:me(y(),ge()).optional()}),Ih=E({type:N("image"),data:Sh,mimeType:y(),annotations:$o.optional(),_meta:me(y(),ge()).optional()}),Ph=E({type:N("audio"),data:Sh,mimeType:y(),annotations:$o.optional(),_meta:me(y(),ge()).optional()}),rj=E({type:N("tool_use"),name:y(),id:y(),input:me(y(),ge()),_meta:me(y(),ge()).optional()}),nj=E({type:N("resource"),resource:ye([Tb,zb]),annotations:$o.optional(),_meta:me(y(),ge()).optional()}),oj=Ib.extend({type:N("resource_link")}),jh=ye([zh,Ih,Ph,oj,nj]),ij=E({role:Pa,content:jh}),aj=Ue.extend({description:y().optional(),messages:ee(ij)}),sj=_t.extend({method:N("notifications/prompts/list_changed"),params:vt.optional()}),cj=E({title:y().optional(),readOnlyHint:Te().optional(),destructiveHint:Te().optional(),idempotentHint:Te().optional(),openWorldHint:Te().optional()}),uj=E({taskSupport:De(["required","optional","forbidden"]).optional()}),Pb=E({...vo.shape,...wa.shape,description:y().optional(),inputSchema:E({type:N("object"),properties:me(y(),Ee).optional(),required:ee(y()).optional()}).catchall(ge()),outputSchema:E({type:N("object"),properties:me(y(),Ee).optional(),required:ee(y()).optional()}).catchall(ge()).optional(),annotations:cj.optional(),execution:uj.optional(),_meta:me(y(),ge()).optional()}),Eh=Sa.extend({method:N("tools/list")}),lj=Ta.extend({tools:ee(Pb)}),Xl=Ue.extend({content:ee(jh).default([]),structuredContent:me(y(),ge()).optional(),isError:Te().optional()});Xl.or(Ue.extend({toolResult:ge()}));var dj=ba.extend({name:y(),arguments:me(y(),ge()).optional()}),ja=Ae.extend({method:N("tools/call"),params:dj}),pj=_t.extend({method:N("notifications/tools/list_changed"),params:vt.optional()});E({autoRefresh:Te().default(true),debounceMs:ce().int().nonnegative().default(300)});var Ea=De(["debug","info","notice","warning","error","critical","alert","emergency"]),mj=pt.extend({level:Ea}),Oh=Ae.extend({method:N("logging/setLevel"),params:mj}),fj=vt.extend({level:Ea,logger:y().optional(),data:ge()}),hj=_t.extend({method:N("notifications/message"),params:fj}),gj=E({name:y().optional()}),yj=E({hints:ee(gj).optional(),costPriority:ce().min(0).max(1).optional(),speedPriority:ce().min(0).max(1).optional(),intelligencePriority:ce().min(0).max(1).optional()}),vj=E({mode:De(["auto","required","none"]).optional()}),_j=E({type:N("tool_result"),toolUseId:y().describe("The unique identifier for the corresponding tool call."),content:ee(jh).default([]),structuredContent:E({}).loose().optional(),isError:Te().optional(),_meta:me(y(),ge()).optional()}),$j=ya("type",[zh,Ih,Ph]),Ul=ya("type",[zh,Ih,Ph,rj,_j]),kj=E({role:Pa,content:ye([Ul,ee(Ul)]),_meta:me(y(),ge()).optional()}),bj=ba.extend({messages:ee(kj),modelPreferences:yj.optional(),systemPrompt:y().optional(),includeContext:De(["none","thisServer","allServers"]).optional(),temperature:ce().optional(),maxTokens:ce().int(),stopSequences:ee(y()).optional(),metadata:Ee.optional(),tools:ee(Pb).optional(),toolChoice:vj.optional()}),xj=Ae.extend({method:N("sampling/createMessage"),params:bj}),Oa=Ue.extend({model:y(),stopReason:_e(De(["endTurn","stopSequence","maxTokens"]).or(y())),role:Pa,content:$j}),Rh=Ue.extend({model:y(),stopReason:_e(De(["endTurn","stopSequence","maxTokens","toolUse"]).or(y())),role:Pa,content:ye([Ul,ee(Ul)])}),wj=E({type:N("boolean"),title:y().optional(),description:y().optional(),default:Te().optional()}),Sj=E({type:N("string"),title:y().optional(),description:y().optional(),minLength:ce().optional(),maxLength:ce().optional(),format:De(["email","uri","date","date-time"]).optional(),default:y().optional()}),Tj=E({type:De(["number","integer"]),title:y().optional(),description:y().optional(),minimum:ce().optional(),maximum:ce().optional(),default:ce().optional()}),zj=E({type:N("string"),title:y().optional(),description:y().optional(),enum:ee(y()),default:y().optional()}),Ij=E({type:N("string"),title:y().optional(),description:y().optional(),oneOf:ee(E({const:y(),title:y()})),default:y().optional()}),Pj=E({type:N("string"),title:y().optional(),description:y().optional(),enum:ee(y()),enumNames:ee(y()).optional(),default:y().optional()}),jj=ye([zj,Ij]),Ej=E({type:N("array"),title:y().optional(),description:y().optional(),minItems:ce().optional(),maxItems:ce().optional(),items:E({type:N("string"),enum:ee(y())}),default:ee(y()).optional()}),Oj=E({type:N("array"),title:y().optional(),description:y().optional(),minItems:ce().optional(),maxItems:ce().optional(),items:E({anyOf:ee(E({const:y(),title:y()}))}),default:ee(y()).optional()}),Rj=ye([Ej,Oj]),Cj=ye([Pj,jj,Rj]),Nj=ye([Cj,wj,Sj,Tj]),Dj=ba.extend({mode:N("form").optional(),message:y(),requestedSchema:E({type:N("object"),properties:me(y(),Nj),required:ee(y()).optional()})}),Aj=ba.extend({mode:N("url"),message:y(),elicitationId:y(),url:y().url()}),Uj=ye([Dj,Aj]),Zj=Ae.extend({method:N("elicitation/create"),params:Uj}),Mj=vt.extend({elicitationId:y()}),Lj=_t.extend({method:N("notifications/elicitation/complete"),params:Mj}),ko=Ue.extend({action:De(["accept","decline","cancel"]),content:$a(t=>t===null?void 0:t,me(y(),ye([y(),ce(),Te(),ee(y())])).optional())}),qj=E({type:N("ref/resource"),uri:y()});var Fj=E({type:N("ref/prompt"),name:y()}),Vj=pt.extend({ref:ye([Fj,qj]),argument:E({name:y(),value:y()}),context:E({arguments:me(y(),y()).optional()}).optional()}),Jj=Ae.extend({method:N("completion/complete"),params:Vj});var Bj=Ue.extend({completion:Ne({values:ee(y()).max(100),total:_e(ce().int()),hasMore:_e(Te())})}),Gj=E({uri:y().startsWith("file://"),name:y().optional(),_meta:me(y(),ge()).optional()}),Kj=Ae.extend({method:N("roots/list"),params:pt.optional()}),Ch=Ue.extend({roots:ee(Gj)}),Hj=_t.extend({method:N("notifications/roots/list_changed"),params:vt.optional()});ye([Fl,xh,Jj,Oh,tj,YP,DP,UP,LP,JP,GP,ja,Eh,Jl,Gl,Kl,Wl]);ye([ql,Vl,wh,Hj,Ia]);ye([Ll,Oa,Rh,ko,Ch,Bl,Hl,_o]);ye([Fl,xj,Zj,Kj,Jl,Gl,Kl,Wl]);ye([ql,Vl,hj,HP,FP,pj,sj,Ia,Lj]);ye([Ll,PP,Bj,aj,QP,AP,ZP,qP,Xl,lj,Bl,Hl,_o]);var W=class t extends Error{constructor(e,n,o){super(`MCP error ${e}: ${n}`),this.code=e,this.data=o,this.name="McpError";}static fromError(e,n,o){if(e===oe.UrlElicitationRequired&&o){let r=o;if(r.elicitations)return new yh(r.elicitations,n)}return new t(e,n,o)}},yh=class extends W{constructor(e,n=`URL elicitation${e.length>1?"s":""} required`){super(oe.UrlElicitationRequired,n,{elicitations:e});}get elicitations(){return this.data?.elicitations??[]}};function Or(t){return t==="completed"||t==="failed"||t==="cancelled"}new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Nh(t){let n=il(t)?.method;if(!n)throw new Error("Schema is missing a method literal");let o=Q$(n);if(typeof o!="string")throw new Error("Schema method literal must be a string");return o}function Dh(t,e){let n=Pr(t,e);if(!n.success)throw n.error;return n.data}var tE=6e4,Yl=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(ql,n=>{this._oncancel(n);}),this.setNotificationHandler(Vl,n=>{this._onprogress(n);}),this.setRequestHandler(Fl,n=>({})),this._taskStore=e?.taskStore,this._taskMessageQueue=e?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Jl,async(n,o)=>{let r=await this._taskStore.getTask(n.params.taskId,o.sessionId);if(!r)throw new W(oe.InvalidParams,"Failed to retrieve task: Task not found");return {...r}}),this.setRequestHandler(Gl,async(n,o)=>{let r=async()=>{let i=n.params.taskId;if(this._taskMessageQueue){let s;for(;s=await this._taskMessageQueue.dequeue(i,o.sessionId);){if(s.type==="response"||s.type==="error"){let c=s.message,u=c.id,l=this._requestResolvers.get(u);if(l)if(this._requestResolvers.delete(u),s.type==="response")l(c);else {let d=c,p=new W(d.error.code,d.error.message,d.error.data);l(p);}else {let d=s.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${u}`));}continue}await this._transport?.send(s.message,{relatedRequestId:o.requestId});}}let a=await this._taskStore.getTask(i,o.sessionId);if(!a)throw new W(oe.InvalidParams,`Task not found: ${i}`);if(!Or(a.status))return await this._waitForTaskUpdate(i,o.signal),await r();if(Or(a.status)){let s=await this._taskStore.getTaskResult(i,o.sessionId);return this._clearTaskQueue(i),{...s,_meta:{...s._meta,[Er]:{taskId:i}}}}return await r()};return await r()}),this.setRequestHandler(Kl,async(n,o)=>{try{let{tasks:r,nextCursor:i}=await this._taskStore.listTasks(n.params?.cursor,o.sessionId);return {tasks:r,nextCursor:i,_meta:{}}}catch(r){throw new W(oe.InvalidParams,`Failed to list tasks: ${r instanceof Error?r.message:String(r)}`)}}),this.setRequestHandler(Wl,async(n,o)=>{try{let r=await this._taskStore.getTask(n.params.taskId,o.sessionId);if(!r)throw new W(oe.InvalidParams,`Task not found: ${n.params.taskId}`);if(Or(r.status))throw new W(oe.InvalidParams,`Cannot cancel task in terminal status: ${r.status}`);await this._taskStore.updateTaskStatus(n.params.taskId,"cancelled","Client cancelled task execution.",o.sessionId),this._clearTaskQueue(n.params.taskId);let i=await this._taskStore.getTask(n.params.taskId,o.sessionId);if(!i)throw new W(oe.InvalidParams,`Task not found after cancellation: ${n.params.taskId}`);return {_meta:{},...i}}catch(r){throw r instanceof W?r:new W(oe.InvalidRequest,`Failed to cancel task: ${r instanceof Error?r.message:String(r)}`)}}));}async _oncancel(e){if(!e.params.requestId)return;this._requestHandlerAbortControllers.get(e.params.requestId)?.abort(e.params.reason);}_setupTimeout(e,n,o,r,i=false){this._timeoutInfo.set(e,{timeoutId:setTimeout(r,n),startTime:Date.now(),timeout:n,maxTotalTimeout:o,resetTimeoutOnProgress:i,onTimeout:r});}_resetTimeout(e){let n=this._timeoutInfo.get(e);if(!n)return false;let o=Date.now()-n.startTime;if(n.maxTotalTimeout&&o>=n.maxTotalTimeout)throw this._timeoutInfo.delete(e),W.fromError(oe.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:n.maxTotalTimeout,totalElapsed:o});return clearTimeout(n.timeoutId),n.timeoutId=setTimeout(n.onTimeout,n.timeout),true}_cleanupTimeout(e){let n=this._timeoutInfo.get(e);n&&(clearTimeout(n.timeoutId),this._timeoutInfo.delete(e));}async connect(e){if(this._transport)throw new 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 n=this.transport?.onclose;this._transport.onclose=()=>{n?.(),this._onclose();};let o=this.transport?.onerror;this._transport.onerror=i=>{o?.(i),this._onerror(i);};let r=this._transport?.onmessage;this._transport.onmessage=(i,a)=>{r?.(i,a),xa(i)||kb(i)?this._onresponse(i):$h(i)?this._onrequest(i,a):$b(i)?this._onnotification(i):this._onerror(new Error(`Unknown message type: ${JSON.stringify(i)}`));},await this._transport.start();}_onclose(){let e=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(let o of this._timeoutInfo.values())clearTimeout(o.timeoutId);this._timeoutInfo.clear();for(let o of this._requestHandlerAbortControllers.values())o.abort();this._requestHandlerAbortControllers.clear();let n=W.fromError(oe.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(let o of e.values())o(n);}_onerror(e){this.onerror?.(e);}_onnotification(e){let n=this._notificationHandlers.get(e.method)??this.fallbackNotificationHandler;n!==void 0&&Promise.resolve().then(()=>n(e)).catch(o=>this._onerror(new Error(`Uncaught error in notification handler: ${o}`)));}_onrequest(e,n){let o=this._requestHandlers.get(e.method)??this.fallbackRequestHandler,r=this._transport,i=e.params?._meta?.[Er]?.taskId;if(o===void 0){let l={jsonrpc:"2.0",id:e.id,error:{code:oe.MethodNotFound,message:"Method not found"}};i&&this._taskMessageQueue?this._enqueueTaskMessage(i,{type:"error",message:l,timestamp:Date.now()},r?.sessionId).catch(d=>this._onerror(new Error(`Failed to enqueue error response: ${d}`))):r?.send(l).catch(d=>this._onerror(new Error(`Failed to send an error response: ${d}`)));return}let a=new AbortController;this._requestHandlerAbortControllers.set(e.id,a);let s=yb(e.params)?e.params.task:void 0,c=this._taskStore?this.requestTaskStore(e,r?.sessionId):void 0,u={signal:a.signal,sessionId:r?.sessionId,_meta:e.params?._meta,sendNotification:async l=>{if(a.signal.aborted)return;let d={relatedRequestId:e.id};i&&(d.relatedTask={taskId:i}),await this.notification(l,d);},sendRequest:async(l,d,p)=>{if(a.signal.aborted)throw new W(oe.ConnectionClosed,"Request was cancelled");let m={...p,relatedRequestId:e.id};i&&!m.relatedTask&&(m.relatedTask={taskId:i});let h=m.relatedTask?.taskId??i;return h&&c&&await c.updateTaskStatus(h,"input_required"),await this.request(l,d,m)},authInfo:n?.authInfo,requestId:e.id,requestInfo:n?.requestInfo,taskId:i,taskStore:c,taskRequestedTtl:s?.ttl,closeSSEStream:n?.closeSSEStream,closeStandaloneSSEStream:n?.closeStandaloneSSEStream};Promise.resolve().then(()=>{s&&this.assertTaskHandlerCapability(e.method);}).then(()=>o(e,u)).then(async l=>{if(a.signal.aborted)return;let d={result:l,jsonrpc:"2.0",id:e.id};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:"response",message:d,timestamp:Date.now()},r?.sessionId):await r?.send(d);},async l=>{if(a.signal.aborted)return;let d={jsonrpc:"2.0",id:e.id,error:{code:Number.isSafeInteger(l.code)?l.code:oe.InternalError,message:l.message??"Internal error",...l.data!==void 0&&{data:l.data}}};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:"error",message:d,timestamp:Date.now()},r?.sessionId):await r?.send(d);}).catch(l=>this._onerror(new Error(`Failed to send response: ${l}`))).finally(()=>{this._requestHandlerAbortControllers.get(e.id)===a&&this._requestHandlerAbortControllers.delete(e.id);});}_onprogress(e){let{progressToken:n,...o}=e.params,r=Number(n),i=this._progressHandlers.get(r);if(!i){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(e)}`));return}let a=this._responseHandlers.get(r),s=this._timeoutInfo.get(r);if(s&&a&&s.resetTimeoutOnProgress)try{this._resetTimeout(r);}catch(c){this._responseHandlers.delete(r),this._progressHandlers.delete(r),this._cleanupTimeout(r),a(c);return}i(o);}_onresponse(e){let n=Number(e.id),o=this._requestResolvers.get(n);if(o){if(this._requestResolvers.delete(n),xa(e))o(e);else {let a=new W(e.error.code,e.error.message,e.error.data);o(a);}return}let r=this._responseHandlers.get(n);if(r===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(e)}`));return}this._responseHandlers.delete(n),this._cleanupTimeout(n);let i=false;if(xa(e)&&e.result&&typeof e.result=="object"){let a=e.result;if(a.task&&typeof a.task=="object"){let s=a.task;typeof s.taskId=="string"&&(i=true,this._taskProgressTokens.set(s.taskId,n));}}if(i||this._progressHandlers.delete(n),xa(e))r(e);else {let a=W.fromError(e.error.code,e.error.message,e.error.data);r(a);}}get transport(){return this._transport}async close(){await this._transport?.close();}async*requestStream(e,n,o){let{task:r}=o??{};if(!r){try{yield {type:"result",result:await this.request(e,n,o)};}catch(a){yield {type:"error",error:a instanceof W?a:new W(oe.InternalError,String(a))};}return}let i;try{let a=await this.request(e,_o,o);if(a.task)i=a.task.taskId,yield {type:"taskCreated",task:a.task};else throw new W(oe.InternalError,"Task creation did not return a task");for(;;){let s=await this.getTask({taskId:i},o);if(yield {type:"taskStatus",task:s},Or(s.status)){s.status==="completed"?yield {type:"result",result:await this.getTaskResult({taskId:i},n,o)}:s.status==="failed"?yield {type:"error",error:new W(oe.InternalError,`Task ${i} failed`)}:s.status==="cancelled"&&(yield {type:"error",error:new W(oe.InternalError,`Task ${i} was cancelled`)});return}if(s.status==="input_required"){yield {type:"result",result:await this.getTaskResult({taskId:i},n,o)};return}let c=s.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(u=>setTimeout(u,c)),o?.signal?.throwIfAborted();}}catch(a){yield {type:"error",error:a instanceof W?a:new W(oe.InternalError,String(a))};}}request(e,n,o){let{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a,task:s,relatedTask:c}=o??{};return new Promise((u,l)=>{let d=A=>{l(A);};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===true)try{this.assertCapabilityForMethod(e.method),s&&this.assertTaskCapability(e.method);}catch(A){d(A);return}o?.signal?.throwIfAborted();let p=this._requestMessageId++,m={...e,jsonrpc:"2.0",id:p};o?.onprogress&&(this._progressHandlers.set(p,o.onprogress),m.params={...e.params,_meta:{...e.params?._meta||{},progressToken:p}}),s&&(m.params={...m.params,task:s}),c&&(m.params={...m.params,_meta:{...m.params?._meta||{},[Er]:c}});let h=A=>{this._responseHandlers.delete(p),this._progressHandlers.delete(p),this._cleanupTimeout(p),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:p,reason:String(A)}},{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a}).catch(q=>this._onerror(new Error(`Failed to send cancellation: ${q}`)));let R=A instanceof W?A:new W(oe.RequestTimeout,String(A));l(R);};this._responseHandlers.set(p,A=>{if(!o?.signal?.aborted){if(A instanceof Error)return l(A);try{let R=Pr(n,A.result);R.success?u(R.data):l(R.error);}catch(R){l(R);}}}),o?.signal?.addEventListener("abort",()=>{h(o?.signal?.reason);});let v=o?.timeout??tE,T=()=>h(W.fromError(oe.RequestTimeout,"Request timed out",{timeout:v}));this._setupTimeout(p,v,o?.maxTotalTimeout,T,o?.resetTimeoutOnProgress??false);let z=c?.taskId;if(z){let A=R=>{let q=this._responseHandlers.get(p);q?q(R):this._onerror(new Error(`Response handler missing for side-channeled request ${p}`));};this._requestResolvers.set(p,A),this._enqueueTaskMessage(z,{type:"request",message:m,timestamp:Date.now()}).catch(R=>{this._cleanupTimeout(p),l(R);});}else this._transport.send(m,{relatedRequestId:r,resumptionToken:i,onresumptiontoken:a}).catch(A=>{this._cleanupTimeout(p),l(A);});})}async getTask(e,n){return this.request({method:"tasks/get",params:e},Bl,n)}async getTaskResult(e,n,o){return this.request({method:"tasks/result",params:e},n,o)}async listTasks(e,n){return this.request({method:"tasks/list",params:e},Hl,n)}async cancelTask(e,n){return this.request({method:"tasks/cancel",params:e},wb,n)}async notification(e,n){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(e.method);let o=n?.relatedTask?.taskId;if(o){let s={...e,jsonrpc:"2.0",params:{...e.params,_meta:{...e.params?._meta||{},[Er]:n.relatedTask}}};await this._enqueueTaskMessage(o,{type:"notification",message:s,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(e.method)&&!e.params&&!n?.relatedRequestId&&!n?.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 s={...e,jsonrpc:"2.0"};n?.relatedTask&&(s={...s,params:{...s.params,_meta:{...s.params?._meta||{},[Er]:n.relatedTask}}}),this._transport?.send(s,n).catch(c=>this._onerror(c));});return}let a={...e,jsonrpc:"2.0"};n?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[Er]:n.relatedTask}}}),await this._transport.send(a,n);}setRequestHandler(e,n){let o=Nh(e);this.assertRequestHandlerCapability(o),this._requestHandlers.set(o,(r,i)=>{let a=Dh(e,r);return Promise.resolve(n(a,i))});}removeRequestHandler(e){this._requestHandlers.delete(e);}assertCanSetRequestHandler(e){if(this._requestHandlers.has(e))throw new Error(`A request handler for ${e} already exists, which would be overridden`)}setNotificationHandler(e,n){let o=Nh(e);this._notificationHandlers.set(o,r=>{let i=Dh(e,r);return Promise.resolve(n(i))});}removeNotificationHandler(e){this._notificationHandlers.delete(e);}_cleanupTaskProgressHandler(e){let n=this._taskProgressTokens.get(e);n!==void 0&&(this._progressHandlers.delete(n),this._taskProgressTokens.delete(e));}async _enqueueTaskMessage(e,n,o){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");let r=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(e,n,o,r);}async _clearTaskQueue(e,n){if(this._taskMessageQueue){let o=await this._taskMessageQueue.dequeueAll(e,n);for(let r of o)if(r.type==="request"&&$h(r.message)){let i=r.message.id,a=this._requestResolvers.get(i);a?(a(new W(oe.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(i)):this._onerror(new Error(`Resolver missing for request ${i} during task ${e} cleanup`));}}}async _waitForTaskUpdate(e,n){let o=this._options?.defaultTaskPollInterval??1e3;try{let r=await this._taskStore?.getTask(e);r?.pollInterval&&(o=r.pollInterval);}catch{}return new Promise((r,i)=>{if(n.aborted){i(new W(oe.InvalidRequest,"Request cancelled"));return}let a=setTimeout(r,o);n.addEventListener("abort",()=>{clearTimeout(a),i(new W(oe.InvalidRequest,"Request cancelled"));},{once:true});})}requestTaskStore(e,n){let o=this._taskStore;if(!o)throw new Error("No task store configured");return {createTask:async r=>{if(!e)throw new Error("No request provided");return await o.createTask(r,e.id,{method:e.method,params:e.params},n)},getTask:async r=>{let i=await o.getTask(r,n);if(!i)throw new W(oe.InvalidParams,"Failed to retrieve task: Task not found");return i},storeTaskResult:async(r,i,a)=>{await o.storeTaskResult(r,i,a,n);let s=await o.getTask(r,n);if(s){let c=Ia.parse({method:"notifications/tasks/status",params:s});await this.notification(c),Or(s.status)&&this._cleanupTaskProgressHandler(r);}},getTaskResult:r=>o.getTaskResult(r,n),updateTaskStatus:async(r,i,a)=>{let s=await o.getTask(r,n);if(!s)throw new W(oe.InvalidParams,`Task "${r}" not found - it may have been cleaned up`);if(Or(s.status))throw new W(oe.InvalidParams,`Cannot update task "${r}" from terminal status "${s.status}" to "${i}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await o.updateTaskStatus(r,i,a,n);let c=await o.getTask(r,n);if(c){let u=Ia.parse({method:"notifications/tasks/status",params:c});await this.notification(u),Or(c.status)&&this._cleanupTaskProgressHandler(r);}},listTasks:r=>o.listTasks(r,n)}}};function jb(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function Eb(t,e){let n={...t};for(let o in e){let r=o,i=e[r];if(i===void 0)continue;let a=n[r];jb(a)&&jb(i)?n[r]={...a,...i}:n[r]=i;}return n}var bS=dv(by()),xS=dv(kS());function o1(){let t=new bS.default({strict:false,validateFormats:true,validateSchema:false,allErrors:true});return (0, xS.default)(t),t}var Rd=class{constructor(e){this._ajv=e??o1();}getValidator(e){let n="$id"in e&&typeof e.$id=="string"?this._ajv.getSchema(e.$id)??this._ajv.compile(e):this._ajv.compile(e);return o=>n(o)?{valid:true,data:o,errorMessage:void 0}:{valid:false,data:void 0,errorMessage:this._ajv.errorsText(n.errors)}}};var Cd=class{constructor(e){this._server=e;}requestStream(e,n,o){return this._server.requestStream(e,n,o)}createMessageStream(e,n){let o=this._server.getClientCapabilities();if((e.tools||e.toolChoice)&&!o?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){let r=e.messages[e.messages.length-1],i=Array.isArray(r.content)?r.content:[r.content],a=i.some(l=>l.type==="tool_result"),s=e.messages.length>1?e.messages[e.messages.length-2]:void 0,c=s?Array.isArray(s.content)?s.content:[s.content]:[],u=c.some(l=>l.type==="tool_use");if(a){if(i.some(l=>l.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!u)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(u){let l=new Set(c.filter(p=>p.type==="tool_use").map(p=>p.id)),d=new Set(i.filter(p=>p.type==="tool_result").map(p=>p.toolUseId));if(l.size!==d.size||![...l].every(p=>d.has(p)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return this.requestStream({method:"sampling/createMessage",params:e},Oa,n)}elicitInputStream(e,n){let o=this._server.getClientCapabilities(),r=e.mode??"form";switch(r){case "url":{if(!o?.elicitation?.url)throw new Error("Client does not support url elicitation.");break}case "form":{if(!o?.elicitation?.form)throw new Error("Client does not support form elicitation.");break}}let i=r==="form"&&e.mode===void 0?{...e,mode:"form"}:e;return this.requestStream({method:"elicitation/create",params:i},ko,n)}async getTask(e,n){return this._server.getTask({taskId:e},n)}async getTaskResult(e,n,o){return this._server.getTaskResult({taskId:e},n,o)}async listTasks(e,n){return this._server.listTasks(e?{cursor:e}:void 0,n)}async cancelTask(e,n){return this._server.cancelTask({taskId:e},n)}};function wS(t,e,n){if(!t)throw new Error(`${n} does not support task creation (required for ${e})`);switch(e){case "tools/call":if(!t.tools?.call)throw new Error(`${n} does not support task creation for tools/call (required for ${e})`);break;}}function SS(t,e,n){if(!t)throw new Error(`${n} does not support task creation (required for ${e})`);switch(e){case "sampling/createMessage":if(!t.sampling?.createMessage)throw new Error(`${n} does not support task creation for sampling/createMessage (required for ${e})`);break;case "elicitation/create":if(!t.elicitation?.create)throw new Error(`${n} does not support task creation for elicitation/create (required for ${e})`);break;}}var Nd=class extends Yl{constructor(e,n){super(n),this._serverInfo=e,this._loggingLevels=new Map,this.LOG_LEVEL_SEVERITY=new Map(Ea.options.map((o,r)=>[o,r])),this.isMessageIgnored=(o,r)=>{let i=this._loggingLevels.get(r);return i?this.LOG_LEVEL_SEVERITY.get(o)<this.LOG_LEVEL_SEVERITY.get(i):false},this._capabilities=n?.capabilities??{},this._instructions=n?.instructions,this._jsonSchemaValidator=n?.jsonSchemaValidator??new Rd,this.setRequestHandler(xh,o=>this._oninitialize(o)),this.setNotificationHandler(wh,()=>this.oninitialized?.()),this._capabilities.logging&&this.setRequestHandler(Oh,async(o,r)=>{let i=r.sessionId||r.requestInfo?.headers["mcp-session-id"]||void 0,{level:a}=o.params,s=Ea.safeParse(a);return s.success&&this._loggingLevels.set(i,s.data),{}});}get experimental(){return this._experimental||(this._experimental={tasks:new Cd(this)}),this._experimental}registerCapabilities(e){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=Eb(this._capabilities,e);}setRequestHandler(e,n){let r=il(e)?.method;if(!r)throw new Error("Schema is missing a method literal");let i;if(uo(r)){let s=r;i=s._zod?.def?.value??s.value;}else {let s=r;i=s._def?.value??s.value;}if(typeof i!="string")throw new Error("Schema method literal must be a string");if(i==="tools/call"){let s=async(c,u)=>{let l=Pr(ja,c);if(!l.success){let h=l.error instanceof Error?l.error.message:String(l.error);throw new W(oe.InvalidParams,`Invalid tools/call request: ${h}`)}let{params:d}=l.data,p=await Promise.resolve(n(c,u));if(d.task){let h=Pr(_o,p);if(!h.success){let v=h.error instanceof Error?h.error.message:String(h.error);throw new W(oe.InvalidParams,`Invalid task creation result: ${v}`)}return h.data}let m=Pr(Xl,p);if(!m.success){let h=m.error instanceof Error?m.error.message:String(m.error);throw new W(oe.InvalidParams,`Invalid tools/call result: ${h}`)}return m.data};return super.setRequestHandler(e,s)}return super.setRequestHandler(e,n)}assertCapabilityForMethod(e){switch(e){case "sampling/createMessage":if(!this._clientCapabilities?.sampling)throw new Error(`Client does not support sampling (required for ${e})`);break;case "elicitation/create":if(!this._clientCapabilities?.elicitation)throw new Error(`Client does not support elicitation (required for ${e})`);break;case "roots/list":if(!this._clientCapabilities?.roots)throw new Error(`Client does not support listing roots (required for ${e})`);break;}}assertNotificationCapability(e){switch(e){case "notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case "notifications/resources/updated":case "notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${e})`);break;case "notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${e})`);break;case "notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${e})`);break;case "notifications/elicitation/complete":if(!this._clientCapabilities?.elicitation?.url)throw new Error(`Client does not support URL elicitation (required for ${e})`);break;}}assertRequestHandlerCapability(e){if(this._capabilities)switch(e){case "completion/complete":if(!this._capabilities.completions)throw new Error(`Server does not support completions (required for ${e})`);break;case "logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${e})`);break;case "prompts/get":case "prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${e})`);break;case "resources/list":case "resources/templates/list":case "resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${e})`);break;case "tools/call":case "tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${e})`);break;case "tasks/get":case "tasks/list":case "tasks/result":case "tasks/cancel":if(!this._capabilities.tasks)throw new Error(`Server does not support tasks capability (required for ${e})`);break;}}assertTaskCapability(e){SS(this._clientCapabilities?.tasks?.requests,e,"Client");}assertTaskHandlerCapability(e){this._capabilities&&wS(this._capabilities.tasks?.requests,e,"Server");}async _oninitialize(e){let n=e.params.protocolVersion;return this._clientCapabilities=e.params.capabilities,this._clientVersion=e.params.clientInfo,{protocolVersion:fb.includes(n)?n:vh,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},Ll)}async createMessage(e,n){if((e.tools||e.toolChoice)&&!this._clientCapabilities?.sampling?.tools)throw new Error("Client does not support sampling tools capability.");if(e.messages.length>0){let o=e.messages[e.messages.length-1],r=Array.isArray(o.content)?o.content:[o.content],i=r.some(u=>u.type==="tool_result"),a=e.messages.length>1?e.messages[e.messages.length-2]:void 0,s=a?Array.isArray(a.content)?a.content:[a.content]:[],c=s.some(u=>u.type==="tool_use");if(i){if(r.some(u=>u.type!=="tool_result"))throw new Error("The last message must contain only tool_result content if any is present");if(!c)throw new Error("tool_result blocks are not matching any tool_use from the previous message")}if(c){let u=new Set(s.filter(d=>d.type==="tool_use").map(d=>d.id)),l=new Set(r.filter(d=>d.type==="tool_result").map(d=>d.toolUseId));if(u.size!==l.size||![...u].every(d=>l.has(d)))throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match")}}return e.tools?this.request({method:"sampling/createMessage",params:e},Rh,n):this.request({method:"sampling/createMessage",params:e},Oa,n)}async elicitInput(e,n){switch(e.mode??"form"){case "url":{if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support url elicitation.");let r=e;return this.request({method:"elicitation/create",params:r},ko,n)}case "form":{if(!this._clientCapabilities?.elicitation?.form)throw new Error("Client does not support form elicitation.");let r=e.mode==="form"?e:{...e,mode:"form"},i=await this.request({method:"elicitation/create",params:r},ko,n);if(i.action==="accept"&&i.content&&r.requestedSchema)try{let s=this._jsonSchemaValidator.getValidator(r.requestedSchema)(i.content);if(!s.valid)throw new W(oe.InvalidParams,`Elicitation response content does not match requested schema: ${s.errorMessage}`)}catch(a){throw a instanceof W?a:new W(oe.InternalError,`Error validating elicitation response: ${a instanceof Error?a.message:String(a)}`)}return i}}}createElicitationCompletionNotifier(e,n){if(!this._clientCapabilities?.elicitation?.url)throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");return ()=>this.notification({method:"notifications/elicitation/complete",params:{elicitationId:e}},n)}async listRoots(e,n){return this.request({method:"roots/list",params:e},Ch,n)}async sendLoggingMessage(e,n){if(this._capabilities.logging&&!this.isMessageIgnored(e.level,n))return this.notification({method:"notifications/message",params:e})}async sendResourceUpdated(e){return this.notification({method:"notifications/resources/updated",params:e})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}};var Dd=class{append(e){this._buffer=this._buffer?Buffer.concat([this._buffer,e]):e;}readMessage(){if(!this._buffer)return null;let e=this._buffer.indexOf(`
|
|
87
87
|
`);if(e===-1)return null;let n=this._buffer.toString("utf8",0,e).replace(/\r$/,"");return this._buffer=this._buffer.subarray(e+1),i1(n)}clear(){this._buffer=void 0;}};function i1(t){return bb.parse(JSON.parse(t))}function TS(t){return JSON.stringify(t)+`
|
|
88
|
-
`}var Ad=class{constructor(e=zS.stdin,n=zS.stdout){this._stdin=e,this._stdout=n,this._readBuffer=new Dd,this._started=false,this._ondata=o=>{this._readBuffer.append(o),this.processReadBuffer();},this._onerror=o=>{this.onerror?.(o);};}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=true,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror);}processReadBuffer(){for(;;)try{let e=this._readBuffer.readMessage();if(e===null)break;this.onmessage?.(e);}catch(e){this.onerror?.(e);}}async close(){this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.();}send(e){return new Promise(n=>{let o=TS(e);this._stdout.write(o)?n():this._stdout.once("drain",n);})}};var IS="1.14.2";le();le();le();le();var C1=1e3,N1=["summary","status","assignee","priority","issuetype","created","updated","project","customfield_10014"];function D1({status:t,detail:e}){return t===401?new ms(`Authentication failed: ${e}`):t===403?new fs(`Permission denied: ${e}`):new wt(`Jira API error (${t}): ${e}`)}var Bd=class{http;instanceUrl;constructor(e){this.instanceUrl=e.url,this.http=new Xo(e,D1);}async request(e,n,o,r){return this.http.requestJson(e,n,o,r)}async searchIssues(e,n){return ((await this.request("GET","/rest/api/3/search/jql",void 0,{jql:e,fields:(n?[...n]:N1).join(","),maxResults:String(C1)})).issues??[]).map(i=>{let a=i.fields;return {key:i.key,summary:a.summary,status:a.status?.name??"Unknown",assignee:a.assignee?.emailAddress??null,priority:a.priority?.name??"None",issueType:a.issuetype?.name??a.issueType?.name??"Unknown",created:a.created,updated:a.updated,projectKey:i.key.split("-")[0]??"",epicLink:a.customfield_10014??null}})}async getIssue(e){let n=["summary","description","creator","status","assignee","priority","issuetype","created","updated","project","comment","timetracking"],o=await this.request("GET",`/rest/api/3/issue/${encodeURIComponent(e)}`,void 0,{fields:n.join(",")}),r=o.fields,i=(r.comment?.comments??[]).map(a=>({id:a.id??"",author:a.author?.emailAddress??a.author?.displayName??"Unknown",authorAccountId:a.author?.accountId??null,body:a.body??null,created:a.created??""}));return {key:o.key,summary:r.summary,description:r.description??null,creator:r.creator?.emailAddress??r.creator?.displayName??"Unknown",creatorAccountId:r.creator?.accountId??null,status:r.status?.name??"Unknown",assignee:r.assignee?.emailAddress??null,priority:r.priority?.name??"None",issueType:r.issuetype?.name??r.issueType?.name??"Unknown",created:r.created,updated:r.updated,projectKey:o.key.split("-")[0]??"",comments:i,timeTracking:{originalEstimate:r.timetracking?.originalEstimate??null,remainingEstimate:r.timetracking?.remainingEstimate??null,timeSpent:r.timetracking?.timeSpent??null,originalEstimateSeconds:r.timetracking?.originalEstimateSeconds??null,remainingEstimateSeconds:r.timetracking?.remainingEstimateSeconds??null,timeSpentSeconds:r.timetracking?.timeSpentSeconds??null}}}async addComment(e,n){let o=await this.request("POST",`/rest/api/3/issue/${encodeURIComponent(e)}/comment`,{body:n});return {id:o.id??"",author:o.author?.emailAddress??o.author?.displayName??"Unknown",authorAccountId:o.author?.accountId??null,body:o.body??null,created:o.created??""}}async deleteIssue(e){await this.request("DELETE",`/rest/api/3/issue/${encodeURIComponent(e)}`);}async deleteComment(e,n){await this.request("DELETE",`/rest/api/3/issue/${encodeURIComponent(e)}/comment/${encodeURIComponent(n)}`);}async getTransitions(e){return ((await this.request("GET",`/rest/api/3/issue/${encodeURIComponent(e)}/transitions`)).transitions??[]).map(o=>({id:o.id??"",name:o.name??"",toStatus:o.to?.name??""}))}async doTransition(e,n){await this.request("POST",`/rest/api/3/issue/${encodeURIComponent(e)}/transitions`,{transition:{id:n}});}async assignIssue(e,n){await this.request("PUT",`/rest/api/3/issue/${encodeURIComponent(e)}/assignee`,{accountId:n});}async findUser(e){let o=(await this.request("GET","/rest/api/3/user/search",void 0,{query:e,maxResults:"1"}))?.[0];if(!o?.accountId)throw new wt(`User not found for email: ${e}`);return o.accountId}async getCurrentUser(){let e=await this.request("GET","/rest/api/3/myself");return {accountId:e.accountId,emailAddress:e.emailAddress??null,displayName:e.displayName??"Unknown",active:e.active}}async addWorklog(e,n,o){let r={timeSpentSeconds:n};o&&(r.comment=o);let i=await this.request("POST",`/rest/api/3/issue/${encodeURIComponent(e)}/worklog`,r);return {id:i.id??"",timeSpent:i.timeSpent??"",timeSpentSeconds:i.timeSpentSeconds??n,created:i.created??""}}async getTimeTracking(e){let o=(await this.request("GET",`/rest/api/3/issue/${encodeURIComponent(e)}`,void 0,{fields:"timetracking"})).fields.timetracking;return {originalEstimate:o?.originalEstimate??null,remainingEstimate:o?.remainingEstimate??null,timeSpent:o?.timeSpent??null,originalEstimateSeconds:o?.originalEstimateSeconds??null,remainingEstimateSeconds:o?.remainingEstimateSeconds??null,timeSpentSeconds:o?.timeSpentSeconds??null}}async createIssue(e){let n=await this.request("POST","/rest/api/3/issue",{fields:e});return {key:n.key,id:n.id,url:`${this.instanceUrl}/browse/${n.key}`}}async updateIssue(e,n){await this.request("PUT",`/rest/api/3/issue/${encodeURIComponent(e)}`,{fields:n});}async getFields(){return (await this.request("GET","/rest/api/3/field")).map(n=>({id:n.id??"",name:n.name??"",custom:n.custom??false,...n.schema?.custom!==void 0?{schema:{custom:n.schema.custom}}:{}}))}async searchUsers(e,n=50){return (await this.request("GET","/rest/api/3/user/search",void 0,{query:e,maxResults:String(n)})??[]).map(r=>({accountId:r.accountId,emailAddress:r.emailAddress??null,displayName:r.displayName??"Unknown",active:r.active}))}async getProjectStatuses(e){return (await this.request("GET",`/rest/api/3/project/${encodeURIComponent(e)}/statuses`)).map(o=>({id:o.id,name:o.name,statuses:o.statuses.map(r=>({name:r.name??"",id:r.id??""}))}))}};var ei=class{byProject=new Map;byUrl=new Map;config;constructor(e){this.config=e,this.#e();}getConnector(e){let n=this.byProject.get(e);if(!n)throw new qe(`Project '${e}' not found in configuration`);return n}getConnectorForTask(e){let n=e.split("-")[0];if(!n)throw new qe(`Invalid task key format: '${e}'. Expected 'PROJECT-NUMBER'.`);return this.getConnector(n)}getInstances(){return this.byUrl}#e(){let e=new Map;for(let[n,o]of Object.entries(this.config.projects)){let r=e.get(o.url);r?r.push(n):e.set(o.url,[n]);}for(let[n,o]of e){let r=o[0];if(!r)continue;let i=this.config.projects[r];if(!i)continue;let a=new Bd(i),s={connector:a,projectKeys:o};this.byUrl.set(n,s);for(let c of o)this.byProject.set(c,a);}}};Mo();var zs="1.0",A1=_.object({key:_.string(),summary:_.string(),status:_.string(),assignee:_.string().nullable(),priority:_.string(),issue_type:_.string(),created:_.string(),updated:_.string(),project_key:_.string(),project_url:_.string().url(),epic_link:_.string().nullable()}),U1=_.object({version:_.string(),last_sync:_.string(),jira_user:_.string()}),ov=_.object({metadata:U1,tasks:_.array(A1)});le();le();function V1(t){return t.replaceAll("@","_at_").replaceAll(".","_")}var Gd=class{cacheDir;jiraUser;cachePath;constructor(e,n){this.cacheDir=e,this.jiraUser=n,this.cachePath=join(e,`tasks_${V1(n)}.json`);}async initialize(){if(await mkdir(this.cacheDir,{recursive:true,mode:448}),await Xt(this.cachePath)){try{await this.load();}catch(n){if(!(n instanceof St)){let o=n instanceof Error?n.message:String(n);throw new pr(`Existing cache is corrupted: ${o}`)}}return}let e={metadata:{version:zs,last_sync:new Date().toISOString(),jira_user:this.jiraUser},tasks:[]};await this.#e(e);}async load(){if(!await Xt(this.cachePath))throw new St(`Cache not found: ${this.cachePath}`);let e;try{e=await readFile(this.cachePath,"utf-8");}catch(r){let i=r instanceof Error?r.message:String(r);throw new St(`Failed to read cache file: ${i}`)}let n;try{n=JSON.parse(e);}catch(r){let i=r instanceof Error?r.message:String(r);throw new pr(`Cache file is corrupted (invalid JSON): ${i}`)}let o=ov.safeParse(n);if(!o.success)throw new pr(`Cache data failed validation: ${o.error.message}`);if(o.data.metadata.version!==zs)throw new pr(`Cache version ${o.data.metadata.version} !== ${zs}`);return o.data}async save(e){let n={metadata:{version:zs,last_sync:new Date().toISOString(),jira_user:this.jiraUser},tasks:[...e]},o=ov.safeParse(n);if(!o.success)throw new pr(`Task data failed validation: ${o.error.message}`);await this.#e(o.data);}async getTask(e){let o=(await this.load()).tasks.find(r=>r.key===e);if(!o)throw new Tt(`Task ${e} not found in cache`);return o}async getAllTasks(){return (await this.load()).tasks}async updateTask(e,n){let o=await this.load(),r=o.tasks.findIndex(c=>c.key===e);if(r===-1)throw new Tt(`Task ${e} not found in cache`);let i=o.tasks[r];if(!i)throw new Tt(`Task ${e} not found in cache`);let a={...i,...n,key:e,updated:new Date().toISOString()},s=[...o.tasks.slice(0,r),a,...o.tasks.slice(r+1)];return await this.save(s),a}async deleteTask(e){let n=await this.load(),o=n.tasks.filter(r=>r.key!==e);if(o.length===n.tasks.length)throw new Tt(`Task ${e} not found in cache`);await this.save(o);}async upsertTask(e){let n=[];try{n=(await this.load()).tasks;}catch(i){if(!(i instanceof St))throw i}let o=n.findIndex(i=>i.key===e.key),r=o===-1?[...n,e]:n.map((i,a)=>a===o?e:i);return await this.save(r),e}async getMetadata(){return (await this.load()).metadata}async#e(e){let n=`${this.cachePath}.tmp`,o=JSON.stringify(e,null,2);await writeFile(n,o,{encoding:"utf-8",mode:384}),await rename(n,this.cachePath);}};le();function Is(t){return t.replace(/([\\"])/g,"\\$1")}var Kd=class{#e;#t;#r;constructor(e,n,o){this.#e=e,this.#t=n,this.#r=o;}async sync(e){let n=e?.jql??`assignee = "${Is(this.#t.credentials.username)}" ORDER BY updated DESC`,o=Ld(this.#t);if(e?.projectKey){let i=this.#t.projects[e.projectKey];i&&(o=o.filter(a=>a.url===i.url));}let r=[];for(let i of o){let c=(await this.#r(i.url,i.username,i.api_token).searchIssues(n)).map(u=>this.#n(u,i.url));r.push(...c);}return await this.#e.save(r),r.length}#n(e,n){let o=e.fields.assignee?.emailAddress??null,r=e.fields.priority?.name??"None",i=e.fields.customfield_10014??null;return {key:e.key,summary:e.fields.summary,status:e.fields.status.name,assignee:o,priority:r,issue_type:e.fields.issuetype.name,created:e.fields.created,updated:e.fields.updated,project_key:e.fields.project.key,project_url:n,epic_link:i}}};le();function B1(t){let e=t;for(;;){if(existsSync(join(e,"package.json")))return e;let n=dirname(e);if(n===e)return fileURLToPath(new URL("..",import.meta.url));e=n;}}var G1=B1(dirname(fileURLToPath(import.meta.url)));join(xs,"workflows.json");join(xs,"users.json");var iv=join(Lr,"templates"),b0=join(iv,"comments"),x0=join(iv,"task-templates"),w0=join(iv,"tasks"),av=join(G1,"templates-system"),S0=join(av,"comments"),T0=join(av,"task-templates");join(av,"locales");Mo();var Fr={WORKFLOW:"workflow",COMMUNICATION:"communication",REPORTING:"reporting",DEVELOPMENT:"development"};le();var P0=/^[a-z][a-z0-9-]*$/,j0=_.object({name:_.string().regex(/^\w+$/,"Variable name must be alphanumeric/underscore"),description:_.string().default(""),required:_.boolean().default(false),default:_.string().optional(),example:_.string().optional()}),H1=_.object({kind:_.literal("comment"),id:_.string().regex(P0,"Template id must be a URL-safe slug"),name:_.string().min(1),description:_.string().min(1),category:_.enum([Fr.WORKFLOW,Fr.COMMUNICATION,Fr.REPORTING,Fr.DEVELOPMENT]),variables:_.array(j0).default([])}),W1=_.object({kind:_.literal("task"),id:_.string().regex(P0,"Template id must be a URL-safe slug"),name:_.string().min(1),description:_.string().min(1),summary:_.string().min(1),issue_type:_.string().optional(),priority:_.string().optional(),labels:_.array(_.string()).optional(),epic_key:_.string().optional(),variables:_.array(j0).default([])});function E0(t){return t.map(e=>({name:e.name,description:e.description,required:e.required,defaultValue:e.default,example:e.example}))}function O0(t,e){let n=t.match(/^---\s*\n([\s\S]*?)\n---\s*\n?([\s\S]*)$/);if(!n)throw new mr(`Template file "${e}" must start with a JSON metadata block delimited by ---`);let[,o,r=""]=n;if(o===void 0)throw new mr(`Template file "${e}" is missing metadata.`);let i;try{i=JSON.parse(o);}catch(a){let s=a instanceof Error?a.message:String(a);throw new mr(`Template file "${e}" contains invalid JSON metadata: ${s}`)}return {metadata:i,body:r.trim()}}function R0(t){if(!readdirSync||!t)return [];try{return readdirSync(t).filter(e=>e.endsWith(".md")).sort().map(e=>join(t,e))}catch{return []}}function Hd(t,e){let n=[];for(let o of R0(t)){let r=readFileSync(o,"utf-8"),i=O0(r,o),a=H1.parse(i.metadata);n.push({id:a.id,name:a.name,description:a.description,category:a.category,variables:E0(a.variables),body:i.body,source:e,filePath:o});}return n}function Wd(t,e){let n=[];for(let o of R0(t)){let r=readFileSync(o,"utf-8"),i=O0(r,o),a=W1.parse(i.metadata);n.push({id:a.id,name:a.name,description:a.description,summary:a.summary,issueType:a.issue_type,priority:a.priority,labels:a.labels,epicKey:a.epic_key,variables:E0(a.variables),body:i.body,source:e,filePath:o});}return n}var C0=Hd(S0,"system");le();var Xd=class{templates;constructor(e){let n=new Map;for(let o of C0)n.set(o.id,o);if(e)for(let o of e)n.set(o.id,o);this.templates=n;}getTemplate(e){let n=this.templates.get(e);if(!n)throw new kn(`Template "${e}" not found. Use listTemplates() to see available templates.`);return n}listTemplates(e){let n=[...this.templates.values()];return e?n.filter(o=>o.category===e):n}listCategories(){let e=new Set;for(let n of this.templates.values())e.add(n.category);return [...e]}};le();var N0=Wd(T0,"system");var Yd=class{templates;constructor(e){let n=new Map;for(let o of N0)n.set(o.id,o);if(e)for(let o of e)n.set(o.id,o);this.templates=n;}getTemplate(e){let n=this.templates.get(e);if(!n)throw new kn(`Task template "${e}" not found. Use listTaskTemplates() to see available templates.`);return n}listTemplates(){return [...this.templates.values()]}};function D0(t){let e=Hd(b0,"user"),n=Wd(x0,"user");return {commentRegistry:new Xd(e),taskRegistry:new Yd(n)}}le();var sv=[{name:"sync_tasks",description:"Sync tasks from Jira to local cache. By default syncs from all configured instances. Optionally scope to a single project or provide a custom JQL query.",inputSchema:{type:"object",properties:{project_key:{type:"string",description:"Optional project key to sync from a single instance."},jql:{type:"string",description:"Optional JQL query. If omitted, fetches tasks assigned to the current user."}}}},{name:"read_cached_tasks",description:"Read tasks from local cache without hitting the Jira API. Returns a single task when task_key is provided, or all cached tasks otherwise.",inputSchema:{type:"object",properties:{task_key:{type:"string",description:'Optional task key (e.g. "PROJ-123"). If omitted, returns all cached tasks.'}}}},{name:"update_task_status",description:"Change a task status via Jira workflow transition and update the local cache.",inputSchema:{type:"object",properties:{task_key:{type:"string",description:'Task key (e.g. "PROJ-123").'},status:{type:"string",description:'Target status name (e.g. "In Progress", "Done"). Use get_task_statuses first to check valid transitions.'}},required:["task_key","status"]}},{name:"add_task_comment",description:"Add a markdown comment to a Jira task. The markdown is automatically converted to ADF format.",inputSchema:{type:"object",properties:{task_key:{type:"string",description:'Task key (e.g. "PROJ-123").'},comment:{type:"string",description:"Comment text in markdown format."},user_approved:{type:"boolean",description:"Must be true only after the user explicitly approves posting this comment."}},required:["task_key","comment"]}},{name:"delete_task",description:"Delete a Jira task, but only when the authenticated user is the task creator.",inputSchema:{type:"object",properties:{task_key:{type:"string",description:'Task key (e.g. "PROJ-123").'},user_approved:{type:"boolean",description:"Must be true only after the user explicitly approves deleting this task."}},required:["task_key"]}},{name:"delete_comment",description:"Delete a Jira comment, but only when the authenticated user is the comment author.",inputSchema:{type:"object",properties:{task_key:{type:"string",description:'Task key (e.g. "PROJ-123").'},comment_id:{type:"string",description:"Comment ID to delete."},user_approved:{type:"boolean",description:"Must be true only after the user explicitly approves deleting this comment."}},required:["task_key","comment_id"]}},{name:"reassign_task",description:"Reassign a task to a different user by email, or unassign by providing an empty string or omitting assignee_email.",inputSchema:{type:"object",properties:{task_key:{type:"string",description:'Task key (e.g. "PROJ-123").'},assignee_email:{type:"string",description:"Email of the new assignee. Empty string or omit to unassign."}},required:["task_key"]}},{name:"get_task_statuses",description:"Get available workflow transitions for a task. Call this before update_task_status to see valid target statuses.",inputSchema:{type:"object",properties:{task_key:{type:"string",description:'Task key (e.g. "PROJ-123").'}},required:["task_key"]}},{name:"get_task_details",description:"Get full task details from Jira including description and all comments, with ADF content converted to markdown.",inputSchema:{type:"object",properties:{task_key:{type:"string",description:'Task key (e.g. "PROJ-123").'}},required:["task_key"]}},{name:"log_task_time",description:"Log work time to a Jira task. Uses hours and minutes format only (no days). Invalidates cache after logging.",inputSchema:{type:"object",properties:{task_key:{type:"string",description:'Task key (e.g. "PROJ-123").'},time_spent:{type:"string",description:'Time in format "2h", "30m", or "2h 30m". Days are not supported.'},comment:{type:"string",description:"Optional work description."}},required:["task_key","time_spent"]}},{name:"get_task_time_tracking",description:"Get time tracking information for a Jira task (original estimate, time spent, remaining estimate).",inputSchema:{type:"object",properties:{task_key:{type:"string",description:'Task key (e.g. "PROJ-123").'}},required:["task_key"]}},{name:"list_comment_templates",description:"List all available comment templates with optional category filter. Returns template metadata including required variables.",inputSchema:{type:"object",properties:{category:{type:"string",description:'Optional category filter: "workflow", "communication", "reporting", or "development".',enum:["workflow","communication","reporting","development"]}}}},{name:"add_templated_comment",description:"Add a comment using a registered template (with variable substitution) or raw markdown. Provide exactly one of template_id or markdown.",inputSchema:{type:"object",properties:{task_key:{type:"string",description:'Task key (e.g. "PROJ-123").'},template_id:{type:"string",description:"Template identifier. Use list_comment_templates to see available templates."},variables:{type:"object",description:"Key-value map of template variables. Required when using template_id.",additionalProperties:{type:"string"}},markdown:{type:"string",description:"Raw markdown comment. Use instead of template_id for freeform comments."},user_approved:{type:"boolean",description:"Must be true only after the user explicitly approves posting this comment."}},required:["task_key"]}},{name:"create_task",description:"Create a new Jira issue with either explicit fields or a registered task template, plus optional assignee, labels, epic link, sub-task parent, and original estimate.",inputSchema:{type:"object",properties:{project_key:{type:"string",description:'Project key (e.g. "DEVOPS"). Determines which Jira instance to use.'},summary:{type:"string",description:"Issue title / summary. Do not provide when using template_id."},description:{type:"string",description:"Optional issue description in markdown format. Automatically converted to ADF. Do not provide when using template_id."},template_id:{type:"string",description:"Task template identifier. Use list_task_templates to see available templates."},variables:{type:"object",description:"Key-value map of template variables. Required when using template_id.",additionalProperties:{type:"string"}},type:{type:"string",description:'Issue type name (default "Task"). E.g. "Bug", "Story", "Epic".'},priority:{type:"string",description:'Priority name (default "Medium"). E.g. "High", "Low", "Critical".'},assignee_email:{type:"string",description:"Email of the assignee. Resolved to Jira account ID."},labels:{type:"array",items:{type:"string"},description:"Array of label strings to apply to the issue."},epic_key:{type:"string",description:'Epic issue key to link this issue under (e.g. "PROJ-100").'},parent_key:{type:"string",description:'Parent issue key (e.g. "PROJ-69"). Required when type is a sub-task; Jira rejects sub-task creation without it.'},original_estimate:{type:"string",description:'Original estimate in format "2h", "30m", or "2h 30m". Days are not supported.'}},required:["project_key"]}},{name:"list_task_templates",description:"List all available single-task templates used by create_task. Returns template metadata including required variables.",inputSchema:{type:"object",properties:{}}},{name:"get_project_language",description:"Get the configured language for a project. Use before writing comments or descriptions to determine the correct language.",inputSchema:{type:"object",properties:{project_key:{type:"string",description:'Project key (e.g. "DEVOPS"). Inferred from task key prefix.'}},required:["project_key"]}},{name:"update_task",description:"Update an existing Jira issue, including its original and remaining estimates. Only provided fields are changed; omitted fields are left untouched.",inputSchema:{type:"object",properties:{task_key:{type:"string",description:'Task key (e.g. "DEVOPS-37"). Project is inferred from the key prefix.'},summary:{type:"string",description:"New issue title / summary."},description:{type:"string",description:"New issue description in markdown format. Automatically converted to ADF."},priority:{type:"string",description:'New priority name. E.g. "Medium", "Low", "Critical".'},labels:{type:"array",items:{type:"string"},description:"New set of label strings (replaces existing labels)."},original_estimate:{type:"string",description:'New original estimate in format "2h", "30m", or "2h 30m". Days are not supported.'},remaining_estimate:{type:"string",description:'New remaining estimate in format "2h", "30m", or "2h 30m". Days are not supported. Independent of original_estimate -- setting one leaves the other unchanged.'}},required:["task_key"]}},{name:"search_tasks",description:"Search Jira issues using JQL. Returns results directly without caching.",inputSchema:{type:"object",properties:{jql:{type:"string",description:"JQL query string."},max_results:{type:"number",description:"Maximum number of results to return (default 50)."},project_key:{type:"string",description:"Optional project key to determine which Jira instance to query. Defaults to the configured default project."}},required:["jql"]}},{name:"create_monthly_tasks",description:"Run all monthly_admin.json bulk task configs from ~/.softspark/jira-mcp/templates/tasks/<KEY>/. Defaults to dry-run. Set execute=true to actually create the tasks. Optionally filter to a single project key.",inputSchema:{type:"object",properties:{execute:{type:"boolean",description:"When true, create tasks for real. When false or omitted, run a dry-run preview."},project:{type:"string",description:"Optional project key (case-insensitive) to restrict execution to a single project subdirectory."}}}}];le();le();le();var X1=/(\d+)\s*h/i,Y1=/(\d+)\s*m/i,Q1=/\d+\s*d/i;function xn(t){let e=t.trim();if(e.length===0)throw new Error("Invalid time format: empty string. Use: '2h', '30m', or '2h 30m'");if(Q1.test(e))throw new Error("Days (d) not supported. Use hours (h) and minutes (m) only. Example: '2h', '30m', or '2h 30m'");let n=0,o=X1.exec(e);o?.[1]&&(n+=parseInt(o[1],10)*3600);let r=Y1.exec(e);if(r?.[1]&&(n+=parseInt(r[1],10)*60),n===0)throw new Error(`Invalid time format: '${t}'. Use: '2h', '30m', or '2h 30m'`);return n}le();var Qd=class{constructor(e,n){this.connector=e;this.cacheManager=n;}connector;cacheManager;async changeStatus(e,n){let o=await this.connector.getTransitions(e),r=o.find(a=>a.toStatus.toLowerCase()===n.toLowerCase())??o.find(a=>a.name.toLowerCase()===n.toLowerCase());if(!r){let a=o.map(s=>`${s.name} -> ${s.toStatus}`).join(", ");throw new wt(`Status '${n}' not available for ${e}. Available transitions: ${a}`)}await this.connector.doTransition(e,r.id);let i=await this.#e(e,{status:r.toStatus||n});return {taskKey:e,updatedTask:i}}async getAvailableStatuses(e){return (await this.connector.getTransitions(e)).map(o=>({id:o.id,name:o.name,toStatus:o.toStatus}))}async addComment(e,n){let o=zt(n),r=await this.connector.addComment(e,o);return {taskKey:e,commentId:r.id,author:r.author,bodyMarkdown:Wo(r.body),created:r.created}}async deleteComment(e,n){let o=await this.connector.getCurrentUser(),i=(await this.connector.getIssue(e)).comments.find(a=>a.id===n);if(!i)throw new _s(`Comment ${n} not found on ${e}.`);if(i.authorAccountId==null||i.authorAccountId!==o.accountId)throw new Vo(`Comment ${n} on ${e} can only be deleted by its author.`);return await this.connector.deleteComment(e,n),{taskKey:e,commentId:n}}async reassign(e,n){if(n){let r=await this.connector.findUser(n);await this.connector.assignIssue(e,r);}else await this.connector.assignIssue(e,null);let o=await this.#e(e,{assignee:n??null});return {taskKey:e,updatedTask:o}}async getTaskDetails(e){let n=await this.connector.getIssue(e),o=n.comments.map(r=>({id:r.id,author:r.author,body:Wo(r.body),created:r.created}));return {key:n.key,summary:n.summary,description:Wo(n.description),status:n.status,assignee:n.assignee,priority:n.priority,issueType:n.issueType,created:n.created,updated:n.updated,comments:o}}async deleteTask(e){let n=await this.connector.getCurrentUser(),o=await this.connector.getIssue(e);if(o.creatorAccountId==null||o.creatorAccountId!==n.accountId)throw new Vo(`Task ${e} can only be deleted by its creator.`);await this.connector.deleteIssue(e);try{await this.cacheManager.deleteTask(e);}catch(r){if(!(r instanceof Tt||r instanceof St))throw r}return {taskKey:e}}async logTime(e,n,o){let r=xn(n),i=o?zt(o):void 0,a=await this.connector.addWorklog(e,r,i);try{await this.cacheManager.deleteTask(e);}catch(s){if(!(s instanceof Tt||s instanceof St))throw s}return {taskKey:e,worklogId:a.id,timeSpent:n,timeSpentSeconds:a.timeSpentSeconds}}async getTimeTracking(e){let n=await this.connector.getTimeTracking(e);return {taskKey:e,originalEstimate:n.originalEstimate,remainingEstimate:n.remainingEstimate,timeSpent:n.timeSpent}}async#e(e,n){try{return await this.cacheManager.updateTask(e,n)}catch(o){if(!(o instanceof Tt||o instanceof St))throw o;let r=await this.connector.getIssue(e),i={key:r.key,summary:r.summary,status:r.status,assignee:r.assignee,priority:r.priority,issue_type:r.issueType,created:r.created,updated:r.updated,project_key:r.projectKey,project_url:this.connector.instanceUrl,epic_link:null,...n};return await this.cacheManager.upsertTask(i)}}};function je(t,e,n){let o=t.getConnectorForTask(n);return new Qd(o,e)}async function A0(t,e){try{let n={...t.jql?{jql:t.jql}:{},...t.project_key?{projectKey:t.project_key}:{}},o=await e.syncer.sync(n);return K({tasks_synced:o,message:`Synced ${o} tasks`})}catch(n){return M(n)}}async function U0(t,e){try{if(t.task_key){let o=await e.cacheManager.getTask(t.task_key);return K({task:o})}let n=await e.cacheManager.getAllTasks();return K({tasks:n,count:n.length})}catch(n){return M(n)}}async function Z0(t,e){try{let o=await je(e.pool,e.cacheManager,t.task_key).changeStatus(t.task_key,t.status);return K({task:o.updatedTask,message:`Updated ${t.task_key} status to '${t.status}'`})}catch(n){return M(n)}}le();async function M0(t,e){try{Yo(t.user_approved);let o=await je(e.pool,e.cacheManager,t.task_key).addComment(t.task_key,t.comment);return K({comment:{id:o.commentId,author:o.author,body:o.bodyMarkdown,created:o.created},message:`Added comment to ${t.task_key}`})}catch(n){return M(n)}}le();async function L0(t,e){try{Qo(t.user_approved);let o=await je(e.pool,e.cacheManager,t.task_key).deleteTask(t.task_key);return K({deleted:{task_key:o.taskKey},message:`Deleted task ${t.task_key}`})}catch(n){return M(n)}}le();async function q0(t,e){try{Qo(t.user_approved);let o=await je(e.pool,e.cacheManager,t.task_key).deleteComment(t.task_key,t.comment_id);return K({deleted:{task_key:o.taskKey,comment_id:o.commentId},message:`Deleted comment ${t.comment_id} from ${t.task_key}`})}catch(n){return M(n)}}async function F0(t,e){try{let n=je(e.pool,e.cacheManager,t.task_key),o=t.assignee_email?.trim()||null,r=await n.reassign(t.task_key,o),i=o?`Reassigned ${t.task_key} to ${o}`:`Unassigned ${t.task_key}`;return K({task:r.updatedTask,message:i})}catch(n){return M(n)}}async function V0(t,e){try{let o=await je(e.pool,e.cacheManager,t.task_key).getAvailableStatuses(t.task_key);return K({task_key:t.task_key,statuses:o.map(r=>({id:r.id,name:r.name,to_status:r.toStatus}))})}catch(n){return M(n)}}async function J0(t,e){try{let o=await je(e.pool,e.cacheManager,t.task_key).getTaskDetails(t.task_key),r=t.task_key.split("-")[0]??"",i=e.config.projects[r]?.language??e.config.default_language;return K({task:o,language:i,message:`Retrieved details for ${t.task_key}`})}catch(n){return M(n)}}async function B0(t,e){try{let n=e.config.projects[t.project_key],o=n?.language??e.config.default_language;return K({project_key:t.project_key,language:o,source:n?.language?"project":"default",message:`Project ${t.project_key} language: ${o}`})}catch(n){return M(n)}}async function G0(t,e){try{let o=await je(e.pool,e.cacheManager,t.task_key).logTime(t.task_key,t.time_spent,t.comment);return K({message:`Logged ${t.time_spent} to ${t.task_key}`,worklog_id:o.worklogId,time_spent:o.timeSpent,time_spent_seconds:o.timeSpentSeconds})}catch(n){return M(n)}}async function K0(t,e){try{let o=await je(e.pool,e.cacheManager,t.task_key).getTimeTracking(t.task_key);return K({task_key:t.task_key,time_tracking:{original_estimate:o.originalEstimate,time_spent:o.timeSpent,remaining_estimate:o.remainingEstimate},message:`Retrieved time tracking for ${t.task_key}`})}catch(n){return M(n)}}function eA(t){return Object.values(Fr).includes(t)}async function H0(t,e){try{let n;if(t.category){if(!eA(t.category)){let i=Object.values(Fr).join(", ");return M(new Error(`Invalid category '${t.category}'. Valid categories: ${i}`))}n=t.category;}let o=e.templateRegistry.listTemplates(n),r=e.templateRegistry.listCategories();return K({templates:o.map(i=>({id:i.id,name:i.name,description:i.description,category:i.category,source:i.source??"system",file_path:i.filePath,variables:i.variables.map(a=>({name:a.name,description:a.description,required:a.required,example:a.example}))})),categories:r,count:o.length})}catch(n){return M(n)}}async function W0(t,e){try{let n=e.taskTemplateRegistry.listTemplates();return K({templates:n.map(o=>({id:o.id,name:o.name,description:o.description,summary:o.summary,issue_type:o.issueType??"Task",priority:o.priority??"Medium",labels:o.labels??[],source:o.source??"system",file_path:o.filePath,variables:o.variables.map(r=>({name:r.name,description:r.description,required:r.required,example:r.example}))})),count:n.length})}catch(n){return M(n)}}le();le();async function X0(t,e){try{if(Yo(t.user_approved),t.template_id&&t.markdown)return M(new Error("Provide either template_id or markdown, not both."));if(!t.template_id&&!t.markdown)return M(new Error("Provide either template_id (with variables) or markdown."));let n,o;if(t.template_id){let a=e.templateRegistry.getTemplate(t.template_id),s=bn(a,t.variables??{});if(!s.success)return M(new Error(s.error));n=s.markdown,o={template_id:a.id,template_name:a.name};}else n=t.markdown??"";let i=await je(e.pool,e.cacheManager,t.task_key).addComment(t.task_key,n);return K({comment:{id:i.commentId,author:i.author,body:i.bodyMarkdown,created:i.created},...o?{template:o}:{},message:`Added comment to ${t.task_key}`})}catch(n){return M(n)}}le();le();async function tA(t){return (await t.getFields()).find(o=>o.custom&&o.name.toLowerCase()==="epic link")?.id}async function Y0(t,e){try{let n=t.template_id!==void 0;if(n&&(t.summary!==""||t.description!==void 0))return M(new Error("When template_id is provided, do not also provide summary or description."));if(!n&&t.summary.trim()==="")return M(new Error("Provide either template_id (with variables) or a non-empty summary."));let o=e.pool.getConnector(t.project_key),r=t.summary,i=t.description,a=t.type,s=t.priority,c=t.labels,u=t.epic_key,l;if(n){let m=e.taskTemplateRegistry.getTemplate(t.template_id??""),h=bn({variables:m.variables,body:m.summary},t.variables??{});if(!h.success)return M(new Error(h.error));let v=bn({variables:m.variables,body:m.body},t.variables??{});if(!v.success)return M(new Error(v.error));r=h.markdown,i=v.markdown===""?void 0:v.markdown,a=t.type??m.issueType,s=t.priority??m.priority,c=t.labels??m.labels,u=t.epic_key??m.epicKey,l={template_id:m.id,template_name:m.name,source:m.source??"system"};}let d={project:{key:t.project_key},summary:r,issuetype:{name:a??"Task"},priority:{name:s??"Medium"}};if(i&&(d.description=zt(i)),c&&c.length>0&&(d.labels=c),t.assignee_email){let m=await o.findUser(t.assignee_email);d.assignee={accountId:m};}if(t.parent_key&&(d.parent={key:t.parent_key}),t.original_estimate&&(xn(t.original_estimate),d.timetracking={originalEstimate:t.original_estimate}),u){let m=await tA(o);m&&(d[m]=u);}let p=await o.createIssue(d);return K({issue_key:p.key,url:p.url,summary:r,...l?{template:l}:{},message:`Created ${p.key}: ${r}`})}catch(n){return M(n)}}le();async function Q0(t,e){try{let n=t.task_key.split("-")[0]??"",o=e.pool.getConnector(n),r={};t.summary!==void 0&&(r.summary=t.summary),t.description!==void 0&&(r.description=zt(t.description)),t.priority!==void 0&&(r.priority={name:t.priority}),t.labels!==void 0&&(r.labels=t.labels);let i={};if(t.original_estimate!==void 0&&(xn(t.original_estimate),i.originalEstimate=t.original_estimate),t.remaining_estimate!==void 0&&(xn(t.remaining_estimate),i.remainingEstimate=t.remaining_estimate),Object.keys(i).length>0&&(r.timetracking=i),Object.keys(r).length===0)return M(new Error("No fields to update. Provide at least one of: summary, description, priority, labels, original_estimate, remaining_estimate."));await o.updateIssue(t.task_key,r);let a=Object.keys(r).join(", ");return K({task_key:t.task_key,updated_fields:a,message:`Updated ${t.task_key}: ${a}`})}catch(n){return M(n)}}var rA=50,nA=["summary","status","assignee","priority","issuetype","created","updated","project","customfield_10014"];async function eT(t,e){try{let n=t.project_key??e.config.default_project,o=e.pool.getConnector(n),r=t.max_results??rA,i=await o.searchIssues(t.jql,nA),a=i.slice(0,r);return K({results:a,count:a.length,total_available:i.length,message:`Found ${a.length} issue(s) matching JQL query`})}catch(n){return M(n)}}Mo();le();var oA=_.object({summary:_.string().min(1,"Summary is required").max(255),description:_.string().optional().default(""),type:_.string().default("Task"),assignee:_.string().email("Invalid assignee email format").optional(),priority:_.enum(["Highest","High","Medium","Low","Lowest"]).default("Medium"),labels:_.array(_.string()).default([]),estimate_hours:_.number().positive("Estimate must be positive").optional(),status:_.union([_.string(),_.array(_.string().min(1)).min(1,"Status path must not be empty")]).optional()}).catchall(_.string().optional()),iA=_.object({dry_run:_.boolean().default(true),update_existing:_.boolean().default(false),match_field:_.string().default("summary"),rate_limit_ms:_.number().int().min(0).default(500),force_reassign:_.boolean().default(false),reassign_delay_ms:_.number().int().min(0).default(0),language:Zt.default(Yt)}),tT=_.object({epic_key:_.string().regex(/^[A-Z][A-Z0-9]*-\d+$/,"Invalid epic key format (e.g., PROJ-123)"),tasks:_.array(oA).min(1,"At least one task is required"),options:iA.default(()=>({dry_run:true,update_existing:false,match_field:"summary",rate_limit_ms:500,force_reassign:false,reassign_delay_ms:0,language:Yt}))});function aA(t){let e=new Date;return {MONTH:`${String(e.getMonth()+1).padStart(2,"0")}.${e.getFullYear()}`,YEAR:String(e.getFullYear()),DATE:e.toISOString().slice(0,10)}}function rT(t,e){let n=aA(),o=JSON.stringify(t);return o=o.replaceAll("{MONTH}",n.MONTH),o=o.replaceAll("{YEAR}",n.YEAR),o=o.replaceAll("{DATE}",n.DATE),JSON.parse(o)}le();le();function nT(t){return new Promise(e=>setTimeout(e,t))}var cv=class extends Pe{constructor(e){super(e,"EPIC_NOT_FOUND"),this.name="EpicNotFoundError";}},ep=class extends Pe{constructor(e){super(e,"EPIC_LINK_FIELD_NOT_FOUND"),this.name="EpicLinkFieldNotFoundError";}},tp=class{constructor(e,n){this.connector=e;this.projectKey=n;}connector;projectKey;epicLinkFieldId=null;assigneeCache=new Map;async execute(e){let n=Date.now(),o=e.epic_key,r=e.options;if(!await this.validateEpic(o))throw new cv(`Epic '${o}' not found or not accessible`);this.epicLinkFieldId=await this.discoverEpicLinkField();let a=new Set;for(let l of e.tasks)l.assignee&&a.add(l.assignee);for(let l of a)try{await this.resolveAssignee(l);}catch{}let s=[];for(let l=0;l<e.tasks.length;l++){l>0&&r.rate_limit_ms>0&&await nT(r.rate_limit_ms);let d=e.tasks[l];if(!d)continue;let p=await this.processTask(d,o,r);s.push(p);}let c=sA(s),u=Date.now()-n;return {results:s,summary:c,dry_run:r.dry_run,total_time_ms:u}}async validateEpic(e){try{return await this.connector.getIssue(e),!0}catch{return false}}async discoverEpicLinkField(){let e;try{e=await this.connector.getFields();}catch(n){let o=n instanceof Error?n.message:String(n);throw new ep(`Failed to fetch fields from Jira: ${o}`)}for(let n of e){if(n.name.toLowerCase().includes("epic link"))return n.id;let r=n.schema?.custom??"";if(r.includes("epic-link")||r.includes("gh-epic-link"))return n.id}throw new ep("Epic Link custom field not found. Ensure Jira instance has Epic support enabled.")}async resolveAssignee(e){let n=this.assigneeCache.get(e);if(n!==void 0)return n;let o=await this.connector.findUser(e);return this.assigneeCache.set(e,o),o}async processTask(e,n,o){let r=this.selectSummary(e,o.language);if(o.dry_run)return {summary:r,issue_key:null,action:"preview",error:null,url:null,warning:null};try{let i=await this.findExistingTask(r,this.projectKey);if(i!==null){if(o.update_existing){let c=await this.updateTask(i,e,n,this.epicLinkFieldId,o);return {summary:r,issue_key:i,action:"updated",error:null,url:`${this.connector.instanceUrl}/browse/${i}`,warning:c}}return {summary:r,issue_key:i,action:"skipped",error:null,url:`${this.connector.instanceUrl}/browse/${i}`,warning:null}}let a=await this.createTask(e,n,this.epicLinkFieldId,o),s=e.status?await this.applyStatusPath(a.key,e.status):null;return o.force_reassign&&e.assignee&&await this.forceReassign(a.key,e.assignee,o.reassign_delay_ms),{summary:r,issue_key:a.key,action:"created",error:null,url:a.url,warning:s}}catch(i){let a=i instanceof Error?i.message:String(i);return {summary:r,issue_key:null,action:"failed",error:a,url:null,warning:null}}}async createTask(e,n,o,r){let i=this.selectSummary(e,r.language),a=this.selectDescription(e,r.language),s={project:{key:this.projectKey},summary:i,issuetype:{name:e.type??"Task"},priority:{name:e.priority??"Medium"}};if(a&&(s.description=zt(a)),e.labels&&e.labels.length>0&&(s.labels=[...e.labels]),e.estimate_hours&&(s.timetracking={originalEstimate:`${e.estimate_hours}h`}),e.assignee){let u=this.assigneeCache.get(e.assignee);if(u!==void 0)s.assignee={accountId:u};else throw new wt(`Assignee not resolved: ${e.assignee}`)}o&&(s[o]=n);let c=await this.connector.createIssue(s);return {key:c.key,url:c.url}}async updateTask(e,n,o,r,i){let a=this.selectDescription(n,i.language),s={};if(a&&(s.description=zt(a)),n.priority&&(s.priority={name:n.priority}),n.labels&&n.labels.length>0&&(s.labels=[...n.labels]),n.estimate_hours&&(s.timetracking={originalEstimate:`${n.estimate_hours}h`}),n.assignee){let c=this.assigneeCache.get(n.assignee);c!==void 0&&(s.assignee={accountId:c});}return r&&(s[r]=o),Object.keys(s).length>0&&await this.connector.updateIssue(e,s),n.status?this.applyStatusPath(e,n.status):null}async findExistingTask(e,n){try{let o=Is(`"${e}"`),r=`project = "${Is(n)}" AND summary ~ "${o}"`;return (await this.connector.searchIssues(r)).find(s=>s.summary===e)?.key??null}catch{return null}}async applyStatusPath(e,n){let o=typeof n=="string"?[n]:n;for(let[r,i]of o.entries()){let a;try{a=await this.connector.getTransitions(e);}catch(c){let u=c instanceof Error?c.message:String(c);return `Could not read transitions while moving to "${i}": ${u}`}let s=a.find(c=>c.toStatus.toLowerCase()===i.toLowerCase());if(!s){let c=a.map(l=>l.toStatus).join(", "),u=r===0?"":` (stopped after reaching "${o[r-1]??""}")`;return `Status "${i}" is not reachable${u}. Available from here: ${c||"(none)"}`}try{await this.connector.doTransition(e,s.id);}catch(c){let u=c instanceof Error?c.message:String(c);return `Transition "${s.name}" to "${i}" failed: ${u}`}}return null}async forceReassign(e,n,o){let r=this.assigneeCache.get(n);if(r!==void 0){o>0&&await nT(o);try{await this.connector.assignIssue(e,r);}catch{}}}selectSummary(e,n){if(n!==Yt){let o=e[`summary_${n}`];if(o)return o}return e.summary}selectDescription(e,n){if(n!==Yt){let o=e[`description_${n}`];if(o)return o}return e.description||void 0}};function sA(t){let e=0,n=0,o=0,r=0,i=0;for(let a of t)switch(a.action){case "created":e++;break;case "updated":n++;break;case "failed":o++;break;case "skipped":r++;break;case "preview":i++;break}return {created:e,updated:n,failed:o,skipped:r,previewed:i}}le();le();async function cA(t,e){let{readdir:n,stat:o,access:r}=await import('fs/promises'),{join:i}=await import('path'),a=w0,s=[],c;try{let u=await n(a);c=(await Promise.all(u.map(async d=>{let p=await o(i(a,d));return {name:d,isDir:p.isDirectory()}}))).filter(d=>d.isDir).map(d=>d.name);}catch{return []}for(let u of c){if(t&&u.toUpperCase()!==t.toUpperCase())continue;let l=i(a,u,"monthly_admin.json");try{await r(l),s.push({projectKey:u.toUpperCase(),configPath:l});}catch{}}return s.sort((u,l)=>u.projectKey.localeCompare(l.projectKey)),s}async function oT(t,e){let{readFile:n}=await import('fs/promises'),o=await cA(t.project);if(o.length===0)return {configs:[],totalProcessed:0,totalFailed:0};let i=await(Go)(),s=((l=>new ei(l)))(i),c=[],u=0;for(let l of o)try{let d=await n(l.configPath,"utf-8"),p=JSON.parse(d),m=tT.safeParse(p);if(!m.success){c.push({projectKey:l.projectKey,configPath:l.configPath,error:`Invalid config: ${m.error.message}`}),u++;continue}let h=rT(m.data),z="language"in(p.options??{}),A=h.epic_key.split("-")[0]??"",R=i.projects[A]?.language??i.default_language,q={...h,options:{...h.options,dry_run:t.execute!==!0,...!z&&R?{language:R}:{}}};if(!A){c.push({projectKey:l.projectKey,configPath:l.configPath,error:`Invalid epic_key format: '${q.epic_key}'`}),u++;continue}let Z=s.getConnector(A),ti=await(e?.createBulkCreator??((ri,Vr)=>new tp(ri,Vr)))(Z,A).execute(q);c.push({projectKey:l.projectKey,configPath:l.configPath,result:ti});}catch(d){let p=d instanceof Error?d.message:String(d);c.push({projectKey:l.projectKey,configPath:l.configPath,error:p}),u++;}return {configs:c,totalProcessed:o.length,totalFailed:u}}function uA(t){if(t.error)return {project_key:t.projectKey,config_path:t.configPath,status:"error",error:t.error};if(t.result){let e=t.result.results.filter(n=>n.warning!==null).map(n=>`${n.issue_key??n.summary}: ${n.warning??""}`);return {project_key:t.projectKey,config_path:t.configPath,status:"success",summary:t.result.summary,dry_run:t.result.dry_run,...e.length>0?{warnings:e}:{}}}return {project_key:t.projectKey,config_path:t.configPath,status:"error",error:"No result and no error reported."}}function lA(t,e){return {execute:e,total_processed:t.totalProcessed,total_failed:t.totalFailed,total_succeeded:t.totalProcessed-t.totalFailed,configs:t.configs.map(uA)}}async function iT(t,e){try{let n=await oT({execute:t.execute,project:t.project},e?.createMonthlyDeps);return K(lA(n,t.execute===!0))}catch(n){return M(n)}}function dA(t){return {instanceUrl:t.instanceUrl,async searchIssues(e){return (await t.searchIssues(e)).map(o=>({key:o.key,fields:{summary:o.summary,status:{name:o.status},assignee:o.assignee?{emailAddress:o.assignee}:null,priority:o.priority?{name:o.priority}:null,issuetype:{name:o.issueType},created:o.created,updated:o.updated,project:{key:o.projectKey},customfield_10014:o.epicLink}}))}}}function aT(){return new Nd({name:"@softspark/jira-mcp",version:IS},{capabilities:{tools:{}}})}async function pA(){let t=await Go(),e=new ei(t),{GLOBAL_CACHE_DIR:n}=await Promise.resolve().then(()=>(le(),_0)),o=new Gd(n,t.credentials.username);await o.initialize();let{commentRegistry:r,taskRegistry:i}=D0(),a=new Kd(o,t,(u,l,d)=>dA(e.getConnector(mA(t,u)??""))),s=aT();s.setRequestHandler(Eh,()=>({tools:sv})),s.setRequestHandler(ja,async u=>{let{name:l}=u.params,d=u.params.arguments??{};switch(l){case "sync_tasks":return A0({project_key:ke(d.project_key),jql:ke(d.jql)},{syncer:a});case "read_cached_tasks":return U0({task_key:ke(d.task_key)},{cacheManager:o});case "update_task_status":return Z0({task_key:Ie(d.task_key,"task_key"),status:Ie(d.status,"status")},{pool:e,cacheManager:o});case "add_task_comment":return M0({task_key:Ie(d.task_key,"task_key"),comment:Ie(d.comment,"comment"),user_approved:qr(d.user_approved)},{pool:e,cacheManager:o});case "delete_task":return L0({task_key:Ie(d.task_key,"task_key"),user_approved:qr(d.user_approved)},{pool:e,cacheManager:o});case "delete_comment":return q0({task_key:Ie(d.task_key,"task_key"),comment_id:Ie(d.comment_id,"comment_id"),user_approved:qr(d.user_approved)},{pool:e,cacheManager:o});case "reassign_task":return F0({task_key:Ie(d.task_key,"task_key"),assignee_email:ke(d.assignee_email)},{pool:e,cacheManager:o});case "get_task_statuses":return V0({task_key:Ie(d.task_key,"task_key")},{pool:e,cacheManager:o});case "get_task_details":return J0({task_key:Ie(d.task_key,"task_key")},{pool:e,cacheManager:o,config:t});case "log_task_time":return G0({task_key:Ie(d.task_key,"task_key"),time_spent:Ie(d.time_spent,"time_spent"),comment:ke(d.comment)},{pool:e,cacheManager:o});case "get_task_time_tracking":return K0({task_key:Ie(d.task_key,"task_key")},{pool:e,cacheManager:o});case "list_comment_templates":return H0({category:ke(d.category)},{templateRegistry:r});case "add_templated_comment":return X0({task_key:Ie(d.task_key,"task_key"),template_id:ke(d.template_id),variables:Ts(d.variables),markdown:ke(d.markdown),user_approved:qr(d.user_approved)},{pool:e,cacheManager:o,templateRegistry:r});case "create_task":return Y0({project_key:Ie(d.project_key,"project_key"),summary:ke(d.summary)??"",description:ke(d.description),template_id:ke(d.template_id),variables:Ts(d.variables),type:ke(d.type),priority:ke(d.priority),assignee_email:ke(d.assignee_email),labels:Ss(d.labels),epic_key:ke(d.epic_key),parent_key:ke(d.parent_key),original_estimate:ke(d.original_estimate)},{pool:e,cacheManager:o,taskTemplateRegistry:i});case "list_task_templates":return W0({},{taskTemplateRegistry:i});case "get_project_language":return B0({project_key:Ie(d.project_key,"project_key")},{config:t});case "update_task":return Q0({task_key:Ie(d.task_key,"task_key"),summary:ke(d.summary),description:ke(d.description),priority:ke(d.priority),labels:Ss(d.labels),original_estimate:ke(d.original_estimate),remaining_estimate:ke(d.remaining_estimate)},{pool:e});case "search_tasks":return eT({jql:Ie(d.jql,"jql"),max_results:Jd(d.max_results),project_key:ke(d.project_key)},{pool:e,config:t});case "create_monthly_tasks":return iT({execute:qr(d.execute),project:ke(d.project)});default:return M(new Error(`Unknown tool: ${l}`))}});let c=new Ad;await s.connect(c);}function mA(t,e){for(let[n,o]of Object.entries(t.projects))if(o.url===e)return n}export{aT as createServer,pA as startServer};//# sourceMappingURL=index.js.map
|
|
88
|
+
`}var Ad=class{constructor(e=zS.stdin,n=zS.stdout){this._stdin=e,this._stdout=n,this._readBuffer=new Dd,this._started=false,this._ondata=o=>{this._readBuffer.append(o),this.processReadBuffer();},this._onerror=o=>{this.onerror?.(o);};}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=true,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror);}processReadBuffer(){for(;;)try{let e=this._readBuffer.readMessage();if(e===null)break;this.onmessage?.(e);}catch(e){this.onerror?.(e);}}async close(){this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0&&this._stdin.pause(),this._readBuffer.clear(),this.onclose?.();}send(e){return new Promise(n=>{let o=TS(e);this._stdout.write(o)?n():this._stdout.once("drain",n);})}};var IS="1.14.4";le();le();le();le();var C1=1e3,N1=["summary","status","assignee","priority","issuetype","created","updated","project","customfield_10014"];function D1({status:t,detail:e}){return t===401?new ms(`Authentication failed: ${e}`):t===403?new fs(`Permission denied: ${e}`):new wt(`Jira API error (${t}): ${e}`)}var Bd=class{http;instanceUrl;constructor(e){this.instanceUrl=e.url,this.http=new Xo(e,D1);}async request(e,n,o,r){return this.http.requestJson(e,n,o,r)}async searchIssues(e,n){return ((await this.request("GET","/rest/api/3/search/jql",void 0,{jql:e,fields:(n?[...n]:N1).join(","),maxResults:String(C1)})).issues??[]).map(i=>{let a=i.fields;return {key:i.key,summary:a.summary,status:a.status?.name??"Unknown",assignee:a.assignee?.emailAddress??null,priority:a.priority?.name??"None",issueType:a.issuetype?.name??a.issueType?.name??"Unknown",created:a.created,updated:a.updated,projectKey:i.key.split("-")[0]??"",epicLink:a.customfield_10014??null}})}async getIssue(e){let n=["summary","description","creator","status","assignee","priority","issuetype","created","updated","project","comment","timetracking"],o=await this.request("GET",`/rest/api/3/issue/${encodeURIComponent(e)}`,void 0,{fields:n.join(",")}),r=o.fields,i=(r.comment?.comments??[]).map(a=>({id:a.id??"",author:a.author?.emailAddress??a.author?.displayName??"Unknown",authorAccountId:a.author?.accountId??null,body:a.body??null,created:a.created??""}));return {key:o.key,summary:r.summary,description:r.description??null,creator:r.creator?.emailAddress??r.creator?.displayName??"Unknown",creatorAccountId:r.creator?.accountId??null,status:r.status?.name??"Unknown",assignee:r.assignee?.emailAddress??null,priority:r.priority?.name??"None",issueType:r.issuetype?.name??r.issueType?.name??"Unknown",created:r.created,updated:r.updated,projectKey:o.key.split("-")[0]??"",comments:i,timeTracking:{originalEstimate:r.timetracking?.originalEstimate??null,remainingEstimate:r.timetracking?.remainingEstimate??null,timeSpent:r.timetracking?.timeSpent??null,originalEstimateSeconds:r.timetracking?.originalEstimateSeconds??null,remainingEstimateSeconds:r.timetracking?.remainingEstimateSeconds??null,timeSpentSeconds:r.timetracking?.timeSpentSeconds??null}}}async addComment(e,n){let o=await this.request("POST",`/rest/api/3/issue/${encodeURIComponent(e)}/comment`,{body:n});return {id:o.id??"",author:o.author?.emailAddress??o.author?.displayName??"Unknown",authorAccountId:o.author?.accountId??null,body:o.body??null,created:o.created??""}}async deleteIssue(e){await this.request("DELETE",`/rest/api/3/issue/${encodeURIComponent(e)}`);}async deleteComment(e,n){await this.request("DELETE",`/rest/api/3/issue/${encodeURIComponent(e)}/comment/${encodeURIComponent(n)}`);}async getTransitions(e){return ((await this.request("GET",`/rest/api/3/issue/${encodeURIComponent(e)}/transitions`)).transitions??[]).map(o=>({id:o.id??"",name:o.name??"",toStatus:o.to?.name??""}))}async doTransition(e,n){await this.request("POST",`/rest/api/3/issue/${encodeURIComponent(e)}/transitions`,{transition:{id:n}});}async assignIssue(e,n){await this.request("PUT",`/rest/api/3/issue/${encodeURIComponent(e)}/assignee`,{accountId:n});}async findUser(e){let o=(await this.request("GET","/rest/api/3/user/search",void 0,{query:e,maxResults:"1"}))?.[0];if(!o?.accountId)throw new wt(`User not found for email: ${e}`);return o.accountId}async getCurrentUser(){let e=await this.request("GET","/rest/api/3/myself");return {accountId:e.accountId,emailAddress:e.emailAddress??null,displayName:e.displayName??"Unknown",active:e.active}}async addWorklog(e,n,o){let r={timeSpentSeconds:n};o&&(r.comment=o);let i=await this.request("POST",`/rest/api/3/issue/${encodeURIComponent(e)}/worklog`,r);return {id:i.id??"",timeSpent:i.timeSpent??"",timeSpentSeconds:i.timeSpentSeconds??n,created:i.created??""}}async getTimeTracking(e){let o=(await this.request("GET",`/rest/api/3/issue/${encodeURIComponent(e)}`,void 0,{fields:"timetracking"})).fields.timetracking;return {originalEstimate:o?.originalEstimate??null,remainingEstimate:o?.remainingEstimate??null,timeSpent:o?.timeSpent??null,originalEstimateSeconds:o?.originalEstimateSeconds??null,remainingEstimateSeconds:o?.remainingEstimateSeconds??null,timeSpentSeconds:o?.timeSpentSeconds??null}}async createIssue(e){let n=await this.request("POST","/rest/api/3/issue",{fields:e});return {key:n.key,id:n.id,url:`${this.instanceUrl}/browse/${n.key}`}}async updateIssue(e,n){await this.request("PUT",`/rest/api/3/issue/${encodeURIComponent(e)}`,{fields:n});}async getFields(){return (await this.request("GET","/rest/api/3/field")).map(n=>({id:n.id??"",name:n.name??"",custom:n.custom??false,...n.schema?.custom!==void 0?{schema:{custom:n.schema.custom}}:{}}))}async searchUsers(e,n=50){return (await this.request("GET","/rest/api/3/user/search",void 0,{query:e,maxResults:String(n)})??[]).map(r=>({accountId:r.accountId,emailAddress:r.emailAddress??null,displayName:r.displayName??"Unknown",active:r.active}))}async getProjectStatuses(e){return (await this.request("GET",`/rest/api/3/project/${encodeURIComponent(e)}/statuses`)).map(o=>({id:o.id,name:o.name,statuses:o.statuses.map(r=>({name:r.name??"",id:r.id??""}))}))}};var ei=class{byProject=new Map;byUrl=new Map;config;constructor(e){this.config=e,this.#e();}getConnector(e){let n=this.byProject.get(e);if(!n)throw new qe(`Project '${e}' not found in configuration`);return n}getConnectorForTask(e){let n=e.split("-")[0];if(!n)throw new qe(`Invalid task key format: '${e}'. Expected 'PROJECT-NUMBER'.`);return this.getConnector(n)}getInstances(){return this.byUrl}#e(){let e=new Map;for(let[n,o]of Object.entries(this.config.projects)){let r=e.get(o.url);r?r.push(n):e.set(o.url,[n]);}for(let[n,o]of e){let r=o[0];if(!r)continue;let i=this.config.projects[r];if(!i)continue;let a=new Bd(i),s={connector:a,projectKeys:o};this.byUrl.set(n,s);for(let c of o)this.byProject.set(c,a);}}};Mo();var zs="1.0",A1=_.object({key:_.string(),summary:_.string(),status:_.string(),assignee:_.string().nullable(),priority:_.string(),issue_type:_.string(),created:_.string(),updated:_.string(),project_key:_.string(),project_url:_.string().url(),epic_link:_.string().nullable()}),U1=_.object({version:_.string(),last_sync:_.string(),jira_user:_.string()}),ov=_.object({metadata:U1,tasks:_.array(A1)});le();le();function V1(t){return t.replaceAll("@","_at_").replaceAll(".","_")}var Gd=class{cacheDir;jiraUser;cachePath;constructor(e,n){this.cacheDir=e,this.jiraUser=n,this.cachePath=join(e,`tasks_${V1(n)}.json`);}async initialize(){if(await mkdir(this.cacheDir,{recursive:true,mode:448}),await Xt(this.cachePath)){try{await this.load();}catch(n){if(!(n instanceof St)){let o=n instanceof Error?n.message:String(n);throw new pr(`Existing cache is corrupted: ${o}`)}}return}let e={metadata:{version:zs,last_sync:new Date().toISOString(),jira_user:this.jiraUser},tasks:[]};await this.#e(e);}async load(){if(!await Xt(this.cachePath))throw new St(`Cache not found: ${this.cachePath}`);let e;try{e=await readFile(this.cachePath,"utf-8");}catch(r){let i=r instanceof Error?r.message:String(r);throw new St(`Failed to read cache file: ${i}`)}let n;try{n=JSON.parse(e);}catch(r){let i=r instanceof Error?r.message:String(r);throw new pr(`Cache file is corrupted (invalid JSON): ${i}`)}let o=ov.safeParse(n);if(!o.success)throw new pr(`Cache data failed validation: ${o.error.message}`);if(o.data.metadata.version!==zs)throw new pr(`Cache version ${o.data.metadata.version} !== ${zs}`);return o.data}async save(e){let n={metadata:{version:zs,last_sync:new Date().toISOString(),jira_user:this.jiraUser},tasks:[...e]},o=ov.safeParse(n);if(!o.success)throw new pr(`Task data failed validation: ${o.error.message}`);await this.#e(o.data);}async getTask(e){let o=(await this.load()).tasks.find(r=>r.key===e);if(!o)throw new Tt(`Task ${e} not found in cache`);return o}async getAllTasks(){return (await this.load()).tasks}async updateTask(e,n){let o=await this.load(),r=o.tasks.findIndex(c=>c.key===e);if(r===-1)throw new Tt(`Task ${e} not found in cache`);let i=o.tasks[r];if(!i)throw new Tt(`Task ${e} not found in cache`);let a={...i,...n,key:e,updated:new Date().toISOString()},s=[...o.tasks.slice(0,r),a,...o.tasks.slice(r+1)];return await this.save(s),a}async deleteTask(e){let n=await this.load(),o=n.tasks.filter(r=>r.key!==e);if(o.length===n.tasks.length)throw new Tt(`Task ${e} not found in cache`);await this.save(o);}async upsertTask(e){let n=[];try{n=(await this.load()).tasks;}catch(i){if(!(i instanceof St))throw i}let o=n.findIndex(i=>i.key===e.key),r=o===-1?[...n,e]:n.map((i,a)=>a===o?e:i);return await this.save(r),e}async getMetadata(){return (await this.load()).metadata}async#e(e){let n=`${this.cachePath}.tmp`,o=JSON.stringify(e,null,2);await writeFile(n,o,{encoding:"utf-8",mode:384}),await rename(n,this.cachePath);}};le();function Is(t){return t.replace(/([\\"])/g,"\\$1")}var Kd=class{#e;#t;#r;constructor(e,n,o){this.#e=e,this.#t=n,this.#r=o;}async sync(e){let n=e?.jql??`assignee = "${Is(this.#t.credentials.username)}" ORDER BY updated DESC`,o=Ld(this.#t);if(e?.projectKey){let i=this.#t.projects[e.projectKey];i&&(o=o.filter(a=>a.url===i.url));}let r=[];for(let i of o){let c=(await this.#r(i.url,i.username,i.api_token).searchIssues(n)).map(u=>this.#n(u,i.url));r.push(...c);}return await this.#e.save(r),r.length}#n(e,n){let o=e.fields.assignee?.emailAddress??null,r=e.fields.priority?.name??"None",i=e.fields.customfield_10014??null;return {key:e.key,summary:e.fields.summary,status:e.fields.status.name,assignee:o,priority:r,issue_type:e.fields.issuetype.name,created:e.fields.created,updated:e.fields.updated,project_key:e.fields.project.key,project_url:n,epic_link:i}}};le();function B1(t){let e=t;for(;;){if(existsSync(join(e,"package.json")))return e;let n=dirname(e);if(n===e)return fileURLToPath(new URL("..",import.meta.url));e=n;}}var G1=B1(dirname(fileURLToPath(import.meta.url)));join(xs,"workflows.json");join(xs,"users.json");var iv=join(Lr,"templates"),b0=join(iv,"comments"),x0=join(iv,"task-templates"),w0=join(iv,"tasks"),av=join(G1,"templates-system"),S0=join(av,"comments"),T0=join(av,"task-templates");join(av,"locales");Mo();var Fr={WORKFLOW:"workflow",COMMUNICATION:"communication",REPORTING:"reporting",DEVELOPMENT:"development"};le();var P0=/^[a-z][a-z0-9-]*$/,j0=_.object({name:_.string().regex(/^\w+$/,"Variable name must be alphanumeric/underscore"),description:_.string().default(""),required:_.boolean().default(false),default:_.string().optional(),example:_.string().optional()}),H1=_.object({kind:_.literal("comment"),id:_.string().regex(P0,"Template id must be a URL-safe slug"),name:_.string().min(1),description:_.string().min(1),category:_.enum([Fr.WORKFLOW,Fr.COMMUNICATION,Fr.REPORTING,Fr.DEVELOPMENT]),variables:_.array(j0).default([])}),W1=_.object({kind:_.literal("task"),id:_.string().regex(P0,"Template id must be a URL-safe slug"),name:_.string().min(1),description:_.string().min(1),summary:_.string().min(1),issue_type:_.string().optional(),priority:_.string().optional(),labels:_.array(_.string()).optional(),epic_key:_.string().optional(),variables:_.array(j0).default([])});function E0(t){return t.map(e=>({name:e.name,description:e.description,required:e.required,defaultValue:e.default,example:e.example}))}function O0(t,e){let n=t.match(/^---\s*\n([\s\S]*?)\n---\s*\n?([\s\S]*)$/);if(!n)throw new mr(`Template file "${e}" must start with a JSON metadata block delimited by ---`);let[,o,r=""]=n;if(o===void 0)throw new mr(`Template file "${e}" is missing metadata.`);let i;try{i=JSON.parse(o);}catch(a){let s=a instanceof Error?a.message:String(a);throw new mr(`Template file "${e}" contains invalid JSON metadata: ${s}`)}return {metadata:i,body:r.trim()}}function R0(t){if(!readdirSync||!t)return [];try{return readdirSync(t).filter(e=>e.endsWith(".md")).sort().map(e=>join(t,e))}catch{return []}}function Hd(t,e){let n=[];for(let o of R0(t)){let r=readFileSync(o,"utf-8"),i=O0(r,o),a=H1.parse(i.metadata);n.push({id:a.id,name:a.name,description:a.description,category:a.category,variables:E0(a.variables),body:i.body,source:e,filePath:o});}return n}function Wd(t,e){let n=[];for(let o of R0(t)){let r=readFileSync(o,"utf-8"),i=O0(r,o),a=W1.parse(i.metadata);n.push({id:a.id,name:a.name,description:a.description,summary:a.summary,issueType:a.issue_type,priority:a.priority,labels:a.labels,epicKey:a.epic_key,variables:E0(a.variables),body:i.body,source:e,filePath:o});}return n}var C0=Hd(S0,"system");le();var Xd=class{templates;constructor(e){let n=new Map;for(let o of C0)n.set(o.id,o);if(e)for(let o of e)n.set(o.id,o);this.templates=n;}getTemplate(e){let n=this.templates.get(e);if(!n)throw new kn(`Template "${e}" not found. Use listTemplates() to see available templates.`);return n}listTemplates(e){let n=[...this.templates.values()];return e?n.filter(o=>o.category===e):n}listCategories(){let e=new Set;for(let n of this.templates.values())e.add(n.category);return [...e]}};le();var N0=Wd(T0,"system");var Yd=class{templates;constructor(e){let n=new Map;for(let o of N0)n.set(o.id,o);if(e)for(let o of e)n.set(o.id,o);this.templates=n;}getTemplate(e){let n=this.templates.get(e);if(!n)throw new kn(`Task template "${e}" not found. Use listTaskTemplates() to see available templates.`);return n}listTemplates(){return [...this.templates.values()]}};function D0(t){let e=Hd(b0,"user"),n=Wd(x0,"user");return {commentRegistry:new Xd(e),taskRegistry:new Yd(n)}}le();var sv=[{name:"sync_tasks",description:"Sync tasks from Jira to local cache. By default syncs from all configured instances. Optionally scope to a single project or provide a custom JQL query.",inputSchema:{type:"object",properties:{project_key:{type:"string",description:"Optional project key to sync from a single instance."},jql:{type:"string",description:"Optional JQL query. If omitted, fetches tasks assigned to the current user."}}}},{name:"read_cached_tasks",description:"Read tasks from local cache without hitting the Jira API. Returns a single task when task_key is provided, or all cached tasks otherwise.",inputSchema:{type:"object",properties:{task_key:{type:"string",description:'Optional task key (e.g. "PROJ-123"). If omitted, returns all cached tasks.'}}}},{name:"update_task_status",description:"Change a task status via Jira workflow transition and update the local cache.",inputSchema:{type:"object",properties:{task_key:{type:"string",description:'Task key (e.g. "PROJ-123").'},status:{type:"string",description:'Target status name (e.g. "In Progress", "Done"). Use get_task_statuses first to check valid transitions.'}},required:["task_key","status"]}},{name:"add_task_comment",description:"Add a markdown comment to a Jira task. The markdown is automatically converted to ADF format.",inputSchema:{type:"object",properties:{task_key:{type:"string",description:'Task key (e.g. "PROJ-123").'},comment:{type:"string",description:"Comment text in markdown format."},user_approved:{type:"boolean",description:"Must be true only after the user explicitly approves posting this comment."}},required:["task_key","comment"]}},{name:"delete_task",description:"Delete a Jira task, but only when the authenticated user is the task creator.",inputSchema:{type:"object",properties:{task_key:{type:"string",description:'Task key (e.g. "PROJ-123").'},user_approved:{type:"boolean",description:"Must be true only after the user explicitly approves deleting this task."}},required:["task_key"]}},{name:"delete_comment",description:"Delete a Jira comment, but only when the authenticated user is the comment author.",inputSchema:{type:"object",properties:{task_key:{type:"string",description:'Task key (e.g. "PROJ-123").'},comment_id:{type:"string",description:"Comment ID to delete."},user_approved:{type:"boolean",description:"Must be true only after the user explicitly approves deleting this comment."}},required:["task_key","comment_id"]}},{name:"reassign_task",description:"Reassign a task to a different user by email, or unassign by providing an empty string or omitting assignee_email.",inputSchema:{type:"object",properties:{task_key:{type:"string",description:'Task key (e.g. "PROJ-123").'},assignee_email:{type:"string",description:"Email of the new assignee. Empty string or omit to unassign."}},required:["task_key"]}},{name:"get_task_statuses",description:"Get available workflow transitions for a task. Call this before update_task_status to see valid target statuses.",inputSchema:{type:"object",properties:{task_key:{type:"string",description:'Task key (e.g. "PROJ-123").'}},required:["task_key"]}},{name:"get_task_details",description:"Get full task details from Jira including description and all comments, with ADF content converted to markdown.",inputSchema:{type:"object",properties:{task_key:{type:"string",description:'Task key (e.g. "PROJ-123").'}},required:["task_key"]}},{name:"log_task_time",description:"Log work time to a Jira task. Uses hours and minutes format only (no days). Invalidates cache after logging.",inputSchema:{type:"object",properties:{task_key:{type:"string",description:'Task key (e.g. "PROJ-123").'},time_spent:{type:"string",description:'Time in format "2h", "30m", or "2h 30m". Days are not supported.'},comment:{type:"string",description:"Optional work description."}},required:["task_key","time_spent"]}},{name:"get_task_time_tracking",description:"Get time tracking information for a Jira task (original estimate, time spent, remaining estimate).",inputSchema:{type:"object",properties:{task_key:{type:"string",description:'Task key (e.g. "PROJ-123").'}},required:["task_key"]}},{name:"list_comment_templates",description:"List all available comment templates with optional category filter. Returns template metadata including required variables.",inputSchema:{type:"object",properties:{category:{type:"string",description:'Optional category filter: "workflow", "communication", "reporting", or "development".',enum:["workflow","communication","reporting","development"]}}}},{name:"add_templated_comment",description:"Add a comment using a registered template (with variable substitution) or raw markdown. Provide exactly one of template_id or markdown.",inputSchema:{type:"object",properties:{task_key:{type:"string",description:'Task key (e.g. "PROJ-123").'},template_id:{type:"string",description:"Template identifier. Use list_comment_templates to see available templates."},variables:{type:"object",description:"Key-value map of template variables. Required when using template_id.",additionalProperties:{type:"string"}},markdown:{type:"string",description:"Raw markdown comment. Use instead of template_id for freeform comments."},user_approved:{type:"boolean",description:"Must be true only after the user explicitly approves posting this comment."}},required:["task_key"]}},{name:"create_task",description:"Create a new Jira issue with either explicit fields or a registered task template, plus optional assignee, labels, epic link, sub-task parent, and original estimate.",inputSchema:{type:"object",properties:{project_key:{type:"string",description:'Project key (e.g. "DEVOPS"). Determines which Jira instance to use.'},summary:{type:"string",description:"Issue title / summary. Do not provide when using template_id."},description:{type:"string",description:"Optional issue description in markdown format. Automatically converted to ADF. Do not provide when using template_id."},template_id:{type:"string",description:"Task template identifier. Use list_task_templates to see available templates."},variables:{type:"object",description:"Key-value map of template variables. Required when using template_id.",additionalProperties:{type:"string"}},type:{type:"string",description:'Issue type name (default "Task"). E.g. "Bug", "Story", "Epic".'},priority:{type:"string",description:'Priority name (default "Medium"). E.g. "High", "Low", "Critical".'},assignee_email:{type:"string",description:"Email of the assignee. Resolved to Jira account ID."},labels:{type:"array",items:{type:"string"},description:"Array of label strings to apply to the issue."},epic_key:{type:"string",description:'Epic issue key to link this issue under (e.g. "PROJ-100").'},parent_key:{type:"string",description:'Parent issue key (e.g. "PROJ-69"). Required when type is a sub-task; Jira rejects sub-task creation without it.'},original_estimate:{type:"string",description:'Original estimate in format "2h", "30m", or "2h 30m". Days are not supported.'}},required:["project_key"]}},{name:"list_task_templates",description:"List all available single-task templates used by create_task. Returns template metadata including required variables.",inputSchema:{type:"object",properties:{}}},{name:"get_project_language",description:"Get the configured language for a project. Use before writing comments or descriptions to determine the correct language.",inputSchema:{type:"object",properties:{project_key:{type:"string",description:'Project key (e.g. "DEVOPS"). Inferred from task key prefix.'}},required:["project_key"]}},{name:"update_task",description:"Update an existing Jira issue, including its original and remaining estimates. Only provided fields are changed; omitted fields are left untouched.",inputSchema:{type:"object",properties:{task_key:{type:"string",description:'Task key (e.g. "DEVOPS-37"). Project is inferred from the key prefix.'},summary:{type:"string",description:"New issue title / summary."},description:{type:"string",description:"New issue description in markdown format. Automatically converted to ADF."},priority:{type:"string",description:'New priority name. E.g. "Medium", "Low", "Critical".'},labels:{type:"array",items:{type:"string"},description:"New set of label strings (replaces existing labels)."},original_estimate:{type:"string",description:'New original estimate in format "2h", "30m", or "2h 30m". Days are not supported.'},remaining_estimate:{type:"string",description:'New remaining estimate in format "2h", "30m", or "2h 30m". Days are not supported. Independent of original_estimate -- setting one leaves the other unchanged.'}},required:["task_key"]}},{name:"search_tasks",description:"Search Jira issues using JQL. Returns results directly without caching.",inputSchema:{type:"object",properties:{jql:{type:"string",description:"JQL query string."},max_results:{type:"number",description:"Maximum number of results to return (default 50)."},project_key:{type:"string",description:"Optional project key to determine which Jira instance to query. Defaults to the configured default project."}},required:["jql"]}},{name:"create_monthly_tasks",description:"Run all monthly_admin.json bulk task configs from ~/.softspark/jira-mcp/templates/tasks/<KEY>/. Defaults to dry-run. Set execute=true to actually create the tasks. Optionally filter to a single project key.",inputSchema:{type:"object",properties:{execute:{type:"boolean",description:"When true, create tasks for real. When false or omitted, run a dry-run preview."},project:{type:"string",description:"Optional project key (case-insensitive) to restrict execution to a single project subdirectory."}}}}];le();le();le();var X1=/(\d+)\s*h/i,Y1=/(\d+)\s*m/i,Q1=/\d+\s*d/i;function xn(t){let e=t.trim();if(e.length===0)throw new Error("Invalid time format: empty string. Use: '2h', '30m', or '2h 30m'");if(Q1.test(e))throw new Error("Days (d) not supported. Use hours (h) and minutes (m) only. Example: '2h', '30m', or '2h 30m'");let n=0,o=X1.exec(e);o?.[1]&&(n+=parseInt(o[1],10)*3600);let r=Y1.exec(e);if(r?.[1]&&(n+=parseInt(r[1],10)*60),n===0)throw new Error(`Invalid time format: '${t}'. Use: '2h', '30m', or '2h 30m'`);return n}le();var Qd=class{constructor(e,n){this.connector=e;this.cacheManager=n;}connector;cacheManager;async changeStatus(e,n){let o=await this.connector.getTransitions(e),r=o.find(a=>a.toStatus.toLowerCase()===n.toLowerCase())??o.find(a=>a.name.toLowerCase()===n.toLowerCase());if(!r){let a=o.map(s=>`${s.name} -> ${s.toStatus}`).join(", ");throw new wt(`Status '${n}' not available for ${e}. Available transitions: ${a}`)}await this.connector.doTransition(e,r.id);let i=await this.#e(e,{status:r.toStatus||n});return {taskKey:e,updatedTask:i}}async getAvailableStatuses(e){return (await this.connector.getTransitions(e)).map(o=>({id:o.id,name:o.name,toStatus:o.toStatus}))}async addComment(e,n){let o=zt(n),r=await this.connector.addComment(e,o);return {taskKey:e,commentId:r.id,author:r.author,bodyMarkdown:Wo(r.body),created:r.created}}async deleteComment(e,n){let o=await this.connector.getCurrentUser(),i=(await this.connector.getIssue(e)).comments.find(a=>a.id===n);if(!i)throw new _s(`Comment ${n} not found on ${e}.`);if(i.authorAccountId==null||i.authorAccountId!==o.accountId)throw new Vo(`Comment ${n} on ${e} can only be deleted by its author.`);return await this.connector.deleteComment(e,n),{taskKey:e,commentId:n}}async reassign(e,n){if(n){let r=await this.connector.findUser(n);await this.connector.assignIssue(e,r);}else await this.connector.assignIssue(e,null);let o=await this.#e(e,{assignee:n??null});return {taskKey:e,updatedTask:o}}async getTaskDetails(e){let n=await this.connector.getIssue(e),o=n.comments.map(r=>({id:r.id,author:r.author,body:Wo(r.body),created:r.created}));return {key:n.key,summary:n.summary,description:Wo(n.description),status:n.status,assignee:n.assignee,priority:n.priority,issueType:n.issueType,created:n.created,updated:n.updated,comments:o}}async deleteTask(e){let n=await this.connector.getCurrentUser(),o=await this.connector.getIssue(e);if(o.creatorAccountId==null||o.creatorAccountId!==n.accountId)throw new Vo(`Task ${e} can only be deleted by its creator.`);await this.connector.deleteIssue(e);try{await this.cacheManager.deleteTask(e);}catch(r){if(!(r instanceof Tt||r instanceof St))throw r}return {taskKey:e}}async logTime(e,n,o){let r=xn(n),i=o?zt(o):void 0,a=await this.connector.addWorklog(e,r,i);try{await this.cacheManager.deleteTask(e);}catch(s){if(!(s instanceof Tt||s instanceof St))throw s}return {taskKey:e,worklogId:a.id,timeSpent:n,timeSpentSeconds:a.timeSpentSeconds}}async getTimeTracking(e){let n=await this.connector.getTimeTracking(e);return {taskKey:e,originalEstimate:n.originalEstimate,remainingEstimate:n.remainingEstimate,timeSpent:n.timeSpent}}async#e(e,n){try{return await this.cacheManager.updateTask(e,n)}catch(o){if(!(o instanceof Tt||o instanceof St))throw o;let r=await this.connector.getIssue(e),i={key:r.key,summary:r.summary,status:r.status,assignee:r.assignee,priority:r.priority,issue_type:r.issueType,created:r.created,updated:r.updated,project_key:r.projectKey,project_url:this.connector.instanceUrl,epic_link:null,...n};return await this.cacheManager.upsertTask(i)}}};function je(t,e,n){let o=t.getConnectorForTask(n);return new Qd(o,e)}async function A0(t,e){try{let n={...t.jql?{jql:t.jql}:{},...t.project_key?{projectKey:t.project_key}:{}},o=await e.syncer.sync(n);return K({tasks_synced:o,message:`Synced ${o} tasks`})}catch(n){return M(n)}}async function U0(t,e){try{if(t.task_key){let o=await e.cacheManager.getTask(t.task_key);return K({task:o})}let n=await e.cacheManager.getAllTasks();return K({tasks:n,count:n.length})}catch(n){return M(n)}}async function Z0(t,e){try{let o=await je(e.pool,e.cacheManager,t.task_key).changeStatus(t.task_key,t.status);return K({task:o.updatedTask,message:`Updated ${t.task_key} status to '${t.status}'`})}catch(n){return M(n)}}le();async function M0(t,e){try{Yo(t.user_approved);let o=await je(e.pool,e.cacheManager,t.task_key).addComment(t.task_key,t.comment);return K({comment:{id:o.commentId,author:o.author,body:o.bodyMarkdown,created:o.created},message:`Added comment to ${t.task_key}`})}catch(n){return M(n)}}le();async function L0(t,e){try{Qo(t.user_approved);let o=await je(e.pool,e.cacheManager,t.task_key).deleteTask(t.task_key);return K({deleted:{task_key:o.taskKey},message:`Deleted task ${t.task_key}`})}catch(n){return M(n)}}le();async function q0(t,e){try{Qo(t.user_approved);let o=await je(e.pool,e.cacheManager,t.task_key).deleteComment(t.task_key,t.comment_id);return K({deleted:{task_key:o.taskKey,comment_id:o.commentId},message:`Deleted comment ${t.comment_id} from ${t.task_key}`})}catch(n){return M(n)}}async function F0(t,e){try{let n=je(e.pool,e.cacheManager,t.task_key),o=t.assignee_email?.trim()||null,r=await n.reassign(t.task_key,o),i=o?`Reassigned ${t.task_key} to ${o}`:`Unassigned ${t.task_key}`;return K({task:r.updatedTask,message:i})}catch(n){return M(n)}}async function V0(t,e){try{let o=await je(e.pool,e.cacheManager,t.task_key).getAvailableStatuses(t.task_key);return K({task_key:t.task_key,statuses:o.map(r=>({id:r.id,name:r.name,to_status:r.toStatus}))})}catch(n){return M(n)}}async function J0(t,e){try{let o=await je(e.pool,e.cacheManager,t.task_key).getTaskDetails(t.task_key),r=t.task_key.split("-")[0]??"",i=e.config.projects[r]?.language??e.config.default_language;return K({task:o,language:i,message:`Retrieved details for ${t.task_key}`})}catch(n){return M(n)}}async function B0(t,e){try{let n=e.config.projects[t.project_key],o=n?.language??e.config.default_language;return K({project_key:t.project_key,language:o,source:n?.language?"project":"default",message:`Project ${t.project_key} language: ${o}`})}catch(n){return M(n)}}async function G0(t,e){try{let o=await je(e.pool,e.cacheManager,t.task_key).logTime(t.task_key,t.time_spent,t.comment);return K({message:`Logged ${t.time_spent} to ${t.task_key}`,worklog_id:o.worklogId,time_spent:o.timeSpent,time_spent_seconds:o.timeSpentSeconds})}catch(n){return M(n)}}async function K0(t,e){try{let o=await je(e.pool,e.cacheManager,t.task_key).getTimeTracking(t.task_key);return K({task_key:t.task_key,time_tracking:{original_estimate:o.originalEstimate,time_spent:o.timeSpent,remaining_estimate:o.remainingEstimate},message:`Retrieved time tracking for ${t.task_key}`})}catch(n){return M(n)}}function eA(t){return Object.values(Fr).includes(t)}async function H0(t,e){try{let n;if(t.category){if(!eA(t.category)){let i=Object.values(Fr).join(", ");return M(new Error(`Invalid category '${t.category}'. Valid categories: ${i}`))}n=t.category;}let o=e.templateRegistry.listTemplates(n),r=e.templateRegistry.listCategories();return K({templates:o.map(i=>({id:i.id,name:i.name,description:i.description,category:i.category,source:i.source??"system",file_path:i.filePath,variables:i.variables.map(a=>({name:a.name,description:a.description,required:a.required,example:a.example}))})),categories:r,count:o.length})}catch(n){return M(n)}}async function W0(t,e){try{let n=e.taskTemplateRegistry.listTemplates();return K({templates:n.map(o=>({id:o.id,name:o.name,description:o.description,summary:o.summary,issue_type:o.issueType??"Task",priority:o.priority??"Medium",labels:o.labels??[],source:o.source??"system",file_path:o.filePath,variables:o.variables.map(r=>({name:r.name,description:r.description,required:r.required,example:r.example}))})),count:n.length})}catch(n){return M(n)}}le();le();async function X0(t,e){try{if(Yo(t.user_approved),t.template_id&&t.markdown)return M(new Error("Provide either template_id or markdown, not both."));if(!t.template_id&&!t.markdown)return M(new Error("Provide either template_id (with variables) or markdown."));let n,o;if(t.template_id){let a=e.templateRegistry.getTemplate(t.template_id),s=bn(a,t.variables??{});if(!s.success)return M(new Error(s.error));n=s.markdown,o={template_id:a.id,template_name:a.name};}else n=t.markdown??"";let i=await je(e.pool,e.cacheManager,t.task_key).addComment(t.task_key,n);return K({comment:{id:i.commentId,author:i.author,body:i.bodyMarkdown,created:i.created},...o?{template:o}:{},message:`Added comment to ${t.task_key}`})}catch(n){return M(n)}}le();le();async function tA(t){return (await t.getFields()).find(o=>o.custom&&o.name.toLowerCase()==="epic link")?.id}async function Y0(t,e){try{let n=t.template_id!==void 0;if(n&&(t.summary!==""||t.description!==void 0))return M(new Error("When template_id is provided, do not also provide summary or description."));if(!n&&t.summary.trim()==="")return M(new Error("Provide either template_id (with variables) or a non-empty summary."));let o=e.pool.getConnector(t.project_key),r=t.summary,i=t.description,a=t.type,s=t.priority,c=t.labels,u=t.epic_key,l;if(n){let m=e.taskTemplateRegistry.getTemplate(t.template_id??""),h=bn({variables:m.variables,body:m.summary},t.variables??{});if(!h.success)return M(new Error(h.error));let v=bn({variables:m.variables,body:m.body},t.variables??{});if(!v.success)return M(new Error(v.error));r=h.markdown,i=v.markdown===""?void 0:v.markdown,a=t.type??m.issueType,s=t.priority??m.priority,c=t.labels??m.labels,u=t.epic_key??m.epicKey,l={template_id:m.id,template_name:m.name,source:m.source??"system"};}let d={project:{key:t.project_key},summary:r,issuetype:{name:a??"Task"},priority:{name:s??"Medium"}};if(i&&(d.description=zt(i)),c&&c.length>0&&(d.labels=c),t.assignee_email){let m=await o.findUser(t.assignee_email);d.assignee={accountId:m};}if(t.parent_key&&(d.parent={key:t.parent_key}),t.original_estimate&&(xn(t.original_estimate),d.timetracking={originalEstimate:t.original_estimate}),u){let m=await tA(o);m&&(d[m]=u);}let p=await o.createIssue(d);return K({issue_key:p.key,url:p.url,summary:r,...l?{template:l}:{},message:`Created ${p.key}: ${r}`})}catch(n){return M(n)}}le();async function Q0(t,e){try{let n=t.task_key.split("-")[0]??"",o=e.pool.getConnector(n),r={};t.summary!==void 0&&(r.summary=t.summary),t.description!==void 0&&(r.description=zt(t.description)),t.priority!==void 0&&(r.priority={name:t.priority}),t.labels!==void 0&&(r.labels=t.labels);let i={};if(t.original_estimate!==void 0&&(xn(t.original_estimate),i.originalEstimate=t.original_estimate),t.remaining_estimate!==void 0&&(xn(t.remaining_estimate),i.remainingEstimate=t.remaining_estimate),Object.keys(i).length>0&&(r.timetracking=i),Object.keys(r).length===0)return M(new Error("No fields to update. Provide at least one of: summary, description, priority, labels, original_estimate, remaining_estimate."));await o.updateIssue(t.task_key,r);let a=Object.keys(r).join(", ");return K({task_key:t.task_key,updated_fields:a,message:`Updated ${t.task_key}: ${a}`})}catch(n){return M(n)}}var rA=50,nA=["summary","status","assignee","priority","issuetype","created","updated","project","customfield_10014"];async function eT(t,e){try{let n=t.project_key??e.config.default_project,o=e.pool.getConnector(n),r=t.max_results??rA,i=await o.searchIssues(t.jql,nA),a=i.slice(0,r);return K({results:a,count:a.length,total_available:i.length,message:`Found ${a.length} issue(s) matching JQL query`})}catch(n){return M(n)}}Mo();le();var oA=_.object({summary:_.string().min(1,"Summary is required").max(255),description:_.string().optional().default(""),type:_.string().default("Task"),assignee:_.string().email("Invalid assignee email format").optional(),priority:_.enum(["Highest","High","Medium","Low","Lowest"]).default("Medium"),labels:_.array(_.string()).default([]),estimate_hours:_.number().positive("Estimate must be positive").optional(),status:_.union([_.string(),_.array(_.string().min(1)).min(1,"Status path must not be empty")]).optional()}).catchall(_.string().optional()),iA=_.object({dry_run:_.boolean().default(true),update_existing:_.boolean().default(false),match_field:_.string().default("summary"),rate_limit_ms:_.number().int().min(0).default(500),force_reassign:_.boolean().default(false),reassign_delay_ms:_.number().int().min(0).default(0),language:Zt.default(Yt)}),tT=_.object({epic_key:_.string().regex(/^[A-Z][A-Z0-9]*-\d+$/,"Invalid epic key format (e.g., PROJ-123)"),tasks:_.array(oA).min(1,"At least one task is required"),options:iA.default(()=>({dry_run:true,update_existing:false,match_field:"summary",rate_limit_ms:500,force_reassign:false,reassign_delay_ms:0,language:Yt}))});function aA(t){let e=new Date;return {MONTH:`${String(e.getMonth()+1).padStart(2,"0")}.${e.getFullYear()}`,YEAR:String(e.getFullYear()),DATE:e.toISOString().slice(0,10)}}function rT(t,e){let n=aA(),o=JSON.stringify(t);return o=o.replaceAll("{MONTH}",n.MONTH),o=o.replaceAll("{YEAR}",n.YEAR),o=o.replaceAll("{DATE}",n.DATE),JSON.parse(o)}le();le();function nT(t){return new Promise(e=>setTimeout(e,t))}var cv=class extends Pe{constructor(e){super(e,"EPIC_NOT_FOUND"),this.name="EpicNotFoundError";}},ep=class extends Pe{constructor(e){super(e,"EPIC_LINK_FIELD_NOT_FOUND"),this.name="EpicLinkFieldNotFoundError";}},tp=class{constructor(e,n){this.connector=e;this.projectKey=n;}connector;projectKey;epicLinkFieldId=null;assigneeCache=new Map;async execute(e){let n=Date.now(),o=e.epic_key,r=e.options;if(!await this.validateEpic(o))throw new cv(`Epic '${o}' not found or not accessible`);this.epicLinkFieldId=await this.discoverEpicLinkField();let a=new Set;for(let l of e.tasks)l.assignee&&a.add(l.assignee);for(let l of a)try{await this.resolveAssignee(l);}catch{}let s=[];for(let l=0;l<e.tasks.length;l++){l>0&&r.rate_limit_ms>0&&await nT(r.rate_limit_ms);let d=e.tasks[l];if(!d)continue;let p=await this.processTask(d,o,r);s.push(p);}let c=sA(s),u=Date.now()-n;return {results:s,summary:c,dry_run:r.dry_run,total_time_ms:u}}async validateEpic(e){try{return await this.connector.getIssue(e),!0}catch{return false}}async discoverEpicLinkField(){let e;try{e=await this.connector.getFields();}catch(n){let o=n instanceof Error?n.message:String(n);throw new ep(`Failed to fetch fields from Jira: ${o}`)}for(let n of e){if(n.name.toLowerCase().includes("epic link"))return n.id;let r=n.schema?.custom??"";if(r.includes("epic-link")||r.includes("gh-epic-link"))return n.id}throw new ep("Epic Link custom field not found. Ensure Jira instance has Epic support enabled.")}async resolveAssignee(e){let n=this.assigneeCache.get(e);if(n!==void 0)return n;let o=await this.connector.findUser(e);return this.assigneeCache.set(e,o),o}async processTask(e,n,o){let r=this.selectSummary(e,o.language);if(o.dry_run)return {summary:r,issue_key:null,action:"preview",error:null,url:null,warning:null};try{let i=await this.findExistingTask(r,this.projectKey);if(i!==null){if(o.update_existing){let c=await this.updateTask(i,e,n,this.epicLinkFieldId,o);return {summary:r,issue_key:i,action:"updated",error:null,url:`${this.connector.instanceUrl}/browse/${i}`,warning:c}}return {summary:r,issue_key:i,action:"skipped",error:null,url:`${this.connector.instanceUrl}/browse/${i}`,warning:null}}let a=await this.createTask(e,n,this.epicLinkFieldId,o),s=e.status?await this.applyStatusPath(a.key,e.status):null;return o.force_reassign&&e.assignee&&await this.forceReassign(a.key,e.assignee,o.reassign_delay_ms),{summary:r,issue_key:a.key,action:"created",error:null,url:a.url,warning:s}}catch(i){let a=i instanceof Error?i.message:String(i);return {summary:r,issue_key:null,action:"failed",error:a,url:null,warning:null}}}async createTask(e,n,o,r){let i=this.selectSummary(e,r.language),a=this.selectDescription(e,r.language),s={project:{key:this.projectKey},summary:i,issuetype:{name:e.type??"Task"},priority:{name:e.priority??"Medium"}};if(a&&(s.description=zt(a)),e.labels&&e.labels.length>0&&(s.labels=[...e.labels]),e.estimate_hours&&(s.timetracking={originalEstimate:`${e.estimate_hours}h`}),e.assignee){let u=this.assigneeCache.get(e.assignee);if(u!==void 0)s.assignee={accountId:u};else throw new wt(`Assignee not resolved: ${e.assignee}`)}o&&(s[o]=n);let c=await this.connector.createIssue(s);return {key:c.key,url:c.url}}async updateTask(e,n,o,r,i){let a=this.selectDescription(n,i.language),s={};if(a&&(s.description=zt(a)),n.priority&&(s.priority={name:n.priority}),n.labels&&n.labels.length>0&&(s.labels=[...n.labels]),n.estimate_hours&&(s.timetracking={originalEstimate:`${n.estimate_hours}h`}),n.assignee){let c=this.assigneeCache.get(n.assignee);c!==void 0&&(s.assignee={accountId:c});}return r&&(s[r]=o),Object.keys(s).length>0&&await this.connector.updateIssue(e,s),n.status?this.applyStatusPath(e,n.status):null}async findExistingTask(e,n){try{let o=Is(`"${e}"`),r=`project = "${Is(n)}" AND summary ~ "${o}"`;return (await this.connector.searchIssues(r)).find(s=>s.summary===e)?.key??null}catch{return null}}async applyStatusPath(e,n){let o=typeof n=="string"?[n]:n;for(let[r,i]of o.entries()){let a;try{a=await this.connector.getTransitions(e);}catch(c){let u=c instanceof Error?c.message:String(c);return `Could not read transitions while moving to "${i}": ${u}`}let s=a.find(c=>c.toStatus.toLowerCase()===i.toLowerCase());if(!s){let c=a.map(l=>l.toStatus).join(", "),u=r===0?"":` (stopped after reaching "${o[r-1]??""}")`;return `Status "${i}" is not reachable${u}. Available from here: ${c||"(none)"}`}try{await this.connector.doTransition(e,s.id);}catch(c){let u=c instanceof Error?c.message:String(c);return `Transition "${s.name}" to "${i}" failed: ${u}`}}return null}async forceReassign(e,n,o){let r=this.assigneeCache.get(n);if(r!==void 0){o>0&&await nT(o);try{await this.connector.assignIssue(e,r);}catch{}}}selectSummary(e,n){if(n!==Yt){let o=e[`summary_${n}`];if(o)return o}return e.summary}selectDescription(e,n){if(n!==Yt){let o=e[`description_${n}`];if(o)return o}return e.description||void 0}};function sA(t){let e=0,n=0,o=0,r=0,i=0;for(let a of t)switch(a.action){case "created":e++;break;case "updated":n++;break;case "failed":o++;break;case "skipped":r++;break;case "preview":i++;break}return {created:e,updated:n,failed:o,skipped:r,previewed:i}}le();le();async function cA(t,e){let{readdir:n,stat:o,access:r}=await import('fs/promises'),{join:i}=await import('path'),a=w0,s=[],c;try{let u=await n(a);c=(await Promise.all(u.map(async d=>{let p=await o(i(a,d));return {name:d,isDir:p.isDirectory()}}))).filter(d=>d.isDir).map(d=>d.name);}catch{return []}for(let u of c){if(t&&u.toUpperCase()!==t.toUpperCase())continue;let l=i(a,u,"monthly_admin.json");try{await r(l),s.push({projectKey:u.toUpperCase(),configPath:l});}catch{}}return s.sort((u,l)=>u.projectKey.localeCompare(l.projectKey)),s}async function oT(t,e){let{readFile:n}=await import('fs/promises'),o=await cA(t.project);if(o.length===0)return {configs:[],totalProcessed:0,totalFailed:0};let i=await(Go)(),s=((l=>new ei(l)))(i),c=[],u=0;for(let l of o)try{let d=await n(l.configPath,"utf-8"),p=JSON.parse(d),m=tT.safeParse(p);if(!m.success){c.push({projectKey:l.projectKey,configPath:l.configPath,error:`Invalid config: ${m.error.message}`}),u++;continue}let h=rT(m.data),z="language"in(p.options??{}),A=h.epic_key.split("-")[0]??"",R=i.projects[A]?.language??i.default_language,q={...h,options:{...h.options,dry_run:t.execute!==!0,...!z&&R?{language:R}:{}}};if(!A){c.push({projectKey:l.projectKey,configPath:l.configPath,error:`Invalid epic_key format: '${q.epic_key}'`}),u++;continue}let Z=s.getConnector(A),ti=await(e?.createBulkCreator??((ri,Vr)=>new tp(ri,Vr)))(Z,A).execute(q);c.push({projectKey:l.projectKey,configPath:l.configPath,result:ti});}catch(d){let p=d instanceof Error?d.message:String(d);c.push({projectKey:l.projectKey,configPath:l.configPath,error:p}),u++;}return {configs:c,totalProcessed:o.length,totalFailed:u}}function uA(t){if(t.error)return {project_key:t.projectKey,config_path:t.configPath,status:"error",error:t.error};if(t.result){let e=t.result.results.filter(n=>n.warning!==null).map(n=>`${n.issue_key??n.summary}: ${n.warning??""}`);return {project_key:t.projectKey,config_path:t.configPath,status:"success",summary:t.result.summary,dry_run:t.result.dry_run,...e.length>0?{warnings:e}:{}}}return {project_key:t.projectKey,config_path:t.configPath,status:"error",error:"No result and no error reported."}}function lA(t,e){return {execute:e,total_processed:t.totalProcessed,total_failed:t.totalFailed,total_succeeded:t.totalProcessed-t.totalFailed,configs:t.configs.map(uA)}}async function iT(t,e){try{let n=await oT({execute:t.execute,project:t.project},e?.createMonthlyDeps);return K(lA(n,t.execute===!0))}catch(n){return M(n)}}function dA(t){return {instanceUrl:t.instanceUrl,async searchIssues(e){return (await t.searchIssues(e)).map(o=>({key:o.key,fields:{summary:o.summary,status:{name:o.status},assignee:o.assignee?{emailAddress:o.assignee}:null,priority:o.priority?{name:o.priority}:null,issuetype:{name:o.issueType},created:o.created,updated:o.updated,project:{key:o.projectKey},customfield_10014:o.epicLink}}))}}}function aT(){return new Nd({name:"@softspark/jira-mcp",version:IS},{capabilities:{tools:{}}})}async function pA(){let t=await Go(),e=new ei(t),{GLOBAL_CACHE_DIR:n}=await Promise.resolve().then(()=>(le(),_0)),o=new Gd(n,t.credentials.username);await o.initialize();let{commentRegistry:r,taskRegistry:i}=D0(),a=new Kd(o,t,(u,l,d)=>dA(e.getConnector(mA(t,u)??""))),s=aT();s.setRequestHandler(Eh,()=>({tools:sv})),s.setRequestHandler(ja,async u=>{let{name:l}=u.params,d=u.params.arguments??{};switch(l){case "sync_tasks":return A0({project_key:ke(d.project_key),jql:ke(d.jql)},{syncer:a});case "read_cached_tasks":return U0({task_key:ke(d.task_key)},{cacheManager:o});case "update_task_status":return Z0({task_key:Ie(d.task_key,"task_key"),status:Ie(d.status,"status")},{pool:e,cacheManager:o});case "add_task_comment":return M0({task_key:Ie(d.task_key,"task_key"),comment:Ie(d.comment,"comment"),user_approved:qr(d.user_approved)},{pool:e,cacheManager:o});case "delete_task":return L0({task_key:Ie(d.task_key,"task_key"),user_approved:qr(d.user_approved)},{pool:e,cacheManager:o});case "delete_comment":return q0({task_key:Ie(d.task_key,"task_key"),comment_id:Ie(d.comment_id,"comment_id"),user_approved:qr(d.user_approved)},{pool:e,cacheManager:o});case "reassign_task":return F0({task_key:Ie(d.task_key,"task_key"),assignee_email:ke(d.assignee_email)},{pool:e,cacheManager:o});case "get_task_statuses":return V0({task_key:Ie(d.task_key,"task_key")},{pool:e,cacheManager:o});case "get_task_details":return J0({task_key:Ie(d.task_key,"task_key")},{pool:e,cacheManager:o,config:t});case "log_task_time":return G0({task_key:Ie(d.task_key,"task_key"),time_spent:Ie(d.time_spent,"time_spent"),comment:ke(d.comment)},{pool:e,cacheManager:o});case "get_task_time_tracking":return K0({task_key:Ie(d.task_key,"task_key")},{pool:e,cacheManager:o});case "list_comment_templates":return H0({category:ke(d.category)},{templateRegistry:r});case "add_templated_comment":return X0({task_key:Ie(d.task_key,"task_key"),template_id:ke(d.template_id),variables:Ts(d.variables),markdown:ke(d.markdown),user_approved:qr(d.user_approved)},{pool:e,cacheManager:o,templateRegistry:r});case "create_task":return Y0({project_key:Ie(d.project_key,"project_key"),summary:ke(d.summary)??"",description:ke(d.description),template_id:ke(d.template_id),variables:Ts(d.variables),type:ke(d.type),priority:ke(d.priority),assignee_email:ke(d.assignee_email),labels:Ss(d.labels),epic_key:ke(d.epic_key),parent_key:ke(d.parent_key),original_estimate:ke(d.original_estimate)},{pool:e,cacheManager:o,taskTemplateRegistry:i});case "list_task_templates":return W0({},{taskTemplateRegistry:i});case "get_project_language":return B0({project_key:Ie(d.project_key,"project_key")},{config:t});case "update_task":return Q0({task_key:Ie(d.task_key,"task_key"),summary:ke(d.summary),description:ke(d.description),priority:ke(d.priority),labels:Ss(d.labels),original_estimate:ke(d.original_estimate),remaining_estimate:ke(d.remaining_estimate)},{pool:e});case "search_tasks":return eT({jql:Ie(d.jql,"jql"),max_results:Jd(d.max_results),project_key:ke(d.project_key)},{pool:e,config:t});case "create_monthly_tasks":return iT({execute:qr(d.execute),project:ke(d.project)});default:return M(new Error(`Unknown tool: ${l}`))}});let c=new Ad;await s.connect(c);}function mA(t,e){for(let[n,o]of Object.entries(t.projects))if(o.url===e)return n}export{aT as createServer,pA as startServer};//# sourceMappingURL=index.js.map
|
|
89
89
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@softspark/jira-mcp",
|
|
3
|
-
"version": "1.14.
|
|
3
|
+
"version": "1.14.4",
|
|
4
4
|
"description": "MCP server for Jira integration \u2014 multi-instance routing, ADF formatting, task caching, and comment templates via the Model Context Protocol.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mcp",
|