@diegoaltoworks/chatter 0.15.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/auth/apikeys.d.ts +0 -1
- package/dist/auth/apikeys.d.ts.map +1 -1
- package/dist/bin/create-apikey.js +1 -3
- package/dist/client/__tests__/markdown.test.d.ts +5 -0
- package/dist/client/__tests__/markdown.test.d.ts.map +1 -0
- package/dist/client/src/Chat.d.ts +1 -0
- package/dist/client/src/Chat.d.ts.map +1 -1
- package/dist/client/src/markdown.d.ts +20 -0
- package/dist/client/src/markdown.d.ts.map +1 -0
- package/dist/core/retrieval.d.ts.map +1 -1
- package/dist/index.js +337 -65
- package/dist/index.mjs +337 -65
- package/dist/mcp-server.d.ts.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/static/chatter.css +121 -0
- package/dist/static/chatter.js +8 -2
- package/package.json +19 -12
package/dist/index.mjs
CHANGED
|
@@ -11,7 +11,11 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
11
11
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
12
12
|
});
|
|
13
13
|
var __commonJS = (cb, mod) => function __require2() {
|
|
14
|
-
|
|
14
|
+
try {
|
|
15
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
16
|
+
} catch (e) {
|
|
17
|
+
throw mod = 0, e;
|
|
18
|
+
}
|
|
15
19
|
};
|
|
16
20
|
var __export = (target, all) => {
|
|
17
21
|
for (var name in all)
|
|
@@ -209,6 +213,145 @@ var require_dist = __commonJS({
|
|
|
209
213
|
}
|
|
210
214
|
}
|
|
211
215
|
};
|
|
216
|
+
var SAFE_URL_RE = /^(https?:|mailto:|\/|#)/i;
|
|
217
|
+
var CODE_PH_OPEN = "CODE";
|
|
218
|
+
var CODE_PH_CLOSE = "ENDCODE";
|
|
219
|
+
function escapeHtml(input) {
|
|
220
|
+
return input.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
221
|
+
}
|
|
222
|
+
function sanitizeUrl(url) {
|
|
223
|
+
const trimmed = url.trim();
|
|
224
|
+
if (!SAFE_URL_RE.test(trimmed)) return "#";
|
|
225
|
+
return escapeHtml(trimmed);
|
|
226
|
+
}
|
|
227
|
+
function renderInline(escaped) {
|
|
228
|
+
const codeSpans = [];
|
|
229
|
+
let out = escaped.replace(/`([^`\n]+)`/g, (_m, code) => {
|
|
230
|
+
const idx = codeSpans.push(code) - 1;
|
|
231
|
+
return `${CODE_PH_OPEN}${idx}${CODE_PH_CLOSE}`;
|
|
232
|
+
});
|
|
233
|
+
out = out.replace(
|
|
234
|
+
/\[([^\]]+)\]\(([^)\s]+)(?:\s+"([^&]*)")?\)/g,
|
|
235
|
+
(_m, text, url, title) => {
|
|
236
|
+
const safeUrl = sanitizeUrl(url);
|
|
237
|
+
const titleAttr = title ? ` title="${title}"` : "";
|
|
238
|
+
return `<a href="${safeUrl}" target="_blank" rel="noopener noreferrer"${titleAttr}>${text}</a>`;
|
|
239
|
+
}
|
|
240
|
+
);
|
|
241
|
+
out = out.replace(/(\*\*|__)(?=\S)([\s\S]+?)(?<=\S)\1/g, "<strong>$2</strong>");
|
|
242
|
+
out = out.replace(/(?<!\*)\*(?!\*)(?=\S)([\s\S]+?)(?<=\S)\*(?!\*)/g, "<em>$1</em>");
|
|
243
|
+
out = out.replace(/(?<![A-Za-z0-9_])_(?=\S)([\s\S]+?)(?<=\S)_(?![A-Za-z0-9_])/g, "<em>$1</em>");
|
|
244
|
+
const placeholderRe = new RegExp(`${CODE_PH_OPEN}(\\d+)${CODE_PH_CLOSE}`, "g");
|
|
245
|
+
out = out.replace(placeholderRe, (_m, idx) => {
|
|
246
|
+
const code = codeSpans[Number(idx)] ?? "";
|
|
247
|
+
return `<code>${code}</code>`;
|
|
248
|
+
});
|
|
249
|
+
return out;
|
|
250
|
+
}
|
|
251
|
+
function flushParagraph(buffer, out) {
|
|
252
|
+
if (buffer.length === 0) return;
|
|
253
|
+
const text = buffer.join("\n");
|
|
254
|
+
const html = renderInline(escapeHtml(text)).replace(/\n/g, "<br>");
|
|
255
|
+
out.push(`<p>${html}</p>`);
|
|
256
|
+
buffer.length = 0;
|
|
257
|
+
}
|
|
258
|
+
function flushList(list, out) {
|
|
259
|
+
if (!list) return null;
|
|
260
|
+
const items = list.items.map((item) => `<li>${renderInline(escapeHtml(item))}</li>`).join("");
|
|
261
|
+
out.push(`<${list.type}>${items}</${list.type}>`);
|
|
262
|
+
return null;
|
|
263
|
+
}
|
|
264
|
+
function flushQuote(quote, out) {
|
|
265
|
+
if (quote.length === 0) return;
|
|
266
|
+
const inner = renderMarkdown(quote.join("\n"));
|
|
267
|
+
out.push(`<blockquote>${inner}</blockquote>`);
|
|
268
|
+
quote.length = 0;
|
|
269
|
+
}
|
|
270
|
+
function renderMarkdown(source) {
|
|
271
|
+
if (!source) return "";
|
|
272
|
+
const lines = source.replace(/\r\n?/g, "\n").split("\n");
|
|
273
|
+
const out = [];
|
|
274
|
+
const paragraph = [];
|
|
275
|
+
const quote = [];
|
|
276
|
+
let list = null;
|
|
277
|
+
let inFence = false;
|
|
278
|
+
let fenceLang = "";
|
|
279
|
+
let fenceBuf = [];
|
|
280
|
+
const closeBlocks = () => {
|
|
281
|
+
flushParagraph(paragraph, out);
|
|
282
|
+
list = flushList(list, out);
|
|
283
|
+
flushQuote(quote, out);
|
|
284
|
+
};
|
|
285
|
+
for (const line of lines) {
|
|
286
|
+
if (inFence) {
|
|
287
|
+
if (/^\s*```\s*$/.test(line)) {
|
|
288
|
+
const code = escapeHtml(fenceBuf.join("\n"));
|
|
289
|
+
const langClass = fenceLang ? ` class="language-${escapeHtml(fenceLang)}"` : "";
|
|
290
|
+
out.push(`<pre><code${langClass}>${code}</code></pre>`);
|
|
291
|
+
fenceBuf = [];
|
|
292
|
+
fenceLang = "";
|
|
293
|
+
inFence = false;
|
|
294
|
+
} else {
|
|
295
|
+
fenceBuf.push(line);
|
|
296
|
+
}
|
|
297
|
+
continue;
|
|
298
|
+
}
|
|
299
|
+
const fenceMatch = line.match(/^\s*```\s*([\w+-]*)\s*$/);
|
|
300
|
+
if (fenceMatch) {
|
|
301
|
+
closeBlocks();
|
|
302
|
+
inFence = true;
|
|
303
|
+
fenceLang = fenceMatch[1] || "";
|
|
304
|
+
continue;
|
|
305
|
+
}
|
|
306
|
+
if (/^\s*$/.test(line)) {
|
|
307
|
+
closeBlocks();
|
|
308
|
+
continue;
|
|
309
|
+
}
|
|
310
|
+
if (/^\s*(?:---|\*\*\*|___)\s*$/.test(line) && paragraph.length === 0) {
|
|
311
|
+
closeBlocks();
|
|
312
|
+
out.push("<hr>");
|
|
313
|
+
continue;
|
|
314
|
+
}
|
|
315
|
+
const headingMatch = line.match(/^(#{1,6})\s+(.*)$/);
|
|
316
|
+
if (headingMatch) {
|
|
317
|
+
closeBlocks();
|
|
318
|
+
const level = headingMatch[1].length;
|
|
319
|
+
const content = renderInline(escapeHtml(headingMatch[2].trim()));
|
|
320
|
+
out.push(`<h${level}>${content}</h${level}>`);
|
|
321
|
+
continue;
|
|
322
|
+
}
|
|
323
|
+
const quoteMatch = line.match(/^\s*>\s?(.*)$/);
|
|
324
|
+
if (quoteMatch) {
|
|
325
|
+
flushParagraph(paragraph, out);
|
|
326
|
+
list = flushList(list, out);
|
|
327
|
+
quote.push(quoteMatch[1]);
|
|
328
|
+
continue;
|
|
329
|
+
}
|
|
330
|
+
if (quote.length > 0) flushQuote(quote, out);
|
|
331
|
+
const ulMatch = line.match(/^\s*[-*+]\s+(.*)$/);
|
|
332
|
+
const olMatch = line.match(/^\s*\d+\.\s+(.*)$/);
|
|
333
|
+
if (ulMatch || olMatch) {
|
|
334
|
+
flushParagraph(paragraph, out);
|
|
335
|
+
const type = ulMatch ? "ul" : "ol";
|
|
336
|
+
const item = ulMatch ? ulMatch[1] : olMatch[1];
|
|
337
|
+
if (!list || list.type !== type) {
|
|
338
|
+
list = flushList(list, out);
|
|
339
|
+
list = { type, items: [] };
|
|
340
|
+
}
|
|
341
|
+
list.items.push(item);
|
|
342
|
+
continue;
|
|
343
|
+
}
|
|
344
|
+
if (list) list = flushList(list, out);
|
|
345
|
+
paragraph.push(line);
|
|
346
|
+
}
|
|
347
|
+
if (inFence) {
|
|
348
|
+
const code = escapeHtml(fenceBuf.join("\n"));
|
|
349
|
+
const langClass = fenceLang ? ` class="language-${escapeHtml(fenceLang)}"` : "";
|
|
350
|
+
out.push(`<pre><code${langClass}>${code}</code></pre>`);
|
|
351
|
+
}
|
|
352
|
+
closeBlocks();
|
|
353
|
+
return out.join("");
|
|
354
|
+
}
|
|
212
355
|
var Chat2 = class {
|
|
213
356
|
constructor(config2) {
|
|
214
357
|
this.messages = [];
|
|
@@ -304,10 +447,11 @@ var require_dist = __commonJS({
|
|
|
304
447
|
await this.bot.streamConversation(this.messages, {
|
|
305
448
|
onChunk: (delta) => {
|
|
306
449
|
assistantMessage.content += delta;
|
|
307
|
-
contentEl
|
|
450
|
+
this.renderMessageContent(contentEl, assistantMessage);
|
|
308
451
|
this.scrollToBottom();
|
|
309
452
|
},
|
|
310
453
|
onEnd: () => {
|
|
454
|
+
this.renderMessageContent(contentEl, assistantMessage);
|
|
311
455
|
this.setInputEnabled(true);
|
|
312
456
|
if (!this.isMobile()) {
|
|
313
457
|
this.inputElement.focus();
|
|
@@ -336,11 +480,21 @@ var require_dist = __commonJS({
|
|
|
336
480
|
addMessageToUI(message) {
|
|
337
481
|
const messageEl = document.createElement("div");
|
|
338
482
|
messageEl.className = `chatter-ui-message chatter-ui-message-${message.role}`;
|
|
339
|
-
|
|
483
|
+
const contentEl = document.createElement("div");
|
|
484
|
+
contentEl.className = "chatter-ui-message-content";
|
|
485
|
+
messageEl.appendChild(contentEl);
|
|
486
|
+
this.renderMessageContent(contentEl, message);
|
|
340
487
|
this.messagesContainer.appendChild(messageEl);
|
|
341
488
|
this.scrollToBottom();
|
|
342
489
|
return messageEl;
|
|
343
490
|
}
|
|
491
|
+
renderMessageContent(target, message) {
|
|
492
|
+
if (message.role === "assistant") {
|
|
493
|
+
target.innerHTML = renderMarkdown(message.content);
|
|
494
|
+
} else {
|
|
495
|
+
target.innerHTML = escapeHtml(message.content).replace(/\n/g, "<br>");
|
|
496
|
+
}
|
|
497
|
+
}
|
|
344
498
|
setInputEnabled(enabled) {
|
|
345
499
|
this.inputElement.disabled = !enabled;
|
|
346
500
|
this.sendButton.disabled = !enabled;
|
|
@@ -3571,6 +3725,9 @@ var require_utils = __commonJS({
|
|
|
3571
3725
|
"use strict";
|
|
3572
3726
|
var isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);
|
|
3573
3727
|
var isIPv4 = RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);
|
|
3728
|
+
var isHexPair = RegExp.prototype.test.bind(/^[\da-f]{2}$/iu);
|
|
3729
|
+
var isUnreserved = RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu);
|
|
3730
|
+
var isPathCharacter = RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);
|
|
3574
3731
|
function stringArrayToHexStripped(input) {
|
|
3575
3732
|
let acc = "";
|
|
3576
3733
|
let code = 0;
|
|
@@ -3763,27 +3920,77 @@ var require_utils = __commonJS({
|
|
|
3763
3920
|
}
|
|
3764
3921
|
return output.join("");
|
|
3765
3922
|
}
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
3923
|
+
var HOST_DELIMS = { "@": "%40", "/": "%2F", "?": "%3F", "#": "%23", ":": "%3A" };
|
|
3924
|
+
var HOST_DELIM_RE = /[@/?#:]/g;
|
|
3925
|
+
var HOST_DELIM_NO_COLON_RE = /[@/?#]/g;
|
|
3926
|
+
function reescapeHostDelimiters(host, isIP) {
|
|
3927
|
+
const re = isIP ? HOST_DELIM_NO_COLON_RE : HOST_DELIM_RE;
|
|
3928
|
+
re.lastIndex = 0;
|
|
3929
|
+
return host.replace(re, (ch) => HOST_DELIMS[ch]);
|
|
3930
|
+
}
|
|
3931
|
+
function normalizePercentEncoding(input, decodeUnreserved = false) {
|
|
3932
|
+
if (input.indexOf("%") === -1) {
|
|
3933
|
+
return input;
|
|
3776
3934
|
}
|
|
3777
|
-
|
|
3778
|
-
|
|
3935
|
+
let output = "";
|
|
3936
|
+
for (let i = 0; i < input.length; i++) {
|
|
3937
|
+
if (input[i] === "%" && i + 2 < input.length) {
|
|
3938
|
+
const hex = input.slice(i + 1, i + 3);
|
|
3939
|
+
if (isHexPair(hex)) {
|
|
3940
|
+
const normalizedHex = hex.toUpperCase();
|
|
3941
|
+
const decoded = String.fromCharCode(parseInt(normalizedHex, 16));
|
|
3942
|
+
if (decodeUnreserved && isUnreserved(decoded)) {
|
|
3943
|
+
output += decoded;
|
|
3944
|
+
} else {
|
|
3945
|
+
output += "%" + normalizedHex;
|
|
3946
|
+
}
|
|
3947
|
+
i += 2;
|
|
3948
|
+
continue;
|
|
3949
|
+
}
|
|
3950
|
+
}
|
|
3951
|
+
output += input[i];
|
|
3779
3952
|
}
|
|
3780
|
-
|
|
3781
|
-
|
|
3953
|
+
return output;
|
|
3954
|
+
}
|
|
3955
|
+
function normalizePathEncoding(input) {
|
|
3956
|
+
let output = "";
|
|
3957
|
+
for (let i = 0; i < input.length; i++) {
|
|
3958
|
+
if (input[i] === "%" && i + 2 < input.length) {
|
|
3959
|
+
const hex = input.slice(i + 1, i + 3);
|
|
3960
|
+
if (isHexPair(hex)) {
|
|
3961
|
+
const normalizedHex = hex.toUpperCase();
|
|
3962
|
+
const decoded = String.fromCharCode(parseInt(normalizedHex, 16));
|
|
3963
|
+
if (decoded !== "." && isUnreserved(decoded)) {
|
|
3964
|
+
output += decoded;
|
|
3965
|
+
} else {
|
|
3966
|
+
output += "%" + normalizedHex;
|
|
3967
|
+
}
|
|
3968
|
+
i += 2;
|
|
3969
|
+
continue;
|
|
3970
|
+
}
|
|
3971
|
+
}
|
|
3972
|
+
if (isPathCharacter(input[i])) {
|
|
3973
|
+
output += input[i];
|
|
3974
|
+
} else {
|
|
3975
|
+
output += escape(input[i]);
|
|
3976
|
+
}
|
|
3782
3977
|
}
|
|
3783
|
-
|
|
3784
|
-
|
|
3978
|
+
return output;
|
|
3979
|
+
}
|
|
3980
|
+
function escapePreservingEscapes(input) {
|
|
3981
|
+
let output = "";
|
|
3982
|
+
for (let i = 0; i < input.length; i++) {
|
|
3983
|
+
if (input[i] === "%" && i + 2 < input.length) {
|
|
3984
|
+
const hex = input.slice(i + 1, i + 3);
|
|
3985
|
+
if (isHexPair(hex)) {
|
|
3986
|
+
output += "%" + hex.toUpperCase();
|
|
3987
|
+
i += 2;
|
|
3988
|
+
continue;
|
|
3989
|
+
}
|
|
3990
|
+
}
|
|
3991
|
+
output += escape(input[i]);
|
|
3785
3992
|
}
|
|
3786
|
-
return
|
|
3993
|
+
return output;
|
|
3787
3994
|
}
|
|
3788
3995
|
function recomposeAuthority(component) {
|
|
3789
3996
|
const uriTokens = [];
|
|
@@ -3798,7 +4005,7 @@ var require_utils = __commonJS({
|
|
|
3798
4005
|
if (ipV6res.isIPV6 === true) {
|
|
3799
4006
|
host = `[${ipV6res.escapedHost}]`;
|
|
3800
4007
|
} else {
|
|
3801
|
-
host =
|
|
4008
|
+
host = reescapeHostDelimiters(host, false);
|
|
3802
4009
|
}
|
|
3803
4010
|
}
|
|
3804
4011
|
uriTokens.push(host);
|
|
@@ -3812,7 +4019,10 @@ var require_utils = __commonJS({
|
|
|
3812
4019
|
module.exports = {
|
|
3813
4020
|
nonSimpleDomain,
|
|
3814
4021
|
recomposeAuthority,
|
|
3815
|
-
|
|
4022
|
+
reescapeHostDelimiters,
|
|
4023
|
+
normalizePercentEncoding,
|
|
4024
|
+
normalizePathEncoding,
|
|
4025
|
+
escapePreservingEscapes,
|
|
3816
4026
|
removeDotSegments,
|
|
3817
4027
|
isIPv4,
|
|
3818
4028
|
isUUID,
|
|
@@ -4036,12 +4246,12 @@ var require_schemes = __commonJS({
|
|
|
4036
4246
|
var require_fast_uri = __commonJS({
|
|
4037
4247
|
"node_modules/fast-uri/index.js"(exports, module) {
|
|
4038
4248
|
"use strict";
|
|
4039
|
-
var { normalizeIPv6, removeDotSegments, recomposeAuthority,
|
|
4249
|
+
var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, escapePreservingEscapes, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils();
|
|
4040
4250
|
var { SCHEMES, getSchemeHandler } = require_schemes();
|
|
4041
4251
|
function normalize(uri, options) {
|
|
4042
4252
|
if (typeof uri === "string") {
|
|
4043
4253
|
uri = /** @type {T} */
|
|
4044
|
-
|
|
4254
|
+
normalizeString(uri, options);
|
|
4045
4255
|
} else if (typeof uri === "object") {
|
|
4046
4256
|
uri = /** @type {T} */
|
|
4047
4257
|
parse3(serialize(uri, options), options);
|
|
@@ -4050,7 +4260,12 @@ var require_fast_uri = __commonJS({
|
|
|
4050
4260
|
}
|
|
4051
4261
|
function resolve(baseURI, relativeURI, options) {
|
|
4052
4262
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
4053
|
-
const
|
|
4263
|
+
const { parsed: baseParsed, malformedAuthorityOrPort: baseMalformed } = parseWithStatus(baseURI, schemelessOptions);
|
|
4264
|
+
const { parsed: relativeParsed, malformedAuthorityOrPort: relativeMalformed } = parseWithStatus(relativeURI, schemelessOptions);
|
|
4265
|
+
if (baseMalformed || relativeMalformed) {
|
|
4266
|
+
throw new Error(baseParsed.error || relativeParsed.error || "URI is malformed.");
|
|
4267
|
+
}
|
|
4268
|
+
const resolved = resolveComponent(baseParsed, relativeParsed, schemelessOptions, true);
|
|
4054
4269
|
schemelessOptions.skipEscape = true;
|
|
4055
4270
|
return serialize(resolved, schemelessOptions);
|
|
4056
4271
|
}
|
|
@@ -4108,19 +4323,9 @@ var require_fast_uri = __commonJS({
|
|
|
4108
4323
|
return target;
|
|
4109
4324
|
}
|
|
4110
4325
|
function equal(uriA, uriB, options) {
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
} else if (typeof uriA === "object") {
|
|
4115
|
-
uriA = serialize(normalizeComponentEncoding(uriA, true), { ...options, skipEscape: true });
|
|
4116
|
-
}
|
|
4117
|
-
if (typeof uriB === "string") {
|
|
4118
|
-
uriB = unescape(uriB);
|
|
4119
|
-
uriB = serialize(normalizeComponentEncoding(parse3(uriB, options), true), { ...options, skipEscape: true });
|
|
4120
|
-
} else if (typeof uriB === "object") {
|
|
4121
|
-
uriB = serialize(normalizeComponentEncoding(uriB, true), { ...options, skipEscape: true });
|
|
4122
|
-
}
|
|
4123
|
-
return uriA.toLowerCase() === uriB.toLowerCase();
|
|
4326
|
+
const normalizedA = normalizeComparableURI(uriA, options);
|
|
4327
|
+
const normalizedB = normalizeComparableURI(uriB, options);
|
|
4328
|
+
return normalizedA !== void 0 && normalizedB !== void 0 && normalizedA.toLowerCase() === normalizedB.toLowerCase();
|
|
4124
4329
|
}
|
|
4125
4330
|
function serialize(cmpts, opts) {
|
|
4126
4331
|
const component = {
|
|
@@ -4145,12 +4350,12 @@ var require_fast_uri = __commonJS({
|
|
|
4145
4350
|
if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(component, options);
|
|
4146
4351
|
if (component.path !== void 0) {
|
|
4147
4352
|
if (!options.skipEscape) {
|
|
4148
|
-
component.path =
|
|
4353
|
+
component.path = escapePreservingEscapes(component.path);
|
|
4149
4354
|
if (component.scheme !== void 0) {
|
|
4150
4355
|
component.path = component.path.split("%3A").join(":");
|
|
4151
4356
|
}
|
|
4152
4357
|
} else {
|
|
4153
|
-
component.path =
|
|
4358
|
+
component.path = normalizePercentEncoding(component.path);
|
|
4154
4359
|
}
|
|
4155
4360
|
}
|
|
4156
4361
|
if (options.reference !== "suffix" && component.scheme) {
|
|
@@ -4185,7 +4390,18 @@ var require_fast_uri = __commonJS({
|
|
|
4185
4390
|
return uriTokens.join("");
|
|
4186
4391
|
}
|
|
4187
4392
|
var URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;
|
|
4188
|
-
|
|
4393
|
+
var AUTHORITY_PREFIX = /^(?:[^#/:?]+:)?\/\/([^/?#]*)/;
|
|
4394
|
+
var AUTHORITY_INTRODUCER_REGION = /^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;
|
|
4395
|
+
function getParseError(parsed, matches) {
|
|
4396
|
+
if (matches[2] !== void 0 && parsed.path && parsed.path[0] !== "/") {
|
|
4397
|
+
return 'URI path must start with "/" when authority is present.';
|
|
4398
|
+
}
|
|
4399
|
+
if (typeof parsed.port === "number" && (parsed.port < 0 || parsed.port > 65535)) {
|
|
4400
|
+
return "URI port is malformed.";
|
|
4401
|
+
}
|
|
4402
|
+
return void 0;
|
|
4403
|
+
}
|
|
4404
|
+
function parseWithStatus(uri, opts) {
|
|
4189
4405
|
const options = Object.assign({}, opts);
|
|
4190
4406
|
const parsed = {
|
|
4191
4407
|
scheme: void 0,
|
|
@@ -4196,6 +4412,7 @@ var require_fast_uri = __commonJS({
|
|
|
4196
4412
|
query: void 0,
|
|
4197
4413
|
fragment: void 0
|
|
4198
4414
|
};
|
|
4415
|
+
let malformedAuthorityOrPort = false;
|
|
4199
4416
|
let isIP = false;
|
|
4200
4417
|
if (options.reference === "suffix") {
|
|
4201
4418
|
if (options.scheme) {
|
|
@@ -4204,6 +4421,25 @@ var require_fast_uri = __commonJS({
|
|
|
4204
4421
|
uri = "//" + uri;
|
|
4205
4422
|
}
|
|
4206
4423
|
}
|
|
4424
|
+
const authorityMatch = uri.match(AUTHORITY_PREFIX);
|
|
4425
|
+
if (authorityMatch !== null && authorityMatch[1].indexOf("\\") !== -1) {
|
|
4426
|
+
parsed.error = "URI authority must not contain a literal backslash.";
|
|
4427
|
+
malformedAuthorityOrPort = true;
|
|
4428
|
+
}
|
|
4429
|
+
const introducerMatch = uri.match(AUTHORITY_INTRODUCER_REGION);
|
|
4430
|
+
if (introducerMatch !== null) {
|
|
4431
|
+
const region = introducerMatch[1];
|
|
4432
|
+
const normalizedRegion = region.replace(/[\t\n\r]/g, "");
|
|
4433
|
+
if (normalizedRegion.length >= 2) {
|
|
4434
|
+
if (normalizedRegion.slice(0, 2) !== "//") {
|
|
4435
|
+
parsed.error = parsed.error || "URI authority must not contain a literal backslash.";
|
|
4436
|
+
malformedAuthorityOrPort = true;
|
|
4437
|
+
} else if (region.length !== normalizedRegion.length) {
|
|
4438
|
+
parsed.error = parsed.error || "URI authority introducer must not contain whitespace.";
|
|
4439
|
+
malformedAuthorityOrPort = true;
|
|
4440
|
+
}
|
|
4441
|
+
}
|
|
4442
|
+
}
|
|
4207
4443
|
const matches = uri.match(URI_PARSE);
|
|
4208
4444
|
if (matches) {
|
|
4209
4445
|
parsed.scheme = matches[1];
|
|
@@ -4216,6 +4452,11 @@ var require_fast_uri = __commonJS({
|
|
|
4216
4452
|
if (isNaN(parsed.port)) {
|
|
4217
4453
|
parsed.port = matches[5];
|
|
4218
4454
|
}
|
|
4455
|
+
const parseError = getParseError(parsed, matches);
|
|
4456
|
+
if (parseError !== void 0) {
|
|
4457
|
+
parsed.error = parsed.error || parseError;
|
|
4458
|
+
malformedAuthorityOrPort = true;
|
|
4459
|
+
}
|
|
4219
4460
|
if (parsed.host) {
|
|
4220
4461
|
const ipv4result = isIPv4(parsed.host);
|
|
4221
4462
|
if (ipv4result === false) {
|
|
@@ -4242,7 +4483,7 @@ var require_fast_uri = __commonJS({
|
|
|
4242
4483
|
if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport)) {
|
|
4243
4484
|
if (parsed.host && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) {
|
|
4244
4485
|
try {
|
|
4245
|
-
parsed.host = URL
|
|
4486
|
+
parsed.host = new URL("http://" + parsed.host).hostname;
|
|
4246
4487
|
} catch (e) {
|
|
4247
4488
|
parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e;
|
|
4248
4489
|
}
|
|
@@ -4254,14 +4495,18 @@ var require_fast_uri = __commonJS({
|
|
|
4254
4495
|
parsed.scheme = unescape(parsed.scheme);
|
|
4255
4496
|
}
|
|
4256
4497
|
if (parsed.host !== void 0) {
|
|
4257
|
-
parsed.host = unescape(parsed.host);
|
|
4498
|
+
parsed.host = reescapeHostDelimiters(unescape(parsed.host), isIP);
|
|
4258
4499
|
}
|
|
4259
4500
|
}
|
|
4260
4501
|
if (parsed.path) {
|
|
4261
|
-
parsed.path =
|
|
4502
|
+
parsed.path = normalizePathEncoding(parsed.path);
|
|
4262
4503
|
}
|
|
4263
4504
|
if (parsed.fragment) {
|
|
4264
|
-
|
|
4505
|
+
try {
|
|
4506
|
+
parsed.fragment = encodeURI(decodeURIComponent(parsed.fragment));
|
|
4507
|
+
} catch {
|
|
4508
|
+
parsed.error = parsed.error || "URI malformed";
|
|
4509
|
+
}
|
|
4265
4510
|
}
|
|
4266
4511
|
}
|
|
4267
4512
|
if (schemeHandler && schemeHandler.parse) {
|
|
@@ -4270,7 +4515,29 @@ var require_fast_uri = __commonJS({
|
|
|
4270
4515
|
} else {
|
|
4271
4516
|
parsed.error = parsed.error || "URI can not be parsed.";
|
|
4272
4517
|
}
|
|
4273
|
-
return parsed;
|
|
4518
|
+
return { parsed, malformedAuthorityOrPort };
|
|
4519
|
+
}
|
|
4520
|
+
function parse3(uri, opts) {
|
|
4521
|
+
return parseWithStatus(uri, opts).parsed;
|
|
4522
|
+
}
|
|
4523
|
+
function normalizeString(uri, opts) {
|
|
4524
|
+
return normalizeStringWithStatus(uri, opts).normalized;
|
|
4525
|
+
}
|
|
4526
|
+
function normalizeStringWithStatus(uri, opts) {
|
|
4527
|
+
const { parsed, malformedAuthorityOrPort } = parseWithStatus(uri, opts);
|
|
4528
|
+
return {
|
|
4529
|
+
normalized: malformedAuthorityOrPort ? uri : serialize(parsed, opts),
|
|
4530
|
+
malformedAuthorityOrPort
|
|
4531
|
+
};
|
|
4532
|
+
}
|
|
4533
|
+
function normalizeComparableURI(uri, opts) {
|
|
4534
|
+
if (typeof uri === "string") {
|
|
4535
|
+
const { normalized, malformedAuthorityOrPort } = normalizeStringWithStatus(uri, opts);
|
|
4536
|
+
return malformedAuthorityOrPort ? void 0 : normalized;
|
|
4537
|
+
}
|
|
4538
|
+
if (typeof uri === "object") {
|
|
4539
|
+
return serialize(uri, opts);
|
|
4540
|
+
}
|
|
4274
4541
|
}
|
|
4275
4542
|
var fastUri = {
|
|
4276
4543
|
SCHEMES,
|
|
@@ -7268,15 +7535,13 @@ var require_dist2 = __commonJS({
|
|
|
7268
7535
|
import { randomUUID } from "node:crypto";
|
|
7269
7536
|
import { jwtVerify, SignJWT } from "jose";
|
|
7270
7537
|
var ApiKeyManager = class {
|
|
7538
|
+
secretBytes;
|
|
7271
7539
|
constructor(secret) {
|
|
7272
|
-
this.secret = secret;
|
|
7273
7540
|
if (!secret) {
|
|
7274
7541
|
throw new Error("API key secret is required");
|
|
7275
7542
|
}
|
|
7276
7543
|
this.secretBytes = new TextEncoder().encode(secret);
|
|
7277
7544
|
}
|
|
7278
|
-
secret;
|
|
7279
|
-
secretBytes;
|
|
7280
7545
|
/**
|
|
7281
7546
|
* Create a new API key
|
|
7282
7547
|
*
|
|
@@ -15680,17 +15945,33 @@ function normalizeObjectSchema(schema) {
|
|
|
15680
15945
|
}
|
|
15681
15946
|
return void 0;
|
|
15682
15947
|
}
|
|
15948
|
+
function getDotPath(path) {
|
|
15949
|
+
if (path.length === 0) {
|
|
15950
|
+
return "object root";
|
|
15951
|
+
}
|
|
15952
|
+
return path.reduce((acc, seg, index) => {
|
|
15953
|
+
if (index === 0) {
|
|
15954
|
+
return String(seg);
|
|
15955
|
+
}
|
|
15956
|
+
if (typeof seg === "number") {
|
|
15957
|
+
return `${acc}[${seg}]`;
|
|
15958
|
+
}
|
|
15959
|
+
return `${acc}.${seg}`;
|
|
15960
|
+
}, "");
|
|
15961
|
+
}
|
|
15683
15962
|
function getParseErrorMessage(error2) {
|
|
15684
15963
|
if (error2 && typeof error2 === "object") {
|
|
15964
|
+
if ("issues" in error2 && Array.isArray(error2.issues) && error2.issues.length > 0) {
|
|
15965
|
+
return error2.issues.map((i) => {
|
|
15966
|
+
if (!i.path?.length) {
|
|
15967
|
+
return i.message;
|
|
15968
|
+
}
|
|
15969
|
+
return `${i.message} at ${getDotPath(i.path)}`;
|
|
15970
|
+
}).join("\n");
|
|
15971
|
+
}
|
|
15685
15972
|
if ("message" in error2 && typeof error2.message === "string") {
|
|
15686
15973
|
return error2.message;
|
|
15687
15974
|
}
|
|
15688
|
-
if ("issues" in error2 && Array.isArray(error2.issues) && error2.issues.length > 0) {
|
|
15689
|
-
const firstIssue = error2.issues[0];
|
|
15690
|
-
if (firstIssue && typeof firstIssue === "object" && "message" in firstIssue) {
|
|
15691
|
-
return String(firstIssue.message);
|
|
15692
|
-
}
|
|
15693
|
-
}
|
|
15694
15975
|
try {
|
|
15695
15976
|
return JSON.stringify(error2);
|
|
15696
15977
|
} catch {
|
|
@@ -20633,16 +20914,7 @@ var Server = class extends Protocol {
|
|
|
20633
20914
|
if (!methodSchema) {
|
|
20634
20915
|
throw new Error("Schema is missing a method literal");
|
|
20635
20916
|
}
|
|
20636
|
-
|
|
20637
|
-
if (isZ4Schema(methodSchema)) {
|
|
20638
|
-
const v4Schema = methodSchema;
|
|
20639
|
-
const v4Def = v4Schema._zod?.def;
|
|
20640
|
-
methodValue = v4Def?.value ?? v4Schema.value;
|
|
20641
|
-
} else {
|
|
20642
|
-
const v3Schema = methodSchema;
|
|
20643
|
-
const legacyDef = v3Schema._def;
|
|
20644
|
-
methodValue = legacyDef?.value ?? v3Schema.value;
|
|
20645
|
-
}
|
|
20917
|
+
const methodValue = getLiteralValue(methodSchema);
|
|
20646
20918
|
if (typeof methodValue !== "string") {
|
|
20647
20919
|
throw new Error("Schema method literal must be a string");
|
|
20648
20920
|
}
|
package/dist/mcp-server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-server.d.ts","sourceRoot":"","sources":["../src/mcp-server.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"mcp-server.d.ts","sourceRoot":"","sources":["../src/mcp-server.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAYpE,YAAY,EACV,WAAW,EACX,QAAQ,EACR,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,eAAe,CAAC,MAAM,EAAE,gBAAgB,sBAuS7D"}
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAW5B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7C;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,MAAM,EAAE,aAAa,uFAiJvD"}
|